diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53c3407 --- /dev/null +++ b/.gitignore @@ -0,0 +1,343 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +runtime/ +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +GeneratedFiles/ +model/ +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb diff --git a/Cigarette.sln b/Cigarette.sln new file mode 100644 index 0000000..1126f22 --- /dev/null +++ b/Cigarette.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cigarette", "Cigarette\Cigarette.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CigaretteSingle", "CigaretteSingle\CigaretteSingle.vcxproj", "{795A8611-044A-46D3-8DD9-13A338925BC4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x64.ActiveCfg = Debug|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x64.Build.0 = Debug|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x86.ActiveCfg = Debug|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x86.Build.0 = Debug|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x64.ActiveCfg = Release|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x64.Build.0 = Release|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x86.ActiveCfg = Release|x64 + {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x86.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0AF1A30E-A12C-4014-ACD5-65A1E6D54D46} + Qt5Version = 5.15.2_msvc2019_64 + EndGlobalSection +EndGlobal diff --git a/Cigarette/ASyncQueue.cpp b/Cigarette/ASyncQueue.cpp new file mode 100644 index 0000000..a019c79 --- /dev/null +++ b/Cigarette/ASyncQueue.cpp @@ -0,0 +1,3 @@ +#include "ASyncQueue.h" + + diff --git a/Cigarette/ASyncQueue.h b/Cigarette/ASyncQueue.h new file mode 100644 index 0000000..b4d004e --- /dev/null +++ b/Cigarette/ASyncQueue.h @@ -0,0 +1,81 @@ +#pragma once +#include +//#include +#include +#include + +using namespace std; + +template class ASyncQueue +{ +public: + ASyncQueue(int max_size); + ~ASyncQueue(); + void put(const T& val); + void take(T& val); + void clear(); + bool isEmpty(); + bool isFull(); + int count(); +public: + string name; +private: + mutex lock; + //condition_variable_any cv_full, cv_empty; + list q; + int size; + int max_size; +}; + +using namespace std; + +template +ASyncQueue::ASyncQueue(int max_size) :max_size(max_size) +{ +} + +template +ASyncQueue::~ASyncQueue() +{ +} + +template +void ASyncQueue::put(const T& val) +{ + lock_guard locker(lock); + q.emplace_back(val); +} + +template +void ASyncQueue::take(T& val) +{ + lock_guard locker(lock); + val = q.front(); + q.pop_front(); +} + +template +void ASyncQueue::clear() +{ + lock_guard locker(lock); + q.clear(); +} + +template +bool ASyncQueue::isEmpty() +{ + return q.size() == 0; +} + +template +bool ASyncQueue::isFull() +{ + return q.size() == max_size; +} + +template +int ASyncQueue::count() +{ + lock_guard locker(lock); + return q.size(); +} \ No newline at end of file diff --git a/Cigarette/AlarmInfo.cpp b/Cigarette/AlarmInfo.cpp new file mode 100644 index 0000000..9728b74 --- /dev/null +++ b/Cigarette/AlarmInfo.cpp @@ -0,0 +1,12 @@ +#include "AlarmInfo.h" + + + +AlarmInfo::AlarmInfo() +{ +} + + +AlarmInfo::~AlarmInfo() +{ +} diff --git a/Cigarette/AlarmInfo.h b/Cigarette/AlarmInfo.h new file mode 100644 index 0000000..4bee866 --- /dev/null +++ b/Cigarette/AlarmInfo.h @@ -0,0 +1,15 @@ +#pragma once +#include +class AlarmInfo +{ +public: + AlarmInfo(); + ~AlarmInfo(); + +public: + std::string alarm_start; //ʱ + std::string alarm_handle; //ʱ + std::string alarm_msg; //Ϣ + int alarm_code; // +}; + diff --git a/Cigarette/CaptureThread.cpp b/Cigarette/CaptureThread.cpp new file mode 100644 index 0000000..d2c858a --- /dev/null +++ b/Cigarette/CaptureThread.cpp @@ -0,0 +1,150 @@ +#include "CaptureThread.h" +#include "common.h" + +extern bool g_debug_mode; //ģʽģʽͣ״̬ܴ + +//----------------------------------------------------------------------------- +CaptureThread::CaptureThread( Device* pCurrDev, bool boTerminated, FunctionInterface* pFI_ ,int Num) : + pDev_( pCurrDev ), boTerminated_( boTerminated ), requestPendingForDisplay_( INVALID_ID ), pFI_( pFI_ ),Local_Num(Num) +//----------------------------------------------------------------------------- +{ + p_unit_queue = new ASyncQueue(Unit_Queue_Size); +} +CaptureThread::~CaptureThread() +{ + delete p_unit_queue; +} +//----------------------------------------------------------------------------- +void CaptureThread::process( void ) +//----------------------------------------------------------------------------- +{ + try + { + //Line5ص + mvIMPACT::acquire::GenICam::EventControl pEventCtrl_(pDev_); + //pEventCtrl_.eventSelector.writeS("Line5FallingEdge"); + //pEventCtrl_.eventNotification.writeS("Off"); + //pEventCtrl_.eventSelector.writeS("Line5RisingEdge"); + //pEventCtrl_.eventNotification.writeS("Off"); + pEventCtrl_.eventSelector.writeS("Line5AnyEdge"); +#ifdef IMM_PROCESS + pEventCtrl_.eventNotification.writeS("Off"); +#else + pEventCtrl_.eventNotification.writeS("On"); +#endif + +#ifndef IMM_PROCESS + EventCallback eventCallback(&pEventCtrl_); + eventCallback.p_unit_queue_ = p_unit_queue; + eventCallback.p_image_queue_ = p_image_queue; + eventCallback.p_result_wait_queue_ = p_result_wait_queue; + eventCallback.p_shooted_queue_ = p_shooted_queue; + eventCallback.p_double_queue_ = p_double_queue; + eventCallback.m_pMVCamera = pDev_; + eventCallback.pCaptureThread = this; + eventCallback.registerComponent(pEventCtrl_.eventLine5AnyEdge); +#endif + + m_threadFunc.m_pMVCamera = pDev_; + m_threadFunc.p_result_queue_ = p_result_queue; + m_threadFunc.p_double_queue_ = p_double_queue; + + //߻ص + CIwtCameraLostCallbackMV cam_lost_cb; + cam_lost_cb.channel_ = Local_Num; + /*if (cam_lost_cb.registerComponent(pDev_->state) != true) + { + std::cout << "ERROR: Unable to register the camera's lost CallBack function!\n"; + }*/ //ε߻صֹ󱨾 + //ͼɼѭ + TDMR_ERROR result = DMR_NO_ERROR; + while( ( result = static_cast< TDMR_ERROR >( pFI_->imageRequestSingle() ) ) == DMR_NO_ERROR ) {}; + if( result != DEV_NO_FREE_REQUEST_AVAILABLE ) + { + qDebug() << "'FunctionInterface.imageRequestSingle' returned with an unexpected result: " << QString::fromStdString( mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString( result ) ); + } + manuallyStartAcquisitionIfNeeded( pDev_, *pFI_ ); + int cnt = 0; + + // run thread loop + mvIMPACT::acquire::Statistics statistics( pDev_ ); + mvIMPACT::acquire::Request* pRequest = 0; + mvIMPACT::acquire::Request* pPreviousRequest = nullptr; + const unsigned int timeout_ms = 200; + Ready = true; + while( !boTerminated_ ) + { + const int requestNr = pFI_->imageRequestWaitFor( timeout_ms ); + pRequest = pFI_->isRequestNrValid( requestNr ) ? pFI_->getRequest( requestNr ) : 0; + if( pRequest ) + { + if (pRequest->isOK()) + { + // do something with the image + int openCVDataType = CV_8UC1; + if ((pRequest->imagePixelFormat.read() == ibpfBGR888Packed) || (pRequest->imagePixelFormat.read() == ibpfRGB888Packed)) + openCVDataType = CV_8UC3; + cv::Mat openCVImage(cv::Size(pRequest->imageWidth.read(), pRequest->imageHeight.read()), openCVDataType, pRequest->imageData.read(), pRequest->imageLinePitch.read()); + cv::Mat image_clone = openCVImage.clone(); + if (!g_debug_mode) + { +#ifdef IMM_PROCESS + p_image_queue->put(std::make_pair(1,image_clone)); //ʱ +#else + p_unit_queue->put(image_clone); //ʱ +#endif + } + else + { + p_debug_queue->put(image_clone); //Զ + } + cnt++; + // display some statistics + if (cnt % 100 == 0) + { + QString data = QString::fromStdString(statistics.framesPerSecond.readS()); + emit updateStatistics(data.left(4),Local_Num); + } + } + else + { + // some error: pRequest->requestResult.readS() will return a string representation + } + // this image has been used thus the buffer is no longer needed... + if (pPreviousRequest) + { + // this image has been displayed thus the buffer is no longer needed... + pPreviousRequest->unlock(); + } + pPreviousRequest = pRequest; + // send a new image request into the capture queue + pFI_->imageRequestSingle(); + } +#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK) + m_threadFunc.SendFeedBack(ImageCap); +#endif + } + manuallyStopAcquisitionIfNeeded( pDev_, *pFI_ ); + if( pRequest ) + { + pRequest->unlock(); + } + pFI_->imageRequestReset( 0, 0 ); + } + catch( const ImpactAcquireException& e ) + { + emit error( QString::fromStdString( e.getErrorCodeAsString() ) ); + } +} + +//----------------------------------------------------------------------------- +int CaptureThread::getPendingRequestNr( void ) +//----------------------------------------------------------------------------- +{ + QMutexLocker lockedScope( &lock_ ); + int result = requestPendingForDisplay_; + // Reset the ID of the request to tell the capture loop that this request has already been + // picked up and someone else will take care of it from now on. + requestPendingForDisplay_ = INVALID_ID; + return result; +} \ No newline at end of file diff --git a/Cigarette/CaptureThread.h b/Cigarette/CaptureThread.h new file mode 100644 index 0000000..264393b --- /dev/null +++ b/Cigarette/CaptureThread.h @@ -0,0 +1,241 @@ +//----------------------------------------------------------------------------- +#ifndef CaptureThreadH +#define CaptureThreadH CaptureThreadH +//----------------------------------------------------------------------------- +#include "balluffcamera.h" +#include +#include +#include +#include + +#include "SyncQueue.h" +#include "ASyncQueue.h" + +#include "apps/Common/exampleHelper.h" +#include +#include + +#include + +#include + +extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; + +class CaptureThread_Func +{ +public: + Device* m_pMVCamera; + ASyncQueue *p_result_queue_; + ASyncQueue *p_double_queue_; + void SendFeedBack(int OpID) + { + bool send_ng=false; + bool send_ok=false; + if(OpID == EdgeEvent) + { +#if defined DOUBLE_FEED_BACK + if(p_double_queue_->count() > 0) + { + bool temp; + p_double_queue_->take(temp); + send_ng=true; + } +#endif + } + if (p_result_queue_->count() > 0) + { + bool result; + p_result_queue_->take(result); + if (!result) + { +#if defined DOUBLE_FEED_BACK + p_double_queue_->put(true); +#endif + send_ng=true; + } + else + { + send_ok=true; + } + } + try + { + mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(m_pMVCamera); + if(send_ng){ + mvDIOC.userOutputSelector.writeS("UserOutput0"); + mvIMPACT::acquire::TBoolean tb = mvDIOC.userOutputValue.read(); + if (tb == bFalse) + mvDIOC.userOutputValue.write(bTrue); + else + mvDIOC.userOutputValue.write(bFalse); + } + else if (send_ok) + { + mvDIOC.userOutputSelector.writeS("UserOutput1"); + mvIMPACT::acquire::TBoolean tb = mvDIOC.userOutputValue.read(); + if (tb == bFalse) + mvDIOC.userOutputValue.write(bTrue); + else + mvDIOC.userOutputValue.write(bFalse); + } + } + catch (const ImpactAcquireException& e) + { + std::cout<< "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << std::endl; + } + } +}; + +class CaptureThread : public QObject +//----------------------------------------------------------------------------- +{ + Q_OBJECT + +public: + explicit CaptureThread( Device* pCurrDev, bool boTerminated, FunctionInterface* pFi ,int Num); + CaptureThread::~CaptureThread(void); + void terminate( void ) + { + boTerminated_ = true; + } + int getPendingRequestNr(); + +signals: + void error( QString err ); + void finished( void ); + void requestReady( void ); + void updateStatistics( const QString& data ,int Num); + +private slots: + void process( void ); + +public: + int Local_Num; + SyncQueue > *p_image_queue; + ASyncQueue *p_unit_queue; + ASyncQueue *p_result_queue; + ASyncQueue *p_result_wait_queue; + ASyncQueue *p_double_queue; + ASyncQueue *p_shooted_queue; + SyncQueue *p_debug_queue; + bool Ready = false; + CaptureThread_Func m_threadFunc; +private: + Device* pDev_; + volatile bool boTerminated_; + int requestPendingForDisplay_; + FunctionInterface* pFI_; + QMutex lock_; +}; + +//============================================================================= +//================= Camera's property callback ================================ +//============================================================================= +class EventCallback : public mvIMPACT::acquire::ComponentCallback +{ +public: + ASyncQueue *p_unit_queue_; + SyncQueue > *p_image_queue_; + ASyncQueue *p_result_wait_queue_; + ASyncQueue *p_shooted_queue_; + ASyncQueue *p_double_queue_; + explicit EventCallback(void* pUserData = 0) : ComponentCallback(pUserData) {} + Device* m_pMVCamera; + CaptureThread* pCaptureThread = NULL; + int count = 0; + + virtual void execute(Component& c, void* pUserData) + { + try + { + // re-generating the object/data previously attached to the callback object. This could now be used to call a certain member function e.g. to update a class instance about this event! + mvIMPACT::acquire::GenICam::EventControl* ec = reinterpret_cast(pUserData); + // Execute the followings if the component is a property. + if (c.isProp()) + { + mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(m_pMVCamera); + mvDIOC.lineSelector.writeS("Line5"); + if (mvDIOC.lineStatus.read()) + { +#ifdef IMM_FEED_BACK + if (p_shooted_queue_->count() > 0) + { + bool temp; + p_shooted_queue_->take(temp); + } +#elif defined ONE_TIME_SHIFT + if ( + p_shooted_queue_->count() > 0 +#if defined DOUBLE_FEED_BACK + || p_double_queue_->count() >0 +#endif + ) + { + if (p_shooted_queue_->count() > 0){ + bool temp; + p_shooted_queue_->take(temp); + } + pCaptureThread->m_threadFunc.SendFeedBack(EdgeEvent); + } +#else + if (p_result_wait_queue_->count() > 0) + { + bool temp; + p_result_wait_queue_->take(temp); + pCaptureThread->m_threadFunc.SendFeedBack(EdgeEvent); + } + if (p_shooted_queue_->count() > 0) + { + bool temp; + p_shooted_queue_->take(temp); + p_result_wait_queue_->put(true); + } +#endif + } + else + { + int unit_count = p_unit_queue_->count(); + if (unit_count > 0) + { + cv::Mat long_image; + for (int i = 0; i < unit_count; i++) + { + cv::Mat image; + p_unit_queue_->take(image); + if (0 == i) + { + long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type()); + } + cv::Rect r(0, i * image.rows, image.cols, image.rows); + cv::Mat roi = long_image(r); + image.copyTo(roi); + } + p_image_queue_->put(std::make_pair(unit_count, long_image)); + p_shooted_queue_->put(true); + } + p_unit_queue_->clear(); + } + } + } + catch (const ImpactAcquireException& e) + { + qDebug() << "Error"; + } + } +}; + +class CIwtCameraLostCallbackMV : public mvIMPACT::acquire::ComponentCallback +{ +public: + CIwtCameraLostCallbackMV() : ComponentCallback() {} + int channel_; + virtual void execute(mvIMPACT::acquire::Component& c, void* pDummy) + { + PropertyIDeviceState p(c); + std::cout << p.name() << " = " << p.readS() << endl; + SingleCamInfo[channel_].OffLine = true; + } +}; + +//----------------------------------------------------------------------------- +#endif // CaptureThreadH diff --git a/Cigarette/CaptureThreadBasler.cpp b/Cigarette/CaptureThreadBasler.cpp new file mode 100644 index 0000000..3bb6176 --- /dev/null +++ b/Cigarette/CaptureThreadBasler.cpp @@ -0,0 +1,174 @@ +#include "CaptureThreadBasler.h" +#include +#include "PLCDevice.h" +#include "common.h" +#include +extern PLCDevice * m_PLCDevice; +//----------------------------------------------------------------------------- +CaptureThreadBasler::CaptureThreadBasler(Pylon::CBaslerUniversalInstantCamera* pCurrDev, bool boTerminated,int Num,int shoot) : + pDev_( pCurrDev ), boTerminated_( boTerminated ),Local_Num(Num) +//----------------------------------------------------------------------------- +{ + p_unit_queue = new ASyncQueue(Unit_Queue_Size); + Shoot_Num = shoot; +} +CaptureThreadBasler::~CaptureThreadBasler() +{ + delete p_unit_queue; +} +//----------------------------------------------------------------------------- +void CaptureThreadBasler::process(void) +//----------------------------------------------------------------------------- +{ + bool last_high = false; + bool last_result = false; + try + { + CSampleConfigurationEventHandler CfgEvent; + CfgEvent.channel_ = Local_Num; + //pDev_->RegisterConfiguration(&CfgEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + pDev_->RegisterConfiguration(&CfgEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_Delete); + + CSampleImageEventHandler ImageEvent; + ImageEvent.p_image_queue_ = p_image_queue; + ImageEvent.p_unit_queue_ = p_unit_queue; + ImageEvent.p_shooted_queue_ = p_shooted_queue; + ImageEvent.p_debug_queue_ = p_debug_queue; + ImageEvent.m_cntGrabbedImages_ = &m_cntGrabbedImages; + ImageEvent.Shoot_Num_ = Shoot_Num; + ImageEvent.pDev__ = pDev_; + pDev_->RegisterImageEventHandler(&ImageEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + + CSampleCameraEventHandler BurstEvent; + BurstEvent.p_unit_queue_ = p_unit_queue; + BurstEvent.p_result_wait_queue_ = p_result_wait_queue; + BurstEvent.p_result_queue_ = p_result_queue; + BurstEvent.p_shooted_queue_ = p_shooted_queue; + BurstEvent.p_double_queue_ = p_double_queue; + BurstEvent.p_image_queue_ = p_image_queue; + BurstEvent.pDev__ = pDev_; + BurstEvent.pCaptureThreadBasler = this; + + m_threadFunc.pDev__ = pDev_; + m_threadFunc.p_result_queue_ = p_result_queue; + m_threadFunc.p_double_queue_ = p_double_queue; + m_threadFunc.m_IOTimer_ = m_IOTimer; +#ifndef USB_BASLER_NEW_FW + if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart)) + { + pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_On); + pDev_->TriggerSource.SetValue(Basler_UniversalCameraParams::TriggerSource_Line1); + pDev_->TriggerActivation.SetValue(Basler_UniversalCameraParams::TriggerActivation_RisingEdge); + pDev_->AcquisitionBurstFrameCount.SetValue(Shoot_Num); + if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart)) + { + if (!pDev_->EventNotification.TrySetValue(Basler_UniversalCameraParams::EventNotification_On)) + { + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_GenICamEvent); + } + + m_IOTimer = new QTimer(); + connect(m_IOTimer, SIGNAL(timeout()), this, SLOT(ioTimeout())); + m_IOTimer->setSingleShot(true); + BurstEvent.ioTimer = m_IOTimer; + pDev_->RegisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData", eMyFrameBurstStartEvent, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + } + + if(pDev_->EventSelector.TrySetValue("Line1RisingEdge")) + { + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); + } + if(pDev_->EventSelector.TrySetValue("Line1FallingEdge")) + { + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); + } + } +#else + /*Set here*/ + if (pDev_->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart)) + { + DEBUG(" TriggerSelector_FrameBurstStart\n"); + pDev_->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off); + if(pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart)) + { + DEBUG(" EventSelector_FrameBurstStart\n"); + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); + } + } + + pDev_->RegisterCameraEventHandler(&BurstEvent, "EventLine1RisingEdgeData", Line1RisingEdge, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + pDev_->EventSelector.SetValue("Line1RisingEdge"); +#ifdef IMM_PROCESS + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); +#else + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_On); +#endif + pDev_->RegisterCameraEventHandler(&BurstEvent, "EventLine1FallingEdgeData", Line1FallingEdge, Pylon::RegistrationMode_Append, Pylon::Cleanup_None); + pDev_->EventSelector.SetValue("Line1FallingEdge"); +#ifdef IMM_PROCESS + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_Off); +#else + pDev_->EventNotification.SetValue(Basler_UniversalCameraParams::EventNotification_On); +#endif + +#endif + const unsigned int timeout_ms = 200; + // This smart pointer will receive the grab result data. + Pylon::CGrabResultPtr ptrGrabResult; + + pDev_->StartGrabbing(); + + m_Timer = new QTimer(); + connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout())); + m_Timer->start(1000); + Ready = true; + while (!boTerminated_) + { + // Retrieve grab results and notify the camera event and image event handlers. + pDev_->RetrieveResult(timeout_ms, ptrGrabResult, Pylon::TimeoutHandling_Return); +#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK) + m_threadFunc.SendFeedBack(ImageCap); +#endif + QCoreApplication::processEvents();//Make sure the timer is triggered + } +#ifndef USB_BASLER_NEW_FW + // Disable sending Event Overrun events. + if (pDev_->EventSelector.TrySetValue(Basler_UniversalCameraParams::EventSelector_FrameBurstStart)) + { + pDev_->EventNotification.TrySetValue(Basler_UniversalCameraParams::EventNotification_Off); + } + if (m_IOTimer) delete m_IOTimer; +#endif + if (m_Timer) delete m_Timer; + pDev_->StopGrabbing(); + pDev_->DeregisterConfiguration(&CfgEvent); + pDev_->DeregisterImageEventHandler(&ImageEvent); +#ifndef USB_BASLER_NEW_FW + pDev_->DeregisterCameraEventHandler(&BurstEvent, "EventFrameBurstStartData"); +#endif + } + catch(const Pylon::GenericException& e) + { + emit error( QString::fromStdString( e.GetDescription()) ); + std::cout << e.GetSourceLine()<StopGrabbing(); + } +} + +void CaptureThreadBasler::fpsTimeout() +{ + uint64_t delta = m_cntGrabbedImages - m_cntLastGrabbedImages; + m_cntLastGrabbedImages = m_cntGrabbedImages; + QString data = QString("%1").arg(delta); + emit updateStatistics(data.left(4), Local_Num); +} + +void CaptureThreadBasler::ioTimeout() +{ + pDev_->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput1); + pDev_->UserOutputValue.SetValue(false); + + pDev_->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput3); + pDev_->UserOutputValue.SetValue(false); + +} \ No newline at end of file diff --git a/Cigarette/CaptureThreadBasler.h b/Cigarette/CaptureThreadBasler.h new file mode 100644 index 0000000..dfdc729 --- /dev/null +++ b/Cigarette/CaptureThreadBasler.h @@ -0,0 +1,359 @@ +//----------------------------------------------------------------------------- +#ifndef CaptureThreadBaslerH +#define CaptureThreadBaslerH CaptureThreadBaslerH +//----------------------------------------------------------------------------- +#include "baslercamera.h" +#include +#include +#include + +#include "SyncQueue.h" +#include "ASyncQueue.h" +#include "common.h" +#include + +extern bool g_debug_mode; +extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; +enum MyEvents +{ + eMyFrameBurstStartEvent = 100, + Line1RisingEdge = 200, + Line1FallingEdge = 300 + // More events can be added here. +}; + +class CaptureThreadBasler_Func +{ +public: + Pylon::CBaslerUniversalInstantCamera* pDev__; + ASyncQueue *p_result_queue_; + ASyncQueue *p_double_queue_; + QTimer *m_IOTimer_ = NULL; + void SendFeedBack(int OpID) + { + bool send_ng=false; + bool send_ok=false; + if(OpID == EdgeEvent) + { +#if defined DOUBLE_FEED_BACK + if(p_double_queue_->count() > 0) + { + bool temp; + p_double_queue_->take(temp); + send_ng=true; + } +#endif + } + if (p_result_queue_->count() > 0) + { + bool result; + p_result_queue_->take(result); + if (!result) { +#if defined DOUBLE_FEED_BACK + p_double_queue_->put(true); +#endif + send_ng=true; + } + else + { + send_ok=true; + } + } +#ifndef USB_BASLER_NEW_FW + if (send_ng) { + pDev__->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput3); + pDev__->UserOutputValue.SetValue(true); + } + else if (send_ok) { + pDev__->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput1); + pDev__->UserOutputValue.SetValue(true); + } + m_IOTimer_->start(StrobeLineTime / 2000); +#else + if (send_ng) { + pDev__->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput3); + pDev__->UserOutputValue.SetValue(false); + pDev__->UserOutputValue.SetValue(true); + } + else if (send_ok) { + pDev__->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput1); + pDev__->UserOutputValue.SetValue(false); + pDev__->UserOutputValue.SetValue(true); + } +#endif + } +}; + +//----------------------------------------------------------------------------- +class CaptureThreadBasler : public QObject +{ + Q_OBJECT + +public: + explicit CaptureThreadBasler(Pylon::CBaslerUniversalInstantCamera* pCurrDev, bool boTerminated,int Num,int shoot); + CaptureThreadBasler::~CaptureThreadBasler(void); + void terminate( void ) + { + boTerminated_ = true; + } + +signals: + void error( QString err ); + void finished( void ); + void requestReady( void ); + void updateStatistics( const QString& data ,int Num); + +private slots: + void process( void ); + void fpsTimeout(void); + void ioTimeout(void); + +public: + int Local_Num; + int Shoot_Num; + SyncQueue > *p_image_queue; + ASyncQueue *p_unit_queue; + ASyncQueue *p_result_queue; + ASyncQueue *p_result_wait_queue; + ASyncQueue *p_double_queue; + ASyncQueue *p_shooted_queue; + SyncQueue *p_debug_queue; + QTimer *m_Timer = NULL,*m_IOTimer = NULL; + uint64_t m_cntGrabbedImages = 0; + uint64_t m_cntLastGrabbedImages = 0; + bool Ready = false; + CaptureThreadBasler_Func m_threadFunc; +private: + Pylon::CBaslerUniversalInstantCamera* pDev_; + volatile bool boTerminated_; + QMutex lock_; +}; +//----------------------------------------------------------------------------- +class CSampleConfigurationEventHandler : public Pylon::CConfigurationEventHandler +{ +public: + int channel_; + // This method is called from a different thread when the camera device removal has been detected. + void OnCameraDeviceRemoved(Pylon::CInstantCamera& camera) + { + SingleCamInfo[channel_].OffLine = true; + } +}; + +// Example handler for camera events. +class CSampleCameraEventHandler : public Pylon::CBaslerUniversalCameraEventHandler +{ +public: + QTimer * ioTimer; + ASyncQueue* p_unit_queue_; + ASyncQueue *p_result_wait_queue_; + ASyncQueue *p_result_queue_; + ASyncQueue *p_double_queue_; + ASyncQueue *p_shooted_queue_; + SyncQueue >* p_image_queue_; + Pylon::CBaslerUniversalInstantCamera* pDev__; + CaptureThreadBasler* pCaptureThreadBasler = NULL; + // Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the + // processing of images. + virtual void OnCameraEvent(Pylon::CBaslerUniversalInstantCamera& camera, intptr_t userProvidedId, GenApi::INode* pNode) + { + switch (userProvidedId) + { +#ifndef USB_BASLER_NEW_FW + case eMyFrameBurstStartEvent: + { +#ifdef IMM_FEED_BACK + if (p_shooted_queue_->count() > 0) + { + bool temp; + p_shooted_queue_->take(temp); + } +#elif defined ONE_TIME_SHIFT + if ( + p_shooted_queue_->count() > 0 + #if defined DOUBLE_FEED_BACK + || p_double_queue_->count() >0 + #endif + ) + { + if (p_shooted_queue_->count() > 0){ + bool temp; + p_shooted_queue_->take(temp); + } + pCaptureThreadBasler->m_threadFunc.SendFeedBack(EdgeEvent); + } +#else + if(p_unit_queue_->count() > 0){ + int unit_count = p_unit_queue_->count(); + cv::Mat long_image; + for (int i = 0; i < unit_count; i++) + { + cv::Mat image; + p_unit_queue_->take(image); + if (0 == i) + { + long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type()); + } + cv::Rect r(0, i * image.rows, image.cols, image.rows); + cv::Mat roi = long_image(r); + image.copyTo(roi); + } + p_image_queue_->put(std::make_pair(unit_count, long_image)); + p_shooted_queue_->put(true); + p_unit_queue_->clear(); + } + if(p_result_wait_queue_->count() > 0) + { + bool temp; + p_result_wait_queue_->take(temp); + pCaptureThreadBasler->m_threadFunc.SendFeedBack(EdgeEvent); + } + if(p_shooted_queue_->count() > 0) + { + bool temp; + p_shooted_queue_->take(temp); + p_result_wait_queue_->put(true); + } +#endif + break; + } +#else + case Line1RisingEdge: + { +#ifdef IMM_FEED_BACK + if (p_shooted_queue_->count() > 0) + { + bool temp; + p_shooted_queue_->take(temp); + } +#elif defined ONE_TIME_SHIFT + if ( + p_shooted_queue_->count() > 0 + #if defined DOUBLE_FEED_BACK + || p_double_queue_->count() >0 + #endif + ) + { + bool temp; + p_shooted_queue_->take(temp); + pCaptureThreadBasler->m_threadFunc.SendFeedBack(EdgeEvent); + } +#else + if(p_result_wait_queue_->count() > 0) + { + bool temp; + p_result_wait_queue_->take(temp); + pCaptureThreadBasler->m_threadFunc.SendFeedBack(EdgeEvent); + } + if(p_shooted_queue_->count() > 0) + { + bool temp; + p_shooted_queue_->take(temp); + p_result_wait_queue_->put(true); + } +#endif + break; + } + case Line1FallingEdge: + { + int unit_count = p_unit_queue_->count(); + if (unit_count > 0) + { + cv::Mat long_image; + for (int i = 0; i < unit_count; i++) + { + cv::Mat image; + p_unit_queue_->take(image); + if (0 == i) + { + long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type()); + } + cv::Rect r(0, i * image.rows, image.cols, image.rows); + cv::Mat roi = long_image(r); + image.copyTo(roi); + } + p_image_queue_->put(std::make_pair(unit_count, long_image)); + p_shooted_queue_->put(true); + } + p_unit_queue_->clear(); + break; + } +#endif + default: + break; + } + } +}; + +class CSampleImageEventHandler : public Pylon::CBaslerUniversalImageEventHandler +{ +public: + ASyncQueue* p_unit_queue_; + SyncQueue >* p_image_queue_; + SyncQueue* p_debug_queue_; + ASyncQueue *p_shooted_queue_; + Pylon::CBaslerUniversalInstantCamera* pDev__; + uint64_t* m_cntGrabbedImages_; + int Shoot_Num_; + virtual void OnImageGrabbed(Pylon::CBaslerUniversalInstantCamera& camera, const Pylon::CBaslerUniversalGrabResultPtr& ptrGrabResult) + { + // Create a pylon ImageFormatConverter object. + Pylon::CImageFormatConverter formatConverter; + + // Specify the output pixel format. + formatConverter.OutputPixelFormat = Pylon::PixelType_Mono8; + + cv::Mat openCvImage; + + // Create a PylonImage that will be used to create OpenCV images later. + Pylon::CPylonImage pylonImage; + + // Convert the grabbed buffer to a pylon image. + formatConverter.Convert(pylonImage, ptrGrabResult); + + // Create an OpenCV image from a pylon image. + openCvImage = cv::Mat(ptrGrabResult->GetHeight(), ptrGrabResult->GetWidth(), CV_8UC1, (uint8_t*)pylonImage.GetBuffer()); + cv::Mat image_clone = openCvImage.clone(); + + if (!g_debug_mode) + { +#ifdef IMM_PROCESS + p_image_queue_->put(std::make_pair(1,image_clone)); +#else + p_unit_queue_->put(image_clone); +#endif + } + else + { + p_debug_queue_->put(image_clone); + } + (*m_cntGrabbedImages_)++; +#ifndef IMM_PROCESS +#ifndef USB_BASLER_NEW_FW + int unit_count = p_unit_queue_->count(); + if (unit_count == Shoot_Num_) + { + cv::Mat long_image; + for (int i = 0; i < unit_count; i++) + { + cv::Mat image; + p_unit_queue_->take(image); + if (0 == i) + { + long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type()); + } + cv::Rect r(0, i * image.rows, image.cols, image.rows); + cv::Mat roi = long_image(r); + image.copyTo(roi); + } + p_image_queue_->put(std::make_pair(unit_count, long_image)); + p_shooted_queue_->put(true); + DEBUG(" unit_count\n"); + p_unit_queue_->clear(); + } +#endif +#endif + } +}; + +#endif // CaptureThreadBasler diff --git a/Cigarette/CaptureThreadHIK.cpp b/Cigarette/CaptureThreadHIK.cpp new file mode 100644 index 0000000..b434df6 --- /dev/null +++ b/Cigarette/CaptureThreadHIK.cpp @@ -0,0 +1,300 @@ +#include "CaptureThreadHIK.h" +#include +#include "PLCDevice.h" +#include "common.h" +#include +extern bool g_debug_mode; //ģʽģʽͣ״̬ܴ +extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; +extern PLCDevice * m_PLCDevice; + +inline void LossCallBackfunction(unsigned int pData, void* pUser){ + try{ + CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser; + SingleCamInfo[CaptureThreadHIKptr->Local_Num].OffLine = true; + CaptureThreadHIKptr->terminate(); + } + catch(...){ + std::cout << "LossCallBackfunction error" << std::endl; + } +} +inline void FallingGpioEventfunction(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){ + try{ + CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser; + int unit_count = CaptureThreadHIKptr->p_unit_queue->count(); + if (unit_count > 0) + { + cv::Mat long_image; + for (int i = 0; i < unit_count; i++) + { + cv::Mat image; + CaptureThreadHIKptr->p_unit_queue->take(image); + if (0 == i) + { + long_image = cv::Mat::zeros(image.rows * unit_count, image.cols, image.type()); + } + cv::Rect r(0, i * image.rows, image.cols, image.rows); + cv::Mat roi = long_image(r); + image.copyTo(roi); + } + CaptureThreadHIKptr->p_image_queue->put(std::make_pair(unit_count, long_image)); + CaptureThreadHIKptr->p_shooted_queue->put(true); + } + CaptureThreadHIKptr->p_unit_queue->clear(); + } + catch(...){ + std::cout << "FallingGpioEventfunction error" << std::endl; + } +} +inline void RisingGpioEventfunction(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){ + try{ + CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser; +#ifdef IMM_FEED_BACK + if (CaptureThreadHIKptr->p_shooted_queue->count() > 0) + { + bool temp; + CaptureThreadHIKptr->p_shooted_queue->take(temp); + } +#elif defined ONE_TIME_SHIFT + if( + CaptureThreadHIKptr->p_shooted_queue->count() > 0 + #if defined DOUBLE_FEED_BACK + || CaptureThreadHIKptr->p_double_queue->count() > 0 + #endif + ) + { + if (CaptureThreadHIKptr->p_shooted_queue->count() > 0){ + bool temp; + CaptureThreadHIKptr->p_shooted_queue->take(temp); + } + CaptureThreadHIKptr->m_threadFunc.SendFeedBack(EdgeEvent); + } +#else + if(CaptureThreadHIKptr->p_result_wait_queue->count() > 0) + { + bool temp; + CaptureThreadHIKptr->p_result_wait_queue->take(temp); + CaptureThreadHIKptr->m_threadFunc.SendFeedBack(EdgeEvent); + } + if(CaptureThreadHIKptr->p_shooted_queue->count() > 0) + { + bool temp; + CaptureThreadHIKptr->p_shooted_queue->take(temp); + CaptureThreadHIKptr->p_result_wait_queue->put(true); + } +#endif + } + catch(...){ + std::cout << "RisingGpioEventfunction error" << std::endl; + } +} + +#define CaptureThreadHIK_init(a)\ +void __stdcall LossCallBack##a(unsigned int pData, void* pUser){LossCallBackfunction(pData,pUser);}\ +void __stdcall FallingGpioEvent##a(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){FallingGpioEventfunction(pEventInfo,pUser);}\ +void __stdcall RisingGpioEvent##a(MV_EVENT_OUT_INFO* pEventInfo, void* pUser){RisingGpioEventfunction(pEventInfo,pUser);} +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) +CaptureThreadHIK_init(1) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) +CaptureThreadHIK_init(2) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) +CaptureThreadHIK_init(3) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) +CaptureThreadHIK_init(4) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) +CaptureThreadHIK_init(5) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) +CaptureThreadHIK_init(6) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) +CaptureThreadHIK_init(7) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) +CaptureThreadHIK_init(8) +#endif + +void(*LossCallBack[NumberOfSupportedCameras])(unsigned int pData, void* pUser) = { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + LossCallBack1 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + ,LossCallBack2 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + ,LossCallBack3 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + ,LossCallBack4 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + ,LossCallBack5 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + ,LossCallBack6 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + ,LossCallBack7 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + ,LossCallBack8 +#endif +}; +void(*FallingGpioEvent[NumberOfSupportedCameras])(MV_EVENT_OUT_INFO* pEventInfo, void* pUser) = { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + FallingGpioEvent1 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + ,FallingGpioEvent2 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + ,FallingGpioEvent3 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + ,FallingGpioEvent4 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + ,FallingGpioEvent5 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + ,FallingGpioEvent6 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + ,FallingGpioEvent7 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + ,FallingGpioEvent8 +#endif +}; +void(*RisingGpioEvent[NumberOfSupportedCameras])(MV_EVENT_OUT_INFO* pEventInfo, void* pUser) = { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + RisingGpioEvent1 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + ,RisingGpioEvent2 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + ,RisingGpioEvent3 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + ,RisingGpioEvent4 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + ,RisingGpioEvent5 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + ,RisingGpioEvent6 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + ,RisingGpioEvent7 +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + ,RisingGpioEvent8 +#endif +}; +void CaptureThreadHIK::fpsTimeout(void) +{ + uint64_t delta = m_cntGrabbedImages - m_cntLastGrabbedImages; + m_cntLastGrabbedImages = m_cntGrabbedImages; + QString data = QString("%1").arg(delta); + emit updateStatistics(data.left(4), Local_Num); +} + +//----------------------------------------------------------------------------- +CaptureThreadHIK::CaptureThreadHIK(void *camhandle, bool boTerminated,int Num) : + CamHandle( camhandle ), boTerminated_( boTerminated ),Local_Num(Num) +//----------------------------------------------------------------------------- +{ + p_unit_queue = new ASyncQueue(Unit_Queue_Size); + g_pImage_buf = (unsigned char*)malloc(3000 * 3000 * 3); +} +CaptureThreadHIK::~CaptureThreadHIK() +{ + delete p_unit_queue; + free(g_pImage_buf); +} +//----------------------------------------------------------------------------- +void CaptureThreadHIK::process( void ) +//----------------------------------------------------------------------------- +{ + try { + int nRet = MV_OK, nnRet = MV_OK; + + m_threadFunc.CamHandle_ = CamHandle; + m_threadFunc.p_result_queue_ = p_result_queue; + m_threadFunc.p_double_queue_ = p_double_queue; + + nRet = MV_CC_RegisterExceptionCallBack(CamHandle, LossCallBack[Local_Num], this); + if (nRet) { std::cout << "can not register loss callback" << std::endl; nnRet = nRet; } + +#ifndef IMM_FEED_BACK + nRet = MV_CC_SetEnumValueByString(CamHandle, "EventSelector", "Line0FallingEdge"); + if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValueByString(CamHandle, "EventNotification", "On"); + if (nRet) { std::cout << "can not set EventNotification" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValueByString(CamHandle, "EventSelector", "Line0RisingEdge"); + if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValueByString(CamHandle, "EventNotification", "On"); + if (nRet) { std::cout << "can not set EventNotification" << std::endl; nnRet = nRet; } + + nRet = MV_CC_RegisterEventCallBackEx(CamHandle, "Line0FallingEdge", FallingGpioEvent[Local_Num], this); + if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; } + + nRet = MV_CC_RegisterEventCallBackEx(CamHandle, "Line0RisingEdge", RisingGpioEvent[Local_Num], this); + if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; } +#endif + + m_Timer = new QTimer(); + connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout())); + m_Timer->start(1000); + + unsigned int nDataSize; + MVCC_INTVALUE_EX stIntValue = { 0 }; + nRet = MV_CC_GetIntValueEx(CamHandle, "PayloadSize", &stIntValue); + if (nRet) { std::cout << "Get PayloadSize error" << std::endl; } + nDataSize = stIntValue.nCurValue; + MV_CC_StartGrabbing(CamHandle); + Ready = true; + while(!boTerminated_) + { + nRet = MV_CC_GetOneFrameTimeout(CamHandle, g_pImage_buf, nDataSize, &stFrameInfo, 200); + if (MV_OK == nRet) + { + m_cntGrabbedImages++; + + cv::Mat openCVImage(stFrameInfo.nHeight, stFrameInfo.nWidth, CV_8UC1, g_pImage_buf); + cv::Mat image_clone = openCVImage.clone(); + if (!g_debug_mode) + { +#ifdef IMM_PROCESS + p_image_queue->put(std::make_pair(1,image_clone)); +#else + p_unit_queue->put(image_clone); //ʱ +#endif + } + else + { + p_debug_queue->put(image_clone); //Զ + } + } +#if defined (IMM_FEED_BACK) || defined (CAP_FEED_BACK) + m_threadFunc.SendFeedBack(ImageCap); +#endif + QCoreApplication::processEvents();//Make sure the timer is triggered + } + MV_CC_StopGrabbing(CamHandle); + MV_CC_CloseDevice(CamHandle); + delete m_Timer; + } + catch (cv::Exception& e) { + const char* err_msg = e.what(); + std::cout << "exception caught: " << err_msg << std::endl; + } +} +//----------------------------------------------------------------------------- diff --git a/Cigarette/CaptureThreadHIK.h b/Cigarette/CaptureThreadHIK.h new file mode 100644 index 0000000..9a36e16 --- /dev/null +++ b/Cigarette/CaptureThreadHIK.h @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------------- +#ifndef CaptureThreadHIKH +#define CaptureThreadHIKH CaptureThreadHIKH +//----------------------------------------------------------------------------- +#include "hikcamera.h" + +#include +#include +#include +#include + +#include "SyncQueue.h" +#include "ASyncQueue.h" + +#include + +class CaptureThreadHIK_Func +{ +public: + void *CamHandle_; + ASyncQueue *p_result_queue_; + ASyncQueue *p_double_queue_; + void SendFeedBack(int OpID) + { + bool send_ng=false; + bool send_ok=false; + if(OpID == EdgeEvent) + { +#if defined DOUBLE_FEED_BACK + if(p_double_queue_->count() > 0) + { + bool temp; + p_double_queue_->take(temp); + send_ng=true; + } +#endif + } + if (p_result_queue_->count() > 0) + { + bool result; + p_result_queue_->take(result); + if (!result) + { +#if defined DOUBLE_FEED_BACK + p_double_queue_->put(true); +#endif + send_ng=true; + } + } + if(send_ng) + { + MV_CC_SetEnumValue(CamHandle_, "LineSelector", 1); + MV_CC_SetCommandValue(CamHandle_, "LineTriggerSoftware"); + } + } +}; + +//----------------------------------------------------------------------------- +class CaptureThreadHIK : public QObject +//----------------------------------------------------------------------------- +{ + Q_OBJECT + +public: + explicit CaptureThreadHIK(void *camhandle, bool boTerminated,int Num); + CaptureThreadHIK::~CaptureThreadHIK(void); + void terminate( void ) + { + boTerminated_ = true; + } + +signals: + void error( QString err ); + void finished( void ); + void requestReady( void ); + void updateStatistics( const QString& data ,int Num); + +private slots: + void process( void ); + void fpsTimeout(void); +public: + int Local_Num; + SyncQueue > *p_image_queue; + ASyncQueue *p_unit_queue; + ASyncQueue *p_result_queue; + ASyncQueue *p_result_wait_queue; + ASyncQueue *p_double_queue; + ASyncQueue *p_shooted_queue; + SyncQueue *p_debug_queue; + void* CamHandle; + QTimer* m_Timer; + uint64_t m_cntGrabbedImages = 0; + uint64_t m_cntLastGrabbedImages = 0; + bool Ready = false; + CaptureThreadHIK_Func m_threadFunc; +private: + MV_FRAME_OUT_INFO_EX stFrameInfo; + unsigned char* g_pImage_buf; + volatile bool boTerminated_; + QMutex lock_; +}; +#endif // CaptureThreadHIKH diff --git a/Cigarette/Cigarette.vcxproj b/Cigarette/Cigarette.vcxproj new file mode 100644 index 0000000..fa3dd08 --- /dev/null +++ b/Cigarette/Cigarette.vcxproj @@ -0,0 +1,944 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B12702AD-ABFB-343A-A199-8E24837244A3} + Qt4VSv1.0 + 10.0 + + + + Application + v143 + + + Application + v143 + + + Application + v143 + + + Application + v143 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(IncludePath) + + + + UNICODE;_UNICODE;WIN32;WIN64;QT_CORE_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + true + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + true + qtmaind.lib;Qt5Cored.lib;Qt5Widgetsd.lib;Qt5Guid.lib;Qt5Networkd.lib;%(AdditionalDependencies) + + + + + UNICODE;_UNICODE;WIN32;WIN64;QT_CORE_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;NOMINMAX;QT_NETWORK_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;G:\code_library\c\opencv\4.3\build-opencv-cpu\include;$(ProjectDir)MvIMPACT;$(ProjectDir)Pylon6.2\include;$(ProjectDir)Common;$(ProjectDir)modbus;$(ProjectDir)MVS3.2.1\Include;$(ProjectDir)PLC;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + true + true + stdcpp14 + + + Console + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;G:\code_library\c\opencv\4.3\build-opencv-cpu\x64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;%(AdditionalLibraryDirectories) + true + qtmaind.lib;Qt5Cored.lib;Qt5Widgetsd.lib;Qt5Guid.lib;opencv_world430d.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;Qt5Networkd.lib;%(AdditionalDependencies) + + + + + UNICODE;_UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) + + MultiThreadedDLL + true + + + Windows + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + false + qtmain.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;Qt5Network.lib;%(AdditionalDependencies) + + + + + UNICODE;_UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_WIDGETS_LIB;QT_GUI_LIB;NOMINMAX;QT_NETWORK_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(ProjectDir)MvIMPACT;$(ProjectDir)OpenCV455Simple\include;$(ProjectDir)Common;$(ProjectDir)Pylon6.2\include;$(ProjectDir)modbus;$(ProjectDir)MVS3.2.1\Include;$(ProjectDir)PLC;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) + ProgramDatabase + MultiThreaded + true + true + stdcpp14 + MaxSpeed + false + + + Console + $(OutDir)\$(ProjectName).exe + $(QTDIR)\lib;$(ProjectDir)OpenCV455Simple\win64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;$(ProjectDir)MvIMPACT\lib\win64;$(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)modbus;%(AdditionalLibraryDirectories) + false + qtmain.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;Qt5Network.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + + + + + + + + + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + + + + + + + + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing cigarette.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing cigarette.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing cigarette.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing cigarette.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CHARTS_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WEBCHANNEL_LIB -DQT_WEBSOCKETS_LIB -DQT_WIDGETS_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCharts" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWebChannel" "-I$(QTDIR)\include\QtWebSockets" "-I$(QTDIR)\include\QtWidgets" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DNOMINMAX -DQT_CHARTS_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WEBCHANNEL_LIB -DQT_WEBSOCKETS_LIB -DQT_WIDGETS_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtCharts" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWebChannel" "-I$(QTDIR)\include\QtWebSockets" "-I$(QTDIR)\include\QtWidgets" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CHARTS_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WEBCHANNEL_LIB -DQT_WEBSOCKETS_LIB -DQT_WIDGETS_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCharts" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWebChannel" "-I$(QTDIR)\include\QtWebSockets" "-I$(QTDIR)\include\QtWidgets" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DNOMINMAX -DQT_CHARTS_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WEBCHANNEL_LIB -DQT_WEBSOCKETS_LIB -DQT_WIDGETS_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtCharts" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWebChannel" "-I$(QTDIR)\include\QtWebSockets" "-I$(QTDIR)\include\QtWidgets" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing alarmdialog.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing alarmdialog.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing alarmdialog.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing alarmdialog.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing CaptureThread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing CaptureThread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing CaptureThread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing CaptureThread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing plcsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing plcsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing plcsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing plcsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing db_label.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing db_label.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing db_label.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing db_label.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing debugthread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing debugthread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing debugthread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing debugthread.h... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogin.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogin.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogin.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogin.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + + + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)OpenCV455Simple\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing %(Identity)... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetuppasswd.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetuppasswd.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetuppasswd.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetuppasswd.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-IG:\code_library\c\opencv\4.3\build-opencv-cpu\include" "-I$(ProjectDir)MvIMPACT" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtNetwork" + $(QTDIR)\bin\moc.exe;%(FullPath) + Moc%27ing dialogsetup.hpp... + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DNOMINMAX -DQT_NETWORK_LIB -D%(PreprocessorDefinitions) "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(ProjectDir)MvIMPACT" "-IG:\code_library\c\opencv\4.3\build-opencv+cuda\include" "-I$(ProjectDir)Common" "-I$(ProjectDir)Pylon6.2\include" "-I$(ProjectDir)modbus" "-I$(ProjectDir)MVS3.2.1\Include" "-I$(ProjectDir)PLC" "-I$(QTDIR)\include\QtNetwork" + + + + + + + + + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + %(FullPath);%(AdditionalInputs) + Rcc%27ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + Uic%27ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + + + + + + \ No newline at end of file diff --git a/Cigarette/Cigarette.vcxproj.filters b/Cigarette/Cigarette.vcxproj.filters new file mode 100644 index 0000000..88e8056 --- /dev/null +++ b/Cigarette/Cigarette.vcxproj.filters @@ -0,0 +1,403 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;cxx;c;def + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + + {21a337b6-7c4c-4375-86e6-fb668dce746e} + cpp;moc + False + + + {65773ffc-5f94-4329-b62b-afc0b9e58efa} + cpp;moc + False + + + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + Source Files + + + Source Files + + + Generated Files\Debug + + + Generated Files\Release + + + + + Header Files + + + Form Files + + + Resource Files + + + Header Files + + + Form Files + + + Header Files + + + Form Files + + + Header Files + + + Form Files + + + Header Files + + + Header Files + + + Header Files + + + Form Files + + + Header Files + + + Header Files + + + Form Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Form Files + + + Header Files + + + Form Files + + + Header Files + + + Form Files + + + Header Files + + + Header Files + + + Header Files + + + + + Generated Files + + + Generated Files + + + Generated Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Generated Files + + + Header Files + + + Generated Files + + + Header Files + + + Generated Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Generated Files + + + Generated Files + + + Generated Files + + + \ No newline at end of file diff --git a/Cigarette/Cleanthread.cpp b/Cigarette/Cleanthread.cpp new file mode 100644 index 0000000..9d52d14 --- /dev/null +++ b/Cigarette/Cleanthread.cpp @@ -0,0 +1,147 @@ +#include "Cleanthread.h" +#include +#include +#include +#include +#include +#include +#include +#include "common.h"/// +extern SysConf g_sys_conf;/// +CleanWorkThread::CleanWorkThread(QObject* parent) : QObject(parent) +{ +} +CleanWorkThread::~CleanWorkThread() +{ +} +void CleanWorkThread::setSelAuto() { + delSelection = 1; +} +void CleanWorkThread::setSel() { + delSelection = 2; +} +void CleanWorkThread::startWork() +{ + emit workStart(); + doWork(); +} +void CleanWorkThread::startWorkAuto() +{ + emit workStartAuto(); + doWork(); +} +void CleanWorkThread::doWork() +{ + qint64 spaceSize; + qint64 dirSize; + QString iDriver = "D:/"; + LPCWSTR strDriver = (LPCWSTR)iDriver.utf16(); + ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace; + qint64 gb = (1024 * 1024 * 1024); + QString dir("D:/image"); + + if (delSelection == 2) + { + CleanImageFile(dir, 1); + } + else + { + qint64 delDays = g_sys_conf.save_days;/// + qint64 freeSize = g_sys_conf.freesize; + CleanImageFile(dir, delDays--); + //调用函数获取磁盘参数(单位为字节Byte),转化为GB,需要除以(1024*1024*1024) + GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace); + spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100/freeSize)) / (qint64)totalDiskSpace.QuadPart; + dirSize = DirFileSize(dir) / gb; + + while ((spaceSize < 1) && (delDays > 1)) { //磁盘剩余空间小于百分之十 + CleanImageFile(dir, delDays--); + GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace); + spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100 / freeSize)) / (qint64)totalDiskSpace.QuadPart; + } + } + emit workFinished(); +} +void CleanWorkThread::CleanImageFile(const QString& path, const qint64& delDays) +{ + QDir dir(path); + QFileInfoList list; + QFileInfo curFile; + if (!dir.exists()) { return; }//文件不存,则返回false + dir.setFilter(QDir::Dirs | QDir::Files); + list = dir.entryInfoList(QDir::Dirs | QDir::Files + | QDir::Readable | QDir::Writable + | QDir::Hidden | QDir::NoDotAndDotDot + , QDir::Time); + if (list.isEmpty()) { return; }//文件夹为空,则返回false + int i = list.size() - 1; + do { + QFileInfo fileInfo = list.at(i); + // dir.removeRecursively(); + while (fileInfo.fileName() == "." || fileInfo.fileName() == ".." && i >= 0) + { + i--; + } + if (i < 0) { + break; + } + bool bisDir = fileInfo.isDir(); + if (bisDir) + { + QRegExp rx("\\d{4}-\\d{2}-\\d{2}"); + QRegExpValidator v(rx, 0); + int pos = 0; + int match; + match = v.validate(fileInfo.fileName(), pos); + QString name = fileInfo.fileName(); + if (match == 2) + { + QDate delDate = QDate::currentDate(); + QDate dirDate; + QString name = fileInfo.fileName(); + dirDate = QDate::fromString(fileInfo.fileName(), "yyyy-MM-dd"); + qint64 nDays = dirDate.daysTo(delDate); + if (nDays >= delDays) + { + if (fileInfo.isDir()) { + QString n = fileInfo.absoluteFilePath(); + QDir subPath(fileInfo.absoluteFilePath()); + subPath.removeRecursively(); + } + else + { + fileInfo.dir().remove(fileInfo.fileName()); + } + } + } + else + { + CleanImageFile(fileInfo.filePath(), delDays); + } + } + else + { + fileInfo.dir().remove(fileInfo.fileName()); + } + i--; + } while (i >= 0); +} + +qint64 CleanWorkThread::DirFileSize(const QString& path) +{ + QDir dir(path); + quint64 size = 0; + //dir.entryInfoList(QDir::Files)返回文件信息 + foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files)) + { + //计算文件大小 + size += fileInfo.size(); + } + //dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot)返回所有子目录,并进行过滤 + foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) + { + //若存在子目录,则递归调用dirFileSize()函数 + size += DirFileSize(path + QDir::separator() + subDir); + } + return size; +} \ No newline at end of file diff --git a/Cigarette/Cleanthread.h b/Cigarette/Cleanthread.h new file mode 100644 index 0000000..48a72fe --- /dev/null +++ b/Cigarette/Cleanthread.h @@ -0,0 +1,24 @@ +#pragma once +#include +class CleanWorkThread : public QObject +{ + Q_OBJECT +public: + CleanWorkThread(QObject* parent = nullptr); + ~CleanWorkThread(); +public slots: + void startWork(); + void startWorkAuto(); + void doWork(); + void setSelAuto(); + void setSel(); +signals: + void workFinished(); + void workStart(); + void workStartAuto(); +public: + qint64 DirFileSize(const QString& path); + void CleanImageFile(const QString& path, const qint64& delDays); +private: + int delSelection; +}; diff --git a/Cigarette/Common/CommonGUIFunctions.cpp b/Cigarette/Common/CommonGUIFunctions.cpp new file mode 100644 index 0000000..05ed35b --- /dev/null +++ b/Cigarette/Common/CommonGUIFunctions.cpp @@ -0,0 +1,27 @@ +#include "CommonGUIFunctions.h" + +#include "wxIncludePrologue.h" +#include +#include "wxIncludeEpilogue.h" + +//----------------------------------------------------------------------------- +void UpdateDeviceListWithProgressMessage( wxWindow* pParent, const mvIMPACT::acquire::DeviceManager& devMgr ) +//----------------------------------------------------------------------------- +{ + static const int MAX_TIME_MS = 10000; + wxProgressDialog progressDialog( wxT( "Scanning For Drivers, Interfaces and Devices" ), + wxT( "Scanning for drivers, interfaces and devices...\n\nThis dialog will disappear automatically once this operation completes!" ), + MAX_TIME_MS, // range + pParent, + wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME ); + UpdateDeviceListThread thread( devMgr ); + thread.Create(); + thread.Run(); + while( thread.IsRunning() ) + { + wxMilliSleep( 100 ); + progressDialog.Pulse(); + } + thread.Wait(); + progressDialog.Update( MAX_TIME_MS ); +} diff --git a/Cigarette/Common/CommonGUIFunctions.h b/Cigarette/Common/CommonGUIFunctions.h new file mode 100644 index 0000000..ca58cfc --- /dev/null +++ b/Cigarette/Common/CommonGUIFunctions.h @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------------- +#ifndef CommonGUIFunctionsH +#define CommonGUIFunctionsH CommonGUIFunctionsH +//----------------------------------------------------------------------------- +#include + +#include "wxIncludePrologue.h" +#include +#include "wxIncludeEpilogue.h" + +class wxWindow; + +//============================================================================= +//================= Implementation UpdateDeviceListThread ===================== +//============================================================================= +//------------------------------------------------------------------------------ +class UpdateDeviceListThread : public wxThread +//------------------------------------------------------------------------------ +{ + const mvIMPACT::acquire::DeviceManager& devMgr_; +protected: + void* Entry( void ) + { + devMgr_.updateDeviceList(); + return 0; + } +public: + explicit UpdateDeviceListThread( const mvIMPACT::acquire::DeviceManager& devMgr ) : wxThread( wxTHREAD_JOINABLE ), + devMgr_( devMgr ) {} +}; + +void UpdateDeviceListWithProgressMessage( wxWindow* pParent, const mvIMPACT::acquire::DeviceManager& devMgr ); + +#endif // CommonGUIFunctionsH diff --git a/Cigarette/Common/Info.h b/Cigarette/Common/Info.h new file mode 100644 index 0000000..be05eee --- /dev/null +++ b/Cigarette/Common/Info.h @@ -0,0 +1,12 @@ +//----------------------------------------------------------------------------- +#ifndef InfoH +#define InfoH InfoH +//----------------------------------------------------------------------------- + +#define COMPANY_NAME wxT("MATRIX VISION GmbH") +#define COMPANY_WEBSITE wxT("www.matrix-vision.com") +#define COMPANY_SUPPORT_MAIL wxT("mailto:support@matrix-vision.com") +#define CURRENT_YEAR wxT("2020") +#define VERSION_STRING wxT("2.39.0.2982") + +#endif // InfoH diff --git a/Cigarette/Common/ProxyResolverContext.h b/Cigarette/Common/ProxyResolverContext.h new file mode 100644 index 0000000..969ebec --- /dev/null +++ b/Cigarette/Common/ProxyResolverContext.h @@ -0,0 +1,22 @@ +//----------------------------------------------------------------------------- +#ifndef ProxyResolverContextH +#define ProxyResolverContextH ProxyResolverContextH +//----------------------------------------------------------------------------- +#include + +//----------------------------------------------------------------------------- +class ProxyResolverContext +//----------------------------------------------------------------------------- +{ + struct ProxyResolverContextImpl* pImpl_; +public: + explicit ProxyResolverContext( const std::wstring& userAgent = std::wstring(), const std::wstring& url = std::wstring() ); + ~ProxyResolverContext(); + + std::wstring GetProxy( unsigned int index ) const; + unsigned int GetProxyPort( unsigned int index ) const; +}; + +bool IsCurrentUserLocalAdministrator( void ); + +#endif // ProxyResolverContextH diff --git a/Cigarette/Common/aviexception.h b/Cigarette/Common/aviexception.h new file mode 100644 index 0000000..843a427 --- /dev/null +++ b/Cigarette/Common/aviexception.h @@ -0,0 +1,39 @@ +//---------------------------------------------------------------------------------------- +#ifndef aviexceptionH +#define aviexceptionH aviexceptionH +//---------------------------------------------------------------------------------------- +#include + +//---------------------------------------------------------------------------------------- +class AVIException +//---------------------------------------------------------------------------------------- +{ +public: + virtual const char* what() const = 0; +}; + +//---------------------------------------------------------------------------------------- +class AEUnsupportedCodec : public AVIException +//---------------------------------------------------------------------------------------- +{ +public: + const char* what() const + { + return "Unsupported codec"; + } +}; + +//---------------------------------------------------------------------------------------- +class AVIWrapperException : public AVIException +//---------------------------------------------------------------------------------------- +{ + std::string m_errorString; +public: + AVIWrapperException( const char* pError ) : m_errorString( pError ) {} + const char* what() const + { + return m_errorString.c_str(); + } +}; + +#endif // aviexceptionH \ No newline at end of file diff --git a/Cigarette/Common/avihelper.cpp b/Cigarette/Common/avihelper.cpp new file mode 100644 index 0000000..2c6c87e --- /dev/null +++ b/Cigarette/Common/avihelper.cpp @@ -0,0 +1,173 @@ +//---------------------------------------------------------------------------------------- +#include "avihelper.h" +//---------------------------------------------------------------------------------------- + +using namespace std; + +//---------------------------------------------------------------------------------------- +/*! + \brief Builds an error string from an AVI error code. + \param error The error code to be converted. + + Helper function to convert an AVI error code into a string. +*/ +string AVIErrorToString( HRESULT error ) +//---------------------------------------------------------------------------------------- +{ + string errormsg( "AVI error '" ); + switch( error ) + { + case AVIERR_BADFLAGS : + errormsg.append( "AVIERR_BADFLAGS" ); + break; + case AVIERR_BADFORMAT : + errormsg.append( "AVIERR_BADFORMAT" ); + break; + case AVIERR_BADHANDLE : + errormsg.append( "AVIERR_BADHANDLE" ); + break; + case AVIERR_BADPARAM : + errormsg.append( "AVIERR_BADPARAM" ); + break; + case AVIERR_BADSIZE : + errormsg.append( "AVIERR_BADSIZE" ); + break; + case AVIERR_BUFFERTOOSMALL : + errormsg.append( "AVIERR_BUFFERTOOSMALL" ); + break; + case AVIERR_CANTCOMPRESS : + errormsg.append( "AVIERR_CANTCOMPRESS" ); + break; + case AVIERR_COMPRESSOR : + errormsg.append( "AVIERR_COMPRESSOR" ); + break; + case AVIERR_NOCOMPRESSOR : + errormsg.append( "AVIERR_NOCOMPRESSOR" ); + break; + case AVIERR_NODATA : + errormsg.append( "AVIERR_NODATA" ); + break; + case AVIERR_FILEOPEN : + errormsg.append( "AVIERR_FILEOPEN" ); + break; + case AVIERR_FILEREAD : + errormsg.append( "AVIERR_FILEREAD" ); + break; + case AVIERR_FILEWRITE : + errormsg.append( "AVIERR_FILEWRITE" ); + break; + case AVIERR_INTERNAL : + errormsg.append( "AVIERR_INTERNAL" ); + break; + case AVIERR_MEMORY : + errormsg.append( "AVIERR_MEMORY" ); + break; + case AVIERR_READONLY : + errormsg.append( "AVIERR_READONLY" ); + break; + case AVIERR_UNSUPPORTED : + errormsg.append( "AVIERR_UNSUPPORTED" ); + break; + case AVIERR_USERABORT : + errormsg.append( "AVIERR_USERABORT" ); + break; + case REGDB_E_CLASSNOTREG : + errormsg.append( "REGDB_E_CLASSNOTREG" ); + break; + default: + return "Unrecognized error"; + } + return( errormsg.append( "' occurred" ) ); +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Builds a test image. + \param pData Pointer to the memory in which to build the test image. + \param width The width of the test image. + \param height The height of the test image. + \param bytespp The bytes per pixel of the test image. + + This function is only needed for testing purposes. It builds a moving vertical + grey ramp in the memory pointed to by \e pData. In each new image will move one + pixel to the right in order to simulate movement. +*/ +void BuildTestImage( unsigned char* pData, int width, int height, int bytespp ) +//---------------------------------------------------------------------------------------- +{ + static int count = 0; + unsigned char* p = pData; + + for( int i = 0; i < height; i++ ) + { + for( int j = 0; j < width; j++ ) + { + for( int x = 0; x < bytespp; x++ ) + { + p[x] = static_cast( j + count % 256 ); + } + p += bytespp; + } + } + ++count; +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Convertes a user selected codec into the corresponding 4 character code + \param codec The codec to be converted. +*/ +DWORD CodecToFourccCode( CODEC_T codec ) +//---------------------------------------------------------------------------------------- +{ + switch( codec ) + { + case codecNoCompression: + return mmioFOURCC( 'D', 'I', 'B', ' ' ); + case codecMorganMjpg: + return mmioFOURCC( 'M', 'J', 'P', 'G' ); + case codecMorganMjpg2000: + return mmioFOURCC( 'M', 'J', '2', 'C' ); + case codecIntelJpg: + return mmioFOURCC( 'M', 'J', 'P', 'G' ); + case codecHuffYUV: + return mmioFOURCC( 'H', 'F', 'Y', 'U' ); + case codecDivx5: + return mmioFOURCC( 'd', 'i', 'v', 'x' ); + case codec3ivx: + return mmioFOURCC( '3', 'i', 'v', '2' ); + case codecMjpg2: + return mmioFOURCC( 'e', 'm', '2', 'v' ); + case codecPicVideoWavelet: + return mmioFOURCC( 'p', 'v', 'w', '2' ); + case codecPicVideoMjpg: + return mmioFOURCC( 'm', 'j', 'p', 'x' ); + case codecPicVideoLossLessJpg: + return mmioFOURCC( 'p', 'i', 'm', 'j' ); + case codecMSVideo: + return mmioFOURCC( 'm', 's', 'v', 'c' ); + case codecMSRle: + return mmioFOURCC( 'm', 'r', 'l', 'e' ); + case codecMSH263: + return mmioFOURCC( 'm', '2', '6', '3' ); + case codecMSH261: + return mmioFOURCC( 'm', '2', '6', '1' ); + case codecIntelVidR32: + return mmioFOURCC( 'i', 'v', '3', '2' ); + case codecIntelIndeo510: + return mmioFOURCC( 'i', 'v', '5', '0' ); + case codecDivxMjpg4lm: + return mmioFOURCC( 'd', 'i', 'v', '3' ); + case codecDivxMjpg4fm: + return mmioFOURCC( 'd', 'i', 'v', '4' ); + case codecCinepack: + return mmioFOURCC( 'c', 'v', 'i', 'd' ); + case codecMSMpeg4: + return mmioFOURCC( 'm', 'p', 'g', '4' ); + case codecMax: + return mmioFOURCC( 'D', 'I', 'B', ' ' ); + default: + break; + } + throw AEUnsupportedCodec(); +} \ No newline at end of file diff --git a/Cigarette/Common/avihelper.h b/Cigarette/Common/avihelper.h new file mode 100644 index 0000000..94e4019 --- /dev/null +++ b/Cigarette/Common/avihelper.h @@ -0,0 +1,45 @@ +//---------------------------------------------------------------------------------------- +#ifndef avihelperH +#define avihelperH avihelperH +//---------------------------------------------------------------------------------------- +#include +#include +#include "aviexception.h" +//---------------------------------------------------------------------------------------- + +/*! + \brief The codecs recognized by the \b AVIWrapper class. +*/ +typedef enum +{ + codecNoCompression = 0, + codecMorganMjpg = 1, + codecMorganMjpg2000 = 2, + codecIntelJpg = 3, + codecHuffYUV = 4, + codecDivx5 = 5, + codec3ivx = 6, + codecMjpg2 = 7, + codecPicVideoWavelet = 8, + codecPicVideoMjpg = 9, + codecPicVideoLossLessJpg = 10, + codecMSVideo = 11, + codecMSRle = 12, + codecMSH263 = 13, + codecMSH261 = 14, + codecIntelVidR32 = 15, + codecIntelIndeo510 = 16, + codecDivxMjpg4lm = 17, + codecDivxMjpg4fm = 18, + codecCinepack = 19, + codecMSMpeg4 = 20, + codecMax +} CODEC_T; + +//---------------------------------------------------------------------------------------- +std::string AVIErrorToString( HRESULT error ); +void BuildTestImage( unsigned char* pData, int width, int height, int bytespp ); +DWORD CodecToFourccCode( CODEC_T codec ); +//---------------------------------------------------------------------------------------- + +#endif // avihelperH \ No newline at end of file diff --git a/Cigarette/Common/aviwrapper.cpp b/Cigarette/Common/aviwrapper.cpp new file mode 100644 index 0000000..b71dd2a --- /dev/null +++ b/Cigarette/Common/aviwrapper.cpp @@ -0,0 +1,293 @@ +//---------------------------------------------------------------------------------------- +#include "aviwrapper.h" +#include +#include +//---------------------------------------------------------------------------------------- + +/*! + \class AVIWrapper + \brief Provides an easy way to create and use *.avi-files. + + This class is meant to provide easy access to the AVI file functions. It can be used to generate + an AVI stream with only a few lines of code. + + Three general methods are supported: + + - Creation of an AVI stream using the standard Windows compression options dialog (interactively) + - Creation of an AVI stream specifying a codec handler, quality settings and image dimensions + (not interactively) + - Creation of an AVI stream from images which are already in jpeg format. +*/ + +unsigned int AVIWrapper::m_usageCount = 0; + +//---------------------------------------------------------------------------------------- +/*! + \brief Constructs a new \b AVIWrapper object. + \param filename The filename of the AVI file to be created or \e 0 if no file shall be + created. + \param mode The access mode for this file. + + Opens and creates an AVI file in the mode specified by the \e mode parameter if + a filename has been specified. See MSDN for details about the available modes. +*/ +AVIWrapper::AVIWrapper( const char* pFilename /* = 0 */, UINT mode /* = OF_READ */ ) : + m_AVIStreamFrameCounter( 0 ), m_pAVIFile( 0 ), m_pAVIStream( 0 ), m_pAVIStreamCompressed( 0 ), + m_codec( CodecToFourccCode( codecNoCompression ) ) +//---------------------------------------------------------------------------------------- +{ + if( m_usageCount == 0 ) + { + AVIFileInit(); + } + ++m_usageCount; + if( pFilename ) + { + HRESULT result = AVIFileOpen( &m_pAVIFile, pFilename, mode, 0 ); + if( result == AVIERR_OK ) + { + result = AVIFileGetStream( m_pAVIFile, &m_pAVIStream, streamtypeVIDEO, 0 ); + } + if( result != AVIERR_OK ) + { + AVIFileExit(); + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } + } +} + +//---------------------------------------------------------------------------------------- +AVIWrapper::~AVIWrapper( void ) +//---------------------------------------------------------------------------------------- +{ + if( m_pAVIFile ) + { + CloseStreamsAndFiles(); + } + --m_usageCount; + if( m_usageCount == 0 ) + { + AVIFileExit(); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Closes the AVI file again. + + Closes all open streams and the AVI file itself. At the moment only one stream can be opened + at the same time. +*/ +void AVIWrapper::CloseAVIFile( void ) +//---------------------------------------------------------------------------------------- +{ + if( !m_pAVIFile ) + { + throw AVIWrapperException( "CloseAVIFile: No file has been opened so far" ); + } + CloseStreamsAndFiles(); +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Closes all open stream and the AVI file itself. +*/ +void AVIWrapper::CloseStreamsAndFiles( void ) +//---------------------------------------------------------------------------------------- +{ + if( m_pAVIStream ) + { + AVIStreamRelease( m_pAVIStream ); + } + if( m_pAVIStreamCompressed ) + { + AVIStreamRelease( m_pAVIStreamCompressed ); + } + if( m_pAVIFile ) + { + AVIFileRelease( m_pAVIFile ); + } + m_pAVIStream = 0; + m_pAVIStreamCompressed = 0; + m_pAVIFile = 0; + m_AVIStreamFrameCounter = 0; +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Creates an AVI stream from DIB images. + \param w The width of the images to be stored in the stream + \param h The height of the images to be stored in the stream + \param sampleRate The frames per second entry in the AVI header + \param quality The JPEG quality (from 0 - 10000) + \param name The name of the stream in the file + \param codec The codec to be used for the compression of the DIB data. Pass \e codecMax if + you want to select a codec from the standard Windows compression dialog or + a valid codec from the \b CODEC_T enumeration. + + Use this function to create a compressed or uncompressed AVI stream from images in DIB/Bitmap + format. The images can be stored in a compressed format defined by the specified compression + handler. + + If your images are already in JPEG format use the function AVIWrapper::CreateAVIStreamFromJPEGs() + instead. +*/ +void AVIWrapper::CreateAVIStreamFromDIBs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName /*= "default"*/, CODEC_T codec /*= codecMax*/ ) +//---------------------------------------------------------------------------------------- +{ + BITMAPINFOHEADER BmpHeader; + SetupStreamStructs( BmpHeader, w, h, bitcount, sampleRate, quality, pName, codec ); + BmpHeader.biCompression = BI_RGB; + AVICOMPRESSOPTIONS* opts[1] = {&m_AVICompressionOptions}; + memset( &m_AVICompressionOptions, 0, sizeof( AVICOMPRESSOPTIONS ) ); + PAVISTREAM streams[1] = {m_pAVIStream}; + + if( codec == codecMax ) + { + // show windows compression handler dialog + AVISaveOptions( 0, 0, 1, ( PAVISTREAM* )&streams, ( LPAVICOMPRESSOPTIONS* )&opts ); + } + else // fill AVICOMPRESSOPTIONS with user parameters + { + m_codec = codec; + opts[0]->fccType = streamtypeVIDEO; + opts[0]->fccHandler = CodecToFourccCode( codec ); + opts[0]->dwQuality = quality; + opts[0]->dwFlags = AVICOMPRESSF_VALID; + } + m_codec = opts[0]->fccHandler; + HRESULT result = AVIMakeCompressedStream( &m_pAVIStreamCompressed, m_pAVIStream, &m_AVICompressionOptions, NULL ); + if( result == AVIERR_OK ) + { + result = AVIStreamSetFormat( m_pAVIStreamCompressed, 0, &BmpHeader, sizeof( BITMAPINFOHEADER ) ); + } + if( result != AVIERR_OK ) + { + CloseStreamsAndFiles(); + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Creates an AVI stream from JPEG images. + \param w The width of the images to be stored in the stream + \param h The height of the images to be stored in the stream + \param sampleRate The frames per second entry in the AVI header + \param quality The JPEG quality (from 0 - 10000) + \param name The name of the stream in the file + + Use this function to create a MJPEG stream from images which are already in JPEG format. + + To create an AVI stream from images in DIB format use the function + AVIWrapper::CreateAVIStreamFromDIBs() instead. +*/ +void AVIWrapper::CreateAVIStreamFromJPEGs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName /*= "default"*/ ) +//---------------------------------------------------------------------------------------- +{ + // no 'handler' compression! This section works for already compressed images + BITMAPINFOHEADER BmpHeader; + SetupStreamStructs( BmpHeader, w, h, bitcount, sampleRate, quality, pName, codecMorganMjpg ); + BmpHeader.biCompression = CodecToFourccCode( codecMorganMjpg ); + const HRESULT result = AVIStreamSetFormat( m_pAVIStream, 0, &BmpHeader, sizeof( BITMAPINFOHEADER ) ); + if( result != AVIERR_OK ) + { + CloseStreamsAndFiles(); + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Opens an AVI file. + \param filename The name of the file to be created/opened/used. + \param mode The access mode for this file. + + Opens and creates an AVI file in the mode specified by the \e mode parameter + See MSDN for details about the available modes. +*/ +void AVIWrapper::OpenAVIFile( const char* pFilename, UINT mode /* = OF_READ */ ) +//---------------------------------------------------------------------------------------- +{ + if( m_pAVIFile ) + { + throw AVIWrapperException( "OpenAVIFile: Another file has been opened already" ); + } + if( !pFilename ) + { + throw AVIWrapperException( "OpenAVIFile: No valid filename has been specified" ); + } + const HRESULT result = AVIFileOpen( &m_pAVIFile, pFilename, mode, 0 ); + if( result != AVIERR_OK ) + { + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Stores one image in the AVI stream + \param data Pointer to the image data + \param size Size (in bytes) of the memory block pointed to by \e data + + This function stores one image in the specified stream. +*/ +void AVIWrapper::SaveDataToAVIStream( unsigned char* pData, int size ) +//---------------------------------------------------------------------------------------- +{ + PAVISTREAM pAVIStream = ( m_pAVIStreamCompressed ) ? m_pAVIStreamCompressed : m_pAVIStream; + if( !pAVIStream ) + { + throw AVIWrapperException( "SaveDataToAVIStream: Stream pointer invalid" ); + } + const HRESULT result = AVIStreamWrite( pAVIStream, m_AVIStreamFrameCounter++, 1, pData, size, AVIIF_KEYFRAME, 0, 0 ); + if( result != AVIERR_OK ) + { + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +void AVIWrapper::SetupStreamStructs( BITMAPINFOHEADER& BmpHeader, int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName /*= "default"*/, CODEC_T codec /*= codecMax*/ ) +//---------------------------------------------------------------------------------------- +{ + if( !m_pAVIFile ) + { + throw AVIWrapperException( "CreateNewAVIStream: No file has been opened so far" ); + } + if( strlen( pName ) > sizeof( m_AVIStreamInfo.szName ) ) + { + throw AVIWrapperException( "CreateNewAVIStream: stream name too long" ); + } + if( m_pAVIStream || m_pAVIStreamCompressed ) + { + throw AVIWrapperException( "CreateNewAVIStream: There is already an open stream" ); + } + // setup AVISTREAMINFO structure + memset( &m_AVIStreamInfo, 0, sizeof( AVISTREAMINFO ) ); + m_AVIStreamInfo.fccType = streamtypeVIDEO; + m_AVIStreamInfo.fccHandler = CodecToFourccCode( codec ); + m_AVIStreamInfo.wPriority = 10; + m_AVIStreamInfo.dwScale = 1; + m_AVIStreamInfo.dwRate = sampleRate; + m_AVIStreamInfo.dwQuality = quality; + m_AVIStreamInfo.rcFrame.right = w; + m_AVIStreamInfo.rcFrame.bottom = h; + mv_strncpy_s( m_AVIStreamInfo.szName, pName, sizeof( m_AVIStreamInfo.szName ) ); + + const HRESULT result = AVIFileCreateStream( m_pAVIFile, &m_pAVIStream, &m_AVIStreamInfo ); + if( result != AVIERR_OK ) + { + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } + // setup BITMAPINFOHEADER structure + memset( &BmpHeader, 0, sizeof( BITMAPINFOHEADER ) ); + BmpHeader.biSize = sizeof( BITMAPINFOHEADER ); + BmpHeader.biWidth = w; + BmpHeader.biHeight = h; + BmpHeader.biPlanes = 1; + BmpHeader.biBitCount = static_cast( bitcount ); + + // setup internals + m_AVIStreamFrameCounter = 0; +} \ No newline at end of file diff --git a/Cigarette/Common/aviwrapper.h b/Cigarette/Common/aviwrapper.h new file mode 100644 index 0000000..c49d148 --- /dev/null +++ b/Cigarette/Common/aviwrapper.h @@ -0,0 +1,54 @@ +//---------------------------------------------------------------------------------------- +#ifndef aviwrapperH +#define aviwrapperH aviwrapperH +//---------------------------------------------------------------------------------------- +#include "avihelper.h" + +//---------------------------------------------------------------------------------------- +class AVIWrapper +//---------------------------------------------------------------------------------------- +{ + // member data + /// Keeps track about the number of images stored in the actual stream + int m_AVIStreamFrameCounter; + /// pointer to the structure describing the AVI-file + PAVIFILE m_pAVIFile; + /// pointer to an uncompressed AVI stream + PAVISTREAM m_pAVIStream; + /// pointer to a compressed AVI stream (this is used when a compression handler is used) + PAVISTREAM m_pAVIStreamCompressed; + /// A structure containing information about the AVI stream + AVISTREAMINFO m_AVIStreamInfo; + /// A structure for storing the compression options of the AVI stream + AVICOMPRESSOPTIONS m_AVICompressionOptions; + /// The used codec + DWORD m_codec; + /// Usage count for this class + static unsigned int m_usageCount; + // functions + void CloseStreamsAndFiles( void ); + void SetupStreamStructs( BITMAPINFOHEADER& BmpHeader, int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName = "default", CODEC_T codec = codecMax ); + /// Do not allow copy construction + AVIWrapper( const AVIWrapper& scr ); +public: + // construction/destruction + explicit AVIWrapper( const char* pFilename = 0, UINT mode = OF_READ ); + ~AVIWrapper( void ); + + // user interface + void CloseAVIFile( void ); + void CreateAVIStreamFromDIBs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName = "default", CODEC_T codec = codecMax ); + void CreateAVIStreamFromJPEGs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName = "default" ); + const char* GetStreamName( void ) const + { + return m_AVIStreamInfo.szName; + } + bool UsesCompressionHandler( void ) const + { + return m_codec != CodecToFourccCode( codecNoCompression ); + } + void OpenAVIFile( const char* pFilename, UINT mode = OF_READ ); + void SaveDataToAVIStream( unsigned char* pData, int size ); +}; + +#endif // aviwrapperH \ No newline at end of file diff --git a/Cigarette/Common/exampleHelper.h b/Cigarette/Common/exampleHelper.h new file mode 100644 index 0000000..2f9e857 --- /dev/null +++ b/Cigarette/Common/exampleHelper.h @@ -0,0 +1,545 @@ +//----------------------------------------------------------------------------- +#ifndef exampleHelperH +#define exampleHelperH exampleHelperH +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +template +class DisplayDictEntry +//----------------------------------------------------------------------------- +{ +public: + void operator()( const std::pair& data ) const + { + std::cout << " [" << data.second << "]: " << data.first << std::endl; + } +}; + +//----------------------------------------------------------------------------- +class DisplayComponent +//----------------------------------------------------------------------------- +{ +public: + void operator()( const Component& data ) const + { + if( data.isValid() ) + { + std::cout << " " << data.name() << "(" << data.typeAsString() << ")" << std::endl; + } + } +}; + +//----------------------------------------------------------------------------- +class DisplayProperty +//----------------------------------------------------------------------------- +{ +public: + void operator()( const std::pair& data ) const + { + if( data.second.isValid() ) + { + std::cout << data.first << ": " << data.second.readSArray() << "(" << data.second.flagsAsString() << ")" << std::endl; + } + } +}; + +//----------------------------------------------------------------------------- +template +void DisplayPropertyDictionary( const mvIMPACT::acquire::Property& p ) +//----------------------------------------------------------------------------- +{ + _Ty prop( p ); +#if defined(_MSC_VER) && (_MSC_VER < 1300) // is 'old' VC 6 Microsoft compiler? + std::vector > dict; + prop.getTranslationDict( dict ); + std::for_each( dict.begin(), dict.end(), DisplayDictEntry<_Ty::value_type>() ); +#else + std::vector > dict; + prop.getTranslationDict( dict ); + std::for_each( dict.begin(), dict.end(), DisplayDictEntry() ); +#endif // #ifdef _MSC_VER +} + +//----------------------------------------------------------------------------- +/// \brief Checks is a certain value for property is supported. +template +bool supportsEnumStringValue( const _Tx& prop, const std::string& value ) +//----------------------------------------------------------------------------- +{ + if( prop.hasDict() ) + { + typename std::vector sequence; + prop.getTranslationDictStrings( sequence ); + return std::find( sequence.begin(), sequence.end(), value ) != sequence.end(); + } + return false; +} + +//----------------------------------------------------------------------------- +/// \brief Checks is a certain value for property is supported. +template +bool supportsValue( const _Tx& prop, const _Ty& value ) +//----------------------------------------------------------------------------- +{ + if( prop.hasDict() ) + { + typename std::vector<_Ty> sequence; + prop.getTranslationDictValues( sequence ); + return std::find( sequence.begin(), sequence.end(), value ) != sequence.end(); + } + + if( prop.hasMinValue() && ( prop.getMinValue() > value ) ) + { + return false; + } + + if( prop.hasMaxValue() && ( prop.getMaxValue() < value ) ) + { + return false; + } + + return true; +} + +//----------------------------------------------------------------------------- +/// \brief Sets a property to a certain value if this value is supported. +template +void conditionalSetProperty( const _Ty& prop, const _Tx& value, bool boSilent = false ) +//----------------------------------------------------------------------------- +{ + if( prop.isValid() && prop.isWriteable() && supportsValue( prop, value ) ) + { + prop.write( value ); + if( !boSilent ) + { + std::cout << "Property '" << prop.name() << "' set to '" << prop.readS() << "'." << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +/// \brief Sets a property to a certain value if this value is supported. +template +void conditionalSetEnumPropertyByString( const _Ty& prop, const std::string& value, bool boSilent = false ) +//----------------------------------------------------------------------------- +{ + if( prop.isValid() && prop.isWriteable() && supportsEnumStringValue( prop, value ) ) + { + prop.writeS( value ); + if( !boSilent ) + { + std::cout << "Property '" << prop.name() << "' set to '" << prop.readS() << "'." << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +/// This function makes heavy use of strings. In real world applications +/// this can be avoided if optimal performance is crucial. All properties can be modified +/// via strings, but most properties can also be modified with numerical (int / double ) +/// values, which is much faster, but not as descriptive for a sample application +inline void displayPropertyData( const mvIMPACT::acquire::Property& prop ) +//----------------------------------------------------------------------------- +{ + const std::string name( prop.name() ); + std::cout << std::endl + << "Property '" << name << "'(display name: '" << prop.displayName() << "', type: " << prop.typeAsString() << ") currently specifies the following flags: " << prop.flagsAsString() << std::endl + << std::endl; + const std::string doc( prop.docString() ); + if( !doc.empty() ) + { + std::cout << "The following documentation has been reported by the driver for this feature: " << std::endl + << doc << std::endl + << std::endl; + } + if( prop.selectedFeatureCount() > 0 ) + { + std::vector selectedFeatureList; + prop.selectedFeatures( selectedFeatureList ); + std::cout << "The following features are selected by this feature(Whenever the current feature is modified, all selected features might change):" << std::endl; + std::for_each( selectedFeatureList.begin(), selectedFeatureList.end(), DisplayComponent() ); + std::cout << std::endl; + } + if( prop.selectingFeatureCount() > 0 ) + { + std::vector selectingFeatureList; + prop.selectingFeatures( selectingFeatureList ); + std::cout << "The following features select this feature(Whenever a selecting features is modified, a selected one might change):" << std::endl; + std::for_each( selectingFeatureList.begin(), selectingFeatureList.end(), DisplayComponent() ); + std::cout << std::endl; + } + if( prop.hasMinValue() ) + { + std::cout << "The minimum value of '" << name << "' is " << prop.readS( mvIMPACT::acquire::plMinValue ) << std::endl; + } + if( prop.hasMaxValue() ) + { + std::cout << "The maximum value of '" << name << "' is " << prop.readS( mvIMPACT::acquire::plMaxValue ) << std::endl; + } + if( prop.hasStepWidth() ) + { + std::cout << "The increment of '" << name << "' is " << prop.readS( mvIMPACT::acquire::plStepWidth ) << std::endl; + } + if( prop.hasDict() ) + { + std::cout << "'" << name << "' defines a dictionary. Valid values are: " << std::endl; + mvIMPACT::acquire::TComponentType type = prop.type(); + if( type == mvIMPACT::acquire::ctPropInt ) + { + DisplayPropertyDictionary( prop ); + } + else if( type == mvIMPACT::acquire::ctPropInt64 ) + { + DisplayPropertyDictionary( prop ); + } + else if( type == mvIMPACT::acquire::ctPropFloat ) + { + DisplayPropertyDictionary( prop ); + } + else + { + std::cout << "Error! Unhandled enum prop type: " << prop.typeAsString() << std::endl; + } + } + std::cout << "The current value of '" << name << "' is: '" << prop.readS() << "'" << std::endl; +} + +//----------------------------------------------------------------------------- +inline bool displayPropertyDataWithValidation( const mvIMPACT::acquire::Property& prop, const std::string& name ) +//----------------------------------------------------------------------------- +{ + if( !prop.isValid() ) + { + std::cout << "Property '" << name << "' is not supported/available." << std::endl; + return false; + } + displayPropertyData( prop ); + return true; +} + +//----------------------------------------------------------------------------- +// Start the acquisition manually if this was requested(this is to prepare the driver for data capture and tell the device to start streaming data) +inline void manuallyStartAcquisitionIfNeeded( mvIMPACT::acquire::Device* pDev, const mvIMPACT::acquire::FunctionInterface& fi ) +//----------------------------------------------------------------------------- +{ + if( pDev->acquisitionStartStopBehaviour.read() == mvIMPACT::acquire::assbUser ) + { + const mvIMPACT::acquire::TDMR_ERROR result = static_cast( fi.acquisitionStart() ); + if( result != mvIMPACT::acquire::DMR_NO_ERROR ) + { + std::cout << "'FunctionInterface.acquisitionStart' returned with an unexpected result: " << result + << "(" << mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString( result ) << ")" << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +// Stop the acquisition manually if this was requested +inline void manuallyStopAcquisitionIfNeeded( mvIMPACT::acquire::Device* pDev, const mvIMPACT::acquire::FunctionInterface& fi ) +//----------------------------------------------------------------------------- +{ + if( pDev->acquisitionStartStopBehaviour.read() == mvIMPACT::acquire::assbUser ) + { + const mvIMPACT::acquire::TDMR_ERROR result = static_cast( fi.acquisitionStop() ); + if( result != mvIMPACT::acquire::DMR_NO_ERROR ) + { + std::cout << "'FunctionInterface.acquisitionStop' returned with an unexpected result: " << result + << "(" << mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString( result ) << ")" << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +/// This function makes heavy use of strings. In real world applications +/// this can be avoided if optimal performance is crucial. All properties can be modified +/// via strings, but most properties can also be modified with numerical (int / double ) +/// values, which is much faster, but not as descriptive for a sample application +inline void modifyPropertyValue( const mvIMPACT::acquire::Property& prop, const std::string& param = "", const std::string& index = "" ) +//----------------------------------------------------------------------------- +{ + try + { + const std::string name( prop.name() ); + if( prop.isWriteable() ) + { + int valIndex = 0; + if( param.empty() ) + { + std::cout << "Enter the new value for '" << name << "': "; + std::string val; + std::cin >> val; + // remove the '\n' from the stream + std::cin.get(); + if( prop.valCount() > 1 ) + { + std::cout << "'" << name << "' defines " << prop.valCount() << " values. Enter the index (zero-based) of the value to modify: "; + std::cin >> valIndex; + // remove the '\n' from the stream + std::cin.get(); + } + prop.writeS( val, valIndex ); + } + else + { + if( !index.empty() ) + { + valIndex = atoi( index.c_str() ); + } + prop.writeS( param, valIndex ); + } + } + else + { + std::cout << "'" << name << "' is read-only, thus can't be modified." << std::endl; + } + } + catch( const mvIMPACT::acquire::ImpactAcquireException& e ) + { + std::cout << "An exception occurred: " << e.getErrorString() << "(error code: " << e.getErrorCodeAsString() << ")" << std::endl; + } +} + +//----------------------------------------------------------------------------- +inline void displayAndModifyPropertyDataWithValidation( const mvIMPACT::acquire::Property& prop, const std::string& name ) +//----------------------------------------------------------------------------- +{ + if( displayPropertyDataWithValidation( prop, name ) ) + { + modifyPropertyValue( prop ); + } + std::cout << std::endl; +} + +//----------------------------------------------------------------------------- +inline std::ostream& operator<<( std::ostream& out, const mvIMPACT::acquire::Property& prop ) +//----------------------------------------------------------------------------- +{ + out << prop.name() << ": " << prop.readS(); + return out; +} + +//----------------------------------------------------------------------------- +/// \brief Allows string comparison with a defined character to ignore +/** + * This function allows a tolerant string compare. If \a candidate ends with \a wildcard + * \a candidate can be shorter then \a searchString as the rest of the string will be + * ignored. This is a helper function used internally by DeviceManager objects. + * + * Examples: + * + * \code + * wildcard = '*' + * s1 = "blablabla" + * match( s1, "bl*bl*bla", '*' ); // will return 0 + * // will return 0 ('*' is the default value for parameter 3 ) + * match( s1, "bl*" ); + * // the next call will return -1 as the first character MUST + * // be either a 'b' or the wildcard character. + * match( s1, "a*" ); + * \endcode + * \return + * - 0 if successful + * - -1 otherwise + */ +template +int match( const std::basic_string<_Elem, _Traits, _Ax>& searchString, const std::basic_string<_Elem, _Traits, _Ax>& candidate, _Elem wildcard ) +//----------------------------------------------------------------------------- +{ + typename std::basic_string<_Elem, _Traits, _Ax>::size_type searchLength = searchString.length(); + // determine search length + if( candidate.length() < searchString.length() ) + { + if( candidate.empty() ) + { + return -1; + } + + if( candidate[candidate.length() - 1] != wildcard ) + { + return -1; + } + searchLength = candidate.length() - 1; + } + // search + for( typename std::basic_string<_Elem, _Traits, _Ax>::size_type i = 0; i < searchLength; i++ ) + { + if( ( candidate[i] != searchString[i] ) && ( candidate[i] != wildcard ) ) + { + return -1; + } + } + return 0; +} + +typedef bool( *SUPPORTED_DEVICE_CHECK )( const mvIMPACT::acquire::Device* const ); + +//----------------------------------------------------------------------------- +inline mvIMPACT::acquire::Device* getDeviceFromUserInput( const mvIMPACT::acquire::DeviceManager& devMgr, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn = 0, bool boSilent = false, bool boAutomaticallyUseGenICamInterface = true ) +//----------------------------------------------------------------------------- +{ + const unsigned int devCnt = devMgr.deviceCount(); + if( devCnt == 0 ) + { + std::cout << "No compliant device found!" << std::endl; + return 0; + } + + std::set validDeviceNumbers; + + // display every device detected that matches + for( unsigned int i = 0; i < devCnt; i++ ) + { + Device* pDev = devMgr[i]; + if( pDev ) + { + if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( pDev ) ) + { + std::cout << "[" << i << "]: " << pDev->serial.read() << " (" << pDev->product.read() << ", " << pDev->family.read(); + if( pDev->interfaceLayout.isValid() ) + { + if( boAutomaticallyUseGenICamInterface ) + { + // if this device offers the 'GenICam' interface switch it on, as this will + // allow are better control over GenICam compliant devices + conditionalSetProperty( pDev->interfaceLayout, dilGenICam, true ); + } + std::cout << ", interface layout: " << pDev->interfaceLayout.readS(); + } + if( pDev->acquisitionStartStopBehaviour.isValid() ) + { + // if this device offers a user defined acquisition start/stop behaviour + // enable it as this allows finer control about the streaming behaviour + conditionalSetProperty( pDev->acquisitionStartStopBehaviour, assbUser, true ); + std::cout << ", acquisition start/stop behaviour: " << pDev->acquisitionStartStopBehaviour.readS(); + } + if( pDev->interfaceLayout.isValid() && !pDev->interfaceLayout.isWriteable() ) + { + if( pDev->isInUse() ) + { + std::cout << ", !!!ALREADY IN USE!!!"; + } + } + std::cout << ")" << std::endl; + validDeviceNumbers.insert( i ); + } + } + } + + if( validDeviceNumbers.empty() ) + { + std::cout << devMgr.deviceCount() << " devices have been detected:" << std::endl; + for( unsigned int i = 0; i < devCnt; i++ ) + { + Device* pDev = devMgr[i]; + if( pDev ) + { + std::cout << " [" << i << "]: " << pDev->serial.read() << " (" << pDev->product.read() << ", " << pDev->family.read() << ")" << std::endl; + } + } + std::cout << "However none of these devices seems to be supported by this sample." << std::endl << std::endl; + return 0; + } + + // get user input + std::cout << std::endl << "Please enter the number in front of the listed device followed by [ENTER] to open it: "; + unsigned int devNr = 0; + std::cin >> devNr; + // remove the '\n' from the stream + std::cin.get(); + + if( validDeviceNumbers.find( devNr ) == validDeviceNumbers.end() ) + { + std::cout << "Invalid selection!" << std::endl; + return 0; + } + + if( !boSilent ) + { + std::cout << "Using device number " << devNr << "." << std::endl; + } + return devMgr[devNr]; +} + +//----------------------------------------------------------------------------- +inline std::vector::size_type getValidDevices( const mvIMPACT::acquire::DeviceManager& devMgr, std::vector& v, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn = 0 ) +//----------------------------------------------------------------------------- +{ + const unsigned int devCnt = devMgr.deviceCount(); + // display every device detected that matches + for( unsigned int i = 0; i < devCnt; i++ ) + { + Device* pDev = devMgr[i]; + if( pDev ) + { + if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( pDev ) ) + { + v.push_back( pDev ); + } + } + } + return v.size(); +} + +#if defined(linux) || defined(__linux) || defined(__linux__) +# include +# include +# include +# include +# include +//----------------------------------------------------------------------------- +/// \brief Checks if something was written to a certain file descriptor +/** \return + * - 0 if timeout did elapse + * - 1 otherwise + */ +inline unsigned waitForInput( int maxWait_sec, int fd ) +//----------------------------------------------------------------------------- +{ + fd_set rfds; + struct timeval tv; + + FD_ZERO( &rfds ); +#ifndef __clang_analyzer__ // See https://bugs.llvm.org/show_bug.cgi?id=8920 + FD_SET( fd, &rfds ); +#endif // #ifndef __clang_analyzer__ + + tv.tv_sec = maxWait_sec; + tv.tv_usec = 0; + + return select( fd + 1, &rfds, NULL, NULL, &tv ); +} + +//----------------------------------------------------------------------------- +/** \return + * - 1 if a key has been pressed since the last call to this function + * - 0 otherwise + */ +inline int checkKeyboardInput( void ) +//----------------------------------------------------------------------------- +{ + struct termios oldt, newt; + tcgetattr( STDIN_FILENO, &oldt ); + newt = oldt; + newt.c_lflag &= ~( ICANON | ECHO ); + tcsetattr( STDIN_FILENO, TCSANOW, &newt ); + const int oldf = fcntl( STDIN_FILENO, F_GETFL, 0 ); + fcntl( STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK ); + const int ch = getchar(); + tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); + fcntl( STDIN_FILENO, F_SETFL, oldf ); + if( ch != EOF ) + { + // ungetc(ch, stdin); + return 1; + } + + return 0; +} +#endif // #if defined(linux) || defined(__linux) || defined(__linux__) + +#endif // exampleHelperH diff --git a/Cigarette/Common/exampleHelper_C.c b/Cigarette/Common/exampleHelper_C.c new file mode 100644 index 0000000..80a146c --- /dev/null +++ b/Cigarette/Common/exampleHelper_C.c @@ -0,0 +1,595 @@ +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include "exampleHelper_C.h" + +#define BUF_SIZE (32) +#define BUF_SIZE_LARGE (256) + +//----------------------------------------------------------------------------- +int getIntValFromSTDIn( void ) +//----------------------------------------------------------------------------- +{ + int value; + int conversionResult = 0; + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + conversionResult = scanf_s( "%d", &value ); +#else + conversionResult = scanf( "%d", &value ); +#endif // #if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + if( conversionResult != 1 ) + { + printf( "Conversion error: Expected: 1, conversion result: %d.\n", conversionResult ); + } + return value; +} + +//----------------------------------------------------------------------------- +int getPropI( HOBJ hProp, int index ) +//----------------------------------------------------------------------------- +{ + int value = 0; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_GetI( hProp, &value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "getPropI: Failed to read property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } + return value; +} + +//----------------------------------------------------------------------------- +void setPropI( HOBJ hProp, int value, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetI( hProp, value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropI: Failed to write property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +int64_type getPropI64( HOBJ hProp, int index ) +//----------------------------------------------------------------------------- +{ + int64_type value = 0; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_GetI64( hProp, &value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "getPropI: Failed to read property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } + return value; +} + +//----------------------------------------------------------------------------- +void setPropI64( HOBJ hProp, int64_type value, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetI64( hProp, value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropI: Failed to write property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +void* getPropP( HOBJ hProp, int index ) +//----------------------------------------------------------------------------- +{ + void* value = 0; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_GetP( hProp, &value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "getPropP: Failed to read property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } + return value; +} + +//----------------------------------------------------------------------------- +void setPropP( HOBJ hProp, void* value, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetP( hProp, value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropP: Failed to write property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +void setPropS( HOBJ hProp, const char* pVal, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetS( hProp, pVal, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropS: Failed to write property value %s :%s.\n", pVal, DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver feature +HOBJ getDriverFeature( HDRV hDrv, const char* pFeatureName, const char* pFeatureType, const char* pAddListName, TDMR_ListType type, unsigned int searchMode ) +//----------------------------------------------------------------------------- +{ + TDMR_ERROR dmrResult = DMR_NO_ERROR; + HOBJ hObj = INVALID_ID; + HLIST baseList = INVALID_ID; + + // try to locate the base list for these property + if( ( dmrResult = DMR_FindList( hDrv, pAddListName, type, 0, &baseList ) ) == DMR_NO_ERROR ) + { + // try to locate the property + TPROPHANDLING_ERROR objResult; + if( ( objResult = OBJ_GetHandleEx( baseList, pFeatureName, &hObj, searchMode, INT_MAX ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "OBJ_GetHandleEx for '%s' failed: %d Handle: %d. This %s might not be supported by this device\n", pFeatureName, objResult, hObj, pFeatureType ); + } + } + else + { + printf( "DMR_FindList failed: %d. Lists of type %d are not available for this device\n", dmrResult, type ); + } + return hObj; +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver feature list +HOBJ getDriverList( HDRV hDrv, const char* pListName, const char* pAddListName, TDMR_ListType type ) +//----------------------------------------------------------------------------- +{ + return getDriverFeature( hDrv, pListName, "list", pAddListName, type, smIgnoreProperties | smIgnoreMethods ); +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver property +HOBJ getDriverProperty( HDRV hDrv, const char* pPropName, const char* pAddListName, TDMR_ListType type ) +//----------------------------------------------------------------------------- +{ + return getDriverFeature( hDrv, pPropName, "property", pAddListName, type, smIgnoreLists | smIgnoreMethods ); +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver property +HOBJ getDriverMethod( HDRV hDrv, const char* pPropName, const char* pAddListName, TDMR_ListType type ) +//----------------------------------------------------------------------------- +{ + return getDriverFeature( hDrv, pPropName, "method", pAddListName, type, smIgnoreProperties | smIgnoreLists ); +} + +//----------------------------------------------------------------------------- +HOBJ getDeviceProp( HDEV hDev, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR objResult; + HOBJ hProp = INVALID_ID; + + // try to locate the property + if( ( objResult = OBJ_GetHandleEx( hDev, pPropName, &hProp, 0, -1 ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "OBJ_GetHandleEx failed for property '%s': %d Handle: %d\n", pPropName, objResult, hProp ); + } + return hProp; +} + +//----------------------------------------------------------------------------- +HOBJ getInfoProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltInfo ); +} + +//----------------------------------------------------------------------------- +HOBJ getIOSubSystemProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltIOSubSystem ); +} + +//----------------------------------------------------------------------------- +HOBJ getRequestCtrlProp( HDRV hDrv, const char* pRequestCtrlName, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, pRequestCtrlName, dmltRequestCtrl ); +} + +//----------------------------------------------------------------------------- +HOBJ getRequestProp( HDRV hDrv, int requestNr, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + char buf[BUF_SIZE]; + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + sprintf_s( buf, BUF_SIZE, "Entry %d", requestNr ); +#else + sprintf( buf, "Entry %d", requestNr ); +#endif // #if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + return getDriverProperty( hDrv, pPropName, buf, dmltRequest ); +} + +//----------------------------------------------------------------------------- +HOBJ getSettingProp( HDRV hDrv, const char* pSettingName, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, pSettingName, dmltSetting ); +} + +//----------------------------------------------------------------------------- +HOBJ getSettingMethod( HDRV hDrv, const char* pSettingName, const char* pMethodName ) +//----------------------------------------------------------------------------- +{ + return getDriverMethod( hDrv, pMethodName, pSettingName, dmltSetting ); +} + +//----------------------------------------------------------------------------- +HOBJ getStatisticProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltStatistics ); +} + +//----------------------------------------------------------------------------- +HOBJ getSystemSettingProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltSystemSettings ); +} + +//----------------------------------------------------------------------------- +TPROPHANDLING_ERROR getStringValue( HOBJ hObj, char** pBuf, int index ) +//----------------------------------------------------------------------------- +{ + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + static const int BUFFER_INCREMENT_FACTOR = 2; + + *pBuf = ( char* )calloc( 1, bufSize ); + while( ( result = OBJ_GetS( hObj, *pBuf, bufSize, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + *pBuf = ( char* )realloc( *pBuf, bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + printf( "Error while reading string property value: Error code: %d(%s).\n", result, DMR_ErrorCodeToString( result ) ); + } + return result; +} + +//----------------------------------------------------------------------------- +TPROPHANDLING_ERROR getValueAsString( HOBJ hObj, const char* pFormat, char** pBuf, int index ) +//----------------------------------------------------------------------------- +{ + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + *pBuf = ( char* )calloc( 1, bufSize ); + while( ( result = OBJ_GetSFormattedEx( hObj, *pBuf, &bufSize, pFormat, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + *pBuf = ( char* )realloc( *pBuf, bufSize ); + } + + if( result != PROPHANDLING_NO_ERROR ) + { + printf( "Error while reading string property value: Error code: %d(%s).\n", result, DMR_ErrorCodeToString( result ) ); + } + return result; +} + +//----------------------------------------------------------------------------- +// Start the acquisition manually if this was requested(this is to prepare the driver for data capture and tell the device to start streaming data) +// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStartAcquisitionIfNeeded( HDRV hDrv ) +//----------------------------------------------------------------------------- +{ + const TDMR_ERROR result = DMR_AcquisitionStart( hDrv ); + if( ( result != DMR_NO_ERROR ) && + ( result != DMR_FEATURE_NOT_AVAILABLE ) ) + { + printf( "DMR_AcquisitionStart: Unexpected error(code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) ); + } +} + +//----------------------------------------------------------------------------- +// Stop the acquisition manually if this was requested. +// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStopAcquisitionIfNeeded( HDRV hDrv ) +//----------------------------------------------------------------------------- +{ + const TDMR_ERROR result = DMR_AcquisitionStop( hDrv ); + if( ( result != DMR_NO_ERROR ) && + ( result != DMR_FEATURE_NOT_AVAILABLE ) ) + { + printf( "DMR_AcquisitionStop: Unexpected error(code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) ); + } +} + +//----------------------------------------------------------------------------- +void modifyEnumPropertyI( HDRV hDrv, const char* pSettingName, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + HOBJ hProp = INVALID_ID; + unsigned int dictValCount = 0; + int* dictVals = NULL; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + printf( "Trying to modify property %s:\n", pPropName ); + if( ( hProp = getSettingProp( hDrv, pSettingName, pPropName ) ) != INVALID_ID ) + { + if( ( result = readTranslationDictValuesI( hProp, &dictVals, &dictValCount, 0 ) ) == PROPHANDLING_NO_ERROR ) + { + int value = 0; + printf( "Please select one of the values listed above: " ); + value = getIntValFromSTDIn(); + free( dictVals ); + // set the new trigger mode + if( ( result = OBJ_SetI( hProp, value, 0 ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "Failed to set new value for %s. Error code: %d(%s).\n", pPropName, result, DMR_ErrorCodeToString( result ) ); + } + } + } +} + +//----------------------------------------------------------------------------- +TPROPHANDLING_ERROR readTranslationDictValuesI( HOBJ hObj, int** pDictValues, unsigned int* pDictValCnt, unsigned int silent ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR funcResult = PROPHANDLING_NO_ERROR; + char** ppBuf = 0; + unsigned int i = 0; + size_t bufSize = 0; + const size_t BUFFER_INCREMENT_FACTOR = 6; + + if( ( funcResult = OBJ_GetDictSize( hObj, pDictValCnt ) ) != PROPHANDLING_NO_ERROR ) + { + return funcResult; + } + + *pDictValues = ( int* )calloc( *pDictValCnt, sizeof( int ) ); + if( !( *pDictValues ) ) + { + printf( "Failed to allocate memory for integer dictionary!\n" ); + return PROPHANDLING_INPUT_BUFFER_TOO_SMALL; + } + ppBuf = ( char** )calloc( *pDictValCnt, sizeof( char* ) ); + if( !ppBuf ) + { + free( *pDictValues ); + printf( "Failed to allocate memory for string dictionary!\n" ); + return PROPHANDLING_INPUT_BUFFER_TOO_SMALL; + } + + bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( i = 0; i < *pDictValCnt; i++ ) + { + ppBuf[i] = ( char* )calloc( 1, bufSize ); + } + + while( ( funcResult = OBJ_GetIDictEntries( hObj, ppBuf, bufSize, *pDictValues, ( size_t ) * pDictValCnt ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( i = 0; i < *pDictValCnt; i++ ) + { + ppBuf[i] = ( char* )realloc( ppBuf[i], bufSize ); + } + } + + if( ( funcResult == PROPHANDLING_NO_ERROR ) && + ( silent == 0 ) ) + { + printf( "Got the following dictionary:\n" ); + for( i = 0; i < *pDictValCnt; i++ ) + { + printf( "[%d]: %s(numerical rep: %d)\n", i, ppBuf[i] ? ppBuf[i] : "!NO MEMORY!", ( *pDictValues )[i] ); + } + } + + // free memory again + for( i = 0; i < *pDictValCnt; i++ ) + { + free( ppBuf[i] ); + } + free( ppBuf ); + return funcResult; +} + +//----------------------------------------------------------------------------- +void conditionalSetPropI( HOBJ hProp, int value, unsigned int silent ) +//----------------------------------------------------------------------------- +{ + unsigned int dictValCount = 0; + size_t i = 0; + int* dictVals = NULL; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + char bufName[BUF_SIZE_LARGE]; + char* pBufValue = 0; + + if( ( result = readTranslationDictValuesI( hProp, &dictVals, &dictValCount, silent ) ) == PROPHANDLING_NO_ERROR ) + { + for( i = 0; i < dictValCount; i++ ) + { + if( dictVals[i] == value ) + { + setPropI( hProp, value, 0 ); + memset( bufName, '\0', BUF_SIZE_LARGE ); + OBJ_GetName( hProp, bufName, BUF_SIZE_LARGE ); + getValueAsString( hProp, 0, &pBufValue, 0 ); + if( silent == 0 ) + { + printf( "Property '%s' set to '%s'.\n", bufName, pBufValue ); + } + free( pBufValue ); + break; + } + } + free( dictVals ); + } + else + { + printf( "Failed to read translation dictionary from property. Error code: %d(%s).\n", result, DMR_ErrorCodeToString( result ) ); + } +} + +//----------------------------------------------------------------------------- +int getDeviceFromUserInput( HDEV* phDevice, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn, unsigned int automaticallyUseGenICamInterface ) +//----------------------------------------------------------------------------- +{ + TDMR_ERROR result = DMR_NO_ERROR; + unsigned int i = 0; + unsigned int deviceCount = 0; + unsigned int deviceNumber = 0; + HOBJ hPropSerial = INVALID_ID; + HOBJ hPropProduct = INVALID_ID; + HOBJ hPropInterfaceLayout = INVALID_ID; + HOBJ hPropAcquisitionStartStopBehaviour = INVALID_ID; + char* pSerialStringBuffer = NULL; + char* pProductStringBuffer = NULL; + + if( ( result = DMR_GetDeviceCount( &deviceCount ) ) != DMR_NO_ERROR ) + { + printf( "DMR_GetDeviceCount failed (code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) ); + END_APPLICATION; + } + + if( deviceCount == 0 ) + { + printf( "No compliant device detected.\n" ); + END_APPLICATION; + } + + printf( "%d compliant devices detected.\n", deviceCount ); + for( i = 0; i < deviceCount; i++ ) + { + // try to get access to the device + if( ( result = DMR_GetDevice( phDevice, dmdsmSerial, "*", i, '*' ) ) != DMR_NO_ERROR ) + { + printf( "DMR_GetDevice(%d) failed (code: %d(%s))\n", i, result, DMR_ErrorCodeToString( result ) ); + END_APPLICATION; + } + + if( ( hPropSerial = getDeviceProp( *phDevice, "Serial" ) ) == INVALID_ID ) + { + continue; + } + getStringValue( hPropSerial, &pSerialStringBuffer, 0 ); + if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( *phDevice ) ) + { + if( ( hPropProduct = getDeviceProp( *phDevice, "Product" ) ) == INVALID_ID ) + { + continue; + } + getStringValue( hPropProduct, &pProductStringBuffer, 0 ); + printf( "[%d] %s (%s", i, pSerialStringBuffer, pProductStringBuffer ); + if( ( hPropInterfaceLayout = getDeviceProp( *phDevice, "InterfaceLayout" ) ) != INVALID_ID ) + { + char* pStringBuffer = NULL; + getValueAsString( hPropInterfaceLayout, NULL, &pStringBuffer, 0 ); + if( automaticallyUseGenICamInterface != 0 ) + { + conditionalSetPropI( hPropInterfaceLayout, dilGenICam, 1 ); + } + printf( ", interface layout: %s", pStringBuffer ); + free( pStringBuffer ); + } + + if( ( hPropAcquisitionStartStopBehaviour = getDeviceProp( *phDevice, "AcquisitionStartStopBehaviour" ) ) != INVALID_ID ) + { + char* pStringBuffer = NULL; + conditionalSetPropI( hPropAcquisitionStartStopBehaviour, assbUser, 1 ); + getValueAsString( hPropAcquisitionStartStopBehaviour, NULL, &pStringBuffer, 0 ); + printf( ", acquisition start/stop behaviour: %s", pStringBuffer ); + free( pStringBuffer ); + } + printf( ")\n" ); + free( pProductStringBuffer ); + } + else + { + printf( "%s is not supported by this application.\n", pSerialStringBuffer ); + } + free( pSerialStringBuffer ); + } + + printf( "Please enter the number in brackets followed by [ENTER] to open it: " ); + deviceNumber = getIntValFromSTDIn(); + // remove the '\n' from the stream + fgetc( stdin ); + + // try to get access to the selected device + if( ( result = DMR_GetDevice( phDevice, dmdsmSerial, "*", deviceNumber, '*' ) ) != DMR_NO_ERROR ) + { + printf( "DMR_GetDevice(%d) failed (code: %d(%s))\n", deviceNumber, result, DMR_ErrorCodeToString( result ) ); + printf( "DMR_Close: %d\n", DMR_Close() ); + END_APPLICATION; + } + + return 0; +} + +//----------------------------------------------------------------------------- +static unsigned int isFeatureFlagSet( HOBJ hObj, TComponentFlag flag ) +//----------------------------------------------------------------------------- +{ + TComponentFlag flags; + + if( ( hObj == INVALID_ID ) || + ( OBJ_GetFlags( hObj, &flags ) != PROPHANDLING_NO_ERROR ) ) + { + return 0; + } + + return ( ( flags & flag ) != 0 ); +} + +//----------------------------------------------------------------------------- +unsigned int isFeatureReadable( HOBJ hObj ) +//----------------------------------------------------------------------------- +{ + return isFeatureFlagSet( hObj, cfReadAccess ); +} + +//----------------------------------------------------------------------------- +unsigned int isFeatureWriteable( HOBJ hObj ) +//----------------------------------------------------------------------------- +{ + return isFeatureFlagSet( hObj, cfWriteAccess ); +} + +#if defined(linux) || defined(__linux) || defined(__linux__) +# include +# include +//----------------------------------------------------------------------------- +// returns 0 if timeout, else 1 +unsigned waitForInput( int maxWait_sec, int fd ) +//----------------------------------------------------------------------------- +{ + fd_set rfds; + struct timeval tv; + + FD_ZERO( &rfds ); + FD_SET( fd, &rfds ); + + tv.tv_sec = maxWait_sec ; + tv.tv_usec = 0; + + return select( fd + 1, &rfds, NULL, NULL, &tv ); +} +#endif // #if defined(linux) || defined(__linux) || defined(__linux__) diff --git a/Cigarette/Common/exampleHelper_C.h b/Cigarette/Common/exampleHelper_C.h new file mode 100644 index 0000000..feafd42 --- /dev/null +++ b/Cigarette/Common/exampleHelper_C.h @@ -0,0 +1,71 @@ +//----------------------------------------------------------------------------- +#ifndef exampleHelper_CH +#define exampleHelper_CH exampleHelper_CH +//----------------------------------------------------------------------------- +#include + +#define END_APPLICATION \ + printf( "Press [ENTER] to end the application.\n" ); \ + return getchar() == EOF ? 2 : 1; + +#if defined(linux) || defined(__linux) || defined(__linux__) +unsigned waitForInput( int maxWait_sec, int fd ); +#endif // #if defined(linux) || defined(__linux) || defined(__linux__) + +int getIntValFromSTDIn( void ); +int getPropI( HOBJ hProp, int index ); +void setPropI( HOBJ hProp, int value, int index ); +int64_type getPropI64( HOBJ hProp, int index ); +void setPropI64( HOBJ hProp, int64_type value, int index ); +void* getPropP( HOBJ hProp, int index ); +void setPropP( HOBJ hProp, void* value, int index ); +void setPropS( HOBJ hProp, const char* pVal, int index ); + +HOBJ getDriverList( HDRV hDrv, const char* pListName, const char* pAddListName, TDMR_ListType type ); +HOBJ getDriverProperty( HDRV hDrv, const char* pPropName, const char* pAddListName, TDMR_ListType type ); +HOBJ getDriverMethod( HDRV hDrv, const char* pMethodName, const char* pAddListName, TDMR_ListType type ); +HOBJ getDeviceProp( HDEV hDev, const char* pPropName ); +HOBJ getInfoProp( HDRV hDrv, const char* pPropName ); +HOBJ getIOSubSystemProp( HDRV hDrv, const char* pPropName ); +HOBJ getRequestCtrlProp( HDRV hDrv, const char* pRequestCtrlName, const char* pPropName ); +HOBJ getRequestProp( HDRV hDrv, int requestNr, const char* pPropName ); +HOBJ getSettingProp( HDRV hDrv, const char* pSettingName, const char* pPropName ); +HOBJ getSettingMethod( HDRV hDrv, const char* pSettingName, const char* pMethodName ); +HOBJ getStatisticProp( HDRV hDrv, const char* pPropName ); +HOBJ getSystemSettingProp( HDRV hDrv, const char* pPropName ); + +unsigned int isFeatureReadable( HOBJ hObj ); +unsigned int isFeatureWriteable( HOBJ hObj ); + +typedef unsigned int( *SUPPORTED_DEVICE_CHECK )( const HDEV ); + +int getDeviceFromUserInput( HDEV* phDevice, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn, unsigned int automaticallyUseGenICamInterface ); +/// \brief Reads the value of a feature as a string +/// \note +/// pBuf must be freed by the caller +TPROPHANDLING_ERROR getStringValue( HOBJ hObj, char** pBuf, int index ); +/// \brief Reads the value of a feature as a string +/// \note +/// pBuf must be freed by the caller +TPROPHANDLING_ERROR getValueAsString( HOBJ hObj, const char* pFormat, char** pBuf, int index ); +void modifyEnumPropertyI( HDRV hDrv, const char* pSettingName, const char* pPropName ); +/// \brief Shows how to read the translation dictionary of an integer property and returns all the +/// integer values in the dictionary. +/// +/// \note +/// \a pDictValues must be freed by the caller. +TPROPHANDLING_ERROR readTranslationDictValuesI( HOBJ hObj, int** pDictValues, unsigned int* pDictValCnt, unsigned int silent ); +/// \brief Sets an enumerated integer property to a certain value if this value is supported by +/// the property. +void conditionalSetPropI( HOBJ hObj, int value, unsigned int silent ); + +/// \brief Start the acquisition manually if this was requested(this is to prepare the driver for data capture and tell the device to start streaming data) +/// +/// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStartAcquisitionIfNeeded( HDRV hDrv ); +/// \brief Stop the acquisition manually if this was requested. +/// +/// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStopAcquisitionIfNeeded( HDRV hDrv ); + +#endif // exampleHelper_CH diff --git a/Cigarette/Common/mv.ico b/Cigarette/Common/mv.ico new file mode 100644 index 0000000..906b2a1 Binary files /dev/null and b/Cigarette/Common/mv.ico differ diff --git a/Cigarette/Common/mvIcon.xpm b/Cigarette/Common/mvIcon.xpm new file mode 100644 index 0000000..57a1ac7 --- /dev/null +++ b/Cigarette/Common/mvIcon.xpm @@ -0,0 +1,296 @@ +//----------------------------------------------------------------------------- +#ifndef MV_ICON_XPM +#define MV_ICON_XPM MV_ICON_XPM +//----------------------------------------------------------------------------- + +static const char* mvIcon_xpm[] = { +"32 32 255 2", +" c #000100", +". c #030005", +"+ c #01000D", +"@ c #000206", +"# c #03011D", +"$ c #000407", +"% c #000222", +"& c #010315", +"* c #000319", +"= c #000225", +"- c #000509", +"; c #01070B", +"> c #050803", +", c #000912", +"' c #010929", +") c #000B18", +"! c #080B07", +"~ c #05092E", +"{ c #020B2A", +"] c #000C29", +"^ c #020C3A", +"/ c #080D1E", +"( c #000E30", +"_ c #000F2C", +": c #020E36", +"< c #0F1315", +"[ c #05143B", +"} c #001743", +"| c #00193A", +"1 c #021844", +"2 c #071839", +"3 c #14181A", +"4 c #0B1840", +"5 c #001B4C", +"6 c #001D48", +"7 c #021E55", +"8 c #191C1E", +"9 c #081E45", +"0 c #05213D", +"a c #101F32", +"b c #062153", +"c c #002742", +"d c #1C2128", +"e c #172231", +"f c #00265D", +"g c #11253D", +"h c #08274E", +"i c #1B2338", +"j c #002955", +"k c #102648", +"l c #0F2945", +"m c #092B4C", +"n c #072B5D", +"o c #22282E", +"p c #0A2E4A", +"q c #0D2D4E", +"r c #003061", +"s c #013067", +"t c #162D3F", +"u c #142D4A", +"v c #1F2B3A", +"w c #073057", +"x c #0B2F5C", +"y c #113052", +"z c #053466", +"A c #063651", +"B c #00375D", +"C c #00366C", +"D c #242F3E", +"E c #0E345B", +"F c #053762", +"G c #003970", +"H c #0D3758", +"I c #12365D", +"J c #2E3133", +"K c #0D3769", +"L c #003B6C", +"M c #10366F", +"N c #0A3965", +"O c #153663", +"P c #0E386B", +"Q c #2B333E", +"R c #043B72", +"S c #143860", +"T c #23354E", +"U c #353337", +"V c #113A6C", +"W c #073D74", +"X c #0B3F59", +"Y c #133B6D", +"Z c #153A72", +"` c #323638", +" . c #0E3E64", +".. c #35383A", +"+. c #2E3949", +"@. c #1A4061", +"#. c #17406D", +"$. c #154269", +"%. c #124465", +"&. c #264058", +"*. c #084963", +"=. c #3E3C3F", +"-. c #333E59", +";. c #2C4260", +">. c #294467", +",. c #3E4244", +"'. c #104E6E", +"). c #3E444B", +"!. c #44434C", +"~. c #00566F", +"{. c #175066", +"]. c #324867", +"^. c #3E4752", +"/. c #464755", +"(. c #324C70", +"_. c #0D5878", +":. c #484C4E", +"<. c #424D5E", +"[. c #37506A", +"}. c #474D54", +"|. c #00607F", +"1. c #165B6F", +"2. c #00637B", +"3. c #4E504D", +"4. c #3E5373", +"5. c #475263", +"6. c #455369", +"7. c #50524F", +"8. c #0A6483", +"9. c #4E545C", +"0. c #3A5877", +"a. c #505456", +"b. c #126578", +"c. c #006B89", +"d. c #405A73", +"e. c #505965", +"f. c #4A5C6C", +"g. c #565A5C", +"h. c #0A6F81", +"i. c #4E5D73", +"j. c #515D6E", +"k. c #555D6A", +"l. c #176F88", +"m. c #456282", +"n. c #0F7391", +"o. c #4F6272", +"p. c #5D6163", +"q. c #45668B", +"r. c #62616A", +"s. c #007C99", +"t. c #596476", +"u. c #52687D", +"v. c #0C7D8E", +"w. c #516A85", +"x. c #61676F", +"y. c #576A7A", +"z. c #207A8C", +"A. c #1A7E96", +"B. c #606C7E", +"C. c #526F8F", +"D. c #008898", +"E. c #636C78", +"F. c #5F7283", +"G. c #68717D", +"H. c #25849C", +"I. c #188AA1", +"J. c #0095A4", +"K. c #647A90", +"L. c #2F8B97", +"M. c #75797C", +"N. c #747B82", +"O. c #338EA6", +"P. c #2497A7", +"Q. c #06A1B6", +"R. c #6C85A1", +"S. c #7F827F", +"T. c #199FAE", +"U. c #3D96A2", +"V. c #3D96AF", +"W. c #758899", +"X. c #838991", +"Y. c #808E94", +"Z. c #858F9C", +"`. c #579EA6", +" + c #589EB3", +".+ c #949296", +"++ c #8F959D", +"@+ c #3BADB6", +"#+ c #919598", +"$+ c #35AFBE", +"%+ c #60A7BB", +"&+ c #919AA7", +"*+ c #6AA7B1", +"=+ c #999C98", +"-+ c #92A3AF", +";+ c #75ADBE", +">+ c #92A6B8", +",+ c #57B9C4", +"'+ c #7EAFB5", +")+ c #85B5C7", +"!+ c #A8ADAF", +"~+ c #A1AFB6", +"{+ c #8DB6BD", +"]+ c #73C4CA", +"^+ c #6FC5D1", +"/+ c #90BCC9", +"(+ c #B2B6B9", +"_+ c #9FBDC0", +":+ c #B1B8C1", +"<+ c #9DC1CF", +"[+ c #B0BEC5", +"}+ c #BABCB9", +"|+ c #B4BDCB", +"1+ c #B7BEC6", +"2+ c #ACC2C7", +"3+ c #BABFC1", +"4+ c #86CED6", +"5+ c #B1C3CF", +"6+ c #AAC6D6", +"7+ c #BFC6CE", +"8+ c #B3CACE", +"9+ c #AFCBDB", +"0+ c #C4C9CC", +"a+ c #C1CDCE", +"b+ c #BCCEDA", +"c+ c #9BD9E3", +"d+ c #9ED9DD", +"e+ c #BED0DC", +"f+ c #C7CED6", +"g+ c #C6CFDE", +"h+ c #CBCFD2", +"i+ c #C6D3D3", +"j+ c #D0D5D7", +"k+ c #D2D5D1", +"l+ c #D1D8E1", +"m+ c #D3D8DA", +"n+ c #B0E3E9", +"o+ c #D7DBDE", +"p+ c #DEE0DD", +"q+ c #DCE3EB", +"r+ c #C2ECF3", +"s+ c #C5ECED", +"t+ c #E1E6E9", +"u+ c #E8ECEF", +"v+ c #D4F3F6", +"w+ c #EEF2F5", +"x+ c #E2F9FE", +"y+ c #F3F8FA", +"z+ c #F6F8F5", +"A+ c #E8FDFC", +"B+ c #F7FBFE", +"C+ c #F2FEFF", +"D+ c #FBFDFA", +"E+ c #FAFFFF", +"F+ c #FDFFFC", +": : [ 4 9 h w H %.'._.8.l.A.I.P.Q.$+,+^+4+c+n+r+v+x+A+E+F+F+F+F+", +"{ ( ( 2 | 0 c p A X *.{.1.b.h.v.v.L.U.`.*+'+{+_+2+8+a+i+j+k+k+j+", +"$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ > > > > $ > > > > - > > > ", +" ", +" ", +" ", +"$ $ $ $ $ $ $ $ $ $ > 8 8 ; $ $ ", +"$ $ $ $ $ $ $ $ $ ` S.(+p+z+u+j+(+S.U $ $ $ $ $ $ $ $ $ ", +"$ $ $ $ $ $ $ 7.(+F+F+F+F+F+F+F+F+F+B+(+3. $ $ $ $ $ $ $ ", +"$ $ $ $ $ $ =.}+F+F+F+!+:.8 3 ,.=+z+F+F+F+F+(+.. $ $ $ $ $ $ ", +", , , . g.D+F+F+t+,. 3 8 J o+F+F+F+F+B+p. . $ $ $ ", +", , }.:.$ t+F+F+j+< p.o+F+F+B+M. ! o+F+F+F+F+w+- J }. $ , ", +") !.y+:.d F+F+B+J #+F+F+0+.+0+F+!+ !.F+F+F+F+F+..o B+a. , ", +" !.B+F+) ).F+F+#+ x.F+F+p. r.F+9. h+F+F+F+F+r.. w+F+9. ", +").w+F+u+) 9.F+D+Q & u+F+++ ^.D !+0+ ++F+F+F+F+x.+ m+F+B+}.", +"o+F+F+y+e +.F+t+& <.F+F+D +.E.^.~++ N.o+ ++F+F+F+F+e./ u+F+F+w+", +"5.z+F+F+<.a F+j+& G.F+D+a f.X.i N.* h+Y. 3+F+F+F+D+t v B+F+F+k.", +"# <.z+F+Z.+ h+t+# y.F+F+t.* [+++/.0+j+& T B+F+F+F+h+& B.F+F+j.* ", +"l % 6.D+u+# y.F+0 &.F+F+o+] _ -+1+&+{ ] f+F+F+F+F+F.+ j+F+o.% g ", +"u q ( [.z+W.% o+W.= 7+F+F+f+-.= = = -.l+F+F+F+F+o+% u.F+i.{ l u ", +"q y y : ].7+;.[.7+[ ].F+F+F+E+:+&+1+F+F+F+F+F+y+;.k |+d.: q y q ", +"E E E E 6 @.w.1 m.w.^ K.F+F+F+F+F+F+F+F+F+F+u+4.^ 0.>.6 E E w E ", +"F F F F S j x I j $.F 5 C.t+F+F+F+F+F+F+F+|+(.5 I x j S E E E E ", +"O O O O O O z F O x F F 5 N R.5+q+q+l+>+q.b b F F O F F F F F F ", +"P P P P P P P P P P P L L n 7 r #.#.L f 7 z L K K K K K K K K K ", +"V V V V V V V V V V V V V V P C s s C K V V V V V V V V V V V V ", +"Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y R R R Y Y Y Y Y Y Y Y Y Y Y Y Y ", +"R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R ", +"W W W W W W R R R R R R R G G G G G M G G G M M C C M M M M M M ", +"W W W W W W W R R R R R R R Z G Z Z G G G M M M M G G G G G G M ", +"} 1 6 6 h h w B .%.'._.|.c.n.s.H.O.V. +%+;+)+/+<+6+9+b+e+g+g+g+", +"~ ~ : [ 2 k m H X *.~.2.l.z.D.J.T.@+,+]+4+d+n+s+v+A+C+E+F+F+F+F+"}; + +#endif // MV_ICON_XPM diff --git a/Cigarette/Common/qtIncludeEpilogue.h b/Cigarette/Common/qtIncludeEpilogue.h new file mode 100644 index 0000000..9867116 --- /dev/null +++ b/Cigarette/Common/qtIncludeEpilogue.h @@ -0,0 +1,3 @@ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( pop ) +#endif diff --git a/Cigarette/Common/qtIncludePrologue.h b/Cigarette/Common/qtIncludePrologue.h new file mode 100644 index 0000000..18f49bb --- /dev/null +++ b/Cigarette/Common/qtIncludePrologue.h @@ -0,0 +1,7 @@ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( push ) +# pragma warning( disable : 4127 ) // 'conditional expression is constant' +# pragma warning( disable : 4244 ) // 'conversion from 'Bla' to 'Blub', possible loss of data +# pragma warning( disable : 4251 ) // 'class 'Bla' needs to have dll-interface to be used by clients of class 'Blub'' +# pragma warning( disable : 4800 ) // 'int' : forcing value to bool 'true' or 'false' (performance warning) +#endif diff --git a/Cigarette/Common/win32/ProxyResolver.cpp b/Cigarette/Common/win32/ProxyResolver.cpp new file mode 100644 index 0000000..1c6a083 --- /dev/null +++ b/Cigarette/Common/win32/ProxyResolver.cpp @@ -0,0 +1,409 @@ +#include "ProxyResolver.h" + +#if _WIN32_WINNT < 0x0602 // This stuff became available with Windows 8 +# define WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE 0x01000000 +# define WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE +# define API_GET_PROXY_FOR_URL (6) +#endif // #if _WIN32_WINNT < _WIN32_WINNT_WIN8 + +PFNWINHTTPGETPROXYFORURLEX ProxyResolver::s_pfnWinhttpGetProxyForUrlEx = NULL; +PFNWINHTTPFREEPROXYLIST ProxyResolver::s_pfnWinhttpFreeProxyList = NULL; +PFNWINHTTPCREATEPROXYRESOLVER ProxyResolver::s_pfnWinhttpCreateProxyResolver = NULL; +PFNWINHTTPGETPROXYRESULT ProxyResolver::s_pfnWinhttpGetProxyResult = NULL; + +//----------------------------------------------------------------------------- +ProxyResolver::ProxyResolver() : m_fInit( FALSE ), m_fExtendedAPI( FALSE ), m_dwError( ERROR_SUCCESS ), m_hEvent( 0 ) +//----------------------------------------------------------------------------- +{ + ZeroMemory( &m_wprProxyResult, sizeof( WINHTTP_PROXY_RESULT ) ); + ZeroMemory( &m_wpiProxyInfo, sizeof( WINHTTP_PROXY_INFO ) ); + + HMODULE hWinhttp = GetModuleHandle( L"winhttp.dll" ); + if( hWinhttp != NULL ) + { + s_pfnWinhttpGetProxyForUrlEx = ( PFNWINHTTPGETPROXYFORURLEX )GetProcAddress( hWinhttp, "WinHttpGetProxyForUrlEx" ); + s_pfnWinhttpFreeProxyList = ( PFNWINHTTPFREEPROXYLIST )GetProcAddress( hWinhttp, "WinHttpFreeProxyResult" ); + s_pfnWinhttpCreateProxyResolver = ( PFNWINHTTPCREATEPROXYRESOLVER )GetProcAddress( hWinhttp, "WinHttpCreateProxyResolver" ); + s_pfnWinhttpGetProxyResult = ( PFNWINHTTPGETPROXYRESULT )GetProcAddress( hWinhttp, "WinHttpGetProxyResult" ); + } + m_fExtendedAPI = s_pfnWinhttpGetProxyForUrlEx && s_pfnWinhttpFreeProxyList && s_pfnWinhttpCreateProxyResolver && s_pfnWinhttpGetProxyResult; +} + +//----------------------------------------------------------------------------- +ProxyResolver::~ProxyResolver() +//----------------------------------------------------------------------------- +{ + if( m_wpiProxyInfo.lpszProxy != NULL ) + { + GlobalFree( m_wpiProxyInfo.lpszProxy ); + } + + if( m_wpiProxyInfo.lpszProxyBypass != NULL ) + { + GlobalFree( m_wpiProxyInfo.lpszProxyBypass ); + } + + if( m_fExtendedAPI ) + { + s_pfnWinhttpFreeProxyList( &m_wprProxyResult ); + } + + if( m_hEvent != NULL ) + { + CloseHandle( m_hEvent ); + } +} + +//----------------------------------------------------------------------------- +BOOL ProxyResolver::IsRecoverableAutoProxyError( _In_ DWORD dwError ) +//----------------------------------------------------------------------------- +{ + switch( dwError ) + { + case ERROR_SUCCESS: + case ERROR_INVALID_PARAMETER: + case ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR: + case ERROR_WINHTTP_AUTODETECTION_FAILED: + case ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT: + case ERROR_WINHTTP_LOGIN_FAILURE: + case ERROR_WINHTTP_OPERATION_CANCELLED: + case ERROR_WINHTTP_TIMEOUT: + case ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT: + case ERROR_WINHTTP_UNRECOGNIZED_SCHEME: + return TRUE; + default: + break; + } + return FALSE; +} + +//----------------------------------------------------------------------------- +VOID CALLBACK ProxyResolver::GetProxyCallBack( _In_ HINTERNET hResolver, _In_ DWORD_PTR dwContext, _In_ DWORD dwInternetStatus, _In_ PVOID pvStatusInformation, _In_ DWORD /*dwStatusInformationLength*/ ) +//----------------------------------------------------------------------------- +{ + ProxyResolver* pProxyResolver = ( ProxyResolver* )dwContext; + if( ( dwInternetStatus != WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE && + dwInternetStatus != WINHTTP_CALLBACK_STATUS_REQUEST_ERROR ) || + pProxyResolver == NULL ) + { + return; + } + + if( dwInternetStatus == WINHTTP_CALLBACK_STATUS_REQUEST_ERROR ) + { + WINHTTP_ASYNC_RESULT* pAsyncResult = ( WINHTTP_ASYNC_RESULT* )pvStatusInformation; + + if( pAsyncResult->dwResult != API_GET_PROXY_FOR_URL ) + { + return; + } + + pProxyResolver->m_dwError = pAsyncResult->dwError; + } + else if( dwInternetStatus == WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE ) + { + pProxyResolver->m_dwError = s_pfnWinhttpGetProxyResult( hResolver, &pProxyResolver->m_wprProxyResult ); + } + + if( hResolver != NULL ) + { + WinHttpCloseHandle( hResolver ); + hResolver = NULL; + } + + SetEvent( pProxyResolver->m_hEvent ); +} + +#define CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE(HRESOLVER, ERROR_CODE) \ + if( HRESOLVER != NULL ) \ + { \ + WinHttpCloseHandle( HRESOLVER ); \ + } \ + return ERROR_CODE + +//----------------------------------------------------------------------------- +DWORD ProxyResolver::GetProxyForUrlEx( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_ WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions ) +//----------------------------------------------------------------------------- +{ + // Create proxy resolver handle. It's best to close the handle during call back. + HINTERNET hResolver = NULL; + DWORD dwError = s_pfnWinhttpCreateProxyResolver( hSession, &hResolver ); + if( dwError != ERROR_SUCCESS ) + { + CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE( hResolver, dwError ); + } + + // Sets up a callback function that WinHTTP can call as proxy results are resolved. + WINHTTP_STATUS_CALLBACK wscCallback = WinHttpSetStatusCallback( hResolver, GetProxyCallBack, WINHTTP_CALLBACK_FLAG_REQUEST_ERROR | WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE, 0 ); + if( wscCallback == WINHTTP_INVALID_STATUS_CALLBACK ) + { + dwError = GetLastError(); + CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE( hResolver, dwError ); + } + + // The extended API works in asynchronous mode, therefore wait until the + // results are set in the call back function. + dwError = s_pfnWinhttpGetProxyForUrlEx( hResolver, pwszUrl, pAutoProxyOptions, ( DWORD_PTR )this ); + if( dwError != ERROR_IO_PENDING ) + { + CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE( hResolver, dwError ); + } + + // The resolver handle will get closed in the callback and cannot be used any longer. + hResolver = NULL; + dwError = WaitForSingleObjectEx( m_hEvent, INFINITE, FALSE ); + if( dwError != WAIT_OBJECT_0 ) + { + return GetLastError(); + } + return m_dwError; +} + +//----------------------------------------------------------------------------- +_Success_( return == ERROR_SUCCESS ) DWORD ProxyResolver::GetProxyForAutoSettings( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_opt_z_ PCWSTR pwszAutoConfigUrl, _Outptr_result_maybenull_ PWSTR* ppwszProxy, _Outptr_result_maybenull_ PWSTR* ppwszProxyBypass ) +//----------------------------------------------------------------------------- +{ + DWORD dwError = ERROR_SUCCESS; + WINHTTP_AUTOPROXY_OPTIONS waoOptions = {}; + WINHTTP_PROXY_INFO wpiProxyInfo = {}; + + *ppwszProxy = NULL; + *ppwszProxyBypass = NULL; + + if( pwszAutoConfigUrl ) + { + waoOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; + waoOptions.lpszAutoConfigUrl = pwszAutoConfigUrl; + } + else + { + waoOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT; + waoOptions.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A; + } + + // First call with no autologon. Autologon prevents the + // session (in proc) or autoproxy service (out of proc) from caching + // the proxy script. This causes repetitive network traffic, so it is + // best not to do autologon unless it is required according to the + // result of WinHttpGetProxyForUrl. + // This applies to both WinHttpGetProxyForUrl and WinhttpGetProxyForUrlEx. + if( m_fExtendedAPI ) + { + m_hEvent = CreateEventEx( NULL, NULL, 0, EVENT_ALL_ACCESS ); + if( m_hEvent == NULL ) + { + dwError = GetLastError(); + goto quit; + } + + dwError = GetProxyForUrlEx( hSession, pwszUrl, &waoOptions ); + if( dwError != ERROR_WINHTTP_LOGIN_FAILURE ) + { + // Unless we need to retry with auto-logon exit the function with the + // result, on success the proxy list will be stored in m_wprProxyResult + // by GetProxyCallBack. + goto quit; + } + + // Enable autologon if challenged. + waoOptions.fAutoLogonIfChallenged = TRUE; + dwError = GetProxyForUrlEx( hSession, pwszUrl, &waoOptions ); + goto quit; + } + + if( !WinHttpGetProxyForUrl( hSession, pwszUrl, &waoOptions, &wpiProxyInfo ) ) + { + dwError = GetLastError(); + if( dwError != ERROR_WINHTTP_LOGIN_FAILURE ) + { + goto quit; + } + + // Enable autologon if challenged. + dwError = ERROR_SUCCESS; + waoOptions.fAutoLogonIfChallenged = TRUE; + if( !WinHttpGetProxyForUrl( hSession, pwszUrl, &waoOptions, &wpiProxyInfo ) ) + { + dwError = GetLastError(); + goto quit; + } + } + + *ppwszProxy = wpiProxyInfo.lpszProxy; + wpiProxyInfo.lpszProxy = NULL; + + *ppwszProxyBypass = wpiProxyInfo.lpszProxyBypass; + wpiProxyInfo.lpszProxyBypass = NULL; + +quit: + + if( wpiProxyInfo.lpszProxy ) + { + GlobalFree( wpiProxyInfo.lpszProxy ); + wpiProxyInfo.lpszProxy = NULL; + } + + if( wpiProxyInfo.lpszProxyBypass ) + { + GlobalFree( wpiProxyInfo.lpszProxyBypass ); + wpiProxyInfo.lpszProxyBypass = NULL; + } + + return dwError; +} + +//----------------------------------------------------------------------------- +DWORD ProxyResolver::ResolveProxy( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl ) +//----------------------------------------------------------------------------- +{ + DWORD dwError = ERROR_SUCCESS; + WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ProxyConfig = {}; + PWSTR pwszProxy = NULL; + PWSTR pwszProxyBypass = NULL; + BOOL fFailOverValid = FALSE; + + if( m_fInit ) + { + dwError = ERROR_INVALID_OPERATION; + goto quit; + } + + if( !WinHttpGetIEProxyConfigForCurrentUser( &ProxyConfig ) ) + { + dwError = GetLastError(); + if( dwError != ERROR_FILE_NOT_FOUND ) + { + goto quit; + } + + // No IE proxy settings found, just do autodetect. + ProxyConfig.fAutoDetect = TRUE; + dwError = ERROR_SUCCESS; + } + + // Begin processing the proxy settings in the following order: + // 1) Auto-Detect if configured. + // 2) Auto-Config URL if configured. + // 3) Static Proxy Settings if configured. + // + // Once any of these methods succeed in finding a proxy we are finished. + // In the event one mechanism fails with an expected error code it is + // required to fall back to the next mechanism. If the request fails + // after exhausting all detected proxies, there should be no attempt + // to discover additional proxies. + if( ProxyConfig.fAutoDetect ) + { + fFailOverValid = TRUE; + // Detect Proxy Settings. + dwError = GetProxyForAutoSettings( hSession, pwszUrl, NULL, &pwszProxy, &pwszProxyBypass ); + if( dwError == ERROR_SUCCESS ) + { + goto commit; + } + + if( !IsRecoverableAutoProxyError( dwError ) ) + { + goto quit; + } + + // Fall back to Autoconfig URL or Static settings. An application can + // optionally take some action such as logging, or creating a mechanism + // to expose multiple error codes in the class. + dwError = ERROR_SUCCESS; + } + + if( ProxyConfig.lpszAutoConfigUrl ) + { + fFailOverValid = TRUE; + // Run autoproxy with AutoConfig URL. + dwError = GetProxyForAutoSettings( hSession, pwszUrl, ProxyConfig.lpszAutoConfigUrl, &pwszProxy, &pwszProxyBypass ); + if( dwError == ERROR_SUCCESS ) + { + goto commit; + } + + if( !IsRecoverableAutoProxyError( dwError ) ) + { + goto quit; + } + + // Fall back to Static Settings. An application can optionally take some + // action such as logging, or creating a mechanism to to expose multiple + // error codes in the class. + dwError = ERROR_SUCCESS; + } + + fFailOverValid = FALSE; + // Static Proxy Config. Failover is not valid for static proxy since + // it is always either a single proxy or a list containing protocol + // specific proxies such as "proxy" or http=httpproxy;https=sslproxy + pwszProxy = ProxyConfig.lpszProxy; + ProxyConfig.lpszProxy = NULL; + + pwszProxyBypass = ProxyConfig.lpszProxyBypass; + ProxyConfig.lpszProxyBypass = NULL; + +commit: + + if( pwszProxy == NULL ) + { + m_wpiProxyInfo.dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY; + } + else + { + m_wpiProxyInfo.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; + } + + m_wpiProxyInfo.lpszProxy = pwszProxy; + pwszProxy = NULL; + + m_wpiProxyInfo.lpszProxyBypass = pwszProxyBypass; + pwszProxyBypass = NULL; + + m_fInit = TRUE; + +quit: + + if( pwszProxy != NULL ) + { + GlobalFree( pwszProxy ); + pwszProxy = NULL; + } + + if( pwszProxyBypass != NULL ) + { + GlobalFree( pwszProxyBypass ); + pwszProxyBypass = NULL; + } + + if( ProxyConfig.lpszAutoConfigUrl != NULL ) + { + GlobalFree( ProxyConfig.lpszAutoConfigUrl ); + ProxyConfig.lpszAutoConfigUrl = NULL; + } + + if( ProxyConfig.lpszProxy != NULL ) + { + GlobalFree( ProxyConfig.lpszProxy ); + ProxyConfig.lpszProxy = NULL; + } + + if( ProxyConfig.lpszProxyBypass != NULL ) + { + GlobalFree( ProxyConfig.lpszProxyBypass ); + ProxyConfig.lpszProxyBypass = NULL; + } + + return dwError; +} + +//----------------------------------------------------------------------------- +const WINHTTP_PROXY_RESULT_ENTRY* ProxyResolver::GetProxySetting( const DWORD index ) const +//----------------------------------------------------------------------------- +{ + if( index < m_wprProxyResult.cEntries ) + { + return &m_wprProxyResult.pEntries[index]; + } + return 0; +} diff --git a/Cigarette/Common/win32/ProxyResolver.h b/Cigarette/Common/win32/ProxyResolver.h new file mode 100644 index 0000000..946fb6f --- /dev/null +++ b/Cigarette/Common/win32/ProxyResolver.h @@ -0,0 +1,52 @@ +#pragma once +#include +#include + +#if _WIN32_WINNT < 0x0602 // This stuff became available with Windows 8 +typedef struct _WINHTTP_PROXY_RESULT_ENTRY +{ + BOOL fProxy; // Is this a proxy or DIRECT? + BOOL fBypass; // If DIRECT, is it bypassing a proxy (intranet) or is all traffic DIRECT (internet) + INTERNET_SCHEME ProxyScheme; // The scheme of the proxy, SOCKS, HTTP (CERN Proxy), HTTPS (SSL through Proxy) + PWSTR pwszProxy; // Hostname of the proxy. + INTERNET_PORT ProxyPort; // Port of the proxy. +} WINHTTP_PROXY_RESULT_ENTRY; + +typedef struct _WINHTTP_PROXY_RESULT +{ + DWORD cEntries; + WINHTTP_PROXY_RESULT_ENTRY* pEntries; +} WINHTTP_PROXY_RESULT; +#endif // #if _WIN32_WINNT < 0x0602 + +typedef DWORD ( WINAPI* PFNWINHTTPGETPROXYFORURLEX )( HINTERNET, PCWSTR, WINHTTP_AUTOPROXY_OPTIONS*, DWORD_PTR ); +typedef DWORD ( WINAPI* PFNWINHTTPFREEPROXYLIST )( WINHTTP_PROXY_RESULT* ); +typedef DWORD ( WINAPI* PFNWINHTTPCREATEPROXYRESOLVER )( HINTERNET, HINTERNET* ); +typedef DWORD ( WINAPI* PFNWINHTTPGETPROXYRESULT )( HINTERNET, WINHTTP_PROXY_RESULT* ); + +class ProxyResolver +{ + BOOL m_fInit; + BOOL m_fExtendedAPI; + DWORD m_dwError; + HANDLE m_hEvent; + WINHTTP_PROXY_INFO m_wpiProxyInfo; + WINHTTP_PROXY_RESULT m_wprProxyResult; + + BOOL IsRecoverableAutoProxyError( _In_ DWORD dwError ); + VOID static CALLBACK GetProxyCallBack( _In_ HINTERNET hResolver, _In_ DWORD_PTR dwContext, _In_ DWORD dwInternetStatus, _In_ PVOID pvStatusInformation, _In_ DWORD dwStatusInformationLength ); + DWORD GetProxyForUrlEx( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_ WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions ); + _Success_( return == ERROR_SUCCESS ) DWORD GetProxyForAutoSettings( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_opt_z_ PCWSTR pwszAutoConfigUrl, _Outptr_result_maybenull_ PWSTR* ppwszProxy, _Outptr_result_maybenull_ PWSTR* ppwszProxyBypass ); + + static PFNWINHTTPGETPROXYFORURLEX s_pfnWinhttpGetProxyForUrlEx; + static PFNWINHTTPFREEPROXYLIST s_pfnWinhttpFreeProxyList; + static PFNWINHTTPCREATEPROXYRESOLVER s_pfnWinhttpCreateProxyResolver; + static PFNWINHTTPGETPROXYRESULT s_pfnWinhttpGetProxyResult; + +public: + ProxyResolver(); + ~ProxyResolver(); + + DWORD ResolveProxy( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl ); + const WINHTTP_PROXY_RESULT_ENTRY* GetProxySetting( const DWORD index ) const; +}; diff --git a/Cigarette/Common/win32/ProxyResolverContext.cpp b/Cigarette/Common/win32/ProxyResolverContext.cpp new file mode 100644 index 0000000..9f65f9a --- /dev/null +++ b/Cigarette/Common/win32/ProxyResolverContext.cpp @@ -0,0 +1,232 @@ +//----------------------------------------------------------------------------- +#include "../ProxyResolverContext.h" +#include "ProxyResolver.h" +#include + +using namespace std; + +//============================================================================= +//================= Implementation ProxyResolverContextImpl =================== +//============================================================================= +//----------------------------------------------------------------------------- +struct ProxyResolverContextImpl +//----------------------------------------------------------------------------- +{ + HINTERNET hProxyResolveSession; + ProxyResolver* pProxyResolver; + explicit ProxyResolverContextImpl( const wstring& userAgent ) : hProxyResolveSession( 0 ), pProxyResolver( 0 ) + { + hProxyResolveSession = WinHttpOpen( userAgent.c_str(), WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, WINHTTP_FLAG_ASYNC ); + if( hProxyResolveSession ) + { + pProxyResolver = new ProxyResolver(); + } + } + ~ProxyResolverContextImpl() + { + delete pProxyResolver; + if( hProxyResolveSession ) + { + WinHttpCloseHandle( hProxyResolveSession ); + } + } +}; + +//============================================================================= +//================= Implementation ProxyResolverContext ======================= +//============================================================================= +//----------------------------------------------------------------------------- +ProxyResolverContext::ProxyResolverContext( const wstring& userAgent, const wstring& url ) : pImpl_( new ProxyResolverContextImpl( userAgent ) ) +//----------------------------------------------------------------------------- +{ + if( pImpl_->pProxyResolver ) + { + pImpl_->pProxyResolver->ResolveProxy( pImpl_->hProxyResolveSession, url.c_str() ); + } +} + +//----------------------------------------------------------------------------- +ProxyResolverContext::~ProxyResolverContext() +//----------------------------------------------------------------------------- +{ + delete pImpl_; +} + +//----------------------------------------------------------------------------- +wstring ProxyResolverContext::GetProxy( unsigned int index ) const +//----------------------------------------------------------------------------- +{ + const WINHTTP_PROXY_RESULT_ENTRY* pProxyData = pImpl_->pProxyResolver->GetProxySetting( index ); + return ( pProxyData && pProxyData->pwszProxy ) ? wstring( pProxyData->pwszProxy ) : wstring(); +} + +//----------------------------------------------------------------------------- +unsigned int ProxyResolverContext::GetProxyPort( unsigned int index ) const +//----------------------------------------------------------------------------- +{ + const WINHTTP_PROXY_RESULT_ENTRY* pProxyData = pImpl_->pProxyResolver->GetProxySetting( index ); + return pProxyData ? pProxyData->ProxyPort : 0; +} + +//============================================================================= +//================= Implementation helper functions =========================== +//============================================================================= + +//----------------------------------------------------------------------------- +/// \brief This function checks the token of the calling thread to see if the caller +/// belongs to the Administrators group. +/** + * \return + - true if the caller is an administrator on the local machine. + - false otherwise +*/ +bool IsCurrentUserLocalAdministrator( void ) +//----------------------------------------------------------------------------- +{ + BOOL fReturn = FALSE; + PACL pACL = NULL; + PSID psidAdmin = NULL; + HANDLE hToken = NULL; + HANDLE hImpersonationToken = NULL; + PSECURITY_DESCRIPTOR psdAdmin = NULL; + + + // Determine if the current thread is running as a user that is a member of + // the local admins group. To do this, create a security descriptor that + // has a DACL which has an ACE that allows only local administrators access. + // Then, call AccessCheck with the current thread's token and the security + // descriptor. It will say whether the user could access an object if it + // had that security descriptor. Note: you do not need to actually create + // the object. Just checking access against the security descriptor alone + // will be sufficient. + const DWORD ACCESS_READ = 1; + const DWORD ACCESS_WRITE = 2; + + __try + { + // AccessCheck() requires an impersonation token. We first get a primary + // token and then create a duplicate impersonation token. The + // impersonation token is not actually assigned to the thread, but is + // used in the call to AccessCheck. Thus, this function itself never + // impersonates, but does use the identity of the thread. If the thread + // was impersonating already, this function uses that impersonation context. + if( !OpenThreadToken( GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, TRUE, &hToken ) ) + { + if( GetLastError() != ERROR_NO_TOKEN ) + { + __leave; + } + + if( !OpenProcessToken( GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_QUERY, &hToken ) ) + { + __leave; + } + } + + if( !DuplicateToken ( hToken, SecurityImpersonation, &hImpersonationToken ) ) + { + __leave; + } + + // Create the binary representation of the well-known SID that + // represents the local administrators group. Then create the security + // descriptor and DACL with an ACE that allows only local admins access. + // After that, perform the access check. This will determine whether + // the current user is a local admin. + SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; + if( !AllocateAndInitializeSid( &SystemSidAuthority, 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, &psidAdmin ) ) + { + __leave; + } + + psdAdmin = LocalAlloc( LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH ); + if( psdAdmin == NULL ) + { + __leave; + } + + if( !InitializeSecurityDescriptor( psdAdmin, SECURITY_DESCRIPTOR_REVISION ) ) + { + __leave; + } + + // Compute size needed for the ACL. + const DWORD dwACLSize = sizeof( ACL ) + sizeof( ACCESS_ALLOWED_ACE ) + GetLengthSid( psidAdmin ) - sizeof( DWORD ); + pACL = ( PACL )LocalAlloc( LPTR, dwACLSize ); + if( pACL == NULL ) + { + __leave; + } + + if( !InitializeAcl( pACL, dwACLSize, ACL_REVISION2 ) ) + { + __leave; + } + + if( !AddAccessAllowedAce( pACL, ACL_REVISION2, ACCESS_READ | ACCESS_WRITE, psidAdmin ) ) + { + __leave; + } + + if( !SetSecurityDescriptorDacl( psdAdmin, TRUE, pACL, FALSE ) ) + { + __leave; + } + + // AccessCheck validates a security descriptor somewhat; set the group + // and owner so that enough of the security descriptor is filled out to + // make AccessCheck happy. + SetSecurityDescriptorGroup( psdAdmin, psidAdmin, FALSE ); + SetSecurityDescriptorOwner( psdAdmin, psidAdmin, FALSE ); + + if( !IsValidSecurityDescriptor( psdAdmin ) ) + { + __leave; + } + + // Initialize GenericMapping structure even though you do not use generic rights. + GENERIC_MAPPING GenericMapping; + GenericMapping.GenericRead = ACCESS_READ; + GenericMapping.GenericWrite = ACCESS_WRITE; + GenericMapping.GenericExecute = 0; + GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; + DWORD dwStructureSize = sizeof( PRIVILEGE_SET ); + DWORD dwStatus; + PRIVILEGE_SET ps; + if( !AccessCheck( psdAdmin, hImpersonationToken, ACCESS_READ, + &GenericMapping, &ps, &dwStructureSize, &dwStatus, + &fReturn ) ) + { + fReturn = FALSE; + __leave; + } + } + __finally + { + if( pACL ) + { + LocalFree( pACL ); + } + if( psdAdmin ) + { + LocalFree( psdAdmin ); + } + if( psidAdmin ) + { + FreeSid( psidAdmin ); + } + if( hImpersonationToken ) + { + CloseHandle ( hImpersonationToken ); + } + if( hToken ) + { + CloseHandle ( hToken ); + } + } + + return fReturn != FALSE; +} diff --git a/Cigarette/Common/wxAbstraction.h b/Cigarette/Common/wxAbstraction.h new file mode 100644 index 0000000..1cdd89f --- /dev/null +++ b/Cigarette/Common/wxAbstraction.h @@ -0,0 +1,651 @@ +//----------------------------------------------------------------------------- +#ifndef wxAbstractionH +#define wxAbstractionH wxAbstractionH +//----------------------------------------------------------------------------- +#include +#include +#include +#include + +#include "wxIncludePrologue.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "wxIncludeEpilogue.h" + +//----------------------------------------------------------------------------- +struct ConvertedString : wxString +//----------------------------------------------------------------------------- +{ +#if wxUSE_UNICODE + ConvertedString( const char* s ) : + wxString( s, wxConvUTF8 ) {} + ConvertedString( const std::string& s ) : + wxString( s.c_str(), wxConvUTF8 ) {} + ConvertedString( const wxString& s ) : +# if wxCHECK_VERSION(2,9,0) + wxString( s.mb_str(), wxConvUTF8 ) {} +# else + wxString( s.c_str(), wxConvUTF8 ) {} +# endif +#else + ConvertedString( const char* s ) : + wxString( s ) {} + ConvertedString( const std::string& s ) : + wxString( s.c_str() ) {} + ConvertedString( const wxString& s ) : +# if wxCHECK_VERSION(2,9,0) + wxString( s.mb_str() ) {} +# else + wxString( s.c_str() ) {} +# endif +#endif +}; + +#if ( wxMINOR_VERSION > 6 ) && ( wxMAJOR_VERSION < 3 ) && !WXWIN_COMPATIBILITY_2_6 +#include +enum +{ + wxOPEN = wxFD_OPEN, + wxSAVE = wxFD_SAVE, + wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT, + wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST, + wxMULTIPLE = wxFD_MULTIPLE, + wxCHANGE_DIR = wxFD_CHANGE_DIR +}; +#endif + +//----------------------------------------------------------------------------- +enum TApplicationColors +//----------------------------------------------------------------------------- +{ + acRedPastel = ( 200 << 16 ) | ( 200 << 8 ) | 255, + acYellowPastel = ( 180 << 16 ) | ( 255 << 8 ) | 255, + acBluePastel = ( 255 << 16 ) | ( 220 << 8 ) | 200, + acDarkBluePastel = ( 255 << 16 ) | ( 100 << 8 ) | 80, + acGreenPastel = ( 200 << 16 ) | ( 255 << 8 ) | 200, + acGreyPastel = ( 200 << 16 ) | ( 200 << 8 ) | 200, + acDarkGrey = ( 100 << 16 ) | ( 100 << 8 ) | 100 +}; + +//============================================================================= +//================= Implementation FramePositionStorage ======================= +//============================================================================= +//----------------------------------------------------------------------------- +class FramePositionStorage +//----------------------------------------------------------------------------- +{ + wxWindow* m_pWin; +public: + FramePositionStorage( wxWindow* pWin ) : m_pWin( pWin ) {} + void Save( void ) const + { + Save( m_pWin ); + } + static void Save( wxWindow* pWin, const wxString& windowName = wxT( "MainFrame" ) ) + { + wxConfigBase* pConfig( wxConfigBase::Get() ); + int Height, Width, XPos, YPos; + pWin->GetSize( &Width, &Height ); + pWin->GetPosition( &XPos, &YPos ); + // when we e.g. try to write config stuff on a read-only file system the result can + // be an annoying message box. Therefore we switch off logging during the storage operation. + wxLogNull logSuspendScope; + pConfig->Write( wxString::Format( wxT( "/%s/h" ), windowName.c_str() ), Height ); + pConfig->Write( wxString::Format( wxT( "/%s/w" ), windowName.c_str() ), Width ); + pConfig->Write( wxString::Format( wxT( "/%s/x" ), windowName.c_str() ), XPos ); + pConfig->Write( wxString::Format( wxT( "/%s/y" ), windowName.c_str() ), YPos ); + if( dynamic_cast( pWin ) ) + { + pConfig->Write( wxString::Format( wxT( "/%s/maximized" ), windowName.c_str() ), dynamic_cast( pWin )->IsMaximized() ); + } + pConfig->Flush(); + } + static wxRect Load( const wxRect& defaultDimensions, bool& boMaximized, const wxString& windowName = wxT( "MainFrame" ) ) + { + wxConfigBase* pConfig( wxConfigBase::Get() ); + wxRect rect; + rect.height = pConfig->Read( wxString::Format( wxT( "/%s/h" ), windowName.c_str() ), defaultDimensions.height ); + rect.width = pConfig->Read( wxString::Format( wxT( "/%s/w" ), windowName.c_str() ), defaultDimensions.width ); + rect.x = pConfig->Read( wxString::Format( wxT( "/%s/x" ), windowName.c_str() ), defaultDimensions.x ); + rect.y = pConfig->Read( wxString::Format( wxT( "/%s/y" ), windowName.c_str() ), defaultDimensions.y ); + boMaximized = pConfig->Read( wxString::Format( wxT( "/%s/maximized" ), windowName.c_str() ), 1l ) != 0; + int displayWidth = 0; + int displayHeight = 0; + wxDisplaySize( &displayWidth, &displayHeight ); + if( ( rect.x >= displayWidth ) || ( ( rect.x + rect.width ) < 0 ) ) + { + rect.x = 0; + } + if( ( rect.y >= displayHeight ) || ( ( rect.y + rect.height ) < 0 ) ) + { + rect.y = 0; + } + return rect; + } +}; + +//============================================================================= +//================= Implementation SplashScreenScope ========================== +//============================================================================= +//----------------------------------------------------------------------------- +class SplashScreenScope +//----------------------------------------------------------------------------- +{ + wxSplashScreen* pSplash_; + wxStopWatch stopWatch_; +public: + explicit SplashScreenScope( const wxBitmap& bmp ) : pSplash_( 0 ), stopWatch_() + { + pSplash_ = new wxSplashScreen( ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_SMALL ) ? wxBitmap( mvIcon_xpm ) : bmp, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER ); + pSplash_->Update(); + } + virtual ~SplashScreenScope() + { + const unsigned long startupTime_ms = static_cast( stopWatch_.Time() ); + const unsigned long minSplashDisplayTime_ms = 3000; + if( startupTime_ms < minSplashDisplayTime_ms ) + { + wxMilliSleep( minSplashDisplayTime_ms - startupTime_ms ); + } + delete pSplash_; + } +}; + +//============================================================================= +//================= Implementation SocketInitializeScope ====================== +//============================================================================= +//----------------------------------------------------------------------------- +class SocketInitializeScope +//----------------------------------------------------------------------------- +{ +public: + explicit SocketInitializeScope() + { + // This has to be called in order to be able to initialize sockets outside of + // the main thread ( http://www.litwindow.com/Knowhow/wxSocket/wxsocket.html ) + wxSocketBase::Initialize(); + } + ~SocketInitializeScope() + { + // Must apparently be done since we called wxSocketBase::Initialize(), + // otherwise memory leaks occur when closing the application. + wxSocketBase::Shutdown(); + } +}; + +//============================================================================= +//================= Implementation miscellaneous helper functions ============= +//============================================================================= +//----------------------------------------------------------------------------- +inline wxString LoadGenTLProducer( wxDynamicLibrary& lib ) +//----------------------------------------------------------------------------- +{ +#ifdef _WIN32 + const wxString libName( wxT( "mvGenTLProducer.cti" ) ); +#else + const wxString libName( wxT( "libmvGenTLProducer.so" ) ); +#endif + + const wxString GenTLPathVariable( ( sizeof( void* ) == 8 ) ? wxT( "GENICAM_GENTL64_PATH" ) : wxT( "GENICAM_GENTL32_PATH" ) ); +#if defined(linux) || defined(__linux) || defined(__linux__) + const wxChar PATH_SEPARATOR( wxT( ':' ) ); +#elif defined(_WIN32) || defined(WIN32) || defined(__WIN32__) + const wxChar PATH_SEPARATOR( wxT( ';' ) ); +#else +# error Unsupported target platform +#endif + wxString GenTLPath; + wxArrayString potentialLocations; + if( ::wxGetEnv( GenTLPathVariable, &GenTLPath ) ) + { + potentialLocations = wxSplit( GenTLPath, PATH_SEPARATOR ); + } + + wxString message; + // when we e.g. trying to load a shared library that cannot be found the result can + // be an annoying message box. Therefore we switch off logging during the load attempts. + wxLogNull logSuspendScope; + const size_t potentialLocationCount = potentialLocations.Count(); + for( size_t i = 0; i < potentialLocationCount; i++ ) + { + lib.Load( potentialLocations[i] + wxT( "/" ) + libName, wxDL_VERBATIM ); + if( lib.IsLoaded() ) + { + break; + } + } + + if( !lib.IsLoaded() ) + { + lib.Load( libName, wxDL_VERBATIM ); + } + if( !lib.IsLoaded() ) + { + message = wxString::Format( wxT( "Could not connect to '%s'. Check your installation.\n\n" ), libName.c_str() ); + } + return message; +} + +//----------------------------------------------------------------------------- +inline void AddSourceInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "The complete source code belonging to this application can be obtained by contacting " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, COMPANY_NAME, COMPANY_WEBSITE ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddSupportInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "Support contact: " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, COMPANY_SUPPORT_MAIL, COMPANY_SUPPORT_MAIL ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddwxWidgetsInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "This tool has been written using " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "wxWidgets" ), wxT( "http://www.wxwidgets.org" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxString::Format( wxT( " %d.%d.%d." ), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER ) ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddIconInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "This tool uses modified icons downloaded from here " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "icons8" ), wxT( "https://icons8.com/" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( " and here " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "Freepik" ), wxT( "http://www.freepik.com" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( ". The " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "Material Design" ), wxT( "https://material.io/resources/icons/?style=outline" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( " icons are published under " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "Apache 2.0 license." ), wxT( "https://www.apache.org/licenses/LICENSE-2.0.html" ) ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddListControlToAboutNotebook( wxNotebook* pNotebook, const wxString& pageTitle, bool boSelectPage, const wxString& col0, const wxString& col1, const std::vector >& v ) +//----------------------------------------------------------------------------- +{ + wxListCtrl* pListCtrl = new wxListCtrl( pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxBORDER_NONE ); + pListCtrl->InsertColumn( 0, col0 ); + pListCtrl->InsertColumn( 1, col1 ); + const unsigned long cnt = static_cast( v.size() ); + for( unsigned long i = 0; i < cnt; i++ ) + { + long index = pListCtrl->InsertItem( i, v[i].first, i ); + pListCtrl->SetItem( index, 1, v[i].second ); + } + for( unsigned int i = 0; i < 2; i++ ) + { + pListCtrl->SetColumnWidth( i, wxLIST_AUTOSIZE ); + } + pNotebook->AddPage( pListCtrl, pageTitle, boSelectPage ); +} + +//----------------------------------------------------------------------------- +inline void AppendPathSeparatorIfNeeded( wxString& path ) +//----------------------------------------------------------------------------- +{ + if( !path.EndsWith( wxT( "/" ) ) && !path.EndsWith( wxT( "\\" ) ) ) + { + path.append( wxT( "/" ) ); + } +} + +//----------------------------------------------------------------------------- +inline void WriteToTextCtrl( wxTextCtrl* pTextCtrl, const wxString& msg, const wxTextAttr& style = wxTextAttr( *wxBLACK ) ) +//----------------------------------------------------------------------------- +{ + if( pTextCtrl ) + { + // If you want the control to show the last line of text at the bottom, you can add "ScrollLines(1)" + // right after the AppendText call. AppendText will ensure the new line is visible, and ScrollLines + // will ensure the scroll bar is at the real end of the range, not further. + long posBefore = pTextCtrl->GetLastPosition(); + pTextCtrl->AppendText( msg ); + long posAfter = pTextCtrl->GetLastPosition(); + pTextCtrl->SetStyle( posBefore, posAfter, style ); + pTextCtrl->ScrollLines( 1 ); + pTextCtrl->ShowPosition( pTextCtrl->GetLastPosition() ); // ensure that this position is really visible + } +} + +//----------------------------------------------------------------------------- +struct AboutDialogInformation +//----------------------------------------------------------------------------- +{ + wxWindow* pParent_; + wxString applicationName_; + wxString briefDescription_; + unsigned int yearOfInitialRelease_; + std::vector > usageHints_; + std::vector > keyboardShortcuts_; + std::vector > availableCommandLineOptions_; + bool boAddIconInfo_; + bool boAddExpatInfo_; + bool boAddFFmpegInfo_; + explicit AboutDialogInformation( wxWindow* pParent = 0 ) : pParent_( pParent ), applicationName_(), + briefDescription_(), yearOfInitialRelease_( 2005 ), usageHints_(), keyboardShortcuts_(), + availableCommandLineOptions_(), boAddIconInfo_( false ), boAddExpatInfo_( false ), boAddFFmpegInfo_( false ) {} +}; + +//----------------------------------------------------------------------------- +inline void DisplayCommandLineProcessingInformation( wxTextCtrl* pTextCtrl, const wxString& processedCommandLineParameters, const wxString& parserErrors, const wxTextAttr& style ) +//----------------------------------------------------------------------------- +{ + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + WriteToTextCtrl( pTextCtrl, wxT( "Press 'F1' for help.\n" ), style ); + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + const wxString none( wxT( "none" ) ); + WriteToTextCtrl( pTextCtrl, wxString::Format( wxT( "Processed command line parameters: %s\n" ), ( processedCommandLineParameters.length() > 0 ) ? processedCommandLineParameters.c_str() : none.c_str() ), style ); + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + if( !parserErrors.IsEmpty() ) + { + WriteToTextCtrl( pTextCtrl, parserErrors, wxTextAttr( *wxRED ) ); + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + } +} + +//----------------------------------------------------------------------------- +inline void DisplayCommonAboutDialog( const AboutDialogInformation& info ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pTopDownSizer; + wxDialog dlg( info.pParent_, wxID_ANY, wxString( wxString::Format( wxT( "About %s" ), info.applicationName_.c_str() ) ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX ); + wxIcon icon( mvIcon_xpm ); + dlg.SetIcon( icon ); + pTopDownSizer = new wxBoxSizer( wxVERTICAL ); + wxStaticText* pText = new wxStaticText( &dlg, wxID_ANY, info.briefDescription_ ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + pText = new wxStaticText( &dlg, wxID_ANY, wxString::Format( wxT( "(C) %u - %s by %s" ), info.yearOfInitialRelease_, CURRENT_YEAR, COMPANY_NAME ) ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + pText = new wxStaticText( &dlg, wxID_ANY, wxString::Format( wxT( "Version %s" ), VERSION_STRING ) ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + AddSupportInfo( &dlg, pTopDownSizer ); + AddwxWidgetsInfo( &dlg, pTopDownSizer ); + if( info.boAddIconInfo_ ) + { + AddIconInfo( &dlg, pTopDownSizer ); + } + if( info.boAddExpatInfo_ ) + { + pText = new wxStaticText( &dlg, wxID_ANY, wxT( "The expat wrapper class used internally has been written by Descartes Systems Sciences, Inc." ) ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + } + if( info.boAddFFmpegInfo_ ) + { + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( &dlg, wxID_ANY, wxT( "The video recording functionality of this application requires libraries from the " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( &dlg, wxID_ANY, wxT( "FFmpeg" ), wxT( "https://www.ffmpeg.org/" ) ) ); + pSizer->Add( new wxStaticText( &dlg, wxID_ANY, wxT( " project under the LGPLv2.1. These must be installed separately" ) ) ); + pTopDownSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); + } + AddSourceInfo( &dlg, pTopDownSizer ); + wxNotebook* pNotebook = new wxNotebook( &dlg, wxID_ANY, wxDefaultPosition, wxDefaultSize ); + wxTextCtrl* pUsageHints = new wxTextCtrl( pNotebook, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxBORDER_NONE | wxTE_RICH | wxTE_READONLY ); + pNotebook->AddPage( pUsageHints, wxT( "Usage Hints" ), true ); + std::vector >::size_type usageHintStringCount = info.usageHints_.size(); + for( std::vector >::size_type i = 0; i < usageHintStringCount; i++ ) + { + WriteToTextCtrl( pUsageHints, info.usageHints_[i].first, info.usageHints_[i].second ); + } + pUsageHints->ScrollLines( -( 256 * 256 ) ); // make sure the text control always shows the beginning of the help text + if( !info.keyboardShortcuts_.empty() ) + { + AddListControlToAboutNotebook( pNotebook, wxT( "Keyboard Shortcuts" ), false, wxT( "Shortcut" ), wxT( "Command" ), info.keyboardShortcuts_ ); + } + if( !info.availableCommandLineOptions_.empty() ) + { + AddListControlToAboutNotebook( pNotebook, wxT( "Available Command Line Options" ), false, wxT( "Command" ), wxT( "Description" ), info.availableCommandLineOptions_ ); + } + pTopDownSizer->AddSpacer( 10 ); + pTopDownSizer->Add( pNotebook, wxSizerFlags( 5 ).Expand() ); + pTopDownSizer->AddSpacer( 10 ); + wxButton* pBtnOK = new wxButton( &dlg, wxID_OK, wxT( "OK" ) ); + pBtnOK->SetDefault(); + pTopDownSizer->Add( pBtnOK, 0, wxALL | wxALIGN_RIGHT, 15 ); + dlg.SetSizer( pTopDownSizer ); + dlg.SetSizeHints( 720, 500 ); + dlg.SetSize( -1, -1, 800, 500 ); + dlg.ShowModal(); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetCommonTextStyle( const bool boBold, const bool boUnderlined, wxTextCtrl* +#if wxCHECK_VERSION(2, 9, 5) +#else + pParent +#endif // #if wxCHECK_VERSION(2, 9, 5) + ) +//----------------------------------------------------------------------------- +{ + wxTextAttr theStyle; +#if wxCHECK_VERSION(2, 9, 5) + wxFontInfo fontInfo( 10 ); + if( boBold ) + { + fontInfo.Bold(); + } + if( boUnderlined ) + { + fontInfo.Underlined(); + } + wxFont theFont( fontInfo ); +#else + pParent->GetStyle( pParent->GetLastPosition(), theStyle ); + wxFont theFont( theStyle.GetFont() ); + if( boBold ) + { + theFont.SetWeight( wxFONTWEIGHT_BOLD ); + } + theFont.SetPointSize( 10 ); + if( boUnderlined ) + { + theFont.SetUnderlined( true ); + } +#endif // #if wxCHECK_VERSION(2, 9, 5) + theStyle.SetFont( theFont ); + return theStyle; +} + + +//----------------------------------------------------------------------------- +inline wxTextAttr GetBoldStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( true, false, pParent ); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetBoldUnderlinedStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( true, true, pParent ); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetDefaultStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( false, false, pParent ); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetUnderlinedStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( false, true, pParent ); +} + +//----------------------------------------------------------------------------- +inline bool IsListOfChoicesEmpty( wxComboBox* pCB ) +//----------------------------------------------------------------------------- +{ +#if wxCHECK_VERSION(2, 9, 3) + return pCB->IsListEmpty(); +#else + return pCB->IsEmpty(); +#endif // #if wxCHECK_VERSION(2, 9, 3) +} + +//----------------------------------------------------------------------------- +inline void StopTimer( wxTimer& timer ) +//----------------------------------------------------------------------------- +{ + if( timer.IsRunning() ) + { + timer.Stop(); + } +} + +//============================================================================= +//===================== Implementation Version helper functions =============== +//============================================================================= +//----------------------------------------------------------------------------- +struct Version +//----------------------------------------------------------------------------- +{ + long major_; + long minor_; + long subMinor_; + long release_; + explicit Version() : major_( -1 ), minor_( -1 ), subMinor_( -1 ), release_( 0 ) {} + explicit Version( long ma, long mi, long smi, long re ) : major_( ma ), minor_( mi ), subMinor_( smi ), release_( re ) {} +}; + +//----------------------------------------------------------------------------- +inline bool operator<( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + if( a.major_ < b.major_ ) + { + return true; + } + else if( a.major_ == b.major_ ) + { + if( a.minor_ < b.minor_ ) + { + return true; + } + else if( a.minor_ == b.minor_ ) + { + if( a.subMinor_ < b.subMinor_ ) + { + return true; + } + else if( a.subMinor_ == b.subMinor_ ) + { + if( a.release_ < b.release_ ) + { + return true; + } + } + } + } + return false; +} + +//----------------------------------------------------------------------------- +inline bool operator==( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( ( a.major_ == b.major_ ) && ( a.minor_ == b.minor_ ) && ( a.subMinor_ == b.subMinor_ ) && ( a.release_ == b.release_ ) ); +} + +//----------------------------------------------------------------------------- +inline bool operator!=( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( ( a.major_ != b.major_ ) || ( a.minor_ != b.minor_ ) || ( a.subMinor_ != b.subMinor_ ) || ( a.release_ != b.release_ ) ); +} + +//----------------------------------------------------------------------------- +inline bool operator>( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( !( a < b ) && !( a == b ) ); +} + +//----------------------------------------------------------------------------- +inline bool operator>=( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( a > b ) || ( a == b ); +} + +//----------------------------------------------------------------------------- +inline bool GetNextVersionNumber( wxString& str, long& number ) +//----------------------------------------------------------------------------- +{ + wxString numberString = str.BeforeFirst( wxT( '.' ) ); + str = str.AfterFirst( wxT( '.' ) ); + return numberString.ToLong( &number ); +} + +//----------------------------------------------------------------------------- +inline Version VersionFromString( const wxString& versionAsString ) +//----------------------------------------------------------------------------- +{ + Version version; + wxString tmp( versionAsString ); + GetNextVersionNumber( tmp, version.major_ ); + if( !tmp.empty() ) + { + GetNextVersionNumber( tmp, version.minor_ ); + if( !tmp.empty() ) + { + GetNextVersionNumber( tmp, version.subMinor_ ); + if( !tmp.empty() ) + { + GetNextVersionNumber( tmp, version.release_ ); + } + } + } + return version; +} + +//----------------------------------------------------------------------------- +inline bool IsVersionWithinRange( const Version& version, const Version& minVersion, const Version& maxVersion ) +//----------------------------------------------------------------------------- +{ + if( version < minVersion ) + { + return false; + } + + if( version > maxVersion ) + { + return false; + } + + return true; +} + +#endif // wxAbstractionH diff --git a/Cigarette/Common/wxIncludeEpilogue.h b/Cigarette/Common/wxIncludeEpilogue.h new file mode 100644 index 0000000..a0c3f53 --- /dev/null +++ b/Cigarette/Common/wxIncludeEpilogue.h @@ -0,0 +1,5 @@ +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( pop ) +#endif diff --git a/Cigarette/Common/wxIncludePrologue.h b/Cigarette/Common/wxIncludePrologue.h new file mode 100644 index 0000000..082eff5 --- /dev/null +++ b/Cigarette/Common/wxIncludePrologue.h @@ -0,0 +1,10 @@ +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# pragma clang diagnostic ignored "-Wunused-local-typedef" +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( push ) +# pragma warning( disable : 4127 ) // 'conditional expression is constant' +# pragma warning( disable : 4512 ) // 'class XYZ': assignment operator could not be generated' +# pragma warning( disable : 4996 ) // ''function XYZ': was declared deprecated' +#endif diff --git a/Cigarette/Common/wxIncluder.h b/Cigarette/Common/wxIncluder.h new file mode 100644 index 0000000..7ebe90d --- /dev/null +++ b/Cigarette/Common/wxIncluder.h @@ -0,0 +1,9 @@ +//----------------------------------------------------------------------------- +#ifndef wxIncluderH +#define wxIncluderH wxIncluderH +//----------------------------------------------------------------------------- +#include +#include "wx/wx.h" +#include + +#endif // wxIncluderH diff --git a/Cigarette/CryptoToolLib.h b/Cigarette/CryptoToolLib.h new file mode 100644 index 0000000..264e51a --- /dev/null +++ b/Cigarette/CryptoToolLib.h @@ -0,0 +1,11 @@ +#pragma once +#include "Windows.h" + +typedef enum _EncMethod { + none = 0, + addtime = 1 +}EncMethod; + +extern "C" bool GenerateDeviceID(void); +extern "C" bool GenerateLicenseData(EncMethod Method, char* suffix); +extern "C" bool VerifyLicense(EncMethod Method); \ No newline at end of file diff --git a/Cigarette/CryptoToolLib.lib b/Cigarette/CryptoToolLib.lib new file mode 100644 index 0000000..886afb4 Binary files /dev/null and b/Cigarette/CryptoToolLib.lib differ diff --git a/Cigarette/Logthread.cpp b/Cigarette/Logthread.cpp new file mode 100644 index 0000000..3132f1d --- /dev/null +++ b/Cigarette/Logthread.cpp @@ -0,0 +1,164 @@ +#include "Logthread.h" +#include +#include +#include + +const char PATH_LogPath[] = "D:/log/"; +const char Suffix[] = ".txt"; +bool CLog::isFileReady = false; +bool CLog::isRecord2File = true; +QFile localFile; +QMutex mutexLog; + +CLog::CLog() +{ +} + +void CLog::setLogType(const CLog::CLOG_TYPE& level) +{ +} + +bool CLog::init(LogConfig& logConfig) +{ + isRecord2File = logConfig.isRecord2File; + QString logDir = QString(PATH_LogPath); + if (createDir(logDir)) + { + QString fileName = logDir + QDir::separator() + QDate::currentDate().toString("yyyy-MM-dd") + QString(Suffix); + QFileInfo fi(fileName); + if (fi.exists()) + { + if (!localFile.exists()) + { + localFile.setFileName(fileName); + if (localFile.open(QFile::WriteOnly | QFile::Append | QFile::Text)) + { + isFileReady = true; + } + } + else + { + isFileReady = true; + } + } + else + { + localFile.setFileName(fileName); + if (localFile.open(QFile::WriteOnly | QFile::Append | QFile::Text)) + { + isFileReady = true; + } + } + } + return isFileReady; +} + +bool CLog::createDir(QString dirPath) +{ + QFileInfo fileInfo(dirPath); + if (!fileInfo.exists()) + { + QDir tmpDir; + return tmpDir.mkpath(dirPath); + } + + return true; +} + +void CLog::log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...) +{ + QMutexLocker locker(&mutexLog); + if (isFileReady) + { + QString recordInfo = QString("[%1]").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss:zzz")); + recordInfo.append(getTypeDesc(nType)); + +#ifndef QT_NO_DEBUG + recordInfo.append(QString("[%1:%2:%3]").arg(fileDesc).arg(functionDesc).arg(lineNum)); +#endif + va_list vlist; + va_start(vlist, data); + + QByteArray byteArray; +#if defined(Q_OS_WIN) + int recordLen = _vscprintf(data, vlist); + byteArray.resize(recordLen); +#else + byteArray.resize(1024); +#endif + vsprintf(byteArray.data(), data, vlist); + recordInfo.append(byteArray); + va_end(vlist); + + recordInfo.append("\n"); + + if (isRecord2File) { + localFile.write(recordInfo.toLocal8Bit().data(), recordInfo.toLocal8Bit().length()); + localFile.flush(); + } + else { + // qDebug()< +class CLog : public QObject +{ + Q_OBJECT +public: + + enum CLOG_TYPE + { + + STARTAPP, + STARTWORK, + PAUSEWORK, + UNLOCK, + DEBUGMODE, + UNKICKMODE, + SETTING, + CLEANPIC, + DOUBLECLICK, + ROTATEPIC, + PLCSETTING, + ALARM + }; + //Q_DECLARE_FLAGS(CLOG_TYPE_Flags, CLOG_TYPE) + Q_ENUM(CLOG_TYPE) + + struct LogConfig + { + bool isRecord2File; + int level; + }; + + CLog(); + + void setLogType(const CLog::CLOG_TYPE& type); + // CLog::CLOG_TYPE getLogType() { return logType; } + + //void startClog(); + //void doWork(); + static bool init(CLog::LogConfig& logConfig); + static bool createDir(QString dirPath); + static void log(CLOG_TYPE nType, const char* fileDesc, const char* functionDesc, int lineNum, const char* data, ...); + static void log(CLOG_TYPE nType, const char* data, ...); +public slots: + void recMegFromCigarette(QString); + +private: + static QString getTypeDesc(CLOG_TYPE type); + +private: + static bool isRecord2File; + static bool isFileReady; +}; + +#ifdef Q_OS_WIN +#define FILE_SEPARATOR '\\' +#else +#define FILE_SEPARATOR '/' +#endif + +#define FUNC_SEPARATOR '::' + +#ifndef QT_NO_DEBUG +#define __FILENAME__ (strrchr(__FILE__, FILE_SEPARATOR) ? (strrchr(__FILE__, FILE_SEPARATOR) + 1):__FILE__) +#define __FUNNAME__ (strrchr(__FUNCTION__,FUNC_SEPARATOR)?(strrchr(__FUNCTION__, FUNC_SEPARATOR) + 1):__FUNCTION__) +#else +#define __FILENAME__ NULL +#define __FUNNAME__ NULL +#endif + +#define CLOG_INFO(...) CLog::log(CLog::STARTAPP, __VA_ARGS__) diff --git a/Cigarette/MVS3.2.1/Include/CameraParams.h b/Cigarette/MVS3.2.1/Include/CameraParams.h new file mode 100644 index 0000000..8cd0a39 --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/CameraParams.h @@ -0,0 +1,917 @@ + +#ifndef _MV_CAMERA_PARAMS_H_ +#define _MV_CAMERA_PARAMS_H_ + +#include "PixelType.h" + +#ifndef __cplusplus +typedef char bool; +#define true 1 +#define false 0 +#endif + +/// \~chinese 豸Ͷ \~english Device Type Definition +#define MV_UNKNOW_DEVICE 0x00000000 ///< \~chinese δ֪豸ͣ \~english Unknown Device Type, Reserved +#define MV_GIGE_DEVICE 0x00000001 ///< \~chinese GigE豸 \~english GigE Device +#define MV_1394_DEVICE 0x00000002 ///< \~chinese 1394-a/b 豸 \~english 1394-a/b Device +#define MV_USB_DEVICE 0x00000004 ///< \~chinese USB 豸 \~english USB Device +#define MV_CAMERALINK_DEVICE 0x00000008 ///< \~chinese CameraLink豸 \~english CameraLink Device + +/// \~chinese GigE豸Ϣ \~english GigE device info +typedef struct _MV_GIGE_DEVICE_INFO_ +{ + unsigned int nIpCfgOption; ///< [OUT] \~chinese IPѡ \~english IP Configuration Options + unsigned int nIpCfgCurrent; ///< [OUT] \~chinese ǰIP \~english IP Configuration:bit31-static bit30-dhcp bit29-lla + unsigned int nCurrentIp; ///< [OUT] \~chinese ǰIPַ \~english Current Ip + unsigned int nCurrentSubNetMask; ///< [OUT] \~chinese ǰ \~english Curtent Subnet Mask + unsigned int nDefultGateWay; ///< [OUT] \~chinese ǰ \~english Current Gateway + unsigned char chManufacturerName[32]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chModelName[32]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chDeviceVersion[32]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerSpecificInfo[48];///< [OUT] \~chinese ̵ľϢ \~english Manufacturer Specific Information + unsigned char chSerialNumber[16]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chUserDefinedName[16]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned int nNetExport; ///< [OUT] \~chinese IPַ \~english NetWork IP Address + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MV_GIGE_DEVICE_INFO; + +#define INFO_MAX_BUFFER_SIZE 64 ///< \~chinese ϢС \~english Maximum data information size + +/// \~chinese USB豸Ϣ \~english USB device info +typedef struct _MV_USB3_DEVICE_INFO_ +{ + unsigned char CrtlInEndPoint; ///< [OUT] \~chinese ˵ \~english Control input endpoint + unsigned char CrtlOutEndPoint; ///< [OUT] \~chinese ˵ \~english Control output endpoint + unsigned char StreamEndPoint; ///< [OUT] \~chinese ˵ \~english Flow endpoint + unsigned char EventEndPoint; ///< [OUT] \~chinese ¼˵ \~english Event endpoint + unsigned short idVendor; ///< [OUT] \~chinese ӦID \~english Vendor ID Number + unsigned short idProduct; ///< [OUT] \~chinese ƷID \~english Device ID Number + unsigned int nDeviceNumber; ///< [OUT] \~chinese 豸к \~english Device Serial Number + unsigned char chDeviceGUID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸GUID \~english Device GUID Number + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Ӧ \~english Vendor Name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Family Name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned int nbcdUSB; ///< [OUT] \~chinese ֵ֧USBЭ \~english Support USB Protocol + unsigned int nDeviceAddress; ///< [OUT] \~chinese 豸ַ \~english Device Address + + unsigned int nReserved[2]; ///< \~chinese Ԥ \~english Reserved +}MV_USB3_DEVICE_INFO; + +/// \~chinese CameraLink豸Ϣ \~english CameraLink device info +typedef struct _MV_CamL_DEV_INFO_ +{ + unsigned char chPortID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ˿ں \~english Port ID + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Family Name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + + unsigned int nReserved[38]; ///< \~chinese Ԥ \~english Reserved +}MV_CamL_DEV_INFO; + +/// \~chinese 豸Ϣ \~english Device info +typedef struct _MV_CC_DEVICE_INFO_ +{ + unsigned short nMajorVer; ///< [OUT] \~chinese Ҫ汾 \~english Major Version + unsigned short nMinorVer; ///< [OUT] \~chinese Ҫ汾 \~english Minor Version + unsigned int nMacAddrHigh; ///< [OUT] \~chinese MACַ \~english High MAC Address + unsigned int nMacAddrLow; ///< [OUT] \~chinese MACַ \~english Low MAC Address + + unsigned int nTLayerType; ///< [OUT] \~chinese 豸Эͣe.g. MV_GIGE_DEVICE \~english Device Transport Layer Protocol Type, e.g. MV_GIGE_DEVICE + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved + + union + { + MV_GIGE_DEVICE_INFO stGigEInfo; ///< [OUT] \~chinese GigE豸Ϣ \~english GigE Device Info + MV_USB3_DEVICE_INFO stUsb3VInfo; ///< [OUT] \~chinese USB豸Ϣ \~english USB Device Info + MV_CamL_DEV_INFO stCamLInfo; ///< [OUT] \~chinese CameraLink豸Ϣ \~english CameraLink Device Info + // more ... + }SpecialInfo; + +}MV_CC_DEVICE_INFO; + +#define MV_MAX_TLS_NUM 8 ///< \~chinese ֵ֧Ĵʵ \~english The maximum number of supported transport layer instances +#define MV_MAX_DEVICE_NUM 256 ///< \~chinese ֵ֧豸 \~english The maximum number of supported devices + +/// \~chinese 豸Ϣб \~english Device Information List +typedef struct _MV_CC_DEVICE_INFO_LIST_ +{ + unsigned int nDeviceNum; ///< [OUT] \~chinese 豸 \~english Online Device Number + MV_CC_DEVICE_INFO* pDeviceInfo[MV_MAX_DEVICE_NUM]; ///< [OUT] \~chinese ֧256豸 \~english Support up to 256 devices + +}MV_CC_DEVICE_INFO_LIST; + +/// \~chinese ͨGenTLöٵInterfaceϢ \~english Interface Information with GenTL +typedef struct _MV_GENTL_IF_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese GenTLӿID \~english Interface ID + unsigned char chTLType[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english GenTL Type + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Interfaceʾ \~english Display Name + unsigned int nCtiIndex; ///< [OUT] \~chinese GenTLctiļ \~english The Index of Cti Files + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved +}MV_GENTL_IF_INFO; + +#define MV_MAX_GENTL_IF_NUM 256 ///< \~chinese ֵ֧GenTLӿ \~english The maximum number of GenTL interface supported +/// \~chinese ͨGenTLöٵĽӿϢб \~english Inferface Information List with GenTL +typedef struct _MV_GENTL_IF_INFO_LIST_ +{ + unsigned int nInterfaceNum; ///< [OUT] \~chinese ߽ӿ \~english Online Inferface Number + MV_GENTL_IF_INFO* pIFInfo[MV_MAX_GENTL_IF_NUM]; ///< [OUT] \~chinese ֧256ӿ \~english Support up to 256 inferfaces + +}MV_GENTL_IF_INFO_LIST; + +/// \~chinese ͨGenTLöٵ豸Ϣ \~english Device Information with GenTL +typedef struct _MV_GENTL_DEV_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese GenTLӿID \~english Interface ID + unsigned char chDeviceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸ID \~english Device ID + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Ӧ \~english Vendor Name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chTLType[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english GenTL Type + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸ʾ \~english Display Name + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE];///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned int nCtiIndex; ///< [OUT] \~chinese GenTLctiļ \~english The Index of Cti Files + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved +}MV_GENTL_DEV_INFO; + +#define MV_MAX_GENTL_DEV_NUM 256 ///< \~chinese ֵ֧GenTL豸 \~english The maximum number of GenTL devices supported +/// \~chinese ͨGenTLöٵ豸Ϣб \~english Device Information List with GenTL +typedef struct _MV_GENTL_DEV_INFO_LIST_ +{ + unsigned int nDeviceNum; ///< [OUT] \~chinese 豸 \~english Online Device Number + MV_GENTL_DEV_INFO* pDeviceInfo[MV_MAX_GENTL_DEV_NUM]; ///< [OUT] \~chinese ֧256豸 \~english Support up to 256 devices + +}MV_GENTL_DEV_INFO_LIST; + +/// \~chinese 豸ķģʽ \~english Device Access Mode +/// \~chinese ռȨޣAPPֻCCPĴ \~english Exclusive authority, other APP is only allowed to read the CCP register +#define MV_ACCESS_Exclusive 1 +/// \~chinese Դ5ģʽռȨޣȻԶռȨ޴ \~english You can seize the authority from the 5 mode, and then open with exclusive authority +#define MV_ACCESS_ExclusiveWithSwitch 2 +/// \~chinese ȨޣAPPмĴ \~english Control authority, allows other APP reading all registers +#define MV_ACCESS_Control 3 +/// \~chinese Դ5ģʽռȨޣȻԿȨ޴ \~english You can seize the authority from the 5 mode, and then open with control authority +#define MV_ACCESS_ControlWithSwitch 4 +/// \~chinese ԿɱռĿȨ޴ \~english Open with seized control authority +#define MV_ACCESS_ControlSwitchEnable 5 +/// \~chinese Դ5ģʽռȨޣȻԿɱռĿȨ޴ \~english You can seize the authority from the 5 mode, and then open with seized control authority +#define MV_ACCESS_ControlSwitchEnableWithKey 6 +/// \~chinese ģʽ豸ڿȨ \~english Open with read mode and is available under control authority +#define MV_ACCESS_Monitor 7 + +/// \~chinese Chunk \~english The content of ChunkData +typedef struct _MV_CHUNK_DATA_CONTENT_ +{ + unsigned char* pChunkData; ///< [OUT] \~chinese Chunk \~english Chunk Data + unsigned int nChunkID; ///< [OUT] \~chinese Chunk ID \~english Chunk ID + unsigned int nChunkLen; ///< [OUT] \~chinese Chunkij \~english Chunk Length + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CHUNK_DATA_CONTENT; + +/// \~chinese ֡Ϣ \~english Output Frame Information +typedef struct _MV_FRAME_OUT_INFO_EX_ +{ + unsigned short nWidth; ///< [OUT] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [OUT] \~chinese ͼ \~english Image Height + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel Type + + unsigned int nFrameNum; ///< [OUT] \~chinese ֡ \~english Frame Number + unsigned int nDevTimeStampHigh; ///< [OUT] \~chinese ʱ32λ \~english Timestamp high 32 bits + unsigned int nDevTimeStampLow; ///< [OUT] \~chinese ʱ32λ \~english Timestamp low 32 bits + unsigned int nReserved0; ///< [OUT] \~chinese 8ֽڶ \~english Reserved, 8-byte aligned + int64_t nHostTimeStamp; ///< [OUT] \~chinese ɵʱ \~english Host-generated timestamp + + unsigned int nFrameLen; ///< [OUT] \~chinese ֡ij \~english The Length of Frame + + /// \~chinese 豸ˮӡʱ \~english Device frame-specific time scale + unsigned int nSecondCount; ///< [OUT] \~chinese \~english The Seconds + unsigned int nCycleCount; ///< [OUT] \~chinese \~english The Count of Cycle + unsigned int nCycleOffset; ///< [OUT] \~chinese ƫ \~english The Offset of Cycle + + float fGain; ///< [OUT] \~chinese \~english Gain + float fExposureTime; ///< [OUT] \~chinese عʱ \~english Exposure Time + unsigned int nAverageBrightness; ///< [OUT] \~chinese ƽ \~english Average brightness + + /// \~chinese ƽ \~english White balance + unsigned int nRed; ///< [OUT] \~chinese ɫ \~english Red + unsigned int nGreen; ///< [OUT] \~chinese ɫ \~english Green + unsigned int nBlue; ///< [OUT] \~chinese ɫ \~english Blue + + unsigned int nFrameCounter; ///< [OUT] \~chinese ֡ \~english Frame Counter + unsigned int nTriggerIndex; ///< [OUT] \~chinese \~english Trigger Counting + + unsigned int nInput; ///< [OUT] \~chinese \~english Input + unsigned int nOutput; ///< [OUT] \~chinese \~english Output + + /// \~chinese ROI \~english ROI Region + unsigned short nOffsetX; ///< [OUT] \~chinese ˮƽƫ \~english OffsetX + unsigned short nOffsetY; ///< [OUT] \~chinese ֱƫ \~english OffsetY + unsigned short nChunkWidth; ///< [OUT] \~chinese Chunk \~english The Width of Chunk + unsigned short nChunkHeight; ///< [OUT] \~chinese Chunk \~english The Height of Chunk + + unsigned int nLostPacket; ///< [OUT] \~chinese ֡ \~english Lost Packet Number In This Frame + + unsigned int nUnparsedChunkNum; ///< [OUT] \~chinese δChunkdata \~english Unparsed Chunk Number + union + { + MV_CHUNK_DATA_CONTENT* pUnparsedChunkContent;///< [OUT] \~chinese δChunk \~english Unparsed Chunk Content + int64_t nAligning; ///< [OUT] \~chinese У׼ \~english Aligning + }UnparsedChunkList; + + unsigned int nReserved[36]; ///< \~chinese Ԥ \~english Reserved +}MV_FRAME_OUT_INFO_EX; + +/// \~chinese ͼṹ壬ͼַָͼϢ \~english Image Struct, output the pointer of Image and the information of the specific image +typedef struct _MV_FRAME_OUT_ +{ + unsigned char* pBufAddr; ///< [OUT] \~chinese ͼַָ \~english pointer of image + MV_FRAME_OUT_INFO_EX stFrameInfo; ///< [OUT] \~chinese ͼϢ \~english information of the specific image + + unsigned int nRes[16]; ///< \~chinese Ԥ \~english Reserved +}MV_FRAME_OUT; + +/// \~chinese ȡ \~english The strategy of Grabbing +typedef enum _MV_GRAB_STRATEGY_ +{ + MV_GrabStrategy_OneByOne = 0, ///< \~chinese Ӿɵһ֡һ֡ĻȡͼĬΪòԣ \~english Grab One By One + MV_GrabStrategy_LatestImagesOnly = 1, ///< \~chinese ȡбµһ֡ͼͬʱбеͼ \~english Grab The Latest Image + MV_GrabStrategy_LatestImages = 2, ///< \~chinese ȡбµͼ񣬸OutputQueueSizeΧΪ1-ImageNodeNumó1ͬLatestImagesOnly,óImageNodeNumͬOneByOne \~english Grab The Latest Images + MV_GrabStrategy_UpcomingImage = 3, ///< \~chinese ȴһ֡ͼ \~english Grab The Upcoming Image + +}MV_GRAB_STRATEGY; + +/// \~chinese 紫Ϣ \~english Network transmission information +typedef struct _MV_NETTRANS_INFO_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [ͳStartGrabbingStopGrabbing֮] \~english Received Data Size [Calculate the Data Size between StartGrabbing and StopGrabbing] + int nThrowFrameCount; ///< [OUT] \~chinese ֡ \~english Throw frame number + unsigned int nNetRecvFrameCount; ///< [OUT] \~chinese ѽյ֡ \~english Received Frame Count + int64_t nRequestResendPacketCount; ///< [OUT] \~chinese ط \~english Request Resend Packet Count + int64_t nResendPacketCount; ///< [OUT] \~chinese ط \~english Resend Packet Count + +}MV_NETTRANS_INFO; + +/// \~chinese Ϣ \~english Information Type +#define MV_MATCH_TYPE_NET_DETECT 0x00000001 ///< \~chinese ͶϢ \~english Network traffic and packet loss information +#define MV_MATCH_TYPE_USB_DETECT 0x00000002 ///< \~chinese hostյU3V豸ֽ \~english The total number of bytes host received from U3V device + +/// \~chinese ȫƥһϢṹ \~english A fully matched information structure +typedef struct _MV_ALL_MATCH_INFO_ +{ + unsigned int nType; ///< [IN] \~chinese ҪϢͣe.g. MV_MATCH_TYPE_NET_DETECT \~english Information type need to output ,e.g. MV_MATCH_TYPE_NET_DETECT + void* pInfo; ///< [OUT] \~chinese Ϣ棬ɵ߷ \~english Output information cache, which is allocated by the caller + unsigned int nInfoSize; ///< [IN] \~chinese ϢĴС \ ~english Information cache size + +}MV_ALL_MATCH_INFO; + +/// \~chinese ͶϢṹ壬ӦΪ MV_MATCH_TYPE_NET_DETECT \~english Network traffic and packet loss feedback structure, the corresponding type is MV_MATCH_TYPE_NET_DETECT +typedef struct _MV_MATCH_INFO_NET_DETECT_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [ͳStartGrabbingStopGrabbing֮] \~english Received data size + int64_t nLostPacketCount; ///< [OUT] \~chinese ʧİ \~english Number of packets lost + unsigned int nLostFrameCount; ///< [OUT] \~chinese ֡ \~english Number of frames lost + unsigned int nNetRecvFrameCount; ///< [OUT] \~chinese \~english Received Frame Count + int64_t nRequestResendPacketCount; ///< [OUT] \~chinese ط \~english Request Resend Packet Count + int64_t nResendPacketCount; ///< [OUT] \~chinese ط \~english Resend Packet Count +}MV_MATCH_INFO_NET_DETECT; + +/// \~chinese hostյu3v豸˵ֽӦΪ MV_MATCH_TYPE_USB_DETECT \~english The total number of bytes host received from the u3v device side, the corresponding type is MV_MATCH_TYPE_USB_DETECT +typedef struct _MV_MATCH_INFO_USB_DETECT_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [ͳOpenDevicceCloseDevice֮] \~english Received data size + unsigned int nReceivedFrameCount; ///< [OUT] \~chinese յ֡ \~english Number of frames received + unsigned int nErrorFrameCount; ///< [OUT] \~chinese ֡ \~english Number of error frames + unsigned int nReserved[2]; ///< \~chinese \~english Reserved +}MV_MATCH_INFO_USB_DETECT; + +/// \~chinese ʾ֡Ϣ \~english Display frame information +typedef struct _MV_DISPLAY_FRAME_INFO_ +{ + void* hWnd; ///< [IN] \~chinese ھ \~english HWND + unsigned char* pData; ///< [IN] \~chinese ʾ \~english Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݳ \~english Data Size + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned int nRes[4]; ///< \~chinese \~english Reserved + +}MV_DISPLAY_FRAME_INFO; + +/// \~chinese 3Dݸʽ \~english The saved format for 3D data +enum MV_SAVE_POINT_CLOUD_FILE_TYPE +{ + MV_PointCloudFile_Undefined = 0, ///< \~chinese δĵƸʽ \~english Undefined point cloud format + MV_PointCloudFile_PLY = 1, ///< \~chinese PLYƸʽ \~english The point cloud format named PLY + MV_PointCloudFile_CSV = 2, ///< \~chinese CSVƸʽ \~english The point cloud format named CSV + MV_PointCloudFile_OBJ = 3, ///< \~chinese OBJƸʽ \~english The point cloud format named OBJ +}; + +/// \~chinese 3Dݵ \~english Save 3D data to buffer +typedef struct _MV_SAVE_POINT_CLOUD_PARAM_ +{ + unsigned int nLinePntNum; ///< [IN] \~chineseÿһеͼ \~english The number of points in each row,which is the width of the image + unsigned int nLineNum; ///< [IN] \~chineseͼ \~english The number of rows,which is the height of the image + + MvGvspPixelType enSrcPixelType; ///< [IN] \~chineseݵظʽ \~english The pixel format of the input data + unsigned char* pSrcData; ///< [IN] \~chineseݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chineseݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chineseݻ \~english Output pixel data buffer + unsigned int nDstBufSize; ///< [IN] \~chineseṩС(nLinePntNum * nLineNum * (16*3 + 4) + 2048) \~english Output buffer size provided(nLinePntNum * nLineNum * (16*3 + 4) + 2048) + unsigned int nDstBufLen; ///< [OUT] \~chineseݻ泤 \~english Output pixel data buffer size + MV_SAVE_POINT_CLOUD_FILE_TYPE enPointCloudFileType; ///< [IN] \~chineseṩĵļ \~english Output point data file type provided + + unsigned int nReserved[8]; ///< \~chinese ֶ \~english Reserved Field + +}MV_SAVE_POINT_CLOUD_PARAM; + +/// \~chinese ͼƬʽ \~english Save image type +enum MV_SAVE_IAMGE_TYPE +{ + MV_Image_Undefined = 0, ///< \~chinese δͼʽ \~english Undefined Image Type + MV_Image_Bmp = 1, ///< \~chinese BMPͼʽ \~english BMP Image Type + MV_Image_Jpeg = 2, ///< \~chinese JPEGͼʽ \~english Jpeg Image Type + MV_Image_Png = 3, ///< \~chinese PNGͼʽ \~english Png Image Type + MV_Image_Tif = 4, ///< \~chinese TIFFͼʽ \~english TIFF Image Type +}; + +/// \~chinese ͼƬ \~english Save Image Parameters +typedef struct _MV_SAVE_IMAGE_PARAM_T_EX_ +{ + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Input Data Pixel Format + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬС \~english Output Image Size + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + unsigned int nJpgQuality; ///< [IN] \~chinese JPG(50-99]ʽЧ \~english Encoding quality(50-99]Other formats are invalid + + ///< [IN] \~chinese BayerIJֵ 0- 1- 2-ţֵĬΪţ + ///< [IN] \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + unsigned int iMethodValue; ///< [IN] \~chinese ֵ \~english Method Value + unsigned int nReserved[3]; ///< \~chinese Ԥ \~english Reserved + +}MV_SAVE_IMAGE_PARAM_EX; + +/// \~chinese BMPJPEGPNGTIFFͼƬļIJ \~english Save BMPJPEGPNGTIFF image file parameters +typedef struct _MV_SAVE_IMG_TO_FILE_PARAM_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chineseݵظʽ \~english The pixel format of the input data + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Input Image Format + unsigned int nQuality; ///< [IN] \~chinese JPG(50-99]PNG[0-9]ʽЧ \~english JPG Encoding quality(50-99],PNG Encoding quality[0-9]Other formats are invalid + char pImagePath[256]; ///< [IN] \~chinese ļ· \~english Input file path + + ///< [IN] \~chinese BayerIJֵ 0- 1- 2-ţֵĬΪţ + ///< [IN] \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + int iMethodValue; ///< [IN] \~chinese ֵ \~english Method Value + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_SAVE_IMG_TO_FILE_PARAM; + +/// \~chinese תǶ \~english Rotation angle +typedef enum _MV_IMG_ROTATION_ANGLE_ +{ + MV_IMAGE_ROTATE_90 = 1, + MV_IMAGE_ROTATE_180 = 2, + MV_IMAGE_ROTATE_270 = 3, + +}MV_IMG_ROTATION_ANGLE; + +/// \~chinese ͼתṹ \~english Rotate image structure +typedef struct _MV_CC_ROTATE_IMAGE_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ(֧Mono8/RGB24/BGR24) \~english Pixel format(Only support Mono8/RGB24/BGR24) + unsigned int nWidth; ///< [IN][OUT] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN][OUT] \~chinese ͼ \~english Height + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + + MV_IMG_ROTATION_ANGLE enRotationAngle; ///< [IN] \~chinese תǶ \~english Rotation angle + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_ROTATE_IMAGE_PARAM; + +/// \~chinese ת \~english Flip type +typedef enum _MV_IMG_FLIP_TYPE_ +{ + MV_FLIP_VERTICAL = 1, + MV_FLIP_HORIZONTAL = 2, + +}MV_IMG_FLIP_TYPE; + +/// \~chinese ͼתṹ \~english Flip image structure +typedef struct _MV_CC_FLIP_IMAGE_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ(֧Mono8/RGB24/BGR24) \~english Pixel format(Only support Mono8/RGB24/BGR24) + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ \~english Height + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + + MV_IMG_FLIP_TYPE enFlipType; ///< [IN] \~chinese ת \~english Flip type + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FLIP_IMAGE_PARAM; + +/// \~chinese ͼתṹ \~english Pixel convert structure +typedef struct _MV_PIXEL_CONVERT_PARAM_T_ +{ + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Height + + enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese Դظʽ \~english Source pixel format + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + enum MvGvspPixelType enDstPixelType; ///< [IN] \~chinese Ŀظʽ \~english Destination pixel format + unsigned char* pDstBuffer; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstLen; ///< [OUT] \~chinese ݴС \~english Output data size + unsigned int nDstBufferSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + + unsigned int nRes[4]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_PIXEL_CONVERT_PARAM; + +/// \~chinese ɫʽ \~english Color correction param +typedef struct _MV_CC_CCM_PARAM_T_ +{ + bool bCCMEnable; ///< [IN] \~chinese ɫУʹ \~english Color correction enable + int nCCMat[9]; ///< [IN] \~chinese ɫʽ(-8192~8192) \~english Color correction matrix + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_CCM_PARAM; + +/// \~chinese \~english Noise feature type +typedef enum _MV_CC_BAYER_NOISE_FEATURE_TYPE +{ + MV_CC_BAYER_NOISE_FEATURE_TYPE_INVALID = 0, ///< \~chinese Чֵ \~english Invalid + MV_CC_BAYER_NOISE_FEATURE_TYPE_PROFILE = 1, ///< \~chinese \~english Noise curve + MV_CC_BAYER_NOISE_FEATURE_TYPE_LEVEL = 2, ///< \~chinese ˮƽ \~english Noise level + MV_CC_BAYER_NOISE_FEATURE_TYPE_DEFAULT = 1, ///< \~chinese Ĭֵ \~english Default + +}MV_CC_BAYER_NOISE_FEATURE_TYPE; + +/// \~chinese BayerʽϢ \~english Denoise profile info +typedef struct _MV_CC_BAYER_NOISE_PROFILE_INFO_T_ +{ + unsigned int nVersion; ///< \~chinese 汾 \~english version + MV_CC_BAYER_NOISE_FEATURE_TYPE enNoiseFeatureType; ///< \~chinese \~english noise feature type + enum MvGvspPixelType enPixelType; ///< \~chinese ͼʽ \~english image format + int nNoiseLevel; ///< \~chinese ƽˮƽ \~english noise level + unsigned int nCurvePointNum; ///< \~chinese ߵ \~english curve point number + int* nNoiseCurve; ///< \~chinese \~english noise curve + int* nLumCurve; ///< \~chinese \~english luminance curve + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_NOISE_PROFILE_INFO; + +/// \~chinese BayerʽƲ \~english Bayer noise estimate param +typedef struct _MV_CC_BAYER_NOISE_ESTIMATE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(ڵ8) \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ(ڵ8) \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned int nNoiseThreshold; ///< [IN] \~chinese ֵ(0-4095) \~english Noise Threshold + + unsigned char* pCurveBuf; ///< [IN] \~chinese ڴ洢ߺߣҪⲿ䣬С4096 * sizeof(int) * 2 \~english Buffer used to store noise and brightness curves, size:4096 * sizeof(int) * 2) + MV_CC_BAYER_NOISE_PROFILE_INFO stNoiseProfile; ///< [OUT] \~chinese Ϣ \~english Denoise profile + + unsigned int nThreadNum; ///< [IN] \~chinese ߳0ʾ㷨ӲӦ1ʾ̣߳Ĭϣ1ʾ߳Ŀ \~english Thread number, 0 means that the library is adaptive to the hardware, 1 means single thread(Default value), Greater than 1 indicates the number of threads + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_NOISE_ESTIMATE_PARAM; + +/// \~chinese Bayerʽ \~english Bayer spatial Denoise param +typedef struct _MV_CC_BAYER_SPATIAL_DENOISE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(ڵ8) \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ(ڵ8) \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + MV_CC_BAYER_NOISE_PROFILE_INFO stNoiseProfile; ///< [IN] \~chinese Ϣ(Դ) \~english Denoise profile + unsigned int nDenoiseStrength; ///< [IN] \~chinese ǿ(0-100) \~english nDenoise Strength + unsigned int nSharpenStrength; ///< [IN] \~chinese ǿ(0-32) \~english Sharpen Strength + unsigned int nNoiseCorrect; ///< [IN] \~chinese Уϵ(0-1280) \~english Noise Correct + + unsigned int nThreadNum; ///< [IN] \~chinese ߳0ʾ㷨ӲӦ1ʾ̣߳Ĭϣ1ʾ߳Ŀ \~english Thread number, 0 means that the library is adaptive to the hardware, 1 means single thread(Default value), Greater than 1 indicates the number of threads + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_SPATIAL_DENOISE_PARAM; + +/// \~chinese ˮӡϢ \~english Frame-specific information +typedef struct _MV_CC_FRAME_SPEC_INFO_ +{ + /// \~chinese 豸ˮӡʱ \~english Device frame-specific time scale + unsigned int nSecondCount; ///< [OUT] \~chinese \~english The Seconds + unsigned int nCycleCount; ///< [OUT] \~chinese \~english The Count of Cycle + unsigned int nCycleOffset; ///< [OUT] \~chinese ƫ \~english The Offset of Cycle + + float fGain; ///< [OUT] \~chinese \~english Gain + float fExposureTime; ///< [OUT] \~chinese عʱ \~english Exposure Time + unsigned int nAverageBrightness; ///< [OUT] \~chinese ƽ \~english Average brightness + + /// \~chinese ƽ \~english White balance + unsigned int nRed; ///< [OUT] \~chinese ɫ \~english Red + unsigned int nGreen; ///< [OUT] \~chinese ɫ \~english Green + unsigned int nBlue; ///< [OUT] \~chinese ɫ \~english Blue + + unsigned int nFrameCounter; ///< [OUT] \~chinese ֡ \~english Frame Counter + unsigned int nTriggerIndex; ///< [OUT] \~chinese \~english Trigger Counting + + unsigned int nInput; ///< [OUT] \~chinese \~english Input + unsigned int nOutput; ///< [OUT] \~chinese \~english Output + + /// \~chinese ROI \~english ROI Region + unsigned short nOffsetX; ///< [OUT] \~chinese ˮƽƫ \~english OffsetX + unsigned short nOffsetY; ///< [OUT] \~chinese ֱƫ \~english OffsetY + unsigned short nFrameWidth; ///< [OUT] \~chinese ˮӡ \~english The Width of Chunk + unsigned short nFrameHeight; ///< [OUT] \~chinese ˮӡ \~english The Height of Chunk + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FRAME_SPEC_INFO; + +/// \~chinese \~english High Bandwidth decode structure +typedef struct _MV_CC_HB_DECODE_PARAM_T_ +{ + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned int nWidth; ///< [OUT] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [OUT] \~chinese ͼ \~english Height + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + MvGvspPixelType enDstPixelType; ///< [OUT] \~chinese ظʽ \~english Output pixel format + + MV_CC_FRAME_SPEC_INFO stFrameSpecInfo; ///< [OUT] \~chinese ˮӡϢ \~english Frame Spec Info + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_HB_DECODE_PARAM; + +/// \~chinese ¼ʽ \~english Record Format Type +typedef enum _MV_RECORD_FORMAT_TYPE_ +{ + MV_FormatType_Undefined = 0, ///< \~chinese δ¼ʽ \~english Undefined Recode Format Type + MV_FormatType_AVI = 1, ///< \~chinese AVI¼ʽ \~english AVI Recode Format Type + +}MV_RECORD_FORMAT_TYPE; + +/// \~chinese ¼ \~english Record Parameters +typedef struct _MV_CC_RECORD_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Pixel Type + + unsigned short nWidth; ///< [IN] \~chinese ͼ(ָĿʱΪ2ı) \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ(ָĿʱΪ2ı) \~english Height + + float fFrameRate; ///< [IN] \~chinese ֡fps(1/16) \~english The Rate of Frame + unsigned int nBitRate; ///< [IN] \~chinese kbps(128kbps-16Mbps) \~english The Rate of Bitrate + + MV_RECORD_FORMAT_TYPE enRecordFmtType; ///< [IN] \~chinese ¼ʽ \~english Recode Format Type + + char* strFilePath; ///< [IN] \~chinese ¼ļ·(·дģתutf-8) \~english File Path + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_RECORD_PARAM; + +/// \~chinese ͼ \~english Input Data +typedef struct _MV_CC_INPUT_FRAME_INFO_T_ +{ + unsigned char* pData; ///< [IN] \~chinese ͼָ \~english Record Data + unsigned int nDataLen; ///< [IN] \~chinese ͼС \~english The Length of Record Data + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_INPUT_FRAME_INFO; + +/// \~chinese ɼģʽ \~english Acquisition mode +typedef enum _MV_CAM_ACQUISITION_MODE_ +{ + MV_ACQ_MODE_SINGLE = 0, ///< \~chinese ֡ģʽ \~english Single Mode + MV_ACQ_MODE_MUTLI = 1, ///< \~chinese ֡ģʽ \~english Multi Mode + MV_ACQ_MODE_CONTINUOUS = 2, ///< \~chinese ɼģʽ \~english Continuous Mode + +}MV_CAM_ACQUISITION_MODE; + +/// \~chinese ģʽ \~english Gain Mode +typedef enum _MV_CAM_GAIN_MODE_ +{ + MV_GAIN_MODE_OFF = 0, ///< \~chinese ر \~english Single Mode + MV_GAIN_MODE_ONCE = 1, ///< \~chinese һ \~english Multi Mode + MV_GAIN_MODE_CONTINUOUS = 2, ///< \~chinese \~english Continuous Mode + +}MV_CAM_GAIN_MODE; + +/// \~chinese عģʽ \~english Exposure Mode +typedef enum _MV_CAM_EXPOSURE_MODE_ +{ + MV_EXPOSURE_MODE_TIMED = 0, ///< \~chinese ʱ \~english Timed + MV_EXPOSURE_MODE_TRIGGER_WIDTH = 1, ///< \~chinese \~english TriggerWidth +}MV_CAM_EXPOSURE_MODE; + +/// \~chinese Զعģʽ \~english Auto Exposure Mode +typedef enum _MV_CAM_EXPOSURE_AUTO_MODE_ +{ + MV_EXPOSURE_AUTO_MODE_OFF = 0, ///< \~chinese ر \~english Off + MV_EXPOSURE_AUTO_MODE_ONCE = 1, ///< \~chinese һ \~english Once + MV_EXPOSURE_AUTO_MODE_CONTINUOUS = 2, ///< \~chinese \~english Continuous + +}MV_CAM_EXPOSURE_AUTO_MODE; + +/// \~chinese ģʽ \~english Trigger Mode +typedef enum _MV_CAM_TRIGGER_MODE_ +{ + MV_TRIGGER_MODE_OFF = 0, ///< \~chinese ر \~english Off + MV_TRIGGER_MODE_ON = 1, ///< \~chinese \~english ON + +}MV_CAM_TRIGGER_MODE; + +/// \~chinese Gammaѡ \~english Gamma Selector +typedef enum _MV_CAM_GAMMA_SELECTOR_ +{ + MV_GAMMA_SELECTOR_USER = 1, ///< \~chinese û \~english Gamma Selector User + MV_GAMMA_SELECTOR_SRGB = 2, ///< \~chinese sRGB \~english Gamma Selector sRGB + +}MV_CAM_GAMMA_SELECTOR; + +/// \~chinese ƽ \~english White Balance +typedef enum _MV_CAM_BALANCEWHITE_AUTO_ +{ + MV_BALANCEWHITE_AUTO_OFF = 0, ///< \~chinese ر \~english Off + MV_BALANCEWHITE_AUTO_ONCE = 2, ///< \~chinese һ \~english Once + MV_BALANCEWHITE_AUTO_CONTINUOUS = 1, ///< \~chinese \~english Continuous + +}MV_CAM_BALANCEWHITE_AUTO; + +/// \~chinese Դ \~english Trigger Source +typedef enum _MV_CAM_TRIGGER_SOURCE_ +{ + MV_TRIGGER_SOURCE_LINE0 = 0, ///< \~chinese Line0 \~english Line0 + MV_TRIGGER_SOURCE_LINE1 = 1, ///< \~chinese Line1 \~english Line0 + MV_TRIGGER_SOURCE_LINE2 = 2, ///< \~chinese Line2 \~english Line0 + MV_TRIGGER_SOURCE_LINE3 = 3, ///< \~chinese Line3 \~english Line3 + MV_TRIGGER_SOURCE_COUNTER0 = 4, ///< \~chinese Conuter0 \~english Conuter0 + + MV_TRIGGER_SOURCE_SOFTWARE = 7, ///< \~chinese \~english Software + MV_TRIGGER_SOURCE_FrequencyConverter= 8, ///< \~chinese Ƶ \~english Frequency Converter + +}MV_CAM_TRIGGER_SOURCE; + +/// \~chinese GigEVision IP \~english GigEVision IP Configuration +#define MV_IP_CFG_STATIC 0x05000000 ///< \~chinese ̬ \~english Static +#define MV_IP_CFG_DHCP 0x06000000 ///< \~chinese DHCP \~english DHCP +#define MV_IP_CFG_LLA 0x04000000 ///< \~chinese LLA \~english LLA + +/// \~chinese GigEVision紫ģʽ \~english GigEVision Net Transfer Mode +#define MV_NET_TRANS_DRIVER 0x00000001 ///< \~chinese \~english Driver +#define MV_NET_TRANS_SOCKET 0x00000002 ///< \~chinese Socket \~english Socket + +/// \~chinese CameraLink \~english CameraLink Baud Rates (CLUINT32) +#define MV_CAML_BAUDRATE_9600 0x00000001 ///< \~chinese 9600 \~english 9600 +#define MV_CAML_BAUDRATE_19200 0x00000002 ///< \~chinese 19200 \~english 19200 +#define MV_CAML_BAUDRATE_38400 0x00000004 ///< \~chinese 38400 \~english 38400 +#define MV_CAML_BAUDRATE_57600 0x00000008 ///< \~chinese 57600 \~english 57600 +#define MV_CAML_BAUDRATE_115200 0x00000010 ///< \~chinese 115200 \~english 115200 +#define MV_CAML_BAUDRATE_230400 0x00000020 ///< \~chinese 230400 \~english 230400 +#define MV_CAML_BAUDRATE_460800 0x00000040 ///< \~chinese 460800 \~english 460800 +#define MV_CAML_BAUDRATE_921600 0x00000080 ///< \~chinese 921600 \~english 921600 +#define MV_CAML_BAUDRATE_AUTOMAX 0x40000000 ///< \~chinese ֵ \~english Auto Max + +/// \~chinese 쳣Ϣ \~english Exception message type +#define MV_EXCEPTION_DEV_DISCONNECT 0x00008001 ///< \~chinese 豸Ͽ \~english The device is disconnected +#define MV_EXCEPTION_VERSION_CHECK 0x00008002 ///< \~chinese SDK汾ƥ \~english SDK does not match the driver version + +/// \~chinese Event¼صϢ\ \~english Event callback infomation +#define MAX_EVENT_NAME_SIZE 128 ///< \~chinese 豸Event¼󳤶 \~english Max length of event name +typedef struct _MV_EVENT_OUT_INFO_ +{ + char EventName[MAX_EVENT_NAME_SIZE]; ///< [OUT] \~chinese Event \~english Event name + + unsigned short nEventID; ///< [OUT] \~chinese Event \~english Event ID + unsigned short nStreamChannel; ///< [OUT] \~chinese ͨ \~english Circulation number + + unsigned int nBlockIdHigh; ///< [OUT] \~chinese ֡Ÿλ \~english BlockId high + unsigned int nBlockIdLow; ///< [OUT] \~chinese ֡ŵλ \~english BlockId low + + unsigned int nTimestampHigh; ///< [OUT] \~chinese ʱλ \~english Timestramp high + unsigned int nTimestampLow; ///< [OUT] \~chinese ʱλ \~english Timestramp low + + void* pEventData; ///< [OUT] \~chinese Event \~english Event data + unsigned int nEventDataSize; ///< [OUT] \~chinese Eventݳ \~english Event data len + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved +}MV_EVENT_OUT_INFO; + +/// \~chinese ļȡ \~english File Access +typedef struct _MV_CC_FILE_ACCESS_T +{ + const char* pUserFileName; ///< [IN] \~chinese ûļ \~english User file name + const char* pDevFileName; ///< [IN] \~chinese 豸ļ \~english Device file name + + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FILE_ACCESS; + +/// \~chinese ļȡ \~english File Access Progress +typedef struct _MV_CC_FILE_ACCESS_PROGRESS_T +{ + int64_t nCompleted; ///< [OUT] \~chinese ɵij \~english Completed Length + int64_t nTotal; ///< [OUT] \~chinese ܳ \~english Total Length + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FILE_ACCESS_PROGRESS; + +/// \~chinese GigeĴ \~english The transmission type of Gige +typedef enum _MV_GIGE_TRANSMISSION_TYPE_ +{ + MV_GIGE_TRANSTYPE_UNICAST = 0x0, ///< \~chinese ʾ(Ĭ) \~english Unicast mode + MV_GIGE_TRANSTYPE_MULTICAST = 0x1, ///< \~chinese ʾ鲥 \~english Multicast mode + MV_GIGE_TRANSTYPE_LIMITEDBROADCAST = 0x2, ///< \~chinese ʾڹ㲥ݲ֧ \~english Limited broadcast mode,not support + MV_GIGE_TRANSTYPE_SUBNETBROADCAST = 0x3, ///< \~chinese ʾڹ㲥ݲ֧ \~english Subnet broadcast mode,not support + MV_GIGE_TRANSTYPE_CAMERADEFINED = 0x4, ///< \~chinese ʾ豸ȡݲ֧ \~english Transtype from camera,not support + MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT = 0x5, ///< \~chinese ʾûԶӦö˽ͼPort \~english User Defined Receive Data Port + MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV = 0x00010000, ///< \~chinese ʾ˵ʵͼ \~english Unicast without receive data + MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV = 0x00010001, ///< \~chinese ʾ鲥ģʽʵͼ \~english Multicast without receive data +}MV_GIGE_TRANSMISSION_TYPE; + +/// \~chinese ģʽΪģʽ鲥ģʽ \~english Transmission type +typedef struct _MV_TRANSMISSION_TYPE_T +{ + MV_GIGE_TRANSMISSION_TYPE enTransmissionType; ///< [IN] \~chinese ģʽ \~english Transmission type + unsigned int nDestIp; ///< [IN] \~chinese ĿIP鲥ģʽ \~english Destination IP + unsigned short nDestPort; ///< [IN] \~chinese ĿPort鲥ģʽ \~english Destination port + + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved +}MV_TRANSMISSION_TYPE; + +/// \~chinese Ϣ \~english Action Command +typedef struct _MV_ACTION_CMD_INFO_T +{ + unsigned int nDeviceKey; ///< [IN] \~chinese 豸Կ \~english Device Key; + unsigned int nGroupKey; ///< [IN] \~chinese \~english Group Key + unsigned int nGroupMask; ///< [IN] \~chinese \~english Group Mask + + unsigned int bActionTimeEnable; ///< [IN] \~chinese ֻó1ʱAction TimeЧ1ʱЧ \~english Action Time Enable + int64_t nActionTime; ///< [IN] \~chinese Ԥʱ䣬Ƶй \~english Action Time + + const char* pBroadcastAddress; ///< [IN] \~chinese 㲥ַ \~english Broadcast Address + unsigned int nTimeOut; ///< [IN] \~chinese ȴACKijʱʱ䣬Ϊ0ʾҪACK \~english TimeOut + + unsigned int bSpecialNetEnable; ///< [IN] \~chinese ֻó1ʱָIPЧ1ʱЧ \~english Special IP Enable + unsigned int nSpecialNetIP; ///< [IN] \~chinese ָIP \~english Special Net IP address + + unsigned int nReserved[14]; ///< \~chinese Ԥ \~english Reserved + +}MV_ACTION_CMD_INFO; + +/// \~chinese Ϣ \~english Action Command Result +typedef struct _MV_ACTION_CMD_RESULT_T +{ + unsigned char strDeviceAddress[12 + 3 + 1]; ///< [OUT] \~chinese 豸IP \~english IP address of the device + + int nStatus; ///< [OUT] \~chinese ״̬ \~english status code returned by the device + //1.0x0000:success. + //2.0x8001:Command is not supported by the device. + //3.0x8013:The device is not synchronized to a master clock to be used as time reference. + //4.0x8015:A device queue or packet data has overflowed. + //5.0x8016:The requested scheduled action command was requested at a time that is already past. + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved + +}MV_ACTION_CMD_RESULT; + +/// \~chinese Ϣб \~english Action Command Result List +typedef struct _MV_ACTION_CMD_RESULT_LIST_T +{ + unsigned int nNumResults; ///< [OUT] \~chinese ֵ \~english Number of returned values + MV_ACTION_CMD_RESULT* pResults; ///< [OUT] \~chinese \~english Reslut of action command + +}MV_ACTION_CMD_RESULT_LIST; + +/// \~chinese ÿڵӦĽӿ \~english Interface type corresponds to each node +enum MV_XML_InterfaceType +{ + IFT_IValue, ///< \~chinese Value \~english IValue interface + IFT_IBase, ///< \~chinese Base \~english IBase interface + IFT_IInteger, ///< \~chinese Integer \~english IInteger interface + IFT_IBoolean, ///< \~chinese Boolean \~english IBoolean interface + IFT_ICommand, ///< \~chinese Command \~english ICommand interface + IFT_IFloat, ///< \~chinese Float \~english IFloat interface + IFT_IString, ///< \~chinese String \~english IString interface + IFT_IRegister, ///< \~chinese Register \~english IRegister interface + IFT_ICategory, ///< \~chinese Category \~english ICategory interface + IFT_IEnumeration, ///< \~chinese Enumeration \~english IEnumeration interface + IFT_IEnumEntry, ///< \~chinese EnumEntry \~english IEnumEntry interface + IFT_IPort, ///< \~chinese Port \~english IPort interface +}; + +/// \~chinese ڵķģʽ \~english Node Access Mode +enum MV_XML_AccessMode +{ + AM_NI, ///< \~chinese ʵ \~english Not implemented + AM_NA, ///< \~chinese \~english Not available + AM_WO, ///< \~chinese ֻд \~english Write Only + AM_RO, ///< \~chinese ֻ \~english Read Only + AM_RW, ///< \~chinese д \~english Read and Write + AM_Undefined, ///< \~chinese δ \~english Object is not yet initialized + AM_CycleDetect, ///< \~chinese ڲAccessModeѭ \~english used internally for AccessMode cycle detection +}; + +#define MV_MAX_XML_SYMBOLIC_NUM 64 /// \~chinese XML \~english Max XML Symbolic Number +/// \~chinese öֵ \~english Enumeration Value +typedef struct _MVCC_ENUMVALUE_T +{ + unsigned int nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + unsigned int nSupportedNum; ///< [OUT] \~chinese ݵЧݸ \~english Number of valid data + unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; ///< [OUT] \~chinese ֵ֧öֵ \~english Support Value + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MVCC_ENUMVALUE; + +/// \~chinese Intֵ \~english Int Value +typedef struct _MVCC_INTVALUE_T +{ + unsigned int nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + unsigned int nMax; ///< [OUT] \~chinese ֵ \~english Max + unsigned int nMin; ///< [OUT] \~chinese Сֵ \~english Min + unsigned int nInc; ///< [OUT] \~chinese \~english Inc + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MVCC_INTVALUE; + +/// \~chinese IntֵEx \~english Int Value Ex +typedef struct _MVCC_INTVALUE_EX_T +{ + int64_t nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + int64_t nMax; ///< [OUT] \~chinese ֵ \~english Max + int64_t nMin; ///< [OUT] \~chinese Сֵ \~english Min + int64_t nInc; ///< [OUT] \~chinese Inc \~english Inc + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved +}MVCC_INTVALUE_EX; + +/// \~chinese Floatֵ \~english Float Value +typedef struct _MVCC_FLOATVALUE_T +{ + float fCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + float fMax; ///< [OUT] \~chinese ֵ \~english Max + float fMin; ///< [OUT] \~chinese Сֵ \~english Min + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MVCC_FLOATVALUE; + +/// \~chinese Stringֵ \~english String Value +typedef struct _MVCC_STRINGVALUE_T +{ + char chCurValue[256]; ///< [OUT] \~chinese ǰֵ \~english Current Value + + int64_t nMaxLength; ///< [OUT] \~chinese 󳤶 \~english MaxLength + unsigned int nReserved[2]; ///< \~chinese Ԥ \~english Reserved +}MVCC_STRINGVALUE; + +#endif /* _MV_CAMERA_PARAMS_H_ */ diff --git a/Cigarette/MVS3.2.1/Include/MvCameraControl.h b/Cigarette/MVS3.2.1/Include/MvCameraControl.h new file mode 100644 index 0000000..f5e33d8 --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/MvCameraControl.h @@ -0,0 +1,2007 @@ + +#ifndef _MV_CAMERA_CTRL_H_ +#define _MV_CAMERA_CTRL_H_ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "MvObsoleteInterfaces.h" + +/************************************************************************/ +/* ̬⵼뵼 */ +/* Import and export definition of the dynamic library */ +/************************************************************************/ +#ifndef MV_CAMCTRL_API + + #if (defined (_WIN32) || defined(WIN64)) + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __declspec(dllexport) + #else + #define MV_CAMCTRL_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MV_CAMCTRL_API + #define MV_CAMCTRL_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* 豸ĻָͲ */ +/* Camera basic instructions and operations */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡSDK汾 + * @return 4ֽڰ汾 + | | | | | + 8bits 8bits 8bits 8bits + * @remarks 緵ֵΪ0x01000001SDK汾ΪV1.0.0.1 + + * @~english + * @brief Get SDK Version + * @return Always return 4 Bytes of version number + |Main |Sub |Rev | Test| + 8bits 8bits 8bits 8bits + * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. + ************************************************************************/ +MV_CAMCTRL_API unsigned int __stdcall MV_CC_GetSDKVersion(); + +/********************************************************************//** + * @~chinese + * @brief ȡֵ֧Ĵ + * @return ֵ֧Ĵ + + * @~english + * @brief Get supported Transport Layer + * @return Supported Transport Layer number + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumerateTls(); + +/********************************************************************//** + * @~chinese + * @brief ö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Device + * @param nTLayerType [IN] Enumerate TLs + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevices(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ݳö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @param strManufacturerName [IN] + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate device according to manufacture name + * @param nTLayerType [IN] Transmission layer of enumeration + * @param pstDevList [OUT] Device list + * @param strManufacturerName [IN] Manufacture Name + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName); + +/********************************************************************//** + * @~chinese + * @brief 豸Ƿɴ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param nAccessMode [IN] Ȩ + * @return ɴtrueɴfalse + * @remarks ȡ豸CCPĴֵжϵǰ״̬ǷijַȨޡ \n + 豸֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableWithKeyģʽӿڷfalseĿǰ豸֧3ռģʽij̵豸Ҳݲ֧3ģʽ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Is the device accessible + * @param pstDevInfo [IN] Device Information Structure + * @param nAccessMode [IN] Access Right + * @return Access, return true. Not access, return false + * @remarks Read device CCP register value and determine current access permission.\n + Return false if the device does not support the modes MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode); + +/********************************************************************//** + * @~chinese + * @brief SDK־· + * @param strSDKLogPath [IN] SDK־· + * @return ɹMV_OK󣬷ش + * @remarks ·֮󣬿ָ·־\n + v2.4.1汾־񣬿֮ýӿЧĬ־Ϊ״̬ + + * @~english + * @brief Set SDK log path + * @param strSDKLogPath [IN] SDK log path + * @return Access, return true. Not access, return false + * @remarks For version V2.4.1, added log service, this API is invalid when the service is enabled.And The logging service is enabled by default\n + This API is used to set the log file storing path. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSDKLogPath(IN const char * strSDKLogPath); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandleWithoutLog + + * @~english + * @brief Create Device Handle + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will be created by default. Creating handle through MV_CC_CreateHandleWithoutLog will not generate log files. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandle(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸־ + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandle־ļԶɡ + + * @~english + * @brief Create Device Handle without log + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleWithoutLog(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Destroy Device Handle + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DestroyHandle(IN void * handle); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nAccessMode [IN] Ȩ + * @param nSwitchoverKey [IN] лȨʱԿ + * @return ɹMV_OK󣬷ش + * @remarks õ豸ҵӦ豸豸\n + ýӿʱɲnAccessModenSwitchoverKeyʱĬ豸ģʽΪռȨޡĿǰ豸ݲ֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableMV_ACCESS_ControlSwitchEnableWithKeyռģʽ\n + U3V豸nAccessModenSwitchoverKeyЧ + + * @~english + * @brief Open Device + * @param handle [IN] Device handle + * @param nAccessMode [IN] Access Right + * @param nSwitchoverKey [IN] Switch key of access right + * @return Success, return MV_OK. Failure, return error code + * @remarks Find specific device and connect according to set device parameters. \n + When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access mode is exclusive. Currently the device does not support the following preemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.\n + For USB3Vision device, nAccessMode, nSwitchoverKey are invalid. + ************************************************************************/ +#ifndef __cplusplus +MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey); +#else +MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode = MV_ACCESS_Exclusive, IN unsigned short nSwitchoverKey = 0); +#endif + +/********************************************************************//** + * @~chinese + * @brief ر豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ͨMV_CC_OpenDevice豸󣬿ͨýӿڶϿ豸ӣͷԴ + + * @~english + * @brief Close Device + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CloseDevice(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ж豸Ƿ״̬ + * @param handle [IN] 豸 + * @return 豸״̬trueûӻʧȥӣfalse + + * @~english + * @brief Is The Device Connected + * @param handle [IN] Device handle + * @return Connected, return true. Not Connected or DIsconnected, return false + ***********************************************************************/ +MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceConnected(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief עͼݻص + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackExͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetOneFrameTimeoutȡָظʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register the image callback function + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.\n + There are two available image data acquisition modes, and cannot be used together: \n + Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackEx(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصRGB + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForRGBRGB24ʽͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForRGBȡRGB24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, RGB + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB repeatedly in application layer to get frame data with RGB24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForRGB(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصBGR + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá\n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForBGRBGR24ͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForBGRȡBGR24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, BGR + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.\n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForBGR(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief ʼȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Start Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StartGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ֹͣȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Stop Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StopGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡RGBݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתRGB24ʽأû򷵻ش롣ΪͼתRGB24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡\n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of RGB data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Each time the API is called, the internal cache is checked for data. If there is data, it will be transformed as RGB24 format for return, if there is no data, return error code. As time-consuming exists when transform the image to RGB24 format, this API may cause frame loss when the data frame rate is too high. \n + Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡BGRݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתBGR24ʽأû򷵻ش롣ΪͼתBGR24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡ \n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of BGR data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ʹڲȡһ֡ͼƬMV_CC_Displayͬʱʹã + * @param handle [IN] 豸 + * @param pstFrame [OUT] ͼݺͼϢ + * @param nMsec [IN] ȴʱʱ䣬INFINITEʱʾ޵ȴֱյһ֡ݻֹͣȡ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ \n + ýӿMV_CC_FreeImageBufferʹãȡݺҪMV_CC_FreeImageBufferӿڽpFrameڵָȨ޽ͷš \n + ýӿMV_CC_GetOneFrameTimeoutȣŸߵЧʡȡķsdkڲԶģMV_CC_GetOneFrameTimeoutӿҪͻз䡣\n + ýӿڵMV_CC_Display޷ȡ \n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get a frame of an image using an internal cache + * @param handle [IN] Device handle + * @param pstFrame [OUT] Image data and image information + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API support setting timeout, and SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. \n + This interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. \n + This API cannot be called to stream after calling MV_CC_Display. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. \n + **********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageBuffer(IN void* handle, OUT MV_FRAME_OUT* pstFrame, IN unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ͷͼ񻺴(˽ӿͷŲʹõͼ񻺴棬MV_CC_GetImageBufferʹ) + * @param handle [IN] 豸 + * @param pstFrame [IN] ͼݺͼ + * @return ɹMV_OK󣬷ش + * @remarks ýӿMV_CC_GetImageBufferʹãʹMV_CC_GetImageBufferӿȡͼpFrameҪMV_CC_FreeImageBufferӿڽȨͷš \n + ýӿڶȡЧʸGetOneFrameTimeoutӿڣGetImageBufferڲFree£֧ĽڵSetImageNodeӿõĽڵȣĬϽڵ1\n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) + * @param handle [IN] Device handle + * @param pstFrame [IN] Image data and image information + * @return Success, return MV_OK. Failure, return error code + * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to get image data pFrame, you should call MV_CC_FreeImageBuffer to release the permission. \n + Compared with API MV_CC_GetOneFrameTimeout, this API has higher efficiency of image acquisition. The max. number of nodes can be outputted is same as the "nNum" of API MV_CC_SetImageNodeNum, default value is 1. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. + **********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pstFrame); + +/********************************************************************//** + * @~chinese + * @brief óʱƻȡһ֡ͼƬSDKڲȴֱʱ + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ\n + ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API supports setting timeout, SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + Both the USB3Vision and GIGE camera can support this API. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameTimeout(IN void* handle, IN OUT unsigned char* pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡݻ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿûڲֹͣȡʱ򣬾вҪͼ\n + ýӿģʽдģʽ󣬿ʷݡ + + * @~english + * @brief if Image buffers has retrieved the dataClear them + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface allows user to clear the unnecessary images from the buffer memory without stopping acquisition. \n + This interface allows user to clear previous data after switching from continuous mode to trigger mode. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ClearImageBuffer(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ʾһ֡ͼ + * @param handle [IN] 豸 + * @param pstDisplayInfo [IN] ͼϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Display one frame image + * @param handle [IN] Device handle + * @param pstDisplayInfo [IN] Frame Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is valid for USB3Vision camera and GIGE camera. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pstDisplayInfo); + +/********************************************************************//** + * @~chinese + * @brief SDKڲͼ񻺴ڵڵ1ץͼǰ + * @param handle [IN] 豸 + * @param nNum [IN] ڵ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڿSDKڲͼ񻺴ڵڵMV_CC_StartGrabbingʼץͼǰá\n + SDKĬ1ڵ㡣\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture + * @param handle [IN] Device handle + * @param nNum [IN] Image Node Number + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface to set the number of SDK internal image buffer nodes. The interface should be called before calling MV_CC_StartGrabbing for capturing. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetImageNodeNum(IN void* handle, unsigned int nNum); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param enGrabStrategy [IN] öֵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶȡԣûԸʵѡ񡣾£ + -OneByOne:Ӿɵһ֡һ֡Ĵблȡͼ񣬴豸ĬΪò + -LatestImagesOnly:блȡµһ֡ͼͬʱб + -LatestImages:блȡµOutputQueueSize֡ͼOutputQueueSizeΧΪ1-ImageNodeNumMV_CC_SetOutputQueueSizeӿãImageNodeNumĬΪ1MV_CC_SetImageNodeNumӿ OutputQueueSizeó1ͬLatestImagesOnlyԣOutputQueueSizeóImageNodeNumͬOneByOne + -UpcomingImage:ڵȡӿʱбͼ񣬲ȴ豸ɵһ֡ͼ񡣸òֻ֧GigE豸֧U3V豸 + + * @~english + * @brief Set Grab Strategy + * @param handle [IN] Device handle + * @param enGrabStrategy [IN] The value of Grab Strategy + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is set by four image acquisition approaches, the user may choose one as needed. Specific details are as followed: + -OneByOne:Obtain image from output cache list frame by frame in order, this function is default strategy when device is on. + -LatestImagesOnly:Obtain the latest image from output cache list only, meanwhile clear output cache list. + -LatestImages:Obtain the latest OutputQueueSize image from output cache list, the range of OutputQueueSize is 1-ImageNodeNum, the user may set the value of MV_CC_SetOutputQueueSizeinterface,the default value of ImageNodeNum is 1,If the user usesMV_CC_SetImageNodeNuminterface to set up OutputQueueSize,when the value of OutputQueueSize is set to be 1, the function will be same as LatestImagesOnly; if the value of OutputQueueSize is set to be ImageNodeNum, the function will be same as OneByOne. + -UpcomingImage:Ignore all images in output cache list when calling image acuiqisiotn interface, wait the next upcoming image generated. Support for GigE camera only, not support for U3V camera. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGrabStrategy(IN void* handle, IN MV_GRAB_STRATEGY enGrabStrategy); + +/********************************************************************//** + * @~chinese + * @brief ֻMV_GrabStrategy_LatestImages²ЧΧ1-ImageNodeNum + * @param handle [IN] 豸 + * @param nOutputQueueSize [IN] + * @return ɹMV_OK󣬷ش + * @remarks ýӿLatestImagesȡ׵ãLatestImagesͼĸȡж̬ + + * @~english + * @brief Set The Size of Output Queue(Only work under the strategy of MV_GrabStrategy_LatestImagesrang1-ImageNodeNum) + * @param handle [IN] Device handle + * @param nOutputQueueSize [IN] The Size of Output Queue + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface must be used with LatestImages Grab strategy, it is used for setting the maximum allowance queue size of the image under the LatestImages strategy. The user may change the output queue size while grabbing images. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetOutputQueueSize(IN void* handle, IN unsigned int nOutputQueueSize); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸Ϣȡ֮ǰ + * @param handle [IN] 豸 + * @param pstDevInfo [IN][OUT] ظй豸Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ֧ûڴ豸ȡ豸Ϣ\n + 豸GigE豸øýӿڴգ˲ȡеøýӿڡ + + * @~english + * @brief Get device information + * @param handle [IN] Device handle + * @param pstDevInfo [IN][OUT] Structure pointer of device information + * @return Success, return MV_OK. Failure, return error code + * @remarks The API support users to access device information after opening the device. \n + If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not recommended to call the interface during the fetching process. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief ȡ͵Ϣ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظй豸͵Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӿҪȡϢָͣMV_ALL_MATCH_INFOṹеnTypeͣȡӦϢMV_ALL_MATCH_INFOṹpInfoﷵأ \n + ýӿڵĵǰȡȡϢͣȡGigE豸MV_MATCH_TYPE_NET_DETECTϢڿץͼ֮ãȡU3V豸MV_MATCH_TYPE_USB_DETECTϢڴ豸֮á \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get various type of information + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of various type of information + * @return Success, return MV_OK. Failure, return error code + * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO). \n + The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo); + + +/************************************************************************/ +/* úͻȡ豸ܽӿ */ +/* General interface for getting and setting camera parameters */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡIntegerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param pstIntValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to get width + * @param pstIntValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE_EX *pstIntValue); + +/********************************************************************//** + * @~chinese + * @brief Integerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to set width + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue); + +/********************************************************************//** + * @~chinese + * @brief ȡEnumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param pstEnumValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel format + * @param pstEnumValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetEnumValue(IN void* handle,IN const char* strKey,OUT MVCC_ENUMVALUE *pstEnumValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param strValue [IN] Ҫõ豸ַ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param strValue [IN] Feature String to set + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API after connecting the device. All the values of nodes with IEnumeration type can be set via this API. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValueByString(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief ȡFloatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstFloatValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstFloatValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFloatValue(IN void* handle,IN const char* strKey,OUT MVCC_FLOATVALUE *pstFloatValue); + +/********************************************************************//** + * @~chinese + * @brief floatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param fValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param fValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFloatValue(IN void* handle,IN const char* strKey,IN float fValue); + +/********************************************************************//** + * @~chinese + * @brief ȡBooleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pbValue [IN][OUT] ظй豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pbValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBoolValue(IN void* handle,IN const char* strKey,OUT bool *pbValue); + +/********************************************************************//** + * @~chinese + * @brief Booleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param bValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param bValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBoolValue(IN void* handle,IN const char* strKey,IN bool bValue); + +/********************************************************************//** + * @~chinese + * @brief ȡStringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstStringValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstStringValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetStringValue(IN void* handle,IN const char* strKey,OUT MVCC_STRINGVALUE *pstStringValue); + +/********************************************************************//** + * @~chinese + * @brief Stringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param strValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param strValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetStringValue(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief Commandֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿָCommandͽڵ㡣strKeyȡֵԲοXMLڵбΪICommandĽڵ㶼ͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Send Command + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Command nodes. For value of strKey, see MvCameraNode. The node values of ICommand can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetCommandValue(IN void* handle,IN const char* strKey); + +/********************************************************************//** + * @~chinese + * @brief GenICamڵ㻺 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Invalidate GenICam Nodes + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_InvalidateNodes(IN void* handle); + + +/************************************************************************/ +/* 豸 Ĵд 쳣¼ص */ +/* Device upgrade, register read and write and exception callback */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFilePathName [IN] ļ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԽ̼ļ͸豸ýӿҪȴ̼ļɹ豸֮ٷأӦʱܽϳ + + * @~english + * @brief Device Local Upgrade + * @param handle [IN] Device handle + * @param strFilePathName [IN] File name + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to send the upgrade firmware to the device for upgrade. This API will wait for return until the upgrade firmware is sent to the device, this response may take a long time. \n + For CameraLink device, it keeps sending upgrade firmware continuously. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_LocalUpgrade(IN void* handle, const void* strFilePathName); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param pnProcess [OUT] Ƚյַ + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Get Upgrade Progress + * @param handle [IN] Device handle + * @param pnProcess [OUT] Progress receiving address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetUpgradeProcess(IN void* handle, unsigned int* pnProcess); + +/********************************************************************//** + * @~chinese + * @brief ڴ + * @param handle [IN] 豸 + * @param pBuffer [IN][OUT] ΪֵʹãڴֵGEV豸ڴֵǰմģʽ洢ģЭ豸С˴洢 + * @param nAddress [IN] ȡڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] ȡڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸ȡijμĴݡ + + * @~english + * @brief Read Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( Memory value is stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be read, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be read + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, read the data from certain register. +*************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ReadMemory(IN void* handle , void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief дڴ + * @param handle [IN] 豸 + * @param pBuffer [IN] дڴֵעGEV豸ڴֵҪմģʽ洢Э豸С˴洢 + * @param nAddress [IN] дڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] дڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸һдijμĴ + + * @~english + * @brief Write Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN] Memory value to be written ( Note the memory value to be stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be written, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be written + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, write a piece of data into a certain segment of register. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_WriteMemory(IN void* handle, const void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief ע쳣Ϣصڴ豸֮ + * @param handle [IN] 豸 + * @param cbException [IN] 쳣صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿҪMV_CC_OpenDevice豸֮á豸쳣ϿӺڻصȡ쳣ϢGigE豸֮ҪȵMV_CC_CloseDeviceӿڹر豸ٵMV_CC_OpenDeviceӿ´豸 + + * @~english + * @brief Register Exception Message CallBack, call after open device + * @param handle [IN] Device handle + * @param cbException [IN] Exception Message CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterExceptionCallBack(IN void* handle, + void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עȫ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterAllEventCallBack(void* handle, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עᵥ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param strEventName [IN] ¼ + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ\n + ýӿڲ֧CameraLink豸֧"豸"һ¼ + + * @~english + * @brief Register single event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param strEventName [IN] Event name + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device . +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBackEx(void* handle, const char* strEventName, + void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + + +/************************************************************************/ +/* GigEVision 豸еĽӿ */ +/* GigEVision device specific interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ǿIP + * @param handle [IN] 豸 + * @param nIP [IN] õIP + * @param nSubNetMask [IN] + * @param nDefaultGateWay [IN] Ĭ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ǿ豸IP롢Ĭأǿ֮Ҫ´豸GigEVision豸֧֡\n + 豸ΪDHCP״̬øýӿǿ豸֮豸 + + * @~english + * @brief Force IP + * @param handle [IN] Device handle + * @param nIP [IN] IP to set + * @param nSubNetMask [IN] Subnet mask + * @param nDefaultGateWay [IN] Default gateway + * @return Success, return MV_OK. Failure, return error code + * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After forced setting, device handle should be created again. This function is only supported by GigEVision camera.\n + If device is in DHCP status, after calling this API to force setting camera network parameter, the device will restart. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIpEx(IN void* handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay); + +/********************************************************************//** + * @~chinese + * @brief IPʽ + * @param handle [IN] 豸 + * @param nType [IN] IPͣMV_IP_CFG_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸IPʽDHCPLLAȣGigEVision豸֧֡ + + * @~english + * @brief IP configuration method + * @param handle [IN] Device handle + * @param nType [IN] IP type, refer to MV_IP_CFG_x + * @return Success, return MV_OK. Failure, return error code + * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetIpConfig(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ýʹijģʽ,type: MV_NET_TRANS_xʱĬʹdriver + * @param handle [IN] 豸 + * @param nType [IN] 紫ģʽMV_NET_TRANS_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿSDKڲʹõģʽĬʹģʽGigEVision豸֧֡ + + * @~english + * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default + * @param handle [IN] Device handle + * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x + * @return Success, return MV_OK. Failure, return error code + * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by GigEVision camera. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetNetTransMode(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ȡ紫Ϣ + * @param handle [IN] 豸 + * @param pstInfo [OUT] Ϣṹ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԻȡ紫ϢѽݴС֡ȣMV_CC_StartGrabbingɼ֮áGigEVision豸֧֡ + + * @~english + * @brief Get net transmission information + * @param handle [IN] Device handle + * @param pstInfo [OUT] Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Get network transmission information through this API, including received data size, number of lost frames. Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by GigEVision Camera. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetNetTransInfo(IN void* handle, MV_NETTRANS_INFO* pstInfo); + +/********************************************************************//** + * @~chinese + * @brief öĻظ + * @param nMode [IN] ظͣĬϹ㲥0-1-㲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻGigEЧ + + * @~english + * @brief Setting the ACK mode of devices Discovery. + * @param nMode [IN] ACK modeDefault-Broadcast,0-Unicast,1-Broadcast. + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is ONLY effective on GigE cameras. \n + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetDiscoveryMode(unsigned int nMode); + +/********************************************************************//** + * @~chinese + * @brief GVSPȡʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ300msΧ>10ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮ȡǰøýӿڿGVSPȡʱʱ䡣GVSPȡʱù̿ͼ쳣ùȡʱ䳤 + + * @~english + * @brief Set GVSP streaming timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 300ms, range: >10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, and just before start streaming, + * call this interface to set GVSP streaming timeout value. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvspTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVSPȡʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVSPȡʱʱ + + * @~english + * @brief Get GVSP streaming timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVSP streaming timeout. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvspTimeout(IN void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief GVCPʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ500msΧ0-10000ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿGVCPʱʱ䡣 + + * @~english + * @brief Set GVCP cammand timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 500ms, range: 0-10000ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set GVCP command timeout time. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvcpTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVCPʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPʱʱ䡣 + + * @~english + * @brief Get GVCP cammand timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVCP timeout. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvcpTimeout(IN void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief شGVCP + * @param handle [IN] 豸 + * @param nRetryGvcpTimes [IN] شΧ0-100 + * @return ɹMV_OK󣬷ش + * @remarks ýӿGVCP쳣ʱشĴһ̶ϿԱ豸ߣΧΪ0-100 + + * @~english + * @brief Set the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param nRetryGvcpTimes [IN] The number of retriesrang0-100 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to increase The Times of retransmission when GVCP packet transmission is abnormal,and to some extent, it can avoid dropping the camera, with a range of 0-100. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetRetryGvcpTimes(IN void* handle, unsigned int nRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشGVCP + * @param handle [IN] 豸 + * @param pnRetryGvcpTimes [OUT] شָ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPشĬ3Ρ + + * @~english + * @brief Get the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param pnRetryGvcpTimes [OUT] The number of retries + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of GVCP retransmissions, which defaults to 3. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetRetryGvcpTimes(IN void* handle, unsigned int* pnRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡѵpacket sizeýӿĿǰֻ֧GigE豸 + * @param handle [IN] 豸 + * @return packetsize + * @remarks ȡѵpacket sizeӦGigEVision豸SCPSӦU3V豸ÿδȡİСôСϴһĴСýӿҪMV_CC_OpenDevice֮MV_CC_StartGrabbing֮ǰá \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get the optimal Packet Size, Only support GigE Camera + * @param handle [IN] Device handle + * @return Optimal packetsize + * @remarks To get optimized packet size, for GigEVision device is SCPS, for USB3Vision device is the size of packet read from drive each time, and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOptimalPacketSize(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief Ƿط֧֣ط + * @param handle [IN] 豸 + * @param bEnable [IN] Ƿ֧ط + * @param nMaxResendPercent [IN] ط + * @param nResendTimeout [IN] طʱʱ + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿطԣGigEVision豸֧֡ + + * @~english + * @brief Set whethe to enable resend, and set resend + * @param handle [IN] Device handle + * @param bEnable [IN] enable resend + * @param nMaxResendPercent [IN] Max resend persent + * @param nResendTimeout [IN] Resend timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera. + ************************************************************************/ +#ifndef __cplusplus +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent, unsigned int nResendTimeout); +#else +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent = 10, unsigned int nResendTimeout = 50); +#endif + +/********************************************************************//** + * @~chinese + * @brief شԴ + * @param handle [IN] 豸 + * @param nRetryTimes [IN] شԴĬ20 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set the max resend retry times + * @param handle [IN] Device handle + * @param nRetryTimes [IN] The max times to retry resending lost packetsdefault 20 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendMaxRetryTimes(void* handle, unsigned int nRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشԴ + * @param handle [IN] 豸 + * @param pnRetryTimes [OUT] شԴ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get the max resend retry times + * @param handle [IN] Device handle + * @param pnRetryTimes [OUT] The max times to retry resending lost packets + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendMaxRetryTimes(void* handle, unsigned int* pnRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ͬһش֮ʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ͬһش֮ʱĬ10ms + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set time interval between same resend requests + * @param handle [IN] Device handle + * @param nMillisec [IN] The time interval between same resend requests,default 10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendTimeInterval(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡͬһش֮ʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ͬһش֮ʱ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get time interval between same resend requests + * @param handle [IN] Device handle + * @param pnMillisec [OUT] The time interval between same resend requests + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendTimeInterval(void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief ôģʽΪģʽ鲥ģʽ + * @param handle [IN] 豸 + * @param stTransmissionType [IN] ģʽṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿôģʽΪ鲥ģʽGigEVision豸֧֡ + + * @~english + * @brief Set transmission type,Unicast or Multicast + * @param handle [IN] Device handle + * @param stTransmissionType [IN] Struct of transmission type + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is only valid for GigEVision camera. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetTransmissionType(void* handle, MV_TRANSMISSION_TYPE * pstTransmissionType); + +/********************************************************************//** + * @~chinese + * @brief + * @param pstActionCmdInfo [IN] Ϣ + * @param pstActionCmdResults [OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks GigEVision豸֧֡ + + * @~english + * @brief Issue Action Command + * @param pstActionCmdInfo [IN] Action Command + * @param pstActionCmdResults [OUT] Action Command Result List + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by GigEVision camera. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults); + +/********************************************************************//** + * @~chinese + * @brief ȡ鲥״̬ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param pbStatus [OUT] 鲥״̬,true:鲥״̬false:鲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿж豸ǰǷ鲥״̬ͻöʱҪ豸ж鲥⡣ + + * @~english + * @brief Get Multicast Status + * @param pstDevInfo [IN] Device Information Structure + * @param pbStatus [OUT] Status of Multicast + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to determine whether the camera is currently in multicast state, and to solve the problem that the client needs to turn on the camera to determine multicast when enumerating. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetMulticastStatus(IN MV_CC_DEVICE_INFO* pstDevInfo, OUT bool* pbStatus); + + +/************************************************************************/ +/* CameraLink 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBaudrate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBaudrate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBaudrates(IN void* handle,unsigned int* pnBaudrateAblity); + +/********************************************************************//** + * @~chinese + * @brief ôڲȴʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ڲĵȴʱ, λΪms + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Sets the timeout for operations on the serial port + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. + * @return Success, return MV_OK. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void* handle, unsigned int nMillisec); + + +/************************************************************************/ +/* U3V 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief U3VĴС + * @param handle [IN] 豸 + * @param nTransferSize [IN] İС, ByteĬΪ1Mrang>=0x10000 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӴСʵȡʱCPUռʡͬPCͲͬUSBչڲͬļԣòùܻȡͼķա + + * @~english + * @brief Set transfer size of U3V device + * @param handle [IN] Device handle + * @param nTransferSize [IN] Transfer sizeBytedefault1Mrang>=0x10000 + * @return Success, return MV_OK. Failure, return error code + * @remarks Increasing the transmission packet size can reduce the CPU utilization at the time of fetching. However, different PCS and different USB extension CARDS have different compatibility, and if this parameter is set too large, there may be the risk of not getting the image. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetTransferSize(IN void* handle, unsigned int nTransferSize); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴС + * @param handle [IN] 豸 + * @param pnTransferSize [OUT] İСָ, Byte + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3VСĬ1M + + * @~english + * @brief Get transfer size of U3V device + * @param handle [IN] Device handle + * @param pnTransferSize [OUT] Transfer sizeByte + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current U3V transfer packet size, default 1M. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetTransferSize(IN void* handle, unsigned int* pnTransferSize); + +/********************************************************************//** + * @~chinese + * @brief U3VĴͨ + * @param handle [IN] 豸 + * @param nTransferWays [IN] ͨΧ1-10 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ûԸPCܡ豸ͼ֡ʡͼСڴʹʵضԸòеڡͬPCͲͬUSBչڲͬļԡ + + * @~english + * @brief Set transfer ways of U3V device + * @param handle [IN] Device handle + * @param nTransferWays [IN] Transfer waysrang1-10 + * @return Success, return MV_OK. Failure, return error code + * @remarks Users can adjust this parameter according to PC performance, camera image frame rate, image size, memory utilization and other factors. But different PCS and different USB expansion CARDS have different compatibility. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetTransferWays(IN void* handle, unsigned int nTransferWays); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴͨ + * @param handle [IN] 豸 + * @param pnTransferWays [OUT] ָͨ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3V첽ȡڵ2000W豸MONO8ĬΪ3YUVΪĬ2RGBΪĬ1Ĭ8ڵ㡣 + + * @~english + * @brief Get transfer ways of U3V device + * @param handle [IN] Device handle + * @param pnTransferWays [OUT] Transfer ways + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of U3V asynchronous feed nodes. For 2000W camera, MONO8 defaults to 3, YUV defaults to 2, RGB defaults to 1, and other cases default to 8 nodes. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetTransferWays(IN void* handle, unsigned int* pnTransferWays); + +/************************************************************************/ +/* GenTLؽӿڣӿڿԸãֽӿڲ֧֣ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͨGenTLöInterfaces + * @param pstIFList [OUT] Interfacesб + * @param strGenTLPath [IN] GenTLctiļ· + * @return ɹMV_OK󣬷ش + * @remarks InterfacesбڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Interfaces with GenTL + * @param pstIFList [OUT] Interfaces List + * @param strGenTLPath [IN] GenTL cti file path + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the Interfaces list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumInterfacesByGenTL(IN OUT MV_GENTL_IF_INFO_LIST* pstIFList, IN const char * strGenTLPath); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL Interfaceö豸 + * @param pstIFInfo [IN] InterfaceϢ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Devices with GenTL interface + * @param pstIFInfo [IN] Interface information + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesByGenTL(IN MV_GENTL_IF_INFO* pstIFInfo, IN OUT MV_GENTL_DEV_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL豸Ϣ豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹָ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣 + + * @~english + * @brief Create Device Handle with GenTL Device Info + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleByGenTL(OUT void ** handle, IN const MV_GENTL_DEV_INFO* pstDevInfo); + + +/************************************************************************/ +/* XML */ +/* XML parse tree generation */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡ豸XML + * @param handle [IN] 豸 + * @param pData [OUT] XMLݽջ + * @param nDataSize [IN] ջС + * @param pnDataLen [OUT] ʵݴС + * @return ɹMV_OK󣬷ش + * @remarks pDataΪNULLnDataSizeʵʵxmlļСʱݣpnDataLenxmlļС\n + pDataΪЧַһ㹻ʱݱڸû棬pnDataLenxmlļʵʴС + + * @~english + * @brief Get camera feature tree XML + * @param handle [IN] Device handle + * @param pData [OUT] XML data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pnDataLen [OUT] Actual data length + * @return Success, return MV_OK. Failure, return error code + * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, returned by pnDataLen XML file size.\n + When pData is a valid cache address and the cache is large enough, copy the full data into the cache, and pnDataLen returns the actual size of the XML file. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, OUT unsigned int* pnDataLen); + +/********************************************************************//** + * @~chinese + * @brief õǰڵķģʽ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penAccessMode [OUT] ڵķģʽ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Get Access mode of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penAccessMode [OUT] Access mode of the node + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeAccessMode(IN void* handle, IN const char * strName, OUT MV_XML_AccessMode *penAccessMode); + +/********************************************************************//** + * @~chinese + * @brief õǰڵ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penInterfaceType [OUT] ڵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڿڵܽӿ֮ǰǰ֪ڵͣûѡʵܽӿڽнڵֵúͻȡ + + * @~english + * @brief Get Interface Type of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penInterfaceType [OUT] Interface Type of the node + * @return Success, return MV_OK. Failure, return error code + * @remarks The interface can know the node type in advance before calling the universal interface, so as to facilitate users to select the appropriate universal interface for setting and obtaining the node value. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeInterfaceType(IN void* handle, IN const char * strName, OUT MV_XML_InterfaceType *penInterfaceType); + +/************************************************************************/ +/* ӽӿ */ +/* Additional interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͼƬ֧BmpJpeg. + * @param handle [IN] 豸 + * @param pstSaveParam [IN][OUT] ͼƬṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתJPEGBMPȸʽָڴУȻûԽתֱ֮ӱͼƬļýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ \n + MV_CC_SaveImageEx2MV_CC_SaveImageExӲhandleΪ˱֤ӿڵͳһ + + * @~english + * @brief Save image, support Bmp and Jpeg. + * @param handle [IN] Device handle + * @param pstSaveParam [IN][OUT] Save image parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Once there is image data, you can call this API to convert the data. \n + You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. \n + Comparing with the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx2(IN void* handle, MV_SAVE_IMAGE_PARAM_EX* pstSaveParam); + +/********************************************************************//** + * @~chinese + * @brief ͼļ + * @param handle [IN] 豸 + * @param pstSaveFileParam [IN][OUT] ͼƬļṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧BMP/JPEG/PNG/TIFF + + * @~english + * @brief Save the image file. + * @param handle [IN] Device handle + * @param pstSaveFileParam [IN][OUT] Save the image file parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support BMP/JPEG/PNG/TIFF. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageToFile(IN void* handle, MV_SAVE_IMG_TO_FILE_PARAM* pstSaveFileParam); + +/********************************************************************//** + * @~chinese + * @brief 3Dݣ֧PLYCSVOBJָʽ + * @param handle [IN] 豸 + * @param pstPointDataParam [IN][OUT] ݲṹ + * @return ɹMV_OK󣬷ش + * @remarks 3Dݸʽ3Dļʽ֧PLY/CSV/OBJ/n + Ŀǰ֧PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,ݲ֧3Dʽ + + * @~english + * @brief Save 3D point data, support PLYCSV and OBJ + * @param handle [IN] Device handle + * @param pstPointDataParam [IN][OUT] Save 3D point data parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Save the 3D data format to 3D file formatsupport PLYCSV and OBJ/n + only support PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,Other 3D format is not supported now. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SavePointCloudData(IN void* handle, MV_SAVE_POINT_CLOUD_PARAM* pstPointDataParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstRotateParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵ90/180/270ת + + * @~english + * @brief Rotate Image + * @param handle [IN] Device handle + * @param pstRotateParam [IN][OUT] Rotate image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support 90/180/270 rotation of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RotateImage(IN void* handle, IN OUT MV_CC_ROTATE_IMAGE_PARAM* pstRotateParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstFlipParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵĴֱˮƽת + + * @~english + * @brief Flip Image + * @param handle [IN] Device handle + * @param pstFlipParam [IN][OUT] Flip image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support vertical and horizontal reverse of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FlipImage(IN void* handle, IN OUT MV_CC_FLIP_IMAGE_PARAM* pstFlipParam); + +/********************************************************************//** + * @~chinese + * @brief ظʽת + * @param handle [IN] 豸 + * @param pstCvtParam [IN][OUT] ظʽתṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתûظʽָڴСýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ豸ǰɼͼJPEGѹĸʽֵ֧øýӿڽת \n + + * @~english + * @brief Pixel format conversion + * @param handle [IN] Device handle + * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. There is no order requirement to call this API, the transformation will execute when there is image data. First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, then call this API to transform the format. \n + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ConvertPixelType(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam); + +/********************************************************************//** + * @~chinese + * @brief òֵ㷨 + * @param handle [IN] 豸 + * @param nBayerCvtQuality [IN] BayerIJֵ 0- 1- 2-ţĬΪţ + * @return ɹMV_OK󣬷ش + * @remarks ڲͼתӿڵıֵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڲʹõIJֵ㷨Ǹýӿ趨ġ + + * @~english + * @brief Interpolation algorithm type setting + * @param handle [IN] Device handle + * @param nBayerCvtQuality [IN] Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + * @return Success, return MV_OK. Failure, return error code + * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, and the interpolation algorithm used in the MV CC ConvertPixelType and MV CC SaveImageEx2 interfaces is set by this interface. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int nBayerCvtQuality); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵGammaֵ + * @param handle [IN] 豸 + * @param fBayerGammaValue [IN] Gammaֵ[0.1,4.0] + * @return ɹMV_OK󣬷ش + * @remarks øֵڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set Gamma value after Bayer interpolation + * @param handle [IN] Device handle + * @param fBayerGammaValue [IN] Gamma value[0.1,4.0] + * @return Success, return MV_OK. Failure, return error code + * @remarks After setting the value, it work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerGammaValue(IN void* handle, IN float fBayerGammaValue); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵɫУʹܺ; + * @param handle [IN] 豸 + * @param pstCCMParam [IN] ɫУṹ + * @return ɹMV_OK󣬷ش + * @remarks ɫУɫУڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set CCM param after Bayer interpolation + * @param handle [IN] Device handle + * @param pstCCMParam [IN] Color correction parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the color correction and set the color correction matrix, It work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCCMParam(IN void* handle, IN MV_CC_CCM_PARAM* pstCCMParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstNoiseEstimateParam [IN][OUT] BayerƲṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Noise estimate of Bayer format + * @param handle [IN] Device handle + * @param pstNoiseEstimateParam [IN][OUT] Noise estimate parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_BayerNoiseEstimate(IN void* handle, IN OUT MV_CC_BAYER_NOISE_ESTIMATE_PARAM* pstNoiseEstimateParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstSpatialDenoiseParam [IN][OUT] Bayerṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Spatial Denoise of Bayer format + * @param handle [IN] Device handle + * @param pstSpatialDenoiseParam [IN][OUT] Spatial Denoise parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_BayerSpatialDenoise(IN void* handle, IN OUT MV_CC_BAYER_SPATIAL_DENOISE_PARAM* pstSpatialDenoiseParam); + +/********************************************************************//** + * @~chinese + * @brief + * @param handle [IN] 豸 + * @param pstDecodeParam [IN][OUT] ṹ + * @return ɹMV_OK󣬷ش + * @remarks ȡѹݣͬʱֽ֧ǰʵʱͼˮӡϢǵǰ߲ʵʱȡģˮӡ쳣 + + * @~english + * @brief High Bandwidth Decode + * @param handle [IN] Device handle + * @param pstDecodeParam [IN][OUT] High Bandwidth Decode parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Decode the lossless compressed data from the camera into raw data + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_HB_Decode(IN void* handle, IN OUT MV_CC_HB_DECODE_PARAM* pstDecodeParam); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Save camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FeatureSave(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Load camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FeatureLoad(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸ȡļ + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Read the file from the camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessRead(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ļд豸 + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Write the file to camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessWrite(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ȡļȡĽ + * @param handle [IN] 豸 + * @param pstFileAccessProgress [IN] + * @return ɹMV_OK󣬷ش ǰļȡ״̬ + + * @~english + * @brief Get File Access Progress + * @param handle [IN] Device handle + * @param pstFileAccessProgress [IN] File access Progress + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFileAccessProgress(IN void* handle, OUT MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress); + +/********************************************************************//** + * @~chinese + * @brief ʼ¼ + * @param handle [IN] 豸 + * @param pstRecordParam [IN] ¼ṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Start Record + * @param handle [IN] Device handle + * @param pstRecordParam [IN] Record param structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam); + +/********************************************************************//** + * @~chinese + * @brief ¼ + * @param handle [IN] 豸 + * @param pstInputFrameInfo [IN] ¼ݽṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Input RAW data to Record + * @param handle [IN] Device handle + * @param pstInputFrameInfo [IN] Record data structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo); + +/********************************************************************//** + * @~chinese + * @brief ֹͣ¼ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Stop Record + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StopRecord(IN void* handle); +#ifdef __cplusplus +} +#endif + +#endif //_MV_CAMERA_CTRL_H_ diff --git a/Cigarette/MVS3.2.1/Include/MvErrorDefine.h b/Cigarette/MVS3.2.1/Include/MvErrorDefine.h new file mode 100644 index 0000000..6ad3d6b --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/MvErrorDefine.h @@ -0,0 +1,105 @@ + +#ifndef _MV_ERROR_DEFINE_H_ +#define _MV_ERROR_DEFINE_H_ + +/********************************************************************/ +/// \~chinese +/// \name ȷ붨 +/// @{ +/// \~english +/// \name Definition of correct code +/// @{ +#define MV_OK 0x00000000 ///< \~chinese ɹ޴ \~english Successed, no error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name ͨô붨:Χ0x80000000-0x800000FF +/// @{ +/// \~english +/// \name Definition of General error code +/// @{ +#define MV_E_HANDLE 0x80000000 ///< \~chinese Чľ \~english Error or invalid handle +#define MV_E_SUPPORT 0x80000001 ///< \~chinese ֵ֧Ĺ \~english Not supported function +#define MV_E_BUFOVER 0x80000002 ///< \~chinese \~english Buffer overflow +#define MV_E_CALLORDER 0x80000003 ///< \~chinese ˳ \~english Function calling order error +#define MV_E_PARAMETER 0x80000004 ///< \~chinese IJ \~english Incorrect parameter +#define MV_E_RESOURCE 0x80000006 ///< \~chinese Դʧ \~english Applying resource failed +#define MV_E_NODATA 0x80000007 ///< \~chinese \~english No data +#define MV_E_PRECONDITION 0x80000008 ///< \~chinese ǰ󣬻лѷ仯 \~english Precondition error, or running environment changed +#define MV_E_VERSION 0x80000009 ///< \~chinese 汾ƥ \~english Version mismatches +#define MV_E_NOENOUGH_BUF 0x8000000A ///< \~chinese ڴռ䲻 \~english Insufficient memory +#define MV_E_ABNORMAL_IMAGE 0x8000000B ///< \~chinese 쳣ͼ񣬿Ƕͼ \~english Abnormal image, maybe incomplete image because of lost packet +#define MV_E_LOAD_LIBRARY 0x8000000C ///< \~chinese ̬DLLʧ \~english Load library failed +#define MV_E_NOOUTBUF 0x8000000D ///< \~chinese ûпĻ \~english No Avaliable Buffer +#define MV_E_ENCRYPT 0x8000000E ///< \~chinese ܴ \~english Encryption error +#define MV_E_UNKNOW 0x800000FF ///< \~chinese δ֪Ĵ \~english Unknown error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name GenICamϵд:Χ0x80000100-0x800001FF +/// @{ +/// \~english +/// \name GenICam Series Error Codes: Range from 0x80000100 to 0x800001FF +/// @{ +#define MV_E_GC_GENERIC 0x80000100 ///< \~chinese ͨô \~english General error +#define MV_E_GC_ARGUMENT 0x80000101 ///< \~chinese Ƿ \~english Illegal parameters +#define MV_E_GC_RANGE 0x80000102 ///< \~chinese ֵΧ \~english The value is out of range +#define MV_E_GC_PROPERTY 0x80000103 ///< \~chinese \~english Property +#define MV_E_GC_RUNTIME 0x80000104 ///< \~chinese л \~english Running environment error +#define MV_E_GC_LOGICAL 0x80000105 ///< \~chinese ߼ \~english Logical error +#define MV_E_GC_ACCESS 0x80000106 ///< \~chinese ڵ \~english Node accessing condition error +#define MV_E_GC_TIMEOUT 0x80000107 ///< \~chinese ʱ \~english Timeout +#define MV_E_GC_DYNAMICCAST 0x80000108 ///< \~chinese ת쳣 \~english Transformation exception +#define MV_E_GC_UNKNOW 0x800001FF ///< \~chinese GenICamδ֪ \~english GenICam unknown error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name GigE_STATUSӦĴ:Χ0x80000200-0x800002FF +/// @{ +/// \~english +/// \name GigE_STATUS Error Codes: Range from 0x80000200 to 0x800002FF +/// @{ +#define MV_E_NOT_IMPLEMENTED 0x80000200 ///< \~chinese 豸֧ \~english The command is not supported by device +#define MV_E_INVALID_ADDRESS 0x80000201 ///< \~chinese ʵĿַ \~english The target address being accessed does not exist +#define MV_E_WRITE_PROTECT 0x80000202 ///< \~chinese Ŀַд \~english The target address is not writable +#define MV_E_ACCESS_DENIED 0x80000203 ///< \~chinese 豸޷Ȩ \~english No permission +#define MV_E_BUSY 0x80000204 ///< \~chinese 豸æϿ \~english Device is busy, or network disconnected +#define MV_E_PACKET 0x80000205 ///< \~chinese ݴ \~english Network data packet error +#define MV_E_NETER 0x80000206 ///< \~chinese ش \~english Network error +#define MV_E_IP_CONFLICT 0x80000221 ///< \~chinese 豸IPͻ \~english Device IP conflict +/// @} + +/********************************************************************/ +/// \~chinese +/// \name USB_STATUSӦĴ:Χ0x80000300-0x800003FF +/// @{ +/// \~english +/// \name USB_STATUS Error Codes: Range from 0x80000300 to 0x800003FF +/// @{ +#define MV_E_USB_READ 0x80000300 ///< \~chinese usb \~english Reading USB error +#define MV_E_USB_WRITE 0x80000301 ///< \~chinese дusb \~english Writing USB error +#define MV_E_USB_DEVICE 0x80000302 ///< \~chinese 豸쳣 \~english Device exception +#define MV_E_USB_GENICAM 0x80000303 ///< \~chinese GenICamش \~english GenICam error +#define MV_E_USB_BANDWIDTH 0x80000304 ///< \~chinese ô \~english Insufficient bandwidth, this error code is newly added +#define MV_E_USB_DRIVER 0x80000305 ///< \~chinese ƥδװ \~english Driver mismatch or unmounted drive +#define MV_E_USB_UNKNOW 0x800003FF ///< \~chinese USBδ֪Ĵ \~english USB unknown error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name ʱӦĴ:Χ0x80000400-0x800004FF +/// @{ +/// \~english +/// \name Upgrade Error Codes: Range from 0x80000400 to 0x800004FF +/// @{ +#define MV_E_UPG_FILE_MISMATCH 0x80000400 ///< \~chinese ̼ƥ \~english Firmware mismatches +#define MV_E_UPG_LANGUSGE_MISMATCH 0x80000401 ///< \~chinese ̼Բƥ \~english Firmware language mismatches +#define MV_E_UPG_CONFLICT 0x80000402 ///< \~chinese ͻ豸Ѿٴش˴ \~english Upgrading conflicted (repeated upgrading requests during device upgrade) +#define MV_E_UPG_INNER_ERR 0x80000403 ///< \~chinese ʱ豸ڲִ \~english Camera internal error during upgrade +#define MV_E_UPG_UNKNOW 0x800004FF ///< \~chinese ʱδ֪ \~english Unknown error during upgrade +/// @} + +#endif //_MV_ERROR_DEFINE_H_ diff --git a/Cigarette/MVS3.2.1/Include/MvObsoleteInterfaces.h b/Cigarette/MVS3.2.1/Include/MvObsoleteInterfaces.h new file mode 100644 index 0000000..c039dc3 --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/MvObsoleteInterfaces.h @@ -0,0 +1,1687 @@ + +#ifndef _MV_OBSOLETE_INTERFACES_H_ +#define _MV_OBSOLETE_INTERFACES_H_ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "ObsoleteCamParams.h" + +/** +* @brief ̬⵼뵼 +* @brief Import and export definition of the dynamic library +*/ +#ifndef MV_CAMCTRL_API + + #if (defined (_WIN32) || defined(WIN64)) + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __declspec(dllexport) + #else + #define MV_CAMCTRL_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MV_CAMCTRL_API + #define MV_CAMCTRL_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* ʹõĽӿ */ +/* Interfaces not recommended */ +/************************************************************************/ +/************************************************************************ + * @fn MV_CC_GetImageInfo + * @brief ȡͼϢ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظйͼϢṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CC_GetImageInfo + * @brief Get basic information of image + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of image basic information + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageInfo(IN void* handle, IN OUT MV_IMAGE_BASIC_INFO* pstInfo); + +/************************************************************************ + * @fn MV_CC_GetTlProxy + * @brief ȡGenICam + * @param handle [IN] ַ + * @return GenICamָ ֵNULL쳣NULL + + * @fn MV_CC_GetTlProxy + * @brief Get GenICam proxy + * @param handle [IN] Handle address + * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL + ************************************************************************/ +MV_CAMCTRL_API void* __stdcall MV_CC_GetTlProxy(IN void* handle); + +/*********************************************************************** + * @fn MV_XML_GetRootNode + * @brief ȡڵ + * @param handle [IN] + * @param pstNode [OUT] ڵϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetRootNode + * @brief Get root node + * @param handle [IN] Handle + * @param pstNode [OUT] Root node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetRootNode(IN void* handle, IN OUT MV_XML_NODE_FEATURE* pstNode); + +/*********************************************************************** + * @fn MV_XML_GetChildren + * @brief xmlлȡָڵӽڵ㣬ڵΪRoot + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstNodesList [OUT] ڵбṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetChildren + * @brief Get all children node of specific node from xml, root node is Root + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstNodesList [OUT] Node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetChildren(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT MV_XML_NODES_LIST* pstNodesList); + +/*********************************************************************** + * @fn MV_XML_GetNodeFeature + * @brief õǰڵ + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstFeature [OUT] ǰڵԽṹ壬 + pstFeature ṹݲο MV_XML_FEATURE_x + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetNodeFeature + * @brief Get current node feature + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstFeature [OUT] Current node feature structure + Details of pstFeature refer to MV_XML_FEATURE_x + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeFeature(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT void* pstFeature); + +/*********************************************************************** + * @fn MV_XML_UpdateNodeFeature + * @brief ½ڵ + * @param handle [IN] + * @param enType [IN] ڵ + * @param pstFeature [OUT] ǰڵԽṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_UpdateNodeFeature + * @brief Update node + * @param handle [IN] Handle + * @param enType [IN] Node type + * @param pstFeature [OUT] Current node feature structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_UpdateNodeFeature(IN void* handle, IN enum MV_XML_InterfaceType enType, IN void* pstFeature); + +// нڵҪʱĻص +// MV_XML_UpdateNodeFeatureӿڸ½ڵʱעĻصcbUpdatepstNodesListз֮Ľڵ +/*********************************************************************** + * @fn MV_XML_RegisterUpdateCallBack + * @brief ע»ص + * @param handle [IN] + * @param cbUpdate [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_RegisterUpdateCallBack + * @brief Register update callback + * @param handle [IN] Handle + * @param cbUpdate [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_RegisterUpdateCallBack(IN void* handle, + IN void(__stdcall* cbUpdate)(enum MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser), + IN void* pUser); + +/************************************************************************/ +/* õĽӿڣڸŻĽӿڿ滻 */ +/* Abandoned interface */ +/************************************************************************/ +/*********************************************************************** + * @fn MV_CC_GetOneFrame + * @brief ȡһ֡ͼ񣬴˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrame + * @brief Get one frame data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrame(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_GetOneFrameEx + * @brief ȡһ֡trunckݣ˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrameEx + * @brief Get one frame of trunck data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameEx(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_RegisterImageCallBack + * @brief עͼݻصýӿã MV_CC_RegisterImageCallBackExӿڣ + * @param handle [IN] + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_RegisterImageCallBack + * @brief Register image data callback (This interface is abandoned, it is recommended to use the MV_CC_RegisterImageCallBackEx) + * @param handle [IN] Handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBack(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser), + void* pUser); + +/************************************************************************ + * @fn MV_CC_SaveImage + * @brief ͼƬýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImage + * @brief Save image (This interface is abandoned, it is recommended to use the MV_CC_SaveImageEx) + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Input data pixel format + nWidth; // [IN] Width + nHeight; // [IN] Height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Provided output buffer size + enImageType; // [IN] Output image type + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM* pSaveParam); + +/************************************************************************ + * @fn MV_CC_SaveImageEx + * @brief ͼƬ֧BmpJpeg.50-99֮ǰ ýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + nJpgQuality; // [IN] , (50-99] + nReserved[4]; + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImageEx + * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Pixel format of input data + nWidth; // [IN] Image width + nHeight; // [IN] Image height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Output buffer size provided + enImageType; // [IN] Output image format + nJpgQuality; // [IN] Encoding quality, (50-99] + nReserved[4]; + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX* pSaveParam); + +/************************************************************************ + * @fn MV_GIGE_ForceIp + * @brief ǿIPýӿã MV_GIGE_ForceIpExӿڣ + * @param handle豸 + * @param nIP [IN] õIP + * @return ش + + * @fn MV_GIGE_ForceIp + * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) + * @param handle Handle + * @param nIP [IN] IP to set + * @return Refer to error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIp(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CC_RegisterEventCallBack + * @brief ע¼صýӿã MV_CC_RegisterEventCallBackExӿڣ + * @param handle豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ش + + * @fn MV_CC_RegisterEventCallBack + * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the MV_CC_RegisterEventCallBackEx interface) + * @param handle豸 + * @param cbEvent [IN] event callback pointer + * @param pUser [IN] User defined value + * @return ش +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBack(void* handle, void(__stdcall* cbEvent)(unsigned int nExternalEventId, void* pUser), void* pUser); + +/*********************************************************************** + * @fn MV_CC_Display + * @brief ʾͼעʾڣڲԶʾMV_CC_GetImageBufferͬʱʹãMV_CC_DisplayOneFrameӿڣ + * @param handle [IN] + * @param hWnd [IN] ʾھ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_Display + * @brief Display one frame image, register display window, automatic display internally + * @param handle [IN] Handle + * @param hWnd [IN] Display Window Handle + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_Display(IN void* handle, void* hWnd); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief ȡIntegerֵMV_CC_GetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйԽṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief Get Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to get width + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE *pIntValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief IntegerֵMV_CC_SetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief Set Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to set width + * const unsigned int nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + + +/************************************************************************/ +/* ȡãģнӿѷʹܽӿڴ */ +/* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ +/************************************************************************/ +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȵϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰĿֵ + * unsigned int nMax; // ʾõĿֵ + * unsigned int nMin; // ʾСõĿֵ + * unsigned int nInc; // ʾõĿnIncıЧ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image width + * @param void* handle [IN] Camera Handle + * MVCC_INTVALUE* pstValue [IN][OUT] Returns the information structure pointer about the camera's width for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // Represents the current width value of the camera + * unsigned int nMax; // Indicates the maximum settable width value allowed by the camera + * unsigned int nMin; // Indicates the minimum settable width value allowed by the camera + * unsigned int nInc; // Indicates that the width increment set by the camera must be a multiple of nInc, otherwise it is invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other Integer structure parameters interface can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); +* @brief ͼ +* @param void* handle [IN] +* const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ +* @return ɹ,MV_OK,ȽΪӦֵʧ,ش + +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + * @brief Set image width + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] To set the value of the camera width, note that the width value must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface + * @return Success, return MV_OK, and the camera width will change to the corresponding value. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ߶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظй߶ȵϢṹָ + * @return ɹ,MV_OK,߶ϢصṹУʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image height + * @param void* handle [IN] Camera handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera height to user + * @return Success, return MV_OK, and return height information to the structure. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief ͼ߶ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ + * @return ɹ,MV_OK,߶ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief Set image height + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera height value to set, note that this value must be times of nInc of pstValue returned by MV_CC_GetWidth + * @return Success, return MV_OK, and the camera height will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼXƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйXƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image X offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera X offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief Set image X offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera X offset value to set + * @return Success, return MV_OK, and the camera X offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼYƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйYƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image Y offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera Y offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + * @brief Set image Y offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera Y offset value to set + * @return Success, return MV_OK, and the camera Y offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure lower limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure lower to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure lower limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure lower to set + * @return Success, return MV_OK, and the camera exposure time lower limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure upper limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure upper to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure upper limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure upper to set + * @return Success, return MV_OK, and the camera exposure time upper limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡֵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get brightness + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera brightness to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief ֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief Set brightness + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Brightness upper to set + * @return Success, return MV_OK, and the camera brightness value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ֡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظй֡ʵϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Frame Rate + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera frame rate to user + * The meaning of returns pstValue structure + * float fCurValue; // Indicates the current frame rate of the camera + * float fMax; // Indicates the maximum frame rate allowed by the camera + * float fMin; // Indicates the minimum frame rate allowed by the camera + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief Set frame rate + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Camera frame rate to set + * @return Success, return MV_OK, and camera frame rate will be changed to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gain + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to gain to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current gain + * float fMax; // The maximum gain camera allowed + * float fMin; // The minimum gain camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief Set Gain + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Gain value to set + * @return Success, return MV_OK, and the camera gain value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡعʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйعʱϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get exposure time + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to exposure time to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current exposure time + * float fMax; // The maximum exposure time camera allowed + * float fMin; // The minimum exposure time camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief عʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief Set exposure time + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Exposure time to set + * @return Success, return MV_OK, and the camera exposure time value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡظʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйظʽϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰظʽö,˵PixelType_Gvsp_Mono8, õֵ,ֵPixelType.hMvGvspPixelTypeö + * unsigned int nSupportedNum; // ֵ֧ظʽĸ + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // ֵ֧ظʽӦֵбҪظʽʱеһ֣Ч + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + öͲӿڿɲմ˽ӿڣйӦöͶӦֵPixelType.h CameraParams.hӦĶ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Pixel Format + * @param void* handle [IN] Camera Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Returns the information structure pointer about pixel format for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // The current pixel format of the camera, is the enumeration type, such as PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to MvGvspPixelType enumeration type in PixelType.h + * unsigned int nSupportedNum; // Number of pixel formats supported by the camera + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this list, otherwise invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Other interface of Enumeration structure parameters can refer to this interface, look for the corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõظʽӦֵô˽ӿʱֱдöֵMV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return ɹ,MV_OK,ظʽΪӦֵʧ,ش + * + * ҪõöͱGetӿڷصnSupportValue[MV_MAX_XML_SYMBOLIC_NUM]еһ֣ʧ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief Set Pixel Format + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] The corresponding integer value for pixel format to be set, when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return Success, return MV_OK, and the camera pixel format will change to the corresponding value. Failure, return error code + * + * Other interface of Enumeration structure parameters can refer to this interface, the enumeration type to be set must be one of the nSupportValue [MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it will fail + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡɼģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйزɼģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_ACQUISITION_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get acquisition mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of acquisition mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_ACQUISITION_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõIJɼģʽӦֵ + * @return ɹ,MV_OK,ɼģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief Set acquisition mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to acquisition mode + * @return Success, return MV_OK, and the camera acquisition mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAIN_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get gain mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gain mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAIN_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief ģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief Set gain mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gain mode + * @return Success, return MV_OK, and the camera gain mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶعģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶعģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_EXPOSURE_AUTO_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get auto exposure mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto exposure mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_EXPOSURE_AUTO_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Զعģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶعģʽӦֵ + * @return ɹ,MV_OK,ԶعģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Set auto exposure mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto exposure mode + * @return Success, return MV_OK, and the camera auto exposure mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief ôģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger mode + * @return Success, return MV_OK, and the camera trigger mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйʱϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get tigger delay + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of trigger delay + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief ôʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõʱ + * @return ɹ,MV_OK,ʱΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief Set tigger delay + * @param void* handle [IN] Handle + * const float fValue [IN] Trigger delay to set + * @return Success, return MV_OK, and the camera trigger delay will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԴ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشԴϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_SOURCE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger source + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger source + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief ôԴ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴԴӦֵ + * @return ɹ,MV_OK,ԴΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger source + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger source + * @return Success, return MV_OK, and the camera trigger source will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief һΣӿڽѡĴԴΪʱЧ + * @param void* handle [IN] + * @return ɹ,MV_OK, ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) + * @param void* handle [IN] Handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡGamma + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйGamma͵Ϣṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAMMA_SELECTOR + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Gamma mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gamma mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Gamma + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõGammaͶӦֵ + * @return ɹ,MV_OK,GammaͽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Set Gamma mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gamma mode + * @return Success, return MV_OK, and the camera gamma mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡGammaֵ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйGammaֵϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gamma value + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of gamma value + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Gammaֵ + * @param void* handle [IN] + * const float fValue [IN] ҪõGammaֵ + * @return ɹ,MV_OK,GammaֵΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Set Gamma value + * @param void* handle [IN] Handle + * const float fValue [IN] Gamma value to set + * @return Success, return MV_OK, and the camera gamma value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get sharpness + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of sharpness + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief Set sharpness + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Sharpness to set + * @return Success, return MV_OK, and the camera sharpness will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡҶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйҶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Hue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Hue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief ûҶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĻҶ + * @return ɹ,MV_OK,ҶȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief Set Hue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Hue to set + * @return Success, return MV_OK, and the camera Hue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Saturation + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Saturation + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief ñͶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõıͶ + * @return ɹ,MV_OK,ͶȽΪӦֵʧ,ش + +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief Set Saturation + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Saturation to set + * @return Success, return MV_OK, and the camera Saturation will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶƽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶƽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_BALANCEWHITE_AUTO + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Auto white balance + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto white balance + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Զƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶƽӦֵ + * @return ɹ,MV_OK,Զƽ⽫ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Set Auto white balance + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto white balance + * @return Success, return MV_OK, and the camera auto white balance will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance red + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance red + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ 콫ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance red + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance red to set + * @return Success, return MV_OK, and the camera white balance red will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ̽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance green + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance green + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ̽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance green + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance green to set + * @return Success, return MV_OK, and the camera white balance green will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance blue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance blue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance blue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance blue to set + * @return Success, return MV_OK, and the camera white balance blue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡˮӡϢڰϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйˮӡϢڰϢͽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get information type included by frame stamp + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of information type included by frame stamp + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief ˮӡϢڰϢ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõˮӡϢڰϢ + * @return ɹ,MV_OK,ˮӡϢڰϢͻΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief Set information type included by frame stamp + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Information type included by frame stamp to set + * @return Success, return MV_OK, and the camera information type included by frame stamp will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief ȡ豸Զ + * @param void* handle [IN] + * MVCC_STRINGVALUE* pstValue [IN OUT] ظйֽṹָ + * @return ɹ,MV_OK,һȡԶ֣ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief Get device user defined name + * @param void* handle [IN] Handle + * MVCC_STRINGVALUE* pstValue [IN OUT] Structure pointer of device name + * @return Success, return MV_OK, and get the camera user defined name. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief 豸Զ + * @param void* handle [IN] + * IN const char* chValue [IN] 豸 + * @return ɹ,MV_OK,豸Զ֣ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief Set device user defined name + * @param void* handle [IN] Handle + * IN const char* chValue [IN] Device name + * @return Success, return MV_OK, and set the camera user defined name. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡһδ֡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйһδ֡ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get frame number trigger by once + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of frame number trigger by once + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief һδ֡ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõһδ֡ + * @return ɹ,MV_OK,һδ֡ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief Set frame number trigger by once + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Frame number trigger by once to set + * @return Success, return MV_OK, and the camera frame number trigger by once will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƵṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get line rate + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of line rate + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Ƶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõƵ + * @return ɹ,MV_OK,ƵΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Set line rate + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Line rate to set + * @return Success, return MV_OK, and the camera line rate will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get heartbeat information + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of heartbeat information + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Ϣ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõϢ + * @return ɹ,MV_OK,ϢΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Set heartbeat information + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Heartbeat information to set + * @return Success, return MV_OK, and the camera heartbeat information will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡС + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйСṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet size + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet size + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief С + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõС + * @return ɹ,MV_OK,СΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet size + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet size to set + * @return Success, return MV_OK, and change packet size to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͼṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet sending delay + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet sending delay + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief ͼ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõͼ + * @return ɹ,MV_OK,ͼΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet sending delay + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet delay to set + * @return Success, return MV_OK, and change packet delay to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief ȡնIPַ0xa9fe0102 ʾ 169.254.1.2 + * @param void* handle [IN] + * @param unsigned int* pnIP [IN][OUT] ظ߽նIPַ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 + * @param void* handle [IN] Handle + * @param unsigned int* pnIP [IN][OUT] Receiver IP address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief ýնIPַ + * @param void* handle [IN] + * unsigned int nIP [IN] ҪõĽնIPַ + * @return ɹ,MV_OK,նIPַΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief Set receiver IP address + * @param void* handle [IN] Handel + * unsigned int nIP [IN] Receiver IP address to set + * @return Success, return MV_OK, and change receiver IP address to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief ȡͶ˵Ķ˿ں + * @param void* handle [IN] + * @param unsigned int* pnPort [IN][OUT] ظ߷Ͷ˵Ķ˿ں + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief Get transmitter port number + * @param void* handle [IN] Handle + * @param unsigned int* pnPort [IN][OUT] Transmitter port number + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief ÷Ͷ˵Ķ˿ں + * @param void* handle [IN] + * unsigned int nPort [IN] ҪõķͶ˵Ķ˿ں + * @return ɹ,MV_OK,Ͷ˵Ķ˿ںŻΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief Set transmitter port number + * @param void* handle [IN] Handle + * unsigned int nPort [IN] Transmitter port number to set + * @return Success, return MV_OK, and change transmitter port number to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_SetDeviceBaudrateӿڣ + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_SetDeviceBaudrate) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetDeviceBaudrateӿڣ + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetDeviceBaudrate) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBauderate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetSupportBaudratesӿڣ + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetSupportBaudrates) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBauderates(IN void* handle,unsigned int* pnBaudrateAblity); + +#ifdef __cplusplus +} +#endif + +#endif //_MV_OBSOLETE_INTERFACES_H_ diff --git a/Cigarette/MVS3.2.1/Include/MvSdkExport.h b/Cigarette/MVS3.2.1/Include/MvSdkExport.h new file mode 100644 index 0000000..2bfc02d --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/MvSdkExport.h @@ -0,0 +1,3630 @@ +#ifndef _MV_SDK_EXPORT_H__ +#define _MV_SDK_EXPORT_H__ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "ObsoleteCamParams.h" + +#ifndef MVSDKEXPORT_API + + #ifdef _WIN32 + #if defined(MVSDKEXPORT_EXPORTS) + #define MVSDKEXPORT_API __declspec(dllexport) + #else + #define MVSDKEXPORT_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MVSDKEXPORT_API + #define MVSDKEXPORT_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* 豸ĻָͲ */ +/* Camera basic instructions and operations */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡSDK汾 + * @return 4ֽڰ汾 + | | | | | + 8bits 8bits 8bits 8bits + * @remarks 緵ֵΪ0x01000001SDK汾ΪV1.0.0.1 + + * @~english + * @brief Get SDK Version + * @return Always return 4 Bytes of version number + |Main |Sub |Rev | Test| + 8bits 8bits 8bits 8bits + * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. + ************************************************************************/ +MVSDKEXPORT_API unsigned int __stdcall MV_CC_GetSDKVersion(); + +/********************************************************************//** + * @~chinese + * @brief ȡֵ֧Ĵ + * @return ֵ֧Ĵ + + * @~english + * @brief Get supported Transport Layer + * @return Supported Transport Layer number + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumerateTls(); + +/********************************************************************//** + * @~chinese + * @brief ö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Device + * @param nTLayerType [IN] Enumerate TLs + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumDevices(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ݳö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @param strManufacturerName [IN] + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate device according to manufacture name + * @param nTLayerType [IN] Transmission layer of enumeration + * @param pstDevList [OUT] Device list + * @param strManufacturerName [IN] Manufacture Name + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName); + +/********************************************************************//** + * @~chinese + * @brief 豸Ƿɴ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param nAccessMode [IN] Ȩ + * @return ɴtrueɴfalse + * @remarks ȡ豸CCPĴֵжϵǰ״̬ǷijַȨޡ \n + 豸֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableWithKeyģʽӿڷfalseĿǰ豸֧3ռģʽij̵豸Ҳݲ֧3ģʽ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Is the device accessible + * @param pstDevInfo [IN] Device Information Structure + * @param nAccessMode [IN] Access Right + * @return Access, return true. Not access, return false + * @remarks Read device CCP register value and determine current access permission.\n + Return false if the device does not support the modes MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MVSDKEXPORT_API bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandleWithoutLog + + * @~english + * @brief Create Device Handle + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will be created by default. Creating handle through MV_CC_CreateHandleWithoutLog will not generate log files. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CreateHandle(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸־ + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandle־ļԶɡ + + * @~english + * @brief Create Device Handle without log + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CreateHandleWithoutLog(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Destroy Device Handle + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_DestroyHandle(IN void * handle); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nAccessMode [IN] Ȩ + * @param nSwitchoverKey [IN] лȨʱԿ + * @return ɹMV_OK󣬷ش + * @remarks õ豸ҵӦ豸豸\n + ýӿʱɲnAccessModenSwitchoverKeyʱĬ豸ģʽΪռȨޡĿǰ豸ݲ֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableMV_ACCESS_ControlSwitchEnableWithKeyռģʽ\n + U3V豸nAccessModenSwitchoverKeyЧ + + * @~english + * @brief Open Device + * @param handle [IN] Device handle + * @param nAccessMode [IN] Access Right + * @param nSwitchoverKey [IN] Switch key of access right + * @return Success, return MV_OK. Failure, return error code + * @remarks Find specific device and connect according to set device parameters. \n + When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access mode is exclusive. Currently the device does not support the following preemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.\n + For USB3Vision device, nAccessMode, nSwitchoverKey are invalid. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey); + +/********************************************************************//** + * @~chinese + * @brief ر豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ͨMV_CC_OpenDevice豸󣬿ͨýӿڶϿ豸ӣͷԴ + + * @~english + * @brief Close Device + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CloseDevice(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ж豸Ƿ״̬ + * @param handle [IN] 豸 + * @return 豸״̬trueûӻʧȥӣfalse + + * @~english + * @brief Is The Device Connected + * @param handle [IN] Device handle + * @return Connected, return true. Not Connected or DIsconnected, return false + ***********************************************************************/ +MVSDKEXPORT_API bool __stdcall MV_CC_IsDeviceConnected(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief עͼݻص + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackExͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetOneFrameTimeoutȡָظʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register the image callback function + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.\n + There are two available image data acquisition modes, and cannot be used together: \n + Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBackEx(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصRGB + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForRGBRGB24ʽͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForRGBȡRGB24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, RGB + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB repeatedly in application layer to get frame data with RGB24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBackForRGB(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصBGR + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá\n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForBGRBGR24ͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForBGRȡBGR24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, BGR + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.\n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBackForBGR(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief ʼȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Start Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StartGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ֹͣȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Stop Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StopGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡RGBݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתRGB24ʽأû򷵻ش롣ΪͼתRGB24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡\n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of RGB data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Each time the API is called, the internal cache is checked for data. If there is data, it will be transformed as RGB24 format for return, if there is no data, return error code. As time-consuming exists when transform the image to RGB24 format, this API may cause frame loss when the data frame rate is too high. \n + Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡BGRݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתBGR24ʽأû򷵻ش롣ΪͼתBGR24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡ \n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of BGR data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ʹڲȡһ֡ͼƬMV_CC_Displayͬʱʹã + * @param handle [IN] 豸 + * @param pstFrame [OUT] ͼݺͼϢ + * @param nMsec [IN] ȴʱʱ䣬INFINITEʱʾ޵ȴֱյһ֡ݻֹͣȡ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ \n + ýӿMV_CC_FreeImageBufferʹãȡݺҪMV_CC_FreeImageBufferӿڽpFrameڵָȨ޽ͷš \n + ýӿMV_CC_GetOneFrameTimeoutȣŸߵЧʡȡķsdkڲԶģMV_CC_GetOneFrameTimeoutӿҪͻз䡣\n + ýӿڵMV_CC_Display޷ȡ \n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get a frame of an image using an internal cache + * @param handle [IN] Device handle + * @param pstFrame [OUT] Image data and image information + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API support setting timeout, and SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. \n + This interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. \n + This API cannot be called to stream after calling MV_CC_Display. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. \n + **********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageBuffer(IN void* handle, OUT MV_FRAME_OUT* pstFrame, IN int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ͷͼ񻺴(˽ӿͷŲʹõͼ񻺴棬MV_CC_GetImageBufferʹ) + * @param handle [IN] 豸 + * @param pstFrame [IN] ͼݺͼ + * @return ɹMV_OK󣬷ش + * @remarks ýӿMV_CC_GetImageBufferʹãʹMV_CC_GetImageBufferӿȡͼpFrameҪMV_CC_FreeImageBufferӿڽȨͷš \n + ýӿڶȡЧʸGetOneFrameTimeoutӿڣGetImageBufferڲFree£֧ĽڵSetImageNodeӿõĽڵȣĬϽڵ1\n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) + * @param handle [IN] Device handle + * @param pstFrame [IN] Image data and image information + * @return Success, return MV_OK. Failure, return error code + * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to get image data pFrame, you should call MV_CC_FreeImageBuffer to release the permission. \n + Compared with API MV_CC_GetOneFrameTimeout, this API has higher efficiency of image acquisition. The max. number of nodes can be outputted is same as the "nNum" of API MV_CC_SetImageNodeNum, default value is 1. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. + **********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pstFrame); + +/********************************************************************//** + * @~chinese + * @brief óʱƻȡһ֡ͼƬSDKڲȴֱʱ + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ\n + ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API supports setting timeout, SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + Both the USB3Vision and GIGE camera can support this API. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOneFrameTimeout(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡݻ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿûڲֹͣȡʱ򣬾вҪͼ\n + ýӿģʽдģʽ󣬿ʷݡ + + * @~english + * @brief if Image buffers has retrieved the dataClear them + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface allows user to clear the unnecessary images from the buffer memory without stopping acquisition. \n + This interface allows user to clear previous data after switching from continuous mode to trigger mode. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_ClearImageBuffer(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ʾһ֡ͼ + * @param handle [IN] 豸 + * @param pstDisplayInfo [IN] ͼϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Display one frame image + * @param handle [IN] Device handle + * @param pstDisplayInfo [IN] Frame Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is valid for USB3Vision camera and GIGE camera. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pstDisplayInfo); + +/********************************************************************//** + * @~chinese + * @brief SDKڲͼ񻺴ڵڵ1ץͼǰ + * @param handle [IN] 豸 + * @param nNum [IN] ڵ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڿSDKڲͼ񻺴ڵڵMV_CC_StartGrabbingʼץͼǰá\n + SDKĬ1ڵ㡣\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture + * @param handle [IN] Device handle + * @param nNum [IN] Image Node Number + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface to set the number of SDK internal image buffer nodes. The interface should be called before calling MV_CC_StartGrabbing for capturing. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetImageNodeNum(IN void* handle, unsigned int nNum); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param enGrabStrategy [IN] öֵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶȡԣûԸʵѡ񡣾£ + -OneByOne:Ӿɵһ֡һ֡Ĵблȡͼ񣬴豸ĬΪò + -LatestImagesOnly:блȡµһ֡ͼͬʱб + -LatestImages:блȡµOutputQueueSize֡ͼOutputQueueSizeΧΪ1-ImageNodeNumMV_CC_SetOutputQueueSizeӿãImageNodeNumĬΪ1MV_CC_SetImageNodeNumӿ OutputQueueSizeó1ͬLatestImagesOnlyԣOutputQueueSizeóImageNodeNumͬOneByOne + -UpcomingImage:ڵȡӿʱбͼ񣬲ȴ豸ɵһ֡ͼ񡣸òֻ֧GigE豸֧U3V豸 + + * @~english + * @brief Set Grab Strategy + * @param handle [IN] Device handle + * @param enGrabStrategy [IN] The value of Grab Strategy + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is set by four image acquisition approaches, the user may choose one as needed. Specific details are as followed: + -OneByOne:Obtain image from output cache list frame by frame in order, this function is default strategy when device is on. + -LatestImagesOnly:Obtain the latest image from output cache list only, meanwhile clear output cache list. + -LatestImages:Obtain the latest OutputQueueSize image from output cache list, the range of OutputQueueSize is 1-ImageNodeNum, the user may set the value of MV_CC_SetOutputQueueSizeinterface,the default value of ImageNodeNum is 1,If the user usesMV_CC_SetImageNodeNuminterface to set up OutputQueueSize,when the value of OutputQueueSize is set to be 1, the function will be same as LatestImagesOnly; if the value of OutputQueueSize is set to be ImageNodeNum, the function will be same as OneByOne. + -UpcomingImage:Ignore all images in output cache list when calling image acuiqisiotn interface, wait the next upcoming image generated. Support for GigE camera only, not support for U3V camera. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGrabStrategy(IN void* handle, IN MV_GRAB_STRATEGY enGrabStrategy); + +/********************************************************************//** + * @~chinese + * @brief ֻMV_GrabStrategy_LatestImages²ЧΧ1-ImageNodeNum + * @param handle [IN] 豸 + * @param nOutputQueueSize [IN] + * @return ɹMV_OK󣬷ش + * @remarks ýӿLatestImagesȡ׵ãLatestImagesͼĸȡж̬ + + * @~english + * @brief Set The Size of Output Queue(Only work under the strategy of MV_GrabStrategy_LatestImagesrang1-ImageNodeNum) + * @param handle [IN] Device handle + * @param nOutputQueueSize [IN] The Size of Output Queue + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface must be used with LatestImages Grab strategy, it is used for setting the maximum allowance queue size of the image under the LatestImages strategy. The user may change the output queue size while grabbing images. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetOutputQueueSize(IN void* handle, IN unsigned int nOutputQueueSize); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸Ϣȡ֮ǰ + * @param handle [IN] 豸 + * @param pstDevInfo [IN][OUT] ظй豸Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ֧ûڴ豸ȡ豸Ϣ\n + 豸GigE豸øýӿڴգ˲ȡеøýӿڡ + + * @~english + * @brief Get device information + * @param handle [IN] Device handle + * @param pstDevInfo [IN][OUT] Structure pointer of device information + * @return Success, return MV_OK. Failure, return error code + * @remarks The API support users to access device information after opening the device. \n + If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not recommended to call the interface during the fetching process. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief ȡ͵Ϣ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظй豸͵Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӿҪȡϢָͣMV_ALL_MATCH_INFOṹеnTypeͣȡӦϢMV_ALL_MATCH_INFOṹpInfoﷵأ \n + ýӿڵĵǰȡȡϢͣȡGigE豸MV_MATCH_TYPE_NET_DETECTϢڿץͼ֮ãȡU3V豸MV_MATCH_TYPE_USB_DETECTϢڴ豸֮á \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get various type of information + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of various type of information + * @return Success, return MV_OK. Failure, return error code + * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO). \n + The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo); + + +/************************************************************************/ +/* úͻȡ豸ܽӿ */ +/* General interface for getting and setting camera parameters */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡIntegerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param pstIntValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to get width + * @param pstIntValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE_EX *pstIntValue); + +/********************************************************************//** + * @~chinese + * @brief Integerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to set width + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue); + +/********************************************************************//** + * @~chinese + * @brief ȡEnumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param pstEnumValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel format + * @param pstEnumValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetEnumValue(IN void* handle,IN const char* strKey,OUT MVCC_ENUMVALUE *pstEnumValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetEnumValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param strValue [IN] Ҫõ豸ַ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param strValue [IN] Feature String to set + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API after connecting the device. All the values of nodes with IEnumeration type can be set via this API. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetEnumValueByString(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief ȡFloatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstFloatValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstFloatValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFloatValue(IN void* handle,IN const char* strKey,OUT MVCC_FLOATVALUE *pstFloatValue); + +/********************************************************************//** + * @~chinese + * @brief floatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param fValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param fValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetFloatValue(IN void* handle,IN const char* strKey,IN float fValue); + +/********************************************************************//** + * @~chinese + * @brief ȡBooleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pbValue [IN][OUT] ظй豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pbValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBoolValue(IN void* handle,IN const char* strKey,OUT bool *pbValue); + +/********************************************************************//** + * @~chinese + * @brief Booleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param bValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param bValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBoolValue(IN void* handle,IN const char* strKey,IN bool bValue); + +/********************************************************************//** + * @~chinese + * @brief ȡStringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstStringValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstStringValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetStringValue(IN void* handle,IN const char* strKey,OUT MVCC_STRINGVALUE *pstStringValue); + +/********************************************************************//** + * @~chinese + * @brief Stringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param strValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param strValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetStringValue(IN void* handle,IN const char* strKey,IN const char * strValue); + +/********************************************************************//** + * @~chinese + * @brief Commandֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿָCommandͽڵ㡣strKeyȡֵԲοXMLڵбΪICommandĽڵ㶼ͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Send Command + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Command nodes. For value of strKey, see MvCameraNode. The node values of ICommand can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetCommandValue(IN void* handle,IN const char* strKey); + +/********************************************************************//** + * @~chinese + * @brief GenICamڵ㻺 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Invalidate GenICam Nodes + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_InvalidateNodes(IN void* handle); + + +/************************************************************************/ +/* 豸 Ĵд 쳣¼ص */ +/* Device upgrade, register read and write and exception callback */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFilePathName [IN] ļ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԽ̼ļ͸豸ýӿҪȴ̼ļɹ豸֮ٷأӦʱܽϳ + + * @~english + * @brief Device Local Upgrade + * @param handle [IN] Device handle + * @param strFilePathName [IN] File name + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to send the upgrade firmware to the device for upgrade. This API will wait for return until the upgrade firmware is sent to the device, this response may take a long time. \n + For CameraLink device, it keeps sending upgrade firmware continuously. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_LocalUpgrade(IN void* handle, const void *strFilePathName); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param pnProcess [OUT] Ƚյַ + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Get Upgrade Progress + * @param handle [IN] Device handle + * @param pnProcess [OUT] Progress receiving address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetUpgradeProcess(IN void* handle, unsigned int* pnProcess); + +/********************************************************************//** + * @~chinese + * @brief ڴ + * @param handle [IN] 豸 + * @param pBuffer [IN][OUT] ΪֵʹãڴֵGEV豸ڴֵǰմģʽ洢ģЭ豸С˴洢 + * @param nAddress [IN] ȡڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] ȡڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸ȡijμĴݡ + + * @~english + * @brief Read Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( Memory value is stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be read, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be read + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, read the data from certain register. +*************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_ReadMemory(IN void* handle , void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief дڴ + * @param handle [IN] 豸 + * @param pBuffer [IN] дڴֵעGEV豸ڴֵҪմģʽ洢Э豸С˴洢 + * @param nAddress [IN] дڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] дڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸һдijμĴ + + * @~english + * @brief Write Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN] Memory value to be written ( Note the memory value to be stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be written, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be written + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, write a piece of data into a certain segment of register. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_WriteMemory(IN void* handle , const void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief ע쳣Ϣصڴ豸֮ + * @param handle [IN] 豸 + * @param cbException [IN] 쳣صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿҪMV_CC_OpenDevice豸֮á豸쳣ϿӺڻصȡ쳣ϢGigE豸֮ҪȵMV_CC_CloseDeviceӿڹر豸ٵMV_CC_OpenDeviceӿ´豸 + + * @~english + * @brief Register Exception Message CallBack, call after open device + * @param handle [IN] Device handle + * @param cbException [IN] Exception Message CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterExceptionCallBack(IN void* handle, + void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עȫ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterAllEventCallBack(void* handle, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עᵥ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param strEventName [IN] ¼ + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ\n + ýӿڲ֧CameraLink豸֧"豸"һ¼ + + * @~english + * @brief Register single event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param strEventName [IN] Event name + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device . +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterEventCallBackEx(void* handle, const char* strEventName, + void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + + +/************************************************************************/ +/* GigEVision 豸еĽӿ */ +/* GigEVision device specific interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ǿIP + * @param handle [IN] 豸 + * @param nIP [IN] õIP + * @param nSubNetMask [IN] + * @param nDefaultGateWay [IN] Ĭ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ǿ豸IP롢Ĭأǿ֮Ҫ´豸GigEVision豸֧֡\n + 豸ΪDHCP״̬øýӿǿ豸֮豸 + + * @~english + * @brief Force IP + * @param handle [IN] Device handle + * @param nIP [IN] IP to set + * @param nSubNetMask [IN] Subnet mask + * @param nDefaultGateWay [IN] Default gateway + * @return Success, return MV_OK. Failure, return error code + * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After forced setting, device handle should be created again. This function is only supported by GigEVision camera.\n + If device is in DHCP status, after calling this API to force setting camera network parameter, the device will restart. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_ForceIpEx(IN void* handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay); + +/********************************************************************//** + * @~chinese + * @brief IPʽ + * @param handle [IN] 豸 + * @param nType [IN] IPͣMV_IP_CFG_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸IPʽDHCPLLAȣGigEVision豸֧֡ + + * @~english + * @brief IP configuration method + * @param handle [IN] Device handle + * @param nType [IN] IP type, refer to MV_IP_CFG_x + * @return Success, return MV_OK. Failure, return error code + * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetIpConfig(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ýʹijģʽ,type: MV_NET_TRANS_xʱĬʹdriver + * @param handle [IN] 豸 + * @param nType [IN] 紫ģʽMV_NET_TRANS_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿSDKڲʹõģʽĬʹģʽGigEVision豸֧֡ + + * @~english + * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default + * @param handle [IN] Device handle + * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x + * @return Success, return MV_OK. Failure, return error code + * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by GigEVision camera. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetNetTransMode(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ȡ紫Ϣ + * @param handle [IN] 豸 + * @param pstInfo [OUT] Ϣṹ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԻȡ紫ϢѽݴС֡ȣMV_CC_StartGrabbingɼ֮áGigEVision豸֧֡ + + * @~english + * @brief Get net transmission information + * @param handle [IN] Device handle + * @param pstInfo [OUT] Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Get network transmission information through this API, including received data size, number of lost frames. Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by GigEVision Camera. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetNetTransInfo(IN void* handle, MV_NETTRANS_INFO* pstInfo); + +/********************************************************************//** + * @~chinese + * @brief öĻظ + * @param nMode [IN] ظͣĬϹ㲥0-1-㲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻGigEЧ + + * @~english + * @brief Setting the ACK mode of devices Discovery. + * @param nMode [IN] ACK modeDefault-Broadcast,0-Unicast,1-Broadcast. + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is ONLY effective on GigE cameras. \n + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetDiscoveryMode(unsigned int nMode); + +/********************************************************************//** + * @~chinese + * @brief GVSPȡʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ300msΧ>10ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮ȡǰøýӿڿGVSPȡʱʱ䡣GVSPȡʱù̿ͼ쳣ùȡʱ䳤 + + * @~english + * @brief Set GVSP streaming timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 300ms, range: >10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, and just before start streaming, + * call this interface to set GVSP streaming timeout value. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGvspTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVSPȡʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVSPȡʱʱ + + * @~english + * @brief Get GVSP streaming timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVSP streaming timeout. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGvspTimeout(IN void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief GVCPʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ500msΧ0-10000ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿGVCPʱʱ䡣 + + * @~english + * @brief Set GVCP cammand timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 500ms, range: 0-10000ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set GVCP command timeout time. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGvcpTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVCPʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPʱʱ䡣 + + * @~english + * @brief Get GVCP cammand timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVCP timeout. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGvcpTimeout(void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief شGVCP + * @param handle [IN] 豸 + * @param nRetryGvcpTimes [IN] شΧ0-100 + * @return ɹMV_OK󣬷ش + * @remarks ýӿGVCP쳣ʱشĴһ̶ϿԱ豸ߣΧΪ0-100 + + * @~english + * @brief Set the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param nRetryGvcpTimes [IN] The number of retriesrang0-100 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to increase The Times of retransmission when GVCP packet transmission is abnormal,and to some extent, it can avoid dropping the camera, with a range of 0-100. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetRetryGvcpTimes(void* handle, unsigned int nRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشGVCP + * @param handle [IN] 豸 + * @param pnRetryGvcpTimes [OUT] شָ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPشĬ3Ρ + + * @~english + * @brief Get the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param pnRetryGvcpTimes [OUT] The number of retries + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of GVCP retransmissions, which defaults to 3. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetRetryGvcpTimes(void* handle, unsigned int* pnRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡѵpacket sizeýӿĿǰֻ֧GigE豸 + * @param handle [IN] 豸 + * @return packetsize + * @remarks ȡѵpacket sizeӦGigEVision豸SCPSӦU3V豸ÿδȡİСôСϴһĴСýӿҪMV_CC_OpenDevice֮MV_CC_StartGrabbing֮ǰá \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get the optimal Packet Size, Only support GigE Camera + * @param handle [IN] Device handle + * @return Optimal packetsize + * @remarks To get optimized packet size, for GigEVision device is SCPS, for USB3Vision device is the size of packet read from drive each time, and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOptimalPacketSize(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief Ƿط֧֣ط + * @param handle [IN] 豸 + * @param bEnable [IN] Ƿ֧ط + * @param nMaxResendPercent [IN] ط + * @param nResendTimeout [IN] طʱʱ + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿطԣGigEVision豸֧֡ + + * @~english + * @brief Set whethe to enable resend, and set resend + * @param handle [IN] Device handle + * @param bEnable [IN] enable resend + * @param nMaxResendPercent [IN] Max resend persent + * @param nResendTimeout [IN] Resend timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent, unsigned int nResendTimeout); + +/********************************************************************//** + * @~chinese + * @brief شԴ + * @param handle [IN] 豸 + * @param nRetryTimes [IN] شԴĬ20 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set the max resend retry times + * @param handle [IN] Device handle + * @param nRetryTimes [IN] The max times to retry resending lost packetsdefault 20 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetResendMaxRetryTimes (void* handle, unsigned int nRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشԴ + * @param handle [IN] 豸 + * @param pnRetryTimes [OUT] شԴ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get the max resend retry times + * @param handle [IN] Device handle + * @param pnRetryTimes [OUT] The max times to retry resending lost packets + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetResendMaxRetryTimes (void* handle, unsigned int* pnRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ͬһش֮ʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ͬһش֮ʱĬ10ms + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set time interval between same resend requests + * @param handle [IN] Device handle + * @param nMillisec [IN] The time interval between same resend requests,default 10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetResendTimeInterval (void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡͬһش֮ʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ͬһش֮ʱ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get time interval between same resend requests + * @param handle [IN] Device handle + * @param pnMillisec [OUT] The time interval between same resend requests + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetResendTimeInterval (void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief ôģʽΪģʽ鲥ģʽ + * @param handle [IN] 豸 + * @param stTransmissionType [IN] ģʽṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿôģʽΪ鲥ģʽGigEVision豸֧֡ + + * @~english + * @brief Set transmission type,Unicast or Multicast + * @param handle [IN] Device handle + * @param stTransmissionType [IN] Struct of transmission type + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is only valid for GigEVision camera. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetTransmissionType(void* handle, MV_TRANSMISSION_TYPE * pstTransmissionType); + +/********************************************************************//** + * @~chinese + * @brief + * @param pstActionCmdInfo [IN] Ϣ + * @param pstActionCmdResults [OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks GigEVision豸֧֡ + + * @~english + * @brief Issue Action Command + * @param pstActionCmdInfo [IN] Action Command + * @param pstActionCmdResults [OUT] Action Command Result List + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by GigEVision camera. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults); + +/********************************************************************//** + * @~chinese + * @brief ȡ鲥״̬ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param pbStatus [OUT] 鲥״̬,true:鲥״̬false:鲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿж豸ǰǷ鲥״̬ͻöʱҪ豸ж鲥⡣ + + * @~english + * @brief Get Multicast Status + * @param pstDevInfo [IN] Device Information Structure + * @param pbStatus [OUT] Status of Multicast + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to determine whether the camera is currently in multicast state, and to solve the problem that the client needs to turn on the camera to determine multicast when enumerating. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetMulticastStatus(IN MV_CC_DEVICE_INFO* pstDevInfo, OUT bool* pbStatus); + + +/************************************************************************/ +/* CameraLink 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_SetDeviceBaudrate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetDeviceBaudrate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetSupportBaudrates(IN void* handle,unsigned int* pnBaudrateAblity); + +/********************************************************************//** + * @~chinese + * @brief ôڲȴʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ڲĵȴʱ, λΪms + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Sets the timeout for operations on the serial port + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. + * @return Success, return MV_OK. Failure, return error code +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void* handle, unsigned int nMillisec); + + +/************************************************************************/ +/* U3V 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief U3VĴС + * @param handle [IN] 豸 + * @param nTransferSize [IN] İС, ByteĬΪ1Mrang>=0x10000 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӴСʵȡʱCPUռʡͬPCͲͬUSBչڲͬļԣòùܻȡͼķա + + * @~english + * @brief Set transfer size of U3V device + * @param handle [IN] Device handle + * @param nTransferSize [IN] Transfer sizeBytedefault1Mrang>=0x10000 + * @return Success, return MV_OK. Failure, return error code + * @remarks Increasing the transmission packet size can reduce the CPU utilization at the time of fetching. However, different PCS and different USB extension CARDS have different compatibility, and if this parameter is set too large, there may be the risk of not getting the image. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_SetTransferSize(IN void* handle, unsigned int nTransferSize); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴС + * @param handle [IN] 豸 + * @param pnTransferSize [OUT] İСָ, Byte + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3VСĬ1M + + * @~english + * @brief Get transfer size of U3V device + * @param handle [IN] Device handle + * @param pnTransferSize [OUT] Transfer sizeByte + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current U3V transfer packet size, default 1M. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_GetTransferSize(IN void* handle, unsigned int* pnTransferSize); + +/********************************************************************//** + * @~chinese + * @brief U3VĴͨ + * @param handle [IN] 豸 + * @param nTransferWays [IN] ͨΧ1-10 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ûԸPCܡ豸ͼ֡ʡͼСڴʹʵضԸòеڡͬPCͲͬUSBչڲͬļԡ + + * @~english + * @brief Set transfer ways of U3V device + * @param handle [IN] Device handle + * @param nTransferWays [IN] Transfer waysrang1-10 + * @return Success, return MV_OK. Failure, return error code + * @remarks Users can adjust this parameter according to PC performance, camera image frame rate, image size, memory utilization and other factors. But different PCS and different USB expansion CARDS have different compatibility. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_SetTransferWays(IN void* handle, unsigned int nTransferWays); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴͨ + * @param handle [IN] 豸 + * @param pnTransferWays [OUT] ָͨ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3V첽ȡڵ2000W豸MONO8ĬΪ3YUVΪĬ2RGBΪĬ1Ĭ8ڵ㡣 + + * @~english + * @brief Get transfer ways of U3V device + * @param handle [IN] Device handle + * @param pnTransferWays [OUT] Transfer ways + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of U3V asynchronous feed nodes. For 2000W camera, MONO8 defaults to 3, YUV defaults to 2, RGB defaults to 1, and other cases default to 8 nodes. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_GetTransferWays(IN void* handle, unsigned int* pnTransferWays); + +/************************************************************************/ +/* GenTLؽӿڣӿڿԸãֽӿڲ֧֣ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͨGenTLöInterfaces + * @param pstIFList [OUT] Interfacesб + * @param strGenTLPath [IN] GenTLctiļ· + * @return ɹMV_OK󣬷ش + * @remarks InterfacesбڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Interfaces with GenTL + * @param pstIFList [OUT] Interfaces List + * @param strGenTLPath [IN] GenTL cti file path + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the Interfaces list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumInterfacesByGenTL(IN OUT MV_GENTL_IF_INFO_LIST* pstIFList, IN const char * strGenTLPath); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL Interfaceö豸 + * @param pstIFInfo [IN] InterfaceϢ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Devices with GenTL interface + * @param pstIFInfo [IN] Interface information + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumDevicesByGenTL(IN MV_GENTL_IF_INFO* pstIFInfo, IN OUT MV_GENTL_DEV_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL豸Ϣ豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹָ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣 + + * @~english + * @brief Create Device Handle with GenTL Device Info + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CreateHandleByGenTL(OUT void ** handle, IN const MV_GENTL_DEV_INFO* pstDevInfo); + + +/************************************************************************/ +/* XML */ +/* XML parse tree generation */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡ豸XML + * @param handle [IN] 豸 + * @param pData [OUT] XMLݽջ + * @param nDataSize [IN] ջС + * @param pnDataLen [OUT] ʵݴС + * @return ɹMV_OK󣬷ش + * @remarks pDataΪNULLnDataSizeʵʵxmlļСʱݣpnDataLenxmlļС\n + pDataΪЧַһ㹻ʱݱڸû棬pnDataLenxmlļʵʴС + + * @~english + * @brief Get camera feature tree XML + * @param handle [IN] Device handle + * @param pData [OUT] XML data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pnDataLen [OUT] Actual data length + * @return Success, return MV_OK. Failure, return error code + * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, returned by pnDataLen XML file size.\n + When pData is a valid cache address and the cache is large enough, copy the full data into the cache, and pnDataLen returns the actual size of the XML file. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, OUT unsigned int* pnDataLen); + +/********************************************************************//** + * @~chinese + * @brief õǰڵķģʽ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penAccessMode [OUT] ڵķģʽ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Get Access mode of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penAccessMode [OUT] Access mode of the node + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetNodeAccessMode(IN void* handle, IN const char * pstrName, OUT MV_XML_AccessMode *penAccessMode); + +/********************************************************************//** + * @~chinese + * @brief õǰڵ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penInterfaceType [OUT] ڵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڿڵܽӿ֮ǰǰ֪ڵͣûѡʵܽӿڽнڵֵúͻȡ + + * @~english + * @brief Get Interface Type of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penInterfaceType [OUT] Interface Type of the node + * @return Success, return MV_OK. Failure, return error code + * @remarks The interface can know the node type in advance before calling the universal interface, so as to facilitate users to select the appropriate universal interface for setting and obtaining the node value. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetNodeInterfaceType(IN void* handle, IN const char * pstrName, OUT MV_XML_InterfaceType *penInterfaceType); + +/************************************************************************/ +/* ӽӿ */ +/* Additional interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͼƬ֧BmpJpeg. + * @param handle [IN] 豸 + * @param pstSaveParam [IN][OUT] ͼƬṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתJPEGBMPȸʽָڴУȻûԽתֱ֮ӱͼƬļýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ \n + MV_CC_SaveImageEx2MV_CC_SaveImageExӲhandleΪ˱֤ӿڵͳһ + + * @~english + * @brief Save image, support Bmp and Jpeg. + * @param handle [IN] Device handle + * @param pstSaveParam [IN][OUT] Save image parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Once there is image data, you can call this API to convert the data. \n + You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. \n + Comparing with the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImageEx2(IN void* handle, MV_SAVE_IMAGE_PARAM_EX* pstSaveParam); + +/********************************************************************//** + * @~chinese + * @brief ͼļ + * @param handle [IN] 豸 + * @param pstSaveFileParam [IN][OUT] ͼƬļṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧BMP/JPEG/PNG/TIFF + + * @~english + * @brief Save the image file. + * @param handle [IN] Device handle + * @param pstSaveFileParam [IN][OUT] Save the image file parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support BMP/JPEG/PNG/TIFF. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImageToFile(IN void* handle, MV_SAVE_IMG_TO_FILE_PARAM* pstSaveFileParam); + +/********************************************************************//** + * @~chinese + * @brief 3Dݣ֧PLYCSVOBJָʽ + * @param handle [IN] 豸 + * @param pstPointDataParam [IN][OUT] ݲṹ + * @return ɹMV_OK󣬷ش + * @remarks 3Dݸʽ3Dļʽ֧PLY/CSV/OBJ/n + Ŀǰ֧PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,ݲ֧3Dʽ + + * @~english + * @brief Save 3D point data, support PLYCSV and OBJ + * @param handle [IN] Device handle + * @param pstPointDataParam [IN][OUT] Save 3D point data parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Save the 3D data format to 3D file formatsupport PLYCSV and OBJ/n + only support PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,Other 3D format is not supported now. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SavePointCloudData(IN void* handle, MV_SAVE_POINT_CLOUD_PARAM* pstPointDataParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstRotateParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵ90/180/270ת + + * @~english + * @brief Rotate Image + * @param handle [IN] Device handle + * @param pstRotateParam [IN][OUT] Rotate image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support 90/180/270 rotation of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RotateImage(IN void* handle, IN OUT MV_CC_ROTATE_IMAGE_PARAM* pstRotateParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstFlipParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵĴֱˮƽת + + * @~english + * @brief Flip Image + * @param handle [IN] Device handle + * @param pstFlipParam [IN][OUT] Flip image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support vertical and horizontal reverse of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FlipImage(IN void* handle, IN OUT MV_CC_FLIP_IMAGE_PARAM* pstFlipParam); + +/********************************************************************//** + * @~chinese + * @brief ظʽת + * @param handle [IN] 豸 + * @param pstCvtParam [IN][OUT] ظʽתṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתûظʽָڴСýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ豸ǰɼͼJPEGѹĸʽֵ֧øýӿڽת \n + + * @~english + * @brief Pixel format conversion + * @param handle [IN] Device handle + * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. There is no order requirement to call this API, the transformation will execute when there is image data. First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, then call this API to transform the format. \n + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_ConvertPixelType(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam); + +/********************************************************************//** + * @~chinese + * @brief òֵ㷨 + * @param handle [IN] 豸 + * @param nBayerCvtQuality [IN] BayerIJֵ 0- 1- 2-ţĬΪţ + * @return ɹMV_OK󣬷ش + * @remarks ڲͼתӿڵıֵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڲʹõIJֵ㷨Ǹýӿ趨ġ + + * @~english + * @brief Interpolation algorithm type setting + * @param handle [IN] Device handle + * @param nBayerCvtQuality [IN] Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + * @return Success, return MV_OK. Failure, return error code + * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, and the interpolation algorithm used in the MV CC ConvertPixelType and MV CC SaveImageEx2 interfaces is set by this interface. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int nBayerCvtQuality); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵGammaֵ + * @param handle [IN] 豸 + * @param fBayerGammaValue [IN] Gammaֵ[0.1,4.0] + * @return ɹMV_OK󣬷ش + * @remarks øֵڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set Gamma value after Bayer interpolation + * @param handle [IN] Device handle + * @param fBayerGammaValue [IN] Gamma value[0.1,4.0] + * @return Success, return MV_OK. Failure, return error code + * @remarks After setting the value, it work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBayerGammaValue(IN void* handle, IN float fBayerGammaValue); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵɫУʹܺ; + * @param handle [IN] 豸 + * @param pstCCMParam [IN] ɫУṹ + * @return ɹMV_OK󣬷ش + * @remarks ɫУɫУڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set CCM param after Bayer interpolation + * @param handle [IN] Device handle + * @param pstCCMParam [IN] Color correction parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the color correction and set the color correction matrix, It work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBayerCCMParam(IN void* handle, IN MV_CC_CCM_PARAM* pstCCMParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstNoiseEstimateParam [IN][OUT] BayerƲṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Noise estimate of Bayer format + * @param handle [IN] Device handle + * @param pstNoiseEstimateParam [IN][OUT] Noise estimate parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_BayerNoiseEstimate(IN void* handle, IN OUT MV_CC_BAYER_NOISE_ESTIMATE_PARAM* pstNoiseEstimateParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstSpatialDenoiseParam [IN][OUT] Bayerṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Spatial Denoise of Bayer format + * @param handle [IN] Device handle + * @param pstSpatialDenoiseParam [IN][OUT] Spatial Denoise parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_BayerSpatialDenoise(IN void* handle, IN OUT MV_CC_BAYER_SPATIAL_DENOISE_PARAM* pstSpatialDenoiseParam); + +/********************************************************************//** + * @~chinese + * @brief + * @param handle [IN] 豸 + * @param pstDecodeParam [IN][OUT] ṹ + * @return ɹMV_OK󣬷ش + * @remarks ȡѹݣͬʱֽ֧ǰʵʱͼˮӡϢǵǰ߲ʵʱȡģˮӡ쳣 + + * @~english + * @brief High Bandwidth Decode + * @param handle [IN] Device handle + * @param pstDecodeParam [IN][OUT] High Bandwidth Decode parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Decode the lossless compressed data from the camera into raw data + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_HB_Decode(IN void* handle, IN OUT MV_CC_HB_DECODE_PARAM* pstDecodeParam); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Save camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FeatureSave(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Load camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FeatureLoad(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸ȡļ + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Read the file from the camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FileAccessRead(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ļд豸 + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Write the file to camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FileAccessWrite(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ȡļȡĽ + * @param handle [IN] 豸 + * @param pstFileAccessProgress [IN] + * @return ɹMV_OK󣬷ش ǰļȡ״̬ + + * @~english + * @brief Get File Access Progress + * @param handle [IN] Device handle + * @param pstFileAccessProgress [IN] File access Progress + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFileAccessProgress(IN void* handle, OUT MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress); + +/********************************************************************//** + * @~chinese + * @brief ʼ¼ + * @param handle [IN] 豸 + * @param pstRecordParam [IN] ¼ṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Start Record + * @param handle [IN] Device handle + * @param pstRecordParam [IN] Record param structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam); + +/********************************************************************//** + * @~chinese + * @brief ¼ + * @param handle [IN] 豸 + * @param pstInputFrameInfo [IN] ¼ݽṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Input RAW data to Record + * @param handle [IN] Device handle + * @param pstInputFrameInfo [IN] Record data structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo); + +/********************************************************************//** + * @~chinese + * @brief ֹͣ¼ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Stop Record + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StopRecord(IN void* handle); + + +/************************************************************************/ +/* ʹõĽӿ */ +/* Interfaces not recommended */ +/************************************************************************/ +/************************************************************************ + * @fn MV_CC_GetImageInfo + * @brief ȡͼϢ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظйͼϢṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CC_GetImageInfo + * @brief Get basic information of image + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of image basic information + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageInfo(IN void* handle, IN OUT MV_IMAGE_BASIC_INFO* pstInfo); + +/************************************************************************ + * @fn MV_CC_SetSDKLogPath() + * @brief SDK־·־MvLogServerãýӿЧĬ־Ϊ״̬ + * @param pSDKLogPath [IN] SDK־· + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SetSDKLogPath() + * @brief Set SDK log path + * @param pSDKLogPath [IN] SDK log path + * @return Access, return true. Not access, return false + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetSDKLogPath(IN const char * pSDKLogPath); + +/************************************************************************ + * @fn MV_CC_GetTlProxy + * @brief ȡGenICam + * @param handle [IN] ַ + * @return GenICamָ ֵNULL쳣NULL + + * @fn MV_CC_GetTlProxy + * @brief Get GenICam proxy + * @param handle [IN] Handle address + * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL + ************************************************************************/ +MVSDKEXPORT_API void* __stdcall MV_CC_GetTlProxy(IN void* handle); + +/*********************************************************************** + * @fn MV_XML_GetRootNode + * @brief ȡڵ + * @param handle [IN] + * @param pstNode [OUT] ڵϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetRootNode + * @brief Get root node + * @param handle [IN] Handle + * @param pstNode [OUT] Root node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetRootNode(IN void* handle, IN OUT MV_XML_NODE_FEATURE* pstNode); + +/*********************************************************************** + * @fn MV_XML_GetChildren + * @brief xmlлȡָڵӽڵ㣬ڵΪRoot + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstNodesList [OUT] ڵбṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetChildren + * @brief Get all children node of specific node from xml, root node is Root + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstNodesList [OUT] Node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetChildren(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT MV_XML_NODES_LIST* pstNodesList); + +/*********************************************************************** + * @fn MV_XML_GetNodeFeature + * @brief õǰڵ + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstFeature [OUT] ǰڵԽṹ壬 + pstFeature ṹݲο MV_XML_FEATURE_x + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetNodeFeature + * @brief Get current node feature + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstFeature [OUT] Current node feature structure + Details of pstFeature refer to MV_XML_FEATURE_x + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetNodeFeature(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT void* pstFeature); + +/*********************************************************************** + * @fn MV_XML_UpdateNodeFeature + * @brief ½ڵ + * @param handle [IN] + * @param enType [IN] ڵ + * @param pstFeature [OUT] ǰڵԽṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_UpdateNodeFeature + * @brief Update node + * @param handle [IN] Handle + * @param enType [IN] Node type + * @param pstFeature [OUT] Current node feature structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_UpdateNodeFeature(IN void* handle, IN enum MV_XML_InterfaceType enType, IN void* pstFeature); + +// нڵҪʱĻص +// MV_XML_UpdateNodeFeatureӿڸ½ڵʱעĻصcbUpdatepstNodesListз֮Ľڵ +/*********************************************************************** + * @fn MV_XML_RegisterUpdateCallBack + * @brief ע»ص + * @param handle [IN] + * @param cbUpdate [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_RegisterUpdateCallBack + * @brief Register update callback + * @param handle [IN] Handle + * @param cbUpdate [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_RegisterUpdateCallBack(IN void* handle, + IN void(__stdcall* cbUpdate)(enum MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser), + IN void* pUser); + +/************************************************************************/ +/* õĽӿڣڸŻĽӿڿ滻 */ +/* Abandoned interface */ +/************************************************************************/ +/*********************************************************************** + * @fn MV_CC_GetOneFrame + * @brief ȡһ֡ͼ񣬴˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrame + * @brief Get one frame data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOneFrame(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_GetOneFrameEx + * @brief ȡһ֡trunckݣ˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrameEx + * @brief Get one frame of trunck data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOneFrameEx(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_RegisterImageCallBack + * @brief עͼݻصýӿã MV_CC_RegisterImageCallBackExӿڣ + * @param handle [IN] + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_RegisterImageCallBack + * @brief Register image data callback (This interface is abandoned, it is recommended to use the MV_CC_RegisterImageCallBackEx) + * @param handle [IN] Handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBack(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser), + void* pUser); + +/************************************************************************ + * @fn MV_CC_SaveImage + * @brief ͼƬýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImage + * @brief Save image (This interface is abandoned, it is recommended to use the MV_CC_SaveImageEx) + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Input data pixel format + nWidth; // [IN] Width + nHeight; // [IN] Height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Provided output buffer size + enImageType; // [IN] Output image type + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM* pSaveParam); + +/************************************************************************ + * @fn MV_CC_SaveImageEx + * @brief ͼƬ֧BmpJpeg.50-99֮ǰ ýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + nJpgQuality; // [IN] , (50-99] + nReserved[4]; + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImageEx + * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Pixel format of input data + nWidth; // [IN] Image width + nHeight; // [IN] Image height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Output buffer size provided + enImageType; // [IN] Output image format + nJpgQuality; // [IN] Encoding quality, (50-99] + nReserved[4]; + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX* pSaveParam); + +/************************************************************************ + * @fn MV_GIGE_ForceIp + * @brief ǿIPýӿã MV_GIGE_ForceIpExӿڣ + * @param handle豸 + * @param nIP [IN] õIP + * @return ش + + * @fn MV_GIGE_ForceIp + * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) + * @param handle Handle + * @param nIP [IN] IP to set + * @return Refer to error code +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_ForceIp(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CC_RegisterEventCallBack + * @brief ע¼صýӿã MV_CC_RegisterEventCallBackExӿڣ + * @param handle豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ش + + * @fn MV_CC_RegisterEventCallBack + * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the MV_CC_RegisterEventCallBackEx interface) + * @param handle豸 + * @param cbEvent [IN] event callback pointer + * @param pUser [IN] User defined value + * @return ش +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterEventCallBack(void* handle, void(__stdcall* cbEvent)(unsigned int nExternalEventId, void* pUser), void* pUser); + +/*********************************************************************** + * @fn MV_CC_Display + * @brief ʾͼעʾڣڲԶʾMV_CC_GetImageBufferͬʱʹãMV_CC_DisplayOneFrameӿڣ + * @param handle [IN] + * @param hWnd [IN] ʾھ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_Display + * @brief Display one frame image, register display window, automatic display internally + * @param handle [IN] Handle + * @param hWnd [IN] Display Window Handle + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_Display(IN void* handle, void* hWnd); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief ȡIntegerֵMV_CC_GetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйԽṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief Get Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to get width + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetIntValue(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE *pIntValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief IntegerֵMV_CC_SetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief Set Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to set width + * const unsigned int nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetIntValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + + +/************************************************************************/ +/* ȡãģнӿѷʹܽӿڴ */ +/* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ +/************************************************************************/ +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȵϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰĿֵ + * unsigned int nMax; // ʾõĿֵ + * unsigned int nMin; // ʾСõĿֵ + * unsigned int nInc; // ʾõĿnIncıЧ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image width + * @param void* handle [IN] Camera Handle + * MVCC_INTVALUE* pstValue [IN][OUT] Returns the information structure pointer about the camera's width for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // Represents the current width value of the camera + * unsigned int nMax; // Indicates the maximum settable width value allowed by the camera + * unsigned int nMin; // Indicates the minimum settable width value allowed by the camera + * unsigned int nInc; // Indicates that the width increment set by the camera must be a multiple of nInc, otherwise it is invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other Integer structure parameters interface can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ +* @fn MVSDKEXPORT_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); +* @brief ͼ +* @param void* handle [IN] +* const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ +* @return ɹ,MV_OK,ȽΪӦֵʧ,ش + +* @fn MVSDKEXPORT_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + * @brief Set image width + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] To set the value of the camera width, note that the width value must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface + * @return Success, return MV_OK, and the camera width will change to the corresponding value. Failure, return error code +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ߶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظй߶ȵϢṹָ + * @return ɹ,MV_OK,߶ϢصṹУʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image height + * @param void* handle [IN] Camera handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera height to user + * @return Success, return MV_OK, and return height information to the structure. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief ͼ߶ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ + * @return ɹ,MV_OK,߶ȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief Set image height + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera height value to set, note that this value must be times of nInc of pstValue returned by MV_CC_GetWidth + * @return Success, return MV_OK, and the camera height will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼXƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйXƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image X offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera X offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief Set image X offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera X offset value to set + * @return Success, return MV_OK, and the camera X offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼYƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйYƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image Y offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera Y offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + * @brief Set image Y offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera Y offset value to set + * @return Success, return MV_OK, and the camera Y offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure lower limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure lower to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure lower limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure lower to set + * @return Success, return MV_OK, and the camera exposure time lower limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure upper limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure upper to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure upper limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure upper to set + * @return Success, return MV_OK, and the camera exposure time upper limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡֵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get brightness + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera brightness to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief ֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief Set brightness + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Brightness upper to set + * @return Success, return MV_OK, and the camera brightness value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ֡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظй֡ʵϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Frame Rate + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera frame rate to user + * The meaning of returns pstValue structure + * float fCurValue; // Indicates the current frame rate of the camera + * float fMax; // Indicates the maximum frame rate allowed by the camera + * float fMin; // Indicates the minimum frame rate allowed by the camera + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief Set frame rate + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Camera frame rate to set + * @return Success, return MV_OK, and camera frame rate will be changed to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gain + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to gain to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current gain + * float fMax; // The maximum gain camera allowed + * float fMin; // The minimum gain camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief Set Gain + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Gain value to set + * @return Success, return MV_OK, and the camera gain value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡعʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйعʱϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get exposure time + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to exposure time to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current exposure time + * float fMax; // The maximum exposure time camera allowed + * float fMin; // The minimum exposure time camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief عʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief Set exposure time + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Exposure time to set + * @return Success, return MV_OK, and the camera exposure time value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡظʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйظʽϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰظʽö,˵PixelType_Gvsp_Mono8, õֵ,ֵPixelType.hMvGvspPixelTypeö + * unsigned int nSupportedNum; // ֵ֧ظʽĸ + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // ֵ֧ظʽӦֵбҪظʽʱеһ֣Ч + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + öͲӿڿɲմ˽ӿڣйӦöͶӦֵPixelType.h CameraParams.hӦĶ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Pixel Format + * @param void* handle [IN] Camera Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Returns the information structure pointer about pixel format for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // The current pixel format of the camera, is the enumeration type, such as PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to MvGvspPixelType enumeration type in PixelType.h + * unsigned int nSupportedNum; // Number of pixel formats supported by the camera + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this list, otherwise invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Other interface of Enumeration structure parameters can refer to this interface, look for the corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõظʽӦֵô˽ӿʱֱдöֵMV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return ɹ,MV_OK,ظʽΪӦֵʧ,ش + * + * ҪõöͱGetӿڷصnSupportValue[MV_MAX_XML_SYMBOLIC_NUM]еһ֣ʧ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief Set Pixel Format + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] The corresponding integer value for pixel format to be set, when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return Success, return MV_OK, and the camera pixel format will change to the corresponding value. Failure, return error code + * + * Other interface of Enumeration structure parameters can refer to this interface, the enumeration type to be set must be one of the nSupportValue [MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it will fail + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡɼģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйزɼģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_ACQUISITION_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get acquisition mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of acquisition mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_ACQUISITION_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõIJɼģʽӦֵ + * @return ɹ,MV_OK,ɼģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief Set acquisition mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to acquisition mode + * @return Success, return MV_OK, and the camera acquisition mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAIN_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get gain mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gain mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAIN_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief ģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief Set gain mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gain mode + * @return Success, return MV_OK, and the camera gain mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶعģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶعģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_EXPOSURE_AUTO_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get auto exposure mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto exposure mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_EXPOSURE_AUTO_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Զعģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶعģʽӦֵ + * @return ɹ,MV_OK,ԶعģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Set auto exposure mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto exposure mode + * @return Success, return MV_OK, and the camera auto exposure mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief ôģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger mode + * @return Success, return MV_OK, and the camera trigger mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйʱϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get tigger delay + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of trigger delay + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief ôʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõʱ + * @return ɹ,MV_OK,ʱΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief Set tigger delay + * @param void* handle [IN] Handle + * const float fValue [IN] Trigger delay to set + * @return Success, return MV_OK, and the camera trigger delay will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԴ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشԴϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_SOURCE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger source + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger source + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief ôԴ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴԴӦֵ + * @return ɹ,MV_OK,ԴΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger source + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger source + * @return Success, return MV_OK, and the camera trigger source will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief һΣӿڽѡĴԴΪʱЧ + * @param void* handle [IN] + * @return ɹ,MV_OK, ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) + * @param void* handle [IN] Handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡGamma + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйGamma͵Ϣṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAMMA_SELECTOR + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Gamma mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gamma mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Gamma + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõGammaͶӦֵ + * @return ɹ,MV_OK,GammaͽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Set Gamma mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gamma mode + * @return Success, return MV_OK, and the camera gamma mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡGammaֵ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйGammaֵϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gamma value + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of gamma value + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Gammaֵ + * @param void* handle [IN] + * const float fValue [IN] ҪõGammaֵ + * @return ɹ,MV_OK,GammaֵΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Set Gamma value + * @param void* handle [IN] Handle + * const float fValue [IN] Gamma value to set + * @return Success, return MV_OK, and the camera gamma value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get sharpness + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of sharpness + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief Set sharpness + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Sharpness to set + * @return Success, return MV_OK, and the camera sharpness will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡҶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйҶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Hue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Hue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief ûҶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĻҶ + * @return ɹ,MV_OK,ҶȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief Set Hue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Hue to set + * @return Success, return MV_OK, and the camera Hue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Saturation + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Saturation + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief ñͶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõıͶ + * @return ɹ,MV_OK,ͶȽΪӦֵʧ,ش + +* @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief Set Saturation + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Saturation to set + * @return Success, return MV_OK, and the camera Saturation will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶƽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶƽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_BALANCEWHITE_AUTO + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Auto white balance + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto white balance + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Զƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶƽӦֵ + * @return ɹ,MV_OK,Զƽ⽫ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Set Auto white balance + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto white balance + * @return Success, return MV_OK, and the camera auto white balance will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance red + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance red + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ 콫ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance red + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance red to set + * @return Success, return MV_OK, and the camera white balance red will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ̽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance green + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance green + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ̽ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance green + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance green to set + * @return Success, return MV_OK, and the camera white balance green will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance blue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance blue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance blue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance blue to set + * @return Success, return MV_OK, and the camera white balance blue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡˮӡϢڰϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйˮӡϢڰϢͽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get information type included by frame stamp + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of information type included by frame stamp + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief ˮӡϢڰϢ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõˮӡϢڰϢ + * @return ɹ,MV_OK,ˮӡϢڰϢͻΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief Set information type included by frame stamp + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Information type included by frame stamp to set + * @return Success, return MV_OK, and the camera information type included by frame stamp will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief ȡ豸Զ + * @param void* handle [IN] + * MVCC_STRINGVALUE* pstValue [IN OUT] ظйֽṹָ + * @return ɹ,MV_OK,һȡԶ֣ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief Get device user defined name + * @param void* handle [IN] Handle + * MVCC_STRINGVALUE* pstValue [IN OUT] Structure pointer of device name + * @return Success, return MV_OK, and get the camera user defined name. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief 豸Զ + * @param void* handle [IN] + * IN const char* chValue [IN] 豸 + * @return ɹ,MV_OK,豸Զ֣ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief Set device user defined name + * @param void* handle [IN] Handle + * IN const char* chValue [IN] Device name + * @return Success, return MV_OK, and set the camera user defined name. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡһδ֡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйһδ֡ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get frame number trigger by once + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of frame number trigger by once + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief һδ֡ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõһδ֡ + * @return ɹ,MV_OK,һδ֡ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief Set frame number trigger by once + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Frame number trigger by once to set + * @return Success, return MV_OK, and the camera frame number trigger by once will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƵṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get line rate + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of line rate + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Ƶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõƵ + * @return ɹ,MV_OK,ƵΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Set line rate + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Line rate to set + * @return Success, return MV_OK, and the camera line rate will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get heartbeat information + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of heartbeat information + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Ϣ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõϢ + * @return ɹ,MV_OK,ϢΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Set heartbeat information + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Heartbeat information to set + * @return Success, return MV_OK, and the camera heartbeat information will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡС + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйСṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet size + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet size + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief С + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõС + * @return ɹ,MV_OK,СΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet size + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet size to set + * @return Success, return MV_OK, and change packet size to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͼṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet sending delay + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet sending delay + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief ͼ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõͼ + * @return ɹ,MV_OK,ͼΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet sending delay + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet delay to set + * @return Success, return MV_OK, and change packet delay to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief ȡնIPַ0xa9fe0102 ʾ 169.254.1.2 + * @param void* handle [IN] + * @param unsigned int* pnIP [IN][OUT] ظ߽նIPַ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 + * @param void* handle [IN] Handle + * @param unsigned int* pnIP [IN][OUT] Receiver IP address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief ýնIPַ + * @param void* handle [IN] + * unsigned int nIP [IN] ҪõĽնIPַ + * @return ɹ,MV_OK,նIPַΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief Set receiver IP address + * @param void* handle [IN] Handel + * unsigned int nIP [IN] Receiver IP address to set + * @return Success, return MV_OK, and change receiver IP address to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief ȡͶ˵Ķ˿ں + * @param void* handle [IN] + * @param unsigned int* pnPort [IN][OUT] ظ߷Ͷ˵Ķ˿ں + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief Get transmitter port number + * @param void* handle [IN] Handle + * @param unsigned int* pnPort [IN][OUT] Transmitter port number + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief ÷Ͷ˵Ķ˿ں + * @param void* handle [IN] + * unsigned int nPort [IN] ҪõķͶ˵Ķ˿ں + * @return ɹ,MV_OK,Ͷ˵Ķ˿ںŻΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief Set transmitter port number + * @param void* handle [IN] Handle + * unsigned int nPort [IN] Transmitter port number to set + * @return Success, return MV_OK, and change transmitter port number to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_SetDeviceBaudrateӿڣ + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_SetDeviceBaudrate) +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetDeviceBaudrateӿڣ + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetDeviceBaudrate) +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetDeviceBauderate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetSupportBaudratesӿڣ + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetSupportBaudrates) +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetSupportBauderates(IN void* handle,unsigned int* pnBaudrateAblity); + +#ifdef __cplusplus +} +#endif + +#endif //_MV_SDK_EXPORT_H__ diff --git a/Cigarette/MVS3.2.1/Include/ObsoleteCamParams.h b/Cigarette/MVS3.2.1/Include/ObsoleteCamParams.h new file mode 100644 index 0000000..937a40f --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/ObsoleteCamParams.h @@ -0,0 +1,301 @@ + +#ifndef _MV_OBSOLETE_CAM_PARAMS_H_ +#define _MV_OBSOLETE_CAM_PARAMS_H_ + +#include "PixelType.h" + +/// \~chinese ֡Ϣ \~english Output Frame Information +typedef struct _MV_FRAME_OUT_INFO_ +{ + unsigned short nWidth; ///< [OUT] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [OUT] \~chinese ͼ \~english Image Height + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel Type + + unsigned int nFrameNum; ///< [OUT] \~chinese ֡ \~english Frame Number + unsigned int nDevTimeStampHigh; ///< [OUT] \~chinese ʱ32λ \~english Timestamp high 32 bits + unsigned int nDevTimeStampLow; ///< [OUT] \~chinese ʱ32λ \~english Timestamp low 32 bits + unsigned int nReserved0; ///< [OUT] \~chinese 8ֽڶ \~english Reserved, 8-byte aligned + int64_t nHostTimeStamp; ///< [OUT] \~chinese ɵʱ \~english Host-generated timestamp + + unsigned int nFrameLen; + + unsigned int nLostPacket; // ֡ + unsigned int nReserved[2]; +}MV_FRAME_OUT_INFO; + +/// \~chinese ͼƬ \~english Save image type +typedef struct _MV_SAVE_IMAGE_PARAM_T_ +{ + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Input Data Pixel Format + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬС \~english Output Image Size + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + +}MV_SAVE_IMAGE_PARAM; + +typedef struct _MV_IMAGE_BASIC_INFO_ +{ + unsigned short nWidthValue; + unsigned short nWidthMin; + unsigned int nWidthMax; + unsigned int nWidthInc; + + unsigned int nHeightValue; + unsigned int nHeightMin; + unsigned int nHeightMax; + unsigned int nHeightInc; + + float fFrameRateValue; + float fFrameRateMin; + float fFrameRateMax; + + unsigned int enPixelType; ///< [OUT] \~chinese ǰظʽ \~english Current pixel format + unsigned int nSupportedPixelFmtNum; ///< [OUT] \~chinese ֵ֧ظʽ \~english Support pixel format + unsigned int enPixelList[MV_MAX_XML_SYMBOLIC_NUM]; + unsigned int nReserved[8]; + +}MV_IMAGE_BASIC_INFO; + +/// \~chinese ijڵӦӽڵֵ \~english The maximum number of child nodes corresponding to a node +#define MV_MAX_XML_NODE_NUM_C 128 + +/// \~chinese ڵַ󳤶 \~english The maximum length of node name string +#define MV_MAX_XML_NODE_STRLEN_C 64 + +/// \~chinese ڵStringֵ󳤶 \~english The maximum length of Node String +#define MV_MAX_XML_STRVALUE_STRLEN_C 64 + +/// \~chinese ڵֶ󳤶 \~english The maximum length of the node description field +#define MV_MAX_XML_DISC_STRLEN_C 512 + +/// \~chinese ĵԪ \~english The maximum number of units +#define MV_MAX_XML_ENTRY_NUM 10 + +/// \~chinese ڵ \~english The maximum number of parent nodes +#define MV_MAX_XML_PARENTS_NUM 8 + +/// \~chinese ÿѾʵֵԪƳ \~english The length of the name of each unit that has been implemented +#define MV_MAX_XML_SYMBOLIC_STRLEN_C 64 + +enum MV_XML_Visibility +{ + V_Beginner = 0, ///< Always visible + V_Expert = 1, ///< Visible for experts or Gurus + V_Guru = 2, ///< Visible for Gurus + V_Invisible = 3, ///< Not Visible + V_Undefined = 99 ///< Object is not yet initialized +}; + +/// \~chinese ڵ | en:Single Node Basic Attributes +typedef struct _MV_XML_NODE_FEATURE_ +{ + enum MV_XML_InterfaceType enType; ///< \~chinese ڵ \~english Node Type + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Is visibility + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + unsigned int nReserved[4]; +}MV_XML_NODE_FEATURE; + +/// \~chinese ڵб | en:Node List +typedef struct _MV_XML_NODES_LIST_ +{ + unsigned int nNodeNum; ///< \~chinese ڵ \~english Node Number + MV_XML_NODE_FEATURE stNodes[MV_MAX_XML_NODE_NUM_C]; +}MV_XML_NODES_LIST; + +typedef struct _MV_XML_FEATURE_Value_ +{ + enum MV_XML_InterfaceType enType; ///< \~chinese ڵ \~english Node Type + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + unsigned int nReserved[4]; +}MV_XML_FEATURE_Value; + +typedef struct _MV_XML_FEATURE_Base_ +{ + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode +}MV_XML_FEATURE_Base; + +typedef struct _MV_XML_FEATURE_Integer_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + int64_t nMinValue; ///< \~chinese Сֵ \~english Min Value + int64_t nMaxValue; ///< \~chinese ֵ \~english Max Value + int64_t nIncrement; ///< \~chinese \~english Increment + + unsigned int nReserved[4]; + +}MV_XML_FEATURE_Integer; + +typedef struct _MV_XML_FEATURE_Boolean_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + bool bValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Boolean; + +typedef struct _MV_XML_FEATURE_Command_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Command; + +typedef struct _MV_XML_FEATURE_Float_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + double dfValue; ///< \~chinese ǰֵ \~english Current Value + double dfMinValue; ///< \~chinese Сֵ \~english Min Value + double dfMaxValue; ///< \~chinese ֵ \~english Max Value + double dfIncrement; ///< \~chinese \~english Increment + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Float; + +typedef struct _MV_XML_FEATURE_String_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + char strValue[MV_MAX_XML_STRVALUE_STRLEN_C]; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_String; + +typedef struct _MV_XML_FEATURE_Register_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nAddrValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Register; + +typedef struct _MV_XML_FEATURE_Category_ +{ + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Category; + +typedef struct _MV_XML_FEATURE_EnumEntry_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + int bIsImplemented; + int nParentsNum; + MV_XML_NODE_FEATURE stParentsList[MV_MAX_XML_PARENTS_NUM]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int nReserved[8]; + +}MV_XML_FEATURE_EnumEntry; + +typedef struct _MV_XML_FEATURE_Enumeration_ +{ + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + int nSymbolicNum; ///< \~chinese ymbolic \~english Symbolic Number + char strCurrentSymbolic[MV_MAX_XML_SYMBOLIC_STRLEN_C];///< \~chinese ǰSymbolic \~english Current Symbolic Index + char strSymbolic[MV_MAX_XML_SYMBOLIC_NUM][MV_MAX_XML_SYMBOLIC_STRLEN_C]; + enum MV_XML_AccessMode enAccessMode; ////< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Enumeration; + +typedef struct _MV_XML_FEATURE_Port_ +{ + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Port; + +typedef struct _MV_XML_CAMERA_FEATURE_ +{ + enum MV_XML_InterfaceType enType; + union + { + MV_XML_FEATURE_Integer stIntegerFeature; + MV_XML_FEATURE_Float stFloatFeature; + MV_XML_FEATURE_Enumeration stEnumerationFeature; + MV_XML_FEATURE_String stStringFeature; + }SpecialFeature; + +}MV_XML_CAMERA_FEATURE; + +#endif /* _MV_OBSOLETE_CAM_PARAMS_H_ */ diff --git a/Cigarette/MVS3.2.1/Include/PixelType.h b/Cigarette/MVS3.2.1/Include/PixelType.h new file mode 100644 index 0000000..95ae41a --- /dev/null +++ b/Cigarette/MVS3.2.1/Include/PixelType.h @@ -0,0 +1,178 @@ + +#ifndef _MV_PIXEL_TYPE_H_ +#define _MV_PIXEL_TYPE_H_ + +/************************************************************************/ +/* GigE Vision (2.0.03) PIXEL FORMATS */ +/************************************************************************/ + +// Indicate if pixel is monochrome or RGB +#define MV_GVSP_PIX_MONO 0x01000000 +#define MV_GVSP_PIX_RGB 0x02000000 // deprecated in version 1.1 +#define MV_GVSP_PIX_COLOR 0x02000000 +#define MV_GVSP_PIX_CUSTOM 0x80000000 +#define MV_GVSP_PIX_COLOR_MASK 0xFF000000 + +// Indicate effective number of bits occupied by the pixel (including padding). +// This can be used to compute amount of memory required to store an image. +#define MV_PIXEL_BIT_COUNT(n) ((n) << 16) + +#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_MASK 0x00FF0000 +#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_SHIFT 16 + +// Pixel ID: lower 16-bit of the pixel formats +#define MV_GVSP_PIX_ID_MASK 0x0000FFFF +#define MV_GVSP_PIX_COUNT 0x46 // next Pixel ID available + +enum MvGvspPixelType +{ + // Undefined pixel type + PixelType_Gvsp_Undefined = 0xFFFFFFFF, + + // Mono buffer format defines + PixelType_Gvsp_Mono1p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(1) | 0x0037), + PixelType_Gvsp_Mono2p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(2) | 0x0038), + PixelType_Gvsp_Mono4p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(4) | 0x0039), + PixelType_Gvsp_Mono8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), + PixelType_Gvsp_Mono8_Signed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0002), + PixelType_Gvsp_Mono10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), + PixelType_Gvsp_Mono10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), + PixelType_Gvsp_Mono12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), + PixelType_Gvsp_Mono12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), + PixelType_Gvsp_Mono14 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0025), + PixelType_Gvsp_Mono16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), + + // Bayer buffer format defines + PixelType_Gvsp_BayerGR8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), + PixelType_Gvsp_BayerRG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), + PixelType_Gvsp_BayerGB8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), + PixelType_Gvsp_BayerBG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), + PixelType_Gvsp_BayerGR10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), + PixelType_Gvsp_BayerRG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), + PixelType_Gvsp_BayerGB10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), + PixelType_Gvsp_BayerBG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), + PixelType_Gvsp_BayerGR12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), + PixelType_Gvsp_BayerRG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), + PixelType_Gvsp_BayerGB12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), + PixelType_Gvsp_BayerBG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), + PixelType_Gvsp_BayerGR10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), + PixelType_Gvsp_BayerRG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), + PixelType_Gvsp_BayerGB10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), + PixelType_Gvsp_BayerBG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), + PixelType_Gvsp_BayerGR12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), + PixelType_Gvsp_BayerRG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), + PixelType_Gvsp_BayerGB12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), + PixelType_Gvsp_BayerBG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), + PixelType_Gvsp_BayerGR16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002E), + PixelType_Gvsp_BayerRG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002F), + PixelType_Gvsp_BayerGB16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0030), + PixelType_Gvsp_BayerBG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0031), + + // RGB Packed buffer format defines + PixelType_Gvsp_RGB8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), + PixelType_Gvsp_BGR8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), + PixelType_Gvsp_RGBA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), + PixelType_Gvsp_BGRA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), + PixelType_Gvsp_RGB10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0018), + PixelType_Gvsp_BGR10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0019), + PixelType_Gvsp_RGB12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001A), + PixelType_Gvsp_BGR12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001B), + PixelType_Gvsp_RGB16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033), + PixelType_Gvsp_RGB10V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001C), + PixelType_Gvsp_RGB10V2_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001D), + PixelType_Gvsp_RGB12V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(36) | 0X0034), + PixelType_Gvsp_RGB565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0035), + PixelType_Gvsp_BGR565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0X0036), + + // YUV Packed buffer format defines + PixelType_Gvsp_YUV411_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x001E), + PixelType_Gvsp_YUV422_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), + PixelType_Gvsp_YUV422_YUYV_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), + PixelType_Gvsp_YUV444_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0020), + PixelType_Gvsp_YCBCR8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003A), + PixelType_Gvsp_YCBCR422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003B), + PixelType_Gvsp_YCBCR422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0043), + PixelType_Gvsp_YCBCR411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003C), + PixelType_Gvsp_YCBCR601_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003D), + PixelType_Gvsp_YCBCR601_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003E), + PixelType_Gvsp_YCBCR601_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0044), + PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003F), + PixelType_Gvsp_YCBCR709_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0040), + PixelType_Gvsp_YCBCR709_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0041), + PixelType_Gvsp_YCBCR709_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0045), + PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x0042), + + // RGB Planar buffer format defines + PixelType_Gvsp_RGB8_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0021), + PixelType_Gvsp_RGB10_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0022), + PixelType_Gvsp_RGB12_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0023), + PixelType_Gvsp_RGB16_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0024), + + // ԶͼƬʽ + PixelType_Gvsp_Jpeg = (MV_GVSP_PIX_CUSTOM | MV_PIXEL_BIT_COUNT(24) | 0x0001), + + PixelType_Gvsp_Coord3D_ABC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C0),//0x026000C0 + PixelType_Gvsp_Coord3D_ABC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C1),//0x026000C1 + + // ֵοPixelType_Gvsp_Coord3D_AC32f_64; the value is discarded + PixelType_Gvsp_Coord3D_AC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(40) | 0x00C2), + // ֵ; the value is discarded (ѷChunkdata) + PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(28) | 0x0001), + + PixelType_Gvsp_Coord3D_ABC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x3001),//0x82603001 + PixelType_Gvsp_Coord3D_AB32f = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3002),//0x82403002 + PixelType_Gvsp_Coord3D_AB32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3003),//0x82403003 + PixelType_Gvsp_Coord3D_AC32f_64 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C2),//0x024000C2 + PixelType_Gvsp_Coord3D_AC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C3),//0x024000C3 + PixelType_Gvsp_Coord3D_AC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3004),//0x82403004 + PixelType_Gvsp_Coord3D_A32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BD),//0x012000BD + PixelType_Gvsp_Coord3D_A32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3005),//0x81203005 + PixelType_Gvsp_Coord3D_C32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BF),//0x012000BF + PixelType_Gvsp_Coord3D_C32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3006),//0x81203006 + PixelType_Gvsp_Coord3D_ABC16 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x00B9),//0x023000B9 + PixelType_Gvsp_Coord3D_C16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x00B8),//0x011000B8 + + //ѹظʽ + PixelType_Gvsp_HB_Mono8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), + PixelType_Gvsp_HB_Mono10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), + PixelType_Gvsp_HB_Mono10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), + PixelType_Gvsp_HB_Mono12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), + PixelType_Gvsp_HB_Mono12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), + PixelType_Gvsp_HB_Mono16 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), + PixelType_Gvsp_HB_BayerGR8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), + PixelType_Gvsp_HB_BayerRG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), + PixelType_Gvsp_HB_BayerGB8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), + PixelType_Gvsp_HB_BayerBG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), + PixelType_Gvsp_HB_BayerGR10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), + PixelType_Gvsp_HB_BayerRG10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), + PixelType_Gvsp_HB_BayerGB10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), + PixelType_Gvsp_HB_BayerBG10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), + PixelType_Gvsp_HB_BayerGR12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), + PixelType_Gvsp_HB_BayerRG12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), + PixelType_Gvsp_HB_BayerGB12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), + PixelType_Gvsp_HB_BayerBG12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), + PixelType_Gvsp_HB_BayerGR10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), + PixelType_Gvsp_HB_BayerRG10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), + PixelType_Gvsp_HB_BayerGB10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), + PixelType_Gvsp_HB_BayerBG10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), + PixelType_Gvsp_HB_BayerGR12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), + PixelType_Gvsp_HB_BayerRG12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), + PixelType_Gvsp_HB_BayerGB12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), + PixelType_Gvsp_HB_BayerBG12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), + PixelType_Gvsp_HB_YUV422_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), + PixelType_Gvsp_HB_YUV422_YUYV_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), + PixelType_Gvsp_HB_RGB8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), + PixelType_Gvsp_HB_BGR8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), + PixelType_Gvsp_HB_RGBA8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), + PixelType_Gvsp_HB_BGRA8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), + +}; + +#ifdef WIN32 +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +#endif /* _MV_PIXEL_TYPE_H_ */ diff --git a/Cigarette/MVS3.2.1/lib/win32/C++ Builder/MvCameraControlBC.lib b/Cigarette/MVS3.2.1/lib/win32/C++ Builder/MvCameraControlBC.lib new file mode 100644 index 0000000..8f77d05 Binary files /dev/null and b/Cigarette/MVS3.2.1/lib/win32/C++ Builder/MvCameraControlBC.lib differ diff --git a/Cigarette/MVS3.2.1/lib/win32/MvCameraControl.lib b/Cigarette/MVS3.2.1/lib/win32/MvCameraControl.lib new file mode 100644 index 0000000..7a8b5ff Binary files /dev/null and b/Cigarette/MVS3.2.1/lib/win32/MvCameraControl.lib differ diff --git a/Cigarette/MVS3.2.1/lib/win32/VC6/MvSdkExport.lib b/Cigarette/MVS3.2.1/lib/win32/VC6/MvSdkExport.lib new file mode 100644 index 0000000..0672c18 Binary files /dev/null and b/Cigarette/MVS3.2.1/lib/win32/VC6/MvSdkExport.lib differ diff --git a/Cigarette/MVS3.2.1/lib/win64/C++ Builder/MvCameraControlBC.a b/Cigarette/MVS3.2.1/lib/win64/C++ Builder/MvCameraControlBC.a new file mode 100644 index 0000000..a8ac039 Binary files /dev/null and b/Cigarette/MVS3.2.1/lib/win64/C++ Builder/MvCameraControlBC.a differ diff --git a/Cigarette/MVS3.2.1/lib/win64/MvCameraControl.lib b/Cigarette/MVS3.2.1/lib/win64/MvCameraControl.lib new file mode 100644 index 0000000..97017f4 Binary files /dev/null and b/Cigarette/MVS3.2.1/lib/win64/MvCameraControl.lib differ diff --git a/Cigarette/MvIMPACT/DriverBase/Include/mvCustomCommandDataTypes.h b/Cigarette/MvIMPACT/DriverBase/Include/mvCustomCommandDataTypes.h new file mode 100644 index 0000000..dede197 --- /dev/null +++ b/Cigarette/MvIMPACT/DriverBase/Include/mvCustomCommandDataTypes.h @@ -0,0 +1,270 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MV_CUSTOM_COMMAND_DATA_TYPES_H +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MV_CUSTOM_COMMAND_DATA_TYPES_H MV_CUSTOM_COMMAND_DATA_TYPES_H +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- + +#ifdef __GNUC__ +# define ATTR_PACK __attribute__((packed)) __attribute__ ((aligned (1))) +#elif defined _MSC_VER || defined __BORLANDC__ +# define ATTR_PACK +# pragma pack(push, 1) // 1 byte structure alignment +#elif !defined(SWIG) +# error add your compiler specific structure alignment function here +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#if defined(MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +namespace GenICam +{ +#endif // #if defined(MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +typedef __int16 int16_type; +typedef unsigned __int16 uint16_type; +typedef __int32 int32_type; +typedef unsigned __int32 uint32_type; +# ifdef __BORLANDC__ // is Borland compiler? +# pragma option push -b // force enums to the size of integer +# endif // __BORLANDC__ +# elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNUC__) +# ifndef WRAP_ANY +# include +# endif // #ifndef WRAP_ANY +typedef int16_t int16_type; +typedef uint16_t uint16_type; +typedef int32_t int32_type; +typedef uint32_t uint32_type; +# else +# error "unsupported target environment" +# endif // #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + +//----------------------------------------------------------------------------- +/// \brief Defines valid request transmission modes. +/** + * Using the custom command interpreter images can requested again from a device + * supporting it in different resolutions. This enumeration can be used to define + * what/how to transmit the image. + * + * \since 2.18.0 + * \ingroup GenICamInterfaceDevice + */ +enum TRequestTransmissionMode +//----------------------------------------------------------------------------- +{ + /// \brief Request transmission of an image in full resolution. + rtmFullResolution +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid parameters that can be modified within a sequencer set at runtime. +/** + * Using the custom command interpreter features controlled by a running sequencer can + * be modified while the sequencer is running. This enumeration can be used to define + * which parameter shall/can be modified. + * + * \since 2.18.0 + * \ingroup GenICamInterfaceDevice + */ +enum TSequencerSetParameter +//----------------------------------------------------------------------------- +{ + /// \brief Requests the CounterDuration[CounterSelector=Counter1] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter1, + /// \brief Requests the CounterDuration[CounterSelector=Counter2] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter2, + /// \brief Requests the CounterDuration[CounterSelector=Counter3] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter3, + /// \brief Requests the CounterDuration[CounterSelector=Counter4] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter4, + /// \brief Requests the CounterDuration[CounterSelector=Counter5] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter5, + /// \brief Requests the CounterDuration[CounterSelector=Counter6] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter6, + /// \brief Requests the CounterDuration[CounterSelector=Counter7] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter7, + /// \brief Requests the CounterDuration[CounterSelector=Counter8] property to be modified in a user selected sequencer set. + sspCounterDuration_Counter8, + /// \brief Requests the \c ExposureTime property to be modified in a user selected sequencer set. + sspExposureTime, + /// \brief Requests the Gain[GainSelector=AnalogAll] property to be modified in a user selected sequencer set. + sspGain_AnalogAll, + /// \brief Requests the Gain[GainSelector=AnalogRed] property to be modified in a user selected sequencer set. + sspGain_AnalogRed, + /// \brief Requests the Gain[GainSelector=AnalogGreen] property to be modified in a user selected sequencer set. + sspGain_AnalogGreen, + /// \brief Requests the Gain[GainSelector=AnalogBlue] property to be modified in a user selected sequencer set. + sspGain_AnalogBlue, + /// \brief Requests the Gain[GainSelector=AnalogTap1] property to be modified in a user selected sequencer set. + sspGain_AnalogTap1, + /// \brief Requests the Gain[GainSelector=AnalogTap2] property to be modified in a user selected sequencer set. + sspGain_AnalogTap2, + /// \brief Requests the Gain[GainSelector=AnalogTap3] property to be modified in a user selected sequencer set. + sspGain_AnalogTap3, + /// \brief Requests the Gain[GainSelector=AnalogTap4] property to be modified in a user selected sequencer set. + sspGain_AnalogTap4, + /// \brief Requests the OffsetX property to be modified in a user selected sequencer set. + /** + * \since 2.34.0, requires firmware version >= 2.35 + */ + sspOffsetX, + /// \brief Requests the OffsetY property to be modified in a user selected sequencer set. + /** + * \since 2.34.0, requires firmware version >= 2.35 + */ + sspOffsetY, + /// \brief Requests the Width property to be modified in a user selected sequencer set. + /** + * \since 2.36.0, requires firmware version >= 2.36 + */ + sspWidth, + /// \brief Requests the Height property to be modified in a user selected sequencer set. + /** + * \since 2.36.0, requires firmware version >= 2.36 + */ + sspHeight +}; + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +//----------------------------------------------------------------------------- +enum TCustomCommand +//----------------------------------------------------------------------------- +{ + ccSendFrame = 0x0001, + ccUpdateSequencerSet = 0x0002, + /// Private custom commands start here! + ccLAST = 0x8000 +}; + +//----------------------------------------------------------------------------- +struct CustomCommandProtocolHeader +//----------------------------------------------------------------------------- +{ + uint16_type interpreterVersionMajor; + uint16_type interpreterVersionMinor; + uint16_type totalMessageLength; + uint16_type request_id; +} ATTR_PACK; + +#define VARS_SFCPacketHeader \ + uint16_type command; \ + uint16_type messageLength; + +#define VARS_SFCPacketUpdateSequencerSet \ + uint16_type sequencerSet; \ + uint16_type sequencerSetParameter; + +//----------------------------------------------------------------------------- +struct CustomCommandHeader +//----------------------------------------------------------------------------- +{ + VARS_SFCPacketHeader +} ATTR_PACK; + +//----------------------------------------------------------------------------- +struct CustomCommandSendFrame +//----------------------------------------------------------------------------- +{ + VARS_SFCPacketHeader + uint32_type offsetX; + uint32_type offsetY; + uint32_type width; + uint32_type height; + uint32_type timestamp_high; + uint32_type timestamp_low; + uint32_type identifier; +} ATTR_PACK; + +//----------------------------------------------------------------------------- +struct CustomCommandUpdateSequencerSet +//----------------------------------------------------------------------------- +{ + VARS_SFCPacketHeader + VARS_SFCPacketUpdateSequencerSet +} ATTR_PACK; + +//----------------------------------------------------------------------------- +struct CustomCommandUpdateSequencerSetI64 +//----------------------------------------------------------------------------- +{ + VARS_SFCPacketHeader + VARS_SFCPacketUpdateSequencerSet + int32_type value_high; + int32_type value_low; +} ATTR_PACK; + +//----------------------------------------------------------------------------- +struct CustomCommandUpdateSequencerSetF +//----------------------------------------------------------------------------- +{ + VARS_SFCPacketHeader + VARS_SFCPacketUpdateSequencerSet + char data[8]; +} ATTR_PACK; + +typedef enum TRequestTransmissionMode TRequestTransmissionMode; +typedef enum TSequencerSetParameter TSequencerSetParameter; +typedef enum TCustomCommand TCustomCommand; +typedef struct CustomCommandProtocolHeader CustomCommandProtocolHeader; +typedef struct CustomCommandHeader CustomCommandHeader; +typedef struct CustomCommandSendFrame CustomCommandSendFrame; +typedef struct CustomCommandUpdateSequencerSet CustomCommandUpdateSequencerSet; +typedef struct CustomCommandUpdateSequencerSetI64 CustomCommandUpdateSequencerSetI64; +typedef struct CustomCommandUpdateSequencerSetF CustomCommandUpdateSequencerSetF; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +// restore Borland compiler switch 'force enums to the size of integer' +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ +# pragma option pop +# endif // __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#if defined(MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace GenICam +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef __cplusplus +} +#endif // __cplusplus + +#ifdef __GNUC__ +# undef ATTR_PACK +#elif defined _MSC_VER || defined __BORLANDC__ +# undef ATTR_PACK +# pragma pack(pop) // restore previous structure alignment +#elif !defined(SWIG) +# error restore your compiler specific structure alignment here if necessary +#endif + +#endif /*MV_CUSTOM_COMMAND_DATA_TYPES_H*/ diff --git a/Cigarette/MvIMPACT/DriverBase/Include/mvDriverBaseEnums.h b/Cigarette/MvIMPACT/DriverBase/Include/mvDriverBaseEnums.h new file mode 100644 index 0000000..7f7d44a --- /dev/null +++ b/Cigarette/MvIMPACT/DriverBase/Include/mvDriverBaseEnums.h @@ -0,0 +1,5587 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvDriverBaseEnumsH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvDriverBaseEnumsH mvDriverBaseEnumsH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ +# pragma option push -b // force enums to the size of integer +# endif // __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +// Macros to influence what is to be included into the documentation and what is not +#if defined(DEVICE_SPECIFIC_DOCUMENTATION_ONLY) +# if defined(BUILD_MVBLUECOUGAR_DOCUMENTATION) +# define IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +# define IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +# define IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION +# define IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +# elif defined(BUILD_MVBLUEFOX_DOCUMENTATION) +# define IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +# define IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +# define IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION +# define IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +# elif defined(BUILD_MVGRABBER_DOCUMENTATION) +# define IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +# define IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +# define IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION +# define IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +# elif defined(BUILD_MVVIRTUALDEVICE_DOCUMENTATION) +# define IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +# define IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +# define IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +# define IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION +# elif defined(BUILD_MVV4L2_DOCUMENTATION) +# define IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +# define IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +# define IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +# define IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +# endif // device specific documentation macros +#endif // #if defined(DEVICE_SPECIFIC_DOCUMENTATION_ONLY) + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifndef MV_CUSTOM_COLOR_TWIST_INPUT_CORRECTION_MATRIX_MODES +# define MV_CUSTOM_COLOR_TWIST_INPUT_CORRECTION_MATRIX_MODES +# endif +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#include + +//----------------------------------------------------------------------------- +/// \brief Defines which field triggers the start of the acquisition. +/// \ingroup DeviceSpecificInterface +enum TAcquisitionField // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief Controlled by the camera parameter. + afAuto = 0, + /// \brief Only odd fields will be digitised. + afOdd = 1, + /// \brief Only even fields will be digitised. + afEven = 2, + /// \brief Odd and even fields will be digitised. + afAny = afOdd | afEven +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid acquisition modes. +/// \ingroup CommonInterface +enum TAcquisitionMode +//----------------------------------------------------------------------------- +{ + /// \brief Continuous mode. This is the recommended mode when image data shall either be transferred constantly or when working with an externally triggered setup. + amContinuous = 1, + /// \brief In this mode \a AcquisitionFrameCount images will transferred by the device. + /** + * When \a AcquisitionFrameCount have been send by the device, it will automatically stop + * to send more data + */ + amMultiFrame = 2, + /// \brief In this mode the device always will always just send a single image when a data stream is started. + /** + * This mode can be interesting, when the devices acquisition parameters change from image to + * image or when a lot of devices will be operated in the same system an bandwidth resources are + * limited. + */ + amSingleFrame = 3 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for acquisition start/stop behaviour. +/** + * \since 1.12.11 + */ +/// \ingroup CommonInterface +enum TAcquisitionStartStopBehaviour +//----------------------------------------------------------------------------- +{ + /// \brief The default behaviour for acquisition start and stop. + /** + * Most devices will only support this mode. When this mode is selected, + * the device driver will try to start and stop the transfer of data from + * the device automatically. Internally this will happen while image requests + * are being processed + */ + assbDefault, + /// \brief The user can control the start and stop of the data transfer from the device. + /** + * In this mode, queuing of image request buffers and the actual streaming of + * data from the device is de-coupled. This can sometimes be favourable + * compared to the default behaviour e.g. when dealing with device drivers + * that do not accept new buffers while the acquisition engine is running. + * Also when working at very high frame rates, pre-queuing some buffer before + * starting the actual data transfer can help to avoid capture queue underruns + * and thus data loss. + */ + assbUser +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid Area Of Interest modes. +/// \ingroup CommonInterface +enum TAoiMode +//----------------------------------------------------------------------------- +{ + /// \brief Use a small centered window for image processing. + /** + * In this mode, a device and processing function dependent window in the middle of + * the AOI captured from the device will be used for the processing function. + * + * \since 2.37.0 + * + * Example: + * - Assume a device that can deliver 1280*960 pixels. + * + * Now in the centered AOI mode a processing function will use a window smaller than the AOI in the middle + * of the image. + * + * The starting point can be calculated by the formula: + * \code + * offsetX = ( width - ( width / 2 ) ) / 2 + * offsetY = ( height - ( height / 2 ) ) / 2 + * \endcode + * + * The used AOI is just width / 2 * height / 2 thus takes up the center quarter of the selected AOI. + * + * \image html TAoiMode_amCentered.png + * + * In case of an AOI defined by the user, the central AOI of the delivered image is used. + * + * \deprecated Up to version 2.36.0 the AOI had just a size of 50*50 pixels. + * The behavior was the following: + * - Assume a device that can deliver 640*480 pixels. + * - The user selects to capture an rectangular AOI starting at 100/100 with a width of 200*200 + * Now in the centered AOI mode a processing function will use a window smaller than the AOI in the middle of the user defined AOI. This e.g. could be a rectangle starting at 150/150 with a + * width of 100*100. + * \image html TAoiMode_amCentered_upTo_2-36-0.png + */ + amCentered = 0, + /// \brief Use the complete image for image processing. + amFull, + /// \brief Use a user defined AOI window for image processing. + amUseAoi +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid auto-control speed modes. +/** + * Auto control speed modes define the time in which the controller tries to adapt its parameters to + * reach the desired result. + */ +/// \ingroup DeviceSpecificInterface +enum TAutoControlSpeed +//----------------------------------------------------------------------------- +{ + /// \brief The controller will converge slowly to the desired value. + acsSlow = 0, + /// \brief The controller will converge to the desired value at medium speed. + acsMedium, + /// \brief The controller will converge fast to the desired value. + acsFast, + /// \brief In this mode the user can control the behaviour of the closed loop(control circuit). + acsUserDefined +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid auto control modes. +/// \ingroup DeviceSpecificInterface +enum TAutoControlMode +//----------------------------------------------------------------------------- +{ + /// \brief The standard auto control mode. + acmStandard, + /// \brief A device specific auto control mode. + /** + * \b mvBlueFOX \b specific: + * For mvBlueFOX devices of type 202b and 202d the operation in device specific AEC/AGC + * mode is limited in (non continuous)triggered-modes. AEC/AGC only works while the trigger + * signal is active. As these sensor types only support the trigger modes + * mvIMPACT::acquire::ctmOnHighLevel and mvIMPACT::acquire::ctmOnLowLevel + * 'active' means that the required signal level for that mode(either \a high or \a low) + * is present. + * + * When this signal level is no longer present AEC/AGC will stop working and gain and exposure + * will be set to a static value. This is due to a limitation of the sensor chip. Effectively this + * means that for single frame triggering requiring short active pulses AEC/AGC is not possible. + */ + acmDeviceSpecific +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid AEC( Automatic Exposure Control ) modes. +/// \ingroup DeviceSpecificInterface +enum TAutoExposureControl +//----------------------------------------------------------------------------- +{ + /// \brief AEC is switched off. + aecOff = 0, + /// \brief AEC is switched on. + aecOn +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid AGC( Automatic Gain Control ) modes. +/// \ingroup DeviceSpecificInterface +enum TAutoGainControl +//----------------------------------------------------------------------------- +{ + /// \brief AGC is switched off. + agcOff = 0, + /// \brief AGC is switched on. + agcOn +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid offset calibration modes. +/// \ingroup DeviceSpecificInterface +enum TAutoOffsetCalibration +//----------------------------------------------------------------------------- +{ + /// \brief The automatic offset calibration is switched off. + /** + * In this mode the offset can be adjusted manually. + */ + aocOff = 0, + /// \brief The automatic offset calibration is switched on. + aocOn +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the Bayer conversion algorithm to use. +/// \ingroup CommonInterface +enum TBayerConversionMode // uint_type +//----------------------------------------------------------------------------- +{ + /// \brief Linear interpolation. + /** + * This mode is fast but especially sharp edges will appear slightly blurred in the + * resulting image. + */ + bcmLinearInterpolation, + /// \brief Adaptive edge sensing. + /** + * This mode requires more CPU time than linear interpolation, but the resulting image more closely + * matches the original scene. Edges will be reconstructed with higher accuracy except for noisy images. + * For better results in noisy images mvIMPACT::acquire::bcmLinearInterpolation is the recommended mode. + */ + bcmAdaptiveEdgeSensing, + /// \brief Auto. + /** + * This mode automatically sets the Bayer conversion algorithm according to the format property of the camera description. + */ + bcmAuto, + /// \brief Packed. + /** + * In this mode the resulting image will have half the height of the source image. The following algorithm will be used for + * generating the resulting image: + * + * \code + * 1 2 3 4 ... n + * 1 R G R G ... R G + * 2 G B G B ... G B + * + * | 1 | 2 | 3 | 4 | 5 |...| n | + * 1 |RGB|RGB|RGB|RGB|RGB|...|RGB| + * + * R1(dest) = R11 + * G1(dest) = (G12 + G21) / 2 + * B1(dest) = B22 + * R2(dest) = (R11 + R13) / 2 + * G2(dest) = ((G12 + G21) / 2) + (G12 + G23)) / 2 + * B2(dest) = (B22 + B24) / 2 + * ... + * Rn(dest) = R1(n-1) + * Gn(dest) = (G1(n) + G2(n-1)) / 2 + * Bn(dest) = B2(n) + * \endcode + * + * This mode is mainly useful for line scan cameras as for area cameras this would modify the aspect ratio. + * \since 2.5.9 + */ + bcmPacked, + /// \brief Linear Packed. + /** + * In this mode the resulting image will have half the height of the source image. The following algorithm will be used for + * generating the resulting image: + * + * \code + * 1 2 3 4 ... n + * 1 R G R G ... R G + * 2 G B G B ... G B + * + * | 1 | 2 | 3 | 4 | 5 |...| n | + * 1 |RGB|RGB|RGB|RGB|RGB|...|RGB| + * 2 |RGB|RGB|RGB|RGB|RGB|...|RGB| + * + * R1(dest) = R11 + * G1(dest) = G21 + * B1(dest) = B22 + * R2(dest) = (R11 + R13) / 2 + * G2(dest) = G12 + * B2(dest) = B22 + * R3(dest) = R13 + * G3(dest) = G23 + * B3(dest) = (B22 + B24) / 2 + * ... + * Rn(dest) = R1(n-1) + * Gn(dest) = G1(n) + * Bn(dest) = B2(n) + * \endcode + * + * This mode is mainly useful for line scan cameras as for area cameras this would modify the aspect ratio. + * \since 2.5.9 + */ + bcmLinearPacked, + /// \brief Adaptive edge sensing plus. + /** + * This mode is even more demanding CPU-wise than adaptive edge sensing, but the resulting image is sharper + * and has fewer artifacts. The parameters of the sharpening filter can be set by the user, to fit specific needs. + * \since 2.26.0 + */ + bcmAdaptiveEdgeSensingPlus, + /// \brief Adaptive edge sensing plus. + /** + * This mode is most demanding CPU-wise, but the resulting image will have the best possible quality. + * It is based on the following algorithm: K. Hirakawa, T.W. Parks, Adaptive Homogeneity-Directed Demosaicing Algorithm, IEEE Trans. Image Processing, March, 2005. + * \since 2.27.0 + */ + bcmAdaptiveHomogeneityDirected +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid Bayer formats. +/// \ingroup CommonInterface +enum TBayerMosaicParity +//----------------------------------------------------------------------------- +{ + /// \brief It is not known whether the buffer or image contains raw Bayer data or the buffer or image does NOT contain raw Bayer data. + bmpUndefined = -1, + /// \brief The buffer or image starts with a green-red line starting with a green pixel. + bmpGR, + /// \brief The buffer or image starts with a green-red line starting with a red pixel. + bmpRG, + /// \brief The buffer or image starts with a green-blue line starting with a blue pixel. + bmpBG, + /// \brief The buffer or image starts with a green-blue line starting with a green pixel. + bmpGB +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid results of a white balance calibration. +/// \ingroup CommonInterface +enum TBayerWhiteBalanceResult +//----------------------------------------------------------------------------- +{ + /// \brief No white balance calibration has been performed since start up. + bwbrUnknown = 0, + /// \brief The white balance calibration has been performed successfully for the selected setting. + bwbrOK = 1, + /// \brief An unknown error occurred during the white balance calibration for the selected setting. + bwbrErrorUnknown = 2, + /// \brief The previous white balance calibration failed because the reference image used for the calibration was too dark. + bwbrErrorTooDark = 3, + /// \brief The previous white balance calibration failed because the reference image used for the calibration was too bright. + bwbrErrorTooBright = 4 +}; + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid thresholds( in Volt ) for the digital inputs of the +/// mvBlueFOX cameras. +/// \ingroup DeviceSpecificInterface +enum TBlueFOXDigitalInputThreshold +//----------------------------------------------------------------------------- +{ + /// \brief This input is assumed as logic '1' when the voltage applied to the input lies above about 2 Volts. + bfdit2V = 2, + /// \brief This input is assumed as logic '1' when the voltage applied to the input lies above about 10 Volts. + bfdit10V = 10 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the footer mode of the mvBlueFOX. +/// \ingroup DeviceSpecificInterface +enum TBlueFOXFooterMode +//----------------------------------------------------------------------------- +{ + /// \brief No footer. + bffmOff = 0, + /// \brief A 64 Byte footer (standard). + bffm64B = 64, + /// \brief A long 512 Byte footer. + bffm512B = 512 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid image sensor capabilities +/** + * These enums may be 'ored' together. + */ +/// \ingroup DeviceSpecificInterface +enum TBlueFOXInfoSensorCapabilities // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief A dummy constant to indicate, that this device does not have any capabilities defined by other constants belonging to this enumeration. + bfiscNone = 0x00000, + /// \brief The exposure time can be controlled by an application. + bfiscExposure = 0x00001, + /// \brief This sensor can automatically control the exposure time. + bfiscExposureAuto = 0x00002, + /// \brief The gain can be controlled by an application. + bfiscGain = 0x00004, + /// \brief This sensor can automatically control the gain. + bfiscGainAuto = 0x00008, + /// \brief The offset can be controlled by an application. + bfiscOffset = 0x00010, + /// \brief This sensor can automatically control the offset. + bfiscOffsetAuto = 0x00020, + /// \brief This sensor supports binning. + bfiscBinning = 0x00040, + /// \brief This sensor supports triggered acquisition. + bfiscTrigger = 0x00080, + /// \brief This sensor can output the 'exposure active' signal(e.g. to control a flash). + bfiscFlash = 0x00100, + /// \brief This sensor supports line triggered acquisition. + bfiscLineTrigger = 0x00200, + /// \brief This sensor can perform shading correction. + bfiscShadingCorrection = 0x00400, + /// \brief This sensor supports overlapped exposure. + bfiscOverlappedExposure = 0x00800, + /// \brief This sensor supports frame delay. + bfiscFrameDelay = 0x01000, + /// \brief This sensor supports line delay. + bfiscLineDelay = 0x02000, + /// \brief This sensor supports to define an AOI for the AGC/AEC/AOC(Auto Offset Control) features. + bfiscAutoControlAOI = 0x04000, + /// \brief This sensor supports to define the control speed for the AGC/AEC/AOC(Auto Offset Control) features. + bfiscAutoControlSpeed = 0x08000, + /// \brief This sensor supports to define a delay for the AGC/AEC/AOC(Auto Offset Control) features. + bfiscAutoControlDelay = 0x10000, + /// \brief This sensor supports a temperature sensor within the imager + bfiscTemperatureSensor = 0x20000 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines Offset Auto Calibration Controller Speed. +/** + * These are relative values, that might result in a different behaviour depending + * on the sensor type used. + */ +/// \ingroup DeviceSpecificInterface +enum TBlueFOXOffsetAutoBlackSpeed +//----------------------------------------------------------------------------- +{ + /// \brief Fastest Setting + bfoablFastest = 0, + /// \brief Very fast Setting + bfoablVeryFast = 1, + /// \brief Fast Setting + bfoablFast = 2, + /// \brief Medium Setting + bfoablMedium = 3, + /// \brief Slow Setting + bfoablSlow = 4, + /// \brief Very slow Setting + bfoablVerySlow = 6, + /// \brief Slowest Setting + bfoablSlowest = 7 +}; + +//----------------------------------------------------------------------------- +/// \brief Sensor timing options. +/// \ingroup DeviceSpecificInterface +enum TBlueFOXSensorTiming +//----------------------------------------------------------------------------- +{ + /// \brief Standard Timing + bfstStandard = 0, + /// \brief Fast line skip timing + /** + * In this mode a faster line skip timing will be used. This will result in a higher + * frame rate in partial scan mode, but might affect the image quality. + * + * \note + * This mode is not available for every mvBlueFOX camera. + */ + bfstFastLineSkip = 1, + /// \brief This mode is not available for every mvBlueFOX camera. + bfstLowSmearLineSkip = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the block size used for the USB transfer of the mvBlueFOX. +/// \ingroup DeviceSpecificInterface +enum TBlueFOXTransferSize +//----------------------------------------------------------------------------- +{ + /// \brief 16KB blocks. + bfts16KB = 16 * 1024, + /// \brief 32KB blocks. + bfts32KB = 32 * 1024, + /// \brief 64KB blocks. + bfts64KB = 64 * 1024, + /// \brief 128KB blocks. + bfts128KB = 128 * 1024, + /// \brief 256KB blocks. + bfts256KB = 256 * 1024, + /// \brief 512KB blocks. + bfts512KB = 512 * 1024, + /// \brief 1024KB blocks. + bfts1024KB = 1024 * 1024, + /// \brief 2048KB blocks. + bfts2048KB = 2048 * 1024 +}; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines a Boolean value type. +/// \ingroup CommonInterface +enum TBoolean +//----------------------------------------------------------------------------- +{ + /// \brief Off, false or logical low. + bFalse = 0, + /// \brief On, true or logical high. + bTrue = 1 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines buffer part data types. +/** + * \since 2.20.0 + */ +/// \ingroup CommonInterface +enum TBufferPartDataType +//----------------------------------------------------------------------------- +{ + /// \brief The framework is not aware of the data type of the data in the provided buffer part + /** + * From the application perspective this can be handled as raw data. + */ + bpdtUnknown = 0, + /// \brief Color or monochrome (2D) image. + /** + * This part carries all the pixel data of given image (even if the image is represented by a single-plane pixel format). + */ + bpdt2DImage = 1, + /// \brief Single color plane of a planar (2D) image. + /** + * The data should be linked with the other color planes to get the complete image. The complete image consists of 2 planes. + * The planes of a given planar image must be placed as consecutive parts within the buffer. + */ + bpdt2DPlaneBiplanar = 2, + /// \brief Single color plane of a planar (2D) image. + /** + * The data should be linked with the other color planes to get the complete image. The complete image consists of 3 planes. + * The planes of a given planar image must be placed as consecutive parts within the buffer. + */ + bpdt2DPlaneTriplanar = 3, + /// \brief Single color plane of a planar (2D) image. + /** + * The data should be linked with the other color planes to get the complete image. The complete image consists of 4 planes. + * The planes of a given planar image must be placed as consecutive parts within the buffer. + */ + bpdt2DPlaneQuadplanar = 4, + /// \brief 3D image (pixel coordinates). + /** + * This part carries all the pixel data of given image (even if the image is represented by a single-plane pixel format, for example when transferring the depth map only). + */ + bpdt3DImage = 5, + /// \brief Single color plane of a planar (3D) image. + /** + * The data should be linked with the other color planes to get the complete image. The complete image consists of 2 planes. + * The planes of a given planar image must be placed as consecutive parts within the buffer. + */ + bpdt3DPlaneBiplanar = 6, + /// \brief Single color plane of a planar (3D) image. + /** + * The data should be linked with the other color planes to get the complete image. The complete image consists of 3 planes. + * The planes of a given planar image must be placed as consecutive parts within the buffer. + */ + bpdt3DPlaneTriplanar = 7, + /// \brief Single color plane of a planar (3D) image. + /** + * The data should be linked with the other color planes to get the complete image. The complete image consists of 4 planes. + * The planes of a given planar image must be placed as consecutive parts within the buffer. + */ + bpdt3DPlaneQuadplanar = 8, + /// \brief Confidence of the individual pixel values. + /** + * Expresses the level of validity of given pixel values. Confidence map is always used together with one or more additional + * image-based parts matching 1:1 dimension-wise. Each value in the confidence map expresses level of validity of the image pixel at + * matching position. + */ + bpdtConfidenceMap = 9, + /// \brief JPEG image data. + bpdtJPEG = 1000, + /// \brief JPEG 2000 image data. + bpdtJPEG2000 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the camera Aoi modes. +/// \ingroup DeviceSpecificInterface +enum TCameraAoiMode +//----------------------------------------------------------------------------- +{ + /// \brief Use the complete AOI window defined by the hardware or input data (sensor, camera). + camFull = 0, + /// \brief Use a user defined AOI window. + camUser +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid binning modes for the camera. +/** + * \note + * Binning might be available for color sensors that do not support color + * binning. This will result in incorrect color information when the data + * is converted from a Bayer sensor. However under some circumstances this feature + * might be useful (e.g. when taking image in a very dark surrounding or at night + * where almost no color information will be contained in the image anyway thus + * resulting in useful images again). Therefore this feature has deliberately + * left available. \n \n + * \image html Binning_modes.png + */ +/// \ingroup DeviceSpecificInterface +enum TCameraBinningMode // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief No Binning. + cbmOff = 0x0, + /// \brief Horizontal Binning (combines 2 adjacent columns). + cbmBinningH = 0x1, + /// \brief Vertical Binning (combines 2 adjacent rows). + cbmBinningV = 0x2, + /// \brief Combines mvIMPACT::acquire::cbmBinningH and mvIMPACT::acquire::cbmBinningV. + cbmBinningHV = cbmBinningH | cbmBinningV, + /// \brief Horizontal Binning (combines 4 adjacent columns). + cbmBinning3H = 0x10, + /// \brief Vertical Binning (combines 4 adjacent rows). + cbmBinning3V = 0x20, + /// \brief Combines mvIMPACT::acquire::cbmBinning3H and mvIMPACT::acquire::cbmBinning3V. + cbmBinning3H3V = cbmBinning3H | cbmBinning3V, + /// \brief Horizontal Binning with average (combines 2 adjacent columns and averages the result). + cbmBinningHAvg = 0x101, + /// \brief Vertical Binning with average (combines 2 adjacent rows and averages the result). + cbmBinningVAvg = 0x102, + /// \brief Combines mvIMPACT::acquire::cbmBinningH and mvIMPACT::acquire::cbmBinningV. + cbmBinningHVAvg = cbmBinningHAvg | cbmBinningVAvg, + /// \brief Horizontal Binning with average (combines 4 adjacent columns and averages the result). + cbmBinning3HAvg = 0x110, + /// \brief Vertical Binning with average (combines 4 adjacent rows and averages the result). + cbmBinning3VAvg = 0x120, + /// \brief Combines mvIMPACT::acquire::cbmBinning3H and mvIMPACT::acquire::cbmBinning3V. + cbmBinning3H3VAvg = cbmBinning3HAvg | cbmBinning3VAvg, + /// \brief Horizontal Dropping (drops every second column). + cbmDroppingH = 0x1001, + /// \brief Vertical Dropping (drops every second row). + cbmDroppingV = 0x1002, + /// \brief Combines mvIMPACT::acquire::cbmDroppingH and mvIMPACT::acquire::cbmDroppingV. + cbmDroppingHV = cbmDroppingH | cbmDroppingV, + /// \brief Horizontal Dropping (drops 3 adjacent columns out of 4). + cbmDropping3H = 0x1010, + /// \brief Vertical Binning (drops 3 adjacent rows out of 4). + cbmDropping3V = 0x1020, + /// \brief Combines mvIMPACT::acquire::cbmDropping3H and mvIMPACT::acquire::cbmDropping3V. + cbmDropping3H3V = cbmDropping3H | cbmDropping3V +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines the data format the camera is sending. +/// \ingroup CommonInterface +enum TCameraDataFormat +//----------------------------------------------------------------------------- +{ + /// \brief This is an unknown type. + cdfUnknown = 0, + /// \brief This is a mono data format. + cdfMono, + /// \brief This is a Bayer format. + cdfBayer, + /// \brief This is a Bayer Packed format. For each object line there is a red and a blue raw line to calculate the resulting color line. + cdfBayerPacked, + /// \brief This is a RGB format. + cdfRGB, + /// \brief This is a YUV format. + cdfYUV +}; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines recognized camera sensor expose modes. +/// \ingroup DeviceSpecificInterface +enum TCameraExposeMode +//----------------------------------------------------------------------------- +{ + /// \brief Standard sequential mode. + /** + * In this mode the sensor first is exposed and then afterwards the image readout + * is performed. + */ + cemStandard = 0, + /// \brief Overlapped mode, expose during image readout. + /** + * This only affects the behaviour of the acquisition in mvIMPACT::acquire::TCameraTriggerMode + * is set to mvIMPACT::acquire::ctmContinuous. + * + * In this mode the flash output should NOT be used. In any case the flash output will NOT + * work like in mvIMPACT::acquire::cemStandard but only a short pulse will be sent to + * the output. + */ + cemOverlapped, + /// \brief 'No shutter' mode, switch off exposure control. + /** + * This only affects the behaviour of the acquisition in mvIMPACT::acquire::TCameraTriggerMode + * is set to mvIMPACT::acquire::ctmContinuous. In this case the shutter of the camera is + * never closed. Thus the exposure time in this mode is equal to the reciprocal value of the + * current frame rate. + */ + cemNoShutter +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Some grabbers are able to get the video signal and sync signals ( HD-IN, VD-IN ) on separate lines. The user can define this for non standard cameras. +/// \ingroup DeviceSpecificInterface +enum TCameraExternalSyncEdge +//----------------------------------------------------------------------------- +{ + // \brief The sync signal is expected within the video signal. + ceseNo = 0, + // \brief The falling edge of external sync signal is used ( HD-IN,VD-IN ) + ceseFallingEdge = 1, + // \brief The rising edge of external sync signal is used ( HD-IN,VD-IN ) + ceseRisingEdge = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Some grabbers are able to get the video signal and the sync signal on different input pins. The user can select this for non standard cameras. +/// \ingroup DeviceSpecificInterface +enum TCameraExternalSyncOutput +//----------------------------------------------------------------------------- +{ + // \brief The sync signal is expected on the selected video channel. + // If RGB is used the sync signal is expected on the 'green' channel ( SyncOnGreen ) + cesoAuto = 0, + // \brief The sync signal is expected on the first ('red') video channel ( mvTITAN-RGB only ) + cesoRed = 1, + // \brief The sync signal is expected on the second ('green') video channel ( mvTITAN-RGB only ) + cesoGreen = 2, + // \brief The sync signal is expected on the third ('blue') video channel ( mvTITAN-RGB only ) + cesoBlue = 3, + // \brief The sync signal is expected on the fourth ('extern') video channel ( mvTITAN-RGB only ) + cesoExtern = 4 +}; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid camera flash modes. +/** + * These enumeration values may be 'ored' together. + */ +/// \ingroup DeviceSpecificInterface +enum TCameraFlashMode +//----------------------------------------------------------------------------- +{ + /// \brief Do not use the cameras flash output. + cfmOff = 0, + /// \brief Output 0 will be active during the exposure period. + cfmDigout0 = 0x1, + /// \brief Output 1 will be active during the exposure period. + cfmDigout1 = 0x2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid camera flash control types. +/// \ingroup DeviceSpecificInterface +enum TCameraFlashType +//----------------------------------------------------------------------------- +{ + /// \brief Flash signal is on while the shutter is open on a frame shutter sensor or during the complete exposure period of a rolling shutter sensor. + cftStandard = 0, + /// \brief Flash signal is only on during the time all lines of a rolling shutter sensor are exposed. + /** + * This time is always smaller or equal to the time defined by mvIMPACT::acquire::cftStandard. + */ + cftRollingShutterFlash = 1, + /// \brief Flash signal is derived from the sensors internal VSync (Frame-sync. signal). + /** + * The specific timing of this signal is hardware dependent. The signal can be used to synchronise + * a master camera with a flash or another camera with a rolling shutter sensor. + */ + cftVSync = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid camera High Dynamic Range modes. +/// \ingroup DeviceSpecificInterface +enum TCameraHDRMode +//----------------------------------------------------------------------------- +{ + /// \brief Fixed HDR parameter set 0. + cHDRmFixed0 = 0, + /// \brief Fixed HDR parameter set 1. + cHDRmFixed1 = 1, + /// \brief Fixed HDR parameter set 2. + cHDRmFixed2 = 2, + /// \brief Fixed HDR parameter set 3. + cHDRmFixed3 = 3, + /// \brief Fixed HDR parameter set 4. + cHDRmFixed4 = 4, + /// \brief Fixed HDR parameter set 5. + cHDRmFixed5 = 5, + /// \brief Fixed HDR parameter set 6. + cHDRmFixed6 = 6, + /// \brief User specific HDR mode, controlled by additional parameters. + cHDRmUser = 100 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines how the camera transmits its video signal. +/// \ingroup DeviceSpecificInterface +enum TCameraInterlacedType +//----------------------------------------------------------------------------- +{ + /// \brief The video signal is transmitted non interlaced, meaning that a complete image is transferred without interruption. + citNone, + /// \brief The video signal is transferred interlaced. + /** + * Here the camera transmits the video signal in two consecutive frames that form a complete + * image. The first frame contains all the even lines (0, 2, 4, ... ) of the image, while + * the second frame contains all odd lines of the image. + */ + citInterlaced, + /// \brief The video signal is transferred interlaced with the two frames in reversed order. + /** + * Here the camera transmits the video signal in two consecutive frames that form a complete + * image. The first frame contains all the odd lines (0, 2, 4, ... ) of the image, while + * the second frame contains all even lines of the image. + */ + citInvertedInterlaced +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines how the camera transmits the DVAL signal defined in the CameraLink® standard. +/// \ingroup DeviceSpecificInterface +enum TCameraLinkDataValidMode +//----------------------------------------------------------------------------- +{ + /// \brief The camera transmits a data valid (DVAL) signal, that should be evaluated by the frame grabber. + cldvmActive = 0, + /// \brief The camera does not transmit a data valid (DVAL) signal, that should be evaluated by the frame grabber. + cldvmInactive +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid ways a camera can offer image data to a capture device. +/// \ingroup CommonInterface +enum TCameraOutput +//----------------------------------------------------------------------------- +{ + /// \brief Specifies an undefined output. + coUndefined = -1, + /// \brief Auto mode. Here the capture device tries to guess how the data is transmitted. + coAuto = 0, + /// \brief The camera will offer an analogue composite video signal. + coComposite = 1, + /// \brief The camera will offer CameraLink® Base compliant image data. + coBase = 2, + /// \brief The camera will offer digital image data. + coDigital = 3, + /// \brief The camera will offer an analogue SVideo signal. + coSVideo = 4, + /// \brief The camera will offer CameraLink® Medium compliant image data. + coMedium = 5, + /// \brief The camera will offer an analogue RGB signal. + coRGB = 6, + /// \brief Two cameras will offer two synchronous analogue signals. + co2xComposite = 7, + /// \brief Three cameras will offer three synchronous analogue signals. + co3xComposite = 8, + /// \brief Four cameras will offer four synchronous analogue signals. + co4xComposite = 9, + /// \brief The camera will offer CameraLink® Full compliant image data. + coFull = 10, + /// \brief The camera will offer serial digital interface(SDI) SD signal. + coSDSDI = 11, + /// \brief The camera will offer serial digital interface(SDI) HD signal. + coHDSDI = 12, + /// \brief The camera will offer serial digital interface(SDI) 3G signal. + co3GSDI = 13 +}; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid camera pixel frequencies. +/// \ingroup DeviceSpecificInterface +enum TCameraPixelClock +//----------------------------------------------------------------------------- +{ + /// \brief Standard sensor clocking. + /** + * This is a legacy mode used by some devices only. + */ + cpcStandard = 0, + /// \brief High speed sensor clocking. + /** + * This is a legacy mode used by some devices only. + */ + cpcHighSpeed = 1, + /// \brief 6 MHz pixel clock. + cpc6000KHz = 6000, + /// \brief 8 MHz pixel clock. + cpc8000KHz = 8000, + /// \brief 10 MHz pixel clock. + cpc10000KHz = 10000, + /// \brief 12 MHz pixel clock. + cpc12000KHz = 12000, + /// \brief 13.5 MHz pixel clock. + cpc13500KHz = 13500, + /// \brief 20 MHz pixel clock. + cpc20000KHz = 20000, + /// \brief 24 MHz pixel clock. + cpc24000KHz = 24000, + /// \brief 24.54 MHz pixel clock. + cpc24540KHz = 24540, + /// \brief 27 MHz pixel clock. + cpc27000KHz = 27000, + /// \brief 32 MHz pixel clock. + cpc32000KHz = 32000, + /// \brief 37.6 MHz pixel clock. + cpc37600KHz = 37600, + /// \brief 40 MHz pixel clock. + cpc40000KHz = 40000, + /// \brief 50 MHz pixel clock. + cpc50000KHz = 50000, + /// \brief 57.6 MHz pixel clock. + cpc57600KHz = 57600 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid scan modes for the a camera. +/// \ingroup DeviceSpecificInterface +enum TCameraScanMode +//----------------------------------------------------------------------------- +{ + /// \brief The connected camera is an area scan camera. + csmArea = 0, + /// \brief The connected camera is an line scan camera. + csmLine +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid baud rates for serial port communication between frame grabber and camera. +/// \ingroup DeviceSpecificInterface +enum TCameraSerialPortBaudRate +//----------------------------------------------------------------------------- +{ + /// \brief 9600 baud + cspbr9600 = 9600, + /// \brief 19200 baud + cspbr19200 = 19200, + /// \brief 38400 baud + cspbr38400 = 38400, + /// \brief 57600 baud + cspbr57600 = 57600, + /// \brief 115200 baud + cspbr115200 = 115200, + /// \brief 230400 baud + cspbr230400 = 230400, + /// \brief 460800 baud + cspbr460800 = 460800, + /// \brief 921600 baud + cspbr921600 = 921600 +}; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines recognized camera sensor shutter modes. +/// \ingroup DeviceSpecificInterface +enum TCameraShutterMode +//----------------------------------------------------------------------------- +{ + /// \brief Standard Frame-Shutter mode. + /** + * Start and stop of integration occurs at the same time for all pixels + */ + csmFrameShutter = 0, + /// \brief Electronic rolling shutter mode (ERS) + /** + * Start and stop of integration occurs on a line by line base. Integration time is the same for all lines bit timing is slightly different + */ + csmElectronicRollingShutter, + /// \brief Global reset release shutter (GRR) + /** + * Start of integration occurs at the same time for all pixels. End of integration happens on a line per line base like with ERS. + * This is only useful with special lighting or an mechanical extra shutter + */ + csmGlobalResetRelease, + /// \brief Start and stop of integration will happen at the same time for all pixels. Uses optimization for fast centered Readout. + csmFrameShutterWithFastCenterReadout +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Multitap cameras can transmit data in different ways. This enum can be used to define how the camera transmits a line of pixels. +/// \ingroup DeviceSpecificInterface +enum TCameraTapsXGeometry +//----------------------------------------------------------------------------- +{ + /// \brief One tap. Pixels are transmitted from left to right. + cltxg1X = 0, + /// \brief Two taps. Pixels are transmitted from left to right. + /** + * Adjacent pixels are transmitted with one pixel clock. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2
112
234
.........
W/2W-1W
+ */ + cltxg1X2 = 1, + /// \brief Two taps. Sorting of data needed. + /** + * The first tap will transmit the first half of each line, the second tap will transmit the second half + * of each line. Both taps will transmit pixels from left to right. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2
11W/2+1
22W/2+2
.........
W/2W/2W
+ */ + cltxg2X = 2, + /// \brief Two taps. Sorting of data needed. + /** + * The first tap will transmit the first half of each line from left to right, the second tap will transmit the + * second half of the line from right to left. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2
11W
22W-1
.........
W/2W/2W/2+1
+ */ + cltxg2XE = 3, + /// \brief Two taps. Sorting of data needed. + /** + * The first tap will transmit the first half of each line from right to left, the second tap will transmit the + * second half of the line from left to right. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2
1W/2W/2+1
2W/2-1W/2+2
.........
W/21W
+ */ + cltxg2XM = 4, + /// \brief Three taps. Pixels are transmitted from left to right. + /** + * Adjacent pixels are transmitted with one pixel clock. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3
1123
2456
............
W/3W-2W-1W
+ */ + cltxg1X3 = 5, + /// \brief Three taps. Each tap will transmit one third of each line, pixel are transmitted from left to right. Sorting of data needed. + /** + * The first tap will transmit the first third of each line, the second tap will transmit the second third and the third tap will transmit the + * last third of each line from left to right. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3
11W/3+12W/3+1
22W/3+22W/3+2
............
W/3W/32W/3W
+ */ + cltxg3X = 6, + /// \brief Four taps. Pixels are transmitted from left to right. + /** + * Adjacent pixels are transmitted with one pixel clock. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4
11234
25678
...............
W/4W-3W-2W-1W
+ */ + cltxg1X4 = 7, + /// \brief Four taps. Each tap will transmit one fourth of each line, pixel are transmitted from left to right. Sorting of data needed. + /** + * The first tap will transmit the first quarter of each line, the second tap will transmit the second quarter etc. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4
11W/4+12W/4+13W/4+1
22W/4+22W/4+23W/4+2
...............
W/4W/42W/43W/4W
+ */ + cltxg4X = 8, + /// \brief Four taps. The first two taps will transmit the first half of the line, while the second two taps will transmit the second half of the line. Sorting of data needed. + /** + * Both tap pairs will transmit their data from left to right. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4
112W/2+1W/2+2
234W/2+3W/2+4
...............
W/4W/2-1W/2W-1W
+ */ + cltxg2X2 = 9, + /// \brief Four taps. The first two taps will transmit the first half of the line, while the second two taps will transmit the second half of the line. Sorting of data needed. + /** + * The first tap pair will transmit the data from left to right, while the second pair of taps will transfer the data from right to left. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4
112W-1W
234W-3W-2
...............
W/4W/2-1W/2W/2+1W/2+2
+ */ + cltxg2X2E = 10, + /// \brief Four taps. The first two taps will transmit the first half of the line, while the second two taps will transmit the second half of the line. Sorting of data needed. + /** + * The first tap pair will transmit the data from right to left, while the second pair of taps will transfer the data from left to right. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4
1W/2-1W/2W/2+1W/2+2
2W/2-3W/2-2W/2+3W/2+4
...............
W/412W-1W
+ */ + cltxg2X2M = 11, + /// \brief Four taps. Each tap will transmit one quarter of the image. Sorting of data needed. + /** + * The first two taps will transmit the data from left to right, while the second two taps will transfer the data from right to left. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4
11W/4+13W/4W
22W/4+23W/4-1W-1
...............
W/4W/4W/2W/2+13W/4+1
+ */ + cltxg4XE = 12, + /// \brief Eight taps. Pixels are transmitted from left to right. + /** + * Adjacent pixels are transmitted with one pixel clock. + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4Pixel from Tap 5Pixel from Tap 6Pixel from Tap 7Pixel from Tap 8
112345678
2910111213141516
...........................
W/8W-7W-6W-5W-4W-3W-2W-1W
+ */ + cltxg1X8 = 13, + /// \brief Eight taps. Each tap will transmit one eighth of each line, pixel are transmitted from left to right. Sorting of data needed. + /** + * The first tap will transmit the first eighth of each line, the second tap will transmit the second eighth etc. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4Pixel from Tap 5Pixel from Tap 6Pixel from Tap 7Pixel from Tap 8
11W/8+12W/8+13W/8+14W/8+15W/8+16W/8+17W/8+1
22W/8+22W/8+23W/8+24W/8+25W/8+26W/8+27W/8+2
...........................
W/8W/82W/83W/84W/85W/86W/87W/8W
+ */ + cltxg8X = 14, + /// \brief Eight taps. Every two taps will transmit one quarter of the line. Sorting of data needed. + /** + * All tap pairs will transmit their data from left to right. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4Pixel from Tap 5Pixel from Tap 6Pixel from Tap 7Pixel from Tap 8
112W/4+1W/4+2W/2+1W/2+23W/4+13W/4+2
234W/4+3W/4+4W/2+3W/2+43W/4+33W/4+4
...........................
W/8W/4-1W/4W/2-1W/23W/4-13W/4W-1W
+ */ + cltxg4X2 = 15, + /// \brief Eight taps. Every two taps will transmit one quarter of the line. Sorting of data needed. + /** + * Taps 1 to 4 will transmit the data from left to right, while taps 5 to 8 will transmit the data from right to left. + * + * + * + * + * + * + * + *
clock cyclePixel from Tap 1Pixel from Tap 2Pixel from Tap 3Pixel from Tap 4Pixel from Tap 5Pixel from Tap 6Pixel from Tap 7Pixel from Tap 8
112W/4+1W/4+23W/4-13W/4W-1W
234W/4+3W/4+43W/4-33W/4-2W-3W-2
...........................
W/8W/4-1W/4W/2-1W/2W/2+1W/2+23W/4+13W/4+2
+ * + * \since 2.4.0 + */ + cltxg4X2E = 16 +}; + +//----------------------------------------------------------------------------- +/// \brief Multi-tap cameras can transmit data in different ways. This enumeration can be used to +/// define how the camera transmits the lines of pixels. +/// \ingroup DeviceSpecificInterface +enum TCameraTapsYGeometry +//----------------------------------------------------------------------------- +{ + /// \brief Lines from top to bottom. + cltyg1Y = 0, + /// \brief Two neighbouring lines are transmitted during one FVAL + cltyg1Y2 = 1, + /// \brief One line from top and one line from bottom are transmitted during one FVAL + cltyg2YE = 2 +}; + +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid transmission modes for the camera. +/// \ingroup DeviceSpecificInterface +enum TCameraTestMode +//----------------------------------------------------------------------------- +{ + /// \brief The 'normal' camera image will be transmitted. + ctmOff = 0, + /// \brief A grey gradient will be transmitted by the camera. + ctmGreyRamp = 1, + /// \brief A color test image with some moving components in it will be displayed. + ctmMovingColor = 2, + /// \brief A raw white Bayer image will be transmitted. + ctmWBTest = 3 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid camera sensor trigger modes. +/** + * \anchor TCameraTriggerMode_Enum + */ +/// \ingroup DeviceSpecificInterface +enum TCameraTriggerMode +//----------------------------------------------------------------------------- +{ + /// \brief Don't wait for trigger. In this mode the camera continuously exposes images with the current settings. + /** + * However images are not transferred to the host system automatically in this mode, + * so NO CPU load or whatsoever is produced in this mode when the driver isn't asked + * for images by the user. + * + * This mode is recommended for most applications and will be available for every image sensor. + * + * When the user requests an image the image AFTER the next frame start will be returned. + * In applications that need fast but NOT continuous image transfer the mvIMPACT::acquire::ctmOnDemand + * therefore might be more interesting. + */ + ctmContinuous = 0, + /// \brief Start frame expose when the software asks for an image. + /** + * Here without image requests by the user the image sensor will not expose images. An exposure + * and image transmission will start immediately after at least one images has been requested + * by the user. + * + * When e.g. a camera in free running mode captures 30 images per sec. and the user needs + * an image every 40 ms (25 fps) this mode might be more suitable than mvIMPACT::acquire::ctmContinuous + * as in the continuous mode when asking for an image every 40 ms the user might need to wait + * for the next frame start which at 30 Hz in the worst case would result in a capture time + * of (1/30Hz)*2 = 66.6 ms when an image start has just been missed. In + * mvIMPACT::acquire::ctmOnDemand however the image exposure will be started immediately + * after the request reaches the camera thus no delay will be introduced. + * + * \note + * In applications where the capture time can be disregarded because either the transfer time is + * much higher or the capture frequency is very low the difference between the + * mvIMPACT::acquire::ctmOnDemand and the mvIMPACT::acquire::ctmContinuous can + * be disregarded as well. However in this case mvIMPACT::acquire::ctmContinuous is recommended + * as this mode will be available for every sensor type and is more universal. + */ + ctmOnDemand, + /// \brief Start the exposure of a frame when the trigger input is below the trigger threshold. + /** + * Each time an image is requested and the trigger signal is below the trigger threshold a image will be captured. + */ + ctmOnLowLevel, + /// \brief Start the exposure of a frame when the trigger input is above the trigger threshold. + /** + * Each time an image is requested and the trigger signal is above the trigger threshold a image will be captured. + */ + ctmOnHighLevel, + /// \brief Start the exposure of a frame when the trigger input level changes from high to low. + ctmOnFallingEdge, + /// \brief Start the exposure of a frame when the trigger input level changes from low to high. + ctmOnRisingEdge, + /// \brief Start frame expose when the trigger input level rises above the trigger threshold and + /// expose while the trigger input level remains above this threshold. + ctmOnHighExpose, + /// \brief Start frame expose when the trigger input level falls below the trigger threshold and + /// expose while the trigger input level remains below this threshold. + ctmOnLowExpose, + /// \brief Start the exposure of a frame when the trigger input level changes from high to low or from low to high. + ctmOnAnyEdge, + /// \brief Start the exposure of a frame when the trigger input level changes from high to low or from low to high. + /** + * This mode is behaves like ctmContinuous but allows the FPS-Rate to be controlled directly. + */ + ctmFramerateControlled +}; + +//----------------------------------------------------------------------------- +/// \brief Defined valid camera sensor trigger source values. +/// \ingroup DeviceSpecificInterface +enum TCameraTriggerSource +//----------------------------------------------------------------------------- +{ + /// \brief Uses digital input 0 as the source for the trigger signal. + ctsDigIn0 = 0, + /// \brief Use digital input 1 as the source for the trigger signal. + ctsDigIn1, + /// \brief Use real time controller (RTCtrl) as the source for the trigger signal. + ctsRTCtrl, + /// \brief Uses digital output 0 as the source for the trigger signal (this allows a SW controlled trigger (or exposure)). + ctsDigOut0, + /// \brief Uses digital output 1 as the source for the trigger signal (this allows a SW controlled trigger (or exposure)). + ctsDigOut1, + /// \brief Uses digital output 2 as the source for the trigger signal (this allows a SW controlled trigger (or exposure)). + ctsDigOut2, + /// \brief Uses digital output 3 as the source for the trigger signal (this allows a SW controlled trigger (or exposure)). + ctsDigOut3 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for channel split filters. +/// \ingroup CommonInterface +enum TChannelSplitMode +//----------------------------------------------------------------------------- +{ + /// \brief The channels will be re-arranged one after the other thus the resulting image will have the same width but 'channel count' times more lines than the input image. + csmVertical, + /// \brief The channels will be re-arranged next to each other thus the resulting image will have the same height but 'channel count' times more pixels per line. + csmHorizontal, + /// \brief Only one selectable channel will be extracted and forwarded. + csmExtractSingle +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Clamp signal means, that an AC coupled video signal is clamped on the porch to get a signal transfer with less noise and independent from the d.c. voltage portion. +/** + * The clamp pulse width is always 0.5 micro sec. + */ +/// \ingroup DeviceSpecificInterface +enum TClampMode +//----------------------------------------------------------------------------- +{ + /// \brief Clamp pulse starts at 80 % of \b ActiveVideoAoi/X . + ecmAuto, + /// \brief The user can set the clamp start time in micro sec. after the falling edge of the video signals' VSync. + ecmUser +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid values for input color correction matrices. +/** + * \since 2.2.2 + */ +/// \ingroup CommonInterface +enum TColorTwistInputCorrectionMatrixMode +//----------------------------------------------------------------------------- +{ +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + MV_CUSTOM_COLOR_TWIST_INPUT_CORRECTION_MATRIX_MODES +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief A user defined correction matrix. + cticmmUser = 0x00010000 | 0x1000, + /// \brief A device specific internally defined correction matrix. + /** + * This will almost always be the best selection as then the driver + * internally uses the best matrix for known products. + */ + cticmmDeviceSpecific = 0x00010000 | 0x2000 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid values for output color correction matrices. +/** + * \since 2.2.2 + */ +/// \ingroup CommonInterface +enum TColorTwistOutputCorrectionMatrixMode +//----------------------------------------------------------------------------- +{ + /// \brief A user defined correction matrix. + ctocmmUser, + /// \brief Will apply the XYZ to Adobe RGB matrix with a D50 white reference. + /** + * The following matrix will be applied: + * + * + * + * + * + * + *
Row 0Row 1Row 2
1.9624274-0.6105343-0.3413404
-0.97876841.91614150.0334540
0.0286869-0.14067521.3487655
+ */ + ctocmmXYZToAdobeRGB_D50, + /// \brief Will apply the XYZ to sRGB matrix with a D50 white reference. + /** + * The following matrix will be applied: + * + * + * + * + * + * + *
Row 0Row 1Row 2
3.1338561-1.6168667-0.4906146
-0.97876841.91614150.0334540
0.0719453-0.22899141.4052427
+ */ + ctocmmXYZTosRGB_D50, + /// \brief Will apply the XYZ to White Gamut RGB matrix with a D50 white reference. + /** + * The following matrix will be applied: + * + * + * + * + * + * + *
Row 0Row 1Row 2
1.4628067-0.1840623-0.2743606
-0.5217933,1.44723810.0677227
0.0349342-0.09689301.2884099
+ */ + ctocmmXYZToWideGamutRGB_D50, + /// \brief Will apply the XYZ to Adobe RGB matrix with a D65 white reference. + /** + * The following matrix will be applied: + * + * + * + * + * + * + *
Row 0Row 1Row 2
2.0413690-0.5649464-0.3446944
-0.96926601.87601080.0415560
0.0134474-0.11838971.0154096
+ */ + ctocmmXYZToAdobeRGB_D65, + /// \brief Will apply the XYZ to sRGB matrix with a D65 white reference. + /** + * The following matrix will be applied: + * + * + * + * + * + * + *
Row 0Row 1Row 2
3.2404542-1.5371385-0.4985314
-0.96926601.87601080.0415560
0.0556434-0.20402591.0572252
+ */ + ctocmmXYZTosRGB_D65 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the color processing mode. +/// \ingroup CommonInterface +enum TColorProcessingMode +//----------------------------------------------------------------------------- +{ + /// \brief The driver decides (depending on the connected camera) what kind of color processing has to be applied. + cpmAuto = 0, + /// \brief No color processing will be performed. + cpmRaw, + /// \brief A Bayer color conversion will be applied before the image is transferred to the user. + cpmBayer, + /// \brief A Bayer to mono conversion will be applied before the image is transferred to the user. + cpmBayerToMono, + /// \brief No color processing will be performed but the packed raw Bayer data will be re-arranged within the buffer. + /** + * In the resulting image the top left quarter of the image will contain the red pixels, + * the top right quarter the blue pixels, the lower left quarter the green pixels from the + * red line and the lower right quarter the green pixels from the blue line: + * + \verbatim + // w: width, h: height + R(0, 0) R(0, 1), ... R(0, (w-1)/2) B(0, 0) B(0, 1), ... B(0, (w-1)/2) + R(1, 0) R(1, 1), ... R(1, (w-1)/2) B(1, 0) B(1, 1), ... B(1, (w-1)/2) + . + . + . + R((h-1/2), 0) R((h-1/2), 1), ... R((h-1/2), (w-1)/2) B((h-1/2), 0) B((h-1/2), 1), ... B((h-1/2), (w-1)/2) + G(R)(0, 0) G(R)(0, 1), ... G(R)(0, (w-1)/2) G(B)(0, 0) G(B)(0, 1), ... G(B)(0, (w-1)/2) + G(R)(1, 0) G(R)(1, 1), ... G(R)(1, (w-1)/2) G(B)(1, 0) G(B)(1, 1), ... G(B)(1, (w-1)/2) + . + . + . + G(R)((h-1/2), 0) G(R)((h-1/2), 1), ... G(R)((h-1/2), (w-1)/2) G(B)((h-1/2), 0) G(B)((h-1/2), 1), ... G(B)((h-1/2), (w-1)/2) + \endverbatim + */ + cpmRawToPlanes +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for the dark current filter. +/// \ingroup CommonInterface +enum TDarkCurrentFilterMode +//----------------------------------------------------------------------------- +{ + /// \brief The filter is switched off. + dcfmOff = 0, + /// \brief The filter is switched on. + dcfmOn, + /// \brief The next selected number of images will be taken for calculating the dark current correction image. + /** + * In this mode after the correction image has been calculated the mode will automatically switch back to + * mvIMPACT::acquire::dcfmOff + */ + dcfmCalibrateDarkCurrent, + /// \brief In this mode whenever reaching this filter, the captured image will be replaced by the + /// last correction image, that has been created as a result of the filter being calibrated. + /** + * \since 2.5.9 + */ + dcfmTransmitCorrectionImage +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for defective pixels filter. +/// \ingroup CommonInterface +enum TDefectivePixelsFilterMode +//----------------------------------------------------------------------------- +{ + /// \brief This filter is switched off. + dpfmOff = 0, + /// \brief The filter is active, detected defective pixels will be replaced with the average value from the left and right neighbor pixel. + dpfm3x1Average, + /// \brief The filter is active, detected defective pixels will be replaced with the median value calculated from the nearest neighbors (3x3). + dpfm3x3Median, + /// \brief reset the calibration, delete all internal lists. + dpfmResetCalibration, + /// \brief Detect defective leaky pixels within the next frame captured. + /** + * These are pixels that produce a higher read out value than the average when the sensor is not exposed. + */ + dpfmCalibrateLeakyPixel, + /// \brief Detect defective cold pixels within the next frame captured. + /** + * These are pixels that produce a lower read out code than the average when the sensor is exposed to light. + */ + dpfmCalibrateColdPixel, + /// \brief Detect defective hot pixels within the next frame captured. + /** + * These are pixels that produce a higher read out code than the average when the sensor is exposed to light. + * + * \since 2.31.0 + */ + dpfmCalibrateHotPixel, + /// \brief Detect defective hot and cold pixels within the next frame captured. + /** + * These are pixels that produce either a higher or a lower read out code than the average when the sensor is exposed to light. This + * effectively combines mvIMPACT::acquire::dpfmCalibrateColdPixel and mvIMPACT::acquire::dpfmCalibrateHotPixel + * + * \since 2.31.0 + */ + dpfmCalibrateHotAndColdPixel, + /// \brief The filter is active, detected defective pixel will be replaced and treated as being fed into a 3x3 de-Bayer algorithm before reaching the filter. + /** + * This is a rather special mode that only makes sense for very specific use cases: + * - Defective pixel data has been obtained by the filter from a device that did carry this data within it's non-volatile memory, + * the device itself does NOT provide a defective pixel replacement functionality and the device is + * operated in RGB or YUV mode using a 3 by 3 filter kernel. This will introduce artifacts in the pixels surrounding the defective pixel then and + * to compensate that a special handling is needed. + * - To reduce CPU load another use case might be to detect defective pixels on a device in Bayer mode using the defective pixel filter of this + * SDK and then switch the device into RGB mode if supported. Again this is only needed if the device itself does not offer a defective + * pixel compensation. + * + * A far better way to tackle this of course would be (in that order): + * - Compensate the defective pixels on the device BEFORE feeding the data into the Bayer filter + * - Switch the device to a Bayer format, compensate the defective pixels on the host and THEN feed the data into a host-based Bayer filter + * - Select a device with less defective pixels if these are causing harm to the application + * + * This mode will only operate on packed RGB or packed YUV444 data! It will assume that when given a pixel \a p all the surrounding pixels marked with a \a d in the following + * section need to be replaced as well(\a - stands for other pixels \b NOT affected by the replacement operation): + * + * \code + * --------------- + * --------------- + * ----ddd-------- + * ----dpd-------- + * ----ddd-------- + * --------------- + * \endcode + * + * \since 2.33.0 + */ + dpfmReplaceDefectivePixelAfter3x3Filter +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid device access modes. +/// \ingroup CommonInterface +enum TDeviceAccessMode +//----------------------------------------------------------------------------- +{ + /// \brief Unknown device access mode. + damUnknown, + /// \brief No access to the device. + damNone, + /// \brief Requested or obtained read access to the device. + /** + * Properties can be read but can't be changed. + */ + damRead, + /// \brief Requested or obtained control access to the device. + /** + * Properties can be read and changed, other applications might establish read + * access. + */ + damControl, + /// \brief Requested or obtained exclusive access to the device. + /** + * Properties can be read and changed, other applications can't establish access to the device. + */ + damExclusive +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid advanced options +/** + * These enums may be 'ored' together. + */ +/// \ingroup DeviceSpecificInterface +enum TDeviceAdvancedOptions // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief No advanced option selected. + daoOff = 0, + /// \brief Put camera in low light mode. + /** + * This is a special feature offered by some sensors. Typically this will enable an additional analogue + * gain that will increase both the luminance and the noise of the resulting image. This feature can not + * be configured any further and there also is no additional information available on this topic. + */ + daoLowLight = 0x1, + /// \brief Embed sensor specific info into the image readout buffer. + daoEmbeddedImageInfo = 0x2, + /// \brief Calculate the average intensity value of the image and return as part of the request. + daoImageAverage = 0x4, + /// \brief Enable pipelined Gain/Exposure control. + /** + * This will result in a changed exposure or gain value becoming active not with the next frame but the one after that. + * Changing Gain/Exposure will be faster in pipelined Gain/Exposure control mode. + * \since 2.1.3 + */ + daoPipelinedGainExposeControl = 0x8, + /// \brief Enable on demand trigger pre-shot option. + /** + * This will trigger an internal image capture cycle on the sensor prior to the user requested frame. + * Can be used to remove variations in image quality when working with unstable frame rates. + * \since 2.5.0 + */ + daoOnDemandTriggerPreShot = 0x10, + /// \brief Enable low frame rate optimization. + /** + * This will result in a much reduced variation in the offset signal when changing the sensor frame rate or running + * the sensor at low frame rates. The offset will change slightly if switched on and the signal response is slightly reduced. + */ + daoLowFrameRateOptimization = 0x20, + /// \brief Enable per channel offset correction. + /** + * Allow per channel offset correction in non auto offset mode for sensors with a Bayer (RGGB) based analog path. + * The per channel offset value will be added to the master offset (Offset_pc). + */ + daoEnablePerChannelOffsetCorrection = 0x40, + /// \brief Enable raw sensor gain. + /** + * Use mathematical correct gain for sensor setting. Thus increasing the gain by 6 dB will actually result in a factor of 2. + * However with this option enabled the gain range will include values so low that the pixel saturation charge will + * be with in ADC digitizer range thus an over-saturated image will contain pixels that do \b NOT contain the maximum + * value for the given pixel format. + * \since 2.5.6 + */ + daoUseRawSensorGain = 0x80, + /// \brief Trigger sensor column correction. + /** + * When switched on this triggers a single column correction calibration process when requesting an image. + * To do it again switch it off and on again. This should be done while no acquisition is running. + * Changing gain or AOI could make such a recalibration necessary. + */ + daoTriggerSensorColumnCalibration = 0x100 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the way the packet size auto negotiation is handled for GigE Vision devices. +/** + * All modes will eventually result in the optimal packet value. However depending on the network + * setup one method might be faster than another. + */ +/// \ingroup CommonInterface +enum TDeviceAutoNegotiatePacketSizeMode +//----------------------------------------------------------------------------- +{ + /// \brief Start with the maximum possible packet size. + /** + * If set to mvIMPACT::acquire::danpsmHighToLow the packet size auto negotiation starts with the NICs current MTU value. If this value is too + * large (in terms of not all network components support it) decreasing sizes will be tried until the optimal (thus highest value supported by all + * network components) has been found. + * + * \note This mode is optimal when working with network interfaces where Jumbo frames are enabled. + */ + danpsmHighToLow, + /// \brief Start with the minimal possible packet size. + /** + * If set to mvIMPACT::acquire::danpsmLowToHigh the packet size auto negotiation starts with the smallest possible MTU. Afterwards increasing sizes + * will be tried until the optimal (thus highest value supported by all network components) has been found. + * + * \note This mode is optimal when nothing is known about the network configuration. + */ + danpsmLowToHigh +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid device capabilities. +/** + * Values of these enum type may be 'OR'ed together. + */ +/// \ingroup CommonInterface +enum TDeviceCapability // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief A dummy constant to indicate, that this device does not have any capabilities defined by other constants belonging to this enumeration. + dcNone = 0x0, + /// \brief This is a device that supports hot plugging. + dcHotplugable = 0x1, + /// \brief This is a device, that has more than one video input channel. + dcSelectableVideoInputs = 0x2, + /// \brief This device has non volatile memory, the user can write to and read from. + dcNonVolatileUserMemory = 0x4, + /// \brief This device supports camera descriptions. + /** + * This is a feature mainly interesting for frame grabbers. + */ + dcCameraDescriptionSupport = 0x8, + /// \brief This device supports events. + dcEventSupport = 0x10 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid generic device classes. +/// \ingroup CommonInterface +enum TDeviceClass +//----------------------------------------------------------------------------- +{ + /// \brief A generic device + dcGeneric, + /// \brief A plain camera device + dcCamera, + /// \brief An intelligent camera device + dcIntelligentCamera, + /// \brief A frame grabber device + dcFrameGrabber, + /// \brief A 3D camera + dc3DCamera +}; + +//----------------------------------------------------------------------------- +/// \brief Defines grabber specific digital output modes. +/// \ingroup DeviceSpecificInterface +enum TDeviceDigitalOutputMode +//----------------------------------------------------------------------------- +{ + /// \brief The digital output can be switched manually. + ddomManual = 0, + /// \brief A single pulse will be generated on the digital output. + ddomPulse, + /// \brief A user defined signal will be generated on the digital output. + ddomUser, + /// \brief The digital output will change its state during the active exposure period of the image sensor and will switch back to its initial state again once the exposure period is over. + ddomExposureActive, + /// \brief A signal connected to a digital input is passed through to this digital output. + ddomDigitalSignalPassThrough, + /// \brief A signal connected to a digital input is inverted and passed to this digital output. + ddomDigitalSignalPassThroughInv, + /// \brief An internal VD sync. signal will be passed to this digital output. + /** + * In case of a camera this e.g. might be the cameras internal VD signal. This then can be used to + * synchronize two or more cameras. + */ + ddomInternalVD, + /// \brief The digital output is controlled by a Real Time Controller. + ddomRealTimeController, + /// \brief When there is at least one outstanding request the digital output will change its state during the active exposure period of the image sensor and will switch back to its initial state again once the exposure period is over. + ddomExposureAndAcquisitionActive, + /// \brief Will change the state whenever the device temperature moves in or out of defined limits(subject to change!). + ddomTemperatureOutOfRange +}; + +#if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +//----------------------------------------------------------------------------- +/// \brief Defines valid event states. +/** + * A driver might offer to inform the user about certain events that occur + * at runtime. This e.g. might be unplugging the device if it's PnP compliant or + * the detection of a digital input change. + */ +/// \ingroup CommonInterface +enum TDeviceEventMode +//----------------------------------------------------------------------------- +{ + /// \brief This event won't be signaled in this state even if the underlying event has been noticed by the device driver. + demIgnore, + /// \brief This event will be notified whenever the underlying event has been detected by the device driver. + demNotify +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid device event types. +/** + * \note + * Not every device will support every event. + * + * \deprecated + * This enumeration belongs to a set of functions and data types that have been declared + * deprecated and will be removed in future versions of this interface. + * A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. Look for an example + * called \a Callback to find out how to use it. + */ +/// \ingroup CommonInterface +enum TDeviceEventType // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief A dummy constant to specify \a no event where an event type must be specified. + detNone = 0, + /// \brief An event of this type will be signaled (if desired) each time a hotplug compliant device recognized by the mvIMPACT acquire device manager has been connected to the system(deprecated). + /** + * \deprecated + * This event has been declared deprecated. An application should register a callback + * to the state property instead. + */ + detPnPArrival = 0x1, + /// \brief An event of this type will be signaled (if desired) each time a hotplug compliant device recognized by the mvIMPACT acquire device manager has been disconnected to the system(deprecated). + /** + * \deprecated + * This event has been declared deprecated. An application should register a callback + * to the state property instead. + */ + detPnPRemoval = 0x2, + /// \brief An event of this type will be signaled (if desired) each time the start of a new image has been detected by the device. + /** + * \note + * This is currently only supported by mvTITAN/mvGAMMA devices. + */ + detFrameStart = 0x4, + /// \brief An event of this type will be signaled (if desired) each time the histogram is calculated. + /** + * \note + * This is currently only supported by OEM devices. + */ + detHistogramReady = 0x8, + /// \brief A combination of all event types, which can be used as a mask. + detAll = detPnPArrival | detPnPRemoval | detFrameStart | detHistogramReady +}; +#endif // #if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines acquisition start event if using pulse sequences. +/// \ingroup DeviceSpecificInterface +enum TDeviceImageTrigger +//----------------------------------------------------------------------------- +{ + /// \brief Acquisition starts with trigger event as fast as possible. + ditImmediately = 0, + /// \brief Acquisition starts after all defined signals have been generated on the digital outputs. + ditAfterDigOutSignals +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid interface layouts for the device. +/** + * The device interface layout defines what kind of features will be available + * after the device driver has been opened and where these features will be + * located. Apart from that the interface layout also has impact at what time + * property values will be buffered for buffer captures. + */ +/// \ingroup CommonInterface +enum TDeviceInterfaceLayout +//----------------------------------------------------------------------------- +{ + /// \brief A device specific interface shall be used(deprecated for all GenICam compliant devices). + /** + * For most devices supported by this SDK this will be the only interface layout + * available. In this interface layout also most of the features will have + * the same name and location for every device even if a device is operated + * using another device driver. However this interface layout requires the + * driver to have detailed information about the underlying hardware, thus + * it will not be available for any third party hardware which might be usable with + * a certain device driver. + * + * In contrast to the other interface layouts, this layout will use a \a buffered \a property + * \a approach. This means that consecutive buffers can be requested each using defined but + * different settings. At the time of requesting a buffer, the driver will internally store the + * current property settings and will re-program the hardware later at the time of processing + * this request if the current settings differ from the settings that shall be used for this request. + * + * \deprecated + * This interface layout has been declared deprecated for GenICam compliant devices(mvBlueCOUGAR-S, + * mvBlueCOUGAR-X and mvBlueCOUGAR-XD). For these products please use mvIMPACT::acquire::dilGenICam + * instead. Newer devices like the mvBlueFOX3 will not support this interface layout at all. + * + * \sa \ref InterfaceLayouts_Differences. + */ + dilDeviceSpecific = 1, + /// \brief A GenICam™ like interface layout shall be used. + /** + * This interface layout will be available when a device is + * (or claims to be) compliant with a the GenICam™ standard, thus provides a GenICam™ + * compliant XML interface description. This also applies for third party devices, which can + * be used with the GenICam GenTL Producer of mvIMPACT Acquire. + * + * In this interface layout property value changes will always have immediate effect, thus when + * changing the exposure time directly \b after requesting a buffer this buffer might be captured + * with the new exposure time already depending on the time the buffer request is actually be processed. + * + * \note This interface layout will allow to access third party devices as well. + * + * \sa \ref InterfaceLayouts \n + * \ref InterfaceLayouts_Differences. + */ + dilGenICam = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for the loading of settings during initialization. +/** + * Whenever a mvIMPACT::acquire::Device is initialized this enumeration type defines the mode the + * mvIMPACT::acquire::Device tries to restore settings from a previously stored session. + */ +/// \ingroup CommonInterface +enum TDeviceLoadSettings +//----------------------------------------------------------------------------- +{ + /// \brief Tries to load settings automatically following an internal procedure. + /** + * The load cycle at initialization time is like this: + * + * \code + * look for a setting for this particular device (via serial number) + * if not found + * look for a setting for this device type (via string in property 'Product' ) + * if not found + * look for a setting for this device family (via string in property 'Family' ) + * if not found + * use the default settings + * \endcode + * + * Under Linux® the current directory will be searched for files named <serialNumber>.xml, + * <productString>.xml and <familyString.xml> while under Windows® the registry will + * be searched for keys with these names. This only happens once (when the device is opened) + */ + dlsAuto = 0, + /// \brief No stored settings will be loaded at start-up. The device will be initialized with the drivers default values. + dlsNoLoad +}; + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines the power mode for this device. +/// \ingroup DeviceSpecificInterface +enum TDevicePowerMode +//----------------------------------------------------------------------------- +{ + /// \brief This device is switched on + dpmOn, + /// \brief This device is switched off. + /** + * This might save a considerable amount of energy if the device isn't + * needed for a certain amount of time. + */ + dpmOff +}; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid device scan rate mode. +/// \ingroup DeviceSpecificInterface +enum TDeviceScanRateMode +//----------------------------------------------------------------------------- +{ + /// \brief Auto, scan rate of camera used. + dsrmAuto, + /// \brief User, scan rate must be set manually. + dsrmUser +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid moments to start the signal generation on the digital outputs. +/// \ingroup DeviceSpecificInterface +enum TDeviceSignalOutputStartEvent +//----------------------------------------------------------------------------- +{ + /// \brief The signal generation on the digital outputs starts with the next frame start signal ( e.g.: VSync ). + dsoseFrame, + /// \brief The signal generation on the digital outputs starts with the event defined in setting->camera->trigger. + dsoseTrigger, + /// \brief The signal generation on the digital outputs starts with next frame signal after the event defined in setting->camera->trigger. + dsoseFrameAfterTrigger, + /// \brief The signal generation on the digital outputs starts with the rising edge of SyncIn - signal. CameraLink® only!!! + dsoseSyncInRisingEdge, + /// \brief The signal generation on the digital outputs starts with the falling edge of SyncIn - signal. CameraLink® only!!! + dsoseSyncInFallingEdge, + /// \brief The SyncIn - signal is passed to the selected digital output. CameraLink® only!!! + dsoseSyncInPassThrough, + /// \brief The SyncIn - signal is inverted and passed to the selected digital output. CameraLink® only!!! + dsoseSyncInPassThroughInv, + /// \brief The signal generation on the digital outputs starts periodically. CameraLink® only!!! + dsosePeriodically, + /// \brief The TriggerIn - signal is passed to the selected digital output. CameraLink® only!!! + dsoseTriggerInPassThrough, + /// \brief The TriggerIn - signal is inverted and passed to the selected digital output. CameraLink® only!!! + dsoseTriggerInPassThroughInv, + /// \brief The FVAL - signal is passed to the selected digital output. CameraLink® only!!! + dsoseFVALPassThrough, + /// \brief The FVAL - signal is inverted and passed to the selected digital output. CameraLink® only!!! + dsoseFVALPassThroughInv, + /// \brief The signal generation on the digital outputs starts with the rising edge of FVAL - signal. CameraLink® only!!! + dsoseFVALRisingEdge +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid Device states. +/// \ingroup CommonInterface +enum TDeviceState +//----------------------------------------------------------------------------- +{ + /// \brief The mvIMPACT::acquire::Device has been unplugged. + /** + * The mvIMPACT::acquire::Device has present been since the mvIMPACT::acquire::DeviceManager has been initialized, + * but has been unplugged now and the driver has detected the unplugging of the device. Automatic detection of unplugging events + * is only possible for devices that support plug and play, other device drivers will only check if a device is still present + * if an application triggered this check. + */ + dsAbsent = 0, + /// \brief The mvIMPACT::acquire::Device is currently connected and initialized. + dsPresent, + /// \brief The mvIMPACT::acquire::Device is connected and is currently initializing. + dsInitializing, + /// \brief This device is recognized, but can't be accessed currently. + /** + * This e.g. can be the case, if this is a device connected via a network and the device + * does not respond to one of the recognized network protocols or if another client is already + * connected to this device and the device does not support multiple clients. + */ + dsUnreachable, + /// \brief This device is present, but currently switched into a low power consumption mode + dsPowerDown +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Valid sync. signal output modes for frame grabbers. +/** + * Currently only mvTITAN-RGB boards support this feature. + */ +/// \ingroup DeviceSpecificInterface +enum TDeviceSyncOutMode +//----------------------------------------------------------------------------- +{ + /// \brief Sync. signals off. + dsomOff = 0, + /// \brief A non interlaced HD-out/VD-out signal is generated. + dsomNonInterlaced, + /// \brief A interlaced HD-out/VD-out signal is generated. + dsomInterlaced +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines which trigger interface is currently active for the device. +/** + * A device might offer different views on the properties that can be used to + * configure trigger signals and events. + */ +/// \ingroup DeviceSpecificInterface +enum TDeviceTriggerInterface +//----------------------------------------------------------------------------- +{ + /// \brief The standard trigger interface. + /** + * When this trigger interface is used, the configuration of an external trigger + * signal can be done very easy. However more complex scenarios might not be + * possible using this view on the trigger configuration. + */ + dtiStandard = 0, + /// \brief The advanced view on the trigger interface. + /** + * When this view on the interface is selected, all features offered by the device + * regarding the creation of trigger events will be visible. So more complex configurations are possible + * but more knowledge about the hardware is required as well. + */ + dtiAdvanced +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Valid trigger modes for frame grabber boards. +/// \ingroup DeviceSpecificInterface +enum TDeviceTriggerMode +//----------------------------------------------------------------------------- +{ + /// \brief Trigger off + dtmOff = 0, + /// \brief Trigger on + dtmOn, + /// \brief Trigger on falling edge of an external signal. + dtmFallingEdge, + /// \brief Trigger on rising edge of an external signal. + dtmRisingEdge, + /// \brief Timer is used to simulate trigger. + dtmPeriodically, + /// \brief Request simulates trigger. + dtmOnDemand, + /// \brief Line scan mode: Acquisition starts with rising edge and stops with falling edge of trigger ( mvTITAN/mvGAMMA-CL only ) + dtmStartRisingStopFalling, + /// \brief Line scan mode: Acquisition starts with falling edge and stops with rising edge of trigger ( mvTITAN/mvGAMMA-CL only ) + dtmStartFallingStopRising, + /// \brief Trigger valid as long as the level of the source signal is high. + dtmLevelHigh, + /// \brief Trigger valid as long as the level of the source signal is low. + dtmLevelLow +}; + +//----------------------------------------------------------------------------- +/// \brief Specifies the type trigger overlap permitted with the previous frame. +/** + * This defines when a valid trigger will be accepted (or latched) for a new frame. + */ +/// \ingroup DeviceSpecificInterface +enum TDeviceTriggerOverlap // long_type +//----------------------------------------------------------------------------- +{ + /// \brief No trigger overlap is permitted. + dtoOff, + /// \brief Trigger is accepted immediately after the exposure period. + dtoReadOut, + /// \brief Trigger is accepted at any time during the capture of the previous frame. + dtoPreviousFrame +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid digital I/O states. +/// \ingroup DeviceSpecificInterface +enum TDigIOState +//----------------------------------------------------------------------------- +{ + /// \brief Digital I/O is in 'logic 0' state. + digioOff = 0, + /// \brief Digital I/O is in 'logic 1' state. + digioOn = 1, + /// \brief Digital Input is in 'ignore' state. + digioIgnore = 2, + /// \brief Digital Output is kept in unchanged state. + digioKeep = 3 +}; + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid IO Measurement Modes. +/** + * The shorter the gate time the faster results will be available. However a + * shorter gate time will also result in a less accurate measurement. + */ +/// \ingroup DeviceSpecificInterface +enum TDigitalIOMeasurementMode +//----------------------------------------------------------------------------- +{ + /// \brief Measure frequency with a 10 ms gate time. + diommFrequency_Hz_10ms = 0, + /// \brief Measure frequency with a 100 ms gate time. + diommFrequency_Hz_100ms +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid IO Measurement Sources. +/** + * This will define where the actual measurement will take place. + */ +/// \ingroup DeviceSpecificInterface +enum TDigitalIOMeasurementSource +//----------------------------------------------------------------------------- +{ + /// \brief Measurement will be done on digital input 0. + diomsInput0 = 0, + /// \brief Measurement will be done on digital input 1. + diomsInput1 = 1, + /// \brief Measurement will be done on digital input 2. + diomsInput2 = 2, + /// \brief Measurement will be done on digital input 3. + diomsInput3 = 3 +}; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid ways to create signals on a digital output. +/// \ingroup DeviceSpecificInterface +enum TDigitalOutputControlMode +//----------------------------------------------------------------------------- +{ + /// \brief The digital output signal is generated by the on-board processor. + docmSoftware = 0, + /// \brief The digital output signal is generated by a Real Time Controller that is part of the used hardware device. + docmRTC +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid digital source signal constants that can be used to configure a devices behaviour in certain digital I/O related modes. +/** + * As these parameters are highly device dependent, no direct name like + * \a dsTriggerJ8/12 are defined here. However when the translation dictionary for + * a property with this type is queried, the string representation for the + * enumeration value will contain a more descriptive name for the digital signal. + */ +/// \ingroup DeviceSpecificInterface +enum TDigitalSignal // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief A dummy value to delete a mask or signal configuration. + dsNone = 0x00000000, + /// \brief A constant for digital signal 1. + dsSignal1 = 0x00000001, + /// \brief A constant for digital signal 2. + dsSignal2 = 0x00000002, + /// \brief A constant for digital signal 3. + dsSignal3 = 0x00000004, + /// \brief A constant for digital signal 4. + dsSignal4 = 0x00000008, + /// \brief A constant for digital signal 5. + dsSignal5 = 0x00000010, + /// \brief A constant for digital signal 6. + dsSignal6 = 0x00000020, + /// \brief A constant for digital signal 7. + dsSignal7 = 0x00000040, + /// \brief A constant for digital signal 8. + dsSignal8 = 0x00000080, + /// \brief A constant for digital signal 9. + dsSignal9 = 0x00000100, + /// \brief A constant for digital signal 10. + dsSignal10 = 0x00000200, + /// \brief A constant for digital signal 11. + dsSignal11 = 0x00000400, + /// \brief A constant for digital signal 12. + dsSignal12 = 0x00000800, + /// \brief A constant for digital signal 13. + dsSignal13 = 0x00001000, + /// \brief A constant for digital signal 14. + dsSignal14 = 0x00002000, + /// \brief A constant for digital signal 15. + dsSignal15 = 0x00004000, + /// \brief A constant for digital signal 16. + dsSignal16 = 0x00008000 +}; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Errors reported by the device manager. +/** + * These are errors which might occur in connection with the device manager + * itself or while working with the single devices. + */ +/// \ingroup CommonInterface +enum TDMR_ERROR // no_property_type +//----------------------------------------------------------------------------- +{ + /// \brief The function call was executed successfully. + /** + * \n \b [0] + */ + DMR_NO_ERROR = 0, + /// \brief The specified device can't be found. + /** + * This error occurs either if an invalid device ID has been passed to the + * device manager or if the caller tried to close a device which currently + * isn't initialized. + * + * \n \b [-2100] + */ + DMR_DEV_NOT_FOUND = -2100, + /// \brief The device manager couldn't be initialized. + /** + * This is an internal error. + * + * \n \b [-2101] + */ + DMR_INIT_FAILED = -2101, + /// \brief The device is already in use. + /** + * This error e.g. will occur if this or another process has initialized this + * device already and an application tries to open the device once more or if a + * certain resource is available only once but shall be used twice. + * + * \n \b [-2102] + */ + DMR_DRV_ALREADY_IN_USE = -2102, + /// \brief The specified device couldn't be initialized. + /** + * \n \b [-2103] + */ + DMR_DEV_CANNOT_OPEN = -2103, + /// \brief The device manager or another module hasn't been initialized properly. + /** + * This error occurs if the user tries e.g. to close the device manager without + * having initialized it before or if a library used internally or a module or device associated with that library has not been initialized properly or if + * + * \n \b [-2104] + */ + DMR_NOT_INITIALIZED = -2104, + /// \brief A device could not be initialized. + /** + * In this case the log-file will contain detailed information about the source of the + * problem. + * + * \n \b [-2105] + */ + DMR_DRV_CANNOT_OPEN = -2105, + /// \brief The devices request queue is empty. + /** + * This error e.g. occurs if the user waits for an image request to become available at a + * result queue without having send an image request to the device before. + * + * It might also arise when trying to trigger an image with a software trigger mechanism + * before the acquisition engine has been completely started. In this case a small delay and + * then again calling the software trigger function will succeed. + * + * \n \b [-2106] + */ + DMR_DEV_REQUEST_QUEUE_EMPTY = -2106, + /// \brief A request object couldn't be created. + /** + * The creation of a request object failed. This might e.g. happen, if the system + * runs extremely low on memory. + * + * \n \b [-2107] + */ + DMR_DEV_REQUEST_CREATION_FAILED = -2107, + /// \brief An invalid parameter has been passed to a function. + /** + * This might e.g. happen if a function requiring a pointer to a structure has been passed + * an unassigned pointer or if a value has been passed, that is either too large or too small in + * that context. + * + * \n \b [-2108] + */ + DMR_INVALID_PARAMETER = -2108, + /// \brief One or more symbols needed in a detected driver library couldn't be resolved. + /** + * In most cases this is an error handled internally. So the user will not receive this error + * code as a result of a call to an API function. However when the user tries to get access + * to an IMPACT buffer type while the needed IMPACT Base libraries are not installed + * on the target system this error code also might be returned to the user. + * + * \n \b [-2109] + */ + DMR_EXPORTED_SYMBOL_NOT_FOUND = -2109, + /// \brief An unknown error occurred while processing a user called driver function. + /** + * \n \b [-2110] + */ + DEV_UNKNOWN_ERROR = -2110, + /// \brief A driver function has been called with an invalid device handle. + /** + * \n \b [-2111] + */ + DEV_HANDLE_INVALID = -2111, + /// \brief A driver function has been called but one or more of the input parameters are invalid. + /** + * There are several possible reasons for this error: + * - an unassigned pointer has been passed to a function, that requires a valid pointer + * - one or more of the passed parameters are of an incorrect type + * - one or more parameters contain an invalid value (e.g. a filename that points to a file that can't + * be found, a value, that is larger or smaller than the allowed values. + * + * \n \b [-2112] + */ + DEV_INPUT_PARAM_INVALID = -2112, + /// \brief A function has been called with an invalid number of input parameters. + /** + * \n \b [-2113] + */ + DEV_WRONG_INPUT_PARAM_COUNT = -2113, + /// \brief The creation of a setting failed. + /** + * This can either happen, when a setting with the same name as the one the user + * tried to create already exists or if the system can't allocate memory for the + * new setting. + * + * \n \b [-2114] + */ + DEV_CREATE_SETTING_FAILED = -2114, + /// \brief The unlock for a mvIMPACT::acquire::Request object failed. + /** + * This might happen, if the mvIMPACT::acquire::Request is + * not locked at the time of calling the unlock function. It either has been unlocked by the + * user already or this request has never been locked as the request so far has not been used to + * capture image data into its buffer. Another reason for this error might be that the user tries to + * unlock a request that is currently processed by the device driver. + * + * \n \b [-2115] + */ + DEV_REQUEST_CANT_BE_UNLOCKED = -2115, + /// \brief The number for the mvIMPACT::acquire::Request object is invalid. + /** + * The max. number for a mvIMPACT::acquire::Request object is + * the value of the property \a RequestCount in the mvIMPACT::acquire::SystemSettings list - 1. + * + * \n \b [-2116] + */ + DEV_INVALID_REQUEST_NUMBER = -2116, + /// \brief A Request that hasn't been unlocked has been passed back to the driver. + /** + * This error might occur if the user requested an image from the driver but hasn't + * unlocked the mvIMPACT::acquire::Request that will be used for this new + * image. + * + * \n \b [-2117] + */ + DEV_LOCKED_REQUEST_IN_QUEUE = -2117, + /// \brief The user requested a new image, but no free mvIMPACT::acquire::Request object is available to process this request. + /** + * \n \b [-2118] + */ + DEV_NO_FREE_REQUEST_AVAILABLE = -2118, + /// \brief The wait for a request failed. + /** + * This might have several reasons: + * + * • the user waited for an image, but no image has been requested before. \n + * • the user waited for a requested image, but the image is still not ready(e.g. because of + * a short timeout and a long exposure time). \n + * • a triggered image has been requested but no trigger signal has been detected within the + * wait period. \n + * • a plug and play device(e.g. an USB device) has been unplugged and therefore can't deliver + * images anymore. In this case the \a 'state' property should be checked to find out if the + * device is still present or not. \n + * + * \n \b [-2119] + */ + DEV_WAIT_FOR_REQUEST_FAILED = -2119, + /// \brief The user tried to get/set a parameter, which is not supported by this device. + /** + * \n \b [-2120] + */ + DEV_UNSUPPORTED_PARAMETER = -2120, + /// \brief The requested real time controller is not available for this device. + /** + * \n \b [-2121] + */ + DEV_INVALID_RTC_NUMBER = -2121, + /// \brief Some kind of internal error occurred. + /** + * More information can be found in the *.log-file or the debug output. + * + * \n \b [-2122] + */ + DMR_INTERNAL_ERROR = -2122, + /// \brief The user allocated input buffer is too small to accommodate the result. + /** + * \n \b [-2123] + */ + DMR_INPUT_BUFFER_TOO_SMALL = -2123, + /// \brief Some kind of internal error occurred in the device driver. + /** + * More information can be found in the *.log-file or the debug output. + * + * \n \b [-2124] + */ + DEV_INTERNAL_ERROR = -2124, + /// \brief One or more needed libraries are not installed on the system. + /** + * \n \b [-2125] + */ + DMR_LIBRARY_NOT_FOUND = -2125, + /// \brief A called function or accessed feature is not available for this device. + /** + * \n \b [-2126] + */ + DMR_FUNCTION_NOT_IMPLEMENTED = -2126, + /// \brief The feature in question is (currently) not available for this device or driver. + /** + * This might be because another feature currently blocks the one in question from being accessible. + * More information can be found in the *.log-file or the debug output. + * + * \n \b [-2127] + */ + DMR_FEATURE_NOT_AVAILABLE = -2127, + /// \brief The user is not permitted to perform the requested operation. + /** + * This e.g. might happen if the user tried to delete user data without specifying the + * required password. + * + * \n \b [-2128] + */ + DMR_EXECUTION_PROHIBITED = -2128, + /// \brief The specified file can't be found. + /** + * This might e.g. happen if the current working directory doesn't contain the file specified. + * + * \n \b [-2129] + */ + DMR_FILE_NOT_FOUND = -2129, + /// \brief The licence doesn't match the device it has been assigned to. + /** + * When e.g. upgrading a device feature each licence file is bound to a certain device. If the + * device this file has been assigned to has a different serial number then the one used + * to create the licence this error will occur. + * + * \n \b [-2130] + */ + DMR_INVALID_LICENCE = -2130, + /// \brief There is no sensor found or the found sensor type is wrong or not supported. + /** + * \n \b [-2131] + */ + DEV_SENSOR_TYPE_ERROR = -2131, + /// \brief A function call was associated with a camera description, that is invalid. + /** + * One possible reason might be, that the camera description has been deleted(driver closed?). + * + * \since 1.5.0 + * + * \n \b [-2132] + */ + DMR_CAMERA_DESCRIPTION_INVALID = -2132, + /// \brief A suitable driver library to work with the device manager has been detected, but it is too old to work with this version of the mvDeviceManager library. + /** + * This might happen if two different drivers have been installed on the target system and + * one introduces a newer version of the device manager that is not compatible with the older + * driver installed on the system. In this case this error message will be written into the + * log-file together with the name of the library that is considered to be too old. + * + * The latest drivers will always be available online under www.matrix-vision.de. There + * will always be an updated version of the library considered to be too old for download from + * here. + * + * \since 1.6.6 + * + * \n \b [-2133] + */ + DMR_NEWER_LIBRARY_REQUIRED = -2133, + /// \brief A general timeout occurred. + /** + * This is the typical result of functions that wait for some condition to be met with a timeout + * among their parameters. + * + * More information can be found in the *.log-file or the debug output. + * + * \since 1.7.2 + * + * \n \b [-2134] + */ + DMR_TIMEOUT = -2134, + /// \brief A wait operation has been aborted. + /** + * This e.g. might occur if the user waited for some message to be returned by the driver and the + * device driver has been closed within another thread. In order to inform the user that this waiting operation + * terminated in an unusual wait, mvIMPACT::acquire::DMR_WAIT_ABANDONED will be returned then. + * + * \since 1.7.2 + * + * \n \b [-2135] + */ + DMR_WAIT_ABANDONED = -2135, + /// \brief The execution of a method object or reading/writing to a feature failed. + /** + * More information can be found in the log-file. + * + * \since 1.9.0 + * + * \n \b [-2136] + */ + DMR_EXECUTION_FAILED = -2136, + /// \brief This request is currently used by the driver + /** + * This error may occur if the user tries to send a certain request object to the driver by a call to the + * corresponding image request function. + * + * \since 1.10.31 + * + * \n \b [-2137] + */ + DEV_REQUEST_ALREADY_IN_USE = -2137, + /// \brief A request has been configured to use a user supplied buffer, but the buffer pointer associated with the request is invalid. + /** + * + * \since 1.10.31 + * + * \n \b [-2138] + */ + DEV_REQUEST_BUFFER_INVALID = -2138, + /// \brief A request has been configured to use a user supplied buffer, but the buffer pointer associated with the request has an incorrect alignment. + /** + * Certain devices need aligned memory to perform efficiently thus when a user supplied buffer shall be used to + * capture data into this buffer must follow these alignment constraints + * + * \since 1.10.31 + * + * \n \b [-2139] + */ + DEV_REQUEST_BUFFER_MISALIGNED = -2139, + /// \brief The requested access to a device could not be granted. + /** + * This might e.g. happen if an application tries to access a device exclusively that is already open in another + * process. This could also happen if a network device has already been opened with control access from another system + * and the current system also tries to establish control access to the device. + * + * \since 1.10.39 + * + * \n \b [-2140] + */ + DEV_ACCESS_DENIED = -2140, + /// \brief A pre-load condition for loading a device driver failed. + /** + * Certain device drivers may depend on certain changes applied to the system in order to operate correctly. + * E.g. a device driver might need a certain environment variable to exist. When the device manager tries + * to load a device driver it performs some basic checks to detect problems like this. When one of these checks + * fails the device manager will not try to load the device driver and an error message will be written + * to the selected log outputs. + * + * \since 1.10.52 + * + * \n \b [-2141] + */ + DMR_PRELOAD_CHECK_FAILED = -2141, + /// \brief One or more of the camera descriptions parameters are invalid for the grabber it is used with. + /** + * There are multiple reasons for this error code. Detailed information can be found in the *.log-file. + * + * POSSIBLE CAUSES: + * + * • The TapsXGeometry or TapsYGeometry parameter of the selected camera description cannot be used with a user defined AOI. \n + * • A scan standard has been selected, that is not supported by this device. \n + * • An invalid scan rate has been selected. \n + * • ... \n + * + * This error code will be returned by frame grabbers only. + * + * \since 1.10.57 + * + * \n \b [-2142] + */ + DMR_CAMERA_DESCRIPTION_INVALID_PARAMETER = -2142, + /// \brief A general error returned whenever there has been a problem with accessing a file. + /** + * There can be multiple reasons for this error and a detailed error message will be sent to the log-output + * whenever this error code is returned. + * + * POSSIBLE CAUSES: + * + * • The driver tried to modify a file, for which it has no write access \n + * • The driver tried to read from a file, for which it has no read access \n + * • ... \n + * + * \since 1.10.87 + * + * \n \b [-2143] + */ + DMR_FILE_ACCESS_ERROR = -2143, + /// \brief An error returned when the user application attempts to operate on an invalid queue. + /** + * \since 1.11.0 + * + * \n \b [-2144] + */ + DMR_INVALID_QUEUE_SELECTION = -2144, + /// \brief An error returned when the user application attempts to start the acquisition engine at a + /// time, where it is already running. + /** + * \since 2.5.3 + * + * \n \b [-2145] + */ + DMR_ACQUISITION_ENGINE_BUSY = -2145, + /// \brief An error returned when the user application attempts to perform any operation that currently for any reason cannot be started because something else already running. + /** + * The log-output will provide additional information. + * + * \since 2.32.0 + * + * \n \b [-2146] + */ + DMR_BUSY = -2146, + /// \brief An error returned when for any reason internal resources (memory, handles, ...) cannot be allocated. + /** + * The log-output will provide additional information. + * + * \since 2.32.0 + * + * \n \b [-2147] + */ + DMR_OUT_OF_MEMORY = -2147, + // If new error codes must be added this happens HERE! + // When adding a new value here NEVER forget to update the internal string AND/OR exception table! +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Needed for compile time checks for invalid error code values + DMR_PSEUDO_LAST_ASSIGNED_ERROR_CODE, + /// \brief A dummy constant to mark the last valid error code for device and device manager related errors. + DMR_LAST_ASSIGNED_ERROR_CODE = DMR_PSEUDO_LAST_ASSIGNED_ERROR_CODE - 2, +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Defines the last valid error code value for device and device manager related errors. + /** + * \n \b [-2199] + */ + DMR_LAST_VALID_ERROR_CODE = -2199 +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief The fieldgate is used to detect the field ( odd or even ) for interlaced video signals. +/// \ingroup DeviceSpecificInterface +enum TFieldGateMode +//----------------------------------------------------------------------------- +{ + /// \brief Fieldgate starts at 1/3 of a line and ends at 2/3 of a line. + efmAuto, + /// \brief FieldGateStart and FieldGateWidth can be set in pixels. + efmUser +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for the flat field correction. +/// \ingroup CommonInterface +enum TFlatFieldFilterCorrectionMode +//----------------------------------------------------------------------------- +{ + /// \brief The default flat field correction is used. + ffcmDefault = 0, + /// \brief The flat field correction with clipping compensation is used. This mode prevents + /// clipping artifacts when overexposing the image, but may cause missing codes in the histogram + /// and a brighter image. + ffcmBrightPreserving +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for the flat field filter. +/// \ingroup CommonInterface +enum TFlatFieldFilterMode +//----------------------------------------------------------------------------- +{ + /// \brief The filter is switched off. + fffmOff = 0, + /// \brief The filter is switched on. + fffmOn, + /// \brief The next selected number of images will be taken for calculating the flat field correction image. + /** + * In this mode after the correction image has been calculated the mode will automatically switch back to + * mvIMPACT::acquire::fffmOff + */ + fffmCalibrateFlatField, + /// \brief In this mode whenever reaching this filter, the captured image will be replaced by the + /// last correction image, that has been created as a result of the filter being calibrated. + /** + * \since 2.5.9 + */ + fffmTransmitCorrectionImage +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid steps for the actual firmware update process. +/* +* \since 2.41.0 +*/ +enum TFirmwareUpdateStep +//----------------------------------------------------------------------------- +{ + /// \brief A message wants to be sent + fusErrorMessage = -1, + /// \brief Unzipping the .mvu file. + fusUnzippingFirmwareArchive = 5, + /// \brief Saving user sets of the device. + fusSavingUserSets = 10, + /// \brief Erasing the device's flash memory. + fusErasingFlash = 15, + /// \brief Updating the boot programmer of the device. + fusUpdatingBootProgrammer = 20, + /// \brief Uploading firmware into device memory. + fusUploadingFirmware = 25, + /// \brief Rebooting the device. + fusRebootingDevice = 90, + /// \brief Loading user sets of the device. + fusLoadingUserSets = 95 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid steps for the actual firmware update process. +/* +* \since 2.41.0 +*/ +enum TFirmwareUpdateAction +//----------------------------------------------------------------------------- +{ + /// \brief The default return value to tell the driver to continue processing the firmware update. + fuaContinue = 0, + /// \brief Return this value to request the driver to terminate an ongoing firmware update as soon as possible. + fuaCancel +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid \b Device HW update results. +/** + * This defines valid result e.g. of a user executed firmware update. + */ +/// \ingroup CommonInterface +enum THWUpdateResult +//----------------------------------------------------------------------------- +{ + /// \brief No update has been performed for this mvIMPACT::acquire::Device. + /** + * No update has been performed in the current process since this device driver + * has been loaded in the current process address space. + */ + urNoUpdatePerformed = 0, + /// \brief The mvIMPACT::acquire::Device is currently updating firmware. + urUpdateFW, + /// \brief The mvIMPACT::acquire::Device indicates an error during updating firmware. + urUpdateFWError, + /// \brief The requested update couldn't be performed as the device is already in use. + /** + * If another (or even the same) process uses the device, this hardware update can't be performed. + * To perform the requested update this device needs to be closed. + */ + urDevAlreadyInUse, + /// \brief The mvIMPACT::acquire::Device indicates that the firmware has been updated successfully. + urUpdateFWOK, + /// \brief The mvIMPACT::acquire::Device is currently setting device ID. + urSetDevID, + /// \brief The mvIMPACT::acquire::Device signaled an error when setting device ID. + urSetDevIDError, + /// \brief An invalid device ID has been specified. + /** + * Valid device IDs are within 0 and 250 including the upper and lower limit. + */ + urSetDevIDInvalidID, + /// \brief The mvIMPACT::acquire::Device has successfully been assigned a new ID. + urSetDevIDOK, + /// \brief Size Error in writing User Data to mvIMPACT::acquire::Device . + urSetUserDataSizeError, + /// \brief Write Error in writing User Data to mvIMPACT::acquire::Device . + urSetUserDataWriteError, + /// \brief Writing user data to mvIMPACT::acquire::Device was successful. + urSetUserDataWriteOK, + /// \brief Reading user data from an mvIMPACT::acquire::Device failed. + urGetUserDataReadError, + /// \brief The mvIMPACT::acquire::Device indicates an error during verifying firmware. + urVerifyFWError, + /// \brief The mvIMPACT::acquire::Device indicates that the firmware has been verified successfully. + urVerifyFWOK +}; + +//----------------------------------------------------------------------------- +/// \brief Valid I2C operation modes. +/// \ingroup DeviceSpecificInterface +enum TI2COperationMode +//----------------------------------------------------------------------------- +{ + /// \brief Selects I2C read access. + I2ComRead = 0, + /// \brief Selects I2C write access. + I2ComWrite +}; + +//----------------------------------------------------------------------------- +/// \brief Valid I2C operation status values. +/// \ingroup DeviceSpecificInterface +enum TI2COperationStatus +//----------------------------------------------------------------------------- +{ + /// \brief The last I2C operation was successful. + I2CosSuccess = 0, + /// \brief The last I2C operation did fail. The log-file might contain additional information + I2CosFailure, + /// \brief During the execution of the last I2C operation an invalid device address was specified. + I2CosInvalidDeviceAddress, + /// \brief During the execution of the last I2C operation an invalid device sub-address was specified. + /** + * This can either be caused by an invalid address or by an invalid address width. + */ + I2CosInvalidDeviceSubAddress, + /// \brief During the execution of the last I2C operation too much data was either requested or sent. + I2CosTooMuchData, + /// \brief During the execution of the last I2C operation the amount of data requested or sent was too small. + I2CosNotEnoughData +}; + +//----------------------------------------------------------------------------- +/// \brief Valid image buffer pixel formats. +/// \ingroup CommonInterface +enum TImageBufferPixelFormat +//----------------------------------------------------------------------------- +{ + /// \brief An unprocessed block of data. + ibpfRaw = 0, + /// \brief A single channel 8 bit per pixel format. + ibpfMono8 = 1, + /// \brief A single channel 16 bit per pixel format. + ibpfMono16 = 2, + /// \brief A three channel RGB image with 32 bit per pixel containing one fill byte per pixel. + /** + * This is an interleaved pixel format suitable for most display functions. The data + * is stored pixel-wise. The memory layout of the pixel data is like this: + * + * \code + * 4 bytes 4 bytes etc. + * B(1) G(1) R(1) A(1) B(2) G(2) R(2) A(2) etc. + * ....................................... + * B(n) G(n) R(n) A(n) + * \endcode + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfRGBx888Packed = 3, + /// \brief This is a YUV422 packed image with 32 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 8 bits, the pair of pixels requires 32 bits. + * + * Two consecutive pixels (32 bit, 0xaabbccdd ) contain 8 bit luminance of pixel 1(aa), + * 8 bit chrominance blue of pixel 1 and 2(bb), 8 bit luminance of pixel 2(cc) and finally 8 bit chrominance red of pixels 1 and 2(dd). + * + * Thus in memory the data will be stored like this: + * + * \code + * 4 bytes 4 bytes etc. + * Y(1) Cb(1,2) Y(2) Cr(1,2) Y(3) Cb(3,4) Y(4) Cr(3,4) etc. + * ..........................Y(n-1) Cb(n-1,n) Y(n) Cr(n-1,n) + * \endcode + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV422Packed = 4, + /// \brief The image will be transferred as an RGB image in planar format. + /** + * This is a format best suitable for most image processing functions. + * The image will be converted into four planes(a plane for each color component and one + * alpha plane). + * + * \code + * R(1) R(2) R(3) R(4) etc. + * ................... + * .............. R(n) + * G(1) G(2) G(3) G(4) etc. + * ................... + * .............. G(n) + * B(1) B(2) B(3) B(4) etc. + * ................... + * .............. B(n) + * A(1) A(2) A(3) A(4) etc. + * ................... + * .............. A(n) + * \endcode + * + * So the first byte in memory is the first pixels red component. ImageBuffer::vpData will therefore + * point to R(1) when using a byte pointer. + */ + ibpfRGBx888Planar = 5, + /// \brief A single channel 10 bit per pixel format. + /** + * Each pixel in this format consumes 2 bytes of memory. The lower 10 bit of this 2 bytes will contain valid data. + */ + ibpfMono10 = 6, + /// \brief A single channel 12 bit per pixel format. + /** + * Each pixel in this format consumes 2 bytes of memory. The lower 12 bit of this 2 bytes will contain valid data. + */ + ibpfMono12 = 7, + /// \brief A single channel 14 bit per pixel format. + /** + * Each pixel in this format consumes 2 bytes of memory. The lower 14 bit of this 2 bytes will contain valid data. + */ + ibpfMono14 = 8, + /// \brief The image will be transferred as an RGB image with 24 bit per pixel. + /** + * This is an interleaved pixel format suitable for most display and processing functions. + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfRGB888Packed = 9, + /// \brief This is a YUV444 planar image with 24 bit per pixels. + /** + * A planar YUV format. In memory the data will be stored plane-wise like this: + * + * \code + * Y(1) Y(2) Y(3) Y(4) etc. + * ............................ + * .............. Y(n-1) Y(n) + * Cr(1) Cr(2) Cr(3) Cr(4) etc. + * ............................ + * .............. Cr(n-1) Cr(n) + * Cb(1) Cb(2) Cb(3) Cb(4) etc. + * ............................ + * ............. Cb(n-1) Cb(n) + * \endcode + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + */ + ibpfYUV444Planar = 10, + /// \brief A single channel 32 bit per pixel format. + ibpfMono32 = 11, + /// \brief This is a YUV422 planar image with 32 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 8 bits, the pair of pixels requires 32 bits. + * + * In memory the data will be stored like this: + * + * \code + * Y(1) Y(2) Y(3) Y(4) etc. + * ............................ + * .............. Y(n-1) Y(n) + * Cr(1,2) Cr(3,4) etc. + * ............... + * ....... Cr(n/2) + * Cb(1,2) Cb(3,4) etc. + * ............... + * ....... Cb(n/2) + * \endcode + * + * Thus the Y planes size in bytes equals the sum of the 2 other planes. + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + */ + ibpfYUV422Planar = 12, + /// \brief The image will be transferred as an RGB image with 30 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 6 MSB of each 16 bit will + * not contain valid data. + * + * So the first 2 bytes in memory are the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfRGB101010Packed = 13, + /// \brief The image will be transferred as an RGB image with 36 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 4 MSB of each 16 bit will + * not contain valid data. + * + * So the first 2 bytes in memory are the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfRGB121212Packed = 14, + /// \brief The image will be transferred as an RGB image with 42 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 2 MSB of each 16 bit will + * not contain valid data. + * + * So the first 2 bytes in memory are the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfRGB141414Packed = 15, + /// \brief The image will be transferred as an RGB image with 48 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned. + * + * So the first 2 bytes in memory are the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfRGB161616Packed = 16, + /// \brief This is a YUV422 packed image with 32 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 8 bits, the pair of pixels requires 32 bits. + * + * Two consecutive pixels (32 bit, 0xaabbccdd ) will contain 8 bit chrominance blue of pixel 1 and 2(aa), + * 8 bit luminance of pixel 1(bb), 8 bit chrominance red of pixel 1 and 2 (cc) and finally 8 bit luminance of pixel 2(dd). + * + * Thus in memory the data will be stored like this: + * + * \code + * 4 bytes 4 bytes etc. + * Cb(1,2) Y(1) Cr(1,2) Y(2) Cb(3,4) Y(3) Cr(3,4) Y(4) etc. + * ..........................Cb(n-1,n) Y(n-1) Cr(n-1,n) Y(n) + * \endcode + * + * So the first byte in memory is the first pixels Cb component. ImageBuffer::vpData will therefore + * point to Cb(1,2) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV422_UYVYPacked = 17, + /// \brief A single channel 12 bit per pixel packed format. + /** + * This format will use 3 bytes to store 2 12 bit pixel. Every 3 bytes will use the following layout in + * memory: + * + * \code + * 3 bytes 3 bytes etc. + * bits 11..4(1) bits 3..0(1) bits 3..0(2) bits 11..4(2) bits 11..4(3) bits 3..0(3) bits 3..0(4) bits 11..4(4) etc. + * \endcode + * + * \note + * When the width is not divisible by 2 the line pitch of a buffer can't be used to calculate line start offsets in a buffer! + * In that case something like this can be used to access a certain pixel (pseudo code assuming 'pointerToStartOfTheBuffer' is a 'byte pointer'): + * + * \code + * GetMono12Packed_V1Pixel( pointerToStartOfTheBuffer, pixelIndex ) + * const int offsetFromStartOfTheBuffer = (3*pixel)/2 + * if pixel divisible by 2 + * return (pointerToStartOfTheBuffer[offset+1] << shift) | (pointerToStartOfTheBuffer[offset] >> 4) + * return pointerToStartOfTheBuffer[offset] << shift) | (pointerToStartOfTheBuffer[offset+1] & 0xF) + * \endcode + */ + ibpfMono12Packed_V2 = 18, + /// \brief This is a YUV422 packed image with 64 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 16 bits, the pair of pixels requires 64 bits. + * + * Two consecutive pixels (64 bit, 0xaaaabbbbccccdddd ) contain 10 bit luminance of pixel 1(aaaa), + * 10 bit chrominance blue of pixel 1 and 2(bbbb), 10 bit luminance of pixel 2(cccc) and finally 10 bit chrominance red of pixels 1 and 2(dddd). + * The upper 6 bits of each component will be 0. + * + * Thus in memory the data will be stored like this: + * + * \code + * 8 bytes 8 bytes etc. + * Y(1) Cb(1,2) Y(2) Cr(1,2) Y(3) Cb(3,4) Y(4) Cr(3,4) etc. + * ..........................Y(n-1) Cb(n-1,n) Y(n) Cr(n-1,n) + * \endcode + * + * So the first 2 bytes in memory are the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV422_10Packed = 20, + /// \brief This is a YUV422 packed image with 64 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 16 bits, the pair of pixels requires 64 bits. + * + * Two consecutive pixels (64 bit, 0xaaaabbbbccccdddd ) will contain 10 bit chrominance blue of pixel 1 and 2(aaaa), + * 10 bit luminance of pixel 1(bbbb), 10 bit chrominance red of pixel 1 and 2 (cccc) and finally 10 bit luminance of pixel 2(dddd). + * The upper 6 bits of each component will be 0. + * + * Thus in memory the data will be stored like this: + * + * \code + * 8 bytes 8 bytes etc. + * Cb(1,2) Y(1) Cr(1,2) Y(2) Cb(3,4) Y(3) Cr(3,4) Y(4) etc. + * ..........................Cb(n-1,n) Y(n-1) Cr(n-1,n) Y(n) + * \endcode + * + * So the first 2 bytes in memory are the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Cb(1,2) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV422_UYVY_10Packed = 21, + /// \brief The image will be transferred as an RGB image with 24 bit per pixel. + /** + * This is an interleaved pixel format suitable for most processing functions. Most + * blit/display function however will expect ibpfRGB888Packed. + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * R(1)G(1)B(1) R(2)G(2)B(2) R(3)G(3)B(3) etc. + * .......................................... + * ........................... R(n)G(n)B(n) + * \endcode + * + * So the first byte in memory is the first pixels red component. ImageBuffer::vpData will therefore + * point to R(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfBGR888Packed = 22, + /// \brief A 10 bit per color component RGB packed format. + /** + * This format will use 4 bytes to store one 10 bit per color component RGB pixel. The following memory layout is + * used for each pixel: + * + * \code + * byte 0 | byte 1 | byte 2 | byte 3 | + * 0 7 | 890....5 | 6..90..3 | 4 9xx | + * RRRRRRRR | RRGGGGGG | GGGGBBBB | BBBBBB | + * \endcode + * + * \if (DOXYGEN_C_DOCUMENTATION || DOXYGEN_CPP_DOCUMENTATION) + * \note + * Access to a certain pixel can e.g. be implemented like this: + * + * \code + * //----------------------------------------------------------------------------- + * // slow version + * inline void GetBGR101010Packed_V2Pixel( void* p, const int pitch, int x, int y, unsigned short& red, unsigned short& green, unsigned short& blue ) + * //----------------------------------------------------------------------------- + * { + * unsigned int* pSrc = reinterpret_cast(static_cast(p) + y * pitch) + x; + * red = static_cast( (*pSrc) & 0x3FF); + * green = static_cast(((*pSrc) >> 10 ) & 0x3FF); + * blue = static_cast(((*pSrc) >> 20 ) & 0x3FF); + * } + * + * //----------------------------------------------------------------------------- + * // faster version + * inline void GetBGR101010Packed_V2Pixel( unsigned int pixel, unsigned short& red, unsigned short& green, unsigned short& blue ) + * //----------------------------------------------------------------------------- + * { + * red = static_cast( pixel & 0x3FF); + * green = static_cast(( pixel >> 10 ) & 0x3FF); + * blue = static_cast(( pixel >> 20 ) & 0x3FF); + * } + * \endcode + * \endif + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfBGR101010Packed_V2 = 23, + /// \brief The image will be transferred as an YUV image with 24 bit per pixel. + /** + * This is an interleaved pixel format. + * + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * Cb(1)Y(1)Cr(1) Cb(2)Y(2)Cr(2) Cb(3)Y(3)Cr(3) etc. + * .......................................... + * ........................... Cb(n)Y(n)Cr(n) + * \endcode + * + * So the first byte in memory is the first pixels Cb component. ImageBuffer::vpData will therefore + * point to Cb(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV444_UYVPacked = 24, + /// \brief The image will be transferred as an YUV image with 30 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * Cb(1)Y(1)Cr(1) Cb(2)Y(2)Cr(2) Cb(3)Y(3)Cr(3) etc. + * .......................................... + * ........................... Cb(n)Y(n)Cr(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 6 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels Cb component. ImageBuffer::vpData will therefore + * point to Cb(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV444_UYV_10Packed = 25, + /// \brief The image will be transferred as an YUV image with 24 bit per pixel. + /** + * This is an interleaved pixel format. + * + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * Y(1)Cb(1)Cr(1) Y(2)Cb(2)Cr(2) Y(3)Cb(3)Cr(3) etc. + * .......................................... + * ........................... Y(n)Cb(n)Cr(n) + * \endcode + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV444Packed = 26, + /// \brief The image will be transferred as an YUV image with 30 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * Y(1)Cb(1)Cr(1) Y(2)Cb(2)Cr(2) Y(3)Cb(3)Cr(3) etc. + * .......................................... + * ........................... Y(n)Cb(n)Cr(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 6 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + ibpfYUV444_10Packed = 27, + /// \brief A single channel 12 bit per pixel packed format. + /** + * This format will use 3 bytes to store 2 12 bit pixel. Every 3 bytes will use the following layout in + * memory: + * + * \code + * 3 bytes 3 bytes etc. + * bits 0..7(1) bits 8..11(1) bits 0..3(2) bits 4..11(2) bits 0..7(3) bits 8..11(3) bits 0..3(4) bits 4..11(4) etc. + * \endcode + * + * \note + * When the width is not divisible by 2 the line pitch of a buffer can't be used to calculate line start offsets in a buffer! + * In that case something like this can be used to access a certain pixel (pseudo code assuming 'pointerToStartOfTheBuffer' is a 'byte pointer'): + * + * \code + * GetMono12Packed_V1Pixel( pointerToStartOfTheBuffer, pixelIndex ) + * const int offsetFromStartOfTheBuffer = pixel + pixel/2 + * if pixel divisible by 2 + * return (pointerToStartOfTheBuffer[offset] >> 4) | (pointerToStartOfTheBuffer[offset+1] << 4) + * return pointerToStartOfTheBuffer[offset]) | (pointerToStartOfTheBuffer[offset+1] & 0xF) << 8) + * \endcode + * + * \since 2.5.0 + */ + ibpfMono12Packed_V1 = 28, + /// \brief This is a YUV411 packed image with 48 bits for four pixels. + /** + * This format uses 4:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 4 pixels in + * horizontal direction. If each component takes 8 bits, four pixels require 48 bits. + * + * Four consecutive pixels (48 bit, 0xaabbccddeeff ) contain 8 bit chrominance blue of pixels 1, 2, 3 and 4(aa), + * 8 bit luminance of pixel 1(bb),8 bit luminance of pixel 2(cc), 8 bit chrominance red of pixels 1, 2, 3 and 4(dd), + * 8 bit luminance of pixel 3(ee) and finally 8 bit luminance of pixel 4(ff). + * + * Thus in memory the data will be stored like this: + * + * \code + * 6 bytes 6 bytes etc. + * Cb(1,2,3,4) Y(1) Y(2) Cr(1,2,3,4) Y(3) Y(4) Cb(5,6,7,8) Y(5) Y(6) Cr(5,6,7,8) Y(7) Y(8) etc. + * .................. Cb(n,n+1,n+2,n+3) Y(n) Y(n+1) Cr(n,n+1,n+2,n+3) Y(n+2) Y(n+3) + * \endcode + * + * So the first byte in memory is the chrominance blue component. ImageBuffer::vpData will therefore + * point to Cb when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + * + * \since 2.13.0 + */ + ibpfYUV411_UYYVYY_Packed = 29, + /// \brief The image will be transferred as an RGB image in planar format. + /** + * This is a format best suitable for most image processing functions. + * The image will be converted into 3 planes(a plane for each color component). + * + * \code + * R(1) R(2) R(3) R(4) etc. + * ................... + * .............. R(n) + * G(1) G(2) G(3) G(4) etc. + * ................... + * .............. G(n) + * B(1) B(2) B(3) B(4) etc. + * ................... + * .............. B(n) + * \endcode + * + * So the first byte in memory is the first pixels red component. ImageBuffer::vpData will therefore + * point to R(1) when using a byte pointer. + * + * \since 2.17.0 + */ + ibpfRGB888Planar = 30, + /// \brief The driver will decide which format will be used. + ibpfAuto = -1 +}; + +//------------------------------------------------------------------------------ +/// \brief Valid image buffer format reinterpreter modes. +/** + * \since 2.10.1 + * \ingroup CommonInterface + */ +enum TImageBufferFormatReinterpreterMode // dotNETReplacement=ibpf;TImageBufferPixelFormat.ibpf +//------------------------------------------------------------------------------ +{ + /// \brief Attach or remove a mvIMPACT::acquire::TBayerMosaicParity attribute to a mvIMPACT::acquire::ibpfMono8 buffer OR change the existing Bayer attribute to a different value. + /** + * The new mvIMPACT::acquire::TBayerMosaicParity value for the buffer can be selected by the property FormatReinterpreterBayerMosaicParity. + */ + ibfrmMono8_To_Mono8 = ibpfMono8 << 16 | ibpfMono8, + /// \brief Reinterpret mvIMPACT::acquire::ibpfMono8 as mvIMPACT::acquire::ibpfRGB888Packed. + /** + * This will effectively divide the width by 3 but preserve the original line pitch. + */ + ibfrmMono8_To_RGB888Packed = ibpfMono8 << 16 | ibpfRGB888Packed, + /// \brief Reinterpret mvIMPACT::acquire::ibpfMono8 as mvIMPACT::acquire::ibpfBGR888Packed. + /** + * This will effectively divide the width by 3 but preserve the original line pitch. + */ + ibfrmMono8_To_BGR888Packed = ibpfMono8 << 16 | ibpfBGR888Packed, + /// \brief Attach or remove a mvIMPACT::acquire::TBayerMosaicParity attribute to a mvIMPACT::acquire::ibpfMono8 buffer OR change the existing Bayer attribute to a different value. + /** + * The new mvIMPACT::acquire::TBayerMosaicParity value for the buffer can be selected by the property FormatReinterpreterBayerMosaicParity. + */ + ibfrmMono10_To_Mono10 = ibpfMono10 << 16 | ibpfMono10, + /// \brief Reinterpret mvIMPACT::acquire::ibpfMono10 as mvIMPACT::acquire::ibpfRGB101010Packed. + /** + * This will effectively divide the width by 3 but preserve the original line pitch. + */ + ibfrmMono10_To_RGB101010Packed = ibpfMono10 << 16 | ibpfRGB101010Packed, + /// \brief Attach or remove a mvIMPACT::acquire::TBayerMosaicParity attribute to a mvIMPACT::acquire::ibpfMono8 buffer OR change the existing Bayer attribute to a different value. + /** + * The new mvIMPACT::acquire::TBayerMosaicParity value for the buffer can be selected by the property FormatReinterpreterBayerMosaicParity. + */ + ibfrmMono12_To_Mono12 = ibpfMono12 << 16 | ibpfMono12, + /// \brief Reinterpret mvIMPACT::acquire::ibpfMono12 as mvIMPACT::acquire::ibpfRGB121212Packed. + /** + * This will effectively divide the width by 3 but preserve the original line pitch. + */ + ibfrmMono12_To_RGB121212Packed = ibpfMono12 << 16 | ibpfRGB121212Packed, + /// \brief Attach or remove a mvIMPACT::acquire::TBayerMosaicParity attribute to a mvIMPACT::acquire::ibpfMono8 buffer OR change the existing Bayer attribute to a different value. + /** + * The new mvIMPACT::acquire::TBayerMosaicParity value for the buffer can be selected by the property FormatReinterpreterBayerMosaicParity. + */ + ibfrmMono14_To_Mono14 = ibpfMono14 << 16 | ibpfMono14, + /// \brief Reinterpret mvIMPACT::acquire::ibpfMono14 as mvIMPACT::acquire::ibpfRGB141414Packed. + /** + * This will effectively divide the width by 3 but preserve the original line pitch. + */ + ibfrmMono14_To_RGB141414Packed = ibpfMono14 << 16 | ibpfRGB141414Packed, + /// \brief Attach or remove a mvIMPACT::acquire::TBayerMosaicParity attribute to a mvIMPACT::acquire::ibpfMono8 buffer OR change the existing Bayer attribute to a different value. + /** + * The new mvIMPACT::acquire::TBayerMosaicParity value for the buffer can be selected by the property FormatReinterpreterBayerMosaicParity. + */ + ibfrmMono16_To_Mono16 = ibpfMono16 << 16 | ibpfMono16, + /// \brief Reinterpret mvIMPACT::acquire::ibpfMono16 as mvIMPACT::acquire::ibpfRGB161616Packed. + /** + * This will effectively divide the width by 3 but preserve the original line pitch. + */ + ibfrmMono16_To_RGB161616Packed = ibpfMono16 << 16 | ibpfRGB161616Packed +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the pixel format of the result image. +/// \ingroup CommonInterface +enum TImageDestinationPixelFormat +//----------------------------------------------------------------------------- +{ + /// \brief The driver will decide which destination format will be used. + idpfAuto = 0, + /// \brief The image will be transferred as an unprocessed block of data. + idpfRaw = 1, + /// \brief The image will be transferred as a mono channel 8 bit per pixel image. + idpfMono8 = 2, + /// \brief The image will be transferred as an RGB image with 32 bit per pixel containing one fill byte per pixel. + /** + * This is an interleaved pixel format suitable for most display functions. The data + * is stored pixel-wise. When accessed 4-byte wise the data layout in memory can be + * interpreted like this (starting with the MSB): + * + * \code + * 4 bytes 4 bytes etc. + * B(1) G(1) R(1) A(1) B(2) G(2) R(2) A(2) etc. + * ....................................... + * B(n) G(n) R(n) A(n) + * \endcode + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfRGBx888Packed = 3, + /// \brief This is a YUV422 packed image with 32 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 8 bits, the pair of pixels requires 32 bits. + * + * Two consecutive pixels (32 bit, 0xaabbccdd ) contain 8 bit luminance of pixel 1(aa), + * 8 bit chrominance blue of pixel 1 and 2(bb), 8 bit luminance of pixel 2(cc) and finally 8 bit chrominance red of pixels 1 and 2(dd). + * + * Thus in memory the data will be stored like this: + * + * \code + * 4 bytes 4 bytes etc. + * Y(1) Cb(1,2) Y(2) Cr(1,2) Y(3) Cb(3,4) Y(4) Cr(3,4) etc. + * ..........................Y(n-1) Cb(n-1,n) Y(n) Cr(n-1,n) + * \endcode + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV422Packed = 4, + /// \brief The image will be transferred as an RGB image in planar format. + /** + * This is a format best suitable for most image processing functions. + * The image will be converted into four planes(a plane for each color component and one + * alpha plane). + * + * \code + * R(1) R(2) R(3) R(4) etc. + * ................... + * .............. R(n) + * G(1) G(2) G(3) G(4) etc. + * ................... + * .............. G(n) + * B(1) B(2) B(3) B(4) etc. + * ................... + * .............. B(n) + * A(1) A(2) A(3) A(4) etc. + * ................... + * .............. A(n) + * \endcode + * + * So the first byte in memory is the first pixels red component. ImageBuffer::vpData will therefore + * point to R(1) when using a byte pointer. + */ + idpfRGBx888Planar = 5, + /// \brief The image will be transferred as a mono channel 10 bit per pixel image. + /** + * Each pixel in this format consumes 2 bytes of memory. The lower 10 bit of this 2 bytes will contain valid data. + */ + idpfMono10 = 6, + /// \brief The image will be transferred as a mono channel 12 bit per pixel image. + /** + * Each pixel in this format consumes 2 bytes of memory. The lower 12 bit of this 2 bytes will contain valid data. + */ + idpfMono12 = 7, + /// \brief The image will be transferred as a mono channel 14 bit per pixel image. + /** + * Each pixel in this format consumes 2 bytes of memory. The lower 14 bit of this 2 bytes will contain valid data. + */ + idpfMono14 = 8, + /// \brief The image will be transferred as a mono channel 16 bit per pixel image. + idpfMono16 = 9, + /// \brief The image will be transferred as an RGB image with 24 bit per pixel. + /** + * This is an interleaved pixel format suitable for most display and processing functions. + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfRGB888Packed = 10, + /// \brief The image will be transferred as a YUV422 image with 16 bit per pixel. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 8 bits, the pair of pixels requires 32 bits. + * + * In memory the data will be stored like this: + * + * \code + * Y(1) Y(2) Y(3) Y(4) etc. + * ............................ + * .............. Y(n-1) Y(n) + * Cr(1,2) Cr(3,4) etc. + * ............... + * ....... Cr(n/2) + * Cb(1,2) Cb(3,4) etc. + * ............... + * ....... Cb(n/2) + * \endcode + * + * Thus the Y planes size in bytes equals the sum of the 2 other planes. + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + */ + idpfYUV422Planar = 13, + /// \brief The image will be transferred as an RGB image with 30 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 6 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfRGB101010Packed = 14, + /// \brief The image will be transferred as an RGB image with 36 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 4 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfRGB121212Packed = 15, + /// \brief The image will be transferred as an RGB image with 42 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 2 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfRGB141414Packed = 16, + /// \brief The image will be transferred as an RGB image with 48 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * B(1)G(1)R(1) B(2)G(2)R(2) B(3)G(3)R(3) etc. + * .......................................... + * ........................... B(n)G(n)R(n) + * \endcode + * + * The data of each color component will be LSB aligned. + * + * So the first byte in memory is the first pixels blue component. ImageBuffer::vpData will therefore + * point to B(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfRGB161616Packed = 17, + /// \brief This is a YUV422 packed image with 32 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 8 bits, the pair of pixels requires 32 bits. + * + * Two consecutive pixels (32 bit, 0xaabbccdd ) will contain 8 bit chrominance blue of pixel 1 and 2(aa), + * 8 bit luminance of pixel 1(bb), 8 bit chrominance red of pixel 1 and 2 (cc) and finally 8 bit luminance of pixel 2(dd). + * + * Thus in memory the data will be stored like this: + * + * \code + * 4 bytes 4 bytes etc. + * Cb(1,2) Y(1) Cr(1,2) Y(2) Cb(3,4) Y(3) Cr(3,4) Y(4) etc. + * ..........................Cb(n-1,n) Y(n-1) Cr(n-1,n) Y(n) + * \endcode + * + * So the first byte in memory is the first pixels Cb component. ImageBuffer::vpData will therefore + * point to Cb(1,2) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV422_UYVYPacked = 18, + /// \brief A single channel 12 bit per pixel packed format. + /** + * This format will use 3 bytes to store 2 12 bit pixel. Every 3 bytes will use the following layout in + * memory: + * + * \code + * 3 bytes 3 bytes etc. + * bits 11..4(1) bits 3..0(1) bits 3..0(2) bits 11..4(2) bits 11..4(3) bits 3..0(3) bits 3..0(4) bits 11..4(4) etc. + * \endcode + * + * \note + * When the width is not divisible by 2 the line pitch of a buffer can't be used to calculate line start offsets in a buffer! + * In that case something like this can be used to access a certain pixel (pseudo code assuming 'pointerToStartOfTheBuffer' is a 'byte pointer'): + * + * \code + * GetMono12Packed_V1Pixel( pointerToStartOfTheBuffer, pixelIndex ) + * const int offsetFromStartOfTheBuffer = (3*pixel)/2 + * if pixel divisible by 2 + * return (pointerToStartOfTheBuffer[offset+1] << shift) | (pointerToStartOfTheBuffer[offset] >> 4) + * return pointerToStartOfTheBuffer[offset] << shift) | (pointerToStartOfTheBuffer[offset+1] & 0xF) + * } + * \endcode + */ + idpfMono12Packed_V2 = 19, + /// \brief This is a YUV422 packed image with 64 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 16 bits, the pair of pixels requires 64 bits. + * + * Two consecutive pixels (64 bit, 0xaaaabbbbccccdddd ) contain 10 bit luminance of pixel 1(aaaa), + * 10 bit chrominance blue of pixel 1 and 2(bbbb), 10 bit luminance of pixel 2(cccc) and finally 10 bit chrominance red of pixels 1 and 2(dddd). + * The upper 6 bits of each component will be 0. + * + * Thus in memory the data will be stored like this: + * + * \code + * 8 bytes 8 bytes etc. + * Y(1) Cb(1,2) Y(2) Cr(1,2) Y(3) Cb(3,4) Y(4) Cr(3,4) etc. + * ..........................Y(n-1) Cb(n-1,n) Y(n) Cr(n-1,n) + * \endcode + * + * So the first 2 bytes in memory are the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV422_10Packed = 20, + /// \brief This is a YUV422 packed image with 64 bit for a pair of pixels. + /** + * This format uses 2:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 2 pixels in + * horizontal direction. If each component takes 16 bits, the pair of pixels requires 64 bits. + * + * Two consecutive pixels (64 bit, 0xaaaabbbbccccdddd ) will contain 10 bit chrominance blue of pixel 1 and 2(aaaa), + * 10 bit luminance of pixel 1(bbbb), 10 bit chrominance red of pixel 1 and 2 (cccc) and finally 10 bit luminance of pixel 2(dddd). + * The upper 6 bits of each component will be 0. + * + * Thus in memory the data will be stored like this: + * + * \code + * 8 bytes 8 bytes etc. + * Cb(1,2) Y(1) Cr(1,2) Y(2) Cb(3,4) Y(3) Cr(3,4) Y(4) etc. + * ..........................Cb(n-1,n) Y(n-1) Cr(n-1,n) Y(n) + * \endcode + * + * So the first 2 bytes in memory are the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Cb(1,2) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV422_UYVY_10Packed = 21, + /// \brief The image will be transferred as an RGB image with 24 bit per pixel. + /** + * This is an interleaved pixel format suitable for most processing functions. Most + * blit/display function however will expect idpfRGB888Packed. + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * R(1)G(1)B(1) R(2)G(2)B(2) R(3)G(3)B(3) etc. + * .......................................... + * ........................... R(n)G(n)B(n) + * \endcode + * + * So the first byte in memory is the first pixels red component. ImageBuffer::vpData will therefore + * point to R(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfBGR888Packed = 22, + /// \brief A 10 bit per color component RGB packed format. + /** + * This format will use 4 bytes to store one 10 bit per color component RGB pixel. The following memory layout is + * used for each pixel: + * + * \code + * byte 0 | byte 1 | byte 2 | byte 3 | + * 0 7 | 890....5 | 6..90..3 | 4 9xx | + * RRRRRRRR | RRGGGGGG | GGGGBBBB | BBBBBB | + * \endcode + * + * \if (DOXYGEN_C_DOCUMENTATION || DOXYGEN_CPP_DOCUMENTATION) + * \note + * Access to a certain pixel can e.g. be implemented like this: + * \code + * //----------------------------------------------------------------------------- + * // slow version + * inline void GetBGR101010Packed_V2Pixel( void* p, const int pitch, int x, int y, unsigned short& red, unsigned short& green, unsigned short& blue ) + * //----------------------------------------------------------------------------- + * { + * unsigned int* pSrc = reinterpret_cast(static_cast(p) + y * pitch) + x; + * red = static_cast( (*pSrc) & 0x3FF); + * green = static_cast(((*pSrc) >> 10 ) & 0x3FF); + * blue = static_cast(((*pSrc) >> 20 ) & 0x3FF); + * } + * + * //----------------------------------------------------------------------------- + * // faster version + * inline void GetBGR101010Packed_V2Pixel( unsigned int pixel, unsigned short& red, unsigned short& green, unsigned short& blue ) + * //----------------------------------------------------------------------------- + * { + * red = static_cast( pixel & 0x3FF); + * green = static_cast(( pixel >> 10 ) & 0x3FF); + * blue = static_cast(( pixel >> 20 ) & 0x3FF); + * } + * \endcode + * \endif + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfBGR101010Packed_V2 = 23, + /// \brief The image will be transferred as an YUV image with 24 bit per pixel. + /** + * This is an interleaved pixel format. + * + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * Cb(1)Y(1)Cr(1) Cb(2)Y(2)Cr(2) Cb(3)Y(3)Cr(3) etc. + * .......................................... + * ........................... Cb(n)Y(n)Cr(n) + * \endcode + * + * So the first byte in memory is the first pixels Cb component. ImageBuffer::vpData will therefore + * point to Cb(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV444_UYVPacked = 24, + /// \brief The image will be transferred as an YUV image with 30 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * Cb(1)Y(1)Cr(1) Cb(2)Y(2)Cr(2) Cb(3)Y(3)Cr(3) etc. + * .......................................... + * ........................... Cb(n)Y(n)Cr(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 6 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels Cb component. ImageBuffer::vpData will therefore + * point to Cb(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV444_UYV_10Packed = 25, + /// \brief The image will be transferred as an YUV image with 24 bit per pixel. + /** + * This is an interleaved pixel format. + * + * The data is stored pixel-wise: + * + * \code + * 3 bytes 3 bytes 3 bytes etc. + * Y(1)Cb(1)Cr(1) Y(2)Cb(2)Cr(2) Y(3)Cb(3)Cr(3) etc. + * .......................................... + * ........................... Y(n)Cb(n)Cr(n) + * \endcode + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV444Packed = 26, + /// \brief The image will be transferred as an YUV image with 30 bit of usable data per pixel. + /** + * This is an interleaved pixel format with 2 bytes per color component. + * The data is stored pixel-wise: + * + * \code + * 6 bytes 6 bytes 6 bytes etc. + * Y(1)Cb(1)Cr(1) Y(2)Cb(2)Cr(2) Y(3)Cb(3)Cr(3) etc. + * .......................................... + * ........................... Y(n)Cb(n)Cr(n) + * \endcode + * + * The data of each color component will be LSB aligned, thus the 6 MSB of each 16 bit will + * not contain valid data. + * + * So the first byte in memory is the first pixels luminance component. ImageBuffer::vpData will therefore + * point to Y(1) when using a 16 bit pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + */ + idpfYUV444_10Packed = 27, + /// \brief A single channel 12 bit per pixel packed format. + /** + * This format will use 3 bytes to store 2 12 bit pixel. Every 3 bytes will use the following layout in + * memory: + * + * \code + * 3 bytes 3 bytes etc. + * bits 0..7(1) bits 8..11(1) bits 0..3(2) bits 4..11(2) bits 0..7(3) bits 8..11(3) bits 0..3(4) bits 4..11(4) etc. + * \endcode + * + * \note + * When the width is not divisible by 2 the line pitch of a buffer can't be used to calculate line start offsets in a buffer! + * In that case something like this can be used to access a certain pixel (pseudo code assuming 'pointerToStartOfTheBuffer' is a 'byte pointer'): + * + * \code + * GetMono12Packed_V1Pixel( pointerToStartOfTheBuffer, pixelIndex ) + * const int offsetFromStartOfTheBuffer = pixel + pixel/2 + * if pixel divisible by 2 + * return (pointerToStartOfTheBuffer[offset] >> 4) | (pointerToStartOfTheBuffer[offset+1] << 4) + * return pointerToStartOfTheBuffer[offset]) | (pointerToStartOfTheBuffer[offset+1] & 0xF) << 8) + * \endcode + * + * \since 2.5.0 + */ + idpfMono12Packed_V1 = 28, + /// \brief This is a YUV411 packed image with 48 bits for four pixels. + /** + * This format uses 4:1 horizontal downsampling, which means that the Y component is + * sampled at each pixel, while U(Cb) and V(Cr) components are sampled every 4 pixels in + * horizontal direction. If each component takes 8 bits, four pixels require 48 bits. + * + * Four consecutive pixels (48 bit, 0xaabbccddeeff ) contain 8 bit chrominance blue of pixels 1, 2, 3 and 4(aa), + * 8 bit luminance of pixel 1(bb),8 bit luminance of pixel 2(cc), 8 bit chrominance red of pixels 1, 2, 3 and 4(dd), + * 8 bit luminance of pixel 3(ee) and finally 8 bit luminance of pixel 4(ff). + * + * Thus in memory the data will be stored like this: + * + * \code + * 6 bytes 6 bytes etc. + * Cb(1,2,3,4) Y(1) Y(2) Cr(1,2,3,4) Y(3) Y(4) Cb(5,6,7,8) Y(5) Y(6) Cr(5,6,7,8) Y(7) Y(8) etc. + * .................. Cb(n,n+1,n+2,n+3) Y(n) Y(n+1) Cr(n,n+1,n+2,n+3) Y(n+2) Y(n+3) + * \endcode + * + * So the first byte in memory is the chrominance blue component. ImageBuffer::vpData will therefore + * point to Cb when using a byte pointer. + * + * \sa \ref Channel_Split_PackedToPlanar + * + * \since 2.13.0 + */ + idpfYUV411_UYYVYY_Packed = 29, + /// \brief The image will be transferred as an RGB image in planar format. + /** + * This is a format best suitable for most image processing functions. + * The image will be converted into 3 planes(a plane for each color component). + * + * \code + * R(1) R(2) R(3) R(4) etc. + * ................... + * .............. R(n) + * G(1) G(2) G(3) G(4) etc. + * ................... + * .............. G(n) + * B(1) B(2) B(3) B(4) etc. + * ................... + * .............. B(n) + * \endcode + * + * So the first byte in memory is the first pixels red component. ImageBuffer::vpData will therefore + * point to R(1) when using a byte pointer. + * + * \since 2.17.0 + */ + idpfRGB888Planar = 30 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid image file formats. +/** + * + * \since 2.23.0 + * + */ +/// \ingroup CommonInterface +enum TImageFileFormat +//----------------------------------------------------------------------------- +{ + /// \brief Automatically tries to select the file format e.g. from the file extension + iffAuto = -1, + /// \brief The BMP format. + iffBMP = 1, + /// \brief The JPEG format. + iffJPEG = 2, + /// \brief The PNG format. + iffPNG = 13, + /// \brief The TIFF format. + iffTIFF = 18 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid filters which can be applied to the captured image before it is transferred to the user. +/// \ingroup CommonInterface +enum TImageProcessingFilter +//----------------------------------------------------------------------------- +{ + /// \brief No filter function will be applied to the image. + ipfOff = 0, + /// \brief A sharpen filter will be applied to the image. + ipfSharpen +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes the internal image processing pipeline can be operated in. +/** + * + * \since 2.14.0 + * + */ +/// \ingroup CommonInterface +enum TImageProcessingMode +//----------------------------------------------------------------------------- +{ + /// \brief The default mode where every image is processed in the order they have been acquired + ipmDefault = 0, + /// \brief This mode can be useful for applications where processing on the host takes longer than the average time between two consecutive frames transmitted by the device. + /** + * This might be useful for applications that display the processed result but that also want to + * capture data at the highest possible frame rate and is not important that EVERY image gets processed. + * + * \attention This mode might result in images being returned without the expected processing on the host. + * + * \sa \b mvIMPACT::acquire::Device::userControlledImageProcessingEnable, \n + * \b mvIMPACT::acquire::Request::hasProcessingBeenSkipped, \n + * \b mvIMPACT::acquire::Request::getImageProcessingResultsIterator + */ + ipmProcessLatestOnly = 1 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes the internal image processing algorithms can be operated in. +/** + * \sa \ref ImageProcessing_General. + * + * \since 2.12.2 + * + */ +/// \ingroup CommonInterface +enum TImageProcessingOptimization +//----------------------------------------------------------------------------- +{ + /// \brief Will maximize the execution speed. This might result in a higher memory consumption. + ipoMaximizeSpeed = 0, + /// \brief Will minimize the memory footprint. This might result in a higher CPU load. + /** + * \attention This mode will also result in a higher amount of memory allocation and freeing operations + * thus if the application itself is working with heap memory a lot the long term effects of heap + * fragmentation should be considered! + */ + ipoMinimizeMemoryUsage = 1 +}; + +//------------------------------------------------------------------------------ +/// \brief Defines valid values for the result of a certain image processing algorithm applied to a request. +/** + * + * \since 2.14.0 + * + */ +/// \ingroup CommonInterface +enum TImageProcessingResult +//------------------------------------------------------------------------------ +{ + /// \brief This algorithm was either switched off or not needed when applied to this request object. + /** + * When an algorithm is switched on and this result is returned this can indicate e.g. that for a format conversion + * the input and output format where identical. + */ + iprNotActive = 0, + /// \brief This algorithm has been applied to this request object. + iprApplied, + /// \brief A problem was encountered when this algorithm has been applied to this request object. + /** + * One reason for this result might be that an unsupported pixel format was fed into this algorithm. The log-file + * will provide additional information then. + */ + iprFailure, + /// \brief This algorithm has NOT been applied because of a lack of processing time. + /** + * In most cases the acquisition frame rate(thus the frame rate generated on the device) was higher + * than the processing frame rate the host can handle and the user has explicitly + * configured the image processing mode to skip images then. + */ + iprSkipped, + /// \brief This algorithm has NOT been applied because it was not applicable. + /** + * This result will be reported whenever a buffer was fed into a filter that was not applicable. An example + * for such a situation would be a JPEG image that has been fed into a de-Bayer algorithm. + * + * \since 2.22.1 + */ + iprNotApplicable +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the behaviour of an mvIMPACT::acquire::ImageRequestControl. +/// \ingroup CommonInterface +enum TImageRequestControlMode +//----------------------------------------------------------------------------- +{ + /// \brief The standard mode for image requests. + /** + * In this mode one image will be captured from the hardware for each request + * that is send to the device driver. The image will be taken with respect to the + * current parameters as defined in the setting selected in the corresponding + * image request control. + */ + ircmManual, + /// \brief Reserved. Currently not implemented. + ircmLive, + /// \brief Reserved. Currently not implemented. + ircmCounting, + /// \brief In this mode no 'real' image will be captured, but the whole processing chain will be traversed once. + /** + * This mode can be used either to find out what the image format and parameters + * after an image capture would be with the current settings or to prepare + * the hardware before starting the first image acquisition to save time when + * real image data is processed. + * + * When requesting an image in this mode, the corresponding wait function will return + * a complete request object with pixel format, dimensions and image buffer that contains + * some dummy data. + */ + ircmTrial, + /// \brief In this mode no 'real' image will be captured, but the whole processing chain will be traversed once. + /** + * This mode can be used either to find out what the image format and parameters + * after an image capture would be with the current settings or to prepare + * the hardware before starting the first image acquisition to save time when + * real image data is processed. + * + * In this mode, no wait function must be called. When the image request function has + * returned successfully, the current destination buffer layout will be available as part + * of the general information properties. + */ + ircmUpdateBufferLayout +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the type of camera sensor. +/// \ingroup DeviceSpecificInterface +enum TInfoSensorColorMode +//----------------------------------------------------------------------------- +{ + /// \brief This is an unknown type of sensor. + iscmUnknown = 0, + /// \brief This is a mono sensor. + iscmMono, + /// \brief This is a Bayer color sensor. + iscmBayer, + /// \brief This is a color sensor. + iscmColor, + /// \brief This is a sensor sensitive in the near IF spectrum only. + iscmNIR +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the bayer pattern of the sensor. +/// \ingroup DeviceSpecificInterface +enum TInfoSensorColorPattern +//----------------------------------------------------------------------------- +{ + /// \brief This sensor starts to transmit a green pixel from a green and red line. + /** + * The raw image therefore is structured like this: + * + * GRGRGRGRGRGRG etc. \n + * BGBGBGBGBGBGB etc. \n + * GRGRGRGRGRGRG etc. \n + * etc. \n + */ + iscpGreenRed, + /// \brief This sensor starts to transmit a red pixel from a green and red line. + /** + * The raw image therefore is structured like this: + * + * RGRGRGRGRGRGR etc. \n + * GBGBGBGBGBGBG etc. \n + * RGRGRGRGRGRGR etc. \n + * etc. \n + */ + iscpRedGreen, + /// \brief This sensor starts to transmit a green pixel from a green and blue line. + /** + * The raw image therefore is structured like this: + * + * GBGBGBGBGBGBG etc. \n + * RGRGRGRGRGRGR etc. \n + * GBGBGBGBGBGBG etc. \n + * etc. \n + */ + iscpBlueGreen, + /// \brief This sensor starts to transmit a blue pixel from a green and blue line. + /** + * The raw image therefore is structured like this: + * + * BGBGBGBGBGBGB etc. \n + * GRGRGRGRGRGRG etc. \n + * BGBGBGBGBGBGB etc. \n + * etc. \n + */ + iscpGreenBlue, + /// \brief Nothing is known about the way the sensor transmits data. + iscpUnknown +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the type of camera sensor. +/// \ingroup DeviceSpecificInterface +enum TInfoSensorType +//----------------------------------------------------------------------------- +{ + /// \brief This is an unknown type of sensor. + istUnknown = 0, + /// \brief This is a CCD sensor. + istCCD = 0x1, + /// \brief This is a CMOS sensor. + istCMOS = 0x2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the enumeration behaviour of a certain interface of a third party GenTL producer. +/** + * \since 2.34.0 + */ +/// \ingroup CommonInterface +enum TInterfaceEnumerationBehaviour +//----------------------------------------------------------------------------- +{ + /// \brief The interface will enumerate devices or not according to the general enumeration behavior of this interface type(according to EnumerateEnable setting). + iebNotConfigured = 0, + /// \brief The interface will not enumerate devices, regardless of the general enumeration behavior of this interface type(overrides EnumerateEnable setting). + iebForceIgnore = 1, + /// \brief The interface will forcefully enumerate devices, regardless of the general enumeration behavior of this interface type(overrides EnumerateEnable setting). + iebForceEnumerate = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines how to handle interlaced image data. +/** + * Image data might be transmitted as fields. These later can either be combined + * back into a full frame or can be handled individually. + */ +/// \ingroup DeviceSpecificInterface +enum TInterlacedMode +//----------------------------------------------------------------------------- +{ + /// \brief Enable the interlaced function. + /** + * The device will re-construct the interlaced data into a full frame. + * InvInterlaced/Interlaced is controlled by the camera parameter. + */ + imOn = 0, + /// \brief Disable the interlaced function. + imOff = 1 +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Currently available for mvTITAN/mvGAMMA-CL. +/** + * If mvIMPACT::acquire::lcOn is used + * \if DOXYGEN_C_DOCUMENTATION + * mvIMPACT::acquire::RequestInfo::lineCounter + * \else + * mvIMPACT::acquire::Request::infoLineCounter + * \endif + * will contain the overall line count. + * + * mvTITAN/mvGAMMA-CL: The counter is implemented in the hardware. All incoming lines will be counted. + * A detected signal on the trigger input will reset the counter. In addition to the result + * the line count will be encoded in bit 0 of the first 32 Words (2-byte) of every line (watermark). + * + * To decode the line counter from a line of image data something like this is needed(pseudo-code): + * + * \code + * unsigned integer getWatermark( pointer pData ) + * { + * unsigned integer result = 0 + * do + * { + * result = result OR ( pData[i multiplied by 2] AND 0x1 ) shift_left_by(i) + * i + 1 + * } while( i < 32 ) + * return result + * } + * \endcode + */ +/// \ingroup DeviceSpecificInterface +enum TLineCounter +//----------------------------------------------------------------------------- +{ + /// \brief Disables line counter. + lcOff = 0, + /// \brief Enables line counter. + lcOn = 1 +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid LUT(LookUp Table) gamma modes. +/// \ingroup CommonInterface +enum TLUTGammaMode +//----------------------------------------------------------------------------- +{ + /// \brief Default gamma mode. + /** + * Maps an image by applying intensity transformation with gamma correction to the complete intensity range of the LUT. + */ + LUTgmStandard, + /// \brief Maps an image by applying a linear interpolation in the lower intensity range of the LUT and an intensity transformation with gamma correction to the upper intensity range of the LUT. + LUTgmLinearStart +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid LUT(LookUp Table) implementations. +/// \ingroup CommonInterface +enum TLUTImplementation +//----------------------------------------------------------------------------- +{ + /// \brief The mapping of the image data will be done in hardware. + /** + * When set to 'Hardware' the LUT operation will NOT introduce additional CPU load. + * This feature will no be available for every device. + */ + LUTiHardware, + /// \brief The mapping of the image data will be done with an optimized software algorithm. + LUTiSoftware +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid LUT(LookUp Table) interpolation modes. +/// \ingroup CommonInterface +enum TLUTInterpolationMode +//----------------------------------------------------------------------------- +{ + /// \brief Maps an image by applying intensity transformation based on a set of given threshold values. + LUTimThreshold, + /// \brief Maps an image by applying intensity transformation with linear interpolation. + LUTimLinear, + /// \brief Maps an image by applying intensity transformation with cubic interpolation. + LUTimCubic +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid LUT(LookUp Table) mapping modes. +/// \ingroup CommonInterface +enum TLUTMapping // uint_type +//----------------------------------------------------------------------------- +{ + /// \brief 8 bit input data will be mapped to 8 bit output data. + LUTm8To8 = ( 8 << 16 ) | 8, + /// \brief 10 bit input data will be mapped to 8 bit output data. + LUTm10To8 = ( 10 << 16 ) | 8, + /// \brief 10 bit input data will be mapped to 10 bit output data. + LUTm10To10 = ( 10 << 16 ) | 10, + /// \brief 12 bit input data will be mapped to 10 bit output data. + LUTm12To10 = ( 12 << 16 ) | 10, + /// \brief 12 bit input data will be mapped to 12 bit output data. + LUTm12To12 = ( 12 << 16 ) | 12, + /// \brief 14 bit input data will be mapped to 14 bit output data. + /** + * \since 2.0.2 + */ + LUTm14To14 = ( 14 << 16 ) | 14, + /// \brief 16 bit input data will be mapped to 16 bit output data. + /** + * \since 2.0.2 + */ + LUTm16To16 = ( 16 << 16 ) | 16 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid LUT(LookUp Table) modes. +/// \ingroup CommonInterface +enum TLUTMode +//----------------------------------------------------------------------------- +{ + /// \brief Maps an image by applying interpolated intensity transformation between a set of given sampling points. + LUTmInterpolated, + /// \brief Maps an image by applying intensity transformation with gamma correction. + /** + * Since the human eye perceives light similar to a logarithm of real light intensity it's characteristic curve is + * non-linear. It follows the rule of (intensity ^ gamma) with a gamma value between 0.3-0.5. + * To provide as much useful information as possible, the image is converted from 12-bit acquired by the sensor to 8-bit utilizing + * this characteristic curve. The result is a linearized image optimized for the human eye's non-linear behavior which allows + * to perceive as much intensity differences as possible. + * \image html Gamma_correction_filter.png +
Conversion from 12- to 8-bit utilizing the gamma function
+ */ + LUTmGamma, + /// \brief Maps an image by applying intensity transformation. + LUTmDirect +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes to operate the memory manager in. +/// \ingroup CommonInterface +enum TMemoryManagerMode +//----------------------------------------------------------------------------- +{ + /// \brief Automatic mode. + /** + * In this mode the DMA memory is only used as intermediate buffer. The user has no direct access to it + * instead he get always a copy of the image that resides on the heap. Internally the DMA memory is organized as + * ring buffer. It decouples the autonomous grabbing of the board from the application. The size of the + * memory should be big enough to hold as many images as requests are used in the application. + */ + mmmAuto = 0, + /// \brief Pool Mode + /** + * This mode allows direct access to the DMA memory. So its not necessary for the driver to make copies + * of the images. This improves the performance of the system. But there is one disadvantage: The + * partitioning of the DMA memory is fixed and has to be done by the user. The block size must be set + * to the image size in bytes. Additional the block count must be set. Before these parameters can be + * changed it must be sure that all ImageBuffers are returned and the grabber is stopped. + */ + mmmPool = 1 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the pool mode of memory manager. +/// \ingroup CommonInterface +enum TMemoryManagerPoolMode +//----------------------------------------------------------------------------- +{ + /// \brief Dont use Pool + mmpmOff = 0, + /// \brief Use Pool in Manual Mode + mmpmFixed = 1, + /// \brief Use Pool in Automatic Mode + mmpmAuto = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid mirror modes. +/** + * These enumeration values may be 'ored' together. + */ +/// \ingroup CommonInterface +enum TMirrorMode // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief No Mirroring. + mmOff = 0, + /// \brief The resulting image will be flipped around a horizontal axis. + mmTopDown = 0x1, + /// \brief The resulting image will be flipped around a vertical axis. + mmLeftRight = 0x2, + /// \brief The resulting image will be both around a horizontal and vertical axis. + mmTopDownAndLeftRight = mmTopDown | mmLeftRight +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid mirror operation modes. +/// \ingroup CommonInterface +enum TMirrorOperationMode +//----------------------------------------------------------------------------- +{ + /// \brief There will be a single mode option only and this mode will be applied to all channels + /// of the image. + momGlobal, + /// \brief The mirror mode can be selected for differently for each channel of the image. + momChannelBased +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for the handling of the device' on board memory (if available) +/// \ingroup DeviceSpecificInterface +enum TOnBoardMemoryMode +//----------------------------------------------------------------------------- +{ + /// \brief The device will work with reasonable default values. + /** + * This option will be the right choice for most of the user. + */ + obmmDefault, + /// \brief The user can define how the on board memory of the device will be used. + /** + * This is for advanced user only and will not be necessary in most of + * the cases. + */ + obmmUser +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for polarization data extraction filters. +/// \ingroup CommonInterface +/** + * \since 2.29.0 + */ +enum TPolarizedDataExtractionMode +//----------------------------------------------------------------------------- +{ + /// \brief The pixels will be re-arranged one after the other thus the resulting image will have a width of 'input image width / 2' and a height of 'input image height * 2' + /** + * The resulting image will consist of several small images sitting on top of each other. The first image will contain all the upper left + * pixels from each extraction ROI, the last image all the lower right pixels. The images in between will be extracted line by line and then row by row. + * + * \since 2.29.0 + */ + prmVertical, + /// \brief The pixels will be re-arranged one after the other thus the resulting image will have a width of 'input image width * 2' and a height of 'input image height / 2' + /** + * The resulting image will consist of several small images sitting next each other. The first image will contain all the upper left + * pixels from each extraction ROI, the last image all the lower right pixels. The images in between will be extracted line by line and then row by row. + * + * \since 2.29.0 + */ + prmHorizontal, + /// \brief The pixel selected by 'PolarizedDataExtractionChannelIndex' will be extracted and forwarded from each region defined by '2 * 2'. + /** + * The resulting image therefore will have a width equal to 'input image width / 2' and a height equal to 'input image height / 2' + * + * \since 2.29.0 + */ + prmExtractSingle, + /// \brief The pixel with the minimum value will be extracted and forwarded from each region defined by '2 * 2'. + /** + * The resulting image therefore will have a width equal to 'input image width / 2' and a height equal to 'input image height / 2' + * + * \since 2.29.0 + */ + prmMinimumValue, + /// \brief The mean value of all pixels whose value ranges from 'PolarizedDataExtractionLowerLimit' to 'PolarizedDataExtractionUpperLimit' will be calculated within each region defined by '2 * 2' in the source image and will be forwarded as a single new pixel in the destination image. + /** + * The resulting image therefore will have a width equal to 'input image width / 2' and a height equal to 'input image height / 2' + * + * \since 2.29.0 + */ + prmMeanValue, + /// \brief The pixels will be re-arranged in a way the image keeps its original dimension but each polarization angle will afterwards occupy a certain section in the image + /** + * The upper left quarter of the resulting image will contain all the upper left pixels from each 2 by 2 pixel region etc. + * + * \since 2.29.1 + */ + prm2By2, + /// \brief The angle of the maximum polarization for every '2 * 2' region in the image will be calculated and the resulting value will then be mapped to the value range of the source pixel format. + /** + * The resulting image therefore will have a width equal to 'input image width / 2' and a height equal to 'input image height / 2'. From each 2 by 2 region (thus 4 input values) a single output + * value will be calculated and placed into the resulting image. In this mode the output pixel format will be the same as the input pixel format and the resulting value will be mapped to this + * pixel formats value range thus the maximum angle (180 degree) will correspond the maximum pixel value in this format (e.g. 1023 for \b mvIMPACT::acquire::ibpfMono10). + * + * The angle of the maximum polarization is calculated based the formula: + * \f[\Theta = \frac{1}{2}*atan\left (\left ( P45-P135 \right ); \left (P0 - P90\right )\right ) \f] + * + * \warning Pixels which are saturated or which don't show a signal at all will cause incorrect polarization data. This happens as a result of wrong relations between the different + * polarization directions which causes wrong values for the different stokes parameters resulting in incorrect pixel data. Different exposure settings might improve the result. + * \since 2.38.0 + */ + prmExtractAngle, + /// \brief The degree of the polarization for every '2 * 2' region in the image will be calculated and the resulting value will then be mapped to the value range of the source pixel format. + /** + * The resulting image therefore will have a width equal to 'input image width / 2' and a height equal to 'input image height / 2'. From each 2 by 2 region (thus 4 input values) a single output + * value will be calculated and placed into the resulting image. In this mode the output pixel format will be the same as the input pixel format and the resulting value will be mapped to this + * pixel formats value range thus the maximum polarization will correspond the maximum pixel value in this format (e.g. 1023 for \b mvIMPACT::acquire::ibpfMono10). + * + * The calculation of the degree of the maximum polarization is based the formula: + * \f[\Pi = \frac{\sqrt{\left(P0-P90\right)^{2}+\left(P45-P135\right)^{2}}}{\left(P0+P90\right)}\f] + * + * \warning Pixels which are saturated or which don't show a signal at all will cause incorrect polarization data. This happens as a result of wrong relations between the different + * polarization directions which causes wrong values for the different stokes parameters resulting in incorrect pixel data. Different exposure settings might improve the result. + * \since 2.38.0 + */ + prmExtractDegree, + /// \brief The angle of the maximum polarization and the degree of the polarization for every '2 * 2' region in the image will be calculated and the resulting value will then be mapped to the value range of and 8-bit HSL image. + /** + * The angle and the degree are calculated as described in \b mvIMPACT::acquire::prmExtractDegree and \b \b mvIMPACT::acquire::prmExtractAngle mode. Afterwards the angle is used as hue and the degree is used as saturation value + * in the HSL color representation and converted to RGB color representation. + * + * The resulting image therefore will have a width equal to 'input image width / 2' and a height equal to 'input image height / 2'. From each 2 by 2 region (thus 4 input values) 2 output + * values will be calculated and placed into the resulting temporary HSL image. Afterwards this HSL image will transformed back to RGB to generate a pseudo-color image in \b mvIMPACT::acquire::ibpfRGB888Planar format. + * + * \warning Pixels which are saturated or which don't show a signal at all will cause incorrect polarization data. This happens as a result of wrong relations between the different + * polarization directions which causes wrong values for the different stokes parameters resulting in incorrect pixel data. Different exposure settings might improve the result. + * \since 2.38.0 + */ + prmPseudoColorRepresentation +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid modes for the interpolation mode of polarization data extraction filters. +/// \ingroup CommonInterface +/** + * \since 2.29.0 + */ +enum TPolarizedDataExtractionInterpolationMode +//----------------------------------------------------------------------------- +{ + /// \brief No interpolation + /** + * The resulting image therefore will have the same amount of pixels for horizontal or vertical polarization data extraction modes + * or a reduced number of pixels for all other modes. + * + * \since 2.29.0 + */ + primOff, + /// \brief Linear interpolation + /** + * The resulting image therefore will have either 4 times the number of pixels for horizontal or vertical polarization data extraction modes + * or the same dimensions as the input image for single extraction mode. The additional pixel data will be generated using + * linear interpolation algorithm + * + * \since 2.29.0 + */ + primLinear +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid pulse start trigger values. +/// \ingroup DeviceSpecificInterface +enum TPulseStartTrigger +//----------------------------------------------------------------------------- +{ + /// \brief Changes on one or more digital inputs will trigger the output of the pulse or pulse sequence. + pstDigitalSignal = 0, + /// \brief The output of a pulse or pulse sequence will be done periodically. + pstPeriodically, + /// \brief The output of a rotary decoder will trigger the output of the pulse or pulse sequence. + pstRotaryDecoder +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid image modes for request objects +/// \ingroup CommonInterface +enum TRequestImageMemoryMode +//----------------------------------------------------------------------------- +{ + /// \brief Automatic mode. + /** + * In this mode the driver will decide what kind of memory will be used, + * when it will be allocated and when it will be freed. + */ + rimmAuto, + /// \brief User supplied memory mode. + /** + * A request in this mode can capture data directly into a user supplied + * buffer. + * + * The user can assign a buffer to each request that has been set into this + * mode. However some devices require the capture memory to be aligned thus + * then the buffer supplied by the user must be aligned to the requirements + * of the driver as well. To find out, which alignment is needed, the property + * \a captureBufferAlignment must be queried. + */ + rimmUser +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid result of an image request. +/** + * Whenever during the processing of the capture parameters but well before the actual + * image capture and error is detected the MSB of this enumeration will be set to 1. + * In this case almost every time the current input parameters can't lead to a + * correct image and have to be changed. + */ +/// \ingroup CommonInterface +enum TRequestResult // uint_type +//----------------------------------------------------------------------------- +{ + /// \brief This image request has been processed successfully. + rrOK = 0, + /// \brief This image request resulted in a timeout. No image has been captured during the allowed period of time. + rrTimeout = 1, + /// \brief An error occurred during the processing of this request. + /** + * \b mvBlueFOX \b specific: + * This error typically results in some kind of USB transmission problem. The log-file will contain + * more information in that case. + */ + rrError = 2, + /// \brief This request has been aborted either because there are no free internal buffers or the user itself caused this abort e.g. by clearing the request queue. + rrRequestAborted = 3, + /// \brief An incomplete frame was transferred. + /** + * This can have several reasons, however the one most likely is that the transfer channel couldn't cope with + * the amount of data that was transmitted resulting in parts of the frame or in the worst case the complete + * frame being lost. + * + * This e.g. might happen if several network devices transmit at the same time or a single device (e.g. connected + * to a PCI bus transfers more data than the PCI bus can pass to the receiving end until a temporary buffer on the + * device runs full. The log output will contain additional information. + * + * If the information is available the property 'MissingData_pc' belonging to that request will contain information + * about the amount of data missing. Also some of the statistical properties will provide hints about how much + * data is lost. E.g. the properties 'MissingPacktesRecovered', 'RetransmitCount' and 'MissingDataAverage_pc' might + * be of interest here. Please note that not every property is supported by every device. + */ + rrFrameIncomplete = 4, + /// \brief The access to the device has been lost. + /** + * In this case no further access to the device will succeed. Only closing and re-opening the device + * will fix this problem. There can be numerous reasons for this error to occur, however the most likely one + * is that a device, that a timeout register inside the device, that needs to be refreshed constantly by + * the driver hasn't been refreshed during the timeout period. In this case the device will disconnect + * itself from the driver. This e.g. can happen if a network device is used and the application is operated in + * debug mode. For debugging the corresponding timeout register must be set to an appropriate value. + */ + rrDeviceAccessLost = 5, + /// \brief A complete buffer has been delivered, but it did fail to pass the internal validation check. + /** + * This e.g. might happen with drivers that transmit buffers that contain more than a pure block of pixel + * data. Examples for this might be run-length encoded images, or buffers with additional information + * somewhere in the buffer that will be interpreted by the device driver. This error is most likely a + * result of a device that doesn't transfer data in the requested format. The log output will contain + * additional information. + */ + rrInconsistentBufferContent = 6, + /// \brief The device has reported that an image acquisition did fail on the device side thus BEFORE the data transfer. + /** + * This e.g. might happen if a device is running low on local memory or because of some other problem detected + * on the device itself. This result status is just meant for information. The associated buffer will not contain + * valid image data. + */ + rrFrameCorrupt = 7, + /// \brief This request is not processible. + /** + * If this flag (the MSB) is set this either indicates that the current input parameters + * can't be used to capture an image (in that case the result will not be the MSB alone) + * or that an internal error occurred during the process of this request. + */ + rrUnprocessibleRequest = 0x80000000, + /// \brief No free buffer available to process this request. + /** + * To get more memory either some old requests should be unlocked or the size of the + * DMA memory (frame grabbers only) could be increased using the tools provided. + */ + rrNoBufferAvailable = rrUnprocessibleRequest | 1, + /// \brief There is not enough memory available to the driver to process the current image request. + /** + * To get more memory either some old requests should be unlocked or the size of the + * DMA memory (frame grabbers only) could be increased using the tools provided. + * + * Another possibility might be, that the process currently hosting the application cannot + * map all the capture memory requested by the application. In this case adding more memory to + * the system might solve the problem. Please note that when running on a 32 bit system no + * more than 2 GB of RAM can be used by a single process, thus applications demanding a lot + * of memory might still not run then. In this case only reducing the number of request buffers + * will help. + */ + rrNotEnoughMemory = rrUnprocessibleRequest | 2, + // Don't recycle these values + // rrScanStandardNotSupported = rrUnprocessibleRequest | 3, + // rrScanRateInvalid = rrUnprocessibleRequest | 4, + /// \brief The current camera description is not supported by the capture device. + /** + * This error code currently is relevant for frame grabbers only and might occur e.g. + * when selecting a MEDIUM CameraLink® camera description for a grabber, + * that only supports BASE cameras. + */ + rrCameraNotSupported = rrUnprocessibleRequest | 5, + // Don't recycle this value + // rrCameraUserAOINotSupported = rrUnprocessibleRequest | 6, + /// \brief The device does not support capturing data in the current configuration. + /** + * This error code will occur if a request has been sent to a device that does not + * support the acquisition of data. This can e.g. be the case + * + * - for GEV or U3V devices that do \b NOT support at least 1 streaming channel + * - for U3V devices that have been opened with mvIMPACT::acquire::damRead access + * + * \since 2.5.0 + */ + rrDataAcquisitionNotSupported = rrUnprocessibleRequest | 7 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the current state of this mvIMPACT::acquire::Request. +/// \ingroup CommonInterface +enum TRequestState +//----------------------------------------------------------------------------- +{ + /// \brief This mvIMPACT::acquire::Request is currently unused. + rsIdle, + /// \brief This mvIMPACT::acquire::Request has been sent into the drivers image request queue and currently awaits processing. + rsWaiting, + /// \brief This mvIMPACT::acquire::Request is currently being processed. + rsCapturing, + /// \brief This mvIMPACT::acquire::Request has been processed. + /** + * The user is now responsible for this request. Before this mvIMPACT::acquire::Request is not unlocked + * again it can't be used by the driver. A mvIMPACT::acquire::Request in this state can safely be processed + * by the user. Its data will remain valid until either the mvIMPACT::acquire::Request is unlocked by + * the user or the device is closed. + */ + rsReady, + /// \brief This mvIMPACT::acquire::Request is currently in configuration mode. + /** + * Within this mode certain properties of the request object will become writeable, which + * e.g. will allow the user to pass a capture buffer to the request object. + */ + rsBeingConfigured +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid RTCtrl Modes. +/// \ingroup DeviceSpecificInterface +enum TRTCtrlModes +//----------------------------------------------------------------------------- +{ + /// \brief RTC switched off and editable. + rtctrlModeStop, + /// \brief RTC switched on and NOT editable. + rtctrlModeRun, + /// \brief RTC switched on and restart after changes. + rtctrlModeRunRestart +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid RTProg OpCodes. +/// \ingroup DeviceSpecificInterface +enum TRTProgOpCodes +//----------------------------------------------------------------------------- +{ + /// \brief Do nothing. + rtctrlProgNop, + /// \brief Set digital outputs. + rtctrlProgSetDigout, + /// \brief Wait for digital inputs. + rtctrlProgWaitDigin, + /// \brief Wait for n clocks. + rtctrlProgWaitClocks, + /// \brief Jump to location. + rtctrlProgJumpLoc, + /// \brief Set internal trigger signal of the sensor controller. + rtctrlProgTriggerSet, + /// \brief Reset internal trigger signal of the sensor controller. + rtctrlProgTriggerReset, + /// \brief Set internal expose signal of the sensor controller. + rtctrlProgExposeSet, + /// \brief Reset internal expose signal of the sensor controller. + rtctrlProgExposeReset, + /// \brief Reset internal sensor frame counter. + rtctrlProgFrameNrReset, + /// \brief Jump to location if a certain register contains zero. + rtctrlProgJumpLocOnZero, + /// \brief Jump to location if a certain register differs from zero. + rtctrlProgJumpLocOnNotZero, + /// \brief Set a registers value. + rtctrlProgRegisterSet, + /// \brief Add a constant value to a register. + rtctrlProgRegisterAdd, + /// \brief Subtract a constant value from a register. + rtctrlProgRegisterSub +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid scaler interpolation modes. +/// \ingroup CommonInterface +enum TScalerInterpolationMode +//----------------------------------------------------------------------------- +{ + /// \brief Nearest neighbor interpolation (default). + simNearestNeighbor, + /// \brief Linear interpolation. + simLinear, + /// \brief Cubic interpolation. + simCubic +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid scaler modes. +/// \ingroup CommonInterface +enum TScalerMode +//----------------------------------------------------------------------------- +{ + /// \brief The scaler is switched off (default). + smOff, + /// \brief The scaler is switched on. + smOn +}; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Analogue grabbers generate its scan clock on different ways. +/// \ingroup DeviceSpecificInterface +enum TScanClock +//----------------------------------------------------------------------------- +{ + /// \brief The cameras clock signal is used. + /** + * If the property \a pixelClockOutput in the camera description is either set to + * mvIMPACT::acquire::ceseFallingEdge or + * mvIMPACT::acquire::ceseRisingEdge. + * Otherwise mvIMPACT::acquire::scAnalogue is used for mvTITAN-RGB + * and mvTITAN-G1 devices and mvIMPACT::acquire::scDigital for + * mvGAMMA-G devices. Other devices currently do not support this feature. + */ + scAuto, + /// \brief The scan clock is generated by genlocking on horizontal sync.(HD) signal. + /** + * ADVANTAGES: \n + * - very small jitter (typically around some 100 pico seconds) -> suitable for high pixel clock (>20Mhz) + * - for matching HD freq. values (with respect to the signal send by the camera) this will produce + * results almost as good as when working with an external clock signal(less scan artifacts) + * + * DISADVANTAGES: \n + * - slow reaction time -> not suitable for fast channel switching + * - not suitable for signals with a pixel clock below 12 MHz + */ + scAnalogue, + /// \brief The scan clock is generated digitally. + /** + * ADVANTAGE: \n + * - locked after a single line, therefore this mode is very useful for fast channel switching + * + * DISADVANTAGE: \n + * - bigger jitter as the analogue mode(<10ns), therefore not suitable for cameras with a pixel clock higher than about 20Mhz + */ + scDigital +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid scan modes for standard cameras. +/// \ingroup DeviceSpecificInterface +enum TScanStandard +//----------------------------------------------------------------------------- +{ + /// \brief 720 x 576 Pixels for 50 Hz standard cameras, 720 x 480 Pixels for 60 Hz standard cameras + ssITU601, + /// \brief 768 x 576 Pixels for 50 Hz standard cameras, 640 x 480 Pixels for 60 Hz standard cameras + ssSquare, + /// \brief The user can define scan rate and camera AOI + ssUser +}; +#endif // IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines a trigger moment for a digital signal. +/** + * This can e.g. be the moment a signal connected to a device changes it state + * or reaches a certain state. + */ +/// \ingroup DeviceSpecificInterface +enum TTriggerMoment +//----------------------------------------------------------------------------- +{ + /// \brief A falling edge will trigger the event. + tmOnFallingEdge = 0, + /// \brief A rising edge will trigger the event. + tmOnRisingEdge +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid flags for controlling the user access rights to the user data that can be stored in the devices non-volatile memory. +/// \ingroup CommonInterface +enum TUserDataAccessRight // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief The user has read rights for this entry. + udarRead = 0x1, + /// \brief The user has principle write rights for this entry. + /** + * If mvIMPACT::acquire::udarPassword is not set for this entry or + * the corresponding password has been set correctly, the user can modify the + * corresponding entry. + */ + udarWrite = 0x2, + /// \brief Just combines mvIMPACT::acquire::udarRead and mvIMPACT::acquire::udarWrite. + udarRW = udarRead | udarWrite, + /// \brief A password is needed to modify this entry. + /** + * Even if mvIMPACT::acquire::udarWrite is specified the user can only modify this entry + * if the correct password has been set. + */ + udarPassword = 0x4, + /// \brief Combines all other flags. + udarFull = udarRW | udarPassword +}; + +//----------------------------------------------------------------------------- +/// \brief Defined valid values for the behaviour of the user data when a device has been disconnected and reconnected within a running process. +/// \ingroup CommonInterface +enum TUserDataReconnectBehaviour +//----------------------------------------------------------------------------- +{ + /// \brief Keep the data currently buffered in the properties describing the user data. + /** + * When the user data has been modified on another machine this + * will result in a loss of that data once this buffered data is written back + * to the devices non-volatile memory. + */ + udrbKeepCachedData, + /// \brief Updates the properties describing the user data with the fresh data as read from the devices non-volatile memory. + /** + * This might result in the loss of data that has been edited but NOT written + * to the devices non-volatile memory if this data differs from the current + * data stored in the devices non-volatile memory. + */ + udrbUpdateFromDeviceData +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid video codecs that might be supported by the underlying video compression engine. +/// \ingroup CommonInterface +enum TVideoCodec +//----------------------------------------------------------------------------- +{ + /// \brief MPEG2. + /** + * Recommend file extension for this codec: .m2v + * + * Supported input pixel formats for this video codec: + * - \b mvIMPACT::acquire::ibpfYUV422Packed + * - \b mvIMPACT::acquire::ibpfYUV422Planar + */ + vcMPEG2 = 2, + /// \brief H264. + /** + * Recommend file extension for this codec: .mp4 + * + * Supported input pixel formats for this video codec: + * - \b mvIMPACT::acquire::ibpfYUV422Packed + * - \b mvIMPACT::acquire::ibpfYUV422Planar + */ + vcH264 = 27, + /// \brief H265. + /** + * Recommend file extension for this codec: .mp4 + * + * Supported input pixel formats for this video codec: + * - \b mvIMPACT::acquire::ibpfYUV422Packed + * - \b mvIMPACT::acquire::ibpfYUV422Planar + */ + vcH265 = 173 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid video standards that might be supported by a video capture device. +/// \ingroup CommonInterface +enum TVideoStandard +//----------------------------------------------------------------------------- +{ + /// \brief CCIR video signal: Grey, 50 fields per second, 625 lines. + vsCCIR, + /// \brief RS 170 video signal: Grey, 60 fields per second, 525 lines. + vsRS170, + /// \brief PAL video signal: Color, 50 fields per second, 625 lines. + vsPALBGH, + /// \brief NTSC video signal: Color, 60 fields per second, 525 lines. + vsNTSCM, + /// \brief SDI video signal: 60 fields per second, 480 lines, interlaced. + vsSDI480i, + /// \brief SDI video signal: 50 fields per second, 576 lines, interlaced. + vsSDI576i, + /// \brief SDI video signal: Different frame rates, 720 lines, progressive. + vsSDI720p, + /// \brief SDI video signal: Different frame rates, 1080 lines, interlaced. + vsSDI1080i, + /// \brief SDI video signal: Different frame rates, 1080 lines, progressive. + vsSDI1080p +}; + +#ifndef IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Defines valid image types used when capturing data from a certain directory. +/** + * These enums may be 'ored' together. + */ +/// \ingroup DeviceSpecificInterface +enum TVirtualDeviceImageType // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief Will capture none of the recognized image formats + vditNone = 0x00000000, + /// \brief Will capture BMP files. + vditBMP = 0x000000001, + /// \brief Will capture PGM files. + vditPGM = 0x000000002, + /// \brief Will capture PNG files. + /** + * \note + * This requires the FreeImage (see http://freeimage.sourceforge.net/) library being present on the target system. See \b Use \b Cases section of the mvVirtualDriver for details. + * + * \since 2.11.9 + * + */ + vditPNG = 0x000000004, + /// \brief Will capture JPG files. + /** + * \note + * This requires the FreeImage (see http://freeimage.sourceforge.net/) library being present on the target system. See \b Use \b Cases section of the mvVirtualDriver for details. + * + * \since 2.11.9 + * + */ + vditJPG = 0x000000008, + /// \brief Will capture TIFF files. + /** + * \note + * This requires the FreeImage (see http://freeimage.sourceforge.net/) library being present on the target system. See \b Use \b Cases section of the mvVirtualDriver for details. + * + * \since 2.11.9 + * + */ + vditTIFF = 0x000000010, + /// \brief Will capture all supported image formats. + vditALL = vditBMP | vditPGM | vditPNG | vditJPG | vditTIFF +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid test modes for virtual devices. +/// \ingroup DeviceSpecificInterface +enum TVirtualDeviceTestMode +//----------------------------------------------------------------------------- +{ + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGBx888Packed. + vdtmMovingRGBx888PackedImage, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGB888Packed. + vdtmMovingRGB888PackedImage, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGBx888Planar. + vdtmMovingRGBx888PlanarImage, + /// \brief Will generate a moving horizontal test pattern with a mono pixel format. + vdtmMovingMonoRamp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfYUV422Packed or mvIMPACT::acquire::ibpfYUV422_10Packed depending on the value of the 'ChannelBitDepth' property. + vdtmMovingYUV422PackedRamp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfYUV422Planar. + vdtmMovingYUV422PlanarRamp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGB101010Packed. + vdtmMovingRGB101010PackedImage, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGB121212Packed. + vdtmMovingRGB121212PackedImage, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGB141414Packed. + vdtmMovingRGB141414PackedImage, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGB161616Packed. + vdtmMovingRGB161616PackedImage, + /// \brief Will generate a moving Bayer test pattern. + vdtmMovingBayerDataRamp, + /// \brief Will generate a still Bayer test pattern that can be used for white balancing. + vdtmBayerWhiteBalanceTestImage, + /// \brief Will capture images from a user supplied directory. + vdtmImageDirectory, + /// \brief Will generate a still 8 bit Bayer test pattern for leaky pixel calibration. + vdtmLeakyPixelTestImageMono8Bayer, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfYUV422_UYVYPacked or mvIMPACT::acquire::ibpfYUV422_UYVY_10Packed depending on the value of the 'ChannelBitDepth' property. + vdtmMovingYUV422_UYVYPackedRamp, + /// \brief Will generate a horizontal mono ramp. + vdtmHorizontalMonoRamp, + /// \brief Will generate a vertical mono ramp. + vdtmVerticalMonoRamp, + /// \brief Will generate a moving vertical mono ramp. + vdtmMovingVerticalMonoRamp, + /// \brief Will generate a horizontal mono ramp with pixel format mvIMPACT::acquire::ibpfMono12Packed_V2. + vdtmHorizontalMono12Packed_V2Ramp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfBGR888Packed. + vdtmMovingBGR888PackedImage, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfYUV444Packed or mvIMPACT::acquire::ibpfYUV444_10Packed depending on the value of the 'ChannelBitDepth' property. + vdtmMovingYUV444PackedRamp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfYUV444_UYVPacked or mvIMPACT::acquire::ibpfYUV444_UYV_10Packed depending on the value of the 'ChannelBitDepth' property. + vdtmMovingYUV444_UYVPackedRamp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfBGR101010Packed_V2. + vdtmMovingBGRPacked_V2Image, + /// \brief Will just allocate but not initialize a mono buffer. + vdtmEmptyMonoBuffer, + /// \brief Will generate a horizontal mono ramp with pixel format mvIMPACT::acquire::ibpfMono12Packed_V1. + /** + * \since 2.5.0 + */ + vdtmHorizontalMono12Packed_V1Ramp, + /// \brief Will generate a horizontal Bayer ramp with pixel format mvIMPACT::acquire::ibpfMono12Packed_V1. + /** + * \since 2.5.2 + */ + vdtmHorizontalBayer12Packed_V1Ramp, + /// \brief Will generate a horizontal Bayer ramp with pixel format mvIMPACT::acquire::ibpfMono12Packed_V2. + /** + * \since 2.5.2 + */ + vdtmHorizontalBayer12Packed_V2Ramp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfYUV411_UYYVYY_Packed. + /** + * \since 2.13.0 + */ + vdtmMovingYUV411_UYYVYY_PackedRamp, + /// \brief Will generate a moving test pattern with pixel format mvIMPACT::acquire::ibpfRGB888Planar. + /** + * \since 2.17.0 + */ + vdtmMovingRGB888PlanarImage, + /// \brief Will generate a still Bayer test pattern for hot and cold pixel calibration. + /** + * \since 2.31.0 + */ + vdtmHotAndColdPixelTestImageBayer, + /// \brief Will generate a still RGB8 test pattern for hot and cold pixel calibration. + /** + * \since 2.33.0 + */ + vdtmHotAndColdPixelTestImageRGB888Packed +}; +#endif // #ifndef IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Defines valid white balance calibration modes. +/// \ingroup CommonInterface +enum TWhiteBalanceCalibrationMode +//----------------------------------------------------------------------------- +{ + /// \brief Do not perform calibration, current values will be used. + wbcmOff = 0, + /// \brief Use the next image to perform the white balance calibration. + /** + * This is defined for bayer color sensors only. + */ + wbcmNextFrame, + /// \brief Do a continuous white balance calibration. + wbcmContinuous +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid parameter sets selectable via the \a WhiteBalance property. +/// \ingroup CommonInterface +enum TWhiteBalanceParameter +//----------------------------------------------------------------------------- +{ + /// \brief A set of constant parameters optimised for scenes illuminated by tungsten light sources. + wbpTungsten = 0, + /// \brief A set of constant parameters optimised for scenes illuminated by halogen light sources. + wbpHalogen, + /// \brief A set of constant parameters optimised for scenes illuminated by fluorescent light sources. + wbpFluorescent, + /// \brief A set of constant parameters optimised for scenes illuminated by day light. + wbpDayLight, + /// \brief A set of constant parameters optimised for scenes illuminated by photo flash light sources. + wbpPhotoFlash, + /// \brief A set of constant parameters optimised for scenes illuminated by day light and perfect weather. + wbpBlueSky, + /// \brief A parameter set which can be modified by the user. + wbpUser1, + /// \brief A parameter set which can be modified by the user. + wbpUser2, + /// \brief A parameter set which can be modified by the user. + wbpUser3, + /// \brief A parameter set which can be modified by the user. + wbpUser4 +}; + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +typedef enum TAcquisitionField TAcquisitionField; +typedef enum TAcquisitionMode TAcquisitionMode; +typedef enum TAcquisitionStartStopBehaviour TAcquisitionStartStopBehaviour; +typedef enum TAoiMode TAoiMode; +typedef enum TAutoControlMode TAutoControlMode; +typedef enum TAutoControlSpeed TAutoControlSpeed; +typedef enum TAutoExposureControl TAutoExposureControl; +typedef enum TAutoGainControl TAutoGainControl; +typedef enum TAutoOffsetCalibration TAutoOffsetCalibration; +typedef enum TBayerConversionMode TBayerConversionMode; +typedef enum TBayerMosaicParity TBayerMosaicParity; +typedef enum TBayerWhiteBalanceResult TBayerWhiteBalanceResult; +typedef enum TBlueFOXDigitalInputThreshold TBlueFOXDigitalInputThreshold; +typedef enum TBlueFOXFooterMode TBlueFOXFooterMode; +typedef enum TBlueFOXInfoSensorCapabilities TBlueFOXInfoSensorCapabilities; +typedef enum TBlueFOXOffsetAutoBlackSpeed TBlueFOXOffsetAutoBlackSpeed; +typedef enum TBlueFOXSensorTiming TBlueFOXSensorTiming; +typedef enum TBlueFOXTransferSize TBlueFOXTransferSize; +typedef enum TBoolean TBoolean; +typedef enum TBufferPartDataType TBufferPartDataType; +typedef enum TCameraAoiMode TCameraAoiMode; +typedef enum TCameraBinningMode TCameraBinningMode; +typedef enum TCameraDataFormat TCameraDataFormat; +typedef enum TCameraExposeMode TCameraExposeMode; +typedef enum TCameraExternalSyncEdge TCameraExternalSyncEdge; +typedef enum TCameraExternalSyncOutput TCameraExternalSyncOutput; +typedef enum TCameraFlashMode TCameraFlashMode; +typedef enum TCameraFlashType TCameraFlashType; +typedef enum TCameraHDRMode TCameraHDRMode; +typedef enum TCameraInterlacedType TCameraInterlacedType; +typedef enum TCameraLinkDataValidMode TCameraLinkDataValidMode; +typedef enum TCameraOutput TCameraOutput; +typedef enum TCameraPixelClock TCameraPixelClock; +typedef enum TCameraScanMode TCameraScanMode; +typedef enum TCameraSerialPortBaudRate TCameraSerialPortBaudRate; +typedef enum TCameraShutterMode TCameraShutterMode; +typedef enum TCameraTapsXGeometry TCameraTapsXGeometry; +typedef enum TCameraTapsYGeometry TCameraTapsYGeometry; +typedef enum TCameraTestMode TCameraTestMode; +typedef enum TCameraTriggerMode TCameraTriggerMode; +typedef enum TCameraTriggerSource TCameraTriggerSource; +typedef enum TChannelSplitMode TChannelSplitMode; +typedef enum TClampMode TClampMode; +typedef enum TColorTwistInputCorrectionMatrixMode TColorTwistInputCorrectionMatrixMode; +typedef enum TColorTwistOutputCorrectionMatrixMode TColorTwistOutputCorrectionMatrixMode; +typedef enum TColorProcessingMode TColorProcessingMode; +typedef enum TDarkCurrentFilterMode TDarkCurrentFilterMode; +typedef enum TDefectivePixelsFilterMode TDefectivePixelsFilterMode; +typedef enum TDeviceAccessMode TDeviceAccessMode; +typedef enum TDeviceAdvancedOptions TDeviceAdvancedOptions; +typedef enum TDeviceAutoNegotiatePacketSizeMode TDeviceAutoNegotiatePacketSizeMode; +typedef enum TDeviceCapability TDeviceCapability; +typedef enum TDeviceClass TDeviceClass; +typedef enum TDeviceDigitalOutputMode TDeviceDigitalOutputMode; +#if !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +typedef enum TDeviceEventMode TDeviceEventMode; +typedef enum TDeviceEventType TDeviceEventType; +#endif // #if !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +typedef enum TDeviceImageTrigger TDeviceImageTrigger; +typedef enum TDeviceInterfaceLayout TDeviceInterfaceLayout; +typedef enum TDeviceLoadSettings TDeviceLoadSettings; +typedef enum TDevicePowerMode TDevicePowerMode; +typedef enum TDeviceScanRateMode TDeviceScanRateMode; +typedef enum TDeviceSignalOutputStartEvent TDeviceSignalOutputStartEvent; +typedef enum TDeviceState TDeviceState; +typedef enum TDeviceSyncOutMode TDeviceSyncOutMode; +typedef enum TDeviceTriggerInterface TDeviceTriggerInterface; +typedef enum TDeviceTriggerMode TDeviceTriggerMode; +typedef enum TDeviceTriggerOverlap TDeviceTriggerOverlap; +typedef enum TDigIOState TDigIOState; +typedef enum TDigitalIOMeasurementMode TDigitalIOMeasurementMode; +typedef enum TDigitalIOMeasurementSource TDigitalIOMeasurementSource; +typedef enum TDigitalOutputControlMode TDigitalOutputControlMode; +typedef enum TDigitalSignal TDigitalSignal; +typedef enum TDMR_ERROR TDMR_ERROR; +typedef enum TFirmwareUpdateAction TFirmwareUpdateAction; +typedef enum TFirmwareUpdateStep TFirmwareUpdateStep; +typedef enum TFieldGateMode TFieldGateMode; +typedef enum TFlatFieldFilterCorrectionMode TFlatFieldFilterCorrectionMode; +typedef enum TFlatFieldFilterMode TFlatFieldFilterMode; +typedef enum THWUpdateResult THWUpdateResult; +typedef enum TI2COperationMode TI2COperationMode; +typedef enum TI2COperationStatus TI2COperationStatus; +typedef enum TImageBufferFormatReinterpreterMode TImageBufferFormatReinterpreterMode; +typedef enum TImageBufferPixelFormat TImageBufferPixelFormat; +typedef enum TImageDestinationPixelFormat TImageDestinationPixelFormat; +typedef enum TImageFileFormat TImageFileFormat; +typedef enum TImageProcessingFilter TImageProcessingFilter; +typedef enum TImageProcessingMode TImageProcessingMode; +typedef enum TImageProcessingOptimization TImageProcessingOptimization; +typedef enum TImageProcessingResult TImageProcessingResult; +typedef enum TImageRequestControlMode TImageRequestControlMode; +typedef enum TInfoSensorColorMode TInfoSensorColorMode; +typedef enum TInfoSensorColorPattern TInfoSensorColorPattern; +typedef enum TInfoSensorType TInfoSensorType; +typedef enum TInterfaceEnumerationBehaviour TInterfaceEnumerationBehaviour; +typedef enum TInterlacedMode TInterlacedMode; +typedef enum TLineCounter TLineCounter; +typedef enum TLUTGammaMode TLUTGammaMode; +typedef enum TLUTImplementation TLUTImplementation; +typedef enum TLUTInterpolationMode TLUTInterpolationMode; +typedef enum TLUTMapping TLUTMapping; +typedef enum TLUTMode TLUTMode; +typedef enum TMemoryManagerMode TMemoryManagerMode; +typedef enum TMemoryManagerPoolMode TMemoryManagerPoolMode; +typedef enum TMirrorMode TMirrorMode; +typedef enum TMirrorOperationMode TMirrorOperationMode; +typedef enum TOnBoardMemoryMode TOnBoardMemoryMode; +typedef enum TPolarizedDataExtractionMode TPolarizedDataExtractionMode; +typedef enum TPolarizedDataExtractionInterpolationMode TPolarizedDataExtractionInterpolationMode; +typedef enum TPulseStartTrigger TPulseStartTrigger; +typedef enum TRequestImageMemoryMode TRequestImageMemoryMode; +typedef enum TRequestResult TRequestResult; +typedef enum TRequestState TRequestState; +typedef enum TRTCtrlModes TRTCtrlModes; +typedef enum TRTProgOpCodes TRTProgOpCodes; +typedef enum TScalerInterpolationMode TScalerInterpolationMode; +typedef enum TScalerMode TScalerMode; +typedef enum TScanClock TScanClock; +typedef enum TScanStandard TScanStandard; +typedef enum TTriggerMoment TTriggerMoment; +typedef enum TUserDataAccessRight TUserDataAccessRight; +typedef enum TUserDataReconnectBehaviour TUserDataReconnectBehaviour; +typedef enum TVideoCodec TVideoCodec; +typedef enum TVideoStandard TVideoStandard; +typedef enum TVirtualDeviceImageType TVirtualDeviceImageType; +typedef enum TVirtualDeviceTestMode TVirtualDeviceTestMode; +typedef enum TWhiteBalanceCalibrationMode TWhiteBalanceCalibrationMode; +typedef enum TWhiteBalanceParameter TWhiteBalanceParameter; + +#ifdef __GNUC__ +# define ATTR_PACK_FOUR __attribute__((packed)) __attribute__ ((aligned (4))) +#else +#define ATTR_PACK_FOUR +# pragma pack(push, 4) // 4 byte structure alignment +#endif // #ifdef __GNUC__ + +//----------------------------------------------------------------------------- +/// \brief A structure containing information about the currently running firmware update process +struct FirmwareUpdateStatusData +//----------------------------------------------------------------------------- +{ + unsigned int structSize; + TFirmwareUpdateStep updateStep; + int progressPercent; + double timeElapsed_s; +} ATTR_PACK_FOUR; + +#ifndef __GNUC__ +# pragma pack(pop) // restore previous structure alignment +#endif +#undef ATTR_PACK_FOUR +typedef struct FirmwareUpdateStatusData FirmwareUpdateStatusData; + +//----------------------------------------------------------------------------- +/// \brief A prototype for a callback function that is attached to a firmware update process. +/** + * This callback will be executed to inform the user about the progress of the firmware update. + */ +typedef int( *CBP_FIRMWARE_UPDATE )( /// The pointer to the associated FirmwareUpdater object + void* pUserData, + /// The information about the internal states + FirmwareUpdateStatusData* statusData, + /// The size of the statusData structure + unsigned long sizeStatusData ); +//----------------------------------------------------------------------------- +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef __cplusplus +} +#endif // __cplusplus + +// restore Borland compiler switch 'force enums to the size of integer' +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ +# pragma option pop +# endif // __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#endif // mvDriverBaseEnumsH diff --git a/Cigarette/MvIMPACT/DriverBase/Include/mvVersionInfo.h b/Cigarette/MvIMPACT/DriverBase/Include/mvVersionInfo.h new file mode 100644 index 0000000..a2fc4cd --- /dev/null +++ b/Cigarette/MvIMPACT/DriverBase/Include/mvVersionInfo.h @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvVersionInfoH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvVersionInfoH mvVersionInfoH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- + +#if !defined(mvDriverBaseEnumsH) && !defined(SWIG) +# error "This file must NOT be included directly! Include mvDeviceManager.h(C-API) or mvIMPACT_acquire.h(C++ API) instead" +#endif // #if !defined(mvDriverBaseEnumsH) && !defined(SWIG) + +/// \brief Returns the major version number of the current mvIMPACT Acquire release. +/** + * \returns The major version number of mvIMPACT Acquire +*/ +#define MVIMPACT_ACQUIRE_MAJOR_VERSION 2 + +/// \brief Returns the minor version number of the current mvIMPACT Acquire release. +/** + * \returns The minor version number of mvIMPACT Acquire +*/ +#define MVIMPACT_ACQUIRE_MINOR_VERSION 43 + +/// \brief Returns the release version number of the current mvIMPACT Acquire release. +/** + * \returns The release version number of mvIMPACT Acquire +*/ +#define MVIMPACT_ACQUIRE_RELEASE_VERSION 0 + +/// \brief Returns the build version number of the current mvIMPACT Acquire release. +/** + * \returns The build version number of mvIMPACT Acquire +*/ +#define MVIMPACT_ACQUIRE_BUILD_VERSION 3180 + +/// \brief Returns the full version number of the current mvIMPACT Acquire release as a string ("2.43.0.3180"). +/** + * \returns The full version string of mvIMPACT Acquire +*/ +#define MVIMPACT_ACQUIRE_VERSION_STRING "2.43.0.3180" + +/// \brief This is a macro which evaluates to true if the current mvIMPACT Acquire version is at least major.minor.release. +/** + * For example, to test if the program will be compiled with mvIMPACT Acquire 2.0 or higher, the following can be done: + * + * \code + * HDISP hDisp = getDisplayHandleFromSomewhere(); + * #if MVIMPACT_ACQUIRE_CHECK_VERSION(2, 0, 0) + * mvDispWindowDestroy( hDisp ); + * #else // replacement code for old version + * mvDestroyImageWindow( hDisp ); + * #endif + * \endcode + * + * \since 2.0.0 + */ +#define MVIMPACT_ACQUIRE_CHECK_VERSION(MAJOR, MINOR, RELEASE) \ + (MVIMPACT_ACQUIRE_MAJOR_VERSION > (MAJOR) || \ + (MVIMPACT_ACQUIRE_MAJOR_VERSION == (MAJOR) && MVIMPACT_ACQUIRE_MINOR_VERSION > (MINOR)) || \ + (MVIMPACT_ACQUIRE_MAJOR_VERSION == (MAJOR) && MVIMPACT_ACQUIRE_MINOR_VERSION == (MINOR) && MVIMPACT_ACQUIRE_RELEASE_VERSION >= (RELEASE))) + +#endif // mvVersionInfoH diff --git a/Cigarette/MvIMPACT/apps/Common/CommonGUIFunctions.cpp b/Cigarette/MvIMPACT/apps/Common/CommonGUIFunctions.cpp new file mode 100644 index 0000000..0aed856 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/CommonGUIFunctions.cpp @@ -0,0 +1,40 @@ +#include "CommonGUIFunctions.h" + +#include "wxIncludePrologue.h" +#include +#include "wxIncludeEpilogue.h" + +//----------------------------------------------------------------------------- +void RunThreadAndShowProgress( wxThread* pThread, wxProgressDialog* pDlg, unsigned long threadInterval_ms, int maxExecutionTime_ms ) +//----------------------------------------------------------------------------- +{ + pThread->Create(); + pThread->Run(); + while( pThread->IsRunning() ) + { + wxMilliSleep( threadInterval_ms ); + if( pDlg ) + { + pDlg->Pulse(); + } + } + pThread->Wait(); + if( pDlg ) + { + pDlg->Update( maxExecutionTime_ms ); + } +} + +//----------------------------------------------------------------------------- +void UpdateDeviceListWithProgressMessage( wxWindow* pParent, const mvIMPACT::acquire::DeviceManager& devMgr ) +//----------------------------------------------------------------------------- +{ + static const int MAX_TIME_MS = 10000; + wxProgressDialog progressDialog( wxT( "Scanning For Drivers, Interfaces and Devices" ), + wxT( "Scanning for drivers, interfaces and devices...\n\nThis dialog will disappear automatically once this operation completes!" ), + MAX_TIME_MS, // range + pParent, + wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME ); + UpdateDeviceListThread thread( devMgr ); + RunThreadAndShowProgress( &thread, &progressDialog, 100, MAX_TIME_MS ); +} diff --git a/Cigarette/MvIMPACT/apps/Common/CommonGUIFunctions.h b/Cigarette/MvIMPACT/apps/Common/CommonGUIFunctions.h new file mode 100644 index 0000000..b38f05a --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/CommonGUIFunctions.h @@ -0,0 +1,37 @@ +//----------------------------------------------------------------------------- +#ifndef CommonGUIFunctionsH +#define CommonGUIFunctionsH CommonGUIFunctionsH +//----------------------------------------------------------------------------- +#include + +#include "wxIncludePrologue.h" +#include +#include "wxIncludeEpilogue.h" + +class wxProgressDialog; +class wxWindow; + +void RunThreadAndShowProgress( wxThread* pThread, wxProgressDialog* pDlg, unsigned long threadInterval_ms, int maxExecutionTime_ms ); + +//============================================================================= +//================= Implementation UpdateDeviceListThread ===================== +//============================================================================= +//------------------------------------------------------------------------------ +class UpdateDeviceListThread : public wxThread +//------------------------------------------------------------------------------ +{ + const mvIMPACT::acquire::DeviceManager& devMgr_; +protected: + void* Entry( void ) + { + devMgr_.updateDeviceList(); + return 0; + } +public: + explicit UpdateDeviceListThread( const mvIMPACT::acquire::DeviceManager& devMgr ) : wxThread( wxTHREAD_JOINABLE ), + devMgr_( devMgr ) {} +}; + +void UpdateDeviceListWithProgressMessage( wxWindow* pParent, const mvIMPACT::acquire::DeviceManager& devMgr ); + +#endif // CommonGUIFunctionsH diff --git a/Cigarette/MvIMPACT/apps/Common/Info.h b/Cigarette/MvIMPACT/apps/Common/Info.h new file mode 100644 index 0000000..33af3eb --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/Info.h @@ -0,0 +1,12 @@ +//----------------------------------------------------------------------------- +#ifndef InfoH +#define InfoH InfoH +//----------------------------------------------------------------------------- + +#define COMPANY_NAME wxT("MATRIX VISION GmbH") +#define COMPANY_WEBSITE wxT("www.matrix-vision.com") +#define COMPANY_SUPPORT_MAIL wxT("mailto:support@matrix-vision.com") +#define CURRENT_YEAR wxT("2021") +#define VERSION_STRING wxT("2.43.0.3180") + +#endif // InfoH diff --git a/Cigarette/MvIMPACT/apps/Common/ProxyResolverContext.h b/Cigarette/MvIMPACT/apps/Common/ProxyResolverContext.h new file mode 100644 index 0000000..969ebec --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/ProxyResolverContext.h @@ -0,0 +1,22 @@ +//----------------------------------------------------------------------------- +#ifndef ProxyResolverContextH +#define ProxyResolverContextH ProxyResolverContextH +//----------------------------------------------------------------------------- +#include + +//----------------------------------------------------------------------------- +class ProxyResolverContext +//----------------------------------------------------------------------------- +{ + struct ProxyResolverContextImpl* pImpl_; +public: + explicit ProxyResolverContext( const std::wstring& userAgent = std::wstring(), const std::wstring& url = std::wstring() ); + ~ProxyResolverContext(); + + std::wstring GetProxy( unsigned int index ) const; + unsigned int GetProxyPort( unsigned int index ) const; +}; + +bool IsCurrentUserLocalAdministrator( void ); + +#endif // ProxyResolverContextH diff --git a/Cigarette/MvIMPACT/apps/Common/aviexception.h b/Cigarette/MvIMPACT/apps/Common/aviexception.h new file mode 100644 index 0000000..843a427 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/aviexception.h @@ -0,0 +1,39 @@ +//---------------------------------------------------------------------------------------- +#ifndef aviexceptionH +#define aviexceptionH aviexceptionH +//---------------------------------------------------------------------------------------- +#include + +//---------------------------------------------------------------------------------------- +class AVIException +//---------------------------------------------------------------------------------------- +{ +public: + virtual const char* what() const = 0; +}; + +//---------------------------------------------------------------------------------------- +class AEUnsupportedCodec : public AVIException +//---------------------------------------------------------------------------------------- +{ +public: + const char* what() const + { + return "Unsupported codec"; + } +}; + +//---------------------------------------------------------------------------------------- +class AVIWrapperException : public AVIException +//---------------------------------------------------------------------------------------- +{ + std::string m_errorString; +public: + AVIWrapperException( const char* pError ) : m_errorString( pError ) {} + const char* what() const + { + return m_errorString.c_str(); + } +}; + +#endif // aviexceptionH \ No newline at end of file diff --git a/Cigarette/MvIMPACT/apps/Common/avihelper.cpp b/Cigarette/MvIMPACT/apps/Common/avihelper.cpp new file mode 100644 index 0000000..2c6c87e --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/avihelper.cpp @@ -0,0 +1,173 @@ +//---------------------------------------------------------------------------------------- +#include "avihelper.h" +//---------------------------------------------------------------------------------------- + +using namespace std; + +//---------------------------------------------------------------------------------------- +/*! + \brief Builds an error string from an AVI error code. + \param error The error code to be converted. + + Helper function to convert an AVI error code into a string. +*/ +string AVIErrorToString( HRESULT error ) +//---------------------------------------------------------------------------------------- +{ + string errormsg( "AVI error '" ); + switch( error ) + { + case AVIERR_BADFLAGS : + errormsg.append( "AVIERR_BADFLAGS" ); + break; + case AVIERR_BADFORMAT : + errormsg.append( "AVIERR_BADFORMAT" ); + break; + case AVIERR_BADHANDLE : + errormsg.append( "AVIERR_BADHANDLE" ); + break; + case AVIERR_BADPARAM : + errormsg.append( "AVIERR_BADPARAM" ); + break; + case AVIERR_BADSIZE : + errormsg.append( "AVIERR_BADSIZE" ); + break; + case AVIERR_BUFFERTOOSMALL : + errormsg.append( "AVIERR_BUFFERTOOSMALL" ); + break; + case AVIERR_CANTCOMPRESS : + errormsg.append( "AVIERR_CANTCOMPRESS" ); + break; + case AVIERR_COMPRESSOR : + errormsg.append( "AVIERR_COMPRESSOR" ); + break; + case AVIERR_NOCOMPRESSOR : + errormsg.append( "AVIERR_NOCOMPRESSOR" ); + break; + case AVIERR_NODATA : + errormsg.append( "AVIERR_NODATA" ); + break; + case AVIERR_FILEOPEN : + errormsg.append( "AVIERR_FILEOPEN" ); + break; + case AVIERR_FILEREAD : + errormsg.append( "AVIERR_FILEREAD" ); + break; + case AVIERR_FILEWRITE : + errormsg.append( "AVIERR_FILEWRITE" ); + break; + case AVIERR_INTERNAL : + errormsg.append( "AVIERR_INTERNAL" ); + break; + case AVIERR_MEMORY : + errormsg.append( "AVIERR_MEMORY" ); + break; + case AVIERR_READONLY : + errormsg.append( "AVIERR_READONLY" ); + break; + case AVIERR_UNSUPPORTED : + errormsg.append( "AVIERR_UNSUPPORTED" ); + break; + case AVIERR_USERABORT : + errormsg.append( "AVIERR_USERABORT" ); + break; + case REGDB_E_CLASSNOTREG : + errormsg.append( "REGDB_E_CLASSNOTREG" ); + break; + default: + return "Unrecognized error"; + } + return( errormsg.append( "' occurred" ) ); +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Builds a test image. + \param pData Pointer to the memory in which to build the test image. + \param width The width of the test image. + \param height The height of the test image. + \param bytespp The bytes per pixel of the test image. + + This function is only needed for testing purposes. It builds a moving vertical + grey ramp in the memory pointed to by \e pData. In each new image will move one + pixel to the right in order to simulate movement. +*/ +void BuildTestImage( unsigned char* pData, int width, int height, int bytespp ) +//---------------------------------------------------------------------------------------- +{ + static int count = 0; + unsigned char* p = pData; + + for( int i = 0; i < height; i++ ) + { + for( int j = 0; j < width; j++ ) + { + for( int x = 0; x < bytespp; x++ ) + { + p[x] = static_cast( j + count % 256 ); + } + p += bytespp; + } + } + ++count; +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Convertes a user selected codec into the corresponding 4 character code + \param codec The codec to be converted. +*/ +DWORD CodecToFourccCode( CODEC_T codec ) +//---------------------------------------------------------------------------------------- +{ + switch( codec ) + { + case codecNoCompression: + return mmioFOURCC( 'D', 'I', 'B', ' ' ); + case codecMorganMjpg: + return mmioFOURCC( 'M', 'J', 'P', 'G' ); + case codecMorganMjpg2000: + return mmioFOURCC( 'M', 'J', '2', 'C' ); + case codecIntelJpg: + return mmioFOURCC( 'M', 'J', 'P', 'G' ); + case codecHuffYUV: + return mmioFOURCC( 'H', 'F', 'Y', 'U' ); + case codecDivx5: + return mmioFOURCC( 'd', 'i', 'v', 'x' ); + case codec3ivx: + return mmioFOURCC( '3', 'i', 'v', '2' ); + case codecMjpg2: + return mmioFOURCC( 'e', 'm', '2', 'v' ); + case codecPicVideoWavelet: + return mmioFOURCC( 'p', 'v', 'w', '2' ); + case codecPicVideoMjpg: + return mmioFOURCC( 'm', 'j', 'p', 'x' ); + case codecPicVideoLossLessJpg: + return mmioFOURCC( 'p', 'i', 'm', 'j' ); + case codecMSVideo: + return mmioFOURCC( 'm', 's', 'v', 'c' ); + case codecMSRle: + return mmioFOURCC( 'm', 'r', 'l', 'e' ); + case codecMSH263: + return mmioFOURCC( 'm', '2', '6', '3' ); + case codecMSH261: + return mmioFOURCC( 'm', '2', '6', '1' ); + case codecIntelVidR32: + return mmioFOURCC( 'i', 'v', '3', '2' ); + case codecIntelIndeo510: + return mmioFOURCC( 'i', 'v', '5', '0' ); + case codecDivxMjpg4lm: + return mmioFOURCC( 'd', 'i', 'v', '3' ); + case codecDivxMjpg4fm: + return mmioFOURCC( 'd', 'i', 'v', '4' ); + case codecCinepack: + return mmioFOURCC( 'c', 'v', 'i', 'd' ); + case codecMSMpeg4: + return mmioFOURCC( 'm', 'p', 'g', '4' ); + case codecMax: + return mmioFOURCC( 'D', 'I', 'B', ' ' ); + default: + break; + } + throw AEUnsupportedCodec(); +} \ No newline at end of file diff --git a/Cigarette/MvIMPACT/apps/Common/avihelper.h b/Cigarette/MvIMPACT/apps/Common/avihelper.h new file mode 100644 index 0000000..94e4019 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/avihelper.h @@ -0,0 +1,45 @@ +//---------------------------------------------------------------------------------------- +#ifndef avihelperH +#define avihelperH avihelperH +//---------------------------------------------------------------------------------------- +#include +#include +#include "aviexception.h" +//---------------------------------------------------------------------------------------- + +/*! + \brief The codecs recognized by the \b AVIWrapper class. +*/ +typedef enum +{ + codecNoCompression = 0, + codecMorganMjpg = 1, + codecMorganMjpg2000 = 2, + codecIntelJpg = 3, + codecHuffYUV = 4, + codecDivx5 = 5, + codec3ivx = 6, + codecMjpg2 = 7, + codecPicVideoWavelet = 8, + codecPicVideoMjpg = 9, + codecPicVideoLossLessJpg = 10, + codecMSVideo = 11, + codecMSRle = 12, + codecMSH263 = 13, + codecMSH261 = 14, + codecIntelVidR32 = 15, + codecIntelIndeo510 = 16, + codecDivxMjpg4lm = 17, + codecDivxMjpg4fm = 18, + codecCinepack = 19, + codecMSMpeg4 = 20, + codecMax +} CODEC_T; + +//---------------------------------------------------------------------------------------- +std::string AVIErrorToString( HRESULT error ); +void BuildTestImage( unsigned char* pData, int width, int height, int bytespp ); +DWORD CodecToFourccCode( CODEC_T codec ); +//---------------------------------------------------------------------------------------- + +#endif // avihelperH \ No newline at end of file diff --git a/Cigarette/MvIMPACT/apps/Common/aviwrapper.cpp b/Cigarette/MvIMPACT/apps/Common/aviwrapper.cpp new file mode 100644 index 0000000..b71dd2a --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/aviwrapper.cpp @@ -0,0 +1,293 @@ +//---------------------------------------------------------------------------------------- +#include "aviwrapper.h" +#include +#include +//---------------------------------------------------------------------------------------- + +/*! + \class AVIWrapper + \brief Provides an easy way to create and use *.avi-files. + + This class is meant to provide easy access to the AVI file functions. It can be used to generate + an AVI stream with only a few lines of code. + + Three general methods are supported: + + - Creation of an AVI stream using the standard Windows compression options dialog (interactively) + - Creation of an AVI stream specifying a codec handler, quality settings and image dimensions + (not interactively) + - Creation of an AVI stream from images which are already in jpeg format. +*/ + +unsigned int AVIWrapper::m_usageCount = 0; + +//---------------------------------------------------------------------------------------- +/*! + \brief Constructs a new \b AVIWrapper object. + \param filename The filename of the AVI file to be created or \e 0 if no file shall be + created. + \param mode The access mode for this file. + + Opens and creates an AVI file in the mode specified by the \e mode parameter if + a filename has been specified. See MSDN for details about the available modes. +*/ +AVIWrapper::AVIWrapper( const char* pFilename /* = 0 */, UINT mode /* = OF_READ */ ) : + m_AVIStreamFrameCounter( 0 ), m_pAVIFile( 0 ), m_pAVIStream( 0 ), m_pAVIStreamCompressed( 0 ), + m_codec( CodecToFourccCode( codecNoCompression ) ) +//---------------------------------------------------------------------------------------- +{ + if( m_usageCount == 0 ) + { + AVIFileInit(); + } + ++m_usageCount; + if( pFilename ) + { + HRESULT result = AVIFileOpen( &m_pAVIFile, pFilename, mode, 0 ); + if( result == AVIERR_OK ) + { + result = AVIFileGetStream( m_pAVIFile, &m_pAVIStream, streamtypeVIDEO, 0 ); + } + if( result != AVIERR_OK ) + { + AVIFileExit(); + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } + } +} + +//---------------------------------------------------------------------------------------- +AVIWrapper::~AVIWrapper( void ) +//---------------------------------------------------------------------------------------- +{ + if( m_pAVIFile ) + { + CloseStreamsAndFiles(); + } + --m_usageCount; + if( m_usageCount == 0 ) + { + AVIFileExit(); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Closes the AVI file again. + + Closes all open streams and the AVI file itself. At the moment only one stream can be opened + at the same time. +*/ +void AVIWrapper::CloseAVIFile( void ) +//---------------------------------------------------------------------------------------- +{ + if( !m_pAVIFile ) + { + throw AVIWrapperException( "CloseAVIFile: No file has been opened so far" ); + } + CloseStreamsAndFiles(); +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Closes all open stream and the AVI file itself. +*/ +void AVIWrapper::CloseStreamsAndFiles( void ) +//---------------------------------------------------------------------------------------- +{ + if( m_pAVIStream ) + { + AVIStreamRelease( m_pAVIStream ); + } + if( m_pAVIStreamCompressed ) + { + AVIStreamRelease( m_pAVIStreamCompressed ); + } + if( m_pAVIFile ) + { + AVIFileRelease( m_pAVIFile ); + } + m_pAVIStream = 0; + m_pAVIStreamCompressed = 0; + m_pAVIFile = 0; + m_AVIStreamFrameCounter = 0; +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Creates an AVI stream from DIB images. + \param w The width of the images to be stored in the stream + \param h The height of the images to be stored in the stream + \param sampleRate The frames per second entry in the AVI header + \param quality The JPEG quality (from 0 - 10000) + \param name The name of the stream in the file + \param codec The codec to be used for the compression of the DIB data. Pass \e codecMax if + you want to select a codec from the standard Windows compression dialog or + a valid codec from the \b CODEC_T enumeration. + + Use this function to create a compressed or uncompressed AVI stream from images in DIB/Bitmap + format. The images can be stored in a compressed format defined by the specified compression + handler. + + If your images are already in JPEG format use the function AVIWrapper::CreateAVIStreamFromJPEGs() + instead. +*/ +void AVIWrapper::CreateAVIStreamFromDIBs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName /*= "default"*/, CODEC_T codec /*= codecMax*/ ) +//---------------------------------------------------------------------------------------- +{ + BITMAPINFOHEADER BmpHeader; + SetupStreamStructs( BmpHeader, w, h, bitcount, sampleRate, quality, pName, codec ); + BmpHeader.biCompression = BI_RGB; + AVICOMPRESSOPTIONS* opts[1] = {&m_AVICompressionOptions}; + memset( &m_AVICompressionOptions, 0, sizeof( AVICOMPRESSOPTIONS ) ); + PAVISTREAM streams[1] = {m_pAVIStream}; + + if( codec == codecMax ) + { + // show windows compression handler dialog + AVISaveOptions( 0, 0, 1, ( PAVISTREAM* )&streams, ( LPAVICOMPRESSOPTIONS* )&opts ); + } + else // fill AVICOMPRESSOPTIONS with user parameters + { + m_codec = codec; + opts[0]->fccType = streamtypeVIDEO; + opts[0]->fccHandler = CodecToFourccCode( codec ); + opts[0]->dwQuality = quality; + opts[0]->dwFlags = AVICOMPRESSF_VALID; + } + m_codec = opts[0]->fccHandler; + HRESULT result = AVIMakeCompressedStream( &m_pAVIStreamCompressed, m_pAVIStream, &m_AVICompressionOptions, NULL ); + if( result == AVIERR_OK ) + { + result = AVIStreamSetFormat( m_pAVIStreamCompressed, 0, &BmpHeader, sizeof( BITMAPINFOHEADER ) ); + } + if( result != AVIERR_OK ) + { + CloseStreamsAndFiles(); + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Creates an AVI stream from JPEG images. + \param w The width of the images to be stored in the stream + \param h The height of the images to be stored in the stream + \param sampleRate The frames per second entry in the AVI header + \param quality The JPEG quality (from 0 - 10000) + \param name The name of the stream in the file + + Use this function to create a MJPEG stream from images which are already in JPEG format. + + To create an AVI stream from images in DIB format use the function + AVIWrapper::CreateAVIStreamFromDIBs() instead. +*/ +void AVIWrapper::CreateAVIStreamFromJPEGs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName /*= "default"*/ ) +//---------------------------------------------------------------------------------------- +{ + // no 'handler' compression! This section works for already compressed images + BITMAPINFOHEADER BmpHeader; + SetupStreamStructs( BmpHeader, w, h, bitcount, sampleRate, quality, pName, codecMorganMjpg ); + BmpHeader.biCompression = CodecToFourccCode( codecMorganMjpg ); + const HRESULT result = AVIStreamSetFormat( m_pAVIStream, 0, &BmpHeader, sizeof( BITMAPINFOHEADER ) ); + if( result != AVIERR_OK ) + { + CloseStreamsAndFiles(); + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Opens an AVI file. + \param filename The name of the file to be created/opened/used. + \param mode The access mode for this file. + + Opens and creates an AVI file in the mode specified by the \e mode parameter + See MSDN for details about the available modes. +*/ +void AVIWrapper::OpenAVIFile( const char* pFilename, UINT mode /* = OF_READ */ ) +//---------------------------------------------------------------------------------------- +{ + if( m_pAVIFile ) + { + throw AVIWrapperException( "OpenAVIFile: Another file has been opened already" ); + } + if( !pFilename ) + { + throw AVIWrapperException( "OpenAVIFile: No valid filename has been specified" ); + } + const HRESULT result = AVIFileOpen( &m_pAVIFile, pFilename, mode, 0 ); + if( result != AVIERR_OK ) + { + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +/*! + \brief Stores one image in the AVI stream + \param data Pointer to the image data + \param size Size (in bytes) of the memory block pointed to by \e data + + This function stores one image in the specified stream. +*/ +void AVIWrapper::SaveDataToAVIStream( unsigned char* pData, int size ) +//---------------------------------------------------------------------------------------- +{ + PAVISTREAM pAVIStream = ( m_pAVIStreamCompressed ) ? m_pAVIStreamCompressed : m_pAVIStream; + if( !pAVIStream ) + { + throw AVIWrapperException( "SaveDataToAVIStream: Stream pointer invalid" ); + } + const HRESULT result = AVIStreamWrite( pAVIStream, m_AVIStreamFrameCounter++, 1, pData, size, AVIIF_KEYFRAME, 0, 0 ); + if( result != AVIERR_OK ) + { + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } +} + +//---------------------------------------------------------------------------------------- +void AVIWrapper::SetupStreamStructs( BITMAPINFOHEADER& BmpHeader, int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName /*= "default"*/, CODEC_T codec /*= codecMax*/ ) +//---------------------------------------------------------------------------------------- +{ + if( !m_pAVIFile ) + { + throw AVIWrapperException( "CreateNewAVIStream: No file has been opened so far" ); + } + if( strlen( pName ) > sizeof( m_AVIStreamInfo.szName ) ) + { + throw AVIWrapperException( "CreateNewAVIStream: stream name too long" ); + } + if( m_pAVIStream || m_pAVIStreamCompressed ) + { + throw AVIWrapperException( "CreateNewAVIStream: There is already an open stream" ); + } + // setup AVISTREAMINFO structure + memset( &m_AVIStreamInfo, 0, sizeof( AVISTREAMINFO ) ); + m_AVIStreamInfo.fccType = streamtypeVIDEO; + m_AVIStreamInfo.fccHandler = CodecToFourccCode( codec ); + m_AVIStreamInfo.wPriority = 10; + m_AVIStreamInfo.dwScale = 1; + m_AVIStreamInfo.dwRate = sampleRate; + m_AVIStreamInfo.dwQuality = quality; + m_AVIStreamInfo.rcFrame.right = w; + m_AVIStreamInfo.rcFrame.bottom = h; + mv_strncpy_s( m_AVIStreamInfo.szName, pName, sizeof( m_AVIStreamInfo.szName ) ); + + const HRESULT result = AVIFileCreateStream( m_pAVIFile, &m_pAVIStream, &m_AVIStreamInfo ); + if( result != AVIERR_OK ) + { + throw AVIWrapperException( AVIErrorToString( result ).c_str() ); + } + // setup BITMAPINFOHEADER structure + memset( &BmpHeader, 0, sizeof( BITMAPINFOHEADER ) ); + BmpHeader.biSize = sizeof( BITMAPINFOHEADER ); + BmpHeader.biWidth = w; + BmpHeader.biHeight = h; + BmpHeader.biPlanes = 1; + BmpHeader.biBitCount = static_cast( bitcount ); + + // setup internals + m_AVIStreamFrameCounter = 0; +} \ No newline at end of file diff --git a/Cigarette/MvIMPACT/apps/Common/aviwrapper.h b/Cigarette/MvIMPACT/apps/Common/aviwrapper.h new file mode 100644 index 0000000..c49d148 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/aviwrapper.h @@ -0,0 +1,54 @@ +//---------------------------------------------------------------------------------------- +#ifndef aviwrapperH +#define aviwrapperH aviwrapperH +//---------------------------------------------------------------------------------------- +#include "avihelper.h" + +//---------------------------------------------------------------------------------------- +class AVIWrapper +//---------------------------------------------------------------------------------------- +{ + // member data + /// Keeps track about the number of images stored in the actual stream + int m_AVIStreamFrameCounter; + /// pointer to the structure describing the AVI-file + PAVIFILE m_pAVIFile; + /// pointer to an uncompressed AVI stream + PAVISTREAM m_pAVIStream; + /// pointer to a compressed AVI stream (this is used when a compression handler is used) + PAVISTREAM m_pAVIStreamCompressed; + /// A structure containing information about the AVI stream + AVISTREAMINFO m_AVIStreamInfo; + /// A structure for storing the compression options of the AVI stream + AVICOMPRESSOPTIONS m_AVICompressionOptions; + /// The used codec + DWORD m_codec; + /// Usage count for this class + static unsigned int m_usageCount; + // functions + void CloseStreamsAndFiles( void ); + void SetupStreamStructs( BITMAPINFOHEADER& BmpHeader, int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName = "default", CODEC_T codec = codecMax ); + /// Do not allow copy construction + AVIWrapper( const AVIWrapper& scr ); +public: + // construction/destruction + explicit AVIWrapper( const char* pFilename = 0, UINT mode = OF_READ ); + ~AVIWrapper( void ); + + // user interface + void CloseAVIFile( void ); + void CreateAVIStreamFromDIBs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName = "default", CODEC_T codec = codecMax ); + void CreateAVIStreamFromJPEGs( int w, int h, int bitcount, DWORD sampleRate, DWORD quality, const char* pName = "default" ); + const char* GetStreamName( void ) const + { + return m_AVIStreamInfo.szName; + } + bool UsesCompressionHandler( void ) const + { + return m_codec != CodecToFourccCode( codecNoCompression ); + } + void OpenAVIFile( const char* pFilename, UINT mode = OF_READ ); + void SaveDataToAVIStream( unsigned char* pData, int size ); +}; + +#endif // aviwrapperH \ No newline at end of file diff --git a/Cigarette/MvIMPACT/apps/Common/exampleHelper.h b/Cigarette/MvIMPACT/apps/Common/exampleHelper.h new file mode 100644 index 0000000..2f9e857 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/exampleHelper.h @@ -0,0 +1,545 @@ +//----------------------------------------------------------------------------- +#ifndef exampleHelperH +#define exampleHelperH exampleHelperH +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +template +class DisplayDictEntry +//----------------------------------------------------------------------------- +{ +public: + void operator()( const std::pair& data ) const + { + std::cout << " [" << data.second << "]: " << data.first << std::endl; + } +}; + +//----------------------------------------------------------------------------- +class DisplayComponent +//----------------------------------------------------------------------------- +{ +public: + void operator()( const Component& data ) const + { + if( data.isValid() ) + { + std::cout << " " << data.name() << "(" << data.typeAsString() << ")" << std::endl; + } + } +}; + +//----------------------------------------------------------------------------- +class DisplayProperty +//----------------------------------------------------------------------------- +{ +public: + void operator()( const std::pair& data ) const + { + if( data.second.isValid() ) + { + std::cout << data.first << ": " << data.second.readSArray() << "(" << data.second.flagsAsString() << ")" << std::endl; + } + } +}; + +//----------------------------------------------------------------------------- +template +void DisplayPropertyDictionary( const mvIMPACT::acquire::Property& p ) +//----------------------------------------------------------------------------- +{ + _Ty prop( p ); +#if defined(_MSC_VER) && (_MSC_VER < 1300) // is 'old' VC 6 Microsoft compiler? + std::vector > dict; + prop.getTranslationDict( dict ); + std::for_each( dict.begin(), dict.end(), DisplayDictEntry<_Ty::value_type>() ); +#else + std::vector > dict; + prop.getTranslationDict( dict ); + std::for_each( dict.begin(), dict.end(), DisplayDictEntry() ); +#endif // #ifdef _MSC_VER +} + +//----------------------------------------------------------------------------- +/// \brief Checks is a certain value for property is supported. +template +bool supportsEnumStringValue( const _Tx& prop, const std::string& value ) +//----------------------------------------------------------------------------- +{ + if( prop.hasDict() ) + { + typename std::vector sequence; + prop.getTranslationDictStrings( sequence ); + return std::find( sequence.begin(), sequence.end(), value ) != sequence.end(); + } + return false; +} + +//----------------------------------------------------------------------------- +/// \brief Checks is a certain value for property is supported. +template +bool supportsValue( const _Tx& prop, const _Ty& value ) +//----------------------------------------------------------------------------- +{ + if( prop.hasDict() ) + { + typename std::vector<_Ty> sequence; + prop.getTranslationDictValues( sequence ); + return std::find( sequence.begin(), sequence.end(), value ) != sequence.end(); + } + + if( prop.hasMinValue() && ( prop.getMinValue() > value ) ) + { + return false; + } + + if( prop.hasMaxValue() && ( prop.getMaxValue() < value ) ) + { + return false; + } + + return true; +} + +//----------------------------------------------------------------------------- +/// \brief Sets a property to a certain value if this value is supported. +template +void conditionalSetProperty( const _Ty& prop, const _Tx& value, bool boSilent = false ) +//----------------------------------------------------------------------------- +{ + if( prop.isValid() && prop.isWriteable() && supportsValue( prop, value ) ) + { + prop.write( value ); + if( !boSilent ) + { + std::cout << "Property '" << prop.name() << "' set to '" << prop.readS() << "'." << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +/// \brief Sets a property to a certain value if this value is supported. +template +void conditionalSetEnumPropertyByString( const _Ty& prop, const std::string& value, bool boSilent = false ) +//----------------------------------------------------------------------------- +{ + if( prop.isValid() && prop.isWriteable() && supportsEnumStringValue( prop, value ) ) + { + prop.writeS( value ); + if( !boSilent ) + { + std::cout << "Property '" << prop.name() << "' set to '" << prop.readS() << "'." << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +/// This function makes heavy use of strings. In real world applications +/// this can be avoided if optimal performance is crucial. All properties can be modified +/// via strings, but most properties can also be modified with numerical (int / double ) +/// values, which is much faster, but not as descriptive for a sample application +inline void displayPropertyData( const mvIMPACT::acquire::Property& prop ) +//----------------------------------------------------------------------------- +{ + const std::string name( prop.name() ); + std::cout << std::endl + << "Property '" << name << "'(display name: '" << prop.displayName() << "', type: " << prop.typeAsString() << ") currently specifies the following flags: " << prop.flagsAsString() << std::endl + << std::endl; + const std::string doc( prop.docString() ); + if( !doc.empty() ) + { + std::cout << "The following documentation has been reported by the driver for this feature: " << std::endl + << doc << std::endl + << std::endl; + } + if( prop.selectedFeatureCount() > 0 ) + { + std::vector selectedFeatureList; + prop.selectedFeatures( selectedFeatureList ); + std::cout << "The following features are selected by this feature(Whenever the current feature is modified, all selected features might change):" << std::endl; + std::for_each( selectedFeatureList.begin(), selectedFeatureList.end(), DisplayComponent() ); + std::cout << std::endl; + } + if( prop.selectingFeatureCount() > 0 ) + { + std::vector selectingFeatureList; + prop.selectingFeatures( selectingFeatureList ); + std::cout << "The following features select this feature(Whenever a selecting features is modified, a selected one might change):" << std::endl; + std::for_each( selectingFeatureList.begin(), selectingFeatureList.end(), DisplayComponent() ); + std::cout << std::endl; + } + if( prop.hasMinValue() ) + { + std::cout << "The minimum value of '" << name << "' is " << prop.readS( mvIMPACT::acquire::plMinValue ) << std::endl; + } + if( prop.hasMaxValue() ) + { + std::cout << "The maximum value of '" << name << "' is " << prop.readS( mvIMPACT::acquire::plMaxValue ) << std::endl; + } + if( prop.hasStepWidth() ) + { + std::cout << "The increment of '" << name << "' is " << prop.readS( mvIMPACT::acquire::plStepWidth ) << std::endl; + } + if( prop.hasDict() ) + { + std::cout << "'" << name << "' defines a dictionary. Valid values are: " << std::endl; + mvIMPACT::acquire::TComponentType type = prop.type(); + if( type == mvIMPACT::acquire::ctPropInt ) + { + DisplayPropertyDictionary( prop ); + } + else if( type == mvIMPACT::acquire::ctPropInt64 ) + { + DisplayPropertyDictionary( prop ); + } + else if( type == mvIMPACT::acquire::ctPropFloat ) + { + DisplayPropertyDictionary( prop ); + } + else + { + std::cout << "Error! Unhandled enum prop type: " << prop.typeAsString() << std::endl; + } + } + std::cout << "The current value of '" << name << "' is: '" << prop.readS() << "'" << std::endl; +} + +//----------------------------------------------------------------------------- +inline bool displayPropertyDataWithValidation( const mvIMPACT::acquire::Property& prop, const std::string& name ) +//----------------------------------------------------------------------------- +{ + if( !prop.isValid() ) + { + std::cout << "Property '" << name << "' is not supported/available." << std::endl; + return false; + } + displayPropertyData( prop ); + return true; +} + +//----------------------------------------------------------------------------- +// Start the acquisition manually if this was requested(this is to prepare the driver for data capture and tell the device to start streaming data) +inline void manuallyStartAcquisitionIfNeeded( mvIMPACT::acquire::Device* pDev, const mvIMPACT::acquire::FunctionInterface& fi ) +//----------------------------------------------------------------------------- +{ + if( pDev->acquisitionStartStopBehaviour.read() == mvIMPACT::acquire::assbUser ) + { + const mvIMPACT::acquire::TDMR_ERROR result = static_cast( fi.acquisitionStart() ); + if( result != mvIMPACT::acquire::DMR_NO_ERROR ) + { + std::cout << "'FunctionInterface.acquisitionStart' returned with an unexpected result: " << result + << "(" << mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString( result ) << ")" << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +// Stop the acquisition manually if this was requested +inline void manuallyStopAcquisitionIfNeeded( mvIMPACT::acquire::Device* pDev, const mvIMPACT::acquire::FunctionInterface& fi ) +//----------------------------------------------------------------------------- +{ + if( pDev->acquisitionStartStopBehaviour.read() == mvIMPACT::acquire::assbUser ) + { + const mvIMPACT::acquire::TDMR_ERROR result = static_cast( fi.acquisitionStop() ); + if( result != mvIMPACT::acquire::DMR_NO_ERROR ) + { + std::cout << "'FunctionInterface.acquisitionStop' returned with an unexpected result: " << result + << "(" << mvIMPACT::acquire::ImpactAcquireException::getErrorCodeAsString( result ) << ")" << std::endl; + } + } +} + +//----------------------------------------------------------------------------- +/// This function makes heavy use of strings. In real world applications +/// this can be avoided if optimal performance is crucial. All properties can be modified +/// via strings, but most properties can also be modified with numerical (int / double ) +/// values, which is much faster, but not as descriptive for a sample application +inline void modifyPropertyValue( const mvIMPACT::acquire::Property& prop, const std::string& param = "", const std::string& index = "" ) +//----------------------------------------------------------------------------- +{ + try + { + const std::string name( prop.name() ); + if( prop.isWriteable() ) + { + int valIndex = 0; + if( param.empty() ) + { + std::cout << "Enter the new value for '" << name << "': "; + std::string val; + std::cin >> val; + // remove the '\n' from the stream + std::cin.get(); + if( prop.valCount() > 1 ) + { + std::cout << "'" << name << "' defines " << prop.valCount() << " values. Enter the index (zero-based) of the value to modify: "; + std::cin >> valIndex; + // remove the '\n' from the stream + std::cin.get(); + } + prop.writeS( val, valIndex ); + } + else + { + if( !index.empty() ) + { + valIndex = atoi( index.c_str() ); + } + prop.writeS( param, valIndex ); + } + } + else + { + std::cout << "'" << name << "' is read-only, thus can't be modified." << std::endl; + } + } + catch( const mvIMPACT::acquire::ImpactAcquireException& e ) + { + std::cout << "An exception occurred: " << e.getErrorString() << "(error code: " << e.getErrorCodeAsString() << ")" << std::endl; + } +} + +//----------------------------------------------------------------------------- +inline void displayAndModifyPropertyDataWithValidation( const mvIMPACT::acquire::Property& prop, const std::string& name ) +//----------------------------------------------------------------------------- +{ + if( displayPropertyDataWithValidation( prop, name ) ) + { + modifyPropertyValue( prop ); + } + std::cout << std::endl; +} + +//----------------------------------------------------------------------------- +inline std::ostream& operator<<( std::ostream& out, const mvIMPACT::acquire::Property& prop ) +//----------------------------------------------------------------------------- +{ + out << prop.name() << ": " << prop.readS(); + return out; +} + +//----------------------------------------------------------------------------- +/// \brief Allows string comparison with a defined character to ignore +/** + * This function allows a tolerant string compare. If \a candidate ends with \a wildcard + * \a candidate can be shorter then \a searchString as the rest of the string will be + * ignored. This is a helper function used internally by DeviceManager objects. + * + * Examples: + * + * \code + * wildcard = '*' + * s1 = "blablabla" + * match( s1, "bl*bl*bla", '*' ); // will return 0 + * // will return 0 ('*' is the default value for parameter 3 ) + * match( s1, "bl*" ); + * // the next call will return -1 as the first character MUST + * // be either a 'b' or the wildcard character. + * match( s1, "a*" ); + * \endcode + * \return + * - 0 if successful + * - -1 otherwise + */ +template +int match( const std::basic_string<_Elem, _Traits, _Ax>& searchString, const std::basic_string<_Elem, _Traits, _Ax>& candidate, _Elem wildcard ) +//----------------------------------------------------------------------------- +{ + typename std::basic_string<_Elem, _Traits, _Ax>::size_type searchLength = searchString.length(); + // determine search length + if( candidate.length() < searchString.length() ) + { + if( candidate.empty() ) + { + return -1; + } + + if( candidate[candidate.length() - 1] != wildcard ) + { + return -1; + } + searchLength = candidate.length() - 1; + } + // search + for( typename std::basic_string<_Elem, _Traits, _Ax>::size_type i = 0; i < searchLength; i++ ) + { + if( ( candidate[i] != searchString[i] ) && ( candidate[i] != wildcard ) ) + { + return -1; + } + } + return 0; +} + +typedef bool( *SUPPORTED_DEVICE_CHECK )( const mvIMPACT::acquire::Device* const ); + +//----------------------------------------------------------------------------- +inline mvIMPACT::acquire::Device* getDeviceFromUserInput( const mvIMPACT::acquire::DeviceManager& devMgr, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn = 0, bool boSilent = false, bool boAutomaticallyUseGenICamInterface = true ) +//----------------------------------------------------------------------------- +{ + const unsigned int devCnt = devMgr.deviceCount(); + if( devCnt == 0 ) + { + std::cout << "No compliant device found!" << std::endl; + return 0; + } + + std::set validDeviceNumbers; + + // display every device detected that matches + for( unsigned int i = 0; i < devCnt; i++ ) + { + Device* pDev = devMgr[i]; + if( pDev ) + { + if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( pDev ) ) + { + std::cout << "[" << i << "]: " << pDev->serial.read() << " (" << pDev->product.read() << ", " << pDev->family.read(); + if( pDev->interfaceLayout.isValid() ) + { + if( boAutomaticallyUseGenICamInterface ) + { + // if this device offers the 'GenICam' interface switch it on, as this will + // allow are better control over GenICam compliant devices + conditionalSetProperty( pDev->interfaceLayout, dilGenICam, true ); + } + std::cout << ", interface layout: " << pDev->interfaceLayout.readS(); + } + if( pDev->acquisitionStartStopBehaviour.isValid() ) + { + // if this device offers a user defined acquisition start/stop behaviour + // enable it as this allows finer control about the streaming behaviour + conditionalSetProperty( pDev->acquisitionStartStopBehaviour, assbUser, true ); + std::cout << ", acquisition start/stop behaviour: " << pDev->acquisitionStartStopBehaviour.readS(); + } + if( pDev->interfaceLayout.isValid() && !pDev->interfaceLayout.isWriteable() ) + { + if( pDev->isInUse() ) + { + std::cout << ", !!!ALREADY IN USE!!!"; + } + } + std::cout << ")" << std::endl; + validDeviceNumbers.insert( i ); + } + } + } + + if( validDeviceNumbers.empty() ) + { + std::cout << devMgr.deviceCount() << " devices have been detected:" << std::endl; + for( unsigned int i = 0; i < devCnt; i++ ) + { + Device* pDev = devMgr[i]; + if( pDev ) + { + std::cout << " [" << i << "]: " << pDev->serial.read() << " (" << pDev->product.read() << ", " << pDev->family.read() << ")" << std::endl; + } + } + std::cout << "However none of these devices seems to be supported by this sample." << std::endl << std::endl; + return 0; + } + + // get user input + std::cout << std::endl << "Please enter the number in front of the listed device followed by [ENTER] to open it: "; + unsigned int devNr = 0; + std::cin >> devNr; + // remove the '\n' from the stream + std::cin.get(); + + if( validDeviceNumbers.find( devNr ) == validDeviceNumbers.end() ) + { + std::cout << "Invalid selection!" << std::endl; + return 0; + } + + if( !boSilent ) + { + std::cout << "Using device number " << devNr << "." << std::endl; + } + return devMgr[devNr]; +} + +//----------------------------------------------------------------------------- +inline std::vector::size_type getValidDevices( const mvIMPACT::acquire::DeviceManager& devMgr, std::vector& v, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn = 0 ) +//----------------------------------------------------------------------------- +{ + const unsigned int devCnt = devMgr.deviceCount(); + // display every device detected that matches + for( unsigned int i = 0; i < devCnt; i++ ) + { + Device* pDev = devMgr[i]; + if( pDev ) + { + if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( pDev ) ) + { + v.push_back( pDev ); + } + } + } + return v.size(); +} + +#if defined(linux) || defined(__linux) || defined(__linux__) +# include +# include +# include +# include +# include +//----------------------------------------------------------------------------- +/// \brief Checks if something was written to a certain file descriptor +/** \return + * - 0 if timeout did elapse + * - 1 otherwise + */ +inline unsigned waitForInput( int maxWait_sec, int fd ) +//----------------------------------------------------------------------------- +{ + fd_set rfds; + struct timeval tv; + + FD_ZERO( &rfds ); +#ifndef __clang_analyzer__ // See https://bugs.llvm.org/show_bug.cgi?id=8920 + FD_SET( fd, &rfds ); +#endif // #ifndef __clang_analyzer__ + + tv.tv_sec = maxWait_sec; + tv.tv_usec = 0; + + return select( fd + 1, &rfds, NULL, NULL, &tv ); +} + +//----------------------------------------------------------------------------- +/** \return + * - 1 if a key has been pressed since the last call to this function + * - 0 otherwise + */ +inline int checkKeyboardInput( void ) +//----------------------------------------------------------------------------- +{ + struct termios oldt, newt; + tcgetattr( STDIN_FILENO, &oldt ); + newt = oldt; + newt.c_lflag &= ~( ICANON | ECHO ); + tcsetattr( STDIN_FILENO, TCSANOW, &newt ); + const int oldf = fcntl( STDIN_FILENO, F_GETFL, 0 ); + fcntl( STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK ); + const int ch = getchar(); + tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); + fcntl( STDIN_FILENO, F_SETFL, oldf ); + if( ch != EOF ) + { + // ungetc(ch, stdin); + return 1; + } + + return 0; +} +#endif // #if defined(linux) || defined(__linux) || defined(__linux__) + +#endif // exampleHelperH diff --git a/Cigarette/MvIMPACT/apps/Common/exampleHelper_C.c b/Cigarette/MvIMPACT/apps/Common/exampleHelper_C.c new file mode 100644 index 0000000..d33b4ea --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/exampleHelper_C.c @@ -0,0 +1,599 @@ +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include "exampleHelper_C.h" + +#define BUF_SIZE (32) +#define BUF_SIZE_LARGE (256) + +//----------------------------------------------------------------------------- +int getIntValFromSTDIn( void ) +//----------------------------------------------------------------------------- +{ + int value; + int conversionResult = 0; + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + conversionResult = scanf_s( "%d", &value ); +#else + conversionResult = scanf( "%d", &value ); +#endif // #if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + if( conversionResult != 1 ) + { + printf( "Conversion error: Expected: 1, conversion result: %d.\n", conversionResult ); + } + return value; +} + +//----------------------------------------------------------------------------- +int getPropI( HOBJ hProp, int index ) +//----------------------------------------------------------------------------- +{ + int value = 0; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_GetI( hProp, &value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "getPropI: Failed to read property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } + return value; +} + +//----------------------------------------------------------------------------- +void setPropI( HOBJ hProp, int value, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetI( hProp, value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropI: Failed to write property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +int64_type getPropI64( HOBJ hProp, int index ) +//----------------------------------------------------------------------------- +{ + int64_type value = 0; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_GetI64( hProp, &value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "getPropI: Failed to read property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } + return value; +} + +//----------------------------------------------------------------------------- +void setPropI64( HOBJ hProp, int64_type value, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetI64( hProp, value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropI: Failed to write property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +void* getPropP( HOBJ hProp, int index ) +//----------------------------------------------------------------------------- +{ + void* value = 0; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_GetP( hProp, &value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "getPropP: Failed to read property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } + return value; +} + +//----------------------------------------------------------------------------- +void setPropP( HOBJ hProp, void* value, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetP( hProp, value, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropP: Failed to write property value(%s).\n", DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +void setPropS( HOBJ hProp, const char* pVal, int index ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + if( ( result = OBJ_SetS( hProp, pVal, index ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "setPropS: Failed to write property value %s :%s.\n", pVal, DMR_ErrorCodeToString( result ) ); + exit( 42 ); + } +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver feature +HOBJ getDriverFeature( HDRV hDrv, const char* pFeatureName, const char* pFeatureType, const char* pAddListName, TDMR_ListType type, unsigned int searchMode ) +//----------------------------------------------------------------------------- +{ + TDMR_ERROR dmrResult = DMR_NO_ERROR; + HOBJ hObj = INVALID_ID; + HLIST baseList = INVALID_ID; + + // try to locate the base list for these property + if( ( dmrResult = DMR_FindList( hDrv, pAddListName, type, 0, &baseList ) ) == DMR_NO_ERROR ) + { + // try to locate the property + TPROPHANDLING_ERROR objResult; + if( ( objResult = OBJ_GetHandleEx( baseList, pFeatureName, &hObj, searchMode, INT_MAX ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "OBJ_GetHandleEx for '%s' failed: %d Handle: %d. This %s might not be supported by this device\n", pFeatureName, objResult, hObj, pFeatureType ); + } + } + else + { + printf( "DMR_FindList failed: %d. Lists of type %d are not available for this device\n", dmrResult, type ); + } + return hObj; +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver feature list +HOBJ getDriverList( HDRV hDrv, const char* pListName, const char* pAddListName, TDMR_ListType type ) +//----------------------------------------------------------------------------- +{ + return getDriverFeature( hDrv, pListName, "list", pAddListName, type, smIgnoreProperties | smIgnoreMethods ); +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver property +HOBJ getDriverProperty( HDRV hDrv, const char* pPropName, const char* pAddListName, TDMR_ListType type ) +//----------------------------------------------------------------------------- +{ + return getDriverFeature( hDrv, pPropName, "property", pAddListName, type, smIgnoreLists | smIgnoreMethods ); +} + +//----------------------------------------------------------------------------- +// This function will try to obtain the handle to a certain driver property +HOBJ getDriverMethod( HDRV hDrv, const char* pPropName, const char* pAddListName, TDMR_ListType type ) +//----------------------------------------------------------------------------- +{ + return getDriverFeature( hDrv, pPropName, "method", pAddListName, type, smIgnoreProperties | smIgnoreLists ); +} + +//----------------------------------------------------------------------------- +HOBJ getDeviceProp( HDEV hDev, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR objResult; + HOBJ hProp = INVALID_ID; + + // try to locate the property + if( ( objResult = OBJ_GetHandleEx( hDev, pPropName, &hProp, 0, -1 ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "OBJ_GetHandleEx failed for property '%s': %d Handle: %d\n", pPropName, objResult, hProp ); + } + return hProp; +} + +//----------------------------------------------------------------------------- +HOBJ getInfoProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltInfo ); +} + +//----------------------------------------------------------------------------- +HOBJ getIOSubSystemProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltIOSubSystem ); +} + +//----------------------------------------------------------------------------- +HOBJ getRequestCtrlProp( HDRV hDrv, const char* pRequestCtrlName, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, pRequestCtrlName, dmltRequestCtrl ); +} + +//----------------------------------------------------------------------------- +HOBJ getRequestProp( HDRV hDrv, int requestNr, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + char buf[BUF_SIZE]; + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + sprintf_s( buf, BUF_SIZE, "Entry %d", requestNr ); +#else + sprintf( buf, "Entry %d", requestNr ); +#endif // #if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + return getDriverProperty( hDrv, pPropName, buf, dmltRequest ); +} + +//----------------------------------------------------------------------------- +HOBJ getSettingProp( HDRV hDrv, const char* pSettingName, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, pSettingName, dmltSetting ); +} + +//----------------------------------------------------------------------------- +HOBJ getSettingMethod( HDRV hDrv, const char* pSettingName, const char* pMethodName ) +//----------------------------------------------------------------------------- +{ + return getDriverMethod( hDrv, pMethodName, pSettingName, dmltSetting ); +} + +//----------------------------------------------------------------------------- +HOBJ getStatisticProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltStatistics ); +} + +//----------------------------------------------------------------------------- +HOBJ getSystemSettingProp( HDRV hDrv, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + return getDriverProperty( hDrv, pPropName, 0, dmltSystemSettings ); +} + +//----------------------------------------------------------------------------- +TPROPHANDLING_ERROR getStringValue( HOBJ hObj, char** pBuf, int index ) +//----------------------------------------------------------------------------- +{ + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + static const int BUFFER_INCREMENT_FACTOR = 2; + + *pBuf = ( char* )calloc( 1, bufSize ); + while( ( result = OBJ_GetS( hObj, *pBuf, bufSize, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + *pBuf = ( char* )realloc( *pBuf, bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + printf( "Error while reading string property value: Error code: %d(%s).\n", result, DMR_ErrorCodeToString( result ) ); + } + return result; +} + +//----------------------------------------------------------------------------- +TPROPHANDLING_ERROR getValueAsString( HOBJ hObj, const char* pFormat, char** pBuf, int index ) +//----------------------------------------------------------------------------- +{ + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + *pBuf = ( char* )calloc( 1, bufSize ); + while( ( result = OBJ_GetSFormattedEx( hObj, *pBuf, &bufSize, pFormat, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + *pBuf = ( char* )realloc( *pBuf, bufSize ); + } + + if( result != PROPHANDLING_NO_ERROR ) + { + printf( "Error while reading string property value: Error code: %d(%s).\n", result, DMR_ErrorCodeToString( result ) ); + } + return result; +} + +//----------------------------------------------------------------------------- +// Start the acquisition manually if this was requested(this is to prepare the driver for data capture and tell the device to start streaming data) +// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStartAcquisitionIfNeeded( HDRV hDrv ) +//----------------------------------------------------------------------------- +{ + const TDMR_ERROR result = DMR_AcquisitionStart( hDrv ); + if( ( result != DMR_NO_ERROR ) && + ( result != DMR_FEATURE_NOT_AVAILABLE ) ) + { + printf( "DMR_AcquisitionStart: Unexpected error(code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) ); + } +} + +//----------------------------------------------------------------------------- +// Stop the acquisition manually if this was requested. +// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStopAcquisitionIfNeeded( HDRV hDrv ) +//----------------------------------------------------------------------------- +{ + const TDMR_ERROR result = DMR_AcquisitionStop( hDrv ); + if( ( result != DMR_NO_ERROR ) && + ( result != DMR_FEATURE_NOT_AVAILABLE ) ) + { + printf( "DMR_AcquisitionStop: Unexpected error(code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) ); + } +} + +//----------------------------------------------------------------------------- +void modifyEnumPropertyI( HDRV hDrv, const char* pSettingName, const char* pPropName ) +//----------------------------------------------------------------------------- +{ + HOBJ hProp = INVALID_ID; + unsigned int dictValCount = 0; + int* dictVals = NULL; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + + printf( "Trying to modify property %s:\n", pPropName ); + if( ( hProp = getSettingProp( hDrv, pSettingName, pPropName ) ) != INVALID_ID ) + { + if( ( result = readTranslationDictValuesI( hProp, &dictVals, &dictValCount, 0 ) ) == PROPHANDLING_NO_ERROR ) + { + int value = 0; + printf( "Please select one of the values listed above: " ); + value = getIntValFromSTDIn(); + free( dictVals ); + // set the new trigger mode + if( ( result = OBJ_SetI( hProp, value, 0 ) ) != PROPHANDLING_NO_ERROR ) + { + printf( "Failed to set new value for %s. Error code: %d(%s).\n", pPropName, result, DMR_ErrorCodeToString( result ) ); + } + } + else + { + printf( "Failed to read translation dictionary of property %s. Error code: %d(%s).\n", pPropName, result, DMR_ErrorCodeToString( result ) ); + } + } +} + +//----------------------------------------------------------------------------- +TPROPHANDLING_ERROR readTranslationDictValuesI( HOBJ hObj, int** pDictValues, unsigned int* pDictValCnt, unsigned int silent ) +//----------------------------------------------------------------------------- +{ + TPROPHANDLING_ERROR funcResult = PROPHANDLING_NO_ERROR; + char** ppBuf = 0; + unsigned int i = 0; + size_t bufSize = 0; + const size_t BUFFER_INCREMENT_FACTOR = 6; + + if( ( funcResult = OBJ_GetDictSize( hObj, pDictValCnt ) ) != PROPHANDLING_NO_ERROR ) + { + return funcResult; + } + + *pDictValues = ( int* )calloc( *pDictValCnt, sizeof( int ) ); + if( !( *pDictValues ) ) + { + printf( "Failed to allocate memory for integer dictionary!\n" ); + return PROPHANDLING_INPUT_BUFFER_TOO_SMALL; + } + ppBuf = ( char** )calloc( *pDictValCnt, sizeof( char* ) ); + if( !ppBuf ) + { + free( *pDictValues ); + printf( "Failed to allocate memory for string dictionary!\n" ); + return PROPHANDLING_INPUT_BUFFER_TOO_SMALL; + } + + bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( i = 0; i < *pDictValCnt; i++ ) + { + ppBuf[i] = ( char* )calloc( 1, bufSize ); + } + + while( ( funcResult = OBJ_GetIDictEntries( hObj, ppBuf, bufSize, *pDictValues, ( size_t ) * pDictValCnt ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( i = 0; i < *pDictValCnt; i++ ) + { + ppBuf[i] = ( char* )realloc( ppBuf[i], bufSize ); + } + } + + if( ( funcResult == PROPHANDLING_NO_ERROR ) && + ( silent == 0 ) ) + { + printf( "Got the following dictionary:\n" ); + for( i = 0; i < *pDictValCnt; i++ ) + { + printf( "[%d]: %s(numerical rep: %d)\n", i, ppBuf[i] ? ppBuf[i] : "!NO MEMORY!", ( *pDictValues )[i] ); + } + } + + // free memory again + for( i = 0; i < *pDictValCnt; i++ ) + { + free( ppBuf[i] ); + } + free( ppBuf ); + return funcResult; +} + +//----------------------------------------------------------------------------- +void conditionalSetPropI( HOBJ hProp, int value, unsigned int silent ) +//----------------------------------------------------------------------------- +{ + unsigned int dictValCount = 0; + size_t i = 0; + int* dictVals = NULL; + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + char bufName[BUF_SIZE_LARGE]; + char* pBufValue = 0; + + if( ( result = readTranslationDictValuesI( hProp, &dictVals, &dictValCount, silent ) ) == PROPHANDLING_NO_ERROR ) + { + for( i = 0; i < dictValCount; i++ ) + { + if( dictVals[i] == value ) + { + setPropI( hProp, value, 0 ); + memset( bufName, '\0', BUF_SIZE_LARGE ); + OBJ_GetName( hProp, bufName, BUF_SIZE_LARGE ); + getValueAsString( hProp, 0, &pBufValue, 0 ); + if( silent == 0 ) + { + printf( "Property '%s' set to '%s'.\n", bufName, pBufValue ); + } + free( pBufValue ); + break; + } + } + free( dictVals ); + } + else + { + printf( "Failed to read translation dictionary from property. Error code: %d(%s).\n", result, DMR_ErrorCodeToString( result ) ); + } +} + +//----------------------------------------------------------------------------- +int getDeviceFromUserInput( HDEV* phDevice, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn, unsigned int automaticallyUseGenICamInterface ) +//----------------------------------------------------------------------------- +{ + TDMR_ERROR result = DMR_NO_ERROR; + unsigned int i = 0; + unsigned int deviceCount = 0; + unsigned int deviceNumber = 0; + HOBJ hPropSerial = INVALID_ID; + HOBJ hPropProduct = INVALID_ID; + HOBJ hPropInterfaceLayout = INVALID_ID; + HOBJ hPropAcquisitionStartStopBehaviour = INVALID_ID; + char* pSerialStringBuffer = NULL; + char* pProductStringBuffer = NULL; + + if( ( result = DMR_GetDeviceCount( &deviceCount ) ) != DMR_NO_ERROR ) + { + printf( "DMR_GetDeviceCount failed (code: %d(%s))\n", result, DMR_ErrorCodeToString( result ) ); + END_APPLICATION; + } + + if( deviceCount == 0 ) + { + printf( "No compliant device detected.\n" ); + END_APPLICATION; + } + + printf( "%d compliant devices detected.\n", deviceCount ); + for( i = 0; i < deviceCount; i++ ) + { + // try to get access to the device + if( ( result = DMR_GetDevice( phDevice, dmdsmSerial, "*", i, '*' ) ) != DMR_NO_ERROR ) + { + printf( "DMR_GetDevice(%d) failed (code: %d(%s))\n", i, result, DMR_ErrorCodeToString( result ) ); + END_APPLICATION; + } + + if( ( hPropSerial = getDeviceProp( *phDevice, "Serial" ) ) == INVALID_ID ) + { + continue; + } + getStringValue( hPropSerial, &pSerialStringBuffer, 0 ); + if( !pSupportedDeviceCheckFn || pSupportedDeviceCheckFn( *phDevice ) ) + { + if( ( hPropProduct = getDeviceProp( *phDevice, "Product" ) ) == INVALID_ID ) + { + continue; + } + getStringValue( hPropProduct, &pProductStringBuffer, 0 ); + printf( "[%d] %s (%s", i, pSerialStringBuffer, pProductStringBuffer ); + if( ( hPropInterfaceLayout = getDeviceProp( *phDevice, "InterfaceLayout" ) ) != INVALID_ID ) + { + char* pStringBuffer = NULL; + getValueAsString( hPropInterfaceLayout, NULL, &pStringBuffer, 0 ); + if( automaticallyUseGenICamInterface != 0 ) + { + conditionalSetPropI( hPropInterfaceLayout, dilGenICam, 1 ); + } + printf( ", interface layout: %s", pStringBuffer ); + free( pStringBuffer ); + } + + if( ( hPropAcquisitionStartStopBehaviour = getDeviceProp( *phDevice, "AcquisitionStartStopBehaviour" ) ) != INVALID_ID ) + { + char* pStringBuffer = NULL; + conditionalSetPropI( hPropAcquisitionStartStopBehaviour, assbUser, 1 ); + getValueAsString( hPropAcquisitionStartStopBehaviour, NULL, &pStringBuffer, 0 ); + printf( ", acquisition start/stop behaviour: %s", pStringBuffer ); + free( pStringBuffer ); + } + printf( ")\n" ); + free( pProductStringBuffer ); + } + else + { + printf( "%s is not supported by this application.\n", pSerialStringBuffer ); + } + free( pSerialStringBuffer ); + } + + printf( "Please enter the number in brackets followed by [ENTER] to open it: " ); + deviceNumber = getIntValFromSTDIn(); + // remove the '\n' from the stream + fgetc( stdin ); + + // try to get access to the selected device + if( ( result = DMR_GetDevice( phDevice, dmdsmSerial, "*", deviceNumber, '*' ) ) != DMR_NO_ERROR ) + { + printf( "DMR_GetDevice(%d) failed (code: %d(%s))\n", deviceNumber, result, DMR_ErrorCodeToString( result ) ); + printf( "DMR_Close: %d\n", DMR_Close() ); + END_APPLICATION; + } + + return 0; +} + +//----------------------------------------------------------------------------- +static unsigned int isFeatureFlagSet( HOBJ hObj, TComponentFlag flag ) +//----------------------------------------------------------------------------- +{ + TComponentFlag flags; + + if( ( hObj == INVALID_ID ) || + ( OBJ_GetFlags( hObj, &flags ) != PROPHANDLING_NO_ERROR ) ) + { + return 0; + } + + return ( ( flags & flag ) != 0 ); +} + +//----------------------------------------------------------------------------- +unsigned int isFeatureReadable( HOBJ hObj ) +//----------------------------------------------------------------------------- +{ + return isFeatureFlagSet( hObj, cfReadAccess ); +} + +//----------------------------------------------------------------------------- +unsigned int isFeatureWriteable( HOBJ hObj ) +//----------------------------------------------------------------------------- +{ + return isFeatureFlagSet( hObj, cfWriteAccess ); +} + +#if defined(linux) || defined(__linux) || defined(__linux__) +# include +# include +//----------------------------------------------------------------------------- +// returns 0 if timeout, else 1 +unsigned waitForInput( int maxWait_sec, int fd ) +//----------------------------------------------------------------------------- +{ + fd_set rfds; + struct timeval tv; + + FD_ZERO( &rfds ); + FD_SET( fd, &rfds ); + + tv.tv_sec = maxWait_sec ; + tv.tv_usec = 0; + + return select( fd + 1, &rfds, NULL, NULL, &tv ); +} +#endif // #if defined(linux) || defined(__linux) || defined(__linux__) diff --git a/Cigarette/MvIMPACT/apps/Common/exampleHelper_C.h b/Cigarette/MvIMPACT/apps/Common/exampleHelper_C.h new file mode 100644 index 0000000..feafd42 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/exampleHelper_C.h @@ -0,0 +1,71 @@ +//----------------------------------------------------------------------------- +#ifndef exampleHelper_CH +#define exampleHelper_CH exampleHelper_CH +//----------------------------------------------------------------------------- +#include + +#define END_APPLICATION \ + printf( "Press [ENTER] to end the application.\n" ); \ + return getchar() == EOF ? 2 : 1; + +#if defined(linux) || defined(__linux) || defined(__linux__) +unsigned waitForInput( int maxWait_sec, int fd ); +#endif // #if defined(linux) || defined(__linux) || defined(__linux__) + +int getIntValFromSTDIn( void ); +int getPropI( HOBJ hProp, int index ); +void setPropI( HOBJ hProp, int value, int index ); +int64_type getPropI64( HOBJ hProp, int index ); +void setPropI64( HOBJ hProp, int64_type value, int index ); +void* getPropP( HOBJ hProp, int index ); +void setPropP( HOBJ hProp, void* value, int index ); +void setPropS( HOBJ hProp, const char* pVal, int index ); + +HOBJ getDriverList( HDRV hDrv, const char* pListName, const char* pAddListName, TDMR_ListType type ); +HOBJ getDriverProperty( HDRV hDrv, const char* pPropName, const char* pAddListName, TDMR_ListType type ); +HOBJ getDriverMethod( HDRV hDrv, const char* pMethodName, const char* pAddListName, TDMR_ListType type ); +HOBJ getDeviceProp( HDEV hDev, const char* pPropName ); +HOBJ getInfoProp( HDRV hDrv, const char* pPropName ); +HOBJ getIOSubSystemProp( HDRV hDrv, const char* pPropName ); +HOBJ getRequestCtrlProp( HDRV hDrv, const char* pRequestCtrlName, const char* pPropName ); +HOBJ getRequestProp( HDRV hDrv, int requestNr, const char* pPropName ); +HOBJ getSettingProp( HDRV hDrv, const char* pSettingName, const char* pPropName ); +HOBJ getSettingMethod( HDRV hDrv, const char* pSettingName, const char* pMethodName ); +HOBJ getStatisticProp( HDRV hDrv, const char* pPropName ); +HOBJ getSystemSettingProp( HDRV hDrv, const char* pPropName ); + +unsigned int isFeatureReadable( HOBJ hObj ); +unsigned int isFeatureWriteable( HOBJ hObj ); + +typedef unsigned int( *SUPPORTED_DEVICE_CHECK )( const HDEV ); + +int getDeviceFromUserInput( HDEV* phDevice, SUPPORTED_DEVICE_CHECK pSupportedDeviceCheckFn, unsigned int automaticallyUseGenICamInterface ); +/// \brief Reads the value of a feature as a string +/// \note +/// pBuf must be freed by the caller +TPROPHANDLING_ERROR getStringValue( HOBJ hObj, char** pBuf, int index ); +/// \brief Reads the value of a feature as a string +/// \note +/// pBuf must be freed by the caller +TPROPHANDLING_ERROR getValueAsString( HOBJ hObj, const char* pFormat, char** pBuf, int index ); +void modifyEnumPropertyI( HDRV hDrv, const char* pSettingName, const char* pPropName ); +/// \brief Shows how to read the translation dictionary of an integer property and returns all the +/// integer values in the dictionary. +/// +/// \note +/// \a pDictValues must be freed by the caller. +TPROPHANDLING_ERROR readTranslationDictValuesI( HOBJ hObj, int** pDictValues, unsigned int* pDictValCnt, unsigned int silent ); +/// \brief Sets an enumerated integer property to a certain value if this value is supported by +/// the property. +void conditionalSetPropI( HOBJ hObj, int value, unsigned int silent ); + +/// \brief Start the acquisition manually if this was requested(this is to prepare the driver for data capture and tell the device to start streaming data) +/// +/// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStartAcquisitionIfNeeded( HDRV hDrv ); +/// \brief Stop the acquisition manually if this was requested. +/// +/// Whether this is needed or not depends on the property 'AcquisitionStartStopBehaviour' in the list referenced by 'HDEV'. +void manuallyStopAcquisitionIfNeeded( HDRV hDrv ); + +#endif // exampleHelper_CH diff --git a/Cigarette/MvIMPACT/apps/Common/mv.ico b/Cigarette/MvIMPACT/apps/Common/mv.ico new file mode 100644 index 0000000..dfe6fae Binary files /dev/null and b/Cigarette/MvIMPACT/apps/Common/mv.ico differ diff --git a/Cigarette/MvIMPACT/apps/Common/qtIncludeEpilogue.h b/Cigarette/MvIMPACT/apps/Common/qtIncludeEpilogue.h new file mode 100644 index 0000000..9867116 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/qtIncludeEpilogue.h @@ -0,0 +1,3 @@ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( pop ) +#endif diff --git a/Cigarette/MvIMPACT/apps/Common/qtIncludePrologue.h b/Cigarette/MvIMPACT/apps/Common/qtIncludePrologue.h new file mode 100644 index 0000000..18f49bb --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/qtIncludePrologue.h @@ -0,0 +1,7 @@ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( push ) +# pragma warning( disable : 4127 ) // 'conditional expression is constant' +# pragma warning( disable : 4244 ) // 'conversion from 'Bla' to 'Blub', possible loss of data +# pragma warning( disable : 4251 ) // 'class 'Bla' needs to have dll-interface to be used by clients of class 'Blub'' +# pragma warning( disable : 4800 ) // 'int' : forcing value to bool 'true' or 'false' (performance warning) +#endif diff --git a/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolver.cpp b/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolver.cpp new file mode 100644 index 0000000..1c6a083 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolver.cpp @@ -0,0 +1,409 @@ +#include "ProxyResolver.h" + +#if _WIN32_WINNT < 0x0602 // This stuff became available with Windows 8 +# define WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE 0x01000000 +# define WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE +# define API_GET_PROXY_FOR_URL (6) +#endif // #if _WIN32_WINNT < _WIN32_WINNT_WIN8 + +PFNWINHTTPGETPROXYFORURLEX ProxyResolver::s_pfnWinhttpGetProxyForUrlEx = NULL; +PFNWINHTTPFREEPROXYLIST ProxyResolver::s_pfnWinhttpFreeProxyList = NULL; +PFNWINHTTPCREATEPROXYRESOLVER ProxyResolver::s_pfnWinhttpCreateProxyResolver = NULL; +PFNWINHTTPGETPROXYRESULT ProxyResolver::s_pfnWinhttpGetProxyResult = NULL; + +//----------------------------------------------------------------------------- +ProxyResolver::ProxyResolver() : m_fInit( FALSE ), m_fExtendedAPI( FALSE ), m_dwError( ERROR_SUCCESS ), m_hEvent( 0 ) +//----------------------------------------------------------------------------- +{ + ZeroMemory( &m_wprProxyResult, sizeof( WINHTTP_PROXY_RESULT ) ); + ZeroMemory( &m_wpiProxyInfo, sizeof( WINHTTP_PROXY_INFO ) ); + + HMODULE hWinhttp = GetModuleHandle( L"winhttp.dll" ); + if( hWinhttp != NULL ) + { + s_pfnWinhttpGetProxyForUrlEx = ( PFNWINHTTPGETPROXYFORURLEX )GetProcAddress( hWinhttp, "WinHttpGetProxyForUrlEx" ); + s_pfnWinhttpFreeProxyList = ( PFNWINHTTPFREEPROXYLIST )GetProcAddress( hWinhttp, "WinHttpFreeProxyResult" ); + s_pfnWinhttpCreateProxyResolver = ( PFNWINHTTPCREATEPROXYRESOLVER )GetProcAddress( hWinhttp, "WinHttpCreateProxyResolver" ); + s_pfnWinhttpGetProxyResult = ( PFNWINHTTPGETPROXYRESULT )GetProcAddress( hWinhttp, "WinHttpGetProxyResult" ); + } + m_fExtendedAPI = s_pfnWinhttpGetProxyForUrlEx && s_pfnWinhttpFreeProxyList && s_pfnWinhttpCreateProxyResolver && s_pfnWinhttpGetProxyResult; +} + +//----------------------------------------------------------------------------- +ProxyResolver::~ProxyResolver() +//----------------------------------------------------------------------------- +{ + if( m_wpiProxyInfo.lpszProxy != NULL ) + { + GlobalFree( m_wpiProxyInfo.lpszProxy ); + } + + if( m_wpiProxyInfo.lpszProxyBypass != NULL ) + { + GlobalFree( m_wpiProxyInfo.lpszProxyBypass ); + } + + if( m_fExtendedAPI ) + { + s_pfnWinhttpFreeProxyList( &m_wprProxyResult ); + } + + if( m_hEvent != NULL ) + { + CloseHandle( m_hEvent ); + } +} + +//----------------------------------------------------------------------------- +BOOL ProxyResolver::IsRecoverableAutoProxyError( _In_ DWORD dwError ) +//----------------------------------------------------------------------------- +{ + switch( dwError ) + { + case ERROR_SUCCESS: + case ERROR_INVALID_PARAMETER: + case ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR: + case ERROR_WINHTTP_AUTODETECTION_FAILED: + case ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT: + case ERROR_WINHTTP_LOGIN_FAILURE: + case ERROR_WINHTTP_OPERATION_CANCELLED: + case ERROR_WINHTTP_TIMEOUT: + case ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT: + case ERROR_WINHTTP_UNRECOGNIZED_SCHEME: + return TRUE; + default: + break; + } + return FALSE; +} + +//----------------------------------------------------------------------------- +VOID CALLBACK ProxyResolver::GetProxyCallBack( _In_ HINTERNET hResolver, _In_ DWORD_PTR dwContext, _In_ DWORD dwInternetStatus, _In_ PVOID pvStatusInformation, _In_ DWORD /*dwStatusInformationLength*/ ) +//----------------------------------------------------------------------------- +{ + ProxyResolver* pProxyResolver = ( ProxyResolver* )dwContext; + if( ( dwInternetStatus != WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE && + dwInternetStatus != WINHTTP_CALLBACK_STATUS_REQUEST_ERROR ) || + pProxyResolver == NULL ) + { + return; + } + + if( dwInternetStatus == WINHTTP_CALLBACK_STATUS_REQUEST_ERROR ) + { + WINHTTP_ASYNC_RESULT* pAsyncResult = ( WINHTTP_ASYNC_RESULT* )pvStatusInformation; + + if( pAsyncResult->dwResult != API_GET_PROXY_FOR_URL ) + { + return; + } + + pProxyResolver->m_dwError = pAsyncResult->dwError; + } + else if( dwInternetStatus == WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE ) + { + pProxyResolver->m_dwError = s_pfnWinhttpGetProxyResult( hResolver, &pProxyResolver->m_wprProxyResult ); + } + + if( hResolver != NULL ) + { + WinHttpCloseHandle( hResolver ); + hResolver = NULL; + } + + SetEvent( pProxyResolver->m_hEvent ); +} + +#define CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE(HRESOLVER, ERROR_CODE) \ + if( HRESOLVER != NULL ) \ + { \ + WinHttpCloseHandle( HRESOLVER ); \ + } \ + return ERROR_CODE + +//----------------------------------------------------------------------------- +DWORD ProxyResolver::GetProxyForUrlEx( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_ WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions ) +//----------------------------------------------------------------------------- +{ + // Create proxy resolver handle. It's best to close the handle during call back. + HINTERNET hResolver = NULL; + DWORD dwError = s_pfnWinhttpCreateProxyResolver( hSession, &hResolver ); + if( dwError != ERROR_SUCCESS ) + { + CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE( hResolver, dwError ); + } + + // Sets up a callback function that WinHTTP can call as proxy results are resolved. + WINHTTP_STATUS_CALLBACK wscCallback = WinHttpSetStatusCallback( hResolver, GetProxyCallBack, WINHTTP_CALLBACK_FLAG_REQUEST_ERROR | WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE, 0 ); + if( wscCallback == WINHTTP_INVALID_STATUS_CALLBACK ) + { + dwError = GetLastError(); + CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE( hResolver, dwError ); + } + + // The extended API works in asynchronous mode, therefore wait until the + // results are set in the call back function. + dwError = s_pfnWinhttpGetProxyForUrlEx( hResolver, pwszUrl, pAutoProxyOptions, ( DWORD_PTR )this ); + if( dwError != ERROR_IO_PENDING ) + { + CLOSE_RESOLVER_HANDLE_AND_RETURN_ERROR_CODE( hResolver, dwError ); + } + + // The resolver handle will get closed in the callback and cannot be used any longer. + hResolver = NULL; + dwError = WaitForSingleObjectEx( m_hEvent, INFINITE, FALSE ); + if( dwError != WAIT_OBJECT_0 ) + { + return GetLastError(); + } + return m_dwError; +} + +//----------------------------------------------------------------------------- +_Success_( return == ERROR_SUCCESS ) DWORD ProxyResolver::GetProxyForAutoSettings( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_opt_z_ PCWSTR pwszAutoConfigUrl, _Outptr_result_maybenull_ PWSTR* ppwszProxy, _Outptr_result_maybenull_ PWSTR* ppwszProxyBypass ) +//----------------------------------------------------------------------------- +{ + DWORD dwError = ERROR_SUCCESS; + WINHTTP_AUTOPROXY_OPTIONS waoOptions = {}; + WINHTTP_PROXY_INFO wpiProxyInfo = {}; + + *ppwszProxy = NULL; + *ppwszProxyBypass = NULL; + + if( pwszAutoConfigUrl ) + { + waoOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; + waoOptions.lpszAutoConfigUrl = pwszAutoConfigUrl; + } + else + { + waoOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT; + waoOptions.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A; + } + + // First call with no autologon. Autologon prevents the + // session (in proc) or autoproxy service (out of proc) from caching + // the proxy script. This causes repetitive network traffic, so it is + // best not to do autologon unless it is required according to the + // result of WinHttpGetProxyForUrl. + // This applies to both WinHttpGetProxyForUrl and WinhttpGetProxyForUrlEx. + if( m_fExtendedAPI ) + { + m_hEvent = CreateEventEx( NULL, NULL, 0, EVENT_ALL_ACCESS ); + if( m_hEvent == NULL ) + { + dwError = GetLastError(); + goto quit; + } + + dwError = GetProxyForUrlEx( hSession, pwszUrl, &waoOptions ); + if( dwError != ERROR_WINHTTP_LOGIN_FAILURE ) + { + // Unless we need to retry with auto-logon exit the function with the + // result, on success the proxy list will be stored in m_wprProxyResult + // by GetProxyCallBack. + goto quit; + } + + // Enable autologon if challenged. + waoOptions.fAutoLogonIfChallenged = TRUE; + dwError = GetProxyForUrlEx( hSession, pwszUrl, &waoOptions ); + goto quit; + } + + if( !WinHttpGetProxyForUrl( hSession, pwszUrl, &waoOptions, &wpiProxyInfo ) ) + { + dwError = GetLastError(); + if( dwError != ERROR_WINHTTP_LOGIN_FAILURE ) + { + goto quit; + } + + // Enable autologon if challenged. + dwError = ERROR_SUCCESS; + waoOptions.fAutoLogonIfChallenged = TRUE; + if( !WinHttpGetProxyForUrl( hSession, pwszUrl, &waoOptions, &wpiProxyInfo ) ) + { + dwError = GetLastError(); + goto quit; + } + } + + *ppwszProxy = wpiProxyInfo.lpszProxy; + wpiProxyInfo.lpszProxy = NULL; + + *ppwszProxyBypass = wpiProxyInfo.lpszProxyBypass; + wpiProxyInfo.lpszProxyBypass = NULL; + +quit: + + if( wpiProxyInfo.lpszProxy ) + { + GlobalFree( wpiProxyInfo.lpszProxy ); + wpiProxyInfo.lpszProxy = NULL; + } + + if( wpiProxyInfo.lpszProxyBypass ) + { + GlobalFree( wpiProxyInfo.lpszProxyBypass ); + wpiProxyInfo.lpszProxyBypass = NULL; + } + + return dwError; +} + +//----------------------------------------------------------------------------- +DWORD ProxyResolver::ResolveProxy( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl ) +//----------------------------------------------------------------------------- +{ + DWORD dwError = ERROR_SUCCESS; + WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ProxyConfig = {}; + PWSTR pwszProxy = NULL; + PWSTR pwszProxyBypass = NULL; + BOOL fFailOverValid = FALSE; + + if( m_fInit ) + { + dwError = ERROR_INVALID_OPERATION; + goto quit; + } + + if( !WinHttpGetIEProxyConfigForCurrentUser( &ProxyConfig ) ) + { + dwError = GetLastError(); + if( dwError != ERROR_FILE_NOT_FOUND ) + { + goto quit; + } + + // No IE proxy settings found, just do autodetect. + ProxyConfig.fAutoDetect = TRUE; + dwError = ERROR_SUCCESS; + } + + // Begin processing the proxy settings in the following order: + // 1) Auto-Detect if configured. + // 2) Auto-Config URL if configured. + // 3) Static Proxy Settings if configured. + // + // Once any of these methods succeed in finding a proxy we are finished. + // In the event one mechanism fails with an expected error code it is + // required to fall back to the next mechanism. If the request fails + // after exhausting all detected proxies, there should be no attempt + // to discover additional proxies. + if( ProxyConfig.fAutoDetect ) + { + fFailOverValid = TRUE; + // Detect Proxy Settings. + dwError = GetProxyForAutoSettings( hSession, pwszUrl, NULL, &pwszProxy, &pwszProxyBypass ); + if( dwError == ERROR_SUCCESS ) + { + goto commit; + } + + if( !IsRecoverableAutoProxyError( dwError ) ) + { + goto quit; + } + + // Fall back to Autoconfig URL or Static settings. An application can + // optionally take some action such as logging, or creating a mechanism + // to expose multiple error codes in the class. + dwError = ERROR_SUCCESS; + } + + if( ProxyConfig.lpszAutoConfigUrl ) + { + fFailOverValid = TRUE; + // Run autoproxy with AutoConfig URL. + dwError = GetProxyForAutoSettings( hSession, pwszUrl, ProxyConfig.lpszAutoConfigUrl, &pwszProxy, &pwszProxyBypass ); + if( dwError == ERROR_SUCCESS ) + { + goto commit; + } + + if( !IsRecoverableAutoProxyError( dwError ) ) + { + goto quit; + } + + // Fall back to Static Settings. An application can optionally take some + // action such as logging, or creating a mechanism to to expose multiple + // error codes in the class. + dwError = ERROR_SUCCESS; + } + + fFailOverValid = FALSE; + // Static Proxy Config. Failover is not valid for static proxy since + // it is always either a single proxy or a list containing protocol + // specific proxies such as "proxy" or http=httpproxy;https=sslproxy + pwszProxy = ProxyConfig.lpszProxy; + ProxyConfig.lpszProxy = NULL; + + pwszProxyBypass = ProxyConfig.lpszProxyBypass; + ProxyConfig.lpszProxyBypass = NULL; + +commit: + + if( pwszProxy == NULL ) + { + m_wpiProxyInfo.dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY; + } + else + { + m_wpiProxyInfo.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; + } + + m_wpiProxyInfo.lpszProxy = pwszProxy; + pwszProxy = NULL; + + m_wpiProxyInfo.lpszProxyBypass = pwszProxyBypass; + pwszProxyBypass = NULL; + + m_fInit = TRUE; + +quit: + + if( pwszProxy != NULL ) + { + GlobalFree( pwszProxy ); + pwszProxy = NULL; + } + + if( pwszProxyBypass != NULL ) + { + GlobalFree( pwszProxyBypass ); + pwszProxyBypass = NULL; + } + + if( ProxyConfig.lpszAutoConfigUrl != NULL ) + { + GlobalFree( ProxyConfig.lpszAutoConfigUrl ); + ProxyConfig.lpszAutoConfigUrl = NULL; + } + + if( ProxyConfig.lpszProxy != NULL ) + { + GlobalFree( ProxyConfig.lpszProxy ); + ProxyConfig.lpszProxy = NULL; + } + + if( ProxyConfig.lpszProxyBypass != NULL ) + { + GlobalFree( ProxyConfig.lpszProxyBypass ); + ProxyConfig.lpszProxyBypass = NULL; + } + + return dwError; +} + +//----------------------------------------------------------------------------- +const WINHTTP_PROXY_RESULT_ENTRY* ProxyResolver::GetProxySetting( const DWORD index ) const +//----------------------------------------------------------------------------- +{ + if( index < m_wprProxyResult.cEntries ) + { + return &m_wprProxyResult.pEntries[index]; + } + return 0; +} diff --git a/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolver.h b/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolver.h new file mode 100644 index 0000000..946fb6f --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolver.h @@ -0,0 +1,52 @@ +#pragma once +#include +#include + +#if _WIN32_WINNT < 0x0602 // This stuff became available with Windows 8 +typedef struct _WINHTTP_PROXY_RESULT_ENTRY +{ + BOOL fProxy; // Is this a proxy or DIRECT? + BOOL fBypass; // If DIRECT, is it bypassing a proxy (intranet) or is all traffic DIRECT (internet) + INTERNET_SCHEME ProxyScheme; // The scheme of the proxy, SOCKS, HTTP (CERN Proxy), HTTPS (SSL through Proxy) + PWSTR pwszProxy; // Hostname of the proxy. + INTERNET_PORT ProxyPort; // Port of the proxy. +} WINHTTP_PROXY_RESULT_ENTRY; + +typedef struct _WINHTTP_PROXY_RESULT +{ + DWORD cEntries; + WINHTTP_PROXY_RESULT_ENTRY* pEntries; +} WINHTTP_PROXY_RESULT; +#endif // #if _WIN32_WINNT < 0x0602 + +typedef DWORD ( WINAPI* PFNWINHTTPGETPROXYFORURLEX )( HINTERNET, PCWSTR, WINHTTP_AUTOPROXY_OPTIONS*, DWORD_PTR ); +typedef DWORD ( WINAPI* PFNWINHTTPFREEPROXYLIST )( WINHTTP_PROXY_RESULT* ); +typedef DWORD ( WINAPI* PFNWINHTTPCREATEPROXYRESOLVER )( HINTERNET, HINTERNET* ); +typedef DWORD ( WINAPI* PFNWINHTTPGETPROXYRESULT )( HINTERNET, WINHTTP_PROXY_RESULT* ); + +class ProxyResolver +{ + BOOL m_fInit; + BOOL m_fExtendedAPI; + DWORD m_dwError; + HANDLE m_hEvent; + WINHTTP_PROXY_INFO m_wpiProxyInfo; + WINHTTP_PROXY_RESULT m_wprProxyResult; + + BOOL IsRecoverableAutoProxyError( _In_ DWORD dwError ); + VOID static CALLBACK GetProxyCallBack( _In_ HINTERNET hResolver, _In_ DWORD_PTR dwContext, _In_ DWORD dwInternetStatus, _In_ PVOID pvStatusInformation, _In_ DWORD dwStatusInformationLength ); + DWORD GetProxyForUrlEx( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_ WINHTTP_AUTOPROXY_OPTIONS* pAutoProxyOptions ); + _Success_( return == ERROR_SUCCESS ) DWORD GetProxyForAutoSettings( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl, _In_opt_z_ PCWSTR pwszAutoConfigUrl, _Outptr_result_maybenull_ PWSTR* ppwszProxy, _Outptr_result_maybenull_ PWSTR* ppwszProxyBypass ); + + static PFNWINHTTPGETPROXYFORURLEX s_pfnWinhttpGetProxyForUrlEx; + static PFNWINHTTPFREEPROXYLIST s_pfnWinhttpFreeProxyList; + static PFNWINHTTPCREATEPROXYRESOLVER s_pfnWinhttpCreateProxyResolver; + static PFNWINHTTPGETPROXYRESULT s_pfnWinhttpGetProxyResult; + +public: + ProxyResolver(); + ~ProxyResolver(); + + DWORD ResolveProxy( _In_ HINTERNET hSession, _In_z_ PCWSTR pwszUrl ); + const WINHTTP_PROXY_RESULT_ENTRY* GetProxySetting( const DWORD index ) const; +}; diff --git a/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolverContext.cpp b/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolverContext.cpp new file mode 100644 index 0000000..9f65f9a --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/win32/ProxyResolverContext.cpp @@ -0,0 +1,232 @@ +//----------------------------------------------------------------------------- +#include "../ProxyResolverContext.h" +#include "ProxyResolver.h" +#include + +using namespace std; + +//============================================================================= +//================= Implementation ProxyResolverContextImpl =================== +//============================================================================= +//----------------------------------------------------------------------------- +struct ProxyResolverContextImpl +//----------------------------------------------------------------------------- +{ + HINTERNET hProxyResolveSession; + ProxyResolver* pProxyResolver; + explicit ProxyResolverContextImpl( const wstring& userAgent ) : hProxyResolveSession( 0 ), pProxyResolver( 0 ) + { + hProxyResolveSession = WinHttpOpen( userAgent.c_str(), WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, WINHTTP_FLAG_ASYNC ); + if( hProxyResolveSession ) + { + pProxyResolver = new ProxyResolver(); + } + } + ~ProxyResolverContextImpl() + { + delete pProxyResolver; + if( hProxyResolveSession ) + { + WinHttpCloseHandle( hProxyResolveSession ); + } + } +}; + +//============================================================================= +//================= Implementation ProxyResolverContext ======================= +//============================================================================= +//----------------------------------------------------------------------------- +ProxyResolverContext::ProxyResolverContext( const wstring& userAgent, const wstring& url ) : pImpl_( new ProxyResolverContextImpl( userAgent ) ) +//----------------------------------------------------------------------------- +{ + if( pImpl_->pProxyResolver ) + { + pImpl_->pProxyResolver->ResolveProxy( pImpl_->hProxyResolveSession, url.c_str() ); + } +} + +//----------------------------------------------------------------------------- +ProxyResolverContext::~ProxyResolverContext() +//----------------------------------------------------------------------------- +{ + delete pImpl_; +} + +//----------------------------------------------------------------------------- +wstring ProxyResolverContext::GetProxy( unsigned int index ) const +//----------------------------------------------------------------------------- +{ + const WINHTTP_PROXY_RESULT_ENTRY* pProxyData = pImpl_->pProxyResolver->GetProxySetting( index ); + return ( pProxyData && pProxyData->pwszProxy ) ? wstring( pProxyData->pwszProxy ) : wstring(); +} + +//----------------------------------------------------------------------------- +unsigned int ProxyResolverContext::GetProxyPort( unsigned int index ) const +//----------------------------------------------------------------------------- +{ + const WINHTTP_PROXY_RESULT_ENTRY* pProxyData = pImpl_->pProxyResolver->GetProxySetting( index ); + return pProxyData ? pProxyData->ProxyPort : 0; +} + +//============================================================================= +//================= Implementation helper functions =========================== +//============================================================================= + +//----------------------------------------------------------------------------- +/// \brief This function checks the token of the calling thread to see if the caller +/// belongs to the Administrators group. +/** + * \return + - true if the caller is an administrator on the local machine. + - false otherwise +*/ +bool IsCurrentUserLocalAdministrator( void ) +//----------------------------------------------------------------------------- +{ + BOOL fReturn = FALSE; + PACL pACL = NULL; + PSID psidAdmin = NULL; + HANDLE hToken = NULL; + HANDLE hImpersonationToken = NULL; + PSECURITY_DESCRIPTOR psdAdmin = NULL; + + + // Determine if the current thread is running as a user that is a member of + // the local admins group. To do this, create a security descriptor that + // has a DACL which has an ACE that allows only local administrators access. + // Then, call AccessCheck with the current thread's token and the security + // descriptor. It will say whether the user could access an object if it + // had that security descriptor. Note: you do not need to actually create + // the object. Just checking access against the security descriptor alone + // will be sufficient. + const DWORD ACCESS_READ = 1; + const DWORD ACCESS_WRITE = 2; + + __try + { + // AccessCheck() requires an impersonation token. We first get a primary + // token and then create a duplicate impersonation token. The + // impersonation token is not actually assigned to the thread, but is + // used in the call to AccessCheck. Thus, this function itself never + // impersonates, but does use the identity of the thread. If the thread + // was impersonating already, this function uses that impersonation context. + if( !OpenThreadToken( GetCurrentThread(), TOKEN_DUPLICATE | TOKEN_QUERY, TRUE, &hToken ) ) + { + if( GetLastError() != ERROR_NO_TOKEN ) + { + __leave; + } + + if( !OpenProcessToken( GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_QUERY, &hToken ) ) + { + __leave; + } + } + + if( !DuplicateToken ( hToken, SecurityImpersonation, &hImpersonationToken ) ) + { + __leave; + } + + // Create the binary representation of the well-known SID that + // represents the local administrators group. Then create the security + // descriptor and DACL with an ACE that allows only local admins access. + // After that, perform the access check. This will determine whether + // the current user is a local admin. + SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; + if( !AllocateAndInitializeSid( &SystemSidAuthority, 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, &psidAdmin ) ) + { + __leave; + } + + psdAdmin = LocalAlloc( LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH ); + if( psdAdmin == NULL ) + { + __leave; + } + + if( !InitializeSecurityDescriptor( psdAdmin, SECURITY_DESCRIPTOR_REVISION ) ) + { + __leave; + } + + // Compute size needed for the ACL. + const DWORD dwACLSize = sizeof( ACL ) + sizeof( ACCESS_ALLOWED_ACE ) + GetLengthSid( psidAdmin ) - sizeof( DWORD ); + pACL = ( PACL )LocalAlloc( LPTR, dwACLSize ); + if( pACL == NULL ) + { + __leave; + } + + if( !InitializeAcl( pACL, dwACLSize, ACL_REVISION2 ) ) + { + __leave; + } + + if( !AddAccessAllowedAce( pACL, ACL_REVISION2, ACCESS_READ | ACCESS_WRITE, psidAdmin ) ) + { + __leave; + } + + if( !SetSecurityDescriptorDacl( psdAdmin, TRUE, pACL, FALSE ) ) + { + __leave; + } + + // AccessCheck validates a security descriptor somewhat; set the group + // and owner so that enough of the security descriptor is filled out to + // make AccessCheck happy. + SetSecurityDescriptorGroup( psdAdmin, psidAdmin, FALSE ); + SetSecurityDescriptorOwner( psdAdmin, psidAdmin, FALSE ); + + if( !IsValidSecurityDescriptor( psdAdmin ) ) + { + __leave; + } + + // Initialize GenericMapping structure even though you do not use generic rights. + GENERIC_MAPPING GenericMapping; + GenericMapping.GenericRead = ACCESS_READ; + GenericMapping.GenericWrite = ACCESS_WRITE; + GenericMapping.GenericExecute = 0; + GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; + DWORD dwStructureSize = sizeof( PRIVILEGE_SET ); + DWORD dwStatus; + PRIVILEGE_SET ps; + if( !AccessCheck( psdAdmin, hImpersonationToken, ACCESS_READ, + &GenericMapping, &ps, &dwStructureSize, &dwStatus, + &fReturn ) ) + { + fReturn = FALSE; + __leave; + } + } + __finally + { + if( pACL ) + { + LocalFree( pACL ); + } + if( psdAdmin ) + { + LocalFree( psdAdmin ); + } + if( psidAdmin ) + { + FreeSid( psidAdmin ); + } + if( hImpersonationToken ) + { + CloseHandle ( hImpersonationToken ); + } + if( hToken ) + { + CloseHandle ( hToken ); + } + } + + return fReturn != FALSE; +} diff --git a/Cigarette/MvIMPACT/apps/Common/wxAbstraction.h b/Cigarette/MvIMPACT/apps/Common/wxAbstraction.h new file mode 100644 index 0000000..ce4487a --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/wxAbstraction.h @@ -0,0 +1,660 @@ +//----------------------------------------------------------------------------- +#ifndef wxAbstractionH +#define wxAbstractionH wxAbstractionH +//----------------------------------------------------------------------------- +#include +#include +#include +#include + +#include "wxIncludePrologue.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "wxIncludeEpilogue.h" + +//----------------------------------------------------------------------------- +struct ConvertedString : wxString +//----------------------------------------------------------------------------- +{ +#if wxUSE_UNICODE + ConvertedString( const char* s ) : + wxString( s, wxConvUTF8 ) {} + ConvertedString( const std::string& s ) : + wxString( s.c_str(), wxConvUTF8 ) {} + ConvertedString( const wxString& s ) : +# if wxCHECK_VERSION(2,9,0) + wxString( s.mb_str(), wxConvUTF8 ) {} +# else + wxString( s.c_str(), wxConvUTF8 ) {} +# endif +#else + ConvertedString( const char* s ) : + wxString( s ) {} + ConvertedString( const std::string& s ) : + wxString( s.c_str() ) {} + ConvertedString( const wxString& s ) : +# if wxCHECK_VERSION(2,9,0) + wxString( s.mb_str() ) {} +# else + wxString( s.c_str() ) {} +# endif +#endif +}; + +#if ( wxMINOR_VERSION > 6 ) && ( wxMAJOR_VERSION < 3 ) && !WXWIN_COMPATIBILITY_2_6 +#include +enum +{ + wxOPEN = wxFD_OPEN, + wxSAVE = wxFD_SAVE, + wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT, + wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST, + wxMULTIPLE = wxFD_MULTIPLE, + wxCHANGE_DIR = wxFD_CHANGE_DIR +}; +#endif + +//----------------------------------------------------------------------------- +enum TApplicationColors +//----------------------------------------------------------------------------- +{ + acRedPastel = ( 200 << 16 ) | ( 200 << 8 ) | 255, + acYellowPastel = ( 180 << 16 ) | ( 255 << 8 ) | 255, + acBluePastel = ( 255 << 16 ) | ( 220 << 8 ) | 200, + acDarkBluePastel = ( 255 << 16 ) | ( 100 << 8 ) | 80, + acGreenPastel = ( 200 << 16 ) | ( 255 << 8 ) | 200, + acGreyPastel = ( 200 << 16 ) | ( 200 << 8 ) | 200, + acDarkGrey = ( 100 << 16 ) | ( 100 << 8 ) | 100 +}; + +//============================================================================= +//================= Implementation FramePositionStorage ======================= +//============================================================================= +//----------------------------------------------------------------------------- +class FramePositionStorage +//----------------------------------------------------------------------------- +{ + wxWindow* m_pWin; +public: + FramePositionStorage( wxWindow* pWin ) : m_pWin( pWin ) {} + void Save( void ) const + { + Save( m_pWin ); + } + static void Save( wxWindow* pWin, const wxString& windowName = wxT( "MainFrame" ) ) + { + wxConfigBase* pConfig( wxConfigBase::Get() ); + int Height, Width, XPos, YPos; + pWin->GetSize( &Width, &Height ); + pWin->GetPosition( &XPos, &YPos ); + // when we e.g. try to write config stuff on a read-only file system the result can + // be an annoying message box. Therefore we switch off logging during the storage operation. + wxLogNull logSuspendScope; + pConfig->Write( wxString::Format( wxT( "/%s/h" ), windowName.c_str() ), Height ); + pConfig->Write( wxString::Format( wxT( "/%s/w" ), windowName.c_str() ), Width ); + pConfig->Write( wxString::Format( wxT( "/%s/x" ), windowName.c_str() ), XPos ); + pConfig->Write( wxString::Format( wxT( "/%s/y" ), windowName.c_str() ), YPos ); + if( dynamic_cast( pWin ) ) + { + pConfig->Write( wxString::Format( wxT( "/%s/maximized" ), windowName.c_str() ), dynamic_cast( pWin )->IsMaximized() ); + } + pConfig->Flush(); + } + static wxRect Load( const wxRect& defaultDimensions, bool& boMaximized, const wxString& windowName = wxT( "MainFrame" ) ) + { + wxConfigBase* pConfig( wxConfigBase::Get() ); + wxRect rect; + rect.height = pConfig->Read( wxString::Format( wxT( "/%s/h" ), windowName.c_str() ), defaultDimensions.height ); + rect.width = pConfig->Read( wxString::Format( wxT( "/%s/w" ), windowName.c_str() ), defaultDimensions.width ); + rect.x = pConfig->Read( wxString::Format( wxT( "/%s/x" ), windowName.c_str() ), defaultDimensions.x ); + rect.y = pConfig->Read( wxString::Format( wxT( "/%s/y" ), windowName.c_str() ), defaultDimensions.y ); + boMaximized = pConfig->Read( wxString::Format( wxT( "/%s/maximized" ), windowName.c_str() ), 1l ) != 0; + int displayWidth = 0; + int displayHeight = 0; + wxDisplaySize( &displayWidth, &displayHeight ); + if( ( rect.x >= displayWidth ) || ( ( rect.x + rect.width ) < 0 ) ) + { + rect.x = 0; + } + if( ( rect.y >= displayHeight ) || ( ( rect.y + rect.height ) < 0 ) ) + { + rect.y = 0; + } + return rect; + } +}; + +//============================================================================= +//================= Implementation SplashScreenScope ========================== +//============================================================================= +//----------------------------------------------------------------------------- +class SplashScreenScope +//----------------------------------------------------------------------------- +{ + wxSplashScreen* pSplash_; + wxStopWatch stopWatch_; +public: + explicit SplashScreenScope( const wxBitmap& bmp, const wxBitmap& icon ) : pSplash_( 0 ), stopWatch_() + { + pSplash_ = new wxSplashScreen( ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_SMALL ) ? icon : bmp, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER ); + pSplash_->Update(); + } + virtual ~SplashScreenScope() + { + const unsigned long startupTime_ms = static_cast( stopWatch_.Time() ); + const unsigned long minSplashDisplayTime_ms = 3000; + if( startupTime_ms < minSplashDisplayTime_ms ) + { + wxMilliSleep( minSplashDisplayTime_ms - startupTime_ms ); + } + delete pSplash_; + } +}; + +//============================================================================= +//================= Implementation SocketInitializeScope ====================== +//============================================================================= +//----------------------------------------------------------------------------- +class SocketInitializeScope +//----------------------------------------------------------------------------- +{ +public: + explicit SocketInitializeScope() + { + // This has to be called in order to be able to initialize sockets outside of + // the main thread ( http://www.litwindow.com/Knowhow/wxSocket/wxsocket.html ) + wxSocketBase::Initialize(); + } + ~SocketInitializeScope() + { + // Must apparently be done since we called wxSocketBase::Initialize(), + // otherwise memory leaks occur when closing the application. + wxSocketBase::Shutdown(); + } +}; + +//============================================================================= +//================= Implementation miscellaneous helper functions ============= +//============================================================================= +//----------------------------------------------------------------------------- +inline wxString LoadGenTLProducer( wxDynamicLibrary& lib ) +//----------------------------------------------------------------------------- +{ +#ifdef _WIN32 + const wxString libName( wxT( "mvGenTLProducer.cti" ) ); +#else + const wxString libName( wxT( "libmvGenTLProducer.so" ) ); +#endif + + const wxString GenTLPathVariable( ( sizeof( void* ) == 8 ) ? wxT( "GENICAM_GENTL64_PATH" ) : wxT( "GENICAM_GENTL32_PATH" ) ); +#if defined(linux) || defined(__linux) || defined(__linux__) + const wxChar PATH_SEPARATOR( wxT( ':' ) ); +#elif defined(_WIN32) || defined(WIN32) || defined(__WIN32__) + const wxChar PATH_SEPARATOR( wxT( ';' ) ); +#else +# error Unsupported target platform +#endif + wxString GenTLPath; + wxArrayString potentialLocations; + if( ::wxGetEnv( GenTLPathVariable, &GenTLPath ) ) + { + potentialLocations = wxSplit( GenTLPath, PATH_SEPARATOR ); + } + + wxString message; + // when we e.g. trying to load a shared library that cannot be found the result can + // be an annoying message box. Therefore we switch off logging during the load attempts. + wxLogNull logSuspendScope; + const size_t potentialLocationCount = potentialLocations.Count(); + for( size_t i = 0; i < potentialLocationCount; i++ ) + { + lib.Load( potentialLocations[i] + wxT( "/" ) + libName, wxDL_VERBATIM ); + if( lib.IsLoaded() ) + { + break; + } + } + + if( !lib.IsLoaded() ) + { + lib.Load( libName, wxDL_VERBATIM ); + } + if( !lib.IsLoaded() ) + { + message = wxString::Format( wxT( "Could not connect to '%s'. Check your installation.\n\n" ), libName.c_str() ); + } + return message; +} + +//----------------------------------------------------------------------------- +inline void AddSourceInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "The complete source code belonging to this application can be obtained by contacting " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, COMPANY_NAME, COMPANY_WEBSITE ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddSupportInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "Support contact: " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, COMPANY_SUPPORT_MAIL, COMPANY_SUPPORT_MAIL ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddwxWidgetsInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "This tool has been written using " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "wxWidgets" ), wxT( "http://www.wxwidgets.org" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxString::Format( wxT( " %d.%d.%d." ), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER ) ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddIconInfo( wxWindow* pParent, wxSizer* pParentSizer ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( "This tool uses modified icons downloaded from here " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "icons8" ), wxT( "https://icons8.com/" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( " and here " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "Freepik" ), wxT( "http://www.freepik.com" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( ". The " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "Material Design" ), wxT( "https://material.io/resources/icons/?style=outline" ) ) ); + pSizer->Add( new wxStaticText( pParent, wxID_ANY, wxT( " icons are published under " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( pParent, wxID_ANY, wxT( "Apache 2.0 license." ), wxT( "https://www.apache.org/licenses/LICENSE-2.0.html" ) ) ); + pParentSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); +} + +//----------------------------------------------------------------------------- +inline void AddListControlToAboutNotebook( wxNotebook* pNotebook, const wxString& pageTitle, bool boSelectPage, const wxString& col0, const wxString& col1, const std::vector >& v ) +//----------------------------------------------------------------------------- +{ + wxListCtrl* pListCtrl = new wxListCtrl( pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxBORDER_NONE ); + pListCtrl->InsertColumn( 0, col0 ); + pListCtrl->InsertColumn( 1, col1 ); + const unsigned long cnt = static_cast( v.size() ); + for( unsigned long i = 0; i < cnt; i++ ) + { + long index = pListCtrl->InsertItem( i, v[i].first, i ); + pListCtrl->SetItem( index, 1, v[i].second ); + } + for( unsigned int i = 0; i < 2; i++ ) + { + pListCtrl->SetColumnWidth( i, wxLIST_AUTOSIZE ); + } + pNotebook->AddPage( pListCtrl, pageTitle, boSelectPage ); +} + +//----------------------------------------------------------------------------- +inline void AppendPathSeparatorIfNeeded( wxString& path ) +//----------------------------------------------------------------------------- +{ + if( !path.EndsWith( wxT( "/" ) ) && !path.EndsWith( wxT( "\\" ) ) ) + { + path.append( wxT( "/" ) ); + } +} + +//----------------------------------------------------------------------------- +inline void WriteToTextCtrl( wxTextCtrl* pTextCtrl, const wxString& msg, const wxTextAttr& style = wxTextAttr( *wxBLACK ) ) +//----------------------------------------------------------------------------- +{ + if( pTextCtrl ) + { + // If you want the control to show the last line of text at the bottom, you can add "ScrollLines(1)" + // right after the AppendText call. AppendText will ensure the new line is visible, and ScrollLines + // will ensure the scroll bar is at the real end of the range, not further. + long posBefore = pTextCtrl->GetLastPosition(); + pTextCtrl->AppendText( msg ); + long posAfter = pTextCtrl->GetLastPosition(); + pTextCtrl->SetStyle( posBefore, posAfter, style ); + pTextCtrl->ScrollLines( 1 ); + pTextCtrl->ShowPosition( pTextCtrl->GetLastPosition() ); // ensure that this position is really visible + } +} + +//----------------------------------------------------------------------------- +struct AboutDialogInformation +//----------------------------------------------------------------------------- +{ + wxIcon icon_; + wxWindow* pParent_; + wxString applicationName_; + wxString briefDescription_; + unsigned int yearOfInitialRelease_; + std::vector > usageHints_; + std::vector > keyboardShortcuts_; + std::vector > availableCommandLineOptions_; + bool boAddIconInfo_; + bool boAddExpatInfo_; + bool boAddFFmpegInfo_; + explicit AboutDialogInformation( const wxIcon& icon, wxWindow* pParent = 0 ) : icon_( icon ), pParent_( pParent ), applicationName_(), + briefDescription_(), yearOfInitialRelease_( 2005 ), usageHints_(), keyboardShortcuts_(), + availableCommandLineOptions_(), boAddIconInfo_( false ), boAddExpatInfo_( false ), boAddFFmpegInfo_( false ) {} +}; + +//----------------------------------------------------------------------------- +inline void DisplayCommandLineProcessingInformation( wxTextCtrl* pTextCtrl, const wxString& processedCommandLineParameters, const wxString& parserErrors, const wxTextAttr& style ) +//----------------------------------------------------------------------------- +{ + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + WriteToTextCtrl( pTextCtrl, wxT( "Press 'F1' for help.\n" ), style ); + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + const wxString none( wxT( "none" ) ); + WriteToTextCtrl( pTextCtrl, wxString::Format( wxT( "Processed command line parameters: %s\n" ), ( processedCommandLineParameters.length() > 0 ) ? processedCommandLineParameters.c_str() : none.c_str() ), style ); + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + if( !parserErrors.IsEmpty() ) + { + WriteToTextCtrl( pTextCtrl, parserErrors, wxTextAttr( *wxRED ) ); + WriteToTextCtrl( pTextCtrl, wxT( "\n" ) ); + } +} + +//----------------------------------------------------------------------------- +inline void DisplayCommonAboutDialog( const AboutDialogInformation& info ) +//----------------------------------------------------------------------------- +{ + wxBoxSizer* pTopDownSizer; + wxDialog dlg( info.pParent_, wxID_ANY, wxString( wxString::Format( wxT( "About %s" ), info.applicationName_.c_str() ) ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX ); + dlg.SetIcon( info.icon_ ); + pTopDownSizer = new wxBoxSizer( wxVERTICAL ); + wxStaticText* pText = new wxStaticText( &dlg, wxID_ANY, info.briefDescription_ ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + pText = new wxStaticText( &dlg, wxID_ANY, wxString::Format( wxT( "(C) %u - %s by %s" ), info.yearOfInitialRelease_, CURRENT_YEAR, COMPANY_NAME ) ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + pText = new wxStaticText( &dlg, wxID_ANY, wxString::Format( wxT( "Version %s" ), VERSION_STRING ) ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + AddSupportInfo( &dlg, pTopDownSizer ); + AddwxWidgetsInfo( &dlg, pTopDownSizer ); + if( info.boAddIconInfo_ ) + { + AddIconInfo( &dlg, pTopDownSizer ); + } + if( info.boAddExpatInfo_ ) + { + pText = new wxStaticText( &dlg, wxID_ANY, wxT( "The expat wrapper class used internally has been written by Descartes Systems Sciences, Inc." ) ); + pTopDownSizer->Add( pText, 0, wxALL | wxALIGN_CENTER, 5 ); + } + if( info.boAddFFmpegInfo_ ) + { + wxBoxSizer* pSizer = new wxBoxSizer( wxHORIZONTAL ); + pSizer->Add( new wxStaticText( &dlg, wxID_ANY, wxT( "The video recording functionality of this application was implemented using libraries from the " ) ) ); + pSizer->Add( new wxHyperlinkCtrl( &dlg, wxID_ANY, wxT( "FFmpeg" ), wxT( "https://www.ffmpeg.org/" ) ) ); + pSizer->Add( new wxStaticText( &dlg, wxID_ANY, wxT( " project under the LGPLv2.1. These must be installed separately" ) ) ); + pTopDownSizer->Add( pSizer, 0, wxALL | wxALIGN_CENTER, 5 ); + } + AddSourceInfo( &dlg, pTopDownSizer ); + wxNotebook* pNotebook = new wxNotebook( &dlg, wxID_ANY, wxDefaultPosition, wxDefaultSize ); + wxTextCtrl* pUsageHints = new wxTextCtrl( pNotebook, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxBORDER_NONE | wxTE_RICH | wxTE_READONLY ); + pNotebook->AddPage( pUsageHints, wxT( "Usage Hints" ), true ); + std::vector >::size_type usageHintStringCount = info.usageHints_.size(); + for( std::vector >::size_type i = 0; i < usageHintStringCount; i++ ) + { + WriteToTextCtrl( pUsageHints, info.usageHints_[i].first, info.usageHints_[i].second ); + } + pUsageHints->ScrollLines( -( 256 * 256 ) ); // make sure the text control always shows the beginning of the help text + if( !info.keyboardShortcuts_.empty() ) + { + AddListControlToAboutNotebook( pNotebook, wxT( "Keyboard Shortcuts" ), false, wxT( "Shortcut" ), wxT( "Command" ), info.keyboardShortcuts_ ); + } + if( !info.availableCommandLineOptions_.empty() ) + { + AddListControlToAboutNotebook( pNotebook, wxT( "Available Command Line Options" ), false, wxT( "Command" ), wxT( "Description" ), info.availableCommandLineOptions_ ); + } + pTopDownSizer->AddSpacer( 10 ); + pTopDownSizer->Add( pNotebook, wxSizerFlags( 5 ).Expand() ); + pTopDownSizer->AddSpacer( 10 ); + wxButton* pBtnOK = new wxButton( &dlg, wxID_OK, wxT( "OK" ) ); + pBtnOK->SetDefault(); + pTopDownSizer->Add( pBtnOK, 0, wxALL | wxALIGN_RIGHT, 15 ); + dlg.SetSizer( pTopDownSizer ); + dlg.SetSizeHints( 720, 500 ); + dlg.SetSize( -1, -1, 800, 500 ); + dlg.ShowModal(); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetCommonTextStyle( const bool boBold, const bool boUnderlined, wxTextCtrl* +#if wxCHECK_VERSION(2, 9, 5) +#else + pParent +#endif // #if wxCHECK_VERSION(2, 9, 5) + ) +//----------------------------------------------------------------------------- +{ + wxTextAttr theStyle; +#if wxCHECK_VERSION(2, 9, 5) + wxFontInfo fontInfo( 10 ); + if( boBold ) + { + fontInfo.Bold(); + } + if( boUnderlined ) + { + fontInfo.Underlined(); + } + wxFont theFont( fontInfo ); +#else + pParent->GetStyle( pParent->GetLastPosition(), theStyle ); + wxFont theFont( theStyle.GetFont() ); + if( boBold ) + { + theFont.SetWeight( wxFONTWEIGHT_BOLD ); + } + theFont.SetPointSize( 10 ); + if( boUnderlined ) + { + theFont.SetUnderlined( true ); + } +#endif // #if wxCHECK_VERSION(2, 9, 5) + theStyle.SetFont( theFont ); + return theStyle; +} + + +//----------------------------------------------------------------------------- +inline wxTextAttr GetBoldStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( true, false, pParent ); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetBoldUnderlinedStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( true, true, pParent ); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetDefaultStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( false, false, pParent ); +} + +//----------------------------------------------------------------------------- +inline wxTextAttr GetUnderlinedStyle( wxTextCtrl* pParent ) +//----------------------------------------------------------------------------- +{ + return GetCommonTextStyle( false, true, pParent ); +} + +//----------------------------------------------------------------------------- +inline bool IsListOfChoicesEmpty( wxComboBox* pCB ) +//----------------------------------------------------------------------------- +{ +#if wxCHECK_VERSION(2, 9, 3) + return pCB->IsListEmpty(); +#else + return pCB->IsEmpty(); +#endif // #if wxCHECK_VERSION(2, 9, 3) +} + +//----------------------------------------------------------------------------- +inline void StopTimer( wxTimer& timer ) +//----------------------------------------------------------------------------- +{ + if( timer.IsRunning() ) + { + timer.Stop(); + } +} + +//============================================================================= +//===================== Implementation Version helper functions =============== +//============================================================================= +//----------------------------------------------------------------------------- +struct Version +//----------------------------------------------------------------------------- +{ + long major_; + long minor_; + long subMinor_; + long release_; + explicit Version() : major_( -1 ), minor_( -1 ), subMinor_( -1 ), release_( 0 ) {} + explicit Version( long ma, long mi, long smi, long re ) : major_( ma ), minor_( mi ), subMinor_( smi ), release_( re ) {} +}; + +//----------------------------------------------------------------------------- +inline bool operator<( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + if( a.major_ < b.major_ ) + { + return true; + } + else if( a.major_ == b.major_ ) + { + if( a.minor_ < b.minor_ ) + { + return true; + } + else if( a.minor_ == b.minor_ ) + { + if( a.subMinor_ < b.subMinor_ ) + { + return true; + } + else if( a.subMinor_ == b.subMinor_ ) + { + if( a.release_ < b.release_ ) + { + return true; + } + } + } + } + return false; +} + +//----------------------------------------------------------------------------- +inline bool operator==( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( ( a.major_ == b.major_ ) && ( a.minor_ == b.minor_ ) && ( a.subMinor_ == b.subMinor_ ) && ( a.release_ == b.release_ ) ); +} + +//----------------------------------------------------------------------------- +inline bool operator!=( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( ( a.major_ != b.major_ ) || ( a.minor_ != b.minor_ ) || ( a.subMinor_ != b.subMinor_ ) || ( a.release_ != b.release_ ) ); +} + +//----------------------------------------------------------------------------- +inline bool operator>( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( !( a < b ) && !( a == b ) ); +} + +//----------------------------------------------------------------------------- +inline bool operator>=( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( a > b ) || ( a == b ); +} + +//----------------------------------------------------------------------------- +inline bool operator<=( const Version& a, const Version& b ) +//----------------------------------------------------------------------------- +{ + return ( a < b ) || ( a == b ); +} + +//----------------------------------------------------------------------------- +inline bool GetNextVersionNumber( wxString& str, long& number ) +//----------------------------------------------------------------------------- +{ + wxString numberString = str.BeforeFirst( wxT( '.' ) ); + str = str.AfterFirst( wxT( '.' ) ); + return numberString.ToLong( &number ); +} + +//----------------------------------------------------------------------------- +inline Version VersionFromString( const wxString& versionAsString ) +//----------------------------------------------------------------------------- +{ + Version version; + wxString tmp( versionAsString ); + GetNextVersionNumber( tmp, version.major_ ); + if( !tmp.empty() ) + { + GetNextVersionNumber( tmp, version.minor_ ); + if( !tmp.empty() ) + { + GetNextVersionNumber( tmp, version.subMinor_ ); + if( !tmp.empty() ) + { + GetNextVersionNumber( tmp, version.release_ ); + } + } + } + return version; +} + +//----------------------------------------------------------------------------- +inline bool IsVersionWithinRange( const Version& version, const Version& minVersion, const Version& maxVersion ) +//----------------------------------------------------------------------------- +{ + return ( version >= minVersion ) && ( version <= maxVersion ); +} + +//============================================================================= +//============= Implementation IP Address conversion functions ================ +//============================================================================= +//----------------------------------------------------------------------------- +inline std::string GetIPv4AddressAsString( unsigned int ip ) +//----------------------------------------------------------------------------- +{ + std::ostringstream output; + output << ( ( ip >> 24 ) & 0xFF ) << "." << ( ( ip >> 16 ) & 0xFF ) << "." << ( ( ip >> 8 ) & 0xFF ) << "." << ( ip & 0xFF ); + return output.str(); +} + +#endif // wxAbstractionH diff --git a/Cigarette/MvIMPACT/apps/Common/wxIncludeEpilogue.h b/Cigarette/MvIMPACT/apps/Common/wxIncludeEpilogue.h new file mode 100644 index 0000000..a0c3f53 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/wxIncludeEpilogue.h @@ -0,0 +1,5 @@ +#if defined(__clang__) +# pragma clang diagnostic pop +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( pop ) +#endif diff --git a/Cigarette/MvIMPACT/apps/Common/wxIncludePrologue.h b/Cigarette/MvIMPACT/apps/Common/wxIncludePrologue.h new file mode 100644 index 0000000..082eff5 --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/wxIncludePrologue.h @@ -0,0 +1,10 @@ +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# pragma clang diagnostic ignored "-Wunused-local-typedef" +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? +# pragma warning( push ) +# pragma warning( disable : 4127 ) // 'conditional expression is constant' +# pragma warning( disable : 4512 ) // 'class XYZ': assignment operator could not be generated' +# pragma warning( disable : 4996 ) // ''function XYZ': was declared deprecated' +#endif diff --git a/Cigarette/MvIMPACT/apps/Common/wxIncluder.h b/Cigarette/MvIMPACT/apps/Common/wxIncluder.h new file mode 100644 index 0000000..7ebe90d --- /dev/null +++ b/Cigarette/MvIMPACT/apps/Common/wxIncluder.h @@ -0,0 +1,9 @@ +//----------------------------------------------------------------------------- +#ifndef wxIncluderH +#define wxIncluderH wxIncluderH +//----------------------------------------------------------------------------- +#include +#include "wx/wx.h" +#include + +#endif // wxIncluderH diff --git a/Cigarette/MvIMPACT/common/STLHelper.h b/Cigarette/MvIMPACT/common/STLHelper.h new file mode 100644 index 0000000..07514f8 --- /dev/null +++ b/Cigarette/MvIMPACT/common/STLHelper.h @@ -0,0 +1,360 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 STLHelperH +#define STLHelperH STLHelperH +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//============================================================================= +//==================== std::pair related stuff ================================ +//============================================================================= +//----------------------------------------------------------------------------- +template +const _Ty1& GetFirst( const std::pair<_Ty1, _Ty2>& data ) +//----------------------------------------------------------------------------- +{ + return data.first; +} + +//----------------------------------------------------------------------------- +template +const _Ty2& GetSecond( const std::pair<_Ty1, _Ty2>& data ) +//----------------------------------------------------------------------------- +{ + return data.second; +} + +//----------------------------------------------------------------------------- +template +void DeleteFirst( std::pair<_Ty1, _Ty2>& data ) +//----------------------------------------------------------------------------- +{ + delete data.first; + data.first = 0; +} + +//----------------------------------------------------------------------------- +template +void DeleteSecond( std::pair<_Ty1, _Ty2>& data ) +//----------------------------------------------------------------------------- +{ + delete data.second; + data.second = 0; +} + +//----------------------------------------------------------------------------- +template +class ContainsFirst : public std::unary_function, bool> +//----------------------------------------------------------------------------- +{ + std::map<_Ty1, _Ty2> m_; +public: + explicit ContainsFirst( const std::map<_Ty1, _Ty2>& m ) : m_( m ) {} + bool operator()( const std::pair<_Ty1, _Ty2>& x ) + { + return m_.find( x.first ) != m_.end(); + } +}; + +//----------------------------------------------------------------------------- +template +class FirstMatches : public std::unary_function, bool> +//----------------------------------------------------------------------------- +{ + std::pair<_Ty1, _Ty2> value_; + FirstMatches<_Ty1, _Ty2>& operator=( const FirstMatches<_Ty1, _Ty2>& ); // do not allow assignments +public: + explicit FirstMatches( const std::pair<_Ty1, _Ty2>& val ) : value_( val ) {} + bool operator()( const std::pair<_Ty1, _Ty2>& x ) + { + return x.first == value_.first; + } +}; + +//----------------------------------------------------------------------------- +template +class SecondMatches : public std::unary_function, bool> +//----------------------------------------------------------------------------- +{ + std::pair<_Ty1, _Ty2> value_; + SecondMatches<_Ty1, _Ty2>& operator=( const SecondMatches<_Ty1, _Ty2>& ); // do not allow assignments +public: + explicit SecondMatches( const std::pair<_Ty1, _Ty2>& val ) : value_( val ) {} + bool operator()( const std::pair<_Ty1, _Ty2>& x ) + { + return x.second == value_.second; + } +}; + +//----------------------------------------------------------------------------- +template +bool SecondSmaller( const std::pair<_Ty1, _Ty2>& a, const std::pair<_Ty1, _Ty2>& b ) +//----------------------------------------------------------------------------- +{ + if( a.second < b.second ) + { + return true; + } + + if( a.second > b.second ) + { + return false; + } + + return ( a.first < b.first ); +} + +//============================================================================= +//==================== various ================================================ +//============================================================================= +//----------------------------------------------------------------------------- +template +void DeleteElement( _Ty& data ) +//----------------------------------------------------------------------------- +{ + delete data; + data = 0; +} + +//----------------------------------------------------------------------------- +template +void DeleteArrayElement( _Ty& data ) +//----------------------------------------------------------------------------- +{ + delete [] data; + data = 0; +} + +//----------------------------------------------------------------------------- +/// \brief Proxy reference for ObjectDeleter copying. +template +struct ObjectDeleterReference +//----------------------------------------------------------------------------- +{ + // construct from generic pointer to ObjectDeleter pointer + explicit ObjectDeleterReference( _Ty* rhs ) : pReference_( rhs ) {} + + _Ty* pReference_; // generic pointer to ObjectDeleter pointer +}; + +//----------------------------------------------------------------------------- +/// \brief Simple wrapper class to make sure an object is deleted at the end of the scope +/** + * This of course could also be done using std::auto_ptr but as this template has been + * declared deprecated it causes new compilers to spit out warnings/failures. + * + * The nice way of doing this would be by the use of std::unique_ptr these days but then + * the client code would force people to have a C++11 or greater compliant compiler... + */ +template +class ObjectDeleter +//----------------------------------------------------------------------------- +{ + _Ty* pObject_; +public: + explicit ObjectDeleter( _Ty* pObject = 0 ) : pObject_( pObject ) {} + /// \brief Pass ownership to the new object. + ObjectDeleter( ObjectDeleter<_Ty>& rhs ) : pObject_( rhs.release() ) {} + ~ObjectDeleter() + { + DeleteElement( pObject_ ); + } + /// \brief Pass ownership. Old buffer on the left hand side object is + /// freed, the lhs object takes ownership of the pointer of the rhs object. + ObjectDeleter<_Ty>& operator=( ObjectDeleter<_Ty>& rhs ) + { + if( this != &rhs ) + { + DeleteElement( pObject_ ); + pObject_ = rhs.release(); + } + return *this; + } + template + operator ObjectDeleterReference<_Other>() + { + // convert to compatible ObjectDeleterReference + _Other* p = pObject_; // test implicit conversion + ObjectDeleterReference<_Other> reference( p ); + pObject_ = 0; // pass ownership to ObjectDeleterReference + return ( reference ); + } + ObjectDeleter<_Ty>& operator=( ObjectDeleterReference<_Ty> rhs ) + { + // assign compatible rhs.pReference_ (assume pointer) + _Ty* p = rhs.pReference_; + rhs.pReference_ = 0; + reset( p ); + return ( *this ); + } + operator _Ty* () + { + return pObject_; + } + _Ty* operator->() + { + return pObject_; + } + _Ty* get( void ) + { + return pObject_; + } + const _Ty* get( void ) const + { + return pObject_; + } + _Ty* release( void ) + { + _Ty* p = pObject_; + pObject_ = 0; + return p; + } + void reset( _Ty* pObject = 0 ) + { + if( pObject_ != pObject ) + { + DeleteElement( pObject_ ); + pObject_ = pObject; + } + } +}; + +//----------------------------------------------------------------------------- +/// This could in theory be accomplished with a call to the for_each template: +/// +/// for_each( s.begin(), s.end(), ptr_fun(DeleteElement<_Ty*>) ); +/// +/// But some ports of the STL always return const_iterators for sets (e.g. gcc 4.1.2) +template +void ClearSetWithHeapAllocatedKeys( std::set<_Ty>& s ) +//----------------------------------------------------------------------------- +{ + typename std::set<_Ty>::iterator it = s.begin(); + typename std::set<_Ty>::iterator itEnd = s.end(); + while( it != itEnd ) + { + delete *it; + ++it; + } + s.clear(); +} + +//----------------------------------------------------------------------------- +/// \brief Assigns a new value to a variable when this objects goes out of scope. +/// +/// Can be useful if a variable must be set to a defined value at the end of a +/// code block that might rise an exception. +template +class VarScopeMod +//----------------------------------------------------------------------------- +{ + T& var_; + T valAtEndOfScope_; + VarScopeMod( const VarScopeMod& ); // do not allow copy constructor + VarScopeMod& operator=( const VarScopeMod& ); // do not allow assignments +public: + explicit VarScopeMod( T& var, T valAtEndOfScope ) : var_( var ), valAtEndOfScope_( valAtEndOfScope ) {} + explicit VarScopeMod( T& var, T valWithinScope, T valAtEndOfScope ) : var_( var ), valAtEndOfScope_( valAtEndOfScope ) + { + var = valWithinScope; + } + ~VarScopeMod() + { + var_ = valAtEndOfScope_; + } +}; + +//----------------------------------------------------------------------------- +template +void removeDuplicates( T& container ) +//----------------------------------------------------------------------------- +{ + std::sort( container.begin(), container.end() ); + typename T::iterator it = std::unique( container.begin(), container.end() ); + container.erase( it, container.end() ); +} + +//----------------------------------------------------------------------------- +template +_Elem mv_tolower( _Elem c ) +//----------------------------------------------------------------------------- +{ + return static_cast<_Elem>( tolower( c ) ); +} + +//----------------------------------------------------------------------------- +template +void makeLowerCase( + /// The string to convert + std::basic_string<_Elem, _Traits, _Ax>& s ) +//----------------------------------------------------------------------------- +{ + std::transform( s.begin(), s.end(), s.begin(), std::ptr_fun<_Elem, _Elem>( mv_tolower ) ); +} + +//----------------------------------------------------------------------------- +template +std::basic_string<_Elem, _Traits, _Ax> makeLowerCase( + /// The string to convert + const std::basic_string<_Elem, _Traits, _Ax>& s ) +//----------------------------------------------------------------------------- +{ + std::basic_string<_Elem, _Traits, _Ax> lc( s ); + std::transform( lc.begin(), lc.end(), lc.begin(), std::ptr_fun<_Elem, _Elem>( mv_tolower ) ); + return lc; +} + +//----------------------------------------------------------------------------- +template +_Elem mv_toupper( _Elem c ) +//----------------------------------------------------------------------------- +{ + return static_cast<_Elem>( toupper( c ) ); +} + +//----------------------------------------------------------------------------- +template +void makeUpperCase( + /// The string to convert + std::basic_string<_Elem, _Traits, _Ax>& s ) +//----------------------------------------------------------------------------- +{ + std::transform( s.begin(), s.end(), s.begin(), std::ptr_fun<_Elem, _Elem>( mv_toupper ) ); +} + +//----------------------------------------------------------------------------- +template +std::basic_string<_Elem, _Traits, _Ax> makeUpperCase( + /// The string to convert + const std::basic_string<_Elem, _Traits, _Ax>& s ) +//----------------------------------------------------------------------------- +{ + std::basic_string<_Elem, _Traits, _Ax> uc( s ); + std::transform( uc.begin(), uc.end(), uc.begin(), std::ptr_fun<_Elem, _Elem>( mv_toupper ) ); + return uc; +} + +#endif // STLHelperH diff --git a/Cigarette/MvIMPACT/common/System/win32/common.rc2 b/Cigarette/MvIMPACT/common/System/win32/common.rc2 new file mode 100644 index 0000000..fd9c0a3 --- /dev/null +++ b/Cigarette/MvIMPACT/common/System/win32/common.rc2 @@ -0,0 +1,105 @@ +// This file will be included from the resource files of the individual libraries belonging to +// the current release version of the mvIMPACT Acquire driver packages + + +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 2,43,0,3180 + PRODUCTVERSION 2,43,0,3180 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "CompanyName", "MATRIX VISION GmbH" + VALUE "FileDescription", FILE_DESCRIPTION + VALUE "FileVersion", "2, 43, 0, 3180" + VALUE "InternalName", INTERNAL_NAME + VALUE "LegalCopyright", " 2005 - 2021 MATRIX VISION GmbH, Germany" + VALUE "OriginalFilename", ORIGINAL_FILENAME + VALUE "ProductName", PRODUCT_NAME + VALUE "ProductVersion", "2, 43, 0, 3180" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Cigarette/MvIMPACT/common/auto_array_ptr.h b/Cigarette/MvIMPACT/common/auto_array_ptr.h new file mode 100644 index 0000000..eefa2c1 --- /dev/null +++ b/Cigarette/MvIMPACT/common/auto_array_ptr.h @@ -0,0 +1,116 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 auto_array_ptrH +#define auto_array_ptrH auto_array_ptrH +//----------------------------------------------------------------------------- +#include +#include +//----------------------------------------------------------------------------- +/// \brief A automatically managed buffer type to handle subscriptable data. +template +class auto_array_ptr +//----------------------------------------------------------------------------- +{ + size_t m_cnt; + T* m_pBuf; +public: + auto_array_ptr( size_t initialSize = 0 ) : m_cnt( initialSize ), m_pBuf( 0 ) + { + if( initialSize > 0 ) + { + m_pBuf = new T[initialSize]; + } + } + /// \brief Pass ownership to the new object. + auto_array_ptr( auto_array_ptr& rhs ) : m_cnt( rhs.m_cnt ), m_pBuf( rhs.release() ) {} + /// \brief Pass ownership to the new object. + /// + /// Do NOT delete the original T*. This is done by this class now. + auto_array_ptr( T* pBuf, size_t cnt ) : m_cnt( cnt ), m_pBuf( pBuf ) {} + ~auto_array_ptr() + { + delete [] m_pBuf; + } + // functions + operator T* () + { + return m_pBuf; + } + /// \brief Pass ownership. Old buffer on the left hand side object is + /// freed, the lhs object takes ownership of the buffer of the rhs object. + auto_array_ptr& operator=( auto_array_ptr& rhs ) + { + if( this != &rhs ) + { + delete [] m_pBuf; + m_cnt = rhs.m_cnt; + m_pBuf = rhs.release(); + } + return *this; + } + /// \brief If the new size differs from the current one free old buffer, allocate new buffer. + void realloc( size_t newSize ) + { + if( newSize != m_cnt ) + { + delete [] m_pBuf; + m_pBuf = ( newSize > 0 ) ? new T[newSize] : 0; + m_cnt = newSize; + } + } + /// \brief Increases the buffer size if necessary and keeps the old data. + void grow( size_t newSize ) + { + if( newSize > m_cnt ) + { + T* p = new T[newSize]; + if( m_pBuf && ( m_cnt > 0 ) ) + { + memcpy( p, m_pBuf, m_cnt ); + delete [] m_pBuf; + } + m_pBuf = p; + m_cnt = newSize; + } + } + /// \brief Release ownership, return pointer to buffer. + T* release( void ) + { + T* p = m_pBuf; + m_pBuf = 0; + m_cnt = 0; + return p; + } + /// \brief Return pointer to buffer. + T* get( void ) + { + return m_pBuf; + } + /// \brief Return const pointer to buffer. + const T* get( void ) const + { + return m_pBuf; + } + /// \brief Return element count. + size_t parCnt( void ) const + { + return m_cnt; + } +}; + +#endif // auto_array_ptr diff --git a/Cigarette/MvIMPACT/common/crt/mvstdio.h b/Cigarette/MvIMPACT/common/crt/mvstdio.h new file mode 100644 index 0000000..97ba574 --- /dev/null +++ b/Cigarette/MvIMPACT/common/crt/mvstdio.h @@ -0,0 +1,63 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvstdioH +#define mvstdioH mvstdioH +//----------------------------------------------------------------------------- +#include +#include +#if defined(_MSC_VER) +# include +#endif + +//----------------------------------------------------------------------------- +/// \brief Version that mimics the C11 \c fopen_s function. +/** + * See \c fopen_s of your runtime implementation for documentation! + */ +inline int mv_fopen_s( FILE** ppFile, const char* pName, const char* pMode ) +//----------------------------------------------------------------------------- +{ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) // is at least VC 2005 compiler? + // The M$ version of fopen_s does not support sharing thus parallel access to the same file... + // As this is needed by mvIMPACT Acquire e.g. when writing log files from multiple processes into + // a common file we have to use the '_fsopen' function with '_SH_DENYNO' here to get + // what we want, which is parallel access AND no compiler warnings + *ppFile = _fsopen( pName, pMode, _SH_DENYNO ); + return errno; +#elif defined (__STDC_LIB_EXT1__) + return fopen_s( ppFile, pName, pMode ); +#else + *ppFile = fopen( pName, pMode ); + return errno; +#endif // #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) || defined (__STDC_LIB_EXT1__) // is at least VC 2005 compiler OR implementation supports CRT extensions? +} + +//----------------------------------------------------------------------------- +/// \brief Version that mimics the traditional \c fopen function. +/** + * See \c fopen of your runtime implementation for documentation! + */ +inline FILE* mv_fopen_s( const char* pName, const char* pMode ) +//----------------------------------------------------------------------------- +{ + FILE* pFile = 0; + mv_fopen_s( &pFile, pName, pMode ); + return pFile; +} + +#endif // mvstdioH diff --git a/Cigarette/MvIMPACT/common/crt/mvstring.h b/Cigarette/MvIMPACT/common/crt/mvstring.h new file mode 100644 index 0000000..a6d324a --- /dev/null +++ b/Cigarette/MvIMPACT/common/crt/mvstring.h @@ -0,0 +1,105 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvstringH +#define mvstringH mvstringH +//----------------------------------------------------------------------------- +#include +#include +#include + +//----------------------------------------------------------------------------- +/// \brief Version that mimics the C11 \c strncpy_s function. +/** + * See \c strncpy_s of your runtime implementation for documentation! + */ +inline int mv_strncpy_s( char* pDst, const char* pSrc, size_t bufSize ) +//----------------------------------------------------------------------------- +{ +#if (defined(_MSC_VER) && (_MSC_VER >= 1400)) // is at least VC 2005 compiler? + // '_TRUNCATE' is a Microsoft extension! + return strncpy_s( pDst, bufSize, pSrc, _TRUNCATE ); +#elif defined (__STDC_LIB_EXT1__) // does implementation support CRT extensions? + return strncpy_s( pDst, bufSize, pSrc, bufSize ); +#else + strncpy( pDst, pSrc, bufSize ); + return errno; +#endif // #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) // is at least VC 2005 compiler? +} + +//----------------------------------------------------------------------------- +/// \brief Version that mimics the C11 \c strncat_s function. +/** + * See \c strncat_s of your runtime implementation for documentation! + */ +inline int mv_strncat_s( char* pDst, const char* pSrc, size_t bufSize ) +//----------------------------------------------------------------------------- +{ +#if (defined(_MSC_VER) && (_MSC_VER >= 1400)) // is at least VC 2005 compiler? + // '_TRUNCATE' is a Microsoft extension! + return strncat_s( pDst, bufSize, pSrc, _TRUNCATE ); +#elif defined (__STDC_LIB_EXT1__) // does implementation support CRT extensions? + return strncat_s( pDst, bufSize, pSrc, bufSize - strnlen_s( pDst, bufSize ) ); +#else + strncat( pDst, pSrc, bufSize ); + return errno; +#endif // #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) // is at least VC 2005 compiler? +} + +//----------------------------------------------------------------------------- +/// \brief Version that mimics the C11 \c strerror_s function. +/** + * See \c strerror_s of your runtime implementation for documentation! + */ +inline int mv_strerror_s( char* pBuf, size_t bufSize, int errnum ) +//----------------------------------------------------------------------------- +{ +#if (defined(_MSC_VER) && (_MSC_VER >= 1400)) || defined (__STDC_LIB_EXT1__) // is at least VC 2005 compiler OR implementation supports CRT extensions? + return strerror_s( pBuf, bufSize, errnum ); +#else + // Should check the following constraints here: + // - pBuf is a null pointer + // - bufSize is zero or greater than RSIZE_MAX + strncpy( pBuf, strerror( errnum ), bufSize ); + return errno; +#endif // #if (defined(_MSC_VER) && (_MSC_VER >= 1400)) || defined (__STDC_LIB_EXT1__) // is at least VC 2005 compiler OR implementation supports CRT extensions? +} + +//----------------------------------------------------------------------------- +inline size_t mv_strerrorlen_s( int errnum ) +//----------------------------------------------------------------------------- +{ +#ifdef __STDC_LIB_EXT1__ // does implementation supports CRT extensions? + return strerrorlen_s( errnum ); +#else +# if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wdeprecated-declarations" +# elif defined(_MSC_VER) && (_MSC_VER >= 1800) // is at least VC 2013 compiler? +# pragma warning( push ) +# pragma warning( disable : 4996 ) // 'warning C4996: 'GetVersionExA': was declared deprecated' +# endif + return strlen( strerror( errnum ) ); +# if defined(__clang__) +# pragma clang diagnostic pop +# elif defined(_MSC_VER) && (_MSC_VER >= 1800) // is at least VC 2013 compiler? +# pragma warning( pop ) // restore old warning level +# endif +#endif // #ifdef __STDC_LIB_EXT1__ // does implementation supports CRT extensions? +} + +#endif // mvstringH diff --git a/Cigarette/MvIMPACT/common/function_cast.h b/Cigarette/MvIMPACT/common/function_cast.h new file mode 100644 index 0000000..0539219 --- /dev/null +++ b/Cigarette/MvIMPACT/common/function_cast.h @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 function_castH +#define function_castH function_castH +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +/// \brief Allows casting void* to a function pointer without gcc complaining. +/// +/// When e.g. compiling code with the \a -pedantic option, gcc will complain about the following +/// piece of code +/// +/// \code +/// void fn( void ) +/// { +/// void* hMod = dlopen( "mylib", RTLD_LAZY ); +/// if( hMod ) +/// { +/// typedef void (*myFnPtr)( void ); +/// myFnPtr p = (myFnPtr)dlsym( hMod, "foobar" ); // this will give a warning +/// } +/// } +/// \endcode +/// +/// The compiler will give you the following warning: +/// +/// \verbatim +/// ISO C++ forbids casting between pointer-to-function and pointer-to-object +/// \endverbatim +/// +/// That is true, but there is not other way to extract symbols from shared libraries. +/// By using this template instead, gcc will be happy and will you. +/// +/// \code +/// void fn( void ) +/// { +/// void* hMod = dlopen( "mylib", RTLD_LAZY ); +/// if( hMod ) +/// { +/// typedef void (*myFnPtr)( void ); +/// function_cast pFunc; +/// pFunc.pI = dlsym( hMod, "foobar" ); +/// myFnPtr p = pFunc.pO; +/// } +/// } +/// \endcode +template +union function_cast +//----------------------------------------------------------------------------- +{ + void* pI; + OutputPtr pO; +}; + +#endif // function_castH diff --git a/Cigarette/MvIMPACT/common/minmax.h b/Cigarette/MvIMPACT/common/minmax.h new file mode 100644 index 0000000..200f676 --- /dev/null +++ b/Cigarette/MvIMPACT/common/minmax.h @@ -0,0 +1,154 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 minmaxH +#define minmaxH minmaxH +//----------------------------------------------------------------------------- +#include +#include +#include + +#undef min // otherwise we can't work with the 'numeric_limits' template here as Windows defines a macro 'min' +#undef max // otherwise we can't work with the 'numeric_limits' template here as Windows defines a macro 'max' + +//----------------------------------------------------------------------------- +template +_Ty bitMask( _Ty bitCount ) +//----------------------------------------------------------------------------- +{ + if( bitCount >= static_cast<_Ty>( sizeof( _Ty ) * 8 ) ) + { + return _Ty( -1 ); + } + return ( _Ty( 1 ) << bitCount ) - _Ty( 1 ); +} + +//----------------------------------------------------------------------------- +template +_Ty bitMask_s( _Ty bitCount ) +//----------------------------------------------------------------------------- +{ + if( bitCount > static_cast<_Ty>( sizeof( _Ty ) * 8 ) ) + { + throw std::invalid_argument( "Requested bit mask cannot be stored by target type" ); + } + return bitMask( bitCount ); +} + +//--------------------------------------------------------------------------- +template +bool isPowerOfTwo( _Ty val ) +//--------------------------------------------------------------------------- +{ + return ( ( val > 0 ) && ( ( val & ( val - 1 ) ) == 0 ) ); +} + +//----------------------------------------------------------------------------- +template +_Ty align( _Ty val, _Ty alignment ) +//----------------------------------------------------------------------------- +{ + if( ( alignment <= 0 ) || ( !isPowerOfTwo( alignment ) ) ) + { + throw std::invalid_argument( "align: Invalid alignment" ); + } + return static_cast<_Ty>( ( val + alignment - 1 ) & ( bitMask( static_cast<_Ty>( sizeof( val ) * 8 ) ) - ( alignment - 1 ) ) ); +} + +//----------------------------------------------------------------------------- +template +bool isAligned( _Ty val, _Ty alignment ) +//----------------------------------------------------------------------------- +{ + if( ( alignment <= 0 ) || ( !isPowerOfTwo( alignment ) ) ) + { + throw std::invalid_argument( "isAligned: Invalid alignment" ); + } + return ( ( ( alignment - 1 ) & val ) == 0 ); +} + +//----------------------------------------------------------------------------- +template +inline _Result getBit( _Ty shift ) +//----------------------------------------------------------------------------- +{ + if( static_cast<_Result>( shift ) > static_cast<_Result>( ( sizeof( _Result ) * 8 ) ) ) + { + throw std::invalid_argument( "shift value too large for this data type" ); + } + return static_cast<_Result>( _Result( 1 ) << _Result( shift ) ); +} + +//----------------------------------------------------------------------------- +template +bool isInRange( const _Ty& lowerLimit, const _Ty& upperLimit, const _Ty& start, const _Ty& end, _Ty* pOverlappingRangeStart = 0, _Ty* pOverlappingRangeEnd = 0 ) +//----------------------------------------------------------------------------- +{ + if( end < lowerLimit ) + { + return false; + } + + if( start > upperLimit ) + { + return false; + } + + if( pOverlappingRangeStart ) + { + *pOverlappingRangeStart = ( start > lowerLimit ) ? start : lowerLimit; + } + + if( pOverlappingRangeEnd ) + { + *pOverlappingRangeEnd = ( end > upperLimit ) ? upperLimit : end; + } + + return true; +} + +//----------------------------------------------------------------------------- +template +#if (defined(_WIN32) || defined(WIN32) || defined(__WIN32__)) && (defined(_WIN64) || defined(WIN64) || defined(__WIN64__)) +inline const T& saveAssign( const __unaligned T& val, const __unaligned T& min, const __unaligned T& max ) +#else +inline const T& saveAssign( const T& val, const T& min, const T& max ) +#endif +//----------------------------------------------------------------------------- +{ + return ( ( val > max ) ? max : ( val < min ) ? min : val ); +} + +//----------------------------------------------------------------------------- +template +_Result getClippedValue( _Ty val ) +//----------------------------------------------------------------------------- +{ + if( val > static_cast<_Ty>( std::numeric_limits<_Result>::max() ) ) + { + return std::numeric_limits<_Result>::max(); + } + + if( val < static_cast<_Ty>( std::numeric_limits<_Result>::min() ) ) + { + return std::numeric_limits<_Result>::min(); + } + + return static_cast<_Result>( val ); +} + +#endif // minmaxH diff --git a/Cigarette/MvIMPACT/lib/win32/mvDeviceManager.lib b/Cigarette/MvIMPACT/lib/win32/mvDeviceManager.lib new file mode 100644 index 0000000..68150e2 Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win32/mvDeviceManager.lib differ diff --git a/Cigarette/MvIMPACT/lib/win32/mvDeviceManagerb.lib b/Cigarette/MvIMPACT/lib/win32/mvDeviceManagerb.lib new file mode 100644 index 0000000..6ac3a5b Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win32/mvDeviceManagerb.lib differ diff --git a/Cigarette/MvIMPACT/lib/win32/mvDisplay.lib b/Cigarette/MvIMPACT/lib/win32/mvDisplay.lib new file mode 100644 index 0000000..59eda9c Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win32/mvDisplay.lib differ diff --git a/Cigarette/MvIMPACT/lib/win32/mvDisplayb.lib b/Cigarette/MvIMPACT/lib/win32/mvDisplayb.lib new file mode 100644 index 0000000..4ef6335 Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win32/mvDisplayb.lib differ diff --git a/Cigarette/MvIMPACT/lib/win64/mvDeviceManager.lib b/Cigarette/MvIMPACT/lib/win64/mvDeviceManager.lib new file mode 100644 index 0000000..23915be Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win64/mvDeviceManager.lib differ diff --git a/Cigarette/MvIMPACT/lib/win64/mvDeviceManagerb.lib b/Cigarette/MvIMPACT/lib/win64/mvDeviceManagerb.lib new file mode 100644 index 0000000..1725d11 Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win64/mvDeviceManagerb.lib differ diff --git a/Cigarette/MvIMPACT/lib/win64/mvDisplay.lib b/Cigarette/MvIMPACT/lib/win64/mvDisplay.lib new file mode 100644 index 0000000..32f97ff Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win64/mvDisplay.lib differ diff --git a/Cigarette/MvIMPACT/lib/win64/mvDisplayb.lib b/Cigarette/MvIMPACT/lib/win64/mvDisplayb.lib new file mode 100644 index 0000000..ab263bd Binary files /dev/null and b/Cigarette/MvIMPACT/lib/win64/mvDisplayb.lib differ diff --git a/Cigarette/MvIMPACT/mvDeviceManager/Include/mvDeviceManager.h b/Cigarette/MvIMPACT/mvDeviceManager/Include/mvDeviceManager.h new file mode 100644 index 0000000..8980c64 --- /dev/null +++ b/Cigarette/MvIMPACT/mvDeviceManager/Include/mvDeviceManager.h @@ -0,0 +1,1031 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvDeviceManagerH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvDeviceManagerH mvDeviceManagerH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#ifndef WRAP_ANY +# include +#endif // #ifndef WRAP_ANY + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif // #ifdef __cplusplus + +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef DOXYGEN_SHOULD_SKIP_THIS +# define __vl_base_h__ // force doxygen to include mvIMPACT related functions +#else +# ifdef _WIN32 +# define DMR_CALL __stdcall +# ifndef WRAP_ANY +# define MVDMR_API +# if defined(__BORLANDC__) // is Borland compiler? +# pragma option push -b // force enums to size of integer +# endif // #if defined(__BORLANDC__) +# ifndef NO_MV_DEVICE_MANAGER_AUTOLINK +# if defined(__BORLANDC__) // is Borland compiler? +# if __CODEGEARC__ >= 0X710 +# pragma comment(lib,"mvDeviceManagerb") +# else +# pragma comment(lib,"mvDeviceManagerb.lib") +# endif // #if __CODEGEARC__ >= 0X710 +# pragma message( "Automatically linking with mvDeviceManagerb.lib" ) +# elif defined(_MSC_VER) // is Microsoft compiler? +# pragma comment(lib,"mvDeviceManager.lib") +# pragma message( "Automatically linking with mvDeviceManager.lib" ) +# endif // #if defined(__BORLANDC__) +# endif // #ifndef NO_MV_DEVICE_MANAGER_AUTOLINK +# endif // #ifndef WRAP_ANY +# else // #ifdef _WIN32 +# ifndef WRAP_ANY +# if __GNUC__ >= 4 +# define MVDMR_API __attribute__ ((visibility ("default"))) +# else +# define MVDMR_API +# endif // #if __GNUC__ >= 4 +# endif // ifndef WRAP_ANY +# define DMR_CALL +# endif // #ifdef _WIN32 +#endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + +#ifdef __GNUC__ +# define ATTR_PACK __attribute__((packed)) __attribute__ ((aligned (8))) +#else +#define ATTR_PACK +# pragma pack(push, 8) // 8 byte structure alignment +#endif // #ifdef __GNUC__ + +#if !defined(MVIMPACT_DEPRECATED_C) && !defined(DOXYGEN_SHOULD_SKIP_THIS) +# if !defined(MVIMPACT_ACQUIRE_H_) && !defined(NO_MVIMPACT_DEPRECATED_C_WARNINGS) +# if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__ ) >= 301) // is at least GCC 3.1 compiler? +# define MVIMPACT_DEPRECATED_C(FUNCTION) FUNCTION __attribute__ ((deprecated)) +# elif defined(_MSC_VER) && (_MSC_VER >= 1310) // is at least VC 2003 compiler? +# define MVIMPACT_DEPRECATED_C(FUNCTION) __declspec(deprecated) FUNCTION +# else +# define MVIMPACT_DEPRECATED_C(FUNCTION) FUNCTION +# endif // compiler check +# else +# define MVIMPACT_DEPRECATED_C(FUNCTION) FUNCTION +# endif // #if !defined(MVIMPACT_ACQUIRE_H_) && !defined(NO_MVIMPACT_DEPRECATED_C_WARNINGS) +#endif // #if !defined(MVIMPACT_DEPRECATED_C) && !defined(DOXYGEN_SHOULD_SKIP_THIS) + +//----------------------------------------------------------------------------- +/// \brief A structure for image buffer channel specific data +/** + * Channel specific data in an image is data, that in e.g. and RGB image + * might differ for the color components red, green and blue. + * + * \ingroup CommonInterface + */ +struct ChannelData +//----------------------------------------------------------------------------- +{ + /// \brief The offset (in bytes) to the next channel. + int iChannelOffset; + /// \brief The offset (in bytes) to the next line of this channel. + int iLinePitch; + /// \brief The offset (in bytes) to the next pixel of this channel. + int iPixelPitch; + /// \brief The string descriptor for this channel. + /** + * For an RGB image the string values of three mvIMPACT::acquire::ChannelData + * structures this might e.g. be "R", "G" and "B". + */ + char szChannelDesc[DEFAULT_STRING_SIZE_LIMIT]; +} ATTR_PACK; + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +typedef struct ChannelData ChannelData; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +//----------------------------------------------------------------------------- +/// \brief Fully describes a captured image. +/** + * This class serves as a describing structure for captured images. + * + * \ingroup CommonInterface + */ +struct ImageBuffer +//----------------------------------------------------------------------------- +{ + /// \brief The number of bytes per pixel. + int iBytesPerPixel; + /// \brief The height of the image in pixel or lines. + int iHeight; + /// \brief The width of the image in pixel. + int iWidth; + /// \brief The pixel format of this image. + /** + * This might be important, when the image data needs to be processed or stored in + * a file or maybe even if the image shall be displayed. + */ + TImageBufferPixelFormat pixelFormat; + /// \brief The size (in bytes) of the whole image. + /** + * This value in connection with mvIMPACT::acquire::ImageBuffer::vpData + * is sufficient to copy the complete image without having any additional information about it. + */ + int iSize; + /// \brief The starting address of the image. + /** + * This address in connection with mvIMPACT::acquire::ImageBuffer::iSize + * is sufficient to copy the complete image without having any additional information about it. + * + * \if (DOXYGEN_CPP_DOCUMENTATION || DOXYGEN_C_DOCUMENTATION) + * EXAMPLE:

+ * \code + * const ImageBuffer* pib = getImageBufferFromSomewhere(); + * unsigned char* pTempBuf = new unsigned char[ib.iSize]; + * memcpy( pTempBuf, pib.vpData, pIB.iSize ); + * \endcode + * \elseif DOXYGEN_NET_DOCUMENTATION + * \attention To copy this data from within a .NET environment the appropriate marshaling functions must be used! + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \warning Do \b NOT use this pointer in Java! It references native, unmanaged memory and cannot be copied directly into + * a piece of managed Java memory. Use mvIMPACT::acquire::ImageBufferDesc::copy() instead (see code below)! + * \code + * byte[] data = new byte[pRequest.getImageSize().read()]; + * pRequest.getImageBufferDesc().copy( data ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \attention There are various ways to access the data captured into a request object. One way would be by using the \c ctypes module: + * \code + * ib = getImageBufferFromSomewhere() + * cbuf = (ctypes.c_char * ib.iSize).from_address(int(ib.vpData)) + * \endcode + * \endif + * + * \note + * It's not always necessary to copy the image data! Each mvIMPACT::acquire::ImageBuffer is an + * integral part of the mvIMPACT::acquire::Request object returned to the user by a call to + * the corresponding 'waitFor' function offered by the interface. + * The data in this mvIMPACT::acquire::ImageBuffer remains valid until the user either + * unlocks the request buffer or closes the mvIMPACT::acquire::Device again. + * + * \note + * By unlocking the mvIMPACT::acquire::Request the user informs the driver, that this mvIMPACT::acquire::Request + * and the mvIMPACT::acquire::ImageBuffer belonging to that mvIMPACT::acquire::Request is not longer needed by the + * user. The driver then queues this mvIMPACT::acquire::Request for capturing image data into it once + * again. However once a mvIMPACT::acquire::Request has been returned to the user, its mvIMPACT::acquire::ImageBuffer + * can't be overwritten by the driver! Therefore the user can work with, modify, store or + * copy the data safely until he unlocks the mvIMPACT::acquire::Request again. + */ + void* vpData; + /// \brief The number of channels this image consists of. + /** + * For an RGB image this value e.g. would be 3. This value defines how many + * mvIMPACT::acquire::ChannelData structures mvIMPACT::acquire::ImageBuffer::pChannels + * is pointing to once this structure has been allocated and filled with valid data. + */ + int iChannelCount; + /// \brief A pointer to an array of channel specific image data. + ChannelData* pChannels; +} ATTR_PACK; + +#if !defined(DOXYGEN_CPP_DOCUMENTATION) && !defined(WRAP_ANY) +//----------------------------------------------------------------------------- +/// \brief This structure contains information about the image currently associated with the request object. +/// \ingroup CommonInterface +struct RequestInfo +//----------------------------------------------------------------------------- +{ + /// \brief A unique frame identifier. + /** + * This parameter is returned as part of the each request object. It can be + * used to associate a certain image with a unique identifier. + * \if DOXYGEN_CPP_DOCUMENTATION + * When an mvIMPACT::acquire::RTCtrProgramStep instruction of the type mvIMPACT::acquire::rtctrlProgTriggerSet + * is executed, the \a frameID is set to the value of the property \a FrameID of a corresponding mvIMPACT::acquire::RTCtrProgramStep if the + * HRTC is used and any program step executes the setting of the ID. + * \endif + * + * \note For some devices this property will only contain meaningful data if the device supports HRTC and a program is running and writing data to + * the property. + * + * \attention + * with version 2.4.0 this feature internally became a 64-bit value as certain supported standards (e.g. GigE Vision 2.x) using 64-bit identifiers for + * tagging blocks of data. Thus in order not to get truncated data the use of this parameter + * from this structure is discouraged. Use direct access functions to the \a FrameID property of each request instead! How to achieve this can e.g. + * be seen in the source code of the function \c getRequestProp of \c exampleHelper_C.c. In this case \c FrameID should be passed as \c pPropName. + * Not doing so might result in wraparounds back to 0 after 2^32 blocks of data have been captured even when the internal accurate value would be + * 0x0000000100000000. + */ + int frameID; + /// \brief The number of images captured since the driver has been initialised including the current image. + /** + * \attention + * with version 2.4.0 this feature internally became a 64-bit value as certain supported standards (e.g. GigE Vision 2.x) using 64-bit identifiers for + * tagging blocks of data. Thus in order not to get truncated data the use of this parameter + * from this structure is discouraged. Use direct access functions to the \a FrameNr property of each request instead! How to achieve this can e.g. + * be seen in the source code of the function \c getRequestProp of \c exampleHelper_C.c. In this case \c FrameNr should be passed as \c pPropName. + * Not doing so might result in wraparounds back to 0 after 2^32 blocks of data have been captured even when the internal accurate value would be + * 0x0000000100000000. + */ + int frameNr; + /// \brief A timestamp (in us) defining the time the device started the exposure of the image associated with this request object. + /** + * This value will stay 0 if nothing is known about the time the exposure did start. + * In such a case the timeStamp_us parameter should be used instead. + */ + int exposeStart_us; + /// \brief The 'real' expose time (in us) used to generate this image. + /** + * This might differ slightly from the value selected by the user via + * the corresponding exposure property depending on the precision + * available for the device or the connected camera. + */ + int exposeTime_us; + /// \brief The time the transaction of this image has been delayed (in us) because either the bus was blocked or the CPU was busy. + /** + * Normally this value will be 0. A value larger than 0 indicates that the system + * can't manage the current load. + * + * \note This property is not supported by every device. + */ + int transferDelay_us; + /// \brief The gain(in dB) this image has been taken with. + double gain_dB; + /// \brief A timestamp to define the exact time this image has been captured (usually either at exposure start or exposure end, depending on the device). + /** + * The timestamp is independent from the FPGA and has a resolution of 1 us. + * + * \attention + * with version 1.9.7 this feature internally became a 64-bit value thus in order not to get truncated data the use of this parameter + * from this structure is discouraged. Use direct access functions to the \a TimeStamp_us property of each request instead! + * + * \b mvBlueFOX \b specific: + * The counter of the timestamp starts when the camera gets initialized. It is measured in us. + */ + int timeStamp_us; + /// \brief Currently unsupported. + double imageAverage; + /// \brief The video input channel of the device this image has been acquired from. + /** + * \note This property is not supported by every device. Devices with only a + * single video channel will always leave this value at 0. + */ + int videoChannel; + /// \brief The camera output used to transmit the image to the capture device. + /** + * \note This property is not supported by every device. It will contain valid data for + * capture devices with at least one physical video input channel. + */ + TCameraOutput cameraOutputUsed; + /// \brief Line number since last trigger event. + /** + * Will contain + * - the line number since last trigger event of the first line of the snap if line counting is enabled + * - -1 otherwise + * + * \note This property is not supported by every device. + */ + int lineCounter; + /// \brief The amount of data missing in the current image. + /** + * The value of this property will be 0 almost always. However if a device + * can detect blocks of missing data and an image request has returned with + * \if DOXYGEN_CPP_DOCUMENTATION + * mvIMPACT::acquire::rrFrameIncomplete + * \else + * ::rrFrameIncomplete + * \endif + * to indicate that not all the data has been captured, this property will contain the amount of data missing in percent. + */ + double missingData_pc; +} ATTR_PACK; + +//----------------------------------------------------------------------------- +/// \brief Contains status information about the capture process. +/** + * This part of a complete request contains general status information about the + * request or the image currently referenced by it. + * + * \ingroup CommonInterface + */ +struct RequestResult +//----------------------------------------------------------------------------- +{ + /// \brief The result of this request. + /** + * This parameter indicates whether a previous image acquisition has been + * successful or not. + */ + TRequestResult result; + /// \brief The current state of this request. + /** + * This parameter indicates the current state of this request. A request e.g. + * can currently be idle. This would mean, that it is currently not used for + * image acquisition. Also a request can be in 'Capturing' state, which means + * it is currently processed by the driver. + */ + TRequestState state; +} ATTR_PACK; +#endif // #if !defined(DOXYGEN_CPP_DOCUMENTATION) && !defined(WRAP_ANY) + +#if !defined(WRAP_ANY) +//----------------------------------------------------------------------------- +/// \brief A structure containing information about an event that has been reported by the device driver and has been successfully waited for. +/** + * \deprecated This structure has been declared deprecated. 'onChanged' callbacks can + * directly be registered on every feature now. + * + * \ingroup CommonInterface + */ +struct EventData +//----------------------------------------------------------------------------- +{ + /// \brief A consecutive number telling the user how many times this event has occurred already. + unsigned int count; + /// \brief The lower part of the timestamp associated with this event. + unsigned int timestamp_lowPart; + /// \brief The higher part of the timestamp associated with this event. + /** + * \note Not every device or event type will support this parameter. If the + * parameter is not supported, it will be 0. + */ + unsigned int timestamp_highPart; +} ATTR_PACK; +#endif // #if !defined(WRAP_ANY) + +//----------------------------------------------------------------------------- +/// \brief Defines valid image request parameters. +/** + * Some functions accept this type as the input for certain parameter related + * functions such as obtaining a string representation of the parameter specified. + * + * \ingroup CommonInterface + */ +enum TImageRequestParam +//----------------------------------------------------------------------------- +{ + /// \brief The pixel format of an image request buffer. + irpPixelFormat = 0, + /// \brief The Result associated with an image request. + irpResult = 1, + /// \brief The current state of an image request. + irpState = 2, + /// \brief The camera output used to transmit the image from the imaging device to the capture device. + irpCameraOutputUsed = 3 +}; + +//----------------------------------------------------------------------------- +/// \brief Flags to define the way an mvIMPACT buffer is created and handled. +/// \ingroup CommonInterface +enum TImpactBufferFlag +//----------------------------------------------------------------------------- +{ + /// \brief A dummy constant to state that none of the flags shall be specified. + /** + * This flag can be used instead of writing code like this: TImpactBufferFlag(0) or + * static_cast(0). + */ + ibfNone = 0x0, + /// \brief If set no new memory will be allocated for the creation of the mvIMPACT buffer. + /** + * This way of creating the images is fast, but modifying the image data with an image processing + * function will always modify the image data associated with the underlying request object. + * + * \note + * Once the underlying request object has been unlocked, working with the image is no longer + * save when this flag was set during creation of the mvIMPACT buffer, as the memory might + * be freed by the driver. If you want to keep the created image do NOT specify this flag + * during creation. + * + * \note + * Whenever a new image is acquired from a device the device might be using the memory already associated + * with another image thus you might end up with to IMPACT images that internally reference the + * same buffer. However a large DMA memory will (at least twice the size of one image) will allow + * to work with a double buffering scheme. + */ + ibfUseRequestMemory = 0x1, + /// \brief If an existing \b IPL_BUFHANDLE is passed to a function it will try to copy data in this buffer instead of freeing it. + /** + * This flag can be used to allow the continuous usage of the same mvIMPACT buffer. If this + * flag is NOT specified whenever a valid mvIMPACT buffer handle is passed to a function + * accepting this type of flags it might free the existing buffer and create a new one. + * + * If this flag is specified and the new buffer doesn't match the existing one in terms of + * the number of bands, size, etc. the function will fail and return an error code. Thus this + * flag can be used to optimize performance if the buffer layout will remain constant during + * application runtime. + */ + ibfRecycleBufHandle = 0x2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid libraries to query information from. +/// \ingroup CommonInterface +enum TLibraryQuery +//----------------------------------------------------------------------------- +{ + /// \brief Specifies the mvDeviceManager library. + lqDeviceManager = 0, + /// \brief Specifies the mvPropHandling library. + lqPropHandling = 1 +}; + +/// \brief A type for handles bound to a certain device. +/** + * As 'C' is not a strongly typed language this simply adds an alias for \c int. + * Internally an \c int with a unique value is used to identify properties, methods and lists. The type + * HDEV therefore is nothing special. It is an integer value identifying the list containing the + * device properties available before opening the device. A HDEV therefore can also be passed to all + * functions expecting a HLIST or HOBJ type. + * + * \attention Functions expecting a HDRV will fail when fed with a HDEV as these functions obviously + * expect a different feature list! + */ +typedef int HDEV; +/// \brief A type for handles bound to an interface of a certain device. +/** + * As 'C' is not a strongly typed language this simply adds an alias for \c int. + * Internally an \c int with a unique value is used to identify properties, methods and lists. The type + * HDRV therefore is nothing special. It is an integer value identifying the list containing the + * device properties becoming available after opening the device. A HDRV therefore can also be passed to all + * functions expecting a HLIST or HOBJ type. + * + * \attention Functions expecting a HDEV will fail when fed with a HDRV as these functions obviously + * expect a different feature list! + */ +typedef int HDRV; +/// \brief A type for handles bound to an object list. +/** + * As 'C' is not a strongly typed language this simply adds an alias for \c int. + * Internally an \c int with a unique value is used to identify properties, methods and lists. The type + * HDEV therefore is nothing special. It is an integer value identifying a list of features. A HLIST therefore + * can also be passed to all functions expecting a HOBJ, HDEV(when it is the correct list) or HDRV(when it is the correct list). + * + * \attention Functions expecting a HDRV or HDEV will fail when fed with a HLIST identifier not referencing the correct feature list! + */ +typedef int HLIST; +/// \brief A type for handles bound to an unspecified object. +/** + * As 'C' is not a strongly typed language this simply adds an alias for \c int. + * Internally an \c int with a unique value is used to identify properties, methods and lists. The type + * HOBJ therefore is nothing special. It is an integer value identifying a feature (either a list of features, a property or a method). + * A HOBJ therefore can also be passed to all functions expecting a HLIST(when referencing a list), HDEV(when it is the correct list) + * or HDRV(when it is the correct list). + * + * \attention Functions expecting a HDRV or HDEV will fail when fed with a HOBJ identifier not referencing the correct feature list + * as will a function expecting a certain feature type while the HOBJ references another or no valid feature at all! + */ +typedef int HOBJ; + +/// \brief A type for handles bound to a video stream. +/** + * As 'C' is not a strongly typed language this simply adds an alias for \c void*. + * Internally this pointer however will be checked for validity in various ways. + */ +typedef void* HDMR_VIDEO_STREAM; + +#ifndef DOXYGEN_CPP_DOCUMENTATION + +/// \brief a handle to the device manager bound to the list of all devices. +typedef int HDMR; + +#ifndef WRAP_ANY + +typedef struct EventData EventData; +typedef struct ImageBuffer ImageBuffer; +typedef struct RequestInfo RequestInfo; +typedef struct RequestResult RequestResult; +typedef enum TImageRequestParam TImageRequestParam; +typedef enum TImpactBufferFlag TImpactBufferFlag; +typedef enum TLibraryQuery TLibraryQuery; + +#ifdef __cplusplus +/// \brief A constant defining the maximum length of the strings in the TDMR_DeviceInfo structure. +/** + * \note + * This is used if __cplusplus is defined. + */ +const size_t INFO_STRING_SIZE = 38; +#else // C compatible set of constants +/// \brief A macro defining the maximum length of the strings in the TDMR_DeviceInfo structure. +/** + * \note + * This is used if __cplusplus is NOT defined. + */ +#define INFO_STRING_SIZE (38) +#endif // #ifdef __cplusplus + +//----------------------------------------------------------------------------- +/// \brief Valid handle check modes. +enum TOBJ_HandleCheckMode // no_managed_type +//----------------------------------------------------------------------------- +{ + /// \brief Only the owner list of the current HOBJ is checked. + hcmOwnerList = 1, + /// \brief The owner list and the object referenced by the HOBJ parameter is checked. + hcmFull = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Valid string query types. +/** + * Certain information for an object can be queried as a string with direct + * construction. + */ +enum TOBJ_StringQuery // no_managed_type +//----------------------------------------------------------------------------- +{ + /// \brief The name of the object referenced by HOBJ. + sqObjName = 0, + /// \brief The documentation string of the object referenced by HOBJ. + sqObjDocString = 1, + /// \brief The content descriptor of the object referenced by HOBJ. + /** + * \note + * This value is only defined if the referenced object is of type ::ctList. + */ + sqListContentDescriptor = 2, + /// \brief The value of the object referenced by HOBJ. + /** + * \note + * This value is only defined if the referenced object is of type ::ctProp. + */ + sqPropVal = 3, + /// \brief The format string of the object referenced by HOBJ. + /** + * \note + * This value is only defined if the referenced object is of type ::ctProp. + */ + sqPropFormatString = 4, + /// \brief The parameter list of the object referenced by HOBJ. + /** + * \note + * This value is only defined if the referenced object is of type ::ctMeth. + * + * The returned string will contain characters giving information about the parameters expected by + * the method object. + * + * The characters have the following meaning: + * - i specifies a 32-bit integer value + * - I specifies a 64-bit integer value + * - s specifies a pointer to a C-string + * - f specifies a double precision float value + * - v specifies a void return value + * + * Examples: + * + * - 'v': This is a function returning nothing (void). It expects no parameters. + * - 'viis': This is a function returning nothing (void). It expects 2 integer values + * and one pointer to a C-string. + * - 'if': This function returns an integer value and expects a float value. + */ + sqMethParamString = 5, + /// \brief The display name of the object referenced by HOBJ. + /** + * + * \since 1.11.20 + * + */ + sqObjDisplayName = 6 +}; + +//----------------------------------------------------------------------------- +/// \brief A structure for device specific information. +/** + * \sa + * DMR_GetDeviceInfo() + */ +struct TDMR_DeviceInfo // no_managed_type +//----------------------------------------------------------------------------- +{ + /// \brief A string representation of the serial number of this device. + char serial[INFO_STRING_SIZE]; + /// \brief A string representation of the family this device belongs to. + char family[INFO_STRING_SIZE]; + /// \brief A string representation of the product name of this device. + char product[INFO_STRING_SIZE]; + /// \brief An integer value containing the current firmware version this device is programmed with. + int firmwareVersion; + /// \brief The device ID this device has been associated with. + int deviceId; +} ATTR_PACK; + +//----------------------------------------------------------------------------- +/// \brief Valid search modes for the function \b DMR_GetDevice() when searching for a certain device. +/** + * \note + * ::dmdsmUseDevID can be 'ored' (|) together with + * all the other modes. + */ +enum TDMR_DeviceSearchMode // no_managed_type +//----------------------------------------------------------------------------- +{ + /// \brief Searches for a device with a certain serial number. + dmdsmSerial = 1, + /// \brief Searches for a device belonging to a certain family. + dmdsmFamily = 2, + /// \brief Searches for a devices with a certain product string identifier. + dmdsmProduct = 3, + /// \brief This flag can be 'ored' (|) together with one of the other values. + /** + * When ::dmdsmUseDevID is specified, the device + * is located via the criteria specified above AND the device must have + * a certain ID stored into some internal memory. + */ + dmdsmUseDevID = 0x8000 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid info query types, which can be passed to the function \b DMR_GetDeviceInfoEx(). +enum TDMR_DeviceInfoType +//----------------------------------------------------------------------------- +{ + /// \brief Used to query a small structure containing some information about the device. + /** + * DMR_GetDeviceInfoEx() will expect a pointer to a TDMR_DeviceInfo + * structure when called with ::dmditDeviceInfoStructure. + */ + dmditDeviceInfoStructure = 0, + /// \brief Checks if the device is in use by an application. + /** + * The output value will be a 4 byte unsigned integer. A value different from 0 + * indicates the device is already in use. In this case the device might be in + * use either by the current process, by another process running on this machine + * or even by a process running on a different machine(e.g. when talking to a + * network device). + * + * \since 2.0.11 + */ + dmditDeviceIsInUse = 1, + /// \brief Returns a handle providing access to device driver library specific features. + /** + * The output value will be a HOBJ. + * This list does exist only once per device driver library. Changes in this list will affect all + * devices that are operated using this device driver library. + * + * \since 2.17.0 + */ + dmdithDeviceDriver = 2 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid interface list types, which can be located using the function \b DMR_FindList(). +enum TDMR_ListType // no_managed_type +//----------------------------------------------------------------------------- +{ + /// \brief A placeholder for an undefined list type + dmltUndefined = -1, + /// \brief Specifies a certain setting. + /** + * An additional string defines the name of the setting to look for. + */ + dmltSetting = 0, + /// \brief Specifies the list of driver owned image request objects. + dmltRequest = 1, + /// \brief Specifies a certain image request control. + /** + * An additional string defines the name of the setting to look for. + */ + dmltRequestCtrl = 2, + /// \brief Specifies the driver interfaces list containing general information. + /** + * This e.g. can be properties containing the driver version, the current state + * of the device and stuff like that. + */ + dmltInfo = 3, + /// \brief Specifies the driver interface list containing statistical information. + /** + * This list e.g. might contain the current frame rate, the total number of images + * captured, etc.. + */ + dmltStatistics = 4, + /// \brief Specifies the driver interface list containing properties, which influence the overall operation of the device. + /** + * This list e.g. might contain the priority of the drivers internal worker thread, + * the number of request objects the driver shall work with, etc.. + */ + dmltSystemSettings = 5, + /// \brief Specifies the driver interface list containing properties to work with any kind of I/O pin belonging to that device. + /** + * Here properties addressing the digital inputs and outputs and other I/O related + * properties can be found. + */ + dmltIOSubSystem = 6, + /// \brief Specifies the driver interface list providing access to the drivers Hardware Real-Time Controller (HRTC). + /** + * Here properties to control the behaviour of the HRTCs can be found. + * \note + * This feature might not be available for every device. + */ + dmltRTCtr = 7, + /// \brief Specifies the driver interface list providing access to the recognized camera description lists. + /** + * Within this list all recognized camera descriptions can be found, each forming a sub list + * containing the properties describing the camera. + * + * \note This feature currently is only available for frame grabber devices. + */ + dmltCameraDescriptions = 8, + /// \brief Specifies the driver interface list providing access to the device specific settings lists. + /** + * \note This feature currently is only available for frame grabber devices. + */ + dmltDeviceSpecificData = 9, + /// \brief Specifies the driver interface list providing access to the device specific event type settings lists (\b deprecated). + /** + * \note Every device will support a different set of events that can be waited for by the user. + * + * This list will contain a sublist for each event type recognized for this device. Within this sublist + * all properties that can be describe the current mode an event is operated in user can be found. + * + * \deprecated + * This value has been declared deprecated and will be removed in future versions of this interface. + * A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method + * is \b Callback.c. + */ + dmltEventSubSystemSettings = 10, + /// \brief Specifies the driver interface list providing access to the device specific event type results lists (\b deprecated). + /** + * \note Every device will support a different set of events that can be waited for by the user. + * + * This list will contain a sublist for each event type recognized for this device. Within this sublist + * all result properties that can be queried by the user can be found. + * + * \deprecated + * This value has been declared deprecated and will be removed in future versions of this interface. + * A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method + * is \b Callback.c. + */ + dmltEventSubSystemResults = 11, + /// \brief Specifies the driver interface list providing access to the devices memory manager list. + /** + * \note This feature currently is only available for frame grabber devices. + * + * This list will contain properties and lists providing access to settings related to the memory + * handling used by the device. E.g. the buffer size for individual DMA blocks can be configured + * here. + * + * \note + * Properties in this list should only be modified by advanced users. + */ + dmltImageMemoryManager = 12, + /// \brief Specifies the device driver lib + /** + * An additional string defines the name of the device driver lib to look for. + * + * \since 2.17.0 + */ + dmltDeviceDriverLib = 13 +}; + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +typedef enum TOBJ_HandleCheckMode TOBJ_HandleCheckMode; +typedef enum TOBJ_StringQuery TOBJ_StringQuery; +typedef struct TDMR_DeviceInfo TDMR_DeviceInfo; +typedef enum TDMR_DeviceInfoType TDMR_DeviceInfoType; +typedef enum TDMR_ListType TDMR_ListType; +typedef enum TDMR_DeviceSearchMode TDMR_DeviceSearchMode; +#endif // DOXYGEN_SHOULD_SKIP_THIS + +// general library functions +MVDMR_API TDMR_ERROR DMR_CALL DMR_Init( HDMR* pHDmr ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_Close( void ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDevice( HDEV* pHDev, TDMR_DeviceSearchMode searchMode, const char* pSearchString, unsigned int devNr, char wildcard ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDeviceWithStringID( HDEV* pHDev, TDMR_DeviceSearchMode searchMode, const char* pSearchString, const char* pStringID, char wildcard ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDeviceCount( unsigned int* pDevCnt ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_OpenDevice( HDEV hDev, HDRV* pHDrv ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CloseDevice( HDRV hDrv, HDEV hDev ); +MVIMPACT_DEPRECATED_C( MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDeviceInfo( unsigned int devNr, TDMR_DeviceInfo* pInfo, size_t infoSize ) ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDeviceInfoEx( HDEV hDev, TDMR_DeviceInfoType infoType, void* pInfo, size_t* pInfoSize ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetDriverHandle( HDEV hDev, HDRV* pHDrv ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_UpdateDeviceList( unsigned int reserved, int reserved2 ); +// device specific functions. These function require a handle to an initialised device +// basic operations +MVDMR_API TDMR_ERROR DMR_CALL DMR_CreateSetting( HDRV hDrv, const char* pName, const char* pParentName, HLIST* pNewID ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CreateRequestControl( HDRV hDrv, const char* pName, const char* pParentName, HLIST* pNewID, int* pRequestCtrl ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_DeleteList( HDRV hDrv, const char* pName, TDMR_ListType type ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_FindList( HDRV hDrv, const char* pName, TDMR_ListType type, unsigned int flags, HLIST* phDevList ); +// image acquisition functions +MVDMR_API TDMR_ERROR DMR_CALL DMR_AcquisitionStart( HDRV hDrv ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_AcquisitionStop( HDRV hDrv ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestReset( HDRV hDrv, int requestCtrl, int mode ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestSingle( HDRV hDrv, int requestCtrl, int* pRequestUsed ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestUnlock( HDRV hDrv, int requestNr ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestConfigure( HDRV hDrv, int requestNr, int reserved, void* pReserved ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestWaitFor( HDRV hDrv, int timeout_ms, int queueNr, int* pRequestNr ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestResultQueueElementCount( HDRV hDrv, int queueNr, int* pResultQueueElements ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestSave( HDRV hDrv, int requestNr, const char* pFileName, TImageFileFormat format ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestBuffer( HDRV hDrv, int requestNr, ImageBuffer** ppBuffer ); +// functions only needed to query certain information from other languages such as VB. +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestBufferData( HDRV hDrv, int requestNr, int* pBytesPerPixel, int* pChannelCount, int* pHeight, int* pWidth, int* pSize, TImageBufferPixelFormat* pPixelFormat, void** ppData ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestBufferChannelData( HDRV hDrv, int requestNr, int channelNr, int* pChannelOffset, int* pLinePitch, int* pPixelPitch, char* pChannelDesc, size_t channelDescSize ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestBufferImageData( HDRV hDrv, int requestNr, int xOff, int yOff, int width, int height, char* pBuf, size_t bufSize ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_SetImageRequestBufferImageData( HDRV hDrv, int requestNr, int xOff, int yOff, int width, int height, char* pBuf, size_t bufSize ); +// functions only needed to query certain information from other languages such as VB END. +#ifdef __vl_base_h__ +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImpactRequestBufferEx( HDRV hDrv, int requestNr, IPL_BUFHANDLE* pBuffer, TImpactBufferFlag flags, unsigned int reserved ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_BuildImpactImage( const ImageBuffer* pBuffer, IPL_BUFHANDLE* pBufHandle, TImpactBufferFlag flags, void* pReserved, size_t reservedSize ); +#endif // __vl_base_h__ +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestInfoEx( HDRV hDrv, int requestNr, RequestInfo* pInfo, size_t infoSize, int reserved, int reserved2 ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestResultEx( HDRV hDrv, int requestNr, RequestResult* pResult, size_t resultSize, int reserved, int reserved2 ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetImageRequestParamS( HDRV hDrv, int requestNr, TImageRequestParam param, char* pBuf, size_t bufSize ); +// file I/O functions +MVDMR_API TDMR_ERROR DMR_CALL DMR_LoadRTCtrProgram( HDRV hDrv, HLIST hRTCtrList ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_SaveRTCtrProgram( HDRV hDrv, HLIST hRTCtrList ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_LoadSetting( HDRV hDrv, const char* pName, TStorageFlag storageFlags, TScope scope ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_SaveSetting( HDRV hDrv, const char* pName, TStorageFlag storageFlags, TScope scope ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_LoadSettingFromDefault( HDRV hDrv, TScope scope ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_SaveSettingToDefault( HDRV hDrv, TScope scope ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_IsSettingAvailable( const char* pName, TStorageLocation storageLocation, TScope scope ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_DeleteSetting( const char* pName, TStorageLocation location, TScope scope ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ExportCameraDescription( HDRV hDrv, HLIST hCameraDescList ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImportCameraDescription( HDRV hDrv, HLIST hCameraDescList ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CopyCameraDescription( HDRV hDrv, HLIST hCameraDescList, const char* pNewName ); +// miscellaneous HW specific functions +MVDMR_API TDMR_ERROR DMR_CALL DMR_SetDeviceID( HDEV hDev, int newID ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_UpdateFirmware( HDEV hDev ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_UpdateDigitalInputs( HDRV hDrv ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CreateUserDataEntry( HDEV hDev, HLIST* pEntry ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_DeleteUserDataEntry( HDEV hDev, HLIST hEntry ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_WriteUserDataToHardware( HDEV hDev ); +#if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +MVIMPACT_DEPRECATED_C( MVDMR_API TDMR_ERROR DMR_CALL DMR_EventWaitFor( HDRV hDrv, int timeout_ms, TDeviceEventType mask, int reserved, int reserved2, TDeviceEventType* pResultType ) ); +MVIMPACT_DEPRECATED_C( MVDMR_API TDMR_ERROR DMR_CALL DMR_EventGetData( HDRV hDrv, TDeviceEventType type, int reserved, int reserved2, EventData* pResult, size_t resultSize ) ); +#endif // #if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + +// device independent image buffer related functions +MVDMR_API TDMR_ERROR DMR_CALL DMR_AllocImageRequestBufferDesc( ImageBuffer** ppBuffer, int channelCount ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ReleaseImageRequestBufferDesc( ImageBuffer** ppBuffer ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CopyImageRequestBufferDesc( const ImageBuffer* pSrc, ImageBuffer** ppDst, int flags ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_AllocImageBuffer( ImageBuffer** ppBuffer, TImageBufferPixelFormat pixelFormat, int width, int height ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ReleaseImageBuffer( ImageBuffer** ppBuffer ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CopyImageBuffer( const ImageBuffer* pSrc, ImageBuffer** ppDst, int flags ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_LoadImageBuffer( ImageBuffer** ppBuffer, const char* pFileName, TImageFileFormat format ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_SaveImageBuffer( const ImageBuffer* pBuffer, const char* pFileName, TImageFileFormat format ); + +// video stream related functions +MVDMR_API TDMR_ERROR DMR_CALL DMR_InitVideoStreamAPI( void* pReserved, size_t reserved ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_OpenVideoStream( const char* pFileName, const unsigned int imageWidth, const unsigned int imageHeight, const TVideoCodec codec, const unsigned int quality_pc, const unsigned int bitrate, HDMR_VIDEO_STREAM* pHVideoStream ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_CloseVideoStream( HDMR_VIDEO_STREAM hVideoStream ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_SaveImageBufferToVideoStream( HDMR_VIDEO_STREAM hVideoStream, const ImageBuffer* pBuffer, const int64_type timestamp_us ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ImageRequestSaveToVideoStream( HDRV hDrv, int requestNr, HDMR_VIDEO_STREAM hVideoStream ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_PauseVideoStream( HDMR_VIDEO_STREAM hVideoStream ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_ResumeVideoStream( HDMR_VIDEO_STREAM hVideoStream ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_IsVideoStreamPaused( HDMR_VIDEO_STREAM hVideoStream ); + +// miscellaneous functions +MVDMR_API const char* DMR_CALL DMR_ErrorCodeToString( int errorCode ); +MVDMR_API const char* DMR_CALL DMR_GetVersion( TLibraryQuery libraryQuery ); +MVDMR_API TDMR_ERROR DMR_CALL DMR_GetLastError( TDMR_ERROR* pErrorCode, char* pErrorText, size_t* pErrorTextSize ); +// general object specific functions +MVIMPACT_DEPRECATED_C( MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_IsSettingAvailable( const char* pName, TStorageFlag storageFlags, TScope scope ) ); +MVIMPACT_DEPRECATED_C( MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_DeleteSetting( const char* pName, TStorageFlag storageFlags, TScope scope ) ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_CheckHandle( HOBJ hObj, TOBJ_HandleCheckMode mode ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetChangedCounter( HOBJ hObj, unsigned int* pChangedCounter ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetChangedCounterAttr( HOBJ hObj, unsigned int* pChangedCounter ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetContentDesc( HOBJ hList, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetDocString( HOBJ hObj, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFlags( HOBJ hObj, TComponentFlag* pFlags ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFlagsS( HOBJ hObj, const char* pSeparator, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetName( HOBJ hObj, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetDisplayName( HOBJ hObj, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetType( HOBJ hObj, TComponentType* pType ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetTypeS( HOBJ hObj, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetVisibility( HOBJ hObj, TComponentVisibility* pVisibility ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetVisibilityS( HOBJ hObj, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_VisibilityToString( TComponentVisibility visibility, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetRepresentation( HOBJ hObj, TComponentRepresentation* pRepresentation ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetRepresentationS( HOBJ hObj, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_RepresentationToString( TComponentRepresentation representation, char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_IsDefault( HOBJ hObj, unsigned int* pResult ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_RestoreDefault( HOBJ hObj ); +MVIMPACT_DEPRECATED_C( MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetHandle( HLIST hList, const char* pPathAndObjName, HOBJ* phObj ) ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetSelectedFeatures( HOBJ hObj, int index, HOBJ* phFeatures, size_t* pFeatureCount ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetSelectingFeatures( HOBJ hObj, int index, HOBJ* phFeatures, size_t* pFeatureCount ); + +//----------------------------------------------------------------------------- +/// \brief A prototype for a callback function that can be attached to a feature. +/** + * This callback will be executed whenever the feature changes + */ +typedef void ( DMR_CALL* CBOBJChanged )( /// The feature which has changed + HOBJ hObj, + /// A pointer to additional user data bound to this callback. + /// This data can be passed to the callback on creation. + /// Whenever the callback gets executed this data is passed back to the user. + void* pUserData ); +//----------------------------------------------------------------------------- +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_CreateCallback( TCallbackType type, CBOBJChanged pMeth, void* pUserData, CallbackHandle* phCallback ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_DeleteCallback( CallbackHandle hCallback ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_AttachCallback( HOBJ hObj, CallbackHandle hCallback ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_DetachCallback( HOBJ hObj, CallbackHandle hCallback ); +// navigation within object hierarchies +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFirstSibling( HOBJ hObj, HOBJ* phFirstSibling ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetNextSibling( HOBJ hObj, HOBJ* phNextSibling ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetLastSibling( HOBJ hObj, HOBJ* phLastSibling ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFirstChild( HOBJ hObj, HOBJ* phFirstChild ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetParent( HOBJ hObj, HOBJ* phParent ); +// property specific object functions +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetMaxValCount( HOBJ hProp, unsigned int* pValCount ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetValCount( HOBJ hProp, unsigned int* pValCount ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetValCount( HOBJ hProp, unsigned int valCount ); +MVIMPACT_DEPRECATED_C( MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetBinary( HOBJ hProp, char* pBuf, unsigned int bufSize, int index ) ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetBinaryEx( HOBJ hProp, char* pBuf, unsigned int* pBufSize, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetBinary( HOBJ hProp, const char* pBuf, unsigned int bufSize, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetBinaryBufferSize( HOBJ hProp, unsigned int* pBufSize, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetBinaryBufferMaxSize( HOBJ hProp, unsigned int* pBufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetF( HOBJ hProp, double* pVal, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFArray( HOBJ hProp, double* pVal, unsigned int valCount, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetF( HOBJ hProp, double val, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetFArray( HOBJ hProp, const double* pVal, unsigned int valCount, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFDictEntry( HOBJ hProp, char* pTranslationString, size_t translationStringBufSize, double* pValue, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFDictEntries( HOBJ hProp, char** pTranslationArray, size_t sizePerTranslationBuf, double* pValArray, size_t arraySizes ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetI( HOBJ hProp, int* pVal, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetIArray( HOBJ hProp, int* pVal, unsigned int valCount, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetI( HOBJ hProp, int val, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetIArray( HOBJ hProp, const int* pVal, unsigned int valCount, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetIDictEntry( HOBJ hProp, char* pTranslationString, size_t translationStringBufSize, int* pValue, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetIDictEntries( HOBJ hObj, char** pTranslationArray, size_t sizePerTranslationBuf, int* pValArray, size_t arraySizes ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetI64( HOBJ hProp, int64_type* pVal, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetI64Array( HOBJ hProp, int64_type* pVal, unsigned int valCount, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetI64( HOBJ hProp, int64_type val, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetI64Array( HOBJ hProp, const int64_type* pVal, unsigned int valCount, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetI64DictEntry( HOBJ hProp, char* pTranslationString, size_t translationStringBufSize, int64_type* pValue, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetI64DictEntries( HOBJ hObj, char** pTranslationArray, size_t sizePerTranslationBuf, int64_type* pValArray, size_t arraySizes ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetP( HOBJ hProp, void** pVal, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetP( HOBJ hProp, void* val, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetS( HOBJ hProp, char* pVal, size_t bufSize, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_SetS( HOBJ hProp, const char* pVal, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetSFormattedEx( HOBJ hProp, char* pBuf, size_t* pBufSize, const char* pFormat, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetSArrayFormattedEx( HOBJ hProp, char* pBuf, size_t* pBufSize, const char* pFormat, const char* pDelimiters, int startIndex, int endIndex, int mode ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_RemoveVal( HOBJ hProp, int index ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_IsConstantDefined( HOBJ hProp, int constant, unsigned int* pResult ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetDictSize( HOBJ hProp, unsigned int* pDictSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetFormatString( HOBJ hProp, char* pBuf, size_t bufSize ); +// list specific object functions +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetElementCount( HLIST hList, unsigned int* pElementCount ); +// method specific object functions +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_Execute( HOBJ hMeth, const char* pCallParams, const char* pDelimiters, int* pResult ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetSParamList( HOBJ hMeth, char* pBuf, size_t bufSize ); +// advanced object specific functions +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetHandleEx( HLIST hList, const char* pObjName, HOBJ* phObj, unsigned int searchMode, int maxSearchDepth ); +/// \brief A prototype for a function pointer used for in place string construction +/** + * This function pointer can be used to prototype advanced efficient calls to interface functions. + * \sa + * \b OBJ_GetSWithInplaceConstruction() + */ +typedef char* ( *SCF )( const char* pBuf, size_t bufSize ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_GetSWithInplaceConstruction( HOBJ hObj, TOBJ_StringQuery sq, char** pResult, SCF constructionFunc, int mode, int reserved ); +MVDMR_API TPROPHANDLING_ERROR DMR_CALL OBJ_FreeSMemory( char* pBuffer ); + +#endif // #ifndef WRAP_ANY + +#endif // #ifndef DOXYGEN_CPP_DOCUMENTATION + +#ifndef __GNUC__ +# pragma pack(pop) // restore previous structure alignment +#endif +#undef ATTR_PACK + +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef __cplusplus +} +#endif // __cplusplus + +// restore Borland compiler switch 'force enums to the size of integer' +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ // is Borland compiler? +# pragma option pop +# endif // #ifdef __BORLANDC__ +# endif // #ifdef _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#endif // mvDeviceManagerH diff --git a/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplay.h b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplay.h new file mode 100644 index 0000000..354c729 --- /dev/null +++ b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplay.h @@ -0,0 +1,112 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvDisplayH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvDisplayH mvDisplayH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//--------------------------------------------------------------------------- +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# ifdef _WIN32 +# ifndef WRAP_ANY +# if defined(__BORLANDC__) // is Borland compiler +# pragma option -b // force enums to size of integer +# endif // #if defined(__BORLANDC__) +# ifndef NO_MV_DISPLAY_AUTOLINK +# if defined(__BORLANDC__) // is Borland compiler +# if __CODEGEARC__ >= 0X710 +# pragma comment(lib,"mvDisplayb") +# else +# pragma comment(lib,"mvDisplayb.lib") +# endif // #if __CODEGEARC__ >= 0X710 +# pragma message( "Automatically linking with mvDisplayb.lib" ) +# elif defined(_MSC_VER) // Microsoft compiler +# pragma comment(lib,"mvDisplay.lib") +# pragma message( "Automatically linking with mvDisplay.lib" ) +# endif // #if defined(__BORLANDC__) +# endif // #ifndef NO_MV_DISPLAY_AUTOLINK +# include +# include +typedef COLORREF ColorValue; +# else +typedef unsigned int ColorValue; +# endif // #ifndef WRAP_ANY +# define MV_DISPLAY_API_CALL __stdcall +typedef HWND WindowHandle; +typedef HDC DeviceContextHandle; +typedef HBRUSH BrushHandle; +# elif !defined(DOXYGEN_JAVA_DOCUMENTATION) && !defined(DOXYGEN_PYTHON_DOCUMENTATION) +# error Unsupported operating system +# endif // #ifdef _WIN32 +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +namespace display +{ +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifndef WRAP_ANY + +/// \brief Prototype for the overlay callback function that can be passed to \b mvDispSetOverlayCallbackFunction() +typedef void ( MV_DISPLAY_API_CALL* TImageDisplayOverlayFunction )( DeviceContextHandle hdc, WindowHandle hwnd, int bmpLeft, int bmpTop, int bmpWidth, int bmpHeight, int dispLeft, int dispTop, int dispWidth, int dispHeight, void* pUserParam ); + +TDisp* MV_DISPLAY_API_CALL mvDispInit( WindowHandle hwnd ); +void MV_DISPLAY_API_CALL mvDispDeinit( TDisp** ppDisp ); +void MV_DISPLAY_API_CALL mvDispClear( TDisp* pDisp ); +int MV_DISPLAY_API_CALL mvDispGetError( TDisp* pDisp ); +void MV_DISPLAY_API_CALL mvDispSetBitmapRectangle( TDisp* pDisp, int left, int top, int width, int height ); +void MV_DISPLAY_API_CALL mvDispSetDisplayMode( TDisp* pDisp, TDisplayMode mode ); +TDisplayMode MV_DISPLAY_API_CALL mvDispGetDisplayMode( TDisp* pDisp ); +void MV_DISPLAY_API_CALL mvDispSetDisplayRectangle( TDisp* pDisp, int left, int top, int width, int height ); +void MV_DISPLAY_API_CALL mvDispSetBackgroundBrush( TDisp* pDisp, HBRUSH hBrush ); +void MV_DISPLAY_API_CALL mvDispSetDDrawOverlayKeyColor( TDisp* pDisp, COLORREF keyColor ); +void MV_DISPLAY_API_CALL mvDispSetOverlayCallbackFunction( TDisp* pDisp, TImageDisplayOverlayFunction fctOverlay, void* pUserParam ); +void MV_DISPLAY_API_CALL mvDispGetImage( TDisp* pDisp, const void** ppData, int* pWidth, int* pHeight, int* pBitsPerPixel, int* pPitch ); +void MV_DISPLAY_API_CALL mvDispSetImage( TDisp* pDisp, const void* pData, int width, int height, int bitsPerPixel, int pitch ); +void MV_DISPLAY_API_CALL mvDispSetImageEx( TDisp* pDisp, const void** ppData, size_t ppDataArraySize, TFormatFlags format, int width, int height, int bitsPerPixel, int pitch ); +void MV_DISPLAY_API_CALL mvDispUpdate( TDisp* pDisp ); +void MV_DISPLAY_API_CALL mvDispSetWindowHandle( TDisp* pDisp, WindowHandle hwnd ); +WindowHandle MV_DISPLAY_API_CALL mvDispGetWindowHandle( TDisp* pDisp ); +void MV_DISPLAY_API_CALL mvDispSetInterpolationMode( TDisp* pDisp, TInterpolationMode interpolationMode ); +TInterpolationMode MV_DISPLAY_API_CALL mvDispGetInterpolationMode( TDisp* pDisp ); +int MV_DISPLAY_API_CALL mvDispGetShift( TDisp* pDisp ); +void MV_DISPLAY_API_CALL mvDispSetShift( TDisp* pDisp, int shift ); +int MV_DISPLAY_API_CALL mvDispGetAppliedShift( TDisp* pDisp ); + +#endif // #ifndef WRAP_ANY + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace display +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // mvDisplayH diff --git a/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayDatatypes.h b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayDatatypes.h new file mode 100644 index 0000000..26f2396 --- /dev/null +++ b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayDatatypes.h @@ -0,0 +1,197 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvDisplayDatatypesH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvDisplayDatatypesH mvDisplayDatatypesH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ +# pragma option push -b // force enums to the size of integer +# endif // __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +namespace display +{ +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +//--------------------------------------------------------------------------- +/// \brief Defines valid error values for this module. +/// \ingroup Display +enum TImageDisplayError +//--------------------------------------------------------------------------- +{ + /// \brief No error occurred since the last time the error code was queried. + IDE_NoError = 0, + /// \brief There is not enough memory available to perform the requested operation. + IDE_OutOfMemory, + /// \brief The update failed. This is an internal error. + IDE_UpdateFailed, + /// \brief One or more of the handles passed to a function where invalid. + IDE_InvalidHandle, + /// \brief Unspecified internal error. + IDE_InternalError, + /// \brief Calling a DirectDraw® function did fail. + IDE_DirectDrawAccessFailed +}; + +//--------------------------------------------------------------------------- +/// \brief Defines valid display modes. +/// \ingroup Display +enum TDisplayMode +//--------------------------------------------------------------------------- +{ + /// \brief The default display mode. + /** + * This display mode is capable of scaling the image. Scaling however will + * result in additional CPU load. + * + * In this mode, the bitmap rectangle will always be scaled to fit into the display rectangle. + * + * In this mode(and in this mode only) overlay callbacks will be executed. + */ + DM_Default = 0, + /// \brief The fastest display mode. + /** + * In this mode there will be no scaling and no overlay callbacks but it will + * operate with the lowest possible CPU load. + */ + DM_Fastest, + /// \brief DirectDraw® mode. + /** + * This mode will use DirectDraw® for displaying the image. + * + * In this mode, the bitmap rectangle will always be scaled to fit into the display rectangle. + */ + DM_DDrawOverlay, + /// \brief Fullscreen (Exclusive) DirectDraw® mode. + /** + * This mode will use DirectDraw® exclusive mode for displaying the image. + * + * In this mode, the bitmap rectangle will always be scaled to fit into the display rectangle. + */ + DM_FullScreen +}; + +//--------------------------------------------------------------------------- +/// \brief Defines valid scaler interpolation modes. +/// \ingroup Display +enum TInterpolationMode +//--------------------------------------------------------------------------- +{ + /// \brief Nearest neighbor interpolation (default). + /** + * Fast but with reduced quality. + */ + IM_NEAREST_NEIGHBOUR = 0, + /// \brief Linear interpolation. + /** + * Both quality and CPU load will be average. + */ + IM_LINEAR, + /// \brief Cubic interpolation. + /** + * Best quality, highest CPU load. + */ + IM_CUBIC +}; + +//--------------------------------------------------------------------------- +/// \brief Defines valid display pixel formats. +/// \ingroup Display +enum TFormatFlags +//--------------------------------------------------------------------------- +{ + /// \brief Valid values for bits per pixel in this format: 15, 16, 24, 32; pData[0] points to the packed image data. + ffRGB888xPacked, + /// \brief Valid values for bits per pixel in this format: not used, 8 bit per plane, pData[0] points to the Blue, pData[1] points to the Green, pData[2] points to the Red plane. + ffRGB888xPlanar, + /// \brief Valid values for bits per pixel in this format: 8, 10, 12, 14, 16, LSB aligned. + ffMono, + /// \brief Valid values for bits per pixel in this format: 16, 20, YUV422: 8-10 bit Y | 8-10 bit U | 8-10 bit Y | 8-10 bit V. + ffYUY2, + /// \brief Valid values for bits per pixel in this format: not used, YUV422 planar. + ffYUV422Planar, + /// \brief Valid values for bits per pixel in this format: 30, 36, 42 or 48 10-16 bits per color component RGB packed data. + ffRGB2BytePacked, + /// \brief Valid values for bits per pixel in this format: 16, 20, YUV422: 8-10 bit U | 8-10 bit Y | 8-10 bit V | 8-10 bit Y. + ffUYVY, + /// \brief Valid values for bits per pixel in this format: 12, 8 MSB(1), 4 LSBs(1+2), 8MSB(2). + ffMonoPacked_V2, + /// \brief Valid values for bits per pixel in this format: 15, 16, 24, 32; pData[0] points to the packed image data. + ffBGR888xPacked, + /// \brief Valid values for bits per pixel in this format: 24 or 48. + ffUYV444, + /// \brief Valid values for bits per pixel in this format: 48. + ffYUV444, + /// \brief Valid values for bits per pixel in this format: 30 (R=pix&0x3FF, G=(pix>>10)&0x3FF, B=(pix>>20)&3FF). + ffBGR2BytePacked_V2, + /// \brief Valid values for bits per pixel in this format: 12, 8 MSB(1), 4 LSB(1) + 4 MSB(2), 8LSB(2). + /** + * \since 2.5.0 + */ + ffMonoPacked_V1, + /// \brief Valid values for bits per pixel in this format: not used, YUV411: 8 bit U | 8 bit Y1 | 8 bit Y2 | 8 bit V | 8 bit Y3 | 8 bit Y4. + /** + * \since 2.13.0 + */ + ffYUV411_UYYVYY_Packed +}; + +/// \brief Display structure handle for C compliant interface +typedef struct SDisp TDisp; + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +typedef enum TImageDisplayError TImageDisplayError; +typedef enum TDisplayMode TDisplayMode; +typedef enum TInterpolationMode TInterpolationMode; +typedef enum TFormatFlags TFormatFlags; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace display +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef __cplusplus +} +#endif // __cplusplus + +// restore Borland compiler switch 'force enums to the size of integer' +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ +# pragma option pop +# endif // __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#endif // mvDisplayDatatypesH diff --git a/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayExtensions.h b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayExtensions.h new file mode 100644 index 0000000..ff1ad5a --- /dev/null +++ b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayExtensions.h @@ -0,0 +1,113 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvDisplayExtensionsH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvDisplayExtensionsH mvDisplayExtensionsH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//--------------------------------------------------------------------------- +#include +#ifdef __cplusplus +# include +#else +# include +#endif // __cplusplus + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +namespace display +{ +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifndef WRAP_ANY + +#ifdef __cplusplus +extern "C" { +#endif + +void MV_DISPLAY_API_CALL mvDispConvertFormat( TImageBufferPixelFormat pixelFormat, TFormatFlags* pFormat, int* pBitsPerPixel ); +void MV_DISPLAY_API_CALL mvDispSetImageFromImageBuffer( TDisp* pDisp, const ImageBuffer* pBuf ); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#ifdef __cplusplus +//----------------------------------------------------------------------------- +/// \brief Sets the next image to display. +/** + * This function can deal with any pixel format supported by mvIMPACT Acquire. + * \since 1.12.68 + */ +inline void mvDispSetImageFromRequest( + /// [in] A handle to a display structure obtained + /// from a successful call to \b mvDispInit(). + TDisp* pDisp, + /// [in] The request object that shall be displayed. + const mvIMPACT::acquire::Request* pRequest ) +//----------------------------------------------------------------------------- +{ +if( pRequest ) +{ + const size_t MAX_PLANE_CNT = 3; + size_t planeCount = 1; + const void* dataPtrArray[MAX_PLANE_CNT]; + char* p = ( char* )pRequest->imageData.read(); + int bitsPerPixel = 8; + TFormatFlags format = ffMono; + + mvDispConvertFormat( static_cast( pRequest->imagePixelFormat.read() ), &format, &bitsPerPixel ); + switch( pRequest->imagePixelFormat.read() ) + { + case ibpfRGB888Planar: + case ibpfRGBx888Planar: + dataPtrArray[2] = p + pRequest->imageChannelOffset.read( 0 ); + dataPtrArray[1] = p + pRequest->imageChannelOffset.read( 1 ); + dataPtrArray[0] = p + pRequest->imageChannelOffset.read( 2 ); + planeCount = 3; + break; + case ibpfYUV422Planar: + dataPtrArray[0] = p + pRequest->imageChannelOffset.read( 0 ); + dataPtrArray[1] = p + pRequest->imageChannelOffset.read( 1 ); + dataPtrArray[2] = p + pRequest->imageChannelOffset.read( 2 ); + planeCount = 3; + break; + default: + dataPtrArray[0] = p; + break; + } + mvDispSetImageEx( pDisp, dataPtrArray, planeCount, format, pRequest->imageWidth.read(), pRequest->imageHeight.read(), bitsPerPixel, pRequest->imageLinePitch.read() ); +} +else +{ + mvDispSetImage( pDisp, 0, 0, 0, 8, 0 ); +} +} +#endif // #ifdef __cplusplus + +#endif // #ifndef WRAP_ANY + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace display +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#endif // mvDisplayExtensionsH diff --git a/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayWindow.h b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayWindow.h new file mode 100644 index 0000000..841d23c --- /dev/null +++ b/Cigarette/MvIMPACT/mvDisplay/Include/mvDisplayWindow.h @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvDisplayWindowH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvDisplayWindowH mvDisplayWindowH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//--------------------------------------------------------------------------- +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +namespace display +{ +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +/// \brief Display window handle for C compliant interface. +typedef void* HDISP; + +#ifndef WRAP_ANY + +/// \brief Prototype for the callback function that can be passed to \b mvDispWindowSetMessageHandler() +typedef void ( *TPreProcessMessage )( HDISP hDisp, UINT message, WPARAM wParam, LPARAM lParam ); + +void MV_DISPLAY_API_CALL mvDispWindowDestroy( HDISP hDisp ); +WindowHandle MV_DISPLAY_API_CALL mvDispWindowGetWindowHandle( HDISP hDisp ); +TDisp* MV_DISPLAY_API_CALL mvDispWindowGetDisplayHandle( HDISP hDisp ); +HDISP MV_DISPLAY_API_CALL mvDispWindowCreate( const char* title ); +int MV_DISPLAY_API_CALL mvDispWindowSetRefreshTime( HDISP hDisp, int time_ms ); +void MV_DISPLAY_API_CALL mvDispWindowShow( HDISP hDisp ); +void MV_DISPLAY_API_CALL mvDispWindowSetMessageHandler( HDISP hDisp, TPreProcessMessage handler ); +TPreProcessMessage MV_DISPLAY_API_CALL mvDispWindowGetMessageHandler( HDISP hDisp ); + +#endif // #ifndef WRAP_ANY + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace display +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#if defined(__cplusplus) +} +#endif + +#endif // mvDisplayWindowH diff --git a/Cigarette/MvIMPACT/mvDisplay/Include/mvIMPACT_acquire_display.h b/Cigarette/MvIMPACT/mvDisplay/Include/mvIMPACT_acquire_display.h new file mode 100644 index 0000000..bde1ce9 --- /dev/null +++ b/Cigarette/MvIMPACT/mvDisplay/Include/mvIMPACT_acquire_display.h @@ -0,0 +1,666 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MVIMPACT_ACQUIRE_DISPLAY_H_ +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_ACQUIRE_DISPLAY_H_ MVIMPACT_ACQUIRE_DISPLAY_H_ +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#ifdef SWIG +# ifdef SWIGPYTHON +# ifndef WRAP_PYTHON +# define WRAP_PYTHON +# endif +# endif +# ifdef SWIGJAVA +# ifndef WRAP_JAVA +# define WRAP_JAVA +# endif +# endif +#endif + +#ifdef WRAP_PYTHON +# ifndef PYTHON_ONLY +# define PYTHON_ONLY(X) X +# endif +# ifndef PYTHON_CPP_SWITCH +# define PYTHON_CPP_SWITCH(PYTHON_WRAPPER_CODE,CPP_WRAPPER_CODE) PYTHON_WRAPPER_CODE +# endif +# ifndef WRAP_ANY +# define WRAP_ANY +# endif // #ifndef WRAP_ANY +#else // #ifdef WRAP_PYTHON +# ifndef PYTHON_ONLY +# define PYTHON_ONLY(X) +# endif +# ifndef PYTHON_CPP_SWITCH +# define PYTHON_CPP_SWITCH(PYTHON_WRAPPER_CODE,CPP_WRAPPER_CODE) CPP_WRAPPER_CODE +# endif +#endif // #ifdef WRAP_PYTHON + +#ifdef WRAP_JAVA +# ifndef JAVA_ONLY +# define JAVA_ONLY(X) X +# endif +# ifndef JAVA_CPP_SWITCH +# define JAVA_CPP_SWITCH(JAVA_WRAPPER_CODE,CPP_WRAPPER_CODE) JAVA_WRAPPER_CODE +# endif +# ifndef WRAP_ANY +# define WRAP_ANY +# endif // #ifndef WRAP_ANY +#else // #ifdef WRAP_JAVA +# ifndef JAVA_ONLY +# define JAVA_ONLY(X) +# endif +# ifndef JAVA_CPP_SWITCH +# define JAVA_CPP_SWITCH(JAVA_WRAPPER_CODE,CPP_WRAPPER_CODE) CPP_WRAPPER_CODE +# endif +#endif // #ifdef WRAP_JAVA + +#if defined(WRAP_PYTHON) || defined(WRAP_JAVA) +# ifndef PYTHON_OR_JAVA_ONLY +# define PYTHON_OR_JAVA_ONLY(X) X +# endif +#else +# ifndef PYTHON_OR_JAVA_ONLY +# define PYTHON_OR_JAVA_ONLY(X) +# endif +#endif // #if defined(WRAP_PYTHON) || defined(WRAP_JAVA) + +#ifdef _MSC_VER // is Microsoft compiler? +# pragma warning( push ) +# if _MSC_VER < 1300 // is 'old' VC 6 compiler? +# pragma warning( disable : 4786 ) // 'identifier was truncated to '255' characters in the debug information' +# define __FUNCTION__ "No function name information as the __FUNCTION__ macro is not supported by this(VC 6) compiler" +# pragma message( "WARNING: This header(" __FILE__ ") uses the __FUNCTION__ macro, which is not supported by this compiler. A default definition(\"" __FUNCTION__ "\") will be used!" ) +# pragma message( "WARNING: This header(" __FILE__ ") uses inheritance for exception classes. However this compiler can't handle this correctly. Trying to catch a specific exception by writing a catch block for a base class will not work!" ) +# endif // #if _MSC_VER < 1300 +# pragma warning( disable : 4512 ) // 'assignment operator could not be generated' (reason: assignment operators declared 'private' but not implemented) +#endif // #ifdef _MSC_VER + +#ifndef WRAP_ANY +# include +#endif // #ifdef WRAP_ANY + +// C-API header will be imported into mvIMPACT::acquire::display if included from here +#include +#ifdef MVIMPACT_ACQUIRE_H_ +# include +# if defined(CPP_STANDARD_VERSION) && (CPP_STANDARD_VERSION >= 11) +# include +# endif // #if defined(CPP_STANDARD_VERSION) && (CPP_STANDARD_VERSION >= 11) +#endif // #ifdef MVIMPACT_ACQUIRE_H_ + +#if defined(MVIMPACT_ACQUIRE_HELPER_H) && (!defined(CPP_STANDARD_VERSION) || ( defined(CPP_STANDARD_VERSION) && (CPP_STANDARD_VERSION < 11))) +# error "Combining the mvIMPACT_acquire_helper.h and mvIMPACT_acquire_display.h requires 'CPP_STANDARD_VERSION' being defined and set to a minimal value of 11! See documentation of the class mvIMPACT::acquire::helper::RequestProvider for details." +#endif // #if defined(MVIMPACT_ACQUIRE_HELPER_H) && (!defined(CPP_STANDARD_VERSION) || ( defined(CPP_STANDARD_VERSION) && (CPP_STANDARD_VERSION < 11))) + +namespace mvIMPACT +{ +namespace acquire +{ +/// \namespace mvIMPACT::acquire::display This namespace contains classes and functions that can be used to display images. +namespace display +{ + +/// \defgroup Display Display functions +/// \brief Classes and functions that can be used to display images. +/** + * This group contains classes and functions that can be used to display images. + */ +/// @{ + +class ImageDisplayWindow; + +//----------------------------------------------------------------------------- +/// \brief A class that can be used for displaying images within existing windows or GUI elements that can provide a window handle. +/** + * Instances of this class can be associated with an existing window object of + * which the window handle is known and can be passed to the constructor of this + * class. + * + * \image html Display_Window.png + * + * The full client area of a window will be consumed by a display object. Where the actual image shall be display relative + * to the upper left corner of the windows client area can be defined by calling \b mvIMPACT::acquire::display::ImageDisplay::SetDisplayRectangle(). This function + * will also limit the area where image data will be displayed. The area outside the display rectangle but within the + * windows client area can be filled by defining a background brush and then attach this brush to the display by calling + * \b mvIMPACT::acquire::display::ImageDisplay::SetBackgroundBrush(). + * + * If the actual image size differs from the area defined by \b mvIMPACT::acquire::display::ImageDisplay::SetDisplayRectangle(), it depends on the display mode + * if the complete image is scaled, cropped of just drawn in the top left corner of the display rectangle. The display mode + * can be modified by calling \b mvIMPACT::acquire::display::ImageDisplay::SetDisplayMode(). + * + * In addition to that only a part of the actual image can be selected for drawing by the function \b mvIMPACT::acquire::display::ImageDisplay::SetBitmapRectangle(). + * For this region the same scaling and cropping regions will be applied then. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \note + * This class can be used without using the rest of %mvIMPACT Acquire. This is achieved by using a pre-processor check + * for the presence of a certain include guard that is defined by %mvIMPACT Acquire. Now in order to be able to use those + * functions, that can directly work on data types as defined by %mvIMPACT Acquire, the main %mvIMPACT Acquire header + * must be included \b BEFORE including this header: + * + * \code + * #include + * #include + * \endcode + * \endif + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay::SetDisplayRectangle(),
+ * mvIMPACT::acquire::display::ImageDisplay::SetBitmapRectangle(),
+ * mvIMPACT::acquire::display::ImageDisplay::SetBackgroundBrush(),
+ * mvIMPACT::acquire::display::ImageDisplay::SetDisplayMode()
+ */ +class ImageDisplay +//----------------------------------------------------------------------------- +{ + friend class ImageDisplayWindow; + TDisp* pDisp_; + bool boMustFree_; +#if defined(MVIMPACT_ACQUIRE_H_) +# if defined( CPP_STANDARD_VERSION ) && ( CPP_STANDARD_VERSION >= 11 ) + std::shared_ptr pCurrentRequest_; +# endif // #if defined( CPP_STANDARD_VERSION ) && ( CPP_STANDARD_VERSION >= 11 ) +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + explicit ImageDisplay() : pDisp_( 0 ), boMustFree_( false ) {} +public: + /// \brief Create a new object that can be used for displaying images + explicit ImageDisplay( + /// A handle to the window which should be used for the displaying. + WindowHandle hwnd ) : pDisp_( 0 ), boMustFree_( true ) + { + pDisp_ = mvDispInit( hwnd ); + } + /// \brief Frees the resources previously allocated. + ~ImageDisplay() + { + if( boMustFree_ ) + { + mvDispDeinit( &pDisp_ ); + } + } + /// \brief Clears the display. + /** + * Either the windows default background will be displayed afterwards or if a + * background brush has been defined the background brush will be used to fill + * the complete client area. + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay::SetBackgroundBrush() + */ + void Clear( void ) const + { + mvDispClear( pDisp_ ); + } + /// \brief Sets the position and dimension of bitmap data region. + /** + * This defines the area relative within the area consumed by the window associated with + * the window handle that is bound to this display. See \b mvIMPACT::acquire::display::ImageDisplay for a detailed + * description on how to define the different rectangles and areas for drawing. + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay
+ * mvIMPACT::acquire::display::ImageDisplay::SetDisplayRectangle()
+ */ + void SetBitmapRectangle( + /// [in] The left offset of the rectangle. + int left, + /// [in] The top offset of the rectangle. + int top, + /// [in] The width of the bitmap rectangle. + int width, + /// [in] The height of the rectangle. + int height ) + { + mvDispSetBitmapRectangle( pDisp_, left, top, width, height ); + } + /// \brief Defines the rectangle used for drawing within the window associated with the display structure. + /** + * This function can be used to define a rectangle within the defined window + * Only this then will be used for drawing. This window can be smaller than the image + * defined by \b mvIMPACT::acquire::display::ImageDisplay::SetImage(). Then just a part of the image + * will be displayed when in \b mvIMPACT::acquire::display::DM_Fastest or the whole image will be scaled + * down to fit into the rectangle when in \b mvIMPACT::acquire::display::DM_Default mode. + * + * When the display rectangle is larger than the image the image will be placed in the lower left + * corner of the display rectangle (either scaled or unscaled). See \b ImageDisplay for a detailed + * description on how to define the different rectangles and areas for drawing. + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay,
+ * mvIMPACT::acquire::display::ImageDisplay::SetBitmapRectangle
+ */ + void SetDisplayRectangle( + /// [in] The left offset within the window. + int left, + /// [in] The top offset within the window. + int top, + /// [in] The width of the rectangle to use for drawing. + int width, + /// [in] The height of the rectangle to use for drawing. + int height ) + { + mvDispSetDisplayRectangle( pDisp_, left, top, width, height ); + } + /// \brief Gets the parameters of the current data block associated with the display. + /** + * If a parameter is not needed it might be 0(NULL). + * + * The data returned will always be in packed format. + */ + void GetImage( + /// [out] A pointer to a variable to receive the storage location of the pixel data. + /// This can be 0 if the value is not needed. + const void** ppData, + /// [out] A pointer to a variable to receive the width of the current image. + /// This can be 0 if the value is not needed. + int* pWidth, + /// [out] A pointer to a variable to receive the height of the current image. + /// This can be 0 if the value is not needed. + int* pHeight, + /// [out] A pointer to a variable to receive the bits per pixel of the current image. + /// This can be 0 if the value is not needed. + int* pBitsPerPixel, + /// [out] A pointer to a variable to receive the pitch (bytes per pixel * width in pixel)of the current image. + /// This can be 0 if the value is not needed. + int* pPitch ) + { + mvDispGetImage( pDisp_, ppData, pWidth, pHeight, pBitsPerPixel, pPitch ); + } + /// \brief Sets the next image to display. + /** + * This function can deal with RGB888x packed images, 8 bit grey-scale images + * and 16 bit Packed RGB images. For other formats overloaded versions of this function + * must be used. + */ + void SetImage( + /// [in] A pointer to the address of the pixel data. + const void* pData, + /// [in] The width of the image. + int width, + /// [in] The height of the image. + int height, + /// [in] The number of bits per pixel. + int bitsPerPixel, + /// [in] The pitch in bytes of one line of pixel data (bytes per pixel * width in pixel per line). + int pitch ) + { + mvDispSetImage( pDisp_, pData, width, height, bitsPerPixel, pitch ); + } + /// \brief Sets the next image to display. + void SetImage( + /// [in] An array of pointers that point to the actual image data + /// For planar RGB images e.g. this can be 3 pointers each pointing + /// to one color plane. + const void** ppData, + /// [in] The number of pointers passed via \a ppData. + size_t ppDataArraySize, + /// [in] The pixel format as defined by \b mvIMPACT::acquire::display::TFormatFlags. + TFormatFlags format, + /// [in] The width of the image. + int width, + /// [in] The height of the image. + int height, + /// [in] The number of bits per pixel. + int bitsPerPixel, + /// [in] The pitch in bytes of one line of pixel data (bytes per pixel * width in pixel per line). + int pitch ) + { + mvDispSetImageEx( pDisp_, ppData, ppDataArraySize, format, width, height, bitsPerPixel, pitch ); + } +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + /// \brief Sets the next image to display. + /** + * This function can deal with any pixel format supported by %mvIMPACT Acquire. + */ + void SetImage( + /// [in] The image buffer object that shall be displayed. + const mvIMPACT::acquire::ImageBuffer* pBuf ) + { + mvDispSetImageFromImageBuffer( pDisp_, pBuf ); + } + /// \brief Sets the next image to display. + /** + * This function can deal with any pixel format supported by %mvIMPACT Acquire. + */ + void SetImage( + /// [in] The \b mvIMPACT::acquire::Request object whose image data shall be displayed. + const mvIMPACT::acquire::Request* pRequest ) + { + mvDispSetImageFromRequest( pDisp_, pRequest ); + } +# if (defined( CPP_STANDARD_VERSION ) && ( CPP_STANDARD_VERSION >= 11 )) || defined(DOXYGEN_CPP_DOCUMENTATION) + /// \brief Sets the next image to display. + /** + * This function can deal with any pixel format supported by %mvIMPACT Acquire. + */ + void SetImage( + /// [in] The \b mvIMPACT::acquire::Request object whose image data shall be displayed. + std::shared_ptr pRequest ) + { + pCurrentRequest_ = pRequest; + mvDispSetImageFromRequest( pDisp_, pRequest.get() ); + } +# endif // #if (defined( CPP_STANDARD_VERSION ) && ( CPP_STANDARD_VERSION >= 11 )) || defined(DOXYGEN_CPP_DOCUMENTATION) +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + /// \brief Removes the current image from the display. + /** + * This function will remove the current image attached to the display from the display again. + * This is mainly meant to be able to free the memory associated with the image buffer without the risk that a + * later call to an update function or a repaint message would cause another redraw of then + * freed memory. As only one buffer can be attached to a display at any given time calling + * \b mvIMPACT::acquire::display::ImageDisplay::SetImage will effectively remove the previous + * image as well so this function usually is only needed when ending e.g. a live display. + */ + void RemoveImage( void ) + { + mvDispSetImage( pDisp_, 0, 0, 0, 0, 0 ); +#if defined(MVIMPACT_ACQUIRE_H_) +# if defined( CPP_STANDARD_VERSION ) && ( CPP_STANDARD_VERSION >= 11 ) + pCurrentRequest_.reset(); +# endif // #if defined( CPP_STANDARD_VERSION ) && ( CPP_STANDARD_VERSION >= 11 ) +#endif // #if defined(MVIMPACT_ACQUIRE_H_) + } + /// \brief Immediately redraws the current image. + void Update( void ) const + { + mvDispUpdate( pDisp_ ); + } + /// \brief Returns the current display mode. + /** + * Valid display modes are defined by \b mvIMPACT::acquire::display::TDisplayMode. + * \return + * The current display mode. + */ + TDisplayMode GetDisplayMode( void ) const + { + return mvDispGetDisplayMode( pDisp_ ); + } + /// \brief Switches to a different display mode. + void SetDisplayMode( + /// [in] The new display mode. + TDisplayMode mode ) + { + mvDispSetDisplayMode( pDisp_, mode ); + } + /// \brief Gets the current interpolation mode that will be used for scaling if display window rectangle is different to input image rectangle. + /** + * Valid interpolation modes are defined by \b mvIMPACT::acquire::display::TInterpolationMode. + * \return The current interpolation mode. + */ + TInterpolationMode GetInterpolationMode( void ) const + { + return mvDispGetInterpolationMode( pDisp_ ); + } + /// \brief Sets the new interpolation mode that will be used for scaling if display window rectangle is different to input image rectangle. + void SetInterpolationMode( + /// [in] The new interpolation mode. + TInterpolationMode mode ) + { + mvDispSetInterpolationMode( pDisp_, mode ); + } + /// \brief Returns the current shift value as defined by the application. + /** + * This function returns the current shift value as defined by the application by previous + * calls to \b mvIMPACT::acquire::display::ImageDisplay::SetShift. See \b mvIMPACT::acquire::display::ImageDisplay::SetShift for a detailed explanation + * about the display behaviour when applying custom shift values. + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay::SetShift,
+ * mvIMPACT::acquire::display::ImageDisplay::GetAppliedShift
+ * \since 2.4.0 + * \return The current shift value from previous calls to \b mvIMPACT::acquire::display::ImageDisplay::SetShift. + */ + int GetShift( void ) const + { + return mvDispGetShift( pDisp_ ); + } + /// \brief Sets the shift value that shall be subtracted from the shift value needed to display the 8 msb of a pixel. + /** + * This function will allow to select which 8 bits out of a multi-byte pixel format shall be displayed the + * next time \b mvIMPACT::acquire::display::ImageDisplay::Update is called. When the \a shift value is 0 the 8 msb of each pixel will be displayed + * so e.g. for a 12 bit format bits 11 to 4 will be displayed by default. + * + * Consider the typical layout of 12 mono pixel data in memory: + * + * \image html Mono12_01.png + * + * So with an application defined \a shift value of 0 (the default), the display module will shift each + * 2 byte pixel by 4 positions to the right. This will remove the 4 lsb from the data. Afterwards the now + * empty upper byte of each pixel is removed from the data resulting in the following memory layout which is + * then displayed on the canvas: + * + * \image html Mono12_02.png + * + * Now sometimes it is required to display other bits from the image e.g. for analysis purposes. As most operating + * systems only support to display 8 bits per color component this requires to select a different range of pixels to + * be send to the canvas. This can be done by calling this function and passing a custom \a shift value to it. The + * custom \a shift value will be subtracted from the value that would be needed to display the 8 msb for a given format. + * + * So to display the 8 lsb for a 12 bit mono format, \a shift must be set to 4. This then results in the display module to + * use a actual shift value of 4(required to display the 8 msb) - 4(defined by calling this function) = 0. Then removing + * the upper byte from each pixel results in only the 8 lsb of each pixel being displayed. + * + * When e.g. setting \a shift to 3 for a 12 bit mono for would result in bits 8 - 1 to be displayed: + * + * \image html Mono12_03.png + * + * The shift value that has actually been applied the last time an image has been displayed (thus '1' when taking the + * example in the image above (4(required) - 3(defined))) can be queried by calling \b mvIMPACT::acquire::display::ImageDisplay::GetAppliedShift. + * + * \note + * During the conversion from a multi-byte to a single byte format the pixel data will be clipped to 255 if + * a pixel value is larger than what can be stored in a single byte after the shift operation. + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay::GetShift,
+ * mvIMPACT::acquire::display::ImageDisplay::GetAppliedShift
+ * \since 2.4.0 + */ + void SetShift( + /// [in] The shift value to apply to the displayed images. The maximum value for + /// this function is 8, the minimum 0. Values out of this range will be ignored. + /// It is \b NOT possible to shift pixel data in such a way that less than 8 bits contain valid + /// data, thus e.g. a shift value of 2 applied to 8 bit mono data will be ignored. + int shift ) + { + mvDispSetShift( pDisp_, shift ); + } + /// \brief Returns the current shift value that has been applied to the last image that has been displayed. + /** + * This function returns the shift value that has been applied to the last image that has been displayed. + * See \b mvIMPACT::acquire::display::ImageDisplay::SetShift for a detailed explanation about the display behaviour when applying custom shift values. + * + * \sa + * mvIMPACT::acquire::display::ImageDisplay::SetShift,
+ * mvIMPACT::acquire::display::ImageDisplay::GetShift
+ * \since 2.4.0 + * \return The current shift value that has been applied to the last image that has been displayed. + */ + int GetAppliedShift( void ) const + { + return mvDispGetAppliedShift( pDisp_ ); + } + /// \brief Returns the last error and clears it. + /** + * If an error has occurred it will not be overwritten by subsequent + * errors till the error is queried and cleared. After calling this + * function a second call would return \b mvIMPACT::acquire::display::IDE_NoError until another error + * occurs. + * + * \return The last error + */ + int GetLastError( void ) const + { + return mvDispGetError( pDisp_ ); + } + /// \brief Returns the current window handle associated with the display object. + /** + * Returns the current window handle associated with the display object. + * \return The current window handle associated with the display object. + */ + WindowHandle GetWindowHandle( void ) const + { + return mvDispGetWindowHandle( pDisp_ ); + } + /// \brief Assigns a new destination window handle to a display object. + void SetWindowHandle( + /// [in] The handle of the new destination window. + WindowHandle hwnd ) + { + mvDispSetWindowHandle( pDisp_, hwnd ); + } + /// \brief Associates a brush to be used for painting the background within the client area. + /** + * See \b mvDispInit() for a detailed description on which regions will be painted using + * the background brush. + * + * \warning This only stores the handle to the brush object, not the actual brush, so + * as long as this handle is set and the display object is used, the referenced + * brush must \b NOT be deleted again. + */ + void SetBackgroundBrush( + /// [in] Handle to the brush to be used to paint the background. + /// This brush then will be used to paint the regions of the rectangle + /// used for drawing that will not painted with the image itself. + BrushHandle hBrush ) + { + mvDispSetBackgroundBrush( pDisp_, hBrush ); + } + /// \brief Defines the key color for the DirectDraw® overlay + void SetDDrawOverlayKeyColor( + /// [in] The key color to be used for the DirectDraw® overlay. + ColorValue keyColor ) + { + mvDispSetDDrawOverlayKeyColor( pDisp_, keyColor ); + } +#ifndef WRAP_ANY + /// \brief Installs an overlay callback function. + /** + * This function will be called when operated in \b mvIMPACT::acquire::display::DM_Default mode + * and can be used to draw a user defined overlay on top of the image before it + * is displayed. + */ + void SetOverlayCallbackFunction( + /// [in] The address of the function to be called for a user + /// defined overlay + TImageDisplayOverlayFunction fctOverlay, + /// [in] A pointer to a user defined parameter + void* pUserParam ) + { + mvDispSetOverlayCallbackFunction( pDisp_, fctOverlay, pUserParam ); + } +#endif // #ifndef WRAP_ANY +}; + +//----------------------------------------------------------------------------- +/// \brief A class that can be used to display images in a window. +/** + * Every instance of this class will create and display its own independent window. + * Internally it uses an instance of mvIMPACT::acquire::display::ImageDisplay + * to display image data. The internal display object can be accessed by calling + * mvIMPACT::acquire::display::ImageDisplayWindow::GetImageDisplay(). + */ +class ImageDisplayWindow +//----------------------------------------------------------------------------- +{ + HDISP hDisp_; + ImageDisplay imageDisplay_; + + ImageDisplayWindow( const ImageDisplayWindow& ); // do not allow copy constructor + ImageDisplayWindow& operator=( const ImageDisplayWindow& ); // do not allow assignments +public: + /// \brief Creates a new window that can be used to display image data and displays it. + /** + * This is an example of how to use the GetImageDisplay class. + * More details about this example. + */ + explicit ImageDisplayWindow( + /// [in] The title of the window (will be displayed in the windows title bar). + const std::string& title ) : hDisp_( 0 ) + { + hDisp_ = mvDispWindowCreate( title.c_str() ); + mvDispWindowShow( hDisp_ ); + imageDisplay_.pDisp_ = mvDispWindowGetDisplayHandle( hDisp_ ); + } + /// \brief destroys the display window and frees resources. + ~ImageDisplayWindow() + { + mvDispWindowDestroy( hDisp_ ); + hDisp_ = 0; + } + /// \brief Returns a reference to the actual display object associated with this window. + ImageDisplay& GetImageDisplay( void ) + { + return imageDisplay_; + } + /// \brief Defines the refresh time in ms + /** + * This function can be used to define a refresh period that - when elapsed - + * will automatically repaint the window. + */ + void SetRefreshTime( + /// [in] The refresh period for the window in ms. Passing \a 0 will + /// disable the automatic repaint behaviour. + int time_ms ) + { + mvDispWindowSetRefreshTime( hDisp_, time_ms ); + } +#ifndef WRAP_ANY + /// \brief Installs a callback to handle the window messages. + /** + * \sa + * mvIMPACT::acquire::display::ImageDisplayWindow::GetMessageHandler() + */ + void SetMessageHandler( + /// [in] Pointer to a function which is called by the windows + /// procedure before the display update is done. + /// If zero is passed here even the internal default handler + /// will be disabled and \a WM_SIZE and \a WM_LBUTTONDBLCLK will no longer + /// be handled internally. + TPreProcessMessage handler ) + { + mvDispWindowSetMessageHandler( hDisp_, handler ); + } + /// \brief Returns the current message handler for this window. + /** + * \sa + * mvIMPACT::acquire::display::ImageDisplayWindow::SetMessageHandler() + * \return The current message handler for this window. + */ + TPreProcessMessage GetMessageHandler( void ) const + { + return mvDispWindowGetMessageHandler( hDisp_ ); + } +#endif // #ifndef WRAP_ANY // The concept of callback functions as used here is rather C/C++ specific. +}; + +/// @} + +} // namespace display +} // namespace acquire +} // namespace mvIMPACT + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifndef MVIMPACT_USE_NAMESPACES +using namespace mvIMPACT::acquire::display; +# endif // #ifndef MVIMPACT_USE_NAMESPACES +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#endif //MVIMPACT_ACQUIRE_DISPLAY_H_ diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire.h b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire.h new file mode 100644 index 0000000..f57199e --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire.h @@ -0,0 +1,24662 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MVIMPACT_ACQUIRE_H_ +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_ACQUIRE_H_ MVIMPACT_ACQUIRE_H_ +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#ifdef SWIG +# ifdef SWIGPYTHON +# ifndef WRAP_PYTHON +# define WRAP_PYTHON +# endif +# endif +# ifdef SWIGJAVA +# ifndef WRAP_JAVA +# define WRAP_JAVA +# endif +# endif +#endif + +#ifdef WRAP_PYTHON +# ifndef PYTHON_ONLY +# define PYTHON_ONLY(X) X +# endif +# ifndef PYTHON_CPP_SWITCH +# define PYTHON_CPP_SWITCH(PYTHON_WRAPPER_CODE,CPP_WRAPPER_CODE) PYTHON_WRAPPER_CODE +# endif +# ifndef WRAP_ANY +# define WRAP_ANY +# endif // #ifndef WRAP_ANY +#else // #ifdef WRAP_PYTHON +# ifndef PYTHON_ONLY +# define PYTHON_ONLY(X) +# endif +# ifndef PYTHON_CPP_SWITCH +# define PYTHON_CPP_SWITCH(PYTHON_WRAPPER_CODE,CPP_WRAPPER_CODE) CPP_WRAPPER_CODE +# endif +#endif // #ifdef WRAP_PYTHON + +#ifdef WRAP_JAVA +# ifndef JAVA_ONLY +# define JAVA_ONLY(X) X +# endif +# ifndef JAVA_CPP_SWITCH +# define JAVA_CPP_SWITCH(JAVA_WRAPPER_CODE,CPP_WRAPPER_CODE) JAVA_WRAPPER_CODE +# endif +# ifndef WRAP_ANY +# define WRAP_ANY +# endif // #ifndef WRAP_ANY +#else // #ifdef WRAP_JAVA +# ifndef JAVA_ONLY +# define JAVA_ONLY(X) +# endif +# ifndef JAVA_CPP_SWITCH +# define JAVA_CPP_SWITCH(JAVA_WRAPPER_CODE,CPP_WRAPPER_CODE) CPP_WRAPPER_CODE +# endif +#endif // #ifdef WRAP_JAVA + +#if defined(WRAP_PYTHON) || defined(WRAP_JAVA) +# ifndef PYTHON_OR_JAVA_ONLY +# define PYTHON_OR_JAVA_ONLY(X) X +# endif +#else +# ifndef PYTHON_OR_JAVA_ONLY +# define PYTHON_OR_JAVA_ONLY(X) +# endif +#endif // #if defined(WRAP_PYTHON) || defined(WRAP_JAVA) + +#if !defined(MVIMPACT_DEPRECATED_CPP) +# ifdef WRAP_ANY +# define MVIMPACT_DEPRECATED_CPP(FUNCTION) +# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__ ) >= 301) // is at least GCC 3.1 compiler? +# define MVIMPACT_DEPRECATED_CPP(FUNCTION) FUNCTION __attribute__ ((deprecated)) +# elif defined(_MSC_VER) +# if _MSC_VER >= 1310 // is at least VC 2003 compiler? +# define MVIMPACT_DEPRECATED_CPP(FUNCTION) __declspec(deprecated) FUNCTION +# else +# define MVIMPACT_DEPRECATED_CPP(FUNCTION) FUNCTION +# endif // #if _MSC_VER >= 1310 +# else +# define MVIMPACT_DEPRECATED_CPP(FUNCTION) FUNCTION +# endif // compiler check +#endif // #if !defined(MVIMPACT_DEPRECATED_CPP) + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) +# ifdef _MSC_VER // is Microsoft compiler? +# pragma warning( push ) +# if _MSC_VER < 1300 // is 'old' VC 6 compiler? +# pragma warning( disable : 4786 ) // 'identifier was truncated to '255' characters in the debug information' +# define MVIA_FUNCTION "No function name information as the __FUNCTION__ macro is not supported by this(VC 6) compiler" +# pragma message( "WARNING: This header(" __FILE__ ") uses the __FUNCTION__ macro, which is not supported by this compiler. A default definition(\"" MVIA_FUNCTION "\") will be used!" ) +# pragma message( "WARNING: This header(" __FILE__ ") uses inheritance for exception classes. However this compiler can't handle this correctly. Trying to catch a specific exception by writing a catch block for a base class will not work!" ) +# else +# define MVIA_FUNCTION __FUNCTION__ +# endif // #if _MSC_VER < 1300 +# pragma warning( disable : 4512 ) // 'assignment operator could not be generated' (reason: assignment operators declared 'private' but not implemented) +# elif defined(__BORLANDC__) // is Borland compiler? +# pragma option push -b // force enums to the size of integer +# define MVIA_FUNCTION __FUNC__ +# else +# define MVIA_FUNCTION __FUNCTION__ +# endif // #ifdef _MSC_VER +#endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + +#ifndef WRAP_ANY +# include +# include +# include +# include +# include +# include +# include +# ifdef __BORLANDC__ // is Borland compiler? +# include // Borland has own ideas about where 'memset' should be defined... +# endif // #ifdef __BORLANDC__ +# include +# include +# include +# include +# include +# include +# include +#endif // #ifdef WRAP_ANY + +#ifndef WRAP_ANY +# ifdef MVIMPACT_H_ +namespace mvIMPACT +{ +// needed to keep the C-header working +using mvIMPACT_C::IPL_BUFHANDLE; +} // namespace mvIMPACT +# endif // #ifdef MVIMPACT_H_ +#endif // #ifndef WRAP_ANY + +// C-API header will be imported into mvIMPACT::acquire if included from here +#include + +namespace mvIMPACT +{ +/// \namespace mvIMPACT::acquire This namespace contains classes and functions belonging to the image acquisition module of this SDK. +namespace acquire +{ + +/// \defgroup CommonInterface Common +/// \brief Classes and functions that are available for all interface layouts. +/// +/// This group contains classes and functions that are available for all interface layouts. +/// +/// @{ + +// predeclares +#ifndef DOXYGEN_SHOULD_SKIP_THIS +class CameraDescriptionManager; +class CameraSettingsBlueCOUGAR; +class CameraSettingsBlueFOX; +class ComponentList; +class ComponentLocator; +class Device; +class DigitalInput; +class DigitalOutput; +# ifndef WRAP_ANY +class EventSubSystem; +# endif // #ifndef WRAP_ANY +class HDRControl; +class IOSubSystem; +class ImageProcessing; +class ImageRequestControl; +class Request; +class RTCtrProgram; +class RTCtrProgramStep; +class WhiteBalanceSettings; +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + +#ifdef MVIMPACT_H_ +//----------------------------------------------------------------------------- +/// \brief A base class for exceptions generated by mvIMPACT Acquire. +/** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a mvIMPACT.h has been included before including this interface, this class will + * be derived from \b mvIMPACT::ImpactException, which is derived from \b std::runtime_error. + * If this interface is used without the rest of the \b mvIMPACT library, this class + * will be derived directly from \b std::runtime_error, but apart from that will provide the + * same interface and class layout. + * \endif +*/ +class ImpactAcquireException : public mvIMPACT::ImpactException +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::ImpactAcquireException object. + explicit ImpactAcquireException( + /// [in] The string representation of the error. + const std::string& errorString, + /// [in] The origin of the error (function name and line) + const std::string& errorOrigin, + /// [in] The numerical representation of the error. + int errorCode ) : ImpactException( errorString, errorOrigin, errorCode ) {} + virtual ~ImpactAcquireException() throw() {} + /// \brief Returns a string representation of the error associated with the exception. + /** + * This function will return the name of the enum of the error code. + * + * \b EXAMPLE + * + * In case of error \b -2102 this function would return \b mvIMPACT::acquire::DMR_DRV_ALREADY_IN_USE, which + * is the error codes corresponding enum name. + */ + std::string getErrorCodeAsString( void ) const + { + return DMR_ErrorCodeToString( getErrorCode() ); + } + /// \brief Returns a string representation of a error. + /** + * This function will return the name of the enum of the error code. + * + * \b EXAMPLE + * + * In case of error \b -2102 this function would return \b mvIMPACT::acquire::DMR_DRV_ALREADY_IN_USE, which + * is the error codes corresponding enum name. + */ + static std::string getErrorCodeAsString( + /// [in] The error code to query a string representation for. + int errorCode ) + { + return DMR_ErrorCodeToString( errorCode ); + } +}; +#else +//----------------------------------------------------------------------------- +/// \brief A base class for exceptions generated by mvIMPACT Acquire. +class ImpactAcquireException : public std::runtime_error +//----------------------------------------------------------------------------- +{ + const int m_errorCode; + const std::string m_errorOrigin; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::ImpactAcquireException object. + explicit ImpactAcquireException( + /// [in] The string representation of the error. + const std::string& errorString, + /// [in] The origin of the error (function name and line) + const std::string& errorOrigin, + /// [in] The numerical representation of the error. + int errorCode ) : std::runtime_error( errorString ), m_errorCode( errorCode ), m_errorOrigin( errorOrigin ) {} + virtual ~ImpactAcquireException() throw() {} + /// \brief Returns an error string containing information about the reason for the error. + std::string getErrorString( void ) const + { + return what(); + } + /// \brief Returns a unique numerical representation for this error. + int getErrorCode( void ) const + { + return m_errorCode; + } + /// \brief Returns a string representation of the error associated with the exception. + /** + * This function will return the name of the enum of the error code. + * + * \b EXAMPLE + * + * In case of error \b -2102 this function would return \b mvIMPACT::acquire::DMR_DRV_ALREADY_IN_USE, which + * is the error codes corresponding enum name. + */ + std::string getErrorCodeAsString( void ) const + { + return DMR_ErrorCodeToString( m_errorCode ); + } + /// \brief Returns a string representation of a error. + /** + * This function will return the name of the enum of the error code. + * + * \b EXAMPLE + * + * In case of error \b -2102 this function would return \b mvIMPACT::acquire::DMR_DRV_ALREADY_IN_USE, which + * is the error codes corresponding enum name. + */ + static std::string getErrorCodeAsString( + /// [in] The error code to query a string representation for. + int errorCode ) + { + return DMR_ErrorCodeToString( errorCode ); + } + /// \brief Returns information about the origin of the error. + /** + * The string returned by this function will contain the name of the function + * and the line number where the exception was raised. + */ + std::string getErrorOrigin( void ) const + { + return m_errorOrigin; + } +}; +#endif // #ifdef MVIMPACT_H_ + +//----------------------------------------------------------------------------- +/// \brief A base class for device manager related exceptions. +class EDeviceManager : public ImpactAcquireException +//----------------------------------------------------------------------------- +{ +public: + /// \brief Creates a new \b mvIMPACT::acquire::EDeviceManager object. + explicit EDeviceManager( + /// [in] The error string. + const std::string& errorString, + /// [in] The error origin. + const std::string& errorOrigin, + /// [in] The error code. + TDMR_ERROR errorCode ) : ImpactAcquireException( errorString, errorOrigin, errorCode ) {} + virtual ~EDeviceManager() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief A base class for exceptions related to the property module. +/** + * This exception object will only be raised if an unknown error occurred. + * To check for errors related to the property module a catch block for + * \b mvIMPACT::acquire::EPropertyHandling objects can be written to catch all property module related + * exceptions. + */ +class EPropertyHandling : public ImpactAcquireException +//----------------------------------------------------------------------------- +{ +public: + /// \brief Creates a new \b mvIMPACT::acquire::EPropertyHandling object. + explicit EPropertyHandling( + /// [in] The error string. + const std::string& errorString, + /// [in] The error origin. + const std::string& errorOrigin, + /// [in] The error code. + TPROPHANDLING_ERROR errorCode ) : ImpactAcquireException( errorString, errorOrigin, errorCode ) {} + virtual ~EPropertyHandling() throw() {} +}; + +//----------------------------------------------------------------------------- +// COMPONENT EXCEPTION CLASSES : +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// \brief A base class for \b mvIMPACT::acquire::Component object related exceptions from the property module. +/** + * This exception object will never be raised in the code. It can't be constructed + * directly but to check for \b mvIMPACT::acquire::Component related errors a catch block for + * \b mvIMPACT::acquire::EComponent objects can be written to catch all \b mvIMPACT::acquire::Component related + * exceptions. + */ +class EComponent : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +protected: + /// \brief Creates a new \b mvIMPACT::acquire::EComponent object. + explicit EComponent( + /// [in] The error string. + const std::string& errorString, + /// [in] The error origin. + const std::string& errorOrigin, + /// [in] The error code. + TPROPHANDLING_ERROR errorCode ) : EPropertyHandling( errorString, errorOrigin, errorCode ) {} + virtual ~EComponent() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_NOT_A_LIST error. +class ENotAList : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit ENotAList( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "Component '" + msg + "' is not a list. Unable to perform list operation" : msg, errorOrigin, PROPHANDLING_NOT_A_LIST ) {} + virtual ~ENotAList() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_NOT_A_PROPERTY error. +class ENotAProperty : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit ENotAProperty( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "Component '" + msg + "' is not a property. Unable to perform property operation" : msg, errorOrigin, PROPHANDLING_NOT_A_PROPERTY ) {} + virtual ~ENotAProperty() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_NOT_A_METHOD error. +class ENotAMethod : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit ENotAMethod( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "Component '" + msg + "' is not a method. Unable to perform function call operation" : msg, errorOrigin, PROPHANDLING_NOT_A_METHOD ) {} + virtual ~ENotAMethod() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_NO_READ_RIGHTS error. +class ENoReadRights : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit ENoReadRights( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "No read rights for component '" + msg + "'" : msg, errorOrigin, PROPHANDLING_NO_READ_RIGHTS ) {} + virtual ~ENoReadRights() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_NO_WRITE_RIGHTS error. +class ENoWriteRights : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit ENoWriteRights( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "No write rights for component '" + msg + "'" : msg, errorOrigin, PROPHANDLING_NO_WRITE_RIGHTS ) {} + virtual ~ENoWriteRights() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_NO_MODIFY_SIZE_RIGHTS error. +class ENoModifySizeRights : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit ENoModifySizeRights( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "Component '" + msg + "'s size is fixed and therefore cannot be modified" : msg, errorOrigin, PROPHANDLING_NO_MODIFY_SIZE_RIGHTS ) {} + virtual ~ENoModifySizeRights() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_INCOMPATIBLE_COMPONENTS error. +class EIncompatibleComponents : public EComponent +//----------------------------------------------------------------------------- +{ +public: + explicit EIncompatibleComponents( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EComponent( boMsgIsNameOnly ? "Component '" + msg + "' has been compared with an incompatible type (might differ in components, size, etc.)" : msg, errorOrigin, PROPHANDLING_INCOMPATIBLE_COMPONENTS ) {} + virtual ~EIncompatibleComponents() throw() {} +}; + +//----------------------------------------------------------------------------- +// PROPERTY EXCEPTION CLASSES : +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// \brief A base class for \b mvIMPACT::acquire::Property related exceptions from the property module. +/** + * This exception object will never be raised in the code. It can't be constructed + * directly but to check for \b mvIMPACT::acquire::Property related errors a catch block for + * \b mvIMPACT::acquire::EProperty objects can be written to catch all \b mvIMPACT::acquire::Property related + * exceptions. + */ +class EProperty : public EComponent +//----------------------------------------------------------------------------- +{ +protected: + /// \brief Creates a new \b mvIMPACT::acquire::EProperty object. + explicit EProperty( + /// [in] The error string. + const std::string& errorString, + /// [in] The error origin. + const std::string& errorOrigin, + /// [in] The error code. + TPROPHANDLING_ERROR errorCode ) : EComponent( errorString, errorOrigin, errorCode ) {} + virtual ~EProperty() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_INVALID_PROP_VALUE error. +class EInvalidValue : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit EInvalidValue( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EProperty( boMsgIsNameOnly ? "Invalid value for property '" + msg + "'" : msg, errorOrigin, PROPHANDLING_INVALID_PROP_VALUE ) {} + virtual ~EInvalidValue() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_PROP_VAL_ID_OUT_OF_BOUNDS error. +class EValIDOutOfBounds : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit EValIDOutOfBounds( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EProperty( boMsgIsNameOnly ? "Value ID out of bounds for property '" + msg + "'" : msg, errorOrigin, PROPHANDLING_PROP_VAL_ID_OUT_OF_BOUNDS ) {} + virtual ~EValIDOutOfBounds() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_PROP_TRANSLATION_TABLE_CORRUPTED error. +class ETranslationTableCorrupted : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit ETranslationTableCorrupted( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EProperty( boMsgIsNameOnly ? "The translation dictionary of property '" + msg + "' is corrupted" : msg, errorOrigin, PROPHANDLING_PROP_TRANSLATION_TABLE_CORRUPTED ) {} + virtual ~ETranslationTableCorrupted() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_PROP_TRANSLATION_TABLE_NOT_DEFINED error. +class ETranslationTableNotDefined : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit ETranslationTableNotDefined( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EProperty( boMsgIsNameOnly ? "Translation dictionary has not been defined for property '" + msg + "'" : msg, errorOrigin, PROPHANDLING_PROP_TRANSLATION_TABLE_NOT_DEFINED ) {} + virtual ~ETranslationTableNotDefined() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_INVALID_PROP_VALUE_TYPE error. +class EInvalidValueType : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit EInvalidValueType( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EProperty( boMsgIsNameOnly ? "Property '" + msg + "' does not support this value type" : msg, errorOrigin, PROPHANDLING_INVALID_PROP_VALUE_TYPE ) {} + virtual ~EInvalidValueType() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_PROP_VAL_TOO_LARGE error. +class EValTooLarge : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit EValTooLarge( const std::string& msg, const std::string& errorOrigin ) : EProperty( msg, errorOrigin, PROPHANDLING_PROP_VAL_TOO_LARGE ) {} + explicit EValTooLarge( const std::string& value, const std::string& maxValue, const std::string& propName, const std::string& errorOrigin ) : EProperty( "The value '" + value + "' is larger than the maximum value(" + maxValue + ") for property '" + propName + "'", errorOrigin, PROPHANDLING_PROP_VAL_TOO_LARGE ) {} + virtual ~EValTooLarge() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_PROP_VAL_TOO_SMALL error. +class EValTooSmall : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit EValTooSmall( const std::string& msg, const std::string& errorOrigin ) : EProperty( msg, errorOrigin, PROPHANDLING_PROP_VAL_TOO_SMALL ) {} + explicit EValTooSmall( const std::string& value, const std::string& minValue, const std::string& propName, const std::string& errorOrigin ) : EProperty( "The value'" + value + "' is smaller than the minimum value(" + minValue + ") for property '" + propName + "'", errorOrigin, PROPHANDLING_PROP_VAL_TOO_SMALL ) {} + virtual ~EValTooSmall() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_PROP_VALIDATION_FAILED error. +class EValidationFailed : public EProperty +//----------------------------------------------------------------------------- +{ +public: + explicit EValidationFailed( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EProperty( boMsgIsNameOnly ? "The assigned value doesn't pass the validation test for property '" + msg + "'" : msg, errorOrigin, PROPHANDLING_PROP_VALIDATION_FAILED ) {} + virtual ~EValidationFailed() throw() {} +}; + +//----------------------------------------------------------------------------- +// PROPERTYLIST EXCEPTION CLASSES : +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// \brief A base class for component list related exceptions from the property module. +/** + * This exception object will never be raised in the code. It can't be constructed + * directly but to check for component list related errors a catch block for + * \b mvIMPACT::acquire::EPropertyList objects can be written to catch all exceptions related + * to lists and list operations. + */ +class EPropertyList : public EComponent +//----------------------------------------------------------------------------- +{ +protected: + /// \brief Creates a new \b mvIMPACT::acquire::EPropertyList object. + explicit EPropertyList( + /// [in] The error string. + const std::string& errorString, + /// [in] The error origin. + const std::string& errorOrigin, + /// [in] The error code. + TPROPHANDLING_ERROR errorCode ) : EComponent( errorString, errorOrigin, errorCode ) {} + virtual ~EPropertyList() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_COMPONENT_NOT_FOUND error. +class EComponentNotFound : public EPropertyList +//----------------------------------------------------------------------------- +{ +public: + explicit EComponentNotFound( const std::string& msg, const std::string& errorOrigin ) : EPropertyList( msg, errorOrigin, PROPHANDLING_COMPONENT_NOT_FOUND ) {} + virtual ~EComponentNotFound() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_LIST_ENTRY_OCCUPIED error. +class EListEntryOccupied : public EPropertyList +//----------------------------------------------------------------------------- +{ +public: + explicit EListEntryOccupied( const std::string& errorOrigin ) : EPropertyList( "List entry occupied already", errorOrigin, PROPHANDLING_LIST_ENTRY_OCCUPIED ) {} + virtual ~EListEntryOccupied() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_COMPONENT_ID_INVALID error. +class EComponentIDInvalid : public EPropertyList +//----------------------------------------------------------------------------- +{ +public: + explicit EComponentIDInvalid( const std::string& errorOrigin ) : EPropertyList( "Invalid component ID", errorOrigin, PROPHANDLING_COMPONENT_ID_INVALID ) {} + virtual ~EComponentIDInvalid() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_LIST_ID_INVALID error. +class EInvalidListID : public EPropertyList +//----------------------------------------------------------------------------- +{ +public: + explicit EInvalidListID( const std::string& errorOrigin ) : EPropertyList( "Invalid property list ID", errorOrigin, PROPHANDLING_LIST_ID_INVALID ) {} + explicit EInvalidListID( const std::string& msg, const std::string& errorOrigin ) : EPropertyList( msg, errorOrigin, PROPHANDLING_LIST_ID_INVALID ) {} + virtual ~EInvalidListID() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_LIST_CANT_ACCESS_DATA error. +class ECantAccessData : public EPropertyList +//----------------------------------------------------------------------------- +{ +public: + explicit ECantAccessData( const std::string& msg, const std::string& errorOrigin, bool boMsgIsPathOnly = true ) : EPropertyList( boMsgIsPathOnly ? "Cannot access data from '" + msg + "'" : msg, errorOrigin, PROPHANDLING_LIST_CANT_ACCESS_DATA ) {} + virtual ~ECantAccessData() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_CANT_REGISTER_COMPONENT error. +class ECantRegisterComponent : public EPropertyList +//----------------------------------------------------------------------------- +{ +public: + explicit ECantRegisterComponent( const std::string& errorOrigin ) : EPropertyList( "Cannot register component in the current list.", errorOrigin, PROPHANDLING_CANT_REGISTER_COMPONENT ) {} + explicit ECantRegisterComponent( const std::string& msg, const std::string& errorOrigin ) : EPropertyList( msg, errorOrigin, PROPHANDLING_CANT_REGISTER_COMPONENT ) {} + virtual ~ECantRegisterComponent() throw() {} +}; + +//----------------------------------------------------------------------------- +// METHOD EXCEPTION CLASSES : +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// \brief A base class for \b mvIMPACT::acquire::Method object related exceptions from the property module. +/** + * This exception object will never be raised in the code. It can't be constructed + * directly but to check for \b mvIMPACT::acquire::Method object related errors a catch block for + * \b mvIMPACT::acquire::EMethod objects can be written to catch only \b Method related exceptions. + */ +class EMethod : public EComponent +//----------------------------------------------------------------------------- +{ +protected: + /// \brief Creates a new \b mvIMPACT::acquire::EMethod object. + explicit EMethod( + /// [in] The error string. + const std::string& errorString, + /// [in] The error origin. + const std::string& errorOrigin, + /// [in] The error code. + TPROPHANDLING_ERROR errorCode ) : EComponent( errorString, errorOrigin, errorCode ) {} + virtual ~EMethod() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_METHOD_PTR_INVALID error. +class EMethodPtrInvalid : public EMethod +//----------------------------------------------------------------------------- +{ +public: + explicit EMethodPtrInvalid( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EMethod( boMsgIsNameOnly ? "The function pointer for Method '" + msg + "' is invalid" : msg, errorOrigin, PROPHANDLING_METHOD_PTR_INVALID ) {} + virtual ~EMethodPtrInvalid() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_METHOD_INVALID_PARAM_LIST error. +class EInvalidParameterList : public EMethod +//----------------------------------------------------------------------------- +{ +public: + explicit EInvalidParameterList( const std::string& errorOrigin ) : EMethod( "The functions parameter list is invalid", errorOrigin, PROPHANDLING_METHOD_INVALID_PARAM_LIST ) {} + explicit EInvalidParameterList( const std::string& msg, const std::string& errorOrigin ) : EMethod( msg, errorOrigin, PROPHANDLING_METHOD_INVALID_PARAM_LIST ) {} + virtual ~EInvalidParameterList() throw() {} +}; + +//----------------------------------------------------------------------------- +// PROPERTYHANDLING EXCEPTION CLASSES : +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_UNSUPPORTED_PARAMETER error. +class EUnsupportedParameter : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EUnsupportedParameter( const std::string& errorOrigin ) : EPropertyHandling( "Unsupported parameter", errorOrigin, PROPHANDLING_UNSUPPORTED_PARAMETER ) {} + virtual ~EUnsupportedParameter() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_SIZE_MISMATCH error. +class ESizeMismatch : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit ESizeMismatch( const std::string& errorString, const std::string& errorOrigin ) : EPropertyHandling( errorString, errorOrigin, PROPHANDLING_SIZE_MISMATCH ) {} + virtual ~ESizeMismatch() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_IMPLEMENTATION_MISSING error. +class EImplementationMissing : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EImplementationMissing( const std::string& errorOrigin ) : EPropertyHandling( "This feature has not been implemented so far", errorOrigin, PROPHANDLING_IMPLEMENTATION_MISSING ) {} + explicit EImplementationMissing( const std::string& msg, const std::string& errorOrigin ) : EPropertyHandling( msg, errorOrigin, PROPHANDLING_IMPLEMENTATION_MISSING ) {} + virtual ~EImplementationMissing() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_INVALID_INPUT_PARAMETER error. +class EInvalidInputParameter : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EInvalidInputParameter( const std::string& errorOrigin ) : EPropertyHandling( "One or more of the input parameters are invalid (unassigned pointers?)", errorOrigin, PROPHANDLING_INVALID_INPUT_PARAMETER ) {} + explicit EInvalidInputParameter( const std::string& msg, const std::string& errorOrigin ) : EPropertyHandling( msg, errorOrigin, PROPHANDLING_INVALID_INPUT_PARAMETER ) {} + virtual ~EInvalidInputParameter() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_INPUT_BUFFER_TOO_SMALL error. +class EInputBufferTooSmall : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EInputBufferTooSmall( const std::string& errorOrigin ) : EPropertyHandling( "The user supplied input buffer was too small for the result", errorOrigin, PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) {} + virtual ~EInputBufferTooSmall() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_WRONG_PARAM_COUNT error. +class EWrongParamCount : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EWrongParamCount( const std::string& errorOrigin ) : EPropertyHandling( "Wrong parameter count", errorOrigin, PROPHANDLING_WRONG_PARAM_COUNT ) {} + explicit EWrongParamCount( const std::string& msg, const std::string& errorOrigin ) : EPropertyHandling( msg, errorOrigin, PROPHANDLING_WRONG_PARAM_COUNT ) {} + virtual ~EWrongParamCount() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_UNSUPPORTED_OPERATION error. +class EUnsupportedOperation : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EUnsupportedOperation( const std::string& errorOrigin ) : EPropertyHandling( "This component does not support this operation", errorOrigin, PROPHANDLING_UNSUPPORTED_OPERATION ) {} + virtual ~EUnsupportedOperation() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_CANT_SERIALIZE_DATA error. +class ECantSerializeData : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit ECantSerializeData( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EPropertyHandling( boMsgIsNameOnly ? "No serialize rights for list '" + msg + "'" : msg, errorOrigin, PROPHANDLING_CANT_SERIALIZE_DATA ) {} + virtual ~ECantSerializeData() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_INVALID_FILE_CONTENT error. +class EInvalidFileContent : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit EInvalidFileContent( const std::string& msg, const std::string& errorOrigin, bool boMsgIsNameOnly = true ) : EPropertyHandling( boMsgIsNameOnly ? "The file '" + msg + "' does not contain valid data for this operation" : msg, errorOrigin, PROPHANDLING_INVALID_FILE_CONTENT ) {} + virtual ~EInvalidFileContent() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief An exception thrown in case of a \b mvIMPACT::acquire::PROPHANDLING_CANT_ALLOCATE_LIST error. +class ECantAllocateNewList : public EPropertyHandling +//----------------------------------------------------------------------------- +{ +public: + explicit ECantAllocateNewList( const std::string& errorOrigin ) : EPropertyHandling( "Cannot allocate a new list until an old one has been deleted", errorOrigin, PROPHANDLING_CANT_ALLOCATE_LIST ) {} + virtual ~ECantAllocateNewList() throw() {} +}; + +//----------------------------------------------------------------------------- +/// \brief A factory class to raise mvIMPACT acquire related exceptions. +/** + * This class contains a collection of static member functions that are used inside the + * interface to raise the appropriate exception in case of an error + */ +class ExceptionFactory +//----------------------------------------------------------------------------- +{ +public: + /// \brief Returns the last error string that did occur inside the framework within the current thread. + /** + * \return The last error string that did occur inside the framework within the current thread. + */ + static std::string getLastErrorString( void ) + { + size_t stringSize = 0; + TDMR_ERROR lastError = DMR_NO_ERROR; + TDMR_ERROR result = DMR_GetLastError( &lastError, 0, &stringSize ); + if( result != DMR_NO_ERROR ) + { + return ""; + } + char* pStringBuffer = new char[stringSize]; + result = DMR_GetLastError( &lastError, pStringBuffer, &stringSize ); + const std::string errorString( ( result == DMR_NO_ERROR ) ? pStringBuffer : "" ); + delete [] pStringBuffer; + return errorString; + } + /// \brief Raises an exception from an error code, its origin in terms of the function name and the line number the error did occur and an optional component handle. + static void raiseException( + /// [in] The name of the function this exception was raised from. + const char* pFunctionName, + /// [in] The line number in the source this exception was raised from. + int lineNumber, + /// [in] The error code. + int errorCode, + /// [in] A handle to an object. + HOBJ objectHandle = INVALID_ID ); + /// \brief Raises an exception from an error code, its origin in terms of the function name and the line number the error did occur and an exception string. + static void raiseException( + /// [in] The name of the function this exception was raised from. + const char* pFunctionName, + /// [in] The line number in the source this exception was raised from. + int lineNumber, + /// [in] The error code. + TDMR_ERROR errorCode, + /// [in] The actual exception text. + const std::string& msg ) + { + std::ostringstream oss; + oss << pFunctionName << " (line: " << lineNumber << ")"; + throw EDeviceManager( msg, oss.str(), errorCode ); + } +}; + +#ifdef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_H_ // force doxygen to include mvIMPACT related functions +#endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + +//----------------------------------------------------------------------------- +/// \brief A base class to implement access to internal driver objects. +/** + * Instances of this class can't be constructed directly. + */ +class ComponentAccess +//----------------------------------------------------------------------------- +{ + friend class ComponentLocatorBase; +protected: + /// \brief An internal constant that defines by which factor dynamic buffers will grow when the current size is not sufficient. + enum { BUFFER_INCREMENT_FACTOR = 6 }; + /// \brief A unique identifier for the internal driver object referenced by this instance of \b mvIMPACT::acquire::ComponentAccess. + HOBJ m_hObj; + /// \brief A helper function to query certain component related string parameters. + /** + * This function might throw an exception, if an invalid parameter has been queried. + * \return A string containing the data to be queried. + */ + std::string compGetStringParam( /// The type of the parameter to read + TOBJ_StringQuery query, + /// [in] An additional parameter + int param1 = 0, + /// [in] An additional parameter + int param2 = 0 ) const + { + char* pStr = 0; + std::string stringParam; + const TPROPHANDLING_ERROR result = OBJ_GetSWithInplaceConstruction( m_hObj, query, &pStr, stringAllocator, param1, param2 ); + if( result == PROPHANDLING_NO_ERROR ) + { + if( pStr ) + { + stringParam = std::string( pStr ); + } + delete [] pStr; + } + else + { + delete [] pStr; + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return stringParam; + } + /// \brief Constructs a new \b mvIMPACT::acquire::ComponentAccess object to a driver object. + explicit ComponentAccess( + /// [in] A valid handle to a component object + HOBJ hObj ) : m_hObj( hObj ) + { + const TPROPHANDLING_ERROR result = OBJ_CheckHandle( m_hObj, hcmOwnerList ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + } + /// \brief Constructs a new unbound \b mvIMPACT::acquire::ComponentAccess object. + explicit ComponentAccess( void ) : m_hObj( INVALID_ID ) {} + /// \brief An internal helper function for fast string allocation. + static char* stringAllocator( const char* pBuf, size_t reqBufSize ) + { + char* pStr = new char[reqBufSize]; + mv_strncpy_s( pStr, pBuf, reqBufSize ); + return pStr; + } +public: + virtual ~ComponentAccess( void ) {} + /// \brief Constructs a new \b mvIMPACT::acquire::ComponentAccess from an existing one. + ComponentAccess( + /// [in] A constant reference to the \b mvIMPACT::acquire::ComponentAccess object, this object shall be created from + const ComponentAccess& src ) : m_hObj( src.m_hObj ) {} + /// \brief Allows implicit conversion to a HOBJ. + operator HOBJ() const + { + return m_hObj; + } + /// \brief Allows assignments of \b mvIMPACT::acquire::ComponentAccess objects. + ComponentAccess& operator=( const ComponentAccess& rhs ) + { + m_hObj = rhs.m_hObj; + return *this; + } + /// \brief Returns the current changed counter for the component referenced by this object. + /** + * This changed counter is incremented internally each time the component is modified. + * To check if this component has been modified since the last time, this check has been + * performed, keep track of the last return value of this function and compare + * it with the new value. This can be helpful e.g. to keep a GUI up to date. The value returned + * by this function will always be larger than or equal to the value returned by + * \b mvIMPACT::acquire::ComponentAccess::changedCounterAttr (except in case of a + * wrap around) when called at the same time for the same object as it's always incremented + * when the component has been modified in + * any way while the latter one will only be incremented if the attributes (e.g. the + * flags) but \b NOT if e.g. the value(s) of a property has been modified. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * struct ComponentRef + * //----------------------------------------------------------------------------- + * { + * mvIMPACT::acquire::Component c_; + * unsigned int lastChangedCount_; + * ComponentRef( mvIMPACT::acquire::Component c ) : c_( c ), lastChangedCount_( 0 ) {} + * }; + * + * //----------------------------------------------------------------------------- + * void fn( ComponentRef& cr ) + * //----------------------------------------------------------------------------- + * { + * if( cr.c_.isValid() ) + * { + * const unsigned int currentChangedCount = cr.c_.changedCounter(); + * if( currentChangedCount != cr.lastChangedCount_ ) + * { + * // something has happened since the last check! + * doWhatNeedsToBeDone(); + * // and remember the current changed counter + * cr.lastChangedCount_ = currentChangedCount; + * } + * } + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * public class ComponentRef + * //----------------------------------------------------------------------------- + * { + * private Component c_; + * private long lastChangedCount_; + * public ComponentRef( Component c ) : c_( c ), lastChangedCount_( 0 ) {} + * public Component getComponent() + * { + * return c_; + * } + * public long getLastChangedCounter() + * { + * return lastChangedCount_; + * } + * public void setLastChangedCounter( long changedCounter ) + * { + * lastChangedCount_ = lastChangedCount; + * } + * } + * + * // ...more code, class definition etc. + * + * //----------------------------------------------------------------------------- + * public static void fn( ComponentRef cr ) + * //----------------------------------------------------------------------------- + * { + * if( cr.c_.isValid() ) + * { + * final long currentChangedCount = cr.getComponent().changedCounter(); + * if( currentChangedCount != cr.getLastChangedCounter() ) + * { + * // something has happened since the last check! + * doWhatNeedsToBeDone(); + * // and remember the current changed counter + * cr.setLastChangedCounter( currentChangedCount ); + * } + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * class ComponentRef + * def __init__(self, c): + * self.c_ = c + * self.lastChangedCount_ = 0 + * + * def fn(cr): + * if cr.c_.isValid: + * currentChangedCount = cr.c_.changedCounter() + * if currentChangedCount != cr.lastChangedCount_: + * # something has happened since the last check! + * doWhatNeedsToBeDone() + * # and remember the current changed counter + * cr.lastChangedCount_ = currentChangedCount + * \endcode + * \endif + * + * \return The current changed counter of this object. + */ + unsigned int changedCounter( void ) const + { + unsigned int changedCounter; + const TPROPHANDLING_ERROR result = OBJ_GetChangedCounter( m_hObj, &changedCounter ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return changedCounter; + } + /// \brief Returns the current attribute changed counter for the component referenced by this object. + /** + * This changed counter is incremented internally each time the components attributes have been modified. + * To check if this components attributes have been modified since the last time, this check has been + * performed, keep track of the last return value of this function and compare + * it with the new value. This can be helpful e.g. to keep a GUI up to date. + * + * \note + * Attributes changes are e.g. a modification to a property's translation dictionary, + * but \b NOT a property's value. Because of this the value returned by this function + * will always be less or equal than the value returned by the function + * \b mvIMPACT::acquire::ComponentAccess::changedCounter (except in case of a + * wrap around) when called at the same time for the same object. + * \sa \b mvIMPACT::acquire::ComponentAccess::changedCounter + * \return The current attributes changed counter of this object. + */ + unsigned int changedCounterAttr( void ) const + { + unsigned int changedCounter; + const TPROPHANDLING_ERROR result = OBJ_GetChangedCounterAttr( m_hObj, &changedCounter ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return changedCounter; + } + /// \brief Returns a unique identifier for the component referenced by this object. + /** + * \return A unique identifier for the component referenced by this object. + */ + HOBJ hObj( void ) const + { + return m_hObj; + } + /// \brief Returns the name of the component referenced by this object. + /** + * \return The name of the component referenced by this object. + */ + std::string name( void ) const + { + return compGetStringParam( sqObjName ); + } + /// \brief Returns the display name of the component referenced by this object. + /** + * + * \since 1.11.20 + * + * \return The display name of the component referenced by this object. This might be an empty string if no display name has been specified. + */ + std::string displayName( void ) const + { + return compGetStringParam( sqObjDisplayName ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to implement access to internal driver components. +/** + * Objects of this class can be constructed directly even if nothing is known about the type + * of driver object we are referring to. This class acts as a base class to provide + * access to internal properties, methods and component lists offered by the driver. + * + * This object can be used to navigate through component lists of + * unknown content. + * + * Consider the following structure: + * + * \code + * LA + * |-LB + * |-LC + * | |-PE + * | |-PF + * | |-PG + * |-PD + * \endcode + * + * Where the prefix 'L' means this is a list, 'P' that this is a property. + * Assuming that we have and iterator referencing list 'C', calling \b mvIMPACT::acquire::Component::firstChild + * e.g. would return a new iterator referencing object 'PE', while calling \b mvIMPACT::acquire::Component::nextSibling + * would have returned a reference to 'PD' and \b mvIMPACT::acquire::Component::parent would have + * returned a reference to object 'LA'. + * + * \b "EXAMPLE 1": + * + * A new \b mvIMPACT::acquire::Component is created with the \a ID of list 'C': + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * Component it(ID_of_list_C); + * it = it.firstChild(); // now we are referencing 'PE' + * it = it.lastSibling(); // moves to 'PG' + * it = it.firstSibling(); // moves back to PE' + * it = it.nextSibling(); // moves to 'PF' + * it = it.firstSibling(); // moves back to PE' + * it = it.parent(); // we are referencing 'LC' again + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * Component it = new Component(ID_of_list_C); + * it = it.firstChild(); // now we are referencing 'PE' + * it = it.lastSibling(); // moves to 'PG' + * it = it.firstSibling(); // moves back to PE' + * it = it.nextSibling(); // moves to 'PF' + * it = it.firstSibling(); // moves back to PE' + * it = it.parent(); // we are referencing 'LC' again + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * it = acquire.Component(ID_of_list_C); + * it = it.firstChild() # now we are referencing 'PE' + * it = it.lastSibling() # moves to 'PG' + * it = it.firstSibling() # moves back to PE' + * it = it.nextSibling() # moves to 'PF' + * it = it.firstSibling() # moves back to PE' + * it = it.parent() # we are referencing 'LC' again + * \endcode + * \endif + * + * \b "EXAMPLE 2": + * + * Iterate over a complete list including sub lists. This will result in a list + * of all lists and properties that reside in the list the iterator currently + * is moving through to be written to the standard output. The name of the component + * and every parent component will be printed into the standard output: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * void ParseList( Component iter, const string& path = "" ) + * //----------------------------------------------------------------------------- + * { + * while( iter.isValid() ) + * { + * if( iter.isVisible() ) + * { + * if( iter.isList() ) + * { + * // do some list specific stuff + * cout << "List " << path << iter.name() << "/" << endl; + * // move down into the list and append its name to the path + * ParseList( iter.firstChild(), path + iter.name() + "/" ); + * } + * else if( iter.isProp() ) + * { + * // do property specific stuff e.g. read the value + * Property prop( iter ); + * cout << "Property " << path << prop.name() << "(value(s): "; + * unsigned int valCount = prop.valCount(); + * for( unsigned int i=0; i size_t queryFeatureCount( _FnQuery pFnQuery ) const + //----------------------------------------------------------------------------- + { + size_t featureCount = 0; + const TPROPHANDLING_ERROR result = pFnQuery( m_hObj, 0, 0, &featureCount ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return featureCount; + } + //----------------------------------------------------------------------------- + template size_t queryFeatures( std::vector& v, _FnQuery pFnQuery ) const + //----------------------------------------------------------------------------- + { + v.clear(); + size_t featureCount = queryFeatureCount( pFnQuery ); + if( featureCount > 0 ) + { + std::vector buf; + buf.resize( featureCount ); + const TPROPHANDLING_ERROR result = pFnQuery( m_hObj, 0, &( *( buf.begin() ) ), &featureCount ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + v.resize( featureCount ); + for( size_t i = 0; i < featureCount; i++ ) + { + v[i] = Component( buf[i] ); + } + } + return static_cast( v.size() ); + } + //----------------------------------------------------------------------------- + template HOBJ queryFeature( _FnQuery pFnQuery, int index ) const + //----------------------------------------------------------------------------- + { + HOBJ hObj; + size_t featureCount = 1; + const TPROPHANDLING_ERROR result = pFnQuery( m_hObj, index, &hObj, &featureCount ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return hObj; + } + //----------------------------------------------------------------------------- + template std::string queryAsString( _FnQuery pFnQuery ) const + //----------------------------------------------------------------------------- + { + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pBuf( bufSize ); + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = pFnQuery( m_hObj, pBuf.get(), bufSize ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pBuf.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pBuf.get() ); + } +public: + /// \brief Constructs a new access object to a driver object. + explicit Component( + /// [in] A valid handle to a component object + HOBJ hObj ) : ComponentAccess( hObj ) {} + /// \brief Constructs a new unbound access object. + explicit Component( void ) {} + /// \brief Constructs a new \b mvIMPACT::acquire::Component from an existing one. + Component( + /// [in] A constant reference to the \b mvIMPACT::acquire::Component object, this object shall be created from + const Component& src ) : ComponentAccess( src ) {} + /// \brief Moves to the next sibling(the next feature in the current list of features). + /** + * \return A self reference + */ + Component& operator++( void ) // prefix + { + HOBJ nextSibling; + const TPROPHANDLING_ERROR result = OBJ_GetNextSibling( m_hObj, &nextSibling ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + m_hObj = nextSibling; + return *this; + } + /// \brief Moves to the next sibling(the next feature in the current list of features). + /** + * \return A new \b mvIMPACT::acquire::Component object + */ + Component operator++( int ) // postfix + { + Component temp( *this ); + ++*this; + return temp; + } + /// \brief Allows assignments of \b mvIMPACT::acquire::Component objects. + Component& operator=( const Component& rhs ) + { + ComponentAccess::operator=( rhs ); + return *this; + } + /// \brief Moves to the first sibling(the first feature in the current list of features). + /** + * \return A new \b mvIMPACT::acquire::Component object + */ + Component firstSibling( void ) const + { + HOBJ hNew = INVALID_ID; + const TPROPHANDLING_ERROR result = OBJ_GetFirstSibling( m_hObj, &hNew ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return ( hNew != INVALID_ID ) ? Component( hNew ) : Component(); + } + /// \brief Moves to the last sibling(the last feature in the current list of features). + /** + * + * \since 1.10.64 + * + * \return A new \b mvIMPACT::acquire::Component object + */ + Component lastSibling( void ) const + { + HOBJ hNew = INVALID_ID; + const TPROPHANDLING_ERROR result = OBJ_GetLastSibling( m_hObj, &hNew ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return ( hNew != INVALID_ID ) ? Component( hNew ) : Component(); + } + /// \brief Moves to the next sibling(the next feature in the current list of features). + /** + * \return A new \b mvIMPACT::acquire::Component object + */ + Component nextSibling( void ) + { + return ++*this; + } + /// \brief Moves to the first child of this component(moves down one level). + /** + * Calling this function will only succeed, if the current \b mvIMPACT::acquire::Component + * references a list. + * + * \return A new \b mvIMPACT::acquire::Component object + */ + Component firstChild( void ) const + { + HOBJ hNew = INVALID_ID; + const TPROPHANDLING_ERROR result = OBJ_GetFirstChild( m_hObj, &hNew ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return ( hNew != INVALID_ID ) ? Component( hNew ) : Component(); + } + /// \brief Moves to the parent of this component(moves up one level). + /** + * \return A new \b mvIMPACT::acquire::Component object + */ + Component parent( void ) const + { + HOBJ hNew = INVALID_ID; + const TPROPHANDLING_ERROR result = OBJ_GetParent( m_hObj, &hNew ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return ( hNew != INVALID_ID ) ? Component( hNew ) : Component(); + } + /// \brief Returns a string containing general information about the component referenced by this object. + /** + * \return A string containing general information about the component referenced by this object. + */ + std::string docString( void ) const + { + return compGetStringParam( sqObjDocString ); + } + /// \brief Returns the flags associated with this component. + /** + * \return The flags associated with this component. + */ + TComponentFlag flags( void ) const + { + TComponentFlag flags; + const TPROPHANDLING_ERROR result = OBJ_GetFlags( m_hObj, &flags ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return flags; + } + /// \brief Returns the flags associated with this component as a string. + /** + * \return The flags associated with this component as a string. + */ + std::string flagsAsString( + /// [in] A user definable string to separate the individual flags. The default value is ' | ' resulting in the string to look e.g. like this: 'cfWriteAccess | cfReadAccess' + const std::string& separator = " | " ) const + { + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pBuf( bufSize ); + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetFlagsS( m_hObj, separator.c_str(), pBuf.get(), pBuf.parCnt() ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pBuf.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pBuf.get() ); + } + /// \brief Checks if this component is currently referencing the default for this component. + /** + * This function will return true only for derived components that have not been modified. + * \return + * - true if the component is currently set to its default value + * - false otherwise. + */ + bool isDefault( void ) const + { + unsigned int isDefault; + const TPROPHANDLING_ERROR result = OBJ_IsDefault( m_hObj, &isDefault ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return isDefault != 0; + } + /// \brief Checks if this component is of type \b mvIMPACT::acquire::ComponentList. + /** + * \return + * - true if the component references a list + * - false otherwise + */ + bool isList( void ) const + { + return ( type() & ctList ) != 0; + } + /// \brief Checks if this component is of type \b mvIMPACT::acquire::Method. + /** + * \return + * - true if the component references a method + * - false otherwise + */ + bool isMeth( void ) const + { + return ( type() & ctMeth ) != 0; + } + /// \brief Checks if this component is of type \b mvIMPACT::acquire::Property or a derived type. + /** + * \return + * - true if the component references a property + * - false otherwise + */ + bool isProp( void ) const + { + return ( type() & ctProp ) != 0; + } + /// \brief Checks if the internal component referenced by this object is still valid. + /** + * This function can be used to verify whether a referenced component + * is still valid or not. When e.g. referencing a driver property after + * \b mvIMPACT::acquire::Device::close has been called this function would return false. + * Calling any other function that tries to access the referenced component + * in that case would raise an exception. + * \return + * - true if this object currently references a valid component + * - false otherwise. + */ + bool isValid( void ) const + { + return OBJ_CheckHandle( m_hObj, hcmFull ) == PROPHANDLING_NO_ERROR; + } + /// \brief Checks if the component is currently shadowed due to a settings made elsewhere or not. + /** + * Settings applied to certain components might affect the behaviour of others. For example + * an activated automatic gain control might shadow the value written to the + * gain property by the user as the gain is calculated internally. In order to + * check if modifying the actual component will affect the behaviour of the + * system this function may be used. When it returns \a true, the \b mvIMPACT::acquire::Component + * will have an impact on the system, if \a false is returned, the feature might be + * modified, but this will currently NOT influence the acquisition process or the overall behaviour + * of the device or driver. + * + * This is what is called visibility. The user still might modify or read the + * current \b mvIMPACT::acquire::Component when it's not visible however the actual data will + * be used only if the \b Component is visible (\b mvIMPACT::acquire::cfInvisible + * must \b NOT be set). + * + * The visibility of a \b mvIMPACT::acquire::Component object will change only if other + * \b mvIMPACT::acquire::Component objects are modified and \b NEVER when a program + * runs but does not change any \b mvIMPACT::acquire::Component. + */ + bool isVisible( void ) const + { + return ( flags() & cfInvisible ) == 0; + } + /// \brief Checks if the caller has write/modify access to the component. + /** + * \return + * - true if the caller is allowed to call write/modify operation for this component. + * - false otherwise. + */ + bool isWriteable( void ) const + { + return ( flags() & cfWriteAccess ) != 0; + } + /// \brief Restores the default for the referenced component. + /** + * Calling this function will restore the default value for the + * component referenced by this object. + * + * If this function is called for an object of type \b mvIMPACT::acquire::ComponentList + * every component in that list is restored to the default value. + * + * \note The caller must have the right to modify the component. Otherwise + * an exception will be thrown. + * + * \return A const reference to the component. + */ + const Component& restoreDefault( void ) const + { + const TPROPHANDLING_ERROR result = OBJ_RestoreDefault( m_hObj ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Returns the type of the referenced component. + /** + * \return The type of the referenced component. + */ + TComponentType type( void ) const + { + TComponentType type; + const TPROPHANDLING_ERROR result = OBJ_GetType( m_hObj, &type ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return type; + } + /// \brief Returns the type of the component referenced by \a hObj. + /** + * \return The type of the component referenced by \a hObj. + */ + static TComponentType type( + /// [in] The component the type shall be retrieved for + HOBJ hObj ) + { + return Component( hObj ).type(); + } + /// \brief Returns the type of the referenced component as a string. + /** + * \return The type of the referenced component as a string. + */ + std::string typeAsString( void ) const + { + return queryAsString( OBJ_GetTypeS ); + } + /// \brief Returns the recommended visibility for this component. + /** + * The visibility can be used e.g. to develop a GUI that displays a + * crucial subset of features only. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TComponentVisibility. + * \return The recommended visibility for this component. + */ + TComponentVisibility visibility( void ) const + { + TComponentVisibility visibility; + const TPROPHANDLING_ERROR result = OBJ_GetVisibility( m_hObj, &visibility ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return visibility; + } + /// \brief Returns the recommended visibility of the referenced component as a string. + /** + * \return The recommended visibility of the referenced component as a string. + */ + std::string visibilityAsString( void ) const + { + return queryAsString( OBJ_GetVisibilityS ); + } + /// \brief Returns the recommended visibility converted to a string. + /** + * \return The recommended visibility converted to a string. + */ + static std::string visibilityAsString( + /// [in] The visibility to query the string representation for + TComponentVisibility visibility ) + { + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pBuf( bufSize ); + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_VisibilityToString( visibility, pBuf.get(), bufSize ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pBuf.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return std::string( pBuf.get() ); + } + /// \brief Returns the recommended representation for this component. + /** + * The representation can be used e.g. to develop a GUI that creates convenient controls + * for certain features. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TComponentRepresentation. + * + * \since 2.14.0 + * + * \return The recommended representation for this component. + */ + TComponentRepresentation representation( void ) const + { + TComponentRepresentation representation; + const TPROPHANDLING_ERROR result = OBJ_GetRepresentation( m_hObj, &representation ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return representation; + } + /// \brief Returns the recommended representation of the referenced component as a string. + /** + * + * \since 2.14.0 + * + * \return The recommended representation of the referenced component as a string. + */ + std::string representationAsString( void ) const + { + return queryAsString( OBJ_GetRepresentationS ); + } + /// \brief Returns the recommended representation converted to a string. + /** + * + * \since 2.14.0 + * + * \return The recommended representation converted to a string. + */ + static std::string representationAsString( + /// [in] The representation to query the string representation for + TComponentRepresentation representation ) + { + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pBuf( bufSize ); + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_RepresentationToString( representation, pBuf.get(), bufSize ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pBuf.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return std::string( pBuf.get() ); + } + /// \brief Returns the number of features selected by the current one. + /** + * \sa + * \b mvIMPACT::acquire::Component::selectedFeatures, \n + * \b mvIMPACT::acquire::Component::selectedFeature + * + * \since 1.11.20 + * + * \return The number of features selected by the current one. + */ + unsigned int selectedFeatureCount( void ) const + { + return static_cast( queryFeatureCount( OBJ_GetSelectedFeatures ) ); + } + /// \brief Returns the number of features selecting the current one. + /** + * \sa + * \b mvIMPACT::acquire::Component::selectingFeatures, \n + * \b mvIMPACT::acquire::Component::selectingFeature + * + * \since 1.11.20 + * + * \return The number of features selecting the current one. + */ + unsigned int selectingFeatureCount( void ) const + { + return static_cast( queryFeatureCount( OBJ_GetSelectingFeatures ) ); + } + /// \brief Retrieves the list of components that are selected by the current one. + /** + * This function retrieves the list of components that are selected by + * the current one. This information is mainly useful for GUI applications that want to arrange + * features in a way that dependencies between features can easily been spotted. + * + * When a component 'selects' other components, this indicates that selected components may change whenever + * the selecting component changes. An example for a selector might be a property defining the index within + * a LUT while the value of a particular LUT entry could be a selected feature. Assuming 2 properties + * \a LUTIndex and \a LUTValue then changing \a LUTIndex will invalidate and possibly change \a LUTValue. + * + * \sa + * \b mvIMPACT::acquire::Component::selectedFeatureCount, \n + * \b mvIMPACT::acquire::Component::selectedFeature + * + * \since 1.11.20 + * + * \return The number of features selected by the current one. + */ + unsigned int selectedFeatures( + /// [out] An array that will retrieve the list of components that are selected by the current one. + std::vector& v ) const + { + return static_cast( queryFeatures( v, OBJ_GetSelectedFeatures ) ); + } + /// \brief Retrieves the list of components that are selecting the current one. + /** + * This function retrieves the list of components that are selecting + * the current one. This information is mainly useful for GUI applications that want to arrange + * features in a way that dependencies between features can easily been spotted. + * + * When a component 'selects' other components, this indicates that selected components may change whenever + * the selecting component changes. An example for a selector might be a property defining the index within + * a LUT while the value of a particular LUT entry could be a selected feature. Assuming 2 properties + * \a LUTIndex and \a LUTValue then changing \a LUTIndex will invalidate and possibly change \a LUTValue. + * + * \sa + * \b mvIMPACT::acquire::Component::selectingFeatureCount, \n + * \b mvIMPACT::acquire::Component::selectingFeature + * + * \since 1.11.20 + * + * \return The number of features selecting the current one. + */ + unsigned int selectingFeatures( + /// [out] An array that will retrieve the list of components that are selecting the current one. + std::vector& v ) const + { + return static_cast( queryFeatures( v, OBJ_GetSelectingFeatures ) ); + } + /// \brief Retrieves a component that is selected by the current one. + /** + * This function retrieves a component that is selected by the current one. + * This information is mainly useful for GUI applications that want to arrange + * features in a way that dependencies between features can easily been spotted. + * + * When a component 'selects' other components, this indicates that selected components may change whenever + * the selecting component changes. An example for a selector might be a property defining the index within + * a LUT while the value of a particular LUT entry could be a selected feature. Assuming 2 properties + * \a LUTIndex and \a LUTValue then changing \a LUTIndex will invalidate and possibly change \a LUTValue. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::Component::selectedFeatures to obtain this + * information. + * \endif + * + * To find out how many \b mvIMPACT::acquire::Component objects are selected by the current one call + * \b mvIMPACT::acquire::Component::selectedFeatureCount. This value minus 1 will also be the + * max. value for \a index. + * \sa + * \b mvIMPACT::acquire::Component::selectedFeatureCount, \n + * \b mvIMPACT::acquire::Component::selectedFeatures + * + * \since 1.11.20 + * + * \return A \b mvIMPACT::acquire::Component that is selected by the current one. + */ + Component selectedFeature( + /// [in] The index for the component to query. + unsigned int index ) const + { + return Component( queryFeature( OBJ_GetSelectedFeatures, static_cast( index ) ) ); + } + /// \brief Retrieves a component that is selecting the current one. + /** + * This function retrieves a component that is selecting the current one. + * This information is mainly useful for GUI applications that want to arrange + * features in a way that dependencies between features can easily been spotted. + * + * When a component 'selects' other components, this indicates that selected components may change whenever + * the selecting component changes. An example for a selector might be a property defining the index within + * a LUT while the value of a particular LUT entry could be a selected feature. Assuming 2 properties + * \a LUTIndex and \a LUTValue then changing \a LUTIndex will invalidate and possibly change \a LUTValue. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::Component::selectingFeatures to obtain this + * information. + * \endif + * + * To find out how many \b mvIMPACT::acquire::Component objects are selecting the current one call + * \b mvIMPACT::acquire::Component::selectingFeatureCount. This value minus 1 will also be the + * max. value for \a index. + * \sa + * \b mvIMPACT::acquire::Component::selectingFeatureCount, \n + * \b mvIMPACT::acquire::Component::selectingFeatures + * + * \since 1.11.20 + * + * \return A \b mvIMPACT::acquire::Component that is selecting the current one. + */ + Component selectingFeature( + /// [in] The index for the component to query. + unsigned int index ) const + { + return Component( queryFeature( OBJ_GetSelectingFeatures, static_cast( index ) ) ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A simple helper class to wrap the creation of a callback object. +/** + * Applications need to derive from this class and must re-implement the function + * \b mvIMPACT::acquire::ComponentCallback::execute. + * + * By deriving from this class it will become possible to receive a notification whenever + * an object derived from \b mvIMPACT::acquire::Component has changed. So e.g. an application + * could register a callback on the \b mvIMPACT::acquire::Device::state property to get + * notified when e.g. a certain device has been unplugged or restarted. + * + * \note + * A \c change is not necessarily a changed value of a property but also any other change + * in behaviour like a change in visibility or availability. So when a callback has been registered + * for a certain read-only component that becomes writable for some reason the registered + * callback would be executed as well. + * + * A single instance of an object derived from this class can hold an arbitrary number of + * components which are monitored. components can be registered by calling the \b mvIMPACT::acquire::ComponentCallback::registerComponent + * function, so it is not necessary to create and hold a callback instance for every feature that shall be + * monitored. Since when the callback is executed the information about the object that has + * triggered it will be supplied as one the input parameters it is easy to decide what has + * to be done. + * + * \attention + * Reading and understanding the documentation supplied with the \b mvIMPACT::acquire::ComponentCallback::execute function + * is vital to write error-free code! + * + * \warning + * It is \b NOT save to call \b mvIMPACT::acquire::ComponentCallback::registerComponent and \b mvIMPACT::acquire::ComponentCallback::unregisterComponent + * from parallel threads! If this is absolutely necessary appropriate synchronization code must be wrapped around these calls by the calling code! + * + * \since 1.12.18 + * + */ +class ComponentCallback +//----------------------------------------------------------------------------- +{ +#ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct CallbackUserData + //----------------------------------------------------------------------------- + { + void* pUserData_; + ComponentCallback* pCallback_; + explicit CallbackUserData() : pUserData_( 0 ), pCallback_( 0 ) {} + }; + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + CallbackHandle handle_; + CallbackUserData callbackUserData_; + std::set objectsRegistered_; + int m_refCnt; + explicit ReferenceCountedData() : handle_( 0 ), callbackUserData_(), objectsRegistered_(), m_refCnt( 1 ) {} + }* m_pRefData; +#endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS +#ifndef WRAP_ANY + //----------------------------------------------------------------------------- + static void DMR_CALL myCallback( HOBJ hObj, void* pUserData ) + //----------------------------------------------------------------------------- + { + Component c( hObj ); + CallbackUserData* p = reinterpret_cast( pUserData ); + p->pCallback_->execute( c, p->pUserData_ ); + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + OBJ_DeleteCallback( m_pRefData->handle_ ); + delete m_pRefData; + m_pRefData = 0; + } + } +#endif // #ifndef WRAP_ANY +public: + /// \brief Creates a new \b mvIMPACT::acquire::ComponentCallback instance. + explicit ComponentCallback( + /// [in] A pointer to user specific data bound to this callback. This data will + /// be passed back to the user whenever the callback function gets executed and can be used to attach + /// custom data to the callback function. + void* pUserData = 0 ) : m_pRefData( new ReferenceCountedData() ) + { + m_pRefData->callbackUserData_.pUserData_ = pUserData; + m_pRefData->callbackUserData_.pCallback_ = this; + const TPROPHANDLING_ERROR result = OBJ_CreateCallback( ctOnChanged, myCallback, &m_pRefData->callbackUserData_, &m_pRefData->handle_ ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief Copy constructor. + /** + * Creates a new object from an existing device object. Keep in mind that this new object + * will provide access to the very same objects. This constructor + * is only provided for internal reference counting to guarantee correct operation of the + * objects of this class under all platforms and languages. + */ + explicit ComponentCallback( const ComponentCallback& src ) : m_pRefData( src.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + /** + * This will automatically unregister all components still referencing this callback and will + * free all internal resources. + */ + virtual ~ComponentCallback() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::ComponentCallback objects. + ComponentCallback& operator=( const ComponentCallback& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++( m_pRefData->m_refCnt ); + } + return *this; + } + /// \brief Checks if a component is currently registered for this callback or not. + /** + * \return + * - true if the component currently is registered for this callback + * - false otherwise + */ + bool isComponentRegistered( + /// [in] The component that shall be tested against this callback + Component c ) const + { + return m_pRefData->objectsRegistered_.find( c.hObj() ) != m_pRefData->objectsRegistered_.end(); + } + /// \brief Registers a component for this callback. + /** + * \return + * - true if the component could be registered successfully for this callback. + * - false otherwise + */ + bool registerComponent( + /// [in] The component to register for this callback + Component c ) + { + if( isComponentRegistered( c ) ) + { + return false; + } + const TPROPHANDLING_ERROR result = OBJ_AttachCallback( c.hObj(), m_pRefData->handle_ ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + m_pRefData->objectsRegistered_.insert( c.hObj() ); + return true; + } + /// \brief Unregisters a component for this callback. + /** + * \return + * - true if the component could be unregistered successfully for this callback. + * - false otherwise + */ + bool unregisterComponent( + /// [in] The component to unregister from this callback + Component c ) + { + std::set::iterator it = m_pRefData->objectsRegistered_.find( c.hObj() ); + if( it == m_pRefData->objectsRegistered_.end() ) + { + return false; + } + const TPROPHANDLING_ERROR result = OBJ_DetachCallback( c.hObj(), m_pRefData->handle_ ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + m_pRefData->objectsRegistered_.erase( *it ); + return true; + } + /// \brief The callback function. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * \note + * Please note that this function will be executed within the thread context that is \b causing this callback, + * thus by any thread belonging to the internal device driver instance. There is a high chance that this is + * a different thread than any known to by the application, thus appropriate mechanisms to ensure + * correct execution must be implemented by an application(e.g. GUI applications might send an + * event to the main thread instead of directly accessing GUI elements from here). + * + * As each device driver instance internally creates multiple threads and since components can be modified by the + * driver framework from any of these threads, the thread context might in fact be different each time + * this function gets called. Accessing data from objects that are inherited from \b mvIMPACT::acquire::Component is + * thread safe so e.g. property values can be read out in parallel securely! + * However this 'execute' in a worst case (when several components have been registered to a single callback) might in + * fact be called in parallel so everything that happens in here should be designed accordingly! + * + * \attention + * It is \b NOT recommended to do time consuming stuff here! This function should be considered as something like an + * interrupt instead: Just take a note about what did just happen and leave. The calling thread will block until this + * function does return which might have all sorts of consequences if this takes a lot of time. In the worst case + * e.g. image data might get lost! + * + * \b GenICam \b event \b specific: + * When dealing with GenICam device events from a single device only within this callback + * due to the internal design it is guaranteed that this callback will NOT be executed in parallel + * since the device events will be received sequentially and will always be reported by the same + * (device driver instance related) thread! So when e.g. registering for changes to the following + * properties: + * - mvIMPACT::acquire::GenICam::EventControl::eventLine4RisingEdgeTimestamp + * - mvIMPACT::acquire::GenICam::EventControl::eventLine5RisingEdgeTimestamp + * - mvIMPACT::acquire::GenICam::EventControl::eventExposureEndTimestamp + * for a single device only then the following things are guaranteed: + * - The thread context used by the \b mvIMPACT::acquire::ComponentCallback::execute function will always be the same until the device is either closed or the connection is lost e.g. due to a reboot + * - \b mvIMPACT::acquire::ComponentCallback::execute function will \b NOT be called concurrently + * - The event property changes will be reported in the same order as generated by the device + */ + virtual void execute( + /// [in] The component that did cause the callback to be executed + Component& PYTHON_OR_JAVA_ONLY( c ), + /// [in] A pointer to user specific data that was bound to this callback instance + /// upon construction + void* PYTHON_OR_JAVA_ONLY( pUserData ) ) {} +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to locate components within the driver. +/** + * Every driver will offer a set of properties, methods and component lists. + * \b mvIMPACT::acquire::Property objects contain data such as the current gain in dB, the state of a + * digital input, etc.. \b mvIMPACT::acquire::Method objects can be executed like a normal function and + * \b mvIMPACT::acquire::ComponentList objects are used to group certain + * objects together to form a logical unit. + * + * When it's necessary to locate one or more of these objects without knowing + * exactly where to look for them this locator class can be used to look for the component. + */ +class ComponentLocatorBase : public ComponentAccess +//----------------------------------------------------------------------------- +{ + HLIST m_searchbase; +public: + /// \brief Constructs a new unbound locator. + explicit ComponentLocatorBase() : m_searchbase( INVALID_ID ) {} + /// \brief Constructs a new bound to the specified base list locator. + explicit ComponentLocatorBase( + /// [in] A unique identifier to the base list from where to start to search for + /// the search base. + HLIST baselist ) : ComponentAccess( baselist ), m_searchbase( baselist ) {} + /// \brief Constructs a new locator and searches the search base list. + explicit ComponentLocatorBase( + /// [in] A unique identifier to the base list from where to start to search for + /// the search base. + HLIST baselist, + /// [in] The name or path ('/' separated) to the search base. + const std::string& pathToSearchBase ) : ComponentAccess( baselist ), m_searchbase( INVALID_ID ) + { + bindSearchBase( baselist, pathToSearchBase ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::ComponentLocatorBase from an existing one. + ComponentLocatorBase( + /// [in] A constant reference to the \b mvIMPACT::acquire::ComponentLocatorBase object, this object shall be created from + const ComponentLocatorBase& src ) : ComponentAccess( src ), m_searchbase( src.m_searchbase ) {} + /// \brief Allows assignments of \b mvIMPACT::acquire::ComponentLocatorBase objects. + ComponentLocatorBase& operator=( const ComponentLocatorBase& rhs ) + { + ComponentAccess::operator=( rhs ); + m_searchbase = rhs.m_searchbase; + return *this; + } + /// \brief Binds an access object to an internal driver object. + /** + * \return + * - true if successful + * - false otherwise. In case false is returned by this function the component could not + * be bound, which means subsequent calls using \a access will fail or throw an exception. + */ + bool bindComponent( + /// [in,out] The access object to bind to the driver object. + Component& access, + /// [in] The path and/or name of the object to be located. + const std::string& name, + /// [in] Specifies how and what to search for. Valid flags(these flags can be combined using the '|' operator) for this parameter + /// are: + /// - smIgnoreLists + /// - smIgnoreMethods + /// - smIgnoreProperties + int searchMode = 0, + /// [in] The maximum depth (in lists) where to search for the component. + /// By e.g. setting this value to 2, the current list and all + /// its sub lists will be searched for the object, but no sublists + /// of sub lists. -1 will search in ALL sub lists. + int maxSearchDepth = INT_MAX ) const + { + access.m_hObj = findComponent( name, searchMode, maxSearchDepth ); + return access.isValid(); + } + /// \brief Assign a new search base to the locator. + /** + * This new search base will be searched starting from the base list specified. + * \return The unique identifier of the new search base. + */ + HLIST bindSearchBase( + /// [in] A unique identifier for the base list used to start searching the search base. + HLIST baselist, + /// [in] The name or path to the search base. + const std::string& pathToSearchBase = "" ) + { + if( pathToSearchBase.empty() ) + { + m_hObj = m_searchbase = baselist; + } + else + { + HLIST hList; + const TPROPHANDLING_ERROR result = OBJ_GetHandleEx( baselist, pathToSearchBase.c_str(), &hList, smIgnoreProperties | smIgnoreMethods, 0 ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, baselist ); + } + m_hObj = baselist; + m_searchbase = hList; + } + return m_searchbase; + } + /// \brief Tries to locate a certain component in a hierarchy of components. + /** + * \return A unique identifier to the component if found or \b mvIMPACT::acquire::INVALID_ID if the component couldn't + * be found. + */ + HOBJ findComponent( + /// [in] The path and/or name of the object to be located. + const std::string& name, + /// [in] Specifies how and what to search for. Valid flags(these flags can be combined using the '|' operator) for this parameter + /// are: + /// - smIgnoreLists + /// - smIgnoreMethods + /// - smIgnoreProperties + int searchMode = 0, + /// [in] The maximum depth (in lists) where to search for the component. + /// By e.g. setting this value to 2, the current list and all + /// its sub lists will be searched for the object, but no sublists + /// of sub lists. -1 will search in ALL sub lists. + int maxSearchDepth = INT_MAX ) const + { + HOBJ hObj; + const TPROPHANDLING_ERROR result = OBJ_GetHandleEx( m_searchbase, name.c_str(), &hObj, searchMode, maxSearchDepth ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_searchbase ); + } + return hObj; + } + /// \brief Returns the unique identifier of the base list from where to start searching for a component. + /** + * \return The unique identifier of the base list from where searching for a component will start currently. + */ + HLIST searchbase_id( void ) const + { + return m_searchbase; + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class to locate components within the driver. +/** + * Every driver will offer a set of properties, methods and component lists. + * \b mvIMPACT::acquire::Property objects contain data such as the current gain in dB, the state of a + * digital input, etc.. \b mvIMPACT::acquire::Method objects can be executed like a normal function and + * \b mvIMPACT::acquire::ComponentList objects are used to group certain + * objects together to form a logical unit. + * + * When it's necessary to locate one or more of these objects without knowing + * exactly where to look for them this locator class can be used to look for the component. + */ +class ComponentLocator : public ComponentLocatorBase +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound locator. + explicit ComponentLocator() : ComponentLocatorBase() {} + /// \brief Constructs a new bound to the specified base list locator. + explicit ComponentLocator( + /// [in] A unique identifier to the base list from where to start to search for + /// the search base. + HLIST baselist ) : ComponentLocatorBase( baselist ) {} + /// \brief Constructs a new locator and searches the search base list. + explicit ComponentLocator( + /// [in] A unique identifier to the base list from where to start to search for + /// the search base. + HLIST baselist, + /// [in] The name or path ('/' separated) to the search base. + const std::string& pathToSearchBase ) : ComponentLocatorBase( baselist, pathToSearchBase ) {} + /// \brief Constructs a new \b mvIMPACT::acquire::ComponentLocator from an existing one. + ComponentLocator( + /// [in] A constant reference to the \b mvIMPACT::acquire::ComponentLocator object, this object shall be created from + const ComponentLocator& src ) : ComponentLocatorBase( src ) {} + /// \brief Allows assignments of \b mvIMPACT::acquire::ComponentLocator objects. + ComponentLocator& operator=( const ComponentLocator& rhs ) + { + ComponentLocatorBase::operator=( rhs ); + return *this; + } +}; + +#if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +//----------------------------------------------------------------------------- +/// \brief A class to iterate over component lists. +/** + * \deprecated + * These days this class is just a typedef mapping the class mvIMPACT::acquire::Component to this type for + * compatibility reasons. New applications should work with the mvIMPACT::acquire::Component class instead. + * + * This object can be used to navigate through component lists of + * unknown content. + * + * Consider the following structure: + * + * \code + * LA + * |-LB + * |-LC + * | |-PE + * | |-PF + * | |-PG + * |-PD + * \endcode + * + * Where the prefix 'L' means that this is a list, 'P' that this is a property. + * Assuming that we have and iterator referencing list 'C', calling \b mvIMPACT::acquire::ComponentIterator::firstChild + * e.g. would return a new iterator referencing object 'PE', while calling \b mvIMPACT::acquire::ComponentIterator::nextSibling + * would have returned a reference to 'PD' and \b mvIMPACT::acquire::ComponentIterator::parent would have + * returned a reference to object 'LA'. + * + * \b "EXAMPLE 1": + * + * A new \b mvIMPACT::acquire::ComponentIterator is created with the \a ID of list 'C': + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * ComponentIterator it(ID_of_list_C); + * it = it.firstChild(); // now we are referencing 'PE' + * it = it.lastSibling(); // moves to 'PG' + * it = it.firstSibling(); // moves back to PE' + * it = it.nextSibling(); // moves to 'PF' + * it = it.firstSibling(); // moves back to PE' + * it = it.parent(); // we are referencing 'LC' again + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * ComponentIterator it = new ComponentIterator(ID_of_list_C); + * it = it.firstChild(); // now we are referencing 'PE' + * it = it.lastSibling(); // moves to 'PG' + * it = it.firstSibling(); // moves back to PE' + * it = it.nextSibling(); // moves to 'PF' + * it = it.firstSibling(); // moves back to PE' + * it = it.parent(); // we are referencing 'LC' again + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * it = acquire.ComponentIterator(ID_of_list_C); + * it = it.firstChild() # now we are referencing 'PE' + * it = it.lastSibling() # moves to 'PG' + * it = it.firstSibling() # moves back to PE' + * it = it.nextSibling() # moves to 'PF' + * it = it.firstSibling() # moves back to PE' + * it = it.parent() # we are referencing 'LC' again + * \endcode + * \endif + * + * \b "EXAMPLE 2": + * + * Iterate over a complete list including sub lists. This will result in a list + * of all lists and properties that reside in the list the iterator currently + * is moving through to be written to the standard output. The name of the component + * and every parent component will be printed into the standard output: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * void ParseList( ComponentIterator iter, const string& path = "" ) + * //----------------------------------------------------------------------------- + * { + * while( iter.isValid() ) + * { + * if( iter.isVisible() ) + * { + * if( iter.isList() ) + * { + * // do some list specific stuff + * cout << "List " << path << iter.name() << "/" << endl; + * // move down into the list and append its name to the path + * ParseList( iter.firstChild(), path + iter.name() + "/" ); + * } + * else if( iter.isProp() ) + * { + * // do property specific stuff e.g. read the value + * Property prop(iter); + * cout << "Property " << path << prop.name() << "(value(s): "; + * unsigned int valCount = prop.valCount(); + * for( unsigned int i=0; i& strings ) + { + const std::vector::size_type stringCount = strings.size(); + for ( std::vector::size_type i = 0; i < stringCount; i++ ) + { + if( strings[i].find( c ) != std::string::npos ) + { + return true; + } + } + return false; + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::Method object. + explicit Method( + /// [in] A valid handle to method object + HOBJ hMeth ) : Component( hMeth ) + { + if( !isMeth() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_NOT_A_METHOD, hMeth ); + } + } + /// \brief Constructs a new unbound \b mvIMPACT::acquire::Method object. + explicit Method() {} + /// \brief Constructs a new \b mvIMPACT::acquire::Method from an existing one. + Method( + /// [in] A constant reference to the \b mvIMPACT::acquire::Method object, this object shall be created from + const Method& src ) : Component( src ) {} + /// \brief Calls an underlying driver function. + /** + * This function can be used to call any driver function which is registered + * for the device it is called for. To call a function successfully the parameters + * passed to the function must match the parameters expected by the function. + * + * The parameters are passed as a list of strings. + * + * To find out what kind of parameters are expected by the function use + * the function \b mvIMPACT::acquire::Method::paramList(). + * + * floating point values can be passed either with a '.' or a ',' acting as the + * decimal point. + * + * 'empty' strings can be passed as a single underline('_').rs. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * + * \code + * // call a function expecting a string and a float + * vector params; + * params.push_back( "stringParam" ); + * params.push_back( "3.14" ); + * meth.call( params ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // call a function expecting a string and a float + * ArrayList list = new ArrayList(); + * list.add( "stringParam" ); + * list.add( "3.14" ); + * StringVector params = new StringVector( list ); + * meth.call( params ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # call a function expecting a string and a float + * params = [] + * params.append("stringParam") + * params.append("3.14") + * meth.call(params) + * \endcode + * \endif + * \return An integer value. For a typical function that is part of the driver SDK this integer value will be + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int call( + /// [in] The parameters to be passed to the function as a list of strings + const std::vector& params ) const + { + if( params.empty() ) + { + return call(); + } + const std::vector::size_type paramCount = params.size(); + if( paramCount == 1 ) + { + return call( params[0] ); + } + const std::string separators( " $%&!?=*#:;()" ); + const std::string::size_type separatorCount = separators.size(); + for ( std::string::size_type i = 0; i < separatorCount; i++ ) + { + if( !isCharacterInStringList( separators[i], params ) ) + { + const std::string delimiter( separators.substr( i, 1 ) ); + std::string parameterList; + for( std::vector::size_type j = 0; j < paramCount; j++ ) + { + if( !parameterList.empty() ) + { + parameterList.append( delimiter ); + } + parameterList.append( params[j] ); + } + return call( parameterList, delimiter ); + } + } + throw EInvalidParameterList( "A valid parameter delimiter could not be determined from the internal list('" + separators + "'). At least one occurrence of each of these characters has been detected in parameter list passed to this function" ); + } + /// \brief Calls an underlying driver function. + /** + * This function can be used to call any driver function which is registered + * for the device it is called for. To call a function successfully the parameters + * passed to the function must match the parameters expected by the function. + * + * All parameters are passed as a single string, which is parsed with respect to the + * given delimiter characters internally. + * + * To find out what kind of parameters are expected by the function use + * the function \b mvIMPACT::acquire::Method::paramList(). + * + * floating point values can be passed either with a '.' or a ',' acting as the + * decimal point. + * + * 'empty' strings can be passed as a single underline('_'). + * + * \warning + * The characters '.', ',' and '_' can't be used as delimiters. + * + * \if (DOXYGEN_CPP_DOCUMENTATION || DOXYGEN_JAVA_DOCUMENTATION) + * + * \code + * // call a function expecting a string and a float + * // value parameters separated by spaces + * meth.call( "stringParam 3,14" ); + * // call of a function expecting 2 integers an a string + * // where an empty string shall be passed + * // parameters are separated by '%' + * meth.call( "1000%666%_", "%" ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # call a function expecting a string and a float + * # value parameters separated by spaces + * meth.call("stringParam 3,14") + * # call of a function expecting 2 integers an a string + * # where an empty string shall be passed + * # parameters are separated by '%' + * meth.call("1000%666%_", "%") + * \endcode + * \endif + * \return An integer value. For a typical function that is part of the driver SDK this integer value will be + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int call( + /// [in] The parameters to be passed to the function as a single string + const std::string& params, + /// [in] A string containing valid delimiter characters for the parameter string + const std::string& delimiters = " " ) const + { + int retval; + const TPROPHANDLING_ERROR result = OBJ_Execute( m_hObj, params.c_str(), delimiters.c_str(), &retval ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return retval; + } + /// \brief Calls an underlying driver function expecting no parameters. + /** + * This function can be used to call any driver function which is registered + * for the device it is called for that does \b NOT expect any parameters + * + * To find out what kind of parameters are expected by the function use + * the function \b mvIMPACT::acquire::Method::paramList(). + * + * \return An integer value. For a typical function that is part of the driver SDK this integer value will be + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int call( void ) const + { + int retval; + const TPROPHANDLING_ERROR result = OBJ_Execute( m_hObj, 0, 0, &retval ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return retval; + } + /// \brief Returns the parameter list of the methods as a string. + /** + * This function returns a string containing one character for each parameter this \b mvIMPACT::acquire::Method + * object expects and one for the return type of the function call. + * + * The first character is the return type of the function all others are parameters. void functions + * don't specify parameters. + * + * The characters have the following meaning: + * - i specifies a 32-bit integer value + * - I specifies a 64-bit integer value + * - s specifies a pointer to a C-string + * - f specifies a double precision float value + * - p specifies a pointer value + * - v specifies a void return value + * + * \b EXAMPLES: + * + * - 'v': This is a function returning nothing (void). It expects no parameters. + * - 'viis': This is a function returning nothing (void). It expects 2 integer values + * and one pointer to a C-string. + * - 'if': This function returns an integer value and expects a float value. + * \return The parameter list of the method as a string. + */ + std::string paramList( void ) const + { + return compGetStringParam( sqMethParamString ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid limits which can be queried for a \b mvIMPACT::acquire::Property object. +enum TPropertyLimits +//----------------------------------------------------------------------------- +{ + /// \brief Set/Get the maximum value for this \b mvIMPACT::acquire::Property. + /** + * Pass this as the index to set or get the maximum number of values this property + * can store with a call to the \b mvIMPACT::acquire::Property object's corresponding + * \b read or \b write method. + */ + plMaxValue = PROP_MAX_VAL, + /// \brief Set/Get the minimum value for this \b mvIMPACT::acquire::Property. + /** + * Pass this as the index to set or get the maximum number of values this property + * can store with a call to the \b mvIMPACT::acquire::Property object's corresponding + * \b read or \b write method. + */ + plMinValue = PROP_MIN_VAL, + /// \brief Set/Get the step width value for this \b mvIMPACT::acquire::Property. + /** + * Pass this as the index to set or get the maximum number of values this property + * can store with a call to the \b mvIMPACT::acquire::Property object's corresponding + * \b read or \b write method. + */ + plStepWidth = PROP_STEP_WIDTH +}; + +//----------------------------------------------------------------------------- +/// \brief A base class for properties. +/** + * A property can be used to represent certain values like e.g. the input channel + * of a device. Depending on the way the property has been created it is either + * possible to read and write data to it or ( when the \b mvIMPACT::acquire::cfWriteAccess flag is \b NOT set ) + * just to read the data. In rare cases it might also be possible that the user is + * is not allowed to read the data of a property. To find out what you are allowed + * to do with a property or any other component the function \b mvIMPACT::acquire::Component::flags() + * can be called. + * + * A property can contain either a single value or an array of values of the same + * type (e.g. 4 integer values could be used to represent a property call 'Rectangle'. + * It can even (if the \b mvIMPACT::acquire::cfFixedSize flag is not set) contain + * a different number of values all the time its data is queried. E.g. for a property + * 'searchresults' each time some function is called which writes its results to this + * property the property could contain a different number of integer values afterwards. + * + * Every properties value can be read and written either as string or by it actual value type. + * So you can either assign the value of an integer property by using the standard 'write' function + * that accepts the value to be the type of the property or the function \b mvIMPACT::acquire::Property::writeS + * can be used to set the property via a string containing the new value. + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * PropertyI prop(hObj); + * prop.writeS("5"); // string assignment + * prop.write(5); // integer assignment + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * PropertyI prop = new PropertyI(hObj); + * prop.writeS("5"); // string assignment + * prop.write(5); // integer assignment + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * prop = acquire.PropertyI(hObj) + * prop.writeS("5") # string assignment + * prop.write(5) # integer assignment + * \endcode + * \endif + * + * In addition to that \e float and \e int Properties might define a translation dictionary. This cannot be + * done by the user, but the user can work with the dictionary afterwards. A translation + * dictionary is a table which maps strings to certain values (e.g. integers). + * + * The translation dictionary serves two purposes: Once it has been defined this property can only be + * assigned values ( which can either be passed as a string or as the actual value ) + * which are contained in the translation table. Thus this makes it very easy to restrict + * a certain property to a fixed number of values, which can be assigned to it. + * Properties that have a translation dictionary will typically be defined by declaring + * a template instance with the type of the enumeration. + * + * The second benefit of a translation dictionary is that certain values can be assigned + * a meaningful description via its translation. + * When a translation table has been defined either the string translation can be used to + * assign its value or its actual data type. A float property e.g. might define a translation + * table like this: 'Auto -> 0', 'auto -> 1', 'OnLowLevel -> 2'. Now to set this property + * to use the 'on low level' trigger mode this can be done by calling one of the 'write' functions. + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * PropertyICameraTriggerMode prop = getPropertyFromSomewhere(); + * prop.writeS("OnLowLevel"); // set value via the translation string + * prop.write(ctmOnLowLevel); // set value via enum type + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * PropertyI prop = getPropertyFromSomewhere(); + * prop.writeS("OnLowLevel"); // set value via the translation string + * prop.write(TCameraTriggerMode.ctmOnLowLevel); // set value via enum type + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * prop = getPropertyFromSomewhere() # assuming this function will return a 'PropertyICameraTriggerMode' instance! + * prop.writeS("OnLowLevel") # set value via the translation string + * prop.write(acquire.ctmOnLowLevel) # set value via enum type + * \endcode + * \endif + * + * This can also be extremely useful to populate combo boxes for GUI applications. + * + * Float and int properties can also define certain constants like a max. value or + * a min. value. If a property does define such values it can't be assigned values + * which do not lie within the defined range. To find out if constants are defined + * The user can call the functions \b mvIMPACT::acquire::Property::hasMaxValue, + * \b mvIMPACT::acquire::Property::hasMinValue and \b mvIMPACT::acquire::Property::hasStepWidth. + * To query to actual value of the max, min or step width the functions + * \b getMaxValue, \b getMinValue and \b getStepWidth of the classes + * \b mvIMPACT::acquire::EnumPropertyF, \b mvIMPACT::acquire::EnumPropertyI and + * \b mvIMPACT::acquire::EnumPropertyI64 can be called. + * + * When reading the value of a property as a string the user can define a format string + * telling the property module how to format the returned string. This works pretty much + * like when working e.g. with the \e printf function. + */ +class Property : public Component +//----------------------------------------------------------------------------- +{ +#ifdef BUILD_FOR_JAVA +public: + // For building the Java interface this must be public but this does not do any harm as + // only affects internal behaviour! + Property& operator=( const Property& rhs ) + { + Component::operator=( rhs ); + return *this; + } +private: +#else + // do not allow assignments! This makes sure the user can't assign e.g. the + // gain property to the property for controlling the expose time + Property& operator=( const Property& ); +#endif // #ifdef BUILD_FOR_JAVA + bool isConstDefinedInternal( TPropertyLimits constant ) const + { + unsigned int isDefined; + const TPROPHANDLING_ERROR result = OBJ_IsConstantDefined( m_hObj, constant, &isDefined ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return isDefined != 0; + } +protected: + //----------------------------------------------------------------------------- + int valuesToRead( int start, int end ) const + //----------------------------------------------------------------------------- + { + if( start < 0 ) + { + // when reading a set of values, these can't include limits or any other value associated with + // a negative index parameter to avoid confusion cause by END_OF_LIST + // having the same value as PROP_MAX_VAL. + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_INPUT_PARAMETER, m_hObj ); + } + return ( end == END_OF_LIST ) ? ( valCount() - start ) : ( end - start + 1 ); + } +public: + /// \brief Constructs a new unbound \b mvIMPACT::acquire::Property object. + /** + * Properties constructed this way can't be used for anything unless they + * are bound to a internal driver property with a \b mvIMPACT::acquire::ComponentLocator object. + */ + explicit Property( void ) {} + /// \brief Constructs a new \b mvIMPACT::acquire::Property object. + /** + * Properties successfully constructed this way can be worked with directly. + * If \a hObj does not reference an internal driver property a \b mvIMPACT::acquire::ENotAProperty + * exception will be thrown. + */ + explicit Property( + /// [in] A valid handle to a property + HOBJ hProp ) : Component( hProp ) + { + if( !isProp() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_NOT_A_PROPERTY, hProp ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::Property from an existing one. + Property( + /// [in] A constant reference to the \b mvIMPACT::acquire::Property object, this object shall be created from + const Property& src ) : Component( src ) {} + /// \brief Checks if this enumerated property allows the combination of enum values. + /** + * If this function returns true, the enum constants can be 'ored' together. This works + * for the enum constants as well as for the string representations returned in the + * properties translation dictionary. + * + * if a property e.g. defines a dictionary (('1', "one"), ('2', "two")) the following + * write operations will be valid: + * + * \code + * prop = getPropFromSomewhere() + * prop.write( 1 | 2 ) + * prop.write( "one | two" ) + * \endcode + * + * If this function returns true code like this will be valid: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * + * \code + * enum TEnum + * { + * eA, + * eB + * }; + * + * typedef EnumPropertyI PropertyIEnum; + * PropertyIEnum p = getPropFromSomewhere(); + * p.write( TEnum(eA | eB) ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * ImageProcessing ip = new ImageProcessing( pDev ); + * ip.getMirrorMode().write( TMirrorMode.mmTopDown | TMirrorMode.mmLeftRight ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * prop = getPropFromSomewhere() + * prop.write(1 | 2) + * prop.write("one | two") + * \endcode + * \endif + * \return + * - true if this property allows the combination of enum values. + * - false otherwise. + */ + bool allowsValueCombinations( void ) const + { + return ( flags() & cfAllowValueCombinations ) != 0; + } + /// \brief Returns the size of the properties translation dictionary. + /** + * If the property does define a translation dictionary this function returns + * the number of elements contained in this dictionary. + * \return + * - The size of the properties translation dictionary. + * - 0 If this property does not define a translation dictionary. + */ + unsigned int dictSize( void ) const + { + unsigned int size = 0; + const TPROPHANDLING_ERROR result = OBJ_GetDictSize( m_hObj, &size ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return size; + } + /// \brief Returns whether this property defines a translation dictionary or not. + /** + * \return + * - true if this property defines a translation table + * - false otherwise + */ + bool hasDict( void ) const + { + return ( dictSize() > 0 ); + } +#if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + /// \brief Checks if a certain constant is defined for this property(\b deprecated). + /** + * \deprecated + * This function has been declared deprecated and will be removed in future versions of this interface. + * Use \b mvIMPACT::acquire::Property::hasMaxValue(), \b mvIMPACT::acquire::Property::hasMinValue() + * and \b mvIMPACT::acquire::Property::hasStepWidth() instead and see the corresponding 'Porting existing code' + * section in the documentation. + * + * Valid values for \a constant are defined by the enum \b mvIMPACT::acquire::TPropertyLimits. + * \return + * - true if this property defines this constant + * - false otherwise + */ + MVIMPACT_DEPRECATED_CPP( bool isConstDefined( + /// [in] The constant whose existence is in question + TPropertyLimits constant ) const ); +#endif // #if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + /// \brief Checks if a maximum value is defined for this property. + /** + * \since 1.12.63 + * + * \return + * - true if this property defines a maximum value + * - false otherwise + */ + bool hasMaxValue( void ) const + { + return isConstDefinedInternal( plMaxValue ); + } + /// \brief Checks if a minimum value is defined for this property. + /** + * \since 1.12.63 + * + * \return + * - true if this property defines a minimum value + * - false otherwise + */ + bool hasMinValue( void ) const + { + return isConstDefinedInternal( plMinValue ); + } + /// \brief Checks if a step width is defined for this property. + /** + * \since 1.12.63 + * + * \return + * - true if this property defines a step width + * - false otherwise + */ + bool hasStepWidth( void ) const + { + return isConstDefinedInternal( plStepWidth ); + } + /// \brief Reads data from this property as a string. + /** + * \note If the caller does not have the needed rights this function might throw an + * exception of the type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \return A string containing the data questioned. + */ + std::string readS( + /// [in] The index of the desired value(only necessary for properties containing more than one value) + int index = 0, + /// [in] The format string telling the function how to format the result. If left empty the property uses its standard way of converting its data into a string + const std::string& format = "" ) const + { + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pBuf( bufSize ); + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetSFormattedEx( m_hObj, pBuf.get(), &bufSize, ( ( format != "" ) ? format.c_str() : 0 ), index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pBuf.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pBuf.get() ); + } + /// \brief Reads data from this property as a string. + /** + * This function can be used to query a set of values if this property stores more + * than a single value which might be useful for GUI applications. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * PropertyI p = getPropFromSomewhere(); + * p.write( 1 ); + * p.write( 2, 1 ); + * p.write( 666, 2 ); + * std::string s = p.readSArray( "%d", "&&:", 1 ); + * // now s should contain '2&&:666' + * s = p.readSArray( "%4d", " ", 0, 1 ); + * // now s should contain ' 1, 2' + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * PropertyI p = getPropFromSomewhere(); + * p.write( 1 ); + * p.write( 2, 1 ); + * p.write( 666, 2 ); + * String s = p.readSArray( "%d", "&&:", 1 ); + * // now s should contain '2&&:666' + * s = p.readSArray( "%4d", " ", 0, 1 ); + * // now s should contain ' 1, 2' + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * PropertyI p = getPropFromSomewhere() + * p.write(1) + * p.write(2, 1) + * p.write(666, 2) + * s = p.readSArray("%d", "&&:", 1) + * # now s should contain '2&&:666' + * s = p.readSArray("%4d", " ", 0, 1) + * # now s should contain ' 1, 2' + * \endcode + * \endif + * + * \note If the caller does not have the needed rights this function might throw an + * exception of the type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \return A string containing the data questioned. + */ + std::string readSArray( + /// [in] The format string telling the function how to format the result. If left empty the property uses its standard way of converting its data into a string + const std::string& format = "", + /// [in] This string is used to separate the individual values from one another. If left empty, a single blank will separate + /// the data. + const std::string& delimiter = "", + /// [in] The index of the first of the desired values + int startIndex = 0, + /// [in] The index of the last of the desired values. If \b INT_MAX is passed, every + /// from \a startIndex to the last value stored by the property will be returned. + int endIndex = INT_MAX, + /// [in] Specifies the mode this function operates in. Currently only the LSB affects the behaviour of this function. + /// When the LSB is set, the translation dictionary (if defined) will be ignored for this call. + int mode = 0 ) const + { + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pBuf( bufSize ); + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetSArrayFormattedEx( m_hObj, + pBuf.get(), + &bufSize, + ( format != "" ) ? format.c_str() : 0, + ( delimiter != "" ) ? delimiter.c_str() : 0, + startIndex, + endIndex, + mode ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pBuf.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pBuf.get() ); + } + /// \brief Removes a certain value from the property's data. + /** + * \return A const reference to the calling property. + */ + const Property& removeValue( + /// [in] The index of the value to be removed + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_RemoveVal( m_hObj, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Resizes the property's data array. + /** + * This function resizes the internal data array of this property. The size of + * this array represents the number of values, which can be stored within the + * property. This function will only succeed, if the \b mvIMPACT::acquire::cfFixedSize + * is \b NOT set for this property and the user has \b "write rights" for this property. + * Otherwise an exception will be thrown. Whenever the user successfully writes an + * array of values to a property and this array contains more elements than the current + * internal data array can accommodate at the desired offset the internal data array + * will be increased automatically. + * + * \note If the caller does not have the needed rights this function might throw an + * exception of the type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \note In order to be allowed to modify the number of values a property + * can store, the \b mvIMPACT::acquire::cfFixedSize flag + * must \b NOT be set. + * \sa + * \b mvIMPACT::acquire::Component::isWriteable + * + * \return A const reference to the calling property. + */ + const Property& resizeValArray( + /// [in] The new number of values this property shall be allowed to store + unsigned int newSize ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetValCount( m_hObj, newSize ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Returns the internal format string this property uses to convert data to strings. + /** + * \return A string containing the format string internally used by the property + * whenever the user reads a value as a string without specifying a format string and + * the property is not a string type one. + */ + std::string stringFormatString( void ) const + { + return compGetStringParam( sqPropFormatString ); + } + /// \brief Returns the current number of values managed by this property. + /** + * For the majority of properties this function will return '1', but as properties + * might manage more than a single value, this value might be interesting from time + * to time. + * \return the current number of values managed by this property. + */ + unsigned int valCount( void ) const + { + unsigned int valCount; + const TPROPHANDLING_ERROR result = OBJ_GetValCount( m_hObj, &valCount ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return valCount; + } + /// \brief Returns maximum number of values that can be managed by this property. + /** + * For the majority of properties this function will return '1', but as properties + * might manage more than a single value, this value might be interesting from time + * to time. + * \return the maximum number of values that can be managed by this property. + */ + unsigned int maxValCount( void ) const + { + unsigned int maxValCount; + const TPROPHANDLING_ERROR result = OBJ_GetMaxValCount( m_hObj, &maxValCount ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return maxValCount; + } + /// \brief Assigns a new value to this property. + /** + * The user caller have \b "write rights" for this property in order to be able to + * modify its value. Also if \a index is greater than the current internal data array + * size of this property the user must be allowed to change to size of the properties + * internal data array (the \b mvIMPACT::acquire::cfFixedSize flag must \b NOT be set). + * + * \note If the caller does not have the needed rights this function might throw an + * exception of the type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \sa + * \b mvIMPACT::acquire::Component::isWriteable, \n + * \b mvIMPACT::acquire::Component::flags, \n + * \b mvIMPACT::acquire::Property::writeS + * + * \return A const reference to the calling property. + */ + const Property& writeS( + /// [in] The new value for this property at the given \a index + const std::string& value, + /// [in] The index of the value to modify + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetS( m_hObj, value.c_str(), index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Assigns new values to this property. + /** + * The user must have \b "write rights" for this property in order to be able to + * modify its values. Also if \a index is greater than the current internal data array + * size of this property the user must be allowed to change to size of the properties + * internal data array (the \b mvIMPACT::acquire::cfFixedSize flag must \b NOT be set). This + * function behaves exactly like \b mvIMPACT::acquire::Property::writeS + * except that is can be used to assign more than one value at the same time. The parameter + * \a index here serves as an offset. If for example a property holds 3 values 'one', 'two' + * and 'three' before this call and the function is then called with an array containing the + * string 'orange' and 'blue' and \a index = 2 then after a successful call to this function + * the property will hold the data 'one', 'two', 'orange' and 'blue'. + * + * \note If the caller does not have the needed rights this function might throw an + * exception of the type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \sa + * \b mvIMPACT::acquire::Component::isWriteable, \n \b mvIMPACT::acquire::Component::flags, \n + * \b mvIMPACT::acquire::Property::writeS + * + * \return A const reference to the calling property. + */ + const Property& writeS( + /// [in] A constant reference to an array containing the strings to be assigned to the property + const std::vector& sequence, + /// [in] The offset from where to start to assign the values + int index = 0 ) const + { + unsigned int vSize = static_cast( sequence.size() ); + for( unsigned int i = 0; i < vSize; i++ ) + { + writeS( sequence[i], index + i ); + } + return *this; + } +}; + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +//----------------------------------------------------------------------------- +inline bool Property::isConstDefined( TPropertyLimits constant ) const +//----------------------------------------------------------------------------- +{ + return isConstDefinedInternal( constant ); +} +# endif // #if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) +#endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + +//----------------------------------------------------------------------------- +/// \brief A template class to represent float properties and enumerated float properties. +/** + * The template parameter specifies the enum to use as the value type for this + * enumerated property. The class itself however is restricted for float values. + * To use a normal float (not enumerated) properties use the \b mvIMPACT::acquire::PropertyF type. + */ +template +class EnumPropertyF : public Property +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound \b mvIMPACT::acquire::EnumPropertyF object. + explicit EnumPropertyF() {} + /// \brief Constructs a new \b mvIMPACT::acquire::EnumPropertyF object. + explicit EnumPropertyF( + /// [in] A valid handle to a float property + HOBJ hProp ) : Property( hProp ) + { + if( type() != ctPropFloat ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_PROP_VALUE_TYPE, hProp ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::EnumPropertyF from an existing one. + EnumPropertyF( + /// [in] A constant reference to the \b mvIMPACT::acquire::EnumPropertyF object, this object shall be created from + const EnumPropertyF& src ) : Property( src ) {} +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + typedef ZYX value_type; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief This function queries the property's translation table. + /** + * If this property defines a translation table the strings and their corresponding + * translation values will be written into \a sequence. If the property does \b NOT + * define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b EnumPropertyF::getTranslationDictString and + * \b EnumPropertyF::getTranslationDictValue multiple times and + * therefore this function should be called whenever all entries are required. + * \return A const reference to the calling property. + */ + const EnumPropertyF& getTranslationDict( + /// [out] A reference to a container which will receive the data from the properties translation dictionary. + std::vector >& sequence ) const + { + const unsigned int size = dictSize(); + double* pVal = new double[size]; + char** ppBuf = new char* [size]; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( size_t i = 0; i < size; i++ ) + { + ppBuf[i] = new char[bufSize]; + } + + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetFDictEntries( m_hObj, ppBuf, bufSize, pVal, size ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + ppBuf[i] = new char[bufSize]; + } + } + + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = std::pair( ppBuf[i], static_cast( pVal[i] ) ); + } + } + + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + } + delete [] ppBuf; + delete [] pVal; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief This function reads a single translation table string entry from a property. + /** + * If this property defines a translation table and \a index specifies a valid entry + * the string representation of this entry will be returned. + * If the property does \b NOT define a translation table or \a index specifies + * an invalid entry an exception will be thrown. + */ + std::string getTranslationDictString( + /// [in] The index of the entry to read from the property. + int index = 0 ) const + { + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pTranslationString( bufSize ); + while( ( result = OBJ_GetFDictEntry( m_hObj, pTranslationString.get(), bufSize, 0, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pTranslationString.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pTranslationString.get() ); + } + /// \brief This function reads a single translation table value entry from a property. + /** + * If this property defines a translation table and \a index specifies a valid entry + * the value of this entry will be returned. + * If the property does \b NOT define a translation table or \a index specifies + * an invalid entry an exception will be thrown. + * \sa \b mvIMPACT::acquire::EnumPropertyF::getTranslationDictValues to query all valid + * values efficiently in a single call. + */ + ZYX getTranslationDictValue( + /// [in] The index of the entry to read from the property. + int index = 0 ) const + { + double value; + const TPROPHANDLING_ERROR result = OBJ_GetFDictEntry( m_hObj, 0, 0, &value, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return static_cast( value ); + } + /// \brief This function queries a list of valid strings for this property. + /** + * If this property defines a translation table all valid strings will be written into \a sequence. + * If the property does \b NOT define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyF::getTranslationDictString multiple times and + * therefore this function should be called whenever all entries are required. + * \since 2.5.0 + * \return A const reference to the calling property. + */ + const EnumPropertyF& getTranslationDictStrings( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence ) const + { + const unsigned int size = dictSize(); + char** ppBuf = new char* [size]; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( size_t i = 0; i < size; i++ ) + { + ppBuf[i] = new char[bufSize]; + } + + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetFDictEntries( m_hObj, ppBuf, bufSize, 0, size ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + ppBuf[i] = new char[bufSize]; + } + } + + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = std::string( ppBuf[i] ); + } + } + + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + } + delete [] ppBuf; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + + /// \brief This function queries a list of valid values for this property. + /** + * If this property defines a translation table all valid values will be written into \a sequence. + * If the property does \b NOT + * define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyF::getTranslationDictValue multiple times and + * therefore this function should be called whenever all entries are required. + * \since 1.12.68 + * + * \return A const reference to the calling property. + */ + const EnumPropertyF& getTranslationDictValues( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence ) const + { + const unsigned int size = dictSize(); + if( size == 0 ) + { + sequence.clear(); + return *this; + } + + double* pVal = new double[size]; + const TPROPHANDLING_ERROR result = OBJ_GetFDictEntries( m_hObj, 0, 0, pVal, size ); + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = static_cast( pVal[i] ); + } + } + delete [] pVal; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Reads a value from a property. + /** + * This function queries a single value stored under index \a index in the property. + * \return The value stored at \a index within the property. + */ + ZYX read( + /// [in] The index of the value to read from the property. + int index = 0 ) const + { + double val; + const TPROPHANDLING_ERROR result = OBJ_GetF( m_hObj, &val, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return static_cast( val ); + } + /// \brief Reads the maximum value from a property. + /** + * \note + * To find out if the property defines a maximum value \b mvIMPACT::acquire::Property::hasMaxValue + * should be called first. + * + * \note + * If the property does not define a maximum value calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getMaxValue( void ) const + { + return read( plMaxValue ); + } + /// \brief Reads the minimum value from a property. + /** + * \note + * To find out if the property defines a minimum value \b mvIMPACT::acquire::Property::hasMinValue + * should be called first. + * + * \note + * If the property does not define a minimum value calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getMinValue( void ) const + { + return read( plMinValue ); + } + /// \brief Reads the step width from a property. + /** + * \note + * To find out if the property defines a step width \b mvIMPACT::acquire::Property::hasStepWidth + * should be called first. + * + * \note + * If the property does not define a step width calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getStepWidth( void ) const + { + return read( plStepWidth ); + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = read( i + start ); + } + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] Set this parameter to \a true to get all values at once(recommended). If set to false the function will + /// need more time and all values in \a sequence will be read one after the other + bool boAtomic, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + if( boAtomic ) + { + unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + double* pValues = new double[valCnt]; + const TPROPHANDLING_ERROR result = OBJ_GetFArray( m_hObj, pValues, valCnt, start ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = static_cast( pValues[i] ); + } + delete [] pValues; + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + } + else + { + read( sequence, start, end ); + } + } + /// \brief Writes one value to the property. + /** + * This function writes a single value under index \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyF& write( + /// [in] The value to write to the property. + ZYX value, + /// [in] The index defining at which position to write the value. + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetF( m_hObj, static_cast( value ), index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyF& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + unsigned int vSize = static_cast( sequence.size() ); + for( unsigned int i = 0; i < vSize; i++ ) + { + write( sequence[i], index + i ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyF& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] Set this parameter to \a true to set all values at once(recommended). If set to false the function will + /// need more time and all values in \a sequence will be set one after the other + bool boAtomic, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + if( boAtomic ) + { + const unsigned int valCnt = static_cast( sequence.size() ); + double* pValues = new double[valCnt]; + for( unsigned int i = 0; i < valCnt; i++ ) + { + pValues[i] = sequence[i]; + } + const TPROPHANDLING_ERROR result = OBJ_SetFArray( m_hObj, pValues, valCnt, index ); + delete [] pValues; + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + else + { + return write( sequence, index ); + } + } +}; + +/// \brief A type for floating point properties. +/** + * Provided for convenience only. This type represents a standard float property type. + */ +typedef EnumPropertyF PropertyF; + +//----------------------------------------------------------------------------- +/// \brief A template class to represent 32 bit integer properties and 32 bit enumerated integer properties. +/** + * The template parameter specifies the enum to use as the value type for this + * enumerated property. The class itself however is restricted for integer values. + * To use a normal int (not enumerated) properties use the \b mvIMPACT::acquire::PropertyI type. + */ +template +class EnumPropertyI : public Property +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound \b mvIMPACT::acquire::EnumPropertyI object. + explicit EnumPropertyI() {} + /// \brief Constructs a new \b mvIMPACT::acquire::EnumPropertyI object. + explicit EnumPropertyI( + /// [in] A valid handle to an integer property + HOBJ hProp ) : Property( hProp ) + { + const TComponentType compType = type(); + if( ( compType != ctPropInt ) && ( compType != ctPropInt64 ) ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_PROP_VALUE_TYPE, hProp ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::EnumPropertyI from an existing one. + EnumPropertyI( + /// [in] A constant reference to the \b mvIMPACT::acquire::EnumPropertyI object, this object shall be created from + const EnumPropertyI& src ) : Property( src ) {} +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + typedef ZYX value_type; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief This function queries the property's translation table. + /** + * If this property defines a translation table the strings and their corresponding + * translation values will be written into \a sequence. If the property does \b NOT + * define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyI::getTranslationDictString and + * \b mvIMPACT::acquire::EnumPropertyI::getTranslationDictValue multiple times and + * therefore this function should be called whenever all entries are required. + * + * \return A const reference to the calling property. + */ + const EnumPropertyI& getTranslationDict( + /// [out] A reference to a container which will receive the data from the properties translation dictionary. + std::vector >& sequence ) const + { + const unsigned int size = dictSize(); + int* pVal = new int[size]; + char** ppBuf = new char* [size]; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( size_t i = 0; i < size; i++ ) + { + ppBuf[i] = new char[bufSize]; + } + + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetIDictEntries( m_hObj, ppBuf, bufSize, pVal, size ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + ppBuf[i] = new char[bufSize]; + } + } + + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = std::pair( ppBuf[i], static_cast( pVal[i] ) ); + } + } + + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + } + delete [] ppBuf; + delete [] pVal; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief This function reads a single translation table string entry from a property. + /** + * If this property defines a translation table and \a index specifies a valid entry + * the string representation of this entry will be returned. + * If the property does \b NOT define a translation table or \a index specifies + * an invalid entry an exception will be thrown. + */ + std::string getTranslationDictString( + /// [in] The index of the entry to read from the property. + int index = 0 ) const + { + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pTranslationString( bufSize ); + while( ( result = OBJ_GetIDictEntry( m_hObj, pTranslationString.get(), bufSize, 0, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pTranslationString.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pTranslationString.get() ); + } + /// \brief This function reads a single translation table value entry from a property. + /** + * If this property defines a translation table and \a index specifies a valid entry + * the value of this entry will be returned. + * If the property does \b NOT define a translation table or \a index specifies + * an invalid entry an exception will be thrown. + * \sa \b mvIMPACT::acquire::EnumPropertyI::getTranslationDictValues to query all valid + * values efficiently in a single call. + */ + ZYX getTranslationDictValue( + /// [in] The index of the entry to read from the property. + int index = 0 ) const + { + int value; + const TPROPHANDLING_ERROR result = OBJ_GetIDictEntry( m_hObj, 0, 0, &value, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return static_cast( value ); + } + /// \brief This function queries a list of valid strings for this property. + /** + * If this property defines a translation table all valid strings will be written into \a sequence. + * If the property does \b NOT define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyI::getTranslationDictString multiple times and + * therefore this function should be called whenever all entries are required. + * \since 2.5.0 + * \return A const reference to the calling property. + */ + const EnumPropertyI& getTranslationDictStrings( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence ) const + { + const unsigned int size = dictSize(); + char** ppBuf = new char* [size]; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( size_t i = 0; i < size; i++ ) + { + ppBuf[i] = new char[bufSize]; + } + + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetIDictEntries( m_hObj, ppBuf, bufSize, 0, size ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + ppBuf[i] = new char[bufSize]; + } + } + + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = std::string( ppBuf[i] ); + } + } + + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + } + delete [] ppBuf; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + + /// \brief This function queries a list of valid values for this property. + /** + * If this property defines a translation table all valid values will be written into \a sequence. + * If the property does \b NOT + * define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyI::getTranslationDictValue multiple times and + * therefore this function should be called whenever all entries are required. + * \since 1.12.68 + * + * \return A const reference to the calling property. + */ + const EnumPropertyI& getTranslationDictValues( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence ) const + { + const unsigned int size = dictSize(); + if( size == 0 ) + { + sequence.clear(); + return *this; + } + + int* pVal = new int[size]; + const TPROPHANDLING_ERROR result = OBJ_GetIDictEntries( m_hObj, 0, 0, pVal, size ); + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = static_cast( pVal[i] ); + } + } + delete [] pVal; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Reads a value from a property. + /** + * This function queries a single value stored under index \a index in the property. + * \return The value stored at \a index within the property. + */ + ZYX read( + /// [in] The index of the value to read from the property. + int index = 0 ) const + { + int val; + const TPROPHANDLING_ERROR result = OBJ_GetI( m_hObj, &val, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return static_cast( val ); + } + /// \brief Reads the maximum value from a property. + /** + * \note + * To find out if the property defines a maximum value \b mvIMPACT::acquire::Property::hasMaxValue + * should be called first. + * + * \note + * If the property does not define a maximum value calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getMaxValue( void ) const + { + return read( plMaxValue ); + } + /// \brief Reads the minimum value from a property. + /** + * \note + * To find out if the property defines a minimum value \b mvIMPACT::acquire::Property::hasMinValue + * should be called first. + * + * \note + * If the property does not define a minimum value calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getMinValue( void ) const + { + return read( plMinValue ); + } + /// \brief Reads the step width from a property. + /** + * \note + * To find out if the property defines a step width \b mvIMPACT::acquire::Property::hasStepWidth + * should be called first. + * + * \note + * If the property does not define a step width calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getStepWidth( void ) const + { + return read( plStepWidth ); + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = read( i + start ); + } + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] Set this parameter to \a true to get all values at once(recommended). If set to false the function will + /// need more time and all values in \a sequence will be read one after the other + bool boAtomic, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + if( boAtomic ) + { + unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + int* pValues = new int[valCnt]; + const TPROPHANDLING_ERROR result = OBJ_GetIArray( m_hObj, pValues, valCnt, start ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = static_cast( pValues[i] ); + } + delete [] pValues; + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + } + else + { + read( sequence, start, end ); + } + } + /// \brief Writes one value to the property. + /** + * This function writes a single value under index \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyI& write( + /// [in] The value to write to the property. + ZYX value, + /// [in] The index defining at which position to write the value. + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetI( m_hObj, static_cast( value ), index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyI& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + int vSize = static_cast( sequence.size() ); + for( int i = 0; i < vSize; i++ ) + { + write( sequence[i], index + i ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyI& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] Set this parameter to \a true to set all values at once(recommended). If set to false the function will + /// need more time and all values in \a sequence will be set one after the other + bool boAtomic, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + if( boAtomic ) + { + const unsigned int valCnt = static_cast( sequence.size() ); + int* pValues = new int[valCnt]; + for( unsigned int i = 0; i < valCnt; i++ ) + { + pValues[i] = sequence[i]; + } + const TPROPHANDLING_ERROR result = OBJ_SetIArray( m_hObj, pValues, valCnt, index ); + delete [] pValues; + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + else + { + return write( sequence, index ); + } + } +}; + +#if defined(WRAP_JAVA) || defined(BUILD_FOR_JAVA) +typedef EnumPropertyI PropertyIAcquisitionMode; +typedef EnumPropertyI PropertyIAcquisitionStartStopBehaviour; +typedef EnumPropertyI PropertyIAoiMode; +typedef EnumPropertyI PropertyIBayerConversionMode; +typedef EnumPropertyI PropertyIBayerMosaicParity; +typedef EnumPropertyI PropertyIBayerWhiteBalanceResult; +typedef EnumPropertyI PropertyIBoolean; +typedef EnumPropertyI PropertyICameraOutput; +typedef EnumPropertyI PropertyIChannelSplitMode; +typedef EnumPropertyI PropertyIColorTwistInputCorrectionMatrixMode; +typedef EnumPropertyI PropertyIColorTwistOutputCorrectionMatrixMode; +typedef EnumPropertyI PropertyIColorProcessingMode; +typedef EnumPropertyI PropertyIDarkCurrentFilterMode; +typedef EnumPropertyI PropertyIDefectivePixelsFilterMode; +typedef EnumPropertyI PropertyIDeviceAccessMode; +typedef EnumPropertyI PropertyIDeviceAutoNegotiatePacketSizeMode; +typedef EnumPropertyI PropertyIDeviceCapability; +typedef EnumPropertyI PropertyIDeviceClass; +typedef EnumPropertyI PropertyIDeviceInterfaceLayout; +typedef EnumPropertyI PropertyIDeviceLoadSettings; +typedef EnumPropertyI PropertyIDeviceState; +typedef EnumPropertyI PropertyIDFirmwareUpdateResult; +typedef EnumPropertyI PropertyIFlatFieldFilterCorrectionMode; +typedef EnumPropertyI PropertyIFlatFieldFilterMode; +typedef EnumPropertyI PropertyIHWUpdateResult; +typedef EnumPropertyI PropertyIImageBufferPixelFormat; +typedef EnumPropertyI PropertyIImageBufferFormatReinterpreterMode; +typedef EnumPropertyI PropertyIImageDestinationPixelFormat; +typedef EnumPropertyI PropertyIImageProcessingFilter; +typedef EnumPropertyI PropertyIImageProcessingMode; +typedef EnumPropertyI PropertyIImageProcessingOptimization; +typedef EnumPropertyI PropertyIImageProcessingResult; +typedef EnumPropertyI PropertyIRequestImageMemoryMode; +typedef EnumPropertyI PropertyIImageRequestControlMode; +typedef EnumPropertyI PropertyIInterfaceEnumerationBehaviour; +typedef EnumPropertyI PropertyILUTGammaMode; +typedef EnumPropertyI PropertyILUTImplementation; +typedef EnumPropertyI PropertyILUTInterpolationMode; +typedef EnumPropertyI PropertyILUTMapping; +typedef EnumPropertyI PropertyILUTMode; +typedef EnumPropertyI PropertyIMirrorMode; +typedef EnumPropertyI PropertyIMirrorOperationMode; +typedef EnumPropertyI PropertyIPolarizedDataExtractionMode; +typedef EnumPropertyI PropertyIPolarizedDataExtractionInterpolationMode; +typedef EnumPropertyI PropertyIRequestResult; +typedef EnumPropertyI PropertyIRequestState; +typedef EnumPropertyI PropertyIScalerMode; +typedef EnumPropertyI PropertyIScalerInterpolationMode; +typedef EnumPropertyI PropertyIUserDataAccessRight; +typedef EnumPropertyI PropertyIUserDataReconnectBehaviour; +typedef EnumPropertyI PropertyIWhiteBalanceCalibrationMode; +typedef EnumPropertyI PropertyIWhiteBalanceParameter; +#else +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAcquisitionMode. +typedef EnumPropertyI PropertyIAcquisitionMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAcquisitionStartStopBehaviour. +typedef EnumPropertyI PropertyIAcquisitionStartStopBehaviour; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAoiMode. +typedef EnumPropertyI PropertyIAoiMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBayerConversionMode. +typedef EnumPropertyI PropertyIBayerConversionMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBayerMosaicParity. +typedef EnumPropertyI PropertyIBayerMosaicParity; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBayerWhiteBalanceResult. +typedef EnumPropertyI PropertyIBayerWhiteBalanceResult; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBoolean. +typedef EnumPropertyI PropertyIBoolean; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraOutput. +typedef EnumPropertyI PropertyICameraOutput; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TChannelSplitMode. +typedef EnumPropertyI PropertyIChannelSplitMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TColorTwistInputCorrectionMatrixMode. +typedef EnumPropertyI PropertyIColorTwistInputCorrectionMatrixMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TColorTwistOutputCorrectionMatrixMode. +typedef EnumPropertyI PropertyIColorTwistOutputCorrectionMatrixMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TColorProcessingMode. +typedef EnumPropertyI PropertyIColorProcessingMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDarkCurrentFilterMode. +typedef EnumPropertyI PropertyIDarkCurrentFilterMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDefectivePixelsFilterMode. +typedef EnumPropertyI PropertyIDefectivePixelsFilterMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceAccessMode. +typedef EnumPropertyI PropertyIDeviceAccessMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceAutoNegotiatePacketSizeMode. +typedef EnumPropertyI PropertyIDeviceAutoNegotiatePacketSizeMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceCapability. +typedef EnumPropertyI PropertyIDeviceCapability; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceClass. +typedef EnumPropertyI PropertyIDeviceClass; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceInterfaceLayout. +typedef EnumPropertyI PropertyIDeviceInterfaceLayout; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceLoadSettings. +typedef EnumPropertyI PropertyIDeviceLoadSettings; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceState. +typedef EnumPropertyI PropertyIDeviceState; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TFlatFieldFilterCorrectionMode. +typedef EnumPropertyI PropertyIFlatFieldFilterCorrectionMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TFlatFieldFilterMode. +typedef EnumPropertyI PropertyIFlatFieldFilterMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::THWUpdateResult. +typedef EnumPropertyI PropertyIHWUpdateResult; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageBufferPixelFormat. +typedef EnumPropertyI PropertyIImageBufferPixelFormat; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageBufferFormatReinterpreterMode. +typedef EnumPropertyI PropertyIImageBufferFormatReinterpreterMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageDestinationPixelFormat. +typedef EnumPropertyI PropertyIImageDestinationPixelFormat; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageProcessingFilter. +typedef EnumPropertyI PropertyIImageProcessingFilter; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageProcessingMode. +typedef EnumPropertyI PropertyIImageProcessingMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageProcessingOptimization. +typedef EnumPropertyI PropertyIImageProcessingOptimization; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageProcessingResult. +typedef EnumPropertyI PropertyIImageProcessingResult; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TRequestImageMemoryMode. +typedef EnumPropertyI PropertyIRequestImageMemoryMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageRequestControlMode. +typedef EnumPropertyI PropertyIImageRequestControlMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TInterfaceEnumerationBehaviour. +typedef EnumPropertyI PropertyIInterfaceEnumerationBehaviour; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TLUTGammaMode. +typedef EnumPropertyI PropertyILUTGammaMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TLUTImplementation. +typedef EnumPropertyI PropertyILUTImplementation; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TLUTInterpolationMode. +typedef EnumPropertyI PropertyILUTInterpolationMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TLUTMapping. +typedef EnumPropertyI PropertyILUTMapping; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TLUTMode. +typedef EnumPropertyI PropertyILUTMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TMirrorMode. +typedef EnumPropertyI PropertyIMirrorMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TMirrorOperationMode. +typedef EnumPropertyI PropertyIMirrorOperationMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TPolarizedDataExtractionMode. +typedef EnumPropertyI PropertyIPolarizedDataExtractionMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TPolarizedDataExtractionInterpolationMode. +typedef EnumPropertyI PropertyIPolarizedDataExtractionInterpolationMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TRequestResult. +typedef EnumPropertyI PropertyIRequestResult; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TRequestState. +typedef EnumPropertyI PropertyIRequestState; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TScalerMode. +typedef EnumPropertyI PropertyIScalerMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TScalerInterpolationMode. +typedef EnumPropertyI PropertyIScalerInterpolationMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TUserDataAccessRight. +typedef EnumPropertyI PropertyIUserDataAccessRight; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TUserDataReconnectBehaviour. +typedef EnumPropertyI PropertyIUserDataReconnectBehaviour; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TWhiteBalanceCalibrationMode. +typedef EnumPropertyI PropertyIWhiteBalanceCalibrationMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TWhiteBalanceParameter. +typedef EnumPropertyI PropertyIWhiteBalanceParameter; +#endif // #if defined(WRAP_JAVA) || defined(BUILD_FOR_JAVA) + +/// \brief A type for integer properties. +/** + * Provided for convenience only. This type represents a standard integer property type. + */ +typedef EnumPropertyI PropertyI; + +//----------------------------------------------------------------------------- +/// \brief A template class to represent 64 bit integer properties and enumerated 64 bit integer properties. +/** + * The template parameter specifies the enum to use as the value type for this + * enumerated property. The class itself however is restricted for integer values. + * To use a normal int (not enumerated) properties use the \b mvIMPACT::acquire::PropertyI64 type. + */ +template +class EnumPropertyI64 : public Property +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound \b mvIMPACT::acquire::EnumPropertyI64 object. + explicit EnumPropertyI64() {} + /// \brief Constructs a new \b mvIMPACT::acquire::EnumPropertyI64 object. + explicit EnumPropertyI64( + /// [in] A valid handle to a 64-bit integer property + HOBJ hProp ) : Property( hProp ) + { + const TComponentType compType = type(); + if( ( compType != ctPropInt ) && ( compType != ctPropInt64 ) ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_PROP_VALUE_TYPE, hProp ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::EnumPropertyI64 from an existing one. + EnumPropertyI64( + /// [in] A constant reference to the \b mvIMPACT::acquire::EnumPropertyI64 object, this object shall be created from + const EnumPropertyI64& src ) : Property( src ) {} +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + typedef ZYX value_type; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief This function queries the property's translation table. + /** + * If this property defines a translation table the strings and their corresponding + * translation values will be written into \a sequence. If the property does \b NOT + * define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyI64::getTranslationDictString and + * \b mvIMPACT::acquire::EnumPropertyI64::getTranslationDictValue multiple times and + * therefore this function should be called whenever all entries are required. + * \return A const reference to the calling property. + */ + const EnumPropertyI64& getTranslationDict( + /// [out] A reference to a container which will receive the data from the properties translation dictionary. + std::vector >& sequence ) const + { + const unsigned int size = dictSize(); + int64_type* pVal = new int64_type[size]; + char** ppBuf = new char* [size]; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( size_t i = 0; i < size; i++ ) + { + ppBuf[i] = new char[bufSize]; + } + + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetI64DictEntries( m_hObj, ppBuf, bufSize, pVal, size ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + ppBuf[i] = new char[bufSize]; + } + } + + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = std::pair( ppBuf[i], static_cast( pVal[i] ) ); + } + } + + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + } + delete [] ppBuf; + delete [] pVal; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief This function reads a single translation table string entry from a property. + /** + * If this property defines a translation table and \a index specifies a valid entry + * the string representation of this entry will be returned. + * If the property does \b NOT define a translation table or \a index specifies + * an invalid entry an exception will be thrown. + */ + std::string getTranslationDictString( + /// [in] The index of the entry to read from the property. + int index = 0 ) const + { + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + auto_array_ptr pTranslationString( bufSize ); + while( ( result = OBJ_GetI64DictEntry( m_hObj, pTranslationString.get(), bufSize, 0, index ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + pTranslationString.realloc( bufSize ); + } + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pTranslationString.get() ); + } + /// \brief This function reads a single translation table value entry from a property. + /** + * If this property defines a translation table and \a index specifies a valid entry + * the value of this entry will be returned. + * If the property does \b NOT define a translation table or \a index specifies + * an invalid entry an exception will be thrown. + * \sa \b mvIMPACT::acquire::EnumPropertyI64::getTranslationDictValues to query all valid + * values efficiently in a single call. + */ + ZYX getTranslationDictValue( + /// [in] The index of the entry to read from the property. + int index = 0 ) const + { + int64_type value; + const TPROPHANDLING_ERROR result = OBJ_GetI64DictEntry( m_hObj, 0, 0, &value, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return static_cast( value ); + } + /// \brief This function queries a list of valid strings for this property. + /** + * If this property defines a translation table all valid strings will be written into \a sequence. + * If the property does \b NOT define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyI64::getTranslationDictString multiple times and + * therefore this function should be called whenever all entries are required. + * \since 2.5.0 + * \return A const reference to the calling property. + */ + const EnumPropertyI64& getTranslationDictStrings( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence ) const + { + const unsigned int size = dictSize(); + char** ppBuf = new char* [size]; + size_t bufSize = DEFAULT_STRING_SIZE_LIMIT; + for( size_t i = 0; i < size; i++ ) + { + ppBuf[i] = new char[bufSize]; + } + + TPROPHANDLING_ERROR result = PROPHANDLING_NO_ERROR; + while( ( result = OBJ_GetI64DictEntries( m_hObj, ppBuf, bufSize, 0, size ) ) == PROPHANDLING_INPUT_BUFFER_TOO_SMALL ) + { + bufSize *= BUFFER_INCREMENT_FACTOR; + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + ppBuf[i] = new char[bufSize]; + } + } + + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = std::string( ppBuf[i] ); + } + } + + for( size_t i = 0; i < size; i++ ) + { + delete [] ppBuf[i]; + } + delete [] ppBuf; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + + /// \brief This function queries a list of valid values for this property. + /** + * If this property defines a translation table all valid values will be written into \a sequence. + * If the property does \b NOT + * define a translation table \a sequence will be empty after this function call. + * + * \note + * This function is much more efficient than calling + * \b mvIMPACT::acquire::EnumPropertyI64::getTranslationDictValue multiple times and + * therefore this function should be called whenever all entries are required. + * \since 1.12.68 + * + * \return A const reference to the calling property. + */ + const EnumPropertyI64& getTranslationDictValues( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence ) const + { + const unsigned int size = dictSize(); + if( size == 0 ) + { + sequence.clear(); + return *this; + } + + int64_type* pVal = new int64_type[size]; + const TPROPHANDLING_ERROR result = OBJ_GetI64DictEntries( m_hObj, 0, 0, pVal, size ); + if( result == PROPHANDLING_NO_ERROR ) + { + sequence.resize( size ); + for( unsigned int i = 0; i < size; i++ ) + { + sequence[i] = static_cast( pVal[i] ); + } + } + delete [] pVal; + + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Reads a value from a property. + /** + * This function queries a single value stored under index \a index in the property. + * \return The value stored at \a index within the property. + */ + ZYX read( + /// [in] The index of the value to read from the property. + int index = 0 ) const + { + int64_type val; + const TPROPHANDLING_ERROR result = OBJ_GetI64( m_hObj, &val, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return static_cast( val ); + } + /// \brief Reads the maximum value from a property. + /** + * \note + * To find out if the property defines a maximum value \b mvIMPACT::acquire::Property::hasMaxValue + * should be called first. + * + * \note + * If the property does not define a maximum value calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getMaxValue( void ) const + { + return read( plMaxValue ); + } + /// \brief Reads the minimum value from a property. + /** + * \note + * To find out if the property defines a minimum value \b mvIMPACT::acquire::Property::hasMinValue + * should be called first. + * + * \note + * If the property does not define a minimum value calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getMinValue( void ) const + { + return read( plMinValue ); + } + /// \brief Reads the step width from a property. + /** + * \note + * To find out if the property defines a step width \b mvIMPACT::acquire::Property::hasStepWidth + * should be called first. + * + * \note + * If the property does not define a step width calling this function will raise + * an exception. + * + * \since 1.12.63 + * + */ + ZYX getStepWidth( void ) const + { + return read( plStepWidth ); + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = read( i + start ); + } + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] Set this parameter to \a true to get all values at once(recommended). If set to false the function will + /// need more time and all values in \a sequence will be read one after the other + bool boAtomic, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + if( boAtomic ) + { + const unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + int64_type* pValues = new int64_type[valCnt]; + const TPROPHANDLING_ERROR result = OBJ_GetI64Array( m_hObj, pValues, valCnt, start ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = static_cast( pValues[i] ); + } + delete [] pValues; + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + } + else + { + read( sequence, start, end ); + } + } + /// \brief Writes one value to the property. + /** + * This function writes a single value under index \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyI64& write( + /// [in] The value to write to the property. + ZYX value, + /// [in] The index defining at which position to write the value. + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetI64( m_hObj, static_cast( value ), index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyI64& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + const int vSize = static_cast( sequence.size() ); + for( int i = 0; i < vSize; i++ ) + { + write( sequence[i], index + i ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const EnumPropertyI64& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] Set this parameter to \a true to set all values at once(recommended). If set to false the function will + /// need more time and all values in \a sequence will be set one after the other + bool boAtomic, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + if( boAtomic ) + { + const unsigned int valCnt = static_cast( sequence.size() ); + int64_type* pValues = new int64_type[valCnt]; + for( unsigned int i = 0; i < valCnt; i++ ) + { + pValues[i] = static_cast( sequence[i] ); + } + const TPROPHANDLING_ERROR result = OBJ_SetI64Array( m_hObj, pValues, valCnt, index ); + delete [] pValues; + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + else + { + return write( sequence, index ); + } + } +}; + +/// Provided for convenience only. This type represents a standard 64 bit integer property type. +typedef EnumPropertyI64 PropertyI64; + +#if defined(WRAP_JAVA) || defined(BUILD_FOR_JAVA) +typedef EnumPropertyI64 PropertyI64BufferPartDataType; +typedef EnumPropertyI64 PropertyI64DeviceTriggerOverlap; +#else +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TImageBufferPartType. +typedef EnumPropertyI64 PropertyI64BufferPartDataType; + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceTriggerOverlap. +typedef EnumPropertyI64 PropertyI64DeviceTriggerOverlap; +#endif // #if defined(WRAP_JAVA) || defined(BUILD_FOR_JAVA) + +//----------------------------------------------------------------------------- +/// \brief A class to represent pointer properties. +class PropertyPtr : public Property +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound \b mvIMPACT::acquire::PropertyPtr object. + explicit PropertyPtr() {} + /// \brief Constructs a new \b mvIMPACT::acquire::PropertyPtr object. + explicit PropertyPtr( + /// [in] A valid handle to a pointer property + HOBJ hProp ) : Property( hProp ) + { + if( type() != ctPropPtr ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_PROP_VALUE_TYPE, hProp ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::PropertyPtr from an existing one. + PropertyPtr( + /// [in] A constant reference to the \b mvIMPACT::acquire::PropertyPtr object, this object shall be created from + const PropertyPtr& src ) : Property( src ) {} +# if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + typedef void* value_type; +# endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Reads a value from a property. + /** + * This function queries a single value stored under index \a index in the property. + * \return The value stored at \a index within the property. + */ + void* read( + /// [in] The index of the value to read from the property. + int index = 0 ) const + { + void* val; + const TPROPHANDLING_ERROR result = OBJ_GetP( m_hObj, &val, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return val; + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + const unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = read( i + start ); + } + } + /// \brief Writes one value to the property. + /** + * This function writes a single value under index \a index to the property. + * \return A const 'self' reference. + */ + const PropertyPtr& write( + /// [in] The value to write to the property. + void* value, + /// [in] The index defining at which position to write the value. + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetP( m_hObj, value, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * \return A const 'self' reference. + */ + const PropertyPtr& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + const unsigned int vSize = static_cast( sequence.size() ); + for( unsigned int i = 0; i < vSize; i++ ) + { + write( sequence[i], static_cast( index + i ) ); + } + return *this; + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class to represent string properties. +class PropertyS : public Property +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound \b mvIMPACT::acquire::PropertyS object. + explicit PropertyS() {} + /// \brief Constructs a new \b mvIMPACT::acquire::PropertyS object. + explicit PropertyS( + /// [in] A valid handle to the string property + HOBJ hProp ) : Property( hProp ) + { + if( type() != ctPropString ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_PROP_VALUE_TYPE, hProp ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::PropertyS from an existing one. + PropertyS( + /// [in] A constant reference to the \b mvIMPACT::acquire::EnumPropertyS object, this object shall be created from + const PropertyS& src ) : Property( src ) {} +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + typedef std::string value_type; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Returns the size(in bytes) needed for the binary representation of the string buffer. + /** + * When binary data has been stored in a string property it has been stored in [Base64](https://en.wikipedia.org/wiki/Base64) format + * internally. If the user wants to know the length of the binary data in decoded format, + * this function can be called. + * + * \sa \b mvIMPACT::acquire::PropertyS::readBinary, \n + * \b mvIMPACT::acquire::PropertyS::writeBinary, \n + * \b mvIMPACT::acquire::PropertyS::binaryDataBufferMaxSize + * + * \return The size(in bytes) needed for the binary representation of the string buffer. + */ + unsigned int binaryDataBufferSize( + /// [in] The index of the value for which to query the + /// buffer size(if this property holds more than one value). + int index = 0 ) const + { + unsigned int val; + const TPROPHANDLING_ERROR result = OBJ_GetBinaryBufferSize( m_hObj, &val, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return val; + } + /// \brief Reads the max size(in bytes) of binary data this property can store. + /** + * When binary data shall be stored in a string property, the user will need to allocate memory + * when this data shall be written to the property. To find out how much binary data can be stored + * by a property before calling the function \b mvIMPACT::acquire::PropertyS::writeBinary this function can be used. + * + * \sa \b mvIMPACT::acquire::PropertyS::readBinary, \n + * \b mvIMPACT::acquire::PropertyS::writeBinary, \n + * \b mvIMPACT::acquire::PropertyS::binaryDataBufferMaxSize + * + * \return The size(in bytes) needed for the binary representation of the string buffer. + */ + unsigned int binaryDataBufferMaxSize( void ) const + { + unsigned int val; + const TPROPHANDLING_ERROR result = OBJ_GetBinaryBufferMaxSize( m_hObj, &val ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return val; + } + /// \brief Reads a value from a property. + /** + * This function queries a single value stored under index \a index in the property. + * \return The value stored at \a index within the property. + */ + std::string read( + /// [in] The index of the value to read from the property. + int index = 0 ) const + { + return compGetStringParam( sqPropVal, 0, index ); + } + /// \brief Reads a set of values from a property. + /** + * This function queries a set of values from a property and stores these values + * into \a sequence. + * \return Nothing. + */ + void read( + /// [out] A reference to a container to store the data read from the property into. + std::vector& sequence, + /// [in] The index from where to start reading values from the property. + int start = 0, + /// [in] The index where to stop reading values from the property. + int end = END_OF_LIST ) const + { + const unsigned int valCnt = valuesToRead( start, end ); + sequence.resize( valCnt ); + for( unsigned int i = 0; i < valCnt; i++ ) + { + sequence[i] = read( i + start ); + } + } +#if !defined(WRAP_JAVA) + /// \brief Reads a value stored in the property as binary data. + /** + * Binary data can only be stored in string properties. When writing binary data to a string + * property it's stored in [Base64](https://en.wikipedia.org/wiki/Base64) format internally. The Base64 algorithm converts arbitrary data + * into a read and printable string representation. As a result of this 3 bytes of arbitrary binary + * data will occupy 4 bytes of memory. + * + * Reading binary data with this function obviously only makes sense if the property has been assigned + * the value by a previous call to \b mvIMPACT::acquire::PropertyS::writeBinary (here you find a small code example as well). + * However using this method any kind of data can be stored by a string property. + * This can e.g. be interesting when certain data shall be stored in the + * user accessible part of the devices non-volatile memory. + * + * \sa \b mvIMPACT::acquire::PropertyS::writeBinary, \n + * \b mvIMPACT::acquire::PropertyS::binaryDataBufferSize, \n + * \b mvIMPACT::acquire::PropertyS::binaryDataBufferMaxSize + * \return The binary data representation of the specified property value as a new std::string object. + */ + std::string readBinary( + /// [in] The index of the value to get(if this property holds more than one value). + int index = 0, + /// [in] If set to \a true this allows applications compiled with mvIMPACT Acquire 2.32.0 or greater using this function + /// to run on systems with mvIMPACT Acquire smaller than 2.32.0. The legacy version of this function runs slower! + bool boLegacyMode = false ) const + { + unsigned int bufSize = boLegacyMode ? binaryDataBufferSize( index ) : binaryDataBufferMaxSize(); + if( bufSize == 0 ) + { + return std::string( "" ); + } + + auto_array_ptr pBuf( bufSize ); + memset( pBuf.get(), 0, bufSize ); + const TPROPHANDLING_ERROR result = boLegacyMode ? OBJ_GetBinary( m_hObj, pBuf.get(), bufSize, index ) : OBJ_GetBinaryEx( m_hObj, pBuf.get(), &bufSize, index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return std::string( pBuf.get(), bufSize ); + } +#endif // #if !defined(WRAP_JAVA) + /// \brief Writes one value to the property. + /** + * This function writes a single value under index \a index to the property. + * + * \return A const 'self' reference. + */ + const PropertyS& write( + /// [in] The value to write to the property. + const std::string& value, + /// [in] The index defining at which position to write the value. + int index = 0 ) const + { + writeS( value, index ); + return *this; + } + /// \brief Writes a set of values to the property. + /** + * This function writes a set of values starting at \a index to the property. + * + * \return A const 'self' reference. + */ + const PropertyS& write( + /// [in] An array containing the values to write to the property. + const std::vector& sequence, + /// [in] The index where to write the first value to the property. + int index = 0 ) const + { + writeS( sequence, index ); + return *this; + } +#if !defined(WRAP_JAVA) + /// \brief Writes a block of binary data to one entry of the property. + /** + * Binary data can only be stored in string properties. When writing binary data to a string + * property it's stored in [Base64](https://en.wikipedia.org/wiki/Base64) format internally. The Base64 algorithm converts arbitrary data + * into a read and printable string representation. As a result of this 3 bytes of arbitrary binary + * data will occupy 4 bytes of memory. + * + * By writing binary data with this function arbitrary data can be stored by a string property. + * This can e.g. be interesting when certain data shall be stored in the + * user accessible part of the devices non-volatile memory. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * char binData [6] = { 'A', 'B', 0x00, -128, 'E', 'F' }; + * const string value( binData, sizeof( binData ) / sizeof( binData[0] ) ); + * PropertyS prop( getHandleFromSomewhere() ); + * prop.writeBinary( value ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * final int BUF_SIZE = 6; + * byte[] data_bytes = new byte[BUF_SIZE]; + * data_bytes[0] = 0x00; + * data_bytes[1] = -1; + * data_bytes[2] = -128; + * data_bytes[3] = 0x33; + * ByteBuffer data = ByteBuffer.allocateDirect( BUF_SIZE ); + * data.put( data_bytes ); + * binaryProp = acquire.PropertyS( getHandleFromSomewhere() ) + * binaryProp.writeBinary( data ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * binData = '\x00\xFF\x80\x33' + * binaryProp = acquire.PropertyS(getHandleFromSomewhere()) + * binaryProp.writeBinary(binData) + * \endcode + * \endif + * + * To find out if a property contains binary data check if \b mvIMPACT::acquire::cfContainsBinaryData is set e.g. by calling + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * PropertyS prop( getHandleFromSomewhere() ); + * if( prop.flags() & cfContainsBinaryData ) + * { + * // Yes!! Binary data + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * PropertyS prop = new PropertyS( getHandleFromSomewhere() ); + * if( ( prop.flags() & TComponentFlag.cfContainsBinaryData ) == TComponentFlag.cfContainsBinaryData ) + * { + * // Yes!! Binary data + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * binaryProp = acquire.PropertyS(getHandleFromSomewhere()) + * if pseudoBinaryProp.flags() & acquire.cfContainsBinaryData: + * # Yes!! Binary data! + * \endcode + * \endif + * + * Performance considerations: + * + * mvIMPACT Acquire 2.15.0 and newer: + * + * - Base64 encoding/decoding only is performed when read string data previously written as binary data and vice versa. + * - encoding/decoding only is performed if the 2 internal caches are out of sync. so only on the first read access using the other format. + * - this version is more efficient compared to previous implementations. + * + * \dot + * digraph BinaryDataHandling2_15 { + * abb [label="Application Binary Buffer"]; + * asb [label="Application String Buffer"]; + * ibs [label="Internal Binary Storage"]; + * iss [label="Internal Base64 Storage"]; + * { rank=same; abb; asb; } + * { rank=same; ibs; iss; } + * abb -> ibs [label="writeBinary:\nmemcpy"]; + * ibs -> abb [label="readBinary:\nmemcpy"]; + * asb -> iss [label="write:\nmemcpy"]; + * iss -> asb [label="read:\nmemcpy"]; + * ibs -> iss [label="Base64(encode)"]; + * iss -> ibs [label="Base64(decode)"]; + * } + * \enddot + * + * mvIMPACT Acquire versions smaller than 2.15.0 + * + * - Base64 encoding/decoding always is performed when reading/writing data in binary format. + * + * \dot + * digraph BinaryDataHandling { + * abb [label="Application Binary Buffer"]; + * asb [label="Application String Buffer"]; + * tb [label="Temporary Buffer"]; + * is [label="Internal Storage"]; + * { rank=same; abb; asb; } + * abb -> tb [label="writeBinary:\nmemcpy"]; + * tb -> is [label="Base64(encode)"]; + * tb -> abb [label="readBinary:\nmemcpy"]; + * is -> tb [label="Base64(decode)"]; + * asb -> is [label="write:\nmemcpy"]; + * is -> asb [label="read:\nmemcpy"]; + * } + * \enddot + * + * \note + * When a property stores binary data that came from a GenICam chunk buffer additional copy operations from the GenApi runtime will take place. This can be + * considered as an additional copy operation into the application binary buffer. So binary chunk data should be avoided if possible! + * + * \sa \b mvIMPACT::acquire::PropertyS::readBinary, \n + * \b mvIMPACT::acquire::PropertyS::binaryDataBufferSize, \n + * \b mvIMPACT::acquire::PropertyS::binaryDataBufferMaxSize + * + * \return A const 'self' reference. + */ + const PropertyS& writeBinary( + /// [in] A const reference to the string holding the binary data that shall + /// be stored by the this property. + const std::string& value, + /// [in] The index defining at which position to write the value. + int index = 0 ) const + { + const TPROPHANDLING_ERROR result = OBJ_SetBinary( m_hObj, value.c_str(), static_cast( value.size() ), index ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hObj ); + } + return *this; + } +#endif // #if !defined(WRAP_JAVA) +}; + +//----------------------------------------------------------------------------- +/// \brief A helper class that represents one entry in the devices non-volatile memory +/** (if available). + * + * Each entry of user and device specific data consists of a name, data a property + * defining the access rights for this entry and an optional password. + * + * The name can be any string, but currently is limited to 255 characters. + * + * The \b mvIMPACT::acquire::UserDataEntry::data property can hold any type of user data that shall be + * stored in the device's non-volatile memory. This can either be a string or binary + * data. To store binary data the function + * \b mvIMPACT::acquire::PropertyS::writeBinary + * can be used. Internally however binary data will be stored as a [Base64](https://en.wikipedia.org/wiki/Base64) encoded string. + * To read binary data from the property again the function + * \b mvIMPACT::acquire::PropertyS::readBinary + * must be called. The theoretical limit for the amount of data per entry is 2^16 (64KB) bytes, + * however the real limit might be below this value because the device does not offer + * that much memory. + * + * The \b mvIMPACT::acquire::UserDataEntry::access property defines the access rights the user has when + * working with the entry. \b AFTER creation but \b BEFORE storing the entry into the device + * this property can be modified. At this point the creator of the entry can choose between 2 options: + * \b mvIMPACT::acquire::udarFull and \b mvIMPACT::acquire::udarRW. + * After storing the entry into the device by calling + * \b mvIMPACT::acquire::UserData::writeToHardware this property will become \b read-only and + * will remain \b read-only until the complete entry is deleted. + * + * When the user creates a new entry for the user accessible device non-volatile memory + * he can either create a read/write data set, which means that every user can modify + * the \a data and the \a name property. In that case the property \a password is ignored. + * Apart from that an entry that can only be modified when the correct password has been + * written to the \a password property. To read a value is always allowed. + * + * The \a password property will hold the user input and \b NOT the actual password needed + * to unlock the data set. However when an entry has been created the creator afterwards can + * write to the password. When the creator then calls the function \b mvIMPACT::acquire::UserData::writeToHardware + * the value of the \a password property is used as the 'real' password from that + * moment onwards. + * + * The maximum length for the password currently is 255 characters. This does not + * provide total security of cause, but the idea of the password only is to hinder + * the user from deleting an import entry by accident. + * + * The memory consumed by a single \b mvIMPACT::acquire::UserDataEntry can vary from device + * to device and depends on the way the data is stored internally. In any case when an entry + * is created it will consume more memory than the amount of bytes written to the + * \b mvIMPACT::acquire::UserDataEntry::data. After data has been written to an entry + * it is therefore important to check the \b mvIMPACT::acquire::UserData::memoryAvailable_bytes + * property if there is still enough memory available. + * + * \note + * There might be entries that can't be modified by the user. These entries contain + * important data that have been written to the memory during production. An attempt + * to delete this data will fail. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * int storeUserData( Device* pDev, char* pData, size_t dataSize, const std::string& entryName ) + * //----------------------------------------------------------------------------- + * { + * UserData& userData = pDev->getUserData(); + * if( !userData.isAvailable() ) + * { + * cout << "This device does not support user data" << endl; + * return -1; + * } + * + * cout << "Available user memory(bytes): " << userData.memoryAvailable_bytes.read() << endl; + * cout << "Memory consumed already(bytes): " << userData.memoryConsumed_bytes.read() << endl; + * + * // create a new entry + * UserDataEntry entry = userData.createEntry(); + * if( !entry.isValid() ) + * { + * cout << "Failed to create new entry" << endl; + * return -2; + * } + * + * string value( pData, dataSize ); + * entry.data.writeBinary( value ); + * entry.name.write( entryName ); + * + * // write to non-volatile memory (therefore the device MUST be closed) + * if( pDev->isOpen() ) + * { + * cout << "Can't store data as the device is already in use" << endl; + * return -3; + * } + * + * userData.writeToHardware(); + * if( pDev->HWUpdateResult.read() != urSetUserDataWriteOK ) + * { + * cout << "Failed to store data in device non-volatile memory" << endl; + * return -4; + * } + * + * // now this data is stored in the devices permanent memory + * return 0; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * public static int storeUserData( Device pDev, byte[] data_bytes, final String entryName ) + * //----------------------------------------------------------------------------- + * { + * UserData userData = pDev.getUserData(); + * if( !userData.isAvailable() ) + * { + * System.out.println( "This device does not support user data" ); + * return -1; + * } + * + * System.out.println( String.format( "Available user memory(bytes): %d", userData.getMemoryAvailable_bytes().read() ) ); + * System.out.println( String.format( "Memory consumed already(bytes): %d", userData.getMemoryConsumed_bytes().read() ) ); + * + * // create a new entry + * UserDataEntry entry = userData.createEntry(); + * if( !entry.isValid() ) + * { + * System.out.println( "Failed to create new entry" ); + * return -2; + * } + * + * ByteBuffer data = ByteBuffer.allocateDirect( data_bytes.length ); + * data.put( data_bytes ); + * entry.getData().writeBinary( data ); + * entry.getName().write( entryName ); + * + * // write to non-volatile memory (therefore the device MUST be closed) + * if( pDev.isOpen() ) + * { + * System.out.println( "Can't store data as the device is already in use" ); + * return -3; + * } + * + * userData.writeToHardware(); + * if( pDev.getHWUpdateResult().read() != THWUpdateResult.urSetUserDataWriteOK ) + * { + * System.out.println( "Failed to store data in device non-volatile memory" ); + * return -4; + * } + * + * // now this data is stored in the devices permanent memory + * return 0; + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * + * def storeUserData(pDev, pData, entryName): + * userData = pDev.getUserData() + * if not userData.isAvailable: + * print("This device does not support user data") + * return -1 + * + * print("Available user memory(bytes): " + str(userData.memoryAvailable_bytes.read())) + * print("Memory consumed already(bytes): " + str(userData.memoryConsumed_bytes.read())) + * + * # create a new entry + * entry = userData.createEntry(); + * if not entry.isValid: + * print("Failed to create new entry") + * return -2; + * + * entry.data.writeBinary(pData) + * entry.name.write(entryName) + * + * # write to non-volatile memory (therefore the device MUST be closed) + * if pDev.isOpen: + * print("Can't store data as the device is already in use") + * return -3 + * + * userData.writeToHardware(); + * if pDev.HWUpdateResult.read() != acquire.urSetUserDataWriteOK: + * print("Failed to store data in device non-volatile memory") + * return -4 + * + * # now this data is stored in the devices permanent memory + * return 0 + * \endcode + * \endif + * + * \note + * Instances of this class can only be created by the class \b UserData. + */ +class UserDataEntry +//----------------------------------------------------------------------------- +{ + friend class UserData; + HLIST m_hList; + //----------------------------------------------------------------------------- + explicit UserDataEntry( HLIST hList ) : m_hList( hList ), name(), data(), access(), password() + //----------------------------------------------------------------------------- + { + if( hList != INVALID_ID ) + { + ComponentLocator locator( hList ); + locator.bindComponent( name, "Name" ); + locator.bindComponent( data, "Data" ); + locator.bindComponent( access, "Access" ); + locator.bindComponent( password, "Password" ); + } + } +public: + /// \brief Call this function to check if this object references an existing entry. + /** + * \return + * - true if this object references an existing entry + * - false otherwise + */ + bool isValid( void ) const + { + return ( ( m_hList != INVALID_ID ) && ( OBJ_CheckHandle( m_hList, hcmFull ) == PROPHANDLING_NO_ERROR ) ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief The name of the entry. + /** + * The maximum length for the name currently is 255 characters. + */ + PropertyS name; + /// \brief The data stored in this entry. + /** + * The theoretical limit for the amount of data per entry is 2^16 (64KB) bytes, + * however the real limit might be below this value because the device does not offer + * that much memory. + * + * This property can either store string or binary data. See \b mvIMPACT::acquire::PropertyS to find + * out how to work with binary data. + */ + PropertyS data; + /// \brief The access rights for this entry. + /** + * After this entry has been written to the devices non-volatile memory, this property + * will become \b read-only. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TUserDataAccessRight. + */ + PropertyIUserDataAccessRight access; + /// \brief The password needed to modify this entry. + /** + * The maximum length for the password is 255 characters currently. When the + * \b mvIMPACT::acquire::udarPassword is not specified + * by the \a access property, this property will be ignored. Otherwise this + * property must have been assigned the correct password (case sensitive) before + * the \a name and \a data properties can be modified. + */ + PropertyS password; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-OFF* +}; + +//----------------------------------------------------------------------------- +/// \brief A helper class to work with the device specific non-volatile memory(if available). +/** + * A device might have a certain amount of non-volatile memory which can be accessed and modified by + * the user. This data can e.g. be used to store certain parameters or custom data permanently into the + * device. Thus this property e.g. can be used to store configuration data in the device before shipping it + * to the end user. + * + * In theory the number of entries that can be stored in the device is not limited. However no device + * will provide an unlimited amount of memory. + * + * Writing data to any property of a \b mvIMPACT::acquire::UserDataEntry as well as creating a new entry by calling + * \b mvIMPACT::acquire::UserData::createEntry or deleting an entry with the function + * \b mvIMPACT::acquire::UserData::deleteEntry will \b NOT automatically result in + * the complete data to be updated in the device specific memory. As writing to the device memory takes + * a long (in terms of ms) time depending on the device architecture the modifications will only become. + * permanent when calling \b mvIMPACT::acquire::UserData::writeToHardware. + * + * If data at the end of the list of entries doesn't fit in the memory it will be discarded and therefore + * will not be visible the next time the device is enumerated/accessed after the running process has + * terminated or the device has been disconnected. + * + * \note + * Entries that contain no data will not be stored in hardware. If e.g. 5 user data entries have been created, + * but only entry 0, 1, 2 and 4 contain data the write operation will pack the data in a way that when the user data + * is read from the device again (when the driver for that device is loaded the next time) the list of entries + * will contain elements at position 0, 1, 2 and 3 but \b NOT a index number 4. Deleting an entry from the middle + * of the list of user data however will \b NOT move all remaining entries one step towards the front of the + * list. Therefore during one session the entry indexes will \b NOT change. They can either become invalid (when + * the corresponding entry has been deleted), can get valid (newly created entries will always appear at the next + * free entry, thus deleting and entry and creating a new directly afterwards will create that entry at exactly the + * same index) or new entries can appear (when a new entry has been created and no free list position in the + * middle of the list of entries has been available). + * + * \note + * The device must be closed in order to write the user data. Check the property \b mvIMPACT::acquire::Device::HWUpdateResult + * afterwards in order to make sure the data transfer was successful. + * + * \note + * If a device does not offer user accessible data \b mvIMPACT::acquire::UserDataEntry objects will still be returned by certain + * functions. To check if this feature is available call \b mvIMPACT::acquire::UserData::isAvailable. + * + * \note + * If the user accessible data currently can't be modified an exception of type \b mvIMPACT::acquire::ENoWriteRights + * will be thrown. + * + * \note + * Instances of this class cannot be constructed directly. To get access the function \b mvIMPACT::acquire::Device::getUserData. + * must be used. + */ +class UserData +//----------------------------------------------------------------------------- +{ + friend class Device; + bool m_boAvailable; + HDEV m_hDev; + ComponentLocator m_userDataEntryLocator; + //----------------------------------------------------------------------------- + explicit UserData( HDEV hDev ) : m_boAvailable( false ), m_hDev( hDev ), m_userDataEntryLocator( hDev ), + reconnectBehaviour(), memoryAvailable_bytes(), memoryConsumed_bytes() + //----------------------------------------------------------------------------- + { + init(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::UserData objects. + UserData& operator=( const UserData& rhs ) + { + if( this != &rhs ) + { + m_boAvailable = false; + m_hDev = rhs.m_hDev; + m_userDataEntryLocator.bindSearchBase( rhs.m_hDev ); + init(); + } + return *this; + } + void init( void ) + { + // check if user data is supported + HOBJ hUserData = m_userDataEntryLocator.findComponent( "UserData" ); + if( hUserData != INVALID_ID ) + { + Component userData( hUserData ); + // check if the driver supports the new enhanced user data access + if( userData.isList() ) + { + m_userDataEntryLocator.bindSearchBase( m_userDataEntryLocator.searchbase_id(), "UserData" ); + m_userDataEntryLocator.bindComponent( reconnectBehaviour, "ReconnectBehaviour" ); + m_userDataEntryLocator.bindComponent( memoryAvailable_bytes, "MemoryAvailable_bytes" ); + m_userDataEntryLocator.bindComponent( memoryConsumed_bytes, "MemoryConsumed_bytes" ); + m_userDataEntryLocator.bindSearchBase( m_userDataEntryLocator.searchbase_id(), "Entries" ); + m_boAvailable = true; + } + } + } +public: + /// \brief Creates and returns a new entry to store user specific data. + /** + * \note + * The data handled by this object will not be stored permanently in the devices non-volatile + * memory until \b mvIMPACT::acquire::UserData::writeToHardware has been called successfully. + * + * \sa + * \b mvIMPACT::acquire::UserData::deleteEntry, \n + * mvIMPACT::acquire::UserData::writeToHardware + * \return A new \b mvIMPACT::acquire::UserDataEntry instance that can be used to store user specific data + * in the devices non-volatile memory. + */ + UserDataEntry createEntry( void ) + { + HLIST hList; + TDMR_ERROR result = DMR_CreateUserDataEntry( m_hDev, &hList ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return UserDataEntry( hList ); + } + /// \brief Deletes an entry of user specific data. + /** + * If the entry has been stored to the non-volatile memory already and has been assigned + * the \b mvIMPACT::acquire::udarPassword flag, this call will fail, when + * \b mvIMPACT::acquire::UserDataEntry::password does not contain the correct password. + * \note + * The data handled by this object will not be removed permanently from the devices non-volatile + * memory until \b mvIMPACT::acquire::UserData::writeToHardware( void ) const has been called successfully. + * \sa + * \b mvIMPACT::acquire::UserData::createEntry, \n + * mvIMPACT::acquire::UserData::writeToHardware + */ + void deleteEntry( + /// [in] A reference to the entry to delete + UserDataEntry& userDataEntry ) + { + TDMR_ERROR result = DMR_DeleteUserDataEntry( m_hDev, userDataEntry.m_hList ); + userDataEntry.m_hList = INVALID_ID; + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief Returns the number of bytes of user accessible, non-volatile memory that is still available. + /** + * + * \since 1.12.64 + */ + int getFreeMemory( void ) const + { + return memoryAvailable_bytes.read() - memoryConsumed_bytes.read(); + } + /// \brief Returns An object to work with an existing entry of user specific data. + /** + * \note + * If an invalid number has been passed as \a nr an object will be returned as well. Therefore + * always check if the entry is valid by calling \b mvIMPACT::acquire::UserDataEntry::isValid before + * working with the object. + * + * \return An object to work with an existing entry of user specific data. + */ + UserDataEntry getUserDataEntry( + /// [in] The number of the entry to return + int nr ) const + { + std::ostringstream oss; + oss << "Entry" << nr; + return UserDataEntry( m_userDataEntryLocator.findComponent( oss.str() ) ); + } + /// \brief Fills an array with all currently valid user data entry indexes. + /** + * This function can be used to obtain a list of valid parameters for calls to the function \b mvIMPACT::acquire::UserData::getUserDataEntry. + * Every value in the returned array will (when passed to the function \b mvIMPACT::acquire::UserData::getUserDataEntry) result in a + * valid \b mvIMPACT::acquire::UserDataEntry object. + */ + void validUserDataEntryIndexes( + /// [out] A reference to the array receiving the list of valid indexes + std::vector& sequence ) const + { + sequence.clear(); + Component it( m_userDataEntryLocator.searchbase_id() ); + if( !it.isValid() ) + { + return; + } + it = it.firstChild(); + if( !it.isValid() ) + { + return; + } + std::string::size_type indexStart = it.name().find_first_of( "0123456789" ); + while( it.isValid() ) + { + sequence.push_back( atoi( it.name().substr( indexStart ).c_str() ) ); + ++it; + } + } + /// \brief This function should be called to check if this device offers non-volatile memory that can be accessed by the user. + /** + * \return + * - true if the device offers non-volatile memory that can be accessed by the user + * - false otherwise + */ + bool isAvailable( void ) const + { + return m_boAvailable; + } + /// \brief Writes the current set of user data into the devices non-volatile memory. + /** + * This function might take a while. Depending on the device architecture and the amount of + * memory up to some hundred ms. Therefore make sure this function is not called more often + * than necessary to let your application perform efficiently. + * \sa + * \b mvIMPACT::acquire::UserData::createEntry, \n + * \b mvIMPACT::acquire::UserData::deleteEntry + */ + void writeToHardware( void ) const + { + TDMR_ERROR result = DMR_WriteUserDataToHardware( m_hDev ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property that can be used to configure how the user data should be treated in case of a device that has been unplugged is plugged back in again. + /** + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TUserDataReconnectBehaviour. + * + * If a device does not support hot-plugging, this property will be invisible (\b mvIMPACT::acquire::Component::isVisible()), + */ + PropertyIUserDataReconnectBehaviour reconnectBehaviour; + /// \brief An integer property \b (read-only) containing the number of bytes of user accessible, non-volatile memory this device has available. + PropertyI memoryAvailable_bytes; + /// \brief An integer property \b (read-only) containing the number of bytes of user accessible, non-volatile memory currently consumed by user data. + /** + * This doesn't indicate that all the data has already been stored in the non-volatile memory, + * but is the number of bytes needed to store the current user data permanently. No check for + * overflows will be performed. If the user defined data exceeds the size of the available memory, + * this data will be lost when disconnecting or switching of the supply voltage for this device. + * + * To write data permanently into the device call the function \b mvIMPACT::acquire::UserData::writeToHardware + * But even after calling this function data that exceeds the available memory will be lost when the + * device looses supply voltage and/or the process terminates. + */ + PropertyI memoryConsumed_bytes; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief This class and its functions represent an actual device detected by this interface in the current system. +/** + * + * Instances of it can only be created by instances of the \b mvIMPACT::acquire::DeviceManager class + * as only the \b mvIMPACT::acquire::DeviceManager has the precise knowledge to do that anyway. + * As a result from this fact pointers to instances of \b mvIMPACT::acquire::Device can be obtained + * via a \b mvIMPACT::acquire::DeviceManager object only. + * + * \attention + * \b NEVER try to explicitly delete an instance of \b mvIMPACT::acquire::Device! You did not allocate it + * and the result will be a crash! The \b mvIMPACT::acquire::DeviceManager will take care of all resources + * for you. + * + * A valid pointer to a \b mvIMPACT::acquire::Device object is needed to construct most of the + * other objects available in this interface. + * + * Almost every object requiering a valid pointer to a \b mvIMPACT::acquire::Device object will + * need to device in an initialized state as the properties provided e.g. by the + * class \b mvIMPACT::acquire::CameraSettingsBase will be constructed when the device is initialized. + * To initialize a device this class provides the function \b Device::open. + * However every object which needs an initialized device to be constructed + * successfully will try to open the device when it hasn't been opened before, so + * the user does not need to call this function explicitly. + * + * \attention + * Whenever a device is closed via a call to \b mvIMPACT::acquire::Device::close + * all other objects constructed with a pointer to that device(e.g. \b mvIMPACT::acquire::CameraSettingsBase + * before will become invalid and need to be reconstructed afterwards, so don't close a device needlessly. + * + * \attention + * Whenever the last instance to a \b DeviceManager object gets + * destroyed within the current process every remaining device that was opened in this process before will + * be closed automatically! + * Thus every instance to \b mvIMPACT::acquire::Device objects or objects created with a pointer to a + * \b mvIMPACT::acquire::Device object will become invalid automatically. + * Therefore the user has to make sure there is always at least one instance to a + * \b mvIMPACT::acquire::DeviceManager object within the current process unless no more + * device access functions shall be called! + */ +class Device +//----------------------------------------------------------------------------- +{ +#ifndef DOXYGEN_SHOULD_SKIP_THIS + // only the DeviceManager is allowed to create Device objects, as it doesn't make + // any sense for someone else anyway. + friend class DeviceManager; + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + HDEV m_hDev; + HDRV m_hDrv; + int m_refCnt; + explicit ReferenceCountedData( HDEV hDev ) : m_hDev( hDev ), m_hDrv( INVALID_ID ), m_refCnt( 1 ) {} + }* m_pRefData; + UserData m_userData; +#endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + void bindPublicProperties( HDEV hDev ) + //----------------------------------------------------------------------------- + { + ComponentLocator locator( hDev ); + locator.bindComponent( deviceClass, "DeviceClass" ); + locator.bindComponent( family, "Family" ); + locator.bindComponent( product, "Product" ); + locator.bindComponent( capabilities, "Capabilities" ); + locator.bindComponent( serial, "Serial" ); + locator.bindComponent( state, "State" ); + locator.bindComponent( deviceID, "DeviceID" ); + locator.bindComponent( deviceVersion, "DeviceVersion" ); + locator.bindComponent( firmwareVersion, "FirmwareVersion" ); + locator.bindComponent( loadSettings, "LoadSettings" ); + locator.bindComponent( autoLoadSettingOrder, "AutoLoadSettingOrder" ); + locator.bindComponent( interfaceLayout, "InterfaceLayout" ); + locator.bindComponent( customDataDirectory, "CustomDataDirectory" ); + locator.bindComponent( defaultRequestCount, "DefaultRequestCount" ); + locator.bindComponent( resultQueueCount, "ResultQueueCount" ); + locator.bindComponent( userControlledImageProcessingEnable, "UserControlledImageProcessingEnable" ); + locator.bindComponent( allowUnrecommendedFeatures, "AllowUnrecommendedFeatures" ); + locator.bindComponent( acquisitionStartStopBehaviour, "AcquisitionStartStopBehaviour" ); + locator.bindComponent( HWUpdateResult, "HWUpdateResult" ); + locator.bindComponent( manufacturer, "Manufacturer" ); + locator.bindComponent( manufacturerSpecificInformation, "ManufacturerSpecificInformation" ); + locator.bindComponent( desiredAccess, "DesiredAccess" ); + locator.bindComponent( grantedAccess, "GrantedAccess" ); + locator.bindComponent( autoNegotiatePacketSize, "AutoNegotiatePacketSize" ); + locator.bindComponent( autoNegotiatePacketSizeMode, "AutoNegotiatePacketSizeMode" ); + } + //----------------------------------------------------------------------------- + HDRV hDrvInternal( void ) const + //----------------------------------------------------------------------------- + { + DMR_GetDriverHandle( m_pRefData->m_hDev, &( m_pRefData->m_hDrv ) ); + return m_pRefData->m_hDrv; + } + //----------------------------------------------------------------------------- + explicit Device( HDEV hDev ) : m_pRefData( new ReferenceCountedData( hDev ) ), m_userData( hDev ), + deviceClass(), family(), product(), capabilities(), serial(), state(), deviceID(), deviceVersion(), + firmwareVersion(), loadSettings(), autoLoadSettingOrder(), interfaceLayout(), + customDataDirectory(), defaultRequestCount(), resultQueueCount(), userControlledImageProcessingEnable(), allowUnrecommendedFeatures(), + acquisitionStartStopBehaviour(), HWUpdateResult(), manufacturer(), manufacturerSpecificInformation(), desiredAccess(), grantedAccess(), autoNegotiatePacketSize(), autoNegotiatePacketSizeMode() + //----------------------------------------------------------------------------- + { + bindPublicProperties( hDev ); + } +public: + /// \brief Copy constructor. + /** + * Creates a new object from an existing device object. Keep in mind that this new object + * will provide access to the very same hardware and therefore you might as well use the original + * reference returned from the \b mvIMPACT::acquire::DeviceManager. This constructor + * is only provided for internal reference counting to guarantee correct operation of the + * objects of this class under all platforms and languages. + */ + explicit Device( const Device& src ) : m_pRefData( src.m_pRefData ), m_userData( src.m_pRefData->m_hDev ), + deviceClass( src.deviceClass ), family( src.family ), product( src.product ), + capabilities( src.capabilities ), serial( src.serial ), state( src.state ), + deviceID( src.deviceID ), deviceVersion( src.deviceVersion ), firmwareVersion( src.firmwareVersion ), loadSettings( src.loadSettings ), + autoLoadSettingOrder( src.autoLoadSettingOrder ), interfaceLayout( src.interfaceLayout ), + customDataDirectory( src.customDataDirectory ), defaultRequestCount( src.defaultRequestCount ), resultQueueCount( src.resultQueueCount ), + userControlledImageProcessingEnable( src.userControlledImageProcessingEnable ), allowUnrecommendedFeatures( src.allowUnrecommendedFeatures ), + acquisitionStartStopBehaviour( src.acquisitionStartStopBehaviour ), + HWUpdateResult( src.HWUpdateResult ), manufacturer( src.manufacturer ), manufacturerSpecificInformation( src.manufacturerSpecificInformation ), + desiredAccess( src.desiredAccess ), grantedAccess( src.grantedAccess ), autoNegotiatePacketSize( src.autoNegotiatePacketSize ), autoNegotiatePacketSizeMode( src.autoNegotiatePacketSizeMode ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + /** + * \note + * This destructor must only be called for objects that have been created directly by + * the user on unmanaged heaps. Under most circumstances this means \b NEVER. E.g. for instances + * that have been obtained from a \b mvIMPACT::acquire::DeviceManager object do \b NOT call + * this destructor. The \b mvIMPACT::acquire::DeviceManager will take care of all the + * resources for you. + */ + ~Device( void ) + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::Device objects. + Device& operator=( const Device& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++( m_pRefData->m_refCnt ); + bindPublicProperties( m_pRefData->m_hDev ); + m_userData = UserData( rhs.m_pRefData->m_hDev ); + } + return *this; + } + /// \brief Closes an opened device. + /** + * This function closes a device previously opened again. + * + * \attention + * Whenever a device is closed via a call to \b mvIMPACT::acquire::Device::close + * all other objects constructed with a pointer to that device(e.g. \b mvIMPACT::acquire::CameraSettingsBase + * before will become invalid and need to be reconstructed afterwards, so don't close a device needlessly. + * + * \sa + * \b Device::open, \n \b Device::isOpen + */ + void close( void ) + { + HDRV hDrv = hDrvInternal(); + if( hDrv != INVALID_ID ) + { + DMR_CloseDevice( hDrv, m_pRefData->m_hDev ); + m_pRefData->m_hDrv = INVALID_ID; + } + } + /// \brief Checks whether this device has a certain capability. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceCapability. + * + * \return + * - true if the device has the capability in question + * - false otherwise. + */ + bool hasCapability( + /// [in] The capability who's presence shall be checked. + TDeviceCapability capability ) const + { + return ( ( capabilities.isValid() ) ? ( ( capabilities.read() & capability ) == capability ) : false ); + } + /// \brief A unique identifier for this device. + /** + * \note + * This handle is \b NOT to be confused with the id stored in the devices EEPROM + * The latter one represents a number stored somewhere in the physical device's EEPROM, while + * this handle can be assumed as a handle from a software based point of view. + */ + HDEV hDev( void ) const + { + return m_pRefData->m_hDev; + } + /// \brief A unique identifier for the functionality offered by this device. + /** + * + * \note + * This identifier is only valid, if the device has been initialized + * before by a call to \b Device::open + */ + HDRV hDrv( void ) const + { + return ( m_pRefData->m_hDrv != INVALID_ID ) ? m_pRefData->m_hDrv : hDrvInternal(); + } + /// \brief Returns a list providing access to driver library specific features. + /** + * This list does exist only once per device driver library. Changes in this list will affect all + * devices that are operated using this device driver library. + * + * \since 2.17.0 + */ + ComponentList deviceDriverFeatureList( void ) const + { + HOBJ hObj = INVALID_ID; + size_t bufSize = sizeof( hObj ); + TDMR_ERROR result = DMR_GetDeviceInfoEx( m_pRefData->m_hDev, dmdithDeviceDriver, &hObj, &bufSize ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return ComponentList( hObj ); + } + /// \brief Returns the current initialisation status in this process. + /** + * If this function returns \a true, this only states that the current + * process has not opened the device in question already. A call to \b mvIMPACT::acquire::Device::open() + * can still fail because of some other process using this device. + * + * \sa + * \b Device::open, \n \b Device::close + * \return + * - true if the device is initialized(opened) in the current process. + * - false otherwise. + */ + bool isOpen( void ) const + { + return hDrvInternal() != INVALID_ID; + } + /// \brief Returns the current usage status of this device. + /** + * If this function returns \a true, this device was not in use at the time of calling this function. + * A call to \b mvIMPACT::acquire::Device::open() can still fail afterwards if some other process on the system + * claimed the device in the time between this call and the call to \b mvIMPACT::acquire::Device::open(). + * + * \sa + * \b Device::open, \n \b Device::close + * + * \since 2.0.11 + * \return + * - true if the device is in use by at least one process(this includes the calling process). + * - false otherwise. + */ + bool isInUse( void ) const + { + if( isOpen() ) + { + return true; + } + unsigned int inUse = 0; + size_t bufSize = sizeof( inUse ); + TDMR_ERROR result = DMR_GetDeviceInfoEx( m_pRefData->m_hDev, dmditDeviceIsInUse, &inUse, &bufSize ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return inUse != 0; + } + /// \brief Opens a device. + /** + * This function will try to open the device represented by this instance of + * \b mvIMPACT::acquire::Device. If this fails for any reason an exception will be thrown. The exception + * object will contain additional information about the reason for the error. + * + * Calling this function is not really necessary, as each object for accessing + * other settings of the device or even the function interface need the device to + * be opened in order to be constructed. Therefore all the constructors for these + * objects check if the device is open by calling \b mvIMPACT::acquire::Device::isOpen and open + * the device if necessary. + * + * \note + * Keep in mind that the first object trying to open the device might therefore + * throw an exception as well if opening the device fails for some reason. + * + * Whenever a device is opened, the driver executes the following procedure: + * + *
Device_Setting_Start_Procedure.png
+ *
Device setting start procedure
+ * + * Please have a look here for more information about automatic loading of + * settings when a device is opened. + */ + void open( void ) + { + TDMR_ERROR result = DMR_OpenDevice( m_pRefData->m_hDev, &( m_pRefData->m_hDrv ) ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief Assigns a new ID to this device. + /** + * To allow any application to distinguish between different devices of the same + * type the user can assign an unique ID to each device using this function. This ID + * currently is limited to values between 0 and 250 and is stored in the devices + * internal memory. This ID is \b NOT volatile. It will remain stored even if + * the device is unplugged. + * + * \note + * \b REMARKS: + * \note + * - The device must be \b closed to assign a new ID. + * - This ID is not to be confused with the handle returned by the function \b mvIMPACT::acquire::Device::hDev. + * The latter one represents something which can be assumed as a handle from a software based point + * of view, while the ID represented by the property \b mvIMPACT::acquire::Device::deviceID is an ID stored in the physical + * devices EEPROM. + * - Not every device will offer this feature! When calling this function for a device that does not + * offer this feature, the function will return \b mvIMPACT::acquire::DMR_FEATURE_NOT_AVAILABLE. + * + * \sa + * \b mvIMPACT::acquire::Device::open, \n \b mvIMPACT::acquire::Device::close + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int setID( + /// [in] The new \a ID that shall be assigned to the device. + int newID ) const + { + return DMR_SetDeviceID( m_pRefData->m_hDev, newID ); + } + /// \brief Updates the firmware of the device. + /** + * Calling this function will cause the driver to download a firmware version compiled + * into the driver library into the devices non-volatile internal memory. + * + * \note + * - This feature currently is only available for \b mvBlueFOX devices. To update the firmware of other devices please refer to the tool \c mvDeviceConfigure(this tool also offers a command line interface) + * - Be sure you know what you are doing \b before calling this function. Under normal circumstances + * it won't be necessary to update a devices firmware. + * - The download will take some time (depending on the device up to 30 seconds). During this time + * the device and the thread calling this function will \b NOT respond. + * - Do \b NOT interrupt this download. + * - After a successful download a USB device needs to be unplugged and plugged in again. + * Otherwise the new firmware version will not be activated. + * - To download a new firmware version the device must be \b closed. + * - Not every device will offer this feature! When calling this function for a device that does not + * offer this feature, the function will return \b mvIMPACT::acquire::DMR_FEATURE_NOT_AVAILABLE. + * + * \sa + * \b mvIMPACT::acquire::Device::open, \n \b mvIMPACT::acquire::Device::close + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int updateFirmware( void ) const + { + return DMR_UpdateFirmware( m_pRefData->m_hDev ); + } + /// \brief Returns a reference to a helper class to handle user specific data stored in the devices non-volatile memory(if available). + /** + * \return A reference to a helper class to handle user specific data stored in the devices + * non-volatile memory(if available). + */ + UserData& getUserData( void ) + { + return m_userData; + } + /// \brief A convenience function mostly used internally. Raises an exception if the current value of mvIMPACT::acquire::Device::interfaceLayout does not match the value passed to the function. + /** + * If a driver does not support the interface layout property this function does nothing! + */ + void validateInterfaceLayout( TDeviceInterfaceLayout requiredInterfaceLayout ) const + { + if( interfaceLayout.isValid() ) + { + if( interfaceLayout.read() != requiredInterfaceLayout ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_INVALID_PARAMETER, "The current interface layout does not support the current operation or object instantiation. Refer to the API documentation for details about different interface layouts" ); + } + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property \b (read-only) defining the device class this device belongs to. + /** + * \note + * This property has been added to the device driver in version 1.8.3 thus might not be available when + * working with old device drivers. Therefore always call the function \b mvIMPACT::acquire::Component::isValid + * to check if this property is available or not. + */ + PropertyIDeviceClass deviceClass; + /// \brief A string property \b (read-only) containing the family name of this device. + PropertyS family; + /// \brief A string property \b (read-only) containing the product name of this device. + PropertyS product; + /// \brief An enumerated integer property \b (read-only) defining special device capabilities. + /** + * This property stores certain device capabilities that can be read without opening the device. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceCapability. + */ + PropertyIDeviceCapability capabilities; + /// \brief A string property \b (read-only) containing the serial number of this device. + PropertyS serial; + /// \brief An enumerated integer property \b (read-only) containing the current state of this device. + /** + * This property e.g. provides information about the current state of the device. For USB devices this can e.g. indicate whether + * a device is currently plugged into the system or not. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceState. + * + * \b GenICam/GenTL \b device \b specific: + * In order to reduce the amount of network traffic to a minimum, this property will only be updated automatically + * for network devices if the property \b mvIMPACT::acquire::Device::registerErrorEvent is set to + * \b mvIMPACT::acquire::bTrue (which is the default behaviour). If the IP addresses stay the same the + * connection is automatically re-established then once the device is detected by the driver again. + * However if the IP address of the device and/or the network adapter of the system it is used from changes + * \b mvIMPACT::acquire::DeviceManager::updateDeviceList() + * must be called regardless of the value of \b mvIMPACT::acquire::Device::registerErrorEvent before a device + * that was lost can re-establish a connection to the capture driver. + * Apart from that \b ALL \b GenICam/GenTL will only update this property automatically if the device is + * currently in use \b BY \b THIS \b PROCESS, so when the device has been opened. This is also to save + * bandwidth and resources! + */ + PropertyIDeviceState state; + /// \brief An integer property \b (read-only) containing the device ID associated with this device. + /** + * A device ID can be used to identify a certain device in the system. The ID is an 8 bit unsigned + * integer value stored in the device's EEPROM. In order to allow the + * distinct detection of a device via its device ID, the user has to make sure that two devices + * belonging to the same product family never share the same ID. + * + * \note + * \b REMARKS: + * \note + * - To modify the device ID a separate tool will be provided. To modify the device + * ID without that tool the function \b mvIMPACT::acquire::Device::setID can be called. + * - This ID is not to be confused with the handle returned by the function \b mvIMPACT::acquire::Device::hDev. + * The latter one represents something which can be assumed as a handle from a software based point + * of view, while the ID represented by the property \a deviceID is an ID stored in the physical + * devices EEPROM. + */ + PropertyI deviceID; + /// \brief A string property \b (read-only) containing the version(e.g. the hard ware revision) of this device. + /** + * \note + * This feature is supported by every device driver. If a device does not seem to support this feature (calling \b mvIMPACT::acquire::Component::isValid returns false) + * a driver update will fix this. + */ + PropertyS deviceVersion; + /// \brief An integer property \b (read-only) containing the firmware version of this device. + /** + * A firmware is considered to be something that is stored in non volatile device memory, thus when a device + * is disconnected from the power supply and plugged into a different target system the same code will be executed + * on the device. + * + * Some devices however may not support non volatile memory to accommodate a firmware. Typically the device driver then will download + * a firmware into the devices RAM at startup. Such devices will be considered as not supporting a firmware as in this + * case only the driver version present on the target system has impact on the devices behaviour. + * + * When a device does not support a non volatile firmware, reading this property will always return 0. + */ + PropertyI firmwareVersion; + /// \brief An enumerated integer property which can be used to define which previously stored setting to load when the device is opened. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceLoadSettings. + * + * \note + * Once the device is in use (has been initialized) this property will become \b (read-only). + */ + PropertyIDeviceLoadSettings loadSettings; + /// \brief A string property \b (read-only) containing the auto load order of feature settings that is executed during initialisation of the device. + /** + * The first setting detected on the system will be used. + */ + PropertyS autoLoadSettingOrder; + /// \brief An enumerated integer property which can be used to define which interface layout shall be used when the device is opened. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceInterfaceLayout. + * + * \note + * Once the device is in use (has been initialized) this property will become \b (read-only). + * + * \note + * This feature is available for every device. A device not offering this feature requires a driver update. Always check + * for the availability of this feature by calling \b mvIMPACT::acquire::Component::isValid. + * + * Not every device will offer the same options. + * Check for valid modes by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIDeviceInterfaceLayout::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIDeviceInterfaceLayout::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIDeviceInterfaceLayout::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyIDeviceInterfaceLayout interfaceLayout; + /// \brief A string property \b (read-only once the device is open) containing a path to a custom directory for the location of camera description files, etc. + /** + * When a custom path is assigned to this property this path will be used to locate certain driver specific files + * and folders. Under this folder the following structure must be created: + * + * \code + * + * |- CameraFiles // this folder will be searched by frame grabbers for camera description files + * |- GenICam // this folder will be searched by GenICam compliant devices that refer to a local GenICam™ description file + * \endcode + * + * If this property is left empty + * \code + * %ALL USERS%/Documents/MATRIX VISION/mvIMPACT acquire + * \endcode + * will be used by default on Windows™ platforms and + * \code + * /etc/matrix-vision/mvimpact-acquire + * \endcode + * on Linux platforms. + */ + PropertyS customDataDirectory; + /// \brief An integer property that defines the number of \b mvIMPACT::acquire::Request objects to be created when the device is opened. + /** + * By writing to this property an application can define the default number of \b mvIMPACT::acquire::Request + * objects that will be allocated when opening the device. + * + * \note + * This property will become read-only while the device is open. + * + * \sa + * \b mvIMPACT::acquire::SystemSettings::requestCount to change the number of request objects later and to find out why this parameter is important + */ + PropertyI defaultRequestCount; + /// \brief An integer property that defines the number of result queues to be created when the device is opened. + /** + * By writing to this property an application can define the number of result queues that will be allocated + * when opening the device. When requesting buffers the user can define in which result queue a processed request shall + * end up by writing to the property \b mvIMPACT::acquire::ImageRequestControl::resultQueue. When waiting for a request to become ready by calling \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor + * the application can specify on which queue to wait. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * Device* pDev = getDevicePointerFromSomewhere(); + * pDev->resultQueueCount.write( 2 ); + * ImageRequestControl irc( pDev ); + * FunctionInterface fi( pDev ); + * irc.resultQueue.write( 0 ); + * fi.imageRequestSingle( &irc ); // request a buffer that will be stored in queue 0 when ready + * irc.resultQueue.write( 1 ); + * fi.imageRequestSingle( &irc ); // request a buffer that will be stored in queue 1 when ready + * fi.imageRequestWaitFor( 500, 0 ); // wait on queue 0 + * fi.imageRequestWaitFor( 500, 1 ); // wait on queue 1 + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * Device pDev = getDevicePointerFromSomewhere(); + * pDev.getResultQueueCount().write( 2 ); + * ImageRequestControl irc = new ImageRequestControl( pDev ); + * FunctionInterface fi = new FunctionInterface( pDev ); + * irc.getResultQueue().write( 0 ); + * fi.imageRequestSingle( irc ); // request a buffer that will be stored in queue 0 when ready + * irc.getResultQueue().write( 1 ); + * fi.imageRequestSingle( irc ); // request a buffer that will be stored in queue 1 when ready + * fi.imageRequestWaitFor( 500, 0 ); // wait on queue 0 + * fi.imageRequestWaitFor( 500, 1 ); // wait on queue 1 + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * pDev = getDeviceFromSomewhere() + * pDev.resultQueueCount.write(2) + * irc = ImageRequestControl(pDev) + * fi = FunctionInterface(pDev) + * irc.resultQueue.write(0) + * fi.imageRequestSingle(irc) # request a buffer that will be stored in queue 0 when ready + * irc.resultQueue.write(1) + * fi.imageRequestSingle(irc) # request a buffer that will be stored in queue 1 when ready + * fi.imageRequestWaitFor(500, 0) # wait on queue 0 + * fi.imageRequestWaitFor(500, 1) # wait on queue 1 + * \endcode + * \endif + * + * This can be useful e.g. when working with 2 different settings to sort all buffer capture with setting 0 into one queue + * and all the others into another queue. + * \note + * This property will become read-only while the device is open. + * + * \sa + * \b mvIMPACT::acquire::ImageRequestControl::resultQueue, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor + */ + PropertyI resultQueueCount; + /// \brief An enumerated integer property defining whether user controlled image processing related features shall be created under 'System Settings' or not. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * Setting this feature to \b mvIMPACT::acquire::bTrue will result in a separate thread being created when opening the + * device driver instance. The thread will decouple the host based image processing from the acquisition engine. Apart + * from that it will also create additional properties in the \c ImageProcessingControl list under \c SystemSettings that + * can be used to control the behaviour of this thread. This might be useful e.g. to make sure images can be acquired faster + * than they can be processed and it is not needed to processed each image. + * + * \note + * This property will become read-only while the device is open. + * + * \sa + * \b mvIMPACT::acquire::SystemSettings::imageProcessingMode \n + * \b mvIMPACT::acquire::Request::hasProcessingBeenSkipped + * + * \since 2.14.0 + * + */ + PropertyIBoolean userControlledImageProcessingEnable; + /// \brief An enumerated integer property which can be used to unlock certain features, that are available but not recommended by the device manufacturer. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * This property will be invisible by default. As the name indicates its use requires special + * knowledge that can be provided by the device manufacturer on request. + * + * \note + * Once the device is in use (has been initialized) this property will become \b (read-only). + * + * \attention + * Unlocking certain unrecommended features might result in the appearance of new translation + * dictionary entries for certain properties. Some of these translation strings might contain + * an exclamation mark ('!') in its name. \b NEVER rely on that! These exclamation marks + * or even the complete entry might disappear with a new driver release without further notice! + */ + PropertyIBoolean allowUnrecommendedFeatures; + /// \brief An enumerated integer property defining the start/stop behaviour during acquisition of this driver instance. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAcquisitionStartStopBehaviour. + * + * \note + * This property will become read-only while the device is open. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * + * Not every device will offer the same options. + * Check for valid modes by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIAcquisitionStartStopBehaviour::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIAcquisitionStartStopBehaviour::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIAcquisitionStartStopBehaviour::getTranslationDict + * in addition to the functions mentioned above. + * \endif + * + * \since 1.12.11 + */ + PropertyIAcquisitionStartStopBehaviour acquisitionStartStopBehaviour; + /// \brief An enumerated integer property \b (read-only) defining user executed hardware update results. + /** + * This property e.g. might contain the result of a user executed firmware update. + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::THWUpdateResult. + */ + PropertyIHWUpdateResult HWUpdateResult; + /// \brief A string property \b (read-only) containing the name of the manufacturer of this device. + /** + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * + * \since 2.11.3 + */ + PropertyS manufacturer; + /// \brief A string property \b (read-only) containing manufacturer specific information of this device. + /** + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * + * \since 2.18.3 + */ + PropertyS manufacturerSpecificInformation; + /// \brief An enumerated integer property that can be used to define the desired access to the device when opening it. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceAccessMode. + * + * \note + * This property will become read-only while the device is open. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIDeviceAccessMode desiredAccess; + /// \brief An enumerated integer property \b (read-only) that can be used to query the granted access to the device after an attempt to open it. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceAccessMode. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIDeviceAccessMode grantedAccess; + /// \brief An enumerated integer property which can be used to enable or disable the MTU auto negotiation of a GigE Vision device when opening it. + /** + * If set to true, the driver will try to determine the max. possible packet size during init, which if successful will result in optimal performance. + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note Once the device is in use (has been initialized) this property will become \b (read-only). If this feature is disabled even before the device has been opened a + * firmware update is needed to use it when accessed via the \c mvGenTLProducer-lib. When using a 3rd party GenTL producer to access the GigE Vision device this + * feature will not be available. + * + * \note This property might not supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean autoNegotiatePacketSize; + /// \brief An enumerated integer property \b (read-only) that can be used to define how the auto packet size negotiation for a GigE Vision device is handled. + /** + * If set to \b mvIMPACT::acquire::danpsmHighToLow the MTU is automatically negotiated starting from the NICs current MTU down to a value supported by all components belonging to the network path + * (device, network interface card, switches, ...), if set to \b mvIMPACT::acquire::danpsmLowToHigh the negotiation starts with the small value tries larger values with each iteration until the + * optimal value has been found. + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceAutoNegotiatePacketSizeMode. + * + * \note Once the device is in use (has been initialized) this property will become \b (read-only). When using a 3rd party GenTL producer to access the GigE Vision device this + * feature will not be available. + * + * \note This property might not supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIDeviceAutoNegotiatePacketSizeMode autoNegotiatePacketSizeMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Grants access to devices that can be operated by this software interface. +/** + * This class will grant access to any device installed on/in the + * current system. Whenever somewhere in the code a \b mvIMPACT::acquire::DeviceManager instance is + * created it can be used to access any device currently + * supported and available. \n \n This is the only class which is allowed to + * create instances of the class \b mvIMPACT::acquire::Device, which are needed to access a certain + * device. + * + * \note + * There always has to be at least one instance of the mvIMPACT::acquire::DeviceManager when + * the user still works with \b mvIMPACT::acquire::Device objects! When the last instance to + * this object is destroyed all remaining \b mvIMPACT::acquire::Device objects will be closed + * automatically and every device driver will be unloaded from the current process memory! + * + * If a device is installed in the system but an appropriate driver has not been installed, this class + * will \b NOT list these devices. + * + * As a result of this every program written by the use of this interface + * will create an instance of \b mvIMPACT::acquire::DeviceManager before performing any other + * operations which uses objects or functions from this interface. + * + * During the construction of a \b mvIMPACT::acquire::DeviceManager object the system will be scanned + * for supported devices and once the instance has been created the object will + * provide an up to date list of devices whenever the user asks for it. Some devices when plugged into + * the system after the device manager has been created might require an explicit update of the device + * list. This can be triggered by an application by calling \b mvIMPACT::acquire::DeviceManager::updateDeviceList(). + * When there is currently no \b mvIMPACT::acquire::DeviceManager instance within the process creating + * the first one will result in all supported driver stacks to be loaded dynamically. See remarks below for + * consequences that result from this. + * + * This class also provides various functions to find a particular device in the system. + * Devices can e.g. be found by family or by serial number. + * + * \attention + * \b NEVER try to explicitly delete an instance of \b mvIMPACT::acquire::Device! You did not allocate it + * and the result will be a crash! The \b mvIMPACT::acquire::DeviceManager will take care of all resources + * for you. + * + * \note + * A \b mvIMPACT::acquire::DeviceManager object will initially return pointers to \b mvIMPACT::acquire::Device objects, + * which all seem to be closed. However one or more of the devices might have been opened + * by another instance of the device manager running in a different + * process. In that case the attempt to open a device, which seems to be closed will raise + * an exception with the error code \b mvIMPACT::acquire::DMR_DRV_ALREADY_IN_USE, which MUST + * be handled by the user. + * + * \attention + * \b NEVER declare a global instance of this class within a dynamic library(*.dll, *.so, *.ocx, ...), as creating + * this instance will result in other shared libraries to be loaded dynamically by the framework. If you do, applications + * using your library might lock up because global objects might be constructed from (Windows) the \c DllMain context + * and loading other libraries from within \c DllMain is discouraged (see \c DllMain \c Best \c Practices in MSDN for + * example). Instead either attach your instance of the device manager to a singleton, declare a global pointer that gets + * initialised/destroyed by custom library init/close functions or use any other approach that suits your needs. + * + * \b EXAMPLE CODE: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * void obtainDevicePointers( void ) + * //----------------------------------------------------------------------------- + * { + * // Create an instance of the device manager to get access + * // to supported devices. + * DeviceManager devMgr; + * + * // show all devices + * for( unsigned int i=0; i DevVector; + HDMR m_deviceBaseList; + mutable DevVector m_devVector; + mutable unsigned int m_lastChangedCounter; + int* m_pRefCnt; + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + if( m_pRefCnt ) + { + --( *m_pRefCnt ); + for( unsigned int i = 0; i < m_devVector.size(); i++ ) + { + delete m_devVector[i]; + } + m_devVector.clear(); + // free reference count memory if no one uses it anymore + if( *m_pRefCnt == 0 ) + { + delete m_pRefCnt; + m_pRefCnt = 0; + } + } + } + //----------------------------------------------------------------------------- + Device* getDevice( TDMR_DeviceSearchMode mode, const std::string& search_string, unsigned int devNr, char wildcard ) const + //----------------------------------------------------------------------------- + { + updateInfoVector(); + Device* pResult = 0; + HDEV device; + if( DMR_GetDevice( &device, mode, search_string.c_str(), devNr, wildcard ) == DMR_NO_ERROR ) + { + DevVector::size_type vSize = m_devVector.size(); + for( DevVector::size_type i = 0; i < vSize; i++ ) + { + if( m_devVector[i]->hDev() == device ) + { + pResult = m_devVector[i]; + break; + } + } + } + return pResult; + } + //----------------------------------------------------------------------------- + Device* getDevice( TDMR_DeviceSearchMode mode, const std::string& search_string, const std::string& deviceID, char wildcard ) const + //----------------------------------------------------------------------------- + { + updateInfoVector(); + Device* pResult = 0; + HDEV device; + if( DMR_GetDeviceWithStringID( &device, mode, search_string.c_str(), deviceID.c_str(), wildcard ) == DMR_NO_ERROR ) + { + DevVector::size_type vSize = m_devVector.size(); + for( DevVector::size_type i = 0; i < vSize; i++ ) + { + if( m_devVector[i]->hDev() == device ) + { + pResult = m_devVector[i]; + break; + } + } + } + return pResult; + } + //----------------------------------------------------------------------------- + bool updateInfoVector( void ) const + //----------------------------------------------------------------------------- + { + Component iter( m_deviceBaseList ); + unsigned int changedCount = iter.changedCounter(); + if( m_lastChangedCounter == changedCount ) + { + return false; + } + + m_lastChangedCounter = changedCount; + + unsigned int curDevCnt = 0; + size_t vSize = m_devVector.size(); + DMR_GetDeviceCount( &curDevCnt ); + if( curDevCnt <= static_cast( vSize ) ) + { + return false; + } + + HDEV hDev = INVALID_ID; + for( size_t i = vSize; i < curDevCnt; i++ ) + { + DMR_GetDevice( &hDev, dmdsmSerial, "*", static_cast( i ), '*' ); + if( hDev != INVALID_ID ) + { + m_devVector.push_back( new Device( hDev ) ); + } + } + return true; + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::DeviceManager object. + /** + * If the construction of this object fails for some reason this constructor + * might throw an exception of type \b mvIMPACT::acquire::ImpactAcquireException or a type + * derived from this class. + */ + explicit DeviceManager( void ) : m_deviceBaseList( INVALID_ID ), m_devVector(), m_lastChangedCounter( 0 ), m_pRefCnt( 0 ) + { + TDMR_ERROR result; + if( ( result = DMR_Init( &m_deviceBaseList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + m_pRefCnt = new int(); + *m_pRefCnt = 1; + } + /// \brief Constructs a new \b mvIMPACT::acquire::DeviceManager object from an existing one. + /** + * If the construction of this object fails for some reason this constructor + * might throw an exception of type \b mvIMPACT::acquire::ImpactAcquireException or a type + * derived from this class. + */ + DeviceManager( const DeviceManager& src ) : m_deviceBaseList( INVALID_ID ), m_devVector(), m_lastChangedCounter( 0 ), m_pRefCnt( src.m_pRefCnt ) + { + // we don't need to copy data as the necessary updates are done anyway. + // But we have to call the underlying C-API to achieve correct reference counting. + TDMR_ERROR result; + if( ( result = DMR_Init( &m_deviceBaseList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + ++( *m_pRefCnt ); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::DeviceManager objects. + DeviceManager& operator=( const DeviceManager& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefCnt = rhs.m_pRefCnt; + // inc. the NEW reference count + ++( *m_pRefCnt ); + // this will fill the device vector with up to date data the next time someone asks + // for a device. + m_lastChangedCounter = 0; + m_devVector.clear(); + } + return *this; + } + /// \brief Class destructor. + /** + * There always has to be at least one instance of the \b DeviceManager when + * the user still works with \b mvIMPACT::acquire::Device objects, as when the last instance to + * this object is destroyed all remaining \b mvIMPACT::acquire::Device objects will be closed + * automatically! + */ + virtual ~DeviceManager( void ) + { + dealloc(); + DMR_Close(); + } + /// \brief Returns a string containing the version number of the specified library. + /** + * This function returns a string containing the version number of the specified library. + * + * The format of the string will be MAJOR.MINOR.RELEASE.BUILD. + * \since 2.1.2 + * \return A pointer to an internal version string. + */ + static std::string getVersionAsString( + /// [in] Specifies the library to query information from. + TLibraryQuery libraryQuery ) + { + return DMR_GetVersion( libraryQuery ); + } +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + /// \brief Returns the internal handle to the device manager created via \b DMR_Init(). + HDMR getInternalHandle( void ) const + { + return m_deviceBaseList; + } +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) + /// \brief Returns a pointer to a \b mvIMPACT::acquire::Device object. + /** + * Returns a pointer to a \b mvIMPACT::acquire::Device object specifying the device found at the given + * index in the device managers internal list. + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of devices detected \n + * a STL out_of_range exception is thrown. + * \endif + * + * \sa + * \b mvIMPACT::acquire::DeviceManager::deviceCount, \n + * \b mvIMPACT::acquire::DeviceManager::getDeviceBySerial, \n + * \b mvIMPACT::acquire::DeviceManager::getDeviceByFamily, \n + * \b mvIMPACT::acquire::DeviceManager::getDeviceByProduct + * \return + * - A pointer to the device if found. + * - an invalid pointer or reference otherwise. + */ + Device* operator[]( + /// [in] The index of the device to be returned. + unsigned int index ) const + { + return getDevice( index ); + } + /// \brief Returns the current changed counter for the device list. + /** + * This is a useful function to find out if the device list has been changed in any + * way. Such a change might be the appearance of a new USB device or a state change + * of any other device (e.g. when a USB device has been unplugged). Thus this function + * can be called periodically in order to maintain lists in GUI application for example. + * To find out the actual number of devices call \b mvIMPACT::acquire::DeviceManager::deviceCount. + * \return The current changed counter for the device list. + */ + unsigned int changedCount( void ) const + { + return Component( m_deviceBaseList ).changedCounter(); + } + /// \brief Returns the number of devices currently present in the system. + /** + * This function returns the number of devices currently detected in the system. A + * device once connected to the system while the device manager was running will remain + * in its list even if it's unplugged (then only its state will change). To detect + * changes in the \b mvIMPACT::acquire::DeviceManager objects list call the function + * \b mvIMPACT::acquire::DeviceManager::changedCount. + * \return The number of devices detected in the current system. + */ + unsigned int deviceCount( void ) const + { + updateInfoVector(); + return static_cast( m_devVector.size() ); + } + /// \brief Updates the internal device list. + /** + * Most devices can't appear out of nowhere. For example a PCI device is + * either connected to the current system when the device manager is initialized + * or not but it will never appear at runtime after this instance of \b mvIMPACT::acquire::DeviceManager + * has been created. + * + * However certain device classes (e.g. network devices) might be connected to + * the system \b AFTER the device manager has been initialized. Some will announce themselves + * like e.g. USB devices, which will send a message to every application interested while others + * like e.g. network devices wont. In order not to + * pollute the network or bus with constant rescan messages no polling is done inside the driver. + * the user should call this function instead when looking for new devices. This can either be done in reasonable intervals or after + * it is known that a new device has been connected to the system. + * + * If new devices have been detected a subsequent call to \b mvIMPACT::acquire::DeviceManager::deviceCount + * will result in a higher value when compared to a previous call and \b mvIMPACT::acquire::DeviceManager::changedCount + * will contain a different value as well then (however this could also happen because a certain device related property did change + * its state). + * + * \note + * As long as a certain instance of a device manager is active, the devices once detected will \b NOT + * disappear from the list of devices even if they have been unplugged from the system. So the list + * of devices can only grow, but never gets shorter again until either the process terminates or the + * last instance of this class went out of scope. If a device has been unplugged, its \b mvIMPACT::acquire::Device::state + * property will change. If the application is interested in getting an instant notification when a + * device has been disconnected a callback can be registered on this property. How to do this is explained + * here: \ref Callback.cpp + */ + void updateDeviceList( void ) const + { + TDMR_ERROR result = DMR_NO_ERROR; + if( ( result = DMR_UpdateDeviceList( 0, 0 ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::Device object. + /** + * Returns a pointer to a \b mvIMPACT::acquire::Device object specifying the device found at the given + * index in the device managers internal list. + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of devices detected + * a STL out_of_range exception will be thrown. + * \endif + * + * \sa + * \b DeviceManager::deviceCount, \n + * \b DeviceManager::getDeviceBySerial, \n + * \b DeviceManager::getDeviceByFamily, \n + * \b DeviceManager::getDeviceByProduct + * \return + * - A pointer to the device if \a index specifies a valid value. \n + * - an exception will be raised otherwise. + */ + Device* getDevice( + /// [in] The index of the device to be returned. + unsigned int index ) const + { + updateInfoVector(); + return m_devVector.at( index ); + } + /// \brief Tries to locate a device via the serial number. + /** + * This function tries to find a device by its serial number (or parts of this number). + * The user can specify only parts of the serial number and a wildcard. The \b mvIMPACT::acquire::DeviceManager + * object will then try to find that matches these parameters in its current list. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * DeviceManager devMgr; + * // this will return a pointer to the second device with + * // a serial number starting with 'SD' device found or 0 + * // if there are no 2 sample devices in the system + * devMgr.getDeviceBySerial( "SD*******", 1, '*' ); + * // will return a pointer to the device with the serial + * // number SD000001 if present or 0 + * devMgr.getDeviceBySerial( "SD0000001" ); + * // will return a pointer to the first device in the system + * devMgr.getDeviceBySerial( "*", 0, '*' ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * DeviceManager devMgr = new DeviceManager(); + * // this will return a pointer to the second device with + * // a serial number starting with 'SD' device found or 0 + * // if there are no 2 sample devices in the system + * devMgr.getDeviceBySerial( "SD*******", 1, '*' ); + * // will return a pointer to the device with the serial + * // number SD000001 if present or 0 + * devMgr.getDeviceBySerial( "SD0000001" ); + * // will return a pointer to the first device in the system + * devMgr.getDeviceBySerial( "*", 0, '*' ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * devMgr = acquire.DeviceManager() + * # this will return a reference to the second device with + * # a serial number starting with 'SD' device found or 0 + * # if there are no 2 sample devices in the system + * devMgr.getDeviceBySerial("SD*******", 1, '*') + * # will return a reference to the device with the serial + * # number SD000001 if present or 0 + * devMgr.getDeviceBySerial("SD0000001") + * # will return a reference to the first device in the system + * devMgr.getDeviceBySerial("*", 0, '*') + * \endcode + * \endif + * + * \sa + * \b DeviceManager::getDeviceByFamily, \n + * \b DeviceManager::getDeviceByProduct, \n + * \b DeviceManager::getDeviceByProductAndID + * \return + * - A pointer to the device if found. \n + * - an invalid pointer or reference otherwise. + */ + Device* getDeviceBySerial( + /// [in] The full serial number or the known parts of the serial number and wildcard characters. + const std::string& serial = "", + /// [in] The number of the device to return (if there is more than one candidate). + unsigned int devNr = 0, + /// [in] The character to ignore in \a serial. + char wildcard = '*' ) const + { + return getDevice( dmdsmSerial, serial, devNr, wildcard ); + } + /// \brief Tries to locate a device via the family name. + /** + * This function tries to find a device by its family (or parts of this family name). + * The user can specify only parts of the family name and a wildcard. The \b mvIMPACT::acquire::DeviceManager + * object will then try to find the device that matches these parameters in its current list. + * The family is the most general method of searching for a device apart from 'any device'. + * E.g. for a device the family name might be 'SampleDevice' + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * DeviceManager devMgr; + * // this will return a pointer to the second 'SampleDevice' + * // device found or 0 if there are no 2 'SampleDevice' + * // devices in the system + * devMgr.getDeviceByFamily( "SampleD*", 1, '*' ); + * // will return a pointer to the first device belonging + * // to the 'SampleDevice' family if present or 0. + * devMgr.getDeviceByFamily( "SampleDevice" ); + * // will return the first recognized device in the system + * devMgr.getDeviceByFamily( "*", 0, '*' ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * DeviceManager devMgr = new DeviceManager(); + * // this will return a pointer to the second 'SampleDevice' + * // device found or 0 if there are no 2 'SampleDevice' + * // devices in the system + * devMgr.getDeviceByFamily( "SampleD*", 1, '*' ); + * // will return a pointer to the first device belonging + * // to the 'SampleDevice' family if present or 0. + * devMgr.getDeviceByFamily( "SampleDevice" ); + * // will return the first recognized device in the system + * devMgr.getDeviceByFamily( "*", 0, '*' ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * devMgr = acquire.DeviceManager() + * # this will return a reference to the second 'SampleDevice' + * # device found or 0 if there are no 2 'SampleDevice' + * # devices in the system + * devMgr.getDeviceByFamily("SampleD*", 1, '*') + * # will return a reference to the first device belonging + * # to the 'SampleDevice' family if present or 0. + * devMgr.getDeviceByFamily("SampleDevice") + * # will return the first recognized device in the system + * devMgr.getDeviceByFamily("*", 0, '*') + * \endcode + * \endif + * + * \sa + * \b mvIMPACT::acquire::DeviceManager::getDeviceBySerial, \n + * \b mvIMPACT::acquire::DeviceManager::getDeviceByProduct, \n + * \b mvIMPACT::acquire::DeviceManager::getDeviceByProductAndID + * \return + * - A pointer to the device if found. \n + * - an invalid pointer or reference otherwise. + */ + Device* getDeviceByFamily( + /// [in] The full family name of the requested device or known parts of it and wildcard characters. + const std::string& family = "", + /// [in] The number of the device to return (if there is more than one candidate). + unsigned int devNr = 0, + /// [in] The character to ignore in \a family. + char wildcard = '*' ) const + { + return getDevice( dmdsmFamily, family, devNr, wildcard ); + } + /// \brief Tries to locate a device via the product name. + /** + * This function tries to find a device by its product name (or parts of it). + * The user can specify only parts of the name and a wildcard. The \b mvIMPACT::acquire::DeviceManager + * object will then try to find the device that matches these parameters in its current list. + * The product name is a bit more specific than the family name, but less specific than + * the serial. For the 'SampleDevice' for example there might be different product names for different + * device types. This might e.g. be 'SampleDevice-G' for a grey version of the sample device and + * 'SampleDevice-C' for the color version of the sample device. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * DeviceManager devMgr; + * // this will return a pointer to the second sample + * // device of type 'G' found or 0 if there aren't + * // two devices of this type in the system + * devMgr.getDeviceByProduct( "SampleDevice-G", 1 ); + * // will return a pointer to the first device whose + * // product string starts with 'SampleDev' or 0 if + * // no such device can be found. + * devMgr.getDeviceByProduct( "SampleDev*", 0, '*' ); + * // will return the first recognized device in the system + * devMgr.getDeviceByProduct( "*", 0, '*' ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * DeviceManager devMgr = new DeviceManager(); + * // this will return a pointer to the second sample + * // device of type 'G' found or 0 if there aren't + * // two devices of this type in the system + * devMgr.getDeviceByProduct( "SampleDevice-G", 1 ); + * // will return a pointer to the first device whose + * // product string starts with 'SampleDev' or 0 if + * // no such device can be found. + * devMgr.getDeviceByProduct( "SampleDev*", 0, '*' ); + * // will return the first recognized device in the system + * devMgr.getDeviceByProduct( "*", 0, '*' ); + * \code + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * devMgr = acquire.DeviceManager() + * # this will return a reference to the second sample + * # device of type 'G' found or 0 if there aren't + * # two devices of this type in the system + * devMgr.getDeviceByProduct("SampleDevice-G", 1) + * # will return a reference to the first device whose + * # product string starts with 'SampleDev' or 0 if + * # no such device can be found. + * devMgr.getDeviceByProduct("SampleDev*", 0, '*') + * # will return the first recognized device in the system + * devMgr.getDeviceByProduct("*", 0, '*') + * \endcode + * \endif + * + * \sa + * \b DeviceManager::getDeviceBySerial, \n + * \b DeviceManager::getDeviceByFamily, \n + * \b DeviceManager::getDeviceByProductAndID + * \return + * - A pointer to the device if found. \n + * - an invalid pointer or reference otherwise. + */ + Device* getDeviceByProduct( + /// [in] The full product name of the requested device or known parts of it and wildcard characters. + const std::string& product = "", + /// [in] The number of the device to return (if there is more than one candidate). + unsigned int devNr = 0, + /// [in] The character to ignore in \a product. + char wildcard = '*' ) const + { + return getDevice( dmdsmProduct, product, devNr, wildcard ); + } + /// \brief Tries to locate a device via the product name and the device ID. + /** + * This function behaves like + * \b mvIMPACT::acquire::DeviceManager::getDeviceByProduct + * except that the second parameter now is interpreted as the device ID. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * DeviceManager devMgr; + * // this will return a pointer to the sample device of + * // type 'G' which has been assigned a device ID of '1' + * // or 0 if there is no sample device with this ID in the system. + * devMgr.getDeviceByProductAndID( "SampleDevice-G", 1 ); + * // will return a pointer to the device whose product string + * // starts with 'SampleDev' and whose device ID has been set + * // to '0' or 0 if no such device can be found. + * devMgr.getDeviceByProductAndID( "SampleDev*", 0, '*' ); + * // will return the first recognized device with an assigned + * // device ID of '0' in the system. + * devMgr.getDeviceByProductAndID( "*", 0 ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * DeviceManager devMgr = new DeviceManager(); + * // this will return a pointer to the sample device of + * // type 'G' which has been assigned a device ID of '1' + * // or 0 if there is no sample device with this ID in the system. + * devMgr.getDeviceByProductAndID( "SampleDevice-G", 1 ); + * // will return a pointer to the device whose product string + * // starts with 'SampleDev' and whose device ID has been set + * // to '0' or 0 if no such device can be found. + * devMgr.getDeviceByProductAndID( "SampleDev*", 0, '*' ); + * // will return the first recognized device with an assigned + * // device ID of '0' in the system. + * devMgr.getDeviceByProductAndID( "*", 0 ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * devMgr = acquire.DeviceManager() + * # this will return a reference to the sample device of + * # type 'G' which has been assigned a device ID of '1' + * # or 0 if there is no sample device with this ID in the system. + * devMgr.getDeviceByProductAndID("SampleDevice-G", 1) + * # will return a reference to the device whose product string + * # starts with 'SampleDev' and whose device ID has been set + * # to '0' or 0 if no such device can be found. + * devMgr.getDeviceByProductAndID("SampleDev*", 0, '*') + * # will return the first recognized device with an assigned + * # device ID of '0' in the system. + * devMgr.getDeviceByProductAndID("*", 0) + * \endcode + * \endif + * + * \sa + * \b Device::deviceID, \n + * \b DeviceManager::getDeviceByFamily, \n + * \b DeviceManager::getDeviceByProduct, \n + * \b DeviceManager::getDeviceBySerial, \n + * \b Device::setID + * \return + * - A pointer to the device if found. \n + * - an invalid pointer or reference otherwise. + */ + Device* getDeviceByProductAndID( + /// [in] The full product name of the requested device or known parts of it and wildcard characters. + const std::string& product = "", + /// [in] The ID associated with this device. + unsigned int devID = 0, + /// [in] The character to ignore in \a product. + char wildcard = '*' ) const + { + return getDevice( static_cast( dmdsmProduct | dmdsmUseDevID ), product, devID, wildcard ); + } + /// \brief Tries to locate a device via the product name and the device ID. + /** + * This function can be used to locate devices with a certain string identifier that has previously been written into a devices non-volatile + * memory. E.g. GenICam devices may support the \c DeviceUserID feature to assign a certain user defined name. A user defined + * name might be useful e.g. to access a device with a certain function without the need to worry about which device is it. You could + * e.g. have a \c barcodeReadingDevice and a \c monitorCamera. + * This function behaves like \b mvIMPACT::acquire::DeviceManager::getDeviceByProduct + * except that the second parameter now is interpreted as the device ID. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * DeviceManager devMgr; + * // this will return a pointer to the sample device of + * // type 'G' which has been assigned a device ID of 'abc' + * // or 0 if there is no sample device with this ID in the system. + * devMgr.getDeviceByProductAndID( "SampleDevice-G", "abc" ); + * // will return a pointer to the device whose product string + * // starts with 'SampleDev' and whose device ID has been set + * // to 'def' or 0 if no such device can be found. + * devMgr.getDeviceByProductAndID( "SampleDev*", "def", '*' ); + * // will return the first recognized device with an assigned + * // device ID of 'anyString' in the system. + * devMgr.getDeviceByProductAndID( "*", "anyString" ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * DeviceManager devMgr = new DeviceManager(); + * // this will return a pointer to the sample device of + * // type 'G' which has been assigned a device ID of 'abc' + * // or 0 if there is no sample device with this ID in the system. + * devMgr.getDeviceByProductAndID( "SampleDevice-G", "abc" ); + * // will return a pointer to the device whose product string + * // starts with 'SampleDev' and whose device ID has been set + * // to 'def' or 0 if no such device can be found. + * devMgr.getDeviceByProductAndID( "SampleDev*", "def", '*' ); + * // will return the first recognized device with an assigned + * // device ID of 'anyString' in the system. + * devMgr.getDeviceByProductAndID( "*", "anyString" ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * devMgr = acquire.DeviceManager() + * # this will return a reference to the sample device of + * # type 'G' which has been assigned a device ID of 'abc' + * # or 0 if there is no sample device with this ID in the system. + * devMgr.getDeviceByProductAndID("SampleDevice-G", "abc") + * # will return a reference to the device whose product string + * # starts with 'SampleDev' and whose device ID has been set + * # to 'def' or 0 if no such device can be found. + * devMgr.getDeviceByProductAndID("SampleDev*", "def", '*') + * # will return the first recognized device with an assigned + * # device ID of 'anyString' in the system. + * devMgr.getDeviceByProductAndID("*", "anyString") + * \endcode + * \endif + * + * \sa + * \b Device::deviceID, \n + * \b DeviceManager::getDeviceByFamily, \n + * \b DeviceManager::getDeviceByProduct, \n + * \b DeviceManager::getDeviceBySerial, \n + * \b Device::setID + * \return + * - A pointer to the device if found. \n + * - an invalid pointer or reference otherwise. + */ + Device* getDeviceByProductAndID( + /// [in] The full product name of the requested device or known parts of it and wildcard characters. + const std::string& product, + /// [in] The device ID associated with this device. + const std::string& devID, + /// [in] The character to ignore in \a product. + char wildcard = '*' ) const + { + return getDevice( static_cast( dmdsmProduct | dmdsmUseDevID ), product, devID, wildcard ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid interface list types, which can be located using an instance of \b mvIMPACT::acquire::DeviceComponentLocator. +enum TDeviceListType +//----------------------------------------------------------------------------- +{ + /// \brief A placeholder for an undefined list type. + dltUndefined = dmltUndefined, + /// \brief Specifies a certain setting. + /** + * An additional string defines the name of the setting to look for. + */ + dltSetting = dmltSetting, + /// \brief Specifies the list of driver owned image request objects. + dltRequest = dmltRequest, + /// \brief Specifies a certain image request control. + /** + * An additional string defines the name of the setting to look for. + */ + dltRequestCtrl = dmltRequestCtrl, + /// \brief Specifies the driver interfaces list containing general information. + /** + * This e.g. can be properties containing the driver version, the current state + * of the device and stuff like that. + */ + dltInfo = dmltInfo, + /// \brief Specifies the driver interface list containing statistical information. + /** + * This list e.g. might contain the current frame rate, the total number of images + * captured, etc. + */ + dltStatistics = dmltStatistics, + /// \brief Specifies the driver interface list containing properties, which influence the overall operation of the device. + /** + * This list e.g. might contain the priority of the drivers internal worker thread, + * the number of request objects the driver shall work with, etc. + */ + dltSystemSettings = dmltSystemSettings, + /// \brief Specifies the driver interface list containing properties to work with any kind of I/O pin belonging to that device. + /** + * Here properties addressing the digital inputs and outputs and other I/O related + * properties can be found. + */ + dltIOSubSystem = dmltIOSubSystem, + /// \brief Specifies the driver interface list providing access to the drivers Hardware Real-Time Controller (HRTC). + /** + * Here properties to control the behaviour of the HRTCs can be found. + * \note + * This feature might not be available for every device. + */ + dltRTCtr = dmltRTCtr, + /// \brief Specifies the driver interface list providing access to the recognized camera description lists. + /** + * Within this list all recognized camera descriptions can be found, each forming a sub list + * containing the properties describing the camera. + * + * \note This feature is only available for frame grabber devices currently. + */ + dltCameraDescriptions = dmltCameraDescriptions, + /// \brief Specifies the driver interface list providing access to the device specific settings lists. + /** + * \note This feature currently is only available for frame grabber devices. + */ + dltDeviceSpecificData = dmltDeviceSpecificData, +#if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + /// \brief Specifies the driver interface list providing access to the device specific event type settings lists(deprecated). + /** + * \note Every device will support a different set of events that can be waited for by the user. + * + * This list will contain a sublist for each event type recognized for this device. Within this sublist + * all properties that can be describe the current mode an event is operated in user can be found. + * + * \deprecated + * This value has been declared deprecated and will be removed in future versions of this interface. + * A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method + * is \ref Callback.cpp. + */ + dltEventSubSystemSettings = dmltEventSubSystemSettings, + /// \brief Specifies the driver interface list providing access to the device specific event type results lists(deprecated). + /** + * \note Every device will support a different set of events that can be waited for by the user. + * + * This list will contain a sublist for each event type recognized for this device. Within this sublist + * all result properties that can be queried by the user can be found. + * + * \deprecated + * This value has been declared deprecated and will be removed in future versions of this interface. + * A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method + * is \ref Callback.cpp. + */ + dltEventSubSystemResults = dmltEventSubSystemResults, +#endif // #if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + /// \brief Specifies the driver interface list providing access to the devices memory manager list. + /** + * \note This feature currently is only available for frame grabber devices. + * + * This list will contain properties and lists providing access to settings related to the memory + * handling used by the device. E.g. the buffer size for individual DMA blocks can be configured + * here. + * + * \note + * Properties in this list should only be modified by advanced users. + */ + dltImageMemoryManager = dmltImageMemoryManager, +#ifndef DOXYGEN_SHOULD_SKIP_THIS + dltPseudoLast, +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS + /// \brief Defines the last entry in this enumeration. + /** + * This is always equal to the last 'real' enum value. + */ + dltLast = dltPseudoLast - 1 +}; + +//----------------------------------------------------------------------------- +/// \brief A class to locate components within the driver. +/** + * Every driver will offer a set of properties, methods and component lists. + * \b mvIMPACT::acquire::Property objects contain data such as the current gain in dB, the state of a + * digital input, etc.. \b mvIMPACT::acquire::Method objects can be executed like a normal function and + * \b mvIMPACT::acquire::ComponentList objects are used to group certain + * objects together to form a logical unit. + * + * When it's necessary to locate one or more of these objects without knowing + * exactly where to look for them this locator class can be used to look for the component. + * + * In general the properties interesting for the user can be found in one of the + * classes offered by this interface, but when a special property is needed or a + * new property that hasn't been embedded into the C++ interface, this class offers + * a way to get hold of its handle. + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // assuming a new property 'MyProp' has been added to the setting of a + * // device driver whose product string is 'MyDevice' and it has not been + * // added to the corresponding class or the property shall be accessed + * // without rebuilding the application. + * // The latter situation will require some kind of interpreter that + * // can pass the required information to the device driver + * //----------------------------------------------------------------------------- + * enum TMyEnumType + * //----------------------------------------------------------------------------- + * { + * metOne = 0, + * metTwo, + * metThree + * }; + * + * //----------------------------------------------------------------------------- + * void fn( void ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr; + * Device* pDev = devMgr.getDeviceByProduct( "MyDev*" ); + * if( pDev ) + * { + * // get access to the base setting + * DeviceComponentLocator locator( pDev, dltSetting, "Base" ); + * Property prop; + * locator.bindComponent( prop, "MyProp" ); + * // set the value by string + * prop.writeS( "MyVal" ); + * if( prop.type() == ctPropInt ) + * { + * PropertyI iProp( prop.hObj() ); + * int myVal = 666; + * iProp.write( myVal ); + * } + * // if the type is known this test can be omitted: + * PropertyF fProp; + * locator.bindComponent( fProp, "MyFloatProperty" ); + * fProp.write( 3.14 ); + * + * // When it's an enumerated property this is legal as well: + * PropertyIMyEnumType eProp; + * locator.bindComponent( eProp, "MyEnumeratedProperty" ); + * eProp.write( metOne ); + * } + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * public static void fn( void ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr = new DeviceManager(); + * Device pDev = devMgr.getDeviceByProduct( "MyDev*" ); + * if( pDev != null ) + * { + * DeviceComponentLocator locator = new DeviceComponentLocator( pDev, TDeviceListType.dltSetting, "Base" ); + * Property prop = new Property(); + * locator.bindComponent( prop, "MyProp" ); + * // set the value by string + * prop.writeS( "MyVal" ); + * if( prop.type() == TComponentType.ctPropInt ) + * { + * PropertyI iProp = new PropertyI( prop.hObj() ); + * int myVal = 666; + * iProp.write( myVal ); + * } + * // if the type is known this test can be omitted: + * PropertyF fProp = new PropertyF(); + * locator.bindComponent( fProp, "MyFloatProperty" ); + * fProp.write( 3.14 ); + * + * // When it's an enumerated property this is legal as well: + * PropertyI eProp = new PropertyI(); + * locator.bindComponent( eProp, "MyBooleanProperty" ); + * eProp.write( TBoolean.bTrue ); + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * devMgr = acquire.DeviceManager() + * pDev = devMgr.getDeviceByProduct("MyDev*") + * if pDev: + * # get access to the base setting + * locator = acquire.DeviceComponentLocator(pDev, dltSetting, "Base") + * prop = None + * locator.bindComponent(prop, "MyProp") + * # set the value by string + * prop.writeS("MyVal") + * if prop.type == ctPropInt: + * iProp = PropertyI(prop.hObj()) + * myVal = 666 + * iProp.write(myVal) + * + * # if the type is known this test can be omitted: + * fProp = None + * locator.bindComponent(fProp, "MyFloatProperty") + * fProp.write(3.14) + * + * # When it's an enumerated property this is legal as well: + * eProp = acquire.EnumPropertyI() + * locator.bindComponent(eProp, "MyEnumeratedProperty") + * # e.g. writing the devices interfaceLayout property using the TDeviceInterfaceLayout enum value + * eProp.write(acquire.dilGenICam) + * \endcode + * \endif + * + */ +class DeviceComponentLocator : public ComponentLocatorBase +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new unbound locator. + explicit DeviceComponentLocator() : ComponentLocatorBase() {} + /// \brief Constructs a new bound to the specified base list locator. + explicit DeviceComponentLocator( + /// [in] A unique identifier to the base list from where to start to search for + /// the search base. + HLIST baselist ) : ComponentLocatorBase( baselist ) {} + /// \brief Constructs a new locator and searches the search base list. + explicit DeviceComponentLocator( + /// [in] A unique identifier to the base list from where to start to search for + /// the search base. + HLIST baselist, + /// [in] The name or path ('/' separated) to the search base. + const std::string& pathToSearchBase ) : ComponentLocatorBase( baselist, pathToSearchBase ) {} + /// \brief Constructs a new locator and bind the search base to the specified list type of the device. + explicit DeviceComponentLocator( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from + /// a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The type list to locate + TDeviceListType deviceListType, + /// [in] A string that can contain the name of the list if there + /// is more than one candidate (e.g. when looking for settings) + const std::string& sublistName = "" ) : ComponentLocatorBase() + { + bindSearchBaseList( pDev, deviceListType, sublistName ); + } + /// \brief Assign a new search base to the locator. + /** + * This new search base will be search starting from the base list specified. + * \return The unique identifier of the new search base. + */ + HLIST bindSearchBaseList( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from + /// a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The type list to locate + TDeviceListType deviceListType, + /// [in] The name or path to the search base. + const std::string& sublistName = "" ) + { + if( !pDev->isOpen() ) + { + pDev->open(); + } + + HLIST hList; + TDMR_ERROR result; + if( ( result = DMR_FindList( pDev->hDrv(), ( sublistName.length() == 0 ) ? 0 : sublistName.c_str(), static_cast( deviceListType ), 0, &hList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + bindSearchBase( hList ); + return searchbase_id(); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A wrapper class to handle \b mvIMPACT::acquire::ImageBuffer structures. +/** + * This class acts as a simple wrapper to handle \b mvIMPACT::acquire::ImageBuffer structures. + * When using this class the user is no longer responsible for the memory management + * of \b mvIMPACT::acquire::ImageBuffer structures. + * + * Instances of this class are reference counted. Memory is freed once the last instance + * to it is destroyed. For details read the corresponding sections in the documentation + * of the various constructors and function belonging to this class. + */ +class ImageBufferDesc +//----------------------------------------------------------------------------- +{ +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + friend class Request; + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + int m_refCnt; + bool m_boBufferAllocated; + ImageBuffer* m_pBuffer; + explicit ReferenceCountedData( bool boAllocated = false, ImageBuffer* pBuffer = 0 ) + : m_refCnt( 1 ), m_boBufferAllocated( boAllocated ), m_pBuffer( pBuffer ) {} + ~ReferenceCountedData() + { + if( m_pBuffer ) + { + if( m_boBufferAllocated ) + { + DMR_ReleaseImageBuffer( &m_pBuffer ); + } + else + { + DMR_ReleaseImageRequestBufferDesc( &m_pBuffer ); + } + } + } + // make sure there are NO assignments or copy constructions by accident! + ReferenceCountedData& operator=( const ReferenceCountedData& rhs ); + ReferenceCountedData( const ReferenceCountedData& src ); + }* m_pRefData; + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + explicit ImageBufferDesc( bool boAllocated, ImageBuffer* pBuf ) : m_pRefData( new ImageBufferDesc::ReferenceCountedData( boAllocated, pBuf ) ) {} +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +public: + /// \brief Constructs a new \b mvIMPACT::acquire::ImageBufferDesc from an existing one. + /** + * The image buffer associated with this descriptor will not be copied! The internal + * data will be reference counted and changing this new object will also affect the + * original one. The internal data is freed when the last descriptor referencing the + * image is destroyed. + */ + ImageBufferDesc( + /// [in] The source buffer descriptor. + const ImageBufferDesc& source ) : m_pRefData( source.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::ImageBufferDesc object with \a channelCount channel specific data elements. + /** + * This constructor does \b NOT allocate memory for the actual pixel data but only for the + * a structure describing an image. + * + * When passing invalid values to this constructor (e.g. a negative value for \c channelCount) an + * exception will be thrown. + */ + explicit ImageBufferDesc( + /// [in] The number of channel specific data elements to allocate + /// memory for. + int channelCount ) : m_pRefData( new ImageBufferDesc::ReferenceCountedData() ) + { + const TDMR_ERROR result = DMR_AllocImageRequestBufferDesc( &( m_pRefData->m_pBuffer ), channelCount ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::ImageBufferDesc object and allocates all memory needed. + /** + * This constructor will allocate and handle a new and complete \b ImageBuffer object including + * memory for the pixel data for the given pixel format. + * + * The size(in bytes) of allocated pixel memory will depend on the \a pixelFormat as well as on the + * parameters \a width and \a height. \b mvIMPACT::acquire::ImageBuffer::iSize will return the + * amount of memory allocated for the buffer. + * + * When passing invalid values to this constructor (e.g. a negative value for \c height) an + * exception will be thrown. + */ + explicit ImageBufferDesc( + /// [in] The desired pixel format for the new \b mvIMPACT::acquire::ImageBuffer + /// object handled by this descriptor. + TImageBufferPixelFormat pixelFormat, + /// [in] The width of the new \b mvIMPACT::acquire::ImageBuffer object handled + /// by this descriptor. + int width, + /// [in] The height of the new \b mvIMPACT::acquire::ImageBuffer object handled + /// by this descriptor. + int height ) : m_pRefData( new ImageBufferDesc::ReferenceCountedData( true ) ) + { + const TDMR_ERROR result = DMR_AllocImageBuffer( &( m_pRefData->m_pBuffer ), pixelFormat, width, height ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::ImageBufferDesc object from a file and allocates all memory needed. + /** + * This constructor will allocate and handle a new and complete \b ImageBuffer object including + * memory for the pixel data for the given pixel format. The buffer will be filled with the + * data from the file referenced by \c fileName. + * + * \note + * Internally The FreeImage library (see 'legal notice' section) is used for this operation. If the library + * cannot be located in version 3.16.0 on the host system calling this constructor will fail and an + * exception will be thrown. + * + * \since 2.23.0 + */ + explicit ImageBufferDesc( + /// [in] The name of the file to load. + const std::string& fileName, + /// [in] The format of the file to load. + TImageFileFormat fileFormat = iffAuto ) : m_pRefData( new ImageBufferDesc::ReferenceCountedData( true ) ) + { + const TDMR_ERROR result = DMR_LoadImageBuffer( &( m_pRefData->m_pBuffer ), fileName.c_str(), fileFormat ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } + /// \brief De-allocates all managed memory again when this is the last object referencing the image. + ~ImageBufferDesc() + { + dealloc(); + } + /// \brief Allows assignments of two different \b mvIMPACT::acquire::ImageBufferDesc. + /** + * The image buffer associated with this descriptor will not be copied! The internal + * data will be reference counted and changing this new object will also affect the + * original one. The internal data is freed when the last descriptor referencing the + * image is destroyed. + */ + ImageBufferDesc& operator=( const ImageBufferDesc& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + ++( m_pRefData->m_refCnt ); + } + return *this; + } + /// \brief Returns a deep copy of the \b mvIMPACT::acquire::ImageBuffer object referenced by this descriptor. + /** + * This function will create a deep copy of the \b mvIMPACT::acquire::ImageBuffer object referenced by this + * descriptor. Afterwards modifying one of the images will \b NOT influence the other one. + * + * \return A deep copy of the \b mvIMPACT::acquire::ImageBuffer object referenced by this descriptor. + */ + ImageBufferDesc clone( void ) const + { + ImageBuffer* pDst = 0; + DMR_CopyImageBuffer( m_pRefData->m_pBuffer, &pDst, 0 ); + return ImageBufferDesc( true, pDst ); + } +#ifdef PYTHON_OR_JAVA_ONLY // This function is only needed e.g. to copy into managed Java memory + /// \brief Returns a deep copy of the data buffer of the underlying \b mvIMPACT::acquire::ImageBuffer object referenced by this descriptor. + /** + * This function will create a deep copy of the data buffer of the \b mvIMPACT::acquire::ImageBuffer object referenced by this + * descriptor. Afterwards modifying one of the buffers will \b NOT influence the other one. + * + * \since 2.36.0 + * \return The buffer size needed for \c pDst if \c dstSize was too small or the size used if the operation was successful. + */ + int copy( + /// A pointer to the buffer to copy the data into. Can be 0 if just the size needed shall be queried. + char* pDst, + /// The size of the buffer pointed to by \c pDst. Is 'don't care' if just the size needed shall be queried. + const int dstSize ) const + { + const int sizeNeeded = getBuffer()->iSize; + if( dstSize < sizeNeeded ) + { + return sizeNeeded; + } + if( pDst ) + { + memcpy( pDst, static_cast( getBuffer()->vpData ), sizeNeeded ); + } + return sizeNeeded; + } +#endif // #ifdef PYTHON_OR_JAVA_ONLY + /// \brief Grants access to the underlying \b mvIMPACT::acquire::ImageBuffer structure managed by this object. + /** + * \return A pointer to the \b mvIMPACT::acquire::ImageBuffer object referenced by this descriptor. + */ + ImageBuffer* getBuffer( void ) const + { + return m_pRefData ? m_pRefData->m_pBuffer : 0; + } + /// \brief Stores the complete data of one ImageBuffer structure into a file. + /** + * This function stores the image described by a mvIMPACT::acquire::ImageBuffer structure pointed to by the \c pBuffer variable + * into a file. + * + * \note + * Internally The FreeImage library (see 'legal notice' section) is used for this operation. If the library + * cannot be located in version 3.16.0 on the host system calling this function will fail. + * + * \since 2.23.0 + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - mvIMPACT::acquire::DMR_LIBRARY_NOT_FOUND if the required version of the FreeImage library could not be located on the host system. + * - mvIMPACT::acquire::DEV_UNSUPPORTED_PARAMETER if a pixel format has been passed to the function that is not supported by the internal algorithms. + * - mvIMPACT::acquire::DEV_INPUT_PARAM_INVALID if a pixel format has been passed to the function that is not supported by the FreeImage library. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int save( + /// [in] The full path of the file to create. + const std::string& fileName, + /// [in] The format of the file to be created. If this parameter is set to mvIMPACT::acquire::iffAuto make sure to specify a proper file extension. + TImageFileFormat format = iffAuto ) const + { + return DMR_SaveImageBuffer( m_pRefData->m_pBuffer, fileName.c_str(), format ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A base class for sets of properties that can be modified by the user. +class ComponentCollection +//----------------------------------------------------------------------------- +{ +protected: + HOBJ m_hRoot; + explicit ComponentCollection() : m_hRoot( INVALID_ID ) {} + explicit ComponentCollection( HOBJ hRoot ) : m_hRoot( hRoot ) {} + explicit ComponentCollection( Device* pDev ) : m_hRoot( INVALID_ID ) + { + if( !pDev->isOpen() ) + { + pDev->open(); + } + } +public: + virtual ~ComponentCollection() {} + /// \brief Returns a unique identifier for the component collection referenced by this object. + /** + * This handle will always reference an object of type \b mvIMPACT::acquire::ComponentList. + * \return A unique identifier for the component referenced by this object. + */ + HOBJ hObj( void ) const + { + return m_hRoot; + } + /// \brief Restores the default for every component of this collection. + /** + * Calling this function will restore the default value for every component + * belonging to this collection. + * + * \note The caller must have the right to modify the component. Otherwise + * an exception will be thrown. + * + * \return A const reference to the component. + */ + const ComponentCollection& restoreDefault( void ) const + { + const TPROPHANDLING_ERROR result = OBJ_RestoreDefault( m_hRoot ); + if( result != PROPHANDLING_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, m_hRoot ); + } + return *this; + } +}; + +//----------------------------------------------------------------------------- +/// \brief Contains information about a specific part of a captured buffer. +/** + * This class provides access to all sorts of information about a specific part of a captured buffer. + * Only Instances of \b mvIMPACT::acquire::Request are allowed to create objects of \b mvIMPACT::acquire::BufferPart. + * Consequently the only way to get access to a \b mvIMPACT::acquire::BufferPart object is via a call to + * \b mvIMPACT::acquire::Request::getBufferPart. + * + * \sa + * \ref ImageAcquisition_MultiPart + * \since 2.20.0 + */ +class BufferPart : public ComponentCollection +//----------------------------------------------------------------------------- +{ + // only Request objects can create these objects, as these objects are + // fixed parts of that class. + friend class Request; + mutable ImageBufferDesc m_imageBufferDesc; + Component m_firstSibling; + explicit BufferPart( HOBJ hObj ): ComponentCollection( hObj ), m_imageBufferDesc( 1 ), m_firstSibling(), address(), dataSize(), dataType(), + pixelFormat(), width(), height(), offsetX(), offsetY(), paddingX(), bytesPerPixel(), bayerMosaicParity(), + channelCount(), channelDesc(), pixelPitch(), linePitch(), channelBitDepth(), channelOffset(), sourceID() + { + bindPublicProperties( hObj ); + } + void bindPublicProperties( HOBJ hObj ) + { + ComponentLocator locator( hObj ); + locator.bindComponent( address, "Address" ); + if( address.isValid() ) + { + m_firstSibling = address.firstSibling(); + } + locator.bindComponent( dataSize, "DataSize" ); + locator.bindComponent( dataType, "DataType" ); + locator.bindComponent( pixelFormat, "PixelFormat" ); + locator.bindComponent( width, "Width" ); + locator.bindComponent( height, "Height" ); + locator.bindComponent( offsetX, "OffsetX" ); + locator.bindComponent( offsetY, "OffsetY" ); + locator.bindComponent( paddingX, "PaddingX" ); + locator.bindComponent( bytesPerPixel, "BytesPerPixel" ); + locator.bindComponent( bayerMosaicParity, "BayerMosaicParity" ); + locator.bindComponent( channelCount, "ChannelCount" ); + locator.bindComponent( channelDesc, "ChannelDesc" ); + locator.bindComponent( pixelPitch, "PixelPitch" ); + locator.bindComponent( linePitch, "LinePitch" ); + locator.bindComponent( channelBitDepth, "ChannelBitDepth" ); + locator.bindComponent( channelOffset, "ChannelOffset" ); + locator.bindComponent( sourceID, "SourceID" ); + } +public: + /// \brief Returns a const reference to the image buffer descriptor of this buffer part. + /** + * This function returns a const reference to the \b mvIMPACT::acquire::ImageBufferDesc associated + * with this \b mvIMPACT::acquire::BufferPart. + * + * \warning + * Please do \b NEVER work with old references to this structure. So do \b NOT store this reference in + * some variable to use it for the evaluation of the next \b mvIMPACT::acquire::BufferPart object as well, + * as this will not work. Whenever \b mvIMPACT::acquire::BufferPart::getImageBufferDesc is called the function + * will make sure that the data in the returned structure is up to date while when working with + * an old reference to the \b mvIMPACT::acquire::ImageBufferDesc structure the containing data might refer + * to a previous result or even worse invalid memory locations. This reference will remain valid until an + * application calls \b mvIMPACT::acquire::Request::unlock for the corresponding request. + */ + const ImageBufferDesc& getImageBufferDesc( void ) const + { + ImageBufferDesc tmp( static_cast( channelCount.read() ) ); + ImageBuffer* p = tmp.getBuffer(); + p->iBytesPerPixel = static_cast( bytesPerPixel.read() ); + p->iHeight = static_cast( height.read() ); + p->iSize = static_cast( dataSize.read() ); + p->iWidth = static_cast( width.read() ); + p->pixelFormat = static_cast( pixelFormat.read() ); + p->vpData = address.read(); + std::vector channelOffsets; + channelOffset.read( channelOffsets ); + std::vector linePitches; + linePitch.read( linePitches ); + std::vector pixelPitches; + pixelPitch.read( pixelPitches ); + std::vector channelDescriptors; + channelDesc.read( channelDescriptors ); + for( int i = 0; i < p->iChannelCount; i++ ) + { + p->pChannels[i].iChannelOffset = static_cast( channelOffsets[i] ); + p->pChannels[i].iLinePitch = static_cast( linePitches[i] ); + p->pChannels[i].iPixelPitch = static_cast( pixelPitches[i] ); + mv_strncpy_s( p->pChannels[i].szChannelDesc, channelDescriptors[i].c_str(), DEFAULT_STRING_SIZE_LIMIT - 1 ); + p->pChannels[i].szChannelDesc[DEFAULT_STRING_SIZE_LIMIT - 1] = '\0'; + } + m_imageBufferDesc = tmp; + return m_imageBufferDesc; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A pointer property \b (read-only) containing the start address of this buffer part. + /** + * See remarks under mvIMPACT::acquire::Request::imageData. Most of the information provided there + * will be valid for this property as well. + */ + PropertyPtr address; + /// \brief A 64-bit integer property \b (read-only) containing the size (in bytes) of this buffer part. + /** + * See remarks under mvIMPACT::acquire::Request::imageData. Most of the information provided there + * will be valid for this property as well. + */ + PropertyI64 dataSize; + /// \brief An enumerated 64-bit integer property \b (read-only) containing the data type of this buffer part. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBufferPartDataType. + */ + PropertyI64BufferPartDataType dataType; + /// \brief An enumerated integer property defining the pixel format of this buffer part. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageBufferPixelFormat. + */ + PropertyIImageBufferPixelFormat pixelFormat; + /// \brief A 64-bit integer property \b (read-only) containing the width of the buffer part in pixels. + PropertyI64 width; + /// \brief A 64-bit integer property \b (read-only) containing the height of the buffer part in pixels. + PropertyI64 height; + /// \brief A 64-bit integer property \b (read-only) containing the X-offset of the buffer part in pixels. + PropertyI64 offsetX; + /// \brief A 64-bit integer property \b (read-only) containing the Y-offset of the buffer part in pixels. + PropertyI64 offsetY; + /// \brief A 64-bit integer property \b (read-only) containing the number of padding bytes in X direction of the buffer part. + PropertyI64 paddingX; + /// \brief A 64-bit integer property \b (read-only) containing the number of bytes per pixel in this buffer part. + PropertyI64 bytesPerPixel; + /// \brief An enumerated 64-bit integer property \b (read-only) containing the Bayer parity of this buffer part. + /** + * If the current buffer part does not contain Bayer data, this value will be \b mvIMPACT::acquire::bmpUndefined. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBayerMosaicParity. + */ + PropertyIBayerMosaicParity bayerMosaicParity; + /// \brief A 64-bit integer property \b (read-only) containing the number of channels this buffer part consists of. + /** + * For an RGB image this value e.g. would be 3. This value also defines how many parameters are stored by the properties + * \b mvIMPACT::acquire::BufferPart::pixelPitch, \n + * \b mvIMPACT::acquire::BufferPart::linePitch, \n + * \b mvIMPACT::acquire::BufferPart::channelBitDepth, \n + * \b mvIMPACT::acquire::BufferPart::channelDesc and \n + * \b mvIMPACT::acquire::BufferPart::channelOffset. + * + * If e.g. the channel count is 3 a call like bufferPart.channelOffset.read( 2 ) would return the channel offset of + * channel 3 (as calls to the read functions of properties are '0' based). + */ + PropertyI64 channelCount; + /// \brief A string property \b (read-only) containing the string descriptors of each channel belonging to the current buffer part. + /** + * See remarks under mvIMPACT::acquire::Request::imageChannelDesc. Most of the information provided there + * will be valid for this property as well. + */ + PropertyS channelDesc; + /// \brief A 64-bit integer property \b (read-only) containing the offset (in bytes) to the next pixel of the specified channel of this buffer part. + /** + * \note + * This property will store \a channelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI64::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI64 pixelPitch; + /// \brief A 64-bit integer property \b (read-only) containing the offset (in bytes) to the next line of each channel belonging to the current buffer part. + /** + * \note + * This property will store \a channelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI64::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI64 linePitch; + /// \brief A 64-bit integer property \b (read-only) containing the number of effective bits stored in each channel belonging to the current buffer part. + /** + * \note + * This property will store \a channelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI64::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI64 channelBitDepth; + /// \brief A 64-bit integer property \b (read-only) containing the offset (in bytes) to each channel belonging to the current buffer part relative to the address contained in \b mvIMPACT::acquire::BufferPart::address. + /** + * \note + * This property will store \a channelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI64::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI64 channelOffset; + /// \brief Identifier allowing to group data parts belonging to the same source (usually corresponding with the SourceSelector/ChunkSourceID features from SFNC). + /** + * Parts marked with the same source_id can be pixel mapped together. Parts carrying data from different ROI's of the same source would typically be marked with the + * same source_id. It is not mandatory that source_id's within a given buffer make a contiguous sequence of numbers starting with zero. + * \note + * For example with a dual-source 3D camera, the buffer can contain data parts carrying the 3D data and Confidence data corresponding to both + * of the two different sources. In this case the source ID helps to match the 3D and Confidence parts belonging together. + */ + PropertyI64 sourceID; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Contains information about a captured buffer. +/** + * This class provides access to all sorts of information about the captured buffer. + * Only Instances of \b mvIMPACT::acquire::FunctionInterface are allowed to create objects of \b mvIMPACT::acquire::Request. + * Consequently the only way to get access to a \b mvIMPACT::acquire::Request object is via a call to + * \b mvIMPACT::acquire::FunctionInterface::getRequest. + * + * A \b mvIMPACT::acquire::Request represents an object used by the driver to fill its internal job + * queues. Whenever a buffer shall be captured a \b mvIMPACT::acquire::Request is sent to the driver + * and the hardware then tries to capture the desired buffer as fast as possible. + * + * Requests are managed by the driver. The only thing the user needs to configure is the + * maximum number of requests he wants the driver to work with. To make sure a + * certain number of requests are available, the property + * \b mvIMPACT::acquire::SystemSettings::requestCount can be used. + * This can be useful for time critical applications where the hardware can capture + * images in the background while the PC performs other tasks. In that case it's + * necessary to make sure that the request queue never runs low to ensure lossless + * data acquisition. + */ +class Request +//----------------------------------------------------------------------------- +{ + // only the function interface object is allowed to create new requests as + // it maintains an internal reference to each request created. + friend class FunctionInterface; + typedef std::vector BufferPartContainer; +protected: +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + std::string m_requestName; + int m_requestNr; + mutable ImageBufferDesc m_imageBufferDesc; + Device* m_pDev; + DeviceComponentLocator m_locator; + Component m_bufferPartIterator; + Component m_infoIterator; + Component m_info_imageProcessingResultsIterator; + mutable BufferPartContainer m_bufferParts; + std::vector m_chunkCounterValues; + std::vector m_chunkTimerValues; + std::vector m_chunkGains; + std::map m_chunkGainString2IndexMap; + unsigned int m_refCnt; + explicit ReferenceCountedData( Device* pDev, int requestNr ) : m_requestName(), m_requestNr( requestNr ), m_imageBufferDesc( 1 ), m_pDev( pDev ), + m_locator(), m_bufferPartIterator(), m_infoIterator(), m_info_imageProcessingResultsIterator(), m_bufferParts(), m_chunkCounterValues(), m_chunkTimerValues(), m_chunkGains(), m_chunkGainString2IndexMap(), m_refCnt( 1 ) + { + if( m_requestNr >= 0 ) + { + std::ostringstream oss; + oss << "Entry " << m_requestNr; + m_requestName = oss.str(); + m_locator = DeviceComponentLocator( m_pDev, dltRequest, m_requestName ); + } + else + { + m_locator = DeviceComponentLocator( m_pDev, dltInfo, "CurrentRequestLayout" ); + } + HLIST hList = m_locator.findComponent( "BufferParts" ); + if( hList != INVALID_ID ) + { + // this driver offers multi-part buffer support + m_bufferPartIterator = Component( hList ); + } + } + ~ReferenceCountedData() + { + const BufferPartContainer::size_type bufferPartsCnt = m_bufferParts.size(); + for( BufferPartContainer::size_type h = 0; h < bufferPartsCnt; h++ ) + { + delete m_bufferParts[h]; + } + const std::vector::size_type cntcc = m_chunkCounterValues.size(); + for( std::vector::size_type i = 0; i < cntcc; i++ ) + { + delete m_chunkCounterValues[i]; + } + const std::vector::size_type cntct = m_chunkTimerValues.size(); + for( std::vector::size_type j = 0; j < cntct; j++ ) + { + delete m_chunkTimerValues[j]; + } + const std::vector::size_type cntcg = m_chunkGains.size(); + for( std::vector::size_type k = 0; k < cntcg; k++ ) + { + delete m_chunkGains[k]; + } + } + // make sure there are NO assignments or copy constructions by accident! + ReferenceCountedData( const ReferenceCountedData& src ); + ReferenceCountedData& operator=( const ReferenceCountedData& rhs ); + void collectChunkFeatures( Component it ) + { + while( it.isValid() ) + { + switch( it.type() ) + { + case ctList: + collectChunkFeatures( it.firstChild() ); + break; + case ctPropInt64: + { + const std::string name( it.name() ); + if( ( name == "ChunkCounterValue" ) || ( name == "ChunkCounter" ) ) // the latter name is the one that became deprecated with GenICam SFNC 1.5 + { + m_chunkCounterValues.push_back( new PropertyI64( it.hObj() ) ); + } + } + break; + case ctPropFloat: + { + const std::string name( it.name() ); + if( ( name == "ChunkTimerValue" ) || ( name == "ChunkTimer" ) ) // the latter name is the one that became deprecated with GenICam SFNC 1.5 + { + m_chunkTimerValues.push_back( new PropertyF( it.hObj() ) ); + } + else if( name == "ChunkGain" ) + { + m_chunkGains.push_back( new PropertyF( it.hObj() ) ); + std::string parentName( it.parent().name() ); + if( parentName.find( "Gain" ) == 0 ) + { + // remove the 'Gain' to get the original string from the selector the user would expect! + parentName = parentName.substr( 4 ); + } + m_chunkGainString2IndexMap.insert( std::make_pair( parentName, static_cast( m_chunkGains.size() - 1 ) ) ); + } + } + break; + default: + break; + } + ++it; + } + } + void collectSelectedChunkFeatures( Component it ) + { + if( m_chunkCounterValues.empty() && m_chunkTimerValues.empty() && m_chunkGains.empty() ) + { + collectChunkFeatures( it ); + } + } + }* m_pRefData; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +private: + //----------------------------------------------------------------------------- + void bindPublicProperties( void ) + //----------------------------------------------------------------------------- + { + DeviceComponentLocator locator( getComponentLocator() ); + locator.bindComponent( requestResult, "Result" ); + locator.bindComponent( requestState, "State" ); + locator.bindSearchBase( locator.searchbase_id(), "Info" ); + m_pRefData->m_infoIterator = Component( locator.searchbase_id() ); + m_pRefData->m_infoIterator = m_pRefData->m_infoIterator.firstChild(); + locator.bindComponent( infoFrameID, "FrameID" ); + locator.bindComponent( infoFrameNr, "FrameNr" ); + locator.bindComponent( infoExposeStart_us, "ExposeStart_us" ); + locator.bindComponent( infoExposeTime_us, "ExposeTime_us" ); + locator.bindComponent( infoTransferDelay_us, "TransferDelay_us" ); + locator.bindComponent( infoGain_dB, "Gain_dB" ); + locator.bindComponent( infoTimeStamp_us, "TimeStamp_us" ); + locator.bindComponent( infoSettingUsed, "SettingUsed" ); + locator.bindComponent( infoImageAverage, "ImageAverage" ); + locator.bindComponent( infoVideoChannel, "VideoChannel" ); + locator.bindComponent( infoCameraOutputUsed, "CameraOutputUsed" ); + locator.bindComponent( infoLineCounter, "LineCounter" ); + locator.bindComponent( infoMissingData_pc, "MissingData_pc" ); + locator.bindComponent( infoIOStatesAtExposureStart, "IOStatesAtExposureStart" ); + locator.bindComponent( infoIOStatesAtExposureEnd, "IOStatesAtExposureEnd" ); + HLIST hList = locator.findComponent( "ChunkData" ); + if( hList != INVALID_ID ) + { + ComponentLocator chunkFeatureLocator( hList ); + chunkFeatureLocator.bindComponent( chunkOffsetX, "ChunkOffsetX" ); + chunkFeatureLocator.bindComponent( chunkOffsetY, "ChunkOffsetY" ); + chunkFeatureLocator.bindComponent( chunkWidth, "ChunkWidth" ); + chunkFeatureLocator.bindComponent( chunkHeight, "ChunkHeight" ); + chunkFeatureLocator.bindComponent( chunkPixelFormat, "ChunkPixelFormat" ); + chunkFeatureLocator.bindComponent( chunkDynamicRangeMin, "ChunkDynamicRangeMin" ); + chunkFeatureLocator.bindComponent( chunkDynamicRangeMax, "ChunkDynamicRangeMax" ); + chunkFeatureLocator.bindComponent( chunkExposureTime, "ChunkExposureTime" ); + chunkFeatureLocator.bindComponent( chunkTimestamp, "ChunkTimestamp" ); + chunkFeatureLocator.bindComponent( chunkLineStatusAll, "ChunkLineStatusAll" ); + chunkFeatureLocator.bindComponent( chunkSequencerSetActive, "ChunkSequencerSetActive" ); + chunkFeatureLocator.bindComponent( chunkmvCustomIdentifier, "ChunkmvCustomIdentifier" ); + m_pRefData->collectSelectedChunkFeatures( Component( hList ).firstChild() ); + } + hList = locator.findComponent( "ImageProcessingResults" ); + if( hList != INVALID_ID ) + { + m_pRefData->m_info_imageProcessingResultsIterator = Component( hList ).firstChild(); + } + locator.bindSearchBase( locator.hObj(), "Image" ); + locator.bindComponent( imageMemoryMode, "MemoryMode" ); + locator.bindComponent( imagePixelFormat, "PixelFormat" ); + locator.bindComponent( imageData, "Data" ); + locator.bindComponent( imageSize, "Size" ); + locator.bindComponent( imageFooter, "Footer" ); + locator.bindComponent( imageFooterSize, "FooterSize" ); + locator.bindComponent( imagePixelPitch, "PixelPitch" ); + locator.bindComponent( imageChannelCount, "ChannelCount" ); + locator.bindComponent( imageChannelOffset, "ChannelOffset" ); + locator.bindComponent( imageChannelBitDepth, "ChannelBitDepth" ); + locator.bindComponent( imageLinePitch, "LinePitch" ); + locator.bindComponent( imageChannelDesc, "ChannelDesc" ); + locator.bindComponent( imageBytesPerPixel, "BytesPerPixel" ); + locator.bindComponent( imageOffsetX, "OffsetX" ); + locator.bindComponent( imageOffsetY, "OffsetY" ); + locator.bindComponent( imageWidth, "Width" ); + locator.bindComponent( imageWidthTotal, "WidthTotal" ); + locator.bindComponent( imageHeight, "Height" ); + locator.bindComponent( imageHeightTotal, "HeightTotal" ); + locator.bindComponent( imageBayerMosaicParity, "BayerMosaicParity" ); + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + void updateBufferParts( void ) const + //----------------------------------------------------------------------------- + { + if( m_pRefData->m_bufferPartIterator.isValid() ) + { + unsigned int bufferPartCount = 0; + Component it( m_pRefData->m_bufferPartIterator.firstChild() ); + while( it.isValid() ) + { + if( bufferPartCount >= m_pRefData->m_bufferParts.size() ) + { + // add new buffer parts + m_pRefData->m_bufferParts.push_back( new BufferPart( it.hObj() ) ); + } + else + { + BufferPart* pBufferPart = m_pRefData->m_bufferParts[bufferPartCount]; + bool boMustUpdate = pBufferPart->hObj() != it.hObj(); + if( !boMustUpdate ) + { + // even if the list handle remained the same, the handles of the features inside it might have different handles now! + boMustUpdate = ( pBufferPart->m_firstSibling.hObj() != it.firstChild().hObj() ) || !pBufferPart->m_firstSibling.isValid(); + } + if( boMustUpdate ) + { + // update existing ones if necessary + pBufferPart->bindPublicProperties( it.hObj() ); + } + } + ++bufferPartCount; + ++it; + } + const BufferPartContainer::size_type bufferPartObjectCount = m_pRefData->m_bufferParts.size(); + if( bufferPartCount < bufferPartObjectCount ) + { + // delete all buffer parts that are no longer part of the buffer + for( size_t i = bufferPartCount; i < bufferPartObjectCount; i++ ) + { + delete m_pRefData->m_bufferParts[i]; + } + m_pRefData->m_bufferParts.resize( bufferPartCount ); + } + } + } +protected: + explicit Request( Device* pDev, int requestNr ) : m_pRefData( new ReferenceCountedData( pDev, requestNr ) ), + requestResult(), requestState(), + infoFrameID(), infoFrameNr(), infoExposeStart_us(), + infoExposeTime_us(), infoTransferDelay_us(), infoGain_dB(), + infoTimeStamp_us(), infoSettingUsed(), infoImageAverage(), + infoVideoChannel(), infoCameraOutputUsed(), infoLineCounter(), + infoMissingData_pc(), infoIOStatesAtExposureStart(), infoIOStatesAtExposureEnd(), + chunkOffsetX(), chunkOffsetY(), chunkWidth(), chunkHeight(), chunkPixelFormat(), chunkDynamicRangeMin(), + chunkDynamicRangeMax(), chunkExposureTime(), chunkTimestamp(), chunkLineStatusAll(), chunkSequencerSetActive(), chunkmvCustomIdentifier(), + imageMemoryMode(), imagePixelFormat(), imageData(), imageSize(), imageFooter(), imageFooterSize(), + imagePixelPitch(), imageChannelCount(), imageChannelOffset(), imageChannelBitDepth(), imageLinePitch(), + imageChannelDesc(), imageBytesPerPixel(), imageOffsetX(), imageOffsetY(), imageWidth(), + imageWidthTotal(), imageHeight(), imageHeightTotal(), imageBayerMosaicParity() + { + bindPublicProperties(); + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::Request from an existing one. + Request( + /// [in] A constant reference to the \b mvIMPACT::acquire::Request object, this object shall be created from + const Request& src ) : m_pRefData( src.m_pRefData ), + requestResult( src.requestResult ), requestState( src.requestState ), + infoFrameID( src.infoFrameID ), infoFrameNr( src.infoFrameNr ), infoExposeStart_us( src.infoExposeStart_us ), + infoExposeTime_us( src.infoExposeTime_us ), infoTransferDelay_us( src.infoTransferDelay_us ), infoGain_dB( src.infoGain_dB ), + infoTimeStamp_us( src.infoTimeStamp_us ), infoSettingUsed( src.infoSettingUsed ), infoImageAverage( src.infoImageAverage ), + infoVideoChannel( src.infoVideoChannel ), infoCameraOutputUsed( src.infoCameraOutputUsed ), infoLineCounter( src.infoLineCounter ), + infoMissingData_pc( src.infoMissingData_pc ), infoIOStatesAtExposureStart( src.infoIOStatesAtExposureStart ), + infoIOStatesAtExposureEnd( src.infoIOStatesAtExposureEnd ), + chunkOffsetX( src.chunkOffsetX ), chunkOffsetY( src.chunkOffsetY ), chunkWidth( src.chunkWidth ), chunkHeight( src.chunkHeight ), + chunkPixelFormat( src.chunkPixelFormat ), chunkDynamicRangeMin( src.chunkDynamicRangeMin ), chunkDynamicRangeMax( src.chunkDynamicRangeMax ), + chunkExposureTime( src.chunkExposureTime ), chunkTimestamp( src.chunkTimestamp ), chunkLineStatusAll( src.chunkLineStatusAll ), + chunkSequencerSetActive( src.chunkSequencerSetActive ), chunkmvCustomIdentifier( src.chunkmvCustomIdentifier ), + imageMemoryMode( src.imageMemoryMode ), imagePixelFormat( src.imagePixelFormat ), + imageData( src.imageData ), imageSize( src.imageSize ), imageFooter( src.imageFooter ), imageFooterSize( src.imageFooterSize ), + imagePixelPitch( src.imagePixelPitch ), imageChannelCount( src.imageChannelCount ), imageChannelOffset( src.imageChannelOffset ), + imageChannelBitDepth( src.imageChannelBitDepth ), imageLinePitch( src.imageLinePitch ), imageChannelDesc( src.imageChannelDesc ), + imageBytesPerPixel( src.imageBytesPerPixel ), imageOffsetX( src.imageOffsetX ), imageOffsetY( src.imageOffsetY ), imageWidth( src.imageWidth ), + imageWidthTotal( src.imageWidthTotal ), imageHeight( src.imageHeight ), imageHeightTotal( src.imageHeightTotal ), imageBayerMosaicParity( src.imageBayerMosaicParity ) + { + ++( m_pRefData->m_refCnt ); + } + virtual ~Request() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::Request objects. + Request& operator=( const Request& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + bindPublicProperties(); + } + return *this; + } + /// \brief Returns a component locator for this request. + /** + * This will allow to write custom feature bind operations. + * + * \since 1.12.68 + * \return A component locator for this request. + */ + DeviceComponentLocator getComponentLocator( void ) const + { + return m_pRefData->m_locator; + } + /// \brief Returns the number of buffer parts currently associated with this request. + /** + * Certain device drivers are able to deliver multiple buffer part within a single request object. + * \sa + * \ref ImageAcquisition_MultiPart + * \since 2.20.0 + * \return The number of buffer parts currently associated with this request. This might be zero in case the device + * driver delivers a \c standard data stream. It might also be 1 for special data formats such as JPEG, which must be handled + * differently from an image describing properties perspective. + */ + unsigned int getBufferPartCount( void ) const + { + updateBufferParts(); + return static_cast( m_pRefData->m_bufferParts.size() ); + } + /// \brief Returns a reference to a buffer part descriptor of this request. + /** + * This function returns a reference to a \b mvIMPACT::acquire::BufferPart at index \c index associated + * with this \b mvIMPACT::acquire::Request. + * + * \warning + * Please do \b NEVER work with old references to this class. So do \b NOT store this reference in + * some variable to use it for the evaluation of the next \b mvIMPACT::acquire::Request object as well, + * as this might not work because the buffer layout might have changed. Whenever \b mvIMPACT::acquire::Request::getBufferPart + * is called the function will make sure that the data in the returned structure is up to date while when working with + * an old reference to the \b mvIMPACT::acquire::BufferPart structure the containing data might refer + * to a previous result or worse an invalid memory location. This reference will remain valid until an + * application calls \b mvIMPACT::acquire::Request::unlock for the corresponding request. + * + * \sa + * \b mvIMPACT::acquire::Request::getBufferPartCount \n + * \ref ImageAcquisition_MultiPart + * + * \since 2.20.0 + * \return A reference to the buffer part defined by \c index + */ + BufferPart& getBufferPart( + /// [in] The index of the buffer part to return + unsigned int index ) const + { + updateBufferParts(); + return *( m_pRefData->m_bufferParts.at( index ) ); + } + /// \brief Returns the name associated with this request. + /** + * \since 2.32.0 + */ + const std::string& getName( void ) const + { + return m_pRefData->m_requestName; + } + /// \brief Returns the number associated with this request. + int getNumber( void ) const + { + return m_pRefData->m_requestNr; + } + /// \brief Returns a const reference to the image buffer descriptor of this request. + /** + * This function returns a const reference to the \b mvIMPACT::acquire::ImageBufferDesc associated + * with this \b mvIMPACT::acquire::Request. + * + * \warning + * Please do \b NEVER work with old references to this structure. So do \b NOT store this reference in + * some variable to use it for the evaluation of the next \b mvIMPACT::acquire::Request object as well, + * as this will not work. Whenever \b mvIMPACT::acquire::Request::getImageBufferDesc is called the function + * will make sure that the data in the returned structure is up to date while when working with + * an old reference to the \b mvIMPACT::acquire::ImageBufferDesc structure the containing data might refer + * to a previous result. + */ + const ImageBufferDesc& getImageBufferDesc( void ) const + { + const TDMR_ERROR result = DMR_GetImageRequestBuffer( m_pRefData->m_pDev->hDrv(), m_pRefData->m_requestNr, &( m_pRefData->m_imageBufferDesc.m_pRefData->m_pBuffer ) ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return m_pRefData->m_imageBufferDesc; + } +#if defined(MVIMPACT_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + /// \brief Returns a mvIMPACT image buffer representation of the image associated with this request. + /** + * \attention + * This function is slow, as it performs a copy of the + * image data. So using this function will not affect the actual image data from the + * device when modifying the image object. + * + * \note + * This function is provided for backward compatibility only. New applications should use + * the overloaded function accepting a parameter of type \b mvIMPACT::acquire::TImpactBufferFlag. + * This function might be faster and provides the user with more control over the way the image + * is constructed. However if the \a new function is used also a new driver has to be deployed + * on every target system running software compiled with this interface. At least version + * 1.3.5 of the mvDeviceManager-lib. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \attention + * This function will only be available if \a mvIMPACT.h has been included before including this interface! + * \endif + */ + mvIMPACT::Image getIMPACTImage( void ) const + { + mvIMPACT_C::IPL_BUFHANDLE hBuf = IPL_DONT_CARE; + const TDMR_ERROR result = DMR_GetImpactRequestBufferEx( m_pRefData->m_pDev->hDrv(), m_pRefData->m_requestNr, &hBuf, TImpactBufferFlag( 0 ), 0 ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return mvIMPACT::Image::imageFactory( hBuf ); + } + /// \brief Returns a mvIMPACT image buffer representation of the image associated with this request. + /** + * \note + * This function might be fast depending on the \a flags parameter or might behave like + * \b mvIMPACT::acquire::Request::getIMPACTImage. + * + * Valid values for \a flags are defined by the enumeration \b mvIMPACT::acquire::TImpactBufferFlag. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \attention + * This function will only be available if \a mvIMPACT.h has been included before including this interface! + * \endif + */ + mvIMPACT::Image getIMPACTImage( + /// [in] Flags defining how the buffer is created and behaves. + TImpactBufferFlag flags ) const + { + mvIMPACT_C::IPL_BUFHANDLE hBuf = IPL_DONT_CARE; + const TDMR_ERROR result = DMR_GetImpactRequestBufferEx( m_pRefData->m_pDev->hDrv(), m_pRefData->m_requestNr, &hBuf, flags, 0 ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, INVALID_ID ); + } + return mvIMPACT::Image::imageFactory( hBuf ); + } +#endif // #if defined(MVIMPACT_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + /// \brief Returns an iterator for iterating inside the info list of the request. + /** + * This can be useful when custom or device specific information has been attached to the request + * object that wasn't known at compile time. + * + * It allows to write code like this: + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * // 'nr' is assumed to be a valid request number returned from a previous call to + * // mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor() + * const Request* pRequest = fi.getRequest( nr ); + * if( pRequest ) + * { + * Component it(pRequest->getInfoIterator()); + * std::map m; + * while( it.isValid() ) + * { + * // collect all entries that are properties and store their current name and value in a map + * if( it.isProp() && it.isVisible() ) + * { + * Property prop( it ); + * m.insert( std::make_pair( prop.name(), prop.readS() ) ); + * } + * ++it; + * } + * // Here you can work with the information you just obtained + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import java.util.Hashtable; + * + * // ... + * + * Component it = pRequest.getInfoIterator(); + * Hashtable m = new Hashtable(); + * while( it.isValid() ) + * { + * // collect all entries that are properties and store their current name and value in a hash table + * if( it.isProp() && it.isVisible() ) + * { + * Property prop = new Property( it.hObj() ); + * m.put( prop.name(), prop.readS() ); + * } + * it = it.nextSibling(); + * } + * // Here you can work with the information you just obtained + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # 'fi' is assumed to be a valid instance of acquire.FunctionInterface, + * # 'nr' is assumed to be a valid request number returned from a previous call to + * # acquire.FunctionInterface.imageRequestWaitFor() + * pRequest = fi.getRequest(requestNr) + * if pRequest: + * it = pRequest.getInfoIterator() + * props = {None:None} + * while it.isValid: + * if it.isProp and it.isVisible: + * prop = acquire.Property(it.hObj()) + * props[prop.name()] = prop.readS() + * it = it.nextSibling() + * # Here you can work with the information you just obtained + * \endcode + * \endif + * \return + * An iterator for iterating inside the info list of the request. + */ + Component getInfoIterator( void ) const + { + return m_pRefData->m_infoIterator; + } + /// \brief Returns an iterator for iterating inside the info/imageProcessingResults list of the request. + /** + * This can be useful when custom or device specific algorithms have been applied to the request + * object that weren't known at compile time. + * + * For a code example please refer to the documentation of \b mvIMPACT::acquire::Request::getInfoIterator + * \sa + * \b mvIMPACT::acquire::Request::getInfoIterator \n + * + * \since 2.14.0 + * + * \return + * An iterator for iterating inside the info/imageProcessingResults list of the request. + */ + Component getImageProcessingResultsIterator( void ) const + { + return m_pRefData->m_info_imageProcessingResultsIterator; + } + /// \brief Checks if image processing that was set up for this request has been skipped for performance reasons. + /** + * If \b mvIMPACT::acquire::Device::userControlledImageProcessingEnable is set to \b mvIMPACT::acquire::bTrue and + * \b mvIMPACT::acquire::SystemSettings::imageProcessingMode is set to \b mvIMPACT::acquire::ipmProcessLatestOnly + * this function can be used to check if at least one algorithm has been skipped because of a lack of processing time. + * \sa + * \b mvIMPACT::acquire::Device::userControlledImageProcessingEnable, \n + * \b mvIMPACT::acquire::SystemSettings::imageProcessingMode \n + * + * \since 2.14.0 + * + * \return + * - true if at least one internal algorithm has been skipped. + * - false otherwise. + */ + bool hasProcessingBeenSkipped( void ) const + { + if( !m_pRefData->m_info_imageProcessingResultsIterator.isValid() ) + { + return false; + } + + Component it( m_pRefData->m_info_imageProcessingResultsIterator ); + while( it.isValid() ) + { + if( PropertyIImageProcessingResult( it.hObj() ).read() == iprSkipped ) + { + return true; + } + ++it; + } + + return false; + } + /// \brief Returns the number of counter values that can be returned as part of the additional data of the buffer containing the request data. + /** + * A device may support a large number of counters even though just a few of them or none is configured + * for counting. In such a case situation when switching on the transmission of the counter values + * at the time of the internal frame start event will allow to access the number of counters returned + * by this function but then the data in these counters of course will be meaningless. + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.0.15 + * \return + * The number of counter values that can be returned as part of the additional data of the buffer containing the request data. + */ + unsigned int getChunkCounterCount( void ) const + { + return static_cast( m_pRefData->m_chunkCounterValues.size() ); + } + /// \brief Returns a 64 bit integer property \b (read-only) defining the selected counter value at the time of the internal frame start event for this request. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a index is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.0.15 + */ + PropertyI64 getChunkCounterValue( + /// [in] The index of the counter to return + unsigned int index ) const + { + return PropertyI64( m_pRefData->m_chunkCounterValues.at( index )->hObj() ); + } + /// \brief Returns the number of timer values that can be returned as part of the additional data of the buffer containing the request data. + /** + * A device may support a large number of timers even though just a few of them or none is configured + * to run. In such a case situation when switching on the transmission of the timer values + * at the time of the internal frame start event will allow to access the number of timers returned + * by this function but then the data in these timers of course will be meaningless. + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.0.15 + */ + unsigned int getChunkTimerCount( void ) const + { + return static_cast( m_pRefData->m_chunkTimerValues.size() ); + } + /// \brief Returns a floating point property \b (read-only) defining the selected timer value at the time of the internal frame start event for this request. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a index is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.0.15 + */ + PropertyF getChunkTimerValue( + /// [in] The index of the timer to return + unsigned int index ) const + { + return PropertyF( m_pRefData->m_chunkTimerValues.at( index )->hObj() ); + } + /// \brief Returns the number of gain values that can be returned as part of the additional data of the buffer containing the request data. + /** + * A device may support a large number of gains even though just a few of them or none is configured + * to run. In such a case situation when switching on the transmission of the gain values + * at the time of the internal frame start event will allow to access the number of gains returned + * by this function but then the data in these gains of course will be meaningless. + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.17.3 + */ + unsigned int getChunkGainCount( void ) const + { + return static_cast( m_pRefData->m_chunkGains.size() ); + } + /// \brief Returns a floating point property \b (read-only) defining the selected gain value at the time of the internal frame start event for this request. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a index is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.17.3 + */ + PropertyF getChunkGain( + /// [in] The index of the gain to return + unsigned int index ) const + { + return PropertyF( m_pRefData->m_chunkGains.at( index )->hObj() ); + } + /// \brief Returns a floating point property \b (read-only) defining the selected gain value at the time of the internal frame start event for this request. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a name is invalid(not a valid gain to select) a mvIMPACT::acquire::EInvalidInputParameter exception + * will be thrown. + * \endif + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.17.3 + */ + PropertyF getChunkGain( + /// [in] The name of the gain to return (as selected by mvIMPACT::acquire::GenICam::AnalogControl::gainSelector) + const std::string& name ) const + { + std::map::const_iterator it = m_pRefData->m_chunkGainString2IndexMap.find( name ); + if( it == m_pRefData->m_chunkGainString2IndexMap.end() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, PROPHANDLING_INVALID_INPUT_PARAMETER, INVALID_ID ); + } + return getChunkGain( it->second ); + } + /// \brief Convenience function to check if a request has been processed successfully. + /** + * This is just a nicer way of checking the value of the \a requestResult property. + * It allows to write code like this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * // 'nr' is assumed to be a valid request number returned from a previous call to + * // mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor() + * const Request* pRequest = fi.getRequest( nr ); + * if( pRequest->isOK() ) + * { + * // do something + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * // 'nr' is assumed to be a valid request number returned from a previous call to + * // mvIMPACT.acquire.FunctionInterface.imageRequestWaitFor() + * Request pRequest = fi.getRequest( nr ); + * if( pRequest.isOK() ) + * { + * // do something + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # 'fi' is assumed to be a valid instance of acquire.FunctionInterface, + * # 'nr' is assumed to be a valid request number returned from a previous call to + * # acquire.FunctionInterface.imageRequestWaitFor() + * pRequest = fi.getRequest(nr) + * if pRequest.isOK: + * # do something + * \endcode + * \endif + * + * Instead if this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * // 'nr' is assumed to be a valid request number returned from a previous call to + * // mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor() + * const Request* pRequest = fi.getRequest( nr ); + * if( pRequest->requestResult.read() == rrOK ) + * { + * // do something + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * // 'nr' is assumed to be a valid request number returned from a previous call to + * // mvIMPACT.acquire.FunctionInterface.imageRequestWaitFor() + * Request pRequest = fi.getRequest( nr ); + * if( pRequest.getRequestResult().read() == TRequestResult.rrOK ) + * { + * // do something + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # 'fi' is assumed to be a valid instance of acquire.FunctionInterface, + * # 'nr' is assumed to be a valid request number returned from a previous call to + * # acquire.FunctionInterface.imageRequestWaitFor() + * pRequest = fi.getRequest(nr) + * if(pRequest.requestResult.read() == acquire.rrOK): + * # do something + * \endcode + * \endif + * + * \since 1.12.63 + * + * \return + * - true if the request has been processed successfully. + * - false otherwise. + */ + bool isOK( void ) const + { + return ( requestResult.read() == rrOK ); + } + /// \brief Sets a request into configuration mode. + /** + * In configuration mode certain properties like \b mvIMPACT::acquire::Request::imageData, + * \b mvIMPACT::acquire::Request::imageSize, \b mvIMPACT::acquire::Request::imageMemoryMode + * of a request object can be modified. This can be used to configure one or more requests + * to use a user supplied memory. To use only a subset of the \b mvIMPACT::acquire::Request + * objects available the \b mvIMPACT::acquire::ImageRequestControl::requestToUse feature + * can be used. + * + * Only requests that are currently not used by the driver and are not locked + * because they contain image data that hasn't been processed can be set into + * configuration mode. + * + * \note + * Instead of calling this function directly for most cases it is much more convenient to use + * the functions \b mvIMPACT::acquire::Request::attachUserBuffer and \b mvIMPACT::acquire::Request::detachUserBuffer + * instead. + * + * User supplied buffers must follow the alignment and size requirements reported by versions of the + * function \b mvIMPACT::acquire::FunctionInterface::getCurrentCaptureBufferLayout. Calling + * a version of this function will return all the information required to allocate buffers that + * can be used to capture data for the specified settings. + * + * When allocating memory on the heap, the complete buffer size is needed which is calculated like + * this: + * + * size + alignment + * + * \note + * The address passed to the request object must be aligned already! + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * Device* pDev = getDevicePointerFromSomewhere() + * FunctionInterface fi(pDev); + * Request* pRequest = fi.getRequest( 0 ); + * // the buffer assigned to the request object must be aligned accordingly + * // the size of the user supplied buffer MUST NOT include the additional size + * // caused by the alignment + * if( pRequest->attachUserBuffer( getAlignedMemoryPtr(), getAlignedMemorySize() ) ) == DMR_NO_ERROR ) + * { + * ImageRequestControl irc(pDev); + * irc.requestToUse.write( 0 ); // use the buffer just configured for the next image request + * // now the next image will be captured into the user supplied memory + * fi.imageRequestSingle( &irc ); // this will send request '0' to the driver + * // wait for the buffer. Once it has been returned by the driver AND the user buffer shall no + * // longer be used call + * if( pRequest->detachUserBuffer() != DMR_NO_ERROR ) + * { + * // handle error + * } + * // now this request will use internal memory again. + * } + * else + * { + * // handle error + * } + * \endcode + * \endif + * \note + * A request that is in configuration mode can't be sent to the driver for acquisition until + * \b mvIMPACT::acquire::Request::unlock or \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock has been called again. + * By using \b mvIMPACT::acquire::Request::attachUserBuffer and \b mvIMPACT::acquire::Request::detachUserBuffer this locking + * and unlocking is done internally thus the application does not need to worry about this. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle, \n + * \b mvIMPACT::acquire::Request::attachUserBuffer, \n + * \b mvIMPACT::acquire::Request::detachUserBuffer, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestReset + * + * \since 1.12.68 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int configure( void ) + { + return DMR_ImageRequestConfigure( m_pRefData->m_pDev->hDrv(), m_pRefData->m_requestNr, 0, 0 ); + } + /// \brief Stores the image described by this request into a file. + /** + * This function stores the image described by this request into a file. + * + * \note + * Internally The FreeImage library (see 'legal notice' section) is used for this operation. If the library + * cannot be located in version 3.16.0 on the host system calling this function will fail. + * + * \since 2.23.0 + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - mvIMPACT::acquire::DMR_LIBRARY_NOT_FOUND if the required version of the FreeImage library could not be located on the host system. + * - mvIMPACT::acquire::DEV_UNSUPPORTED_PARAMETER if a pixel format has been passed to the function that is not supported by the internal algorithms. + * - mvIMPACT::acquire::DEV_INPUT_PARAM_INVALID if a pixel format has been passed to the function that is not supported by the FreeImage library. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int save( + /// [in] The full path of the file to create. + const std::string& fileName, + /// [in] The format of the file to be created. If this parameter is set to mvIMPACT::acquire::iffAuto make sure to specify a proper file extension. + TImageFileFormat format = iffAuto ) const + { + return DMR_ImageRequestSave( m_pRefData->m_pDev->hDrv(), m_pRefData->m_requestNr, fileName.c_str(), format ); + } + /// \brief Unlocks the request for the driver again. + /** + * + * To ensure that no image data is overwritten by another image request while the user still + * deals with the image from a previous acquisition each image buffer will be locked by the driver when + * it is returned to the user by a call to \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor. + * No new image will be captured into the same buffer until the user unlocks the buffer again + * by calling \b mvIMPACT::acquire::Request::unlock or \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock. + * + * \note + * After unlocking a request it is no longer guaranteed that the memory once referenced by the + * request and the image buffer belonging to it stays valid, so do \b NEVER try to access + * memory belonging to an unlocked request object. If you need to copy the image buffer or + * modify it in any other way, do everything you have to do \b BEFORE calling this function! + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::imageRequestReset, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure, \n + * \b mvIMPACT::acquire::Request::configure + * + * \since 1.12.68 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int unlock( void ) + { + return DMR_ImageRequestUnlock( m_pRefData->m_pDev->hDrv(), m_pRefData->m_requestNr ); + } + /// \brief Convenience function to attach a user supplied buffer to a \b mvIMPACT::acquire::Request object. + /** + * This function just provides a nicer way to attach a user supplied buffer to a \b mvIMPACT::acquire::Request. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * It e.g. makes it possible to write code like this: + * + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * const Request* pRequest = fi.getRequest( 0 ); // get access to request 0 + * pRequest->attachUserBuffer( getBufferFromSomewhere(), getBufferSizeFromSomewhere() ); + * \endcode + * + * Instead if this: + * + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface, + * const Request* pRequest = fi.getRequest( 0 ); // get access to request 0 + * if( pRequest->configure() == DMR_NO_ERROR ) + * { + * pRequest->imageMemoryMode.write( rimmUser ); + * pRequest->imageData.write( getBufferFromSomewhere() ); + * pRequest->imageSize.write( getBufferSizeFromSomewhere() ); + * pRequest->unlock(); + * } + * \endcode + * \endif + * + * To find out more about capturing to user supplied buffers please refer to the example + * \ref CaptureToUserMemory.cpp and have a look at the + * documentation of the function \b mvIMPACT::acquire::Request::configure + * + * \sa + * \b mvIMPACT::acquire::Request::detachUserBuffer, \n + * mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * mvIMPACT::acquire::Request::unlock, \n + * mvIMPACT::acquire::FunctionInterface::imageRequestConfigure, \n + * mvIMPACT::acquire::Request::configure + * + * \since 1.12.68 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int attachUserBuffer( + /// [in] A pointer to a user supplied buffer + void* pBuf, + /// [in] The size of the user supplied buffer + int bufSize ) + { + int result = configure(); + if( result == DMR_NO_ERROR ) + { + imageMemoryMode.write( rimmUser ); + imageData.write( pBuf ); + imageSize.write( bufSize ); + result = unlock(); + } + return result; + } + /// \brief Convenience function to detach a user supplied buffer from a \b mvIMPACT::acquire::Request object. + /** + * This function just provides a nicer way to detach a user supplied buffer from a \b mvIMPACT::acquire::Request. + * It e.g. allows to write code like this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface + * const Request* pRequest = fi.getRequest( 0 ); // get access to request 0 + * pRequest->detachUserBuffer(); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT.acquire.FunctionInterface + * Request pRequest = fi.getRequest( 0 ); // get access to request 0 + * pRequest.detachUserBuffer(); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # 'fi' is assumed to be a valid instance of acquire.FunctionInterface + * pRequest = fi.getRequest(0) # get access to request 0 + * pRequest.detachUserBuffer() + * \endcode + * \endif + * + * Instead if this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT::acquire::FunctionInterface + * const Request* pRequest = fi.getRequest( 0 ); // get access to request 0 + * if( pRequest->configure() == DMR_NO_ERROR ) + * { + * pRequest->imageMemoryMode.write( rimmAuto ); + * pRequest->unlock(); + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // 'fi' is assumed to be a valid instance of mvIMPACT.acquire.FunctionInterface + * Request pRequest = fi.getRequest( 0 ); // get access to request 0 + * if( pRequest.configure() == TDMR_ERROR.DMR_NO_ERROR ) + * { + * pRequest.getImageMemoryMode().write( TRequestImageMemoryMode.rimmAuto ); + * pRequest.unlock(); + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # 'fi' is assumed to be a valid instance of acquire.FunctionInterface + * pRequest = fi.getRequest(0) # get access to request 0 + * if pRequest.configure() == acquire.DMR_NO_ERROR: + * pRequest.imageMemoryMode.write(acquire.rimmAuto) + * pRequest.unlock() + * \endcode + * \endif + * + * To find out more about capturing to user supplied buffers please refer to the example + * \ref CaptureToUserMemory.cpp and have a look at the + * documentation of the function \b mvIMPACT::acquire::Request::configure + * + * \sa + * \b mvIMPACT::acquire::Request::attachUserBuffer, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure, \n + * \b mvIMPACT::acquire::Request::configure + * + * \since 1.12.68 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int detachUserBuffer( void ) + { + int result = configure(); + if( result == DMR_NO_ERROR ) + { + imageMemoryMode.write( rimmAuto ); + result = unlock(); + } + return result; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property \b (read-only) defining the result of this request. + /** + * This parameter indicates whether a previous image acquisition has been + * successful or not. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TRequestResult. + */ + PropertyIRequestResult requestResult; + /// \brief An enumerated integer property \b (read-only) defining the current state of this request. + /** + * This parameter indicates the current state of this request. A \b mvIMPACT::acquire::Request e.g. + * can currently be idle. This would mean that it is currently not used for + * image acquisition. Also a \b mvIMPACT::acquire::Request can be in 'Capturing' state, which means + * it is currently processed by the driver. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TRequestState. + */ + PropertyIRequestState requestState; + /// \brief A 64 bit integer property \b (read-only) containing a frame identifier. + /** + * This parameter is returned as part of the \b mvIMPACT::acquire::Request. It is + * used to associate a certain image with a unique identifier. + * + * When an \b mvIMPACT::acquire::RTCtrProgramStep instruction of the type \b mvIMPACT::acquire::rtctrlProgTriggerSet + * is executed, the \a frameID is set to the value of the property \a FrameID of a corresponding \b mvIMPACT::acquire::RTCtrProgramStep if the + * HRTC is used and any program step executes the setting of the ID. + * + * If a device (e.g. a digital camera) supports the transmission of a unique identifier for an image, this property will reflect + * the identifier as transmitted by the device. + * + * \note \b mvBlueFOX and \b mvHYPERION specific: + * This property will only contain meaningful data if the device supports at least one \b HRTC and a program is running and writing data to + * the property OR if a device supports the transmission of a unique identifier for an image. Currently HRTC programs are supported by \b mvBlueFOX and \b mvHYPERION devices. + * + * \note \b GigE \b Vision and \b USB3 \b Vision specific: + * This is the property where the so called block ID will be stored which is a unique identifier for each frame that will be transferred by the device as part of each frame as defined by the standard. + * - For \b GigE \b Vision 1.x compliant devices, this will be a 16 bit counter that will be incremented with every data block(e.g. an image or chunk data) transmitted + * by the device where '0' is a reserved value, which will never be used, thus values like this will be transmitted in a round robin scheme: + * 1, 2, 3, ..., 65535, 1, 2, ... + * - For devices complying with version 2.0 and greater of the \b GigE \b Vision specification, this will be a 64 bit counter that will be incremented with every data block(e.g. an image or chunk data) transmitted + * by the device where '0' is a reserved value, which will never be used, thus values like this will be transmitted in a round robin scheme: + * 1, 2, 3, ..., ((2^64)-1), 1, 2, ... + * - For \b USB3 \b Vision compliant devices, this will be a 64 bit counter that will be incremented with every data block(e.g. an image or chunk data) transmitted + * by the device, thus values like this will be transmitted in a round robin scheme: + * 0, 1, 2, ..., ((2^64)-1), 0, 1, ... + * + * Please note that due to the nature of \b mvIMPACT::acquire::amContinuous there might be gaps between the + * last image of a continuous stream and the first image of the next continuous stream if the device is stopped or re-programmed in between. + */ + PropertyI64 infoFrameID; + /// \brief A 64 bit integer property \b (read-only, zero-based) containing the number of image requests processed since this driver instance has been opened. + /** + * This counter is incremented regardless of the result this request is returned with thus also e.g. if a request did time out, was aborted(e.g. due to a call to \b mvIMPACT::acquire::FunctionInterface::imageRequestReset or \b mvIMPACT::acquire::FunctionInterface::acquisitionStop) or the data was not completely captured. + * So if a \b mvIMPACT::acquire::Request object contains the value \a 6 here, 6 requests have been processed before this one(the first request would contain the value \a 0) + * This value is reset to 0 only if the current driver instance is closed. + */ + PropertyI64 infoFrameNr; + /// \brief An integer property \b (read-only) containing a timestamp (in us) defining the time the device started the exposure of the image associated with this \b mvIMPACT::acquire::Request object. + /** + * This value will stay 0 if nothing is known about the time the exposure did start. + * In such a case the \b mvIMPACT::acquire::Request::infoTimeStamp_us property should be used instead. + */ + PropertyI infoExposeStart_us; + /// \brief An integer property \b (read-only) containing the 'real' expose time (in us) used to generate this image. + /** + * This might differ slightly from the value selected by the user via + * the corresponding exposure property depending on the precision + * available for the device or the connected camera. + */ + PropertyI infoExposeTime_us; + /// \brief An integer property \b (read-only) containing the time the transaction of this image has been delayed (in us) because either the bus was blocked or the CPU was busy. + /** + * Normally this value will be 0. A value larger than 0 indicates that the system + * can't manage the current load. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyI infoTransferDelay_us; + /// \brief A float property \b (read-only) containing the gain(in dB) this image has been taken with. + PropertyF infoGain_dB; + /// \brief A 64 bit integer property \b (read-only) containing a timestamp to define the exact time this image has been captured + /// (usually either at exposure start or exposure end, depending on the device). + /** + * \b mvBlueFOX specific: + * The counter of the timestamp starts when the camera gets initialized. It is measured in us. + */ + PropertyI64 infoTimeStamp_us; + /// \brief A enumerated integer property \b (read-only) containing the setting that was used for processing this request. + /** + * The string representation will be a valid setting name, the integer representation can be casted into a \b mvIMPACT::acquire::HOBJ type. + */ + PropertyI infoSettingUsed; + /// \brief Currently unsupported. + PropertyF infoImageAverage; + /// \brief An integer property \b (read-only) containing the video input channel of the device this image has been acquired from. + /** + * \note + * This property is not supported by every device and will only be available if the device has more than one input channel. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyI infoVideoChannel; + /// \brief An enumerated integer property \b (read-only) containing the camera output used to transmit the image to the capture device. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraOutput. + * + * \note This property is not supported by every device. Therefore always call the function \b mvIMPACT::acquire::Component::isValid + * to check if this property is available or not. + */ + PropertyICameraOutput infoCameraOutputUsed; + /// \brief An integer property \b (read-only) containing the number of lines since the last trigger event. + /** + * Will contain + * - the number of lines since last trigger event of the first line of the snap if line counting is enabled + * - -1 otherwise + * + * \note This property is not supported by every device. Therefore always call the function \b mvIMPACT::acquire::Component::isValid + * to check if this property is available or not. + */ + PropertyI infoLineCounter; + /// \brief A float property \b (read-only) containing the amount of data missing in the current image. + /** + * The value of this property will be 0 almost always. However if a device + * can detect blocks of missing data and an image request has returned with \b mvIMPACT::acquire::rrFrameIncomplete + * to indicate that not all the data has been captured, this property will contain the amount of data missing in percent. + */ + PropertyF infoMissingData_pc; + /// \brief An integer property \b (read-only) containing the state of all the IO lines at the beginning of the frame exposure as a device specific bit field. + /** + * The following table documents which bit in this property represents the state of which digital I/O for \b mvBlueFOX devices: + * + * + * + * + * + * + * + * + * + * + * + *
bitIO
0in 0
1in 1
2in 2(if available)
3in 3(if available)
4out 0
5out 1
6out 2(if available)
7out 3(if available)
+ * + * \attention This feature is currently only available for \b mvBlueFOX-MLC devices! + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * #include + * #include + * + * using namespace std; + * using namespace mvIMPACT::acquire; + * + * //----------------------------------------------------------------------------- + * template + * string decToBinString( _Ty value ) + * //----------------------------------------------------------------------------- + * { + * const size_t bitCount = sizeof(_Ty)*8; + * ostringstream oss; + * for( size_t i=0; iinfoIOStatesAtExposureStart.isValid() ) + * { + * cout << pRequest->infoIOStatesAtExposureStart.name() << ": " << decToBinString( pRequest->infoIOStatesAtExposureStart.read() ) << endl; + * } + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * public static void printIOStateOfAValidRequest( Request pRequest ) + * //----------------------------------------------------------------------------- + * { + * if( pRequest.getInfoIOStatesAtExposureStart().isValid() ) + * { + * System.out.println( pRequest.getInfoIOStatesAtExposureStart().name() + ": " + Integer.toBinaryString( pRequest.getInfoIOStatesAtExposureStart().read() ) ); + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * def printIOStateOfAValidRequest(pRequest): + * if pRequest.infoIOStatesAtExposureStart.isValid: + * print(pRequest.infoIOStatesAtExposureStart.name() + ": " + format(pRequest.infoIOStatesAtExposureStart.read(), '32b')) + * \endcode + * \endif + * \note This property is not supported by every device. Therefore always call the function \b mvIMPACT::acquire::Component::isValid + * to check if this property is available or not. + */ + PropertyI infoIOStatesAtExposureStart; + /// \brief An integer property \b (read-only) containing the state of all the IO lines at the end of the frame exposure as a device specific bit field. + /** + * See \b mvIMPACT::acquire::Request::infoIOStatesAtExposureStart for details on how to interpret the data. + * + * \note This property is not supported by every device. Therefore always call the function \b mvIMPACT::acquire::Component::isValid + * to check if this property is available or not. + */ + PropertyI infoIOStatesAtExposureEnd; + /// \brief A 64 bit integer property \b (read-only) containing the X-offset of the image in pixels as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkOffsetX; + /// \brief A 64 bit integer property \b (read-only) containing the Y-offset of the image in pixels as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkOffsetY; + /// \brief A 64 bit integer property \b (read-only) containing the width of the image in pixels as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkWidth; + /// \brief A 64 bit integer property \b (read-only) containing the height of the image in pixels as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkHeight; + /// \brief A 64 bit integer property \b (read-only) containing the pixel format of the image as returned in the chunk data attached to the image. + /** + * This will \b NOT be a valid mvIMPACT acquire pixel format but e.g. a GigE Vision, USB3 Vision of PFNC compliant pixel format or something else. + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkPixelFormat; + /// \brief A 64 bit integer property \b (read-only) containing the minimum value of dynamic range of the image as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkDynamicRangeMin; + /// \brief A 64 bit integer property \b (read-only) containing the maximum value of dynamic range of the image as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkDynamicRangeMax; + /// \brief A floating point property \b (read-only) containing the exposure time used to capture the image as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.5.16 + */ + PropertyF chunkExposureTime; + /// \brief A 64 bit integer property \b (read-only) containing the timestamp value of the internal frame start signal of the image as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkTimestamp; + /// \brief A 64 bit integer property \b (read-only) containing the status of all I/O lines at the time of the internal frame start signal of the image as returned in the chunk data attached to the image. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + */ + PropertyI64 chunkLineStatusAll; + /// \brief A 64-bit integer property \b (read-only) containing the index of the active set of the running sequencer use during the creation of this block of data. + /** + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.12.3 + */ + PropertyI64 chunkSequencerSetActive; + /// \brief A 64 bit integer property \b (read-only) containing the previously configured user defined identifier attached to the image. + /** + * This identifier can be specified by some other functions belonging to this SDK. If not specified this value will be 0. + * + * \note + * For additional information about the chunk data format please refer to \ref ImageAcquisition_chunk. + * + * \since 2.17.3 + */ + PropertyI64 chunkmvCustomIdentifier; + /// \brief An enumerated integer property \b (read-only) containing the memory mode used for this request. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TRequestImageMemoryMode. + * + * \note This property will become writeable if this request is in configuration mode. + * \sa + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure, \n + * \b mvIMPACT::acquire::Request::configure + */ + PropertyIRequestImageMemoryMode imageMemoryMode; + /// \brief An enumerated integer property \b (read-only) containing the pixel format of this image. + /** + * This might be important, when the image data needs to be processed or stored in + * a file or maybe even if the image shall be displayed. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageBufferPixelFormat. + */ + PropertyIImageBufferPixelFormat imagePixelFormat; + /// \brief A pointer property \b (read-only) containing the start address of the image data. + /** + * This address in connection with \b mvIMPACT::acquire::Request::imageSize is sufficient + * to copy the complete image without having any additional information about it. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * FunctionInterface& fi = getFunctionInterfaceFromSomewhere(); + * int currentRequestNr = getCurrentRequestNumberFromSomewhere(); + * const Request* pRequest = fi.getRequest( currentRequestNr ); + * char* pTempBuf = new char[pRequest->imageSize.read()]; + * memcpy( pTempBuf, pRequest->imageData.read(), pRequest->imageSize.read() ); + * // free the memory once no longer needed... + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * FunctionInterface fi = getFunctionInterfaceFromSomewhere(); + * int currentRequestNr = getCurrentRequestNumberFromSomewhere(); + * Request pRequest = fi.getRequest( currentRequestNr ); + * byte[] data = new byte[pRequest.getImageSize().read()]; + * pRequest.getImageBufferDesc().copy( data ); + * \code + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * currentRequestNr = getCurrentRequestNumberFromSomewhere() + * pRequest = fi.getRequest(currentRequestNr) + * cbuf = (ctypes.c_char * pRequest.imageSize.read()).from_address(int(pRequest.imageData.read())) + * \endcode + * \endif + * + * \note + * It's not always necessary to copy the image data! Each image buffer is an + * integral part of the \b mvIMPACT::acquire::Request object returned to the user by a call to + * the corresponding 'waitFor' function offered by the interface. + * The data in this buffer remains valid until the user either + * unlocks the request buffer or closes the \b mvIMPACT::acquire::Device again. + * + * \note + * By unlocking the \b mvIMPACT::acquire::Request, the user informs the driver that this \b mvIMPACT::acquire::Request + * and the image buffer belonging to that \b mvIMPACT::acquire::Request is no longer needed by the + * user. The driver then queues this \b mvIMPACT::acquire::Request for capturing image data into it once + * again. However, once a \b mvIMPACT::acquire::Request has been returned to the user, its image buffer + * can't be overwritten by the driver! Therefore the user can work with, modify, store or + * copy the data safely until he unlocks the \b mvIMPACT::acquire::Request again. + * + * \note This property will become writeable if this request is in configuration mode. + * \sa + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure, \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::Request::imageSize, \n + * \b mvIMPACT::acquire::Request::imageFooterSize + */ + PropertyPtr imageData; + /// \brief An integer property \b (read-only) containing the size (in bytes) of the whole image. + /** + * This value in connection with \b mvIMPACT::acquire::Request::imageData is sufficient + * to copy the complete image without having any additional information about it. + * + * \note This property will become writeable if this request is in configuration mode. + * \sa + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure, \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::Request::imageData, \n + * \b mvIMPACT::acquire::Request::imageFooterSize + */ + PropertyI imageSize; + /// \brief A pointer property \b (read-only) containing the start address of the footer associated with this image. + /** + * A footer may contain additional data like e.g. information about the image (e.g. the exposure time used for this image). + * If this property contains the value '0' no footer is attached to this image. + * + * \note + * In general it is not necessary to access footer data. Sometime e.g. when the hardware already does some image pre-processing + * a footer containing additional information about the image data might be attached to the image. In this case some additional + * information about the structure of the footer might be needed as well. + */ + PropertyPtr imageFooter; + /// \brief An integer property \b (read-only) containing the size (in bytes) of the footer associated with this image. + /// + /// If this property contains the value '0' no footer is attached to this image. + PropertyI imageFooterSize; + /// \brief An integer property \b (read-only) containing the offset (in bytes) to the next pixel of the specified channel of this image. + /** + * \note + * This property will store \a imageChannelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI imagePixelPitch; + /// \brief An integer property \b (read-only) containing the number of channels this image consists of. + /** + * For an RGB image this value e.g. would be 3. This value also defines how many parameters are stored by the properties + * \b mvIMPACT::acquire::Request::imagePixelPitch, \n + * \b mvIMPACT::acquire::Request::imageLinePitch, \n + * \b mvIMPACT::acquire::Request::imageChannelBitDepth, \n + * \b mvIMPACT::acquire::Request::imageChannelDesc and \n + * \b mvIMPACT::acquire::Request::imageChannelOffset. + * + * If e.g. the channel count is 3 a call like pRequest->imageChannelOffset.read( 2 ) would return the channel offset of + * channel 3 (as calls to the read functions of properties are '0' based). + */ + PropertyI imageChannelCount; + /// \brief An integer property \b (read-only) containing the offset (in bytes) to each channel belonging to the current image relative to the address contained in \b mvIMPACT::acquire::Request::imageData. + /** + * \note + * This property will store \a imageChannelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI imageChannelOffset; + /// \brief An integer property \b (read-only) containing the number of effective bits stored in each channel belonging to the current image. + /** + * \note + * This property will store \a imageChannelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI imageChannelBitDepth; + /// \brief An integer property \b (read-only) containing the offset (in bytes) to the next line of each channel belonging to the current image. + /** + * \note + * This property will store \a imageChannelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyI::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + */ + PropertyI imageLinePitch; + /// \brief A string property \b (read-only) containing the string descriptors of each channel belonging to the current image. + /** + * \note + * This property will store \a imageChannelCount values. These can be queried one by one using the \a index parameter of the function + * \b mvIMPACT::acquire::PropertyS::read() or in a single call by using the overloaded \a read function accepting a reference to a + * vector. + * + * For an RGB image this property e.g. might contain three values "R", "G" and "B". + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * FunctionInterface& fi = getFunctionInterfaceFromSomewhere(); + * int currentRequestNr = getCurrentRequestNumberFromSomewhere(); + * const Request* pRequest = fi.getRequest( currentRequestNr ); + * int channelCount = pRequest->imageChannelCount.read(); + * for( int i=0; iimageChannelDesc.read( i ) << endl; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * FunctionInterface fi = getFunctionInterfaceFromSomewhere(); + * int currentRequestNr = getCurrentRequestNumberFromSomewhere(); + * Request pRequest = fi.getRequest( currentRequestNr ); + * int channelCount = pRequest.getImageChannelCount().read(); + * for( int i=0; iisOK() ) + * { + * const MyRequest* pMyRequest(dynamic_cast(pRequest)); + * cout << pMyRequest->myRequestResult.name() << ": " << pMyRequest->myRequestResult.readS() << endl; + * // do what you want to do with your derived request instance here! + * } + * // ... probably even more additional code + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * This shows how a request factory could be used to create custom request objects + * from within a \b mvIMPACT::acquire::FunctionInterface instance. + * + * MyRequest.java: + * + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * // Example for a derived request object. It doesn't introduce new functionality + * // but rebinds an existing property. Custom properties could bound in a similar + * // way. + * class MyRequest extends Request + * //----------------------------------------------------------------------------- + * { + * private PropertyI myRequestResult_ = new PropertyI(); + * + * private void init() + * { + * DeviceComponentLocator locator = new DeviceComponentLocator( getComponentLocator().hObj() ); + * locator.bindComponent( myRequestResult_, "Result" ); + * } + * + * protected MyRequest( Device pDev, int requestNr ) + * { + * super( pDev, requestNr ); + * init(); + * } + * + * // Without this constructor this whole 'RequestFactory' concept will not work + * // at the moment as in 'FunctionInterface.getRequest' the internal correctly + * // constructed 'MyRequest' generated via the director class and 'MyRequestFactory' + * // will be used to create a new 'Request' instance from it. We now use this to + * // re-create yet another 'MyRequest' instance from that which is kind of silly + * // but in Python we have a very similar effect(see corresponding snippet in the Python manual). + * // + * // Maybe there is a better way to do this! Suggestions welcome! + * public MyRequest( Request pRequest ) + * { + * super( Request.getCPtr( pRequest ), false ); + * init(); + * } + * + * public PropertyI getMyRequestResult() + * { + * return myRequestResult_; + * } + * } + * \endcode + * + * MyRequestFactory.java: + * + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * // Example for a factory that creates 'MyRequest' instances + * class MyRequestFactory extends RequestFactory + * //----------------------------------------------------------------------------- + * { + * @Override + * public Request createRequest( Device pDev, int requestNr ) + * { + * return new MyRequest( pDev, requestNr ); + * } + * } + * + * \endcode + * + * Now the request factory must be passed to the constructor of the function interface! + * This might happen in some other source file or class within the application. + * + * \code + * //----------------------------------------------------------------------------- + * void fn( Device pDev ) + * //----------------------------------------------------------------------------- + * { + * // ... some code ... + * MyRequestFactory mrf = new MyRequestFactory(); + * FunctionInterface fi = new FunctionInterface( pDev, mrf ); + * // ... more additional code + * // assuming we got back a request from the driver at this point: + * Request pRequest = fi.getRequest( getRequestNrFromSomewhere() ); + * if( pRequest->isOK() ) + * { + * System.out.println( String.format( "%s: %s", ( ( MyRequest )pRequest ).getMyRequestResult().name(), ( ( MyRequest )pRequest ).getMyRequestResult().readS() ); + * // do what you want to do with your derived request instance here! + * } + * // ... probably even more additional code + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * This shows how a request factory could be used to create custom request objects + * from within a \b mvIMPACT::acquire::FunctionInterface instance. + * + * \code + * # Example for a derived request object. It doesn't introduce new functionality + * # but rebinds an existing property. Custom properties could bound in a similar + * # way. + * class MyRequest(acquire.Request): + * def __init__(self, *args): + * acquire.Request.__init__(self, *args) + * self.myRequestResult = acquire.PropertyIRequestResult() + * locator = acquire.DeviceComponentLocator(self.getComponentLocator().hObj()) + * locator.bindComponent(self.myRequestResult, "Result") + * + * class MyRequestFactory(acquire.RequestFactory): + * def __init__(self): + * acquire.RequestFactory.__init__(self) + * self.__instances = [] + * + * def createRequest(self, pDev, requestNr): + * try: + * instance = MyRequest(pDev, requestNr) + * # We MUST keep a reference to this request object here as otherwise the instance gets cleaned up + * # by the garbage collector when leaving this function. We therefore add an artificial reference + * # by adding this MyRequest instance to the array which is kind of silly but in Java we have a + * # very similar effect (see corresponding snippet in the Java manual). + * # + * # Maybe there is a better way to do this! Suggestions welcome! + * self.__instances.append(instance) + * return instance + * except Exception as e: + * print("An exception has been raised by code that is not supposed to raise one: '" + str(e) + "'! If this is NOT handled here the application will crash as this Python exception instance will be returned back into the native code that fired this function callS!") + * return None + * \endcode + * + * Now the request factory must be passed to the constructor of the function interface + * + * \code + * def fn(pDev): + * # ... some code ... + * mrf = MyRequestFactory() + * fi = acquire.FunctionInterface(pDev, mrf) + * # ... more additional code + * # assuming we got back a request from the driver at this point: + * pRequest = fi.getRequest(getRequestNrFromSomewhere()) + * if pRequest.isOK: + * # The paranoid could do this additional check, but it is not neccessary: + * if type(pRequest) is MyRequest: + * print(pMyRequest.myRequestResult.name() + ": " + pMyRequest.myRequestResult.readS()) + * else: + * print("ERROR! We should have an instance of our derived 'MyRequest' class here!") + * sys.exit(-1) + * # do what you want to do with your derived request instance here! + * # ... probably even more additional code + * } + * \endcode + * \endif + * + * \since 1.12.56 + * + */ +class RequestFactory +//----------------------------------------------------------------------------- +{ +public: + virtual ~RequestFactory() {} + virtual Request* createRequest( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from + /// a \b mvIMPACT::acquire::>DeviceManager object. + Device* /*pDev*/, + /// [in] The request number that internally has been assigned to this + /// request by the device driver. + int /*requestNr*/ ) + { + return 0; + } +}; + +//----------------------------------------------------------------------------- +/// \brief The function interface to devices supported by this interface. +/** + * This class contains all the basic functions needed when working with a device. + * There are not too many functions as most data will be represented by 'properties' + * in other classes of this module, keeping the set of functions to remember rather + * small. To construct a new function interface, a pointer to a \b mvIMPACT::acquire::Device object + * must be passed to the constructor of \b mvIMPACT::acquire::FunctionInterface. In order to work + * with the \b mvIMPACT::acquire::FunctionInterface object the device needs to be initialized, so + * if the \b mvIMPACT::acquire::Device object pointed to by \a pDev in the constructors parameter list + * hasn't been opened already the constructor will try to do that. + * + * Please refer to one of the examples listed below to get an idea on how to use this class for data acquisition: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * - \ref SingleCapture.cpp + * - \ref ContinuousCapture.cpp + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * - \ref ContinuousCapture.java + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * - \ref ContinuousCapture.py + * \endif + */ +class FunctionInterface +//----------------------------------------------------------------------------- +{ + typedef std::vector RequestVector; +# if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + ComponentList m_requestList; + ComponentList m_imageRequestControlList; + mutable std::vector m_imageRequestControls; + mutable RequestVector m_requests; + Request* m_pCurrentCaptureBufferLayout; + mutable std::vector m_settings; + mutable unsigned int m_lastImageRequestChangedCounter; + mutable unsigned int m_lastSettingsListChangedCounter; + std::stack m_settingsInRAM; + Device* m_pDevice; + RequestFactory* m_pRequestFactory; + PropertyI m_requestCount; + PropertyI m_captureBufferAlignment; + ComponentList m_settingsList; + unsigned int m_refCnt; + explicit ReferenceCountedData( Device* pDev, RequestFactory* pRequestFactory ) : m_requestList(), m_imageRequestControlList(), + m_imageRequestControls(), m_requests(), m_pCurrentCaptureBufferLayout( 0 ), m_settings(), m_lastImageRequestChangedCounter( 0 ), + m_lastSettingsListChangedCounter( 0 ), m_settingsInRAM(), m_pDevice( pDev ), m_pRequestFactory( pRequestFactory ), + m_requestCount(), m_captureBufferAlignment(), m_settingsList(), m_refCnt( 1 ) {} + // make sure there are NO assignments or copy constructions by accident! + ReferenceCountedData& operator=( const ReferenceCountedData& rhs ); + ReferenceCountedData( const ReferenceCountedData& src ); + ~ReferenceCountedData() + { + RequestVector::size_type rvSize = m_requests.size(); + for( RequestVector::size_type i = 0; i < rvSize; i++ ) + { + delete m_requests[i]; + } + delete m_pCurrentCaptureBufferLayout; + while( !m_settingsInRAM.empty() ) + { + deleteSettingFromStack(); + } + } + //----------------------------------------------------------------------------- + int deleteSettingFromStack( void ) + //----------------------------------------------------------------------------- + { + if( m_settingsInRAM.empty() ) + { + return PROPHANDLING_LIST_CANT_ACCESS_DATA; + } + const int result = DMR_DeleteSetting( m_settingsInRAM.top().c_str(), slRAM, sUser ); + m_settingsInRAM.pop(); + return result; + } + //----------------------------------------------------------------------------- + int saveCurrentSettingOnStack( TStorageFlag storageFlags ) + //----------------------------------------------------------------------------- + { + std::ostringstream oss; + oss << m_pDevice->serial.read() << "_" << this << "_" << m_settingsInRAM.size(); + storageFlags = static_cast( ( storageFlags & ( ~( sfFile | sfNative ) ) ) | sfRAM ); + const int result = DMR_SaveSetting( m_pDevice->hDrv(), oss.str().c_str(), storageFlags, sUser ); + if( result == DMR_NO_ERROR ) + { + m_settingsInRAM.push( oss.str() ); + } + return result; + } + }* m_pRefData; +# endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + //----------------------------------------------------------------------------- + Request* createRequest( int requestNr ) const + //----------------------------------------------------------------------------- + { + if( m_pRefData->m_pRequestFactory ) + { + return m_pRefData->m_pRequestFactory->createRequest( m_pRefData->m_pDevice, requestNr ); + } + return new Request( m_pRefData->m_pDevice, requestNr ); + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + void updateRequests( void ) const + //----------------------------------------------------------------------------- + { + RequestVector::size_type rListSize = static_cast( m_pRefData->m_requestList.size() ); + RequestVector::size_type vSize = m_pRefData->m_requests.size(); + if( rListSize < vSize ) + { + // requests have been deleted... + for( RequestVector::size_type i = rListSize; i < vSize; i++ ) + { + delete m_pRefData->m_requests[i]; + } + m_pRefData->m_requests.resize( rListSize ); + } + else if( rListSize > vSize ) + { + // there are new requests + Component it( m_pRefData->m_requestList ); + it = it.firstChild(); + for( RequestVector::size_type i = 0; ( i < vSize ) && it.isValid(); i++ ) + { + ++it; + } + while( it.isValid() ) + { + // this might happen, if there are several instances referring to the same device + // and another instance has created new requests in the meantime, or if this instance + // has just been created + m_pRefData->m_requests.push_back( createRequest( static_cast( m_pRefData->m_requests.size() ) ) ); + ++it; + } + } + } + //----------------------------------------------------------------------------- + void updateSettings( void ) const + //----------------------------------------------------------------------------- + { + unsigned int actChangedCounter = m_pRefData->m_settingsList.changedCounter(); + if( m_pRefData->m_lastSettingsListChangedCounter != actChangedCounter ) + { + // something has changed in the settings list -> update the string array + // the string array must be filled from scratch each time because settings might have been + // deleted as well... + m_pRefData->m_settings.clear(); + Component it( m_pRefData->m_settingsList ); + it = it.firstChild(); + while( it.isValid() ) + { + // this might happen, if there are several instances referring to the same device + // and another instance has created new settings in the meantime, or if this instance + // has just been created + m_pRefData->m_settings.push_back( it.name() ); + ++it; + } + m_pRefData->m_lastSettingsListChangedCounter = actChangedCounter; + } + } + //----------------------------------------------------------------------------- + void updateImageRequestControls( void ) const + //----------------------------------------------------------------------------- + { + unsigned int actChangedCounter = m_pRefData->m_imageRequestControlList.changedCounter(); + if( m_pRefData->m_lastImageRequestChangedCounter != actChangedCounter ) + { + // something has changed in the image request controls list -> update the string array + // the string array must be filled from scratch each time because objects might have been + // deleted as well... + m_pRefData->m_imageRequestControls.clear(); + Component it( m_pRefData->m_imageRequestControlList ); + it = it.firstChild(); + while( it.isValid() ) + { + // this might happen, if there are several instances referring to the same device + // and another instance has created new object in the meantime, or if this instance + // has just been created + m_pRefData->m_imageRequestControls.push_back( it.name() ); + ++it; + } + m_pRefData->m_lastImageRequestChangedCounter = actChangedCounter; + } + } +public: + /// \brief Constructs a new function interface for the device pointed to by \a pDev. + /** + * In order to work with the \b mvIMPACT::acquire::FunctionInterface object the device needs to be + * initialized, so if the \b mvIMPACT::acquire::Device object pointed to by \a pDev in the constructors + * parameter list hasn't been opened already the constructor will try to do that. + * Thus internally a call to \b mvIMPACT::acquire::Device::open might be preformed with all consequences + * following from this call. + * + * \sa + * \b Device::open + */ + explicit FunctionInterface( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from + /// a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] A pointer to a request factory. + /// By supplying a custom request factory the user can control the type of request objects + /// that will be created by the function interface. + /// \since 1.12.56 + RequestFactory* pRequestFactory = 0 ) : m_pRefData( 0 ) + { + if( !pDev->isOpen() ) + { + pDev->open(); + } + m_pRefData = new ReferenceCountedData( pDev, pRequestFactory ); + DeviceComponentLocator locator( pDev, dltSetting ); + m_pRefData->m_settingsList = ComponentList( locator.searchbase_id() ); + locator.bindSearchBaseList( pDev, dltRequest ); + m_pRefData->m_requestList = ComponentList( locator.searchbase_id() ); + locator.bindSearchBaseList( pDev, dltRequestCtrl ); + m_pRefData->m_imageRequestControlList = ComponentList( locator.searchbase_id() ); + locator.bindSearchBaseList( pDev, dltSystemSettings ); + locator.bindComponent( m_pRefData->m_requestCount, "RequestCount" ); + locator.bindSearchBaseList( pDev, dltInfo ); + locator.bindComponent( m_pRefData->m_captureBufferAlignment, "CaptureBufferAlignment" ); + updateRequests(); + locator.bindSearchBaseList( pDev, dltInfo ); + if( locator.findComponent( "CurrentRequestLayout" ) != INVALID_ID ) + { + m_pRefData->m_pCurrentCaptureBufferLayout = createRequest( -1 ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::FunctionInterface from an existing one. + FunctionInterface( + /// [in] A constant reference to the \b mvIMPACT::acquire::FunctionInterface object, this object shall be created from + const FunctionInterface& src ) : m_pRefData( src.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + virtual ~FunctionInterface( void ) + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::FunctionInterface objects. + FunctionInterface& operator=( const FunctionInterface& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + } + return *this; + } + /// \brief Manually starts the acquisition engine of this device driver instance. + /** + * Calling this function will manually start this device driver's acquisition engine. This will only + * have an effect on the overall behaviour if \b mvIMPACT::acquire::Device::acquisitionStartStopBehaviour is + * set to \b mvIMPACT::acquire::assbUser. + * + * If supported by the device driver, starting and stopping the acquisition engine manually can sometimes + * help to overcome capture queue underruns or certain restrictions in the underlying device driver + * technology. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStop, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor, \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure + * + * \since 1.12.11 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - \b mvIMPACT::acquire::DMR_FEATURE_NOT_AVAILABLE if this device/driver combination does not support manual control over the acquisition engine. This will also happen if \b mvIMPACT::acquire::Device::acquisitionStartStopBehaviour is \b NOT set to \b mvIMPACT::acquire::assbUser. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int acquisitionStart( void ) const + { + return DMR_AcquisitionStart( m_pRefData->m_pDevice->hDrv() ); + } + /// \brief Manually stops the acquisition engine of this device driver instance. + /** + * Calling this function will manually stop this device drivers acquisition engine. This will only + * have effect on the overall behaviour, if \b mvIMPACT::acquire::Device::acquisitionStartStopBehaviour is + * set to \b mvIMPACT::acquire::assbUser. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStart, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor, \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure + * + * \since 1.12.11 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - \b mvIMPACT::acquire::DMR_FEATURE_NOT_AVAILABLE if this device/driver combination does not support manual control over the acquisition engine. This will also happen if \b mvIMPACT::acquire::Device::acquisitionStartStopBehaviour is \b NOT set to \b mvIMPACT::acquire::assbUser. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int acquisitionStop( void ) const + { + return DMR_AcquisitionStop( m_pRefData->m_pDevice->hDrv() ); + } + /// \brief Creates a new \b mvIMPACT::acquire::ImageRequestControl object. + /** + * This function creates a new \b mvIMPACT::acquire::ImageRequestControl based on an existing one. New \b mvIMPACT::acquire::ImageRequestControl instances can only be derived + * from \b mvIMPACT::acquire::ImageRequestControl instances that already exist. When the driver has been initialized there will be at least + * one base \b mvIMPACT::acquire::ImageRequestControl called 'Base', which acts as the base for all other request controls. + * + * All \b mvIMPACT::acquire::ImageRequestControl constructed by the application must be derived either from this base or any of its children using this function. + * + * When this function succeeds, the \b mvIMPACT::acquire::ImageRequestControl constructor can be called with the \a name parameter passed to this function + * to get access to this newly registered \b mvIMPACT::acquire::ImageRequestControl. + * + * \note + * See all comments made under \b mvIMPACT::acquire::FunctionInterface::createSetting for understanding the relationship between base and + * derived \b mvIMPACT::acquire::ImageRequestControl objects. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int createImageRequestControl( + /// [in] The name of the new \b mvIMPACT::acquire::ImageRequestControl object. + const std::string& name, + /// [in] The name of the \b mvIMPACT::acquire::ImageRequestControl the new object shall be derived from. + const std::string& parent = "Base", + /// [out] A pointer to a \b mvIMPACT::acquire::ComponentList object that will receive the ID of the newly created request control. + /// This parameter can be 0 if the application is not interested in that parameter. + ComponentList* pNewRequestControl = 0 ) + { + HLIST newID; + int result = DMR_CreateRequestControl( m_pRefData->m_pDevice->hDrv(), name.c_str(), parent.c_str(), &newID, 0 ); + if( pNewRequestControl ) + { + *pNewRequestControl = ComponentList( newID ); + } + return result; + } + /// \brief Creates a new setting. + /** + * This function creates a new setting base on an existing one. New settings can only be derived + * from settings that already exist. When the driver has been initialized there will be at least + * one base setting called 'Base', which acts as the base for all other settings. + * + * When a new setting is created it derives all the properties from the parent setting. That means + * initially the new setting will contain the very same data as the parent setting. As long as a + * component hasn't been modified in the new setting it will depend on the parent settings data. + * That means if e.g. a property in the parent list is modified, the newly created setting will + * also benefit from the updated value. + * + * To release a certain component from this dependency it must be assigned a new value. The function + * \b mvIMPACT::acquire::Component::isDefault will return false afterwards indicating that the component no longer + * depends on the parent. + * + * To restore this parent <-> child dependency the user can call the function + * \b mvIMPACT::acquire::Component::restoreDefault. Afterwards settings applied to the parent component + * will also be visible in the child component again. + * + * When a new setting has been created successfully the name used to create the setting can + * be passed to any of the constructors of the setting related classes (\b mvIMPACT::acquire::CameraSettingsBase, + * \b mvIMPACT::acquire::ImageProcessing, ...) to access the new components. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int createSetting( + /// [in] The name of the setting to be created. + const std::string& name, + /// [in] The name of the setting to derive the new setting from. + const std::string& parent = "Base", + /// [out] A pointer to a \b mvIMPACT::acquire::ComponentList object that will receive the ID of the newly created setting. + /// This parameter can be 0 if the application is not interested in that parameter. + ComponentList* pNewSetting = 0 ) + { + HLIST newID = INVALID_ID; + int result = DMR_CreateSetting( m_pRefData->m_pDevice->hDrv(), name.c_str(), parent.c_str(), &newID ); + updateSettings(); + if( pNewSetting ) + { + if( newID == INVALID_ID ) + { + *pNewSetting = ComponentList(); + } + else + { + *pNewSetting = ComponentList( newID ); + } + } + return result; + } + /// \brief Deletes the last setting from the setting stack. + /** + * This function deletes the last setting from the setting stack. + * + * See mvIMPACT::acquire::FunctionInterface::saveCurrentSettingOnStack for an example how to use this feature. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::saveCurrentSettingOnStack \n + * \b mvIMPACT::acquire::FunctionInterface::loadSettingFromStack \n + * \b mvIMPACT::acquire::FunctionInterface::loadAndDeleteSettingFromStack \n + * + * \since 2.19.0 + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if the setting is available. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int deleteSettingFromStack( void ) + { + return m_pRefData->deleteSettingFromStack(); + } + /// \brief Deletes a setting from the specified location. + /** + * This function deletes a setting from the specified location. + * + * \since 2.19.0 + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if the setting is available. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int deleteSetting( + /// [in] The name or the full path under where the setting is located. + const std::string& name, + /// [in] The location of the setting. + TStorageLocation storageLocation = slNative, + /// [in] Specifies the scope of this operation. + TScope scope = sGlobal ) const + { + return DMR_DeleteSetting( name.c_str(), storageLocation, scope ); + } + /// \brief Returns the names of the settings available for this \b mvIMPACT::acquire::Device. + /** + * This function returns a const reference to a string array containing the names of all settings available + * for the current \b mvIMPACT::acquire::Device. These names are valid constructor parameters for objects + * like \b mvIMPACT::acquire::CameraSettingsBase, \b mvIMPACT::acquire::ImageProcessing, \b mvIMPACT::acquire::ImageDestination or + * classes derived from these types. + * + * New settings can be created by calling + * \b mvIMPACT::acquire::FunctionInterface::createSetting + * \return A const reference to an array containing the names of all request controls available. + */ + const std::vector& getAvailableSettings( void ) const + { + updateSettings(); + return m_pRefData->m_settings; + } + /// \brief Returns the names of the image request controls available for this \b mvIMPACT::acquire::Device. + /** + * This function returns a const reference to a string array containing the names of all image request controls available + * for the current \b mvIMPACT::acquire::Device. These names are valid constructor parameters for objects + * of the type \b mvIMPACT::acquire::ImageRequestControl. + * + * New image request controls can be created by calling \b mvIMPACT::acquire::FunctionInterface::createImageRequestControl. + * \return A const reference to an array containing the names of all settings available. + */ + const std::vector& getAvailableImageRequestControls( void ) const + { + updateImageRequestControls(); + return m_pRefData->m_imageRequestControls; + } + /// \brief Returns a pointer to the desired \b mvIMPACT::acquire::Request. + /** + * This function returns a pointer to the \b mvIMPACT::acquire::Request stored at \a nr + * in the internal array of requests. + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr refers to an invalid \b mvIMPACT::acquire::Request \n + * (e.g. when \a nr is higher than the actual number of \n + * available requests) a STL out_of_range exception will be thrown. + * \endif + * \return A pointer to a \b mvIMPACT::acquire::Request object. + */ + Request* getRequest( + /// [in] The number of the request to return + int nr ) const + { + updateRequests(); + Request* pRequest = m_pRefData->m_requests.at( nr ); + if( !pRequest->imageWidth.isValid() || pRequest->imageWidth.parent().parent().name() != pRequest->getName() ) + { + // This could happen because someone changed the request count back and forth to the same value as the + // last time 'getRequest' got called. In that case 'updateRequests' will do nothing and we need to update + // this object here! + delete m_pRefData->m_requests[nr]; + pRequest = createRequest( nr ); + m_pRefData->m_requests[nr] = pRequest; + } + return pRequest; + } + /// \brief Returns a \b mvIMPACT::acquire::ComponentList object to a setting with a specified name. + /** + * This function returns a \b mvIMPACT::acquire::ComponentList object to a setting with a specified name + * or will raise an exception if no such setting exists. + * + * \since 1.12.58 + * + * \return A \b mvIMPACT::acquire::ComponentList object to a setting with a specified name + */ + ComponentList getSetting( + /// [in] The name of the setting to locate + const std::string& name ) const + { + Component it( m_pRefData->m_settingsList ); + it = it.firstChild(); + while( it.isValid() ) + { + if( name == it.name() ) + { + return ComponentList( it ); + } + ++it; + } + std::ostringstream oss; + oss << MVIA_FUNCTION << " (line: " << __LINE__ << ")"; + throw EComponentNotFound( "Setting '" + name + "' could not be found", oss.str() ); + } + /// \brief Sets a request into configuration mode. + /** + * \note + * Another version of this function is available that might be nicer to use depending on personal + * preferences and use case: \b mvIMPACT::acquire::Request::configure. + * + * In configuration mode certain properties like \b mvIMPACT::acquire::Request::imageData, + * \b mvIMPACT::acquire::Request::imageSize, \b mvIMPACT::acquire::Request::imageMemoryMode + * of a request object can be modified. This can be used to configure one or more requests + * to use a user supplied memory. To use only a subset of the \b mvIMPACT::acquire::Request + * objects available the \b mvIMPACT::acquire::ImageRequestControl::requestToUse feature + * can be used. + * + * Only requests that are currently not used by the driver and are not locked + * because they contain image data that hasn't been processed can be set into + * configuration mode. + * + * \note + * Instead of calling this function directly for most cases it is much more convenient to use + * the functions \b mvIMPACT::acquire::Request::attachUserBuffer and \b mvIMPACT::acquire::Request::detachUserBuffer + * instead. + * + * User supplied buffers must follow the alignment and size requirements reported by versions of the + * function \b mvIMPACT::acquire::FunctionInterface::getCurrentCaptureBufferLayout. Calling + * a version of this function will return all the information required to allocate buffers that + * can be used to capture data for the specified settings. + * + * When allocating memory on the heap, the complete buffer size is needed which is calculated like + * this: + * + * \b size + alignment + * + * \note + * The address passed to the request object must be aligned already! + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * Device* pDev = getDevicePointerFromSomewhere() + * FunctionInterface fi( pDev ); + * ImageRequestControl irc( pDev ); + * int bufferSize = 0; + * int bufferAlignment = 0; + * const TDMR_ERROR result = static_cast( fi.getCurrentCaptureBufferLayout( irc, bufferSize, bufferAlignment ) ); + * Request* pRequest = fi.getRequest( 0 ); + * // the buffer assigned to the request object must be aligned accordingly + * // the size of the user supplied buffer MUST NOT include the additional size + * // caused by the alignment + * if( pRequest->attachUserBuffer( getAlignedMemoryPtr( bufferSize, bufferAlignment ), bufferSize ) == DMR_NO_ERROR ) + * { + * irc.requestToUse.write( 0 ); // use the buffer just configured for the next image request + * // now the next image will be captured into the user supplied memory + * fi.imageRequestSingle( &irc ); // this will send request '0' to the driver + * // wait for the buffer. Once it has been returned by the driver AND the user buffer shall no + * // longer be used call + * if( pRequest->detachUserBuffer() != DMR_NO_ERROR ) + * { + * // handle error + * } + * // now this request will use internal memory again. + * } + * else + * { + * // handle error + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \warning There is currently no way to deal with alignment in Java when capturing into user supplied(thus managed) memory! Suggestions welcome! + * + * \code + * import java.nio.ByteBuffer; + * + * // ... + * + * Device pDev = getDevicePointerFromSomewhere() + * FunctionInterface fi = new FunctionInterface( pDev ); + * ImageRequestControl irc = new ImageRequestControl( pDev ); + * int[] bufferSize = {0}; + * int[] bufferAlignment = {0}; + * if( fi.getCurrentCaptureBufferLayout( irc, bufferSize, bufferAlignment ) == TDMR_ERROR.DMR_NO_ERROR ) + * { + * Request pRequest = fi.getRequest( 0 ); + * // the buffer assigned to the request object must be aligned accordingly + * // the size of the user supplied buffer MUST NOT include the additional size + * // caused by the alignment + * ByteBuffer pBuffer = ByteBuffer.allocateDirect( bufferSize[0] + bufferAlignment[0] ); // todo: There is currently no way to deal with alignment in Java! Suggestions welcome! + * if( pRequest.attachUserBuffer( pBuffer ) == TDMR_ERROR.DMR_NO_ERROR ) + * { + * irc.getRequestToUse().write( 0 ); // use the buffer just configured for the next image request + * // now the next image will be captured into the user supplied memory + * fi.imageRequestSingle( irc ); // this will send request '0' to the driver + * // wait for the buffer. Once it has been returned by the driver AND the user buffer shall no + * // longer be used call + * if( pRequest.detachUserBuffer() != TDMR_ERROR.DMR_NO_ERROR ) + * { + * // handle error + * } + * // now this request will use internal memory again. + * } + * else + * { + * // handle error + * } + * } + * else + * { + * // handle error + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * pDev = getDevicePointerFromSomewhere() + * fi = acquire.FunctionInterface(pDev) + * irc = acquire.ImageRequestControl(pDev) + * # this function returns a list containing [result, size, alignment] + * results = fi.getCurrentCaptureBufferLayout(irc) + * if results[0] == int(acquire.DMR_NO_ERROR): + * pRequest = fi.getRequest(0) + * # the buffer assigned to the request object must be aligned accordingly + * # the size of the user supplied buffer MUST NOT include the additional size + * # caused by the alignment + * if pRequest.attachUserBuffer(getAlignedMemoryPtr(results[1], results[2] ), results[2]) == int(acquire.DMR_NO_ERROR): + * irc.requestToUse.write(0) # use the buffer just configured for the next image request + * # now the next image will be captured into the user supplied memory + * fi.imageRequestSingle(irc) # this will send request '0' to the driver + * # wait for the buffer. Once it has been returned by the driver AND the user buffer shall no + * # longer be used call + * if pRequest.detachUserBuffer() != TDMR_ERROR.DMR_NO_ERROR: + * # handle error + * # now this request will use internal memory again. + * else: + * # handle error + * else: + * # handle error + * \endcode + * \endif + * \note + * A request that is in configuration mode can't be sent to the driver for acquisition until + * \b mvIMPACT::acquire::Request::unlock or \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock has been called again. + * By using \b mvIMPACT::acquire::Request::attachUserBuffer and \b mvIMPACT::acquire::Request::detachUserBuffer this locking + * and unlocking is done internally thus the application does not need to worry about this. + * + * \sa + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle, \n + * \b mvIMPACT::acquire::Request::attachUserBuffer, \n + * \b mvIMPACT::acquire::Request::detachUserBuffer, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestReset + * + * \since 1.10.31 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int imageRequestConfigure( + /// [in] A const pointer to the request object to configure + const Request* pRequest ) const + { + return DMR_ImageRequestConfigure( m_pRefData->m_pDevice->hDrv(), pRequest->getNumber(), 0, 0 ); + } + /// \brief Returns the number of \b mvIMPACT::acquire::Request objects in the result queue . + /** + * This functions queries the number of \b mvIMPACT::acquire::Request objects currently in the result queue that are available for pickup. This number reflects the number of + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor calls that could be executed afterwards the would return with a valid \b mvIMPACT::acquire::Request + * object immediately without waiting! + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStart, \n + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStop, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestReset, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestResultQueueElementCount, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure + * + * \since 2.9.0 + * + * \return + * - The number of \b mvIMPACT::acquire::Request objects in the result queue if successful. + * - \b mvIMPACT::acquire::DMR_INVALID_QUEUE_SELECTION if the selected result queue does not exist. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int imageRequestResultQueueElementCount( + /// [in] The result queue to be queried. + int queueNr = 0 ) const + { + int resultQueueElements; + TDMR_ERROR result = DMR_ImageRequestResultQueueElementCount( m_pRefData->m_pDevice->hDrv(), queueNr, &resultQueueElements ); + return ( result != DMR_NO_ERROR ) ? static_cast( result ) : resultQueueElements; + } + /// \brief Deletes all requests currently queued for the specified \b mvIMPACT::acquire::ImageRequestControl. + /** + * This function will terminate all running image acquisitions associated with the queue + * bound to the specified image request control and in addition to that + * will empty the queue of pending image requests for that queue. Also all requests that reside in the + * result queue and have not been picked up by the application will be unlocked and removed from the + * result queue. So after this function returns only the requests currently in possession of the + * application (so requests that have been picked up by successful calls to \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor + * that have \b NOT been unlocked) need to be handled. All other requests are in a state where they + * can be queued for an acquisition again. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor, \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int imageRequestReset( + /// [in] The \b mvIMPACT::acquire::ImageRequestControl for which all + /// the requests shall be cancelled. + int requestCtrlNr, + /// [in] Currently unsupported. MUST be set 0. + int mode ) const + { + return DMR_ImageRequestReset( m_pRefData->m_pDevice->hDrv(), requestCtrlNr, mode ); + } +#ifndef WRAP_ANY + /// \brief Sends an image request to the \b mvIMPACT::acquire::Device driver. + /** + * This functions sends a single image request to the capture device. To wait for the image + * to become ready call the function + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor. + * + * \attention + * In order to make sure that no image data is lost, it is important to understand how + * the request mechanism works. The driver works with a fixed number of \b mvIMPACT::acquire::Request + * objects. The number of \b mvIMPACT::acquire::Request objects available to the driver can be set + * by modifying the property \b mvIMPACT::acquire::SystemSettings::requestCount. Each \b mvIMPACT::acquire::Request will + * consume a certain amount of memory. Once an image has been captured by the \b mvIMPACT::acquire::Request, + * this amount will be slightly more than the image itself needs in memory, so modify this + * parameter gently. On the other hand, it's necessary to have more than a single request + * in order to ensure a lossless acquisition. E.g. when working with free running cameras an + * image might be lost because while an image has been captured and is being processed, the next + * vertical sync. pulse is already missed before the \b mvIMPACT::acquire::Request is unlocked again. + * + * \note + * When \b mvIMPACT::acquire::Device::acquisitionStartStopBehaviour is + * set to \b mvIMPACT::acquire::assbUser several calls to \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle + * will \b NOT start the data acquisition! After requests have been send down to the driver, + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStart must be called. For performance reasons some device drivers + * will \b NOT allow to request data into buffers which have not been known to the driver when \b mvIMPACT::acquire::FunctionInterface::acquisitionStart + * was called, thus before starting the acquisition, \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle + * should be called as many times as there are request objects. + * \sa + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStart, \n + * \b mvIMPACT::acquire::FunctionInterface::acquisitionStop, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestReset, \n + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestResultQueueElementCount, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestWaitFor, \n + * \b mvIMPACT::acquire::Request::configure, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestConfigure + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - \b mvIMPACT::acquire::DEV_NO_FREE_REQUEST_AVAILABLE if all mvIMPACT::acquire::Request objects are currently in use (either owned by the user or queued for acquisition). + * - \b mvIMPACT::acquire::DEV_INVALID_REQUEST_NUMBER if the request number defined by the property \b ImageRequestControl::requestToUse is invalid (out of bounds). + * - \b mvIMPACT::acquire::DEV_REQUEST_ALREADY_IN_USE if the request number defined by the property \b ImageRequestControl::requestToUse is already in use (either owned by the user or queued for acquisition). + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int imageRequestSingle( + /// [in] A pointer to the \b mvIMPACT::acquire::ImageRequestControl object + /// to be used for this request. \b mvIMPACT::acquire::ImageRequestControl + /// objects define (among other things), which setting will + /// be used for this image acquisition (via the property + /// \b mvIMPACT::acquire::ImageRequestControl::setting). + ImageRequestControl* pImageRequestControl = 0, + /// [out] If a valid pointer to an integer is passed here, this + /// variable receives the number of the \b mvIMPACT::acquire::Request which + /// will be used to process this request. + int* pRequestUsed = 0 ) const + { + return DMR_ImageRequestSingle( m_pRefData->m_pDevice->hDrv(), pImageRequestControl ? pImageRequestControl->hObj() & 0xFFFF : 0, pRequestUsed ); + } +#endif // #ifndef WRAP_ANY + /// \brief Unlocks the request for the driver again. + /** + * \note + * Another version of this function is available that might be nicer to use depending on personal + * preferences and use case: \b mvIMPACT::acquire::Request::unlock. Unlocking a certain request + * might be nicer by using this function, e.g. unlocking \b ALL requests in a loop is probably easier + * done by writing + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * Device* pDev = getDevicePointerFromSomewhere() + * FunctionInterface fi( pDev ); + * const int rc = static_cast< int >( fi.requestCount() ); + * for( int i=0; im_pDevice->hDrv(), nr ); + } + /// \brief Waits for a request object to become ready. + /** + * This function waits for a request object previously sent to the capture device by calling + * \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle. When a new request became ready during + * the period of time specified by the \a timeout_ms parameter this request is extracted from the + * result queue and is returned to the user so the same request can not be returned twice until + * it has been processed and unlocked by the application. + * + * \note Whenever a \b mvIMPACT::acquire::Request is returned to the user the image data + * described by the \b mvIMPACT::acquire::Request remains valid until the user unlocks + * the image buffer again or the driver is closed. + * + * \sa + * \b mvIMPACT::acquire::Request::unlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestUnlock, \n + * \b mvIMPACT::acquire::FunctionInterface::imageRequestResultQueueElementCount, \n + * \b mvIMPACT::acquire::FunctionInterface::getRequest + * \return If the return value is positive, the return value is the request number of the + * image request in the interface's internal array of image requests. In this case the user + * can call \b mvIMPACT::acquire::FunctionInterface::getRequest to get access to the + * results. \n \n If the result is negative, the return value is an error code. + * The error code that is returned in most cases will be \b mvIMPACT::acquire::DEV_WAIT_FOR_REQUEST_FAILED. + * To find out possible reasons for this error, look at the corresponding explanation. + */ + int imageRequestWaitFor( + /// [in] The maximum wait time in milliseconds (ms) for + /// this request to become ready. If \a timeout_ms + /// is '-1', the function's timeout interval never + /// elapses. If the result queue specified by the \a queueNr parameter already contains + /// a request when calling this function the function will return immediately. Please note + /// that each request has its own timeout that is independent from + /// this wait timeout, thus this function will return with a valid request after the timeout + /// for this request has elapsed even if e.g. a trigger has not been detected. For detailed + /// information on the interaction of the timeout of this function and the timeout of a + /// request please refer to the chapter \ref ImageAcquisition_capture_AcquiringData in the C++ section. + int timeout_ms, + /// [in] The queue where to wait for the request. + /// The number of request queues available depends on the number of video channels offered by the + /// device. The queue a processed request ends up in can be defined by setting the property + /// \b mvIMPACT::acquire::ImageRequestControl::resultQueue \b BEFORE calling \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle. + int queueNr = 0 ) const + { + int requestNr; + TDMR_ERROR result = DMR_ImageRequestWaitFor( m_pRefData->m_pDevice->hDrv(), timeout_ms, queueNr, &requestNr ); + return ( result != DMR_NO_ERROR ) ? static_cast( result ) : requestNr; + } +#ifndef WRAP_ANY + /// \brief Returns information about the current capture buffer requirements. + /** + * When an application wants to provide capture buffers, this function will be needed in order to + * get information on how the capture buffers must be constructed. The most important parameters + * will probably be \a alignment and \a size, thus for most application calling the other overload + * of this function will probably be enough. + * + * To find out more about capturing to user memory please refer to the application + * \ref CaptureToUserMemory.cpp + * + * \sa mvIMPACT::acquire::Request::configure + * + * \since 1.12.68 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int getCurrentCaptureBufferLayout( + /// [in] A reference to the \b mvIMPACT::acquire::ImageRequestControl object + /// containing the setting for which the current capture buffer layout shall + /// be queried. The setting can be defined via the property + /// \b mvIMPACT::acquire::ImageRequestControl::setting. + ImageRequestControl& imageRequestControl, + /// [out] On a successful call this variable will receive a pointer to a + /// \b mvIMPACT::acquire::Request object reflecting the current + /// capture buffer layout. + Request** ppRequest = 0, + /// [out] On a successful call this variable will receive the alignment + /// needed for capturing into user supplied buffers that use the + /// current settings. + int* pAlignment = 0 ) const + { + int result = DMR_NO_ERROR; + if( ppRequest ) + { + if( !m_pRefData->m_pCurrentCaptureBufferLayout ) + { + // This feature is available for every driver, but could not be detected thus an + // update might be required. + return DMR_NEWER_LIBRARY_REQUIRED; + } + const TImageRequestControlMode previousMode( static_cast( imageRequestControl.mode.read() ) ); + if( previousMode != ircmUpdateBufferLayout ) + { + imageRequestControl.mode.write( ircmUpdateBufferLayout ); + } + result = imageRequestSingle( &imageRequestControl ); + if( previousMode != ircmUpdateBufferLayout ) + { + imageRequestControl.mode.write( previousMode ); + } + *ppRequest = m_pRefData->m_pCurrentCaptureBufferLayout; + } + if( pAlignment ) + { + *pAlignment = m_pRefData->m_captureBufferAlignment.read(); + } + return result; + } +#endif // #ifndef WRAP_ANY + /// \brief Returns information about the current capture buffer requirements. + /** + * When an application wants to provide capture buffers, this function will be needed in order to + * get information on how the capture buffers must be constructed. + * + * To find out more about capturing to user memory please refer to the application + * \ref CaptureToUserMemory.cpp + * + * \sa + * \b mvIMPACT::acquire::Request::configure + * + * \since 1.12.68 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int getCurrentCaptureBufferLayout( + /// [in] A reference to the \b mvIMPACT::acquire::ImageRequestControl object + /// containing the setting for which the current capture buffer layout shall + /// be queried. The setting can be defined via the property + /// \b mvIMPACT::acquire::ImageRequestControl::setting. + ImageRequestControl& imageRequestControl, + /// [out] On a successful call this variable will receive the size + /// needed for capturing into user supplied buffers that use the + /// current settings. + int& size, + /// [out] On a successful call this variable will receive the alignment + /// needed for capturing into user supplied buffers that use the + /// current settings. + int& alignment ) const + { + Request* pRequest = 0; + size = 0; + const int result = getCurrentCaptureBufferLayout( imageRequestControl, &pRequest, &alignment ); + if( m_pRefData->m_pCurrentCaptureBufferLayout ) + { + size = m_pRefData->m_pCurrentCaptureBufferLayout->imageSize.read() + m_pRefData->m_pCurrentCaptureBufferLayout->imageFooterSize.read(); + } + return result; + } + /// \brief Check if \a nr specifies a valid \b mvIMPACT::acquire::Request. + /** + * \return \n + * - true if \a nr specifies a valid request. + * - false otherwise + */ + bool isRequestNrValid( int nr ) const + { + if( nr < 0 ) + { + return false; + } + + if( nr >= static_cast( m_pRefData->m_requests.size() ) ) + { + updateRequests(); + } + + return nr < static_cast( m_pRefData->m_requests.size() ); + } + /// \brief Checks if a certain setting is available under the specified location. + /** + * This function checks if a certain setting is available under the specified location. + * + * \since 2.19.0 + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if the setting is available. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int isSettingAvailable( + /// [in] The name or the full path under where the setting is located. + const std::string& name, + /// [in] The location of the setting. + TStorageLocation storageLocation = slNative, + /// [in] Specifies the scope of this operation. + TScope scope = sGlobal ) const + { + return DMR_IsSettingAvailable( name.c_str(), storageLocation, scope ); + } + /// \brief Loads a previously stored setting. + /** + * This function can be used to restore a previously stored setting again. + * + * To load a setting from a file the \b mvIMPACT::acquire::sfFile should be specified + * as part of \a storageFlags. To load a setting from a platform specific location + * such as the Registry under Windows© \b mvIMPACT::acquire::sfNative should be + * specified. It's not allowed to combine \b mvIMPACT::acquire::sfFile and + * \b mvIMPACT::acquire::sfNative for this operation. + * + * \warning Since mvIMPACT Acquire 2.9.0 GenICam devices will be able to save their properties in a XML File, only if the properties have the \b streamable attribute set (for more information refer to the GenICam standard specification). Properties with no \b streamable attribute set, will be silently ignored when saving, which means they will \b not be saved in the XML file. For MATRIX VISION GenICam cameras, starting with firmware version 1.6.414 the \b streamable attribute is set for all the necessary properties. + * + *
+ * + * \warning Since mvIMPACT Acquire 2.9.0 and again in version 2.11.0 storing and loading of camera settings in a XML file for the \b mvIMPACT::acquire::dilGenICam + * interface layout has been updated. As a result XML files created with newer versions of mvIMPACT Acquire might \b not + * be readable on systems with older version of mvIMPACT Acquire installed. XML files created on systems + * with earlier versions of mvIMPACT Acquire will always be readable this or newer versions. See the following table for details. + * + *
%mvIMPACT Acquire VersionLoading a XML settings file created with %mvIMPACT Acquire version < 2.9.0Loading a XML settings file created with %mvIMPACT Acquire version 2.9.0 - 2.10.1Loading a XML settings file created with %mvIMPACT Acquire version 2.11.0 or later + *
< 2.9.0 YES NO NO + *
2.9.0 - 2.10.1 YES YES NO + *
>= 2.11.0 YES YES YES + *
+ * + * \attention Since mvIMPACT Acquire 2.28.0 it is possible for devices operated in the \b ::dilGenICam interface layout to store settings including + * sequencer sets and user sets (see SFNC for details) data by specifying the \b ::sfProcessGenICamSequencerData and/or \b ::sfProcessGenICamUserSetData + * during the storage operation. Settings stored like this cannot be loaded by previous mvIMPACT Acquire versions. + * + * \note For devices operated in the \b mvIMPACT::acquire::dilGenICam interface layout further restriction apply: Settings created with a certain product type can only + * be used with other devices belonging to the exact same type as defined by the property mvIMPACT::acquire::Device::product inside the device list (the one device specific property list that + * is accessible without initialising the device before). Even if a setting can be used with various firmware versions it is recommended to use one setting + * for multiple devices all updated to the very same firmware version to avoid compatibility problems. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::saveSetting. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int loadSetting( + /// [in] The name or the full path under where the setting is located. + const std::string& name, + /// [in] The flags which define which information shall be read from the location + /// and how this information shall be interpreted. + TStorageFlag storageFlags = sfNative, + /// [in] Specifies where the information is located. + TScope scope = sGlobal ) const + { + return DMR_LoadSetting( m_pRefData->m_pDevice->hDrv(), name.c_str(), storageFlags, scope ); + } + /// \brief loads the last setting from the setting stack. + /** + * This function loads the last setting from the setting stack. + * + * See mvIMPACT::acquire::FunctionInterface::saveCurrentSettingOnStack for an example how to use this feature. + * + * See also mvIMPACT::acquire::FunctionInterface::loadSetting to find out which features of a GenICam device + * are stored in a setting and which are not! + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::saveCurrentSettingOnStack \n + * \b mvIMPACT::acquire::FunctionInterface::deleteSettingFromStack \n + * \b mvIMPACT::acquire::FunctionInterface::loadAndDeleteSettingFromStack \n + * + * \since 2.19.0 + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if the setting is available. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int loadSettingFromStack( void ) + { + if( m_pRefData->m_settingsInRAM.empty() ) + { + return PROPHANDLING_LIST_CANT_ACCESS_DATA; + } + return DMR_LoadSetting( m_pRefData->m_pDevice->hDrv(), m_pRefData->m_settingsInRAM.top().c_str(), sfRAM, sUser ); + } + /// \brief loads the last setting from the setting stack and then removes this setting from the stack. + /** + * This function loads the last setting from the setting stack and then removes this setting from the stack. + * + * See mvIMPACT::acquire::FunctionInterface::saveCurrentSettingOnStack for an example how to use this feature. + * + * See also mvIMPACT::acquire::FunctionInterface::loadSetting to find out which features of a GenICam device + * are stored in a setting and which are not! + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::saveCurrentSettingOnStack \n + * \b mvIMPACT::acquire::FunctionInterface::deleteSettingFromStack \n + * \b mvIMPACT::acquire::FunctionInterface::loadSettingFromStack \n + * + * \since 2.19.0 + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if the setting is available. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int loadAndDeleteSettingFromStack( void ) + { + int result = loadSettingFromStack(); + if( result == DMR_NO_ERROR ) + { + result = deleteSettingFromStack(); + } + return result; + } + /// \brief Loads the default settings. + /** + * This function will try to load the settings from a default location. This function + * can only succeed if a setting has been stored previously by a call to + * \b mvIMPACT::acquire::FunctionInterface::saveSettingToDefault. + * + * \warning There has been an incompatible change when loading settings in version 2.9.0 and 2.11.0 of mvIMPACT Acquire as well as in version 2.28.0. See mvIMPACT::acquire::FunctionInterface::loadSetting for details. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int loadSettingFromDefault( + /// [in] Specifies where the information is located. + TScope scope = sUser ) const + { + return DMR_LoadSettingFromDefault( m_pRefData->m_pDevice->hDrv(), scope ); + } + /// \brief Returns the number of available request objects. + /** + * \sa + * \b mvIMPACT::acquire::SystemSettings::requestCount to change the number of request objects + * + * \return Returns the number of available request objects. + */ + unsigned int requestCount( void ) const + { + updateRequests(); + return static_cast( m_pRefData->m_requests.size() ); + } + /// \brief Saves the current setting on the setting stack. + /** + * This function saves the current setting on the setting stack. Together which the + * functions mentioned below this implements a stack for capture settings. This can + * become handy when entering a section of code that might modify the current capture settings + * in various ways and depending on the result these modifications shall either be kept or + * discarded at the end of the operation. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // ... + * enum TResult + * { + * rApply, + * rDiscard + * }; + * // ... + * FunctionInterface& fi = getFunctionInterfaceFromSomewhere(); + * fi.saveCurrentSettingOnStack(); + * switch( enterSectionThatModifiesDeviceSettings() ) + * { + * case rDiscard: + * fi.loadAndDeleteSettingFromStack(); // revert all changes just applied without worrying about what these changes actually are + * break; + * case rApply: + * fi.deleteSettingFromStack(); // remove the setting from the stack, but keep changes + * break; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // ... + * final int Apply = 1; + * final int Discard = 2; + * // ... + * FunctionInterface fi = getFunctionInterfaceFromSomewhere(); + * fi.saveCurrentSettingOnStack(); + * final int option = enterSectionThatModifiesDeviceSettings(); + * if( option == Discard ) + * { + * fi.loadAndDeleteSettingFromStack(); // revert all changes just applied without worrying about what these changes actually are + * } + * else if( option == Apply ) + * { + * fi.deleteSettingFromStack(); // remove the setting from the stack, but keep changes + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * DISCARD_SETTING = 1 + * APPLY_SETTING = 2 + * fi = getFunctionInterfaceFromSomewhere() + * fi.saveCurrentSettingOnStack() + * option = enterSectionThatModifiesDeviceSettings() + * if option == DISCARD_SETTING: # discard + * fi.loadAndDeleteSettingFromStack() # revert all changes just applied without worrying about what these changes actually are + * elif option == APPLY_SETTING: # apply + * fi.deleteSettingFromStack() # remove the setting from the stack, but keep changes + * \endif + * + * The stack makes use of mvIMPACT Acquires ability to store capture settings in the memory of + * the current process. Once the last instance of this mvIMPACT::acquire::FunctionInterface + * object is deleted all settings pushed on this stack will be deleted automatically. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::deleteSettingFromStack \n + * \b mvIMPACT::acquire::FunctionInterface::loadSettingFromStack \n + * \b mvIMPACT::acquire::FunctionInterface::loadAndDeleteSettingFromStack \n + * + * \since 2.19.0 + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if the setting is available. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int saveCurrentSettingOnStack( + /// [in] The flags which define which information shall be stored and how this + /// information shall be stored. + TStorageFlag storageFlags = sfRAM ) + { + return m_pRefData->saveCurrentSettingOnStack( storageFlags ); + } + /// \brief Stores the current settings. + /** + * This function can be used to store the current settings either in a XML-file or + * (under Windows©) into the Registry. A setting contains all the values set + * for properties that control the overall way an image is acquired( e.g. the exposure time, etc.). + * + * To store a setting in a file the \b mvIMPACT::acquire::sfFile should be specified + * as part of \a storageFlags. To store a setting in a platform specific location + * such as the Registry under Windows© \b mvIMPACT::acquire::sfNative should be + * specified. Both flags can be combined. In that case the same setting will be stored in a + * file \b AND in a platform specific location if these location differ (platform dependent!). + * + * \warning There has been an incompatible change when loading settings in version 2.9.0 and 2.11.0 of mvIMPACT Acquire as well as in version 2.28.0. See mvIMPACT::acquire::FunctionInterface::loadSetting for details. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int saveSetting( + /// [in] The name or the full path under which this setting shall be stored + const std::string& name, + /// [in] The flags which define which information shall be stored and how this + /// information shall be stored. + TStorageFlag storageFlags = sfNative, + /// [in] Specifies where the information shall be stored. + TScope scope = sGlobal ) const + { + return DMR_SaveSetting( m_pRefData->m_pDevice->hDrv(), name.c_str(), storageFlags, scope ); + } + /// \brief Stores the current settings under a default location. + /** + * Under Windows© this will be in the Registry. A setting contains all the values set + * for properties that control the overall way an image is acquired( e.g. the exposure time, etc.). + * + * \warning There has been an incompatible change when loading settings in version 2.9.0 and 2.11.0 of mvIMPACT Acquire as well as in version 2.28.0. See mvIMPACT::acquire::FunctionInterface::loadSetting for details. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int saveSettingToDefault( + /// [in] Specifies where the information shall be stored. + TScope scope = sUser ) const + { + return DMR_SaveSettingToDefault( m_pRefData->m_pDevice->hDrv(), scope ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to access various general information about the device and its driver. +/** + * This class contains a collection of properties providing various information about + * the device and its driver. + * + * Instances of this class can't be constructed directly. Use one of the derived types. + */ +class Info : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::Info object. + explicit Info( /// A pointer to a \b mvIMPACT::acquire::Device object obtained from + /// a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : ComponentCollection( pDev ), deviceDriverVersion(), driverDate(), + driverVersion(), state(), loadedSettings(), logFile(), captureBufferAlignment(), + recommendedListsForUIs() + { + DeviceComponentLocator locator( pDev, dltInfo ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( deviceDriverVersion, "DeviceDriverVersion" ); + locator.bindComponent( driverDate, "DriverDate" ); + locator.bindComponent( driverVersion, "DriverVersion" ); + locator.bindComponent( state, "State" ); + locator.bindComponent( loadedSettings, "LoadedSettings" ); + locator.bindComponent( logFile, "LogFile" ); + locator.bindComponent( captureBufferAlignment, "CaptureBufferAlignment" ); + locator.bindComponent( recommendedListsForUIs, "RecommendedListsForUIs" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property \b (read-only) containing the device driver version used by this device. + /** + * This is the version of the underlying hardware driver. For device drivers that don't have another + * user mode driver below the interface driver this property will contain the same version information + * as the property \b mvIMPACT::acquire::Info::driverVersion. + */ + PropertyS deviceDriverVersion; + /// \brief A string property \b (read-only) containing the date the device driver has been compiled. + PropertyS driverDate; + /// \brief A string property \b (read-only) containing the version number of the device driver. + PropertyS driverVersion; + /// \brief An enumerated integer property \b (read-only) containing the current state of this device. + /** + * This property e.g. provides information about the current state of the device. For USB devices this can e.g. indicate whether + * a device is currently plugged into the system or not. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceState. + * + * \b GenICam/GenTL \b device \b specific: + * In order to reduce the amount of network traffic to a minimum, this property will only be updated automatically + * for network devices if the property \b mvIMPACT::acquire::Device::registerErrorEvent is set to + * \b mvIMPACT::acquire::bTrue (which is the default behaviour). If the IP addresses stay the same the + * connection is automatically re-established then once the device is detected by the driver again. + * However if the IP address of the device and/or the network adapter of the system it is used from changes + * \b mvIMPACT::acquire::DeviceManager::updateDeviceList() + * must be called regardless of the value of \b mvIMPACT::acquire::Device::registerErrorEvent before a device + * that was lost can re-establish a connection to the capture driver. + */ + PropertyIDeviceState state; + /// \brief A string property \b (read-only) containing the name of the setting currently loaded. + PropertyS loadedSettings; + /// \brief A string property \b (read-only) containing the name and the full path of the current log-file for this device. + PropertyS logFile; + /// \brief An integer property \b (read-only) containing the capture buffer alignment in bytes needed by this device driver. + PropertyI captureBufferAlignment; + /// \brief A string property \b (read-only) containing an array of full search paths to lists which are recommended to be displayed in a user interface that is created dynamically. + PropertyS recommendedListsForUIs; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +#ifndef WRAP_ANY +/// \brief \b deprecated. Use the class \b mvIMPACT::acquire::Info instead. +/** + * \deprecated + * This class has been declared \b deprecated and might not be available in future releases. + * All features of this class are available in \b mvIMPACT::acquire::Info as well, so please use + * this class instead. + */ +typedef Info MVIMPACT_DEPRECATED_CPP( InfoBase ); +#endif // #ifndef WRAP_ANY + +//----------------------------------------------------------------------------- +/// \brief A base class for essential device related settings. +/** + * This class acts as a base class for essential device related settings. It only contains + * features that are available for every device. + * + * \since 1.12.58 + * + */ +class BasicDeviceSettings : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::BasicDeviceSettings object. + explicit BasicDeviceSettings( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : ComponentCollection( pDev ), basedOn(), imageRequestTimeout_ms() + { + DeviceComponentLocator locator( pDev, dltSetting, settingName ); + locator.bindComponent( basedOn, "BasedOn" ); + locator.bindSearchBase( locator.searchbase_id(), "Camera" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( imageRequestTimeout_ms, "ImageRequestTimeout_ms" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property \b (read-only) containing the name of the setting this setting is based on. + /** + * \since 1.12.67 + */ + PropertyS basedOn; + /// \brief An integer property defining the maximum time to wait for an image in ms. + /** + * When this property is set to 0 the timeout never elapses. If the timeout this property + * defines elapses the currently processed request will be returned to the user even if no data + * has been captured so far. The result structure of the request object should be examined in that + * case. Also this should be considered as an error from the users point of view in which case he + * should clean up the acquisition queue by calling \b mvIMPACT::acquire::FunctionInterface::imageRequestReset. + * Afterwards the capture loop can be restarted. + * + * \note + * It is crucial to understand that this is a timeout PER REQUEST! The timespan taken into account for the measurement + * starts when the driver begins to capture data into this particular buffer! So when queuing 4 buffers with a timeout of 3000 + * ms each and no data being transmitted by the device for any reason will cause the last buffer to time out 3000*4 = 12000 ms AFTER + * the buffer has been queued and the acquisition has been started as the driver will wait for up to 3 seconds for each buffer that is + * being processed. When the device sends data this timeout does not affect the runtime behaviour at all. No additional delay is introduced + * by it when everything runs as planned. + */ + PropertyI imageRequestTimeout_ms; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class to configure the behaviour of trigger signals. +/** + * Features in this class will open up a more flexible way to configure certain + * trigger events for devices then the previous features('triggerInterface', + * 'triggerSource' and 'triggerMode' used. + * + * \note + * Not ever device will support every property listed in this class for every trigger + * mode. Always call \b mvIMPACT::acquire::Component::isValid to check whether + * a feature is available or not before using it. Otherwise an exception will + * be generated. + */ +class TriggerControl : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class CameraSettingsBlueCOUGAR; + friend class CameraSettingsFrameGrabber; + Method m_triggerSoftware; + explicit TriggerControl( HLIST hList ) : ComponentCollection( hList ), m_triggerSoftware() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( m_triggerSoftware, "TriggerSoftware@i" ); + locator.bindComponent( triggerMode, "TriggerMode" ); + locator.bindComponent( triggerSource, "TriggerSource" ); + locator.bindComponent( triggerActivation, "TriggerActivation" ); + locator.bindComponent( triggerDivider, "TriggerDivider" ); + // unfortunately there are a couple of different names around... + locator.bindComponent( triggerDelayAbs_us, "TriggerDelayAbs_us" ); + if( !triggerDelayAbs_us.isValid() ) + { + locator.bindComponent( triggerDelayAbs_us, "TriggerDelayAbs" ); + if( !triggerDelayAbs_us.isValid() ) + { + locator.bindComponent( triggerDelayAbs_us, "TriggerDelay" ); + } + } + locator.bindComponent( triggerDelayLines, "TriggerDelayLines" ); + locator.bindComponent( triggerOverlap, "TriggerOverlap" ); + } +public: + /// \brief Returns a name of the trigger being configured. + std::string getDescription( void ) const + { + return ComponentList( m_hRoot ).name(); + } + /// \brief Generates of software trigger command. + /** + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int triggerSoftware( void ) const + { + if( !m_triggerSoftware.isValid() ) + { + return DMR_FEATURE_NOT_AVAILABLE; + } + return m_triggerSoftware.call(); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief Defines if the selected trigger is active. + PropertyI64 triggerMode; + /// \brief Defines the signal that will cause the trigger event. + /** + * Currently this property will define a translation dictionary that can e.g. be queried via a call to + * \b mvIMPACT::acquire::PropertyI64::getTranslationDict. The resulting translation dictionary can be used + * to select the desired trigger source either via a string or the associated 64 bit integer value. + */ + PropertyI64 triggerSource; + /// \brief An enumerated 64 bit integer property that defines the start condition for the selected trigger. + /** + * Valid value will be 'RisingEdge', 'FallingEdge', 'AnyEdge', 'LevelLow' or 'LevelHigh'. + */ + PropertyI64 triggerActivation; + /// \brief An integer property used to divide the number of incoming trigger pulses by an integer factor. + /** + * E.g. setting this value to 2 would generate 5 internal trigger events from a 10 Hz external signal. + */ + PropertyI triggerDivider; + /// \brief Specifies the absolute delay in microseconds (us) to apply after the trigger reception before + /// effectively activating it. + PropertyF triggerDelayAbs_us; + /// \brief Specifies the absolute delay in lines to apply after the trigger reception before effectively activating it. + PropertyI triggerDelayLines; + /// \brief Specifies the type trigger overlap permitted with the previous frame. + /// + /** This defines when a valid trigger will be accepted (or latched) for a new frame. + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceTriggerOverlap. + */ + PropertyI64DeviceTriggerOverlap triggerOverlap; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Properties to define the format of resulting images. +/** + * This class provides properties allowing the user to define how the resulting + * image should be created. Things like the width and height of the captured image + * can be defined here for example. + */ +class ImageDestination : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::ImageDestination object. + explicit ImageDestination( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : ComponentCollection( pDev ), pixelFormat(), + scalerMode(), scalerInterpolationMode(), scalerAoiEnable(), scalerAoiHeight(), scalerAoiStartX(), + scalerAoiStartY(), scalerAoiWidth(), imageWidth(), imageHeight() + { + DeviceComponentLocator locator( pDev, dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "ImageDestination" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( pixelFormat, "PixelFormat" ); + locator.bindComponent( scalerMode, "ScalerMode" ); + locator.bindComponent( scalerInterpolationMode, "ScalerInterpolationMode" ); + locator.bindComponent( scalerAoiEnable, "ScalerAoiEnable" ); + if( locator.findComponent( "ScalerAoi" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "ScalerAoi" ); + locator.bindComponent( scalerAoiHeight, "H" ); + locator.bindComponent( scalerAoiStartX, "X" ); + locator.bindComponent( scalerAoiStartY, "Y" ); + locator.bindComponent( scalerAoiWidth, "W" ); + } + locator.bindSearchBase( m_hRoot ); + locator.bindComponent( imageWidth, "ImageWidth" ); + locator.bindComponent( imageHeight, "ImageHeight" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the pixel format of the resulting image. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageDestinationPixelFormat. + */ + PropertyIImageDestinationPixelFormat pixelFormat; + /// \brief An integer property defining whether the image is scaled or not. + /** + * \note + * This feature is available for every device! However currently only \b mvDELTA / \b mvSIGMA + * devices provide hardware support for \b REDUCING the image size. In this case the scaled width + * and height must be divisible by 4. For every other device this + * will be done by a software filter and therefore will introduce additional CPU load. Increasing + * the image size will always be done in software. When using the scaler the property + * \b mvIMPACT::acquire::Statistics::imageProcTime_s can be used to observe the additional + * CPU time needed for the image processing. + */ + PropertyIScalerMode scalerMode; + /// \brief An integer property defining the interpolation method used when the scaler is active. + /** + * \note + * Whenever the property \b mvIMPACT::acquire::ImageDestination::scalerMode is set to + * \b mvIMPACT::acquire::smOff modifying or reading this property will have no effect. + * Call \b Component::isVisible to find out whether this property is currently active or not. + * + * \note + * Please see remarks under \b mvIMPACT::acquire::ImageDestination::scalerMode. The interpolation mode + * currently will only be used when scaling is \b NOT done by the hardware. + */ + PropertyIScalerInterpolationMode scalerInterpolationMode; + /// \brief A boolean property defining whether an AOI, rather than the whole image, will be used for scaling. + /** + * \note + * Whenever the property \b mvIMPACT::acquire::ImageDestination::scalerAoiEnable is set to + * \b mvIMPACT::acquire::bTrue the relevant AOI configuration properties will become visible. + */ + PropertyIBoolean scalerAoiEnable; + /// \brief An integer property defining the height of the AOI in pixel to be used for scaling. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::ImageDestination::scalerAoiEnable + * is set to \b mvIMPACT::acquire::bTrue. + */ + PropertyI scalerAoiHeight; + /// \brief An integer property defining the X-offset of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::ImageDestination::scalerAoiEnable + * is set to \b mvIMPACT::acquire::bTrue. + */ + PropertyI scalerAoiStartX; + /// \brief An integer property defining the Y-offset of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::ImageDestination::scalerAoiEnable + * is set to \b mvIMPACT::acquire::bTrue. + */ + PropertyI scalerAoiStartY; + /// \brief An integer property defining the width of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::ImageDestination::scalerAoiEnable + * is set to \b mvIMPACT::acquire::bTrue. + */ + PropertyI scalerAoiWidth; + /// \brief An integer property defining the width of the scaled image. + /** + * \note + * Whenever the property \b mvIMPACT::acquire::ImageDestination::scalerMode is set to + * \b mvIMPACT::acquire::smOff modifying or reading this property will have no effect. + * Call \b Component::isVisible to find out whether this property is currently active or not. + * + * \note + * Please see remarks under \b mvIMPACT::acquire::ImageDestination::scalerMode. + */ + PropertyI imageWidth; + /// \brief An integer property defining the height of the scaled image. + /** + * \note + * Whenever the property \b mvIMPACT::acquire::ImageDestination::scalerMode is set to + * \b mvIMPACT::acquire::smOff modifying or reading this property will have no effect. + * Call \b Component::isVisible to find out whether this property is currently active or not. + * + * \note + * Please see remarks under \b mvIMPACT::acquire::ImageDestination::scalerMode. + */ + PropertyI imageHeight; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Properties to configure which information shall be attached to the resulting images. +/** + * This class provides properties allowing the user to define which additional information + * shall be attached to the resulting images. For example some devices can transmit the state + * of the digital I/Os at the time the exposure of an image has been started. Some information + * will always be attached to the resulting images other information will only be available + * if it has been explicitly enabled before. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * + * \b EXAMPLE: + * + * Enable the transmission of the \c LineStatusAll information in device interface layout + * mvIMPACT::acquire::dilDeviceSpecific: + * + * \code + * //----------------------------------------------------------------------------- + * void fn( Device* pDev ) + * //----------------------------------------------------------------------------- + * { + * RequestInfoConfiguration ric( pDev ); + * if( !ric.lineStatusAll.isValid() ) + * { + * // feature not supported + * return; + * } + * ric.lineStatusAll.write( bTrue ); + * Request* pRequest = captureAnImage( pDev ); + * printf( "%s: 0x%08x\n", pRequest->chunkLineStatusAll.name().c_str(), static_cast< int >( pRequest->chunkLineStatusAll.read() ) ); + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * public void fn( Device pDev ) + * //----------------------------------------------------------------------------- + * { + * RequestInfoConfiguration ric = new RequestInfoConfiguration( pDev ); + * if( !ric.lineStatusAll.isValid() ) + * { + * // feature not supported + * return; + * } + * ric.getLineStatusAll().write( TBoolean.bTrue ); + * Request pRequest = captureAnImage( pDev ); + * System.out.println( String.format( "%s: 0x%08x\n", pRequest.getChunkLineStatusAll().name(), ( int )( pRequest.getChunkLineStatusAll().read() ) ) ); + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * def fn(pdev, pRequest): + * ric = acquire.RequestInfoConfiguration(pDev) + * if ric.lineStatusAll.isValid == False: + * # feature not supported + * return + * else: + * ric.lineStatusAll.write(acquire.bTrue) + * print(pRequest.chunkLineStatusAll.name() + ": 0x%x" %(pRequest.chunkLineStatusAll.read())) + * \endcode + * \endif + * E.g. for the \b mvBlueCOUGAR-X/XD series possible \c LineStatusAll values are + * + * - \b 0x11, Out0 and In0 on (Out0 needs to be connected with In0 for this to work) + * - \b 0x33, Out0, Out1, In0 and In1 on (Out0 and Out1 need to be connected with In0 and In1 for this to work) + * - \b 0x37, Out0, Out1, Out2, In0 and In1 on (Out0 and Out1 need to be connected with In0 and In1 for this to work) + * - \b 0x3f, Out0, Out1, Out2, Out3, In0 and In1 on (Out0 and Out1 need to be connected with in0 and in1 for this to work) + * + * \since 2.10.0 + */ +class RequestInfoConfiguration : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::RequestInfoConfiguration object. + explicit RequestInfoConfiguration( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : ComponentCollection( pDev ), frameNr(), timeStamp_us(), settingUsed(), + exposeStart_us(), exposeTime_us(), gain_dB(), videoChannel(), missingData_pc(), transferDelay_us(), + imageAverage(), IOStatesAtExposureStart(), triggerCounterAcquisitionStart(), triggerCounterFrameStart(), + lineCounter(), userData(), lineStatusAll() + { + DeviceComponentLocator locator( pDev, dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "RequestInfo" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( frameNr, "FrameNr" ); + locator.bindComponent( timeStamp_us, "TimeStamp_us" ); + locator.bindComponent( settingUsed, "SettingUsed" ); + locator.bindComponent( frameID, "FrameID" ); + locator.bindComponent( exposeStart_us, "ExposeStart_us" ); + locator.bindComponent( exposeTime_us, "ExposeTime_us" ); + locator.bindComponent( gain_dB, "Gain_dB" ); + locator.bindComponent( videoChannel, "VideoChannel" ); + locator.bindComponent( missingData_pc, "MissingData_pc" ); + locator.bindComponent( transferDelay_us, "TransferDelay_us" ); + locator.bindComponent( imageAverage, "ImageAverage" ); + locator.bindComponent( IOStatesAtExposureStart, "IOStatesAtExposureStart" ); + locator.bindComponent( triggerCounterAcquisitionStart, "TriggerCounterAcquisitionStart" ); + locator.bindComponent( triggerCounterFrameStart, "TriggerCounterFrameStart" ); + locator.bindComponent( lineCounter, "LineCounter" ); + locator.bindComponent( userData, "UserData" ); + locator.bindComponent( lineStatusAll, "LineStatusAll" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property which can be used to configure whether the frame number information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean frameNr; + /// \brief An enumerated integer property which can be used to configure whether the time stamp(us) information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean timeStamp_us; + /// \brief An enumerated integer property which can be used to configure whether the 'setting used' information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean settingUsed; + /// \brief An enumerated integer property which can be used to configure whether the frame ID information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean frameID; + /// \brief An enumerated integer property which can be used to configure whether the exposure start(us) information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean exposeStart_us; + /// \brief An enumerated integer property which can be used to configure whether the exposure time(us) information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean exposeTime_us; + /// \brief An enumerated integer property which can be used to configure whether the gain(dB) information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean gain_dB; + /// \brief An enumerated integer property which can be used to configure whether the video channel information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean videoChannel; + /// \brief An enumerated integer property which can be used to configure whether the missing data information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean missingData_pc; + /// \brief An enumerated integer property which can be used to configure whether the transfer delay(us) information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * - This feature currently is only available for \b mvBlueFOX devices + */ + PropertyIBoolean transferDelay_us; + /// \brief An enumerated integer property which can be used to configure whether the image average information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * - This feature currently is only available for \b mvBlueFOX devices + */ + PropertyIBoolean imageAverage; + /// \brief An enumerated integer property which can be used to configure whether the I/O states at exposure start information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * This feature currently is only available for \b mvBlueFOX-MLC devices. + */ + PropertyIBoolean IOStatesAtExposureStart; + /// \brief An enumerated integer property which can be used to configure whether the trigger counter at acquisition start information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * - This feature currently is only available for \b mvHYPERION devices + */ + PropertyIBoolean triggerCounterAcquisitionStart; + /// \brief An enumerated integer property which can be used to configure whether the trigger counter at frame start information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * - This feature currently is only available for \b mvHYPERION devices + */ + PropertyIBoolean triggerCounterFrameStart; + /// \brief An enumerated integer property which can be used to configure whether the line counter information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * - This feature currently is only available for \b mvTITAN-CL, \b mvGAMMA-CL and \b mvTITAN-DIG devices + */ + PropertyIBoolean lineCounter; + /// \brief An enumerated integer property which can be used to configure whether the user data information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * This feature currently is only available for \b mvVirtual devices. + */ + PropertyIBoolean userData; + /// \brief An enumerated integer property which can be used to configure whether the line status all information shall be attached to the resulting \b mvIMPACT::acquire::Request objects. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * \note + * - This feature may be available for GenICam compliant devices + */ + PropertyIBoolean lineStatusAll; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Properties for adjusting the colors during a Bayer conversion. +/** + * This class provides properties to adjust the parameters needed for a + * Bayer conversion. + * + * \note + * Objects of this class can't be constructed directly. Its parameters can + * be accessed via an instance of a class derived from \b mvIMPACT::acquire::ImageProcessing. + */ +class WhiteBalanceSettings : public ComponentCollection +//----------------------------------------------------------------------------- +{ + // only ImageProcessing objects can create these objects, as these objects are + // fixed parts of that class. + friend class ImageProcessing; + explicit WhiteBalanceSettings( HOBJ hObj ): ComponentCollection( hObj ), WBAoiMode(), aoiHeight(), aoiStartX(), aoiStartY(), + aoiWidth(), totalGain(), redGain(), greenGain(), blueGain(), WBResult() + { + ComponentLocator locator( hObj ); + locator.bindComponent( WBAoiMode, "WBAoiMode" ); + locator.bindComponent( totalGain, "TotalGain" ); + locator.bindComponent( redGain, "RedGain" ); + locator.bindComponent( greenGain, "GreenGain" ); + locator.bindComponent( blueGain, "BlueGain" ); + locator.bindComponent( WBResult, "WBResult" ); + locator.bindSearchBase( locator.searchbase_id(), "WBAoi" ); + locator.bindComponent( aoiHeight, "H" ); + locator.bindComponent( aoiStartX, "X" ); + locator.bindComponent( aoiStartY, "Y" ); + locator.bindComponent( aoiWidth, "W" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the which area of the image is used + /** for the calculation of the parameters. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAoiMode. + */ + PropertyIAoiMode WBAoiMode; + /// \brief An integer property defining the height of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::WhiteBalanceSettings::WBAoiMode + * is set to \b mvIMPACT::acquire::amUseAoi. + */ + PropertyI aoiHeight; + /// \brief An integer property defining the X-offset of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::WhiteBalanceSettings::WBAoiMode + * is set to \b mvIMPACT::acquire::amUseAoi. + */ + PropertyI aoiStartX; + /// \brief An integer property defining the Y-offset of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::WhiteBalanceSettings::WBAoiMode + * is set to \b mvIMPACT::acquire::amUseAoi. + */ + PropertyI aoiStartY; + /// \brief An integer property defining the width of the AOI in pixel to be used for the calculation. + /** + * \note + * This property will be visible only when \b mvIMPACT::acquire::WhiteBalanceSettings::WBAoiMode + * is set to \b mvIMPACT::acquire::amUseAoi. + */ + PropertyI aoiWidth; + /// \brief A float property defining the overall gain. + PropertyF totalGain; + /// \brief A float property defining the gain for the red channel. + PropertyF redGain; + /// \brief A float property defining the gain for the green channel. + PropertyF greenGain; + /// \brief A float property defining the gain for the blue channel. + PropertyF blueGain; + /// \brief An enumerated integer property \b (read-only) containing the result of the last white balance calibration. + /** + * After the \b mvIMPACT::acquire::Device has been initialized, the value of this property will be + * \b mvIMPACT::acquire::bwbrUnknown. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBayerWhiteBalanceResult. + */ + PropertyIBayerWhiteBalanceResult WBResult; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Properties for configuring settings belonging to a certain channel of the GainOffsetKnee filter. +/** + * First the master offset will be added to all channels of the image, then each + * channels individual gain factor will be applied to the pixel of each channel and + * finally the channel specific offset will be added. + * + * \image html GainOffsetKnee.png + * + * \note + * Objects of this class can't be constructed directly. Its parameters can + * be accessed via an instance of a class derived from \b mvIMPACT::acquire::ImageProcessing. + */ +class GainOffsetKneeChannelParameters : public ComponentCollection +//----------------------------------------------------------------------------- +{ + // only ImageProcessing objects can create these objects, as these objects are + // fixed parts of that class. + friend class ImageProcessing; + explicit GainOffsetKneeChannelParameters( HOBJ hObj ): ComponentCollection( hObj ), gain(), offset_pc() + { + ComponentLocator locator( hObj ); + locator.bindComponent( gain, "Gain" ); + locator.bindComponent( offset_pc, "Offset_pc" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A float property that contains the channel specific gain to be applied to the selected channel of the image. + /** + * This gain will be applied after the master offset but before the channel specific offset. + */ + PropertyF gain; + /// \brief A float property that contains the channel specific offset (in percent) to be applied to the selected channel of the image. + /** + * This offset will be applied after the channel specific gain. + */ + PropertyF offset_pc; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Properties for configuring settings belonging to a certain LUT (Look Up Table) to be applied to a captured image. +/** + * \note + * Objects of this class can't be constructed directly. Its parameters can + * be accessed via an instance of a class derived from \b mvIMPACT::acquire::ImageProcessing. + */ +class LUTParameters : public ComponentCollection +//----------------------------------------------------------------------------- +{ + // only ImageProcessing objects can create these objects, as these objects are + // fixed parts of that class. + friend class ImageProcessing; + explicit LUTParameters( HOBJ hObj ): ComponentCollection( hObj ), gamma(), + gammaAlpha(), gammaMode(), gammaStartThreshold(), gammaInverter(), + valueCount(), inputValues(), outputValues(), directValues() + { + ComponentLocator locator( hObj ); + locator.bindComponent( gamma, "Gamma" ); + locator.bindComponent( gammaAlpha, "GammaAlpha" ); + locator.bindComponent( gammaMode, "GammaMode" ); + locator.bindComponent( gammaStartThreshold, "GammaStartThreshold" ); + locator.bindComponent( gammaInverter, "GammaInverter" ); + locator.bindComponent( valueCount, "ValueCount" ); + locator.bindComponent( inputValues, "InputValues" ); + locator.bindComponent( outputValues, "OutputValues" ); + locator.bindComponent( directValues, "DirectValues" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A float property which can be used to set the gamma value. + /** + * Gamma correction is explained e.g. in this Wikipedia article: http://en.wikipedia.org/wiki/Gamma_correction. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmGamma. + * + * The gamma value will be used to calculate the corresponding input -> output transformation LUT. + * + * The following formula will be used: + * \code + * ( ( 1 + gammaAlpha ) * inputValue^(1/gamma) ) - gammaAlpha + * \endcode + */ + PropertyF gamma; + /// \brief A float property which can be used to set the gammaAlpha value. + /** + * Refer to \b mvIMPACT::acquire::LUTParameters::gamma to see how this parameter affects the resulting + * LUT data. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmGamma. + */ + PropertyF gammaAlpha; + /// \brief An enumerated integer property which can be used to configure the LUT(Look Up Table) gamma mode. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLUTGammaMode. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmGamma. + */ + PropertyILUTGammaMode gammaMode; + /// \brief An integer property which can be used to define a start threshold above which the gamma correction formula shall be used in \b mvIMPACT::acquire::LUTParameters::gammaMode \b mvIMPACT::acquire::LUTgmLinearStart. + /** + * Values below that threshold will be calculated using linear interpolation. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmGamma or if \b mvIMPACT::acquire::LUTParameters::gammaMode is \b NOT set to + * \b mvIMPACT::acquire::LUTgmLinearStart. + */ + PropertyI gammaStartThreshold; + /// \brief An enumerated integer property defining whether the calculated gamma correction function shall be inverted or not + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmGamma. + * + * \attention This property is mainly provided for compatibility reasons since the original implementation of + * the mvIMPACT Acquire framework and the implementation inside MATRIX VISION GmbH GenICam devices introduced later + * differ. The default behaviour of the mvIMPACT Acquire results in the reverse function of the gamma function + * inside the device firmware thus the gamma value specified here results in the same response as if applying + * (1/gamma value) to a device. So a gamma value of 2.2 with the inverter switched off this would result in the same + * response as a gamma value of 0.45 with the inverter switched on. In order not to change the default behaviour of this filter + * the default value for this property will be \b mvIMPACT::acquire::bTrue and can be set to + * \b mvIMPACT::acquire::bFalse to achieve the same behaviour as implemented for GenICam devices and specified in + * the SFNC (GenICam Standard Features Naming Convention). + * + * \since 2.38.0 + */ + PropertyIBoolean gammaInverter; + /// \brief An integer property to define the number of sampling points for interpolated LUT transformations. + /** + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmInterpolated. + * + * At least 2 sampling points are needed, the max. number of sampling points is defined by the bit depth of the input + * image, thus a 8 bit input image can have no more than 2^8 (256) sampling points. if the max. number of sampling points + * is used, the behaviour is the same a when working with \b mvIMPACT::acquire::ImageProcessing::LUTMode set to + * \b mvIMPACT::acquire::LUTmDirect. + * + * \b EXAMPLE + * + * Assuming 4 sampling points in \b mvIMPACT::acquire::LUTimThreshold mode for an 8 to 8 bit transformation where the following + * values are used: + * + * + * + * + * + * + * + *
indexinput valueoutput value
0064
1128255
21920
32550
+ * + * This will result in the following transfer function characteristic: + * + * \image html LUT_ThresholdInterpolation_4SamplingPoints.png + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \b The following C++ code would be needed to achieve this behaviour for mono video sources: + * + * \code + * //----------------------------------------------------------------------------- + * void fn( ImageProcessing& ip, TLUTImplemention LUTImplementation ) + * //----------------------------------------------------------------------------- + * { + * ip.LUTEnable.write( bTrue ); + * ip.LUTMode.write( LUTmInterpolated ); + * ip.LUTImplementation.write( LUTImplementation ); + * ip.LUTInterpolationMode.write( LUTimThreshold ); + * switch( LUTImplementation ) + * { + * case LUTiHardware: + * ip.LUTMappingHardware.write( LUTm8To8 ); + * break; + * case LUTiSoftware: + * ip.LUTMappingSoftware.write( LUTm8To8 ); + * break; + * } + * LUTParameters& LUTAccess = ip.getLUTParameter( 0 ); + * LUTAccess.valueCount.write( 4 ); + * vector v(4); + * v[0] = 0; + * v[1] = 128; + * v[2] = 192; + * v[3] = 255; + * LUTAccess.inputValues.write( v ); + * v[0] = 64; + * v[1] = 255; + * v[2] = 0; + * v[3] = 0; + * LUTAccess.outputValues.write( v ); + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * public void fn( ImageProcessing ip, final int LUTImplementation ) + * //----------------------------------------------------------------------------- + * { + * ip.getLUTEnable().write( TBoolean.bTrue ); + * ip.getLUTMode().write( TLUTMode.LUTmInterpolated ); + * ip.getLUTImplementation().write( LUTImplementation ); + * ip.getLUTInterpolationMode().write( TLUTInterpolationMode.LUTimThreshold ); + * if( LUTImplementation == TLUTImplementation.LUTiHardware ) + * { + * ip.getLUTMappingHardware().write( TLUTMapping.LUTm8To8 ); + * } + * else if( LUTImplementation == TLUTImplementation.LUTiSoftware ) + * { + * ip.getLUTMappingSoftware().write( TLUTMapping.LUTm8To8 ); + * } + * LUTParameters LUTAccess = ip.getLUTParameter( 0 ); + * LUTAccess.getValueCount().write( 4 ); + * { + * IntVector v = new IntVector(); + * v.add( 0 ); + * v.add( 128 ); + * v.add( 192 ); + * v.add( 255 ); + * LUTAccess.getInputValues().write( v ); + * } + * { + * IntVector v = new IntVector(); + * v.add( 64 ); + * v.add( 255 ); + * v.add( 0 ); + * v.add( 0 ); + * LUTAccess.getOutputValues().write( v ); + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * This sample assumes a valid reference to a \b mvIMPACT::acquire::ImageProcessing object has been obtained. + * def fn(ip, LUTImplementation): + * ip.LUTEnable.write(acquire.bTrue) + * ip.LUTMode.write(acquire.LUTmInterpolated) + * ip.LUTImplementation.write(LUTImplementation) + * ip.LUTInterpolationMode.write(LUTimThreshold) + * if LUTImplementation == LUTiHardware: + * ip.LUTMappingHardware.write(acquire.LUTm8To8) + * elif LUTImplementation == LUTiSoftware: + * ip.LUTMappingSoftware.write(acquire.LUTm8To8) + * + * LUTAccess = ip.getLUTParameter(0) + * LUTAccess.valueCount.write(4) + * v = [] + * v[0] = 0 + * v[1] = 128 + * v[2] = 192 + * v[3] = 255 + * LUTAccess.inputValues.write(v) + * + * v[0] = 64 + * v[1] = 255 + * v[2] = 0 + * v[3] = 0 + * LUTAccess.outputValues.write(v) + * \endcode + * \endif + * Assuming 3 sampling points in \b mvIMPACT::acquire::LUTimLinear mode for an 8 to 8 bit transformation where the following + * values are used: + * + * + * + * + * + * + *
indexinput valueoutput value
0064
1128255
22550
+ * + * This will result in the following transfer function characteristic: + * + * \image html LUT_linearInterpolation_3SamplingPoints.png + * + * Assuming 4 sampling points in \b mvIMPACT::acquire::LUTimCubic mode for an 8 to 8 bit transformation where the following + * values are used: + * + * + * + * + * + * + * + *
indexinput valueoutput value
000
1128255
2192192
32550
+ * + * This will result in the following transfer function characteristic: + * + * \image html LUT_CubicInterpolation_4SamplingPoints.png + */ + PropertyI valueCount; + /// \brief An integer property to define the input values for sampling points for interpolated LUT transformations. + /** + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmInterpolated. + * + * The number of values stored by this property can be changed by writing to the property \b mvIMPACT::acquire::LUTParameters::valueCount. + * The documentation of this property also provides some example values and resulting transfer characteristics. + */ + PropertyI inputValues; + /// \brief An integer property to define the output values for sampling points for interpolated LUT transformations. + /** + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmInterpolated. + * + * The number of values stored by this property can be changed by writing to the property \b mvIMPACT::acquire::LUTParameters::valueCount. + * The documentation of this property also provides some example values and resulting transfer characteristics. + */ + PropertyI outputValues; + /// \brief An integer property which can be used to directly define a LUT. + /** + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmDirect. + * + * This property will provide a complete LUT thus e.g. in a LUT mapping to a 10 bit output this property will store 2^10 (1024) + * values that can be accessed and modified by the user. + */ + PropertyI directValues; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Properties for configuring settings belonging to the mirror filter that processes a certain channel of a captured image. +/** + * Properties in this class will only have influence on the capture process if + * \b mvIMPACT::acquire::ImageProcessing::mirrorOperationMode is set to \b mvIMPACT::acquire::momChannelBased. + * + * \note + * Objects of this class can't be constructed directly. Its parameters can + * be accessed via an instance of a class derived from \b mvIMPACT::acquire::ImageProcessing. + */ +class MirrorParameters : public ComponentCollection +//----------------------------------------------------------------------------- +{ + // only ImageProcessing objects can create these objects, as these objects are + // fixed parts of that class. + friend class ImageProcessing; + explicit MirrorParameters( HOBJ hObj ): ComponentCollection( hObj ), mirrorMode() + { + ComponentLocator locator( hObj ); + locator.bindComponent( mirrorMode, "MirrorMode" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the mirror mode to be applied to this channel of the image. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TMirrorMode. + */ + PropertyIMirrorMode mirrorMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + +}; + +//----------------------------------------------------------------------------- +/// \brief Base class for image processing related properties. +/** + * This class provides access to properties, which define how the image shall + * be processed after it has been captured but before it will be handed back to + * the user. + */ +class ImageProcessing : public ComponentCollection +//----------------------------------------------------------------------------- +{ + typedef std::vector GainOffsetKneeParameterContainer; + typedef std::vector LUTParameterContainer; + typedef std::vector MirrorParameterContainer; + typedef std::vector WBSettingsContainer; +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + GainOffsetKneeParameterContainer m_GainOffsetKneeParameters; + LUTParameterContainer m_LUTParameters; + MirrorParameterContainer m_MirrorParameters; + WBSettingsContainer m_WBUserSettings; + unsigned int m_refCnt; + explicit ReferenceCountedData() : m_GainOffsetKneeParameters(), m_LUTParameters(), + m_MirrorParameters(), m_WBUserSettings(), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + const GainOffsetKneeParameterContainer::size_type GainOffsetKneeParameterCnt = m_GainOffsetKneeParameters.size(); + for( GainOffsetKneeParameterContainer::size_type h = 0; h < GainOffsetKneeParameterCnt; h++ ) + { + delete m_GainOffsetKneeParameters[h]; + } + const LUTParameterContainer::size_type LUTParametersCnt = m_LUTParameters.size(); + for( LUTParameterContainer::size_type i = 0; i < LUTParametersCnt; i++ ) + { + delete m_LUTParameters[i]; + } + const MirrorParameterContainer::size_type MirrorParametersCnt = m_MirrorParameters.size(); + for( MirrorParameterContainer::size_type j = 0; j < MirrorParametersCnt; j++ ) + { + delete m_MirrorParameters[j]; + } + const WBSettingsContainer::size_type WBSettingsCnt = m_WBUserSettings.size(); + for( WBSettingsContainer::size_type k = 0; k < WBSettingsCnt; k++ ) + { + delete m_WBUserSettings[k]; + } + } + }* m_pRefData; +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + void bindPublicProperties( void ) + //----------------------------------------------------------------------------- + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( colorProcessing, "ColorProcessing" ); + locator.bindComponent( bayerConversionMode, "BayerConversionMode" ); + locator.bindComponent( adaptiveEdgeSensingPlusSharpenThreshold, "AdaptiveEdgeSensingPlusSharpenThreshold" ); + locator.bindComponent( adaptiveEdgeSensingPlusSharpenGain, "AdaptiveEdgeSensingPlusSharpenGain" ); + locator.bindComponent( whiteBalance, "WhiteBalance" ); + locator.bindComponent( whiteBalanceCalibration, "WhiteBalanceCalibration" ); + locator.bindComponent( filter, "Filter" ); + if( locator.findComponent( "Mirror" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "Mirror" ); + locator.bindComponent( mirrorOperationMode, "MirrorOperationMode" ); + locator.bindComponent( mirrorModeGlobal, "MirrorModeGlobal" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "PolarizedDataExtraction" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "PolarizedDataExtraction" ); + locator.bindComponent( polarizedDataExtractionEnable, "PolarizedDataExtractionEnable" ); + locator.bindComponent( polarizedDataExtractionMode, "PolarizedDataExtractionMode" ); + locator.bindComponent( polarizedDataExtractionInterpolationMode, "PolarizedDataExtractionInterpolationMode" ); + locator.bindComponent( polarizedDataExtractionChannelIndex, "PolarizedDataExtractionChannelIndex" ); + locator.bindComponent( polarizedDataExtractionLowerLimit, "PolarizedDataExtractionLowerLimit" ); + locator.bindComponent( polarizedDataExtractionUpperLimit, "PolarizedDataExtractionUpperLimit" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "DefectivePixelsFilter" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "DefectivePixelsFilter" ); + locator.bindComponent( defectivePixelsFilterMode, "Mode" ); + locator.bindComponent( defectivePixelsFilterLeakyPixelDeviation_ADCLimit, "LeakyPixelDeviation_ADCLimit" ); + locator.bindComponent( defectivePixelsFilterColdPixelDeviation_pc, "ColdPixelDeviation_pc" ); + locator.bindComponent( defectivePixelsMaxDetectionCount, "DefectivePixelsMaxDetectionCount" ); + locator.bindComponent( defectivePixelsFound, "DefectivePixelsFound" ); + locator.bindComponent( defectivePixelOffsetX, "DefectivePixelOffsetX" ); + locator.bindComponent( defectivePixelOffsetY, "DefectivePixelOffsetY" ); + locator.bindComponent( defectivePixelReadFromDevice, "DefectivePixelReadFromDevice@i" ); + locator.bindComponent( defectivePixelWriteToDevice, "DefectivePixelWriteToDevice@i" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "FlatFieldFilter" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "FlatFieldFilter" ); + locator.bindComponent( flatFieldFilterMode, "Mode" ); + locator.bindComponent( flatFieldFilterCorrectionMode, "CorrectionMode" ); + locator.bindComponent( flatFieldFilterCorrectionModeReverseX, "CorrectionModeReverseX" ); + locator.bindComponent( flatFieldFilterCorrectionModeReverseY, "CorrectionModeReverseY" ); + locator.bindComponent( flatFieldFilterCorrectionAoiMode, "CorrectionAoiMode" ); + locator.bindComponent( flatFieldFilterCalibrationImageCount, "CalibrationImageCount" ); + locator.bindComponent( flatFieldFilterCalibrationAoiMode, "CalibrationAoiMode" ); + HOBJ hObj = locator.findComponent( "CorrectionAOI" ); + if( hObj != INVALID_ID ) + { + ComponentLocator l( hObj ); + l.bindComponent( flatFieldFilterCorrectionAoiOffsetX, "X" ); + l.bindComponent( flatFieldFilterCorrectionAoiOffsetY, "Y" ); + l.bindComponent( flatFieldFilterCorrectionAoiWidth, "W" ); + l.bindComponent( flatFieldFilterCorrectionAoiHeight, "H" ); + } + hObj = locator.findComponent( "CalibrationAOI" ); + if( hObj != INVALID_ID ) + { + ComponentLocator l( hObj ); + l.bindComponent( flatFieldFilterCalibrationAoiOffsetX, "X" ); + l.bindComponent( flatFieldFilterCalibrationAoiOffsetY, "Y" ); + l.bindComponent( flatFieldFilterCalibrationAoiWidth, "W" ); + l.bindComponent( flatFieldFilterCalibrationAoiHeight, "H" ); + } + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "DarkCurrentFilter" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "DarkCurrentFilter" ); + locator.bindComponent( darkCurrentFilterMode, "Mode" ); + locator.bindComponent( darkCurrentFilterCalibrationImageCount, "CalibrationImageCount" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "GainOffsetKnee" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "GainOffsetKnee" ); + locator.bindComponent( gainOffsetKneeEnable, "GainOffsetKneeEnable" ); + locator.bindComponent( gainOffsetKneeMasterOffset_pc, "GainOffsetKneeMasterOffset_pc" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "LUTOperations" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "LUTOperations" ); + locator.bindComponent( LUTEnable, "LUTEnable" ); + locator.bindComponent( LUTMode, "LUTMode" ); + locator.bindComponent( LUTInterpolationMode, "LUTInterpolationMode" ); + locator.bindComponent( LUTImplementation, "LUTImplementation" ); + locator.bindComponent( LUTMappingHardware, "LUTMappingHardware" ); + locator.bindComponent( LUTMappingSoftware, "LUTMappingSoftware" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "TapSort" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "TapSort" ); + locator.bindComponent( tapSortEnable, "TapSortEnable" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "ChannelSplit" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "ChannelSplit" ); + locator.bindComponent( channelSplitEnable, "ChannelSplitEnable" ); + locator.bindComponent( channelSplitMode, "ChannelSplitMode" ); + locator.bindComponent( channelSplitChannelIndex, "ChannelSplitChannelIndex" ); + locator.bindComponent( channelSplitDeinterlaceEnable, "ChannelSplitDeinterlaceEnable" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "ColorTwist" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "ColorTwist" ); + locator.bindComponent( colorTwistInputCorrectionMatrixEnable, "ColorTwistInputCorrectionMatrixEnable" ); + locator.bindComponent( colorTwistInputCorrectionMatrixMode, "ColorTwistInputCorrectionMatrixMode" ); + locator.bindComponent( colorTwistInputCorrectionMatrixRow0, "ColorTwistInputCorrectionMatrixRow0" ); + locator.bindComponent( colorTwistInputCorrectionMatrixRow1, "ColorTwistInputCorrectionMatrixRow1" ); + locator.bindComponent( colorTwistInputCorrectionMatrixRow2, "ColorTwistInputCorrectionMatrixRow2" ); + locator.bindComponent( colorTwistEnable, "ColorTwistEnable" ); + locator.bindComponent( colorTwistRow0, "ColorTwistRow0" ); + locator.bindComponent( colorTwistRow1, "ColorTwistRow1" ); + locator.bindComponent( colorTwistRow2, "ColorTwistRow2" ); + locator.bindComponent( colorTwistOutputCorrectionMatrixEnable, "ColorTwistOutputCorrectionMatrixEnable" ); + locator.bindComponent( colorTwistOutputCorrectionMatrixMode, "ColorTwistOutputCorrectionMatrixMode" ); + locator.bindComponent( colorTwistOutputCorrectionMatrixRow0, "ColorTwistOutputCorrectionMatrixRow0" ); + locator.bindComponent( colorTwistOutputCorrectionMatrixRow1, "ColorTwistOutputCorrectionMatrixRow1" ); + locator.bindComponent( colorTwistOutputCorrectionMatrixRow2, "ColorTwistOutputCorrectionMatrixRow2" ); + locator.bindComponent( colorTwistResultingMatrixRow0, "ColorTwistResultingMatrixRow0" ); + locator.bindComponent( colorTwistResultingMatrixRow1, "ColorTwistResultingMatrixRow1" ); + locator.bindComponent( colorTwistResultingMatrixRow2, "ColorTwistResultingMatrixRow2" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "FormatReinterpreter" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "FormatReinterpreter" ); + locator.bindComponent( formatReinterpreterEnable, "FormatReinterpreterEnable" ); + locator.bindComponent( formatReinterpreterMode, "FormatReinterpreterMode" ); + locator.bindComponent( formatReinterpreterBayerMosaicParity, "FormatReinterpreterBayerMosaicParity" ); + } + locator.bindSearchBase( m_hRoot ); + if( locator.findComponent( "Rotation" ) != INVALID_ID ) + { + locator.bindSearchBase( m_hRoot, "Rotation" ); + locator.bindComponent( rotationEnable, "RotationEnable" ); + locator.bindComponent( rotationAngle, "RotationAngle" ); + } + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::ImageProcessing object. + explicit ImageProcessing( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : ComponentCollection( pDev ), m_pRefData( 0 ), + colorProcessing(), bayerConversionMode(), adaptiveEdgeSensingPlusSharpenThreshold(), + adaptiveEdgeSensingPlusSharpenGain(), whiteBalance(), whiteBalanceCalibration(), filter(), + mirrorOperationMode(), mirrorModeGlobal(), polarizedDataExtractionEnable(), + polarizedDataExtractionMode(), polarizedDataExtractionInterpolationMode(), + polarizedDataExtractionChannelIndex(), + polarizedDataExtractionLowerLimit(), polarizedDataExtractionUpperLimit(), + defectivePixelsFilterMode(), defectivePixelsFilterLeakyPixelDeviation_ADCLimit(), + defectivePixelsFilterColdPixelDeviation_pc(), defectivePixelsMaxDetectionCount(), defectivePixelsFound(), + defectivePixelOffsetX(), defectivePixelOffsetY(), defectivePixelReadFromDevice(), defectivePixelWriteToDevice(), + flatFieldFilterMode(), flatFieldFilterCorrectionMode(), flatFieldFilterCorrectionModeReverseX(), flatFieldFilterCorrectionModeReverseY(), + flatFieldFilterCorrectionAoiMode(), flatFieldFilterCorrectionAoiOffsetX(), flatFieldFilterCorrectionAoiOffsetY(), + flatFieldFilterCorrectionAoiWidth(), flatFieldFilterCorrectionAoiHeight(), flatFieldFilterCalibrationImageCount(), + flatFieldFilterCalibrationAoiMode(), flatFieldFilterCalibrationAoiOffsetX(), flatFieldFilterCalibrationAoiOffsetY(), + flatFieldFilterCalibrationAoiWidth(), flatFieldFilterCalibrationAoiHeight(), + darkCurrentFilterMode(), darkCurrentFilterCalibrationImageCount(), + gainOffsetKneeEnable(), gainOffsetKneeMasterOffset_pc(), + LUTEnable(), LUTMode(), LUTInterpolationMode(), + LUTImplementation(), LUTMappingHardware(), LUTMappingSoftware(), + tapSortEnable(), channelSplitEnable(), channelSplitMode(), channelSplitChannelIndex(), channelSplitDeinterlaceEnable(), + colorTwistInputCorrectionMatrixEnable(), colorTwistInputCorrectionMatrixMode(), + colorTwistInputCorrectionMatrixRow0(), colorTwistInputCorrectionMatrixRow1(), colorTwistInputCorrectionMatrixRow2(), + colorTwistEnable(), colorTwistRow0(), colorTwistRow1(), colorTwistRow2(), + colorTwistOutputCorrectionMatrixEnable(), colorTwistOutputCorrectionMatrixMode(), + colorTwistOutputCorrectionMatrixRow0(), colorTwistOutputCorrectionMatrixRow1(), colorTwistOutputCorrectionMatrixRow2(), + colorTwistResultingMatrixRow0(), colorTwistResultingMatrixRow1(), colorTwistResultingMatrixRow2(), + formatReinterpreterEnable(), formatReinterpreterMode(), formatReinterpreterBayerMosaicParity(), rotationEnable(), rotationAngle() + { + DeviceComponentLocator locator( pDev, dltSetting, settingName ); + m_pRefData = new ReferenceCountedData(); + locator.bindSearchBase( locator.searchbase_id(), "ImageProcessing" ); + m_hRoot = locator.searchbase_id(); + bindPublicProperties(); + int number = 1; + HOBJ hList = INVALID_ID; + // create the WB user parameter objects for this setting + do + { + std::ostringstream oss; + oss << "WhiteBalanceSettings-" << number++; + if( ( hList = locator.findComponent( oss.str() ) ) != INVALID_ID ) + { + m_pRefData->m_WBUserSettings.push_back( new WhiteBalanceSettings( hList ) ); + } + } + while( hList != INVALID_ID ); + + // create the GainOffsetKnee parameter objects for this setting + if( locator.findComponent( "GainOffsetKnee" ) != INVALID_ID ) + { + // this driver offers GainOffsetKnee support + locator.bindSearchBase( locator.searchbase_id(), "GainOffsetKnee" ); + locator.bindSearchBase( locator.searchbase_id(), "GainOffsetKneeChannels" ); + number = 0; + do + { + std::ostringstream oss; + oss << "Channel-" << number++; + if( ( hList = locator.findComponent( oss.str() ) ) != INVALID_ID ) + { + m_pRefData->m_GainOffsetKneeParameters.push_back( new GainOffsetKneeChannelParameters( hList ) ); + } + } + while( hList != INVALID_ID ); + } + + locator.bindSearchBase( m_hRoot ); + // create the Mirror parameter objects for this setting + if( locator.findComponent( "Mirror" ) != INVALID_ID ) + { + // this driver offers Mirror support + locator.bindSearchBase( locator.searchbase_id(), "Mirror" ); + locator.bindSearchBase( locator.searchbase_id(), "MirrorChannels" ); + number = 0; + do + { + std::ostringstream oss; + oss << "Channel-" << number++; + if( ( hList = locator.findComponent( oss.str() ) ) != INVALID_ID ) + { + m_pRefData->m_MirrorParameters.push_back( new MirrorParameters( hList ) ); + } + } + while( hList != INVALID_ID ); + } + + locator.bindSearchBase( m_hRoot ); + // create the LUT parameter objects for this setting + if( locator.findComponent( "LUTOperations" ) != INVALID_ID ) + { + // this driver offers LUT support + locator.bindSearchBase( locator.searchbase_id(), "LUTOperations" ); + locator.bindSearchBase( locator.searchbase_id(), "LUTs" ); + number = 0; + do + { + std::ostringstream oss; + oss << "LUT-" << number++; + if( ( hList = locator.findComponent( oss.str() ) ) != INVALID_ID ) + { + m_pRefData->m_LUTParameters.push_back( new LUTParameters( hList ) ); + } + } + while( hList != INVALID_ID ); + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::ImageProcessing from an existing one. + ImageProcessing( + /// [in] A constant reference to the \b mvIMPACT::acquire::ImageProcessing object, this object shall be created from + const ImageProcessing& src ) : ComponentCollection( src.hObj() ), m_pRefData( src.m_pRefData ), + colorProcessing( src.colorProcessing ), bayerConversionMode( src.bayerConversionMode ), + adaptiveEdgeSensingPlusSharpenThreshold( src.adaptiveEdgeSensingPlusSharpenThreshold ), + adaptiveEdgeSensingPlusSharpenGain( src.adaptiveEdgeSensingPlusSharpenGain ), whiteBalance( src.whiteBalance ), + whiteBalanceCalibration( src.whiteBalanceCalibration ), filter( src.filter ), + mirrorOperationMode( src.mirrorOperationMode ), + mirrorModeGlobal( src.mirrorModeGlobal ), polarizedDataExtractionEnable( src.polarizedDataExtractionEnable ), + polarizedDataExtractionMode( src.polarizedDataExtractionMode ), + polarizedDataExtractionInterpolationMode( src.polarizedDataExtractionInterpolationMode ), + polarizedDataExtractionChannelIndex( src.polarizedDataExtractionChannelIndex ), + polarizedDataExtractionLowerLimit( src.polarizedDataExtractionLowerLimit ), + polarizedDataExtractionUpperLimit( src.polarizedDataExtractionUpperLimit ), + defectivePixelsFilterMode( src.defectivePixelsFilterMode ), + defectivePixelsFilterLeakyPixelDeviation_ADCLimit( src.defectivePixelsFilterLeakyPixelDeviation_ADCLimit ), + defectivePixelsFilterColdPixelDeviation_pc( src.defectivePixelsFilterColdPixelDeviation_pc ), + defectivePixelsFound( src.defectivePixelsFound ), + defectivePixelOffsetX( src.defectivePixelOffsetX ), + defectivePixelOffsetY( src.defectivePixelOffsetY ), + defectivePixelReadFromDevice( src.defectivePixelReadFromDevice ), + defectivePixelWriteToDevice( src.defectivePixelWriteToDevice ), + flatFieldFilterMode( src.flatFieldFilterMode ), + flatFieldFilterCorrectionMode( src.flatFieldFilterCorrectionMode ), + flatFieldFilterCorrectionModeReverseX( src.flatFieldFilterCorrectionModeReverseX ), + flatFieldFilterCorrectionModeReverseY( src.flatFieldFilterCorrectionModeReverseY ), + flatFieldFilterCorrectionAoiMode( src.flatFieldFilterCorrectionAoiMode ), + flatFieldFilterCorrectionAoiOffsetX( src.flatFieldFilterCorrectionAoiOffsetX ), + flatFieldFilterCorrectionAoiOffsetY( src.flatFieldFilterCorrectionAoiOffsetY ), + flatFieldFilterCorrectionAoiWidth( src.flatFieldFilterCorrectionAoiWidth ), + flatFieldFilterCorrectionAoiHeight( src.flatFieldFilterCorrectionAoiHeight ), + flatFieldFilterCalibrationImageCount( src.flatFieldFilterCalibrationImageCount ), + flatFieldFilterCalibrationAoiMode( src.flatFieldFilterCalibrationAoiMode ), + flatFieldFilterCalibrationAoiOffsetX( src.flatFieldFilterCalibrationAoiMode ), + flatFieldFilterCalibrationAoiOffsetY( src.flatFieldFilterCalibrationAoiOffsetY ), + flatFieldFilterCalibrationAoiWidth( src.flatFieldFilterCalibrationAoiWidth ), + flatFieldFilterCalibrationAoiHeight( src.flatFieldFilterCalibrationAoiHeight ), + darkCurrentFilterMode( src.darkCurrentFilterMode ), + darkCurrentFilterCalibrationImageCount( src.darkCurrentFilterCalibrationImageCount ), + gainOffsetKneeEnable( src.gainOffsetKneeEnable ), gainOffsetKneeMasterOffset_pc( src.gainOffsetKneeMasterOffset_pc ), + LUTEnable( src.LUTEnable ), LUTMode( src.LUTMode ), LUTInterpolationMode( src.LUTInterpolationMode ), + LUTImplementation( src.LUTImplementation ), LUTMappingHardware( src.LUTMappingHardware ), LUTMappingSoftware( src.LUTMappingSoftware ), + tapSortEnable( src.tapSortEnable ), channelSplitEnable( src.channelSplitEnable ), channelSplitMode( src.channelSplitMode ), + channelSplitChannelIndex( src.channelSplitChannelIndex ), channelSplitDeinterlaceEnable( src.channelSplitDeinterlaceEnable ), + colorTwistInputCorrectionMatrixEnable( src.colorTwistInputCorrectionMatrixEnable ), + colorTwistInputCorrectionMatrixMode( src.colorTwistInputCorrectionMatrixMode ), + colorTwistInputCorrectionMatrixRow0( src.colorTwistInputCorrectionMatrixRow0 ), + colorTwistInputCorrectionMatrixRow1( src.colorTwistInputCorrectionMatrixRow1 ), + colorTwistInputCorrectionMatrixRow2( src.colorTwistInputCorrectionMatrixRow2 ), + colorTwistEnable( src.colorTwistEnable ), + colorTwistRow0( src.colorTwistRow0 ), colorTwistRow1( src.colorTwistRow1 ), colorTwistRow2( src.colorTwistRow2 ), + colorTwistOutputCorrectionMatrixEnable( src.colorTwistOutputCorrectionMatrixEnable ), + colorTwistOutputCorrectionMatrixMode( src.colorTwistOutputCorrectionMatrixMode ), + colorTwistOutputCorrectionMatrixRow0( src.colorTwistOutputCorrectionMatrixRow0 ), + colorTwistOutputCorrectionMatrixRow1( src.colorTwistOutputCorrectionMatrixRow1 ), + colorTwistOutputCorrectionMatrixRow2( src.colorTwistOutputCorrectionMatrixRow2 ), + colorTwistResultingMatrixRow0( src.colorTwistResultingMatrixRow0 ), + colorTwistResultingMatrixRow1( src.colorTwistResultingMatrixRow1 ), + colorTwistResultingMatrixRow2( src.colorTwistResultingMatrixRow2 ), + formatReinterpreterEnable( src.formatReinterpreterEnable ), + formatReinterpreterMode( src.formatReinterpreterMode ), + formatReinterpreterBayerMosaicParity( src.formatReinterpreterBayerMosaicParity ), + rotationEnable( src.rotationEnable ), rotationAngle( src.rotationAngle ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + virtual ~ImageProcessing() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::ImageProcessing objects. + ImageProcessing& operator=( const ImageProcessing& rhs ) + { + if( this != &rhs ) + { + ComponentCollection::operator=( rhs ); + dealloc(); + m_pRefData = rhs.m_pRefData; + ++m_pRefData->m_refCnt; + bindPublicProperties(); + } + return *this; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining what kind of color processing shall be applied to the raw image data. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TColorProcessingMode. + */ + PropertyIColorProcessingMode colorProcessing; + /// \brief An enumerated integer property defining what kind of algorithm shall be used during Bayer to RGB conversion. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBayerConversionMode. + */ + PropertyIBayerConversionMode bayerConversionMode; + /// \brief An integer property defining the max. brightness level difference for which sharpening is not applied during AdaptiveEdgeSensingPlus deBayering. + /** + * Valid values for this property are between 0 and 2^(bits per pixel). + * + * \since 2.26.0 + */ + PropertyI adaptiveEdgeSensingPlusSharpenThreshold; + /// \brief A floating point property defining the intensity of the sharpening during AdaptiveEdgeSensingPlus deBayering. + /** + * Valid values for this property are between 0. and 100. (percent). + * + * \since 2.26.0 + */ + PropertyF adaptiveEdgeSensingPlusSharpenGain; + /// \brief An integer property defining the parameter set to be used to perform the white balance correction. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TWhiteBalanceParameter. + */ + PropertyIWhiteBalanceParameter whiteBalance; + /// \brief An enumerated integer property defining the mode used for white balance calibration. + /** + * This property can be used to define the way a white balance calibration shall be performed. + * Currently only the \b mvIMPACT::acquire::wbcmNextFrame mode is supported, + * but new modes might appear in later revisions of the interface. + * + * When this property is set to \b mvIMPACT::acquire::wbcmNextFrame the next + * image captured will be used as a reference to calculate the gain factors for the + * \e red, \e green and \e blue channel. So make sure when the next image is captured the camera + * looks on a plain white or slightly grey surface in order to obtain correct results. After + * the calibration has been done, the property will be reset to \b mvIMPACT::acquire::wbcmOff + * again. + * + * \note + * Performing this kind of white balance calibration will only affect Bayer color sensors and will + * only have any visual effect on the image if one of the user definable parameter sets has been + * selected before. This can be done by modifying the property \b mvIMPACT::acquire::ImageProcessing::whiteBalance. + * Afterwards the calculated factors will be stored in the \b mvIMPACT::acquire::WhiteBalanceSettings selected. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TWhiteBalanceCalibrationMode. + */ + PropertyIWhiteBalanceCalibrationMode whiteBalanceCalibration; + /// \brief An enumerated integer property defining the filter to be applied to the image before it is transferred to the user. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageProcessingFilter. + */ + PropertyIImageProcessingFilter filter; + /// \brief An enumerated integer property defining the general mode the mirror filter will work in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TMirrorOperationMode. + */ + PropertyIMirrorOperationMode mirrorOperationMode; + /// \brief An enumerated integer property defining the mirror mode to be applied to ALL channels of the image. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TMirrorMode. + * + * \note This property will only be visible, when \b mvIMPACT::acquire::ImageProcessing::mirrorOperationMode is set + * to \b mvIMPACT::acquire::momGlobal. + */ + PropertyIMirrorMode mirrorModeGlobal; + /// \brief An enumerated integer property defining whether the polarization data extraction filter shall be active or not. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.29.0 + */ + PropertyIBoolean polarizedDataExtractionEnable; + /// \brief An enumerated integer property defining in which mode the polarization data extraction filter shall be operated in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TPolarizedDataExtractionMode. + * + * \since 2.29.0 + */ + PropertyIPolarizedDataExtractionMode polarizedDataExtractionMode; + /// \brief An enumerated integer property defining the interpolation mode the polarization data extraction filter shall be operated in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TPolarizedDataExtractionInterpolationMode. + * + * \note This property will only be available when the polarization data extraction mode is either horizontal, vertical or single. + * + * \since 2.29.0 + */ + PropertyIPolarizedDataExtractionInterpolationMode polarizedDataExtractionInterpolationMode; + /// \brief An integer property defining the channel within the processing window of the polarization data extraction filter. + /** + * This channel will only be taken into account when \b mvIMPACT::acquire::ImageProcessing::polarizedDataExtractionMode is set to + * \b mvIMPACT::acquire::prmExtractSingle. + * + * \since 2.29.0 + */ + PropertyI polarizedDataExtractionChannelIndex; + /// \brief An integer property defining the lower limit of the grey value of a pixel to be taken into account within the processing window of the polarization data extraction filter. + /** + * This limit will only be taken into account when \b mvIMPACT::acquire::ImageProcessing::polarizedDataExtractionMode is set to + * \b mvIMPACT::acquire::prmMeanValue. + * + * \since 2.29.0 + */ + PropertyI polarizedDataExtractionLowerLimit; + /// \brief An integer property defining the upper limit of the grey value of a pixel to be taken into account within the processing window of the polarization data extraction filter. + /** + * This limit will only be taken into account when \b mvIMPACT::acquire::ImageProcessing::polarizedDataExtractionMode is set to + * \b mvIMPACT::acquire::prmMeanValue. + * + * \since 2.29.0 + */ + PropertyI polarizedDataExtractionUpperLimit; + /// \brief An enumerated integer property defining the operation mode of the defective pixels filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDefectivePixelsFilterMode. + */ + PropertyIDefectivePixelsFilterMode defectivePixelsFilterMode; + /// \brief An integer property defining the max. allowed offset from the average grey value for a pixel during calibration. + /** + * When this filter is calibrated each pixel producing a grey value higher than the average grey value plus + * the value of this property will be considered as a leaky pixel and therefore will be replaced by + * a value depending on the operation mode of the filter. + */ + PropertyI defectivePixelsFilterLeakyPixelDeviation_ADCLimit; + /// \brief An integer property defining the max. allowed deviation for a pixel in per cent from the average grey value. + /** + * If this filter is active every pixel that during the calibration produces a grey value which is + * lower than the average grey value of the image minus the allowed deviation in per cent will be + * considered as a cold pixel and therefore will be replaced by a value depending on the operation + * mode of the filter. + */ + PropertyI defectivePixelsFilterColdPixelDeviation_pc; + /// \brief An integer property defining maximum the number of pixels considered as being defective during consecutive calibration runs. + /** + * With this property it is possible to define an upper limit for the number of detected defective pixels. This is not to be meant + * as an error checking mechanism for sensors reporting more defective pixels but to allow an application to keep the length of the + * list of defective pixels within reasonable boundaries. The more pixels a sensor has the higher a reasonable value might be. Set this + * to a value suitable for your application to protect the algorithm from huge lists due to incorrect calibration environments (too much light, + * not enough light, ...). + * + * When after a calibration this value and the value of the \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFound property are the + * same this indicates a problem. There are several possible reasons for this: + * + * - the lighting conditions or calibration parameters have not been set up correctly (fix your setup then) + * - the sensor is damaged (replace the device then) + * - the sensor has more defective pixels then indicated by the value of this property but which are still valid according to the specification of the sensor manufacturer (adjust the value of this property accordingly then) + * + * \attention When reducing this value at runtime excess pixels will be dropped from the current list of defective pixels if the new maximum list length is smaller then the amount of + * defective pixels currently detected. + * + * \attention Some devices might offer to store defective pixels inside the device in an mvIMPACT Acquire compatible format by calling \b mvIMPACT::acquire::ImageProcessing::defectivePixelWriteToDevice. + * However the device might not be able to store all these pixels due to a lack of storage space. Therefore always check the return value of the function! + * + * \note + * In order to get rid of currently detected pixels an application must set the property + * \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode to \b mvIMPACT::acquire::dpfmResetCalibration + * and then capture a fresh image. Only then all currently detected pixels will be discarded. + * + * \since 2.37.0 + */ + PropertyI defectivePixelsMaxDetectionCount; + /// \brief An integer property \b (read-only) containing the number of pixels considered as being defective with respect to the + /// calibration runs executed after the last reset of the calibration data. + /** + * \note + * In order to collect \b ALL defective pixels the list of detected pixels is not emptied each time a new calibration + * is started. In order to get rid of currently detected pixels an application must set the property + * \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode to \b mvIMPACT::acquire::dpfmResetCalibration + * and then capture a fresh image. Only then all currently detected pixels will be discarded. + * + * \since 2.5.9 + */ + PropertyI defectivePixelsFound; + /// \brief An integer property defining a list of X-offsets of all pixels currently treated as defective. + /** + * All these pixels will be replaced depending on the selected algorithm in \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode. + * + * \note + * In order to collect \b ALL defective pixels the list of detected pixels is not emptied each time a new calibration + * is started. In order to get rid of currently detected pixels an application must set the property + * \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode to \b mvIMPACT::acquire::dpfmResetCalibration + * and then capture a fresh image. Only then all currently detected pixels will be discarded. + * + * \since 2.17.1 + */ + PropertyI defectivePixelOffsetX; + /// \brief An integer property defining a list of Y-offsets of all pixels currently treated as defective. + /** + * All these pixels will be replaced depending on the selected algorithm in \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode. + * + * \note + * In order to collect \b ALL defective pixels the list of detected pixels is not emptied each time a new calibration + * is started. In order to get rid of currently detected pixels an application must set the property + * \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode to \b mvIMPACT::acquire::dpfmResetCalibration + * and then capture a fresh image. Only then all currently detected pixels will be discarded. + * + * \since 2.17.1 + */ + PropertyI defectivePixelOffsetY; + /// \brief Calling this method will download defective pixels from the device. + /** + * \note + * In order to collect \b ALL defective pixels the list of detected pixels is not emptied each time a download from the device is executed. + * In order to get rid of currently detected pixels an application must set the property + * \b mvIMPACT::acquire::ImageProcessing::defectivePixelsFilterMode to \b mvIMPACT::acquire::dpfmResetCalibration + * and then capture a fresh image. Only then all currently detected pixels will be discarded. + * + * \attention + * This feature will only be supported by some devices providing a special interface inside their firmware. + * + * \since 2.17.1 + * + * Calling this method will return \n + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. Most likely mvIMPACT::acquire::DMR_FEATURE_NOT_AVAILABLE if the device does not support this feature. + */ + Method defectivePixelReadFromDevice; + /// \brief Calling this method will upload defective pixels from the device. + /** + * \note + * This will \b NOT automatically store this data in non-volatile memory on the device! + * A call to \b mvIMPACT::acquire::GenICam::mvDefectivePixelCorrectionControl::mvDefectivePixelDataSave might be needed! + * + * \attention + * This feature will only be supported by some devices providing a special interface inside their firmware. + * + * \since 2.17.1 + * + * Calling this method will return \n + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. Most likely mvIMPACT::acquire::DMR_FEATURE_NOT_AVAILABLE if the device does not support this feature. + */ + Method defectivePixelWriteToDevice; + /// \brief An enumerated integer property defining the operation mode of the flat field correction filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TFlatFieldFilterMode. + */ + PropertyIFlatFieldFilterMode flatFieldFilterMode; + /// \brief An enumerated integer property defining the correction mode of the flat field correction filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TFlatFieldFilterCorrectionMode. + */ + PropertyIFlatFieldFilterCorrectionMode flatFieldFilterCorrectionMode; + /// \brief An enumerated integer property defining the X-orientation that shall be used when applying the correction. + /** + * When active the calibration image will be applied reversed X direction thus the last correction factor of each line of the correction image will be applied to the first pixel of the image etc.. This can be useful e.g. if the calibration has been done and the device shall transmit the image flipped on a vertical axis in some configurations. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.40.0 + */ + PropertyIBoolean flatFieldFilterCorrectionModeReverseX; + /// \brief An enumerated integer property defining the Y-orientation that shall be used when applying the correction. + /** + * When active the calibration image will be applied reversed Y direction thus the last line of correction factors of the correction image will be applied to the first line of the image etc.. This can be useful e.g. if the calibration has been done and the device shall transmit the image flipped on a horizontal axis in some configurations. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.40.0 + */ + PropertyIBoolean flatFieldFilterCorrectionModeReverseY; + /// \brief An enumerated integer property defining the correction AOI mode of the flat field correction filter. + /** + * When using an AOI only the AOI region is corrected by this filter. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAoiMode. + * + * \since 2.31.0 + */ + PropertyIAoiMode flatFieldFilterCorrectionAoiMode; + /// \brief An integer property defining the correction AOI's X-offset of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCorrectionAoiOffsetX; + /// \brief An integer property defining the correction AOI's Y-offset of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCorrectionAoiOffsetY; + /// \brief An integer property defining the correction AOI's width of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCorrectionAoiWidth; + /// \brief An integer property defining the correction AOI's height of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCorrectionAoiHeight; + /// \brief An integer property defining the number of consecutive images to take into account during the calibration of the flat field filter. + PropertyI flatFieldFilterCalibrationImageCount; + /// \brief An enumerated integer property defining the correction AOI mode of the flat field correction filter. + /** + * When using an AOI only the AOI region is taken into consideration during calibration by this filter. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAoiMode. + * + * \since 2.31.0 + */ + PropertyIAoiMode flatFieldFilterCalibrationAoiMode; + /// \brief An integer property defining the calibration AOI's X-offset of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCalibrationAoiOffsetX; + /// \brief An integer property defining the calibration AOI's Y-offset of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCalibrationAoiOffsetY; + /// \brief An integer property defining the calibration AOI's width of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCalibrationAoiWidth; + /// \brief An integer property defining the calibration AOI's height of the flat field correction filter. + /** + * + * \since 2.31.0 + */ + PropertyI flatFieldFilterCalibrationAoiHeight; + /// \brief An enumerated integer property defining the operation mode of the dark current filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDarkCurrentFilterMode. + */ + PropertyIDarkCurrentFilterMode darkCurrentFilterMode; + /// \brief An integer property defining the number of consecutive images to take into account during calibration of the dark current filter. + PropertyI darkCurrentFilterCalibrationImageCount; + /// \brief An enumerated integer property which can be used to enable the Gain, Offset, Knee filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean gainOffsetKneeEnable; + /// \brief A float property that contains master offset(in percent). + /** + * This offset will be applied before the channel specific gain. + */ + PropertyF gainOffsetKneeMasterOffset_pc; + /// \brief An enumerated integer property which can be used to enable LUT (Look Up Table) transformations. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean LUTEnable; + /// \brief An enumerated integer property which can be used to configure the LUT (Look Up Table) transformation mode. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLUTMode. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse. + */ + PropertyILUTMode LUTMode; + /// \brief An enumerated integer property which can be used to configure the LUT (Look Up Table) interpolation mode. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLUTInterpolationMode. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTMode is \b NOT set to + * \b mvIMPACT::acquire::LUTmInterpolated. + */ + PropertyILUTInterpolationMode LUTInterpolationMode; + /// \brief An enumerated integer property which can be used to configure the LUT (Look Up Table) implementation. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLUTImplementation. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse. + */ + PropertyILUTImplementation LUTImplementation; + /// \brief An enumerated integer property which can be used to configure the LUT (Look Up Table) mapping mode for LUT transformations done by the hardware. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLUTMapping. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTImplementation is \b NOT set to + * \b mvIMPACT::acquire::LUTiHardware. + */ + PropertyILUTMapping LUTMappingHardware; + /// \brief An enumerated integer property which can be used to configure the LUT (Look Up Table) mapping mode for LUT transformations done optimized software algorithms. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLUTMapping. + * + * \note This property will be invisible when \b mvIMPACT::acquire::ImageProcessing::LUTEnable is set to + * \b mvIMPACT::acquire::bFalse or if \b mvIMPACT::acquire::ImageProcessing::LUTImplementation is \b NOT set to + * \b mvIMPACT::acquire::LUTiSoftware. + */ + PropertyILUTMapping LUTMappingSoftware; + /// \brief An enumerated integer property which can be used to enable/disable automatic data re-ordering from image sources delivering data from multiple taps that require re-ordering to reconstruct the image. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean tapSortEnable; + /// \brief An enumerated integer property which can be used to enable/disable automatic data re-ordering or extraction from multi-channel images. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean channelSplitEnable; + /// \brief An enumerated integer property which can be used to define how data from multi-channel images shall be re-ordered. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TChannelSplitMode. + */ + PropertyIChannelSplitMode channelSplitMode; + /// \brief An integer property which can be used to define which channel of the image shall be extracted. + /** + * This property will only be visible if \b mvIMPACT::acquire::ImageProcessing::channelSplitMode is set + * to \b mvIMPACT::acquire::csmExtractSingle. + */ + PropertyI channelSplitChannelIndex; + /// \brief An enumerated integer property which can be used to enable/disable data re-ordering for interlaced images. + /** + * Enabling this feature will cause interlaced images in a way that the 2 fields will be display next to each other. This + * will modify the original image in an image with twice the width but half the height. + * + * \note + * Right now this property will only result in correct results for images, that are line wise interlaced, thus + * some special sensors that e.g. transfer Bayer interlaced data (2 lines field 0, 2 lines field even, etc.) + * can not be re-arranged in a meaningful way. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean channelSplitDeinterlaceEnable; + /// \brief An enumerated integer property which can be used to enable/disable the color twist input correction matrix. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.2.2. + */ + PropertyIBoolean colorTwistInputCorrectionMatrixEnable; + /// \brief An enumerated integer property which can be used to select an input color correction matrix. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TColorTwistInputCorrectionMatrixMode. + * + * \since 2.2.2. + */ + PropertyIColorTwistInputCorrectionMatrixMode colorTwistInputCorrectionMatrixMode; + /// \brief The first row of the input color correction matrix. + /** + * This property stores the first row of a user defined 3x3 input color correction matrix if + * \b mvIMPACT::acquire::ImageProcessing::colorTwistInputCorrectionMatrixMode is set to + * \b mvIMPACT::acquire::cticmmUser. For other values of \b mvIMPACT::acquire::ImageProcessing::colorTwistInputCorrectionMatrixMode + * modifying this property will have no effect. + * + * \since 2.2.2. + */ + PropertyF colorTwistInputCorrectionMatrixRow0; + /// \brief The second row of the input color correction matrix. + /** + * This property stores the second row of a user defined 3x3 input color correction matrix if + * \b mvIMPACT::acquire::ImageProcessing::colorTwistInputCorrectionMatrixMode is set to + * \b mvIMPACT::acquire::cticmmUser. For other values of \b mvIMPACT::acquire::ImageProcessing::colorTwistInputCorrectionMatrixMode + * modifying this property will have no effect. + * + * \since 2.2.2. + */ + PropertyF colorTwistInputCorrectionMatrixRow1; + /// \brief The third row of the input color correction matrix. + /** + * This property stores the third row of a user defined 3x3 input color correction matrix if + * \b mvIMPACT::acquire::ImageProcessing::colorTwistInputCorrectionMatrixMode is set to + * \b mvIMPACT::acquire::cticmmUser. For other values of \b mvIMPACT::acquire::ImageProcessing::colorTwistInputCorrectionMatrixMode + * modifying this property will have no effect. + * + * \since 2.2.2. + */ + PropertyF colorTwistInputCorrectionMatrixRow2; + /// \brief An enumerated integer property which can be used to enable/disable the color twist matrix. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * The color twist filter can be used to apply a linear transformation to a 3 channel image. Each pixel will + * at first be multiplied by a 3x3 matrix and afterwards an offset triplet can be added. + * + * \since 2.2.2. + */ + PropertyIBoolean colorTwistEnable; + /// \brief The first row of the color twist matrix. + /** + * This property stores 4 values. The first 3 components for the first row of the 3x4 matrix, the last component is the + * offset of this row. + * + * \since 2.2.2. + */ + PropertyF colorTwistRow0; + /// \brief The second row of the color twist matrix. + /** + * This property stores 4 values. The first 3 components for the second row of the 3x4 matrix, the last component is the + * offset of this row. + * + * \since 2.2.2. + */ + PropertyF colorTwistRow1; + /// \brief The third row of the color twist matrix. + /** + * This property stores 4 values. The first 3 components for the third row of the 3x4 matrix, the last component is the + * offset of this row. + * + * \since 2.2.2. + */ + PropertyF colorTwistRow2; + /// \brief An enumerated integer property which can be used to enable/disable the color twist output correction matrix. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.2.2. + */ + PropertyIBoolean colorTwistOutputCorrectionMatrixEnable; + /// \brief An enumerated integer property which can be used to select an output color correction matrix. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TColorTwistOutputCorrectionMatrixMode. + * + * \since 2.2.2. + */ + PropertyIColorTwistOutputCorrectionMatrixMode colorTwistOutputCorrectionMatrixMode; + /// \brief The first row of the output color correction matrix. + /** + * This property stores the first row of a user defined 3x3 output color correction matrix if + * \b mvIMPACT::acquire::ImageProcessing::colorTwistOutputCorrectionMatrixMode is set to + * \b mvIMPACT::acquire::ctocmmUser. For other values of \b mvIMPACT::acquire::ImageProcessing::colorTwistOutputCorrectionMatrixMode + * modifying this property will have no effect. + * + * \since 2.2.2. + */ + PropertyF colorTwistOutputCorrectionMatrixRow0; + /// \brief The second row of the output color correction matrix. + /** + * This property stores the second row of a user defined 3x3 output color correction matrix if + * \b mvIMPACT::acquire::ImageProcessing::colorTwistOutputCorrectionMatrixMode is set to + * \b mvIMPACT::acquire::ctocmmUser. For other values of \b mvIMPACT::acquire::ImageProcessing::colorTwistOutputCorrectionMatrixMode + * modifying this property will have no effect. + * + * \since 2.2.2. + */ + PropertyF colorTwistOutputCorrectionMatrixRow1; + /// \brief The third row of the output color correction matrix. + /** + * This property stores the third row of a user defined 3x3 output color correction matrix if + * \b mvIMPACT::acquire::ImageProcessing::colorTwistOutputCorrectionMatrixMode is set to + * \b mvIMPACT::acquire::ctocmmUser. For other values of \b mvIMPACT::acquire::ImageProcessing::colorTwistOutputCorrectionMatrixMode + * modifying this property will have no effect. + * + * \since 2.2.2. + */ + PropertyF colorTwistOutputCorrectionMatrixRow2; + /// \brief The first row of the resulting color twist matrix. + /** + * This property will store the first row of the 3x4 resulting color twist matrix. This matrix + * is created by multiplying the input correction matrix by the color twist matrix by the output correction matrix. + * Only active matrices will be used to calculate the resulting matrix. + * + * \since 2.2.2. + */ + PropertyF colorTwistResultingMatrixRow0; + /// \brief The second row of the resulting color twist matrix. + /** + * This property will store the second row of the 3x4 resulting color twist matrix. This matrix + * is created by multiplying the input correction matrix by the color twist matrix by the output correction matrix. + * Only active matrices will be used to calculate the resulting matrix. + * + * \since 2.2.2. + */ + PropertyF colorTwistResultingMatrixRow1; + /// \brief The third row of the resulting color twist matrix. + /** + * This property will store the third row of the 3x4 resulting color twist matrix. This matrix + * is created by multiplying the input correction matrix by the color twist matrix by the output correction matrix. + * Only active matrices will be used to calculate the resulting matrix. + * + * \since 2.2.2. + */ + PropertyF colorTwistResultingMatrixRow2; + /// \brief An enumerated integer property which can be used to enable/disable the format reinterpreter filter. + /** + * This filter can be used if a device transmits data in a non-compliant or incorrect format. Using this filter the incoming + * data will simply be treated as a different pixel format then. This will \b NOT copy or modify the pixel data but will only + * adjust some of the elements describing the buffer (e.g. the pixel format and width). When e.g. setting this filter to treat + * mono data as RGB data, this will result in buffers with a width divided by 3 but RGB pixels instead of mono pixel afterwards. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.10.1 + */ + PropertyIBoolean formatReinterpreterEnable; + /// \brief An enumerated integer property which can be used to configure the format reinterpreter filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageBufferFormatReinterpreterMode. + * + * \since 2.10.1 + */ + PropertyIImageBufferFormatReinterpreterMode formatReinterpreterMode; + /// \brief An enumerated integer property defining the new Bayer parity of this buffer. + /** + * After applying the format reinterpreter this will be the new Bayer parity of the buffer when the filter is operated + * in one of the \c Mono \c To \c Mono modes. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBayerMosaicParity. + * + * \since 2.31.0 + */ + PropertyIBayerMosaicParity formatReinterpreterBayerMosaicParity; + /// \brief An enumerated integer property which can be used to enable/disable the rotation filter. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.13.2 + */ + PropertyIBoolean rotationEnable; + /// \brief The counterclockwise angle at which the image will be rotated. + /** + * This property will store the counterclockwise angle at which the image will be rotated. + * + * \since 2.13.2 + */ + PropertyF rotationAngle; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Sets the saturation by using the color twist matrix. + /** + * The following saturation formula is used: + * + * \code + * [0.299 + 0.701*K , 0.587*(1-K) , 0.114*(1-K) ] + * [0.299*(1-K) + 0.701*K , 0.587 , 0.114*(1-K) ] + * [0.299*(1-K) + 0.701*K , 0.587*(1-K) , 0.114 + 0.886*K ] + * \endcode + * + * K is the saturation factor + * K > 1 increases saturation + * K = 1 means no change + * 0 < K < 1 decreases saturation + * K = 0 produces B&W + * K < 0 inverts color + * + * \note + * To enable/disable the saturation the application must write to \b mvIMPACT::acquire::ImageProcessing::colorTwistEnable. + */ + void setSaturation( + /// [in] The saturation value. + double K ) + { + std::vector row( 3, 0. ); + row[0] = 0.299 + 0.701 * K; + row[1] = 0.587 * ( 1 - K ); + row[2] = 0.114 * ( 1 - K ); + colorTwistRow0.write( row, true ); + row[0] = 0.299 * ( 1 - K ); + row[1] = 0.587 + 0.413 * K; + row[2] = 0.114 * ( 1 - K ); + colorTwistRow1.write( row, true ); + row[0] = 0.299 * ( 1 - K ); + row[1] = 0.587 * ( 1 - K ); + row[2] = 0.114 + 0.886 * K; + colorTwistRow2.write( row, true ); + } + /// \brief Returns a reference to a set of user definable parameters to configure a certain channel of the GainOffsetKnee filter. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A reference to one of the parameter sets for the GainOffsetKnee filter that + * can be altered by the user. + */ + GainOffsetKneeChannelParameters& getGainOffsetKneeParameter( + /// [in] The index of the gain, offset, knee parameter set to be returned + unsigned int index ) const + { + return *( m_pRefData->m_GainOffsetKneeParameters.at( index ) ); + } + /// \brief Returns the number of available user definable parameter sets for the GainOffsetKnee filter. + unsigned int getGainOffsetKneeParameterCount( void ) const + { + return static_cast( m_pRefData->m_GainOffsetKneeParameters.size() ); + } + /// \brief Returns a reference to a set of user definable parameters to configure mirror filter related features. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A reference to one of the parameter sets for mirror filter related features that + * can be altered by the user. + */ + MirrorParameters& getMirrorParameter( + /// [in] The index of the mirror parameter set to be returned + unsigned int index ) const + { + return *( m_pRefData->m_MirrorParameters.at( index ) ); + } + /// \brief Returns the number of available user definable parameter sets mirror filter related operations. + unsigned int getMirrorParameterCount( void ) const + { + return static_cast( m_pRefData->m_MirrorParameters.size() ); + } + /// \brief Returns a reference to a set of user definable parameters to configure LUT (Look Up Table) operations. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A reference to one of the parameter sets for LUT (Look Up Table) operations that + * can be altered by the user. + */ + LUTParameters& getLUTParameter( + /// [in] The index of the LUT parameter set to be returned + unsigned int index ) const + { + return *( m_pRefData->m_LUTParameters.at( index ) ); + } + /// \brief Returns the number of available user definable parameter sets for LUT (Look Up Table) operations. + unsigned int getLUTParameterCount( void ) const + { + return static_cast( m_pRefData->m_LUTParameters.size() ); + } + /// \brief Returns a reference to a set of user definable parameters to perform a white balance correction. + /** + * Pass '0' for the setting that is activated by setting the property \b mvIMPACT::acquire::ImageProcessing::whiteBalance + * to \b mvIMPACT::acquire::wbpUser1, '1' for + * \b mvIMPACT::acquire::wbpUser2 and so on. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A reference to one of the parameter sets for white balance correction that + * can be altered by the user. + */ + WhiteBalanceSettings& getWBUserSetting( + /// [in] The index of the white balance parameter set to be returned + unsigned int index ) const + { + return *( m_pRefData->m_WBUserSettings.at( index ) ); + } + /// \brief Returns the number of available user definable parameter sets for white balance correction. + unsigned int getWBUserSettingsCount( void ) const + { + return static_cast( m_pRefData->m_WBUserSettings.size() ); + } +}; + + + +//----------------------------------------------------------------------------- +/// \brief Convenience class to provide an easy way for a more precise white balance calibration. +/** + * A convenience function which will be used to do a white balance calibration + * with more than 8bit image data to increase the precision of the calculated + * gain values. + * + * \note + * Since a homogeneous grey image is needed for the processing, it is necessary + * that the camera is not configured to a triggered mode and a reasonable + * exposure time. + */ +class WhiteBalancer +//----------------------------------------------------------------------------- +{ +public: + + static void highQualityWhiteBalance( Device* pDev ) + { + FunctionInterface fi( pDev ); + ImageProcessing ip( pDev ); + fi.saveCurrentSettingOnStack(); + + PropertyI64 pixelFormat; + DeviceComponentLocator locator( pDev, dltSetting, "" ); + locator.bindComponent( pixelFormat, "PixelFormat" ); + + std::vector availablePixelFormats; + pixelFormat.getTranslationDictStrings( availablePixelFormats ); + std::string sBayerColorMask; + bool boIsBayer = false; + bool boIsMono = false; + int iMaxBitDepth = 0; + const std::string bayerToken = "Bayer"; + const std::string monoToken = "Mono"; + + for( std::vector::size_type i = 0; i != availablePixelFormats.size(); i++ ) + { + boIsBayer = ( availablePixelFormats[i].find( bayerToken ) ) != std::string::npos; + boIsMono = ( availablePixelFormats[i].find( monoToken ) ) != std::string::npos; + std::string sTempBitDepth = ""; + for( size_t j = 0; j < availablePixelFormats[i].length(); j++ ) + { + if( isdigit( availablePixelFormats[i][j] ) ) + { + sTempBitDepth += availablePixelFormats[i][j]; + } + if( boIsBayer ) + { + if( sBayerColorMask == "" ) + { + // extract the Bayer parity AFTER the word 'Bayer' + const std::string::size_type len = bayerToken.length(); + sBayerColorMask += availablePixelFormats[i][len]; + sBayerColorMask += availablePixelFormats[i][len + 1]; + } + } + } + const int iTempBitDepth = atoi( sTempBitDepth.c_str() ); + if( iTempBitDepth > iMaxBitDepth ) + { + iMaxBitDepth = iTempBitDepth; + } + } + + const std::string sPixelFormatPrefix = ( boIsBayer && !boIsMono ) ? bayerToken : monoToken; + std::ostringstream sOptimalPixelFormat; + sOptimalPixelFormat << sPixelFormatPrefix << sBayerColorMask << iMaxBitDepth; + + try + { + pixelFormat.writeS( sOptimalPixelFormat.str() ); + } + catch( const ImpactAcquireException& ) {} + + PropertyF balanceRatio; + PropertyI64 balanceRatioSelector; + locator.bindComponent( balanceRatio, "BalanceRatio" ); + locator.bindComponent( balanceRatioSelector, "BalanceRatioSelector" ); + + if( ( pDev->interfaceLayout.read() == dilGenICam ) && balanceRatioSelector.isValid() && balanceRatio.isValid() ) + { + try + { + balanceRatioSelector.writeS( "Red" ); + balanceRatio.write( 1.00 ); + + balanceRatioSelector.writeS( "Blue" ); + balanceRatio.write( 1.00 ); + } + catch( const ImpactAcquireException& ) {} + } + + ip.whiteBalance.write( wbpUser1 ); + ip.whiteBalanceCalibration.write( wbcmNextFrame ); + + fi.imageRequestSingle(); + fi.acquisitionStart(); + int requestNr = fi.imageRequestWaitFor( 8000 ); + Request* pRequest = fi.isRequestNrValid( requestNr ) ? fi.getRequest( requestNr ) : 0; + if( pRequest ) + { + pRequest->unlock(); + } + fi.acquisitionStop(); + + WhiteBalanceSettings& wbs( ip.getWBUserSetting( 0 ) ); + const double dRedGain = wbs.redGain.read(); + const double dGreenGain = wbs.greenGain.read(); + const double dBlueGain = wbs.blueGain.read(); + + fi.loadAndDeleteSettingFromStack(); + + if( ( pDev->interfaceLayout.read() == dilGenICam ) && balanceRatioSelector.isValid() && balanceRatio.isValid() ) + { + balanceRatioSelector.writeS( "Red" ); + balanceRatio.write( dRedGain / dGreenGain ); + + balanceRatioSelector.writeS( "Blue" ); + balanceRatio.write( dBlueGain / dGreenGain ); + } + else + { + wbs.redGain.write( dRedGain ); + wbs.greenGain.write( dGreenGain ); + wbs.blueGain.write( dBlueGain ); + } + } +}; + +//----------------------------------------------------------------------------- +/// \brief Contains basic statistical information. +/** + * This class contains basic statistical information about the \b mvIMPACT::acquire::Device and the + * the current image acquisition progress. + */ +class Statistics : public ComponentCollection +//----------------------------------------------------------------------------- +{ + Method m_resetStatistics; +public: + explicit Statistics( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : ComponentCollection( pDev ), m_resetStatistics(), captureTime_s(), + bandwidthConsumed(), errorCount(), abortedRequestsCount(), timedOutRequestsCount(), framesPerSecond(), + frameCount(), imageProcTime_s(), formatConvertTime_s(), queueTime_s(), lostImagesCount(), + framesIncompleteCount(), missingDataAverage_pc(), retransmitCount() + { + DeviceComponentLocator locator( pDev, dltStatistics ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( m_resetStatistics, "ResetStatistics@i" ); + locator.bindComponent( captureTime_s, "CaptureTime_s" ); + locator.bindComponent( bandwidthConsumed, "BandwidthConsumed" ); + locator.bindComponent( errorCount, "ErrorCount" ); + locator.bindComponent( abortedRequestsCount, "AbortedRequestsCount" ); + locator.bindComponent( timedOutRequestsCount, "TimedOutRequestsCount" ); + locator.bindComponent( framesPerSecond, "FramesPerSecond" ); + locator.bindComponent( frameCount, "FrameCount" ); + locator.bindComponent( imageProcTime_s, "ImageProcTime_s" ); + locator.bindComponent( formatConvertTime_s, "FormatConvertTime_s" ); + locator.bindComponent( queueTime_s, "QueueTime_s" ); + locator.bindComponent( lostImagesCount, "LostImagesCount" ); + locator.bindComponent( framesIncompleteCount, "FramesIncompleteCount" ); + locator.bindComponent( missingDataAverage_pc, "MissingDataAverage_pc" ); + locator.bindComponent( retransmitCount, "RetransmitCount" ); + } + /// \brief Resets all statistical properties. + /** + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int reset( void ) const + { + if( !m_resetStatistics.isValid() ) + { + return DMR_FEATURE_NOT_AVAILABLE; + } + return m_resetStatistics.call(); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A float property \b (read-only) containing the overall time an image request spent in the device drivers processing chain. + /** + * This time is \b NOT the reciprocal of the frame rate, but usually a much longer period of time as it includes the time + * elapsed from sending the request into the capture queue until the buffer has been placed back into one of the result queues again. + * This time increases with the amount of requests being used. + */ + PropertyF captureTime_s; + /// \brief A float property \b (read-only) containing the current bandwidth consumed by this device in KB/s based on the average buffer size and the timestamps delivered from the device driver. + /** + * \since 2.12.3 + */ + PropertyF bandwidthConsumed; + /// \brief An integer property \b (read-only) containing the overall count of image requests which returned with an error since the + /// \b mvIMPACT::acquire::Device has been opened OR since the last call to \b mvIMPACT::acquire::Statistics::reset(). + PropertyI errorCount; + /// \brief An integer property \b (read-only) containing the overall count of image requests which have been aborted since the + /// \b mvIMPACT::acquire::Device has been opened OR since the last call to \b mvIMPACT::acquire::Statistics::reset(). + PropertyI abortedRequestsCount; + /// \brief An integer property \b (read-only) containing the overall count of image requests which have timed out since the + /// \b mvIMPACT::acquire::Device has been opened OR since the last call to \b mvIMPACT::acquire::Statistics::reset(). + PropertyI timedOutRequestsCount; + /// \brief A float property \b (read-only) containing the current number of frames captured per second. + PropertyF framesPerSecond; + /// \brief An integer property \b (read-only) containing the overall count of images captured since the + /// \b mvIMPACT::acquire::Device has been opened OR since the last call to \b mvIMPACT::acquire::Statistics::reset(). + /** + * This counter is incremented regardless of the result a request is returned with thus also e.g. if a request did time out, was aborted(e.g. due to a call to \b mvIMPACT::acquire::FunctionInterface::imageRequestReset or \b mvIMPACT::acquire::FunctionInterface::acquisitionStop) or the data was not completely captured. + */ + PropertyI frameCount; + /// \brief An integer property \b (read-only) containing the time (in seconds) needed to process the image data internally. + /** + * This time might be interesting e.g. if the image data is transformed into a color + * image by the driver (e.g. when working with Bayer mosaic cameras) or if any other processing function is applied to the + * image before it is transferred to the user. + */ + PropertyF imageProcTime_s; + /// \brief An integer property \b (read-only) containing the time (in seconds) needed to convert the image data delivered by the hardware and/or active internal driver filter nodes to the format specified by \b mvIMPACT::acquire::ImageDestination::pixelFormat internally. + /** + * This time will be almost 0 when no custom destination pixel format has been specified and if a custom destination format + * was selected and this format differs from the pixel format that is transferred by the hardware this time will be a part + * (or all, but never more) than the time reported by \b mvIMPACT::acquire::Statistics::imageProcTime_s. + * + * \since 1.12.58 + * + */ + PropertyF formatConvertTime_s; + /// \brief A float property \b (read-only) containing the average time (in seconds) a \b mvIMPACT::acquire::Request object spends in the request queue of the device. + /** + * This is the time between a call to \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle() and the time the driver actually uses this buffer + * to capture data into it or to forward it into a kernel driver. + */ + PropertyF queueTime_s; + /// \brief An integer property \b (read-only) containing the number of images that have been lost from a continuous image stream coming from a video signal source. + /** + * \note + * For some devices this value is based on an assumption so it's by no means absolutely accurate, but when this + * value starts to increase this might indicate that a problem is present. + * + * Possible causes (among others) might be: + * - the capture device or device driver can't cope with the amount of data the video signal source is delivering in the current mode of operation + * - the capture device or device driver can't transfer all the data to the host PC because of bus bandwidth shortages + * - the capture device or device driver image request queue ran low because the system is busy doing other things or because of a bug + * in the application + * + * \note + * This feature is supported by every device driver. If a device does not seem to support this feature (calling \b mvIMPACT::acquire::Component::isValid returns false) + * a driver update will fix this. + */ + PropertyI lostImagesCount; + /// \brief An integer property \b (read-only) containing the overall count of image requests which haven't been captured completely since the \b mvIMPACT::acquire::Device has been opened. + /** + * This value is a good indicator for bandwidth problems on the device to host connection. + * + * \note + * This feature is supported by every device driver. If a device does not seem to support this feature (calling \b mvIMPACT::acquire::Component::isValid returns false) + * a driver update will fix this. + */ + PropertyI framesIncompleteCount; + /// \brief A float property \b (read-only) containing the average amount of data missing in frames that haven't been captured completely since the \b mvIMPACT::acquire::Device has been opened OR since the last call to \b mvIMPACT::acquire::Statistics::reset(). + /** + * This value is a good indicator for bandwidth problems on the device to host connection. + * + * \note + * This feature is supported by every device driver. If a device does not seem to support this feature (calling \b mvIMPACT::acquire::Component::isValid returns false) + * a driver update will fix this. + */ + PropertyF missingDataAverage_pc; + /// \brief A 64 bit integer property \b (read-only) containing the number of retransmit requests issued due to temporary bus bandwidth shortages or other transmission problems since this \b mvIMPACT::acquire::Device has been opened OR since the last call to \b mvIMPACT::acquire::Statistics::reset(). + /** + * This value can be an indicator for transmission problems because of bad signal quality or bus + * bandwidth shortages in the system. + * Ideally this property should stay 0 all the time if the system can cope with the amount of data transferred and the signal + * quality is good. However it might increase slowly and still every frame will be flawless as the driver internally was + * able to restore the lost data by re-requesting it from the video signal source again. + * + * \note + * This feature is supported by every device driver. If a device does not seem to support this feature (calling \b mvIMPACT::acquire::Component::isValid returns false) + * a driver update will fix this. + */ + PropertyI64 retransmitCount; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class that provides access to the most common settings for a device. +/** + * Use one of the classes derived from this class to get access to all the available + * settings. + */ +class FullSettingsBase +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::FullSettingsBase object. + explicit FullSettingsBase( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : imageProcessing( pDev, settingName ), imageDestination( pDev, settingName ), basedOn() + { + DeviceComponentLocator locator( pDev, dltSetting, settingName ); + locator.bindComponent( basedOn, "BasedOn" ); + } + virtual ~FullSettingsBase() {} + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief Image processing related properties. + ImageProcessing imageProcessing; + /// \brief Properties to define the result images format. + ImageDestination imageDestination; + /// \brief A string property \b (read-only) containing the name of the setting this setting is based on. + PropertyS basedOn; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +#ifndef WRAP_ANY +/// \brief \b deprecated. Use the class \b mvIMPACT::acquire::Statistics instead +/** + * \deprecated + * This class has been declared \b deprecated and might not be available in future releases. + * All features of this class are available in \b mvIMPACT::acquire::Statistics as well, so please use + * this class instead. + */ +typedef Statistics MVIMPACT_DEPRECATED_CPP( StatisticsBase ); +#endif // #ifndef WRAP_ANY + +//----------------------------------------------------------------------------- +/// \brief A base class for accessing settings that control the overall behaviour of a device driver. +/** + * Instances of this class can't be constructed directly. Use one of the derived types. + */ +class SystemSettings : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::SystemSettings object. + explicit SystemSettings( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : ComponentCollection( pDev ), requestCount(), + acquisitionMode(), acquisitionIdleTimeMax_ms(), imageProcessingMode(), imageProcessingMaximumThreadCount(), imageProcessingOptimization(), + featurePollingEnable(), featurePollingInterval_ms(), methodPollingInterval_ms(), methodPollingMaxRetryCount() + { + DeviceComponentLocator locator( pDev, dltSystemSettings ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( requestCount, "RequestCount" ); + locator.bindComponent( acquisitionMode, "AcquisitionMode" ); + locator.bindComponent( acquisitionIdleTimeMax_ms, "AcquisitionIdleTimeMax_ms" ); + locator.bindComponent( imageProcessingMode, "ImageProcessingMode" ); + locator.bindComponent( imageProcessingMaximumThreadCount, "ImageProcessingMaximumThreadCount" ); + locator.bindComponent( imageProcessingOptimization, "ImageProcessingOptimization" ); + locator.bindComponent( featurePollingEnable, "FeaturePollingEnable" ); + locator.bindComponent( featurePollingInterval_ms, "FeaturePollingInterval_ms" ); + locator.bindComponent( methodPollingInterval_ms, "MethodPollingInterval_ms" ); + locator.bindComponent( methodPollingMaxRetryCount, "MethodPollingMaxRetryCount" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the number of requests allocated by the driver. + /** + * Each request object can be used to capture data into. Multiple requests can be processed + * by a device driver as background tasks. + * + * Setting this property to a value at least allowing a driver to capture data for up to 500ms without user interaction (thus 0.5 times the expected frame rate) is highly + * recommended. Increasing this value will NOT introduce additional latency to your application. The only drawback will be additional RAM consumption by the driver but + * applications that do not need to copy the request buffers can even benefit from that as the overall memory fragmentation is likely to go down then. + * Values smaller than 3 most likely result in undesired behaviour and should be avoided unless absolutely needed. + * + * \note For performance reasons this value can be increased at any time(only exception: Working with the interface layout + * \b mvIMPACT::acquire::dilGenICam while streaming is active) but can only be + * decreased when no request object is currently locked by the application and no requests has been + * queued for acquisition. So modifying this value might require the application to call \b mvIMPACT::acquire::FunctionInterface::imageRequestReset + * and several calls to \b mvIMPACT::acquire::Request::unlock before. + * + * There are not too many reasons to modify the default request count suggested by the device driver. Good reasons include: + * + * - a single image is huge compared to the overall system memory(e.g. a single image has 200MB while the system itself only + * has about 2GB of RAM. Here it might make sense to reduce the number of capture buffers to 1 or 2. Please note that in such a + * scenario double buffering or live display when one buffer is constantly blocked by the display engine can become a challenge! + * - the frame rate is high(larger than 100 frames per second) and no frames shall be lost. Here it might make sense to set + * the number of capture buffers to something like frame rate divided by 2 to 5 as a rule of thumb. + * + * \sa + * \b mvIMPACT::acquire::FunctionInterface::requestCount + */ + PropertyI requestCount; + /// \brief An enumerated integer property defining the acquisition mode of the device. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAcquisitionMode. + */ + PropertyIAcquisitionMode acquisitionMode; + /// \brief An integer property defining the maximum time in ms the driver waits for new requests being queued until streaming by the device will automatically be stopped. + /** + * This property defines the maximum time in milliseconds the driver waits for new \b mvIMPACT::acquire::Request objects being + * queued by calling \b mvIMPACT::acquire::FunctionInterface::imageRequestSingle once the driver will automatically send an + * acquisition stop command to a streaming device (such as a GigE Vision or USB3 Vision device) when the driver's request queue has run empty (thus the + * driver has no more buffers to capture data into). + * + * This property will only be taken into account when \b mvIMPACT::acquire::Device::acquisitionStartStopBehaviour has been set to + * \b mvIMPACT::acquire::assbDefault. + * + * \note + * This property will not be available for every device. Right now only devices operated through the \a GenTL driver package will support + * this feature. + * + * \since 2.4.1 + */ + PropertyI acquisitionIdleTimeMax_ms; + /// \brief An enumerated integer property influencing the behaviour of the internal image processing pipeline. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageProcessingMode. + * + * \note + * This property will only be available if \b mvIMPACT::acquire::Device::userControlledImageProcessingEnable has been + * set to \b mvIMPACT::acquire::bTrue before the device is opened. + * + * \sa + * \b mvIMPACT::acquire::Device::userControlledImageProcessingEnable \n + * \b mvIMPACT::acquire::Request::hasProcessingBeenSkipped + * + * \since 2.14.0 + * + */ + PropertyIImageProcessingMode imageProcessingMode; + /// \brief An integer property influencing the number of parallel threads used by the internal image processing pipeline. + /** + * This property can be used to control the size of the internal thread pool used for image processing tasks. Using + * a value higher than the number of physical CPU cores usually has a negative impact on the performance. Use with care! + * + * \note + * This property will only be available on some platforms. Always check if this property is available before using it! + * + * \sa + * \b mvIMPACT::acquire::SystemSettings::imageProcessingOptimization \n + * \b mvIMPACT::acquire::SystemSettings::imageProcessingMode \n + * \ref ImageProcessing_General_Multithreading + * + * \since 2.41.0 + * + */ + PropertyI imageProcessingMaximumThreadCount; + /// \brief An enumerated integer property influencing the behaviour of the internal image processing algorithms. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageProcessingOptimization. + * + * \since 2.12.2 + */ + PropertyIImageProcessingOptimization imageProcessingOptimization; + /// \brief An enumerated integer property defining whether features defining a polling time shall be updated automatically or not. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \sa mvIMPACT::acquire::SystemSettings::featurePollingInterval_ms + */ + PropertyIBoolean featurePollingEnable; + /// \brief An integer property defining the polling interval in ms the driver waits for each iteration before running through update loop again. + /** + * Some features define a so called \c polling \c time. This is a recommendation by the device/driver stating that this property + * might change it's value without user interaction act a certain rate (e.g. the device temperature could be one example for a + * feature with such a behaviour). When \b mvIMPACT::acquire::SystemSettings::featurePollingEnable is set to + * \b mvIMPACT::acquire::bTrue a thread will check every \c featurePollingInterval_ms if features need to be updated. This will + * only cause communication with a device for each feature who's polling time has elapsed. + * + * \note + * This property will not be available for every device. Right now only devices operated through the \a GenTL driver package will support + * this feature. + * + * \since 2.18.3 + */ + PropertyI featurePollingInterval_ms; + /// \brief An integer property defining the polling interval in ms the driver waits during each iteration before checking a methods execution state again. + /** + * When working with a GenICam compliant device, GenICam method objects need to be checked for their completion status every now + * and then. This parameter defines how often this shall be done. + * + * \note + * This property will not be available for every device. Right now only devices operated through the \a GenTL driver package will support + * this feature. + * + * \since 2.18.3 + */ + PropertyI methodPollingInterval_ms; + /// \brief An integer property defining the polling interval in ms the driver waits during each iteration before checking a methods execution state again. + /** + * When working with a GenICam compliant device, GenICam method objects need to be checked for their completion status every now + * and then. This parameter defines how often this shall be done at all. A method is checked for completion \c + * methodPollingMaxRetryCount * \c methodPollingInterval_ms at max. Until then either the device starts to inform the driver + * that it needs more time \b OR the execution of the method has completed successfully \b or an error will be generated. + * + * \note + * This property will not be available for every device. Right now only devices operated through the \a GenTL driver package will support + * this feature. + * + * \since 2.18.3 + */ + PropertyI methodPollingMaxRetryCount; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +#ifndef WRAP_ANY +/// \brief \b deprecated. Use the class \b mvIMPACT::acquire::SystemSettings instead +/** + * \deprecated + * This class has been declared \b deprecated and might not be available in future releases. + * All features of this class are available in \b mvIMPACT::acquire::SystemSettings as well, so please use + * this class instead. + */ +typedef SystemSettings MVIMPACT_DEPRECATED_CPP( SystemBase ); +#endif // #ifndef WRAP_ANY + +/// @} + +#ifndef IGNORE_MVDEVICE_SPECIFIC_INTERFACE_DOCUMENTATION + +/// \defgroup DeviceSpecificInterface Device specific interface layout +/// \brief Classes and functions that will be available if the device is used in \a device \a specific interface layout. +/// +/// This group contains classes and functions that will be available if the device is used +/// in \b mvIMPACT::acquire::dilDeviceSpecific interface layout. +/// +/// @{ + +#if defined(WRAP_JAVA) || defined(BUILD_FOR_JAVA) +typedef EnumPropertyI PropertyIAcquisitionField; +typedef EnumPropertyI PropertyIAutoControlSpeed; +typedef EnumPropertyI PropertyIAutoControlMode; +typedef EnumPropertyI PropertyIAutoExposureControl; +typedef EnumPropertyI PropertyIAutoGainControl; +typedef EnumPropertyI PropertyIAutoOffsetCalibration; +typedef EnumPropertyI PropertyIBlueFOXDigitalInputThreshold; +typedef EnumPropertyI PropertyIBlueFOXFooterMode; +typedef EnumPropertyI PropertyIBlueFOXInfoSensorCapabilities; +typedef EnumPropertyI PropertyIBlueFOXOffsetAutoBlackSpeed; +typedef EnumPropertyI PropertyIBlueFOXSensorTiming; +typedef EnumPropertyI PropertyIBlueFOXTransferSize; +typedef EnumPropertyI PropertyICameraAoiMode; +typedef EnumPropertyI PropertyICameraBinningMode; +typedef EnumPropertyI PropertyICameraDataFormat; +typedef EnumPropertyI PropertyICameraExposeMode; +typedef EnumPropertyI PropertyICameraExternalSyncEdge; +typedef EnumPropertyI PropertyICameraExternalSyncOutput; +typedef EnumPropertyI PropertyICameraFlashMode; +typedef EnumPropertyI PropertyICameraFlashType; +typedef EnumPropertyI PropertyICameraHDRMode; +typedef EnumPropertyI PropertyICameraInterlacedType; +typedef EnumPropertyI PropertyICameraLinkDataValidMode; +typedef EnumPropertyI PropertyICameraPixelClock; +typedef EnumPropertyI PropertyICameraScanMode; +typedef EnumPropertyI PropertyICameraShutterMode; +typedef EnumPropertyI PropertyICameraTapsXGeometry; +typedef EnumPropertyI PropertyICameraTapsYGeometry; +typedef EnumPropertyI PropertyICameraTriggerMode; +typedef EnumPropertyI PropertyICameraTestMode; +typedef EnumPropertyI PropertyICameraSerialPortBaudRate; +typedef EnumPropertyI PropertyICameraTriggerSource; +typedef EnumPropertyI PropertyIClampMode; +typedef EnumPropertyI PropertyIDeviceAdvancedOptions; +typedef EnumPropertyI PropertyIDeviceDigitalOutputMode; +typedef EnumPropertyI PropertyIDeviceEventMode; +typedef EnumPropertyI PropertyIDeviceEventType; +typedef EnumPropertyI PropertyIDeviceImageTrigger; +typedef EnumPropertyI PropertyIDevicePowerMode; +typedef EnumPropertyI PropertyIDeviceScanRateMode; +typedef EnumPropertyI PropertyIDeviceSignalOutputStartEvent; +typedef EnumPropertyI PropertyIDeviceSyncOutMode; +typedef EnumPropertyI PropertyIDeviceTriggerInterface; +typedef EnumPropertyI PropertyIDeviceTriggerMode; +typedef EnumPropertyI PropertyIDigIOState; +typedef EnumPropertyI PropertyIDigitalIOMeasurementMode; +typedef EnumPropertyI PropertyIDigitalIOMeasurementSource; +typedef EnumPropertyI PropertyIDigitalOutputControlMode; +typedef EnumPropertyI PropertyIDigitalSignal; +typedef std::vector > TDigitalSignalTranslationDict; +typedef EnumPropertyI PropertyIFieldGateMode; +typedef EnumPropertyI PropertyII2COperationMode; +typedef EnumPropertyI PropertyII2COperationStatus; +typedef EnumPropertyI PropertyIInfoSensorColorMode; +typedef EnumPropertyI PropertyIInfoSensorType; +typedef EnumPropertyI PropertyIInterlacedMode; +typedef EnumPropertyI PropertyILineCounter; +typedef EnumPropertyI PropertyIMemoryManagerMode; +typedef EnumPropertyI PropertyIMemoryManagerPoolMode; +typedef EnumPropertyI PropertyIOnBoardMemoryMode; +typedef EnumPropertyI PropertyIPulseStartTrigger; +typedef EnumPropertyI PropertyIRTCtrlModes; +typedef EnumPropertyI PropertyIRTProgOpCodes; +typedef EnumPropertyI PropertyIScanClock; +typedef EnumPropertyI PropertyIScanStandard; +typedef EnumPropertyI PropertyITriggerMoment; +typedef EnumPropertyI PropertyIVideoStandard; +typedef EnumPropertyI PropertyIVirtualDeviceImageType; +typedef EnumPropertyI PropertyIVirtualDeviceTestMode; +#else +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAcquisitionField. +typedef EnumPropertyI PropertyIAcquisitionField; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAutoControlSpeed. +typedef EnumPropertyI PropertyIAutoControlSpeed; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAutoControlMode. +typedef EnumPropertyI PropertyIAutoControlMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAutoExposureControl. +typedef EnumPropertyI PropertyIAutoExposureControl; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAutoGainControl. +typedef EnumPropertyI PropertyIAutoGainControl; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TAutoOffsetCalibration. +typedef EnumPropertyI PropertyIAutoOffsetCalibration; + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBlueFOXDigitalInputThreshold. +typedef EnumPropertyI PropertyIBlueFOXDigitalInputThreshold; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBlueFOXFooterMode. +typedef EnumPropertyI PropertyIBlueFOXFooterMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBlueFOXInfoSensorCapabilities. +typedef EnumPropertyI PropertyIBlueFOXInfoSensorCapabilities; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBlueFOXOffsetAutoBlackSpeed. +typedef EnumPropertyI PropertyIBlueFOXOffsetAutoBlackSpeed; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBlueFOXSensorTiming. +typedef EnumPropertyI PropertyIBlueFOXSensorTiming; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TBlueFOXTransferSize. +typedef EnumPropertyI PropertyIBlueFOXTransferSize; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraAoiMode. +typedef EnumPropertyI PropertyICameraAoiMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraBinningMode. +typedef EnumPropertyI PropertyICameraBinningMode; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraDataFormat. +typedef EnumPropertyI PropertyICameraDataFormat; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraExposeMode. +typedef EnumPropertyI PropertyICameraExposeMode; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraExternalSyncEdge. +typedef EnumPropertyI PropertyICameraExternalSyncEdge; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraExternalSyncOutput. +typedef EnumPropertyI PropertyICameraExternalSyncOutput; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraFlashMode. +typedef EnumPropertyI PropertyICameraFlashMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraFlashType. +typedef EnumPropertyI PropertyICameraFlashType; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraHDRMode. +typedef EnumPropertyI PropertyICameraHDRMode; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraInterlacedType. +typedef EnumPropertyI PropertyICameraInterlacedType; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraLinkDataValidMode. +typedef EnumPropertyI PropertyICameraLinkDataValidMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraPixelClock. +typedef EnumPropertyI PropertyICameraPixelClock; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraScanMode. +typedef EnumPropertyI PropertyICameraScanMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraShutterMode. +typedef EnumPropertyI PropertyICameraShutterMode; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraTapsXGeometry. +typedef EnumPropertyI PropertyICameraTapsXGeometry; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraTapsYGeometry. +typedef EnumPropertyI PropertyICameraTapsYGeometry; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraTriggerMode. +typedef EnumPropertyI PropertyICameraTriggerMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraTestMode. +typedef EnumPropertyI PropertyICameraTestMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraSerialPortBaudRate. +typedef EnumPropertyI PropertyICameraSerialPortBaudRate; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TCameraTriggerSource. +typedef EnumPropertyI PropertyICameraTriggerSource; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TClampMode. +typedef EnumPropertyI PropertyIClampMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceAdvancedOptions. +typedef EnumPropertyI PropertyIDeviceAdvancedOptions; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceDigitalOutputMode. +typedef EnumPropertyI PropertyIDeviceDigitalOutputMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceEventMode. +typedef EnumPropertyI PropertyIDeviceEventMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceEventType. +typedef EnumPropertyI PropertyIDeviceEventType; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceImageTrigger. +typedef EnumPropertyI PropertyIDeviceImageTrigger; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDevicePowerMode. +typedef EnumPropertyI PropertyIDevicePowerMode; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceScanRateMode. +typedef EnumPropertyI PropertyIDeviceScanRateMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceSignalOutputStartEvent. +typedef EnumPropertyI PropertyIDeviceSignalOutputStartEvent; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceSyncOutMode. +typedef EnumPropertyI PropertyIDeviceSyncOutMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceTriggerInterface. +typedef EnumPropertyI PropertyIDeviceTriggerInterface; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDeviceTriggerMode. +typedef EnumPropertyI PropertyIDeviceTriggerMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDigIOState. +typedef EnumPropertyI PropertyIDigIOState; + +#ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDigitalIOMeasurementMode. +typedef EnumPropertyI PropertyIDigitalIOMeasurementMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDigitalIOMeasurementSource. +typedef EnumPropertyI PropertyIDigitalIOMeasurementSource; +#endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDigitalOutputControlMode. +typedef EnumPropertyI PropertyIDigitalOutputControlMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TDigitalSignal. +typedef EnumPropertyI PropertyIDigitalSignal; +typedef std::vector > TDigitalSignalTranslationDict; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TFieldGateMode. +typedef EnumPropertyI PropertyIFieldGateMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TI2COperationMode. +typedef EnumPropertyI PropertyII2COperationMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TI2COperationStatus. +typedef EnumPropertyI PropertyII2COperationStatus; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TInfoSensorColorMode. +typedef EnumPropertyI PropertyIInfoSensorColorMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TInfoSensorType. +typedef EnumPropertyI PropertyIInfoSensorType; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TInterlacedMode. +typedef EnumPropertyI PropertyIInterlacedMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TLineCounter. +typedef EnumPropertyI PropertyILineCounter; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +#if !defined(IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TMemoryManagerMode. +typedef EnumPropertyI PropertyIMemoryManagerMode; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TMemoryManagerPoolMode. +typedef EnumPropertyI PropertyIMemoryManagerPoolMode; +#endif // #if !defined(IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TOnBoardMemoryMode. +typedef EnumPropertyI PropertyIOnBoardMemoryMode; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TPulseStartTrigger. +typedef EnumPropertyI PropertyIPulseStartTrigger; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TRTCtrlModes. +typedef EnumPropertyI PropertyIRTCtrlModes; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TRTProgOpCodes. +typedef EnumPropertyI PropertyIRTProgOpCodes; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TScanClock. +typedef EnumPropertyI PropertyIScanClock; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TScanStandard. +typedef EnumPropertyI PropertyIScanStandard; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TTriggerMoment. +typedef EnumPropertyI PropertyITriggerMoment; + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TVideoStandard. +typedef EnumPropertyI PropertyIVideoStandard; +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +#ifndef IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TVirtualDeviceImageType. +typedef EnumPropertyI PropertyIVirtualDeviceImageType; +/// \brief Defines a property for values defined by \b mvIMPACT::acquire::TVirtualDeviceTestMode. +typedef EnumPropertyI PropertyIVirtualDeviceTestMode; +#endif // #ifndef IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +#endif // #if defined(WRAP_JAVA) || defined(BUILD_FOR_JAVA) + +# ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief An interface class to access DMA memory related properties(\b Device specific interface layout only). +/** + * This class can be used to configure the way the device works with DMA memory. + * This is an advanced feature and shall only be used if necessary or to + * fine tune an application to achieve optimal performance. + * + * All frame grabbers belonging to the mvTITAN, mvGAMMA, mvSIGMA and mvDELTA series use a special, + * preallocated block of memory(DMA memory) as target for fast image transfer. The total size of + * this block has to be set during driver installation. The memory is claimed from the operating + * system during startup and is shared between all installed devices. + * + * The memory size needed to achieve optimal performance depends on the image size to grab, the queue depth + * and the mode the memory manager is operated in. + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TMemoryManagerMode + * and can be selected by modifying the property \b mvIMPACT::acquire::ImageMemoryManager::mode. + * + * \note This class is currently available for frame grabber devices only. + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class ImageMemoryManager : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::ImageMemoryManager object. + explicit ImageMemoryManager( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : ComponentCollection( pDev ), + mode(), allocatedDMAMemory_bytes(), + usedDMAMemory_bytes(), usedBlocks(), + poolMode(), poolBlockSize_bytes(), + poolBlockCount() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltImageMemoryManager ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mode, "Mode" ); + locator.bindComponent( allocatedDMAMemory_bytes, "AllocatedDMAMemory_bytes" ); + locator.bindComponent( usedDMAMemory_bytes, "UsedDMAMemory_bytes" ); + locator.bindComponent( usedBlocks, "UsedBlocks" ); + locator.bindComponent( poolMode, "PoolMode" ); + locator.bindComponent( poolBlockSize_bytes, "PoolBlockSize_bytes" ); + locator.bindComponent( poolBlockCount, "PoolBlockCount" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property containing the mode the memory manager is currently operated in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TMemoryManagerMode. + */ + PropertyIMemoryManagerMode mode; + /// \brief An integer property \b (read-only) containing the size of the allocated DMA memory (in bytes). + PropertyI allocatedDMAMemory_bytes; + /// \brief An integer property \b (read-only) containing the size of the DMA memory (in bytes) currently used by the device. + PropertyI usedDMAMemory_bytes; + /// \brief An integer property \b (read-only) containing the number of individual blocks of DMA memory currently used by the device. + PropertyI usedBlocks; + /// \brief An enumerated integer property containing the mode the memory managers memory pool is currently operated in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TMemoryManagerPoolMode. + */ + PropertyIMemoryManagerPoolMode poolMode; + /// \brief An integer property defining the size (in bytes) to use for each block of DMA memory. + PropertyI poolBlockSize_bytes; + /// \brief An integer property \b (read-only) containing the number of individual blocks of DMA memory currently available when using the current pool block size and pool mode. + PropertyI poolBlockCount; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +# if !defined(IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) +//----------------------------------------------------------------------------- +/// \brief A more specific class to query information about a \b mvBlueDevice device and its driver(\b Device specific interface layout only). +/** + * This class contains a collection of properties providing various information about + * a \b mvBlueDevice device and its driver. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class InfoBlueDevice : public Info +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::InfoBlueDevice object. + explicit InfoBlueDevice( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : Info( pDev ), + sensorXRes(), sensorYRes(), sensorColorMode(), sensorType() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + ComponentLocator locator( m_hRoot, "Camera" ); + locator.bindComponent( sensorXRes, "SensorXRes" ); + locator.bindComponent( sensorYRes, "SensorYRes" ); + locator.bindComponent( sensorColorMode, "SensorColorMode" ); + locator.bindComponent( sensorType, "SensorType" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property \b (read-only) containing the horizontal resolution of the camera sensor. + /** + * If the device has more than one sensor head, and all these sensor heads can be accessed using the current interface, + * this property will contain as many values as the devices offers sensor heads. + */ + PropertyI sensorXRes; + /// \brief An integer property \b (read-only) containing the vertical resolution of the camera sensor. + /** + * If the device has more than one sensor head, and all these sensor heads can be accessed using the current interface, + * this property will contain as many values as the devices offers sensor heads. + */ + PropertyI sensorYRes; + /// \brief An enumerated integer property \b (read-only) containing the type of the sensor (color/mono/...)(if known). + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TInfoSensorColorMode. + * + * \note + * If nothing is known about this feature, this property will contain \b mvIMPACT::acquire::iscmUnknown. + * + * If the device has more than one sensor head, and all these sensor heads can be accessed using the current interface, + * this property will contain as many values as the devices offers sensor heads. + */ + PropertyIInfoSensorColorMode sensorColorMode; + /// \brief An enumerated integer property \b (read-only) containing the type of sensor chip of the camera (if known). + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TInfoSensorType. + * + * This usually will either be \b mvIMPACT::acquire::istCCD or \b mvIMPACT::acquire::istCMOS. + * + * If the device has more than one sensor head, and all these sensor heads can be accessed using the current interface, + * this property will contain as many values as the devices offers sensor heads. + */ + PropertyIInfoSensorType sensorType; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #if !defined(IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) + +# ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A more specific class to query information about a \b mvBlueCOUGAR devices and its driver(\b Device specific interface layout only). +/** + * This class contains a collection of properties providing various information about + * a \b mvBlueCOUGAR devices and its driver. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class InfoBlueCOUGAR : public InfoBlueDevice +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::InfoBlueCOUGAR object. + explicit InfoBlueCOUGAR( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : InfoBlueDevice( pDev ), deviceFPGAVersion() + { + ComponentLocator locator( m_hRoot, "Camera" ); + locator.bindComponent( deviceFPGAVersion, "DeviceFPGAVersion" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A 64 bit integer property \b (read-only) containing the current FPGA version of this device. + /** + * \note + * This feature is only supported by \b mvBlueCOUGAR-S devices. + */ + PropertyI64 deviceFPGAVersion; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A more specific class to query information about a \b mvBlueFOX device and its driver(\b Device specific interface layout only). +/** + * This class contains a collection of properties providing various information about + * a \b mvBlueFOX device and its driver. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class InfoBlueFOX : public InfoBlueDevice +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::InfoBlueFOX object. + explicit InfoBlueFOX( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : InfoBlueDevice( pDev ), firmwareVersion(), sensorFPGAVersion(), sensorCaps(), + deviceSensorRevision(), userEEPROMSize(), deviceTemperature() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( firmwareVersion, "FirmwareVersion" ); + locator.bindSearchBase( locator.searchbase_id(), "Camera" ); + locator.bindComponent( sensorFPGAVersion, "SensorFPGAVersion" ); + locator.bindComponent( sensorCaps, "SensorCaps" ); + locator.bindComponent( deviceSensorRevision, "DeviceSensorRevision" ); + locator.bindComponent( userEEPROMSize, "UserEEPROMSize" ); + locator.bindComponent( deviceTemperature, "DeviceTemperature" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property \b (read-only) containing the firmware version of this device. + PropertyI firmwareVersion; + /// \brief An integer property \b (read-only) containing the FPGA version of the camera(if known). + /** + * \note + * If nothing is known about this feature, this property will contain '-1'. + */ + PropertyI sensorFPGAVersion; + /// \brief An integer property \b (read-only) containing a bit mask containing information about the sensors capabilities(if known). + /** + * \note + * If nothing is known about this feature, this property will contain '-1'. + */ + PropertyIBlueFOXInfoSensorCapabilities sensorCaps; + /// \brief A 64 bit integer property \b (read-only) containing the current revision of the sensor head of this device. + /** + * \note + * This feature is currently not supported by all sensors. If a sensor can't provide this information, the value + * of this property will remain 0 at all time. + * + * \since 1.12.65 + */ + PropertyI64 deviceSensorRevision; + /// \brief An integer property \b (read-only) containing the size of the user EEPROM that can be accessed using the I2C access features of \b mvIMPACT::acquire::I2CControl. + /** + * \note + * The size may vary depending on the product. Even different products with the same sensor might report + * different values here. + * + * \note + * The user EEPROM uses a virtual I2C address of 0x1A2 for write access and 0x1A3 for read access. + */ + PropertyI userEEPROMSize; + /// \brief A float property \b (read-only) containing the temperature of the selected temperature sensor on the device in degrees Celsius. + /** + * \note + * This property will not be available for every mvBlueFOX. Right now this feature is only implemented for + * 202d version of the mvBlueFOX. + * + * \since 1.12.62 + * + */ + PropertyF deviceTemperature; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief A class to represent a digital input pin(\b Device specific interface layout only). +/** + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class DigitalInput +//----------------------------------------------------------------------------- +{ + friend class IOSubSystem; + HDRV m_hDrv; + PropertyI m_register; + int m_bitNumber; + std::string m_description; + explicit DigitalInput( HDRV hDrv, PropertyI reg, int bitNumber, const std::string& desc ) : m_hDrv( hDrv ), m_register( reg ), m_bitNumber( bitNumber ), m_description( desc ) {} +public: + /// \brief Returns the current state of this input pin. + /** + * \return + * - true if the current state of this pin is considered as 'logic 1' + * - false otherwise + */ + bool get( void ) const + { + const TDMR_ERROR result = DMR_UpdateDigitalInputs( m_hDrv ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return m_register.read( m_bitNumber ) != 0; + } + /// \brief Returns a description for this digital input. + /** + * This might contain connector descriptions or other information like + * e.g. 'Trigger-In(J8.4/J8.5)', which means, this is the trigger input + * of connector \a J8 pins \a 4 and \a 5. + */ + std::string getDescription( void ) const + { + return m_description; + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class to represent a digital output pin(\b Device specific interface layout only). +/** + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class DigitalOutput +//----------------------------------------------------------------------------- +{ + friend class IOSubSystem; + PropertyI m_register; + int m_bitNumber; + std::string m_description; + explicit DigitalOutput( PropertyI reg, int bitNumber, const std::string& desc ) : m_register( reg ), m_bitNumber( bitNumber ), m_description( desc ) {} +public: + /// \brief Inverts the current state of the digital output and returns the previous state. + /** + * \return + * - true if the previous state of this pin was considered as 'logic 1' + * - false otherwise + */ + bool flip( void ) + { + bool oldState = get(); + m_register.write( !oldState, m_bitNumber ); + return oldState; + } + /// \brief Returns the current state of this output pin. + /** + * \return + * - true if the current state of this pin is considered as 'logic 1' + * - false otherwise + */ + bool get( void ) const + { + return m_register.read( m_bitNumber ) != 0; + } + /// \brief Checks if the caller has write/modify access to this digital output. + /** + * Some devices will offer access to digital outputs, but these outputs can't be switched manually. + * E.g. a device might offer a digital output that can only be configured to stay either high or + * low during frame exposure but can't be switched to high at a certain user defined moment. For + * such an output, this function will return false. + * + * If the user calls a function belonging to this class that would modify the state of the + * associated digital output, an exception will be raised. + * + * \return + * - true if the caller is allowed to call write/modify operation for this component. + * - false otherwise. + */ + bool isWriteable( void ) const + { + return m_register.isWriteable(); + } + /// \brief Sets the output pin to 'logic 1'. + void set( void ) + { + m_register.write( 1, m_bitNumber ); + } + /// \brief Sets the output pin to 'logic 0'. + void reset( void ) + { + m_register.write( 0, m_bitNumber ); + } + /// \brief Returns a description for this digital output. + /** + * This might contain connector descriptions or other information like + * e.g. 'CC1(J1)', which means, this is the CameraLink® control + * channel 1 of connector \a J1. + */ + std::string getDescription( void ) const + { + return m_description; + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class to represent a sync. output pin(\b Device specific interface layout only). +/** + * Instances of this class can be used to define and generate sync. signals + * at the corresponding outputs of the device. + * + * \note + * Instances of this class can't be constructed directly, but must be obtained + * via the device specific class derived from \b mvIMPACT::acquire::IOSubSystem. + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class SyncOutput : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class IOSubSystem; + explicit SyncOutput( HLIST hList ) : ComponentCollection( hList ), frequency_Hz(), lowPart_pc() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( frequency_Hz, "Frequency_Hz" ); + locator.bindComponent( lowPart_pc, "LowPart_pc" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A float property defining the frequency(in Hertz) for the sync. signal generated by this pin. + PropertyF frequency_Hz; + /// \brief A float property defining the width in percent the sync. signal stays low during one period. The output signal generated will be a square pulse. + PropertyF lowPart_pc; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Returns a description for this sync. output. + /** + * This might contain connector descriptions or other information like + * e.g. 'VD-OUT(J9.24)', which means, this is the VD output at connector J9 + * pin 24. + */ + std::string getDescription( void ) const + { + return ComponentList( m_hRoot ).name(); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class to represent one step of a real time control(\b RTCtr) program (\b Device specific interface layout only). +/** + * An object of this class represents a single instruction in a program represented + * by an \b mvIMPACT::acquire::RTCtrProgram. \b mvIMPACT::acquire::RTCtrProgramStep object can't be constructed + * directly, but must be accessed via the function + * \b mvIMPACT::acquire::RTCtrProgram::programStep of the program they belong + * to. + * + * The instruction this \b mvIMPACT::acquire::RTCtrProgramStep will executed when the program is + * executed is defined by the property \b mvIMPACT::acquire::RTCtrProgramStep::opCode. Depending + * on the value of this property certain other parameters will influence the + * behaviour of this instruction. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class RTCtrProgramStep : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class RTCtrProgram; + explicit RTCtrProgramStep( HOBJ hObj ) : ComponentCollection( hObj ), address(), frameID(), clocks_us(), + digitalInputs(), digitalOutputs(), sensorHeads(), opCode(), controllerRegister(), + registerValue() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( address, "Address" ); + locator.bindComponent( frameID, "FrameID" ); + locator.bindComponent( clocks_us, "Clocks_us" ); + locator.bindComponent( digitalInputs, "DigitalInputs" ); + locator.bindComponent( digitalOutputs, "DigitalOutputs" ); + locator.bindComponent( sensorHeads, "SensorHeads" ); + locator.bindComponent( opCode, "OpCode" ); + locator.bindComponent( controllerRegister, "ControllerRegister" ); + locator.bindComponent( registerValue, "RegisterValue" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property, which defines the absolute jump address within this \b mvIMPACT::acquire::RTCtrProgram. + /** + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to \b mvIMPACT::acquire::rtctrlProgJumpLoc. + */ + PropertyI address; + /// \brief An integer property, which defines the frame ID of the triggered image \b mvIMPACT::acquire::RTCtrProgram. + /** + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to \b mvIMPACT::acquire::rtctrlProgTriggerSet. + */ + PropertyI frameID; + /// \brief An integer property, which defines the waiting time \b mvIMPACT::acquire::RTCtrProgram. + /** + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to \b mvIMPACT::acquire::rtctrlProgWaitClocks. + */ + PropertyI clocks_us; + /// \brief An enumerated integer property to define for which digital input state this program step waits for. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigIOState. + * + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to \b mvIMPACT::acquire::rtctrlProgWaitDigin. + */ + PropertyIDigIOState digitalInputs; + /// \brief An enumerated integer property to define how to set the digital outputs of this device. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigIOState. + * + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to \b mvIMPACT::acquire::rtctrlProgSetDigout. + */ + PropertyIDigIOState digitalOutputs; + /// \brief An enumerated integer property to define which sensor heads to trigger (for devices with more than one sensor head). + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigIOState. + * + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to \b mvIMPACT::acquire::rtctrlProgTriggerSet + * or \b mvIMPACT::acquire::rtctrlProgTriggerReset. + */ + PropertyIDigIOState sensorHeads; + /// \brief An enumerated integer property defining the general purpose of this \b mvIMPACT::acquire::RTCtrProgramStep object. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TRTProgOpCodes. + */ + PropertyIRTProgOpCodes opCode; + /// \brief An integer property, which defines the index of the controller register to refer in this \b mvIMPACT::acquire::RTCtrProgramStep. + /** + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to + * \b mvIMPACT::acquire::rtctrlProgRegisterSet, \b mvIMPACT::acquire::rtctrlProgRegisterAdd, + * \b mvIMPACT::acquire::rtctrlProgRegisterSub, \b mvIMPACT::acquire::rtctrlProgJumpLocOnZero + * or \b mvIMPACT::acquire::rtctrlProgJumpLocOnNotZero. + * + * \note + * This feature will not be available for every device offering a HRTC. It will be available if the translation + * dictionary of the property \b mvIMPACT::acquire::RTCtrProgramStep::opCode contains + * \b mvIMPACT::acquire::rtctrlProgRegisterSet, \b mvIMPACT::acquire::rtctrlProgRegisterAdd, + * \b mvIMPACT::acquire::rtctrlProgRegisterSub, \b mvIMPACT::acquire::rtctrlProgJumpLocOnZero + * or \b mvIMPACT::acquire::rtctrlProgJumpLocOnNotZero. + * + * Read the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyI controllerRegister; + /// \brief An integer property, which defines the a value to associate with a register access in this \b mvIMPACT::acquire::RTCtrProgramStep. + /** + * This property only is taken into account, if \b mvIMPACT::acquire::RTCtrProgramStep::opCode is set to + * \b mvIMPACT::acquire::rtctrlProgRegisterSet, \b mvIMPACT::acquire::rtctrlProgRegisterAdd + * or \b mvIMPACT::acquire::rtctrlProgRegisterSub. + * + * \note + * This feature will not be available for every device offering a HRTC. It will be available if the translation + * dictionary of the property \b mvIMPACT::acquire::RTCtrProgramStep::opCode contains + * \b mvIMPACT::acquire::rtctrlProgRegisterSet, \b mvIMPACT::acquire::rtctrlProgRegisterAdd, + * or \b mvIMPACT::acquire::rtctrlProgRegisterSub. + * + * Read the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyI registerValue; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class to represent real time control programs(\b Device specific interface layout only). +/** + * Real time control programs can be used to control the way how an when images + * are exposed and transmitted to the user. + * + * An \b mvIMPACT::acquire::RTCtrProgram e.g. can be used to achieve a constant frame rate with + * a desired frequency. This can be done e.g. by triggering the camera with a constant frequency. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * An appropriate signal for triggering the camera can be generated as follows: + * \code + * #include + * + * using namespace mvIMPACT::acquire; + * + * void runAt10Hz( Device* pBF ) + * { + * CameraSettingsBlueFOX bfs( pBF ); + * IOSubSystemBlueFOX bfIOs( pBF ); + * // define a HRTC program that results in a define image frequency + * // the hardware real time controller shall be used to trigger an image + * bfs.triggerSource.write( ctsRTCtrl ); + * // when the hardware real time controller switches the trigger signal to + * // high the exposure of the image shall start + * bfs.triggerMode.write( ctmOnRisingEdge ); + * + * // error checks + * if( bfIOs.RTCtrProgramCount() == 0 ) + * { + * // no HRTC controllers available (this never happens for the mvBlueFOX) + * return; + * } + * + * RTCtrProgram* pRTCtrlProgram = bfIOs.getRTCtrProgram( 0 ); + * if( !pRTCtrlProgram ) + * { + * // this only should happen if the system is short of memory + * return; + * } + * + * // start of the program + * + * // we need 5 steps for the program + * pRTCtrlProgram->setProgramSize(5); + * + * // wait a certain amount of time to achieve the desired frequency + * int progStep = 0; + * RTCtrProgramStep* pRTCtrlStep = 0; + * pRTCtrlStep = pRTCtrlProgram->programStep( progStep++ ); + * pRTCtrlStep->opCode.write( rtctrlProgWaitClocks ); + * pRTCtrlStep->clocks_us.write( 99900 ); + * + * // trigger an image + * pRTCtrlStep = pRTCtrlProgram->programStep( progStep++ ); + * pRTCtrlStep->opCode.write( rtctrlProgTriggerSet ); + * + * // high time for the trigger signal (should not be smaller than 100 us) + * pRTCtrlStep = pRTCtrlProgram->programStep( progStep++ ); + * pRTCtrlStep->opCode.write( rtctrlProgWaitClocks ); + * pRTCtrlStep->clocks_us.write( 100 ); + * + * // end trigger signal + * pRTCtrlStep = pRTCtrlProgram->programStep( progStep++ ); + * pRTCtrlStep->opCode.write( rtctrlProgTriggerReset ); + * + * // restart the program + * pRTCtrlStep = pRTCtrlProgram->programStep( progStep++ ); + * pRTCtrlStep->opCode.write( rtctrlProgJumpLoc ); + * pRTCtrlStep->address.write( 0 ); + * + * // start the program + * pRTCtrlProgram->mode.write( rtctrlModeRun ); + * + * // Now this camera will deliver images at exactly 10 Hz ( 1 / ( 99900 us + 100us ) ) + * // when it is constantly feed with image requests. + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * //============================================================================= + * public static void runAt10Hz( Device pBF ) + * //============================================================================= + * { + * CameraSettingsBlueFOX bfs = new CameraSettingsBlueFOX( pBF ); + * IOSubSystemBlueFOX bfIOs = new IOSubSystemBlueFOX( pBF ); + * // define a HRTC program that results in a define image frequency + * // the hardware real time controller shall be used to trigger an image + * bfs.getTriggerSource().write( TCameraTriggerSource.ctsRTCtrl ); + * // when the hardware real time controller switches the trigger signal to + * // high the exposure of the image shall start + * bfs.getTriggerMode().write( TCameraTriggerMode.ctmOnRisingEdge ); + * + * // error checks + * if( bfIOs.RTCtrProgramCount() == 0 ) + * { + * // no HRTC controllers available (this never happens for the mvBlueFOX) + * return; + * } + * + * RTCtrProgram pRTCtrlProgram = bfIOs.getRTCtrProgram( 0 ); + * if( pRTCtrlProgram == null ) + * { + * // this only should happen if the system is short of memory + * return; + * } + * + * // start of the program + * + * // we need 5 steps for the program + * pRTCtrlProgram.setProgramSize(5); + * + * // wait a certain amount of time to achieve the desired frequency + * int progStep = 0; + * RTCtrProgramStep pRTCtrlStep = null; + * pRTCtrlStep = pRTCtrlProgram.programStep( progStep++ ); + * pRTCtrlStep.getOpCode().write( TRTProgOpCodes.rtctrlProgWaitClocks ); + * pRTCtrlStep.getClocks_us().write( 99900 ); + * + * // trigger an image + * pRTCtrlStep = pRTCtrlProgram.programStep( progStep++ ); + * pRTCtrlStep.getOpCode().write( TRTProgOpCodes.rtctrlProgTriggerSet ); + * + * // high time for the trigger signal (should not be smaller than 100 us) + * pRTCtrlStep = pRTCtrlProgram.programStep( progStep++ ); + * pRTCtrlStep.getOpCode().write( TRTProgOpCodes.rtctrlProgWaitClocks ); + * pRTCtrlStep.getClocks_us().write( 100 ); + * + * // end trigger signal + * pRTCtrlStep = pRTCtrlProgram.programStep( progStep++ ); + * pRTCtrlStep.getOpCode().write( TRTProgOpCodes.rtctrlProgTriggerReset ); + * + * // restart the program + * pRTCtrlStep = pRTCtrlProgram.programStep( progStep++ ); + * pRTCtrlStep.getOpCode().write( TRTProgOpCodes.rtctrlProgJumpLoc ); + * pRTCtrlStep.getAddress().write( 0 ); + * + * // start the program + * pRTCtrlProgram.getMode().write( TRTCtrlModes.rtctrlModeRun ); + * + * // Now this camera will deliver images at exactly 10 Hz ( 1 / ( 99900 us + 100us ) ) + * // when it is constantly feed with image requests. + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * def runAt10Hz(pBF): + * bfs = acquire.CameraSettingsBlueFOX(pBF) + * bfIOs = acquire.IOSubSystemBlueFOX(pBF) + * # define a HRTC program that results in a define image frequency + * # the hardware real time controller shall be used to trigger an image + * bfs.triggerSource.write(acquire.ctsRTCtrl) + * # when the hardware real time controller switches the trigger signal to + * # high the exposure of the image shall start + * bfs.triggerMode.write(acquire.ctmOnRisingEdge) + * + * # error checks + * if bfIOs.RTCtrProgramCount == 0: + * # no HRTC controllers available (this never happens for the mvBlueFOX) + * return + * + * pRTCtrlProgram = bfIOs.getRTCtrProgram(0) + * if pRTCtrlProgram == None: + * # this only should happen if the system is short of memory + * return + * + * # start of the program + * # we need 5 steps for the program + * pRTCtrlProgram.setProgramSize(5) + * # wait a certain amount of time to achieve the desired frequency + * progStep = 0 + * pRTCtrlStep = None + * pRTCtrlStep = pRTCtrlProgram.programStep(progStep) + * pRTCtrlStep.opCode.write(acquire.rtctrlProgWaitClocks) + * pRTCtrlStep.clocks_us.write(99900) + * + * # trigger an image + * progStep = progStep + 1 + * pRTCtrlStep = pRTCtrlProgram.programStep(progStep) + * pRTCtrlStep.opCode.write(acquire.rtctrlProgTriggerSet) + * + * # high time for the trigger signal (should not be smaller than 100 us) + * progStep = progStep + 1 + * pRTCtrlStep = pRTCtrlProgram.programStep(progStep) + * pRTCtrlStep.opCode.write(acquire.rtctrlProgWaitClocks) + * pRTCtrlStep.clocks_us.write(100) + * + * # end trigger signal + * progStep = progStep + 1 + * pRTCtrlStep = pRTCtrlProgram.programStep(progStep) + * pRTCtrlStep.opCode.write(acquire.rtctrlProgTriggerReset) + * + * # restart the program + * progStep = progStep + 1 + * pRTCtrlStep = pRTCtrlProgram.programStep(progStep) + * pRTCtrlStep.opCode.write(acquire.rtctrlProgJumpLoc) + * pRTCtrlStep.address.write(0) + * + * # start the program + * pRTCtrlProgram.mode.write(acquire.rtctrlModeRun) + * + * # Now this camera will deliver images at exactly 10 Hz (1 / (99900 us + 100us)) + * # when it is constantly feed with image requests. + * \endcode + * \endif + * + * Once this program has been defined it can be executed by setting the \a mode + * property to \b mvIMPACT::acquire::rtctrlModeRun. As in this example we do not + * wait for an external signal the property \b triggerMode + * must be set to a value demanding an external signal + * (e.g. \b mvIMPACT::acquire::ctmOnHighLevel ; You will find a summary of the valid + * trigger modes in the sensor specific data in the "Sensor data" chapter of the + * specific product manual. \b triggerMode must be set to \b mvIMPACT::acquire::ctsRTCtrl + * to inform the driver that the signal generate by the real time program shall + * be used as the trigger signal. + * + * \note + * \b mvIMPACT::acquire::RTCtrProgram objects can't be created directly! To access an \b mvIMPACT::acquire::RTCtrProgram + * associated with a certain device create an instance of an object derived from + * \b mvIMPACT::acquire::IOSubSystem and then use the function + * \b mvIMPACT::acquire::IOSubSystem::RTCtrProgramCount() to find out if there are + * hardware real time controller machines available for this device and if so how + * many of them can be accessed. Pointers to the machines then can be obtained by calling the + * function \b mvIMPACT::acquire::IOSubSystem::getRTCtrProgram() with the number of the + * controller (zero based) to be modified. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class RTCtrProgram : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class IOSubSystem; + typedef std::vector RTCtrlProgramStepVector; +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + HDRV m_hDrv; + mutable RTCtrlProgramStepVector m_programSteps; + PropertyI m_programSize; + HLIST m_hRTCtrList; + HOBJ m_programStepList; + unsigned int m_refCnt; + explicit ReferenceCountedData( HDRV hDrv, HLIST hList ) : m_hDrv( hDrv ), m_programSteps(), m_programSize(), + m_hRTCtrList( hList ), m_programStepList(), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + RTCtrlProgramStepVector::size_type vSize = m_programSteps.size(); + for( RTCtrlProgramStepVector::size_type i = 0; i < vSize; i++ ) + { + delete m_programSteps[i]; + } + } + }* m_pRefData; +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + void bindPublicProperties( HLIST hList ) + //----------------------------------------------------------------------------- + { + ComponentLocator locator( hList ); + locator.bindComponent( mode, "Mode" ); + locator.bindComponent( filename, "Filename" ); + locator.bindComponent( programState, "ProgramState" ); + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + void updateProgram( void ) const + //----------------------------------------------------------------------------- + { + RTCtrlProgramStepVector::size_type vSize = m_pRefData->m_programSteps.size(); + unsigned int lSize = ComponentList( m_pRefData->m_programStepList ).size(); + if( lSize < vSize ) + { + // steps have been deleted somewhere... + for( unsigned int i = lSize; i < vSize; i++ ) + { + delete m_pRefData->m_programSteps[i]; + } + m_pRefData->m_programSteps.resize( lSize ); + } + else if( lSize > vSize ) + { + // new steps have been created + Component iter( m_pRefData->m_programStepList ); + iter = iter.firstChild(); + // move to the next valid end point + for( unsigned int i = 0; i < vSize; i++ ) + { + ++iter; + } + + while( iter.isValid() ) + { + m_pRefData->m_programSteps.push_back( new RTCtrProgramStep( iter ) ); + ++iter; + } + } + } + //----------------------------------------------------------------------------- + explicit RTCtrProgram( HDRV hDrv, HLIST hList ) : ComponentCollection( hList ), + m_pRefData( new ReferenceCountedData( hDrv, hList ) ), mode(), filename(), programState() + //----------------------------------------------------------------------------- + { + ComponentLocator locator( hList ); + locator.bindComponent( m_pRefData->m_programSize, "ProgramSize" ); + bindPublicProperties( m_pRefData->m_hRTCtrList ); + m_pRefData->m_programStepList = locator.findComponent( "RTCtrProgram" ); + updateProgram(); + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::RTCtrProgram from an existing one. + RTCtrProgram( + /// [in] A constant reference to the \b mvIMPACT::acquire::RTCtrProgram object, this object shall be created from + const RTCtrProgram& src ) : ComponentCollection( src.m_hRoot ), m_pRefData( src.m_pRefData ), mode( src.mode ), + filename( src.filename ), programState( src.programState ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + ~RTCtrProgram() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::RTCtrProgram objects. + RTCtrProgram& operator=( const RTCtrProgram& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + bindPublicProperties( m_pRefData->m_hRTCtrList ); + } + return *this; + } + /// \brief A function to define the number of instructions this program should consist of. + void setProgramSize( + /// [in] The new number of program instructions + int newSize ) + { + m_pRefData->m_programSize.write( newSize ); + updateProgram(); + } + /// \brief Returns the number of program instructions for this program. + /** + * \return The number of program instructions for this program. + */ + int getProgramSize( void ) const + { + return m_pRefData->m_programSize.read(); + } + /// \brief Returns a pointer to a program instruction of the program. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A pointer to a program instruction of the program. + */ + RTCtrProgramStep* programStep( + /// [in] The index of the program instruction to obtain. + unsigned int nr ) const + { + updateProgram(); + return m_pRefData->m_programSteps.at( nr ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the current state this program is into. + /** + * In order to affect the behaviour of the image acquisition an \b mvIMPACT::acquire::RTCtrProgram must be in + * running mode. Apart from that the property \b triggerSource must be set + * appropriately. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TRTCtrlModes. + */ + PropertyIRTCtrlModes mode; + /// \brief A string property storing the filename for this program. + /** + * \b mvIMPACT::acquire::RTCtrProgram s can be stored and loaded from/to XML files. + * To do this, this property must be set to the desired filename. + * \sa + * \b mvIMPACT::acquire::RTCtrProgram::load, \n \b mvIMPACT::acquire::RTCtrProgram::save + */ + PropertyS filename; + /// \brief A string property \b (read-only) containing information about the current state of the program. + PropertyS programState; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Loads an existing program specified by the property \b mvIMPACT::acquire::RTCtrProgram::fileName. + /** + * The default file extension for these programs is '*.rtp'. If the user doesn't + * specify this file extension, it is appended automatically. Only + * files of this type can be loaded by this function. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int load( void ) + { + return DMR_LoadRTCtrProgram( m_pRefData->m_hDrv, m_pRefData->m_hRTCtrList ); + } + /// \brief Stores the current state of the program under the name specified by the property \b mvIMPACT::acquire::RTCtrProgram::filename. + /** + * The default file extension for files stored using this function is '*.rtp'. If + * the user doesn't specify this file extension, it is appended automatically. Only + * files of this type can be loaded by the function \b mvIMPACT::acquire::RTCtrProgram::load. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int save( void ) + { + return DMR_SaveRTCtrProgram( m_pRefData->m_hDrv, m_pRefData->m_hRTCtrList ); + } +}; + +#if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff +//----------------------------------------------------------------------------- +/// \brief An interface class to model a internal driver event that the user can wait for(\b Device specific interface layout only)(\b deprecated). +/** + * \deprecated + * This class has been declared \b deprecated and will be removed in future versions + * of this interface. A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method can + * be found here: \ref Callback.cpp + * + * An event can be anything that occurs at a certain time within the driver or + * something that can be reported by the hardware. Typical examples might + * be the detection of an external trigger signal, a change at one of the + * digital inputs of a device or the start of a VD pulse send from a camera and + * detected by a capture device. + * + * Sometimes one or more of these events might be important for an application. + * E.g. the user might want to get a notification each time the state of + * one of the digital inputs of a device changes in order to read the current + * state from the device. + * + * Events will return a timestamp that can be used to synchronize the event + * with a certain chronology of other events. + * + * \note + * Instances of this class can't be constructed directly. Valid objects must be + * obtained via the class \b mvIMPACT::acquire::EventSubSystem. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class Event +//----------------------------------------------------------------------------- +{ + friend class EventSubSystem; + mutable EventData m_data; + HDRV m_hDrv; + TDeviceEventType m_type; + explicit Event( HDRV hDrv, HOBJ hObjSettings ) : m_data(), m_hDrv( hDrv ), m_type( detNone ), mode(), + queueDepth(), type() + { + memset( &m_data, 0, sizeof( m_data ) ); + ComponentLocator locator( hObjSettings ); + locator.bindComponent( mode, "Mode" ); + locator.bindComponent( queueDepth, "QueueDepth" ); + locator.bindComponent( type, "Type" ); + // buffer this type as it doesn't change and this provides faster access at runtime. + m_type = static_cast( type.read() ); + } +public: + /// \brief Returns a const reference to the \b mvIMPACT::acquire::EventData structure of this event(deprecated). + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::Event. + * + * The referenced \b mvIMPACT::acquire::EventData structure contains additional information about + * the image, e.g. a timestamp that defines the time this event has been reported by the device. + * + * \note + * Please do \b NOT store this reference in some variable to use it for the + * evaluation of the next notification you get for this event as well, as this will \b NOT update + * the referenced data. Whenever \b mvIMPACT::acquire::Event::getData is called the function + * will make sure that the data in the returned structure is up to date while when working with + * an old reference to the \b mvIMPACT::acquire::EventData structure the data in the structure + * will refer to the previous result. + */ + MVIMPACT_DEPRECATED_CPP( const EventData& getData( void ) const ); + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property \b (read-only) defining the mode this event is currently operated in. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::Event. + * + * This property must be used whenever the user wants to receive notification from this event + * Valid values for this property are defined by the enumeration + * \b mvIMPACT::acquire::TDeviceEventMode. + */ + PropertyIDeviceEventMode mode; + /// \brief Currently unsupported. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::Event. + * + * \note + * This feature is subject to change! Don't use it! + */ + PropertyI queueDepth; + /// \brief An enumerated integer property \b (read-only) containing the type of this event. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::Event. + * + * Valid values for this property are defined by the enumeration + * \b mvIMPACT::acquire::TDeviceEventType. + */ + PropertyIDeviceEventType type; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class containing the result of a wait call for events (\b Device specific interface layout only)(\b deprecated). +/** + * \deprecated + * This class has been declared \b deprecated and will be removed in future versions + * of this interface. A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method can + * be found here: \ref Callback.cpp + * + * Objects of this class will be returned by \b mvIMPACT::acquire::EventSubSystem::waitFor + * calls. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class EventWaitResults +//----------------------------------------------------------------------------- +{ + int m_errorCode; + TDeviceEventType m_waitMask; + TDeviceEventType m_resultMask; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::EventWaitResults object. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventWaitResults. + */ + explicit EventWaitResults( + /// [in] The error code returned by the wait function + int errorCode, + /// [in] The wait mask passed to the wait function + TDeviceEventType waitMask, + /// [in] The result mask of the wait function call + TDeviceEventType resultMask ); + /// \brief The error code returned by the wait function. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventWaitResults. + */ + int errorCode( void ) const + { + return m_errorCode; + } + /// \brief The wait mask passed to the wait function. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventWaitResults. + */ + TDeviceEventType waitMask( void ) const + { + return m_waitMask; + } + /// \brief The result mask of the wait function call. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventWaitResults. + */ + TDeviceEventType resultMask( void ) const + { + return m_resultMask; + } +}; + +//----------------------------------------------------------------------------- +/// \brief An interface class that provides access to all event handling related objects and functions(\b Device specific interface layout only)(\b deprecated). +/** + * \deprecated + * This class has been declared \b deprecated and will be removed in future versions + * of this interface. A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method can + * be found here: \ref Callback.cpp + * + * Events from the \b mvIMPACT \b Acquire interfaces point of view are certain + * things reported by the hardware like e.g. the detection of a frame start or + * the change on one of the digital inputs of a device. + * + * This class combines everything that is related \b mvIMPACT \a Acquire s event + * handling. + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * //----------------------------------------------------------------------------- + * void fn( void ) + * //----------------------------------------------------------------------------- + * { + * // create an interface to the event processing + * unsigned int frameStartEventCnt = 0; + * EventSubSystem ess(getDevicePointerFromSomewhere()); + * Event* pEvent = ess.getEventByType( detFrameStart ); + * if( !pEvent ) + * { + * cout << "Frame start events not supported by this device." << endl; + * return; + * } + * + * pEvent->mode.write( demNotify ); + * TDeviceEventType type = pEvent->type.read(); + * TDeviceEventType resultMask; + * int timeout_ms = 500; + * + * while( !s_boTerminated ) + * { + * // wait for frame start event + * EventWaitResults waitResult = ess.waitFor( timeout_ms, type ); + * if( ( waitResult.errorCode() == DMR_NO_ERROR ) ) + * { + * // we are just waiting for one event type, thus the result mask ain't interesting + * frameStartEventCnt = pEvent->getData().count; + * // do something + * } + * else + * { + * // no event detected within the given timeout + * } + * } + * } + * \endcode + * \endif + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class EventSubSystem +//----------------------------------------------------------------------------- +{ + typedef std::vector EventVector; + typedef std::map EventTypeToEventMap; + typedef std::map StringToEventMap; +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + EventVector m_vEvents; + EventTypeToEventMap m_mTypeToEvent; + StringToEventMap m_mNameToEvent; + HDRV m_hDrv; + int m_refCnt; + explicit ReferenceCountedData( HDRV hDrv ) : m_vEvents(), m_mTypeToEvent(), m_mNameToEvent(), + m_hDrv( hDrv ), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + m_mTypeToEvent.clear(); + m_mNameToEvent.clear(); + EventVector::size_type vSize = m_vEvents.size(); + for( EventVector::size_type i = 0; i < vSize; i++ ) + { + delete m_vEvents[i]; + } + } + }* m_pRefData; +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::EventSubSystem object(\b deprecated). + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventSubSystem. + */ + explicit MVIMPACT_DEPRECATED_CPP( EventSubSystem( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) ); + /// \brief Constructs a new \b mvIMPACT::acquire::EventSubSystem from an existing one. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventSubSystem. + * + * Internal data is reference counted, thus modifying an event obtained from \a src will also + * modify the same event obtained from this newly constructed class. + */ + EventSubSystem( + /// [in] A reference to an existing \b mvIMPACT::acquire::EventSubSystem. + const EventSubSystem& src ) : m_pRefData( src.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + /// \deprecated + ~EventSubSystem() + { + dealloc(); + } + /// \brief Allows assignment of one \b mvIMPACT::acquire::EventSubSystem to another. + /** + * \deprecated + * Internal data is reference counted, thus modifying an event obtained from \a src will also + * modify the same event obtained from this newly constructed class. + */ + EventSubSystem& operator=( + /// [in] A reference to an existing \b mvIMPACT::acquire::EventSubSystem. + const EventSubSystem& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + ++( m_pRefData->m_refCnt ); + } + return *this; + } + /// \brief Returns a reference to an \b mvIMPACT::acquire::Event based on the index in the internal array of event references. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventSubSystem. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of recognized events \n + * a STL out_of_range exception is thrown. + * \endif + * \return + * - a pointer to a \b mvIMPACT::acquire::Event object specifying the event + * the given index in the internal list if available. + * - an invalid pointer or reference otherwise. + */ + Event* getEventByIndex( + /// [in] The index of the event object the user wants to access. + int index ) const + { + return m_pRefData->m_vEvents.at( index ); + } + /// \brief Returns a reference to an \b mvIMPACT::acquire::Event based on the type of the event. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventSubSystem. + * + * \return + * - a pointer to a \b mvIMPACT::acquire::Event object specifying the event of + * the given type in the internal list if available. + * - an invalid pointer or reference otherwise. + */ + Event* getEventByType( + /// [in] The type of the event object the user wants to access. + TDeviceEventType type ) const + { + EventTypeToEventMap::iterator it = m_pRefData->m_mTypeToEvent.find( type ); + if( it != m_pRefData->m_mTypeToEvent.end() ) + { + return it->second; + } + return 0; + } + /// \brief Returns a reference to an \b mvIMPACT::acquire::Event based on the type (represented as a string) of the event. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventSubSystem. + * + * \return + * - a pointer to a \b mvIMPACT::acquire::Event object specifying the event of + * the given type in the internal list if available. + * - an invalid pointer or reference otherwise. + */ + Event* getEventByName( + /// [in] The name/string representation of the event object the user wants to access. + const std::string& name ) const + { + StringToEventMap::iterator it = m_pRefData->m_mNameToEvent.find( name ); + if( it != m_pRefData->m_mNameToEvent.end() ) + { + return it->second; + } + return 0; + } + /// \brief Returns the number of different event types available for the device that has been passed to the constructor of this object. + /** + * \deprecated + * All functions belonging to this class have been declared \b deprecated. See detailed description of + * \b mvIMPACT::acquire::EventSubSystem. + */ + unsigned int getEventCount( void ) const + { + return static_cast( m_pRefData->m_vEvents.size() ); + } + /// \brief Waits for the occurrence of one or more events(\b deprecated). + /** + * \deprecated + * This function has been declared \b deprecated and will be removed in future versions + * of this interface. A more flexible way of getting informed about changes in driver features + * has been added to the interface and should be used instead. An example for this new method can + * be found here: \ref Callback.cpp + * + * This function must be called to wait for one or more events to becomes signalled by the device + * driver. + * + * \return A \b mvIMPACT::acquire::EventWaitResults object containing information about the + * result of this operation. + */ + MVIMPACT_DEPRECATED_CPP( EventWaitResults waitFor( + /// [in] The timeout in ms defining the maximum time to be spend waiting + int timeout_ms, + /// [in] A mask specifying the event types to wait for. Here values defined by + /// \b mvIMPACT::acquire::TDeviceEventType can be ORed together. + TDeviceEventType mask ) ); +}; + +# ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +inline const EventData& Event::getData( void ) const +//----------------------------------------------------------------------------- +{ + TDMR_ERROR result = DMR_NO_ERROR; + if( ( result = DMR_EventGetData( m_hDrv, m_type, 0, 0, &m_data, sizeof( m_data ) ) ) != DMR_NO_ERROR ) + { + std::ostringstream oss; + oss << "Couldn't obtain event data for event type " << m_type << "(string representation: " << type.name() << ")"; + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, oss.str() ); + } + return m_data; +} + +//----------------------------------------------------------------------------- +inline EventWaitResults::EventWaitResults( int errorCode, TDeviceEventType waitMask, TDeviceEventType resultMask ) : m_errorCode( errorCode ), m_waitMask( waitMask ), m_resultMask( resultMask ) {} +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +inline EventSubSystem::EventSubSystem( Device* pDev ) : m_pRefData( 0 ) +//----------------------------------------------------------------------------- +{ + pDev->validateInterfaceLayout( dilDeviceSpecific ); + if( !pDev->isOpen() ) + { + pDev->open(); + } + + m_pRefData = new ReferenceCountedData( pDev->hDrv() ); + + HLIST hList; + if( DMR_FindList( pDev->hDrv(), 0, dmltEventSubSystemSettings, 0, &hList ) == DMR_NO_ERROR ) + { + Component it( hList ); + it = it.firstChild(); + while( it.isValid() ) + { + Event* p = new Event( pDev->hDrv(), it.hObj() ); + m_pRefData->m_mTypeToEvent.insert( std::make_pair( p->type.read(), p ) ); + m_pRefData->m_mNameToEvent.insert( std::make_pair( p->type.readS(), p ) ); + m_pRefData->m_vEvents.push_back( p ); + ++it; + } + } +} + +//----------------------------------------------------------------------------- +inline EventWaitResults EventSubSystem::waitFor( int timeout_ms, TDeviceEventType mask ) +//----------------------------------------------------------------------------- +{ + TDeviceEventType resultMask; + int errorCode = DMR_EventWaitFor( m_pRefData->m_hDrv, timeout_ms, mask, 0, 0, &resultMask ); + return EventWaitResults( errorCode, mask, resultMask ); +} +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS +#endif // #if !defined(WRAP_ANY) && !defined(BUILD_FOR_JAVA) // don't wrap deprecated stuff + +//----------------------------------------------------------------------------- +/// \brief A class to configure the creation of digital signals passed to one or more of the digital outputs of a device(\b Device specific interface layout only). +/** + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class PulseStartConfiguration : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class IOSubSystem; + explicit PulseStartConfiguration( HLIST hList, int nr ) : ComponentCollection( hList ), m_nr( nr ), + pulseStartTrigger(), digitalSignal(), divider(), frequency_Hz(), triggerMoment() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( pulseStartTrigger, "PulseStartTrigger" ); + locator.bindComponent( digitalSignal, "DigitalSignal" ); + locator.bindComponent( divider, "Divider" ); + locator.bindComponent( frequency_Hz, "Frequency_Hz" ); + locator.bindComponent( triggerMoment, "TriggerMoment" ); + } + int m_nr; +public: + /// \brief Returns the internal number associated with this pulse start configuration. + int number( void ) const + { + return m_nr; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property that will define how/when a digital signal is generated by the device. + /** + * When certain digital output signals + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TPulseStartTrigger. + * + * \note + * Not every device will offer the same options. + * Check for valid modes by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIPulseStartTrigger::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyIPulseStartTrigger pulseStartTrigger; + /// \brief An enumerated property to define one or more signals that will trigger the creation of the associated output signals. + /** + * This property will be visible and thus active when \b mvIMPACT::acquire::PulseStartConfiguration::digitalSignal is switched + * to \b mvIMPACT::acquire::pstDigitalSignal. + * + * Depending on the device one or more signals can be defined as 'active for output signal creation'. When more than one signal can be + * defined, calling \b mvIMPACT::acquire::PropertyIDigitalSignal::allowsValueCombinations will return true. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigitalSignal. + * + * \b mvHYPERION \b specific: + * Currently when more than one signal can be defined here, these signals will have an 'or relationship', which means that when any of these + * signals is detected, it will trigger the creation of the associated output signals. + * + * The following signals are defined: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
enum ValueAssociated signal
mvIMPACT::acquire::dsSignal1Line Valid(J1)
mvIMPACT::acquire::dsSignal2Line Valid(J2)
mvIMPACT::acquire::dsSignal3Frame Valid(J1)
mvIMPACT::acquire::dsSignal4Frame Valid(J2)
mvIMPACT::acquire::dsSignal5Trigger-In(J3.4/J3.5)
mvIMPACT::acquire::dsSignal6Sync-In(J3.6/J3.7)
mvIMPACT::acquire::dsSignal7Trigger-In(J4.4/J4.5)
mvIMPACT::acquire::dsSignal8Sync-In(J4.6/J4.7)
mvIMPACT::acquire::dsSignal9DigIn0(J6.9)
mvIMPACT::acquire::dsSignal10DigIn1(J6.10)
mvIMPACT::acquire::dsSignal11DigIn2(J6.11)
mvIMPACT::acquire::dsSignal12DigIn3(J6.12)
+ */ + PropertyIDigitalSignal digitalSignal; + /// \brief An integer property defining a factor by which the external input signal shall divided. + /** + * Every \a divider-value pulse will be used then. All others will be skipped. + */ + PropertyI divider; + /// \brief A float property defining the frequency in Hz. for the creation of the output signals associated with configuration. + /** + * This property will be visible and thus active when \b mvIMPACT::acquire::PulseStartConfiguration::digitalSignal is switched + * to \b mvIMPACT::acquire::pstPeriodically. + */ + PropertyF frequency_Hz; + /// \brief An enumerated integer property defining the exact moment when this pulse start configuration shall be triggered. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TTriggerMoment. + */ + PropertyITriggerMoment triggerMoment; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to handle digital inputs and outputs(\b Device specific interface layout only). +/** + * This class can't be instantiated by the user, but acts as a base class for + * hardware specific classes. Please use a device specific class suitable for the device + * you are working with instead. The documentation of the device specific class will also + * contain some example code. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class IOSubSystem +//----------------------------------------------------------------------------- +{ +protected: +# if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + typedef std::vector RTCtrProgramVector; + typedef std::vector DigitalInputVector; + typedef std::vector DigitalOutputVector; + typedef std::vector SyncOutputVector; + typedef std::vector PulseStartConfigurationVector; + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + HDRV m_hDrv; + DigitalInputVector m_vInputs; + DigitalOutputVector m_vOutputs; + SyncOutputVector m_vHDOutputs; + SyncOutputVector m_vVDOutputs; + mutable RTCtrProgramVector m_RTCtrPrograms; + PulseStartConfigurationVector m_PulseStartConfigurations; + unsigned int m_refCnt; + explicit ReferenceCountedData( HDRV hDrv ) : m_hDrv( hDrv ), m_vInputs(), m_vOutputs(), + m_vHDOutputs(), m_vVDOutputs(), m_RTCtrPrograms(), m_PulseStartConfigurations(), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + DigitalInputVector::size_type vInputsSize = m_vInputs.size(); + for( DigitalInputVector::size_type i = 0; i < vInputsSize; i++ ) + { + delete m_vInputs[i]; + } + + DigitalOutputVector::size_type vOutputsSize = m_vOutputs.size(); + for( DigitalOutputVector::size_type j = 0; j < vOutputsSize; j++ ) + { + delete m_vOutputs[j]; + } + + SyncOutputVector::size_type vSyncOutputsSize = m_vHDOutputs.size(); + for( SyncOutputVector::size_type k = 0; k < vSyncOutputsSize; k++ ) + { + delete m_vHDOutputs[k]; + } + + vSyncOutputsSize = m_vVDOutputs.size(); + for( SyncOutputVector::size_type l = 0; l < vSyncOutputsSize; l++ ) + { + delete m_vVDOutputs[l]; + } + + RTCtrProgramVector::size_type vRTCProgSize = m_RTCtrPrograms.size(); + for( RTCtrProgramVector::size_type m = 0; m < vRTCProgSize; m++ ) + { + delete m_RTCtrPrograms[m]; + } + + PulseStartConfigurationVector::size_type vPulseStartConfigurationsSize = m_PulseStartConfigurations.size(); + for( PulseStartConfigurationVector::size_type n = 0; n < vPulseStartConfigurationsSize; n++ ) + { + delete m_PulseStartConfigurations[n]; + } + } + }* m_pRefData; + //----------------------------------------------------------------------------- + explicit IOSubSystem( Device* pDev ) : m_pRefData( 0 ) + //----------------------------------------------------------------------------- + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + if( !pDev->isOpen() ) + { + pDev->open(); + } + m_pRefData = new ReferenceCountedData( pDev->hDrv() ); + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + void registerAllRTCtrPrograms( HDRV hDrv, HLIST hList ) + { + if( hList != INVALID_ID ) + { + unsigned int cnt = ComponentList( hList ).size(); + for( unsigned int k = 0; k < cnt; k++ ) + { + if( DMR_FindList( hDrv, 0, dmltRTCtr, k, &hList ) == DMR_NO_ERROR ) + { + registerRTCtrProgram( hDrv, hList ); + } + } + } + } + void registerDigitalInput( HDRV hDrv, PropertyI reg, int nr, const std::string& desc ) + { + m_pRefData->m_vInputs.push_back( new DigitalInput( hDrv, reg, nr, desc ) ); + } + void registerDigitalOutput( PropertyI reg, int nr, const std::string& desc ) + { + m_pRefData->m_vOutputs.push_back( new DigitalOutput( reg, nr, desc ) ); + } + void registerHDOutput( HLIST hList ) + { + m_pRefData->m_vHDOutputs.push_back( new SyncOutput( hList ) ); + } + void registerRTCtrProgram( HDRV hDrv, HLIST hList ) + { + m_pRefData->m_RTCtrPrograms.push_back( new RTCtrProgram( hDrv, hList ) ); + } + void registerPulseStartConfiguration( HLIST hList ) + { + m_pRefData->m_PulseStartConfigurations.push_back( new PulseStartConfiguration( hList, static_cast( m_pRefData->m_PulseStartConfigurations.size() ) ) ); + } + void registerVDOutput( HLIST hList ) + { + m_pRefData->m_vVDOutputs.push_back( new SyncOutput( hList ) ); + } +# endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +public: + /// \brief Constructs a new \b mvIMPACT::acquire::IOSubSystem from an existing one. + IOSubSystem( + /// [in] A constant reference to the \b mvIMPACT::acquire::IOSubSystem object, this object shall be created from + const IOSubSystem& src ) : m_pRefData( src.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + virtual ~IOSubSystem() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::IOSubSystem objects. + IOSubSystem& operator=( const IOSubSystem& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + } + return *this; + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::PulseStartConfiguration associated with this device. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + */ + PulseStartConfiguration* getPulseStartConfiguration( + /// [in] The number of the pulse start configuration to return + unsigned int nr ) const + { + return m_pRefData->m_PulseStartConfigurations.at( nr ); + } + /// \brief Returns the number of \b mvIMPACT::acquire::PulseStartConfiguration objects available for the \b mvIMPACT::acquire::Device associated with this object. + unsigned int getPulseStartConfigurationCount( void ) const + { + return static_cast( m_pRefData->m_PulseStartConfigurations.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::RTCtrProgram associated with this device. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + */ + RTCtrProgram* getRTCtrProgram( + /// [in] The number of the real time controller program to return + unsigned int nr ) const + { + return m_pRefData->m_RTCtrPrograms.at( nr ); + } + /// \brief Returns the number of \b mvIMPACT::acquire::RTCtrProgram s available for the \b mvIMPACT::acquire::Device associated with this object. + unsigned int RTCtrProgramCount( void ) const + { + return static_cast( m_pRefData->m_RTCtrPrograms.size() ); + } + /// \brief Returns the number of \b mvIMPACT::acquire::DigitalInput s available for the \b mvIMPACT::acquire::Device associated with this object. + unsigned int getInputCount( void ) const + { + return static_cast( m_pRefData->m_vInputs.size() ); + } + /// \brief Returns the current state of the digital input register. + /** + * This function can be used to read all digital inputs as a single value. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital inputs 0 and 1 are + * currently have a voltage considered as logical '1' applied to them. + */ + virtual unsigned int readInputRegister( void ) const = 0; + /// \brief Returns a const pointer to a \b mvIMPACT::acquire::DigitalInput object. + /** + * + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr references an invalid pin a STL out_of_range exception + * will be thrown. + * \endif + * + * \note + * The possibility to access the digital inputs of a device as single objects is + * just provided for convenience. The same thing can be achieved by calling the + * function \b mvIMPACT::acquire::IOSubSystem::readInputRegister. + */ + const DigitalInput* input( + /// [in] The number of the digital input. + unsigned int nr ) const + { + return m_pRefData->m_vInputs.at( nr ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::DigitalOutput object. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr references an invalid pin a STL out_of_range exception + * will be thrown. + * \endif + * + * \note + * The possibility to access the digital outputs of a device as single objects is + * just provided for convenience. The same thing can be achieved by calling the function + * \b mvIMPACT::acquire::IOSubSystem::writeOutputRegister with the corresponding bit mask. + */ + DigitalOutput* output( + /// [in] The number of the digital output. + unsigned int nr ) const + { + return m_pRefData->m_vOutputs.at( nr ); + } + /// \brief Returns the number of digital outputs available for the \b mvIMPACT::acquire::Device associated with this object. + unsigned int getOutputCount( void ) const + { + return static_cast( m_pRefData->m_vOutputs.size() ); + } + /// \brief Returns the current state of the digital output register. + /** + * This function can be used to read all digital outputs as a single value. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital output 0 and 1 are + * currently set to high. + */ + virtual unsigned int readOutputRegister( void ) const = 0; + /// \brief Alters the state of the digital output register. + /** + * This function can be used to alter the state of certain (or all) digital outputs + * with a single function call. By working with the parameter \a mask certain bits + * can remain unaffected. + * + * \b EXAMPLE + * + * If the previous state of a digital output register was '5', which means that outputs + * 0 and 2 are set to high a call to + * \b mvIMPACT::acquire::IOSubSystem::writeOutputRegister with + * \a value set to 2 and \a mask set to 3 would result in '6' as the new value for the + * output register. Pin 2 will remain unaffected, as \a mask states just to modify + * pin 0 and 1 ( 3 = 00000011 binary ). + * + * \code + * currentValue = 5, mask = 3, value = 2 + * ( currentValue & ~mask ) | value -> new Value + * ( 00000101b(current value) & 11111100(~mask) ) | 00000010(value) -> 0000110(new value of the register) + * \endcode + */ + virtual void writeOutputRegister( + /// [in] The value to be applied to the output register + unsigned int value, + /// [in] The mask to specify which pins to modify. A bit + /// set to '1' in this parameter means that the + /// state of this output has to adopt its style according to + /// the value in \a value. + unsigned int mask = UINT_MAX ) = 0; +}; + +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A class to handle the digital inputs and outputs for \b mvBlueFOX USB cameras(\b Device specific interface layout only). +/** + * \if DOXYGEN_CPP_DOCUMENTATION + * A sample to show how to work with this class and the mvBlueFOX (Creating and instance + * of this class for another device might raise an exception): + * + * \code + * #include + * #include + * + * using namespace std; + * using namespace mvIMPACT::acquire; + * + * void doSomeIOStuff( Device* pBF ) + * { + * IOSubSystemBlueFOX bfIOs( pBF ); + * cout << "output 0 was " << bfIOs.output(0)->get() << " and is now(after flipping) "; + * bfIOs.output(0)->flip(); + * cout << bfIOs.output(0)->get() << endl; + * cout << "input threshold(" << bfIOs.digitalInputThreshold.readS() << ") set to " << bfdit10V << endl; + * if( bfIOs.digitalInputThreshold.isWriteable() ) // mvBlueFOX-M doesn't support modifying the input threshold + * { + * bfIOs.digitalInputThreshold.write( bfdit10V ); + * cout << "input threshold is now " << bfIOs.digitalInputThreshold.readS() << endl; + * } + * cout << "input 0 is " << bfIOs.input(0)->get() << endl; + * cout << "press ENTER." << endl; + * cin.get(); + * cout << "input 0 is " << bfIOs.input(0)->get() << endl; + * cout << "press ENTER." << endl; + * cin.get(); + * cout << "input 0 is " << bfIOs.input(0)->get() << endl; + * // switch on digital out 0 and 1 ( 3 = 00000011 binary ) + * bfIOs.writeOutputRegister( 3 ); + * cout << "outputs: " << bfIOs.readOutputRegister() << ", inputs: " << bfIOs.readInputRegister(); + * // the next line will reset bit 0 only, resulting in output 1 to remain high + * // as the mask parameter of '1' defines that only the LSB of the register will be + * // affected by the first parameter of the function call + * bfIOs.writeOutputRegister( 0, 1 ); + * cout << "outputs: " << bfIOs.readOutputRegister() << ", inputs " << bfIOs.readInputRegister() << endl; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * public static void doSomeIOStuff( Device pBF ) + * { + * IOSubSystemBlueFOX bfIOs = new mvIMPACT.acquire.IOSubSystemBlueFOX( pBF ); + * System.out.println( "output 0 was " + bfIOs.output(0).get() + " and is now(after flipping) "); + * bfIOs.output(0).flip(); + * System.out.println( bfIOs.output(0).get() ); + * System.out.println( "input threshold(" + bfIOs.getDigitalInputThreshold().readS() + ") set to " + TBlueFOXDigitalInputThreshold .bfdit10V ); + * if( bfIOs.getDigitalInputThreshold().isWriteable() ) // mvBlueFOX-M doesn't support modifying the input threshold + * { + * bfIOs.getDigitalInputThreshold().write( TBlueFOXDigitalInputThreshold .bfdit10V ); + * System.out.println( "input threshold is now " + bfIOs.getDigitalInputThreshold().readS() ); + * } + * System.out.println( "input 0 is " + bfIOs.input(0).get()); + * System.out.println( "press ENTER." ); + * waitForENTER(); + * System.out.println( "input 0 is " + bfIOs.input(0).get() ); + * System.out.println( "press ENTER." ); + * waitForENTER(); + * System.out.println( "input 0 is " + bfIOs.input(0).get() ); + * // switch on digital out 0 and 1 ( 3 = 00000011 binary ) + * bfIOs.writeOutputRegister( 3 ); + * System.out.println( "outputs: " + bfIOs.readOutputRegister() + ", inputs: " + bfIOs.readInputRegister()); + * // the next line will reset bit 0 only, resulting in output 1 to remain high + * // as the mask parameter of '1' defines that only the LSB of the register will be + * // affected by the first parameter of the function call + * bfIOs.writeOutputRegister( 0, 1 ); + * System.out.println( "outputs: " + bfIOs.readOutputRegister() + ", inputs " + bfIOs.readInputRegister() ); + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * def doSomeIOStuff(pBF): + * bfIOs = acquire.IOSubSystemBlueFOX(pBF) + * print("output 0 was " + str(bfIOs.getOutput(0).get()) + " and is now(after flipping) ") + * bfIOs.getOutput(0).flip() + * print(bfIOs.getOutput(0).get()) + * print("input threshold(" + bfIOs.digitalInputThreshold.readS() + ") set to " + str(acquire.bfdit10V)) + * if(bfIOs.digitalInputThreshold.isWriteable): # mvBlueFOX-M doesn't support modifying the input threshold + * bfIOs.digitalInputThreshold.write(acquire.bfdit10V) + * print("input threshold is now " + bfIOs.digitalInputThreshold.readS()) + * + * print("input 0 is " + str(bfIOs.getInput(0).get())) + * time.sleep(5) # wait for 5 seconds + * print("input 0 is " + str(bfIOs.getInput(0).get())) + * time.sleep(5) # wait for 5 seconds + * print("input 0 is " + str(bfIOs.getInput(0).get())) + * # switch on digital out 0 and 1 (3 = 00000011 binary) + * bfIOs.writeOutputRegister(3) + * print("outputs: " + str(bfIOs.readOutputRegister()) + ", inputs: " + str(bfIOs.readInputRegister())) + * # the next line will reset bit 0 only, resulting in output 1 to remain high + * # as the mask parameter of '1' defines that only the LSB of the register will be + * # affected by the first parameter of the function call + * bfIOs.writeOutputRegister(0, 1) + * print("outputs: " + str(bfIOs.readOutputRegister()) + ", inputs " + str(bfIOs.readInputRegister())) + * \endcode + * \endif + * + * \note + * The \b mvBlueFOX defines an additional property \b mvIMPACT::acquire::CameraSettingsBlueFOX::flashMode. + * This might affect the state of the digital outputs as well. + * + * If a digital output is defined to be 'logic 0' but the flash mode is switched on + * for the same digital output, the output will be high during the expose time of + * the camera sensor. If a digital output is defined to be 'logic 1' the output will + * be high all the time. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class IOSubSystemBlueFOX : public IOSubSystem +//----------------------------------------------------------------------------- +{ +private: + unsigned int readRegister( const PropertyI& reg ) const + { + std::vector v; + reg.read( v ); + std::vector::size_type vSize = v.size(); + unsigned int result = 0; + for( std::vector::size_type i = 0; i < vSize; i++ ) + { + result |= ( ( v[i] & 1 ) << i ); + } + return result; + } + unsigned int readRegisterAtomic( const PropertyI& reg ) const + { + std::vector v; + reg.read( v, true ); + std::vector::size_type vSize = v.size(); + unsigned int result = 0; + for( std::vector::size_type i = 0; i < vSize; i++ ) + { + result |= ( ( v[i] & 1 ) << i ); + } + return result; + } + PropertyI m_inputRegister; + PropertyI m_outputRegister; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::IOSubSystemBlueFOX object. + explicit IOSubSystemBlueFOX( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : IOSubSystem( pDev ), m_inputRegister(), m_outputRegister(), digitalInputThreshold() + { + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + locator.bindComponent( digitalInputThreshold, "DigitalInputThreshold" ); + locator.bindComponent( m_inputRegister, "DigitalInputs" ); + locator.bindComponent( m_outputRegister, "DigitalOutputs" ); + + // register all input pins + unsigned int pinCount = m_inputRegister.valCount(); + for( unsigned int i = 0; i < pinCount; i++ ) + { + std::ostringstream oss; + oss << "DigitialInput" << i; + registerDigitalInput( pDev->hDrv(), m_inputRegister, i, oss.str() ); + } + + // register all output pins + pinCount = m_outputRegister.valCount(); + for( unsigned int j = 0; j < pinCount; j++ ) + { + std::ostringstream oss; + oss << "DigitalOutput" << j; + registerDigitalOutput( m_outputRegister, j, oss.str() ); + } + + registerAllRTCtrPrograms( pDev->hDrv(), locator.findComponent( "HardwareRealTimeController" ) ); + } + /// \brief Returns the current state of the digital input register. + /** + * This function can be used to read all digital inputs as a single value. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital inputs 0 and 1 are + * currently have a voltage considered as logical '1' applied to them. + */ + virtual unsigned int readInputRegister( void ) const + { + const TDMR_ERROR result = DMR_UpdateDigitalInputs( m_pRefData->m_hDrv ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return readRegister( m_inputRegister ); + } + /// \brief Returns the current state of the digital input register. + /** + * This function can be used to read all digital inputs as a single value \b at the same time. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital inputs 0 and 1 are + * currently have a voltage considered as logical '1' applied to them. + */ + unsigned int readInputRegisterAtomic( void ) const + { + const TDMR_ERROR result = DMR_UpdateDigitalInputs( m_pRefData->m_hDrv ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + return readRegisterAtomic( m_inputRegister ); + } + /// \brief Returns the current state of the digital output register. + /** + * This function can be used to read all digital outputs as a single value. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital output 0 and 1 are + * currently set to high. + */ + virtual unsigned int readOutputRegister( void ) const + { + return readRegister( m_outputRegister ); + } + /// \brief Returns the current state of the digital output register. + /** + * This function can be used to read all digital outputs as a single value \b at the same time. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital output 0 and 1 are + * currently set to high. + */ + unsigned int readOutputRegisterAtomic( void ) const + { + return readRegisterAtomic( m_outputRegister ); + } + /// \brief Alters the state of the digital output register. + /** + * This function can be used to alter the state of certain (or all) digital outputs + * with a single function call. By working with the parameter \a mask certain bits + * can remain unaffected. + * + * \b EXAMPLE + * + * If the previous state of a digital output register was '5', which means that outputs + * 0 and 2 are set to high a call to + * \b mvIMPACT::acquire::IOSubSystem::writeOutputRegister with + * \a value set to 2 and \a mask set to 3 would result in '6' as the new value for the + * output register. Pin 2 will remain unaffected, as \a mask states just to modify + * pin 0 and 1 ( 3 = 00000011 binary ). + */ + void writeOutputRegister( + /// [in] The value to be applied to the output register + unsigned int value, + /// [in] The mask to specify which pins to modify. A bit + /// set to '1' in this parameter means that the + /// state of this output has to adopt its style according to + /// the value in \a value. + unsigned int mask = UINT_MAX ) + { + unsigned int newVal = ( readRegister( m_outputRegister ) & ~mask ) | ( mask & value ); + DigitalOutputVector::size_type vSize = m_pRefData->m_vOutputs.size(); + std::vector v( vSize ); + for( std::vector::size_type i = 0; i < vSize; i++ ) + { + v[i] = ( ( newVal & ( 1 << i ) ) != 0 ); + } + m_outputRegister.write( v ); + } + /// \brief Alters the state of the digital output register. + /** + * This function can be used to alter the state of certain (or all) digital outputs + * with a single function call \b at the same time. By working with the parameter \a mask + * certain bits can remain unaffected. + * + * \b EXAMPLE + * + * If the previous state of a digital output register was '5', which means that outputs + * 0 and 2 are set to high a call to + * \b mvIMPACT::acquire::IOSubSystem::writeOutputRegister with + * \a value set to 2 and \a mask set to 3 would result in '6' as the new value for the + * output register. Pin 2 will remain unaffected, as \a mask states just to modify + * pin 0 and 1 ( 3 = 00000011 binary ). + */ + void writeOutputRegisterAtomic( + /// [in] The value to be applied to the output register + unsigned int value, + /// [in] The mask to specify which pins to modify. A bit + /// set to '1' in this parameter means that the + /// state of this output has to adopt its style according to + /// the value in \a value. + unsigned int mask = UINT_MAX ) + { + unsigned int newVal = ( readRegister( m_outputRegister ) & ~mask ) | ( mask & value ); + DigitalOutputVector::size_type vSize = m_pRefData->m_vOutputs.size(); + std::vector v( vSize ); + for( std::vector::size_type i = 0; i < vSize; i++ ) + { + v[i] = ( ( newVal & ( 1 << i ) ) != 0 ); + } + m_outputRegister.write( v, true ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the threshold for the digital inputs in Volt. + /** + * If a voltage applied to the digital input lies above the threshold this pin + * will be considered as 'logic 1' otherwise it will be considered as 'logic 0'. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBlueFOXDigitalInputThreshold. + * + * \note + * This property is \b read-only for \b mvBlueFOX-M devices and will always be 2V. + */ + PropertyIBlueFOXDigitalInputThreshold digitalInputThreshold; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // # ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +# if !defined(IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) +//----------------------------------------------------------------------------- +/// \brief A base class to handle the digital inputs and outputs for devices (\b Device specific interface layout only). +/** + * This class provides a convenient basic access to the digital inputs and + * outputs of almost every device supported by this interface. + * + * \note + * This class may \b NOT be used for mvBlueFOX devices. + * + * \note + * The number of digital inputs and outputs available will vary significantly + * from device to device. Some devices might not even have digital inputs and/or + * digital outputs. Therefore it's crucial to check for available pins before + * using them. The corresponding functions to do that can be found in the + * base class \b mvIMPACT::acquire::IOSubSystem. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * #include + * #include + * + * using namespace std; + * using namespace mvIMPACT::acquire; + * + * // lists all available digital inputs and outputs and their description + * void listIOPins( Device* pDev ) + * { + * IOSubSystemCommon io( pDev ); + * unsigned int iCnt = io.getInputCount(); + * cout << "available digital inputs: " << iCnt << endl; + * for( unsigned int d=0; dgetDescription() << endl; + * } + * unsigned int oCnt = io.getOutputCount(); + * cout << "available digital outputs: " << oCnt << endl; + * for( unsigned int e=0; egetDescription() << " to high" << endl; + * // set this output to logic '1' + * pOutput->set(); + * } + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * public class CameraDescriptionManagerExample + * //----------------------------------------------------------------------------- + * { + * //============================================================================= + * //=== Static member functions ================================================= + * //============================================================================= + * static + * { + * try + * { + * System.loadLibrary( "mvIMPACT_Acquire.java" ); + * } + * catch( UnsatisfiedLinkError e ) + * { + * System.err.println( "Native code library failed to load. Make sure the 'mvIMPACT_Acquire.java' library can be found in the systems search path.\n" + e ); + * System.exit( 1 ); + * } + * } + * + * //----------------------------------------------------------------------------- + * public static void main( String[] args ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr = new DeviceManager(); + * Device pDev = mvIMPACT.acquire.examples.helper.DeviceAccess.getDeviceFromUserInput( devMgr ); + * if( pDev == null ) + * { + * System.out.print( "Unable to continue!" ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * System.out.println( "Initialising the device. This might take some time..." ); + * try + * { + * pDev.open(); + * } + * catch( ImpactAcquireException e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * System.out.println( "An error occurred while opening device " + pDev.getSerial().read() + + * "(error code: " + e.getMessage() + ")." ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * try + * { + * // the next line will raise an exception if this device is not a frame grabber + * IOSubSystemFrameGrabber io = new IOSubSystemFrameGrabber( pDev ); + * final long iCnt = io.getInputCount(); + * System.out.println( String.format( "Available digital inputs: %d", iCnt ) ); + * for( long d=0; dhDrv(), PropertyI( it ), 0, it.name() ); + ++it; + } + } + + ComponentList outputs; + locator.bindComponent( outputs, "DigitalOutputs", 0, 1 ); + if( outputs.isValid() ) + { + Component it( outputs ); + it = it.firstChild(); + while( it.isValid() ) + { + if( it.isList() ) + { + ComponentLocator outputStateLocator( it ); + registerDigitalOutput( PropertyI( outputStateLocator.findComponent( "State" ) ), 0, it.name() ); + } + ++it; + } + } + + registerAllRTCtrPrograms( pDev->hDrv(), locator.findComponent( "HardwareRealTimeController" ) ); + } + /// \brief Returns the current state of the digital input register. + /** + * This function can be used to read all digital inputs as a single value. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital inputs 0 and 1 are + * currently have a voltage considered as logical '1' applied to them. + * + * \return The current state of the digital inputs where bit 0 in the result represents + * the state of digital input 0, bit 1 the state of digital input 1 a.s.o. + */ + virtual unsigned int readInputRegister( void ) const + { + DMR_UpdateDigitalInputs( m_pRefData->m_hDrv ); + if( !m_inputs.isValid() ) + { + return 0; + } + unsigned int result = 0; + Component it( m_inputs ); + int i = 0; + it = it.firstChild(); + while( it.isValid() ) + { + PropertyI input( it ); + result |= ( ( input.read() & 1 ) << i ); + ++it; + ++i; + } + return result; + } + /// \brief Returns the current state of the digital output register. + /** + * This function can be used to read all digital outputs as a single value. Each + * bit represents the status of one digital output pin. + * + * \b EXAMPLE + * + * A value of '3' returned by this function means that digital output 0 and 1 are + * currently set to high. + * + * \return The current state of the digital outputs where bit 0 in the result represents + * the state of digital output 0, bit 1 the state of digital output 1 a.s.o. + */ + virtual unsigned int readOutputRegister( void ) const + { + unsigned int result = 0; + DigitalOutputVector::size_type vSize = m_pRefData->m_vOutputs.size(); + for( DigitalOutputVector::size_type i = 0; i < vSize; i++ ) + { + result |= ( ( m_pRefData->m_vOutputs[i]->get() & 1 ) << i ); + } + return result; + } + /// \brief Alters the state of the digital output register. + /** + * This function can be used to alter the state of certain (or all) digital outputs + * with a single function call. By working with the parameter \a mask certain bits + * can remain unaffected. + * + * \b EXAMPLE + * + * If the previous state of a digital output register was '5', which means that outputs + * 0 and 2 are set to high a call to + * \b mvIMPACT::acquire::IOSubSystem::writeOutputRegister with + * \a value set to 2 and \a mask set to 3 would result in '6' as the new value for the + * output register. Pin 2 will remain unaffected, as \a mask states just to modify + * pin 0 and 1 ( 3 = 00000011 binary ). + */ + void writeOutputRegister( + /// [in] The value to be applied to the output register + unsigned int value, + /// [in] The mask to specify which pins to modify. A bit + /// set to '1' in this parameter means that the + /// state of this output has to adopt its style according to + /// the value in \a value. + unsigned int mask = UINT_MAX ) + { + DigitalOutputVector::size_type vSize = m_pRefData->m_vOutputs.size(); + for( DigitalOutputVector::size_type i = 0; i < vSize; i++ ) + { + if( mask & ( 1 << i ) ) + { + if( value & ( 1 << i ) ) + { + m_pRefData->m_vOutputs[i]->set(); + } + else + { + m_pRefData->m_vOutputs[i]->reset(); + } + } + } + } +}; +# endif // #i f !defined(IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) + +# ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +/// \brief A class to create complex digital output signals(\b Device specific interface layout only). +/** + * Instances of this class can be used to create more complex digital output + * related signals like a single pulse or sequence of pulses on a certain pin + * as a reaction on a signal on one of the digital inputs of a device. + * + * The availability of the features provided by this class heavily depends on the + * used capture device. Therefore it's crucial to check if a desired feature is available + * at all. This class either provides the functions needed for these checks or its + * functions will return appropriate error codes. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class OutputSignalGeneratorBlueDevice +//----------------------------------------------------------------------------- +{ +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct OutputProperties + //----------------------------------------------------------------------------- + { + PropertyIDeviceDigitalOutputMode mode; + PropertyIBoolean inverter; + explicit OutputProperties( HLIST hOutput ) : mode() + { + ComponentLocator locator( hOutput ); + locator.bindComponent( mode, "Mode" ); + locator.bindComponent( inverter, "Inverter" ); + } + }; + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + std::map m_mOutputs; + unsigned int m_refCnt; + explicit ReferenceCountedData() : m_mOutputs(), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + std::map::iterator itEnd = m_mOutputs.end(); + std::map::iterator it = m_mOutputs.begin(); + while( it != itEnd ) + { + delete it->second; + ++it; + } + } + }* m_pRefData; + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + OutputProperties* getOutputProperties( DigitalOutput* pOutput ) const + //----------------------------------------------------------------------------- + { + if( pOutput ) + { + std::map::iterator it = m_pRefData->m_mOutputs.find( pOutput->getDescription() ); + if( it != m_pRefData->m_mOutputs.end() ) + { + return it->second; + } + } + return 0; + } +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS +public: + /// \brief Constructs a new \b mvIMPACT::acquire::OutputSignalGeneratorBlueDevice object. + explicit OutputSignalGeneratorBlueDevice( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : m_pRefData( 0 ) + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + m_pRefData = new ReferenceCountedData(); + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + ComponentList outputs; + locator.bindComponent( outputs, "DigitalOutputs" ); + if( outputs.isValid() ) + { + Component it( outputs.hObj() ); + it = it.firstChild(); + while( it.isValid() ) + { + if( it.isList() ) + { + m_pRefData->m_mOutputs.insert( std::pair( it.name(), new OutputProperties( it ) ) ); + } + ++it; + } + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::OutputSignalGeneratorBlueDevice from and existing one. + explicit OutputSignalGeneratorBlueDevice( + /// [in] A constant reference to the \b mvIMPACT::acquire::OutputSignalGeneratorBlueDevice object, this object shall be created from + const OutputSignalGeneratorBlueDevice& src ) : m_pRefData( src.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + ~OutputSignalGeneratorBlueDevice() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::OutputSignalGeneratorBlueDevice objects. + OutputSignalGeneratorBlueDevice& operator=( const OutputSignalGeneratorBlueDevice& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + } + return *this; + } + /// \brief Removes the signal definition from the specified output pin. + /** + * Whenever a signal has been defined for a a certain digital output + * pin, this pin can no longer controlled using the corresponding functions + * in the class \b mvIMPACT::acquire::DigitalOutput. This function removes the + * signal definition and hands back manual control of that digital output to the user. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int undefineSignal( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p ) + { + p->mode.write( ddomManual ); + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + /// \brief Checks whether the specified output can be used to create an inverted expose active signal. + bool canCreateExposeActiveSignal( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + if( !p || !p->mode.isValid() ) + { + return false; + } + unsigned int dictSize = p->mode.dictSize(); + for( unsigned int i = 0; i < dictSize; i++ ) + { + if( p->mode.getTranslationDictValue( i ) == ddomExposureActive ) + { + return true; + } + } + return false; + } + /// \brief Checks whether the specified output can be used to create an inverted version of a certain signal. + bool canInvertSignal( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + return ( p && p->inverter.isValid() ); + } + /// \brief Returns the current mode a digital output is operated in. + /// + /// If the mode is not selectable for the current output an exception will be raised. + TDeviceDigitalOutputMode getOutputMode( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + if( !p ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_FEATURE_NOT_AVAILABLE, "Unsupported feature query(Could not obtain pointer to output properties)" ); + } + return p ? static_cast( p->mode.read() ) : ddomManual; + } + /// \brief Checks whether the specified output is currently operated in a certain mode. + bool isOutputModeActive( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput, + /// [in] The mode the specified output shall be checked for. + TDeviceDigitalOutputMode mode ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + return ( p && p->mode.isValid() && ( p->mode.read() == mode ) ); + } + /// \brief Checks whether the specified output will currently invert a certain internal signal. + bool isSignalInverted( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + return ( p && p->mode.isValid() && p->inverter.isValid() && ( p->inverter.read() == bTrue ) ); + } + /// \brief This function will configure the digital output to operate in a certain mode. + /** + * After calling this function the digital output will be operated in the mode specified by + * \a mode. + * + * Valid values for \a constant are defined by the enum \b mvIMPACT::acquire::TDeviceDigitalOutputMode. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int setOutputMode( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemCommon + /// for this device. + DigitalOutput* pOutput, + /// [in] The mode the specified output shall be operated in. If the mode passed to the + /// function is not available for the output or the device an exception will be raised. + TDeviceDigitalOutputMode mode, + /// [in] Set this parameter to true, to invert the exposure signal + bool boInverted = false ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p && p->mode.isValid() ) + { + p->mode.write( mode ); + if( p->inverter.isValid() ) + { + p->inverter.write( boInverted ? bTrue : bFalse ); + } + else if( boInverted ) + { + return DMR_FEATURE_NOT_AVAILABLE; + } + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } +}; +# endif // #ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A class to handle the digital inputs and outputs for frame grabber devices(\b Device specific interface layout only). +/** + * This class provides a convenient basic access to the digital inputs and + * outputs of a frame grabber device. + * + * \note + * The number of digital inputs and outputs available will vary significantly + * from device to device. Some devices might not even have digital inputs and/or + * digital outputs. Therefore it's crucial to check for available pins before + * using them. The corresponding functions to do that can be found in the + * base class \b mvIMPACT::acquire::IOSubSystem. + * + * To create more complex digital output related signals the class + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber should be used. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class IOSubSystemFrameGrabber : public IOSubSystemCommon +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::IOSubSystemFrameGrabber object. + explicit IOSubSystemFrameGrabber( /// A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : IOSubSystemCommon( pDev ), syncOutputMode() + { + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + Component itSyncs; + locator.bindComponent( itSyncs, "SyncOutputs", 0, 1 ); + if( itSyncs.isValid() && itSyncs.firstChild().isValid() ) + { + locator.bindSearchBase( locator.searchbase_id(), "SyncOutputs" ); + locator.bindComponent( syncOutputMode, "Mode" ); + itSyncs = itSyncs.firstChild(); + while( itSyncs.isValid() ) + { + if( itSyncs.isList() ) + { + std::string name = itSyncs.name(); + if( name.substr( 0, 3 ) == "VD-" ) + { + registerVDOutput( itSyncs ); + } + else if( name.substr( 0, 3 ) == "HD-" ) + { + registerHDOutput( itSyncs ); + } + else + { + ; // type not recognized?! + } + } + ++itSyncs; + } + } + } + /// \brief Returns the number of available HD output pins for the \b mvIMPACT::acquire::Device associated with this object. + unsigned int getHDOutputCount( void ) const + { + return static_cast( m_pRefData->m_vHDOutputs.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::SyncOutput object that represents a HD output for this device. + /** + * \a nr \b MUST be a valid number ( larger or equal than 0 and smaller than the + * value returned by \b mvIMPACT::acquire::IOSubSystemFrameGrabber::getHDOutputCount. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr references an invalid pin a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A pointer to a \b mvIMPACT::acquire::SyncOutput object. + */ + SyncOutput* HDOutput( + /// [in] The number of the HD output to return. + unsigned int nr ) const + { + return m_pRefData->m_vHDOutputs.at( nr ); + } + /// \brief Returns the number of available VD output pins for the \b mvIMPACT::acquire::Device associated with this object. + unsigned int getVDOutputCount( void ) const + { + return static_cast( m_pRefData->m_vVDOutputs.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::SyncOutput object that represents a VD output for this device. + /** + * \a nr \b MUST be a valid number ( larger or equal than 0 and smaller than the + * value returned by \b mvIMPACT::acquire::IOSubSystemFrameGrabber::getVDOutputCount. + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr references an invalid pin a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A pointer to a \b mvIMPACT::acquire::SyncOutput object. + */ + SyncOutput* VDOutput( + /// [in] The number of the VD output to return. + unsigned int nr ) const + { + return m_pRefData->m_vVDOutputs.at( nr ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the current mode for sync. signal creation. + /** + * Sometimes it's desired to create a signal to sync. cameras connected to a capture device. + * E.g. when capturing 3 monochrome cameras in parallel these should be synchronized. Therefore + * some devices can create HD and VD signals that synchronize the connected cameras. + * + * To create sync. signals this property must be set either to \b mvIMPACT::acquire::dsomNonInterlaced + * or \b mvIMPACT::acquire::dsomInterlaced. + * + * In interlaced mode only the frequency of the VD signals can be modified, while in non-interlaced + * mode the width (in percent) the signal stays low can be modified as well. + * + * Now e.g. to sync. two or more CCIR compliant cameras connected to a capture device that can + * create sync. signals, the HD signals must be generated with a CCIR compliant frequency. + * The function \b mvIMPACT::acquire::IOSubSystemFrameGrabber::HDOutput can be used to access the + * desired output pin. Then its property \b mvIMPACT::acquire::SyncOutput::frequency_Hz is + * set to 15625 Hz (CCIR standard). The remaining values can be left untouched. The capture device + * will no generate HD signals with the desired frequency and VD outputs with the frequency + * stored by the property \b mvIMPACT::acquire::SyncOutput::frequency_Hz belonging to the + * pointer to the object returned by a call to \b mvIMPACT::acquire::IOSubSystemFrameGrabber::VDOutput. + */ + PropertyIDeviceSyncOutMode syncOutputMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class to create complex digital output signals(\b Device specific interface layout only). +/** + * Instances of this class can be used to create more complex digital output + * related signals like a single pulse or sequence of pulses on a certain pin + * as a reaction on a signal on one of the digital inputs of a device. + * + * The availability of the features provided by this class heavily depends on the + * used capture device. Therefore it's crucial to check if a desired feature is available + * at all. This class either provides the functions needed for these checks or its + * functions will return appropriate error codes. + * + * \note + * If the property \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::controlMode + * is not available \b NO feature of this class can be used. + * + * \note + * If the translation dictionary of \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::controlMode + * does not contain \b mvIMPACT::acquire::docmRTC the function + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::defineLineScanPulse will \b NOT + * be available. + * + * \note + * Calling unsupported functions or accessing unsupported features will raise an exception. + * + * Pointers to \b mvIMPACT::acquire::DigitalOutput objects \b MUST be obtained + * by an instance to a \b mvIMPACT::acquire::IOSubSystemFrameGrabber object of the + * same device. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * #include + * #include + * #include + * + * using namespace std; + * using namespace mvIMPACT::acquire; + * + * //----------------------------------------------------------------------------- + * int main( int argc, char* argv[] ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr; + * Device* pDev = getValidDevicePointerFromSomewhere( devMgr ); + * // The next line will raise an exception if the device is not operated + * // in interface layout 'dilDeviceSpecific' or is not a frame grabber! This + * // should therefore be wrapped in an exception handler if in doubt! + * IOSubSystemFrameGrabber io( pDev ); + * unsigned int iCnt = io.getInputCount(); + * cout << "available digital inputs: " << iCnt << endl; + * for( unsigned int d=0; dgetDescription() << endl; + * } + * unsigned int oCnt = io.getOutputCount(); + * cout << "available digital outputs: " << oCnt << endl; + * // set all available digital outputs to high + * for( unsigned int e=0; egetDescription() << " to high" << endl; + * pOutput->set(); + * } + * + * // check there is at least one digital output + * if( oCnt > 0 ) + * { + * OutputSignalGeneratorFrameGrabber osg( pDev ); + * // check if this device supports enhanced signal creation at all + * if( osg.controlMode.isValid() ) + * { + * // define a simple pulse on the first digital output detected. + * // this pulse will be low after 100 us for + * // 200us and then switches back to high. + * osg.definePulse( io.output( 0 ), 0, 100, 200 ); + * + * // define a more complex pulse + * vector v; + * v.push_back( 100 ); + * v.push_back( 299 ); + * v.push_back( 666 ); + * osg.definePulseSequence( io.output( 0 ), 0, v ); + * osg.controlMode.write( docmSoftware ); + * osg.imageTrigger.write( ditAfterDigOutSignals ); + * + * // check if line scan pulse creation is supported by this device + * vector > dict; + * osg.controlMode.getTranslationDict( dict ); + * unsigned int dictSize = osg.controlMode.dictSize(); + * for( unsigned int i=0; i define some signal + * cout << "checkGrabberInterface: This device supports RTC control signal creation." << endl; + * osg.controlMode.write( docmRTC ); + * osg.defineLineScanPulse( io.output( 0 ), dsosePeriodically, 100, 100, 1, 1 ); + * } + * } + * } + * } + * return 0; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * public class OutputSignalGeneratorExample + * //----------------------------------------------------------------------------- + * { + * //============================================================================= + * //=== Static member functions ================================================= + * //============================================================================= + * static + * { + * try + * { + * System.loadLibrary( "mvIMPACT_Acquire.java" ); + * } + * catch( UnsatisfiedLinkError e ) + * { + * System.err.println( "Native code library failed to load. Make sure the 'mvIMPACT_Acquire.java' library can be found in the systems search path.\n" + e ); + * System.exit( 1 ); + * } + * } + * + * //----------------------------------------------------------------------------- + * public static void main( String[] args ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr = new DeviceManager(); + * Device pDev = mvIMPACT.acquire.examples.helper.DeviceAccess.getDeviceFromUserInput( devMgr ); + * if( pDev == null ) + * { + * System.out.print( "Unable to continue!" ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * System.out.println( "Initialising the device. This might take some time..." ); + * try + * { + * pDev.open(); + * } + * catch( ImpactAcquireException e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * System.out.println( "An error occurred while opening device " + pDev.getSerial().read() + + * "(error code: " + e.getMessage() + ")." ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * try + * { + * IOSubSystemFrameGrabber io = new IOSubSystemFrameGrabber( pDev ); + * final long iCnt = io.getInputCount(); + * System.out.println( String.format( "Available digital inputs: %d", iCnt ) ); + * for( long d=0; d 0 ) + * { + * OutputSignalGeneratorFrameGrabber osg = new OutputSignalGeneratorFrameGrabber( pDev ); + * // check if this device supports enhanced signal creation at all + * if( osg.getControlMode().isValid() ) + * { + * // define a simple pulse on the first digital output detected. + * // this pulse will be low after 100 us for + * // 200us and then switches back to high. + * osg.definePulse( io.output( 0 ), 0, 100, 200 ); + * + * // define a more complex pulse + * IntVector v = new IntVector(); + * v.add( 100 ); + * v.add( 299 ); + * v.add( 666 ); + * osg.definePulseSequence( io.output( 0 ), 0, v ); + * osg.getControlMode().write( TDigitalOutputControlMode.docmSoftware ); + * osg.getImageTrigger().write( TDeviceImageTrigger.ditAfterDigOutSignals ); + * + * // check if line scan pulse creation is supported by this device + * StringIntVector dict = new StringIntVector(); + * osg.getControlMode().getTranslationDict( dict ); + * final long dictSize = osg.getControlMode().dictSize(); + * for( long i=0; i define some signal + * System.out.println( "checkGrabberInterface: This device supports RTC control signal creation." ); + * osg.getControlMode().write( TDigitalOutputControlMode.docmRTC ); + * osg.defineLineScanPulse( io.output( 0 ), TDeviceSignalOutputStartEvent.dsosePeriodically, 100, 100, 1, 1 ); + * } + * } + * } + * } + * } + * catch( ImpactAcquireException e ) + * { + * System.out.println( "An error occurred: " + e.getMessage() + ")." ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * def setUpIOs(pDev): + * # The next line will raise an exception if the device is not operated + * # in interface layout 'dilDeviceSpecific' or is not a frame grabber! This + * # should therefore be wrapped in an exception handler if in doubt! + * io = acquire.IOSubSystemFrameGrabber(pDev) + * iCnt = io.getInputCount() + * print("available digital inputs: " + str(iCnt)) + * for x in range(iCnt): + * print(io.getInput(d).getDescription()) + * + * oCnt = io.getOutputCount() + * print("available digital outputs: " + str(oCnt)) + * # set all available digital outputs to high + * for e in range(oCnt): + * pOutput = io.getOutput(e) + * print("setting " + pOutput.getDescription() + " to high") + * pOutput.state = True + * + * # check there is at least one digital output + * if oCnt > 0: + * osg = acquire.OutputSignalGeneratorFrameGrabber(pDev) + * # check if this device supports enhanced signal creation at all + * if osg.controlMode.isValid: + * # define a simple pulse on the first digital output detected. + * # this pulse will be low after 100 us for + * # 200us and then switches back to high. + * osg.definePulse(io.getOutput(0), 0, 100, 200) + * + * # define a more complex pulse + * v = [] + * v[0] = 100 + * v[1] = 299 + * v[1] = 666 + * osg.definePulseSequence(io.getOutput(0), 0, v) + * osg.controlMode.write(acquire.docmSoftware) + * osg.imageTrigger.write(acquire.ditAfterDigOutSignals) + * + * # check if line scan pulse creation is supported by this device + * dict = {None:None} + * osg.controlMode.getTranslationDict(dict) + * dictSize = osg.controlMode.dictSize + * for i in range(dictSize): + * if dict[i].second == acquire.docmRTC: + * # supported -> define some signal + * print("checkGrabberInterface: This device supports RTC control signal creation.") + * osg.controlMode.write(acquire.docmRTC) + * osg.defineLineScanPulse(io.getOutput(0), acquire.dsosePeriodically, 100, 100, 1, 1) + * \endcode + * \endif + * + * Whenever a signal has been defined for a a certain digital output + * pin, this pin can no longer controlled using the corresponding functions + * in the class \b mvIMPACT::acquire::DigitalOutput. In order to do that + * the pin in question must be released using the function + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::undefineSignal. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class OutputSignalGeneratorFrameGrabber +//----------------------------------------------------------------------------- +{ +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct OutputProperties + //----------------------------------------------------------------------------- + { + PropertyIDeviceDigitalOutputMode mode; + PropertyI polarity; + PropertyI delay_us; + PropertyI width_us; + PropertyI width_pclk; + PropertyI startLevel; + PropertyI polaritySwitchAfter_us; + PropertyIDigitalSignal digitalSignal; + PropertyI pulseStartConfiguration; + explicit OutputProperties( HLIST hOutput ) : mode(), polarity(), delay_us(), width_us(), + width_pclk(), startLevel(), polaritySwitchAfter_us(), digitalSignal(), + pulseStartConfiguration() + { + ComponentLocator locator( hOutput ); + locator.bindComponent( mode, "Mode" ); + locator.bindComponent( polarity, "Polarity" ); + locator.bindComponent( delay_us, "Delay_us" ); + locator.bindComponent( width_us, "Width_us" ); + locator.bindComponent( width_pclk, "Width_pclk" ); + locator.bindComponent( startLevel, "StartLevel" ); + locator.bindComponent( polaritySwitchAfter_us, "PolaritySwitchAfter_us" ); + locator.bindComponent( digitalSignal, "DigitalSignal" ); + locator.bindComponent( pulseStartConfiguration, "PulseStartConfiguration" ); + } + }; + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + ComponentList m_outputs; + PropertyIDeviceSignalOutputStartEvent m_pulseStartEventLineScan; + PropertyI m_softwareSignalPeriod_pclk; + PropertyI m_output; + PropertyI m_width_pclk; + PropertyI m_polarity; + PropertyI m_divider; + std::map m_mOutputs; + unsigned int m_refCnt; + explicit ReferenceCountedData() : m_outputs(), m_pulseStartEventLineScan(), + m_softwareSignalPeriod_pclk(), m_output(), m_width_pclk(), + m_polarity(), m_divider(), m_mOutputs(), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + std::map::iterator itEnd = m_mOutputs.end(); + std::map::iterator it = m_mOutputs.begin(); + while( it != itEnd ) + { + delete it->second; + ++it; + } + } + }* m_pRefData; + //----------------------------------------------------------------------------- + void bindPublicProperties( HLIST hList ) + //----------------------------------------------------------------------------- + { + ComponentLocator locator( hList ); + locator.bindComponent( controlMode, "ControlMode" ); + locator.bindComponent( pulseStartEvent, "PulseStartEvent" ); + locator.bindComponent( imageTrigger, "ImageTrigger" ); + } + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + OutputProperties* getOutputProperties( DigitalOutput* pOutput ) const + //----------------------------------------------------------------------------- + { + if( pOutput ) + { + std::map::iterator it = m_pRefData->m_mOutputs.find( pOutput->getDescription() ); + if( it != m_pRefData->m_mOutputs.end() ) + { + return it->second; + } + } + return 0; + } +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS +public: + /// \brief Constructs a new \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber object. + explicit OutputSignalGeneratorFrameGrabber( /// A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : m_pRefData( 0 ), controlMode(), pulseStartEvent(), imageTrigger() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + m_pRefData = new ReferenceCountedData(); + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + locator.bindComponent( m_pRefData->m_outputs, "DigitalOutputs" ); + locator.bindSearchBase( m_pRefData->m_outputs.hObj() ); + bindPublicProperties( m_pRefData->m_outputs.hObj() ); + locator.bindComponent( m_pRefData->m_pulseStartEventLineScan, "PulseStartEvent(LineScan)" ); + locator.bindComponent( m_pRefData->m_softwareSignalPeriod_pclk, "SoftwareSignalPeriod_pclk" ); + locator.bindComponent( m_pRefData->m_output, "Output" ); + locator.bindComponent( m_pRefData->m_width_pclk, "Width_pclk" ); + locator.bindComponent( m_pRefData->m_polarity, "Polarity" ); + locator.bindComponent( m_pRefData->m_divider, "Divider" ); + if( m_pRefData->m_outputs.isValid() ) + { + Component it( m_pRefData->m_outputs.hObj() ); + it = it.firstChild(); + while( it.isValid() ) + { + if( it.isList() ) + { + m_pRefData->m_mOutputs.insert( std::pair( it.name(), new OutputProperties( it ) ) ); + } + ++it; + } + } + } + /// \brief Constructs a new \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber from an existing one. + OutputSignalGeneratorFrameGrabber( + /// [in] A constant reference to the \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber object, this object shall be created from + const OutputSignalGeneratorFrameGrabber& src ) : m_pRefData( src.m_pRefData ), + controlMode( src.controlMode ), pulseStartEvent( src.pulseStartEvent ), imageTrigger( src.imageTrigger ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + ~OutputSignalGeneratorFrameGrabber() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber objects. + OutputSignalGeneratorFrameGrabber& operator=( const OutputSignalGeneratorFrameGrabber& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + bindPublicProperties( m_pRefData->m_outputs.hObj() ); + } + return *this; + } + /// \brief Assigns a single pulse to a digital output. + /** + * Whenever a single pulse of a certain duration and polarity shall be generated + * on a digital output as a reaction on a trigger signal that was either generated by one of + * digital inputs of the device or software this is the right function to use. + * + * When the signal is generated can be defined by the properties + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::pulseStartEvent and + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::imageTrigger. + * + * \sa + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::undefineSignal + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int definePulse( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] The polarity of the pulse to generate. + /// + /// - 0: The pulse will be low for \a width_pclk and high otherwise + /// - 1: The pulse will be high for \a width_pclk and high otherwise + int polarity, + /// [in] The delay after the trigger event before a signal generation starts + int delay, + /// [in] The width of the pulse to generate + int width, + /// [in] The pulse start configuration to be used for this pulse sequence. + /// Not every device will support the use of pulse start configurations. Valid objects that + /// can be passed to this function can be obtained from a call to \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfiguration, + /// and \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfigurationCount. If objects of these type are + /// not supported, pass 0 or ignore this parameter. In that case the property + /// \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::imageTrigger will define the start condition + /// for the signal output. + PulseStartConfiguration* pPulseStartConfiguration = 0 ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p ) + { + p->mode.write( ddomPulse ); + p->polarity.write( polarity ); + p->delay_us.write( delay ); + p->width_us.write( width ); + if( pPulseStartConfiguration ) + { + p->pulseStartConfiguration.write( pPulseStartConfiguration->number() ); + } + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + /// \brief Assigns a complex signal to a digital output. + /** + * This function can be used when a complex signal shall be generated + * on a digital output as a reaction on a trigger signal that was either generated by one of + * digital inputs of the device or software. + * + * When the signal is generated can be defined by the properties + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::pulseStartEvent and + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::imageTrigger. + * + * \sa + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::undefineSignal + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int definePulseSequence( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] The start level of the generated signal. + /// + /// - 0: The signal will start with 'low' + /// - 1: The signal will start with 'high' + int startLevel, + /// [in] An array of integer values. Each values defines a switch in polarity + /// of the signal after 'x' us. + /// An array containing '1000', '2000' therefore will describe a signal + /// starting with \a startLevel, switches polarity after 1000 us and then + /// again switches polarity after 2000 us. + const std::vector& sequence, + /// [in] The pulse start configuration to be used for this pulse sequence. + /// Not every device will support the use of pulse start configurations. Valid objects that + /// can be passed to this function can be obtained from a call to \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfiguration, + /// and \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfigurationCount. If objects of these type are + /// not supported, pass 0 or ignore this parameter. In that case the property + /// \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::imageTrigger will define the start condition + /// for the signal output. + PulseStartConfiguration* pPulseStartConfiguration = 0 ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p ) + { + p->mode.write( ddomUser ); + p->startLevel.write( startLevel ); + p->polaritySwitchAfter_us.write( sequence ); + if( pPulseStartConfiguration ) + { + p->pulseStartConfiguration.write( pPulseStartConfiguration->number() ); + } + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + /// \brief Receives a list of valid signals that can be passed directly to a certain digital output pin. + /** + * Whenever it is necessary to output a certain signal (e.g. a digital input signal connected to the device or + * an internal digital signal like e.g. a frame valid signal) to a digital output of the device this can be done + * by a call to the function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::definePassThroughSignal + * + * As the type of signals that a device can send to a digital output depends heavily on the device and even on the + * digital output as well, this function will return a list of strings and a numerical representation for each signal + * that can be sent to this digital output. + * + * \note + * This function is much more efficient than calling + * \b OutputSignalGeneratorFrameGrabber::getValidPassThroughSignalValue and + * \b OutputSignalGeneratorFrameGrabber::getValidPassThroughSignalString and + * therefore this function should be called whenever all entries are required. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int getValidSignalsForPassThroughModes( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [out] A reference to a vector that will receive the list of allowed digital signals + /// for this particular digital output pin. + TDigitalSignalTranslationDict& sequence ) const + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p && p->digitalSignal.isValid() && p->digitalSignal.hasDict() ) + { + p->digitalSignal.getTranslationDict( sequence ); + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + /// \brief Returns the number of signals that can be used for pass through signal definitions for a certain digital output pin of this device. + unsigned int getValidPassThroughSignalCount( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + if( p && p->digitalSignal.isValid() && p->digitalSignal.hasDict() ) + { + return p->digitalSignal.dictSize(); + } + return 0; + } + /// \brief Receives a valid signal that can be passed directly to a certain digital output pin. + /** + * Whenever it is necessary to output a certain signal (e.g. a digital input signal connected to the device or + * an internal digital signal like e.g. a frame valid signal) to a digital output of the device this can be done + * by a call to the function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::definePassThroughSignal + * + * As the type of signals that a device can send to a digital output depends heavily on the device and even on the + * digital output as well, this function together with the function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidPassThroughSignalString + * can be used to query a list of strings and a numerical representation for each signal + * that can be sent to this digital output. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidSignalsForPassThroughModes + * to obtain this information. + * \endif + */ + TDigitalSignal getValidPassThroughSignalValue( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] The index of the entry to read from the property. The find out the last valid value for this parameter + /// call \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidPassThroughSignalCount + int index = 0 ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + if( !p || !p->digitalSignal.isValid() || !p->digitalSignal.hasDict() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_FEATURE_NOT_AVAILABLE, "Unsupported feature query" ); + } + return p ? static_cast( p->digitalSignal.getTranslationDictValue( index ) ) : dsNone; + } + /// \brief Receives a valid string representation of a signal that can be passed directly to a certain digital output pin. + /** + * Whenever it is necessary to output a certain signal (e.g. a digital input signal connected to the device or + * an internal digital signal like e.g. a frame valid signal) to a digital output of the device this can be done + * by a call to the function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::definePassThroughSignal + * + * As the type of signals that a device can send to a digital output depends heavily on the device and even on the + * digital output as well, this function together with the function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidPassThroughSignalString + * can be used to query a list of strings and a numerical representation for each signal + * that can be sent to this digital output. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidSignalsForPassThroughModes + * to obtain this information. + * \endif + */ + std::string getValidPassThroughSignalString( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] The index of the entry to read from the property. The find out the last valid value for this parameter + /// call \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidPassThroughSignalCount + int index = 0 ) const + { + OutputProperties* p = getOutputProperties( pOutput ); + if( !p || !p->digitalSignal.isValid() || !p->digitalSignal.hasDict() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_FEATURE_NOT_AVAILABLE, "Unsupported feature query" ); + } + return p ? p->digitalSignal.getTranslationDictString( index ) : std::string(); + } + /// \brief Assigns a certain signal to a digital output. + /** + * Some digital input signals or even some internal signals can be passed directly to one or more + * digital outputs. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int definePassThroughSignal( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] The digital signal that shall be passed to the digital output. + /// Valid values for this parameter will be obtained by a call to the function + /// \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidSignalsForPassThroughModes + TDigitalSignal digitalSignal, + /// [in] If set to \a true, the signal will be inverted internally before being passed to the output. + bool boInverted = false ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p && p->digitalSignal.isValid() ) + { + p->mode.write( boInverted ? ddomDigitalSignalPassThroughInv : ddomDigitalSignalPassThrough ); + p->digitalSignal.write( digitalSignal ); + return DMR_NO_ERROR; + } + else + { + return DMR_FEATURE_NOT_AVAILABLE; + } + } + /// \brief Assigning a certain signal to a digital output. + /** + * Some digital input signals or even some internal signals can be passed directly to one or more + * digital outputs. + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int definePassThroughSignal( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] The string representation of the digital output that shall be passed to the digital output. + /// Valid values for this parameter will be obtained by a call to the function + /// \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::getValidSignalsForPassThroughModes + const std::string& digitalSignal, + /// [in] If set to \a true, the signal will be inverted internally before being passed to the output. + bool boInverted = false ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p && p->digitalSignal.isValid() ) + { + p->mode.write( boInverted ? ddomDigitalSignalPassThroughInv : ddomDigitalSignalPassThrough ); + p->digitalSignal.writeS( digitalSignal ); + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + /// \brief Removes the signal definition from the specified output pin. + /** + * Whenever a signal has been defined for a a certain digital output + * pin, this pin can no longer controlled using the corresponding functions + * in the class \b mvIMPACT::acquire::DigitalOutput. This function removes the + * signal definition and hands back manual control of that digital output to the user. + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int undefineSignal( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p ) + { + p->mode.write( ddomManual ); + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + /// \brief Defines a pulse to trigger line scan cameras. + /** + * Calling this function without setting \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::controlMode + * to \b mvIMPACT::acquire::docmRTC will have \b NO effect. + * + * \note + * Not every frame grabber will offer the \b mvIMPACT::acquire::docmRTC + * mode. Check is the mode is available by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIDigitalOutputControlMode::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIDigitalOutputControlMode::getTranslationDictValue. The detailed description + * of this class might contain source code examples for the language you are working with. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIDigitalOutputControlMode::getTranslationDict + * in addition to the functions mentioned above. + * \endif + * + * \sa + * \b mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber::undefineSignal + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int defineLineScanPulse( + /// [in] A pointer to a \b mvIMPACT::acquire::DigitalOutput object + /// obtained from an instance of the class \b mvIMPACT::acquire::IOSubSystemFrameGrabber + /// for this device. + DigitalOutput* pOutput, + /// [in] Defines the start event for the signal generation. Valid values for this parameter + /// are defined by \b mvIMPACT::acquire::TDeviceSignalOutputStartEvent. + TDeviceSignalOutputStartEvent pulseStartEventValue, + /// [in] Defines the frequency for a continuously generated signal if + /// \a pulseStartEventValue is \b mvIMPACT::acquire::dsoseSyncInRisingEdge + /// or \b mvIMPACT::acquire::dsoseSyncInFallingEdge and is + /// ignored otherwise. + int softwareSignalPeriod_pclk, + /// [in] The width of the signal to generate if \a pulseStartEventValue is \b mvIMPACT::acquire::dsoseSyncInRisingEdge, + /// \b mvIMPACT::acquire::dsosePeriodically or + /// \b mvIMPACT::acquire::dsoseSyncInFallingEdge and is + /// ignored otherwise. + int width_pclk, + /// [in] The polarity of the signal to generate if \a pulseStartEventValue is \b mvIMPACT::acquire::dsoseSyncInRisingEdge, + /// \b mvIMPACT::acquire::dsosePeriodically or + /// \b mvIMPACT::acquire::dsoseSyncInFallingEdge and is + /// ignored otherwise. + /// + /// - 0: The signal will be low for \a width_pclk and high otherwise + /// - 1: The signal will be high for \a width_pclk and high otherwise + int polarity, + /// [in] Defines the divider value if \a pulseStartEventValue is + /// \b mvIMPACT::acquire::dsosePeriodically + unsigned int divider ) + { + if( !pOutput ) + { + return DMR_INVALID_PARAMETER; + } + OutputProperties* p = getOutputProperties( pOutput ); + if( p ) + { + m_pRefData->m_pulseStartEventLineScan.write( pulseStartEventValue ); + m_pRefData->m_output.writeS( pOutput->getDescription() ); + switch( pulseStartEventValue ) + { + case dsoseSyncInRisingEdge: + case dsoseSyncInFallingEdge: + m_pRefData->m_width_pclk.write( width_pclk ); + m_pRefData->m_polarity.write( polarity ); + m_pRefData->m_divider.write( divider ); + break; + case dsosePeriodically: + m_pRefData->m_softwareSignalPeriod_pclk.write( softwareSignalPeriod_pclk ); + m_pRefData->m_width_pclk.write( width_pclk ); + m_pRefData->m_polarity.write( polarity ); + break; + default: + // nothing to do + break; + } + return DMR_NO_ERROR; + } + return DMR_FEATURE_NOT_AVAILABLE; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the general method used to create output signals. + /** + * This setting always applies to every signal defined. Modifying this property will also + * change the behaviour of signals already defined. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigitalOutputControlMode. + * + * When switching to \b mvIMPACT::acquire::docmRTC mode + * only one signal can be created currently. + * + * \note + * Not every frame grabber will offer the \b mvIMPACT::acquire::docmRTC + * mode. Check if the mode is available by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyIDigitalOutputControlMode::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyIDigitalOutputControlMode::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyIDigitalOutputControlMode::getTranslationDict + * in addition to the functions mentioned above. + * \endif + * + * Some devices will offer a more flexible way to define this behaviour. In this case, this property won't be available (a call to the function + * \b mvIMPACT::acquire::Component::isValid will return false). However then calls to \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfigurationCount + * and \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfiguration will succeed and the objects returned by + * \b mvIMPACT::acquire::IOSubSystem::getPulseStartConfiguration (\b mvIMPACT::acquire::PulseStartConfiguration) will + * provide a more sophisticated way to define the signal output behaviour of a device. + */ + PropertyIDigitalOutputControlMode controlMode; + /// \brief An enumerated integer property defining the general behaviour of created output signals. + /** + * This setting always applies to every signal defined. Modifying this property will also + * change the behaviour of signals already defined. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceSignalOutputStartEvent. + */ + PropertyIDeviceSignalOutputStartEvent pulseStartEvent; + /// \brief An enumerated integer property defining the general behaviour of created output signals. + /** + * This setting always applies to every signal defined. Modifying this property will also + * change the behaviour of signals already defined. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceImageTrigger. + */ + PropertyIDeviceImageTrigger imageTrigger; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief A class describing how a video signal source(e.g. a camera or image sensor) is connected to a video signal sink(e.g. a frame grabber)(\b Device specific interface layout only). +/** + * With an instance of this class the user can define on which input channels the + * video signal source used for this setting is connected to the video signal sink and how(in which format) the + * video signal source transmits its data. + * + * Video signal source and video signal sink can both belong to the same physical piece + * of hardware. This e.g. might apply to a digital camera that doesn't need a + * frame grabber (e.g. a GigE Vision™, USB3 Vision™ or USB camera). In such a scenario + * certain properties belonging to this class might be read-only or may only allow + * a single enumeration value. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class Connector : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::Connector object. + explicit Connector( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : ComponentCollection( pDev ), cameraOutputUsed(), + videoChannel(), pinDescription() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltSetting, settingName ); + if( locator.findComponent( "Connector" ) != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "Connector" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( cameraOutputUsed, "CameraOutputUsed" ); + locator.bindComponent( videoChannel, "VideoChannel" ); + locator.bindComponent( pinDescription, "PinDescription" ); + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the video signal output of the video signal source used for the connection to the video signal sink. + /** + * \note + * Not every video signal sink will support every possible value defined for this property. + * For example a CameraLink® frame grabber will not offer to use an SVideo connector. + * Therefore the translation dictionary of this property should be used to find out, which connector types are available. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraOutput. + * + * \note + * This property might not be supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyICameraOutput cameraOutputUsed; + /// \brief An integer property containing the video channel the camera belonging to the current setting is connected to. + /** + * The maximum possible video channel might change when the property + * \b mvIMPACT::acquire::Connector::cameraOutputUsed is modified as the different + * ways to transmit a video signal require more or less video input channels. While e.g. a composite + * video signal can be transmitted via a single wire, an RGB signal requires either 3 or 4 wires + * (depending on whether the sync. signal is transmitted on a separate wire or not). + * + * The first channel will always have the number 0. The limits (max/min values) can be queried + * by calling the function \b mvIMPACT::acquire::PropertyI::getMinValue or + * \b mvIMPACT::acquire::PropertyI::getMaxValue. + * + * \note + * This property might not be supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyI videoChannel; + /// \brief A string property \b (read-only) containing a description for the video channel currently selected by the property \b mvIMPACT::acquire::Connector::videoChannel. + /** + * The description string contains information about the connector pins belonging to this video + * input of the video signal sink as well as the corresponding name of this video input. + * + * \note + * This property might not be supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyS pinDescription; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class for camera related settings(\b Device specific interface layout only). +/** + * This class acts as a base class for camera related settings. It only contains + * settings that are available for every device! + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class BasicDeviceSettingsWithAOI : public BasicDeviceSettings +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::BasicDeviceSettingsWithAOI object. + explicit BasicDeviceSettingsWithAOI( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : BasicDeviceSettings( pDev, settingName ), aoiHeight(), + aoiStartX(), aoiStartY(), aoiWidth() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + ComponentLocator locator( m_hRoot ); + if( locator.findComponent( "Aoi" ) != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "Aoi" ); + locator.bindComponent( aoiHeight, "H" ); + locator.bindComponent( aoiStartX, "X" ); + locator.bindComponent( aoiStartY, "Y" ); + locator.bindComponent( aoiWidth, "W" ); + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the number of lines to capture. + PropertyI aoiHeight; + /// \brief An integer property defining the X-offset for each capture line. + /** + * Example: When setting this property to 5 the first pixel in each line of + * the resulting image will be pixel number 5 of each line transmitted by + * the camera. + */ + PropertyI aoiStartX; + /// \brief An integer property defining the Y-offset. + /** + * Example: When setting this property to 5 the first line of + * the resulting image will be line number 5 of the image transmitted by + * the camera. + */ + PropertyI aoiStartY; + /// \brief An integer property defining the number of pixels to capture per line. + PropertyI aoiWidth; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class for camera related settings(\b Device specific interface layout only). +/** + * This class acts as a base class for camera related settings. It only contains + * settings that are available for almost every device! + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsBase : public BasicDeviceSettingsWithAOI +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsBase object. + explicit CameraSettingsBase( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : BasicDeviceSettingsWithAOI( pDev, settingName ), pixelFormat() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( pixelFormat, "PixelFormat" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the pixel format used to transfer the image data into the target systems host memory. + /** + * Support for this property has been added in version 1.11.0 of mvIMPACT Acquire thus old driver versions will + * raise an exception if an application accesses the property without checking if the property is present. + * + * By default this property will be set to \b mvIMPACT::acquire::ibpfAuto. This will result in the previous driver + * behaviour where depending on the various post processing steps that are enabled or disabled the driver will decide + * which transfer format will be used. However sometimes this could result in a transfer format, which is not ideal + * for the application (e.g. when a post processing step of the application needs RGBx888Packed but the systems bandwidth + * is limited the application might want to transfer the data in YUV422 packed and then use the fast format conversion + * algorithm in the driver). This can be achieved by explicitly setting \b mvIMPACT::acquire::CameraSettingsBase::pixelFormat to + * \b mvIMPACT::acquire::ibpfYUV422Packed and \b mvIMPACT::acquire::ImageDestination::pixelFormat to + * \b mvIMPACT::acquire::ibpfRGBx888Packed. + * + * \note + * Selecting a defined transfer format can in some cases result in certain filters (e.g. dark current, ...) to be switched + * of as then the filters themselves can no longer influence the transfer format, which is sometimes necessary as not every + * filter does support every input format. Also this property will contain only pixel formats, which are actually supported + * by the capture device, thus in most of the cases this will be a subset of the pixel formats defined by the enumeration defining this property. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TImageBufferPixelFormat. + */ + PropertyIImageBufferPixelFormat pixelFormat; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +# ifndef IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief \b mvVirtualDevice related camera settings(\b Device specific interface layout only). +/** + * \note + * As this is a device driver meant for testing the interface an allowing to + * start the integration of mvIMPACT Acquire into an application, this class + * might change at ANY time! Changes in the virtual device driver might not + * be backward compatible! + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsVirtualDevice : public CameraSettingsBase +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsVirtualDevice object. + explicit CameraSettingsVirtualDevice( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : CameraSettingsBase( pDev, settingName ), + bufferPartCount(), aoiMode(), gain_dB(), testMode(), channelBitDepth(), paddingX(), tapsXGeometry(), tapsYGeometry(), + frameDelay_us(), imageDirectory(), imageType(), bayerMosaicParity(), testImageBarWidth(), userData() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( bufferPartCount, "BufferPartCount" ); + locator.bindComponent( aoiMode, "AoiMode" ); + locator.bindComponent( gain_dB, "Gain_dB" ); + locator.bindComponent( testMode, "TestMode" ); + locator.bindComponent( channelBitDepth, "ChannelBitDepth" ); + locator.bindComponent( paddingX, "PaddingX" ); + locator.bindComponent( tapsXGeometry, "TapsXGeometry" ); + locator.bindComponent( tapsYGeometry, "TapsYGeometry" ); + locator.bindComponent( frameDelay_us, "FrameDelay_us" ); + locator.bindComponent( imageDirectory, "ImageDirectory" ); + locator.bindComponent( imageType, "ImageType" ); + locator.bindComponent( bayerMosaicParity, "BayerMosaicParity" ); + locator.bindComponent( testImageBarWidth, "TestImageBarWidth" ); + locator.bindComponent( userData, "UserData" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the number of buffer part to transmit in each request. + /** + * This property is meant to test the multi-part buffer feature of mvIMPACT Acquire mainly. When + * set to 0 multi-part buffer handling is switched off. When set to a value greater than 0 the + * virtual device will transmit data in multi-part mode, meaning that mvIMPACT::acquire::Request::getBufferPartCount() + * will return a value larger than zero. Only when this is the case the properties belonging to the + * individual buffer parts are guaranteed to contain up to date data while then all properties whose name + * starts with \c image within that request might not. + * + * \since 2.20.0 + */ + PropertyI bufferPartCount; + /// \brief An enumerated integer property defining the used AOI mode for the image capture. + /** + * This feature will only be visible, when the property \b mvIMPACT::acquire::CameraSettingsVirtualDevice::testMode + * is set to \b mvIMPACT::acquire::vdtmImageDirectory. Then this property will allow to enforce a certain image dimension + * ( \b mvIMPACT::acquire::camUser ) or to capture every image file in its original dimensions ( \b mvIMPACT::acquire::camFull ). + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraAoiMode. + * + * \since 2.11.9 + */ + PropertyICameraAoiMode aoiMode; + /// \brief A float property defining the gain in dB to be applied to the test image. + /** + * The formula for given \c gain_dB is + * \code + * gain_x= 10 ^ (gain_dB/20) + * \endcode + * + * \b Example: + * + * \code + * gain_x = 10 ^ (6/20) = 1.995 + * \endcode + * + * I.e. increasing the gain setting by 6dB corresponds to factor of 2. + * + * The formula for given gain_x is + * \code + * gain_dB = 20*log(gain_x) dB + * \endcode + * + * Where: \n + * \c gain_dB: MATRIX VISION gain value (logarithmic) \n + * \c gain_x: multiplicative gain \n + * \c ^: power function \n + */ + PropertyF gain_dB; + /// \brief An enumerated integer property defining the test mode use to generate the dummy images. + /** + * When \b mvIMPACT::acquire::CameraSettingsBase::pixelFormat is \b NOT set to \b mvIMPACT::acquire::ibpfAuto, this + * this property will become invisible. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TVirtualDeviceTestMode. + */ + PropertyIVirtualDeviceTestMode testMode; + /// \brief An integer property defining the channel bit depth for certain test image generation modes. + /** + * When \b mvIMPACT::acquire::CameraSettingsBase::pixelFormat is \b NOT set to \b mvIMPACT::acquire::ibpfAuto, this + * this property will become invisible. + * + * When \b mvIMPACT::acquire::CameraSettingsVirtualDevice::testMode is set to \b mvIMPACT::acquire::vdtmMovingMonoRamp, + * \b mvIMPACT::acquire::vdtmMovingBayerDataRamp or \b mvIMPACT::acquire::vdtmBayerWhiteBalanceTestImage this property + * will allow to define the pixel format for the test image. + */ + PropertyI channelBitDepth; + /// \brief An integer property defining the padding(in bytes) in X-direction for certain test image generation modes. + /** + * When \b mvIMPACT::acquire::CameraSettingsVirtualDevice::testMode is set to a mono format(not the weird packed ones!), + * \b mvIMPACT::acquire::vdtmMovingBayerDataRamp or \b mvIMPACT::acquire::vdtmBayerWhiteBalanceTestImage this property + * will allow to define the padding in bytes for each line. This will result in images where the line pitch differs from + * the width multiplied by the bytes per pixel value. E.g. a padding of 1 in X-direction and a width of 5 for a 16 bit mono + * format will result in a line pitch of 11 bytes(5*2 + 1). + */ + PropertyI paddingX; + /// \brief An enumerated integer property defining the way this camera transmits the pixel data in X direction. + /** + * Within the virtual device driver, modifying this property internally will only attach the corresponding + * attribute to the request buffer, thus might result in the tap sort filter to process the data. This is mainly + * meant for testing purposes. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTapsXGeometry. + * \since 2.5.2 + */ + PropertyICameraTapsXGeometry tapsXGeometry; + /// \brief An enumerated integer property defining the way this camera transmits the pixel data in Y direction. + /** + * Within the virtual device driver, modifying this property internally will only attach the corresponding + * attribute to the request buffer, thus might result in the tap sort filter to process the data. This is mainly + * meant for testing purposes. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTapsYGeometry. + * \since 2.5.2 + */ + PropertyICameraTapsYGeometry tapsYGeometry; + /// \brief An integer property defining a delay in us before the 'captured' image is returned to the user. + PropertyI frameDelay_us; + /// \brief A string property defining the directory to capture images from. + /** + * This feature will only be visible, when the property \b mvIMPACT::acquire::CameraSettingsVirtualDevice::testMode + * is set to \b mvIMPACT::acquire::vdtmImageDirectory. + * + * See \b mvIMPACT::acquire::CameraSettingsVirtualDevice::imageType to find out how to configure what kind of images shall be captured from disc. + */ + PropertyS imageDirectory; + /// \brief An enumerated integer property defining what images shall be captured from hard disk. + /** + * This feature will only be visible, when the property \b mvIMPACT::acquire::CameraSettingsVirtualDevice::testMode + * is set to \b mvIMPACT::acquire::vdtmImageDirectory. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TVirtualDeviceImageType. + */ + PropertyIVirtualDeviceImageType imageType; + /// \brief An enumerated integer property defining the Bayer attribute assigned to the generated test image. + /** + * When images are acquired via a directory, or a Bayer test pattern is generated this can be used to specify the Bayer parity. + * \b mvIMPACT::acquire::bmpUndefined will set the buffers Bayer attribute thus will result in a grey(mono) buffer being returned. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBayerMosaicParity. + */ + PropertyIBayerMosaicParity bayerMosaicParity; + /// \brief An integer property defining the width (in pixels) of the different bars in certain test modes. + PropertyI testImageBarWidth; + /// \brief A string property that will be copied into the user data property of each request. + /** + * This e.g. can be used to assign a certain identifier to each image request. + */ + PropertyS userData; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVVIRTUALDEVICE_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief \b mvV4L2 related camera settings(\b Device specific interface layout only). +/** + * \note UNDER CONSTRUCTION! Subject to change. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsV4L2Device : public BasicDeviceSettingsWithAOI +//----------------------------------------------------------------------------- +{ + Component m_customFeatureIterator; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsV4L2Device object. + explicit CameraSettingsV4L2Device( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : BasicDeviceSettingsWithAOI( pDev, settingName ), + m_customFeatureIterator(), imageWidth(), imageHeight(), videoStandard(), pixelFormat(), + brightness(), contrast(), saturation(), hue(), blackLevel(), autoWhiteBalance(), redBalance(), + blueBalance(), gamma(), exposure(), autoGain(), gain(), HFlip(), VFlip(), powerLineFrequency(), + hueAuto(), whiteBalanceTemperature(), sharpness(), backlightCompensation() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( imageWidth, "ImageWidth" ); + locator.bindComponent( imageHeight, "ImageHeight" ); + locator.bindComponent( videoStandard, "VideoStandard" ); + locator.bindComponent( pixelFormat, "PixelFormat" ); + locator.bindComponent( brightness, "Brightness" ); + locator.bindComponent( contrast, "Contrast" ); + locator.bindComponent( saturation, "Saturation" ); + locator.bindComponent( hue, "Hue" ); + locator.bindComponent( blackLevel, "BlackLevel" ); + locator.bindComponent( autoWhiteBalance, "AutoWhiteBalance" ); + locator.bindComponent( redBalance, "RedBalance" ); + locator.bindComponent( blueBalance, "BlueBalance" ); + locator.bindComponent( gamma, "Gamma" ); + locator.bindComponent( exposure, "Exposure" ); + locator.bindComponent( autoGain, "AutoGain" ); + locator.bindComponent( gain, "Gain" ); + locator.bindComponent( HFlip, "HFlip" ); + locator.bindComponent( VFlip, "VFlip" ); + locator.bindComponent( powerLineFrequency, "PowerLineFrequency" ); + locator.bindComponent( hueAuto, "HueAuto" ); + locator.bindComponent( whiteBalanceTemperature, "WhiteBalanceTemperature" ); + locator.bindComponent( sharpness, "Sharpness" ); + locator.bindComponent( backlightCompensation, "BacklightCompensation" ); + m_customFeatureIterator = Component( pixelFormat.hObj() ); + m_customFeatureIterator = m_customFeatureIterator.firstSibling(); + } + /// \brief Returns an iterator to for iterating inside a device specific feature list. + /** + * This can be useful a device offers custom features that are not defined in the V4L2 standard and thus + * can't be known at compile time. + * + * It allows to write code like this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * CameraSettingsV4L2Device cs( getDevicePointerFromSomewhere() ); + * Component it( cs.getCustomFeatureIterator() ); + * std::map m; + * while( it.isValid() ) + * { + * // collect all entries that are properties and store their current name and value in a map + * if( it.isProp() && it.isVisible() ) + * { + * Property prop( it ); + * m.insert( std::make_pair( prop.name(), prop.readS() ); + * } + * ++it; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import java.util.Hashtable; + * + * // ... + * + * CameraSettingsV4L2Device cs = new CameraSettingsV4L2Device( getDevicePointerFromSomewhere() ); + * Component it = cs.getCustomFeatureIterator(); + * Hashtable m = new Hashtable(); + * while( it.isValid() ) + * { + * // collect all entries that are properties and store their current name and value in a hash table + * if( it.isProp() && it.isVisible() ) + * { + * Property prop = new Property( it.hObj() ); + * m.put( prop.name(), prop.readS() ); + * } + * it = it.nextSibling(); + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * cs = acquire.CameraSettingsV4L2Device(pDev) + * it = acquire.Component(cs.getCustomFeatureIterator()) + * m = {} + * while it.isValid: + * # collect all entries that are properties and store their current name and value in a map + * if it.isProp and it.isVisible: + * prop = acquire.Property(it); + * m[prop.name()] = prop.readS() + * it = it.nextSibling() + * \endcode + * \endif + */ + Component getCustomFeatureIterator( void ) const + { + return m_customFeatureIterator; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the width of the image supplied by the V4L2 device. + /** + * \sa V4L2 API at http://v4l2spec.bytesex.org/spec-single/v4l2.html + */ + PropertyI imageWidth; + /// \brief An integer property defining the height of the image supplied by the V4L2 device. + /** + * \sa V4L2 API at http://v4l2spec.bytesex.org/spec-single/v4l2.html + */ + PropertyI imageHeight; + /// \brief An integer property defining the video standard. + /** + * Use this property to configure the V4L2-device corresponding to the connected video source. + * Available video standards depend on the V4L2-device and conform to \b v4l2_std_id + * \sa V4L2 API at http://v4l2spec.bytesex.org/spec-single/v4l2.html + */ + PropertyI videoStandard; + /// \brief An integer property defining the pixel format of captured frames. + /** + * Use this property to set the pixel format within the image buffer supplied by the V4L2-device. + * Available pixel formats depend on the V4L2-device and conform to \b v4l2_fourcc() + * \sa V4L2 API at http://v4l2spec.bytesex.org/spec-single/v4l2.html + */ + PropertyI pixelFormat; + /// \brief An integer property to adjust the brightness. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI brightness; + /// \brief An integer property to adjust the contrast. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI contrast; + /// \brief An integer property to adjust the saturation. + /** + * This property represents a V4L2-control ID. + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI saturation; + /// \brief An integer property to adjust the hue. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI hue; + /// \brief An integer property to adjust the black level. + /** + * This property represents a V4L2-control ID. + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI blackLevel; + /// \brief An enumerated integer property to switch on/off the auto white balance function of the V4L2-device. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean autoWhiteBalance; + /// \brief An integer property to adjust the red balance. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI redBalance; + /// \brief An integer property to adjust the blue balance. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI blueBalance; + /// \brief An integer property to adjust the gamma. + /** + * This property represents a V4L2-control ID + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a min-value, a max-value and step-width are defined. Thus, invalid values may be tuned after writing to fit within the limits. + */ + PropertyI gamma; + /// \brief An integer property to adjust the exposure. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI exposure; + /// \brief An enumerated integer property to switch on/off the auto gain. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean autoGain; + /// \brief An integer property to adjust the gain. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI gain; + /// \brief An enumerated integer property to mirror the frames horizontally. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean HFlip; + /// \brief An integer property to mirror the frames vertically. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean VFlip; + /// \brief An enumerated integer property to enable power line frequency filter. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * + * If supported, possible values conform to V4L2 API: + * + * + * + * + * + *
string representationnumerical representation
V4L2_CID_POWER_LINE_FREQUENCY_DISABLED0
V4L2_CID_POWER_LINE_FREQUENCY_50HZ1
V4L2_CID_POWER_LINE_FREQUENCY_60HZ2
+ */ + PropertyI powerLineFrequency; + /// \brief An enumerated integer property to switch on/off auto hue. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean hueAuto; + /// \brief An integer property to adjust white balance temperature. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI whiteBalanceTemperature; + /// \brief An integer property to adjust the sharpness. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI sharpness; + /// \brief An integer property to adjust the backlight compensation. + /** + * This property represents a V4L2-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a min-value, a max-value and step-width are defined. Thus, invalid values may be tuned after writing to fit within the limits. + */ + PropertyI backlightCompensation; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION + +# if !defined(IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) +//----------------------------------------------------------------------------- +/// \brief A class to control the automatic control parameters of a device(\b Device specific interface layout only). +/** + * Currently this class provides access to the properties, which control the way the + * AGC(\b A utomatic \b G ain \b C ontrol) and the AEC + * (\b A utomatic \b E xpose \b C ontrol) operates. + * + * The values used to capture the image, which are directly influenced by this properties + * (e.g. the gain or the exposure time) will be returned as part of the result of the + * image request. + * + * \note + * Not every device will offer the features provided in this class. Before accessing any members + * and/or properties call the function \b mvIMPACT::acquire::AutoControlParameters::isAvailable. + * If this function returns false, no other member or function call in this class will return valid + * results. + * + * \note + * Instances of these class can't be constructed directly. Its parameters can + * be accessed via an instance of the class \b mvIMPACT::acquire::CameraSettingsBlueDevice. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class AutoControlParameters : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class CameraSettingsBlueDevice; + bool m_boAvailable; + explicit AutoControlParameters( HOBJ hObj ): m_boAvailable( false ), aoiHeight(), + aoiStartX(), aoiStartY(), aoiWidth(), aoiMode(), desiredAverageGreyValue(), + controllerSpeed(), controllerGain(), controllerIntegralTime_ms(), controllerDerivativeTime_ms(), + controllerDelay_Images(), gainLowerLimit_dB(), + gainUpperLimit_dB(), exposeLowerLimit_us(), exposeUpperLimit_us() + { + ComponentLocator locator( hObj ); + HOBJ hRoot = locator.findComponent( "AutoControlParameters" ); + if( hRoot != INVALID_ID ) + { + m_hRoot = hRoot; + locator.bindSearchBase( locator.searchbase_id(), "AutoControlParameters" ); + locator.bindComponent( aoiMode, "AoiMode" ); + locator.bindComponent( desiredAverageGreyValue, "DesiredAverageGreyValue" ); + locator.bindComponent( controllerSpeed, "ControllerSpeed" ); + locator.bindComponent( controllerDelay_Images, "ControllerDelay_Images" ); + locator.bindComponent( gainLowerLimit_dB, "GainLowerLimit_dB" ); + locator.bindComponent( gainUpperLimit_dB, "GainUpperLimit_dB" ); + locator.bindComponent( exposeLowerLimit_us, "ExposeLowerLimit_us" ); + locator.bindComponent( exposeUpperLimit_us, "ExposeUpperLimit_us" ); + if( locator.findComponent( "ControllerParameter" ) != INVALID_ID ) + { + locator.bindSearchBase( hRoot, "ControllerParameter" ); + locator.bindComponent( controllerGain, "ControllerGain" ); + locator.bindComponent( controllerIntegralTime_ms, "IntegralTime_ms" ); + locator.bindComponent( controllerDerivativeTime_ms, "DerivativeTime_ms" ); + } + locator.bindSearchBase( hRoot ); + if( locator.findComponent( "Aoi" ) != INVALID_ID ) + { + locator.bindSearchBase( hRoot, "Aoi" ); + locator.bindComponent( aoiHeight, "H" ); + locator.bindComponent( aoiStartX, "X" ); + locator.bindComponent( aoiStartY, "Y" ); + locator.bindComponent( aoiWidth, "W" ); + } + m_boAvailable = true; + } + } +public: + /// \brief This function should be called to check if this device offers auto control parameters. + /** + * \return + * - true if the device offers the features defined by this object. + * - false otherwise + */ + bool isAvailable( void ) const + { + return m_boAvailable; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the height of the rectangle used for the parameter calculation. + PropertyI aoiHeight; + /// \brief An integer property defining the X-offset of the rectangle used for the parameter calculation. + /** + * Example: When setting this property to 5 the first pixel in each line of + * the resulting rectangle used for the calculation will be pixel number 5 + * of each line transmitted by the camera. + */ + PropertyI aoiStartX; + /// \brief An integer property defining the Y-offset of the rectangle used for the parameter calculation. + /** + * Example: When setting this property to 5 the first line of + * the resulting rectangle used for the calculation will be line number 5 of the + * image transmitted by the camera. + */ + PropertyI aoiStartY; + /// \brief An integer property defining the width of the rectangle. + PropertyI aoiWidth; + /// \brief An enumerated integer property defining the which area of the image is used for the calculation of the parameters. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAoiMode. + */ + PropertyIAoiMode aoiMode; + /// \brief An integer property defining the average grey value to be reached within the AOI in the image by the control circuit. + /** + * For multi-byte pixel formats like e.g. \b mvIMPACT::acquire::ibpfMono10 this value will refer to + * the 8 most significant bits of the pixel data, thus e.g a value of 128 for this property will result + * it the controller trying reach an average grey value of 512 (0x200). + */ + PropertyI desiredAverageGreyValue; + /// \brief An enumerated integer property defining the speed the control circuit will be operated in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAutoControlSpeed. + * + * Once the controller started to react and adapt itself to a new situation, this property will + * define how long this adaption will take, while \b AutoControlParameters::controllerDelay_Images + * defines the number of images to wait from a detected change to the actual start of the + * adaption to this new situation. + */ + PropertyIAutoControlSpeed controllerSpeed; + /// \brief The \b P fraction of the controller. + /** + * This feature will only be visible when \b mvIMPACT::acquire::AutoControlParameters::controllerSpeed + * is set to \b mvIMPACT::acquire::acsUserDefined. + */ + PropertyF controllerGain; + /// \brief The \b I fraction of the controller. + /** + * This feature will only be visible when \b mvIMPACT::acquire::AutoControlParameters::controllerSpeed + * is set to \b mvIMPACT::acquire::acsUserDefined. + */ + PropertyF controllerIntegralTime_ms; + /// \brief The \b D fraction of the controller. + /** + * This feature will only be visible when \b mvIMPACT::acquire::AutoControlParameters::controllerSpeed + * is set to \b mvIMPACT::acquire::acsUserDefined. + */ + PropertyF controllerDerivativeTime_ms; + /// \brief An integer property to influence the speed the AGC and/or AEC control circuit will react and adapt to changes. + /** + * While \b AutoControlParameters::controllerSpeed influences the overall time + * needed to adjust the controller to a new situation, this property can be used to define a + * delay when the controller shall start to adapt to a changed situation. + */ + PropertyI controllerDelay_Images; + /// \brief A float property defining the lower limit for the cameras gain(in dB). + /** + * When the AGC is active this value defines the minimum value for the cameras gain. + * Even if the controller can reach the desired average grey value, the gain will + * never fall below this value. + */ + PropertyF gainLowerLimit_dB; + /// \brief A float property defining the upper limit for the cameras gain(in dB). + /** + * When the AGC is active this value defines the maximum value for the cameras gain. + * Even if the controller can reach the desired average grey value, the gain will + * never exceed this value. + */ + PropertyF gainUpperLimit_dB; + /// \brief A float property defining the lower limit for the sensors expose time(in us). + /** + * When the AEC is active this value defines the minimum value for the sensors expose time(in us). + * Even if the controller can reach the desired average grey value, the expose time will + * never fall below this value. + */ + PropertyI exposeLowerLimit_us; + /// \brief An integer property defining the upper limit for the sensors expose time in us. + /** + * When the AEC is active this value defines the maximum value for the sensors expose time(in us). + * Even if the controller can reach the desired average grey value, the expose time will + * never exceed this value. + */ + PropertyI exposeUpperLimit_us; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class for camera related settings belonging to the mvBlueXXX-series (\b Device specific interface layout only). +/** + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsBlueDevice : public CameraSettingsBase +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsBlueDevice object. + explicit CameraSettingsBlueDevice( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : CameraSettingsBase( pDev, settingName ), + autoControlMode(), autoGainControl(), autoExposeControl(), gain_dB(), + offset_pc(), pixelClock_KHz(), exposeMode(), expose_us(), + binningMode(), testMode(), triggerMode(), frameDelay_us(), autoControlParameters( m_hRoot ) + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( autoControlMode, "AutoControlMode" ); + locator.bindComponent( autoGainControl, "AutoGainControl" ); + locator.bindComponent( autoExposeControl, "AutoExposeControl" ); + locator.bindComponent( gain_dB, "Gain_dB" ); + locator.bindComponent( offset_pc, "Offset_pc" ); + locator.bindComponent( pixelClock_KHz, "PixelClock_KHz" ); + locator.bindComponent( exposeMode, "ExposeMode" ); + locator.bindComponent( expose_us, "Expose_us" ); + locator.bindComponent( binningMode, "BinningMode" ); + locator.bindComponent( testMode, "TestMode" ); + locator.bindComponent( triggerMode, "TriggerMode", 0, 0 ); + locator.bindComponent( frameDelay_us, "FrameDelay_us" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the auto control mode the device is operated in. + /** + * This property can be used to control the overall behaviour of the algorithms used for performing AEC + * (\b A utomatic \b E xpose \b C ontrol) or AGC (\b A utomatic \b G ain \b C ontrol). + * This could be done by the device itself thus e.g. even in the analog domain or e.g. by a software + * process in the driver. Each method will offer certain advantages and disadvantages and depending on the + * application the correct method can be selected. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAutoControlMode. + * + * Every device or even different models belonging to the same device family may support different auto control modes, + * thus it's crucial to query the valid modes for each device by reading the properties translation dictionary BEFORE trying + * to assign a certain value to this property. + */ + PropertyIAutoControlMode autoControlMode; + /// \brief An enumerated integer property, which represents the current mode the AGC (\b A utomatic \b G ain \b C ontrol) is operated in. + /** + * The values used to capture the image, which are directly influenced by an activated AGC or AEC + * (e.g. the gain or the exposure time) will be returned as part of the result of the + * image request. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAutoGainControl. + * + * \note + * This property is not supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIAutoGainControl autoGainControl; + /// \brief An enumerated integer property, which represents the current mode the AEC (\b A utomatic \b E xpose \b C ontrol) is operated in. + /** + * The values used to capture the image, which are directly influenced by an activated AGC or AEC + * (e.g. the gain or the exposure time) will be returned as part of the result of the + * image request. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAutoExposureControl. + * + * \note + * This property might not be supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIAutoExposureControl autoExposeControl; + /// \brief A float property defining the gain in dB. + /** + * The formula for given \c gain_dB is + * \code + * gain_x= 10 ^ (gain_dB/20) + * \endcode + * + * \b Example: + * + * \code + * gain_x = 10 ^ (6/20) = 1.995 + * \endcode + * + * I.e. increasing the gain setting by 6dB corresponds to factor of 2. + * + * The formula for given gain_x is + * \code + * gain_dB = 20*log(gain_x) dB + * \endcode + * + * Where: \n + * \c gain_dB: MATRIX VISION gain value (logarithmic) \n + * \c gain_x: multiplicative gain \n + * \c ^: power function \n + */ + PropertyF gain_dB; + /// \brief A float property defining the analogue sensor offset in percent of the allowed range (sensor specific). + /** + * This property influences the average grey level when no light reaches the sensor. + * + */ +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + /** \b mvBlueFOX \b specific: + * Changing its value will have no effect if \b mvIMPACT::acquire::CameraSettingsBlueFOX::offsetAutoCalibration is set to + * \b mvIMPACT::acquire::aocOn. + * + * By default + * this value will be around 10 (if \b mvIMPACT::acquire::CameraSettingsBlueFOX::offsetAutoCalibration if set + * to \b mvIMPACT::acquire::aocOn). This means the average grey value for an image + * taken in a completely dark environment will be around 10. When setting + * \b mvIMPACT::acquire::CameraSettingsBlueFOX::offsetAutoCalibration to \b mvIMPACT::acquire::aocOff + * \b mvIMPACT::acquire::CameraSettingsBlueFOX::offset_pc can be used to modify this value. + */ +# endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + /** + * \image html Offset_pc.png + * The valid range for this property lies between -100% and +100%, whereas negative values + * will shifts the black level towards 0 and positive values to 255. + * + * \note + * This property might not be supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyF offset_pc; + /// \brief An enumerated integer property defining the pixel clock of the camera sensor in KHz. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraPixelClock. + * + * \note + * Changing the pixel clock at runtime will have major impact on the overall behaviour of the + * camera. The pixel clock should therefore not be modified constantly during the execution + * of the application code. Whenever this property is changed, the next images captured should + * be skipped if a device works with an active auto offset calibration controller circuit as then the + * control circuits on the camera might need one to three images until all control loops are + * locked again. + * + * Every device or even different models belonging to the same device family may support different pixel clocks, + * thus it's crucial to query the valid clock modes for each sensor by reading the properties translation dictionary. + */ + PropertyICameraPixelClock pixelClock_KHz; + /// \brief An enumerated integer property defining the exposure mode the camera sensor is operated in. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExposeMode. + * + * \note + * Not every device will offer the same options. + * Check for valid modes by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyICameraExposeMode::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyICameraExposeMode::getTranslationDictValue. + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyICameraExposeMode::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyICameraExposeMode exposeMode; + /// \brief An integer property which defines the exposure time for an image in us. + /** + * \image html Expose_us.png + * + */ + PropertyI expose_us; + /// \brief An enumerated integer property defining the binning mode the camera is operated in. + /** + * By default the no binning will be performed. + * \note + * Not every camera will support every binning mode. To find out which binning modes + * are supported by your camera you can query the properties translation table with + * the functions \b mvIMPACT::acquire::PropertyICameraBinningMode::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyICameraBinningMode::getTranslationDictValue + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyICameraBinningMode::getTranslationDict + * in addition to the functions mentioned above. + * \endif + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraBinningMode. + */ + PropertyICameraBinningMode binningMode; + /// \brief An enumerated integer property defining the image transmission mode of the camera. + /** + * If this property is set to \b mvIMPACT::acquire::ctmOff the 'normal' image + * captured by the cameras sensor will be transmitted. This is the default. + * To ensure correct operation the camera might define several test modes where + * some kind of well defined pattern will be transmitted. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTestMode. No every + * test mode will be supported by every device. + */ + PropertyICameraTestMode testMode; + /// \brief An enumerated integer property which defines what kind of trigger mode shall be used for an image acquisition. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTriggerMode. + * + * \note + * Not every device will support every trigger mode. To find out which trigger modes are supported by a specific + * device at runtime the properties translation dictionary should be queried. + * + * \note + * Also the sensor specific part of this manual will contain a list of trigger modes that are available for + * this specific image sensor. + */ + PropertyICameraTriggerMode triggerMode; + /// \brief An integer property defining the delay in us between an external trigger event an the begin of the sensor exposure. + /** + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyI frameDelay_us; + /// \brief Provides access to the control parameters for AGC and AEC. + /** + * \note + * These settings will only affect the image if \b mvIMPACT::acquire::CameraSettingsBlueDevice::autoGainControl, + * \b mvIMPACT::acquire::CameraSettingsBlueDevice::autoExposeControl or both are set to active. + */ + AutoControlParameters autoControlParameters; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +#ifndef WRAP_JAVA + /// \brief Provides access to the control parameters for AGC and AEC. + /** + * \note + * These settings will only affect the image if \b mvIMPACT::acquire::CameraSettingsBlueDevice::autoGainControl, + * \b mvIMPACT::acquire::CameraSettingsBlueDevice::autoExposeControl or both are set to active. + */ + AutoControlParameters& getAutoControlParameters( void ) + { + return autoControlParameters; + } +#endif // #ifndef WRAP_JAVA +}; +# endif // #if !defined(IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) + +# if !defined(IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) +//----------------------------------------------------------------------------- +/// \brief A class to configure a HDR (High Dynamic Range) knee point (\b Device specific interface layout only). +/** + * \note + * Not every device will offer the features provided in this class. Before accessing properties call + * the function \b mvIMPACT::acquire::Component::isValid. Right now only the mvBlueFOX-x00wx types + * will support the features defined by this class. + * + * \note + * Instances of these class can't be constructed directly. Its parameters can + * be accessed via an instance of the class \b mvIMPACT::acquire::CameraSettingsBlueFOX or + * \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class HDRKneePoint : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class HDRControl; + explicit HDRKneePoint( HOBJ hObj ): ComponentCollection( hObj ) + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( HDRControlVoltage_mV, "HDRControlVoltage_mV" ); + locator.bindComponent( HDRExposure_ppm, "HDRExposure_ppm" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property that can be used to define the control voltage in mV for this knee point. + PropertyI HDRControlVoltage_mV; + /// \brief An enumerated integer property that can be used to define the exposure time in ppm of the overall exposure time for this knee point. + PropertyI HDRExposure_ppm; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class to control the HDR (High Dynamic Range) parameters of a device (\b Device specific interface layout only). +/** + * \note + * Not every device will offer the features provided in this class. Before accessing properties call + * the function \b mvIMPACT::acquire::Component::isValid. Right now only the mvBlueFOX-x00wx, mvBlueFOX-x02dx and + * mvBlueCOUGAR-x00wx as well as mvBlueCOUGAR-x02dx types will support the features defined by this class. + * + * \note + * Instances of these class can't be constructed directly. Its parameters can + * be accessed via an instance of the class \b mvIMPACT::acquire::CameraSettingsBlueFOX or + * \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class HDRControl : public ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class CameraSettingsBlueCOUGAR; + friend class CameraSettingsBlueFOX; + typedef std::vector HDRKneePointContainer; +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + bool m_boAvailable; + HDRKneePointContainer m_KneePoints; + HOBJ m_HDRControlRoot; + unsigned int m_refCnt; + explicit ReferenceCountedData() : m_boAvailable( false ), m_KneePoints(), m_HDRControlRoot( INVALID_ID ), m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + const HDRKneePointContainer::size_type HDRKneePointCnt = m_KneePoints.size(); + for( HDRKneePointContainer::size_type h = 0; h < HDRKneePointCnt; h++ ) + { + delete m_KneePoints[h]; + } + } + }* m_pRefData; +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + void bindPublicProperties( void ) + //----------------------------------------------------------------------------- + { + if( m_pRefData->m_HDRControlRoot != INVALID_ID ) + { + ComponentLocator locator( m_pRefData->m_HDRControlRoot ); + locator.bindComponent( HDREnable, "HDREnable" ); + locator.bindComponent( HDRMode, "HDRMode" ); + locator.bindComponent( HDRKneePointCount, "HDRKneePointCount" ); + } + } + //----------------------------------------------------------------------------- + explicit HDRControl( HOBJ hObj ): ComponentCollection( hObj ), m_pRefData( new ReferenceCountedData() ) + //----------------------------------------------------------------------------- + { + ComponentLocator locator( m_hRoot ); + HOBJ hRoot = locator.findComponent( "HDRControl" ); + if( hRoot != INVALID_ID ) + { + m_hRoot = hRoot; + m_pRefData->m_HDRControlRoot = m_hRoot; + bindPublicProperties(); + locator.bindSearchBase( locator.searchbase_id(), "HDRControl" ); + // create the HDR knee point objects for this setting + Component it; + locator.bindComponent( it, "HDRKneePoints" ); + if( it.isValid() ) + { + it = it.firstChild(); + while( it.isValid() ) + { + m_pRefData->m_KneePoints.push_back( new HDRKneePoint( it.hObj() ) ); + ++it; + } + } + m_pRefData->m_boAvailable = true; + } + } +public: + /// \brief Copy constructor. + /** + * Creates a new object from an existing device object. Keep in mind that this new object + * will provide access to the very same hardware and therefore you might as well use the original + * reference. This constructor is only provided for internal reference counting to guarantee correct operation of the + * objects of this class under all platforms and languages. + */ + explicit HDRControl( const HDRControl& src ) : ComponentCollection( src.m_hRoot ), m_pRefData( src.m_pRefData ), HDREnable( src.HDREnable ), + HDRMode( src.HDRMode ), HDRKneePointCount( src.HDRKneePointCount ) + { + ++( m_pRefData->m_refCnt ); + } + ~HDRControl() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::HDRControl objects. + HDRControl& operator=( const HDRControl& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++( m_pRefData->m_refCnt ); + bindPublicProperties(); + } + return *this; + } + /// \brief This function should be called to check if this device offers HDR (High Dynamic Range) control parameters. + /** + * \return + * - true if the device offers the features defined by this object. + * - false otherwise + */ + bool isAvailable( void ) const + { + return m_pRefData->m_boAvailable; + } + /// \brief Returns a reference to a set of user definable parameters to configure a HDR (High Dynamic Range) knee point. + /** + * Use the property \b mvIMPACT::acquire::HDRControl::HDRKneePointCount to find out how many knee points are available + * or to change the number of knee points. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr is invalid(too large) a STL out_of_range exception + * will be thrown. + * \endif + * + * \return A reference to a set of user definable parameters to configure a HDR (High Dynamic Range) knee point. + */ + HDRKneePoint& getHDRKneePoint( + /// [in] The number of the knee point to be returned + unsigned int nr ) const + { + return *( m_pRefData->m_KneePoints.at( nr ) ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property which can be used to enable/disable HDR (High Dynamic Range) mode. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean HDREnable; + /// \brief An enumerated integer property which can be used to configure the HDR (High Dynamic Range) mode to work with. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraHDRMode. + */ + PropertyICameraHDRMode HDRMode; + /// \brief An integer property to define the number of knee points to work with when \b mvIMPACT::acquire::HDRControl::HDRMode is set to \b mvIMPACT::acquire::cHDRmUser. + PropertyI HDRKneePointCount; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #if !defined(IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION) || !defined(IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION) + +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief \b mvBlueFOX related camera settings(\b Device specific interface layout only). +/** + * This class contains properties to control the way the image sensor of the + * \b mvBlueFOX behaves. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsBlueFOX : public CameraSettingsBlueDevice +//----------------------------------------------------------------------------- +{ + HDRControl HDRControl_; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsBlueFOX object. + explicit CameraSettingsBlueFOX( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : CameraSettingsBlueDevice( pDev, settingName ), HDRControl_( m_hRoot ), + offsetAutoCalibration(), offsetCorrection_pc(), offsetAutoBlackLevel(), + offsetAutoBlackSpeed(), lineDelay_clk(), advancedOptions(), + flashToExposeDelay_us(), flashMode(), flashType(), shutterMode(), + triggerSource(), sensorTimingMode() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( offsetAutoCalibration, "OffsetAutoCalibration" ); + locator.bindComponent( offsetCorrection_pc, "OffsetCorrection_pc" ); + locator.bindComponent( offsetAutoBlackLevel, "OffsetAutoBlackLevel" ); + locator.bindComponent( offsetAutoBlackSpeed, "OffsetAutoBlackSpeed" ); + locator.bindComponent( lineDelay_clk, "LineDelay_clk" ); + locator.bindComponent( advancedOptions, "AdvancedOptions" ); + locator.bindComponent( flashToExposeDelay_us, "FlashToExposeDelay_us" ); + locator.bindComponent( flashMode, "FlashMode" ); + locator.bindComponent( flashType, "FlashType" ); + locator.bindComponent( shutterMode, "ShutterMode" ); + locator.bindComponent( triggerSource, "TriggerSource" ); + locator.bindComponent( sensorTimingMode, "SensorTimingMode" ); + } + /// \brief Returns the \b mvIMPACT::acquire::HDRControl object associated with this setting. + HDRControl& getHDRControl( void ) + { + return HDRControl_; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the offset calibration mode. + /** + * If this property is set to \b mvIMPACT::acquire::aocOff + * the offset can be adjusted manually by modifying the \b mvIMPACT::acquire::CameraSettingsBlueFOX::offset_pc and + * mvIMPACT::acquire::CameraSettingsBlueFOX::offsetCorrection_pc properties. + * + * If set to \b mvIMPACT::acquire::aocOn the offset is approx. 10. That means, + * that the medium pixel count is 10, in case no light is falling on the sensor. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAutoOffsetCalibration. + */ + PropertyIAutoOffsetCalibration offsetAutoCalibration; + /// \brief A float property defining and \b additional analogue sensor offset in percent of the allowed range (sensor specific) \b per \b color \b channel. + /** + * Together with value of the property \b mvIMPACT::acquire::CameraSettingsBlueDevice::offset_pc this property influences the average grey level + * when no light reaches the sensor. + * + * This property stores 4 values. + * - The value at index 0 applies to the green component of the red-green rows of the bayer pattern + * - The value at index 1 applies to the red component of the bayer pattern + * - The value at index 2 applies to the green component of the blue-green rows of the bayer pattern + * - The value at index 3 applies to the blue component of the bayer pattern + * + * \note + * This property might not be supported by every device. Therefore always call the function + * \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * In addition to that this property must be enabled explicitly by setting the advanced option bit + * \b mvIMPACT::acquire::daoEnablePerChannelOffsetCorrection of the property + * \b mvIMPACT::acquire::CameraSettingsBlueFOX::advancedOptions. + * \sa + * \b mvIMPACT::acquire::CameraSettingsBlueDevice::offset_pc + */ + PropertyF offsetCorrection_pc; + /// \brief An integer property defining the digital value assumed as black. + /** + * Modifying this property in rare cases might be useful to achieve a higher dynamic range for noise close to the black + * level. + * + * \note + * As the \b mvBlueFOX internally works with a 10 bit analog to digital conversion increasing this + * value by 4 will result in a black level increased by about 1 in the resulting 8 bit raw image + * delivered from the camera. + */ + PropertyI offsetAutoBlackLevel; + /// \brief An enumerated integer property defining the speed of the auto offset calibration circuit. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBlueFOXOffsetAutoBlackSpeed. + */ + PropertyIBlueFOXOffsetAutoBlackSpeed offsetAutoBlackSpeed; + /// \brief An integer property defining the delay in clocks between two lines. + /** + * Can be used to slow down the image readout the reduce the peak bandwidth required + * for the transfer. + */ + PropertyI lineDelay_clk; + /// \brief An enumerated integer property defining a collection of advanced options that can be enabled or disabled. + /** + * This property is highly sensor dependent. Each sensor might offer a different sub set of the options offered. + * Only experienced users should work with this feature. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceAdvancedOptions. + */ + PropertyIDeviceAdvancedOptions advancedOptions; + /// \brief An integer property defining the delay in us between the start of the flash signal output and the beginning of the expose period of the image sensor. + /** + * \note + * This property is mainly provided for compatibility reasons. Previous versions of the + * \b mvBlueFOX driver produced a fixed delay of about 300 us between the beginning of the + * flash signal creation and the beginning of the sensors expose period. Newer versions of the + * driver do \b NOT produce this delay anymore which might cause a different illumination + * for applications using very intensive, short flash and expose times. Applications relying on + * the delay introduced in older driver versions should set this property to + * '300' by calling \b mvIMPACT::acquire::PropertyI::write. + * + * \sa + * \b mvIMPACT::acquire::CameraSettingsBlueDevice::expose_us + */ + PropertyI flashToExposeDelay_us; + /// \brief An enumerated integer property defining the behaviour of the flash output of the camera (if available). + /** + * If this property is set the cameras flash output (if available) will be pulsed + * during the exposure period of the sensor. In that case the pulse width will be equal + * to the exposure time. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraFlashMode. + * + * \sa + * \b mvIMPACT::acquire::CameraSettingsBlueFOX::flashToExposeDelay_us + */ + PropertyICameraFlashMode flashMode; + /// \brief An enumerated integer property defining the type of the flash output of the camera (if available). + /** + * Depending of the camera sensor type (\a rolling shutter or \a frame \a shutter + * there well be different modes available + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraFlashType. + */ + PropertyICameraFlashType flashType; + /// \brief An enumerated integer property defining the shutter mode to use. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraShutterMode. + */ + PropertyICameraShutterMode shutterMode; + /// \brief An enumerated integer property defining where the trigger signal is expected to occur. + /** + * When working with hardware generated signals via \b mvIMPACT::acquire::RTCtrProgram objects + * this property should be set to \b mvIMPACT::acquire::ctsRTCtrl as otherwise + * the program will not affect the behaviour of the camera. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTriggerSource. + */ + PropertyICameraTriggerSource triggerSource; + /// \brief An enumerated integer property defining the current image sensor timing mode. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBlueFOXSensorTiming. + */ + PropertyIBlueFOXSensorTiming sensorTimingMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief \b mvBlueCOUGAR related camera settings (\b Device specific interface layout only). +/** + * This class contains properties to control the way the image sensor(s) of the + * \b mvBlueCOUGAR behaves. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsBlueCOUGAR : public CameraSettingsBlueDevice +//----------------------------------------------------------------------------- +{ + typedef std::vector TriggerControlVector; + TriggerControlVector m_triggerControls; + HDRControl HDRControl_; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR object. + explicit CameraSettingsBlueCOUGAR( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : CameraSettingsBlueDevice( pDev, settingName ), + m_triggerControls(), HDRControl_( m_hRoot ), + triggerInterface(), triggerSource(), acquisitionBurstFrameCount() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( frameRate_Hz, "FrameRate_Hz" ); + locator.bindComponent( partialScanMode, "PartialScanMode" ); + locator.bindComponent( triggerInterface, "TriggerInterface" ); + locator.bindComponent( triggerSource, "TriggerSource" ); + locator.bindComponent( acquisitionBurstFrameCount, "AcquisitionBurstFrameCount" ); + if( locator.findComponent( "TriggerControls" ) != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "TriggerControls" ); + Component it( locator.searchbase_id() ); + it = it.firstChild(); + while( it.isValid() ) + { + m_triggerControls.push_back( new TriggerControl( it ) ); + ++it; + } + } + } + virtual ~CameraSettingsBlueCOUGAR() + { + TriggerControlVector::size_type vSize = m_triggerControls.size(); + for( TriggerControlVector::size_type i = 0; i < vSize; i++ ) + { + delete m_triggerControls[i]; + } + } + /// \brief Returns the number of \b mvIMPACT::acquire::TriggerControls available for this device. + /** + * This might be 0 if the device either does not support this feature. + */ + unsigned int getTriggerControlCount( void ) const + { + return static_cast( m_triggerControls.size() ); + } + /// \brief Returns a const pointer to a \b mvIMPACT::acquire::TriggerControl object. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr references an invalid pin a STL out_of_range exception + * will be thrown. + * \endif + * + * \note + * The features of each \b mvIMPACT::acquire::TriggerControl will only be visible and thus available, + * when \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR::triggerInterface + * is set to \b mvIMPACT::acquire::dtiAdvanced. + */ + const TriggerControl* triggerControl( + /// [in] The number of the trigger control + unsigned int nr ) const + { + return m_triggerControls.at( nr ); + } + /// \brief Returns a const pointer to a \b mvIMPACT::acquire::TriggerControl object or NULL if the name passed to the function does not specify a valid trigger control. + const TriggerControl* triggerControl( + /// [in] The name of the trigger control + const std::string& name ) const + { + const TriggerControlVector::size_type cnt = m_triggerControls.size(); + for( TriggerControlVector::size_type i = 0; i < cnt; i++ ) + { + const TriggerControl* p = triggerControl( static_cast( i ) ); + if( p->getDescription() == name ) + { + return p; + } + } + return 0; + } + /// \brief Returns the \b mvIMPACT::acquire::HDRControl object associated with this setting. + HDRControl& getHDRControl( void ) + { + return HDRControl_; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A float property defining the frame rate (in Hz) this device shall use to transfer images. + /** + * Depending on other parameters the desired frame rate might not be achievable (e.g. if the exposure time + * is higher than the frame period. In that case the device will automatically reduce the frame rate. + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyF frameRate_Hz; + /// \brief An enumerated integer property defining whether partial scan mode shall be used or not. + /** + * This property currently is only available for \b mvBlueCOUGAR-S devices. When partial scan mode is active, the + * frame rate can no longer be controlled be the property \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR::frameRate_Hz. + * The device will always transmit frames as fast as possible instead. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean partialScanMode; + /// \brief An enumerated integer property defining which view of the trigger interface to use. + /** + * This property mainly switches the visibility of trigger the different trigger interfaces. After applying changes to + * this property all trigger related features might have a different visibility. However the documentation will state + * what features are available in which mode. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceTriggerInterface. + */ + PropertyIDeviceTriggerInterface triggerInterface; + /// \brief An enumerated integer property defining where the trigger signal is expected to occur. + /** + * When working with hardware generated signals via \b mvIMPACT::acquire::RTCtrProgram objects + * this property should be set to \b mvIMPACT::acquire::ctsRTCtrl as otherwise + * the program will not affect the behaviour of the camera. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTriggerSource. + * + * \note + * This feature will only be visible and thus available, when \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR::triggerInterface + * is set to \b mvIMPACT::acquire::dtiStandard. + */ + PropertyICameraTriggerSource triggerSource; + /// \brief A 64-bit integer property defining the number of frames to acquire for each FrameBurstStart trigger. + /** + * \note + * This feature will only be taken into account if the \c FrameBurstStart trigger is active when \b mvIMPACT::acquire::CameraSettingsBlueCOUGAR::triggerInterface + * is set to \b mvIMPACT::acquire::dtiAdvanced. + */ + PropertyI64 acquisitionBurstFrameCount; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A class to access frame grabber related camera settings(\b Device specific interface layout only). +/** + * This class contains properties to control the way the a frame grabber + * behaves in connection with the connected camera. + * + * \note + * Not every frame grabber will support every property defined in this class. Please + * refer to the description of the individual properties and make heavy use of the + * function \b mvIMPACT::acquire::Component::isValid in order to check whether + * a property is available for the device. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraSettingsFrameGrabber : public CameraSettingsBase +//----------------------------------------------------------------------------- +{ + typedef std::vector TriggerControlVector; + TriggerControlVector m_triggerControls; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraSettingsFrameGrabber object. + explicit CameraSettingsFrameGrabber( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : CameraSettingsBase( pDev, settingName ), + type(), aoiMode(), gain_dB(), offset_mV(), scanClock(), triggerMode(), softwareTriggerPeriod_ms(), + serialPortBaudrate(), interlacedMode(), acquisitionField(), scanRateMode(), scanRate_kHz(), + luminance_pc(), saturation_pc(), hue_pc(), contrast_pc(), lineCounter() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( type, "Type" ); + locator.bindComponent( aoiMode, "AoiMode" ); + locator.bindComponent( gain_dB, "Gain_dB" ); + locator.bindComponent( offset_mV, "Offset_mV" ); + locator.bindComponent( scanClock, "ScanClock" ); + locator.bindComponent( triggerMode, "TriggerMode", 0, 0 ); + locator.bindComponent( softwareTriggerPeriod_ms, "SoftwareTriggerPeriod_ms" ); + locator.bindComponent( serialPortBaudrate, "SerialPortBaudRate" ); + locator.bindComponent( interlacedMode, "InterlacedMode" ); + locator.bindComponent( acquisitionField, "AcquisitionField" ); + locator.bindComponent( scanRateMode, "ScanRateMode" ); + locator.bindComponent( scanRate_kHz, "ScanRate_kHz" ); + locator.bindComponent( luminance_pc, "Luminance_pc" ); + locator.bindComponent( saturation_pc, "Saturation_pc" ); + locator.bindComponent( hue_pc, "Hue_pc" ); + locator.bindComponent( contrast_pc, "Contrast_pc" ); + locator.bindComponent( lineCounter, "LineCounter" ); + if( locator.findComponent( "TriggerControls" ) != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "TriggerControls" ); + Component it( locator.searchbase_id() ); + if( it.isValid() ) + { + it = it.firstChild(); + while( it.isValid() ) + { + m_triggerControls.push_back( new TriggerControl( it ) ); + ++it; + } + } + } + } + virtual ~CameraSettingsFrameGrabber() + { + TriggerControlVector::size_type vSize = m_triggerControls.size(); + for( TriggerControlVector::size_type i = 0; i < vSize; i++ ) + { + delete m_triggerControls[i]; + } + } + /// \brief Returns the number of \b mvIMPACT::acquire::TriggerControls available for this device. + /** + * This might be 0 if the device either does not support this feature. + */ + unsigned int getTriggerControlCount( void ) const + { + return static_cast( m_triggerControls.size() ); + } + /// \brief Returns a const pointer to a \b mvIMPACT::acquire::TriggerControl object. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If \a nr references an invalid pin a STL out_of_range exception + * will be thrown. + * \endif + */ + const TriggerControl* triggerControl( + /// [in] The number of the trigger control + unsigned int nr ) const + { + return m_triggerControls.at( nr ); + } + /// \brief Returns a const pointer to a \b mvIMPACT::acquire::TriggerControl object or NULL if the name passed to the function does not specify a valid trigger control. + const TriggerControl* triggerControl( + /// [in] The name of the trigger control + const std::string& name ) const + { + const TriggerControlVector::size_type cnt = m_triggerControls.size(); + for( TriggerControlVector::size_type i = 0; i < cnt; i++ ) + { + const TriggerControl* p = triggerControl( static_cast( i ) ); + if( p->getDescription() == name ) + { + return p; + } + } + return 0; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the camera description used for the image acquisition. + /** + * This property \b ALWAYS defines a translation dictionary containing a string representation + * and a numerical value for the camera descriptions available for the device. The string + * representation of the camera description will be built from the property name of the class this + * camera description belongs to (e.g. \a 'Standard', \a 'NonStandard' or \a 'CameraLink') and + * the name of the camera description itself. Assuming a the device can handle standard + * video cameras and a description for a camera named \a 'MyCCIRCamera' will therefore + * add \a 'Standard_MyCCIRCamera' and a unique numerical representation to the properties + * translation dictionary. + */ + PropertyI type; + /// \brief An enumerated integer property defining the used AOI mode for the image capture. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraAoiMode. + */ + PropertyICameraAoiMode aoiMode; + /// \brief A float property defining the gain in dB. + /** + * This is the gain applied during the analogue to digital conversion inside the frame + * grabber, not applied inside the camera. + * + * * The formula for given \c gain_dB is + * \code + * gain_x= 10 ^ (gain_dB/20) + * \endcode + * + * \b Example: + * + * \code + * gain_x = 10 ^ (6/20) = 1.995 + * \endcode + * + * I.e. increasing the gain setting by 6dB corresponds to factor of 2. + * + * The formula for given gain_x is + * \code + * gain_dB = 20*log(gain_x) dB + * \endcode + * + * Where: \n + * \c gain_dB: MATRIX VISION gain value (logarithmic) \n + * \c gain_x: multiplicative gain \n + * \c ^: power function \n + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyF gain_dB; + /// \brief An integer property defining the offset in milli-Volt. + /** + * This is the analogue offset applied during the analogue to digital conversion inside the frame + * grabber, not applied inside the camera. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI offset_mV; + /// \brief An enumerated integer property defining the scan clock mode used for the current acquisition. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TScanClock. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! Digital frame grabbers will however \b NOT support + * this property. + */ + PropertyIScanClock scanClock; + /// \brief An enumerated integer property defining the behaviour of the frame grabbers trigger input. + /** + * \note + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceTriggerMode. However + * not every device will offer all these trigger modes but a subset of them. Valid trigger modes therefore + * can be found by reading the properties translation dictionary. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyIDeviceTriggerMode triggerMode; + /// \brief An integer property defining the software simulated trigger period. + /** + * When \b mvIMPACT::acquire::CameraSettingsFrameGrabber::triggerMode is set to + * \b mvIMPACT::acquire::dtmPeriodically this property defines the + * interval between two consecutive external trigger events simulated by the driver. + * + * Currently this property is only available for \b mvTITAN and \b mvGAMMA frame grabbers. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI softwareTriggerPeriod_ms; + /// \brief An enumerated integer property defining the baud rate of the serial communication port between frame grabber and camera. + /** + * Currently this property is only available for CameraLink® frame grabbers. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraSerialPortBaudRate. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyICameraSerialPortBaudRate serialPortBaudrate; + /// \brief An enumerated integer property defining how the image from the camera shall be captured. + /** + * If a video signal is transmitted to the capture device in an interlaced format, the device + * can either capture each individual frame, or merge two frames together into a complete image. + * + * This property will be invisible when the camera description selected by the property + * \b mvIMPACT::acquire::CameraSettingsFrameGrabber::type does define it property + * \b mvIMPACT::acquire::CameraDescriptionBase::interlacedType to be \b mvIMPACT::acquire::citNone + * as the decision whether an interlaced image shall be reconstructed from frames or left + * as individual frame is redundant if the video source transmits full frames only. + * + * The visibility of a property can be checked by calling \b mvIMPACT::acquire::Component::isVisible + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TInterlacedMode. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyIInterlacedMode interlacedMode; + /// \brief An enumerated integer property defining which frame(s) of an interlaced video signal will be digitised or triggers the start of the acquisition. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAcquisitionField. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyIAcquisitionField acquisitionField; + /// \brief An enumerated integer property defining the scan rate mode for this setting. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDeviceScanRateMode. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyIDeviceScanRateMode scanRateMode; + /// \brief An integer property defining the current scan frequency of the capture device. + /** + * This property is only visible if the \b mvIMPACT::acquire::CameraSettingsFrameGrabber::scanRateMode + * property is \b NOT in an auto mode. + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI scanRate_kHz; + /// \brief An integer property defining the luminance value to be applied to the image data by the frame grabber in per cent. + /** + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI luminance_pc; + /// \brief An integer property defining the saturation value to be applied to the image data by the frame grabber in per cent. + /** + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI saturation_pc; + /// \brief An integer property defining the hue value to be applied to the image data by the frame grabber in per cent. + /** + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI hue_pc; + /// \brief An integer property defining the contrast value to be applied to the image data by the frame grabber in per cent. + /** + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyI contrast_pc; + /// \brief An enumerated integer property defining the way line counter information is handled by the device. + /** + * This is interesting for line scan camera applications. + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TLineCounter. + * + * \note + * This property will not be available for every frame grabber, so before using it, check + * if the property is available at all by calling \b mvIMPACT::acquire::Component::isValid. Accessing + * an invalid property will raise an exception! + */ + PropertyILineCounter lineCounter; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to describe a camera (\b Device specific interface layout only). +/** + * A camera description object provides an abstract way to prepare the capture + * device (e.g. a frame grabber) for the connected imaging device (e.g. a camera). + * + * By selecting one of the available camera descriptions the underlying hardware + * will use the information provided in the camera description to prepare the + * image capture. Therefore it is crucial to select a camera description + * that matches the connected video signal as close as possible. If no description + * for the camera or imaging device connected is available a new description + * should be generated from one of the existing ones. This can be achieved by calling + * the function \b mvIMPACT::acquire::CameraDescriptionBase::copyDescription. A new + * camera description with the name that is passed to the function will be created. + * + * \note + * The name must be unique. There can't be two descriptions with the same name + * belonging to the same generic class (i.e. \a 'Standard' or \a 'CameraLink'®). However + * it's perfectly legal to have a camera description for standard analogue video signals + * and one for e.g. CameraLink® signals with the same name. + * + * This new description will be an exact copy of the one the copy function has been + * executed for. After creation this description can be selected e.g. by setting the + * property \b mvIMPACT::acquire::CameraSettingsFrameGrabber::type to the name of the + * new description. + * + * \note + * Please note that the name passed to the property \b mvIMPACT::acquire::CameraSettingsFrameGrabber::type + * does \b NOT exactly correspond to the name assigned to the new camera description. + * It is a combination of the class the camera is belonging to (e.g. \a 'Standard') and the actual name. + * So to select a camera description the name must be build from the return value of a call to + * \b mvIMPACT::acquire::CameraDescriptionBase::getClassName, an underscore ('_') and the + * actual name of the description: <class name>_<desc. name> + * + * Example: For a standard description with the name \a 'MyCam' the full name would be \a 'Standard_MyCam'. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * #include + * #include + * + * using namespace std; + * + * //----------------------------------------------------------------------------- + * int main( int argc, char* argv[] ) + * //----------------------------------------------------------------------------- + * { + * mvIMPACT::acquire::DeviceManager devMgr; + * mvIMPACT::acquire::Device* pDev = devMgr[0]; + * if( !pDev ) + * { + * cout << "No device found" << endl; + * return 1; + * } + * + * try + * { + * // the next line will raise an exception if this device does not + * // support camera descriptions (e.g. if it is a USB camera rather than a frame grabber) + * mvIMPACT::acquire::CameraDescriptionManager cdm( pDev ); + * mvIMPACT::acquire::CameraDescriptionStandard* pCam = cdm.cameraDescriptionStandard( "Generic" ); + * pCam->copyDescription( "MyCam" ); + * // Get access to the newly created description + * mvIMPACT::acquire::CameraDescriptionStandard* pMyCam = cdm.cameraDescriptionStandard( "MyCam" ); + * // Modify something + * pMyCam->videoStandard.write( vsRS170 ); + * pMyCam->scanStandard.write( ssITU601 ); + * // now save the description to make it available in all future sessions + * pMyCam->exportDescription(); + * // select the newly created description + * mvIMPACT::acquire::CameraSettingsFrameGrabber cs( pDev ); + * // the name for this property is always a combination of the class the camera + * // description is belonging to and the actual name: + * cs.type.writeS( pMyCam->getClassName() + "_" + pMyCam->name.read() ); + * } + * catch( const ImpactAcquireException& e ) + * { + * cout << "An exception occurred: " << e.getErrorString() << endl; + * return 1; + * } + * return 0; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * public class CameraDescriptionManagerExample + * //----------------------------------------------------------------------------- + * { + * //============================================================================= + * //=== Static member functions ================================================= + * //============================================================================= + * static + * { + * try + * { + * System.loadLibrary( "mvIMPACT_Acquire.java" ); + * } + * catch( UnsatisfiedLinkError e ) + * { + * System.err.println( "Native code library failed to load. Make sure the 'mvIMPACT_Acquire.java' library can be found in the systems search path.\n" + e ); + * System.exit( 1 ); + * } + * } + * + * //----------------------------------------------------------------------------- + * public static void main( String[] args ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr = new DeviceManager(); + * Device pDev = mvIMPACT.acquire.examples.helper.DeviceAccess.getDeviceFromUserInput( devMgr ); + * if( pDev == null ) + * { + * System.out.print( "Unable to continue!" ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * System.out.println( "Initialising the device. This might take some time..." ); + * try + * { + * pDev.open(); + * } + * catch( ImpactAcquireException e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * System.out.println( "An error occurred while opening device " + pDev.getSerial().read() + + * "(error code: " + e.getMessage() + ")." ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * try + * { + * // the next line will raise an exception if this device does not + * // support camera descriptions (e.g. if it is a USB camera rather than a frame grabber) + * CameraDescriptionManager cdm = new CameraDescriptionManager( pDev ); + * CameraDescriptionStandard pCam = cdm.cameraDescriptionStandard( "Generic" ); + * pCam.copyDescription( "MyCam" ); + * // Get access to the newly created description + * CameraDescriptionStandard pMyCam = cdm.cameraDescriptionStandard( "MyCam" ); + * // Modify something + * pMyCam.getVideoStandard().write( TVideoStandard.vsRS170 ); + * pMyCam.getScanStandard().write( TScanStandard.ssITU601 ); + * // now save the description to make it available in all future sessions + * pMyCam.exportDescription(); + * // select the newly created description + * CameraSettingsFrameGrabber cs = new CameraSettingsFrameGrabber( pDev ); + * // the name for this property is always a combination of the class the camera + * // description is belonging to and the actual name: + * cs.getType().writeS( pMyCam.getClassName() + "_" + pMyCam.getName().read() ); + * } + * catch( ImpactAcquireException e ) + * { + * System.out.println( "An error occurred: " + e.getMessage() + "." ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * try: + * # the next line will raise an exception if this device does not + * # support camera descriptions (e.g. if it is a USB camera rather than a frame grabber) + * cdm = acquire.CameraDescriptionManager(pDev) + * pCam = cdm.cameraDescriptionStandard("Generic") + * pCam.copyDescription("MyCam") + * # Get access to the newly created description + * pMyCam = cdm.cameraDescriptionStandard("MyCam") + * # Modify something + * pMyCam.videoStandard.write(acquire.vsRS170) + * pMyCam.scanStandard.write(acquire.ssITU601) + * # now save the description to make it available in all future sessions + * pMyCam.exportDescription() + * # select the newly created description + * cs = acquire.CameraSettingsFrameGrabber(pDev) + * # the name for this property is always a combination of the class the camera + * # description is belonging to and the actual name: + * cs.type.writeS(pMyCam.getClassName() + "_" + pMyCam.name.readS()) + * except Exception as e: + * print("An exception occurred: " + e.getErrorString()) + * \endcode + * \endif + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionBase : public ComponentCollection +//----------------------------------------------------------------------------- +{ + HDRV m_hDrv; +protected: + explicit CameraDescriptionBase( HDRV hDrv, HLIST hList ) : ComponentCollection( hList ), m_hDrv( hDrv ), name(), + videoOutput(), interlacedType(), aoiHeight(), aoiStartX(), aoiStartY(), aoiWidth() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( name, "Name" ); + locator.bindComponent( videoOutput, "VideoOutput" ); + locator.bindComponent( interlacedType, "InterlacedType" ); + locator.bindSearchBase( locator.searchbase_id(), "ActiveVideoAoi" ); + locator.bindComponent( aoiHeight, "H" ); + locator.bindComponent( aoiStartX, "X" ); + locator.bindComponent( aoiStartY, "Y" ); + locator.bindComponent( aoiWidth, "W" ); + } +public: + /// \brief Returns the class this description is belonging to. + /** + * \return The class this description is belonging to. + */ + std::string getClassName( void ) const + { + return ComponentList( m_hRoot ).contentDescriptor(); + } + /// \brief Creates a new camera description list as a copy of the current one. + /** + * This function can be used to create a new camera description list. It will create + * a deep copy of the properties referenced by this camera description and will append the new description + * to the list of camera descriptions. + * + * \note + * This will \b NOT store the new description permanently. After the driver has been + * closed, this data will be lost. To store the new list in a way that it will be available + * the next time the driver/device is opened again, \b mvIMPACT::acquire::CameraDescriptionBase::exportDescription must + * be called with the handle of the newly created description after this function. + * \sa + * \b mvIMPACT::acquire::CameraDescriptionBase::exportDescription, \n + * \b mvIMPACT::acquire::CameraDescriptionBase::importDescription + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - \b mvIMPACT::acquire::DEV_INPUT_PARAM_INVALID if new name matches a description that is already + * existing. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int copyDescription( + /// [in] The name for the newly created camera description. This name + /// \b MUST NOT match a description already existing. + const std::string& newName ) const + { + return DMR_CopyCameraDescription( m_hDrv, m_hRoot, newName.c_str() ); + } + /// \brief Stores the current camera description on disc. + /** + * This function can be used to store the current settings of a camera description + * permanently so that the next time the driver is initialized these settings are restored. + * + * When exporting a camera description a file in XML format will be written to disc. On + * Windows® camera descriptions will be stored under + * \code + * %ALLUSERS%/Documents/MATRIX VISION/mvIMPACT acquire/CameraFiles + * \endcode + * or + * \code + * %MVIMPACT_ACQUIRE_DATA_DIR%/CameraFiles + * \endcode + * which will point to the same folder), on Linux® this directory will be + * \code + * /etc/matrix-vision/mvimpact-acquire/camerafiles + * \endcode + * while under other platforms these files will end up in the current working directory. This behaviour can be modified + * by writing the property \b mvIMPACT::acquire::Device::customDataDirectory before initialising the + * device. + * + * \sa + * \b mvIMPACT::acquire::CameraDescriptionBase::copyDescription, \n + * \b mvIMPACT::acquire::CameraDescriptionBase::importDescription + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int exportDescription( void ) const + { + return DMR_ExportCameraDescription( m_hDrv, m_hRoot ); + } + /// \brief Updates a camera description with the data stored in a previous session or with the original default data. + /** + * When importing a camera description the device driver will try to retrieve the parameters + * needed from a XML file. On Windows® camera descriptions MUST be stored under + * \code + * %ALLUSERS%/Documents/MATRIX VISION/mvIMPACT acquire/CameraFiles + * \endcode + * or + * \code + * %MVIMPACT_ACQUIRE_DATA_DIR%/CameraFiles + * \endcode + * which will point to the same folder), under Linux® this directory will be + * \code + * /etc/matrix-vision/mvimpact-acquire/camerafiles + * \endcode + * while under other platforms these files MUST be located in the current working directory. + * This behaviour can be modified by writing the property \b mvIMPACT::acquire::Device::customDataDirectory before initialising the device. + * To get access to a XML description file within the application, these file must be copied to + * this directory \b BEFORE the device is initialized. During the initialisation process the + * device driver will process every file located under this location and will add them to + * the internal list of descriptions. Every camera located during this process and also descriptions + * created later on during the program operation can be selected via the property + * \b mvIMPACT::acquire::CameraSettingsFrameGrabber::type. + * + * \note + * In order not to bloat the device driver with redundant data it's wise only to store the + * descriptions needed for the application to run under this location. + * + * \note + * Only camera descriptions supported by the capture device will be added to the device + * drivers internal list and will therefore be accessible via the + * \b mvIMPACT::acquire::CameraDescriptionManager. + * + * To restore the default values valid during the driver was initialized the function + * \b mvIMPACT::acquire::ComponentCollection::restoreDefault can be used as well. + * + * \sa + * \b mvIMPACT::acquire::CameraDescriptionBase::exportDescription, \n + * mvIMPACT::acquire::CameraDescriptionBase::copyDescription + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR or \b mvIMPACT::acquire::TPROPHANDLING_ERROR otherwise. + */ + int importDescription( void ) const + { + return DMR_ImportCameraDescription( m_hDrv, m_hRoot ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property \b read-only containing the name of this camera description list. + PropertyS name; + /// \brief An enumerated integer property defining the type of video outputs this camera offers. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraOutput. + * + * \note + * This property will be \b (read-only) for camera descriptions of type + * \b mvIMPACT::acquire::CameraDescriptionCameraLink and \b mvIMPACT::acquire::CameraDescriptionSDI + * as for these camera types the video output depends on certain other parameters according to the + * corresponding standard. + */ + PropertyICameraOutput videoOutput; + /// \brief An enumerated integer property defining how the camera transmits image data. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraInterlacedType. + */ + PropertyICameraInterlacedType interlacedType; + /// \brief An integer property defining the number of active lines to capture from the camera. + PropertyI aoiHeight; + /// \brief An integer property defining the X-offset in pixels to the first active pixel to capture. + PropertyI aoiStartX; + /// \brief An integer property defining the Y-offset in lines to the first active line to capture. + PropertyI aoiStartY; + /// \brief An integer property defining the number of active pixels to capture per line. + PropertyI aoiWidth; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to describe an arbitrary digital camera signal(\b Device specific interface layout only). +/** + * This class provides access to all settings specific for digital video signals. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionDigitalBase : public CameraDescriptionBase +//----------------------------------------------------------------------------- +{ +protected: + explicit CameraDescriptionDigitalBase( HDRV hDrv, HLIST hList ) : CameraDescriptionBase( hDrv, hList ), bitsPerPixel(), + format(), bayerParity() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( bitsPerPixel, "BitsPerPixel" ); + locator.bindComponent( format, "Format" ); + locator.bindComponent( bayerParity, "BayerParity" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the number of bits per pixel currently transmitted by this camera. + PropertyI bitsPerPixel; + /// \brief An enumerated integer property defining the data format the camera is sending image data. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraDataFormat. + */ + PropertyICameraDataFormat format; + /// \brief An enumerated integer property defining the start pixel for a camera delivering an unconverted bayer image. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBayerMosaicParity. + */ + PropertyIBayerMosaicParity bayerParity; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to describe a SDI(Serial Digital Interface) camera signal (\b Device specific interface layout only). +/** + * This class provides access to all settings specific for SDI video signals. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionSDI : public CameraDescriptionDigitalBase +//----------------------------------------------------------------------------- +{ + friend class CameraDescriptionManager; + explicit CameraDescriptionSDI( HDRV hDrv, HLIST hList ) : CameraDescriptionDigitalBase( hDrv, hList ), videoStandard() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( videoStandard, "VideoStandard" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property for defining the video standard this camera is compliant with. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TVideoStandard. + */ + PropertyIVideoStandard videoStandard; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A base class to describe an arbitrary digital camera signal(\b Device specific interface layout only). +/** + * This class provides access to all settings specific for digital video signals. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionDigitalBase2 : public CameraDescriptionDigitalBase +//----------------------------------------------------------------------------- +{ +protected: + explicit CameraDescriptionDigitalBase2( HDRV hDrv, HLIST hList ) : CameraDescriptionDigitalBase( hDrv, hList ), + pixelsPerCycle(), scanMode() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( pixelsPerCycle, "PixelsPerCycle" ); + locator.bindComponent( scanMode, "ScanMode" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property defining the number of pixels per clock cycle transmitted by this camera. + /** + * This corresponds the number of taps used by the camera in the described configuration. + */ + PropertyI pixelsPerCycle; + /// \brief An enumerated integer property providing information about the sensor of this camera. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraScanMode. + */ + PropertyICameraScanMode scanMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class to describe a CameraLink® compliant camera(\b Device specific interface layout only). +/** + * This class provides access to all settings specific for CameraLink® compliant cameras. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionCameraLink : public CameraDescriptionDigitalBase2 +//----------------------------------------------------------------------------- +{ + friend class CameraDescriptionManager; + explicit CameraDescriptionCameraLink( HDRV hDrv, HLIST hList ) : CameraDescriptionDigitalBase2( hDrv, hList ), dataValid(), + tapsXGeometry(), tapsYGeometry() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( dataValid, "DataValid" ); + locator.bindComponent( tapsXGeometry, "TapsXGeometry" ); + locator.bindComponent( tapsYGeometry, "TapsYGeometry" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the way this camera transmits the data valid (\b DVAL) signal. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraLinkDataValidMode. + */ + PropertyICameraLinkDataValidMode dataValid; + /// \brief An enumerated integer property defining the way this camera transmits the pixel data in X direction. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTapsXGeometry. + */ + PropertyICameraTapsXGeometry tapsXGeometry; + /// \brief An enumerated integer property defining the way this camera transmits the pixel data in Y direction. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraTapsYGeometry. + */ + PropertyICameraTapsYGeometry tapsYGeometry; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class to describe a non-standard digital video signal(\b Device specific interface layout only). +/** + * This class provides access to all settings specific for non-standard digital video signals. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionDigital : public CameraDescriptionDigitalBase2 +//----------------------------------------------------------------------------- +{ + friend class CameraDescriptionManager; + explicit CameraDescriptionDigital( HDRV hDrv, HLIST hList ) : CameraDescriptionDigitalBase2( hDrv, hList ), + frameSync(), lineSync(), pixelClk() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( frameSync, "FrameSync" ); + locator.bindComponent( lineSync, "LineSync" ); + locator.bindComponent( pixelClk, "PixelClk" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the edge valid for the frame sync signal of this camera. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncEdge. + * + * \note + * Not every value defined by this enumeration will be supported by this property. Check which values + * are available by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDictValue + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyICameraExternalSyncEdge frameSync; + /// \brief An enumerated integer property defining the edge valid for the line sync. of this camera. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncEdge. + * + * \note + * Not every value defined by this enumeration will be supported by this property. Check which values + * are available by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDictValue + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyICameraExternalSyncEdge lineSync; + /// \brief An enumerated integer property defining the edge valid for the pixel clock of this camera. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncEdge. + * + * \note + * Not every value defined by this enumeration will be supported by this property. Check which values + * are available by reading the properties translation dictionary with + * the functions \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDictString and + * \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDictValue + * \if DOXYGEN_CPP_DOCUMENTATION + * C++ offers the more efficient function \b mvIMPACT::acquire::PropertyICameraExternalSyncEdge::getTranslationDict + * in addition to the functions mentioned above. + * \endif + */ + PropertyICameraExternalSyncEdge pixelClk; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief An internal base class to describe standard analogue video cameras(\b Device specific interface layout only). +/** + * Instances of this class can't be constructed directly. Use one of the derived types. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionStandardBase : public CameraDescriptionBase +//----------------------------------------------------------------------------- +{ +protected: + explicit CameraDescriptionStandardBase( HDRV hDrv, HLIST hList ) : CameraDescriptionBase( hDrv, hList ), videoStandard(), + scanStandard(), scanRate_kHz(), startField() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( videoStandard, "VideoStandard" ); + locator.bindComponent( scanStandard, "ScanStandard" ); + locator.bindComponent( scanRate_kHz, "ScanRate_kHz" ); + locator.bindComponent( startField, "StartField" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property for defining the video standard this camera is compliant with. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TVideoStandard. + */ + PropertyIVideoStandard videoStandard; + /// \brief An enumerated integer property defining the scan standard this camera is compliant with. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TScanStandard. + */ + PropertyIScanStandard scanStandard; + /// \brief An integer property containing the scan rate in kHz needed to driver the AD converter of the capture device with to convert the video signal properly. + PropertyI scanRate_kHz; + /// \brief An enumerated integer property containing information about the first field transmitted by a camera. + /** + * A camera might transmit either the odd or the even field of an interlaced video signal first. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TAcquisitionField. + */ + PropertyIAcquisitionField startField; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief A class describing analogue standard compliant video cameras(\b Device specific interface layout only). +/** + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionStandard : public CameraDescriptionStandardBase +//----------------------------------------------------------------------------- +{ + friend class CameraDescriptionManager; + explicit CameraDescriptionStandard( HDRV hDrv, HLIST hList ) : CameraDescriptionStandardBase( hDrv, hList ) {} +}; + +//----------------------------------------------------------------------------- +/// \brief A class describing non-standard video cameras(\b Device specific interface layout only). +/** + * This class can be used to describe a non-standard analogue video camera. A camera + * considered as non-standard when it is not compliant with one of the defined + * video standards like e.g. CCIR. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class CameraDescriptionNonStandard : public CameraDescriptionStandardBase +//----------------------------------------------------------------------------- +{ + friend class CameraDescriptionManager; + explicit CameraDescriptionNonStandard( HDRV hDrv, HLIST hList ) : CameraDescriptionStandardBase( hDrv, hList ), lineFrequency_Hz(), + VDOutput(), HDOutput(), syncOutput(), pixelClockOutput(), fieldGateMode(), fieldGateStart(), fieldGateWidth(), + clampMode(), clampStart_us() + { + ComponentLocator locator( m_hRoot ); + locator.bindComponent( lineFrequency_Hz, "LineFrequency_Hz" ); + locator.bindComponent( VDOutput, "VDOutput" ); + locator.bindComponent( HDOutput, "HDOutput" ); + locator.bindComponent( syncOutput, "SyncOutput" ); + locator.bindComponent( pixelClockOutput, "PixelClockOutput" ); + locator.bindComponent( fieldGateMode, "FieldGateMode" ); + locator.bindComponent( fieldGateStart, "FieldGateStart" ); + locator.bindComponent( fieldGateWidth, "FieldGateWidth" ); + locator.bindComponent( clampMode, "ClampMode" ); + locator.bindComponent( clampStart_us, "ClampStart_us" ); + } +public: + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property containing the line frequency of this camera in Hertz. + PropertyI lineFrequency_Hz; + /// \brief An enumerated integer property defining whether the vertical sync. information is part of the video signal or transmitted via a separate wire. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncEdge. + */ + PropertyICameraExternalSyncEdge VDOutput; + /// \brief An enumerated integer property defining whether the horizontal sync. information is part of the video signal or transmitted via a separate wire. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncEdge. + */ + PropertyICameraExternalSyncEdge HDOutput; + /// \brief An enumerated integer property for RGB cameras containing information where the sync. information is transmitted. + /** + * This can either be within one of the three color components or on a separate wire. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncOutput. + */ + PropertyICameraExternalSyncOutput syncOutput; + /// \brief An enumerated integer property containing information whether the pixel clock is part of the video signal or not. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TCameraExternalSyncEdge. + */ + PropertyICameraExternalSyncEdge pixelClockOutput; + /// \brief An enumerated integer property defining the clamp mode for this camera description. + /** + * This defines how the field detection(ODD/EVEN) is done. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TFieldGateMode. + */ + PropertyIFieldGateMode fieldGateMode; + /// \brief An integer property defining the start position (in pixel clocks) of the field gate detection area. + /** + * This will only need modification in very rare cases. + */ + PropertyI fieldGateStart; + /// \brief An integer property defining the width (in pixel clocks) of the field gate detection area. + /** + * This will only need modification in very rare cases. + */ + PropertyI fieldGateWidth; + /// \brief An enumerated integer property defining the clamp mode for this camera description. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TClampMode. + */ + PropertyIClampMode clampMode; + /// \brief The clamp start position defines where in each line of the video signal the frame grabber assumes the black level position. + /** + * This will only need modification in very rare cases. + */ + PropertyI clampStart_us; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Grants access to camera description objects(\b Device specific interface layout only). +/** + * This class provides access to the various camera description objects. Each + * device recognizes a different set of camera descriptions. E.g. a digital + * frame grabber will not be able to work with analogue cameras. Each camera description + * class will be derived from \b mvIMPACT::acquire::CameraDescriptionBase. + * + * \note + * Please note that instances of this class will \b ONLY list camera descriptions + * that have once been selected by the property \b mvIMPACT::acquire::CameraSettingsFrameGrabber::type + * at runtime. This is to save memory. A complete list of camera descriptions + * available for the current device therefore can only be queried by reading the + * the translation dictionary of the property \b mvIMPACT::acquire::CameraSettingsFrameGrabber::type. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * #include + * #include + * #include + * + * using namespace std; + * using namespace mvIMPACT::acquire; + * + * //----------------------------------------------------------------------------- + * template + * class DisplayDictEntry : public unary_function, void> + * //----------------------------------------------------------------------------- + * { + * public: + * void operator()( const pair& data ) const + * { + * cout << " [" << data.second << "]: " << data.first << endl; + * } + * }; + * + * //----------------------------------------------------------------------------- + * // lists all available camera descriptions for a certain device + * int main( int argc, char* argv[] ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr; + * Device* pDev = devMgr[0]; + * if( !pDev ) + * { + * cout << "No device found" << endl; + * return 0; + * } + * + * // display the name of every camera description available for this device. + * // this might be less than the number of camera descriptions available on the system as e.g. + * // an analog frame grabber can't use descriptions for digital cameras + * CameraSettingsFrameGrabber cs( pDev ); + * std::string vAvailableDescriptions; + * cs.type.getTranslationDict( vAvailableDescriptions ); + * cout << endl << "Available camera descriptions: " << vAvailableDescriptions.size() << endl + * << "----------------------------------" << endl; + * for_each( vAvailableDescriptions.begin(), vAvailableDescriptions.end(), DisplayDictEntry() ) + * + * // list all descriptions that already have been selected at least once + * CameraDescriptionManager camMgr( pDev ); + * unsigned int camCnt = camMgr.getCLCameraDescriptionCount(); + * cout << "Available CL descriptions: " << camCnt << endl; + * for( unsigned int a=0; aname.read() << endl; + * } + * camCnt = camMgr.getStandardCameraDescriptionCount(); + * cout << "Available Std descriptions: " << camCnt << endl; + * for( unsigned int b=0; bname.read() << endl; + * } + * camCnt = camMgr.getNonStandardCameraDescriptionCount(); + * cout << "Available NonStd descriptions: " << camCnt << endl; + * for( unsigned int c=0; cname.read() << endl; + * } + * return 0; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import mvIMPACT.acquire.*; + * + * //----------------------------------------------------------------------------- + * public class ListCameraDescriptions + * //----------------------------------------------------------------------------- + * { + * static + * { + * try + * { + * System.loadLibrary( "mvIMPACT_Acquire.java" ); + * } + * catch( UnsatisfiedLinkError e ) + * { + * System.err.println( "Native code library failed to load. Make sure the 'mvIMPACT_Acquire.java' library can be found in the systems search path.\n" + e ); + * System.exit( 1 ); + * } + * } + * + * //----------------------------------------------------------------------------- + * public static void main( String[] args ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr = new DeviceManager(); + * Device pDev = mvIMPACT.acquire.examples.helper.DeviceAccess.getDeviceFromUserInput( devMgr ); + * if( pDev == null ) + * { + * System.out.print( "Unable to continue!" ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * System.out.println( "Initialising the device. This might take some time..." ); + * try + * { + * pDev.open(); + * } + * catch( ImpactAcquireException e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * System.out.println( "An error occurred while opening device " + pDev.getSerial().read() + + * "(error code: " + e.getMessage() + ")." ); + * mvIMPACT.acquire.examples.helper.DeviceAccess.waitForENTER(); + * System.exit( 1 ); + * } + * + * // display the name of every camera description available for this device. + * // this might be less than the number of camera descriptions available on the system as e.g. + * // an analog frame grabber can't use descriptions for digital cameras + * CameraSettingsFrameGrabber cs = new CameraSettingsFrameGrabber(pDev); + * StringIntVector vAvailableDescriptions = new StringIntVector(); + * cs.getType().getTranslationDict( vAvailableDescriptions ); + * System.out.println( String.format( "\nAvailable camera descriptions: %d", vAvailableDescriptions.size() ) ); + * System.out.println( "----------------------------------" ); + * + * for( int i=0; i StringUIntMap; +# ifndef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + struct ReferenceCountedData + //----------------------------------------------------------------------------- + { + HDRV m_hDrv; + HLIST m_hListCameraDescriptions; + mutable unsigned int m_lastListSize; + mutable std::vector m_vStdDescriptions; + mutable std::vector m_vNonStdDescriptions; + mutable std::vector m_vSDIDescriptions; + mutable std::vector m_vCLDescriptions; + mutable std::vector m_vDigitalDescriptions; + mutable StringUIntMap m_mListNameToDescription; + mutable StringUIntMap m_mStdNameToDescription; + mutable StringUIntMap m_mNonStdNameToDescription; + mutable StringUIntMap m_mSDINameToDescription; + mutable StringUIntMap m_mCLNameToDescription; + mutable StringUIntMap m_mDigitalNameToDescription; + unsigned int m_refCnt; + explicit ReferenceCountedData( HDRV hDrv, HLIST hList ) : m_hDrv( hDrv ), m_hListCameraDescriptions( hList ), + m_lastListSize( 0 ), m_vStdDescriptions(), m_vNonStdDescriptions(), m_vSDIDescriptions(), m_vCLDescriptions(), + m_vDigitalDescriptions(), m_mListNameToDescription(), m_mStdNameToDescription(), + m_mNonStdNameToDescription(), m_mCLNameToDescription(), m_mDigitalNameToDescription(), + m_refCnt( 1 ) {} + ~ReferenceCountedData() + { + std::vector::size_type vStdSize = m_vStdDescriptions.size(); + for( std::vector::size_type a = 0; a < vStdSize; a++ ) + { + delete m_vStdDescriptions[a]; + } + std::vector::size_type vNonStdSize = m_vNonStdDescriptions.size(); + for( std::vector::size_type b = 0; b < vNonStdSize; b++ ) + { + delete m_vNonStdDescriptions[b]; + } + std::vector::size_type vSDISize = m_vSDIDescriptions.size(); + for( std::vector::size_type c = 0; c < vSDISize; c++ ) + { + delete m_vSDIDescriptions[c]; + } + std::vector::size_type vCLSize = m_vCLDescriptions.size(); + for( std::vector::size_type d = 0; d < vCLSize; d++ ) + { + delete m_vCLDescriptions[d]; + } + std::vector::size_type vDigSize = m_vDigitalDescriptions.size(); + for( std::vector::size_type e = 0; e < vDigSize; e++ ) + { + delete m_vDigitalDescriptions[e]; + } + } + }* m_pRefData; +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS + //----------------------------------------------------------------------------- + void dealloc( void ) + //----------------------------------------------------------------------------- + { + assert( m_pRefData && "BUG in reference counting detected!" ); + --( m_pRefData->m_refCnt ); + if( m_pRefData->m_refCnt == 0 ) + { + delete m_pRefData; + m_pRefData = 0; + } + } + //----------------------------------------------------------------------------- + bool locateDescription( const StringUIntMap& m, const std::string& name, unsigned int& index ) const + //----------------------------------------------------------------------------- + { + update(); + StringUIntMap::const_iterator it = m_pRefData->m_mListNameToDescription.find( name ); + if( it != m_pRefData->m_mListNameToDescription.end() ) + { + index = it->second; + return true; + } + else + { + it = m.find( name ); + if( it != m.end() ) + { + index = it->second; + return true; + } + } + return false; + } + //----------------------------------------------------------------------------- + void update( void ) const + //----------------------------------------------------------------------------- + { + ComponentList camDescList( m_pRefData->m_hListCameraDescriptions ); + unsigned int curSize = camDescList.size(); + if( m_pRefData->m_lastListSize != curSize ) + { + // new cameras at runtime can only appear at the end of the list + Component it( m_pRefData->m_hListCameraDescriptions ); + it = it.firstChild(); + // move to the old end + for( unsigned int i = 0; ( i < m_pRefData->m_lastListSize ) && it.isValid(); i++ ) + { + ++it; + } + // start to add new descriptions + while( it.isValid() ) + { + ComponentList list( it ); + const std::string contentDescriptor( list.contentDescriptor() ); + if( contentDescriptor == "CameraLink" ) + { + CameraDescriptionCameraLink* p = new CameraDescriptionCameraLink( m_pRefData->m_hDrv, list ); + unsigned int index = static_cast( m_pRefData->m_vCLDescriptions.size() ); // do not change order of this and the next line! + m_pRefData->m_vCLDescriptions.push_back( p ); + m_pRefData->m_mListNameToDescription.insert( std::make_pair( list.name(), index ) ); + m_pRefData->m_mCLNameToDescription.insert( std::make_pair( p->name.read(), index ) ); + } + else if( contentDescriptor == "SDI" ) + { + CameraDescriptionSDI* p = new CameraDescriptionSDI( m_pRefData->m_hDrv, list ); + unsigned int index = static_cast( m_pRefData->m_vCLDescriptions.size() ); // do not change order of this and the next line! + m_pRefData->m_vSDIDescriptions.push_back( p ); + m_pRefData->m_mListNameToDescription.insert( std::make_pair( list.name(), index ) ); + m_pRefData->m_mSDINameToDescription.insert( std::make_pair( p->name.read(), index ) ); + } + else if( contentDescriptor == "Digital" ) + { + CameraDescriptionDigital* p = new CameraDescriptionDigital( m_pRefData->m_hDrv, list ); + unsigned int index = static_cast( m_pRefData->m_vDigitalDescriptions.size() ); // do not change order of this and the next line! + m_pRefData->m_vDigitalDescriptions.push_back( p ); + m_pRefData->m_mListNameToDescription.insert( std::make_pair( list.name(), index ) ); + m_pRefData->m_mDigitalNameToDescription.insert( std::make_pair( p->name.read(), index ) ); + } + else if( contentDescriptor == "Standard" ) + { + CameraDescriptionStandard* p = new CameraDescriptionStandard( m_pRefData->m_hDrv, list ); + unsigned int index = static_cast( m_pRefData->m_vStdDescriptions.size() ); // do not change order of this and the next line! + m_pRefData->m_vStdDescriptions.push_back( p ); + m_pRefData->m_mListNameToDescription.insert( std::make_pair( list.name(), index ) ); + m_pRefData->m_mStdNameToDescription.insert( std::make_pair( p->name.read(), index ) ); + } + else if( contentDescriptor == "NonStandard" ) + { + CameraDescriptionNonStandard* p = new CameraDescriptionNonStandard( m_pRefData->m_hDrv, list ); + unsigned int index = static_cast( m_pRefData->m_vNonStdDescriptions.size() ); // do not change order of this and the next line! + m_pRefData->m_vNonStdDescriptions.push_back( p ); + m_pRefData->m_mListNameToDescription.insert( std::make_pair( list.name(), index ) ); + m_pRefData->m_mNonStdNameToDescription.insert( std::make_pair( p->name.read(), index ) ); + } + else + { + ; // NOT recognized.... + } + ++it; + } + m_pRefData->m_lastListSize = curSize; + } + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::CameraDescriptionManager object. + explicit CameraDescriptionManager( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::>DeviceManager object. + Device* pDev ) : m_pRefData( 0 ) + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + if( !pDev->isOpen() ) + { + pDev->open(); + } + + TDMR_ERROR result; + HLIST hList; + if( ( result = DMR_FindList( pDev->hDrv(), 0, dmltCameraDescriptions, 0, &hList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, "Couldn't find camera description list (is this a frame grabber?)" ); + } + m_pRefData = new ReferenceCountedData( pDev->hDrv(), hList ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::CameraDescriptionManager from an existing one. + CameraDescriptionManager( + /// A constant reference to the \b mvIMPACT::acquire::CameraDescriptionManager object, this object shall be created from + const CameraDescriptionManager& src ) : m_pRefData( src.m_pRefData ) + { + ++( m_pRefData->m_refCnt ); + } + /// \brief Class destructor. + ~CameraDescriptionManager() + { + dealloc(); + } + /// \brief Allows assignments of \b mvIMPACT::acquire::CameraDescriptionManager objects. + CameraDescriptionManager& operator=( const CameraDescriptionManager& rhs ) + { + if( this != &rhs ) + { + dealloc(); + m_pRefData = rhs.m_pRefData; + // inc. the NEW reference count + ++m_pRefData->m_refCnt; + } + return *this; + } + /// \brief Returns the number of CameraLink® camera descriptions currently available for the device that constructed this instance of the class. + unsigned int getCLCameraDescriptionCount( void ) const + { + update(); + return static_cast( m_pRefData->m_vCLDescriptions.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionCameraLink object specifying the camera description found at the given index in the camera description managers internal list. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of CameraLink® camera descriptions \n + * detected for this device a STL out_of_range exception will be thrown. + * \endif + */ + CameraDescriptionCameraLink* cameraDescriptionCameraLink( + /// [in] The index of the camera description to return + unsigned int index ) const + { + update(); + return m_pRefData->m_vCLDescriptions.at( index ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionCameraLink object specifying the camera description with the given name in the camera description managers internal list. + /** + * \return + * - a pointer to a \b mvIMPACT::acquire::CameraDescriptionCameraLink object specifying the camera + * description with the given name in the camera description managers internal list if a camera + * description with \a name is available. + * - an invalid pointer or reference otherwise. + */ + CameraDescriptionCameraLink* cameraDescriptionCameraLink( + /// [in] The name of the camera description. This can either be + /// the name of the list like e.g. 'CameraLink_Generic' or the + /// value of the property 'name' of this description like + /// e.g. 'Generic'. + const std::string& name ) const + { + unsigned int index = 0; + return ( ( locateDescription( m_pRefData->m_mCLNameToDescription, name, index ) == true ) ? m_pRefData->m_vCLDescriptions.at( index ) : 0 ); + } + /// \brief Returns the number of SDI camera descriptions currently available for the device that constructed this instance of the class. + unsigned int getSDICameraDescriptionCount( void ) const + { + update(); + return static_cast( m_pRefData->m_vSDIDescriptions.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionSDI object specifying the camera description found at the given index in the camera description managers internal list. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of SDI camera descriptions \n + * detected for this device a STL out_of_range exception will be thrown. + * \endif + */ + CameraDescriptionSDI* cameraDescriptionSDI( + /// [in] The index of the camera description to return + unsigned int index ) const + { + update(); + return m_pRefData->m_vSDIDescriptions.at( index ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionSDI object specifying the camera description with the given name in the camera description managers internal list. + /** + * \return + * - a pointer to a \b mvIMPACT::acquire::CameraDescriptionSDI object specifying the camera + * description with the given name in the camera description managers internal list if a camera + * description with \a name is available. + * - an invalid pointer or reference otherwise. + */ + CameraDescriptionSDI* cameraDescriptionSDI( + /// [in] The name of the camera description. This can either be + /// the name of the list like e.g. 'CameraLink_Generic' or the + /// value of the property 'name' of this description like + /// e.g. 'Generic'. + const std::string& name ) const + { + unsigned int index = 0; + return ( ( locateDescription( m_pRefData->m_mSDINameToDescription, name, index ) == true ) ? m_pRefData->m_vSDIDescriptions.at( index ) : 0 ); + } + /// \brief Returns the number of non-standard digital camera descriptions currently available for the device that constructed this instance of the class. + unsigned int getDigitalCameraDescriptionCount( void ) const + { + update(); + return static_cast( m_pRefData->m_vDigitalDescriptions.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionDigital object specifying the camera description found at the given index in the camera description managers internal list. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of non-standard digital camera descriptions \n + * detected for this device a STL out_of_range exception will be thrown. + * \endif + */ + CameraDescriptionDigital* cameraDescriptionDigital( + /// [in] The index of the camera description to return + unsigned int index ) const + { + update(); + return m_pRefData->m_vDigitalDescriptions.at( index ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionDigital object specifying the camera description with the given name in the camera description managers internal list. + /** + * \return + * - a pointer to a \b mvIMPACT::acquire::CameraDescriptionDigital object specifying the camera + * description with the given name in the camera description managers internal list if a camera + * description with \a name is available. + * - an invalid pointer or reference otherwise. + */ + CameraDescriptionDigital* cameraDescriptionDigital( + /// [in] The name of the camera description. This can either be + /// the name of the list like e.g. 'Digital_Generic' or the + /// value of the property 'name' of this description like + /// e.g. 'Generic'. + const std::string& name ) const + { + unsigned int index = 0; + return ( ( locateDescription( m_pRefData->m_mDigitalNameToDescription, name, index ) == true ) ? m_pRefData->m_vDigitalDescriptions.at( index ) : 0 ); + } + /// \brief Returns the number of standard camera descriptions currently available for the device that constructed this instance of the class. + unsigned int getStandardCameraDescriptionCount( void ) const + { + update(); + return static_cast( m_pRefData->m_vStdDescriptions.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionStandard object specifying the camera description found at the given index in the camera description managers internal list. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of standard camera descriptions \n + * detected for this device a STL out_of_range exception will be thrown. + * \endif + */ + CameraDescriptionStandard* cameraDescriptionStandard( + /// [in] The index of the camera description to return + unsigned int index ) const + { + update(); + return m_pRefData->m_vStdDescriptions.at( index ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionStandard object specifying the camera description with the given name in the camera description managers internal list. + /** + * \return + * - a pointer to a \b mvIMPACT::acquire::CameraDescriptionStandard object specifying the camera + * description with the given name in the camera description managers internal list if a camera + * description with \a name is available. + * - an invalid pointer or reference otherwise. + */ + CameraDescriptionStandard* cameraDescriptionStandard( + /// [in] The name of the camera description. This can either be + /// the name of the list like e.g. 'Standard_Generic' or the + /// value of the property 'name' of this description like + /// e.g. 'Generic'. + const std::string& name ) const + { + unsigned int index = 0; + return ( ( locateDescription( m_pRefData->m_mStdNameToDescription, name, index ) == true ) ? m_pRefData->m_vStdDescriptions.at( index ) : 0 ); + } + /// \brief Returns the number of non-standard camera descriptions currently available for the device that constructed this instance of the class. + unsigned int getNonStandardCameraDescriptionCount( void ) const + { + update(); + return static_cast( m_pRefData->m_vNonStdDescriptions.size() ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionNonStandard object specifying the camera description found at the given index in the camera description managers internal list. + /** + * \if DOXYGEN_CPP_DOCUMENTATION + * If the index is either equal or higher than the number of non-standard camera descriptions \n + * detected for this device a STL out_of_range exception will be thrown. + * \endif + */ + CameraDescriptionNonStandard* cameraDescriptionNonStandard( + /// [in] The index of the camera description to return + unsigned int index ) const + { + update(); + return m_pRefData->m_vNonStdDescriptions.at( index ); + } + /// \brief Returns a pointer to a \b mvIMPACT::acquire::CameraDescriptionNonStandard object specifying the camera description with the given name in the camera description managers internal list. + /** + * \return + * - a pointer to a \b mvIMPACT::acquire::CameraDescriptionNonStandard object specifying the camera + * description with the given name in the camera description managers internal list if a camera + * description with \a name is available. + * - an invalid pointer or reference otherwise. + */ + CameraDescriptionNonStandard* cameraDescriptionNonStandard( + /// [in] The name of the camera description. This can either be + /// the name of the list like e.g. 'NonStandard_Generic' or the + /// value of the property 'name' of this description like + /// e.g. 'Generic'. + const std::string& name ) const + { + unsigned int index = 0; + return ( ( locateDescription( m_pRefData->m_mNonStdNameToDescription, name, index ) == true ) ? m_pRefData->m_vNonStdDescriptions.at( index ) : 0 ); + } + /// \brief Returns the total number camera descriptions currently available for the device that constructed this instance of the class. + /** + * \since 2.1.4 + */ + unsigned int getTotalCameraDescriptionCount( void ) const + { + update(); + return m_pRefData->m_lastListSize; + } +}; +# endif // #ifndef #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Properties for accessing features belonging to the I2C control(\b Device specific interface layout only). +/** + * Properties in this class will only be available if a device has a local I2C + * bus and this is configured for access from an application. Right now this is only + * the case for mvBlueFOX-MLC devices. + * + * \b mvBlueFOX \b specific: + * + * For mvBlueFOX devices + * - clock stretching is supported + * - bus master is supported + * + * The following I2C addresses will be blocked for access from an application: + * + * + * + * + * + * + * + * + *
i2c addressremark
0x20-0x3F-
0x66-0x67-
0x90-0x91mvBlueFOX-200w only
0xA0-0xA3-
0xA6-0xA7-
0xBA-0xBBmvBlueFOX-202a and mvBlueFOX-205 only
+ * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * I2CControl i2cc( pBF ); // assuming 'pBF' to be a valid 'Device*' instance to an mvBlueFOX device + * if( i2cc.I2COperationMode.isValid() ) + * { + * // direct property access + * i2cc.I2CBufferLength.write( 0 ); + * i2cc.I2COperationMode.write( I2ComRead ); + * assert( ( i2cc.I2COperationExecute.call() == DMR_INVALID_PARAMETER ) && "Unexpected driver behaviour" ); + * assert( ( i2cc.I2COperationStatus.read() == I2CosNotEnoughData ) && "Unexpected driver behaviour" ); + * i2cc.I2CBufferLength.write( 1 ); + * // assuming we write to an invalid address + * assert( ( i2cc.I2COperationExecute.call() == DMR_EXECUTION_FAILED ) && "Unexpected driver behaviour" ); + * assert( ( i2cc.I2COperationStatus.read() == I2CosFailure ) && "Unexpected driver behaviour" ); + * i2cc.I2COperationMode.write( I2ComWrite ); + * i2cc.I2CBuffer.writeBinary( string() ); + * assert( ( i2cc.I2COperationExecute.call() == DMR_INVALID_PARAMETER ) && "Unexpected driver behaviour" ); + * assert( ( i2cc.I2COperationStatus.read() == I2CosNotEnoughData ) && "Unexpected driver behaviour" ); + * { + * char binData[2] = { 'A', 'B' }; + * i2cc.I2CBuffer.writeBinary( string(binData, sizeof(binData)) ); + * } + * // assuming we write to an invalid address + * assert( ( i2cc.I2COperationExecute.call() == DMR_EXECUTION_FAILED ) && "Unexpected driver behaviour" ); + * assert( ( i2cc.I2COperationStatus.read() == I2CosFailure ) && "Unexpected driver behaviour" ); + * // Write some data. This will only work if several conditions are met: + * // - there is a device that can be written to at address 0xA6 + * // - the sub-address 0x04 is valid + * // - the device is designed to work with 8 bit sub-addresses + * // - the device can deal with 9 bytes in a single command + * i2cc.I2CDeviceAddress.write( 0xA6 ); + * i2cc.I2CDeviceSubAddress.write( 0x04 ); + * i2cc.I2CDeviceSubAddressWidth.write( 8 ); + * { + * char binData[9] = { 'D', 'E', 'A', 'D', ' ', 'B', 'E', 'E', 'F' }; + * i2cc.I2CBuffer.writeBinary( string( binData, sizeof( binData ) ) ); + * } + * i2cc.I2COperationMode.write( I2ComWrite ); + * int I2COperationExecuteResult = i2cc.I2COperationExecute.call(); + * if( I2COperationExecuteResult != DMR_NO_ERROR ) + * { + * printf( "'I2COperationExecute' write failed. Return value: %s(%d).\n", ImpactAcquireException::getErrorCodeAsString( I2COperationExecuteResult ).c_str(), I2COperationExecuteResult ); + * } + * printf( "'I2COperationStatus' after write: %s.\n", i2cc.I2COperationStatus.readS().c_str() ); + * // Read some data. Similar condition as for write apply + * const int bytesToRead = 4; + * i2cc.I2CDeviceAddress.write( 0xA8 ); + * i2cc.I2CDeviceSubAddress.write( 0x00 ); + * i2cc.I2CDeviceSubAddressWidth.write( 8 ); + * i2cc.I2CBufferLength.write( bytesToRead ); // read 'bytesToRead' bytes + * i2cc.I2COperationMode.write( I2ComRead ); + * i2cc.I2COperationExecute.call(); + * I2COperationExecuteResult = i2cc.I2COperationExecute.call(); + * if( I2COperationExecuteResult != DMR_NO_ERROR ) + * { + * printf( "'I2COperationExecute' read failed. Return value: %s(%d).\n", ImpactAcquireException::getErrorCodeAsString( I2COperationExecuteResult ).c_str(), I2COperationExecuteResult ); + * } + * printf( "'I2COperationStatus' after read: %s.\n", i2cc.I2COperationStatus.readS().c_str() ); + * if( i2cc.I2CBuffer.binaryDataBufferSize() != bytesToRead ) + * { + * printf( "'I2CBuffer' reports %d bytes of data while %d bytes where expected.\n", i2cc.I2CBuffer.binaryDataBufferSize(), bytesToRead ); + * } + * // usage of the convenience functions + * i2cc.I2CWrite( 0xA4, 0x00, 8, string("TEST") ); + * const string i2cReadBuffer = i2cc.I2CRead( 0xA4, 0x00, 8, 4 ); + * } + * else + * { + * printf( "I2CControl not available.\n" ); + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import java.nio.ByteBuffer; // needed for binary data exchange! + * + * // more code and a class definition must follow here... + * +* I2CControl i2cc = new I2CControl( pDev ); // assuming 'pBF' to be a valid 'Device*' instance to an mvBlueFOX device +* if( i2cc.getI2COperationMode().isValid() ) +* { +* // direct property access +* i2cc.getI2CBufferLength().write( 0 ); +* i2cc.getI2COperationMode().write( TI2COperationMode.I2ComRead ); +* assert i2cc.getI2COperationExecute().call() == TDMR_ERROR.DMR_INVALID_PARAMETER : "Unexpected driver behaviour"; +* assert i2cc.getI2COperationStatus().read() == TI2COperationStatus.I2CosNotEnoughData : "Unexpected driver behaviour"; +* i2cc.getI2CBufferLength().write( 1 ); +* // assuming we write to an invalid address +* assert i2cc.getI2COperationExecute().call() == TDMR_ERROR.DMR_EXECUTION_FAILED : "Unexpected driver behaviour"; +* assert i2cc.getI2COperationStatus().read() == TI2COperationStatus.I2CosFailure : "Unexpected driver behaviour"; +* i2cc.getI2COperationMode().write( TI2COperationMode.I2ComWrite ); +* { +* final int BUF_SIZE = 2; +* byte[] data_bytes = new byte[BUF_SIZE]; +* data_bytes[0] = 'A'; +* data_bytes[1] = 'B'; +* ByteBuffer data = ByteBuffer.allocateDirect( BUF_SIZE ); +* data.put( data_bytes ); +* i2cc.getI2CBuffer().writeBinary( data ); +* } +* // assuming we write to an invalid address +* assert i2cc.getI2COperationExecute().call() == TDMR_ERROR.DMR_EXECUTION_FAILED : "Unexpected driver behaviour"; +* assert i2cc.getI2COperationStatus().read() == TI2COperationStatus.I2CosFailure : "Unexpected driver behaviour"; +* // Write some data. This will only work if several conditions are met: +* // - there is a device that can be written to at address 0xA6 +* // - the sub-address 0x04 is valid +* // - the device is designed to work with 8 bit sub-addresses +* // - the device can deal with 9 bytes in a single command +* i2cc.getI2CDeviceAddress().write( 0xA6 ); +* i2cc.getI2CDeviceSubAddress().write( 0x04 ); +* i2cc.getI2CDeviceSubAddressWidth().write( 8 ); +* { +* final int BUF_SIZE = 9; +* byte[] data_bytes = new byte[BUF_SIZE]; +* data_bytes[0] = 'D'; +* data_bytes[0] = 'E'; +* data_bytes[0] = 'A'; +* data_bytes[0] = 'D'; +* data_bytes[0] = ' '; +* data_bytes[0] = 'B'; +* data_bytes[0] = 'E'; +* data_bytes[0] = 'E'; +* data_bytes[0] = 'F'; +* ByteBuffer data = ByteBuffer.allocateDirect( BUF_SIZE ); +* data.put( data_bytes ); +* i2cc.getI2CBuffer().writeBinary( data ); +* } +* i2cc.getI2COperationMode().write( TI2COperationMode.I2ComWrite ); +* int I2COperationExecuteResult = i2cc.getI2COperationExecute().call(); +* if( I2COperationExecuteResult != TDMR_ERROR.DMR_NO_ERROR ) +* { +* System.out.println( String.format( "'I2COperationExecute' write failed. Return value: %s(%d).", ImpactAcquireException.getErrorCodeAsString( I2COperationExecuteResult ), I2COperationExecuteResult ) ); +* } +* System.out.println( String.format( "'I2COperationStatus' after write: %s.", i2cc.getI2COperationStatus().readS() ) ); +* // Read some data. Similar condition as for write apply +* final int bytesToRead = 4; +* i2cc.getI2CDeviceAddress().write( 0xA8 ); +* i2cc.getI2CDeviceSubAddress().write( 0x00 ); +* i2cc.getI2CDeviceSubAddressWidth().write( 8 ); +* i2cc.getI2CBufferLength().write( bytesToRead ); // read 'bytesToRead' bytes +* i2cc.getI2COperationMode().write( TI2COperationMode.I2ComRead ); +* i2cc.getI2COperationExecute().call(); +* I2COperationExecuteResult = i2cc.getI2COperationExecute().call(); +* if( I2COperationExecuteResult != TDMR_ERROR.DMR_NO_ERROR ) +* { +* System.out.println( String.format( "'I2COperationExecute' read failed. Return value: %s(%d).", ImpactAcquireException.getErrorCodeAsString( I2COperationExecuteResult ), I2COperationExecuteResult ) ); +* } +* System.out.println( String.format( "'I2COperationStatus' after read: %s.", i2cc.getI2COperationStatus().readS() ) ); +* if( i2cc.getI2CBuffer().binaryDataBufferSize() != bytesToRead ) +* { +* System.out.println( String.format( "'I2CBuffer' reports %d bytes of data while %d bytes where expected.", i2cc.getI2CBuffer().binaryDataBufferSize(), bytesToRead ) ); +* } +* // usage of the convenience functions +* i2cc.I2CWrite( 0xA4, 0x00, 8, "TEST" ); +* final String i2cReadBuffer = i2cc.I2CRead( 0xA4, 0x00, 8, 4 ); +* } +* else +* { +* System.out.println( "I2CControl not available." ); +* } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * i2cc = acquire.I2CControl(pBF); # assuming 'pBF' to be a valid 'Device*' instance to an mvBlueFOX device + * if i2cc.I2COperationMode.isValid(): + * # direct property access + * i2cc.I2CBufferLength.write(0) + * i2cc.I2COperationMode.write(acquire.I2ComRead) + * assert i2cc.I2COperationExecute.call() == acquire.DMR_INVALID_PARAMETER, "Unexpected driver behaviour" + * assert i2cc.I2COperationStatus.read() == acquire.I2CosNotEnoughData, "Unexpected driver behaviour" + * i2cc.I2CBufferLength.write(1) + * # assuming we write to an invalid address + * assert i2cc.I2COperationExecute.call() == acquire.DMR_EXECUTION_FAILED, "Unexpected driver behaviour" + * assert i2cc.I2COperationStatus.read() == acquire.I2CosFailure, "Unexpected driver behaviour" + * i2cc.I2COperationMode.write(acquire.I2ComWrite) + * pBuf = '\x41\x42' # 'A' and 'B' + * i2cc.I2CBuffer.writeBinary(pBuf) + * # assuming we write to an invalid address + * assert i2cc.I2COperationExecute.call() == acquire.DMR_EXECUTION_FAILED, "Unexpected driver behaviour" + * assert i2cc.I2COperationStatus.read() == acquire.I2CosFailure, "Unexpected driver behaviour" + * # Write some data. This will only work if several conditions are met: + * # - there is a device that can be written to at address 0xA6 + * # - the sub-address 0x04 is valid + * # - the device is designed to work with 8 bit sub-addresses + * # - the device can deal with 9 bytes in a single command + * i2cc.I2CDeviceAddress.write(0xA6) + * i2cc.I2CDeviceSubAddress.write(0x04) + * i2cc.I2CDeviceSubAddressWidth.write(8) + * pBuf = '\x44\x45\x41\x44\x20\x42\x45\x45\x46' # The good old 'DEAD BEEF' in HEX notation + * i2cc.I2CBuffer.writeBinary(pBuf) + * i2cc.I2COperationMode.write(acquire.I2ComWrite) + * I2COperationExecuteResult = i2cc.I2COperationExecute.call() + * if I2COperationExecuteResult != acquire.DMR_NO_ERROR: + * print("'I2COperationExecute' write failed. Return value: {0}({1}).".format(acquire.ImpactAcquireException.getErrorCodeAsString(I2COperationExecuteResult), I2COperationExecuteResult)) + * print("'I2COperationStatus' after write: {0}.".format(i2cc.I2COperationStatus.readS())) + * # Read some data. Similar condition as for write apply + * bytesToRead = 4 + * i2cc.I2CDeviceAddress.write(0xA8) + * i2cc.I2CDeviceSubAddress.write(0x00) + * i2cc.I2CDeviceSubAddressWidth.write(8) + * i2cc.I2CBufferLength.write(bytesToRead) # read 'bytesToRead' bytes + * i2cc.I2COperationMode.write(acquire.I2ComRead) + * i2cc.I2COperationExecute.call() + * I2COperationExecuteResult = i2cc.I2COperationExecute.call() + * if I2COperationExecuteResult != acquire.DMR_NO_ERROR: + * System.out.println(String.format("'I2COperationExecute' read failed. Return value: %s(%d).", ImpactAcquireException.getErrorCodeAsString(I2COperationExecuteResult), I2COperationExecuteResult)) + * print("'I2COperationStatus' after read: {0}.".format(i2cc.I2COperationStatus.readS())) + * if i2cc.I2CBuffer.binaryDataBufferSize() != bytesToRead: + * print("'I2CBuffer' reports {0} bytes of data while {1} bytes where expected.".format(i2cc.I2CBuffer.binaryDataBufferSize(), bytesToRead)) + * # usage of the convenience functions + * i2cc.I2CWrite(0xA4, 0x00, 8, "TEST") + * i2cReadBuffer = i2cc.I2CRead(0xA4, 0x00, 8, 4) + * else: + * print("I2CControl not available.") + * \endcode + * \endif + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class I2CControl : public ComponentCollection +//----------------------------------------------------------------------------- +{ +private: + void prepareI2CAccess( int deviceAddress, int deviceSubAddress, int deviceSubAddressWidth, TI2COperationMode mode ) + { + I2CDeviceAddress.write( deviceAddress ); + I2CDeviceSubAddress.write( deviceSubAddress ); + I2CDeviceSubAddressWidth.write( deviceSubAddressWidth ); + I2COperationMode.write( mode ); + } +public: + /// brief Constructs a new \b mvIMPACT::acquire::I2CControl object. + explicit I2CControl( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ): ComponentCollection( pDev ), I2COperationMode(), I2COperationExecute(), I2COperationStatus(), + I2CDeviceAddress(), I2CDeviceSubAddressWidth(), I2CDeviceSubAddress(), I2CBuffer(), I2CBufferLength() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + HLIST hList = locator.findComponent( "I2CControl" ); + if( hList != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "I2CControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( I2COperationMode, "I2COperationMode" ); + locator.bindComponent( I2COperationExecute, "I2COperationExecute@i" ); + locator.bindComponent( I2COperationStatus, "I2COperationStatus" ); + locator.bindComponent( I2CDeviceAddress, "I2CDeviceAddress" ); + locator.bindComponent( I2CDeviceSubAddressWidth, "I2CDeviceSubAddressWidth" ); + locator.bindComponent( I2CDeviceSubAddress, "I2CDeviceSubAddress" ); + locator.bindComponent( I2CBuffer, "I2CBuffer" ); + locator.bindComponent( I2CBufferLength, "I2CBufferLength" ); + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property to select the I2C operation. + /** + * The selected operation is executed when \b mvIMPACT::acquire::I2CControl::I2COperationExecute is called. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TI2COperationMode. + */ + PropertyII2COperationMode I2COperationMode; + /// \brief Calling this function will execute the operation selected by \b mvIMPACT::acquire::I2CControl::I2COperationMode. + Method I2COperationExecute; + /// \brief Represents the I2C operation execution status. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TI2COperationStatus. + */ + PropertyII2COperationStatus I2COperationStatus; + /// \brief An integer property storing the address of the I2C device to communicate with. + PropertyI I2CDeviceAddress; + /// \brief An enumerated integer property storing the sub-address width(in bits) of the I2C device to communicate with. + /** + * Valid values for this property are: + * + * - 0 + * - 8 + * - 16 + * + * \note + * This property must be set to 0 for devices not supporting a sub-address. + */ + PropertyI I2CDeviceSubAddressWidth; + /// \brief An integer property storing the sub-address of the I2C device to communicate with. + /** + * When \b mvIMPACT::acquire::I2CControl::I2CDeviceSubAddressWidth is set to 0, this property will be ignored. + */ + PropertyI I2CDeviceSubAddress; + /// \brief Defines the intermediate access buffer that allows the exchange of data between the I2C device and the application. + /** + * This property can store binary data. + */ + PropertyS I2CBuffer; + /// \brief An integer property controlling the length of the mapping between the I2C device and the \b mvIMPACT::acquire::I2CControl::I2CBuffer property. + PropertyI I2CBufferLength; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Read data from an I2C device. + /** + * This is a convenience function that wraps the property access a little. + * In order to find out if the command has been executed successfully + * \b mvIMPACT::acquire::I2CControl::I2COperationStatus should be checked afterwards. + */ + std::string I2CRead( + /// [in] The address of the I2C device to communicate with. + int deviceAddress, + /// [in] The sub-address of the I2C device to communicate with. + int deviceSubAddress, + /// [in] The sub-address width(in bits) of the I2C device to communicate with. + int deviceSubAddressWidth, + /// [in] The amount of bytes to read. + int byteCnt ) + { + prepareI2CAccess( deviceAddress, deviceSubAddress, deviceSubAddressWidth, I2ComRead ); + I2CBufferLength.write( byteCnt ); + I2COperationExecute.call(); + return I2CBuffer.readBinary(); + } + /// \brief Write data to a I2C device. + /** + * This is a convenience function that wraps the property access a little. + * In order to find out if the command has been executed successfully + * \b mvIMPACT::acquire::I2CControl::I2COperationStatus should be checked afterwards. + */ + void I2CWrite( + /// [in] The address of the I2C device to communicate with. + int deviceAddress, + /// [in] The sub-address of the I2C device to communicate with. + int deviceSubAddress, + /// [in] The sub-address width(in bits) of the I2C device to communicate with. + int deviceSubAddressWidth, + /// [in] The data to write to the I2C device. + const std::string& data ) + { + prepareI2CAccess( deviceAddress, deviceSubAddress, deviceSubAddressWidth, I2ComWrite ); + I2CBuffer.writeBinary( data ); + I2COperationExecute.call(); + } +}; +# endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +//----------------------------------------------------------------------------- +/// \brief Properties for configuring settings belonging to the motor focus control (\b Device specific interface layout only). +/** + * Properties in this class will only be available if a device is fitted with + * a focus motor. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class MotorFocusControl : public ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::MotorFocusControl object. + explicit MotorFocusControl( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ): ComponentCollection( pDev ), motorFocusSendBuffer(), motorFocusReceiveBuffer(), motorFocusSend(), + motorFocusIncrement(), motorFocusNear(), motorFocusFar(), motorFocusAbsolutePositionCurrent(), + motorFocusAbsolutePositionDesired(), motorFocusMoveToAbsolutePositionDesired() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + HLIST hList = locator.findComponent( "MotorFocusControl" ); + if( hList != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "MotorFocusControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( motorFocusSendBuffer, "MotorFocusSendBuffer" ); + locator.bindComponent( motorFocusReceiveBuffer, "MotorFocusReceiveBuffer" ); + locator.bindComponent( motorFocusSend, "MotorFocusSend@i" ); + locator.bindComponent( motorFocusIncrement, "MotorFocusIncrement" ); + locator.bindComponent( motorFocusNear, "MotorFocusNear@i" ); + locator.bindComponent( motorFocusFar, "MotorFocusFar@i" ); + locator.bindComponent( motorFocusAbsolutePositionCurrent, "MotorFocusAbsolutePositionCurrent" ); + locator.bindComponent( motorFocusAbsolutePositionDesired, "MotorFocusAbsolutePositionDesired" ); + locator.bindComponent( motorFocusMoveToAbsolutePositionDesired, "MotorFocusMoveToAbsolutePositionDesired@i" ); + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property storing a command to be sent to the motor focus. + /** + * To actually send the command, the function \b mvIMPACT::acquire::MotorFocusControl::motorFocusSend must be executed. + */ + PropertyS motorFocusSendBuffer; + /// \brief A string property \b (read-only) that will contain answers sent by the motor focus controller. + PropertyS motorFocusReceiveBuffer; + /// \brief Calling this function will send the value of \b mvIMPACT::acquire::MotorFocusControl::motorFocusSendBuffer to the hardware. + /** + * Afterwards \b mvIMPACT::acquire::MotorFocusControl::motorFocusReceiveBuffer will contain the hardwares answer. + */ + Method motorFocusSend; + /// \brief An integer property storing an increment(in encoder counts) that will be used by subsequent calls to \b mvIMPACT::acquire::MotorFocusControl::motorFocusNear and \b mvIMPACT::acquire::MotorFocusControl::motorFocusFar commands. + PropertyI motorFocusIncrement; + /// \brief Calling this function will cause the motor focus to move forward by \b mvIMPACT::acquire::MotorFocusControl::motorFocusIncrement encoder units. + Method motorFocusNear; + /// \brief Calling this function will cause the motor focus to move backward by \b mvIMPACT::acquire::MotorFocusControl::motorFocusIncrement encoder units. + Method motorFocusFar; + /// \brief An integer property \b (read-only) storing the current absolute position(in encoder counts). + PropertyI motorFocusAbsolutePositionCurrent; + /// \brief An integer property storing an absolute position(in encoder counts) that will be used by subsequent calls to the \b mvIMPACT::acquire::MotorFocusControl::motorFocusMoveToAbsolutePositionDesired command. + PropertyI motorFocusAbsolutePositionDesired; + /// \brief Calling this function will cause the motor focus to move to the position defined by the value of \b mvIMPACT::acquire::MotorFocusControl::motorFocusAbsolutePositionDesired. + Method motorFocusMoveToAbsolutePositionDesired; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief Properties for configuring settings belonging to the digital I/O measurement(\b Device specific interface layout only). +/** + * Properties in this class will only be available if a device offers digital I/O measurement features. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // This code fragment will print result of measurement using all modes on all sources + * // to the standard output. + * DigitalIOMeasurementControl iomc(getDevicePointerFromSomewhere()); + * if( iomc.digitalIOMeasurementMode.isValid() && iomc.digitalIOMeasurementSource.isValid() ) + * { + * vector > modeDict; + * iomc.digitalIOMeasurementMode.getTranslationDict( modeDict ); + * const unsigned int modeCnt = iomc.digitalIOMeasurementMode.dictSize(); + * vector > srcDict; + * iomc.digitalIOMeasurementSource.getTranslationDict( srcDict ); + * const unsigned int srcCnt = iomc.digitalIOMeasurementSource.dictSize(); + * for( unsigned int i=0; ivalidateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltIOSubSystem ); + HLIST hList = locator.findComponent( "DigitalIOMeasurementControl" ); + if( hList != INVALID_ID ) + { + locator.bindSearchBase( locator.searchbase_id(), "DigitalIOMeasurementControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( digitalIOMeasurementMode, "DigitalIOMeasurementMode" ); + locator.bindComponent( digitalIOMeasurementSource, "DigitalIOMeasurementSource" ); + locator.bindComponent( digitalIOMeasurementResult, "DigitalIOMeasurementResult" ); + } + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the type of measurement to perform. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigitalIOMeasurementMode. + */ + PropertyIDigitalIOMeasurementMode digitalIOMeasurementMode; + /// \brief An enumerated integer property defining where the measurement shall be performed. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDigitalIOMeasurementMode. + */ + PropertyIDigitalIOMeasurementSource digitalIOMeasurementSource; + /// \brief A float property \b (read-only) that will contain the result of the measurement. + /** + * Reading this property will automatically perform a new measurement. + * + * \note + * Please note that the signal connected to the digital input must match the selected digital input + * threshold(see \b mvIMPACT::acquire::IOSubSystemBlueFOX::digitalInputThreshold) in order to + * obtain valid results. + */ + PropertyF digitalIOMeasurementResult; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief This class provides access to general settings as well as to settings which are unique for the \b mvBlueFOX(\b Device specific interface layout only). +/** + * To see a small code example on how you can work with object of this class see + * the detailed description of the class \b mvIMPACT::acquire::FunctionInterface as well. + * Statements made for the use of the class \b mvIMPACT::acquire::FullSettingsBase apply for + * this class as well. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class SettingsBlueFOX : public FullSettingsBase +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::SettingsBlueFOX object. + explicit SettingsBlueFOX( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& name = "Base" ) : FullSettingsBase( pDev, name ), cameraSetting( pDev, name ) {} + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief Camera related settings. + CameraSettingsBlueFOX cameraSetting; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief This class provides access to general settings as well as to settings which are unique for frame grabber devices(\b Device specific interface layout only). +/** + * To see a small code example on how you can work with object of this class see + * the detailed description of the class \b mvIMPACT::acquire::FunctionInterface as well. + * Statements made for the use of the class \b mvIMPACT::acquire::FullSettingsBase apply for + * this class as well. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class SettingsFrameGrabber : public FullSettingsBase +//----------------------------------------------------------------------------- +{ +public: + /// brief Constructs a new \b mvIMPACT::acquire::SettingsFrameGrabber object. + explicit SettingsFrameGrabber( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// \b mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// \b mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& name = "Base" ) : FullSettingsBase( pDev, name ), cameraSetting( pDev, name ), connector( pDev, name ) {} + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief Camera related settings. + CameraSettingsFrameGrabber cameraSetting; + /// \brief Input channel related properties. + Connector connector; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION +# ifndef WRAP_ANY +/// \brief \b deprecated. Use the class \b mvIMPACT::acquire::SystemSettings instead(\b Device specific interface layout only). +/** + * \deprecated + * This class has been declared \b deprecated and might not be available in future releases. + * All features of this class are now available in \b mvIMPACT::acquire::SystemSettings as well, so please use + * this class instead. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +typedef SystemSettings MVIMPACT_DEPRECATED_CPP( SystemBlueCOUGAR ); +# endif // # ifndef WRAP_ANY +# endif // #ifndef IGNORE_MVBLUECOUGAR_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A class containing \b mvBlueFOX specific settings to control the overall behaviour of the driver(\b Device specific interface layout only). +/** + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class SystemBlueFOX : public SystemSettings +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::SystemBlueFOX object. + explicit SystemBlueFOX( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : SystemSettings( pDev ), transferSize(), footerMode(), footerCheckEnable(), powerMode(), statusLEDEnable() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltSystemSettings ); + locator.bindComponent( powerMode, "PowerMode" ); + locator.bindComponent( statusLEDEnable, "StatusLEDEnable" ); + locator.bindSearchBase( locator.searchbase_id(), "Camera" ); + locator.bindComponent( transferSize, "TransferSize" ); + locator.bindComponent( footerMode, "FooterMode" ); + locator.bindComponent( footerCheckEnable, "FooterCheckEnable" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the block size of the image data blocks transferred from the device. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBlueFOXTransferSize. + */ + PropertyIBlueFOXTransferSize transferSize; + /// \brief An enumerated integer property defining the footer mode of the device. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBlueFOXFooterMode. + */ + PropertyIBlueFOXFooterMode footerMode; + /// \brief An enumerated integer property allowing to switch on/off the check of the image footer. + /** + * The image footer contains certain additional data as e.g. the exposure time as used by the image + * sensor. To debug transfer related problems it sometimes can be useful to disable all internal + * data consistency checks by the driver. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean footerCheckEnable; + /// \brief An enumerated integer property defining the power mode of the device. + /** + * \note + * This property requires at least firmware version 39! See \b mvIMPACT::acquire::Device::firmwareVersion to find + * out which firmware is currently running on the device or use \b mvIMPACT::acquire::Device::updateFirmware() + * to update the firmware to the state compiled into the driver. + * + * \note + * Do \b NOT modify this property when images are acquired in parallel. Switching off or on the power + * for a device that is capturing images at the same time will result in incorrect images! Therefore + * always make sure to stop image acquisition and clean up \b BEFORE modifying this property. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TDevicePowerMode. + */ + PropertyIDevicePowerMode powerMode; + /// \brief An enumerated integer property allowing to switch on/off the status LED of the device. + /** + * \note + * This feature is currently available for mvBlueFOX-MLC devices only. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \since 2.17.0 + */ + PropertyIBoolean statusLEDEnable; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; +# endif // #ifndef IGNORE_MVBLUEFOX_SPECIFIC_DOCUMENTATION + +# ifndef IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION +//----------------------------------------------------------------------------- +/// \brief A class containing \b mvV4L2 specific settings to control the overall behaviour of the driver(\b Device specific interface layout only). +/** + * \note UNDER CONSTRUCTION! Subject to change. + * + * \note This class will only be available if \b mvIMPACT::acquire::Device::interfaceLayout is set to + * \b mvIMPACT::acquire::dilDeviceSpecific before the device is opened. + */ +class SystemV4L2 : public SystemSettings +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new \b mvIMPACT::acquire::SystemV4L2 object. + explicit SystemV4L2( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev ) : SystemSettings( pDev ), volume(), balance(), bass(), treble(), mute(), loudness() + { + pDev->validateInterfaceLayout( dilDeviceSpecific ); + DeviceComponentLocator locator( pDev, dltSystemSettings ); + locator.bindSearchBase( locator.searchbase_id(), "V4L-Audio" ); + locator.bindComponent( volume, "Volume" ); + locator.bindComponent( balance, "Balance" ); + locator.bindComponent( bass, "Bass" ); + locator.bindComponent( treble, "Treble" ); + locator.bindComponent( mute, "Mute" ); + locator.bindComponent( loudness, "Loudness" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief If V4L2 device supports audio, this integer property adjusts the audio volume. + /** + * This property represents a V4L2-audio-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI volume; + /// \brief If V4L2 device supports audio, this integer property adjusts the audio balance. + /** + * This property represents a V4L2-audio-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI balance; + /// \brief If V4L2 device supports audio, this integer property adjusts the audio bass. + /** + * This property represents a V4L2-audio-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI bass; + /// \brief If V4L2 device supports audio, this integer property adjusts the audio treble. + /** + * This property represents a V4L2-audio-control ID. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + * If supported, a minimum value, a maximum value and step width will be defined. Thus, invalid values may be tuned after writing to fit within the step size, + * values too large or too small will raise an exception. + */ + PropertyI treble; + /// \brief If V4L2 device supports audio, this enumerated integer property sets audio mute on/off. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean mute; + /// \brief If V4L2 device supports audio, this enumerated integer property sets audio loudness on/off. + /** + * This property represents a boolean-valued V4L2-control ID. Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + * + * \note This property is not supported by every device. + * Therefore always call the function \b mvIMPACT::acquire::Component::isValid to check if this property is available or not. + */ + PropertyIBoolean loudness; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + +}; +# endif // #ifndef IGNORE_MVV4L2_SPECIFIC_DOCUMENTATION + +/// @} + +#endif // #ifndef IGNORE_MVDEVICE_SPECIFIC_INTERFACE_DOCUMENTATION + +inline void ExceptionFactory::raiseException( const char* pFunctionName, int lineNumber, int errorCode, HOBJ objectHandle /* = INVALID_ID*/ ) +{ + std::ostringstream oss; + oss << pFunctionName << " (line: " << lineNumber << ")"; + switch( errorCode ) + { + case PROPHANDLING_NOT_A_LIST: + throw ENotAList( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_NOT_A_PROPERTY: + throw ENotAProperty( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_NOT_A_METHOD: + throw ENotAMethod( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_NO_READ_RIGHTS: + throw ENoReadRights( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_NO_WRITE_RIGHTS: + throw ENoWriteRights( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_NO_MODIFY_SIZE_RIGHTS: + throw ENoModifySizeRights( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_INCOMPATIBLE_COMPONENTS: + throw EIncompatibleComponents( getLastErrorString(), oss.str(), false ); + case PROPHANDLING_UNSUPPORTED_PARAMETER: + throw EUnsupportedParameter( oss.str() ); + case PROPHANDLING_SIZE_MISMATCH: + throw ESizeMismatch( getLastErrorString(), oss.str() ); + case PROPHANDLING_IMPLEMENTATION_MISSING: + throw EImplementationMissing( getLastErrorString(), oss.str() ); + case PROPHANDLING_INVALID_PROP_VALUE: + throw EInvalidValue( getLastErrorString(), oss.str(), false ); + case PROPHANDLING_PROP_TRANSLATION_TABLE_CORRUPTED: + throw ETranslationTableCorrupted( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_PROP_VAL_ID_OUT_OF_BOUNDS: + throw EValIDOutOfBounds( getLastErrorString(), oss.str(), false ); + case PROPHANDLING_PROP_TRANSLATION_TABLE_NOT_DEFINED: + throw ETranslationTableNotDefined( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_INVALID_PROP_VALUE_TYPE: + throw EInvalidValueType( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_PROP_VAL_TOO_LARGE: + throw EValTooLarge( getLastErrorString(), oss.str() ); + case PROPHANDLING_PROP_VAL_TOO_SMALL: + throw EValTooSmall( getLastErrorString(), oss.str() ); + case PROPHANDLING_COMPONENT_NOT_FOUND: + throw EComponentNotFound( getLastErrorString(), oss.str() ); + case PROPHANDLING_LIST_ID_INVALID: + throw EInvalidListID( getLastErrorString(), oss.str() ); + case PROPHANDLING_COMPONENT_ID_INVALID: + throw EComponentIDInvalid( oss.str() ); + case PROPHANDLING_LIST_ENTRY_OCCUPIED: + throw EListEntryOccupied( oss.str() ); + case PROPHANDLING_LIST_CANT_ACCESS_DATA: + throw ECantAccessData( getLastErrorString(), oss.str() ); + case PROPHANDLING_METHOD_PTR_INVALID: + throw EMethodPtrInvalid( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_METHOD_INVALID_PARAM_LIST: + throw EInvalidParameterList( getLastErrorString(), oss.str() ); + case PROPHANDLING_INVALID_INPUT_PARAMETER: + throw EInvalidInputParameter( getLastErrorString(), oss.str() ); + case PROPHANDLING_INPUT_BUFFER_TOO_SMALL: + throw EInputBufferTooSmall( oss.str() ); + case PROPHANDLING_WRONG_PARAM_COUNT: + throw EWrongParamCount( getLastErrorString(), oss.str() ); + case PROPHANDLING_UNSUPPORTED_OPERATION: + throw EUnsupportedOperation( oss.str() ); + case PROPHANDLING_CANT_SERIALIZE_DATA: + throw ECantSerializeData( Component( objectHandle ).name(), oss.str() ); + case PROPHANDLING_INVALID_FILE_CONTENT: + throw EInvalidFileContent( getLastErrorString(), oss.str() ); + case PROPHANDLING_CANT_ALLOCATE_LIST: + throw ECantAllocateNewList( oss.str() ); + case PROPHANDLING_CANT_REGISTER_COMPONENT: + throw ECantRegisterComponent( getLastErrorString(), oss.str() ); + case PROPHANDLING_PROP_VALIDATION_FAILED: + throw EValidationFailed( getLastErrorString(), oss.str() ); + // unsupported: + //PROPHANDLING_ACCESSTOKEN_CREATION_FAILED = -2011 + //PROPHANDLING_COMPONENT_HAS_OWNER_ALREADY = -2023, + //PROPHANDLING_COMPONENT_ALREADY_REGISTERED = -2024, + //PROPHANDLING_SWIG_ERROR = -2028, + //PROPHANDLING_COMPONENT_NO_CALLBACK_REGISTERED = -2030, + case DMR_DEV_NOT_FOUND: + case DMR_INIT_FAILED: + case DMR_DRV_ALREADY_IN_USE: + case DMR_DEV_CANNOT_OPEN: + case DMR_NOT_INITIALIZED: + case DMR_DRV_CANNOT_OPEN: + case DMR_DEV_REQUEST_QUEUE_EMPTY: + case DMR_DEV_REQUEST_CREATION_FAILED: + case DMR_INVALID_PARAMETER: + case DMR_EXPORTED_SYMBOL_NOT_FOUND: + case DEV_UNKNOWN_ERROR: + case DEV_HANDLE_INVALID: + case DEV_INPUT_PARAM_INVALID: + case DEV_WRONG_INPUT_PARAM_COUNT: + case DEV_CREATE_SETTING_FAILED: + case DEV_REQUEST_CANT_BE_UNLOCKED: + case DEV_INVALID_REQUEST_NUMBER: + case DEV_LOCKED_REQUEST_IN_QUEUE: + case DEV_NO_FREE_REQUEST_AVAILABLE: + case DEV_WAIT_FOR_REQUEST_FAILED: + case DEV_UNSUPPORTED_PARAMETER: + case DEV_INVALID_RTC_NUMBER: + case DMR_INTERNAL_ERROR: + case DMR_INPUT_BUFFER_TOO_SMALL: + case DEV_INTERNAL_ERROR: + case DMR_LIBRARY_NOT_FOUND: + case DMR_FUNCTION_NOT_IMPLEMENTED: + case DMR_FEATURE_NOT_AVAILABLE: + case DMR_EXECUTION_PROHIBITED: + case DMR_FILE_NOT_FOUND: + case DMR_INVALID_LICENCE: + case DEV_SENSOR_TYPE_ERROR: + case DMR_CAMERA_DESCRIPTION_INVALID: + case DMR_NEWER_LIBRARY_REQUIRED: + case DMR_TIMEOUT: + case DMR_WAIT_ABANDONED: + case DMR_EXECUTION_FAILED: + case DEV_REQUEST_ALREADY_IN_USE: + case DEV_REQUEST_BUFFER_INVALID: + case DEV_REQUEST_BUFFER_MISALIGNED: + case DEV_ACCESS_DENIED: + case DMR_PRELOAD_CHECK_FAILED: + case DMR_FILE_ACCESS_ERROR: + case DMR_CAMERA_DESCRIPTION_INVALID_PARAMETER: + case DMR_INVALID_QUEUE_SELECTION: + case DMR_ACQUISITION_ENGINE_BUSY: + case DMR_BUSY: + case DMR_OUT_OF_MEMORY: + throw EDeviceManager( getLastErrorString(), oss.str(), static_cast( errorCode ) ); + default: + throw ImpactAcquireException( "Unknown error(" + getLastErrorString() + ")", oss.str(), errorCode ); + } +} + +namespace GenICam +{ + +class GenTLDriverConfigurator; + +//----------------------------------------------------------------------------- +/// \brief A class that contains items to configure the behaviour of the GenICam GenTL driver stack. +/** + * This class contains items to configure the enumeration behaviour of a third party GenTL producer library. + * +* \note + * Instances of this class cannot be constructed directly. To get access the functions \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator::createProducerConfiguration, + * \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator::getProducerConfigurations + * or \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator::getProducerConfiguration must be used. + * must be used. + * + * For a comprehensive usage example see the description of the class \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator. + * + * \sa + * \ref CommonCases_mvGenTLConsumerSetup + * + * \since 2.34.0 + * \ingroup GenICamInterfaceProducer + */ +class GenTLProducerConfiguration : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ + friend class GenTLDriverConfigurator; + + Method createProducerInterfaceConfigurationEntry_; + Method deleteProducerInterfaceConfigurationEntry_; + + void bindProperties( HLIST hList ) + { + { + Component it( hList ); + ComponentLocator locator( it.parent().parent().hObj() ); + locator.bindComponent( createProducerInterfaceConfigurationEntry_, "CreateProducerInterfaceConfigurationEntry@iss" ); + locator.bindComponent( deleteProducerInterfaceConfigurationEntry_, "DeleteProducerInterfaceConfigurationEntry@iss" ); + } + { + ComponentLocator locator( hList ); + locator.bindComponent( enumerationEnable, "EnumerationEnable" ); + } + } + explicit GenTLProducerConfiguration( HLIST hList ) : mvIMPACT::acquire::ComponentCollection( hList ), + createProducerInterfaceConfigurationEntry_(), deleteProducerInterfaceConfigurationEntry_(), + enumerationEnable() + { + bindProperties( hList ); + } +public: + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration from an existing one. + GenTLProducerConfiguration( + /// [in] A constant reference to the \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration object, this object shall be created from + const GenTLProducerConfiguration& src ) : ComponentCollection( src.hObj() ), + createProducerInterfaceConfigurationEntry_( src.createProducerInterfaceConfigurationEntry_ ), + deleteProducerInterfaceConfigurationEntry_( src.deleteProducerInterfaceConfigurationEntry_ ), + enumerationEnable( src.enumerationEnable ) {} + /// \brief Allows assignments of \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration objects. + GenTLProducerConfiguration& operator=( const GenTLProducerConfiguration& rhs ) + { + if( this != &rhs ) + { + ComponentCollection::operator=( rhs ); + bindProperties( rhs.hObj() ); + } + return *this; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the enumeration behavior this particular GenTL producer. + /** + * If this property is set to \b mvIMPACT::acquire::bTrue ALL interfaces of this producer will be enumerated + * unless a specific interface enumeration behaviour has been set to \b mvIMPACT::acquire::iebForceIgnore. + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TBoolean. + */ + PropertyIBoolean enumerationEnable; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Returns the interface enumeration behaviour property for the specified interface ID for this particular GenTL producer. + /** + * + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TInterfaceEnumerationBehaviour. + * + * \note If no entry for the specified interface ID exists an exception will be thrown. + * + * \return The enumeration behaviour configuration property for the specified interface + */ + PropertyIInterfaceEnumerationBehaviour getInterfaceEnumerationBehaviour( + /// [in] The interface ID previously passed e.g. to the \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration::createProducerInterfaceConfigurationEntry function. + const std::string& interfaceID ) const + { + ComponentLocator locator( hObj(), "Interfaces" ); + const HOBJ hObj = locator.findComponent( interfaceID, 0, 1 ); + if( hObj == INVALID_ID ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, static_cast( PROPHANDLING_COMPONENT_NOT_FOUND ), "Couldn't find 'InterfaceEnumerationBehaviour' for interface '" + interfaceID + "' of producer '" + getProducerName() + "'" ); + } + return PropertyIInterfaceEnumerationBehaviour( hObj ); + } + /// \brief Returns a map containing all the configured interface IDs and their corresponding enumeration behaviour properties for this particular GenTL producer. + /** + * The returned map will only contain interface IDs which have explicitly been configured (e.g. by a previous call to + * \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration::createProducerInterfaceConfigurationEntry. Certain third party + * interfaces might also have an entry in this map (e.g. if there is a MATRIX VISION producer supporting the same technology present + * on the system). + * + * Valid values for the properties are defined by the enumeration \b mvIMPACT::acquire::TInterfaceEnumerationBehaviour. + * + * \return A map containing all the configured interface IDs and their corresponding enumeration behaviour properties for this particular GenTL producer + */ + std::map getInterfaceEnumerationBehaviours( void ) const + { + std::map m; + ComponentLocator locator( hObj(), "Interfaces" ); + Component it( locator.searchbase_id() ); + it = it.firstChild(); + while( it.isValid() ) + { + m.insert( make_pair( it.name(), PropertyIInterfaceEnumerationBehaviour( it.hObj() ) ) ); + it++; + } + return m; + } + /// \brief Creates a new interface configuration entry for this producers configuration. + /** + * Usually the parameter passed to this function will be one of the interface IDs of the producers list of reported interfaces + * in order to configure this particular interface. However it can also be an identifier for an interface not yet connected to the + * system or not yet available to the producer. No internal checks are performed regarding the validity of the given interface ID. + * + * \note If an entry with the same interface ID already exists an exception will be thrown. + */ + PropertyIInterfaceEnumerationBehaviour createProducerInterfaceConfigurationEntry( + /// [in] The interface ID to create the configuration entry for. + const std::string& interfaceID ) + { + Component it( hObj() ); + std::vector parameters; + parameters.push_back( it.name() ); + parameters.push_back( interfaceID ); + const int result = createProducerInterfaceConfigurationEntry_.call( parameters ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, static_cast( result ), "Failed to create interface configuration entry" ); + } + ComponentLocator locator( hObj(), "Interfaces" ); + return PropertyIInterfaceEnumerationBehaviour( locator.findComponent( interfaceID ) ); + } + /// \brief Deletes an interface configuration entry from this producers configuration. + /** + * \note If no entry for the specified interface can be found an exception will be thrown. + */ + void deleteProducerInterfaceConfigurationEntry( + /// [in] The exact interface ID of the producers list of reported interfaces to delete the configuration entry for. + const std::string& interfaceID ) + { + Component it( hObj() ); + std::vector parameters; + parameters.push_back( it.name() ); + parameters.push_back( interfaceID ); + const int result = deleteProducerInterfaceConfigurationEntry_.call( parameters ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, static_cast( result ), "Failed to delete interface configuration entry" ); + } + } + /// \brief Returns the name of the GenTL producer associated with this configuration object. + /** + * \return The name of the GenTL producer associated with this configuration object. + */ + std::string getProducerName( void ) const + { + return Component( hObj() ).name(); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class that contains items to configure the behaviour of the GenICam GenTL driver stack. +/** + * This class contains items e.g. to configure the enumeration behaviour of third party GenTL producer libraries. + * + * Since version 2.32.0 mvIMPACT Acquire has built-in support for third party GenTL producer libraries. + * The latest version of the GenTL specification can be found here: https://www.emva.org/standards-technology/genicam/. + * + * Detection of GenTL producer libraries works by evaluating the \c GENICAM_GENTL32_PATH environment variable + * within a 32-bit process or the \c GENICAM_GENTL64_PATH variable in a 64-bit process. This variable contains + * a list of directories that might potentially contain GenTL producer libraries. These libraries use a + * the file extension \c .cti and export a defined interface. + * + * All libraries that fulfill these requirements will be loaded into the mvIMPACT Acquire process. By default + * all these libraries will then also be enumerated for connected/bound devices. The only exception will be + * if a third party producer is found that reports an interface supporting the same technology as one delivered + * by mvIMPACT Acquire (e.g. for the GigE Vision or USB3 Vision standard). These interfaces by default will not + * be enumerated. + * + * The purpose of this class now is to allow an application to modify this behaviour. This might be beneficial for + * several reasons: + * + * - a certain third party library on the system has negative impact on the overall stability of the process + * - there are so many third party libraries on the system that enumeration takes a very long time but the application does not want to access devices reported by these third party libraries + * - multiple producers support the same device resulting in very long and confusing device lists + * - etc. + * + * To exclude a certain producer from enumeration first a mvIMPACT::acquire::GenICam::GenTLProducerConfiguration entry for that + * producer must be created and then the \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration::enumerationEnable + * property for this producer must be set to \b mvIMPACT::acquire::bFalse. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * GenTLDriverConfigurator driverConfigurator; + * if( !driverConfigurator.hasProducerConfiguration( "ACME.producer.cti" ) ) + * { + * driverConfigurator.createProducerConfiguration( "ACME.producer.cti" ); // the 'enumerationEnable' will be false by default! + * } + * else + * { + * driverConfigurator.getProducerConfiguration( "ACME.producer.cti" ).enumerationEnable.write( bFalse ); + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * GenTLDriverConfigurator driverConfigurator = new GenTLDriverConfigurator(); + * if( !driverConfigurator.hasProducerConfiguration( "ACME.producer.cti" ) ) + * { + * driverConfigurator.createProducerConfiguration( "ACME.producer.cti" ); // the 'enumerationEnable' will be false by default! + * } + * else + * { + * driverConfigurator.getProducerConfiguration( "ACME.producer.cti" ).enumerationEnable.write( TBoolean.bFalse ); + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * driverConfigurator = acquire.GenTLDriverConfigurator() + * if driverConfigurator.hasProducerConfiguration("ACME.producer.cti") == False: + * driverConfigurator.createProducerConfiguration("ACME.producer.cti") # the 'enumerationEnable' will be false by default! + * else: + * driverConfigurator.getProducerConfiguration("ACME.producer.cti").enumerationEnable.write(acquire.bFalse) + * \endcode + * \endif + * + * To exclude a certain interface from a producer from enumeration an \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration::enumerationEnable + * property for this producer can be set to \b mvIMPACT::acquire::bFalse and the interface enumeration behaviour should be set to + * \b mvIMPACT::acquire::iebForceEnumerate. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * GenTLDriverConfigurator driverConfigurator; + * GenTLProducerConfiguration configuration( driverConfigurator.hasProducerConfiguration( "ACME.producer.cti" ) ? driverConfigurator.getProducerConfiguration( "ACME.producer.cti" ) : driverConfigurator.createProducerConfiguration( "ACME.producer.cti" ) ); + * configuration.enumerationEnable.write( bTrue ); // switch on ALL interfaces... + * configuration.createProducerInterfaceConfigurationEntry( "ACME.interface0.ID" ).write( iebForceIgnore ); // ... except this one + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * // Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * GenTLDriverConfigurator driverConfigurator = new GenTLDriverConfigurator(); + * GenTLProducerConfiguration configuration = null; + * if( driverConfigurator.hasProducerConfiguration( "ACME.producer.cti" ) ) + * { + * configuration = driverConfigurator.getProducerConfiguration( "ACME.producer.cti" ); + * } + * else + * { + * configuration = driverConfigurator.createProducerConfiguration( "ACME.producer.cti" ); + * } + * configuration.getEnumerationEnable().write( TBoolean.bTrue ); // switch on ALL interfaces... + * configuration.createProducerInterfaceConfigurationEntry( "ACME.interface0.ID" ).write( TInterfaceEnumerationBehaviour.iebForceIgnore ); // ... except this one + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * driverConfigurator = acquire.GenTLDriverConfigurator() + * GenTLProducerConfiguration configuration = None + * if driverConfigurator.hasProducerConfiguration("ACME.producer.cti"): + * configuration = driverConfigurator.getProducerConfiguration("ACME.producer.cti") + * else: + * configuration = driverConfigurator.createProducerConfiguration("ACME.producer.cti") + * configuration.enumerationEnable.write(acquire.bTrue) # switch on ALL interfaces... + * configuration.createProducerInterfaceConfigurationEntry("ACME.interface0.ID").write(acquire.iebForceIgnore) # ... except this one + * \endcode + * \endif + * + * The same thing can be done the other way round: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH and only a certain interface shall be enumerated. + * GenTLDriverConfigurator driverConfigurator; + * GenTLProducerConfiguration configuration( driverConfigurator.hasProducerConfiguration( "ACME.producer.cti" ) ? driverConfigurator.getProducerConfiguration( "ACME.producer.cti" ) : driverConfigurator.createProducerConfiguration( "ACME.producer.cti" ) ); + * configuration.enumerationEnable.write( bFalse ); // switch off ALL interfaces... + * configuration.createProducerInterfaceConfigurationEntry( "ACME.interface0.ID" ).write( iebForceEnumerate ); // ... except this one + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * GenTLDriverConfigurator driverConfigurator = new GenTLDriverConfigurator(); + * GenTLProducerConfiguration configuration = null; + * if( driverConfigurator.hasProducerConfiguration( "ACME.producer.cti" ) ) + * { + * configuration = driverConfigurator.getProducerConfiguration( "ACME.producer.cti" ); + * } + * else + * { + * configuration = driverConfigurator.createProducerConfiguration( "ACME.producer.cti" ); + * } + * configuration.getEnumerationEnable().write( TBoolean.bFalse ); // switch on ALL interfaces... + * configuration.createProducerInterfaceConfigurationEntry( "ACME.interface0.ID" ).write( TInterfaceEnumerationBehaviour.iebForceEnumerate ); // ... except this one + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * # Assuming a certain 'ACME.producer.cti' producer has been found somewhere in the GENICAM_GENTLXY_PATH. + * driverConfigurator = acquire.GenTLDriverConfigurator() + * GenTLProducerConfiguration configuration = None + * if driverConfigurator.hasProducerConfiguration("ACME.producer.cti"): + * configuration = driverConfigurator.getProducerConfiguration("ACME.producer.cti") + * else: + * configuration = driverConfigurator.createProducerConfiguration("ACME.producer.cti") + * configuration.enumerationEnable.write(acquire.bFalse) # switch on ALL interfaces... + * configuration.createProducerInterfaceConfigurationEntry("ACME.interface0.ID").write(acquire.iebForceEnumerate) # ... except this one + * \endcode + * \endif + * \sa + * \ref CommonCases_mvGenTLConsumerSetup + * + * \since 2.34.0 + * \ingroup GenICamInterfaceProducer + */ +class GenTLDriverConfigurator : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +private: + Method createProducerConfigurationEntry_; + Method deleteProducerConfigurationEntry_; + Method createProducerInterfaceConfigurationEntry_; + + void bindProperties( void ) + { + HLIST hList; + TDMR_ERROR result; + if( ( result = DMR_FindList( INVALID_ID, "mvGenTLConsumer", dmltDeviceDriverLib, 0, &hList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, "Couldn't find list 'mvGenTLConsumer'(type: dmltDeviceDriverLib)" ); + } + mvIMPACT::acquire::ComponentLocator locator( hList, "GenTL" ); + hList = locator.findComponent( "ProducersConfiguration", 0, 1 ); + if( hList == INVALID_ID ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_NEWER_LIBRARY_REQUIRED, "Couldn't find list 'ProducersConfiguration'. An update of the GenTL Acquire package might fix this!" ); + } + locator.bindComponent( masterEnumerationBehaviour, "MasterEnumerationBehaviour" ); + locator.bindComponent( createProducerConfigurationEntry_, "CreateProducerConfigurationEntry@is" ); + locator.bindComponent( deleteProducerConfigurationEntry_, "DeleteProducerConfigurationEntry@is" ); + locator.bindComponent( createProducerInterfaceConfigurationEntry_, "CreateProducerInterfaceConfigurationEntry@iss" ); + locator.bindSearchBase( hList ); + m_hRoot = locator.searchbase_id(); + } +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::GenTLDriverConfigurator object. + explicit GenTLDriverConfigurator() : mvIMPACT::acquire::ComponentCollection( INVALID_ID ), + createProducerConfigurationEntry_(), deleteProducerConfigurationEntry_(), + createProducerInterfaceConfigurationEntry_(), + masterEnumerationBehaviour() + { + bindProperties(); + } + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator from an existing one. + GenTLDriverConfigurator( + /// [in] A constant reference to the \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator object, this object shall be created from + const GenTLDriverConfigurator& src ) : ComponentCollection( src.hObj() ), + createProducerConfigurationEntry_( src.createProducerConfigurationEntry_ ), + deleteProducerConfigurationEntry_( src.deleteProducerConfigurationEntry_ ), + createProducerInterfaceConfigurationEntry_( src.createProducerInterfaceConfigurationEntry_ ), + masterEnumerationBehaviour( src.masterEnumerationBehaviour ) {} + /// \brief Allows assignments of \b mvIMPACT::acquire::GenICam::GenTLDriverConfigurator objects. + GenTLDriverConfigurator& operator=( const GenTLDriverConfigurator& rhs ) + { + if( this != &rhs ) + { + ComponentCollection::operator=( rhs ); + bindProperties(); + } + return *this; + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property defining the master enumeration mode for all GenTL producer detected in the current session. + /** + * Valid values for this property are defined by the enumeration \b mvIMPACT::acquire::TInterfaceEnumerationBehaviour. + */ + PropertyIInterfaceEnumerationBehaviour masterEnumerationBehaviour; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Creates a new \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration object for the desired interface reported by the specified producer. + /** + * Calling this function will creates a new \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration object for the desired interface + * reported by the specified producer. + * + * \note If a configuration entry for the specified interface does already exist an exception will be thrown. + */ + GenTLProducerConfiguration createProducerConfiguration( + /// [in] The exact name of the producer library without the path to create the entry for. + const std::string& producerName, + /// [in] The interface ID to create the configuration entry for. + const std::string& interfaceID = "" ) + { + int result = DMR_NO_ERROR; + if( interfaceID.empty() ) + { + result = createProducerConfigurationEntry_.call( producerName ); + } + else + { + std::vector parameters; + parameters.push_back( producerName ); + parameters.push_back( interfaceID ); + result = createProducerInterfaceConfigurationEntry_.call( parameters ); + } + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, static_cast( result ), "Failed to create entry '" + producerName + "'" + ( interfaceID.empty() ? "" : " with interface entry '" + interfaceID + "'" ) ); + } + ComponentLocator locator( hObj(), "ConfigurationData" ); + return GenTLProducerConfiguration( locator.findComponent( producerName, 0, 1 ) ); + } + /// \brief Deletes a \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration objects. + /** + * Calling this function will delete the \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration object for the referenced producer. + * + * \note If no entry for the specified producer can be found an exception will be thrown. + */ + void deleteProducerConfiguration( + /// [in] The exact name of the producer library without the path to delete the entry from. + const std::string& producerName ) + { + const int result = deleteProducerConfigurationEntry_.call( producerName ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, static_cast( result ), "Failed to delete entry '" + producerName + "'" ); + } + } + /// \brief Deletes all \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration objects. + /** + * Calling this function will result in all \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration objects to be deleted. When the next + * mvIMPACT Acquire process will be started after shutting down the current one all producer libraries found on the system will be processed. By default only interfaces reporting + * types/technologies (e.g. GigE Vision) also supported by MATRIX VISION will be ignored (will not enumerate devices) then. + */ + void deleteAllProducerConfigurations( void ) + { + std::vector data( getProducerConfigurations() ); + std::vector::size_type cnt = data.size(); + for( std::vector::size_type i = 0; i < cnt; i++ ) + { + deleteProducerConfiguration( data[i].getProducerName() ); + } + } + /// \brief Checks if a certain producer library has been associated with a \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration. + /** + * \return + * - true if a \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration is currently associated with the referenced producer library + * - false otherwise + */ + bool hasProducerConfiguration( + /// [in] The exact name of the producer library without the path. + const std::string& producerName ) const + { + ComponentLocator locator( hObj(), "ConfigurationData" ); + return locator.findComponent( producerName, 0, 1 ) != INVALID_ID; + } + /// \brief Returns the \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration associated with the referenced producer library. + /** + * + * \note If no entry for the specified producer can be found an exception will be thrown. + * + * \return The \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration associated with the referenced producer library. + */ + GenTLProducerConfiguration getProducerConfiguration( + /// [in] The exact name of the producer library without the path. + const std::string& producerName ) const + { + ComponentLocator locator( hObj(), "ConfigurationData" ); + const HLIST hList = locator.findComponent( producerName, 0, 1 ); + if( hList == INVALID_ID ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, static_cast( PROPHANDLING_COMPONENT_NOT_FOUND ), "Couldn't find configuration for producer '" + producerName + "'" ); + } + return GenTLProducerConfiguration( hList ); + } + /// \brief Returns a vector containing all \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration objects currently defined. + /** + * \return A vector containing all \b mvIMPACT::acquire::GenICam::GenTLProducerConfiguration objects currently defined. + */ + std::vector getProducerConfigurations( void ) const + { + ComponentLocator locator( hObj(), "ConfigurationData" ); + Component it( locator.searchbase_id() ); + it = it.firstChild(); + std::vector data; + while( it.isValid() ) + { + data.push_back( GenTLProducerConfiguration( it.hObj() ) ); + it++; + } + return data; + } +}; + +} // namespace GenICam + +/// \namespace mvIMPACT::acquire::labs This namespace contains classes and functions belonging to the general part of this SDK that +/// are not yet final and might change in the future without further notice. Yet still we think code within this namespace +/// might prove useful thus we encourage you to use it if beneficial for your application. However be prepared to apply changes when needed. +/// Feedback that helps to improve or finalize code from this namespace will be highly appreciated! A migration guide will be provided and we will +/// perform changes only if they make sense and improve the code. +namespace labs +{ + +//----------------------------------------------------------------------------- +/// \brief A class to create compressed video stream from images captured or loaded using the %mvIMPACT Acquire API. +/** + * This class heavily depends on the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg). Without the + * libraries belonging to this project being present on the target system video streams cannot be created. + * + * Because of what is stated in the above section %mvIMPACT Acquire is \b NOT shipped with the FFmpeg binaries required to use + * this class! + * + * On Windows the \a FFmpeg-share package matching the platform the application shall run with (32- or 64-bit) is needed. This + * can either be extracted into the installation folder of %mvIMPACT Acquire e.g. into \$(MVIMPACT_ACQUIRE_DIR)/Toolkits/ffmpeg-4.2.2-win64-shared or + * \$(MVIMPACT_ACQUIRE_DIR)/Toolkits/ffmpeg-4.2.2-win32-shared (Works only for this versions) \b OR at the location pointed to by \b MVIMPACT_ACQUIRE_FFMPEG_DIR (see below) + * \b OR anywhere into the systems search path. + * + * On Linux the package \a ffmpeg must be installed and if e.g. H.264 support is needed the libavcodec-extra package as well. + * + * \attention Please carefully read and understand the legal implications coming with the use of FFmpeg in a commercial product: http://ffmpeg.org/legal.html + * + * %mvIMPACT Acquire is capable of communicating with FFmpeg 4.x right now. This means that the following libraries will be recognized: + * - libavcodec-58, libavformat-58 and libavutil-56 (FFmpeg 4.0 was released on 20.04.2018) + * + * In order to load the FFmpeg libraries + * from a custom location the environment variable \b MVIMPACT_ACQUIRE_FFMPEG_DIR can be defined before creating the first + * \b mvIMPACT::acquire::labs::VideoStream instance after loading the mvDeviceManager library into the current processes address space. + * Without this environment variable only the systems default search path will be used to locate it and (Windows only) the \a Toolkits + * folder of the installation directory. This is how the search algorithm will operate: + * + * \code + * if isEnvironmentVariableDefined( MVIMPACT_ACQUIRE_FFMPEG_DIR ) + * if tryToLoadFFmpegVersion4Succeeded + * return + * if tryToLoadFFmpegVersion3Succeeded + * return + * if isWindowsSystem + * if tryToLoadFFmpegVersionFromToolkits4Succeeded + * return + * if tryToLoadFFmpegVersion4Succeeded + * return + * if tryToLoadFFmpegVersion3Succeeded + * return + * ReportError + * \endcode + * + * \note + * Currently video streams can only be created for a limited number of pixel formats. Which codec supports which input formats is described at the corresponding + * \b mvIMPACT::acquire::TVideoCodec value. Make sure to use one of these formats either by setting up your device accordingly or by using + * the \b mvIMPACT::acquire::ImageDestination::pixelFormat property of the \ref Image_Format_Converter. + * + * \attention + * - You have to feed one of the supported pixel formats depending on the video codecs requirements into the stream! The video stream API will NOT perform internal conversion. If you need to convert + * (most likely you will be!) use the \ref Image_Format_Converter to achieve that. It will get the job done! + * - When not providing timestamps together with the images that are fed into the encoder the resulting video stream can still be used, but the playback speed will differ from the acquisition speed then. + * When providing the timestamps coming with the requests the playback speed will resemble exactly the acquisition speed. Most codecs even support variable playback speeds so dynamic changes in the + * frame rate will be reflected during playback. + * \since 2.39.0 + * \ingroup CommonInterface + */ +class VideoStream +//----------------------------------------------------------------------------- +{ + HDMR_VIDEO_STREAM hStream_; + std::string fileName_; + TVideoCodec videoCodec_; + + void create( const std::string& fileName, const unsigned int imageWidth, const unsigned int imageHeight, const TVideoCodec codec, const unsigned int quality_pc, const unsigned int bitrate ) + { + const TDMR_ERROR result = DMR_OpenVideoStream( fileName.c_str(), imageWidth, imageHeight, codec, quality_pc, bitrate, &hStream_ ); + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result ); + } + } +public: +/// \brief Creates a new video stream file. + /** + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this constructor will raise an exception. + */ + explicit VideoStream( + /// [in] The name or full path of the file to create. The recommended file extensions for files can be found where the + /// \b mvIMPACT::acquire::TVideoCodec enumeration is documented + const std::string& fileName, + /// [in] An image buffer containing the layout of the images that are about to get stored in the stream. This structure can be + /// extracted from a real \b mvIMPACT::acquire::Request object captured previously but \b NOT by calling the + /// \b mvIMPACT::acquire::FunctionInterface::getCurrentCaptureBufferLayout function after setting up the device + /// completely.The latter one will not contain all the information needed for a successful stream creation. You could even create a stream from a list of files e.g. on a hard-disc using the + /// \b mvIMPACT::acquire::ImageBufferDesc constructor accepting a file name. If you want to use the \b mvIMPACT::acquire::Request + /// object obtained from a call to \b mvIMPACT::acquire::FunctionInterface::getCurrentCaptureBufferLayout use the constructor accepting + /// a \b mvIMPACT::acquire::Request pointer! + const ImageBuffer* pBuffer, + /// [in] The codec that shall be used while encoding the images into the stream. + const TVideoCodec codec = vcH264, + /// [in] The quality of the resulting video stream in percent. The higher this value the larger the file will get. This value is only taken into + /// account for the following codecs: \b mvIMPACT::acquire::vcH264, \b mvIMPACT::acquire::vcH265 + const unsigned int quality_pc = 60, + /// [in] The bitrate of the resulting video stream in kBit/s. The higher this value the larger the file will get. This value is only taken into + /// account for the following codecs: \b mvIMPACT::acquire::vcMPEG2. + const unsigned int bitrate = 6000 ) : hStream_( 0 ), fileName_( fileName ), videoCodec_( codec ) + { + create( fileName, pBuffer->iWidth, pBuffer->iHeight, codec, quality_pc, bitrate ); + } + /// \brief Creates a new video stream file. + /** + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this constructor will raise an exception. + */ + explicit VideoStream( + /// [in] The name or full path of the file to create. The recommended file extensions for files can be found where the + /// \b mvIMPACT::acquire::TVideoCodec enumeration is documented + const std::string& fileName, + /// [in] The input image width in pixels + const unsigned int imageWidth, + /// [in] The input image height in pixels + const unsigned int imageHeight, + /// [in] The codec that shall be used while encoding the images into the stream. + const TVideoCodec codec = vcH264, + /// [in] The quality of the resulting video stream in percent. The higher this value the larger the file will get. This value is only taken into + /// account for the following codecs: \b mvIMPACT::acquire::vcH264, \b mvIMPACT::acquire::vcH265 + const unsigned int quality_pc = 60, + /// [in] The bitrate of the resulting video stream in kBit/s. The higher this value the larger the file will get. This value is only taken into + /// account for the following codecs: \b mvIMPACT::acquire::vcMPEG2. + const unsigned int bitrate = 6000 ) : hStream_( 0 ), fileName_( fileName ), videoCodec_( codec ) + { + create( fileName, imageWidth, imageHeight, codec, quality_pc, bitrate ); + } + /// \brief Creates a new video stream file. + /** + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this constructor will raise an exception. + */ + explicit VideoStream( + /// [in] The name or full path of the file to create. The recommended file extensions for files can be found where the + /// \b mvIMPACT::acquire::TVideoCodec enumeration is documented. + const std::string& fileName, + /// [in] A \b mvIMPACT::acquire::Request object carrying the image related information that are about to get stored in the stream. This can either be + /// extracted from a real \b mvIMPACT::acquire::Request object captured previously or by calling the + /// \b mvIMPACT::acquire::FunctionInterface::getCurrentCaptureBufferLayout function after setting up the device + /// completely. To create a stream from a list of files e.g. on a hard-disc use the \b mvIMPACT::acquire::labs::VideoStream + /// constructor accepting a \b mvIMPACT::acquire::ImageBufferDesc instead! Create instances of b mvIMPACT::acquire::ImageBufferDesc + /// objects from files call the \b mvIMPACT::acquire::ImageBufferDesc constructor accepting a file name. + const Request* pRequest, + /// [in] The codec that shall be used while encoding the images into the stream. + const TVideoCodec codec = vcH264, + /// [in] The quality of the resulting video stream in percent. The higher this value the larger the file will get. This value is only taken into + /// account for the following codecs: \b mvIMPACT::acquire::vcH264, \b mvIMPACT::acquire::vcH265 + const unsigned int quality_pc = 60, + /// [in] The bitrate of the resulting video stream in kBit/s. The higher this value the larger the file will get. This value is only taken into + /// account for the following codecs: \b mvIMPACT::acquire::vcMPEG2. + const unsigned int bitrate = 6000 ) : hStream_( 0 ), fileName_( fileName ), videoCodec_( codec ) + { + create( fileName, pRequest->imageWidth.read(), pRequest->imageHeight.read(), codec, quality_pc, bitrate ); + } + ~VideoStream() + { + DMR_CloseVideoStream( hStream_ ); + } + /// \brief Returns the file name of this video stream. + /** + * This function returns the file name of this video stream. + * + * \since 2.39.0 + * + * \return The file name of this video stream. + */ + const std::string& getFileName( void ) const + { + return fileName_; + } + /// \brief Returns the codec used by this video stream. + /** + * This function returns the codec used by this video stream. + * + * \since 2.39.0 + * + * \return The codec used by this video stream. + */ + const TVideoCodec& getCodec( void ) const + { + return videoCodec_; + } + /// \brief Returns the a string representation for a video codec. + /** + * This function returns a string representation for a video codec. + * + * \since 2.39.0 + * + * \return A string representation for a video codec. + */ + static std::string getCodecAsString( const TVideoCodec codec ) + { + switch( codec ) + { + case vcH264: + return "H.264"; + case vcH265: + return "H.265"; + case vcMPEG2: + return "MPEG-2"; + } + return "INVALID VIDEO CODEC"; + } + /// \brief Returns the codec used by this video stream as a string. + /** + * This function returns the codec used by this video stream as a string. + * + * \since 2.39.0 + * + * \return The codec used by this video stream as a string. + */ + std::string getCodecAsString( void ) const + { + return getCodecAsString( getCodec() ); + } + /// \brief Checks if the video stream API is available. + /** + * This function checks if the video stream API is available. + * + * \since 2.39.0 + * + * \return + * - true if the video stream API is available thus video streams can be created + * - false otherwise. + */ + static bool isAPIAvailable( void ) + { + return DMR_InitVideoStreamAPI( 0, 0 ) == DMR_NO_ERROR; + } + /// \brief Stores an image into the video stream. + /** + * This function stores an image into the video stream. + * + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section as well as the remarks made here: \b mvIMPACT::acquire::labs::VideoStream) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this function will fail. + * + * \since 2.39.0 + * + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - mvIMPACT::acquire::DMR_LIBRARY_NOT_FOUND if no compatible version of the FFmpeg libraries could be located on the host system. + * - mvIMPACT::acquire::DEV_UNSUPPORTED_PARAMETER if a pixel format has been passed to the function that is not supported by the internal algorithms. + * - mvIMPACT::acquire::DEV_INPUT_PARAM_INVALID e.g. if a pixel format has been passed to the function that is not supported by the FFmpeg libraries. + * - A negative error code of type ::TDMR_ERROR otherwise. + */ + int saveImage( + /// [in] The image to encode and store. + const ImageBuffer* pBuffer, + /// [in] A timestamp(in us) to associate this image with. This can be 0 if no timestamp is available. + int64_type timestamp_us = 0LL ) + { + return DMR_SaveImageBufferToVideoStream( hStream_, pBuffer, timestamp_us ); + } + /// \brief Encodes and stores the image associated with the \b mvIMPACT::acquire::Request object into the stream. + /** + * This function stores the image associated with an \b mvIMPACT::acquire::Request object into the video stream. + * + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section as well as the remarks made here: \b mvIMPACT::acquire::labs::VideoStream) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this function will fail. + * + * \since 2.39.0 + * + * \sa + * \b mvIMPACT::acquire::labs::VideoStream::pause, \n + * \b mvIMPACT::acquire::labs::VideoStream::isPaused, \n + * \b mvIMPACT::acquire::labs::VideoStream::resume \n + * + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - mvIMPACT::acquire::DMR_LIBRARY_NOT_FOUND if no compatible version of the FFmpeg libraries could be located on the host system. + * - mvIMPACT::acquire::DEV_UNSUPPORTED_PARAMETER if a pixel format has been passed to the function that is not supported by the internal algorithms. + * - mvIMPACT::acquire::DEV_INPUT_PARAM_INVALID e.g. if a pixel format has been passed to the function that is not supported by the FFmpeg libraries. + * - A negative error code of type ::TDMR_ERROR otherwise. + */ + int saveImage( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from + /// a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] A pointer to the \b mvIMPACT::acquire::Request object carrying the image to encode and store. + const Request* pRequest ) + { + return DMR_ImageRequestSaveToVideoStream( pDev->hDrv(), pRequest->getNumber(), hStream_ ); + } + /// \brief Pauses this video stream. + /** + * This function pauses this video stream. While paused no images can be written into the stream. Pausing internally simply starts a timer + * and all accumulated pause times will be subtracted from images that will be written into the stream after the pause has been ended effectively + * allowing to remove inactive sections from the video stream. + * + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section as well as the remarks made here: \b mvIMPACT::acquire::labs::VideoStream) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this function will fail. + * + * \since 2.41.0 + * + * \sa + * \b mvIMPACT::acquire::labs::VideoStream::resume, \n + * \b mvIMPACT::acquire::labs::VideoStream::isPaused + * + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - mvIMPACT::acquire::DMR_BUSY if this stream has been paused already. + * - A negative error code of type ::TDMR_ERROR otherwise. + */ + int pause( void ) const + { + return DMR_PauseVideoStream( hStream_ ); + } + /// \brief Checks is this video stream is currently paused. + /** + * + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section as well as the remarks made here: \b mvIMPACT::acquire::labs::VideoStream) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this function will fail. + * + * \since 2.41.0 + * + * \sa + * \b mvIMPACT::acquire::labs::VideoStream::pause, \n + * \b mvIMPACT::acquire::labs::VideoStream::resume + * + * \return + * - true if this video stream is currently paused. + * - false otherwise. + */ + bool isPaused( void ) const + { + return DMR_IsVideoStreamPaused( hStream_ ) == DMR_NO_ERROR; + } + /// \brief Resumes this video stream. + /** + * This function resumes this previously paused video stream. While paused no images can be written into the stream. Pausing internally simply starts a timer + * and all accumulated pause times will be subtracted from images that will be written into the stream after the pause has been ended effectively + * allowing to remove inactive sections from the video stream. + * + * \note + * Internally the FFmpeg project (see \ref LegalNotice_UsedThirdPartySoftware_FFmpeg section as well as the remarks made here: \b mvIMPACT::acquire::labs::VideoStream) is used for this operation. If the corresponding libraries + * cannot be located in one of the supported versions on the host system calling this function will fail. + * + * \since 2.41.0 + * + * \sa + * \b mvIMPACT::acquire::labs::VideoStream::pause, \n + * \b mvIMPACT::acquire::labs::VideoStream::isPaused + * + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - mvIMPACT::acquire::DMR_EXECUTION_PROHIBITED if this stream has been paused already. + * - A negative error code of type ::TDMR_ERROR otherwise. + */ + int resume( void ) const + { + return DMR_ResumeVideoStream( hStream_ ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief A smaller helper class for pausing a video stream for a defined time. +/** + * This class uses a RAII pattern to pause an instance of mvIMPACT::acquire::labs::VideoStream + * \since 2.41.0 + * \ingroup CommonInterface + */ +class VideoStreamPauseScope +//----------------------------------------------------------------------------- +{ + VideoStream& stream_; + bool boPausedWithinScope_; +public: + /// \brief Creates a new mvIMPACT::acquire::labs::VideoStreamPauseScope object. + /** + * Trying to pause a stream that is paused already or trying to resume a stream that is not paused will raise an exception! + * When this object goes out of scope the previous state will be restored automatically. + */ + explicit VideoStreamPauseScope( + /// [in] The video stream that shall be configured. + VideoStream& stream, + /// [in] The mode the selected video stream shall have while this object is alive. + bool boPausedWithinScope = true ) : stream_( stream ), boPausedWithinScope_( boPausedWithinScope ) + { + TDMR_ERROR result = DMR_NO_ERROR; + if( boPausedWithinScope_ ) + { + result = static_cast( stream_.pause() ); + } + else + { + result = static_cast( stream_.resume() ); + } + + if( result != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( __FUNCTION__, __LINE__, result ); + } + } + ~VideoStreamPauseScope() + { + if( boPausedWithinScope_ ) + { + stream_.resume(); + } + else + { + stream_.pause(); + } + } +}; + +//----------------------------------------------------------------------------- +/// \brief A class to perform a firmware update of a specific device. +/** + * This class is intended to provide an ease of use possibility to update the firmware of specific devices. It is possible to + * specify the behavior of the class very detailed to make sure the update suits the users expectations. It is also possible to derive + * from this class and override various functions in order to get custom notifications e.g. to update a GUI application. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * To start a firmware update for MATRIX VISION GenICam devices the following code will be sufficient: + * \code + * // force the update even if the version of the mvu-file is the same es the one on the device + * mvIMPACT::acquire::labs::FirmwareUpdater fwUpdater( pDev, true ); + * try + * { + * const string pathToFirmwareArchive( "someArchive.mvu" ); + * // start the whole update process + * const int FWUpdateResult = fwUpdater.update( pathToFirmwareArchive ); + * cout << "Result of 'updateFirmware' call: " << ImpactAcquireException::getErrorCodeAsString( FWUpdateResult ) << "." << endl; + * } + * catch( const ImpactAcquireException& e ) + * { + * cout << "An error occurred while updating the firmware of the device " << pDev->serial.read() + * << "(error code: " << e.getErrorCodeAsString() << ")."; + * // reading out potential issues + * cout << "Status: " << fwUpdater.statusMessage() << endl; + * return 1; + * } + * \endcode + * + * To start a firmware update for MATRIX VISION mvBlueFOX devices the following code will be sufficient: + * \code + * mvIMPACT::acquire::labs::FirmwareUpdater fwUpdater( pDev ); + * // if necessary, a specific version for the update can be selected by using the firmwareVersionToUpload property + * try + * { + * const int FWUpdateResult = fwUpdater.update(); + * cout << "Result of 'updateFirmware' call: " << ImpactAcquireException::getErrorCodeAsString( FWUpdateResult ) << "." << endl; + * } + * catch( const ImpactAcquireException& e ) + * { + * cout << "An error occurred while updating the firmware of the device " << pDev->serial.read() + * << "(error code: " << e.getErrorCodeAsString() << ")."; + * return 1; + * } + * \endcode + * + * A more custom behavior can be accomplished by deriving from the mvIMPACT::acquire::labs::FirmwareUpdater class and re-implementing the various notification functions: + * \code + * //----------------------------------------------------------------------------- + * class MyFirmwareUpdater : public mvIMPACT::acquire::labs::FirmwareUpdater + * //----------------------------------------------------------------------------- + * { + * public: + * explicit MyFirmwareUpdater( mvIMPACT::acquire::Device* pDev ) : mvIMPACT::acquire::labs::FirmwareUpdater( pDev ) {} + * virtual int onErrorMessage( const double timeElapsed_s ) const + * { + * printf( "Error: %s @ %f [s]\n", statusMessage().c_str(), timeElapsed_s ); + * return fuaCancel; + * } + * virtual int onErasingFlash( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Erasing - Update progress: %d, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * virtual int onUnzippingFirmwareArchive( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Unzipping firmware archive - Update progress: %d, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * virtual int onUpdatingBootProgrammer( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Updating boot programmer - Update progress: %, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * virtual int onUploadingImage( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Uploading - Update progress: %d, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * virtual int onSavingUserSets( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Saving sets - Update progress: %d, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * virtual int onLoadingUserSets( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Loading sets - Update progress: %d, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * virtual int onRebooting( const int currentProgress_pc, const double timeElapsed_s ) const + * { + * printf( "Rebooting - Update progress: %d, time %f [s]\n", currentProgress_pc, timeElapsed_s ); + * return fuaContinue; + * } + * }; + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * To start a firmware update for MATRIX VISION GenICam devices the following code will be sufficient: + * \code + * // force the update even if the version of the mvu-file is the same es the one on the device + * mvIMPACT.acquire.labs.FirmwareUpdater fwUpdater = new mvIMPACT.acquire.labs.FirmwareUpdater( pDev, true ); + * try + * { + * String pathToMVUfile = new String( "someArchive.mvu" ); + * // start the whole update process + * System.out.println( "Result of firmware update call: " + ImpactAcquireException.getErrorCodeAsString( pFWU.update( pathToMVUfile ) ) ); + * } + * catch( ImpactAcquireException e ) + * { + * System.out.println( "An error occured during the firmware update process. Error code: " + e.getErrorCodeAsString() ); + * System.out.println( "Status: " + pFWU.statusMessage() ); + * } + * \endcode + * + * To start a firmware update for MATRIX VISION mvBlueFOX devices the following code will be sufficient: + * \code + * mvIMPACT.acquire.labs.FirmwareUpdater fwUpdater = new mvIMPACT.acquire.labs.FirmwareUpdater( pDev ); + * // if necessary, a specific version for the update can be selected by using the firmwareVersionToUpload property + * try + * { + * // start the whole update process + * System.out.println( "Result of firmware update call: " + ImpactAcquireException.getErrorCodeAsString( pFWU.update() ) ); + * } + * catch( ImpactAcquireException e ) + * { + * System.out.println( "An error occured during the firmware update process. Error code: " + e.getErrorCodeAsString() ); + * System.out.println( "Status: " + pFWU.statusMessage() ); + * } + * \endcode + * + * A more custom behavior can be accomplished by deriving from the mvIMPACT.acquire.labs.FirmwareUpdater class and re-implementing the various notification functions: + * \code + * import mvIMPACT.acquire.*; + * + * public class MyFirmwareUpdater extends FirmwareUpdater + * { + * public MyFirmwareUpdater( Device pDev, boolean boForceOverideSameVersion, boolean boForceDowngrade, boolean boKeepUserSets, boolean boForceBreakingChange ) + * { + * super( pDev, boForceOverideSameVersion, boForceDowngrade, boKeepUserSets, boForceBreakingChange ); + * } + * @Override + * public int onErrorMessage( double timeElapsed_s ) + * { + * System.out.println( "Error: " + statusMessage() + " @ " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onErasingFlash( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Erasing - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onUnzippingFirmwareArchive( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Unzipping firmware archive - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onUpdatingBootProgrammer( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Updating boot programmer - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onUploadingImage( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Uploading - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onSavingUserSets( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Saving sets - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onLoadingUserSets( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Loading sets - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * @Override + * public int onRebooting( int currentProgress_pc, double timeElapsed_s ) + * { + * System.out.println( "Rebooting - Update progress: " + currentProgress_pc + ", time " + timeElapsed_s + " [s]" ); + * return mvIMPACT.acquire.TFirmwareUpdateAction.fuaContinue; + * } + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * + * To start a firmware update for MATRIX VISION mvBlueFOX devices the following code will be sufficient: + * \code + * fwUpdater = acquire.FirmwareUpdater( pDev, False, False, True, False ) + * fwUpdateResult = fwUpdater.update( PATH_TO_FIRMWARE_ARCHIVE.mvu ) + * if FWUpdateResult == 0: + * print("Update successful!") + * else: + * print( fwUpdater.statusMessage() ) + * \endcode + * To start a firmware update for MATRIX VISION mvBlueFOX devices the following code will be sufficient: + * \code + * fwUpdater = acquire.FirmwareUpdater( pDev ) + * fwUpdateResult = fwUpdater.update( 52 ) + * if FWUpdateResult == 0: + * print("Update successful!") + * else: + * print( fwUpdater.statusMessage() ) + * \endcode + * A more custom behavior can be accomplished by deriving from the acquire.FirmwareUpdater class and re-implementing the various notification functions: + * \code + * from mvIMPACT import acquire + * + * class MyFirmwareUpdater( acquire.FirmwareUpdater ): + * def __init__(self, *args): + * super(MyFirmwareUpdater, self).__init__(*args) + * + * def onErrorMessage( self, timeElapsed_s ): + * print( "Error: " + statusMessage() + " @ " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onErasingFlash( self, currentProgress_pc, timeElapsed_s ): + * print( "Erasing - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onUnzippingFirmwareArchive( self, currentProgress_pc, timeElapsed_s ): + * print( "Unzipping firmware archive - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onUpdatingBootProgrammer( self, currentProgress_pc, timeElapsed_s ): + * print( "Updating boot programmer - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onUploadingImage( self, currentProgress_pc, timeElapsed_s ): + * print( "Uploading - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onSavingUserSets( self, currentProgress_pc, timeElapsed_s ): + * print( "Saving sets - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onLoadingUserSets( self, currentProgress_pc, timeElapsed_s ): + * print( "Loading sets - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * + * def onRebooting( self, currentProgress_pc, timeElapsed_s ): + * print( "Rebooting - Update progress: " + str(currentProgress_pc) + ", time " + str(timeElapsed_s) + " [s]" ) + * return acquire.fuaContinue + * \endcode + + * \endif + + * \note + * Currently supported are the following device families: + * \note + * GenICam compliant MATRIX VISION devices + * - mvBlueCOUGAR-X + * - mvBlueCOUGAR-XD + * - mvBlueCOUGAR-XT + * - mvBlueFOX3 + * \note + * Other MATRIX VISION devices + * - mvBlueFOX + * - mvBlueFOX-MLC/IGC + * + * \attention + * It is important not to unplug the device during the update procedure.\n + * Once the firmwareUpdate method call returns an error call the mvIMPACT::acquire::labs::FirmwareUpdater::statusMessage function. It will return useful information about the current status (including issues) during the update procedure. + * + * \since 2.41.0 + * \ingroup CommonInterface + */ +class FirmwareUpdater +//----------------------------------------------------------------------------- +{ +private: +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) + PropertyS firmwareUpdateFileName_; + PropertyPtr firmwareUpdateProgressListenerAddress_; + PropertyPtr firmwareUpdateProgressListenerUserDataAddress_; + PropertyIBoolean firmwareUpdateKeepUserSets_; + PropertyIBoolean firmwareUpdateForceBreakingChange_; + PropertyIBoolean firmwareUpdateForceOverrideSameVersion_; + PropertyIBoolean firmwareUpdateForceDowngrade_; + PropertyS firmwareUpdateStatusMessage_; + Method updateFirmware_; + double timeElapsed_s_; + + void registerFirmwareUpdateCallback( CBP_FIRMWARE_UPDATE pCB, void* pUserData ) + { + if( firmwareUpdateProgressListenerAddress_.isValid() && firmwareUpdateProgressListenerUserDataAddress_.isValid() ) + { + function_cast< CBP_FIRMWARE_UPDATE > pFunc; + pFunc.pO = pCB; + firmwareUpdateProgressListenerAddress_.write( pFunc.pI ); + firmwareUpdateProgressListenerUserDataAddress_.write( pUserData ); + } + } + void unregisterFirmwareUpdateCallback( void ) + { + if( firmwareUpdateProgressListenerAddress_.isValid() && firmwareUpdateProgressListenerUserDataAddress_.isValid() ) + { + firmwareUpdateProgressListenerAddress_.write( 0 ); + firmwareUpdateProgressListenerUserDataAddress_.write( 0 ); + } + } + static int infoCallback( void* pUserData, FirmwareUpdateStatusData* pFwUpdateData, unsigned long int /*fwUpdateDataSize*/ ) + { + if( !pUserData ) + { + return fuaContinue; + } + FirmwareUpdater* pFirmwareUpdater = reinterpret_cast( pUserData ); + pFirmwareUpdater->setTimeElapsed( pFwUpdateData->timeElapsed_s ); + switch ( pFwUpdateData->updateStep ) + { + case fusErasingFlash: + return pFirmwareUpdater->onErasingFlash( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusUpdatingBootProgrammer: + return pFirmwareUpdater->onUpdatingBootProgrammer( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusUnzippingFirmwareArchive: + return pFirmwareUpdater->onUnzippingFirmwareArchive( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusUploadingFirmware: + return pFirmwareUpdater->onUploadingImage( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusRebootingDevice: + return pFirmwareUpdater->onRebooting( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusSavingUserSets: + return pFirmwareUpdater->onSavingUserSets( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusLoadingUserSets: + return pFirmwareUpdater->onLoadingUserSets( pFwUpdateData->progressPercent, pFwUpdateData->timeElapsed_s ); + case fusErrorMessage: + return pFirmwareUpdater->onErrorMessage( pFwUpdateData->timeElapsed_s ); + } + return fuaContinue; + } + + // do not allow assignments + FirmwareUpdater& operator=( const FirmwareUpdater& ); + // do not allow copy construction + FirmwareUpdater( const FirmwareUpdater& src ); + +protected: + void setTimeElapsed( double time_s ) + { + timeElapsed_s_ = time_s; + } +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) +public: + /// \brief Creates a new mvIMPACT::acquire::labs::FirmwareUpdater object. + explicit FirmwareUpdater( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] A boolean value which defines if updates using the same version as installed on the camera should be allowed. + bool boForceOverideSameVersion = false, + /// [in] A boolean value which defines if updates using an older version as installed on the camera should be allowed. + bool boForceDowngrade = false, + /// [in] A boolean value which defines if the user sets of the device will be kept or will be deleted during the update. + bool boKeepUserSets = true, + /// [in] A boolean value which defines if updates to versions which will deliver interface breaking changes will be allowed. Setting this value to \c true will also update a device which after the update + /// might have a different interface. See documentation for additional information about breaking changes in firmware versions(there are not too many)! + bool boForceBreakingChange = false ) : timeElapsed_s_( 0 ) + { + ComponentLocator l( pDev->hDev() ); + l.bindComponent( updateFirmware_, "UpdateFirmware@i" ); + if( !updateFirmware_.isValid() ) + { + if( !pDev->isOpen() ) + { + pDev->open(); + } + DeviceComponentLocator locator( pDev, dltSystemSettings ); + locator.bindComponent( firmwareUpdateKeepUserSets_, "KeepUserSets" ); + locator.bindComponent( firmwareUpdateForceBreakingChange_, "ForceBreakingChange" ); + locator.bindComponent( firmwareUpdateForceOverrideSameVersion_, "ForceOverrideSameVersion" ); + locator.bindComponent( firmwareUpdateForceDowngrade_, "ForceDowngrade" ); + locator.bindComponent( firmwareUpdateFileName_, "FileName" ); + locator.bindComponent( firmwareUpdateStatusMessage_, "UpdateStatusMessage" ); + locator.bindComponent( firmwareUpdateProgressListenerAddress_, "ProgressListenerAddress" ); + locator.bindComponent( firmwareUpdateProgressListenerUserDataAddress_, "ProgressListenerUserDataAddress" ); + locator.bindComponent( updateFirmware_, "UpdateDeviceFirmware@i" ); + } + else + { + l.bindComponent( firmwareVersionToUpload, "FirmwareVersionToUpload" ); + } + + if( firmwareUpdateForceOverrideSameVersion_.isValid() ) + { + firmwareUpdateForceOverrideSameVersion_.write( boForceOverideSameVersion ? bTrue : bFalse ); + } + if( firmwareUpdateForceDowngrade_.isValid() ) + { + firmwareUpdateForceDowngrade_.write( boForceDowngrade ? bTrue : bFalse ); + } + if( firmwareUpdateKeepUserSets_.isValid() ) + { + firmwareUpdateKeepUserSets_.write( boKeepUserSets ? bTrue : bFalse ); + } + if( firmwareUpdateForceBreakingChange_.isValid() ) + { + firmwareUpdateForceBreakingChange_.write( boForceBreakingChange ? bTrue : bFalse ); + } + } + virtual ~FirmwareUpdater() {} + /// \brief This function will be called once a message is waiting to be passed to the user. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onErrorMessage( const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called once the devices flash memory is erased. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * \note Only some device types require this step so this callback might not be called for every device type. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onErasingFlash( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called once firmware archive (*.mvu) is unzipped to provide the correct firmware file. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onUnzippingFirmwareArchive( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called once the boot programmer of an mvBlueFOX3 camera is updated. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * \note + * - Only mvBlueFOX3 cameras require this step so this callback might not be called in case of different device types. + * - BootProgrammer updates won't be necessary often, so this callback will not apply in every firmware update process. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onUpdatingBootProgrammer( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called once the actual firmware file is uploaded to the device's flash memory. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * \note + * - Depending on the device type this step might take a few seconds up to a few minutes. + * - The callback will be called several times during the upload. + * - Each time there was a progress of 5 percent this callback will be called. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onUploadingImage( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called once the device reboots to make sure the new firmware is applied to the device. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onRebooting( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called when the settings of the device are stored before updating the firmware. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * This callback will only be called when user sets shall be available after the update. This can be specified by setting the \b boKeepUserSets flag upon construction of this object. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onSavingUserSets( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief This function will be called when the settings of the device are written back after updating the firmware. + /** + * Re-implement this function in a derived class in order to implement a custom behaviour. + * + * This callback will only be called when user sets shall be available after the update. This can be specified by setting the \b boKeepUserSets flag upon construction of this object. + * + * \return + * - mvIMPACT::acquire::fuaContinue if the current update shall continue. + * - mvIMPACT::acquire::fuaCancel otherwise. + */ + virtual int onLoadingUserSets( const int /*currentProgress_pc*/, const double /*timeElapsed*/ ) const + { + return fuaContinue; + } + /// \brief A function to start the firmware update process. + /** + * This function is intended to be used to update MATRIX VISION devices. + * \note + * The function needs to be called without any additional parameter in case of mvBlueFOX devices. + * + * \return + * - mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type ::TDMR_ERROR otherwise. + */ + TDMR_ERROR update( + /// [in] Path to the file which should be used to update the device. Can be empty if no update archives are needed for the device. + const std::string& archivePath = "" + ) + { + if( !updateFirmware_.isValid() ) + { + return DMR_FEATURE_NOT_AVAILABLE; + } + if( firmwareUpdateFileName_.isValid() ) + { + firmwareUpdateFileName_.writeS( archivePath ); + } + registerFirmwareUpdateCallback( infoCallback, this ); + const TDMR_ERROR returnVal = static_cast( updateFirmware_.call() ); + unregisterFirmwareUpdateCallback(); + return returnVal; + } + /// \brief Returns the current status from the status property + std::string statusMessage( void ) const + { + return firmwareUpdateStatusMessage_.isValid() ? firmwareUpdateStatusMessage_.readS() : "STATUS PROPERTY NOT AVAILABLE"; + } + /// \brief A method to receive the time in seconds since the update process has been started + /** + * \return The time elapsed since the firmware update currently running has been started. + */ + double getTimeElapsed( void ) const + { + return timeElapsed_s_; + } + + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property containing a list of available firmware versions. + /** + * \note + * This feature currently is only available for \b mvBlueFOX devices since here the firmware is part of the driver library. + * So no additional archive is needed, but the desired firmware version to upload into the device's non-volatile memory can + * be selected by writing to this property before calling the \b mvIMPACT::acquire::labs::FirmwareUpdater::update function. + */ + PropertyI firmwareVersionToUpload; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-OFF* +}; + +} // namespace labs + +} // namespace acquire +} // namespace mvIMPACT + +PYTHON_ONLY( ENUM_PROPERTY( PropertyI, EnumPropertyI, int, ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAcquisitionField, EnumPropertyI, TAcquisitionField, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAcquisitionMode, EnumPropertyI, TAcquisitionMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAcquisitionStartStopBehaviour, EnumPropertyI, TAcquisitionStartStopBehaviour, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAoiMode, EnumPropertyI, TAoiMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAutoControlSpeed, EnumPropertyI, TAutoControlSpeed, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAutoControlMode, EnumPropertyI, TAutoControlMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAutoExposureControl, EnumPropertyI, TAutoExposureControl, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAutoGainControl, EnumPropertyI, TAutoGainControl, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIAutoOffsetCalibration, EnumPropertyI, TAutoOffsetCalibration, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBayerConversionMode, EnumPropertyI, TBayerConversionMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBayerMosaicParity, EnumPropertyI, TBayerMosaicParity, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBayerWhiteBalanceResult, EnumPropertyI, TBayerWhiteBalanceResult, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBlueFOXDigitalInputThreshold, EnumPropertyI, TBlueFOXDigitalInputThreshold, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBlueFOXFooterMode, EnumPropertyI, TBlueFOXFooterMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBlueFOXInfoSensorCapabilities, EnumPropertyI, TBlueFOXInfoSensorCapabilities, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBlueFOXOffsetAutoBlackSpeed, EnumPropertyI, TBlueFOXOffsetAutoBlackSpeed, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBlueFOXSensorTiming, EnumPropertyI, TBlueFOXSensorTiming, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBlueFOXTransferSize, EnumPropertyI, TBlueFOXTransferSize, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIBoolean, EnumPropertyI, TBoolean, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraAoiMode, EnumPropertyI, TCameraAoiMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraBinningMode, EnumPropertyI, TCameraBinningMode, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraDataFormat, EnumPropertyI, TCameraDataFormat, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraExposeMode, EnumPropertyI, TCameraExposeMode, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraExternalSyncEdge, EnumPropertyI, TCameraExternalSyncEdge, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraExternalSyncOutput, EnumPropertyI, TCameraExternalSyncOutput, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraFlashMode, EnumPropertyI, TCameraFlashMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraFlashType, EnumPropertyI, TCameraFlashType, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraHDRMode, EnumPropertyI, TCameraHDRMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraInterlacedType, EnumPropertyI, TCameraInterlacedType, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraLinkDataValidMode, EnumPropertyI, TCameraLinkDataValidMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraOutput, EnumPropertyI, TCameraOutput, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraPixelClock, EnumPropertyI, TCameraPixelClock, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraScanMode, EnumPropertyI, TCameraScanMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraSerialPortBaudRate, EnumPropertyI, TCameraSerialPortBaudRate, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraShutterMode, EnumPropertyI, TCameraShutterMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraTapsXGeometry, EnumPropertyI, TCameraTapsXGeometry, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraTapsYGeometry, EnumPropertyI, TCameraTapsYGeometry, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraTestMode, EnumPropertyI, TCameraTestMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraTriggerMode, EnumPropertyI, TCameraTriggerMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyICameraTriggerSource, EnumPropertyI, TCameraTriggerSource, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIChannelSplitMode, EnumPropertyI, TChannelSplitMode, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIClampMode, EnumPropertyI, TClampMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIColorTwistInputCorrectionMatrixMode, EnumPropertyI, TColorTwistInputCorrectionMatrixMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIColorTwistOutputCorrectionMatrixMode, EnumPropertyI, TColorTwistOutputCorrectionMatrixMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIColorProcessingMode, EnumPropertyI, TColorProcessingMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDarkCurrentFilterMode, EnumPropertyI, TDarkCurrentFilterMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDefectivePixelsFilterMode, EnumPropertyI, TDefectivePixelsFilterMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceAccessMode, EnumPropertyI, TDeviceAccessMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceAdvancedOptions, EnumPropertyI, TDeviceAdvancedOptions, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceCapability, EnumPropertyI, TDeviceCapability, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceClass, EnumPropertyI, TDeviceClass, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceDigitalOutputMode, EnumPropertyI, TDeviceDigitalOutputMode, mvIMPACT::acquire:: ) ) +//PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceEventMode, EnumPropertyI, TDeviceEventMode, mvIMPACT::acquire:: ) ) // deprecated! +//PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceEventType, EnumPropertyI, TDeviceEventType, mvIMPACT::acquire:: ) ) // deprecated! + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceImageTrigger, EnumPropertyI, TDeviceImageTrigger, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceInterfaceLayout, EnumPropertyI, TDeviceInterfaceLayout, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceLoadSettings, EnumPropertyI, TDeviceLoadSettings, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDevicePowerMode, EnumPropertyI, TDevicePowerMode, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceScanRateMode, EnumPropertyI, TDeviceScanRateMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceSignalOutputStartEvent, EnumPropertyI, TDeviceSignalOutputStartEvent, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceState, EnumPropertyI, TDeviceState, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceSyncOutMode, EnumPropertyI, TDeviceSyncOutMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceTriggerInterface, EnumPropertyI, TDeviceTriggerInterface, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDeviceTriggerMode, EnumPropertyI, TDeviceTriggerMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDigIOState, EnumPropertyI, TDigIOState, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDigitalIOMeasurementMode, EnumPropertyI, TDigitalIOMeasurementMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDigitalIOMeasurementSource, EnumPropertyI, TDigitalIOMeasurementSource, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDigitalOutputControlMode, EnumPropertyI, TDigitalOutputControlMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIDigitalSignal, EnumPropertyI, TDigitalSignal, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIFieldGateMode, EnumPropertyI, TFieldGateMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIFlatFieldFilterCorrectionMode, EnumPropertyI, TFlatFieldFilterCorrectionMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIFlatFieldFilterMode, EnumPropertyI, TFlatFieldFilterMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIHWUpdateResult, EnumPropertyI, THWUpdateResult, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyII2COperationMode, EnumPropertyI, TI2COperationMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyII2COperationStatus, EnumPropertyI, TI2COperationStatus, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageBufferPixelFormat, EnumPropertyI, TImageBufferPixelFormat, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageBufferFormatReinterpreterMode, EnumPropertyI, TImageBufferFormatReinterpreterMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageDestinationPixelFormat, EnumPropertyI, TImageDestinationPixelFormat, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageProcessingFilter, EnumPropertyI, TImageProcessingFilter, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageProcessingMode, EnumPropertyI, TImageProcessingMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageProcessingOptimization, EnumPropertyI, TImageProcessingOptimization, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageProcessingResult, EnumPropertyI, TImageProcessingResult, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIRequestImageMemoryMode, EnumPropertyI, TRequestImageMemoryMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIImageRequestControlMode, EnumPropertyI, TImageRequestControlMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIInfoSensorColorMode, EnumPropertyI, TInfoSensorColorMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIInfoSensorType, EnumPropertyI, TInfoSensorType, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIInterfaceEnumerationBehaviour, EnumPropertyI, TInterfaceEnumerationBehaviour, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIInterlacedMode, EnumPropertyI, TInterlacedMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyILineCounter, EnumPropertyI, TLineCounter, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyILUTGammaMode, EnumPropertyI, TLUTGammaMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyILUTImplementation, EnumPropertyI, TLUTImplementation, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyILUTInterpolationMode, EnumPropertyI, TLUTInterpolationMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyILUTMapping, EnumPropertyI, TLUTMapping, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyILUTMode, EnumPropertyI, TLUTMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIMemoryManagerMode, EnumPropertyI, TMemoryManagerMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIMemoryManagerPoolMode, EnumPropertyI, TMemoryManagerPoolMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIMirrorMode, EnumPropertyI, TMirrorMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIMirrorOperationMode, EnumPropertyI, TMirrorOperationMode, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIOnBoardMemoryMode, EnumPropertyI, TOnBoardMemoryMode, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIPolarizedDataExtractionMode, EnumPropertyI, TPolarizedDataExtractionMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIPolarizedDataExtractionInterpolationMode, EnumPropertyI, TPolarizedDataExtractionInterpolationMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIPulseStartTrigger, EnumPropertyI, TPulseStartTrigger, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIRequestResult, EnumPropertyI, TRequestResult, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIRequestState, EnumPropertyI, TRequestState, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIRTCtrlModes, EnumPropertyI, TRTCtrlModes, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIRTProgOpCodes, EnumPropertyI, TRTProgOpCodes, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIScalerMode, EnumPropertyI, TScalerMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIScalerInterpolationMode, EnumPropertyI, TScalerInterpolationMode, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIScanClock, EnumPropertyI, TScanClock, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIScanStandard, EnumPropertyI, TScanStandard, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyITriggerMoment, EnumPropertyI, TTriggerMoment, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIUserDataAccessRight, EnumPropertyI, TUserDataAccessRight, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIUserDataReconnectBehaviour, EnumPropertyI, TUserDataReconnectBehaviour, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyIVideoStandard, EnumPropertyI, TVideoStandard, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyIVirtualDeviceImageType, EnumPropertyI, TVirtualDeviceImageType, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIVirtualDeviceTestMode, EnumPropertyI, TVirtualDeviceTestMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIWhiteBalanceCalibrationMode, EnumPropertyI, TWhiteBalanceCalibrationMode, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyIWhiteBalanceParameter, EnumPropertyI, TWhiteBalanceParameter, mvIMPACT::acquire:: ) ) + +PYTHON_ONLY( ENUM_PROPERTY( PropertyI64, EnumPropertyI64, int64_type, mvIMPACT::acquire:: ) ) +PYTHON_ONLY( ENUM_PROPERTY( PropertyI64BufferPartDataType, EnumPropertyI64, TBufferPartDataType, mvIMPACT::acquire:: ) ) + +#ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION +PYTHON_ONLY( ENUM_PROPERTY( PropertyI64DeviceTriggerOverlap, EnumPropertyI64, TDeviceTriggerOverlap, mvIMPACT::acquire:: ) ) +#endif // #ifndef IGNORE_MVGRABBER_SPECIFIC_DOCUMENTATION + +PYTHON_ONLY( ENUM_PROPERTY( PropertyF, EnumPropertyF, double, ) ) + +// restore Borland compiler switch 'force enums to the size of integer' +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ +# pragma option pop +# endif // #ifdef __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifndef MVIMPACT_USE_NAMESPACES +using namespace mvIMPACT::acquire; +# endif // #ifndef MVIMPACT_USE_NAMESPACES +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#ifdef _MSC_VER // is Microsoft compiler? +// restore old warning level +# pragma warning( pop ) +#endif // #ifdef _MSC_VER + +#endif // MVIMPACT_ACQUIRE_H_ diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam.h b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam.h new file mode 100644 index 0000000..d8ed61b --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam.h @@ -0,0 +1,18417 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvIMPACT_acquire_GenICam_CPP_autogen_h +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvIMPACT_acquire_GenICam_CPP_autogen_h mvIMPACT_acquire_GenICam_CPP_autogen_h +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +// AUTOMATICALLY GENERATED CODE. DO NOT EDIT!!! + +#include + +#ifdef _MSC_VER // is Microsoft compiler? +# pragma warning( push ) +# if _MSC_VER < 1300 // is 'old' VC 6 compiler? +# pragma warning( disable : 4786 ) // 'identifier was truncated to '255' characters in the debug information' +# define __FUNCTION__ "No function name information as the __FUNCTION__ macro is not supported by this(VC 6) compiler" +# pragma message( "WARNING: This header(" __FILE__ ") uses the __FUNCTION__ macro, which is not supported by this compiler. A default definition(\"" __FUNCTION__ "\") will be used!" ) +# pragma message( "WARNING: This header(" __FILE__ ") uses inheritance for exception classes. However this compiler can't handle this correctly. Trying to catch a specific exception by writing a catch block for a base class will not work!" ) +# endif // #if _MSC_VER < 1300 +# pragma warning( disable : 4512 ) // 'assignment operator could not be generated' (reason: assignment operators declared 'private' but not implemented) +#endif // #ifdef _MSC_VER + +namespace mvIMPACT +{ +namespace acquire +{ +namespace GenICam +{ + +/// \defgroup GenICamInterface GenICam interface layout +/// \brief Classes and functions that will be available if the device is used +/// with the \a GenICam interface layout. +/** + * This group contains classes and functions that will be available if the device is used + * with the mvIMPACT::acquire::dilGenICam interface layout. + */ + +/** \defgroup GenICamInterfaceDevice GenICam interface layout(device) + * \brief Classes and functions that will be available if the device is used + * with the \a GenICam interface layout. + * + * This group contains classes and functions that will be available for a device used + * with the mvIMPACT::acquire::dilGenICam interface layout. + * + * \ingroup GenICamInterface + */ + +/** \defgroup GenICamInterfaceProducer GenICam interface layout(producer) + * \brief Classes and functions that will be available if the device is used + * with the \a GenICam interface layout. + * + * This group contains classes and functions that will be available for a \a GenICam \a GenTL \a producer + * + * \ingroup GenICamInterface + */ + +//----------------------------------------------------------------------------- +/// \brief Category for device information and control. +/** + * A category for device information and control. + * \ingroup GenICamInterfaceDevice + */ +class DeviceControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::DeviceControl object. + explicit DeviceControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + deviceType(), + deviceScanType(), + deviceVendorName(), + deviceModelName(), + deviceFamilyName(), + deviceManufacturerInfo(), + deviceVersion(), + deviceFirmwareVersion(), + mvDeviceFirmwareBuildDate(), + deviceSerialNumber(), + deviceID(), + deviceUserID(), + deviceSFNCVersionMajor(), + deviceSFNCVersionMinor(), + deviceSFNCVersionSubMinor(), + deviceManifestEntrySelector(), + deviceManifestXMLMajorVersion(), + deviceManifestXMLMinorVersion(), + deviceManifestXMLSubMinorVersion(), + deviceManifestSchemaMajorVersion(), + deviceManifestSchemaMinorVersion(), + deviceManifestPrimaryURL(), + deviceManifestSecondaryURL(), + deviceTLType(), + deviceTLVersionMajor(), + deviceTLVersionMinor(), + deviceTLVersionSubMinor(), + deviceGenCPVersionMajor(), + deviceGenCPVersionMinor(), + deviceMaxThroughput(), + deviceConnectionSelector(), + deviceConnectionSpeed(), + deviceConnectionStatus(), + deviceLinkSelector(), + deviceLinkSpeed(), + deviceLinkThroughputLimitMode(), + deviceLinkThroughputLimit(), + deviceLinkConnectionCount(), + deviceLinkHeartbeatMode(), + deviceLinkHeartbeatTimeout(), + deviceLinkCommandTimeout(), + deviceStreamChannelCount(), + deviceStreamChannelSelector(), + deviceStreamChannelType(), + deviceStreamChannelLink(), + deviceStreamChannelEndianness(), + deviceStreamChannelPacketSize(), + deviceEventChannelCount(), + deviceMessageChannelCount(), + deviceCharacterSet(), + deviceReset(), + deviceIndicatorMode(), + deviceFeaturePersistenceStart(), + deviceFeaturePersistenceEnd(), + deviceRegistersStreamingStart(), + deviceRegistersStreamingEnd(), + deviceRegistersCheck(), + deviceRegistersValid(), + mvDeviceRegistersStatus(), + deviceRegistersEndianness(), + deviceTemperatureSelector(), + deviceTemperature(), + deviceClockSelector(), + deviceClockFrequency(), + deviceSerialPortSelector(), + deviceSerialPortBaudRate(), + timestamp(), + timestampReset(), + timestampLatch(), + timestampLatchValue(), + mvDeviceTemperatureRaw(), + mvDeviceTemperatureUpperLimit(), + mvDeviceTemperatureLowerLimit(), + mvDeviceTemperatureLimitHysteresis(), + mvDeviceClockFrequency(), + mvDeviceSensorColorMode(), + mvDeviceFPGAVersion(), + mvDeviceFirmwareSource(), + mvDeviceProcessingUnitSelector(), + mvDeviceProcessingUnit(), + mvDeviceStatusLEDEnable(), + mvDevicePowerMode(), + mvDeviceStandbyTimeoutEnable(), + mvDeviceStandbyTimeout(), + mvDeviceFirmwareHashCode(), + mvCalculateHashCode(), + mvDeviceFirmwareHashAlgorithm(), + mvDeviceLaserCurrent(), + mvTimestampPPSSync(), + mvTimestampPPSTriggerEdge(), + mvTimestampPPSPulsesMissed(), + mvTimestampPPSStatus(), + mvTimestampResetValue(), + mvTemperatureState(), + mvTemperatureStateCriticalThreshold() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( deviceType, "DeviceType" ); + if( !deviceType.isValid() ) + { + locator.bindComponent( deviceType, "GevDeviceClass" ); + } + locator.bindComponent( deviceScanType, "DeviceScanType" ); + locator.bindComponent( deviceVendorName, "DeviceVendorName" ); + locator.bindComponent( deviceModelName, "DeviceModelName" ); + locator.bindComponent( deviceFamilyName, "DeviceFamilyName" ); + locator.bindComponent( deviceManufacturerInfo, "DeviceManufacturerInfo" ); + locator.bindComponent( deviceVersion, "DeviceVersion" ); + locator.bindComponent( deviceFirmwareVersion, "DeviceFirmwareVersion" ); + locator.bindComponent( mvDeviceFirmwareBuildDate, "mvDeviceFirmwareBuildDate" ); + locator.bindComponent( deviceSerialNumber, "DeviceSerialNumber" ); + if( !deviceSerialNumber.isValid() ) + { + locator.bindComponent( deviceSerialNumber, "DeviceID" ); + } + locator.bindComponent( deviceID, "DeviceID" ); + locator.bindComponent( deviceUserID, "DeviceUserID" ); + locator.bindComponent( deviceSFNCVersionMajor, "DeviceSFNCVersionMajor" ); + locator.bindComponent( deviceSFNCVersionMinor, "DeviceSFNCVersionMinor" ); + locator.bindComponent( deviceSFNCVersionSubMinor, "DeviceSFNCVersionSubMinor" ); + locator.bindComponent( deviceManifestEntrySelector, "DeviceManifestEntrySelector" ); + locator.bindComponent( deviceManifestXMLMajorVersion, "DeviceManifestXMLMajorVersion" ); + locator.bindComponent( deviceManifestXMLMinorVersion, "DeviceManifestXMLMinorVersion" ); + locator.bindComponent( deviceManifestXMLSubMinorVersion, "DeviceManifestXMLSubMinorVersion" ); + locator.bindComponent( deviceManifestSchemaMajorVersion, "DeviceManifestSchemaMajorVersion" ); + locator.bindComponent( deviceManifestSchemaMinorVersion, "DeviceManifestSchemaMinorVersion" ); + locator.bindComponent( deviceManifestPrimaryURL, "DeviceManifestPrimaryURL" ); + locator.bindComponent( deviceManifestSecondaryURL, "DeviceManifestSecondaryURL" ); + locator.bindComponent( deviceTLType, "DeviceTLType" ); + locator.bindComponent( deviceTLVersionMajor, "DeviceTLVersionMajor" ); + if( !deviceTLVersionMajor.isValid() ) + { + locator.bindComponent( deviceTLVersionMajor, "GevVersionMajor" ); + } + locator.bindComponent( deviceTLVersionMinor, "DeviceTLVersionMinor" ); + if( !deviceTLVersionMinor.isValid() ) + { + locator.bindComponent( deviceTLVersionMinor, "GevVersionMinor" ); + } + locator.bindComponent( deviceTLVersionSubMinor, "DeviceTLVersionSubMinor" ); + locator.bindComponent( deviceGenCPVersionMajor, "DeviceGenCPVersionMajor" ); + locator.bindComponent( deviceGenCPVersionMinor, "DeviceGenCPVersionMinor" ); + locator.bindComponent( deviceMaxThroughput, "DeviceMaxThroughput" ); + locator.bindComponent( deviceConnectionSelector, "DeviceConnectionSelector" ); + locator.bindComponent( deviceConnectionSpeed, "DeviceConnectionSpeed" ); + locator.bindComponent( deviceConnectionStatus, "DeviceConnectionStatus" ); + locator.bindComponent( deviceLinkSelector, "DeviceLinkSelector" ); + locator.bindComponent( deviceLinkSpeed, "DeviceLinkSpeed" ); + locator.bindComponent( deviceLinkThroughputLimitMode, "DeviceLinkThroughputLimitMode" ); + locator.bindComponent( deviceLinkThroughputLimit, "DeviceLinkThroughputLimit" ); + locator.bindComponent( deviceLinkConnectionCount, "DeviceLinkConnectionCount" ); + locator.bindComponent( deviceLinkHeartbeatMode, "DeviceLinkHeartbeatMode" ); + locator.bindComponent( deviceLinkHeartbeatTimeout, "DeviceLinkHeartbeatTimeout" ); + if( !deviceLinkHeartbeatTimeout.isValid() ) + { + locator.bindComponent( deviceLinkHeartbeatTimeout, "GevHeartbeatTimeout" ); + } + locator.bindComponent( deviceLinkCommandTimeout, "DeviceLinkCommandTimeout" ); + locator.bindComponent( deviceStreamChannelCount, "DeviceStreamChannelCount" ); + if( !deviceStreamChannelCount.isValid() ) + { + locator.bindComponent( deviceStreamChannelCount, "GevStreamChannelCount" ); + } + locator.bindComponent( deviceStreamChannelSelector, "DeviceStreamChannelSelector" ); + locator.bindComponent( deviceStreamChannelType, "DeviceStreamChannelType" ); + locator.bindComponent( deviceStreamChannelLink, "DeviceStreamChannelLink" ); + locator.bindComponent( deviceStreamChannelEndianness, "DeviceStreamChannelEndianness" ); + locator.bindComponent( deviceStreamChannelPacketSize, "DeviceStreamChannelPacketSize" ); + locator.bindComponent( deviceEventChannelCount, "DeviceEventChannelCount" ); + if( !deviceEventChannelCount.isValid() ) + { + locator.bindComponent( deviceEventChannelCount, "GevMessageChannelCount" ); + } + locator.bindComponent( deviceMessageChannelCount, "DeviceMessageChannelCount" ); + if( !deviceMessageChannelCount.isValid() ) + { + locator.bindComponent( deviceMessageChannelCount, "GevMessageChannelCount" ); + } + locator.bindComponent( deviceCharacterSet, "DeviceCharacterSet" ); + if( !deviceCharacterSet.isValid() ) + { + locator.bindComponent( deviceCharacterSet, "GevDeviceModeCharacterSet" ); + } + locator.bindComponent( deviceReset, "DeviceReset@i" ); + locator.bindComponent( deviceIndicatorMode, "DeviceIndicatorMode" ); + locator.bindComponent( deviceFeaturePersistenceStart, "DeviceFeaturePersistenceStart@i" ); + locator.bindComponent( deviceFeaturePersistenceEnd, "DeviceFeaturePersistenceEnd@i" ); + locator.bindComponent( deviceRegistersStreamingStart, "DeviceRegistersStreamingStart@i" ); + locator.bindComponent( deviceRegistersStreamingEnd, "DeviceRegistersStreamingEnd@i" ); + locator.bindComponent( deviceRegistersCheck, "DeviceRegistersCheck@i" ); + locator.bindComponent( deviceRegistersValid, "DeviceRegistersValid" ); + locator.bindComponent( mvDeviceRegistersStatus, "mvDeviceRegistersStatus" ); + locator.bindComponent( deviceRegistersEndianness, "DeviceRegistersEndianness" ); + if( !deviceRegistersEndianness.isValid() ) + { + locator.bindComponent( deviceRegistersEndianness, "GevDeviceModeIsBigEndian" ); + } + locator.bindComponent( deviceTemperatureSelector, "DeviceTemperatureSelector" ); + locator.bindComponent( deviceTemperature, "DeviceTemperature" ); + locator.bindComponent( deviceClockSelector, "DeviceClockSelector" ); + locator.bindComponent( deviceClockFrequency, "DeviceClockFrequency" ); + locator.bindComponent( deviceSerialPortSelector, "DeviceSerialPortSelector" ); + locator.bindComponent( deviceSerialPortBaudRate, "DeviceSerialPortBaudRate" ); + locator.bindComponent( timestamp, "Timestamp" ); + locator.bindComponent( timestampReset, "TimestampReset@i" ); + if( !timestampReset.isValid() ) + { + locator.bindComponent( timestampReset, "GevTimestampControlReset@i" ); + } + locator.bindComponent( timestampLatch, "TimestampLatch@i" ); + if( !timestampLatch.isValid() ) + { + locator.bindComponent( timestampLatch, "GevTimestampControlLatch@i" ); + } + locator.bindComponent( timestampLatchValue, "TimestampLatchValue" ); + if( !timestampLatchValue.isValid() ) + { + locator.bindComponent( timestampLatchValue, "GevTimestampValue" ); + } + locator.bindComponent( mvDeviceTemperatureRaw, "mvDeviceTemperatureRaw" ); + locator.bindComponent( mvDeviceTemperatureUpperLimit, "mvDeviceTemperatureUpperLimit" ); + locator.bindComponent( mvDeviceTemperatureLowerLimit, "mvDeviceTemperatureLowerLimit" ); + locator.bindComponent( mvDeviceTemperatureLimitHysteresis, "mvDeviceTemperatureLimitHysteresis" ); + locator.bindComponent( mvDeviceClockFrequency, "mvDeviceClockFrequency" ); + locator.bindComponent( mvDeviceSensorColorMode, "mvDeviceSensorColorMode" ); + locator.bindComponent( mvDeviceFPGAVersion, "mvDeviceFPGAVersion" ); + locator.bindComponent( mvDeviceFirmwareSource, "mvDeviceFirmwareSource" ); + if( !mvDeviceFirmwareSource.isValid() ) + { + locator.bindComponent( mvDeviceFirmwareSource, "FirmwareSource" ); + } + locator.bindComponent( mvDeviceProcessingUnitSelector, "mvDeviceProcessingUnitSelector" ); + locator.bindComponent( mvDeviceProcessingUnit, "mvDeviceProcessingUnit" ); + locator.bindComponent( mvDeviceStatusLEDEnable, "mvDeviceStatusLEDEnable" ); + locator.bindComponent( mvDevicePowerMode, "mvDevicePowerMode" ); + locator.bindComponent( mvDeviceStandbyTimeoutEnable, "mvDeviceStandbyTimeoutEnable" ); + locator.bindComponent( mvDeviceStandbyTimeout, "mvDeviceStandbyTimeout" ); + locator.bindComponent( mvDeviceFirmwareHashCode, "mvDeviceFirmwareHashCode" ); + locator.bindComponent( mvCalculateHashCode, "mvCalculateHashCode@i" ); + locator.bindComponent( mvDeviceFirmwareHashAlgorithm, "mvDeviceFirmwareHashAlgorithm" ); + locator.bindComponent( mvDeviceLaserCurrent, "mvDeviceLaserCurrent" ); + locator.bindComponent( mvTimestampPPSSync, "mvTimestampPPSSync" ); + if( !mvTimestampPPSSync.isValid() ) + { + locator.bindComponent( mvTimestampPPSSync, "mvGevTimestampPPSSync" ); + } + locator.bindComponent( mvTimestampPPSTriggerEdge, "mvTimestampPPSTriggerEdge" ); + locator.bindComponent( mvTimestampPPSPulsesMissed, "mvTimestampPPSPulsesMissed" ); + locator.bindComponent( mvTimestampPPSStatus, "mvTimestampPPSStatus" ); + locator.bindComponent( mvTimestampResetValue, "mvTimestampResetValue" ); + locator.bindComponent( mvTemperatureState, "mvTemperatureState" ); + locator.bindComponent( mvTemperatureStateCriticalThreshold, "mvTemperatureStateCriticalThreshold" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Returns the device type. + /** + * Returns the device type. + * + * The following string values might be valid for this feature: + * - \b Transmitter (Display string: 'Transmitter'): Data stream transmitter device. + * - \b Receiver (Display string: 'Receiver'): Data stream receiver device. + * - \b Transceiver (Display string: 'Transceiver'): Data stream receiver and transmitter device. + * - \b Peripheral (Display string: 'Peripheral'): Controllable device (with no data stream handling). + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is a device for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is a device for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is a device for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is a device for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is a device for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is a device for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is a device for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceType; + /// \brief An enumerated integer property. Scan type of the sensor of the device. + /** + * Scan type of the sensor of the device. + * + * The following string values might be valid for this feature: + * - \b Areascan (Display string: 'Areascan'): 2D sensor. + * - \b Linescan (Display string: 'Linescan'): 1D sensor. + * - \b Areascan3D (Display string: 'Areascan 3D'): device outputs 2D range image. + * - \b Linescan3D (Display string: 'Linescan 3D'): device outputs 1D range image. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceScanType; + /// \brief A string property. Name of the manufacturer of the device. + /** + * Name of the manufacturer of the device. + */ + PropertyS deviceVendorName; + /// \brief A string property. Model of the device. + /** + * Model of the device. + */ + PropertyS deviceModelName; + /// \brief A string property. Identifier of the product family of the device. + /** + * Identifier of the product family of the device. + */ + PropertyS deviceFamilyName; + /// \brief A string property. Manufacturer information about the device. + /** + * Manufacturer information about the device. + */ + PropertyS deviceManufacturerInfo; + /// \brief A string property. Version of the device. + /** + * Version of the device. + */ + PropertyS deviceVersion; + /// \brief A string property. Version of the firmware in the device. + /** + * Version of the firmware in the device. + */ + PropertyS deviceFirmwareVersion; + /// \brief A string property. The build time and date of the firmware + /** + * The build time and date of the firmware + */ + PropertyS mvDeviceFirmwareBuildDate; + /// \brief A string property. Device's serial number. + /** + * Device's serial number. This string is a unique identifier of the device. + */ + PropertyS deviceSerialNumber; + /// \brief A string property. This feature is deprecated (See DeviceSerialNumber). + /** + * \deprecated + * This feature is deprecated (See DeviceSerialNumber). It was representing the Device unique identifier (serial number). + */ + PropertyS deviceID; + /// \brief A string property. User-programmable device identifier. + /** + * User-programmable device identifier. + */ + PropertyS deviceUserID; + /// \brief An integer property. Major version of the Standard Features Naming Convention that was used to create the device's GenICam XML. + /** + * Major version of the Standard Features Naming Convention that was used to create the device's GenICam XML. + */ + PropertyI64 deviceSFNCVersionMajor; + /// \brief An integer property. Minor version of the Standard Features Naming Convention that was used to create the device's GenICam XML. + /** + * Minor version of the Standard Features Naming Convention that was used to create the device's GenICam XML. + */ + PropertyI64 deviceSFNCVersionMinor; + /// \brief An integer property. Sub minor version of Standard Features Naming Convention that was used to create the device's GenICam XML. + /** + * Sub minor version of Standard Features Naming Convention that was used to create the device's GenICam XML. + */ + PropertyI64 deviceSFNCVersionSubMinor; + /// \brief An integer property. Selects the manifest entry to reference. + /** + * Selects the manifest entry to reference. + */ + PropertyI64 deviceManifestEntrySelector; + /// \brief An integer property. Indicates the major version number of the GenICam XML file of the selected manifest entry. + /** + * Indicates the major version number of the GenICam XML file of the selected manifest entry. + */ + PropertyI64 deviceManifestXMLMajorVersion; + /// \brief An integer property. Indicates the minor version number of the GenICam XML file of the selected manifest entry. + /** + * Indicates the minor version number of the GenICam XML file of the selected manifest entry. + */ + PropertyI64 deviceManifestXMLMinorVersion; + /// \brief An integer property. Indicates the subminor version number of the GenICam XML file of the selected manifest entry. + /** + * Indicates the subminor version number of the GenICam XML file of the selected manifest entry. + */ + PropertyI64 deviceManifestXMLSubMinorVersion; + /// \brief An integer property. Indicates the major version number of the schema file of the selected manifest entry. + /** + * Indicates the major version number of the schema file of the selected manifest entry. + */ + PropertyI64 deviceManifestSchemaMajorVersion; + /// \brief An integer property. Indicates the minor version number of the schema file of the selected manifest entry. + /** + * Indicates the minor version number of the schema file of the selected manifest entry. + */ + PropertyI64 deviceManifestSchemaMinorVersion; + /// \brief A string property. Indicates the first URL to the GenICam XML device description file of the selected manifest entry. + /** + * Indicates the first URL to the GenICam XML device description file of the selected manifest entry. + */ + PropertyS deviceManifestPrimaryURL; + /// \brief A string property. Indicates the second URL to the GenICam XML device description file of the selected manifest entry. + /** + * Indicates the second URL to the GenICam XML device description file of the selected manifest entry. + */ + PropertyS deviceManifestSecondaryURL; + /// \brief An enumerated integer property. Transport Layer type of the device. + /** + * Transport Layer type of the device. + * + * The following string values might be valid for this feature: + * - \b GigEVision (Display string: 'GigE Vision'): GigE Vision. + * - \b CameraLink (Display string: 'Camera Link'): Camera Link. + * - \b CameraLinkHS (Display string: 'Camera Link HS'): Camera Link High Speed. + * - \b CoaXPress (Display string: 'CoaXPress'): CoaXPress. + * - \b USB3Vision (Display string: 'USB3 Vision'): USB3 Vision. + * - \b Custom (Display string: 'Custom'): Custom Transport Layer. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceTLType; + /// \brief An integer property. Major version of the Transport Layer of the device. + /** + * Major version of the Transport Layer of the device. + */ + PropertyI64 deviceTLVersionMajor; + /// \brief An integer property. Minor version of the Transport Layer of the device. + /** + * Minor version of the Transport Layer of the device. + */ + PropertyI64 deviceTLVersionMinor; + /// \brief An integer property. Sub minor version of the Transport Layer of the device. + /** + * Sub minor version of the Transport Layer of the device. + */ + PropertyI64 deviceTLVersionSubMinor; + /// \brief An integer property. Major version of the GenCP protocol supported by the device. + /** + * Major version of the GenCP protocol supported by the device. + */ + PropertyI64 deviceGenCPVersionMajor; + /// \brief An integer property. Minor version of the GenCP protocol supported by the device. + /** + * Minor version of the GenCP protocol supported by the device. + */ + PropertyI64 deviceGenCPVersionMinor; + /// \brief An integer property. Maximum bandwidth of the data that can be streamed out of the device. + /** + * Maximum bandwidth of the data that can be streamed out of the device. This can be used to estimate if the physical connection(s) can sustain transfer of free-running images from the camera at its maximum speed. + */ + PropertyI64 deviceMaxThroughput; + /// \brief An integer property. Selects which Connection of the device to control. + /** + * Selects which Connection of the device to control. + */ + PropertyI64 deviceConnectionSelector; + /// \brief An integer property. Indicates the speed of transmission of the specified Connection. + /** + * Indicates the speed of transmission of the specified Connection + */ + PropertyI64 deviceConnectionSpeed; + /// \brief An enumerated integer property. Indicates the status of the specified Connection. + /** + * Indicates the status of the specified Connection. + * + * The following string values might be valid for this feature: + * - \b Active (Display string: 'Active'): Connection is in use. + * - \b Inactive (Display string: 'Inactive'): Connection is not in use. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceConnectionStatus; + /// \brief An integer property. Selects which Link of the device to control. + /** + * Selects which Link of the device to control. + */ + PropertyI64 deviceLinkSelector; + /// \brief An integer property. Indicates the speed of transmission negotiated on the specified Link. + /** + * Indicates the speed of transmission negotiated on the specified Link. + */ + PropertyI64 deviceLinkSpeed; + /// \brief An enumerated integer property. Controls if the DeviceLinkThroughputLimit is active. + /** + * Controls if the DeviceLinkThroughputLimit is active. When disabled, lower level TL specific features are expected to control the throughput. When enabled, DeviceLinkThroughputLimit controls the overall throughput. + * + * The following string values might be valid for this feature: + * - \b On (Display string: 'On'): Enables the DeviceLinkThroughputLimit feature. + * - \b Off (Display string: 'Off'): Disables the DeviceLinkThroughputLimit feature. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceLinkThroughputLimitMode; + /// \brief An integer property. Limits the maximum bandwidth of the data that will be streamed out by the device on the selected Link. + /** + * Limits the maximum bandwidth of the data that will be streamed out by the device on the selected Link. If necessary, delays will be uniformly inserted between transport layer packets in order to control the peak bandwidth. + */ + PropertyI64 deviceLinkThroughputLimit; + /// \brief An integer property. Returns the number of physical connection of the device used by a particular Link. + /** + * Returns the number of physical connection of the device used by a particular Link. + */ + PropertyI64 deviceLinkConnectionCount; + /// \brief An enumerated integer property. Activate or deactivate the Link's heartbeat. + /** + * Activate or deactivate the Link's heartbeat. + * + * The following string values might be valid for this feature: + * - \b On (Display string: 'On'): Enables the Link heartbeat. + * - \b Off (Display string: 'Off'): Disables the Link heartbeat. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceLinkHeartbeatMode; + /// \brief A floating point property. Controls the current heartbeat timeout of the specific Link. + /** + * Controls the current heartbeat timeout of the specific Link. + */ + PropertyF deviceLinkHeartbeatTimeout; + /// \brief A floating point property. Indicates the command timeout of the specified Link. + /** + * Indicates the command timeout of the specified Link. This corresponds to the maximum response time of the device for a command sent on that link. + */ + PropertyF deviceLinkCommandTimeout; + /// \brief An integer property. Indicates the number of streaming channels supported by the device. + /** + * Indicates the number of streaming channels supported by the device. + */ + PropertyI64 deviceStreamChannelCount; + /// \brief An integer property. Selects the stream channel to control. + /** + * Selects the stream channel to control. + */ + PropertyI64 deviceStreamChannelSelector; + /// \brief An enumerated integer property. Reports the type of the stream channel. + /** + * Reports the type of the stream channel. + * + * The following string values might be valid for this feature: + * - \b Transmitter (Display string: 'Transmitter'): Data stream transmitter channel. + * - \b Receiver (Display string: 'Receiver'): Data stream receiver channel. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceStreamChannelType; + /// \brief An integer property. Index of device's Link to use for streaming the specified stream channel. + /** + * Index of device's Link to use for streaming the specified stream channel. + */ + PropertyI64 deviceStreamChannelLink; + /// \brief An enumerated integer property. Endianness of multi-byte pixel data for this stream. + /** + * Endianness of multi-byte pixel data for this stream. + * + * The following string values might be valid for this feature: + * - \b Big (Display string: 'Big'): Stream channel data is big Endian. + * - \b Little (Display string: 'Little'): Stream channel data is little Endian. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceStreamChannelEndianness; + /// \brief An integer property. Specifies the stream packet size, in bytes, to send on the selected channel for a Transmitter or specifies the maximum packet size supported by a receiver. + /** + * Specifies the stream packet size, in bytes, to send on the selected channel for a Transmitter or specifies the maximum packet size supported by a receiver. + */ + PropertyI64 deviceStreamChannelPacketSize; + /// \brief An integer property. Indicates the number of event channels supported by the device. + /** + * Indicates the number of event channels supported by the device. + */ + PropertyI64 deviceEventChannelCount; + /// \brief An integer property. This feature is deprecated (See DeviceEventChannelCount). + /** + * \deprecated + * This feature is deprecated (See DeviceEventChannelCount). It indicates the number of message/event channels supported by the device. + */ + PropertyI64 deviceMessageChannelCount; + /// \brief An enumerated integer property. Character set used by the strings of the device. + /** + * Character set used by the strings of the device. + * + * The following string values might be valid for this feature: + * - \b UTF8 (Display string: 'UTF 8'): Device use UTF8 character set. + * - \b ASCII (Display string: 'ASCII'): Device use ASCII character set. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceCharacterSet; + /// \brief A method object. Resets the device to its power up state. + /** + * Resets the device to its power up state. After reset, the device must be rediscovered. + */ + Method deviceReset; + /// \brief An enumerated integer property. Controls the behavior of the indicators (such as LEDs) showing the status of the Device. + /** + * Controls the behavior of the indicators (such as LEDs) showing the status of the Device. + * + * The following string values might be valid for this feature: + * - \b Inactive (Display string: 'Inactive'): Device's indicators are inactive (Off). + * - \b Active (Display string: 'Active'): Device's indicators are active showing their respective status. + * - \b ErrorStatus (Display string: 'Error Status'): Device's indicators are inactive unless an error occurs. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceIndicatorMode; + /// \brief A method object. Indicate to the device and GenICam XML to get ready for persisting of all streamable features. + /** + * Indicate to the device and GenICam XML to get ready for persisting of all streamable features. + */ + Method deviceFeaturePersistenceStart; + /// \brief A method object. Indicate to the device the end of feature persistence. + /** + * Indicate to the device the end of feature persistence. + */ + Method deviceFeaturePersistenceEnd; + /// \brief A method object. Prepare the device for registers streaming without checking for consistency. + /** + * Prepare the device for registers streaming without checking for consistency. + */ + Method deviceRegistersStreamingStart; + /// \brief A method object. Announce the end of registers streaming. + /** + * Announce the end of registers streaming. This will do a register set validation for consistency and activate it. This will also update the DeviceRegistersValid flag. + */ + Method deviceRegistersStreamingEnd; + /// \brief A method object. Perform the validation of the current register set for consistency. + /** + * Perform the validation of the current register set for consistency. This will update the DeviceRegistersValid flag. + */ + Method deviceRegistersCheck; + /// \brief A boolean property. Returns if the current register set is valid and consistent. + /** + * Returns if the current register set is valid and consistent. + */ + PropertyIBoolean deviceRegistersValid; + /// \brief An enumerated integer property. Will give a hint where to find the invalid register settings if any. + /** + * Will give a hint where to find the invalid register settings if any. + * + * The following string values might be valid for this feature: + * - \b Valid (Display string: 'Valid'): The current register settings are in a consistent state. + * - \b Invalid (Display string: 'Invalid'): The current register settings are in an invalid and/or inconsistent state. + * - \b BinningHorizontalValueInvalid (Display string: 'Binning Horizontal Value Invalid'): The current BinningHorizontal value is not supported. + * - \b BinningVerticalValueInvalid (Display string: 'Binning Vertical Value Invalid'): The current BinningVertical value is not supported. + * - \b DecimationHorizontalValueInvalid (Display string: 'Decimation Horizontal Value Invalid'): The current DecimationHorizontal value is not supported. + * - \b DecimationVerticalValueInvalid (Display string: 'Decimation Vertical Value Invalid'): The current DecimationVertical value is not supported. + * - \b BinningDecimationCombinationInvalid (Display string: 'Binning Decimation Combination Invalid'): The current combination of binning and decimation is not valid. + * - \b BinningDecimationImageTooWide (Display string: 'Binning Decimation Image Too Wide'): The current Width is too wide for the BinningVertical and/or DecimationVertical settings. Please reduce the Width or add BinningHorizontal orDecimationHorizontal. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceRegistersStatus; + /// \brief An enumerated integer property. Endianness of the registers of the device. + /** + * Endianness of the registers of the device. + * + * The following string values might be valid for this feature: + * - \b Big (Display string: 'Big'): Device's registers are big Endian. + * - \b Little (Display string: 'Little'): Device's registers are little Endian. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceRegistersEndianness; + /// \brief An enumerated integer property. Selects the location within the device, where the temperature will be measured. + /** + * Selects the location within the device, where the temperature will be measured. + * + * The following string values might be valid for this feature: + * - \b Sensor (Display string: 'Sensor'): Temperature of the image sensor of the camera. + * - \b Mainboard (Display string: 'Mainboard'): Temperature of the device's mainboard. + * - \b XLamp (Display string: 'X Lamp') + * - \b SensorCMVx000 (Display string: 'Sensor CM Vx 000') + * - \b SensorInternal (Display string: 'Sensor Internal') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceTemperatureSelector; + /// \brief A floating point property. Device temperature in degrees Celsius (C). + /** + * Device temperature in degrees Celsius (C). It is measured at the location selected by DeviceTemperatureSelector. + */ + PropertyF deviceTemperature; + /// \brief An enumerated integer property. Selects the clock frequency to access from the device. + /** + * Selects the clock frequency to access from the device. + * + * The following string values might be valid for this feature: + * - \b Sensor (Display string: 'Sensor'): Clock frequency of the image sensor of the camera. + * - \b SensorDigitization (Display string: 'Sensor Digitization'): Clock frequency of the camera A/D conversion stage. + * - \b CameraLink (Display string: 'Camera Link'): Frequency of the Camera Link clock. + * - \b DeviceSpecific (Display string: 'Device Specific') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceClockSelector; + /// \brief A floating point property. Returns the frequency of the selected Clock. + /** + * Returns the frequency of the selected Clock. + */ + PropertyF deviceClockFrequency; + /// \brief An enumerated integer property. Selects which serial port of the device to control. + /** + * Selects which serial port of the device to control. + * + * The following string values might be valid for this feature: + * - \b CameraLink (Display string: 'Camera Link'): Serial port associated to the Camera link connection. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceSerialPortSelector; + /// \brief An enumerated integer property. This feature controls the baud rate used by the selected serial port. + /** + * This feature controls the baud rate used by the selected serial port. + * + * The following string values might be valid for this feature: + * - \b Baud9600 (Display string: 'Baud 9600'): Serial port speed of 9600 baud. + * - \b Baud19200 (Display string: 'Baud 19200'): Serial port speed of 19200 baud. + * - \b Baud38400 (Display string: 'Baud 38400'): Serial port speed of 38400 baud. + * - \b Baud57600 (Display string: 'Baud 57600'): Serial port speed of 57600 baud. + * - \b Baud115200 (Display string: 'Baud 115200'): Serial port speed of 115200 baud. + * - \b Baud230400 (Display string: 'Baud 230400'): Serial port speed of 230400 baud. + * - \b Baud460800 (Display string: 'Baud 460800'): Serial port speed of 460800 baud. + * - \b Baud921600 (Display string: 'Baud 921600'): Serial port speed of 921600 baud. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceSerialPortBaudRate; + /// \brief An integer property. Reports the current value of the device timestamp counter. + /** + * Reports the current value of the device timestamp counter. + */ + PropertyI64 timestamp; + /// \brief A method object. Resets the current value of the device timestamp counter. + /** + * Resets the current value of the device timestamp counter. + */ + Method timestampReset; + /// \brief A method object. Latches the current timestamp counter into TimestampLatchValue. + /** + * Latches the current timestamp counter into TimestampLatchValue. + */ + Method timestampLatch; + /// \brief An integer property. Returns the latched value of the timestamp counter. + /** + * Returns the latched value of the timestamp counter. + */ + PropertyI64 timestampLatchValue; + /// \brief An integer property. Device temperature in degrees Celsius (C). + /** + * Device temperature in degrees Celsius (C). It is measured at the location selected by DeviceTemperatureSelector. + */ + PropertyI64 mvDeviceTemperatureRaw; + /// \brief An integer property. Upper limit in degrees Celsius(C) for the TemperatureOutOfRange signal. + /** + * Upper limit in degrees Celsius(C) for the TemperatureOutOfRange signal. + */ + PropertyI64 mvDeviceTemperatureUpperLimit; + /// \brief An integer property. Lower limit in degrees Celsius(C) for the TemperatureOutOfRange signal. + /** + * Lower limit in degrees Celsius(C) for the TemperatureOutOfRange signal. + */ + PropertyI64 mvDeviceTemperatureLowerLimit; + /// \brief An enumerated integer property. Hysteresis in degrees Celsius(C) for temperature limits. + /** + * Hysteresis in degrees Celsius(C) for temperature limits. + * + * The following string values might be valid for this feature: + * - \b deg_0p0 (Display string: 'deg 0p 0') + * - \b deg_1p5 (Display string: 'deg 1p 5') + * - \b deg_3p0 (Display string: 'deg 3p 0') + * - \b deg_6p0 (Display string: 'deg 6p 0') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceTemperatureLimitHysteresis; + /// \brief An enumerated integer property. Clock frequency of the image sensor of the camera. + /** + * Clock frequency of the image sensor of the camera. + * + * The following string values might be valid for this feature: + * - \b kHz_08000 (Display string: '8000 kHz') + * - \b kHz_10000 (Display string: '10000 kHz') + * - \b kHz_11000 (Display string: '11000 kHz') + * - \b kHz_12000 (Display string: '12000 kHz') + * - \b kHz_20000 (Display string: '20000 kHz') + * - \b kHz_22000 (Display string: '22000 kHz') + * - \b kHz_23000 (Display string: '23000 kHz') + * - \b kHz_24000 (Display string: '24000 kHz') + * - \b kHz_24540 (Display string: '24540 kHz') + * - \b kHz_25000 (Display string: '25000 kHz') + * - \b kHz_26000 (Display string: '26000 kHz') + * - \b kHz_27000 (Display string: '27000 kHz') + * - \b kHz_28000 (Display string: '28000 kHz') + * - \b kHz_29000 (Display string: '29000 kHz') + * - \b kHz_29500 (Display string: '29500 kHz') + * - \b kHz_30000 (Display string: '30000 kHz') + * - \b kHz_32000 (Display string: '32000 kHz') + * - \b kHz_36000 (Display string: '36000 kHz') + * - \b kHz_37120 (Display string: '37120 kHz') + * - \b kHz_40000 (Display string: '40000 kHz') + * - \b kHz_45000 (Display string: '45000 kHz') + * - \b kHz_48000 (Display string: '48000 kHz') + * - \b kHz_50000 (Display string: '50000 kHz') + * - \b kHz_56000 (Display string: '56000 kHz') + * - \b kHz_60000 (Display string: '60000 kHz') + * - \b kHz_65000 (Display string: '65000 kHz') + * - \b kHz_66000 (Display string: '66000 kHz') + * - \b kHz_74250 (Display string: '74250 kHz') + * - \b kHz_80000 (Display string: '80000 kHz') + * - \b kHz_85000 (Display string: '85000 kHz') + * - \b kHz_96000 (Display string: '96000 kHz') + * - \b kHz_98000 (Display string: '98000 kHz') + * - \b kHz_120000 (Display string: '120000 kHz') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceClockFrequency; + /// \brief An enumerated integer property. Shows color mode of the sensor. + /** + * Shows color mode of the sensor. + * + * The following string values might be valid for this feature: + * - \b Unknown (Display string: 'Unknown') + * - \b Grey (Display string: 'Grey') + * - \b BayerMosaic (Display string: 'Bayer Mosaic') + * - \b NearInfraRed (Display string: 'Near Infra Red') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceSensorColorMode; + /// \brief A string property. Shows version number of the FPGA. + /** + * Shows version number of the FPGA. + */ + PropertyS mvDeviceFPGAVersion; + /// \brief An enumerated integer property. Shows the location from where the firmware was loaded. + /** + * Shows the location from where the firmware was loaded. + * + * The following string values might be valid for this feature: + * - \b BootSection (Display string: 'Boot Section') + * - \b ProgramSection (Display string: 'Program Section') + * - \b Upload (Display string: 'Upload') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceFirmwareSource; + /// \brief An integer property. Selects the device processing unit. + /** + * Selects the device processing unit. + */ + PropertyI64 mvDeviceProcessingUnitSelector; + /// \brief An enumerated integer property. The processing unit to activate for the selected processing unit. + /** + * The processing unit to activate for the selected processing unit. + * + * The following string values might be valid for this feature: + * - \b mvFFC (Display string: 'mv FFC'): Selects the Flat-field correction engine for this processing unit. + * - \b mvFrameAverage (Display string: 'mv Frame Average'): Selects the frame average engine for this processing unit. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceProcessingUnit; + /// \brief A boolean property. This feature is deprecated (See DeviceIndicatorMode). If enabled, the color of the LED changes depending on the state of the camera. Otherwise the LED is Off. + /** + * \deprecated + * This feature is deprecated (See DeviceIndicatorMode). If enabled, the color of the LED changes depending on the state of the camera. Otherwise the LED is Off. + */ + PropertyIBoolean mvDeviceStatusLEDEnable; + /// \brief An enumerated integer property. Selects the device power mode. + /** + * Selects the device power mode. + * + * The following string values might be valid for this feature: + * - \b mvActive (Display string: 'mv Active'): Puts the device to power-active mode. Going back to 'mvActive' will take about 10 seconds. + * - \b mvStandby (Display string: 'mv Standby'): Puts the device in power-saving mode. In this mode the device will only consume up to 20 percent of its normal power consumption. Going back to 'mvActive' will take about 10 seconds. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDevicePowerMode; + /// \brief A boolean property. If enabled, the device switch to standby after a configurable time if no register is read. + /** + * If enabled, the device switch to standby after a configurable time if no register is read. + */ + PropertyIBoolean mvDeviceStandbyTimeoutEnable; + /// \brief An integer property. Defines the time in seconds after which the device automatically switches to standby if no register is read. + /** + * Defines the time in seconds after which the device automatically switches to standby if no register is read. + */ + PropertyI64 mvDeviceStandbyTimeout; + /// \brief A string property. Shows the hash code of the firmware. + /** + * Shows the hash code of the firmware. + */ + PropertyS mvDeviceFirmwareHashCode; + /// \brief A method object. Do a new calculation of the hash code. This might serve as a means to check whether the firmware has been changed in flash. + /** + * Do a new calculation of the hash code. This might serve as a means to check whether the firmware has been changed in flash. Caution: This needs approximately 15-20 seconds! + */ + Method mvCalculateHashCode; + /// \brief An enumerated integer property. The algorithm used for the hash calculation. + /** + * The algorithm used for the hash calculation. + * + * The following string values might be valid for this feature: + * - \b mvCRC32b (Display string: 'mv CRC 32b'): CRC32b will be used. + * - \b mvSHA1 (Display string: 'mv SHA 1'): SHA1 will be used. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceFirmwareHashAlgorithm; + /// \brief An integer property. Laser current consumption value (mA). + /** + * Laser current consumption value (mA). + */ + PropertyI64 mvDeviceLaserCurrent; + /// \brief An enumerated integer property. Will synchronize the internal clock to an external GPS(PPS) signal. + /** + * Will synchronize the internal clock to an external GPS(PPS) signal. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b Line4 (Display string: 'Line 4') + * - \b Line5 (Display string: 'Line 5') + * - \b Line6 (Display string: 'Line 6') + * - \b Line7 (Display string: 'Line 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvTimestampPPSSync; + /// \brief An enumerated integer property. Selects the trigger edge on which the controller will be pulsed. + /** + * Selects the trigger edge on which the controller will be pulsed. + * + * The following string values might be valid for this feature: + * - \b mvRisingEdge (Display string: 'mv Rising Edge'): Controller is pulsed on rising edges. + * - \b mvFallingEdge (Display string: 'mv Falling Edge'): Controller is pulsed on falling edges. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvTimestampPPSTriggerEdge; + /// \brief An integer property. Shows the number of missed pulses since the last status latch. + /** + * Shows the number of missed pulses since the last status latch. + */ + PropertyI64 mvTimestampPPSPulsesMissed; + /// \brief An enumerated integer property. Shows the current status of the pulse per second controller. + /** + * Shows the current status of the pulse per second controller. + * + * The following string values might be valid for this feature: + * - \b Disabled (Display string: 'Disabled'): Controller is disabled. + * - \b NoPulses (Display string: 'No Pulses'): Controller is enabled but pps pulses are missing. + * - \b Unstable (Display string: 'Unstable'): Controller has not reached the steady state so far. + * - \b Stable (Display string: 'Stable'): Controller has reached the range of steady state. + * - \b Error (Display string: 'Error'): Controller is in faulty state and must be reenabled manually. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvTimestampPPSStatus; + /// \brief An integer property. Defines the initial value after the cameras timestamp timer has been reset. + /** + * Defines the initial value after the cameras timestamp timer has been reset. + */ + PropertyI64 mvTimestampResetValue; + /// \brief An enumerated integer property. Indicates the current temperature state of the camera + /** + * Indicates the current temperature state of the camera + * + * The following string values might be valid for this feature: + * - \b Normal (Display string: 'Normal') + * - \b Critical (Display string: 'Critical') + * - \b OverTemperature (Display string: 'Over Temperature') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvTemperatureState; + /// \brief An integer property. If the temperature of the camera exceeds this value mvTemperatureState switches from normal to critical + /** + * If the temperature of the camera exceeds this value mvTemperatureState switches from normal to critical + */ + PropertyI64 mvTemperatureStateCriticalThreshold; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category for Image Format Control features. +/** + * A category for Image Format Control features. + * \ingroup GenICamInterfaceDevice + */ +class ImageFormatControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::ImageFormatControl object. + explicit ImageFormatControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + sensorWidth(), + sensorHeight(), + sensorPixelWidth(), + sensorPixelHeight(), + sensorName(), + sensorShutterMode(), + sensorTaps(), + sensorDigitizationTaps(), + widthMax(), + heightMax(), + regionSelector(), + regionMode(), + regionDestination(), + regionIDValue(), + componentSelector(), + componentEnable(), + componentIDValue(), + groupSelector(), + groupIDValue(), + imageComponentSelector(), + imageComponentEnable(), + width(), + height(), + offsetX(), + offsetY(), + mvBlockscanLinesPerBlock(), + mvBlockscanBlockCount(), + mvMultiAreaMode(), + mvAreaSelector(), + mvAreaEnable(), + mvAreaWidth(), + mvAreaHeight(), + mvAreaOffsetX(), + mvAreaOffsetY(), + mvAreaResultingOffsetX(), + mvAreaResultingOffsetY(), + linePitchEnable(), + linePitch(), + binningSelector(), + binningHorizontalMode(), + binningHorizontal(), + binningVerticalMode(), + binningVertical(), + decimationHorizontalMode(), + decimationHorizontal(), + decimationVerticalMode(), + decimationVertical(), + reverseX(), + reverseY(), + pixelFormat(), + pixelFormatInfoSelector(), + pixelFormatInfoID(), + pixelCoding(), + pixelSize(), + pixelColorFilter(), + pixelDynamicRangeMin(), + pixelDynamicRangeMax(), + testPatternGeneratorSelector(), + testPattern(), + testImageSelector(), + deinterlacing(), + imageCompressionMode(), + imageCompressionRateOption(), + imageCompressionQuality(), + imageCompressionBitrate(), + imageCompressionJPEGFormatOption(), + mvSensorDigitizationBitDepth() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( sensorWidth, "SensorWidth" ); + locator.bindComponent( sensorHeight, "SensorHeight" ); + locator.bindComponent( sensorPixelWidth, "SensorPixelWidth" ); + if( !sensorPixelWidth.isValid() ) + { + locator.bindComponent( sensorPixelWidth, "mvDeviceSensorPixelWidth" ); + } + locator.bindComponent( sensorPixelHeight, "SensorPixelHeight" ); + if( !sensorPixelHeight.isValid() ) + { + locator.bindComponent( sensorPixelHeight, "mvDeviceSensorPixelHeight" ); + } + locator.bindComponent( sensorName, "SensorName" ); + if( !sensorName.isValid() ) + { + locator.bindComponent( sensorName, "mvDeviceSensorName" ); + } + locator.bindComponent( sensorShutterMode, "SensorShutterMode" ); + locator.bindComponent( sensorTaps, "SensorTaps" ); + locator.bindComponent( sensorDigitizationTaps, "SensorDigitizationTaps" ); + locator.bindComponent( widthMax, "WidthMax" ); + locator.bindComponent( heightMax, "HeightMax" ); + locator.bindComponent( regionSelector, "RegionSelector" ); + locator.bindComponent( regionMode, "RegionMode" ); + locator.bindComponent( regionDestination, "RegionDestination" ); + locator.bindComponent( regionIDValue, "RegionIDValue" ); + locator.bindComponent( componentSelector, "ComponentSelector" ); + locator.bindComponent( componentEnable, "ComponentEnable" ); + locator.bindComponent( componentIDValue, "ComponentIDValue" ); + locator.bindComponent( groupSelector, "GroupSelector" ); + locator.bindComponent( groupIDValue, "GroupIDValue" ); + locator.bindComponent( imageComponentSelector, "ImageComponentSelector" ); + locator.bindComponent( imageComponentEnable, "ImageComponentEnable" ); + locator.bindComponent( width, "Width" ); + locator.bindComponent( height, "Height" ); + locator.bindComponent( offsetX, "OffsetX" ); + locator.bindComponent( offsetY, "OffsetY" ); + locator.bindComponent( mvBlockscanLinesPerBlock, "mvBlockscanLinesPerBlock" ); + locator.bindComponent( mvBlockscanBlockCount, "mvBlockscanBlockCount" ); + locator.bindComponent( mvMultiAreaMode, "mvMultiAreaMode" ); + locator.bindComponent( mvAreaSelector, "mvAreaSelector" ); + locator.bindComponent( mvAreaEnable, "mvAreaEnable" ); + locator.bindComponent( mvAreaWidth, "mvAreaWidth" ); + locator.bindComponent( mvAreaHeight, "mvAreaHeight" ); + locator.bindComponent( mvAreaOffsetX, "mvAreaOffsetX" ); + locator.bindComponent( mvAreaOffsetY, "mvAreaOffsetY" ); + locator.bindComponent( mvAreaResultingOffsetX, "mvAreaResultingOffsetX" ); + locator.bindComponent( mvAreaResultingOffsetY, "mvAreaResultingOffsetY" ); + locator.bindComponent( linePitchEnable, "LinePitchEnable" ); + locator.bindComponent( linePitch, "LinePitch" ); + locator.bindComponent( binningSelector, "BinningSelector" ); + locator.bindComponent( binningHorizontalMode, "BinningHorizontalMode" ); + locator.bindComponent( binningHorizontal, "BinningHorizontal" ); + locator.bindComponent( binningVerticalMode, "BinningVerticalMode" ); + locator.bindComponent( binningVertical, "BinningVertical" ); + locator.bindComponent( decimationHorizontalMode, "DecimationHorizontalMode" ); + locator.bindComponent( decimationHorizontal, "DecimationHorizontal" ); + locator.bindComponent( decimationVerticalMode, "DecimationVerticalMode" ); + locator.bindComponent( decimationVertical, "DecimationVertical" ); + locator.bindComponent( reverseX, "ReverseX" ); + locator.bindComponent( reverseY, "ReverseY" ); + locator.bindComponent( pixelFormat, "PixelFormat" ); + locator.bindComponent( pixelFormatInfoSelector, "PixelFormatInfoSelector" ); + locator.bindComponent( pixelFormatInfoID, "PixelFormatInfoID" ); + locator.bindComponent( pixelCoding, "PixelCoding" ); + locator.bindComponent( pixelSize, "PixelSize" ); + locator.bindComponent( pixelColorFilter, "PixelColorFilter" ); + locator.bindComponent( pixelDynamicRangeMin, "PixelDynamicRangeMin" ); + locator.bindComponent( pixelDynamicRangeMax, "PixelDynamicRangeMax" ); + locator.bindComponent( testPatternGeneratorSelector, "TestPatternGeneratorSelector" ); + locator.bindComponent( testPattern, "TestPattern" ); + if( !testPattern.isValid() ) + { + locator.bindComponent( testPattern, "TestImageSelector" ); + } + locator.bindComponent( testImageSelector, "TestImageSelector" ); + locator.bindComponent( deinterlacing, "Deinterlacing" ); + locator.bindComponent( imageCompressionMode, "ImageCompressionMode" ); + locator.bindComponent( imageCompressionRateOption, "ImageCompressionRateOption" ); + locator.bindComponent( imageCompressionQuality, "ImageCompressionQuality" ); + locator.bindComponent( imageCompressionBitrate, "ImageCompressionBitrate" ); + locator.bindComponent( imageCompressionJPEGFormatOption, "ImageCompressionJPEGFormatOption" ); + locator.bindComponent( mvSensorDigitizationBitDepth, "mvSensorDigitizationBitDepth" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property. Effective width of the sensor in pixels. + /** + * Effective width of the sensor in pixels. + */ + PropertyI64 sensorWidth; + /// \brief An integer property. Effective height of the sensor in pixels. + /** + * Effective height of the sensor in pixels. + */ + PropertyI64 sensorHeight; + /// \brief A floating point property. Physical size (pitch) in the x direction of a photo sensitive pixel unit. + /** + * Physical size (pitch) in the x direction of a photo sensitive pixel unit. + */ + PropertyF sensorPixelWidth; + /// \brief A floating point property. Physical size (pitch) in the y direction of a photo sensitive pixel unit. + /** + * Physical size (pitch) in the y direction of a photo sensitive pixel unit. + */ + PropertyF sensorPixelHeight; + /// \brief A string property. Product name of the imaging Sensor. + /** + * Product name of the imaging Sensor. + */ + PropertyS sensorName; + /// \brief An enumerated integer property. Specifies the shutter mode of the device. + /** + * Specifies the shutter mode of the device. + * + * The following string values might be valid for this feature: + * - \b Global (Display string: 'Global'): The shutter opens and closes at the same time for all pixels. All the pixels are exposed for the same length of time at the same time. + * - \b Rolling (Display string: 'Rolling'): The shutter opens and closes sequentially for groups (typically lines) of pixels. All the pixels are exposed for the same length of time but not at the same time. + * - \b GlobalReset (Display string: 'Global Reset'): The shutter opens at the same time for all pixels but ends in a sequential manner. The pixels are exposed for different lengths of time. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sensorShutterMode; + /// \brief An enumerated integer property. Number of taps of the camera sensor. + /** + * Number of taps of the camera sensor. + * + * The following string values might be valid for this feature: + * - \b One (Display string: 'One'): 1 tap. + * - \b Two (Display string: 'Two'): 2 taps. + * - \b Three (Display string: 'Three'): 3 taps. + * - \b Four (Display string: 'Four'): 4 taps. + * - \b Eight (Display string: 'Eight'): 8 taps. + * - \b Ten (Display string: 'Ten'): 10 taps. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sensorTaps; + /// \brief An enumerated integer property. Number of digitized samples outputted simultaneously by the camera A/D conversion stage. + /** + * Number of digitized samples outputted simultaneously by the camera A/D conversion stage. + * + * The following string values might be valid for this feature: + * - \b One (Display string: 'One'): 1 tap. + * - \b Two (Display string: 'Two'): 2 taps. + * - \b Three (Display string: 'Three'): 3 taps. + * - \b Four (Display string: 'Four'): 4 taps. + * - \b Eight (Display string: 'Eight'): 8 taps. + * - \b Ten (Display string: 'Ten'): 10 taps. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sensorDigitizationTaps; + /// \brief An integer property. Maximum width of the image (in pixels). + /** + * Maximum width of the image (in pixels). The dimension is calculated after horizontal binning, decimation or any other function changing the horizontal dimension of the image. + */ + PropertyI64 widthMax; + /// \brief An integer property. Maximum height of the image (in pixels). + /** + * Maximum height of the image (in pixels). This dimension is calculated after vertical binning, decimation or any other function changing the vertical dimension of the image. + */ + PropertyI64 heightMax; + /// \brief An enumerated integer property. Selects the Region of interest to control. + /** + * Selects the Region of interest to control. The RegionSelector feature allows devices that are able to extract multiple regions out of an image, to configure the features of those individual regions independently. + * + * The following string values might be valid for this feature: + * - \b Region0 (Display string: 'Region 0'): Selected feature will control the region 0. + * - \b Region1 (Display string: 'Region 1'): Selected feature will control the region 1. + * - \b Region2 (Display string: 'Region 2'): Selected feature will control the region 2. + * - \b Region\#3\# (Display string: 'Region \#3\#'): Selected feature will control the region \#3\#. + * - \b Scan3dExtraction0 (Display string: 'Scan 3d Extraction 0'): Selected feature will control the Scan3dExtraction0 output Region. + * - \b Scan3dExtraction1 (Display string: 'Scan 3d Extraction 1'): Selected feature will control the Scan3dExtraction1 output Region. + * - \b Scan3dExtraction2 (Display string: 'Scan 3d Extraction 2'): Selected feature will control the Scan3dExtraction2 output Region. + * - \b All (Display string: 'All'): Selected features will control all the regions at the same time. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 regionSelector; + /// \brief An enumerated integer property. Controls if the selected Region of interest is active and streaming. + /** + * Controls if the selected Region of interest is active and streaming. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disable the usage of the Region. + * - \b On (Display string: 'On'): Enable the usage of the Region. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 regionMode; + /// \brief An enumerated integer property. Control the destination of the selected region. + /** + * Control the destination of the selected region. + * + * The following string values might be valid for this feature: + * - \b Stream0 (Display string: 'Stream 0'): The destination of the region is the data stream 0. + * - \b Stream1 (Display string: 'Stream 1'): The destination of the region is the data stream 1. + * - \b Stream2 (Display string: 'Stream 2'): The destination of the region is the data stream 2. + * - \b Stream\#3\# (Display string: 'Stream \#3\#'): The destination of the region is the data stream \#3\#. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 regionDestination; + /// \brief An integer property. Returns a unique Identifier value that corresponds to the selected Region. + /** + * Returns a unique Identifier value that corresponds to the selected Region. + */ + PropertyI64 regionIDValue; + /// \brief An enumerated integer property. Selects a component to activate/deactivate its data streaming. + /** + * Selects a component to activate/deactivate its data streaming. + * + * The following string values might be valid for this feature: + * - \b Intensity (Display string: 'Intensity'): The acquisition of intensity (monochrome or color) of the visible reflected light is controlled. + * - \b Infrared (Display string: 'Infrared'): The acquisition of non-visible infrared light is controlled. + * - \b Ultraviolet (Display string: 'Ultraviolet'): The acquisition of non-visible ultraviolet light is controlled. + * - \b Range (Display string: 'Range'): The acquisition of range (distance) data is controlled. The data produced may be only range (2.5D) or a point cloud giving the 3D coordinates depending on the Scan3dControl features. + * - \b Reflectance (Display string: 'Reflectance'): The reflected intensity acquired together with Range in a Linescan3D sensor acquiring a single linescan profile for each exposure of the sensor. + * - \b Confidence (Display string: 'Confidence'): The acquisition of confidence map of the acquired image is controlled. Confidence data may be binary (0 - invalid) or an integer where 0 is invalid and increasing value is increased confidence in the data in the corresponding pixel. If floating point representation is used the confidence image is normalized to the range [0,1], for integer representation the maximum possible integer represents maximum confidence. + * - \b Disparity (Display string: 'Disparity'): The acquisition of stereo camera disparity data is controlled. Disparity is a more specific range format approximately inversely proportional to distance. Disparity is typically given in pixel units. + * - \b Scatter (Display string: 'Scatter'): The acquisition of data measuring how much light is scattered around the reflected light. In processing this is used as an additional intensity image, often together with the standard intensity or reflectance. + * - \b Multispectral (Display string: 'Multispectral'): The acquisition of multiple spectral bands corresponding to various light wavelenghts is controlled. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 componentSelector; + /// \brief A boolean property. Controls if the selected component streaming is active. + /** + * Controls if the selected component streaming is active. + */ + PropertyIBoolean componentEnable; + /// \brief An integer property. Returns a unique Identifier value that corresponds to type of the component selected by ComponentSelector. + /** + * Returns a unique Identifier value that corresponds to type of the component selected by ComponentSelector. + */ + PropertyI64 componentIDValue; + /// \brief An enumerated integer property. Selects a Group of component to control or inquire. + /** + * Selects a Group of component to control or inquire. The GroupSelector determines which components Group will be used for the selected features. + * + * The following string values might be valid for this feature: + * - \b Group0 (Display string: 'Group 0'): Group 0 + * - \b Group1 (Display string: 'Group 1'): Group 1 + * - \b Group2 (Display string: 'Group 2'): Group 2 + * - \b Group\#3\# (Display string: 'Group \#3\#'): Group \#3\# + * - \b Group3 (Display string: 'Group 3'): Group 3 + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 groupSelector; + /// \brief An integer property. Returns a unique Identifier value corresponding to the selected Group of Components. + /** + * Returns a unique Identifier value corresponding to the selected Group of Components. If no grouping is required, this value should be set to 0. + */ + PropertyI64 groupIDValue; + /// \brief An enumerated integer property. This feature is deprecated (See ComponentSelector). + /** + * \deprecated + * This feature is deprecated (See ComponentSelector). It was used to select a component. + * + * The following string values might be valid for this feature: + * - \b Intensity (Display string: 'Intensity'): The acquisition of intensity (monochrome or color) of the visible reflected light is controlled. + * - \b Color (Display string: 'Color'): The acquisition of color of the reflected light is controlled + * - \b Infrared (Display string: 'Infrared'): The acquisition of non-visible infrared light is controlled. + * - \b Ultraviolet (Display string: 'Ultraviolet'): The acquisition of non-visible ultraviolet light is controlled. + * - \b Range (Display string: 'Range'): The acquisition of range (distance) data is controlled. The data produced may be only range (2.5D) or a point cloud 3D coordinates depending on the Scan3dControl features. + * - \b Confidence (Display string: 'Confidence'): The acquisition of confidence map of the acquired image is controlled. Confidence data may be binary (0 - invalid) or an integer where 0 is invalid and increasing value is increased confidence in the data in the corresponding pixel. If floating point representation is used the confidence image is normalized to the range [0,1], for integer representation the maximum possible integer represents maximum confidence. + * - \b Disparity (Display string: 'Disparity'): The acquisition of stereo camera disparity data is controlled. Disparity is a more specific range format approximately inversely proportional to distance. Disparity is typically given in pixel units. + * - \b Scatter (Display string: 'Scatter'): The acquisition of data measuring how much light is scattered around the reflected light. In processing this is used as an additional intensity image, often together with the standard intensity. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 imageComponentSelector; + /// \brief A boolean property. This feature is deprecated (See ComponentEnable). + /** + * \deprecated + * This feature is deprecated (See ComponentEnable). It was used to control if the selected component streaming is active. + */ + PropertyIBoolean imageComponentEnable; + /// \brief An integer property. Width of the image provided by the device (in pixels). + /** + * Width of the image provided by the device (in pixels). + */ + PropertyI64 width; + /// \brief An integer property. Height of the image provided by the device (in pixels). + /** + * Height of the image provided by the device (in pixels). + */ + PropertyI64 height; + /// \brief An integer property. Horizontal offset from the origin to the region of interest (in pixels). + /** + * Horizontal offset from the origin to the region of interest (in pixels). + */ + PropertyI64 offsetX; + /// \brief An integer property. Vertical offset from the origin to the region of interest (in pixels). + /** + * Vertical offset from the origin to the region of interest (in pixels). + */ + PropertyI64 offsetY; + /// \brief An integer property. Blockscan mode only: Number of lines per block. + /** + * Blockscan mode only: Number of lines per block. + */ + PropertyI64 mvBlockscanLinesPerBlock; + /// \brief An integer property. Blockscan mode only: Number of blocks combined to one frame. + /** + * Blockscan mode only: Number of blocks combined to one frame + */ + PropertyI64 mvBlockscanBlockCount; + /// \brief An enumerated integer property. Selects the overall multi area mode. + /** + * Selects the overall multi area mode. + * + * The following string values might be valid for this feature: + * - \b mvOff (Display string: 'mv Off'): Multi area mode is altogether switched off. Only one single AOI as defined in Width, Height, OffsetX and OffsetY properties is used and valid. + * - \b mvMultiAreasCombined (Display string: 'mv Multi Areas Combined'): Image is combined from multiple areas. The overlapping of areas is allowed. The camera decides which areas it needs to crop from the image and combines all areas into one image. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvMultiAreaMode; + /// \brief An enumerated integer property. Selects the area in multi area context. + /** + * Selects the area in multi area context. + * + * The following string values might be valid for this feature: + * - \b mvArea0 (Display string: 'mv Area 0'): First area in multi area context. + * - \b mvArea1 (Display string: 'mv Area 1'): Second area in multi area context. + * - \b mvArea2 (Display string: 'mv Area 2'): Third area in multi area context. + * - \b mvArea3 (Display string: 'mv Area 3'): Fourth area in multi area context. + * - \b mvArea4 (Display string: 'mv Area 4'): Fifth area in multi area context. + * - \b mvArea5 (Display string: 'mv Area 5'): Sixth area in multi area context. + * - \b mvArea6 (Display string: 'mv Area 6'): Seventh area in multi area context. + * - \b mvArea7 (Display string: 'mv Area 7'): Eighth area in multi area context. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvAreaSelector; + /// \brief A boolean property. This feature controls whether the selected area is active during streaming or not. + /** + * This feature controls whether the selected area is active during streaming or not. + */ + PropertyIBoolean mvAreaEnable; + /// \brief An integer property. Width of this area's part of the image (in pixels). + /** + * Width of this area's part of the image (in pixels). + */ + PropertyI64 mvAreaWidth; + /// \brief An integer property. Height of this area's part of the image (in pixels). + /** + * Height of this area's part of the image (in pixels). + */ + PropertyI64 mvAreaHeight; + /// \brief An integer property. Horizontal offset of this area within the image (in pixels). + /** + * Horizontal offset of this area within the image (in pixels). + */ + PropertyI64 mvAreaOffsetX; + /// \brief An integer property. Vertical offset of this area within the image (in pixels). + /** + * Vertical offset of this area within the image (in pixels). + */ + PropertyI64 mvAreaOffsetY; + /// \brief An integer property. Horizontal offset of this area within the resulting image (in pixels). + /** + * Horizontal offset of this area within the resulting image (in pixels). + */ + PropertyI64 mvAreaResultingOffsetX; + /// \brief An integer property. Vertical offset of this area within the resulting image (in pixels). + /** + * Vertical offset of this area within the resulting image (in pixels). + */ + PropertyI64 mvAreaResultingOffsetY; + /// \brief A boolean property. This feature controls whether the LinePitch feature is writable. + /** + * This feature controls whether the LinePitch feature is writable. Otherwise LinePitch is implicitly controlled by the combination of features like Width, PixelFormat, etc... + */ + PropertyIBoolean linePitchEnable; + /// \brief An integer property. Total number of bytes between the starts of 2 consecutive lines. + /** + * Total number of bytes between the starts of 2 consecutive lines. This feature is used to facilitate alignment of image data. + */ + PropertyI64 linePitch; + /// \brief An enumerated integer property. Selects which binning engine is controlled by the BinningHorizontal and BinningVertical features. + /** + * Selects which binning engine is controlled by the BinningHorizontal and BinningVertical features. + * + * The following string values might be valid for this feature: + * - \b Sensor (Display string: 'Sensor'): Selected features will control the sensor binning. + * - \b Region0 (Display string: 'Region 0'): Selected feature will control the region 0 binning. + * - \b Region1 (Display string: 'Region 1'): Selected feature will control the region 1 binning. + * - \b Region2 (Display string: 'Region 2'): Selected feature will control the region 2 binning. + * - \b Region\#3\# (Display string: 'Region \#3\#'): Selected feature will control the region \#3\# binning. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 binningSelector; + /// \brief An enumerated integer property. Sets the mode to use to combine horizontal photo-sensitive cells together when BinningHorizontal is used. + /** + * Sets the mode to use to combine horizontal photo-sensitive cells together when BinningHorizontal is used. + * + * The following string values might be valid for this feature: + * - \b Sum (Display string: 'Sum'): The response from the combined cells will be added, resulting in increased sensitivity. + * - \b Average (Display string: 'Average'): The response from the combined cells will be averaged, resulting in increased signal/noise ratio. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 binningHorizontalMode; + /// \brief An integer property. Number of horizontal photo-sensitive cells to combine together. + /** + * Number of horizontal photo-sensitive cells to combine together. This reduces the horizontal resolution (width) of the image. + */ + PropertyI64 binningHorizontal; + /// \brief An enumerated integer property. Sets the mode to use to combine vertical photo-sensitive cells together when BinningVertical is used. + /** + * Sets the mode to use to combine vertical photo-sensitive cells together when BinningVertical is used. + * + * The following string values might be valid for this feature: + * - \b Sum (Display string: 'Sum'): The response from the combined cells will be added, resulting in increased sensitivity. + * - \b Average (Display string: 'Average'): The response from the combined cells will be averaged, resulting in increased signal/noise ratio. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 binningVerticalMode; + /// \brief An integer property. Number of vertical photo-sensitive cells to combine together. + /** + * Number of vertical photo-sensitive cells to combine together. This reduces the vertical resolution (height) of the image. + */ + PropertyI64 binningVertical; + /// \brief An enumerated integer property. Sets the mode used to reduce the horizontal resolution when DecimationHorizontal is used. + /** + * Sets the mode used to reduce the horizontal resolution when DecimationHorizontal is used. + * + * The following string values might be valid for this feature: + * - \b Discard (Display string: 'Discard'): The value of every Nth pixel is kept, others are discarded. + * - \b Average (Display string: 'Average'): The values of a group of N adjacent pixels are averaged. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 decimationHorizontalMode; + /// \brief An integer property. Horizontal sub-sampling of the image. + /** + * Horizontal sub-sampling of the image. This reduces the horizontal resolution (width) of the image by the specified horizontal decimation factor. + */ + PropertyI64 decimationHorizontal; + /// \brief An enumerated integer property. Sets the mode used to reduce the Vertical resolution when DecimationVertical is used. + /** + * Sets the mode used to reduce the Vertical resolution when DecimationVertical is used. + * + * The following string values might be valid for this feature: + * - \b Discard (Display string: 'Discard'): The value of every Nth pixel is kept, others are discarded. + * - \b Average (Display string: 'Average'): The values of a group of N adjacent pixels are averaged. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 decimationVerticalMode; + /// \brief An integer property. Vertical sub-sampling of the image. + /** + * Vertical sub-sampling of the image. This reduces the vertical resolution (height) of the image by the specified vertical decimation factor. + */ + PropertyI64 decimationVertical; + /// \brief A boolean property. Flip horizontally the image sent by the device. + /** + * Flip horizontally the image sent by the device. The Region of interest is applied after the flipping. + */ + PropertyIBoolean reverseX; + /// \brief A boolean property. Flip vertically the image sent by the device. + /** + * Flip vertically the image sent by the device. The Region of interest is applied after the flipping. + */ + PropertyIBoolean reverseY; + /// \brief An enumerated integer property. Format of the pixels provided by the device. + /** + * Format of the pixels provided by the device. It represents all the information provided by PixelSize, PixelColorFilter combined in a single feature. + * + * The following string values might be valid for this feature: + * - \b Mono1p (Display string: 'Mono1p'): Mono 1 bit packed. + * - \b Mono2p (Display string: 'Mono2p'): Mono 2 bit packed. + * - \b Mono4p (Display string: 'Mono4p'): Mono 4 bit packed. + * - \b Mono8 (Display string: 'Mono8'): Mono 8 bit packed. + * - \b Mono8s (Display string: 'Mono8s'): Mono 1 bit signed. + * - \b Mono10 (Display string: 'Mono10'): Mono 10 bit. + * - \b Mono10p (Display string: 'Mono10p'): Mono 10 bit packed. + * - \b Mono12 (Display string: 'Mono12'): Mono 12 bit. + * - \b Mono12p (Display string: 'Mono12p'): Mono 12 bit packed. + * - \b Mono14 (Display string: 'Mono14'): Mono 14 bit. + * - \b Mono16 (Display string: 'Mono16'): Mono 16 bit. + * - \b R8 (Display string: 'R8'): Red 8 bit. + * - \b G8 (Display string: 'G8'): Green 8 bit. + * - \b B8 (Display string: 'B8'): Blue 8 bit. + * - \b RGB8 (Display string: 'RGB8'): Red, Green, Blue 8 bit + * - \b RGB8_Planar (Display string: 'RGB8_Planar'): Red, Green, Blue 8 bit planar. + * - \b RGBa8 (Display string: 'RGBa8'): Red, Green, Blue 8 bit aligned on 8 bit + * - \b RGB10 (Display string: 'RGB10'): Red, Green, Blue 10 bit. + * - \b RGB10_Planar (Display string: 'RGB10_Planar'): Red, Green, Blue 10 bit planar. + * - \b RGB10p32 (Display string: 'RGB10p32'): Red, Green, Blue 10 bit packed in 32 bit pixel. + * - \b RGB12 (Display string: 'RGB12'): Red, Green, Blue 12 bit. + * - \b RGB12_Planar (Display string: 'RGB12_Planar'): Red, Green, Blue 12 bit planar. + * - \b RGB16 (Display string: 'RGB16'): Red, Green, Blue 16 bit. + * - \b RGB16_Planar (Display string: 'RGB16_Planar'): Red, Green, Blue 16 bit planar. + * - \b RGB565p (Display string: 'RGB565p'): Red, Green, Blue 16 bit packet in 5, 6, 5 bits. + * - \b BGR10 (Display string: 'BGR10'): Blue, Green, Red, 10 bit. + * - \b BGR12 (Display string: 'BGR12'): Blue, Green, Red, 12 bit. + * - \b BGR16 (Display string: 'BGR16'): Blue, Green, Red, 16 bit. + * - \b BGR565p (Display string: 'BGR565p'): Blue, Green, Red, 16 bit packet in 5, 6, 5 bits. + * - \b BGR8 (Display string: 'BGR8'): Blue, Green, Red, 8 bit. + * - \b BGRa8 (Display string: 'BGRa8'): Blue, Green, Red, Alpha 8 bit. + * - \b YUV422_8 (Display string: 'YUV422_8'): YUV 422 8 bit. + * - \b YCbCr411_8 (Display string: 'YCbCr411_8'): YCrCb 411 8 bit. + * - \b YCbCr422_8 (Display string: 'YCbCr422_8'): YCrCb 422 8 bit. + * - \b YCbCr601_422_8 (Display string: 'YCbCr601_422_8'): YCrCb 601 422 8 bit. + * - \b YCbCr709_422_8 (Display string: 'YCbCr709_422_8'): YCrCb 709 422 8 bit. + * - \b YCbCr8 (Display string: 'YCbCr8'): YCbCr 8 bit. + * - \b BayerBG8 (Display string: 'BayerBG8'): Bayer Blue Green 8 bit. + * - \b BayerGB8 (Display string: 'BayerGB8'): Bayer Green Blue 8 bit. + * - \b BayerGR8 (Display string: 'BayerGR8'): Bayer Green Red 8 bit. + * - \b BayerRG8 (Display string: 'BayerRG8'): Bayer Red Green 8 bit. + * - \b BayerBG10 (Display string: 'BayerBG10'): Bayer Blue Green 10 bit. + * - \b BayerGB10 (Display string: 'BayerGB10'): Bayer Green Blue 10 bit. + * - \b BayerGR10 (Display string: 'BayerGR10'): Bayer Green Red 10 bit. + * - \b BayerRG10 (Display string: 'BayerRG10'): Bayer Red Green 10 bit. + * - \b BayerBG12 (Display string: 'BayerBG12'): Bayer Blue Green 12 bit + * - \b BayerGB12 (Display string: 'BayerGB12'): Bayer Green Blue 12 bit + * - \b BayerGR12 (Display string: 'BayerGR12'): Bayer Green Red 12 bit. + * - \b BayerRG12 (Display string: 'BayerRG12'): Bayer Red Green 12 bit. + * - \b BayerBG16 (Display string: 'BayerBG16'): Bayer Blue Green 16 bit. + * - \b BayerGB16 (Display string: 'BayerGB16'): Bayer Green Blue 16 bit. + * - \b BayerGR16 (Display string: 'BayerGR16'): Bayer Green Red 16 bit. + * - \b BayerRG16 (Display string: 'BayerRG16'): Bayer Red Green 16 bit. + * - \b Coord3D_A8 (Display string: 'Coord3D_A8'): 3D coordinate, first component 8 bit. + * - \b Coord3D_B8 (Display string: 'Coord3D_B8'): 3D coordinate, second component 8 bit. + * - \b Coord3D_C8 (Display string: 'Coord3D_C8'): 3D coordinate, third component 8 bit. + * - \b Coord3D_ABC8 (Display string: 'Coord3D_ABC8'): 3D coordinates, 3 components 8 bit. + * - \b Coord3D_ABC8_Planar (Display string: 'Coord3D_ABC8_Planar'): 3D coordinates, 3 components 8 bit planar. + * - \b Coord3D_A16 (Display string: 'Coord3D_A16'): 3D coordinate, first component 16 bit. + * - \b Coord3D_B16 (Display string: 'Coord3D_B16'): 3D coordinate, second component 16 bit. + * - \b Coord3D_C16 (Display string: 'Coord3D_C16'): 3D coordinate, third component 16 bit. + * - \b Coord3D_ABC16 (Display string: 'Coord3D_ABC16'): 3D coordinates, 3 components 16 bit. + * - \b Coord3D_ABC16_Planar (Display string: 'Coord3D_ABC16_Planar'): 3D coordinates, 3 components 16 bit planar. + * - \b Coord3D_A32f (Display string: 'Coord3D_A32f'): 3D coordinate, first component 32 bit float. + * - \b Coord3D_B32f (Display string: 'Coord3D_B32f'): 3D coordinate, second component 32 bit float. + * - \b Coord3D_C32f (Display string: 'Coord3D_C32f'): 3D coordinate, third component 32 bit float. + * - \b Coord3D_ABC32f (Display string: 'Coord3D_ABC32f'): 3D coordinates, 3 components 32 bit float. + * - \b Coord3D_ABC32f_Planar (Display string: 'Coord3D_ABC32f_Planar'): 3D coordinates, 3 components 32 bit float planar. + * - \b Confidence1 (Display string: 'Confidence1'): Confidence data 1 bit. + * - \b Confidence1p (Display string: 'Confidence1p'): Confidence data 1 bit packed. + * - \b Confidence8 (Display string: 'Confidence8'): Confidence data 8 bit. + * - \b Confidence16 (Display string: 'Confidence16'): Confidence data 16 bit. + * - \b Confidence32f (Display string: 'Confidence32f'): Confidence data 32 bit float. + * - \b Data8 (Display string: 'Data8'): Generic non-pixel data 8 bit. + * - \b Data8s (Display string: 'Data8s'): Generic non-pixel data 8 bit signed. + * - \b Data16 (Display string: 'Data16'): Generic non-pixel data 16 bit. + * - \b Data16s (Display string: 'Data16s'): Generic non-pixel data 16 bit signed. + * - \b Data32 (Display string: 'Data32'): Generic non-pixel data 32 bit. + * - \b Data32s (Display string: 'Data32s'): Generic non-pixel data 32 bit signed. + * - \b Data32f (Display string: 'Data32f'): Generic non-pixel data 32 bit floating point. + * - \b Data64 (Display string: 'Data64'): Generic non-pixel data 64 bit. + * - \b Data64s (Display string: 'Data64s'): Generic non-pixel data 64 bit signed. + * - \b Data64f (Display string: 'Data64f'): Generic non-pixel data 64 bit floating point. + * - \b Raw8 (Display string: 'Raw8'): Raw 8 bit. + * - \b Raw16 (Display string: 'Raw16'): Raw 16 bit. + * - \b Mono12Packed (Display string: 'Mono12Packed'): Mono 12 bit packed (GigE Vision Specific). + * - \b BayerGR10Packed (Display string: 'BayerGR10Packed'): Bayer GR 10 bit packed (GigE Vision Specific). + * - \b BayerRG10Packed (Display string: 'BayerRG10Packed'): Bayer RG 10 bit packed (GigE Vision Specific). + * - \b BayerGB10Packed (Display string: 'BayerGB10Packed'): Bayer GB 10 bit packed (GigE Vision Specific). + * - \b BayerBG10Packed (Display string: 'BayerBG10Packed'): Bayer BG 10 bit packed (GigE Vision Specific). + * - \b BayerGR12Packed (Display string: 'BayerGR12Packed'): Bayer GR 12 bit packed (GigE Vision Specific). + * - \b BayerRG12Packed (Display string: 'BayerRG12Packed'): Bayer RG 12 bit packed (GigE Vision Specific). + * - \b BayerGB12Packed (Display string: 'BayerGB12Packed'): Bayer GB 12 bit packed (GigE Vision Specific). + * - \b BayerBG12Packed (Display string: 'BayerBG12Packed'): Bayer BG 12 bit packed (GigE Vision Specific). + * - \b RGB10V1Packed (Display string: 'RGB10V1Packed'): RGB 10 bit packed (GigE Vision Specific). + * - \b RGB12V1Packed (Display string: 'RGB12V1Packed'): RGB 12 bit packed (GigE Vision Specific). + * - \b Mono8Signed (Display string: 'Mono 8 Signed') + * - \b Mono10Packed (Display string: 'Mono 10 Packed') + * - \b RGB8Packed (Display string: 'RGB 8 Packed') + * - \b BGR8Packed (Display string: 'BGR 8 Packed') + * - \b RGBA8Packed (Display string: 'RGBA 8 Packed') + * - \b BGRA8Packed (Display string: 'BGRA 8 Packed') + * - \b RGB10Packed (Display string: 'RGB 10 Packed') + * - \b BGR10Packed (Display string: 'BGR 10 Packed') + * - \b RGB12Packed (Display string: 'RGB 12 Packed') + * - \b BGR12Packed (Display string: 'BGR 12 Packed') + * - \b RGB16Packed (Display string: 'RGB 16 Packed') + * - \b RGB10V2Packed (Display string: 'RGB 10 V 2 Packed') + * - \b RGB565Packed (Display string: 'RGB 565 Packed') + * - \b BGR565Packed (Display string: 'BGR 565 Packed') + * - \b YUV411Packed (Display string: 'YUV 411 Packed') + * - \b YUV422Packed (Display string: 'YUV 422 Packed') + * - \b YUV444Packed (Display string: 'YUV 444 Packed') + * - \b YUYVPacked (Display string: 'YUYV Packed') + * - \b RGB8Planar (Display string: 'RGB 8 Planar') + * - \b RGB10Planar (Display string: 'RGB 10 Planar') + * - \b RGB12Planar (Display string: 'RGB 12 Planar') + * - \b RGB16Planar (Display string: 'RGB 16 Planar') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 pixelFormat; + /// \brief An enumerated integer property. Select the pixel format for which the information will be returned. + /** + * Select the pixel format for which the information will be returned. + * + * The following string values might be valid for this feature: + * - \b Mono1p (Display string: 'Mono1p'): Mono 1 bit packed. + * - \b Mono2p (Display string: 'Mono2p'): Mono 2 bit packed. + * - \b Mono4p (Display string: 'Mono4p'): Mono 4 bit packed. + * - \b Mono8 (Display string: 'Mono8'): Mono 8 bit packed. + * - \b Mono10 (Display string: 'Mono10'): Mono 10 bit. + * - \b Mono10p (Display string: 'Mono10p'): Mono 10 bit packed. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 pixelFormatInfoSelector; + /// \brief An integer property. Returns the value used by the streaming channels to identify the selected pixel format. + /** + * Returns the value used by the streaming channels to identify the selected pixel format. + */ + PropertyI64 pixelFormatInfoID; + /// \brief An enumerated integer property. This feature is deprecated. + /** + * \deprecated + * This feature is deprecated. It represents the coding of the pixels in the image. Raw gives the data in the native format of the sensor. + * + * The following string values might be valid for this feature: + * - \b Mono (Display string: 'Mono'): Mono. + * - \b MonoSigned (Display string: 'MonoSigned'): Mono signed. + * - \b MonoPacked (Display string: 'MonoPacked'): Mono packed. + * - \b RGBPacked (Display string: 'RGBPacked'): RGB packed. + * - \b BGRPacked (Display string: 'BGRPacked'): BGR packed. + * - \b RGBAPacked (Display string: 'RGBAPacked'): RGBA packed. + * - \b BGRAPacked (Display string: 'BGRAPacked'): BGRA packed. + * - \b RGBPlanar (Display string: 'RGBPlanar'): RGB planar. + * - \b YUV411Packed (Display string: 'YUV411Packed'): YUV 411 packed. + * - \b YUV422Packed (Display string: 'YUV422Packed'): YUV 422 packed. + * - \b YUV444Packed (Display string: 'YUV444Packed'): YUV 444 packed. + * - \b YUYVPacked (Display string: 'YUYVPacked'): YUYV packed. + * - \b Raw (Display string: 'Raw'): Raw. + * - \b RawPacked (Display string: 'RawPacked'): Raw packed. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 pixelCoding; + /// \brief An enumerated integer property. Total size in bits of a pixel of the image. + /** + * Total size in bits of a pixel of the image. + * + * The following string values might be valid for this feature: + * - \b Bpp1 (Display string: 'Bpp1'): 1 bit per pixel. + * - \b Bpp2 (Display string: 'Bpp2'): 2 bits per pixel. + * - \b Bpp4 (Display string: 'Bpp4'): 4 bits per pixel. + * - \b Bpp8 (Display string: 'Bpp8'): 8 bits per pixel. + * - \b Bpp10 (Display string: 'Bpp10'): 10 bits per pixel. + * - \b Bpp12 (Display string: 'Bpp12'): 12 bits per pixel. + * - \b Bpp14 (Display string: 'Bpp14'): 14 bits per pixel. + * - \b Bpp16 (Display string: 'Bpp16'): 16 bits per pixel. + * - \b Bpp20 (Display string: 'Bpp20'): 20 bits per pixel. + * - \b Bpp24 (Display string: 'Bpp24'): 24 bits per pixel. + * - \b Bpp30 (Display string: 'Bpp30'): 30 bits per pixel. + * - \b Bpp32 (Display string: 'Bpp32'): 32 bits per pixel. + * - \b Bpp36 (Display string: 'Bpp36'): 36 bits per pixel. + * - \b Bpp48 (Display string: 'Bpp48'): 48 bits per pixel. + * - \b Bpp64 (Display string: 'Bpp64'): 64 bits per pixel. + * - \b Bpp96 (Display string: 'Bpp96'): 96 bits per pixel. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 pixelSize; + /// \brief An enumerated integer property. Type of color filter that is applied to the image. + /** + * Type of color filter that is applied to the image. + * + * The following string values might be valid for this feature: + * - \b None (Display string: 'None'): No color filter. + * - \b BayerRG (Display string: 'BayerRG'): Bayer Red Green filter. + * - \b BayerGB (Display string: 'BayerGB'): Bayer Green Blue filter. + * - \b BayerGR (Display string: 'BayerGR'): Bayer Green Red filter. + * - \b BayerBG (Display string: 'BayerBG'): Bayer Blue Green filter. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 pixelColorFilter; + /// \brief An integer property. Minimum value that can be returned during the digitization process. + /** + * Minimum value that can be returned during the digitization process. This corresponds to the darkest value of the camera. For color camera, this returns the smallest value that each color component can take. + */ + PropertyI64 pixelDynamicRangeMin; + /// \brief An integer property. Maximum value that will be returned during the digitization process. + /** + * Maximum value that will be returned during the digitization process. This corresponds to the brightest value of the camera. For color camera, this returns the biggest value that each color component can take. + */ + PropertyI64 pixelDynamicRangeMax; + /// \brief An enumerated integer property. Selects which test pattern generator is controlled by the TestPattern feature. + /** + * Selects which test pattern generator is controlled by the TestPattern feature. + * + * The following string values might be valid for this feature: + * - \b Sensor (Display string: 'Sensor'): TestPattern feature will control the sensor's test pattern generator. + * - \b Region0 (Display string: 'Region 0'): TestPattern feature will control the region 0 test pattern generator. + * - \b Region1 (Display string: 'Region 1'): TestPattern feature will control the region 1 test pattern generator. + * - \b Region2 (Display string: 'Region 2'): TestPattern feature will control the region 2 test pattern generator. + * - \b Region\#3\# (Display string: 'Region \#3\#'): TestPattern feature will control the region \#3\# test pattern generator. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 testPatternGeneratorSelector; + /// \brief An enumerated integer property. Selects the type of test pattern that is generated by the device as image source. + /** + * Selects the type of test pattern that is generated by the device as image source. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Image is coming from the sensor. + * - \b Black (Display string: 'Black'): Image is filled with the darkest possible image. + * - \b White (Display string: 'White'): Image is filled with the brightest possible image. + * - \b GreyHorizontalRamp (Display string: 'Grey Horizontal Ramp'): Image is filled horizontally with an image that goes from the darkest possible value to the brightest. + * - \b GreyVerticalRamp (Display string: 'Grey Vertical Ramp'): Image is filled vertically with an image that goes from the darkest possible value to the brightest. + * - \b GreyHorizontalRampMoving (Display string: 'Grey Horizontal Ramp Moving'): Image is filled horizontally with an image that goes from the darkest possible value to the brightest and that moves horizontally from left to right at each frame. + * - \b GreyVerticalRampMoving (Display string: 'Grey Vertical Ramp Moving'): Image is filled vertically with an image that goes from the darkest possible value to the brightest and that moves vertically from top to bottom at each frame. + * - \b HorizontalLineMoving (Display string: 'Horizontal Line Moving'): A moving horizontal line is superimposed on the live image. + * - \b VerticalLineMoving (Display string: 'Vertical Line Moving'): A moving vertical line is superimposed on the live image. + * - \b ColorBar (Display string: 'Color Bar'): Image is filled with stripes of color including White, Black, Red, Green, Blue, Cyan, Magenta and Yellow. + * - \b FrameCounter (Display string: 'Frame Counter'): A frame counter is superimposed on the live image. + * - \b HorzontalLineMoving (Display string: 'Horzontal Line Moving') + * - \b mvBayerRaw (Display string: 'mv Bayer Raw') + * - \b mvGreyDiagonalRamp (Display string: 'mv Grey Diagonal Ramp') + * - \b mvFadeToGreyColorBar (Display string: 'mv Fade To Grey Color Bar') + * - \b mvFFCImage (Display string: 'mv FFC Image') + * - \b mvMovingGreyDiagonalRamp (Display string: 'mv Moving Grey Diagonal Ramp') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 testPattern; + /// \brief An enumerated integer property. This feature is deprecated (See TestPattern). + /** + * \deprecated + * This feature is deprecated (See TestPattern). Selects the type of test image that is sent by the device. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Image is coming from the sensor. + * - \b Black (Display string: 'Black'): Image is filled with the darkest possible image. + * - \b White (Display string: 'White'): Image is filled with the brightest possible image. + * - \b GreyHorizontalRamp (Display string: 'Grey Horizontal Ramp'): Image is filled horizontally with an image that goes from the darkest possible value to the brightest. + * - \b GreyVerticalRamp (Display string: 'Grey Vertical Ramp'): Image is filled vertically with an image that goes from the darkest possible value to the brightest. + * - \b GreyHorizontalRampMoving (Display string: 'Grey Horizontal Ramp Moving'): Image is filled horizontally with an image that goes from the darkest possible value to the brightest and that moves horizontally from left to right at each frame. + * - \b GreyVerticalRampMoving (Display string: 'Grey Vertical Ramp Moving'): Image is filled vertically with an image that goes from the darkest possible value to the brightest and that moves vertically from top to bottom at each frame. + * - \b HorizontalLineMoving (Display string: 'Horizontal Line Moving'): A moving horizontal line is superimposed on the live image. + * - \b VerticalLineMoving (Display string: 'Vertical Line Moving'): A moving vertical line is superimposed on the live image. + * - \b ColorBar (Display string: 'Color Bar'): Image is filled with stripes of color including White, Black, Red, Green, Blue, Cyan, Magenta and Yellow. + * - \b FrameCounter (Display string: 'Frame Counter'): A frame counter is superimposed on the live image. + * - \b HorzontalLineMoving (Display string: 'Horzontal Line Moving') + * - \b mvBayerRaw (Display string: 'mv Bayer Raw') + * - \b mvGreyDiagonalRamp (Display string: 'mv Grey Diagonal Ramp') + * - \b mvFadeToGreyColorBar (Display string: 'mv Fade To Grey Color Bar') + * - \b mvFFCImage (Display string: 'mv FFC Image') + * - \b mvMovingGreyDiagonalRamp (Display string: 'mv Moving Grey Diagonal Ramp') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 testImageSelector; + /// \brief An enumerated integer property. Controls how the device performs de-interlacing. + /** + * Controls how the device performs de-interlacing. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The device doesn't perform de-interlacing. + * - \b LineDuplication (Display string: 'Line Duplication'): The device performs de-interlacing by outputting each line of each field twice. + * - \b Weave (Display string: 'Weave'): The device performs de-interlacing by interleaving the lines of all fields. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deinterlacing; + /// \brief An enumerated integer property. Enable a specific image compression mode as the base mode for image transfer. + /** + * Enable a specific image compression mode as the base mode for image transfer. Optionally, chunk data can be appended to the compressed image (See the REF _Ref397502619 \h chapter). + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Default value. Image compression is disabled. Images are transmitted uncompressed. + * - \b JPEG (Display string: 'JPEG'): JPEG compression is selected. + * - \b JPEG2000 (Display string: 'JPEG 2000'): JPEG 2000 compression is selected. + * - \b H264 (Display string: 'H 264'): H.264 compression is selected. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 imageCompressionMode; + /// \brief An enumerated integer property. Two rate controlling options are offered: fixed bit rate or fixed quality. + /** + * Two rate controlling options are offered: fixed bit rate or fixed quality. The exact implementation to achieve one or the other is vendor-specific. + * + * The following string values might be valid for this feature: + * - \b FixBitrate (Display string: 'Fix Bitrate'): Output stream follows a constant bit rate. Allows easy bandwidth management on the link. + * - \b FixQuality (Display string: 'Fix Quality'): Output stream has a constant image quality. Can be used when image processing algorithms are sensitive to image degradation caused by excessive data compression. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 imageCompressionRateOption; + /// \brief An integer property. Control the quality of the produced compressed stream. + /** + * Control the quality of the produced compressed stream. + */ + PropertyI64 imageCompressionQuality; + /// \brief A floating point property. Control the rate of the produced compressed stream. + /** + * Control the rate of the produced compressed stream. + */ + PropertyF imageCompressionBitrate; + /// \brief An enumerated integer property. When JPEG is selected as the compression format, a device might optionally offer better control over JPEG-specific options through this feature. + /** + * When JPEG is selected as the compression format, a device might optionally offer better control over JPEG-specific options through this feature. + * + * The following string values might be valid for this feature: + * - \b Lossless (Display string: 'Lossless'): Selects lossless JPEG compression based on a predictive coding model. + * - \b BaselineStandard (Display string: 'Baseline Standard'): Indicates this is a baseline sequential (single-scan) DCT-based JPEG. + * - \b BaselineOptimized (Display string: 'Baseline Optimized'): Provides optimized color and slightly better compression than baseline standard by using custom Huffman tables optimized after statistical analysis of the image content. + * - \b Progressive (Display string: 'Progressive'): Indicates this is a progressive (multi-scan) DCT-based JPEG. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 imageCompressionJPEGFormatOption; + /// \brief An enumerated integer property. This feature manually selects the resolution of the device's ADC. + /** + * This feature manually selects the resolution of the device's ADC. + * + * The following string values might be valid for this feature: + * - \b Auto (Display string: 'Auto'): When the selected pixel format has 12 bits or more the ADC will work with 12 bits. Otherwise the ADC will work with 10 bits. + * - \b Bpp8 (Display string: 'Bpp 8'): The ADC will always work with a resolution of 8 bits no matter which pixel format has been selected. + * - \b Bpp10 (Display string: 'Bpp 10'): The ADC will always work with a resolution of 10 bits no matter which pixel format has been selected. + * - \b Bpp12 (Display string: 'Bpp 12'): The ADC will always work with a resolution of 12 bits no matter which pixel format has been selected. This will allow to achieve higher precision and thus improved quality when internal processing is done (e.g. when applying digital gain to the image). + * - \b Fixed (Display string: 'Fixed') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSensorDigitizationBitDepth; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category for the acquisition and trigger control features. +/** + * A category for the acquisition and trigger control features. + * \ingroup GenICamInterfaceDevice + */ +class AcquisitionControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::AcquisitionControl object. + explicit AcquisitionControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + acquisitionMode(), + acquisitionStart(), + acquisitionStop(), + acquisitionStopMode(), + acquisitionAbort(), + acquisitionArm(), + acquisitionFrameCount(), + acquisitionBurstFrameCount(), + mvSensorRegister(), + mvSensorRegisterValue(), + acquisitionFrameRate(), + acquisitionFrameRateEnable(), + acquisitionLineRate(), + acquisitionLineRateEnable(), + acquisitionStatusSelector(), + acquisitionStatus(), + triggerSelector(), + triggerMode(), + triggerSoftware(), + triggerSource(), + triggerActivation(), + triggerOverlap(), + triggerDelay(), + triggerDivider(), + triggerMultiplier(), + exposureMode(), + exposureTimeMode(), + exposureTimeSelector(), + exposureTime(), + mvExposureHorizontalZoneDivider(), + exposureAuto(), + multiSlopeMode(), + multiSlopeKneePointCount(), + multiSlopeKneePointSelector(), + multiSlopeExposureLimit(), + multiSlopeSaturationThreshold(), + multiSlopeIntensityLimit(), + multiSlopeExposureGradient(), + mvAcquisitionFrameRateLimitMode(), + mvAcquisitionFrameRateEnable(), + mvResultingFrameRate(), + mvShutterMode(), + mvCompressionKneepoint(), + mvExposureAutoLowerLimit(), + mvExposureAutoUpperLimit(), + mvExposureAutoSpeed(), + mvExposureAutoDelayImages(), + mvExposureAutoAverageGrey(), + mvExposureAutoHighlightAOI(), + mvExposureAutoAOIMode(), + mvExposureAutoOffsetX(), + mvExposureAutoOffsetY(), + mvExposureAutoWidth(), + mvExposureAutoHeight(), + mvExposureAutoMode(), + mvSmearReduction(), + mvAcquisitionMemoryMode(), + mvPretriggerFrameCount(), + mvAcquisitionMemoryMaxFrameCount(), + mvAcquisitionMemoryFrameCount(), + mvAcquisitionMemoryAOIParameterChanged(), + mvFeatureMode(), + mvSmartFrameRecallEnable(), + mvSmartFrameRecallTimestampLookupAccuracy(), + mvSmartFrameRecallFrameSkipRatio(), + mvLensCalibrationEnable() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( acquisitionMode, "AcquisitionMode" ); + locator.bindComponent( acquisitionStart, "AcquisitionStart@i" ); + locator.bindComponent( acquisitionStop, "AcquisitionStop@i" ); + locator.bindComponent( acquisitionStopMode, "AcquisitionStopMode" ); + locator.bindComponent( acquisitionAbort, "AcquisitionAbort@i" ); + locator.bindComponent( acquisitionArm, "AcquisitionArm@i" ); + locator.bindComponent( acquisitionFrameCount, "AcquisitionFrameCount" ); + locator.bindComponent( acquisitionBurstFrameCount, "AcquisitionBurstFrameCount" ); + locator.bindComponent( mvSensorRegister, "mvSensorRegister" ); + locator.bindComponent( mvSensorRegisterValue, "mvSensorRegisterValue" ); + locator.bindComponent( acquisitionFrameRate, "AcquisitionFrameRate" ); + if( !acquisitionFrameRate.isValid() ) + { + locator.bindComponent( acquisitionFrameRate, "AcquisitionFrameRateAbs" ); + } + locator.bindComponent( acquisitionFrameRateEnable, "AcquisitionFrameRateEnable" ); + locator.bindComponent( acquisitionLineRate, "AcquisitionLineRate" ); + if( !acquisitionLineRate.isValid() ) + { + locator.bindComponent( acquisitionLineRate, "AcquisitionLineRateAbs" ); + } + locator.bindComponent( acquisitionLineRateEnable, "AcquisitionLineRateEnable" ); + locator.bindComponent( acquisitionStatusSelector, "AcquisitionStatusSelector" ); + locator.bindComponent( acquisitionStatus, "AcquisitionStatus" ); + locator.bindComponent( triggerSelector, "TriggerSelector" ); + locator.bindComponent( triggerMode, "TriggerMode" ); + locator.bindComponent( triggerSoftware, "TriggerSoftware@i" ); + locator.bindComponent( triggerSource, "TriggerSource" ); + locator.bindComponent( triggerActivation, "TriggerActivation" ); + locator.bindComponent( triggerOverlap, "TriggerOverlap" ); + locator.bindComponent( triggerDelay, "TriggerDelay" ); + if( !triggerDelay.isValid() ) + { + locator.bindComponent( triggerDelay, "TriggerDelayAbs" ); + } + locator.bindComponent( triggerDivider, "TriggerDivider" ); + locator.bindComponent( triggerMultiplier, "TriggerMultiplier" ); + locator.bindComponent( exposureMode, "ExposureMode" ); + locator.bindComponent( exposureTimeMode, "ExposureTimeMode" ); + locator.bindComponent( exposureTimeSelector, "ExposureTimeSelector" ); + locator.bindComponent( exposureTime, "ExposureTime" ); + if( !exposureTime.isValid() ) + { + locator.bindComponent( exposureTime, "ExposureTimeAbs" ); + } + locator.bindComponent( mvExposureHorizontalZoneDivider, "mvExposureHorizontalZoneDivider" ); + locator.bindComponent( exposureAuto, "ExposureAuto" ); + locator.bindComponent( multiSlopeMode, "MultiSlopeMode" ); + locator.bindComponent( multiSlopeKneePointCount, "MultiSlopeKneePointCount" ); + locator.bindComponent( multiSlopeKneePointSelector, "MultiSlopeKneePointSelector" ); + locator.bindComponent( multiSlopeExposureLimit, "MultiSlopeExposureLimit" ); + locator.bindComponent( multiSlopeSaturationThreshold, "MultiSlopeSaturationThreshold" ); + locator.bindComponent( multiSlopeIntensityLimit, "MultiSlopeIntensityLimit" ); + locator.bindComponent( multiSlopeExposureGradient, "MultiSlopeExposureGradient" ); + locator.bindComponent( mvAcquisitionFrameRateLimitMode, "mvAcquisitionFrameRateLimitMode" ); + locator.bindComponent( mvAcquisitionFrameRateEnable, "mvAcquisitionFrameRateEnable" ); + locator.bindComponent( mvResultingFrameRate, "mvResultingFrameRate" ); + locator.bindComponent( mvShutterMode, "mvShutterMode" ); + locator.bindComponent( mvCompressionKneepoint, "mvCompressionKneepoint" ); + locator.bindComponent( mvExposureAutoLowerLimit, "mvExposureAutoLowerLimit" ); + locator.bindComponent( mvExposureAutoUpperLimit, "mvExposureAutoUpperLimit" ); + locator.bindComponent( mvExposureAutoSpeed, "mvExposureAutoSpeed" ); + locator.bindComponent( mvExposureAutoDelayImages, "mvExposureAutoDelayImages" ); + locator.bindComponent( mvExposureAutoAverageGrey, "mvExposureAutoAverageGrey" ); + locator.bindComponent( mvExposureAutoHighlightAOI, "mvExposureAutoHighlightAOI" ); + locator.bindComponent( mvExposureAutoAOIMode, "mvExposureAutoAOIMode" ); + locator.bindComponent( mvExposureAutoOffsetX, "mvExposureAutoOffsetX" ); + locator.bindComponent( mvExposureAutoOffsetY, "mvExposureAutoOffsetY" ); + locator.bindComponent( mvExposureAutoWidth, "mvExposureAutoWidth" ); + locator.bindComponent( mvExposureAutoHeight, "mvExposureAutoHeight" ); + locator.bindComponent( mvExposureAutoMode, "mvExposureAutoMode" ); + locator.bindComponent( mvSmearReduction, "mvSmearReduction" ); + locator.bindComponent( mvAcquisitionMemoryMode, "mvAcquisitionMemoryMode" ); + locator.bindComponent( mvPretriggerFrameCount, "mvPretriggerFrameCount" ); + locator.bindComponent( mvAcquisitionMemoryMaxFrameCount, "mvAcquisitionMemoryMaxFrameCount" ); + locator.bindComponent( mvAcquisitionMemoryFrameCount, "mvAcquisitionMemoryFrameCount" ); + locator.bindComponent( mvAcquisitionMemoryAOIParameterChanged, "mvAcquisitionMemoryAOIParameterChanged" ); + locator.bindComponent( mvFeatureMode, "mvFeatureMode" ); + locator.bindComponent( mvSmartFrameRecallEnable, "mvSmartFrameRecallEnable" ); + locator.bindComponent( mvSmartFrameRecallTimestampLookupAccuracy, "mvSmartFrameRecallTimestampLookupAccuracy" ); + locator.bindComponent( mvSmartFrameRecallFrameSkipRatio, "mvSmartFrameRecallFrameSkipRatio" ); + locator.bindComponent( mvLensCalibrationEnable, "mvLensCalibrationEnable" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Sets the acquisition mode of the device. + /** + * Sets the acquisition mode of the device. It defines mainly the number of frames to capture during an acquisition and the way the acquisition stops. + * + * The following string values might be valid for this feature: + * - \b SingleFrame (Display string: 'Single Frame'): One frame is captured. + * - \b MultiFrame (Display string: 'Multi Frame'): The number of frames specified by AcquisitionFrameCount is captured. + * - \b Continuous (Display string: 'Continuous'): Frames are captured continuously until stopped with the AcquisitionStop command. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 acquisitionMode; + /// \brief A method object. Starts the Acquisition of the device. + /** + * Starts the Acquisition of the device. The number of frames captured is specified by AcquisitionMode. + */ + Method acquisitionStart; + /// \brief A method object. Stops the Acquisition of the device at the end of the current Frame. + /** + * Stops the Acquisition of the device at the end of the current Frame. It is mainly used when AcquisitionMode is Continuous but can be used in any acquisition mode. + */ + Method acquisitionStop; + /// \brief An enumerated integer property. Controls how the AcquisitionStop command and the acquisition stopped using a trigger (e.g. + /** + * Controls how the AcquisitionStop command and the acquisition stopped using a trigger (e.g. AcquisitionActive, FrameBurstActive, FrameActive or FrameEnd trigger), ends an ongoing frame. This feature is mainly used in Linescan devices where each line in a frame is acquired sequentially. + * + * The following string values might be valid for this feature: + * - \b Complete (Display string: 'Complete'): When stopped during a frame, the device will continue acquisition of lines until the specified Height is reached to deliver a complete default size frame. Note that if each line is triggered from an external source and this line trigger stops no frame is delivered, and an AcquisitionAbort is needed. + * - \b Immediate (Display string: 'Immediate'): Acquisition stops immediately even during a frame and only the lines acquired at the time are delivered. + * - \b ImmediateWithPadding (Display string: 'Immediate With Padding'): Acquisition stops immediately even during a frame but the remaining of the frame will be padded with data to deliver a complete default Height frame. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 acquisitionStopMode; + /// \brief A method object. Aborts the Acquisition immediately. + /** + * Aborts the Acquisition immediately. This will end the capture without completing the current Frame or waiting on a trigger. If no Acquisition is in progress, the command is ignored. + */ + Method acquisitionAbort; + /// \brief A method object. Arms the device before an AcquisitionStart command. + /** + * Arms the device before an AcquisitionStart command. This optional command validates all the current features for consistency and prepares the device for a fast start of the Acquisition. + */ + Method acquisitionArm; + /// \brief An integer property. Number of frames to acquire in MultiFrame Acquisition mode. + /** + * Number of frames to acquire in MultiFrame Acquisition mode. + */ + PropertyI64 acquisitionFrameCount; + /// \brief An integer property. Number of frames to acquire for each FrameBurstStart trigger. + /** + * Number of frames to acquire for each FrameBurstStart trigger. + */ + PropertyI64 acquisitionBurstFrameCount; + /// \brief An integer property. Number of sensor register to access. + /** + * Number of sensor register to access. + */ + PropertyI64 mvSensorRegister; + /// \brief An integer property. Value of sensor register. + /** + * Value of sensor register. + */ + PropertyI64 mvSensorRegisterValue; + /// \brief A floating point property. Controls the acquisition rate (in Hertz) at which the frames are captured. + /** + * Controls the acquisition rate (in Hertz) at which the frames are captured. + */ + PropertyF acquisitionFrameRate; + /// \brief A boolean property. Controls if the AcquisitionFrameRate feature is writable and used to control the acquisition rate. + /** + * Controls if the AcquisitionFrameRate feature is writable and used to control the acquisition rate. Otherwise, the acquisition rate is implicitly controlled by the combination of other features like ExposureTime, etc... + */ + PropertyIBoolean acquisitionFrameRateEnable; + /// \brief A floating point property. Controls the rate (in Hertz) at which the Lines in a Frame are captured. + /** + * Controls the rate (in Hertz) at which the Lines in a Frame are captured. + */ + PropertyF acquisitionLineRate; + /// \brief A boolean property. Controls if the AcquisitionLineRate feature is writable and used to control the acquisition rate. + /** + * Controls if the AcquisitionLineRate feature is writable and used to control the acquisition rate. Otherwise, the acquisition rate is implicitly controlled by the combination of other features like ExposureTime, etc... + */ + PropertyIBoolean acquisitionLineRateEnable; + /// \brief An enumerated integer property. Selects the internal acquisition signal to read using AcquisitionStatus. + /** + * Selects the internal acquisition signal to read using AcquisitionStatus. + * + * The following string values might be valid for this feature: + * - \b AcquisitionTriggerWait (Display string: 'Acquisition Trigger Wait'): Device is currently waiting for a trigger for the capture of one or many frames. + * - \b AcquisitionActive (Display string: 'Acquisition Active'): Device is currently doing an acquisition of one or many frames. + * - \b AcquisitionTransfer (Display string: 'Acquisition Transfer'): Device is currently transferring an acquisition of one or many frames. + * - \b FrameTriggerWait (Display string: 'Frame Trigger Wait'): Device is currently waiting for a frame start trigger. + * - \b FrameActive (Display string: 'Frame Active'): Device is currently doing the capture of a frame. + * - \b ExposureActive (Display string: 'Exposure Active'): Device is doing the exposure of a frame. + * - \b FrameTransfer (Display string: 'Frame Transfer'): See TransferStatus. + * - \b FrameTransfer (Display string: 'Frame Transfer'): See TransferStatus. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 acquisitionStatusSelector; + /// \brief A boolean property. Reads the state of the internal acquisition signal selected using AcquisitionStatusSelector. + /** + * Reads the state of the internal acquisition signal selected using AcquisitionStatusSelector. + */ + PropertyIBoolean acquisitionStatus; + /// \brief An enumerated integer property. Selects the type of trigger to configure. + /** + * Selects the type of trigger to configure. + * + * The following string values might be valid for this feature: + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Selects a trigger that starts the Acquisition of one or many frames according to AcquisitionMode. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Selects a trigger that ends the Acquisition of one or many frames according to AcquisitionMode. + * - \b AcquisitionActive (Display string: 'Acquisition Active'): Selects a trigger that controls the duration of the Acquisition of one or many frames. The Acquisition is activated when the trigger signal becomes active and terminated when it goes back to the inactive state. + * - \b FrameStart (Display string: 'Frame Start'): Selects a trigger starting the capture of one frame. + * - \b FrameEnd (Display string: 'Frame End'): Selects a trigger ending the capture of one frame (mainly used in linescan mode). + * - \b FrameActive (Display string: 'Frame Active'): Selects a trigger controlling the duration of one frame (mainly used in linescan mode). + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Selects a trigger starting the capture of the bursts of frames in an acquisition. AcquisitionBurstFrameCount controls the length of each burst unless a FrameBurstEnd trigger is active. The total number of frames captured is also conditioned by AcquisitionFrameCount if AcquisitionMode is MultiFrame. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Selects a trigger ending the capture of the bursts of frames in an acquisition. + * - \b FrameBurstActive (Display string: 'Frame Burst Active'): Selects a trigger controlling the duration of the capture of the bursts of frames in an acquisition. + * - \b LineStart (Display string: 'Line Start'): Selects a trigger starting the capture of one Line of a Frame (mainly used in linescan mode). + * - \b ExposureStart (Display string: 'Exposure Start'): Selects a trigger controlling the start of the exposure of one Frame (or Line). + * - \b ExposureEnd (Display string: 'Exposure End'): Selects a trigger controlling the end of the exposure of one Frame (or Line). + * - \b ExposureActive (Display string: 'Exposure Active'): Selects a trigger controlling the duration of the exposure of one frame (or Line). + * - \b MultiSlopeExposureLimit1 (Display string: 'Multi Slope Exposure Limit 1'): Selects a trigger controlling the first duration of a multi-slope exposure. Exposure is continued according to the pre-defined multi-slope settings. + * - \b mvTimestampReset (Display string: 'mv Timestamp Reset') + * - \b mvLoopRecordEnd (Display string: 'mv Loop Record End') + * - \b mvFrameStartSensor2 (Display string: 'mv Frame Start Sensor 2') + * - \b mvInvalidTriggerSelector (Display string: 'mv Invalid Trigger Selector') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 triggerSelector; + /// \brief An enumerated integer property. Controls if the selected trigger is active. + /** + * Controls if the selected trigger is active. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disables the selected trigger. + * - \b On (Display string: 'On'): Enable the selected trigger. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 triggerMode; + /// \brief A method object. Generates an internal trigger. + /** + * Generates an internal trigger. TriggerSource must be set to Software. + */ + Method triggerSoftware; + /// \brief An enumerated integer property. Specifies the internal signal or physical input Line to use as the trigger source. + /** + * Specifies the internal signal or physical input Line to use as the trigger source. The selected trigger must have its TriggerMode set to On. + * + * The following string values might be valid for this feature: + * - \b Software (Display string: 'Software'): Specifies that the trigger source will be generated by software using the TriggerSoftware command. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Specifies that the trigger source will be a signal generated by software using the SoftwareSignalPulse command. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Specifies that the trigger source will be a signal generated by software using the SoftwareSignalPulse command. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Specifies that the trigger source will be a signal generated by software using the SoftwareSignalPulse command. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Specifies that the trigger source will be a signal generated by software using the SoftwareSignalPulse command. + * - \b Line0 (Display string: 'Line 0'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line1 (Display string: 'Line 1'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line2 (Display string: 'Line 2'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b UserOutput0 (Display string: 'User Output 0'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput1 (Display string: 'User Output 1'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput2 (Display string: 'User Output 2'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter0End (Display string: 'Counter 0 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter1End (Display string: 'Counter 1 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter2End (Display string: 'Counter 2 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer0End (Display string: 'Timer 0 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer1End (Display string: 'Timer 1 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer2End (Display string: 'Timer 2 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Encoder0 (Display string: 'Encoder 0'): Specifies which Encoder signal to use as internal source for the trigger. + * - \b Encoder1 (Display string: 'Encoder 1'): Specifies which Encoder signal to use as internal source for the trigger. + * - \b Encoder2 (Display string: 'Encoder 2'): Specifies which Encoder signal to use as internal source for the trigger. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Specifies which Encoder signal to use as internal source for the trigger. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Specifies which Logic Block signal to use as internal source for the trigger. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Specifies which Logic Block signal to use as internal source for the trigger. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Specifies which Logic Block signal to use as internal source for the trigger. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Specifies which Logic Block signal to use as internal source for the trigger. + * - \b Action0 (Display string: 'Action 0'): Specifies which Action command to use as internal source for the trigger. + * - \b Action1 (Display string: 'Action 1'): Specifies which Action command to use as internal source for the trigger. + * - \b Action2 (Display string: 'Action 2'): Specifies which Action command to use as internal source for the trigger. + * - \b Action\#3\# (Display string: 'Action \#3\#'): Specifies which Action command to use as internal source for the trigger. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Specifies which Link Trigger to use as source for the trigger (received from the transport layer). + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Specifies which Link Trigger to use as source for the trigger (received from the transport layer). + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Specifies which Link Trigger to use as source for the trigger (received from the transport layer). + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Specifies which Link Trigger to use as source for the trigger (received from the transport layer). + * - \b CC1 (Display string: 'CC 1'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC2 (Display string: 'CC 2'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC3 (Display string: 'CC 3'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC4 (Display string: 'CC 4'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC\#5\# (Display string: 'CC \#5\#'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b Line3 (Display string: 'Line 3'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line4 (Display string: 'Line 4'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line5 (Display string: 'Line 5'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line6 (Display string: 'Line 6'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line7 (Display string: 'Line 7'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line8 (Display string: 'Line 8'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line9 (Display string: 'Line 9'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line10 (Display string: 'Line 10'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line11 (Display string: 'Line 11'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line12 (Display string: 'Line 12'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line13 (Display string: 'Line 13'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line14 (Display string: 'Line 14'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Line15 (Display string: 'Line 15'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the trigger signal. + * - \b Timer3Start (Display string: 'Timer 3 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer4Start (Display string: 'Timer 4 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer5Start (Display string: 'Timer 5 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer6Start (Display string: 'Timer 6 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer7Start (Display string: 'Timer 7 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer8Start (Display string: 'Timer 8 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer9Start (Display string: 'Timer 9 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer10Start (Display string: 'Timer 10 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer11Start (Display string: 'Timer 11 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer12Start (Display string: 'Timer 12 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer13Start (Display string: 'Timer 13 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer14Start (Display string: 'Timer 14 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer15Start (Display string: 'Timer 15 Start'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer16Start (Display string: 'Timer 16 Start') + * - \b Timer3End (Display string: 'Timer 3 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer4End (Display string: 'Timer 4 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer5End (Display string: 'Timer 5 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer6End (Display string: 'Timer 6 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer7End (Display string: 'Timer 7 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer8End (Display string: 'Timer 8 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer9End (Display string: 'Timer 9 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer10End (Display string: 'Timer 10 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer11End (Display string: 'Timer 11 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer12End (Display string: 'Timer 12 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer13End (Display string: 'Timer 13 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer14End (Display string: 'Timer 14 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer15End (Display string: 'Timer 15 End'): Specifies which Timer signal to use as internal source for the trigger. + * - \b Timer16End (Display string: 'Timer 16 End') + * - \b Counter3Start (Display string: 'Counter 3 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter4Start (Display string: 'Counter 4 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter5Start (Display string: 'Counter 5 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter6Start (Display string: 'Counter 6 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter7Start (Display string: 'Counter 7 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter8Start (Display string: 'Counter 8 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter9Start (Display string: 'Counter 9 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter10Start (Display string: 'Counter 10 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter11Start (Display string: 'Counter 11 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter12Start (Display string: 'Counter 12 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter13Start (Display string: 'Counter 13 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter14Start (Display string: 'Counter 14 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter15Start (Display string: 'Counter 15 Start'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter16Start (Display string: 'Counter 16 Start') + * - \b Counter3End (Display string: 'Counter 3 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter4End (Display string: 'Counter 4 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter5End (Display string: 'Counter 5 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter6End (Display string: 'Counter 6 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter7End (Display string: 'Counter 7 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter8End (Display string: 'Counter 8 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter9End (Display string: 'Counter 9 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter10End (Display string: 'Counter 10 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter11End (Display string: 'Counter 11 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter12End (Display string: 'Counter 12 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter13End (Display string: 'Counter 13 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter14End (Display string: 'Counter 14 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter15End (Display string: 'Counter 15 End'): Specifies which of the Counter signal to use as internal source for the trigger. + * - \b Counter16End (Display string: 'Counter 16 End') + * - \b mvLogicGateOR1Output (Display string: 'mv Logic Gate OR 1 Output') + * - \b mvLogicGateOR2Output (Display string: 'mv Logic Gate OR 2 Output') + * - \b mvLogicGateOR3Output (Display string: 'mv Logic Gate OR 3 Output') + * - \b mvLogicGateOR4Output (Display string: 'mv Logic Gate OR 4 Output') + * - \b UserOutput3 (Display string: 'User Output 3'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput4 (Display string: 'User Output 4'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput5 (Display string: 'User Output 5'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput6 (Display string: 'User Output 6'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput7 (Display string: 'User Output 7'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput8 (Display string: 'User Output 8'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput9 (Display string: 'User Output 9'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput10 (Display string: 'User Output 10'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput11 (Display string: 'User Output 11'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput12 (Display string: 'User Output 12'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput13 (Display string: 'User Output 13'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput14 (Display string: 'User Output 14'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput15 (Display string: 'User Output 15'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Action3 (Display string: 'Action 3'): Specifies which Action command to use as internal source for the trigger. + * - \b Action4 (Display string: 'Action 4'): Specifies which Action command to use as internal source for the trigger. + * - \b Action5 (Display string: 'Action 5'): Specifies which Action command to use as internal source for the trigger. + * - \b Action6 (Display string: 'Action 6'): Specifies which Action command to use as internal source for the trigger. + * - \b Action7 (Display string: 'Action 7'): Specifies which Action command to use as internal source for the trigger. + * - \b Action8 (Display string: 'Action 8'): Specifies which Action command to use as internal source for the trigger. + * - \b Action9 (Display string: 'Action 9'): Specifies which Action command to use as internal source for the trigger. + * - \b Action10 (Display string: 'Action 10'): Specifies which Action command to use as internal source for the trigger. + * - \b Action11 (Display string: 'Action 11'): Specifies which Action command to use as internal source for the trigger. + * - \b Action12 (Display string: 'Action 12'): Specifies which Action command to use as internal source for the trigger. + * - \b Action13 (Display string: 'Action 13'): Specifies which Action command to use as internal source for the trigger. + * - \b Action14 (Display string: 'Action 14'): Specifies which Action command to use as internal source for the trigger. + * - \b Action15 (Display string: 'Action 15'): Specifies which Action command to use as internal source for the trigger. + * - \b Action16 (Display string: 'Action 16') + * - \b CC5 (Display string: 'CC 5'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC6 (Display string: 'CC 6'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC7 (Display string: 'CC 7'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC8 (Display string: 'CC 8'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC9 (Display string: 'CC 9'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC10 (Display string: 'CC 10'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC11 (Display string: 'CC 11'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC12 (Display string: 'CC 12'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC13 (Display string: 'CC 13'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC14 (Display string: 'CC 14'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC15 (Display string: 'CC 15'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC16 (Display string: 'CC 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 triggerSource; + /// \brief An enumerated integer property. Specifies the activation mode of the trigger. + /** + * Specifies the activation mode of the trigger. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Specifies that the trigger is considered valid on the rising edge of the source signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Specifies that the trigger is considered valid on the falling edge of the source signal. + * - \b AnyEdge (Display string: 'Any Edge'): Specifies that the trigger is considered valid on the falling or rising edge of the source signal. + * - \b LevelHigh (Display string: 'Level High'): Specifies that the trigger is considered valid as long as the level of the source signal is high. + * - \b LevelLow (Display string: 'Level Low'): Specifies that the trigger is considered valid as long as the level of the source signal is low. + * - \b mvNone (Display string: 'mv None') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 triggerActivation; + /// \brief An enumerated integer property. Specifies the type trigger overlap permitted with the previous frame or line. + /** + * Specifies the type trigger overlap permitted with the previous frame or line. This defines when a valid trigger will be accepted (or latched) for a new frame or a new line. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): No trigger overlap is permitted. + * - \b ReadOut (Display string: 'Read Out'): Trigger is accepted immediately after the exposure period. + * - \b PreviousFrame (Display string: 'Previous Frame'): Trigger is accepted (latched) at any time during the capture of the previous frame. + * - \b PreviousLine (Display string: 'Previous Line'): Trigger is accepted (latched) at any time during the capture of the previous line. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 triggerOverlap; + /// \brief A floating point property. Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + /** + * Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + */ + PropertyF triggerDelay; + /// \brief An integer property. Specifies a division factor for the incoming trigger pulses. + /** + * Specifies a division factor for the incoming trigger pulses. + */ + PropertyI64 triggerDivider; + /// \brief An integer property. Specifies a multiplication factor for the incoming trigger pulses. + /** + * Specifies a multiplication factor for the incoming trigger pulses. It is generally used in conjunction with TriggerDivider to control the ratio of triggers that are accepted. + */ + PropertyI64 triggerMultiplier; + /// \brief An enumerated integer property. Sets the operation mode of the Exposure. + /** + * Sets the operation mode of the Exposure. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disables the Exposure and let the shutter open. + * - \b Timed (Display string: 'Timed'): Timed exposure. The exposure duration time is set using the ExposureTime or ExposureAuto features and the exposure starts with the FrameStart or LineStart. + * - \b TriggerWidth (Display string: 'Trigger Width'): Uses the width of the current Frame or Line trigger signal(s) pulse to control the exposure duration. Note that if the Frame or Line TriggerActivation is RisingEdge or LevelHigh, the exposure duration will be the time the trigger stays High. If TriggerActivation is FallingEdge or LevelLow, the exposure time will last as long as the trigger stays Low. + * - \b TriggerControlled (Display string: 'Trigger Controlled'): Uses one or more trigger signal(s) to control the exposure duration independently from the current Frame or Line triggers. See ExposureStart, ExposureEnd and ExposureActive of the TriggerSelector feature. + * - \b mvMultiZone (Display string: 'mv Multi Zone'): The exposure duration time can be configured individually for different zones within the image by setting the 'ExposureTimeSelector' to one of the 'mvHorizontalZone' values. This mode will only have effect on the image when operating the device in a 'mvMultiAreaMode' different from 'mvOff'. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 exposureMode; + /// \brief An enumerated integer property. Sets the configuration mode of the ExposureTime feature. + /** + * Sets the configuration mode of the ExposureTime feature. + * + * The following string values might be valid for this feature: + * - \b Common (Display string: 'Common'): The exposure time is common to all the color components. The common ExposureTime value to use can be set selecting it with ExposureTimeSelector[Common]. + * - \b Individual (Display string: 'Individual'): The exposure time is individual for each color component. Each individual ExposureTime values to use can be set by selecting them with ExposureTimeSelector. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 exposureTimeMode; + /// \brief An enumerated integer property. Selects which exposure time is controlled by the ExposureTime feature. + /** + * Selects which exposure time is controlled by the ExposureTime feature. This allows for independent control over the exposure components. + * + * The following string values might be valid for this feature: + * - \b Common (Display string: 'Common'): Selects the common ExposureTime. + * - \b Red (Display string: 'Red'): Selects the red common ExposureTime. + * - \b Green (Display string: 'Green'): Selects the green ExposureTime. + * - \b Blue (Display string: 'Blue'): Selects the blue ExposureTime. + * - \b Cyan (Display string: 'Cyan'): Selects the cyan common ExposureTime. + * - \b Magenta (Display string: 'Magenta'): Selects the magenta ExposureTime. + * - \b Yellow (Display string: 'Yellow'): Selects the yellow ExposureTime. + * - \b Infrared (Display string: 'Infrared'): Selects the infrared ExposureTime. + * - \b Ultraviolet (Display string: 'Ultraviolet'): Selects the ultraviolet ExposureTime. + * - \b Stage1 (Display string: 'Stage 1'): Selects the first stage ExposureTime. + * - \b Stage2 (Display string: 'Stage 2'): Selects the second stage ExposureTime. + * - \b Stage\#3\# (Display string: 'Stage \#3\#'): Selects the second stage ExposureTime. + * - \b mvHorizontalZone0 (Display string: 'mv Horizontal Zone 0'): Selects the first horizontal exposure zone used when 'ExposureMode' is set to 'mvMultiZone' and when operating the device in a 'mvMultiAreaMode' different from 'mvOff'. + * - \b mvHorizontalZone1 (Display string: 'mv Horizontal Zone 1'): Selects the second horizontal exposure zone used when 'ExposureMode' is set to 'mvMultiZone' and when operating the device in a 'mvMultiAreaMode' different from 'mvOff'. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 exposureTimeSelector; + /// \brief A floating point property. Sets the Exposure time when ExposureMode is Timed and ExposureAuto is Off. + /** + * Sets the Exposure time when ExposureMode is Timed and ExposureAuto is Off. This controls the duration where the photosensitive cells are exposed to light. + */ + PropertyF exposureTime; + /// \brief A floating point property. Defines the position(in percent of the total number of lines) within the image to switch from one exposure time to the next. + /** + * Defines the position(in percent of the total number of lines) within the image to switch from one exposure time to the next. 100% means that only one zone exists. 25% means that the upper 25% of the image are defined by the exposure time of 'mvHorizontalZone0' and the lower 75% are defined by the exposure time of 'mvHorizontalZone1'. + */ + PropertyF mvExposureHorizontalZoneDivider; + /// \brief An enumerated integer property. Sets the automatic exposure mode when ExposureMode is Timed. + /** + * Sets the automatic exposure mode when ExposureMode is Timed. The exact algorithm used to implement this control is device-specific. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Exposure duration is user controlled using ExposureTime. + * - \b Once (Display string: 'Once'): Exposure duration is adapted once by the device. Once it has converged, it returns to the Off state. + * - \b Continuous (Display string: 'Continuous'): Exposure duration is constantly adapted by the device to maximize the dynamic range. + * - \b mvSequenced (Display string: 'mv Sequenced') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 exposureAuto; + /// \brief An enumerated integer property. Controls multi-slope exposure state. + /** + * Controls multi-slope exposure state. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Off + * - \b Manual (Display string: 'Manual'): Manual + * - \b PresetSoft (Display string: 'Preset Soft'): Preset Soft + * - \b PresetMedium (Display string: 'Preset Medium'): Preset Medium + * - \b PresetAggressive (Display string: 'Preset Aggressive'): Preset Aggressive + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 multiSlopeMode; + /// \brief An integer property. The number of knee-points as well as the number of additional exposure slopes used for multi-slope exposure. + /** + * The number of knee-points as well as the number of additional exposure slopes used for multi-slope exposure. + */ + PropertyI64 multiSlopeKneePointCount; + /// \brief An integer property. Selects the parameters for controlling an additional slope in multi-slope exposure. + /** + * Selects the parameters for controlling an additional slope in multi-slope exposure. + */ + PropertyI64 multiSlopeKneePointSelector; + /// \brief A floating point property. Percent of the ExposureTime at a certain knee-point of multi-slope exposure. + /** + * Percent of the ExposureTime at a certain knee-point of multi-slope exposure. + */ + PropertyF multiSlopeExposureLimit; + /// \brief A floating point property. The percentage of the full saturation that is applied at a certain knee-point of a multi-slope exposure. + /** + * The percentage of the full saturation that is applied at a certain knee-point of a multi-slope exposure. + */ + PropertyF multiSlopeSaturationThreshold; + /// \brief A floating point property. The relative intensity which divides intensities influenced by different exposure slopes. + /** + * The relative intensity which divides intensities influenced by different exposure slopes. + */ + PropertyF multiSlopeIntensityLimit; + /// \brief A floating point property. The gradient of the additional slope that is defined by this knee-point. + /** + * The gradient of the additional slope that is defined by this knee-point. + */ + PropertyF multiSlopeExposureGradient; + /// \brief An enumerated integer property. Controls the calculation of the maximum frame rate. + /** + * Controls the calculation of the maximum frame rate. + * + * The following string values might be valid for this feature: + * - \b mvDeviceLinkThroughput (Display string: 'mv Device Link Throughput'): Uses the highest possible frame rate depending on bandwidth and sensor settings. + * - \b mvDeviceMaxSensorThroughput (Display string: 'mv Device Max Sensor Throughput'): Maximum frame rate the sensor can provide depending on AOI and pixel clock. Note: Images might be buffered in the cameras memory. This can result in delayed images. + * - \b mvLegacy (Display string: 'mv Legacy'): Compatibility mode, not recommended. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvAcquisitionFrameRateLimitMode; + /// \brief An enumerated integer property. Enables the use of the 'AcquisitionFrameRate' feature. + /** + * Enables the use of the 'AcquisitionFrameRate' feature. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The acquisition frame rate is set automatically to the limit, calculated according to 'mvAcquisitionFrameRateLimitMode' feature. + * - \b On (Display string: 'On'): The acquisition frame rate is set by the 'AcquisitionFrameRate' feature. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvAcquisitionFrameRateEnable; + /// \brief A floating point property. Shows the resulting frame rate. + /** + * Shows the resulting frame rate. + */ + PropertyF mvResultingFrameRate; + /// \brief An enumerated integer property. Selects the shutter mode of the sensor. + /** + * Selects the shutter mode of the sensor. + * + * The following string values might be valid for this feature: + * - \b mvRollingShutter (Display string: 'mv Rolling Shutter') + * - \b mvGlobalReset (Display string: 'mv Global Reset') + * - \b mvGlobalShutter (Display string: 'mv Global Shutter') + * - \b mvGlobalShutterWithoutReset (Display string: 'mv Global Shutter Without Reset') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvShutterMode; + /// \brief An integer property. Knee point of 10 to 8 bit compression. + /** + * Knee point of 10 to 8 bit compression. + */ + PropertyI64 mvCompressionKneepoint; + /// \brief A floating point property. The lower limit of the exposure time in auto exposure mode. + /** + * The lower limit of the exposure time in auto exposure mode. + */ + PropertyF mvExposureAutoLowerLimit; + /// \brief A floating point property. The upper limit of the exposure time in auto exposure mode. + /** + * The upper limit of the exposure time in auto exposure mode. + */ + PropertyF mvExposureAutoUpperLimit; + /// \brief An enumerated integer property. Determines the increment or decrement size of exposure value from frame to frame. + /** + * Determines the increment or decrement size of exposure value from frame to frame. + * + * The following string values might be valid for this feature: + * - \b Slow (Display string: 'Slow') + * - \b Medium (Display string: 'Medium') + * - \b Fast (Display string: 'Fast') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvExposureAutoSpeed; + /// \brief An integer property. The number of frames that the AEC must skip before updating the exposure register. + /** + * The number of frames that the AEC must skip before updating the exposure register. + */ + PropertyI64 mvExposureAutoDelayImages; + /// \brief An integer property. Common desired average grey value (in percent) used for Auto Gain Control(AGC) and Auto Exposure Control(AEC). + /** + * Common desired average grey value (in percent) used for auto gain control(AGC) and auto exposure control (AEC). + */ + PropertyI64 mvExposureAutoAverageGrey; + /// \brief An enumerated integer property. Highlight auto control AOI to check AOI settings. Switch off for normal operation. + /** + * Highlight auto control AOI to check AOI settings. Switch off for normal operation. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b On (Display string: 'On') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvExposureAutoHighlightAOI; + /// \brief An enumerated integer property. Common AutoControl AOI used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AutoControl AOI used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + * + * The following string values might be valid for this feature: + * - \b mvFull (Display string: 'mv Full') + * - \b mvCenter (Display string: 'mv Center') + * - \b mvUser (Display string: 'mv User') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvExposureAutoAOIMode; + /// \brief An integer property. Common AOI XOffset used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI XOffset used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvExposureAutoOffsetX; + /// \brief An integer property. Common AOI YOffset used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI YOffset used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvExposureAutoOffsetY; + /// \brief An integer property. Common AOI Width used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Width used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvExposureAutoWidth; + /// \brief An integer property. Common AOI Height used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Height used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvExposureAutoHeight; + /// \brief An enumerated integer property. Selects the common auto mode for gain and exposure. + /** + * Selects the common auto mode for gain and exposure. + * + * The following string values might be valid for this feature: + * - \b mvSensor (Display string: 'mv Sensor'): The sensor itself will do the auto control. + * - \b mvDevice (Display string: 'mv Device'): The device(firmware) will do the auto control. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvExposureAutoMode; + /// \brief An enumerated integer property. Smear reduction in triggered and non-overlapped mode. + /** + * Smear reduction in triggered and non-overlapped mode. + * + * The following string values might be valid for this feature: + * - \b mvStandard (Display string: 'mv Standard'): Standard smear reduction. + * - \b mvMedium (Display string: 'mv Medium'): Medium smear reduction. + * - \b mvHighest (Display string: 'mv Highest'): Highest smear but more power consumption. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSmearReduction; + /// \brief An enumerated integer property. mvRecord is used to store frames in memory. mvPlayback transfers stored frames. mvPretrigger stores frames in memory to be transferred after trigger. + /** + * mvRecord is used to store frames in memory. mvPlayback transfers stored frames. mvPretrigger stores frames in memory to be transferred after trigger. + * + * The following string values might be valid for this feature: + * - \b Default (Display string: 'Default'): Default memory mode. + * - \b mvRecord (Display string: 'mv Record'): Stores frames in memory. + * - \b mvPlayback (Display string: 'mv Playback'): Transfers stored frames. + * - \b mvPretrigger (Display string: 'mv Pretrigger'): Stores frames in memory to be transferred after trigger. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvAcquisitionMemoryMode; + /// \brief An integer property. Number of frames to acquire before the occurrence of an AcquisitionStart or AcquisitionActive trigger. + /** + * Number of frames to acquire before the occurrence of an AcquisitionStart or AcquisitionActive trigger. + */ + PropertyI64 mvPretriggerFrameCount; + /// \brief An integer property. Maximum number of frames that can be recorded in the current configuration(deprecated, use the maximum value of 'mvAcquisitionMemoryFrameCount' instead). + /** + * \deprecated + * Maximum number of frames that can be recorded in the current configuration(deprecated, use the maximum value of 'mvAcquisitionMemoryFrameCount' instead). + */ + PropertyI64 mvAcquisitionMemoryMaxFrameCount; + /// \brief An integer property. The number of frames currently stored in the frame buffer. + /** + * The number of frames currently stored in the frame buffer. If this value keeps increasing this can indicate a bandwidth/transmission problem. + */ + PropertyI64 mvAcquisitionMemoryFrameCount; + /// \brief An integer property. AOI and/or binning parameter changed after last Acquisition. + /** + * AOI and/or binning parameter changed after last Acquisition. + */ + PropertyI64 mvAcquisitionMemoryAOIParameterChanged; + /// \brief An enumerated integer property. Enables feature mode. + /** + * Enables feature mode. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): No smart feature mode is selected + * - \b mvJPEGWithRaw (Display string: 'mv JPEG With Raw'): When active a binned raw image is sent together with a full resolution JPEG. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvFeatureMode; + /// \brief A boolean property. When active in addition to the processed image data also the unprocessed image is stored inside the devices RAM. + /** + * When active in addition to the processed image data (e.g. after binning, decimation, de-Bayering, LUT etc. applied inside the device) also the unprocessed image is stored inside the devices RAM allowing to request the transmission of these images by an application as well. This will effectively reduce the number of images that can be stored inside the frame buffer. + */ + PropertyIBoolean mvSmartFrameRecallEnable; + /// \brief An integer property. This value defines the strictness of the timestamp-check for the recalled image (given in us). + /** + * This value defines the strictness of the timestamp-check for the recalled image (given in us). + */ + PropertyI64 mvSmartFrameRecallTimestampLookupAccuracy; + /// \brief An integer property. When set to a value != 0, the smaller frames get thinned out. AOI requests can still be done for all frames. + /** + * The number of processed images to drop, i.e. skip. This can be used to reduce the frame rate even further. AOIs for unsent images can still be requested - the timestamps for these dropped images must be interpolated. + */ + PropertyI64 mvSmartFrameRecallFrameSkipRatio; + /// \brief A boolean property. Enables or disables lens calibration. + /** + * When active lens calibration will be applied to the image. The calibration data must have been correctly calculated for the scene and loaded into device memory using, for example, the file interface with filename 'mvLensCalibrationBlocks' and 'mvLensCalibrationPixels'. This will effectively reduce the number of images that can be stored inside the frame buffer. + */ + PropertyIBoolean mvLensCalibrationEnable; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Analog control features. +/** + * A category that contains the Analog control features. + * \ingroup GenICamInterfaceDevice + */ +class AnalogControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::AnalogControl object. + explicit AnalogControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvTapBalancingMode(), + mvGainMode(), + gainSelector(), + gain(), + mvGainHorizontalZoneDivider(), + gainAuto(), + gainAutoBalance(), + blackLevelSelector(), + blackLevel(), + blackLevelAuto(), + blackLevelAutoBalance(), + whiteClipSelector(), + whiteClip(), + balanceRatioSelector(), + balanceRatio(), + balanceWhiteAuto(), + mvGainAutoDelayImages(), + mvGainAutoUpperLimit(), + mvGainAutoLowerLimit(), + mvGainAutoSpeed(), + mvGainAutoAverageGrey(), + mvGainAutoHighlightAOI(), + mvGainAutoAOIMode(), + mvGainAutoOffsetX(), + mvGainAutoOffsetY(), + mvGainAutoWidth(), + mvGainAutoHeight(), + mvGainAutoMode(), + mvBalanceWhiteAutoAOIMode(), + mvBalanceWhiteAutoOffsetX(), + mvBalanceWhiteAutoOffsetY(), + mvBalanceWhiteAutoWidth(), + mvBalanceWhiteAutoHeight(), + mvLowLight(), + mvADCGain(), + mvVRamp(), + mvLinearLogarithmicMode(), + mvDigitalGainOffset(), + mvSaveCalibrationData(), + mvGammaEnable(), + mvGammaSelector(), + gamma() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( mvTapBalancingMode, "mvTapBalancingMode" ); + locator.bindComponent( mvGainMode, "mvGainMode" ); + locator.bindComponent( gainSelector, "GainSelector" ); + locator.bindComponent( gain, "Gain" ); + if( !gain.isValid() ) + { + locator.bindComponent( gain, "GainAbs" ); + } + locator.bindComponent( mvGainHorizontalZoneDivider, "mvGainHorizontalZoneDivider" ); + locator.bindComponent( gainAuto, "GainAuto" ); + locator.bindComponent( gainAutoBalance, "GainAutoBalance" ); + locator.bindComponent( blackLevelSelector, "BlackLevelSelector" ); + locator.bindComponent( blackLevel, "BlackLevel" ); + if( !blackLevel.isValid() ) + { + locator.bindComponent( blackLevel, "BlackLevelAbs" ); + } + locator.bindComponent( blackLevelAuto, "BlackLevelAuto" ); + locator.bindComponent( blackLevelAutoBalance, "BlackLevelAutoBalance" ); + locator.bindComponent( whiteClipSelector, "WhiteClipSelector" ); + locator.bindComponent( whiteClip, "WhiteClip" ); + if( !whiteClip.isValid() ) + { + locator.bindComponent( whiteClip, "WhiteClipAbs" ); + } + locator.bindComponent( balanceRatioSelector, "BalanceRatioSelector" ); + locator.bindComponent( balanceRatio, "BalanceRatio" ); + if( !balanceRatio.isValid() ) + { + locator.bindComponent( balanceRatio, "BalanceRatioAbs" ); + } + locator.bindComponent( balanceWhiteAuto, "BalanceWhiteAuto" ); + locator.bindComponent( mvGainAutoDelayImages, "mvGainAutoDelayImages" ); + locator.bindComponent( mvGainAutoUpperLimit, "mvGainAutoUpperLimit" ); + locator.bindComponent( mvGainAutoLowerLimit, "mvGainAutoLowerLimit" ); + locator.bindComponent( mvGainAutoSpeed, "mvGainAutoSpeed" ); + locator.bindComponent( mvGainAutoAverageGrey, "mvGainAutoAverageGrey" ); + locator.bindComponent( mvGainAutoHighlightAOI, "mvGainAutoHighlightAOI" ); + locator.bindComponent( mvGainAutoAOIMode, "mvGainAutoAOIMode" ); + locator.bindComponent( mvGainAutoOffsetX, "mvGainAutoOffsetX" ); + locator.bindComponent( mvGainAutoOffsetY, "mvGainAutoOffsetY" ); + locator.bindComponent( mvGainAutoWidth, "mvGainAutoWidth" ); + locator.bindComponent( mvGainAutoHeight, "mvGainAutoHeight" ); + locator.bindComponent( mvGainAutoMode, "mvGainAutoMode" ); + locator.bindComponent( mvBalanceWhiteAutoAOIMode, "mvBalanceWhiteAutoAOIMode" ); + locator.bindComponent( mvBalanceWhiteAutoOffsetX, "mvBalanceWhiteAutoOffsetX" ); + locator.bindComponent( mvBalanceWhiteAutoOffsetY, "mvBalanceWhiteAutoOffsetY" ); + locator.bindComponent( mvBalanceWhiteAutoWidth, "mvBalanceWhiteAutoWidth" ); + locator.bindComponent( mvBalanceWhiteAutoHeight, "mvBalanceWhiteAutoHeight" ); + locator.bindComponent( mvLowLight, "mvLowLight" ); + locator.bindComponent( mvADCGain, "mvADCGain" ); + locator.bindComponent( mvVRamp, "mvVRamp" ); + locator.bindComponent( mvLinearLogarithmicMode, "mvLinearLogarithmicMode" ); + locator.bindComponent( mvDigitalGainOffset, "mvDigitalGainOffset" ); + locator.bindComponent( mvSaveCalibrationData, "mvSaveCalibrationData@i" ); + locator.bindComponent( mvGammaEnable, "mvGammaEnable" ); + locator.bindComponent( mvGammaSelector, "mvGammaSelector" ); + locator.bindComponent( gamma, "Gamma" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Where do the tap balancing calibration data come from? + /** + * Where do the tap balancing calibration data come from? + * + * The following string values might be valid for this feature: + * - \b mvFactory (Display string: 'mv Factory') + * - \b mvUser (Display string: 'mv User') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvTapBalancingMode; + /// \brief An enumerated integer property. Sets the operation mode of Gain. + /** + * Sets the operation mode of Gain + * + * The following string values might be valid for this feature: + * - \b Default (Display string: 'Default'): Default operation mode. The whole image is configured as a single zone. + * - \b mvMultiZone (Display string: 'mv Multi Zone'): In this mode different gains can be applied to different zones of the image by writing them into the 'mvHorizontalZone' registers selectable via the 'GainSelector'. This mode will only have effect on the image when operating the device in a 'mvMultiAreaMode' different from 'mvOff'. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGainMode; + /// \brief An enumerated integer property. Selects which Gain is controlled by the various Gain features. + /** + * Selects which Gain is controlled by the various Gain features. + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): Gain will be applied to all channels or taps. + * - \b Red (Display string: 'Red'): Gain will be applied to the red channel. + * - \b Green (Display string: 'Green'): Gain will be applied to the green channel. + * - \b Blue (Display string: 'Blue'): Gain will be applied to the blue channel. + * - \b Y (Display string: 'Y'): Gain will be applied to Y channel. + * - \b U (Display string: 'U'): Gain will be applied to U channel. + * - \b V (Display string: 'V'): Gain will be applied to V channel. + * - \b Tap1 (Display string: 'Tap 1'): Gain will be applied to Tap 1. + * - \b Tap2 (Display string: 'Tap 2'): Gain will be applied to Tap 2. + * - \b Tap\#3\# (Display string: 'Tap \#3\#'): Gain will be applied to Tap \#3\#. + * - \b AnalogAll (Display string: 'Analog All'): Gain will be applied to all analog channels or taps. + * - \b AnalogRed (Display string: 'Analog Red'): Gain will be applied to the red analog channel. + * - \b AnalogGreen (Display string: 'Analog Green'): Gain will be applied to the green analog channel. + * - \b AnalogBlue (Display string: 'Analog Blue'): Gain will be applied to the blue analog channel. + * - \b AnalogY (Display string: 'Analog Y'): Gain will be applied to Y analog channel. + * - \b AnalogU (Display string: 'Analog U'): Gain will be applied to U analog channel. + * - \b AnalogV (Display string: 'Analog V'): Gain will be applied to V analog channel. + * - \b AnalogTap1 (Display string: 'Analog Tap 1'): Analog gain will be applied to Tap 1. + * - \b AnalogTap2 (Display string: 'Analog Tap 2'): Analog gain will be applied to Tap 2. + * - \b AnalogTap\#3\# (Display string: 'Analog Tap \#3\#'): Analog gain will be applied to Tap \#3\#. + * - \b DigitalAll (Display string: 'Digital All'): Gain will be applied to all digital channels or taps. + * - \b DigitalRed (Display string: 'Digital Red'): Gain will be applied to the red digital channel. + * - \b DigitalGreen (Display string: 'Digital Green'): Gain will be applied to the green digital channel. + * - \b DigitalBlue (Display string: 'Digital Blue'): Gain will be applied to the blue digital channel. + * - \b DigitalY (Display string: 'Digital Y'): Gain will be applied to Y digital channel. + * - \b DigitalU (Display string: 'Digital U'): Gain will be applied to U digital channel. + * - \b DigitalV (Display string: 'Digital V'): Gain will be applied to V digital channel. + * - \b DigitalTap1 (Display string: 'Digital Tap 1'): Digital gain will be applied to Tap 1. + * - \b DigitalTap2 (Display string: 'Digital Tap 2'): Digital gain will be applied to Tap 2. + * - \b DigitalTap\#3\# (Display string: 'Digital Tap \#3\#'): Digital gain will be applied to Tap \#3\#. + * - \b Tap3 (Display string: 'Tap 3'): Gain will be applied to Tap 3. + * - \b Tap4 (Display string: 'Tap 4'): Gain will be applied to Tap 4. + * - \b Tap5 (Display string: 'Tap 5'): Gain will be applied to Tap 5. + * - \b Tap6 (Display string: 'Tap 6'): Gain will be applied to Tap 6. + * - \b Tap7 (Display string: 'Tap 7'): Gain will be applied to Tap 7. + * - \b Tap8 (Display string: 'Tap 8'): Gain will be applied to Tap 8. + * - \b Tap9 (Display string: 'Tap 9'): Gain will be applied to Tap 9. + * - \b Tap10 (Display string: 'Tap 10'): Gain will be applied to Tap 10. + * - \b Tap11 (Display string: 'Tap 11'): Gain will be applied to Tap 11. + * - \b Tap12 (Display string: 'Tap 12'): Gain will be applied to Tap 12. + * - \b Tap13 (Display string: 'Tap 13'): Gain will be applied to Tap 13. + * - \b Tap14 (Display string: 'Tap 14'): Gain will be applied to Tap 14. + * - \b Tap15 (Display string: 'Tap 15'): Gain will be applied to Tap 15. + * - \b Tap16 (Display string: 'Tap 16') + * - \b AnalogTap3 (Display string: 'Analog Tap 3'): Analog gain will be applied to Tap 3. + * - \b AnalogTap4 (Display string: 'Analog Tap 4'): Analog gain will be applied to Tap 4. + * - \b AnalogTap5 (Display string: 'Analog Tap 5'): Analog gain will be applied to Tap 5. + * - \b AnalogTap6 (Display string: 'Analog Tap 6'): Analog gain will be applied to Tap 6. + * - \b AnalogTap7 (Display string: 'Analog Tap 7'): Analog gain will be applied to Tap 7. + * - \b AnalogTap8 (Display string: 'Analog Tap 8'): Analog gain will be applied to Tap 8. + * - \b AnalogTap9 (Display string: 'Analog Tap 9'): Analog gain will be applied to Tap 9. + * - \b AnalogTap10 (Display string: 'Analog Tap 10'): Analog gain will be applied to Tap 10. + * - \b AnalogTap11 (Display string: 'Analog Tap 11'): Analog gain will be applied to Tap 11. + * - \b AnalogTap12 (Display string: 'Analog Tap 12'): Analog gain will be applied to Tap 12. + * - \b AnalogTap13 (Display string: 'Analog Tap 13'): Analog gain will be applied to Tap 13. + * - \b AnalogTap14 (Display string: 'Analog Tap 14'): Analog gain will be applied to Tap 14. + * - \b AnalogTap15 (Display string: 'Analog Tap 15'): Analog gain will be applied to Tap 15. + * - \b AnalogTap16 (Display string: 'Analog Tap 16') + * - \b DigitalTap3 (Display string: 'Digital Tap 3'): Digital gain will be applied to Tap 3. + * - \b DigitalTap4 (Display string: 'Digital Tap 4'): Digital gain will be applied to Tap 4. + * - \b DigitalTap5 (Display string: 'Digital Tap 5'): Digital gain will be applied to Tap 5. + * - \b DigitalTap6 (Display string: 'Digital Tap 6'): Digital gain will be applied to Tap 6. + * - \b DigitalTap7 (Display string: 'Digital Tap 7'): Digital gain will be applied to Tap 7. + * - \b DigitalTap8 (Display string: 'Digital Tap 8'): Digital gain will be applied to Tap 8. + * - \b DigitalTap9 (Display string: 'Digital Tap 9'): Digital gain will be applied to Tap 9. + * - \b DigitalTap10 (Display string: 'Digital Tap 10'): Digital gain will be applied to Tap 10. + * - \b DigitalTap11 (Display string: 'Digital Tap 11'): Digital gain will be applied to Tap 11. + * - \b DigitalTap12 (Display string: 'Digital Tap 12'): Digital gain will be applied to Tap 12. + * - \b DigitalTap13 (Display string: 'Digital Tap 13'): Digital gain will be applied to Tap 13. + * - \b DigitalTap14 (Display string: 'Digital Tap 14'): Digital gain will be applied to Tap 14. + * - \b DigitalTap15 (Display string: 'Digital Tap 15'): Digital gain will be applied to Tap 15. + * - \b DigitalTap16 (Display string: 'Digital Tap 16') + * - \b mvAnalogSensorA (Display string: 'mv Analog Sensor A') + * - \b mvAnalogSensorB (Display string: 'mv Analog Sensor B') + * - \b mvHorizontalZone0 (Display string: 'mv Horizontal Zone 0'): Selects the first horizontal gain zone used when 'mvGainMode' is set to 'mvMultiZone' and when operating the device in a 'mvMultiAreaMode' different from 'mvOff'. + * - \b mvHorizontalZone1 (Display string: 'mv Horizontal Zone 1'): Selects the second horizontal gain zone used when 'mvGainMode' is set to 'mvMultiZone' and when operating the device in a 'mvMultiAreaMode' different from 'mvOff'. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gainSelector; + /// \brief A floating point property. Controls the selected gain as an absolute physical value. + /** + * Controls the selected gain as an absolute physical value. This is an amplification factor applied to the video signal. + */ + PropertyF gain; + /// \brief A floating point property. Defines the position(in percent of the total number of lines) within the image to switch from one gain value to the next. + /** + * Defines the position(in percent of the total number of lines) within the image to switch from one gain value to the next. 100% means that only one zone exists. 25% means that the upper 25% of the image are defined by the gain value of 'mvHorizontalZone0' and the lower 75% are defined by the gain value of 'mvHorizontalZone1'. Some sensors may only allow to change the gain at certain positions e.g. the last line of a defined ROI. In this case the first possible switching point above the actual line will be used. + */ + PropertyF mvGainHorizontalZoneDivider; + /// \brief An enumerated integer property. Sets the automatic gain control (AGC) mode. + /** + * Sets the automatic gain control (AGC) mode. The exact algorithm used to implement AGC is device-specific. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Gain is User controlled using Gain. + * - \b Once (Display string: 'Once'): Gain is automatically adjusted once by the device. Once it has converged, it automatically returns to the Off state. + * - \b Continuous (Display string: 'Continuous'): Gain is constantly adjusted by the device. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gainAuto; + /// \brief An enumerated integer property. Sets the mode for automatic gain balancing between the sensor color channels or taps. + /** + * Sets the mode for automatic gain balancing between the sensor color channels or taps. The gain coefficients of each channel or tap are adjusted so they are matched. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Gain tap balancing is user controlled using Gain . + * - \b Once (Display string: 'Once'): Gain tap balancing is automatically adjusted once by the device. Once it has converged, it automatically returns to the Off state. + * - \b Continuous (Display string: 'Continuous'): Gain tap balancing is constantly adjusted by the device. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gainAutoBalance; + /// \brief An enumerated integer property. Selects which Black Level is controlled by the various Black Level features. + /** + * Selects which Black Level is controlled by the various Black Level features. + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): Black Level will be applied to all channels or taps. + * - \b Red (Display string: 'Red'): Black Level will be applied to the red channel. + * - \b Green (Display string: 'Green'): Black Level will be applied to the green channel. + * - \b Blue (Display string: 'Blue'): Black Level will be applied to the blue channel. + * - \b Y (Display string: 'Y'): Black Level will be applied to Y channel. + * - \b U (Display string: 'U'): Black Level will be applied to U channel. + * - \b V (Display string: 'V'): Black Level will be applied to V channel. + * - \b Tap1 (Display string: 'Tap 1'): Black Level will be applied to Tap 1. + * - \b Tap2 (Display string: 'Tap 2'): Black Level will be applied to Tap 2. + * - \b Tap\#3\# (Display string: 'Tap \#3\#'): Black Level will be applied to Tap \#3\#. + * - \b Tap3 (Display string: 'Tap 3'): Black Level will be applied to Tap 3. + * - \b Tap4 (Display string: 'Tap 4'): Black Level will be applied to Tap 4. + * - \b Tap5 (Display string: 'Tap 5'): Black Level will be applied to Tap 5. + * - \b Tap6 (Display string: 'Tap 6'): Black Level will be applied to Tap 6. + * - \b Tap7 (Display string: 'Tap 7'): Black Level will be applied to Tap 7. + * - \b Tap8 (Display string: 'Tap 8'): Black Level will be applied to Tap 8. + * - \b Tap9 (Display string: 'Tap 9'): Black Level will be applied to Tap 9. + * - \b Tap10 (Display string: 'Tap 10'): Black Level will be applied to Tap 10. + * - \b Tap11 (Display string: 'Tap 11'): Black Level will be applied to Tap 11. + * - \b Tap12 (Display string: 'Tap 12'): Black Level will be applied to Tap 12. + * - \b Tap13 (Display string: 'Tap 13'): Black Level will be applied to Tap 13. + * - \b Tap14 (Display string: 'Tap 14'): Black Level will be applied to Tap 14. + * - \b Tap15 (Display string: 'Tap 15'): Black Level will be applied to Tap 15. + * - \b Tap16 (Display string: 'Tap 16') + * - \b mvAnalogSensorA (Display string: 'mv Analog Sensor A') + * - \b mvAnalogSensorB (Display string: 'mv Analog Sensor B') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 blackLevelSelector; + /// \brief A floating point property. Controls the analog black level as an absolute physical value. + /** + * Controls the analog black level as an absolute physical value. This represents a DC offset applied to the video signal. + */ + PropertyF blackLevel; + /// \brief An enumerated integer property. Controls the mode for automatic black level adjustment. + /** + * Controls the mode for automatic black level adjustment. The exact algorithm used to implement this adjustment is device-specific. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Analog black level is user controlled using BlackLevel. + * - \b Once (Display string: 'Once'): Analog black level is automatically adjusted once by the device. Once it has converged, it automatically returns to the Off state. + * - \b Continuous (Display string: 'Continuous'): Analog black level is constantly adjusted by the device. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 blackLevelAuto; + /// \brief An enumerated integer property. Controls the mode for automatic black level balancing between the sensor color channels or taps. + /** + * Controls the mode for automatic black level balancing between the sensor color channels or taps. The black level coefficients of each channel are adjusted so they are matched. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Black level tap balancing is user controlled using BlackLevel. + * - \b Once (Display string: 'Once'): Black level tap balancing is automatically adjusted once by the device. Once it has converged, it automatically returns to the Off state. + * - \b Continuous (Display string: 'Continuous'): Black level tap balancing is constantly adjusted by the device. + * - \b mvRaw (Display string: 'mv Raw') + * - \b mvFixed (Display string: 'mv Fixed') + * - \b mvLowerLine (Display string: 'mv Lower Line') + * - \b mvSlow (Display string: 'mv Slow') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 blackLevelAutoBalance; + /// \brief An enumerated integer property. Selects which White Clip to control. + /** + * Selects which White Clip to control. + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): White Clip will be applied to all channels or taps. + * - \b Red (Display string: 'Red'): White Clip will be applied to the red channel. + * - \b Green (Display string: 'Green'): White Clip will be applied to the green channel. + * - \b Blue (Display string: 'Blue'): White Clip will be applied to the blue channel. + * - \b Y (Display string: 'Y'): White Clip will be applied to Y channel. + * - \b U (Display string: 'U'): White Clip will be applied to U channel. + * - \b V (Display string: 'V'): White Clip will be applied to V channel. + * - \b Tap1 (Display string: 'Tap 1'): White Clip will be applied to Tap 1. + * - \b Tap2 (Display string: 'Tap 2'): White Clip will be applied to Tap 2. + * - \b Tap\#3\# (Display string: 'Tap \#3\#'): White Clip will be applied to Tap \#3\#. + * - \b Tap3 (Display string: 'Tap 3'): White Clip will be applied to Tap 3. + * - \b Tap4 (Display string: 'Tap 4'): White Clip will be applied to Tap 4. + * - \b Tap5 (Display string: 'Tap 5'): White Clip will be applied to Tap 5. + * - \b Tap6 (Display string: 'Tap 6'): White Clip will be applied to Tap 6. + * - \b Tap7 (Display string: 'Tap 7'): White Clip will be applied to Tap 7. + * - \b Tap8 (Display string: 'Tap 8'): White Clip will be applied to Tap 8. + * - \b Tap9 (Display string: 'Tap 9'): White Clip will be applied to Tap 9. + * - \b Tap10 (Display string: 'Tap 10'): White Clip will be applied to Tap 10. + * - \b Tap11 (Display string: 'Tap 11'): White Clip will be applied to Tap 11. + * - \b Tap12 (Display string: 'Tap 12'): White Clip will be applied to Tap 12. + * - \b Tap13 (Display string: 'Tap 13'): White Clip will be applied to Tap 13. + * - \b Tap14 (Display string: 'Tap 14'): White Clip will be applied to Tap 14. + * - \b Tap15 (Display string: 'Tap 15'): White Clip will be applied to Tap 15. + * - \b Tap16 (Display string: 'Tap 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 whiteClipSelector; + /// \brief A floating point property. Controls the maximal intensity taken by the video signal before being clipped as an absolute physical value. + /** + * Controls the maximal intensity taken by the video signal before being clipped as an absolute physical value. The video signal will never exceed the white clipping point: it will saturate at that level. + */ + PropertyF whiteClip; + /// \brief An enumerated integer property. Selects which Balance ratio to control. + /** + * Selects which Balance ratio to control. + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): Balance Ratio will be applied to all channels or taps. + * - \b Red (Display string: 'Red'): Balance Ratio will be applied to the red channel. + * - \b Green (Display string: 'Green'): Balance Ratio will be applied to the green channel. + * - \b Blue (Display string: 'Blue'): Balance Ratio will be applied to the blue channel. + * - \b Y (Display string: 'Y'): Balance Ratio will be applied to Y channel. + * - \b U (Display string: 'U'): Balance Ratio will be applied to U channel. + * - \b V (Display string: 'V'): Balance Ratio will be applied to V channel. + * - \b Tap1 (Display string: 'Tap 1'): Balance Ratio will be applied to Tap 1. + * - \b Tap2 (Display string: 'Tap 2'): Balance Ratio will be applied to Tap 2. + * - \b Tap\#3\# (Display string: 'Tap \#3\#'): Balance Ratio will be applied to Tap \#3\#. + * - \b Green0 (Display string: 'Green 0') + * - \b Green1 (Display string: 'Green 1') + * - \b Tap3 (Display string: 'Tap 3'): Balance Ratio will be applied to Tap 3. + * - \b Tap4 (Display string: 'Tap 4'): Balance Ratio will be applied to Tap 4. + * - \b Tap5 (Display string: 'Tap 5'): Balance Ratio will be applied to Tap 5. + * - \b Tap6 (Display string: 'Tap 6'): Balance Ratio will be applied to Tap 6. + * - \b Tap7 (Display string: 'Tap 7'): Balance Ratio will be applied to Tap 7. + * - \b Tap8 (Display string: 'Tap 8'): Balance Ratio will be applied to Tap 8. + * - \b Tap9 (Display string: 'Tap 9'): Balance Ratio will be applied to Tap 9. + * - \b Tap10 (Display string: 'Tap 10'): Balance Ratio will be applied to Tap 10. + * - \b Tap11 (Display string: 'Tap 11'): Balance Ratio will be applied to Tap 11. + * - \b Tap12 (Display string: 'Tap 12'): Balance Ratio will be applied to Tap 12. + * - \b Tap13 (Display string: 'Tap 13'): Balance Ratio will be applied to Tap 13. + * - \b Tap14 (Display string: 'Tap 14'): Balance Ratio will be applied to Tap 14. + * - \b Tap15 (Display string: 'Tap 15'): Balance Ratio will be applied to Tap 15. + * - \b Tap16 (Display string: 'Tap 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 balanceRatioSelector; + /// \brief A floating point property. Controls ratio of the selected color component to a reference color component. + /** + * Controls ratio of the selected color component to a reference color component. It is used for white balancing. + */ + PropertyF balanceRatio; + /// \brief An enumerated integer property. Controls the mode for automatic white balancing between the color channels. + /** + * Controls the mode for automatic white balancing between the color channels. The white balancing ratios are automatically adjusted. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): White balancing is user controlled using BalanceRatioSelector and BalanceRatio. + * - \b Once (Display string: 'Once'): White balancing is automatically adjusted once by the device. Once it has converged, it automatically returns to the Off state. + * - \b Continuous (Display string: 'Continuous'): White balancing is constantly adjusted by the device. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 balanceWhiteAuto; + /// \brief An integer property. The number of frames that the AEC must skip before updating the exposure register + /** + * The number of frames that the AEC must skip before updating the exposure register + */ + PropertyI64 mvGainAutoDelayImages; + /// \brief A floating point property. The upper limit of the gain in auto gain mode + /** + * The upper limit of the gain in auto gain mode + */ + PropertyF mvGainAutoUpperLimit; + /// \brief A floating point property. The lower limit of the gain in auto gain mode + /** + * The lower limit of the gain in auto gain mode + */ + PropertyF mvGainAutoLowerLimit; + /// \brief An enumerated integer property. Determines the increment or decrement size of gain value from frame to frame. + /** + * Determines the increment or decrement size of gain value from frame to frame. + * + * The following string values might be valid for this feature: + * - \b Slow (Display string: 'Slow') + * - \b Medium (Display string: 'Medium') + * - \b Fast (Display string: 'Fast') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGainAutoSpeed; + /// \brief An integer property. Common desired average grey value (in percent) used for Auto Gain Control(AGC) and Auto Exposure Control(AEC). + /** + * Common desired average grey value (in percent) used for Auto Gain Control(AGC) and Auto Exposure Control(AEC). + */ + PropertyI64 mvGainAutoAverageGrey; + /// \brief An enumerated integer property. Highlight auto control AOI to check AOI settings. Switch off for normal operation. + /** + * Highlight auto control AOI to check AOI settings. Switch off for normal operation. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b On (Display string: 'On') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGainAutoHighlightAOI; + /// \brief An enumerated integer property. Common AutoControl AOI used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balancing. + /** + * Common AutoControl AOI used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balancing. + * + * The following string values might be valid for this feature: + * - \b mvFull (Display string: 'mv Full') + * - \b mvCenter (Display string: 'mv Center') + * - \b mvUser (Display string: 'mv User') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGainAutoAOIMode; + /// \brief An integer property. Common AOI X-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI X-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvGainAutoOffsetX; + /// \brief An integer property. Common AOI Y-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Y-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvGainAutoOffsetY; + /// \brief An integer property. Common AOI Width used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Width used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvGainAutoWidth; + /// \brief An integer property. Common AOI Height used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Height used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvGainAutoHeight; + /// \brief An enumerated integer property. Selects the common auto mode for gain and exposure. + /** + * Selects the common auto mode for gain and exposure. + * + * The following string values might be valid for this feature: + * - \b mvSensor (Display string: 'mv Sensor'): The sensor itself will do the auto control. + * - \b mvDevice (Display string: 'mv Device'): The device(firmware) will do the auto control. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGainAutoMode; + /// \brief An enumerated integer property. Common AutoControl AOI used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AutoControl AOI used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + * + * The following string values might be valid for this feature: + * - \b mvFull (Display string: 'mv Full') + * - \b mvCenter (Display string: 'mv Center') + * - \b mvUser (Display string: 'mv User') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvBalanceWhiteAutoAOIMode; + /// \brief An integer property. Common AOI X-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI XOffset used for auto gain control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvBalanceWhiteAutoOffsetX; + /// \brief An integer property. Common AOI Y-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Y-Offset used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvBalanceWhiteAutoOffsetY; + /// \brief An integer property. Common AOI Width used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Width used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvBalanceWhiteAutoWidth; + /// \brief An integer property. Common AOI Height used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + /** + * Common AOI Height used for Auto Gain Control(AGC), Auto Exposure Control(AEC) and Auto White Balance(AWB). + */ + PropertyI64 mvBalanceWhiteAutoHeight; + /// \brief An enumerated integer property. Makes the image brighter. + /** + * Makes the image brighter. + * + * The following string values might be valid for this feature: + * - \b On (Display string: 'On') + * - \b Off (Display string: 'Off') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLowLight; + /// \brief An integer property. Adapt gain. Gain value of the sensor may differ from sensor to sensor. + /** + * Adapt gain. Gain value of the sensor may differ from sensor to sensor. + */ + PropertyI64 mvADCGain; + /// \brief An integer property. Adjusting this value will result in better column CDS (correlated double sampling) which will remove the column FPN from the image. + /** + * Adjusting this value will result in better column CDS (correlated double sampling) which will remove the column FPN from the image. + */ + PropertyI64 mvVRamp; + /// \brief An integer property. Controls the knee point between linear response and logarithmic response. + /** + * Controls the knee point between linear response and logarithmic response. + */ + PropertyI64 mvLinearLogarithmicMode; + /// \brief An integer property. Used for fine tuning of the brightness of the sensor. + /** + * Used for fine tuning of the brightness of the sensor. + */ + PropertyI64 mvDigitalGainOffset; + /// \brief A method object. Saves the calibration data to non-volatile memory. + /** + * Saves the calibration data to non-volatile memory. + */ + Method mvSaveCalibrationData; + /// \brief A boolean property. Enables Gamma correction. All other LUT will be disabled. + /** + * Enables gamma correction. All other LUT will be disabled. + */ + PropertyIBoolean mvGammaEnable; + /// \brief An enumerated integer property. Sets the type of Gamma to be used. + /** + * Sets the type of Gamma to be used. + * + * The following string values might be valid for this feature: + * - \b mvSRGB (Display string: 'mv SRGB'): Gamma curve is fixed to a sRGB curve. + * - \b mvUser (Display string: 'mv User'): Gamma curve can be configured by user. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGammaSelector; + /// \brief A floating point property. Controls the gamma correction of pixel intensity. + /** + * Controls the gamma correction of pixel intensity. + * Since the human eye perceives light similar to a logarithm of real light intensity it's characteristic curve is + * non-linear. It follows the rule of (intensity ^ gamma) with a gamma value between 0.3-0.5. + * To provide as much useful information as possible, the image is converted from 12-bit acquired by the sensor to 8-bit utilizing + * this characteristic curve. The result is a linearized image optimized for the human eye's non-linear behavior which allows + * to perceive as much intensity differences as possible. + * \image html Gamma_correction_camera.png +
Conversion from 12- to 8-bit utilizing the gamma function
+ */ + PropertyF gamma; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that includes the LUT control features. +/** + * A category that includes the LUT control features. + * \ingroup GenICamInterfaceDevice + */ +class LUTControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::LUTControl object. + explicit LUTControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + LUTSelector(), + LUTEnable(), + LUTIndex(), + LUTValue(), + LUTValueAll(), + mvLUTType(), + mvLUTInputData(), + mvLUTMapping() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( LUTSelector, "LUTSelector" ); + locator.bindComponent( LUTEnable, "LUTEnable" ); + locator.bindComponent( LUTIndex, "LUTIndex" ); + locator.bindComponent( LUTValue, "LUTValue" ); + locator.bindComponent( LUTValueAll, "LUTValueAll" ); + locator.bindComponent( mvLUTType, "mvLUTType" ); + locator.bindComponent( mvLUTInputData, "mvLUTInputData" ); + locator.bindComponent( mvLUTMapping, "mvLUTMapping" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which LUT to control. + /** + * Selects which LUT to control. + * + * The following string values might be valid for this feature: + * - \b Luminance (Display string: 'Luminance'): Selects the Luminance LUT. + * - \b Red (Display string: 'Red'): Selects the Red LUT. + * - \b Green (Display string: 'Green'): Selects the Green LUT. + * - \b Blue (Display string: 'Blue'): Selects the Blue LUT. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 LUTSelector; + /// \brief A boolean property. Activates the selected LUT. + /** + * Activates the selected LUT. + */ + PropertyIBoolean LUTEnable; + /// \brief An integer property. Control the index (offset) of the coefficient to access in the selected LUT. + /** + * Control the index (offset) of the coefficient to access in the selected LUT. + */ + PropertyI64 LUTIndex; + /// \brief An integer property. Returns the Value at entry LUTIndex of the LUT selected by LUTSelector. + /** + * Returns the Value at entry LUTIndex of the LUT selected by LUTSelector. + */ + PropertyI64 LUTValue; + /// \brief A string property. Accesses all the LUT coefficients in a single access without using individual LUTIndex. + /** + * Accesses all the LUT coefficients in a single access without using individual LUTIndex. + */ + PropertyS LUTValueAll; + /// \brief An enumerated integer property. Describes the type of LUT used. + /** + * Describes the type of LUT used. + * + * The following string values might be valid for this feature: + * - \b Direct (Display string: 'Direct'): The user can define an output value for each input value of the LUT. + * - \b Interpolated (Display string: 'Interpolated'): The user can define the output values for equidistant nodes in the LUT. Linear interpolation is used to determine the output values for input values that lie in between the given nodes. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLUTType; + /// \brief An enumerated integer property. Describes the data the LUT is operating on + /** + * Describes the data the LUT is operating on + * + * The following string values might be valid for this feature: + * - \b Bayer (Display string: 'Bayer'): The LUT is operating on raw Bayer data (i.e. before debayering) + * - \b Gray (Display string: 'Gray'): The LUT is operating on gray data + * - \b RGB (Display string: 'RGB'): The LUT is operating on RGB data (i.e. after debayering) + * - \b DeviceSpecific (Display string: 'Device Specific'): The LUT is operating on device specific data + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLUTInputData; + /// \brief An enumerated integer property. Describes mapping of the LUT + /** + * Describes the mapping of the LUT + * + * The following string values might be valid for this feature: + * - \b map_8To12 (Display string: 'map 8 To 12'): The LUT maps 8 bit input data to 12 bit output data. + * - \b map_10To12 (Display string: 'map 10 To 12'): The LUT maps 10 bit input data to 12 bit output data. + * - \b map_10To10 (Display string: 'map 10 To 10'): The LUT maps 10 bit input data to 10 bit output data. + * - \b map_8To10 (Display string: 'map 8 To 10'): The LUT maps 8 bit input data to 12 bit output data. + * - \b map_12To10 (Display string: 'map 12 To 10'): The LUT maps 12 bit input data to 10 bit output data. + * - \b map_10To9 (Display string: 'map 10 To 9'): The LUT maps 10 bit input data to 9 bit output data. + * - \b map_12To9 (Display string: 'map 12 To 9'): The LUT maps 12 bit input data to 9 bit output data. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLUTMapping; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Color Transformation control features. +/** + * A category that contains the Color Transformation control features. + * \ingroup GenICamInterfaceDevice + */ +class ColorTransformationControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::ColorTransformationControl object. + explicit ColorTransformationControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + colorTransformationSelector(), + colorTransformationEnable(), + colorTransformationValueSelector(), + colorTransformationValue() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( colorTransformationSelector, "ColorTransformationSelector" ); + locator.bindComponent( colorTransformationEnable, "ColorTransformationEnable" ); + locator.bindComponent( colorTransformationValueSelector, "ColorTransformationValueSelector" ); + locator.bindComponent( colorTransformationValue, "ColorTransformationValue" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which Color Transformation module is controlled by the various Color Transformation features. + /** + * Selects which Color Transformation module is controlled by the various Color Transformation features. + * + * The following string values might be valid for this feature: + * - \b RGBtoRGB (Display string: 'RGB to RGB'): RGB to RGB color transformation. + * - \b RGBtoYUV (Display string: 'RGB to YUV'): RGB to YUV color transformation. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 colorTransformationSelector; + /// \brief A boolean property. Activates the selected Color Transformation module. + /** + * Activates the selected Color Transformation module. + */ + PropertyIBoolean colorTransformationEnable; + /// \brief An enumerated integer property. Selects the Gain factor or Offset of the Transformation matrix to access in the selected Color Transformation module. + /** + * Selects the Gain factor or Offset of the Transformation matrix to access in the selected Color Transformation module. + * + * The following string values might be valid for this feature: + * - \b Gain00 (Display string: 'Gain 00'): Gain 0,0 of the transformation matrix. + * - \b Gain01 (Display string: 'Gain 01'): Gain 0,1 of the transformation matrix. + * - \b Gain02 (Display string: 'Gain 02'): Gain 0,2 of the transformation matrix. + * - \b Gain10 (Display string: 'Gain 10'): Gain 1,0 of the transformation matrix. + * - \b Gain11 (Display string: 'Gain 11'): Gain 1,1 of the transformation matrix. + * - \b Gain12 (Display string: 'Gain 12'): Gain 1,2 of the transformation matrix. + * - \b Gain20 (Display string: 'Gain 20'): Gain 2,0 of the transformation matrix. + * - \b Gain21 (Display string: 'Gain 21'): Gain 2,1 of the transformation matrix. + * - \b Gain22 (Display string: 'Gain 22'): Gain 2,2 of the transformation matrix. + * - \b Offset0 (Display string: 'Offset 0'): Offset 0 of the transformation matrix. + * - \b Offset1 (Display string: 'Offset 1'): Offset 1 of the transformation matrix. + * - \b Offset2 (Display string: 'Offset 2'): Offset 2 of the transformation matrix. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 colorTransformationValueSelector; + /// \brief A floating point property. Represents the value of the selected Gain factor or Offset inside the Transformation matrix. + /** + * Represents the value of the selected Gain factor or Offset inside the Transformation matrix. + */ + PropertyF colorTransformationValue; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the digital input and output control features. +/** + * A category that contains the digital input and output control features. + * \ingroup GenICamInterfaceDevice + */ +class DigitalIOControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::DigitalIOControl object. + explicit DigitalIOControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + lineSelector(), + lineMode(), + lineInverter(), + lineStatus(), + lineStatusAll(), + lineSource(), + lineFormat(), + userOutputSelector(), + userOutputValue(), + userOutputValueAll(), + userOutputValueAllMask(), + mvLineDebounceTimeRisingEdge(), + mvLineDebounceTimeFallingEdge(), + mvRTMInputSelector(), + mvRTMSource(), + mvLineLED(), + mvEnable12VPowerOut() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( lineSelector, "LineSelector" ); + locator.bindComponent( lineMode, "LineMode" ); + locator.bindComponent( lineInverter, "LineInverter" ); + locator.bindComponent( lineStatus, "LineStatus" ); + locator.bindComponent( lineStatusAll, "LineStatusAll" ); + locator.bindComponent( lineSource, "LineSource" ); + locator.bindComponent( lineFormat, "LineFormat" ); + locator.bindComponent( userOutputSelector, "UserOutputSelector" ); + locator.bindComponent( userOutputValue, "UserOutputValue" ); + locator.bindComponent( userOutputValueAll, "UserOutputValueAll" ); + locator.bindComponent( userOutputValueAllMask, "UserOutputValueAllMask" ); + locator.bindComponent( mvLineDebounceTimeRisingEdge, "mvLineDebounceTimeRisingEdge" ); + locator.bindComponent( mvLineDebounceTimeFallingEdge, "mvLineDebounceTimeFallingEdge" ); + locator.bindComponent( mvRTMInputSelector, "mvRTMInputSelector" ); + locator.bindComponent( mvRTMSource, "mvRTMSource" ); + locator.bindComponent( mvLineLED, "mvLineLED" ); + locator.bindComponent( mvEnable12VPowerOut, "mvEnable12VPowerOut" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the physical line (or pin) of the external device connector or the virtual line of the Transport Layer to configure. + /** + * Selects the physical line (or pin) of the external device connector or the virtual line of the Transport Layer to configure. + * + * The following string values might be valid for this feature: + * - \b Line0 (Display string: 'Line 0'): Index of the physical line and associated I/O control block to use. + * - \b Line1 (Display string: 'Line 1'): Index of the physical line and associated I/O control block to use. + * - \b Line2 (Display string: 'Line 2'): Index of the physical line and associated I/O control block to use. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Index of the physical line and associated I/O control block to use. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Index of the virtual line going on the Transport layer to use. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Index of the virtual line going on the Transport layer to use. + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Index of the virtual line going on the Transport layer to use. + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Index of the virtual line going on the Transport layer to use. + * - \b CC1 (Display string: 'CC 1'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC2 (Display string: 'CC 2'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC3 (Display string: 'CC 3'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC4 (Display string: 'CC 4'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC\#5\# (Display string: 'CC \#5\#'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b Line3 (Display string: 'Line 3'): Index of the physical line and associated I/O control block to use. + * - \b Line4 (Display string: 'Line 4'): Index of the physical line and associated I/O control block to use. + * - \b Line5 (Display string: 'Line 5'): Index of the physical line and associated I/O control block to use. + * - \b Line6 (Display string: 'Line 6'): Index of the physical line and associated I/O control block to use. + * - \b Line7 (Display string: 'Line 7'): Index of the physical line and associated I/O control block to use. + * - \b Line8 (Display string: 'Line 8'): Index of the physical line and associated I/O control block to use. + * - \b Line9 (Display string: 'Line 9'): Index of the physical line and associated I/O control block to use. + * - \b Line10 (Display string: 'Line 10'): Index of the physical line and associated I/O control block to use. + * - \b Line11 (Display string: 'Line 11'): Index of the physical line and associated I/O control block to use. + * - \b Line12 (Display string: 'Line 12'): Index of the physical line and associated I/O control block to use. + * - \b Line13 (Display string: 'Line 13'): Index of the physical line and associated I/O control block to use. + * - \b Line14 (Display string: 'Line 14'): Index of the physical line and associated I/O control block to use. + * - \b Line15 (Display string: 'Line 15'): Index of the physical line and associated I/O control block to use. + * - \b CC5 (Display string: 'CC 5'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC6 (Display string: 'CC 6'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC7 (Display string: 'CC 7'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC8 (Display string: 'CC 8'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC9 (Display string: 'CC 9'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC10 (Display string: 'CC 10'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC11 (Display string: 'CC 11'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC12 (Display string: 'CC 12'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC13 (Display string: 'CC 13'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC14 (Display string: 'CC 14'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC15 (Display string: 'CC 15'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink Product only. + * - \b CC16 (Display string: 'CC 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + * + * See \b lineStatusAll to find out which line corresponds to which input or output of your device + * + */ + PropertyI64 lineSelector; + /// \brief An enumerated integer property. Controls if the physical Line is used to Input or Output a signal. + /** + * Controls if the physical Line is used to Input or Output a signal. + * + * The following string values might be valid for this feature: + * - \b Input (Display string: 'Input'): The selected physical line is used to Input an electrical signal. + * - \b Output (Display string: 'Output'): The selected physical line is used to Output an electrical signal. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 lineMode; + /// \brief A boolean property. Controls the inversion of the signal of the selected input or output Line. + /** + * Controls the inversion of the signal of the selected input or output Line. + */ + PropertyIBoolean lineInverter; + /// \brief A boolean property. Returns the current status of the selected input or output Line. + /** + * Returns the current status of the selected input or output Line. + */ + PropertyIBoolean lineStatus; + /// \brief An integer property. Returns the current status of all available Line signals at time of polling in a single bitfield. + /** + * Returns the current status of all available Line signals at time of polling in a single bitfield. + * + * The following table documents which bit in this property represents the state of which digital I/O for \b mvBlueCOUGAR-X and \b mvBlueFOX3 devices: + * + * + * + * + * + * + * + * + * + *
bitIOLineSelectorValue
0out 0Line0
1out 1Line1
2out 2Line2
3out 3Line3
4in 0Line4
5in 1Line5
+ * + * The following table documents which bit in this property represents the state of which digital I/O for \b mvBlueCOUGAR-X-POE devices: + * + * + * + * + * + * + * + * + * + *
bitIOLineSelectorValue
0out 0Line0
1out 1Line1
2--
3--
4in 0Line4
5in 1Line5
+ * + * The following table documents which bit in this property represents the state of which digital I/O for \b mvBlueCOUGAR-X-POEI \b mvBlueCOUGAR-XD devices: + * + * + * + * + * + * + * + * + * + * + * + *
bitIOLineSelectorValue
0out 0Line0
1out 1Line1
2out 2Line2
3out 3Line3
4in 0Line4
5in 1Line5
6in 2Line6
7in 3Line7
+ */ + PropertyI64 lineStatusAll; + /// \brief An enumerated integer property. Selects which internal acquisition or I/O source signal to output on the selected Line. + /** + * Selects which internal acquisition or I/O source signal to output on the selected Line. LineMode must be Output. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Line output is disabled (Tri-State). + * - \b UserOutput0 (Display string: 'User Output 0'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput1 (Display string: 'User Output 1'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput2 (Display string: 'User Output 2'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b AcquisitionTriggerWait (Display string: 'Acquisition Trigger Wait'): Device is currently waiting for a trigger for the capture of one or many Frames. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device is currently waiting for a trigger for the capture of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device has missed an Acquisition start trigger. + * - \b AcquisitionActive (Display string: 'Acquisition Active'): Device is currently doing an acquisition of one or many Frames. + * - \b FrameTriggerWait (Display string: 'Frame Trigger Wait'): Device is currently waiting for a Frame start trigger. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device is currently waiting for a Frame start trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device has missed a Frame start trigger. + * - \b FrameActive (Display string: 'Frame Active'): Device is currently doing the capture of a Frame. + * - \b ExposureActive (Display string: 'Exposure Active'): Device is doing the exposure of a Frame (or Line). + * - \b LineTriggerWait (Display string: 'Line Trigger Wait'): Device is currently waiting for a Line start trigger. + * - \b LineTrigger (Display string: 'Line Trigger'): Device is currently waiting for a Line start trigger. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device has missed a Line start trigger. + * - \b LineActive (Display string: 'Line Active'): Device is currently doing the capture of a Line. + * - \b Counter0Active (Display string: 'Counter 0 Active'): The chosen counter is in active state (counting). + * - \b Counter1Active (Display string: 'Counter 1 Active'): The chosen counter is in active state (counting). + * - \b Counter2Active (Display string: 'Counter 2 Active'): The chosen counter is in active state (counting). + * - \b Counter\#3\#Active (Display string: 'Counter \#3\# Active'): The chosen counter is in active state (counting). + * - \b Timer0Active (Display string: 'Timer 0 Active'): The chosen Timer is in active state. + * - \b Timer1Active (Display string: 'Timer 1 Active'): The chosen Timer is in active state. + * - \b Timer2Active (Display string: 'Timer 2 Active'): The chosen Timer is in active state. + * - \b Timer\#3\#Active (Display string: 'Timer \#3\# Active'): The chosen Timer is in active state. + * - \b Encoder0 (Display string: 'Encoder 0'): The chosen Encoder Output state. + * - \b Encoder1 (Display string: 'Encoder 1'): The chosen Encoder Output state. + * - \b Encoder2 (Display string: 'Encoder 2'): The chosen Encoder Output state. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): The chosen Encoder Output state. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): The choosen Logic Block output state. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): The choosen Logic Block output state. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): The choosen Logic Block output state. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): The choosen Logic Block output state. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): The choosen Software Signal output state. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): The choosen Software Signal output state. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): The choosen Software Signal output state. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): The choosen Software Signal output state. + * - \b Stream0TransferActive (Display string: 'Stream 0 Transfer Active'): Transfer on the stream is active. + * - \b Stream1TransferActive (Display string: 'Stream 1 Transfer Active'): Transfer on the stream is active. + * - \b Stream\#2\#TransferActive (Display string: 'Stream \#2\# Transfer Active'): Transfer on the stream is active. + * - \b Stream0TransferPaused (Display string: 'Stream 0 Transfer Paused'): Transfer on the stream is paused. + * - \b Stream1TransferPaused (Display string: 'Stream 1 Transfer Paused'): Transfer on the stream is paused. + * - \b Stream\#2\#TransferPaused (Display string: 'Stream \#2\# Transfer Paused'): Transfer on the stream is paused. + * - \b Stream0TransferStopping (Display string: 'Stream 0 Transfer Stopping'): Transfer on the stream is stopping. + * - \b Stream1TransferStopping (Display string: 'Stream 1 Transfer Stopping'): Transfer on the stream is stopping. + * - \b Stream\#2\#TransferStopping (Display string: 'Stream \#2\# Transfer Stopping'): Transfer on the stream is stopping. + * - \b Stream0TransferStopped (Display string: 'Stream 0 Transfer Stopped'): Transfer on the stream is stopped. + * - \b Stream1TransferStopped (Display string: 'Stream 1 Transfer Stopped'): Transfer on the stream is stopped. + * - \b Stream\#2\#TransferStopped (Display string: 'Stream \#2\# Transfer Stopped'): Transfer on the stream is stopped. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Transfer on the stream is in overflow. + * - \b Stream1TransferOverflow (Display string: 'Stream 1 Transfer Overflow'): Transfer on the stream is in overflow. + * - \b Stream\#2\#TransferOverflow (Display string: 'Stream \#2\# Transfer Overflow'): Transfer on the stream is in overflow. + * - \b mvExposureSensor2Active (Display string: 'mv Exposure Sensor 2 Active') + * - \b UserOutput3 (Display string: 'User Output 3'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput4 (Display string: 'User Output 4'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput5 (Display string: 'User Output 5'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput6 (Display string: 'User Output 6'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b UserOutput7 (Display string: 'User Output 7'): The chosen User Output Bit state as defined by its current UserOutputValue. + * - \b Counter3Active (Display string: 'Counter 3 Active'): The chosen counter is in active state (counting). + * - \b Counter4Active (Display string: 'Counter 4 Active'): The chosen counter is in active state (counting). + * - \b Counter5Active (Display string: 'Counter 5 Active'): The chosen counter is in active state (counting). + * - \b Counter6Active (Display string: 'Counter 6 Active'): The chosen counter is in active state (counting). + * - \b Counter7Active (Display string: 'Counter 7 Active'): The chosen counter is in active state (counting). + * - \b Counter8Active (Display string: 'Counter 8 Active'): The chosen counter is in active state (counting). + * - \b mvReadOutActive (Display string: 'mv Read Out Active') + * - \b mvExposureAndAcquisitionActive (Display string: 'mv Exposure And Acquisition Active') + * - \b mvTemperatureOutOfRange (Display string: 'mv Temperature Out Of Range') + * - \b mvLogicGateOR1Output (Display string: 'mv Logic Gate OR 1 Output') + * - \b mvLogicGateOR2Output (Display string: 'mv Logic Gate OR 2 Output') + * - \b mvLogicGateOR3Output (Display string: 'mv Logic Gate OR 3 Output') + * - \b mvLogicGateOR4Output (Display string: 'mv Logic Gate OR 4 Output') + * - \b mvExposureActive (Display string: 'mv Exposure Active') + * - \b mvRTMOutput0 (Display string: 'mv RTM Output 0') + * - \b mvRTMOutput1 (Display string: 'mv RTM Output 1') + * - \b mvRTMOutput2 (Display string: 'mv RTM Output 2') + * - \b mvRTMOutput3 (Display string: 'mv RTM Output 3') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 lineSource; + /// \brief An enumerated integer property. Controls the current electrical format of the selected physical input or output Line. + /** + * Controls the current electrical format of the selected physical input or output Line. + * + * The following string values might be valid for this feature: + * - \b NoConnect (Display string: 'No Connect'): The Line is not connected. + * - \b TriState (Display string: 'Tri State'): The Line is currently in Tri-State mode (Not driven). + * - \b TTL (Display string: 'TTL'): The Line is currently accepting or sending TTL level signals. + * - \b LVDS (Display string: 'LVDS'): The Line is currently accepting or sending LVDS level signals. + * - \b RS422 (Display string: 'RS 422'): The Line is currently accepting or sending RS422 level signals. + * - \b OptoCoupled (Display string: 'Opto Coupled'): The Line is opto-coupled. + * - \b OpenDrain (Display string: 'Open Drain'): The Line is Open Drain (or Open Collector). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 lineFormat; + /// \brief An enumerated integer property. Selects which bit of the User Output register will be set by UserOutputValue. + /** + * Selects which bit of the User Output register will be set by UserOutputValue. + * + * The following string values might be valid for this feature: + * - \b UserOutput0 (Display string: 'User Output 0'): Selects the bit 0 of the User Output register. + * - \b UserOutput1 (Display string: 'User Output 1'): Selects the bit 1 of the User Output register. + * - \b UserOutput2 (Display string: 'User Output 2'): Selects the bit 2 of the User Output register. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Selects the bit \#3\# of the User Output register. + * - \b UserOutput3 (Display string: 'User Output 3'): Selects the bit 3 of the User Output register. + * - \b UserOutput4 (Display string: 'User Output 4'): Selects the bit 4 of the User Output register. + * - \b UserOutput5 (Display string: 'User Output 5'): Selects the bit 5 of the User Output register. + * - \b UserOutput6 (Display string: 'User Output 6'): Selects the bit 6 of the User Output register. + * - \b UserOutput7 (Display string: 'User Output 7'): Selects the bit 7 of the User Output register. + * - \b UserOutput8 (Display string: 'User Output 8'): Selects the bit 8 of the User Output register. + * - \b UserOutput9 (Display string: 'User Output 9'): Selects the bit 9 of the User Output register. + * - \b UserOutput10 (Display string: 'User Output 10'): Selects the bit 10 of the User Output register. + * - \b UserOutput11 (Display string: 'User Output 11'): Selects the bit 11 of the User Output register. + * - \b UserOutput12 (Display string: 'User Output 12'): Selects the bit 12 of the User Output register. + * - \b UserOutput13 (Display string: 'User Output 13'): Selects the bit 13 of the User Output register. + * - \b UserOutput14 (Display string: 'User Output 14'): Selects the bit 14 of the User Output register. + * - \b UserOutput15 (Display string: 'User Output 15'): Selects the bit 15 of the User Output register. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 userOutputSelector; + /// \brief A boolean property. Sets the value of the bit selected by UserOutputSelector. + /** + * Sets the value of the bit selected by UserOutputSelector. + */ + PropertyIBoolean userOutputValue; + /// \brief An integer property. Sets the value of all the bits of the User Output register. + /** + * Sets the value of all the bits of the User Output register. It is subject to the UserOutputValueAllMask. + */ + PropertyI64 userOutputValueAll; + /// \brief An integer property. Sets the write mask to apply to the value specified by UserOutputValueAll before writing it in the User Output register. + /** + * Sets the write mask to apply to the value specified by UserOutputValueAll before writing it in the User Output register. If the UserOutputValueAllMask feature is present, setting the user Output register using UserOutputValueAll will only change the bits that have a corresponding bit in the mask set to one. + */ + PropertyI64 userOutputValueAllMask; + /// \brief An integer property. Sets the debounce time in micro seconds for low to high transitions. + /** + * Sets the debounce time in micro seconds for low to high transitions. + */ + PropertyI64 mvLineDebounceTimeRisingEdge; + /// \brief An integer property. Sets the debounce time in micro seconds for high to low transitions. + /** + * Sets the debounce time in micro seconds for high to low transitions. + */ + PropertyI64 mvLineDebounceTimeFallingEdge; + /// \brief An enumerated integer property. Selects which RTM input to configure. + /** + * Selects which RTM input to configure. + * + * The following string values might be valid for this feature: + * - \b mvRTMInput0 (Display string: 'mv RTM Input 0') + * - \b mvRTMInput1 (Display string: 'mv RTM Input 1') + * - \b mvRTMInput2 (Display string: 'mv RTM Input 2') + * - \b mvRTMInput3 (Display string: 'mv RTM Input 3') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvRTMInputSelector; + /// \brief An enumerated integer property. Selects which signal to connect to the selected RTM input. + /** + * Selects which signal to connect to the selected RTM input. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b Line4 (Display string: 'Line 4') + * - \b Line5 (Display string: 'Line 5') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvRTMSource; + /// \brief An enumerated integer property. Selects the digital I/O line to be stated by the LED + /** + * Selects the digital I/O line to be stated by the LED + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b Line0 (Display string: 'Line 0') + * - \b Line1 (Display string: 'Line 1') + * - \b Line2 (Display string: 'Line 2') + * - \b Line3 (Display string: 'Line 3') + * - \b Line4 (Display string: 'Line 4') + * - \b Line5 (Display string: 'Line 5') + * - \b Line6 (Display string: 'Line 6') + * - \b Line7 (Display string: 'Line 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLineLED; + /// \brief A boolean property. Enable 12V power out on MultipurposeIO POWER_OUT pin. + /** + * Enable 12V power out on MultipurposeIO POWER_OUT pin. + */ + PropertyIBoolean mvEnable12VPowerOut; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Counter and Timer control features. +/** + * A category that contains the Counter and Timer control features. + * \ingroup GenICamInterfaceDevice + */ +class CounterAndTimerControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::CounterAndTimerControl object. + explicit CounterAndTimerControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + counterSelector(), + counterEventSource(), + counterEventActivation(), + counterResetSource(), + counterResetActivation(), + counterReset(), + counterValue(), + counterValueAtReset(), + counterDuration(), + counterStatus(), + counterTriggerSource(), + counterTriggerActivation(), + timerSelector(), + timerDuration(), + timerDelay(), + timerReset(), + timerValue(), + timerStatus(), + timerTriggerSource(), + timerTriggerActivation(), + timerTriggerArmDelay() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( counterSelector, "CounterSelector" ); + locator.bindComponent( counterEventSource, "CounterEventSource" ); + locator.bindComponent( counterEventActivation, "CounterEventActivation" ); + locator.bindComponent( counterResetSource, "CounterResetSource" ); + locator.bindComponent( counterResetActivation, "CounterResetActivation" ); + locator.bindComponent( counterReset, "CounterReset@i" ); + locator.bindComponent( counterValue, "CounterValue" ); + locator.bindComponent( counterValueAtReset, "CounterValueAtReset" ); + locator.bindComponent( counterDuration, "CounterDuration" ); + locator.bindComponent( counterStatus, "CounterStatus" ); + locator.bindComponent( counterTriggerSource, "CounterTriggerSource" ); + locator.bindComponent( counterTriggerActivation, "CounterTriggerActivation" ); + locator.bindComponent( timerSelector, "TimerSelector" ); + locator.bindComponent( timerDuration, "TimerDuration" ); + if( !timerDuration.isValid() ) + { + locator.bindComponent( timerDuration, "TimerDurationAbs" ); + } + locator.bindComponent( timerDelay, "TimerDelay" ); + if( !timerDelay.isValid() ) + { + locator.bindComponent( timerDelay, "TimerDelayAbs" ); + } + locator.bindComponent( timerReset, "TimerReset@i" ); + locator.bindComponent( timerValue, "TimerValue" ); + if( !timerValue.isValid() ) + { + locator.bindComponent( timerValue, "TimerValueAbs" ); + } + locator.bindComponent( timerStatus, "TimerStatus" ); + locator.bindComponent( timerTriggerSource, "TimerTriggerSource" ); + locator.bindComponent( timerTriggerActivation, "TimerTriggerActivation" ); + locator.bindComponent( timerTriggerArmDelay, "TimerTriggerArmDelay" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which Counter to configure. + /** + * Selects which Counter to configure. + * + * The following string values might be valid for this feature: + * - \b Counter0 (Display string: 'Counter 0'): Selects the counter 0. + * - \b Counter1 (Display string: 'Counter 1'): Selects the counter 1. + * - \b Counter2 (Display string: 'Counter 2'): Selects the counter 2. + * - \b Counter\#3\# (Display string: 'Counter \#3\#'): Selects the counter \#3\#. + * - \b Counter3 (Display string: 'Counter 3'): Selects the counter 3. + * - \b Counter4 (Display string: 'Counter 4'): Selects the counter 4. + * - \b Counter5 (Display string: 'Counter 5'): Selects the counter 5. + * - \b Counter6 (Display string: 'Counter 6'): Selects the counter 6. + * - \b Counter7 (Display string: 'Counter 7'): Selects the counter 7. + * - \b Counter8 (Display string: 'Counter 8'): Selects the counter 8. + * - \b Counter9 (Display string: 'Counter 9'): Selects the counter 9. + * - \b Counter10 (Display string: 'Counter 10'): Selects the counter 10. + * - \b Counter11 (Display string: 'Counter 11'): Selects the counter 11. + * - \b Counter12 (Display string: 'Counter 12'): Selects the counter 12. + * - \b Counter13 (Display string: 'Counter 13'): Selects the counter 13. + * - \b Counter14 (Display string: 'Counter 14'): Selects the counter 14. + * - \b Counter15 (Display string: 'Counter 15'): Selects the counter 15. + * - \b Counter16 (Display string: 'Counter 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterSelector; + /// \brief An enumerated integer property. Select the events that will be the source to increment the Counter. + /** + * Select the events that will be the source to increment the Counter. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Counter is stopped. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Counts the number of Acquisition Trigger. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Counts the number of missed Acquisition Start Trigger. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Counts the number of Acquisition Start. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Counts the number of Acquisition End. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Counts the number of Frame Start Trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Counts the number of missed Frame Start Trigger. + * - \b FrameStart (Display string: 'Frame Start'): Counts the number of Frame Start. + * - \b FrameEnd (Display string: 'Frame End'): Counts the number of Frame End. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Counts the number of Frame Burst Start. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Counts the number of Frame Burst End. + * - \b LineTrigger (Display string: 'Line Trigger'): Counts the number of Line Start Trigger. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Counts the number of missed Line Start Trigger. + * - \b LineStart (Display string: 'Line Start'): Counts the number of Line Start. + * - \b LineEnd (Display string: 'Line End'): Counts the number of Line End. + * - \b ExposureStart (Display string: 'Exposure Start'): Counts the number of Exposure Start. + * - \b ExposureEnd (Display string: 'Exposure End'): Counts the number of Exposure End. + * - \b Line0 (Display string: 'Line 0'): Counts the number of transitions on the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Counts the number of transitions on the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Counts the number of transitions on the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Counts the number of transitions on the chosen I/O Line. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Counts the number of Counter Start. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Counts the number of Counter Start. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Counts the number of Counter Start. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Counts the number of Counter Start. + * - \b Counter0End (Display string: 'Counter 0 End'): Counts the number of Counter End. + * - \b Counter1End (Display string: 'Counter 1 End'): Counts the number of Counter End. + * - \b Counter2End (Display string: 'Counter 2 End'): Counts the number of Counter End. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Counts the number of Counter End. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Counts the number of Timer Start pulses generated. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Counts the number of Timer Start pulses generated. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Counts the number of Timer Start pulses generated. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Counts the number of Timer Start pulses generated. + * - \b Timer0End (Display string: 'Timer 0 End'): Counts the number of Timer End pulses generated. + * - \b Timer1End (Display string: 'Timer 1 End'): Counts the number of Timer End pulses generated. + * - \b Timer2End (Display string: 'Timer 2 End'): Counts the number of Timer End pulses generated. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Counts the number of Timer End pulses generated. + * - \b Encoder0 (Display string: 'Encoder 0'): Counts the number of Encoder output pulses. + * - \b Encoder1 (Display string: 'Encoder 1'): Counts the number of Encoder output pulses. + * - \b Encoder2 (Display string: 'Encoder 2'): Counts the number of Encoder output pulses. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Counts the number of Encoder output pulses. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Counts the number of Logic Block output pulses. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Counts the number of Logic Block output pulses. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Counts the number of Logic Block output pulses. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Counts the number of Logic Block output pulses. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Counts the number of Software Signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Counts the number of Software Signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Counts the number of Software Signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Counts the number of Software Signal. + * - \b Action0 (Display string: 'Action 0'): Counts the number of assertions of the chosen action signal. + * - \b Action1 (Display string: 'Action 1'): Counts the number of assertions of the chosen action signal. + * - \b Action2 (Display string: 'Action 2'): Counts the number of assertions of the chosen action signal. + * - \b Action\#3\# (Display string: 'Action \#3\#'): Counts the number of assertions of the chosen action signal. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Counts the number of Link Triggers. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Counts the number of Link Triggers. + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Counts the number of Link Triggers. + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Counts the number of Link Triggers. + * - \b LinkTriggerMissed0 (Display string: 'Link Trigger Missed 0'): Counts the number of Link Triggers missed. + * - \b LinkTriggerMissed1 (Display string: 'Link Trigger Missed 1'): Counts the number of Link Triggers missed. + * - \b LinkTriggerMissed2 (Display string: 'Link Trigger Missed 2'): Counts the number of Link Triggers missed. + * - \b LinkTriggerMissed\#3\# (Display string: 'Link Trigger Missed \#3\#'): Counts the number of Link Triggers missed. + * - \b TimestampTick (Display string: 'Timestamp Tick'): Counts the number of clock ticks of the Timestamp clock. Can be used to create a programmable timer. + * - \b Line3 (Display string: 'Line 3'): Counts the number of transitions on the chosen I/O Line. + * - \b Line4 (Display string: 'Line 4'): Counts the number of transitions on the chosen I/O Line. + * - \b Line5 (Display string: 'Line 5'): Counts the number of transitions on the chosen I/O Line. + * - \b Line6 (Display string: 'Line 6'): Counts the number of transitions on the chosen I/O Line. + * - \b Line7 (Display string: 'Line 7'): Counts the number of transitions on the chosen I/O Line. + * - \b Line8 (Display string: 'Line 8'): Counts the number of transitions on the chosen I/O Line. + * - \b Line9 (Display string: 'Line 9'): Counts the number of transitions on the chosen I/O Line. + * - \b Line10 (Display string: 'Line 10'): Counts the number of transitions on the chosen I/O Line. + * - \b Line11 (Display string: 'Line 11'): Counts the number of transitions on the chosen I/O Line. + * - \b Line12 (Display string: 'Line 12'): Counts the number of transitions on the chosen I/O Line. + * - \b Line13 (Display string: 'Line 13'): Counts the number of transitions on the chosen I/O Line. + * - \b Line14 (Display string: 'Line 14'): Counts the number of transitions on the chosen I/O Line. + * - \b Line15 (Display string: 'Line 15'): Counts the number of transitions on the chosen I/O Line. + * - \b Counter3End (Display string: 'Counter 3 End'): Counts the number of Counter End. + * - \b Counter4End (Display string: 'Counter 4 End'): Counts the number of Counter End. + * - \b Counter5End (Display string: 'Counter 5 End'): Counts the number of Counter End. + * - \b Counter6End (Display string: 'Counter 6 End'): Counts the number of Counter End. + * - \b Counter7End (Display string: 'Counter 7 End'): Counts the number of Counter End. + * - \b Counter8End (Display string: 'Counter 8 End'): Counts the number of Counter End. + * - \b Counter9End (Display string: 'Counter 9 End'): Counts the number of Counter End. + * - \b Counter10End (Display string: 'Counter 10 End'): Counts the number of Counter End. + * - \b Counter11End (Display string: 'Counter 11 End'): Counts the number of Counter End. + * - \b Counter12End (Display string: 'Counter 12 End'): Counts the number of Counter End. + * - \b Counter13End (Display string: 'Counter 13 End'): Counts the number of Counter End. + * - \b Counter14End (Display string: 'Counter 14 End'): Counts the number of Counter End. + * - \b Counter15End (Display string: 'Counter 15 End'): Counts the number of Counter End. + * - \b Counter16End (Display string: 'Counter 16 End') + * - \b Timer3End (Display string: 'Timer 3 End'): Counts the number of Timer End pulses generated. + * - \b Timer4End (Display string: 'Timer 4 End'): Counts the number of Timer End pulses generated. + * - \b Timer5End (Display string: 'Timer 5 End'): Counts the number of Timer End pulses generated. + * - \b Timer6End (Display string: 'Timer 6 End'): Counts the number of Timer End pulses generated. + * - \b Timer7End (Display string: 'Timer 7 End'): Counts the number of Timer End pulses generated. + * - \b Timer8End (Display string: 'Timer 8 End'): Counts the number of Timer End pulses generated. + * - \b Timer9End (Display string: 'Timer 9 End'): Counts the number of Timer End pulses generated. + * - \b Timer10End (Display string: 'Timer 10 End'): Counts the number of Timer End pulses generated. + * - \b Timer11End (Display string: 'Timer 11 End'): Counts the number of Timer End pulses generated. + * - \b Timer12End (Display string: 'Timer 12 End'): Counts the number of Timer End pulses generated. + * - \b Timer13End (Display string: 'Timer 13 End'): Counts the number of Timer End pulses generated. + * - \b Timer14End (Display string: 'Timer 14 End'): Counts the number of Timer End pulses generated. + * - \b Timer15End (Display string: 'Timer 15 End'): Counts the number of Timer End pulses generated. + * - \b Timer16End (Display string: 'Timer 16 End') + * - \b Action3 (Display string: 'Action 3'): Counts the number of assertions of the chosen action signal. + * - \b Action4 (Display string: 'Action 4'): Counts the number of assertions of the chosen action signal. + * - \b Action5 (Display string: 'Action 5'): Counts the number of assertions of the chosen action signal. + * - \b Action6 (Display string: 'Action 6'): Counts the number of assertions of the chosen action signal. + * - \b Action7 (Display string: 'Action 7'): Counts the number of assertions of the chosen action signal. + * - \b Action8 (Display string: 'Action 8'): Counts the number of assertions of the chosen action signal. + * - \b Action9 (Display string: 'Action 9'): Counts the number of assertions of the chosen action signal. + * - \b Action10 (Display string: 'Action 10'): Counts the number of assertions of the chosen action signal. + * - \b Action11 (Display string: 'Action 11'): Counts the number of assertions of the chosen action signal. + * - \b Action12 (Display string: 'Action 12'): Counts the number of assertions of the chosen action signal. + * - \b Action13 (Display string: 'Action 13'): Counts the number of assertions of the chosen action signal. + * - \b Action14 (Display string: 'Action 14'): Counts the number of assertions of the chosen action signal. + * - \b Action15 (Display string: 'Action 15'): Counts the number of assertions of the chosen action signal. + * - \b Action16 (Display string: 'Action 16') + * - \b Line0RisingEdge (Display string: 'Line 0 Rising Edge') + * - \b Line1RisingEdge (Display string: 'Line 1 Rising Edge') + * - \b Line2RisingEdge (Display string: 'Line 2 Rising Edge') + * - \b Line3RisingEdge (Display string: 'Line 3 Rising Edge') + * - \b Line4RisingEdge (Display string: 'Line 4 Rising Edge') + * - \b Line5RisingEdge (Display string: 'Line 5 Rising Edge') + * - \b Line6RisingEdge (Display string: 'Line 6 Rising Edge') + * - \b Line7RisingEdge (Display string: 'Line 7 Rising Edge') + * - \b Line8RisingEdge (Display string: 'Line 8 Rising Edge') + * - \b Line9RisingEdge (Display string: 'Line 9 Rising Edge') + * - \b Line10RisingEdge (Display string: 'Line 10 Rising Edge') + * - \b Line11RisingEdge (Display string: 'Line 11 Rising Edge') + * - \b Line12RisingEdge (Display string: 'Line 12 Rising Edge') + * - \b Line13RisingEdge (Display string: 'Line 13 Rising Edge') + * - \b Line14RisingEdge (Display string: 'Line 14 Rising Edge') + * - \b Line15RisingEdge (Display string: 'Line 15 Rising Edge') + * - \b mvTemperatureOutOfRange (Display string: 'mv Temperature Out Of Range') + * - \b mvLogicGateOR1Output (Display string: 'mv Logic Gate OR 1 Output') + * - \b mvLogicGateOR2Output (Display string: 'mv Logic Gate OR 2 Output') + * - \b mvLogicGateOR3Output (Display string: 'mv Logic Gate OR 3 Output') + * - \b mvLogicGateOR4Output (Display string: 'mv Logic Gate OR 4 Output') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterEventSource; + /// \brief An enumerated integer property. Selects the Activation mode Event Source signal. + /** + * Selects the Activation mode Event Source signal. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Counts on the Rising Edge of the signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Counts on the Falling Edge of the signal. + * - \b AnyEdge (Display string: 'Any Edge'): Counts on the Falling or rising Edge of the selected signal. + * - \b LevelHigh (Display string: 'Level High') + * - \b LevelLow (Display string: 'Level Low') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterEventActivation; + /// \brief An enumerated integer property. Selects the signals that will be the source to reset the Counter. + /** + * Selects the signals that will be the source to reset the Counter. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disable the Counter Reset trigger. + * - \b CounterTrigger (Display string: 'Counter Trigger'): Resets with the reception of a trigger on the CounterTriggerSource. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Resets with the reception of the Acquisition Trigger. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Resets with the reception of the missed Acquisition start trigger. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Resets with the reception of the Acquisition Start. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Resets with the reception of the Acquisition End. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Resets with the reception of the Frame Start Trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Resets with the reception of the missed Frame start trigger. + * - \b FrameStart (Display string: 'Frame Start'): Resets with the reception of the Frame Start. + * - \b FrameEnd (Display string: 'Frame End'): Resets with the reception of the Frame End. + * - \b LineTrigger (Display string: 'Line Trigger'): Resets with the reception of the Line Start Trigger. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Resets with the reception of the missed Line start trigger. + * - \b LineStart (Display string: 'Line Start'): Resets with the reception of the Line Start. + * - \b LineEnd (Display string: 'Line End'): Resets with the reception of the Line End. + * - \b ExposureStart (Display string: 'Exposure Start'): Resets with the reception of the Exposure Start. + * - \b ExposureEnd (Display string: 'Exposure End'): Resets with the reception of the Exposure End. + * - \b Line0 (Display string: 'Line 0'): Resets by the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Resets by the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Resets by the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Resets by the chosen I/O Line. + * - \b UserOutput0 (Display string: 'User Output 0'): Resets by the chosen User Output bit. + * - \b UserOutput1 (Display string: 'User Output 1'): Resets by the chosen User Output bit. + * - \b UserOutput2 (Display string: 'User Output 2'): Resets by the chosen User Output bit. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Resets by the chosen User Output bit. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Resets with the reception of the Counter Start. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Resets with the reception of the Counter Start. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Resets with the reception of the Counter Start. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Resets with the reception of the Counter Start. + * - \b Counter0End (Display string: 'Counter 0 End'): Resets with the reception of the Counter End. + * - \b Counter1End (Display string: 'Counter 1 End'): Resets with the reception of the Counter End. + * - \b Counter2End (Display string: 'Counter 2 End'): Resets with the reception of the Counter End. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Resets with the reception of the Counter End. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Resets with the reception of the Timer Start. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Resets with the reception of the Timer Start. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Resets with the reception of the Timer Start. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Resets with the reception of the Timer Start. + * - \b Timer0End (Display string: 'Timer 0 End'): Resets with the reception of the Timer End. + * - \b Timer1End (Display string: 'Timer 1 End'): Resets with the reception of the Timer End. + * - \b Timer2End (Display string: 'Timer 2 End'): Resets with the reception of the Timer End. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Resets with the reception of the Timer End. + * - \b Encoder0 (Display string: 'Encoder 0'): Resets with the reception of the Encoder output signal. + * - \b Encoder1 (Display string: 'Encoder 1'): Resets with the reception of the Encoder output signal. + * - \b Encoder2 (Display string: 'Encoder 2'): Resets with the reception of the Encoder output signal. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Resets with the reception of the Encoder output signal. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Resets with the reception of the LogicBlock output signal. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Resets with the reception of the LogicBlock output signal. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Resets with the reception of the LogicBlock output signal. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Resets with the reception of the LogicBlock output signal. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Resets on the reception of the Software Signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Resets on the reception of the Software Signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Resets on the reception of the Software Signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Resets on the reception of the Software Signal. + * - \b Action0 (Display string: 'Action 0'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action1 (Display string: 'Action 1'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action2 (Display string: 'Action 2'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action\#3\# (Display string: 'Action \#3\#'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b Line3 (Display string: 'Line 3'): Resets by the chosen I/O Line. + * - \b Line4 (Display string: 'Line 4'): Resets by the chosen I/O Line. + * - \b Line5 (Display string: 'Line 5'): Resets by the chosen I/O Line. + * - \b Line6 (Display string: 'Line 6'): Resets by the chosen I/O Line. + * - \b Line7 (Display string: 'Line 7'): Resets by the chosen I/O Line. + * - \b Line8 (Display string: 'Line 8'): Resets by the chosen I/O Line. + * - \b Line9 (Display string: 'Line 9'): Resets by the chosen I/O Line. + * - \b Line10 (Display string: 'Line 10'): Resets by the chosen I/O Line. + * - \b Line11 (Display string: 'Line 11'): Resets by the chosen I/O Line. + * - \b Line12 (Display string: 'Line 12'): Resets by the chosen I/O Line. + * - \b Line13 (Display string: 'Line 13'): Resets by the chosen I/O Line. + * - \b Line14 (Display string: 'Line 14'): Resets by the chosen I/O Line. + * - \b Line15 (Display string: 'Line 15'): Resets by the chosen I/O Line. + * - \b Counter3End (Display string: 'Counter 3 End'): Resets with the reception of the Counter End. + * - \b Counter4End (Display string: 'Counter 4 End'): Resets with the reception of the Counter End. + * - \b Counter5End (Display string: 'Counter 5 End'): Resets with the reception of the Counter End. + * - \b Counter6End (Display string: 'Counter 6 End'): Resets with the reception of the Counter End. + * - \b Counter7End (Display string: 'Counter 7 End'): Resets with the reception of the Counter End. + * - \b Counter8End (Display string: 'Counter 8 End'): Resets with the reception of the Counter End. + * - \b Counter9End (Display string: 'Counter 9 End'): Resets with the reception of the Counter End. + * - \b Counter10End (Display string: 'Counter 10 End'): Resets with the reception of the Counter End. + * - \b Counter11End (Display string: 'Counter 11 End'): Resets with the reception of the Counter End. + * - \b Counter12End (Display string: 'Counter 12 End'): Resets with the reception of the Counter End. + * - \b Counter13End (Display string: 'Counter 13 End'): Resets with the reception of the Counter End. + * - \b Counter14End (Display string: 'Counter 14 End'): Resets with the reception of the Counter End. + * - \b Counter15End (Display string: 'Counter 15 End'): Resets with the reception of the Counter End. + * - \b Counter16End (Display string: 'Counter 16 End') + * - \b Timer3End (Display string: 'Timer 3 End'): Resets with the reception of the Timer End. + * - \b Timer4End (Display string: 'Timer 4 End'): Resets with the reception of the Timer End. + * - \b Timer5End (Display string: 'Timer 5 End'): Resets with the reception of the Timer End. + * - \b Timer6End (Display string: 'Timer 6 End'): Resets with the reception of the Timer End. + * - \b Timer7End (Display string: 'Timer 7 End'): Resets with the reception of the Timer End. + * - \b Timer8End (Display string: 'Timer 8 End'): Resets with the reception of the Timer End. + * - \b Timer9End (Display string: 'Timer 9 End'): Resets with the reception of the Timer End. + * - \b Timer10End (Display string: 'Timer 10 End'): Resets with the reception of the Timer End. + * - \b Timer11End (Display string: 'Timer 11 End'): Resets with the reception of the Timer End. + * - \b Timer12End (Display string: 'Timer 12 End'): Resets with the reception of the Timer End. + * - \b Timer13End (Display string: 'Timer 13 End'): Resets with the reception of the Timer End. + * - \b Timer14End (Display string: 'Timer 14 End'): Resets with the reception of the Timer End. + * - \b Timer15End (Display string: 'Timer 15 End'): Resets with the reception of the Timer End. + * - \b Timer16End (Display string: 'Timer 16 End') + * - \b UserOutput3 (Display string: 'User Output 3'): Resets by the chosen User Output bit. + * - \b UserOutput4 (Display string: 'User Output 4'): Resets by the chosen User Output bit. + * - \b UserOutput5 (Display string: 'User Output 5'): Resets by the chosen User Output bit. + * - \b UserOutput6 (Display string: 'User Output 6'): Resets by the chosen User Output bit. + * - \b UserOutput7 (Display string: 'User Output 7'): Resets by the chosen User Output bit. + * - \b UserOutput8 (Display string: 'User Output 8'): Resets by the chosen User Output bit. + * - \b UserOutput9 (Display string: 'User Output 9'): Resets by the chosen User Output bit. + * - \b UserOutput10 (Display string: 'User Output 10'): Resets by the chosen User Output bit. + * - \b UserOutput11 (Display string: 'User Output 11'): Resets by the chosen User Output bit. + * - \b UserOutput12 (Display string: 'User Output 12'): Resets by the chosen User Output bit. + * - \b UserOutput13 (Display string: 'User Output 13'): Resets by the chosen User Output bit. + * - \b UserOutput14 (Display string: 'User Output 14'): Resets by the chosen User Output bit. + * - \b UserOutput15 (Display string: 'User Output 15'): Resets by the chosen User Output bit. + * - \b Action3 (Display string: 'Action 3'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action4 (Display string: 'Action 4'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action5 (Display string: 'Action 5'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action6 (Display string: 'Action 6'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action7 (Display string: 'Action 7'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action8 (Display string: 'Action 8'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action9 (Display string: 'Action 9'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action10 (Display string: 'Action 10'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action11 (Display string: 'Action 11'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action12 (Display string: 'Action 12'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action13 (Display string: 'Action 13'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action14 (Display string: 'Action 14'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action15 (Display string: 'Action 15'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action16 (Display string: 'Action 16') + * - \b mvTemperatureOutOfRange (Display string: 'mv Temperature Out Of Range') + * - \b mvLogicGateOR1Output (Display string: 'mv Logic Gate OR 1 Output') + * - \b mvLogicGateOR2Output (Display string: 'mv Logic Gate OR 2 Output') + * - \b mvLogicGateOR3Output (Display string: 'mv Logic Gate OR 3 Output') + * - \b mvLogicGateOR4Output (Display string: 'mv Logic Gate OR 4 Output') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterResetSource; + /// \brief An enumerated integer property. Selects the Activation mode of the Counter Reset Source signal. + /** + * Selects the Activation mode of the Counter Reset Source signal. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Resets the counter on the Rising Edge of the signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Resets the counter on the Falling Edge of the signal. + * - \b AnyEdge (Display string: 'Any Edge'): Resets the counter on the Falling or rising Edge of the selected signal. + * - \b LevelHigh (Display string: 'Level High'): Resets the counter as long as the selected signal level is High. + * - \b LevelLow (Display string: 'Level Low'): Resets the counter as long as the selected signal level is Low. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterResetActivation; + /// \brief A method object. Does a software reset of the selected Counter and starts it. + /** + * Does a software reset of the selected Counter and starts it. The counter starts counting events immediately after the reset unless a Counter trigger is active. CounterReset can be used to reset the Counter independently from the CounterResetSource. To disable the counter temporarily, set CounterEventSource to Off. + */ + Method counterReset; + /// \brief An integer property. Reads or writes the current value of the selected Counter. + /** + * Reads or writes the current value of the selected Counter. + */ + PropertyI64 counterValue; + /// \brief An integer property. Reads the value of the selected Counter when it was reset by a trigger or by an explicit CounterReset command. + /** + * Reads the value of the selected Counter when it was reset by a trigger or by an explicit CounterReset command. + */ + PropertyI64 counterValueAtReset; + /// \brief An integer property. Sets the duration (or number of events) before the CounterEnd event is generated. + /** + * Sets the duration (or number of events) before the CounterEnd event is generated. + */ + PropertyI64 counterDuration; + /// \brief An enumerated integer property. Returns the current status of the Counter. + /** + * Returns the current status of the Counter. + * + * The following string values might be valid for this feature: + * - \b CounterIdle (Display string: 'Counter Idle'): The counter is idle. + * - \b CounterTriggerWait (Display string: 'Counter Trigger Wait'): The counter is waiting for a start trigger. + * - \b CounterActive (Display string: 'Counter Active'): The counter is counting for the specified duration. + * - \b CounterCompleted (Display string: 'Counter Completed'): The counter reached the CounterDuration count. + * - \b CounterOverflow (Display string: 'Counter Overflow'): The counter reached its maximum possible count. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterStatus; + /// \brief An enumerated integer property. Selects the source to start the Counter. + /** + * Selects the source to start the Counter. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disables the Counter trigger. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Starts with the reception of the Acquisition Trigger. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device has missed an Acquisition start trigger. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Starts with the reception of the Acquisition Start. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Starts with the reception of the Acquisition End. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Starts with the reception of the Frame Start Trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device has missed a Frame start trigger. + * - \b FrameStart (Display string: 'Frame Start'): Starts with the reception of the Frame Start. + * - \b FrameEnd (Display string: 'Frame End'): Starts with the reception of the Frame End. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Starts with the reception of the Frame Burst Start. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Starts with the reception of the Frame Burst End. + * - \b LineTrigger (Display string: 'Line Trigger'): Starts with the reception of the Line Start Trigger. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device has missed a Line start trigger. + * - \b LineStart (Display string: 'Line Start'): Starts with the reception of the Line Start. + * - \b LineEnd (Display string: 'Line End'): Starts with the reception of the Line End. + * - \b ExposureStart (Display string: 'Exposure Start'): Starts with the reception of the Exposure Start. + * - \b ExposureEnd (Display string: 'Exposure End'): Starts with the reception of the Exposure End. + * - \b Line0 (Display string: 'Line 0'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b UserOutput0 (Display string: 'User Output 0'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput1 (Display string: 'User Output 1'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput2 (Display string: 'User Output 2'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Starts with the reception of the Counter Start. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Starts with the reception of the Counter Start. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Starts with the reception of the Counter Start. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Starts with the reception of the Counter Start. + * - \b Counter0End (Display string: 'Counter 0 End'): Starts with the reception of the Counter End. + * - \b Counter1End (Display string: 'Counter 1 End'): Starts with the reception of the Counter End. + * - \b Counter2End (Display string: 'Counter 2 End'): Starts with the reception of the Counter End. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Starts with the reception of the Counter End. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Starts with the reception of the Timer Start. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Starts with the reception of the Timer Start. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Starts with the reception of the Timer Start. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Starts with the reception of the Timer Start. + * - \b Timer0End (Display string: 'Timer 0 End'): Starts with the reception of the Timer End. + * - \b Timer1End (Display string: 'Timer 1 End'): Starts with the reception of the Timer End. + * - \b Timer2End (Display string: 'Timer 2 End'): Starts with the reception of the Timer End. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Starts with the reception of the Timer End. + * - \b Encoder0 (Display string: 'Encoder 0'): Starts with the reception of the Encoder output signal. + * - \b Encoder1 (Display string: 'Encoder 1'): Starts with the reception of the Encoder output signal. + * - \b Encoder2 (Display string: 'Encoder 2'): Starts with the reception of the Encoder output signal. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Starts with the reception of the Encoder output signal. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Starts with the reception of the Logic Block output signal. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Starts on the reception of the Software Signal. + * - \b Action0 (Display string: 'Action 0'): Starts with the assertion of the chosen action signal. + * - \b Action1 (Display string: 'Action 1'): Starts with the assertion of the chosen action signal. + * - \b Action2 (Display string: 'Action 2'): Starts with the assertion of the chosen action signal. + * - \b Action\#3\# (Display string: 'Action \#3\#'): Starts with the assertion of the chosen action signal. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Starts with the reception of the chosen Link Trigger signal. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Starts with the reception of the chosen Link Trigger signal. + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Starts with the reception of the chosen Link Trigger signal. + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Starts with the reception of the chosen Link Trigger signal. + * - \b Line3 (Display string: 'Line 3'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line4 (Display string: 'Line 4'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line5 (Display string: 'Line 5'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line6 (Display string: 'Line 6'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line7 (Display string: 'Line 7'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line8 (Display string: 'Line 8'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line9 (Display string: 'Line 9'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line10 (Display string: 'Line 10'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line11 (Display string: 'Line 11'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line12 (Display string: 'Line 12'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line13 (Display string: 'Line 13'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line14 (Display string: 'Line 14'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b Line15 (Display string: 'Line 15'): Starts when the specified CounterTriggerActivation condition is met on the chosen I/O Line. + * - \b UserOutput3 (Display string: 'User Output 3'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput4 (Display string: 'User Output 4'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput5 (Display string: 'User Output 5'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput6 (Display string: 'User Output 6'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput7 (Display string: 'User Output 7'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput8 (Display string: 'User Output 8'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput9 (Display string: 'User Output 9'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput10 (Display string: 'User Output 10'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput11 (Display string: 'User Output 11'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput12 (Display string: 'User Output 12'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput13 (Display string: 'User Output 13'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput14 (Display string: 'User Output 14'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput15 (Display string: 'User Output 15'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Counter3End (Display string: 'Counter 3 End'): Starts with the reception of the Counter End. + * - \b Counter4End (Display string: 'Counter 4 End'): Starts with the reception of the Counter End. + * - \b Counter5End (Display string: 'Counter 5 End'): Starts with the reception of the Counter End. + * - \b Counter6End (Display string: 'Counter 6 End'): Starts with the reception of the Counter End. + * - \b Counter7End (Display string: 'Counter 7 End'): Starts with the reception of the Counter End. + * - \b Counter8End (Display string: 'Counter 8 End'): Starts with the reception of the Counter End. + * - \b Counter9End (Display string: 'Counter 9 End'): Starts with the reception of the Counter End. + * - \b Counter10End (Display string: 'Counter 10 End'): Starts with the reception of the Counter End. + * - \b Counter11End (Display string: 'Counter 11 End'): Starts with the reception of the Counter End. + * - \b Counter12End (Display string: 'Counter 12 End'): Starts with the reception of the Counter End. + * - \b Counter13End (Display string: 'Counter 13 End'): Starts with the reception of the Counter End. + * - \b Counter14End (Display string: 'Counter 14 End'): Starts with the reception of the Counter End. + * - \b Counter15End (Display string: 'Counter 15 End'): Starts with the reception of the Counter End. + * - \b Counter16End (Display string: 'Counter 16 End') + * - \b Timer3End (Display string: 'Timer 3 End'): Starts with the reception of the Timer End. + * - \b Timer4End (Display string: 'Timer 4 End'): Starts with the reception of the Timer End. + * - \b Timer5End (Display string: 'Timer 5 End'): Starts with the reception of the Timer End. + * - \b Timer6End (Display string: 'Timer 6 End'): Starts with the reception of the Timer End. + * - \b Timer7End (Display string: 'Timer 7 End'): Starts with the reception of the Timer End. + * - \b Timer8End (Display string: 'Timer 8 End'): Starts with the reception of the Timer End. + * - \b Timer9End (Display string: 'Timer 9 End'): Starts with the reception of the Timer End. + * - \b Timer10End (Display string: 'Timer 10 End'): Starts with the reception of the Timer End. + * - \b Timer11End (Display string: 'Timer 11 End'): Starts with the reception of the Timer End. + * - \b Timer12End (Display string: 'Timer 12 End'): Starts with the reception of the Timer End. + * - \b Timer13End (Display string: 'Timer 13 End'): Starts with the reception of the Timer End. + * - \b Timer14End (Display string: 'Timer 14 End'): Starts with the reception of the Timer End. + * - \b Timer15End (Display string: 'Timer 15 End'): Starts with the reception of the Timer End. + * - \b Timer16End (Display string: 'Timer 16 End') + * - \b Action3 (Display string: 'Action 3'): Starts with the assertion of the chosen action signal. + * - \b Action4 (Display string: 'Action 4'): Starts with the assertion of the chosen action signal. + * - \b Action5 (Display string: 'Action 5'): Starts with the assertion of the chosen action signal. + * - \b Action6 (Display string: 'Action 6'): Starts with the assertion of the chosen action signal. + * - \b Action7 (Display string: 'Action 7'): Starts with the assertion of the chosen action signal. + * - \b Action8 (Display string: 'Action 8'): Starts with the assertion of the chosen action signal. + * - \b Action9 (Display string: 'Action 9'): Starts with the assertion of the chosen action signal. + * - \b Action10 (Display string: 'Action 10'): Starts with the assertion of the chosen action signal. + * - \b Action11 (Display string: 'Action 11'): Starts with the assertion of the chosen action signal. + * - \b Action12 (Display string: 'Action 12'): Starts with the assertion of the chosen action signal. + * - \b Action13 (Display string: 'Action 13'): Starts with the assertion of the chosen action signal. + * - \b Action14 (Display string: 'Action 14'): Starts with the assertion of the chosen action signal. + * - \b Action15 (Display string: 'Action 15'): Starts with the assertion of the chosen action signal. + * - \b Action16 (Display string: 'Action 16') + * - \b mvLogicGateOR1Output (Display string: 'mv Logic Gate OR 1 Output') + * - \b mvLogicGateOR2Output (Display string: 'mv Logic Gate OR 2 Output') + * - \b mvLogicGateOR3Output (Display string: 'mv Logic Gate OR 3 Output') + * - \b mvLogicGateOR4Output (Display string: 'mv Logic Gate OR 4 Output') + * - \b mvReadOutActive (Display string: 'mv Read Out Active') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterTriggerSource; + /// \brief An enumerated integer property. Selects the activation mode of the trigger to start the Counter. + /** + * Selects the activation mode of the trigger to start the Counter. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Starts counting on the Rising Edge of the selected trigger signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Starts counting on the Falling Edge of the selected trigger signal. + * - \b AnyEdge (Display string: 'Any Edge'): Starts counting on the Falling or rising Edge of the selected trigger signal. + * - \b LevelHigh (Display string: 'Level High'): Counts as long as the selected trigger signal level is High. + * - \b LevelLow (Display string: 'Level Low'): Counts as long as the selected trigger signal level is Low. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 counterTriggerActivation; + /// \brief An enumerated integer property. Selects which Timer to configure. + /** + * Selects which Timer to configure. + * + * The following string values might be valid for this feature: + * - \b Timer0 (Display string: 'Timer 0'): Selects the Timer 0. + * - \b Timer1 (Display string: 'Timer 1'): Selects the Timer 1. + * - \b Timer2 (Display string: 'Timer 2'): Selects the Timer 2. + * - \b Timer\#3\# (Display string: 'Timer \#3\#'): Selects the Timer \#3\#. + * - \b Timer3 (Display string: 'Timer 3'): Selects the Timer 3. + * - \b Timer4 (Display string: 'Timer 4'): Selects the Timer 4. + * - \b Timer5 (Display string: 'Timer 5'): Selects the Timer 5. + * - \b Timer6 (Display string: 'Timer 6'): Selects the Timer 6. + * - \b Timer7 (Display string: 'Timer 7'): Selects the Timer 7. + * - \b Timer8 (Display string: 'Timer 8'): Selects the Timer 8. + * - \b Timer9 (Display string: 'Timer 9'): Selects the Timer 9. + * - \b Timer10 (Display string: 'Timer 10'): Selects the Timer 10. + * - \b Timer11 (Display string: 'Timer 11'): Selects the Timer 11. + * - \b Timer12 (Display string: 'Timer 12'): Selects the Timer 12. + * - \b Timer13 (Display string: 'Timer 13'): Selects the Timer 13. + * - \b Timer14 (Display string: 'Timer 14'): Selects the Timer 14. + * - \b Timer15 (Display string: 'Timer 15'): Selects the Timer 15. + * - \b Timer16 (Display string: 'Timer 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 timerSelector; + /// \brief A floating point property. Sets the duration (in microseconds) of the Timer pulse. + /** + * Sets the duration (in microseconds) of the Timer pulse. + */ + PropertyF timerDuration; + /// \brief A floating point property. Sets the duration (in microseconds) of the delay to apply at the reception of a trigger before starting the Timer. + /** + * Sets the duration (in microseconds) of the delay to apply at the reception of a trigger before starting the Timer. + */ + PropertyF timerDelay; + /// \brief A method object. Does a software reset of the selected timer and starts it. + /** + * Does a software reset of the selected timer and starts it. The timer starts immediately after the reset unless a timer trigger is active. + */ + Method timerReset; + /// \brief A floating point property. Reads or writes the current value (in microseconds) of the selected Timer. + /** + * Reads or writes the current value (in microseconds) of the selected Timer. + */ + PropertyF timerValue; + /// \brief An enumerated integer property. Returns the current status of the Timer. + /** + * Returns the current status of the Timer. + * + * The following string values might be valid for this feature: + * - \b TimerIdle (Display string: 'Timer Idle'): The Timer is idle. + * - \b TimerTriggerWait (Display string: 'Timer Trigger Wait'): The Timer is waiting for a start trigger. + * - \b TimerActive (Display string: 'Timer Active'): The Timer is counting for the specified duration. + * - \b TimerCompleted (Display string: 'Timer Completed'): The Timer reached the TimerDuration count. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 timerStatus; + /// \brief An enumerated integer property. Selects the source of the trigger to start the Timer. + /** + * Selects the source of the trigger to start the Timer. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disables the Timer trigger. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Starts with the reception of the Acquisition Trigger. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Starts with the reception of a missed Acquisition Trigger. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Starts with the reception of the Acquisition Start. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Starts with the reception of the Acquisition End. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Starts with the reception of the Frame Start Trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Starts with the reception of a missed Frame Trigger. + * - \b FrameStart (Display string: 'Frame Start'): Starts with the reception of the Frame Start. + * - \b FrameEnd (Display string: 'Frame End'): Starts with the reception of the Frame End. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Starts with the reception of the Frame Burst Start. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Starts with the reception of the Frame Burst End. + * - \b LineTrigger (Display string: 'Line Trigger'): Starts with the reception of the Line Start Trigger. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Starts with the reception of a missed Line Trigger. + * - \b LineStart (Display string: 'Line Start'): Starts with the reception of the Line Start. + * - \b LineEnd (Display string: 'Line End'): Starts with the reception of the Line End. + * - \b ExposureStart (Display string: 'Exposure Start'): Starts with the reception of the Exposure Start. + * - \b ExposureEnd (Display string: 'Exposure End'): Starts with the reception of the Exposure End. + * - \b Line0 (Display string: 'Line 0'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b UserOutput0 (Display string: 'User Output 0'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput1 (Display string: 'User Output 1'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput2 (Display string: 'User Output 2'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Starts with the reception of the Counter Start. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Starts with the reception of the Counter Start. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Starts with the reception of the Counter Start. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Starts with the reception of the Counter Start. + * - \b Counter0End (Display string: 'Counter 0 End'): Starts with the reception of the Counter End. + * - \b Counter1End (Display string: 'Counter 1 End'): Starts with the reception of the Counter End. + * - \b Counter2End (Display string: 'Counter 2 End'): Starts with the reception of the Counter End. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Starts with the reception of the Counter End. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Starts with the reception of the Timer Start. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Starts with the reception of the Timer Start. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Starts with the reception of the Timer Start. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Starts with the reception of the Timer Start. + * - \b Timer0End (Display string: 'Timer 0 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer1End (Display string: 'Timer 1 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer2End (Display string: 'Timer 2 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Encoder0 (Display string: 'Encoder 0'): Starts with the reception of the Encoder output signal. + * - \b Encoder1 (Display string: 'Encoder 1'): Starts with the reception of the Encoder output signal. + * - \b Encoder2 (Display string: 'Encoder 2'): Starts with the reception of the Encoder output signal. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Starts with the reception of the Encoder output signal. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Starts with the reception of the Logic Block output signal. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Starts on the reception of the Software Signal. + * - \b Action0 (Display string: 'Action 0'): Starts with the assertion of the chosen action signal. + * - \b Action1 (Display string: 'Action 1'): Starts with the assertion of the chosen action signal. + * - \b Action2 (Display string: 'Action 2'): Starts with the assertion of the chosen action signal. + * - \b Action\#3\# (Display string: 'Action \#3\#'): Starts with the assertion of the chosen action signal. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Starts with the reception of the chosen Link Trigger. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Starts with the reception of the chosen Link Trigger. + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Starts with the reception of the chosen Link Trigger. + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Starts with the reception of the chosen Link Trigger. + * - \b Line3 (Display string: 'Line 3'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line4 (Display string: 'Line 4'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line5 (Display string: 'Line 5'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line6 (Display string: 'Line 6'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line7 (Display string: 'Line 7'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line8 (Display string: 'Line 8'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line9 (Display string: 'Line 9'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line10 (Display string: 'Line 10'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line11 (Display string: 'Line 11'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line12 (Display string: 'Line 12'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line13 (Display string: 'Line 13'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line14 (Display string: 'Line 14'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line15 (Display string: 'Line 15'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b UserOutput3 (Display string: 'User Output 3'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput4 (Display string: 'User Output 4'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput5 (Display string: 'User Output 5'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput6 (Display string: 'User Output 6'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput7 (Display string: 'User Output 7'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Counter3End (Display string: 'Counter 3 End'): Starts with the reception of the Counter End. + * - \b Counter4End (Display string: 'Counter 4 End'): Starts with the reception of the Counter End. + * - \b Counter5End (Display string: 'Counter 5 End'): Starts with the reception of the Counter End. + * - \b Counter6End (Display string: 'Counter 6 End'): Starts with the reception of the Counter End. + * - \b Counter7End (Display string: 'Counter 7 End'): Starts with the reception of the Counter End. + * - \b Counter8End (Display string: 'Counter 8 End'): Starts with the reception of the Counter End. + * - \b Counter9End (Display string: 'Counter 9 End'): Starts with the reception of the Counter End. + * - \b Counter10End (Display string: 'Counter 10 End'): Starts with the reception of the Counter End. + * - \b Counter11End (Display string: 'Counter 11 End'): Starts with the reception of the Counter End. + * - \b Counter12End (Display string: 'Counter 12 End'): Starts with the reception of the Counter End. + * - \b Counter13End (Display string: 'Counter 13 End'): Starts with the reception of the Counter End. + * - \b Counter14End (Display string: 'Counter 14 End'): Starts with the reception of the Counter End. + * - \b Counter15End (Display string: 'Counter 15 End'): Starts with the reception of the Counter End. + * - \b Counter16End (Display string: 'Counter 16 End') + * - \b Timer3End (Display string: 'Timer 3 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer4End (Display string: 'Timer 4 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer5End (Display string: 'Timer 5 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer6End (Display string: 'Timer 6 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer7End (Display string: 'Timer 7 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer8End (Display string: 'Timer 8 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer9End (Display string: 'Timer 9 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer10End (Display string: 'Timer 10 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer11End (Display string: 'Timer 11 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer12End (Display string: 'Timer 12 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer13End (Display string: 'Timer 13 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer14End (Display string: 'Timer 14 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer15End (Display string: 'Timer 15 End'): Starts with the reception of the Timer End. Note that a timer can retrigger itself to achieve a free running Timer. + * - \b Timer16End (Display string: 'Timer 16 End') + * - \b Action3 (Display string: 'Action 3'): Starts with the assertion of the chosen action signal. + * - \b Action4 (Display string: 'Action 4'): Starts with the assertion of the chosen action signal. + * - \b Action5 (Display string: 'Action 5'): Starts with the assertion of the chosen action signal. + * - \b Action6 (Display string: 'Action 6'): Starts with the assertion of the chosen action signal. + * - \b Action7 (Display string: 'Action 7'): Starts with the assertion of the chosen action signal. + * - \b Action8 (Display string: 'Action 8'): Starts with the assertion of the chosen action signal. + * - \b Action9 (Display string: 'Action 9'): Starts with the assertion of the chosen action signal. + * - \b Action10 (Display string: 'Action 10'): Starts with the assertion of the chosen action signal. + * - \b Action11 (Display string: 'Action 11'): Starts with the assertion of the chosen action signal. + * - \b Action12 (Display string: 'Action 12'): Starts with the assertion of the chosen action signal. + * - \b Action13 (Display string: 'Action 13'): Starts with the assertion of the chosen action signal. + * - \b Action14 (Display string: 'Action 14'): Starts with the assertion of the chosen action signal. + * - \b Action15 (Display string: 'Action 15'): Starts with the assertion of the chosen action signal. + * - \b Action16 (Display string: 'Action 16') + * - \b mvLogicGateOR1Output (Display string: 'mv Logic Gate OR 1 Output') + * - \b mvLogicGateOR2Output (Display string: 'mv Logic Gate OR 2 Output') + * - \b mvLogicGateOR3Output (Display string: 'mv Logic Gate OR 3 Output') + * - \b mvLogicGateOR4Output (Display string: 'mv Logic Gate OR 4 Output') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 timerTriggerSource; + /// \brief An enumerated integer property. Selects the activation mode of the trigger to start the Timer. + /** + * Selects the activation mode of the trigger to start the Timer. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Starts counting on the Rising Edge of the selected trigger signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Starts counting on the Falling Edge of the selected trigger signal. + * - \b AnyEdge (Display string: 'Any Edge'): Starts counting on the Falling or Rising Edge of the selected trigger signal. + * - \b LevelHigh (Display string: 'Level High'): Counts as long as the selected trigger signal level is High. + * - \b LevelLow (Display string: 'Level Low'): Counts as long as the selected trigger signal level is Low. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 timerTriggerActivation; + /// \brief A floating point property. Sets the minimum period between two valid timer triggers. + /** + * Sets the minimum period between two valid timer triggers. + */ + PropertyF timerTriggerArmDelay; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the quadrature Encoder Control features. +/** + * A category that contains the quadrature Encoder Control features. + * \ingroup GenICamInterfaceDevice + */ +class EncoderControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::EncoderControl object. + explicit EncoderControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + encoderSelector(), + encoderSourceA(), + encoderSourceB(), + encoderMode(), + encoderDivider(), + encoderOutputMode(), + encoderStatus(), + encoderTimeout(), + encoderResetSource(), + encoderResetActivation(), + encoderReset(), + encoderValue(), + encoderValueAtReset(), + encoderResolution() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( encoderSelector, "EncoderSelector" ); + locator.bindComponent( encoderSourceA, "EncoderSourceA" ); + locator.bindComponent( encoderSourceB, "EncoderSourceB" ); + locator.bindComponent( encoderMode, "EncoderMode" ); + locator.bindComponent( encoderDivider, "EncoderDivider" ); + locator.bindComponent( encoderOutputMode, "EncoderOutputMode" ); + locator.bindComponent( encoderStatus, "EncoderStatus" ); + locator.bindComponent( encoderTimeout, "EncoderTimeout" ); + locator.bindComponent( encoderResetSource, "EncoderResetSource" ); + locator.bindComponent( encoderResetActivation, "EncoderResetActivation" ); + locator.bindComponent( encoderReset, "EncoderReset@i" ); + locator.bindComponent( encoderValue, "EncoderValue" ); + locator.bindComponent( encoderValueAtReset, "EncoderValueAtReset" ); + locator.bindComponent( encoderResolution, "EncoderResolution" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which Encoder to configure. + /** + * Selects which Encoder to configure. + * + * The following string values might be valid for this feature: + * - \b Encoder0 (Display string: 'Encoder 0'): Selects Encoder 0. + * - \b Encoder1 (Display string: 'Encoder 1'): Selects Encoder 1. + * - \b Encoder2 (Display string: 'Encoder 2'): Selects Encoder 2. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Selects Encoder \#3\#. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderSelector; + /// \brief An enumerated integer property. Selects the signal which will be the source of the A input of the Encoder. + /** + * Selects the signal which will be the source of the A input of the Encoder. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Counter is stopped. + * - \b Line0 (Display string: 'Line 0'): Encoder Forward input is taken from the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Encoder Forward input is taken from the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Encoder Forward input is taken from the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Encoder Forward input is taken from the chosen I/O Line. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderSourceA; + /// \brief An enumerated integer property. Selects the signal which will be the source of the B input of the Encoder. + /** + * Selects the signal which will be the source of the B input of the Encoder. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Counter is stopped. + * - \b Line0 (Display string: 'Line 0'): Encoder Reverse input is taken from the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Encoder Reverse input is taken from the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Encoder Reverse input is taken from the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Encoder Reverse input is taken from the chosen I/O Line. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderSourceB; + /// \brief An enumerated integer property. Selects if the count of encoder uses FourPhase mode with jitter filtering or the HighResolution mode without jitter filtering. + /** + * Selects if the count of encoder uses FourPhase mode with jitter filtering or the HighResolution mode without jitter filtering. + * + * The following string values might be valid for this feature: + * - \b FourPhase (Display string: 'Four Phase'): The counter increments or decrements 1 for every full quadrature cycle with jitter filtering. + * - \b HighResolution (Display string: 'High Resolution'): The counter increments or decrements every quadrature phase for high resolution counting, but without jitter filtering. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderMode; + /// \brief An integer property. Sets how many Encoder increments/decrements are needed to generate an Encoder output pulse signal. + /** + * Sets how many Encoder increments/decrements are needed to generate an Encoder output pulse signal. + */ + PropertyI64 encoderDivider; + /// \brief An enumerated integer property. Selects the conditions for the Encoder interface to generate a valid Encoder output signal. + /** + * Selects the conditions for the Encoder interface to generate a valid Encoder output signal. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): No output pulse are generated. + * - \b PositionUp (Display string: 'Position Up'): Output pulses are generated at all new positions in the positive direction. If the encoder reverses no output pulse are generated until it has again passed the position where the reversal started. + * - \b PositionDown (Display string: 'Position Down'): Output pulses are generated at all new positions in the negative direction. If the encoder reverses no output pulse are generated until it has again passed the position where the reversal started. + * - \b DirectionUp (Display string: 'Direction Up'): Output pulses are generated at all position increments in the positive direction while ignoring negative direction motion. + * - \b DirectionDown (Display string: 'Direction Down'): Output pulses are generated at all position increments in the negative direction while ignoring positive direction motion. + * - \b Motion (Display string: 'Motion'): Output pulses are generated at all motion increments in both directions. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + * + * The following figure explains the different \b encoderOutputModes + * + *
+ * \image html EventControl.png + * encoderOutputModes + *
+ * + */ + PropertyI64 encoderOutputMode; + /// \brief An enumerated integer property. Returns the motion status of the encoder. + /** + * Returns the motion status of the encoder. + * + * The following string values might be valid for this feature: + * - \b EncoderUp (Display string: 'Encoder Up'): The encoder counter last incremented. + * - \b EncoderDown (Display string: 'Encoder Down'): The encoder counter last decremented. + * - \b EncoderIdle (Display string: 'Encoder Idle'): The encoder is not active. + * - \b EncoderStatic (Display string: 'Encoder Static'): No motion within the EncoderTimeout time. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderStatus; + /// \brief A floating point property. Sets the maximum time interval between encoder counter increments before the status turns to static. + /** + * Sets the maximum time interval between encoder counter increments before the status turns to static. + */ + PropertyF encoderTimeout; + /// \brief An enumerated integer property. Selects the signals that will be the source to reset the Encoder. + /** + * Selects the signals that will be the source to reset the Encoder. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disable the Encoder Reset trigger. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Resets with the reception of the Acquisition Trigger. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Resets with the reception of a missed Acquisition Trigger. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Resets with the reception of the Acquisition Start. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Resets with the reception of the Acquisition End. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Resets with the reception of the Frame Start Trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Resets with the reception of a missed Frame Trigger. + * - \b FrameStart (Display string: 'Frame Start'): Resets with the reception of the Frame Start. + * - \b FrameEnd (Display string: 'Frame End'): Resets with the reception of the Frame End. + * - \b ExposureStart (Display string: 'Exposure Start'): Resets with the reception of the Exposure Start. + * - \b ExposureEnd (Display string: 'Exposure End'): Resets with the reception of the Exposure End. + * - \b Line0 (Display string: 'Line 0'): Resets by the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Resets by the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Resets by the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Resets by the chosen I/O Line. + * - \b UserOutput0 (Display string: 'User Output 0'): Resets by the chosen User Output bit. + * - \b UserOutput1 (Display string: 'User Output 1'): Resets by the chosen User Output bit. + * - \b UserOutput2 (Display string: 'User Output 2'): Resets by the chosen User Output bit. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Resets by the chosen User Output bit. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Resets with the reception of the Counter Start. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Resets with the reception of the Counter Start. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Resets with the reception of the Counter Start. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Resets with the reception of the Counter Start. + * - \b Counter0End (Display string: 'Counter 0 End'): Resets with the reception of the Counter End. + * - \b Counter1End (Display string: 'Counter 1 End'): Resets with the reception of the Counter End. + * - \b Counter2End (Display string: 'Counter 2 End'): Resets with the reception of the Counter End. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Resets with the reception of the Counter End. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Resets with the reception of the Timer Start. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Resets with the reception of the Timer Start. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Resets with the reception of the Timer Start. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Resets with the reception of the Timer Start. + * - \b Timer0End (Display string: 'Timer 0 End'): Resets with the reception of the Timer End. + * - \b Timer1End (Display string: 'Timer 1 End'): Resets with the reception of the Timer End. + * - \b Timer2End (Display string: 'Timer 2 End'): Resets with the reception of the Timer End. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Resets with the reception of the Timer End. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Reset by the choosen Logic Block signal. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Reset by the choosen Logic Block signal. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Reset by the choosen Logic Block signal. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Reset by the choosen Logic Block signal. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Resets on the reception of the Software Signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Resets on the reception of the Software Signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Resets on the reception of the Software Signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Resets on the reception of the Software Signal. + * - \b Action0 (Display string: 'Action 0'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action1 (Display string: 'Action 1'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action2 (Display string: 'Action 2'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b Action\#3\# (Display string: 'Action \#3\#'): Resets on assertions of the chosen action signal (Broadcasted signal on the transport layer). + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Resets on the reception of the chosen Link Trigger (received from the transport layer). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderResetSource; + /// \brief An enumerated integer property. Selects the Activation mode of the Encoder Reset Source signal. + /** + * Selects the Activation mode of the Encoder Reset Source signal. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Resets the Encoder on the Rising Edge of the signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Resets the Encoder on the Falling Edge of the signal. + * - \b AnyEdge (Display string: 'Any Edge'): Resets the Encoder on the Falling or rising Edge of the selected signal. + * - \b LevelHigh (Display string: 'Level High'): Resets the Encoder as long as the selected signal level is High. + * - \b LevelLow (Display string: 'Level Low'): Resets the Encoder as long as the selected signal level is Low. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 encoderResetActivation; + /// \brief A method object. Does a software reset of the selected Encoder and starts it. + /** + * Does a software reset of the selected Encoder and starts it. The Encoder starts counting events immediately after the reset. EncoderReset can be used to reset the Encoder independently from the EncoderResetSource. + */ + Method encoderReset; + /// \brief An integer property. Reads or writes the current value of the position counter of the selected Encoder. + /** + * Reads or writes the current value of the position counter of the selected Encoder. + */ + PropertyI64 encoderValue; + /// \brief An integer property. Reads the value of the of the position counter of the selected Encoder when it was reset by a signal or by an explicit EncoderReset command. + /** + * Reads the value of the of the position counter of the selected Encoder when it was reset by a signal or by an explicit EncoderReset command. + */ + PropertyI64 encoderValueAtReset; + /// \brief A floating point property. Defines the resolution of one encoder step. + /** + * Defines the resolution of one encoder step. + */ + PropertyF encoderResolution; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Logic Block control features. +/** + * A category that contains the Logic Block control features. + * \ingroup GenICamInterfaceDevice + */ +class LogicBlockControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::LogicBlockControl object. + explicit LogicBlockControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + logicBlockSelector(), + logicBlockFunction(), + logicBlockInputNumber(), + logicBlockInputSelector(), + logicBlockInputSource(), + logicBlockInputInverter(), + logicBlockLUTIndex(), + logicBlockLUTValue(), + logicBlockLUTValueAll(), + logicBlockLUTSelector() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( logicBlockSelector, "LogicBlockSelector" ); + locator.bindComponent( logicBlockFunction, "LogicBlockFunction" ); + locator.bindComponent( logicBlockInputNumber, "LogicBlockInputNumber" ); + locator.bindComponent( logicBlockInputSelector, "LogicBlockInputSelector" ); + locator.bindComponent( logicBlockInputSource, "LogicBlockInputSource" ); + locator.bindComponent( logicBlockInputInverter, "LogicBlockInputInverter" ); + locator.bindComponent( logicBlockLUTIndex, "LogicBlockLUTIndex" ); + locator.bindComponent( logicBlockLUTValue, "LogicBlockLUTValue" ); + locator.bindComponent( logicBlockLUTValueAll, "LogicBlockLUTValueAll" ); + locator.bindComponent( logicBlockLUTSelector, "LogicBlockLUTSelector" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Specifies the Logic Block to configure. + /** + * Specifies the Logic Block to configure. + * + * The following string values might be valid for this feature: + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Logic Block 0 is selected. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Logic Block 1 is selected. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Logic Block 2 is selected. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Logic Block \#3\# is selected. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 logicBlockSelector; + /// \brief An enumerated integer property. Selects the combinational logic Function of the Logic Block to configure. + /** + * Selects the combinational logic Function of the Logic Block to configure. + * + * The following string values might be valid for this feature: + * - \b AND (Display string: 'AND'): Selects a Logic Block that does the logical AND of all the inputs. + * - \b OR (Display string: 'OR'): Selects a Logic Block that does the logical OR of all the inputs. + * - \b LUT (Display string: 'LUT'): Selects a Logic Block that does a Look Up Table Transformation on all the inputs. + * - \b LatchedLUT (Display string: 'Latched LUT'): Selects a Logic Block with 2 LUTs as inputs to a Flip-Flop. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 logicBlockFunction; + /// \brief An integer property. Specifies the number of active signal inputs of the Logic Block. + /** + * Specifies the number of active signal inputs of the Logic Block. + */ + PropertyI64 logicBlockInputNumber; + /// \brief An integer property. Selects the Logic Block's input to configure. + /** + * Selects the Logic Block's input to configure. + */ + PropertyI64 logicBlockInputSelector; + /// \brief An enumerated integer property. Selects the source signal for the input into the Logic Block. + /** + * Selects the source signal for the input into the Logic Block. True or False indicates the input is forced constant. + * + * The following string values might be valid for this feature: + * - \b True (Display string: 'True'): Logic Block input is forced to One. + * - \b False (Display string: 'False'): Logic Block input is forced to Zero. + * - \b AcquisitionTriggerWait (Display string: 'Acquisition Trigger Wait'): Device is currently waiting for a trigger for the capture of one or many Frames. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device is currently waiting for a trigger for the capture of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device has missed a trigger for the capture of one or many Frames. + * - \b AcquisitionActive (Display string: 'Acquisition Active'): Device is acquiring one or many Frames. + * - \b FrameTriggerWait (Display string: 'Frame Trigger Wait'): Device is currently waiting for a Frame start trigger. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device is currently waiting for a Frame start trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device has missed a Frame start trigger. + * - \b FrameActive (Display string: 'Frame Active'): Device is currently doing the capture of a Frame. + * - \b ExposureActive (Display string: 'Exposure Active'): Device is doing the exposure of a Frame (or Line). + * - \b LineTriggerWait (Display string: 'Line Trigger Wait'): Device is currently waiting for a Line start trigger. + * - \b LineTrigger (Display string: 'Line Trigger'): Device is currently waiting for a Line start trigger. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device has missed a Line start trigger. + * - \b LineActive (Display string: 'Line Active'): Device is currently doing the capture of a Line. + * - \b Counter0Active (Display string: 'Counter 0 Active'): The chosen counter is in active state (counting). + * - \b Counter1Active (Display string: 'Counter 1 Active'): The chosen counter is in active state (counting). + * - \b Counter2Active (Display string: 'Counter 2 Active'): The chosen counter is in active state (counting). + * - \b Counter\#3\#Active (Display string: 'Counter \#3\# Active'): The chosen counter is in active state (counting). + * - \b Timer0Active (Display string: 'Timer 0 Active'): The chosen Timer is in active state. + * - \b Timer1Active (Display string: 'Timer 1 Active'): The chosen Timer is in active state. + * - \b Timer2Active (Display string: 'Timer 2 Active'): The chosen Timer is in active state. + * - \b Timer\#3\#Active (Display string: 'Timer \#3\# Active'): The chosen Timer is in active state. + * - \b Encoder0 (Display string: 'Encoder 0'): The chosen Encoder Output state. + * - \b Encoder1 (Display string: 'Encoder 1'): The chosen Encoder Output state. + * - \b Encoder2 (Display string: 'Encoder 2'): The chosen Encoder Output state. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): The chosen Encoder Output state. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): The choosen Logic Block output state. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): The choosen Logic Block output state. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): The choosen Logic Block output state. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): The choosen Logic Block output state. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): The choosen Software Signal output state. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): The choosen Software Signal output state. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): The choosen Software Signal output state. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): The choosen Software Signal output state. + * - \b Line0 (Display string: 'Line 0'): The chosen I/OLine state. + * - \b Line1 (Display string: 'Line 1'): The chosen I/OLine state. + * - \b Line2 (Display string: 'Line 2'): The chosen I/OLine state. + * - \b Line\#3\# (Display string: 'Line \#3\#'): The chosen I/OLine state. + * - \b UserOutput0 (Display string: 'User Output 0'): The chosen User Output bit state as defined by its current UserOutputValue. + * - \b UserOutput1 (Display string: 'User Output 1'): The chosen User Output bit state as defined by its current UserOutputValue. + * - \b UserOutput2 (Display string: 'User Output 2'): The chosen User Output bit state as defined by its current UserOutputValue. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): The chosen User Output bit state as defined by its current UserOutputValue. + * - \b Stream0TransferActive (Display string: 'Stream 0 Transfer Active'): Transfer on the stream is active. + * - \b Stream1TransferActive (Display string: 'Stream 1 Transfer Active'): Transfer on the stream is active. + * - \b Stream\#2\#TransferActive (Display string: 'Stream \#2\# Transfer Active'): Transfer on the stream is active. + * - \b Stream0TransferPaused (Display string: 'Stream 0 Transfer Paused'): Transfer on the stream is paused. + * - \b Stream1TransferPaused (Display string: 'Stream 1 Transfer Paused'): Transfer on the stream is paused. + * - \b Stream\#2\#TransferPaused (Display string: 'Stream \#2\# Transfer Paused'): Transfer on the stream is paused. + * - \b Stream0TransferStopping (Display string: 'Stream 0 Transfer Stopping'): Transfer on the stream is stopping. + * - \b Stream1TransferStopping (Display string: 'Stream 1 Transfer Stopping'): Transfer on the stream is stopping. + * - \b Stream\#2\#TransferStopping (Display string: 'Stream \#2\# Transfer Stopping'): Transfer on the stream is stopping. + * - \b Stream0TransferStopped (Display string: 'Stream 0 Transfer Stopped'): Transfer on the stream is stopped. + * - \b Stream1TransferStopped (Display string: 'Stream 1 Transfer Stopped'): Transfer on the stream is stopped. + * - \b Stream\#2\#TransferStopped (Display string: 'Stream \#2\# Transfer Stopped'): Transfer on the stream is stopped. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Transfer on the stream is in overflow. + * - \b Stream1TransferOverflow (Display string: 'Stream 1 Transfer Overflow'): Transfer on the stream is in overflow. + * - \b Stream\#2\#TransferOverflow (Display string: 'Stream \#2\# Transfer Overflow'): Transfer on the stream is in overflow. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 logicBlockInputSource; + /// \brief A boolean property. Selects if the selected Logic Block Input source signal is inverted. + /** + * Selects if the selected Logic Block Input source signal is inverted. This feature is not available when the LogicBlockInputSource is set to True or False. + */ + PropertyIBoolean logicBlockInputInverter; + /// \brief An integer property. Controls the index of the truth table to access in the selected LUT. + /** + * Controls the index of the truth table to access in the selected LUT. + */ + PropertyI64 logicBlockLUTIndex; + /// \brief A boolean property. Read or Write the Value associated with the entry at index LogicBlockLUTIndex of the selected LUT. + /** + * Read or Write the Value associated with the entry at index LogicBlockLUTIndex of the selected LUT. + */ + PropertyIBoolean logicBlockLUTValue; + /// \brief An integer property. Sets the values of all the output bits of the selected LUT in one access ignoring LogicBlockLUTIndex. + /** + * Sets the values of all the output bits of the selected LUT in one access ignoring LogicBlockLUTIndex. LogicBlockLUTValueAll value can be any binary number and each bit correspond to the output value for the corresponding index (i.e. Bit 0 = LUT Index 0 output binary value). + */ + PropertyI64 logicBlockLUTValueAll; + /// \brief An enumerated integer property. Selects which of the two LUTs to configure when the selected Logic Block is a Latched dual LUTs (i.e: LogicalBlockFunction = LatchedLUT). + /** + * Selects which of the two LUTs to configure when the selected Logic Block is a Latched dual LUTs (i.e: LogicalBlockFunction = LatchedLUT). + * + * The following string values might be valid for this feature: + * - \b Value (Display string: 'Value'): Selects the LUT controlling the data input of the flip-flop. + * - \b Enable (Display string: 'Enable'): Selects the LUT controlling the enable input of the flip-flop. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 logicBlockLUTSelector; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Software Signal Control features. +/** + * A category that contains the Software Signal Control features. + * \ingroup GenICamInterfaceDevice + */ +class SoftwareSignalControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::SoftwareSignalControl object. + explicit SoftwareSignalControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + softwareSignalSelector(), + softwareSignalPulse() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( softwareSignalSelector, "SoftwareSignalSelector" ); + locator.bindComponent( softwareSignalPulse, "SoftwareSignalPulse@i" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which Software Signal features to control. + /** + * Selects which Software Signal features to control. + * + * The following string values might be valid for this feature: + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Selects the software generated signal to control. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Selects the software generated signal to control. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Selects the software generated signal to control. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Selects the software generated signal to control. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 softwareSignalSelector; + /// \brief A method object. Generates a pulse signal that can be used as a software trigger. + /** + * Generates a pulse signal that can be used as a software trigger. This command can be used to trigger other modules that accept a SoftwareSignal as trigger source. + */ + Method softwareSignalPulse; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Action control features. +/** + * A category that contains the Action control features. + * \ingroup GenICamInterfaceDevice + */ +class ActionControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::ActionControl object. + explicit ActionControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + actionUnconditionalMode(), + actionDeviceKey(), + actionQueueSize(), + actionSelector(), + actionGroupMask(), + actionGroupKey() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( actionUnconditionalMode, "ActionUnconditionalMode" ); + locator.bindComponent( actionDeviceKey, "ActionDeviceKey" ); + locator.bindComponent( actionQueueSize, "ActionQueueSize" ); + locator.bindComponent( actionSelector, "ActionSelector" ); + locator.bindComponent( actionGroupMask, "ActionGroupMask" ); + locator.bindComponent( actionGroupKey, "ActionGroupKey" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Enables the unconditional action command mode where action commands are processed even when the primary control channel is closed. + /** + * Enables the unconditional action command mode where action commands are processed even when the primary control channel is closed. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Unconditional mode is disabled. + * - \b On (Display string: 'On'): Unconditional mode is enabled. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 actionUnconditionalMode; + /// \brief An integer property. Provides the device key that allows the device to check the validity of action commands. + /** + * Provides the device key that allows the device to check the validity of action commands. The device internal assertion of an action signal is only authorized if the ActionDeviceKey and the action device key value in the protocol message are equal. + */ + PropertyI64 actionDeviceKey; + /// \brief An integer property. Indicates the size of the scheduled action commands queue. + /** + * Indicates the size of the scheduled action commands queue. This number represents the maximum number of scheduled action commands that can be pending at a given point in time. + */ + PropertyI64 actionQueueSize; + /// \brief An integer property. Selects to which Action Signal further Action settings apply. + /** + * Selects to which Action Signal further Action settings apply. + */ + PropertyI64 actionSelector; + /// \brief An integer property. Provides the mask that the device will use to validate the action on reception of the action protocol message. + /** + * Provides the mask that the device will use to validate the action on reception of the action protocol message. + */ + PropertyI64 actionGroupMask; + /// \brief An integer property. Provides the key that the device will use to validate the action on reception of the action protocol message. + /** + * Provides the key that the device will use to validate the action on reception of the action protocol message. + */ + PropertyI64 actionGroupKey; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains Event control features. +/** + * A category that contains Event control features. + * \ingroup GenICamInterfaceDevice + */ +class EventControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::EventControl object. + explicit EventControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + eventSelector(), + eventNotification(), + eventAcquisitionTrigger(), + eventAcquisitionTriggerTimestamp(), + eventAcquisitionTriggerFrameID(), + eventAcquisitionTriggerMissed(), + eventAcquisitionTriggerMissedTimestamp(), + eventAcquisitionTriggerMissedFrameID(), + eventAcquisitionStart(), + eventAcquisitionStartTimestamp(), + eventAcquisitionStartFrameID(), + eventAcquisitionEnd(), + eventAcquisitionEndTimestamp(), + eventAcquisitionEndFrameID(), + eventAcquisitionTransferStart(), + eventAcquisitionTransferStartTimestamp(), + eventAcquisitionTransferStartFrameID(), + eventAcquisitionTransferEnd(), + eventAcquisitionTransferEndTimestamp(), + eventAcquisitionTransferEndFrameID(), + eventAcquisitionError(), + eventAcquisitionErrorTimestamp(), + eventAcquisitionErrorFrameID(), + eventFrameBurstStart(), + eventFrameBurstStartTimestamp(), + eventFrameBurstStartFrameID(), + eventFrameBurstEnd(), + eventFrameBurstEndTimestamp(), + eventFrameBurstEndFrameID(), + eventFrameTrigger(), + eventFrameTriggerTimestamp(), + eventFrameTriggerFrameID(), + eventFrameTriggerMissed(), + eventFrameTriggerMissedTimestamp(), + eventFrameTriggerMissedFrameID(), + eventFrameStart(), + eventFrameStartTimestamp(), + eventFrameStartFrameID(), + eventFrameEnd(), + eventFrameEndTimestamp(), + eventFrameEndFrameID(), + eventFrameTransferStart(), + eventFrameTransferStartTimestamp(), + eventFrameTransferStartFrameID(), + eventFrameTransferEnd(), + eventFrameTransferEndTimestamp(), + eventFrameTransferEndFrameID(), + eventLineTrigger(), + eventLineTriggerTimestamp(), + eventLineTriggerFrameID(), + eventLineTriggerMissed(), + eventLineTriggerMissedTimestamp(), + eventLineTriggerMissedFrameID(), + eventLineStart(), + eventLineStartTimestamp(), + eventLineStartFrameID(), + eventLineEnd(), + eventLineEndTimestamp(), + eventLineEndFrameID(), + eventExposureStart(), + eventExposureStartTimestamp(), + eventExposureStartFrameID(), + eventExposureEnd(), + eventExposureEndTimestamp(), + eventExposureEndFrameID(), + eventActionLate(), + eventActionLateTimestamp(), + eventActionLateFrameID(), + eventPrimaryApplicationSwitch(), + eventPrimaryApplicationSwitchTimestamp(), + eventPrimaryApplicationSwitchFrameID(), + eventTest(), + eventTestTimestamp(), + eventCounter0Start(), + eventCounter0StartTimestamp(), + eventCounter0StartFrameID(), + eventCounter1Start(), + eventCounter1StartTimestamp(), + eventCounter1StartFrameID(), + eventCounter2Start(), + eventCounter2StartTimestamp(), + eventCounter2StartFrameID(), + eventCounter3Start(), + eventCounter3StartTimestamp(), + eventCounter3StartFrameID(), + eventCounter4Start(), + eventCounter4StartTimestamp(), + eventCounter4StartFrameID(), + eventCounter5Start(), + eventCounter5StartTimestamp(), + eventCounter5StartFrameID(), + eventCounter6Start(), + eventCounter6StartTimestamp(), + eventCounter6StartFrameID(), + eventCounter7Start(), + eventCounter7StartTimestamp(), + eventCounter7StartFrameID(), + eventCounter8Start(), + eventCounter8StartTimestamp(), + eventCounter8StartFrameID(), + eventCounter9Start(), + eventCounter9StartTimestamp(), + eventCounter9StartFrameID(), + eventCounter10Start(), + eventCounter10StartTimestamp(), + eventCounter10StartFrameID(), + eventCounter11Start(), + eventCounter11StartTimestamp(), + eventCounter11StartFrameID(), + eventCounter12Start(), + eventCounter12StartTimestamp(), + eventCounter12StartFrameID(), + eventCounter13Start(), + eventCounter13StartTimestamp(), + eventCounter13StartFrameID(), + eventCounter14Start(), + eventCounter14StartTimestamp(), + eventCounter14StartFrameID(), + eventCounter0End(), + eventCounter0EndTimestamp(), + eventCounter0EndFrameID(), + eventCounter1End(), + eventCounter1EndTimestamp(), + eventCounter1EndFrameID(), + eventCounter2End(), + eventCounter2EndTimestamp(), + eventCounter2EndFrameID(), + eventCounter3End(), + eventCounter3EndTimestamp(), + eventCounter3EndFrameID(), + eventCounter4End(), + eventCounter4EndTimestamp(), + eventCounter4EndFrameID(), + eventCounter5End(), + eventCounter5EndTimestamp(), + eventCounter5EndFrameID(), + eventCounter6End(), + eventCounter6EndTimestamp(), + eventCounter6EndFrameID(), + eventCounter7End(), + eventCounter7EndTimestamp(), + eventCounter7EndFrameID(), + eventCounter8End(), + eventCounter8EndTimestamp(), + eventCounter8EndFrameID(), + eventCounter9End(), + eventCounter9EndTimestamp(), + eventCounter9EndFrameID(), + eventCounter10End(), + eventCounter10EndTimestamp(), + eventCounter10EndFrameID(), + eventCounter11End(), + eventCounter11EndTimestamp(), + eventCounter11EndFrameID(), + eventCounter12End(), + eventCounter12EndTimestamp(), + eventCounter12EndFrameID(), + eventCounter13End(), + eventCounter13EndTimestamp(), + eventCounter13EndFrameID(), + eventCounter14End(), + eventCounter14EndTimestamp(), + eventCounter14EndFrameID(), + eventTimer0Start(), + eventTimer0StartTimestamp(), + eventTimer0StartFrameID(), + eventTimer1Start(), + eventTimer1StartTimestamp(), + eventTimer1StartFrameID(), + eventTimer2Start(), + eventTimer2StartTimestamp(), + eventTimer2StartFrameID(), + eventTimer3Start(), + eventTimer3StartTimestamp(), + eventTimer3StartFrameID(), + eventTimer4Start(), + eventTimer4StartTimestamp(), + eventTimer4StartFrameID(), + eventTimer5Start(), + eventTimer5StartTimestamp(), + eventTimer5StartFrameID(), + eventTimer6Start(), + eventTimer6StartTimestamp(), + eventTimer6StartFrameID(), + eventTimer7Start(), + eventTimer7StartTimestamp(), + eventTimer7StartFrameID(), + eventTimer8Start(), + eventTimer8StartTimestamp(), + eventTimer8StartFrameID(), + eventTimer9Start(), + eventTimer9StartTimestamp(), + eventTimer9StartFrameID(), + eventTimer10Start(), + eventTimer10StartTimestamp(), + eventTimer10StartFrameID(), + eventTimer11Start(), + eventTimer11StartTimestamp(), + eventTimer11StartFrameID(), + eventTimer12Start(), + eventTimer12StartTimestamp(), + eventTimer12StartFrameID(), + eventTimer13Start(), + eventTimer13StartTimestamp(), + eventTimer13StartFrameID(), + eventTimer14Start(), + eventTimer14StartTimestamp(), + eventTimer14StartFrameID(), + eventTimer0End(), + eventTimer0EndTimestamp(), + eventTimer0EndFrameID(), + eventTimer1End(), + eventTimer1EndTimestamp(), + eventTimer1EndFrameID(), + eventTimer2End(), + eventTimer2EndTimestamp(), + eventTimer2EndFrameID(), + eventTimer3End(), + eventTimer3EndTimestamp(), + eventTimer3EndFrameID(), + eventTimer4End(), + eventTimer4EndTimestamp(), + eventTimer4EndFrameID(), + eventTimer5End(), + eventTimer5EndTimestamp(), + eventTimer5EndFrameID(), + eventTimer6End(), + eventTimer6EndTimestamp(), + eventTimer6EndFrameID(), + eventTimer7End(), + eventTimer7EndTimestamp(), + eventTimer7EndFrameID(), + eventTimer8End(), + eventTimer8EndTimestamp(), + eventTimer8EndFrameID(), + eventTimer9End(), + eventTimer9EndTimestamp(), + eventTimer9EndFrameID(), + eventTimer10End(), + eventTimer10EndTimestamp(), + eventTimer10EndFrameID(), + eventTimer11End(), + eventTimer11EndTimestamp(), + eventTimer11EndFrameID(), + eventTimer12End(), + eventTimer12EndTimestamp(), + eventTimer12EndFrameID(), + eventTimer13End(), + eventTimer13EndTimestamp(), + eventTimer13EndFrameID(), + eventTimer14End(), + eventTimer14EndTimestamp(), + eventTimer14EndFrameID(), + eventEncoder0Stopped(), + eventEncoder0StoppedTimestamp(), + eventEncoder0StoppedFrameID(), + eventEncoder1Stopped(), + eventEncoder1StoppedTimestamp(), + eventEncoder1StoppedFrameID(), + eventEncoder2Stopped(), + eventEncoder2StoppedTimestamp(), + eventEncoder2StoppedFrameID(), + eventEncoder3Stopped(), + eventEncoder3StoppedTimestamp(), + eventEncoder3StoppedFrameID(), + eventEncoder4Stopped(), + eventEncoder4StoppedTimestamp(), + eventEncoder4StoppedFrameID(), + eventEncoder5Stopped(), + eventEncoder5StoppedTimestamp(), + eventEncoder5StoppedFrameID(), + eventEncoder6Stopped(), + eventEncoder6StoppedTimestamp(), + eventEncoder6StoppedFrameID(), + eventEncoder7Stopped(), + eventEncoder7StoppedTimestamp(), + eventEncoder7StoppedFrameID(), + eventEncoder8Stopped(), + eventEncoder8StoppedTimestamp(), + eventEncoder8StoppedFrameID(), + eventEncoder9Stopped(), + eventEncoder9StoppedTimestamp(), + eventEncoder9StoppedFrameID(), + eventEncoder10Stopped(), + eventEncoder10StoppedTimestamp(), + eventEncoder10StoppedFrameID(), + eventEncoder11Stopped(), + eventEncoder11StoppedTimestamp(), + eventEncoder11StoppedFrameID(), + eventEncoder12Stopped(), + eventEncoder12StoppedTimestamp(), + eventEncoder12StoppedFrameID(), + eventEncoder13Stopped(), + eventEncoder13StoppedTimestamp(), + eventEncoder13StoppedFrameID(), + eventEncoder14Stopped(), + eventEncoder14StoppedTimestamp(), + eventEncoder14StoppedFrameID(), + eventEncoder0Restarted(), + eventEncoder0RestartedTimestamp(), + eventEncoder0RestartedFrameID(), + eventEncoder1Restarted(), + eventEncoder1RestartedTimestamp(), + eventEncoder1RestartedFrameID(), + eventEncoder2Restarted(), + eventEncoder2RestartedTimestamp(), + eventEncoder2RestartedFrameID(), + eventEncoder3Restarted(), + eventEncoder3RestartedTimestamp(), + eventEncoder3RestartedFrameID(), + eventEncoder4Restarted(), + eventEncoder4RestartedTimestamp(), + eventEncoder4RestartedFrameID(), + eventEncoder5Restarted(), + eventEncoder5RestartedTimestamp(), + eventEncoder5RestartedFrameID(), + eventEncoder6Restarted(), + eventEncoder6RestartedTimestamp(), + eventEncoder6RestartedFrameID(), + eventEncoder7Restarted(), + eventEncoder7RestartedTimestamp(), + eventEncoder7RestartedFrameID(), + eventEncoder8Restarted(), + eventEncoder8RestartedTimestamp(), + eventEncoder8RestartedFrameID(), + eventEncoder9Restarted(), + eventEncoder9RestartedTimestamp(), + eventEncoder9RestartedFrameID(), + eventEncoder10Restarted(), + eventEncoder10RestartedTimestamp(), + eventEncoder10RestartedFrameID(), + eventEncoder11Restarted(), + eventEncoder11RestartedTimestamp(), + eventEncoder11RestartedFrameID(), + eventEncoder12Restarted(), + eventEncoder12RestartedTimestamp(), + eventEncoder12RestartedFrameID(), + eventEncoder13Restarted(), + eventEncoder13RestartedTimestamp(), + eventEncoder13RestartedFrameID(), + eventEncoder14Restarted(), + eventEncoder14RestartedTimestamp(), + eventEncoder14RestartedFrameID(), + eventLine0RisingEdge(), + eventLine0RisingEdgeTimestamp(), + eventLine0RisingEdgeFrameID(), + eventLine1RisingEdge(), + eventLine1RisingEdgeTimestamp(), + eventLine1RisingEdgeFrameID(), + eventLine2RisingEdge(), + eventLine2RisingEdgeTimestamp(), + eventLine2RisingEdgeFrameID(), + eventLine3RisingEdge(), + eventLine3RisingEdgeTimestamp(), + eventLine3RisingEdgeFrameID(), + eventLine4RisingEdge(), + eventLine4RisingEdgeTimestamp(), + eventLine4RisingEdgeFrameID(), + eventLine5RisingEdge(), + eventLine5RisingEdgeTimestamp(), + eventLine5RisingEdgeFrameID(), + eventLine6RisingEdge(), + eventLine6RisingEdgeTimestamp(), + eventLine6RisingEdgeFrameID(), + eventLine7RisingEdge(), + eventLine7RisingEdgeTimestamp(), + eventLine7RisingEdgeFrameID(), + eventLine8RisingEdge(), + eventLine8RisingEdgeTimestamp(), + eventLine8RisingEdgeFrameID(), + eventLine9RisingEdge(), + eventLine9RisingEdgeTimestamp(), + eventLine9RisingEdgeFrameID(), + eventLine10RisingEdge(), + eventLine10RisingEdgeTimestamp(), + eventLine10RisingEdgeFrameID(), + eventLine11RisingEdge(), + eventLine11RisingEdgeTimestamp(), + eventLine11RisingEdgeFrameID(), + eventLine12RisingEdge(), + eventLine12RisingEdgeTimestamp(), + eventLine12RisingEdgeFrameID(), + eventLine13RisingEdge(), + eventLine13RisingEdgeTimestamp(), + eventLine13RisingEdgeFrameID(), + eventLine14RisingEdge(), + eventLine14RisingEdgeTimestamp(), + eventLine14RisingEdgeFrameID(), + eventLine0FallingEdge(), + eventLine0FallingEdgeTimestamp(), + eventLine0FallingEdgeFrameID(), + eventLine1FallingEdge(), + eventLine1FallingEdgeTimestamp(), + eventLine1FallingEdgeFrameID(), + eventLine2FallingEdge(), + eventLine2FallingEdgeTimestamp(), + eventLine2FallingEdgeFrameID(), + eventLine3FallingEdge(), + eventLine3FallingEdgeTimestamp(), + eventLine3FallingEdgeFrameID(), + eventLine4FallingEdge(), + eventLine4FallingEdgeTimestamp(), + eventLine4FallingEdgeFrameID(), + eventLine5FallingEdge(), + eventLine5FallingEdgeTimestamp(), + eventLine5FallingEdgeFrameID(), + eventLine6FallingEdge(), + eventLine6FallingEdgeTimestamp(), + eventLine6FallingEdgeFrameID(), + eventLine7FallingEdge(), + eventLine7FallingEdgeTimestamp(), + eventLine7FallingEdgeFrameID(), + eventLine8FallingEdge(), + eventLine8FallingEdgeTimestamp(), + eventLine8FallingEdgeFrameID(), + eventLine9FallingEdge(), + eventLine9FallingEdgeTimestamp(), + eventLine9FallingEdgeFrameID(), + eventLine10FallingEdge(), + eventLine10FallingEdgeTimestamp(), + eventLine10FallingEdgeFrameID(), + eventLine11FallingEdge(), + eventLine11FallingEdgeTimestamp(), + eventLine11FallingEdgeFrameID(), + eventLine12FallingEdge(), + eventLine12FallingEdgeTimestamp(), + eventLine12FallingEdgeFrameID(), + eventLine13FallingEdge(), + eventLine13FallingEdgeTimestamp(), + eventLine13FallingEdgeFrameID(), + eventLine14FallingEdge(), + eventLine14FallingEdgeTimestamp(), + eventLine14FallingEdgeFrameID(), + eventLine0AnyEdge(), + eventLine0AnyEdgeTimestamp(), + eventLine0AnyEdgeFrameID(), + eventLine1AnyEdge(), + eventLine1AnyEdgeTimestamp(), + eventLine1AnyEdgeFrameID(), + eventLine2AnyEdge(), + eventLine2AnyEdgeTimestamp(), + eventLine2AnyEdgeFrameID(), + eventLine3AnyEdge(), + eventLine3AnyEdgeTimestamp(), + eventLine3AnyEdgeFrameID(), + eventLine4AnyEdge(), + eventLine4AnyEdgeTimestamp(), + eventLine4AnyEdgeFrameID(), + eventLine5AnyEdge(), + eventLine5AnyEdgeTimestamp(), + eventLine5AnyEdgeFrameID(), + eventLine6AnyEdge(), + eventLine6AnyEdgeTimestamp(), + eventLine6AnyEdgeFrameID(), + eventLine7AnyEdge(), + eventLine7AnyEdgeTimestamp(), + eventLine7AnyEdgeFrameID(), + eventLine8AnyEdge(), + eventLine8AnyEdgeTimestamp(), + eventLine8AnyEdgeFrameID(), + eventLine9AnyEdge(), + eventLine9AnyEdgeTimestamp(), + eventLine9AnyEdgeFrameID(), + eventLine10AnyEdge(), + eventLine10AnyEdgeTimestamp(), + eventLine10AnyEdgeFrameID(), + eventLine11AnyEdge(), + eventLine11AnyEdgeTimestamp(), + eventLine11AnyEdgeFrameID(), + eventLine12AnyEdge(), + eventLine12AnyEdgeTimestamp(), + eventLine12AnyEdgeFrameID(), + eventLine13AnyEdge(), + eventLine13AnyEdgeTimestamp(), + eventLine13AnyEdgeFrameID(), + eventLine14AnyEdge(), + eventLine14AnyEdgeTimestamp(), + eventLine14AnyEdgeFrameID(), + eventLinkTrigger0(), + eventLinkTrigger0Timestamp(), + eventLinkTrigger0FrameID(), + eventLinkTrigger1(), + eventLinkTrigger1Timestamp(), + eventLinkTrigger1FrameID(), + eventLinkTrigger2(), + eventLinkTrigger2Timestamp(), + eventLinkTrigger2FrameID(), + eventLinkTrigger3(), + eventLinkTrigger3Timestamp(), + eventLinkTrigger3FrameID(), + eventLinkTrigger4(), + eventLinkTrigger4Timestamp(), + eventLinkTrigger4FrameID(), + eventLinkTrigger5(), + eventLinkTrigger5Timestamp(), + eventLinkTrigger5FrameID(), + eventLinkTrigger6(), + eventLinkTrigger6Timestamp(), + eventLinkTrigger6FrameID(), + eventLinkTrigger7(), + eventLinkTrigger7Timestamp(), + eventLinkTrigger7FrameID(), + eventLinkTrigger8(), + eventLinkTrigger8Timestamp(), + eventLinkTrigger8FrameID(), + eventLinkTrigger9(), + eventLinkTrigger9Timestamp(), + eventLinkTrigger9FrameID(), + eventLinkTrigger10(), + eventLinkTrigger10Timestamp(), + eventLinkTrigger10FrameID(), + eventLinkTrigger11(), + eventLinkTrigger11Timestamp(), + eventLinkTrigger11FrameID(), + eventLinkTrigger12(), + eventLinkTrigger12Timestamp(), + eventLinkTrigger12FrameID(), + eventLinkTrigger13(), + eventLinkTrigger13Timestamp(), + eventLinkTrigger13FrameID(), + eventLinkTrigger14(), + eventLinkTrigger14Timestamp(), + eventLinkTrigger14FrameID(), + eventError(), + eventErrorTimestamp(), + eventErrorFrameID(), + eventErrorCode() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( eventSelector, "EventSelector" ); + locator.bindComponent( eventNotification, "EventNotification" ); + locator.bindComponent( eventAcquisitionTrigger, "EventAcquisitionTrigger" ); + locator.bindComponent( eventAcquisitionTriggerTimestamp, "EventAcquisitionTriggerTimestamp" ); + locator.bindComponent( eventAcquisitionTriggerFrameID, "EventAcquisitionTriggerFrameID" ); + locator.bindComponent( eventAcquisitionTriggerMissed, "EventAcquisitionTriggerMissed" ); + locator.bindComponent( eventAcquisitionTriggerMissedTimestamp, "EventAcquisitionTriggerMissedTimestamp" ); + locator.bindComponent( eventAcquisitionTriggerMissedFrameID, "EventAcquisitionTriggerMissedFrameID" ); + locator.bindComponent( eventAcquisitionStart, "EventAcquisitionStart" ); + locator.bindComponent( eventAcquisitionStartTimestamp, "EventAcquisitionStartTimestamp" ); + locator.bindComponent( eventAcquisitionStartFrameID, "EventAcquisitionStartFrameID" ); + locator.bindComponent( eventAcquisitionEnd, "EventAcquisitionEnd" ); + locator.bindComponent( eventAcquisitionEndTimestamp, "EventAcquisitionEndTimestamp" ); + locator.bindComponent( eventAcquisitionEndFrameID, "EventAcquisitionEndFrameID" ); + locator.bindComponent( eventAcquisitionTransferStart, "EventAcquisitionTransferStart" ); + locator.bindComponent( eventAcquisitionTransferStartTimestamp, "EventAcquisitionTransferStartTimestamp" ); + locator.bindComponent( eventAcquisitionTransferStartFrameID, "EventAcquisitionTransferStartFrameID" ); + locator.bindComponent( eventAcquisitionTransferEnd, "EventAcquisitionTransferEnd" ); + locator.bindComponent( eventAcquisitionTransferEndTimestamp, "EventAcquisitionTransferEndTimestamp" ); + locator.bindComponent( eventAcquisitionTransferEndFrameID, "EventAcquisitionTransferEndFrameID" ); + locator.bindComponent( eventAcquisitionError, "EventAcquisitionError" ); + locator.bindComponent( eventAcquisitionErrorTimestamp, "EventAcquisitionErrorTimestamp" ); + locator.bindComponent( eventAcquisitionErrorFrameID, "EventAcquisitionErrorFrameID" ); + locator.bindComponent( eventFrameBurstStart, "EventFrameBurstStart" ); + locator.bindComponent( eventFrameBurstStartTimestamp, "EventFrameBurstStartTimestamp" ); + locator.bindComponent( eventFrameBurstStartFrameID, "EventFrameBurstStartFrameID" ); + locator.bindComponent( eventFrameBurstEnd, "EventFrameBurstEnd" ); + locator.bindComponent( eventFrameBurstEndTimestamp, "EventFrameBurstEndTimestamp" ); + locator.bindComponent( eventFrameBurstEndFrameID, "EventFrameBurstEndFrameID" ); + locator.bindComponent( eventFrameTrigger, "EventFrameTrigger" ); + locator.bindComponent( eventFrameTriggerTimestamp, "EventFrameTriggerTimestamp" ); + locator.bindComponent( eventFrameTriggerFrameID, "EventFrameTriggerFrameID" ); + locator.bindComponent( eventFrameTriggerMissed, "EventFrameTriggerMissed" ); + locator.bindComponent( eventFrameTriggerMissedTimestamp, "EventFrameTriggerMissedTimestamp" ); + locator.bindComponent( eventFrameTriggerMissedFrameID, "EventFrameTriggerMissedFrameID" ); + locator.bindComponent( eventFrameStart, "EventFrameStart" ); + locator.bindComponent( eventFrameStartTimestamp, "EventFrameStartTimestamp" ); + locator.bindComponent( eventFrameStartFrameID, "EventFrameStartFrameID" ); + locator.bindComponent( eventFrameEnd, "EventFrameEnd" ); + locator.bindComponent( eventFrameEndTimestamp, "EventFrameEndTimestamp" ); + locator.bindComponent( eventFrameEndFrameID, "EventFrameEndFrameID" ); + locator.bindComponent( eventFrameTransferStart, "EventFrameTransferStart" ); + locator.bindComponent( eventFrameTransferStartTimestamp, "EventFrameTransferStartTimestamp" ); + locator.bindComponent( eventFrameTransferStartFrameID, "EventFrameTransferStartFrameID" ); + locator.bindComponent( eventFrameTransferEnd, "EventFrameTransferEnd" ); + locator.bindComponent( eventFrameTransferEndTimestamp, "EventFrameTransferEndTimestamp" ); + locator.bindComponent( eventFrameTransferEndFrameID, "EventFrameTransferEndFrameID" ); + locator.bindComponent( eventLineTrigger, "EventLineTrigger" ); + locator.bindComponent( eventLineTriggerTimestamp, "EventLineTriggerTimestamp" ); + locator.bindComponent( eventLineTriggerFrameID, "EventLineTriggerFrameID" ); + locator.bindComponent( eventLineTriggerMissed, "EventLineTriggerMissed" ); + locator.bindComponent( eventLineTriggerMissedTimestamp, "EventLineTriggerMissedTimestamp" ); + locator.bindComponent( eventLineTriggerMissedFrameID, "EventLineTriggerMissedFrameID" ); + locator.bindComponent( eventLineStart, "EventLineStart" ); + locator.bindComponent( eventLineStartTimestamp, "EventLineStartTimestamp" ); + locator.bindComponent( eventLineStartFrameID, "EventLineStartFrameID" ); + locator.bindComponent( eventLineEnd, "EventLineEnd" ); + locator.bindComponent( eventLineEndTimestamp, "EventLineEndTimestamp" ); + locator.bindComponent( eventLineEndFrameID, "EventLineEndFrameID" ); + locator.bindComponent( eventExposureStart, "EventExposureStart" ); + locator.bindComponent( eventExposureStartTimestamp, "EventExposureStartTimestamp" ); + locator.bindComponent( eventExposureStartFrameID, "EventExposureStartFrameID" ); + locator.bindComponent( eventExposureEnd, "EventExposureEnd" ); + locator.bindComponent( eventExposureEndTimestamp, "EventExposureEndTimestamp" ); + locator.bindComponent( eventExposureEndFrameID, "EventExposureEndFrameID" ); + locator.bindComponent( eventActionLate, "EventActionLate" ); + locator.bindComponent( eventActionLateTimestamp, "EventActionLateTimestamp" ); + locator.bindComponent( eventActionLateFrameID, "EventActionLateFrameID" ); + locator.bindComponent( eventPrimaryApplicationSwitch, "EventPrimaryApplicationSwitch" ); + locator.bindComponent( eventPrimaryApplicationSwitchTimestamp, "EventPrimaryApplicationSwitchTimestamp" ); + locator.bindComponent( eventPrimaryApplicationSwitchFrameID, "EventPrimaryApplicationSwitchFrameID" ); + locator.bindComponent( eventTest, "EventTest" ); + locator.bindComponent( eventTestTimestamp, "EventTestTimestamp" ); + locator.bindComponent( eventCounter0Start, "EventCounter0Start" ); + locator.bindComponent( eventCounter0StartTimestamp, "EventCounter0StartTimestamp" ); + locator.bindComponent( eventCounter0StartFrameID, "EventCounter0StartFrameID" ); + locator.bindComponent( eventCounter1Start, "EventCounter1Start" ); + locator.bindComponent( eventCounter1StartTimestamp, "EventCounter1StartTimestamp" ); + locator.bindComponent( eventCounter1StartFrameID, "EventCounter1StartFrameID" ); + locator.bindComponent( eventCounter2Start, "EventCounter2Start" ); + locator.bindComponent( eventCounter2StartTimestamp, "EventCounter2StartTimestamp" ); + locator.bindComponent( eventCounter2StartFrameID, "EventCounter2StartFrameID" ); + locator.bindComponent( eventCounter3Start, "EventCounter3Start" ); + locator.bindComponent( eventCounter3StartTimestamp, "EventCounter3StartTimestamp" ); + locator.bindComponent( eventCounter3StartFrameID, "EventCounter3StartFrameID" ); + locator.bindComponent( eventCounter4Start, "EventCounter4Start" ); + locator.bindComponent( eventCounter4StartTimestamp, "EventCounter4StartTimestamp" ); + locator.bindComponent( eventCounter4StartFrameID, "EventCounter4StartFrameID" ); + locator.bindComponent( eventCounter5Start, "EventCounter5Start" ); + locator.bindComponent( eventCounter5StartTimestamp, "EventCounter5StartTimestamp" ); + locator.bindComponent( eventCounter5StartFrameID, "EventCounter5StartFrameID" ); + locator.bindComponent( eventCounter6Start, "EventCounter6Start" ); + locator.bindComponent( eventCounter6StartTimestamp, "EventCounter6StartTimestamp" ); + locator.bindComponent( eventCounter6StartFrameID, "EventCounter6StartFrameID" ); + locator.bindComponent( eventCounter7Start, "EventCounter7Start" ); + locator.bindComponent( eventCounter7StartTimestamp, "EventCounter7StartTimestamp" ); + locator.bindComponent( eventCounter7StartFrameID, "EventCounter7StartFrameID" ); + locator.bindComponent( eventCounter8Start, "EventCounter8Start" ); + locator.bindComponent( eventCounter8StartTimestamp, "EventCounter8StartTimestamp" ); + locator.bindComponent( eventCounter8StartFrameID, "EventCounter8StartFrameID" ); + locator.bindComponent( eventCounter9Start, "EventCounter9Start" ); + locator.bindComponent( eventCounter9StartTimestamp, "EventCounter9StartTimestamp" ); + locator.bindComponent( eventCounter9StartFrameID, "EventCounter9StartFrameID" ); + locator.bindComponent( eventCounter10Start, "EventCounter10Start" ); + locator.bindComponent( eventCounter10StartTimestamp, "EventCounter10StartTimestamp" ); + locator.bindComponent( eventCounter10StartFrameID, "EventCounter10StartFrameID" ); + locator.bindComponent( eventCounter11Start, "EventCounter11Start" ); + locator.bindComponent( eventCounter11StartTimestamp, "EventCounter11StartTimestamp" ); + locator.bindComponent( eventCounter11StartFrameID, "EventCounter11StartFrameID" ); + locator.bindComponent( eventCounter12Start, "EventCounter12Start" ); + locator.bindComponent( eventCounter12StartTimestamp, "EventCounter12StartTimestamp" ); + locator.bindComponent( eventCounter12StartFrameID, "EventCounter12StartFrameID" ); + locator.bindComponent( eventCounter13Start, "EventCounter13Start" ); + locator.bindComponent( eventCounter13StartTimestamp, "EventCounter13StartTimestamp" ); + locator.bindComponent( eventCounter13StartFrameID, "EventCounter13StartFrameID" ); + locator.bindComponent( eventCounter14Start, "EventCounter14Start" ); + locator.bindComponent( eventCounter14StartTimestamp, "EventCounter14StartTimestamp" ); + locator.bindComponent( eventCounter14StartFrameID, "EventCounter14StartFrameID" ); + locator.bindComponent( eventCounter0End, "EventCounter0End" ); + locator.bindComponent( eventCounter0EndTimestamp, "EventCounter0EndTimestamp" ); + locator.bindComponent( eventCounter0EndFrameID, "EventCounter0EndFrameID" ); + locator.bindComponent( eventCounter1End, "EventCounter1End" ); + locator.bindComponent( eventCounter1EndTimestamp, "EventCounter1EndTimestamp" ); + locator.bindComponent( eventCounter1EndFrameID, "EventCounter1EndFrameID" ); + locator.bindComponent( eventCounter2End, "EventCounter2End" ); + locator.bindComponent( eventCounter2EndTimestamp, "EventCounter2EndTimestamp" ); + locator.bindComponent( eventCounter2EndFrameID, "EventCounter2EndFrameID" ); + locator.bindComponent( eventCounter3End, "EventCounter3End" ); + locator.bindComponent( eventCounter3EndTimestamp, "EventCounter3EndTimestamp" ); + locator.bindComponent( eventCounter3EndFrameID, "EventCounter3EndFrameID" ); + locator.bindComponent( eventCounter4End, "EventCounter4End" ); + locator.bindComponent( eventCounter4EndTimestamp, "EventCounter4EndTimestamp" ); + locator.bindComponent( eventCounter4EndFrameID, "EventCounter4EndFrameID" ); + locator.bindComponent( eventCounter5End, "EventCounter5End" ); + locator.bindComponent( eventCounter5EndTimestamp, "EventCounter5EndTimestamp" ); + locator.bindComponent( eventCounter5EndFrameID, "EventCounter5EndFrameID" ); + locator.bindComponent( eventCounter6End, "EventCounter6End" ); + locator.bindComponent( eventCounter6EndTimestamp, "EventCounter6EndTimestamp" ); + locator.bindComponent( eventCounter6EndFrameID, "EventCounter6EndFrameID" ); + locator.bindComponent( eventCounter7End, "EventCounter7End" ); + locator.bindComponent( eventCounter7EndTimestamp, "EventCounter7EndTimestamp" ); + locator.bindComponent( eventCounter7EndFrameID, "EventCounter7EndFrameID" ); + locator.bindComponent( eventCounter8End, "EventCounter8End" ); + locator.bindComponent( eventCounter8EndTimestamp, "EventCounter8EndTimestamp" ); + locator.bindComponent( eventCounter8EndFrameID, "EventCounter8EndFrameID" ); + locator.bindComponent( eventCounter9End, "EventCounter9End" ); + locator.bindComponent( eventCounter9EndTimestamp, "EventCounter9EndTimestamp" ); + locator.bindComponent( eventCounter9EndFrameID, "EventCounter9EndFrameID" ); + locator.bindComponent( eventCounter10End, "EventCounter10End" ); + locator.bindComponent( eventCounter10EndTimestamp, "EventCounter10EndTimestamp" ); + locator.bindComponent( eventCounter10EndFrameID, "EventCounter10EndFrameID" ); + locator.bindComponent( eventCounter11End, "EventCounter11End" ); + locator.bindComponent( eventCounter11EndTimestamp, "EventCounter11EndTimestamp" ); + locator.bindComponent( eventCounter11EndFrameID, "EventCounter11EndFrameID" ); + locator.bindComponent( eventCounter12End, "EventCounter12End" ); + locator.bindComponent( eventCounter12EndTimestamp, "EventCounter12EndTimestamp" ); + locator.bindComponent( eventCounter12EndFrameID, "EventCounter12EndFrameID" ); + locator.bindComponent( eventCounter13End, "EventCounter13End" ); + locator.bindComponent( eventCounter13EndTimestamp, "EventCounter13EndTimestamp" ); + locator.bindComponent( eventCounter13EndFrameID, "EventCounter13EndFrameID" ); + locator.bindComponent( eventCounter14End, "EventCounter14End" ); + locator.bindComponent( eventCounter14EndTimestamp, "EventCounter14EndTimestamp" ); + locator.bindComponent( eventCounter14EndFrameID, "EventCounter14EndFrameID" ); + locator.bindComponent( eventTimer0Start, "EventTimer0Start" ); + locator.bindComponent( eventTimer0StartTimestamp, "EventTimer0StartTimestamp" ); + locator.bindComponent( eventTimer0StartFrameID, "EventTimer0StartFrameID" ); + locator.bindComponent( eventTimer1Start, "EventTimer1Start" ); + locator.bindComponent( eventTimer1StartTimestamp, "EventTimer1StartTimestamp" ); + locator.bindComponent( eventTimer1StartFrameID, "EventTimer1StartFrameID" ); + locator.bindComponent( eventTimer2Start, "EventTimer2Start" ); + locator.bindComponent( eventTimer2StartTimestamp, "EventTimer2StartTimestamp" ); + locator.bindComponent( eventTimer2StartFrameID, "EventTimer2StartFrameID" ); + locator.bindComponent( eventTimer3Start, "EventTimer3Start" ); + locator.bindComponent( eventTimer3StartTimestamp, "EventTimer3StartTimestamp" ); + locator.bindComponent( eventTimer3StartFrameID, "EventTimer3StartFrameID" ); + locator.bindComponent( eventTimer4Start, "EventTimer4Start" ); + locator.bindComponent( eventTimer4StartTimestamp, "EventTimer4StartTimestamp" ); + locator.bindComponent( eventTimer4StartFrameID, "EventTimer4StartFrameID" ); + locator.bindComponent( eventTimer5Start, "EventTimer5Start" ); + locator.bindComponent( eventTimer5StartTimestamp, "EventTimer5StartTimestamp" ); + locator.bindComponent( eventTimer5StartFrameID, "EventTimer5StartFrameID" ); + locator.bindComponent( eventTimer6Start, "EventTimer6Start" ); + locator.bindComponent( eventTimer6StartTimestamp, "EventTimer6StartTimestamp" ); + locator.bindComponent( eventTimer6StartFrameID, "EventTimer6StartFrameID" ); + locator.bindComponent( eventTimer7Start, "EventTimer7Start" ); + locator.bindComponent( eventTimer7StartTimestamp, "EventTimer7StartTimestamp" ); + locator.bindComponent( eventTimer7StartFrameID, "EventTimer7StartFrameID" ); + locator.bindComponent( eventTimer8Start, "EventTimer8Start" ); + locator.bindComponent( eventTimer8StartTimestamp, "EventTimer8StartTimestamp" ); + locator.bindComponent( eventTimer8StartFrameID, "EventTimer8StartFrameID" ); + locator.bindComponent( eventTimer9Start, "EventTimer9Start" ); + locator.bindComponent( eventTimer9StartTimestamp, "EventTimer9StartTimestamp" ); + locator.bindComponent( eventTimer9StartFrameID, "EventTimer9StartFrameID" ); + locator.bindComponent( eventTimer10Start, "EventTimer10Start" ); + locator.bindComponent( eventTimer10StartTimestamp, "EventTimer10StartTimestamp" ); + locator.bindComponent( eventTimer10StartFrameID, "EventTimer10StartFrameID" ); + locator.bindComponent( eventTimer11Start, "EventTimer11Start" ); + locator.bindComponent( eventTimer11StartTimestamp, "EventTimer11StartTimestamp" ); + locator.bindComponent( eventTimer11StartFrameID, "EventTimer11StartFrameID" ); + locator.bindComponent( eventTimer12Start, "EventTimer12Start" ); + locator.bindComponent( eventTimer12StartTimestamp, "EventTimer12StartTimestamp" ); + locator.bindComponent( eventTimer12StartFrameID, "EventTimer12StartFrameID" ); + locator.bindComponent( eventTimer13Start, "EventTimer13Start" ); + locator.bindComponent( eventTimer13StartTimestamp, "EventTimer13StartTimestamp" ); + locator.bindComponent( eventTimer13StartFrameID, "EventTimer13StartFrameID" ); + locator.bindComponent( eventTimer14Start, "EventTimer14Start" ); + locator.bindComponent( eventTimer14StartTimestamp, "EventTimer14StartTimestamp" ); + locator.bindComponent( eventTimer14StartFrameID, "EventTimer14StartFrameID" ); + locator.bindComponent( eventTimer0End, "EventTimer0End" ); + locator.bindComponent( eventTimer0EndTimestamp, "EventTimer0EndTimestamp" ); + locator.bindComponent( eventTimer0EndFrameID, "EventTimer0EndFrameID" ); + locator.bindComponent( eventTimer1End, "EventTimer1End" ); + locator.bindComponent( eventTimer1EndTimestamp, "EventTimer1EndTimestamp" ); + locator.bindComponent( eventTimer1EndFrameID, "EventTimer1EndFrameID" ); + locator.bindComponent( eventTimer2End, "EventTimer2End" ); + locator.bindComponent( eventTimer2EndTimestamp, "EventTimer2EndTimestamp" ); + locator.bindComponent( eventTimer2EndFrameID, "EventTimer2EndFrameID" ); + locator.bindComponent( eventTimer3End, "EventTimer3End" ); + locator.bindComponent( eventTimer3EndTimestamp, "EventTimer3EndTimestamp" ); + locator.bindComponent( eventTimer3EndFrameID, "EventTimer3EndFrameID" ); + locator.bindComponent( eventTimer4End, "EventTimer4End" ); + locator.bindComponent( eventTimer4EndTimestamp, "EventTimer4EndTimestamp" ); + locator.bindComponent( eventTimer4EndFrameID, "EventTimer4EndFrameID" ); + locator.bindComponent( eventTimer5End, "EventTimer5End" ); + locator.bindComponent( eventTimer5EndTimestamp, "EventTimer5EndTimestamp" ); + locator.bindComponent( eventTimer5EndFrameID, "EventTimer5EndFrameID" ); + locator.bindComponent( eventTimer6End, "EventTimer6End" ); + locator.bindComponent( eventTimer6EndTimestamp, "EventTimer6EndTimestamp" ); + locator.bindComponent( eventTimer6EndFrameID, "EventTimer6EndFrameID" ); + locator.bindComponent( eventTimer7End, "EventTimer7End" ); + locator.bindComponent( eventTimer7EndTimestamp, "EventTimer7EndTimestamp" ); + locator.bindComponent( eventTimer7EndFrameID, "EventTimer7EndFrameID" ); + locator.bindComponent( eventTimer8End, "EventTimer8End" ); + locator.bindComponent( eventTimer8EndTimestamp, "EventTimer8EndTimestamp" ); + locator.bindComponent( eventTimer8EndFrameID, "EventTimer8EndFrameID" ); + locator.bindComponent( eventTimer9End, "EventTimer9End" ); + locator.bindComponent( eventTimer9EndTimestamp, "EventTimer9EndTimestamp" ); + locator.bindComponent( eventTimer9EndFrameID, "EventTimer9EndFrameID" ); + locator.bindComponent( eventTimer10End, "EventTimer10End" ); + locator.bindComponent( eventTimer10EndTimestamp, "EventTimer10EndTimestamp" ); + locator.bindComponent( eventTimer10EndFrameID, "EventTimer10EndFrameID" ); + locator.bindComponent( eventTimer11End, "EventTimer11End" ); + locator.bindComponent( eventTimer11EndTimestamp, "EventTimer11EndTimestamp" ); + locator.bindComponent( eventTimer11EndFrameID, "EventTimer11EndFrameID" ); + locator.bindComponent( eventTimer12End, "EventTimer12End" ); + locator.bindComponent( eventTimer12EndTimestamp, "EventTimer12EndTimestamp" ); + locator.bindComponent( eventTimer12EndFrameID, "EventTimer12EndFrameID" ); + locator.bindComponent( eventTimer13End, "EventTimer13End" ); + locator.bindComponent( eventTimer13EndTimestamp, "EventTimer13EndTimestamp" ); + locator.bindComponent( eventTimer13EndFrameID, "EventTimer13EndFrameID" ); + locator.bindComponent( eventTimer14End, "EventTimer14End" ); + locator.bindComponent( eventTimer14EndTimestamp, "EventTimer14EndTimestamp" ); + locator.bindComponent( eventTimer14EndFrameID, "EventTimer14EndFrameID" ); + locator.bindComponent( eventEncoder0Stopped, "EventEncoder0Stopped" ); + locator.bindComponent( eventEncoder0StoppedTimestamp, "EventEncoder0StoppedTimestamp" ); + locator.bindComponent( eventEncoder0StoppedFrameID, "EventEncoder0StoppedFrameID" ); + locator.bindComponent( eventEncoder1Stopped, "EventEncoder1Stopped" ); + locator.bindComponent( eventEncoder1StoppedTimestamp, "EventEncoder1StoppedTimestamp" ); + locator.bindComponent( eventEncoder1StoppedFrameID, "EventEncoder1StoppedFrameID" ); + locator.bindComponent( eventEncoder2Stopped, "EventEncoder2Stopped" ); + locator.bindComponent( eventEncoder2StoppedTimestamp, "EventEncoder2StoppedTimestamp" ); + locator.bindComponent( eventEncoder2StoppedFrameID, "EventEncoder2StoppedFrameID" ); + locator.bindComponent( eventEncoder3Stopped, "EventEncoder3Stopped" ); + locator.bindComponent( eventEncoder3StoppedTimestamp, "EventEncoder3StoppedTimestamp" ); + locator.bindComponent( eventEncoder3StoppedFrameID, "EventEncoder3StoppedFrameID" ); + locator.bindComponent( eventEncoder4Stopped, "EventEncoder4Stopped" ); + locator.bindComponent( eventEncoder4StoppedTimestamp, "EventEncoder4StoppedTimestamp" ); + locator.bindComponent( eventEncoder4StoppedFrameID, "EventEncoder4StoppedFrameID" ); + locator.bindComponent( eventEncoder5Stopped, "EventEncoder5Stopped" ); + locator.bindComponent( eventEncoder5StoppedTimestamp, "EventEncoder5StoppedTimestamp" ); + locator.bindComponent( eventEncoder5StoppedFrameID, "EventEncoder5StoppedFrameID" ); + locator.bindComponent( eventEncoder6Stopped, "EventEncoder6Stopped" ); + locator.bindComponent( eventEncoder6StoppedTimestamp, "EventEncoder6StoppedTimestamp" ); + locator.bindComponent( eventEncoder6StoppedFrameID, "EventEncoder6StoppedFrameID" ); + locator.bindComponent( eventEncoder7Stopped, "EventEncoder7Stopped" ); + locator.bindComponent( eventEncoder7StoppedTimestamp, "EventEncoder7StoppedTimestamp" ); + locator.bindComponent( eventEncoder7StoppedFrameID, "EventEncoder7StoppedFrameID" ); + locator.bindComponent( eventEncoder8Stopped, "EventEncoder8Stopped" ); + locator.bindComponent( eventEncoder8StoppedTimestamp, "EventEncoder8StoppedTimestamp" ); + locator.bindComponent( eventEncoder8StoppedFrameID, "EventEncoder8StoppedFrameID" ); + locator.bindComponent( eventEncoder9Stopped, "EventEncoder9Stopped" ); + locator.bindComponent( eventEncoder9StoppedTimestamp, "EventEncoder9StoppedTimestamp" ); + locator.bindComponent( eventEncoder9StoppedFrameID, "EventEncoder9StoppedFrameID" ); + locator.bindComponent( eventEncoder10Stopped, "EventEncoder10Stopped" ); + locator.bindComponent( eventEncoder10StoppedTimestamp, "EventEncoder10StoppedTimestamp" ); + locator.bindComponent( eventEncoder10StoppedFrameID, "EventEncoder10StoppedFrameID" ); + locator.bindComponent( eventEncoder11Stopped, "EventEncoder11Stopped" ); + locator.bindComponent( eventEncoder11StoppedTimestamp, "EventEncoder11StoppedTimestamp" ); + locator.bindComponent( eventEncoder11StoppedFrameID, "EventEncoder11StoppedFrameID" ); + locator.bindComponent( eventEncoder12Stopped, "EventEncoder12Stopped" ); + locator.bindComponent( eventEncoder12StoppedTimestamp, "EventEncoder12StoppedTimestamp" ); + locator.bindComponent( eventEncoder12StoppedFrameID, "EventEncoder12StoppedFrameID" ); + locator.bindComponent( eventEncoder13Stopped, "EventEncoder13Stopped" ); + locator.bindComponent( eventEncoder13StoppedTimestamp, "EventEncoder13StoppedTimestamp" ); + locator.bindComponent( eventEncoder13StoppedFrameID, "EventEncoder13StoppedFrameID" ); + locator.bindComponent( eventEncoder14Stopped, "EventEncoder14Stopped" ); + locator.bindComponent( eventEncoder14StoppedTimestamp, "EventEncoder14StoppedTimestamp" ); + locator.bindComponent( eventEncoder14StoppedFrameID, "EventEncoder14StoppedFrameID" ); + locator.bindComponent( eventEncoder0Restarted, "EventEncoder0Restarted" ); + locator.bindComponent( eventEncoder0RestartedTimestamp, "EventEncoder0RestartedTimestamp" ); + locator.bindComponent( eventEncoder0RestartedFrameID, "EventEncoder0RestartedFrameID" ); + locator.bindComponent( eventEncoder1Restarted, "EventEncoder1Restarted" ); + locator.bindComponent( eventEncoder1RestartedTimestamp, "EventEncoder1RestartedTimestamp" ); + locator.bindComponent( eventEncoder1RestartedFrameID, "EventEncoder1RestartedFrameID" ); + locator.bindComponent( eventEncoder2Restarted, "EventEncoder2Restarted" ); + locator.bindComponent( eventEncoder2RestartedTimestamp, "EventEncoder2RestartedTimestamp" ); + locator.bindComponent( eventEncoder2RestartedFrameID, "EventEncoder2RestartedFrameID" ); + locator.bindComponent( eventEncoder3Restarted, "EventEncoder3Restarted" ); + locator.bindComponent( eventEncoder3RestartedTimestamp, "EventEncoder3RestartedTimestamp" ); + locator.bindComponent( eventEncoder3RestartedFrameID, "EventEncoder3RestartedFrameID" ); + locator.bindComponent( eventEncoder4Restarted, "EventEncoder4Restarted" ); + locator.bindComponent( eventEncoder4RestartedTimestamp, "EventEncoder4RestartedTimestamp" ); + locator.bindComponent( eventEncoder4RestartedFrameID, "EventEncoder4RestartedFrameID" ); + locator.bindComponent( eventEncoder5Restarted, "EventEncoder5Restarted" ); + locator.bindComponent( eventEncoder5RestartedTimestamp, "EventEncoder5RestartedTimestamp" ); + locator.bindComponent( eventEncoder5RestartedFrameID, "EventEncoder5RestartedFrameID" ); + locator.bindComponent( eventEncoder6Restarted, "EventEncoder6Restarted" ); + locator.bindComponent( eventEncoder6RestartedTimestamp, "EventEncoder6RestartedTimestamp" ); + locator.bindComponent( eventEncoder6RestartedFrameID, "EventEncoder6RestartedFrameID" ); + locator.bindComponent( eventEncoder7Restarted, "EventEncoder7Restarted" ); + locator.bindComponent( eventEncoder7RestartedTimestamp, "EventEncoder7RestartedTimestamp" ); + locator.bindComponent( eventEncoder7RestartedFrameID, "EventEncoder7RestartedFrameID" ); + locator.bindComponent( eventEncoder8Restarted, "EventEncoder8Restarted" ); + locator.bindComponent( eventEncoder8RestartedTimestamp, "EventEncoder8RestartedTimestamp" ); + locator.bindComponent( eventEncoder8RestartedFrameID, "EventEncoder8RestartedFrameID" ); + locator.bindComponent( eventEncoder9Restarted, "EventEncoder9Restarted" ); + locator.bindComponent( eventEncoder9RestartedTimestamp, "EventEncoder9RestartedTimestamp" ); + locator.bindComponent( eventEncoder9RestartedFrameID, "EventEncoder9RestartedFrameID" ); + locator.bindComponent( eventEncoder10Restarted, "EventEncoder10Restarted" ); + locator.bindComponent( eventEncoder10RestartedTimestamp, "EventEncoder10RestartedTimestamp" ); + locator.bindComponent( eventEncoder10RestartedFrameID, "EventEncoder10RestartedFrameID" ); + locator.bindComponent( eventEncoder11Restarted, "EventEncoder11Restarted" ); + locator.bindComponent( eventEncoder11RestartedTimestamp, "EventEncoder11RestartedTimestamp" ); + locator.bindComponent( eventEncoder11RestartedFrameID, "EventEncoder11RestartedFrameID" ); + locator.bindComponent( eventEncoder12Restarted, "EventEncoder12Restarted" ); + locator.bindComponent( eventEncoder12RestartedTimestamp, "EventEncoder12RestartedTimestamp" ); + locator.bindComponent( eventEncoder12RestartedFrameID, "EventEncoder12RestartedFrameID" ); + locator.bindComponent( eventEncoder13Restarted, "EventEncoder13Restarted" ); + locator.bindComponent( eventEncoder13RestartedTimestamp, "EventEncoder13RestartedTimestamp" ); + locator.bindComponent( eventEncoder13RestartedFrameID, "EventEncoder13RestartedFrameID" ); + locator.bindComponent( eventEncoder14Restarted, "EventEncoder14Restarted" ); + locator.bindComponent( eventEncoder14RestartedTimestamp, "EventEncoder14RestartedTimestamp" ); + locator.bindComponent( eventEncoder14RestartedFrameID, "EventEncoder14RestartedFrameID" ); + locator.bindComponent( eventLine0RisingEdge, "EventLine0RisingEdge" ); + locator.bindComponent( eventLine0RisingEdgeTimestamp, "EventLine0RisingEdgeTimestamp" ); + locator.bindComponent( eventLine0RisingEdgeFrameID, "EventLine0RisingEdgeFrameID" ); + locator.bindComponent( eventLine1RisingEdge, "EventLine1RisingEdge" ); + locator.bindComponent( eventLine1RisingEdgeTimestamp, "EventLine1RisingEdgeTimestamp" ); + locator.bindComponent( eventLine1RisingEdgeFrameID, "EventLine1RisingEdgeFrameID" ); + locator.bindComponent( eventLine2RisingEdge, "EventLine2RisingEdge" ); + locator.bindComponent( eventLine2RisingEdgeTimestamp, "EventLine2RisingEdgeTimestamp" ); + locator.bindComponent( eventLine2RisingEdgeFrameID, "EventLine2RisingEdgeFrameID" ); + locator.bindComponent( eventLine3RisingEdge, "EventLine3RisingEdge" ); + locator.bindComponent( eventLine3RisingEdgeTimestamp, "EventLine3RisingEdgeTimestamp" ); + locator.bindComponent( eventLine3RisingEdgeFrameID, "EventLine3RisingEdgeFrameID" ); + locator.bindComponent( eventLine4RisingEdge, "EventLine4RisingEdge" ); + locator.bindComponent( eventLine4RisingEdgeTimestamp, "EventLine4RisingEdgeTimestamp" ); + locator.bindComponent( eventLine4RisingEdgeFrameID, "EventLine4RisingEdgeFrameID" ); + locator.bindComponent( eventLine5RisingEdge, "EventLine5RisingEdge" ); + locator.bindComponent( eventLine5RisingEdgeTimestamp, "EventLine5RisingEdgeTimestamp" ); + locator.bindComponent( eventLine5RisingEdgeFrameID, "EventLine5RisingEdgeFrameID" ); + locator.bindComponent( eventLine6RisingEdge, "EventLine6RisingEdge" ); + locator.bindComponent( eventLine6RisingEdgeTimestamp, "EventLine6RisingEdgeTimestamp" ); + locator.bindComponent( eventLine6RisingEdgeFrameID, "EventLine6RisingEdgeFrameID" ); + locator.bindComponent( eventLine7RisingEdge, "EventLine7RisingEdge" ); + locator.bindComponent( eventLine7RisingEdgeTimestamp, "EventLine7RisingEdgeTimestamp" ); + locator.bindComponent( eventLine7RisingEdgeFrameID, "EventLine7RisingEdgeFrameID" ); + locator.bindComponent( eventLine8RisingEdge, "EventLine8RisingEdge" ); + locator.bindComponent( eventLine8RisingEdgeTimestamp, "EventLine8RisingEdgeTimestamp" ); + locator.bindComponent( eventLine8RisingEdgeFrameID, "EventLine8RisingEdgeFrameID" ); + locator.bindComponent( eventLine9RisingEdge, "EventLine9RisingEdge" ); + locator.bindComponent( eventLine9RisingEdgeTimestamp, "EventLine9RisingEdgeTimestamp" ); + locator.bindComponent( eventLine9RisingEdgeFrameID, "EventLine9RisingEdgeFrameID" ); + locator.bindComponent( eventLine10RisingEdge, "EventLine10RisingEdge" ); + locator.bindComponent( eventLine10RisingEdgeTimestamp, "EventLine10RisingEdgeTimestamp" ); + locator.bindComponent( eventLine10RisingEdgeFrameID, "EventLine10RisingEdgeFrameID" ); + locator.bindComponent( eventLine11RisingEdge, "EventLine11RisingEdge" ); + locator.bindComponent( eventLine11RisingEdgeTimestamp, "EventLine11RisingEdgeTimestamp" ); + locator.bindComponent( eventLine11RisingEdgeFrameID, "EventLine11RisingEdgeFrameID" ); + locator.bindComponent( eventLine12RisingEdge, "EventLine12RisingEdge" ); + locator.bindComponent( eventLine12RisingEdgeTimestamp, "EventLine12RisingEdgeTimestamp" ); + locator.bindComponent( eventLine12RisingEdgeFrameID, "EventLine12RisingEdgeFrameID" ); + locator.bindComponent( eventLine13RisingEdge, "EventLine13RisingEdge" ); + locator.bindComponent( eventLine13RisingEdgeTimestamp, "EventLine13RisingEdgeTimestamp" ); + locator.bindComponent( eventLine13RisingEdgeFrameID, "EventLine13RisingEdgeFrameID" ); + locator.bindComponent( eventLine14RisingEdge, "EventLine14RisingEdge" ); + locator.bindComponent( eventLine14RisingEdgeTimestamp, "EventLine14RisingEdgeTimestamp" ); + locator.bindComponent( eventLine14RisingEdgeFrameID, "EventLine14RisingEdgeFrameID" ); + locator.bindComponent( eventLine0FallingEdge, "EventLine0FallingEdge" ); + locator.bindComponent( eventLine0FallingEdgeTimestamp, "EventLine0FallingEdgeTimestamp" ); + locator.bindComponent( eventLine0FallingEdgeFrameID, "EventLine0FallingEdgeFrameID" ); + locator.bindComponent( eventLine1FallingEdge, "EventLine1FallingEdge" ); + locator.bindComponent( eventLine1FallingEdgeTimestamp, "EventLine1FallingEdgeTimestamp" ); + locator.bindComponent( eventLine1FallingEdgeFrameID, "EventLine1FallingEdgeFrameID" ); + locator.bindComponent( eventLine2FallingEdge, "EventLine2FallingEdge" ); + locator.bindComponent( eventLine2FallingEdgeTimestamp, "EventLine2FallingEdgeTimestamp" ); + locator.bindComponent( eventLine2FallingEdgeFrameID, "EventLine2FallingEdgeFrameID" ); + locator.bindComponent( eventLine3FallingEdge, "EventLine3FallingEdge" ); + locator.bindComponent( eventLine3FallingEdgeTimestamp, "EventLine3FallingEdgeTimestamp" ); + locator.bindComponent( eventLine3FallingEdgeFrameID, "EventLine3FallingEdgeFrameID" ); + locator.bindComponent( eventLine4FallingEdge, "EventLine4FallingEdge" ); + locator.bindComponent( eventLine4FallingEdgeTimestamp, "EventLine4FallingEdgeTimestamp" ); + locator.bindComponent( eventLine4FallingEdgeFrameID, "EventLine4FallingEdgeFrameID" ); + locator.bindComponent( eventLine5FallingEdge, "EventLine5FallingEdge" ); + locator.bindComponent( eventLine5FallingEdgeTimestamp, "EventLine5FallingEdgeTimestamp" ); + locator.bindComponent( eventLine5FallingEdgeFrameID, "EventLine5FallingEdgeFrameID" ); + locator.bindComponent( eventLine6FallingEdge, "EventLine6FallingEdge" ); + locator.bindComponent( eventLine6FallingEdgeTimestamp, "EventLine6FallingEdgeTimestamp" ); + locator.bindComponent( eventLine6FallingEdgeFrameID, "EventLine6FallingEdgeFrameID" ); + locator.bindComponent( eventLine7FallingEdge, "EventLine7FallingEdge" ); + locator.bindComponent( eventLine7FallingEdgeTimestamp, "EventLine7FallingEdgeTimestamp" ); + locator.bindComponent( eventLine7FallingEdgeFrameID, "EventLine7FallingEdgeFrameID" ); + locator.bindComponent( eventLine8FallingEdge, "EventLine8FallingEdge" ); + locator.bindComponent( eventLine8FallingEdgeTimestamp, "EventLine8FallingEdgeTimestamp" ); + locator.bindComponent( eventLine8FallingEdgeFrameID, "EventLine8FallingEdgeFrameID" ); + locator.bindComponent( eventLine9FallingEdge, "EventLine9FallingEdge" ); + locator.bindComponent( eventLine9FallingEdgeTimestamp, "EventLine9FallingEdgeTimestamp" ); + locator.bindComponent( eventLine9FallingEdgeFrameID, "EventLine9FallingEdgeFrameID" ); + locator.bindComponent( eventLine10FallingEdge, "EventLine10FallingEdge" ); + locator.bindComponent( eventLine10FallingEdgeTimestamp, "EventLine10FallingEdgeTimestamp" ); + locator.bindComponent( eventLine10FallingEdgeFrameID, "EventLine10FallingEdgeFrameID" ); + locator.bindComponent( eventLine11FallingEdge, "EventLine11FallingEdge" ); + locator.bindComponent( eventLine11FallingEdgeTimestamp, "EventLine11FallingEdgeTimestamp" ); + locator.bindComponent( eventLine11FallingEdgeFrameID, "EventLine11FallingEdgeFrameID" ); + locator.bindComponent( eventLine12FallingEdge, "EventLine12FallingEdge" ); + locator.bindComponent( eventLine12FallingEdgeTimestamp, "EventLine12FallingEdgeTimestamp" ); + locator.bindComponent( eventLine12FallingEdgeFrameID, "EventLine12FallingEdgeFrameID" ); + locator.bindComponent( eventLine13FallingEdge, "EventLine13FallingEdge" ); + locator.bindComponent( eventLine13FallingEdgeTimestamp, "EventLine13FallingEdgeTimestamp" ); + locator.bindComponent( eventLine13FallingEdgeFrameID, "EventLine13FallingEdgeFrameID" ); + locator.bindComponent( eventLine14FallingEdge, "EventLine14FallingEdge" ); + locator.bindComponent( eventLine14FallingEdgeTimestamp, "EventLine14FallingEdgeTimestamp" ); + locator.bindComponent( eventLine14FallingEdgeFrameID, "EventLine14FallingEdgeFrameID" ); + locator.bindComponent( eventLine0AnyEdge, "EventLine0AnyEdge" ); + locator.bindComponent( eventLine0AnyEdgeTimestamp, "EventLine0AnyEdgeTimestamp" ); + locator.bindComponent( eventLine0AnyEdgeFrameID, "EventLine0AnyEdgeFrameID" ); + locator.bindComponent( eventLine1AnyEdge, "EventLine1AnyEdge" ); + locator.bindComponent( eventLine1AnyEdgeTimestamp, "EventLine1AnyEdgeTimestamp" ); + locator.bindComponent( eventLine1AnyEdgeFrameID, "EventLine1AnyEdgeFrameID" ); + locator.bindComponent( eventLine2AnyEdge, "EventLine2AnyEdge" ); + locator.bindComponent( eventLine2AnyEdgeTimestamp, "EventLine2AnyEdgeTimestamp" ); + locator.bindComponent( eventLine2AnyEdgeFrameID, "EventLine2AnyEdgeFrameID" ); + locator.bindComponent( eventLine3AnyEdge, "EventLine3AnyEdge" ); + locator.bindComponent( eventLine3AnyEdgeTimestamp, "EventLine3AnyEdgeTimestamp" ); + locator.bindComponent( eventLine3AnyEdgeFrameID, "EventLine3AnyEdgeFrameID" ); + locator.bindComponent( eventLine4AnyEdge, "EventLine4AnyEdge" ); + locator.bindComponent( eventLine4AnyEdgeTimestamp, "EventLine4AnyEdgeTimestamp" ); + locator.bindComponent( eventLine4AnyEdgeFrameID, "EventLine4AnyEdgeFrameID" ); + locator.bindComponent( eventLine5AnyEdge, "EventLine5AnyEdge" ); + locator.bindComponent( eventLine5AnyEdgeTimestamp, "EventLine5AnyEdgeTimestamp" ); + locator.bindComponent( eventLine5AnyEdgeFrameID, "EventLine5AnyEdgeFrameID" ); + locator.bindComponent( eventLine6AnyEdge, "EventLine6AnyEdge" ); + locator.bindComponent( eventLine6AnyEdgeTimestamp, "EventLine6AnyEdgeTimestamp" ); + locator.bindComponent( eventLine6AnyEdgeFrameID, "EventLine6AnyEdgeFrameID" ); + locator.bindComponent( eventLine7AnyEdge, "EventLine7AnyEdge" ); + locator.bindComponent( eventLine7AnyEdgeTimestamp, "EventLine7AnyEdgeTimestamp" ); + locator.bindComponent( eventLine7AnyEdgeFrameID, "EventLine7AnyEdgeFrameID" ); + locator.bindComponent( eventLine8AnyEdge, "EventLine8AnyEdge" ); + locator.bindComponent( eventLine8AnyEdgeTimestamp, "EventLine8AnyEdgeTimestamp" ); + locator.bindComponent( eventLine8AnyEdgeFrameID, "EventLine8AnyEdgeFrameID" ); + locator.bindComponent( eventLine9AnyEdge, "EventLine9AnyEdge" ); + locator.bindComponent( eventLine9AnyEdgeTimestamp, "EventLine9AnyEdgeTimestamp" ); + locator.bindComponent( eventLine9AnyEdgeFrameID, "EventLine9AnyEdgeFrameID" ); + locator.bindComponent( eventLine10AnyEdge, "EventLine10AnyEdge" ); + locator.bindComponent( eventLine10AnyEdgeTimestamp, "EventLine10AnyEdgeTimestamp" ); + locator.bindComponent( eventLine10AnyEdgeFrameID, "EventLine10AnyEdgeFrameID" ); + locator.bindComponent( eventLine11AnyEdge, "EventLine11AnyEdge" ); + locator.bindComponent( eventLine11AnyEdgeTimestamp, "EventLine11AnyEdgeTimestamp" ); + locator.bindComponent( eventLine11AnyEdgeFrameID, "EventLine11AnyEdgeFrameID" ); + locator.bindComponent( eventLine12AnyEdge, "EventLine12AnyEdge" ); + locator.bindComponent( eventLine12AnyEdgeTimestamp, "EventLine12AnyEdgeTimestamp" ); + locator.bindComponent( eventLine12AnyEdgeFrameID, "EventLine12AnyEdgeFrameID" ); + locator.bindComponent( eventLine13AnyEdge, "EventLine13AnyEdge" ); + locator.bindComponent( eventLine13AnyEdgeTimestamp, "EventLine13AnyEdgeTimestamp" ); + locator.bindComponent( eventLine13AnyEdgeFrameID, "EventLine13AnyEdgeFrameID" ); + locator.bindComponent( eventLine14AnyEdge, "EventLine14AnyEdge" ); + locator.bindComponent( eventLine14AnyEdgeTimestamp, "EventLine14AnyEdgeTimestamp" ); + locator.bindComponent( eventLine14AnyEdgeFrameID, "EventLine14AnyEdgeFrameID" ); + locator.bindComponent( eventLinkTrigger0, "EventLinkTrigger0" ); + locator.bindComponent( eventLinkTrigger0Timestamp, "EventLinkTrigger0Timestamp" ); + locator.bindComponent( eventLinkTrigger0FrameID, "EventLinkTrigger0FrameID" ); + locator.bindComponent( eventLinkTrigger1, "EventLinkTrigger1" ); + locator.bindComponent( eventLinkTrigger1Timestamp, "EventLinkTrigger1Timestamp" ); + locator.bindComponent( eventLinkTrigger1FrameID, "EventLinkTrigger1FrameID" ); + locator.bindComponent( eventLinkTrigger2, "EventLinkTrigger2" ); + locator.bindComponent( eventLinkTrigger2Timestamp, "EventLinkTrigger2Timestamp" ); + locator.bindComponent( eventLinkTrigger2FrameID, "EventLinkTrigger2FrameID" ); + locator.bindComponent( eventLinkTrigger3, "EventLinkTrigger3" ); + locator.bindComponent( eventLinkTrigger3Timestamp, "EventLinkTrigger3Timestamp" ); + locator.bindComponent( eventLinkTrigger3FrameID, "EventLinkTrigger3FrameID" ); + locator.bindComponent( eventLinkTrigger4, "EventLinkTrigger4" ); + locator.bindComponent( eventLinkTrigger4Timestamp, "EventLinkTrigger4Timestamp" ); + locator.bindComponent( eventLinkTrigger4FrameID, "EventLinkTrigger4FrameID" ); + locator.bindComponent( eventLinkTrigger5, "EventLinkTrigger5" ); + locator.bindComponent( eventLinkTrigger5Timestamp, "EventLinkTrigger5Timestamp" ); + locator.bindComponent( eventLinkTrigger5FrameID, "EventLinkTrigger5FrameID" ); + locator.bindComponent( eventLinkTrigger6, "EventLinkTrigger6" ); + locator.bindComponent( eventLinkTrigger6Timestamp, "EventLinkTrigger6Timestamp" ); + locator.bindComponent( eventLinkTrigger6FrameID, "EventLinkTrigger6FrameID" ); + locator.bindComponent( eventLinkTrigger7, "EventLinkTrigger7" ); + locator.bindComponent( eventLinkTrigger7Timestamp, "EventLinkTrigger7Timestamp" ); + locator.bindComponent( eventLinkTrigger7FrameID, "EventLinkTrigger7FrameID" ); + locator.bindComponent( eventLinkTrigger8, "EventLinkTrigger8" ); + locator.bindComponent( eventLinkTrigger8Timestamp, "EventLinkTrigger8Timestamp" ); + locator.bindComponent( eventLinkTrigger8FrameID, "EventLinkTrigger8FrameID" ); + locator.bindComponent( eventLinkTrigger9, "EventLinkTrigger9" ); + locator.bindComponent( eventLinkTrigger9Timestamp, "EventLinkTrigger9Timestamp" ); + locator.bindComponent( eventLinkTrigger9FrameID, "EventLinkTrigger9FrameID" ); + locator.bindComponent( eventLinkTrigger10, "EventLinkTrigger10" ); + locator.bindComponent( eventLinkTrigger10Timestamp, "EventLinkTrigger10Timestamp" ); + locator.bindComponent( eventLinkTrigger10FrameID, "EventLinkTrigger10FrameID" ); + locator.bindComponent( eventLinkTrigger11, "EventLinkTrigger11" ); + locator.bindComponent( eventLinkTrigger11Timestamp, "EventLinkTrigger11Timestamp" ); + locator.bindComponent( eventLinkTrigger11FrameID, "EventLinkTrigger11FrameID" ); + locator.bindComponent( eventLinkTrigger12, "EventLinkTrigger12" ); + locator.bindComponent( eventLinkTrigger12Timestamp, "EventLinkTrigger12Timestamp" ); + locator.bindComponent( eventLinkTrigger12FrameID, "EventLinkTrigger12FrameID" ); + locator.bindComponent( eventLinkTrigger13, "EventLinkTrigger13" ); + locator.bindComponent( eventLinkTrigger13Timestamp, "EventLinkTrigger13Timestamp" ); + locator.bindComponent( eventLinkTrigger13FrameID, "EventLinkTrigger13FrameID" ); + locator.bindComponent( eventLinkTrigger14, "EventLinkTrigger14" ); + locator.bindComponent( eventLinkTrigger14Timestamp, "EventLinkTrigger14Timestamp" ); + locator.bindComponent( eventLinkTrigger14FrameID, "EventLinkTrigger14FrameID" ); + locator.bindComponent( eventError, "EventError" ); + locator.bindComponent( eventErrorTimestamp, "EventErrorTimestamp" ); + locator.bindComponent( eventErrorFrameID, "EventErrorFrameID" ); + locator.bindComponent( eventErrorCode, "EventErrorCode" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which Event to signal to the host application. + /** + * Selects which Event to signal to the host application. + * + * The following string values might be valid for this feature: + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device just received a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device just missed a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Device just started the Acquisition of one or many Frames. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Device just completed the Acquisition of one or many Frames. + * - \b AcquisitionTransferStart (Display string: 'Acquisition Transfer Start'): Device just started the transfer of one or many Frames. + * - \b AcquisitionTransferEnd (Display string: 'Acquisition Transfer End'): Device just completed the transfer of one or many Frames. + * - \b AcquisitionError (Display string: 'Acquisition Error'): Device just detected an error during the active Acquisition. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Device just started the capture of a burst of Frames. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Device just completed the capture of a burst of Frames. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device just received a trigger to start the capture of one Frame. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device just missed a trigger to start the capture of one Frame. + * - \b FrameStart (Display string: 'Frame Start'): Device just started the capture of one Frame. + * - \b FrameEnd (Display string: 'Frame End'): Device just completed the capture of one Frame. + * - \b FrameTransferStart (Display string: 'Frame Transfer Start'): Device just started the transfer of one Frame. + * - \b FrameTransferEnd (Display string: 'Frame Transfer End'): Device just completed the transfer of one Frame. + * - \b LineTrigger (Display string: 'Line Trigger'): Device just received a trigger to start the capture of one Line. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device just missed a trigger to start the capture of one Line. + * - \b LineStart (Display string: 'Line Start'): Device just started the capture of one Line. + * - \b LineEnd (Display string: 'Line End'): Device just completed the capture of one Line. + * - \b ExposureStart (Display string: 'Exposure Start'): Device just started the exposure of one Frame (or Line). + * - \b ExposureEnd (Display string: 'Exposure End'): Device just completed the exposure of one Frame (or Line). + * - \b Stream0TransferStart (Display string: 'Stream 0 Transfer Start'): Device just started the transfer of one or many Blocks. + * - \b Stream0TransferEnd (Display string: 'Stream 0 Transfer End'): Device just completed the transfer of one or many Blocks. + * - \b Stream0TransferPause (Display string: 'Stream 0 Transfer Pause'): Device just paused the transfer. + * - \b Stream0TransferResume (Display string: 'Stream 0 Transfer Resume'): Device just resumed the transfer. + * - \b Stream0TransferBlockStart (Display string: 'Stream 0 Transfer Block Start'): Device just started the transfer of one Block. + * - \b Stream0TransferBlockEnd (Display string: 'Stream 0 Transfer Block End'): Device just completed the transfer of one Block. + * - \b Stream0TransferBlockTrigger (Display string: 'Stream 0 Transfer Block Trigger'): Device just received a trigger to start the transfer of one Block. + * - \b Stream0TransferBurstStart (Display string: 'Stream 0 Transfer Burst Start'): Device just started the transfer of a burst of Blocks. + * - \b Stream0TransferBurstEnd (Display string: 'Stream 0 Transfer Burst End'): Device just completed the transfer of a burst of Blocks. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Device transfer queue overflowed. + * - \b SequencerSetChange (Display string: 'Sequencer Set Change'): Device sequencer set has changed. + * - \b Counter0Start (Display string: 'Counter 0 Start'): The event will be generated when counter 0 starts counting. + * - \b Counter1Start (Display string: 'Counter 1 Start'): The event will be generated when counter 1 starts counting. + * - \b Counter\#2\#Start (Display string: 'Counter \#2\# Start'): The event will be generated when counter \#2\# starts counting. + * - \b Counter0End (Display string: 'Counter 0 End'): The event will be generated when counter 0 ends counting. + * - \b Counter1End (Display string: 'Counter 1 End'): The event will be generated when counter 1 ends counting. + * - \b Counter\#2\#End (Display string: 'Counter \#2\# End'): The event will be generated when counter \#2\# ends counting. + * - \b Timer0Start (Display string: 'Timer 0 Start'): The event will be generated when Timer 0 starts counting. + * - \b Timer1Start (Display string: 'Timer 1 Start'): The event will be generated when Timer 1 starts counting. + * - \b Timer\#2\#Start (Display string: 'Timer \#2\# Start'): The event will be generated when Timer \#2\# starts counting. + * - \b Timer0End (Display string: 'Timer 0 End'): The event will be generated when Timer 0 ends counting. + * - \b Timer1End (Display string: 'Timer 1 End'): The event will be generated when Timer 1 ends counting. + * - \b Timer\#2\#End (Display string: 'Timer \#2\# End'): The event will be generated when Timer \#2\# ends counting. + * - \b Encoder0Stopped (Display string: 'Encoder 0 Stopped'): The event will be generated when the Encoder 0 stops for longer than EncoderTimeout. + * - \b Encoder1Stopped (Display string: 'Encoder 1 Stopped'): The event will be generated when the Encoder 1 stops for longer than EncoderTimeout. + * - \b Encoder\#2\#Stopped (Display string: 'Encoder \#2\# Stopped'): The event will be generated when the Encoder \#2\# stops for longer than EncoderTimeout. + * - \b Encoder0Restarted (Display string: 'Encoder 0 Restarted'): The event will be generated when the Encoder 0 restarts moving. + * - \b Encoder1Restarted (Display string: 'Encoder 1 Restarted'): The event will be generated when the Encoder 1 restarts moving. + * - \b Encoder\#2\#Restarted (Display string: 'Encoder \#2\# Restarted'): The event will be generated when the Encoder \#2\# restarts moving. + * - \b Line0RisingEdge (Display string: 'Line 0 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 0. + * - \b Line1RisingEdge (Display string: 'Line 1 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 1. + * - \b Line\#2\#RisingEdge (Display string: 'Line \#2\# Rising Edge'): The event will be generated when a Rising Edge is detected on the Line \#2\#. + * - \b Line0FallingEdge (Display string: 'Line 0 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 0. + * - \b Line1FallingEdge (Display string: 'Line 1 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 1. + * - \b Line\#2\#FallingEdge (Display string: 'Line \#2\# Falling Edge'): The event will be generated when a Falling Edge is detected on the Line \#2\#. + * - \b Line0AnyEdge (Display string: 'Line 0 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 0. + * - \b Line1AnyEdge (Display string: 'Line 1 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 1. + * - \b Line\#2\#AnyEdge (Display string: 'Line \#2\# Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line \#2\#. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): The event will be generated when a Rising Edge is detected on the LinkTrigger 0. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): The event will be generated when a Rising Edge is detected on the LinkTrigger 1. + * - \b LinkTrigger\#2\# (Display string: 'Link Trigger \#2\#'): The event will be generated when a Rising Edge is detected on the LinkTrigger \#2\#. + * - \b LinkSpeedChange (Display string: 'Link Speed Change'): The event will be generated when the link speed has changed. + * - \b ActionLate (Display string: 'Action Late'): The event will be generated when a valid scheduled action command is received and is scheduled to be executed at a time that is already past. + * - \b Error (Display string: 'Error'): Device just detected an error during the active Acquisition. + * - \b Test (Display string: 'Test'): The test event will be generated when the device receives the TestEventGenerate command (EventNotification for the Test event is always On). + * - \b PrimaryApplicationSwitch (Display string: 'Primary Application Switch'): The event will be generated when a primary application switchover has been granted (GigE Vision Specific). + * - \b Counter2Start (Display string: 'Counter 2 Start'): The event will be generated when counter 2 starts counting. + * - \b Counter3Start (Display string: 'Counter 3 Start'): The event will be generated when counter 3 starts counting. + * - \b Counter4Start (Display string: 'Counter 4 Start'): The event will be generated when counter 4 starts counting. + * - \b Counter5Start (Display string: 'Counter 5 Start'): The event will be generated when counter 5 starts counting. + * - \b Counter6Start (Display string: 'Counter 6 Start'): The event will be generated when counter 6 starts counting. + * - \b Counter7Start (Display string: 'Counter 7 Start'): The event will be generated when counter 7 starts counting. + * - \b Counter8Start (Display string: 'Counter 8 Start'): The event will be generated when counter 8 starts counting. + * - \b Counter9Start (Display string: 'Counter 9 Start'): The event will be generated when counter 9 starts counting. + * - \b Counter10Start (Display string: 'Counter 10 Start'): The event will be generated when counter 10 starts counting. + * - \b Counter11Start (Display string: 'Counter 11 Start'): The event will be generated when counter 11 starts counting. + * - \b Counter12Start (Display string: 'Counter 12 Start'): The event will be generated when counter 12 starts counting. + * - \b Counter13Start (Display string: 'Counter 13 Start'): The event will be generated when counter 13 starts counting. + * - \b Counter14Start (Display string: 'Counter 14 Start'): The event will be generated when counter 14 starts counting. + * - \b Counter15Start (Display string: 'Counter 15 Start'): The event will be generated when counter 15 starts counting. + * - \b Counter2End (Display string: 'Counter 2 End'): The event will be generated when counter 2 ends counting. + * - \b Counter3End (Display string: 'Counter 3 End'): The event will be generated when counter 3 ends counting. + * - \b Counter4End (Display string: 'Counter 4 End'): The event will be generated when counter 4 ends counting. + * - \b Counter5End (Display string: 'Counter 5 End'): The event will be generated when counter 5 ends counting. + * - \b Counter6End (Display string: 'Counter 6 End'): The event will be generated when counter 6 ends counting. + * - \b Counter7End (Display string: 'Counter 7 End'): The event will be generated when counter 7 ends counting. + * - \b Counter8End (Display string: 'Counter 8 End'): The event will be generated when counter 8 ends counting. + * - \b Counter9End (Display string: 'Counter 9 End'): The event will be generated when counter 9 ends counting. + * - \b Counter10End (Display string: 'Counter 10 End'): The event will be generated when counter 10 ends counting. + * - \b Counter11End (Display string: 'Counter 11 End'): The event will be generated when counter 11 ends counting. + * - \b Counter12End (Display string: 'Counter 12 End'): The event will be generated when counter 12 ends counting. + * - \b Counter13End (Display string: 'Counter 13 End'): The event will be generated when counter 13 ends counting. + * - \b Counter14End (Display string: 'Counter 14 End'): The event will be generated when counter 14 ends counting. + * - \b Counter15End (Display string: 'Counter 15 End'): The event will be generated when counter 15 ends counting. + * - \b Timer2Start (Display string: 'Timer 2 Start'): The event will be generated when Timer 2 starts counting. + * - \b Timer3Start (Display string: 'Timer 3 Start'): The event will be generated when Timer 3 starts counting. + * - \b Timer4Start (Display string: 'Timer 4 Start'): The event will be generated when Timer 4 starts counting. + * - \b Timer5Start (Display string: 'Timer 5 Start'): The event will be generated when Timer 5 starts counting. + * - \b Timer6Start (Display string: 'Timer 6 Start'): The event will be generated when Timer 6 starts counting. + * - \b Timer7Start (Display string: 'Timer 7 Start'): The event will be generated when Timer 7 starts counting. + * - \b Timer8Start (Display string: 'Timer 8 Start'): The event will be generated when Timer 8 starts counting. + * - \b Timer9Start (Display string: 'Timer 9 Start'): The event will be generated when Timer 9 starts counting. + * - \b Timer10Start (Display string: 'Timer 10 Start'): The event will be generated when Timer 10 starts counting. + * - \b Timer11Start (Display string: 'Timer 11 Start'): The event will be generated when Timer 11 starts counting. + * - \b Timer12Start (Display string: 'Timer 12 Start'): The event will be generated when Timer 12 starts counting. + * - \b Timer13Start (Display string: 'Timer 13 Start'): The event will be generated when Timer 13 starts counting. + * - \b Timer14Start (Display string: 'Timer 14 Start'): The event will be generated when Timer 14 starts counting. + * - \b Timer15Start (Display string: 'Timer 15 Start'): The event will be generated when Timer 15 starts counting. + * - \b Timer2End (Display string: 'Timer 2 End'): The event will be generated when Timer 2 ends counting. + * - \b Timer3End (Display string: 'Timer 3 End'): The event will be generated when Timer 3 ends counting. + * - \b Timer4End (Display string: 'Timer 4 End'): The event will be generated when Timer 4 ends counting. + * - \b Timer5End (Display string: 'Timer 5 End'): The event will be generated when Timer 5 ends counting. + * - \b Timer6End (Display string: 'Timer 6 End'): The event will be generated when Timer 6 ends counting. + * - \b Timer7End (Display string: 'Timer 7 End'): The event will be generated when Timer 7 ends counting. + * - \b Timer8End (Display string: 'Timer 8 End'): The event will be generated when Timer 8 ends counting. + * - \b Timer9End (Display string: 'Timer 9 End'): The event will be generated when Timer 9 ends counting. + * - \b Timer10End (Display string: 'Timer 10 End'): The event will be generated when Timer 10 ends counting. + * - \b Timer11End (Display string: 'Timer 11 End'): The event will be generated when Timer 11 ends counting. + * - \b Timer12End (Display string: 'Timer 12 End'): The event will be generated when Timer 12 ends counting. + * - \b Timer13End (Display string: 'Timer 13 End'): The event will be generated when Timer 13 ends counting. + * - \b Timer14End (Display string: 'Timer 14 End'): The event will be generated when Timer 14 ends counting. + * - \b Timer15End (Display string: 'Timer 15 End'): The event will be generated when Timer 15 ends counting. + * - \b Encoder2Stopped (Display string: 'Encoder 2 Stopped'): The event will be generated when the Encoder 2 stops for longer than EncoderTimeout. + * - \b Encoder3Stopped (Display string: 'Encoder 3 Stopped'): The event will be generated when the Encoder 3 stops for longer than EncoderTimeout. + * - \b Encoder4Stopped (Display string: 'Encoder 4 Stopped'): The event will be generated when the Encoder 4 stops for longer than EncoderTimeout. + * - \b Encoder5Stopped (Display string: 'Encoder 5 Stopped'): The event will be generated when the Encoder 5 stops for longer than EncoderTimeout. + * - \b Encoder6Stopped (Display string: 'Encoder 6 Stopped'): The event will be generated when the Encoder 6 stops for longer than EncoderTimeout. + * - \b Encoder7Stopped (Display string: 'Encoder 7 Stopped'): The event will be generated when the Encoder 7 stops for longer than EncoderTimeout. + * - \b Encoder8Stopped (Display string: 'Encoder 8 Stopped'): The event will be generated when the Encoder 8 stops for longer than EncoderTimeout. + * - \b Encoder9Stopped (Display string: 'Encoder 9 Stopped'): The event will be generated when the Encoder 9 stops for longer than EncoderTimeout. + * - \b Encoder10Stopped (Display string: 'Encoder 10 Stopped'): The event will be generated when the Encoder 10 stops for longer than EncoderTimeout. + * - \b Encoder11Stopped (Display string: 'Encoder 11 Stopped'): The event will be generated when the Encoder 11 stops for longer than EncoderTimeout. + * - \b Encoder12Stopped (Display string: 'Encoder 12 Stopped'): The event will be generated when the Encoder 12 stops for longer than EncoderTimeout. + * - \b Encoder13Stopped (Display string: 'Encoder 13 Stopped'): The event will be generated when the Encoder 13 stops for longer than EncoderTimeout. + * - \b Encoder14Stopped (Display string: 'Encoder 14 Stopped'): The event will be generated when the Encoder 14 stops for longer than EncoderTimeout. + * - \b Encoder15Stopped (Display string: 'Encoder 15 Stopped'): The event will be generated when the Encoder 15 stops for longer than EncoderTimeout. + * - \b Encoder2Restarted (Display string: 'Encoder 2 Restarted'): The event will be generated when the Encoder 2 restarts moving. + * - \b Encoder3Restarted (Display string: 'Encoder 3 Restarted'): The event will be generated when the Encoder 3 restarts moving. + * - \b Encoder4Restarted (Display string: 'Encoder 4 Restarted'): The event will be generated when the Encoder 4 restarts moving. + * - \b Encoder5Restarted (Display string: 'Encoder 5 Restarted'): The event will be generated when the Encoder 5 restarts moving. + * - \b Encoder6Restarted (Display string: 'Encoder 6 Restarted'): The event will be generated when the Encoder 6 restarts moving. + * - \b Encoder7Restarted (Display string: 'Encoder 7 Restarted'): The event will be generated when the Encoder 7 restarts moving. + * - \b Encoder8Restarted (Display string: 'Encoder 8 Restarted'): The event will be generated when the Encoder 8 restarts moving. + * - \b Encoder9Restarted (Display string: 'Encoder 9 Restarted'): The event will be generated when the Encoder 9 restarts moving. + * - \b Encoder10Restarted (Display string: 'Encoder 10 Restarted'): The event will be generated when the Encoder 10 restarts moving. + * - \b Encoder11Restarted (Display string: 'Encoder 11 Restarted'): The event will be generated when the Encoder 11 restarts moving. + * - \b Encoder12Restarted (Display string: 'Encoder 12 Restarted'): The event will be generated when the Encoder 12 restarts moving. + * - \b Encoder13Restarted (Display string: 'Encoder 13 Restarted'): The event will be generated when the Encoder 13 restarts moving. + * - \b Encoder14Restarted (Display string: 'Encoder 14 Restarted'): The event will be generated when the Encoder 14 restarts moving. + * - \b Encoder15Restarted (Display string: 'Encoder 15 Restarted'): The event will be generated when the Encoder 15 restarts moving. + * - \b Line2RisingEdge (Display string: 'Line 2 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 2. + * - \b Line3RisingEdge (Display string: 'Line 3 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 3. + * - \b Line4RisingEdge (Display string: 'Line 4 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 4. + * - \b Line5RisingEdge (Display string: 'Line 5 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 5. + * - \b Line6RisingEdge (Display string: 'Line 6 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 6. + * - \b Line7RisingEdge (Display string: 'Line 7 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 7. + * - \b Line8RisingEdge (Display string: 'Line 8 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 8. + * - \b Line9RisingEdge (Display string: 'Line 9 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 9. + * - \b Line10RisingEdge (Display string: 'Line 10 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 10. + * - \b Line11RisingEdge (Display string: 'Line 11 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 11. + * - \b Line12RisingEdge (Display string: 'Line 12 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 12. + * - \b Line13RisingEdge (Display string: 'Line 13 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 13. + * - \b Line14RisingEdge (Display string: 'Line 14 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 14. + * - \b Line15RisingEdge (Display string: 'Line 15 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 15. + * - \b Line2FallingEdge (Display string: 'Line 2 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 2. + * - \b Line3FallingEdge (Display string: 'Line 3 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 3. + * - \b Line4FallingEdge (Display string: 'Line 4 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 4. + * - \b Line5FallingEdge (Display string: 'Line 5 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 5. + * - \b Line6FallingEdge (Display string: 'Line 6 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 6. + * - \b Line7FallingEdge (Display string: 'Line 7 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 7. + * - \b Line8FallingEdge (Display string: 'Line 8 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 8. + * - \b Line9FallingEdge (Display string: 'Line 9 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 9. + * - \b Line10FallingEdge (Display string: 'Line 10 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 10. + * - \b Line11FallingEdge (Display string: 'Line 11 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 11. + * - \b Line12FallingEdge (Display string: 'Line 12 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 12. + * - \b Line13FallingEdge (Display string: 'Line 13 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 13. + * - \b Line14FallingEdge (Display string: 'Line 14 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 14. + * - \b Line15FallingEdge (Display string: 'Line 15 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 15. + * - \b Line2AnyEdge (Display string: 'Line 2 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 2. + * - \b Line3AnyEdge (Display string: 'Line 3 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 3. + * - \b Line4AnyEdge (Display string: 'Line 4 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 4. + * - \b Line5AnyEdge (Display string: 'Line 5 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 5. + * - \b Line6AnyEdge (Display string: 'Line 6 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 6. + * - \b Line7AnyEdge (Display string: 'Line 7 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 7. + * - \b Line8AnyEdge (Display string: 'Line 8 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 8. + * - \b Line9AnyEdge (Display string: 'Line 9 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 9. + * - \b Line10AnyEdge (Display string: 'Line 10 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 10. + * - \b Line11AnyEdge (Display string: 'Line 11 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 11. + * - \b Line12AnyEdge (Display string: 'Line 12 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 12. + * - \b Line13AnyEdge (Display string: 'Line 13 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 13. + * - \b Line14AnyEdge (Display string: 'Line 14 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 14. + * - \b Line15AnyEdge (Display string: 'Line 15 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 15. + * - \b Link0Trigger (Display string: 'Link 0 Trigger') + * - \b Link1Trigger (Display string: 'Link 1 Trigger') + * - \b Link2Trigger (Display string: 'Link 2 Trigger') + * - \b Link3Trigger (Display string: 'Link 3 Trigger') + * - \b Link4Trigger (Display string: 'Link 4 Trigger') + * - \b Link5Trigger (Display string: 'Link 5 Trigger') + * - \b Link6Trigger (Display string: 'Link 6 Trigger') + * - \b Link7Trigger (Display string: 'Link 7 Trigger') + * - \b Link8Trigger (Display string: 'Link 8 Trigger') + * - \b Link9Trigger (Display string: 'Link 9 Trigger') + * - \b Link10Trigger (Display string: 'Link 10 Trigger') + * - \b Link11Trigger (Display string: 'Link 11 Trigger') + * - \b Link12Trigger (Display string: 'Link 12 Trigger') + * - \b Link13Trigger (Display string: 'Link 13 Trigger') + * - \b Link14Trigger (Display string: 'Link 14 Trigger') + * - \b Link15Trigger (Display string: 'Link 15 Trigger') + * - \b InterfaceListChanged (Display string: 'Interface List Changed'): This enumeration value indicates an event that is fired when the list of interfaces has been updated. + * - \b InterfaceLost (Display string: 'Interface Lost'): This enumeration value indicates an event that is raised when the interface connection is lost. + * - \b DeviceListChanged (Display string: 'Device List Changed'): This enumeration value indicates an event that is fired when the list of devices has been updated. + * - \b DeviceLost (Display string: 'Device Lost'): This enumeration value indicates an event that is raised when the local host looses connection to the physical(remote) device. + * - \b BufferTooSmall (Display string: 'Buffer Too Small'): This enumeration value indicates an event that is raised when the buffer was too small to receive the expected amount of data. + * - \b BuffersDiscarded (Display string: 'Buffers Discarded'): This enumeration value indicates an event that is raised when buffers discared by GenTL or device. This event could optionally carry two numeric child data fields EventBuffersDiscardedDeviceCount and EventBuffersDiscardedProducerCount. + * - \b BuffersDiscardedDeviceCount (Display string: 'Buffers Discarded Device Count'): This enumeration value indicates the number of buffers discarded by the device since last fired instance of this event (the producer would get to know about this for example by observing a gap in the block_id sequence). + * - \b BuffersDiscardedProducerCount (Display string: 'Buffers Discarded Producer Count'): This enumeration value indicates the number of buffers discarded by the producer since last fired instance of this event (this would happen e.g. if there are no free buffers available or if given buffer handling mode requires discarding old buffers etc.). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventSelector; + /// \brief An enumerated integer property. Activate or deactivate the notification to the host application of the occurrence of the selected Event. + /** + * Activate or deactivate the notification to the host application of the occurrence of the selected Event. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The selected Event notification is disabled. + * - \b On (Display string: 'On'): The selected Event notification is enabled. + * - \b Once (Display string: 'Once'): The selected Event notification is enabled for one event then return to Off state. + * - \b GigEVisionEvent (Display string: 'Gig E Vision Event') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventNotification; + /// \brief An integer property. Returns the unique Identifier of the Acquisition Trigger type of Event. + /** + * Returns the unique Identifier of the Acquisition Trigger type of Event. + */ + PropertyI64 eventAcquisitionTrigger; + /// \brief An integer property. Returns the Timestamp of the Acquisition Trigger Event. + /** + * Returns the Timestamp of the Acquisition Trigger Event. + */ + PropertyI64 eventAcquisitionTriggerTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition Trigger Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition Trigger Event. + */ + PropertyI64 eventAcquisitionTriggerFrameID; + /// \brief An integer property. Returns the unique Identifier of the Acquisition Trigger Missed type of Event. + /** + * Returns the unique Identifier of the Acquisition Trigger Missed type of Event. + */ + PropertyI64 eventAcquisitionTriggerMissed; + /// \brief An integer property. Returns the Timestamp of the Acquisition Trigger Missed Event. + /** + * Returns the Timestamp of the Acquisition Trigger Missed Event. + */ + PropertyI64 eventAcquisitionTriggerMissedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition Trigger Missed Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition Trigger Missed Event. + */ + PropertyI64 eventAcquisitionTriggerMissedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Acquisition Start type of Event. + /** + * Returns the unique Identifier of the Acquisition Start type of Event. + */ + PropertyI64 eventAcquisitionStart; + /// \brief An integer property. Returns the Timestamp of the Acquisition Start Event. + /** + * Returns the Timestamp of the Acquisition Start Event. + */ + PropertyI64 eventAcquisitionStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition Start Event. + */ + PropertyI64 eventAcquisitionStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Acquisition End type of Event. + /** + * Returns the unique Identifier of the Acquisition End type of Event. + */ + PropertyI64 eventAcquisitionEnd; + /// \brief An integer property. Returns the Timestamp of the Acquisition End Event. + /** + * Returns the Timestamp of the Acquisition End Event. + */ + PropertyI64 eventAcquisitionEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition End Event. + */ + PropertyI64 eventAcquisitionEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Acquisition Transfer Start type of Event. + /** + * Returns the unique Identifier of the Acquisition Transfer Start type of Event. + */ + PropertyI64 eventAcquisitionTransferStart; + /// \brief An integer property. Returns the Timestamp of the Acquisition Transfer Start Event. + /** + * Returns the Timestamp of the Acquisition Transfer Start Event. + */ + PropertyI64 eventAcquisitionTransferStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition Transfer Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition Transfer Start Event. + */ + PropertyI64 eventAcquisitionTransferStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Acquisition Transfer End type of Event. + /** + * Returns the unique Identifier of the Acquisition Transfer End type of Event. + */ + PropertyI64 eventAcquisitionTransferEnd; + /// \brief An integer property. Returns the Timestamp of the Acquisition Transfer End Event. + /** + * Returns the Timestamp of the Acquisition Transfer End Event. + */ + PropertyI64 eventAcquisitionTransferEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition Transfer End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition Transfer End Event. + */ + PropertyI64 eventAcquisitionTransferEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Acquisition Error type of Event. + /** + * Returns the unique Identifier of the Acquisition Error type of Event. + */ + PropertyI64 eventAcquisitionError; + /// \brief An integer property. Returns the Timestamp of the Acquisition Error Event. + /** + * Returns the Timestamp of the Acquisition Error Event. + */ + PropertyI64 eventAcquisitionErrorTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Acquisition Error Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Acquisition Error Event. + */ + PropertyI64 eventAcquisitionErrorFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Burst Start type of Event. + /** + * Returns the unique Identifier of the Frame Burst Start type of Event. + */ + PropertyI64 eventFrameBurstStart; + /// \brief An integer property. Returns the Timestamp of the Frame Burst Start Event. + /** + * Returns the Timestamp of the Frame Burst Start Event. + */ + PropertyI64 eventFrameBurstStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Burst Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Burst Start Event. + */ + PropertyI64 eventFrameBurstStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Burst End type of Event. + /** + * Returns the unique Identifier of the Frame Burst End type of Event. + */ + PropertyI64 eventFrameBurstEnd; + /// \brief An integer property. Returns the Timestamp of the Frame Burst End Event. + /** + * Returns the Timestamp of the Frame Burst End Event. + */ + PropertyI64 eventFrameBurstEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Burst End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Burst End Event. + */ + PropertyI64 eventFrameBurstEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Trigger type of Event. + /** + * Returns the unique Identifier of the Frame Trigger type of Event. + */ + PropertyI64 eventFrameTrigger; + /// \brief An integer property. Returns the Timestamp of the Frame Trigger Event. + /** + * Returns the Timestamp of the Frame Trigger Event. + */ + PropertyI64 eventFrameTriggerTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Trigger Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Trigger Event. + */ + PropertyI64 eventFrameTriggerFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Trigger Missed type of Event. + /** + * Returns the unique Identifier of the Frame Trigger Missed type of Event. + */ + PropertyI64 eventFrameTriggerMissed; + /// \brief An integer property. Returns the Timestamp of the Frame Trigger Missed Event. + /** + * Returns the Timestamp of the Frame Trigger Missed Event. + */ + PropertyI64 eventFrameTriggerMissedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Trigger Missed Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Trigger Missed Event. + */ + PropertyI64 eventFrameTriggerMissedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Start type of Event. + /** + * Returns the unique Identifier of the Frame Start type of Event. + */ + PropertyI64 eventFrameStart; + /// \brief An integer property. Returns the Timestamp of the Frame Start Event. + /** + * Returns the Timestamp of the Frame Start Event. + */ + PropertyI64 eventFrameStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Start Event. + */ + PropertyI64 eventFrameStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame End type of Event. + /** + * Returns the unique Identifier of the Frame End type of Event. + */ + PropertyI64 eventFrameEnd; + /// \brief An integer property. Returns the Timestamp of the Frame End Event. + /** + * Returns the Timestamp of the Frame End Event. + */ + PropertyI64 eventFrameEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame End Event. + */ + PropertyI64 eventFrameEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Transfer Start type of Event. + /** + * Returns the unique Identifier of the Frame Transfer Start type of Event. + */ + PropertyI64 eventFrameTransferStart; + /// \brief An integer property. Returns the Timestamp of the Frame Transfer Start Event. + /** + * Returns the Timestamp of the Frame Transfer Start Event. + */ + PropertyI64 eventFrameTransferStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Transfer Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Transfer Start Event. + */ + PropertyI64 eventFrameTransferStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Frame Transfer End type of Event. + /** + * Returns the unique Identifier of the Frame Transfer End type of Event. + */ + PropertyI64 eventFrameTransferEnd; + /// \brief An integer property. Returns the Timestamp of the Frame Transfer End Event. + /** + * Returns the Timestamp of the Frame Transfer End Event. + */ + PropertyI64 eventFrameTransferEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Frame Transfer End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Frame Transfer End Event. + */ + PropertyI64 eventFrameTransferEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line Trigger type of Event. + /** + * Returns the unique Identifier of the Line Trigger type of Event. + */ + PropertyI64 eventLineTrigger; + /// \brief An integer property. Returns the Timestamp of the Line Trigger Event. + /** + * Returns the Timestamp of the Line Trigger Event. + */ + PropertyI64 eventLineTriggerTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line Trigger Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line Trigger Event. + */ + PropertyI64 eventLineTriggerFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line Trigger Missed type of Event. + /** + * Returns the unique Identifier of the Line Trigger Missed type of Event. + */ + PropertyI64 eventLineTriggerMissed; + /// \brief An integer property. Returns the Timestamp of the Line Trigger Missed Event. + /** + * Returns the Timestamp of the Line Trigger Missed Event. + */ + PropertyI64 eventLineTriggerMissedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line Trigger Missed Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line Trigger Missed Event. + */ + PropertyI64 eventLineTriggerMissedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line Start type of Event. + /** + * Returns the unique Identifier of the Line Start type of Event. + */ + PropertyI64 eventLineStart; + /// \brief An integer property. Returns the Timestamp of the Line Start Event. + /** + * Returns the Timestamp of the Line Start Event. + */ + PropertyI64 eventLineStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line Start Event. + */ + PropertyI64 eventLineStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line End type of Event. + /** + * Returns the unique Identifier of the Line End type of Event. + */ + PropertyI64 eventLineEnd; + /// \brief An integer property. Returns the Timestamp of the Line End Event. + /** + * Returns the Timestamp of the Line End Event. + */ + PropertyI64 eventLineEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line End Event. + */ + PropertyI64 eventLineEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Exposure Start type of Event. + /** + * Returns the unique Identifier of the Exposure Start type of Event. + */ + PropertyI64 eventExposureStart; + /// \brief An integer property. Returns the Timestamp of the Exposure Start Event. + /** + * Returns the Timestamp of the Exposure Start Event. + */ + PropertyI64 eventExposureStartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Exposure Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Exposure Start Event. + */ + PropertyI64 eventExposureStartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Exposure End type of Event. + /** + * Returns the unique Identifier of the Exposure End type of Event. + */ + PropertyI64 eventExposureEnd; + /// \brief An integer property. Returns the Timestamp of the Exposure End Event. + /** + * Returns the Timestamp of the Exposure End Event. + */ + PropertyI64 eventExposureEndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Exposure End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Exposure End Event. + */ + PropertyI64 eventExposureEndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Action Late type of Event. + /** + * Returns the unique Identifier of the Action Late type of Event. + */ + PropertyI64 eventActionLate; + /// \brief An integer property. Returns the Timestamp of the Action Late Event. + /** + * Returns the Timestamp of the Action Late Event. + */ + PropertyI64 eventActionLateTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Action Late Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Action Late Event. + */ + PropertyI64 eventActionLateFrameID; + /// \brief An integer property. Returns the unique Identifier of the Primary Application Switch type of Event. + /** + * Returns the unique Identifier of the Primary Application Switch type of Event. + */ + PropertyI64 eventPrimaryApplicationSwitch; + /// \brief An integer property. Returns the Timestamp of the Primary Application Switch Event. + /** + * Returns the Timestamp of the Primary Application Switch Event. + */ + PropertyI64 eventPrimaryApplicationSwitchTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Primary Application Switch Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Primary Application Switch Event. + */ + PropertyI64 eventPrimaryApplicationSwitchFrameID; + /// \brief An integer property. Returns the unique identifier of the Event Test type of event generated using the TestEventGenerate command. + /** + * Returns the unique identifier of the Event Test type of event generated using the TestEventGenerate command. It can be used to register a callback function to be notified of the EventTest event occurrence. Its value uniquely identifies that the event received was an Event Test. + */ + PropertyI64 eventTest; + /// \brief An integer property. Returns the Timestamp of the Event Test event. + /** + * Returns the Timestamp of the Event Test event. It can be used to determine when the event occurred. + */ + PropertyI64 eventTestTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Counter 0 Start type of Event. + /** + * Returns the unique Identifier of the Counter 0 Start type of Event. + */ + PropertyI64 eventCounter0Start; + /// \brief An integer property. Returns the Timestamp of the Counter 0 Start Event. + /** + * Returns the Timestamp of the Counter 0 Start Event. + */ + PropertyI64 eventCounter0StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 0 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 0 Start Event. + */ + PropertyI64 eventCounter0StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 1 Start type of Event. + /** + * Returns the unique Identifier of the Counter 1 Start type of Event. + */ + PropertyI64 eventCounter1Start; + /// \brief An integer property. Returns the Timestamp of the Counter 1 Start Event. + /** + * Returns the Timestamp of the Counter 1 Start Event. + */ + PropertyI64 eventCounter1StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 1 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 1 Start Event. + */ + PropertyI64 eventCounter1StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 2 Start type of Event. + /** + * Returns the unique Identifier of the Counter 2 Start type of Event. + */ + PropertyI64 eventCounter2Start; + /// \brief An integer property. Returns the Timestamp of the Counter 2 Start Event. + /** + * Returns the Timestamp of the Counter 2 Start Event. + */ + PropertyI64 eventCounter2StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 2 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 2 Start Event. + */ + PropertyI64 eventCounter2StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 3 Start type of Event. + /** + * Returns the unique Identifier of the Counter 3 Start type of Event. + */ + PropertyI64 eventCounter3Start; + /// \brief An integer property. Returns the Timestamp of the Counter 3 Start Event. + /** + * Returns the Timestamp of the Counter 3 Start Event. + */ + PropertyI64 eventCounter3StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 3 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 3 Start Event. + */ + PropertyI64 eventCounter3StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 4 Start type of Event. + /** + * Returns the unique Identifier of the Counter 4 Start type of Event. + */ + PropertyI64 eventCounter4Start; + /// \brief An integer property. Returns the Timestamp of the Counter 4 Start Event. + /** + * Returns the Timestamp of the Counter 4 Start Event. + */ + PropertyI64 eventCounter4StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 4 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 4 Start Event. + */ + PropertyI64 eventCounter4StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 5 Start type of Event. + /** + * Returns the unique Identifier of the Counter 5 Start type of Event. + */ + PropertyI64 eventCounter5Start; + /// \brief An integer property. Returns the Timestamp of the Counter 5 Start Event. + /** + * Returns the Timestamp of the Counter 5 Start Event. + */ + PropertyI64 eventCounter5StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 5 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 5 Start Event. + */ + PropertyI64 eventCounter5StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 6 Start type of Event. + /** + * Returns the unique Identifier of the Counter 6 Start type of Event. + */ + PropertyI64 eventCounter6Start; + /// \brief An integer property. Returns the Timestamp of the Counter 6 Start Event. + /** + * Returns the Timestamp of the Counter 6 Start Event. + */ + PropertyI64 eventCounter6StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 6 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 6 Start Event. + */ + PropertyI64 eventCounter6StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 7 Start type of Event. + /** + * Returns the unique Identifier of the Counter 7 Start type of Event. + */ + PropertyI64 eventCounter7Start; + /// \brief An integer property. Returns the Timestamp of the Counter 7 Start Event. + /** + * Returns the Timestamp of the Counter 7 Start Event. + */ + PropertyI64 eventCounter7StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 7 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 7 Start Event. + */ + PropertyI64 eventCounter7StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 8 Start type of Event. + /** + * Returns the unique Identifier of the Counter 8 Start type of Event. + */ + PropertyI64 eventCounter8Start; + /// \brief An integer property. Returns the Timestamp of the Counter 8 Start Event. + /** + * Returns the Timestamp of the Counter 8 Start Event. + */ + PropertyI64 eventCounter8StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 8 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 8 Start Event. + */ + PropertyI64 eventCounter8StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 9 Start type of Event. + /** + * Returns the unique Identifier of the Counter 9 Start type of Event. + */ + PropertyI64 eventCounter9Start; + /// \brief An integer property. Returns the Timestamp of the Counter 9 Start Event. + /** + * Returns the Timestamp of the Counter 9 Start Event. + */ + PropertyI64 eventCounter9StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 9 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 9 Start Event. + */ + PropertyI64 eventCounter9StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 10 Start type of Event. + /** + * Returns the unique Identifier of the Counter 10 Start type of Event. + */ + PropertyI64 eventCounter10Start; + /// \brief An integer property. Returns the Timestamp of the Counter 10 Start Event. + /** + * Returns the Timestamp of the Counter 10 Start Event. + */ + PropertyI64 eventCounter10StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 10 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 10 Start Event. + */ + PropertyI64 eventCounter10StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 11 Start type of Event. + /** + * Returns the unique Identifier of the Counter 11 Start type of Event. + */ + PropertyI64 eventCounter11Start; + /// \brief An integer property. Returns the Timestamp of the Counter 11 Start Event. + /** + * Returns the Timestamp of the Counter 11 Start Event. + */ + PropertyI64 eventCounter11StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 11 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 11 Start Event. + */ + PropertyI64 eventCounter11StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 12 Start type of Event. + /** + * Returns the unique Identifier of the Counter 12 Start type of Event. + */ + PropertyI64 eventCounter12Start; + /// \brief An integer property. Returns the Timestamp of the Counter 12 Start Event. + /** + * Returns the Timestamp of the Counter 12 Start Event. + */ + PropertyI64 eventCounter12StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 12 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 12 Start Event. + */ + PropertyI64 eventCounter12StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 13 Start type of Event. + /** + * Returns the unique Identifier of the Counter 13 Start type of Event. + */ + PropertyI64 eventCounter13Start; + /// \brief An integer property. Returns the Timestamp of the Counter 13 Start Event. + /** + * Returns the Timestamp of the Counter 13 Start Event. + */ + PropertyI64 eventCounter13StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 13 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 13 Start Event. + */ + PropertyI64 eventCounter13StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 14 Start type of Event. + /** + * Returns the unique Identifier of the Counter 14 Start type of Event. + */ + PropertyI64 eventCounter14Start; + /// \brief An integer property. Returns the Timestamp of the Counter 14 Start Event. + /** + * Returns the Timestamp of the Counter 14 Start Event. + */ + PropertyI64 eventCounter14StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 14 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 14 Start Event. + */ + PropertyI64 eventCounter14StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 0 End type of Event. + /** + * Returns the unique Identifier of the Counter 0 End type of Event. + */ + PropertyI64 eventCounter0End; + /// \brief An integer property. Returns the Timestamp of the Counter 0 End Event. + /** + * Returns the Timestamp of the Counter 0 End Event. + */ + PropertyI64 eventCounter0EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 0 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 0 End Event. + */ + PropertyI64 eventCounter0EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 1 End type of Event. + /** + * Returns the unique Identifier of the Counter 1 End type of Event. + */ + PropertyI64 eventCounter1End; + /// \brief An integer property. Returns the Timestamp of the Counter 1 End Event. + /** + * Returns the Timestamp of the Counter 1 End Event. + */ + PropertyI64 eventCounter1EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 1 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 1 End Event. + */ + PropertyI64 eventCounter1EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 2 End type of Event. + /** + * Returns the unique Identifier of the Counter 2 End type of Event. + */ + PropertyI64 eventCounter2End; + /// \brief An integer property. Returns the Timestamp of the Counter 2 End Event. + /** + * Returns the Timestamp of the Counter 2 End Event. + */ + PropertyI64 eventCounter2EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 2 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 2 End Event. + */ + PropertyI64 eventCounter2EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 3 End type of Event. + /** + * Returns the unique Identifier of the Counter 3 End type of Event. + */ + PropertyI64 eventCounter3End; + /// \brief An integer property. Returns the Timestamp of the Counter 3 End Event. + /** + * Returns the Timestamp of the Counter 3 End Event. + */ + PropertyI64 eventCounter3EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 3 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 3 End Event. + */ + PropertyI64 eventCounter3EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 4 End type of Event. + /** + * Returns the unique Identifier of the Counter 4 End type of Event. + */ + PropertyI64 eventCounter4End; + /// \brief An integer property. Returns the Timestamp of the Counter 4 End Event. + /** + * Returns the Timestamp of the Counter 4 End Event. + */ + PropertyI64 eventCounter4EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 4 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 4 End Event. + */ + PropertyI64 eventCounter4EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 5 End type of Event. + /** + * Returns the unique Identifier of the Counter 5 End type of Event. + */ + PropertyI64 eventCounter5End; + /// \brief An integer property. Returns the Timestamp of the Counter 5 End Event. + /** + * Returns the Timestamp of the Counter 5 End Event. + */ + PropertyI64 eventCounter5EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 5 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 5 End Event. + */ + PropertyI64 eventCounter5EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 6 End type of Event. + /** + * Returns the unique Identifier of the Counter 6 End type of Event. + */ + PropertyI64 eventCounter6End; + /// \brief An integer property. Returns the Timestamp of the Counter 6 End Event. + /** + * Returns the Timestamp of the Counter 6 End Event. + */ + PropertyI64 eventCounter6EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 6 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 6 End Event. + */ + PropertyI64 eventCounter6EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 7 End type of Event. + /** + * Returns the unique Identifier of the Counter 7 End type of Event. + */ + PropertyI64 eventCounter7End; + /// \brief An integer property. Returns the Timestamp of the Counter 7 End Event. + /** + * Returns the Timestamp of the Counter 7 End Event. + */ + PropertyI64 eventCounter7EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 7 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 7 End Event. + */ + PropertyI64 eventCounter7EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 8 End type of Event. + /** + * Returns the unique Identifier of the Counter 8 End type of Event. + */ + PropertyI64 eventCounter8End; + /// \brief An integer property. Returns the Timestamp of the Counter 8 End Event. + /** + * Returns the Timestamp of the Counter 8 End Event. + */ + PropertyI64 eventCounter8EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 8 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 8 End Event. + */ + PropertyI64 eventCounter8EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 9 End type of Event. + /** + * Returns the unique Identifier of the Counter 9 End type of Event. + */ + PropertyI64 eventCounter9End; + /// \brief An integer property. Returns the Timestamp of the Counter 9 End Event. + /** + * Returns the Timestamp of the Counter 9 End Event. + */ + PropertyI64 eventCounter9EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 9 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 9 End Event. + */ + PropertyI64 eventCounter9EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 10 End type of Event. + /** + * Returns the unique Identifier of the Counter 10 End type of Event. + */ + PropertyI64 eventCounter10End; + /// \brief An integer property. Returns the Timestamp of the Counter 10 End Event. + /** + * Returns the Timestamp of the Counter 10 End Event. + */ + PropertyI64 eventCounter10EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 10 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 10 End Event. + */ + PropertyI64 eventCounter10EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 11 End type of Event. + /** + * Returns the unique Identifier of the Counter 11 End type of Event. + */ + PropertyI64 eventCounter11End; + /// \brief An integer property. Returns the Timestamp of the Counter 11 End Event. + /** + * Returns the Timestamp of the Counter 11 End Event. + */ + PropertyI64 eventCounter11EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 11 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 11 End Event. + */ + PropertyI64 eventCounter11EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 12 End type of Event. + /** + * Returns the unique Identifier of the Counter 12 End type of Event. + */ + PropertyI64 eventCounter12End; + /// \brief An integer property. Returns the Timestamp of the Counter 12 End Event. + /** + * Returns the Timestamp of the Counter 12 End Event. + */ + PropertyI64 eventCounter12EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 12 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 12 End Event. + */ + PropertyI64 eventCounter12EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 13 End type of Event. + /** + * Returns the unique Identifier of the Counter 13 End type of Event. + */ + PropertyI64 eventCounter13End; + /// \brief An integer property. Returns the Timestamp of the Counter 13 End Event. + /** + * Returns the Timestamp of the Counter 13 End Event. + */ + PropertyI64 eventCounter13EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 13 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 13 End Event. + */ + PropertyI64 eventCounter13EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Counter 14 End type of Event. + /** + * Returns the unique Identifier of the Counter 14 End type of Event. + */ + PropertyI64 eventCounter14End; + /// \brief An integer property. Returns the Timestamp of the Counter 14 End Event. + /** + * Returns the Timestamp of the Counter 14 End Event. + */ + PropertyI64 eventCounter14EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Counter 14 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Counter 14 End Event. + */ + PropertyI64 eventCounter14EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 0 Start type of Event. + /** + * Returns the unique Identifier of the Timer 0 Start type of Event. + */ + PropertyI64 eventTimer0Start; + /// \brief An integer property. Returns the Timestamp of the Timer 0 Start Event. + /** + * Returns the Timestamp of the Timer 0 Start Event. + */ + PropertyI64 eventTimer0StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 0 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 0 Start Event. + */ + PropertyI64 eventTimer0StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 1 Start type of Event. + /** + * Returns the unique Identifier of the Timer 1 Start type of Event. + */ + PropertyI64 eventTimer1Start; + /// \brief An integer property. Returns the Timestamp of the Timer 1 Start Event. + /** + * Returns the Timestamp of the Timer 1 Start Event. + */ + PropertyI64 eventTimer1StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 1 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 1 Start Event. + */ + PropertyI64 eventTimer1StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 2 Start type of Event. + /** + * Returns the unique Identifier of the Timer 2 Start type of Event. + */ + PropertyI64 eventTimer2Start; + /// \brief An integer property. Returns the Timestamp of the Timer 2 Start Event. + /** + * Returns the Timestamp of the Timer 2 Start Event. + */ + PropertyI64 eventTimer2StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 2 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 2 Start Event. + */ + PropertyI64 eventTimer2StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 3 Start type of Event. + /** + * Returns the unique Identifier of the Timer 3 Start type of Event. + */ + PropertyI64 eventTimer3Start; + /// \brief An integer property. Returns the Timestamp of the Timer 3 Start Event. + /** + * Returns the Timestamp of the Timer 3 Start Event. + */ + PropertyI64 eventTimer3StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 3 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 3 Start Event. + */ + PropertyI64 eventTimer3StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 4 Start type of Event. + /** + * Returns the unique Identifier of the Timer 4 Start type of Event. + */ + PropertyI64 eventTimer4Start; + /// \brief An integer property. Returns the Timestamp of the Timer 4 Start Event. + /** + * Returns the Timestamp of the Timer 4 Start Event. + */ + PropertyI64 eventTimer4StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 4 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 4 Start Event. + */ + PropertyI64 eventTimer4StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 5 Start type of Event. + /** + * Returns the unique Identifier of the Timer 5 Start type of Event. + */ + PropertyI64 eventTimer5Start; + /// \brief An integer property. Returns the Timestamp of the Timer 5 Start Event. + /** + * Returns the Timestamp of the Timer 5 Start Event. + */ + PropertyI64 eventTimer5StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 5 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 5 Start Event. + */ + PropertyI64 eventTimer5StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 6 Start type of Event. + /** + * Returns the unique Identifier of the Timer 6 Start type of Event. + */ + PropertyI64 eventTimer6Start; + /// \brief An integer property. Returns the Timestamp of the Timer 6 Start Event. + /** + * Returns the Timestamp of the Timer 6 Start Event. + */ + PropertyI64 eventTimer6StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 6 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 6 Start Event. + */ + PropertyI64 eventTimer6StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 7 Start type of Event. + /** + * Returns the unique Identifier of the Timer 7 Start type of Event. + */ + PropertyI64 eventTimer7Start; + /// \brief An integer property. Returns the Timestamp of the Timer 7 Start Event. + /** + * Returns the Timestamp of the Timer 7 Start Event. + */ + PropertyI64 eventTimer7StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 7 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 7 Start Event. + */ + PropertyI64 eventTimer7StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 8 Start type of Event. + /** + * Returns the unique Identifier of the Timer 8 Start type of Event. + */ + PropertyI64 eventTimer8Start; + /// \brief An integer property. Returns the Timestamp of the Timer 8 Start Event. + /** + * Returns the Timestamp of the Timer 8 Start Event. + */ + PropertyI64 eventTimer8StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 8 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 8 Start Event. + */ + PropertyI64 eventTimer8StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 9 Start type of Event. + /** + * Returns the unique Identifier of the Timer 9 Start type of Event. + */ + PropertyI64 eventTimer9Start; + /// \brief An integer property. Returns the Timestamp of the Timer 9 Start Event. + /** + * Returns the Timestamp of the Timer 9 Start Event. + */ + PropertyI64 eventTimer9StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 9 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 9 Start Event. + */ + PropertyI64 eventTimer9StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 10 Start type of Event. + /** + * Returns the unique Identifier of the Timer 10 Start type of Event. + */ + PropertyI64 eventTimer10Start; + /// \brief An integer property. Returns the Timestamp of the Timer 10 Start Event. + /** + * Returns the Timestamp of the Timer 10 Start Event. + */ + PropertyI64 eventTimer10StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 10 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 10 Start Event. + */ + PropertyI64 eventTimer10StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 11 Start type of Event. + /** + * Returns the unique Identifier of the Timer 11 Start type of Event. + */ + PropertyI64 eventTimer11Start; + /// \brief An integer property. Returns the Timestamp of the Timer 11 Start Event. + /** + * Returns the Timestamp of the Timer 11 Start Event. + */ + PropertyI64 eventTimer11StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 11 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 11 Start Event. + */ + PropertyI64 eventTimer11StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 12 Start type of Event. + /** + * Returns the unique Identifier of the Timer 12 Start type of Event. + */ + PropertyI64 eventTimer12Start; + /// \brief An integer property. Returns the Timestamp of the Timer 12 Start Event. + /** + * Returns the Timestamp of the Timer 12 Start Event. + */ + PropertyI64 eventTimer12StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 12 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 12 Start Event. + */ + PropertyI64 eventTimer12StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 13 Start type of Event. + /** + * Returns the unique Identifier of the Timer 13 Start type of Event. + */ + PropertyI64 eventTimer13Start; + /// \brief An integer property. Returns the Timestamp of the Timer 13 Start Event. + /** + * Returns the Timestamp of the Timer 13 Start Event. + */ + PropertyI64 eventTimer13StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 13 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 13 Start Event. + */ + PropertyI64 eventTimer13StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 14 Start type of Event. + /** + * Returns the unique Identifier of the Timer 14 Start type of Event. + */ + PropertyI64 eventTimer14Start; + /// \brief An integer property. Returns the Timestamp of the Timer 14 Start Event. + /** + * Returns the Timestamp of the Timer 14 Start Event. + */ + PropertyI64 eventTimer14StartTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 14 Start Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 14 Start Event. + */ + PropertyI64 eventTimer14StartFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 0 End type of Event. + /** + * Returns the unique Identifier of the Timer 0 End type of Event. + */ + PropertyI64 eventTimer0End; + /// \brief An integer property. Returns the Timestamp of the Timer 0 End Event. + /** + * Returns the Timestamp of the Timer 0 End Event. + */ + PropertyI64 eventTimer0EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 0 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 0 End Event. + */ + PropertyI64 eventTimer0EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 1 End type of Event. + /** + * Returns the unique Identifier of the Timer 1 End type of Event. + */ + PropertyI64 eventTimer1End; + /// \brief An integer property. Returns the Timestamp of the Timer 1 End Event. + /** + * Returns the Timestamp of the Timer 1 End Event. + */ + PropertyI64 eventTimer1EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 1 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 1 End Event. + */ + PropertyI64 eventTimer1EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 2 End type of Event. + /** + * Returns the unique Identifier of the Timer 2 End type of Event. + */ + PropertyI64 eventTimer2End; + /// \brief An integer property. Returns the Timestamp of the Timer 2 End Event. + /** + * Returns the Timestamp of the Timer 2 End Event. + */ + PropertyI64 eventTimer2EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 2 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 2 End Event. + */ + PropertyI64 eventTimer2EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 3 End type of Event. + /** + * Returns the unique Identifier of the Timer 3 End type of Event. + */ + PropertyI64 eventTimer3End; + /// \brief An integer property. Returns the Timestamp of the Timer 3 End Event. + /** + * Returns the Timestamp of the Timer 3 End Event. + */ + PropertyI64 eventTimer3EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 3 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 3 End Event. + */ + PropertyI64 eventTimer3EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 4 End type of Event. + /** + * Returns the unique Identifier of the Timer 4 End type of Event. + */ + PropertyI64 eventTimer4End; + /// \brief An integer property. Returns the Timestamp of the Timer 4 End Event. + /** + * Returns the Timestamp of the Timer 4 End Event. + */ + PropertyI64 eventTimer4EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 4 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 4 End Event. + */ + PropertyI64 eventTimer4EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 5 End type of Event. + /** + * Returns the unique Identifier of the Timer 5 End type of Event. + */ + PropertyI64 eventTimer5End; + /// \brief An integer property. Returns the Timestamp of the Timer 5 End Event. + /** + * Returns the Timestamp of the Timer 5 End Event. + */ + PropertyI64 eventTimer5EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 5 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 5 End Event. + */ + PropertyI64 eventTimer5EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 6 End type of Event. + /** + * Returns the unique Identifier of the Timer 6 End type of Event. + */ + PropertyI64 eventTimer6End; + /// \brief An integer property. Returns the Timestamp of the Timer 6 End Event. + /** + * Returns the Timestamp of the Timer 6 End Event. + */ + PropertyI64 eventTimer6EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 6 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 6 End Event. + */ + PropertyI64 eventTimer6EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 7 End type of Event. + /** + * Returns the unique Identifier of the Timer 7 End type of Event. + */ + PropertyI64 eventTimer7End; + /// \brief An integer property. Returns the Timestamp of the Timer 7 End Event. + /** + * Returns the Timestamp of the Timer 7 End Event. + */ + PropertyI64 eventTimer7EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 7 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 7 End Event. + */ + PropertyI64 eventTimer7EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 8 End type of Event. + /** + * Returns the unique Identifier of the Timer 8 End type of Event. + */ + PropertyI64 eventTimer8End; + /// \brief An integer property. Returns the Timestamp of the Timer 8 End Event. + /** + * Returns the Timestamp of the Timer 8 End Event. + */ + PropertyI64 eventTimer8EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 8 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 8 End Event. + */ + PropertyI64 eventTimer8EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 9 End type of Event. + /** + * Returns the unique Identifier of the Timer 9 End type of Event. + */ + PropertyI64 eventTimer9End; + /// \brief An integer property. Returns the Timestamp of the Timer 9 End Event. + /** + * Returns the Timestamp of the Timer 9 End Event. + */ + PropertyI64 eventTimer9EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 9 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 9 End Event. + */ + PropertyI64 eventTimer9EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 10 End type of Event. + /** + * Returns the unique Identifier of the Timer 10 End type of Event. + */ + PropertyI64 eventTimer10End; + /// \brief An integer property. Returns the Timestamp of the Timer 10 End Event. + /** + * Returns the Timestamp of the Timer 10 End Event. + */ + PropertyI64 eventTimer10EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 10 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 10 End Event. + */ + PropertyI64 eventTimer10EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 11 End type of Event. + /** + * Returns the unique Identifier of the Timer 11 End type of Event. + */ + PropertyI64 eventTimer11End; + /// \brief An integer property. Returns the Timestamp of the Timer 11 End Event. + /** + * Returns the Timestamp of the Timer 11 End Event. + */ + PropertyI64 eventTimer11EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 11 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 11 End Event. + */ + PropertyI64 eventTimer11EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 12 End type of Event. + /** + * Returns the unique Identifier of the Timer 12 End type of Event. + */ + PropertyI64 eventTimer12End; + /// \brief An integer property. Returns the Timestamp of the Timer 12 End Event. + /** + * Returns the Timestamp of the Timer 12 End Event. + */ + PropertyI64 eventTimer12EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 12 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 12 End Event. + */ + PropertyI64 eventTimer12EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 13 End type of Event. + /** + * Returns the unique Identifier of the Timer 13 End type of Event. + */ + PropertyI64 eventTimer13End; + /// \brief An integer property. Returns the Timestamp of the Timer 13 End Event. + /** + * Returns the Timestamp of the Timer 13 End Event. + */ + PropertyI64 eventTimer13EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 13 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 13 End Event. + */ + PropertyI64 eventTimer13EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Timer 14 End type of Event. + /** + * Returns the unique Identifier of the Timer 14 End type of Event. + */ + PropertyI64 eventTimer14End; + /// \brief An integer property. Returns the Timestamp of the Timer 14 End Event. + /** + * Returns the Timestamp of the Timer 14 End Event. + */ + PropertyI64 eventTimer14EndTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Timer 14 End Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Timer 14 End Event. + */ + PropertyI64 eventTimer14EndFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 0 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 0 Stopped type of Event. + */ + PropertyI64 eventEncoder0Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 0 Stopped Event. + /** + * Returns the Timestamp of the Encoder 0 Stopped Event. + */ + PropertyI64 eventEncoder0StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 0 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 0 Stopped Event. + */ + PropertyI64 eventEncoder0StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 1 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 1 Stopped type of Event. + */ + PropertyI64 eventEncoder1Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 1 Stopped Event. + /** + * Returns the Timestamp of the Encoder 1 Stopped Event. + */ + PropertyI64 eventEncoder1StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 1 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 1 Stopped Event. + */ + PropertyI64 eventEncoder1StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 2 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 2 Stopped type of Event. + */ + PropertyI64 eventEncoder2Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 2 Stopped Event. + /** + * Returns the Timestamp of the Encoder 2 Stopped Event. + */ + PropertyI64 eventEncoder2StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 2 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 2 Stopped Event. + */ + PropertyI64 eventEncoder2StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 3 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 3 Stopped type of Event. + */ + PropertyI64 eventEncoder3Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 3 Stopped Event. + /** + * Returns the Timestamp of the Encoder 3 Stopped Event. + */ + PropertyI64 eventEncoder3StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 3 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 3 Stopped Event. + */ + PropertyI64 eventEncoder3StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 4 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 4 Stopped type of Event. + */ + PropertyI64 eventEncoder4Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 4 Stopped Event. + /** + * Returns the Timestamp of the Encoder 4 Stopped Event. + */ + PropertyI64 eventEncoder4StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 4 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 4 Stopped Event. + */ + PropertyI64 eventEncoder4StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 5 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 5 Stopped type of Event. + */ + PropertyI64 eventEncoder5Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 5 Stopped Event. + /** + * Returns the Timestamp of the Encoder 5 Stopped Event. + */ + PropertyI64 eventEncoder5StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 5 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 5 Stopped Event. + */ + PropertyI64 eventEncoder5StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 6 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 6 Stopped type of Event. + */ + PropertyI64 eventEncoder6Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 6 Stopped Event. + /** + * Returns the Timestamp of the Encoder 6 Stopped Event. + */ + PropertyI64 eventEncoder6StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 6 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 6 Stopped Event. + */ + PropertyI64 eventEncoder6StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 7 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 7 Stopped type of Event. + */ + PropertyI64 eventEncoder7Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 7 Stopped Event. + /** + * Returns the Timestamp of the Encoder 7 Stopped Event. + */ + PropertyI64 eventEncoder7StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 7 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 7 Stopped Event. + */ + PropertyI64 eventEncoder7StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 8 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 8 Stopped type of Event. + */ + PropertyI64 eventEncoder8Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 8 Stopped Event. + /** + * Returns the Timestamp of the Encoder 8 Stopped Event. + */ + PropertyI64 eventEncoder8StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 8 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 8 Stopped Event. + */ + PropertyI64 eventEncoder8StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 9 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 9 Stopped type of Event. + */ + PropertyI64 eventEncoder9Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 9 Stopped Event. + /** + * Returns the Timestamp of the Encoder 9 Stopped Event. + */ + PropertyI64 eventEncoder9StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 9 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 9 Stopped Event. + */ + PropertyI64 eventEncoder9StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 10 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 10 Stopped type of Event. + */ + PropertyI64 eventEncoder10Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 10 Stopped Event. + /** + * Returns the Timestamp of the Encoder 10 Stopped Event. + */ + PropertyI64 eventEncoder10StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 10 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 10 Stopped Event. + */ + PropertyI64 eventEncoder10StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 11 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 11 Stopped type of Event. + */ + PropertyI64 eventEncoder11Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 11 Stopped Event. + /** + * Returns the Timestamp of the Encoder 11 Stopped Event. + */ + PropertyI64 eventEncoder11StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 11 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 11 Stopped Event. + */ + PropertyI64 eventEncoder11StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 12 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 12 Stopped type of Event. + */ + PropertyI64 eventEncoder12Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 12 Stopped Event. + /** + * Returns the Timestamp of the Encoder 12 Stopped Event. + */ + PropertyI64 eventEncoder12StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 12 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 12 Stopped Event. + */ + PropertyI64 eventEncoder12StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 13 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 13 Stopped type of Event. + */ + PropertyI64 eventEncoder13Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 13 Stopped Event. + /** + * Returns the Timestamp of the Encoder 13 Stopped Event. + */ + PropertyI64 eventEncoder13StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 13 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 13 Stopped Event. + */ + PropertyI64 eventEncoder13StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 14 Stopped type of Event. + /** + * Returns the unique Identifier of the Encoder 14 Stopped type of Event. + */ + PropertyI64 eventEncoder14Stopped; + /// \brief An integer property. Returns the Timestamp of the Encoder 14 Stopped Event. + /** + * Returns the Timestamp of the Encoder 14 Stopped Event. + */ + PropertyI64 eventEncoder14StoppedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 14 Stopped Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 14 Stopped Event. + */ + PropertyI64 eventEncoder14StoppedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 0 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 0 Restarted type of Event. + */ + PropertyI64 eventEncoder0Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 0 Restarted Event. + /** + * Returns the Timestamp of the Encoder 0 Restarted Event. + */ + PropertyI64 eventEncoder0RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 0 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 0 Restarted Event. + */ + PropertyI64 eventEncoder0RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 1 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 1 Restarted type of Event. + */ + PropertyI64 eventEncoder1Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 1 Restarted Event. + /** + * Returns the Timestamp of the Encoder 1 Restarted Event. + */ + PropertyI64 eventEncoder1RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 1 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 1 Restarted Event. + */ + PropertyI64 eventEncoder1RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 2 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 2 Restarted type of Event. + */ + PropertyI64 eventEncoder2Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 2 Restarted Event. + /** + * Returns the Timestamp of the Encoder 2 Restarted Event. + */ + PropertyI64 eventEncoder2RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 2 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 2 Restarted Event. + */ + PropertyI64 eventEncoder2RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 3 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 3 Restarted type of Event. + */ + PropertyI64 eventEncoder3Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 3 Restarted Event. + /** + * Returns the Timestamp of the Encoder 3 Restarted Event. + */ + PropertyI64 eventEncoder3RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 3 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 3 Restarted Event. + */ + PropertyI64 eventEncoder3RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 4 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 4 Restarted type of Event. + */ + PropertyI64 eventEncoder4Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 4 Restarted Event. + /** + * Returns the Timestamp of the Encoder 4 Restarted Event. + */ + PropertyI64 eventEncoder4RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 4 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 4 Restarted Event. + */ + PropertyI64 eventEncoder4RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 5 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 5 Restarted type of Event. + */ + PropertyI64 eventEncoder5Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 5 Restarted Event. + /** + * Returns the Timestamp of the Encoder 5 Restarted Event. + */ + PropertyI64 eventEncoder5RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 5 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 5 Restarted Event. + */ + PropertyI64 eventEncoder5RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 6 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 6 Restarted type of Event. + */ + PropertyI64 eventEncoder6Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 6 Restarted Event. + /** + * Returns the Timestamp of the Encoder 6 Restarted Event. + */ + PropertyI64 eventEncoder6RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 6 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 6 Restarted Event. + */ + PropertyI64 eventEncoder6RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 7 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 7 Restarted type of Event. + */ + PropertyI64 eventEncoder7Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 7 Restarted Event. + /** + * Returns the Timestamp of the Encoder 7 Restarted Event. + */ + PropertyI64 eventEncoder7RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 7 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 7 Restarted Event. + */ + PropertyI64 eventEncoder7RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 8 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 8 Restarted type of Event. + */ + PropertyI64 eventEncoder8Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 8 Restarted Event. + /** + * Returns the Timestamp of the Encoder 8 Restarted Event. + */ + PropertyI64 eventEncoder8RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 8 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 8 Restarted Event. + */ + PropertyI64 eventEncoder8RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 9 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 9 Restarted type of Event. + */ + PropertyI64 eventEncoder9Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 9 Restarted Event. + /** + * Returns the Timestamp of the Encoder 9 Restarted Event. + */ + PropertyI64 eventEncoder9RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 9 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 9 Restarted Event. + */ + PropertyI64 eventEncoder9RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 10 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 10 Restarted type of Event. + */ + PropertyI64 eventEncoder10Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 10 Restarted Event. + /** + * Returns the Timestamp of the Encoder 10 Restarted Event. + */ + PropertyI64 eventEncoder10RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 10 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 10 Restarted Event. + */ + PropertyI64 eventEncoder10RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 11 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 11 Restarted type of Event. + */ + PropertyI64 eventEncoder11Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 11 Restarted Event. + /** + * Returns the Timestamp of the Encoder 11 Restarted Event. + */ + PropertyI64 eventEncoder11RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 11 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 11 Restarted Event. + */ + PropertyI64 eventEncoder11RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 12 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 12 Restarted type of Event. + */ + PropertyI64 eventEncoder12Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 12 Restarted Event. + /** + * Returns the Timestamp of the Encoder 12 Restarted Event. + */ + PropertyI64 eventEncoder12RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 12 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 12 Restarted Event. + */ + PropertyI64 eventEncoder12RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 13 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 13 Restarted type of Event. + */ + PropertyI64 eventEncoder13Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 13 Restarted Event. + /** + * Returns the Timestamp of the Encoder 13 Restarted Event. + */ + PropertyI64 eventEncoder13RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 13 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 13 Restarted Event. + */ + PropertyI64 eventEncoder13RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Encoder 14 Restarted type of Event. + /** + * Returns the unique Identifier of the Encoder 14 Restarted type of Event. + */ + PropertyI64 eventEncoder14Restarted; + /// \brief An integer property. Returns the Timestamp of the Encoder 14 Restarted Event. + /** + * Returns the Timestamp of the Encoder 14 Restarted Event. + */ + PropertyI64 eventEncoder14RestartedTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Encoder 14 Restarted Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Encoder 14 Restarted Event. + */ + PropertyI64 eventEncoder14RestartedFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 0 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 0 Rising Edge type of Event. + */ + PropertyI64 eventLine0RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 0 Rising Edge Event. + /** + * Returns the Timestamp of the Line 0 Rising Edge Event. + */ + PropertyI64 eventLine0RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 0 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 0 Rising Edge Event. + */ + PropertyI64 eventLine0RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 1 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 1 Rising Edge type of Event. + */ + PropertyI64 eventLine1RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 1 Rising Edge Event. + /** + * Returns the Timestamp of the Line 1 Rising Edge Event. + */ + PropertyI64 eventLine1RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 1 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 1 Rising Edge Event. + */ + PropertyI64 eventLine1RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 2 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 2 Rising Edge type of Event. + */ + PropertyI64 eventLine2RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 2 Rising Edge Event. + /** + * Returns the Timestamp of the Line 2 Rising Edge Event. + */ + PropertyI64 eventLine2RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 2 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 2 Rising Edge Event. + */ + PropertyI64 eventLine2RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 3 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 3 Rising Edge type of Event. + */ + PropertyI64 eventLine3RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 3 Rising Edge Event. + /** + * Returns the Timestamp of the Line 3 Rising Edge Event. + */ + PropertyI64 eventLine3RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 3 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 3 Rising Edge Event. + */ + PropertyI64 eventLine3RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 4 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 4 Rising Edge type of Event. + */ + PropertyI64 eventLine4RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 4 Rising Edge Event. + /** + * Returns the Timestamp of the Line 4 Rising Edge Event. + */ + PropertyI64 eventLine4RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 4 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 4 Rising Edge Event. + */ + PropertyI64 eventLine4RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 5 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 5 Rising Edge type of Event. + */ + PropertyI64 eventLine5RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 5 Rising Edge Event. + /** + * Returns the Timestamp of the Line 5 Rising Edge Event. + */ + PropertyI64 eventLine5RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 5 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 5 Rising Edge Event. + */ + PropertyI64 eventLine5RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 6 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 6 Rising Edge type of Event. + */ + PropertyI64 eventLine6RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 6 Rising Edge Event. + /** + * Returns the Timestamp of the Line 6 Rising Edge Event. + */ + PropertyI64 eventLine6RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 6 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 6 Rising Edge Event. + */ + PropertyI64 eventLine6RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 7 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 7 Rising Edge type of Event. + */ + PropertyI64 eventLine7RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 7 Rising Edge Event. + /** + * Returns the Timestamp of the Line 7 Rising Edge Event. + */ + PropertyI64 eventLine7RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 7 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 7 Rising Edge Event. + */ + PropertyI64 eventLine7RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 8 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 8 Rising Edge type of Event. + */ + PropertyI64 eventLine8RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 8 Rising Edge Event. + /** + * Returns the Timestamp of the Line 8 Rising Edge Event. + */ + PropertyI64 eventLine8RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 8 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 8 Rising Edge Event. + */ + PropertyI64 eventLine8RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 9 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 9 Rising Edge type of Event. + */ + PropertyI64 eventLine9RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 9 Rising Edge Event. + /** + * Returns the Timestamp of the Line 9 Rising Edge Event. + */ + PropertyI64 eventLine9RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 9 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 9 Rising Edge Event. + */ + PropertyI64 eventLine9RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 10 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 10 Rising Edge type of Event. + */ + PropertyI64 eventLine10RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 10 Rising Edge Event. + /** + * Returns the Timestamp of the Line 10 Rising Edge Event. + */ + PropertyI64 eventLine10RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 10 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 10 Rising Edge Event. + */ + PropertyI64 eventLine10RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 11 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 11 Rising Edge type of Event. + */ + PropertyI64 eventLine11RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 11 Rising Edge Event. + /** + * Returns the Timestamp of the Line 11 Rising Edge Event. + */ + PropertyI64 eventLine11RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 11 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 11 Rising Edge Event. + */ + PropertyI64 eventLine11RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 12 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 12 Rising Edge type of Event. + */ + PropertyI64 eventLine12RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 12 Rising Edge Event. + /** + * Returns the Timestamp of the Line 12 Rising Edge Event. + */ + PropertyI64 eventLine12RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 12 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 12 Rising Edge Event. + */ + PropertyI64 eventLine12RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 13 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 13 Rising Edge type of Event. + */ + PropertyI64 eventLine13RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 13 Rising Edge Event. + /** + * Returns the Timestamp of the Line 13 Rising Edge Event. + */ + PropertyI64 eventLine13RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 13 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 13 Rising Edge Event. + */ + PropertyI64 eventLine13RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 14 Rising Edge type of Event. + /** + * Returns the unique Identifier of the Line 14 Rising Edge type of Event. + */ + PropertyI64 eventLine14RisingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 14 Rising Edge Event. + /** + * Returns the Timestamp of the Line 14 Rising Edge Event. + */ + PropertyI64 eventLine14RisingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 14 Rising Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 14 Rising Edge Event. + */ + PropertyI64 eventLine14RisingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 0 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 0 Falling Edge type of Event. + */ + PropertyI64 eventLine0FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 0 Falling Edge Event. + /** + * Returns the Timestamp of the Line 0 Falling Edge Event. + */ + PropertyI64 eventLine0FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 0 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 0 Falling Edge Event. + */ + PropertyI64 eventLine0FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 1 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 1 Falling Edge type of Event. + */ + PropertyI64 eventLine1FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 1 Falling Edge Event. + /** + * Returns the Timestamp of the Line 1 Falling Edge Event. + */ + PropertyI64 eventLine1FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 1 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 1 Falling Edge Event. + */ + PropertyI64 eventLine1FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 2 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 2 Falling Edge type of Event. + */ + PropertyI64 eventLine2FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 2 Falling Edge Event. + /** + * Returns the Timestamp of the Line 2 Falling Edge Event. + */ + PropertyI64 eventLine2FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 2 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 2 Falling Edge Event. + */ + PropertyI64 eventLine2FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 3 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 3 Falling Edge type of Event. + */ + PropertyI64 eventLine3FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 3 Falling Edge Event. + /** + * Returns the Timestamp of the Line 3 Falling Edge Event. + */ + PropertyI64 eventLine3FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 3 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 3 Falling Edge Event. + */ + PropertyI64 eventLine3FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 4 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 4 Falling Edge type of Event. + */ + PropertyI64 eventLine4FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 4 Falling Edge Event. + /** + * Returns the Timestamp of the Line 4 Falling Edge Event. + */ + PropertyI64 eventLine4FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 4 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 4 Falling Edge Event. + */ + PropertyI64 eventLine4FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 5 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 5 Falling Edge type of Event. + */ + PropertyI64 eventLine5FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 5 Falling Edge Event. + /** + * Returns the Timestamp of the Line 5 Falling Edge Event. + */ + PropertyI64 eventLine5FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 5 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 5 Falling Edge Event. + */ + PropertyI64 eventLine5FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 6 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 6 Falling Edge type of Event. + */ + PropertyI64 eventLine6FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 6 Falling Edge Event. + /** + * Returns the Timestamp of the Line 6 Falling Edge Event. + */ + PropertyI64 eventLine6FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 6 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 6 Falling Edge Event. + */ + PropertyI64 eventLine6FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 7 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 7 Falling Edge type of Event. + */ + PropertyI64 eventLine7FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 7 Falling Edge Event. + /** + * Returns the Timestamp of the Line 7 Falling Edge Event. + */ + PropertyI64 eventLine7FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 7 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 7 Falling Edge Event. + */ + PropertyI64 eventLine7FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 8 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 8 Falling Edge type of Event. + */ + PropertyI64 eventLine8FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 8 Falling Edge Event. + /** + * Returns the Timestamp of the Line 8 Falling Edge Event. + */ + PropertyI64 eventLine8FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 8 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 8 Falling Edge Event. + */ + PropertyI64 eventLine8FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 9 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 9 Falling Edge type of Event. + */ + PropertyI64 eventLine9FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 9 Falling Edge Event. + /** + * Returns the Timestamp of the Line 9 Falling Edge Event. + */ + PropertyI64 eventLine9FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 9 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 9 Falling Edge Event. + */ + PropertyI64 eventLine9FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 10 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 10 Falling Edge type of Event. + */ + PropertyI64 eventLine10FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 10 Falling Edge Event. + /** + * Returns the Timestamp of the Line 10 Falling Edge Event. + */ + PropertyI64 eventLine10FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 10 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 10 Falling Edge Event. + */ + PropertyI64 eventLine10FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 11 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 11 Falling Edge type of Event. + */ + PropertyI64 eventLine11FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 11 Falling Edge Event. + /** + * Returns the Timestamp of the Line 11 Falling Edge Event. + */ + PropertyI64 eventLine11FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 11 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 11 Falling Edge Event. + */ + PropertyI64 eventLine11FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 12 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 12 Falling Edge type of Event. + */ + PropertyI64 eventLine12FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 12 Falling Edge Event. + /** + * Returns the Timestamp of the Line 12 Falling Edge Event. + */ + PropertyI64 eventLine12FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 12 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 12 Falling Edge Event. + */ + PropertyI64 eventLine12FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 13 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 13 Falling Edge type of Event. + */ + PropertyI64 eventLine13FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 13 Falling Edge Event. + /** + * Returns the Timestamp of the Line 13 Falling Edge Event. + */ + PropertyI64 eventLine13FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 13 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 13 Falling Edge Event. + */ + PropertyI64 eventLine13FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 14 Falling Edge type of Event. + /** + * Returns the unique Identifier of the Line 14 Falling Edge type of Event. + */ + PropertyI64 eventLine14FallingEdge; + /// \brief An integer property. Returns the Timestamp of the Line 14 Falling Edge Event. + /** + * Returns the Timestamp of the Line 14 Falling Edge Event. + */ + PropertyI64 eventLine14FallingEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 14 Falling Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 14 Falling Edge Event. + */ + PropertyI64 eventLine14FallingEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 0 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 0 Any Edge type of Event. + */ + PropertyI64 eventLine0AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 0 Any Edge Event. + /** + * Returns the Timestamp of the Line 0 Any Edge Event. + */ + PropertyI64 eventLine0AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 0 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 0 Any Edge Event. + */ + PropertyI64 eventLine0AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 1 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 1 Any Edge type of Event. + */ + PropertyI64 eventLine1AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 1 Any Edge Event. + /** + * Returns the Timestamp of the Line 1 Any Edge Event. + */ + PropertyI64 eventLine1AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 1 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 1 Any Edge Event. + */ + PropertyI64 eventLine1AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 2 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 2 Any Edge type of Event. + */ + PropertyI64 eventLine2AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 2 Any Edge Event. + /** + * Returns the Timestamp of the Line 2 Any Edge Event. + */ + PropertyI64 eventLine2AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 2 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 2 Any Edge Event. + */ + PropertyI64 eventLine2AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 3 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 3 Any Edge type of Event. + */ + PropertyI64 eventLine3AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 3 Any Edge Event. + /** + * Returns the Timestamp of the Line 3 Any Edge Event. + */ + PropertyI64 eventLine3AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 3 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 3 Any Edge Event. + */ + PropertyI64 eventLine3AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 4 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 4 Any Edge type of Event. + */ + PropertyI64 eventLine4AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 4 Any Edge Event. + /** + * Returns the Timestamp of the Line 4 Any Edge Event. + */ + PropertyI64 eventLine4AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 4 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 4 Any Edge Event. + */ + PropertyI64 eventLine4AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 5 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 5 Any Edge type of Event. + */ + PropertyI64 eventLine5AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 5 Any Edge Event. + /** + * Returns the Timestamp of the Line 5 Any Edge Event. + */ + PropertyI64 eventLine5AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 5 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 5 Any Edge Event. + */ + PropertyI64 eventLine5AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 6 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 6 Any Edge type of Event. + */ + PropertyI64 eventLine6AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 6 Any Edge Event. + /** + * Returns the Timestamp of the Line 6 Any Edge Event. + */ + PropertyI64 eventLine6AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 6 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 6 Any Edge Event. + */ + PropertyI64 eventLine6AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 7 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 7 Any Edge type of Event. + */ + PropertyI64 eventLine7AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 7 Any Edge Event. + /** + * Returns the Timestamp of the Line 7 Any Edge Event. + */ + PropertyI64 eventLine7AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 7 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 7 Any Edge Event. + */ + PropertyI64 eventLine7AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 8 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 8 Any Edge type of Event. + */ + PropertyI64 eventLine8AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 8 Any Edge Event. + /** + * Returns the Timestamp of the Line 8 Any Edge Event. + */ + PropertyI64 eventLine8AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 8 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 8 Any Edge Event. + */ + PropertyI64 eventLine8AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 9 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 9 Any Edge type of Event. + */ + PropertyI64 eventLine9AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 9 Any Edge Event. + /** + * Returns the Timestamp of the Line 9 Any Edge Event. + */ + PropertyI64 eventLine9AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 9 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 9 Any Edge Event. + */ + PropertyI64 eventLine9AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 10 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 10 Any Edge type of Event. + */ + PropertyI64 eventLine10AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 10 Any Edge Event. + /** + * Returns the Timestamp of the Line 10 Any Edge Event. + */ + PropertyI64 eventLine10AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 10 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 10 Any Edge Event. + */ + PropertyI64 eventLine10AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 11 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 11 Any Edge type of Event. + */ + PropertyI64 eventLine11AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 11 Any Edge Event. + /** + * Returns the Timestamp of the Line 11 Any Edge Event. + */ + PropertyI64 eventLine11AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 11 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 11 Any Edge Event. + */ + PropertyI64 eventLine11AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 12 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 12 Any Edge type of Event. + */ + PropertyI64 eventLine12AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 12 Any Edge Event. + /** + * Returns the Timestamp of the Line 12 Any Edge Event. + */ + PropertyI64 eventLine12AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 12 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 12 Any Edge Event. + */ + PropertyI64 eventLine12AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 13 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 13 Any Edge type of Event. + */ + PropertyI64 eventLine13AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 13 Any Edge Event. + /** + * Returns the Timestamp of the Line 13 Any Edge Event. + */ + PropertyI64 eventLine13AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 13 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 13 Any Edge Event. + */ + PropertyI64 eventLine13AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Line 14 Any Edge type of Event. + /** + * Returns the unique Identifier of the Line 14 Any Edge type of Event. + */ + PropertyI64 eventLine14AnyEdge; + /// \brief An integer property. Returns the Timestamp of the Line 14 Any Edge Event. + /** + * Returns the Timestamp of the Line 14 Any Edge Event. + */ + PropertyI64 eventLine14AnyEdgeTimestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Line 14 Any Edge Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Line 14 Any Edge Event. + */ + PropertyI64 eventLine14AnyEdgeFrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 0 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 0 type of Event. + */ + PropertyI64 eventLinkTrigger0; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 0 Event. + /** + * Returns the Timestamp of the Link Trigger 0 Event. + */ + PropertyI64 eventLinkTrigger0Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 0 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 0 Event. + */ + PropertyI64 eventLinkTrigger0FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 1 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 1 type of Event. + */ + PropertyI64 eventLinkTrigger1; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 1 Event. + /** + * Returns the Timestamp of the Link Trigger 1 Event. + */ + PropertyI64 eventLinkTrigger1Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 1 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 1 Event. + */ + PropertyI64 eventLinkTrigger1FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 2 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 2 type of Event. + */ + PropertyI64 eventLinkTrigger2; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 2 Event. + /** + * Returns the Timestamp of the Link Trigger 2 Event. + */ + PropertyI64 eventLinkTrigger2Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 2 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 2 Event. + */ + PropertyI64 eventLinkTrigger2FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 3 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 3 type of Event. + */ + PropertyI64 eventLinkTrigger3; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 3 Event. + /** + * Returns the Timestamp of the Link Trigger 3 Event. + */ + PropertyI64 eventLinkTrigger3Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 3 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 3 Event. + */ + PropertyI64 eventLinkTrigger3FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 4 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 4 type of Event. + */ + PropertyI64 eventLinkTrigger4; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 4 Event. + /** + * Returns the Timestamp of the Link Trigger 4 Event. + */ + PropertyI64 eventLinkTrigger4Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 4 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 4 Event. + */ + PropertyI64 eventLinkTrigger4FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 5 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 5 type of Event. + */ + PropertyI64 eventLinkTrigger5; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 5 Event. + /** + * Returns the Timestamp of the Link Trigger 5 Event. + */ + PropertyI64 eventLinkTrigger5Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 5 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 5 Event. + */ + PropertyI64 eventLinkTrigger5FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 6 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 6 type of Event. + */ + PropertyI64 eventLinkTrigger6; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 6 Event. + /** + * Returns the Timestamp of the Link Trigger 6 Event. + */ + PropertyI64 eventLinkTrigger6Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 6 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 6 Event. + */ + PropertyI64 eventLinkTrigger6FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 7 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 7 type of Event. + */ + PropertyI64 eventLinkTrigger7; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 7 Event. + /** + * Returns the Timestamp of the Link Trigger 7 Event. + */ + PropertyI64 eventLinkTrigger7Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 7 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 7 Event. + */ + PropertyI64 eventLinkTrigger7FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 8 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 8 type of Event. + */ + PropertyI64 eventLinkTrigger8; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 8 Event. + /** + * Returns the Timestamp of the Link Trigger 8 Event. + */ + PropertyI64 eventLinkTrigger8Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 8 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 8 Event. + */ + PropertyI64 eventLinkTrigger8FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 9 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 9 type of Event. + */ + PropertyI64 eventLinkTrigger9; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 9 Event. + /** + * Returns the Timestamp of the Link Trigger 9 Event. + */ + PropertyI64 eventLinkTrigger9Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 9 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 9 Event. + */ + PropertyI64 eventLinkTrigger9FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 10 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 10 type of Event. + */ + PropertyI64 eventLinkTrigger10; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 10 Event. + /** + * Returns the Timestamp of the Link Trigger 10 Event. + */ + PropertyI64 eventLinkTrigger10Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 10 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 10 Event. + */ + PropertyI64 eventLinkTrigger10FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 11 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 11 type of Event. + */ + PropertyI64 eventLinkTrigger11; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 11 Event. + /** + * Returns the Timestamp of the Link Trigger 11 Event. + */ + PropertyI64 eventLinkTrigger11Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 11 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 11 Event. + */ + PropertyI64 eventLinkTrigger11FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 12 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 12 type of Event. + */ + PropertyI64 eventLinkTrigger12; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 12 Event. + /** + * Returns the Timestamp of the Link Trigger 12 Event. + */ + PropertyI64 eventLinkTrigger12Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 12 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 12 Event. + */ + PropertyI64 eventLinkTrigger12FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 13 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 13 type of Event. + */ + PropertyI64 eventLinkTrigger13; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 13 Event. + /** + * Returns the Timestamp of the Link Trigger 13 Event. + */ + PropertyI64 eventLinkTrigger13Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 13 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 13 Event. + */ + PropertyI64 eventLinkTrigger13FrameID; + /// \brief An integer property. Returns the unique Identifier of the Link Trigger 14 type of Event. + /** + * Returns the unique Identifier of the Link Trigger 14 type of Event. + */ + PropertyI64 eventLinkTrigger14; + /// \brief An integer property. Returns the Timestamp of the Link Trigger 14 Event. + /** + * Returns the Timestamp of the Link Trigger 14 Event. + */ + PropertyI64 eventLinkTrigger14Timestamp; + /// \brief An integer property. Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 14 Event. + /** + * Returns the unique Identifier of the Frame (or image) that generated the Link Trigger 14 Event. + */ + PropertyI64 eventLinkTrigger14FrameID; + /// \brief An integer property. Returns the unique identifier of the Error type of Event. + /** + * Returns the unique identifier of the Error type of Event. It can be used to register a callback function to be notified of the Error event occurrence. Its value uniquely identifies that the event received was an Error. + */ + PropertyI64 eventError; + /// \brief An integer property. Returns the Timestamp of the Error Event. + /** + * Returns the Timestamp of the Error Event. It can be used to determine when the event occurred. + */ + PropertyI64 eventErrorTimestamp; + /// \brief An integer property. If applicable, returns the unique Identifier of the Frame (or image) that generated the Error Event. + /** + * If applicable, returns the unique Identifier of the Frame (or image) that generated the Error Event. + */ + PropertyI64 eventErrorFrameID; + /// \brief An integer property. Returns an error code for the error(s) that happened. + /** + * Returns an error code for the error(s) that happened. + */ + PropertyI64 eventErrorCode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the User Set control features. +/** + * A category that contains the User Set control features. + * \ingroup GenICamInterfaceDevice + */ +class UserSetControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::UserSetControl object. + explicit UserSetControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + userSetSelector(), + userSetDescription(), + userSetLoad(), + userSetSave(), + userSetDefault(), + userSetDefaultSelector(), + userSetFeatureSelector(), + userSetFeatureEnable(), + mvUserData() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( userSetSelector, "UserSetSelector" ); + locator.bindComponent( userSetDescription, "UserSetDescription" ); + locator.bindComponent( userSetLoad, "UserSetLoad@i" ); + locator.bindComponent( userSetSave, "UserSetSave@i" ); + locator.bindComponent( userSetDefault, "UserSetDefault" ); + if( !userSetDefault.isValid() ) + { + locator.bindComponent( userSetDefault, "UserSetDefaultSelector" ); + } + locator.bindComponent( userSetDefaultSelector, "UserSetDefaultSelector" ); + locator.bindComponent( userSetFeatureSelector, "UserSetFeatureSelector" ); + locator.bindComponent( userSetFeatureEnable, "UserSetFeatureEnable" ); + locator.bindComponent( mvUserData, "mvUserData" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the feature User Set to load, save or configure. + /** + * Selects the feature User Set to load, save or configure. + * + * The following string values might be valid for this feature: + * - \b Default (Display string: 'Default'): Selects the factory setting user set. + * - \b UserSet0 (Display string: 'User Set 0'): Selects the user set 0. + * - \b UserSet1 (Display string: 'User Set 1'): Selects the user set 1. + * - \b UserSet\#2\# (Display string: 'User Set \#2\#'): Selects the user set \#2\#. + * - \b UserSet2 (Display string: 'User Set 2'): Selects the user set 2. + * - \b UserSet3 (Display string: 'User Set 3'): Selects the user set 3. + * - \b UserSet4 (Display string: 'User Set 4'): Selects the user set 4. + * - \b UserSet5 (Display string: 'User Set 5'): Selects the user set 5. + * - \b UserSet6 (Display string: 'User Set 6'): Selects the user set 6. + * - \b UserSet7 (Display string: 'User Set 7'): Selects the user set 7. + * - \b UserSet8 (Display string: 'User Set 8'): Selects the user set 8. + * - \b UserSet9 (Display string: 'User Set 9'): Selects the user set 9. + * - \b UserSet10 (Display string: 'User Set 10'): Selects the user set 10. + * - \b UserSet11 (Display string: 'User Set 11'): Selects the user set 11. + * - \b UserSet12 (Display string: 'User Set 12'): Selects the user set 12. + * - \b UserSet13 (Display string: 'User Set 13'): Selects the user set 13. + * - \b UserSet14 (Display string: 'User Set 14'): Selects the user set 14. + * - \b UserSet15 (Display string: 'User Set 15'): Selects the user set 15. + * - \b UserSet16 (Display string: 'User Set 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 userSetSelector; + /// \brief A string property. Description of the selected User Set content. + /** + * Description of the selected User Set content. + */ + PropertyS userSetDescription; + /// \brief A method object. Loads the User Set specified by UserSetSelector to the device and makes it active. + /** + * Loads the User Set specified by UserSetSelector to the device and makes it active. + */ + Method userSetLoad; + /// \brief A method object. Save the User Set specified by UserSetSelector to the non-volatile memory of the device. + /** + * Save the User Set specified by UserSetSelector to the non-volatile memory of the device. + */ + Method userSetSave; + /// \brief An enumerated integer property. Selects the feature User Set to load and make active by default when the device is reset. + /** + * Selects the feature User Set to load and make active by default when the device is reset. + * + * The following string values might be valid for this feature: + * - \b Default (Display string: 'Default'): Select the factory setting user set. + * - \b UserSet0 (Display string: 'User Set 0'): Select the user set 0. + * - \b UserSet1 (Display string: 'User Set 1'): Select the user set 1. + * - \b UserSet\#2\# (Display string: 'User Set \#2\#'): Select the user set \#2\#. + * - \b UserSet2 (Display string: 'User Set 2'): Select the user set 2. + * - \b UserSet3 (Display string: 'User Set 3'): Select the user set 3. + * - \b UserSet4 (Display string: 'User Set 4'): Select the user set 4. + * - \b UserSet5 (Display string: 'User Set 5'): Select the user set 5. + * - \b UserSet6 (Display string: 'User Set 6'): Select the user set 6. + * - \b UserSet7 (Display string: 'User Set 7'): Select the user set 7. + * - \b UserSet8 (Display string: 'User Set 8'): Select the user set 8. + * - \b UserSet9 (Display string: 'User Set 9'): Select the user set 9. + * - \b UserSet10 (Display string: 'User Set 10'): Select the user set 10. + * - \b UserSet11 (Display string: 'User Set 11'): Select the user set 11. + * - \b UserSet12 (Display string: 'User Set 12'): Select the user set 12. + * - \b UserSet13 (Display string: 'User Set 13'): Select the user set 13. + * - \b UserSet14 (Display string: 'User Set 14'): Select the user set 14. + * - \b UserSet15 (Display string: 'User Set 15'): Select the user set 15. + * - \b UserSet16 (Display string: 'User Set 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 userSetDefault; + /// \brief An enumerated integer property. This feature is deprecated (See UserSetDefault). + /** + * \deprecated + * This feature is deprecated (See UserSetDefault). Selects the feature User Set to load and make active when the device is reset. + * + * The following string values might be valid for this feature: + * - \b Default (Display string: 'Default'): Select the factory setting user set. + * - \b UserSet0 (Display string: 'User Set 0'): Select the user set 0. + * - \b UserSet1 (Display string: 'User Set 1'): Select the user set 1. + * - \b UserSet\#2\# (Display string: 'User Set \#2\#'): Select the user set \#2\#. + * - \b UserSet2 (Display string: 'User Set 2'): Select the user set 2. + * - \b UserSet3 (Display string: 'User Set 3'): Select the user set 3. + * - \b UserSet4 (Display string: 'User Set 4'): Select the user set 4. + * - \b UserSet5 (Display string: 'User Set 5'): Select the user set 5. + * - \b UserSet6 (Display string: 'User Set 6'): Select the user set 6. + * - \b UserSet7 (Display string: 'User Set 7'): Select the user set 7. + * - \b UserSet8 (Display string: 'User Set 8'): Select the user set 8. + * - \b UserSet9 (Display string: 'User Set 9'): Select the user set 9. + * - \b UserSet10 (Display string: 'User Set 10'): Select the user set 10. + * - \b UserSet11 (Display string: 'User Set 11'): Select the user set 11. + * - \b UserSet12 (Display string: 'User Set 12'): Select the user set 12. + * - \b UserSet13 (Display string: 'User Set 13'): Select the user set 13. + * - \b UserSet14 (Display string: 'User Set 14'): Select the user set 14. + * - \b UserSet15 (Display string: 'User Set 15'): Select the user set 15. + * - \b UserSet16 (Display string: 'User Set 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 userSetDefaultSelector; + /// \brief An enumerated integer property. Selects which individual UserSet feature to control. + /** + * Selects which individual UserSet feature to control. + * + * The following string values might be valid for this feature: + * - \b Device-Specific (Display string: 'Device - Specific'): Device - Specific + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 userSetFeatureSelector; + /// \brief A boolean property. Enables the selected feature and make it active in all the UserSets. + /** + * Enables the selected feature and make it active in all the UserSets. + */ + PropertyIBoolean userSetFeatureEnable; + /// \brief A string property. A register to store arbitrary user data into the devices non-volatile memory. + /** + * A register to store arbitrary user data into the devices non-volatile memory + */ + PropertyS mvUserData; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category for the Sequencer Control features. +/** + * A category for the Sequencer Control features. + * \ingroup GenICamInterfaceDevice + */ +class SequencerControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::SequencerControl object. + explicit SequencerControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + sequencerMode(), + sequencerConfigurationMode(), + sequencerFeatureSelector(), + sequencerFeatureEnable(), + sequencerSetSelector(), + sequencerSetSave(), + sequencerSetLoad(), + sequencerSetActive(), + sequencerSetStart(), + sequencerPathSelector(), + sequencerSetNext(), + sequencerTriggerSource(), + sequencerTriggerActivation() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( sequencerMode, "SequencerMode" ); + locator.bindComponent( sequencerConfigurationMode, "SequencerConfigurationMode" ); + locator.bindComponent( sequencerFeatureSelector, "SequencerFeatureSelector" ); + locator.bindComponent( sequencerFeatureEnable, "SequencerFeatureEnable" ); + locator.bindComponent( sequencerSetSelector, "SequencerSetSelector" ); + locator.bindComponent( sequencerSetSave, "SequencerSetSave@i" ); + locator.bindComponent( sequencerSetLoad, "SequencerSetLoad@i" ); + locator.bindComponent( sequencerSetActive, "SequencerSetActive" ); + locator.bindComponent( sequencerSetStart, "SequencerSetStart" ); + locator.bindComponent( sequencerPathSelector, "SequencerPathSelector" ); + locator.bindComponent( sequencerSetNext, "SequencerSetNext" ); + locator.bindComponent( sequencerTriggerSource, "SequencerTriggerSource" ); + locator.bindComponent( sequencerTriggerActivation, "SequencerTriggerActivation" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Controls if the sequencer mechanism is active. + /** + * Controls if the sequencer mechanism is active. + * + * The following string values might be valid for this feature: + * - \b On (Display string: 'On'): Enables the sequencer. + * - \b Off (Display string: 'Off'): Disables the sequencer. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sequencerMode; + /// \brief An enumerated integer property. Controls if the sequencer configuration mode is active. + /** + * Controls if the sequencer configuration mode is active. + * + * The following string values might be valid for this feature: + * - \b On (Display string: 'On'): Enables the sequencer configuration mode. + * - \b Off (Display string: 'Off'): Disables the sequencer configuration mode. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sequencerConfigurationMode; + /// \brief An enumerated integer property. Selects which sequencer features to control. + /** + * Selects which sequencer features to control. + * + * The following string values might be valid for this feature: + * - \b Device-Specific (Display string: 'Device - Specific'): Device - Specific + * - \b ExposureTime (Display string: 'Exposure Time') + * - \b CounterDuration (Display string: 'Counter Duration') + * - \b mvImagePositionAndSize (Display string: 'mv Image Position And Size'): This value selects whether features affecting the image position and size shall be controlled by the sequencer. + * - \b Width (Display string: 'Width') + * - \b Height (Display string: 'Height') + * - \b OffsetX (Display string: 'Offset X') + * - \b OffsetY (Display string: 'Offset Y') + * - \b BinningHorizontal (Display string: 'Binning Horizontal') + * - \b BinningVertical (Display string: 'Binning Vertical') + * - \b DecimationHorizontal (Display string: 'Decimation Horizontal') + * - \b DecimationVertical (Display string: 'Decimation Vertical') + * - \b Gain (Display string: 'Gain') + * - \b UserOutputValueAll (Display string: 'User Output Value All') + * - \b UserOutputValueAllMask (Display string: 'User Output Value All Mask') + * - \b mvUserOutput (Display string: 'mv User Output'): This value selects whether features affecting the user outputs shall be controlled by the sequencer. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sequencerFeatureSelector; + /// \brief A boolean property. Enables the selected feature and make it active in all the sequencer sets. + /** + * Enables the selected feature and make it active in all the sequencer sets. + */ + PropertyIBoolean sequencerFeatureEnable; + /// \brief An integer property. Selects the sequencer set to which further feature settings applies. + /** + * Selects the sequencer set to which further feature settings applies. + */ + PropertyI64 sequencerSetSelector; + /// \brief A method object. Saves the current device state to the sequencer set selected by the SequencerSetSelector. + /** + * Saves the current device state to the sequencer set selected by the SequencerSetSelector. + */ + Method sequencerSetSave; + /// \brief A method object. Loads the sequencer set selected by SequencerSetSelector in the device. + /** + * Loads the sequencer set selected by SequencerSetSelector in the device. Even if SequencerMode is off, this will change the device state to the configuration of the selected set. + */ + Method sequencerSetLoad; + /// \brief An integer property. Contains the currently active sequencer set. + /** + * Contains the currently active sequencer set. + */ + PropertyI64 sequencerSetActive; + /// \brief An integer property. Sets the initial/start sequencer set, which is the first set used within a sequencer. + /** + * Sets the initial/start sequencer set, which is the first set used within a sequencer. + */ + PropertyI64 sequencerSetStart; + /// \brief An integer property. Selects to which branching path further path settings applies. + /** + * Selects to which branching path further path settings applies. + */ + PropertyI64 sequencerPathSelector; + /// \brief An integer property. Specifies the next sequencer set. + /** + * Specifies the next sequencer set. + */ + PropertyI64 sequencerSetNext; + /// \brief An enumerated integer property. Specifies the internal signal or physical input line to use as the sequencer trigger source. + /** + * Specifies the internal signal or physical input line to use as the sequencer trigger source. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disables the sequencer trigger. + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Starts with the reception of the Acquisition Trigger. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Starts with the reception of the missed Acquisition Trigger. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Starts with the reception of the Acquisition Start. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Starts with the reception of the Acquisition End. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Starts with the reception of the Frame Start Trigger. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Starts with the reception of the missed Frame Trigger. + * - \b FrameStart (Display string: 'Frame Start'): Starts with the reception of the Frame Start. + * - \b FrameEnd (Display string: 'Frame End'): Starts with the reception of the Frame End. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Starts with the reception of the Frame Burst Start. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Starts with the reception of the Frame Burst End. + * - \b ExposureStart (Display string: 'Exposure Start'): Starts with the reception of the Exposure Start. + * - \b ExposureEnd (Display string: 'Exposure End'): Starts with the reception of the Exposure End. + * - \b Line0 (Display string: 'Line 0'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line1 (Display string: 'Line 1'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line2 (Display string: 'Line 2'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Starts when the specified TimerTriggerActivation condition is met on the chosen I/O Line. + * - \b UserOutput0 (Display string: 'User Output 0'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput1 (Display string: 'User Output 1'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput2 (Display string: 'User Output 2'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b UserOutput\#3\# (Display string: 'User Output \#3\#'): Specifies which User Output bit signal to use as internal source for the trigger. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Starts with the reception of the Counter Start. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Starts with the reception of the Counter Start. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Starts with the reception of the Counter Start. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Starts with the reception of the Counter Start. + * - \b Counter0End (Display string: 'Counter 0 End'): Starts with the reception of the Counter End. + * - \b Counter1End (Display string: 'Counter 1 End'): Starts with the reception of the Counter End. + * - \b Counter2End (Display string: 'Counter 2 End'): Starts with the reception of the Counter End. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Starts with the reception of the Counter End. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Starts with the reception of the Timer Start. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Starts with the reception of the Timer Start. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Starts with the reception of the Timer Start. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Starts with the reception of the Timer Start. + * - \b Timer0End (Display string: 'Timer 0 End'): Starts with the reception of the Timer End. + * - \b Timer1End (Display string: 'Timer 1 End'): Starts with the reception of the Timer End. + * - \b Timer2End (Display string: 'Timer 2 End'): Starts with the reception of the Timer End. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Starts with the reception of the Timer End. + * - \b Encoder0 (Display string: 'Encoder 0'): Starts with the reception of the Encoder output signal. + * - \b Encoder1 (Display string: 'Encoder 1'): Starts with the reception of the Encoder output signal. + * - \b Encoder2 (Display string: 'Encoder 2'): Starts with the reception of the Encoder output signal. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Starts with the reception of the Encoder output signal. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Starts with the reception of the Logic Block output signal. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Starts with the reception of the Logic Block output signal. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Starts on the reception of the Software Signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Starts on the reception of the Software Signal. + * - \b Action0 (Display string: 'Action 0'): Starts with the assertion of the chosen action signal. + * - \b Action1 (Display string: 'Action 1'): Starts with the assertion of the chosen action signal. + * - \b Action2 (Display string: 'Action 2'): Starts with the assertion of the chosen action signal. + * - \b Action\#3\# (Display string: 'Action \#3\#'): Starts with the assertion of the chosen action signal. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): Starts with the reception of the chosen Link Trigger. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): Starts with the reception of the chosen Link Trigger. + * - \b LinkTrigger2 (Display string: 'Link Trigger 2'): Starts with the reception of the chosen Link Trigger. + * - \b LinkTrigger\#3\# (Display string: 'Link Trigger \#3\#'): Starts with the reception of the chosen Link Trigger. + * - \b CC1 (Display string: 'CC 1'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC2 (Display string: 'CC 2'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC3 (Display string: 'CC 3'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * - \b CC4 (Display string: 'CC 4'): Index of the Camera Link physical line and associated I/O control block to use. This ensures a direct mapping between the lines on the frame grabber and on the camera. Applicable to CameraLink products only. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sequencerTriggerSource; + /// \brief An enumerated integer property. Specifies the activation mode of the sequencer trigger. + /** + * Specifies the activation mode of the sequencer trigger. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Specifies that the trigger is considered valid on the rising edge of the source signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Specifies that the trigger is considered valid on the falling edge of the source signal. + * - \b AnyEdge (Display string: 'Any Edge'): Specifies that the trigger is considered valid on the falling or rising edge of the source signal. + * - \b LevelHigh (Display string: 'Level High'): Specifies that the trigger is considered valid as long as the level of the source signal is high. + * - \b LevelLow (Display string: 'Level Low'): Specifies that the trigger is considered valid as long as the level of the source signal is low. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sequencerTriggerActivation; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Contains features to control the device's defective pixel correction parameters. +/** + * Contains features to control the device's defective pixel correction parameters. + * \ingroup GenICamInterfaceDevice + */ +class mvDefectivePixelCorrectionControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvDefectivePixelCorrectionControl object. + explicit mvDefectivePixelCorrectionControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvDefectPixelThreshold(), + mvDefectivePixelEnable(), + mvDefectivePixelBlinkingMode(), + mvDefectivePixelSelector(), + mvDefectivePixelOffsetX(), + mvDefectivePixelOffsetY(), + mvDefectivePixelCount(), + mvDefectivePixelDataLoad(), + mvDefectivePixelDataSave() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvDefectivePixelCorrectionControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvDefectPixelThreshold, "mvDefectPixelThreshold" ); + locator.bindComponent( mvDefectivePixelEnable, "mvDefectivePixelEnable" ); + locator.bindComponent( mvDefectivePixelBlinkingMode, "mvDefectivePixelBlinkingMode" ); + locator.bindComponent( mvDefectivePixelSelector, "mvDefectivePixelSelector" ); + locator.bindComponent( mvDefectivePixelOffsetX, "mvDefectivePixelOffsetX" ); + locator.bindComponent( mvDefectivePixelOffsetY, "mvDefectivePixelOffsetY" ); + locator.bindComponent( mvDefectivePixelCount, "mvDefectivePixelCount" ); + locator.bindComponent( mvDefectivePixelDataLoad, "mvDefectivePixelDataLoad@i" ); + locator.bindComponent( mvDefectivePixelDataSave, "mvDefectivePixelDataSave@i" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property. Sets the threshold for the defect pixel detection. + /** + * Sets the threshold for the defect pixel detection. + */ + PropertyI64 mvDefectPixelThreshold; + /// \brief A boolean property. Activates the camera's defective pixel correction. + /** + * Activates the camera's defective pixel correction. + */ + PropertyIBoolean mvDefectivePixelEnable; + /// \brief A boolean property. Activates the blinking mode of the camera's defective pixel correction. + /** + * Activates the blinking mode of the camera's defective pixel correction. + */ + PropertyIBoolean mvDefectivePixelBlinkingMode; + /// \brief An integer property. Controls the index (offset) of the defective pixel to access. + /** + * Controls the index (offset) of the defective pixel to access. Data selected by this selector is NOT part of a user set, but must be written to non volatile memory by calling 'mvDefectivePixelDataSave' explicitly. + */ + PropertyI64 mvDefectivePixelSelector; + /// \brief An integer property. Returns the horizontal offset of the defective pixel selected by mvDefectivePixelSelector. + /** + * Returns the horizontal offset of the defective pixel selected by mvDefectivePixelSelector. This data is NOT part of a user set, but must be written to non volatile memory by calling 'mvDefectivePixelDataSave' explicitly. + */ + PropertyI64 mvDefectivePixelOffsetX; + /// \brief An integer property. Returns the vertical offset of the defective pixel selected by mvDefectivePixelSelector. + /** + * Returns the vertical offset of the defective pixel selected by mvDefectivePixelSelector. This data is NOT part of a user set, but must be written to non volatile memory by calling 'mvDefectivePixelDataSave' explicitly. + */ + PropertyI64 mvDefectivePixelOffsetY; + /// \brief An integer property. Contains the number of valid defective pixels. Increasing this value adds a new empty entry. Decreasing this value deletes the last entry. + /** + * Contains the number of valid defective pixels. Increasing this value adds a new empty entry. Decreasing this value deletes the last entry. + */ + PropertyI64 mvDefectivePixelCount; + /// \brief A method object. Loads the defective pixels from device non volatile memory. + /** + * Loads the defective pixels from device non volatile memory. + */ + Method mvDefectivePixelDataLoad; + /// \brief A method object. Saves the defective pixels to device non volatile memory. + /** + * Saves the defective pixels to device non volatile memory. + */ + Method mvDefectivePixelDataSave; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the File Access control features. +/** + * A category that contains the File Access control features. + * \ingroup GenICamInterfaceDevice + */ +class FileAccessControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::FileAccessControl object. + explicit FileAccessControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + fileSelector(), + fileOperationSelector(), + fileOperationExecute(), + fileOpenMode(), + fileAccessBuffer(), + fileAccessOffset(), + fileAccessLength(), + fileOperationStatus(), + fileOperationResult(), + fileSize() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( fileSelector, "FileSelector" ); + locator.bindComponent( fileOperationSelector, "FileOperationSelector" ); + locator.bindComponent( fileOperationExecute, "FileOperationExecute@i" ); + locator.bindComponent( fileOpenMode, "FileOpenMode" ); + locator.bindComponent( fileAccessBuffer, "FileAccessBuffer" ); + locator.bindComponent( fileAccessOffset, "FileAccessOffset" ); + locator.bindComponent( fileAccessLength, "FileAccessLength" ); + locator.bindComponent( fileOperationStatus, "FileOperationStatus" ); + locator.bindComponent( fileOperationResult, "FileOperationResult" ); + locator.bindComponent( fileSize, "FileSize" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the target file in the device. + /** + * Selects the target file in the device. + * + * The following string values might be valid for this feature: + * - \b UserSetDefault (Display string: 'User Set Default'): The default user set of the device. + * - \b UserSet1 (Display string: 'User Set 1'): The first user set of the device. + * - \b UserSet2 (Display string: 'User Set 2'): The second user set of the device. + * - \b UserSet3 (Display string: 'User Set 3'): The third user set of the device. + * - \b UserSet\#4\# (Display string: 'User Set \#4\#'): The third user set of the device. + * - \b LUTLuminance (Display string: 'LUT Luminance'): The Luminance LUT of the camera. + * - \b LUTRed (Display string: 'LUT Red'): The Red LUT of the camera. + * - \b LUTGreen (Display string: 'LUT Green'): The Green LUT of the camera. + * - \b LUTBlue (Display string: 'LUT Blue'): The Blue LUT of the camera. + * - \b DeviceFirmware (Display string: 'Device Firmware') + * - \b UserFile (Display string: 'User File') + * - \b mvFFCImage (Display string: 'mv FFC Image') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 fileSelector; + /// \brief An enumerated integer property. Selects the target operation for the selected file in the device. + /** + * Selects the target operation for the selected file in the device. This Operation is executed when the FileOperationExecute feature is called. + * + * The following string values might be valid for this feature: + * - \b Open (Display string: 'Open'): Opens the file selected by FileSelector in the device. The access mode in which the file is opened is selected by FileOpenMode. + * - \b Close (Display string: 'Close'): Closes the file selected by FileSelector in the device. + * - \b Read (Display string: 'Read'): Reads FileAccessLength bytes from the device storage at the file relative offset FileAccessOffset into FileAccessBuffer. + * - \b Write (Display string: 'Write'): Writes FileAccessLength bytes taken from the FileAccessBuffer into the device storage at the file relative offset FileAccessOffset. + * - \b Delete (Display string: 'Delete'): Deletes the file selected by FileSelector in the device. Note that deleting a device file should not remove the associated FileSelector entry to allow future operation on this file. + * - \b MvFlashWrite (Display string: 'Mv Flash Write') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 fileOperationSelector; + /// \brief A method object. Executes the operation selected by FileOperationSelector on the selected file. + /** + * Executes the operation selected by FileOperationSelector on the selected file. + */ + Method fileOperationExecute; + /// \brief An enumerated integer property. Selects the access mode in which a file is opened in the device. + /** + * Selects the access mode in which a file is opened in the device. + * + * The following string values might be valid for this feature: + * - \b Read (Display string: 'Read'): This mode selects read-only open mode. + * - \b Write (Display string: 'Write'): This mode selects write-only open mode. + * - \b ReadWrite (Display string: 'Read Write'): This mode selects read and write open mode. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 fileOpenMode; + /// \brief A string property. Defines the intermediate access buffer that allows the exchange of data between the device file storage and the application. + /** + * Defines the intermediate access buffer that allows the exchange of data between the device file storage and the application. + */ + PropertyS fileAccessBuffer; + /// \brief An integer property. Controls the Offset of the mapping between the device file storage and the FileAccessBuffer. + /** + * Controls the Offset of the mapping between the device file storage and the FileAccessBuffer. + */ + PropertyI64 fileAccessOffset; + /// \brief An integer property. Controls the Length of the mapping between the device file storage and the FileAccessBuffer. + /** + * Controls the Length of the mapping between the device file storage and the FileAccessBuffer. + */ + PropertyI64 fileAccessLength; + /// \brief An enumerated integer property. Represents the file operation execution status. + /** + * Represents the file operation execution status. + * + * The following string values might be valid for this feature: + * - \b Success (Display string: 'Success'): File Operation was successful. + * - \b Failure (Display string: 'Failure'): File Operation failed. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 fileOperationStatus; + /// \brief An integer property. Represents the file operation result. + /** + * Represents the file operation result. For Read or Write operations, the number of successfully read/written bytes is returned. + */ + PropertyI64 fileOperationResult; + /// \brief An integer property. Represents the size of the selected file in bytes. + /** + * Represents the size of the selected file in bytes. + */ + PropertyI64 fileSize; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the source control features. +/** + * A category that contains the source control features. + * \ingroup GenICamInterfaceDevice + */ +class SourceControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::SourceControl object. + explicit SourceControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + sourceCount(), + sourceSelector(), + sourceIDValue() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( sourceCount, "SourceCount" ); + locator.bindComponent( sourceSelector, "SourceSelector" ); + locator.bindComponent( sourceIDValue, "SourceIDValue" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property. Controls or returns the number of sources supported by the device. + /** + * Controls or returns the number of sources supported by the device. + */ + PropertyI64 sourceCount; + /// \brief An enumerated integer property. Selects the source to control. + /** + * Selects the source to control. + * + * The following string values might be valid for this feature: + * - \b Source0 (Display string: 'Source 0'): Selects the data source 0. + * - \b Source1 (Display string: 'Source 1'): Selects the data source 1. + * - \b Source2 (Display string: 'Source 2'): Selects the data source 2. + * - \b Source\#3\# (Display string: 'Source \#3\#'): Selects the data source \#3\#. + * - \b All (Display string: 'All'): Selects all the data sources. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 sourceSelector; + /// \brief An integer property. Returns a unique Identifier value that correspond to the selected Source. + /** + * Returns a unique Identifier value that correspond to the selected Source. + */ + PropertyI64 sourceIDValue; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category for the data Transfer Control features. +/** + * A category for the data Transfer Control features. + * \ingroup GenICamInterfaceDevice + */ +class TransferControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::TransferControl object. + explicit TransferControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + transferSelector(), + transferControlMode(), + transferOperationMode(), + transferBlockCount(), + transferBurstCount(), + transferQueueMaxBlockCount(), + transferQueueCurrentBlockCount(), + transferQueueMode(), + transferStart(), + transferStop(), + transferAbort(), + transferPause(), + transferResume(), + transferTriggerSelector(), + transferTriggerMode(), + transferTriggerSource(), + transferTriggerActivation(), + transferStatusSelector(), + transferStatus(), + transferComponentSelector(), + transferStreamChannel() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( transferSelector, "TransferSelector" ); + locator.bindComponent( transferControlMode, "TransferControlMode" ); + locator.bindComponent( transferOperationMode, "TransferOperationMode" ); + locator.bindComponent( transferBlockCount, "TransferBlockCount" ); + locator.bindComponent( transferBurstCount, "TransferBurstCount" ); + locator.bindComponent( transferQueueMaxBlockCount, "TransferQueueMaxBlockCount" ); + locator.bindComponent( transferQueueCurrentBlockCount, "TransferQueueCurrentBlockCount" ); + locator.bindComponent( transferQueueMode, "TransferQueueMode" ); + locator.bindComponent( transferStart, "TransferStart@i" ); + locator.bindComponent( transferStop, "TransferStop@i" ); + locator.bindComponent( transferAbort, "TransferAbort@i" ); + locator.bindComponent( transferPause, "TransferPause@i" ); + locator.bindComponent( transferResume, "TransferResume@i" ); + locator.bindComponent( transferTriggerSelector, "TransferTriggerSelector" ); + locator.bindComponent( transferTriggerMode, "TransferTriggerMode" ); + locator.bindComponent( transferTriggerSource, "TransferTriggerSource" ); + locator.bindComponent( transferTriggerActivation, "TransferTriggerActivation" ); + locator.bindComponent( transferStatusSelector, "TransferStatusSelector" ); + locator.bindComponent( transferStatus, "TransferStatus" ); + locator.bindComponent( transferComponentSelector, "TransferComponentSelector" ); + locator.bindComponent( transferStreamChannel, "TransferStreamChannel" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects which stream transfers are currently controlled by the selected Transfer features. + /** + * Selects which stream transfers are currently controlled by the selected Transfer features. + * + * The following string values might be valid for this feature: + * - \b Stream0 (Display string: 'Stream 0'): The transfer features control the data stream 0. + * - \b Stream1 (Display string: 'Stream 1'): The transfer features control the data stream 1. + * - \b Stream2 (Display string: 'Stream 2'): The transfer features control the data stream 2. + * - \b Stream\#3\# (Display string: 'Stream \#3\#'): The transfer features control the data stream \#3\#. + * - \b All (Display string: 'All'): The transfer features control all the data streams simultaneously. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferSelector; + /// \brief An enumerated integer property. Selects the control method for the transfers. + /** + * Selects the control method for the transfers. + * + * The following string values might be valid for this feature: + * - \b Basic (Display string: 'Basic'): Basic + * - \b Automatic (Display string: 'Automatic'): Automatic + * - \b UserControlled (Display string: 'User Controlled'): User Controlled + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferControlMode; + /// \brief An enumerated integer property. Selects the operation mode of the transfer. + /** + * Selects the operation mode of the transfer. + * + * The following string values might be valid for this feature: + * - \b Continuous (Display string: 'Continuous'): Continuous + * - \b MultiBlock (Display string: 'Multi Block'): Multi Block + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferOperationMode; + /// \brief An integer property. Specifies the number of data Blocks that the device should stream before stopping. + /** + * Specifies the number of data Blocks that the device should stream before stopping. This feature is only active if the TransferOperationMode is set to MultiBlock. + */ + PropertyI64 transferBlockCount; + /// \brief An integer property. Number of Block(s) to transfer for each TransferBurstStart trigger. + /** + * Number of Block(s) to transfer for each TransferBurstStart trigger. + */ + PropertyI64 transferBurstCount; + /// \brief An integer property. Controls the maximum number of data blocks that can be stored in the block queue of the selected stream. + /** + * Controls the maximum number of data blocks that can be stored in the block queue of the selected stream. + */ + PropertyI64 transferQueueMaxBlockCount; + /// \brief An integer property. Returns the number of Block(s) currently in the transfer queue. + /** + * Returns the number of Block(s) currently in the transfer queue. + */ + PropertyI64 transferQueueCurrentBlockCount; + /// \brief An enumerated integer property. Specifies the operation mode of the transfer queue. + /** + * Specifies the operation mode of the transfer queue. + * + * The following string values might be valid for this feature: + * - \b FirstInFirstOut (Display string: 'First In First Out'): Blocks first In are transferred Out first. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferQueueMode; + /// \brief A method object. Starts the streaming of data blocks out of the device. + /** + * Starts the streaming of data blocks out of the device. This feature must be available when the TransferControlMode is set to 'UserControlled'. If the TransferStart feature is not writable (locked), the application should not start the transfer and should avoid using the feature until it becomes writable again. + */ + Method transferStart; + /// \brief A method object. Stops the streaming of data Block(s). + /** + * Stops the streaming of data Block(s). The current block transmission will be completed. This feature must be available when the TransferControlMode is set to 'UserControlled'. + */ + Method transferStop; + /// \brief A method object. Aborts immediately the streaming of data block(s). + /** + * Aborts immediately the streaming of data block(s). Aborting the transfer will result in the lost of the data that is present or currently entering in the block queue. However, the next new block received will be stored in the queue and transferred to the host when the streaming is restarted. If implemented, this feature should be available when the TransferControlMode is set to 'UserControlled'. + */ + Method transferAbort; + /// \brief A method object. Pauses the streaming of data Block(s). + /** + * Pauses the streaming of data Block(s). Pausing the streaming will immediately suspend the ongoing data transfer even if a block is partially transfered. The device will resume its transmission at the reception of a TransferResume command. + */ + Method transferPause; + /// \brief A method object. Resumes a data Blocks streaming that was previously paused by a TransferPause command. + /** + * Resumes a data Blocks streaming that was previously paused by a TransferPause command. + */ + Method transferResume; + /// \brief An enumerated integer property. Selects the type of transfer trigger to configure. + /** + * Selects the type of transfer trigger to configure. + * + * The following string values might be valid for this feature: + * - \b TransferStart (Display string: 'Transfer Start'): Selects a trigger to start the transfers. + * - \b TransferStop (Display string: 'Transfer Stop'): Selects a trigger to stop the transfers. + * - \b TransferAbort (Display string: 'Transfer Abort'): Selects a trigger to abort the transfers. + * - \b TransferPause (Display string: 'Transfer Pause'): Selects a trigger to pause the transfers. + * - \b TransferResume (Display string: 'Transfer Resume'): Selects a trigger to Resume the transfers. + * - \b TransferActive (Display string: 'Transfer Active'): Selects a trigger to Activate the transfers. This trigger type is used when TriggerActivation is set LevelHigh or levelLow. + * - \b TransferBurstStart (Display string: 'Transfer Burst Start'): Selects a trigger to start the transfer of a burst of frames specified by TransferBurstCount. + * - \b TransferBurstStop (Display string: 'Transfer Burst Stop'): Selects a trigger to end the transfer of a burst of frames. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferTriggerSelector; + /// \brief An enumerated integer property. Controls if the selected trigger is active. + /** + * Controls if the selected trigger is active. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Disables the selected trigger. + * - \b On (Display string: 'On'): Enable the selected trigger. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferTriggerMode; + /// \brief An enumerated integer property. Specifies the signal to use as the trigger source for transfers. + /** + * Specifies the signal to use as the trigger source for transfers. + * + * The following string values might be valid for this feature: + * - \b Line0 (Display string: 'Line 0'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the transfer control trigger signal. + * - \b Line1 (Display string: 'Line 1'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the transfer control trigger signal. + * - \b Line2 (Display string: 'Line 2'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the transfer control trigger signal. + * - \b Line\#3\# (Display string: 'Line \#3\#'): Specifies which physical line (or pin) and associated I/O control block to use as external source for the transfer control trigger signal. + * - \b Counter0Start (Display string: 'Counter 0 Start'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter1Start (Display string: 'Counter 1 Start'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter2Start (Display string: 'Counter 2 Start'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter\#3\#Start (Display string: 'Counter \#3\# Start'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter0End (Display string: 'Counter 0 End'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter1End (Display string: 'Counter 1 End'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter2End (Display string: 'Counter 2 End'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Counter\#3\#End (Display string: 'Counter \#3\# End'): Specifies which of the Counter signal to use as internal source for the transfer control trigger signal. + * - \b Timer0Start (Display string: 'Timer 0 Start'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer1Start (Display string: 'Timer 1 Start'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer2Start (Display string: 'Timer 2 Start'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer\#3\#Start (Display string: 'Timer \#3\# Start'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer0End (Display string: 'Timer 0 End'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer1End (Display string: 'Timer 1 End'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer2End (Display string: 'Timer 2 End'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b Timer\#3\#End (Display string: 'Timer \#3\# End'): Specifies which Timer signal to use as internal source for the transfer control trigger signal. + * - \b LogicBlock0 (Display string: 'Logic Block 0'): Specifies which Logic Block to use as internal source for the transfer control trigger signal. + * - \b LogicBlock1 (Display string: 'Logic Block 1'): Specifies which Logic Block to use as internal source for the transfer control trigger signal. + * - \b LogicBlock2 (Display string: 'Logic Block 2'): Specifies which Logic Block to use as internal source for the transfer control trigger signal. + * - \b LogicBlock\#3\# (Display string: 'Logic Block \#3\#'): Specifies which Logic Block to use as internal source for the transfer control trigger signal. + * - \b SoftwareSignal0 (Display string: 'Software Signal 0'): Specifies which Software Signal to use as internal source for the transfer control trigger signal. + * - \b SoftwareSignal1 (Display string: 'Software Signal 1'): Specifies which Software Signal to use as internal source for the transfer control trigger signal. + * - \b SoftwareSignal2 (Display string: 'Software Signal 2'): Specifies which Software Signal to use as internal source for the transfer control trigger signal. + * - \b SoftwareSignal\#3\# (Display string: 'Software Signal \#3\#'): Specifies which Software Signal to use as internal source for the transfer control trigger signal. + * - \b Action0 (Display string: 'Action 0'): Specifies which Action command to use as internal source for the transfer control trigger signal. + * - \b Action1 (Display string: 'Action 1'): Specifies which Action command to use as internal source for the transfer control trigger signal. + * - \b Action2 (Display string: 'Action 2'): Specifies which Action command to use as internal source for the transfer control trigger signal. + * - \b Action\#3\# (Display string: 'Action \#3\#'): Specifies which Action command to use as internal source for the transfer control trigger signal. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferTriggerSource; + /// \brief An enumerated integer property. Specifies the activation mode of the transfer control trigger. + /** + * Specifies the activation mode of the transfer control trigger. + * + * The following string values might be valid for this feature: + * - \b RisingEdge (Display string: 'Rising Edge'): Specifies that the trigger is considered valid on the rising edge of the source signal. + * - \b FallingEdge (Display string: 'Falling Edge'): Specifies that the trigger is considered valid on the falling edge of the source signal. + * - \b AnyEdge (Display string: 'Any Edge'): Specifies that the trigger is considered valid on the falling or rising edge of the source signal. + * - \b LevelHigh (Display string: 'Level High'): Specifies that the trigger is considered valid as long as the level of the source signal is high. This can apply to TransferActive and TransferPause trigger. + * - \b LevelLow (Display string: 'Level Low'): Specifies that the trigger is considered valid as long as the level of the source signal is low. This can apply to TransferActive and TransferPause trigger. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferTriggerActivation; + /// \brief An enumerated integer property. Selects which status of the transfer module to read. + /** + * Selects which status of the transfer module to read. + * + * The following string values might be valid for this feature: + * - \b Streaming (Display string: 'Streaming'): Data blocks are transmitted when enough data is available. + * - \b Paused (Display string: 'Paused'): Data blocks transmission is suspended immediately. + * - \b Stopping (Display string: 'Stopping'): Data blocks transmission is stopping. The current block transmission will be completed and the transfer state will stop. + * - \b Stopped (Display string: 'Stopped'): Data blocks transmission is stopped. + * - \b QueueOverflow (Display string: 'Queue Overflow'): Data blocks queue is in overflow state. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferStatusSelector; + /// \brief A boolean property. Reads the status of the Transfer module signal selected by TransferStatusSelector. + /** + * Reads the status of the Transfer module signal selected by TransferStatusSelector. + */ + PropertyIBoolean transferStatus; + /// \brief An enumerated integer property. Selects the color component for the control of the TransferStreamChannel feature. + /** + * Selects the color component for the control of the TransferStreamChannel feature. + * + * The following string values might be valid for this feature: + * - \b Red (Display string: 'Red'): The TransferStreamChannel feature controls the index of the stream channel for the streaming of the red plane of the planar pixel formats. + * - \b Green (Display string: 'Green'): The TransferStreamChannel feature controls the index of the stream channel for the streaming of the green plane of the planar pixel formats. + * - \b Blue (Display string: 'Blue'): The TransferStreamChannel feature controls the index of the stream channel for the streaming of blue plane of the planar pixel formats. + * - \b All (Display string: 'All'): The TransferStreamChannel feature controls the index of the stream channel for the streaming of all the planes of the planar pixel formats simultaneously or non planar pixel formats. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 transferComponentSelector; + /// \brief An integer property. Selects the streaming channel that will be used to transfer the selected stream of data. + /** + * Selects the streaming channel that will be used to transfer the selected stream of data. In general, this feature can be omitted and the default streaming channel will be used. + */ + PropertyI64 transferStreamChannel; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category for control of 3D camera specific features. +/** + * A category for control of 3D camera specific features. + * \ingroup GenICamInterfaceDevice + */ +class Scan3dControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::Scan3dControl object. + explicit Scan3dControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + scan3dExtractionSelector(), + scan3dExtractionSource(), + scan3dExtractionMethod(), + scan3dDistanceUnit(), + scan3dCoordinateSystem(), + scan3dOutputMode(), + scan3dCoordinateSystemReference(), + scan3dCoordinateSelector(), + scan3dCoordinateScale(), + scan3dCoordinateOffset(), + scan3dInvalidDataFlag(), + scan3dInvalidDataValue(), + scan3dAxisMin(), + scan3dAxisMax(), + scan3dCoordinateTransformSelector(), + scan3dTransformValue(), + scan3dCoordinateReferenceSelector(), + scan3dCoordinateReferenceValue(), + scan3dFocalLength(), + scan3dBaseline(), + scan3dPrincipalPointU(), + scan3dPrincipalPointV() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( scan3dExtractionSelector, "Scan3dExtractionSelector" ); + locator.bindComponent( scan3dExtractionSource, "Scan3dExtractionSource" ); + locator.bindComponent( scan3dExtractionMethod, "Scan3dExtractionMethod" ); + locator.bindComponent( scan3dDistanceUnit, "Scan3dDistanceUnit" ); + locator.bindComponent( scan3dCoordinateSystem, "Scan3dCoordinateSystem" ); + locator.bindComponent( scan3dOutputMode, "Scan3dOutputMode" ); + locator.bindComponent( scan3dCoordinateSystemReference, "Scan3dCoordinateSystemReference" ); + locator.bindComponent( scan3dCoordinateSelector, "Scan3dCoordinateSelector" ); + locator.bindComponent( scan3dCoordinateScale, "Scan3dCoordinateScale" ); + locator.bindComponent( scan3dCoordinateOffset, "Scan3dCoordinateOffset" ); + locator.bindComponent( scan3dInvalidDataFlag, "Scan3dInvalidDataFlag" ); + locator.bindComponent( scan3dInvalidDataValue, "Scan3dInvalidDataValue" ); + locator.bindComponent( scan3dAxisMin, "Scan3dAxisMin" ); + locator.bindComponent( scan3dAxisMax, "Scan3dAxisMax" ); + locator.bindComponent( scan3dCoordinateTransformSelector, "Scan3dCoordinateTransformSelector" ); + locator.bindComponent( scan3dTransformValue, "Scan3dTransformValue" ); + locator.bindComponent( scan3dCoordinateReferenceSelector, "Scan3dCoordinateReferenceSelector" ); + locator.bindComponent( scan3dCoordinateReferenceValue, "Scan3dCoordinateReferenceValue" ); + locator.bindComponent( scan3dFocalLength, "Scan3dFocalLength" ); + locator.bindComponent( scan3dBaseline, "Scan3dBaseline" ); + locator.bindComponent( scan3dPrincipalPointU, "Scan3dPrincipalPointU" ); + locator.bindComponent( scan3dPrincipalPointV, "Scan3dPrincipalPointV" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the 3DExtraction processing module to control (if multiple ones are present). + /** + * Selects the 3DExtraction processing module to control (if multiple ones are present). + * + * The following string values might be valid for this feature: + * - \b Scan3dExtraction0 (Display string: 'Scan 3d Extraction 0'): Selects Scan3d Extraction module 0. + * - \b Scan3dExtraction1 (Display string: 'Scan 3d Extraction 1'): Selects Scan3d Extraction module 1. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dExtractionSelector; + /// \brief An enumerated integer property. Selects the sensor's data source region for 3D Extraction module. + /** + * Selects the sensor's data source region for 3D Extraction module. + * + * The following string values might be valid for this feature: + * - \b Region0 (Display string: 'Region 0'): Data come from Sensor's Region0. + * - \b Region1 (Display string: 'Region 1'): Data come from Sensor's Region1. + * - \b Region\#2\# (Display string: 'Region \#2\#'): Data come from Sensor's Region\#2\#. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dExtractionSource; + /// \brief An enumerated integer property. Selects the method for extracting 3D from the input sensor data. + /** + * Selects the method for extracting 3D from the input sensor data. + * + * The following string values might be valid for this feature: + * - \b Default (Display string: 'Default'): Default range extraction method for the device. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dExtractionMethod; + /// \brief An enumerated integer property. Specifies the unit used when delivering (calibrated) distance data. + /** + * Specifies the unit used when delivering (calibrated) distance data. + * + * The following string values might be valid for this feature: + * - \b Millimeter (Display string: 'Millimeter'): Distance values are in millimeter units (default). + * - \b Meter (Display string: 'Meter'): Distance values are in meter units. + * - \b Inch (Display string: 'Inch'): Distance values are in inch units. + * - \b Pixel (Display string: 'Pixel'): Distance values are given as a multiple of the size of a pixel. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dDistanceUnit; + /// \brief An enumerated integer property. Specifies the Coordinate system to use for the device. + /** + * Specifies the Coordinate system to use for the device. + * + * The following string values might be valid for this feature: + * - \b Cartesian (Display string: 'Cartesian'): Default value. 3-axis orthogonal, right-hand X-Y-Z. + * - \b Spherical (Display string: 'Spherical'): A Theta-Phi-Rho coordinate system. + * - \b Cylindrical (Display string: 'Cylindrical'): A Theta-Y-Rho coordinate system. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dCoordinateSystem; + /// \brief An enumerated integer property. Controls the Calibration and data organization of the device and the coordinates transmitted. + /** + * Controls the Calibration and data organization of the device and the coordinates transmitted. + * + * The following string values might be valid for this feature: + * - \b UncalibratedC (Display string: 'Uncalibrated C'): Uncalibrated 2.5D Depth map. The distance data does not represent a physical unit and may be non-linear. The data is a 2.5D range map only. + * - \b CalibratedABC_Grid (Display string: 'Calibrated ABC Grid'): 3 Coordinates in grid organization. The full 3 coordinate data with the grid array organization from the sensor kept. + * - \b CalibratedABC_PointCloud (Display string: 'Calibrated ABC Point Cloud'): 3 Coordinates without organization. The full 3 coordinate data without any organization of data points. Typically only valid points transmitted giving varying image size. + * - \b CalibratedAC (Display string: 'Calibrated AC'): 2 Coordinates with fixed B sampling. The data is sent as a A and C coordinates (X,Z or Theta,Rho). The B (Y) axis uses the scale and offset parameters for the B axis. + * - \b CalibratedAC_Linescan (Display string: 'Calibrated AC Linescan'): 2 Coordinates with varying sampling. The data is sent as a A and C coordinates (X,Z or Theta,Rho). The B (Y) axis comes from the encoder chunk value. + * - \b CalibratedC (Display string: 'Calibrated C'): Calibrated 2.5D Depth map. The distance data is expressed in the chosen distance unit. The data is a 2.5D range map. No information on X-Y axes available. + * - \b CalibratedC_Linescan (Display string: 'Calibrated C Linescan'): Depth Map with varying B sampling. The distance data is expressed in the chosen distance unit. The data is a 2.5D range map. The B (Y) axis comes from the encoder chunk value. + * - \b RectifiedC (Display string: 'Rectified C'): Rectified 2.5D Depth map. The distance data has been rectified to a uniform sampling pattern in the X and Y direction. The data is a 2.5D range map only. If a complete 3D point cloud is rectified but transmitted as explicit coordinates it should be transmitted as one of the 'CalibratedABC' formats. + * - \b RectifiedC_Linescan (Display string: 'Rectified C Linescan'): Rectified 2.5D Depth map with varying B sampling. The data is sent as rectified 1D profiles using Coord3D_C pixels. The B (Y) axis comes from the encoder chunk value. + * - \b DisparityC (Display string: 'Disparity C'): Disparity 2.5D Depth map. The distance is inversely proportional to the pixel (disparity) value. + * - \b DisparityC_Linescan (Display string: 'Disparity C Linescan'): Disparity 2.5D Depth map with varying B sampling. The distance is inversely proportional to the pixel (disparity) value. The B (Y) axis comes from the encoder chunk value. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dOutputMode; + /// \brief An enumerated integer property. Defines coordinate system reference location. + /** + * Defines coordinate system reference location. + * + * The following string values might be valid for this feature: + * - \b Anchor (Display string: 'Anchor'): Default value. Original fixed reference. The coordinate system fixed relative the camera reference point marker is used. + * - \b Transformed (Display string: 'Transformed'): Transformed reference system. The transformed coordinate system is used according to the definition in the rotation and translation matrices. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dCoordinateSystemReference; + /// \brief An enumerated integer property. Selects the individual coordinates in the vectors for 3D information/transformation. + /** + * Selects the individual coordinates in the vectors for 3D information/transformation. + * + * The following string values might be valid for this feature: + * - \b CoordinateA (Display string: 'Coordinate A'): The first (X or Theta) coordinate + * - \b CoordinateB (Display string: 'Coordinate B'): The second (Y or Phi) coordinate + * - \b CoordinateC (Display string: 'Coordinate C'): The third (Z or Rho) coordinate. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dCoordinateSelector; + /// \brief A floating point property. Scale factor when transforming a pixel from relative coordinates to world coordinates. + /** + * Scale factor when transforming a pixel from relative coordinates to world coordinates. + */ + PropertyF scan3dCoordinateScale; + /// \brief A floating point property. Offset when transforming a pixel from relative coordinates to world coordinates. + /** + * Offset when transforming a pixel from relative coordinates to world coordinates. + */ + PropertyF scan3dCoordinateOffset; + /// \brief A boolean property. Enables the definition of a non-valid flag value in the data stream. + /** + * Enables the definition of a non-valid flag value in the data stream. Note that the confidence output is an alternate recommended way to identify non-valid pixels. Using a Scan3dInvalidDataValue may give processing penalties due to special handling. + */ + PropertyIBoolean scan3dInvalidDataFlag; + /// \brief A floating point property. Value which identifies a non-valid pixel if Scan3dInvalidDataFlag is enabled. + /** + * Value which identifies a non-valid pixel if Scan3dInvalidDataFlag is enabled. + */ + PropertyF scan3dInvalidDataValue; + /// \brief A floating point property. Minimum valid transmitted coordinate value of the selected Axis. + /** + * Minimum valid transmitted coordinate value of the selected Axis. + */ + PropertyF scan3dAxisMin; + /// \brief A floating point property. Maximum valid transmitted coordinate value of the selected Axis. + /** + * Maximum valid transmitted coordinate value of the selected Axis. + */ + PropertyF scan3dAxisMax; + /// \brief An enumerated integer property. Sets the index to read/write a coordinate transform value. + /** + * Sets the index to read/write a coordinate transform value. + * + * The following string values might be valid for this feature: + * - \b RotationX (Display string: 'Rotation X'): Rotation around X axis. + * - \b RotationY (Display string: 'Rotation Y'): Rotation around Y axis. + * - \b RotationZ (Display string: 'Rotation Z'): Rotation around Z axis. + * - \b TranslationX (Display string: 'Translation X'): Translation along X axis. + * - \b TranslationY (Display string: 'Translation Y'): Translation along Y axis. + * - \b TranslationZ (Display string: 'Translation Z'): Translation along Z axis. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dCoordinateTransformSelector; + /// \brief A floating point property. Specifies the transform value selected. + /** + * Specifies the transform value selected. For translations (Scan3dCoordinateTransformSelector = TranslationX/Y/Z) it is expressed in the distance unit of the system, for rotations (Scan3dCoordinateTransformSelector =RotationX/Y/Z) in degrees. + */ + PropertyF scan3dTransformValue; + /// \brief An enumerated integer property. Sets the index to read a coordinate system reference value defining the transform of a point from the current (Anchor or Transformed) system to the reference system. + /** + * Sets the index to read a coordinate system reference value defining the transform of a point from the current (Anchor or Transformed) system to the reference system. + * + * The following string values might be valid for this feature: + * - \b RotationX (Display string: 'Rotation X'): Rotation around X axis. + * - \b RotationY (Display string: 'Rotation Y'): Rotation around Y axis. + * - \b RotationZ (Display string: 'Rotation Z'): Rotation around Z axis. + * - \b TranslationX (Display string: 'Translation X'): X axis translation. + * - \b TranslationY (Display string: 'Translation Y'): Y axis translation. + * - \b TranslationZ (Display string: 'Translation Z'): Z axis translation. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 scan3dCoordinateReferenceSelector; + /// \brief A floating point property. Returns the reference value selected. + /** + * Returns the reference value selected. Reads the value of a rotation or translation value for the current (Anchor or Transformed) coordinate system transformation to the Reference system. + */ + PropertyF scan3dCoordinateReferenceValue; + /// \brief A floating point property. Returns the focal length of the camera in pixel. + /** + * Returns the focal length of the camera in pixel. The focal length depends on the selected region. The value of this feature takes into account horizontal binning, decimation, or any other function changing the image resolution. + */ + PropertyF scan3dFocalLength; + /// \brief A floating point property. Returns the baseline as the physical distance of two cameras in a stereo camera setup. + /** + * Returns the baseline as the physical distance of two cameras in a stereo camera setup. The value of this feature can be used for 3D reconstruction from disparity images. In this case, the unit of the 3D coordinates corresponds to the unit of the baseline. + */ + PropertyF scan3dBaseline; + /// \brief A floating point property. Returns the value of the horizontal position of the principal point, relative to the region origin, i.e. + /** + * Returns the value of the horizontal position of the principal point, relative to the region origin, i.e. OffsetX. The value of this feature takes into account horizontal binning, decimation, or any other function changing the image resolution. + */ + PropertyF scan3dPrincipalPointU; + /// \brief A floating point property. Returns the value of the vertical position of the principal point, relative to the region origin, i.e. + /** + * Returns the value of the vertical position of the principal point, relative to the region origin, i.e. OffsetY. The value of this feature takes into account vertical binning, decimation, or any other function changing the image resolution. + */ + PropertyF scan3dPrincipalPointV; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category containing the Lighting control features. +/** + * A category containing the Lighting control features. + * \ingroup GenICamInterfaceDevice + */ +class LightControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::LightControl object. + explicit LightControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + lightControllerSelector(), + lightControllerSource(), + lightCurrentRating(), + lightVoltageRating(), + lightBrightness(), + lightConnectionStatus(), + lightCurrentMeasured(), + lightVoltageMeasured() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( lightControllerSelector, "LightControllerSelector" ); + locator.bindComponent( lightControllerSource, "LightControllerSource" ); + locator.bindComponent( lightCurrentRating, "LightCurrentRating" ); + locator.bindComponent( lightVoltageRating, "LightVoltageRating" ); + locator.bindComponent( lightBrightness, "LightBrightness" ); + locator.bindComponent( lightConnectionStatus, "LightConnectionStatus" ); + locator.bindComponent( lightCurrentMeasured, "LightCurrentMeasured" ); + locator.bindComponent( lightVoltageMeasured, "LightVoltageMeasured" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the Light Controller to configure. + /** + * Selects the Light Controller to configure. + * + * The following string values might be valid for this feature: + * - \b LightController0 (Display string: 'Light Controller 0'): Light Controller 0 + * - \b LightController1 (Display string: 'Light Controller 1'): Light Controller 1 + * - \b LightController2 (Display string: 'Light Controller 2'): Light Controller 2 + * - \b LightController\#3\# (Display string: 'Light Controller \#3\#'): Light Controller \#3\# + * - \b LightController3 (Display string: 'Light Controller 3'): Light Controller 3 + * - \b LightController4 (Display string: 'Light Controller 4'): Light Controller 4 + * - \b LightController5 (Display string: 'Light Controller 5'): Light Controller 5 + * - \b LightController6 (Display string: 'Light Controller 6'): Light Controller 6 + * - \b LightController7 (Display string: 'Light Controller 7'): Light Controller 7 + * - \b LightController8 (Display string: 'Light Controller 8'): Light Controller 8 + * - \b LightController9 (Display string: 'Light Controller 9'): Light Controller 9 + * - \b LightController10 (Display string: 'Light Controller 10'): Light Controller 10 + * - \b LightController11 (Display string: 'Light Controller 11'): Light Controller 11 + * - \b LightController12 (Display string: 'Light Controller 12'): Light Controller 12 + * - \b LightController13 (Display string: 'Light Controller 13'): Light Controller 13 + * - \b LightController14 (Display string: 'Light Controller 14'): Light Controller 14 + * - \b LightController15 (Display string: 'Light Controller 15'): Light Controller 15 + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 lightControllerSelector; + /// \brief An enumerated integer property. Selects the input source signal of the Light Controller. + /** + * Selects the input source signal of the Light Controller. + * + * The following string values might be valid for this feature: + * - \b Line0 (Display string: 'Line 0'): Line 0 + * - \b Line\#1\# (Display string: 'Line \#1\#'): Line \#1\# + * - \b Timer0 (Display string: 'Timer 0'): Timer 0 + * - \b Timer\#1\# (Display string: 'Timer \#1\#'): Timer \#1\# + * - \b Counter0 (Display string: 'Counter 0'): Counter 0 + * - \b Counter\#1\# (Display string: 'Counter \#1\#'): Counter \#1\# + * - \b UserOutput0 (Display string: 'User Output 0'): User Output 0 + * - \b UserOutput\#1\# (Display string: 'User Output \#1\#'): User Output \#1\# + * - \b Line1 (Display string: 'Line 1'): Line 1 + * - \b Line2 (Display string: 'Line 2'): Line 2 + * - \b Line3 (Display string: 'Line 3'): Line 3 + * - \b Line4 (Display string: 'Line 4'): Line 4 + * - \b Line5 (Display string: 'Line 5'): Line 5 + * - \b Line6 (Display string: 'Line 6'): Line 6 + * - \b Line7 (Display string: 'Line 7'): Line 7 + * - \b Line8 (Display string: 'Line 8'): Line 8 + * - \b Line9 (Display string: 'Line 9'): Line 9 + * - \b Line10 (Display string: 'Line 10'): Line 10 + * - \b Line11 (Display string: 'Line 11'): Line 11 + * - \b Line12 (Display string: 'Line 12'): Line 12 + * - \b Line13 (Display string: 'Line 13'): Line 13 + * - \b Line14 (Display string: 'Line 14'): Line 14 + * - \b Line15 (Display string: 'Line 15'): Line 15 + * - \b Timer1 (Display string: 'Timer 1'): Timer 1 + * - \b Timer2 (Display string: 'Timer 2'): Timer 2 + * - \b Timer3 (Display string: 'Timer 3'): Timer 3 + * - \b Timer4 (Display string: 'Timer 4'): Timer 4 + * - \b Timer5 (Display string: 'Timer 5'): Timer 5 + * - \b Timer6 (Display string: 'Timer 6'): Timer 6 + * - \b Timer7 (Display string: 'Timer 7'): Timer 7 + * - \b Timer8 (Display string: 'Timer 8'): Timer 8 + * - \b Timer9 (Display string: 'Timer 9'): Timer 9 + * - \b Timer10 (Display string: 'Timer 10'): Timer 10 + * - \b Timer11 (Display string: 'Timer 11'): Timer 11 + * - \b Timer12 (Display string: 'Timer 12'): Timer 12 + * - \b Timer13 (Display string: 'Timer 13'): Timer 13 + * - \b Timer14 (Display string: 'Timer 14'): Timer 14 + * - \b Timer15 (Display string: 'Timer 15'): Timer 15 + * - \b Counter1 (Display string: 'Counter 1'): Counter 1 + * - \b Counter2 (Display string: 'Counter 2'): Counter 2 + * - \b Counter3 (Display string: 'Counter 3'): Counter 3 + * - \b Counter4 (Display string: 'Counter 4'): Counter 4 + * - \b Counter5 (Display string: 'Counter 5'): Counter 5 + * - \b Counter6 (Display string: 'Counter 6'): Counter 6 + * - \b Counter7 (Display string: 'Counter 7'): Counter 7 + * - \b Counter8 (Display string: 'Counter 8'): Counter 8 + * - \b Counter9 (Display string: 'Counter 9'): Counter 9 + * - \b Counter10 (Display string: 'Counter 10'): Counter 10 + * - \b Counter11 (Display string: 'Counter 11'): Counter 11 + * - \b Counter12 (Display string: 'Counter 12'): Counter 12 + * - \b Counter13 (Display string: 'Counter 13'): Counter 13 + * - \b Counter14 (Display string: 'Counter 14'): Counter 14 + * - \b Counter15 (Display string: 'Counter 15'): Counter 15 + * - \b UserOutput1 (Display string: 'User Output 1'): User Output 1 + * - \b UserOutput2 (Display string: 'User Output 2'): User Output 2 + * - \b UserOutput3 (Display string: 'User Output 3'): User Output 3 + * - \b UserOutput4 (Display string: 'User Output 4'): User Output 4 + * - \b UserOutput5 (Display string: 'User Output 5'): User Output 5 + * - \b UserOutput6 (Display string: 'User Output 6'): User Output 6 + * - \b UserOutput7 (Display string: 'User Output 7'): User Output 7 + * - \b UserOutput8 (Display string: 'User Output 8'): User Output 8 + * - \b UserOutput9 (Display string: 'User Output 9'): User Output 9 + * - \b UserOutput10 (Display string: 'User Output 10'): User Output 10 + * - \b UserOutput11 (Display string: 'User Output 11'): User Output 11 + * - \b UserOutput12 (Display string: 'User Output 12'): User Output 12 + * - \b UserOutput13 (Display string: 'User Output 13'): User Output 13 + * - \b UserOutput14 (Display string: 'User Output 14'): User Output 14 + * - \b UserOutput15 (Display string: 'User Output 15'): User Output 15 + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 lightControllerSource; + /// \brief A floating point property. Set the current rating of the lighting output. + /** + * Set the current rating of the lighting output. + */ + PropertyF lightCurrentRating; + /// \brief A floating point property. Set the voltage rating of the lighting output. + /** + * Set the voltage rating of the lighting output. + */ + PropertyF lightVoltageRating; + /// \brief A floating point property. Set the brightness of the lighting output in percent. + /** + * Set the brightness of the lighting output in percent. Can be greater than 100% for short overdrive period. + */ + PropertyF lightBrightness; + /// \brief An enumerated integer property. Status of a light connected to the controller's output Line. + /** + * Status of a light connected to the controller's output Line. + * + * The following string values might be valid for this feature: + * - \b Sensing (Display string: 'Sensing'): Sensing + * - \b Ready (Display string: 'Ready'): Ready + * - \b NoConnect (Display string: 'No Connect'): No Connect + * - \b Error (Display string: 'Error'): Error + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 lightConnectionStatus; + /// \brief A floating point property. The measured current applied to the lighting. + /** + * The measured current applied to the lighting. + */ + PropertyF lightCurrentMeasured; + /// \brief A floating point property. The measured voltage applied to the lighting. + /** + * The measured voltage applied to the lighting. + */ + PropertyF lightVoltageMeasured; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the Chunk Data control features. +/** + * A category that contains the Chunk Data control features. + * \ingroup GenICamInterfaceDevice + */ +class ChunkDataControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::ChunkDataControl object. + explicit ChunkDataControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + chunkModeActive(), + chunkXMLEnable(), + chunkSelector(), + chunkEnable(), + chunkRegionSelector(), + chunkRegionID(), + chunkRegionIDValue(), + chunkComponentSelector(), + chunkComponentID(), + chunkComponentIDValue(), + chunkGroupSelector(), + chunkGroupID(), + chunkImageComponent(), + chunkGroupIDValue(), + chunkPartSelector(), + chunkImage(), + chunkOffsetX(), + chunkOffsetY(), + chunkWidth(), + chunkHeight(), + chunkPixelFormat(), + chunkPixelDynamicRangeMin(), + chunkPixelDynamicRangeMax(), + chunkBinningHorizontal(), + chunkBinningVertical(), + chunkDecimationHorizontal(), + chunkDecimationVertical(), + chunkReverseX(), + chunkReverseY(), + chunkTimestamp(), + chunkTimestampLatchValue(), + chunkLineStatusAll(), + chunkCounterSelector(), + chunkCounterValue(), + chunkTimerSelector(), + chunkTimerValue(), + chunkScanLineSelector(), + chunkEncoderSelector(), + chunkEncoderValue(), + chunkEncoderStatus(), + chunkExposureTimeSelector(), + chunkExposureTime(), + chunkGainSelector(), + chunkGain(), + chunkBlackLevelSelector(), + chunkBlackLevel(), + chunkLinePitch(), + chunkFrameID(), + chunkSourceSelector(), + chunkSourceID(), + chunkSourceIDValue(), + chunkTransferBlockID(), + chunkTransferStreamID(), + chunkTransferQueueCurrentBlockCount(), + chunkStreamChannelID(), + chunkSequencerSetActive(), + chunkScan3dDistanceUnit(), + chunkScan3dOutputMode(), + chunkScan3dCoordinateSystem(), + chunkScan3dCoordinateSystemReference(), + chunkScan3dCoordinateSelector(), + chunkScan3dCoordinateScale(), + chunkScan3dCoordinateOffset(), + chunkScan3dInvalidDataFlag(), + chunkScan3dInvalidDataValue(), + chunkScan3dAxisMin(), + chunkScan3dAxisMax(), + chunkScan3dCoordinateTransformSelector(), + chunkScan3dTransformValue(), + chunkScan3dCoordinateReferenceSelector(), + chunkScan3dCoordinateReferenceValue(), + chunkScan3dFocalLength(), + chunkScan3dBaseline(), + chunkScan3dPrincipalPointU(), + chunkScan3dPrincipalPointV(), + mvChunkJPEG(), + chunkmvCustomIdentifier() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( chunkModeActive, "ChunkModeActive" ); + locator.bindComponent( chunkXMLEnable, "ChunkXMLEnable" ); + locator.bindComponent( chunkSelector, "ChunkSelector" ); + locator.bindComponent( chunkEnable, "ChunkEnable" ); + locator.bindComponent( chunkRegionSelector, "ChunkRegionSelector" ); + locator.bindComponent( chunkRegionID, "ChunkRegionID" ); + locator.bindComponent( chunkRegionIDValue, "ChunkRegionIDValue" ); + locator.bindComponent( chunkComponentSelector, "ChunkComponentSelector" ); + locator.bindComponent( chunkComponentID, "ChunkComponentID" ); + locator.bindComponent( chunkComponentIDValue, "ChunkComponentIDValue" ); + locator.bindComponent( chunkGroupSelector, "ChunkGroupSelector" ); + locator.bindComponent( chunkGroupID, "ChunkGroupID" ); + locator.bindComponent( chunkImageComponent, "ChunkImageComponent" ); + locator.bindComponent( chunkGroupIDValue, "ChunkGroupIDValue" ); + locator.bindComponent( chunkPartSelector, "ChunkPartSelector" ); + locator.bindComponent( chunkImage, "ChunkImage" ); + locator.bindComponent( chunkOffsetX, "ChunkOffsetX" ); + locator.bindComponent( chunkOffsetY, "ChunkOffsetY" ); + locator.bindComponent( chunkWidth, "ChunkWidth" ); + locator.bindComponent( chunkHeight, "ChunkHeight" ); + locator.bindComponent( chunkPixelFormat, "ChunkPixelFormat" ); + locator.bindComponent( chunkPixelDynamicRangeMin, "ChunkPixelDynamicRangeMin" ); + if( !chunkPixelDynamicRangeMin.isValid() ) + { + locator.bindComponent( chunkPixelDynamicRangeMin, "ChunkDynamicRangeMin" ); + } + locator.bindComponent( chunkPixelDynamicRangeMax, "ChunkPixelDynamicRangeMax" ); + if( !chunkPixelDynamicRangeMax.isValid() ) + { + locator.bindComponent( chunkPixelDynamicRangeMax, "ChunkDynamicRangeMax" ); + } + locator.bindComponent( chunkBinningHorizontal, "ChunkBinningHorizontal" ); + locator.bindComponent( chunkBinningVertical, "ChunkBinningVertical" ); + locator.bindComponent( chunkDecimationHorizontal, "ChunkDecimationHorizontal" ); + locator.bindComponent( chunkDecimationVertical, "ChunkDecimationVertical" ); + locator.bindComponent( chunkReverseX, "ChunkReverseX" ); + locator.bindComponent( chunkReverseY, "ChunkReverseY" ); + locator.bindComponent( chunkTimestamp, "ChunkTimestamp" ); + locator.bindComponent( chunkTimestampLatchValue, "ChunkTimestampLatchValue" ); + locator.bindComponent( chunkLineStatusAll, "ChunkLineStatusAll" ); + locator.bindComponent( chunkCounterSelector, "ChunkCounterSelector" ); + locator.bindComponent( chunkCounterValue, "ChunkCounterValue" ); + if( !chunkCounterValue.isValid() ) + { + locator.bindComponent( chunkCounterValue, "ChunkCounter" ); + } + locator.bindComponent( chunkTimerSelector, "ChunkTimerSelector" ); + locator.bindComponent( chunkTimerValue, "ChunkTimerValue" ); + if( !chunkTimerValue.isValid() ) + { + locator.bindComponent( chunkTimerValue, "ChunkTimer" ); + } + locator.bindComponent( chunkScanLineSelector, "ChunkScanLineSelector" ); + locator.bindComponent( chunkEncoderSelector, "ChunkEncoderSelector" ); + locator.bindComponent( chunkEncoderValue, "ChunkEncoderValue" ); + locator.bindComponent( chunkEncoderStatus, "ChunkEncoderStatus" ); + locator.bindComponent( chunkExposureTimeSelector, "ChunkExposureTimeSelector" ); + locator.bindComponent( chunkExposureTime, "ChunkExposureTime" ); + locator.bindComponent( chunkGainSelector, "ChunkGainSelector" ); + locator.bindComponent( chunkGain, "ChunkGain" ); + locator.bindComponent( chunkBlackLevelSelector, "ChunkBlackLevelSelector" ); + locator.bindComponent( chunkBlackLevel, "ChunkBlackLevel" ); + locator.bindComponent( chunkLinePitch, "ChunkLinePitch" ); + locator.bindComponent( chunkFrameID, "ChunkFrameID" ); + locator.bindComponent( chunkSourceSelector, "ChunkSourceSelector" ); + locator.bindComponent( chunkSourceID, "ChunkSourceID" ); + locator.bindComponent( chunkSourceIDValue, "ChunkSourceIDValue" ); + locator.bindComponent( chunkTransferBlockID, "ChunkTransferBlockID" ); + locator.bindComponent( chunkTransferStreamID, "ChunkTransferStreamID" ); + locator.bindComponent( chunkTransferQueueCurrentBlockCount, "ChunkTransferQueueCurrentBlockCount" ); + locator.bindComponent( chunkStreamChannelID, "ChunkStreamChannelID" ); + locator.bindComponent( chunkSequencerSetActive, "ChunkSequencerSetActive" ); + locator.bindComponent( chunkScan3dDistanceUnit, "ChunkScan3dDistanceUnit" ); + locator.bindComponent( chunkScan3dOutputMode, "ChunkScan3dOutputMode" ); + locator.bindComponent( chunkScan3dCoordinateSystem, "ChunkScan3dCoordinateSystem" ); + locator.bindComponent( chunkScan3dCoordinateSystemReference, "ChunkScan3dCoordinateSystemReference" ); + locator.bindComponent( chunkScan3dCoordinateSelector, "ChunkScan3dCoordinateSelector" ); + locator.bindComponent( chunkScan3dCoordinateScale, "ChunkScan3dCoordinateScale" ); + locator.bindComponent( chunkScan3dCoordinateOffset, "ChunkScan3dCoordinateOffset" ); + locator.bindComponent( chunkScan3dInvalidDataFlag, "ChunkScan3dInvalidDataFlag" ); + locator.bindComponent( chunkScan3dInvalidDataValue, "ChunkScan3dInvalidDataValue" ); + locator.bindComponent( chunkScan3dAxisMin, "ChunkScan3dAxisMin" ); + locator.bindComponent( chunkScan3dAxisMax, "ChunkScan3dAxisMax" ); + locator.bindComponent( chunkScan3dCoordinateTransformSelector, "ChunkScan3dCoordinateTransformSelector" ); + locator.bindComponent( chunkScan3dTransformValue, "ChunkScan3dTransformValue" ); + locator.bindComponent( chunkScan3dCoordinateReferenceSelector, "ChunkScan3dCoordinateReferenceSelector" ); + locator.bindComponent( chunkScan3dCoordinateReferenceValue, "ChunkScan3dCoordinateReferenceValue" ); + locator.bindComponent( chunkScan3dFocalLength, "ChunkScan3dFocalLength" ); + locator.bindComponent( chunkScan3dBaseline, "ChunkScan3dBaseline" ); + locator.bindComponent( chunkScan3dPrincipalPointU, "ChunkScan3dPrincipalPointU" ); + locator.bindComponent( chunkScan3dPrincipalPointV, "ChunkScan3dPrincipalPointV" ); + locator.bindComponent( mvChunkJPEG, "mvChunkJPEG" ); + locator.bindComponent( chunkmvCustomIdentifier, "ChunkmvCustomIdentifier" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A boolean property. Activates the inclusion of Chunk data in the transmitted payload. + /** + * Activates the inclusion of Chunk data in the transmitted payload. + */ + PropertyIBoolean chunkModeActive; + /// \brief A boolean property. Activates the inclusion of the GenICam XML necessary to the chunk parser to decode all the Chunk data included in the transmitted payload. + /** + * Activates the inclusion of the GenICam XML necessary to the chunk parser to decode all the Chunk data included in the transmitted payload. + */ + PropertyIBoolean chunkXMLEnable; + /// \brief An enumerated integer property. Selects which Chunk to enable or control. + /** + * Selects which Chunk to enable or control. + * + * The following string values might be valid for this feature: + * - \b Image (Display string: 'Image'): Image + * - \b OffsetX (Display string: 'Offset X'): Offset X + * - \b OffsetY (Display string: 'Offset Y'): Offset Y + * - \b Width (Display string: 'Width'): Width + * - \b Height (Display string: 'Height'): Height + * - \b PixelFormat (Display string: 'Pixel Format'): Pixel Format + * - \b PixelDynamicRangeMin (Display string: 'Pixel Dynamic Range Min'): Pixel Dynamic Range Min + * - \b PixelDynamicRangeMax (Display string: 'Pixel Dynamic Range Max'): Pixel Dynamic Range Max + * - \b BinningHorizontal (Display string: 'Binning Horizontal'): Binning Horizontal + * - \b BinningVertical (Display string: 'Binning Vertical'): Binning Vertical + * - \b DecimationHorizontal (Display string: 'Decimation Horizontal'): Decimation Horizontal + * - \b DecimationVertical (Display string: 'Decimation Vertical'): Decimation Vertical + * - \b ReverseX (Display string: 'Reverse X'): Reverse X + * - \b ReverseY (Display string: 'Reverse Y'): Reverse Y + * - \b Timestamp (Display string: 'Timestamp'): Timestamp + * - \b TimestampLatchValue (Display string: 'Timestamp Latch Value'): Timestamp Latch Value + * - \b LineStatusAll (Display string: 'Line Status All'): Line Status All + * - \b CounterValue (Display string: 'Counter Value'): Counter Value + * - \b TimerValue (Display string: 'Timer Value'): Timer Value + * - \b EncoderValue (Display string: 'Encoder Value'): Encoder Value + * - \b EncoderStatusValue (Display string: 'Encoder Status Value'): Encoder Status Value + * - \b ExposureTime (Display string: 'Exposure Time'): Exposure Time + * - \b Gain (Display string: 'Gain'): Gain + * - \b BlackLevel (Display string: 'Black Level'): Black Level + * - \b LinePitch (Display string: 'Line Pitch'): Line Pitch + * - \b FrameID (Display string: 'Frame ID'): Frame ID + * - \b SourceID (Display string: 'Source ID'): Source ID + * - \b SourceIDValue (Display string: 'Source ID Value'): Source ID Value + * - \b RegionID (Display string: 'Region ID'): Region ID + * - \b RegionIDValue (Display string: 'Region ID Value'): Region ID Value + * - \b ComponentID (Display string: 'Component ID'): Component ID + * - \b ComponentIDValue (Display string: 'Component ID Value'): Component ID Value + * - \b GroupIDValue (Display string: 'Group ID Value'): Group ID Value + * - \b TransferBlockID (Display string: 'Transfer Block ID'): Transfer Block ID + * - \b TransferStreamID (Display string: 'Transfer Stream ID'): Transfer Stream ID + * - \b TransferQueueCurrentBlockCount (Display string: 'Transfer Queue Current Block Count'): Transfer Queue Current Block Count + * - \b StreamChannelID (Display string: 'Stream Channel ID'): Stream Channel ID + * - \b SequencerSetActive (Display string: 'Sequencer Set Active'): Sequencer Set Active + * - \b Scan3dDistanceUnit (Display string: 'Scan 3d Distance Unit'): Scan 3d Distance Unit + * - \b Scan3dOutputMode (Display string: 'Scan 3d Output Mode'): Scan 3d Output Mode + * - \b Scan3dCoordinateSystem (Display string: 'Scan 3d Coordinate System'): Scan 3d Coordinate System + * - \b Scan3dCoordinateSystemReference (Display string: 'Scan 3d Coordinate System Reference'): Scan 3d Coordinate System Reference + * - \b Scan3dCoordinateScale (Display string: 'Scan 3d Coordinate Scale'): Scan 3d Coordinate Scale + * - \b Scan3dCoordinateOffset (Display string: 'Scan 3d Coordinate Offset'): Scan 3d Coordinate Offset + * - \b Scan3dInvalidDataFlag (Display string: 'Scan 3d Invalid Data Flag'): Scan 3d Invalid Data Flag + * - \b Scan3dInvalidDataValue (Display string: 'Scan 3d Invalid Data Value'): Scan 3d Invalid Data Value + * - \b Scan3dAxisMin (Display string: 'Scan 3d Axis Min'): Scan 3d Axis Min + * - \b Scan3dAxisMax (Display string: 'Scan 3d Axis Max'): Scan 3d Axis Max + * - \b Scan3dCoordinateTransformValue (Display string: 'Scan 3d Coordinate Transform Value'): Scan 3d Coordinate Transform Value + * - \b Scan3dCoordinateReferenceValue (Display string: 'Scan 3d Coordinate Reference Value'): Scan 3d Coordinate Reference Value + * - \b AdditionalInfo (Display string: 'Additional Info') + * - \b JPEG (Display string: 'JPEG') + * - \b mvCustomIdentifier (Display string: 'mv Custom Identifier') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkSelector; + /// \brief A boolean property. Enables the inclusion of the selected Chunk data in the payload of the image. + /** + * Enables the inclusion of the selected Chunk data in the payload of the image. + */ + PropertyIBoolean chunkEnable; + /// \brief An enumerated integer property. Selects which Region to retrieve data from. + /** + * Selects which Region to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Region0 (Display string: 'Region 0'): Image comes from the Region 0. + * - \b Region1 (Display string: 'Region 1'): Image comes from the Region 1. + * - \b Region2 (Display string: 'Region 2'): Image comes from the Region 2. + * - \b Region\#3\# (Display string: 'Region \#3\#'): Image comes from the Region \#3\#. + * - \b Scan3dExtraction0 (Display string: 'Scan 3d Extraction 0'): Image comes from the Scan3dExtraction output Region 0. + * - \b Scan3dExtraction1 (Display string: 'Scan 3d Extraction 1'): Image comes from the Scan3dExtraction output Region 1. + * - \b Scan3dExtraction2 (Display string: 'Scan 3d Extraction 2'): Image comes from the Scan3dExtraction output Region 2. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkRegionSelector; + /// \brief An enumerated integer property. Returns the Identifier of Region that the image comes from. + /** + * Returns the Identifier of Region that the image comes from. + * + * The following string values might be valid for this feature: + * - \b Region0 (Display string: 'Region 0'): Image comes from the Region 0. + * - \b Region1 (Display string: 'Region 1'): Image comes from the Region 1. + * - \b Region2 (Display string: 'Region 2'): Image comes from the Region 2. + * - \b Region\#3\# (Display string: 'Region \#3\#'): Image comes from the Region \#3\#. + * - \b Scan3dExtraction0 (Display string: 'Scan 3d Extraction 0'): Image comes from the Scan3dExtraction output Region 0. + * - \b Scan3dExtraction1 (Display string: 'Scan 3d Extraction 1'): Image comes from the Scan3dExtraction output Region 1. + * - \b Scan3dExtraction2 (Display string: 'Scan 3d Extraction 2'): Image comes from the Scan3dExtraction output Region 2. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkRegionID; + /// \brief An integer property. Returns the unique integer Identifier value of the Region that the image comes from. + /** + * Returns the unique integer Identifier value of the Region that the image comes from. + */ + PropertyI64 chunkRegionIDValue; + /// \brief An enumerated integer property. Selects the Component from which to retrieve data from. + /** + * Selects the Component from which to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Intensity (Display string: 'Intensity'): The image data is the intensity component (visible). + * - \b Infrared (Display string: 'Infrared'): The image data is the infrared component. + * - \b Ultraviolet (Display string: 'Ultraviolet'): The image data is the ultraviolet component. + * - \b Range (Display string: 'Range'): The image data is the range component (distance or depth). + * - \b Reflectance (Display string: 'Reflectance'): The image data is the reflected intensity component (acquired with the Range). + * - \b Disparity (Display string: 'Disparity'): The image data is the disparity component. + * - \b Confidence (Display string: 'Confidence'): The image data is the confidence map component. + * - \b Scatter (Display string: 'Scatter'): The image data is the scatter component. + * - \b Multispectral (Display string: 'Multispectral'): The image data is the multispectral component. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkComponentSelector; + /// \brief An enumerated integer property. Returns the Identifier of the selected Component. + /** + * Returns the Identifier of the selected Component. This can be used to identify the image component type of a multi-component payload. + * + * The following string values might be valid for this feature: + * - \b Intensity (Display string: 'Intensity'): The image data is the intensity component (visible). + * - \b Infrared (Display string: 'Infrared'): The image data is the infrared component. + * - \b Ultraviolet (Display string: 'Ultraviolet'): The image data is the ultraviolet component. + * - \b Range (Display string: 'Range'): The image data is the range component (distance or depth). + * - \b Reflectance (Display string: 'Reflectance'): The image data is the reflected intensity component (acquired with the Range). + * - \b Disparity (Display string: 'Disparity'): The image data is the disparity component. + * - \b Confidence (Display string: 'Confidence'): The image data is the confidence map component. + * - \b Scatter (Display string: 'Scatter'): The image data is the scatter component. + * - \b Multispectral (Display string: 'Multispectral'): The image data is the multispectral component. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkComponentID; + /// \brief An integer property. Returns a unique Identifier value that corresponds to the selected chunk Component. + /** + * Returns a unique Identifier value that corresponds to the selected chunk Component. + */ + PropertyI64 chunkComponentIDValue; + /// \brief An enumerated integer property. Selects the component Group from which to retrieve data from. + /** + * Selects the component Group from which to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Group0 (Display string: 'Group 0'): Selects Components group 0. + * - \b Group1 (Display string: 'Group 1'): Selects Components group 1. + * - \b Group2 (Display string: 'Group 2'): Selects Components group 2. + * - \b Group\#3\# (Display string: 'Group \#3\#'): Selects Components group \#3\#. + * - \b Group3 (Display string: 'Group 3'): Selects Components group 3. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkGroupSelector; + /// \brief An enumerated integer property. Returns a unique Identifier corresponding to the selected Group of components. + /** + * Returns a unique Identifier corresponding to the selected Group of components. This can be used to identify the component Group of a multi-group payload. + * + * The following string values might be valid for this feature: + * - \b Group0 (Display string: 'Group 0'): Selects Components group 0. + * - \b Group1 (Display string: 'Group 1'): Selects Components group 1. + * - \b Group2 (Display string: 'Group 2'): Selects Components group 2. + * - \b Group\#3\# (Display string: 'Group \#3\#'): Selects Components group \#3\#. + * - \b Group3 (Display string: 'Group 3'): Selects Components group 3. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkGroupID; + /// \brief An enumerated integer property. This feature is deprecated (See ChunkComponentID). + /** + * \deprecated + * This feature is deprecated (See ChunkComponentID). It was representing the component of the payload image. + * + * The following string values might be valid for this feature: + * - \b Intensity (Display string: 'Intensity'): Intensity + * - \b Infrared (Display string: 'Infrared'): Infrared + * - \b Ultraviolet (Display string: 'Ultraviolet'): Ultraviolet + * - \b Range (Display string: 'Range'): Range + * - \b Reflectance (Display string: 'Reflectance'): Reflectance + * - \b Disparity (Display string: 'Disparity'): Disparity + * - \b Confidence (Display string: 'Confidence'): Confidence + * - \b Scatter (Display string: 'Scatter'): Scatter + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkImageComponent; + /// \brief An integer property. Returns a unique Identifier value that corresponds to the Group of Components of the selected chunk Component. + /** + * Returns a unique Identifier value that corresponds to the Group of Components of the selected chunk Component. + */ + PropertyI64 chunkGroupIDValue; + /// \brief An integer property. This feature is deprecated (See ChunkComponentSelector). + /** + * \deprecated + * This feature is deprecated (See ChunkComponentSelector). It was selecting the individual parts of a multi-component/multi-part buffer to access. + */ + PropertyI64 chunkPartSelector; + /// \brief A string property. Returns the entire image data included in the payload. + /** + * Returns the entire image data included in the payload. + */ + PropertyS chunkImage; + /// \brief An integer property. Returns the OffsetX of the image included in the payload. + /** + * Returns the OffsetX of the image included in the payload. + */ + PropertyI64 chunkOffsetX; + /// \brief An integer property. Returns the OffsetY of the image included in the payload. + /** + * Returns the OffsetY of the image included in the payload. + */ + PropertyI64 chunkOffsetY; + /// \brief An integer property. Returns the Width of the image included in the payload. + /** + * Returns the Width of the image included in the payload. + */ + PropertyI64 chunkWidth; + /// \brief An integer property. Returns the Height of the image included in the payload. + /** + * Returns the Height of the image included in the payload. + */ + PropertyI64 chunkHeight; + /// \brief An enumerated integer property. Returns the PixelFormat of the image included in the payload. + /** + * Returns the PixelFormat of the image included in the payload. + * + * The following string values might be valid for this feature: + * - \b Mono1p (Display string: 'Mono1p'): Mono 1 bit packed. + * - \b Mono2p (Display string: 'Mono2p'): Mono 2 bit packed. + * - \b Mono4p (Display string: 'Mono4p'): Mono 4 bit packed. + * - \b Mono8 (Display string: 'Mono8'): Mono 8 bit packed. + * - \b Mono8s (Display string: 'Mono8s'): Mono 1 bit signed. + * - \b Mono10 (Display string: 'Mono10'): Mono 10 bit. + * - \b Mono10p (Display string: 'Mono10p'): Mono 10 bit packed. + * - \b Mono12 (Display string: 'Mono12'): Mono 12 bit. + * - \b Mono12p (Display string: 'Mono12p'): Mono 12 bit packed. + * - \b Mono14 (Display string: 'Mono14'): Mono 14 bit. + * - \b Mono16 (Display string: 'Mono16'): Mono 16 bit. + * - \b R8 (Display string: 'R8'): Red 8 bit. + * - \b G8 (Display string: 'G8'): Green 8 bit. + * - \b B8 (Display string: 'B8'): Blue 8 bit. + * - \b RGB8 (Display string: 'RGB8'): Red, Green, Blue 8 bit + * - \b RGB8_Planar (Display string: 'RGB8_Planar'): Red, Green, Blue 8 bit planar. + * - \b RGBa8 (Display string: 'RGBa8'): Red, Green, Blue 8 bit aligned on 8 bit + * - \b RGB10 (Display string: 'RGB10'): Red, Green, Blue 10 bit. + * - \b RGB10_Planar (Display string: 'RGB10_Planar'): Red, Green, Blue 10 bit planar. + * - \b RGB10p32 (Display string: 'RGB10p32'): Red, Green, Blue 10 bit packed in 32 bit pixel. + * - \b RGB12 (Display string: 'RGB12'): Red, Green, Blue 12 bit. + * - \b RGB12_Planar (Display string: 'RGB12_Planar'): Red, Green, Blue 12 bit planar. + * - \b RGB16 (Display string: 'RGB16'): Red, Green, Blue 16 bit. + * - \b RGB16_Planar (Display string: 'RGB16_Planar'): Red, Green, Blue 16 bit planar. + * - \b RGB565p (Display string: 'RGB565p'): Red, Green, Blue 16 bit packet in 5, 6, 5 bits. + * - \b BGR10 (Display string: 'BGR10'): Blue, Green, Red, 10 bit. + * - \b BGR12 (Display string: 'BGR12'): Blue, Green, Red, 12 bit. + * - \b BGR16 (Display string: 'BGR16'): Blue, Green, Red, 16 bit. + * - \b BGR565p (Display string: 'BGR565p'): Blue, Green, Red, 16 bit packet in 5, 6, 5 bits. + * - \b BGR8 (Display string: 'BGR8'): Blue, Green, Red, 8 bit. + * - \b BGRa8 (Display string: 'BGRa8'): Blue, Green, Red, Alpha 8 bit. + * - \b YUV422_8 (Display string: 'YUV422_8'): YUV 422 8 bit. + * - \b YCbCr411_8 (Display string: 'YCbCr411_8'): YCrCb 411 8 bit. + * - \b YCbCr422_8 (Display string: 'YCbCr422_8'): YCrCb 422 8 bit. + * - \b YCbCr601_422_8 (Display string: 'YCbCr601_422_8'): YCrCb 601 422 8 bit. + * - \b YCbCr709_422_8 (Display string: 'YCbCr709_422_8'): YCrCb 709 422 8 bit. + * - \b YCbCr8 (Display string: 'YCbCr8'): YCbCr 8 bit. + * - \b BayerBG8 (Display string: 'BayerBG8'): Bayer Blue Green 8 bit. + * - \b BayerGB8 (Display string: 'BayerGB8'): Bayer Green Blue 8 bit. + * - \b BayerGR8 (Display string: 'BayerGR8'): Bayer Green Red 8 bit. + * - \b BayerRG8 (Display string: 'BayerRG8'): Bayer Red Green 8 bit. + * - \b BayerBG10 (Display string: 'BayerBG10'): Bayer Blue Green 10 bit. + * - \b BayerGB10 (Display string: 'BayerGB10'): Bayer Green Blue 10 bit. + * - \b BayerGR10 (Display string: 'BayerGR10'): Bayer Green Red 10 bit. + * - \b BayerRG10 (Display string: 'BayerRG10'): Bayer Red Green 10 bit. + * - \b BayerBG12 (Display string: 'BayerBG12'): Bayer Blue Green 12 bit + * - \b BayerGB12 (Display string: 'BayerGB12'): Bayer Green Blue 12 bit + * - \b BayerGR12 (Display string: 'BayerGR12'): Bayer Green Red 12 bit. + * - \b BayerRG12 (Display string: 'BayerRG12'): Bayer Red Green 12 bit. + * - \b BayerBG16 (Display string: 'BayerBG16'): Bayer Blue Green 16 bit. + * - \b BayerGB16 (Display string: 'BayerGB16'): Bayer Green Blue 16 bit. + * - \b BayerGR16 (Display string: 'BayerGR16'): Bayer Green Red 16 bit. + * - \b BayerRG16 (Display string: 'BayerRG16'): Bayer Red Green 16 bit. + * - \b Coord3D_A8 (Display string: 'Coord3D_A8'): 3D coordinate, first component 8 bit. + * - \b Coord3D_B8 (Display string: 'Coord3D_B8'): 3D coordinate, second component 8 bit. + * - \b Coord3D_C8 (Display string: 'Coord3D_C8'): 3D coordinate, third component 8 bit. + * - \b Coord3D_ABC8 (Display string: 'Coord3D_ABC8'): 3D coordinates, 3 components 8 bit. + * - \b Coord3D_ABC8_Planar (Display string: 'Coord3D_ABC8_Planar'): 3D coordinates, 3 components 8 bit planar. + * - \b Coord3D_A16 (Display string: 'Coord3D_A16'): 3D coordinate, first component 16 bit. + * - \b Coord3D_B16 (Display string: 'Coord3D_B16'): 3D coordinate, second component 16 bit. + * - \b Coord3D_C16 (Display string: 'Coord3D_C16'): 3D coordinate, third component 16 bit. + * - \b Coord3D_ABC16 (Display string: 'Coord3D_ABC16'): 3D coordinates, 3 components 16 bit. + * - \b Coord3D_ABC16_Planar (Display string: 'Coord3D_ABC16_Planar'): 3D coordinates, 3 components 16 bit planar. + * - \b Coord3D_A32f (Display string: 'Coord3D_A32f'): 3D coordinate, first component 32 bit float. + * - \b Coord3D_B32f (Display string: 'Coord3D_B32f'): 3D coordinate, second component 32 bit float. + * - \b Coord3D_C32f (Display string: 'Coord3D_C32f'): 3D coordinate, third component 32 bit float. + * - \b Coord3D_ABC32f (Display string: 'Coord3D_ABC32f'): 3D coordinates, 3 components 32 bit float. + * - \b Coord3D_ABC32f_Planar (Display string: 'Coord3D_ABC32f_Planar'): 3D coordinates, 3 components 32 bit float planar. + * - \b Confidence1 (Display string: 'Confidence1'): Confidence data 1 bit. + * - \b Confidence1p (Display string: 'Confidence1p'): Confidence data 1 bit packed. + * - \b Confidence8 (Display string: 'Confidence8'): Confidence data 8 bit. + * - \b Confidence16 (Display string: 'Confidence16'): Confidence data 16 bit. + * - \b Confidence32f (Display string: 'Confidence32f'): Confidence data 32 bit float. + * - \b Data8 (Display string: 'Data8'): Generic non-pixel data 8 bit. + * - \b Data8s (Display string: 'Data8s'): Generic non-pixel data 8 bit signed. + * - \b Data16 (Display string: 'Data16'): Generic non-pixel data 16 bit. + * - \b Data16s (Display string: 'Data16s'): Generic non-pixel data 16 bit signed. + * - \b Data32 (Display string: 'Data32'): Generic non-pixel data 32 bit. + * - \b Data32s (Display string: 'Data32s'): Generic non-pixel data 32 bit signed. + * - \b Data32f (Display string: 'Data32f'): Generic non-pixel data 32 bit floating point. + * - \b Data64 (Display string: 'Data64'): Generic non-pixel data 64 bit. + * - \b Data64s (Display string: 'Data64s'): Generic non-pixel data 64 bit signed. + * - \b Data64f (Display string: 'Data64f'): Generic non-pixel data 64 bit floating point. + * - \b Raw8 (Display string: 'Raw8'): Raw 8 bit. + * - \b Raw16 (Display string: 'Raw16'): Raw 16 bit. + * - \b Mono12Packed (Display string: 'Mono12Packed'): Mono 12 bit packed (GigE Vision Specific). + * - \b BayerGR10Packed (Display string: 'BayerGR10Packed'): Bayer GR 10 bit packed (GigE Vision Specific). + * - \b BayerRG10Packed (Display string: 'BayerRG10Packed'): Bayer RG 10 bit packed (GigE Vision Specific). + * - \b BayerGB10Packed (Display string: 'BayerGB10Packed'): Bayer GB 10 bit packed (GigE Vision Specific). + * - \b BayerBG10Packed (Display string: 'BayerBG10Packed'): Bayer BG 10 bit packed (GigE Vision Specific). + * - \b BayerGR12Packed (Display string: 'BayerGR12Packed'): Bayer GR 12 bit packed (GigE Vision Specific). + * - \b BayerRG12Packed (Display string: 'BayerRG12Packed'): Bayer RG 12 bit packed (GigE Vision Specific). + * - \b BayerGB12Packed (Display string: 'BayerGB12Packed'): Bayer GB 12 bit packed (GigE Vision Specific). + * - \b BayerBG12Packed (Display string: 'BayerBG12Packed'): Bayer BG 12 bit packed (GigE Vision Specific). + * - \b RGB10V1Packed (Display string: 'RGB10V1Packed'): RGB 10 bit packed (GigE Vision Specific). + * - \b RGB12V1Packed (Display string: 'RGB12V1Packed'): RGB 12 bit packed (GigE Vision Specific). + * - \b Mono8Signed (Display string: 'Mono 8 Signed') + * - \b Mono10Packed (Display string: 'Mono 10 Packed') + * - \b RGB8Packed (Display string: 'RGB 8 Packed') + * - \b BGR8Packed (Display string: 'BGR 8 Packed') + * - \b RGBA8Packed (Display string: 'RGBA 8 Packed') + * - \b BGRA8Packed (Display string: 'BGRA 8 Packed') + * - \b RGB10Packed (Display string: 'RGB 10 Packed') + * - \b BGR10Packed (Display string: 'BGR 10 Packed') + * - \b RGB12Packed (Display string: 'RGB 12 Packed') + * - \b BGR12Packed (Display string: 'BGR 12 Packed') + * - \b RGB16Packed (Display string: 'RGB 16 Packed') + * - \b RGB10V2Packed (Display string: 'RGB 10 V 2 Packed') + * - \b RGB565Packed (Display string: 'RGB 565 Packed') + * - \b BGR565Packed (Display string: 'BGR 565 Packed') + * - \b YUV411Packed (Display string: 'YUV 411 Packed') + * - \b YUV422Packed (Display string: 'YUV 422 Packed') + * - \b YUV444Packed (Display string: 'YUV 444 Packed') + * - \b YUYVPacked (Display string: 'YUYV Packed') + * - \b RGB8Planar (Display string: 'RGB 8 Planar') + * - \b RGB10Planar (Display string: 'RGB 10 Planar') + * - \b RGB12Planar (Display string: 'RGB 12 Planar') + * - \b RGB16Planar (Display string: 'RGB 16 Planar') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkPixelFormat; + /// \brief An integer property. Returns the minimum value of dynamic range of the image included in the payload. + /** + * Returns the minimum value of dynamic range of the image included in the payload. + */ + PropertyI64 chunkPixelDynamicRangeMin; + /// \brief An integer property. Returns the maximum value of dynamic range of the image included in the payload. + /** + * Returns the maximum value of dynamic range of the image included in the payload. + */ + PropertyI64 chunkPixelDynamicRangeMax; + /// \brief An integer property. Number of horizontal photo-sensitive cells combined together. + /** + * Number of horizontal photo-sensitive cells combined together. + */ + PropertyI64 chunkBinningHorizontal; + /// \brief An integer property. Number of vertical photo-sensitive cells combined together. + /** + * Number of vertical photo-sensitive cells combined together. + */ + PropertyI64 chunkBinningVertical; + /// \brief An integer property. Horizontal sub-sampling of the image. + /** + * Horizontal sub-sampling of the image. + */ + PropertyI64 chunkDecimationHorizontal; + /// \brief An integer property. Vertical sub-sampling of the image. + /** + * Vertical sub-sampling of the image. + */ + PropertyI64 chunkDecimationVertical; + /// \brief A boolean property. Flip horizontal of the image sent by the device. + /** + * Flip horizontal of the image sent by the device. + */ + PropertyIBoolean chunkReverseX; + /// \brief A boolean property. Flip vertically of the image sent by the device. + /** + * Flip vertically of the image sent by the device. + */ + PropertyIBoolean chunkReverseY; + /// \brief An integer property. Returns the Timestamp of the image included in the payload at the time of the FrameStart internal event. + /** + * Returns the Timestamp of the image included in the payload at the time of the FrameStart internal event. + */ + PropertyI64 chunkTimestamp; + /// \brief An integer property. Returns the last Timestamp latched with the TimestampLatch command. + /** + * Returns the last Timestamp latched with the TimestampLatch command. + */ + PropertyI64 chunkTimestampLatchValue; + /// \brief An integer property. Returns the status of all the I/O lines at the time of the FrameStart internal event. + /** + * Returns the status of all the I/O lines at the time of the FrameStart internal event. + */ + PropertyI64 chunkLineStatusAll; + /// \brief An enumerated integer property. Selects which counter to retrieve data from. + /** + * Selects which counter to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Counter0 (Display string: 'Counter 0'): Selects the counter 0. + * - \b Counter1 (Display string: 'Counter 1'): Selects the counter 1. + * - \b Counter2 (Display string: 'Counter 2'): Selects the counter 2. + * - \b Counter\#3\# (Display string: 'Counter \#3\#'): Selects the counter \#3\#. + * - \b Counter3 (Display string: 'Counter 3'): Selects the counter 3. + * - \b Counter4 (Display string: 'Counter 4'): Selects the counter 4. + * - \b Counter5 (Display string: 'Counter 5'): Selects the counter 5. + * - \b Counter6 (Display string: 'Counter 6'): Selects the counter 6. + * - \b Counter7 (Display string: 'Counter 7'): Selects the counter 7. + * - \b Counter8 (Display string: 'Counter 8'): Selects the counter 8. + * - \b Counter9 (Display string: 'Counter 9'): Selects the counter 9. + * - \b Counter10 (Display string: 'Counter 10'): Selects the counter 10. + * - \b Counter11 (Display string: 'Counter 11'): Selects the counter 11. + * - \b Counter12 (Display string: 'Counter 12'): Selects the counter 12. + * - \b Counter13 (Display string: 'Counter 13'): Selects the counter 13. + * - \b Counter14 (Display string: 'Counter 14'): Selects the counter 14. + * - \b Counter15 (Display string: 'Counter 15'): Selects the counter 15. + * - \b Counter16 (Display string: 'Counter 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkCounterSelector; + /// \brief An integer property. Returns the value of the selected Chunk counter at the time of the FrameStart event. + /** + * Returns the value of the selected Chunk counter at the time of the FrameStart event. + */ + PropertyI64 chunkCounterValue; + /// \brief An enumerated integer property. Selects which Timer to retrieve data from. + /** + * Selects which Timer to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Timer0 (Display string: 'Timer 0'): Selects the first Timer. + * - \b Timer1 (Display string: 'Timer 1'): Selects the first Timer. + * - \b Timer2 (Display string: 'Timer 2'): Selects the second Timer. + * - \b Timer\#3\# (Display string: 'Timer \#3\#'): Selects the second Timer. + * - \b Timer3 (Display string: 'Timer 3'): Selects the second Timer. + * - \b Timer4 (Display string: 'Timer 4'): Selects the second Timer. + * - \b Timer5 (Display string: 'Timer 5'): Selects the second Timer. + * - \b Timer6 (Display string: 'Timer 6'): Selects the second Timer. + * - \b Timer7 (Display string: 'Timer 7'): Selects the second Timer. + * - \b Timer8 (Display string: 'Timer 8'): Selects the second Timer. + * - \b Timer9 (Display string: 'Timer 9'): Selects the second Timer. + * - \b Timer10 (Display string: 'Timer 10'): Selects the second Timer. + * - \b Timer11 (Display string: 'Timer 11'): Selects the second Timer. + * - \b Timer12 (Display string: 'Timer 12'): Selects the second Timer. + * - \b Timer13 (Display string: 'Timer 13'): Selects the second Timer. + * - \b Timer14 (Display string: 'Timer 14'): Selects the second Timer. + * - \b Timer15 (Display string: 'Timer 15'): Selects the second Timer. + * - \b Timer16 (Display string: 'Timer 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkTimerSelector; + /// \brief A floating point property. Returns the value of the selected Timer at the time of the FrameStart internal event. + /** + * Returns the value of the selected Timer at the time of the FrameStart internal event. + */ + PropertyF chunkTimerValue; + /// \brief An integer property. Index for vector representation of one chunk value per line in an image. + /** + * Index for vector representation of one chunk value per line in an image. + */ + PropertyI64 chunkScanLineSelector; + /// \brief An enumerated integer property. Selects which Encoder to retrieve data from. + /** + * Selects which Encoder to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Encoder0 (Display string: 'Encoder 0'): Selects the first Encoder. + * - \b Encoder1 (Display string: 'Encoder 1'): Selects the first Encoder. + * - \b Encoder2 (Display string: 'Encoder 2'): Selects the second Encoder. + * - \b Encoder\#3\# (Display string: 'Encoder \#3\#'): Selects the second Encoder. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkEncoderSelector; + /// \brief An integer property. Returns the counter's value of the selected Encoder at the time of the FrameStart in area scan mode or the counter's value at the time of the LineStart selected by ChunkScanLineSelector in Linescan mode. + /** + * Returns the counter's value of the selected Encoder at the time of the FrameStart in area scan mode or the counter's value at the time of the LineStart selected by ChunkScanLineSelector in Linescan mode. + */ + PropertyI64 chunkEncoderValue; + /// \brief An enumerated integer property. Returns the motion status of the selected encoder. + /** + * Returns the motion status of the selected encoder. + * + * The following string values might be valid for this feature: + * - \b EncoderUp (Display string: 'Encoder Up'): The encoder counter last incremented. + * - \b EncoderDown (Display string: 'Encoder Down'): The encoder counter last decremented. + * - \b EncoderIdle (Display string: 'Encoder Idle'): The encoder is not active. + * - \b EncoderStatic (Display string: 'Encoder Static'): No motion within the EncoderTimeout time. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkEncoderStatus; + /// \brief An enumerated integer property. Selects which exposure time is read by the ChunkExposureTime feature. + /** + * Selects which exposure time is read by the ChunkExposureTime feature. + * + * The following string values might be valid for this feature: + * - \b Common (Display string: 'Common'): Selects the common ExposureTime. + * - \b Red (Display string: 'Red'): Selects the red common ExposureTime. + * - \b Green (Display string: 'Green'): Selects the green ExposureTime. + * - \b Blue (Display string: 'Blue'): Selects the blue ExposureTime. + * - \b Cyan (Display string: 'Cyan'): Selects the cyan common ExposureTime.. + * - \b Magenta (Display string: 'Magenta'): Selects the magenta ExposureTime.. + * - \b Yellow (Display string: 'Yellow'): Selects the yellow ExposureTime.. + * - \b Infrared (Display string: 'Infrared'): Selects the infrared ExposureTime. + * - \b Ultraviolet (Display string: 'Ultraviolet'): Selects the ultraviolet ExposureTime. + * - \b Stage1 (Display string: 'Stage 1'): Selects the first stage ExposureTime. + * - \b Stage2 (Display string: 'Stage 2'): Selects the second stage ExposureTime. + * - \b Stage\#3\# (Display string: 'Stage \#3\#'): Selects the second stage ExposureTime. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkExposureTimeSelector; + /// \brief A floating point property. Returns the exposure time used to capture the image. + /** + * Returns the exposure time used to capture the image. + */ + PropertyF chunkExposureTime; + /// \brief An enumerated integer property. Selects which Gain to return. + /** + * Selects which Gain to return. + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): Gain will be applied to all channels or taps. + * - \b Red (Display string: 'Red'): Gain will be applied to the red channel. + * - \b Green (Display string: 'Green'): Gain will be applied to the green channel. + * - \b Blue (Display string: 'Blue'): Gain will be applied to the blue channel. + * - \b Y (Display string: 'Y'): Gain will be applied to Y channel. + * - \b U (Display string: 'U'): Gain will be applied to U channel. + * - \b V (Display string: 'V'): Gain will be applied to V channel. + * - \b Tap1 (Display string: 'Tap 1'): Gain will be applied to Tap 1. + * - \b Tap2 (Display string: 'Tap 2'): Gain will be applied to Tap 2. + * - \b Tap\#3\# (Display string: 'Tap \#3\#'): Gain will be applied to Tap \#3\#. + * - \b AnalogAll (Display string: 'Analog All'): Gain will be applied to all analog channels or taps. + * - \b AnalogRed (Display string: 'Analog Red'): Gain will be applied to the red analog channel. + * - \b AnalogGreen (Display string: 'Analog Green'): Gain will be applied to the green analog channel. + * - \b AnalogBlue (Display string: 'Analog Blue'): Gain will be applied to the blue analog channel. + * - \b AnalogY (Display string: 'Analog Y'): Gain will be applied to Y analog channel. + * - \b AnalogU (Display string: 'Analog U'): Gain will be applied to U analog channel. + * - \b AnalogV (Display string: 'Analog V'): Gain will be applied to V analog channel. + * - \b AnalogTap1 (Display string: 'Analog Tap 1'): Analog gain will be applied to Tap 1. + * - \b AnalogTap2 (Display string: 'Analog Tap 2'): Analog gain will be applied to Tap 2. + * - \b AnalogTap\#3\# (Display string: 'Analog Tap \#3\#'): Analog gain will be applied to Tap \#3\#. + * - \b DigitalAll (Display string: 'Digital All'): Gain will be applied to all digital channels or taps. + * - \b DigitalRed (Display string: 'Digital Red'): Gain will be applied to the red digital channel. + * - \b DigitalGreen (Display string: 'Digital Green'): Gain will be applied to the green digital channel. + * - \b DigitalBlue (Display string: 'Digital Blue'): Gain will be applied to the blue digital channel. + * - \b DigitalY (Display string: 'Digital Y'): Gain will be applied to Y digital channel. + * - \b DigitalU (Display string: 'Digital U'): Gain will be applied to U digital channel. + * - \b DigitalV (Display string: 'Digital V'): Gain will be applied to V digital channel. + * - \b DigitalTap1 (Display string: 'Digital Tap 1'): Digital gain will be applied to Tap 1. + * - \b DigitalTap2 (Display string: 'Digital Tap 2'): Digital gain will be applied to Tap 2. + * - \b DigitalTap\#3\# (Display string: 'Digital Tap \#3\#'): Digital gain will be applied to Tap \#3\#. + * - \b Tap3 (Display string: 'Tap 3'): Gain will be applied to Tap 3. + * - \b Tap4 (Display string: 'Tap 4'): Gain will be applied to Tap 4. + * - \b Tap5 (Display string: 'Tap 5'): Gain will be applied to Tap 5. + * - \b Tap6 (Display string: 'Tap 6'): Gain will be applied to Tap 6. + * - \b Tap7 (Display string: 'Tap 7'): Gain will be applied to Tap 7. + * - \b Tap8 (Display string: 'Tap 8'): Gain will be applied to Tap 8. + * - \b Tap9 (Display string: 'Tap 9'): Gain will be applied to Tap 9. + * - \b Tap10 (Display string: 'Tap 10'): Gain will be applied to Tap 10. + * - \b Tap11 (Display string: 'Tap 11'): Gain will be applied to Tap 11. + * - \b Tap12 (Display string: 'Tap 12'): Gain will be applied to Tap 12. + * - \b Tap13 (Display string: 'Tap 13'): Gain will be applied to Tap 13. + * - \b Tap14 (Display string: 'Tap 14'): Gain will be applied to Tap 14. + * - \b Tap15 (Display string: 'Tap 15'): Gain will be applied to Tap 15. + * - \b Tap16 (Display string: 'Tap 16') + * - \b AnalogTap3 (Display string: 'Analog Tap 3'): Analog gain will be applied to Tap 3. + * - \b AnalogTap4 (Display string: 'Analog Tap 4'): Analog gain will be applied to Tap 4. + * - \b AnalogTap5 (Display string: 'Analog Tap 5'): Analog gain will be applied to Tap 5. + * - \b AnalogTap6 (Display string: 'Analog Tap 6'): Analog gain will be applied to Tap 6. + * - \b AnalogTap7 (Display string: 'Analog Tap 7'): Analog gain will be applied to Tap 7. + * - \b AnalogTap8 (Display string: 'Analog Tap 8'): Analog gain will be applied to Tap 8. + * - \b AnalogTap9 (Display string: 'Analog Tap 9'): Analog gain will be applied to Tap 9. + * - \b AnalogTap10 (Display string: 'Analog Tap 10'): Analog gain will be applied to Tap 10. + * - \b AnalogTap11 (Display string: 'Analog Tap 11'): Analog gain will be applied to Tap 11. + * - \b AnalogTap12 (Display string: 'Analog Tap 12'): Analog gain will be applied to Tap 12. + * - \b AnalogTap13 (Display string: 'Analog Tap 13'): Analog gain will be applied to Tap 13. + * - \b AnalogTap14 (Display string: 'Analog Tap 14'): Analog gain will be applied to Tap 14. + * - \b AnalogTap15 (Display string: 'Analog Tap 15'): Analog gain will be applied to Tap 15. + * - \b AnalogTap16 (Display string: 'Analog Tap 16') + * - \b DigitalTap3 (Display string: 'Digital Tap 3'): Digital gain will be applied to Tap 3. + * - \b DigitalTap4 (Display string: 'Digital Tap 4'): Digital gain will be applied to Tap 4. + * - \b DigitalTap5 (Display string: 'Digital Tap 5'): Digital gain will be applied to Tap 5. + * - \b DigitalTap6 (Display string: 'Digital Tap 6'): Digital gain will be applied to Tap 6. + * - \b DigitalTap7 (Display string: 'Digital Tap 7'): Digital gain will be applied to Tap 7. + * - \b DigitalTap8 (Display string: 'Digital Tap 8'): Digital gain will be applied to Tap 8. + * - \b DigitalTap9 (Display string: 'Digital Tap 9'): Digital gain will be applied to Tap 9. + * - \b DigitalTap10 (Display string: 'Digital Tap 10'): Digital gain will be applied to Tap 10. + * - \b DigitalTap11 (Display string: 'Digital Tap 11'): Digital gain will be applied to Tap 11. + * - \b DigitalTap12 (Display string: 'Digital Tap 12'): Digital gain will be applied to Tap 12. + * - \b DigitalTap13 (Display string: 'Digital Tap 13'): Digital gain will be applied to Tap 13. + * - \b DigitalTap14 (Display string: 'Digital Tap 14'): Digital gain will be applied to Tap 14. + * - \b DigitalTap15 (Display string: 'Digital Tap 15'): Digital gain will be applied to Tap 15. + * - \b DigitalTap16 (Display string: 'Digital Tap 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkGainSelector; + /// \brief A floating point property. Returns the gain used to capture the image. + /** + * Returns the gain used to capture the image. + */ + PropertyF chunkGain; + /// \brief An enumerated integer property. Selects which Black Level to return. + /** + * Selects which Black Level to return. Possible values are: + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): Black Level will be applied to all channels or taps. + * - \b Red (Display string: 'Red'): Black Level will be applied to the red channel. + * - \b Green (Display string: 'Green'): Black Level will be applied to the green channel. + * - \b Blue (Display string: 'Blue'): Black Level will be applied to the blue channel. + * - \b Y (Display string: 'Y'): Black Level will be applied to Y channel. + * - \b U (Display string: 'U'): Black Level will be applied to U channel. + * - \b V (Display string: 'V'): Black Level will be applied to V channel. + * - \b Tap1 (Display string: 'Tap 1'): Black Level will be applied to Tap 1. + * - \b Tap2 (Display string: 'Tap 2'): Black Level will be applied to Tap 2. + * - \b Tap\#3\# (Display string: 'Tap \#3\#'): Black Level will be applied to Tap \#3\#. + * - \b Tap3 (Display string: 'Tap 3'): Black Level will be applied to Tap 3. + * - \b Tap4 (Display string: 'Tap 4'): Black Level will be applied to Tap 4. + * - \b Tap5 (Display string: 'Tap 5'): Black Level will be applied to Tap 5. + * - \b Tap6 (Display string: 'Tap 6'): Black Level will be applied to Tap 6. + * - \b Tap7 (Display string: 'Tap 7'): Black Level will be applied to Tap 7. + * - \b Tap8 (Display string: 'Tap 8'): Black Level will be applied to Tap 8. + * - \b Tap9 (Display string: 'Tap 9'): Black Level will be applied to Tap 9. + * - \b Tap10 (Display string: 'Tap 10'): Black Level will be applied to Tap 10. + * - \b Tap11 (Display string: 'Tap 11'): Black Level will be applied to Tap 11. + * - \b Tap12 (Display string: 'Tap 12'): Black Level will be applied to Tap 12. + * - \b Tap13 (Display string: 'Tap 13'): Black Level will be applied to Tap 13. + * - \b Tap14 (Display string: 'Tap 14'): Black Level will be applied to Tap 14. + * - \b Tap15 (Display string: 'Tap 15'): Black Level will be applied to Tap 15. + * - \b Tap16 (Display string: 'Tap 16') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkBlackLevelSelector; + /// \brief A floating point property. Returns the black level used to capture the image included in the payload. + /** + * Returns the black level used to capture the image included in the payload. + */ + PropertyF chunkBlackLevel; + /// \brief An integer property. Returns the LinePitch of the image included in the payload. + /** + * Returns the LinePitch of the image included in the payload. + */ + PropertyI64 chunkLinePitch; + /// \brief An integer property. Returns the unique Identifier of the frame (or image) included in the payload. + /** + * Returns the unique Identifier of the frame (or image) included in the payload. + */ + PropertyI64 chunkFrameID; + /// \brief An enumerated integer property. Selects which Source to retrieve data from. + /** + * Selects which Source to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b Source0 (Display string: 'Source 0'): Image comes from the Source 0. + * - \b Source1 (Display string: 'Source 1'): Image comes from the Source 1. + * - \b Source2 (Display string: 'Source 2'): Image comes from the Source 2. + * - \b Source\#3\# (Display string: 'Source \#3\#'): Image comes from the Source \#3\#. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkSourceSelector; + /// \brief An enumerated integer property. Returns the Identifier of Source that the image comes from. + /** + * Returns the Identifier of Source that the image comes from. + * + * The following string values might be valid for this feature: + * - \b Source0 (Display string: 'Source 0'): Image comes from the Source 0. + * - \b Source1 (Display string: 'Source 1'): Image comes from the Source 1. + * - \b Source2 (Display string: 'Source 2'): Image comes from the Source 2. + * - \b Source\#3\# (Display string: 'Source \#3\#'): Image comes from the Source \#3\#. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkSourceID; + /// \brief An integer property. Returns the unique integer Identifier value of the Source that the image comes from. + /** + * Returns the unique integer Identifier value of the Source that the image comes from. + */ + PropertyI64 chunkSourceIDValue; + /// \brief An integer property. Returns the unique identifier of the transfer block used to transport the payload. + /** + * Returns the unique identifier of the transfer block used to transport the payload. + */ + PropertyI64 chunkTransferBlockID; + /// \brief An enumerated integer property. Returns identifier of the stream that generated this block. + /** + * Returns identifier of the stream that generated this block. + * + * The following string values might be valid for this feature: + * - \b Stream0 (Display string: 'Stream 0'): Data comes from Stream0. + * - \b Stream1 (Display string: 'Stream 1'): Data comes from Stream1. + * - \b Stream2 (Display string: 'Stream 2'): Data comes from Stream2. + * - \b Stream3 (Display string: 'Stream 3'): Data comes from Stream3. + * - \b Stream\#4\# (Display string: 'Stream \#4\#'): Data comes from Stream\#4\#. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkTransferStreamID; + /// \brief An integer property. Returns the current number of blocks in the transfer queue. + /** + * Returns the current number of blocks in the transfer queue. + */ + PropertyI64 chunkTransferQueueCurrentBlockCount; + /// \brief An integer property. Returns identifier of the stream channel used to carry the block. + /** + * Returns identifier of the stream channel used to carry the block. + */ + PropertyI64 chunkStreamChannelID; + /// \brief An integer property. Return the index of the active set of the running sequencer included in the payload. + /** + * Return the index of the active set of the running sequencer included in the payload. + */ + PropertyI64 chunkSequencerSetActive; + /// \brief An enumerated integer property. Returns the Distance Unit of the payload image. + /** + * Returns the Distance Unit of the payload image. + * + * The following string values might be valid for this feature: + * - \b Millimeter (Display string: 'Millimeter'): Default value. Distance values are in millimeter units. + * - \b Inch (Display string: 'Inch'): Distance values are in inch units. + * - \b Pixel (Display string: 'Pixel'): Distance values are given as a multiple of the size of a pixel. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dDistanceUnit; + /// \brief An enumerated integer property. Returns the Calibrated Mode of the payload image. + /** + * Returns the Calibrated Mode of the payload image. + * + * The following string values might be valid for this feature: + * - \b UncalibratedC (Display string: 'Uncalibrated C'): Uncalibrated 2.5D Depth map. The distance data does not represent a physical unit and may be non-linear. The data is a 2.5D range map only. + * - \b CalibratedABC_Grid (Display string: 'Calibrated ABC Grid'): 3 Coordinates in grid organization. The full 3 coordinate data with the grid array organization from the sensor kept. + * - \b CalibratedABC_PointCloud (Display string: 'Calibrated ABC Point Cloud'): 3 Coordinates without organization. The full 3 coordinate data without any organization of data points. Typically only valid points transmitted giving varying image size. + * - \b CalibratedAC (Display string: 'Calibrated AC'): 2 Coordinates with fixed B sampling. The data is sent as a A and C coordinates (X,Z or Theta,Rho). The B (Y) axis uses the scale and offset parameters for the B axis. + * - \b CalibratedAC_Linescan (Display string: 'Calibrated AC Linescan'): 2 Coordinates with varying sampling. The data is sent as a A and C coordinates (X,Z or Theta,Rho). The B (Y) axis comes from the encoder chunk value. + * - \b CalibratedC (Display string: 'Calibrated C'): Calibrated 2.5D Depth map. The distance data is expressed in the chosen distance unit. The data is a 2.5D range map. No information on X-Y axes available. + * - \b CalibratedC_Linescan (Display string: 'Calibrated C Linescan'): Depth Map with varying B sampling. The distance data is expressed in the chosen distance unit. The data is a 2.5D range map. The B (Y) axis comes from the encoder chunk value. + * - \b RectifiedC (Display string: 'Rectified C'): Rectified 2.5D Depth map. The distance data has been rectified to a uniform sampling pattern in the X and Y direction. The data is a 2.5D range map only. If a complete 3D point cloud is rectified but transmitted as explicit coordinates it should be transmitted as one of the 'CalibratedABC' formats. + * - \b RectifiedC_Linescan (Display string: 'Rectified C Linescan'): Rectified 2.5D Depth map with varying B sampling. The data is sent as rectified 1D profiles using Coord3D_C pixels. The B (Y) axis comes from the encoder chunk value. + * - \b DisparityC (Display string: 'Disparity C'): Disparity 2.5D Depth map. The distance is inversely proportional to the pixel (disparity) value. + * - \b DisparityC_Linescan (Display string: 'Disparity C Linescan'): Disparity 2.5D Depth map with varying B sampling. The distance is inversely proportional to the pixel (disparity) value. The B (Y) axis comes from the encoder chunk value. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dOutputMode; + /// \brief An enumerated integer property. Returns the Coordinate System of the image included in the payload. + /** + * Returns the Coordinate System of the image included in the payload. + * + * The following string values might be valid for this feature: + * - \b Cartesian (Display string: 'Cartesian'): Default value. 3-axis orthogonal, right-hand X-Y-Z. + * - \b Spherical (Display string: 'Spherical'): A Theta-Phi-Rho coordinate system. + * - \b Cylindrical (Display string: 'Cylindrical'): A Theta-Y-Rho coordinate system. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dCoordinateSystem; + /// \brief An enumerated integer property. Returns the Coordinate System Position of the image included in the payload. + /** + * Returns the Coordinate System Position of the image included in the payload. + * + * The following string values might be valid for this feature: + * - \b Anchor (Display string: 'Anchor'): Default value. Original fixed reference. The coordinate system fixed relative the camera reference point marker is used. + * - \b Transformed (Display string: 'Transformed'): Transformed reference system. The transformed coordinate system is used according to the definition in the rotation and translation matrices. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dCoordinateSystemReference; + /// \brief An enumerated integer property. Selects which Coordinate to retrieve data from. + /** + * Selects which Coordinate to retrieve data from. + * + * The following string values might be valid for this feature: + * - \b CoordinateA (Display string: 'Coordinate A'): The first (X or Theta) coordinate + * - \b CoordinateB (Display string: 'Coordinate B'): The second (Y or Phi) coordinate + * - \b CoordinateC (Display string: 'Coordinate C'): The third (Z or Rho) coordinate. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dCoordinateSelector; + /// \brief A floating point property. Returns the Scale for the selected coordinate axis of the image included in the payload. + /** + * Returns the Scale for the selected coordinate axis of the image included in the payload. + */ + PropertyF chunkScan3dCoordinateScale; + /// \brief A floating point property. Returns the Offset for the selected coordinate axis of the image included in the payload. + /** + * Returns the Offset for the selected coordinate axis of the image included in the payload. + */ + PropertyF chunkScan3dCoordinateOffset; + /// \brief A boolean property. Returns if a specific non-valid data flag is used in the data stream. + /** + * Returns if a specific non-valid data flag is used in the data stream. + */ + PropertyIBoolean chunkScan3dInvalidDataFlag; + /// \brief A floating point property. Returns the Invalid Data Value used for the image included in the payload. + /** + * Returns the Invalid Data Value used for the image included in the payload. + */ + PropertyF chunkScan3dInvalidDataValue; + /// \brief A floating point property. Returns the Minimum Axis value for the selected coordinate axis of the image included in the payload. + /** + * Returns the Minimum Axis value for the selected coordinate axis of the image included in the payload. + */ + PropertyF chunkScan3dAxisMin; + /// \brief A floating point property. Returns the Maximum Axis value for the selected coordinate axis of the image included in the payload. + /** + * Returns the Maximum Axis value for the selected coordinate axis of the image included in the payload. + */ + PropertyF chunkScan3dAxisMax; + /// \brief An enumerated integer property. Selector for transform values. + /** + * Selector for transform values. + * + * The following string values might be valid for this feature: + * - \b RotationX (Display string: 'Rotation X'): Rotation around X axis. + * - \b RotationY (Display string: 'Rotation Y'): Rotation around Y axis. + * - \b RotationZ (Display string: 'Rotation Z'): Rotation around Z axis. + * - \b TranslationX (Display string: 'Translation X'): Translation along X axis. + * - \b TranslationY (Display string: 'Translation Y'): Translation along Y axis. + * - \b TranslationZ (Display string: 'Translation Z'): Translation along Z axis. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dCoordinateTransformSelector; + /// \brief A floating point property. Returns the transform value. + /** + * Returns the transform value. + */ + PropertyF chunkScan3dTransformValue; + /// \brief An enumerated integer property. Selector to read a coordinate system reference value defining the transform of a point from one system to the other. + /** + * Selector to read a coordinate system reference value defining the transform of a point from one system to the other. + * + * The following string values might be valid for this feature: + * - \b RotationX (Display string: 'Rotation X'): Rotation around X axis. + * - \b RotationY (Display string: 'Rotation Y'): Rotation around Y axis. + * - \b RotationZ (Display string: 'Rotation Z'): Rotation around Z axis. + * - \b TranslationX (Display string: 'Translation X'): X axis translation. + * - \b TranslationY (Display string: 'Translation Y'): Y axis translation. + * - \b TranslationZ (Display string: 'Translation Z'): Z axis translation. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 chunkScan3dCoordinateReferenceSelector; + /// \brief A floating point property. Returns the value of a position or pose coordinate for the anchor or transformed coordinate systems relative to the reference point. + /** + * Returns the value of a position or pose coordinate for the anchor or transformed coordinate systems relative to the reference point. + */ + PropertyF chunkScan3dCoordinateReferenceValue; + /// \brief A floating point property. Returns the focal length of the camera in pixel. + /** + * Returns the focal length of the camera in pixel. The focal length depends on the selected region. The value of this feature takes into account horizontal binning, decimation, or any other function changing the image resolution. + */ + PropertyF chunkScan3dFocalLength; + /// \brief A floating point property. Returns the baseline as the physical distance of two cameras in a stereo camera setup. + /** + * Returns the baseline as the physical distance of two cameras in a stereo camera setup. The value of this feature can be used for 3D reconstruction from disparity images. In this case, the unit of the 3D coordinates corresponds to the unit of the baseline. + */ + PropertyF chunkScan3dBaseline; + /// \brief A floating point property. Returns the value of this feature gives the horizontal position of the principal point, relative to the region origin, i.e. + /** + * Returns the value of this feature gives the horizontal position of the principal point, relative to the region origin, i.e. OffsetX. The value of this feature takes into account horizontal binning, decimation, or any other function changing the image resolution. + */ + PropertyF chunkScan3dPrincipalPointU; + /// \brief A floating point property. Returns the value of this feature gives the vertical position of the principal point, relative to the region origin, i.e. + /** + * Returns the value of this feature gives the vertical position of the principal point, relative to the region origin, i.e. OffsetY. The value of this feature takes into account vertical binning, decimation, or any other function changing the image resolution. + */ + PropertyF chunkScan3dPrincipalPointV; + /// \brief A string property. Provides access to a JPEG image transmitted as part of the chunk data. + /** + * Provides access to a JPEG image transmitted as part of the chunk data. + */ + PropertyS mvChunkJPEG; + /// \brief An integer property. Contains a custom identifier previously specified by the user. + /** + * Contains a custom identifier previously specified by the user. + */ + PropertyI64 chunkmvCustomIdentifier; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category for Test Control features. +/** + * A category for Test Control features. + * \ingroup GenICamInterfaceDevice + */ +class TestControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::TestControl object. + explicit TestControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + testPendingAck(), + testEventGenerate(), + testPayloadFormatMode() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( testPendingAck, "TestPendingAck" ); + locator.bindComponent( testEventGenerate, "TestEventGenerate@i" ); + locator.bindComponent( testPayloadFormatMode, "TestPayloadFormatMode" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property. Tests the device's pending acknowledge feature. + /** + * Tests the device's pending acknowledge feature. When this feature is written, the device waits a time period corresponding to the value of TestPendingAck before acknowledging the write. + */ + PropertyI64 testPendingAck; + /// \brief A method object. Generates a Test Event. + /** + * Generates a Test Event. + */ + Method testEventGenerate; + /// \brief An enumerated integer property. This feature allows setting a device in test mode and to output a specific payload format for validation of data streaming. + /** + * This feature allows setting a device in test mode and to output a specific payload format for validation of data streaming. This feature is intended solely for test purposes. The data can be real acquired data or any test pattern. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The test mode is disabled. This feature has no effect and the device is streaming data normally according to its configuration. This option has to be the default after each boot of the device. + * - \b MultiPart (Display string: 'Multi Part'): The device streams data using multi-part payload format with at least one part in each payload. This option must be present if and only if the device supports the multi-part payload format. If the underlying transport layer negotiation has failed to allow the device to enter multi-part mode, it must not be possible to enable this test mode. + * - \b GenDC (Display string: 'Gen DC'): The device streams data using GenDC payload format with at least one component in each payload. This option must be present if the device supports the GenDC payload format. If the underlying transport layer negotiation has failed to allow the device to enter GenDC mode, it must not be possible to enable this test mode. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 testPayloadFormatMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains the transport Layer control features. +/** + * A category that contains the transport Layer control features. + * \ingroup GenICamInterfaceDevice + */ +class TransportLayerControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::TransportLayerControl object. + explicit TransportLayerControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + payloadSize(), + genDCStreamingMode(), + genDCStreamingStatus(), + genDCDescriptor(), + genDCFlowMappingTable(), + mvU3VPHYErrorCount(), + mvU3VLNKErrorCount(), + mvU3VEndpointSelector(), + mvU3VEndpointResetEventCount(), + mvU3VEndpointRetryEventCount(), + mvU3VErrorCounterReset(), + mvU3VSpreadSpectrumClockingSupportDisable(), + deviceTapGeometry(), + ptpEnable(), + ptpClockAccuracy(), + ptpDataSetLatch(), + ptpStatus(), + ptpServoStatus(), + ptpOffsetFromMaster(), + ptpClockID(), + ptpParentClockID(), + ptpGrandmasterClockID(), + gevVersionMajor(), + gevVersionMinor(), + gevDeviceModeIsBigEndian(), + gevDeviceClass(), + gevDeviceModeCharacterSet(), + gevPhysicalLinkConfiguration(), + gevCurrentPhysicalLinkConfiguration(), + gevActiveLinkCount(), + gevSupportedOptionSelector(), + gevSupportedOption(), + gevInterfaceSelector(), + gevLinkSpeed(), + gevMACAddress(), + gevPAUSEFrameReception(), + gevPAUSEFrameTransmission(), + gevCurrentIPConfigurationLLA(), + gevCurrentIPConfigurationDHCP(), + gevCurrentIPConfigurationPersistentIP(), + gevCurrentIPAddress(), + gevCurrentSubnetMask(), + gevCurrentDefaultGateway(), + gevIPConfigurationStatus(), + gevFirstURL(), + gevSecondURL(), + gevNumberOfInterfaces(), + gevPersistentIPAddress(), + gevPersistentSubnetMask(), + gevPersistentDefaultGateway(), + gevMessageChannelCount(), + gevStreamChannelCount(), + gevHeartbeatTimeout(), + gevTimestampTickFrequency(), + gevTimestampControlLatch(), + gevTimestampControlReset(), + gevTimestampValue(), + gevDiscoveryAckDelay(), + gevIEEE1588(), + gevIEEE1588ClockAccuracy(), + gevIEEE1588Status(), + gevGVCPExtendedStatusCodesSelector(), + gevGVCPExtendedStatusCodes(), + gevGVCPPendingAck(), + gevGVCPHeartbeatDisable(), + gevGVCPPendingTimeout(), + gevPrimaryApplicationSwitchoverKey(), + gevGVSPExtendedIDMode(), + gevCCP(), + gevPrimaryApplicationSocket(), + gevPrimaryApplicationIPAddress(), + gevMCPHostPort(), + gevMCDA(), + gevMCTT(), + gevMCRC(), + gevMCSP(), + gevStreamChannelSelector(), + gevSCCFGPacketResendDestination(), + gevSCCFGAllInTransmission(), + gevSCCFGUnconditionalStreaming(), + gevSCCFGExtendedChunkData(), + gevSCPDirection(), + gevSCPInterfaceIndex(), + gevSCPHostPort(), + gevSCPSFireTestPacket(), + gevSCPSDoNotFragment(), + gevSCPSBigEndian(), + gevSCPSPacketSize(), + gevSCPD(), + gevSCDA(), + gevSCSP(), + gevSCZoneCount(), + gevSCZoneDirectionAll(), + gevSCZoneConfigurationLock(), + aPAUSEMACCtrlFramesTransmitted(), + aPAUSEMACCtrlFramesReceived(), + clConfiguration(), + clTimeSlotsCount(), + cxpLinkConfigurationStatus(), + cxpLinkConfigurationPreferred(), + cxpLinkConfiguration(), + cxpLinkSharingEnable(), + cxpLinkSharingSubDeviceSelector(), + cxpLinkSharingSubDeviceType(), + cxpLinkSharingHorizontalStripeCount(), + cxpLinkSharingVerticalStripeCount(), + cxpLinkSharingHorizontalOverlap(), + cxpLinkSharingVerticalOverlap(), + cxpLinkSharingDuplicateStripe(), + cxpConnectionSelector(), + cxpConnectionTestMode(), + cxpConnectionTestErrorCount(), + cxpSendReceiveSelector(), + cxpConnectionTestPacketCount(), + cxpErrorCounterSelector(), + cxpErrorCounterReset(), + cxpErrorCounterValue(), + cxpErrorCounterStatus(), + cxpPoCxpAuto(), + cxpPoCxpTurnOff(), + cxpPoCxpTripReset(), + cxpPoCxpStatus(), + cxpFirstLineTriggerWithFrameStart(), + mvGevSCBWControl(), + mvGevSCBW() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam" ); + locator.bindComponent( payloadSize, "PayloadSize" ); + locator.bindComponent( genDCStreamingMode, "GenDCStreamingMode" ); + locator.bindComponent( genDCStreamingStatus, "GenDCStreamingStatus" ); + locator.bindComponent( genDCDescriptor, "GenDCDescriptor" ); + locator.bindComponent( genDCFlowMappingTable, "GenDCFlowMappingTable" ); + locator.bindComponent( mvU3VPHYErrorCount, "mvU3VPHYErrorCount" ); + locator.bindComponent( mvU3VLNKErrorCount, "mvU3VLNKErrorCount" ); + locator.bindComponent( mvU3VEndpointSelector, "mvU3VEndpointSelector" ); + locator.bindComponent( mvU3VEndpointResetEventCount, "mvU3VEndpointResetEventCount" ); + locator.bindComponent( mvU3VEndpointRetryEventCount, "mvU3VEndpointRetryEventCount" ); + locator.bindComponent( mvU3VErrorCounterReset, "mvU3VErrorCounterReset@i" ); + locator.bindComponent( mvU3VSpreadSpectrumClockingSupportDisable, "mvU3VSpreadSpectrumClockingSupportDisable@i" ); + locator.bindComponent( deviceTapGeometry, "DeviceTapGeometry" ); + locator.bindComponent( ptpEnable, "PtpEnable" ); + locator.bindComponent( ptpClockAccuracy, "PtpClockAccuracy" ); + locator.bindComponent( ptpDataSetLatch, "PtpDataSetLatch@i" ); + locator.bindComponent( ptpStatus, "PtpStatus" ); + locator.bindComponent( ptpServoStatus, "PtpServoStatus" ); + locator.bindComponent( ptpOffsetFromMaster, "PtpOffsetFromMaster" ); + locator.bindComponent( ptpClockID, "PtpClockID" ); + if( !ptpClockID.isValid() ) + { + locator.bindComponent( ptpClockID, "PtpClockId" ); + } + locator.bindComponent( ptpParentClockID, "PtpParentClockID" ); + if( !ptpParentClockID.isValid() ) + { + locator.bindComponent( ptpParentClockID, "PtpParentClockId" ); + } + locator.bindComponent( ptpGrandmasterClockID, "PtpGrandmasterClockID" ); + locator.bindComponent( gevVersionMajor, "GevVersionMajor" ); + locator.bindComponent( gevVersionMinor, "GevVersionMinor" ); + locator.bindComponent( gevDeviceModeIsBigEndian, "GevDeviceModeIsBigEndian" ); + locator.bindComponent( gevDeviceClass, "GevDeviceClass" ); + locator.bindComponent( gevDeviceModeCharacterSet, "GevDeviceModeCharacterSet" ); + locator.bindComponent( gevPhysicalLinkConfiguration, "GevPhysicalLinkConfiguration" ); + locator.bindComponent( gevCurrentPhysicalLinkConfiguration, "GevCurrentPhysicalLinkConfiguration" ); + locator.bindComponent( gevActiveLinkCount, "GevActiveLinkCount" ); + locator.bindComponent( gevSupportedOptionSelector, "GevSupportedOptionSelector" ); + locator.bindComponent( gevSupportedOption, "GevSupportedOption" ); + locator.bindComponent( gevInterfaceSelector, "GevInterfaceSelector" ); + locator.bindComponent( gevLinkSpeed, "GevLinkSpeed" ); + locator.bindComponent( gevMACAddress, "GevMACAddress" ); + locator.bindComponent( gevPAUSEFrameReception, "GevPAUSEFrameReception" ); + locator.bindComponent( gevPAUSEFrameTransmission, "GevPAUSEFrameTransmission" ); + locator.bindComponent( gevCurrentIPConfigurationLLA, "GevCurrentIPConfigurationLLA" ); + locator.bindComponent( gevCurrentIPConfigurationDHCP, "GevCurrentIPConfigurationDHCP" ); + locator.bindComponent( gevCurrentIPConfigurationPersistentIP, "GevCurrentIPConfigurationPersistentIP" ); + locator.bindComponent( gevCurrentIPAddress, "GevCurrentIPAddress" ); + locator.bindComponent( gevCurrentSubnetMask, "GevCurrentSubnetMask" ); + locator.bindComponent( gevCurrentDefaultGateway, "GevCurrentDefaultGateway" ); + locator.bindComponent( gevIPConfigurationStatus, "GevIPConfigurationStatus" ); + locator.bindComponent( gevFirstURL, "GevFirstURL" ); + locator.bindComponent( gevSecondURL, "GevSecondURL" ); + locator.bindComponent( gevNumberOfInterfaces, "GevNumberOfInterfaces" ); + locator.bindComponent( gevPersistentIPAddress, "GevPersistentIPAddress" ); + locator.bindComponent( gevPersistentSubnetMask, "GevPersistentSubnetMask" ); + locator.bindComponent( gevPersistentDefaultGateway, "GevPersistentDefaultGateway" ); + locator.bindComponent( gevMessageChannelCount, "GevMessageChannelCount" ); + locator.bindComponent( gevStreamChannelCount, "GevStreamChannelCount" ); + locator.bindComponent( gevHeartbeatTimeout, "GevHeartbeatTimeout" ); + locator.bindComponent( gevTimestampTickFrequency, "GevTimestampTickFrequency" ); + locator.bindComponent( gevTimestampControlLatch, "GevTimestampControlLatch@i" ); + locator.bindComponent( gevTimestampControlReset, "GevTimestampControlReset@i" ); + locator.bindComponent( gevTimestampValue, "GevTimestampValue" ); + locator.bindComponent( gevDiscoveryAckDelay, "GevDiscoveryAckDelay" ); + locator.bindComponent( gevIEEE1588, "GevIEEE1588" ); + locator.bindComponent( gevIEEE1588ClockAccuracy, "GevIEEE1588ClockAccuracy" ); + locator.bindComponent( gevIEEE1588Status, "GevIEEE1588Status" ); + locator.bindComponent( gevGVCPExtendedStatusCodesSelector, "GevGVCPExtendedStatusCodesSelector" ); + locator.bindComponent( gevGVCPExtendedStatusCodes, "GevGVCPExtendedStatusCodes" ); + locator.bindComponent( gevGVCPPendingAck, "GevGVCPPendingAck" ); + locator.bindComponent( gevGVCPHeartbeatDisable, "GevGVCPHeartbeatDisable" ); + locator.bindComponent( gevGVCPPendingTimeout, "GevGVCPPendingTimeout" ); + locator.bindComponent( gevPrimaryApplicationSwitchoverKey, "GevPrimaryApplicationSwitchoverKey" ); + locator.bindComponent( gevGVSPExtendedIDMode, "GevGVSPExtendedIDMode" ); + locator.bindComponent( gevCCP, "GevCCP" ); + locator.bindComponent( gevPrimaryApplicationSocket, "GevPrimaryApplicationSocket" ); + locator.bindComponent( gevPrimaryApplicationIPAddress, "GevPrimaryApplicationIPAddress" ); + locator.bindComponent( gevMCPHostPort, "GevMCPHostPort" ); + locator.bindComponent( gevMCDA, "GevMCDA" ); + locator.bindComponent( gevMCTT, "GevMCTT" ); + locator.bindComponent( gevMCRC, "GevMCRC" ); + locator.bindComponent( gevMCSP, "GevMCSP" ); + locator.bindComponent( gevStreamChannelSelector, "GevStreamChannelSelector" ); + locator.bindComponent( gevSCCFGPacketResendDestination, "GevSCCFGPacketResendDestination" ); + locator.bindComponent( gevSCCFGAllInTransmission, "GevSCCFGAllInTransmission" ); + locator.bindComponent( gevSCCFGUnconditionalStreaming, "GevSCCFGUnconditionalStreaming" ); + locator.bindComponent( gevSCCFGExtendedChunkData, "GevSCCFGExtendedChunkData" ); + locator.bindComponent( gevSCPDirection, "GevSCPDirection" ); + locator.bindComponent( gevSCPInterfaceIndex, "GevSCPInterfaceIndex" ); + locator.bindComponent( gevSCPHostPort, "GevSCPHostPort" ); + locator.bindComponent( gevSCPSFireTestPacket, "GevSCPSFireTestPacket" ); + locator.bindComponent( gevSCPSDoNotFragment, "GevSCPSDoNotFragment" ); + locator.bindComponent( gevSCPSBigEndian, "GevSCPSBigEndian" ); + locator.bindComponent( gevSCPSPacketSize, "GevSCPSPacketSize" ); + locator.bindComponent( gevSCPD, "GevSCPD" ); + locator.bindComponent( gevSCDA, "GevSCDA" ); + locator.bindComponent( gevSCSP, "GevSCSP" ); + locator.bindComponent( gevSCZoneCount, "GevSCZoneCount" ); + locator.bindComponent( gevSCZoneDirectionAll, "GevSCZoneDirectionAll" ); + locator.bindComponent( gevSCZoneConfigurationLock, "GevSCZoneConfigurationLock" ); + locator.bindComponent( aPAUSEMACCtrlFramesTransmitted, "aPAUSEMACCtrlFramesTransmitted" ); + locator.bindComponent( aPAUSEMACCtrlFramesReceived, "aPAUSEMACCtrlFramesReceived" ); + locator.bindComponent( clConfiguration, "ClConfiguration" ); + locator.bindComponent( clTimeSlotsCount, "ClTimeSlotsCount" ); + locator.bindComponent( cxpLinkConfigurationStatus, "CxpLinkConfigurationStatus" ); + locator.bindComponent( cxpLinkConfigurationPreferred, "CxpLinkConfigurationPreferred" ); + locator.bindComponent( cxpLinkConfiguration, "CxpLinkConfiguration" ); + locator.bindComponent( cxpLinkSharingEnable, "CxpLinkSharingEnable" ); + locator.bindComponent( cxpLinkSharingSubDeviceSelector, "CxpLinkSharingSubDeviceSelector" ); + locator.bindComponent( cxpLinkSharingSubDeviceType, "CxpLinkSharingSubDeviceType" ); + locator.bindComponent( cxpLinkSharingHorizontalStripeCount, "CxpLinkSharingHorizontalStripeCount" ); + locator.bindComponent( cxpLinkSharingVerticalStripeCount, "CxpLinkSharingVerticalStripeCount" ); + locator.bindComponent( cxpLinkSharingHorizontalOverlap, "CxpLinkSharingHorizontalOverlap" ); + locator.bindComponent( cxpLinkSharingVerticalOverlap, "CxpLinkSharingVerticalOverlap" ); + locator.bindComponent( cxpLinkSharingDuplicateStripe, "CxpLinkSharingDuplicateStripe" ); + locator.bindComponent( cxpConnectionSelector, "CxpConnectionSelector" ); + locator.bindComponent( cxpConnectionTestMode, "CxpConnectionTestMode" ); + locator.bindComponent( cxpConnectionTestErrorCount, "CxpConnectionTestErrorCount" ); + locator.bindComponent( cxpSendReceiveSelector, "CxpSendReceiveSelector" ); + locator.bindComponent( cxpConnectionTestPacketCount, "CxpConnectionTestPacketCount" ); + locator.bindComponent( cxpErrorCounterSelector, "CxpErrorCounterSelector" ); + locator.bindComponent( cxpErrorCounterReset, "CxpErrorCounterReset@i" ); + locator.bindComponent( cxpErrorCounterValue, "CxpErrorCounterValue" ); + locator.bindComponent( cxpErrorCounterStatus, "CxpErrorCounterStatus" ); + locator.bindComponent( cxpPoCxpAuto, "CxpPoCxpAuto@i" ); + locator.bindComponent( cxpPoCxpTurnOff, "CxpPoCxpTurnOff@i" ); + locator.bindComponent( cxpPoCxpTripReset, "CxpPoCxpTripReset@i" ); + locator.bindComponent( cxpPoCxpStatus, "CxpPoCxpStatus" ); + locator.bindComponent( cxpFirstLineTriggerWithFrameStart, "CxpFirstLineTriggerWithFrameStart" ); + locator.bindComponent( mvGevSCBWControl, "mvGevSCBWControl" ); + locator.bindComponent( mvGevSCBW, "mvGevSCBW" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An integer property. Provides the number of bytes transferred for each data buffer or chunk on the stream channel. + /** + * Provides the number of bytes transferred for each data buffer or chunk on the stream channel. This includes any end-of-line, end-of-frame statistics or other stamp data. This is the total size of data payload for a data block. + */ + PropertyI64 payloadSize; + /// \brief An enumerated integer property. Controls the device's streaming format. + /** + * Controls the device's streaming format. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The device will only stream data in its native format. + * - \b On (Display string: 'On'): The device will stream all its data in the generic GenDC format. + * - \b Automatic (Display string: 'Automatic'): The device will automatically choose in which format it streams its data. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 genDCStreamingMode; + /// \brief An enumerated integer property. Returns whether the current device data streaming format is GenDC. + /** + * Returns whether the current device data streaming format is GenDC. This value is conditioned by the GenDCStreamingMode. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The device will only stream data in its native format. + * - \b On (Display string: 'On'): The device will stream all its data in the generic GenDC format. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 genDCStreamingStatus; + /// \brief A string property. Returns a preliminary GenDC Descriptor that can be used as reference for the data to be streamed out by the device in its current configuration. + /** + * Returns a preliminary GenDC Descriptor that can be used as reference for the data to be streamed out by the device in its current configuration. This information can be used to set up the receiver in advance to be ready for the data Containers to come. + */ + PropertyS genDCDescriptor; + /// \brief A string property. Returns the GenDC Container data Flow mapping table that will be used to transport the GenDC Container. + /** + * Returns the GenDC Container data Flow mapping table that will be used to transport the GenDC Container. + */ + PropertyS genDCFlowMappingTable; + /// \brief An integer property. Counts the number of errors on the PHY interface. + /** + * Counts the number of errors on the PHY interface. + */ + PropertyI64 mvU3VPHYErrorCount; + /// \brief An integer property. Counts the number of errors on the USB3 link. + /** + * Counts the number of errors on the USB3 link. + */ + PropertyI64 mvU3VLNKErrorCount; + /// \brief An enumerated integer property. Selects the endpoint for the event counters. + /** + * Selects the endpoint for the event counters. + * + * The following string values might be valid for this feature: + * - \b mvControl (Display string: 'mv Control'): The control endpoint of the camera. + * - \b mvEvent (Display string: 'mv Event'): The event endpoint of the camera. + * - \b mvStreaming (Display string: 'mv Streaming'): The streaming endpoint of the camera. + * - \b mvDebug (Display string: 'mv Debug'): The debug endpoint of the camera. + * - \b mvAll (Display string: 'mv All'): Sums up data from all endpoints. + * - \b mvReserved (Display string: 'mv Reserved'): Reserved. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvU3VEndpointSelector; + /// \brief An integer property. Counts the number of reset events received on all endpoints. + /** + * Counts the number of reset events received on all endpoints. + */ + PropertyI64 mvU3VEndpointResetEventCount; + /// \brief An integer property. Counts the number of retry events received on all endpoints. + /** + * Counts the number of retry events received on all endpoints. + */ + PropertyI64 mvU3VEndpointRetryEventCount; + /// \brief A method object. Resets the 'mvU3VPHYErrorCount' and 'mvU3VLNKErrorCount' registers. + /** + * Resets the 'mvU3VPHYErrorCount' and 'mvU3VLNKErrorCount' registers. + */ + Method mvU3VErrorCounterReset; + /// \brief A method object. Disable the spread spectrum clocking support. + /** + * Disable the spread spectrum clocking support. + */ + Method mvU3VSpreadSpectrumClockingSupportDisable; + /// \brief An enumerated integer property. This device tap geometry feature describes the geometrical properties characterizing the taps of a camera as presented at the output of the device. + /** + * This device tap geometry feature describes the geometrical properties characterizing the taps of a camera as presented at the output of the device. + * + * The following string values might be valid for this feature: + * - \b Geometry_1X_1Y (Display string: 'Geometry_1X_1Y'): Geometry_1X_1Y + * - \b Geometry_1X2_1Y (Display string: 'Geometry_1X2_1Y'): Geometry_1X2_1Y + * - \b Geometry_1X2_1Y2 (Display string: 'Geometry_1X2_1Y2'): Geometry_1X2_1Y2 + * - \b Geometry_2X_1Y (Display string: 'Geometry_2X_1Y'): Geometry_2X_1Y + * - \b Geometry_2X_1Y2 (Display string: 'Geometry_2X_1Y2'): Geometry_2X_1Y2 + * - \b Geometry_2XE_1Y (Display string: 'Geometry_2XE_1Y'): Geometry_2XE_1Y + * - \b Geometry_2XE_1Y2 (Display string: 'Geometry_2XE_1Y2'): Geometry_2XE_1Y2 + * - \b Geometry_2XM_1Y (Display string: 'Geometry_2XM_1Y'): Geometry_2XM_1Y + * - \b Geometry_2XM_1Y2 (Display string: 'Geometry_2XM_1Y2'): Geometry_2XM_1Y2 + * - \b Geometry_1X_1Y2 (Display string: 'Geometry_1X_1Y2'): Geometry_1X_1Y2 + * - \b Geometry_1X_2YE (Display string: 'Geometry_1X_2YE'): Geometry_1X_2YE + * - \b Geometry_1X3_1Y (Display string: 'Geometry_1X3_1Y'): Geometry_1X3_1Y + * - \b Geometry_3X_1Y (Display string: 'Geometry_3X_1Y'): Geometry_3X_1Y + * - \b Geometry_1X (Display string: 'Geometry_1X'): Geometry_1X + * - \b Geometry_1X2 (Display string: 'Geometry_1X2'): Geometry_1X2 + * - \b Geometry_2X (Display string: 'Geometry_2X'): Geometry_2X + * - \b Geometry_2XE (Display string: 'Geometry_2XE'): Geometry_2XE + * - \b Geometry_2XM (Display string: 'Geometry_2XM'): Geometry_2XM + * - \b Geometry_1X3 (Display string: 'Geometry_1X3'): Geometry_1X3 + * - \b Geometry_3X (Display string: 'Geometry_3X'): Geometry_3X + * - \b Geometry_1X4_1Y (Display string: 'Geometry_1X4_1Y'): Geometry_1X4_1Y + * - \b Geometry_4X_1Y (Display string: 'Geometry_4X_1Y'): Geometry_4X_1Y + * - \b Geometry_2X2_1Y (Display string: 'Geometry_2X2_1Y'): Geometry_2X2_1Y + * - \b Geometry_2X2E_1Y (Display string: 'Geometry_2X2E_1Y'): Geometry_2X2E_1Y + * - \b Geometry_2X2M_1Y (Display string: 'Geometry_2X2M_1Y'): Geometry_2X2M_1Y + * - \b Geometry_1X2_2YE (Display string: 'Geometry_1X2_2YE'): Geometry_1X2_2YE + * - \b Geometry_2X_2YE (Display string: 'Geometry_2X_2YE'): Geometry_2X_2YE + * - \b Geometry_2XE_2YE (Display string: 'Geometry_2XE_2YE'): Geometry_2XE_2YE + * - \b Geometry_2XM_2YE (Display string: 'Geometry_2XM_2YE'): Geometry_2XM_2YE + * - \b Geometry_1X4 (Display string: 'Geometry_1X4'): Geometry_1X4 + * - \b Geometry_4X (Display string: 'Geometry_4X'): Geometry_4X + * - \b Geometry_2X2 (Display string: 'Geometry_2X2'): Geometry_2X2 + * - \b Geometry_2X2E (Display string: 'Geometry_2X2E'): Geometry_2X2E + * - \b Geometry_2X2M (Display string: 'Geometry_2X2M'): Geometry_2X2M + * - \b Geometry_1X8_1Y (Display string: 'Geometry_1X8_1Y'): Geometry_1X8_1Y + * - \b Geometry_8X_1Y (Display string: 'Geometry_8X_1Y'): Geometry_8X_1Y + * - \b Geometry_4X2_1Y (Display string: 'Geometry_4X2_1Y'): Geometry_4X2_1Y + * - \b Geometry_2X2E_2YE (Display string: 'Geometry_2X2E_2YE'): Geometry_2X2E_2YE + * - \b Geometry_1X8 (Display string: 'Geometry_1X8'): Geometry_1X8 + * - \b Geometry_8X (Display string: 'Geometry_8X'): Geometry_8X + * - \b Geometry_4X2 (Display string: 'Geometry_4X2'): Geometry_4X2 + * - \b Geometry_4X2E (Display string: 'Geometry_4X2E'): Geometry_4X2E + * - \b Geometry_4X2E_1Y (Display string: 'Geometry_4X2E_1Y'): Geometry_4X2E_1Y + * - \b Geometry_1X10_1Y (Display string: 'Geometry_1X10_1Y'): Geometry_1X10_1Y + * - \b Geometry_10X_1Y (Display string: 'Geometry_10X_1Y'): Geometry_10X_1Y + * - \b Geometry_1X10 (Display string: 'Geometry_1X10'): Geometry_1X10 + * - \b Geometry_10X (Display string: 'Geometry_10X'): Geometry_10X + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceTapGeometry; + /// \brief A boolean property. Enables the Precision Time Protocol (PTP). + /** + * Enables the Precision Time Protocol (PTP). + */ + PropertyIBoolean ptpEnable; + /// \brief An enumerated integer property. Indicates the expected accuracy of the device PTP clock when it is the grandmaster, or in the event it becomes the grandmaster. + /** + * Indicates the expected accuracy of the device PTP clock when it is the grandmaster, or in the event it becomes the grandmaster. + * + * The following string values might be valid for this feature: + * - \b Within25ns (Display string: 'Within 25ns'): Within 25ns + * - \b Within100ns (Display string: 'Within 100ns'): Within 100ns + * - \b Within250ns (Display string: 'Within 250ns'): Within 250ns + * - \b Within1us (Display string: 'Within 1us'): Within 1us + * - \b Within2p5us (Display string: 'Within 2p 5us'): Within 2p 5us + * - \b Within10us (Display string: 'Within 10us'): Within 10us + * - \b Within25us (Display string: 'Within 25us'): Within 25us + * - \b Within100us (Display string: 'Within 100us'): Within 100us + * - \b Within250us (Display string: 'Within 250us'): Within 250us + * - \b Within1ms (Display string: 'Within 1ms'): Within 1ms + * - \b Within2p5ms (Display string: 'Within 2p 5ms'): Within 2p 5ms + * - \b Within10ms (Display string: 'Within 10ms'): Within 10ms + * - \b Within25ms (Display string: 'Within 25ms'): Within 25ms + * - \b Within100ms (Display string: 'Within 100ms'): Within 100ms + * - \b Within250ms (Display string: 'Within 250ms'): Within 250ms + * - \b Within1s (Display string: 'Within 1s'): Within 1s + * - \b Within10s (Display string: 'Within 10s'): Within 10s + * - \b GreaterThan10s (Display string: 'Greater Than 10s'): Greater Than 10s + * - \b AlternatePTPProfile (Display string: 'Alternate PTP Profile'): Alternate PTP Profile + * - \b Unknown (Display string: 'Unknown'): Unknown + * - \b Reserved (Display string: 'Reserved'): Reserved + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 ptpClockAccuracy; + /// \brief A method object. Latches the current values from the device's PTP clock data set. + /** + * Latches the current values from the device's PTP clock data set. + */ + Method ptpDataSetLatch; + /// \brief An enumerated integer property. Returns the latched state of the PTP clock. + /** + * Returns the latched state of the PTP clock. + * + * The following string values might be valid for this feature: + * - \b Initializing (Display string: 'Initializing'): Initializing + * - \b Faulty (Display string: 'Faulty'): Faulty + * - \b Disabled (Display string: 'Disabled'): Disabled + * - \b Listening (Display string: 'Listening'): Listening + * - \b PreMaster (Display string: 'Pre Master'): Pre Master + * - \b Master (Display string: 'Master'): Master + * - \b Passive (Display string: 'Passive'): Passive + * - \b Uncalibrated (Display string: 'Uncalibrated'): Uncalibrated + * - \b Slave (Display string: 'Slave'): Slave + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 ptpStatus; + /// \brief An enumerated integer property. Returns the latched state of the clock servo. + /** + * Returns the latched state of the clock servo. When the servo is in a locked state, the value returned is 'Locked'. When the servo is in a non-locked state, a device-specific value can be returned to give specific information. If no device-specific value is available to describe the current state of the clock servo, the value should be 'Unknown'. + * + * The following string values might be valid for this feature: + * - \b Unknown (Display string: 'Unknown'): Unknown + * - \b Locked (Display string: 'Locked'): Locked + * - \b Device-Specific (Display string: 'Device - Specific'): Device - Specific + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 ptpServoStatus; + /// \brief An integer property. Returns the latched offset from the PTP master clock in nanoseconds. + /** + * Returns the latched offset from the PTP master clock in nanoseconds. + */ + PropertyI64 ptpOffsetFromMaster; + /// \brief An integer property. Returns the latched clock ID of the PTP device. + /** + * Returns the latched clock ID of the PTP device. + */ + PropertyI64 ptpClockID; + /// \brief An integer property. Returns the latched parent clock ID of the PTP device. + /** + * Returns the latched parent clock ID of the PTP device. The parent clock ID is the clock ID of the current master clock. + */ + PropertyI64 ptpParentClockID; + /// \brief An integer property. Returns the latched grandmaster clock ID of the PTP device. + /** + * Returns the latched grandmaster clock ID of the PTP device. The grandmaster clock ID is the clock ID of the current grandmaster clock. + */ + PropertyI64 ptpGrandmasterClockID; + /// \brief An integer property. This feature is deprecated (See DeviceTLVersionMajor). + /** + * \deprecated + * This feature is deprecated (See DeviceTLVersionMajor). It was representing the major version of the specification. + */ + PropertyI64 gevVersionMajor; + /// \brief An integer property. This feature is deprecated (See DeviceTLVersionMinor). + /** + * \deprecated + * This feature is deprecated (See DeviceTLVersionMinor). It was representing the minor version of the specification. + */ + PropertyI64 gevVersionMinor; + /// \brief A boolean property. This feature is deprecated (See DeviceRegistersEndianness). + /** + * \deprecated + * This feature is deprecated (See DeviceRegistersEndianness). It was representing the Endianness of the device registers. + */ + PropertyIBoolean gevDeviceModeIsBigEndian; + /// \brief An enumerated integer property. This feature is deprecated (See DeviceType). + /** + * \deprecated + * This feature is deprecated (See DeviceType). It was representing the class of the device. + * + * The following string values might be valid for this feature: + * - \b Transmitter (Display string: 'Transmitter'): Transmitter + * - \b Receiver (Display string: 'Receiver'): Receiver + * - \b Transceiver (Display string: 'Transceiver'): Transceiver + * - \b Peripheral (Display string: 'Peripheral'): Peripheral + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevDeviceClass; + /// \brief An enumerated integer property. This feature is deprecated (See DeviceCharacterSet). + /** + * \deprecated + * This feature is deprecated (See DeviceCharacterSet). It was representing the character set used by all the strings of the device. + * + * The following string values might be valid for this feature: + * - \b UTF8 (Display string: 'UTF 8'): UTF 8 + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevDeviceModeCharacterSet; + /// \brief An enumerated integer property. Controls the principal physical link configuration to use on next restart/power-up of the device. + /** + * Controls the principal physical link configuration to use on next restart/power-up of the device. + * + * The following string values might be valid for this feature: + * - \b SingleLink (Display string: 'Single Link'): Single Link + * - \b MultiLink (Display string: 'Multi Link'): Multi Link + * - \b StaticLAG (Display string: 'Static LAG'): Static LAG + * - \b DynamicLAG (Display string: 'Dynamic LAG'): Dynamic LAG + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevPhysicalLinkConfiguration; + /// \brief An enumerated integer property. Indicates the current physical link configuration of the device. + /** + * Indicates the current physical link configuration of the device. + * + * The following string values might be valid for this feature: + * - \b SingleLink (Display string: 'Single Link'): Single Link + * - \b MultiLink (Display string: 'Multi Link'): Multi Link + * - \b StaticLAG (Display string: 'Static LAG'): Static LAG + * - \b DynamicLAG (Display string: 'Dynamic LAG'): Dynamic LAG + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevCurrentPhysicalLinkConfiguration; + /// \brief An integer property. Indicates the current number of active logical links. + /** + * Indicates the current number of active logical links. + */ + PropertyI64 gevActiveLinkCount; + /// \brief An enumerated integer property. Selects the GEV option to interrogate for existing support. + /** + * Selects the GEV option to interrogate for existing support. + * + * The following string values might be valid for this feature: + * - \b SingleLink (Display string: 'Single Link'): Single Link + * - \b MultiLink (Display string: 'Multi Link'): Multi Link + * - \b StaticLAG (Display string: 'Static LAG'): Static LAG + * - \b DynamicLAG (Display string: 'Dynamic LAG'): Dynamic LAG + * - \b PAUSEFrameReception (Display string: 'PAUSE Frame Reception'): PAUSE Frame Reception + * - \b PAUSEFrameGeneration (Display string: 'PAUSE Frame Generation'): PAUSE Frame Generation + * - \b IPConfigurationLLA (Display string: 'IP Configuration LLA'): IP Configuration LLA + * - \b IPConfigurationDHCP (Display string: 'IP Configuration DHCP'): IP Configuration DHCP + * - \b IPConfigurationPersistentIP (Display string: 'IP Configuration Persistent IP'): IP Configuration Persistent IP + * - \b StreamChannelSourceSocket (Display string: 'Stream Channel Source Socket'): Stream Channel Source Socket + * - \b StandardIDMode (Display string: 'Standard ID Mode'): Standard ID Mode + * - \b MessageChannelSourceSocket (Display string: 'Message Channel Source Socket'): Message Channel Source Socket + * - \b CommandsConcatenation (Display string: 'Commands Concatenation'): Commands Concatenation + * - \b WriteMem (Display string: 'Write Mem'): Write Mem + * - \b PacketResend (Display string: 'Packet Resend'): Packet Resend + * - \b Event (Display string: 'Event'): Event + * - \b EventData (Display string: 'Event Data'): Event Data + * - \b PendingAck (Display string: 'Pending Ack'): Pending Ack + * - \b IEEE1588 (Display string: 'IEEE 1588'): IEEE 1588 + * - \b Ptp (Display string: 'Ptp'): Ptp + * - \b Action (Display string: 'Action'): Action + * - \b UnconditionalAction (Display string: 'Unconditional Action'): Unconditional Action + * - \b ScheduledAction (Display string: 'Scheduled Action'): Scheduled Action + * - \b PrimaryApplicationSwitchover (Display string: 'Primary Application Switchover'): Primary Application Switchover + * - \b ExtendedStatusCodes (Display string: 'Extended Status Codes'): Extended Status Codes + * - \b ExtendedStatusCodesVersion2_0 (Display string: 'Extended Status Codes Version 2 0'): Extended Status Codes Version 2 0 + * - \b DiscoveryAckDelay (Display string: 'Discovery Ack Delay'): Discovery Ack Delay + * - \b DiscoveryAckDelayWritable (Display string: 'Discovery Ack Delay Writable'): Discovery Ack Delay Writable + * - \b TestData (Display string: 'Test Data'): Test Data + * - \b ManifestTable (Display string: 'Manifest Table'): Manifest Table + * - \b CCPApplicationSocket (Display string: 'CCP Application Socket'): CCP Application Socket + * - \b LinkSpeed (Display string: 'Link Speed'): Link Speed + * - \b HeartbeatDisable (Display string: 'Heartbeat Disable'): Heartbeat Disable + * - \b SerialNumber (Display string: 'Serial Number'): Serial Number + * - \b UserDefinedName (Display string: 'User Defined Name'): User Defined Name + * - \b StreamChannel0BigAndLittleEndian (Display string: 'Stream Channel 0 Big And Little Endian'): Stream Channel 0 Big And Little Endian + * - \b StreamChannel0IPReassembly (Display string: 'Stream Channel 0 IP Reassembly'): Stream Channel 0 IP Reassembly + * - \b StreamChannel0MultiZone (Display string: 'Stream Channel 0 Multi Zone'): Stream Channel 0 Multi Zone + * - \b StreamChannel0PacketResendDestination (Display string: 'Stream Channel 0 Packet Resend Destination'): Stream Channel 0 Packet Resend Destination + * - \b StreamChannel0AllInTransmission (Display string: 'Stream Channel 0 All In Transmission'): Stream Channel 0 All In Transmission + * - \b StreamChannel0UnconditionalStreaming (Display string: 'Stream Channel 0 Unconditional Streaming'): Stream Channel 0 Unconditional Streaming + * - \b StreamChannel0ExtendedChunkData (Display string: 'Stream Channel 0 Extended Chunk Data'): Stream Channel 0 Extended Chunk Data + * - \b StreamChannel1BigAndLittleEndian (Display string: 'Stream Channel 1 Big And Little Endian'): Stream Channel 1 Big And Little Endian + * - \b StreamChannel1IPReassembly (Display string: 'Stream Channel 1 IP Reassembly'): Stream Channel 1 IP Reassembly + * - \b StreamChannel1MultiZone (Display string: 'Stream Channel 1 Multi Zone'): Stream Channel 1 Multi Zone + * - \b StreamChannel1PacketResendDestination (Display string: 'Stream Channel 1 Packet Resend Destination'): Stream Channel 1 Packet Resend Destination + * - \b StreamChannel1AllInTransmission (Display string: 'Stream Channel 1 All In Transmission'): Stream Channel 1 All In Transmission + * - \b StreamChannel1UnconditionalStreaming (Display string: 'Stream Channel 1 Unconditional Streaming'): Stream Channel 1 Unconditional Streaming + * - \b StreamChannel1ExtendedChunkData (Display string: 'Stream Channel 1 Extended Chunk Data'): Stream Channel 1 Extended Chunk Data + * - \b StreamChannel2BigAndLittleEndian (Display string: 'Stream Channel 2 Big And Little Endian'): Stream Channel 2 Big And Little Endian + * - \b StreamChannel2IPReassembly (Display string: 'Stream Channel 2 IP Reassembly'): Stream Channel 2 IP Reassembly + * - \b StreamChannel2MultiZone (Display string: 'Stream Channel 2 Multi Zone'): Stream Channel 2 Multi Zone + * - \b StreamChannel2PacketResendDestination (Display string: 'Stream Channel 2 Packet Resend Destination'): Stream Channel 2 Packet Resend Destination + * - \b StreamChannel2AllInTransmission (Display string: 'Stream Channel 2 All In Transmission'): Stream Channel 2 All In Transmission + * - \b StreamChannel2UnconditionalStreaming (Display string: 'Stream Channel 2 Unconditional Streaming'): Stream Channel 2 Unconditional Streaming + * - \b StreamChannel2ExtendedChunkData (Display string: 'Stream Channel 2 Extended Chunk Data'): Stream Channel 2 Extended Chunk Data + * - \b StreamChannel\#3\#ExtendedChunkData (Display string: 'Stream Channel \#3\# Extended Chunk Data'): Stream Channel \#3\# Extended Chunk Data + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevSupportedOptionSelector; + /// \brief A boolean property. Returns if the selected GEV option is supported. + /** + * Returns if the selected GEV option is supported. + */ + PropertyIBoolean gevSupportedOption; + /// \brief An integer property. Selects which logical link to control. + /** + * Selects which logical link to control. + */ + PropertyI64 gevInterfaceSelector; + /// \brief An integer property. This feature is deprecated (See DeviceLinkSpeed). + /** + * \deprecated + * This feature is deprecated (See DeviceLinkSpeed). It was representing the speed of transmission negotiated by the given logical link. + */ + PropertyI64 gevLinkSpeed; + /// \brief An integer property. MAC address of the logical link. + /** + * MAC address of the logical link. + */ + PropertyI64 gevMACAddress; + /// \brief A boolean property. Controls whether incoming PAUSE Frames are handled on the given logical link. + /** + * Controls whether incoming PAUSE Frames are handled on the given logical link. + */ + PropertyIBoolean gevPAUSEFrameReception; + /// \brief A boolean property. Controls whether PAUSE Frames can be generated on the given logical link. + /** + * Controls whether PAUSE Frames can be generated on the given logical link. + */ + PropertyIBoolean gevPAUSEFrameTransmission; + /// \brief A boolean property. Controls whether the Link Local Address IP configuration scheme is activated on the given logical link. + /** + * Controls whether the Link Local Address IP configuration scheme is activated on the given logical link. + */ + PropertyIBoolean gevCurrentIPConfigurationLLA; + /// \brief A boolean property. Controls whether the DHCP IP configuration scheme is activated on the given logical link. + /** + * Controls whether the DHCP IP configuration scheme is activated on the given logical link. + */ + PropertyIBoolean gevCurrentIPConfigurationDHCP; + /// \brief A boolean property. Controls whether the PersistentIP configuration scheme is activated on the given logical link. + /** + * Controls whether the PersistentIP configuration scheme is activated on the given logical link. + */ + PropertyIBoolean gevCurrentIPConfigurationPersistentIP; + /// \brief An integer property. Reports the IP address for the given logical link. + /** + * Reports the IP address for the given logical link. + */ + PropertyI64 gevCurrentIPAddress; + /// \brief An integer property. Reports the subnet mask of the given logical link. + /** + * Reports the subnet mask of the given logical link. + */ + PropertyI64 gevCurrentSubnetMask; + /// \brief An integer property. Reports the default gateway IP address of the given logical link. + /** + * Reports the default gateway IP address of the given logical link. + */ + PropertyI64 gevCurrentDefaultGateway; + /// \brief An enumerated integer property. Reports the current IP configuration status. + /** + * Reports the current IP configuration status. + * + * The following string values might be valid for this feature: + * - \b None (Display string: 'None'): None + * - \b PersistentIP (Display string: 'Persistent IP'): Persistent IP + * - \b DHCP (Display string: 'DHCP'): DHCP + * - \b LLA (Display string: 'LLA'): LLA + * - \b ForceIP (Display string: 'Force IP'): Force IP + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevIPConfigurationStatus; + /// \brief A string property. Indicates the first URL to the GenICam XML device description file. + /** + * Indicates the first URL to the GenICam XML device description file. The First URL is used as the first choice by the application to retrieve the GenICam XML device description file. + */ + PropertyS gevFirstURL; + /// \brief A string property. Indicates the second URL to the GenICam XML device description file. + /** + * Indicates the second URL to the GenICam XML device description file. This URL is an alternative if the application was unsuccessful to retrieve the device description file using the first URL. + */ + PropertyS gevSecondURL; + /// \brief An integer property. This feature is deprecated (See DeviceLinkSelector). + /** + * \deprecated + * This feature is deprecated (See DeviceLinkSelector). It was representing the number of logical links supported by this device. + */ + PropertyI64 gevNumberOfInterfaces; + /// \brief An integer property. Controls the Persistent IP address for this logical link. + /** + * Controls the Persistent IP address for this logical link. It is only used when the device boots with the Persistent IP configuration scheme. + */ + PropertyI64 gevPersistentIPAddress; + /// \brief An integer property. Controls the Persistent subnet mask associated with the Persistent IP address on this logical link. + /** + * Controls the Persistent subnet mask associated with the Persistent IP address on this logical link. It is only used when the device boots with the Persistent IP configuration scheme. + */ + PropertyI64 gevPersistentSubnetMask; + /// \brief An integer property. Controls the persistent default gateway for this logical link. + /** + * Controls the persistent default gateway for this logical link. It is only used when the device boots with the Persistent IP configuration scheme. + */ + PropertyI64 gevPersistentDefaultGateway; + /// \brief An integer property. This feature is deprecated (See DeviceEventChannelCount). + /** + * \deprecated + * This feature is deprecated (See DeviceEventChannelCount). It was representing the number of message channels supported by this device. + */ + PropertyI64 gevMessageChannelCount; + /// \brief An integer property. This feature is deprecated (See DeviceStreamChannelCount). + /** + * \deprecated + * This feature is deprecated (See DeviceStreamChannelCount). It was representing the number of stream channels supported by this device. + */ + PropertyI64 gevStreamChannelCount; + /// \brief An integer property. This feature is deprecated (See DeviceLinkHeartbeatTimeout). + /** + * \deprecated + * This feature is deprecated (See DeviceLinkHeartbeatTimeout). It was controlling the current heartbeat timeout in milliseconds. + */ + PropertyI64 gevHeartbeatTimeout; + /// \brief An integer property. This feature is deprecated (See the increment of the TimestampLatchValue feature). + /** + * \deprecated + * This feature is deprecated (See the increment of the TimestampLatchValue feature). It was used to indicate the number of timestamp ticks in 1 second (frequency in Hz). If PTP is used, this feature must return 1,000,000,000 (1 GHz). + */ + PropertyI64 gevTimestampTickFrequency; + /// \brief A method object. This feature is deprecated (See TimestampLatch). + /** + * \deprecated + * This feature is deprecated (See TimestampLatch). It was used to latche the current timestamp counter into GevTimestampValue. + */ + Method gevTimestampControlLatch; + /// \brief A method object. This feature is deprecated (See TimestampReset). + /** + * \deprecated + * This feature is deprecated (See TimestampReset). It was used to reset the timestamp counter to 0. This feature is not available or as no effect when PTP is used. + */ + Method gevTimestampControlReset; + /// \brief An integer property. This feature is deprecated (See TimestampLatchValue). + /** + * \deprecated + * This feature is deprecated (See TimestampLatchValue). It was used to return the latched 64-bit value of the timestamp counter. + */ + PropertyI64 gevTimestampValue; + /// \brief An integer property. Indicates the maximum randomized delay the device will wait to acknowledge a discovery command. + /** + * Indicates the maximum randomized delay the device will wait to acknowledge a discovery command. + */ + PropertyI64 gevDiscoveryAckDelay; + /// \brief A boolean property. This feature is deprecated (See PtpEnable). + /** + * \deprecated + * This feature is deprecated (See PtpEnable). It was used to enable the IEEE 1588 Precision Time Protocol to control the timestamp register. + */ + PropertyIBoolean gevIEEE1588; + /// \brief An enumerated integer property. This feature is deprecated (See PtpClockAccurarcy). + /** + * \deprecated + * This feature is deprecated (See PtpClockAccurarcy). It was used to indicate the expected accuracy of the device clock when it is the grandmaster, or in the event it becomes the grandmaster. + * + * The following string values might be valid for this feature: + * - \b Within25ns (Display string: 'Within 25ns'): Within 25ns + * - \b Within100ns (Display string: 'Within 100ns'): Within 100ns + * - \b Within250ns (Display string: 'Within 250ns'): Within 250ns + * - \b Within1us (Display string: 'Within 1us'): Within 1us + * - \b Within2p5u (Display string: 'Within 2p 5u'): Within 2p 5u + * - \b Within10us (Display string: 'Within 10us'): Within 10us + * - \b Within25us (Display string: 'Within 25us'): Within 25us + * - \b Within100us (Display string: 'Within 100us'): Within 100us + * - \b Within250us (Display string: 'Within 250us'): Within 250us + * - \b Within1ms (Display string: 'Within 1ms'): Within 1ms + * - \b Within2p5ms (Display string: 'Within 2p 5ms'): Within 2p 5ms + * - \b Within10ms (Display string: 'Within 10ms'): Within 10ms + * - \b Within25ms (Display string: 'Within 25ms'): Within 25ms + * - \b Within100ms (Display string: 'Within 100ms'): Within 100ms + * - \b Within250ms (Display string: 'Within 250ms'): Within 250ms + * - \b Within1s (Display string: 'Within 1s'): Within 1s + * - \b Within10s (Display string: 'Within 10s'): Within 10s + * - \b GreaterThan10s (Display string: 'Greater Than 10s'): Greater Than 10s + * - \b AlternatePTPProfile (Display string: 'Alternate PTP Profile'): Alternate PTP Profile + * - \b Unknown (Display string: 'Unknown'): Unknown + * - \b Reserved (Display string: 'Reserved'): Reserved + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevIEEE1588ClockAccuracy; + /// \brief An enumerated integer property. This feature is deprecated (See PtpStatus). + /** + * \deprecated + * This feature is deprecated (See PtpStatus). It was used to Provide the status of the IEEE 1588 clock. + * + * The following string values might be valid for this feature: + * - \b Initializing (Display string: 'Initializing'): Initializing + * - \b Faulty (Display string: 'Faulty'): Faulty + * - \b Disabled (Display string: 'Disabled'): Disabled + * - \b Listening (Display string: 'Listening'): Listening + * - \b PreMaster (Display string: 'Pre Master'): Pre Master + * - \b Master (Display string: 'Master'): Master + * - \b Passive (Display string: 'Passive'): Passive + * - \b Uncalibrated (Display string: 'Uncalibrated'): Uncalibrated + * - \b Slave (Display string: 'Slave'): Slave + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevIEEE1588Status; + /// \brief An enumerated integer property. Selects the GigE Vision version to control extended status codes for. + /** + * Selects the GigE Vision version to control extended status codes for. + * + * The following string values might be valid for this feature: + * - \b Version1_1 (Display string: 'Version 1 1'): Version 1 1 + * - \b Version2_0 (Display string: 'Version 2 0'): Version 2 0 + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevGVCPExtendedStatusCodesSelector; + /// \brief A boolean property. Enables the generation of extended status codes. + /** + * Enables the generation of extended status codes. + */ + PropertyIBoolean gevGVCPExtendedStatusCodes; + /// \brief A boolean property. Enables the generation of PENDING_ACK. + /** + * Enables the generation of PENDING_ACK. + */ + PropertyIBoolean gevGVCPPendingAck; + /// \brief A boolean property. This feature is deprecated (See DeviceLinkHeartbeatMode). + /** + * \deprecated + * This feature is deprecated (See DeviceLinkHeartbeatMode). It was used to disable the GVCP heartbeat. + */ + PropertyIBoolean gevGVCPHeartbeatDisable; + /// \brief An integer property. This feature is deprecated (See DeviceLinkCommandTimeout). + /** + * \deprecated + * This feature is deprecated (See DeviceLinkCommandTimeout). It was used to indicate the longest GVCP command execution time before a device returns a PENDING_ACK. + */ + PropertyI64 gevGVCPPendingTimeout; + /// \brief An integer property. Controls the key to use to authenticate primary application switchover requests. + /** + * Controls the key to use to authenticate primary application switchover requests. + */ + PropertyI64 gevPrimaryApplicationSwitchoverKey; + /// \brief An enumerated integer property. Enables the extended IDs mode. + /** + * Enables the extended IDs mode. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Off + * - \b On (Display string: 'On'): On + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevGVSPExtendedIDMode; + /// \brief An enumerated integer property. Controls the device access privilege of an application. + /** + * Controls the device access privilege of an application. + * + * The following string values might be valid for this feature: + * - \b OpenAccess (Display string: 'Open Access'): Open Access + * - \b ExclusiveAccess (Display string: 'Exclusive Access'): Exclusive Access + * - \b ControlAccess (Display string: 'Control Access'): Control Access + * - \b ControlAccessSwitchoverActive (Display string: 'Control Access Switchover Active'): Control Access Switchover Active + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevCCP; + /// \brief An integer property. Returns the UDP source port of the primary application. + /** + * Returns the UDP source port of the primary application. + */ + PropertyI64 gevPrimaryApplicationSocket; + /// \brief An integer property. Returns the address of the primary application. + /** + * Returns the address of the primary application. + */ + PropertyI64 gevPrimaryApplicationIPAddress; + /// \brief An integer property. Controls the port to which the device must send messages. + /** + * Controls the port to which the device must send messages. Setting this value to 0 closes the message channel. + */ + PropertyI64 gevMCPHostPort; + /// \brief An integer property. Controls the destination IP address for the message channel. + /** + * Controls the destination IP address for the message channel. + */ + PropertyI64 gevMCDA; + /// \brief An integer property. Provides the transmission timeout value in milliseconds. + /** + * Provides the transmission timeout value in milliseconds. + */ + PropertyI64 gevMCTT; + /// \brief An integer property. Controls the number of retransmissions allowed when a message channel message times out. + /** + * Controls the number of retransmissions allowed when a message channel message times out. + */ + PropertyI64 gevMCRC; + /// \brief An integer property. This feature indicates the source port for the message channel. + /** + * This feature indicates the source port for the message channel. + */ + PropertyI64 gevMCSP; + /// \brief An integer property. Selects the stream channel to control. + /** + * Selects the stream channel to control. + */ + PropertyI64 gevStreamChannelSelector; + /// \brief A boolean property. Enables the alternate IP destination for stream packets resent due to a packet resend request. + /** + * Enables the alternate IP destination for stream packets resent due to a packet resend request. When True, the source IP address provided in the packet resend command packet is used. When False, the value set in the GevSCDA[GevStreamChannelSelector] feature is used. + */ + PropertyIBoolean gevSCCFGPacketResendDestination; + /// \brief A boolean property. Enables the selected GVSP transmitter to use the single packet per data block All-in Transmission mode. + /** + * Enables the selected GVSP transmitter to use the single packet per data block All-in Transmission mode. + */ + PropertyIBoolean gevSCCFGAllInTransmission; + /// \brief A boolean property. Enables the camera to continue to stream, for this stream channel, if its control channel is closed or regardless of the reception of any ICMP messages (such as destination unreachable messages). + /** + * Enables the camera to continue to stream, for this stream channel, if its control channel is closed or regardless of the reception of any ICMP messages (such as destination unreachable messages). + */ + PropertyIBoolean gevSCCFGUnconditionalStreaming; + /// \brief A boolean property. Enables cameras to use the extended chunk data payload type for this stream channel. + /** + * Enables cameras to use the extended chunk data payload type for this stream channel. + */ + PropertyIBoolean gevSCCFGExtendedChunkData; + /// \brief An enumerated integer property. This feature is deprecated (See DeviceStreamChannelType). + /** + * \deprecated + * This feature is deprecated (See DeviceStreamChannelType). It was used to report the direction of the stream channel. + * + * The following string values might be valid for this feature: + * - \b Transmitter (Display string: 'Transmitter'): Transmitter + * - \b Receiver (Display string: 'Receiver'): Receiver + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevSCPDirection; + /// \brief An integer property. Index of the logical link to use. + /** + * Index of the logical link to use. + */ + PropertyI64 gevSCPInterfaceIndex; + /// \brief An integer property. Controls the port of the selected channel to which a GVSP transmitter must send data stream or the port from which a GVSP receiver may receive data stream. + /** + * Controls the port of the selected channel to which a GVSP transmitter must send data stream or the port from which a GVSP receiver may receive data stream. Setting this value to 0 closes the stream channel. + */ + PropertyI64 gevSCPHostPort; + /// \brief A boolean property. Sends a test packet. + /** + * Sends a test packet. When this feature is set, the device will fire one test packet. + */ + PropertyIBoolean gevSCPSFireTestPacket; + /// \brief A boolean property. The state of this feature is copied into the 'do not fragment' bit of IP header of each stream packet. + /** + * The state of this feature is copied into the 'do not fragment' bit of IP header of each stream packet. It can be used by the application to prevent IP fragmentation of packets on the stream channel. + */ + PropertyIBoolean gevSCPSDoNotFragment; + /// \brief A boolean property. This feature is deprecated (See DeviceStreamChannelEndianness). + /** + * \deprecated + * This feature is deprecated (See DeviceStreamChannelEndianness). It was used to control the endianness of multi-byte pixel data for this stream. + */ + PropertyIBoolean gevSCPSBigEndian; + /// \brief An integer property. This GigE Vision specific feature corresponds to DeviceStreamChannelPacketSize and should be kept in sync with it. + /** + * This GigE Vision specific feature corresponds to DeviceStreamChannelPacketSize and should be kept in sync with it. It specifies the stream packet size, in bytes, to send on the selected channel for a GVSP transmitter or specifies the maximum packet size supported by a GVSP receiver. + */ + PropertyI64 gevSCPSPacketSize; + /// \brief An integer property. Controls the delay (in GEV timestamp counter unit) to insert between each packet for this stream channel. + /** + * Controls the delay (in GEV timestamp counter unit) to insert between each packet for this stream channel. This can be used as a crude flow-control mechanism if the application or the network infrastructure cannot keep up with the packets coming from the device. + */ + PropertyI64 gevSCPD; + /// \brief An integer property. Controls the destination IP address of the selected stream channel to which a GVSP transmitter must send data stream or the destination IP address from which a GVSP receiver may receive data stream. + /** + * Controls the destination IP address of the selected stream channel to which a GVSP transmitter must send data stream or the destination IP address from which a GVSP receiver may receive data stream. + */ + PropertyI64 gevSCDA; + /// \brief An integer property. Indicates the source port of the stream channel. + /** + * Indicates the source port of the stream channel. + */ + PropertyI64 gevSCSP; + /// \brief An integer property. Reports the number of zones per block transmitted on the selected stream channel. + /** + * Reports the number of zones per block transmitted on the selected stream channel. + */ + PropertyI64 gevSCZoneCount; + /// \brief An integer property. Reports the transmission direction of each zone transmitted on the selected stream channel. + /** + * Reports the transmission direction of each zone transmitted on the selected stream channel. + */ + PropertyI64 gevSCZoneDirectionAll; + /// \brief A boolean property. Controls whether the selected stream channel multi-zone configuration is locked. + /** + * Controls whether the selected stream channel multi-zone configuration is locked. When locked, the GVSP transmitter is not allowed to change the number of zones and their direction during block acquisition and transmission. + */ + PropertyIBoolean gevSCZoneConfigurationLock; + /// \brief An integer property. Reports the number of transmitted PAUSE frames. + /** + * Reports the number of transmitted PAUSE frames. + */ + PropertyI64 aPAUSEMACCtrlFramesTransmitted; + /// \brief An integer property. Reports the number of received PAUSE frames. + /** + * Reports the number of received PAUSE frames. + */ + PropertyI64 aPAUSEMACCtrlFramesReceived; + /// \brief An enumerated integer property. This Camera Link specific feature describes the configuration used by the camera. + /** + * This Camera Link specific feature describes the configuration used by the camera. It helps especially when a camera is capable of operation in a non-standard configuration, and when the features PixelSize, SensorDigitizationTaps, and DeviceTapGeometry do not provide enough information for interpretation of the image data provided by the camera. + * + * The following string values might be valid for this feature: + * - \b Base (Display string: 'Base'): Standard base configuration described by the Camera Link standard. + * - \b Medium (Display string: 'Medium'): Standard medium configuration described by the Camera Link standard. + * - \b Full (Display string: 'Full'): Standard full configuration described by the Camera Link standard. + * - \b DualBase (Display string: 'Dual Base'): The camera streams the data from multiple taps (that do not fit in the standard base configuration) through two Camera Link base ports. It is responsibility of the application or frame grabber to reconstruct the full image. Only one of the ports (fixed) serves as the 'master' for serial communication and triggering. + * - \b EightyBit (Display string: 'Eighty Bit'): Standard 80-bit configuration with 10 taps of 8 bits or 8 taps of 10 bits, as described by the Camera Link standard. + * - \b Deca (Display string: 'Deca'): This enumeration entry is deprecated. It was used for Deca configuration with 10 taps of 8-bit. Use EightyBit instead. + * - \b Deca (Display string: 'Deca'): This enumeration entry is deprecated. It was used for Deca configuration with 10 taps of 8-bit. Use EightyBit instead. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 clConfiguration; + /// \brief An enumerated integer property. This Camera Link specific feature describes the time multiplexing of the camera link connection to transfer more than the configuration allows, in one single clock. + /** + * This Camera Link specific feature describes the time multiplexing of the camera link connection to transfer more than the configuration allows, in one single clock. + * + * The following string values might be valid for this feature: + * - \b One (Display string: 'One'): One + * - \b Two (Display string: 'Two'): Two + * - \b Three (Display string: 'Three'): Three + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 clTimeSlotsCount; + /// \brief An enumerated integer property. This feature indicates the current and active Link configuration used by the Device. + /** + * This feature indicates the current and active Link configuration used by the Device. + * + * The following string values might be valid for this feature: + * - \b None (Display string: 'None'): The Link configuration of the Device is unknown. Either the configuration operation has failed or there is nothing connected. + * - \b Pending (Display string: 'Pending'): The Device is in the process of configuring the Link. The Link cannot be used yet. + * - \b CXP1_X1 (Display string: 'CXP 1 X 1'): 1 Connection operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X1 (Display string: 'CXP 2 X 1'): 1 Connection operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X1 (Display string: 'CXP 3 X 1'): 1 Connection operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X1 (Display string: 'CXP 5 X 1'): 1 Connection operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X1 (Display string: 'CXP 6 X 1'): 1 Connection operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X1 (Display string: 'CXP 10 X 1'): 1 Connection operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X1 (Display string: 'CXP 12 X 1'): 1 Connection operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X2 (Display string: 'CXP 1 X 2'): 2 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X2 (Display string: 'CXP 2 X 2'): 2 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X2 (Display string: 'CXP 3 X 2'): 2 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X2 (Display string: 'CXP 5 X 2'): 2 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X2 (Display string: 'CXP 6 X 2'): 2 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X2 (Display string: 'CXP 10 X 2'): 2 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X2 (Display string: 'CXP 12 X 2'): 2 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X3 (Display string: 'CXP 1 X 3'): 3 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X3 (Display string: 'CXP 2 X 3'): 3 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X3 (Display string: 'CXP 3 X 3'): 3 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X3 (Display string: 'CXP 5 X 3'): 3 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X3 (Display string: 'CXP 6 X 3'): 3 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X3 (Display string: 'CXP 10 X 3'): 3 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X3 (Display string: 'CXP 12 X 3'): 3 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X4 (Display string: 'CXP 1 X 4'): 4 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X4 (Display string: 'CXP 2 X 4'): 4 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X4 (Display string: 'CXP 3 X 4'): 4 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X4 (Display string: 'CXP 5 X 4'): 4 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X4 (Display string: 'CXP 6 X 4'): 4 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X4 (Display string: 'CXP 10 X 4'): 4 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X4 (Display string: 'CXP 12 X 4'): 4 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X5 (Display string: 'CXP 1 X 5'): 5 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X5 (Display string: 'CXP 2 X 5'): 5 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X5 (Display string: 'CXP 3 X 5'): 5 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X5 (Display string: 'CXP 5 X 5'): 5 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X5 (Display string: 'CXP 6 X 5'): 5 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X5 (Display string: 'CXP 10 X 5'): 5 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X5 (Display string: 'CXP 12 X 5'): 5 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X6 (Display string: 'CXP 1 X 6'): 6 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X6 (Display string: 'CXP 2 X 6'): 6 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X6 (Display string: 'CXP 3 X 6'): 6 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X6 (Display string: 'CXP 5 X 6'): 6 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X6 (Display string: 'CXP 6 X 6'): 6 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X6 (Display string: 'CXP 10 X 6'): 6 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X6 (Display string: 'CXP 12 X 6'): 6 Connections operating at CXP-12 speed (12.50 Gbps). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpLinkConfigurationStatus; + /// \brief An enumerated integer property. Provides the Link configuration that allows the Transmitter Device to operate in its default mode. + /** + * Provides the Link configuration that allows the Transmitter Device to operate in its default mode. + * + * The following string values might be valid for this feature: + * - \b CXP1_X1 (Display string: 'CXP 1 X 1'): 1 Connection operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X1 (Display string: 'CXP 2 X 1'): 1 Connection operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X1 (Display string: 'CXP 3 X 1'): 1 Connection operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X1 (Display string: 'CXP 5 X 1'): 1 Connection operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X1 (Display string: 'CXP 6 X 1'): 1 Connection operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X1 (Display string: 'CXP 10 X 1'): 1 Connection operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X1 (Display string: 'CXP 12 X 1'): 1 Connection operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X2 (Display string: 'CXP 1 X 2'): 2 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X2 (Display string: 'CXP 2 X 2'): 2 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X2 (Display string: 'CXP 3 X 2'): 2 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X2 (Display string: 'CXP 5 X 2'): 2 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X2 (Display string: 'CXP 6 X 2'): 2 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X2 (Display string: 'CXP 10 X 2'): 2 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X2 (Display string: 'CXP 12 X 2'): 2 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X3 (Display string: 'CXP 1 X 3'): 3 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X3 (Display string: 'CXP 2 X 3'): 3 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X3 (Display string: 'CXP 3 X 3'): 3 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X3 (Display string: 'CXP 5 X 3'): 3 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X3 (Display string: 'CXP 6 X 3'): 3 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X3 (Display string: 'CXP 10 X 3'): 3 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X3 (Display string: 'CXP 12 X 3'): 3 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X4 (Display string: 'CXP 1 X 4'): 4 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X4 (Display string: 'CXP 2 X 4'): 4 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X4 (Display string: 'CXP 3 X 4'): 4 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X4 (Display string: 'CXP 5 X 4'): 4 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X4 (Display string: 'CXP 6 X 4'): 4 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X4 (Display string: 'CXP 10 X 4'): 4 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X4 (Display string: 'CXP 12 X 4'): 4 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X5 (Display string: 'CXP 1 X 5'): 5 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X5 (Display string: 'CXP 2 X 5'): 5 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X5 (Display string: 'CXP 3 X 5'): 5 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X5 (Display string: 'CXP 5 X 5'): 5 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X5 (Display string: 'CXP 6 X 5'): 5 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X5 (Display string: 'CXP 10 X 5'): 5 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X5 (Display string: 'CXP 12 X 5'): 5 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X6 (Display string: 'CXP 1 X 6'): 6 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X6 (Display string: 'CXP 2 X 6'): 6 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X6 (Display string: 'CXP 3 X 6'): 6 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X6 (Display string: 'CXP 5 X 6'): 6 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X6 (Display string: 'CXP 6 X 6'): 6 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X6 (Display string: 'CXP 10 X 6'): 6 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X6 (Display string: 'CXP 12 X 6'): 6 Connections operating at CXP-12 speed (12.50 Gbps). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpLinkConfigurationPreferred; + /// \brief An enumerated integer property. This feature allows specifying the Link configuration for the communication between the Receiver and Transmitter Device. + /** + * This feature allows specifying the Link configuration for the communication between the Receiver and Transmitter Device. In most cases this feature does not need to be written because automatic discovery will set configuration correctly to the value returned by CxpLinkConfigurationPreferred. Note that the currently active configuration of the Link can be read using CxpLinkConfigurationStatus. + * + * The following string values might be valid for this feature: + * - \b Auto (Display string: 'Auto'): Sets Automatic discovery for the Link Configuration. + * - \b CXP1_X1 (Display string: 'CXP 1 X 1'): Force the Link to 1 Connection operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X1 (Display string: 'CXP 2 X 1'): Force the Link to 1 Connection operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X1 (Display string: 'CXP 3 X 1'): Force the Link to 1 Connection operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X1 (Display string: 'CXP 5 X 1'): Force the Link to 1 Connection operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X1 (Display string: 'CXP 6 X 1'): Force the Link to 1 Connection operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X1 (Display string: 'CXP 10 X 1'): Force the Link to 1 Connection operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X1 (Display string: 'CXP 12 X 1'): Force the Link to 1 Connection operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X2 (Display string: 'CXP 1 X 2'): Force the Link to 2 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X2 (Display string: 'CXP 2 X 2'): Force the Link to 2 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X2 (Display string: 'CXP 3 X 2'): Force the Link to 2 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X2 (Display string: 'CXP 5 X 2'): Force the Link to 2 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X2 (Display string: 'CXP 6 X 2'): Force the Link to 2 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X2 (Display string: 'CXP 10 X 2'): Force the Link to 2 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X2 (Display string: 'CXP 12 X 2'): Force the Link to 2 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X3 (Display string: 'CXP 1 X 3'): Force the Link to 3 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X3 (Display string: 'CXP 2 X 3'): Force the Link to 3 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X3 (Display string: 'CXP 3 X 3'): Force the Link to 3 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X3 (Display string: 'CXP 5 X 3'): Force the Link to 3 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X3 (Display string: 'CXP 6 X 3'): Force the Link to 3 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X3 (Display string: 'CXP 10 X 3'): Force the Link to 3 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X3 (Display string: 'CXP 12 X 3'): Force the Link to 3 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X4 (Display string: 'CXP 1 X 4'): Force the Link to 4 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X4 (Display string: 'CXP 2 X 4'): Force the Link to 4 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X4 (Display string: 'CXP 3 X 4'): Force the Link to 4 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X4 (Display string: 'CXP 5 X 4'): Force the Link to 4 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X4 (Display string: 'CXP 6 X 4'): Force the Link to 4 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X4 (Display string: 'CXP 10 X 4'): Force the Link to 4 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X4 (Display string: 'CXP 12 X 4'): Force the Link to 4 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X5 (Display string: 'CXP 1 X 5'): Force the Link to 5 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X5 (Display string: 'CXP 2 X 5'): Force the Link to 5 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X5 (Display string: 'CXP 3 X 5'): Force the Link to 5 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X5 (Display string: 'CXP 5 X 5'): Force the Link to 5 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X5 (Display string: 'CXP 6 X 5'): Force the Link to 5 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X5 (Display string: 'CXP 10 X 5'): Force the Link to 5 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X5 (Display string: 'CXP 12 X 5'): Force the Link to 5 Connections operating at CXP-12 speed (12.50 Gbps). + * - \b CXP1_X6 (Display string: 'CXP 1 X 6'): Force the Link to 6 Connections operating at CXP-1 speed (1.25 Gbps). + * - \b CXP2_X6 (Display string: 'CXP 2 X 6'): Force the Link to 6 Connections operating at CXP-2 speed (2.50 Gbps). + * - \b CXP3_X6 (Display string: 'CXP 3 X 6'): Force the Link to 6 Connections operating at CXP-3 speed (3.125 Gbps). + * - \b CXP5_X6 (Display string: 'CXP 5 X 6'): Force the Link to 6 Connections operating at CXP-5 speed (5.00 Gbps). + * - \b CXP6_X6 (Display string: 'CXP 6 X 6'): Force the Link to 6 Connections operating at CXP-6 speed (6.25 Gbps). + * - \b CXP10_X6 (Display string: 'CXP 10 X 6'): Force the Link to 6 Connections operating at CXP-10 speed (10.00 Gbps). + * - \b CXP12_X6 (Display string: 'CXP 12 X 6'): Force the Link to 6 Connections operating at CXP-12 speed (12.50 Gbps). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpLinkConfiguration; + /// \brief A boolean property. Enable or disable the link sharing functionality of the device. + /** + * Enable or disable the link sharing functionality of the device. + */ + PropertyIBoolean cxpLinkSharingEnable; + /// \brief An integer property. Index of the sub device used in the Link Sharing. + /** + * Index of the sub device used in the Link Sharing. + */ + PropertyI64 cxpLinkSharingSubDeviceSelector; + /// \brief An enumerated integer property. This feature provides the type of sub device. + /** + * This feature provides the type of sub device. + * + * The following string values might be valid for this feature: + * - \b Master (Display string: 'Master'): The sub device is the master. + * - \b Slave (Display string: 'Slave'): The sub device is a slave. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpLinkSharingSubDeviceType; + /// \brief An integer property. This feature provides the number of horizontal stripes that the device implements. + /** + * This feature provides the number of horizontal stripes that the device implements. + */ + PropertyI64 cxpLinkSharingHorizontalStripeCount; + /// \brief An integer property. This feature provides the number of vertical stripes that the device implements. + /** + * This feature provides the number of vertical stripes that the device implements. + */ + PropertyI64 cxpLinkSharingVerticalStripeCount; + /// \brief An integer property. This feature provides the number of pixel overlap in the horizontal stripes that the device implements. + /** + * This feature provides the number of pixel overlap in the horizontal stripes that the device implements. + */ + PropertyI64 cxpLinkSharingHorizontalOverlap; + /// \brief An integer property. This feature provides the number of pixel overlap in the vertical stripes that the device implements. + /** + * This feature provides the number of pixel overlap in the vertical stripes that the device implements. + */ + PropertyI64 cxpLinkSharingVerticalOverlap; + /// \brief An integer property. This feature provides the duplicate count in striped system. + /** + * This feature provides the duplicate count in striped system. A non-zero value sets the number of duplicate images sent to sub-Devices. + */ + PropertyI64 cxpLinkSharingDuplicateStripe; + /// \brief An integer property. Selects the CoaXPress physical connection to control. + /** + * Selects the CoaXPress physical connection to control. + */ + PropertyI64 cxpConnectionSelector; + /// \brief An enumerated integer property. Enables the test mode for an individual physical connection of the Device. + /** + * Enables the test mode for an individual physical connection of the Device. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): Off + * - \b Mode1 (Display string: 'Mode 1'): Mode 1 + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpConnectionTestMode; + /// \brief An integer property. Reports the current connection error count for test packets received by the device on the connection selected by CxpConnectionSelector. + /** + * Reports the current connection error count for test packets received by the device on the connection selected by CxpConnectionSelector. + */ + PropertyI64 cxpConnectionTestErrorCount; + /// \brief An enumerated integer property. Selects which one of the send or receive features to control. + /** + * Selects which one of the send or receive features to control. + * + * The following string values might be valid for this feature: + * - \b Send (Display string: 'Send'): Send + * - \b Receive (Display string: 'Receive'): Receive + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpSendReceiveSelector; + /// \brief An integer property. Reports the current count for the test packets on the connection selected by CxpConnectionSelector. + /** + * Reports the current count for the test packets on the connection selected by CxpConnectionSelector. + */ + PropertyI64 cxpConnectionTestPacketCount; + /// \brief An enumerated integer property. Selects which Cxp Error Counter to read or reset. + /** + * Selects which Cxp Error Counter to read or reset. + * + * The following string values might be valid for this feature: + * - \b ConnectionLockLoss (Display string: 'Connection Lock Loss'): Counts the number of times the lock was lost. + * - \b Encoding (Display string: 'Encoding'): Counts the number of protocol encoding errors detected. + * - \b StreamDataPacketCrc (Display string: 'Stream Data Packet Crc'): Counts the number of CRC errors detected in a data packet. This counter is only available on the CoaXpress host. + * - \b ControlPacketCrc (Display string: 'Control Packet Crc'): Counts the number of CRC errors detected in a control packet. + * - \b EventPacketCrc (Display string: 'Event Packet Crc'): Counts the number of CRC errors detected in an event packet. + * - \b DuplicatedCharactersCorrected (Display string: 'Duplicated Characters Corrected'): Counts the number of corrected errors in the duplicated characters in CXP control words. + * - \b DuplicatedCharactersUncorrected (Display string: 'Duplicated Characters Uncorrected'): Counts the number of uncorrected errors in the duplicated characters in CXP control words. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpErrorCounterSelector; + /// \brief A method object. Resets the selected Cxp Error Counter on the connection selected by CxpConnectionSelector. + /** + * Resets the selected Cxp Error Counter on the connection selected by CxpConnectionSelector. The counter starts counting events immediately after the reset. + */ + Method cxpErrorCounterReset; + /// \brief An integer property. Reads the current value of the selected Cxp Error Counter on the connection selected by CxpConnectionSelector. + /** + * Reads the current value of the selected Cxp Error Counter on the connection selected by CxpConnectionSelector. + */ + PropertyI64 cxpErrorCounterValue; + /// \brief An enumerated integer property. Returns the current status of the selected Cxp Error Counter on the connection selected by CxpConnectionSelector. + /** + * Returns the current status of the selected Cxp Error Counter on the connection selected by CxpConnectionSelector. + * + * The following string values might be valid for this feature: + * - \b CounterActive (Display string: 'Counter Active'): The counter is actively counting errors. + * - \b CounterOverflow (Display string: 'Counter Overflow'): The counter exceeded its maximum error count. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpErrorCounterStatus; + /// \brief A method object. Activate automatic control of the Power over CoaXPress (PoCXP) for the Link. + /** + * Activate automatic control of the Power over CoaXPress (PoCXP) for the Link. + */ + Method cxpPoCxpAuto; + /// \brief A method object. Disable Power over CoaXPress (PoCXP) for the Link. + /** + * Disable Power over CoaXPress (PoCXP) for the Link. + */ + Method cxpPoCxpTurnOff; + /// \brief A method object. Reset the Power over CoaXPress (PoCXP) Link after an over-current trip on the Device connection(s). + /** + * Reset the Power over CoaXPress (PoCXP) Link after an over-current trip on the Device connection(s). + */ + Method cxpPoCxpTripReset; + /// \brief An enumerated integer property. Returns the Power over CoaXPress (PoCXP) status of the Device. + /** + * Returns the Power over CoaXPress (PoCXP) status of the Device. + * + * The following string values might be valid for this feature: + * - \b Auto (Display string: 'Auto'): Normal automatic PoCXP operation. + * - \b Off (Display string: 'Off'): PoCXP is forced off. + * - \b Tripped (Display string: 'Tripped'): The Link has shut down because of an over-current trip. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 cxpPoCxpStatus; + /// \brief A boolean property. Specifies if a FrameStart trigger also triggers the first LineStart at the same time. + /** + * Specifies if a FrameStart trigger also triggers the first LineStart at the same time. + */ + PropertyIBoolean cxpFirstLineTriggerWithFrameStart; + /// \brief An enumerated integer property. Selects the bandwidth control for the selected stream channel. + /** + * This enumeration selects the bandwidth control for the selected stream channel. + * + * The following string values might be valid for this feature: + * - \b GevSCPD (Display string: 'Gev SCPD') + * - \b mvGevSCBW (Display string: 'mv Gev SCBW') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvGevSCBWControl; + /// \brief An integer property. Sets the stream channels max. bandwidth in KBps + /** + * This value sets the stream channels max. bandwidth in KBps. + */ + PropertyI64 mvGevSCBW; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Calculates the effective number of payload packets (not including leader and trailer) per block of data (e.g. an image) for a GigE Vision data stream when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent accurate as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * \since 2.5.11 + * \return The effective number of payload packets (not including leader and trailer) per block of data (e.g. an image) transferred by a GigE Vision device with the current parameters. + */ + static int64_type gevGetEffectivePayloadPacketsPerImage( + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] The current value of the \a payloadSize property. + const int64_type payloadSizeValue, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) + { + const int64_type PacketSizeWithoutEthernet = boExtendedID ? 48LL : 36LL; // 20 (IP Header) + 8 (UDP Header) + boExtendedID ? 20 : 8 (GVSP Header) + const int64_type gevSCPSPacketSizeValue_effective = gevSCPSPacketSizeValue - PacketSizeWithoutEthernet; // The Ethernet header is not taken into account here! + return ( payloadSizeValue + gevSCPSPacketSizeValue_effective - 1LL ) / gevSCPSPacketSizeValue_effective; + } + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent accurate as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * \since 2.5.7 + * \return The effective number of payload packets (not including leader and trailer) per block of data (e.g. an image) transferred by a GigE Vision device with the current parameters. + */ + int64_type gevGetEffectivePayloadPacketsPerImage( + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) const + { + return gevGetEffectivePayloadPacketsPerImage( gevSCPSPacketSizeValue, payloadSize.read(), boExtendedID ); + } + /// \brief Calculates the effective bytes per block of data (e.g. an image) for a GigE Vision data stream when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent accurate as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * \since 2.5.11 + * \return The effective bytes per block of data (e.g. an image) transferred by a GigE Vision device with the current parameters. + */ + static int64_type gevGetEffectiveBytesPerImage( + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] The current value of the \a payloadSize property. + const int64_type payloadSizeValue, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) + { + const int64_type PacketSizeWithoutEthernet = boExtendedID ? 48LL : 36LL; // 20 (IP Header) + 8 (UDP Header) + boExtendedID ? 20 : 8 (GVSP Header) + const int64_type GVSPHeaderSize = PacketSizeWithoutEthernet + 14LL; // 14 (Ethernet Header) + const int64_type GVSPImageLeaderSize = GVSPHeaderSize + 36LL; + const int64_type GVSPImageTrailerSize = GVSPHeaderSize + 8LL; + const int64_type protocolOverhead = GVSPImageLeaderSize + ( gevGetEffectivePayloadPacketsPerImage( gevSCPSPacketSizeValue, payloadSizeValue, boExtendedID ) * GVSPHeaderSize ) + GVSPImageTrailerSize; + return protocolOverhead + payloadSizeValue; + } + /// \brief Calculates the effective bytes per block of data (e.g. an image) for a GigE Vision data stream when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent accurate as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * \since 2.5.7 + * \return The effective bytes per block of data (e.g. an image) transferred by a GigE Vision device with the current parameters. + */ + int64_type gevGetEffectiveBytesPerImage( + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) const + { + return gevGetEffectiveBytesPerImage( gevSCPSPacketSizeValue, payloadSize.read(), boExtendedID ); + } + /// \brief Calculates the overall resulting bandwidth (in bytes) needed for GigE Vision data streams when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent precise as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * \since 2.5.11 + * \return The overall resulting bandwidth (in bytes) needed for GigE Vision data streams when transferring the payload type \a image. + */ + static int64_type gevGetResultingBandwidth( + /// [in] The overall current or desired frame rate. + const double acquisitionFrameRateValue, + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] The current value of the \a payloadSize property. + const int64_type payloadSizeValue, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) + { + return static_cast( static_cast( gevGetEffectiveBytesPerImage( gevSCPSPacketSizeValue, payloadSizeValue, boExtendedID ) ) * acquisitionFrameRateValue ); + } + /// \brief Calculates the overall resulting bandwidth (in bytes) needed for GigE Vision data streams when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent precise as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * \since 2.5.7 + * \return The overall resulting bandwidth (in bytes) needed for GigE Vision data streams when transferring the payload type \a image. + */ + int64_type gevGetResultingBandwidth( + /// [in] The overall current or desired frame rate. + const double acquisitionFrameRateValue, + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) const + { + return static_cast( static_cast( gevGetEffectiveBytesPerImage( gevSCPSPacketSizeValue, boExtendedID ) ) * acquisitionFrameRateValue ); + } + /// \brief Calculates the inter-packet delay needed to achieve a uniform packet and thus payload distribution for GigE Vision data streams when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent accurate as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * + * The result of this function should be written to the property mvIMPACT::acquire::TransportLayerControl::gevSCPD if supported by the device. + * \since 2.5.11 + * \return The \a GevSCPD value for the given input parameters. If this value is negative, this indicates that the overall bandwidth resulting + * from the given input parameters is higher than stated by \a bandwidthAvailable. In such a case the inter-packet delay must be set to 0 and + * it should be noted that the desired frame rate cannot be reached in this configuration. + */ + static int64_type gevGetResultingPacketDelay( + /// [in] The overall current or desired frame rate. + const double acquisitionFrameRateValue, + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] The current value of the \a payloadSize property. + const int64_type payloadSizeValue, + /// [in] The timestamp tick frequency of the GEV remote device. + const int64_type gevTimestampTickFrequencyValue, + /// [in] The overall bandwidth in bytes that is available on the given link. + const int64_type bandwidthAvailable, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) + { + const int64_type bandwidthNeeded = gevGetResultingBandwidth( acquisitionFrameRateValue, gevSCPSPacketSizeValue, payloadSizeValue, boExtendedID ); + const int64_type packetsPerImage = gevGetEffectivePayloadPacketsPerImage( gevSCPSPacketSizeValue, payloadSizeValue, boExtendedID ) + 2; // one leader, one trailer + const double totalDelayTime = 1. - static_cast( bandwidthNeeded ) / static_cast( bandwidthAvailable ); + const double interPacketDelayTime = totalDelayTime / ( static_cast( packetsPerImage ) * acquisitionFrameRateValue ); + return static_cast( ( interPacketDelayTime < 0.0 ) ? 0 : interPacketDelayTime * gevTimestampTickFrequencyValue ); + } + /// \brief Calculates the inter-packet delay needed to achieve a uniform packet and thus payload distribution for GigE Vision data streams when transferring the payload type \a image. + /** + * This will include all overhead introduced by the network protocol. The value will be correct for payload type image only, thus e.g. when + * transferring chunk data the result will not be 100 per cent accurate as then some packets will use a slightly different layout. However + * these differences are negligible when working in modes, where individual images are not smaller than roughly 64 by 64 pixels. + * + * The result of this function should be written to the property mvIMPACT::acquire::TransportLayerControl::gevSCPD if supported by the device. + * \since 2.5.7 + * \return The \a GevSCPD value for the given input parameters. If this value is negative, this indicates that the overall bandwidth resulting + * from the given input parameters is higher than stated by \a bandwidthAvailable. In such a case the inter-packet delay must be set to 0 and + * it should be noted that the desired frame rate cannot be reached in this configuration. + */ + int64_type gevGetResultingPacketDelay( + /// [in] The overall current or desired frame rate. + const double acquisitionFrameRateValue, + /// [in] The current or desired gevSCPSPacketSizeValue. This value depends e.g. on the MTU of the NIC the stream has been created on. See network configuration chapters for details. + const int64_type gevSCPSPacketSizeValue, + /// [in] The timestamp tick frequency of the GEV remote device. + const int64_type gevTimestampTickFrequencyValue, + /// [in] The overall bandwidth in bytes that is available on the given link. + const int64_type bandwidthAvailable, + /// [in] Indicates whether the bandwidth shall be calculated for the extended ID mode (introduced in GigE Vision 2.0) or not. + /// With \a boExtendedID the protocol overhead will increase slightly. + const bool boExtendedID = false ) const + { + return gevGetResultingPacketDelay( acquisitionFrameRateValue, gevSCPSPacketSizeValue, payloadSize.read(), gevTimestampTickFrequencyValue, bandwidthAvailable, boExtendedID ); + } +}; + +//----------------------------------------------------------------------------- +/// \brief Contains features to control the serial interface. +/** + * Contains features to control the serial interface. + * \ingroup GenICamInterfaceDevice + */ +class mvSerialInterfaceControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvSerialInterfaceControl object. + explicit mvSerialInterfaceControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvSerialInterfaceEnable(), + mvSerialInterfaceMode(), + mvSerialInterfaceBaudRate(), + mvSerialInterfaceDataBits(), + mvSerialInterfaceStopBits(), + mvSerialInterfaceParity(), + mvSerialInterfaceASCIIBuffer(), + mvSerialInterfaceBinaryBuffer(), + mvSerialInterfaceBytesToWrite(), + mvSerialInterfaceBytesAvailableForRead(), + mvSerialInterfaceReceiveStatus(), + mvSerialInterfaceBytesToRead(), + mvSerialInterfaceRead(), + mvSerialInterfaceWrite(), + mvLiquidLensFirmwareVersion(), + mvLiquidLensStatus(), + mvLiquidLensErrorCount(), + mvLiquidLensPowerMode(), + mvLiquidLensSetFocusValue(), + mvLiquidLensReceiveStatus(), + mvLiquidLensSaveFocusValue(), + mvStepperFirmwareVersion(), + mvStepperReceiveStatus(), + mvStepperErrorCount(), + mvStepperAutoSavePositionEnable(), + mvStepperMotorSelector(), + mvStepperStatus(), + mvStepperCurrentPosition(), + mvStepperDesiredPosition(), + mvStepperSpeed(), + mvStepperAcceleration(), + mvStepperSpeedManual(), + mvStepperPositionSetSelector(), + mvStepperPositionSetLoad(), + mvStepperPositionSetSave(), + mvStepperMoveToHomeAll(), + mvStepperStopAll() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvSerialInterfaceControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvSerialInterfaceEnable, "mvSerialInterfaceEnable" ); + locator.bindComponent( mvSerialInterfaceMode, "mvSerialInterfaceMode" ); + locator.bindComponent( mvSerialInterfaceBaudRate, "mvSerialInterfaceBaudRate" ); + locator.bindComponent( mvSerialInterfaceDataBits, "mvSerialInterfaceDataBits" ); + locator.bindComponent( mvSerialInterfaceStopBits, "mvSerialInterfaceStopBits" ); + locator.bindComponent( mvSerialInterfaceParity, "mvSerialInterfaceParity" ); + locator.bindComponent( mvSerialInterfaceASCIIBuffer, "mvSerialInterfaceASCIIBuffer" ); + locator.bindComponent( mvSerialInterfaceBinaryBuffer, "mvSerialInterfaceBinaryBuffer" ); + locator.bindComponent( mvSerialInterfaceBytesToWrite, "mvSerialInterfaceBytesToWrite" ); + locator.bindComponent( mvSerialInterfaceBytesAvailableForRead, "mvSerialInterfaceBytesAvailableForRead" ); + locator.bindComponent( mvSerialInterfaceReceiveStatus, "mvSerialInterfaceReceiveStatus" ); + locator.bindComponent( mvSerialInterfaceBytesToRead, "mvSerialInterfaceBytesToRead" ); + locator.bindComponent( mvSerialInterfaceRead, "mvSerialInterfaceRead@i" ); + locator.bindComponent( mvSerialInterfaceWrite, "mvSerialInterfaceWrite@i" ); + locator.bindComponent( mvLiquidLensFirmwareVersion, "mvLiquidLensFirmwareVersion" ); + locator.bindComponent( mvLiquidLensStatus, "mvLiquidLensStatus" ); + locator.bindComponent( mvLiquidLensErrorCount, "mvLiquidLensErrorCount" ); + locator.bindComponent( mvLiquidLensPowerMode, "mvLiquidLensPowerMode" ); + locator.bindComponent( mvLiquidLensSetFocusValue, "mvLiquidLensSetFocusValue" ); + locator.bindComponent( mvLiquidLensReceiveStatus, "mvLiquidLensReceiveStatus" ); + locator.bindComponent( mvLiquidLensSaveFocusValue, "mvLiquidLensSaveFocusValue@i" ); + locator.bindComponent( mvStepperFirmwareVersion, "mvStepperFirmwareVersion" ); + locator.bindComponent( mvStepperReceiveStatus, "mvStepperReceiveStatus" ); + locator.bindComponent( mvStepperErrorCount, "mvStepperErrorCount" ); + locator.bindComponent( mvStepperAutoSavePositionEnable, "mvStepperAutoSavePositionEnable" ); + locator.bindComponent( mvStepperMotorSelector, "mvStepperMotorSelector" ); + locator.bindComponent( mvStepperStatus, "mvStepperStatus" ); + locator.bindComponent( mvStepperCurrentPosition, "mvStepperCurrentPosition" ); + locator.bindComponent( mvStepperDesiredPosition, "mvStepperDesiredPosition" ); + locator.bindComponent( mvStepperSpeed, "mvStepperSpeed" ); + locator.bindComponent( mvStepperAcceleration, "mvStepperAcceleration" ); + locator.bindComponent( mvStepperSpeedManual, "mvStepperSpeedManual" ); + locator.bindComponent( mvStepperPositionSetSelector, "mvStepperPositionSetSelector" ); + locator.bindComponent( mvStepperPositionSetLoad, "mvStepperPositionSetLoad@i" ); + locator.bindComponent( mvStepperPositionSetSave, "mvStepperPositionSetSave@i" ); + locator.bindComponent( mvStepperMoveToHomeAll, "mvStepperMoveToHomeAll@i" ); + locator.bindComponent( mvStepperStopAll, "mvStepperStopAll@i" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A boolean property. Controls whether the serial interface is enabled or not. + /** + * Controls whether the serial interface is enabled or not. + */ + PropertyIBoolean mvSerialInterfaceEnable; + /// \brief An enumerated integer property. States the interface mode of the serial interface + /** + * States the interface mode of the serial interface + * + * The following string values might be valid for this feature: + * - \b Plain (Display string: 'Plain') + * - \b InveniosLiquidLens (Display string: 'Invenios Liquid Lens') + * - \b OptoEngineeringStepper (Display string: 'Opto Engineering Stepper') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSerialInterfaceMode; + /// \brief An enumerated integer property. Serial interface clock frequency. + /** + * Serial interface clock frequency. + * + * The following string values might be valid for this feature: + * - \b Hz_115200 (Display string: '115200 Hz') + * - \b Hz_57600 (Display string: '57600 Hz') + * - \b Hz_38400 (Display string: '38400 Hz') + * - \b Hz_19200 (Display string: '19200 Hz') + * - \b Hz_9600 (Display string: '9600 Hz') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSerialInterfaceBaudRate; + /// \brief An enumerated integer property. Number of data bits. + /** + * Number of data bits. + * + * The following string values might be valid for this feature: + * - \b Seven (Display string: 'Seven') + * - \b Eight (Display string: 'Eight') + * - \b Nine (Display string: 'Nine') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSerialInterfaceDataBits; + /// \brief An enumerated integer property. Number of stop bits. + /** + * Number of stop bits. + * + * The following string values might be valid for this feature: + * - \b One (Display string: 'One') + * - \b Two (Display string: 'Two') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSerialInterfaceStopBits; + /// \brief An enumerated integer property. Serial interface parity. + /** + * Serial interface parity. + * + * The following string values might be valid for this feature: + * - \b None (Display string: 'None') + * - \b Odd (Display string: 'Odd') + * - \b Even (Display string: 'Even') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvSerialInterfaceParity; + /// \brief A string property. Buffer for exchanging ASCII data over the serial interface. This buffer uses the same memory as 'mvSerialInterfaceBinaryBuffer'. + /** + * Buffer for exchanging ASCII data over the serial interface. This buffer uses the same memory as 'mvSerialInterfaceBinaryBuffer'. + */ + PropertyS mvSerialInterfaceASCIIBuffer; + /// \brief A string property. Buffer for exchanging binary data over the serial interface. This buffer uses the same memory as 'mvSerialInterfaceASCIIBuffer'. + /** + * Buffer for exchanging binary data over the serial interface. This buffer uses the same memory as 'mvSerialInterfaceASCIIBuffer'. + */ + PropertyS mvSerialInterfaceBinaryBuffer; + /// \brief An integer property. Length of data to write. + /** + * Length of data to write. + */ + PropertyI64 mvSerialInterfaceBytesToWrite; + /// \brief An integer property. Number of serial data bytes available for read. + /** + * Number of serial data bytes available for read. + */ + PropertyI64 mvSerialInterfaceBytesAvailableForRead; + /// \brief An integer property. Result of the serial receive error detection mechanism. + /** + * Result of the serial receive error detection mechanism. + */ + PropertyI64 mvSerialInterfaceReceiveStatus; + /// \brief An integer property. Number of serial bytes to read. + /** + * Number of serial bytes to read. + */ + PropertyI64 mvSerialInterfaceBytesToRead; + /// \brief A method object. Command to read data from serial interface. + /** + * Command to read data from serial interface. + */ + Method mvSerialInterfaceRead; + /// \brief A method object. Command to write data to serial interface + /** + * Command to write data to serial interface + */ + Method mvSerialInterfaceWrite; + /// \brief An integer property. Returns the firmware version of the Liquid Lens. + /** + * Returns the firmware version of the Liquid Lens. + */ + PropertyI64 mvLiquidLensFirmwareVersion; + /// \brief An enumerated integer property. Returns the current status of the Liquid Lens. + /** + * Returns the current status of the Liquid Lens. + * + * The following string values might be valid for this feature: + * - \b NoError (Display string: 'No Error'): No Errors. + * - \b VhOverload (Display string: 'Vh Overload'): Vh below 70V because Liquid Lens is taking too much current. + * - \b ThermalOverload (Display string: 'Thermal Overload'): Driver shutdown because Liquid Lens is too hot. + * - \b VhAndThermalOverload (Display string: 'Vh And Thermal Overload'): Vh does not reach 70V and driver shutdown because Liquid Lens is too hot. + * - \b StatusReadErrorNoAnswer (Display string: 'Status Read Error No Answer'): No response from Liquid Lens. + * - \b StatusReadErrorCRC (Display string: 'Status Read Error CRC'): CRC error in response from Liquid Lens. + * - \b StatusReadErrorNakAnswer (Display string: 'Status Read Error Nak Answer'): NAK response from Liquid Lens. + * - \b StatusReadErrorInvalidAnswer (Display string: 'Status Read Error Invalid Answer'): Invalid Size or Command in response from Liquid Lens. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLiquidLensStatus; + /// \brief An integer property. This register increments whenever an error occurred while communicating with the Liquid Lens. + /** + * This register increments whenever an error occurred while communicating with the Liquid Lens. + */ + PropertyI64 mvLiquidLensErrorCount; + /// \brief An enumerated integer property. Selects the device power mode. + /** + * Selects the device power mode. + * + * The following string values might be valid for this feature: + * - \b mvLiquidLensActive (Display string: 'mv Liquid Lens Active'): Puts the device to power-active mode. + * - \b mvLiquidLensStandby (Display string: 'mv Liquid Lens Standby'): Puts the Liquid Lens in power-saving mode. In this mode the device will only consume up to 25 percent of its normal power consumption. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLiquidLensPowerMode; + /// \brief An integer property. Focus position value for Liquid Lens. + /** + * Focus position value for Liquid Lens. + */ + PropertyI64 mvLiquidLensSetFocusValue; + /// \brief An integer property. Result of the serial receive error detection mechanism. + /** + * Result of the serial receive error detection mechanism. This is a bit field. The bits have the following meaning: 0x1: CRC Error, 0x2: NAK received, 0x4: No response, 0x8 Incorrect answer received. + */ + PropertyI64 mvLiquidLensReceiveStatus; + /// \brief A method object. Saves the current Focus position into LiquidLens EEPROM. + /** + * Saves the current Focus position into LiquidLens EEPROM. + */ + Method mvLiquidLensSaveFocusValue; + /// \brief An integer property. Returns the firmware version of the Opto Engineering Stepper. + /** + * Returns the firmware version of the Opto Engineering Stepper. + */ + PropertyI64 mvStepperFirmwareVersion; + /// \brief An integer property. Result of the serial receive error detection mechanism. + /** + * Result of the serial receive error detection mechanism. This is a bit field. The bits have the following meaning: 0x1: Reserved, 0x2: Mismatch in answer detected, 0x4: No response, 0x8 Incorrect answer received. + */ + PropertyI64 mvStepperReceiveStatus; + /// \brief An integer property. This register increments whenever an error occurred while communicating with the Opto Engineering Stepper. + /** + * This register increments whenever an error occurred while communicating with the Opto Engineering Stepper. + */ + PropertyI64 mvStepperErrorCount; + /// \brief A boolean property. Controls if the auto-save of motor positions is active. + /** + * Controls if the auto-save of motor positions is active. + */ + PropertyIBoolean mvStepperAutoSavePositionEnable; + /// \brief An enumerated integer property. Selects the stepper motor to control. + /** + * Selects the stepper motor to control(Zoom, Iris or Focus). + * + * The following string values might be valid for this feature: + * - \b All (Display string: 'All'): All stepper motors are selected. + * - \b Zoom (Display string: 'Zoom'): Selects the stepper motor controlling the zoom. + * - \b Focus (Display string: 'Focus'): Selects the stepper motor controlling the focus. + * - \b Iris (Display string: 'Iris'): Selects the stepper motor controlling the iris. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvStepperMotorSelector; + /// \brief An enumerated integer property. Returns the current status of the stepper. + /** + * Returns the current status of the stepper. + * + * The following string values might be valid for this feature: + * - \b Unknown (Display string: 'Unknown'): The current status of the stepper is unknown. + * - \b Moving (Display string: 'Moving'): The selected stepper motor is currently moving. + * - \b StoppedAtLowerLimitWithTorque (Display string: 'Stopped At Lower Limit With Torque'): The selected stepper motor has stopped at its lower limit with torque(this should never happen and indicates a problem). + * - \b StoppedAtLowerLimit (Display string: 'Stopped At Lower Limit'): The selected stepper motor has stopped at its lower limit. + * - \b StoppedAtUpperLimitWithTorque (Display string: 'Stopped At Upper Limit With Torque'): The selected stepper motor has stopped at its upper limit with torque(this should never happen and indicates a problem). + * - \b StoppedAtUpperLimit (Display string: 'Stopped At Upper Limit'): The selected stepper motor has stopped at its upper limit. + * - \b StoppedWithTorque (Display string: 'Stopped With Torque'): The selected stepper motor has stopped with torque(this should never happen and indicates a problem). + * - \b Stopped (Display string: 'Stopped'): The selected stepper motor has stopped. + * - \b OvercurrentOrOvertemperatureError (Display string: 'Overcurrent Or Overtemperature Error'): The selected stepper motor either became too hot or is taking in too much current(this should never happen and indicates a problem). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvStepperStatus; + /// \brief An integer property. Read current position from stepper. + /** + * Read current position from stepper. + */ + PropertyI64 mvStepperCurrentPosition; + /// \brief An integer property. The desired position of the selected stepper motor. + /** + * The desired position of the selected stepper motor. When the motor has not yet reached this position(is moving) this value may differ from 'mvStepperCurrentPosition'. + */ + PropertyI64 mvStepperDesiredPosition; + /// \brief A floating point property. Current speed of the selected stepper motor. + /** + * Current speed of the selected stepper motor. + */ + PropertyF mvStepperSpeed; + /// \brief A floating point property. Current acceleration of the selected stepper motor. + /** + * Current acceleration of the selected stepper motor. + */ + PropertyF mvStepperAcceleration; + /// \brief A floating point property. Manual speed of the selected stepper motor. + /** + * Manual speed of the selected stepper motor. + */ + PropertyF mvStepperSpeedManual; + /// \brief An integer property. Selects the stepper parameter set to load or save. + /** + * Selects the stepper parameter set to load or save. + */ + PropertyI64 mvStepperPositionSetSelector; + /// \brief A method object. Loads the stepper 'mvStepperDesiredPosition' specified by 'mvStepperPositionSetSelector' and makes it active for each motor. + /** + * Loads the stepper 'mvStepperDesiredPosition' specified by 'mvStepperPositionSetSelector' and makes it active for each motor. + */ + Method mvStepperPositionSetLoad; + /// \brief A method object. Saves the stepper 'mvStepperDesiredPosition' specified by 'mvStepperPositionSetSelector' into the steppers non-volatile memory for each motor. + /** + * Saves the stepper 'mvStepperDesiredPosition' specified by 'mvStepperPositionSetSelector' into the steppers non-volatile memory for each motor. + */ + Method mvStepperPositionSetSave; + /// \brief A method object. Moves all stepper motors to their home position. + /** + * Moves all stepper motors to their home position. + */ + Method mvStepperMoveToHomeAll; + /// \brief A method object. Stops all stepper motors. + /** + * Stops all stepper motors. + */ + Method mvStepperStopAll; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Contains features to control the I2C interface. +/** + * Contains features to control the I2C interface. + * \ingroup GenICamInterfaceDevice + */ +class mvI2cInterfaceControl +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvI2cInterfaceControl object. + explicit mvI2cInterfaceControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvI2cInterfaceEnable(), + mvI2cInterfaceDeviceAddress(), + mvI2cInterfaceDeviceSubAddress(), + mvI2cInterfaceASCIIBuffer(), + mvI2cInterfaceBinaryBuffer(), + mvI2cInterfaceBytesToWrite(), + mvI2cInterfaceBytesToRead(), + mvI2cInterfaceRead(), + mvI2cInterfaceWrite(), + mvI2cInterfaceSpeed() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindComponent( mvI2cInterfaceEnable, "mvI2cInterfaceEnable" ); + locator.bindComponent( mvI2cInterfaceDeviceAddress, "mvI2cInterfaceDeviceAddress" ); + locator.bindComponent( mvI2cInterfaceDeviceSubAddress, "mvI2cInterfaceDeviceSubAddress" ); + locator.bindComponent( mvI2cInterfaceASCIIBuffer, "mvI2cInterfaceASCIIBuffer" ); + locator.bindComponent( mvI2cInterfaceBinaryBuffer, "mvI2cInterfaceBinaryBuffer" ); + locator.bindComponent( mvI2cInterfaceBytesToWrite, "mvI2cInterfaceBytesToWrite" ); + locator.bindComponent( mvI2cInterfaceBytesToRead, "mvI2cInterfaceBytesToRead" ); + locator.bindComponent( mvI2cInterfaceRead, "mvI2cInterfaceRead@i" ); + locator.bindComponent( mvI2cInterfaceWrite, "mvI2cInterfaceWrite@i" ); + locator.bindComponent( mvI2cInterfaceSpeed, "mvI2cInterfaceSpeed" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A boolean property. Controls whether the I2C interface is enabled or not. + /** + * Controls whether the I2C interface is enabled or not. + */ + PropertyIBoolean mvI2cInterfaceEnable; + /// \brief An integer property. I2C device address, must be even. + /** + * I2C device address, must be even, blocked addresses: 0x20, 0x30 (Test), 0x32, 0x34, 0x36, 0x3E, 0x60, 0x62, 0x64, 0x66, 0x6E, 0x90, 0x92, 0xA0, 0xA2, 0xA4, 0xA6, 0xAE, 0xB0, 0xB2, 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0xBE. + */ + PropertyI64 mvI2cInterfaceDeviceAddress; + /// \brief An integer property. I2C device sub address ignored when set to -1, 2 byte address if bit 0x10000 is set, else 1 Byte. + /** + * I2C device sub address ignored when set to -1, 2 byte address if bit 0x10000 is set, else 1 Byte. + */ + PropertyI64 mvI2cInterfaceDeviceSubAddress; + /// \brief A string property. Buffer for exchanging ASCII data over the I2C interface. This buffer uses the same memory as 'mvI2cInterfaceBinaryBuffer'. + /** + * Buffer for exchanging ASCII data over the I2C interface. This buffer uses the same memory as 'mvI2cInterfaceBinaryBuffer'. + */ + PropertyS mvI2cInterfaceASCIIBuffer; + /// \brief A string property. Buffer for exchanging binary data over the I2C interface. This buffer uses the same memory as 'mvI2cInterfaceASCIIBuffer'. + /** + * Buffer for exchanging binary data over the I2C interface. This buffer uses the same memory as 'mvI2cInterfaceASCIIBuffer'. + */ + PropertyS mvI2cInterfaceBinaryBuffer; + /// \brief An integer property. Number of bytes from mvI2cInterfaceBuffer to write to I2C device. + /** + * Number of bytes from mvI2cInterfaceBuffer to write to I2C device. + */ + PropertyI64 mvI2cInterfaceBytesToWrite; + /// \brief An integer property. Number of bytes to read from I2C device. + /** + * Number of bytes to read from I2C device. + */ + PropertyI64 mvI2cInterfaceBytesToRead; + /// \brief A method object. Command to read data from I2C device. + /** + * Command to read data from I2C device. + */ + Method mvI2cInterfaceRead; + /// \brief A method object. Command to write data to I2C device + /** + * Command to write data to I2C device + */ + Method mvI2cInterfaceWrite; + /// \brief An enumerated integer property. I2C interface clock frequency. + /** + * I2C interface clock frequency. + * + * The following string values might be valid for this feature: + * - \b kHz_100 (Display string: '100 kHz'): default speed + * - \b kHz_400 (Display string: '400 kHz'): fast speed + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvI2cInterfaceSpeed; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Custom area. +/** + * Custom area. + * \ingroup GenICamInterfaceDevice + */ +class mvCustomData : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvCustomData object. + explicit mvCustomData( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvCustomText(), + mvWriteCustomData(), + mvReadCustomData(), + mvSensorRegister(), + mvSensorRegisterValue(), + mvInternalRegister(), + mvInternalRegisterValue(), + mvMSeqRegister(), + mvMSeqRegisterValue(), + mvStateSumRegister(), + mvStat2SumRegister(), + mvStat3SumRegister(), + mvStat4SumRegister(), + mvStat5SumRegister(), + mvStat6SumRegister(), + mvStateSumRegisterReset(), + mvStateSumRegister3Reset(), + mvLVDSSelection(), + mvLVDSAlignment(), + mvRunTest(), + mvTestNumber(), + mvTestMin(), + mvTestMax(), + mvCustomCommandInterpreterVersionMajor(), + mvCustomCommandInterpreterVersionMinor(), + mvCustomCommandBuffer(), + mvImxSensorType(), + mvImxSensorIdOne(), + mvImxGroup(), + mvImxSensorIdTwo() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvCustomData" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvCustomText, "mvCustomText" ); + locator.bindComponent( mvWriteCustomData, "mvWriteCustomData@i" ); + locator.bindComponent( mvReadCustomData, "mvReadCustomData@i" ); + locator.bindComponent( mvSensorRegister, "mvSensorRegister" ); + locator.bindComponent( mvSensorRegisterValue, "mvSensorRegisterValue" ); + locator.bindComponent( mvInternalRegister, "mvInternalRegister" ); + locator.bindComponent( mvInternalRegisterValue, "mvInternalRegisterValue" ); + locator.bindComponent( mvMSeqRegister, "mvMSeqRegister" ); + locator.bindComponent( mvMSeqRegisterValue, "mvMSeqRegisterValue" ); + locator.bindComponent( mvStateSumRegister, "mvStateSumRegister" ); + locator.bindComponent( mvStat2SumRegister, "mvStat2SumRegister" ); + locator.bindComponent( mvStat3SumRegister, "mvStat3SumRegister" ); + locator.bindComponent( mvStat4SumRegister, "mvStat4SumRegister" ); + locator.bindComponent( mvStat5SumRegister, "mvStat5SumRegister" ); + locator.bindComponent( mvStat6SumRegister, "mvStat6SumRegister" ); + locator.bindComponent( mvStateSumRegisterReset, "mvStateSumRegisterReset@i" ); + locator.bindComponent( mvStateSumRegister3Reset, "mvStateSumRegister3Reset@i" ); + locator.bindComponent( mvLVDSSelection, "mvLVDSSelection" ); + locator.bindComponent( mvLVDSAlignment, "mvLVDSAlignment" ); + locator.bindComponent( mvRunTest, "mvRunTest@i" ); + locator.bindComponent( mvTestNumber, "mvTestNumber" ); + locator.bindComponent( mvTestMin, "mvTestMin" ); + locator.bindComponent( mvTestMax, "mvTestMax" ); + locator.bindComponent( mvCustomCommandInterpreterVersionMajor, "mvCustomCommandInterpreterVersionMajor" ); + locator.bindComponent( mvCustomCommandInterpreterVersionMinor, "mvCustomCommandInterpreterVersionMinor" ); + locator.bindComponent( mvCustomCommandBuffer, "mvCustomCommandBuffer" ); + locator.bindComponent( mvImxSensorType, "mvImxSensorType" ); + locator.bindComponent( mvImxSensorIdOne, "mvImxSensorIdOne" ); + locator.bindComponent( mvImxGroup, "mvImxGroup" ); + locator.bindComponent( mvImxSensorIdTwo, "mvImxSensorIdTwo" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property. Custom text. + /** + * Custom text. + */ + PropertyS mvCustomText; + /// \brief A method object. Function to write custom data. + /** + * Function to write custom data. + */ + Method mvWriteCustomData; + /// \brief A method object. Function to read custom data. + /** + * Function to read custom data. + */ + Method mvReadCustomData; + /// \brief An integer property. Sensor register address to access. + /** + * Sensor register address to access. + */ + PropertyI64 mvSensorRegister; + /// \brief An integer property. Value of sensor register. + /** + * Value of sensor register. + */ + PropertyI64 mvSensorRegisterValue; + /// \brief An integer property. Register address to access. + /** + * Register address to access. + */ + PropertyI64 mvInternalRegister; + /// \brief An integer property. Value of internal register. + /** + * Value of internal register. + */ + PropertyI64 mvInternalRegisterValue; + /// \brief An integer property. Register address to access. + /** + * Register address to access. + */ + PropertyI64 mvMSeqRegister; + /// \brief An integer property. Value of mseq register. + /** + * Value of mseq register. + */ + PropertyI64 mvMSeqRegisterValue; + /// \brief An integer property. Indicates several states besides some other info. + /** + * Indicates several states besides some other info. + */ + PropertyI64 mvStateSumRegister; + /// \brief An integer property. Indicates several states besides some other info. + /** + * Indicates several states besides some other info. + */ + PropertyI64 mvStat2SumRegister; + /// \brief An integer property. Indicates several states besides some other info. + /** + * Indicates several states besides some other info. + */ + PropertyI64 mvStat3SumRegister; + /// \brief An integer property. Indicates several states besides some other info. + /** + * Indicates several states besides some other info. + */ + PropertyI64 mvStat4SumRegister; + /// \brief An integer property. Indicates several states besides some other info. + /** + * Indicates several states besides some other info. + */ + PropertyI64 mvStat5SumRegister; + /// \brief An integer property. Indicates several states besides some other info. + /** + * Indicates several states besides some other info. + */ + PropertyI64 mvStat6SumRegister; + /// \brief A method object. Resets the state register. + /** + * Resets the state register. + */ + Method mvStateSumRegisterReset; + /// \brief A method object. Resets the state register. + /** + * Resets the state register. + */ + Method mvStateSumRegister3Reset; + /// \brief An integer property. Selector for LVDS lanes. + /** + * Selector for LVDS lanes. + */ + PropertyI64 mvLVDSSelection; + /// \brief An integer property. Alignment of LVDS lanes. + /** + * Alignment of LVDS lanes. + */ + PropertyI64 mvLVDSAlignment; + /// \brief A method object. Runs internal test. + /** + * Runs internal test. + */ + Method mvRunTest; + /// \brief An integer property. Number of test to run. + /** + * Number of test to run. + */ + PropertyI64 mvTestNumber; + /// \brief An integer property. Min number for test. + /** + * Min number for test. + */ + PropertyI64 mvTestMin; + /// \brief An integer property. Max number for test. + /** + * Max number for test. + */ + PropertyI64 mvTestMax; + /// \brief An integer property. Returns the major version of the custom command interpreter on the device. + /** + * Returns the major version of the custom command interpreter on the device. + */ + PropertyI64 mvCustomCommandInterpreterVersionMajor; + /// \brief An integer property. Returns the minor version of the custom command interpreter on the device. + /** + * Returns the minor version of the custom command interpreter on the device. + */ + PropertyI64 mvCustomCommandInterpreterVersionMinor; + /// \brief A string property. Command buffer for custom commands. + /** + * Command buffer for custom commands. + */ + PropertyS mvCustomCommandBuffer; + /// \brief An enumerated integer property. IMX sensor type from registers. + /** + * IMX sensor type from registers. + * + * The following string values might be valid for this feature: + * - \b mvUnknown (Display string: 'mv Unknown'): unknown or TS + * - \b IMX250G (Display string: 'IMX250G'): IMX250 Grey + * - \b IMX250G_POL (Display string: 'IMX250G_POL'): IMX250 Grey with POL filter + * - \b IMX250C (Display string: 'IMX250C'): IMX250 Color + * - \b IMX250C_POL (Display string: 'IMX250C_POL'): IMX250 Color with POL filter + * - \b IMX252G (Display string: 'IMX252G'): IMX252 Grey + * - \b IMX252C (Display string: 'IMX252C'): IMX252 Color + * - \b IMX253G (Display string: 'IMX253G'): IMX253 Grey + * - \b IMX253C (Display string: 'IMX253C'): IMX253 Color + * - \b IMX255G (Display string: 'IMX255G'): IMX255 Grey + * - \b IMX255C (Display string: 'IMX255C'): IMX255 Color + * - \b IMX264G (Display string: 'IMX264G'): IMX264 Grey + * - \b IMX264C (Display string: 'IMX264C'): IMX264 Color + * - \b IMX265G (Display string: 'IMX265G'): IMX265 Grey + * - \b IMX265C (Display string: 'IMX265C'): IMX265 Color + * - \b IMX267G (Display string: 'IMX267G'): IMX267 Grey + * - \b IMX267C (Display string: 'IMX267C'): IMX267 Color + * - \b IMX273G (Display string: 'IMX273G'): IMX273 Grey + * - \b IMX273C (Display string: 'IMX273C'): IMX273 Color + * - \b IMX392G (Display string: 'IMX392G'): IMX392 Grey + * - \b IMX392C (Display string: 'IMX392C'): IMX392 Color + * - \b IMX287G (Display string: 'IMX287G'): IMX287 Grey + * - \b IMX287C (Display string: 'IMX287C'): IMX287 Color + * - \b IMX304G (Display string: 'IMX304G'): IMX304 Grey + * - \b IMX304C (Display string: 'IMX304C'): IMX304 Color + * - \b IMX342G (Display string: 'IMX342G'): IMX342 Grey + * - \b IMX342C (Display string: 'IMX342C'): IMX342 Color + * - \b IMX367G (Display string: 'IMX367G'): IMX367 Grey + * - \b IMX367C (Display string: 'IMX367C'): IMX367 Color + * - \b IMX387G (Display string: 'IMX387G'): IMX387 Grey + * - \b IMX387C (Display string: 'IMX387C'): IMX387 Color + * - \b IMX420G (Display string: 'IMX420G'): IMX420 Grey + * - \b IMX420C (Display string: 'IMX420C'): IMX420 Color + * - \b IMX425G (Display string: 'IMX425G'): IMX425 Grey + * - \b IMX425C (Display string: 'IMX425C'): IMX425 Color + * - \b IMX428G (Display string: 'IMX428G'): IMX428 Grey + * - \b IMX428C (Display string: 'IMX428C'): IMX428 Color + * - \b IMX430G (Display string: 'IMX430G'): IMX430 Grey + * - \b IMX430C (Display string: 'IMX430C'): IMX430 Color + * - \b IMX432G (Display string: 'IMX432G'): IMX432 Grey + * - \b IMX432C (Display string: 'IMX432C'): IMX432 Color + * - \b IMX531G (Display string: 'IMX531G'): IMX531 Grey + * - \b IMX531C (Display string: 'IMX531C'): IMX531 Color + * - \b IMX532G (Display string: 'IMX532G'): IMX532 Grey + * - \b IMX532C (Display string: 'IMX532C'): IMX532 Color + * - \b IMX535G (Display string: 'IMX535G'): IMX535 Grey + * - \b IMX535C (Display string: 'IMX535C'): IMX535 Color + * - \b IMX540G (Display string: 'IMX540G'): IMX540 Grey + * - \b IMX540C (Display string: 'IMX540C'): IMX540 Color + * - \b IMX541G (Display string: 'IMX541G'): IMX541 Grey + * - \b IMX541C (Display string: 'IMX541C'): IMX541 Color + * - \b IMX542G (Display string: 'IMX542G'): IMX542 Grey + * - \b IMX542C (Display string: 'IMX542C'): IMX542 Color + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvImxSensorType; + /// \brief An integer property. IMX SensorID1 + /** + * IMX SensorID1 + */ + PropertyI64 mvImxSensorIdOne; + /// \brief An enumerated integer property. IMX Group + /** + * IMX Group + * + * The following string values might be valid for this feature: + * - \b mvUnknown (Display string: 'mv Unknown'): unknown + * - \b V2TypeOneGroup (Display string: 'V2 Type One Group'): Type 1/1 Group: IMX253/255/267/304/305 (2nd Generation GS-CIS) + * - \b V2TypeTwoThirdsGroup (Display string: 'V2 Type Two Thirds Group'): Type 2/3 Group: IMX250/252/264/265 (2nd Generation GS-CIS) + * - \b V2TypeOneThirdGroup (Display string: 'V2 Type One Third Group'): Type 1/3 Group: IMX273/287/296/297/392 (2nd Generation GS-CIS) + * - \b V25Group342 (Display string: 'V2.5 Group 342'): Group 342: IMX342/367/387 (IMX342 GS-CIS) + * - \b V3Group1 (Display string: 'V3 Group 1'): Group 1: IMX420/428 (3rd Generation GS-CIS) + * - \b V3Group2 (Display string: 'V3 Group 2'): Group 2: IMX421/422/429/430/437 (3rd Generation GS-CIS) + * - \b V3Group3 (Display string: 'V3 Group 3'): Group 3: IMX425/432 (3rd Generation GS-CIS) + * - \b V3Group4 (Display string: 'V3 Group 4'): Group 4: IMX426/433 (3rd Generation GS-CIS) + * - \b V4Group1 (Display string: 'V4 Group 1'): Group 1: IMX530/540 (4th Generation GS-CIS) + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvImxGroup; + /// \brief An integer property. IMX SensorID2 + /** + * IMX SensorID2 + */ + PropertyI64 mvImxSensorIdTwo; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains features to control the devices Logic Gate Control parameters. +/** + * A category that contains features to control the devices Logic Gate Control parameters. + * \ingroup GenICamInterfaceDevice + */ +class mvLogicGateControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvLogicGateControl object. + explicit mvLogicGateControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvLogicGateANDSelector(), + mvLogicGateANDSource1(), + mvANDSource1Inverter(), + mvLogicGateANDSource2(), + mvANDSource2Inverter(), + mvLogicGateORSelector(), + mvLogicGateORSource1(), + mvLogicGateORSource2(), + mvLogicGateORSource3(), + mvLogicGateORSource4(), + mvLogicGateSourceSelector(), + mvLogicGateSource(), + mvLogicGateSourceInverter(), + mvLogicGateANDTermSelector(), + mvLogicGateANDTermSrc0(), + mvLogicGateANDTermSrc1(), + mvLogicGateORTermSelector(), + mvLogicGateORTermSrc0(), + mvLogicGateORTermSrc1() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvLogicGateControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvLogicGateANDSelector, "mvLogicGateANDSelector" ); + locator.bindComponent( mvLogicGateANDSource1, "mvLogicGateANDSource1" ); + locator.bindComponent( mvANDSource1Inverter, "mvANDSource1Inverter" ); + locator.bindComponent( mvLogicGateANDSource2, "mvLogicGateANDSource2" ); + locator.bindComponent( mvANDSource2Inverter, "mvANDSource2Inverter" ); + locator.bindComponent( mvLogicGateORSelector, "mvLogicGateORSelector" ); + locator.bindComponent( mvLogicGateORSource1, "mvLogicGateORSource1" ); + locator.bindComponent( mvLogicGateORSource2, "mvLogicGateORSource2" ); + locator.bindComponent( mvLogicGateORSource3, "mvLogicGateORSource3" ); + locator.bindComponent( mvLogicGateORSource4, "mvLogicGateORSource4" ); + locator.bindComponent( mvLogicGateSourceSelector, "mvLogicGateSourceSelector" ); + locator.bindComponent( mvLogicGateSource, "mvLogicGateSource" ); + locator.bindComponent( mvLogicGateSourceInverter, "mvLogicGateSourceInverter" ); + locator.bindComponent( mvLogicGateANDTermSelector, "mvLogicGateANDTermSelector" ); + locator.bindComponent( mvLogicGateANDTermSrc0, "mvLogicGateANDTermSrc0" ); + locator.bindComponent( mvLogicGateANDTermSrc1, "mvLogicGateANDTermSrc1" ); + locator.bindComponent( mvLogicGateORTermSelector, "mvLogicGateORTermSelector" ); + locator.bindComponent( mvLogicGateORTermSrc0, "mvLogicGateORTermSrc0" ); + locator.bindComponent( mvLogicGateORTermSrc1, "mvLogicGateORTermSrc1" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the AND gate to configure. + /** + * This enumeration selects the AND gate to configure. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateAND1 (Display string: 'mv Logic Gate AND 1') + * - \b mvLogicGateAND2 (Display string: 'mv Logic Gate AND 2') + * - \b mvLogicGateAND3 (Display string: 'mv Logic Gate AND 3') + * - \b mvLogicGateAND4 (Display string: 'mv Logic Gate AND 4') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateANDSelector; + /// \brief An enumerated integer property. Selects the first input signal of the AND gate selected by mvLogicGateANDSelector. + /** + * This enumeration can be used to select the first input signal of the AND gate selected by mvLogicGateANDSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b Line4 (Display string: 'Line 4') + * - \b Line5 (Display string: 'Line 5') + * - \b Line6 (Display string: 'Line 6') + * - \b Line7 (Display string: 'Line 7') + * - \b Line12 (Display string: 'Line 12') + * - \b Line13 (Display string: 'Line 13') + * - \b Line14 (Display string: 'Line 14') + * - \b Line15 (Display string: 'Line 15') + * - \b ExposureActive (Display string: 'Exposure Active') + * - \b mvExposureSensor2Active (Display string: 'mv Exposure Sensor 2 Active') + * - \b UserOutput0 (Display string: 'User Output 0') + * - \b UserOutput1 (Display string: 'User Output 1') + * - \b UserOutput2 (Display string: 'User Output 2') + * - \b UserOutput3 (Display string: 'User Output 3') + * - \b UserOutput4 (Display string: 'User Output 4') + * - \b UserOutput5 (Display string: 'User Output 5') + * - \b UserOutput6 (Display string: 'User Output 6') + * - \b UserOutput7 (Display string: 'User Output 7') + * - \b Timer1Active (Display string: 'Timer 1 Active') + * - \b Timer2Active (Display string: 'Timer 2 Active') + * - \b Timer3Active (Display string: 'Timer 3 Active') + * - \b Counter1Active (Display string: 'Counter 1 Active') + * - \b Counter2Active (Display string: 'Counter 2 Active') + * - \b Counter3Active (Display string: 'Counter 3 Active') + * - \b Counter4Active (Display string: 'Counter 4 Active') + * - \b Counter5Active (Display string: 'Counter 5 Active') + * - \b Counter6Active (Display string: 'Counter 6 Active') + * - \b Counter7Active (Display string: 'Counter 7 Active') + * - \b Counter8Active (Display string: 'Counter 8 Active') + * - \b AcquisitionActive (Display string: 'Acquisition Active') + * - \b FrameActive (Display string: 'Frame Active') + * - \b LineActive (Display string: 'Line Active') + * - \b FrameTriggerWait (Display string: 'Frame Trigger Wait') + * - \b mvTemperatureOutOfRange (Display string: 'mv Temperature Out Of Range') + * - \b mvExposureActive (Display string: 'mv Exposure Active') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateANDSource1; + /// \brief A boolean property. Inverts the first input signal of the AND gate selected by mvLogicGateANDSelector + /** + * Inverts the first input signal of the AND gate selected by mvLogicGateANDSelector + */ + PropertyIBoolean mvANDSource1Inverter; + /// \brief An enumerated integer property. Selects the second input signal of the AND gate selected by mvLogicGateANDSelector. + /** + * This enumeration can be used to select the second input signal of the AND gate selected by mvLogicGateANDSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b Line4 (Display string: 'Line 4') + * - \b Line5 (Display string: 'Line 5') + * - \b Line6 (Display string: 'Line 6') + * - \b Line7 (Display string: 'Line 7') + * - \b Line12 (Display string: 'Line 12') + * - \b Line13 (Display string: 'Line 13') + * - \b Line14 (Display string: 'Line 14') + * - \b Line15 (Display string: 'Line 15') + * - \b ExposureActive (Display string: 'Exposure Active') + * - \b mvExposureSensor2Active (Display string: 'mv Exposure Sensor 2 Active') + * - \b UserOutput0 (Display string: 'User Output 0') + * - \b UserOutput1 (Display string: 'User Output 1') + * - \b UserOutput2 (Display string: 'User Output 2') + * - \b UserOutput3 (Display string: 'User Output 3') + * - \b UserOutput4 (Display string: 'User Output 4') + * - \b UserOutput5 (Display string: 'User Output 5') + * - \b UserOutput6 (Display string: 'User Output 6') + * - \b UserOutput7 (Display string: 'User Output 7') + * - \b Timer1Active (Display string: 'Timer 1 Active') + * - \b Timer2Active (Display string: 'Timer 2 Active') + * - \b Timer3Active (Display string: 'Timer 3 Active') + * - \b Counter1Active (Display string: 'Counter 1 Active') + * - \b Counter2Active (Display string: 'Counter 2 Active') + * - \b Counter3Active (Display string: 'Counter 3 Active') + * - \b Counter4Active (Display string: 'Counter 4 Active') + * - \b Counter5Active (Display string: 'Counter 5 Active') + * - \b Counter6Active (Display string: 'Counter 6 Active') + * - \b Counter7Active (Display string: 'Counter 7 Active') + * - \b Counter8Active (Display string: 'Counter 8 Active') + * - \b AcquisitionActive (Display string: 'Acquisition Active') + * - \b FrameActive (Display string: 'Frame Active') + * - \b LineActive (Display string: 'Line Active') + * - \b FrameTriggerWait (Display string: 'Frame Trigger Wait') + * - \b mvTemperatureOutOfRange (Display string: 'mv Temperature Out Of Range') + * - \b mvExposureActive (Display string: 'mv Exposure Active') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateANDSource2; + /// \brief A boolean property. Inverts the second input signal of the AND gate selected by mvLogicGateANDSelector + /** + * Inverts the second input signal of the AND gate selected by mvLogicGateANDSelector + */ + PropertyIBoolean mvANDSource2Inverter; + /// \brief An enumerated integer property. Selects the OR gate to configure. + /** + * This enumeration selects the OR gate to configure. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateOR1 (Display string: 'mv Logic Gate OR 1') + * - \b mvLogicGateOR2 (Display string: 'mv Logic Gate OR 2') + * - \b mvLogicGateOR3 (Display string: 'mv Logic Gate OR 3') + * - \b mvLogicGateOR4 (Display string: 'mv Logic Gate OR 4') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORSelector; + /// \brief An enumerated integer property. Selects the first input signal of the OR gate selected by mvLogicGateORSelector. + /** + * This enumeration can be used to select the first input signal of the OR gate selected by mvLogicGateORSelector. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateAND1Output (Display string: 'mv Logic Gate AND 1 Output') + * - \b mvLogicGateAND2Output (Display string: 'mv Logic Gate AND 2 Output') + * - \b mvLogicGateAND3Output (Display string: 'mv Logic Gate AND 3 Output') + * - \b mvLogicGateAND4Output (Display string: 'mv Logic Gate AND 4 Output') + * - \b Off (Display string: 'Off') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORSource1; + /// \brief An enumerated integer property. Selects the second input signal of the OR gate selected by mvLogicGateORSelector. + /** + * This enumeration can be used to select the second input signal of the OR gate selected by mvLogicGateORSelector. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateAND1Output (Display string: 'mv Logic Gate AND 1 Output') + * - \b mvLogicGateAND2Output (Display string: 'mv Logic Gate AND 2 Output') + * - \b mvLogicGateAND3Output (Display string: 'mv Logic Gate AND 3 Output') + * - \b mvLogicGateAND4Output (Display string: 'mv Logic Gate AND 4 Output') + * - \b Off (Display string: 'Off') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORSource2; + /// \brief An enumerated integer property. Selects the third input signal of the OR gate selected by mvLogicGateORSelector. + /** + * This enumeration can be used to select the third input signal of the OR gate selected by mvLogicGateORSelector. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateAND1Output (Display string: 'mv Logic Gate AND 1 Output') + * - \b mvLogicGateAND2Output (Display string: 'mv Logic Gate AND 2 Output') + * - \b mvLogicGateAND3Output (Display string: 'mv Logic Gate AND 3 Output') + * - \b mvLogicGateAND4Output (Display string: 'mv Logic Gate AND 4 Output') + * - \b Off (Display string: 'Off') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORSource3; + /// \brief An enumerated integer property. Selects the fourth input signal of the OR gate selected by mvLogicGateORSelector. + /** + * This enumeration can be used to select the fourth input signal of the OR gate selected by mvLogicGateORSelector. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateAND1Output (Display string: 'mv Logic Gate AND 1 Output') + * - \b mvLogicGateAND2Output (Display string: 'mv Logic Gate AND 2 Output') + * - \b mvLogicGateAND3Output (Display string: 'mv Logic Gate AND 3 Output') + * - \b mvLogicGateAND4Output (Display string: 'mv Logic Gate AND 4 Output') + * - \b Off (Display string: 'Off') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORSource4; + /// \brief An enumerated integer property. Selects the LogicGateSource of the AND-OR-Matrix. + /** + * Selects the LogicGateSource of the AND-OR-Matrix. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateSource0 (Display string: 'mv Logic Gate Source 0') + * - \b mvLogicGateSource1 (Display string: 'mv Logic Gate Source 1') + * - \b mvLogicGateSource2 (Display string: 'mv Logic Gate Source 2') + * - \b mvLogicGateSource3 (Display string: 'mv Logic Gate Source 3') + * - \b mvLogicGateSource4 (Display string: 'mv Logic Gate Source 4') + * - \b mvLogicGateSource5 (Display string: 'mv Logic Gate Source 5') + * - \b mvLogicGateSource6 (Display string: 'mv Logic Gate Source 6') + * - \b mvLogicGateSource7 (Display string: 'mv Logic Gate Source 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateSourceSelector; + /// \brief An enumerated integer property. Selects the input signal of the AND-OR-Matrix selected by mvLogicGateSourceSelector. + /** + * Selects the input signal of the AND-OR-Matrix selected by mvLogicGateSourceSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b Line4 (Display string: 'Line 4') + * - \b Line5 (Display string: 'Line 5') + * - \b Line6 (Display string: 'Line 6') + * - \b Line7 (Display string: 'Line 7') + * - \b ExposureActive (Display string: 'Exposure Active') + * - \b mvExposureSensor2Active (Display string: 'mv Exposure Sensor 2 Active') + * - \b UserOutput0 (Display string: 'User Output 0') + * - \b UserOutput1 (Display string: 'User Output 1') + * - \b UserOutput2 (Display string: 'User Output 2') + * - \b UserOutput3 (Display string: 'User Output 3') + * - \b UserOutput4 (Display string: 'User Output 4') + * - \b UserOutput5 (Display string: 'User Output 5') + * - \b UserOutput6 (Display string: 'User Output 6') + * - \b UserOutput7 (Display string: 'User Output 7') + * - \b Timer1Active (Display string: 'Timer 1 Active') + * - \b Timer2Active (Display string: 'Timer 2 Active') + * - \b Timer3Active (Display string: 'Timer 3 Active') + * - \b Counter1Active (Display string: 'Counter 1 Active') + * - \b Counter2Active (Display string: 'Counter 2 Active') + * - \b Counter3Active (Display string: 'Counter 3 Active') + * - \b Counter4Active (Display string: 'Counter 4 Active') + * - \b Counter5Active (Display string: 'Counter 5 Active') + * - \b Counter6Active (Display string: 'Counter 6 Active') + * - \b Counter7Active (Display string: 'Counter 7 Active') + * - \b Counter8Active (Display string: 'Counter 8 Active') + * - \b AcquisitionActive (Display string: 'Acquisition Active') + * - \b FrameActive (Display string: 'Frame Active') + * - \b LineActive (Display string: 'Line Active') + * - \b FrameTriggerWait (Display string: 'Frame Trigger Wait') + * - \b mvTemperatureOutOfRange (Display string: 'mv Temperature Out Of Range') + * - \b mvExposureActive (Display string: 'mv Exposure Active') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateSource; + /// \brief A boolean property. Inverts the input signal. + /** + * Inverts the input signal. + */ + PropertyIBoolean mvLogicGateSourceInverter; + /// \brief An enumerated integer property. Selects the AND-term of the AND-OR-matrix. + /** + * Selects the AND-term of the AND-OR-matrix. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateANDTerm0 (Display string: 'mv Logic Gate AND Term 0') + * - \b mvLogicGateANDTerm1 (Display string: 'mv Logic Gate AND Term 1') + * - \b mvLogicGateANDTerm2 (Display string: 'mv Logic Gate AND Term 2') + * - \b mvLogicGateANDTerm3 (Display string: 'mv Logic Gate AND Term 3') + * - \b mvLogicGateANDTerm4 (Display string: 'mv Logic Gate AND Term 4') + * - \b mvLogicGateANDTerm5 (Display string: 'mv Logic Gate AND Term 5') + * - \b mvLogicGateANDTerm6 (Display string: 'mv Logic Gate AND Term 6') + * - \b mvLogicGateANDTerm7 (Display string: 'mv Logic Gate AND Term 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateANDTermSelector; + /// \brief An enumerated integer property. Selects the first input signal of the AND-term selected by mvLogicGateANDTermSelector. + /** + * Selects the first input signal of the AND-term selected by mvLogicGateANDTermSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b mvLogicGateSource0 (Display string: 'mv Logic Gate Source 0') + * - \b mvLogicGateSource1 (Display string: 'mv Logic Gate Source 1') + * - \b mvLogicGateSource2 (Display string: 'mv Logic Gate Source 2') + * - \b mvLogicGateSource3 (Display string: 'mv Logic Gate Source 3') + * - \b mvLogicGateSource4 (Display string: 'mv Logic Gate Source 4') + * - \b mvLogicGateSource5 (Display string: 'mv Logic Gate Source 5') + * - \b mvLogicGateSource6 (Display string: 'mv Logic Gate Source 6') + * - \b mvLogicGateSource7 (Display string: 'mv Logic Gate Source 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateANDTermSrc0; + /// \brief An enumerated integer property. Selects the second input signal of the AND-term selected by mvLogicGateANDTermSelector. + /** + * Selects the second input signal of the AND-term selected by mvLogicGateANDTermSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b mvLogicGateSource0 (Display string: 'mv Logic Gate Source 0') + * - \b mvLogicGateSource1 (Display string: 'mv Logic Gate Source 1') + * - \b mvLogicGateSource2 (Display string: 'mv Logic Gate Source 2') + * - \b mvLogicGateSource3 (Display string: 'mv Logic Gate Source 3') + * - \b mvLogicGateSource4 (Display string: 'mv Logic Gate Source 4') + * - \b mvLogicGateSource5 (Display string: 'mv Logic Gate Source 5') + * - \b mvLogicGateSource6 (Display string: 'mv Logic Gate Source 6') + * - \b mvLogicGateSource7 (Display string: 'mv Logic Gate Source 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateANDTermSrc1; + /// \brief An enumerated integer property. Selects the OR-term of the AND-OR-matrix. + /** + * Selects the OR-term of the AND-OR-matrix. + * + * The following string values might be valid for this feature: + * - \b mvLogicGateORTerm0 (Display string: 'mv Logic Gate OR Term 0') + * - \b mvLogicGateORTerm1 (Display string: 'mv Logic Gate OR Term 1') + * - \b mvLogicGateORTerm2 (Display string: 'mv Logic Gate OR Term 2') + * - \b mvLogicGateORTerm3 (Display string: 'mv Logic Gate OR Term 3') + * - \b mvLogicGateORTerm4 (Display string: 'mv Logic Gate OR Term 4') + * - \b mvLogicGateORTerm5 (Display string: 'mv Logic Gate OR Term 5') + * - \b mvLogicGateORTerm6 (Display string: 'mv Logic Gate OR Term 6') + * - \b mvLogicGateORTerm7 (Display string: 'mv Logic Gate OR Term 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORTermSelector; + /// \brief An enumerated integer property. Selects the first input signal of the ORTerm selected by mvLogicGateORTermSelector. + /** + * Selects the first input signal of the ORTerm selected by mvLogicGateORTermSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b mvLogicGateANDTerm0 (Display string: 'mv Logic Gate AND Term 0') + * - \b mvLogicGateANDTerm1 (Display string: 'mv Logic Gate AND Term 1') + * - \b mvLogicGateANDTerm2 (Display string: 'mv Logic Gate AND Term 2') + * - \b mvLogicGateANDTerm3 (Display string: 'mv Logic Gate AND Term 3') + * - \b mvLogicGateANDTerm4 (Display string: 'mv Logic Gate AND Term 4') + * - \b mvLogicGateANDTerm5 (Display string: 'mv Logic Gate AND Term 5') + * - \b mvLogicGateANDTerm6 (Display string: 'mv Logic Gate AND Term 6') + * - \b mvLogicGateANDTerm7 (Display string: 'mv Logic Gate AND Term 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORTermSrc0; + /// \brief An enumerated integer property. Selects the second input signal of the ORTerm selected by mvLogicGateORTermSelector. + /** + * Selects the second input signal of the ORTerm selected by mvLogicGateORTermSelector. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off') + * - \b mvLogicGateANDTerm0 (Display string: 'mv Logic Gate AND Term 0') + * - \b mvLogicGateANDTerm1 (Display string: 'mv Logic Gate AND Term 1') + * - \b mvLogicGateANDTerm2 (Display string: 'mv Logic Gate AND Term 2') + * - \b mvLogicGateANDTerm3 (Display string: 'mv Logic Gate AND Term 3') + * - \b mvLogicGateANDTerm4 (Display string: 'mv Logic Gate AND Term 4') + * - \b mvLogicGateANDTerm5 (Display string: 'mv Logic Gate AND Term 5') + * - \b mvLogicGateANDTerm6 (Display string: 'mv Logic Gate AND Term 6') + * - \b mvLogicGateANDTerm7 (Display string: 'mv Logic Gate AND Term 7') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvLogicGateORTermSrc1; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains features to control the devices Current Control parameters. +/** + * A category that contains features to control the devices Current Control parameters. + * \ingroup GenICamInterfaceDevice + */ +class mvCurrentControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvCurrentControl object. + explicit mvCurrentControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvCurrentSelector(), + mvCurrent() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvCurrentControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvCurrentSelector, "mvCurrentSelector" ); + locator.bindComponent( mvCurrent, "mvCurrent" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Selects the current source to configure. + /** + * Selects the current source to configure. + * + * The following string values might be valid for this feature: + * - \b Current0 (Display string: 'Current 0') + * - \b Current1 (Display string: 'Current 1') + * - \b Current2 (Display string: 'Current 2') + * - \b Current3 (Display string: 'Current 3') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvCurrentSelector; + /// \brief An integer property. Sets the current value for the selected device(e.g.: LED). + /** + * Sets the current value for the selected device(e.g.: LED). + */ + PropertyI64 mvCurrent; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Contains features to control motorized lenses +/** + * Contains features to control motorized lenses. + * \ingroup GenICamInterfaceDevice + */ +class mvLensControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvLensControl object. + explicit mvLensControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvIrisType(), + mvIrisMode(), + mvIrisSignalLevelMin(), + mvIrisSignalLevelMax(), + mvDriveSelector(), + mvDriveForward(), + mvDriveBackward(), + mvDriveDuration(), + mvDriveLevel() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvLensControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvIrisType, "mvIrisType" ); + locator.bindComponent( mvIrisMode, "mvIrisMode" ); + locator.bindComponent( mvIrisSignalLevelMin, "mvIrisSignalLevelMin" ); + locator.bindComponent( mvIrisSignalLevelMax, "mvIrisSignalLevelMax" ); + locator.bindComponent( mvDriveSelector, "mvDriveSelector" ); + locator.bindComponent( mvDriveForward, "mvDriveForward@i" ); + locator.bindComponent( mvDriveBackward, "mvDriveBackward@i" ); + locator.bindComponent( mvDriveDuration, "mvDriveDuration" ); + locator.bindComponent( mvDriveLevel, "mvDriveLevel" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Sets the iris type. + /** + * Sets the iris type. + * + * The following string values might be valid for this feature: + * - \b mvVideoIris (Display string: 'mv Video Iris') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvIrisType; + /// \brief An enumerated integer property. Sets the iris operating mode. + /** + * Sets the iris operating mode. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): No iris adjustment will be done. + * - \b mvIrisAuto (Display string: 'mv Iris Auto'): The iris adjustment will be done automatically by evaluating the current image data. + * - \b mvIrisOpen (Display string: 'mv Iris Open'): The iris is fully open. + * - \b mvIrisClose (Display string: 'mv Iris Close'): The iris is fully closed. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvIrisMode; + /// \brief An integer property. Sets the minimum iris signal level in mV. + /** + * Sets the minimum iris signal level in mV. + */ + PropertyI64 mvIrisSignalLevelMin; + /// \brief An integer property. Sets the maximum iris signal level in mV. + /** + * Sets the maximum iris signal level in mV. + */ + PropertyI64 mvIrisSignalLevelMax; + /// \brief An enumerated integer property. Selects the lens drive that should be adjusted. + /** + * Selects the lens drive that should be adjusted. + * + * The following string values might be valid for this feature: + * - \b mvFocus (Display string: 'mv Focus'): Selects the motor to control the focus. + * - \b mvZoom (Display string: 'mv Zoom'): Selects the motor to control the zoom. + * - \b mvIris (Display string: 'mv Iris'): Selects the motor to control the iris. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDriveSelector; + /// \brief A method object. Generates a pulse defined by 'mvDriveDuration' and 'mvDriveLevel' to move the selected motor in forward direction. + /** + * Generates a pulse defined by 'mvDriveDuration' and 'mvDriveLevel' to move the selected motor in forward direction. + */ + Method mvDriveForward; + /// \brief A method object. Generates a pulse defined by 'mvDriveDuration' and 'mvDriveLevel' to move the selected motor in backward direction. + /** + * Generates a pulse defined by 'mvDriveDuration' and 'mvDriveLevel' to move the selected motor in backward direction. + */ + Method mvDriveBackward; + /// \brief An integer property. Sets the duration of the drive command in us. + /** + * Sets the duration of the drive command in us. + */ + PropertyI64 mvDriveDuration; + /// \brief An integer property. Sets the voltage level of the drive command in mV. + /** + * Sets the voltage level of the drive command in mV. + */ + PropertyI64 mvDriveLevel; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Contains features to control the devices Flat Field Correction parameters. +/** + * Contains features to control the devices Flat Field Correction parameters. + * \ingroup GenICamInterfaceDevice + */ +class mvFFCControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvFFCControl object. + explicit mvFFCControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvFFCEnable(), + mvFFCCalibrationImageCount(), + mvFFCCalibrate(), + mvFFCImageLoad(), + mvFFCImageSave(), + mvFFCAutoLoadMode() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvFFCControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvFFCEnable, "mvFFCEnable" ); + locator.bindComponent( mvFFCCalibrationImageCount, "mvFFCCalibrationImageCount" ); + locator.bindComponent( mvFFCCalibrate, "mvFFCCalibrate@i" ); + locator.bindComponent( mvFFCImageLoad, "mvFFCImageLoad@i" ); + locator.bindComponent( mvFFCImageSave, "mvFFCImageSave@i" ); + locator.bindComponent( mvFFCAutoLoadMode, "mvFFCAutoLoadMode" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A boolean property. Enables the Flat Field Correction. + /** + * Enables the Flat Field Correction. + */ + PropertyIBoolean mvFFCEnable; + /// \brief An integer property. The number of images to use for the calculation of the correction image. + /** + * The number of images to use for the calculation of the correction image. + */ + PropertyI64 mvFFCCalibrationImageCount; + /// \brief A method object. Starts the Calibration of the Flat Field Correction. + /** + * Starts the Calibration of the Flat Field Correction. + */ + Method mvFFCCalibrate; + /// \brief A method object. Loads the Flat Field Correction image from flash. + /** + * Loads the Flat Field Correction image from flash. + */ + Method mvFFCImageLoad; + /// \brief A method object. Saves the calibrated Flat Field Correction image to flash. + /** + * Saves the calibrated Flat Field Correction image to flash. + */ + Method mvFFCImageSave; + /// \brief An enumerated integer property. Selects whether FFC image shall be automatically loaded at camera startup. + /** + * Selects whether FFC image shall be automatically loaded at camera startup. + * + * The following string values might be valid for this feature: + * - \b mvLegacy (Display string: 'mv Legacy'): ) + * - \b Off (Display string: 'Off'): FFC image will not be automatically loaded at startup. Use this for short boot times. + * - \b On (Display string: 'On'): FFC image will be automatically loaded at startup. Boot time will increase accordingly. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvFFCAutoLoadMode; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains features to control the frame averaging engine. +/** + * A category that contains features to control the frame averaging engine. + * \ingroup GenICamInterfaceDevice + */ +class mvFrameAverageControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvFrameAverageControl object. + explicit mvFrameAverageControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvFrameAverageMode(), + mvFrameAverageEnable(), + mvFrameAverageSlope(), + mvFrameAverageDynamicMode(), + mvFrameAverageNoiseLimit(), + mvFrameAverageNoiseGain(), + mvFrameAverageFrameCount() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvFrameAverageControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvFrameAverageMode, "mvFrameAverageMode" ); + locator.bindComponent( mvFrameAverageEnable, "mvFrameAverageEnable" ); + locator.bindComponent( mvFrameAverageSlope, "mvFrameAverageSlope" ); + locator.bindComponent( mvFrameAverageDynamicMode, "mvFrameAverageDynamicMode" ); + locator.bindComponent( mvFrameAverageNoiseLimit, "mvFrameAverageNoiseLimit" ); + locator.bindComponent( mvFrameAverageNoiseGain, "mvFrameAverageNoiseGain" ); + locator.bindComponent( mvFrameAverageFrameCount, "mvFrameAverageFrameCount" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief An enumerated integer property. Sets the frame average operating mode. + /** + * Sets the frame average operating mode. + * + * The following string values might be valid for this feature: + * - \b mvPlain (Display string: 'mv Plain') + * - \b mvDynamic (Display string: 'mv Dynamic') + * - \b mvNTo1 (Display string: 'mv N To 1') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvFrameAverageMode; + /// \brief A boolean property. Enables the frame averaging engine. + /** + * Enables the frame averaging engine. + */ + PropertyIBoolean mvFrameAverageEnable; + /// \brief An integer property. Here you specify the noise border for very dark pictures. + /** + * Here you specify the noise border for very dark pictures. + */ + PropertyI64 mvFrameAverageSlope; + /// \brief An enumerated integer property. Sets the frame average dynamic operating mode. + /** + * Sets the frame average dynamic operating mode. + * + * The following string values might be valid for this feature: + * - \b mvStandard (Display string: 'mv Standard') + * - \b mvGauss (Display string: 'mv Gauss') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvFrameAverageDynamicMode; + /// \brief An integer property. Here you specify the noise limit for very bright pictures. + /** + * Here you specify the noise limit for very bright pictures. + */ + PropertyI64 mvFrameAverageNoiseLimit; + /// \brief An integer property. Here you specify the noise border for very bright pictures. + /** + * Here you specify the noise border for very bright pictures. + */ + PropertyI64 mvFrameAverageNoiseGain; + /// \brief An integer property. Here you specify the frame count used for the calculation of the frame average. + /** + * Here you specify the frame count used for the calculation of the frame average. + */ + PropertyI64 mvFrameAverageFrameCount; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains features to control the devices High Dynamic Range parameters. +/** + * A category that contains features to control the devices High Dynamic Range parameters. + * \ingroup GenICamInterfaceDevice + */ +class mvHDRControl : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::mvHDRControl object. + explicit mvHDRControl( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + mvHDREnable(), + mvHDRPreset(), + mvHDRSelector(), + mvHDRVoltage1(), + mvHDRVoltage2(), + mvHDRExposure1(), + mvHDRExposure2(), + mvHDRExposureRatio(), + mvHDRMotionCompensationEnable(), + mvHDRAdaptiveLocalToneMappingEnable() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenICam/mvHDRControl" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( mvHDREnable, "mvHDREnable" ); + locator.bindComponent( mvHDRPreset, "mvHDRPreset" ); + locator.bindComponent( mvHDRSelector, "mvHDRSelector" ); + locator.bindComponent( mvHDRVoltage1, "mvHDRVoltage1" ); + locator.bindComponent( mvHDRVoltage2, "mvHDRVoltage2" ); + locator.bindComponent( mvHDRExposure1, "mvHDRExposure1" ); + locator.bindComponent( mvHDRExposure2, "mvHDRExposure2" ); + locator.bindComponent( mvHDRExposureRatio, "mvHDRExposureRatio" ); + locator.bindComponent( mvHDRMotionCompensationEnable, "mvHDRMotionCompensationEnable" ); + locator.bindComponent( mvHDRAdaptiveLocalToneMappingEnable, "mvHDRAdaptiveLocalToneMappingEnable" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A boolean property. Enables the High Dynamic Range Feature. + /** + * Enables the High Dynamic Range Feature. + */ + PropertyIBoolean mvHDREnable; + /// \brief An enumerated integer property. Selects the HDR parameter set. + /** + * Selects the HDR parameter set. + * + * The following string values might be valid for this feature: + * - \b mvDualKneePoint0 (Display string: 'mv Dual Knee Point 0') + * - \b mvDualKneePoint1 (Display string: 'mv Dual Knee Point 1') + * - \b mvDualKneePoint2 (Display string: 'mv Dual Knee Point 2') + * - \b mvDualKneePoint3 (Display string: 'mv Dual Knee Point 3') + * - \b mvDualKneePoint4 (Display string: 'mv Dual Knee Point 4') + * - \b mvDualKneePoint5 (Display string: 'mv Dual Knee Point 5') + * - \b mvDualKneePoint6 (Display string: 'mv Dual Knee Point 6') + * - \b mvDualKneePointUser (Display string: 'mv Dual Knee Point User') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvHDRPreset; + /// \brief An enumerated integer property. Selects the HDR parameter set to configure. + /** + * This enumeration selects the HDR parameter set to configure. + * + * The following string values might be valid for this feature: + * - \b mvDualKneePoint0 (Display string: 'mv Dual Knee Point 0') + * - \b mvDualKneePoint1 (Display string: 'mv Dual Knee Point 1') + * - \b mvDualKneePoint2 (Display string: 'mv Dual Knee Point 2') + * - \b mvDualKneePoint3 (Display string: 'mv Dual Knee Point 3') + * - \b mvDualKneePoint4 (Display string: 'mv Dual Knee Point 4') + * - \b mvDualKneePoint5 (Display string: 'mv Dual Knee Point 5') + * - \b mvDualKneePoint6 (Display string: 'mv Dual Knee Point 6') + * - \b mvDualKneePointUser (Display string: 'mv Dual Knee Point User') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvHDRSelector; + /// \brief An integer property. First HDR Voltage in mV. + /** + * First HDR Voltage in mV. + */ + PropertyI64 mvHDRVoltage1; + /// \brief An integer property. Second HDR Voltage in mV. + /** + * Second HDR Voltage in mV. + */ + PropertyI64 mvHDRVoltage2; + /// \brief An integer property. First HDR Exposure in ppm. + /** + * First HDR Exposure in ppm. + */ + PropertyI64 mvHDRExposure1; + /// \brief An integer property. Second HDR Exposure in ppm. + /** + * Second HDR Exposure in ppm. + */ + PropertyI64 mvHDRExposure2; + /// \brief An enumerated integer property. T1/T2 Exposure Ratio + /** + * The ratio of the long exposure time to the short exposure time. + * + * The following string values might be valid for this feature: + * - \b mvRatio4x (Display string: 'mv Ratio 4x') + * - \b mvRatio8x (Display string: 'mv Ratio 8x') + * - \b mvRatio16x (Display string: 'mv Ratio 16x') + * - \b mvRatio32x (Display string: 'mv Ratio 32x') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvHDRExposureRatio; + /// \brief A boolean property. Enables motion compensation + /** + * Enables motion compensation. Recommended for scenes with a lot of motion. + */ + PropertyIBoolean mvHDRMotionCompensationEnable; + /// \brief A boolean property. Enables Adaptive Local Tone Mapping + /** + * Enables Adaptive Local Tone Mapping. Recommended if mvHDRMotionCompensationEnable is enabled. + */ + PropertyIBoolean mvHDRAdaptiveLocalToneMappingEnable; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains items that belong to the system module of the transport layer. +/** + * The System category contains items that belong to the system module of the transport layer. + * \ingroup GenICamInterfaceProducer + */ +class SystemModule : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +private: + void init( mvIMPACT::acquire::ComponentLocator& locator ) + { + locator.bindComponent( TLVendorName, "TLVendorName" ); + locator.bindComponent( TLModelName, "TLModelName" ); + locator.bindComponent( TLID, "TLID" ); + locator.bindComponent( TLVersion, "TLVersion" ); + locator.bindComponent( TLFileName, "TLFileName" ); + locator.bindComponent( TLDisplayName, "TLDisplayName" ); + locator.bindComponent( TLPath, "TLPath" ); + locator.bindComponent( TLType, "TLType" ); + locator.bindComponent( genTLVersionMajor, "GenTLVersionMajor" ); + locator.bindComponent( genTLVersionMinor, "GenTLVersionMinor" ); + locator.bindComponent( genTLSFNCVersionMajor, "GenTLSFNCVersionMajor" ); + locator.bindComponent( genTLSFNCVersionMinor, "GenTLSFNCVersionMinor" ); + locator.bindComponent( genTLSFNCVersionSubMinor, "GenTLSFNCVersionSubMinor" ); + locator.bindComponent( genCPVersionMajor, "GenCPVersionMajor" ); + locator.bindComponent( genCPVersionMinor, "GenCPVersionMinor" ); + locator.bindComponent( gevVersionMajor, "GevVersionMajor" ); + locator.bindComponent( gevVersionMinor, "GevVersionMinor" ); + locator.bindComponent( u3vVersionMajor, "U3vVersionMajor" ); + locator.bindComponent( u3vVersionMinor, "U3vVersionMinor" ); + locator.bindComponent( mvGevChannelDummyPacketSendEnable, "mvGevChannelDummyPacketSendEnable" ); + locator.bindComponent( mvGevChannelDummyPacketSendInterval, "mvGevChannelDummyPacketSendInterval" ); + locator.bindComponent( mvInterfaceTechnologyToIgnoreSelector, "mvInterfaceTechnologyToIgnoreSelector" ); + locator.bindComponent( mvInterfaceTechnologyToIgnoreEnable, "mvInterfaceTechnologyToIgnoreEnable" ); + locator.bindComponent( interfaceUpdateList, "InterfaceUpdateList@i" ); + locator.bindComponent( interfaceUpdateTimeout, "InterfaceUpdateTimeout" ); + locator.bindComponent( interfaceSelector, "InterfaceSelector" ); + locator.bindComponent( interfaceID, "InterfaceID" ); + locator.bindComponent( interfaceDisplayName, "InterfaceDisplayName" ); + locator.bindComponent( interfaceType, "InterfaceType" ); + locator.bindComponent( gevInterfaceMACAddress, "GevInterfaceMACAddress" ); + locator.bindComponent( gevInterfaceDefaultIPAddress, "GevInterfaceDefaultIPAddress" ); + locator.bindComponent( gevInterfaceDefaultSubnetMask, "GevInterfaceDefaultSubnetMask" ); + locator.bindComponent( gevInterfaceDefaultGateway, "GevInterfaceDefaultGateway" ); + locator.bindComponent( mvGevInterfaceMTU, "mvGevInterfaceMTU" ); + locator.bindComponent( mvGevInterfaceLinkSpeed, "mvGevInterfaceLinkSpeed" ); + locator.bindComponent( mvDeviceUpdateListBehaviour, "mvDeviceUpdateListBehaviour" ); + locator.bindComponent( eventSelector, "EventSelector" ); + locator.bindComponent( eventNotification, "EventNotification" ); + } +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::SystemModule object. + explicit SystemModule( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The \a index of the instance this object shall be created for. Passing an invalid index will raise an exception. + int64_type index = 0 ) : + mvIMPACT::acquire::ComponentCollection( INVALID_ID ), + TLVendorName(), + TLModelName(), + TLID(), + TLVersion(), + TLFileName(), + TLDisplayName(), + TLPath(), + TLType(), + genTLVersionMajor(), + genTLVersionMinor(), + genTLSFNCVersionMajor(), + genTLSFNCVersionMinor(), + genTLSFNCVersionSubMinor(), + genCPVersionMajor(), + genCPVersionMinor(), + gevVersionMajor(), + gevVersionMinor(), + u3vVersionMajor(), + u3vVersionMinor(), + mvGevChannelDummyPacketSendEnable(), + mvGevChannelDummyPacketSendInterval(), + mvInterfaceTechnologyToIgnoreSelector(), + mvInterfaceTechnologyToIgnoreEnable(), + interfaceUpdateList(), + interfaceUpdateTimeout(), + interfaceSelector(), + interfaceID(), + interfaceDisplayName(), + interfaceType(), + gevInterfaceMACAddress(), + gevInterfaceDefaultIPAddress(), + gevInterfaceDefaultSubnetMask(), + gevInterfaceDefaultGateway(), + mvGevInterfaceMTU(), + mvGevInterfaceLinkSpeed(), + mvDeviceUpdateListBehaviour(), + eventSelector(), + eventNotification() + { + mvIMPACT::acquire::ComponentLocator locator( pDev->deviceDriverFeatureList(), "GenTL" ); + if( locator.findComponent( "System", 0, 1 ) == INVALID_ID ) + { + std::ostringstream oss; + oss << "Producers/Producer" << index << "/System"; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + } + else if( index == 0 ) + { + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( "System" ) ); + } + else + { + std::ostringstream oss; + oss << "Producers/Producer" << index - 1 << "/System"; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + } + m_hRoot = locator.searchbase_id(); + init( locator ); + } + /// \brief Constructs a new mvIMPACT::acquire::GenICam::SystemModule object. + /** + * \since 2.17.0 + */ + explicit SystemModule( + /// [in] The \a index of the instance this object shall be created for. Passing an invalid index will raise an exception. + int64_type index = 0 ) : + mvIMPACT::acquire::ComponentCollection( INVALID_ID ), + TLVendorName(), + TLModelName(), + TLID(), + TLVersion(), + TLFileName(), + TLDisplayName(), + TLPath(), + TLType(), + genTLVersionMajor(), + genTLVersionMinor(), + genTLSFNCVersionMajor(), + genTLSFNCVersionMinor(), + genTLSFNCVersionSubMinor(), + genCPVersionMajor(), + genCPVersionMinor(), + gevVersionMajor(), + gevVersionMinor(), + u3vVersionMajor(), + u3vVersionMinor(), + mvGevChannelDummyPacketSendEnable(), + mvGevChannelDummyPacketSendInterval(), + mvInterfaceTechnologyToIgnoreSelector(), + mvInterfaceTechnologyToIgnoreEnable(), + interfaceUpdateList(), + interfaceUpdateTimeout(), + interfaceSelector(), + interfaceID(), + interfaceDisplayName(), + interfaceType(), + gevInterfaceMACAddress(), + gevInterfaceDefaultIPAddress(), + gevInterfaceDefaultSubnetMask(), + gevInterfaceDefaultGateway(), + mvGevInterfaceMTU(), + mvGevInterfaceLinkSpeed(), + mvDeviceUpdateListBehaviour(), + eventSelector(), + eventNotification() + { + HLIST hList; + TDMR_ERROR result; + if( ( result = DMR_FindList( INVALID_ID, "mvGenTLConsumer", dmltDeviceDriverLib, 0, &hList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, "Couldn't find list 'mvGenTLConsumer'(type: dmltDeviceDriverLib)" ); + } + mvIMPACT::acquire::ComponentLocator locator( hList, "GenTL" ); + if( locator.findComponent( "System", 0, 1 ) == INVALID_ID ) + { + std::ostringstream oss; + oss << "Producers/Producer" << index << "/System"; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + } + else if( index == 0 ) + { + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( "System" ) ); + } + else + { + std::ostringstream oss; + oss << "Producers/Producer" << index - 1 << "/System"; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + } + m_hRoot = locator.searchbase_id(); + init( locator ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property. Indicates the name of the transport layer vendor. + /** + * This is a read only element. It is a string that indicates the name of the transport layer vendor. + */ + PropertyS TLVendorName; + /// \brief A string property. Indicates the name of the transport layer Model. + /** + * This is a read only element. It is a string that indicates the name of the transport layer Model to distinguish different kinds of GenTL Producer implementations from one vendor. + */ + PropertyS TLModelName; + /// \brief A string property. Indicates the ID of the transport layer. + /** + * This is a read only element. It is a string that indicates the ID of the transport layer. + */ + PropertyS TLID; + /// \brief A string property. Indicates a vendor specific version string for this transport layer. + /** + * This is a read only element. It is a string that indicates a vendor specific version string for this transport layer. + */ + PropertyS TLVersion; + /// \brief A string property. Indicates the file name of the GenTL Producer driver including name and extension. + /** + * This is a read only element. It is a string that indicates the file name of the GenTL Producer driver including name and extension. + */ + PropertyS TLFileName; + /// \brief A string property. User readable name of the GenTL Producer. + /** + * This is a read only element. It is a string that indicates a user readable name of the GenTL Producer. + */ + PropertyS TLDisplayName; + /// \brief A string property. Indicates the full path to the GenTL Producer driver including name and extension. + /** + * This is a read only element. It is a string that indicates the full path to the GenTL Producer driver including name and extension. + */ + PropertyS TLPath; + /// \brief An enumerated integer property. Identifies the transport layer technology of the GenTL Producer implementation. + /** + * This is a read only feature. This enumeration provides a value that indicates the transport layer technology of the GenTL Producer implementation. + * + * The following string values might be valid for this feature: + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is a transport layer for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is a transport layer for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is a transport layer for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is a transport layer for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is a transport layer for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is a transport layer for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is a transport layer for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 TLType; + /// \brief An integer property. Defines the major version number of the GenTL specification the GenTL Producer implementation complies with. + /** + * This is a read only element. It defines the major version number of the GenTL specification the GenTL Producer implementation complies with. + */ + PropertyI64 genTLVersionMajor; + /// \brief An integer property. Defines the minor version number of the GenTL specification the GenTL Producer implementation complies with. + /** + * This is a read only element. It defines the minor version number of the GenTL specification the GenTL Producer implementation complies with. + */ + PropertyI64 genTLVersionMinor; + /// \brief An integer property. Defines the major version number of the GenTL SFNC specification the GenTL Producer implementation complies with. + /** + * This is a read only element. It defines the major version number of the GenTL SFNC specification the GenTL Producer implementation complies with. + */ + PropertyI64 genTLSFNCVersionMajor; + /// \brief An integer property. Defines the minor version number of the GenTL SFNC specification the GenTL Producer implementation complies with. + /** + * This is a read only element. It defines the minor version number of the GenTL SFNC specification the GenTL Producer implementation complies with. + */ + PropertyI64 genTLSFNCVersionMinor; + /// \brief An integer property. Defines the sub minor version number of the GenTL SFNC specification the GenTL Producer implementation complies with. + /** + * This is a read only element. It defines the sub minor version number of the GenTL SFNC specification the GenTL Producer implementation complies with. + */ + PropertyI64 genTLSFNCVersionSubMinor; + /// \brief An integer property. Indicates the major version number of the GenCP specification this GenTL Producer implementation complies with. + /** + * This is a read only element. It indicates the major version number of the GenCP specification this GenTL Producer implementation complies with. + */ + PropertyI64 genCPVersionMajor; + /// \brief An integer property. Indicates the minor version number of the GenCP specification this GenTL Producer implementation complies with. + /** + * This is a read only element. It indicates the minor version number of the GenCP specification this GenTL Producer implementation complies with. + */ + PropertyI64 genCPVersionMinor; + /// \brief An integer property. Indicates the major version number of the GigE Vision specification this GenTL Producer implementation complies with. + /** + * This is a read only element. It indicates the major version number of the GigE Vision specification this GenTL Producer implementation complies with. + */ + PropertyI64 gevVersionMajor; + /// \brief An integer property. Indicates the minor version number of the GigE Vision specification this GenTL Producer implementation complies with. + /** + * This is a read only element. It indicates the minor version number of the GigE Vision specification this GenTL Producer implementation complies with. + */ + PropertyI64 gevVersionMinor; + /// \brief An integer property. Indicates the major version number of the USB3 Vision specification this GenTL Producer implementation complies with. + /** + * This is a read only element. It indicates the major version number of the USB3 Vision specification this GenTL Producer implementation complies with. + */ + PropertyI64 u3vVersionMajor; + /// \brief An integer property. Indicates the minor version number of the USB3 Vision specification this GenTL Producer implementation complies with. + /** + * This is a read only element. It indicates the minor version number of the USB3 Vision specification this GenTL Producer implementation complies with. + */ + PropertyI64 u3vVersionMinor; + /// \brief A boolean property. Enables or disables the periodical sending of dummy packets to a stream or message channel source port of a GigE Vision device. + /** + * Enables or disables the periodical sending of dummy packets to a stream or message channel source port of a GigE Vision device. This might be useful to overcome firewall related problems when working with network devices. + */ + PropertyIBoolean mvGevChannelDummyPacketSendEnable; + /// \brief An integer property. Defines the period(in ms) for sending dummy packets to a stream or message channel source port of a GigE Vision device. + /** + * Defines the period(in ms) for sending dummy packets to a stream or message channel source port of a GigE Vision device. This might be useful to overcome firewall related problems when working with network devices. + */ + PropertyI64 mvGevChannelDummyPacketSendInterval; + /// \brief An enumerated integer property. Selects the interface technology type that should be ignored when updating the device list. + /** + * Selects the interface technology type that should be ignored when updating the device list. + * + * The following string values might be valid for this feature: + * - \b Mixed (Display string: 'Mixed') + * - \b Custom (Display string: 'Custom') + * - \b GEV (Display string: 'GigE Vision') + * - \b CameraLink (Display string: 'CameraLink') + * - \b CoaXPress (Display string: 'CoaXPress') + * - \b CameraLinkHS (Display string: 'CameraLink HS') + * - \b U3V (Display string: 'USB3 Vision') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvInterfaceTechnologyToIgnoreSelector; + /// \brief A boolean property. When enabled, the selected interface technology type is ignored when updating the device list. + /** + * When enabled, the selected interface technology type is ignored when updating the device list. + */ + PropertyIBoolean mvInterfaceTechnologyToIgnoreEnable; + /// \brief A method object. Updates the internal interface list. + /** + * This command updates the internal interface list of this transport layer. + */ + Method interfaceUpdateList; + /// \brief An integer property. Specifies timeout for the InterfaceUpdateList Command. + /** + * Specifies timeout for the InterfaceUpdateList Command. + */ + PropertyI64 interfaceUpdateTimeout; + /// \brief An integer property. Selector for the different GenTL Producer interfaces. + /** + * Selector for the different GenTL Producer interfaces. Selector for the different GenTL Producer interfaces. This interface list only changes on execution of InterfaceUpdateList. The selector is 0-based in order to match the index of the C interface. + */ + PropertyI64 interfaceSelector; + /// \brief A string property. GenTL producer wide unique identifier of the selected interface. + /** + * This is a read only element. It is a string that indicates a GenTL producer wide unique identifier of the selected interface. + */ + PropertyS interfaceID; + /// \brief A string property. A user-friendly name of the Interface. + /** + * This is a read only element. It is a string that indicates a user-friendly name of the Interface. + */ + PropertyS interfaceDisplayName; + /// \brief An enumerated integer property. Identifies the interfaces technology of the GenTL Producer implementation. + /** + * This is a read only feature. This enumeration provides a value that indicates interfaces technology of the GenTL Producer implementation. + * + * The following string values might be valid for this feature: + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is an interface for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is an interface for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is an interface for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is an interface for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is an interface for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is an interface for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is an interface for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 interfaceType; + /// \brief An integer property. Indicates the 48-bit MAC address of the selected interface. + /** + * This is a read only element. It indicates the 48-bit MAC address of the selected interface. + */ + PropertyI64 gevInterfaceMACAddress; + /// \brief An integer property. Indicates the IP address of the first subnet of the selected interface. + /** + * This is a read only element. It indicates the IP address of the first subnet of the selected interface. + */ + PropertyI64 gevInterfaceDefaultIPAddress; + /// \brief An integer property. Indicates the subnet mask of the first subnet of the selected interface. + /** + * This is a read only element. It indicates the subnet mask of the first subnet of the selected interface. + */ + PropertyI64 gevInterfaceDefaultSubnetMask; + /// \brief An integer property. Indicates the default gateway of the first subnet of the selected interface. + /** + * This is a read only element. It indicates the default gateway of the first subnet of the selected interface. + */ + PropertyI64 gevInterfaceDefaultGateway; + /// \brief An integer property. Indicates the MTU of the selected interface. + /** + * This is a read only element. It indicates the MTU(Maximum Transmission Unit) of the selected interface. + */ + PropertyI64 mvGevInterfaceMTU; + /// \brief An integer property. Indicates the link speed of this interface. + /** + * This is a read only element. It indicates the link speed(in Mbits per second) of this interface. + */ + PropertyI64 mvGevInterfaceLinkSpeed; + /// \brief An enumerated integer property. Defines the behavior of the interface when the device list is being updated. + /** + * Defines the behavior of the interface when the device list is being updated. + * + * The following string values might be valid for this feature: + * - \b NotConfigured (Display string: 'Not Configured'): Interface will enumerate devices or not according to the general enumeration behavior of this interface type(according to mvInterfaceTechnologyToIgnoreEnable setting). + * - \b ForceIgnore (Display string: 'Force Ignore'): Interface will not enumerate devices, regardless of the the general enumeration behavior of this interface type(overrides mvInterfaceTechnologyToIgnoreEnable setting). + * - \b ForceEnumerate (Display string: 'Force Enumerate'): Interface will forcefully enumerate devices, regardless of the the general enumeration behavior of this interface type(overrides mvInterfaceTechnologyToIgnoreEnable setting). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 mvDeviceUpdateListBehaviour; + /// \brief An enumerated integer property. Selects which Event to signal to the host application. + /** + * Selects which Event to signal to the host application. + * + * The following string values might be valid for this feature: + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device just received a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device just missed a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Device just started the Acquisition of one or many Frames. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Device just completed the Acquisition of one or many Frames. + * - \b AcquisitionTransferStart (Display string: 'Acquisition Transfer Start'): Device just started the transfer of one or many Frames. + * - \b AcquisitionTransferEnd (Display string: 'Acquisition Transfer End'): Device just completed the transfer of one or many Frames. + * - \b AcquisitionError (Display string: 'Acquisition Error'): Device just detected an error during the active Acquisition. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Device just started the capture of a burst of Frames. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Device just completed the capture of a burst of Frames. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device just received a trigger to start the capture of one Frame. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device just missed a trigger to start the capture of one Frame. + * - \b FrameStart (Display string: 'Frame Start'): Device just started the capture of one Frame. + * - \b FrameEnd (Display string: 'Frame End'): Device just completed the capture of one Frame. + * - \b FrameTransferStart (Display string: 'Frame Transfer Start'): Device just started the transfer of one Frame. + * - \b FrameTransferEnd (Display string: 'Frame Transfer End'): Device just completed the transfer of one Frame. + * - \b LineTrigger (Display string: 'Line Trigger'): Device just received a trigger to start the capture of one Line. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device just missed a trigger to start the capture of one Line. + * - \b LineStart (Display string: 'Line Start'): Device just started the capture of one Line. + * - \b LineEnd (Display string: 'Line End'): Device just completed the capture of one Line. + * - \b ExposureStart (Display string: 'Exposure Start'): Device just started the exposure of one Frame (or Line). + * - \b ExposureEnd (Display string: 'Exposure End'): Device just completed the exposure of one Frame (or Line). + * - \b Stream0TransferStart (Display string: 'Stream 0 Transfer Start'): Device just started the transfer of one or many Blocks. + * - \b Stream0TransferEnd (Display string: 'Stream 0 Transfer End'): Device just completed the transfer of one or many Blocks. + * - \b Stream0TransferPause (Display string: 'Stream 0 Transfer Pause'): Device just paused the transfer. + * - \b Stream0TransferResume (Display string: 'Stream 0 Transfer Resume'): Device just resumed the transfer. + * - \b Stream0TransferBlockStart (Display string: 'Stream 0 Transfer Block Start'): Device just started the transfer of one Block. + * - \b Stream0TransferBlockEnd (Display string: 'Stream 0 Transfer Block End'): Device just completed the transfer of one Block. + * - \b Stream0TransferBlockTrigger (Display string: 'Stream 0 Transfer Block Trigger'): Device just received a trigger to start the transfer of one Block. + * - \b Stream0TransferBurstStart (Display string: 'Stream 0 Transfer Burst Start'): Device just started the transfer of a burst of Blocks. + * - \b Stream0TransferBurstEnd (Display string: 'Stream 0 Transfer Burst End'): Device just completed the transfer of a burst of Blocks. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Device transfer queue overflowed. + * - \b SequencerSetChange (Display string: 'Sequencer Set Change'): Device sequencer set has changed. + * - \b Counter0Start (Display string: 'Counter 0 Start'): The event will be generated when counter 0 starts counting. + * - \b Counter1Start (Display string: 'Counter 1 Start'): The event will be generated when counter 1 starts counting. + * - \b Counter\#2\#Start (Display string: 'Counter \#2\# Start'): The event will be generated when counter \#2\# starts counting. + * - \b Counter0End (Display string: 'Counter 0 End'): The event will be generated when counter 0 ends counting. + * - \b Counter1End (Display string: 'Counter 1 End'): The event will be generated when counter 1 ends counting. + * - \b Counter\#2\#End (Display string: 'Counter \#2\# End'): The event will be generated when counter \#2\# ends counting. + * - \b Timer0Start (Display string: 'Timer 0 Start'): The event will be generated when Timer 0 starts counting. + * - \b Timer1Start (Display string: 'Timer 1 Start'): The event will be generated when Timer 1 starts counting. + * - \b Timer\#2\#Start (Display string: 'Timer \#2\# Start'): The event will be generated when Timer \#2\# starts counting. + * - \b Timer0End (Display string: 'Timer 0 End'): The event will be generated when Timer 0 ends counting. + * - \b Timer1End (Display string: 'Timer 1 End'): The event will be generated when Timer 1 ends counting. + * - \b Timer\#2\#End (Display string: 'Timer \#2\# End'): The event will be generated when Timer \#2\# ends counting. + * - \b Encoder0Stopped (Display string: 'Encoder 0 Stopped'): The event will be generated when the Encoder 0 stops for longer than EncoderTimeout. + * - \b Encoder1Stopped (Display string: 'Encoder 1 Stopped'): The event will be generated when the Encoder 1 stops for longer than EncoderTimeout. + * - \b Encoder\#2\#Stopped (Display string: 'Encoder \#2\# Stopped'): The event will be generated when the Encoder \#2\# stops for longer than EncoderTimeout. + * - \b Encoder0Restarted (Display string: 'Encoder 0 Restarted'): The event will be generated when the Encoder 0 restarts moving. + * - \b Encoder1Restarted (Display string: 'Encoder 1 Restarted'): The event will be generated when the Encoder 1 restarts moving. + * - \b Encoder\#2\#Restarted (Display string: 'Encoder \#2\# Restarted'): The event will be generated when the Encoder \#2\# restarts moving. + * - \b Line0RisingEdge (Display string: 'Line 0 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 0. + * - \b Line1RisingEdge (Display string: 'Line 1 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 1. + * - \b Line\#2\#RisingEdge (Display string: 'Line \#2\# Rising Edge'): The event will be generated when a Rising Edge is detected on the Line \#2\#. + * - \b Line0FallingEdge (Display string: 'Line 0 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 0. + * - \b Line1FallingEdge (Display string: 'Line 1 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 1. + * - \b Line\#2\#FallingEdge (Display string: 'Line \#2\# Falling Edge'): The event will be generated when a Falling Edge is detected on the Line \#2\#. + * - \b Line0AnyEdge (Display string: 'Line 0 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 0. + * - \b Line1AnyEdge (Display string: 'Line 1 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 1. + * - \b Line\#2\#AnyEdge (Display string: 'Line \#2\# Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line \#2\#. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): The event will be generated when a Rising Edge is detected on the LinkTrigger 0. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): The event will be generated when a Rising Edge is detected on the LinkTrigger 1. + * - \b LinkTrigger\#2\# (Display string: 'Link Trigger \#2\#'): The event will be generated when a Rising Edge is detected on the LinkTrigger \#2\#. + * - \b LinkSpeedChange (Display string: 'Link Speed Change'): The event will be generated when the link speed has changed. + * - \b ActionLate (Display string: 'Action Late'): The event will be generated when a valid scheduled action command is received and is scheduled to be executed at a time that is already past. + * - \b Error (Display string: 'Error'): Device just detected an error during the active Acquisition. + * - \b Test (Display string: 'Test'): The test event will be generated when the device receives the TestEventGenerate command (EventNotification for the Test event is always On). + * - \b PrimaryApplicationSwitch (Display string: 'Primary Application Switch'): The event will be generated when a primary application switchover has been granted (GigE Vision Specific). + * - \b Counter2Start (Display string: 'Counter 2 Start'): The event will be generated when counter 2 starts counting. + * - \b Counter3Start (Display string: 'Counter 3 Start'): The event will be generated when counter 3 starts counting. + * - \b Counter4Start (Display string: 'Counter 4 Start'): The event will be generated when counter 4 starts counting. + * - \b Counter5Start (Display string: 'Counter 5 Start'): The event will be generated when counter 5 starts counting. + * - \b Counter6Start (Display string: 'Counter 6 Start'): The event will be generated when counter 6 starts counting. + * - \b Counter7Start (Display string: 'Counter 7 Start'): The event will be generated when counter 7 starts counting. + * - \b Counter8Start (Display string: 'Counter 8 Start'): The event will be generated when counter 8 starts counting. + * - \b Counter9Start (Display string: 'Counter 9 Start'): The event will be generated when counter 9 starts counting. + * - \b Counter10Start (Display string: 'Counter 10 Start'): The event will be generated when counter 10 starts counting. + * - \b Counter11Start (Display string: 'Counter 11 Start'): The event will be generated when counter 11 starts counting. + * - \b Counter12Start (Display string: 'Counter 12 Start'): The event will be generated when counter 12 starts counting. + * - \b Counter13Start (Display string: 'Counter 13 Start'): The event will be generated when counter 13 starts counting. + * - \b Counter14Start (Display string: 'Counter 14 Start'): The event will be generated when counter 14 starts counting. + * - \b Counter15Start (Display string: 'Counter 15 Start'): The event will be generated when counter 15 starts counting. + * - \b Counter2End (Display string: 'Counter 2 End'): The event will be generated when counter 2 ends counting. + * - \b Counter3End (Display string: 'Counter 3 End'): The event will be generated when counter 3 ends counting. + * - \b Counter4End (Display string: 'Counter 4 End'): The event will be generated when counter 4 ends counting. + * - \b Counter5End (Display string: 'Counter 5 End'): The event will be generated when counter 5 ends counting. + * - \b Counter6End (Display string: 'Counter 6 End'): The event will be generated when counter 6 ends counting. + * - \b Counter7End (Display string: 'Counter 7 End'): The event will be generated when counter 7 ends counting. + * - \b Counter8End (Display string: 'Counter 8 End'): The event will be generated when counter 8 ends counting. + * - \b Counter9End (Display string: 'Counter 9 End'): The event will be generated when counter 9 ends counting. + * - \b Counter10End (Display string: 'Counter 10 End'): The event will be generated when counter 10 ends counting. + * - \b Counter11End (Display string: 'Counter 11 End'): The event will be generated when counter 11 ends counting. + * - \b Counter12End (Display string: 'Counter 12 End'): The event will be generated when counter 12 ends counting. + * - \b Counter13End (Display string: 'Counter 13 End'): The event will be generated when counter 13 ends counting. + * - \b Counter14End (Display string: 'Counter 14 End'): The event will be generated when counter 14 ends counting. + * - \b Counter15End (Display string: 'Counter 15 End'): The event will be generated when counter 15 ends counting. + * - \b Timer2Start (Display string: 'Timer 2 Start'): The event will be generated when Timer 2 starts counting. + * - \b Timer3Start (Display string: 'Timer 3 Start'): The event will be generated when Timer 3 starts counting. + * - \b Timer4Start (Display string: 'Timer 4 Start'): The event will be generated when Timer 4 starts counting. + * - \b Timer5Start (Display string: 'Timer 5 Start'): The event will be generated when Timer 5 starts counting. + * - \b Timer6Start (Display string: 'Timer 6 Start'): The event will be generated when Timer 6 starts counting. + * - \b Timer7Start (Display string: 'Timer 7 Start'): The event will be generated when Timer 7 starts counting. + * - \b Timer8Start (Display string: 'Timer 8 Start'): The event will be generated when Timer 8 starts counting. + * - \b Timer9Start (Display string: 'Timer 9 Start'): The event will be generated when Timer 9 starts counting. + * - \b Timer10Start (Display string: 'Timer 10 Start'): The event will be generated when Timer 10 starts counting. + * - \b Timer11Start (Display string: 'Timer 11 Start'): The event will be generated when Timer 11 starts counting. + * - \b Timer12Start (Display string: 'Timer 12 Start'): The event will be generated when Timer 12 starts counting. + * - \b Timer13Start (Display string: 'Timer 13 Start'): The event will be generated when Timer 13 starts counting. + * - \b Timer14Start (Display string: 'Timer 14 Start'): The event will be generated when Timer 14 starts counting. + * - \b Timer15Start (Display string: 'Timer 15 Start'): The event will be generated when Timer 15 starts counting. + * - \b Timer2End (Display string: 'Timer 2 End'): The event will be generated when Timer 2 ends counting. + * - \b Timer3End (Display string: 'Timer 3 End'): The event will be generated when Timer 3 ends counting. + * - \b Timer4End (Display string: 'Timer 4 End'): The event will be generated when Timer 4 ends counting. + * - \b Timer5End (Display string: 'Timer 5 End'): The event will be generated when Timer 5 ends counting. + * - \b Timer6End (Display string: 'Timer 6 End'): The event will be generated when Timer 6 ends counting. + * - \b Timer7End (Display string: 'Timer 7 End'): The event will be generated when Timer 7 ends counting. + * - \b Timer8End (Display string: 'Timer 8 End'): The event will be generated when Timer 8 ends counting. + * - \b Timer9End (Display string: 'Timer 9 End'): The event will be generated when Timer 9 ends counting. + * - \b Timer10End (Display string: 'Timer 10 End'): The event will be generated when Timer 10 ends counting. + * - \b Timer11End (Display string: 'Timer 11 End'): The event will be generated when Timer 11 ends counting. + * - \b Timer12End (Display string: 'Timer 12 End'): The event will be generated when Timer 12 ends counting. + * - \b Timer13End (Display string: 'Timer 13 End'): The event will be generated when Timer 13 ends counting. + * - \b Timer14End (Display string: 'Timer 14 End'): The event will be generated when Timer 14 ends counting. + * - \b Timer15End (Display string: 'Timer 15 End'): The event will be generated when Timer 15 ends counting. + * - \b Encoder2Stopped (Display string: 'Encoder 2 Stopped'): The event will be generated when the Encoder 2 stops for longer than EncoderTimeout. + * - \b Encoder3Stopped (Display string: 'Encoder 3 Stopped'): The event will be generated when the Encoder 3 stops for longer than EncoderTimeout. + * - \b Encoder4Stopped (Display string: 'Encoder 4 Stopped'): The event will be generated when the Encoder 4 stops for longer than EncoderTimeout. + * - \b Encoder5Stopped (Display string: 'Encoder 5 Stopped'): The event will be generated when the Encoder 5 stops for longer than EncoderTimeout. + * - \b Encoder6Stopped (Display string: 'Encoder 6 Stopped'): The event will be generated when the Encoder 6 stops for longer than EncoderTimeout. + * - \b Encoder7Stopped (Display string: 'Encoder 7 Stopped'): The event will be generated when the Encoder 7 stops for longer than EncoderTimeout. + * - \b Encoder8Stopped (Display string: 'Encoder 8 Stopped'): The event will be generated when the Encoder 8 stops for longer than EncoderTimeout. + * - \b Encoder9Stopped (Display string: 'Encoder 9 Stopped'): The event will be generated when the Encoder 9 stops for longer than EncoderTimeout. + * - \b Encoder10Stopped (Display string: 'Encoder 10 Stopped'): The event will be generated when the Encoder 10 stops for longer than EncoderTimeout. + * - \b Encoder11Stopped (Display string: 'Encoder 11 Stopped'): The event will be generated when the Encoder 11 stops for longer than EncoderTimeout. + * - \b Encoder12Stopped (Display string: 'Encoder 12 Stopped'): The event will be generated when the Encoder 12 stops for longer than EncoderTimeout. + * - \b Encoder13Stopped (Display string: 'Encoder 13 Stopped'): The event will be generated when the Encoder 13 stops for longer than EncoderTimeout. + * - \b Encoder14Stopped (Display string: 'Encoder 14 Stopped'): The event will be generated when the Encoder 14 stops for longer than EncoderTimeout. + * - \b Encoder15Stopped (Display string: 'Encoder 15 Stopped'): The event will be generated when the Encoder 15 stops for longer than EncoderTimeout. + * - \b Encoder2Restarted (Display string: 'Encoder 2 Restarted'): The event will be generated when the Encoder 2 restarts moving. + * - \b Encoder3Restarted (Display string: 'Encoder 3 Restarted'): The event will be generated when the Encoder 3 restarts moving. + * - \b Encoder4Restarted (Display string: 'Encoder 4 Restarted'): The event will be generated when the Encoder 4 restarts moving. + * - \b Encoder5Restarted (Display string: 'Encoder 5 Restarted'): The event will be generated when the Encoder 5 restarts moving. + * - \b Encoder6Restarted (Display string: 'Encoder 6 Restarted'): The event will be generated when the Encoder 6 restarts moving. + * - \b Encoder7Restarted (Display string: 'Encoder 7 Restarted'): The event will be generated when the Encoder 7 restarts moving. + * - \b Encoder8Restarted (Display string: 'Encoder 8 Restarted'): The event will be generated when the Encoder 8 restarts moving. + * - \b Encoder9Restarted (Display string: 'Encoder 9 Restarted'): The event will be generated when the Encoder 9 restarts moving. + * - \b Encoder10Restarted (Display string: 'Encoder 10 Restarted'): The event will be generated when the Encoder 10 restarts moving. + * - \b Encoder11Restarted (Display string: 'Encoder 11 Restarted'): The event will be generated when the Encoder 11 restarts moving. + * - \b Encoder12Restarted (Display string: 'Encoder 12 Restarted'): The event will be generated when the Encoder 12 restarts moving. + * - \b Encoder13Restarted (Display string: 'Encoder 13 Restarted'): The event will be generated when the Encoder 13 restarts moving. + * - \b Encoder14Restarted (Display string: 'Encoder 14 Restarted'): The event will be generated when the Encoder 14 restarts moving. + * - \b Encoder15Restarted (Display string: 'Encoder 15 Restarted'): The event will be generated when the Encoder 15 restarts moving. + * - \b Line2RisingEdge (Display string: 'Line 2 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 2. + * - \b Line3RisingEdge (Display string: 'Line 3 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 3. + * - \b Line4RisingEdge (Display string: 'Line 4 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 4. + * - \b Line5RisingEdge (Display string: 'Line 5 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 5. + * - \b Line6RisingEdge (Display string: 'Line 6 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 6. + * - \b Line7RisingEdge (Display string: 'Line 7 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 7. + * - \b Line8RisingEdge (Display string: 'Line 8 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 8. + * - \b Line9RisingEdge (Display string: 'Line 9 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 9. + * - \b Line10RisingEdge (Display string: 'Line 10 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 10. + * - \b Line11RisingEdge (Display string: 'Line 11 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 11. + * - \b Line12RisingEdge (Display string: 'Line 12 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 12. + * - \b Line13RisingEdge (Display string: 'Line 13 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 13. + * - \b Line14RisingEdge (Display string: 'Line 14 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 14. + * - \b Line15RisingEdge (Display string: 'Line 15 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 15. + * - \b Line2FallingEdge (Display string: 'Line 2 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 2. + * - \b Line3FallingEdge (Display string: 'Line 3 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 3. + * - \b Line4FallingEdge (Display string: 'Line 4 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 4. + * - \b Line5FallingEdge (Display string: 'Line 5 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 5. + * - \b Line6FallingEdge (Display string: 'Line 6 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 6. + * - \b Line7FallingEdge (Display string: 'Line 7 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 7. + * - \b Line8FallingEdge (Display string: 'Line 8 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 8. + * - \b Line9FallingEdge (Display string: 'Line 9 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 9. + * - \b Line10FallingEdge (Display string: 'Line 10 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 10. + * - \b Line11FallingEdge (Display string: 'Line 11 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 11. + * - \b Line12FallingEdge (Display string: 'Line 12 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 12. + * - \b Line13FallingEdge (Display string: 'Line 13 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 13. + * - \b Line14FallingEdge (Display string: 'Line 14 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 14. + * - \b Line15FallingEdge (Display string: 'Line 15 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 15. + * - \b Line2AnyEdge (Display string: 'Line 2 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 2. + * - \b Line3AnyEdge (Display string: 'Line 3 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 3. + * - \b Line4AnyEdge (Display string: 'Line 4 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 4. + * - \b Line5AnyEdge (Display string: 'Line 5 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 5. + * - \b Line6AnyEdge (Display string: 'Line 6 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 6. + * - \b Line7AnyEdge (Display string: 'Line 7 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 7. + * - \b Line8AnyEdge (Display string: 'Line 8 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 8. + * - \b Line9AnyEdge (Display string: 'Line 9 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 9. + * - \b Line10AnyEdge (Display string: 'Line 10 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 10. + * - \b Line11AnyEdge (Display string: 'Line 11 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 11. + * - \b Line12AnyEdge (Display string: 'Line 12 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 12. + * - \b Line13AnyEdge (Display string: 'Line 13 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 13. + * - \b Line14AnyEdge (Display string: 'Line 14 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 14. + * - \b Line15AnyEdge (Display string: 'Line 15 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 15. + * - \b Link0Trigger (Display string: 'Link 0 Trigger') + * - \b Link1Trigger (Display string: 'Link 1 Trigger') + * - \b Link2Trigger (Display string: 'Link 2 Trigger') + * - \b Link3Trigger (Display string: 'Link 3 Trigger') + * - \b Link4Trigger (Display string: 'Link 4 Trigger') + * - \b Link5Trigger (Display string: 'Link 5 Trigger') + * - \b Link6Trigger (Display string: 'Link 6 Trigger') + * - \b Link7Trigger (Display string: 'Link 7 Trigger') + * - \b Link8Trigger (Display string: 'Link 8 Trigger') + * - \b Link9Trigger (Display string: 'Link 9 Trigger') + * - \b Link10Trigger (Display string: 'Link 10 Trigger') + * - \b Link11Trigger (Display string: 'Link 11 Trigger') + * - \b Link12Trigger (Display string: 'Link 12 Trigger') + * - \b Link13Trigger (Display string: 'Link 13 Trigger') + * - \b Link14Trigger (Display string: 'Link 14 Trigger') + * - \b Link15Trigger (Display string: 'Link 15 Trigger') + * - \b InterfaceListChanged (Display string: 'Interface List Changed'): This enumeration value indicates an event that is fired when the list of interfaces has been updated. + * - \b InterfaceLost (Display string: 'Interface Lost'): This enumeration value indicates an event that is raised when the interface connection is lost. + * - \b DeviceListChanged (Display string: 'Device List Changed'): This enumeration value indicates an event that is fired when the list of devices has been updated. + * - \b DeviceLost (Display string: 'Device Lost'): This enumeration value indicates an event that is raised when the local host looses connection to the physical(remote) device. + * - \b BufferTooSmall (Display string: 'Buffer Too Small'): This enumeration value indicates an event that is raised when the buffer was too small to receive the expected amount of data. + * - \b BuffersDiscarded (Display string: 'Buffers Discarded'): This enumeration value indicates an event that is raised when buffers discared by GenTL or device. This event could optionally carry two numeric child data fields EventBuffersDiscardedDeviceCount and EventBuffersDiscardedProducerCount. + * - \b BuffersDiscardedDeviceCount (Display string: 'Buffers Discarded Device Count'): This enumeration value indicates the number of buffers discarded by the device since last fired instance of this event (the producer would get to know about this for example by observing a gap in the block_id sequence). + * - \b BuffersDiscardedProducerCount (Display string: 'Buffers Discarded Producer Count'): This enumeration value indicates the number of buffers discarded by the producer since last fired instance of this event (this would happen e.g. if there are no free buffers available or if given buffer handling mode requires discarding old buffers etc.). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventSelector; + /// \brief An enumerated integer property. Activate or deactivate the notification to the host application of the occurrence of the selected Event. + /** + * Activate or deactivate the notification to the host application of the occurrence of the selected Event. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The selected Event notification is disabled. + * - \b On (Display string: 'On'): The selected Event notification is enabled. + * - \b Once (Display string: 'Once'): The selected Event notification is enabled for one event then return to Off state. + * - \b GigEVisionEvent (Display string: 'Gig E Vision Event') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventNotification; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* + /// \brief Returns the number of GenTL producers detected in the current system. + /** + * This is also the number of system modules detected thus this value - 1 defines the maximum value that can + * be passed as the \a index parameter into a mvIMPACT::acquire::SystemModule constructor. + * \since 2.32.0 + */ + static int64_type getSystemModuleCount( void ) + { + int64_type systemModuleCount = 0; + HLIST hList = INVALID_ID; + if( DMR_FindList( INVALID_ID, "mvGenTLConsumer", dmltDeviceDriverLib, 0, &hList ) == DMR_NO_ERROR ) + { + if( hList != INVALID_ID ) + { + ComponentLocator locator( hList ); + hList = locator.findComponent( "GenTL", 0, 1 ); + if( hList != INVALID_ID ) + { + locator = ComponentLocator( hList ); + if( locator.findComponent( "System", 0, 1 ) != INVALID_ID ) + { + systemModuleCount++; + } + const HLIST hListProducers = locator.findComponent( "Producers", 0, 1 ); + if( hListProducers != INVALID_ID ) + { + ComponentList producers( hListProducers ); + systemModuleCount += static_cast( producers.size() ); + } + } + } + } + return systemModuleCount; + } + /// \brief Returns the number of interfaces associated with this GenTL producer. + /** + * This should return the same value as when calling mvIMPACT::acquire::GenICam::SystemModule::interfaceSelector::getMaxValue + * however there are producers out there that do not implement the \c interfaceSelector property correctly. + * + * \since 2.34.0 + */ + int64_type getInterfaceModuleCount( void ) + { + int64_type interfaceCount = 0; + ComponentLocator locator( Component( hObj() ).parent() ); + const HLIST hList = locator.findComponent( "Interfaces", smIgnoreMethods | smIgnoreProperties ); + if( hList != INVALID_ID ) + { + Component it( hList ); + it = it.firstChild(); + while( it.isValid() ) + { + ++interfaceCount; + it = it.nextSibling(); + } + } + return interfaceCount; + } +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains items that belong to the interface module of the transport layer. +/** + * The Interface category contains items that belong to the interface module of the transport layer. + * \ingroup GenICamInterfaceProducer + */ +class InterfaceModule : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +private: + void init( mvIMPACT::acquire::ComponentLocator& locator ) + { + locator.bindComponent( interfaceID, "InterfaceID" ); + locator.bindComponent( interfaceDisplayName, "InterfaceDisplayName" ); + locator.bindComponent( interfaceType, "InterfaceType" ); + locator.bindComponent( interfaceTLVersionMajor, "InterfaceTLVersionMajor" ); + locator.bindComponent( interfaceTLVersionMinor, "InterfaceTLVersionMinor" ); + locator.bindComponent( gevInterfaceGatewaySelector, "GevInterfaceGatewaySelector" ); + locator.bindComponent( gevInterfaceGateway, "GevInterfaceGateway" ); + locator.bindComponent( gevInterfaceMACAddress, "GevInterfaceMACAddress" ); + locator.bindComponent( gevInterfaceSubnetSelector, "GevInterfaceSubnetSelector" ); + locator.bindComponent( gevInterfaceSubnetIPAddress, "GevInterfaceSubnetIPAddress" ); + locator.bindComponent( gevInterfaceSubnetMask, "GevInterfaceSubnetMask" ); + locator.bindComponent( mvGevInterfaceMTU, "mvGevInterfaceMTU" ); + locator.bindComponent( mvGevInterfaceLinkSpeed, "mvGevInterfaceLinkSpeed" ); + locator.bindComponent( mvGevAdvancedDeviceDiscoveryEnable, "mvGevAdvancedDeviceDiscoveryEnable" ); + locator.bindComponent( deviceUpdateList, "DeviceUpdateList@i" ); + locator.bindComponent( mvUnicastDeviceDiscoveryCommandCount, "mvUnicastDeviceDiscoveryCommandCount" ); + locator.bindComponent( mvUnicastDeviceDiscoveryCommandSelector, "mvUnicastDeviceDiscoveryCommandSelector" ); + locator.bindComponent( mvUnicastDeviceDiscoveryDestinationIPAddress, "mvUnicastDeviceDiscoveryDestinationIPAddress" ); + locator.bindComponent( deviceUpdateTimeout, "DeviceUpdateTimeout" ); + locator.bindComponent( deviceSelector, "DeviceSelector" ); + locator.bindComponent( deviceID, "DeviceID" ); + locator.bindComponent( deviceVendorName, "DeviceVendorName" ); + locator.bindComponent( deviceModelName, "DeviceModelName" ); + locator.bindComponent( deviceType, "DeviceType" ); + locator.bindComponent( deviceLinkSpeed, "DeviceLinkSpeed" ); + locator.bindComponent( deviceAccessStatus, "DeviceAccessStatus" ); + locator.bindComponent( deviceSerialNumber, "DeviceSerialNumber" ); + locator.bindComponent( deviceUserID, "DeviceUserID" ); + locator.bindComponent( deviceTLVersionMajor, "DeviceTLVersionMajor" ); + locator.bindComponent( deviceTLVersionMinor, "DeviceTLVersionMinor" ); + locator.bindComponent( gevDeviceIPAddress, "GevDeviceIPAddress" ); + locator.bindComponent( gevDeviceSubnetMask, "GevDeviceSubnetMask" ); + locator.bindComponent( gevDeviceGateway, "GevDeviceGateway" ); + locator.bindComponent( gevDeviceIPConfigurationStatus, "GevDeviceIPConfigurationStatus" ); + locator.bindComponent( gevDeviceMACAddress, "GevDeviceMACAddress" ); + locator.bindComponent( gevCurrentControlMode, "GevCurrentControlMode" ); + locator.bindComponent( mvDeviceCommandChannelTransmissionTimeout, "mvDeviceCommandChannelTransmissionTimeout" ); + locator.bindComponent( mvDeviceCommandChannelRetryCount, "mvDeviceCommandChannelRetryCount" ); + locator.bindComponent( gevVersionMajor, "GevVersionMajor" ); + locator.bindComponent( gevVersionMinor, "GevVersionMinor" ); + locator.bindComponent( genCPVersionMajor, "GenCPVersionMajor" ); + locator.bindComponent( genCPVersionMinor, "GenCPVersionMinor" ); + locator.bindComponent( u3vVersionMajor, "U3vVersionMajor" ); + locator.bindComponent( u3vVersionMinor, "U3vVersionMinor" ); + locator.bindComponent( mvDevicePrimaryApplicationSwitchoverSupported, "mvDevicePrimaryApplicationSwitchoverSupported" ); + locator.bindComponent( mvDevicePrimaryApplicationSwitchoverEnable, "mvDevicePrimaryApplicationSwitchoverEnable" ); + locator.bindComponent( gevApplicationSwitchoverKey, "GevApplicationSwitchoverKey" ); + if( !gevApplicationSwitchoverKey.isValid() ) + { + locator.bindComponent( gevApplicationSwitchoverKey, "mvDevicePrimaryApplicationSwitchoverKey" ); + } + locator.bindComponent( mvDeviceNetworkInterfaceCount, "mvDeviceNetworkInterfaceCount" ); + locator.bindComponent( gevDeviceForceIP, "GevDeviceForceIP@i" ); + locator.bindComponent( gevDeviceForceIPAddress, "GevDeviceForceIPAddress" ); + locator.bindComponent( gevDeviceForceSubnetMask, "GevDeviceForceSubnetMask" ); + locator.bindComponent( gevDeviceForceGateway, "GevDeviceForceGateway" ); + locator.bindComponent( mvDeviceUpdateFirmware, "mvDeviceUpdateFirmware@i" ); + locator.bindComponent( actionCommand, "ActionCommand@i" ); + if( !actionCommand.isValid() ) + { + locator.bindComponent( actionCommand, "mvActionSend@i" ); + } + locator.bindComponent( actionDeviceKey, "ActionDeviceKey" ); + if( !actionDeviceKey.isValid() ) + { + locator.bindComponent( actionDeviceKey, "mvActionDeviceKey" ); + } + locator.bindComponent( actionGroupKey, "ActionGroupKey" ); + if( !actionGroupKey.isValid() ) + { + locator.bindComponent( actionGroupKey, "mvActionGroupKey" ); + } + locator.bindComponent( actionGroupMask, "ActionGroupMask" ); + if( !actionGroupMask.isValid() ) + { + locator.bindComponent( actionGroupMask, "mvActionGroupMask" ); + } + locator.bindComponent( actionScheduledTimeEnable, "ActionScheduledTimeEnable" ); + if( !actionScheduledTimeEnable.isValid() ) + { + locator.bindComponent( actionScheduledTimeEnable, "mvActionScheduledTimeEnable" ); + } + locator.bindComponent( actionScheduledTime, "ActionScheduledTime" ); + if( !actionScheduledTime.isValid() ) + { + locator.bindComponent( actionScheduledTime, "mvActionScheduledTime" ); + } + locator.bindComponent( gevActionDestinationIPAddress, "GevActionDestinationIPAddress" ); + if( !gevActionDestinationIPAddress.isValid() ) + { + locator.bindComponent( gevActionDestinationIPAddress, "mvActionDestinationIPAddress" ); + } + locator.bindComponent( eventSelector, "EventSelector" ); + locator.bindComponent( eventNotification, "EventNotification" ); + } +public: +#ifndef WRAP_ANY + /// \brief Constructs a new mvIMPACT::acquire::GenICam::InterfaceModule object(\b deprecated). + /** + * \deprecated This constructor has been declared deprecated as it doesn't allow to access features from 3rd party GenTL producers. Use a constructor that allows the selection of the desired GenTL producer instead. + * \since 2.17.0 + */ + explicit MVIMPACT_DEPRECATED_CPP( InterfaceModule( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The \a index of the instance this object shall be created for. Passing an invalid index will raise an exception. + int64_type index ) ); +#endif // #ifndef WRAP_ANY +#ifndef WRAP_ANY + /// \brief Constructs a new mvIMPACT::acquire::GenICam::InterfaceModule object(\b deprecated). + /** + * \deprecated This constructor has been declared deprecated as it doesn't allow to access features from 3rd party GenTL producers. Use a constructor that allows the selection of the desired GenTL producer instead. + * \since 2.17.0 + */ + explicit MVIMPACT_DEPRECATED_CPP( InterfaceModule( + /// [in] The \a index of the instance this object shall be created for. Passing an invalid index will raise an exception. + int64_type index ) ); +#endif // #ifndef WRAP_ANY + /// \brief Constructs a new mvIMPACT::acquire::GenICam::InterfaceModule object. + /** + * \since 2.32.0 + */ + explicit InterfaceModule( + /// [in] The mvIMPACT::acquire::GenICam::SystemModule instance providing access to the interface module to be created. + const SystemModule& parent, + /// [in] The \a index of the instance this object shall be created for. Passing an invalid index will raise an exception. + int64_type index ) : + mvIMPACT::acquire::ComponentCollection( INVALID_ID ), + interfaceID(), + interfaceDisplayName(), + interfaceType(), + interfaceTLVersionMajor(), + interfaceTLVersionMinor(), + gevInterfaceGatewaySelector(), + gevInterfaceGateway(), + gevInterfaceMACAddress(), + gevInterfaceSubnetSelector(), + gevInterfaceSubnetIPAddress(), + gevInterfaceSubnetMask(), + mvGevInterfaceMTU(), + mvGevInterfaceLinkSpeed(), + mvGevAdvancedDeviceDiscoveryEnable(), + deviceUpdateList(), + mvUnicastDeviceDiscoveryCommandCount(), + mvUnicastDeviceDiscoveryCommandSelector(), + mvUnicastDeviceDiscoveryDestinationIPAddress(), + deviceUpdateTimeout(), + deviceSelector(), + deviceID(), + deviceVendorName(), + deviceModelName(), + deviceType(), + deviceLinkSpeed(), + deviceAccessStatus(), + deviceSerialNumber(), + deviceUserID(), + deviceTLVersionMajor(), + deviceTLVersionMinor(), + gevDeviceIPAddress(), + gevDeviceSubnetMask(), + gevDeviceGateway(), + gevDeviceIPConfigurationStatus(), + gevDeviceMACAddress(), + gevCurrentControlMode(), + mvDeviceCommandChannelTransmissionTimeout(), + mvDeviceCommandChannelRetryCount(), + gevVersionMajor(), + gevVersionMinor(), + genCPVersionMajor(), + genCPVersionMinor(), + u3vVersionMajor(), + u3vVersionMinor(), + mvDevicePrimaryApplicationSwitchoverSupported(), + mvDevicePrimaryApplicationSwitchoverEnable(), + gevApplicationSwitchoverKey(), + mvDeviceNetworkInterfaceCount(), + gevDeviceForceIP(), + gevDeviceForceIPAddress(), + gevDeviceForceSubnetMask(), + gevDeviceForceGateway(), + mvDeviceUpdateFirmware(), + actionCommand(), + actionDeviceKey(), + actionGroupKey(), + actionGroupMask(), + actionScheduledTimeEnable(), + actionScheduledTime(), + gevActionDestinationIPAddress(), + eventSelector(), + eventNotification() + { + ComponentList baseList( parent.hObj() ); + mvIMPACT::acquire::ComponentLocator locator( baseList.parent(), "Interfaces" ); + std::ostringstream oss; + oss << "Interface" << index; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + m_hRoot = locator.searchbase_id(); + init( locator ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property. GenTL producer wide unique identifier of the selected interface. + /** + * This is a read only element. It is a string that indicates a GenTL producer wide unique identifier of the selected interface. + */ + PropertyS interfaceID; + /// \brief A string property. A user-friendly name of the Interface. + /** + * This is a read only element. It is a string that indicates a user-friendly name of the Interface. + */ + PropertyS interfaceDisplayName; + /// \brief An enumerated integer property. Identifies the interfaces technology of the GenTL Producer implementation. + /** + * This is a read only feature. This enumeration provides a value that indicates interfaces technology of the GenTL Producer implementation. + * + * The following string values might be valid for this feature: + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is an interface for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is an interface for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is an interface for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is an interface for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is an interface for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is an interface for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is an interface for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 interfaceType; + /// \brief An integer property. Indicates the major version number of the transport layer specification the GenTL Producer complies with. + /** + * This is a read only element. It indicates the major version number of the transport layer specification the GenTL Producer complies with. + */ + PropertyI64 interfaceTLVersionMajor; + /// \brief An integer property. Indicates the minor version number of the transport layer specification the GenTL Producer complies with. + /** + * This is a read only element. It indicates the minor version number of the transport layer specification the GenTL Producer complies with. + */ + PropertyI64 interfaceTLVersionMinor; + /// \brief An integer property. Selector for the different gateway entries for this interface. + /** + * Selector for the different gateway entries for this interface. The selector is 0-based in order to match the index of the C interface. + */ + PropertyI64 gevInterfaceGatewaySelector; + /// \brief An integer property. Indicates the IP address of the selected gateway entry of this interface. + /** + * This is a read only element. It indicates the IP address of the selected gateway entry of this interface. + */ + PropertyI64 gevInterfaceGateway; + /// \brief An integer property. Indicates the 48-bit MAC address of the selected interface. + /** + * This is a read only element. It indicates the 48-bit MAC address of the selected interface. + */ + PropertyI64 gevInterfaceMACAddress; + /// \brief An integer property. Selector for the different subnet entries for this interface. + /** + * Selector for the different subnet entries for this interface. The selector is 0-based in order to match the index of the C interface. + */ + PropertyI64 gevInterfaceSubnetSelector; + /// \brief An integer property. Indicates the IP address of the selected subnet entry of this interface. + /** + * This is a read only element. It indicates the IP address of the selected subnet entry of this interface. + */ + PropertyI64 gevInterfaceSubnetIPAddress; + /// \brief An integer property. Indicates the subnet mask of the selected subnet entry of this interface. + /** + * This is a read only element. It indicates the subnet mask of the selected subnet entry of this interface. + */ + PropertyI64 gevInterfaceSubnetMask; + /// \brief An integer property. Indicates the MTU of this interface. + /** + * This is a read only element. It indicates the MTU(Maximum Transmission Unit) of this interface. + */ + PropertyI64 mvGevInterfaceMTU; + /// \brief An integer property. Indicates the link speed of this interface. + /** + * This is a read only element. It indicates the link speed(in Mbits per second) of this interface. + */ + PropertyI64 mvGevInterfaceLinkSpeed; + /// \brief A boolean property. Enables or disables the advanced device discovery. + /** + * Enables or disables the advanced device discovery. When enabled also devices, which currently use an incorrect IP configuration for the network they are connected to might be detectable. However depending on the operating system this may result in devices showing up on interfaces to which they are not physically connected. + */ + PropertyIBoolean mvGevAdvancedDeviceDiscoveryEnable; + /// \brief A method object. Updates the internal device list of this interface. + /** + * This command updates the internal device list of this interface. + */ + Method deviceUpdateList; + /// \brief An integer property. Specifies the number of discovery commands which will be sent to destinations defined by 'mvUnicastDeviceDiscoveryCommandSelector' and 'mvUnicastDeviceDiscoveryDestinationIPAddress'. + /** + * Specifies the number of discovery commands which will be sent to destinations defined by 'mvUnicastDeviceDiscoveryCommandSelector' and 'mvUnicastDeviceDiscoveryDestinationIPAddress'. No unicast device discovery will be performed once set to '0'. The mvUnicastDeviceDiscoveryCommandCount specifies the maximum value of the mvUnicastDeviceDiscoveryCommandSelector property. + */ + PropertyI64 mvUnicastDeviceDiscoveryCommandCount; + /// \brief An integer property. Selects unicast discovery command to configure. + /** + * Selects unicast discovery command to configure. + */ + PropertyI64 mvUnicastDeviceDiscoveryCommandSelector; + /// \brief An integer property. Controls the destination IP address of the selected unicast device discovery command. + /** + * Controls the destination IP address of the selected unicast device discovery command. + */ + PropertyI64 mvUnicastDeviceDiscoveryDestinationIPAddress; + /// \brief An integer property. Specifies timeout for the DeviceUpdateList Command. + /** + * Specifies timeout for the DeviceUpdateList Command. + */ + PropertyI64 deviceUpdateTimeout; + /// \brief An integer property. Selector for the different devices on this interface. + /** + * Selector for the different devices on this interface. The limits of this feature might change upon execution of DeviceUpdateList. + */ + PropertyI64 deviceSelector; + /// \brief A string property. This feature is deprecated (See DeviceSerialNumber). + /** + * \deprecated + * This feature is deprecated (See DeviceSerialNumber). It was representing the Device unique identifier (serial number). + */ + PropertyS deviceID; + /// \brief A string property. Name of the manufacturer of the device. + /** + * Name of the manufacturer of the device. + */ + PropertyS deviceVendorName; + /// \brief A string property. Model of the device. + /** + * Model of the device. + */ + PropertyS deviceModelName; + /// \brief An enumerated integer property. Returns the device type. + /** + * Returns the device type. + * + * The following string values might be valid for this feature: + * - \b Transmitter (Display string: 'Transmitter'): Data stream transmitter device. + * - \b Receiver (Display string: 'Receiver'): Data stream receiver device. + * - \b Transceiver (Display string: 'Transceiver'): Data stream receiver and transmitter device. + * - \b Peripheral (Display string: 'Peripheral'): Controllable device (with no data stream handling). + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is a device for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is a device for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is a device for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is a device for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is a device for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is a device for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is a device for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceType; + /// \brief An integer property. Indicates the speed of transmission negotiated on the specified Link. + /** + * Indicates the speed of transmission negotiated on the specified Link. + */ + PropertyI64 deviceLinkSpeed; + /// \brief An enumerated integer property. Indicates the current access status for the device. + /** + * This is a read only feature. This enumeration gives the device's access status at the moment of the last execution of the DeviceUpdateList command. This value only changes on execution of the DeviceUpdateList command. + * + * The following string values might be valid for this feature: + * - \b Unknown (Display string: 'Unknown'): This enumeration value indicates that the device accessibility is not known. + * - \b ReadWrite (Display string: 'Read/Write'): This enumeration value indicates that full access to the device is available. + * - \b ReadOnly (Display string: 'Read Only'): This enumeration value indicates that read access to the device is available. + * - \b NoAccess (Display string: 'No Access'): This enumeration value indicates that no access to the device is available. + * - \b Busy (Display string: 'Busy'): This enumeration value indicates that the device is already opened by another entity. + * - \b OpenReadWrite (Display string: 'Open Read Write'): This enumeration value indicates that the device is open in Read/Write mode by this GenTL host. + * - \b OpenReadOnly (Display string: 'Open Read Only'): This enumeration value indicates that the device is open in Read only mode by this GenTL host. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceAccessStatus; + /// \brief A string property. Device's serial number. + /** + * Device's serial number. This string is a unique identifier of the device. + */ + PropertyS deviceSerialNumber; + /// \brief A string property. User-programmable device identifier. + /** + * User-programmable device identifier. + */ + PropertyS deviceUserID; + /// \brief An integer property. Major version of the Transport Layer of the device. + /** + * Major version of the Transport Layer of the device. + */ + PropertyI64 deviceTLVersionMajor; + /// \brief An integer property. Minor version of the Transport Layer of the device. + /** + * Minor version of the Transport Layer of the device. + */ + PropertyI64 deviceTLVersionMinor; + /// \brief An integer property. Indicates the current IP address of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the current IP address of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceIPAddress; + /// \brief An integer property. Indicates the current subnet mask of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the current subnet mask of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceSubnetMask; + /// \brief An integer property. Indicates the current gateway of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the current gateway of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceGateway; + /// \brief An enumerated integer property. Identifies the IP configuration of the GVCP interface of the selected remote device. + /** + * This is a read only feature. This enumeration provides a value that indicates the Device IP configuration of the GVCP interface of the selected remote device. This value only changes on execution of the DeviceUpdateList command. + * + * The following string values might be valid for this feature: + * - \b DHCP (Display string: 'DHCP') + * - \b PersistentIP (Display string: 'Persistent IP') + * - \b LinkLocal (Display string: 'Link Local') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevDeviceIPConfigurationStatus; + /// \brief An integer property. Indicates the 48-bit MAC address of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the 48-bit MAC address of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceMACAddress; + /// \brief An enumerated integer property. The current control mode of the device. + /** + * This enumeration provides a value that indicates the current control mode of the device. + * + * The following string values might be valid for this feature: + * - \b Open (Display string: 'Open'): This enumeration value indicates that the device is open for control or exclusive access. + * - \b ControlAccess (Display string: 'Control Access'): This enumeration value indicates that the device is controlled by another host, but switchover or read-only access is possible. + * - \b ExclusiveAccess (Display string: 'Exclusive Access'): This enumeration value indicates that the device is under exclusive access by a host and cannot be accessed by another. + * - \b NoAccess (Display string: 'No Access'): This enumeration value indicates that the device cannot be accessed, for instance it may be a GigE Vision device on a subnet different from the interface. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 gevCurrentControlMode; + /// \brief An integer property. Defines the maximum time in milli-seconds the host driver will wait for an ACK from the device to a previously sent command(deprecated). + /** + * \deprecated + * Defines the maximum time in milli-seconds the host driver will wait for an ACK from the device to a previously sent command. This feature has been declared deprecated. Use 'LinkCommandTimeout' of the DeviceModule instead. + */ + PropertyI64 mvDeviceCommandChannelTransmissionTimeout; + /// \brief An integer property. Indicates the number of retransmissions allowed when command channel message timed out (no ACK was received from the device)(deprecated). + /** + * \deprecated + * Indicates the number of retransmissions allowed when command channel message timed out (no ACK was received from the device). This feature has been declared deprecated. Use 'LinkCommandRetryCount' of the DeviceModule instead. + */ + PropertyI64 mvDeviceCommandChannelRetryCount; + /// \brief An integer property. Indicates the major version number of the GigE Vision specification this device complies with. + /** + * This is a read only element. It indicates the major version number of the GigE Vision specification this device complies with. + */ + PropertyI64 gevVersionMajor; + /// \brief An integer property. Indicates the minor version number of the GigE Vision specification this device complies with. + /** + * This is a read only element. It indicates the minor version number of the GigE Vision specification this device complies with. + */ + PropertyI64 gevVersionMinor; + /// \brief An integer property. Indicates the major version number of the GenCP specification this device complies with. + /** + * This is a read only element. It indicates the major version number of the GenCP specification this device complies with. + */ + PropertyI64 genCPVersionMajor; + /// \brief An integer property. Indicates the minor version number of the GenCP specification this device complies with. + /** + * This is a read only element. It indicates the minor version number of the GenCP specification this device complies with. + */ + PropertyI64 genCPVersionMinor; + /// \brief An integer property. Indicates the major version number of the USB3 Vision specification this device complies with. + /** + * This is a read only element. It indicates the major version number of the USB3 Vision specification this device complies with. + */ + PropertyI64 u3vVersionMajor; + /// \brief An integer property. Indicates the minor version number of the USB3 Vision specification this device complies with. + /** + * This is a read only element. It indicates the minor version number of the USB3 Vision specification this device complies with. + */ + PropertyI64 u3vVersionMinor; + /// \brief A boolean property. Reports the availability of the primary application switchover feature. + /** + * Reports the availability of the primary application switchover feature. + */ + PropertyIBoolean mvDevicePrimaryApplicationSwitchoverSupported; + /// \brief A boolean property. Enables or disables primary application switchover. + /** + * Enables or disables primary application switchover. + */ + PropertyIBoolean mvDevicePrimaryApplicationSwitchoverEnable; + /// \brief An integer property. Controls the key to use to authenticate primary application switchover requests. + /** + * Controls the key to use to authenticate primary application switchover requests. If the device to take over has 'mvDevicePrimaryApplicationSwitchoverEnable' set to true and this key matches the devices internal key control access will be granted. + */ + PropertyI64 gevApplicationSwitchoverKey; + /// \brief An integer property. The number of physical network interfaces supported by this device. + /** + * This is an integer feature. It contains the number of physical network interfaces supported by this device. + */ + PropertyI64 mvDeviceNetworkInterfaceCount; + /// \brief A method object. Apply the force IP settings (GevDeviceForceIPAddress, GevDeviceForceSubnetMask and GevDeviceForceGateway) in the Device using ForceIP command. + /** + * Apply the force IP settings (GevDeviceForceIPAddress, GevDeviceForceSubnetMask and GevDeviceForceGateway) in the Device using ForceIP command. + */ + Method gevDeviceForceIP; + /// \brief An integer property. Static IP address to set for the GVCP interface of the selected remote device. + /** + * Static IP address to set for the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceForceIPAddress; + /// \brief An integer property. Static subnet mask to set for the GVCP interface of the selected remote device. + /** + * Static subnet mask to set for the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceForceSubnetMask; + /// \brief An integer property. Static gateway IP address to set for the GVCP interface of the selected remote device. + /** + * Static gateway IP address to set for the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceForceGateway; + /// \brief A method object. Updates the device's firmware. + /** + * Updates the device using the firmware images embedded into this producer library. + */ + Method mvDeviceUpdateFirmware; + /// \brief A method object. Sends the action command + /** + * It either sends an action command unicast packet to the IP address specified by the 'mvActionDestinationIPAddress' property, or broadcasts an action command broadcast packet on the broadcast domain specified by the 'mvActionDestinationIPAddress' property + */ + Method actionCommand; + /// \brief An integer property. The device key for the action command + /** + * The device key is one of the three main components that constitute an action command packet. It partly defines which device(s) will positively assert the action command packet. + */ + PropertyI64 actionDeviceKey; + /// \brief An integer property. The group key for the action command + /** + * The group key is one of the three main components that constitute an action command packet. It partly defines which device(s) will positively assert the action command packet. + */ + PropertyI64 actionGroupKey; + /// \brief An integer property. The group mask for the action command + /** + * The group mask is one of the three main components that constitute an action command packet. It partly defines which device(s) will positively assert the action command packet. + */ + PropertyI64 actionGroupMask; + /// \brief A boolean property. Enables or disables action command scheduling + /** + * Action commands can be scheduled to execute at a particular moment in time, defined by the 'mvActionScheduledTime' property. If this is disabled the action command takes place immediately after it is received and asserted by each device. + */ + PropertyIBoolean actionScheduledTimeEnable; + /// \brief An integer property. Sets the time in which the action command will be executed + /** + * Sets the time in which the action command will be executed + */ + PropertyI64 actionScheduledTime; + /// \brief An integer property. The IP address of the action command recipient + /** + * A valid IP address if the action command shall be unicast. A broadcast subnet if the action command shall be broadcast. + */ + PropertyI64 gevActionDestinationIPAddress; + /// \brief An enumerated integer property. Selects which Event to signal to the host application. + /** + * Selects which Event to signal to the host application. + * + * The following string values might be valid for this feature: + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device just received a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device just missed a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Device just started the Acquisition of one or many Frames. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Device just completed the Acquisition of one or many Frames. + * - \b AcquisitionTransferStart (Display string: 'Acquisition Transfer Start'): Device just started the transfer of one or many Frames. + * - \b AcquisitionTransferEnd (Display string: 'Acquisition Transfer End'): Device just completed the transfer of one or many Frames. + * - \b AcquisitionError (Display string: 'Acquisition Error'): Device just detected an error during the active Acquisition. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Device just started the capture of a burst of Frames. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Device just completed the capture of a burst of Frames. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device just received a trigger to start the capture of one Frame. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device just missed a trigger to start the capture of one Frame. + * - \b FrameStart (Display string: 'Frame Start'): Device just started the capture of one Frame. + * - \b FrameEnd (Display string: 'Frame End'): Device just completed the capture of one Frame. + * - \b FrameTransferStart (Display string: 'Frame Transfer Start'): Device just started the transfer of one Frame. + * - \b FrameTransferEnd (Display string: 'Frame Transfer End'): Device just completed the transfer of one Frame. + * - \b LineTrigger (Display string: 'Line Trigger'): Device just received a trigger to start the capture of one Line. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device just missed a trigger to start the capture of one Line. + * - \b LineStart (Display string: 'Line Start'): Device just started the capture of one Line. + * - \b LineEnd (Display string: 'Line End'): Device just completed the capture of one Line. + * - \b ExposureStart (Display string: 'Exposure Start'): Device just started the exposure of one Frame (or Line). + * - \b ExposureEnd (Display string: 'Exposure End'): Device just completed the exposure of one Frame (or Line). + * - \b Stream0TransferStart (Display string: 'Stream 0 Transfer Start'): Device just started the transfer of one or many Blocks. + * - \b Stream0TransferEnd (Display string: 'Stream 0 Transfer End'): Device just completed the transfer of one or many Blocks. + * - \b Stream0TransferPause (Display string: 'Stream 0 Transfer Pause'): Device just paused the transfer. + * - \b Stream0TransferResume (Display string: 'Stream 0 Transfer Resume'): Device just resumed the transfer. + * - \b Stream0TransferBlockStart (Display string: 'Stream 0 Transfer Block Start'): Device just started the transfer of one Block. + * - \b Stream0TransferBlockEnd (Display string: 'Stream 0 Transfer Block End'): Device just completed the transfer of one Block. + * - \b Stream0TransferBlockTrigger (Display string: 'Stream 0 Transfer Block Trigger'): Device just received a trigger to start the transfer of one Block. + * - \b Stream0TransferBurstStart (Display string: 'Stream 0 Transfer Burst Start'): Device just started the transfer of a burst of Blocks. + * - \b Stream0TransferBurstEnd (Display string: 'Stream 0 Transfer Burst End'): Device just completed the transfer of a burst of Blocks. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Device transfer queue overflowed. + * - \b SequencerSetChange (Display string: 'Sequencer Set Change'): Device sequencer set has changed. + * - \b Counter0Start (Display string: 'Counter 0 Start'): The event will be generated when counter 0 starts counting. + * - \b Counter1Start (Display string: 'Counter 1 Start'): The event will be generated when counter 1 starts counting. + * - \b Counter\#2\#Start (Display string: 'Counter \#2\# Start'): The event will be generated when counter \#2\# starts counting. + * - \b Counter0End (Display string: 'Counter 0 End'): The event will be generated when counter 0 ends counting. + * - \b Counter1End (Display string: 'Counter 1 End'): The event will be generated when counter 1 ends counting. + * - \b Counter\#2\#End (Display string: 'Counter \#2\# End'): The event will be generated when counter \#2\# ends counting. + * - \b Timer0Start (Display string: 'Timer 0 Start'): The event will be generated when Timer 0 starts counting. + * - \b Timer1Start (Display string: 'Timer 1 Start'): The event will be generated when Timer 1 starts counting. + * - \b Timer\#2\#Start (Display string: 'Timer \#2\# Start'): The event will be generated when Timer \#2\# starts counting. + * - \b Timer0End (Display string: 'Timer 0 End'): The event will be generated when Timer 0 ends counting. + * - \b Timer1End (Display string: 'Timer 1 End'): The event will be generated when Timer 1 ends counting. + * - \b Timer\#2\#End (Display string: 'Timer \#2\# End'): The event will be generated when Timer \#2\# ends counting. + * - \b Encoder0Stopped (Display string: 'Encoder 0 Stopped'): The event will be generated when the Encoder 0 stops for longer than EncoderTimeout. + * - \b Encoder1Stopped (Display string: 'Encoder 1 Stopped'): The event will be generated when the Encoder 1 stops for longer than EncoderTimeout. + * - \b Encoder\#2\#Stopped (Display string: 'Encoder \#2\# Stopped'): The event will be generated when the Encoder \#2\# stops for longer than EncoderTimeout. + * - \b Encoder0Restarted (Display string: 'Encoder 0 Restarted'): The event will be generated when the Encoder 0 restarts moving. + * - \b Encoder1Restarted (Display string: 'Encoder 1 Restarted'): The event will be generated when the Encoder 1 restarts moving. + * - \b Encoder\#2\#Restarted (Display string: 'Encoder \#2\# Restarted'): The event will be generated when the Encoder \#2\# restarts moving. + * - \b Line0RisingEdge (Display string: 'Line 0 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 0. + * - \b Line1RisingEdge (Display string: 'Line 1 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 1. + * - \b Line\#2\#RisingEdge (Display string: 'Line \#2\# Rising Edge'): The event will be generated when a Rising Edge is detected on the Line \#2\#. + * - \b Line0FallingEdge (Display string: 'Line 0 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 0. + * - \b Line1FallingEdge (Display string: 'Line 1 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 1. + * - \b Line\#2\#FallingEdge (Display string: 'Line \#2\# Falling Edge'): The event will be generated when a Falling Edge is detected on the Line \#2\#. + * - \b Line0AnyEdge (Display string: 'Line 0 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 0. + * - \b Line1AnyEdge (Display string: 'Line 1 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 1. + * - \b Line\#2\#AnyEdge (Display string: 'Line \#2\# Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line \#2\#. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): The event will be generated when a Rising Edge is detected on the LinkTrigger 0. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): The event will be generated when a Rising Edge is detected on the LinkTrigger 1. + * - \b LinkTrigger\#2\# (Display string: 'Link Trigger \#2\#'): The event will be generated when a Rising Edge is detected on the LinkTrigger \#2\#. + * - \b LinkSpeedChange (Display string: 'Link Speed Change'): The event will be generated when the link speed has changed. + * - \b ActionLate (Display string: 'Action Late'): The event will be generated when a valid scheduled action command is received and is scheduled to be executed at a time that is already past. + * - \b Error (Display string: 'Error'): Device just detected an error during the active Acquisition. + * - \b Test (Display string: 'Test'): The test event will be generated when the device receives the TestEventGenerate command (EventNotification for the Test event is always On). + * - \b PrimaryApplicationSwitch (Display string: 'Primary Application Switch'): The event will be generated when a primary application switchover has been granted (GigE Vision Specific). + * - \b Counter2Start (Display string: 'Counter 2 Start'): The event will be generated when counter 2 starts counting. + * - \b Counter3Start (Display string: 'Counter 3 Start'): The event will be generated when counter 3 starts counting. + * - \b Counter4Start (Display string: 'Counter 4 Start'): The event will be generated when counter 4 starts counting. + * - \b Counter5Start (Display string: 'Counter 5 Start'): The event will be generated when counter 5 starts counting. + * - \b Counter6Start (Display string: 'Counter 6 Start'): The event will be generated when counter 6 starts counting. + * - \b Counter7Start (Display string: 'Counter 7 Start'): The event will be generated when counter 7 starts counting. + * - \b Counter8Start (Display string: 'Counter 8 Start'): The event will be generated when counter 8 starts counting. + * - \b Counter9Start (Display string: 'Counter 9 Start'): The event will be generated when counter 9 starts counting. + * - \b Counter10Start (Display string: 'Counter 10 Start'): The event will be generated when counter 10 starts counting. + * - \b Counter11Start (Display string: 'Counter 11 Start'): The event will be generated when counter 11 starts counting. + * - \b Counter12Start (Display string: 'Counter 12 Start'): The event will be generated when counter 12 starts counting. + * - \b Counter13Start (Display string: 'Counter 13 Start'): The event will be generated when counter 13 starts counting. + * - \b Counter14Start (Display string: 'Counter 14 Start'): The event will be generated when counter 14 starts counting. + * - \b Counter15Start (Display string: 'Counter 15 Start'): The event will be generated when counter 15 starts counting. + * - \b Counter2End (Display string: 'Counter 2 End'): The event will be generated when counter 2 ends counting. + * - \b Counter3End (Display string: 'Counter 3 End'): The event will be generated when counter 3 ends counting. + * - \b Counter4End (Display string: 'Counter 4 End'): The event will be generated when counter 4 ends counting. + * - \b Counter5End (Display string: 'Counter 5 End'): The event will be generated when counter 5 ends counting. + * - \b Counter6End (Display string: 'Counter 6 End'): The event will be generated when counter 6 ends counting. + * - \b Counter7End (Display string: 'Counter 7 End'): The event will be generated when counter 7 ends counting. + * - \b Counter8End (Display string: 'Counter 8 End'): The event will be generated when counter 8 ends counting. + * - \b Counter9End (Display string: 'Counter 9 End'): The event will be generated when counter 9 ends counting. + * - \b Counter10End (Display string: 'Counter 10 End'): The event will be generated when counter 10 ends counting. + * - \b Counter11End (Display string: 'Counter 11 End'): The event will be generated when counter 11 ends counting. + * - \b Counter12End (Display string: 'Counter 12 End'): The event will be generated when counter 12 ends counting. + * - \b Counter13End (Display string: 'Counter 13 End'): The event will be generated when counter 13 ends counting. + * - \b Counter14End (Display string: 'Counter 14 End'): The event will be generated when counter 14 ends counting. + * - \b Counter15End (Display string: 'Counter 15 End'): The event will be generated when counter 15 ends counting. + * - \b Timer2Start (Display string: 'Timer 2 Start'): The event will be generated when Timer 2 starts counting. + * - \b Timer3Start (Display string: 'Timer 3 Start'): The event will be generated when Timer 3 starts counting. + * - \b Timer4Start (Display string: 'Timer 4 Start'): The event will be generated when Timer 4 starts counting. + * - \b Timer5Start (Display string: 'Timer 5 Start'): The event will be generated when Timer 5 starts counting. + * - \b Timer6Start (Display string: 'Timer 6 Start'): The event will be generated when Timer 6 starts counting. + * - \b Timer7Start (Display string: 'Timer 7 Start'): The event will be generated when Timer 7 starts counting. + * - \b Timer8Start (Display string: 'Timer 8 Start'): The event will be generated when Timer 8 starts counting. + * - \b Timer9Start (Display string: 'Timer 9 Start'): The event will be generated when Timer 9 starts counting. + * - \b Timer10Start (Display string: 'Timer 10 Start'): The event will be generated when Timer 10 starts counting. + * - \b Timer11Start (Display string: 'Timer 11 Start'): The event will be generated when Timer 11 starts counting. + * - \b Timer12Start (Display string: 'Timer 12 Start'): The event will be generated when Timer 12 starts counting. + * - \b Timer13Start (Display string: 'Timer 13 Start'): The event will be generated when Timer 13 starts counting. + * - \b Timer14Start (Display string: 'Timer 14 Start'): The event will be generated when Timer 14 starts counting. + * - \b Timer15Start (Display string: 'Timer 15 Start'): The event will be generated when Timer 15 starts counting. + * - \b Timer2End (Display string: 'Timer 2 End'): The event will be generated when Timer 2 ends counting. + * - \b Timer3End (Display string: 'Timer 3 End'): The event will be generated when Timer 3 ends counting. + * - \b Timer4End (Display string: 'Timer 4 End'): The event will be generated when Timer 4 ends counting. + * - \b Timer5End (Display string: 'Timer 5 End'): The event will be generated when Timer 5 ends counting. + * - \b Timer6End (Display string: 'Timer 6 End'): The event will be generated when Timer 6 ends counting. + * - \b Timer7End (Display string: 'Timer 7 End'): The event will be generated when Timer 7 ends counting. + * - \b Timer8End (Display string: 'Timer 8 End'): The event will be generated when Timer 8 ends counting. + * - \b Timer9End (Display string: 'Timer 9 End'): The event will be generated when Timer 9 ends counting. + * - \b Timer10End (Display string: 'Timer 10 End'): The event will be generated when Timer 10 ends counting. + * - \b Timer11End (Display string: 'Timer 11 End'): The event will be generated when Timer 11 ends counting. + * - \b Timer12End (Display string: 'Timer 12 End'): The event will be generated when Timer 12 ends counting. + * - \b Timer13End (Display string: 'Timer 13 End'): The event will be generated when Timer 13 ends counting. + * - \b Timer14End (Display string: 'Timer 14 End'): The event will be generated when Timer 14 ends counting. + * - \b Timer15End (Display string: 'Timer 15 End'): The event will be generated when Timer 15 ends counting. + * - \b Encoder2Stopped (Display string: 'Encoder 2 Stopped'): The event will be generated when the Encoder 2 stops for longer than EncoderTimeout. + * - \b Encoder3Stopped (Display string: 'Encoder 3 Stopped'): The event will be generated when the Encoder 3 stops for longer than EncoderTimeout. + * - \b Encoder4Stopped (Display string: 'Encoder 4 Stopped'): The event will be generated when the Encoder 4 stops for longer than EncoderTimeout. + * - \b Encoder5Stopped (Display string: 'Encoder 5 Stopped'): The event will be generated when the Encoder 5 stops for longer than EncoderTimeout. + * - \b Encoder6Stopped (Display string: 'Encoder 6 Stopped'): The event will be generated when the Encoder 6 stops for longer than EncoderTimeout. + * - \b Encoder7Stopped (Display string: 'Encoder 7 Stopped'): The event will be generated when the Encoder 7 stops for longer than EncoderTimeout. + * - \b Encoder8Stopped (Display string: 'Encoder 8 Stopped'): The event will be generated when the Encoder 8 stops for longer than EncoderTimeout. + * - \b Encoder9Stopped (Display string: 'Encoder 9 Stopped'): The event will be generated when the Encoder 9 stops for longer than EncoderTimeout. + * - \b Encoder10Stopped (Display string: 'Encoder 10 Stopped'): The event will be generated when the Encoder 10 stops for longer than EncoderTimeout. + * - \b Encoder11Stopped (Display string: 'Encoder 11 Stopped'): The event will be generated when the Encoder 11 stops for longer than EncoderTimeout. + * - \b Encoder12Stopped (Display string: 'Encoder 12 Stopped'): The event will be generated when the Encoder 12 stops for longer than EncoderTimeout. + * - \b Encoder13Stopped (Display string: 'Encoder 13 Stopped'): The event will be generated when the Encoder 13 stops for longer than EncoderTimeout. + * - \b Encoder14Stopped (Display string: 'Encoder 14 Stopped'): The event will be generated when the Encoder 14 stops for longer than EncoderTimeout. + * - \b Encoder15Stopped (Display string: 'Encoder 15 Stopped'): The event will be generated when the Encoder 15 stops for longer than EncoderTimeout. + * - \b Encoder2Restarted (Display string: 'Encoder 2 Restarted'): The event will be generated when the Encoder 2 restarts moving. + * - \b Encoder3Restarted (Display string: 'Encoder 3 Restarted'): The event will be generated when the Encoder 3 restarts moving. + * - \b Encoder4Restarted (Display string: 'Encoder 4 Restarted'): The event will be generated when the Encoder 4 restarts moving. + * - \b Encoder5Restarted (Display string: 'Encoder 5 Restarted'): The event will be generated when the Encoder 5 restarts moving. + * - \b Encoder6Restarted (Display string: 'Encoder 6 Restarted'): The event will be generated when the Encoder 6 restarts moving. + * - \b Encoder7Restarted (Display string: 'Encoder 7 Restarted'): The event will be generated when the Encoder 7 restarts moving. + * - \b Encoder8Restarted (Display string: 'Encoder 8 Restarted'): The event will be generated when the Encoder 8 restarts moving. + * - \b Encoder9Restarted (Display string: 'Encoder 9 Restarted'): The event will be generated when the Encoder 9 restarts moving. + * - \b Encoder10Restarted (Display string: 'Encoder 10 Restarted'): The event will be generated when the Encoder 10 restarts moving. + * - \b Encoder11Restarted (Display string: 'Encoder 11 Restarted'): The event will be generated when the Encoder 11 restarts moving. + * - \b Encoder12Restarted (Display string: 'Encoder 12 Restarted'): The event will be generated when the Encoder 12 restarts moving. + * - \b Encoder13Restarted (Display string: 'Encoder 13 Restarted'): The event will be generated when the Encoder 13 restarts moving. + * - \b Encoder14Restarted (Display string: 'Encoder 14 Restarted'): The event will be generated when the Encoder 14 restarts moving. + * - \b Encoder15Restarted (Display string: 'Encoder 15 Restarted'): The event will be generated when the Encoder 15 restarts moving. + * - \b Line2RisingEdge (Display string: 'Line 2 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 2. + * - \b Line3RisingEdge (Display string: 'Line 3 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 3. + * - \b Line4RisingEdge (Display string: 'Line 4 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 4. + * - \b Line5RisingEdge (Display string: 'Line 5 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 5. + * - \b Line6RisingEdge (Display string: 'Line 6 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 6. + * - \b Line7RisingEdge (Display string: 'Line 7 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 7. + * - \b Line8RisingEdge (Display string: 'Line 8 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 8. + * - \b Line9RisingEdge (Display string: 'Line 9 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 9. + * - \b Line10RisingEdge (Display string: 'Line 10 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 10. + * - \b Line11RisingEdge (Display string: 'Line 11 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 11. + * - \b Line12RisingEdge (Display string: 'Line 12 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 12. + * - \b Line13RisingEdge (Display string: 'Line 13 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 13. + * - \b Line14RisingEdge (Display string: 'Line 14 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 14. + * - \b Line15RisingEdge (Display string: 'Line 15 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 15. + * - \b Line2FallingEdge (Display string: 'Line 2 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 2. + * - \b Line3FallingEdge (Display string: 'Line 3 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 3. + * - \b Line4FallingEdge (Display string: 'Line 4 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 4. + * - \b Line5FallingEdge (Display string: 'Line 5 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 5. + * - \b Line6FallingEdge (Display string: 'Line 6 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 6. + * - \b Line7FallingEdge (Display string: 'Line 7 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 7. + * - \b Line8FallingEdge (Display string: 'Line 8 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 8. + * - \b Line9FallingEdge (Display string: 'Line 9 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 9. + * - \b Line10FallingEdge (Display string: 'Line 10 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 10. + * - \b Line11FallingEdge (Display string: 'Line 11 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 11. + * - \b Line12FallingEdge (Display string: 'Line 12 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 12. + * - \b Line13FallingEdge (Display string: 'Line 13 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 13. + * - \b Line14FallingEdge (Display string: 'Line 14 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 14. + * - \b Line15FallingEdge (Display string: 'Line 15 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 15. + * - \b Line2AnyEdge (Display string: 'Line 2 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 2. + * - \b Line3AnyEdge (Display string: 'Line 3 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 3. + * - \b Line4AnyEdge (Display string: 'Line 4 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 4. + * - \b Line5AnyEdge (Display string: 'Line 5 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 5. + * - \b Line6AnyEdge (Display string: 'Line 6 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 6. + * - \b Line7AnyEdge (Display string: 'Line 7 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 7. + * - \b Line8AnyEdge (Display string: 'Line 8 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 8. + * - \b Line9AnyEdge (Display string: 'Line 9 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 9. + * - \b Line10AnyEdge (Display string: 'Line 10 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 10. + * - \b Line11AnyEdge (Display string: 'Line 11 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 11. + * - \b Line12AnyEdge (Display string: 'Line 12 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 12. + * - \b Line13AnyEdge (Display string: 'Line 13 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 13. + * - \b Line14AnyEdge (Display string: 'Line 14 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 14. + * - \b Line15AnyEdge (Display string: 'Line 15 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 15. + * - \b Link0Trigger (Display string: 'Link 0 Trigger') + * - \b Link1Trigger (Display string: 'Link 1 Trigger') + * - \b Link2Trigger (Display string: 'Link 2 Trigger') + * - \b Link3Trigger (Display string: 'Link 3 Trigger') + * - \b Link4Trigger (Display string: 'Link 4 Trigger') + * - \b Link5Trigger (Display string: 'Link 5 Trigger') + * - \b Link6Trigger (Display string: 'Link 6 Trigger') + * - \b Link7Trigger (Display string: 'Link 7 Trigger') + * - \b Link8Trigger (Display string: 'Link 8 Trigger') + * - \b Link9Trigger (Display string: 'Link 9 Trigger') + * - \b Link10Trigger (Display string: 'Link 10 Trigger') + * - \b Link11Trigger (Display string: 'Link 11 Trigger') + * - \b Link12Trigger (Display string: 'Link 12 Trigger') + * - \b Link13Trigger (Display string: 'Link 13 Trigger') + * - \b Link14Trigger (Display string: 'Link 14 Trigger') + * - \b Link15Trigger (Display string: 'Link 15 Trigger') + * - \b InterfaceListChanged (Display string: 'Interface List Changed'): This enumeration value indicates an event that is fired when the list of interfaces has been updated. + * - \b InterfaceLost (Display string: 'Interface Lost'): This enumeration value indicates an event that is raised when the interface connection is lost. + * - \b DeviceListChanged (Display string: 'Device List Changed'): This enumeration value indicates an event that is fired when the list of devices has been updated. + * - \b DeviceLost (Display string: 'Device Lost'): This enumeration value indicates an event that is raised when the local host looses connection to the physical(remote) device. + * - \b BufferTooSmall (Display string: 'Buffer Too Small'): This enumeration value indicates an event that is raised when the buffer was too small to receive the expected amount of data. + * - \b BuffersDiscarded (Display string: 'Buffers Discarded'): This enumeration value indicates an event that is raised when buffers discared by GenTL or device. This event could optionally carry two numeric child data fields EventBuffersDiscardedDeviceCount and EventBuffersDiscardedProducerCount. + * - \b BuffersDiscardedDeviceCount (Display string: 'Buffers Discarded Device Count'): This enumeration value indicates the number of buffers discarded by the device since last fired instance of this event (the producer would get to know about this for example by observing a gap in the block_id sequence). + * - \b BuffersDiscardedProducerCount (Display string: 'Buffers Discarded Producer Count'): This enumeration value indicates the number of buffers discarded by the producer since last fired instance of this event (this would happen e.g. if there are no free buffers available or if given buffer handling mode requires discarding old buffers etc.). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventSelector; + /// \brief An enumerated integer property. Activate or deactivate the notification to the host application of the occurrence of the selected Event. + /** + * Activate or deactivate the notification to the host application of the occurrence of the selected Event. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The selected Event notification is disabled. + * - \b On (Display string: 'On'): The selected Event notification is enabled. + * - \b Once (Display string: 'Once'): The selected Event notification is enabled for one event then return to Off state. + * - \b GigEVisionEvent (Display string: 'Gig E Vision Event') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventNotification; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +#if !defined( DOXYGEN_SHOULD_SKIP_THIS ) && !defined( WRAP_ANY ) +//----------------------------------------------------------------------------- +inline InterfaceModule::InterfaceModule( mvIMPACT::acquire::Device* pDev, int64_type index ) : + mvIMPACT::acquire::ComponentCollection( INVALID_ID ), + interfaceID(), + interfaceDisplayName(), + interfaceType(), + interfaceTLVersionMajor(), + interfaceTLVersionMinor(), + gevInterfaceGatewaySelector(), + gevInterfaceGateway(), + gevInterfaceMACAddress(), + gevInterfaceSubnetSelector(), + gevInterfaceSubnetIPAddress(), + gevInterfaceSubnetMask(), + mvGevInterfaceMTU(), + mvGevInterfaceLinkSpeed(), + mvGevAdvancedDeviceDiscoveryEnable(), + deviceUpdateList(), + mvUnicastDeviceDiscoveryCommandCount(), + mvUnicastDeviceDiscoveryCommandSelector(), + mvUnicastDeviceDiscoveryDestinationIPAddress(), + deviceUpdateTimeout(), + deviceSelector(), + deviceID(), + deviceVendorName(), + deviceModelName(), + deviceType(), + deviceLinkSpeed(), + deviceAccessStatus(), + deviceSerialNumber(), + deviceUserID(), + deviceTLVersionMajor(), + deviceTLVersionMinor(), + gevDeviceIPAddress(), + gevDeviceSubnetMask(), + gevDeviceGateway(), + gevDeviceIPConfigurationStatus(), + gevDeviceMACAddress(), + gevCurrentControlMode(), + mvDeviceCommandChannelTransmissionTimeout(), + mvDeviceCommandChannelRetryCount(), + gevVersionMajor(), + gevVersionMinor(), + genCPVersionMajor(), + genCPVersionMinor(), + u3vVersionMajor(), + u3vVersionMinor(), + mvDevicePrimaryApplicationSwitchoverSupported(), + mvDevicePrimaryApplicationSwitchoverEnable(), + gevApplicationSwitchoverKey(), + mvDeviceNetworkInterfaceCount(), + gevDeviceForceIP(), + gevDeviceForceIPAddress(), + gevDeviceForceSubnetMask(), + gevDeviceForceGateway(), + mvDeviceUpdateFirmware(), + actionCommand(), + actionDeviceKey(), + actionGroupKey(), + actionGroupMask(), + actionScheduledTimeEnable(), + actionScheduledTime(), + gevActionDestinationIPAddress(), + eventSelector(), + eventNotification() +//----------------------------------------------------------------------------- +{ + mvIMPACT::acquire::ComponentLocator locator( pDev->deviceDriverFeatureList() ); + locator.bindSearchBase( locator.searchbase_id(), "GenTL/Interfaces" ); + std::ostringstream oss; + oss << "Interface" << index; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + m_hRoot = locator.searchbase_id(); + init( locator ); +} +#endif // #if !defined( DOXYGEN_SHOULD_SKIP_THIS ) && !defined( WRAP_ANY ) + +#if !defined( DOXYGEN_SHOULD_SKIP_THIS ) && !defined( WRAP_ANY ) +//----------------------------------------------------------------------------- +inline InterfaceModule::InterfaceModule( int64_type index ) : + mvIMPACT::acquire::ComponentCollection( INVALID_ID ), + interfaceID(), + interfaceDisplayName(), + interfaceType(), + interfaceTLVersionMajor(), + interfaceTLVersionMinor(), + gevInterfaceGatewaySelector(), + gevInterfaceGateway(), + gevInterfaceMACAddress(), + gevInterfaceSubnetSelector(), + gevInterfaceSubnetIPAddress(), + gevInterfaceSubnetMask(), + mvGevInterfaceMTU(), + mvGevInterfaceLinkSpeed(), + mvGevAdvancedDeviceDiscoveryEnable(), + deviceUpdateList(), + mvUnicastDeviceDiscoveryCommandCount(), + mvUnicastDeviceDiscoveryCommandSelector(), + mvUnicastDeviceDiscoveryDestinationIPAddress(), + deviceUpdateTimeout(), + deviceSelector(), + deviceID(), + deviceVendorName(), + deviceModelName(), + deviceType(), + deviceLinkSpeed(), + deviceAccessStatus(), + deviceSerialNumber(), + deviceUserID(), + deviceTLVersionMajor(), + deviceTLVersionMinor(), + gevDeviceIPAddress(), + gevDeviceSubnetMask(), + gevDeviceGateway(), + gevDeviceIPConfigurationStatus(), + gevDeviceMACAddress(), + gevCurrentControlMode(), + mvDeviceCommandChannelTransmissionTimeout(), + mvDeviceCommandChannelRetryCount(), + gevVersionMajor(), + gevVersionMinor(), + genCPVersionMajor(), + genCPVersionMinor(), + u3vVersionMajor(), + u3vVersionMinor(), + mvDevicePrimaryApplicationSwitchoverSupported(), + mvDevicePrimaryApplicationSwitchoverEnable(), + gevApplicationSwitchoverKey(), + mvDeviceNetworkInterfaceCount(), + gevDeviceForceIP(), + gevDeviceForceIPAddress(), + gevDeviceForceSubnetMask(), + gevDeviceForceGateway(), + mvDeviceUpdateFirmware(), + actionCommand(), + actionDeviceKey(), + actionGroupKey(), + actionGroupMask(), + actionScheduledTimeEnable(), + actionScheduledTime(), + gevActionDestinationIPAddress(), + eventSelector(), + eventNotification() +//----------------------------------------------------------------------------- +{ + HLIST hList; + TDMR_ERROR result; + if( ( result = DMR_FindList( INVALID_ID, "mvGenTLConsumer", dmltDeviceDriverLib, 0, &hList ) ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, result, "Couldn't find list 'mvGenTLConsumer'(type: dmltDeviceDriverLib)" ); + } + mvIMPACT::acquire::ComponentLocator locator( hList ); + locator.bindSearchBase( locator.searchbase_id(), "GenTL/Interfaces" ); + std::ostringstream oss; + oss << "Interface" << index; + locator = mvIMPACT::acquire::ComponentLocator( locator.findComponent( oss.str() ) ); + m_hRoot = locator.searchbase_id(); + init( locator ); +} +#endif // #if !defined( DOXYGEN_SHOULD_SKIP_THIS ) && !defined( WRAP_ANY ) + +//----------------------------------------------------------------------------- +/// \brief Category contains items that belong to the device module of the transport layer. +/** + * The Device category contains items that belong to the device module of the transport layer. + * \ingroup GenICamInterfaceProducer + */ +class DeviceModule : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::DeviceModule object. + explicit DeviceModule( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + deviceID(), + deviceSerialNumber(), + deviceUserID(), + deviceVendorName(), + deviceModelName(), + deviceFamilyName(), + deviceVersion(), + deviceManufacturerInfo(), + deviceType(), + deviceDisplayName(), + deviceTimestampFrequency(), + deviceAccessStatus(), + deviceChunkDataFormat(), + deviceEventDataFormat(), + gevDeviceMACAddress(), + gevDeviceIPAddress(), + gevDeviceSubnetMask(), + gevDeviceGateway(), + gevVersionMajor(), + gevVersionMinor(), + genCPVersionMajor(), + genCPVersionMinor(), + u3vVersionMajor(), + u3vVersionMinor(), + deviceEndianessMechanism(), + linkCommandTimeout(), + mvLinkCommandTimeoutCheckGranularity(), + linkCommandRetryCount(), + streamSelector(), + streamID(), + eventSelector(), + eventNotification() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenTL/Device" ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( deviceID, "DeviceID" ); + locator.bindComponent( deviceSerialNumber, "DeviceSerialNumber" ); + locator.bindComponent( deviceUserID, "DeviceUserID" ); + locator.bindComponent( deviceVendorName, "DeviceVendorName" ); + locator.bindComponent( deviceModelName, "DeviceModelName" ); + locator.bindComponent( deviceFamilyName, "DeviceFamilyName" ); + locator.bindComponent( deviceVersion, "DeviceVersion" ); + locator.bindComponent( deviceManufacturerInfo, "DeviceManufacturerInfo" ); + locator.bindComponent( deviceType, "DeviceType" ); + locator.bindComponent( deviceDisplayName, "DeviceDisplayName" ); + locator.bindComponent( deviceTimestampFrequency, "DeviceTimestampFrequency" ); + locator.bindComponent( deviceAccessStatus, "DeviceAccessStatus" ); + locator.bindComponent( deviceChunkDataFormat, "DeviceChunkDataFormat" ); + locator.bindComponent( deviceEventDataFormat, "DeviceEventDataFormat" ); + locator.bindComponent( gevDeviceMACAddress, "GevDeviceMACAddress" ); + locator.bindComponent( gevDeviceIPAddress, "GevDeviceIPAddress" ); + locator.bindComponent( gevDeviceSubnetMask, "GevDeviceSubnetMask" ); + locator.bindComponent( gevDeviceGateway, "GevDeviceGateway" ); + locator.bindComponent( gevVersionMajor, "GevVersionMajor" ); + locator.bindComponent( gevVersionMinor, "GevVersionMinor" ); + locator.bindComponent( genCPVersionMajor, "GenCPVersionMajor" ); + locator.bindComponent( genCPVersionMinor, "GenCPVersionMinor" ); + locator.bindComponent( u3vVersionMajor, "U3vVersionMajor" ); + locator.bindComponent( u3vVersionMinor, "U3vVersionMinor" ); + locator.bindComponent( deviceEndianessMechanism, "DeviceEndianessMechanism" ); + locator.bindComponent( linkCommandTimeout, "LinkCommandTimeout" ); + locator.bindComponent( mvLinkCommandTimeoutCheckGranularity, "mvLinkCommandTimeoutCheckGranularity" ); + locator.bindComponent( linkCommandRetryCount, "LinkCommandRetryCount" ); + locator.bindComponent( streamSelector, "StreamSelector" ); + locator.bindComponent( streamID, "StreamID" ); + locator.bindComponent( eventSelector, "EventSelector" ); + locator.bindComponent( eventNotification, "EventNotification" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property. This feature is deprecated (See DeviceSerialNumber). + /** + * \deprecated + * This feature is deprecated (See DeviceSerialNumber). It was representing the Device unique identifier (serial number). + */ + PropertyS deviceID; + /// \brief A string property. Device's serial number. + /** + * Device's serial number. This string is a unique identifier of the device. + */ + PropertyS deviceSerialNumber; + /// \brief A string property. User-programmable device identifier. + /** + * User-programmable device identifier. + */ + PropertyS deviceUserID; + /// \brief A string property. Name of the manufacturer of the device. + /** + * Name of the manufacturer of the device. + */ + PropertyS deviceVendorName; + /// \brief A string property. Model of the device. + /** + * Model of the device. + */ + PropertyS deviceModelName; + /// \brief A string property. Identifier of the product family of the device. + /** + * Identifier of the product family of the device. + */ + PropertyS deviceFamilyName; + /// \brief A string property. Version of the device. + /** + * Version of the device. + */ + PropertyS deviceVersion; + /// \brief A string property. Manufacturer information about the device. + /** + * Manufacturer information about the device. + */ + PropertyS deviceManufacturerInfo; + /// \brief An enumerated integer property. Returns the device type. + /** + * Returns the device type. + * + * The following string values might be valid for this feature: + * - \b Transmitter (Display string: 'Transmitter'): Data stream transmitter device. + * - \b Receiver (Display string: 'Receiver'): Data stream receiver device. + * - \b Transceiver (Display string: 'Transceiver'): Data stream receiver and transmitter device. + * - \b Peripheral (Display string: 'Peripheral'): Controllable device (with no data stream handling). + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is a device for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is a device for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is a device for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is a device for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is a device for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is a device for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is a device for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceType; + /// \brief A string property. Indicates user readable name for the remote device. + /** + * This is a read only element. It is a string that indicates user readable name for the remote device model. + */ + PropertyS deviceDisplayName; + /// \brief An integer property. Indicates the tick-frequency of the timestamp clock of the remote device. + /** + * Indicates the tick-frequency of the timestamp clock of the remote device. + */ + PropertyI64 deviceTimestampFrequency; + /// \brief An enumerated integer property. Indicates the current access status for the device. + /** + * This is a read only feature. This enumeration gives the device's access status at the moment of the last execution of the DeviceUpdateList command. This value only changes on execution of the DeviceUpdateList command. + * + * The following string values might be valid for this feature: + * - \b Unknown (Display string: 'Unknown'): This enumeration value indicates that the device accessibility is not known. + * - \b ReadWrite (Display string: 'Read/Write'): This enumeration value indicates that full access to the device is available. + * - \b ReadOnly (Display string: 'Read Only'): This enumeration value indicates that read access to the device is available. + * - \b NoAccess (Display string: 'No Access'): This enumeration value indicates that no access to the device is available. + * - \b Busy (Display string: 'Busy'): This enumeration value indicates that the device is already opened by another entity. + * - \b OpenReadWrite (Display string: 'Open Read Write'): This enumeration value indicates that the device is open in Read/Write mode by this GenTL host. + * - \b OpenReadOnly (Display string: 'Open Read Only'): This enumeration value indicates that the device is open in Read only mode by this GenTL host. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceAccessStatus; + /// \brief An enumerated integer property. Indicates the chunk data format used by the remote device. + /** + * This is a read only feature. This enumeration provides a value that indicates the chunk data format used by the remote device. + * + * The following string values might be valid for this feature: + * - \b None (Display string: 'None'): This enumeration value indicates that the device does not use chunk data at all. + * - \b GigEVision (Display string: 'GigE Vision'): This enumeration value indicates that the device formats the chunk data using chunk data format defined by GigE Vision specification version 1.x. The chunk data decoding algorithm (chunk adapter) common for the GigE Vision devices can be used. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that the device formats the chunk data using a custom, non-standard format. Without a-priori additional knowledge about the device and its implementation, the GenTL Consumer should always use the generic chunk adapter to decode the chunk data, not making any assumptions about the internal event data layout.. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceChunkDataFormat; + /// \brief An enumerated integer property. Indicates the event data format used by the remote device. + /** + * This is a read only feature. This enumeration provides a value that indicates the event data format used by the remote device. + * + * The following string values might be valid for this feature: + * - \b None (Display string: 'None'): This enumeration value indicates that the device does not use event data at all. + * - \b GigEVision (Display string: 'GigE Vision'): This enumeration value indicates that the device formats the event data using the event data format defined by GigE Vision specification version 1.x. The event data decoding algorithm (event adapter) common for the GigE Vision devices can be used. + * - \b GigEVisionExtendedId (Display string: 'GigE Vision Extended Id'): This enumeration value indicates that the device formats the event data using the event data format defined by GigE Vision specification version 2.x. The event data decoding algorithm (event adapter) common for the GigE Vision devices can be used. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that the device formats the event data using a custom, non-standard format. Without a-priori additional knowledge about the device and its implementation, the GenTL Consumer should always use the generic event adapter to decode the event data, not making any assumptions about the internal event data layout.. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceEventDataFormat; + /// \brief An integer property. Indicates the 48-bit MAC address of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the 48-bit MAC address of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceMACAddress; + /// \brief An integer property. Indicates the current IP address of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the current IP address of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceIPAddress; + /// \brief An integer property. Indicates the current subnet mask of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the current subnet mask of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceSubnetMask; + /// \brief An integer property. Indicates the current gateway of the GVCP interface of the selected remote device. + /** + * This is a read only element. It indicates the current gateway of the GVCP interface of the selected remote device. + */ + PropertyI64 gevDeviceGateway; + /// \brief An integer property. Indicates the major version number of the GigE Vision specification this device complies with. + /** + * This is a read only element. It indicates the major version number of the GigE Vision specification this device complies with. + */ + PropertyI64 gevVersionMajor; + /// \brief An integer property. Indicates the minor version number of the GigE Vision specification this device complies with. + /** + * This is a read only element. It indicates the minor version number of the GigE Vision specification this device complies with. + */ + PropertyI64 gevVersionMinor; + /// \brief An integer property. Indicates the major version number of the GenCP specification this device complies with. + /** + * This is a read only element. It indicates the major version number of the GenCP specification this device complies with. + */ + PropertyI64 genCPVersionMajor; + /// \brief An integer property. Indicates the minor version number of the GenCP specification this device complies with. + /** + * This is a read only element. It indicates the minor version number of the GenCP specification this device complies with. + */ + PropertyI64 genCPVersionMinor; + /// \brief An integer property. Indicates the major version number of the USB3 Vision specification this device complies with. + /** + * This is a read only element. It indicates the major version number of the USB3 Vision specification this device complies with. + */ + PropertyI64 u3vVersionMajor; + /// \brief An integer property. Indicates the minor version number of the USB3 Vision specification this device complies with. + /** + * This is a read only element. It indicates the minor version number of the USB3 Vision specification this device complies with. + */ + PropertyI64 u3vVersionMinor; + /// \brief An enumerated integer property. Identifies the endianess mode to be used for this device. + /** + * This is a read only feature. This enumeration provides a value that indicates the endianess mode to be used for this device. + * + * The following string values might be valid for this feature: + * - \b Legacy (Display string: 'Legacy'): This enumeration value indicates that this device shall be handled according to GenICam Schema 1.0. + * - \b Standard (Display string: 'Standard'): This enumeration value indicates that this device shall be handled according to GenICam Schema 1.1 and later. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 deviceEndianessMechanism; + /// \brief A floating point property. Specifies application timeout for the control channel communication. + /** + * The feature specifies application timeout for the control channel communication. It defines the application timeout, and it is related to the device feature DeviceLinkCommandTimeout specifying the maximum time for handling a command in the device. Up to DeviceLinkCommandRetryCount attempts with this timeout are made before a command fails with a timout error. + */ + PropertyF linkCommandTimeout; + /// \brief An integer property. Indicates how often the driver shall check the link during one 'DeviceLinkCommandTimeout' interval. + /** + * Indicates how often the driver shall check the link during one 'DeviceLinkCommandTimeout' interval. The higher this value the more often the link will be checked. However additional traffic on the link is only generated if no other communication like polling certain registers, reading or writing is performed by an application. A higher value will result in a faster notification in case a device has been physically been unplugged. + */ + PropertyI64 mvLinkCommandTimeoutCheckGranularity; + /// \brief An integer property. Specifies maximum number of tries before failing the control channel commands. + /** + * This feature specifies maximum number of tries before failing the control channel commands. + */ + PropertyI64 linkCommandRetryCount; + /// \brief An integer property. Selects the stream channel. + /** + * Selects the stream channel. + */ + PropertyI64 streamSelector; + /// \brief A string property. Device wide unique ID of the selected stream. + /** + * This is a read only element. It is a string that indicates a device wide unique identifier of the selected stream. + */ + PropertyS streamID; + /// \brief An enumerated integer property. Selects which Event to signal to the host application. + /** + * Selects which Event to signal to the host application. + * + * The following string values might be valid for this feature: + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device just received a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device just missed a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Device just started the Acquisition of one or many Frames. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Device just completed the Acquisition of one or many Frames. + * - \b AcquisitionTransferStart (Display string: 'Acquisition Transfer Start'): Device just started the transfer of one or many Frames. + * - \b AcquisitionTransferEnd (Display string: 'Acquisition Transfer End'): Device just completed the transfer of one or many Frames. + * - \b AcquisitionError (Display string: 'Acquisition Error'): Device just detected an error during the active Acquisition. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Device just started the capture of a burst of Frames. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Device just completed the capture of a burst of Frames. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device just received a trigger to start the capture of one Frame. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device just missed a trigger to start the capture of one Frame. + * - \b FrameStart (Display string: 'Frame Start'): Device just started the capture of one Frame. + * - \b FrameEnd (Display string: 'Frame End'): Device just completed the capture of one Frame. + * - \b FrameTransferStart (Display string: 'Frame Transfer Start'): Device just started the transfer of one Frame. + * - \b FrameTransferEnd (Display string: 'Frame Transfer End'): Device just completed the transfer of one Frame. + * - \b LineTrigger (Display string: 'Line Trigger'): Device just received a trigger to start the capture of one Line. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device just missed a trigger to start the capture of one Line. + * - \b LineStart (Display string: 'Line Start'): Device just started the capture of one Line. + * - \b LineEnd (Display string: 'Line End'): Device just completed the capture of one Line. + * - \b ExposureStart (Display string: 'Exposure Start'): Device just started the exposure of one Frame (or Line). + * - \b ExposureEnd (Display string: 'Exposure End'): Device just completed the exposure of one Frame (or Line). + * - \b Stream0TransferStart (Display string: 'Stream 0 Transfer Start'): Device just started the transfer of one or many Blocks. + * - \b Stream0TransferEnd (Display string: 'Stream 0 Transfer End'): Device just completed the transfer of one or many Blocks. + * - \b Stream0TransferPause (Display string: 'Stream 0 Transfer Pause'): Device just paused the transfer. + * - \b Stream0TransferResume (Display string: 'Stream 0 Transfer Resume'): Device just resumed the transfer. + * - \b Stream0TransferBlockStart (Display string: 'Stream 0 Transfer Block Start'): Device just started the transfer of one Block. + * - \b Stream0TransferBlockEnd (Display string: 'Stream 0 Transfer Block End'): Device just completed the transfer of one Block. + * - \b Stream0TransferBlockTrigger (Display string: 'Stream 0 Transfer Block Trigger'): Device just received a trigger to start the transfer of one Block. + * - \b Stream0TransferBurstStart (Display string: 'Stream 0 Transfer Burst Start'): Device just started the transfer of a burst of Blocks. + * - \b Stream0TransferBurstEnd (Display string: 'Stream 0 Transfer Burst End'): Device just completed the transfer of a burst of Blocks. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Device transfer queue overflowed. + * - \b SequencerSetChange (Display string: 'Sequencer Set Change'): Device sequencer set has changed. + * - \b Counter0Start (Display string: 'Counter 0 Start'): The event will be generated when counter 0 starts counting. + * - \b Counter1Start (Display string: 'Counter 1 Start'): The event will be generated when counter 1 starts counting. + * - \b Counter\#2\#Start (Display string: 'Counter \#2\# Start'): The event will be generated when counter \#2\# starts counting. + * - \b Counter0End (Display string: 'Counter 0 End'): The event will be generated when counter 0 ends counting. + * - \b Counter1End (Display string: 'Counter 1 End'): The event will be generated when counter 1 ends counting. + * - \b Counter\#2\#End (Display string: 'Counter \#2\# End'): The event will be generated when counter \#2\# ends counting. + * - \b Timer0Start (Display string: 'Timer 0 Start'): The event will be generated when Timer 0 starts counting. + * - \b Timer1Start (Display string: 'Timer 1 Start'): The event will be generated when Timer 1 starts counting. + * - \b Timer\#2\#Start (Display string: 'Timer \#2\# Start'): The event will be generated when Timer \#2\# starts counting. + * - \b Timer0End (Display string: 'Timer 0 End'): The event will be generated when Timer 0 ends counting. + * - \b Timer1End (Display string: 'Timer 1 End'): The event will be generated when Timer 1 ends counting. + * - \b Timer\#2\#End (Display string: 'Timer \#2\# End'): The event will be generated when Timer \#2\# ends counting. + * - \b Encoder0Stopped (Display string: 'Encoder 0 Stopped'): The event will be generated when the Encoder 0 stops for longer than EncoderTimeout. + * - \b Encoder1Stopped (Display string: 'Encoder 1 Stopped'): The event will be generated when the Encoder 1 stops for longer than EncoderTimeout. + * - \b Encoder\#2\#Stopped (Display string: 'Encoder \#2\# Stopped'): The event will be generated when the Encoder \#2\# stops for longer than EncoderTimeout. + * - \b Encoder0Restarted (Display string: 'Encoder 0 Restarted'): The event will be generated when the Encoder 0 restarts moving. + * - \b Encoder1Restarted (Display string: 'Encoder 1 Restarted'): The event will be generated when the Encoder 1 restarts moving. + * - \b Encoder\#2\#Restarted (Display string: 'Encoder \#2\# Restarted'): The event will be generated when the Encoder \#2\# restarts moving. + * - \b Line0RisingEdge (Display string: 'Line 0 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 0. + * - \b Line1RisingEdge (Display string: 'Line 1 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 1. + * - \b Line\#2\#RisingEdge (Display string: 'Line \#2\# Rising Edge'): The event will be generated when a Rising Edge is detected on the Line \#2\#. + * - \b Line0FallingEdge (Display string: 'Line 0 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 0. + * - \b Line1FallingEdge (Display string: 'Line 1 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 1. + * - \b Line\#2\#FallingEdge (Display string: 'Line \#2\# Falling Edge'): The event will be generated when a Falling Edge is detected on the Line \#2\#. + * - \b Line0AnyEdge (Display string: 'Line 0 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 0. + * - \b Line1AnyEdge (Display string: 'Line 1 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 1. + * - \b Line\#2\#AnyEdge (Display string: 'Line \#2\# Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line \#2\#. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): The event will be generated when a Rising Edge is detected on the LinkTrigger 0. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): The event will be generated when a Rising Edge is detected on the LinkTrigger 1. + * - \b LinkTrigger\#2\# (Display string: 'Link Trigger \#2\#'): The event will be generated when a Rising Edge is detected on the LinkTrigger \#2\#. + * - \b LinkSpeedChange (Display string: 'Link Speed Change'): The event will be generated when the link speed has changed. + * - \b ActionLate (Display string: 'Action Late'): The event will be generated when a valid scheduled action command is received and is scheduled to be executed at a time that is already past. + * - \b Error (Display string: 'Error'): Device just detected an error during the active Acquisition. + * - \b Test (Display string: 'Test'): The test event will be generated when the device receives the TestEventGenerate command (EventNotification for the Test event is always On). + * - \b PrimaryApplicationSwitch (Display string: 'Primary Application Switch'): The event will be generated when a primary application switchover has been granted (GigE Vision Specific). + * - \b Counter2Start (Display string: 'Counter 2 Start'): The event will be generated when counter 2 starts counting. + * - \b Counter3Start (Display string: 'Counter 3 Start'): The event will be generated when counter 3 starts counting. + * - \b Counter4Start (Display string: 'Counter 4 Start'): The event will be generated when counter 4 starts counting. + * - \b Counter5Start (Display string: 'Counter 5 Start'): The event will be generated when counter 5 starts counting. + * - \b Counter6Start (Display string: 'Counter 6 Start'): The event will be generated when counter 6 starts counting. + * - \b Counter7Start (Display string: 'Counter 7 Start'): The event will be generated when counter 7 starts counting. + * - \b Counter8Start (Display string: 'Counter 8 Start'): The event will be generated when counter 8 starts counting. + * - \b Counter9Start (Display string: 'Counter 9 Start'): The event will be generated when counter 9 starts counting. + * - \b Counter10Start (Display string: 'Counter 10 Start'): The event will be generated when counter 10 starts counting. + * - \b Counter11Start (Display string: 'Counter 11 Start'): The event will be generated when counter 11 starts counting. + * - \b Counter12Start (Display string: 'Counter 12 Start'): The event will be generated when counter 12 starts counting. + * - \b Counter13Start (Display string: 'Counter 13 Start'): The event will be generated when counter 13 starts counting. + * - \b Counter14Start (Display string: 'Counter 14 Start'): The event will be generated when counter 14 starts counting. + * - \b Counter15Start (Display string: 'Counter 15 Start'): The event will be generated when counter 15 starts counting. + * - \b Counter2End (Display string: 'Counter 2 End'): The event will be generated when counter 2 ends counting. + * - \b Counter3End (Display string: 'Counter 3 End'): The event will be generated when counter 3 ends counting. + * - \b Counter4End (Display string: 'Counter 4 End'): The event will be generated when counter 4 ends counting. + * - \b Counter5End (Display string: 'Counter 5 End'): The event will be generated when counter 5 ends counting. + * - \b Counter6End (Display string: 'Counter 6 End'): The event will be generated when counter 6 ends counting. + * - \b Counter7End (Display string: 'Counter 7 End'): The event will be generated when counter 7 ends counting. + * - \b Counter8End (Display string: 'Counter 8 End'): The event will be generated when counter 8 ends counting. + * - \b Counter9End (Display string: 'Counter 9 End'): The event will be generated when counter 9 ends counting. + * - \b Counter10End (Display string: 'Counter 10 End'): The event will be generated when counter 10 ends counting. + * - \b Counter11End (Display string: 'Counter 11 End'): The event will be generated when counter 11 ends counting. + * - \b Counter12End (Display string: 'Counter 12 End'): The event will be generated when counter 12 ends counting. + * - \b Counter13End (Display string: 'Counter 13 End'): The event will be generated when counter 13 ends counting. + * - \b Counter14End (Display string: 'Counter 14 End'): The event will be generated when counter 14 ends counting. + * - \b Counter15End (Display string: 'Counter 15 End'): The event will be generated when counter 15 ends counting. + * - \b Timer2Start (Display string: 'Timer 2 Start'): The event will be generated when Timer 2 starts counting. + * - \b Timer3Start (Display string: 'Timer 3 Start'): The event will be generated when Timer 3 starts counting. + * - \b Timer4Start (Display string: 'Timer 4 Start'): The event will be generated when Timer 4 starts counting. + * - \b Timer5Start (Display string: 'Timer 5 Start'): The event will be generated when Timer 5 starts counting. + * - \b Timer6Start (Display string: 'Timer 6 Start'): The event will be generated when Timer 6 starts counting. + * - \b Timer7Start (Display string: 'Timer 7 Start'): The event will be generated when Timer 7 starts counting. + * - \b Timer8Start (Display string: 'Timer 8 Start'): The event will be generated when Timer 8 starts counting. + * - \b Timer9Start (Display string: 'Timer 9 Start'): The event will be generated when Timer 9 starts counting. + * - \b Timer10Start (Display string: 'Timer 10 Start'): The event will be generated when Timer 10 starts counting. + * - \b Timer11Start (Display string: 'Timer 11 Start'): The event will be generated when Timer 11 starts counting. + * - \b Timer12Start (Display string: 'Timer 12 Start'): The event will be generated when Timer 12 starts counting. + * - \b Timer13Start (Display string: 'Timer 13 Start'): The event will be generated when Timer 13 starts counting. + * - \b Timer14Start (Display string: 'Timer 14 Start'): The event will be generated when Timer 14 starts counting. + * - \b Timer15Start (Display string: 'Timer 15 Start'): The event will be generated when Timer 15 starts counting. + * - \b Timer2End (Display string: 'Timer 2 End'): The event will be generated when Timer 2 ends counting. + * - \b Timer3End (Display string: 'Timer 3 End'): The event will be generated when Timer 3 ends counting. + * - \b Timer4End (Display string: 'Timer 4 End'): The event will be generated when Timer 4 ends counting. + * - \b Timer5End (Display string: 'Timer 5 End'): The event will be generated when Timer 5 ends counting. + * - \b Timer6End (Display string: 'Timer 6 End'): The event will be generated when Timer 6 ends counting. + * - \b Timer7End (Display string: 'Timer 7 End'): The event will be generated when Timer 7 ends counting. + * - \b Timer8End (Display string: 'Timer 8 End'): The event will be generated when Timer 8 ends counting. + * - \b Timer9End (Display string: 'Timer 9 End'): The event will be generated when Timer 9 ends counting. + * - \b Timer10End (Display string: 'Timer 10 End'): The event will be generated when Timer 10 ends counting. + * - \b Timer11End (Display string: 'Timer 11 End'): The event will be generated when Timer 11 ends counting. + * - \b Timer12End (Display string: 'Timer 12 End'): The event will be generated when Timer 12 ends counting. + * - \b Timer13End (Display string: 'Timer 13 End'): The event will be generated when Timer 13 ends counting. + * - \b Timer14End (Display string: 'Timer 14 End'): The event will be generated when Timer 14 ends counting. + * - \b Timer15End (Display string: 'Timer 15 End'): The event will be generated when Timer 15 ends counting. + * - \b Encoder2Stopped (Display string: 'Encoder 2 Stopped'): The event will be generated when the Encoder 2 stops for longer than EncoderTimeout. + * - \b Encoder3Stopped (Display string: 'Encoder 3 Stopped'): The event will be generated when the Encoder 3 stops for longer than EncoderTimeout. + * - \b Encoder4Stopped (Display string: 'Encoder 4 Stopped'): The event will be generated when the Encoder 4 stops for longer than EncoderTimeout. + * - \b Encoder5Stopped (Display string: 'Encoder 5 Stopped'): The event will be generated when the Encoder 5 stops for longer than EncoderTimeout. + * - \b Encoder6Stopped (Display string: 'Encoder 6 Stopped'): The event will be generated when the Encoder 6 stops for longer than EncoderTimeout. + * - \b Encoder7Stopped (Display string: 'Encoder 7 Stopped'): The event will be generated when the Encoder 7 stops for longer than EncoderTimeout. + * - \b Encoder8Stopped (Display string: 'Encoder 8 Stopped'): The event will be generated when the Encoder 8 stops for longer than EncoderTimeout. + * - \b Encoder9Stopped (Display string: 'Encoder 9 Stopped'): The event will be generated when the Encoder 9 stops for longer than EncoderTimeout. + * - \b Encoder10Stopped (Display string: 'Encoder 10 Stopped'): The event will be generated when the Encoder 10 stops for longer than EncoderTimeout. + * - \b Encoder11Stopped (Display string: 'Encoder 11 Stopped'): The event will be generated when the Encoder 11 stops for longer than EncoderTimeout. + * - \b Encoder12Stopped (Display string: 'Encoder 12 Stopped'): The event will be generated when the Encoder 12 stops for longer than EncoderTimeout. + * - \b Encoder13Stopped (Display string: 'Encoder 13 Stopped'): The event will be generated when the Encoder 13 stops for longer than EncoderTimeout. + * - \b Encoder14Stopped (Display string: 'Encoder 14 Stopped'): The event will be generated when the Encoder 14 stops for longer than EncoderTimeout. + * - \b Encoder15Stopped (Display string: 'Encoder 15 Stopped'): The event will be generated when the Encoder 15 stops for longer than EncoderTimeout. + * - \b Encoder2Restarted (Display string: 'Encoder 2 Restarted'): The event will be generated when the Encoder 2 restarts moving. + * - \b Encoder3Restarted (Display string: 'Encoder 3 Restarted'): The event will be generated when the Encoder 3 restarts moving. + * - \b Encoder4Restarted (Display string: 'Encoder 4 Restarted'): The event will be generated when the Encoder 4 restarts moving. + * - \b Encoder5Restarted (Display string: 'Encoder 5 Restarted'): The event will be generated when the Encoder 5 restarts moving. + * - \b Encoder6Restarted (Display string: 'Encoder 6 Restarted'): The event will be generated when the Encoder 6 restarts moving. + * - \b Encoder7Restarted (Display string: 'Encoder 7 Restarted'): The event will be generated when the Encoder 7 restarts moving. + * - \b Encoder8Restarted (Display string: 'Encoder 8 Restarted'): The event will be generated when the Encoder 8 restarts moving. + * - \b Encoder9Restarted (Display string: 'Encoder 9 Restarted'): The event will be generated when the Encoder 9 restarts moving. + * - \b Encoder10Restarted (Display string: 'Encoder 10 Restarted'): The event will be generated when the Encoder 10 restarts moving. + * - \b Encoder11Restarted (Display string: 'Encoder 11 Restarted'): The event will be generated when the Encoder 11 restarts moving. + * - \b Encoder12Restarted (Display string: 'Encoder 12 Restarted'): The event will be generated when the Encoder 12 restarts moving. + * - \b Encoder13Restarted (Display string: 'Encoder 13 Restarted'): The event will be generated when the Encoder 13 restarts moving. + * - \b Encoder14Restarted (Display string: 'Encoder 14 Restarted'): The event will be generated when the Encoder 14 restarts moving. + * - \b Encoder15Restarted (Display string: 'Encoder 15 Restarted'): The event will be generated when the Encoder 15 restarts moving. + * - \b Line2RisingEdge (Display string: 'Line 2 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 2. + * - \b Line3RisingEdge (Display string: 'Line 3 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 3. + * - \b Line4RisingEdge (Display string: 'Line 4 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 4. + * - \b Line5RisingEdge (Display string: 'Line 5 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 5. + * - \b Line6RisingEdge (Display string: 'Line 6 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 6. + * - \b Line7RisingEdge (Display string: 'Line 7 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 7. + * - \b Line8RisingEdge (Display string: 'Line 8 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 8. + * - \b Line9RisingEdge (Display string: 'Line 9 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 9. + * - \b Line10RisingEdge (Display string: 'Line 10 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 10. + * - \b Line11RisingEdge (Display string: 'Line 11 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 11. + * - \b Line12RisingEdge (Display string: 'Line 12 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 12. + * - \b Line13RisingEdge (Display string: 'Line 13 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 13. + * - \b Line14RisingEdge (Display string: 'Line 14 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 14. + * - \b Line15RisingEdge (Display string: 'Line 15 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 15. + * - \b Line2FallingEdge (Display string: 'Line 2 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 2. + * - \b Line3FallingEdge (Display string: 'Line 3 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 3. + * - \b Line4FallingEdge (Display string: 'Line 4 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 4. + * - \b Line5FallingEdge (Display string: 'Line 5 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 5. + * - \b Line6FallingEdge (Display string: 'Line 6 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 6. + * - \b Line7FallingEdge (Display string: 'Line 7 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 7. + * - \b Line8FallingEdge (Display string: 'Line 8 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 8. + * - \b Line9FallingEdge (Display string: 'Line 9 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 9. + * - \b Line10FallingEdge (Display string: 'Line 10 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 10. + * - \b Line11FallingEdge (Display string: 'Line 11 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 11. + * - \b Line12FallingEdge (Display string: 'Line 12 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 12. + * - \b Line13FallingEdge (Display string: 'Line 13 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 13. + * - \b Line14FallingEdge (Display string: 'Line 14 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 14. + * - \b Line15FallingEdge (Display string: 'Line 15 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 15. + * - \b Line2AnyEdge (Display string: 'Line 2 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 2. + * - \b Line3AnyEdge (Display string: 'Line 3 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 3. + * - \b Line4AnyEdge (Display string: 'Line 4 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 4. + * - \b Line5AnyEdge (Display string: 'Line 5 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 5. + * - \b Line6AnyEdge (Display string: 'Line 6 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 6. + * - \b Line7AnyEdge (Display string: 'Line 7 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 7. + * - \b Line8AnyEdge (Display string: 'Line 8 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 8. + * - \b Line9AnyEdge (Display string: 'Line 9 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 9. + * - \b Line10AnyEdge (Display string: 'Line 10 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 10. + * - \b Line11AnyEdge (Display string: 'Line 11 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 11. + * - \b Line12AnyEdge (Display string: 'Line 12 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 12. + * - \b Line13AnyEdge (Display string: 'Line 13 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 13. + * - \b Line14AnyEdge (Display string: 'Line 14 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 14. + * - \b Line15AnyEdge (Display string: 'Line 15 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 15. + * - \b Link0Trigger (Display string: 'Link 0 Trigger') + * - \b Link1Trigger (Display string: 'Link 1 Trigger') + * - \b Link2Trigger (Display string: 'Link 2 Trigger') + * - \b Link3Trigger (Display string: 'Link 3 Trigger') + * - \b Link4Trigger (Display string: 'Link 4 Trigger') + * - \b Link5Trigger (Display string: 'Link 5 Trigger') + * - \b Link6Trigger (Display string: 'Link 6 Trigger') + * - \b Link7Trigger (Display string: 'Link 7 Trigger') + * - \b Link8Trigger (Display string: 'Link 8 Trigger') + * - \b Link9Trigger (Display string: 'Link 9 Trigger') + * - \b Link10Trigger (Display string: 'Link 10 Trigger') + * - \b Link11Trigger (Display string: 'Link 11 Trigger') + * - \b Link12Trigger (Display string: 'Link 12 Trigger') + * - \b Link13Trigger (Display string: 'Link 13 Trigger') + * - \b Link14Trigger (Display string: 'Link 14 Trigger') + * - \b Link15Trigger (Display string: 'Link 15 Trigger') + * - \b InterfaceListChanged (Display string: 'Interface List Changed'): This enumeration value indicates an event that is fired when the list of interfaces has been updated. + * - \b InterfaceLost (Display string: 'Interface Lost'): This enumeration value indicates an event that is raised when the interface connection is lost. + * - \b DeviceListChanged (Display string: 'Device List Changed'): This enumeration value indicates an event that is fired when the list of devices has been updated. + * - \b DeviceLost (Display string: 'Device Lost'): This enumeration value indicates an event that is raised when the local host looses connection to the physical(remote) device. + * - \b BufferTooSmall (Display string: 'Buffer Too Small'): This enumeration value indicates an event that is raised when the buffer was too small to receive the expected amount of data. + * - \b BuffersDiscarded (Display string: 'Buffers Discarded'): This enumeration value indicates an event that is raised when buffers discared by GenTL or device. This event could optionally carry two numeric child data fields EventBuffersDiscardedDeviceCount and EventBuffersDiscardedProducerCount. + * - \b BuffersDiscardedDeviceCount (Display string: 'Buffers Discarded Device Count'): This enumeration value indicates the number of buffers discarded by the device since last fired instance of this event (the producer would get to know about this for example by observing a gap in the block_id sequence). + * - \b BuffersDiscardedProducerCount (Display string: 'Buffers Discarded Producer Count'): This enumeration value indicates the number of buffers discarded by the producer since last fired instance of this event (this would happen e.g. if there are no free buffers available or if given buffer handling mode requires discarding old buffers etc.). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventSelector; + /// \brief An enumerated integer property. Activate or deactivate the notification to the host application of the occurrence of the selected Event. + /** + * Activate or deactivate the notification to the host application of the occurrence of the selected Event. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The selected Event notification is disabled. + * - \b On (Display string: 'On'): The selected Event notification is enabled. + * - \b Once (Display string: 'Once'): The selected Event notification is enabled for one event then return to Off state. + * - \b GigEVisionEvent (Display string: 'Gig E Vision Event') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventNotification; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +//----------------------------------------------------------------------------- +/// \brief Category that contains items that belong to the data stream module of the transport layer. +/** + * The DataStream category contains items that belong to the data stream module of the transport layer. + * \ingroup GenICamInterfaceProducer + */ +class DataStreamModule : public mvIMPACT::acquire::ComponentCollection +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::DataStreamModule object. + explicit DataStreamModule( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The \a index of the instance this object shall be created for. Passing an invalid index will raise an exception. + int64_type index, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : + mvIMPACT::acquire::ComponentCollection( pDev ), + streamID(), + streamType(), + mvStreamDriverTechnology(), + mvAutoJoinMulticastGroups(), + mvResendActive(), + mvResendUserControlledEnable(), + mvResendMode(), + mvResendBatchingActive(), + mvResendMaximumGapSize(), + mvResendThreshold(), + mvResendRequestMax(), + mvResendRequestCredits(), + mvResendResponseTimeout(), + mvResendsPerTimeout(), + mvMultiCPUStreamProcessingEnable(), + mvMultiCPUStreamProcessingCPUCount(), + mvMultiCPUStreamProcessingFirstCPUIndex(), + mvMultiCPUStreamProcessingSwitchInterval(), + streamAnnouncedBufferCount(), + streamBufferHandlingMode(), + streamAnnounceBufferMinimum(), + mvStreamAnnounceBufferMaximum(), + streamDeliveredFrameCount(), + streamLostFrameCount(), + streamInputBufferCount(), + streamOutputBufferCount(), + streamStartedFrameCount(), + payloadSize(), + streamIsGrabbing(), + streamChunkCountMaximum(), + streamBufferAlignment(), + eventSelector(), + eventNotification() + { + pDev->validateInterfaceLayout( dilGenICam ); + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, mvIMPACT::acquire::dltSetting, settingName ); + locator.bindSearchBase( locator.searchbase_id(), "Camera/GenTL/DataStreams" ); + std::ostringstream oss; + oss << "Stream" << index; + locator = mvIMPACT::acquire::DeviceComponentLocator( locator.findComponent( oss.str() ) ); + m_hRoot = locator.searchbase_id(); + locator.bindComponent( streamID, "StreamID" ); + locator.bindComponent( streamType, "StreamType" ); + locator.bindComponent( mvStreamDriverTechnology, "mvStreamDriverTechnology" ); + locator.bindComponent( mvAutoJoinMulticastGroups, "mvAutoJoinMulticastGroups" ); + locator.bindComponent( mvResendActive, "mvResendActive" ); + locator.bindComponent( mvResendUserControlledEnable, "mvResendUserControlledEnable" ); + locator.bindComponent( mvResendMode, "mvResendMode" ); + locator.bindComponent( mvResendBatchingActive, "mvResendBatchingActive" ); + locator.bindComponent( mvResendMaximumGapSize, "mvResendMaximumGapSize" ); + if( !mvResendMaximumGapSize.isValid() ) + { + locator.bindComponent( mvResendMaximumGapSize, "mvResendCaptureWindowSize" ); + } + locator.bindComponent( mvResendThreshold, "mvResendThreshold" ); + locator.bindComponent( mvResendRequestMax, "mvResendRequestMax" ); + locator.bindComponent( mvResendRequestCredits, "mvResendRequestCredits" ); + locator.bindComponent( mvResendResponseTimeout, "mvResendResponseTimeout" ); + locator.bindComponent( mvResendsPerTimeout, "mvResendsPerTimeout" ); + locator.bindComponent( mvMultiCPUStreamProcessingEnable, "mvMultiCPUStreamProcessingEnable" ); + locator.bindComponent( mvMultiCPUStreamProcessingCPUCount, "mvMultiCPUStreamProcessingCPUCount" ); + locator.bindComponent( mvMultiCPUStreamProcessingFirstCPUIndex, "mvMultiCPUStreamProcessingFirstCPUIndex" ); + locator.bindComponent( mvMultiCPUStreamProcessingSwitchInterval, "mvMultiCPUStreamProcessingSwitchInterval" ); + locator.bindComponent( streamAnnouncedBufferCount, "StreamAnnouncedBufferCount" ); + locator.bindComponent( streamBufferHandlingMode, "StreamBufferHandlingMode" ); + locator.bindComponent( streamAnnounceBufferMinimum, "StreamAnnounceBufferMinimum" ); + locator.bindComponent( mvStreamAnnounceBufferMaximum, "mvStreamAnnounceBufferMaximum" ); + locator.bindComponent( streamDeliveredFrameCount, "StreamDeliveredFrameCount" ); + locator.bindComponent( streamLostFrameCount, "StreamLostFrameCount" ); + locator.bindComponent( streamInputBufferCount, "StreamInputBufferCount" ); + locator.bindComponent( streamOutputBufferCount, "StreamOutputBufferCount" ); + locator.bindComponent( streamStartedFrameCount, "StreamStartedFrameCount" ); + locator.bindComponent( payloadSize, "PayloadSize" ); + locator.bindComponent( streamIsGrabbing, "StreamIsGrabbing" ); + locator.bindComponent( streamChunkCountMaximum, "StreamChunkCountMaximum" ); + locator.bindComponent( streamBufferAlignment, "StreamBufferAlignment" ); + locator.bindComponent( eventSelector, "EventSelector" ); + locator.bindComponent( eventNotification, "EventNotification" ); + } + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %immutable; ) + // *INDENT-ON* + /// \brief A string property. Device wide unique ID of the selected stream. + /** + * This is a read only element. It is a string that indicates a device wide unique identifier of the selected stream. + */ + PropertyS streamID; + /// \brief An enumerated integer property. Identifies the stream technology of the GenTL Producer implementation. + /** + * This is a read only feature. This enumeration provides a value that indicates stream technology of the GenTL Producer implementation. + * + * The following string values might be valid for this feature: + * - \b Mixed (Display string: 'Mixed'): This enumeration value indicates that this is a data stream for a mixed protocol. + * - \b Custom (Display string: 'Custom'): This enumeration value indicates that this is a data stream for a custom protocol. + * - \b GEV (Display string: 'GigE Vision'): This enumeration value indicates that this is a data stream for the GigE Vision protocol. + * - \b CameraLink (Display string: 'CameraLink'): This enumeration value indicates that this is a data stream for the CameraLink protocol. + * - \b CoaXPress (Display string: 'CoaXPress'): This enumeration value indicates that this is a data stream for the CoaXPress protocol. + * - \b CameraLinkHS (Display string: 'CameraLink HS'): This enumeration value indicates that this is a data stream for the CameraLink HS protocol. + * - \b U3V (Display string: 'USB3 Vision'): This enumeration value indicates that this is a data stream for the USB3 Vision protocol. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 streamType; + /// \brief A string property. The underlying driver technology used by this stream. + /** + * This is a read only element. It is a string that contains the underlying driver technology used by this stream. + */ + PropertyS mvStreamDriverTechnology; + /// \brief A boolean property. This feature controls whether the host automatically joins the multicast group(s) of the camera(s) it configures. + /** + * This feature controls whether the host automatically joins the multicast group(s) of the camera(s) it configures. + */ + PropertyIBoolean mvAutoJoinMulticastGroups; + /// \brief A boolean property. This feature controls if the stream will issue packet resend requests. + /** + * This feature controls if the stream will issue packet resend requests. + */ + PropertyIBoolean mvResendActive; + /// \brief A boolean property. This feature controls if the resend related parameters on this stream will be controlled by the driver or the host application. + /** + * This feature controls if the resend related parameters on this stream will be controlled by the driver or the host application. + */ + PropertyIBoolean mvResendUserControlledEnable; + /// \brief An integer property. Indicates the mode the internal resend algorithm is working in. This feature is a bit mask. The bits have the following meaning (LSB to MSB): Request Resends when a new block starts and the current one has missing packets(0x01)(not recommended for LAG), Request Resends when a new block starts and the current one has no trailer so far(0x02)(not recommended for LAG), Request Resends when more than 'ResendThreshold' packets have been received since a missing packet has been detected(0x04), Request Resends whenever 'mvResendResponseTimeout' did elapse for the previous still incomplete buffer(0x08), Request Resends whenever 'mvResendResponseTimeout' did elapse for the current still incomplete buffer(0x10), Request Resends whenever a packet is considered as missing(0x20)(not recommended for LAG), Request Resends whenever a block start has been missing(e.g. because no capture buffer was available at the time the block did start)(0x40) + /** + * Indicates the mode the internal resend algorithm is working in. This feature is a bit mask. The bits have the following meaning (LSB to MSB): Request Resends when a new block starts and the current one has missing packets(0x01)(not recommended for LAG), Request Resends when a new block starts and the current one has no trailer so far(0x02)(not recommended for LAG), Request Resends when more than 'ResendThreshold' packets have been received since a missing packet has been detected(0x04), Request Resends whenever 'mvResendResponseTimeout' did elapse for the previous still incomplete buffer(0x08), Request Resends whenever 'mvResendResponseTimeout' did elapse for the current still incomplete buffer(0x10), Request Resends whenever a packet is considered as missing(0x20)(not recommended for LAG), Request Resends whenever a block start has been missing(e.g. because no capture buffer was available at the time the block did start)(0x40) + */ + PropertyI64 mvResendMode; + /// \brief A boolean property. This feature controls if the stream will issue batched packet resend requests if it detects several consecutive missing packets. + /** + * This feature controls if the stream will issue batched packet resend requests if it detects several consecutive missing packets. + */ + PropertyIBoolean mvResendBatchingActive; + /// \brief An integer property. Defines the maximum gap between 2 consecutive packets in the stream. + /** + * This feature defines the maximum gap between 2 consecutive packets in the stream. If a detected gap larger than 'MaximumGapSize' this block is considered as incomplete. When this parameter is 0 no gap will be considered as too big! + */ + PropertyI64 mvResendMaximumGapSize; + /// \brief An integer property. Indicates the resend threshold within the capture window. + /** + * This feature indicates the resend threshold within the capture window. If current packet ID and first missing packet ID are mvResendThreshold IDs apart the stream will issue a resend request. + */ + PropertyI64 mvResendThreshold; + /// \brief An integer property. Indicates the maximum number of resend requests per packet to send to the device until the packet is considered as lost. + /** + * This feature indicates the maximum number of resend requests per packet to send to the device until the packet is considered as lost. + */ + PropertyI64 mvResendRequestMax; + /// \brief A floating point property. Indicates the maximum number of resend requests in percent of payload packets per buffer to send to the device until the packet is considered as lost. + /** + * This feature indicates the maximum number of resend requests in percent of payload packets per buffer to send to the device until the packet is considered as lost. + */ + PropertyF mvResendRequestCredits; + /// \brief An integer property. This feature controls the resend response timeout in milliseconds. + /** + * This float value sets the resend response timeout in milliseconds. Whenever a requested packet does not arrive within this timer period it will be requested again until mvResendRequestMax resend requests for this packet have been issued. + */ + PropertyI64 mvResendResponseTimeout; + /// \brief An integer property. Indicates the number of packets to be requested whenever the resend response timeout elapses. + /** + * This feature indicates the number of packets to be requested whenever the resend response timeout elapses. + */ + PropertyI64 mvResendsPerTimeout; + /// \brief A boolean property. This (PRELIMINARY) feature controls whether the host shall process incoming data on multiple CPUs or a single dedicated one. + /** + * This (PRELIMINARY) feature controls whether the host shall process incoming data on multiple CPUs or a single dedicated one. ATTENTION: CHANGES MAY BE APPLIED TO THIS FEATURE WITHOUT FURTHER NOTICE! USE IT FOR EVALUATION PURPOSES ONLY! + */ + PropertyIBoolean mvMultiCPUStreamProcessingEnable; + /// \brief An integer property. This (PRELIMINARY) feature controls how many CPUs will be used for the processing of network data for this stream. + /** + * This (PRELIMINARY) feature controls how many CPUs will be used for the processing of network data for this stream. ATTENTION: CHANGES MAY BE APPLIED TO THIS FEATURE WITHOUT FURTHER NOTICE! USE IT FOR EVALUATION PURPOSES ONLY! + */ + PropertyI64 mvMultiCPUStreamProcessingCPUCount; + /// \brief An integer property. This (PRELIMINARY) feature controls which is the first CPU to use for processing network data out of the list of CPUs available for this task for the NIC associated with this stream. + /** + * This (PRELIMINARY) feature controls which is the first CPU to use for processing network data out of the list of CPUs available for this task for the NIC associated with this stream. Please note that this number does NOT have a 1:1 relationship to the CPU in your system but to the CPUs available for processing on the selected NIC. So if e.g. the corresponding NICs RSS table can access CPUs 6, 8, 10 and 12 then setting 'mvMultiCPUStreamProcessingFirstCPUIndex' to 2 will result in CPUs 10 and 12 to be used! ATTENTION: CHANGES MAY BE APPLIED TO THIS FEATURE WITHOUT FURTHER NOTICE! USE IT FOR EVALUATION PURPOSES ONLY! + */ + PropertyI64 mvMultiCPUStreamProcessingFirstCPUIndex; + /// \brief An integer property. This (PRELIMINARY) feature controls after how many network packets the processing shall switch to another CPU. Smaller values introduce a higher overhead, values too high might result in loss of data when the network card runs out of buffers. The recommended values are in the range of 32 - 256. + /** + * This (PRELIMINARY) feature controls after how many network packets the processing shall switch to another CPU. Smaller values introduce a higher overhead, values too high might result in loss of data when the network card runs out of buffers. The recommended values are in the range of 32 - 256. ATTENTION: CHANGES MAY BE APPLIED TO THIS FEATURE WITHOUT FURTHER NOTICE! USE IT FOR EVALUATION PURPOSES ONLY! + */ + PropertyI64 mvMultiCPUStreamProcessingSwitchInterval; + /// \brief An integer property. Number of announced (known) buffers on this stream. This value is volatile. It may change if additional buffers are announced and/or buffers are revoked by the GenTL Consumer. + /** + * This is a read-only feature. It indicates the number of announced (known) buffers on this stream. This value is volatile. It may change if additional buffers are announced and/or buffers are revoked by the GenTL Consumer. + */ + PropertyI64 streamAnnouncedBufferCount; + /// \brief An enumerated integer property. Allows to select the buffer handling mode for the stream. + /** + * This enumeration allows the selection of the buffer handling mode for the stream. + * + * The following string values might be valid for this feature: + * - \b OldestFirst (Display string: 'OldestFirst'): This enumeration value indicates that this stream is using the default acquisition mode. + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 streamBufferHandlingMode; + /// \brief An integer property. Minimal number of buffers to announce to enable selected acquisition mode. + /** + * This feature indicates the minimal number of buffers to announce to enable selected acquisition mode. + */ + PropertyI64 streamAnnounceBufferMinimum; + /// \brief An integer property. Maximal number of buffers to announce to enable selected acquisition mode. + /** + * This feature indicates the maximal number of buffers to announce to enable selected acquisition mode. + */ + PropertyI64 mvStreamAnnounceBufferMaximum; + /// \brief An integer property. Number of delivered frames since last acquisition start. + /** + * This feature indicates the number of delivered frames since last acquisition start. It is not reset until the stream is closed. + */ + PropertyI64 streamDeliveredFrameCount; + /// \brief An integer property. Number of lost frames due to queue underrun. + /** + * This feature indicates the number of lost frames due to queue underrun. This number is initialized with zero at the time the stream is opened and incremented every time the data could not be acquired because there was no buffer in the input buffer pool. It is not reset until the stream is closed. + */ + PropertyI64 streamLostFrameCount; + /// \brief An integer property. Number of buffers in the input buffer pool plus the buffers(s) currently being filled. + /** + * This feature indicates the number of buffers in the input buffer pool plus the buffers(s) currently being filled. + */ + PropertyI64 streamInputBufferCount; + /// \brief An integer property. Number of buffers in the output buffer queue. + /** + * This feature indicates the number of buffers in the output buffer queue. + */ + PropertyI64 streamOutputBufferCount; + /// \brief An integer property. Number of frames started in the acquisition engine. + /** + * This feature indicates the number of frames started in the acquisition engine. This number is incremented every time in case of a new buffer is started and then to be filled (data written to) regardless even if the buffer is later delivered to the user or discarded for any reason. This number is initialized with 0 at the time the stream is opened. It is not reset until the stream is closed. + */ + PropertyI64 streamStartedFrameCount; + /// \brief An integer property. Provides the number of bytes transferred for each data buffer or chunk on the stream channel. + /** + * Provides the number of bytes transferred for each data buffer or chunk on the stream channel. This includes any end-of-line, end-of-frame statistics or other stamp data. This is the total size of data payload for a data block. + */ + PropertyI64 payloadSize; + /// \brief A boolean property. Flag indicating whether the acquisition engine is started or not. + /** + * This feature indicates whether the acquisition engine is started or not. This is independent from the acquisition status of the remote device. + */ + PropertyIBoolean streamIsGrabbing; + /// \brief An integer property. Maximum number of chunks to be expected in a buffer (can be used to allocate the array for the DSGetBufferChunkData function). + /** + * Maximum number of chunks to be expected in a buffer (can be used to allocate the array for the DSGetBufferChunkData function). + */ + PropertyI64 streamChunkCountMaximum; + /// \brief An integer property. Alignment size in bytes of the buffers passed to DSAnnounceBuffer. + /** + * This feature indicates the alignment size in bytes of the buffers passed to DSAnnounceBuffer. If a buffer is passed to DSAnnounceBuffer which is not aligned according to the alignment size it is up to the Producer to either reject the buffer and return a GC_ERR_INVALID_BUFFER error code or to cope with a potential overhead and use the unaligned buffer as is. + */ + PropertyI64 streamBufferAlignment; + /// \brief An enumerated integer property. Selects which Event to signal to the host application. + /** + * Selects which Event to signal to the host application. + * + * The following string values might be valid for this feature: + * - \b AcquisitionTrigger (Display string: 'Acquisition Trigger'): Device just received a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionTriggerMissed (Display string: 'Acquisition Trigger Missed'): Device just missed a trigger for the Acquisition of one or many Frames. + * - \b AcquisitionStart (Display string: 'Acquisition Start'): Device just started the Acquisition of one or many Frames. + * - \b AcquisitionEnd (Display string: 'Acquisition End'): Device just completed the Acquisition of one or many Frames. + * - \b AcquisitionTransferStart (Display string: 'Acquisition Transfer Start'): Device just started the transfer of one or many Frames. + * - \b AcquisitionTransferEnd (Display string: 'Acquisition Transfer End'): Device just completed the transfer of one or many Frames. + * - \b AcquisitionError (Display string: 'Acquisition Error'): Device just detected an error during the active Acquisition. + * - \b FrameBurstStart (Display string: 'Frame Burst Start'): Device just started the capture of a burst of Frames. + * - \b FrameBurstEnd (Display string: 'Frame Burst End'): Device just completed the capture of a burst of Frames. + * - \b FrameTrigger (Display string: 'Frame Trigger'): Device just received a trigger to start the capture of one Frame. + * - \b FrameTriggerMissed (Display string: 'Frame Trigger Missed'): Device just missed a trigger to start the capture of one Frame. + * - \b FrameStart (Display string: 'Frame Start'): Device just started the capture of one Frame. + * - \b FrameEnd (Display string: 'Frame End'): Device just completed the capture of one Frame. + * - \b FrameTransferStart (Display string: 'Frame Transfer Start'): Device just started the transfer of one Frame. + * - \b FrameTransferEnd (Display string: 'Frame Transfer End'): Device just completed the transfer of one Frame. + * - \b LineTrigger (Display string: 'Line Trigger'): Device just received a trigger to start the capture of one Line. + * - \b LineTriggerMissed (Display string: 'Line Trigger Missed'): Device just missed a trigger to start the capture of one Line. + * - \b LineStart (Display string: 'Line Start'): Device just started the capture of one Line. + * - \b LineEnd (Display string: 'Line End'): Device just completed the capture of one Line. + * - \b ExposureStart (Display string: 'Exposure Start'): Device just started the exposure of one Frame (or Line). + * - \b ExposureEnd (Display string: 'Exposure End'): Device just completed the exposure of one Frame (or Line). + * - \b Stream0TransferStart (Display string: 'Stream 0 Transfer Start'): Device just started the transfer of one or many Blocks. + * - \b Stream0TransferEnd (Display string: 'Stream 0 Transfer End'): Device just completed the transfer of one or many Blocks. + * - \b Stream0TransferPause (Display string: 'Stream 0 Transfer Pause'): Device just paused the transfer. + * - \b Stream0TransferResume (Display string: 'Stream 0 Transfer Resume'): Device just resumed the transfer. + * - \b Stream0TransferBlockStart (Display string: 'Stream 0 Transfer Block Start'): Device just started the transfer of one Block. + * - \b Stream0TransferBlockEnd (Display string: 'Stream 0 Transfer Block End'): Device just completed the transfer of one Block. + * - \b Stream0TransferBlockTrigger (Display string: 'Stream 0 Transfer Block Trigger'): Device just received a trigger to start the transfer of one Block. + * - \b Stream0TransferBurstStart (Display string: 'Stream 0 Transfer Burst Start'): Device just started the transfer of a burst of Blocks. + * - \b Stream0TransferBurstEnd (Display string: 'Stream 0 Transfer Burst End'): Device just completed the transfer of a burst of Blocks. + * - \b Stream0TransferOverflow (Display string: 'Stream 0 Transfer Overflow'): Device transfer queue overflowed. + * - \b SequencerSetChange (Display string: 'Sequencer Set Change'): Device sequencer set has changed. + * - \b Counter0Start (Display string: 'Counter 0 Start'): The event will be generated when counter 0 starts counting. + * - \b Counter1Start (Display string: 'Counter 1 Start'): The event will be generated when counter 1 starts counting. + * - \b Counter\#2\#Start (Display string: 'Counter \#2\# Start'): The event will be generated when counter \#2\# starts counting. + * - \b Counter0End (Display string: 'Counter 0 End'): The event will be generated when counter 0 ends counting. + * - \b Counter1End (Display string: 'Counter 1 End'): The event will be generated when counter 1 ends counting. + * - \b Counter\#2\#End (Display string: 'Counter \#2\# End'): The event will be generated when counter \#2\# ends counting. + * - \b Timer0Start (Display string: 'Timer 0 Start'): The event will be generated when Timer 0 starts counting. + * - \b Timer1Start (Display string: 'Timer 1 Start'): The event will be generated when Timer 1 starts counting. + * - \b Timer\#2\#Start (Display string: 'Timer \#2\# Start'): The event will be generated when Timer \#2\# starts counting. + * - \b Timer0End (Display string: 'Timer 0 End'): The event will be generated when Timer 0 ends counting. + * - \b Timer1End (Display string: 'Timer 1 End'): The event will be generated when Timer 1 ends counting. + * - \b Timer\#2\#End (Display string: 'Timer \#2\# End'): The event will be generated when Timer \#2\# ends counting. + * - \b Encoder0Stopped (Display string: 'Encoder 0 Stopped'): The event will be generated when the Encoder 0 stops for longer than EncoderTimeout. + * - \b Encoder1Stopped (Display string: 'Encoder 1 Stopped'): The event will be generated when the Encoder 1 stops for longer than EncoderTimeout. + * - \b Encoder\#2\#Stopped (Display string: 'Encoder \#2\# Stopped'): The event will be generated when the Encoder \#2\# stops for longer than EncoderTimeout. + * - \b Encoder0Restarted (Display string: 'Encoder 0 Restarted'): The event will be generated when the Encoder 0 restarts moving. + * - \b Encoder1Restarted (Display string: 'Encoder 1 Restarted'): The event will be generated when the Encoder 1 restarts moving. + * - \b Encoder\#2\#Restarted (Display string: 'Encoder \#2\# Restarted'): The event will be generated when the Encoder \#2\# restarts moving. + * - \b Line0RisingEdge (Display string: 'Line 0 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 0. + * - \b Line1RisingEdge (Display string: 'Line 1 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 1. + * - \b Line\#2\#RisingEdge (Display string: 'Line \#2\# Rising Edge'): The event will be generated when a Rising Edge is detected on the Line \#2\#. + * - \b Line0FallingEdge (Display string: 'Line 0 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 0. + * - \b Line1FallingEdge (Display string: 'Line 1 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 1. + * - \b Line\#2\#FallingEdge (Display string: 'Line \#2\# Falling Edge'): The event will be generated when a Falling Edge is detected on the Line \#2\#. + * - \b Line0AnyEdge (Display string: 'Line 0 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 0. + * - \b Line1AnyEdge (Display string: 'Line 1 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 1. + * - \b Line\#2\#AnyEdge (Display string: 'Line \#2\# Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line \#2\#. + * - \b LinkTrigger0 (Display string: 'Link Trigger 0'): The event will be generated when a Rising Edge is detected on the LinkTrigger 0. + * - \b LinkTrigger1 (Display string: 'Link Trigger 1'): The event will be generated when a Rising Edge is detected on the LinkTrigger 1. + * - \b LinkTrigger\#2\# (Display string: 'Link Trigger \#2\#'): The event will be generated when a Rising Edge is detected on the LinkTrigger \#2\#. + * - \b LinkSpeedChange (Display string: 'Link Speed Change'): The event will be generated when the link speed has changed. + * - \b ActionLate (Display string: 'Action Late'): The event will be generated when a valid scheduled action command is received and is scheduled to be executed at a time that is already past. + * - \b Error (Display string: 'Error'): Device just detected an error during the active Acquisition. + * - \b Test (Display string: 'Test'): The test event will be generated when the device receives the TestEventGenerate command (EventNotification for the Test event is always On). + * - \b PrimaryApplicationSwitch (Display string: 'Primary Application Switch'): The event will be generated when a primary application switchover has been granted (GigE Vision Specific). + * - \b Counter2Start (Display string: 'Counter 2 Start'): The event will be generated when counter 2 starts counting. + * - \b Counter3Start (Display string: 'Counter 3 Start'): The event will be generated when counter 3 starts counting. + * - \b Counter4Start (Display string: 'Counter 4 Start'): The event will be generated when counter 4 starts counting. + * - \b Counter5Start (Display string: 'Counter 5 Start'): The event will be generated when counter 5 starts counting. + * - \b Counter6Start (Display string: 'Counter 6 Start'): The event will be generated when counter 6 starts counting. + * - \b Counter7Start (Display string: 'Counter 7 Start'): The event will be generated when counter 7 starts counting. + * - \b Counter8Start (Display string: 'Counter 8 Start'): The event will be generated when counter 8 starts counting. + * - \b Counter9Start (Display string: 'Counter 9 Start'): The event will be generated when counter 9 starts counting. + * - \b Counter10Start (Display string: 'Counter 10 Start'): The event will be generated when counter 10 starts counting. + * - \b Counter11Start (Display string: 'Counter 11 Start'): The event will be generated when counter 11 starts counting. + * - \b Counter12Start (Display string: 'Counter 12 Start'): The event will be generated when counter 12 starts counting. + * - \b Counter13Start (Display string: 'Counter 13 Start'): The event will be generated when counter 13 starts counting. + * - \b Counter14Start (Display string: 'Counter 14 Start'): The event will be generated when counter 14 starts counting. + * - \b Counter15Start (Display string: 'Counter 15 Start'): The event will be generated when counter 15 starts counting. + * - \b Counter2End (Display string: 'Counter 2 End'): The event will be generated when counter 2 ends counting. + * - \b Counter3End (Display string: 'Counter 3 End'): The event will be generated when counter 3 ends counting. + * - \b Counter4End (Display string: 'Counter 4 End'): The event will be generated when counter 4 ends counting. + * - \b Counter5End (Display string: 'Counter 5 End'): The event will be generated when counter 5 ends counting. + * - \b Counter6End (Display string: 'Counter 6 End'): The event will be generated when counter 6 ends counting. + * - \b Counter7End (Display string: 'Counter 7 End'): The event will be generated when counter 7 ends counting. + * - \b Counter8End (Display string: 'Counter 8 End'): The event will be generated when counter 8 ends counting. + * - \b Counter9End (Display string: 'Counter 9 End'): The event will be generated when counter 9 ends counting. + * - \b Counter10End (Display string: 'Counter 10 End'): The event will be generated when counter 10 ends counting. + * - \b Counter11End (Display string: 'Counter 11 End'): The event will be generated when counter 11 ends counting. + * - \b Counter12End (Display string: 'Counter 12 End'): The event will be generated when counter 12 ends counting. + * - \b Counter13End (Display string: 'Counter 13 End'): The event will be generated when counter 13 ends counting. + * - \b Counter14End (Display string: 'Counter 14 End'): The event will be generated when counter 14 ends counting. + * - \b Counter15End (Display string: 'Counter 15 End'): The event will be generated when counter 15 ends counting. + * - \b Timer2Start (Display string: 'Timer 2 Start'): The event will be generated when Timer 2 starts counting. + * - \b Timer3Start (Display string: 'Timer 3 Start'): The event will be generated when Timer 3 starts counting. + * - \b Timer4Start (Display string: 'Timer 4 Start'): The event will be generated when Timer 4 starts counting. + * - \b Timer5Start (Display string: 'Timer 5 Start'): The event will be generated when Timer 5 starts counting. + * - \b Timer6Start (Display string: 'Timer 6 Start'): The event will be generated when Timer 6 starts counting. + * - \b Timer7Start (Display string: 'Timer 7 Start'): The event will be generated when Timer 7 starts counting. + * - \b Timer8Start (Display string: 'Timer 8 Start'): The event will be generated when Timer 8 starts counting. + * - \b Timer9Start (Display string: 'Timer 9 Start'): The event will be generated when Timer 9 starts counting. + * - \b Timer10Start (Display string: 'Timer 10 Start'): The event will be generated when Timer 10 starts counting. + * - \b Timer11Start (Display string: 'Timer 11 Start'): The event will be generated when Timer 11 starts counting. + * - \b Timer12Start (Display string: 'Timer 12 Start'): The event will be generated when Timer 12 starts counting. + * - \b Timer13Start (Display string: 'Timer 13 Start'): The event will be generated when Timer 13 starts counting. + * - \b Timer14Start (Display string: 'Timer 14 Start'): The event will be generated when Timer 14 starts counting. + * - \b Timer15Start (Display string: 'Timer 15 Start'): The event will be generated when Timer 15 starts counting. + * - \b Timer2End (Display string: 'Timer 2 End'): The event will be generated when Timer 2 ends counting. + * - \b Timer3End (Display string: 'Timer 3 End'): The event will be generated when Timer 3 ends counting. + * - \b Timer4End (Display string: 'Timer 4 End'): The event will be generated when Timer 4 ends counting. + * - \b Timer5End (Display string: 'Timer 5 End'): The event will be generated when Timer 5 ends counting. + * - \b Timer6End (Display string: 'Timer 6 End'): The event will be generated when Timer 6 ends counting. + * - \b Timer7End (Display string: 'Timer 7 End'): The event will be generated when Timer 7 ends counting. + * - \b Timer8End (Display string: 'Timer 8 End'): The event will be generated when Timer 8 ends counting. + * - \b Timer9End (Display string: 'Timer 9 End'): The event will be generated when Timer 9 ends counting. + * - \b Timer10End (Display string: 'Timer 10 End'): The event will be generated when Timer 10 ends counting. + * - \b Timer11End (Display string: 'Timer 11 End'): The event will be generated when Timer 11 ends counting. + * - \b Timer12End (Display string: 'Timer 12 End'): The event will be generated when Timer 12 ends counting. + * - \b Timer13End (Display string: 'Timer 13 End'): The event will be generated when Timer 13 ends counting. + * - \b Timer14End (Display string: 'Timer 14 End'): The event will be generated when Timer 14 ends counting. + * - \b Timer15End (Display string: 'Timer 15 End'): The event will be generated when Timer 15 ends counting. + * - \b Encoder2Stopped (Display string: 'Encoder 2 Stopped'): The event will be generated when the Encoder 2 stops for longer than EncoderTimeout. + * - \b Encoder3Stopped (Display string: 'Encoder 3 Stopped'): The event will be generated when the Encoder 3 stops for longer than EncoderTimeout. + * - \b Encoder4Stopped (Display string: 'Encoder 4 Stopped'): The event will be generated when the Encoder 4 stops for longer than EncoderTimeout. + * - \b Encoder5Stopped (Display string: 'Encoder 5 Stopped'): The event will be generated when the Encoder 5 stops for longer than EncoderTimeout. + * - \b Encoder6Stopped (Display string: 'Encoder 6 Stopped'): The event will be generated when the Encoder 6 stops for longer than EncoderTimeout. + * - \b Encoder7Stopped (Display string: 'Encoder 7 Stopped'): The event will be generated when the Encoder 7 stops for longer than EncoderTimeout. + * - \b Encoder8Stopped (Display string: 'Encoder 8 Stopped'): The event will be generated when the Encoder 8 stops for longer than EncoderTimeout. + * - \b Encoder9Stopped (Display string: 'Encoder 9 Stopped'): The event will be generated when the Encoder 9 stops for longer than EncoderTimeout. + * - \b Encoder10Stopped (Display string: 'Encoder 10 Stopped'): The event will be generated when the Encoder 10 stops for longer than EncoderTimeout. + * - \b Encoder11Stopped (Display string: 'Encoder 11 Stopped'): The event will be generated when the Encoder 11 stops for longer than EncoderTimeout. + * - \b Encoder12Stopped (Display string: 'Encoder 12 Stopped'): The event will be generated when the Encoder 12 stops for longer than EncoderTimeout. + * - \b Encoder13Stopped (Display string: 'Encoder 13 Stopped'): The event will be generated when the Encoder 13 stops for longer than EncoderTimeout. + * - \b Encoder14Stopped (Display string: 'Encoder 14 Stopped'): The event will be generated when the Encoder 14 stops for longer than EncoderTimeout. + * - \b Encoder15Stopped (Display string: 'Encoder 15 Stopped'): The event will be generated when the Encoder 15 stops for longer than EncoderTimeout. + * - \b Encoder2Restarted (Display string: 'Encoder 2 Restarted'): The event will be generated when the Encoder 2 restarts moving. + * - \b Encoder3Restarted (Display string: 'Encoder 3 Restarted'): The event will be generated when the Encoder 3 restarts moving. + * - \b Encoder4Restarted (Display string: 'Encoder 4 Restarted'): The event will be generated when the Encoder 4 restarts moving. + * - \b Encoder5Restarted (Display string: 'Encoder 5 Restarted'): The event will be generated when the Encoder 5 restarts moving. + * - \b Encoder6Restarted (Display string: 'Encoder 6 Restarted'): The event will be generated when the Encoder 6 restarts moving. + * - \b Encoder7Restarted (Display string: 'Encoder 7 Restarted'): The event will be generated when the Encoder 7 restarts moving. + * - \b Encoder8Restarted (Display string: 'Encoder 8 Restarted'): The event will be generated when the Encoder 8 restarts moving. + * - \b Encoder9Restarted (Display string: 'Encoder 9 Restarted'): The event will be generated when the Encoder 9 restarts moving. + * - \b Encoder10Restarted (Display string: 'Encoder 10 Restarted'): The event will be generated when the Encoder 10 restarts moving. + * - \b Encoder11Restarted (Display string: 'Encoder 11 Restarted'): The event will be generated when the Encoder 11 restarts moving. + * - \b Encoder12Restarted (Display string: 'Encoder 12 Restarted'): The event will be generated when the Encoder 12 restarts moving. + * - \b Encoder13Restarted (Display string: 'Encoder 13 Restarted'): The event will be generated when the Encoder 13 restarts moving. + * - \b Encoder14Restarted (Display string: 'Encoder 14 Restarted'): The event will be generated when the Encoder 14 restarts moving. + * - \b Encoder15Restarted (Display string: 'Encoder 15 Restarted'): The event will be generated when the Encoder 15 restarts moving. + * - \b Line2RisingEdge (Display string: 'Line 2 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 2. + * - \b Line3RisingEdge (Display string: 'Line 3 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 3. + * - \b Line4RisingEdge (Display string: 'Line 4 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 4. + * - \b Line5RisingEdge (Display string: 'Line 5 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 5. + * - \b Line6RisingEdge (Display string: 'Line 6 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 6. + * - \b Line7RisingEdge (Display string: 'Line 7 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 7. + * - \b Line8RisingEdge (Display string: 'Line 8 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 8. + * - \b Line9RisingEdge (Display string: 'Line 9 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 9. + * - \b Line10RisingEdge (Display string: 'Line 10 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 10. + * - \b Line11RisingEdge (Display string: 'Line 11 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 11. + * - \b Line12RisingEdge (Display string: 'Line 12 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 12. + * - \b Line13RisingEdge (Display string: 'Line 13 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 13. + * - \b Line14RisingEdge (Display string: 'Line 14 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 14. + * - \b Line15RisingEdge (Display string: 'Line 15 Rising Edge'): The event will be generated when a Rising Edge is detected on the Line 15. + * - \b Line2FallingEdge (Display string: 'Line 2 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 2. + * - \b Line3FallingEdge (Display string: 'Line 3 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 3. + * - \b Line4FallingEdge (Display string: 'Line 4 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 4. + * - \b Line5FallingEdge (Display string: 'Line 5 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 5. + * - \b Line6FallingEdge (Display string: 'Line 6 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 6. + * - \b Line7FallingEdge (Display string: 'Line 7 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 7. + * - \b Line8FallingEdge (Display string: 'Line 8 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 8. + * - \b Line9FallingEdge (Display string: 'Line 9 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 9. + * - \b Line10FallingEdge (Display string: 'Line 10 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 10. + * - \b Line11FallingEdge (Display string: 'Line 11 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 11. + * - \b Line12FallingEdge (Display string: 'Line 12 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 12. + * - \b Line13FallingEdge (Display string: 'Line 13 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 13. + * - \b Line14FallingEdge (Display string: 'Line 14 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 14. + * - \b Line15FallingEdge (Display string: 'Line 15 Falling Edge'): The event will be generated when a Falling Edge is detected on the Line 15. + * - \b Line2AnyEdge (Display string: 'Line 2 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 2. + * - \b Line3AnyEdge (Display string: 'Line 3 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 3. + * - \b Line4AnyEdge (Display string: 'Line 4 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 4. + * - \b Line5AnyEdge (Display string: 'Line 5 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 5. + * - \b Line6AnyEdge (Display string: 'Line 6 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 6. + * - \b Line7AnyEdge (Display string: 'Line 7 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 7. + * - \b Line8AnyEdge (Display string: 'Line 8 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 8. + * - \b Line9AnyEdge (Display string: 'Line 9 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 9. + * - \b Line10AnyEdge (Display string: 'Line 10 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 10. + * - \b Line11AnyEdge (Display string: 'Line 11 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 11. + * - \b Line12AnyEdge (Display string: 'Line 12 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 12. + * - \b Line13AnyEdge (Display string: 'Line 13 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 13. + * - \b Line14AnyEdge (Display string: 'Line 14 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 14. + * - \b Line15AnyEdge (Display string: 'Line 15 Any Edge'): The event will be generated when a Falling or Rising Edge is detected on the Line 15. + * - \b Link0Trigger (Display string: 'Link 0 Trigger') + * - \b Link1Trigger (Display string: 'Link 1 Trigger') + * - \b Link2Trigger (Display string: 'Link 2 Trigger') + * - \b Link3Trigger (Display string: 'Link 3 Trigger') + * - \b Link4Trigger (Display string: 'Link 4 Trigger') + * - \b Link5Trigger (Display string: 'Link 5 Trigger') + * - \b Link6Trigger (Display string: 'Link 6 Trigger') + * - \b Link7Trigger (Display string: 'Link 7 Trigger') + * - \b Link8Trigger (Display string: 'Link 8 Trigger') + * - \b Link9Trigger (Display string: 'Link 9 Trigger') + * - \b Link10Trigger (Display string: 'Link 10 Trigger') + * - \b Link11Trigger (Display string: 'Link 11 Trigger') + * - \b Link12Trigger (Display string: 'Link 12 Trigger') + * - \b Link13Trigger (Display string: 'Link 13 Trigger') + * - \b Link14Trigger (Display string: 'Link 14 Trigger') + * - \b Link15Trigger (Display string: 'Link 15 Trigger') + * - \b InterfaceListChanged (Display string: 'Interface List Changed'): This enumeration value indicates an event that is fired when the list of interfaces has been updated. + * - \b InterfaceLost (Display string: 'Interface Lost'): This enumeration value indicates an event that is raised when the interface connection is lost. + * - \b DeviceListChanged (Display string: 'Device List Changed'): This enumeration value indicates an event that is fired when the list of devices has been updated. + * - \b DeviceLost (Display string: 'Device Lost'): This enumeration value indicates an event that is raised when the local host looses connection to the physical(remote) device. + * - \b BufferTooSmall (Display string: 'Buffer Too Small'): This enumeration value indicates an event that is raised when the buffer was too small to receive the expected amount of data. + * - \b BuffersDiscarded (Display string: 'Buffers Discarded'): This enumeration value indicates an event that is raised when buffers discared by GenTL or device. This event could optionally carry two numeric child data fields EventBuffersDiscardedDeviceCount and EventBuffersDiscardedProducerCount. + * - \b BuffersDiscardedDeviceCount (Display string: 'Buffers Discarded Device Count'): This enumeration value indicates the number of buffers discarded by the device since last fired instance of this event (the producer would get to know about this for example by observing a gap in the block_id sequence). + * - \b BuffersDiscardedProducerCount (Display string: 'Buffers Discarded Producer Count'): This enumeration value indicates the number of buffers discarded by the producer since last fired instance of this event (this would happen e.g. if there are no free buffers available or if given buffer handling mode requires discarding old buffers etc.). + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventSelector; + /// \brief An enumerated integer property. Activate or deactivate the notification to the host application of the occurrence of the selected Event. + /** + * Activate or deactivate the notification to the host application of the occurrence of the selected Event. + * + * The following string values might be valid for this feature: + * - \b Off (Display string: 'Off'): The selected Event notification is disabled. + * - \b On (Display string: 'On'): The selected Event notification is enabled. + * - \b Once (Display string: 'Once'): The selected Event notification is enabled for one event then return to Off state. + * - \b GigEVisionEvent (Display string: 'Gig E Vision Event') + * + * \note Depending on the device some of these values might not be supported and especially when working with third party devices there might be custom values which are not listed here. + * To get a complete and reliable list of supported values at runtime an application should therefore call mvIMPACT::acquire::EnumPropertyI::getTranslationDictStrings() or one of the other functions dealing with translation dictionaries for enumerated properties. + */ + PropertyI64 eventNotification; + // *INDENT-OFF* + PYTHON_OR_JAVA_ONLY( %mutable; ) + // *INDENT-ON* +}; + +} // namespace GenICam +} // namespace acquire +} // namespace mvIMPACT + +#endif //mvIMPACT_acquire_GenICam_CPP_autogen_h diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_CustomCommands.h b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_CustomCommands.h new file mode 100644 index 0000000..1b648f4 --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_CustomCommands.h @@ -0,0 +1,1045 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#include + +#ifndef WRAP_ANY +# include +# include +#endif // #ifndef WRAP_ANY + +#ifdef _MSC_VER // is Microsoft compiler? +# pragma warning( push ) +# if _MSC_VER < 1300 // is 'old' VC 6 compiler? +# pragma warning( disable : 4786 ) // 'identifier was truncated to '255' characters in the debug information' +# define __FUNCTION__ "No function name information as the __FUNCTION__ macro is not supported by this(VC 6) compiler" +# pragma message( "WARNING: This header(" __FILE__ ") uses the __FUNCTION__ macro, which is not supported by this compiler. A default definition(\"" __FUNCTION__ "\") will be used!" ) +# pragma message( "WARNING: This header(" __FILE__ ") uses inheritance for exception classes. However this compiler can't handle this correctly. Trying to catch a specific exception by writing a catch block for a base class will not work!" ) +# endif // #if _MSC_VER < 1300 +# pragma warning( disable : 4512 ) // 'assignment operator could not be generated' (reason: assignment operators declared 'private' but not implemented) +#endif // #ifdef _MSC_VER + +#ifndef WRAP_ANY +# if CHAR_BIT != 8 +# error "unsupported char size" +# endif +#endif // #ifndef WRAP_ANY + +#include // C-API header will be imported into mvIMPACT::acquire::GenICam if included from here + +namespace mvIMPACT +{ +namespace acquire +{ +namespace GenICam +{ + +//----------------------------------------------------------------------------- +/// \brief Contains convenience functions to control features understood by a devices custom command interpreter. +/** + * Contains convenience functions to control features understood by a devices custom command interpreter. + * \note Creating an instance of this class will only succeed when the device associated with this object + * supports the mvIMPACT::acquire::GenICam::mvCustomData.mvCustomCommandBuffer feature. If the + * feature is not supported an exception will be raised! + * + * This class will allow to create various special commands understood by MATRIX VISION GmbH devices. + * For example an application can modify parameters in a running sequencer program without stopping the + * acquisition engine and/or the sequencer program + * (see mvIMPACT::acquire::GenICam::SequencerControl and the corresponding use cases for details). + * This allows changes to be applied much faster than with a conventional approach which would work like this: + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * mvIMPACT::acquire::GenICam::AcquisitionControl ac( getDevicePointerFromSomewhere() ); + * mvIMPACT::acquire::GenICam::SequencerControl sc( getDevicePointerFromSomewhere() ); + * sc.sequencerMode.writeS( "Off" ); + * sc.sequencerConfigurationMode.writeS( "On" ); + * sc.sequencerSetSelector.write( 2 ); + * sc.sequencerSetLoad.call(); // needed as otherwise other parameters in the set might get changed as well. + * ac.exposureTime.write( 20000 ); + * sc.sequencerSetSave.call(); + * sc.sequencerConfigurationMode.writeS( "Off" ); + * sc.sequencerMode.writeS( "On" ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * AcquisitionControl ac = new AcquisitionControl( getDevicePointerFromSomewhere() ); + * SequencerControl sc = new SequencerControl( getDevicePointerFromSomewhere() ); + * sc.getSequencerMode().writeS( "Off" ); + * sc.getSequencerConfigurationMode().writeS( "On" ); + * sc.getSequencerSetSelector().write( 2 ); + * sc.getSequencerSetLoad().call(); // needed as otherwise other parameters in the set might get changed as well. + * ac.getExposureTime().write( 20000 ); + * sc.getSequencerSetSave().call(); + * sc.getSequencerConfigurationMode().writeS( "Off" ); + * sc.getSequencerMode().writeS( "On" ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * ac = acquire.AcquisitionControl(getDeviceReferenceFromSomewhere()) + * sc = acquire.SequencerControl(getDeviceReferenceFromSomewhere()) + * sc.sequencerMode.writeS("Off") + * sc.sequencerConfigurationMode.writeS("On") + * sc.sequencerSetSelector.write(2) + * sc.sequencerSetLoad.call() # needed as otherwise other parameters in the set might get changed as well. + * ac.exposureTime.write(20000) + * sc.sequencerSetSave.call() + * sc.sequencerConfigurationMode.writeS("Off") + * sc.sequencerMode.writeS("On") + * \endcode + * \endif + * + * A single parameter in a defined sequencer set can be modified much faster at runtime like this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * mvIMPACT::acquire::GenICam::CustomCommandGenerator ccg( getDevicePointerFromSomewhere() ); + * // change the exposure time in sequencer set 2 to 30000 us. + * ccg.modifySequencerSetValue( 2, sspExposureTime, 30000 ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * CustomCommandGenerator ccg = new CustomCommandGenerator( getDevicePointerFromSomewhere() ); + * // change the exposure time in sequencer set 2 to 30000 us. + * ccg.modifySequencerSetValue( 2, TSequencerSetParameter.sspExposureTime, 30000 ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * ccg = acquire.CustomCommandGenerator(getDeviceReferenceFromSomewhere()) + * # change the exposure time in sequencer set 2 to 30000 us. + * ccg.modifySequencerSetValue(2, acquire.sspExposureTime, 30000) + * \endcode + * \endif + * + * \attention In a real world application the instance of mvIMPACT::acquire::GenICam::CustomCommandGenerator should be a member of a class + * or stored elsewhere as constructing objects from the mvIMPACT::acquire::GenICam namespace is taking time so this shouldn't be done for each command + * that shall be sent! + * + * This class uses an internal command buffer which allows an application to send multiple change commands in a single packet. + * This can be achieved like this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * mvIMPACT::acquire::GenICam::CustomCommandGenerator ccg( getDevicePointerFromSomewhere() ); + * // queue 2 parameter change requests + * // change the \c AnalogAll gain in sequencer set 0 to 3.14 dB. + * ccg.queueSequencerSetValueModification( 0, sspGain_AnalogAll, 3.14 ); + * // change the exposure time in sequencer set 1 to 20000 us. + * ccg.queueSequencerSetValueModification( 1, sspExposureTime, 20000 ); + * // send the 2 modifications in a single package + * ccg.sendCommandBuffer(); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * CustomCommandGenerator ccg = new CustomCommandGenerator( getDevicePointerFromSomewhere() ); + * // queue 2 parameter change requests + * // change the \c AnalogAll gain in sequencer set 0 to 3.14 dB. + * ccg.queueSequencerSetValueModification( 0, TSequencerSetParameter.sspGain_AnalogAll, 3.14 ); + * // change the exposure time in sequencer set 1 to 20000 us. + * ccg.queueSequencerSetValueModification( 1, TSequencerSetParameter.sspExposureTime, 20000 ); + * // send the 2 modifications in a single package + * ccg.sendCommandBuffer(); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * ccg = acquire.CustomCommandGenerator(getDeviceReferenceFromSomewhere()) + * # queue 2 parameter change requests + * # change the \c AnalogAll gain in sequencer set 0 to 3.14 dB. + * ccg.queueSequencerSetValueModification(0, acquire.sspGain_AnalogAll, 3.14) + * # change the exposure time in sequencer set 1 to 20000 us. + * ccg.queueSequencerSetValueModification(1, acquire.sspExposureTime, 20000) + * # send the 2 modifications in a single package + * ccg.sendCommandBuffer() + * \endcode + * \endif + * + * The command queue NEVER overflows. When no more data can be stored in the queue before queuing the next parameter + * change all the pending changes will be transmitted to the device. Calling mvIMPACT::acquire::GenICam::CustomCommandGenerator.queueSequencerSetValueModification + * and mvIMPACT::acquire::GenICam::CustomCommandGenerator.sendCommandBuffer directly afterwards is equivalent to call + * mvIMPACT::acquire::GenICam::CustomCommandGenerator.modifySequencerSetValue. So the previous example can also be rewritten like this: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * mvIMPACT::acquire::GenICam::CustomCommandGenerator ccg( getDevicePointerFromSomewhere() ); + * // queue 2 parameter change requests + * // change the \c AnalogAll gain in sequencer set 0 to 3.14 dB. + * ccg.queueSequencerSetValueModification( 0, sspGain_AnalogAll, 3.14 ); + * // change the exposure time in sequencer set 1 to 20000 us and send both requests to the device in a single packet. + * ccg.modifySequencerSetValue( 1, sspExposureTime, 20000 ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * CustomCommandGenerator ccg = new CustomCommandGenerator( getDevicePointerFromSomewhere() ); + * // queue 2 parameter change requests + * // change the \c AnalogAll gain in sequencer set 0 to 3.14 dB. + * ccg.queueSequencerSetValueModification( 0, TSequencerSetParameter.sspGain_AnalogAll, 3.14 ); + * // change the exposure time in sequencer set 1 to 20000 us and send both requests to the device in a single packet. + * ccg.modifySequencerSetValue( 1, TSequencerSetParameter.sspExposureTime, 20000 ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * ccg = acquire.CustomCommandGenerator(getDeviceReferenceFromSomewhere ()) + * # queue 2 parameter change requests + * # change the \c AnalogAll gain in sequencer set 0 to 3.14 dB. + * ccg.queueSequencerSetValueModification(0, acquire.sspGain_AnalogAll, 3.14) + * # change the exposure time in sequencer set 1 to 20000 us and send both requests to the device in a single packet. + * ccg.modifySequencerSetValue(1, acquire.sspExposureTime, 20000) + * \endcode + * \endif + * + * Because there can never be an overflow of the command queue even this code is valid: + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * for( int i = 0; i < 100; i += 2 ) + * { + * // if the command buffer is full everything should be sent to the device thus no error should be returned here + * ccg.queueSequencerSetValueModification( i % 5, sspCounterDuration_Counter1, i * 100 ); + * ccg.queueSequencerSetValueModification( i % 5, sspExposureTime, ac.exposureTime.getMinValue() + static_cast( i * 10 ) ); + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * for( int i = 0; i < 100; i += 2 ) + * { + * // if the command buffer is full everything should be sent to the device thus no error should be returned here + * ccg.queueSequencerSetValueModification( i % 5, TSequencerSetParameter.sspCounterDuration_Counter1, i * 100 ); + * ccg.queueSequencerSetValueModification( i % 5, TSequencerSetParameter.sspExposureTime, ac.getExposureTime().getMinValue() + ( i * 10.0 ) ); + * } + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * for i in range(0, 100, 2): + * # if the command buffer is full everything should be sent to the device thus no error should be returned here + * ccg.queueSequencerSetValueModification(i % 5, acquire.sspCounterDuration_Counter1, i * 100) + * ccg.queueSequencerSetValueModification(i % 5, acquire.sspExposureTime, ac.exposureTime.getMinValue() + (i * 10)) + * \endcode + * \endif + * + * Apart from modifying sequencer sets at runtime some MATRIX VISION GmbH devices support the so called Smart Frame Recall feature. + * For more information about the feature itself please refer to the corresponding use case in the product documentation. There is also a C++ example + * called \b GenICamSmartFrameRecallUsage.cpp which can be read to get a first glimpse. The source code and the documentation of this example can be found in the C++ + * version of this documentation. The mvIMPACT::acquire::GenICam::CustomCommandGenerator provides functions to request a full resolution + * version of an image based on a mvIMPACT::acquire::Request object containing an image with + * reduced resolution passed to it (internally the relevant piece of information is the timestamp of the image to request). To request an image an + * application can call one of the various versions of the mvIMPACT::acquire::GenICam::CustomCommandGenerator.requestTransmission functions. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * int getNextRandomValue( int min, int max ) + * { + * return ( rand() % ( max - min ) ) + min; + * } + * //... + * + * // switch on the smart frame recall feature + * mvIMPACT::acquire::GenICam::AcquisitionControl ac( pDev ); + * ac.mvSmartFrameRecallEnable.write( bTrue ); + * // more code + * Request* pRequest = getRequestFromSomewhere(); + * // request the transmission of an arbitrary ROI of this image in full resolution + * int w = getNextRandomValue( 1, pRequest->imageWidth.read() ); + * int h = getNextRandomValue( 1, pRequest->imageHeight.read() ); + * int x = getNextRandomValue( 0, pRequest->imageWidth.read() - w ); + * int y = getNextRandomValue( 0, pRequest->imageHeight.read() - h ); + * ccg.requestTransmission( pRequest, x, y, w, h, rtmFullResolution ); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * import java.util.concurrent.ThreadLocalRandom; // for random number! + * + * // ... more code, class definition, etc. + * + * public static int getNextRandomValue( int min, int max ) + * { + * return ThreadLocalRandom.current().nextInt( min, max + 1 ); + * } + * + * // ... more code, function body, etc. + * + * CustomCommandGenerator ccg = new CustomCommandGenerator( pDev ); + * //... + * + * // switch on the smart frame recall feature + * AcquisitionControl ac = new AcquisitionControl( pDev ); + * ac.getMvSmartFrameRecallEnable().write( TBoolean.bTrue ); + * // more code + * Request pRequest = getRequestFromSomewhere(); + * // request the transmission of an arbitrary ROI of this image in full resolution + * int w = getNextRandomValue( 1, pRequest.getImageWidth().read() ); + * int h = getNextRandomValue( 1, pRequest.getImageHeight().read() ); + * int x = getNextRandomValue( 0, pRequest.getImageWidth().read() - w ); + * int y = getNextRandomValue( 0, pRequest.getImageHeight().read() - h ); + * ccg.requestTransmission( pRequest, x, y, w, h, TRequestTransmissionMode.rtmFullResolution ); + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * def getNextRandomValue(min, max): + * value = min + int((max - min + 1) * random.uniform(0, 1)) + * if(value < min): + * return min + * if(value > max): + * return max + * return value + * ... + * # switch on the smart frame recall feature + * ac = acquire.AcquisitionControl( pDev ) + * ac.mvSmartFrameRecallEnable.write( acquire.bTrue ) + * # more code + * pRequest = getRequestFromSomewhere() + * # request the transmission of an arbitrary ROI of this image in full resolution + * w = getNextRandomValue(1, pRequest.getImageWidth.read()) + * h = getNextRandomValue(1, pRequest.getImageHeight.read()) + * x = getNextRandomValue(0, pRequest.getImageWidth.read() - w) + * y = getNextRandomValue(0, pRequest.getImageHeight.read() - h) + * ccg.requestTransmission(pRequest, x, y, w, h, acquire.rtmFullResolution) + * \endcode + * \endif + * + * To allow the application to distinguish easily between images belonging to the reduced data stream and the ones that have been explicitly requested + * by the application the mvIMPACT::acquire::Request.chunkmvCustomIdentifier can be used. When requesting a full resolution ROI the application can + * tag the requested images with a custom identifier. This identifier is later returned in the chunk data of the image. The following example demonstrates + * how to use this feature: + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // switch on the smart frame recall feature + * mvIMPACT::acquire::GenICam::AcquisitionControl ac( pDev ); + * ac.mvSmartFrameRecallEnable.write( bTrue ); + * // the chunk mode must be switched on to use chunk data for processing: + * mvIMPACT::acquire::GenICam::ChunkDataControl cdc( getDevicePointerFromSomewhere() ); + * cdc.chunkModeActive.write( bTrue ); + * cdc.chunkSelector.writeS("Image"); + * cdc.chunkEnable.write( bTrue ); + * // enable the 'mvCustomIdentifier' chunk + * cdc.chunkSelector.writeS("mvCustomIdentifier"); + * cdc.chunkEnable.write( bTrue ); + * // more code ... + * Request* pRequest = getRequestFromSomewhere(); + * uint customID = 42; + * if( pRequest->chunkmvCustomIdentifier.read() == 0 ) + * { + * // As the 'mvCustomIdentifier' is 0 this is a frame from the normal stream + * Rect r; + * if( doesImageContainInteresstingData( r ) ) + * { + * // request the transmission of the interesting ROI this image in full resolution + * ccg.requestTransmission( pRequest, r.x, r.y, r.w, r.h, rtmFullResolution, customID ); + * } + * } + * else if( pRequest->chunkmvCustomIdentifier.read() == static_cast( customID ) ) + * { + * // As the 'mvCustomIdentifier' is 'customID' this is a frame explicitly requested by the application + * processImage( pRequest ); + * } + * else + * { + * // some other ID (this however must have been set by the application as well) + * } + * // normal 'unlocking' code for requests should reside here!! + * // more code... + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * CustomCommandGenerator ccg = new CustomCommandGenerator( getDevicePointerFromSomewhere() ); + * // switch on the smart frame recall feature + * AcquisitionControl ac = new AcquisitionControl( getDevicePointerFromSomewhere() ); + * ac.getMvSmartFrameRecallEnable().write( TBoolean.bTrue ); + * // the chunk mode must be switched on to use chunk data for processing: + * ChunkDataControl cdc = new ChunkDataControl( getDevicePointerFromSomewhere() ); + * cdc.getChunkModeActive().write( TBoolean.bTrue ); + * cdc.getChunkSelector().writeS("Image"); + * cdc.getChunkEnable().write( TBoolean.bTrue ); + * // enable the 'mvCustomIdentifier' chunk + * cdc.getChunkSelector().writeS( "mvCustomIdentifier" ); + * cdc.getChunkEnable().write( TBoolean.bTrue ); + * // more code ... + * long customID = 42; + * Request pRequest = getRequestFromSomewhere(); + * if( pRequest.getChunkmvCustomIdentifier().read() == 0 ) + * { + * // As the 'mvCustomIdentifier' is 0 this is a frame from the normal stream + * Rectangle r = new Rectangle(); + * if( doesImageContainInteresstingData( r ) ) + * { + * // request the transmission of the interesting ROI this image in full resolution + * ccg.requestTransmission( pRequest, r.x, r.y, r.w, r.h, TRequestTransmissionMode.rtmFullResolution, customID ); + * } + * } + * else if( pRequest.getChunkmvCustomIdentifier.read() == customID ) + * { + * // As the 'mvCustomIdentifier' is 'customID' this is a frame explicitly requested by the application + * processImage( pRequest ); + * } + * else + * { + * // some other ID (this however must have been set by the application as well) + * } + * // normal 'unlocking' code for requests should reside here!! + * // more code... + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * ccg = acquire.CustomCommandGenerator(getDeviceReferenceFromSomewhere()) + * # switch on the smart frame recall feature + * ac = acquire.AcquisitionControl(getDeviceReferenceFromSomewhere()) + * ac.mvSmartFrameRecallEnable.write(acquire.bTrue) + * # the chunk mode must be switched on to use chunk data for processing: + * cdc = acquire.ChunkDataControl(getDeviceReferenceFromSomewhere()) + * cdc.chunkModeActive.write(acquire.bTrue) + * cdc.chunkSelector.writeS("Image") + * cdc.chunkEnable.write(acquire.bTrue) + * # enable the 'mvCustomIdentifier' chunk + * cdc.chunkSelector.writeS("mvCustomIdentifier") + * cdc.chunkEnable.write(acquire.bTrue) + * # more code ... + * pRequest = getRequestFromSomewhere() + * customID = 42 + * if pRequest.chunkmvCustomIdentifier.read() == 0: + * # As the 'mvCustomIdentifier' is 0 this is a frame from the normal stream + * Rect r # assuming this to be a valid Python class for a rectangle + * if doesImageContainInteresstingData(r): + * # request the transmission of the interesting ROI this image in full resolution + * ccg.requestTransmission(pRequest, r.x, r.y, r.w, r.h, acquire.rtmFullResolution, customID) + * elif pRequest.chunkmvCustomIdentifier.read() == customID: + * # As the 'mvCustomIdentifier' is 'customID' this is a frame explicitly requested by the application + * processImage(pRequest) + * else: + * # some other ID (this however must have been set by the application as well) + * # normal 'unlocking' code for requests should reside here!! + * # more code... + * \endcode + * \endif + * + * \since 2.18.0 + * \ingroup GenICamInterfaceDevice + */ +class CustomCommandGenerator +//----------------------------------------------------------------------------- +{ +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + enum THostByteOrder + { + O32_LITTLE_ENDIAN = 0x03020100ul, + //O32_PDP_ENDIAN = 0x01000302ul, // we don't handle PDP endianess here! + O32_BIG_ENDIAN = 0x00010203ul + }; + class O32HostByteOrderEvaluator + { + union Helper + { + unsigned char bytes[4]; + uint32_type value; + } h_; + public: + explicit O32HostByteOrderEvaluator() + { + for( unsigned char i = 0; i < 4; i++ ) + { + h_.bytes[i] = i; + } + } + THostByteOrder get32BitHostByteOrder( void ) const + { + return static_cast( h_.value ); + } + }; + +protected: + template + _Ty hostToNet16( _Ty value ) + { + switch( O32HostByteOrderEvaluator_.get32BitHostByteOrder() ) + { + case O32_LITTLE_ENDIAN: + return ( ( value & 0xff00 ) >> 8 ) | ( ( value & 0x00ff ) << 8 ); + case O32_BIG_ENDIAN: + break; + } + return value; + } + template + _Ty hostToNet32( _Ty value ) + { + switch( O32HostByteOrderEvaluator_.get32BitHostByteOrder() ) + { + case O32_LITTLE_ENDIAN: + return ( ( value & 0xff000000 ) >> 24 ) | ( ( value & 0x00ff0000 ) >> 8 ) | ( ( value & 0x0000ff00 ) << 8 ) | ( ( value & 0x000000ff ) << 24 ); + case O32_BIG_ENDIAN: + break; + } + return value; + } + mvCustomData cd_; + O32HostByteOrderEvaluator O32HostByteOrderEvaluator_; + auto_array_ptr commandBuffer_; + size_t currentCommandBufferOffset_; + int16_type currentCommandRequestID_; + int16_type mvCustomCommandInterpreterVersionMajor_; + int16_type mvCustomCommandInterpreterVersionMinor_; + + bool checkMinInterpreterVersion( int16_type versionMajor, int16_type versionMinor ) const + { + if( mvCustomCommandInterpreterVersionMajor_ < versionMajor ) + { + return false; + } + if( mvCustomCommandInterpreterVersionMajor_ > versionMajor ) + { + return true; + } + return mvCustomCommandInterpreterVersionMinor_ >= versionMinor; + } + void prepareCommandBuffer( void ) + { + commandBuffer_.realloc( cd_.mvCustomCommandBuffer.binaryDataBufferMaxSize() ); + memset( commandBuffer_.get(), 0, commandBuffer_.parCnt() ); + currentCommandBufferOffset_ = sizeof( CustomCommandProtocolHeader ); + } + void prepareCommandProtocolHeader( char* pBuf, const uint16_type commandSize ) + { + CustomCommandProtocolHeader* pHeader = reinterpret_cast( pBuf ); + pHeader->interpreterVersionMajor = hostToNet16( uint16_type( mvCustomCommandInterpreterVersionMajor_ ) ); + pHeader->interpreterVersionMinor = hostToNet16( uint16_type( mvCustomCommandInterpreterVersionMinor_ ) ); + pHeader->totalMessageLength = hostToNet16( commandSize ); + pHeader->request_id = hostToNet16( currentCommandRequestID_++ ); + } + void prepareCustomCommandHeader( char* pBuf, const TCustomCommand command, const size_t messageLength ) + { + CustomCommandHeader* pPacket = reinterpret_cast( pBuf ); + pPacket->command = hostToNet16( uint16_type( command ) ); + pPacket->messageLength = hostToNet16( uint16_type( messageLength ) ); + } + void prepareCustomCommandUpdateSequencerSet( char* pBuf, const TCustomCommand command, const size_t messageLength, const int64_type sequencerSet, const TSequencerSetParameter parameter ) + { + prepareCustomCommandHeader( pBuf, command, messageLength ); + CustomCommandUpdateSequencerSet* pPacket = ( CustomCommandUpdateSequencerSet* )( pBuf ); + pPacket->sequencerSet = hostToNet16( static_cast( sequencerSet ) ); + pPacket->sequencerSetParameter = hostToNet16( static_cast( parameter ) ); + } + int queueCustomCommandPreCondition( const size_t sizeOfCommand ) + { + int result = DMR_NO_ERROR; + if( currentCommandBufferOffset_ == 0 ) + { + prepareCommandBuffer(); + } + else if( ( currentCommandBufferOffset_ + sizeOfCommand ) > commandBuffer_.parCnt() ) + { + result = sendCommandBuffer(); + prepareCommandBuffer(); + } + return result; + } + int sendCommandBuffer( const char* pBuf, const size_t bufSize ) + { + if( !pBuf || ( bufSize < sizeof( CustomCommandProtocolHeader ) ) ) + { + return DMR_INVALID_PARAMETER; + } + const std::string bufS( pBuf, bufSize ); + try + { + cd_.mvCustomCommandBuffer.writeBinary( bufS ); + } + catch( const ImpactAcquireException& e ) + { + return e.getErrorCode(); + } + return DMR_NO_ERROR; + } +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::CustomCommandGenerator object. + explicit CustomCommandGenerator( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) : cd_( pDev, settingName ), + O32HostByteOrderEvaluator_(), commandBuffer_(), currentCommandBufferOffset_( 0 ), + currentCommandRequestID_( 0 ) + { + mvCustomCommandInterpreterVersionMajor_ = static_cast( cd_.mvCustomCommandInterpreterVersionMajor.read() ); + mvCustomCommandInterpreterVersionMinor_ = static_cast( cd_.mvCustomCommandInterpreterVersionMinor.read() ); + if( mvCustomCommandInterpreterVersionMajor_ > 2 ) + { + // this interpreter currently does not support versions > 2 + mvCustomCommandInterpreterVersionMajor_ = 2; + mvCustomCommandInterpreterVersionMinor_ = 0; + } + } + /// \brief Discards all pending custom commands to the device. + /** + * This function will discard all pending custom commands. After calling this function + * the pending command queue will be empty an can be filled with new commands. + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + void discardCommandBuffer() + { + if( commandBuffer_.parCnt() > 0 ) + { + memset( commandBuffer_.get(), 0, commandBuffer_.parCnt() ); + } + currentCommandBufferOffset_ = 0; + } + /// \brief Request the transmission of an image with a certain timestamp in a different mode/ROI. + /** + * If mvIMPACT::acquire::GenICam::AcquisitionControl::mvSmartFrameRecallEnable is set to mvIMPACT::acquire::bTrue this + * function can be used to request the transmission of the image currently associated with \c pRequest in a different mode/resolution. + * One use case would be to transmit every image taken by the sensor with a very coarse resolution e.g. by setting the properties + * mvIMPACT::acquire::GenICam::ImageFormatControl::decimationHorizontal and/or mvIMPACT::acquire::GenICam::ImageFormatControl::decimationVertical + * to values greater than 1. When then an algorithm finds something interesting within an image this function can be used to request the transmission + * of the very same image in full resolution for detailed processing. + * + * \since 2.18.1 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int queueTransmissionRequest( + /// [in] The timestamp of the mvIMPACT::acquire::Request object shall be transmitted again. + int64_type timestamp_us, + /// [in] The X-offset of the ROI of the image that shall be transmitted within the current image. + int offsetX, + /// [in] The Y-offset of the ROI of the image that shall be transmitted within the current image. + int offsetY, + /// [in] The width of the ROI of the image that shall be transmitted within the current image. + int width, + /// [in] The height of the ROI of the image that shall be transmitted within the current image. + int height, + /// [in] The mode in which this image shall be transmitted. + TRequestTransmissionMode mode = rtmFullResolution, + /// [in] A user defined identifier that shall be attached to the image that will be sent as a result of calling this function. This value will be written into the + /// mvIMPACT::acquire::Request::chunkmvCustomIdentifier property so in order to actually benefit from this parameter the corresponding chunk must be enabled. + /// See mvIMPACT::acquire::GenICam::ChunkDataControl for details. + unsigned int identifier = 0 ) + { + if( !cd_.mvCustomCommandBuffer.isValid() ) + { + return DMR_FEATURE_NOT_AVAILABLE; + } + if( mode != rtmFullResolution ) + { + return DMR_FEATURE_NOT_AVAILABLE; + } + const int result = queueCustomCommandPreCondition( sizeof( CustomCommandSendFrame ) ); + prepareCustomCommandHeader( commandBuffer_.get() + currentCommandBufferOffset_, ccSendFrame, sizeof( CustomCommandSendFrame ) - sizeof( CustomCommandHeader ) ); + CustomCommandSendFrame* pPacket = ( CustomCommandSendFrame* )( commandBuffer_.get() + sizeof( CustomCommandProtocolHeader ) ); + pPacket->offsetX = hostToNet32( static_cast( offsetX ) ); + pPacket->offsetY = hostToNet32( static_cast( offsetY ) ); + pPacket->width = hostToNet32( static_cast( width ) ); + pPacket->height = hostToNet32( static_cast( height ) ); + pPacket->identifier = hostToNet32( identifier ); + pPacket->timestamp_high = hostToNet32( static_cast( ( timestamp_us >> 32 ) & 0xFFFFFFFF ) ); + pPacket->timestamp_low = hostToNet32( static_cast( timestamp_us & 0xFFFFFFFF ) ); + currentCommandBufferOffset_ += sizeof( CustomCommandSendFrame ); + return result; + } + /// \brief Request the transmission of an image currently associated with the Request object in a different mode/ROI. + /** + * If mvIMPACT::acquire::GenICam::AcquisitionControl::mvSmartFrameRecallEnable is set to mvIMPACT::acquire::bTrue this + * function can be used to request the transmission of the image currently associated with \c pRequest in a different mode/resolution. + * One use case would be to transmit every image taken by the sensor with a very coarse resolution e.g. by setting the properties + * mvIMPACT::acquire::GenICam::ImageFormatControl::decimationHorizontal and/or mvIMPACT::acquire::GenICam::ImageFormatControl::decimationVertical + * to values greater than 1. When then an algorithm finds something interesting within an image this function can be used to request the transmission + * of the very same image in full resolution for detailed processing. + * + * \since 2.18.1 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int queueTransmissionRequest( + /// [in] A pointer to a mvIMPACT::acquire::Request object currently associated with the image that shall be transmitted again. + const Request* pRequest, + /// [in] The X-offset of the ROI of the image that shall be transmitted within the current image. + int offsetX, + /// [in] The Y-offset of the ROI of the image that shall be transmitted within the current image. + int offsetY, + /// [in] The width of the ROI of the image that shall be transmitted within the current image. + int width, + /// [in] The height of the ROI of the image that shall be transmitted within the current image. + int height, + /// [in] The mode in which this image shall be transmitted. + TRequestTransmissionMode mode = rtmFullResolution, + /// [in] A user defined identifier that shall be attached to the image that will be sent as a result of calling this function. This value will be written into the + /// mvIMPACT::acquire::Request::chunkmvCustomIdentifier property so in order to actually benefit from this parameter the corresponding chunk must be enabled. + /// See mvIMPACT::acquire::GenICam::ChunkDataControl for details. + unsigned int identifier = 0 ) + { + return queueTransmissionRequest( pRequest->infoTimeStamp_us.read(), offsetX, offsetY, width, height, mode, identifier ); + } + /// \brief Request the transmission of an image currently associated with the Request object in full resolution. + /** + * If mvIMPACT::acquire::GenICam::AcquisitionControl::mvSmartFrameRecallEnable is set to mvIMPACT::acquire::bTrue this + * function can be used to queue the transmission request of the image currently associated with \c pRequest in full resolution. + * One use case would be to transmit every image taken by the sensor with a very coarse resolution e.g. by setting the properties + * mvIMPACT::acquire::GenICam::ImageFormatControl::decimationHorizontal and/or mvIMPACT::acquire::GenICam::ImageFormatControl::decimationVertical + * to values greater than 1. When then an algorithm finds something interesting within an image this function can be used to request the transmission + * of the very same image in full resolution for detailed processing. + * + * The actual transmission request will not be sent to the device until mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer + * is called. With this function multiple commands can be sent to a device at once. When the new + * command does not fit inside the internal command queue any more all pending commands will be sent + * to the device before the new one is put into the queue. + * + * \sa + * \b mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer + * + * \since 2.18.1 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int queueTransmissionRequest( + /// [in] A pointer to a mvIMPACT::acquire::Request object currently associated with the image that shall be transmitted again. + const Request* pRequest, + /// [in] A user defined identifier that shall be attached to the image that will be sent as a result of calling this function. This value will be written into the + /// mvIMPACT::acquire::Request::chunkmvCustomIdentifier property so in order to actually benefit from this parameter the corresponding chunk must be enabled. + /// See mvIMPACT::acquire::GenICam::ChunkDataControl for details. + unsigned int identifier = 0 ) + { + return queueTransmissionRequest( pRequest, + pRequest->imageOffsetX.read(), + pRequest->imageOffsetY.read(), + pRequest->imageWidth.read(), + pRequest->imageHeight.read(), + rtmFullResolution, + identifier ); + } + /// \brief Request the transmission of an image with a certain timestamp in a different mode/ROI. + /** + * This is a convenience function combining a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::queueTransmissionRequest + * directly followed by a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer. Commands which have been + * queued before and have not yet been sent will be sent as well when calling this function. + * + * If mvIMPACT::acquire::GenICam::AcquisitionControl::mvSmartFrameRecallEnable is set to mvIMPACT::acquire::bTrue this + * function can be used to request the transmission of the image currently associated with \c pRequest in a different mode/resolution. + * One use case would be to transmit every image taken by the sensor with a very coarse resolution e.g. by setting the properties + * mvIMPACT::acquire::GenICam::ImageFormatControl::decimationHorizontal and/or mvIMPACT::acquire::GenICam::ImageFormatControl::decimationVertical + * to values greater than 1. When then an algorithm finds something interesting within an image this function can be used to request the transmission + * of the very same image in full resolution for detailed processing. + * + * \since 2.18.1 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int requestTransmission( + /// [in] The timestamp of the mvIMPACT::acquire::Request object shall be transmitted again. + int64_type timestamp_us, + /// [in] The X-offset of the ROI of the image that shall be transmitted within the current image. + int offsetX, + /// [in] The Y-offset of the ROI of the image that shall be transmitted within the current image. + int offsetY, + /// [in] The width of the ROI of the image that shall be transmitted within the current image. + int width, + /// [in] The height of the ROI of the image that shall be transmitted within the current image. + int height, + /// [in] The mode in which this image shall be transmitted. + TRequestTransmissionMode mode = rtmFullResolution, + /// [in] A user defined identifier that shall be attached to the image that will be sent as a result of calling this function. This value will be written into the + /// mvIMPACT::acquire::Request::chunkmvCustomIdentifier property so in order to actually benefit from this parameter the corresponding chunk must be enabled. + /// See mvIMPACT::acquire::GenICam::ChunkDataControl for details. + unsigned int identifier = 0 ) + { + const int result = queueTransmissionRequest( timestamp_us, offsetX, offsetY, width, height, mode, identifier ); + if( result != DMR_NO_ERROR ) + { + return result; + } + return sendCommandBuffer(); + } + /// \brief Request the transmission of an image currently associated with the Request object in a different mode/ROI. + /** + * This is a convenience function combining a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::queueTransmissionRequest + * directly followed by a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer. Commands which have been + * queued before and have not yet been sent will be sent as well when calling this function. + * + * If mvIMPACT::acquire::GenICam::AcquisitionControl::mvSmartFrameRecallEnable is set to mvIMPACT::acquire::bTrue this + * function can be used to request the transmission of the image currently associated with \c pRequest in a different mode/resolution. + * One use case would be to transmit every image taken by the sensor with a very coarse resolution e.g. by setting the properties + * mvIMPACT::acquire::GenICam::ImageFormatControl::decimationHorizontal and/or mvIMPACT::acquire::GenICam::ImageFormatControl::decimationVertical + * to values greater than 1. When then an algorithm finds something interesting within an image this function can be used to request the transmission + * of the very same image in full resolution for detailed processing. + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int requestTransmission( + /// [in] A pointer to a mvIMPACT::acquire::Request object currently associated with the image that shall be transmitted again. + const Request* pRequest, + /// [in] The X-offset of the ROI of the image that shall be transmitted within the current image. + int offsetX, + /// [in] The Y-offset of the ROI of the image that shall be transmitted within the current image. + int offsetY, + /// [in] The width of the ROI of the image that shall be transmitted within the current image. + int width, + /// [in] The height of the ROI of the image that shall be transmitted within the current image. + int height, + /// [in] The mode in which this image shall be transmitted. + TRequestTransmissionMode mode = rtmFullResolution, + /// [in] A user defined identifier that shall be attached to the image that will be sent as a result of calling this function. This value will be written into the + /// mvIMPACT::acquire::Request::chunkmvCustomIdentifier property so in order to actually benefit from this parameter the corresponding chunk must be enabled. + /// See mvIMPACT::acquire::GenICam::ChunkDataControl for details. + unsigned int identifier = 0 ) + { + return requestTransmission( pRequest->infoTimeStamp_us.read(), offsetX, offsetY, width, height, mode, identifier ); + } + /// \brief Request the transmission of an image currently associated with the Request object in full resolution. + /** + * This is a convenience function combining a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::queueTransmissionRequest + * directly followed by a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer. Commands which have been + * queued before and have not yet been sent will be sent as well when calling this function. + * + * If mvIMPACT::acquire::GenICam::AcquisitionControl::mvSmartFrameRecallEnable is set to mvIMPACT::acquire::bTrue this + * function can be used to request the transmission of the image currently associated with \c pRequest in full resolution. + * One use case would be to transmit every image taken by the sensor with a very coarse resolution e.g. by setting the properties + * mvIMPACT::acquire::GenICam::ImageFormatControl::decimationHorizontal and/or mvIMPACT::acquire::GenICam::ImageFormatControl::decimationVertical + * to values greater than 1. When then an algorithm finds something interesting within an image this function can be used to request the transmission + * of the very same image in full resolution for detailed processing. + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int requestTransmission( + /// [in] A pointer to a mvIMPACT::acquire::Request object currently associated with the image that shall be transmitted again. + const Request* pRequest, + /// [in] A user defined identifier that shall be attached to the image that will be sent as a result of calling this function. This value will be written into the + /// mvIMPACT::acquire::Request::chunkmvCustomIdentifier property so in order to actually benefit from this parameter the corresponding chunk must be enabled. + /// See mvIMPACT::acquire::GenICam::ChunkDataControl for details. + unsigned int identifier = 0 ) + { + return requestTransmission( pRequest->infoTimeStamp_us.read(), + pRequest->imageOffsetX.read(), + pRequest->imageOffsetY.read(), + pRequest->imageWidth.read(), + pRequest->imageHeight.read(), + rtmFullResolution, + identifier ); + } + /// \brief Modifies a value of a certain sequencer set at runtime. + /** + * This is a convenience function combining a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::queueSequencerSetValueModification + * directly followed by a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer. Commands which have been + * queued before and have not yet been sent will be sent as well when calling this function. + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int modifySequencerSetValue( + /// The index of the sequencer set to modify. + const int64_type sequencerSet, + /// The parameter within the selected sequencer set to modify. + const TSequencerSetParameter parameter, + /// The new value the selected parameter within the selected sequencer set shall be set to. + const int64_type value ) + { + const int result = queueSequencerSetValueModification( sequencerSet, parameter, value ); + if( result != DMR_NO_ERROR ) + { + return result; + } + return sendCommandBuffer(); + } + /// \brief Modifies a value of a certain sequencer set at runtime. + /** + * This is a convenience function combining a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::queueSequencerSetValueModification + * directly followed by a call to mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer. Commands which have been + * queued before and have not yet been sent will be sent as well when calling this function. + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int modifySequencerSetValue( + /// The index of the sequencer set to modify. + const int64_type sequencerSet, + /// The parameter within the selected sequencer set to modify. + const TSequencerSetParameter parameter, + /// The new value the selected parameter within the selected sequencer set shall be set to. + const double value ) + { + const int result = queueSequencerSetValueModification( sequencerSet, parameter, value ); + if( result != DMR_NO_ERROR ) + { + return result; + } + return sendCommandBuffer(); + } + /// \brief Queues the modification of a value of a certain sequencer set at runtime. + /** + * This function queues a single parameter modification of a selected sequencer set. The actual + * modification will not become effective until mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer + * is called. With this function multiple modifications can be sent to a device at once. When the new + * command does not fit inside the internal command queue any more all pending commands will be sent + * to the device before the new one is put into the queue. + * + * \sa + * \b mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int queueSequencerSetValueModification( + /// The index of the sequencer set to modify. + const int64_type sequencerSet, + /// The parameter within the selected sequencer set to modify. + const TSequencerSetParameter parameter, + /// The new value the selected parameter within the selected sequencer set shall be set to. + const int64_type value ) + { + const int result = queueCustomCommandPreCondition( sizeof( CustomCommandUpdateSequencerSetI64 ) ); + prepareCustomCommandUpdateSequencerSet( commandBuffer_.get() + currentCommandBufferOffset_, ccUpdateSequencerSet, sizeof( CustomCommandUpdateSequencerSetI64 ) - sizeof( CustomCommandHeader ), sequencerSet, parameter ); + CustomCommandUpdateSequencerSetI64* pPacket = ( CustomCommandUpdateSequencerSetI64* )( commandBuffer_.get() + currentCommandBufferOffset_ ); + pPacket->value_high = hostToNet32( static_cast( ( value >> 32 ) & 0xFFFFFFFF ) ); + pPacket->value_low = hostToNet32( static_cast( value & 0xFFFFFFFF ) ); + currentCommandBufferOffset_ += sizeof( CustomCommandUpdateSequencerSetI64 ); + return result; + } + /// \brief Queues the modification of a value of a certain sequencer set at runtime. + /** + * This function queues a single parameter modification of a selected sequencer set. The actual + * modification will not become effective until mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer + * is called. With this function multiple modifications can be sent to a device at once. When the new + * command does not fit inside the internal command queue any more all pending commands will be sent + * to the device before the new one is put into the queue. + * + * \sa + * \b mvIMPACT::acquire::GenICam::CustomCommandGenerator::sendCommandBuffer + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int queueSequencerSetValueModification( + /// The index of the sequencer set to modify. + const int64_type sequencerSet, + /// The parameter within the selected sequencer set to modify. + const TSequencerSetParameter parameter, + /// The new value the selected parameter within the selected sequencer set shall be set to. + const double value ) + { + const int result = queueCustomCommandPreCondition( sizeof( CustomCommandUpdateSequencerSetF ) ); + prepareCustomCommandUpdateSequencerSet( commandBuffer_.get() + currentCommandBufferOffset_, ccUpdateSequencerSet, sizeof( CustomCommandUpdateSequencerSetF ) - sizeof( CustomCommandHeader ), sequencerSet, parameter ); + CustomCommandUpdateSequencerSetF* pPacket = ( CustomCommandUpdateSequencerSetF* )( commandBuffer_.get() + currentCommandBufferOffset_ ); + const size_t byteCount = sizeof( double ) < 8 ? sizeof( double ) : 8; + switch( O32HostByteOrderEvaluator_.get32BitHostByteOrder() ) + { + case O32_LITTLE_ENDIAN: + { + for( size_t i = byteCount ; i > 0; i-- ) + { + pPacket->data[i - 1] = ( reinterpret_cast( &value ) )[byteCount - i]; + } + } + break; + case O32_BIG_ENDIAN: + memcpy( pPacket->data, &value, byteCount ); + break; + } + currentCommandBufferOffset_ += sizeof( CustomCommandUpdateSequencerSetF ); + return result; + } + /// \brief Applies all pending custom commands to the device. + /** + * This function will send all pending custom commands to a device. After calling this function + * the pending command queue will be empty an can be filled with new commands. Calling this function + * multiple times without queuing new commands after each send will have no effect! + * + * \since 2.18.0 + * + * \return + * - \b mvIMPACT::acquire::DMR_NO_ERROR if successful. + * - A negative error code of type \b mvIMPACT::acquire::TDMR_ERROR otherwise. + */ + int sendCommandBuffer( void ) + { + if( currentCommandBufferOffset_ <= sizeof( CustomCommandProtocolHeader ) ) + { + return DMR_INVALID_PARAMETER; + } + prepareCommandProtocolHeader( commandBuffer_.get(), static_cast( currentCommandBufferOffset_ - sizeof( CustomCommandProtocolHeader ) ) ); + const int result = sendCommandBuffer( commandBuffer_.get(), commandBuffer_.parCnt() ); + discardCommandBuffer(); + return result; + } + /// \brief Returns the size of the command buffer for this device in bytes. + /** + * \since 2.18.0 + * + * \return The size of the command buffer for this device in bytes. + */ + unsigned int commandBufferSize( void ) const + { + return cd_.mvCustomCommandBuffer.binaryDataBufferMaxSize(); + } + /// \brief Returns the amount of bytes of the command buffer currently used(thus the amount of bytes that await sending) for this device in bytes. + /** + * \since 2.18.0 + * + * \return The amount of bytes of the command buffer currently used(thus the amount of bytes that await sending) for this device in bytes. + */ + unsigned int commandBufferSizeUsed( void ) const + { + return static_cast( currentCommandBufferOffset_ ); + } +}; + +} // namespace GenICam +} // namespace acquire +} // namespace mvIMPACT + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifndef MVIMPACT_USE_NAMESPACES +using namespace mvIMPACT::acquire::GenICam; +# endif // #ifndef MVIMPACT_USE_NAMESPACES +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#endif //MVIMPACT_ACQUIRE_CUSTOM_COMMANDS_H diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_FileStream.h b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_FileStream.h new file mode 100644 index 0000000..a49f0ae --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_FileStream.h @@ -0,0 +1,1053 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MVIMPACT_ACQUIRE_GENICAM_FILESTREAM_H_ +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_ACQUIRE_GENICAM_FILESTREAM_H_ MVIMPACT_ACQUIRE_GENICAM_FILESTREAM_H_ +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#include + +#ifndef WRAP_ANY +# include +# include +# include +# include +# include +# include +# include +#endif // #ifndef WRAP_ANY + +#ifdef _MSC_VER +# pragma push_macro("min") +# undef min +#endif + +namespace mvIMPACT +{ +namespace acquire +{ +/// \namespace mvIMPACT::acquire::GenICam This namespace contains classes and functions belonging to the GenICam specific part of the image acquisition module of this SDK. +namespace GenICam +{ + +/** \defgroup GenICamInterfaceFileStream GenICam interface layout(file stream) + * \brief Classes and functions that will be available if the device is used with the \a GenICam interface layout. + * + * This group contains classes and functions that will be available if the device is used + * with the mvIMPACT::acquire::dilGenICam interface layout. + * + * \ingroup GenICamInterface + * + * @{ + */ + +//----------------------------------------------------------------------------- +/// \brief Adapter between the std::iostreambuf and the SFNC Features representing the device file system +/** + * The adapter assumes, that the features provide stdio file access compatible semantic + */ +class FileProtocolAdapter +//----------------------------------------------------------------------------- +{ + /// \brief Align an integer + /** + * \return \c value aligned at \c alignment + */ + int64_type Align( + /// value to align + int64_type value, + /// alignment + const int64_type alignment ) + { + if( alignment > 1 ) + { + int64_type r = ( value + ( alignment - 1 ) ) / alignment; + return r * alignment; + } + else if( alignment < 1 ) + { + std::ostringstream oss; + oss << "Unexpected alignment " << alignment; + ExceptionFactory::raiseException( __FUNCTION__, __LINE__, DMR_INVALID_PARAMETER, oss.str() ); + } + return value; + } +public: + /// \brief Constructor + explicit FileProtocolAdapter() {} + /// \brief Attach file protocol adapter to the corresponding properties + /** + * \return true if attach was successful, false if not + */ + bool attach( + /// A pointer to a mvIMPACT::acquire::Device object obtained from + /// a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// The name of the driver internal setting to access with this instance. + /// A list of valid setting names can be obtained by a call to + /// mvIMPACT::acquire::FunctionInterface::getAvailableSettings, new + /// settings can be created with the function + /// mvIMPACT::acquire::FunctionInterface::createSetting + const std::string& settingName = "Base" ) + { + pDev->validateInterfaceLayout( dilGenICam ); + if( !pDev->isOpen() ) + { + pDev->open(); + } + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, dltSetting, settingName ); + locator.bindComponent( m_ptrFileSelector, "FileSelector" ); + locator.bindComponent( m_ptrFileOperationSelector, "FileOperationSelector" ); + locator.bindComponent( m_ptrFileOperationExecute, "FileOperationExecute@i" ); + locator.bindComponent( m_ptrFileOpenMode, "FileOpenMode" ); + locator.bindComponent( m_ptrFileAccessBuffer, "FileAccessBuffer" ); + locator.bindComponent( m_ptrFileAccessOffset, "FileAccessOffset" ); + locator.bindComponent( m_ptrFileAccessLength, "FileAccessLength" ); + locator.bindComponent( m_ptrFileOperationStatus, "FileOperationStatus" ); + locator.bindComponent( m_ptrFileOperationResult, "FileOperationResult" ); + locator.bindComponent( m_ptrFileSize, "FileSize" ); + return m_ptrFileAccessBuffer.isValid() && m_ptrFileAccessLength.isValid() && m_ptrFileAccessOffset.isValid() && + m_ptrFileOpenMode.isValid() && m_ptrFileOperationExecute.isValid() && m_ptrFileOperationResult.isValid() && + m_ptrFileOperationSelector.isValid() && m_ptrFileOperationStatus.isValid() && m_ptrFileSelector.isValid(); + } + /// \brief Open a file on the device + /** + * \return true on success, false on error + */ + bool openFile( + /// Name of the file to open. The file name must exist in the Enumeration FileSelector + const char* pFileName, + /// mode to open the file. The mode must exist in the Enumeration FileOpenMode + std::ios_base::openmode mode ) + { + if( !m_ptrFileSelector.isValid() ) + { + return false; + } + + m_ptrFileSelector.writeS( pFileName ); + if( mode & ( std::ios_base::out | std::ios_base::trunc ) ) + { + m_ptrFileOpenMode.writeS( "Write" ); + } + else if( mode & std::ios_base::in ) + { + m_ptrFileOpenMode.writeS( "Read" ); + } + else + { + return false; + } + + m_ptrFileOperationSelector.writeS( "Open" ); + m_ptrFileOperationExecute.call(); + return m_ptrFileOperationStatus.readS() == "Success"; + } + /// \brief Close a file on the device + /** + * \return true on success, false on error + */ + bool closeFile( + /// Name of the file to open. The file name must exist in the Enumeration FileSelector + const char* pFileName ) + { + m_ptrFileSelector.writeS( pFileName ); + m_ptrFileOperationSelector.writeS( "Close" ); + m_ptrFileOperationExecute.call(); + return m_ptrFileOperationStatus.readS() == "Success"; + } + /// \brief Writes data into a file. + /** + * \return Number of bytes written + */ + std::streamsize write( + /// Source buffer + const char* pBuf, + /// Offset into the device file + int64_type offs, + /// Number of bytes to write + int64_type len, + /// Name of the file to write into The file name must exist in the Enumeration FileSelector + const char* pFileName ) + { + m_ptrFileSelector.writeS( pFileName ); + m_ptrFileOperationSelector.writeS( "Write" ); + + const std::streamsize maxWriteLen( static_cast( m_ptrFileAccessBuffer.binaryDataBufferMaxSize() ) ); + std::streamsize bytesWritten = 0; + while( bytesWritten < len ) + { + // copy streamdata to xchange buffer + const int64_type remain( len - bytesWritten ); + const int64_type writeSize( remain <= maxWriteLen ? remain : maxWriteLen ); + + // offset + if( offs + bytesWritten > m_ptrFileAccessOffset.getMaxValue() ) + { + // we cannot move the outbuffer any further + break; + } + + m_ptrFileAccessOffset.write( offs + bytesWritten ); + m_ptrFileAccessLength.write( writeSize ); + // set the buffer + const std::string bufS( pBuf + bytesWritten, static_cast( Align( writeSize, 4 ) ) ); + m_ptrFileAccessBuffer.writeBinary( bufS ); + m_ptrFileOperationExecute.call(); + bytesWritten += static_cast( m_ptrFileOperationResult.read() ); + if( m_ptrFileOperationStatus.readS() != "Success" ) + { + // no more space on device + break; + } + } + return bytesWritten; + } + /// \brief Read data from the device into a buffer + /** + * \return number of bytes successfully read + */ + std::streamsize read( + /// Target buffer + char* pBuf, + /// Offset in the device file to read from + int64_type offs, + /// Number of bytes to read + std::streamsize len, + /// Name of the file to write into The file name must exist in the Enumeration FileSelector + const char* pFileName ) + { + m_ptrFileSelector.writeS( pFileName ); + m_ptrFileOperationSelector.writeS( "Read" ); + const std::streamsize maxReadLen = static_cast( m_ptrFileAccessBuffer.binaryDataBufferMaxSize() ); + std::streamsize bytesRead = 0; + while( bytesRead < len ) + { + // copy xchange buffer to streamdata + const std::streamsize readSize = std::min( len - bytesRead, maxReadLen ); + // offset + if( offs + bytesRead > m_ptrFileAccessOffset.getMaxValue() ) + { + // we cannot move the inbuffer any further + break; + } + m_ptrFileAccessOffset.write( offs + bytesRead ); + m_ptrFileAccessLength.write( readSize ); + // fetch file data into xchange buffer + m_ptrFileOperationExecute.call(); + const std::streamsize result = static_cast( m_ptrFileOperationResult.read() ); + const std::string bufS( m_ptrFileAccessBuffer.readBinary() ); + memcpy( pBuf + bytesRead, bufS.c_str(), static_cast( readSize ) ); + bytesRead += result; + if( m_ptrFileOperationStatus.readS() != "Success" ) + { + // reached end of file + break; + } + } + return bytesRead; + } + /// \brief Fetch max FileAccessBuffer length for a file + /** + * \return Max length of FileAccessBuffer in the given mode on the given file + */ + int64_type getBufSize( + /// Name of the file to open. The file name must exist in the Enumeration FileSelector + const char* pFileName, + /// mode to open the file. The mode must exist in the Enumeration FileOpenMode + std::ios_base::openmode mode ) + { + m_ptrFileSelector.writeS( pFileName ); + if( mode & ( std::ios_base::out | std::ios_base::trunc ) ) + { + m_ptrFileOperationSelector.writeS( "Write" ); + return m_ptrFileAccessBuffer.binaryDataBufferMaxSize(); + } + else if( mode & ( std::ios_base::in ) ) + { + m_ptrFileOperationSelector.writeS( "Read" ); + return m_ptrFileAccessBuffer.binaryDataBufferMaxSize(); + } + return 0; + } + /// \brief Fetch the size of the file currently selected on the device. + /** + * \return The size(in bytes) of the file currently selected. + */ + std::streamsize size( void ) const + { + return static_cast( m_ptrFileSize.read() ); + } +private: + PropertyI64 m_ptrFileSelector; + PropertyI64 m_ptrFileOperationSelector; + Method m_ptrFileOperationExecute; + PropertyI64 m_ptrFileOpenMode; + PropertyI64 m_ptrFileAccessOffset; + PropertyI64 m_ptrFileAccessLength; + PropertyS m_ptrFileAccessBuffer; + PropertyI64 m_ptrFileOperationStatus; + PropertyI64 m_ptrFileOperationResult; + PropertyI64 m_ptrFileSize; +}; + +//----------------------------------------------------------------------------- +/// \brief An input stream buffer derived from std::basic_streambuf used to read from a file of a device. +/** + * \note See description of the std::basic_streambuf in a STL implementation of + * your choice to find out more about how to use this object. + */ +template +class IDevFileStreamBuf : public std::basic_streambuf +//----------------------------------------------------------------------------- +{ + typedef Traits traits_type; + typedef typename Traits::int_type int_type; + typedef typename Traits::char_type char_type; + typedef IDevFileStreamBuf filebuf_type; + // GET next ptr + using std::basic_streambuf::gptr; + // GET end ptr + using std::basic_streambuf::egptr; + // GET begin ptr + using std::basic_streambuf::eback; + // increment next pointer + using std::basic_streambuf::gbump; + // set buffer info + using std::basic_streambuf::setg; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::IDevFileStreamBuf object. + IDevFileStreamBuf() : m_pBuffer( 0 ), m_BufSize( 0 ), m_file( 0 ), m_pAdapter( 0 ), m_fpos( 0 ) {} + /// \brief class destructor. + ~IDevFileStreamBuf() + { + // catch and dump all exceptions - we're in a destructor... + try + { + this->close(); + } + catch( ... ) {} + } + /// \brief Opens a file on the device. + /** + * The member function calls rdbuf -> open(_Filename, _Mode | ios_base::in). If open fails, + * the function calls setstate(failbit), which may throw an ios_base::failure exception. + */ + filebuf_type* open( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode. One of the enumerations in ios_base::openmode + std::ios_base::openmode mode = std::ios_base::in ) + { + if( m_pAdapter ) + { + delete m_pAdapter; + m_pAdapter = 0; + } + m_pAdapter = new FileProtocolAdapter(); + if( !m_pAdapter ) + { + return 0; + } + + if( !m_pAdapter->attach( pDev ) || !m_pAdapter->openFile( pFileName, mode ) ) + { + delete m_pAdapter; + m_pAdapter = 0; + return 0; + } + + m_file = pFileName; + // allocate buffer according to file info + m_BufSize = ( std::streamsize )m_pAdapter->getBufSize( m_file, mode ); + m_pBuffer = new char_type[static_cast( m_BufSize ) / sizeof( char_type )]; + // setg(buffer+pbSize, buffer+pbSize, buffer+pbSize); + setg( m_pBuffer, m_pBuffer + m_BufSize, m_pBuffer + m_BufSize ); +#ifdef _MSC_VER + // is this reasonable? + std::basic_streambuf::_Init(); +#endif + return this; + } + /// \brief Determines if a file is open. + /** + * \return + * - true if the file is open + * - false otherwise + */ + bool is_open( void ) const + { + return ( m_pAdapter != 0 ) && ( m_file != 0 ); + } + /// \brief Fetch the size of the file currently selected on the device. + /** + * \return The size(in bytes) of the file currently selected. + */ + std::streamsize size( void ) const + { + return m_pAdapter ? m_pAdapter->size() : 0; + } + /// \brief Closes a file on the device. + /** + * \return + * - A pointer to itself if successful + * - 0 otherwise + */ + filebuf_type* close( void ) + { + filebuf_type* ret = 0; + if( this->is_open() ) + { + if( m_pAdapter->closeFile( m_file ) ) + { + // no error + ret = this; + } + } + delete m_pAdapter; + m_pAdapter = 0; + delete[] m_pBuffer; + m_pBuffer = 0; + return ret; + } +protected: + int_type underflow( void ) + { + if( gptr() < egptr() ) + { + return traits_type::to_int_type( *gptr() ); + } + if( buffer_in() < 0 ) + { + return traits_type::eof(); + } + return traits_type::to_int_type( *gptr() ); + } + int_type pbackfail( int_type c ) + { + if( ( gptr() != eback() ) || ( eback() < gptr() ) ) + { + gbump( -1 ); + if( !traits_type::eq_int_type( c, traits_type::eof() ) ) + { + *( gptr() ) = static_cast( traits_type::not_eof( c ) ); + } + return traits_type::not_eof( c ); + } + return traits_type::eof(); + } +private: + char_type* m_pBuffer; + std::streamsize m_BufSize; + const char* m_file; + FileProtocolAdapter* m_pAdapter; + int64_type m_fpos; + + int buffer_in( void ) + { + std::streamsize retval = m_pAdapter->read( m_pBuffer, m_fpos, m_BufSize, m_file ); + if( retval <= 0 ) + { + setg( 0, 0, 0 ); + return -1; + } + setg( m_pBuffer, m_pBuffer, m_pBuffer + retval ); + m_fpos += retval; + return static_cast( retval ); + } + + // prohibit copying and assignment + IDevFileStreamBuf( const IDevFileStreamBuf& ); + IDevFileStreamBuf& operator=( const IDevFileStreamBuf& ); +}; + +//----------------------------------------------------------------------------- +/// \brief An output stream buffer derived from std::basic_streambuf used to write to a file on a device. +/** + * \note See description of the std::basic_streambuf in a STL implementation of + * your choice to find out more about how to use this object. + */ +template +class ODevFileStreamBuf : public std::basic_streambuf +//----------------------------------------------------------------------------- +{ + typedef Traits traits_type; + typedef typename Traits::int_type int_type; + typedef typename Traits::char_type char_type; + typedef typename Traits::pos_type pos_type; + typedef typename Traits::off_type off_type; + typedef ODevFileStreamBuf filebuf_type; + // PUT begin + using std::basic_streambuf::pbase; + // PUT next + using std::basic_streambuf::pptr; + // PUT end + using std::basic_streambuf::epptr; + // increment next pointer + using std::basic_streambuf::pbump; +public: + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::ODevFileStreamBuf object. + ODevFileStreamBuf() : m_pBuffer( 0 ), m_file( 0 ), m_pAdapter( 0 ), m_fpos( 0 ) {} + /// \brief class destructor. + ~ODevFileStreamBuf() + { + // catch and dump all exceptions - we're in a destructor... + try + { + this->close(); + } + catch( ... ) {} + } + /// \brief Opens a file on the device. + /** + * The member function calls rdbuf -> open(_Filename, _Mode | ios_base::in). If open fails, + * the function calls setstate(failbit), which may throw an ios_base::failure exception. + */ + filebuf_type* open( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode + std::ios_base::openmode mode ) + { + if( m_pAdapter ) + { + delete m_pAdapter; + m_pAdapter = 0; + } + m_pAdapter = new FileProtocolAdapter(); + if( !m_pAdapter ) + { + return 0; + } + + if( !m_pAdapter->attach( pDev ) || !m_pAdapter->openFile( pFileName, mode ) ) + { + delete m_pAdapter; + m_pAdapter = 0; + return 0; + } + + m_file = pFileName; + // allocate buffer according to file info + const int64_type bufSize = m_pAdapter->getBufSize( m_file, mode ); + m_pBuffer = new char_type[static_cast( bufSize ) / sizeof( char_type )]; + std::basic_streambuf::setp( m_pBuffer, m_pBuffer + bufSize ); + return this; + } + /// \brief Determines if a file is open. + /** + * \return + * - true if the file is open + * - false otherwise + */ + bool is_open( void ) const + { + return ( m_pAdapter != 0 ) && ( m_file != 0 ); + } + /// \brief Closes a file on the device. + /** + * \return + * - A pointer to itself if successful + * - 0 otherwise + */ + filebuf_type* close( void ) + { + filebuf_type* ret = 0; + if( this->is_open() ) + { + bool syncFailed = false; + if( sync() ) + { + syncFailed = true; + } + if( m_pAdapter->closeFile( m_file ) ) + { + ret = syncFailed ? 0 : this; + } + } + delete m_pAdapter; + m_pAdapter = 0; + delete[] m_pBuffer; + m_pBuffer = 0; + return ret; + } +protected: + std::streamsize xsputn( const char_type* s, std::streamsize n ) + { + if( n < epptr() - pptr() ) + { + memcpy( pptr(), s, static_cast( n ) * sizeof( char_type ) ); + pbump( static_cast( n ) ); + return n; + } + else + { + for( std::streamsize i = 0; i < n; ++i ) + { + if( traits_type::eq_int_type( std::basic_streambuf::sputc( s[i] ), traits_type::eof() ) ) + { + return i; + } + } + return n; + } + } + int_type overflow( int_type c = traits_type::eof() ) + { + if( buffer_out() < 0 ) + { + return traits_type::eof(); + } + else if( !traits_type::eq_int_type( c, traits_type::eof() ) ) + { + return std::basic_streambuf::sputc( static_cast( c ) ); + } + return traits_type::not_eof( c ); + } + int sync( void ) + { + return static_cast( buffer_out() ); + } +private: + char_type* m_pBuffer; + const char* m_file; + FileProtocolAdapter* m_pAdapter; + int64_type m_fpos; + + int64_type buffer_out( void ) + { + int64_type cnt = pptr() - pbase(); + int64_type retval; + int64_type res = m_pAdapter->write( m_pBuffer, m_fpos, cnt, m_file ); + retval = ( res == cnt ) ? 0 : -1; + m_fpos += res; + pbump( -static_cast( cnt ) ); + return retval; + } + + // prohibit copying assignment + ODevFileStreamBuf( const ODevFileStreamBuf& ); + ODevFileStreamBuf& operator=( const ODevFileStreamBuf& ); +}; + +//----------------------------------------------------------------------------- +/// \brief An output stream buffer derived from std::basic_ostream used to write to a file on a device. +/** + * \note See description of the std::basic_ostream in a STL implementation of + * your choice to find out more about how to use this object. + */ +template +class ODevFileStreamBase : public std::basic_ostream +//----------------------------------------------------------------------------- +{ +public: + // Non-standard types: + typedef ODevFileStreamBuf filebuf_type; + typedef std::basic_ios ios_type; + typedef std::basic_ostream ostream_type; +private: + filebuf_type m_streambuf; +public: +#if defined (_MSC_VER) + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::ODevFileStreamBase object. + ODevFileStreamBase() : ostream_type( std::_Noinit ), m_streambuf() + { + this->init( &m_streambuf ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::ODevFileStreamBase object. + ODevFileStreamBase( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode + std::ios_base::openmode mode = std::ios_base::out | std::ios_base::trunc ) : ostream_type( std::_Noinit ), m_streambuf() + { + this->init( &m_streambuf ); + this->open( pDev, pFileName, mode ); + } +#elif defined (__GNUC__) + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::ODevFileStreamBase object. + ODevFileStreamBase() : ostream_type(), m_streambuf() + { + this->init( &m_streambuf ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::ODevFileStreamBase object. + ODevFileStreamBase( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode + std::ios_base::openmode mode = std::ios_base::out | std::ios_base::trunc ) : ostream_type(), m_streambuf() + { + this->init( &m_streambuf ); + this->open( pDev, pFileName, mode ); + } +#elif !defined(SWIG) +# error Unknown C++ library +#endif + /// \brief Returns the address of the stored stream buffer. + /** + * \return The address of the stored stream buffer. + */ + filebuf_type* rdbuf( void ) const + { + return const_cast( &m_streambuf ); + } + /// \brief Determines if a file is open. + /** + * \return + * - true if the file is open + * - false otherwise + */ + bool is_open( void ) const + { + return m_streambuf.is_open(); + } + /// \brief Open file on device in write mode + void open( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode + std::ios_base::openmode mode = std::ios_base::out | std::ios_base::trunc ) + { + if( !m_streambuf.open( pDev, pFileName, mode ) ) + { + this->setstate( std::ios_base::failbit ); + } + else + { + this->clear(); + } + } + /// \brief Close the file on device. + void close( void ) + { + if( !m_streambuf.close() ) + { + this->setstate( std::ios_base::failbit ); + } + } +}; + +//----------------------------------------------------------------------------- +/// \brief An output stream buffer derived from std::basic_istream used to read from a file on a device. +/** + * \note See description of the std::basic_istream in a STL implementation of + * your choice to find out more about how to use this object. + */ +template +class IDevFileStreamBase : public std::basic_istream +//----------------------------------------------------------------------------- +{ +public: + // Non-standard types: + typedef IDevFileStreamBuf filebuf_type; + typedef std::basic_ios ios_type; + typedef std::basic_istream istream_type; +private: + filebuf_type m_streambuf; +public: +#if defined (_MSC_VER) + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::IDevFileStreamBase object. + IDevFileStreamBase() : istream_type( std::_Noinit ), m_streambuf() + { + this->init( &m_streambuf ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::IDevFileStreamBase object. + IDevFileStreamBase( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode + std::ios_base::openmode mode = std::ios_base::in ) : istream_type( std::_Noinit ), m_streambuf() + { + this->init( &m_streambuf ); + this->open( pDev, pFileName, mode ); + } +#elif defined (__GNUC__) + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::IDevFileStreamBase object. + IDevFileStreamBase() : istream_type(), m_streambuf() + { + this->init( &m_streambuf ); + } + /// \brief Constructs a new \b mvIMPACT::acquire::GenICam::IDevFileStreamBase object. + IDevFileStreamBase( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// Name of the file to open + const char* pFileName, + /// File open mode + std::ios_base::openmode mode = std::ios_base::in ) : istream_type(), m_streambuf() + { + this->init( &m_streambuf ); + this->open( pDev, pFileName, mode ); + } +#elif !defined(SWIG) +# error Unknown C++ library +#endif + /// \brief Returns the address of the stored stream buffer. + /** + * \return The address of the stored stream buffer. + */ + filebuf_type* rdbuf( void ) const + { + return const_cast( &m_streambuf ); + } + /// \brief Determines if a file is open. + /** + * \return + * - true if the file is open + * - false otherwise + */ + bool is_open( void ) const + { + return m_streambuf.is_open(); + } + /// \brief Opens a file on the device. + /** + * The member function calls rdbuf -> open(_Filename, _Mode | ios_base::in). If open fails, + * the function calls setstate(failbit), which may throw an ios_base::failure exception. + */ + void open( + /// A pointer to a mvIMPACT::acquire::Device object obtained from a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// name of the file to open + const char* pFileName, + /// open mode + std::ios_base::openmode mode = std::ios_base::in ) + { + if( !m_streambuf.open( pDev, pFileName, mode ) ) + { + this->setstate( std::ios_base::failbit ); + } + else + { + this->clear(); + } + } + /// \brief Close the file on the device + void close( void ) + { + if( !m_streambuf.close() ) + { + this->setstate( std::ios_base::failbit ); + } + } + /// \brief Returns the size of the file on the device + std::streamsize size( void ) const + { + return m_streambuf.size(); + } +}; + +/// \brief A type for char type file access. +/** + * Provided for convenience only. This type represents an output file stream for char data. + * \if DOXYGEN_CPP_DOCUMENTATION + * + * \b Example: + * \code + * //----------------------------------------------------------------------------- + * void uploadUserFile( Device* pDev ) + * //----------------------------------------------------------------------------- + * { + * string srcName = "Upload_Source.txt"; + * string dstName = "UserFile"; // This name hase to be used. + * bool boOk = false; + * + * try + * { + * // upload a file + * mvIMPACT::acquire::GenICam::ODevFileStream file; + * file.open( pDev, dstName.c_str() ); + * if( !file.fail() ) + * { + * FILE* pFile; + * size_t lSize; + * char * pBuffer; + * size_t result; + * + * pFile = fopen( srcName.c_str(), "rb" ); + * if( pFile != NULL ) + * { + * // obtain file size: + * fseek( pFile , 0 , SEEK_END ); + * lSize = ftell( pFile ); + * rewind( pFile ); + * + * // allocate memory to contain the whole file: + * pBuffer = (char*)malloc( sizeof(char) * lSize ); + * if( pBuffer ) + * { + * // copy the file into the pBuffer: + * printf( "Copying file to pBuffer..." ); + * result = fread( pBuffer, 1, lSize, pFile ); + * if( result != lSize ) + * { + * printf( "%s(%d): Could not read all data from file %s locally.\n", __FUNCTION__, __LINE__, srcName.c_str() ); + * } + * else + * { + * // the whole file has been copied into 'pBuffer' now. + * //file.seekp(); + * file.write( pBuffer, lSize ); + * printf( "ready.\nSaving to flash..." ); + * boOk = true; + * } + * free( pBuffer ); + * } + * else + * { + * printf( "Memory error\n" ); + * } + * fclose( pFile ); + * } + * else + * { + * printf( "%s(%d): Could not open file %s with read access locally.\n", __FUNCTION__, __LINE__, srcName.c_str() ); + * } + * } + * else + * { + * printf( "%s(%d): Could not open file %s with write access on device.\n", __FUNCTION__, __LINE__, dstName.c_str() ); + * } + * } + * catch( const ImpactAcquireException& e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * cout << "An error occurred while opening the device " << pDev->serial.read() + * << "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << endl; + * } + * if( boOk ) + * { + * printf( "ready.\nFile '%s' successfully uploaded to device.\n", srcName.c_str() ); + * } + * } + * \endcode + * \endif + */ +typedef ODevFileStreamBase > ODevFileStream; +/// \brief A type for char type file access. +/** + * Provided for convenience only. This type represents an input file stream for char data. + * \if DOXYGEN_CPP_DOCUMENTATION + * + * \b Example: + * \code + * //----------------------------------------------------------------------------- + * void downloadUserFile( Device* pDev ) + * //----------------------------------------------------------------------------- + * { + * string srcName = "UserFile"; + * string dstName = "Downloaded_file.txt"; + * bool boOk = false; + * + * try + * { + * // download a file + * mvIMPACT::acquire::GenICam::IDevFileStream file; + * file.open( pDev, srcName.c_str() ); + * if( !file.fail() ) + * { + * FILE* pFile; + * size_t lSize; + * char * pBuffer; + * size_t result; + * + * lSize = file.size(); + * // allocate memory to contain the whole file: + * pBuffer = (char*)malloc( sizeof(char) * lSize ); + * if( pBuffer ) + * { + * // copy the file into the pBuffer: + * printf( "Copying from flash to pBuffer..." ); + * file.read( pBuffer, lSize ); + * printf( "Ready.\n" ); + * // write pBuffer to file + * pFile = fopen( dstName.c_str(), "wb" ); + * if( pFile != NULL ) + * { + * result = fwrite( pBuffer, 1, lSize, pFile ); + * if( result != lSize ) + * { + * printf( "%s(%d): Could not write all data to file %s locally.\n", __FUNCTION__, __LINE__, dstName.c_str() ); + * } + * else + * { + * boOk = true; + * } + * } + * else + * { + * printf( "%s(%d): Could not open file %s with write access locally.\n", __FUNCTION__, __LINE__, dstName.c_str() ); + * } + * free( pBuffer ); + * fclose( pFile ); + * } + * else + * { + * printf("Memory error\n"); + * } + * } + * else + * { + * printf( "%s(%d): Could not open file %s with read access on device.\n", __FUNCTION__, __LINE__, srcName.c_str() ); + * } + * } + * catch( const ImpactAcquireException& e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * cout << "An error occurred while opening the device " << pDev->serial.read() + * << "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << endl; + * } + * if( boOk ) + * { + * printf( "User file successfully saved to file '%s'.\n", dstName.c_str() ); + * } + * } + * \endcode + * \endif + */ +typedef IDevFileStreamBase > IDevFileStream; + +/// @} + +} // namespace GenICam +} // namespace acquire +} // namespace mvIMPACT + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifndef MVIMPACT_USE_NAMESPACES +using namespace mvIMPACT::acquire::GenICam; +# endif // #ifndef MVIMPACT_USE_NAMESPACES +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#ifdef _MSC_VER +# pragma pop_macro("min") +#endif + +#endif // MVIMPACT_ACQUIRE_GENICAM_FILESTREAM_H_ diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_LensControl.h b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_LensControl.h new file mode 100644 index 0000000..291b0c9 --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_GenICam_LensControl.h @@ -0,0 +1,566 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MVIMPACT_ACQUIRE_GENICAM_LENS_CONTROL_H +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_ACQUIRE_GENICAM_LENS_CONTROL_H MVIMPACT_ACQUIRE_GENICAM_LENS_CONTROL_H +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#include + +#ifndef WRAP_ANY +# include +# include +# include +# include +# include +#endif // #ifndef WRAP_ANY + +#ifdef _MSC_VER // is Microsoft compiler? +# pragma warning( push ) +# if _MSC_VER < 1300 // is 'old' VC 6 compiler? +# pragma warning( disable : 4786 ) // 'identifier was truncated to '255' characters in the debug information' +# define __FUNCTION__ "No function name information as the __FUNCTION__ macro is not supported by this(VC 6) compiler" +# pragma message( "WARNING: This header(" __FILE__ ") uses the __FUNCTION__ macro, which is not supported by this compiler. A default definition(\"" __FUNCTION__ "\") will be used!" ) +# pragma message( "WARNING: This header(" __FILE__ ") uses inheritance for exception classes. However this compiler can't handle this correctly. Trying to catch a specific exception by writing a catch block for a base class will not work!" ) +# endif // #if _MSC_VER < 1300 +# pragma warning( disable : 4512 ) // 'assignment operator could not be generated' (reason: assignment operators declared 'private' but not implemented) +#endif // #ifdef _MSC_VER + +namespace mvIMPACT +{ +namespace acquire +{ +namespace GenICam +{ +/// \namespace mvIMPACT::acquire::GenICam::labs This namespace contains classes and functions belonging to the GenICam specific part of the image acquisition module of this SDK that are not yet final and might change in the future without further notice. Yet still we think code within this namespace might prove useful thus we encourage you to use it if beneficial for your application. However be prepared to apply changes when needed. Feedback that helps to improve or finalize code from this namespace will be highly appreciated! A migration guide will be provided and we will perform changes only if they make sense and improve the code. +namespace labs +{ + +//----------------------------------------------------------------------------- +/// \brief Contains convenience functions to control features understood by generic lens adapters. +/** + * \attention + * Please note that this class currently is part of the mvIMPACT::acquire::GenICam::labs namespace! This means that this code + * is not yet final and therefore might change in a future release. Feedback will be highly appreciated + * and if changes are applied to this code a detailed migration guide can be found in the documentation! + * + * \since 2.38.0 + * \ingroup GenICamInterfaceDevice + */ +class LensControlBase +//----------------------------------------------------------------------------- +{ +#if !DOXYGEN_SHOULD_SKIP_THIS +protected: + PropertyIBoolean mvSerialInterfaceEnable_; + PropertyI64 mvSerialInterfaceASCIIBuffer_; + PropertyI64 mvSerialInterfaceBaudRate_; + PropertyI64 mvSerialInterfaceBytesAvailableForRead_; + PropertyI64 mvSerialInterfaceBytesToRead_; + PropertyI64 mvSerialInterfaceBytesToWrite_; + PropertyI64 mvSerialInterfaceMode_; + PropertyI64 mvSerialInterfaceDataBits_; + PropertyI64 mvSerialInterfaceStopBits_; + PropertyI64 mvSerialInterfaceParity_; + Method mvSerialInterfaceRead_; + Method mvSerialInterfaceWrite_; + + int64_type ASCIIBufferLength_; + + double fStopMax_; + double fStopMin_; + unsigned int fStopCount_; + int focalLength_; + int focusMin_; + int focusMax_; +#endif // #if !DOXYGEN_SHOULD_SKIP_THIS + + /// \brief Constructs a new mvIMPACT::acquire::GenICam::labs::LensControlBase object. + explicit LensControlBase( + /// [in] A pointer to a mvIMPACT::acquire::Device object obtained from + /// a mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev ) : mvSerialInterfaceEnable_(), mvSerialInterfaceASCIIBuffer_(), mvSerialInterfaceBaudRate_(), + mvSerialInterfaceBytesAvailableForRead_(), mvSerialInterfaceBytesToRead_(), mvSerialInterfaceBytesToWrite_(), + mvSerialInterfaceMode_(), mvSerialInterfaceDataBits_(), mvSerialInterfaceStopBits_(), + mvSerialInterfaceParity_(), mvSerialInterfaceRead_(), mvSerialInterfaceWrite_(), + ASCIIBufferLength_( 32 ), fStopMax_( 0 ), fStopMin_( 0 ), fStopCount_( 0 ), focalLength_( 0 ), focusMin_( 0 ), focusMax_( 0 ) + { + pDev->validateInterfaceLayout( dilGenICam ); + if( !pDev->isOpen() ) + { + pDev->open(); + } + mvIMPACT::acquire::DeviceComponentLocator locator( pDev, dltSetting, "Base" ); + locator.bindComponent( mvSerialInterfaceEnable_, "mvSerialInterfaceEnable" ); + locator.bindComponent( mvSerialInterfaceASCIIBuffer_, "mvSerialInterfaceASCIIBuffer" ); + locator.bindComponent( mvSerialInterfaceBaudRate_, "mvSerialInterfaceBaudRate" ); + locator.bindComponent( mvSerialInterfaceBytesAvailableForRead_, "mvSerialInterfaceBytesAvailableForRead" ); + locator.bindComponent( mvSerialInterfaceBytesToRead_, "mvSerialInterfaceBytesToRead" ); + locator.bindComponent( mvSerialInterfaceBytesToWrite_, "mvSerialInterfaceBytesToWrite" ); + locator.bindComponent( mvSerialInterfaceMode_, "mvSerialInterfaceMode" ); + locator.bindComponent( mvSerialInterfaceDataBits_, "mvSerialInterfaceDataBits" ); + locator.bindComponent( mvSerialInterfaceStopBits_, "mvSerialInterfaceStopBits" ); + locator.bindComponent( mvSerialInterfaceParity_, "mvSerialInterfaceParity" ); + locator.bindComponent( mvSerialInterfaceRead_, "mvSerialInterfaceRead@i" ); + locator.bindComponent( mvSerialInterfaceWrite_, "mvSerialInterfaceWrite@i" ); + + if( mvSerialInterfaceEnable_.isValid() && + mvSerialInterfaceASCIIBuffer_.isValid() && + mvSerialInterfaceBaudRate_.isValid() && + mvSerialInterfaceBytesAvailableForRead_.isValid() && + mvSerialInterfaceBytesToRead_.isValid() && + mvSerialInterfaceBytesToWrite_.isValid() && + mvSerialInterfaceMode_.isValid() && + mvSerialInterfaceDataBits_.isValid() && + mvSerialInterfaceStopBits_.isValid() && + mvSerialInterfaceParity_.isValid() && + mvSerialInterfaceRead_.isValid() && + mvSerialInterfaceWrite_.isValid() ) + { + mvSerialInterfaceEnable_.write( bFalse ); + mvSerialInterfaceEnable_.write( bTrue ); + mvSerialInterfaceMode_.writeS( "Plain" ); + mvSerialInterfaceBaudRate_.writeS( "Hz_115200" ); + mvSerialInterfaceDataBits_.writeS( "Eight" ); + mvSerialInterfaceStopBits_.writeS( "One" ); + mvSerialInterfaceParity_.writeS( "None" ); + + if( mvSerialInterfaceBytesToRead_.hasMaxValue() ) + { + ASCIIBufferLength_ = mvSerialInterfaceBytesToRead_.getMaxValue(); + } + } + else + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_FEATURE_NOT_AVAILABLE, "At least on crucial property for accessing the serial interface is missing therefore this class cannot operate correctly!" ); + } + } +#if !DOXYGEN_SHOULD_SKIP_THIS + /// \brief Returns the result of a command issued to the lens or the lens adapter. + /** + * \return The string value which has been send as answer to the issued command. + */ + std::string getCommandResult( const std::string& cmd, const std::chrono::milliseconds maxPollingTime_ms = std::chrono::milliseconds( 5000 ), const int delimiterCount = 2 ) const + { + if( mvSerialInterfaceASCIIBuffer_.isWriteable() && mvSerialInterfaceBytesToWrite_.isWriteable() ) + { + mvSerialInterfaceASCIIBuffer_.writeS( cmd ); + mvSerialInterfaceBytesToWrite_.write( cmd.length() ); + } + if( static_cast( mvSerialInterfaceWrite_.call() ) != DMR_NO_ERROR ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_EXECUTION_FAILED, "Error sending command " + cmd + " to lens adapter!" ); + } + + const std::chrono::milliseconds pollingInterval_ms = std::chrono::milliseconds( 20 ); + std::chrono::milliseconds pollingTimeExpired_ms( 0 ); + std::string commandResult; + + while( pollingTimeExpired_ms < maxPollingTime_ms ) + { + int64_type bytesToRead = mvSerialInterfaceBytesAvailableForRead_.read(); + while( bytesToRead > 0 ) + { + mvSerialInterfaceBytesToRead_.write( ( bytesToRead > ASCIIBufferLength_ ) ? ASCIIBufferLength_ : bytesToRead ); + mvSerialInterfaceRead_.call(); + const std::string resultFragment = mvSerialInterfaceASCIIBuffer_.readS(); + commandResult.append( resultFragment ); + bytesToRead = bytesToRead - resultFragment.length(); + } + if( resultComplete( commandResult, delimiterCount ) ) + { + break; + } + std::this_thread::sleep_for( pollingInterval_ms ); + pollingTimeExpired_ms += pollingInterval_ms; + } + if( pollingTimeExpired_ms >= maxPollingTime_ms ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_EXECUTION_FAILED, "Error! Adapter did not send the full answer in the expected time." ); + } + return commandResult; + } + /// \brief Returns the command string with an appended delimiter. + /** + * \return Both passed strings concatenated together. + */ + static std::string prepareCommand( + /// [in] A constant reference to the command string object + const std::string& cmd, + /// [in] The delimiter to append to \c cmd. + const std::string& delimiter ) + { + return cmd + delimiter; + } + /// \brief Splits a string by the separator parameter into the vector provided. + static void split( + /// [in] A constant reference to the string, which should be separated + const std::string& stringToSplit, + /// [in] A constant reference to the string, which should be used to split the provided string + const std::string& separator, + /// [in] A constant reference to the vector of strings, which should be used for the results + std::vector& v ) + { + std::string::size_type i = 0; + std::string::size_type j = stringToSplit.find( separator ); + while ( j != std::string::npos ) + { + v.push_back( stringToSplit.substr( i, j - i ) ); + i = ++j; + j = stringToSplit.find( separator, j ); + if ( j == std::string::npos ) + { + if( i != stringToSplit.length() ) + { + v.push_back( stringToSplit.substr( i, stringToSplit.length() ) ); + } + } + } + } + /// \brief Removes unwanted characters from the provided string. + static std::string removeCharsFromString( + /// [in] A reference to the string, from which the characters should be removed + std::string& str, + /// [in] A constant pointer to the character(s), which should be removed + const std::string& charsToRemove ) + { + for( const auto charToRemove : charsToRemove ) + { + str.erase( remove( str.begin(), str.end(), charToRemove ), str.end() ); + } + return str; + } + virtual bool resultComplete( const std::string& result, const int delimiterCount ) const = 0; +#endif // #if !DOXYGEN_SHOULD_SKIP_THIS +public: + virtual ~LensControlBase() {} +}; + +// ---------------------------------------------------------------------------------- +/// \brief Contains convenience functions to control features understood by Birger Engineering, Inc. lens adapters. +/** + * \attention + * Please note that this class currently is part of the mvIMPACT::acquire::GenICam::labs namespace! This means that this code + * is not yet final and therefore might change in a future release. Feedback will be highly appreciated + * and if changes are applied to this code a detailed migration guide can be found in the documentation! + * + * \since 2.38.0 + * \ingroup GenICamInterfaceDevice + */ +class LensControlBirger : public LensControlBase +//----------------------------------------------------------------------------- +{ +public: + /// \brief Constructs a new mvIMPACT::acquire::GenICam::labs::LensControlBirger object. + explicit LensControlBirger( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + mvIMPACT::acquire::Device* pDev, + /// [in] The default timeout value in milliseconds after which a command is considered as not successful. + unsigned int defaultCommunicationTimeout_ms = 5000 ) : LensControlBase( pDev ), delimiter_( "\r" ), okToken_( "OK" ), doneToken_( "DONE" ), defaultCommunicationTimeout_ms_( defaultCommunicationTimeout_ms ) + { + init( defaultCommunicationTimeout_ms_ ); + } + /// \brief Returns the serial number of the connected adapter. + /** + * \return The serial number of the attached adapter as string. + */ + std::string getSerial( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) const + { + return sendCommandAndGetResult( prepareCommand( "sn", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ) ); + } + /// \brief Returns the maximum f-stop value of the attached lens. + /** + * \return The maximum f-stop value of the attached lens as double value. + */ + double getMaxAperture( void ) const + { + return fStopMax_; + } + /// \brief Returns the minimum f-stop value of the attached lens. + /** + * \return The minimum f-stop value of the attached lens as double value. + */ + double getMinAperture( void ) const + { + return fStopMin_; + } + /// \brief Returns the number of possible stops usable to change the opening of the aperture of the attached lens. + /** + * \return The number of possible stops as unsigned int. + */ + unsigned int getApertureStepCount( void ) const + { + return fStopCount_; + } + /// \brief Writes the new aperture to the device. + /** + * \return The resulting FStop value the aperture is set to. + */ + double setAperture( + /// [in] The new aperture value which should be set in 1/4 stops. + int steps, + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 ) + { + return returnValueToFStopValue( sendCommandAndGetResult( prepareCommand( "ma" + std::to_string( steps ), delimiter_ ), "DONE", getTimeoutToUse( timeout_ms ) ) ); + } + /// \brief Opens the aperture to the min possible value. + /** + * \return The number of steps (1/4 stops) the aperture has actually moved. + */ + double setApertureToMin( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + return returnValueToFStopValue( sendCommandAndGetResult( prepareCommand( "mo", delimiter_ ), "DONE", getTimeoutToUse( timeout_ms ) ) ); + } + /// \brief Closes the aperture to the max possible value. + /** + * \return The number of steps (1/4 stops) the aperture has actually moved. + */ + double setApertureToMax( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + return returnValueToFStopValue( sendCommandAndGetResult( prepareCommand( "mc", delimiter_ ), "DONE", getTimeoutToUse( timeout_ms ) ) ); + } + /// \brief Reads the current FStop value from the device. + /** + * \return The resulting f value the aperture is set to. + */ + double getAperture( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + std::string result = sendCommandAndGetResult( prepareCommand( "pa", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ) ); + std::vector seglist = prepareReturnValues( result, "f", "," ); + return returnValueToFStopValue( seglist[1] ); + } + /// \brief Reads the current focus value from the device. + /** + * \return The value the focus is currently set to. + */ + int getFocus( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + return stoi( sendCommandAndGetResult( prepareCommand( "pf", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ) ) ); + } + /// \brief Returns the maximum focus value of the attached lens. + /** + * \return The maximum focus value of the attached lens as unsigned int value. + */ + int getMaxFocus( void ) const + { + return focusMax_; + } + /// \brief Returns the minimum focus value of the attached lens. + /** + * \return The minimum focus value of the attached lens as unsigned int value. + */ + int getMinFocus( void ) const + { + return focusMin_; + } + /// \brief Moves the focus to the closest position. + /** + * \return The number of steps the focus has moved. + */ + int setFocusToZero( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + return stoi( sendCommandAndGetResult( prepareCommand( "mz", delimiter_ ), "DONE", getTimeoutToUse( timeout_ms ) ) ); + } + /// \brief Moves the focus about the provided number of encoder steps. + /** + * \return The number of steps the focus has moved. Might be positive for a movement towards the infinity position or negative for a movement towards the zero position. + */ + int setFocus( + /// [in] The value of encoder steps the focus should be moved. Might be positive for a movement towards the infinity position or negative for a movement towards the zero position. + int steps, + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 ) + { + return stoi( sendCommandAndGetResult( prepareCommand( "mf" + std::to_string( steps ), delimiter_ ), "DONE", getTimeoutToUse( timeout_ms ), 2 ) ); + } + /// \brief Moves the focus to the infinity position. + /** + * \return The number of steps the focus has moved. + */ + int setFocusToInfinity( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + return stoi( sendCommandAndGetResult( prepareCommand( "mi", delimiter_ ), "DONE", getTimeoutToUse( timeout_ms ) ) ); + } +private: + std::string delimiter_; + std::string okToken_; + std::string doneToken_; + + unsigned int defaultCommunicationTimeout_ms_; + + /// \brief Initializes the Birger Engineering, Inc. Lens adapter and reads out the fix aperture values e.g.: max aperture, min aperture and number of increments between the maximum and the minimum. + void init( + /// [in] The timeout value in milliseconds after which the command is considered as not successful. In case of '0' the value of defaultCommunicationTimeout_ms will be used. + unsigned int timeout_ms = 0 + ) + { + try + { + sendCommandAndGetResult( prepareCommand( "", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ), 2 ); + sendCommandAndGetResult( prepareCommand( "rm1", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ), 2 ); + } + catch( const ImpactAcquireException& /*e*/ ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_FEATURE_NOT_AVAILABLE, "Could not detect any Birger lens adapter!" ); + } + + if( !isLensPresent() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_FEATURE_NOT_AVAILABLE, "Could not detect any Birger lens adapter!" ); + } + + sendCommandAndGetResult( prepareCommand( "in", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ) ); + readApertureLimits( focalLength_, fStopMin_, fStopMax_, fStopCount_, ( timeout_ms == 0 ) ? timeout_ms = defaultCommunicationTimeout_ms_ : timeout_ms ); + sendCommandAndGetResult( prepareCommand( "la0", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ), 3 ); + readFocusLimits( focusMin_, focusMax_, ( timeout_ms == 0 ) ? defaultCommunicationTimeout_ms_ : timeout_ms ); + } + std::chrono::milliseconds getTimeoutToUse( int timeout_ms ) const + { + return std::chrono::milliseconds( ( timeout_ms == 0 ) ? defaultCommunicationTimeout_ms_ : timeout_ms ); + } + std::vector parseResult( const std::string& resultToParse ) const + { + std::vector seglist; + split( resultToParse, delimiter_, seglist ); + return seglist; + } + std::vector prepareReturnValues( std::string& stringToPrepare, const std::string& charsToRemove, const std::string& separator ) const + { + removeCharsFromString( stringToPrepare, charsToRemove ); + std::vector segments; + split( stringToPrepare, separator, segments ); + return segments; + } + double returnValueToFStopValue( const std::string& valueToConvert ) const + { + return round( stod( valueToConvert ) * 100 ) / 1000; + } + virtual bool resultComplete( const std::string& result, const int delimiterCount ) const + { + return ( std::count( result.begin(), result.end(), delimiter_.at( 0 ) ) == delimiterCount ); + } + std::string sendCommandAndGetResult( const std::string& cmd, const std::string& expectedResult, std::chrono::milliseconds timeout_ms, const int delimiterCount = 3 ) const + { + std::string result = ""; + std::vector resultVector = parseResult( getCommandResult( cmd, timeout_ms, delimiterCount ) ); + size_t okIndex = 0; + if( resultVector.empty() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_EXECUTION_FAILED, "No valid answer on command " + cmd + " received!" ); + } + else + { + std::vector::iterator it = find( resultVector.begin(), resultVector.end(), "ERR2" ); + if( it != resultVector.end() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_EXECUTION_FAILED, "Lens is in manual focus mode, therefore focus settings can not be applied!" ); + } + + it = find( resultVector.begin(), resultVector.end(), okToken_ ); + if( it == resultVector.end() ) + { + ExceptionFactory::raiseException( MVIA_FUNCTION, __LINE__, DMR_EXECUTION_FAILED, "No valid answer on command " + cmd + " received!" ); + } + else + { + if( expectedResult == okToken_ ) + { + result = resultVector[resultVector.size() - 1]; + } + else + { + okIndex = distance( resultVector.begin(), it ); + } + + if( expectedResult == doneToken_ && ( ( resultVector.size() - 1 ) == okIndex ) ) + { + result = "0"; + } + else if( ( expectedResult == doneToken_ ) && ( resultVector.size() >= okIndex ) ) + { + const size_t cnt = resultVector.size(); + for( size_t i = 0; i < cnt; i++ ) + { + if( resultVector[i].find( doneToken_ ) == 0 ) + { + resultVector[i] = resultVector[i].substr( doneToken_.size() ); + std::vector tmpVector; + split( resultVector[i], ",", tmpVector ); + result = tmpVector[0]; + } + } + } + } + } + return result; + } + bool isLensPresent( unsigned int timeout_ms = 0 ) const + { + return( sendCommandAndGetResult( prepareCommand( "lp", delimiter_ ), "OK", getTimeoutToUse( timeout_ms ) ) == "1" ); + } + void readApertureLimits( int& focalLength, double& fStopMin, double& fStopMax, unsigned int& fStopStepCount, unsigned int timeout_ms ) const + { + std::string resultToParse = sendCommandAndGetResult( prepareCommand( "ls", delimiter_ ), "OK", std::chrono::milliseconds( timeout_ms ) ); + std::vector seglist = prepareReturnValues( resultToParse, "fm:@", "," ); + + focalLength = stoi( seglist[0] ); + fStopMin = returnValueToFStopValue( seglist[1] ); + fStopStepCount = stoi( seglist[2] ); + fStopMax = returnValueToFStopValue( seglist[3] ); + } + /// \brief Reads the current focus value from the device. + /** + * \return The value the focus is currently set to. + */ + void readFocusLimits( int& focusMin, int& focusMax, unsigned int timeout_ms ) const + { + std::string resultToParse = sendCommandAndGetResult( prepareCommand( "fp", delimiter_ ), "OK", std::chrono::milliseconds( timeout_ms ) ); + std::vector seglist = prepareReturnValues( resultToParse, "fminaxcuret:", " " ); + focusMin = stoi( seglist[0] ); + focusMax = stoi( seglist[2] ); + } +}; + +} // namespace labs +} // namespace GenICam +} // namespace acquire +} // namespace mvIMPACT + +#endif // #ifndef MVIMPACT_ACQUIRE_GENICAM_LENS_CONTROL_H diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_helper.h b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_helper.h new file mode 100644 index 0000000..0bba122 --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/mvIMPACT_acquire_helper.h @@ -0,0 +1,805 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 MVIMPACT_ACQUIRE_HELPER_H +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define MVIMPACT_ACQUIRE_HELPER_H MVIMPACT_ACQUIRE_HELPER_H +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- +#include + +#ifndef WRAP_ANY +# include +# include +# include +# include +# include +# include +# include +# include +#endif // #ifdef WRAP_ANY + +#ifdef _MSC_VER +# pragma push_macro("max") // otherwise we can't work with the 'numeric_limits' template here as Windows defines a macro 'max' +# undef max +#endif // #ifdef _MSC_VER + +#if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) && (!defined(CPP_STANDARD_VERSION) || ( defined(CPP_STANDARD_VERSION) && (CPP_STANDARD_VERSION < 11))) +# error "Combining the mvIMPACT_acquire_helper.h and mvIMPACT_acquire_display.h requires 'CPP_STANDARD_VERSION' being defined and set to a minimal value of 11! See documentation of the class mvIMPACT::acquire::helper::RequestProvider for details." +#endif // #if defined(MVIMPACT_ACQUIRE_DISPLAY_H_) && (!defined(CPP_STANDARD_VERSION) || ( defined(CPP_STANDARD_VERSION) && (CPP_STANDARD_VERSION < 11))) + +namespace mvIMPACT +{ +namespace acquire +{ +namespace helper +{ + +//----------------------------------------------------------------------------- +/// \brief A thread-safe queue. +/** + * This class provides a thread-safe queue implementation with all the operations + * typically needed within a multi-threaded environment. + * + * \note This class requires a C++11 compliant compiler! + * + * \since 2.33.0 + * \ingroup CommonInterface + */ +template +class ThreadSafeQueue final +//----------------------------------------------------------------------------- +{ +public: + /// \brief Creates a new \b mvIMPACT::acquire::helper::ThreadSafeQueue instance. + explicit ThreadSafeQueue( + /// [in] The maximum number of elements this queue shall be allowed to store until another push operation will fail. + typename std::queue::size_type queueSizeMax = std::numeric_limits::size_type>::max() ) : + queue_(), isLocked_( false ), wakeupRequestPending_( false ), queueSizeMax_( queueSizeMax ), mutex_(), conditionVariable_() {} + /// \brief Copy-constructor (deleted) + /** + * Objects of this type shall not be copy-constructed! + */ + ThreadSafeQueue( const ThreadSafeQueue& src ) = delete; + /// \brief assignment operator (deleted) + /** + * Objects of this type shall not be assigned! + */ + ThreadSafeQueue& operator=( const ThreadSafeQueue& rhs ) = delete; + + //----------------------------------------------------------------------------- + /// \brief Defines valid queue result values. + /** + * These enumeration defines valid values that might be returned from some of the + * queue operations defined by the surrounding \b mvIMPACT::acquire::helper::ThreadSafeQueue + * class. + */ + enum TQueueResult + //----------------------------------------------------------------------------- + { + /// \brief The operation on the queue returned successfully. + qrNoError = 0, + /// \brief The operation on the queue could not be executed as the queue is currently full thus contains the maximum number of allowed elements. + qrFull, + /// \brief The operation on the queue could not be executed as the queue is currently locked. + qrLocked + }; + + /// \brief Clears the queue. Discards all data. + void clear( void ) + { + while( pop( 0, nullptr ) ) {}; + } + /// \brief Returns the maximum number of elements this queue can store. + /** + * When trying to push more elements into the queue than returned by this function the next mvIMPACT::acquire::helper::ThreadSafeQueue::push + * call will fail until at least one element has been extracted before. The maximum number of elements a queue can store + * can be specified when constructing the queue. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::clear \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::getCurrentSize \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::pop + * + * \return The maximum number of elements this queue can store. + */ + typename std::queue::size_type getMaxSize( void ) const + { + return queueSizeMax_; + } + /// \brief Returns the current number of elements stored by this queue. + /** + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::getMaxSize + * + * \return The current number of elements stored by this queue. + */ + typename std::queue::size_type getCurrentSize( void ) const + { + std::lock_guard scopeLock( mutex_ ); + return queue_.size(); + } + /// \brief Checks if this queue is currently full. + /** + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::getMaxSize + * + * \return + * - true if the queue is currently full + * - false otherwise + */ + bool isFull( void ) const + { + std::lock_guard scopeLock( mutex_ ); + return queue_.size() == queueSizeMax_; + } + /// \brief Locks the queue. + /** + * While a queue is locked subsequent calls to \b mvIMPACT::acquire::helper::ThreadSafeQueue::push will + * fail and will return \b mvIMPACT::acquire::helper::ThreadSafeQueue::qrLocked. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::getMaxSize, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::push + * + * \return + * - true if the queue was locked already + * - false otherwise + */ + bool lock( void ) + { + return isLocked_.exchange( true ); + } + /// \brief Unlocks the queue. + /** + * While a queue is locked subsequent calls to \b mvIMPACT::acquire::helper::ThreadSafeQueue::push will + * fail and will return \b mvIMPACT::acquire::helper::ThreadSafeQueue::qrLocked. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::getMaxSize, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::push + * + * \return + * - true if the queue was unlocked already + * - false otherwise + */ + bool unlock( void ) + { + return isLocked_.exchange( false ); + } + /// \brief Gets a copy of the oldest element from the queue. + /** + * Gets a copy of the \e oldest element in the queue and the same element that is popped out from the queue + * when mvIMPACT::acquire::helper::ThreadSafeQueue::pop is called. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::pop, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::push + * + * \return + * - true if the queue contains at least one element + * - false if the queue is empty + */ + bool front( + /// [in,out] A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be \a nullptr if a caller just wants + /// to check if there is at least one element stored be the queue right now. + T* pData = nullptr ) const + { + std::lock_guard scopeLock( mutex_ ); + const bool boResult = !queue_.empty(); + if( boResult && pData ) + { + *pData = queue_.front(); + } + return boResult; + } + /// \brief Adds a new copy of an element to the queue. + /** + * Adds a new copy of an element to the queue. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::front, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::pop + * + * \return + * - mvIMPACT::acquire::helper::ThreadSafeQueue::qrFull if the queue contains the maximum number of elements already. The new element will \b NOT be added then + * - mvIMPACT::acquire::helper::ThreadSafeQueue::qrLocked if the queue is currently in a locked state. The new element will \b NOT be added then + * - mvIMPACT::acquire::helper::ThreadSafeQueue::qrNoError otherwise + */ + TQueueResult push( + /// [in] A \a const \a reference to the element to store in the queue. The object must be copy-constructible as this operation + /// will create a copy of the object. + const T& t ) + { + std::lock_guard scopeLock( mutex_ ); + if( queue_.size() >= queueSizeMax_ ) + { + return qrFull; + } + + if( isLocked_.load() ) + { + return qrLocked; + } + + queue_.push( t ); + conditionVariable_.notify_one(); + return qrNoError; + } + /// \brief Removes the oldest element from the queue, effectively reducing its size by one. + /** + * Removes the oldest element from the queue, effectively reducing its size by one. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::front, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::push + * + * \return + * - true if the queue did contain at least one element + * - false if the queue was empty + */ + template + bool pop( + /// [in] The maximum time to wait for incoming data if the queue currently does not contain any data to pick up. + const std::chrono::duration& rel_time, + /// [in,out] A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be \a nullptr if a caller just wants + /// to remove an element from the queue but is not actually interested in it. + T* pData = nullptr ) + { + std::unique_lock scopeLock( mutex_ ); + return extractData( conditionVariable_.wait_for( scopeLock, rel_time, [this] { return !queue_.empty() || wakeupRequestPending_.load(); } ), pData ); + } + /// \brief Removes the oldest element from the queue, effectively reducing its size by one. + /** + * Removes the oldest element from the queue, effectively reducing its size by one. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::front, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::push + * + * \return + * - true if the queue did contain at least one element + * - false if the queue was empty + */ + bool pop( + /// [in] The maximum time (in mill-seconds) to wait for incoming data if the queue currently does not contain any data to pick up. + unsigned int timeout_ms, + /// [in,out] A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be \a nullptr if a caller just wants + /// to remove an element from the queue but is not actually interested in it. + T* pData = nullptr ) + { + return pop( std::chrono::milliseconds( timeout_ms ), pData ); + } + /// \brief Removes the oldest element from the queue, effectively reducing its size by one. + /** + * Removes the oldest element from the queue, effectively reducing its size by one. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::front, \n + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::push + * + * \return + * - true if the queue did contain at least one element + * - false if the queue was empty + */ + bool pop( + /// [in,out] A pointer to the storage location that shall receive a copy of the oldest element currently stored in the queue. Can be \a nullptr if a caller just wants + /// to remove an element from the queue but is not actually interested in it. + T* pData = nullptr ) + { + std::unique_lock scopeLock( mutex_ ); + conditionVariable_.wait( scopeLock, [this] { return !queue_.empty() || wakeupRequestPending_.load(); } ); + return extractData( true, pData ); + } + /// \brief Terminates a single wait operation currently pending from another thread without delivering data. + /** + * If one or multiple thread(s) are currently executing a \b mvIMPACT::acquire::helper::ThreadSafeQueue::pop operation \b ONE of these + * threads will get signaled and the call will return. + * + * \sa + * \b mvIMPACT::acquire::helper::ThreadSafeQueue::pop + */ + void terminateWait( void ) + { + { + std::lock_guard scopeLock( mutex_ ); + wakeupRequestPending_ = true; + } + conditionVariable_.notify_one(); + } +private: + bool extractData( const bool boWaitResult, T* pData ) + { + if( boWaitResult ) + { + if( !queue_.empty() ) + { + if( pData ) + { + *pData = std::move( queue_.front() ); + } + queue_.pop(); + return true; + } + else if( wakeupRequestPending_.load() ) + { + wakeupRequestPending_ = false; + } + } + return false; + } + + std::queue queue_; + std::atomic isLocked_; + std::atomic wakeupRequestPending_; + typename std::queue::size_type queueSizeMax_; + mutable std::mutex mutex_; + std::condition_variable conditionVariable_; +}; + +//----------------------------------------------------------------------------- +/// \brief A helper class that can be used to implement a simple continuous acquisition from a device. +/** + * This class is meant to provide a very convenient way of capturing data continuously from + * a device. All buffer handling is done internally. An application simply needs to start and stop + * the acquisition and can pick up data in between. + * + * Picking up data can be done in 2 ways: + * - Passing an arbitrary function accepting any desired number of parameters to on of the overloads of the + * function \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart + * - Calling \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart with \b NO parameters + * and then \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest consecutively + * + * Both methods internally create a thread. When passing the function pointer and parameters + * the function is invoked from this internal thread context. So an application should not spend + * much time here in order not to block the acquisition engine. When using the + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest approach the internal + * thread pushes it's data into an instance of \b mvIMPACT::acquire::helper::ThreadSafeQueue so + * capturing can continue if an application does not immediately pick up the data. + * + * \note Both ways of using the class have their pros and cons. However the + * \b mvIMPACT::acquire::helper::ThreadSafeQueue is only served when NOT passing a + * function pointer. + * + * \note Internally an instance to \b mvIMPACT::acquire::FunctionInterface is + * created. The number of requests available to this \b mvIMPACT::acquire::helper::RequestProvider + * must (if needed) be configured before starting the acquisition. See \b mvIMPACT::acquire::SystemSettings::requestCount + * for details. + * + * \attention + * An application shall \b NEVER store the raw pointer (mvIMPACT::acquire::Request*) to + * requests returned wrapped in std::shared_ptr objects! This would jeopardize + * auto-unlocking of request and thus more or less the purpose of this class. Instead + * always store the std::shared_ptr objects directly. When no longer needed simply + * dump them. Keeping them all will result in the acquisition engine to run out of buffers. + * It can only re-use mvIMPACT::acquire::Request when no more std::shared_ptr + * references to it exist. On the other hand make sure you did drop all references to requests before + * the \b mvIMPACT::acquire::helper::RequestProvider instance that did return them goes out of + * scope. Not doing this will result in undefined behavior! + * + * \if DOXYGEN_CPP_DOCUMENTATION + * \code + * // The easiest way to use this class is probably like this: + * Device* pDev = getDevicePointerFromSomewhere(); + * helper::RequestProvider requestProvider( pDev ); + * requestProvider.acquisitionStart(); + * for(size_t i = 0; i < 5; i++) + * { + * std::shared_ptr pRequest = requestProvider.waitForNextRequest(); + * std::cout << "Image captured: " << pRequest->imageOffsetX.read() << "x" << pRequest->imageOffsetY.read() << "@" << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << std::endl; + * } + * requestProvider.acquisitionStop(); + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * \endcode + * \endif + * + * a more complex example using the function pointer approach can be found in the description of the corresponding overload of \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart. + * + * \note This class requires a C++11 compliant compiler! + * + * \note When using this class together with \b mvIMPACT::acquire::display::ImageDisplay \b CPP_STANDARD_VERSION must be defined to a value greater than or equal to 11! If not + * some of the magic in \b mvIMPACT::acquire::display::ImageDisplay will not be compiled resulting in the auto-unlocking feature of the requests attached to the display will + * not work and might result in undefined behavior! + * + * \since 2.33.0 + * \ingroup CommonInterface + */ +class RequestProvider final +//----------------------------------------------------------------------------- +{ + struct RequestUnlocker + { + std::shared_ptr pFI_; + explicit RequestUnlocker( std::shared_ptr pFI ) : pFI_( pFI ) {} + void operator()( Request* pRequest ) + { + assert( pRequest && "Something weird that needs fixing has happened before: When a custom deleter is attached to a 'Request' objects shared_ptr this request should actually be valid!" ); + pRequest->unlock(); + pFI_->imageRequestSingle(); + } + }; + + Device* pDev_; + std::shared_ptr pFI_; + volatile bool boRunCaptureThread_; + std::unique_ptr pCaptureThread_; + ThreadSafeQueue > requestResultQueue_; + + static void captureThreadCallbackInternal( std::shared_ptr pRequest, RequestProvider* pInstance ) + { + pInstance->requestResultQueue_.push( pRequest ); + } + template + void captureThread( FUNC pFn, PARAMS ...params ) + { + TDMR_ERROR result = DMR_NO_ERROR; + while( ( result = static_cast( pFI_->imageRequestSingle() ) ) == DMR_NO_ERROR ) {}; + if( result != DEV_NO_FREE_REQUEST_AVAILABLE ) + { + assert( !"'FunctionInterface.imageRequestSingle' returned with an unexpected result!" ); + } + + manuallyStartAcquisitionIfNeeded( pDev_, *pFI_ ); + const unsigned int timeout_ms = {200}; + while( boRunCaptureThread_ ) + { + const int requestNr = pFI_->imageRequestWaitFor( timeout_ms ); + if( pFI_->isRequestNrValid( requestNr ) ) + { + std::shared_ptr pRequest( pFI_->getRequest( requestNr ), RequestUnlocker( pFI_ ) ); + pFn( pRequest, params... ); + } + } + manuallyStopAcquisitionIfNeeded( pDev_, *pFI_ ); + pFI_->imageRequestReset( 0, 0 ); + } + template + static void captureThreadStub( RequestProvider* pInstance, FUNC pFn, PARAMS ...params ) + { + return pInstance->captureThread( pFn, params... ); + } +public: + /// \brief Creates a new \b mvIMPACT::acquire::helper::RequestProvider instance. + explicit RequestProvider( + /// [in] A pointer to a \b mvIMPACT::acquire::Device object obtained from a \b mvIMPACT::acquire::DeviceManager object. + Device* pDev, + /// [in] A pointer to a request factory. + /// By supplying a custom request factory the user can control the type of request objects + /// that will be created by the function interface. + RequestFactory* pRequestFactory = nullptr ) : pDev_( pDev ), pFI_( std::make_shared( pDev, pRequestFactory ) ), boRunCaptureThread_( false ) {} + /// \brief Copy-constructor (deleted) + /** + * Objects of this type shall not be copy-constructed! + */ + RequestProvider( const RequestProvider& src ) = delete; + /// \brief assignment operator (deleted) + /** + * Objects of this type shall not be assigned! + */ + RequestProvider& operator=( const RequestProvider& rhs ) = delete; + /// \brief Starts the acquisition. + /** + * Will start the acquisition by creating an internal thread. To get access to the data that will be acquired from the device an application passes + * a callback function and a variable list of arbitrary parameters to this function. Whenever a request becomes ready this function then will be + * called (from within the internal thread's context!). What kind of function is passed is completely up to the application. The only restriction + * for the functions signature is that the first parameter must be std::shared_ptr pRequest. + * + * \attention Unlocking will be done automatically when the last reference to the \c std::shared_ptr goes out of + * scope. As a consequence do \b NOT store the raw pointer to the mvIMPACT::acquire::Request object stored by the \c std::shared_ptr but always + * the std::shared_ptr\ itself in order not to break reference counting. Do not call \b mvIMPACT::acquire::Request::unlock + * for requests returned wrapped in a std::shared_ptr\ (you can but it is not necessary). + * + * If the acquisition is already running then calling this function will raise an exception of type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \if DOXYGEN_CPP_DOCUMENTATION + * + * \code + * // EXAMPLE + * //----------------------------------------------------------------------------- + * struct ThreadParameter + * //----------------------------------------------------------------------------- + * { + * Device* pDev_; + * unsigned int requestsCaptured_; + * Statistics statistics_; + * explicit ThreadParameter( Device* pDev ) : pDev_( pDev ), requestsCaptured_( 0 ), statistics_( pDev ) {} + * ThreadParameter( const ThreadParameter& src ) = delete; + * ThreadParameter& operator=( const ThreadParameter& rhs ) = delete; + * }; + * + * //----------------------------------------------------------------------------- + * /// Gets called for each 'Request' object that becomes ready. No need to call 'Request::unlock'! + * /// Unlocking will be done automatically when the last 'shared_ptr' reference to this + * /// request goes out of scope. + * void myThreadCallback( shared_ptr pRequest, ThreadParameter& threadParameter ) + * //----------------------------------------------------------------------------- + * { + * ++threadParameter.requestsCaptured_; + * // display some statistical information every 100th image + * if( threadParameter.requestsCaptured_ % 100 == 0 ) + * { + * const Statistics& s = threadParameter.statistics_; + * cout << "Info from " << threadParameter.pDev_->serial.read() + * << ": " << s.framesPerSecond.name() << ": " << s.framesPerSecond.readS() + * << ", " << s.errorCount.name() << ": " << s.errorCount.readS() + * << ", " << s.captureTime_s.name() << ": " << s.captureTime_s.readS() << endl; + * } + * if( pRequest->isOK() ) + * { + * cout << "Image captured: " << pRequest->imageOffsetX.read() << "x" << pRequest->imageOffsetY.read() << "@" << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << endl; + * } + * else + * { + * cout << "Error: " << pRequest->requestResult.readS() << endl; + * } + * } + * + * //----------------------------------------------------------------------------- + * int main( void ) + * //----------------------------------------------------------------------------- + * { + * DeviceManager devMgr; + * Device* pDev = getDeviceFromUserInput( devMgr ); + * if( pDev == nullptr ) + * { + * cout << "Unable to continue! Press [ENTER] to end the application" << endl; + * cin.get(); + * return 1; + * } + * + * cout << "Initialising the device. This might take some time..." << endl; + * try + * { + * pDev->open(); + * } + * catch( const ImpactAcquireException& e ) + * { + * // this e.g. might happen if the same device is already opened in another process... + * cout << "An error occurred while opening the device " << pDev->serial.read() + * << "(error code: " << e.getErrorCodeAsString() << ")."; + * return 1; + * } + * + * cout << "Press [ENTER] to stop the acquisition thread" << endl; + * ThreadParameter threadParam( pDev ); + * helper::RequestProvider requestProvider( pDev ); + * requestProvider.acquisitionStart( myThreadCallback, std::ref( threadParam ) ); + * cin.get(); + * requestProvider.acquisitionStop(); + * + * return 0; + * } + * \endcode + * \elseif DOXYGEN_JAVA_DOCUMENTATION + * \code + * \endcode + * \elseif DOXYGEN_PYTHON_DOCUMENTATION + * \code + * \endcode + * \endif + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStop, \n + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest + */ + template + void acquisitionStart( + /// [in] An arbitrary function that shall be called from the internal thread context whenever a \b mvIMPACT::acquire::Request object becomes ready + FUNC pFn, + /// [in] A variable number of arbitrary arguments that shall be passed to the thread callback function passed as the previous argument. + PARAMS ...params ) + { + if( boRunCaptureThread_ ) + { + ExceptionFactory::raiseException( __FUNCTION__, __LINE__, DMR_BUSY, "This object already has its thread running!" ); + } + boRunCaptureThread_ = true; + // 'make_unique' was not introduced until C++14 + pCaptureThread_ = std::unique_ptr( new std::thread( &RequestProvider::captureThreadStub, this, pFn, params... ) ); + } + /// \brief Starts the acquisition. + /** + * Will start the acquisition by creating an internal thread. To get access to captured blocks of data (typically images) an application can periodically call + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest afterwards. + * + * If the acquisition is already running then calling this function will raise an exception of type \b mvIMPACT::acquire::ImpactAcquireException. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStop, \n + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest + */ + void acquisitionStart( void ) + { + if( boRunCaptureThread_ ) + { + ExceptionFactory::raiseException( __FUNCTION__, __LINE__, DMR_BUSY, "This object already has its thread running!" ); + } + boRunCaptureThread_ = true; + // clean up stuff from previous operations + requestResultQueue_.clear(); + pFI_->imageRequestReset( 0, 0 ); + // 'make_unique' was not introduced until C++14 + pCaptureThread_ = std::unique_ptr( new std::thread( &RequestProvider::captureThreadStub pRequest, RequestProvider* pInstance ), RequestProvider*>, this, RequestProvider::captureThreadCallbackInternal, this ) ); + } + /// \brief Stops the acquisition. + /** + * Will stop the acquisition previously started by a call to mvIMPACT::acquire::helper::RequestProvider::acquisitionStart. + * + * \note + * If the acquisition is not running then calling this function will do nothing. + * + * \note + * This is a convenience function! Internally this is simply a combination of \b mvIMPACT::acquire::helper::RequestProvider::endThreadExecution and + * \b mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart, \n + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest + */ + void acquisitionStop( void ) + { + endThreadExecution(); + waitForThreadTermination(); + } + /// \brief Signaling the acquisition thread to terminate. + /** + * Will stop the acquisition previously started by a call to mvIMPACT::acquire::helper::RequestProvider::acquisitionStart. + * + * \note + * If the acquisition is not running then calling this function will do nothing! + * + * To wait for the acquisition thread to terminate + * \b mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination has to be called afterwards! To combine + * \b mvIMPACT::acquire::helper::RequestProvider::endThreadExecution and \b mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination + * use \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStop. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart, \n + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStop, \n + * \b mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination, \n + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest + * + * \since 2.41.0 + */ + void endThreadExecution( void ) + { + boRunCaptureThread_ = false; + } + /// \brief Waits for the acquisition thread to terminate. + /** + * Will stop the acquisition previously started by a call to mvIMPACT::acquire::helper::RequestProvider::acquisitionStart. + * + * In order to make this function return successfully \b mvIMPACT::acquire::helper::RequestProvider::endThreadExecution has to be called before + * or after(from a different thread then)! To combine \b mvIMPACT::acquire::helper::RequestProvider::endThreadExecution and + * \b mvIMPACT::acquire::helper::RequestProvider::waitForThreadTermination use \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStop. + * + * \note + * If the acquisition is not running then calling this function will do nothing. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart, \n + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStop, \n + * \b mvIMPACT::acquire::helper::RequestProvider::endThreadExecution, \n + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest + * + * \since 2.41.0 + */ + void waitForThreadTermination( void ) + { + if( pCaptureThread_ ) + { + pCaptureThread_->join(); + pCaptureThread_.reset(); + } + } + /// \brief Waits for the next request to become ready and will return a shared_ptr instance to it. + /** + * Waits for the next request to become ready and will return a std::shared_ptr\ instance to it effectively + * removing it from the internal queue. This is a blocking function. It will return not unless either a \b mvIMPACT::acquire::Request + * object became ready, the specified timeout did elapse or \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from a + * different thread. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart, \n + * \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest + * + * \return + * - true when a new request became ready + * - false otherwise + */ + bool waitForNextRequest( + /// [in] A timeout in milliseconds specifying the maximum time this function shall wait for a request to become ready + unsigned int ms, + /// [in,out] A pointer to the storage location that shall receive a pointer to the next \b mvIMPACT::acquire::Request object that becomes ready + /// or the oldest element already available. An application can pass \a nullptr if a caller just wants + /// to remove an element from the queue but is not actually interested in it. + std::shared_ptr* ppRequest ) + { + return requestResultQueue_.pop( ms, ppRequest ); + } + /// \brief Waits for the next request to become ready and will return a shared_ptr instance to it. + /** + * Waits for the next request to become ready and will return a std::shared_ptr\ instance to it effectively + * removing it from the internal queue. This is a blocking function. It will return not unless either a mvIMPACT::acquire::Request + * object became ready, the specified timeout did elapse or \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from a + * different thread. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart, \n + * \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest + * + * \return A std::shared_ptr\ either holding a valid pointer to a mvIMPACT::acquire::Request object or \c nullptr if + * no data became ready and either \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from another + * thread or the specified timeout has elapsed. + */ + std::shared_ptr waitForNextRequest( + /// [in] A timeout in milliseconds specifying the maximum time this function shall wait for a request to become ready + unsigned int ms ) + { + std::shared_ptr pRequest; + requestResultQueue_.pop( ms, &pRequest ); + return pRequest; + } + /// \brief Waits for the next request to become ready and will return a shared_ptr instance to it. + /** + * Waits for the next request to become ready and will return a std::shared_ptr\ instance to it effectively + * removing it from the internal queue. This is a blocking function. It will return not unless either a mvIMPACT::acquire::Request + * object became ready or \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from a + * different thread. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::acquisitionStart, \n + * \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest + * + * \return A std::shared_ptr\ either holding a valid pointer to a mvIMPACT::acquire::Request object or \c nullptr if + * no data became ready and \b mvIMPACT::acquire::helper::RequestProvider::terminateWaitForNextRequest has been called from another + * thread. + */ + std::shared_ptr waitForNextRequest( void ) + { + std::shared_ptr pRequest; + requestResultQueue_.pop( &pRequest ); + return pRequest; + } + /// \brief Terminates a single wait operation currently pending from another thread without delivering data. + /** + * If one or multiple thread(s) are currently executing a \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest operation \b ONE of these + * threads will get signaled and the call will return. + * + * \sa + * \b mvIMPACT::acquire::helper::RequestProvider::waitForNextRequest + */ + void terminateWaitForNextRequest( void ) + { + requestResultQueue_.terminateWait(); + } +}; + +} // namespace helper +} // namespace acquire +} // namespace mvIMPACT + +#ifdef _MSC_VER +# pragma pop_macro("max") +#endif + +#endif //MVIMPACT_ACQUIRE_HELPER_H diff --git a/Cigarette/MvIMPACT/mvIMPACT_CPP/versionInfo.txt b/Cigarette/MvIMPACT/mvIMPACT_CPP/versionInfo.txt new file mode 100644 index 0000000..5f5b557 --- /dev/null +++ b/Cigarette/MvIMPACT/mvIMPACT_CPP/versionInfo.txt @@ -0,0 +1,11726 @@ +=============================================================================================== + version info mvIMPACT Acquire +=============================================================================================== +Date: Release: Changes: Affected modules, files or packages: +-------------------------------------------------------------------------------------------------------------------------------------------- +03.05.2021 2.43.0 + NEW FEATURES: + - If an image is loaded into wxPropView, the file name will now be visible in the (wxPropView) + status bar and also with the 'Request Info' overlay. + - On Linux systems, all mvIMPACT Acquire log files are now read- and writable by any (all shipped Linux packages) + system user, no matter which user created them first. + - Linux installation scripts will install dependencies (e.g. wxWidgets, ...) on x86_64 (all shipped Linux x86_64 packages) + Red Hat Linux and Fedora systems now. + - The Java wrapper for mvIMPACT Acquire added in version 2.36.0 is now shipped for (all shipped Linux ARM64 and ARMhf packages) + ARM64 and ARMhf platforms as well. + - Resend requests can be sent to devices residing in different subnets now. (mvGigECapture.sys, version 2.4.2.71) + (mvGigECapture2.sys, version 3.2.2.71) + + BUGS FIXED: + - mvBlueFOX devices were not reported by the mvDeviceManager library if another process (mvBlueFOX-lib) + has opened this device already. + (Linux only) + - Checking if a certain device is in use or opening a device from multiple processes in (mvGenTLConsumer-lib) + parallel could results in false positives for the 'is in use' state or a failure + when trying to open an unused device. + +09.04.2021 2.42.0 + NEW FEATURES: + - It is now possible to choose, if image meta data is saved beside the image data, (wxPropView) + when the 'Save Image...' or 'Save All Recorded Images' feature is used + - Support for mvBlueFOX-ML/IGC202vG devices added. (mvBlueFOX-lib) + - Support for permanent Unicast device discoveries added. (mvGenTLProducer.cti) + - Added a menu to configure permanent Unicast device discoveries. (mvIPConfigure) + + BUGS FIXED: + - Creating a System.Drawing.Bitmap object from a RGB888Packed request buffer did (mv.impact.acquire.dll) + result in a corrupt bitmap if the source image width was divisible by 4. + (Linux only) + - When an image was loaded from hard drive into wxPropView, the analysis plots were (wxPropView) + not automatically refreshed with data from that image. + - If the device was closed before the destruction of the corresponding FirmwareUpdater (all shipped packages) + object, undefined behavior could occur. + (Bug introduced in version 2.41.0) + - The parameters of the FirmwareUpdater class constructor in .NET didn't change the (mv.impact.acquire.dll) + behaviour of the following update. Only default update settings were used. + (Bug introduced in version 2.41.0) + - Failing to rename or re-create existing log files could result in a crash. (all shipped packages) + This could happen e.g. on Linux when 'root' did create a set of log-files and then + later a standard user tried to override them with a new mvIMPACT Acquire process. + - wxPropView could crash when 'Synchronous Method Execution' was switched off. (wxPropView) + (Bug introduced in version 2.41.0) + +05.03.2021 2.41.0 + NEW FEATURES: + - mvIMPACT Acquire is now capable of updating the firmware of our GenICam devices and (all shipped packages) + the mvBlueFOX devices. For further information see the 'FirmwareUpdater' class in the + SDK manuals. + - Added color correction matrix for Sony IMX530, IMX531, IMX532 based products. (all shipped packages) + - Property 'ImageProcessingMaximumThreadCount' added to 'SystemSettings'. See (all shipped packages) + 'Image Processing' chapter in the API manuals. + - GEV devices can be discovered in subnets different from the host's subnet via unicast (mvGenTLProducer.cti) + device discoveries now. + - 'Capture -> Set Image Processing Thread Count' option added. See 'Advanced Operation' (wxPropView) + in the wxPropView chapter of the GUI tools manual. + - Certain serial numbers can be passed inside a 'update firmware file' to define a (mvDeviceConfigure) + subset of devices to be updated for a certain product type. See command-line + interface documentation of mvDeviceConfigure for details. + + UPDATES: + - Added support for the GEV_FLAG_RESEND_RANGE_ERROR flag specified in the GigE Vision. (mvGigECapture.sys, version 2.4.1.70) + (mvGigECapture2.sys, version 3.2.1.70) + - JPEG data coming from a device is no longer deflated within the capture thread since (wxPropView) + this could result in the capture queue to run empty. + + BUGS FIXED: + - When using the Bayer filter "RawToPlanes" on color images with an even width, the (all shipped packages) + resulting image ended up being one pixel to wide. + (Bug introduced in version 2.36.0) + - The environment variable MVIMPACT_ACQUIRE_DATA_DIR was not correctly evaluated on (all shipped packages) + Windows. As a consequence it e.g. was not possible to configure the log-output based + on that variable. + - Without elevated rights DirectShow related information was not available. Now there (mvDeviceConfigure) + is a hint on how to get this information. The menu item to change the DirectShow + friendly name is only enabled, if the application is running with elevated rights + and the device is already registered as DirectShow device. + - When a mvBlueFOX3 booted with bootprogrammer firmware version 0.33.1693.2, the (all shipped packages) + device could not be initialized to update the firmware, if device specific settings + were present on the host system. + +25.11.2020 2.40.3 + UPDATES: + - When running 'mvDeviceConfigure' with the 'hidden' parameter no more progress dialogs (mvDeviceConfigure) + will pop up. + - Calling acquisitionStop() for GEV devices took up to 50ms on Linux. (mvGenTLProducer.cti) + + BUGS FIXED: + - When an error in the LSFR pattern was detected during the first iteration of the GEV (mvGenTLProducer.cti) + packet size auto-negotiation when 'AutoNegotiatePacketSizeMode' was set to + 'HighToLow' (the default) the algorithm did terminate and 576 was used as the packet + size potentially resulting in poor performance. + - GEV multicast reception of streaming data did not work on Linux systems. (mvGenTLProducer.cti) + (Bug introduced in 1.12.59) + - When constantly starting and stopping the acquisition on Linux systems sometimes even (mvGenTLProducer.cti) + though the device did start streaming data nothing was received by the driver. + - Clicking on the 'Enable AWB' checkbox of the AOI wizard could result in a crash. (wxPropView) + +09.11.2020 2.40.2 + UPDATES: + - Only the first call to 'DMR_InitVideoStreamAPI' will result in an actual load (mvDeviceManager-lib) + attempt to the FFmpeg libraries. Previous releases did result in a failure message + when the libraries could not be found on every function call. + + BUGS FIXED: + - When running an mvIMPACT Acquire application as root and then later trying to run (all shipped packages for Unix/Linux systems) + another mvIMPACT Acquire application as a non-root user the application did not start + until the file /dev/shm/sem.4ED0DA5F-C112-49a2-A313-E80B9F259830 has been removed + from the system. + +22.10.2020 2.40.1 + NEW FEATURES: + - All mvIMPACT Acquire packages for Linux will also use OpenMP for internal image (all shipped packages for Unix/Linux systems) + processing algorithms. Displaying image in wxPropView will also make use of OpenMP + now. See 'Known Issues -> Linux' for additional details and how this might affect + your application. + - The 'FirmwareUpgrade' console application is capable of updating the firmware of (all shipped packages for Unix/Linux systems) + mvBlueFOX3 devices now. + - 'CaptureToOpenGLMemory' example added to the documentation of the C++ API. This (mvIMPACT_Acquire_API_CPP_manual) + can serve as a starting point for displaying images using OpenGL. + + BUGS FIXED: + - On ARM platforms only 1000 images could be captured from MATRIX VISION GEV devices (all shipped packages for GenICam compliant devices, Linux/ARM) + until an annoying overlay was displayed. + (Bug introduced in version 2.40.0) + - On Windows platform the gray values of pixels did not match the exact position in the (wxPropView) + image due to unprecise scaling in case of high zoom levels. + +15.10.2020 2.40.0 + NEW FEATURES: + - The .NET Standard 2.0 build of the mvIMPACT Acquire .NET runtime has been added to (all shipped packages for Unix/Linux systems) + all Linux installers. This runtime will allow to write .NET Core applications with + mvIMPACT Acquire. See .NET API manual for details. + - Added the ability to store image metadata beside the image in a *.xml file. This (wxPropView) + feature is available for 'Snapshot' and 'Hard Disk' mode. + - Added 'CorrectionModeReverseX' and 'CorrectionModeReverseY' properties to flat field (all shipped packages) + filter. + - New example added to all packages: 'TimestampFeatures'. (all shipped packages) + - Added updated versions of the GEV filter driver that provide additional analysis (mvGigECapture.sys, version 2.4.0.68) + data and a slightly optimized default behaviour of the packet resend algorithm (mvGigECapture2.sys, version 3.2.0.68) + especially for LAG configurations. + - Property 'mvLinkCommandTimeoutCheckGranularity' added to 'DeviceModule' API. (all shipped packages) + - The 'ColorTwist' is available for every platform now thus also for ARM. (all shipped packages) + - Added API functions to pause and resume compressed video stream recording. (all shipped packages) + - The tooltips are now visible twice as long. That should make it easier to read (wxPropView, mvDeviceConfigure) + through the longer information. + + UPDATES: + - Internal migration to libexpat 2.2.9. (all shipped MSI-based packages) + + BUGS FIXED: + - Gains were not taken into account for Bayer to mono conversions within the de-Bayer (all shipped packages) + filter on Linux or 64-bit Windows systems. + - When using version 3.x of the FFmpeg libraries together with mvIMPACT Acquire H.264 (mvDeviceManager-lib) + or H.265 encoding the resulting files did use a different encoder than selected. This + was caused by a major change in FFmpeg with release 4.0. Therefore the support for + FFmpeg 3.x was removed from mvIMPACT Acquire. + - The FFmpeg libraries were not detected on Linux. (mvDeviceManager-lib) + - The experimental Birger EF-232 mount interface provides correct focus values after (all shipped packages) + initialization. + - When the same producer file name was detected in more than a single location it was (mvGenTLConsumer-lib) + loaded into the process multiple times. + - When the final output pixel format was one of the more exotic YUV formats the Bayer (all shipped packages) + filter did not process images carrying a Bayer attribute. So the resulting image did + never carry any color information. + - Finding the system's libusb did not work correctly on Debian systems. (mvGenTLProducer.cti) + - Calling acquisitionStop() for GEV devices took up to 500ms on Linux and Windows (mvGenTLProducer.cti) + systems not utilizing the NDIS filter driver. + - Using the 'Quick Setup Wizard' on ARM based platforms could result in crashes. (wxPropView) + - The 'Quick Setup Wizard' did not always configure the highest possible frame rate (wxPropView) + when the 'Highest Speed' option was selected. + - In some cases the 'Quick Setup Wizard' disabled the the camera's AEC once it was (wxPropView) + enabled in the wizard before. + - On Linux 'Update firmware from online package' did use a wrong directory to store (mvDeviceConfigure) + the package and therefore the update did not work. + +15.07.2020 2.39.0 + NEW FEATURES: + - The 'GenICam' namespace now contains the full SFNC 2.6 feature set. (mvIMPACT_acquire_GenICam.h) + - 'CaptureToMegaBuffer' example added to the documentation of the C++ API. This (mvIMPACT_Acquire_API_CPP_manual) + can serve as a starting point for making optimal use of the mvBlockscan mode. + - New command line parameter added to mvIPConfigure: 'log_file' which allows to (mvIPConfigure) + specify a log file that will contain the output, after the tool is closed. + - mvIMPACT Acquire learned how to connect to the FFmpeg project. As a result with (all shipped packages) + an installed version of FFmpeg present on the system compressed video streams + can now be created. Have a look at the FFmpeg section in the 'Legal Notice' chapter + of the SDK manual for details. + - All Windows binaries are shipped with a digital signature now! (all shipped MSI-based packages) + + BUGS FIXED: + - Capturing images into user supplied memory could crash for various pixel and test (mvVirtualDevice-lib) + modes(vdtmLeakyPixelTestImageMono8Bayer, vdtmHotAndColdPixelTestImageRGB888Packed as + well as all packed RGB/BGR formats and test modes). + - Calling 'DMR_AllocImageBuffer' with an invalid/unsupported pixel format could result (mvDeviceManager-lib) + in a crash. + - In some cases using the 'forceAutoConfigurePersistent' and 'forceAutoConfigureDHCP' (mvIPConfigure) + command line parameters did not work correctly. + - Using the 'Polarized Data Extraction' filter mode 'PseudoColorRepresentation' (all shipped packages) + on Linux systems could result in a crash. + +10.06.2020 2.38.0 + NEW FEATURES: + - A .NET Standard 2.0 build of the mvIMPACT Acquire .NET runtime has been added to (all shipped MSI-based packages) + all Windows installers. This runtime will allow to write .NET Core applications with + mvIMPACT Acquire. See .NET API manual for details. + - 'Synchronous Method Execution' check-box added to the 'Options' dialog. The new (wxPropView) + default is 'Off', the previous behaviour was 'On'. When 'On' methods in the property + grid will be executed synchronously thus will block all other window messages until + the method has been executed thus will e.g. also block the image display. + - Three more modes added to 'Polarized Data Extraction' filter. (all shipped packages) + 'DegreeOfPolarization': The degree of the polarization in the image is visualized. + 'AngleOfPolarization': The angle of the polarization in the image is visualized. + 'PseudoColorRepresentation': The degree and the angle of the polarization in the + image are used to calculate a pseudo-color image. + - 'ContinuousCaptureFFmpeg' example added to the documentation of the C++ API. This (mvIMPACT_Acquire_API_CPP_manual) + can serve as a starting point for creating compressed video streams. + - New command line parameter added to mvDeviceConfigure, mvGigEConfigure and (mvDeviceConfigure) + mvIPConfigure: 'hidden' which might be useful e.g. during silent installation (mvGigEConfigure) + procedures as it will not show the splash screen or the application window while the (mvIPConfigure) + application can still be used to install or remove the filter driver. + - Experimental support for Birger EF-232 mount added to (all shipped packages) + mvIMPACT::acquire::GenICam::labs namespace. + - 'GammaInverter' property added to LUT filter. (all shipped packages) + + UPDATES: + - Updated integrated U3VBootProgrammer to 0.38.2344.2. (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - From this version onwards the mvIMPACT Acquire .NET API be built for the target (all .NET related libraries and projects) + framework 4.5.1. Previous versions did target version 3.5 of the .NET framework which + was released with Visual Studio 2008. Since modern Windows 10 systems are no longer + shipped with the .NET 3.5 framework using the mvIMPACT Acquire .NET runtime therefore + became impractical. .NET 4.5.1 was introduced with Visual Studio 2013 so should work + flawless on most systems. Applications still need .NET 3.5 have to use the .NET API + shipped with mvIMPACT Acquire 2.37.1 or below. + - During installation and removal of the GEV filter driver the new 'hidden' parameter (mvGenTL_Acquire*.exe) + is passed to mvGigEConfigure. The tool therefore will not be visible while the + installation is running. + - The 'workerPriority' property of the SystemSettings class as well as the enumeration (all shipped packages) + 'TThreadPriority' has been removed from the public interface. It had been declared + deprecated in 2.24.0 in 2017. See 'Porting Existing Code' in the corresponding API + manual for details. + + BUGS FIXED: + - Trying to open a GenICam device with an incorrect 'AcquisitionMode' property setup (wxPropView) + could result in a crash. + - The DirectShow interface finally works with VLC versions >= 3.0.0 now. (mvDeviceManager-lib) + - If the 'FFC Calibration'-tab of the 'AOI Wizard' is selected for a monochrome camera (wxPropView) + wxPropView might crash. + - If images are saved using the "Snapshot To Hard Disk" or "Hard Disk Recording" mode (wxPropView) + the resulting images were stored in the wrong file format. + (Bug introduced in version 2.37.0) + - Downloading firmware files on Linux systems did not work as a result of an incorrect (mvDeviceConfigure) + path used to store the downloaded file. + +19.03.2020 2.37.1 + NEW FEATURES: + - The 'Quick Setup Wizard' allows to define if the color processing should be done (wxPropView) + within the camera or on host side now. + - Besides 8- and 10-bit pixel formats the 'Quick Setup Wizard' supports 12-bit pixel (wxPropView) + formats for devices utilizing a Sony IMX sensor. This will be the new + 'Best Quality' setting for the previously mentioned Sony IMX sensors now. + - wxPropView's 'Update Info' dialog allows to download and update each MATRIX VISION (wxPropView) + software package by just a few clicks now. + - Color correction matrix for Sony IMX540, IMX541, IMX542 based products added. (all shipped packages) + + BUGS FIXED: + - When not calling mvDispSetBitmapRectangle or ImageDisplay::SetDisplayRectangle no (mvDisplay-lib) + image was displayed(or the display image in fact had a size of 0 by 0). + (Bug introduced in version 2.37.0) + - The 'PtpEnable' property was incorrectly mapped as an integer property while in fact (mvIMPACT_acquire_GenICam.h) + it is a 'PropertyIBoolean'. (mv.impact.acquire.dll) + - The 'GevGVCPExtendedStatusCodesSelector' property was incorrectly mapped as a (mvIMPACT_acquire_GenICam.h) + 'PropertyIBoolean' while in fact is an enumerated property. (mv.impact.acquire.dll) + +03.03.2020 2.37.0 + NEW FEATURES: + - Initial version of the Python API manual for mvIMPACT Acquire added. See (all shipped packages) + mvIMPACT_Acquire_API_PYTHON_manual.chm or https://www.matrix-vision.com/manuals/ + for additional details. + - Ported all code snippets from the C++ documentation to Java and Python. (all shipped packages) + - The Java wrapper for mvIMPACT Acquire added in version 2.36.0 is now shipped for (all shipped packages) + x86 platforms as well. + - The Windows version of wxPropView supports different scaling modes now. Right-click (wxPropView) + on the display and select 'Scaling Mode' from the context menu. + - Storing the current image during the acquisition is possible now. Either right-click (wxPropView) + on the display and select 'Save Current Image' or 'Copy Current Image To Clipboard' + from the context menu or press 'CTRL+C' to immediately copy the current image into + the clipboard. + - Storing images via a single hit on the space bar is possible now as well. (wxPropView) + Just enable the 'Snapshot' mode via the 'Setup Snapshot Mode' option from 'Capture' + menu. Select the display window you want to capture snapshots from by left-clicking + into the display area. + - The 'Quick Setup Wizard' allows to define if the color processing should be done (wxPropView) + within the camera or on host side now. + - Defective pixel filter: Property 'DefectivePixelsMaxDetectionCount' added. See (all shipped packages) + documentation of the property for additional information. + - The way the packet size auto negotiation for GEV devices is handled can be configured (mvGenTLProducer.cti) + by the user now. + - Added 'AutoNegotiatePacketSize' and 'AutoNegotiatePacketSizeMode' property to + mvIMPACT::acquire::Device (C++) and (mvIMPACT_acquire.h) + mv.impact.acquire.Device (.NET) (mv.impact.acquire.dll) + + UPDATES: + - Internal migration to Doxygen 1.8.17. + - Improved error recovery when cameras did send data with non-continuous block IDs. (mvGigECapture.sys, version 2.3.9.67) + (mvGigECapture2.sys, version 3.1.9.67) + - Some very small changes to allow compilation with the latest version of Visual Studio (exampleHelper.h) + 2019 with /std:c++17 and /std:c++latest. + - Updated integrated U3VBootProgrammer to 0.37.2227.2. (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - From this version onwards the official support for Linux 32-bit x86/i386 systems as (all shipped packages for Unix/Linux systems) + well as Linux ARMsf will end. Until further notice the required installation packages + will still be build but will only be provided on special request. + - Removed support for features that have been declared deprecated for centuries: + C++: FunctionInterface::isRequestOK: Use Request::isOK instead. (mvIMPACT_acquire.h) + FunctionInterface::saveSystemToDefault: Use + FunctionInterface::saveSettingsToDefault instead + C: 'DMR_SaveSystemToDefault': This function is no longer needed since calling (mvDeviceManager.h) + 'DMR_SaveSettingToDefault' also stores the data previously stored by + 'DMR_SaveSystemToDefault' since version 1.12.58. + 'DMR_UpgradeDeviceFeatures': This function did never do anything useful! + Simply remove all occurrences! + - Performing a white balance calibration with 'WBAoiMode' set to 'amCentered' uses (all shipped packages) + a center quarter of the original image instead of just 50 by 50 pixels now. + - Lists without any visible children will become invisible as well now in the property (wxPropView) + grid control. + - The property grid will remember its state for each device when switching between (wxPropView) + devices now. + - The auto negotiation process of the MTU for GigEVision devices starts with the (mvGenTLProducer.cti) + network interface's MTU and iterates downwards now. Until now it worked reverse by + starting at the minimal value and iterating upwards. + + BUGS FIXED: + - Calling 'mvDispSetInterpolationMode' (C-API) or 'ImageDisplay::SetInterpolationMode' (mvDisplay-lib) + (other APIs) after calling 'mvDispSetImage' (C-API) or 'ImageDisplay::SetImage' + (other APIs) could result in the image being displayed with an incorrect pitch. + - Using interpolation modes different from 'IM_NEAREST_NEIGHBOUR' in combination with (mvDisplay-lib) + dynamic changes in the AOI and pixel formats could result in incorrectly displayed + images and even crashes. + - Defective pixel filter: When calibrating a sensor directly after initialising a (all shipped packages) + device before calling 'Reset Calibration Data' at least once the list of detected + defective pixels did always contain pixel 0/0. + - When 'DMR_ImageRequestSingle' or 'imageRequestSingle' of the FunctionInterface did (mvGenTLConsumer-lib) + fail calling 'AcquisitionStop' afterwards did never return. + - When switching between devices using the combo-box in the upper left section of the (wxPropView) + window wxPropView could crash randomly. + - The camera based color correction configured by the 'Quick Setup Wizard' did not (wxPropView) + work if the camera was transmitting Bayer pixel data. + - The 'Quick Setup Wizard' could crash when started by using the "Show 'Quick Setup' (wxPropView) + Wizard now"-Button of the "Welcome to the Quick Setup Wizard" dialog. + (Bug introduced in version 2.36.0) + - On Linux using sliders with logarithmic behaviour in the property grid could result (wxPropView) + in the application to lock up. + - The LUT Wizard allowed to check the 'Enable'-check-box even if the selected LUT could (wxPropView) + not be enabled due to another LUT which is currently active and using the same + resources on the device. + - When deriving from mvIMPACT.acquire.ComponentCallback and application did crash when (Python API) + the 'execute' method was called for the first time. + - The 'state' property of the class 'mvIMPACT.acquire.DigitalOutput' could not be (Python API) + written. + - Functions like 'mvIMPACT.acquire.FunctionInterface.getCurrentRequestLayout' and some (Python API) + versions of 'mvIMPACT.acquire.FunctionInterface.imageRequestSingle' and + 'mvIMPACT.acquire.ImageDisplay.GetImage' could not be called. + +19.12.2019 2.36.0 + NEW FEATURES: + - Initial version of a full Java wrapper for mvIMPACT Acquire added. See product (all shipped packages) + specific manuals as well as the mvIMPACT_Acquire_API_JAVA_manual.chm or + https://www.matrix-vision.com/manuals/ for additional details. + - The mvIMPACT Acquire Python wrapper now exposes the same exception class hierarchy (Python API) + as the C++/C# API thus not only 'acquire.ImpactAcquireException' objects but also + all the derived types can be caught. + - New functions added to API: + - C++ API: mvIMPACT::acquire::WhiteBalancer::highQualityWhiteBalance (mvIMPACT_acquire.h) + - .NET API: mv.impact.acquire.WhiteBalancer.highQualityWhiteBalance (mv.impact.acquire.dll) + Those convenience functions allow to perform a white balance calibration using the + highest possible bit depth for the used device to get more precise correction + gain values. + + UPDATES: + - If possible the 'Quick Setup Wizard' will use the device's color transformation (wxPropView) + feature to apply color corrections and saturation if available. This reduces load + on the host CPU then. + - The overall size of the source code of the mvIMPACT Acquire Python wrapper has been (Python API) + reduced to about a third of its previous size thus should be easily digestible by + smaller systems as well now. + - mvHYPERION Linux kernel driver and the respective installers now support kernel 5.3. (low level mvHYPERION driver, Linux) + + CHANGED BEHAVIOUR: + - Some incompatible changes have been applied to the Python interface. Please refer (Python API) + to the migration guide in the 'Python developers' chapter of your product. E.g.: + https://www.matrix-vision.com/manuals/mvBlueCOUGAR-X/Python_page_0.html + - The directory containing the Python interface moved from 'mvIMPACT_Python' to (Python API) + 'LanguageBindings/Python'. + - The C++ member mvIMPACT::acquire::CameraSettingsBlueDevice::autoControlParameters (mvIMPACT_acquire.h) + became private like in all other language bindings. Use the corresponding 'getter' + instead. + - When using the defective pixel filter in 'dpfm3x1Average' the algorithm doing the (all shipped packages) + actual pixel correction can deal with locally connected clusters of defective pixels. + - When a MATRIX VISION device offers defective pixel correction and this correction is (all shipped packages) + active then the driver based defective pixel correction filter is no longer switched + on automatically when defective pixel data is present on the device. + - In case a U3V capture buffer could not be queued(e.g. because the system is running (mvGenTLProducer.cti) + low on memory) the request object will be returned with the 'requestState' property + set to 'rrNotEnoughMemory' instead of 'rrRequestAborted' now. + + BUGS FIXED: + - Potential blue screen (BSOD) when working with the NDIS filter driver on Windows (mvGigECapture.sys, version 2.3.7.66) + when resend commands were initiated by the filter driver while new data was received (mvGigECapture2.sys, version 3.1.8.66) + in parallel. + - Potential crash when building Mono12Packed_V1/V2 buffers with Bayer attributes and (all shipped packages) + and a width not divisible by 2. + - Potential crashes in the channel split filter when working with (all shipped packages) + 'ibpfYUV411_UYYVYY_Packed' the format on an image with a width not divisible by 4. + - Potential crash when feeding buffers with an odd width into the Bayer conversion (all shipped packages) + filter with the 'RawToPlanes' mode selected. + - Detection of defective pixels did sometimes produce unexpected results when the (all shipped packages) + illumination was not perfect especially when in a color image one channel was in + saturation. + (Bug introduced in version 2.22.1) + - Opening the 'Quick Setup Wizard' for a GenICam device which did not support the (wxPropView) + Gamma feature the wizard closed immediately without further notice. + (Bug introduced in version 2.35.0) + - Images using the 'ibpfMono12Packed_V1' format could not be displayed. (wxPropView) + (Linux only) + - After changing parameters in the 'LUT Wizard' and selecting a different device the (wxPropView) + 'LUT Wizard' showed LUT values of the previously used device. + - Downloading firmware automatically did not work because of missing write rights to (mvDeviceConfigure) + MVIMPACT_ACQUIRE_DIR as a result of missing elevated privileges. + The firmware will be downloaded to MVIMPACT_ACQUIRE_DATA_DIR/FirmwareUpdates from + now. (Windows only) + (Bug introduced in version 2.35.0) + - Potential crashes when using user supplied capture memory in combination with image (mvVirtualDevice-lib) + processing like the defective pixel filter. + - Fixed a memory leak of about 256 bytes per network interface when GEV interfaces have (mvGenTLProducer.cti) + been enumerated. This leak only occurred once per dlopen/LoadLibrary of the + 'mvDeviceManager-lib'. + (Bug introduced in version 2.33.0) + - Calling 'TLOpen' after calling 'GCGetInfo' did return 'GC_ERR_RESOURCE_IN_USE'. (mvGenTLProducer.cti) + (Bug introduced in version 2.35.0) + - Under some conditions the Linux libusb driver put the event endpoint in the stalled (mvGenTLProducer.cti) + state without canceling queued event buffers which was causing a 'USBDEVFS_CLEAR_HALT + for active endpoint 0x82' message in the kernel debug messages. + - The GenICam registers for the 'InterfaceID' feature could just store 128 bytes which (mvGenTLProducer.cti) + was not enough on some systems. This value has been increased to the MAX_PATH value + now. + - Requesting images using the 'ircmTrial' sometimes did return incorrect information (mvGenTLConsumer-lib) + when the device would return a Bayer format. + - Sometimes when reading/writing properties from 2 threads (e.g. when processing an (mvGenTLConsumer-lib) + event callback while also setting a properties value) the write access to the + property has been ignored. + - Calling mvIMPACT::acquire::helper::ThreadSafeQueue::terminateWait did not always (mvIMPACT_acquire_helper.h) + wake up mvIMPACT::acquire::helper::ThreadSafeQueue::pop when both functions where + called more or less in parallel. + +02.10.2019 2.35.0 + NEW FEATURES: + - The mvIMPACT Acquire Python wrapper is delivered for ARMhf and ARM64 platforms now. (all shipped packages for Unix/Linux systems) + - mvDeviceConfigure now also informs about an available firmware update for mvBlueFOX2 (mvDeviceConfigure) + devices. + - When passing 'online' as the value for the 'fw_file' parameter the latest firmware (mvDeviceConfigure) + version from the MATRIX VISION website will be downloaded and stored on supported + devices. This can e.g. be used to update ALL devices connected to a system without + user interaction with the latest firmware available. + - Initial version of the AOI Wizard which will allow to configure AOIs for many (wxPropView) + different features like auto exposure and auto gain controllers, white balance + calibration or flat field filter. + + UPDATES: + - PFNC format YCbCr2020_411_8_CbYYCrYY will be treated as 'ibpfYUV411_UYYVYY' (mvGenTLConsumer-lib) + YCbCr601_422_8, YCbCr709_422_8, YCbCr2020_422_8 will be treated as 'ibpfYUV422Packed' + and YCbCr601_422_8_CbYCrY, YCbCr709_422_8_CbYCrY, YCbCr2020_422_8_CbYCrY + will be treated as 'ibpfYUV422_UYVYPacked' now thus data in these formats can + be fully dealt with. + - If possible the 'Quick Setup Wizard' will use the device's gamma feature if (wxPropView) + available. This reduces load on the host CPU then. + - Internal migration from swig 3.0.12 to 4.0.1. + + CHANGED BEHAVIOUR: + - mvIMPACT Acquire is not statically linked with libstdc++ and libgcc anymore, so (all shipped packages for Unix/Linux systems) + the Linux systems have to use at least the version of gcc mvIMPACT Acquire has been + compiled with. + This means in detail: + - gcc 4.8.5 (GLIBCXX 3.4.19, libstdc++ 6.0.19) for x64 and x86_64 packages. + - gcc 4.9.4 (GLIBCXX 3.4.20, libstdc++ 6.0.20) for ARMsf and ARMhf packages. + - gcc 4.9.4 (GLIBCXX 3.4.20, libstdc++ 6.0.20) for ARM64 packages. + See 'Building, linking and running...' chapter in the 'Supported compilers' section + for additional details. + - A firmware update from the Internet can be enforced even if the firmware version is (mvDeviceConfigure) + the same as the one currently running on the device. This can e.g. be useful to get + rid of any user sets stored on the device. + - mvDeviceConfigure no longer enforces elevated privileges on Windows systems. Most (mvDeviceConfigure) + operations (like firmware updates for GenICam devices) can be done as a normal user + now. Whenever elevated privileges are required but not available the application will + inform the user. + - Some incompatible changes have been applied to the Python interface. Please refer (Python API) + to the migration guide in the 'Python developers' chapter of your product. E.g.: + https://www.matrix-vision.com/manuals/mvBlueCOUGAR-X/Python_page_0.html + + BUGS FIXED: + - Calling 'GCGetInfo' without calling 'TLOpen' before did result in a crash! (mvGenTLProducer.cti) + (Bug introduced in version 2.33.0) + - In very rare cases the 'State' property was not set to 'Absent' when a U3V device was (mvGenTLProducer.cti) + unplugged on Windows when it had been unplugged at least one time before. + - Common module including some helper functions of the mvIMPACT Acquire Python wrapper (all shipped packages) + is now installed in a Python 2.7 and 3.7 compatible way. + - Exception handling in Python API was broken on Windows systems. When an mvIMPACT (setup.py) + Acquire related exception was raised the application did terminate. + (Bug introduced in version 2.22.0) + - When the width of the AOI is smaller than 640 the host based AEC/AGC will be used (mvBlueFOX-lib) + for mvBlueFOX-x02dx devices now even if 'DeviceSpecific' has been selected. This is a + little slower but the 'DeviceSpecific' version does not work then due to a sensor + limitation. + - Devices with whitespace characters in their serial number can be initialised using (wxPropView) + wxPropView. + - mvDeviceConfigure correctly informs about an available firmware update if a package (mvDeviceConfigure) + using the old naming scheme is found (_Update-a.b.c.d.mvu) containing a + more recent firmware for a detected device. + (Bug introduced in version 2.31.0) + - Calling mvIMPACT::acquire::Property::readS or mvIMPACT::acquire::Property::readSArray (mvIMPACT_acquire.h) + did never terminate if the returned string was longer than 8192 characters. + - mvIMPACT::acquire::EnumPropertyF::getTranslationDictValue did return the internal (mvIMPACT_acquire.h) + error code casted to a double instead of the requested value. + - Requesting images using the 'ircmTrial' sometimes did return incorrect information (mvGenTLConsumer-lib) + e.g. a different pixel format as an internal exception was raised by e.g. the format + convert filter. + (Bug introduced in version 2.22.0) + - Some interface functions (TLIMV_MACFromSerial, TLIMV_IsValidIPv4Address, (mvGenTLProducer.cti) + TLIMV_ForceIP and TLIMV_DoAddressesMatch) where no longer exported on Linux systems. + (Bug introduced in version 2.33.0) + +09.08.2019 2.34.0 + NEW FEATURES: + - API added to configure the enumeration behaviour of third party GenTL producer (mvGenTLConsumer-lib) + libraries. See 'General SDK functionality' in the 'Typical Usage Scenarios And (wxPropView) + Example Applications' section of the SDK manual for details. + - The 'GenICam' namespace now contains the full SFNC 2.5 feature set. (mvIMPACT_acquire_GenICam.h) + - New overload for mvIMPACT::acquire::Method::call/mv.impact.acquire.Method.call (mvIMPACT_acquire.h) + added that accepts a list of strings. (mv.impact.acquire.dll) + - New example added to all packages: 'GenICamI2cUsage'. (all shipped packages) + + UPDATES: + - wxPropView became 'DeviceRegistersValid' aware. (wxPropView) + - Improved compatibility with 3rd party GenTL producers. (mvGenTLConsumer-lib) + - Removed all occurrences of 'std::auto_ptr' since this class has been deprecated in (all shipped packages) + C++11 and removed in C++17 and therefore applications built with up to date compilers + did receive a lot of warnings. + - Improved and enhanced 'Typical Usage Scenarios And Example Applications' chapter. (all shipped packages) + + CHANGED BEHAVIOUR: + - From this version onwards mvBlueLYNX-X, mvBlueLYNX-M7 and mvBlueCOUGAR-P devices (all shipped packages for GenICam compliant devices) + will no longer be supported. As a consequence the following example applications + have been removed from the SDK: 'CaptureFromMultipleChannelsUsingMultipleSettings', + 'SynchronousCaptureMultipleInputs' and 'SynchronousCaptureMultipleInputsFLTK'. The + class 'IOSubSystemBlueCOUGAR' has also been removed. Use 'IOSubSystem' instead. + - From this version onwards PPC based platforms will no longer be supported. (all shipped packages) + - GEV adapters will report a more unique interface ID now. It used to be the MAC (mvGenTLProducer.cti) + address. Weird systems reporting the same MAC address for multiple adapters however + did enumerate devices on the first of these adapters only then. + - Known technologies from third party GenTL producers mvIMPACT Acquire has built-in (mvGenTLConsumer-lib) + support for will be ignored by default now in order not to pollute the list of + devices with duplicated entries. Using the new API these can enabled by the user. + - When running Windows 8 or greater a reboot of the system after installing the (mvGenTL_Acquire*.exe) + mvGenTL_Acquire package is no longer necessary. In previous versions when not logging + on as an administrator AFTER the reboot the NDIS filter driver for GigE Vision + devices was not properly installed. + - Removed 'PowerDownTest' example from mvBlueFOX Linux installation packages. Please (mvBlueFOX-*.tgz) + refer to the 'Typical Usage Scenarios And Example Applications' in the documentation + instead. + - Merged the Linux example 'LiveSnap' with the 'ContinuousCapture' example. Now there (all shipped packages) + is a common 'ContinuousCapture' example. + - 'LiveSnapFLTK' became 'ContinuousCaptureFLTK'. (all shipped packages for Unix/Linux systems) + + BUGS FIXED: + - When 2 or more processes using mvIMPACT Acquire have been started in parallel this (all shipped packages) + could result in all processes to lock up when accessing the *.bak files. + (Bug introduced in version 2.19.0) + - Potential crash on systems with more logical CPU cores than the height of the current (all shipped packages) + image in the image processing pipeline. + - The functions 'acquistionStart' and 'acquisitionStop' did not always propagate all (mvGenTLConsumer-lib) + internal errors up to the application. (mvGenTLProducer.cti) + - When a GenTL producer did report an invalid image size that was larger than the (mvGenTLConsumer-lib) + buffer currently allocated this buffer was incorrectly been re-allocated without + revoking it from the GenTL producer resulting in a crash the next time this buffer + was queued. + - Sometimes when starting the application for the very first time no images were (wxPropView) + displayed while the status bar did suggest the acquisition is running just fine. + (Bug introduced in version 2.32.0) + - mvVirtualDevice displays BMP files with a custom palette correctly now. (mvVirtualDevice-lib) + - In some cases "Junk After Document Element" messages showed up in mvDeviceConfigure (mvDeviceConfigure) + once the "Firmware Update from Online Package" option has been used. + - In some cases the LostImageCount property showed negative values once the (mvBlueFOX-lib) + RequestCount value was increased during a running acquisition. + - Device specific AGC/AEC mode features were not always properly updated inside the (mvBlueFOX-lib) + device. + - 'DesiredAverageGreyValue' for AGC/AEC was not taken into account for mvBlueFOX-x02dx (mvBlueFOX-lib) + devices. + +26.06.2019 2.33.1 + UPDATES: + - Improved compatibility with 3rd party GenTL producers. (mvGenTLConsumer-lib) + +05.06.2019 2.33.0 + NEW FEATURES: + - The defective pixel filter now supports also the following pixel formats: (all shipped packages) + BGR888Packed, RGB888Packed, RGB101010Packed, RGB121212Packed, RGB141414Packed, + RGB161616Packed, RGBx888Packed, YUV444_UYVPacked, YUV444_UYV_10Packed, YUV444Packed + and YUV444_10Packed. + - New correction mode added to defective pixel filter: (all shipped packages) + dpfmReplaceDefectivePixelAfter3x3Filter. See SDK documentation for additional + details. + - New header file added to C++ interface: mvIMPACT_acquire_helper.h. This file adds the (all shipped packages) + classes 'mvIMPACT::acquire::helper::RequestProvider' and + 'mvIMPACT::acquire::helper::ThreadSafeQueue' to the public interface. + - Added 64-bit Borland import libraries to 32-bit installers as well: (all shipped MSI-based packages) + mvDeviceManagerb.lib and mvDisplayb.lib. + - PFNC formats YCbCr411_8_CbYYCrYY, YCbCr601_411_8_CbYYCrYY and YCbCr709_411_8_CbYYCrYY (mvGenTLConsumer-lib) + will be treated as 'ibpfYUV411_UYYVYY_Packed' now thus data in these formats can + be fully dealt with. + + BUGS FIXED: + - When running out of USB kernel memory on Linux queuing a request can fail. However (mvGenTLProducer.cti) + it took 'ImageRequestTimeout_ms' for this unsuccessful operation to return and in + case this timeout was INFINITE the operation did never return. + (Linux only) + - BF3-3 and BF3-4 devices will also be recognized as being 'Quick Setup Wizard' (wxPropView) + compatible. + - Switching on 'Gamma' in the 'Quick Setup Wizard', leaving it with 'Ok' and (wxPropView) + re-entering it switched off the gamma control but did show the 'Gamma' button as + being active. + - LUT wizard displays the interpolated LUT values and not only the LUT's sampling (wxPropView) + points in case of interpolated LUTs + - Calling 'DMR_SaveImageBuffer' with 'iffAuto' and a *.bmp, *.jpg or *.jpeg file (mvDeviceManager-lib) + extension did result in the creation of files not readable for almost every other + image viewer. + - Calling 'DMR_UpdateDeviceList' when new interfaces have appeared since the last call (mvGenTLConsumer-lib) + could result in inconsistent interface to device reports (e.g. in wxPropViews 'Info' + dialog). + - The NeuroCheck 6.x interface did crash when enumerating third party interfaces within (mv.impact.acquire.NeuroCheck6.dll) + NeuroCheck's device manager. (mv.impact.acquire.NeuroCheck6_1.dll) + (Bug introduced in version 2.31.0) + - On Windows when installing the mvGenTL-Acquire package and then restarting the system (all shipped MSI-based packages) + and logging in with a non administrator account GEV and U3V interfaces where not be + enumerated. Therefore it seems like no devices are connected to the system. + + UPDATES: + - Internal migration from (all shipped Linux packages) + - gcc 4.2.4 to gcc 4.8.5 for x64 and x86_64 packages. + - gcc 4.6.3 to gcc 4.9.4 for ARMsf and ARMhf packages. + - gcc 4.8.3 to gcc 4.9.4 for ARM64 packages. + See 'Building, linking and running...' chapter in the 'Supported compilers' section + for additional details. + - Internal migration from swig 2.0.12 to 3.0.12. + - The status bar tooltip introduced in version 2.32.0 can be switched on and off now (wxPropView) + within the 'Settings -> Options' dialog and will only be displayed if the mouse stays + at least one second on the status bar. + + CHANGED BEHAVIOUR: + - The socket based GigE Vision driver will no longer start in the middle of a running (mvGenTLProducer.cti) + block when it did run out of capture buffers and gets a fresh one in between. When + not listening on an LAG group it will now wait for the next start of a block. On LAG + groups it will start with packets with an ID smaller than the value of + 'mvResendCaptureWindowSize'. + - When a GenICam device returns an error in the middle of a 'load setting' operation (mvGenTLConsumer-lib) + the load operation as a whole no longer fails but only the particular feature is + not written then. + +08.05.2019 2.32.0 + NEW FEATURES: + - mvIMPACT Acquire supports all 3rd party devices and 3rd party GenTL producers now (mvGenTLConsumer-lib) + even though right now some of them will only work for a trial period. Get in touch (mvGenTLProducer.cti) + with us if you have questions about that. + - New error codes added: DMR_BUSY and DMR_OUT_OF_MEMORY. (all shipped packages) + - New function added: 'OBJ_GetBinaryEx'. See PropertyS::readBinary for additional (mvDeviceManager-lib) + information! (mvIMPACT_Acquire.h) + - Added 64-bit Borland import libraries: mvDeviceManagerb.lib and mvDisplayb.lib. (all shipped MSI-based packages) + - wxPropView shows a 'Welcome' dialog before the 'Quick Setup' wizard is opened now to (wxPropView) + allow the user to show, not to show or disable the 'Quick Setup' wizard completely. + - Added 'Default Acquisition Start/Stop Behaviour' menu. (wxPropView) + - The defective pixel filter learned how to process the following pixel formats: (all shipped packages) + BGR888Packed, RGBx888Packed, RGB888Packed, RGB101010Packed, RGB121212Packed, + RGB141414Packed, RGB161616Packed, YUV444_UYVPacked, YUV444_UYV_10Packed, + YUV444Packed, YUV444_10Packed. + - Test image format 'vdtmHotAndColdPixelTestImageRGB888Packed' added. (mvVirtualDevice-lib) + + UPDATES: + - Improved translation of GenTL error codes into mvIMPACT Acquire error ones. (all shipped packages) + - Improved cache efficiency when accessing GenICam properties containing binary data. (mvPropHandling-lib) + (mvGenTLConsumer-lib) + - In order to increase the awareness for the 'ImageRequestTimeout_ms' property (wxPropView) + wxPropView will warn when buffer timeouts occur and will recommend to adjust the + timeout property then. + - All files (kernel mode and user mode) are signed with a DigiCert EV certificate now + as the new COMODO certificate still resulted in Windows SmartScreen warnings. + (Windows only) + - All installer scripts report errors and warnings in case of issues during (all shipped Linux packages) + installation and their result at the end of the installation. + + CHANGED BEHAVIOUR: + - The default value of 'ImageRequestTimeout_ms' has been changed from 2000 to 0 + (infinite). In very rare cases this might result in the function + 'imageRequestWaitFor' not returning anymore depending on how the application is + written. See 'Calling 'imageRequestWaitFor' never returns / An application no + longer terminates after upgrading to mvIMPACT Acquire 2.32.0 or greater' in the + 'Known Issues' section of the documentation to make sure this does NOT affect you! + - Examples for Borland C++ Builder are no longer shipped as part of the installation. (all shipped MSI-based packages) + However Borland Makefiles for the example applications can be generated with CMake + now. See documentation in the 'building and linking' section for details. + + BUGS FIXED: + - wxPropView did not scale LUT values once they were copied within the LUT wizard. (wxPropView) + - The LUT wizard calculates the correct gamma correction values instead of it's inverse (wxPropView) + values now. + - Firmware downgrade notifications showed incorrect version numbers in some cases. (mvDeviceConfigure) + - mvBlueFOX devices with an MT9M021 sensor(e.g. mvBlueFOX-ML/IGC202bC) sometimes did (mvBlueFOX-lib) + not apply the gain when exposure time and gain where changed at the same time and the + new exposure time was greater than the previous one. + - PFNC pixel formats 'Coord3D_A12p', 'Coord3D_B12p' and 'Coord3D_C12p' have been (mvGenTLConsumer-lib) + treated as 'ibpfMono12' instead of 'ibpfMono12Packed_V1' resulting in crashes and + all sorts of other problems. + - Some small changes in the interface header files in order to compile applications (all shipped packages) + with Embarcadero C++ 7.40. + - The black level slider in the 'Quick Setup' wizard can be used again. (wxPropView) + (Bug introduced in version 2.31.0) + - Reducing the 'RequestCount' property and then increasing it again without calling (mvIMPACT_acquire.h) + 'FunctionInterface::getRequest' in between at least once did result in invalid (mv.impact.acquire.dll) + request properties and could result in exception being thrown at runtime. + - clGetSerialPortIdentifier returned portID without portIndex. (clsermv-lib) + (Bug introduced in version 2.26.0) + +15.03.2019 2.31.1 + UPDATES: + - Files will be signed using a COMODO certificate now since the StartCom certificate (all shipped MSI-based packages) + used previously is no longer trusted by Windows. + (Windows only) + +07.03.2019 2.31.0 + NEW FEATURES: + - mvIMPACT Acquire is now shipped with CMake support! See the 'Building and linking' (all shipped packages) + chapter of the documentation for details. + - mvIMPACT Acquire example applications will now be shipped with C++11 features. CMake (all shipped packages) + users using an appropriate compiler and users using the Visual Studio 2013 solution + will automatically get the new versions of the example applications, all others will + continue to see the legacy C++03 code. As a result a lot of new example applications + are therefore available as part of the Linux installation as well now. + - 'RemoveImage' function added to 'ImageDisplay' class. (mv.impact.acquire.display.dll) + (mvIMPACT_acquire_display.h) + - New calibration modes added to defective pixel filter: 'dpfmCalibrateHotPixel' and (all shipped packages) + 'dpfmCalibrateHotAndColdPixel'. + - New example added to all packages: 'GenICamCommonSettingsUsage'. (all shipped packages) + - 'formatReinterpreterBayerMosaicParity' property added. This will allow to modify, (all shipped packages) + add or remove the 'Bayer' attribute from an image buffer. + - The 'Quick Setup' wizard will display images coming from a polarized sensor in 2by2 (all shipped packages) + mode now and is able to display these image in color when they come from a color + sensor. + - mvDeviceConfigure learned to apply firmware updates by downloading the latest version (mvDeviceConfigure) + from the MATRIX VISION GmbH website. + - The flat field filter became AOI aware. It is now possible to calibrate only a part (all shipped packages) + of the image and then only apply the flat field correction to that part of the image. + Furthermore a calibration AOI can be selected which basically defines the AOI that is + process. This results in reduced CPU load. Refer to the 'Image Processing' chapter + in the documentation. + - Color correction matrix for Sony IMX226 based products added. (all shipped packages) + + UPDATES: + - Updated integrated U3VBootProgrammer to 0.33.1693.2. (mvGenTLProducer.cti) + - Internal migration to Doxygen 1.8.15. + + CHANGED BEHAVIOUR: + - Test image format 'vdtmColdPixelTestImageBayer' changed to (mvVirtualDevice-lib) + 'vdtmHotAndColdPixelTestImageBayer'. + - Examples for Visual Studio 2008 are no longer shipped as part of the installation. (all shipped MSI-based packages) + Project files for the example applications for arbitrary Visual Studio can be + generated with CMake now. + - The Linux example application 'SingleSnap' is no longer shipped as part of the (all shipped packages for Unix/Linux systems) + installation. It has long been replaced by 'SingleCapture'. + - The Linux example application 'testserial' is no longer shipped as part of the (all shipped packages for Unix/Linux systems) + installation. + - On Linux the driver will try to use the systems native libusb and libudev if possible (mvGenTLProducer.cti) + if an environment variable 'MVIMPACT_ACQUIRE_FAVOUR_SYSTEMS_LIBUSB' is specified now. + If no matching compatible pair can be detected the libraries that are installed + in the $MVIMPACT_ACQUIRE_DIR/Toolkits directory will be used(this was the previous + behaviour). See 'known issues' section in the API manuals for details. + - When saving a setting in GenICam interface layout without specifying that sequencer (mvGenTLConsumer-lib) + or user set data shall be stored the old file format of GenApi 3.0.x and smaller will + be used in order to allow old software to load these settings as well. + - Internal buffer layout changed for U3V devices as certain USB3 host controllers (mvGenTLProducer.cti) + due to bugs in their driver cannot deal with large (>16MB) transfer sizes. This e.g. + fixes potential problems when using certain sequencer sets with high resolution + devices. + + BUGS FIXED: + - mvDeviceConfigure did not always allow to update the firmware of a device even if a (mvDeviceConfigure) + suitable firmware was present in the selected archive(*.mvu). + - Random crashes when a U3V device was unplugged and closed more or less (mvGenTLProducer.cti) + simultaneously. + (Linux only) + - Fixed a couple of small issues in the installation scripts. (all shipped packages for Unix/Linux systems) + (Linux only) + - The property mv.impact.acquire.ImageProcessing.flatFieldFilterCorrectionMode had an (mv.impact.acquire.dll) + invalid handle. + - Added missing build dependency which could result in the build of (samples.NET.VC12.sln) + 'GenICamCommonSettingsUsage' to fail when building the .NET examples. + +14.12.2018 2.30.1 + NEW FEATURES: + - New test image format added: 'vdtmColdPixelTestImageBayer'. (mvVirtualDevice-lib) + - New example added to all packages: 'ContinuousCaptureQt'. (all shipped packages) + + UPDATES: + - Updated integrated U3VBootProgrammer and U3VBootLoader to 0.32.1667.2. (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - From this version onwards on Windows the mvGenTL_Acquire installation package will (mvGenTL_Acquire*.exe) + be shipped as an executable package. The underlying technology will still be the + same but the package is wrapper inside a bootstrapper now. Also when mvGigEConfigure + is launched after the reboot no more user interaction will be required by default. + + BUGS FIXED: + - In rare cases when 'userControlledImageProcessingEnable' was active the processing (all shipped packages) + result of the 'Decoupler' node was 'iprSkipped' instead of 'iprApplied'. + +10.12.2018 2.30.0 + NEW FEATURES: + - New example added to all packages: 'GenICamSequencerUsageWithPaths'. (all shipped packages) + - Color correction matrix for Sony IMX183 based products added. (all shipped packages) + + UPDATES: + - The driver no longer reads back gain and exposure time with the GenICam attribute (mvGenTLConsumer-lib) + 'NoCache' when written. Instead a faster internal caching mechanism is used now. + - Internal migration to IPP 2019.1. This effectively changes the runtime installations (all -x86_*.tgz packages) + on Linux systems slightly. Instead of linking statically all IPP related code has + been extracted into a dynamic library 'mvImageProcessing' which is now part of the + installation packages. + + CHANGED BEHAVIOUR: + - The multi-AOI wizard will correctly restore the current camera AOI when exited with (wxPropView) + 'OK' now. + + BUGS FIXED: + - mvIPConfigure did crash when mvGenTLProducer.cti was not located in the same folder. (mvIPConfigure) + The crash no longer occurs and also the GENICAM_GENTL32_PATH or GENICAM_GENTL64_PATH + variable is evaluated when looking for the library. + - Raise condition that could result in an mvBlueFOX3 device to move into standby mode (mvGenTLConsumer-lib) + while being in use by an application. + - When the NDIS filter driver was used for GEV devices, 'acquisitionStartStopBehaviour' (mvGenTLProducer.cti) + was set to 'assbUser' and the time that passed between the first 'imageRequestSingle' + call and the first 'acquisitionStart' call was higher than the value of the + property 'imageRequestTimeout_ms' for that buffer, the buffer was returned with a + timeout. Now the timeout period will start not until 'acquisitionStart' is called. + - Some mvBlueFOX devices (e.g. mvBlueFOX-121) did no longer deliver images. (mvBlueFOX-lib) + (Bug introduced in version 2.29.0) + - Cold pixel detection in the defective pixel filter did not work correctly with Bayer (all shipped packages) + images. In case of error usually lots of cold pixels have been detected within the + first line of the image. + +07.11.2018 2.29.1 + NEW FEATURES: + - 2 by 2 mode added to 'Polarized Data Extraction' filter. (all shipped packages) + - Color correction matrix for Sony IMX342 based products added. (all shipped packages) + + UPDATES: + - Internal migration to CMake. All Linux based builds are generated using CMake now. (all shipped packages for Unix/Linux systems) + - Internal migration to IPP 2019.0. (all shipped packages) + (Windows only) + + CHANGED BEHAVIOUR: + - From this version onwards ppc603e based platforms will no longer be supported. (all shipped packages for GenICam compliant devices) + - From this version onwards the mvBlueCOUGAR-X/(D) and mvBlueFOX3 firmware will no + longer be shipped as part of mvIMPACT Acquire. However the firmware can of course + still be downloaded from the MATRIX VISION website separately. This is meant to + speed up the release cycle times for both the firmware and the mvIMPACT Acquire SDK. + + BUGS FIXED: + - Potential blue screen (BSOD) when working with the NDIS filter driver on Windows (mvGigECapture.sys, version 2.3.6.65) + with Stream Channel Packet Size (SCPS) values smaller than 576 bytes. (mvGigECapture2.sys, version 3.1.7.65) + (mvGenTLProducer.cti) + - On some systems where multiple network adapters did have multiple IP addresses (mvGenTLProducer.cti) + assigned sometimes the MTU of the network adapter was reported incorrectly. + - Potential deadlock when calling updateDeviceList after another network adapter had (mvGenTLProducer.cti) + appeared. + - Potential crash after another network adapter had appeared. (mvDeviceConfigure) + - Random crashes when at least on mvBlueFOX device was present in a Linux system. (mvBlueFOX-lib) + - Incorrect 'Invalid command line parameter: 'postinstallmessage'' error message after (mvGigEConfigure) + the installation of the GEV filter driver when selecting 'No' when asked whether to + show NIC setup hints. + (Bug introduced in version 2.11.3) + - From this version onwards on Windows 7 the NDIS 5.x based GEV filter driver will be (mvGenTL_Acquire*.msi) + used again as since the last changes the NDIS 6.x based version did cause problems. + With version 2.29.0 after rebooting the system on Windows 7 the filter driver had to + be disabled and then enabled again to get a working network connection. + (Bug introduced in version 2.29.0) + +02.10.2018 2.29.0 + NEW FIRMWARE: + - Firmware version 2.31.1567.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - IMX: Improved frame rate exactness in continuous mode for all IMX sensors + except for IMX178. + - mvBlueCOUGAR-XD107G/C: AOI and binning/decimation can now be used with the + sequencer + - Support for new cameras mvBlueCOUGAR-X102kG/C with IMX432 sensor. + Changed behaviour: + - mvBlueFOX3-2XXX: SmartFrameRecall can only be enabled if the image width is a + multiple of 8 + - USB 3.0 devices will now act as USB 3.1 Gen 1 devices. + Bugs Fixed: + - Sequencered Binning had problems when the width changed and the height was also + scaled. + - mvBlueCOUGAR-XD102fG/C, mvBlueCOUGAR-XD104dG/C, mvBlueCOUGAR-XD104hG/C, + mvBlueCOUGAR-XD105aG/C, mvBlueCOUGAR-XD107G/C, mvBlueCOUGAR-XD109bG/C, + mvBlueCOUGAR-XD1012bG/C: fixed a bug, that led to corrupted images in + SmartFrameRecall mode if the image width was not a multiple of 16 + - mvBlueFOX3-2XXX: SmartFrameRecall in combination with USB 2.0 / High Speed did + not work as expected. + - mvBlueCOUGAR-XD107G/C: Changing PixelFormat or mvSensorDigitizationBitDepth when + mvDualAdcMode is already on led to bad images. + + NEW FEATURES: + - 'Polarized Data Extraction' filter added. (all shipped packages) + - Color correction matrix for mvBlueCOUGAR-X102kC devices added. (all shipped packages) + - Color correction matrix for mvBlueCOUGAR-X102mC devices added. (all shipped packages) + + UPDATES: + - Support for newer kernel versions(up to 4.15) added to mvHYPERION modules. (low level mvHYPERION driver, Linux) + - Improved reconnection behaviour for GEV devices connected to a network adapter whose (mvGenTLProducer.cti) + IPv4 address has been changed after a device has been initialised. + - Updated integrated U3VBootProgrammer to 0.31.1553.2 (mvGenTLProducer.cti) + + BUGS FIXED: + - GEV devices sometimes did not change their 'State' property anymore when being (mvGenTLConsumer-lib) + re-connected/disconnected when the link was lost again at a certain point during + a previous re-connection event. + - GenICam devices sometimes appeared under a wrong interface in 'Current Driver, (wxPropView) + Interface and Device Information' dialog. + - Fixed handle leaks. (clsermv-lib) + (Windows only) + - On Linux systems devices with NO firmware did only appear in the device manager when (mvBlueFOX-lib) + the initial device manager instance was deleted and a new one was created. + - Potential blue screen (BSOD) when changing network adapter parameters such as the (mvGigECapture.sys, version 2.3.6.63) + link speed while at least one device was either streaming or when at least one image (mvGigECapture2.sys, version 3.1.6.63) + has been captured on this adapter before since the system did start. + - Capturing into user supplied memory did always result in an additional internal copy. (mvGenTLConsumer-lib) + (mvVirtualDevice-lib) + - Sometimes old white balance parameters have been applied to the image when using the (all shipped packages) + host based processing when an application did change the gain values in parallel with + calling 'imageRequestReset'. + - When the 'Multi AOI' wizard was opened while an analysis tool was selected and this (wxPropView) + analysis tool was operated in 'Full AOI' mode the AOIs in the 'Multi AOI' could not + be dragged. + (Bug introduced in version 2.25.0) + - U3V devices could not be found on ARM64 boards running on Linux OSes that do not (all shipped packages for GenICam compliant devices, Linux/ARM64) + ship with libcgmanager.so (e.g. Ubuntu 18.04) + - Fixed a memory leak when calling the 'getCurrentCaptureBufferLayout' function more (mvGenTLConsumer-lib) + than once for GenICam compliant devices. + +05.07.2018 2.28.0 + NEW FIRMWARE: + - Firmware version 2.30.1463.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3-2XXX: Enabled SmartFrameRecall + - mvBlueFOX3-MXXXX: Enabled user i2c interface for module version + - mvBlueFOX3-2064G/C: GlobalReset mode implemented. + Changed behaviour: + - Additional flash space of mvBlueCOUGAR-X/XD, Rev.5 and mvBlueFOX3-2 is now + reserved, to ensure that the theoretic possible amount of defective pixel + positions of our larger sensors can be stored. IMX420, IMX428, IMX253 and IMX304 + sensor now support up to 1536 defective pixel. + - Cameras with IMX sensors: First image after switching to TriggerMode 'Off' is + done faster. + - 'mvDeviceSensorName' became 'SensorName', 'mvDeviceSensorPixelWidth' became + 'SensorPixelWidth' and 'mvDeviceSensorPixelHeight' became + 'SensorPixelHeight' according to the SFNC 2.4. Also the features have been + moved from the 'DeviceControl' category into the 'ImageFormatControl' + category. 'mvDeviceSensorName' remains as an invisible property for backward + compatibility. + Bugs Fixed: + - BCX(D)s with IMX sensors when using LUTs in combination with Mono8/Bayer8 + delivered reduced quality image (missing codes). + - Frame rate was halved when using ReverseY. Bug introduced in 2.29.1385.0. + - mvBlueCOUGAR-XD107G/C: fixed bug, that caused images being displaced by a few + lines when enabling vertical binning/decimation in comparison to the same image + without vertical binning/decimation + - mvBlueCOUGAR-X102eG/C/GE, mvBlueCOUGAR-X104eG/C, mvBlueFOX3-1013G/C/GE, + mvBlueFOX3-1020G/C, mvBlueFOX3-1020aG/C: + LineScan mode did not work with OffsetX != 0. + FrameActive was not set correctly. + - SmartFrameRecall didn't work since 2.24, currently the user has to ensure that + thumbnail width is a multiple of 8. + - mvBlueCOUGAR-X105G/C: Disturbed images could occur at high temperatures when + using maximum device clock frequency (98Mhz). + - mvBlueFOX3, mvBlueCOUGAR-X(D) all models: Code for mutual exclusion of triggers + FrameStart, FrameBurstStart and FrameBurstActive was triggered even if + one of these triggers was switched off. + + NEW FEATURES: + - Multiple firmware versions are available for updating mvBlueFOX USB2 devices now. (mvBlueFOX-lib) + - The 'GenICam' namespace now contains the full SFNC 2.4 feature set. (mvIMPACT_acquire_GenICam.h) + (mv.impact.acquire.dll) + + UPDATES: + - Migration to version 3.1.0 of the GenApi runtime. (all shipped packages for GenICam compliant devices) + This will allow to store UserSets as well as SequencerControl programs within a + setting file(see 'FunctionInterface::loadSetting' or 'DMR_LoadSetting' for details), + improves execution speed and also fixes a couple of other issues. + - Internal migration to IPP 2018.3. (all shipped packages) + - Updated integrated U3VBootProgrammer to 0.30.1438.2 (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - The default format string for pointer properties (vtPtr) is "0x%p" now, while it (mvPropHandling-lib) + used to be "0x%x" which does not work with 64-bit addresses. + - Whenever an 'AcquisitionStart' command is executed the link speed for a GigE Vision (mvGenTLProducer.cti) + is read back from the device in order to respond correctly on changing link speeds + in terms of resend behaviour. + - Removed all device/sensor specific values from (mvDriverBaseEnums.h) + 'TColorTwistInputCorrectionMatrixMode'. Use 'DeviceSpecific' if you did use a value (mv.impact.acquire.dll) + that is no longer available now. It will automatically select the best match for your + device. + - Maximum number of defective pixels that can be processed by the host based defective (all shipped packages) + pixel filter will automatically adjust to the maximum number of pixel that can be + processed by a device supporting the 'mvDefectivePixelCorrectionControl' category + now. + - Weird jumps in block IDs caused by malfunctioning devices are reported by the driver (mvGigECapture.sys, version 2.3.5.62) + by increments of the LostFrame counter and log messages now. The stream of data (mvGigECapture2.sys, version 3.1.5.62) + will continue after losing 1 or multiple frames. Previous driver versions did more + or less stop streaming. + + BUGS FIXED: + - The 'Callback' examples for C++/.NET did raise an 'invalid interface layout' (Callback) + exception when used with a GenICam device. + (Bug introduced in version 2.27.0) + - Missing header files added to MSI based installation packages: wxIncludeEpilogue.h, (all shipped MSI-based packages) + wxIncludePrologue.h, wxIncluder.h. + (Bug introduced in version 2.26.0) + - When operating the scaler with cubic interpolation and 10, 12 or 14 bit pixel formats (all shipped packages) + the resulting buffer could contain values slightly larger than the maximum value for + that pixel format. + - When logging in to windows from the login screen, and wxPropView is already running (wxPropView) + in the background in full screen mode, it did no longer respond. + - Calling the 'ResetStatistics' function did not reset the 'LostImagesCount' when the (mvGenTLConsumer-lib) + NDIS based driver was used. (mvGenTLProducer.cti) + - Cameras operated in 'DeviceSpecific' interface layout no longer raise internal (mvGenTLConsumer-lib) + exceptions when a camera did set 'mvExposureAutoUpperLimit' to 'not available'. + - Potential crash when working with one of the adaptive edge sensing debayering (all shipped packages) + algorithms. + - Heap corruption when using the 'AdaptiveHomogeneityDirected' de-Bayer algorithm on (all shipped packages) + an image with a height of 5. + - On Windows the installers incorrectly did create a sub-folder 'MATRIX VISION' within (all shipped MSI-based packages) + the target directory of the installation. + (Bug introduced in version 2.24.0) + - U3V devices specifying multiple IADs and the USB 3 Vision descriptor is not the first (mvGenTLProducer.cti) + IAD can be operated now. + - GenICam devices streaming multi-part data with multiple images using different pixel (mvGenTLConsumer-lib) + formats for each part where not always correctly processed resulting e.g. in + incorrect display output. + - Moving Mono12 packed Bayer test images with an odd width have not been created (mvVirtualDevice-lib) + correctly. + - For test images with a an odd width AND height using the pixel format (mvVirtualDevice-lib) + ibpfMono12Packed_V1 the last pixel of the last row of the image was incorrect. + - Images with a height of 1 could result in a crash when the defective pixel filter was (all shipped packages) + configured to perform calibration on the next image. + +17.05.2018 2.27.0 + NEW FIRMWARE: + - Firmware version 2.29.1385.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-X225G/C: Exact frame rate in continuous mode. + - IMX sensors with 12 and 9 MPixel now support RGB/YUV-Modes in BF3 and BCXD + - mvBlueCOUGAR-XD107G/C: 60 fps instead of 44 fps at full AOI in burst mode. + - mvBlueFOX3-2089G/C, mvBlueFOX3-2089aG/C, mvBlueCOUGAR-XD109bG/C: + ReverseX and ReverseY implemented. + Changed behaviour: + - mvBlueCOUGAR-X225G/C: Improved AcquisitionStart behaviour. + - mvBlueCOUGAR-X(D), mvBlueFOX3 (models with IMX sensors): + Improved AcquisitionStart behaviour. + - mvBlueFOX3, mvBlueCOUGAR-X(D) all models: Enabling one of the following triggers + automatically disables the other ones: FrameStart, FrameBurstStart, + FrameBurstActive. + Bugs Fixed: + - mvBlueCOUAGR-XD104G/C: Changing the exposure time could crash the camera + firmware. + - mvBlueFOX-2064G/C: Streaming could stop during auto exposure mode. + - Firmware version 0x34(52) for mvBlueFOX devices added. (mvBlueFOX-lib) + Changes: + - Fixed "device descriptor read/64, error -110" message in the kernel ring buffer + of Linux systems when plugging in the camera. + + NEW FEATURES: + - On Linux systems the priority of certain threads has been adjusted. All Linux (all shipped Linux packages) + installer scripts take care of the necessary settings automatically. + - 'AdaptiveHomogeneityDirected' Bayer conversion mode added for very high quality (all shipped packages except ARM platforms) + debayering. + + UPDATES: + - Improved execution speed of the 'imageRequestReset' function for USB3 Vision devices. (mvGenTLProducer.cti) + - Internal migration to CMake. All Visual Studio projects for Visual Studio are (all shipped MSI-based packages) + generated using CMake now. + - Internal migration to Doxygen 1.8.14. + - Added sensor specific CIECAM16 color correction matrices for all supported sensors. (all shipped MSI-based packages) + + CHANGED BEHAVIOUR: + - Removed support for features that have been declared deprecated for centuries. (mvIMPACT_acquire_GenICam.h) + An 'XYZRaw' feature should be replaced by the same feature without the 'Raw' in its + name. If your application really still depends on the removed feature derive from the + class the feature has been in and add the relevant code(copy it from an older + release) there. + - TransportLayerControl: gevSupportedOptionalCommandsUserDefinedName, + gevSupportedOptionalCommandsSerialNumber, gevSupportedOptionalCommandsEVENTDATA, + gevSupportedOptionalCommandsEVENT, gevSupportedOptionalCommandsPACKETRESEND, + gevSupportedOptionalCommandsWRITEMEM, gevSupportedOptionalCommandsConcatenation, + gevSupportedIPConfigurationLLA, gevSupportedIPConfigurationDHCP, + gevSupportedIPConfigurationPersistentIP gevCurrentIPConfiguration, all + gevManifest related properties. + A device should offer gevSupportedOptionSelector and gevSupportedOption flavors + of gevCurrentIPConfigurationXYZ and deviceManifestXYZ properties instead. + - AcquisitionControl: acquisitionFrameRateRaw, acquisitionLineRateRaw, + triggerDelayRaw, exposureTimeRaw. + - AnalogControl: gainRaw, blackLevelRaw, whiteClipRaw. + - CounterAndTimerControl: timerDurationRaw, timerDelayRaw, timerValueRaw. + - Instantiating classes with an incompatible interface layout will raise an exception (all shipped packages) + now. So classes from the GenICam namespace can only be used with devices operated in + 'GenICam' interface layout and classes that state they can only be used with 'Device + Specific' interface layout can only be used with devices operated in device specific + interface layout now. + + BUGS FIXED: + - On Linux USB3 Vision devices that have been opened in a another process are no longer (mvGenTLConsumer-lib) + report 'Unreachable' in the 'State' property of the current process. + - Potential crash when using the 'AdaptiveEdgeSensingPlus' Bayer conversion mode when (all shipped packages) + the channel bit depth did change from one request to the next. + - Moving Mono12 packed test images did use a different start pixel value for each color (mvVirtualDevice-lib) + color bar. + - Network interfaces with more than one IP address could lead to error messages (all shipped Linux packages) + appearing on the console. + - Updating the DirectShow interface without uninstalling all previous versions of (DirectShow_acquire.ax) + mvIMPACT Acquire did not install the latest version since version 2.17.0. + (Bug introduced in version 2.17.0) + - Unchecking the 'automatically check for updates' checkbox within the MSI installer (all shipped MSI based packages) + did result in an installation error. + (Bug introduced in version 2.26.0) + - .NET 'Request' property hasProcessingBeenSkipped always returned false. (mv.impact.acquire.dll) + +12.04.2018 2.26.0 + NEW FIRMWARE: + - Firmware version 2.28.1323.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Maximum exposure time increased to up to 20s for all ICX and IMX sensors + except the IMX178. + - New properties 'mvDeviceSensorRevisionMajor', 'mvDeviceSensorRevisionMinor', + 'mvDeviceSensorPixelWidth', 'mvDeviceSensorPixelHeight' added. + - Support for multiple paths in sequencer using old properties + 'SequencerPathSelector', 'SequencerTriggerSource' and new property + 'SequencerTriggerActivation'. 'SequencerTriggerSource' now also supports + 'UserOutput0' as a trigger. + - mvBlueCOUGAR-XD107: SONY IMX420 Dual Gain feature now available + Dual Gain feature is only usable in combination with Multi-AOI mode. + Changed behaviour: + - Nodes with attribute 'ValidValueSet' are no longer used in the GenICam XML + file. Therefore this and future versions can also be used with software + that is linked with the GenApi 2.0 - 2.3(e.g. mvIMPACT Acquire 1.10.95 - + 2.6.3, MIL 9, etc..). + - 'mvFeatureMode' and 'ImageCompressionMode' will only be available if JPEG + compression is available now. + - mvBlueFOX3: Cameras do no longer go into standby while streaming. + - CIECAM16 instead of WPPLS color correction matrices are now used in all + cameras. + - mvBlueCOUGAR-X(D), mvBlueFOX3 (models with IMX sensors): + Improved AquisitionStart behaviour. + Bugs Fixed: + - UserOutputValues and LineSources were not set correctly when calling + UserSetLoad(). Bug introduced in 2.27.1231.0. + - mvBlueCOUGAR-X(D) (all models): fixed bug that could crash the camera firmware + when enabling/disabling the serial interface + - mvBlueCOUGAR-X(D), mvBlueFOX3 (models with IMX sensors): + In random cases acquisition could stop when changing exposure time. + - mvBlueCOUGAR-XD107G/C: Sequencer could stop when changing image size. + - Sequencer frame rate no longer depends on exposure time of last configured + sequencer set. + - Writing to the binning/decimation registers sometimes did take quite some + time for some IMX sensor based cameras. Bug introduced in 2.27.1231.0. + - The 'device mode' register did contain an invalid value for 'current link + configuration' in static LAG mode resulting in invalid data in the + 'GevCurrentPhysicalLinkConfiguration' property when a GEV device then. + + NEW FEATURES: + - 'mvGainMode' and 'mvGainHorizontalZoneDivider' property added to the 'AnalogControl' (mvIMPACT_acquire_GenICam.h) + class of the GenICam namespace. (mv.impact.acquire.dll) + - Added a checkbox to allow to configure whether wxPropView shall automatically check (all shipped MSI based packages) + for updates or not. + - All Linux installer scripts now support a minimal installation option, which can be (all shipped Linux packages) + achieved with the '-m' or '--minimal' command line argument. + - The sequencer wizard can now cope with multiple sequencer paths per sequencer set. (wxPropView) + - 'AdaptiveEdgeSensingPlus' Bayer conversion mode added for high quality debayering. (all shipped packages) + + UPDATES: + - Checking for updates now is 'proxy setting aware'. (wxPropView) + - Migration to wxWidgets 3.0.4 (Windows only). All wxWidgets based applications (all shipped MSI based packages) + are built using wxWidgets 3.0.4 now. + - Internal migration to IPP 2018.2. (all shipped packages) + + CHANGED BEHAVIOUR: + - From this version onwards the initial mvBlueFOX kernel driver for 32-bit Windows (mvBlueFOX.sys) + that was removed in version 1.10.66 can no longer be updated to the mvBlueFOX2.sys + driver that was added in version 1.6.10 (2006). When you still have 32-bit systems + using this old driver use mvDeviceConfigure to update the driver BEFORE migrating + to mvIMPACT Acquire 2.26.0 or newer. + - From this version onwards Windows XP is no longer supported by mvIMPACT Acquire. (all shipped MSI based packages) + Official support stopped a while ago, since this release GUI applications as well as + some of the underlying libraries will no longer load on Windows versions older than + Windows Vista. + - The ColorTwist filters 'DeviceSpecific' input matrix now uses CIECAM16 color (all shipped packages) + correction matrices, in contrast to WPPLS color correction matrices used until now. + Furthermore, CIECAM16 color correction matrices can now also be manually selected + for all products. + - The ColorTwist filter's output matrix default preset has been changed from (all shipped packages) + XYZToAdobeRGB_D50 to XYZTosRGB_D50 since most use-cases use the sRGB colorspace. + - Writing a GenICam feature no longer blocks the acquisition engine. When writing to a (mvGenTLConsumer-lib) + device feature took a long time (e.g. did generate PENDING_ACKs) during that time + no new requests could be queued which could result in the acquisition engine to + starve. + - The default visibility of the infoFrameID property of a request has been changed from (all shipped packages) + 'invisible' to 'visible'. + - Low level errors reported by a GenTL producer when reading and writing properties (mvPropHandling-lib) + will be reported to the application now. + + BUGS FIXED: + - Updating mvBlueCOUGAR-X(D) devices running with firmware version 1.1.3.0 or smaller (mvDeviceConfigure) + did not work properly and resulted in various messages with information that did not + actually apply. + - Some bugs and warnings fixed for mvIMPACT_Python wrapper scripts. (all shipped packages) + - Potential crash when no GenICam device has been detected, the 'warn on potential (wxPropView) + firewall issues' option was active, and the user selected 'No' in the message dialog. + - On Linux systems the various settings of the options dialog could not be changed. (wxPropView) + (Bug introduced in version 2.25.0) + - Crash when shutting down a Windows 7 system while wxPropView was still open. (wxPropView) + - When moving wxPropView around or minimizing and then maximizing the application again (wxPropView) + the display overlay messages haven't been repainted. (Windows only) + - The example applications 'CaptureToUserMemory_C' and + 'ContinuousCaptureOnlyProcessLatest' have been missing some files after the (all shipped MSI based packages) + installation. (Windows only) + - Potential crash in defective pixel filter when feeding it with images with either the (all shipped packages) + width or the height being smaller than 20. + (Bug introduced in version 2.22.1) + +09.02.2018 2.25.0 + NEW FIRMWARE: + - Firmware version 2.27.1231.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR: FFC Calibration is now possible with configured AOI. + In this case the average value is calculated for the AOI only + while the FFC values are calculated for the full sensor area. + - New camera mvBlueCOUGAR-XD107C with sensor IMX420. + Changed behaviour: + - mvBlueFOX3-2064G/C: Minimum AOI height is 320 now, + minimum AOI width is 376 now. + - Deprecated some features with respect to the latest SFNC 2.3: + 'mvGevSCBWControl' (use 'DeviceLinkThroughputLimitMode' instead), + 'mvGevSCBW'(use 'DeviceLinkThroughputLimit' instead) + - Removed support for features that have been declared deprecated for centuries. + All the information can be accessed using 'GevSupportedOptionSelector' and + 'GevSupportedOption': + - 'GevSupportedOptionalCommandsUserDefinedName' + - 'GevSupportedOptionalCommandsSerialNumber' + - 'GevSupportedOptionalCommandsEVENTDATA' + - 'GevSupportedOptionalCommandsEVENT' + - 'GevSupportedOptionalCommandsPACKETRESEND' + - 'GevSupportedOptionalCommandsWRITEMEM' + - 'GevSupportedOptionalCommandsConcatenation' + - 'GevSupportedIPConfigurationLLA' + - 'GevSupportedIPConfigurationDHCP' + - 'GevSupportedIPConfigurationPersistentIP' + - 'GevSupportedOptionalCommandsUserDefinedName' + - mvBlueCOUGAR-X125aG/C: Minimum width is 18 instead of 16 now. + Bugs Fixed: + - mvBlueCOUGAR-X(D): Wrong frame rate after startup. Bug introduced in 2.26.1138.0. + - mvBlueFOX3-2064G/C: Fixed bug that could crash the camera firmware. + - mvBlueSIRIUS: Wrong pixels could occur at 56Mhz device clock. + - mvBlueCOUGAR-X102e/102eGE/104e(since 2.15), + mvBlueCOUGAR-X100/102b/105/1010(since 2.23), + mvBlueCOUGAR-XD12xG/C: + Actual TimerDelay and TriggerDelay were too short by ~3.5%. + + NEW FEATURES: + - Users now can manually check or enable automatic weekly checking for updates. This (wxPropView) + can be done with options found in the 'Help' menu. + - 'Set Parameter Delimiter' option added to the context menu for methods in the (wxPropView) + property grid. + - Outdated fall-back boot programmers on mvBlueFOX3 devices can be updated using (mvDeviceConfigure) + mvDeviceConfigure now. A message box directly before starting a firmware update + will inform the user about this. + - Devices can now be selected based on a string Device ID (e.g. 'UserDefinedName' for (mvIMPACT_acquire.h) + GenICam devices) with the functions 'DMR_GetDeviceWithStringID()', (mvDeviceManager-lib) + 'mvIMPACT::acquire::DeviceManager::getDeviceByProductAndID()' or (mv.impact.acquire.dll) + 'mv.impact.acquire.DeviceManager.getDeviceByProductAndID()'. + - Devices can be operated in GenICam interface layout as well now. (mvIMPACTAcquire_Cognex_Adapter-lib) + - New color correction matrix added: 'cticmmBlueCOUGAR_XDx07C_CIECAM16'. It will be (all shipped packages) + used by mvBlueCOUGAR-XD107C devices. + + UPDATES: + - Added missing features to the 'mvFFCControl' class: 'mvFFCImageLoad', (mvIMPACT_acquire_GenICam.h) + 'mvFFCImageSave' and 'mvFFCAutoLoadMode'. (mv.impact.acquire.dll) + - On Linux systems just like on windows systems, all GEV cameras with bad network (mvIPConfigure) + configurations will now appear on the device list. + + CHANGED BEHAVIOUR: + - The following classes have been removed from the GenICam namespace of the public (all shipped packages) + interface: mvSPIControl, mvDACParams, mvOMAPPreviewConfig, mvXLampControl and + mvACCControl. All these features where only supported by discontinued products. + - The following features have been removed from the GenICam namespace of the public (all shipped packages) + interface + - DeviceControl: mvDeviceSensor. + - ImageFormatControl: mvDebayerAlgorithm, mvOffsetYSensorB, + mvSensorLineOffsetSelector, mvSensorLineOffset, mvSensorLinePeriod. + - AnalogControl: mvVCAL, mvVBLACK, mvVOFFSET. + All these features where only supported by discontinued products. + - From this version onwards mvIMPACT Acquire will no longer serve as a valid license (all shipped packages) + provider for the discontinued mvIMPACT SDK. As a consequence mvIMPACT SDK licenses + bound to a specific MATRIX VISION device can only be used with mvIMPACT Acquire + packages < 2.25.0. + + BUGS FIXED: + - Writing from an application to the 'DefectivePixelOffsetX' or 'DefectivePixelOffsetY' (all shipped packages) + did not always become effective. + - When updating an mvIMPACT Acquire package other than mvGenTL_Acquire to 2.24.0 or (wxPropView) + newer while having an installed version of mvGenTL_acquire < 2.24.0 on the system as (mvDeviceConfigure) + well, mvDeviceConfigure did crash upon starting and wxPropView when opening the + driver information dialog. + (Bug introduced in version 2.24.0) + - Various minor bug fixes and improvements of the Linux installers of mvGenTL_Acquire (mvGenTL_Acquire-*.tgz) + with regard to the plugdev group management and Linux capabilities for arping. (mvGenTL_Acquire-ARM*.tgz) + - Warning regarding ignored interfaces could pop up even if there weren't any. (mvIPConfigure) + - Changing the property 'ImageFormatControl/PixelFormat' did not automatically (mvGenTLConsumer-lib) + update the visibility of the color processing properties in the 'ImageProcessing' + list in GenICam interface layout. + - Fixed some minor issues in the Multi-AOI wizard. When entering the wizard with Multi- (wxPropView) + AOI already active, the behaviour is correct now, incorrect labels when deleting an + AOI fixed, some hints added. + - Clicking on the bitmaps left and right of the optimization slider of the Quick Setup (wxPropView) + Wizard now also selects the min/max value for the slider. + - On Linux systems saving camera settings natively works again. (mvGenTLConsumer-lib) + (Bug introduced in version 2.19.0) + +06.12.2017 2.24.0 + NEW FIRMWARE: + - Firmware version 2.26.1138.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Improved Interface of Flat Field Correction Feature: Loading/Storing the FFC data + in non-volatile can be done now manually too. + - The Flat Field Correction in mvBlueCOUGAR-X CMOS color cameras (all but CMV and + V034) is done now color aware and won't interfere with the normal white balance + settings anymore. + - The new feature 'mvTimestampPPSSync' allows synchronizing the Timestamp by a + 'Pulse Per Second' signal. It is available in all mvBlueCOUGAR-X(D) and mvBlueFOX3 + devices. + - mvBlueCOUGAR-XD107G: Upper and lower part of an image can be acquired with + different exposure times. + Changed behaviour: + - mvBlueFOX3-2064G/C: Minimum width is 640 instead of 512 now. + - Deprecated some features with respect to the latest SFNC 2.3: + 'GevVersionMajor' (use 'DeviceTLVersionMajor' instead), + 'GevVersionMinor'(use 'DeviceTLVersionMinor' instead), + 'GevDeviceModeIsBigEndian' (use 'DeviceRegistersEndianness' instead), + 'GevDeviceClass' (use 'DeviceType' instead), + 'GevDeviceModeCharacterSet' (use 'DeviceCharacterSet' instead), + 'GevNumberOfInterfaces' (use 'DeviceLinkSelector' instead), + 'GevMessageChannelCount' (use 'DeviceEventChannelCount' instead), + 'GevStreamChannelCount' (use 'DeviceStreamChannelCount' instead), + 'GevHeartbeatTimeout' (use 'DeviceLinkHeartbeatTimeout' instead), + 'GevTimestampControlLatch' (use 'TimestampLatch' instead), + 'GevTimestampControlReset' (use 'TimestampReset' instead), + 'GevTimestampControlLatchReset' (use 'TimestampLatch' and 'TimestampReset' + instead), + 'GevTimestampValue' (use 'TimestampLatchValue' instead), + 'GevSCPDirection' (use 'DeviceStreamChannelType' instead), + 'GevSCPSBigEndian' (use 'DeviceStreamChannelEndianness' instead), + 'GevLinkSpeed' (use 'DeviceLinkSpeed' instead), + 'mvDeviceStatusLEDEnable' (use 'DeviceIndicatorMode' instead) + - mvBlueFOX3: Sequencer can be used up to 500 fps. + Bugs Fixed: + - GevMCSP was always reported as 0. + - mvBlueCOUGAR-X/XD: Loading of default user set could lead to wrong bandwidth + (mvGevSCBW) settings. + - AOI used for AEC, AGC, AWB algorithms was not updated when the actual capture + AOI was changed. + + NEW FEATURES: + - Added a 3rd part (Mono8 ramp) to the multi-part mode of the virtual device (mvVirtualDevice-lib) + for testing purposes. + - Interfaces can now be ignored as a group, based on their transport layer technology (mvGenTLProducer.cti) + type by using the properties 'mvInterfaceTechnologyToIgnoreEnable' and + 'mvInterfaceTechnologyToIgnoreSelector'. + - mvDeviceConfigure can detect ignored GenICam interfaces, and recommend a fix. (mvDeviceConfigure) + - mvIPConfigure can detect ignored GenICam interfaces, and recommend a fix. (mvIPConfigure) + + UPDATES: + - Some U3V devices set their 'event_size' in multi-event mode to invalid values (e.g. (mvGenTLProducer.cti) + 0). This could result in an internal infinite loop resulting in no more events being + delivered to the application. + - For GEV devices supporting the message channel source port the driver will now send (mvGenTLProducer.cti) + dummy packets to the devices message channel in order to open up the message channel + if blocked by a firewall. + - Optimized packet size auto negotiation algorithm for GEV devices. (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - The 'workerPriority' property of the SystemSettings class/category has been declared (all shipped packages) + deprecated. + - Property 'mvIgnoreInterfaceWhenEnumerating', is no longer a bool but a tri-state (mvGenTLProducer.cti) + enum, and it has been renamed to 'mvDeviceUpdateListBehaviour'. This change was + necessary for seamless operation with the new 'mvInterfaceTechnologyToIgnoreEnable' + and 'mvInterfaceTechnologyToIgnoreSelector' features. + - When the 'Bayer' filter did return an incorrect result buffer if a device claimed (all shipped packages) + to send one format but then did actually deliver a different one. + - The check for the presence of KB3033929 which is needed on Windows 7 and (all shipped MSI based packages) + earlier for the processing of SHA256 signatures introduced in version 2.16.0 is now + also done during silent installations. + - The Quick Setup Wizard no longer automatically changes any device settings if (wxPropView) + manually started from the button or the menu. Furthermore, feature selectors as + well as scrollbar positions and zoom factor of the displayed image will be reverted + to their original setting when closing the wizard. + - The 'Driver Information dialog' now resides in the 'Action' category of the menu, and (wxPropView) + is called 'Interface Configuration and Driver Information' dialog. If there are + GenICam interfaces on the system the user can ignore or un-ignore them graphically + in this dialog. + + BUGS FIXED: + - Several bugs fixed in the scripts that build the mvIMPACT for Python wrapper. (all shipped packages) + - Potential crash when the application was running in 'full tree' mode, a property was (wxPropView) + selected within the grid and the application was closed then. + - Error message when pressing 'OK' after dragging an area to the left or lower end of (wxPropView) + the image after reducing the width/height of that area in the 'Multi AOI' wizard. + - Firmware update is possible again for mvBlueCOUGAR-S devices. (mvGenTLConsumer-lib) + (Bug introduced in version 2.18.0) + - Potential BSOD when the operating system did run extremely low on resources. (mvGigECapture.sys, version 2.3.4.61) + (mvGigECapture2.sys, version 3.1.4.61) + - Sometimes when opening/closing a GEV device while calling 'updateDeviceList' from a (mvGenTLProducer.cti) + separate thread opening the device the next time could fail. + - For some RGB packed to ibpfBGR101010Packed_V2 conversions the resulting image did (all shipped packages) + incorrectly exchange the red and blue component. + - For internal pixel format conversions of buffers using a line pitch with padding (all shipped packages) + bytes when the conversion was done on the fly (within the existing buffer) the + resulting image could have an incorrect pitch after the conversion. + - White balance calibration for multi-byte data did take the current gain into account (all shipped packages) + resulting in the white balance gains to change every time 'CalibrateNextFrame' was + selected and applied to the next image. + - The Bayer filter did not process data if the final output format was set to (all shipped packages) + 'ibpfBGR101010Packed_V2'.' + - When reading a value as string from a property storing n values, reading at index n (mvPropHandling-lib) + not return an error. The returned data however was arbitrary memory content. + - When leaving the 'Color Correction' dialog without pressing 'OK' the previous (wxPropView) + settings will be restored now. + +18.10.2017 2.23.0 + NEW FIRMWARE: + - Firmware version 2.25.1029.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - New camera mvBlueCOUGAR-XD107G with sensor IMX420. + Changed behaviour: + - Improved configuration speed of sequencer. + Bugs Fixed: + - mvBlueFOX3-1020G/C, mvBlueFOX3-1020aG/C, mvBlueCOUGAR-X104eG/C: One corrupt + column could appear. + - mvBlueCOUGAR-X(D)*: Block ID in legacy mode (16 bit) did not wrap correctly in + some special cases. + - mvBlueFOX3-2124G: In multi-AOI mode these cameras operated at a reduced frame + rate (half) and with slightly incorrect AOIs. + - mvBlueCOUGAR-X(D) and mvBlueFOX3: When loading different trigger configurations + by use of "Load Active Device Settings -> From a File" it was not guaranteed + that the trigger settings were loaded correctly. + + UPDATES: + - Opening multiple devices in parallel is much faster now. (all shipped packages) + + NEW FEATURES: + - Added public interface for accessing the Opto Engineering Stepper and the Invenios (mvIMPACT_acquire.h) + Liquid Lens. (mv.impact.acquire.dll) + - Added new functions to load/store images in TIFF, JPEG, PNG and BMP format. TIFF and (mv.impact.acquire.dll) + PNG supports multi-byte thus lossless storage of formats like e.g. Mono12. For (mvDeviceManager-lib) + formats not supporting multi-byte data the data will be converted into an appropriate (wxPropView) + single-byte format during the file I/O operation. + The new functions for the 'C' interface are 'DMR_LoadImageBuffer', + 'DMR_SaveImageBuffer' and 'DMR_ImageRequestSave'. + For the C++ interface 'mvIMPACT::acquire::Request::save', + 'mvIMPACT::acquire::ImageBufferDesc::save' and a new constructor for + 'mvIMPACT::acquire::ImageBufferDesc' taking a file name have been added. + For the .NET interface so far only 'mv.impact.acquire.Request.save' is available. + - 16-bit mono and RGB images in TIFF or PNG format can be imported from a directory (mvVirtualDevice-lib) + now. + - New constructors added to mv.impact.acquire.GenICam.SystemModule (mv.impact.acquire.dll) + and mv.impact.acquire.GenICam.InterfaceModule. They can be used without a valid + pointer to a device class instance. + - Interfaces can now selectively be ignored when updating the device list, by using (mvGenTLProducer.cti) + the feature 'mvIgnoreInterfaceWhenEnumerating' in the GenICam System module. + + CHANGED BEHAVIOUR: + - Linux installers of mvGenTLAcquire no longer install U3V-related libraries if only (mvGenTL_Acquire-*.tgz ) + GEV support has been explicitly requested. (mvGenTL_Acquire-ARM*.tgz ) + - The 'Pending Timeout' register of a GEV device is now used for determining the (mvGenTLProducer.cti) + default value of 'LinkCommandTimeout' of the 'DeviceModule' instance. + + BUGS FIXED: + - Potential blue screen (BSOD) on 64-bit Windows systems running 32-bit applications. (mvGenTLProducer.cti) + +20.09.2017 2.22.1 + NEW FIRMWARE: + - Firmware version 2.24.975.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - New cameras: mvBlueFOX3-2064G/C + - Serial Interface: Opto Engineering stepper support added for MTDV3CH-00A1 + - Serial Interface: Invenios Liquid Lens support added for Caspian C-39N0-160 + - mvBlueFOX3-2064G/C: FrameStart trigger implemented. + - mvBlueFOX3-2064G/C: new mvRollingShutterFlash mode provides an exposure signal to + flash all lines simultaneously, avoiding motion effects.(only for + exposure > 300usec). + - Added support for the 'DeviceFeaturePersistenceStart' and + 'DeviceFeaturePersistenceEnd' features. + Bugs Fixed: + - mvBlueFOX3-2004G/C, mvBlueFOX3-2016G/C, mvBlueFOX3-2024(a)G/C, + mvBlueFOX3-2032(a)G/C, mvBlueFOX3-2051(a)G/C,mvBlueFOX3-2064G/C, + mvBlueFOX3-2089(a)G/C, mvBlueFOX3-2124(a)G/C, + mvBlueCOUGAR-X100fG/C,mvBlueCOUGAR-X102fG/C, mvBlueCOUGAR-X(D)104d/f/h/iG/C, + mvBlueCOUGAR-X(D)105a/bG/C, mvBlueCOUGAR-X109bG/C, mvBlueCOUGAR-X1012bG/C, + respect exposure time step width in auto exposure mode to prevent flickering + that occurred when using small exposure times. + mvBlueCOUGAR-X(D) cameras had boot problems when real UART traffic or I/O + crosstalk was present at startup + (Bug introduced in version 2.22.883.0) + + NEW FEATURES: + - New sample added to all packages: 'ContinuousCaptureMultiPart'. (all shipped packages) + - Most samples typically installed on Linux x86/x86_64 systems are now available for (mvBlueFOX-ARM*.tgz) + ARM systems too. (mvGenTL_Acquire-ARM*.tgz ) + + CHANGED BEHAVIOUR: + - Defective Pixels algorithms now do not check against a whole image average, but (all shipped packages) + rather against a local average, eliminating false positives in case of e.g. + uneven lighting of the sensor. + - The deprecated libraries 'mvBlueCOUGAR-lib' and 'mvTLIClientGigE.cti' will no longer (all shipped packages for GEV/U3V devices) + be loaded. Their usage had been declared deprecated in version 2.3.0. Since version + 2.7.2 these libraries are no longer shipped anyway. + + BUGS FIXED: + - Pressing the greyscale preset of the 'Quick Setup' wizard when streaming from a color (wxPropView) + camera could lead to unhandled exceptions. + (Bug introduced in version 2.22.0) + - 'Defective pixel filter' did not take AOI/Offset changes into account. (all shipped packages) + - mv.impact.acquire.GenICam.DevFileStream: After calling the Read/Write method with a (mv.impact.acquire.dll) + 'count' value that was not the full file size the 'Position' property was not always + updated correctly. + +10.08.2017 2.22.0 + NEW FIRMWARE: + - Firmware version 2.23.928.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-X(D): Migration to GEV 2.1. This includes support for extended + block ID. + - mvBlueCOUGAR-X102bG/C, mvBlueCOUGAR-X102dG/C, mvBlueFOX3-1012bG/C, + mvBlueFOX3-1012dG/C: Frame rate increased up to 45fps at full AOI if using new + DeviceClockFrequency 74,25MHz. + - mvBlueCOUGAR-X100fG/C, mvBlueCOUGAR-X102fG/C, mvBlueCOUGAR-X104f/iG/C, + mvBlueCOUGAR-X105bG/C, mvBlueCOUGAR-X109bG/C, mvBlueCOUGAR-X1012bG/C: + Flat field correction implemented. + Changed behaviour: + - mvBlueCOUGAR-X102bG/C, mvBlueCOUGAR-X102dG/C: Maximum BinningHorizontal + is 2 now (was 8 before), maximum DecimationHorizontal is 4 now (was 16 + before), maximum DecimationVertical is 4 now (was 2 before). + Bugs Fixed: + - mvBlueCOUGAR-X102bG/C, mvBlueCOUGAR-X102dG/C, mvBlueFOX3-1012bG/C, + mvBlueFOX3-1012dG/C: Trigger problems with 66MHz DeviceClockFrequency solved. + - mvBlueFOX3-2089aG/C, mvBlueFOX3-2124aG/C: Cameras sometimes crashed for long + exposure times. + - mvBlueFOX3-2124G: Displacement of 0.5 vertical pixels of binned image corrected. + + NEW FEATURES: + - Initial version of a full Python wrapper for mvIMPACT Acquire added. Before the (all shipped packages) + samples or any self written code can be executed the wrapper code needs to be + compiled for the installed version of Python. See product specific manuals for + additional details. + - New color correction matrix added: 'cticmmBlueFOX3_x064C_WPPLS'. This matrix will (all shipped packages) + be used by 'mvBlueFOX3_x064C' devices. + - Added new command line option 'allWithAtLeastOneDevice' to enable the filter driver (mvGigEConfigure) + on all network interfaces that have at least one GigE Vision device connected to it. + See tool output window for details. + + BUGS FIXED: + - Certain YUV422Packed formats now display correctly. (mvDisplay-lib) + (Bug introduced in version 2.20.0) + - In the (deprecated) DeviceSpecific interfaceLayout, in case of multiple gains, the (mvBlueCOUGAR-lib) + 'Gain_dB' property now refers to the 'AnalogAll' Gain of the device, and not + arbitrarily to the first gain in the list. + - Calling 'updateDeviceList' after a previous call to (mvGenTLProducer.cti) + 'InterfaceModule::GevDeviceForceIPCommand' did never return. + (Bug introduced in version 2.20.0) + - When a GEV device did stream in the deprecated extended chunk format with 64-bit (mvGenTLProducer.cti) + block ID enabled the reported timestamp was always 0. + - When a GEV device did stream in 'image extended chunk' format with 64-bit block ID (mvGenTLProducer.cti) + disabled the chunk data could not be decoded resulting in + 'rrInconsistentBufferContent' errors. + - The GEV format 'JPEG_ExtendedChunk' (0x4006) can be decoded correctly now. (mvGenTLProducer.cti) + - Resend commands for GEV streams using the 64-bit block ID mode did use an incorrect (mvGenTLProducer.cti) + layout. As a consequence resend did not work then. (mvGigECapture.sys, version 2.3.3.60) + (mvGigECapture2.sys, version 3.1.3.60) + - Requesting images using the 'ircmTrial' did return incorrect information (e.g. a (mvGenTLConsumer-lib) + width of 0). + - When a GEV device was opened with RO access while another process had established (mvGenTLProducer.cti) + control access already the properties in the RO process appeared to be writeable. + (Bug introduced in version 2.15.0) + - Fixed ArgumentNullException that could occur if LibraryPath.init() was called and (mv.impact.acquire.dll) + an assembly without a public key was resolved afterwards. + - Sometimes properties belonging to the 'BufferPart' class did change their handles (mvIMPACT_acquire.h) + but the API still referred to old ones resulting in 'INVALID_LIST_ID' exceptions. (mv.impact.acquire.dll) + - A Bayer image in a multi-part buffer was not automatically converted into an RGB (mvGenTLConsumer-lib) + image(it did loose its Bayer attribute before being delivered to an application). + - The new enum value 'dc3DCamera' did use an incorrect numerical value. This could (mvDriverBaseEnums.h) + cause problems with applications compiled with older versions of the header file. (mv.impact.acquire.dll) + 3D cameras might be reported as frame grabbers and vice versa. + (Bug introduced in version 2.21.1) + - Firmware update for mvBlueSIRIUS devices is possible again. (mvDeviceConfigure) + (Bug introduced in version 2.21.1) + +10.07.2017 2.21.1 + NEW FIRMWARE: + - Firmware version 2.22.883.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3, mvBlueCOUGAR-X(D): mvSerialInterface support added. + - mvBlueFOX3-2024aG/C, mvBlueCOUGAR-X104fG/C: Higher frame rates with reduced + image width. + - mvBlueFOX3-2, FrameAverage now available for all cameras with SONY Pregius sensors + Changed behaviour: + - In ExposureMode TriggerWidth trigger sources only triggers defined by a + pulse are allowed. Triggers generated by logical events + (e.g. CounterEnd) don't make sense and so they can no longer be configured. + Bugs Fixed: + - mvBlueCOUGAR-X1010G/C: Maximum for AcquisitionFrameRate was reduced to 135Hz. + (Bug introduced in version 2.21.833.0) + - mvBlueCOUGAR-X225G/C: Corrupt images. + (Bug introduced in version 2.20.774.0) + - mvBlueFOX3 and mvBlueCOUGAR-X(D) with IMX sensors: ExposureMode TriggerWidth + did not work in some cases. + (Bug introduced in version 2.10.326.0) + - mvBlueCOUGAR-XD129G/C: Corrupt images could occur when using highest + DeviceClockFrequency. + - mvBlueFOX3, mvBlueCOUGAR-X(D): Cameras that were updated from a software prior + to 2.21.833.0 had shown the Firmware Hash Code only after calling + mvCalculateHashCode(). + + NEW FEATURES: + - New color correction matrices added: 'cticmmBlueCOUGAR_Xx00fC_WPPLS', (all shipped packages) + 'cticmmBlueCOUGAR_Xx02fC_WPPLS', 'cticmmBlueFOX3_x004C_WPPLS' and + 'cticmmBlueFOX3_x016C_WPPLS'. These will be used by 'mvBlueCOUGAR-X100fC', + 'mvBlueCOUGAR-X102fC', 'mvBlueFOX3_x004C' and 'mvBlueFOX3_x016C'devices respectively. + + UPDATES: + - Updated target color space matrices for ColorTwist filter. (all shipped packages) + - Previous versions of the GigE Vision filter driver did generate a lot of DPCs even (mvGigECapture.sys, version 2.3.2.59) + when no device was actually streaming data. Now DPCs will only be generated for (mvGigECapture2.sys, version 3.1.2.59) + adapters that currently receive data from at least one GEV device. + + CHANGED BEHAVIOUR: + - The default value of the 'GEV_NDIS_DRIVER_INSTALL' parameter for the installer is now (mvGenTL_Acquire*.msi) + 'yes' in order to restore the previous behaviour of custom installations. + - An EULA has been added to mvIMPACT Acquire that needs to be accepted before you can (all shipped packages) + install the software. + + BUGS FIXED: + - Certain combinations of AOI and pitch could result in crashes in the mvDisplay (mvDisplay-lib) + library on 32-bit Windows systems. + - Potential freeze when using mvBlueFOX devices with no on-board memory in parallel, (DirectShow_acquire.ax) + in combinations that exceed the total bandwidth limit of the USB channel. + - Storing properties containing binary data in a setting did not always work. (mvPropHandling-lib) + This did e.g. result in FFC calibration data not being written to a XML-file. + (Bug introduced in version 2.15.1) + - When capturing data with 'ImageProcessingMode' set to 'ipmProcessLatestOnly' while (all shipped packages) + the flat field filter or the dark current filter are in calibration mode dropped + frames did result in incomplete calibration results. + +01.06.2017 2.21.0 + NEW FIRMWARE: + - Firmware version 2.21.833.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - 'BalanceWhiteAuto' and 'BlackLevelAuto' automatically switch back from + e.g. 'Once' to 'Off' once the calibration has been performed. + - mvBlueFOX3: Added command to reset the PHY and LINK error counters. + - mvBlueFOX3, mvBlueCOUGAR-X(D): Added possibility to calculate SHA1 + hash of firmware file currently saved in camera. + Changed behaviour: + - mvBlueCOUGAR-X105G/C: Minimum width changed from 16 to 80. + - mvBlueCOUGAR-X, mvBlueCOUGAR-XD, mvBlueFOX3: cameras start with + mvAcquisitionFrameRateLimitMode set to 'mvDeviceLinkThroughput', + AcquisitionFrameRateEnable set to 'true' and AcquisitionFrameRate set to the + maximum frame rate available with the sensor + Bugs Fixed: + - mvBlueCOUGAR-X104G/C, mvBlueCOUGAR-X104bG/C/UV, mvBlueCOUGAR-XD104G/C, + mvBlueCOUGAR-XD104bG/C, mvBlueCOUGAR-XD204G/C, mvBlueCOUGAR-XD204bG/C: + Camera could crash during streaming. + (Bug introduced in version 2.15.578.0) + - ChunkGain was not correct when using automatic gain control. + - mvBlueFOX3: Show correct DeviceUserID and DeviceUserData after returning from + standby mode. + + NEW FEATURES: + - All libraries now use thread local storage to store the last error information. (all shipped packages) + As a result much better exception messages can be generated now. + + UPDATES: + - Improved support for 3rd party GenICam devices when using the sequencer wizard. (wxPropView) + - Improved support for 3rd party devices that did not change the 'chunk_layout_id' when (mvGenTLConsumer-lib) + the PayloadSize did change. + - Improved support for 3rd party devices that did support the chunk mode without (mvGenTLConsumer-lib) + specifying at least one chunk feature and a chunk port in their XML file. + - Internal migration to libusb 1.0.21. (mvGenTL_Acquire-*.tgz ) + + BUGS FIXED: + - Potential crash when calling 'GCUnregisterEvent' for a error event registered for a (mvGenTLProducer.cti) + device that has already been closed. (Linux only). + - For GEV streams where the trailer did arrive before the first payload packet these (mvGenTLProducer.cti) + buffers have sometimes been tagged as incomplete even though all data has been + captured when the socket driver was used. + (Bug introduced in version 2.20.0) + - Loading BMP files without the FreeImage library did fail when the bitmap file did (mvVirtualDevice-lib) + specify a negative height(which actually means the image is NOT stored upside down). + - Fixed a couple of bugs that did surface when using a 3rd party GenTL producer (mvGenTLConsumer-lib) + - Potential crash when closing a DirectShow application in which the properties dialog (DirectShow_acquire.ax) + has been opened at least once. + - Lists below a selector can not be displayed correctly. This is a wxWidgets (wxPropView) + limitation. Such lists are now treated like if 'Settings -> Property Grid -> Use + Selector Grouping' is switched off. + +01.05.2017 2.20.0 + NEW FIRMWARE: + - Firmware version 2.20.774.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3 (except for -2024(a)G/C) and mvBlueCOUGAR-X(D) (except for cameras + with IMX sensors): Added new binning and decimation capabilities. + - mvBlueCOUGAR-X(D)104/204(a(12)/b)G/C: Added support for sensor's vertical + decimation feature with steps 2, 4, 8, 16. Sensor discards data. + - mvBlueGEMINI: Lines will only appear as valid sources when configured + as inputs now. + - mvBlueFOX3: Defective pixel data can be stored permanently on cameras now. + Changed behaviour: + - TriggerSoftwareCommand returns GENCP_BUSY if camera isn't ready for trigger. + Bugs Fixed: + - Reading CounterValueAtReset did not work without reading CounterValue first. + - mvBlueFOX3 and mvBlueCOUGAR-XD: CounterValueAtReset wasn't updated on + a "software reset" + - mvBlueCOUGAR-X(D)104/204(a(12)/b)G/C: mvResultingFramerate was not reached for + mvAcquisitionFrameRateLimitMode = mvDeviceMaxSensorThroughput. + - mvBlueCOUGAR-X102eG/C/GE, mvBlueFOX3-1013G/C, mvBlueFOX3-1020aG/C: Due to + compatibility reasons former device clock frequencies are available again. + (Bug introduced in version 2.15.578.0) + - mvBlueFOX3-1012b/dG/C, mvBlueCOUGAR-X102b/dG/C: MaxValue for + AcquisitionFrameRate corrected. + - mvBlueCOUGAR-X/XD: Camera could crash after writing userfile. + - Corrupt images could occur when changing width or height while sequencer mode + is on. + + UPDATES: + - All the GenICam nodemaps of the GenTL Producer comply with the GenICam GenTL SFNC (mvGenTLProducer.cti) + 1.1.1 now. See 'Porting existing code' section in the manual for additional + information. + + CHANGED BEHAVIOUR: + - Examples for Visual Studio 2005 are no longer shipped as part of the installation. (all shipped MSI-based packages) + Visual Studio 2005 is no longer supported by mvIMPACT Acquire. + - All modules belonging to mvIMPACT Acquire are now build with the /DYNAMICBASE and (all shipped MSI-based packages) + /NXCOMPAT linker switches for Windows. + - The default value of 'ImageProcessing/DefectivePixelsFilter/Mode' is now (all shipped packages) + 'dpfm3x3Median' after calibrating or when defective pixel data is detected inside + the devices non-volatile memory while it used to be 'dpfmOff'. + - Timestamp_us in the request info is based on QueryPerformanceCounter now. (low level mvHYPERION driver, Windows, version 2.1.45.53) + - Only supported request info features will be visible now. Features which are not (all shipped packages) + supported will also have the 'cfInvisible' flag set for the corresponding property + within the 'RequestInfoConfiguration' class. + + NEW FEATURES: + - New menu entry 'Settings -> Image Display -> Configure Images Per Display Count' (wxPropView) + added. It allows to display multiple images displayed in a single large buffer. This + might e.g. be useful for line scan applications to reconstruct a large image showing + the complete object of interest. + - Added class mv.impact.acquire.GenICam.DevFileStream for convenient file access for (mv.impact.acquire.dll) + GenICam devices. + - Support for the multi-part payload format as specified by the GenTL/GigE Vision (all shipped packages) + standard added. See 'Image acquisition/Multi-part format' for details and links to (mvGigECapture.sys, version 2.3.1.57) + the corresponding API classes and functions. (mvGigECapture2.sys, version 3.1.1.58) + - Support for GenICam devices that stream JPEG data added. (mvGenTLProducer.cti) + (mvGenTLConsumer-lib) + - 'BufferPartCount' property added to 'CameraSettingsVirtualDevice' to simulate multi- (mvVirtualDevice-lib) + part and JPEG data. + - The scaler in 'ImageDestination' list now supports scaling from an AOI instead from (all shipped packages) + the whole image. + + BUGS FIXED: + - The minimum value of 'ValueCount' in 'LUTOperations/LUTs/LUT-' in interpolated (all shipped packages) + was 1 instead of 2 and setting it to 1 could result in a crash. + - On some Linux system the ARP request mechanism did not function properly. This could (mvGenTLProducer.cti) + lead e.g. to the auto-configure IP in mvIPConfigure to fail. + - Made NDIS 6.x based GEV filter driver 'header-data split' aware. This fixes problems (mvGigECapture2.sys, version 3.0.3.57) + with jumbo frames on certain network interfaces where images could not be captured + when using large packet sizes. + - After canceling the 'Quick Setup' wizard, erroneous values were written into the (wxPropView) + ColorTwist matrices, resulting in greyscale-like images when a ColorTwist matrix + was enabled again. + - Unhandled exception when using the 'Quick Setup' wizard, with mvBlueFOX devices. (wxPropView) + (Bug introduced in version 2.19.0) + - Constantly calling DMR_Init and DMR_Close or creating and deleting instances of (mvDeviceManager-lib) + mvIMPACT::acquire::DeviceManager did cause the 'Path' variable of the calling process + to get longer and longer(Windows only). + - When loading a stored setting the calibration data for the flat field and dark (all shipped packages) + current filter have not been restored. + (Bug introduced in version 2.17.1) + - On Windows 8 or higher the 'DeviceLinkSpeed' property of the 'InterfaceModule' class (mvGenTLProducer.cti) + did report USB2 speed for U3V devices connected with super speed. + - Bitshifting in 10-bit YUV pixel formats now only affects the luminance (Y) component. (mvDisplay-lib) + This eliminates wrong colors due to the shifting affecting the chroma components too. + +21.03.2017 2.19.0 + NEW FIRMWARE: + - Firmware version 2.19.711.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - When not using ANY of the AOI affecting features 'OffsetX' and 'OffsetY' can + be modified at runtime when streaming with an activated sequencer now. + - mvBlueCOUGAR-XD204(a/a12/b)G/C, mvBlueFOX3-2024(a)G/C: DecimationVertical can be + used separate from BinningHorizontal or DecimationHorizontal. + Bugs Fixed: + - mvBlueFOX3: Camera could crash if USB connection was disconnected and reconnected + while the camera was in standby mode. + - Changing area dimensions in mvMultiAreaMode or switching off mvMultiAreaMode led + to corrupt images. + - 'mvAreaEnable' as it affects the 'PayloadSize' must become read-only when + 'TLParamsLocked' is set. + - 'mvMultiAreaMode' did not specify the 'streamable' attribute. + - Selecting zero areas in multi-area mode crashed the camera under some + conditions. + - mvBlueCOUGAR-X(D): SequencerMode: Wrong exposure times could occur when using + very small exposure times. + - GEV test packets are send now even if the host application did not specify the + "don't fragment" bit in the SCPS register. + - mvBlueCOUGAR-X1010C, mvBlueFOX-1100C: ReverseX led to wrong colors. + - mvBlueCOUGAR-XD204(a/a12/b)G/C, mvBlueFOX3-2024(a)G/C: DecimationVertical could + not be configured correctly in combination with BinningHorizontal. + + CHANGED BEHAVIOUR: + - Some function have been declared deprecated: (mvDeviceManager.h) + - OBJ_IsSettingAvailable, use DMR_IsSettingAvailable instead. + - OBJ_DeleteSetting, use DMR_DeleteSetting instead. + + UPDATES: + - When running in chunk mode with the 'Image' chunk disabled the driver will use less (mvGenTLConsumer-lib) + memory now. + - Using mvMultiAreaMode of the camera can lead to corrupt images unless updating + firmware to 2.19.xxx.x or greater. + + NEW FEATURES: + - Initial version of the 'Multi AOI' wizard added. (wxPropView) + - Added new command line parameters to enable/disable the filter driver on one or (mvGigEConfigure) + multiple network interfaces. See tool output window for details. + - Added new command line parameter to configure whether the NDIS filter driver shall (mvGenTL_Acquire*.msi) + be installed automatically or not. See 'Installation from private setup routines' and + search for 'GEV_NDIS_DRIVER_INSTALL' for details. + - Whenever a new log-file is created (or and old one is overwritten) the previous file (all shipped packages) + will be moved to . So now the log-output of the last 2 sessions of + mvIMPACT Acquire will be available. + - Added 'mvLensCalibrationEnable' property to + mvIMPACT::acquire::GenICam::AcquisitionControl (C++) and (mvIMPACT_acquire.h) + mv.impact.acquire.GenICam.AcquisitionControl (.NET) (mv.impact.acquire.dll) + - 'SequencerSetStart' can now be explicitly set in the sequencer wizard. (wxPropView) + - Capture settings can be stored in RAM now. See description of the function (all shipped packages) + 'saveCurrentSettingOnStack' of the FunctionInterface class for one way of using this. + - New functions added to API: + - C API: DMR_IsSettingAvailable, DMR_DeleteSetting (mvDeviceManager-lib) + - C++ API: mvIMPACT::acquire::FunctionInterface got the following new member (mvIMPACT_acquire.h) + functions: deleteSettingFromStack, deleteSetting, isSettingAvailable, + loadSettingFromStack, loadAndDeleteSettingFromStack, saveCurrentSettingOnStack. + - .NET API: mv.impact.acquire.FunctionInterface got the following new member (mv.impact.acquire.dll) + functions: deleteSettingFromStack, deleteSetting, isSettingAvailable, + loadSettingFromStack, loadAndDeleteSettingFromStack, saveCurrentSettingOnStack. + - New command line parameter added: 'fullscreen' or 'fs'. (wxPropView) + + BUGS FIXED: + - Running the ColorTwist filter on Linux with RGB planar formats could result in (all shipped Linux packages) + crashes. + (Bug introduced in version 2.13.6) + - On some occasions when a mvBlueFOX camera would come out of the powered down state (mvBlueFOX-lib) + the driver would fail to acquire images. + - Linux installer scripts now take unused memory into account before spawning multiple (all shipped Linux packages) + threads for parallel compilation of mv sources during installation. This eliminates + potential hangs during installation of MATRIX VISION Linux drivers due to lack of + free memory on the target platform. + - Starting the acquisition did reset the current scroll position of the display window (wxPropView) + to the left upper corner of the image. + - When pressing 'Cancel' in the 'Quick Setup' wizard, the exposure time would be set (wxPropView) + equal to the AutoExposureUpperLimit, instead of it's default value on some occasions. + - Potential crash when closing the device properties dialog from a DirectShow (DirectShow_acquire.ax) + application. + +09.02.2017 2.18.3 + NEW FIRMWARE: + - Firmware version 2.18.651.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3-2024(a)G/C, mvBlueFOX3-2032(a)G/C, mvBlueFOX3-2051(a)G/C, + mvBlueFOX3-2089G/C, mvBlueFOX3-2124G/C, mvBlueCOUGAR-X(D)104d/f/h/iG/C, + mvBlueCOUGAR-X(D)105a/bG/C, mvBlueCOUGAR-X109bG/C, mvBlueCOUGAR-X1012bG/C: + Multi area mode implemented as described in the respective sensor specification. + Changed behaviour: + - mvBlueFOX3-2032(a)G/C, mvBlueFOX3-2051(a)G/C, mvBlueFOX3-2089(a)G/C, + mvBlueFOX3-2124(a)G/C, mvBlueCOUGAR-X(D)104h/iG/C, mvBlueCOUGAR-X(D)105a/bG/C, + mvBlueCOUGAR-X(D)109bG/C, mvBlueCOUGAR-X(D)1012bG/C: Increments for Height and + OffsetY increased to 4. + Bugs Fixed: + - mvBlueFOX3 (all models): cameras did not start correctly if the USB connection + was disconnected and reconnected while the camera was in standby; this could + also happen if the host was switched off and on again while an externally + powered camera was in standby mode. + + UPDATES: + - Adapted firmware update procedure to new product naming scheme. (mvDeviceConfigure) + + NEW FEATURES: + - New properties published in API: + C++: mvIMPACT::acquire::Device::manufacturerSpecificInformation, (mvIMPACT_acquire.h) + mvIMPACT::acquire::SystemSettings::featurePollingEnable, + mvIMPACT::acquire::SystemSettings::featurePollingInterval_ms, + mvIMPACT::acquire::SystemSettings::methodPollingInterval_ms, + mvIMPACT::acquire::SystemSettings::methodPollingMaxRetryCount. + .NET: mv.impact.acquire.Device.manufacturerSpecificInformation, (mv.impact.acquire.dll) + mv.impact.acquire.SystemSettings.featurePollingEnable, + mv.impact.acquire.SystemSettings.featurePollingInterval_ms, + mv.impact.acquire.SystemSettings.methodPollingInterval_ms, + mv.impact.acquire.SystemSettings.methodPollingMaxRetryCount. + + BUGS FIXED: + - Data-streams coming from a GEV 2.x device with 64-bit block ID switched off have not (mvGenTLProducer.cti) + not been decoded correctly when the socket driver was active. + - Legacy 16-bit block ID mode is only used when a GEV 2.x device actually claims to (mvGenTLProducer.cti) + support it. + - It is no longer possible to assign an invalid persistent IPv4 address to a GEV (mvIPConfigure) + device. + +02.02.2017 2.18.2 + NEW FIRMWARE: + - Firmware version 2.17.641.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-X104fG/C, mvBlueCOUGAR-X104iG/C, mvBlueCOUGAR-X105bG/C: + support for extended horizontal and vertical Binning/Decimation up to 16x16 + - mvBlueCOUGAR-X104dG/C, mvBlueCOUGAR-X104fG/C, mvBlueCOUGAR-X105bG/C, + mvBlueCOUGAR-X104iG/C, mvBlueCOUGAR-X1012bG/C, mvBlueCOUGAR-X109bG/C, + mvBlueCOUGAR-XD104dG/C, mvBlueCOUGAR-XD105aG/C, mvBlueCOUGAR-XD104hG/C, + mvBlueCOUGAR-XD1012bG/C, mvBlueCOUGAR-XD109bG/C, mvBlueFOX3-2024G/C, + mvBlueFOX3-2024aG/C, mvBlueFOX3-2051G/C, mvBlueFOX3-2051aG/C, + mvBlueFOX3-2032G/C, mvBlueFOX3-2032aG/C, mvBlueFOX3-2124G/C, + mvBlueFOX3-2124aG/C, mvBlueFOX3-2089G/C, mvBlueFOX3-2089aG/C: + support for OffsetX and OffsetY in sequencer + - mvBlueCOUGAR-X(D), mvBlueFOX3: Added support for the 'chunk layout id' + feature. This update requires mvIMPACT Acquire 2.18.1 or greater! + - mvBlueCOUGAR-X(D): Added support for 'ExtendedChunk' mode. This update + requires mvIMPACT Acquire 2.18.1 or greater! + Changed behaviour: + - mvBlueFOX3: When the image itself is not transferred in chunk mode the + payload type will be 'Chunk' not 'Image Extended Chunk' now. + - All features that affect the payload size can no longer be disabled via + 'SequencerFeatureEnable'. So if the sequencer is used, all these properties + are always part of the sequencer sets. + Bugs Fixed: + - When the sequencer was running the exposure time value was sometimes + taken from the stored sequencer set even if + 'SequencerFeatureEnable[SequencerFeatureSelector]' for 'ExposureTime' was set + to false. + - mvBlueFOX3-1020aG/C: Frame rate was halved for special AOI and exposure time + settings. + + CHANGED BEHAVIOUR: + - The 'mvIMPACT_AcquireExecutablesPrerequisites' merge module became a central (all shipped MSI based packages) + requirement for all installations. As a consequence it will always be installed now. + This will make redistributing custom installations in need of the mvDisplay-lib much + easier but will not affect others. + + UPDATES: + - Improved execution speed for GenICam property function calls. Previous versions did (mvGenTLConsumer-lib) + sometimes read features selected by a selector when changing the selector value even + if the application never accessed the selected features. + + NEW FEATURES: + - The settings of all devices currently opened in wxPropView will be added to the (wxPropView) + ZIP-archive containing the log-files now. + + BUGS FIXED: + - Sometimes 'mvBlueFOX-MLC202bx' and 'mvBlueFOX-MLC202dx' devices did not start (mvBlueFOX-lib) + properly on Windows 10. As a result no images could be acquired even though + communication with the sensor does work properly. + - In Linux systems, under some circumstances a libusb segmentation fault could occur. (mvGenTLProducer.cti) + (Bug introduced in version 2.17.3) + - When a 'SequencerFeatureEnable' property was read-only the sequencer wizard could (wxPropView) + crash. + - Fixed an issue where the property grid did not receive the focus when expanding or (wxPropView) + collapsing items in the tree. As a result using the scrollwheel of the mouse did not + scroll within the tree but e.g. did select another device + - The sequencer wizard did not dynamically respond to changes in the properties thus (wxPropView) + e.g. changing 'BinningHorizontal' did not automatically update the limits for + 'Width'. + +20.01.2017 2.18.1 + NEW FIRMWARE: + - Firmware version 2.16.624.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-XD104dG/C, mvBlueCOUGAR-XD104hG/C, mvBlueCOUGAR-XD105aG/C, + mvBlueCOUGAR-XD109bG/C, mvBlueCOUGAR-XD1012bG/C: + Added Support for Vertical Binning(SUM)/Decimation(AVERAGE) + - Added BinningHorizontalMode, BinningVerticalMode, DecimationHorizontalMode and + DecimationVerticalMode properties. + Changed behaviour: + - mvBlueFOX3-1031C, mvBlueFOX3-1100G/C: + For compatibility reasons: AcquisitionFrameRate is not used in trigger mode. + Bugs Fixed: + - 'SequencerMode' becomes read-only now when streaming is active. + - mvBlueFOX3: AcquisitionFrameRate was not handled correctly when using UserSets. + + UPDATES: + - The GenTL producer is now fully compliant with the current GenTL validation (mvGenTLProducer.cti) + framework. + - The DirectShow interface related header files will be installed by default now. (all shipped MSI based packages) + - When using the merge modules supporting Windows 10 no longer needs special treatment. (all shipped MSI based packages) + - Improved performance when dealing with chunk data delivered by devices supporting the (mvGenTLConsumer-lib) + chunk layout ID feature. + + NEW FEATURES: + - Multiple display windows can be created and deleted dynamically now(see (wxPropView) + 'Settings->Image Display->Configure Image Display Count'). The sequencer wizard has + an 'Auto-Assign Displays To Sets' button now. + - Added new C# example: SmartFrameRecall. (all shipped MSI based packages) + - Added new functions to 'mv.impact.acquire.GenICam.CustomCommandGenerator' and + 'mvIMPACT::acquire::GenICam::CustomCommandGenerator' that allow to send multiple + smart frame recall transmission requests in a single command. + - 'Feature vs. Time' plot added to the analysis section in the lower right side of the (wxPropView) + screen. + + BUGS FIXED: + - The installation of the serial port driver on Windows Vista - Windows 10 was broken (mvHYPERION-x86_64-*.msi) + on 64 platforms. + (Bug introduced in version 2.18.0) + - The 32-bit installation for mvBlueFOX, mvSIGMA and mvTITAN drivers on Windows 10 (mvBlueFOX-x86-*.msi) + did not install the Microsoft signed driver. (mvTITAN_mvGAMMA-x86-*.msi) + (mvDELTA_mvSIGMA-x86-*.msi) + - Potential crash when using the temporal noise histogram in full AOI mode when image (wxPropView) + sizes did change. + - Sometimes 'bind' requests to the socket dealing with the GEV streaming data could (mvGenTLProducer.cti) + fail. + - The recording will only stop early in low memory conditions when the sequence to (wxPropView) + record is larger than the number of available request objects, thus when the requests + need to be copied by the application. + - The X and Y offset was not taken into account when working with DirectShow. (DirectShow_acquire.ax) + (mvGenTLConsumer-lib) + - mvBlueCOUGAR-X devices with firmware revisions smaller than 1.5.75.0 could not be (mvGenTLConsumer-lib) + initialized in 'DeviceSpecific' interface layout any more. + (Bug introduced in version 2.15.1) + - When disconnecting a U3V device supporting events on Windows sometimes the (mvGenTLProducer.cti) + internal event thread did not properly terminate but did generate lots of + 'An unexpected system error did occur: 0x0000001f(31)' errors. + - Potential crash when modifying properties while 'SystemSettings/FeaturePollingEnable' (mvGenTLConsumer-lib) + was active and a device had a lot of polling times defined in its XML file. + - For properties specifying the 'cfAllowValueCombinations' flag it was no longer (wxPropView) + possible to select no option after selecting at least one for the first time. + (Bug introduced in version 2.17.0) + +13.12.2016 2.18.0 + NEW FIRMWARE: + - Firmware version 2.15.578.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-XD104G/C, mvBlueCOUGAR-XD104aG/C, mvBlueCOUGAR-XD104a12G, + mvBlueCOUGAR-XD104bG/C, mvBlueCOUGAR-XD104baG/C, mvBlueCOUGAR-XD104dG/C, + mvBlueCOUGAR-XD104hG/C, mvBlueCOUGAR-XD105aG/C, mvBlueCOUGAR-XD109bG/C, + mvBlueCOUGAR-XD1012bG/C: SmartFrameRecall feature implemented. + - mvBlueFOX3, mvBlueCOUGAR-X(D): support for custom command that allows to modify + gain, exposure and counter duration in a sequencer set while the sequencer is + running + Changed behaviour: + - mvBlueCOUGAR-XD126G/C, mvBlueCOUGAR-XD129G/C: + DecimationVertical is only available for SensorTaps = Two. + Bugs Fixed: + - BF3-2xx: Using special sequencer settings (small AOIs and Binning/Decimation) + could lead to limited bandwidth. + - DeviceLinkHeartbeatMode was inverted. Switching it off turned it on and vice + versa. + - mvBlueFOX-1013G/C, mvBlueFOX-1020G/C, mvBlueFOX-1020aG/C, mvBlueCOUGAR-X102eG/C, + mvBlueCOUGAR-X104eG/C: Some cameras have wrong pixels in one column. + + UPDATES: + - Internal migration to Doxygen 1.8.12. + + NEW FEATURES: + - Kernel drivers are signed by the Windows Hardware Developer Center Dashboard portal (all shipped MSI based packages) + for Windows 10 installations now. Since Windows 10 version 1607 a fresh Windows + installation will no longer accept other signatures. + - On Linux systems, GEV cameras with bad network configurations now appear on the (mvIPConfigure) + device list. + - New header file added to C/C++ interface: mvCustomCommandDataTypes.h (all shipped packages) + - New header file added to C++ interface: mvIMPACT_acquire_GenICam_CustomCommands.h. (all shipped packages) + This file adds the class 'mvIMPACT::acquire::GenICam::CustomCommandGenerator' to the + public interface. + - Class 'mv.impact.acquire.GenICam.CustomCommandGenerator' published. (mv.impact.acquire.dll) + - New samples added to all packages: 'GenICamSmartFrameRecallUsage' and (all shipped packages) + 'GenICamSequencerParameterChangeAtRuntime'. + - Major Sequencer Wizard overhaul, with new capabilities and new user interface. (wxPropView) + + BUGS FIXED: + - On some systems resetting the camera during Auto-assigning the DHCP option caused (mvIPConfigure) + the application to misbehave. + (Bug introduced in version 2.17.3) + - Devices sending an invalid value for 'valid_chunk_data' in their trailer packet could (mvGenTLProducer.cti) + cause crashes. + - When a sequence has been recorded displaying the very last image could cause a crash (wxPropView) + (Bug introduced in version 2.17.3) + - Some of the values stored for the settings of the analysis controls where properly (wxPropView) + read back when restarting the application but haven't been applied. + - Shortcuts to various examples applications created in the programs menu under (all shipped MSI based packages) + 'Programs -> MATRIX VISION -> mvIMPACT Acquire -> Examples' did point to incorrect + targets. + (Bug introduced in version 2.12.3) + - Drivers can be installed on Windows Vista and older again. (all shipped MSI based packages) + (Bug introduced in version 2.16.0) + - Commands 'DefectivePixelReadFromDevice' and 'DefectivePixelWriteToDevice' will only (all shipped packages) + visible now when the device supports loading and storing of defective pixel data in + non-volatile memory. + - Defective pixel data is correctly read back from a setting into the properties (all shipped packages) + 'DefectivePixelOffsetX' and 'DefectivePixelOffsetY' now. + - For certain sensors it was possible to set 'Aoi/X' or 'Aoi/Y' to a value that in (mvBlueFOX-lib) + combination with 'Aoi/W' or 'Aoi/H' did result in an AOI too small finally resulting + in a crash. + - Calling 'OBJ_DeleteSetting' for a setting that does not exist OR for a setting for (mvPropHandling-lib) + which the current user has no sufficient access rights returns an error now. + - When running on Windows 10 the log messages did report Windows 8.1. (all shipped MSI based packages) + +01.11.2016 2.17.3 + NEW FIRMWARE: + - Firmware version 2.14.507.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Sequencer settings are saved in UserSets. + - mvBlueCOUGAR-X104fG/C, mvBlueCOUGAR-X104iG/C, mvBlueCOUGAR-X105bG/C, + mvBlueCOUGAR-X109bG/C, mvBlueCOUGAR-X1012bG/C, mvBlueCOUGAR-XD104dG/C, + mvBlueCOUGAR-XD104hG/C, mvBlueCOUGAR-XD105aG/C, mvBlueCOUGAR-XD109bG/C, + mvBlueCOUGAR-XD1012bG/C: + Extended sequencer mode: Gain and Binning/Decimation + - mvBlueFOX3-2xx: Extended sequencer mode: Gain and Binning/Decimation + - mvBlueCOUGAR-X(D)x2xxG/C (cameras with CCD sensors): + Extended sequencer mode: Gain + Changed behaviour: + - Binning and Decimation Properties now use the 'ValidValueSet' attribute. + - If a sensor specific color correction matrix is available it will be used to + initialize the color transformation control features + Bugs Fixed: + - mvGainAutoLowerLimit could not set different from 0. + + UPDATES: + - Improved firmware update for GEV devices. Added nicer progress dialogues providing (mvDeviceConfigure) + more feedback about the current status of the update process. + - Internal migration to IPP 2017. (all shipped packages) + + CHANGED BEHAVIOUR: + - Removed toolbar for page selection from property grid. The 'Driver' properties are (wxPropView) + accessible under the 'Device Driver' category from the main property grid now. + - Changing the 'CPU Idle States' is no longer available starting from Windows 8 as the (mvDeviceConfigure) + underlying API is no longer supported by the operating system. + + NEW FEATURES: + - 'ValidValueSet' nodes in a GenICam XML file will result in a translation dictionary (mvGenTLConsumer-lib) + containing all these values being attached to that property now. As a result these + properties will automatically be displayed with a drop down box in wxPropView and + similar tools. + - mvIPConfigure now offers various ways of automatically assigning valid network (mvIPConfigure) + configurations to detected devices that are configured incorrectly. + - Support for Hotplugging of U3V devices on Linux systems. (mvGenTLProducer.cti) + - mvIMPACT::acquire::Request::getChunkGainCount, (mvIMPACT_acquire.h) + mvIMPACT::acquire::Request::getChunkGain and + mvIMPACT::acquire::Request::chunkmvCustomIdentifier added. + - mv.impact.acquire.Request.chunkGainCount, (mv.impact.acquire.dll) + mv.impact.acquire.Request.getChunkGain and + mv.impact.acquire.Request.chunkmvCustomIdentifier added. + - The wxPropView recording sequence size is no longer limited to the number of request (wxPropView) + objects allocated for the selected device driver instance. If the number of frames to + record is higher than the number of requests the images will be copied and stored + in RAM. + + BUGS FIXED: + - When closing one of the GUI applications in 'maximized' mode the next time the (all wxWidgets based applications) + application did start parts of the application have been hidden by the Windows + taskbar. + - When one of the GUI applications was moved out of the left side of the screen its (all wxWidgets based applications) + x-position was not correctly restored upon the next start + - The splash screen is displayed at least for one second now. (all wxWidgets based applications) + - Spin-editors will accept a ',' as a floating point value separator again. (wxPropView) + (Bug introduced in version 2.17.0) + - Calling 'mvDispSetImage' with mono/grey-scale data and a pitch not divisible by 4 (mvDisplay-lib) + results in a correct display now. + Missing mv.impact.acquire.SystemSettings.imageProcessingMode property added(.NET) (mv.impact.acquire.dll) + - When the currently selected property in the property tree became read-only it still (wxPropView) + seemed to be writeable and vice versa. + - The *.mvlog files contained in the automatically generated ZIP-file had their (wxPropView) + original content overwritten by one line only, containing the path of the logfile + itself. + - On Linux systems with more than one network adapter the link speed of the last one (mvIPConfigure) + inquired was shown as the link speed for all of them. + - On Linux systems updating the Firmware of GEV devices could sometimes lead to (mvDeviceConfigure) + a segmentation fault. + +21.09.2016 2.17.2 + NEW FIRMWARE: + - Firmware version 2.13.460.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3-1031C : FrameStart and FrameBurstActive trigger are available. + - mvBlueFOX3-1100G/C, mvBlueCOUGAR-X1010G/C : FrameStart trigger can also be used + with rolling shutter. + - mvBlueFOX3-2124C, mvBlueFOX3-2089C support BinningHorizontal. + Changed behaviour: + - mvBlueFOX3-1100G/C : Enabling FrameStart trigger no longer switch to global reset + mode automatically. + - mvBlueFOX3-2024aG/C, mvBlueCOUGAR-X104fG/C: Minimal exposure time is now only + 10 usec. + Bugs Fixed: + - mvBlueFOX3 devices at certain temperatures sometimes did not boot correctly. + - mvBlueFOX3-2024G/C: BalanceWhiteAuto, GainAuto and ExposureAuto features no + longer reduce the maximum frame rate if activated. + + CHANGED BEHAVIOUR: + - Restored old (pre 2.17.0) bit shift behaviour. (mvDisplay-lib) + - Added a check for the presence of KB3033929 which is needed on Windows 7 and (all shipped MSI based packages) + earlier for the processing of SHA256 signatures introduced in version 2.16.0. + + NEW FEATURES: + - ARMv8-a (Aarch64) support added for mvGenTL_Acquire and mvBlueFOX. This will add (mvBlueFOX-ARM64_gnu-*.tgz) + support for various Aarch64 platforms running at least ubuntu 14.04 or a compatible (mvGenTL_Acquire-ARM64_gnu-*.tgz ) + system. + - For Windows 8 and greater the 'FullScreen' option in wxPropView became available. (wxPropView) + The image will be rendered using Direct3D 9 now. + + BUGS FIXED: + - Splashscreen of GUI tools is now displayed correctly on Linux systems. Furthermore on (wxPropView) + both linux and windows systems it is no longer 'always-on-top', thus no longer hides (mvDeviceConfigure) + clickable dialog boxes. (mvIPConfigure) + - Fixed potential crash when opening the Sequencer Wizard for GenICam devices. (wxPropView) + - Fixed potential crash when using the 'Send Logfiles to MV-Support' functionality. (wxPropView) + - Fixed an issue where the property grid did not always receive the focus when clicking (wxPropView) + on it. As a result e.g. clicking on the property grid after selecting a device using + the scrollwheel of the mouse did not scroll within the tree but did select another + device. + - Switching to 'FullScreen' mode on Windows 7 or smaller or changing the setting (wxPropView) + 'Settings -> Property Grid -> Create Editors With Sliders' no longer raises an + assertion. + (Bug introduced in version 2.17.0) + +30.08.2016 2.17.1 + NEW FIRMWARE: + - Firmware version 2.12.426.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-X(D) (res. > 1600x1200): Storing of defective pixel positions + possible. + - New cameras: mvBlueFOX3-2124aG/C, mvBlueFOX3-2089aG/C, + mvBlueCOUGAR-X1012bG/C, mvBlueCOUGAR-X109bG/C, + mvBlueCOUGAR-XD1012bG/C, mvBlueCOUGAR-XD109bG/C + - mvBlueFOX3: LED can be switched off + - mvBlueFOX3: camera can automatically switch to standby if inactive + Restrictions: + - mvBlueFOX3-2024aG/C, mvBlueCOUGAR-X104fG/C: Minimal exposure time increased to + 30 usec. + Changed behaviour: + - BF3-2xx: Enhanced sequencer mode: Sequencered images with BinningHorizontal + and/or BinningVertical may now be captured at higher frame rates if sensor + supports this increase. + - mvBlueFOX3: settings (except LUT values) are restored after standby + Bugs Fixed: + - mvBlueFOX3-2xxx devices at certain temperatures sometimes did not boot + correctly. + + UPDATES: + - Incorrectly configured GigE Vision devices (no matching IPv4 address or netmask) do (mvGenTLProducer.cti) + no longer delay 'updateDeviceList' calls. As a result starting the applications like + wxPropView, mvIPConfigure and mvDeviceConfigure will start much faster now. + + CHANGED BEHAVIOUR: + - Changed name of NDIS 6.x based filter driver files from 'mvGigECapture.*' to (mvGigECapture2.sys, version 3.0.2.56) + 'mvGigECapture2.*' in order to allow easier switching between the NDIS 5.x and the + NDIS 6.x drivers. + + NEW FEATURES: + - Added 'mvDefectivePixelCorrectionControl' class to GenICam namespace (mvIMPACT_acquire.h) + (mv.impact.acquire.display.dll) + - Added properties 'DefectivePixelOffsetX' and 'DefectivePixelOffsetY' and commands (mvIMPACT_acquire.h) + 'DefectivePixelReadFromDevice' and 'DefectivePixelWriteToDevice' to class (mv.impact.acquire.display.dll) + 'ImageProcessing. + - Added 'mvDeviceStatusLEDEnable', 'mvDeviceStandbyTimeoutEnable' and (mvIMPACT_acquire.h) + 'mvDeviceStandbyTimeout' to class 'GenICam::DeviceControl' (mv.impact.acquire.display.dll) + - New color correction matrices added: 'cticmmBlueCOUGAR_Xx09bC_WPPLS', (all shipped packages) + 'cticmmBlueCOUGAR_Xx012bC_WPPLS', 'cticmmBlueCOUGAR_XDx09bC_WPPLS', + 'cticmmBlueCOUGAR_XDx012bC_WPPLS', 'cticmmBlueFOX3_x124aC_WPPLS'. They will be used + by mvBlueCOUGAR-X_x09bC, mvBlueCOUGAR-X_x012bC, mvBlueCOUGAR-XDx09bC, + mvBlueCOUGAR-XDx012bC and mvBlueFOX3_x124aC devices respectively. + - MATRIX VISION GenICam devices supporting the 'mvDeviceStandbyTimeout' feature will (mvGenTLConsumer-lib) + exchange heartbeat messages with the device when this feature is active to prevent + the device from moving into power down mode while the application is running. + + BUGS FIXED: + - Changing features that have impact on the value of 'PayloadSize' AFTER queuing at (mvGenTLConsumer-lib) + least one buffer and BEFORE calling 'acquisitionStart' in chunk mode could result + in buffers being returned to the application with an incorrect 'Request::imageSize' + value (just the size of the image data without the additional chunk data space was + reported then). + - Unplugging or rebooting a U3V device with event support with an open driver instance (mvGenTLProducer.cti) + could cause a handle leak on Windows. + - Potential blue screen (BSOD) when binding the filter driver didn't succeed. (mvGigECapture2.sys, version 3.0.2.56) + - Removing the GigE Vision filter driver when uninstalling the mvIMPACT Acquire package (mvGenTL_Acquire*.msi) + did not work. + (Bug introduced in version 2.6.3) + - downgrading the GigE Vision filter driver from the NDIS 6.x back to the NDIS 5.x (mvGigECapture2.sys, version 3.0.2.56) + version did not work properly. (mvGenTLProducer.cti) + (mvGigEConfigure) + +04.08.2016 2.17.0 + NEW FIRMWARE: + - Firmware version 2.11.383.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3-1031C: HDR mode can be enabled + - New features published: 'mvU3VLNKErrorCount' and 'mvU3VPHYErrorCount'. Both + features can be found in the 'TransportLayer' category. They provide information + about the quality of the USB connection. + Changed behaviour: + - Deprecated some features with respect to the latest SFNC 2.3: + 'GevGGVCPPendingTimeout' (use 'DeviceLinkCommandTimeout' instead), + 'GevGVCPHeartbeatDisable'(use 'DeviceLinkHeartbeatMode' instead) + 'mvAcquisitionFrameRateEnable' (use 'AcquisitionFrameRateEnable' instead) + Bugs Fixed: + - BF3-2xx: BF3-2xxx: The first image after an acquisition start was sometimes + still using the old exposure time. + - BCX: Sometimes the camera could crash while streaming to a multicast address. + + UPDATES: + - Migration to wxWidgets 3.x. All wxWidgets based applications are built using (all shipped packages) + wxWidgets 3.x now. Apart from wxPropView all applications can still be built using + at least wxWidgets 2.6. However wxPropView uses the wxPropertyGrid classes which have + been added to wxWidgets 3.0 thus here at least this version is a hard requirement. + The old wxPropGrid is no longer shipped with mvIMPACT Acquire. + - Migration to an NDIS 6.x based GEV filter driver on Windows Vista or newer. This (mvGigECapture.sys, version 3.0.1.55) + new filter driver can be used on Windows 10 as well now. The NDIS 5.x based driver (mvGigECapture.sys, version 2.2.0.54) + will still be installed on older Windows systems not supporting the NDIS 6.x + framework. + - Color correction matrices 'cticmmBlueCOUGAR_XDx04dC_WPPLS', (all shipped packages) + 'cticmmBlueCOUGAR_Xx04fC_WPPLS', 'cticmmBlueFOX3_x024C_WPPLS', + 'cticmmBlueFOX3_x024aC_WPPLS', 'cticmmBlueCOUGAR_Xx04iC_WPPLS', + 'cticmmBlueCOUGAR_Xx05bC_WPPLS', 'cticmmBlueCOUGAR_XDx04hC_WPPLS', + 'cticmmBlueCOUGAR_XDx05aC_WPPLS', 'cticmmBlueFOX3_x032C_WPPLS', + 'cticmmBlueFOX3_x032aC_WPPLS', 'cticmmBlueFOX3_x051C_WPPLS', + 'cticmmBlueFOX3_x051aC_WPPLS', 'cticmmBlueFOX3_x124C_WPPLS', + 'cticmmBlueFOX3_x089C_WPPLS' and 'cticmmBlueFOX3_x089aC_WPPLS' updated. + + CHANGED BEHAVIOUR: + - Bit shifting images in wxPropView with multi-byte pixel formats now displays the (mvDisplay-lib) + actual bit of the pixels. This might result in solarize effects. + + NEW FEATURES: + - Added support for pixel format RGB888Planar. (all shipped packages) + - A new CameraLink configuration with 16bits per pixel and 2 pixels per clock that is (mvHYPERION-lib) + not included in the CameraLink Standard is now supported. + - 'Copy To Clipboard' and 'Set From Clipboard' option added to the property grids (wxPropView) + context menu. + - ContinuousCaptureToUserMemory can be built with OpenCV support now and has been added (all shipped packages) + to the Linux installation packages as well. + - New constructors added to mvIMPACT::acquire::GenICam::SystemModule (mvDeviceManager-lib) + and mvIMPACT::acquire::GenICam::InterfaceModule. They can be used without any valid (mvIMPACT_acquire.h) + pointer to a device. + - wxPropView and mvDeviceConfigure will warn on incorrectly set up GenICam devices when (wxPropView) + trying to open one of these devices. In previous versions these devices could only be (mvDeviceConfigure) + seen using mvIPConfigure which is not the first application you would normally + launch. + - New property 'StatusLEDEnable' published under 'SystemSettings' for mvBlueFOX (mvBlueFOX-lib) + devices. + - New test image format added: 'vdtmMovingRGB888PlanarImage'. (mvVirtualDevice-lib) + + BUGS FIXED: + - Once the property 'RequestCount' has been modified by an application it did no longer (mvPropHandling-lib) + turn read-only during acquisition for GenICam devices. + - 'FunctionInterface::imageRequestReset' did not always return when using infinite (mvGenTLProducer.cti) + buffer timeouts in triggered mode with no trigger when calling functions in the + following sequence: imageRequestSingle, acquisitionStart, imageRequestSingle, + imageRequestWaitFor, imageRequestReset. + - 'FunctionInterface::imageRequestReset' did not always return when using (mvGenTLConsumer-lib) + acquisitionStartStopBehaviour == assbUser and at least 2 threads in which one thread + constantly calls 'imageRequestSingle' while the other calls 'acquisitionStop' and + 'imageRequestReset'. + - Potential crash when calling 'updateDeviceList' after a failed attempt to open a (mvGenTLConsumer-lib) + GenICam compliant device. + (Bug introduced in version 2.16.0) + +17.06.2016 2.16.1 + NEW FIRMWARE: + - Firmware version 2.10.326.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - BF3-2xx: Extended sequencer mode: Binning can be used. + - Support BCX-104iG/C-POE cameras. + - mvBlueCOUGAR-X104fG/C, mvBlueCOUGAR-XD104dG/C, mvBlueCOUGAR-XD104hG/C, + mvBlueCOUGAR-XD105aG/C, mvBlueCOUGAR-X104iG/C, mvBlueCOUGAR-X105bG/C, + mvBlueFOX3-2024G/C, mvBlueFOX3-2024aG/C, mvBlueFOX3-2032G/C, + mvBlueFOX3-2032aG/C, mvBlueFOX3-2051G/C, mvBlueFOX3-2089G/C, + mvBlueFOX3-2124G/C: + BlackLevelAuto can be set to 'Off'. + Bugs Fixed: + - BF3-2xx: fixed bug that could lead to white blinking LED on USB errors + - BF3-1xx: fixed bug in FrameAverageControl that produced corrupted images + when width or height was changed. + + UPDATES: + - Migration to version 3.0.1 of the GenApi runtime. (all shipped packages for GenICam compliant devices) + + NEW FEATURES: + - The 'GenICam' namespace now contains the full SFNC 2.3 feature set. (mvIMPACT_acquire_GenICam.h) + (mv.impact.acquire.dll) + +19.05.2016 2.16.0 + NEW FIRMWARE: + - Firmware version 2.9.284.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Added SHA1 hash to the GenICam file name for GEV devices in order + to speed up device initialisation time by avoiding redundant file downloads. + - New cameras: mvBlueFOX3-2089G/C + Changed behaviour: + - Removed all impl-bits from the chunk data to allow offline processing of + chunk buffers. + - mvBlueFOX3 devices will automatically change their 'mvDevicePowerMode' property + back to 'mvActive' when opening the a device currently in standby mode. + Bugs Fixed: + - mvBlueFOX3-2xxx: Some exposure times led to lower frame rates than expected. + - Sometimes, after booting host and a mvBlueCOUGAR-XD simultaneously (2 links), + opening the device will fail. + - 'SequencerSetNext' no longer requires an explicit call to 'SequencerSetSave' + in order to become effective. + + UPDATES: + - *.msi and *.cat files are now signed with a SHA-256 certificate and is timestamped by (all shipped MSI based packages) + a SHA-1 timestamp server. All other files will be dual signed with SHA-1 and SHA-256 + signatures as since 01.01.2016 tools like e.g. Internet explorer will issue a + warning otherwise. This may result in the 'Always trust software from MATRIX VISION' + question to be displayed again. This may require KB3033929 and KB2921916 to be + installed on Windows 7 and Windows server 2008. Please have a look in the 'Known + issues' section of the mvIMPACT Acquire manual. + - Initialisation speed for GenICam compliant devices improved. Opening a MATRIX VISION (mvGenTLProducer) + GEV device is up to 350ms faster now when the GenICam file has been downloaded for (mvGenTLConsumer) + the first time(requires a firmware update). For U3V devices supporting the SHA1 hash + the initialisation is up to 450ms faster now. + - Import speed for large LUTs from *.csv-files improved. (wxPropView) + - The display update frame rate can be configured via 'Settings -> Set Update (wxPropView) + Frequency' now. This fixes the problem of a freezing GUI or missing status bar + updates at high frame rates. + - The 'Detailed Feature Information' dialogue contains informations about the binary (wxPropView) + data size and the max. binary data size for properties specifying the + 'cfContainsBinaryData' flag now. + - 'Show Feature Change Time Consumption' option added to 'Settings -> Property Grid'. (wxPropView) + - Execution speed from and to 'ibpfYUV411_UYYVYY_Packed' format improved. (all shipped packages) + - The capture pin property dialogue will automatically expand the device feature tree (DirectShow_acquire.ax) + now as wxPropView does it when opening a device. + - mvHYPERION Linux kernel driver and the respective installers now support kernel 4.0. (low level mvHYPERION driver, Linux) + + CHANGED BEHAVIOUR: + - Interface layout 'dilGeneric' has been removed from the public interface. It has been (all shipped packages) + declared deprecated for almost 4 years now. This might break existing binaries + and will require changes in the source during rebuilds. Systems depending on the + generic interface layout will NO LONGER WORK starting from this version of mvIMPACT + Acquire. Please update your code as described in the documentation. + - When opening a GenICam device, an AcquisitionStop command will now be sent, just in (mvGenTLConsumer-lib) + case the previous process using the device crashed unexpectedly. + + NEW FEATURES: + - Automatically joining multicast groups of GEV devices can be disabled now via the (mvGenTLProducer.cti) + property mvAutoJoinMulticastGroups. + - New color correction matrices added: 'cticmmBlueFOX3_x124C_WPPLS', (all shipped packages) + 'cticmmBlueFOX3_x089C_WPPLS' and 'cticmmBlueFOX3_x089aC_WPPLS'. These will be + used by 'mvBlueFOX3_x124C', 'mvBlueFOX3_x089C' and 'mvBlueFOX3_x089aC' devices + respectively. + - Initial version of the 'Sequencer Control' wizard added. For devices running with the (wxPropView) + GenICam interface layout this wizard will allow convenient access to sequencer + control related features. + + BUGS FIXED: + - The 'TapSort' filter for 1Y2 and 2YE data did not re-order the data correctly when (mvTITANfg-lib) + operated in image processing mode 'ipoMinimizeMemoryUsage'. (mvHYPERIONfg-lib) + (mvVirtualDevice-lib) + - 'TLGetInfo' did return 'INFO_DATATYPE_INT32' instead of 'INFO_DATATYPE_UINT32' for (mvGenTLProducer.cti) + the data type query of 'TL_INFO_GENTL_VER_MAJOR' and 'TL_INFO_GENTL_VER_MINOR'. + - Potential crash when running the de-Bayer filter on Linux. (all shipped packages) + - 'imageRequestReset' calls did not return until the current image has been generated (mvVirtualDevice-lib) + completely and the user defined frame delay (FrameDelay_us) did elapse, thus large + frame delays could block an application for a long time. + - Images that had a different resulting AOI than set for the device(e.g. because of an (DirectShow_acquire.ax) + enabled rotation or scaling filter) have been delivered with incorrect width and + height. + - Calling 'FunctionInterface::getCurrentCaptureBufferLayout' when the rotation filter (all shipped packages) + was active did return a width and height than was 1 pixel and line smaller than the + actual resulting image. + - Caching of the GenICam XML files did not work correctly on Linux systems. (mvGenTLProducer.cti) + +08.04.2016 2.15.2 + NEW FIRMWARE: + - Firmware version 2.8.241.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - New camera: mvBlueFOX3-2124G/C (IMX253) + Bugs Fixed: + - Frame rate inconsistencies corrected for mvBlueCOUGAR-X105bG/C, + mvBlueCOUGAR-X104iG/C and mvBlueFOX3-2032aG/C. + + UPDATES: + - Slightly improved execution speed in general. (mvPropHandling-lib) + - Reduced memory footprint in interface layout 'dilGenICam' and 'dilGeneric' by roughly (mvGenTLConsumer-lib) + 64KB/request object. + + NEW FEATURES: + - The display supports zoom factors smaller than 1 up to 0.125 now. (wxPropView) + + BUGS FIXED: + - The function TransportLayerControl.gevGetResultingPacketDelay could return negative (mvIMPACT_acquire_GenICam.h) + values. (mv.impact.acquire.dll) + - Sometimes when an editor in the property grid was selected and then the focus was (wxPropView) + transferred to another control within the application later when clicking on another + property in the property grid the GUI jump back to the feature previously selected. + - Multi-threaded access to library improved. Waiting for error event data while talking (mvGenTLProducer.cti) + to the device in parallel is faster now. + +28.03.2016 2.15.1 + NEW FIRMWARE: + - Firmware version 2.7.221.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Bugs Fixed: + - mvBlueCOUGAR-X1010G/C: Acquisition could stop when changing exposure time. + Bug introduced in version 2.6.148.0. + - mvBlueFOX3-2032G, mvBlueFOX3-2051G: Although mvAcquisitionFrameRateLimitMode = + mvDeviceLinkThroughput more than 380MByte/s were possible, which results in + delayed images. + + UPDATES: + - Improved execution speed of 'PropertyS::readBinary', 'PropertyS::writeBinary' (mvPropHandling-lib) + 'PropertyS::binaryDataBufferSize', 'OBJ_GetBinaryBufferSize', 'OBJ_GetBinary' + and 'OBJ_SetBinary'. + - Slightly improved the initialisation speed for GEV devices by removing some redundant (mvGenTLProducer.cti) + register accesses. + - GEV devices with an incorrect IP setup correctly update some internal registers like (mvGenTLProducer.cti) + current link speed and interface count once the IP configuration has been fixed and + the device has been re-discovered in the current process. + - minizip is no longer used internally. (mvGenTLConsumer-lib) + - Slightly improved heartbeat behaviour for GEV devices. This will result in less (mvGenTLProducer.cti) + network traffic on the control channel. + - Improved performance when dealing with chunk data delivered by devices supporting the (mvGenTLConsumer-lib) + chunk layout ID feature. + + CHANGED BEHAVIOUR: + - The following enumeration values and classes have been removed from the interface (all shipped packages) + 'acquire::cfUserAllocatedMemory', 'acquire::PROPHANDLING_NO_USER_ALLOCATED_MEMORY and + 'acquire::ENoUserAllocatedMemory'. There is NO direct replacement for all these + things, as they haven't been used internally or externally anyway. Simply remove all + references from your code. + - In case a U3V device did not recover from a reset on the control endpoint(e.g. when (mvGenTLProducer.cti) + the device firmware did crash/hang) the driver did hang when the device did continue + to send incorrect ACK-ids. + + NEW FEATURES: + - The user can now select whether shortcuts to certain applications shall be created (all MSI-based shipped packages) + on the desktop or not. + + BUGS FIXED: + - wxPropView on ARM systems correctly displays captured images again. (wxPropView) + (Bug introduced in version 2.14.0) + - Changing the exposure time from a very small value to one slightly larger (e.g. from (mvBlueFOX-lib) + 12 to 21 us for mvBlueFOX-x00w devices could result in a couple of incorrectly + exposed frames. + - Installing any installer that is NOT the mvGenTL_Acquire one without also updating (mvDeviceManager-lib) + updating the mvGenTL_Acquire package did result in GenICam compliant devices being + no longer accessible(Windows only). + (Bug introduced in version 2.15.0) + - Socket driver did not correctly handle GEV 2.x devices streaming in extended block ID (mvGenTLProducer.cti) + mode. + - Multi-threaded access to library improved. E.g. calling 'DSClose' in parallel with (mvGenTLProducer.cti) + 'EventGetData' sometimes did cause crashes. + - Certain large values when written to the AOI width and/or height of the scaler in the (all shipped packages) + 'ImageDestination' list could result in a crash. + - mvDeviceConfigure refused to update the firmware of mvBlueCOUGAR devices when their (mvDeviceConfigure) + 'AcquisitionFrameRate' Property was not visible. + +24.02.2016 2.15.0 + NEW FIRMWARE: + - Firmware version 2.6.180.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Support for new cameras: + - mvBlueCOUGAR-X105bG/C (IMX264) + - mvBlueCOUGAR-X104iG/C (IMX265) + - mvBlueFOX3-2032aG/C (IMX265) + Changed behaviour: + - mvBlueFOX3-*: Increased event timestamp accuracy. + Bugs Fixed: + - mvBlueFOX3: FWUpdate from 2.3 ( to 2.4 or 2.5 ) could result in unbootable + camera, when starting with saved UserSet. + - mvBlueFOX3, mvBlueCOUGAR-X(D): OffsetX and OffsetY appear correctly in the + image leader / image info chunk. + + UPDATES: + - Migration to version 3.0.0 of the GenApi runtime. (all shipped packages for GenICam compliant devices) + - Migration to version 1.5 of the GenICam GenTL spec. (mvGenTLProducer.cti) + (mvGenTLConsumer-lib) + + CHANGED BEHAVIOUR: + - mvDeviceConfigure will reset the 'UserSetDefault' (aka 'UserSetDefaultSelector') to (mvDeviceConfigure) + 'Default' during updates and will only restore the user selected values if the user + selects to persist the user sets during a firmware update. + + BUGS FIXED: + - The x64 version of wxPropView no longer crashes on Windows 8.1 when opening the (wxPropView) + editor for a property containing binary data. This was a bug in wxWidgets that + surfaced when migrating to Visual Studio 2013. + (Bug introduced in version 2.8.0) + - GenICam URL cache is now properly invalidated during firmware updates and/or device (mvDeviceConfigure) + resets. (mvGenTLConsumer-lib) + - Some issues regarding auto and manual IP assignment on Windows XP systems. (mvIPConfigure) + - Configuring IP settings with mvIPConfigure did fail when the GEV camera had been (mvGenTLProducer.cti) + first recognized with an invalid IP address. This happened because some optional GEV + capabilities were not being recognised correctly due to the IP address mismatch. + - The 'Quick Setup' wizard did not always set minimum and maximum Pixelclock correctly. (wxPropView) + +09.02.2016 2.14.3 + NEW FEATURES: + - New color correction matrices added: 'cticmmBlueFOX3_x032aC_WPPLS', + 'cticmmBlueFOX3_x051aC_WPPLS', 'cticmmBlueCOUGAR_Xx04iC_WPPLS'. They will be used by + mvBlueFOX3_x032aC, mvBlueFOX3_x051aC and 'mvBlueCOUGAR-Xx04iC' devices respectively. (all shipped packages) + + BUGS FIXED: + - If working with medium or full CameraLink cameras trigger mode was not working. (low level mvHYPERION driver, Linux) + - Correct error handling when requesting images larger than 512 MB. (low level mvHYPERION driver, Windows, version 2.1.44.52) + +27.01.2016 2.14.2 + NEW FIRMWARE: + - Firmware version 2.5.146.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3-2024G/C: Added frame averager. + Changed behaviour: + - Deprecated SFNC feature made invisible. Introduced their replacements: + - 'DeviceSerialNumber' (Replaces 'DeviceID') + - 'TestPattern' (Replaces 'TestImageSelector') + - 'UserSetDefault' (Replaces 'UserSetDefaultSelector') + - All the 'GevSupported...' features (Replaced already by + 'GevSupportedOptionSelector' and 'GevSupportedOption'. + - mvBlueFOX3-2024G/C, mvBlueFOX3-2051G/C, mvBlueFOX3-2032(a)G/C, + mvBlueCOUGAR-X104dG/C, mvBlueCOUGAR-X104fG/C, mvBlueCOUGAR-X105bG/C, + mvBlueCOUGAR-XD104dG/C, mvBlueCOUGAR-XD105aG/C, mvBlueCOUGAR-XD104hG/C: + changed mapping of luminance LUT on grey cameras from + 'map_10To12' to 'map_12To9' and + changed mapping of red,green and blue LUTs on color cameras from + from 'map_8To12' to 'map_10To9' + Bugs Fixed: + - mvBlueCOUGAR-X104eG/C, mvBlueFOX3-1020G/C, mvBlueFOX3-1020aG/C: + Constant time between trigger and exposure for all exposure times. + - Several mvBlueCOUGAR-X / mvBlueCOUGAR-XD / mvBlueFOX3: + CounterValueAtReset didn't yield the right value + + BUGS FIXED: + - In Linux systems, mknewappl.sh script no longer generates deprecated code. (all shipped Linux packages) + - 'mvIMPACT::acquire::GenICam::ImageFormatControl::mvDigitizationMode' became (mvIMPACT_acquire_GenICam.h) + 'mvIMPACT::acquire::GenICam::ImageFormatControl::mvSensorDigitizationBitDepth' in (mv.impact.acquire.dll) + the public API. The Firmware did use that name anyway, thus the features in the API + did use an incorrect name before thus always have been invalid. + - DMR_ImageRequestReset did not return when a mvHYPERION board was operated in external (mvHYPERION-lib) + triggered mode and there was NO trigger signal on Linux. (low level mvHYPERION driver, Linux) + - Potential blue screen (BSOD) when requesting images larger than 512 MB on Windows. (low level mvHYPERION driver, Windows) + +21.12.2015 2.14.1 + NEW FIRMWARE: + - Firmware version 2.4.100.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed behaviour: + - 'LUTValueAll' is no longer invalidated by 'LUTValue' but now set the 'noCache' + attribute. So now each read to 'LUTValueAll' actually reads data from the + device, but each write to 'LUTValue' no longer automatically reads + 'LUTValueAll' speeding up LUT write operations significantly. + Bugs Fixed: + - mvBlueFOX3: UserSets saved when connected to USB3 weren't available with USB2 and + vice versa. + - mvBlueFOX3: Events do not have to be collected any more, even if they were + requested before. + - mvBlueCOUGAR-X1010G/mvBlueFOX3-1100G: + AutoWhiteBalance to reduce chess board pattern did not work for + DefaultUserSet != Default. + AcquisitionStop at extremely small frame rates caused timeouts. + + UPDATES: + - Slightly improved internal handling for the thread that updates features defining a (mvGenTLConsumer-lib) + polling time in their XML file. + - Slightly improved color correction wizard. (wxPropView) + + NEW FEATURES: + - New color correction matrix added: 'cticmmBlueCOUGAR_Xx05bC_WPPLS'. This will be (all shipped packages) + used by 'mvBlueCOUGAR-Xx05bC' devices. + + BUGS FIXED: + - Boolean properties that specify the 'cfShouldBeDisplayedAsList' flag did not (wxPropView) + correctly deal with the index parameter in wxPropView thus only element 0 could be + accessed correctly using the check box editors introduced in version 2.14.0. + (Bug introduced in version 2.14.0) + - When enabling/disabling network or USB interfaces while pressing the 'Update Device (wxPropView) + List' button in wxPropView sometimes error messages like 'An exception occurred: + NOT_A_PROPERTY while updating feature XYZ' was generated in the 'Output' Window. + - Fixed a small resource leak when interfaces did appear and vanish frequently between (mvGenTLConsumer-lib) + calls to 'DMR_UpdateDeviceList'. + - Potential deadlock when running a triggered acquisition with no trigger signal and (mvBlueFOX-lib) + infinite timeouts for the buffers. + - IFOpenDevice did return a valid handle even if a particular device could not be (mvGenTLProducer.cti) + opened and the GenTL error code was not GC_ERR_RESOURCE_IN_USE. + (Bug introduced in version 2.12.2) + - Reconnect behaviour improved: Disconnecting a device and calling (mvGenTLProducer.cti) + 'DMR_UpdateDeviceList' afterwards did result in devices not being properly (mvGenTLConsumer-lib) + reopened until 'DMR_UpdateDeviceList' was called again after plugging the device back + in. + - Minor memory leak when enumerating USB3 devices (e.g. when updating the device (mvGenTLProducer.cti) + list). + - 'State' property now correctly describes a mvBlueFOX device as 'Absent' or 'Present' (mvBlueFOX-lib) + after updating the device list on Linux systems. + - Framestart trigger in CameraLink devices will now always work, even if the camera has (mvHYPERION-lib) + a slow pixel clock (~20MHz). + +01.12.2015 2.14.0 + NEW FIRMWARE: + - Firmware version 2.3.73.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - New Property 'mvAcquisitionMemoryFrameCount' added. This property contains the + number of images currently stored in the frame buffer of the device. If this + value increases during normal streaming mode this could indicate a bandwidth + shortage. + - mvBlueFOX3: ColorCorrectionMatrix added. + - New Property 'ColorTransformationSelector' added. + Changed behaviour: + - mvBlueFOX3: Temperature resolution is .25 now. + - 'mvAcquisitionMemoryMaxFrameCount' declared deprecated. Use the maximum value + of 'mvAcquisitionMemoryFrameCount' instead. + - 'LUTValueAll' is no longer invalidated by 'LUTValue' but now set the 'noCache' + attribute. So now each read to 'LUTValueAll' actually reads data from the + device, but each write to 'LUTValue' no longer automatically reads + 'LUTValueAll' speeding up LUT write operations significantly. + Bugs Fixed: + - mvBlueFOX3: Negative temperature values were not shown correctly. + - mvBlueFOX3: DeviceLinkSpeed and mvResultingFramerate were not updated + correctly when switching from a USB2 connection to a USB3 connection. + - mvBlueCOUGAR-X1010G/C: Camera could crash, when switching to trigger mode while + acquisition is on. + - mvBlueFOX3-1100G/C, mvBlueFOX3-1031G/C: Timeouts when switching to continuous + mode while acquisition is on. + - mvBlueCOUGAR-X105G/C: Reducing the frame rate does no longer result in a 45 + second interruption on the streaming channel. + - mvBlueFOX3: Sometimes camera did not start after standby mode. + - mvBlueFOX3: Events do not have to be collected anymore, even if they were + requested before. + + UPDATES: + - Slightly improved update speed for cameras operated in device specific interface (mvGenTLConsumer-lib) + layout. + - Improved reconnection behaviour for GEV cameras that reconnect with a different (mvGenTLProducer.cti) + IP address (e.g. LLA-configured devices ). + + CHANGED BEHAVIOUR: + - The 'Quick Setup' wizard preset "Best Quality" no longer initialises cameras at the (wxPropView) + maximum possible frame rate, so that slower Interfaces (e.g. low performance + USB controllers) can still show a delay-free live image. + + NEW FEATURES: + - New attribute for features introduced: TComponentRepresentation. It can be used (all shipped packages) + to create graphical user interfaces that use custom controls for features with a + certain behaviour(e.g. check boxes for features that only have 2 possible states or + sliders with logarithmic behaviour for features like exposure time). The following + new interface functions have been added: + C: OBJ_GetRepresentation, OBJ_GetRepresentationS, OBJ_RepresentationToString + C++: mvIMPACT::acquire::Component::representation, + mvIMPACT::acquire::Component::representationAsString + .NET: mv.impact.acquire.Component.representation, + mv.impact.acquire.Component.representationAsString. + - New features published: + mvIMPACT::acquire::Device::userControlledImageProcessingEnable, (mvIMPACT_acquire.h) + mvIMPACT::acquire::SystemSettings::imageProcessingMode, + mvIMPACT::acquire::Request::getImageProcessingResultsIterator (C++), + mv.impact.acquire.Device.userControlledImageProcessingEnable, (mv.impact.acquire.dll) + mv.impact.acquire.Request.imageProcessingResultsIterator (NET). + This will allow to control the behaviour of the image processing pipeline. See + 'Image Processing' section in the API manuals for more information. + - New color correction matrices added: 'cticmmBlueCOUGAR_XDx04hC_WPPLS' and (all shipped packages) + 'cticmmBlueFOX3_x032C_WPPLS'. These will be used by 'mvBlueCOUGAR-XDx04hC' and + 'mvBlueFOX3_x032C' devices respectively. + - New command line parameter added: 'fw_file'. (mvDeviceConfigure) + + BUGS FIXED: + - Using a driver older than version 2.13.3 with wxPropView version 2.13.3 or newer did (wxPropView) + not correctly update the status bar. + (Bug introduced in version 2.13.3) + - 'Quick Setup' wizard now correctly removes any residual digital gain or blacklevel (wxPropView) + values, when the respective total value is within the analog range. + (Bug introduced in version 2.13.8) + - IP autocomplete is no longer triggered when simply reading out the IP of a device. (mvIPConfigure) + - mvBlueFOX-x00w: Sometimes the first frame after gain/exposure change had the old (mvBlueFOX-lib) + settings. + - Switching off the tooltips in wxPropView did still display values that didn't fit (wxPropView) + into the editor associated with the value as a tool tip like overlay. + - The 'TapSort' filter for 2XE-1Y data did not re-order the data correctly. (mvTITANfg-lib) + (Bug introduced in version 2.13.4) (mvHYPERIONfg-lib) + (mvVirtualDevice-lib) + - The synchronization of the CameraLink medium channels is now implemented in (low level mvHYPERION driver, Linux) + the hardware. This results in a more reliable operation and removes effects of (low level mvHYPERION driver, Windows) + delayed image processing using ImageRequestSingle. Previous versions sometimes (mvHYPERIONfg-lib) + could not perform the synchronization task and under some conditions an + ImageRequestSingle was delayed. + - Sometimes only parts of an image were captured when buffers where queued and then the (mvGenTLConsumer-lib) + acquisition engine was stopped(e.g. due to a power cycle on the device). Then after + the connection to the device was re-established a new acquisition was set up with + smaller buffer sizes. Then when stopping and restarting the acquisition with a buffer + size requirement larger than the current one but smaller or equal to the initial one + only data up to the previous buffer size was captured. + - The status bar now correctly remembers its own visibility (wxPropView) + - Reset behaviour of U3V devices improved on Linux systems. (mvGenTLProducer.cti) + - When working with multiple instances of the mvIMPACT::acquire::DeviceManager object (mvIMPACT_acquire.h) + the mvIMPACT::acquire::Device::isOpen function did not always return the correct + state of the device. + +10.11.2015 2.13.8 + NEW FIRMWARE: + - Firmware version 2.2.36.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - New cameras: mvBlueFOX3-2051G/C, mvBlueFOX3-2032G/C, mvBlueCOUGAR-XD104hG/C + - mvBlueFOX3-* LUT support. + - Added support for the 'DeviceRegistersStreamingStart' and + 'DeviceRegistersStreamingEnd' features. + Bugs Fixed: + - mvBlueCOUGAR-XD104G/C, mvBlueCOUGAR-XD104a12G, mvBlueCOUGAR-XD104bG/C: + Additional FrameEndEvents could occur at AcquisitionStart. + - mvBlueCOUGAR-XD104d, X104f, mvBlueFOX3-2024, 2024a: + In very rare cases booting could lead to corrupt images. + - mvBlueCOUGAR-X1010, mvBlueFOX3-1100: Wrong exposure event, when switching to + trigger mode. + - mvBlueCOUGAR-X1010, mvBlueFOX3-1100: First trigger failed when using exposure + times > 210 ms. + - mvBlueFOX3: Writing invalid(unaligned) values to the streaming size registers + will properly return U3V_STATUS_SI_PAYLOAD_SIZE_NOT_ALIGNED now. + + UPDATES: + - Internal migration to libusb 1.0.20. (mvGenTL_Acquire-*.tgz ) + + NEW FEATURES: + - 'Quick Setup' wizard can now be configured to not pop up automatically when opening (wxPropView) + a device, over the relevant item in the menu. + - 'Quick Setup' wizard now keeps a history of each property it modifies. (wxPropView) + - Support for non-camera devices not supporting the usual set of mandatory features (mvGenTLConsumer-lib) + added. + - Legacy GenICam XML files specifying invalid register addresses (above the 32-bit (mvGenTLProducer.cti) + range) are supported now if the upper bits of the address definitions can be ignored + for GigE Vision. + - New color correction matrices added: 'cticmmBlueCOUGAR_XDx05aC_WPPLS' and (all shipped packages) + 'cticmmBlueFOX3_x051C_WPPLS'. These will be used by 'mvBlueCOUGAR-XDx05aC' and + 'mvBlueFOX3_x051C' devices respectively. + + BUGS FIXED: + - Rounding of properties defining a minimum value that did not align with the step (mvPropHandling-lib) + width was not done correctly. So a feature with a valid value range from 3 to 18 with + a step width of 5 did not allow to set values of 3, 8, 13 and 18 but only 5, 10 and + 15. + - Fixed an internal issue resulting in tons of 'EProperty: Property 'PixelsPerCycle' (mvHYPERIONfg-lib) + does not support this value type(-2016(PROPHANDLING_INVALID_PROP_VALUE_TYPE))' log (mvTITANfg-lib) + messages when dealing with CameraLink camera descriptions. + (Bug introduced in version 1.11.1) + - If working with medium or full CameraLink cameras then the mvHYPERION needs to (low level mvHYPERION driver, Linux) + synchronize the input channels. This will be done before enabling a request. Under + certain conditions Linux signalled a blocking function call inside the kernel + module during this synchronization step. + - mvLogFileViewer works with up-to-date browsers again. (all shipped packages) + - Fixed clipping bug in ColorTwist filter for pixel formats RGB101010Packed, (all shipped packages) + RGB121212Packed and RGB141414Packed. + - Storing a setting in XML format without specifying a file extension did not add (mvPropHandling) + '.xml' to the file name if a '.' was part of the path. + - GenICam devices defining the 'DeviceRegistersStreamingStart' and/or (mvGenTLConsumer-lib) + 'DeviceRegistersStreamingEnd' features as 'not writeable' did cause a crash when + trying to load or store a setting. + - On Windows multiple entries in the list of network adapters with the same MAC but (mvGenTLProducer.cti) + different IPv4 addresses did result in incorrect interface information after the 2nd + call to 'TLUpdateInterfaceList'. This could e.g. happen if a 'Microsoft Virtual WiFi + Miniport Adapter' was present in the system. + +13.10.2015 2.13.7 + NEW FIRMWARE: + - Firmware version 2.1.2.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Version Number increased. + + BUGS FIXED: + - 'Quick Setup' wizard now remains visible when a greyscale camera is opened. (wxPropView) + (Bug introduced in version 2.13.5) + - 'BandwidthConsumed' did not state the actual bandwidth consumed on the wire, but the (mvBlueFOX-lib) + amount of data after the image processing on the host. + - Properties specifying the 'cfContainsBinaryData' flag did not always return the (mvGenTLConsumer-lib) + correct value when calling the 'binaryDataBufferMaxSize' function when the property + was not accessible when the device was initialised. + - If the image chunk was switched off after images have been captured sometimes the old (mvGenTLConsumer-lib) + image data was displayed instead of an empty buffer with just chunk data. + +09.10.2015 2.13.6 + NEW FIRMWARE: + - Firmware version 2.0.9.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - Version numbering scheme changed due to purely administrative reasons. No major + changes have been made. + - Mono12p/BayerXX12p added for all cameras except mvBlueCOUGAR-X2xx. + - mvBlueFOX3-2024aC/G, mvBlueFOX3-2024C/G: LED indicates different camera + states now. See manual for details. + Bugs Fixed: + - Additional FrameEndEvents could occur at AcquisitionStart. + - LUTs where not stored/restored properly by the UserSetLoad/Save commands if a + device did support both luminance AND RGB LUTs. + - CCDs: SW-Trigger could fail if send immediately after enabling trigger mode. + + NEW FEATURES: + - Gamma filter in Windows and Linux systems has been optimized to run on multiple (all shipped packages) + threads + - In Linux systems, the ColorTwist Filter now uses the internal thread pool (all shipped Linux packages) + optimization, introduced in version 2.12.3 + + UPDATES: + - Support for internal analysis tool improved. (mvGigECapture.sys, version 2.1.2.53) + - Increased packet size auto negotiation algorithm speed thus reduced the (mvGenTLProducer.cti) + initialisation time for GEV devices. + - Firmware related files are no longer presented to the user using the file access (wxPropView) + control wizard. + + BUGS FIXED: + - Debayering to Mono formats in Linux systems, now correctly use the internal (all shipped Linux packages) + thread pool optimization, introduced in version 2.12.3 + - Firmware update for mvBlueCOUGAR-S devices is working again. (mvGenTLConsumer-lib) + (Bug introduced in version 2.12.3) + - mvBlueFOX-x202bx: Column calibration was not always working properly resulting in (mvBlueFOX-lib) + visible columns even when looking at homogeneous scenes. + - mvHYPERION-CLb: The driver did crash if working with signal 'Trigger-In(J3.4/J3.5)'. (mvHYPERIONfg-lib) + - mvHYPERION: Sometimes the DMR_ImageRequestReset function did not work properly. (mvHYPERIONfg-lib) + Requests did return unexpected result values then. + - When one or multiple requests where aborted for a U3V device the first requests (mvGenTLProducer.cti) + result was returned as 'rrTimeout' instead of 'rrRequestAborted' on Windows. + - When releasing the 'IAMVideoProcAmp' once for a device not closed afterwards did (DirectShow_acquire.ax) + result in a crash when accessing stuff belonging to that interface afterwards. + - Calling 'DSA_UnregisterAllDevices' or 'DllUnregisterServer' did no always delete all (DirectShow_acquire.ax) + devices previously registered for DirectShow usage resulting in some applications + displaying devices no longer present in the current system even if one of the + unregister-functions have been called. + - RAW file import in wxPropView now correctly fails if either the width or the height (wxPropView) + is specified smaller than 1. + +18.09.2015 2.13.5 + NEW FEATURES: + - Firmware version 1.6.483.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueCOUGAR-X(D) devices with IMX sensors support decimation in X and Y + direction now. + - mvBlueFOX3-2024C: Added support for YUV411_8_UYYVYY format. + Bugs Fixed: + - mvBlueFOX3: UserFile can be up- and downloaded correctly now. + - AWB sometimes did not work correctly if binning or decimation was enabled. + - The Properties 'Aoi/X' and 'Aoi/Y' also affect the file import mode now. Therefore (mvVirtualDevice-lib) + now AOIs can be extracted from images loaded from disc. + - The 'Quick Setup' wizard now provides color and greyscale pre-sets, tuned for quality (wxPropView) + or speed. + + UPDATES: + - The 'LostImagesCount' property counts gaps in the block ID continuity for U3V devices (mvGenTLProducer.cti) + now. + + BUGS FIXED: + - Fixed bug introduced in version 2.13.0 with mvBlueFOX(-M)12x CCD gain settings update. (mvBlueFOX-lib) + - Windows/64bit: On a few System/OS combinations, application crash when opening (mvTITAN/mvGAMMA) + the device. Fixed in matrixfg.sys, version 1.114. + - When working with the socket implementation in setups where the first payload packet (mvGenTLProducer.cti) + processed was the potential smaller one from the end of a block(e.g. in LAG mode + where data tends to arrive out of order) blocks sometimes did contain corrupt data + with no error being reported to the upper layers. + - When opening a U3V device with event support an error message was written to the (mvGenTLProducer.cti) + log output because of an incorrect initialisation order. + +03.09.2015 2.13.4 + UPDATES: + - Detection of lost frames due to buffer under-runs improved. (mvGigECapture.sys, version 2.1.1.52) + + NEW FEATURES: + - Firmware version 1.6.475.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Bugs Fixed: + - mvBlueFOX3: AGC value can now reach up to 48dB for IMX sensors. + - mvBlueCOUGAR-XD124a, XD126, XD129: maximum image height was incorrect + after closing and opening the camera. + - mvBlueCOUGAR-XD104d, X104f, mvBlueFOX3-2024, 2024a: + - in very rare cases switching the image format led to corrupt images. + - when using LUT the output image no longer has a "solarize" effect. + - pending ACKs are now being sent when writing to 'mvUserData', 'DeviceUserName', + 'UserSetDefaultSelector' IP-configuration registers etc. + - The 'Quick Setup' wizard can now be forcefully shown/hidden by using the 'qsw' (wxPropView) + cmd-line parameter in wxPropView. This feature overrides the default settings for the + current session but it does not overwrite them. + + BUGS FIXED: + - The 'TapSort' filter for 2X-2YE data did not re-order the data correctly when (mvTITANfg-lib) + 'ImageProcessingOptimization' was set to 'ipoMinimizeMemoryUsage'. (mvHYPERIONfg-lib) + (mvVirtualDevice-lib) + - Calling 'imageRequestReset' from a thread running in parallel to a thread calling (mvGenTLProducer.cti) + 'imageRequestSingle' could result in a deadlock on Windows for U3V devices. + - mvDeviceConfigure did not backup and restore settings correctly if a device e.g. had (mvDeviceConfigure) + a valid UserSet2 and UserSet4, but no UsetSet1 and/or UserSet3. + - The 'Quick Setup' wizard now correctly disables features if they are not available on (wxPropView) + the running platform. + +13.08.2015 2.13.3 + NEW FEATURES: + - Firmware version 1.6.461.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueCOUGAR-XD124aG/C: Internal pre-gain reduced by 5dB. This will result in + slightly darker but less noisier images after a firmware update. + - New default: BalanceWhiteAuto = Off. + - All sensors now have default white balance values corresponding to a light + temperature of 5000K. + - mvBlueCOUGAR-X/XD: The 'UserFile', selectable in File Access Control, is be + preserved during firmware updates. + - AcquisitionFrameRate property does not change its value any more, only by user + input. New maximum values provided for this property. The maximum frame rate + that can be reached with the current settings may be read from the + mvResultingFrameRate property. + - mvBlueCOUGAR-X(D): Device boot time reduced by 500 ms. + New Features: + - Full mvBlueSIRIUS support added. + - mvBlueFOX3: RGB/YUV modes enabled for devices with IMX249 sensors. + - Improved SequencerControl: 'CounterDuration' became a valid value for + 'SequencerFeatureSelector', 'SequencerTriggerSource' and + 'SequencerTriggerActivation' added. + Bugs Fixed: + - mvBlueCOUGAR-X104fG/C: Some devices did not start correctly. + - mvBlueCOUGAR-X(D): With certain SCPS payload size and AOI combinations in + chunk mode the device did crash. + - mvBlueFOX3: The data written to 'mvUserData' was not stored in non-volatile + memory. + - mvBlueFOX3: Calling 'FileOperationExecute' with 'FileOperationSelector' set to + 'Close' twice did result in a crash. + - mvBlueFOX3: Corrected device link speed to 5Gbps for USB super speed. + - IMX: Sometimes starting/stopping the acquisition took too long. + - IMX: Corrupt images when over-triggering and ExposureMode = TriggerWidth is used. + - mvBlueCOUGAR-XD124a, XD126, XD129: OffsetY was not set when the image height was + set to the sensor maximum, leading to black stripes in the image + - mvBlueCOUGAR-X/XD: An upload of a 'UserFile' that exceeds the flash section size + could crash the camera. + - mvBlueCOUGAR-X/XD: When a 'DeviceReset' was executed after a firmware update + the device could fail to reboot properly in very rare cases. The status LED + would show blueish white color then. Power-cycling the device did fix this. + + UPDATES: + - U3V devices that specify the non-HEX version of the serial number in the U3V device (mvGenTLProducer.cti) + info serial string descriptor could not be initialised. + + BUGS FIXED: + - When a faulty U3V device did not answer when reading the max. device response time (mvGenTLProducer.cti) + the whole driver did lock up. + - When a request timeout for a U3V device did elapse the request result was returned (mvGenTLProducer.cti) + as 'rrRequestAborted' instead of 'rrTimeout' on Linux. + - On Windows the link speed value of LAG groups has not always been reported (mvGenTLProducer.cti) + correctly as added in version 2.5.17. This could result in incorrect resend + behaviour and/or frames being reported as incomplete even though no data was lost + on the link. + (Bug introduced in version 2.6.0) + +29.07.2015 2.13.2 + UPDATES: + - mvIMPACT Acquire applications can be compiled with C++ 11 support now. (all shipped Linux packages) + + CHANGED BEHAVIOUR: + - The 'Quick Setup' wizard display window no longer hides the status bar of wxPropView. (wxPropView) + + NEW FEATURES: + - New sample added to all packages: 'GenICamSequencerUsage'. (all shipped packages) + - ImageProcessing now has a rotation filter. Relevant properties 'RotationEnable' (mvIMPACT_acquire.h) + and 'RotationAngle' published. + - New C# example application added to all packages: 'SingleCaptureStorage'. (all MSI-based shipped packages) + - New VB.NET example application added to all packages: 'SingleCapture', (all MSI-based shipped packages) + 'SingleCaptureStorage'. + - New color correction matrix added: 'cticmmBlueFOX3_x140C_WPPLS'. It will be used by (all shipped packages) + mvBlueFOX3-1140C devices. + + BUGS FIXED: + - Calling 'EventKill' for events of type 'EVENT_REMOTE_DEVICE' or 'EVENT_NEW_BUFFER' (mvGenTLProducer.cti) + did not result in 'EventGetData' to return 'GC_ERR_ABORT' but 'GC_ERR_NO_DATA'. + - Payload type 'ExtendedChunk' for GEV devices was not handled correctly. The (mvGenTLProducer.cti) + 'image present' bit was ignored, thus the 'BUFFER_INFO_IMAGEPRESENT' query did return + 0 even if an image was present in the payload. + - Unplugging a U3V device with event support on Linux no longer floods the log (mvGenTLProducer.cti) + output. + - The 'TapSort' filter for RGB 24-bit with 2 pixels per cycle did not re-order the (mvHYPERIONfg-lib) + data correctly when 'ImageProcessingOptimization' was set to (mvTITANfg-lib) + 'ipoMinimizeMemoryUsage'. (mvVirtualDevice-lib) + - mvBlueCOUGAR-XD1212aC devices now correctly use the 'cticmmBlueCOUGAR_XDx212C_WPPLS' (all shipped packages) + color correction matrix by default. + - U3V events have been reported in a different order than delivered by the device under (mvGenTLProducer.cti) + Windows. + +22.06.2015 2.13.1 + NEW FEATURES: + - Firmware version 1.6.414.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueCOUGAR-XD126AG/C,mvBlueCOUGAR-XD129G/C: Improved image quality for higher + device clock frequencies. + New Features: + - mvBlueFOX3: Event support added. + - mvBlueFOX3-1012bC/1012dC/1013C/1020C/1020aC/1031C support YUV-Formats now. + - 'Streamable' attributes added to features suitable for streaming in the GenICam + XML files. + Bugs Fixed: + - mvBlueCOUGAR-X225G/C: Corrupt images. + (Bug introduced in 1.6.403.0) + - mvBlueFOX3: Switching 'mvDevicePowerMode' from 'mvActive' to 'mvStandby' and then + back to 'mvActive' did result in the chunk mode no longer working. + (Bug introduced in 1.6.403.0) + - mvBlueFOX3-2024aC/G: Only 32 instead of 41 Hz could be reached with + 'mvDigitizationBitDepth' set to 'Auto'. + - New sample added to all packages: 'ContinuousCaptureGenICam_C'. (all shipped packages) + + BUGS FIXED: + - Calling 'attachUserBuffer' for a request that had a user buffer with a different (all shipped packages) + size attached to it before could fail. + - The VB.NET example 'ContinuousCapture.VB.exe' also uses the 'getDeviceFromUserInput' (all shipped MSI-based packages) + function from 'mv.impact.acquire.example.helper.dll' now thus also automatically + selects the 'dilGenICam' interface layout if available. + - mvBlueFOX3 cameras with event support on Linux systems may cause a segmentation fault (mvGenTLConsumer-lib) + when closing the device. + (Bug introduced in version 2.12.4) + +11.06.2015 2.13.0 + UPDATES: + - All example applications will now use the interface layout 'dilGenICam' and the (all shipped packages) + acquisition start/stop mode 'assbUser' if supported by the selected device. + + NEW FEATURES: + - Added support for pixel format YUV411_UYYVYY_Packed. (all shipped packages) + + BUGS FIXED: + - mvBlueFOX-M certain CCD sensor types did not power up correctly in rare cases. (mvBlueFOX-lib) + - Potential deadlock when reading or writing properties from or to a GenICam compliant (mvGenTLConsumer-lib) + device defining at least on feature with a polling time. + +26.05.2015 2.12.5 + UPDATES: + - Firmware version 1.6.403.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3: SequencerControl added. + Bugs Fixed: + - mvBlueCOUGAR-X104fG/C: Sometimes no images could be captured after PowerOn. + - mvBlueCOUGAR-XD: Gain for DigitalTaps was ten times higher than the value in the + corresponding register. + + BUGS FIXED: + - mvBlueFOX-MLC202b devices operated in triggered mode did result in incorrectly (mvBlueFOX-lib) + exposed images for certain exposure times. + - If 2 processes during start-up where configured for log-output into a file both (all shipped packages) + processes could lock up. This problem affects ALL mvIMPACT Acquire packages, thus + when running more than one driver package on a system ALL package should be updated! + (Bug introduced in version 1.12.70) + - Capturing images with more than 64 MByte memory consumption could lead to problems. (low level mvHYPERION driver, Windows) + (Bug introduced in version 2.11.4) + +13.05.2015 2.12.4 + UPDATES: + - Firmware version 1.6.393.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueFOX3: Changed the status in case of a buffer too small from + 'U3V_STATUS_DATA_DISCARDED' to 'U3V_STATUS_DATA_OVERRUN' as required by the + U3V specification version 1.0.1. + New Features: + - 'ChunkSequencerSetActive' for all devices supporting the sequencer control + category. + - Support for new product added: mvBlueFOX3-2024aG/C. + Bugs Fixed: + - mvBlueCOUGAR-X125: FFC Calibration bug fixed. + - Missing invalidation of 'LineStatus' and 'LineStatusAll' when writing to + 'LineInverter' or 'LineMode'. + + NEW FEATURES: + - 'IAMCameraControl' feature 'CameraControl_Exposure' as well as the 'AMVideoProcAmp' (DirectShow_acquire.ax) + features 'VideoProcAmp_Brightness' and 'VideoProcAmp_Gain' correctly handle the + 'Auto' option as well as the runtime availability of these features. + + BUGS FIXED: + - Calling 'IAMCameraControl::Get' with 'CameraControl_Exposure' did return a value (DirectShow_acquire.ax) + that was differed from the actual value by 1. + - Calling 'IAMCameraControl::GetRange' with 'CameraControl_Exposure' did return an (DirectShow_acquire.ax) + invalid value for 'pSteppingDelta'. + - Devices specifying a category with a deprecated name as well as a category with the (mvGenTLConsumer-lib) + name the deprecated one has been replaced within their GenICam file could not be + initialised. + +08.05.2015 2.12.3 + UPDATES: + - Detection of lost frames due to buffer under-runs improved. (mvGigECapture.sys, version 2.1.0.51) + (mvGenTLProducer.cti) + - Status bar displays more statistics now. (wxPropView) + - The GenICam nodemaps of the 'System Module' and the 'Interface Module' more closely (mvGenTLProducer.cti) + comply with the GenICam GenTL SFNC 1.0 now. + + CHANGED BEHAVIOUR: + - The mvGenTLProducer is now fully compliant with the GenICam GenTL validation (mvGenTLProducer.cti) + framework. This however required some changes that might affect applications relying + on some MATRIX VISION specific GenTL producer behaviour: + - After calling 'GCUnregisterEvent' for a given event or after closing the module + associated with an event the event handle will become invalid now. + - DevicePort related function calls will now fail after closing the associated + device. + - Calling 'DSGetBufferID' with an invalid index will now fail. + - Calling 'DSStartAcquisition' with 'iNumToAcquire' set to 0 will now fail. + - Read from or writing to the device port of a device that has been closed will + now fail. + - Calling 'DSAnnounceBuffer' while an acquisition is running will now fail. + - On Windows 8 and greater less shortcuts will be created in the start menu now as (all shipped MSI-based packages) + since Windows 8 nested folders in the start menus are no longer allowed. + + NEW FEATURES: + - On Linux an internal thread pool is now used to speed up de-bayer processing time. (all shipped Linux packages) + This will increase the number of threads created by the number of processors per + initialised device in a process. + - New properties published: mvIMPACT::acquire::Request::chunkSequencerSetActive, (mvIMPACT_acquire.h) + mvIMPACT::acquire::GenICam::DataStreamModule::mvResendMode, + mvIMPACT::acquire::Statistics::bandwidthConsumed (C++), + mv.impact.acquire.Request.chunkSequencerSetActive, (mv.impact.acquire.dll) + mv.impact.acquire.GenICam.DataStreamModule.mvResendMode, + mv.impact.acquire.Statistics.bandwidthConsumed (NET) + - GenCP 1.1 multi-event support added. If supported by the device this will be enabled (mvGenTLProducer.cti) + by the GenTL producer now. + - U3V event support for Linux added. (mvGenTLProducer.cti) + + BUGS FIXED: + - 'Quick Setup' wizard: Pressing 'Cancel'/'Factory Reset' will now correctly revert/set (wxPropView) + all relevant ColorTwist properties respectively. + - The original payload type from the underlying transport layer was reported instead of (mvGenTLProducer.cti) + the GenTL payload type for the 'BUFFER_INFO_PAYLOADTYPE' query. This could result in + problem when processing chunk data with 3rd party software. + - Accessing a data stream buffer through the GenICam node map now works properly. (mvGenTLProducer.cti) + - Constantly opening and closing U3V devices with event support did result in failures (mvGenTLProducer.cti) + during open calls after some time. + - Calling mv.impact.acquire.FunctionInterface.imageRequestUnlock directly after (mv.impact.acquire.dll) + increasing the request count for a newly created request index did crash. + - When a device did stream image data in chunk mode the paddingX field from the leader (mvGenTLConsumer-lib) + of the transport layer specific data was not used to correctly set the line pitch of + the request buffer. + - When a device did stream image data in chunk mode the pixel format property from the (mvGenTLConsumer-lib) + leader of the transport layer specific data was not used to correctly set the pixel + format of the request buffer. This could cause problems when the pixel format did + change from buffer to buffer (e.g. when using the SequencerControl). + - When a device implemented the 'TLParamsLocked' feature as an actual device register (mvGenTLConsumer-lib) + and this register stayed set for whatever reasons when an application did terminate + opening the device again did not reset this parameter causing problems when trying + to configure the device. + - Updating chunk data in a request buffer could fail, if the chunk features did include (mvGenTLConsumer-lib) + selectors, that are there but are not available at the given moment. + - When switching chunk mode off requests no longer display 'old' chunk data when (mvGenTLConsumer-lib) + streaming in image mode. + - mvHYPERION-SDI: Sometimes the first images captured were distorted. This could mainly (mvHYPERIONfg-lib) + be seen with 3G camera signals. (low level mvHYPERION driver, Linux and Windows) + +26.03.2015 2.12.2 + UPDATES: + - Firmware version 1.6.360.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueCOUGAR-X(D)104(b)G/C, mvBlueCOUGAR-XD204(b)G/C: Exact frame rate. + - mvBlueCOUGAR-X, mvBlueFOX3 with EV76Cxxx sensors: Correct YOffset in line-scan + mode. There was an offset of 5 lines compared to areas scan. + New Features: + - mvBlueFOX3: Chunk support added. + - mvBlueCOUGAR-X(D): Action command support added. + - mvBlueCOUGAR-X(D)104d/fG/C: Sequencer mode available. + - mvBlueCOUGAR-X(D)104d/fG/C: LUT-bit-depth increased: 12bit to 9bit. + - mvBlueFOX3: Device link throughput limitation mode added. + - mvBlueCOUGAR-XD126G/C: New clock frequency: 60 MHz + Bugs Fixed: + - mvBlueCOUGAR-X(D): Link speed change detection can fail sporadically when + booting some systems. + - mvBlueCOUGAR-X12x,mvBlueCOUGAR-XD12x: FrameBurstStart did not work correctly in + conjunction with SequencerMode. SequencerMode did not work correctly with very + short exposure time in first SequencerSet. + - Support for newer kernel versions added to mvHYPERION modules. (low level mvHYPERION driver, Linux) + + CHANGED BEHAVIOUR: + - mvGenTLProducer now dynamically adjusts the receive buffer memory, starting with (mvGenTLProducer.cti) + 12MiB and increasing it, if possible, up to 32MiB in 4MiB increments. + - Improved GenTL validation framework compliance. This did change the behaviour of + some of the functions exported by the mvGenTLProducer-lib: + - All 'GetInfo' function can no longer be called with an invalid 'INFO_DATATYPE' + pointer. + - Calling 'IFClose' causes all devices associated with this interface to be closed + as well. + - The deprecated 'StreamAcquisitionModeSelector' feature of the data stream module + has been replaced by the official 'StreamBufferHandlingMode'. + - The data type reported for 'BUFFER_INFO_PIXEL_ENDIANNESS' has been changed from + 'INFO_DATATYPE_UINT32' to 'INFO_DATATYPE_INT32'. + + NEW FEATURES: + - The property mvIMPACT::acquire::SystemSettings::imageProcessingOptimization (C/C++) (mvIMPACT_acquire.h) + or mv.impact.acquire.SystemSettings.imageProcessingOptimization (.NET) can now be (mv.impact.acquire.dll) + used to influence the behaviour of the internal image processing algorithms. + + BUGS FIXED: + - On Linux when the same interface(same MAC address) was present more than once in (mvGenTLProducer.cti) + the ifconfig table some internal list have not been updated correctly and therefore + devices connected to this interface could not be accessed. This could e.g. happen + when an avahi daemon was running on an interface already configured with e.g. dhcp + or static ip. + - The 'auto assign temp IP' option did only work if both the IP as well as the (mvIPConfigure) + netmask where invalid. + - Crashes in the destructor of the classes (mvIMPACT_acquire_GenICam.h) + mvIMPACT::acquire::GenICam::ODevFileStream or + mvIMPACT::acquire::GenICam::IDevFileStream when an attempt to open a file did fail. + - 'CaptureToUserMemory_C' did fail when requesting a single frame for devices with (CaptureToUserMemory.c) + AcquisitionStartStopBehaviour' set to 'assbUser'. + - Potential crashes in the channel split filter when working with 'ibpfMono12Packed_V1' (all shipped packages) + or 'ibpfMono12Packed_V2' formats. + +13.02.2015 2.12.1 + NEW FEATURES: + - mvIPConfigure can now auto-assign a valid and unused temporary IP Address to a device (mvIPConfigure) + which is not configured properly. The user no longer has to enter it manually. + - The 'GenICam' namespace now contains the full SFNC 2.2 feature set. (mvIMPACT_acquire_GenICam.h) + (mv.impact.acquire.dll) + - MATRIX VISION Linux installation scripts now support an unattended installation mode. (all shipped Linux packages) + - Linux installation script for mvVirtualDevices is available now. (all shipped Linux packages) + + BUGS FIXED: + - Unplugging and the re-inserting mvBlueFOX USB2 devices to a USB3 host controller (mvBlueFOX-lib) + on Windows 7 did not work properly. Afterwards no image capture was possible. + - Certain exposure times on mvBlueFOX-x00w did result in incorrectly exposed images. (mvBlueFOX-lib) + - Division by 0 exceptions when trying to initialise various flavors of the mvBlueFOX2 (DirectShow_acquire.ax) + under DirectShow. + (Bug introduced in version 2.11.9) + - When unicasting GEV Action commands only the first action command could be sent while (mvGenTLProducer.cti) + every additional command did report an error. + - The function mv.impact.acquire.helper.RequestProvider.acquisitionStart did fail when (mv.impact.acquire.dll) + called a second time even if mv.impact.acquire.helper.RequestProvider.acquisitionStop + has been called before. + +30.01.2015 2.12.0 + UPDATES: + - Firmware version 1.6.306.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueFOX3-1031G/C: Minimum exposure has been set to 30 usec. + Bugs Fixed: + - mvBlueFOX3-2024xx: Single request acquisition mode failed when using pixel + formats other than Mono8 or BayerRG8. + - mvBlueCOUGAR-X100wG/C: Frame rate for trigger burst modes corrected. + - mvBlueCOUGAR-XD104dG/C, mvBlueCOUGAR-X104fG/C: Changing the pixel format + could result in corrupt images. + + CHANGED BEHAVIOUR: + - For Windows 8 and greater the 'FullScreen' option in wxPropView is no longer (wxPropView) + available as this feature is no longer supported by the operating system. + - All devices offering the 'dilGenICam' interface layout will now be initialised in (DirectShow_acquire.ax) + 'dilGenICam' interface layout instead of 'dilDeviceSpecific'. + - ImageRequestWaitFor() should no longer cause considerable CPU load on weaker Linux (mvBlueFOX-lib) + systems such as ARM boards. + - The increment of the 'ImageWidth' and 'ImageHeight' properties of the scaler (all shipped packages) + belonging to the 'ImageDestination' class have been reduced from 4 to 1 allowing + finer scaling. + - All GenICam SFNC features with the 'Abs' postfix in the feature name have been (mvIMPACT_acquire_GenICam.h) + removed from the public interface. If a device supports the 'Abs' feature only, the (mv.impact.acquire.dll) + interface will automatically bind to this feature when using the object without the + 'Abs'. + + NEW FEATURES: + - New color correction matrices added: 'cticmmBlueCOUGAR_Xx04fC_WPPLS' and (all shipped packages) + 'cticmmBlueFOX3_x024aC_WPPLS'. These will be used by 'mvBlueCOUGAR-x04fC' and + 'mvBlueFOX3_x024aC' devices respectively. + - mvDeviceConfigure now performs checks and displays the current and future firmware (mvDeviceConfigure) + versions before updating a device. + - Support for GEV Action commands added to the (mvGenTLProducer.cti) + mvIMPACT::acquire::GenICam::InterfaceModule (C++) and (mvIMPACT_acquire_GenICam.h) + mv.impact.acquire.GenICam.InterfaceModule (.NET) classes added. (mv.impact.acquire.dll) + - A lot of new events integrated into the GenICam.EventControl wrapper class. (mvIMPACT_acquire_GenICam.h) + (mv.impact.acquire.dll) + + BUGS FIXED: + - IP performance issue check on Linux U3V interfaces no longer takes place. As a (mvIPConfigure) + result, erroneous messages on the log window of mvIPConfigure no longer appear. + - Potential crash when processing hot-plug messages under 64-bit Windows systems. (mvBlueFOX-lib) + - Crashes when an application tried to open a device that was registered for DirectShow (DirectShow_acquire.ax) + access but was not present in the current system. + (Bug introduced in version 2.11.9) + - JPEG, TIFF and PNG import added based on the 'FreeImage' library works for the (mvVirtualDevice-lib) + mvBlueLYNX-X as well now. + - Random crash in wxPropView when switching back and forth between 2 or more devices (wxPropView) + running in live mode. + - Access to WO-GenApi features was not possible. (mvGenTLConsumer-lib) + +15.01.2015 2.11.9 + UPDATES: + - Firmware version 1.6.295.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueFOX3: AGC/AWB/AEC calculation is faster now. + New Features: + - Support for new products added: + mvBlueCOUGAR-X104fG/C, mvBlueFOX3-2024G/C + - mvBlueCOUGAR-X1010G/C, mvBlueCOUGAR-X104G/C, + mvBlueCOUGAR-X104bG/C, mvBlueCOUGAR-XD104G/C, + mvBlueCOUGAR-XD104bG/C, mvBlueCOUGAR-X1010G/C, + mvBlueCOUGAR-X104fG/C, mvBlueCOUGAR-X104dG/C, + mvBlueCOUGAR-X100wG/C, + mvBlueFOX3-1100G/C, mvBlueFOX3-1140C: + FrameBurstStart trigger without jitter. + - mvBlueCOUGAR-XD104dG/C, mvBlueFOX3-2024G/C: ExposureMode = TriggerWidth + Bugs Fixed: + - mvBlueCOUGAR: Setting DiscoveryACKDelay to zero is possible now. + - mvBlueFOX3: The device temperature was not shown correctly. + + NEW FEATURES: + - Initial version of the 'Quick Setup' wizard for mvBlueFOX devices added. (wxPropView) + - On Windows wxPropView has now three new help menu options which (wxPropView) + - directly open the logs folder + - create a zip file with all the logs + - open the systems default email client to send an email to + support@matrix-vision.com. + - New color correction matrix added: 'cticmmBlueCOUGAR_Xx010C_WPPLS' This will be used (all shipped packages) + by 'mvBlueCOUGAR-x010C' devices. + - The DirectShow interface supports the 'IAMVideoProcAmp' and the 'IAMCameraControl' (DirectShow_acquire.ax) + interface now. This will e.g. allow to adjust the exposure time and the gain under + MATLAB. + - JPEG, TIFF and PNG import added based on the 'FreeImage' library. (mvVirtualDevice-lib) + - New property published in C++ and .NET interface: (mvVirtualDevice-lib) + CameraSettingsVirtualDevice::aoiMode. (mvIMPACT_acquire.h) + (mv.impact.acquire.dll) + + BUGS FIXED: + - Logging also works with the new log section format introduced in version 2.5.0. (DirectShow_acquire.ax) + +18.12.2014 2.11.8 + UPDATES: + - Just minor internal changes. Nothing new, nothing fixed. + +17.12.2014 2.11.7 + NEW FEATURES: + - The 'ipv4_mask' parameter now accepts a ';' separated list of masks (mvDeviceConfigure) + (e.g. ipv4_mask=169.254.*;192.168.100*). + + BUGS FIXED: + - Restoring values created and set in the 'Custom Properties' dialog of Vision Pro from (mvIMPACTAcquire_Cognex_Adapter-lib) + a *.vpp file is working now. + - Potential crash when working with mvBlueFOX devices on Linux. (mvBlueFOX-lib) + (Bug introduced in version 2.11.6) + - Under some conditions it could comes to random crashes of the system. (Linux only) (Linux, low level mvHYPERION driver) + +02.12.2014 2.11.6 + UPDATES: + - Firmware version 1.6.259.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - mvBlueFOX3-1020(a)G/C/GE, mvBlueCOUGAR-X102eG/C/GE, mvBlueCOUGAR-X104eG/C/GE has + reduced analog gain step size. + New Features: + - AGC/AWB/AEC for mvBlueFOX3. + - MT9P031/MT9M021/MT9M024/E2V-sensors: FrameBurstStart with no jitter. + Bugs Fixed: + - mvBlueFOX3: + - Under some conditions there was a delay in the communication to the mvBlueFOX3 + devices. This occurred only on Linux systems with particular host controllers. + - Changes in the BOS descriptor from USB2.1 Specification introduced. + - mvBlueFOX3-1013G/C, mvBlueFOX3-1020G/C: Wrong exposure times could occur while + changing properties. + - mvBlueCOUGAR-X105G/C: Wrong exposure times when using ShutterMode = GlobalReset. + - If TriggerMode=On was the very first write command it did not work. + + BUGS FIXED: + - mv.impact.acquire.display.ImageDisplay.SetImage( Request pRequest) did mix up 'R' and (mv.impact.acquire.display.extensions.dll) + 'B' in 'ibpfRGBx888Planar' mode. + - Potential deadlock when closing a device while an unplug message is processed (mvBlueFOX-lib) + internally. (Linux only) + - Random crash when a device was unplugged while streaming data. (Linux only) (mvBlueFOX-lib) + - Under some conditions the imageRequests were returned with an false error code. (Linux, low level mvHYPERION driver) + +24.11.2014 2.11.5 + UPDATES: + - Internal migration to libusb 1.0.19. (mvGenTL_Acquire-*.tgz ) + + NEW FEATURES: + - ARM softfloat and ARM hardfloat support added for mvGenTL_Acquire and mvBlueFOX. (mvBlueFOX-ARMsf_gnueabi-*.tgz) + This will add support for various ARM platforms running at least ubuntu 12.04 or (mvBlueFOX-ARMhf_gnueabi-*.tgz) + a compatible system. (mvGenTL_Acquire-ARMsf_gnueabi-*.tgz ) + (mvGenTL_Acquire-ARMhf_gnueabi-*.tgz ) + - New color correction matrix added: 'cticmmBlueFOX3_x024C_WPPLS' This will be used by (all shipped packages) + 'mvBlueFOX3-x024C' devices. + + BUGS FIXED: + - Linux installer scripts no longer complain about missing Platform.h file. (mvGenTL_Acquire-x86_*.tgz) + (Bug introduced in version 2.11.3) (mvBlueFOX-x86_*.tgz) + +19.11.2014 2.11.4 + CHANGED BEHAVIOUR: + - NeuroCheck 6.x interfaces do no longer support devices NOT manufactured by MATRIX (mv.impact.acquire.NeuroCheck6.dll) + VISION. (mv.impact.acquire.NeuroCheck6_1.dll) + - Footer and actual image buffer use 2 separate blocks of memory now. Because of this (mvHYPERIONfg-lib) (low level mvHYPERION driver, Linux) + it is now possible to allocate or provide a contiguous block of memory that provides (low level mvHYPERION driver) + space for multiple images to implement a ring buffer pool without any gaps between + the individual images. This needs a kernel driver update as well. + + NEW FEATURES: + - NeuroCheck 6.1 interface for mvBlueCOUGAR and mvBlueFOX devices added to all MSI (all shipped MSI-based packages) + based packages. + + BUGS FIXED: + - When the current device got disconnected the 'Quick Setup' wizard is no longer (wxPropView) + periodically generating error messages. + - When for whatever reasons the on-board processor of a mvHYPERION device could not (mvHYPERIONfg-lib) + be booted the driver instance did crash. + +11.11.2014 2.11.3 + NEW FEATURES: + - Initial version of the 'Quick Setup' wizard added. (wxPropView) + - New command line parameter added: 'custom_genicam_file'. (mvDeviceConfigure) + - 'FirmwareUpgrade' on Linux can now be used to update the firmware of mvHYPERION (all shipped Linux packages) + devices from a console window as well. This might be useful on systems without a + graphical user interface. + - New property published in C++ and .NET interface: Device::manufacturer. (mvIMPACT_acquire.h) + (mv.impact.acquire.dll) + + BUGS FIXED: + - A couple of small memory leaks whenever a connection to a GenICam device was (mvGenTLConsumer-lib) + lost an then re-established automatically by the driver when the device was (mvGenTLProducer.cti) + discovered again or when a GEV or U3V interface did disappear at runtime. + - When deleting a 'ComponentCallback' object without previously unregistering all (all shipped packages) + objects bound to this callback an application could crash when the callback condition + became fulfilled afterwards. + - The GenICam XML files returned by the various modules of the producer contained an (mvGenTLProducer.cti) + additional '\0' character at the end and the consumer did rely on this when storing (mvGenTLConsumer-lib) + the file. + - Potential crash when a GenICam device was disconnected shortly before reading the (mvGenTLConsumer-lib) + 'PayloadSize' property. + - Potential deadlock when writing to a GenICam property of the device shortly after a (GenApi runtime) + device was disconnected or the connection to the device was lost for some other + reason. This did only happen for GenICam devices that support an event channel. + - When for some reason a device driver did forward a frame that did carry a width or (all shipped packages) + height of 0 into one of the image processing functions (e.g. the LUT filter) the + driver instance could crash. + - Crash when calling 'DMR_ReleaseImageBuffer' for a buffer that was obtained from a (mvDeviceManager-lib) + call to 'DMR_CopyImageBuffer' with a source buffer where 'vpData' was != 0 but + 'iSize' was 0. + - Payload type 'Image_ExtendedChunk' for GEV devices was not handled correctly. (mvGenTLProducer.cti) + - Payload type 'Chunk' was not handled correctly when the buffer did not carry the (mvGenTLConsumer-lib) + 'ChunkWidth' and 'ChunkHeight' feature. + +23.10.2014 2.11.2 + UPDATES: + - Firmware version 1.6.230.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3-2024G/C: New mvBlueFOX3 hardware added with support for IMX174 sensor. + Bugs Fixed: + - mvBlueCOUGAR-X100wG/C: Corrupt image in HDR-mode. + - mvBlueFOX3-1020G/C: Some sensors were showing stripes in saturated areas. + + CHANGED BEHAVIOUR: + - When 'AcquisitionStartStopBehaviour' is set to 'assbUser' and 'AcquisitionMode' is (mvGenTLConsumer-lib) + set to 'SingleFrame' calling 'acquisitionStop' will also send a stop command to the + device now in order to properly terminate outstanding frame requests there. + - Loading a setting in 'GenICam' or 'Generic' interface layout will only work if the (mvGenTLConsumer-lib) + setting has been created with the same interface layout AND at least the same + product. Thus e.g. loading a setting created with a mvBlueCOUGAR-X122G will only work + for other mvBlueCOUGAR-X122G devices. + - For U3V devices the driver will access the 'MaxDeviceResponseTime' register first (mvGenTLProducer.cti) + now. + + NEW FEATURES: + - Lens control wizard added to allow convenient configuration of a lens controllable by (wxPropView) + a GenICam device. This wizard will be available if the device supports the + 'mvLensControl' category. + + BUGS FIXED: + - Update issue with some HDR parameter combinations for mvBlueFOX-x00w devices. (mvBlueFOX-lib) + - 'imageRequestReset' calls are handled correctly now. (mvVirtualDevice-lib) + - Color correction matrices for 'cticmmBlueCOUGAR_Xx20aC_WPPLS', (all shipped packages) + 'cticmmBlueFOX_x20aC_WPPLS', 'cticmmBlueCOUGAR_Xx05C_WPPLS' and + 'cticmmBlueFOX_x05C_WPPLS' did use incorrect values. + +09.10.2014 2.11.1 + UPDATES: + - Firmware version 1.6.223.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - New camera mvBlueCOUGAR-XD104dG/C supported. + Changed Behaviour: + - mvBlueCOUGAR-XD: Link process with only one link now completes faster. + Bugs Fixed: + - mvBlueCOUGAR-X105G/C: mvShutterMode was not available. + (Bug introduced in Firmware version 1.6.129.0) + - Cameras with CMOSIS sensors: Changing ExposureTime did not work correctly. + - mvBlueCOUGAR-XD12xG/C: Wrong exposure time when using slow framerates (<2 fps). + - mvBlueCOUGAR-XD126C: Max Height could be set to wrong values if switching the + SensorTap property. + - Changing ExposureMode to TriggerWidth did not work correctly. + - mvBlueFOX3: In some cases e.g. after changing the exposure time BF3 sent + corrupted frames. + - FrameStart signal wasn't correct. + - Support for third party GenICam devices that change the 'IsImplemented' feature of (mvGenTLConsumer-lib) + their features at runtime improved. These features will now be available, but when (mvPropHandling-lib) + marked as 'not implemented' will have neither read nor write access. + + CHANGED BEHAVIOUR: + - When the 'TestMode' property is set to 'ImageDirectory the following changes have (mvVirtualDevice-lib) + been applied: + - The 'FrameId' property of a returned request object will contain the index of the + image file within the directory + - The 'UserData' property of a returned request object will contain the name of the + file that was loaded (or an error message) at index 0 and the 'True' if this file + is the last image file in this directory or 'False' otherwise at index 1. + + BUGS FIXED: + - Certain internal error codes could end up in the application layer (e.g. GenTL (mvGenTLConsumer-lib) + specific ones) but as these are not part of the SDK the application could not + properly handle them. + - For GEV 2.x devices the driver now correctly switches on the '64bitBlockIdEnable' bit (mvGenTLProducer.cti) + - For GEV the 'Image_ExtendedChunk' format is decoded correctly now. (mvGenTLProducer.cti) + - For GEV 2.x devices the test packet validation was not always working correctly. (mvGenTLProducer.cti) + - Devices specifying a category with a deprecated name as well as a category with the (mvGenTLConsumer-lib) + name the deprecated one has been replaced with in their GenICam file could not be + initialised. + - Devices specifying sub-lists within their chunk info features caused the driver to (mvGenTLConsumer-lib) + crash at runtime when streaming in chunk mode. + +15.09.2014 2.11.0 + CHANGED BEHAVIOUR: + - Tooltips in the wxPropView Property tree now have a delay of 2 seconds. (wxPropView) + - Format for storing settings to XML files changed. This change comes with some (all shipped packages) + compatibility issues. XML files created from now on might not be usable with mvIMPACT + Acquire versions smaller than 2.11.0! XML files created with older versions will + still be readable. See documentation for details. + + BUGS FIXED: + - mvDeviceConfigure compile errors in Linux systems. (mvDeviceConfigure) + (bug introduced in version 2.10.1) + - When working with more than one U3V device on Windows processing the very first (mvGenTLProducer.cti) + device removal event within the current process did not work correctly. This could + e.g. result in a devices 'State' property not going to 'Absent' when calling + 'DeviceReset' for the very first time. + +26.08.2014 2.10.1 + UPDATES + - Firmware version 1.6.192.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + New Features: + - mvBlueFOX3: mvDevicePowermode function added. + Changed Behaviour: + - mvBlueCOUGAR-XD: Link process with one link now faster + Bugs Fixed: + - LineScan-trigger mode. First image with wrong blockID did lead to a stop of + streaming after first the image. + - mvBlueCOUGAR-X104G/X104aG/X104bG/X125aG: + Wrong init values for LUT did result in 'mv::EValTooLarge' error upon reading. + - Gain(DigitalAll) value was set with factor 10 too high. + (Bug introduced in 1.6.173.0) + + CHANGED BEHAVIOUR: + - Firmware files for discontinued products (mvBlueCOUGAR-P, mvBlueCOUGAR-S and (all shipped packages for GenICam compliant devices) + mvBlueLYNX-M7) will no longer be shipped as part of the installation package. + The latest firmware versions are still available on the MATRIX VISION website. + - Merge modules (*.msm-files) to build custom MSI based installation packages are (all shipped MSI based packages) + no longer part of the actual MSI package for a particular driver but can be + downloaded as a separate archive from the MATRIX VISION website. This was done to + reduce the size of a standard installation. As a result 64-bit packages now roughly + use 55% of their original size, 32-bit packages about 50%. + + NEW FEATURES: + - mvDeviceConfigure can write a log file from the content of the log window now. (mvDeviceConfigure) + - Filter 'FormatReinterpreter' added. (all shipped packages) + - New properties published in C++ and .NET interface: (mvIMPACT_acquire.h) + formatReinterpreterEnable, formatReinterpreterMode (mv.impact.acquire.dll) + + BUGS FIXED: + - Firmware update for mvBlueFOX and mvHYPERION devices is working again. (mvDeviceConfigure) + (Bug introduced in version 2.9.1) + - The default parameter for 'scope' when calling 'DMR_SaveSettingToDefault' or (mvDeviceManager-lib) + 'DMR_SaveSystemToDefault' was 'sGlobal' but must be 'sUser'. This did also result in + an error being reported in wxPropView when selecting + 'Action -> Capture Settings -> Save Active Device Settings -> ... (Per User Only)'. + (Bug introduced in version 2.5.9) + - XML Files stored in the folder 'CameraFiles' but not containing camera description (all shipped frame grabber packages) + data but e.g. a device setting the name of the file did end up as a selectable camera + description but obviously did not behave correctly. + +21.07.2014 2.10.0 + UPDATES + - Firmware version 1.6.165.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Bugs Fixed: + - CCDs: Changing the exposure time did not always work correctly. + - Updated mvSDK driver packages. matrixfg.sys version 1.113, bugfix DMA unmap. (mvTITAN, mvSIGMA) + + CHANGED BEHAVIOUR: + - Unused data type 'TImageResultConfiguration' removed from the interface. If your (all shipped packages) + code was using it, replace every occurrence by 'TBoolean'. This will not affect + shipped applications. + + NEW FEATURES: + - New class 'RequestInfoConfiguration' added to the interface. (mvIMPACT_acquire.h) + (mv.impact.acquire.dll) + + BUGS FIXED: + - The request properties 'Image/OffsetX' and 'Image/OffsetY' where always reported as (mvGenTLConsumer-lib) + 0 when the chunk mode was used. + - When using more than one mvTITAN/mvGAMMA grabber, Calling the 'CloseDevice' could (all shipped packages for mvTITAN/mvGAMMA devices) + cause problems. + - Storing calibration data to an XML setting is working again. (mvPropHandling-lib) + (Bug introduced in version 2.9.0) + +10.07.2014 2.9.2 + CHANGED BEHAVIOUR: + - When updating the firmware of a device, and the UserSet persistence is enabled, the (mvDeviceConfigure) + UserSet used after the update will be the one defined in UserSetDefaultSelector, + instead of the "Default" UserSet. + + BUGS FIXED: + - Updating the firmware of more than one devices with UserSet persistence enabled, (mvDeviceConfigure) + will not restore the UserSets correctly for all devices except the first. + (Bug introduced in version 2.9.1) + - Trying to load an incompatible setting from the Registry on Windows did cause a (mvPropHandling-lib) + leak of 2 handles. + - Restoring settings from the Registry on Windows did not work correctly for GenICam (mvGenTLConsumer-lib) + devices. (mvPropHandling-lib) + (Bug introduced in version 2.9.0) + +07.07.2014 2.9.1 + CHANGED BEHAVIOUR: + - When using mvDeviceConfigure to update the firmware of a GenICam device, UserSets (mvDeviceConfigure) + stored on the device can be preserved now. + + NEW FEATURES: + - The 'DataStreamModule' object will allow access to the 'mvResendRequestCredits' (mvGenTLProducer.cti) + property now when the NDIS based filter driver for GEV is used. + + BUGS FIXED: + - Restoring settings did not work correctly for GenICam devices. (mvGenTLConsumer-lib) + (Bug introduced in version 2.9.0) + - The x64 version of wxPropView no longer crashes on Windows 8.1 when opening the color (wxPropView) + correction wizard. This was a bug in wxWidgets that surfaced when migrating to + Visual Studio 2013. + (Bug introduced in version 2.8.0) + +24.06.2014 2.9.0 + UPDATES: + - Firmware version 1.6.157.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Bugs Fixed: + - Long Link-Up times caused by noise on the twisted pair interface. + - mvBlueCOUGARX-102eG/C, mvBlueCOUGARX-104eG/C: Linescan trigger mode: Camera + absent after stopping and starting trigger signal. + - mvBlueCOUGARX-102eG/C,mvBlueCOUGARX-104eG/C: In trigger mode first image + needs too much trigger pulses. + - mvBlueFOX3-1020G/C: Reduced framerate for special AOI and exposure settings. + - LUT Wizard improved: X-axis uses a nicer scaling now, if there is only a single LUT (wxPropView) + this no longer has to be explicitly selected during synchronization, when loading a + setting the dialog is refreshed automatically, 'Cache -> Device' is now the default, + some hints added. + - Improved Axis scaling of the various analysis plots and wizards. (wxPropView) + + CHANGED BEHAVIOUR: + - Writing an invalid (e.g. too long) value to a GenICam string property will result in (mvGenTLConsumer-lib) + an exception reported back to the application now. + + NEW FEATURES: + - The number of request objects in the result queue can now be queried at runtime, by (all shipped packages) + calling the imageRequestResultQueueElementCount() method of the FunctionInterface + class. + + BUGS FIXED: + - '\n' and '\t' characters in string property values will be stored into and restored (mvPropHandling-lib) + from XML settings correctly now. + - Installing MATRIX VISION Linux drivers on trusty tahr (Ubuntu 14.04 LTS) systems no (all shipped Linux packages) + longer generates warnings/errors when building SingleSnap and mvDeviceConfigure. + - Load settings from XML file now works properly. This change brings some compatibility (all shipped packages) + issues. XML files created from now on will not be usable with mvIMPACT Acquire + versions smaller than 2.9.0! XML files created with older versions, will still be + usable, but with the same limitations they had up until now. + - The x64 version of wxPropView no longer crashes on Windows 8.1. This was a bug in (wxPropView) + wxWidgets that surfaced when migrating to Visual Studio 2013. + (Bug introduced in version 2.8.0) + - Windows XP is supported again! (all MSI-based shipped packages) + (Bug introduced in version 2.8.0) + +26.05.2014 2.8.0 + UPDATES: + - Firmware version 1.6.139.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GenICam compliant devices) + Changed Behaviour: + - all mvBlueFOX3 devices: Minimum width is now 32 Pixel. + - mvBlueFOX3-1013C/1020C/1031C/1100C: Transfer rate limitation changed for RGB + pixelformats. + - mvBlueFOX3-1020G/C: Maximum fps limit is now 51.8 Hz + - mvBlueFOX3-1100C: Bayer pattern changed to RG. + - mvBlueFOX3-1031C: Bayer pattern changed to GR. + - mvBlueFOX3-1012d(b)G/C: Sensor's width and offsetX must be a multiple of 2. + New Features: + - TriggerSelector 'FrameBurstActive' is available for CCD sensors. + - all mvBlueFOX3 devices: Frame Average Control added to mvBlueFOX3 Firmware. + - mvBlueFOX3-1100C: RGB pixelformat support added. + Bugs Fixed: + - Enabling and disabling both FrameBurstStart and FrameBurstActive Triggers could + result in continuous acquisition. + - all mvBlueFOX3 devices: Timestamp does not increment with several pixel clocks + - mvBlueCOUGAR-X1010G/C: Possible camera crash when changing sensor settings. + - mvBlueFOX3-1020C/1013C: Incorrect colors in linescan mode. + - Migration from Visual Studio 2005 to Visual Studio 2013. All Windows packages of (all shipped MSI-based packages) + mvIMPACT Acquire are compiled using Visual Studio 2013 now. This might require + changes in custom installation scripts. See 'Installation from private setup + routines' in the documentation. + - On systems with 4 or more CPUs the Bayer filter will no longer use SSE2 but openMP (all shipped packages) + in order to better distribute the overall load. + + NEW FEATURES: + - 'update_fw_file' parameter added to the command line interface. (mvDeviceConfigure) + + BUGS FIXED: + - FlatField correction wrap-around issue when using the Mono16 pixel format. (mvGenTLConsumer-lib) + - Crash when calling 'DevClose' for a U3V device without previously calling 'DSClose' (mvGenTLProducer.cti) + for each open stream for this device. + +15.05.2014 2.7.2 + UPDATES: + - When only a feature using a deprecated GenICam SFNC name is available this will be (mvIMPACT_acquire_GenICam.h) + automatically be bound to the object expecting the new name as well. This allows (mv.impact.acquire.dll) + to write less code when multiple devices shall be supported. + - Migration to version 3.0.7.0 of libusbK for U3V devices. (mvGenTL_Acquire*.msi) + + CHANGED BEHAVIOUR: + - The deprecated libraries 'mvBlueCOUGAR-lib' and 'mvTLIClientGigE.cti' are no longer (all shipped packages for GEV/U3V devices) + shipped as the migration to version 2.4.0 of the GenApi runtime requires changing + custom installers anyway. + - Examples for Visual Studio 6 and 2003 are no longer shipped as part of the (all shipped MSI-based packages) + installation. Visual Studio 6 and 2003 are no longer supported by mvIMPACT Acquire! + - The GEV filter driver will also capture buffers that not start with a leader but with (mvGigECapture.sys, version 2.0.16.50) + payload when running with the 'ResendImmediate' strategy being switched off (as it + should be done for LAG connections). + + NEW FEATURES: + - Visual Studio 2013 workspace and project files added to sample programs. (all shipped MSI based packages) + - When a firmware update that was triggered by using the command line interface did (mvDeviceConfigure) + fail, the exit code of the application will no longer be 0. + + BUGS FIXED: + - Potential crash when calling 'DMR_UpdateDeviceList' or (mvGenTLProducer.cti) + 'mvIMPACT::acquire::DeviceManager::updateDeviceList' for a device that disappeared + or was disconnected just at roughly the same time. + - Buffers with a 'PayloadSize' smaller than 'wMaxPacketSize' of the streaming endpoint (mvGenTLProducer.cti) + can be captured from U3V devices now. + - Some empty folders no longer needed are no longer created by the installers. (all shipped MSI-based packages) + - The 'FileVersion' and 'SchemaVersion' properties did not always contain the correct (mvGenTLConsumer-lib) + values(decimal values have been interpreted as hexadecimal ones). + - Potential deadlock when a device did re-appear during a call to (mvGenTLConsumer-lib) + 'mvIMPACT::acquire::FunctionInterface::updateDeviceList' or 'DMR_UpdateDeviceList'. + +14.04.2014 2.7.1 + UPDATES: + - Firmware version 1.6.123.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GEV/U3V devices) + New Features: + - writable discovery ACK delay for GEV devices implemented. + Bugs Fixed: + - CCDs: Changing exposure time in trigger mode: + New exposure time was not active during first trigger. + (Bug introduced in 1.6.42.0) + + BUGS FIXED: + - Potential deadlock when a new 'DMR_ImageRequestReset' was executed simultaneously (all shipped packages) + from 2 or more threads. + +10.04.2014 2.7.0 + DEPRECATED API CODE: + - 'mvIMPACT::acquire::InfoBase': Use 'mvIMPACT::acquire::Info' instead. (mvIMPACT_acquire.h) + - 'mvIMPACT::acquire::StatisticsBase': Use 'mvIMPACT::acquire::Statistics' instead. (mvIMPACT_acquire.h) + - 'mvIMPACT::acquire::SystemBase': Use 'mvIMPACT::acquire::SystemSettings' instead. (mvIMPACT_acquire.h) + + UPDATES: + - Firmware version 1.6.120.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GEV/U3V devices) + Changed Behaviour: + - Applying changes to the binning or decimation registers will not affect the + visible section of the AOI anymore. + - mvBlueFOX3-1020G/C: Maximum fps=51.8 Hz + - mvBlueFOX3-1100G/C, mvBlueCOUGAR-X1010G/C: 'BinningVertical' restricts the + vertical AOI increment('Height', 'OffsetY') to 4 pixels. + New Features: + - 'FrameBurstStartTrigger' with sensor trigger for CCDs. + Bugs Fixed: + - mvBlueCOUGAR-XD104G/C: Streaming could fail after startup. + - Invalid frame rate limits when using long exposure times. (mvBlueCOUGAR, mvBlueFOX3) + - mvBlueFOX3-1100G/C, mvBlueFOX3-1140GW, mvBlueCOUGAR-X1010G/C: Cameras do now + saturate also for 'Width' < 500 pixels. + - mvBlueFOX3: On Windows 8.1 with default drivers installed the device could go + into a sleep state. + - mvBlueFOX3: All image related parameters will be reported correctly after a + successful image acquisition. + + - Migration to version 2.4.0 of the GenApi runtime. (mvBlueCOUGAR installer) + - Migration to version 1.4 of the GenICam GenTL spec. (mvGenTLProducer.cti) + (mvGenTLConsumer-lib) + - Improved hotplug support on Windows while streaming. (mvGenTLProducer.cti) + + NEW FEATURES: + - Property 'AcquisitionBurstFrameCount' added to class 'CameraSettingsBlueCOUGAR' for (mvGenTLConsumer-lib) + usage with interface layout 'dilDeviceSpecific'. (mv.impact.acquire.dll) + - U3V event and chunk support added. (mvGenTLProducer.cti) + (mvGenTLConsumer-lib) + - The color of the 'Request Info' overlay is now selectable. (wxPropView) + - The 'Requests' list is no longer displayed in the property tree of wxPropView. As an (wxPropView) + alternative a 'Detailed Request Information' has been added. + + BUGS FIXED: + - The 'State' property of a device did change before it was fully initialised when it (mvGenTLConsumer-lib) + was re-discovered after being absent for some time. + +21.03.2014 2.6.3 + UPDATES: + - Firmware version 1.6.105.0 for mvBlueFOX3 and mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + Changed behaviour: + - 'BalanceWhiteAuto' and 'BlackLevelAuto' temperature stability increased. (mvBlueCOUGAR-X/XD104) + New features: + - Binning/Decimation for many sensors added + Bugs fixed: + - On USB2 acquisition provides no longer out-dated images. (mvBlueFOX3) + - 'mvLineDebounceTime' value in default UserSet was not working after startup. + - A firmware update can also be performed on a USB2 interface. (mvBlueFOX3) + - After a device reset, it could happen that the mvBlueFOX3 did not restart (mvBlueFOX3) + properly. + - Swapped rows and columns corrected. (mvBlueFOX3-1140C) + - Device was sporadically not recognized by the host. (mvBlueFOX3) + - Load speed for large settings (e.g. containing calibration data) from an XML file (all shipped packages) + has been improved. + + BUGS FIXED: + - Autoscrolling in the log-textcontrol did not work correctly. (mvDeviceConfigure) + - Partial (no GEV Support) install/uninstall of the mvGenTL_Acquire driver over the (mvGenTL_Acquire*.msi) + command line caused 'Error 2753'. + - Working with a U3V device from one process while enumerating it from another could (mvGenTLProducer.cti) + cause communication problems. + - Defining digital signals for various I/O related operations using the class (mv.impact.acquire.dll) + 'mv.impact.acquire.OutputSignalGeneratorFrameGrabber' did not work correctly. For + example the function + 'mv.impact.acquire.OutputSignalGeneratorFrameGrabber.getValidPassThroughSignalCount' + did always return 0. + - Calling 'mv.impact.acquire.OutputSignalGeneratorFrameGrabber.undefineSignal' for (mv.impact.acquire.dll) + mvTITAN, mvGAMMA, mvDELTA or mvSIGMA did always return 'DMR_FEATURE_NOT_AVAILABLE', + even if the feature was avaiable. + - Writing register data with more than 492 bytes to a U3V device did fail when operated (mvGenTLProducer.cti) + on a USB2 interface. + +06.03.2014 2.6.2 + UPDATES: + - Firmware version 1.6.89.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + Bugs fixed: + - mvBlueCOUGAR-X(D) with CCDs: No frames with minimum exposure times. + (Bug introduced in 1.6.39.0) + - mvBlueCOUGAR-XD: DHCP in LAG mode works independently of the link where the DHCP + offer arrives now(CISCO Switch) + Changed behaviour: + - mvBlueCOUGAR-X102eG/C/GE: Phase shift adapted for extended temperature range. + + CHANGED BEHAVIOUR: + - Auto-fill of Netmask and Gateway fields in 'Assign Temporary IP' dialogue now matches (mvIPConfigure) + that of persistent IP settings. MAC address and 'Build MAC from serial' button are + now greyed out when a device is already selected in the device list. + + NEW FEATURES: + - Updating a mvBlueFOX3 device with a damaged firmware does also work on Linux now. (mvGenTLProducer.cti) + - 'CPU Idle States' can be configured using the command line interface now. This can (mvDeviceConfigure) + be combined with the 'quit' parameter to be used from a script. + (Windows only). + + BUGS FIXED: + - blue screen (BSOD) on Windows 8.x systems when removing or disabling the filter (mvGigECapture.sys, version 2.0.15.49) + driver one or multiple adapters. + - Open streams are closed before opening them again, U3V interfaces are ignored in the (mvIPConfigure) + log window and auto scrolling now always works correctly. + - U3V(mvBlueFOX3) devices can now be installed on a Linux system, without affecting (mvGenTL_Acquire-x86_*.tgz) + USB2(mvBlueFOX) devices on the same system. + +20.02.2014 2.6.1 + UPDATES: + - Firmware version 1.6.74.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + Bugs fixed: + - mvBlueCOUGAR-3X120aG: Timers were not working. + Changed behaviour: + - SequencerControl: Visibility = Expert. Not saved in UserSet. + - Firmware version 1.6.75.0 for mvBlueFOX3 devices added. (all shipped packages for USB3 Vision devices) + Bugs fixed: + - USB2 compatibility improved. + + NEW FEATURES + - Buffers larger than 4 MB can be captured from U3V devices on Windows via USB2 now. (mvGenTLProducer.cti) + + BUGS FIXED: + - When a GEV device did send a PENDING_ACK command back to the host and the timeout (mvGenTLProducer.cti) + reported in this command did elapse, the host did send an invalid GEV packet back + to the device. + +10.02.2014 2.6.0 + DEPRECATED API CODE: + - Interface layout 'dilDeviceSpecific' has been declared deprecated for usage with (all shipped packages) + the mvGenTL_Acquire driver packages, thus for mvBlueCOUGAR-P, mvBlueCOUGAR-S, + mvBlueCOUGAR-X, mvBlueCOUGAR-XD and mvBlueLYNX-M7 devices. + + UPDATES: + - Firmware version 1.6.63.0 for mvBlueFOX3 devices added. (all shipped packages for USB3 Vision devices) + New features: + - Secure firmware update added, starting with this firmware all file updates will + be verified before being activated. + - mvBlueFOX3-1031G/C: Internal pixel clock increased to 75 MHz (was 68,75 MHz). + Now 30Hz@1920x1080 is possible. + Bugs fixed: + - GenCP pending acknowledge detection changed to a timer based version. + + CHANGED BEHAVIOUR: + - Interface layout 'dilGeneric' has been removed from the public interface. It had been (all shipped packages) + declared deprecated for more than a year now. This will not break existing binaries + but will require changes in the source during rebuilds. + - Improved IP address handling in mvIPConfigure: Setting of persistent IPs can now be (mvIPConfigure) + done directly without setting a temporary IP in advance. + + NEW FEATURES + - Initial support for U3V(USB3 Vision) on Linux added. (mvGenTL_Acquire-x86_*.tgz) + - mvBlueFOX devices support up to 256(instead of 64) HRTC steps now. (mvBlueFOX-lib) + - Added support for new tap geometries to the tap sort filter: 'cltxg1X2/cltyg1Y2', (all shipped packages) + 'cltxg2X/cltyg1Y2', 'cltxg2XE/cltyg1Y2' and 'cltxg2XM/cltyg1Y2'. Please note that all + these formats are currently not covered by the GenICam SFNC. + + BUGS FIXED: + - Potential crashes when a network interface was assigned a new IP-address, subnet mask (mvGenTLConsumer-lib) + or gateway and then afterwards 'DMR_UpdateDeviceList' or (mvGenTLProducer.cti) + 'mvIMPACT::acquire::DeviceManager::updateDeviceList' was called from a running + application. + - On Windows there was a small memory leak (approx. 60 KB) with each call to (mvGenTLProducer.cti) + 'DMR_UpdateDeviceList' or 'mvIMPACT::acquire::DeviceManager::updateDeviceList'. + (Bug introduced in version 2.5.17) + - On Windows there was a leak of 1 OS-handle with each call to (mvGenTLProducer.cti) + 'DMR_UpdateDeviceList' or 'mvIMPACT::acquire::DeviceManager::updateDeviceList'. + See 'known issues' in the documentation. + (Bug introduced in version 2.5.17) + - Potential crash when selecting an unsupported bits per pixel, pixels per cycle (mvHYPERIONfg-lib) + combination for a given pixel format. + - Potential deadlock when a new 'DMR_ImageRequestSingle' was executed while a pending (mvGenTLConsumer-lib) + 'DMR_ImageRequestReset' was being processed. + +20.01.2014 2.5.20 + UPDATES: + - Firmware version 1.6.42.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + Bugs fixed: + - LinescanMode (E2V-sensors): Correct overtrigger behaviour. + - mvBlueCOUGAR-X120bG: Device stopped responding when constantly + changing exposure values from the application. + New features: + - SequencerControl according to GenICam-SFNC. So far CCDs only. + - mvBlueCOUGAR-XD126G, mvBlueCOUGAR-XD126aG: 36MHz pixel clock enabled. + Changed behaviour: + - mvBlueCOUGAR-X105G: Sensor only supports a width increment of 2. + - mvBlueCOUGAR-3X120aG: Added support for two additional digital inputs, + removed Bayer formats. + + - Firmware version 1.6.42.0 for mvBlueFOX3 devices added. (all shipped packages for USB3 Vision devices) + Bugs fixed: + - LinescanMode (E2V-sensors): Correct overtrigger behaviour. + - Wrong pixel format info in leader when changing the 'PixelFormat' + (e.g. Mono10 -> Mono12). + - mvBlueFOX3-1013x, mvBlueFOX3-1020x: Use correct AOI now. + Changed behaviour: + - mvBlueFOX3-1031x: FrameStartTrigger disabled. + + CHANGED BEHAVIOUR: + - The GEV filter driver does no longer try to re-construct buffers that have already (mvGigECapture.sys, version 2.0.14.48) + been partially streamed from the device to the host when a capture buffer is arriving + late in the filter driver. This is now in sync. with the socket layer based + implementation. + + NEW FEATURES: + - New color correction matrix added: 'cticmmBlueFOX3_x031C_WPPLS' This will be used by (all shipped packages) + 'mvBlueFOX3-1031C' devices. + - New color correction matrices added: 'cticmmBlueCOUGAR_x21C_WPPLS' and (all shipped packages) + 'cticmmBlueFOX_x21C_WPPLS'. These will be used by 'mvBlueCOUGAR-Xx21C' and + 'mvBlueFOX-x21C' devices. + - mvBlueFOX3 devices with a damaged firmware image can be accessed again. When (mvGenTLProducer.cti) + detecting such a device the mvGenTLProducer.cti library will automatically upload a + working firmware image into the RAM of the device. However to permanently store a + firmware on the device another update using mvDeviceConfigure is needed afterwards. + + BUGS FIXED: + - Potential crashes when a GEV device lost network connectivity during a certain (mvGenTLConsumer-lib) + stage of the initialisation. + - Potential crash when a device did report a 'min' value larger than the 'max' value (wxPropView) + for a feature an this feature then got modified in the property tree by the user. + +14.01.2014 2.5.19 + UPDATES: + - Slightly improved error reporting for the GEV filter driver. (mvGigECapture.sys, version 2.0.13.47) + (mvGenTLProducer.cti) + CHANGED BEHAVIOUR: + - When using the command line parameters to update the device firmware the application (mvDeviceConfigure) + will also allow to downgrade the firmware now. Only firmware versions which are + exactly the same will be ignored. + + BUGS FIXED: + - Firmware update via command line did not work for mvBlueFOX3 devices if the (mvDeviceConfigure) + 'ipv4_mask' parameter was specified. + - Potential deadlock when a device did re-appear during a call to (mvGenTLConsumer-lib) + 'mvIMPACT::acquire::FunctionInterface::updateDeviceList' or 'DMR_UpdateDeviceList'. + +12.12.2013 2.5.18 + UPDATES: + - Firmware version 0x33 (51) for mvBlueFOX devices added. (mvBlueFOX-lib) + Changes: + - Fix for illegal endpoint size. Now only if CH9Fix-Bit in device EEPROM is set. + Needs mvIMPACT Acquire 1.11.10 or later on the host to to run. + - Firmware version 1.6.31.0 for mvBlueFOX3 devices added. (all shipped packages for USB3 Vision devices) + Bugs fixed: + - Booting host system with a camera already connected could lead to this device + becoming inaccessible. + - Triggermode also works after timeout. (needs mvIMPACT Acquire 2.5.18 or greater) + - mvBlueFOX3-1100x, -1140x: Switching to trigger mode could fail. + - mvBlueFOX3-1013x: Improved pixel sampling at low temperatures. + - mvBlueFOX3-1013x: Bad line in rolling shutter mode with some exposure times. + (E.g.: EV76C560 with exposure time = 2050 us) + + CHANGED BEHAVIOUR: + - In rare cases where a GigE Vision did not reboot after a firmware update the device (mvGenTLConsumer-lib) + driver will now report a timeout error after a certain amount of time instead of + never returning from the firmware update function. + + NEW FEATURES: + - The current progress of the firmware update is displayed when updating mvBlueCOUGAR (mvDeviceConfigure) + or mvBlueFOX3 devices now. (mvGenTLConsumer-lib) + - 'Chapter9TestCompatibilityEnable' property added for mvBlueFOX devices. (mvBlueFOX-lib) + (Requires Firmware version 0x33 (51) or greater) + - CHM version of mvBlueFOX3 manual added. (mvGenTL_Acquire*.msi) + + BUGS FIXED: + - 'mvIMPACT::acquire::GenICam::AcquisitionControl::mvResultingFrameRate' and (mvIMPACT_acquire_GenICam.h) + 'mv.impact.acquire.GenICam.AcquisitionControl.mvResultingFrameRate' did use an (mv.impact.acquire.dll) + incorrect data type. Was 'PropertyI64' and is now 'PropertyF'. + - In case 'ImageRequestTimeout_ms' did elapse for a single buffer queued for a U3V (mvGenTLProducer.cti) + device, sometimes multiple buffers currently queued have been signalled under + Windows Vista and greater (one with 'rrTimeout', all others with 'rrRequestAborted'). + +12.11.2013 2.5.17 + UPDATES: + - LAG link speed detection improved. (mvGenTLProducer.cti) + + NEW FEATURES: + - Firmware version 1.6.15.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + Bugs fixed: + - mvBlueCOUGAR-XD: LAG sometimes was not correctly configured when using + a persistent IP address. + - mvBlueCOUGAR-X102eG/C, mvBlueCOUGAR-X102eGE, mvBlueCOUGAR-X104eG/C: + Bad line in rolling shutter mode with some exposure times. + (E.g.: mvBlueCOUGAR-X102eG with exposure time = 2050us) + - mvBlueCOUGAR-X102bG/C did stop streaming when using exposure times > 12220us in + triggered mode. + + BUGS FIXED: + - U3V devices supporting events can be initialised now. (mvGenTLProducer.cti) + - 'ibpfMono12Packed_V1' (which corresponds 'Mono12p' from the PFNC specification) is (all shipped packages) + supported properly now. + - 'ImageRequestTimeout_ms' handling improved. Whenever one buffer timeout did expire (mvHYPERIONfg-lib) + all buffers currently queued have been returned to the application. + - The 'Connected To IPv4 Address' combo box as well as the (mvIPConfigure) + 'Local IP To Use For Sending' became read-only. + - Modifying the state of the hardware LUT in parallel with changing any other parameter (mvBlueFOX-lib) + except the 'Gain_dB' property did not update the LUT related parameters. + - Socket driver handles ChunkData correctly again. (mvGenTLProducer.cti) + (Bug introduced in version 2.5.15) + +17.10.2013 2.5.16 + DEPRECATED API CODE: + - The function 'DMR_UpgradeDeviceFeatures' has been declared deprecated. Since this (all shipped packages) + function never did perform any useful task there is no direct replacement. + + CHANGED BEHAVIOUR: + - All mvBlueLYNX (NOT mvBlueLYNX-X!) related stuff removed from mvIMPACT Acquire. This (all shipped packages) + is an internal change as the ppc603e based mvIMPACT Acquire package was never + officially released but also did result in some stuff being removed from the public + interface. The following stuff has been removed: + mvIMPACT::acquire::CameraSettingsBlueLYNX, mv.impact.acquire.CameraSettingsBlueLYNX, + TBlueLYNXCameraDataClipMode and TBlueLYNXCameraFlashMode. Please remove every + occurrence of any of those data types from your code. + - Improved image quality for mvBlueFOX-223 devices. (mvBlueFOX-lib) + + NEW FEATURES: + - Firmware version 1.6.4.0 for mvBlueFOX3 devices added. (all shipped packages for USB3 Vision devices) + - Property 'mvIMPACT::acquire::Request::chunkExposureTime' added. (mvIMPACT_acquire.h) + - .NET Property 'mv.impact.acquire.Request.chunkExposureTime' added. (mv.impact.acquire.dll) + + - Firmware version 1.6.5.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - Trigger 'FrameStart'/'mvTimestampReset' with 'AnyEdge'. + - PFNC compliant formats added. + - mvBlueCOUGAR-XD: PowerSaving properties for CCDs added. + - Support for 4 digital inputs for POEI added. + Bugs fixed: + - mvBlueCOUGAR-XD: Resend packets did contain invalid image data. + - Setting 'CounterValue' the first time after booting the device did not work. + - EV76C560: AOI changes sometimes where not visible in the first image. + - MT9M024/MT9M034: First trigger failed when switching to trigger mode. + - ICX415: Shadow in first lines when not using the full height of the sensor. + + BUGS FIXED: + - The display module as well as the analysis plots in wxPropView did mix up the lower (mvDisplay-lib) + 4 bits of 2 consecutive pixels. (wxPropView) + - In case 'ImageRequestTimeout_ms' did elapse for a single buffer queued for a U3V (mvGenTLProducer.cti) + device, sometimes all buffers currently queued have been signalled (one with + 'rrTimeout', all others with 'rrRequestAborted'). + - When an 'ImageRequestTimeout_ms' did elapse more or less at the same time an U3V (mvGenTLProducer.cti) + device did start streaming sometimes the stream did get out of sync resulting in a + lot of buffers being reported as corrupted. + - On systems running low on resources or with an extremely fragmented kernel space U3V (mvGenTLProducer.cti) + buffers sometimes did not completely cleaned up. + - Firmware version 0x32 (50) for mvBlueFOX devices added. (mvBlueFOX-lib) + Bugs fixed: + - Fix for illegal endpoint size on all mvBlueFOX-MLC. + Needs mvIMPACT Acquire 1.11.10 or later on the host to run. + +29.08.2013 2.5.15 + UPDATES: + - Improved the performance of the socket based GEV driver when working in LAG mode with (mvGenTLProducer.cti) + 2 links or more. + +23.08.2013 2.5.14 + CHANGED BEHAVIOUR: + - The old MFC based version of 'PropView' is no longer shipped as part of the examples. (all shipped MSI-based packages) + It has long been replaced by 'wxPropView'. Its source files are also part of the + installer packages but must be enabled explicitly during the installation. + + BUGS FIXED: + - 'GenICam::InterfaceModule::deviceLinkSpeed' and (mvGenTLProducer.cti) + 'GenICam::DeviceModule::deviceLinkSpeed' did report too large values for U3V devices. + - Trying to display an invalid buffer in 'ffBGR2BytePacked_V2' format could cause in a (mvDisplay-lib) + crash. + - With 'InterfaceLayout' set to 'dilDeviceSpecific' and 'ImageDestination/PixelFormat' (mvGenTLConsumer-lib) + set to a 'Mono' format, Bayer versions of the mvBlueCOUGAR-X did deliver unprocessed + Bayer images even when 'ImageProcessing/ColorProcessing' was set to 'Auto'. + (Bug introduced in version 2.4.0) + +12.08.2013 2.5.13 + CHANGED BEHAVIOUR: + - Class 'mvIMPACT::acquire::display::ImageDisplayWindow' does no longer allow a copy (mvIMPACT_acquire_display.h) + constructor or an assignment operator. + + UPDATES: + - Improved support for third party U3V and GEV devices that did not use the numerical (mvGenTLConsumer-lib) + pixel format values from their corresponding standard as numerical values in the + 'PixelFormat' enumeration in their GenICam XML file. + - Full 64-bit support added for mvTITAN and mvGAMMA boards. This will now allow to run (mvTITAN_mvGAMMA-x64.msi) + 64-bit applications with these boards on Windows. + - Migration to version 3.0.6.0 of libusbK for U3V devices. (mvGenTL_Acquire*.msi) + + NEW FEATURES: + - Property 'TimestampLatch' added to class 'mv.impact.acquire.GenICam.DeviceControl'. (mv.impact.acquire.dll) + - Property 'TimestampLatch' added to class (mvIMPACT_acquire_GenICam.h) + 'mvIMPACT::acquire::GenICam::DeviceControl'. + - New C# example application added to all packages: 'ContinuousCaptureAllDevices'. (all MSI-based shipped packages) + + BUGS FIXED: + - An attempt to open a U3V device that has either crashed or did report an invalid (mvGenTLProducer.cti) + value (0) for the 'Maximum Device Response Time' register could cause the driver to + lock up. + - Raw I/O mode enabled for the U3V streaming enabled. This fixes potential deadlocks (mvGenTLProducer.cti) + when asynchronously aborting the acquisition. + - When working with the Socket API based transport layer for GEV sometimes re-starting (mvGenTLProducer.cti) + the stream did not result in data being captured. + (Bug introduced in version 2.5.7) + - When calling 'DSStartAcquisition' with 'iNumToAcquire' greater than 0 the automatic (mvGenTLProducer.cti) + stop of the acquisition engine did sometimes continue to deliver buffers even after + the desired number of buffers had already been captured. + - Calling 'DSRevokeBuffer' after 'DSQueueBuffer' and 'DSFlushQueue' did always return (mvGenTLProducer.cti) + 'GC_ERR_INVALID_BUFFER' for U3V devices if no 'DSStartAcquisition' and + 'DSStopAcquisition' sequence was executed in between. + - Mirror filter did not correctly handle images where one dimension was smaller than 2 (all shipped packages) + or in YUV422Planar mode when one dimension was smaller than 4. + - Sometimes a 'pure virtual function call' exception was raised during the refresh of (mvGenTLConsumer-lib) + features defining a polling time in their GenICam XML file. + - With 'InterfaceLayout' set to 'dilDeviceSpecific' the features under 'Info/Camera' (mvGenTLConsumer-lib) + that provide write access could not be modified. + - Error message in log-file each time when modifying a digital output related property (mvGenTLConsumer-lib) + in 'DeviceSpecific' interface for mvBlueCOUGAR-P or mvBlueLYNX-M7 devices. + (Bug introduced in version 2.2.1) + - Example 'ContinuousCaptureAllDevices' could crash. (ContinuousCaptureAllDevices) + (Bug introduced in version 1.12.69) + - Pixel format 'ibpfBGR101010Packed_V2' can be displayed correctly again. (mvDisplay-lib) + (Bug introduced in version 2.4.0) + +29.07.2013 2.5.12 + UPDATES: + - GEV DISCOVERY commands will be sent without the 'allow broadcast' bit in the command (mvGenTLProducer.cti) + by default now as some devices then do not answer at all. The bit however will still + be used when running e.g. mvIPConfigure with the 'Advanced Device Discovery' option + enabled. + - A warning will be issued now when a device has been detected but cannot be used for (wxPropView) + whatever reasons at the moment. + + NEW FEATURES: + - New color correction matrices added: 'cticmmBlueCOUGAR_Xx04eC_WPPLS' and (all shipped packages) + 'cticmmBlueFOX3_x020C_WPPLS'. These will be used by 'mvBlueCOUGAR-X104eC' and + 'mvBlueFOX3-1020C' devices. + - Full 64-bit support added for mvDELTA and mvSIGMA boards. This will now allow to run (mvDELTA_mvSIGMA-x64.msi) + 64-bit applications with these boards on Windows. + + BUGS FIXED: + - Calling 'DSQueueBuffer' for a U3V data stream did result in a buffer being returned (mvGenTLProducer.cti) + immediately (mostly without consistent content). + - Each open/close iteration did increase the handle count of the current process by 7. (low level driver (oswin32-lib), Windows) + +23.07.2013 2.5.11 + UPDATES: + - Improved the detection of link speed changes on a network interface. (mvGenTLProducer.cti) + (mvGenTLConsumer-lib) + - New FPGA file for mvBlueFOX-22x devices added. This improves EMC compatibility for (mvBlueFOX-lib) + this devices. (FPGA version: 37). + + NEW FEATURES: + - New C# example application added to all packages: 'Callback'. (all MSI-based shipped packages) + - Initial version of hot-plug support for U3V devices added. (mvGenTLProducer.cti) + (mvGenTLConsumer-lib) + - Firmware version 1.5.102.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - GVCP-Capability bit 'test_data' is now supported, Test packets can now be filled + with verifiable test data according to the GEV specification. + Bugs fixed: + - Increasing 'DeviceClockfrequency' did not result in higher frame rates when + setting 'mvAcquisitionFrameRateLimitMode' to 'mvLegacy'. + (Bug introduced in firmware version 1.5.95.0) + - static versions of the functions 'gevGetEffectivePayloadPacketsPerImage', (mvIMPACT_acquire_GenICam.h) + 'gevGetEffectiveBytesPerImage', 'gevGetResultingBandwidth' and + 'gevGetResultingPacketDelayadded' added to class + 'mvIMPACT::acquire::GenICam::TransportLayerControl'. + - static versions of the functions 'gevGetEffectivePayloadPacketsPerImage', (mv.impact.acquire.dll) + 'gevGetEffectiveBytesPerImage', 'gevGetResultingBandwidth' and + 'gevGetResultingPacketDelayadded' added to class + 'mv.impact.acquire.GenICam.TransportLayerControl'. + + BUGS FIXED: + - mvBlueFOX-x00w: With the advanced option 'daoOnDemandTriggerPreShot' enabled (mvBlueFOX-lib) + and with 'OnDemand'-TriggerMode active could randomly cause corrupted images. + - mvBlueFOX-x05: Changing the exposure time sometimes did become effective with a (mvBlueFOX-lib) + delay of one frame. + - Increasing the 'RequestCount' above a certain value (16 or 21 depending on buffer (mvGenTLProducer.cti) + layout) did cause the acquisition to lock up with U3V devices. + - Converting Bayer data to RGB for buffers with a width smaller than 6 could cause (all shipped packages) + crashes on some Windows systems. + - Applying the 'GainOffsetKnee' filter to Bayer data for images with a width smaller (all shipped packages) + than 4 did result in crashes. + - Applying the 'AdaptiveEdgeSensing' filter to Bayer data for images with a width (all shipped packages) + than 4 did result in crashes when at least one gain did differ from 1.0. + - The 'SIPayloadFinalTransfer1Size' register of U3V devices was not set correctly (mvGenTLProducer.cti) + on a 64-bit system. This could e.g. result in images not being delivered. + - Calling 'FunctionInterface::imageRequestReset' several times with (mvGenTLProducer.cti) + 'AcquisitionStartStopBehaviour' to 'assbUser' could result in a deadlock. + - When opening a GenICam compliant device did fail wxPropView did crash when (wxPropView) + 'Settings -> Warn On Reduced Driver Performance' was active. + (Bug introduced in version 2.5.5) + +07.06.2013 2.5.10 + UPDATES: + - Just minor internal changes. Nothing new, nothing fixed. + +06.06.2013 2.5.9 + UPDATES: + - Improved write speed to GenICam features with the 'Cachable' attribute set to (mvGenTLConsumer-lib) + 'NoCache'. + + NEW FEATURES: + - Property 'defectivePixelsFound' added to class (mvIMPACT_acquire.h) + 'mvIMPACT::acquire::ImageProcessing'. + - Property 'defectivePixelsFound' added to class (mv.impact.acquire.dll) + 'mv.impact.acquire.ImageProcessing'. + - Added 'fffmTransmitCorrectionImage' to 'TFlatFieldFilterMode' enumeration. (all shipped packages) + - Added 'dcfmTransmitCorrectionImage' to 'TDarkCurrentFilterMode' enumeration. (all shipped packages) + - Added 'bcmPacked' and 'bcmLinearPacked' to 'TBayerConversionMode' enumeration. (all shipped packages) + + BUGS FIXED: + - Certain image dimensions (e.g. 2100x28 when converted from 'ibpfRGB888Packed' to (all shipped packages) + 'ibpfBGR888Packed' and vice versa) could cause crashes. + - Creating an mvIMPACT buffer from a request using pixel format 'ibpfYUV422Planar' (all shipped packages) + could cause crashes. + - Wizard button for file upload/download will become enabled when the 'FileSelector' (wxPropView) + feature is selected in the property grid now. + - When the 'ChannelSplit' filter was active and the destination format was set to (all shipped packages) + 'ibpfRGB888Packed' the format conversion was not executed. + - mvBlueFOX-x00w: First image after gain/expose change did still use the previous (mvBlueFOX-lib) + values. + (Bug introduced in version 2.5.0) + - In case of a failed white balance calibration the correct error codes will be written (all shipped packages) + to the 'WBResult' property now. + - Performing a white balance calibration with 'WBAoiMode' set to 'amCentered' on an (all shipped packages) + image with either the width or the height or both smaller or equal than 75 pixel did + crash at runtime. + - Calling 'DMR_OpenDevice' with a valid device handle and a NULL-pointer for 'hDrv' did (all shipped packages) + crash at runtime. + +23.05.2013 2.5.8 + CHANGED BEHAVIOUR: + - Reducing the request count will now release large chunks of memory which previously (all shipped packages) + had been locked for future usage. + - Getting a bitmap from 'mv.impact.acquire.Request.bitmapData' will also work for (mv.impact.acquire.dll) + images with a pitch, that is not a multiple of 4 now. + - 'mv.impact.acquire.LibraryPath.init' is called inside the constructor of (mv.impact.acquire.dll) + 'mv.impact.acquire.DeviceManager' now, thus an application does no longer has to do + this explicitly unless changes shall be applied to the search paths. + - Default values changed: (mvGenTLProducer.cti) + 'GenICam::InterfaceModule::mvDeviceCommandChannelTransmissionTimeout': Was 0 is 200. + 'GenICam::InterfaceModule::mvDeviceCommandChannelRetryCount': Was 0 is 3. + - When working with a setting with the deprecated property (all shipped packages) + 'mvIMPACT::acquire::ImageProcessing::mirrorMode' being activated it was not possible + to completely switch off mirroring with the newly introduced global mirror mode. + - Now mvHYPERION-SDI boards starts scanning the ancillary data with a higher user data (mvHYPERIONfg-lib) + id number. + + UPDATES: + - The GEV filter driver will try to map user-mode buffers in kernel space with page (mvGigECapture.sys, version 2.0.12.46) + priority 'high' now. This used to be 'normal' before. + - Improved zooming in and out of the image display using the scroll wheel. (wxPropView) + - Improved Bayer and mono data handling inside the 'DefectivePixel' filter. (all shipped packages) + + NEW FEATURES: + - Property 'mvLinearLogarithmicMode' added to class (mvIMPACT_acquire_GenICam.h) + 'mvIMPACT::acquire::GenICam::AnalogControl'. + - Property 'mvLinearLogarithmicMode' added to class (mv.impact.acquire.dll) + 'mv.impact.acquire.GenICam.AnalogControl'. + - All code that is signed using a code signing certificate will also be timestamped (all shipped MSI based packages) + now. + - Internal conversion filter added. When a device transfers in either of these formats: (all shipped packages) + 'ibpfMono12Packed_V1', 'ibpfMono12Packed_V2' or 'ibpfBGR101010Packed_V2', and at + least one post-processing filter can't deal with this format, the driver will now + silently convert this data into a suitable format if possible. + - Firmware version 1.5.95.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - mvBlueCOUGAR-X1010: DeviceClockFrequency 96 Mhz added. + - mvBlueCOUGAR-X102e: High dynamic range added (mvLinearLogarithmicMode). + Bugs fixed: + - CCD-sensors: Changing the exposure time was delayed by one frame when using long + exposure times. + - mvBlueCOUGAR-XD-124/126/129: Visible SUB-pulse in overlapped trigger mode. + - mvBlueCOUGAR-X102bG: Too bright images when using trigger mode. + - mvBlueCOUGAR-XD: Correct link speed after booting the host while the camera was + already up. + Changed behaviour: + - mvBlueCOUGAR-XD: PixelFormat '12BitPacked' became faster. + - TriggerSoftwareCommand became WriteOnly. + + BUGS FIXED: + - Setting 'GenICam::InterfaceModule::mvDeviceCommandChannelRetryCount' to 0 did result (mvGenTLProducer.cti) + in no commands being sent at all. + - Some newly introduced header files were missing in the Linux packages. (all shipped Linux packages) + (Bug introduced in version 2.5.7) + - Creating instances of the classes 'mv.impact.acquire.GenICam.SystemModule' (mv.impact.acquire.dll) + or 'mv.impact.acquire.GenICam.InterfaceModule' do no longer open the device passed + to the constructors. + - With 'LUTMode' set to direct and 'LUTImplementation' set to 'Software' the highest (all shipped packages) + possible pixel value was not affected by the LUT transformation. + - Fixed various minor issues not affecting user applications directly. (mvPropHandling-lib) + +07.05.2013 2.5.7 + CHANGED BEHAVIOUR: + - When the GEV filter driver detects packets belonging to a new frame that can't (mvGigECapture.sys, version 2.0.11.45) + be reconstructed safely as too much data is missing already (e.g. because at the + time the transmission of the frame did start there was no buffer to capture the + data into and the capture buffer did arrive inside the driver after large parts of + the buffer have already been lost) the remains of these frames are dropped now. + Previous versions did report these frames as incomplete with the remains of the data. + + UPDATES: + - Improved GEV acquisition streaming start speed. (mvGenTLProducer.cti) + - Added 'daoUseRawSensorGain' to the 'Camera/AdvancedOptions' property for (mv.impact.acquire.dll) + mvBlueFOX-x05 devices. + - Some common functions, templates and classes used in various example applications (all shipped packages) + moved into separate header files under $(MVIMPACT_ACQUIRE_DIR)/common. + + NEW FEATURES: + - Functions 'gevGetEffectivePayloadPacketsPerImage', 'gevGetEffectiveBytesPerImage', (mvIMPACT_acquire_GenICam.h) + 'gevGetResultingBandwidth' and 'gevGetResultingPacketDelayadded' added to + class 'mvIMPACT::acquire::GenICam::TransportLayerControl'. + - Functions 'gevGetEffectivePayloadPacketsPerImage', 'gevGetEffectiveBytesPerImage', (mv.impact.acquire.dll) + 'gevGetResultingBandwidth' and 'gevGetResultingPacketDelayadded' added to + 'mv.impact.acquire.GenICam.TransportLayerControl'. + + BUGS FIXED: + - Some code did rely on the SFNC feature 'PixelFormat' using the 'real' numerical (mvGenTLConsumer-lib) + values as the integer representation of the enumeration entries, thus the entry for + 'Mono8' for a GEV device was expected to have a numerical representation of + '0x01080001'. However the numerical values for SFNC enumerated features are not + covered by the standard thus in theory can be anything. + - Downloading the GenICam file from a device did align the amount of memory read to a (mvGenTLConsumer-lib) + 4-byte boundary. For transport layer technologies that are not restricted to a + certain alignment such as GenCP or U3V this could result in the device to complain + about too much memory being read. + - With 'Settings -> Property Grid -> Use Selector Grouping' active a read-only selector (wxPropGrid-lib) + automatically resulted in all selected features becoming read-only as well. + - Network adapters with an IPv4 address of 255.255.255.255 can discover GEV devices (mvGenTLProducer.cti) + now. + - Alignment restrictions reported by the 'SIInfo' register of a U3V device are handled (mvGenTLProducer.cti) + now. + +29.04.2013 2.5.6 + CHANGED BEHAVIOUR: + - The 'index' parameter of the constructors of the classes 'InterfaceModule' and (mvIMPACT_acquire_GenICam.h) + 'DataStreamModule' classes belonging to the 'GenICam' namespace have been changed (mv.impact.acquire.dll) + from int to int64 as the properties these values are obtained from also use 64-bit + integers. + + NEW FEATURES: + - Added 'daoUseRawSensorGain' to the 'Camera/AdvancedOptions' property for (mvBlueFOX-lib) + mvBlueFOX-x05 devices. + - Checks for potential performance issues added. (mvIPConfigure) + - LUT wizard will be available even if the 'LUTSelector' feature is not supported. (wxPropView) + + BUGS FIXED: + - Potential crashes in when working with the spatial noise histogram in one of the (wxPropView) + following pixel formats: 'ibpfRGB101010Packed', 'ibpfRGB121212Packed', + 'ibpfRGB141414Packed', 'ibpfRGB161616Packed', 'ibpfYUV444_UYV_10Packed' or + 'ibpfYUV444_10Packed'. + - Potential crashes when working with the 'DefectivePixelsFilter/Mode' property set to (all shipped packages) + 'dpfm3x3Median'. + - 'DefectivePixelsFilter/Mode' set to 'dpfm3x3Median' or 'dpfm3x1Average' is working (all shipped packages) + with 2-byte mono input pixel formats now. + +23.04.2013 2.5.5 + UPDATES: + - Various hyperlinks added (links to online documentation etc.) to 'Help' menus. (wxPropView) + (mvDeviceConfigure) + (mvGigEConfigure) + (mvIPConfigure) + - A warning will be issued now when driver performance issues are detected (e.g. a (wxPropView) + missing GEV filter driver). + - A warning will be issued now when multiple network adapters of the host system seem (mvIPConfigure) + to reside in the same subnet. + - A more sophisticated check for outdated firmware has been added for mvBlueCOUGAR-X, (mvDeviceConfigure) + mvBlueCOUGAR-XD and mvBlueFOX3 devices. + + BUGS FIXED: + - The state of the pixel histogram related features was not properly restored when (wxPropView) + closing and restarting the application. + - Multiple GEV events send in one network packet will be correctly forwarded as (mvGenTLProducer.cti) + multiple individual events by the producer now. + - Calling 'DMR_AllocImageBuffer' with pixel formats 'ibpfRGB101010Packed', (mvDeviceManager-lib) + 'ibpfRGB121212Packed', 'ibpfRGB141414Packed' or 'ibpfRGB161616Packed' did result in a + buffer set up for 'ibpfRGBx888Planar' with only the pixel format, width and height + set correctly. + - Working with a single buffer in the NDIS filter driver that is incomplete, can't be (mvGigECapture.sys, version 2.0.10.44) + reconstructed and has an infinite timeout resulted in the buffer never being returned + until 'imageRequestReset' was called. + - When working with 'AcquisitionStartStopBehaviour' to 'assbDefault' and just single (mvGenTLConsumer-lib) + buffers in the queue, due to long or delayed processing times internal calls to + 'AcquisitionStop' have been issued. This could rarely result in the next buffer being + returned with the result status 'rrRequestAborted'. + - The order of interfaces as reported by iterating over (mvGenTLConsumer-lib) + 'SystemModule::interfaceSelector' did not match the order of 'InterfaceModule' + instances, thus when using the selector value as the 'index' parameter for the + 'InterfaceModule' this did not always result in the correct interface instance being + created. + +10.04.2013 2.5.4 + NEW FEATURES: + - Property 'OffsetCorrection_pc' for mvBlueFOX-x02aG devices added. (mvBlueFOX-lib) + (mvIMPACT_acquire.h) + (mv.impact.acquire.dll) + +08.04.2013 2.5.3 + UPDATES: + - Added 'Why the MSI packages are that large' to the 'Installation from private setup (mvIMPACT_Acquire_API_C_manual) + routines' chapter of the documentation. (mvIMPACT_Acquire_API_CPP_manual) + (mvIMPACT_Acquire_API_NET_manual) + - Internal migration to IPP 7.1.1. (all shipped packages) + + NEW FEATURES: + - Property 'AcquisitionControl::mvResultingFrameRate' published. (mvIMPACT_acquire_GenICam.h) + (mv.impact.acquire.dll) + + CHANGED BEHAVIOUR: + - In 'SingleFrame' mode calling 'DMR_AcquisitionStart' or (mvGenTLConsumer-lib) + 'FunctionInterface::acquisitionStart' will return 'DMR_ACQUISITION_ENGINE_BUSY' now + if the current single frame acquisition has not finished before the next one shall be + started. + - The application now waits for previous single frame acquisitions to become ready (wxPropView) + before accepting a new acquisition request. The old behaviour can be enabled by + using the menu item 'Settings -> Allow Fast Single Frame Acquisition'. + + BUGS FIXED: + - mvIPConfigure could crash when updating the device list when U3V devices where (mvIPConfigure) + connected to the system and a U3V driver was installed. + +02.04.2013 2.5.2 + NEW FEATURES: + - The 'InfoPlot' can plot every PropertyI, PropertyI64 and PropertyF feature attached (wxPropView) + to a request of the current device now. + - New test image formats added: 'vdtmHorizontalBayer12Packed_V1Ramp' and (mvVirtualDevice-lib) + 'vdtmHorizontalBayer12Packed_V2Ramp'. + - Firmware version 1.5.80.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - New sensor supported: EV76C570 + Bugs fixed: + - Switching 'TriggerSource' from 'Software' to 'Line4' did trigger one image when + 'Line4' was high. + - In triggered mode applied new exposure times did become effective AFTER the next + trigger signal and not with the NEXT trigger signal. + (Bug introduced in firmware version 1.5.71.0) + - Class 'mvXLampControl' added to namespace 'mvIMPACT::acquire::GenICam' (C++) and (mvIMPACT_acquire.h) + 'mv.impact.acquire.GenICam' (.NET). (mv.impact.acquire.dll) + - Properties 'CameraSettingsVirtualDevice::tapsXGeometry' and (mvIMPACT_acquire.h) + 'CameraSettingsVirtualDevice::tapsYGeometry' published. (mv.impact.acquire.dll) + - Properties 'GenICam::InterfaceModule::mvDeviceCommandChannelTransmissionTimeout' and (mvIMPACT_acquire.h) + 'GenICam::InterfaceModule::mvDeviceCommandChannelRetryCount' added. (mv.impact.acquire.dll) + (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - The method 'mvIMPACT::acquire::Request::getComponentLocator' became public. (mvIMPACT_acquire.h) + - The method 'mv.impact.acquire.Request.getComponentLocator' became public. (mv.impact.acquire.dll) + - Internally a monotonic clock is used wherever possible (Linux only). (all shipped Linux packages) + + BUGS FIXED: + - The palette of the 'System.Drawing.Bitmap' instance returned by (mv.impact.acquire.dll) + 'mv.impact.acquire.Request.bitmapData' will actually use a grey-scale palette for + pixel format 'System.Drawing.Imaging.PixelFormat.Format8bppIndexed' now as stated in + the documentation. + - Fixed various minor issues regarding memory allocation. (mvBlueFOX-lib) + - mvBlueFOX3 devices did stay open after a firmware update when the application was not (mvDeviceConfigure) + terminated. + - When a sequence with acquisition mode 'MultiFrame' did terminate on Linux the (wxPropView) + application did lock up. + - mvTITAN-G1/mvGAMMA-G: When changing the gain and/or offset as well as the video (mvTITANfg-lib) + channel between 2 requests the gain/offset changes where lost. + - When a request timeout did elapse with 'AcquisitionMode' set to 'SingleFrame', the (mvGenTLProducer.cti) + 'RequestResult' did contain 'rrRequestAborted' instead of 'rrTimeout' for U3V + devices. + - When quickly requesting images with 'AcquisitionMode' set to 'SingleFrame' from U3V (mvGenTLProducer.cti) + devices, 'RequestResult' did contain 'rrFrameCorrupt' from time to time. + - The link speed for GEV devices supporting the link speed register is correctly (mvGenTLProducer.cti) + reported by the properties 'GenICam::InterfaceModule::DeviceLinkSpeed' and + 'GenICam::DeviceModule::DeviceLinkSpeed' now. + +19.03.2013 2.5.1 + NEW FEATURES: + - Property 'mv.impact.acquire.Request.bitmapData' and function (mv.impact.acquire.dll) + 'mv.impact.acquire.TImageBufferPixelFormat.asSystemDrawingImagingPixelFormat' added. + - mvBlueFOX3_technical_manuals.pdf added. (mvGenTL_Acquire*.msi) + + BUGS FIXED: + - mvBlueFOX-200wG/C devices will no longer offer the 'SlowClock' FPGA, which is (mvBlueFOX-lib) + supported by the MLC version only. + +14.03.2013 2.5.0 + CHANGED BEHAVIOUR: + - mvBlueFOX-x00w: First image after gain/expose change did still (mvBlueFOX-lib) + use the previous values. + - Flash was activated 2 times. + - Artifacts in the upper image area of the image. + - mvBlueFOX-x00w: Increased gain range (lower limit is -1dB now). (mvBlueFOX-lib) + - mvBlueFOX-x00w: Increased minimum exposure time to the minimum the sensor can (mvBlueFOX-lib) + actually work with properly. + - mvBlueFOX-x00w: Adjusted gain in HDR mode. (mvBlueFOX-lib) + - Version 1.1.10.8 of the kernel mode driver added. This driver is no longer WHQL (mvDELTA_mvSIGMA-x86_64-.msi) + certified. + - Version 1.1.4.13 of the kernel mode driver added. This driver is no longer WHQL (mvTITAN_mvGAMMA-x86_64-.msi) + certified. + - The name format for log-sections in mvDebugFlags.mvd has changed. (all shipped packages) + Was: , became: -', 'EnumPropertyI' and 'EnumPropertyI64'. + - Devices not supporting streaming channels are supported now. (mvGenTLConsumer-lib) + - Firmware update for mvBlueFOX3 devices is possible now. (mvDeviceConfigure) + (mvGenTLProducer-lib) + (mvGenTLConsumer-lib) + - New constant added to 'TRequestResult': 'rrDataAcquisitionNotSupported'. This will (all shipped packages) + e.g. be reported when attempting to capture data from a U3V or GEV device that does + not support stream channels. + - Documentation related merge modules added to installer packages. (all MSI-based shipped packages) + + BUGS FIXED: + - A mvBlueLYNX-X device can no longer be opened with 'DEVICE_ACCESS_CONTROL' more than (mvGenTLProducer-lib) + once. + +04.03.2013 2.4.2 + UPDATES: + - Added 'Relationship between driver, firmware, FPGA file and user settings' section (mvBlueFOX3 technical manual) + to the 'Quickstart' chapter of the documentation. (mvBlueCOUGAR-X technical manual) + (mvBlueLYNX-M7 technical manual) + - Added 'Running customized mvIMPACT Acquire MSI installers from other installation (mvIMPACT_Acquire_API_C_manual) + frameworks' to the 'Installation from private setup routines' chapter of the (mvIMPACT_Acquire_API_CPP_manual) + documentation. (mvIMPACT_Acquire_API_NET_manual) + + CHANGED BEHAVIOUR: + - The method 'mv.impact.acquire.helper.RequestReadyEventArgs.unlockData' became (mv.impact.acquire.dll) + 'internal', the method 'mv.impact.acquire.helper.RequestReadyEventArgs.lockData' + became a property 'mv.impact.acquire.helper.RequestReadyEventArgs.data'. Instead of + 'mv.impact.acquire.helper.RequestReadyEventArgs.unlockData', + 'mv.impact.acquire.helper.RequestReadyEventData.Dispose' must be called now. + + NEW FEATURES: + - 'mv.impact.acquire.Request.getIMPACTImage' function added. This can be used to get (mv.impact.acquire.dll) + a handle that can be used to create a 'mvIMPACT_NET.Image' object. + - New C# example application added to all packages: 'CameraDescriptions'. (all MSI-based shipped packages) + + BUGS FIXED: + - When images where displayed in one format and then in a different format which did (mvDisplay-lib) + use the same amount of bytes per buffer but a different width and/or height the + displayed images where not correct. + - When the required payload size for a U3V device did change and data has been acquired (mvGenTLProducer.cti) + into a buffer before then capturing data in this buffer with reduced payload size did + fail. + - PFNC compliant pixel formats 'BGRa8' ('ibpfRGBx888Packed' in mvIMPACT Acquire) and (mvGenTLConsumer-lib) + 'YUV8_UYV' ('ibpfYUV444_UYVPacked' in mvIMPACT Acquire) are supported correctly now. + - Driver crash during Windows8_64 power off. (low level mvHYPERION driver, Windows) + - In Windows standby mode, after re-enabling the mvHYPERION grabber no data acquisition (low level mvHYPERION driver, Windows) + was possible from mvHYPERION-CLm/CLf/SDI devices. + - Writing non-binary data to a string property and then reading back that data in (mvPropHandling-lib) + binary format could cause crashes if the non-binary data was shorter than 4 bytes. + - Fixed various minor issues regarding memory allocation. (all shipped packages) + +22.02.2013 2.4.1 + UPDATES: + - Added 'Acquisition Start/Stop Behaviour' section to 'How the capture process works' (all shipped packages) + chapter to the API documentation. + - Added 'Relationship between driver, firmware and FPGA file' section to the (mvBlueFOX technical manual) + 'Quickstart' chapter of the documentation. + + CHANGED BEHAVIOUR: + - The following properties have been removed from the public interface as they are not (all shipped packages) + exposed by the framework anyway thus have never been available: + 'GenICam::acquisitionStart', 'GenICam::acquisitionStop', 'GenICam::acquisitionAbort'. + - The shift feature introduced in version 2.4.0 will clip pixels that have a too large (all shipped packages) + value to be displayed to the maximum value instead of just masking the higher bits + now. + + NEW FEATURES: + - New property published in 'SystemSettings': 'AcquisitionIdleTimeMax_ms' (all shipped packages) + + BUGS FIXED: + - Color correction matrices for mvBlueCOUGAR-XD104C, mvBlueCOUGAR-XD104aC, (all shipped packages) + mvBlueCOUGAR-XD104bC, mvBlueCOUGAR-XD124bC, mvBlueCOUGAR-XD126aC and + mvBlueCOUGAR-XD129aC devices will be correctly selected when setting + 'ColorTwistInputCorrectionMatrix' to 'DeviceSpecific' now. + - 'Statistics/FramesPerSecond' property converges towards the actual value with (all shipped packages) + 'normal' speed again. + (Bug introduced in version 2.4.0) + - 'GenICamInterfaceLayout' example does no longer crash on Linux. (all shipped Linux packages) + - The 'mvUserData' property of an mvBlueCOUGAR-X or mvBlueCOUGAR-XD device is no longer (mvGenTLConsumer-lib) + stored in a setting/restored from a setting. As this feature is stored in + non-volatile device memory restoring this value would modify the data in the device + which is not wanted. + - imageRequestSingle on Linux did always return an error. (mvHYPERIONfg-lib) + - Building low level drivers for Linux failed. (low level mvHYPERION driver, Linux) + - For images in pixel format 'ibpfBGR101010Packed_V2' the red and the blue channel have (mvVirtualDevice-lib) + been flipped. + - For images in pixel format 'ibpfBGR101010Packed_V2' the 'ChannelSplit' filter did (all shipped packages) + split in BGR order instead of RGB as for all other RGB and BGR formats. + +15.02.2013 2.4.0 + UPDATES: + - Further improved resend behaviour for GEV devices. Fine-tuned some default (mvGigECapture.sys, version 2.0.9.43) + parameters. (mvGenTLProducer.cti) + - The device selection ComboBox as well as the title bar will contain the value of the (wxPropView) + 'DeviceID' property of the selected device now. + - Slightly improved usability of the 'Assign Temporary IPv4 Address' dialog. (mvIPConfigure) + - Improved error handling in case of low system resources (GEV only). (mvGenTLProducer.cti) + + CHANGED BEHAVIOUR: + - The U3V kernel driver will be installed by default now. (mvGenTL_Acquire*.msi) + - The properties 'Request::infoFrameID' and 'Request::infoFrameNr' are reported as 64 (all shipped packages) + bit integers now. Applications compiled with this version of the interface MUST + update mvPropHandling-lib on the target system when accessing these properties! + + NEW FEATURES: + - Overloaded method for 'mv.impact.acquire.Property.readS' added that takes an input of (mv.impact.acquire.dll) + 'TPropertyLimits'. + - For images with more than 8 bits per pixel per channel the left and right arrow keys (wxPropView) + can be used to select which bits shall be displayed now. + - New function added: 'mvDispSetShift', 'mvDispGetShift', 'mvDisplayGetAppliedShift', (mvDisplay-lib) + - New function added: 'mvIMPACT::acquire::display::ImageDisplay::GetShift', (mvIMPACT_acquire_display.h) + 'mvIMPACT::acquire::display::ImageDisplay::SetShift', + 'mvIMPACT::acquire::display::ImageDisplay::GetAppliedShift'. + - New properties added: 'mv.acquire.display.ImageDisplay.shift', (mv.impact.acquire.display.dll) + 'mv.acquire.display.ImageDisplay.appliedShift' + - Added support for 'DeviceTemperature' and 'DeviceTemperatureSelector' for (mvGenTLProducer.cti) + mvBlueLYNX-X devices. + - New classes added: 'mv.impact.acquire.helper.RequestProvider', (mv.impact.acquire.dll) + 'mv.impact.acquire.helper.RequestReadyEventArgs' and + 'mv.impact.acquire.helper.IRequestBuffer. + - 'cltxg4X2E' added to 'TCameraTapsXGeometry'. (mvTITANfg-lib) + (mvHYPERIONfg-lib) + (mvVirtualDevice-lib) + (mv.impact.acquire.dll) + - New C# example applications added to all packages: 'DigitalIOs', (all shipped MSI-based packages) + 'GenICamInterfaceLayout', 'Properties', 'ContinuousCaptureSimple'. + - New property published in 'ChannelSplit' filter: 'channelSplitDeinterlaceEnable' (all shipped packages) + - Color correction matrices added: 'cticmmBlueCOUGAR_Xx04C_WPPLS' and (all shipped packages) + 'cticmmBlueCOUGAR_Xx04aC_WPPLS'. These will be used by mvBlueCOUGAR-X104C and + mvBlueCOUGAR-X104aC devices. + + BUGS FIXED: + - Capturing to user supplied memory with 'InterfaceLayout' set to 'dilDeviceSpecific' (mvGenTLConsumer-lib) + did not work with mvBlueCOUGAR-X devices that came up with a GEV pixel format that + was using more than one channel. + - In rare cases (when the current working directory on Linux became invalid) (all shipped Linux packages) + starting a mvIMPACT Acquire based application could crash. + - When Bayer images where generated by setting the properties 'Camera/PixelFormat' and (mvVirtualDevice-lib) + 'Camera/BayerMosaicParity' the driver internal de-Bayer filter did not process the + images in 'Auto' mode. + +31.01.2013 2.3.4 + BUGS FIXED: + - Fixed some compiler warnings. (mvHYPERIONfg-lib) + +30.01.2013 2.3.3 + UPDATES: + - Default values when using the filter driver changed: 'ResendResponseTimeout_ms' (mvGigECapture.sys, version 2.0.8.42) + changed from 2 to 3. + + BUGS FIXED: + - The buffers internally allocated used 1 byte too much memory. This could cause a (mvGenTLProducer.cti) + decrease in the overall performance because of redundant reallocations. + (Bug introduced in version 2.0.9) + - Improved resend behaviour when working in LAG mode with 2 links or more. Sometimes (mvGigECapture.sys, version 2.0.8.42) + parts of frames that already have been captured completely where requested for + resend. + - Timestamps for U3V devices will correctly be reported in us by the framework now. (mvGenTLProducer.cti) + - Temporary aborting a running acquisition by calling (mvGenTLProducer.cti) + 'FunctionInterface::imageRequestReset' could cause incorrect behaviour. + (Bug introduced in version 2.3.2) + - Improved FrameStart Activation LevelHigh/LevelLow. Previous versions did not (mvHYPERIONfg-lib) + correctly work with this trigger event. + +23.01.2013 2.3.2 + CHANGED BEHAVIOUR: + - Migration to the official version 1.0 of the USB3 Vision standard. This required some (mvGenTLProducer.cti) + changes in internal data structures. Only devices compliant with version 1.0 of the + standard will be supported now. + + NEW FEATURES: + - First version that adds .NET/Mono support for mvBlueLYNX-X devices. (mvBlueLYNX-X firmware) + + BUGS FIXED: + - When calling 'FunctionInterface::imageRequestSingle' after calling (mvGenTLProducer.cti) + 'FunctionInterface::acquisitionStart' on a mvBlueLYNX-X device an error was logged, + but the request was not properly processed. This did result in the function + 'FunctionInterface::imageRequestReset' not returning when called. + - Continuous acquisition from a USB3 Vision device did sometimes stop when e.g. post (mvGenTLProducer.cti) + processing of images took longer then the time between 2 consecutive images delivered + by the device. + - RealTimeController Opcode Jump, writing jump address corrected. (mvHYPERIONfg-lib) + +18.01.2013 2.3.1 + NEW FEATURES: + - New sample added to all packages: 'ContinuousCaptureOnlyProcessLatest'. (all shipped MSI-based packages) + - Added 'CPU Idle States Enabled' option (Windows only). (mvDeviceConfigure) + - Firmware version 1.5.61.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - EV76C560/EV76C661: AEC and AGC implemented. + - Random delay added to discovery acknowledge as required by the GEV + specification, improves the detection of all cameras when there are many + cameras connected to one subnet. + Changed behaviour: + - Streaming indication (LED color GREEN) is triggerd by FrameStart not by + AcquisitionStart. + Bugs fixed: + - CCD sensors sometimes did deliver corrupt image data. + (Bug introduced in firmware version 1.5.18.0) + + BUGS FIXED: + - Trying to close an unplugged mvBlueFOX fitted with a motor focus module did crash (mvBlueFOX-lib) + at runtime. + +11.01.2013 2.3.0 + CHANGED BEHAVIOUR: + - mvBlueCOUGAR-msi packages have been renamed to mvGenTL_Acquire-msi. Some libraries (mvBlueCOUGAR.msi -> mvGenTL_Acquire.msi) + belonging to these packages also changed their name: mvBlueCOUGAR-lib became (mvBlueCOUGAR-lib -> mvGenTLConsumer-lib) + mvGenTLConsumer-lib, mvTLIClientGigE.cti became mvGenTLProducer.cti. This change (mvTLIClientGigE.cti -> mvGenTLProducer.cti) + became necessary as by now a much wider range of products(e.g. mvBlueFOX3, + mvBlueLYNX-X) is supported by this package and therefore the names became misleading. + The old files are still part of the package but are not installed by default any more. + See 'Installation from private setup routines' for details. + + UPDATES: + - On 64-bit Windows now both 32-bit and 64-bit processes can access the GenICam runtime (mvGenTL_Acquire.msi) + at the same time. This required a change in the way the GenICam runtime is installed (mvGenTL_Acquire-x64.msi) + on the target system. See 'Installation from private setup routines' for details. + - Added some missing stuff to the documentation. (all shipped packages) + - 'Done' button added to close the application. (mvGigEConfigure) + - The 64-bit MSI installers do no longer create a desktop shortcut to mvDeviceConfigure.(all shipped MSI-based packages) + + BUGS FIXED: + - 'CaptureToUserMemory' works with 'AcquisitionStartStopBehaviour' set to 'assbUser' (all shipped packages) + - When sending multi-byte Bayer data to the internal de-Bayer algorithm with (all shipped packages) + 'ColorProcessing' set to 'cpmBayerToMono' did result in incorrect results on + multi-core systems. + - unmap user memory works now. Previous version did not unmap user memory if working in (mvHYPERION2.sys, version 2.1.36.44) + a 32-bit process on a 64-bit version of Windows. (mvHYPERION.sys, version 1.0.51.53) + - Properties in mv.impact.acquire.Connector did always refer to the first device in (mv.impact.acquire.dll) + the list of open devices supporting this feature even if the object was created with + a reference to a different device. + - Instances of mvIMPACT::acquire::CameraSettingsBase did always refer to the setting (mvIMPACT_acquire.h) + 'Base' as the parameter 'settingName' was not forwarded to the base class + constructor. + +20.12.2012 2.2.2 + UPDATES: + - Reading the current state of a digital input in 'DeviceSpecific' interface layout (mvBlueCOUGAR-lib) + is faster now. + - The saturation wizards have been re-factored an became a single 'Color Correction' (wxPropView) + wizard. + + NEW FEATURES: + - Firmware version 1.5.58.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - mvBlueCOUGAR-XD supports 8 counters now. + Changed behaviour: + - 'mvAcquisitionFrameRateAuto' is only available for mvBlueCOUGAR-XD devices now. + Bugs fixed: + - Auto Gain Control did not work correctly with multi-tap sensors. + - Writing a char string without a terminating \0 to 'DeviceUserID' + (called 'UserDefinedName' in mvIPConfigure.exe or called 'DeviceID' + in the Device list) caused malfunction concerning EEPROM entries. + - Corrupt images with -X105G/105C. + (Bug introduced in firmware version 1.5.51.10) + - If a 'DeviceUserID' longer than 15 Chars was written, than the camera + it listed with serial number '00:00:00:00:00:00 ()' and opening is NOT possible + any more. + - New properties published in C++ and .NET interface: (mvIMPACT_acquire.h) + colorTwistInputCorrectionMatrixEnable, colorTwistInputCorrectionMatrixMode, (mv.impact.acquire.dll) + colorTwistInputCorrectionMatrixRow0, colorTwistInputCorrectionMatrixRow1, + colorTwistInputCorrectionMatrixRow2, colorTwistOutputCorrectionMatrixEnable, + colorTwistOutputCorrectionMatrixMode, colorTwistOutputCorrectionMatrixRow0, + colorTwistOutputCorrectionMatrixRow1, colorTwistOutputCorrectionMatrixRow2, + colorTwistResultingMatrixRow0, colorTwistResultingMatrixRow1 and + colorTwistResultingMatrixRow2. + + BUGS FIXED: + - With 'LUTInterpolationMode' set to 'Cubic' and 'LUTImplementation' set to 'Hardware' (mvBlueFOX-lib) + the resulting LUT was incorrect. (mvBlueCOUGAR-lib) + - Simultaneous acquisition from both input channels improved. Previous driver versions (mvHYPERIONfg-lib) + had some errors if both input channels did run with different frame rates. + - 'SingleCapture' for C# works with 'AcquisitionStartStopBehaviour' set to 'assbUser' (all shipped MSI-based packages) + now. + +17.12.2012 2.2.1 + UPDATES: + - Modifying the digital outputs in 'DeviceSpecific' interface layout is faster now. (mvBlueCOUGAR-lib) + + NEW FEATURES: + - Firmware version 1.5.51.10 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - Support for mvBlueCOUGAR-X1010G devices + - FrameEndEvent implemented. + Bugs fixed: + - Modifying the gain while AEC and AGC is active resulted in incorrect automode. + - CMV2000/CMV4000 FrameStartTrigger: First trigger failed. + - The user will be notified now if 2 products with different firmware versions are (wxPropView) + detected in mvDeviceConfigure or a device with an outdated firmware is opened in (mvDeviceConfigure) + wxPropView. + - Further improved API documentation: Added [in], [out] and [in, out] statements to (all shipped packages) + all function parameters. + - 'SingleCapture' for C# added. (all shipped MSI-based packages) + +13.12.2012 2.2.0 + UPDATES: + - Added some new message boxes in order to tell the user exactly what is the problem (mvGigEConfigure) + when installing/removing the GEV filter driver fails. + + CHANGED BEHAVIOUR: + - Some 'Access violation' exceptions internally raised during run-time type checks (mvTLIClientGigE-lib) + replaced by a different internal exception with error code 'GC_ERR_INVALID_HANDLE' as + the 'Access violation' exception did trigger certain debuggers(e.g. Delphi XE2 and + XE3) even if handled internally. + + NEW FEATURES: + - Redesign of documentation: (all shipped packages) + - Splitted documentation into product specific technical manual and a separate + document for each supported programming language. + - Added .NET specific documentation. + - Updated from Doxygen 1.5.8 to 1.8.2 resulting in a much nicer output. + - Added a nice search Window in the online versions of the documentation. + - Added 'Deprecated' section to the SDK manuals. + - Added automatic links to examples in the sections describing a certain function. + + BUGS FIXED: + - Start acquisition -> stop acquisition -> reduce request count -> start acquisition -> (mvBlueCOUGAR-lib) + stop acquisition -> increase request count above the initial value -> start + acquisition sequences did sometimes return requests with the 'Result' property set to + 'rrUnprocessibleRequest'. + - Calling 'DSGetBufferInfo' with 'BUFFER_INFO_SIZE_FILLED' always returns the correct (mvTLIClientGigE-lib) + value now. (mvGigECapture.sys, version 2.0.7.41) + - Calling 'OBJ_GetHandleEx' with a path(e.g. Camera/Gain_dB) from a list, that contains (mvDeviceManager-lib) + a sub-list 'Camera' and a 'property 'Gain_dB' in that list will return a valid handle + now. + - When trying to assign a user defined name longer than supported by the device via (mvTLIClientGigE-lib) + mvIPConfigure the string sent to the device was not terminated by '\0'. + - Potential crashes when shutting down the device manager after a failed attempt to (mvTLIClientGigE-lib) + open a U3V device. + - Sometimes the streaming of a U3V device did not start. (mvTLIClientGigE-lib) + +03.12.2012 2.1.4 + CHANGED BEHAVIOUR: + - mv.impact.acquire.RTCtrProgram.setProgramSize removed. Added a setter to the property (mv.impact.acquire.dll) + mv.impact.acquire.RTCtrProgram.programSize instead. + - mv.impact.acquire.IOSubSystem.pulseStartConfiguration became (mv.impact.acquire.dll) + mv.impact.acquire.IOSubSystem.getPulseStartConfiguration, + mv.impact.acquire.DeviceManager.deviceBaseList became + mv.impact.acquire.DeviceManager.internalHandle, + mv.impact.acquire.IOSubSystem.RTCtrProgram became + mv.impact.acquire.IOSubSystem.getRTCtrProgram to match the C++ implementation. + - mv.impact.acquire.Component.flagsAsString became a method. (mv.impact.acquire.dll) + - Return value type of + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.defineDigitalSignal, (mv.impact.acquire.dll) + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.definePulse, + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.definePulseSequence, + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.definePassThroughSignal, + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.defineLineScanPulse, + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.undefineSignal and + mv.impact.acquire.OutputSignalGeneratorFrameGrabber.getValidSignalsForPassThroughModes + changed from bool to int to match the C++ implementation. + + NEW FEATURES: + - mvIMPACT::acquire::CameraDescriptionManager::getTotalCameraDescriptionCount added to (mvIMPACT_acquire.h) + C++ interface to match with the .NET implementation. + + BUGS FIXED: + - Missing class mv.impact.acquire.DigitalIOMeasurementControl added. (mv.impact.acquire.dll) + - Missing property mv.impact.acquire.PropertyS.binaryDataBufferMaxSize added. (mv.impact.acquire.dll) + - mvBlueFOX-x02bG/C: On some systems after the initialisation the image was either too (mvBlueFOX-lib) + dark or no images have been delivered at all. + +26.11.2012 2.1.3 + CHANGED BEHAVIOUR: + - 'DeviceSpecific' and various mvBlueFOX and mvBlueCOUGAR-XD specific color correction (all shipped packages) + matrices added to 'ColorTwistInputCorrectionMatrixEnable'. If the used sensor is + known a matching color correction matrix will be used if + 'ColorTwistInputCorrectionMatrixEnable' is set to 'DeviceSpecific', which is the + default. + + NEW FEATURES: + - Firmware version 1.5.32.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - The 'FrameBurstStart' trigger in conjunction with the 'AcqusitionFrameBurstCount' + allows to trigger multiple bursts of images. + - mvBlueCOUGAR-X102b: The auto modes can be done inside the device's FPGA as well + now, not only within the image sensor. + - mvBlueCOUGAR-X102d: Sensor specific auto exposure is working now. + - New pixel formats: Mono12, Mono14. + - Support for mvBlueCOUGAR-XD124a, mvBlueCOUGAR-XD126, mvBlueCOUGAR-XD129 added. + - mvBlueCOUGAR-X102e: global shutter without reset is possible now. + - mvBlueCOUGAR-XD: auto white balance, auto exposure, auto gain and binning is + working now. + - mvBlueCOUGAR-X125aG/C: Extended temperature range. + - Minimum gain can be used for 'mvGainAutoLowerLimit'. + - CMV2000/CMV4000: New ExposureMode 'TriggerWidth' implemented. + Changed behaviour: + - 'WhiteBalanceRatio' working range increased: Maximum is 8 now. + - mvBlueCOUGAR-XD: Resend functionality disabled. + Bugs fixed: + - mvBlueCOUGAR-XD: 'mvGevSCBW' bandwidth setting, calculation also takes the number + of links into account now. + - mvBlueCOUGAR-X125aC works under LabVIEW again. + - The real inter-packet delay, controlled by 'GevSCPD' and 'mvGevSCBW' was + slightly to short. + - Correction of the Format 'BGR10V2Packed': Red and blue flipped. + - When the ratio between red and blue was adverse the resulting colors of the + 'WhiteBalanceRatio' settings have not been correct. + - mvBlueCOUGAR-X105: Noise after startup eliminated. + - Depending on the selected format and AOI and with activated chunk data the + delivered frames could have been incomplete. + - Writing AnalogGain no longer stops the AGC. + + BUGS FIXED: + - mvBlueFOX-x00w: First image after gain/expose change did still use the previous (mvBlueFOX-lib) + values. Old behaviour can be activated by enabling the AdvancedOptions bit + 'daoPipelinedGainExposeControl'. + - SD-NTSC (125M487i60) format corrected to 720x486. (mvHYPERIONfg-lib) + - When registering a callback to a GenICam event feature such as (mvBlueCOUGAR-lib) + mv.impact.acquire.GenICam.eventExposureEndTimestamp under 64-bit Windows the + application did crash upon the first event delivery. + - For some properties with a registered user callback the callback was executed a (mvBlueCOUGAR-lib) + second time when reading the new value of the property as a result of the callback. + - The default minimum value for floating point properties was DBL_MIN instead of (all shipped packages) + -1. * DBL_MAX. + - The methods 'I2CRead' and 'I2CWrite' of mv.impact.acquire.I"CControl became public as (mv.impact.acquire.dll) + in C/C++. + +16.11.2012 2.1.2 + CHANGED BEHAVIOUR: + - mv.impact.acquire.EnumPropertyF is a Generic class now. (mv.impact.acquire.dll) + + BUGS FIXED: + - mv.impact.acquire.OutputSignalGeneratorBlueDevice allows access to digital outputs (mv.impact.acquire.dll) + now. + - Internal checks for certain versions of a specification did not always work (mvTLIClientGigE-lib) + correctly. E.g. when a device claimed to be compliant with version 2.0 of the GEV + spec. features requiring GEV 1.1 where not accessed. + - Sometimes the GEV capture driver did report 'rrNotEnoughMemory' even if this error (mvGigECapture.sys, version 2.0.5.39) + has not been raised internally. (mvTLIClientGigE-lib) + (Bug introduced in version 2.1.0) + - Missing public properties added: mv.impact.acquire.EnumPropertyI.listOfValidValues, (mv.impact.acquire.dll) + mv.impact.acquire.EnumPropertyF.listOfValidValues. + - mvBlueFOX-x02dG/C: Low light mode was internally reset when changing certain camera (mvBlueFOX-lib) + parameters. + - Changing parameters in the currently selected camera description list did (mvTITANfg-lib) + automatically set the value of 'Connector/CameraOutputUsed' to 'coAuto' for + mvTITAN-RGB/G3, mvTITAN-RGB/G4, mvTITAN-CL and mvGAMMA-CL boards. + - Changing the property 'DigitalOutputs/ControlMode' did automatically set the (mvTITANfg-lib) + value of all 'Mode' properties of the digital outputs to 'Manual' for mvTITAN-CL and + mvGAMMA-CL boards. + - The first delivery of a GenTL event to a registered user callback could result in the (mvBlueCOUGAR-lib) + callback being executed twice. (mvPropHandling-lib) + + NEW FEATURES: + - 'PseudoFloatEnumProp' property added. (mvVirtualDevice-lib) + - 'I2CDeviceSubAddressWidth' can be set to 0 for devices not supporting a sub-address (mvBlueFOX-lib) + now. + - 'DMR_GetVersion', 'mvIMPACT::acquire::DeviceManager::getVersionAsString' and (mvDeviceManager-lib) + 'mv.impact.acquire.DeviceManager.getVersionAsString' added. (mv.impact.acquire.dll) + +12.11.2012 2.1.1 + BUGS FIXED: + - GEV 2.0 events(using the 64-bit block ID) will be correctly forwarded by the producer (mvTLIClientGigE-lib) + now. + +06.11.2012 2.1.0 + CHANGED BEHAVIOUR: + - Constructors of classes mv.impact.acquire.Component and mv.impact.acquire.Property (mv.impact.acquire.dll) + became public as in C/C++. + + NEW FEATURES: + - Initial support for U3V(USB3 Vision) added. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + - NEON optimized version of Bayer decoder added for mvBlueLYNX-X devices. (mvBlueCOUGAR-lib) + + BUGS FIXED: + - mv.impact.acquire.Property.readSArray without the delimiter parameter inserts a (mv.impact.acquire.dll) + single whitespace between the values now as in C/C++. + - Storing and restoring calibration data for the 'DefectivePixelsFilter' does work (all shipped packages) + again. + (Bug introduced in version 1.6.8) + - Calling 'DSGetBufferInfo' with 'BUFFER_INFO_PIXELFORMAT', 'BUFFER_INFO_WIDTH', (mvTLIClientGigE-lib) + 'BUFFER_INFO_HEIGHT', 'BUFFER_INFO_XOFFSET', 'BUFFER_INFO_YOFFSET', + 'BUFFER_INFO_XPADDING' or 'BUFFER_INFO_YPADDING' will return 'GC_ERR_NOT_AVAILABLE' + if the payload type of the buffer is reported as 'PAYLOAD_TYPE_CHUNK_DATA' and + either an image is not present or it is not known if an image is present in the + buffer. + - Calling 'DSRevokeBuffer' for a buffer that was allocated inside the producer will (mvTLIClientGigE-lib) + reset 'pBuffer' to 0 now. + - Potential blue screen (BSOD) on Windows systems running low on resources. (mvGigECapture.sys, version 2.0.5.39) + - GigE Vision streaming protocol blocks with more than 16383 payload packets can be (mvTLIClientGigE-lib) + captured now. + - Removing the last value from a property did always work even if it was the last value (mvPropHandling-lib) + and also if the property did specify the 'cfFixedSize' flag. + +30.10.2012 2.0.17 + UPDATES: + - Internal conversion from 'YUV444_UYVPacked' and 'YUV444Packed' to packed RGB and BGR (all shipped packages) + formats improved. The new version is up to 10 times faster depending on the + processor. + + CHANGED BEHAVIOUR: + - The default user set can be restored via 'UserSetSelector' = 'Default' and then (mvTLIClientGigE-lib) + calling 'UserSetLoad' now. It is no longer possible to overwrite this default + setting using 'UserSetSave'. + + BUGS FIXED: + - 'DEVICE_INFO_ACCESS_STATUS' will be reported as an INT32 now. This used to be UINT32. (mvTLIClientGigE-lib) + - Calling 'TLOpenInterface' with a known ID but without calling 'TLUpdateInterfaceList' (mvTLIClientGigE-lib) + before is working now. + - Calling 'IFOpenDevice' with a known ID but without calling 'IFUpdateDeviceList' (mvTLIClientGigE-lib) + before is working now. + - Calling 'DSAllocAndAnnounceBuffer' could fail with 'GC_ERR_INVALID_PARAMETER' and (mvTLIClientGigE-lib) + the last error message being set to 'invalid alignment' even if all parameters + passed to the function where correct. + +25.10.2012 2.0.16 + CHANGED BEHAVIOUR: + - Devices operated in interface layout 'dilGenICam' will return (mvBlueCOUGAR-lib) + 'DMR_EXECUTION_PROHIBITED' when trying to load a setting while streaming is active + now, as while streaming is active not all features can be updated anyway. + + NEW FEATURES: + - Property 'mvLampDetect' added to 'mvDACParams'. (mv.impact.acquire.dll) + (mvIMPACT_acquire.h) + +24.10.2012 2.0.15 + CHANGED BEHAVIOUR: + - mv.impact.acquire.Request.requestNr became mv.impact.acquire.Request.number. (mv.impact.acquire.dll) + + NEW FEATURES: + - mv.impact.acquire.Request.chunkCounterCount, (mv.impact.acquire.dll) + mv.impact.acquire.Request.chunkTimerCount, + mv.impact.acquire.Request.getChunkCounterValue and + mv.impact.acquire.Request.getChunkTimerValue added. + - Support for 10, 12, 14 and 16-bit PGM import added when reading image data from a (mvVirtualDevice-lib) + directory. + + BUGS FIXED: + - In 'DeviceSpecific' interface layout when for certain trigger configurations the (mvBlueCOUGAR-lib) + trigger edge(TriggerActivation) was not always configured correctly for + mvBlueCOUGAR-X devices. + - When setting 'AcquisitionStartStopBehaviour' to 'assbUser' and calling (mvBlueCOUGAR-lib) + 'DMR_AcquisitionStop' or 'mvIMPACT::acquire::FunctionInterface::acquisitionStop' + while buffers were queued all these buffers did increment the 'ErrorCount' property + in the 'Statistics' list by 1. + +23.10.2012 2.0.14 + UPDATES: + - Improved performance of 'ImageDirectory' TestMode. (mvVirtualDevice-lib) + + NEW FEATURES: + - Support for 'DeviceVersion' and 'FirmwareVersion' properties added for mvBlueLYNX-X (mvTLIClientGigE-lib) + devices. (mvBlueCOUGAR-lib) + + BUGS FIXED: + - System wide internal mutexes could cause deadlocks (Linux only). (all shipped Linux driver packages) + +17.10.2012 2.0.13 + BUGS FIXED: + - Drivers internally deleting a feature from a feature tree could cause crashes. (mvPropHandling-lib) + (Bug introduced in version 2.0.12) + +16.10.2012 2.0.12 + NEW FEATURES: + - 'genCPVersionMajor', 'gencpVersionMinor', 'u3vVersionMajor' and 'u3vVersionMinor' (mvTLIClientGigE-lib) + added to nodemaps of 'System-module', 'Interface-module' and 'Device-module'. + 'gevVersionMajor', 'gevVersionMinor' and 'deviceLinkSpeed' added to nodemaps of (mvTLIClientGigE-lib) + 'Interface-module' and 'Device-module'. + - Preliminary support for U3V became public. To install the supporting files this must (mvBlueCOUGAR.msi) + explicitly be selected in the 'Select the features to install' dialog. (mvBlueCOUGAR-x64.msi) + + BUGS FIXED: + - Exporting the 'ConstantsDictEntry' tokens to and XML file could cause a crash when (mvPropHandling-lib) + encountering a 'PROP_MAX_BINARY_BUFFER_SIZE' attached to a string property. + - Importing settings from a XML file did fail for mvBlueLYNX-X devices without a valid (mvTLIClientGigE-lib) + IPv4 address. + +08.10.2012 2.0.11 + UPDATES: + - The color twist filter is no longer 'UNDER CONSTRUCTION'. (all shipped packages) + + NEW FEATURES: + - Added support for 'inUse' Feature (see e.g. mvIMPACT::acquire::Device::isInUse). (mvTLIClientGigE-lib) + When a mvBlueLYNX-X is opened with 'Exclusive' access no other application can (mvBlueCOUGAR-lib) + connect now, when any application is already connected a connection with 'Exclusive' + access will fail. + - In the 'Detailed Feature Information' dialog the actual raw binary data will be (wxPropView) + displayed now for properties specifying the 'cfContainsBinaryData' flag. Previous + versions did display Base64 encoded strings. + - Properties mvIMPACT::acquire::GenICam::DigitalIOControl::mvRTMInputSelector and (mvIMPACT_acquire_GenICam.h) + mvIMPACT::acquire::GenICam::DigitalIOControl::mvRTMSource added. (mv.impact.acquire.dll) + + BUGS FIXED: + - The Registry based updating of settings did not evaluate the type descriptor of the (mvPropHandling-lib) + setting to update, which could result in inconsistent data sets being used for the + update operation. + - When a network interface had a valid IP address but no GEV device connected to the (mvTLIClientGigE-lib) + interface the 'mvIMPACT::acquire::FunctionInterface::updateDeviceList' or + 'DMR_UpdateDeviceList' calls took several seconds longer than necessary. + - GenICam properties that specify 'NoCache' will be created with the newly introduced (mvPropHandling-lib) + 'cfAlwaysForceUpdate' flag now to make sure that features will always be set to the (mvBlueCOUGAR-lib) + desired value. + - Internal 'Invalid proplist ID' exceptions when opening mvHYPERION devices. (mvHYPERIONfg-lib) + +26.09.2012 2.0.10 + BUGS FIXED: + - 'imageRequestReset' behaviour improved for mvBlueLYNX-X devices. (mvTLIClientGigE-lib) + +24.09.2012 2.0.9 + DEPRECATED API CODE: + - The function 'OBJ_GetHandle' has been declared deprecated. Use 'ObjGetHandleEx' (mvDeviceManager.h) + instead. + + CHANGED BEHAVIOUR: + - Each property list can contain up to 65535 instead of 32767 components now, and up (mvPropHandling-lib) + to 65535 instead of 32767 property list in total are supported now. + + NEW FEATURES: + - Support for 8-bit PGM import added when reading image data from a directory. (mvVirtualDevice-lib) + - 'cfAllowValueCombinations' added to '/Camera/ImageType' property. (mvVirtualDevice-lib) + WARNING: Because of that 'vditAll' became 'vditNone'. + - Preliminary support for U3V(USB3 Vision) added(so far not accessible by everyone). (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + + BUGS FIXED: + - Calling 'DSGetInfo' with 'STREAM_INFO_BUF_ALIGNMENT' will return 1 instead of '0' now (mvTLIClientGigE-lib) + if there are no custom alignment restrictions for that stream. + - When setting a device was configured to transmit Bayer data under certain conditions (all shipped packages) + the host-based Bayer decoder returned an image that only contained 'transmitted height + divided by 2' lines. + (Bug introduced in version 1.11.46) + +30.08.2012 2.0.8 NEW FEATURES: + - Function HDRControl::isAvailable added. (mvIMPACT_acquire.h) + (mv.impact.acquire.dll) + - New properties added to nodemap of the 'System', 'Interface' and 'Device' modules: (mvTLIClientGigE-lib) + 'GenCPVersionMajor', 'GenCPVersionMinor', 'U3vVersionMajor' and 'U3vVersionMinor'. + - New properties added to nodemap of the 'Interface' and 'Device' modules: (mvTLIClientGigE-lib) + 'GevVersionMajor' and 'GevVersionMinor'. + + BUGS FIXED: + - Devices reporting an invalid(too large) number of streaming channels did cause (mvBlueCOUGAR-lib) + crashes. + - Color twist matrices 'XYZToAdobeRGB_D50', 'XYZToAdobeRGB_D65' and 'm_XYZTosRGB_D65' (all shipped packages) + internally used interchanged values. + (Bug introduced in version 2.0.0) + - Class AutoControlParameters did use different names under .NET for some properties (mv.impact.acquire.dll) + Therefore Under .NET 'intergralTime_ms' became 'controllerIntegralTime_ms' and + 'derivativeTime_ms' became 'controllerDerivativeTime_ms'. + - Some newly introduced enum values were missing in the public interface. (mv.impact.acquire.dll) + TLUTMapping.LUTm14To14, TLUTMapping.LUTm16To16, + TBlueFOXInfoSensorCapabilities.bfiscNone, + TBlueFOXInfoSensorCapabilities.bfiscTemperatureSensor. + - Changing the digital input threshold did not correctly update the state of the (mvBlueFOX-lib) + digital inputs. + - Access to the properties aoiWidth, aoiHeight, aoiStartX and aoiStartY of class (mv.impact.acquire.dll) + mv.impact.acquire.AutoControlParameters was not possible. + +15.08.2012 2.0.6 + NEW FEATURES: + - Class mvIMPACT::acquire::GenICam::mvOMAPPreviewConfig added. (mvIMPACT_acquire_GenICam.h) + (mv.impact.acquire.dll) + +13.08.2012 2.0.5 + UPDATES: + - When using the external I2C bus lots of log messages have been generated since (mvBlueFOX-lib) + version 1.12.58. + - Default values when using the filter driver changed: 'mvResendRequestMax' from 0 to (mvGigECapture.sys, version 2.0.4.38) + 5, 'ResendResponseTimeout_ms' from 5 to 2. + - Minimum value of 'mvResendRequestMax' set to 1. (mvTLIClientGigE.cti) + - When a call to 'OBJ_GetHandleEx' does fail a more meaningful exception message will (all shipped packages) + be generated now. + - classes mvIMPACT::acquire::RTCProgram and mvIMPACT::acquire::RTCProgramStep are (mvIMPACT_acquire.h) + derived from mvIMPACT::acquire::ComponentCollection now. + + NEW FEATURES: + - Property 'DACValueAll' added to class mvIMPACT::acquire::GenICam::mvDACParams and (mvIMPACT_acquire.h) + mv.impact.acquire.GenICam.mvDACParams. (mv.impact.acquire.dll) + + BUGS FIXED: + - mv.impact.acquire.PulseStartConfiguration.number_ and (mv.impact.acquire.dll) + mv.impact.acquire.DigitalIO.description_ became private(have been public). + - If supported by the device access to property (mv.impact.acquire.dll) + mv.impact.acquire.PulseStartConfiguration.digitalSignal is possible now. + - The property 'get' of mv.impact.acquire.DigitalOutput and (mv.impact.acquire.dll) + mv.impact.acquire.DigitalInput became a public function. + - The property 'isWriteable' of mv.impact.acquire.DigitalInput has been removed as (mv.impact.acquire.dll) + inputs are not writeable by design and to stay in sync. with the C/C++ interface. + - mv.impact.acquire.OutputSignalGeneratorFrameGrabber does allow to access all digital (mv.impact.acquire.dll) + outputs of a device now. + - When a call to 'createSetting' does fail a proper return value is returned now. (all shipped packages) + Older versions could raise an exception. + +08.08.2012 2.0.4 + BUGS FIXED: + - Camera descriptions have not been available via instances of class (mv.impact.acquire.dll) + mv.impact.acquire.CameraDescriptionManager. All camera description count properties + except 'totalCameraDescriptionCount' did return 0. + +07.08.2012 2.0.3 + BUGS FIXED: + - When working with the interface layout 'dilGenICam' or 'dilGeneric' when requesting (mvBlueCOUGAR-lib) + at least one image with image request control mode 'ircmUpdateBufferLayout' the next + call to 'FunctionInterface::acquisitionStop' or 'DMR_AcquisitionStop' did not return. + - For mvBlueLYNX-X devices the request buffer layout queried by the image request (mvBlueCOUGAR-lib) + control mode 'ircmUpdateBufferLayout' did not correctly handle line pitch + restrictions. + - The initial value of 'Enable' in the saturation wizards could be incorrect. (wxPropView) + +06.08.2012 2.0.2 + UPDATES: + - Improved zooming in and out of the image display using the scroll wheel. (wxPropView) + - 'Details' button added to saturation wizard. (wxPropView) + - Frame rate no longer drops when the AGC is switched on and 'AutoControlMode' is set (mvBlueFOX-lib) + to 'Standard'. + + NEW FEATURES: + - When scrollbars are visible in a display area, you can drag around the center of the (wxPropView) + visible display area when NOT inside the AOI of a analysis plot. + - 14 -> 14 bit and 16 -> 16 bit SW LUT are now supported by the 'LUTOperations' filter. (all shipped packages) + + BUGS FIXED: + - When using the 'IID_IAMCameraControl' interface of the DirectShow support library (DirectShow_acquire.ax) + setting the exposure time to the maximum allowed value could result in a crash. + - The firmware package can be used to update mvBlueCOUGAR-X104bG/C types now (mvBlueCOUGAR-X_Update.mvu) + - EEPROM readout frequency reduced. (mvHYPERION2.sys, version 2.1.36.44) + +31.07.2012 2.0.1 + NEW FEATURES: + - All example applications can be compiled using Visual Studio 2010 now. (all shipped MSI-based packages) + + BUGS FIXED: + - When using the 'IID_IAMCameraControl' interface of the DirectShow support library (DirectShow_acquire.ax) + certain devices could cause an invalid loop if they reported a minimum, maximum or + actual exposure time of '0 us'. + +26.07.2012 2.0.0 + UPDATES: + - using MATRIX VISION devices via the DirectShow_acquire.ax library under LabVIEW no (DirectShow_acquire.ax) + longer displays a 'Error: Cannot initialise OLE' messages when opening the device. + (Windows only) + + CHANGED BEHAVIOUR: + - mvIMPACT Acquire will use version numbers according to the 'Semantic Versioning (all shipped packages) + Specification' starting from this version. See http://semver.org/ for details. + + NEW FEATURES: + - Basic support for the 'IID_IAMCameraControl' interface added. So far only the (DirectShow_acquire.ax) + exposure time can be controlled. + - New header file added: $(MVIMPACT_ACQUIRE_DIR)/DriverBase/Include/mvVersionInfo.h (all shipped packages) + + BUGS FIXED: + - Color twist matrices 'XYZToAdobeRGB_D50' and 'XYZToAdobeRGB_D65' internally used (all shipped packages) + interchanged values, thus the D50 matrix did use the D65 values and vice versa. + - The last byte of the user EEPROM could not be accessed. (mvBlueFOX-lib) + - Missing file added to installer packages: UserSuppliedMemory.cs (all shipped MSI-based packages) + - Timeouts during single frame acquisition could cause a leaking handle per request. (mvBlueFOX-lib) + (Windows only) + - Opening and closing an mvBlueFOX or mvHYPERION device caused a handle leak of 2-4 per (mvBlueFOX-lib) + iteration. (mvHYPERIONfg-lib) + (Windows only) + - Chunk buffers that changed their size on a per buffer basis while streaming was (mvBlueCOUGAR-lib) + active could not always be decoded correctly. (mvTLIClientGigE-lib) + +12.07.2012 1.12.73 + BUGS FIXED: + - 'DeviceIPAddress' property could become 'Unavailable' after rebooting two cameras (mvBlueCOUGAR-lib) + several times. + - EEPROM read out improved. Current version reads byte by byte and no longer with (mvHYPERION2.sys, version 2.1.35.43) + multi-byte accesses. + - Driver cleanup function improved when loading the driver with default flash (mvHYPERION2.sys, version 2.1.35.43) + configuration within DeviceConfigure. + +11.07.2012 1.12.72 + CHANGED BEHAVIOUR: + - 'VBSample' removed(deprecated). (all shipped MSI-based packages) + - Some objects in the namespace 'mvIMPACT::acquire::GenICam' are no longer derived from (mvIMPACT_acquire_GenICam.h) + mvIMPACT::acquire::ComponentCollection as calling the 'restoreDefault' method of this + base class could affect the state of properties outside the scope of the object + calling the function. + - All the component iteration functions (parent, firstChild, firstSibling, nextSibling (mvIMPACT_acquire.h) + and lastSibling) will no longer raise an exception when there queried object is not + available. However the newly returned object must be checked using the 'isValid' + function before accessing it. + + NEW FEATURES: + - Firmware version 1.4.63.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - POE support, devices with POE have only 2 digital outputs. + Changed behaviour: + - EV76C560: No dependency Height-OffsetY in linescan mode. + - flow control and 10Base_T support disabled + - 'ContinuousCapture' for VB.NET added. (all shipped MSI-based packages) + - Installers will also register an environment variable 'MVIMPACT_ACQUIRE_DATA_DIR' now (all shipped MSI-based packages) + that will point to the folder containing all application data specific files and + folders like log-files, camera descriptions etc.. + - All valid pixel formats can be selected by the 'pixelFormat' property in (mvVirtualDevice-lib) + mvIMPACT::acquire::CameraSettingsBase' now. When not set to 'Auto', the properties + 'TestMode' and 'ChannelBitDepth' will become invisible. + + BUGS FIXED: + - mvBlueFOX-x05G/C: Pixel artifacts with certain exposure settings when sensor is (mvBlueFOX-lib) + operated in triggered mode much improved. + +27.06.2012 1.12.71 + UPDATES: + - Improved acquisition performance of mvBlueLYNX-X devices. (mvTLIClientGigE-lib) + (mvBlueCOUGAR-lib) + + BUGS FIXED: + - Some problems occurred while trying to open mvHYPERION devices with default firmware. (mvHYPERIONfg-lib) + Also system powerdown with default firmware did end with a system crash. (mvHYPERION2.sys, version 2.1.34.42) + - Setting 'ImageProcessing/ColorProcessing' to 'RawToPlanes' did not work with (all shipped packages) + an input pixel format of 'ibpfMono12Packed_V2'. + +15.06.2012 1.12.70 + UPDATES: + - Devices that only report a single streaming channel will consume one thread less now. (mvBlueCOUGAR-lib) + + CHANGED BEHAVIOUR: + - 'F5' is used instead of 'ALT+CTRL+U' to update device lists now. (wxPropView) + (mvDeviceConfigure) + (mvIPConfigure) + (mvGigEConfigure) + NEW FEATURES: + - IP address added to list control. (mvIPConfigure) + + BUGS FIXED: + - Loading a setting did not correctly restore calibration data for the dark current and (all shipped packages) + the flat field filter. + (Bug introduced in version 1.11.11) + - When a connection to a GEV device was lost and is re-established later sometimes log- (mvTLIClientGigE-lib) + messages reported invalid values for the GevSCPSPacketSize feature. + +11.06.2012 1.12.69 + DEPRECATED API CODE: + - The function 'mvDispSetWindow' is no longer declared in 'mvDisplay.h'. This function (mvDisplay.h) + internally did only call 'mvDispSetImage'. For backward compatibility this function + however will still be exported by the library thus this will not break existing + applications at runtime. + - In order to have consistent function names several functions from the 'C' interface (mvDisplay-lib) + have been renamed. The functions will still be exported with the old names as well + thus this will not break existing binaries but will require changes in the source + during rebuilds. The following functions have been renamed: + - mvDestroyImageWindow: Use mvDispWindowDestroy instead. + - mvGetDisplayWindowHWnd: Use mvDispWindowGetWindowHandle instead. + - mvGetDisplayStructure: Use mvDispWindowGetDisplayHandle instead. + - mvInitDisplayWindow: Use mvDispWindowCreate instead. + - mvSetDisplayWindowRefreshTime: Use mvDispWindowSetRefreshTime instead. + - mvShowDisplayWindow: Use mvDispWindowShow instead. + - mvInstallPreProcHandler: Use mvDispWindowSetMessageHandler instead. + If re-building your application please note that when linking against the new export + names, the display library on the target system must be updated as well. + + NEW FEATURES: + - 'mvIMPACT::acquire::ComponentIterator' is now just a typedef. All functions/features (mvIMPACT_acquire.h) + of this class has been moved to the base class 'mvIMPACT::acquire::Component'. This + does not cause any compatibility issues, but will slightly improve the way feature + iteration can be used. + - Class mvIMPACT::acquire::GenICam::mvACCControl added. (mvIMPACT_acquire_GenICam.h) + - All camera description recognised by a certain frame grabber will be created during (mvHYPERIONfg-lib) + the initialisation now. Because of this change the class (mvSIGMAfg-lib) + mvIMPACT::acquire::CameraDescriptionManager can finally access all camera (mvTITANfg-lib) + descriptions that can be selected via the 'Camera/Type' property directly after + initialisation of a device. + + BUGS FIXED: + - mvBlueFOX-x05G/C: Pixel artifacts when sensor is saturated. (mvBlueFOX-lib) + - mvBlueFOX-x05G/C: Pixel artifacts with certain exposure settings when sensor is (mvBlueFOX-lib) + operated in triggered mode. + - Calling 'mvDispUpdate' could crash in 'DM_FullScreen' mode if creating the (mvDisplay-lib) + DirectDraw surface did fail before(e.g. because of missing user rights). + - Missing calling convention added to typedef of 'CBOBJChanged'. (mvDeviceManager-lib) + - X-Offset and Y-Offset for analysis controls where interchanged. (wxPropView) + (Bug introduced in version 1.12.28) + - Direct conversion of Bayer data to Mono8 improved. Border pixels are handled (all shipped packages) + correctly now, RGB weighting uses the following formula now: + 0.299 * R' + 0.587 * G' + 0.114 * B'. + +24.05.2012 1.12.68 + UPDATES: + - Color correction data for mvBlueCOUGAR specific sensors updated(EXPERIMENTAL! (all shipped packages) + SUBJECT TO CHANGE!) + + NEW FEATURES: + - Initial version with full .NET support that is independent from the mvIMPACT-SDK. (mv.impact.acquire.dll) + (mv.impact.acquire.display.dll) + - New protected method 'mvIMPACT::acquire::Request::getComponentLocator' added. This (mvIMPACT_acquire.h) + will make it a little easier to derive from 'mvIMPACT::acquire::Request'. + - Functions 'mvIMPACT::acquire::Request::unlock' and (mvIMPACT_acquire.h) + 'mvIMPACT::acquire::Request::configure' added. These functions result in the same + behaviour as calling 'mvIMPACT::acquire::FunctionInterface::imageRequestUnlock' and + 'mvIMPACT::acquire::FunctionInterface::imageRequestConfigure' but allow to write + nicer code. + - Functions 'mvIMPACT::acquire::Request::attachUserBuffer' and (mvIMPACT_acquire.h) + 'mvIMPACT::acquire::Request::detachUserBuffer' added. This will reduce the amount of + code needed to capture into user supplied memory. + - Function 'mvIMPACT::acquire::FunctionInterface::getCurrentCaptureBufferLayout' added. (mvIMPACT_acquire.h) + This will offer a new more convenient way find out what kind of buffers are needed to + capture into user supplied memory. + - Functions mvIMPACT::acquire::EnumPropertyF::getTranslationDictValues, (mvIMPACT_acquire.h) + mvIMPACT::acquire::EnumPropertyI::getTranslationDictValues and + mvIMPACT::acquire::EnumPropertyI64::getTranslationDictValues added. + - Function 'mvDispGetWindowHandle' added. (mvDisplay-lib) + - Functions 'mvDispSetImageFromImageBuffer' and 'mvDispSetImageFromRequest' added (mvDisplayExtensions.h) + + BUGS FIXED: + - mvDispGetError did return a random error code until the first error did occur or the (mvDisplay-lib) + function was called a second time(uninitialised internal variable). + - mvBlueLYNX-X: Read of fallback EEPROM if default EEPROM contains an invalid MAC. (mvTLIClientGigE-lib) + +11.05.2012 1.12.67 + DEPRECATED API CODE: + - mvIMPACT::acquire::Property::isConstDefined has been declared deprecated. Use (mvIMPACT_acquire.h) + mvIMPACT::acquire::Property::hasMaxValue, mvIMPACT::acquire::Property::hasMinValue + and mvIMPACT::acquire::Property::hasStepWidth instead. + + UPDATES: + - Kernel modules rebuilt. No change in behaviour. (mvBlueFOX2.sys, version 1.0.4.5) + + NEW FEATURES: + - Support for mvBlueFOX-202d with MT9M024 revision 0x41 added. (mvBlueFOX-lib) + - 'basedOn' property added to mvIMPACT::acquire::BasicDeviceSettings. (mvIMPACT_acquire.h) + + BUGS FIXED: + - Selecting 'Calibrate' for the 'Mode' of the 'Dark current filter' or the 'Flat Field (all shipped packages) + filter' could cause crashes. + (Bug introduced in version 1.12.57) + - Selecting 'ImageDestination/PixelFormat' different from 'Auto' for mvBlueCOUGAR-X (mvBlueCOUGAR-lib) + devices in device specific interface layout did not always result in the correct + pixel format being returned by the driver. + - Some properties of the mvIMPACT::acquire::GenICam::InterfaceModule class where (mvPropHandling-lib) + missing the 'cfReadAccess' flag. (mvBlueCOUGAR-lib) + +26.04.2012 1.12.66 + NEW FEATURES: + - New features added to 'ColorTwist' filter(EXPERIMENTAL! SUBJECT TO CHANGE!) (all shipped packages) + + BUGS FIXED: + - The 'Offset_pc' property in device specific interface layout for mvBlueCOUGAR-S (mvBlueCOUGAR-lib) + devices can be modified again. + (Bug introduced in version 1.12.33) + - Random crashes when a GEV device was unplugged or rebooted while streaming was (wxPropView) + active. + (Bug introduced in version 1.12.62) + +24.04.2012 1.12.65 + NEW FEATURES: + - mvIMPACT::acquire::InfoBlueFOX::deviceSensorRevision property added. (mvIMPACT_acquire.h) + - 'DeviceSensorRevision' property added. (mvBlueFOX-lib) + + BUGS FIXED: + - When constantly calling 'mvIMPACT::acquire::FunctionInterface::updateDeviceList' or (mvBlueCOUGAR-lib) + 'DMR_UpdateDeviceList' in parallel to running image acquisitions then closing a (mvTLIClientGigE-lib) + device, that became disconnected could end up in a deadlock. + - The maximum number of defective pixels internally that can be detected is 1000 while (all shipped packages) + the 'DefectivePixelsFilter' worked with 1001. + - Depending on the image content at the time of calibration setting (all shipped packages) + 'DefectivePixelsFilter/Mode' either to 'dpfm3x3Median' or 'dpfm3x1Average' could + result in crashes. + - Multi-byte Bayer formats are correctly supported by the 'DefectivePixelsFilter' now. (all shipped packages) + - NeuroCheck 6 interface only gets installed if NeuroCheck 6 has been detected on the (all shipped MSI-based packages) + target system. + +23.04.2012 1.12.64 + CHANGED BEHAVIOUR: + - Return value of the functions mvIMPACT::acquire::TriggerControl::triggerSoftware and (mvIMPACT_acquire.h) + mvIMPACT::acquire::Statistics::reset changed from TDMR_ERROR to int. + + NEW FEATURES: + - mvIMPACT::acquire::UserData::getFreeMemory function added. (mvIMPACT_acquire.h) + + BUGS FIXED: + - A stream channel index different from 0 can be configured now. (mvGigECapture.sys, version 2.0.3.37) + - High frame rates with large amounts of data lost could still lead to a hanging (mvGigECapture.sys, version 2.0.3.37) + process on Windows. + - Unresolved symbols 'DrvGetHardwareFeatureDecodeBufferSize' and (mvBlueFOX-lib) + 'DrvEncodeHardwareFeature' at runtime on some Linux platforms. + +18.04.2012 1.12.63 + DEPRECATED API CODE: + - The functions mvIMPACT::acquire::FunctionInterface::isRequestOK has been declared (all shipped packages) + deprecated. Use mvIMPACT::acquire::Request::isOK instead. Refer to + 'Porting existing code' section in the documentation for more information. + + NEW FEATURES: + - mvIMPACT::acquire::Property::hasMaxValue, mvIMPACT::acquire::Property::hasMinValue, (mvIMPACT_acquire.h) + mvIMPACT::acquire::Property::hasStepWidth added. + - 'getMaxValue', 'getMinValue' and 'getStepWidth' functions added to classes (mvIMPACT_acquire.h) + mvIMPACT::acquire::EnumPropertyF, mvIMPACT::acquire::EnumPropertyI and + mvIMPACT::acquire::EnumPropertyI64. + - mvIMPACT::acquire::Request::isOK added. (mvIMPACT_acquire.h) + + BUGS FIXED: + - When a device suddenly stopped responding while working in 'SoftwareTrigger' mode (mvBlueCOUGAR-lib) + closing the driver or calling 'imageRequestReset' could result in a deadlock when + buffers where queued after the device stopped responding. + - The property 'RequestResult' is updated correctly again. (all shipped packages) + (Bug introduced in version 1.12.58) + +16.04.2012 1.12.62 + NEW FEATURES: + - 'DeviceTemperature' property added for mvBlueFOX-202dx devices. (mvBlueFOX-lib) + + BUGS FIXED: + - mvHYPERION devices can capture data again. (mvHYPERIONfg-lib) + (Bug introduced in version 1.12.60) + - Sporadic crashes caused by invalid image data being used to update the pixel data of (wxPropView) + the status bar. + - In full screen mode the info plot no longer draws on top of the image. (wxPropView) + +11.04.2012 1.12.61 + BUGS FIXED: + - Resend requests when NOT using the 'immediate resend' strategy could be sent to an (mvGigECapture.sys, version 2.0.2.36) + invalid destination MAC address(0). + +11.04.2012 1.12.60 + CHANGED BEHAVIOUR: + - Data type of mvIMPACT::acquire::InfoBlueFOX::sensorCaps changed from (mvIMPACT_acquire.h) + mvIMPACT::acquire::PropertyI to + mvIMPACT::acquire::PropertyIBlueFOXInfoSensorCapabilities. This might force you to + change your code during rebuilds but will not break existing binaries. + - Removed unused data type 'TBlueLYNXVideoOutMode'. (mvDriverBaseEnums.h) + - Property 'Camera/Flash' renamed to 'Camera/FlashMode' (mvBlueLYNX-lib) + - The classes mvIMPACT::acquire::TriggerControl and mvIMPACT::acquire::SyncOutput are (mvIMPACT_acquire.h) + derived from mvIMPACT::acquire::ComponentCollection now. + + BUGS FIXED: + - High frame rates with large amounts of data lost could lead to a hanging process (mvTLIClientGigE-lib) + on Windows. (mvGigECapture.sys, version 2.0.1.35) + +03.04.2012 1.12.59 + UPDATES: + - Internally modified thread shutdown order when closing the driver instance. (mvVirtualDevice-lib) + + NEW FEATURES: + - Firmware version 1.4.57.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - New sensors: CMV2000, CMV4000, EV76C560 (color) + - New devices: mvBlueCOUGAR-XD. + - CCDs: Smear reduction property. + - FFC Feature extended: FFC works for sensor sizes > 1.8 Mega-Pixel, however the + FFC data can not be stored in flash. Instead the data is accessible + using the File Control feature (up- and download). + - MT9P031: New pixel clock frequency: 98 MHz. + - EV76C560: LinescanMode (AcquisitionMode 'Continuous' only) + - MT9V034 can also use the FPGA's auto control features now. + - Support for events added ('EventExposureEnd' 'EventLineRisingEdge'). + - Application Switchover + - HeartbeatDisable + Changed behaviour: + - Many optimizations concerning the network behaviour (traversing firewalls, + DHCP/AutoIP, Discovery Process, GigE Vision Protocol, etc...) + - 'ExposureActive' signal is now internally ANDed with the 'AcquisitionActive' + signal, useful for controlling lighting systems. It is now equivalent to the + DEPRECATED 'mvExposureAndAcquisitionActive' signal. The previous behaviour can be + obtained by using the new signal 'mvExposureActive'. + - GevSCBW unit changed (KByte/s -> KBps) + - Only one green LUT instead of LUT_GreenRed and LUT_GreenBlue is used now. + - Luminance LUT for RGB. + Bugs fixed: + - Color Transformation Matrix works with negative values, too + - MT9V034: AGC upper limit did not work correctly. + - using more than one OR gate caused unexpected results. + - 'UserDefinedName' was lost after FW update. + - FrameAverager (only -2xx) + - First line for all CCD sensors did contain incorrect data. + + BUGS FIXED: + - 'can not access 'CameraLink\serial\' in the network' during the installation. (all shipped 64-bit MSI-based packages with CameraLink support) + +29.03.2012 1.12.58 + DEPRECATED API CODE: + - The functions mvIMPACT::acquire::FunctionInterface::saveSystemToDefault and (all shipped packages) + DMR_SaveSystemToDefault have been declared deprecated. See 'Porting existing code + section in the documentation for more information. + + CHANGED BEHAVIOUR: + - mvIMPACT::acquire::WhiteBalanceSettings::WBresult renamed to (mvIMPACT_acquire.h) + mvIMPACT::acquire::WhiteBalanceSettings::WBResult. This might force you to change + your code during rebuilds but will not break existing binaries. + + UPDATES: + - More internal optimizations. (all shipped packages) + + NEW FEATURES: + - mvIMPACT::acquire::FunctionInterface::getSetting() added. (mvIMPACT_acquire.h) + - mvIMPACT::acquire::Statistics::formatConvertTime_s added. (mvIMPACT_acquire.h) + - Class mvIMPACT::acquire::BasicDeviceSettings added. This acts as a base class (mvIMPACT_acquire.h) + for mvIMPACT::acquire::CameraSettingsBase and contains the features, that are + available for all interface layouts. + + BUGS FIXED: + - 'mvIMPACT::acquire::ComponentList::size' and 'OBJ_GetElementCount' did return the (mvDeviceManager-lib) + number of reserved elements instead of the number of elements actually valid and + allocated. + - Sporadic crashes when leaving full screen mode. (wxPropView) + - Serial write function is working again. (clsermv-lib) + (Bug introduced in version 1.12.49) + - Makefiles now also work on Linux distributions with complex Linux version string. (low level mvHYPERION driver, Linux) + +14.03.2012 1.12.57 + CHANGED BEHAVIOUR: + - As the mvIMPACTAcquire_Cognex_Adapter-lib is shipped and build as part of mvIMPACT (all shipped MSI-based packages) + Acquire it will now use the global mvIMPACT Acquire version number. + + UPDATES: + - Internal optimizations. (all shipped packages) + + NEW FEATURES: + - Support for increment from GenICam XML float nodes added. (mvBlueCOUGAR-lib) + - cfShouldBeDisplayedAsEnumeration added to interface. (mvPropHandling-lib) + + BUGS FIXED: + - A feature selecting others that itself was an enumeration and did not contain any (wxPropView) + translation dictionary entries could cause crashes. + - Some missing files added to mvHYPERION Linux drivers again. (all shipped Linux driver packages for mvHYPERION devices) + (Bug introduced in version 1.12.51) + +08.03.2012 1.12.56 + NEW FEATURES: + - Initial version of mvIMPACT::acquire::RequestFactory added. (mvIMPACT_acquire.h) + + BUGS FIXED: + - Correctly links against GenApi runtime version 2.3.0 now. (mvBlueCOUGAR-lib) + - RGB GEV pixel formats are handled correctly again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.12.54) + - The last value of a selected pixel histogram range was not drawn. (wxPropView) + - Wrong clipping in line profile plots. Connecting lines from points outside of the (wxPropView) + plot window were drawn not from the virtual intersection point of the line, but from + the lower/upper range of the plot window. + +06.03.2012 1.12.55 + CHANGED BEHAVIOUR: + - 'DelphiSample' removed(deprecated). (all shipped MSI-based packages) + + NEW FEATURES: + - New sample added to all packages: 'GenICamInterfaceLayout'. (all shipped packages) + - 32-bit CameraLink communication libraries will be installed on 64-bit versions of (all shipped 64-bit MSI-based packages with CameraLink support) + Windows according to the CameraLink Specification 2.0 now. + + BUGS FIXED: + - The samples 'Callback' and 'Callback_C' have incorrectly been installed into the (all shipped 32-bit MSI-based packages) + 'SingleCaptureMasterSlave' sub-folder. + - The line pitch reported by returned by requests requested in 'Trial' mode was not (mvBlueCOUGAR-lib) + always correct for mvBlueLYNX-X devices. + - DirectShow device registration via command line is working again. (DirectShow_acquire.ax) + +01.03.2012 1.12.54 + CHANGED BEHAVIOUR: + - Devices operated in interface layout 'dilGenICam' will return (mvBlueCOUGAR-lib) + 'DMR_EXECUTION_PROHIBITED' when trying to store a setting while streaming is active + now, as the settings stored that way do not contain all the required data. + - In rare cases where the device string identifier reported by the GenTL producer does (mvBlueCOUGAR-lib) + change at runtime, this is now correctly recognised by the consumer. + + NEW FEATURES: + - Initial version with GEV 2.0 support. Kernel- and User Mode drivers might NOT be (mvTLIClientGigE-lib) + mixed, thus either both modules must belong to a package with a version 1.12.53 or (mvGigECapture.sys, version 2.0.0.34) + older or to a package with a version 1.12.54 or newer. + - Added support for mvBlueCOUGAR-XD devices. (mvTLIClientGigE-lib) + (mvDeviceConfigure) + - If there is more data to display than the system can handle, paint events will be (wxPropView) + skipped on Windows now(see 1.12.26 for a similar change for Linux). + - NIC Setup hints added. (mvGigEConfigure) + + BUGS FIXED: + - mvHYPERION-SDI: Mono formats work again. (mvHYPERIONfg-lib) + - In rare cases when sending more than 256 requests to the driver at the same time not (mvBlueFOX-lib) + all these requests have been processed and returned. This then could result in + unexpected capture errors. + - New FPGA file for mvBlueFOX-MLC added. This introduces a change on the external I2C (mvBlueFOX-lib) + bus. SCL stretching during and after the I2C_ACK is now possible. (FPGA version: 46). + +23.02.2012 1.12.53 + CHANGED BEHAVIOUR: + - Some min/max/resize items added to various dialogs. (wxPropView) + - The property grid will consume all screen space available when the analysis tab and (wxPropView) + the image display are switched off. + - New FPGA file for mvBlueFOX-MLC added. This introduces a different SCL bus stretching (mvBlueFOX-lib) + (FPGA version: 45). + + UPDATES: + - Migration to version 2.3.0 of the GenApi runtime. (mvBlueCOUGAR installer) + + BUGS FIXED: + - Setting the dark current filter mode to 'Calibrate' with a Mono8 input format could (all shipped packages) + result in crashes after all images used for calibration have been captured. + (Bug introduced in version 1.12.8) + +15.02.2012 1.12.52 + CHANGED BEHAVIOUR: + - New FPGA file for mvBlueFOX-MLC added. This introduces a different external I2C bus (mvBlueFOX-lib) + timing(FPGA version: 44). + + NEW FEATURES: + - Initial version with basic GEV 2.0 support. Work in progress. (mvTLIClientGigE-lib) + + BUGS FIXED: + - mvBlueFOX devices do no longer report an error after updating the firmware. (mvBlueFOX-lib) + (Bug introduced in version 1.12.32) + - Flash update mvHYPERION grabber. (mvDeviceConfigure) + +02.02.2012 1.12.51 + BUGS FIXED: + - RotaryDecoder digital input signal list corrected. (mvHYPERIONfg-lib) + - Binning mode for mvBlueFOX-202b is working properly now. (mvBlueFOX-lib) + - mvBlueFOX devices with a firmware version smaller than 36 can be initialised again. (mvBlueFOX-lib) + (Bug introduced in version 1.11.52) + +27.01.2012 1.12.50 + CHANGED BEHAVIOUR: + - The auto negotiation algorithm for the optimal GEV packet size will only select (mvTLIClientGigE-lib) + values which are a multiple of 4 now as some cameras did send test packets even if + they were not capable of streaming data with other packet sizes. + + BUGS FIXED: + - SD signal resolution corrected. (mvHYPERIONfg-lib) + - Data transfer related issues with mvBlueFOX-1xx devices (CCD) on some operating (mvBlueFOX-lib) + systems. FPGA version 89(0x59). + (Bug introduced in version 1.12.32(FPGA version 87(0x57)) + - New FPGA file for mvBlueFOX-2xx (CCD) devices added. This fixes a footer error at (mvBlueFOX-lib) + small exposure times(FPGA version: 36). + +16.01.2012 1.12.49 + CHANGED BEHAVIOUR: + - The interface header file 'DirectShowAcquire.h' is no longer installed to (all shipped MSI-based packages) + '%TARGET_DIR%\DSImpactAcquire\Include' but to + '%TARGET_DIR%\ThirdPartySWBindings\DirectShow\Include'. This might force you to + modify your makefiles during rebuilds. + + BUGS FIXED: + - CapturePin and associated property dialog is working again. (DirectShow_acquire.ax) + - Bitmap files stored with 'SingleCaptureStorage' on 64-bit versions of Linux could not (SingleCaptureStorage.cpp) + be loaded with any other application. + - Camera format Bayer packed: CL-Camera description copy and export corrected. (mvHYPERIONfg-lib) + +03.01.2012 1.12.48 + BUGS FIXED: + - Internal GP-OUT handler did only update the first GP-OUT. (mvTITANfg-lib) + - Wake up from powerstate 3 improved, query for max. request objects corrected (mvHYPERION2.sys, version 2.1.33.41) + - Devices operated in interface layout 'dilGenICam' or 'dilGeneric' not supporting a (DirectShow_acquire.ax) + writeable 'OffsetX', 'OffsetY' 'Width' or 'Height' property can be used now when the + AOI is not touched by an application. + +21.12.2011 1.12.47 + CHANGED BEHAVIOUR: + - Driver is build with DDK 7600 now and requires a newer version of the WDF coinstaller (mvBlueFOX2.sys, version 1.0.3.4) + (1.9). Installations that did NOT use Merge Modules and did integrate the kernel + driver into a private setup routine must change the name of the WdfCoInstaller-DLL + (was: WdfCoInstaller01001.dll for 32-bit and WdfCoInstaller01005.dll for 64-bit, + became WdfCoInstaller01009.dll for both platforms) and the name of the *.cat-file + (was: 'mvBlueFOX2_.cat', became: 'mvBlueFOX2.cat'). + - Matrix multiplication order in 'ColorTwist' filter reversed. Only the 'ColorTwist' (all shipped packages) + matrix provides a 4th column now. When enabled, this will be used as an overall + offset for the resulting matrix. + + BUGS FIXED: + - The internal format converter did not remove the 'BayerParity' attribute from buffers (all shipped packages) + that (after the conversion) did no longer contain Bayer data. + - mvBlueFOX-x05 devices sometimes used a wrong frame rate after switching on/off (mvBlueFOX-lib) + binning related features. Also flash signals could be triggered randomly when + changing the binning parameters. + +07.12.2011 1.12.46 + CHANGED BEHAVIOUR: + - Classes renamed: mvIMPACT::acquire::GenICam::Device became (mvIMPACT_acquire_GenICam.h) + mvIMPACT::acquire::GenICam::DeviceModule, mvIMPACT::acquire::GenICam::Interface + became mvIMPACT::acquire::GenICam::InterfaceModule. + - Property 'ColorTemperature' removed from list 'WhiteBalanceSettings-. This (all shipped packages) + feature never served any purpose. + + NEW FEATURES: + - Wrapper code to access features from the 'SystemModule' and the 'InterfaceModule' (mvIMPACT_acquire_GenICam.h) + module of the GenICam GenTL Producer added. + - The interface list is also updated when calling 'InterfaceUpdateList' from the (mvBlueCOUGAR-lib) + 'System' module now. + - A capture setting can be dropped onto the property grid now. This will load an apply (wxPropView) + this setting automatically. + - The description strings of all enum entries will be appended to the features doc (mvBlueCOUGAR-lib) + string now. + + BUGS FIXED: + - 'full tree' mode is working again. (wxPropView) + (Bug introduced in version 1.12.33) + - Incorrect log message('BUG detected in interface handling...') removed. (mvBlueCOUGAR-lib) + - Updating the device list via DMR_UpdateDeviceList or (mvBlueCOUGAR-lib) + mvIMPACT::acquire::DeviceManager::updatedeviceList will also invalidate the limits + of 'mvBlueCOUGAR/GenTL/System/InterfaceSelector'. + - mvBlueFOX-x00w devices did use an incorrect minimal width and height. (mvBlueFOX-lib) + +29.11.2011 1.12.45 + NEW FEATURES: + - Spin control editors in the property grid will contain an additional slider now. This (wxPropView) + behaviour can be switched off under 'Settings -> Property Grid'. + - Command line interface added. (mvIPConfigure) + - New features added to 'ColorTwist' filter(EXPERIMENTAL! SUBJECT TO CHANGE!) (all shipped packages) + + BUGS FIXED: + - DirectShow access is also possible for devices using interface layout 'dilGenICam' (DirectShow_acquire.ax) + and these devices define a category 'TriggerControls'. + - Packages carry a digital signature again. (all shipped MSI-based packages) + (Bug introduced in version 1.12.41) + - 'ColorTwist' filter works correctly with pixel format 'ibpfRGBx888Planar' now. (all shipped packages) + +22.11.2011 1.12.44 + CHANGED BEHAVIOUR: + - When leaving a spin editor using the TAB key the new property value will be applied (wxPropView) + instead of the previous one now. + - Default value of the the property (all shipped packages) + '/ImageProcessing/WhiteBalance' changed from 'Daylight' to + 'User1'. + + NEW FEATURES: + - 'Driver Properties' page added to property grid control. (wxPropView) + - mvIMPACT::acquire::Device::deviceDriverFeatureList function added as well as (mvDeviceManager-lib) + TDMR_DeviceInfoType::dmdithDeviceDriver. (mvIMPACT_acquire.h) + + BUGS FIXED: + - mvBlueFOX-x00w: Fixed Exposure difference overlapped/non overlapped mode when AOI (mvBlueFOX-lib) + width was smaller than 700 pixels. + - mvBlueFOX-x02d: Fixed update issues with AEC/AGC. Increased minimal exposure time (mvBlueFOX-lib) + because of a sensor specific bug. + - mvBlueFOX-x02b: Fixed update issues with AEC/AGC. (mvBlueFOX-lib) + - Device discovery information was not fully refreshed for GEV devices after a call to (mvTLIClientGigE-lib) + 'IFUpdateDeviceList' if a device has been detected previously and data in the + discovery acknowledge differed from a previous call. + +17.11.2011 1.12.43 + NEW FEATURES: + - DirectShow access is also possible to devices using interface layouts different from (DirectShow_acquire.ax) + 'dilDeviceSpecific'. + - 64-bit integer property support added to property interface. (DirectShow_acquire.ax) + +16.11.2011 1.12.42 + DEPRECATED API CODE: + - The function DMR_GetDeviceInfo has been declared deprecated. Use DMR_GetDeviceInfoEx (mvDeviceManager-lib) + instead. + + CHANGED BEHAVIOUR: + - mv-icon is used by windows created by library now. (mvDisplay-lib) + - in full screen mode there is no more flickering when moving the mouse pointer (wxPropView) + - Red and blue component flipped for 'idpfBGR101010Packed_V2' and (mvBlueCOUGAR-lib) + 'ibpfBGR101010Packed_V2' in order to be compliant with the upcoming PFNC. (mvDisplay-lib) + (wxPropView) + + NEW FEATURES: + - Function 'DMR_GetDeviceInfoEx' added as well as 'mvIMPACT::acquire::Device::isInUse'. (all shipped packages) + wxPropView will show device usage information in the device driver information + dialog(F8) now. + + BUGS FIXED: + - Some UNICODE related issues(wrong string conversions). (wxPropView) + - Some invalid 64 integer to string conversions. (wxPropView) + (mvPropHandling-lib) + (mvVirtualDevice-lib) + - The legacy GCGetPortURL function did always return 0 for the size of the URL. (mvTLIClientGigE-lib) + (Bug introduced in version 1.12.36) + - Data sync. @ 40MHz improved for mvBlueFOX-MLC205x devices. (mvBlueFOX-lib) + +15.11.2011 1.12.41 + UPDATES: + - 'LinearInterpolation' Bayer conversion filter execution speed improved on all (all shipped packages) + platforms except 32-bit Windows. + - Improved property grid in NeuroCheck 6 interface. (all shipped MSI-based packages) + + CHANGED BEHAVIOUR: + - Default request count reduced to 6 for mvBlueLYNX-X devices. (mvBlueCOUGAR-lib) + + BUGS FIXED: + - Reset behaviour of trigger_controller() improved. (mvHYPERIONfg-lib) + - LUT wizard did crash in case the 'LUTSelector' feature was read-only. (wxPropView) + - Internal IP address to string handling did not correctly handle endianess. (mvTLIClientGigE-lib) + (Bug introduced in version 1.12.38) + (Linux only) + +03.11.2011 1.12.40 + BUGS FIXED: + - 'IOStatesAtExposureStart' is working now. (mvBlueFOX-lib) + +02.11.2011 1.12.39 + DEPRECATED API CODE: + - The features '/ImageProcessing/Saturation' and all the features (all shipped packages) + within that list have be declared deprecated. Applications should use the color twist + matrix under '/ImageProcessing/ColorTwist' or(for GenICam SFNC + compliant devices) the + '/Camera/GenICam/ColorTransformationControl' features instead. + + NEW FEATURES: + - 64-bit integer parameters can be handled by method objects now. (mvPropHandling-lib) + (wxPropView) + - Splitter added between the property grid and the tool tip window. (wxPropView) + - Progress dialog added for file upload and download wizard. (wxPropView) + - NeuroCheck 6 interface for mvBlueCOUGAR and mvBlueFOX devices added to all MSI based (all shipped MSI-based packages) + packages. + - Saturation wizards added. (wxPropView) + - 'mvIMPACT::acquire::ImageProcessing::setSaturation' function added. (mvIMPACT_acquire.h) + - 'ColorTwist' filter supports pixel format 'ibpfRGBx888Planar' now (all shipped packages) + + BUGS FIXED: + - 'DSGetBufferInfo' when asked for the size of the 'BUFFER_INFO_PIXELFORMAT_NAMESPACE' (mvTLIClientGigE-lib) + info did return 4 instead of 8 as required by the spec. + - Sometimes ending a continuous acquisition resulted in a 'AcquisitionStop', (wxPropView) + 'AcquisitionStart' and 'AcquisitionStop' command being send to a GenICam device + instead of a single 'AcquisitionStop' command. + (Bug introduced in version 1.12.11) + - Storing image sequences on Linux on slower machines did result in the first image (wxPropView) + of the sequence being stored times. + (Bug introduced in version 1.12.26) + - Property grid popup menus are working again. (wxPropView) + (Bug introduced in version 1.12.38) + - AbortRequest(), Capture-IRP handling improved to avoid any side effects with (mvHYPERION2.sys, version 2.1.31.39) + function DpsForIsr() + +27.10.2011 1.12.38 + NEW FEATURES: + - Support for large(64KB) EEPROM access via I2C added for mvBlueFOX-MLC devices added. (mvBlueFOX-lib) + - Support for 'IOStatesAtExposureStart' property added. (mvBlueFOX-lib) + + BUGS FIXED: + - Value strings starting with one or more whitespace characters have not been processed (wxPropView) + correctly for properties specifying the 'cfShouldBeDisplayedAsList' flag. + +26.10.2011 1.12.37 + UPDATES: + - Migration to version 1.3 of the GenICam GenTL spec. (mvTLIClientGigE-lib) + + BUGS FIXED: + - Crash whenever a wxPropView >= 1.12.33 detected a mvBlueFOX or mvBlueCOUGAR-X with (wxPropView) + a driver < 1.12.33. + (Bug introduced in version 1.12.33) + +25.10.2011 1.12.36 + CHANGED BEHAVIOUR: + - Spin-editors will accept a ',' as a floating point value separator as well now. (wxPropView) + + BUGS FIXED: + - Some request info properties had the 'cfWriteAccess' flag set. (mvBlueCOUGARLocal-lib) + - Tapsort filter RGB24-2Tap corrected. (mvHYPERIONfg-lib) + - Digital input mapping to internal signals corrected. (mvHYPERIONfg-lib) + +19.10.2011 1.12.35 + NEW FEATURES: + - Buffers returned from a mvBlueLYNX-X will have a timestamp now. (mvTLIClientGigE-lib) + - 'PaddingX' property added. (mvVirtualDevice-lib) + - Nonstandard RGB24-2Tap CL-Mode added. (mvHYPERIONfg-lib) + - Enhanced transfer error handling added. (mvSIGMAfg-lib) + + BUGS FIXED: + - When the network interface with a MATRIX VISION MAC address was shut down opening (mvTLIClientGigE-lib) + a mvBlueLYNX-X resulted in a crash. + - 8 mono buffers with a pitch divisible by 4 and a width different from the pitch can (mvDisplay-lib) + be displayed correctly now as well as 422 packed YUV and packed RGB formats that use + X-padding. + +17.10.2011 1.12.34 + CHANGED BEVAVIOUR: + - Some additional I2C device addresses block for access from external applications (mvBlueFOX-lib) + + NEW FEATURES: + - 'mvGevInterfaceLinkSpeed' added to nodemaps of 'System-module' and (mvTLIClientGigE-lib) + 'Interface-module'. + - Link speed and MTU of the adapter a device has been located on is displayed now. (mvIPConfigure) + - Further improved filter driver when packet data does arrive out of order. Immediate (mvGigECapture.sys, version 1.1.10.33) + resend will be disabled in LAG configuration now. + + BUGS FIXED: + - mvBlueFOX devices of type 202b and 202d can be operated again. (mvBlueFOX-lib) + (Bug introduced in version 1.12.33) + +12.10.2011 1.12.33 + DEPRECATED API CODE: + - Windows 2000 version of the GigE Vision filter driver has been declared deprecated. + No new versions will be created but version 1.1.7.30 will remain stay as part of the + driver installation for Windows 2000. + + CHANGED BEVAVIOUR: + - mvBlueCOUGAR-X devices in device specific interface mode do no longer automatically (mvBlueCOUGAR-lib) + set the black level to the lowest possible value by default. + + NEW FEATURES: + - Properties containing binary data can be edited with a simple hex editor now. (wxPropView) + - "Automatically Reconnect To Unused Devices" option added(see 'Usage hints' under (wxPropView) + 'About'). + - "Show Method Execution Errors" option added. (wxPropView) + - I2CControl features added for mvBlueFOX-MLC202 devices. (mvBlueFOX-lib) + - 'UserEEPROMSize' property added. (mvBlueFOX-lib) + - Filter driver behaviour improved when payload packets arrive out of order. (mvGigECapture.sys, version 1.1.9.32) + - Resend statistics will also be updated if resend is switched off now. (mvGigECapture.sys, version 1.1.9.32) + + BUGS FIXED: + - Sometimes the first image of a sequence was returned with a footer error for some (mvBlueFOX-lib) + CMOS versions of the mvBlueFOX-MLC. + - Negative values for 64-bit integer properties can be read and written using the (wxPropView) + property grid now. + - Crashes when closing a device in 'full tree' mode. (wxPropView) + (Bug introduced in version 1.12.29) + - New FPGA file for mvBlueFOX-MLC200 devices added. This fixes a pixel clock related (mvBlueFOX-lib) + issue at 40 MHz pixel clock. + - When storing string property values that did contain either '<' or '>' the resulting (mvPropHandling-lib) + XML file was not well-formed. + +30.09.2011 1.12.32 + NEW FEATURES: + - 'Find Feature' dialog allows logical OR of multiple search strings now. (wxPropView) + - Usage hints, keyboard shortcuts and command line options can be found by pressing (wxPropView) + 'F1' now. + + BUGS FIXED: + - GevSCPx and GevSCDAx where accessed in reverse order. Because of that some devices (mvTLIClientGigE-lib) + refused to open a streaming channel. + - Devices that require 'TLParamsLocked' to be set for 'SingleFrame' acquisition mode (mvBlueCOUGAR-lib) + can be operated in 'SingleFrame' mode now. + - Potential crash when 'Continuous Recording' was active. (wxPropView) + (Bug introduced in version 1.12.22) + - 'The firmware of this device could not be verified' after updating an mvBlueCOUGAR-X (mvDeviceConfigure) + to a FW-version larger or equal than 1.2.0. + +28.09.2011 1.12.31 + NEW FEATURES: + - Properties 'SystemSettings/FeaturePollingEnable' and (mvBlueCOUGAR-lib) + 'SystemSettings/FeaturePollingInterval_ms' added. + + BUGS FIXED: + - Missing newly introduced '$MVIMPACT_ACQUIRE_DIR/common/System/Linux/version.inc' (all shipped Linux packages) + added to TGZ archives. + - Error messages about invalid access to certain HDR related feature upon init for (mvBlueFOX-lib) + mvBlueFOX-202dG, mvBlueFOX-M202dG and mvBlueFOX-ML/IGC202dG devices. + - Serial port communication open/close improved. (mvHYPERION2.sys, version 2.1.31.39) + (mvHYPERION.sys, version 1.0.50.52) + +21.09.2011 1.12.30 + NEW FEATURES: + - mvHYPERION-HD-SDI: Software supported version of interlaced handling added. (mvHYPERIONfg-lib) + - Support for mvBlueFOX-ML/IGC202aG devices added. (mvBlueFOX-lib) + +02.09.2011 1.12.29 + CHANGED BEVAVIOUR: + - If a device supports the 'BalanceWhiteAuto' feature, this feature is switched off in (mvBlueCOUGAR-lib) + 'DeviceSpecific' interface layout for backward compatibility reasons. + + NEW FEATURES: + - Second tool bar added as when working with small horizontal display resolutions not (wxPropView) + not all the tools where visible. + - 'Find Feature' dialog added(e.g. reachable via CTRL+F). (wxPropView) + +31.08.2011 1.12.28 + CHANGED BEHAVIOUR: + - 'Line Profile' plot split into 'Horizontal Line Profile' and 'Vertical Line Profile'. (wxPropView) + - Gain limits adjusted for CCD versions. mvBlueFOX-12x types: was -6.5 - 30.0, became (mvBlueFOX-lib) + -6.48 - 29.7, mvBlueFOX-22x types: was -9.0 - 30.0, became -9.0 - 29.7. + + NEW FEATURES: + - Initial version of GenICam related additional wizards for easier configuration of (wxPropView) + LUTControl and FileAccessControl related features. + + BUGS FIXED: + - Sometimes when writing to a property while internally the polling thread was updating (mvBlueCOUGAR-lib) + features as well some changes where not forwarded to the device. + +25.08.2011 1.12.27 + NEW FEATURES: + - More merge modules added to MSI based packages. (all shipped MSI based packages) + + BUGS FIXED: + - 'FILTER_INSTALL_PARAMS' in the installers property table can be overwritten from the (mvBlueCOUGAR.msi) + outside world now. Please note that overwriting this property will NOT work when (mvBlueCOUGAR-x64.msi) + doing a managed installation with elevated privileges as this is not supported by + Windows Installer. + - SEHException(COM-Context) on some newer i3, i5 and i7 processors when using some of (all shipped packages) + the internal processing functions. + +24.08.2011 1.12.26 + CHANGED BEHAVIOUR: + - The maximum number of request objects is 32767 now. Implicitly this was the case (all shipped packages) + before, but now this is also reflected by all the properties that allow to influence + this value. + - 'VB6Sample' removed(deprecated). (all shipped MSI-based packages) + - Class 'Root' removed. (mvIMPACT_acquire_GenICam.h) + + NEW FEATURES: + - Support for mvBlueLYNX-X devices added. (mvTLIClientGigE-lib) + (mvBlueCOUGAR-lib) + - 'FooterCheckEnable' property added. (mvBlueFOX-lib) + + BUGS FIXED: + - Directly starting live acquisition from the command line is working again. (wxPropView) + (Bug introduced in version 1.12.11) + - On Linux when too much data was send to the display module the application could (wxPropView) + lock up. + - When closing a mvBlueCOUGAR-X in 'DeviceSpecific' interface layout with (mvBlueCOUGAR-lib) + 'TriggerSource' set to 'Software' the next time the device was opened in + 'DeviceSpecific' interface layout not all trigger modes seemed to be available + (only 'Continuous and 'OnHighExpose'). + +16.08.2011 1.12.25 + UPDATES: + - New FPGA file for mvBlueFOX-MLCxxx devices added. (mvBlueFOX-lib) + + NEW FEATURES: + - 'device' command line parameter does accept '*' as a serial number wildcard now. (wxPropView) + + BUGS FIXED: + - Acquisition mode selection did not work properly with every version of wxWidgets. (wxPropView) + - Serial -> MAC Feature is working again. (mvTLIClientGigE-lib) + (Bug introduced in version 1.12.17) + +11.08.2011 1.12.24 + CHANGED BEHAVIOUR: + - Device events reported before an event was registered at the device message port will (mvTLIClientGigE-lib) + by silently discarded now. + - Drivers not supporting the internal 'Update@v' callback for digital input will no (mvDeviceManager-lib) + longer report error messages in the log file. + (Related to change in 1.11.48) + + UPDATES: + - GEV devices will register their user defined name(if supported and set) as the string (mvBlueCOUGAR-lib) + representation of the property mvIMPACT::acquire::Device::deviceID now. + + NEW FEATURES: + - I/O measurement features for mvBlueFOX-2xx and mvBlueFOX-MLCxxx devices added. See (mvBlueFOX-lib) + e.g. the class mvIMPACT::acquire::DigitalIOMeasurementControl. + + BUGS FIXED: + - 'OnChanged' callbacks fired as a result of a device event reported by the GenICam (mvTLIClientGigE-lib) + GenTL producer could not read the 'new' value of a property but received the + previous one. + - 'MirrorMode' property is no longer used internally. (DirectShow_acquire.ax) + +09.08.2011 1.12.23 + NEW FEATURES: + - 'ChannelSplit' can handle Bayer data now. (all shipped packages) + - Files can be written into properties storing binary data and binary data from a + property can be stored into a file when right-clicking on a property in the property (wxPropView) + grid. + - Started to add 'real' pitch(thus a pitch that is NOT width times bytes per pixel) (all shipped packages) + support. + - Support for 'Padding X' and 'Padding Y' as specified in the GEV spec. added. (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + + BUGS FIXED: + - Potential deadlock when a GenICam command with read access got executed in parallel (mvBlueCOUGAR-lib) + with other threads accessing the GenApi runtime. + - Features invalidated by changing others did not accept new values when these were (mvPropHandling-lib) + equal to the value the last time this feature was actively read. + (Bug introduced in version 1.12.17) + - GEV Message channel is set up correctly again. (mvTLIClientGigE-lib) + (Bug introduced in version 1.12.3) + +02.08.2011 1.12.22 + NEW FEATURES: + - Primary application switchover support added. (mvTLIClientGigE-lib) + + BUGS FIXED: + - GenICam features which are write-only can be written to now. (mvBlueCOUGAR-lib) + - When used with multiple displays to display multiple input channels in parallel (wxPropView) + the update for displays receiving data absolutely in parallel could stop resulting + in only a single display refreshing data. + - Some ports of wxWidgets do not allow to have a window without a close button. When (wxPropView) + using this button on the 'monitor image' wxPropView did crash. + - When a callback is fired this is handled in a thread save way now. Certain features (wxPropView) + could cause a deadlock when a callback was registered before as GUI elements were + accessed outside the main thread. + - Updating the firmware of a GEV device sometimes did return DMR_INTERNAL_ERROR even (mvDeviceConfigure) + if the update was successful. + +25.07.2011 1.12.21 + DEPRECATED API CODE: + - 'C': The functions 'DMR_EventWaitFor' and 'DMR_EventGetData' as well as the struct (all shipped packages) + 'EventData'. + 'C++': The classes 'EventSubSystem', 'EventWaitResults' and 'EventData'. + Please refer to the documentation for replacements. + + CHANGED BEHAVIOUR: + - 'showEvents' and 'se' command line options are no longer supported. (wxPropView) + - Sample 'EventHandling' removed(deprecated). (all shipped packages) + + UPDATES: + - 'GVCP_FORCEIP_ALLOW_BROADCAST' added to force IP command for GEV devices. This (mvTLIClientGigE-lib) + will allow devices which move into a different subnet during execution of the + command to send an acknowledge. + - Improved way of reporting errors. Aborted buffers will no longer appear as capture (mvBlueFOX-lib) + errors in the log file. + +21.07.2011 1.12.20 + CHANGED BEHAVIOUR: + - 'OnChanged' callback functions signature introduced in version 1.12.18 has been (all shipped packages) + changed. + + NEW FEATURES: + - New mode added to 'ChannelSplit' filter: csmExtractSingle. Also the 'ChannelSplit' (all shipped packages) + filter interface has been added to the C++ interface now. + +14.07.2011 1.12.19 + NEW FEATURES: + - 'Temporal Noise Histogram' added. (wxPropView) + + UPDATES: + - 'GVCP_DISCOVERY_ALLOW_BROADCAST' added to discovery command for GEV devices. This (mvTLIClientGigE-lib) + will allow devices which reside in different subnets to answer discovery requests. + - 'Noise Histogram' renamed to 'Spatial Noise Histogram'. (wxPropView) + + BUGS FIXED: + - Crash when working with the 'ChannelSplit' filter in 'Vertical' direction and the (all shipped packages) + input format for the filter was either 'ibpfYUV422_UYVY_10Packed' or + 'ibpfYUV422_10Packed'. + +13.07.2011 1.12.18 + NEW FEATURES: + - An application can register an 'OnChanged' callback on an arbitrary feature now. See (mvPropHandling-lib) + new 'Callback' and 'Callback_C' samples for details or right click on a feature in (mvDeviceManager-lib) + wxPropViews property grid and then monitor feature changes in the 'Output' window. (mvIMPACT_acquire.h) + (wxPropView) + - 'mvGevInterfaceMTU' added to nodemaps of 'System-module' and 'Interface-module'. (mvTLIClientGigE-lib) + The interface MTU also internally serves as a boundary for packet size negotiation + now which can help in case of a misbehaving NIC driver. + + BUGS FIXED: + - mvBlueFOX-202b and mvBlueFOX-202d devices did use an incorrect minimal width and (mvBlueFOX-lib) + height as well as an incorrect increment for the AOI/W and AOI/H parameters. + - mvBlueFOX-MLC devices switched on the digital outputs for about 500us during init. (mvBlueFOX-lib) + +07.07.2011 1.12.17 + UPDATES: + - Reduced network traffic. When one feature invalidates one or more other features (mvBlueCOUGAR-lib) + these invalidated features will not be queried from the device unless an application + re-reads them. + - MAC addresses can be build from serial numbers for mvBlueLYNX-M7 and some OEM devices (mvTLIClientGigE-lib) + now. + + BUGS FIXED: + - The current state of the digital inputs can be read back again. (mvTITANfg-lib) + (Bug introduced in version 1.11.48) (mvSIGMAfg-lib) + (mvHYPERIONfg-lib) + (mvBlueCOUGARLocal-lib) + - Firmware updates for mvBlueCOUGAR-S devices are possible again. (mvDeviceConfigure) + (Bug introduced in version 1.11.51) + - Retrieving URL strings from a remote device did fail if the URL address was higher or (mvTLIClientGigE-lib) + equal 0x80000000, which could be the case if the remote device does support a + manifest table. + - camera-info-thread startup behaviour improved. (mvHYPERIONfg-lib) + +05.07.2011 1.12.16 + NEW FEATURES: + - 'FlashType' 'VSync' added for mvBlueFOX-MLC202d devices. (mvBlueFOX-lib) + - Modifying the 'GevGVCPHeartbeatDisable' feature of a GEV device will also cause the (mvTLIClientGigE-lib) + internal heartbeat handling to be updated now. + +04.07.2011 1.12.15 + BUGS FIXED: + - mvHYPERION-HD-SDI, stopping internal camera-info-thread corrected. (mvHYPERIONfg-lib) + - mvHYPERION-HD-SDI, connector capabilities corrected. (mvHYPERIONfg-lib) + - Potential crash when starting the acquisition did fail and logging was enabled on (mvBlueCOUGAR-lib) + 32-bit platforms. + +30.06.2011 1.12.14 + CHANGED BEHAVIOUR: + - Internal sensor update timeout increased in order to address situations where a (mvBlueCOUGARLocal-lib) + sensor update was delayed by other tasks. + + NEW FEATURES: + - Custom FPGA files can be selected using the 'CustomFPGAFileSelector' property. (mvBlueFOX-lib) + + BUGS FIXED: + - Starting the acquisition is working again in 'Generic' and 'GenICam' interface (mvBlueCOUGAR-lib) + layout. + (Bug introduced in version 1.12.11) + - Closing multiple mvBlueFOX devices could take a very long time on Linux. (mvBlueFOX-lib) + - Camera/TriggerControls/FrameStart/TriggerSource did contain string values 'GP-IN0' (mvBlueCOUGARLocal-lib) + and 'GP-IN1' instead of 'Line2' and 'Line3'. + +15.06.2011 1.12.13 + NEW FEATURES: + - x64 version of the kernel mode driver added. This will allow existing 32-bit (mvTITAN_mvGAMMA-x64.msi) + applications to run on x64 bit versions of Windows. However this will still NOT allow + true x64 applications to run with mvTITAN/mvGAMMA boards. + - Generic interface header files added for 'GenICam' interface layout: (all shipped packages) + mvIMPACT_acquire_GenICam.h and mvIMPACT_acquire_GenICam_FileStream.h. + + UPDATES: + - New version of the CRT and OpenMP runtimes added. (all shipped MSI based packages) + + BUGS FIXED: + - If the max. value was also the most frequent value, incorrect data was displayed in (wxPropView) + the histogram plot. + (Bug introduced in version 1.12.9) + +08.06.2011 1.12.12 + CHANGED BEHAVIOUR: + - Acquisition mode 'SingleFrame' is no longer available for GEV devices that don't (wxPropView) + support this mode. + + NEW FEATURES: + - Firmware version 1.3.36.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + New features: + - Device specific AutoExposure, AutoGain and AutoWhiteBalance with AutoHighlightAOI. + - mvAcquisitionMemoryMode: For recording and playback of images. + - DigitalGain and DigitalBlackLevel implemented. + - UserOutputValueAll implemented. + - TimerReset and CounterReset via Command and ResetSource. + - Mono12/Mono14 format implemented. + Changed behaviour: + - GevSCBW unit changed (KByte/s -> KBps). + - ChunkSelector Pixelformat -> PixelFormat. + - ChunkTimer -> ChunkTimerValue. + - ChunkCounter -> ChunkCounterValue. + - Default TimerTriggerSource = TimerEnd -> free-running timer. + - BlackLevel: Unit is now percent of saturation. + Bugs fixed: + - Router capability disabled(could lead to network overloads). + - Colors of YUV formats are correct now. + + BUGS FIXED: + - Continuous acquisition for mvHYPERION devices is working under wxPropView again. (mvHYPERIONfg-lib) + (Bug introduced int version 1.12.11) + - 'Capture -> Capture Settings -> Usage Mode' selection is stored and restored when (wxPropView) + opening/closing the application. + - Update of the internal setting table when working with multiple settings and displays (wxPropView) + when loading a setting at runtime was missing. + +06.06.2011 1.12.11 + DEPRECATED API CODE: + - The class mvIMPACT::acquire::SystemBlueCOUGAR has been declared deprecated (mvIMPACT_acquire.h) + and will be removed in future versions. Use mvIMPACT::acquire::SystemSettings + instead. + + NEW FEATURES: + - 'mvIMPACT::acquire::FunctionInterface::acquisitionStart', (all shipped packages) + 'mvIMPACT::acquire::FunctionInterface::acquisitionStop', + 'mvIMPACT::acquire::Device::acquisitionStartStopBehaviour', + 'DMR_AcquisitionStart' and 'DMR_AcquisitionStop'. + - Refactored acquisition mode selection and added support for 'MultiFrame' (wxPropView) + acquisition for devices supporting this mode. + +01.06.2011 1.12.10 + CHANGED BEHAVIOUR: + - Increased maximum exposure to 8s for mvBlueFOX-x02b/d(with minimum pixel clock). (mvBlueFOX-lib) + - Fixed read back of exposure time to real value. (mvBlueFOX-lib) + - Correctly limit exposure time if internal limit reached. (mvBlueFOX-lib) + + UPDATES: + - Merged with current code base(includes some minor fixes). (mvBlueCOUGARLocal-lib) + +30.05.2011 1.12.9 + CHANGED BEHAVIOUR: + - Displayed minimum, maximum, deviation etc. of a histogram plot will only take into (wxPropView) + account the current draw window now. The plot will be scaled to the maximum value of + that selected draw window. + + UPDATES: + - URL handling improved. (mvTLIClientGigE-lib) + + BUGS FIXED: + - The current state of the digital inputs in 'DeviceSpecific' interface layout can be (mvBlueCOUGAR-lib) + read back again. + (Bug introduced in version 1.11.48) + - mvHYPERION-SDI: Only supported capture pixel formats can be selected now. (mvHYPERIONfg-lib) + - Mysterious 'dummy' device does no longer show up on Linux. (mvTLIClientGigE-lib) + (Bug introduced in version 1.12.5) + - Does no longer crash at startup. (mvIPConfigure) + (Bug introduced in version 1.12.5) + +20.05.2011 1.12.8 + CHANGED BEHAVIOUR: + - Linescan mode optimization added to correction filter (dark current and flat field) (mvHYPERIONfg-lib) + + BUGS FIXED: + - Makefile corrected for Linux build (mvHYPERIONfg-lib) + +12.05.2011 1.12.7 + BUGS FIXED: + - Device specific AGC/AEC is available in 'DeviceSpecific' interface layout for (mvBlueCOUGAR-lib) + mvBlueCOUGAR-X devices with firmware versions 1.2.9 and greater now. + - Potential crashes when calling 'DSClose'. This e.g. happened when closing a device. (mvTLIClientGigE-lib) + (Bug introduced in version 1.12.5) + - Deadlock in case an invalid device handle was passed to 'DevGetPort', (mvTLIClientGigE-lib) + 'DevGetNumDataStreams', 'DevGetDataStreamID'. 'DevOpenDataStream', 'DevGetInfo', + 'TLIMV_DevSetParam', 'TLIMV_DevGetInterfaceParam' or 'TLIMV_DevSetInterfaceParam'. + (Bug introduced in version 1.12.4) + - Remote device events can be received after a device was disconnected and then (mvTLIClientGigE-lib) + reconnected again. + (Bug introduced in version 1.12.5) + +10.05.2011 1.12.6 + NEW FEATURES: + - Support for mvBlueFOX-ML/IGC202dG, Rev >= 0.92 (mvBlueFOX-lib) + - In-place version of Tap sort filter added. (all shipped packages) + - New property added to system setting list to influence memory usage behaviour of (all shipped packages) + image-processing filters. + + CHANGED BEHAVIOUR: + - Serial port, polling period changed in serialwrite() (mvHYPERION2.sys, version 2.1.30.38) + (mvHYPERION.sys, version 1.0.49.51) + - Firmware error handling added, mvHYPERION devices should have at least firmware (mvHYPERIONfg-lib) + version 57. Older firmware are not recommended. + +03.05.2011 1.12.5 + CHANGED BEHAVIOUR: + - Sensor FIFO is reseted when 'imageRequestReset' is called now. (mvBlueFOX-lib) + - GEV test packet validation enabled. (mvTLIClientGigE-lib) + + UPDATES: + - Number of default debug writer tags increased from 8 to 16 for all USB and GEV (all shipped packages) + devices. + - Some gcc 4.5 related crashes fixed by moving around some code and changing the name (all shipped Linux packages) + of some internal classes. + + BUGS FIXED: + - Missed frames calculation correctly handles wrap-around conditions of the frame (mvBlueFOX-lib) + counter now. + - Settings without a hierarchy table can be restored correctly from the Windows (all shipped MSI based packages) + Registry again. + (Bug introduced in version 1.12.4) + +28.04.2011 1.12.4 + NEW FEATURES: + - For GigE Vision compliant devices mvIPConfigure can be launched from the 'Set ID' (mvDeviceConfigure) + dialog now. + - Setting hierarchies can be stored and restored as part of a load/save setting (all shipped packages) + operation now. XML based settings stored with the setting hierarchy included can only + be restored using mvIMPACT Acquire packages with version 1.12.4 or greater. + + BUGS FIXED: + - When an initialised GEV device was unplugged or stopped communicating with an (mvTLIClientGigE-lib) + application all other devices could no longer stream data to this application + properly. + +19.04.2011 1.12.3 + CHANGED BEHAVIOUR: + - When attaching a user supplied buffer to a request the internal buffer previously (all shipped packages) + attached to this request will be unlocked, which will result in memory being freed + in most cases. When removing the user supplied buffer later the internal request + memory will be re-allocated automatically. + - Prepared the GenICam GenTL producer to support other transport layer technologies. (mvTLIClientGigE-lib) + The reported transport layer type of the system module now e.g. will be 'Mixed'. + This later might affect applications that assume only GEV devices devices to be + reported by the library. Therefore an application should then check the TLTYPE value + carefully. + + BUGS FIXED: + - Writing binary data to a string property and then reading it back could result in (mvPropHandling) + in incorrect data if the size of the original binary buffer was not a multiple of 4 + and one of the last 3 bytes did contain a value larger than 127. + - mvIMPACT::acquire::Request did always report either a single ChunkCounterValue or a (mvIMPACT_acquire.h) + single ChunkTimerValue property no matter how many timers or counters have actually + been part of the chunk data. + +12.04.2011 1.12.2 + UPDATES: + - Internal migration to IPP 7.0.3. (all shipped packages) + + CHANGED BEHAVIOUR: + - AbortAllRequests, exception handling improved. (mvHYPERION2.sys, version 2.1.29.37) + + NEW FEATURES: + - Function 'OBJ_GetBinaryBufferMaxSize added to 'C'-interface and (all shipped packages) + 'mvIMPACT::acquire::PropertyS::binaryDataBufferMaxSize' added to 'C++'-interface. + + BUGS FIXED: + - Incorrect black level calibration offset for certain exposure times for mvBlueFOX-x05 (mvBlueFOX-lib) + devices. + - Potential blue screen (BSOD) when re-requesting lost data packages. (mvGigECapture.sys, version 1.1.7.30) + +05.04.2011 1.12.1 + NEW FEATURES: + - Support for mvBlueFOX-ML/IGC202d and mvBlueFOX-ML/IGC205 devices added. (mvBlueFOX-lib) + - HDR control features added for mvBlueCOUGAR-Xx00w devices in device specific (mvIMPACT_acquire.h) + interface layout. + +25.03.2011 1.12.0 + CHANGED BEHAVIOUR + - Functions and classes that have been declared deprecated for some time now have (mvIMPACT_acquire.h) + been removed from the C/C++ interface. This will not break existing binaries, but (mvDeviceManager.h) + will force you to change your code during rebuilds when deprecated code was used by + your application. A list of functions that have been removed and their replacement + can be found in the device drivers manual under + 'C/C++ developer -> Porting existing code'. + - mvHYPERION-SDI: Auto-detect camera mode improved. (mvHYPERIONfg-lib) + - Analysis plot colors better represent the actual color channels of the image buffer (wxPropView) + now. + + NEW FEATURES: + - x64 version of the kernel mode driver added. This will allow existing 32-bit (mvDELTA_mvSIGMA-x64.msi) + applications to run on x64 bit versions of Windows. However this will still NOT allow + true x64 applications to run with mvDELTA/mvSIGMA boards. + - Initial version of the color twist filter published under image processing. (all shipped packages) + - Configuration dialog now uses the same property grid control as wxPropView. (DirectShow_acquire.ax) + - mvHYPERION-SDI: Additional mvHDCam info stuff added. (mvHYPERIONfg-lib) + - Support for mvHDCam output modes Raw2K, YUV, RawTwoInOne, Raw12bit added. (mvHYPERIONfg-lib) + - Error handling improved for 3G-SDI video input. (mvHYPERIONfg-lib) + + BUGS FIXED: + - When a driver internally did modify a property that did specify the (wxPropView) + 'cfShouldBeDisplayedAsList' flag the current editor in the property grid was + deselected. + - Displaying and storing frames belonging to a recorded sequence does work again. (wxPropView) + (Bug introduced in version 1.11.49) + - When working with hardware LUTs in interpolated mode with interpolation mode set to (all shipped packages) + 'Linear' the final value of the calculated LUT was not always correct. + - When the read-only property selected in the grid became writable (e.g. because the (wxPropView) + live mode was stopped and this property can only be modified when the device doesn't + stream data) the editor could only be reactivated if selecting a different + property and then the current one again. + - Previous driver versions did ignore value changes smaller than 0.01 for GenICam float (mvBlueCOUGAR-lib) + properties. + - Driver based controller for AEC and AGC did not work after a long period with (all shipped packages) + almost no light. + +16.03.2011 1.11.53 + BUGS FIXED: + - HRT-controller reset added when programming a new controller sequence. Only HRTC's (mvHYPERION2.sys, version 2.1.28.36) + modifying digital output signals have been affected. (low level mvHYPERION2 driver, Linux) + +15.03.2011 1.11.52 + NEW FEATURES: + - 'TestMode' 'vdtmEmptyMonoBuffer' added. (mvVirtualDevice-lib) + - Initial version of 'SystemSettings/MemoryInit' features added. No interface (all shipped packages) + published so far. Meant for debugging purposes only. + - Final version of 'MotorFocus' features added and published via class (mvBlueFOX-lib) + 'mvIMPACT::acquire::MotorFocusControl'. + - Class mvIMPACT::acquire::CameraDescriptionSDI added (mvIMPACT_acquire.h) + - The double linescan mode(BayerPacked) demosaic algorithms can deliver (mvHYPERIONfg-lib) + ibpfRGBx888Planar directly now. This removes one internal conversion for certain + setups. + + BUGS FIXED: + - In 'Generic' and 'GenICam' interface layout when queuing the first buffer and calling (mvBlueCOUGAR-lib) + 'TriggerSoftware' directly afterwards in rare cases the command was send to the + device before the streaming has been started resulting in the trigger command being + ignored. + + CHANGED BEHAVIOUR: + - 'OBJ_Execute' or 'mvIMPACT::acquire::Method::call' do no longer accept callers who (mvPropHandling-lib) + pass too many parameters. Now the amount of parameters must exactly match what is + expected or an 'PROPHANDLING_WRONG_PARAM_COUNT' error will be returned and an + appropriate exception might be generated. + - Content descriptor of SDI camera descriptions changed from 'SDICamera' to 'SDI'. (mvHYPERIONfg-lib) + Because of this change existing camera descriptions will no longer be detected until + these files are adapted by changing the file name and the 'contentDescriptor' and + 'name' attribute in the root 'Proplist' node of the file. + - Visibility of propertylists in the videocapture dialogbox is now based on wxWidgets. (DirectShow_acquire) + +09.03.2011 1.11.51 + BUGS FIXED: + - Vertical Scrollbar of wxPropView is working again. (mvDisplay-lib) + (Bug introduced in version 1.11.50) + + NEW FEATURES: + - Properties 'mvIMPACT::acquire::Info::recommendedListsForUIs' added. (all shipped packages) + - Bayer images can be treated as mono(single channel) images now by histogram, line (wxPropView) + and intensity plots. + - Initial version of 'MotorFocus' features added to driver. However these are still (mvBlueFOX-lib) + subject to change thus so far are meant for evaluation purposes only. + - Support for mvBlueFOX-MLC205 devices added. (mvBlueFOX-lib) + + CHANGED BEHAVIOUR: + - Property grid view mode 'Multiple Settings View' became 'Standard View'. Old (wxPropView) + 'Standard View' removed. + - Some properties renamed: + - 'CustomDescriptionFilename' became 'CustomDescriptionFileName' (mvBlueCOUGAR-lib) + - 'PseudoFilenameProperty' became 'PseudoFileNameProperty' (mvVirtualDevice-lib) + - 'Filename' became 'FileName' in all lists within 'LUTs'. (all shipped packages) + +03.03.2011 1.11.50 + NEW FEATURES: + - Properties 'mvIMPACT::acquire::Request::imageWidthTotal' and (all shipped packages) + 'mvIMPACT::acquire::Request::imageHeightTotal' added. + + BUGS FIXED: + - If one or more features selected by another one did contain values which where out (mvBlueCOUGAR-lib) + of bounds for the feature of the device to update, an update from a setting could be + incomplete. + - 'TLParamsLocked' feature is set correctly according to the current streaming state (mvBlueCOUGAR-lib) + in 'Generic' and 'GenICam' interface layout again. + (Bug introduced in version 1.11.48) + - Chunk buffers that did not contain any data(just leader and trailer) will no longer (mvBlueCOUGAR-lib) + be returned with result 'rrFrameIncomplete'. (mvTLIClientGigE-lib) + - HW-SPI-Access improved to support the automatic camera parameter detection under (mvHYPERIONfg-lib) + Linux as well. (low level mvHYPERION2 driver, Linux) + - Installation of version 2.1.1 of the GenApi runtime is working correctly now. (mvBlueCOUGAR driver, Linux) + (Bug introduced in version 1.11.42) + - Internal data transfer improved. Now the corresponding routine called from the (mvHYPERIONfg-lib) + FPGA-processor waits until all data has been transferred completely. + +23.02.2011 1.11.49 + NEW FEATURES: + - Automatic camera parameter detection added for mvHYPERION-SDI devices. The driver (mvHYPERIONfg-lib) + now tries to scan and detect the parameters of the connected SDI devices. If the + camera description 'SDICameraAutoDetect' is used then these detected parameters will + be used for image requests. + - Support for mvHYPERION-CLb hardware revision 3.xx added. (mvHYPERIONfg-lib) + (mvHYPERION2.sys, version 2.1.27.35) + (low level mvHYPERION2 driver, Linux) + CHANGED BEHAVIOUR: + - Pending calls to 'imageRequestWaitFor' will return with 'DMR_WAIT_ABANDONED' (all shipped packages) + now whenever 'imageRequestReset' is called from a different thread. + - Optimized driver for very high frame rates. This will improve the overall max. frame (mvBlueFOX-lib) + rate that can be achieved without losing frames but will consume more physical memory + when increasing the request count for the driver instance of a specific device. + +10.02.2011 1.11.48 + CHANGED BEHAVIOUR: + - All 'Update@v' functions to update the state of the digital inputs of a device have (all shipped packages) + been removed. When reading the value of a digital input it will be updated + automatically to reflect its current state. In wxPropView to re-read the state of a + digital input right-click on the property and select 'Force Refresh' from the menu. + + NEW FEATURES: + - The 32-bit version of the VisionPro adapter is correctly recognized on 64-bit (all shipped MSI-based packages) + versions of Windows running a 64-bit mvIMPACT Acquire driver. + - Ancillary data support added for Hyperion-SDI grabber. Now if connecting a (mvHYPERIONfg-lib) + mvHDCam-SDI with anc_data support the grabber could read data like serial number or + device ID independent from serial connection. + - Error handling improved if onboard-processor could not start. (mvHYPERIONfg-lib) + + BUGS FIXED: + - mvBlueCOUGAR-P/mvBlueLYNX-M7 devices can be used in 'DeviceSpecific' interface layout (mvBlueCOUGAR-lib) + again. + (Bug introduced in version 1.11.28) + - When an 'onRead' callback was attached to a property storing more than a single value (mvPropHandling-lib) + reading any other value than the one at index 0 did cause a crash. + - Multiple file access to driver instance improved. Sometimes if working with serial (mvHYPERION2.sys, version 2.1.26.34) + connection in one process and the capture stuff in a different process the system + could stop if closing the driver access (closefile). + - Start/stop trigger sometimes resulted in halve the frame rate if enabling UserAoi in (mvHYPERIONfg-lib) + the camera settings. + +25.01.2011 1.11.47 + CHANGED BEHAVIOUR: + - Start/stop trigger mode: Previous versions did delay incoming stop trigger signals (mvHYPERIONfg-lib) + which resulted in a reduced overall trigger frequency. Now this delay has been + removed. + + BUGS FIXED: + - FPGA <-> processor communication improved. More than one task/process/thread can (mvHYPERION2.sys, version 2.1.25.33) + access digital I/O related functions simultaneously now. + - Previous version did allow to set negative camera AOI parameters. (mvHYPERIONfg-lib) + +19.01.2011 1.11.46 + NEW FEATURES: + - Support for multiple displays and multiple capture settings added. (wxPropView) + - BayerPacked format added to camera description. (mvHYPERIONfg-lib) + - linescan start condition can be combined with FVAL. This mode is needed to avoid any (mvHYPERIONfg-lib) + color mismatch for cameras which support Bayer packed mode. (mvHYPERION2.sys, version 2.1.24.32) + + UPDATES: + - Devices that report register addresses that don't fit into the 32-bit specified (mvBlueCOUGAR-lib) + by the GEV standard can be used now(without the features using invalid addresses). + - Improved behaviour for devices not using the standard category names for chunk + features if the device does at least support 'ChunkWidth'. + - Integer and float properties which where not readable at the time of opening the (mvBlueCOUGAR-lib) + device can be created now. + - Categories that do not contain any accessible feature will no longer created. (mvBlueCOUGAR-lib) + + BUGS FIXED: + - In 'DeviceSpecific' interface layout the first image was taken with the default (mvBlueCOUGAR-lib) + exposure time instead of the selected one if the exposure mode was set to + 'cemStandard' + (Bug introduced in version 1.11.24) + - In rare case assigning a value too large or too small to a floating point property (wxPropView) + could cause the application to crash if the properties min/max value did have a lot + of digits after the comma. + - Crashes when working with GEV devices supporting chunk mode under .NET. Memory (mvIMPACT_acquire.h) + corruptions where reported by the garbage collector in Request::Dispose. + (Bug introduced in version 1.11.29) + - Display can deal with images in ibpfMono12Packed_V2 that have an odd width now. (mvDisplay-lib) + - Binning is working correctly now for mvBlueFOX-x02xx devices. (mvBlueFOX-lib) + +07.01.2011 1.11.45 + CHANGED BEHAVIOUR: + - Renamed mvIMPACT::acquire::Request::getChunkCounter to (mvIMPACT_acquire.h) + mvIMPACT::acquire::Request::getChunkCounterValue and + mvIMPACT::acquire::Request::getChunkTimer to + mvIMPACT::acquire::Request::getChunkTimerValue. + + BUGS FIXED: + - Installation of version 2.1.1 of the GenApi runtime is working correctly now. (mvBlueCOUGAR.msi) + (Bug introduced in version 1.11.42) (mvBlueCOUGAR-x64.msi) + - Under certain conditions image requests could be lost. Then not every image request (mvBlueFOX-lib) + actually did result in an image being captured and transmitted by the camera. + - Automatic installation of the filter driver is working again. (mvBlueCOUGAR-x64.msi) + (Bug introduced in version 1.10.86) + +21.12.2010 1.11.44 + CHANGED BEHAVIOUR: + - EXPERIMENTAL: Some internal threads reserve smaller stack sizes now. (mvBlueCOUGAR-lib) + (Windows only) (mvTLIClientGigE-lib) + - In 'Generic' interface layout trying to load or save a setting will report (mvBlueCOUGAR-lib) + DMR_FEATURE_NO_AVAILABLE now as load/save operations for settings are not supported + anyway. + + NEW FEATURES: + - 2 new samples added to Linux packages: 'CaptureToUserMemory_C' and (all shipped Linux packages) + 'ContinuousCapture_C'. + - Log files can be moved around in the file system and still be viewed with (all shipped packages) + mvLogFileViewer.html without changing files.mvloglist afterwards. + - Import of *.raw images with pixel formats 'ibpfBGR888Packed', (wxPropView) + 'ibpfBGR101010Packed_V2', 'ibpfYUV444_UYVPacked', 'ibpfYUV444_UYV_10Packed', + 'ibpfYUV444Packed' and 'ibpfYUV444_10Packed' improved. + + BUGS FIXED: + - Import of *.raw images with Bayer data is working now. Storing RAW Bayer images did (wxPropView) + create files with a ':' in the file name, which is an illegal character for file + names. + - Internal controller handling improved. This will improve the support for area scan (mvHYPERIONfg-lib) + cameras in trigged applications. + +16.12.2010 1.11.43 + NEW FEATURES: + - Extended line valid(LVAL) signal feature added. The user can extend the camera AOIs (mvHYPERION.sys, version 1.0.48.50) + width only if the cameras horizontal pixels per line are not compatible with the (mvHYPERION2.sys, version 2.1.23.31) + mvHYPERIONs alignment restrictions. (low level mvHYPERION and mvHYPERION2 driver, Linux) + - VectorScope plot can deal with YUV422Packed formats now. (wxPropView) + +10.12.2010 1.11.42 + CHANGED BEHAVIOUR: + - Property 'SystemSettings/Camera/AdvancedImageInfo' removed. Use (mvBlueFOX-lib) + 'Camera/AdvancedOptions' with 'daoImageAverage' in the setting instead. + + NEW FEATURES: + - New pixel formats introduced: 'ibpfBGR101010Packed_V2', 'ibpfYUV444_UYVPacked', (all shipped packages) + 'ibpfYUV444_UYV_10Packed', 'ibpfYUV444Packed', 'ibpfYUV444_10Packed'. + - Linux version can deal with ibpfBGR888Packed now. (wxPropView) + - Rotation filter supports 'ibpfRGBx888Planar' now. (all shipped packages) + - New property 'AdvancedOptions' added to 'Camera' list of each setting. (mvBlueFOX-lib) + - 3G-SDI YUV422_10bit support added. (mvHYPERIONfg-lib) + - 3G-SDI Rawmode support added, 10 or 12 bit. (mvHYPERIONfg-lib) + - TriLevelSync added for synchronizing external devices. (mvHYPERIONfg-lib) + - On-board flash memory can now be selected by the driver (user or default). (mvHYPERIONfg-lib) + + UPDATES: + - Migration to version 2.1.1 of the GenApi runtime. (mvBlueCOUGAR installer) + + BUGS FIXED: + - For formats 'ibpfRGB101010Packed' - 'ibpfRGB161616Packed' the channel split filter (all shipped packages) + did crash in 'vertical' mode. + - When a setting was stored while 'AcquisitionMode' was set to 'Continuous' and (mvBlueCOUGAR-lib) + streaming was active the current state of 'TLParamsLocked' was stored as well, which + in 'Generic' interface layout could result in certain streaming related properties + being read-only after opening the device even if streaming was not active. + - Internal conversions from ibpfMono8 to ibpfRGBx888Planar could cause crashes if the (all shipped packages) + physical buffer size of the source buffer was larger than the width times the line + pitch of this buffer. + - For formats 'ibpfRGB101010Packed' - 'ibpfRGB161616Packed' a correct RGB value is (wxPropView) + displayed in the right corner of the status bar now. + - Images with a width that is not divisible by 4 are stored correctly to a file now. (wxPropView) + (Windows only) + - Properties that specify the 'cfAllowValueCombinations' that only had a 'None'(0) (wxPropView) + entry in their translation dictionary did cause wxPropView to crash. These properties + will be read-only in wxPropView now. + - Sometimes the trigger controller didn't switch synchronously with the corresponding (mvHYPERIONfg-lib) + request. + +01.12.2010 1.11.41 + NEW FEATURES: + - Support for Bayer versions of ibpfMono12Packed_V2 added. (all shipped packages) + + BUGS FIXED: + - Continuous calls to 'DMR_Init' and 'DMR_Close' did cause an error code -2100 (mvBlueFOX-lib) + after roughly 500 iterations. + (Linux only) + - Restart trigger improved if waiting on all possible trigger events (acquisitionStart, (mvHYPERIONfg-lib) + frameStart, frameStop). + - In case of frameStart trigger event when aborting a capture sequence with (mvHYPERIONfg-lib) + 'imageRequestReset' all following requests will return with timeout error. + - DeviceVersion is now reported correctly. (mvHYPERIONfg-lib) + +30.11.2010 1.11.40 + CHANGED BEHAVIOUR: + - All the 'Pseudo'-features have been moved into a sub-category 'PseudoFeatures' (mvVirtualDevice-lib) + + NEW FEATURES: + - After resetting or re-connecting a device all GenICam related features will be (mvBlueCOUGAR-lib) + invalidated now. + + BUGS FIXED: + - Disconnecting or resetting the device while no requests where being processed (mvBlueCOUGAR-lib) + resulted in the data streams not being closed properly. + - mvBlueCOUGAR-S devices can be used for streaming in 'DeviceSpecific' interface again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.37) + - On Linux mvIPConfigure is working again. The application does no longer directly (mvIPConfigure) + link to the mvTLIClientGigE-lib. + +26.11.2010 1.11.39 + NEW FEATURES: + - HDR support added for mvBlueFOX-x02d devices added. (mvBlueFOX-lib) + + UPDATES: + - Slightly improved read/write access to GigE Vision devices(no longer queries the CCP (mvTLIClientGigE-lib) + register before the actual read/write access). + + BUGS FIXED: + - When 'ImageDestination/PixelFormat' was different from 'idpfAuto' or 'idpfRaw' and (all shipped packages) + the device itself did change the pixel format randomly(thus did not transfer what + was requested) the format converter did perform a conversion based on incorrect + assumptions. + - In rare cases disconnecting a device while a continuous stream was running could (mvBlueCOUGAR-lib) + result in crashes. + - Working with external trigger: triggerstart/stop corrected. Some combinations of (mvHYPERIONfg-lib) + previous driver versions and firmware > f57 this triggermode resulted in incorrect + pixel data. This behaviour is now corrected and all combinations of trigger are + supported again. + +25.11.2010 1.11.38 + CHANGED BEHAVIOUR: + - Increased 'PoolSize' registry parameter from 256 MB to 640 MB for Cognex adapter. (all shipped MSI-based packages) + This will fix certain timeout issues when running devices with high resolutions via + the mvIMPACTAcquire_Cognex_Adapter-lib. Please note that this memory is NOT + automatically consumed unless truly needed. + - The data type of the property mvIMPACT::acquire::TriggerControl::triggerDelayAbs_us (mvHYPERIONfg-lib) + has been changed from int to float in order to be compatible with other device (mvIMPACT_acquire.h) + drivers. + + BUGS FIXED: + - When an GenTL function was called without calling 'GCInitLib' and 'TLOpen' before (mvTLIClientGigE-lib) + this did initialise the 'System' module by accident. + - Calling 'DSFlushQueue' with 'ACQ_QUEUE_UNQUEUED_TO_INPUT' or 'ACQ_QUEUE_ALL_TO_INPUT' (mvTLIClientGigE-lib) + or 'DSStopAcquisition' with 'ACQ_QUEUE_ALL_TO_INPUT' could result in buffers being + returned without fresh data. + - mvIMPACT Acquire drivers < 1.10.55 can be initialised again. (wxPropView) + (Bug introduced in version 1.11.37) + - Line profile in YUV422 modes did contain incorrect 'V' values for all even pixels (wxPropView) + of a line. + - Image request control mode 'trial' is working again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.35) + - In device specific legacy trigger mode the selection of the corresponding digital (mvBlueCOUGAR-lib) + input is working with mvBlueCOUGAR-S. + (Bug introduced in version 1.11.37) + - Request Info properties 'FrameNr' and 'CameraOutputUsed' now report valid data. The (mvHYPERION2.sys, version 2.1.22.30) + 'FrameNr' property reports now a channel specific counter. This counter will be (mvHYPERIONfg-lib) + incremented for every request handled by the FPGA-processor. + - Working with external trigger events: Combinations of StartTrigger and DelayLines now (mvHYPERIONfg-lib) + works correctly. Previous version did restart the trigger controller during each + request and under certain conditions trigger events will had been missed. + - Medium CameraLink modes RGB30 and RGB36 corrected. Not all ways of switching between (mvHYPERIONfg-lib) + CameraLink modes Base and Medium where working correctly. + +23.11.2010 1.11.37 + DEPRECATED API CODE: + - The interface layout 'Generic' has been declared deprecated. Please use 'GenICam' (all shipped packages for GigE Vision devices) + instead, which offer a more flexible access to GenICam devices. + + CHANGED BEHAVIOUR: + - The default interface layout became 'GenICam' if supported by the connected device. (wxPropView) + + NEW FEATURES: + - Firmware version 1.2.9.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + This fixes the following issues: + - line debouncer is working now + - mvBlueCOUGAR-X100wG/C devices did start up with the horizontal mirror enabled. + - Fixed caching issues in some command registers(e.g. UserSetLoad and UserSetSave) + - New GenICam description file for mvBlueCOUGAR-S devices added(version 3.0.0) (mvBlueCOUGAR installer) + This might not be completely backward compatible but will introduce SFNC compliant + names for categories and fixes some minor issues. + + UPDATES: + - Now 15 instead of 5 different trigger modes can be handled by the device specific (mvBlueCOUGAR-lib) + interface layout. + + BUGS FIXED: + - Potential crash during firmware update via mvDeviceConfigure. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.35) + - Devices that did offer more than 1 root category with names similar to a standard (mvBlueCOUGAR-lib) + category(e.g. DeviceControl and MyDeviceControl) in the GenICam XML file could not + be initialised. + - In device specific legacy trigger mode the selection of the corresponding digital (mvBlueCOUGAR-lib) + input is working with mvBlueCOUGAR-X firmware versions 1.2.x or greater now. + - Property 'TriggerSource' did not become invisible when switching to (mvBlueCOUGAR-lib) + 'TriggerInterface' 'Advanced'. + - Deadlock when an mvBlueFOX is disconnected during a running acquisition when the (mvBlueFOX-lib) + 'ImageRequestTimeout_ms' property is set to 0. + +08.11.2010 1.11.36 + NEW FEATURES: + - Experimental version of a low-light exposure mode for mvBlueFOX-x02d devices added. (mvBlueFOX-lib) + (subject to change, use with care) + + BUGS FIXED: + - In AGC mode the default upper gain limit is the maximum gain allow again and not 0. (mvBlueFOX-lib) + (Bug introduced in version 1.11.13) (mvBlueCOUGAR-lib) + - Connected devices are displayed again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.20) (mvTLIClientGigE-lib) + (mvGigEConfigure) + - The update of visibilities of properties in the 'TransportLayerControl' list or the (mvBlueCOUGAR-lib) + 'FileAccessControl' list did not work correctly in 'DeviceSpecific' interface layout + and 'Generic' interface layout. + - In 'DeviceSpecific' interface layout the access mode of 'mvGevSCBWControl' and (mvBlueCOUGAR-lib) + 'mvGevSCBW' was not updated correctly with respect to the current state of + 'TLParamsLocked'. + - If a device is accessible via more than one interface, it is displayed on every (mvBlueCOUGAR-lib) + matching adapter now(before it was only listed at the first one the device has been (mvGigEConfigure) + detected on. + +05.11.2010 1.11.35 + NEW FEATURES: + - Added support for 'BUFFER_INFO_IMAGEPRESENT', 'BUFFER_INFO_IMAGEOFFSET', (mvTLIClientGigE-lib) + 'BUFFER_INFO_DELIVERED_IMAGEHEIGHT', 'BUFFER_INFO_DELIVERED_CHUNKPAYLOADSIZE' and + 'BUFFER_INFO_CHUNKLAYOUTID' to the 'DSGetBufferInfo' function. + - Added support for mvBlueFOX-MLC202bG and mvBlueFOX-MLC202bC devices. (mvBlueFOX-lib) + + UPDATES: + - Further improved detection of lost device access. When the connection to a device is (mvBlueCOUGAR-lib) + lost while streaming or after streaming has been on and is then reconnected the + device can either continue streaming or will report an error status during connection + problems. + + BUGS FIXED: + - Calling DSFlushQueue with 'ACQ_QUEUE_ALL_TO_INPUT' could result in buffers being (mvTLIClientGigE-lib) + placed in the input buffer pool more than once, which could result in deadlocks + during cleanup. + - Calling 'DSStopAcquisition' with 'ACQ_STOP_FLAGS_KILL' and an active filter driver (mvTLIClientGigE-lib) + could result in a deadlock. + +04.11.2010 1.11.34 + NEW FEATURES: + - Image request control mode 'trial' implemented. (mvV4L-lib) + + BUGS FIXED: + - Calling 'DSGetBufferInfo' with 'BUFFER_INFO_SIZE_FILLED' returns the correct value (mvTLIClientGigE-lib) + in chunk mode now. + - Capture errors from CMOS versions of the mvBlueFOX-1xx and mvBlueFOX-M1xx when (mvBlueFOX-lib) + switching digital I/Os during image transfer. + +03.11.2010 1.11.33 + NEW FEATURES: + - Capture into a user supplied buffer is working now. (mvV4L-lib) + + BUGS FIXED: + - 'TLIMV_IFSetInterfaceParam' will be exported as all the other function under 32 (mvTLIClientGigE-lib) + Windows now. This will fix an error message being reported under 32-bit versions of + Windows when starting mvIPConfigure. + +02.11.2010 1.11.32 + NEW FEATURES: + - mvBlueFOX-MLC FPGA Version 0x1e: Supports I2C on IO connector (mvBlueFOX-lib) + - Firmware version 1.2.1.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + This firmware introduces massive changes in feature names and a lot of new features + like + - ChunkMode + - Extended Counter/Timer functionality + - New acquisition and trigger modes + However this firmware version is NOT fully backward compatible. If in doubt please + contact MATRIX VISION. Because of these changes it can also not be guaranteed that + older device driver will run in 'DeviceSpecific' interface layout when operated with + devices using a firmware version greater than 1.2.x thus updating the driver on these + systems is also highly recommended. + - Source code for mvIPConfigure added to MSI based installer (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + +28.10.2010 1.11.31 + CHANGED BEHAVIOUR: + - After a PnP arrival event the digital outputs are restored to their previous state. (mvBlueFOX-lib) + + NEW FEATURES: + - Calculation of missed frames based on frame counter in Statistics/LostImagesCount. (mvBlueFOX-lib) + Please note that e.g. when doing single snaps and the sensor runs in autotrigger mode + this will currently result in the lost image counter to increase so don't use + this parameter as a proof that frames have actually been missed. This depends on the + point of view and the application. + - Support for ibpfMono10 and ibpfMono16 added. (mvV4L-lib) + + BUGS FIXED: + - In 'DeviceSpecific' interface layout certain advanced trigger configurations could (mvBlueCOUGAR-lib) + result in inconsistent device updates. + - In 'DeviceSpecific' interface layout modifying the HW-LUT did not always update the (mvBlueCOUGAR-lib) + camera HW. + - In 'GenICam' interface layout Loading settings did not always update all features. (mvBlueCOUGAR-lib) + +25.10.2010 1.11.30 + UPDATES: + - Internal migration to IPP 6.1.6. (all shipped packages) + + NEW FEATURES: + - Support for extended chunk format added. (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + + BUGS FIXED: + - Devices that do not support chunk mode can be opened again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.28) + - Certain Linux distribution could cause crashes during clean up work. (mvPropHandling-lib) + (Bug introduced in version 1.11.16) + +19.10.2010 1.11.29 + CHANGED BEHAVIOUR: + - Packed Bayer conversion mode changed, now this mode packs the pixels and (all shipped packages) + interpolates every second one. + + BUGS FIXED: + - User AOI works with TabXGeometry 1X8 now. (mvHYPERIONfg-lib) + (mvTITANfg-lib) + - Firmware update via mvDeviceConfigure does terminate correctly again for mvBlueCOUGAR (mvBlueCOUGAR-lib) + and mvBlueLYNX-M7 devices again. + (Bug introduced in version 1.11.20) + +14.10.2010 1.11.28 + NEW FEATURES: + - 12 bit acquisition mode added to mvHYPERION-HD-SDI. (mvHYPERIONfg-lib) + - Firmware version 49 for mvBlueFOX devices added. This will add motor focus control (mvBlueFOX-lib) + related features. + + UPDATES: + - Enhanced chunk processing added. All chunk features will be part of the request info (mvBlueCOUGAR-lib) + now and will reside in a sublist 'Info/ChunkData' of each request object. + + BUGS FIXED: + - The 64-bit Linux build of the GenICam GenTL producer did use an incorrect structure (mvTLIClientGigE-lib) + alignment resulting in some registers returning an incorrect value when accessing + them via a GenApi nodemap. + - Fixed initialising of PulseStartConfiguration. Previous versions did program the (mvHYPERIONfg-lib) + rotary decoder interface but not the default behaviour(trigger input signal). + +08.10.2010 1.11.27 + NEW FEATURES: + - Additional trigger delay added. Now it is possible to set also a trigger delay in (mvHYPERIONfg-lib) + lines. The property delayAbs_usec is not affected from this new property. For working + with this new delay feature a mvHYPERION-CLm/CLf firmware upgrade to version 61 is + required. + + UPDATES: + - Improved detection of lost device access. If a device is no longer responding the (mvTLIClientGigE-lib) + 'State' property will be set to 'Absent'. When a device is responding again all (mvBlueCOUGAR-lib) + communication channels will be re-created thus the device can be used again without + the need to close and re-open it. + - Request error handling improved, now error strings will be logged instead of error (mvHYPERIONfg-lib) + codes. + - Further improved enhanced device discovery for misconfigured devices. A new detection (mvTLIClientGigE-lib) + mode has been added to mvIPConfigure. Switching it on and off enables and disables (mvIPConfigure) + the usage of limited broadcasts for the device discovery. If a device is not visible + during 'normal' device discovery switching on limited broadcasts might help. + +07.10.2010 1.11.26 + UPDATES: + - Uncompressed versions of all the GenICam XML files processed will be written to (mvBlueCOUGAR-lib) + a default directory automatically. + - Channel link reset improved if working with full CameraLink cameras. (mvHYPERION2.sys, version 2.1.21.29) + + BUGS FIXED: + - Potential memory corruption when changing from 'normal' operation to 'chunk' mode (mvBlueCOUGAR-lib) + without changing the image resolution and then capturing data into a driver allocated + buffer that previously contained 'normal' image data. + - In interface layout 'dilGeneric' and 'dilGenICam' the 'ChunkModeActive' feature is (mvBlueCOUGAR-lib) + no longer switched off automatically, when opening a device that supports the chunk + mode. + +06.10.2010 1.11.25 + NEW FEATURES: + - 'AcquisitionStart' trigger added. Now it is possible to control acquisition start (mvHYPERIONfg-lib) + independent from the 'FrameStart' trigger. + - Trigger counter read out added for 'FrameStart' and 'AcquisitionStart' trigger. (mvHYPERIONfg-lib) + (mvHYPERION2.sys, version 2.1.20.28) + + CHANGED BEHAVIOUR: + - Previous trigger overlap mode(restart trigger mode) must be defined until now with (mvHYPERIONfg-lib) + 'FrameStart' and 'FrameStop' trigger. This change is not compatible with older + versions. Now both trigger lists must hold the same trigger signal definitions to + enable this restart mode. + + UPDATES: + - Improved device discovery introduced in version 1.11.23 does no longer take more (mvTLIClientGigE-lib) + time. It's even faster than all previous versions now. (mvBlueCOUGAR-lib) + +30.09.2010 1.11.24 + NEW FEATURES: + - Rotary encoder interface added to the pulsestartconfiguration list. (mvHYPERIONfg-lib) + - Additional Bayer conversion algorithms added to support enhanced raw modes. This (all shipped packages) + special line scan acquisition modes are only available for certain line scan cameras. + + BUGS FIXED: + - The x64 version of the DirectShow interface could connect to devices when running (DirectShow_acquire.ax) + the capture application with elevated access rights only on some 64-bit versions of + Windows. + - wxPropView can be compiled with wxWidgets version smaller than 2.7.1 again. (wxPropView) + - Potential crashes at start-up when wxPropView has been compiled with wxWidgets 2.6.x (wxPropView) + on Debian. + - Small memory leak when constantly opening an closing a device. (mvBlueCOUGAR-lib) + +24.09.2010 1.11.23 + CHANGED BEHAVIOUR: + - Discovery of misconfigured GEV devices improved. Now devices e.g. using a persistent (mvTLIClientGigE-lib) + IP address connected to an adapter that resides in a different net can be discovered (mvBlueCOUGAR-lib) + as well. However this increases the device enumeration time per adapter. + - Increased 'PoolSize' registry parameter from 64 MB to 256 MB for Cognex adapter. (all shipped MSI-based packages) + This will fix certain timeout issues when running devices with high resolutions via + the mvIMPACTAcquire_Cognex_Adapter-lib. Please note that this memory is NOT + automatically consumed unless truly needed. + +17.09.2010 1.11.22 + BUGS_FIXED: + - Changes from version 1.11.6 improved. Now internal multiplexer data is only (low level mvHYPERION driver, Linux) + updated if it has changed. This load behaviour was changed in version 1.11.6. (mvHYPERION.sys, version 1.0.47.49) + +10.09.2010 1.11.21 + NEW FEATURES: + - Property mvIMPACT::acquire::Device::bayerConversionMode published. (mvIMPACT_acquire.h) + This will allow full access to the new Bayer conversion mode added in version 1.11.9. + + UPDATES: + - Amount of internal threads needed to operate a mvBlueCOUGAR-S device reduced. (mvTLIClientGigE-lib) + (mvBlueCOUGAR-lib) + BUGS FIXED: + - Device interface IP address is displayed correctly again. (mvIPConfigure) + (Bug introduced in version 1.11.20) + +03.09.2010 1.11.20 + CHANGED BEHAVIOUR: + - All GenTL MATRIX VISION specific features have been renamed to start with a (mvTLIClientGigE-lib) + leading 'mv' now. + - 'TNetworkProtocol' is no longer part of the interface as it has not been used anyway. (mvDriverBaseEnums.h) + - Power over CameraLink is now be enabled during driver start. (mvHYPERION.sys, version 1.0.46.48) + + NEW FEATURES: + - New pixel format introduced: ibpfBGR888Packed. (all shipped packages) + - New binning modes for mvBlueFOX-x05 devices added. (mvBlueFOX-lib) + - New interface layout added: 'dilGenICam'. (mvBlueCOUGAR-lib) + - Saving an interface layout using selectors is possible in 'dilGenICam' now. (mvBlueCOUGAR-lib) + - Functions 'OBJ_GetDisplayName', 'OBJ_GetSelectedFeatures' and (all shipped packages) + 'OBJ_GetSelectingFeatures'added to 'C'-interface and + 'mvIMPACT::acquire::Component::displayName', + 'mvIMPACT::acquire::Component::selectedFeatureCount', + 'mvIMPACT::acquire::Component::selectingFeatureCount', + 'mvIMPACT::acquire::Component::selectedFeatures', + 'mvIMPACT::acquire::Component::selectingFeatures', + 'mvIMPACT::acquire::Component::selectedFeature' + and 'mvIMPACT::acquire::Component::selectingFeature' added to 'C++'-interface. + wxPropView will now allow to use either the 'real' name of the component or the + display name (if defined) to display a feature in the property grid. Also + 'selector <-> selectee' relationships can be displayed now. + - Some internal changes. This version is now a fully compliant GenICam GenTL consumer (mvBlueCOUGAR-lib) + according the GenICam GenTL spec. version 1.2. + - Firmware version 1.1.43.1 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + + BUGS FIXED: + - Selecting 'Assign temp. IP' from the context menu of the device list is working (mvIPConfigure) + again. + (Bug introduced in version 1.11.17) + - In rare cases certain nodes in a devices XML file could result in (mvBlueCOUGAR-lib) + features not being updated correctly or even in enum features being assigned a + different value for no reason when the TLParamsLocked node was accessed during start + and stop of streaming. + - If set request timeout to 0 ms and working with a frametrigger then sometimes the (mvHYPERIONfg-lib) + driver could not be closed. (mvHYPERION2.sys, version 2.1.19.27) + +29.07.2010 1.11.19 + NEW FEATURES: + - Buffer nodemap and port access related functions for buffer module implemented. (mvTLIClientGigE-lib) + - Firmware version 1.1.40.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + This adds support for mvBlueCOUGAR-X124 devices, fixes various minor bugs + regarding network related topics and allows the use of mvBlueCOUGAR-X devices under + National Instruments LabVIEW with the Vision Acquisition Software (VAS). + + BUGS FIXED: + - Calling DSFlushQueue did not always clear all internal buffer flags e.g. leaving some (mvTLIClientGigE-lib) + buffers marked as 'queued' afterwards. + - x64 and ppc_6xx Linux builds are working again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.17) + - mvBlueCOUGAR-X devices with an old firmware not supporting HW-LUT features are (mvBlueCOUGAR-lib) + running at full speed in 'DeviceSpecific' interface mode again. + (Bug introduced in version 1.11.13) + - 'Flat field filter' is working correctly again on multi-core systems. (all shipped packages) + (Bug introduced in version 1.11.6 with the introduction of OpenMP) + +27.07.2010 1.11.18 + DEPRECATED API CODE: + - mvIMPACT::acquire::ImageProcessing::mirrorMode has been declared deprecated and will (mvIMPACT_acquire.h) + be removed in future versions. See 'C++ developers -> Porting existing code' in the + device manual for replacements. + + UPDATES: + - Timing improved for mvBlueFOX-2x devices. (FPGA version) + + NEW FEATURES: + - Driver information can be listed via F12 now. (wxPropView) + - RAW image files containing one of the supported mvIMPACT Acquire pixel formats can (wxPropView) + be imported now. + - The mirror filter can be applied to individual channels of the image now. Each (all shipped packages) + channel can have a different mirror setting. See class + mvIMPACT::acquire::ImageProcessing for details. + - Improved new logging mechanism. (all shipped packages) + - 'ChannelSplit' filter added to image processing chain. This filter can be used to (all shipped packages) + convert multi-channel images into a mono format of the corresponding bit depth + with all channels of the image re-arranged as planes. The interface of this filter + is under development still and might change in future releases. + - mvBlueCOUGAR-X firmware is part of the Linux driver package as well now. (all shipped Linux builds of the mvBlueCOUGAR driver package) + - Decoder reset added for mvHYPERION-SDI during device open. (mvHYPERION2.sys, version 2.1.18.26) + - Remaining SFNC features added to Device, Interface and System nodemaps. + - Support for 'ACQ_STOP_FLAGS_KILL' in DSStopAcquisition added. + + BUGS FIXED: + - In planar or packed YUV test mode images with a height that was not a multiple of 4 (mvVirtualDevice-lib) + could result in the creation of incorrect test data. + - Synchronisation of medium channels improved. (low level mvHYPERION driver, Linux) + - MDL_PAGES_LOCKED check added before calling MdlUnlockPages. (mvHYPERION2.sys, version 2.1.18.26) + - OnCancelReadWrite improved. (mvHYPERION2.sys, version 2.1.18.26) + - Power over CameraLink will be switched on/off correctly for different system power (mvHYPERION2.sys, version 2.1.18.26) + states. + +14.07.2010 1.11.17 + CHANGED BEHAVIOUR: + - The stream channel selector is only available when the device offers at least one (mvTLIClientGigE-lib) + stream now. + - Some return values changed from 'GC_ERR_ERROR' to 'GC_ERR_IO' where appropriate. (mvTLIClientGigE-lib) + - 'PORT_INFO_MODEL' returns a unique name per module now. (mvTLIClientGigE-lib) + - Checking for sufficient disc space will be done AFTER selecting the components to be (all shipped MSI based packages) + installed. + - 'LastResult' property of the code generation section became read-only. (mvBlueCOUGAR-lib) + + NEW FEATURES: + - mvDELTA, mvSIGMA, mvTITAN and mvGAMMA devices will return an increasing frame number (mvSIGMAfg-lib) + now. (mvTITANfg-lib) + - Support for error events added. (mvTLIClientGigE-lib) + - mvBlueFOX devices will work on a NEC-USB 3.0 xHCI controller now. (mvBlueFOX-lib) + - Firmware version 1.1.30.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + This version includes various minor bug fixes, adds new trigger sources and an + initial version of a programmable AND/OR matrix as well as a possibility to reset + the internal timestamp via a digital input which will allow to sync. several cameras + with an external signal. + - New file format for log output added. Files with the *.mvlog extension can be viewed (all shipped packages) + using mvLogFileViewer.html(There is a shortcut in the programs menu on Windows) + now. + + UPDATES: + - Chapters about installation and logging in manuals. (all shipped packages) + + BUGS FIXED: + - Under XP and Windows 2000 drivers could only be installed while the system time (mvBlueFOX.msi) + during installation was within the time span KMCS certificate used to sign the kernel (mvBlueFOX-x64.msi) + drivers was valid. (mvHYPERION.msi) + (mvHYPERION-x64.msi) + (mvTITAN_mvGAMMA.msi) + (mvDELTA_mvSIGMA.msi) + - The grid property currently selected did not become invisible in the tree control (wxPropView) + even if it visibility did change (e.g. because of a change in the user experience + control box). + - Multiple load/unload operations on the module with some interface function calls in (mvTLIClientGigE-lib) + between could result in crashes. + - When a device with no streaming channels was detected during a call to (mvTLIClientGigE-lib) + 'IFUpdateDeviceList' an internal exception was raised and the enumeration of the + devices did stop thus not every device was detected. + - The module names of the 'Device' Module and the remote device have been interchanged. (mvTLIClientGigE-lib) + - The schema version tag of the remote device URL contains a sub minor number now as + required by the GenTL spec 1.2. + - 'DEVICE_INFO_ACCESS_STATUS' always returns the correct value now. (mvTLIClientGigE-lib) + - 'DSFlushQueue' with 'ACQ_QUEUE_ALL_DISCARD' behaves as defined in the GenTL spec. (mvTLIClientGigE-lib) + now. + - 'DSGetInfo' with STREAM_INFO_NUM_DELIVERED, STREAM_INFO_NUM_UNDERRUN, (mvTLIClientGigE-lib) + STREAM_INFO_NUM_STARTED, STREAM_INFO_NUM_ANNOUNCED, STREAM_INFO_NUM_QUEUED, + STREAM_INFO_NUM_AWAIT_DELIVERY or STREAM_INFO_PAYLOAD_SIZE did return incorrect data + type information. + - The visibility of Bayer conversion related properties will be updated depending on (all shipped packages) + current image format again. + (Bug introduced in version 1.11.6) + - various samples as well as wxPropView can be compiled using gcc 4.0 or greater again (all shipped packages) + (Bug introduced in version 1.11.6) + - Potential crash when closing the log-configuration dialog for a certain logger. (mvDeviceConfigure) + - The result of the firmware update is displayed correctly again when updating the (mvDeviceConfigure) + firmware of an mvBlueCOUGAR device. + (Bug introduced in version 1.11.12) + +05.07.2010 1.11.16 + DEPRECATED API CODE: + - mvIMPACT::acquire::OutputSignalGeneratorBlueDevice::canInvertExposeActiveSignal, (mvIMPACT_acquire.h) + mvIMPACT::acquire::OutputSignalGeneratorBlueDevice::isExposeActive, + mvIMPACT::acquire::OutputSignalGeneratorBlueDevice::isExposeActiveSignalInverted + and mvIMPACT::acquire::OutputSignalGeneratorBlueDevice::makeExposeActive + have been declared deprecated and will be removed in future versions. See + 'C++ developers -> Porting existing code' in the device manual for replacements. + + CHANGED BEHAVIOUR: + - Some status information properties moved from statistics list to info list. (mvHYPERIONfg-lib) + + NEW FEATURES: + - Firmware version 47 for mvBlueFOX devices added. This will add improved detection (mvBlueFOX-lib) + for mvBlueFOX-MLC devices with an empty EEPROM. + - mvHYPERION2 kernel module control parameter added to handle special load behaviour. (low level mvHYPERION2 driver, Linux) + Current module version supports handling of PoCL with this control parameter. + - mvIMPACT::acquire::TriggerControl::triggerDelayAbs_us support for mvBlueCOUGAR (mvIMPACT_acquire.h) + devices added. + - SDI camera description added for mvHYPERION-SDI boards. This camera description also (mvHYPERIONfg-lib) + supports enhanced YUV422_10Packed destination formats. + - Additional status info properties added for mvHYPERION-SDI boards. (mvHYPERIONfg-lib) + - 'Force Refresh' option added to the context menu of the property grid. If a property (wxPropView) + internally defines some method to update its value(e.g. a counter value) calling + this function will assign the current value to the property. + - Intensity plot added. (wxPropView) + + UPDATES: + - Linux version of mvBlueFOX driver makes use of libusb 1.0.8 now. (mvBlueFOX-lib) + - USB transfer compliant with Linux kernel versions 2.6.33 and higher now. (mvBlueFOX-lib) + - Updated mvSDK driver package. Changes in mvsigma.sys. IRP_MJ_CLEANUP dispatch (mvSIGMA, version 4.1.13.50) + function added. + - Migration to version 1.2 of the GenICam GenTL spec. (mvTLIClientGigE-lib) + + BUGS FIXED: + - AEC/AGC with active AutoControlMode 'Standard' is working again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.13) + - Translation lookaside buffer(P55 compatible) bugfix added, mvHYPERION-CLm did (low level mvHYPERION2 driver, Linux) + generate 32-bit address headers if detecting a 32-bit physical DMA address + (highpart = 0). + - When the property selected in the grid became read-only (e.g. because the live mode (wxPropView) + was started and this property can only be modified when the device doesn't stream + data) the editor did disappear and could only be reactivated if selecting a different + property and then the current one again. + - Timeout handling corrected. Next request after a timeout condition was also reported (mvHYPERIONfg-lib) + with timeout error(mvHYPERION-CLm/CLf only). + - Average pixel value in Histogram plots in raw Bayer modes was 4 times too small. (wxPropView) + +15.06.2010 1.11.15 + NEW FEATURES: + - Firmware version 46 for mvBlueFOX devices added. This will add enhanced support (mvBlueFOX-lib) + for mvBlueFOX-MLC devices. + + BUGS FIXED: + - Translation lookaside buffer(P55 compatible) bugfix added, mvHYPERION-CLm did (mvHYPERION2.sys, version 2.1.17.25) + generate 32-bit address headers if detecting a 32-bit physical DMA address + (highpart = 0). + +11.06.2010 1.11.14 + NEW FEATURES: + - Firmware version 1.1.19.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + Bugs fixed: + - Sometimes the mvBlueCOUGAR-X failed to boot. + (Bug introduced in firmware version 1.1.18.0) + +10.06.2010 1.11.13 + CHANGED BEHAVIOUR: + - Property mvIMPACT::acquire::Device::autoLoadSettingsOrder renamed to (mvIMPACT_acquire.h) + mvIMPACT::acquire::Device::autoLoadSettingOrder. This might force you to change your + code upon rebuilds but will not affect existing binaries. + + NEW FEATURES: + - Property 'ControllerDelay_Images' is available for the device specific AGC/AEC (mvBlueCOUGAR-lib) + interface for mvBlueCOUGAR-Xx00w devices now. This requires at least firmware + version 1.1.15.0. + - 'Inverter' property is available for digital outputs in the device specific interface (mvBlueCOUGAR-lib) + for mvBlueCOUGAR-X devices now. + - 10 -> 10 bit HW LUT for colour and 12 -> 10 bit HW LUT for mono versions of the (mvBlueCOUGAR-lib) + mvBlueCOUGAR-X added. This will require firmware version than 1.1.18.0. or higher. + - mvBlueCOUGAR-Xx00w devices will allow a negative value for the lower gain limit in (mvBlueCOUGAR-lib) + active AGC mode. + - Firmware version 1.1.18.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + This version includes various minor bug fixes and adds support for HW-LUTs. + Bugs fixed: + - Trigger overlapped with small exposure time. + - mvBlueCOUGAR-X122: Darker images with lower trigger frequency. + - FFC did not work before first AcquisitionStart. + Features added: + - HW-LUT: 10To10 for colour models, 12To10 for mono models. + - mvBlueCOUGAR-Xx00w Test image. + - Temperature limit hysteresis added. + + BUGS FIXED: + - Potential crash when calling the 'UpdateDeviceList' function when the driver could (mvBlueCOUGAR-lib) + not find a valid producer. + - When working with hardware LUTs in interpolated mode the final value of the (all shipped packages) + calculated LUT was not always correct. + - When calling the 'restoreDefault' method for the 'DirectValues' property of a LUT (all shipped packages) + the default value count was defaulted to 256 even when working with larger LUTs. + - When calling 'OBJ_GetFDictEntries', 'OBJ_GetIDictEntries' or 'OBJ_GetI64DictEntries' (mvDeviceManager-lib) + with 'pTranslationString' set to 0 'PROPHANDLING_INPUT_BUFFER_TOO_SMALL' was returned + if 'translationStringBufSize' was smaller than the internal buffers length. + +31.05.2010 1.11.12 + NEW FEATURES: + - Firmware version 1.1.15.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + This version includes various minor bug fixes and adds support for HDR and device + specific AGC/AEC for mvBlueCOUGAR-Xx00w devices. Furthermore it introduces support + for counters and timer, single and multi frame acquisition, overlapped trigger for + CCD types, LineInverter and an initial version of FFC(Flat field correction). + - Improved error reporting when a load/save setting operation did fail on Windows (wxPropView) + NT 6.0 and higher(Vista, 7, ...) because of missing user rights. + - 'ExposureAndAcquisitionActive' mode added to DigitalOutput modes for mvBlueCOUGAR-X (mvBlueCOUGAR-lib) + devices (This requires a firmware update.). + + BUGS FIXED: + - Some small full screen mode related issues fixed: Blinking cursors from the active (wxPropView) + editor in the property grid is no longer visible in full screen mode, once returned (mvDisplay-lib) + from full screen mode the application does no longer stay on top of all other + windows and potential crashes when closing wxPropView while a resource consuming + acquisition was running. + - Potential thread leak when constantly opening and closing a device. (all shipped packages) + (Bug introduced in version 1.11.6 with the introduction of OpenMP) + - Lots of missing calls to 'CloseHandle' added to sample applications. (all shipped MSI based packages) + (Windows only) + - ImageDestination -> PixelFormat = ibpfRGB888Packed did result in the 'R' and 'B' (mvHYPERIONfg-lib) + being flipped when capturing from an RGB video source. + - Memory read access handling improved. Sometimes if working with large image buffers (mvHyperion.sys, version 1.0.45.47) + read access to transfer properties was not possible. (mvHyperion2.sys, version 2.1.16.24) + +26.05.2010 1.11.11 + CHANGED BEHAVIOUR: + - mvBlueFOX-x00w devices will now off a min. exposure time of 6 us with a step width of (mvBlueFOX-lib) + 1 us. + + NEW FEATURES: + - The image correction filters (dark current and flat field) can now handle camera AOI (all shipped packages) + settings. The camera AOI must fit into the correction data AOI or can have the same + size. + - New sample added: 'SingleCaptureMasterSlave'. (all shipped MSI based packages) + - Property 'BayerMosaicParity' added and published in user interface. (mvVirtualDevice-lib) + - Device specific AGC/AEC modes and HDR control features for mvBlueCOUGAR-Xx00w devices (mvBlueCOUGAR-lib) + added. + (Firmware 1.1.9.1 or higher required) + + BUGS FIXED: + - Internal exception when setting up internal callbacks for SDI versions of the (mvHYPERIONfg-lib) + mvHYPERION. + (Bug introduced in version 1.11.6) + - Sometimes mvBlueFOX-x00w devices had a logarithmical response to light after (mvBlueFOX-lib) + initialisation. + +11.05.2010 1.11.10 + NEW FEATURES: + - New functions added to get/set int and float properties in an atomic way. (mvDeviceManager-lib) + C-interface: OBJ_Get/SetIArray, OBJ_Get/SetI64Array, OBJ_Get/SetFArray. (mvDeviceManager.h) + C++-interface: EnumPropertyI::read/write overload, EnumPropertyI64::read/write (mvIMPACT_acquire.h) + overload, EnumPropertyF::read/write overload, + IOSubSystemBlueFOX::readOutputRegisterAtomic, + IOSubSystemBlueFOX::readInputRegisterAtomic, + IOSubSystemBlueFOX::writeOutputRegisterAtomic. + + BUGS FIXED: + - An issue with a code signing certificate resulted in drivers not being installable (all shipped MSI-based packages containing kernel modules) + on Windows XP and Windows XP64 any more. + +07.05.2010 1.11.9 + CHANGED BEHAVIOUR: + - Function mvIMPACT::acquire::HDRControl::getKneePointCount removed from interface. (mvIMPACT_acquire.h) + Use mvIMPACT::acquire::HDRControl::kneePointCount instead. + + NEW FEATURES: + - Handling for buffers with an odd width for ibpfMono12Packed_V2 improved. (all shipped packages) + - Adaptive edge sensing de-Bayer algorithm is fully integrated but not yet published (all shipped packages) + in the user interface. + + BUGS FIXED: + - When a version of wxPropView that makes use of the user defined access level was (wxPropView) + deployed on a system that did not offer support for this feature, wxPropView did + crash. + (Bug introduced in version 1.11.7) + - AOIs in 'Fit to screen' mode and various other special scenarios(zoomed when the (wxPropView) + width and height did differ significantly, ...) on Windows finally behave as + desired. + - Some small full screen mode related issues fixed: With an active analysis plot and/or (wxPropView) + monitor display the full screen image was overwritten by these controls. + - Missing documentation about the new way of installing and running applications build (all shipped packages) + with mvIMPACT Acquire added. + (Bug introduced in version 1.11.7) + - On some Linux distributions certain(long) log messages could result in crashes. (all shipped packages) + - Certain exposure times in connection with certain line delay settings could still (mvBlueFOX-lib) + result in black frames for mvBlueFOX-x05 devices. + +29.04.2010 1.11.8 + CHANGED BEHAVIOUR: + - Pending ACK as well as the transmission of extended status by a device will be (mvTLIClientGigE-lib) + enabled automatically when a device supporting these features is opened. + + NEW FEATURES: + - The 32-bit mvBlueCOUGAR, mvBlueFOX, mvHYPERION and mvVirtualDevice user mode drivers (mvGigECapture.sys, version 1.1.6.29) + can access and run with a 64-bit kernel mode driver. Thus 32-bit (mvTLIClientGigE-lib) + applications can be installed on a 64-bit Windows system. See remarks in the chapter (mvHYPERIONfg-lib) + 'Building and Linking'. (mvHYPERION.sys, version 1.0.44.46) + (Windows only) (mvHYPERION2.sys, version 2.1.15.23) + - GainOffsetKnee filter also supports pixel formats ibpfRGBx888Planar, (all shipped packages) + ibpfYUV422Packed, ibpfYUV422_10Packed, ibpfYUV422_UYVYPacked, + ibpfYUV422_UYVY_10Packed and ibpfYUV422Planar now. + - Debug messages can be controlled via a registry entry 'debuglevel' now. (mvHYPERION.sys, version 1.0.44.46) + - New pixel formats introduced: ibpfYUV422_10Packed, ibpfYUV422_UYVY_10Packed. (all shipped packages) + - Experimental version of adaptive edge sensing de-Bayer algorithm added. Selectable (all shipped packages) + via the property 'ImageProcessing -> BayerConversionMode'. + + BUGS FIXED: + - Device power handling improved. (mvHYPERION.sys, version 1.0.44.46) + - YUV Histogram was only correct for AOI x-offsets divisible by 2. (wxPropView) + +14.04.2010 1.11.7 + CHANGED BEHAVIOUR: + - TScalerInterpolationMode::simLanczos removed from interface (added in 1.11.6) as this (all shipped packages) + interpolation mode was not available for all pixel formats. + - Final version of HDR control features added for mvBlueFOX-x00w devices. (mvBlueFOX-lib) + - Trigger overlap feature stop moment changed if working with trigger_linedelays. (mvHYPERIONfg-lib) + + NEW FEATURES: + - Functions 'OBJ_GetVisibility', 'OBJ_GetVisibilityS' and 'OBJ_VisibilityToString' (all shipped packages) + added to 'C'-interface and 'mvIMPACT::acquire::Component::visibility' and + 'mvIMPACT::acquire::Component::visibilityAsString' added to 'C++'-interface. + wxPropView will now use this information to allow a user defined access level to + properties. + - 10to8 HW-LUT is switched on automatically if 'BitsPerPixel=10' and (mvTITANfg-lib) + 'Camera->PixelFormat=Mono8'. + - The property 'HardwareInit' and the feature list 'OnBoardMemory' have been moved (mvTITANfg-lib) + from 'DeviceSpecificData' to the device list that is available also before opening + a device. The old location of the feature will continue to work, but should not be + used any more. If the newer version of the features have been modified, these will be + used, if not the old version will be used. + - New sample added: 'ContinuousCaptureDirectX'. (all shipped MSI based packages) + - Firmware version 1.00.33 for mvBlueCOUGAR-S Rev. 0 and version 1.02.04 for (all shipped packages for GigE Vision devices) + mvBlueCOUGAR-S Rev. 1 devices added. This fixes the following issues: + - First image after changing the exposure time or the gain was taken with the old + sensor timing + - When connected to certain 3COM PoE Hubs/Switches the cameras didn't work correctly + - AOI/Frame rate related behaviour has been improved. + - Some minor GEV protocol specific issues. + - 2 full screen modes added(one is accessible via the context menu of a certain image (wxPropView) + display, the other one via F11) + + BUGS FIXED: + - In very rare cases calls to 'mvIMPACT::acquire::Property::readS' and (mvIMPACT_acquire.h) + 'mvIMPACT::acquire::Property::readSArray' could raise + 'mvIMPACT::acquire::EInputBufferTooSmall' exceptions when being called at an + 'unfavourable' moment. A second call could end up just fine. + (Bug introduced in version 1.10.65) + - Serial port enable corrected for mvHYPERION-HD-SDI (low level mvHYPERION driver, Linux) + (low level mvHYPERION2 driver, Linux) + - Changing the video mode did not always correctly setup the MSBDataPos parameter. (mvTITAN-lib, version 1.5.28.4) + - Reading property values that specify the 'cfAllowValueCombinations' as strings (mvPropHandling-lib) + did return an empty string if the integer representation of the properties current + value was 0 and an additional trailing whitespace in the resulting value if the + integer representation was different from 0. + - The C++ interface is compatible with Visual Studio 6.0 again (mvIMPACT_acquire.h) + (Bug introduced in version 1.11.6) + - ibpfMono12Packed_V2 buffers can be converted into a mvIMPACT image buffer correctly (mvDeviceManager-lib) + now. + - 'Dark current filter' is working again. (all shipped packages) + (Bug introduced in version 1.11.6) + - mvBlueCOUGAR-X devices can be initialised in 'DeviceSpecific' interface mode again (mvBlueCOUGAR-lib) + (Bug introduced in version 1.11.6) + - Input data multiplexer onboard-RAM access improved. (mvHYPERION.sys, version 1.0.43.45) + - mvHYPERION-CLb/CLe boards work under 64bit versions of Windows again. (mvHYPERION.sys, version 1.0.43.45) + - Triggered acquisition corrected if working with more than one input channel parallel. (mvHYPERIONfg-lib) + - In Bayer test mode images with a height that was not a multiple of 8 could result in (mvVirtualDevice-lib) + the creation of incorrect test data. + +30.03.2010 1.11.6 + CHANGED BEHAVIOUR: + - When a camera description did specify a Y-Tap geometry of 'cltyg1Y2' or 'cltyg2YE' (mvTITANfg-lib) + and the tap sort filter was switched off the resulting image was twice as wide and (mvHYPERIONfg-lib) + did contain half the amount of lines as specified in the camera description. Now + an image with the AOI as defined in the camera description will be returned then. + - Gain step width of Gain-Offset-Knee filter changed from 0.005 to 0.0625. (all shipped packages) + + NEW FEATURES: + - Properties 'TapsXGeometry' and 'TapsYGeometry' added in order to allow testing of (mvVirtualDevice-lib) + the tap sort filter. + - 'cltxg4X2' added to 'TCameraTapsXGeometry'. (mvTITANfg-lib) + (mvHYPERIONfg-lib) + (mvVirtualDevice-lib) + - Property 'ScalerInterpolationMode' published. (mvIMPACT_acquire.h) + - Function CameraSettingsFrameGrabber::triggerControl( const std::string& name ) and (mvIMPACT_acquire.h) + CameraSettingsBlueCOUGAR::triggerControl( const std::string& name ) added. + - Permanent DMA Buffer handling added. Now it is possible to define a device specific (mvHYPERIONfg-lib) + permanent DMA buffer. This buffer is allocated during the driver start. (mvHYPERION.sys, version 1.0.42.44) + (mvHYPERION2.sys, version 2.1.14.22) + UPDATES: + - Lots of internal processing filters make use of Open MP now. This will improve the (all shipped packages) + the execution speed of various conversions or processing steps when the systems the + driver is running on has more than 1 core. However when embedding the driver into a + custom installation package this now requires to ship the correct version of the + Open MP runtime as well. To find out about the correct version please refer to the + chapter 'Installing from private setup routines' of the devices manual. + - Firmware version 1.0.96.0 for mvBlueCOUGAR-X devices added. (all shipped packages for GigE Vision devices) + - Internal image processing code updated. (all shipped packages) + - Internal migration to IPP 6.1.4. (all shipped packages) + + BUGS FIXED: + - Changing the current device selection from a used to an unused one did not change (wxPropView) + the state of the 'Use' button state. + (Bug introduced in version 1.11.5) + - mvBlueFOX-MLC200w will display the correct number of digital I/Os now. (mvBlueFOX-lib) + - Digital input read out improved for mvHYPERION-CLb boards. (mvHYPERIONfg-lib) + - Start behaviour improved. Under certain conditions (first request with trial mode) (mvHYPERIONfg-lib) + some boards did not start the acquisition correctly afterwards. + - Transfer pixel format property was invisible for mvHYPERION, mvTITAN-CL, mvGAMMA-CL (mvHYPERIONfg-lib) + and mvTITAN-DIG boards. (mvTITANfg-lib) + +16.03.2010 1.11.5 + NEW FEATURES: + - Support for mvBlueFOX-MLC200w devices added. (mvBlueFOX-lib) + + UPDATES: + - Firmware version 1.02.03 for mvBlueCOUGAR-S Rev. 1 devices added. This fixes the (all shipped packages for GigE Vision devices) + following issues: + - First image after changing the exposure time or the gain was taken with the old + sensor timing + - When connected to certain 3COM PoE Hubs/Switches the cameras didn't work correctly + - AOI/Frame rate related behaviour has been improved. + - Firmware version 1.0.93.0 for mvBlueCOUGAR-X devices added. This will fix an issue (all shipped packages for GigE Vision devices) + where the device could not be accessed if the devices boot sequence was complete + before the surrounding network was up. + + BUGS FIXED: + - Device specific AEC and AGC is working correctly again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.10.93) + - Image AOI offsetX and offsetY will now be set correctly (DirectShow_acquire.ax) + +09.03.2010 1.11.4 + CHANGED BEHAVIOUR: + - The step width for AOI/W, AOI/H, AOI/X and AOI/Y for mvBlueFOX-x00w devices is 2 (mvBlueFOX-lib) + now(used to be 16 in X and 8 in Y direction). + + BUGS FIXED: + - Trigger acquisition mode 'TriggerOverlap' improved. (mvHYPERIONfg-lib) + - Abort function improved (only CLf/CLm). In rare cases a running acquisition did not (mvHYPERIONfg-lib) + start again after calling 'imageRequestReset'. Sometimes 'imageRequestReset' calls + could result in a system deadlock. + - The first image taken after changing the exposure time or gain was acquired using the (mvBlueFOX-lib) + previous values. + +08.03.2010 1.11.3 + BUGS FIXED: + - Potential blue screen (BSOD) when the internal timeout check function was called in (mvGigECapture.sys, version 1.1.5.28) + parallel with StartIo. + - Potential deadlock when the system was running extremely low on resources. (mvTLIClientGigE-lib) + (Windows only) + +01.03.2010 1.11.2 + BUGS FIXED: + - Calling 'imageRequestReset' and 'imageRequestSingle' in parallel could result in (mvBlueCOUGAR-lib) + deadlocks in rare cases. + (Bug introduced in version 1.10.90) + - Selecting an explicit mono destination format did result in an incomplete sensor (mvBlueCOUGAR-lib) + update for mvBlueCOUGAR-X devices. + - When a device driver did not support the 'SettingUsed' property an active info plot (wxPropView) + could result in crashes. + (Bug introduced in version 1.11.1) + +26.02.2010 1.11.1 + CHANGED BEHAVIOUR: + - Default value type when creating features from XML(thus NOT updating an existing (mvPropHandling-lib) + list) for a property is string now while it used to be int. + - When opened in 'DeviceSpecific' interface layout with 'Read' access, the acquisition (mvBlueCOUGAR-lib) + related features will be read-only now. + + NEW FEATURES: + - New property 'SettingUsed' added to info list of a request. This will contain the (all shipped packages) + handle and name(via readS) of the setting that was used for processing this request. + - mvTITAN-CL boards will support 1x24 RGB and 1x30 RGB configurations now, mvGAMMA-CL (mvTITANfg-lib) + will support 1x24 RGB configurations now. + + BUGS FIXED: + - mvTITAN-CL and mvGAMMA-CL boards will support the 3x8 mono mode as defined in the (mvTITANfg-lib) + CameraLink spec. now. + - Incorrect timestamps have been returned from time to time. (mvHYPERIONfg-lib) + - Inconsistent(in terms of PixelsPerCycle and the tap configuration) but working (mvHYPERIONfg-lib) + CameraLink camera descriptions will result in a correct hardware setup again. (mvTITANfg-lib) + (Bug introduced in version 1.11.0) + - Parallel initialisation of multiple devices should always work now(XALAN doesn't (mvBlueCOUGAR-lib) + seem to be thread safe) + - CancelIO and abort function improved. Under some circumstances the requests sent (mvHYPERION2.sys, version 2.1.13.21) + to mvHYPERION kernel mode driver could not be cancelled. + +11.02.2010 1.11.0 + CHANGED BEHAVIOUR + - Functions and classes that have been declared deprecated for some time now have (mvIMPACT_acquire.h) + been removed from the C/C++ interface. This will not break existing binaries, but (mvDeviceManager.h) + will force you to change your code during rebuilds when deprecated code was used by (mvDriverBaseEnums.h) + your application. A list of functions that have been removed and their replacement + can be found in the device drivers manual under + 'C/C++ developer -> Porting existing code'. + - Max. AOI increased to 8192 x 8192. (mvVirtualDevice-lib) + - CameraLink camera descriptions will only allow consistent property sets now(e.g. when (mvHYPERIONfg-lib) + setting 'PixelsPerCycle' to 1, only tap geometries that are valid in that context (mvTITANfg-lib) + can be selected). In rare cases this might break existing code! + + UPDATES: + - Migration to version 2.0.1 of the GenApi runtime. (mvBlueCOUGAR installer) + + NEW FEATURES: + - New pixel format introduced: ibpfMono12Packed_V2. (all shipped packages) + - New property 'PixelFormat' added to 'Camera' parameter list of the device. This (all shipped packages) + property can be used to explicitly define the pixel format used for the transfer + between the capture device and the host systems memory. This can differ from the + pixel format delivered to the user application if needed. + - Overlapped expose mode is available in device specific interface for mvBlueCOUGAR-X (mvBlueCOUGAR-lib) + devices now. + - The data from the analysis grids can be copied into the clipboard by clicking on one (wxPropView) + of the data cells(right mouse button). + - The grid value format string of the analysis grids can be configured in a printf (wxPropView) + like way(right mouse button). + - GenICam GenTL producer does support multicast now. (mvTLIClientGigE-lib) + - New test image formats added: 'vdtmHorizontalMonoRamp', 'vdtmVerticalMonoRamp', (mvVirtualDevice-lib) + 'vdtmMovingVerticalMonoRamp', 'vdtmHorizontalMono12Packed_V2Ramp'. + - New GenICam description file for mvBlueCOUGAR-S devices added(version 2.3.1). This (mvBlueCOUGAR installer) + will fix an issue when switching on/off vertical binning and reading back the + current height and/or y-offset afterwards. + - mvV4L2 package (V4L2 to mvIMPACT Acquire interface) integrated. + - If supported by the device it is possible to establish a single 'control' and one or (mvBlueCOUGAR-lib) + more 'read-only' connections to a GigE Vision device from one or multiple systems. (mvDeviceManager-lib) + - Property 'TapSortEnable' published. (mvIMPACT_acquire.h) + - A default interface layout that will be used for all devices supporting it can be (wxPropView) + selected and is stored when closing the application now. + - Very simple hard disc recording mechanism added. (wxPropView) + - A driver will offer more than one result queue now. The number of result queues can (all shipped packages) + be defined by writing to the 'ResultQueueCount' property before opening a device. + - HDR control features added for mvBlueFOX-x00w devices. (mvBlueFOX-lib) + - trigger acquisition modes added to mvHYPERION-CLf/CLm. Now the trigger modes are (mvHYPERIONfg-lib) + fully compatible with mvHYPERION-CLe. + - trigger delay property lines added. This property is only available for line scan (mvHYPERIONfg-lib) + applications. + + BUGS FIXED: + - 'Offset_pc' feature was always set to the maximum value internally no matter what was (mvBlueCOUGAR-lib) + selected in the properties value. + - Potential crash when feeding an image with an unsupported pixel format into the (all shipped packages) + calibration routine of the 'Flat field filter' or 'Dark current filter'. + - Storing raw Bayer images in *.raw format is working again. (wxPropView) + (Bug introduced in version 1.10.85) + - Exception handling added to buffer allocation. Now the exception will be caught (all shipped packages) + correctly if buffer allocation failed. + - AGC/AEC when working with ibpfMono16 did not work correctly. (mvBlueFOX-lib) + (mvBlueCOUGAR-lib) + +11.01.2010 1.10.99 + CHANGED BEHAVIOUR: + - Lower limit for property 'Offset_pc' for mvBlueCOUGAR-P, mvBlueCOUGAR-X devices and (mvBlueCOUGAR-lib) + mvBlueLYNX-M7 devices set to 0%(was -100%). + + UPDATES: + - Some properties like AOI related things that will be overwritten by the Cognex (mvIMPACTAcquire_Cognex_Adapter-lib, version 1.1.1.3) + runtime anyway are no longer displayed in the property list of e.g. QuickBuild. + - Devices that don't support rising edge or falling edge trigger modes will use (mvIMPACTAcquire_Cognex_Adapter-lib, version 1.1.1.3) + high level or low level trigger modes if possible now. + - nios application updated because of newer firmware for mvHYPERION-CLm/CLf boards (mvHYPERIONfg-lib) + (firmwareversion > 52). + + NEW FEATURES: + - It's possible to establish 'read-only' access to a GigE Vision device now. (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + - 'Offset_pc' property in device specific interface published for mvBlueCOUGAR-X (mvBlueCOUGAR-lib) + devices + - 40 MHz pixel clock can be selected for mvBlueFOX-x00w devices now. (mvBlueFOX-lib) + - New camera-format YUV for SDI-cameras added. This format in the camera descriptions + has been added temporarily and will be replaced with an newer camera handler later. (mvHYPERIONfg-lib) + - New GenICam description file for mvBlueCOUGAR-S devices added(version 2.3.1) (mvBlueCOUGAR installer) + + BUGS FIXED: + - Single shot mode for mvBlueFOX-202 devices. (mvBlueFOX-lib) + - Several small bugs fixed in the 64-bit version of the Windows kernel drivers. (mvHYPERION2.sys, version 2.1.11.19) + (mvHYPERION-clm/clf). (mvSerialPort.sys, version 1.0.5.5) + +15.12.2009 1.10.98 + UPDATES: + - Improved image quality for mvBlueFOX-x00w at 32 MHz pixel clock. (mvBlueFOX-lib) + + BUGS FIXED: + - Watermark generator: Vertical line in cross-hairs mode for RGBx888Packed format is (all shipped packages) + created correctly now. + +11.12.2009 1.10.97 + UPDATES: + - Some enhanced error checking (short packets, etc.) and statistical information added. (mvGigECapture.sys, version 1.1.4.27) + + NEW FEATURES: + - Enhanced gamma correction related features added to LUTOperations. (all shipped packages) + - 'GainOffsetKnee' filter added to image processing chain. (all shipped packages) + - GenICam features that define a polling time will be updated automatically in the (mvBlueCOUGAR-lib) + generic interface layout now. + - Early version of 'WatermarkGenerator' added. So far the features have not been added (all shipped packages) + to the C++ wrapper. + - Property 'mvIMPACT::acquire::Device::deviceVersion' added. (all shipped packages) + - Firmware update for mvBlueCOUGAR-X devices is possible now. (mvDeviceConfigure) + (mvBlueCOUGAR-lib) + + BUGS FIXED: + - The GenApi 2.0 runtime installer will write to the 'Path' variable on Windows Vista (mvBlueCOUGAR.msi) + and Windows 7 again. (mvBlueCOUGAR-x64.msi) + (Bug introduced in version 1.10.95) + - Test images in ibpfRGB101010Packed - ibpfRGB141414Packed did use an incorrect white (mvVirtualDevice-lib) + value(0xFFFF instead of 0x3FF, 0xFFF and 0x3FFF). + +01.12.2009 1.10.96 + CHANGED BEHAVIOUR: + - Keyboard shortcuts reorganized. (wxPropView) + - mvTLIClientGigE.dll became mvTLIClientGigE.cti on Windows as required by the GenTL (mvTLIClientGigE-lib) + standard. Also the installer will set the GENICAM_GENTL32/64_PATH variable now. + On Linux a softlink has been introduced (mvTLIClientGigE.cti -> + mvTLIClientGigE.so). This version is now a fully compliant GenICam GenTL producer + according the GenICam GenTL spec. version 1.0. + - If no valid boardinfo can be read from the eeprom then the driver will generate some (mvHYPERIONfg-lib) + default strings for serial number and board type. + - Eeprom write access now checks a magic number before flashes data to eeprom. (low level mvHYPERION driver, Linux) + (low level mvHYPERION2 driver, Linux) + + UPDATES: + - updated mvSDK driver package. Changes in matrixfg.sys DMA_Common_Buffer (mvTITAN, version 1.5.28.2) + (mvSIGMA, version 4.1.12.49) + - 'CaptureToUserMemory_C' is available on Linux as well now. (all shipped packages) + + BUGS FIXED: + - Frame number is no longer shared across driver instances. (mvVirtualDevice) + - 'mvIMPACTAcquire_Cognex_Adapter.dll' did not end up in the 'x64' subfolder of 'bin' (all shipped x64 MSI based packages) + - Some missing standard enumeration values implemented, GCPortRead and GCPortWrite no (mvTLIClientGigE-lib) + longer have alignment restrictions. + - Potential crashes in rare case when enumerating devices inside a driver did fail. (mvBlueCOUGAR-lib) + (mvBlueFOX-lib) + (mvBlueLYNX-lib) + - The GenApi 2.0 runtime installer will be executed on x64 versions of Windows as well. (mvBlueCOUGAR-x64.msi) + (Bug introduced in version 1.10.95) + - driver module close function improved. (low level mvHYPERION2 driver, Linux) + +17.11.2009 1.10.95 + DEPRECATED API CODE: + - The class class mvIMPACT::acquire::InfoFrameGrabber has been declared deprecated (mvIMPACT_acquire.h) + and will be removed in future versions. Use mvIMPACT::acquire::Info instead. + + NEW FEATURES: + - The property mvIMPACT::acquire::Info::deviceDriverVersion is available for every (all shipped packages) + driver now. + - Added support for features that became available with AIK version 1.1 supported by (mvIMPACTAcquire_Cognex_Adapter-lib, version 1.1.0.2) + VisionPro 6.0 or greater. This includes a timestamp and multi-byte mono pixel + formats. + + CHANGED BEHAVIOUR: + - Delay of about 50 msec added after EEPROM access. (mvHYPERION2.sys, version 2.1.10.18) + - UART read buffer increased to 64 kByte. (mvHYPERION.sys) + + UPDATES: + - Slightly improved automatic doc string creation from GenICam features. (mvBlueCOUGAR-lib) + - Migration to version 2.0.0 of the GenApi runtime. This will change the installation (mvBlueCOUGAR installer) + sequence on Windows as the GenICam runtime installer will be launched + independently from within the mvBlueCOUGAR installer. + - Driver start behaviour from default flash configuration improved. (mvHYPERION2.sys, version 2.1.10.18) + + BUGS FIXED: + - 3rd party streaming devices that don't support 'AcquisitionMode' 'SingleFrame' will (mvBlueCOUGAR-lib) + work again. + (Bug introduced in version 1.10.77) + - Underlying GenICam features whose node changed from true to false did (mvBlueCOUGAR-lib) + not become invisible in mvIMPACT Acquire(interface layout 'Generic' only). + - Enumerated properties whose underlying GenICam nodes node (mvBlueCOUGAR-lib) + changed at runtime did not result in a correct dictionary update(interface layout + 'Generic' only). + +05.11.2009 1.10.94 + NEW FEATURES: + - New sample added: 'CaptureToUserMemory_C'. (all shipped MSI based packages) + - Standard derivation added to noise histogram plot. (wxPropView) + - mvHYPERION-HD-SDI support added. (low level mvHYPERION2 driver, Linux) + + CHANGED BEHAVIOUR: + - default capture buffer alignment for devices that don't require a certain memory (all shipped packages) + alignment will return '1' now. This used to be '0'. + + BUGS FIXED: + - More minor issues introduced with the changed interface ID in mvTLIClientGigE-lib. (mvIPConfigure) + (Bug introduced in version 1.10.87) + +26.10.2009 1.10.93 + NEW FEATURES: + - Tool bar and status bar can be switched on and off now. (wxPropView) + - 'RawToPlanes' mode added to Bayer conversion filter. (all shipped packages) + - Support for mvBlueCOUGAR-X devices added. (mvBlueCOUGAR-lib) + + UPDATES: + - Firmware versions 1.01.20 for mvBlueCOUGAR-S Rev. 1 and 1.00.29 for mvBlueCOUGAR-S (all shipped packages for GigE Vision devices) + devices added. This fixes some problems with setting the upper and lower limits for + the AGC and AEC algorithms. + + BUGS FIXED: + - On some Linux distributions enabling logging to stdout could result in crashes. (all shipped packages) + - Loading of stored filter parameters for 'Dark current filter' did cause incorrect (all shipped packages) + images for negative correction values. + - Clipping effects in dark current filter. (all shipped packages) + - Potential blue screen (BSOD) when re-requesting lost data packets from cameras that (mvGigECapture.sys, version 1.1.3.26) + don't support resend and some other small issues. (mvTLIClientGigE-lib) + +19.10.2009 1.10.92 + DEPRECATED API CODE: + - mvIMPACT::acquire::FunctionInterface::ensureRequests. (mvIMPACT_acquire.h) + Use mvIMPACT::acquire::SystemSettings::requestCount instead. + + NEW FEATURES: + - Properties 'GainLowerLimit_dB', 'GainUpperLimit_dB', 'ExposeLowerLimit_us' and (mvBlueCOUGAR-lib) + 'ExposeUpperLimit_us' will be available in device specific auto control mode for + mvBlueCOUGAR-S devices after updating the firmware to version 1.01.19 for Rev. 1 + devices or 1.00.28 for Rev. 0 devices. + - Properties 'mvIMPACT::acquire::Request::imageOffsetX' and (all shipped packages) + 'mvIMPACT::acquire::Request::imageOffsetY' added. + - Property 'mvIMPACT::acquire::Device::defaultRequestCount' added. (all shipped packages) + - It is possible to reduce the number of request buffers at runtime by writing to the (all shipped packages) + property mvIMPACT::acquire::SystemSettings::requestCount now. However this is only + possible if NO request is currently queued for acquisition OR is locked by the + application. + - New GenICam description file for mvBlueCOUGAR-S devices added(version 2.3.0). This (mvBlueCOUGAR installer) + will allow to access the gain and exposure limits when ALCMode is active and the + Firmware supports it. + - New pixel format introduced: ibpfYUV422_UYVYPacked. (all shipped packages) + - Mirror function and soft scaler support the formats ibpfRGB101010Packed, (all shipped packages) + ibpfRGB121212Packed, ibpfRGB141414Packed and ibpfRGB161616Packed now. + - 12 -> 12 bit SW LUT added. (all shipped packages) + + UPDATES: + - Firmware versions 1.01.19 for mvBlueCOUGAR-S Rev. 1 and 1.00.28 for mvBlueCOUGAR-S (all shipped packages for GigE Vision devices) + devices added. + + BUGS FIXED: + - TLGetInterfaceInfo is working again. (mvTLIClientGigE-lib) + (Bug introduced in version 1.10.87) + - wxPropView did report errors in its resource (*.rc) file when build it from scratch. (all shipped packages) + - Serial numbers like 'VD1' and 'VD10' could not be distinguished from one another. (mvDeviceManager-lib) + - Several minor issues introduced with the changed interface ID in mvTLIClientGigE-lib. (mvIPConfigure) + (Bug introduced in version 1.10.87) + - In 'mmTopDown' when processing YUV422Packed, every 2 consecutive pixels did contain (all shipped packages) + swapped 'Y' components. + +02.10.2009 1.10.91 + NEW FEATURES: + - Property 'FrameDelay_us' published for mvBlueCOUGAR and mvBlueLYNX-M7 devices. (mvBlueCOUGAR-lib) + + CHANGED BEHAVIOUR: + - Property 'FrameDelay_ms' became 'FrameDelay_us' (mvVirtualDevice-lib) + This is a code AND application breaking change! + - The 32-bit MSI based setup for mvHYPERION devices will no longer allow an (mvHYPERION.msi) + installation on Windows 2000 or smaller. + + BUGS FIXED: + - VectorScope plot for RGB888Packed and RGBx888Packed modes is working again. (wxPropView) + (Bug introduced in version 1.10.85) + - Loading of stored filter parameters for 'Defective pixel filter', 'Flat field filter' (all shipped packages) + and 'Dark current filter' fixed. + - Under certain conditions (using a generic camera) the kernel driver did report (mvHYPERION.sys) + acquisition errors. This was generated by the buildscattergather function and has + now been fixed. + - Serial ports now use the file object pointer from IRPStackLocation as owner (mvHYPERION.sys) + secure multi thread access. (mvHYPERION2.sys, version 2.1.9.17) + - Address encoding bit for FPGA DMA-transfer removed from 32-bit driver versions. The (mvHYPERION2.sys, version 2.1.9.17) + address encoding bit will currently be set on 64-bit operating systems only now. + - Potential blue screen (BSOD) when re-requesting lost data packets on Windows 2000. (mvGigECapture.sys, version 1.1.2.25) + +28.09.2009 1.10.90 + UPDATES: + - MSI packages will be built using WiX 3.0.5419.0 now. (all shipped MSI based packages) + + BUGS FIXED: + - 'Offset_pc' in device specific interface for mvBlueCOUGAR-S devices is working now. (mvBlueCOUGAR-lib) + +17.09.2009 1.10.89 + NEW FEATURES: + - The state of the digital inputs and outputs at the beginning and the end of the (mvBlueCOUGARLocal-lib) + exposure period will be returned as part of the request info now. This requires an + FPGA update. + - Automatic tap calibration enabled for mvBlueCOUGAR-S125 devices. This requires (mvBlueCOUGAR-lib) + Firmware versions 1.01.18 or greater. + - New GenICam description file for mvBlueCOUGAR-S devices added(version 2.2.0). This (mvBlueCOUGAR installer) + will allow to access the pixel compensation and the tap calibration features. + + UPDATES: + - GCGetLastError support improved. (mvTLIClientGigE-lib) + - Missing user rights when trying to change the filter driver configuration will be (mvTLIClientGigE-lib) + reported to the user now. (mvGigEConfigure) + + BUGS FIXED: + - Cameras that according to the camera description needed pixel rearrangement AND (mvHYPERIONfg-lib) + de-mosaicing on the host system where always returned as Bayer RAW images. (mvTITANfg-lib) + - 'StreamType' feature returns the correct value now. (mvTLIClientGigE-lib) + - Standard users can successfully call the function 'TLIMV_IsDriverInstalled' under (mvTLIClientGigE-lib) + Windows now. + - Property 'AdapterIPAddress' did contain a list of MAC addresses instead of IP (mvTLIClientGigE-lib) + addresses. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.10.87) + - The property 'PixelClock_KHz' can contain sensor specific values when the (mvBlueCOUGARLocal-lib) + mvBlueLYNX-M7 is operated with 2 different sensor heads now. + - Switching binning modes or pixel clocks while capturing frames could result in long (mvBlueFOX-lib) + delays or incorrect image data(FPGA version 79). + - Installation order of device drivers was incorrect(Serial port driver will be (mvHYPERION.msi) + installed BEFORE the board drivers will be installed, as the latter once need the (mvHYPERION-x64.msi) + serial port driver to be present). + +10.09.2009 1.10.88 + UPDATES: + - Improved update speed of mvBFx05 in OnDemand trigger mode (mvBlueFOX-lib) + + BUGS FIXED: + - Switching between base and medium cameras improved. (mvHYPERIONfg-lib) + +08.09.2009 1.10.87 + NEW FEATURES: + - Certain things can be done by passing command line parameters to the application as (mvDeviceConfigure) + well no, allowing things like e.g. firmware updates to be performed for each device + with less or no user interaction. + - Settings can be imported to and exported from a system wide location now. (wxPropView) + - Global settings will be handled during device initialisation if available. User (all shipped packages) + specific settings will be favoured for backward compatibility. + - All modules of the TLI support read/write access to their ports now. (mvTLIClientGigE-lib) + - mvHYPERION-HDSDI support added, SPI access is located temporarily in the kernelmodule (mvHYPERION2.sys, version 2.1.7.15) + - UART ctrl RS485 support added (mvHYPERION2.sys, version 2.1.7.15) + + UPDATES: (all shipped packages) + - 'DMR_ImportCameraDescription' or + 'mvIMPACT::acquire::CameraDescriptionBase::importDescription' will return an error, + if the referenced file can't be opened for reading. + - When updating an mvBlueCOUGAR-P or mvBlueLYNX-M7 device, mvDeviceConfigure will (mvDeviceConfigure) + automatically open a file dialogue in the folder containing the FW-files shipped as + part of the driver package. + - Initial version that can handle GigE Vision 1.1 compliant devices. This also (mvTLIClientGigE-lib) + includes a method to overcome some firewall related issues when streaming image data. + This however requires a GigE Vision 1.1 compliant device as well. + - Higher frame rates can be reached in single shot mode for mvBlueFOX-10x devices now. (mvBlueFOX-lib) + - Minor change to get rid of the first property being displayed in red in the (mvIMPACTAcquire_Cognex_Adapter-lib, version 1.0.1.1) + QuickBuild(R) feature dialogue. + - Firmware versions 1.01.18 for mvBlueCOUGAR-S Rev. 1 and 1.00.27 for mvBlueCOUGAR-S (all shipped packages for GigE Vision devices) + devices added. + + BUGS FIXED: + - mvHYPERION-CLe and mvHYPERION-CLb serial port installation. (low level mvHYPERION driver, windows) + - Binning in high speed modes (pixel clock >= 32 MHz) could result in incorrect image (mvBlueFOX-lib) + data for mvBlueFOX-12x devices(FPGA version 78). + - Infinite timeout (ImageRequestTimeout_ms set to 0) is working again. (mvTLIClientGigE-lib) + (Bug introduced in version 1.10.85) (mvGigECapture.sys, version 1.1.1.24) + - imageRequestReset is working with the filter driver again. (mvTLIClientGigE-lib) + (Bug introduced in version 1.10.70) (mvGigECapture.sys, version 1.1.1.24) + +20.08.2009 1.10.86 + NEW FEATURES: + - Method 'mvIMPACT::acquire::Statistics::reset' published. (all shipped packages) + - Installer packages can be installed with no user interaction now. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + - Filter driver can be installed without user interaction now (call mvGigEConfigure (mvGigEConfigure) + with parameters 'install quit'(in this order!)). + + UPDATES: + - Firmware version 1.01.17 for mvBlueCOUGAR-S125C Rev. 1 devices added. This fixes a (all shipped packages for GigE Vision devices) + right shift in the image in Mono8 mode. + + BUGS FIXED: + - 'rtctrlModeRunRestart' mode for devices that support HRTC is working again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.10.26) (mvBlueFOX-lib) + (mvHYPERIONfg-lib) + - PoCL switched on during loading the driver module (low level mvHYPERION2 driver, Linux) + - Closing the driver now releases the mvHYPERION board correctly. (low level mvHYPERION2 driver, Linux) + +07.08.2009 1.10.85 + DEPRECATED API CODE: + - 'urNothing': Use 'urNoUpdatePerformed' instead. (mvDriverBaseEnums.h) + + NEW FEATURES: + - Initial version of mvIMPACT Acquire -> VisionPro(R) adapter added to Windows based (all shipped MSI based packages) + installer packages. The adapter will be installed by default but can be switched off + by deselecting the corresponding merge module in the installation procedure. + - Support for some more pixel formats in VectorScope and noise plot added. (wxPropView) + - When a Bayer raw image is displayed, the pixel histogram and the line profile will (wxPropView) + display a plot for each color component now. + - Property 'mvIMPACT::acquire::CameraSettingsBlueDevice::autoControlMode' published. (mvIMPACT_acquire.h) + + UPDATES: + - Missing xpm files added to Linux versions of the GigE Vision driver packages. (mvBlueCOUGAR driver package, Linux) + - Firmware versions 1.01.16 for mvBlueCOUGAR-S Rev. 1 devices and 1.00.26 (all shipped packages for GigE Vision devices) + for mvBlueCOUGAR-S devices added. This fixes the + following issues: + 1) The first image taken after re-configuring the camera sometimes did not use the + new parameters. + 2) It is possible to use software trigger for both digital inputs in delayed readout + mode + 3) DISCOVERY_ACK will be broadcasted if requested by the application. + + BUGS FIXED: + - When selecting 'idpfRaw' as target pixel format, frame grabber device did return (mvHYPERIONfg-lib) + 8 bit mono formats, even if e.g. a connected digital camera did transfer more bits (mvTITANfg-lib) + per component. + - 'LocalDirectory' for description files is working again. (mvBlueCOUGAR-lib) + - When reading the description file fails the driver no longer keeps the heartbeat (mvBlueCOUGAR-lib) + thread running. + - Devices that reported a local acquisition problem by sending a single trailer with (mvGigECapture.sys, version 1.1.0.23) + an appropriate status message did result in resend requests being triggered. + - The timeout values passed by the user for buffers and resend did not result in the (mvGigECapture.sys, version 1.1.0.23) + correct timeout values on all CPUs. + - Potential deadlock when resend was enabled on multi-core CPUs. (mvGigECapture.sys, version 1.1.0.23) + - Double-clicking on the live display in full view mode did not switch on the selected (wxPropView) + analysis plot again. + (Bug introduced in version 1.10.84) + - In scaled mode, the last line of the image was not drawn under certain conditions. (mvDisplay-lib) + - When using a camera description, that would deliver a 32 or 24 bit RGB signal (mvTITANfg-lib) + directly at the grabbers input, the resulting frame did not contain correct data when + switching the destination pixel format explicitly to RGBx888Packed or RGB888Packed + for mvTITAN-DIG, mvTITAN-CL and mvGAMMA-CL devices. + - When working with the software implementation of the LUT, the data for the red (all shipped packages) + channel has been applied to the blue channel and vice versa. + +24.07.2009 1.10.84 + DEPRECATED API CODE: + - The class class mvIMPACT::acquire::StatisticsFrameGrabber and (mvIMPACT_acquire.h) + mvIMPACT::acquire::StatisticsBlueFOX have been declared deprecated and will be + removed in future versions. Use mvIMPACT::acquire::Statistics instead. + + NEW FEATURES: + - Properties 'mvIMPACT::acquire::Statistics::lostImagesCount' and (all shipped packages) + 'mvIMPACT::acquire::Statistics::retransmitCount' published. (mvIMPACT_acquire.h) + - New HDSDI-Hyperion grabber support added in user mode library. (mvHYPERIONfg-lib) + + UPDATES: + - The property grid will no longer display the last available tool tip if moving the (wxPropView) + mouse to another feature with no tool tip. + (Linux only) + - Some more resend related features added. (mvGigECapture.sys, version 1.0.20.21) + + CHANGED BEHAVIOUR: + - Test image modes offer enhanced functionality(more test images can be created now). (mvVirtualDevice-lib) + This might break existing code as some enum values of TVirtualDeviceTestMode have + been removed. + + BUGS FIXED: + - If omitting the file extension while attempting to store an image on Linux the (wxPropView) + save operation did fail. + - Some messages send to the 'Output' window have not been constructed correctly for (wxPropView) + UNICODE builds. + - An image loaded from a file is not longer erased when maximizing the display area or (wxPropView) + selecting a different device. + - Potential crash when enumerating the devices registered for DirectShow access. (DirectShow_acquire.ax) + (Bug partly introduced in version 1.10.83) + - When the size of a device local description file was 4 byte aligned already, 4 bytes (mvBlueCOUGAR-lib) + too much have been read from the device the description file download to fail for + certain third party cameras. + - Sometimes the first call to the 'triggerSoftware' method directly after sending (mvBlueCOUGAR-lib) + buffers to the request queue that was empty before did not result in an image being + triggered. + - On multi-core CPUs sometimes the calibration of the flat field and the dark current (all shipped packages) + filter could fail/produce incorrect results. + +15.07.2009 1.10.83 + NEW FEATURES: + - The main image display will be hidden when disabled now, allowing (wxPropView) + a full view analysis plot. + - The Bayer parity of the test modes 'vdtmBayerWhiteBalanceTestImage' and (mvVirtualDevice-lib) + 'vdtmBayerWhiteBalanceTestImageMono12' is selectable now. + + BUGS FIXED: + - Bayer conversion: bmpGB did produce an incorrect left upper pixel and (all shipped packages) + bmpBG and bmpGR did produce an incorrect pixel at the beginning of + every other line on some platforms for 8 bit images and + on all platforms for multi-byte images. + - Some labels of the x and y axis displayed an incorrect (too large) value. (wxPropView) + - Potential deadlock on multi-core Windows systems with resend enabled. (mvGigECapture.sys, version 1.0.19.20) + - Certain exposure times could still result in black frames for mvBlueFOX-x05 (mvBlueFOX-lib) + devices. + +13.07.2009 1.10.82 + NEW FEATURES: + - Property 'mvIMPACT::acquire::Request::imageChannelBitDepth' (all shipped packages) + published. This feature will only be available for driver versions (mvIMPACT_acquire.h) + higher than 1.10.81. + - Monitor display added. (wxPropView) + - Initial version of the mvIMPACT Acquire -> VisionPro interface (all shipped MSI based packages) + added to installer packages. + + UPDATES: + - Version 2 of the mvBlueFOX kernel mode driver for x86 is working under (mvBlueFOX.msi) + Windows 2000 as well now. + - A more mature version of the NDIS based filter driver with resend (mvGigECapture.sys, version 1.0.18.19) + introduced in version 1.10.77. + - New firmware 2.2.7 for mvBlueCOUGAR-P devices added. (all shipped packages for GigE Vision devices) + - The property interface will expose 64-bit integer properties as well now. (DirectShow_acquire.ax) + + BUGS FIXED: + - Request size is no longer limited to 64 MB. (mvHYPERION2.sys, version 2.1.5.13) + - Potential crash when ending the application in live mode while (wxPropView) + displaying multi-byte data. + - Last 2 rows in the numerical display of the histogram and noise plot (wxPropView) + did contain incorrect data. + - It was possible that properties define a default value, that was (mvPropHandling-lib) + invalid with respect to the translation dictionary of that property. + - Some devices claimed(e.g. mvHYPERION boards) to support the 'triggerMode' (mvIMPACT_acquire.h) + property from the 'CameraSettingsXXX' class even if they didn't. + - Clipping effects in flat field correction filter. (all shipped packages) + +02.07.2009 1.10.81 + NEW FEATURES: + - Log file output is possible in plain text mode now. See documentation for (all shipped packages) + details. + + UPDATES: + - Missing new source files for wxPropView added to MSI based installer packages (all shipped MSI based packages) + (AnalysisDataGridTable.h/.cpp and VectorScopeCanvas.h/.cpp). + + BUGS FIXED: + - Potential crashes when settings 'ImageRequestTimeout_ms' to 0 and sending 4 (mvBlueFOX-lib) + or more requests to the driver at once while working in a triggered mode + with no trigger signal and then close the driver. + - Potential crash when ending the application in live mode while the mouse (wxPropView) + cursor is on top of the image or when moving the mouse over the lower right + line of the current image. + (Bug introduced in version 1.10.78) + - Request size is no longer limited to 64 MB. (mvHYPERION.sys, version 1.0.37.39) + - Reset medium channel version 2 added. This bugfix needs an up to date (mvHYPERION.sys, version 1.0.37.39) + CLe-firmware(version 44 or higher). + - Image buffer check improved. This fixes an issue when increasing the request (mvHYPERIONfg-lib) + buffer size of a request that had been used before. + +25.06.2009 1.10.80 + DEPRECATED API CODE: + - Function 'mvIMPACT::acquire::FunctionInterface::availableImageRequestControls' (mvIMPACT_acquire.h) + has been declared deprecated. Use 'mvIMPACT::acquire::FunctionInterface:: + getAvailableImageRequestControls' instead. + + NEW FEATURES: + - There can be more than one image request control now. Functions (all shipped packages) + DMR_CreateRequestControl (C-API) and mvIMPACT::acquire:: + FunctionInterface::createRequestControl (C++-API) implemented. + - Grid step controls added to vectorScope in order to allow to (wxPropView) + analyse not every pixel in the selected AOI. + - 'Load image...' added to 'Action' menu (wxPropView) + - The name of an image file can be passed as a command line parameter now. (wxPropView) + + UPDATES: + - Memory usage of numerical analysis display reduced. (wxPropView) + + CHANGED BEHAVIOUR: + - The AOI of the currently selected analysis plot can be dragged to a new (wxPropView) + location by LEFT-clicking into the AOI and drag it to its new location. + RIGHT-clicking and dragging on the image will define a NEW AOI for the + selected analysis control. + + BUGS FIXED: + - Synchronized AOI height was incorrect. (wxPropView) + - Some minor display related issues for multi-byte RGB data display in (wxPropView) + VectorScope control. + - Invalid command line parameters could lead to an endless loop when (wxPropView) + starting the application. + - Restoring the default of AOI, binning, gain and exposure time was not (mvBlueCOUGAR-lib) + always working correctly when closing and then re-opening a device. (mvBlueCOUGARLocal-lib) + - GFP_DMA flag removed from driver init in mvHYPERION2 module. (low level mvHYPERION2 driver, Linux) + +19.06.2009 1.10.79 + NEW FEATURE: Power over CameraLink can now be switched on/off from wxPropView. (mvHYPERIONfg-lib) + This feature has been added to the Device Specific Data list. (mvHYPERION.sys, version 1.0.36.38) + (mvHYPERION2.sys, version 2.1.4.12) + + NEW FEATURE: Standard Windows serial port access added to mvHYPERION (mvHYPERION.sys, version 1.0.36.38) + wdm-kernel module. + + NEW FEATURE: Horizontal binning implemented for mvBlueFOX-x00wG/C devices. (mvBlueFOX-lib) + (This enables 'BinningH' and 'BinningHV'. + + NEW FEATURE: Initial version of enhanced capture thread and recording controls (wxPropView) + added. Continuous and/or silent recording is now possible, the depth + of the capture queue can be configured now (especially useful for + continuous recording). + + NEW FEATURE: The AOI of the currently selected analysis plot can be dragged to (wxPropView) + a new location by right-clicking and dragging into the AOI. + + NEW FEATURE: The analysis plots now have a numerical display based on a wxGrid (wxPropView) + control. Updating this grid requires a lot of additional CPU load if + active in live mode thus this feature should be used for analysis + purposes only. + + NEW FEATURE: Supported image file types can be dropped into the display area (wxPropView) + for analysis now. + + NEW FEATURE: AOI sync. feature added to 'Settings -> Analysis' menu. (wxPropView) + + NEW FEATURE: VectorScope plot control added. (wxPropView) + + CHANGED BEHAVIOUR: AOIs can only be changed by the mouse if the selected plot (wxPropView) + is enabled as well + + BUGFIX: The request info 'exposeStart_us' did return the timestamp of the end (mvBlueFOX-lib) + of the exposure. + + BUGFIX: On Windows changing the value of a spin control in the lower right (wxPropView) + section of the application did not update the internal data structures. + (Windows only) + (Bug introduced in version 1.10.78) + + BUGFIX: LUT related properties in class mvIMPACT::acquire::ImageProcessing (mvIMPACT_acquire.h) + have not been bound correctly if available. + (Bug introduced in version 1.10.73) + + BUGFIX: Calling ImageBufferDesc::ImageBufferDesc( TImageBufferPixelFormat (mvIMPACT_acquire.h) + pixelFormat, int width, int height ) did allocate but never free + memory for the image. + +09.06.2009 1.10.78 + NEW FEATURE: The AOI of the selected image analysis plot can now also be (wxPropView) + positioned by right-clicking and dragging the mouse on the image. + + NEW FEATURE: The current pixels value is displayed in the lower right end of (wxPropView) + the status bar now. + + NEW FEATURE: custom format NonStandardMono12packed added. (mvHYPERIONfg-lib) + + CHANGED BEHAVIOUR: Multi-byte data acquisition set byte ordering correct. (mvHYPERIONfg-lib) + (big endianess) + + CHANGED BEHAVIOUR: Max. request objects limit removed for mvHYPERION-CLm/CLf. (mvHYPERIONfg-lib) + This limit must be temporarily handled on application site. Its value + is 32. + + BUGFIX: When selecting an AOI width smaller than 316 the exposure time selected (mvBlueFOX-lib) + differed from the one actually used for mvBlueFOX-x02 devices. + + BUGFIX: On ppc cell systems weak_ordering attribute will be set for DMA (low level mvHYPERION2 driver, Linux) + mapping. + + BUGFIX: Spin controls directly respond to text input as well now (after (wxPropView) + pressing ENTER). + (Linux only) + + BUGFIX: Scrollbars in scaled display mode behave correctly now. (wxPropView) + (Linux only) + +04.06.2009 1.10.77 + NEW FEATURE: 50 MHz pixel clock for certain sensors is available now. (mvBlueCOUGARLocal-lib) + + NEW FEATURE: Early version of a NDIS based transport layer that supports (mvGigECapture.sys, version 1.0.17.18) + packet resend requests added. The transport layer parameters can be + accessed via the 'System/TLI/DataStream' list for testing. + + UPDATE: Gain response is much more linear for mvBlueFOX-x0x devices now. (mvBlueFOX-lib) + + UPDATE: Improved SingleFrame acquisition mode for mvBluexxx devices. (mvBlueCOUGAR-lib) + + BUGFIX: Certain exposure times could result in black frames for (mvBlueFOX-lib) + mvBlueFOX-x05 devices. + + BUGFIX: Calling imageRequestReset during a live acquisition could lead to (mvBlueCOUGAR-lib) + deadlocks in rare cases. + +26.05.2009 1.10.76 + NEW FEATURE: Slider to quickly navigate into a recorded sequence added. (wxPropView) + + BUGFIX: Starting a record sequence directly after increasing the request (wxPropView) + count for a device did not behave correctly. + + BUGFIX: On Linux platforms not supporting recursive mutexes the end of a (wxPropView) + sequence recording could result in a deadlock. + (Linux only) + + BUGFIX: ibpfYUV422Packed did not return correct images for raw Bayer video (all shipped packages) + sources and the colorProcessing property set to 'Auto'. + (Linux only) + + BUGFIX: Crashes when stopping the filter driver from within the VisualStudio (mvGigECapture.sys, version 1.0.16.17) + debugger or another debugging environment for at least 2 times + (Bug introduced in version 1.10.66 in 1.0.13.14 of the kernel module) + +14.05.2009 1.10.75 + UPDATE: Firmware version 1.00.25 for mvBlueCOUGAR-S devices and version (all shipped packages for GigE Vision devices) + 1.01.13 for mvBlueCOUGAR-S Rev. 1 devices. This fixes an issue where + in software triggered mode some frames did not get transferred + completely. Also this update will allow AGC/AEC in triggered mode. + + BUGFIX: mvIMPACT::acquire::FunctionInterface::requestCount did not always (mvIMPACT_acquire.h) + return the correct current value. The return value was incorrect, if + an application did write to the property + mvIMPACT::acquire::SystemSettings::requestCount before. + + BUGIFX: Now CLm/CLf boards can capture the full frame rate if working with (mvHYPERIONfg-lib) + area scan cameras. LineScan acquisition is not affected from this + change. This bugfix needs an up to date firmware with version 47. + + BUGFIX: copying image result data corrected. (low level mvHYPERION2 driver, Linux) + + BUGFIX: 64bit dma_address handling. Now CLf/CLm low level driver set the (mvHYPERION2.sys, version 2.1.3.11) + AddressSpaceEncoding flag correctly. (low level mvHYPERION2 driver, Linux) + +11.05.2009 1.10.74 + NEW FEATURE: Visual Studio 2008 workspace and project files added to sample (all shipped MSI based packages) + programs. + + UPDATE: More detailed information output added. (mvIPConfigure) + + UPDATE: Migration to version 1.1.2 of the GenApi runtime. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + + UPDATE: Firmware version 2.2.0 added for mvBlueCOUGAR-P devices added. (all shipped packages for GigE Vision devices) + This fixes various issues with memory allocation in the local interface + and enables the new firmware update procedure. + + UPDATE: Sampling parameters for mvBlueFOX-2xx (CCD version only) improved. (mvBlueFOX-lib) + This will improve the overall image quality and will fix a smearing + issue for the mvBlueFOX-221. + + CHANGED BEHAVIOUR: Gamma response behaviour for LUT operations inverted. (all shipped packages) + + BUGFIX: Removing a user supplied capture buffer from a request object could (mvHYPERIONfg-lib) + lead to crashes. + +04.05.2009 1.10.73 + NEW FEATURE: PoCL enabled for Hyperion CLm/CLf. (mvHYPERION2.sys, version 2.1.2.10) + + NEW FEATURE: Property 'UserDataMaxSize_bytes' published. This feature can be (mvBlueCOUGARLocal-lib) + written to BEFORE opening the device. The value stored by the property + defines the max. amount of bytes, that can be transmitted together with + the image or without the image via the transmission library of + mvIMPACT. + + NEW FEATURE: Flexible user data chunk size transmission. (FW/RFS 2.1.35) + This requires a firmware update. + + NEW FEATURE: Vertical binning implemented for mvBlueFOX-x00wG/C devices. (mvBlueFOX-lib) + Max. frame rate increased to 60 Hz. + + NEW FEATURE: 10 -> 8 bit HW LUT for mvBlueFOX-2xx for color versions now fully (mvBlueFOX-lib) + functional. + + UPDATE: New firmware update procedure for mvBlueCOUGAR-P and mvBlueLYNX-M7 (mvBlueCOUGAR-lib) + devices. These method can only be used when the device itself provides (mvDeviceConfigure) + a recent firmware, thus until the device itself can deal with this + method, the 'old' update procedure will be used automatically. + + UPDATE: New version of the filter driver added. This version has been built (mvGigECapture.sys, version 1.0.15.16) + with a newer version of the DDK. + + UPDATE: Missing new source files for wxPropView added to MSI based installer (all shipped MSI based packages) + packages (ValuesFromUserDlg.h/.cpp). + + UPDATE: Internal image processing code updated. (all shipped packages) + + CHANGED BEHAVIOUR: The number of requests is no longer limited by the sensor (mvBlueCOUGARLocal-lib) + resolution. The ImageMemoryManager class and the property + 'ImageBufferSize_bytes' are no longer needed and internally don't do + anything any more. All references in existing applications should be + removed. + + BUGFIX: On-board processor supports DMA transfer on 64-bit operating systems (mvHYPERIONfg-lib) + properly now. + + BUGFIX: On-board processor will clear the input data fifo for line/frame (mvHYPERIONfg-lib) + cameras within the first image request only. + + BUGFIX: Disconnect/Connect a camera to Hyperion-CLm/CLf could result in a (mvHYPERION2.sys, version 2.1.2.10) + disturbed image. Now the PoCL logic reset after 3 sec the CameraLink + receiver channel. + + BUGFIX: Switching from RGB to multi-channel grey acquisition for mvTITAN-RGB/x (mvTITANfg-lib) + boards. + + BUGFIX: When constructing an instance of the class (mvIMPACT_acquire.h) + mvIMPACT::acquire::ImageProcessing in an application build with header + files from versions 1.10.71 - 1.10.72 running this application on a + system with a driver version smaller than 1.10.71 did raise an + exception. + (Bug introduced in version 1.10.71) + + BUGFIX: When editing a spin control via the arrow keys up/down the focus is (wxPropView) + no longer lost at random. + (Bug introduced in version 1.10.69) + + BUGFIX: Crashes when activating the noise profile for multi-byte mono formats. (wxPropView) + + BUGFIX: Multi-byte Bayer raw data conversion to multi-byte mono images. (all shipped packages) + + BUGFIX: When explicitly requesting a multi-byte RGB packed format all (mvBlueFOX-lib) + mvBlueFOX devices internally used a single byte format. As the + mvBlueFOX2 series is capable of capturing with more than 8 bit + resolution, these devices now select a multi-byte format. + + BUGFIX: When explicitly requesting a multi-byte RGB packed format from a Bayer (mvBlueFOX-lib) + sensor, the image color conversion resulted in incorrect images after (mvBlueCOUGAR-lib) + 'requestCount' buffers have been captured. (mvBlueLYNX-lib) + + BUGFIX: Problems when requesting more (>16) frames then some of the internal (mvBlueCOUGARLocal-lib) + components could handle. + +15.04.2009 1.10.72 + NEW FEATURE: mvBlueCOUGAR-S devices support 'AutoControlMode' acmStandard now. (mvBlueCOUGAR-lib) + + NEW FEATURE: Draw window is selectable for line profile as well now. (wxPropView) + + BUGFIX: Switching the draw window start from 0 to 1 and back did not work (wxPropView) + for the pixel and the noise histogram. + + BUGFIX: Switching off the image header did not work. (mvBlueFOX-lib) + (Bug introduced in version 1.10.71) + +14.04.2009 1.10.71 + NEW FEATURE: LUTOperations filter added to image processing features. (all shipped packages) + + NEW FEATURE: 10 -> 8 bit hardware LUT added. This can be configured via the (mvBlueFOX-lib) + LUTOperations filter. This feature is available for mvBlueFOX-2xx + devices only. So far the feature has just been implemented for + mono versions of this device. + + CHANGED BEHAVIOUR: Multi-byte Bayer raw signals are no longer automatically (mvHYPERIONfg-lib) + converted to single byte Bayer raw data by default but will be + transferred as multi-byte data now. + + BUGFIX: On Linux string properties storing string longer than 256 chars (mvPropHandling-lib) + did return their data truncated when calling + mvIMPACT::acquire::Property::readS, OBJ_GetSFormatted, + OBJ_GetSFormattedEx, OBJ_GetSArrayFormatted or + OBJ_GetSArrayFormattedEx. + + BUGFIX: A call to the constructor of (mvIMPACT_acquire.h) + mvIMPACT::acquire::CameraSettingsBlueDevice could raise an exception + for certain device types. + (Bug introduced in version 1.10.65) + +06.04.2009 1.10.70 + UPDATE: Serial port driver compatibility added for Basler cameras. (mvSerialPort.sys, version 1.0.3.3) + + UPDATE: PortClose() now calls an IoCtl in the mvHYPERION low level drivers. (clsermv.dll, version 1.0.5.6) + + BUGFIX: Some debug outputs removed. (mvHYPERION2.sys, version 2.1.1.9) + + BUGFIX: Small bug in read function fixed. (mvSerialPort.sys, version 1.0.3.3) + +03.04.2009 1.10.69 + NEW FEATURE: Serial port driver added for mvHYPERION-CLf and mvHYPERION-CLm (mvSerialPort.sys, version 1.0.0.0) + devices. This will allow communication with CameraLink compliant (mvSAlloc.sys, version 1.0.0.0) + cameras via COM port access function or standard terminal applications. + + UPDATE: Firmware version 1.00.24 for mvBlueCOUGAR-S devices added. (all shipped packages for GigE Vision devices) + This fixes an issue where 1-3 black lines could be seen in the first + lines of the image when working in partial scan mode. For color versions + of the mvBlueCOUGAR-S this could also result in incorrect Bayer conversion + results(mixed up color channels). + + UPDATE: The interface headers and samples can be used with Borland C++ Builder (all shipped packages) + 2007 now. + + UPDATE: New version of the filter driver added. This version contains further (mvGigECapture.sys, version 1.0.14.15) + enhancements regarding debugging. + + UPDATE: mvBlueFOX-x00wG/C devices will return the used Gain and exposure values (mvBlueFOX-lib) + when operated in device specific AGC/AEC mode. + + CHANGED BEHAVIOUR: mvBlueFOX-x00wG/C devices will use 'Standard' as the default (mvBlueFOX-lib) + 'AutoControlMode' now. + + CHANGED BEHAVIOUR: DirectShow_acquire.msi will no longer be shipped as a (all shipped MSI based packages) + separate package. Each device driver now contains the files needed + for DirectShow support. Old DirectShow_acquire installations will + be removed automatically during an upgrade. mvDeviceConfigure can now + be used to set up devices for DirectShow. + + BUGFIX: Installer can be installed on Windows 7 without SP1. (mvBlueCOUGAR.msi) + (Bug introduced in version 1.10.64) (mvBlueCOUGAR-x64.msi) + + BUGFIX: x64 version of the GigE Vision capture driver is working again. (mvGigECapture.sys, version 1.0.14.15) + (Bug introduced in version 1.10.66) + + BUGFIX: Potential crashes, when working with the driver internal Bayer (all shipped packages) + de-mosaicing and mvIMPACT on Linux. + + BUGFIX: Property grid is displayed correctly again. In 'full tree' mode (wxPropView) + certain driver sub-trees are not created any more. + (Bug introduced in version 1.10.66) + + BUGFIX: In single frame acquisition mode sometimes error (either timeouts or (mvBlueCOUGAR-lib) + 'DEV_NO_FREE_REQUEST_AVAILABLE' where returned. + (Bug introduced in version 1.10.65) + +20.03.2009 1.10.68 + UPDATE: mvHYPERION-clf/clm Linux compatibility for ppc64 system added. (low level mvHYPERION2 driver, Linux) + + UPDATE: Timestamps became 64-bit values (have been 32-bit). This needs a FW (mvBlueCOUGARLocal-lib) + update as well. + + BUGFIX: Installation did fail on x86 systems because of a wrong kernel module (mvHYPERIONfg.msi) + (x64). + (Bug introduced in version 1.10.63) + + BUGFIX: 'State' property is correctly updated again when removing/re-connecting (mvBlueFOX-lib) + a device. + (Bug introduced in version 1.10.64) + +19.03.2009 1.10.67 + UPDATE: Firmware version 1.01.11 for mvBlueCOUGAR-S Rev. 1 mono devices and (all shipped packages for GigE Vision devices) + version 1.0112 for mvBlueCOUGAR-S Rev. 1 color devices added. + + UPDATE: Some new code added to 'ContinuousCapture_C' sample. (all shipped packages) + + BUGFIX: Sometimes calling 'DMR_CopyCameraDescription' could fail even when a (mvDeviceManager-lib) + valid camera description handle was passed to the function. + + BUGFIX: Sudden increase in intensity when slightly increasing the Gain_dB (mvBlueFOX-lib) + property for mvBlueFOX-x05 devices. + + BUGFIX: Some AOI, AGC and AEC issues for mvBlueFOX-x00wG/C devices. (mvBlueFOX-lib) + +13.03.2009 1.10.66 + UPDATE: New version of the filter driver added. This version will work with (mvGigECapture.sys, version 1.0.13.14) + limited user rights (e.g. with UAC under Vista switch on and NOT (mvTLIClientGigE-lib) + running the application as an administrator) as well. + + CHANGED BEHAVIOUR: mvGigEConfigure is digitally signed and requires (asks for) (mvGigEConfigure) + administrator rights on Windows Vista now. + + CHANGED BEHAVIOUR: wxPropView, mvDeviceConfigure and mvIPConfigure are (all shipped MSI based packages) + digitally signed now. + + CHANGED BEHAVIOUR: All mvIMPACT Acquire MSI packages are digitally signed now. (all shipped MSI based packages) + + CHANGED BEHAVIOUR: Version 1 of the mvBlueFOX kernel mode driver for x86 (mvBlueFOX.msi) + targets is no longer shipped. + + CHANGED BEHAVIOUR: The 32-bit version of the mvBlueFOX driver is digitally (mvBlueFOX.msi) + signed now. Because of this *.cat files have been added to the + installer packages and this might force you to modify custom + installations. + + BUGFIX: Missing files 'DevData.h' and 'common.rc2' needed to compile (all shipped MSI based packages) + wxPropView added. + + BUGFIX: Writing to the property 'SensorHeads' with an index different from 0 (mvBlueCOUGARLocal-lib) + in a HRTC program step caused an exception for M7 devices even if + multiple sensor heads were available. + (Bug introduced in version 1.10.65) + +10.03.2009 1.10.65 + DEPRECATED API CODE: Functions 'OBJ_GetSFormatted' and 'OBJ_GetSArrayFormatted' (mvDeviceManager-lib) + have been declared deprecated. Use new 'Ex' versions of these + functions. + + UPDATE: channel synchronization improved (for medium and full cameras) (low level mvHYPERION2 driver, windows 2.0.7.7) + (low level mvHYPERION2 driver, Linux) + + UPDATE: Search for mvBlueFOX in /dev/bus/usb by default. (mvBlueFOX-lib) + + UPDATE: CLm support added to kernel modules. AbortRequest function now (low level mvHYPERION2 driver added, windows 2.0.6.6) + releases both request queues. (low level mvHYPERION2 driver, Linux) + + UPDATE: When a mvIMPACT buffer is returned to the user this buffer will now (mvDeviceManager-lib) + correctly specify the 'IPL_BITSPERSAMPLE' feature for multi-byte + pixel formats. + + NEW FEATURE: Long time integration. Exposure on high by writing to a digital (mvBlueFOX-lib) + output. + + NEW FEATURE: mvHYPERION CLm support added to Hyperion driver (mvHYPERIONfg-lib) + + NEW FEATURE: 'DesiredAverageGreyValue' property implemented for mvBlueCOUGAR-S (mvBlueCOUGAR-lib) + devices. + + NEW FEATURE: Missing properties published in class (mvIMPACT_acquire.h) + mvIMPACT::acquire::AutoControlParameters. + + NEW FEATURE: Functions 'OBJ_GetSFormattedEx' and 'OBJ_GetSArrayFormattedEx' (mvDeviceManager-lib) + added. + + BUGFIX: Potential crash when closing a device, that was running in live mode. (wxPropView) + + BUGFIX: Medium modes 10x4 and 12x4 corrected. (mvHYPERIONfg-lib) + + BUGFIX: Sometimes the first call to (mvBlueCOUGAR-lib) + mvIMPACT::acquire::TriggerControl::triggerSoftware did not result in + a frame being triggered. + + BUGFIX: Minor problem when updating properties that do specify the cfFixedSize (mvPropHandling-lib) + flag with data that contained more values than the property did allow. + + BUGFIX: Potential crashes when an application was terminated forcefully without (mvDeviceManager-lib) + calling the correct clean up code (DMR_Close, etc.). + +02.03.2009 1.10.64 + UPDATE: Support for newer kernel version added to mvHYPERION modules. (low level mvHYPERION driver, Linux) + + UPDATE: Property 'AcquisitionIdleTimeMax_ms' introduced. (mvBlueCOUGAR-lib) + + UPDATE: Re-organized structure of the example applications. (all shipped MSI based packages) + 'SynchronousCaptureMultipleInputs' is now part of every installation + package. + + NEW FEATURE: New Samples added: 'GenericInterfaceLayout', 'DigitalIOs' (all shipped MSI based packages) + 'ContinuousCaptureMultipleInputs', + 'ContinuousCaptureMultipleVideoSignals'. + + NEW FEATURE: mvIMPACT::acquire::ComponentIterator::lastSibling and (mvIMPACT_acquire.h) + OBJ_GetLastSibling function added. (mvDeviceManager-lib, 1.10.64.142) + + NEW FEATURE: Support for mvBlueFOX-x00wG/C devices added. (mvBlueFOX-lib) + + NEW FEATURE: Initial version of multi-byte de-mosaicing algorithm added. (all shipped packages) + + NEW FEATURE: Property 'mvIMPACT::acquire::Device::capabilities' and some (mvIMPACT_acquire.h) + convenience functions to query the availability of certain capabilities + published. + + NEW FEATURE: Draw step width is selectable for pixel and noise histogram now. (wxPropView) + + NEW FEATURE: wxPropView can finally cope with lists and features being deleted (wxPropView) + at runtime. + + NEW FEATURE: Inversion parameter added to 'OutputSignalGeneratorBlueDevice' (mvIMPACT_acquire.h) + Some convenience functions added to class + 'OutputSignalGeneratorBlueDevice'. + + NEW FEATURE: HRTC programs can decrease in size at runtime now. (mvBlueCOUGAR-lib) + (mvBlueFOX-lib) + (mvHYPERIONfg-lib) + + NEW FEATURE: 'MissingData_pc' property will be available for every device (all shipped packages) + driver now. Devices, that can't detect missing data will not modify + this parameter, thus it will always stay 0. + + NEW FEATURE: EEPROM access and user data related interface implemented for (mvTITANfg-lib) + mvTITAN and mvGAMMA boards. + + NEW FEATURE: AGC/AEC support for 2 byte mono pixel formats. (mvBlueFOX-lib) + + NEW FEATURE: TAutoControlMode published and implemented for mvBlueFOX and (mvBlueFOX-lib) + mvBlueCOUGAR driver. (mvBlueCOUGAR-lib) + + CHANGED BEHAVIOUR: 'Device::allowUnrecommendedFeatures' became a boolean (mvIMPACT_acquire.h) + property. + + BUGFIX: Sometimes wxPropView did crash when the current device was changed (wxPropView) + and the mouse was moved in the property grid. + + BUGFIX: I/O access is possible again. (mvSIGMAfg-lib) + (Bug introduced in version 1.10.52) + + BUGFIX: mvBlueFOX-10x devices no longer claim to have SDRAM. (mvBlueFOX-lib) + (Bug introduced in version 1.10.55) + + BUGFIX: Property 'syncOutputMode' of class 'IOSubSystemFrameGrabber' was bound (mvIMPACT_acquire.h) + to and incorrect property. + +18.02.2009 1.10.63 + CHANGED BEHAVIOUR: Installation sequence changed as with previous versions (mvBlueCOUGAR.msi) + upgrading from an old to a newer version of the capture filter driver (mvBlueCOUGAR-x64.msi) + could fail until rebooting the system and manually installing the filter + driver using mvGigEConfigure. + + CHANGED BEHAVIOUR: Linux package, mvHYPERION board variants CLf and CLm will (low level mvHYPERION driver, Linux) + now be handled by a separate kernel module 'mvHYPERION2'. This new + kernel module offers a better support for 'full' CameraLink cameras. + + UPDATE: Stop/Restart of streaming behaviour in case of request queue underruns (mvBlueCOUGAR-lib) + improved. + + UPDATE: Slightly improved 'triggerSoftware' command execution time. (mvBlueCOUGAR-lib) + + UPDATE: Invalid FW files can no longer be selected for mvBlueCOUGAR-S devices. (mvDeviceConfigure) + + NEW FEATURE: Partial scan mode implemented for mvBlueCOUGAR-S devices. (mvBlueCOUGAR-lib) + + BUGFIX: mvHYPERION-CLf, sometimes the acquisition does not start and returns (mvHYPERIONfg-lib) + a timeout error. With this bugfix the acquisition should start secure. + + BUGFIX: mvHYPERION-CLe and CLb, sometimes the acquisition does not start (low level mvHYPERION driver, windows 1.0.34.36) + and returns a timeout error. With this bugfix the acquisition should + start secure. + + BUGFIX: Depending on certain internal processing functions being active or not (mvBlueCOUGAR-lib) + sometimes data was captured into the user supplied capture buffer by (mvBlueCOUGARLocal-lib) + the hardware but the final result, which ended up in a different buffer (mvBlueFOX-lib) + was returned to the user. (mvHYPERIONfg-lib) + + BUGFIX: When a device was closed with binning active, re-opening it could (mvBlueCOUGAR-lib) + result in an incorrect max. AOI. + + BUGFIX: Record mode is working correctly again. (wxPropView) + (Bug introduced in version 1.10.57) + + BUGFIX: When binning is active, the FrameRate_Hz property becomes invisible now (mvBlueCOUGAR-lib) + + BUGFIX: Closing the device did not made it available for re-opening until the (mvTLIClientGigE-lib) + the heartbeat timeout did elapse. + (Bug introduced in version 1.10.52) + +12.02.2009 1.10.62 + NEW FEATURE: PropView an drivers can handle buffer that contain NO image data (wxPropView) + but additional data like processing results only now. (mvVirtualDevice-lib) + (mvBlueCOUGAR-lib) + + UPDATE: Firmware version 2.1.22 added for mvBlueCOUGAR-P devices added. (all shipped packages for GigE Vision devices) + This fixes an issue with writing non-volatile parameters(e.g. + GevInterfaceMTU) to the device. + + UPDATE: Optimized the selection of the optimal transfer pixel format for (mvBlueCOUGAR-lib) + mvBlueCOUGAR-S devices. + + BUGFIX: When an incomplete chunk image was forwarded and the height and width (mvBlueCOUGAR-lib) + information of the chunk was invalid this could lead to crashes in rare + cases. + (Bug introduced in version 1.10.61) + + BUGFIX: Internal conversions from multi-byte mono to multi-byte RGB pixel (all shipped packages) + did not always return correct results. + + BUGFIX: Defective pixel filter is working again. (all shipped packages) + (Bug introduced in version 1.8.5) + +11.02.2009 1.10.61 + UPDATE: Firmware version 2.1.21 added for mvBlueCOUGAR-P devices added. (all shipped packages for GigE Vision devices) + + NEW FEATURE: PropView can configured to display incomplete image buffer as (wxPropView) + well. + + BUGFIX: Property 'DigitalInputThreshold_mV' no longer appears to be available (mvBlueCOUGAR-lib) + for mvBlueCOUGAR-P devices. + +09.02.2009 1.10.60 + NEW FEATURE: Image request control mode 'trial' implemented. (mvBlueCOUGARLocal-lib) + +05.02.2009 1.10.59 + DEPRECATED API CODE: The class class mvIMPACT::acquire::StatisticsBlueCOUGAR (mvIMPACT_acquire.h) + has been declared deprecated and will be removed in future version. + All features of this class are now available in the base class + mvIMPACT::acquire::Statistics for every device. + + NEW SAMPLE: SynchronousCaptureMultipleInputs sample added. (mvBlueCOUGAR.msi) + This sample can be used as a starting point synchronized image (mvBlueCOUGAR-x64.msi) + acquisition from multiple sensor heads from mvBlueLYNX-M7 devices. + + NEW FEATURE: Firmware and support for mvBlueCOUGAR-S124(1.01.10) and (all shipped packages for GigE Vision devices) + mvBlueCOUGAR-S125(1.01.07) added. + + NEW FEATURE: Function mvIMPACT::acquire::DigitalOutput::iswriteable added. (mvIMPACT_acquire.h) + + NEW FEATURE: Properties (all shipped packages) + 'mvIMPACT::acquire::Statistics::framesIncompleteCount' + and 'mvIMPACT::acquire::Statistics::missingDataAverage_pc' + published. + + CHANGED BEHAVIOUR: Slightly improved the network adapter recognition function (mvTLIClientGigE-lib) + on Linux. + + CHANGED BEHAVIOUR: Whenever a request is returned to the user that does not (all shipped packages) + contain a valid buffer, the request buffer properties are set to + invalid values. + + BUGFIX: 8 byte memleak whenever the min, max or increment parameter of a (mvPropHandling-lib) + property was changed by a device driver. + + BUGFIX: Leading 'kHz_' in the string representation of the allowed values for (mvBlueCOUGAR-lib) + the property 'PixelClock_kHz' removed again. + (Bug introduced in version 1.10.57) + + BUGFIX: Parallel acquisition improved. If using asynchronous cameras (mvHYPERIONfg-lib) + then sometimes the request was return with an error. + + BUGFIX: When the mvBlueLYNX-M7 was operated with a single sensor head only (mvBlueCOUGARLocal-lib) + the initialisation of the device could fail. + +29.01.2009 1.10.58 + NEW FEATURE: Property 'userData' published in class (mvVirtualDevice-lib) + 'mvIMPACT::acquire::CameraSettingsVirtualDevice'. (mvIMPACT_acquire.h) + + NEW FEATURE: Property 'imageRequestTimeout_ms' published. (mvVirtualDevice-lib) + + BUGFIX: 'empty' strings for overlay display could result in incorrect overlay (wxPropView) + data. + + BUGFIX: New FPGA file (version 76) added to driver. This fixes problems when (mvBlueFOX-lib) + working with single image requests(always just a single request in + the input queue) that could cause in capture errors. + +28.01.2009 1.10.57 + DEPRECATED API CODE: 'rrCameraUserAOINotSupported', (mvDriverBaseEnums.h) + 'rrScanStandardNotSupported' and 'rrScanRateInvalid'. Check for + DMR_CAMERA_DESCRIPTION_INVALID_PARAMETER as a result of calling the + 'imageRequestSingle' function instead. + 'bwbrErrorToDark': Use 'bwbrErrorTooDark' instead. + 'bwbrErrorToBright': Use 'bwbrErrorTooBright' instead. These are + spelling mistakes. Deprecated constants will be removed in future + versions of the interface. This will not break existing binaries + but will force you to change your code we re-build applications. + + CHANGED BEHAVIOUR: Color format conversion from Camera format RGB888packed (mvHYPERIONfg-lib) + to destination color format RGBx888packed now calculated in FPGA. + + UPDATE: Firmware version 1.01.10 for mvBlueCOUGAR-S devices 120, 121 and 123 (all shipped packages for GigE Vision devices) + Rev. 1(mono versions) added to setup. This improves the frame rate in + single shot mode, fixes problems with cameras that have been assigned + a persistent IP, that are connected to power before the host systems + network interface card is up and fixes an issue when accessing the + min. value of ExposureTimeAbs. + + UPDATE: Error detection when calling DMR_ImageRequestSingle or (all shipped packages) + FunctionInterface::imageRequestSingle improved. + + UPDATE: New version of the filter driver added. This version contains enhanced (mvGigECapture.sys, version 1.0.12.13) + debugging options. + + BUGFIX: TDeviceEventType::detAll correctly specifies ALL event event types (mvDriverBaseEnums.h) + again. + (Bug introduced in version 1.10.55) + + BUGFIX: Several minor issues that caused the initialisation of a device to (mvBlueCOUGAR-lib) + fail. This could occur whenever a device has been detected by the (mvTLIClientGigE-lib) + device manager, was then power cycled and afterwards the user tried + to initialise it. + + BUGFIX: In case no capture buffer could be allocated because of the system (mvBlueCOUGARLocal-lib) + being short on memory requesting an image could lead to crashes. + + BUGFIX: Sometimes the max. value of 'RequestCount' was by 1 larger than there (mvBlueCOUGARLocal-lib) + is frame buffer. + + BUGFIX: Certain sets of parameters could result in an unprocessible request (mvBlueCOUGAR-lib) + that because of an internal problem could result in a deadlock. + + BUGFIX: The calculation of the dark current correction image (through the (all shipped packages) + 'Calibrate' mode operated on partly uninitialsed memory. This could + lead to incorrect correction images. When updating the driver also + the calibration must be performed again to get rid of the problem. + + BUGFIX: When changing the video channel for an M7 it was possible that the (mvBlueCOUGAR-lib) + sensor switched to was not completely updated. + (Bug introduced in version 1.10.56) + +19.01.2009 1.10.56 + CHANGED BEHAVIOUR: Properties 'BinningMode' and 'TestMode' will always be (mvBlueCOUGAR-lib) + available for mvBlueLYNX-M7 and mvBlueCOUGAR devices. However as not (mvBlueCOUGARLocal-lib) + every device supports these features, some devices will only allow + to set these properties to 'Off'. This has been done for compatibility + reasons only. + + NEW FEATURE: Binning added to mvBlueLYNX-M7 devices. So far no all sensors (mvBlueCOUGAR-lib) + support this feature. This requires a firmware update. (mvBlueCOUGARLocal-lib) + + UPDATE: Settings that have been exported with a locale that stores floating (mvPropHandling-lib) + point values with a separating ',' instead of a '.' can be imported + again. + + UPDATE: Firmware version 1.00.23 for all mvBlueCOUGAR-S devices 120, 121 and (all shipped packages for GigE Vision devices) + 123 added to setup. This improves the frame rate in single shot mode + and fixes an issue when accessing the min. value of ExposureTimeAbs. + + BUGFIX: devices, that support more than 1 trigger mode in advanced trigger (mvBlueCOUGAR-lib) + interface did not correctly update all device registers, when switching + back to the standard trigger interface. + +15.01.2009 1.10.55 + NEW FEATURE: Support for sensor specific footer sizes added. (mvBlueCOUGARLocal-lib) + + NEW FEATURE: Property 'mvIMPACT::acquire::Device::interfaceLayout' published. (mvIMPACT_acquire.h) + + UPDATE: New version of the filter driver added. This version can return (mvGigECapture.sys, version 1.0.11.12) + statistical information. + + UPDATE: Firmware version 1.00.23 for mvBlueCOUGAR-S mono devices added to (all shipped packages for GigE Vision devices) + setup. This improves the frame rate in single shot mode and fixes + an issue when accessing the min. value of ExposureTimeAbs. + + UPDATE: The image DMA buffer will only be mapped and locked once. This (low level mvHYPERION driver, windows 1.0.33.35) + information are renewed only if the affected buffers are changed. + + BUGFIX: Bottom-half interrupt routine should be thread safe now. (low level mvHYPERION driver, windows 1.0.33.35) + (low level mvHYPERION2 driver, windows 2.0.3.3) + + BUGFIX: Trigge rmode availability corrected for mvHYPERION-CLe boards. (mvHYPERIONfg-lib) + + BUGFIX: mvBlueFOX-10x devices make use of the SDRAM as well. (mvBlueFOX-lib) + + BUGFIX: Socket API based transport layer did not correctly handle an image (mvTLIClientGigE-lib) + request timeout of 0. + + BUGFIX: Multi-byte mono pixel formats with zoom factors greater than 1 could (mvDisplay-lib) + cause crashes. + (Bug introduced in version 1.10.50) + +07.01.2009 1.10.54 + NEW FEATURE: Class mvIMPACT::acquire::EnumPropertyI64 can be compiled using (mvIMPACT_acquire.h) + Visual Studio 6 now. + + NEW FEATURE: Zooming can also be done by using the mouse wheel now. (wxPropView) + + NEW FEATURE: Property 'mvIMPACT::acquire::Request::imageFooter' published. (mvIMPACT_acquire.h) + + NEW FEATURE: 'Offset_pc' feature became available for mvBlueCOUGAR-P and (mvBlueCOUGAR-lib) + mvBlueLYNX-M7 devices. (mvBlueCOUGARLocal-lib) + + NEW FEATURE: Early version of a socket based transport layer that supports (mvTLIClientGigE-lib) + packet resend requests added. The transport layer parameters can be + accessed via the 'System/TLI/DataStream' list for testing. + + DEPRECATED API CODE: The functions ImageProcessing::defineFilterImageBuffer, (mvIMPACT_acquire.h) + ImageProcessing::queryFilterImageBuffer, DMR_GetFilterImageBuffer (mvDeviceManager-lib) + and DMR_SetFilterImageBuffer have been declared deprecated. Since + none of these functions ever did perform any useful task there is + no direct replacement. + + CHANGED BEHAVIOUR: Maximum number of request objects limited for the grabber (mvHYPERIONfg-lib) + boards CLf and CLm. + + BUGFIX: Function mvIMPACT::acquire::EnumPropertyI64::write did truncate the (mvIMPACT_acquire.h) + value to a 32-bit parameter. + + BUGFIX: Improved error handling for imageRequestSingle(). It is possible (mvHYPERIONfg-lib) + that the operating system cannot generate the DMA-address list for + the requested image buffer. This will no result in an appropriate + error message. + +17.12.2008 1.10.53 + CHANGED BEHAVIOUR: Now trigger controlled acquisition is available (mvHYPERIONfg-lib) + for Hyperion-CLf and CLm products (with some limitations). (low level mvHYPERION2 driver added, windows 2.0.0.0) + + CHANGED BEHAVIOUR: Only the trigger modes supported by the selected video (mvBlueCOUGARLocal-lib) + channel will be available now. + + NEW FEATURE: Noise histogram plot added. So far not all pixel formats are (wxPropView) + supported. + + NEW FEATURE: Full AOI mode added for image analysis plots. (wxPropView) + + NEW FEATURE: Draw window is selectable for pixel and noise histogram now. (wxPropView) + + UPDATE: New GenICam description file for mvBlueCOUGAR-S devices added(version 2.1.2). (mvBlueCOUGAR installer) + This will fix some small bugs. + +11.12.2008 1.10.52 + DEPRECATED API CODE: The class class mvIMPACT::acquire::ConnectorFrameGrabber (mvIMPACT_acquire.h) + and the function IOSubSystem::RTCCtrProgramCount have been declared + deprecated and will be removed in future version. Use + mvIMPACT::acquire::Connector and IOSubSystem::RTCtrProgramCount + instead. + + BUGFIX: Calling a read function of one of the classes derived from (mvIMPACT_acquire.h) + mvIMPACT::acquire::Property that accepts a reference to a vector + did raise an exception when the parameter 'start' differed from 0. + + BUGFIX: In case of a failed initialisation the driver could crash while (mvTITANfg-lib) + shutting down. (mvSIGMAfg-lib) + + BUGFIX: Tap sort filter did not re-arrange the pixel data for mvGAMMA-CL and (mvTITANfg-lib) + mvTITAN-CL boards. + (Bug introduced in version 1.10.20) + + BUGFIX: Requesting a buffer that doesn't fit into the memory accessible by the (mvTITANfg-lib) + could lead to states where further image acquisition was no longer (mvSIGMAfg-lib) + possible. + +08.12.2008 1.10.51 + BUGFIX: Programming the flash memory with mvHYPERION2 kernel driver was not (low level mvHYPERION2 driver, windows 2.0.1.1) + possible. + + CHANGED BEHAVIOUR: 'OBJ_GetSFormatted' and 'OBJ_GetSArrayFormatted' will (mvPropHandling-lib) + accept empty format strings now. This will result in the same behaviour (mvDeviceManager-lib) + as a NULL pointer. + +05.12.2008 1.10.50 + NEW FEATURE: 'DeviceReset' feature implemented for mvBlueCOUGAR-P and (FW/RFS 2.1.10) + mvBlueLYNX-M7 devices. This requires a firmware update. + IMPORTANT: Once devices have been updated, at least this version + (1.10.50) of the remote driver must be used! + + UPDATE: Some files needed to build wxPropView added to installer. (all shipped MSI based packages) + + UPDATE: When updating the firmware for mvBlueCOUGAR-S devices only firmware (mvDeviceConfigure) + files matching the HW revision can be selected now. + + UPDATE: Migration to version 1.1.1 of the GenApi runtime. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + + UPDATE: Misleading log message when executing a RW command in generic interface (mvBlueCOUGAR-lib) + mode. + + UPDATE: Register access no longer uses concatenation if not supported by the (mvTLIClientGigE-lib) + device. + + CHANGED BEHAVIOUR: mvHYPERION board variants CLf and CLm will now be (low level mvHYPERION driver, windows 1.0.32.34) + handled by a separate kernel mode driver 'mvHYPERION2'. This new kernel (low level mvHYPERION2 driver added, windows 2.0.0.0) + driver included as part of the driver package. This new kernel driver + offers a better support for 'full' CameraLink cameras. + + BUGFIX: Setting 'ImageRequestTimeout_ms' to 0 did not result in a never (mvTITANfg-lib) + elapsing time out but a buffer that immediately timed out if no (mvSIGMAfg-lib) + captured frame was available in the devices result queue. + + BUGFIX: Sometimes the heartbeat thread was running even if opening the device (mvBlueCOUGAR-lib) + failed. + + BUGFIX: Small memory leak, when opening the device failed. (mvBlueCOUGAR-lib) + + BUGFIX: In scaled mode only the rectangle currently visible was converted. (mvDisplay-lib) + (This only affected pixel formats not directly displayable like e.g. + RGB101010Packed) + + BUGFIX: Switching from zoomed to 'fit to screen' mode could result in only (wxPropView) + parts of the image being displayed. + +=== CD2008/B === + +19.11.2008 1.10.49 + NEW FEATURE: Firmware files for mvBlueCOUGAR-S Rev. 1 devices added to setups. (all shipped packages for GigE Vision devices) + + UPDATE: Slightly improved the algorithm that selects to optimal payload packet (mvTLIClientGigE-lib) + size for the streaming channel as this didn't work with all cameras + before. + UPDATE: Panel for controls on the right have a scroll bar now when needed (mvIPConfigure) + as the controls in the lower right section otherwise couldn't be + accessed with very low screen resolutions. + + BUGFIX: write image results to footer memory improved. (low level mvHYPERION driver, windows) + + BUGFIX: Memory manager mode 'Automatic' could lock up under certain conditions. (mvSIGMAfg-lib) + (Bug introduced in version 1.10.31) (mvTITANfg-lib) + +18.11.2008 1.10.48 + NEW FEATURE: class mvIMPACT::acquire::SystemBlueCOUGAR published. (mvIMPACT_acquire.h) + This class contains the acquisition mode property. + + UPDATE: using medium or full cameras, now phase error detect will be (low level mvHYPERION driver, windows) + checked. + + UPDATE: New GenICam description file for mvBlueCOUGAR-S devices added(version 2.1.1) (mvBlueCOUGAR installer) + This will fix some small bugs. + + UPDATE: Firmware version 1.00.22 for mvBlueCOUGAR-S devices added to setup. (all shipped packages for GigE Vision devices) + This update will reduce the time needed to start the streaming of + on the device by 50%. + + BUGFIX: Float properties are only created as spin controls if they define (wxPropView) + a step width now. + +14.11.2008 1.10.47 + NEW FEATURE: Interrupt enable added for mvHYPERION-CLf and mvHYPERION-CLm (low level mvHYPERION driver, windows) + on Windows XP. + + NEW FEATURE: class mvIMPACT::acquire::CameraSettingsVirtualDevice added. (mvIMPACT_acquire.h) + + UPDATE: Source code for wxWidgets version of PropView added to MSI based (all shipped MSI based packages) + installer. + + CHANGED BEHAVIOUR: serial communication temporarily controlled with a timer. (low level mvHYPERION driver, windows) + + CHANGED BEHAVIOUR: Property 'FrameDelay_ms' became a pure integer property. (mvVirtualDevice-lib) + + BUGFIX: Serial port 1 will be configured correctly now. (low level mvHYPERION driver, windows) + +13.11.2008 1.10.46 + NEW FEATURE: Initial version that supports multiple parallel data streams. (mvBlueCOUGAR-lib) + The mvBlueLYNX-M7 can now transfer to streams in parallel, however + this will need a FW update. + + UPDATE: Splitter added to allow usage with screen resolutions of 1024 by (mvIPConfigure) + 768 and smaller. + + CHANGED BEHAVIOUR: Most methods in generic mode and some belonging to the (mvBlueCOUGAR-lib) + transport layer no longer require parameters. The parameters needed + in previous releases are now available as global properties in the + System list. These new properties are 'MethodPollingInterval_ms' and + 'MethodPollingMaxRetryCount'. + + CHANGED BEHAVIOUR: Certain features reserved for internal use will no longer (mvBlueCOUGAR-lib) + be created as mvIMPACT Acquire properties or methods. + Currently this will affect 'AcquisitionStart', 'AcquisitionStop' and + 'GevCCP'. + + UPDATE: Manual and firmware files for mvBlueLYNX-M7 devices added to setup. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + + UPDATE: The property 'VideoChannel' as part of the request infos will be (all shipped packages) + supported by every device driver now. Devices that don't support + multiple video channels will always return 0. + + BUGFIX: mvBlueFOX-2xx devices make use of the SDRAM as well. (mvBlueFOX-lib) + + BUGFIX: All mvBlueFOX-2xx devices use the same Bayer pattern as the existing (mvBlueFOX-lib) + mvBlueFOX-1xx devices. + + BUGFIX: Gain_dB is returned correctly as part of the request info now. (mvBlueCOUGARLocal-lib) + + BUGFIX: When the current image width was larger than the size of the display (wxPropView) + area and the height of the image was smaller, no image was displayed. + + BUGFIX: In generic mode the feature 'AcquisitionMode' is no longer registered (mvBlueCOUGAR-lib) + in the systems list. + + BUGFIX: Message channel was not closed when closing the device. (mvTLIClientGigE-lib) + +27.10.2008 1.10.45 + UPDATE: The signed versions of the mvDELTA/mvSIGMA and the mvGAMMA/mvTITAN (mvTITAN_mvGAMMA.msi) + drivers that have been introduced with version 1.10.25 of this SDK (mvDELTA_mvSIGMA.msi) + have been removed again as systems running an old unsigned version + of any of these packages can't be cleaned up completely. This in a + worst case could lead to a state where the device driver was not + working at all. Signed versions of these packages will be available + on request, but can't be installed on a system that had an unsigned + version installed in the past. + + BUGFIX: Unscaled display with scrollbars: Scrolling down did move the image (wxPropView) + in upper direction and vice versa. + +24.10.2008 1.10.44 + UPDATE: Some internal and some documentation related issues. First auto build + local packages for mvBlueLYNX-M7 devices. + +22.10.2008 1.10.43 + BUGFIX: Parallel acquisition improved. (low level mvHYPERION driver, windows) + + NEW FEATURE: Property 'DigitalInputThreshold_mV' added for mvBlueLYNX-M7 (mvBlueCOUGAR-lib) + devices. + + NEW FEATURE: Property 'DigitalInputThreshold_mV' published in C++ interface. (mvIMPACT_acquire.h) + + BUGFIX: mvBlueFOX-205 types used a wrong device type and thus appeared as (mvBlueFOX-lib) + mvBlueFOX-M205 types and claimed to have 4 instead of 2 digital + outputs. + + BUGFIX: Digital input properties no longer specify the 'cfWriteAccess' flag (mvBlueCOUGAR-lib) + if no local application is connected. (mvBlueCOUGARLocal-lib) + (Bug introduced in version 1.10.36) + +20.10.2008 1.10.42 + BUGFIX: With a missing sensor head 0 the device can still be initialised. (mvBlueCOUGARLocal-lib) + Check the property 'DeviceStatus' or 'DeviceStatusString' for + information about the device state. + + BUGFIX: Local mvIMPACT lic related problem fixed. (mvBlueCOUGARLocal-lib) + (Bug introduced in version 1.10.36) + + NEW FEATURE: mvBlueLYNX-M7 devices can be accessed and configured via the (mvBlueCOUGAR-lib) + on board WLAN interface now. + +24.09.2008 1.10.41 + BUGFIX: Switching input channel. Not all needed properties have been set (mvHYPERIONfg-lib) + correctly if switching the input channel. + + BUGFIX: InitExternalListAccess exception during init(only visible in log files) (mvSIGMAfg-lib) + (Bug introduced in version 1.10.33) + + BUGFIX: Closing a GigE Vision device did no longer destroy the data streams (mvBlueCOUGAR-lib) + of other GigE Vision devices running in the same process. (mvTLIClientGigE-lib) + + BUGFIX: When using the generic interface layout when working with non-MATRIX (mvBlueCOUGAR-lib) + VISION devices certain interconnections within the XML file belonging + to the device in connection with float features could lead to crashes. + +22.09.2008 1.10.40 + BUGFIX: Configuring a device to use a persistent IP address is working again. (mvIPConfigure) + + BUGFIX: Flash signal output in 'GlobalResetRelease' shutter mode for (mvBlueFOX-lib) + mvBlueFOX-105 devices. + +17.09.2008 1.10.39 + NEW FEATURE: Image buffers no longer need 4 byte alignment in order to be (mvDisplay-lib) + displayed correctly. + + NEW FEATURE: Property 'divider' added to class 'PulseStartConfiguration'. (mvIMPACT_acquire.h) + + CHANGED BEHAVIOUR: AOI step width reduced from 4 to 1. (mvVirtualDevice-lib) + + BUGFIX: If the filter driver was not installed the application did not (mvGigEConfigure) + terminate automatically during silent uninstall. + + BUGFIX: Potential crash in the rare case of cancelling a request that also (mvGigECapture.sys, version 1.0.9.10) + just timed out. + +15.09.2008 1.10.38 + NEW FEATURE: 'customDataDirectory' property published in class 'Device' (all shipped packages) + + NEW FEATURE: Class mvIMPACT::acquire::InfoBlueCOUGAR added to interface. (mvIMPACT_acquire.h) + + CHANGED BEHAVIOUR: Timestamps will now be created in kernel mode to improve (mvBlueCOUGARLocal-lib) + precision. + (Requires RFS update) + + NEW FEATURE: property 'ClientConnectionState' added to 'Info -> Camera' and (mvBlueCOUGARLocal-lib) + class mvIMPACT::acquire::InfoBlueCOUGAR. (mvBlueCOUGAR-lib) + (mvIMPACT_acquire.h) + + BUGFIX: Properties under 'Info' will be updated correctly again. (mvBlueCOUGARLocal-lib) + +11.09.2008 1.10.37 + NEW FEATURE: If supported by the device, the optimal packet size for the (mvBlueCOUGAR-lib) + current transmission channel is determined automatically during (mvTLIClientGigE-lib) + device init. To disabled this feature set the property + 'AutoNegotiatePacketSize' in the device list to 'No'. + This feature requires at least firmware version 2.0.0 for + mvBlueCOUGAR-P and mvBlueLYNX-M7 devices and version 1.00.20 for + mvBlueCOUGAR-S devices. + + NEW FEATURE: All mvBlueFOX-M1xx devices and mvBlueFOX-2xx devices have 8 MB (mvBlueFOX-lib) + of usable local memory now. This might require a firmware update. + + UPDATE: Firmware version 1.00.20 for mvBlueCOUGAR-S devices added to setup. (all shipped packages for GigE Vision devices) + This fixes an issue during the auto negotiation of the package + size and an issue where several devices in a zero config network + couldn't obtain correct IP addresses. + + DEPRECATED API CODE: DEV_REQUEST_CANT_UNLOCKED (use (mvDriverBaseEnums.h) + DEV_REQUEST_CANT_BE_UNLOCKED instead), rrSnapAborted (use + rrRequestAborted instead). + Deprecated constants will be removed in future versions of the + interface. This will not break existing binaries but will force you + to change your code we re-build applications. + + BUGFIX: Detection of changed pixelPerCycle settings improved (mvHYPERIONfg-lib) + + BUGFIX: Timestamps will now be reported correctly. (mvSIGMAfg-lib) + (mvTITANfg-lib) + + BUGFIX: If imageRequestReset was called during a running image acquisition the (mvSIGMAfg-lib) + the current frame was returned with rrTimeout instead of (mvTITANfg-lib) + rrRequestAborted. + + BUGFIX: Calling 'imageRequestReset' while active image requests are processed (mvBlueCOUGAR-lib) + by the driver could cause long delays of up to 10 seconds. + +08.09.2008 1.10.36 + UPDATE: Slightly improved digital I/O access. (mvBlueFOX-lib) + + UPDATE: New GenICam File (2.1.0) for mvBlueCOUGAR-S devices added to setup. (all shipped packages for GigE Vision devices) + + CHANGED BEHAVIOUR: Features used by a local application running on the (mvBlueCOUGAR-lib) + mvBlueCOUGAR-P or mvBlueLYNX-M7 will be locked for the client now. + + BUGFIX: Sometimes images were triggered when enabling an external trigger (mvBlueFOX-lib) + mode or a HRTC program even if there was no external or + HRTC generated signal for mvBlueFOX-102aG devices. + + BUGFIX: Some small license related problems. (mvBlueFOX-lib) + + BUGFIX: Potential deadlock when closing a connection to an mvBlueCOUGAR-P or (mvBlueCOUGAR-lib) + mvBlueLYNX-M7 device that has been disconnected while just updating + some of the device info properties. + +01.09.2008 1.10.35 + UPDATE: Memory management of capture buffers improved for mvBlueCOUGAR-P (mvBlueCOUGAR-lib) + and mvBlueLYNX-M7 devices. + + UPDATE: Slight performance increase in buffer info handling. (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + + UPDATE: Firmware version 1.00.17 for mvBlueCOUGAR-S devices added to setup. (all shipped packages for GigE Vision devices) + ForceIP command is correctly acknowledged now and the DeviceUserID + is correctly written to non-volatile memory now. + + CHANGED BEHAVIOUR: Only update files with a name that exactly matches the (mvDeviceConfigure) + requirements can be selected for mvBlueCOUGAR and mvBlueLYNX-M7 + devices now. + + BUGFIX: Passing a timeout value of 0 to the property 'ImageRequestTimeout_ms' (mvTLIClientGigE-lib) + now results in a timeout, that never elapses. (mvGigECapture.sys, version 1.0.8.9) + + BUGFIX: Potential deadlock when calling imageRequestReset in a triggered (mvBlueCOUGAR-lib) + application with no trigger signal present. + + BUGFIX: Interface count is displayed correctly now. (mvIPConfigure) + + BUGFIX: Error handling during file upload for mvBlueCOUGAR-P and mvBlueLYNX-M7 (mvBlueCOUGAR-lib) + devices. + + BUGFIX: Devices with an old FW (<1.0009) and a new description file can be (mvBlueCOUGAR-lib) + initialised for update now. + + BUGFIX: AOIs in zoom mode where not displayed at the correct('real') position. (wxPropView) + + BUGFIX: TLIMV_ForceIP could crash when the adapter receiving the ack from the (mvTLIClientGigE-lib) + device had an index higher than the number of adapters used to send + the command. + +28.08.2008 1.10.34 + NEW FEATURE: New plots for 'frame ID', 'frame ID difference', (wxPropView) + 'gain in milli dB' and line counter added. + + BUGFIX: OS handle leak in filter based driver(Windows only, one handle per (mvTLIClientGigE-lib) + frame). + + BUGFIX: Some request info properties haven't been updated correctly. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.10.31) + + UPDATE: Firmware and description files for mvBlueCOUGAR and mvBlueLYNX-M7 (mvBlueCOUGAR-1.10.34.112.tar.gz) + devices added to Linux version of the remote driver. + +26.08.2008 1.10.33 + NEW BEHAVIOUR: When explicitly asking for the destination format (mvBlueCOUGAR-lib) + ibdfRGB888Packed mvBlueCOUGAR-S devices will directly transmit RGB + image data. This requires more network bandwidth, but saves CPU time. + + NEW BEHAVIOUR: XML log files can no longer be viewed if the viewer expects (all shipped packages) + valid XML as an input but results in valid XML files when the + drivers are closed correctly even if several devices write to the + same log file. + + NEW FEATURE: Support for devices with multiple network interfaces added. (mvIPConfigure) + + NEW FEATURE: Pixel clock speeds 6000, 8000, 10000 and 12000 MHz added for (mvBlueFOX-lib) + mvBlueFOX-105 and mvBlueFOX-102aG devices. + + NEW FEATURE: Configuration support for devices with multiple interfaces added. (mvIPConfigure) + (mvTLIClientGigE-lib) + + UPDATE: Firmware version 1.00.15 for mvBlueCOUGAR-S devices added to setup. (mvBlueCOUGAR.msi) + Fixes problems during FW update. (mvBlueCOUGAR-x64.msi) + + BUGFIX: Automatic and Pool based memory modes work correctly again. (mvTITANfg-lib) + (Bug introduced in version 1.10.31) (mvSIGMAfg-lib) + (mvBlueCOUGARLocal-lib) + +22.08.2008 1.10.32 + NEW FEATURE: Initial version of mvIPConfigure added. (all shipped mvBlueCOUGAR related driver packages) + + NEW FEATURE: Info plot added to wxPropView. (wxPropView) + + NEW FEATURE: Average pixel values added to histogram output. (wxPropView) + + NEW FEATURE: Zoom added to image display window. (wxPropView) + Usage: Click in the image display area and press '+' or '-'. + Active when 'Scale' feature is not 'checked' only! + + NEW FEATURE: Properties (all shipped packages) + 'mvIMPACT::acquire::Statistics::abortedRequestsCount' + and 'mvIMPACT::acquire::Statistics::timedOutRequestsCount' + published. + + NEW FEATURE: Properties (all shipped mvBlueCOUGAR related driver packages) + 'mvIMPACT::acquire::StatisticsBlueCOUGAR::framesIncompleteCount' + and 'mvIMPACT::acquire::StatisticsBlueCOUGAR::missingDataAverage_pc' + published. + + NEW FEATURE: Initial version of Linux (socket based) version of the GigE Vision (mvTLIClientGigE-lib) + device client driver. + + NEW BEHAVIOUR: The host driver uses dynamic ports for the control channel (mvTLIClientGigE-lib) + now. Thus each device will communicate with a different host port from + now on. + + BUGFIX: Some small GUI layout related bugs fixed (List control column width) (mvDeviceConfigure) + + BUGFIX: Default stream ports are created dynamically by the system now to (mvTLIClientGigE-lib) + avoid potential port collisions when working with multiple devices + in multiple processes. + + BUGFIX: Crashes when writing an invalid or unsupported GevCCP value to the (mvTLIClientGigE-lib) + device. + + BUGFIX: Default message ports are created dynamically by the system now to (mvTLIClientGigE-lib) + avoid potential port collisions when working with multiple devices + in multiple processes. The TLI now gets notified when the message + channel related parameters are changed by the user. + + BUGFIX: Generic GigE Vision devices can be initialised again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.10.30) + + BUGFIX: Timestamp_us in the request info is correct now. (mvVirtualDevice-lib) + +14.08.2008 1.10.31 + NEW FEATURE: error handling improved. Now driver can also detect DMA-FIFO (low level mvHYPERION driver, windows) + overrun errors. + + NEW FEATURE: digital inputs/outputs and connector capability depends on (mvHYPERIONfg-lib) + board variants. Not all mvHYPERION boards support same connectors. + + NEW FEATURE: Property 'mvIMPACT::acquire::Request::imageMemoryMode' published. (mvIMPACT_acquire.h) + + NEW FEATURE: Property 'mvIMPACT::acquire::Request::imageFooterSize' published. (mvIMPACT_acquire.h) + + NEW FEATURE: Function + 'mvIMPACT::acquire::FunctionInterface::imageRequestConfigure' published. (mvIMPACT_acquire.h) + + NEW FEATURE: It's possible to capture directly into user supplied memory now. (all shipped packages) + + NEW FEATURE: Property 'mvIMPACT::acquire::ImageRequestControl::requestToUse' (mvIMPACT_acquire.h) + published. This will allow to define the request object that shall be + be used for the next acquisition. This feature might be interesting + when directly capturing into user supplied memory. + + NEW FEATURE: min, max, step width and default value can be assigned as a string (mvPropHandling-lib) + now if a translation dictionary has been defined before. + + NEW SAMPLE: CaptureToUserMemory (all shipped MSI based packages) + + UPDATE: Optimized firmware programming for mvHYPERION boards. (mvDeviceConfigure) + + UPDATE: Support for mvHYPERION board variants CLm and CLb added. (mvHYPERIONfg-lib) + + CHANGED BEHAVIOUR: EnumHyperion(), If board type is programmed without (mvHYPERIONfg-lib) + the family name ("mvHYPERION") then this family name will be added + to board type string to report consistent board types. + + CHANGED BEHAVIOUR: Property 'AcquisitionMode' moved from ImagingSubSystem (mvBlueCOUGAR-lib) + into 'SystemSettings'. + + BUGFIX: Trigger related settings have not always been stored correctly (mvBlueCOUGAR-lib) + resulting in an incorrect trigger mode after restoring a setting. + Settings stored with older version of the driver should be deleted. + + BUGFIX: Only with application mvDeviceConfigure, if two mvHYPERIONS are (mvHYPERIONfg-lib) + present always mvHYPERION0 will be opened. + + BUGFIX: Functions OBJ_SetP and mvIMPACT::acquire::PropertyPtr::write are (mvDeviceManager-lib) + working now. + + BUGFIX: Crashes with AOI width of 16 for mvBlueFOX-105 types. (mvBlueFOX-lib) + +04.08.2008 1.10.30 + NEW FEATURE: Property 'CaptureBufferAlignment' added to C++ interface. (mvIMPACT_acquire.h) + + DEPRECATED API CODE: mvIMPACT::acquire::Request::getParamS and (mvIMPACT_acquire.h) + mvIMPACT::acquire::Request::getImageBuffer have been declared + deprecated. The information of the structures is available via + direct property access now, which is more flexible and more + efficient. + + BUGFIX: description files, that haven't been 4 byte aligned can be downloaded (mvBlueCOUGAR-lib) + from the device again. + (Bug introduced in version 1.10.29) + +01.08.2008 1.10.29 + NEW FEATURE: Direct access to HRTC's added for advanced control of (mvHYPERIONfg-lib) + digital inputs and outputs(e.g. incremental encoder). + + NEW FEATURE: Property 'shutterMode' for mvBlueFOX devices added to C++ (mvIMPACT_acquire.h) + interface. + + NEW FEATURE: HRTC support added for mvBlueCOUGAR-P and mvBlueLYNX-M7 devices (mvBlueCOUGAR-lib) + This also requires a firmware update. (mvBlueCOUGARLocal-lib) + + NEW FEATURE: Property 'DigitalInputThreshold_mV' added for mvBlueLYNX-M7 (mvBlueCOUGARLocal-lib) + devices. + + UPDATE: Reliability and update speed improved when filter driver is active. (mvTLIClientGigE-lib) + (mvGigECapture.sys, version 1.0.6.7) + + UPDATE: Firmware version 1.00.14 for mvBlueCOUGAR-S devices added to setup (mvBlueCOUGAR.msi) + The behaviour regarding IP configuration is the same for (mvBlueCOUGAR-x64.msi) + mvBlueCOUGAR-S and mvBlueCOUGAR-P now. Update to FW 1.00.14 is required + for mvBlueCOUGAR-S devices. After a power cycle the mvBlueCOUGAR-S + devices will boot faster. + + UPDATE: mvBlueFOX-M105G/C is also working with mvBlueFOX.sys (old version of (mvBlueFOX-lib) + the kernel driver). + + UPDATE: Complete revision of internal buffer handling. (all shipped packages) + + BUGFIX: Potential crashes when initialising two or more devices belonging (all shipped packages) + to at least two different device families in parallel(e.g. each + device in its own thread). + + BUGFIX: Pool mode of the memory manager is working again. (mvTITANfg-lib) + (mvSIGMAfg-lib) + + BUGFIX: Update of muxdata corrected, only mvHYPERION-clf affected. (low level mvHYPERION wdm driver) + + BUGFIX: mvBlueFOX-M105G/C triggerOnLow and (color-)binning mode. (mvBlueFOX-lib) + + BUGFIX: Manual download of description file was only working after the device (mvBlueCOUGAR-lib) + has been initialised. + (Bug introduced in version 1.10.20) + + BUGFIX: Loading of stored filter parameters for 'defective pixel (mvTITANfg-lib) + filter', 'Flat field filter' and 'Dark current filter' fixed. (mvSIGMAfg-lib) + (mvHYPERIONfg-lib) + (mvVirtualDevice-lib) + +=== CD2008/A === + +23.07.2008 1.10.28 + BUGFIX: Potential deadlock when calling 'imageRequestReset' during a pending (mvBlueFOX-lib) + sensor update. + + NEW FEATURE: message signalled interrupt added. This newer interrupt handling (low level mvHYPERION wdm driver) + must be enabled for using mvHYPERION boards clf under Vista and newer + windows version. Linux drivers are not affected. + + BUGFIX: Sometimes acquisition produces a dead_lock. This problem is related (low level mvHYPERION Linux driver) + to the request_queues in the kernel_module while accessing spin_locks + from user mode via read function and from interrupt context. Now + spin_lock functions replaced with spin_lock_irqsave variants. + + BUGFIX: The digital outputs can be controlled using the local interface again. (mvBlueCOUGARLocal-lib) + + BUGFIX: Component::isDefault and OBJ_IsDefault did not always return correct (mvPropHandling-lib) + results. + + UPDATE: Firmware version 1.00.13 for mvBlueCOUGAR-S devices added to setup. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + +18.07.2008 1.10.27 + BUGFIX: Reliability improved, when using multiple devices in one process. (mvBlueFOX-lib) + + CHANGED BEHAVIOUR: A wider range of request results is returned now. (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + + BUGFIX: Automatic pixel format estimation was not always correct. (mvBlueCOUGAR-lib) + + BUGFIX: 'SensorColorPattern' was not always set correctly. (mvBlueCOUGAR-lib) + + BUGFIX: mvIMPACT Acquire compliant user mode library was missing in installer (mvTITAN_mvGAMMA.msi) + database. (mvDELTA_mvSIGMA.msi) + (Bug introduced in version 1.10.25) + +16.07.2008 1.10.26 + BUGFIX: Creating an instance of a class derived from (mvIMPACT_acquire.h) + 'mvIMPACT::acquire::Statistics' could raise an exception. + + BUGFIX: Calling 'restoreDefault' for and instance of (mvIMPACT_acquire.h) + 'mvIMPACT::acquire::SystemSettings' did raise an exception + + CHANGED BEHAVIOUR: mvBlueCOGAR-SxxxG devices will transfer ibpfMono8 unless (mvBlueCOUGAR-lib) + another pixel format is explicitly selected by the user. + + BUGFIX: Changing the trigger or the exposure mode did not always result in a (mvBlueCOUGAR-lib) + consistent deivce update. + +15.07.2008 1.10.25 + UPDATE: Adapter and device info will be logged now. (mvTLIClientGigE-lib) + + UPDATE: Abort speed improved. (mvBlueFOX-lib) + + UPDATE: Firmware version 1.00.12 for mvBlueCOUGAR-S devices added to setup. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + + NEW FEATURE: The MSI based installers for mvDELTA/mvSIGMA and mvTITAN/mvGAMMA (mvTITAN_mvGAMMA.msi) + devices will use the signed version of the kernel mode driver under (mvDELTA_mvSIGMA.msi) + Windows now. Please note that these drivers can't be installed on + a system that has unsigned driver versions installed. Unsigned driver + packages must be removed from the system manually and no unsigned + version should be installed after a signed version has been installed + on the system. + + NEW FEATURE: 'Offset_pc' feature became available for mvBlueCOUGAR-S devices. (mvBlueCOUGAR-lib) + + NEW FEATURE: 'Sharpness' feature became available for mvBlueCOUGAR-S devices. (mvBlueCOUGAR-lib) + + BUGFIX: Certain trigger mode changes in the device specific interface did not (mvBlueCOUGAR-lib) + correctly update the device (old mode was used e.g. when changing from + ctmOnHighExpose to ctmOnRisingEdge. + + BUGFIX: Some missing visibility callbacks for AGC/AEC added. (mvBlueCOUGAR-lib) + + BUGFIX: supported 'non-CameraLink' devices can be initialised again. (mvTITANfg-lib) + (Bug introduced in version 1.10.20) + +11.07.2008 1.10.24 + NEW FEATURE: DMA-Buffer handling improved. Previous versions call alloc/free (mvHYPERIONfg-lib) + for each request. Now only dma_buffer will be reallocated if a size + is increased through other aoi data. + + BUGFIX: Certain parameters in the device specific interface haven't always (mvBlueCOUGAR-lib) + been set correctly directly after opening the device. + + BUGFIX: wxPropView could crash if the image display was switched on before (wxPropView) + at least one image had been captured. (Windows only) + +08.07.2008 1.10.23 + BUGFIX: The zipped version of the mvBlueCOUGAR-S XML file is installed now (mvBlueCOUGAR.msi) + instead of the unzipped one. (mvBlueCOUGAR-x64.msi) + (Bug introduced in version 1.10.22) + + UPDATE: The socket based transport layer achieves a slightly better (mvTLIClientGigE-lib) + performance now and device updates work much faster now. + + BUGFIX: The socket based transport layer did not correctly handle changed (mvTLIClientGigE-lib) + destination port and changed packet size. + +07.07.2008 1.10.22 + BUGFIX: Small memory leak when opening a device with a zipped XML file. (mvBlueCOUGAR-lib) + + BUGFIX: When a network interface disappeared at runtime (when a device has (mvBlueCOUGAR-lib) + been disconnected from a peer-to-peer conection a consecutive call + to DMR_UpdateDeviceList caused a deadlock. + + NEW FEATURE: Trigger modes ctmOnRisingEdge, ctmOnFallingEdge, ctmOnHighExpose (mvBlueCOUGAR-lib) + and ctmOnLowExpose implemented for mvBlueCOUGAR-S devices. + (Requires at least FW version 1.00.11, driver will no longer support + devices with a smaller firmware version) + + NEW FEATURE: Flash signal output and VD signal output implemented for (mvBlueCOUGAR-lib) + mvBlueCOUGAR-S devices. + (Requires at least FW version 1.00.11, driver will no longer fully + support devices with a smaller firmware version) + + UPDATE: Firmware version 1.00.11 for mvBlueCOUGAR-S devices added to setup. (mvBlueCOUGAR.msi) + (mvBlueCOUGAR-x64.msi) + +03.07.2008 1.10.21 + BUGFIX: Timestamps will be correct even without 'GevTimestampTickFrequency' (mvBlueCOUGAR-lib) + being defined in the description file. + + UPDATE: Improved thread savetiness. (mvBlueFOX-lib) + + BUGFIX: ContinuousCaptureToAVI sample will work with mvBlueCOUGAR device as (mvBlueCOUGAR-lib) + well now. (ContinuousCaptureToAVI.cpp) + +26.06.2008 1.10.20 + NEW FEATURE: mvIMPACT::acquire::FunctionInterface::createSetting can return (mvIMPACT_acquire.h) + the ComponentList to the newly created setting now. + + BUGFIX: The constructor of the class CameraSettingsFrameGrabber no longer (mvIMPACT_acquire.h) + raises an exception when the device using it does not support the + 'TriggerControls' list. + (Bug introduced in version 1.10.17) + + BUGFIX: mvIMPACT Lic check could fail because of some misaligned internal (mvDeviceManager-lib) + structures. + + BUGFIX: Generic interface will work with devices that only define the (mvBlueCOUGAR-lib) + the mandatory GenICam features in their description file. (mvTLIClientGigE-lib) + + BUGFIX: Default de-mosaicing for rolor sensors attached to mvBlueLYNX-M7 (mvBlueCOUGAR-lib) + devices. + + UPDATE: Init speed improved. (mvBlueFOX-lib) + + UPDATE: Firmware update files for mvBlueCOUGAR-S devices added to installer. (mvBlueCOUGAR.msi) + (version 1.0010) (mvBlueCOUGAR-x64.msi) + +17.06.2008 1.10.19 + UPDATE: The filter driver works with devices that send larger packets than (mvGigECapture.sys, version 1.0.4.5) + promised by the SCPS register and with devices that send the last + packet of a block larger than necessary now. + + BUGFIX: The property 'FWVersion' contains the correct version info for (mvTLIClientGigE-lib) + mvBlueCOUGAR-S devices now. (mvBlueCOUGAR-lib) + (Requires at least FW version 1.0007) + + BUGFIX: During property update the current value was written before setting (mvBlueCOUGAR-lib) + the new limits. This could cause an internal exception as the current + value e.g. could be larger than the old max. value. + (This applies to the generic interface layout only) + +10.06.2008 1.10.18 + UPDATE: Additional trigger input signals added, software trigger enabled (mvHYPERIONfg-lib) + + CHANGED BEHAVIOUR: Trigger signal PulseStartConfiguration currently (mvHYPERIONfg-lib) + removed from signal list. + + NEW FEATURE: Trigger signal controlled acquisition added for Linux driver (low level mvHYPERION Linux driver) + + BUGFIX: Sometimes the first image capture by the GigE Kernel mode capture (mvTLIClientGigE-lib) + filter was incomplete. + + BUGFIX: Digital outputs 2 and 3 couldn't be modified in manual mode. (mvBlueCOUGARLocal-lib) + + NEW FEATURE: Support for 105 versions of the mvBlueFOX added. (mvBlueFOX-lib) + +29.05.2009 1.10.17 + NEW FEATURE: Trigger signal controlled acquisition added. (mvHYPERIONfg-lib) + + BUGFIX: Visibility of the features 'Expose_us' amd 'Gain_dB' depending on the (mvBlueCOUGAR-lib) + settings applied to 'AutoExposeControl', 'AutoGainControl' and (mvBlueFOX-lib) + 'ExposeMode'. + + BUGFIX: Re-programming the sensor caused aborted images after the first cycle. (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + + NEW FEATURE: Firmware update for mvBlueCOUGAR-S devices added. (mvBlueCOUGAR-lib) + (mvDeviceConfigure) + + NEW FEATURE: FrameRate_Hz feature added for mvBlueCOUGAR-S devices. (mvBlueCOUGAR-lib) + + NEW FEATURE: 'onHighExpose' and 'OnRisingEdge' trigger modes added for (mvBlueCOUGAR-lib) + mvBlueCOUGAR-S devices. + + NEW FEATURE: XML file upload published for mvBlueCOUGAR-S devices. (mvBlueCOUGAR-lib) + (mvDeviceConfigure) + + BUGFIX: Minor number confusion during initialising of more than one device. (low level mvHYPERION driver Linux) + +13.05.2008 1.10.16 + BUGFIX: Improved stability on Linux. (mvBlueFOX-lib) + + NEW FEATURE: 10 bit support added for all 'M' and 'X' types and for all (mvBlueFOX-lib) + CMOS based standard types. + +24.04.2008 1.10.15 + BUGFIX: ReadSerialData() Timeouthandling corrected (low level mvHYPERION Windows driver) + + NEW FEATURE: CameraLink line receiver reset added at device init. (low level mvHYPERION Windows driver) + PoCL feature enabled only with timer callbacks. + + BUGFIX: When multiple threads called functions accessing request object (mvDeviceManager-lib) + related data internal data structures could get damaged. + + BUGFIX: DMR_UpdateDeviceList reports newly detected GigE Vision devices (mvBlueCOUGAR-lib) + connected to a network interface that previously didn't have a valid + IP address. + + BUGFIX: Misleading log message, Support for RGB888Planar histogram and line (wxPropView) + profile. + + BUGFIX: Improved stability on Linux. (mvBlueFOX-lib) + + BUGFIX: 100% CPU load after opening a device under Kubuntu (Kernel 2.6.x). (mvBlueFOX-lib) + + CHANGED BEHAVIOUR: As on Linux we currently only support 16KB per USB (mvBlueFOX-lib) + transfer this is also the only valid value for the property + 'TransferSize' now. This might force you to modify existing + code for Linux projects. + + UPDATE: Re-programming mvBlueCOUGAR devices in 'device specific interface' (mvBlueCOUGAR-lib) + mode is much faster now. + + NEW FEATURE: BinningMode added to device specific interface. (mvBlueCOUGAR-lib) + + UPDATE: Check against matching RFS added. (mvBlueCOUGARLocal-lib) + + UPDATE: DMR_OpenDevice returns a larger variety of error codes now. (mvDeviceManager-lib) + +11.04.2008 1.10.14 + UPDATE: New version of firmware added to installer. (mvBlueCOUGAR.msi) + +08.04.2008 1.10.13 + BUGFIX: Unsafe close of mvHYPERION device because of wrong usage of an internal (mvHYPERIONfg-lib) + index. + + NEW FEATURE: Certain capture related parameters no longer turn read-only during (mvBlueCOUGAR-lib) + a running acquisition. + + NEW FEATURE: A local application running on the mvBlueCOUGAR-P can inform a (mvBlueCOUGAR-lib) + host application about parameter changes now. + (Requires a firmware update) + + +04.04.2008 1.10.12 + NEW FEATURE: mvHYPERION board CL4e added. (low level mvHYPERION drivers windows and Linux) + + CHANGED: serial communication now completely controlled with interrupts. (low level mvHYPERION Windows driver) + + NEW FEATURE: wxPropView can now store image data in raw format. (wxPropView) + + CHANGED BEHAVIOUR: All MSI based packages will now block attempts to downgrade (all shipped MSI based packages) + an installation. If this is desired please uninstall the newer + version before installing the old one. + + BUGFIX: Icons in maintenance mode will be displayed correctly(transparent) now. (all shipped MSI based packages) + + BUGFIX: Min., max. and step width of properties that change dynamically at (mvBlueCOUGAR-lib) + runtime are now correctly propagated up to the user interface. + + BUGFIX: AOI handling in device specific interface is working just like for (mvBlueCOUGAR-lib) + every other mvIMPACT Acquire compliant device now. + + BUGFIX: Crash when closing a device operated with the mvBlueCOUGAR-P specific (mvBlueCOUGAR-lib) + host interface during a running acquisition in 'Continuous' mode. + +28.03.2008 1.10.11 + BUGFIX: Missing 32 MHz enum added to 'TCameraPixelClock' enum (mvDriverBaseEnums.h) + + BUGFIX: Installation of mvTITAN/mvGAMMA devices via MSI is working correctly (mvTITAN_mvGAMMA.msi) + again. + (Bug introduced in version 1.10.10) + + UPDATE: Revision of the local interface. Higher frame rates can be achieved (mvBlueCOUGARLocal-lib) + now and support for the class mvIMPACT::acquire::ImageMemoryManager + has been added. + +14.03.2008 1.10.10 + BUGFIX: The device specific interface for mvBlueCOUGAR-P devices didn't (mvBlueCOUGAR-lib) + convert Bayer image data correctly. (mvTLIClientGigE-lib) + + CHANGED BEHAVIOUR: Some logging mechanisms changed. Now a common *.log file (mvBlueCOUGAR-lib) + is used. (mvTLIClientGigE-lib) + + BUGFIX: Power over CameraLink temporarily removed. (mvHYPERION low level Linux HW driver) + (mvHYPERION low level windows HW driver) + +06.03.2008 1.10.9 + BUGFIX: Medium camera support, synchronization of the medium channels (mvHYPERION low level Linux HW driver) + improved. + + BUGFIX: Power over CameraLink is working on Linux now. (mvHYPERION low level Linux HW driver) + + BUGFIX: Runtime crashes during process termination on Linux when more (all shipped packages) + than one driver lib was present. + + BUGFIX: The property 'pixelClock_KHz' is bound correctly in the C++ layer now. (mvBlueCOUGAR-lib) + +03.03.2008 1.10.8 + BUGFIX: CL comlibs (mvHYPERION and mvTITAN/mvGAMMA packages) + + BUGFIX: Resetting the trigger mode when closing and re-opening the device (mvSIGMA/mvDELTA low level HW driver) + +19.02.2008 1.10.7 + CHANGED BEHAVIOUR: The class mvIMPACT::acquire::AutoControlParametersBlueFOX (mvIMPACT_acquire.h) + has been renamed to mvIMPACT::acquire::AutoControlParameters and is + no available in the class mvIMPACT::acquire::CameraSettingsBlueDevice + thus is no longer restricted to the mvBlueFOX. This will + not break existing binaries, but might force you to change + your code during rebuilds when directed references to this class have + been used. + + CHANGED BEHAVIOUR: The properties autoExposeControl and autoGainControl have (mvIMPACT_acquire.h) + been moved to the base class from + mvIMPACT::acquire::CameraSettingsBlueFOX to + mvIMPACT::acquire::CameraSettingsBlueDevice. This will not affect + existing binaries or code. + + CHANGED BEHAVIOUR: Property 'exposeMode' moved to base class (mvIMPACT_acquire.h) + mvIMPACT::acquire::CameraSettingsBlueDevice. + + BUGFIX: The request count can be modified again. (all shipped packages) + (Bug introduced in version 1.10.6) + + BUGFIX: Calling the import, export and copy function of a camera description (mvDeviceManager-lib) + results in the desired behaviour now. + + NEW FEATURE: mvBlueFOX compatible overlapped expose mode implemented. (mvBlueCOUGAR-lib) + (Requires FW update to version 1.0.11) + + NEW FEATURE: CameraLink grabbers now can sort the pixel data if needed from (mvHYPERIONfg-lib) + multi-tap cameras if needed. (mvTITANfg-lib) + + BUGFIX: Closing the device is working correctly again. (mvHYPERIONfg-lib) + (Bug introduced in version 1.10.6) + +12.02.2008 1.10.6 + BUGFIX: mvDeviceConfigure no longer displays an error on startup when no (mvDeviceConfigure) + mvBlueCOUGAR driver is installed. + (Bug introduced in version 1.10.4) + + NEW BEHAVIOUR: mvHYPERION buffer alignment increased to 64k (mvHYPERIONfg-lib) + + NEW BEHAVIOUR: now mvHYPERION Linux kernel also support ppc64 systems (mvHYPERION low level HW driver) + + + BUGFIX: The correct version of the GigE Kernel mode capture filter is (mvBlueCOUGAR.msi) + installed again on Windows XP an newer. + (Bug introduced in version 1.10.5) + + BUGFIX: mvGigEConfigure is installing the capture filter driver correctly (mvGigEConfigure) + even it hasn't been installed previously using the the method offered + by the Windows OS. + + UPDATE: mvGigEConfigure is started from the MSI based installer and directly (mvBlueCOUGAR.msi) + installs the driver now. Installation process creates shortcuts to + mvGigEConfigure now. + + BUGFIX: Parallel installation of the MSM files of the mvIMPACT Acquire base (all shipped MSI based packages) + libs (mvIMPACT_AcquireBaseLibs.msm) could mess up the OS internal + component data base. This could happen, if installations for two + different product groups both installed the merge modules during the + installation process, which isn't done by default. + + NEW BEHAVIOUR: The environment variables MVIMPACT_ACQUIRE_DIR and GENICAM_ROOT (all shipped MSI based packages) + will now overwrite existing values while in previous installations + the new values where appended ';' separated to the existing values. + + BUGFIX: 'Flat Field Filter' and 'Dark Current Filter' could cause crashes, if (all shipped packages) + no settings have been loaded for the device and the calibration mode + was switched on in live mode. + + BUGFIX: Files that are not DWORD aligned can be downloaded now. (mvBlueCOUGAR-lib) + + NEW FEATURE: Soft AGC and AEC feature added to mvBlueCOUGAR-P specific (mvBlueCOUGAR-lib) + interface. + + BUGFIX: Correct numbering of mvSIGMA-SQ boards. (mvSIGMAfg-lib) + + BUGFIX: Correct handling of digital IOs of mvSIGMA boards. (mvSIGMAfg-lib) + + BUGFIX: Calling 'imageRequestReset' didn't unlock the current request, which (mvSIGMA/mvDELTA low level HW driver) + could result in a delay during the close that was equal to the value + of the property 'ImageRequestTimeout_ms' for that request. + + BUGFIX: Closing a board did not unlock the current request, which could result (mvSIGMAfg-lib) + in a delay during the close that was equal to the value of the (mvTITANfg-lib) + property 'ImageRequestTimeout_ms' for that request. + + BUGFIX: XML log files can be viewed at runtime an will always be valid XML. (all shipped packages) + + NEW FEATURE: Version info of the mvPropHandling lib is stored in a XML setting (mvPropHandling-lib) + in the top-level list now. + + NEW FEATURE: Update device list menu entry. (mvDeviceConfigure) + +24.01.2008 1.10.5 + NEW FEATURE: First version using the new version of the propgrid(1.2.11). (wxPropView) + + + NEW FEATURE: CameraSettingsBlueCOUGAR::triggerSource and (mvIMPACT_acquire.h) + CameraSettingsBlueCOUGAR::triggerInterface feature added. + + NEW FEATURE: Initial version of mvGigEConfigure added. (mvBlueCOUGAR.msi) + + NEW FEATURE: Detection of GigE Vision devices on host systems with more (mvTLIClientGigE-lib) + than one network adapter that has been assigned a zero-conf IP + address. + + NEW FEATURE: Multiple streams per device are now supported. (mvTLIClientGigE-lib) + + NEW FEATURE: Windows 2000 support added to GigE Vision capture kernel driver. (mvBlueCOUGAR.msi) + On Windows 2000 platforms a different version of the kernel mode + filter. + + NEW FEATURE: New configuration tool added to installer: mvGigEConfigure (mvBlueCOUGAR.msi) + This is meant to allow an easy installation and configuration of the + GigE Vision capture kernel driver. + + BUGFIX: Creating a stream was resetting the upper 16 bit of the port register. (mvTLIClientGigE-lib) + + BUGFIX: Firmware version is displayed correctly in the log file now for (mvBlueCOUGAR-lib) + mvBlueCOUGAR-P devices. + + BUGFIX: Changing the 'AdapterIPAddress' property will update the 'AdapterName' (mvBlueCOUGAR-lib) + and 'AdapterDescription' property now. + + BUGFIX: Internal timeout for device discovery increased in order to be (mvBlueCOUGAR-lib) + compliant with the recommendation of the GigE specification. + + BUGFIX: The imageDir mode sometimes internally created an invalid path (mvVirtualDevice-lib) + which resulted in no images being read from the specified directory. + (Linux only) + + NEW FEATURE: TestImageBarWidth property. (mvVirtualDevice-lib) + +14.01.2008 1.10.4 + BUGFIX: When multiple threads where calling DMR_GetImpactRequestBufferEx (mvDeviceManager-lib) + with the 'ibfUseRequestMemory' set and at least two threads where + asking for a packed RGB or an YUV format it could happen that the + content of the returned image buffers contained a mixture of the + individual images. + + BUGFIX: 'MissingData_pc' property wasn't calculated correctly in chunk mode. (mvBlueCOUGAR-lib) + + NEW FEATURE: mvDeviceConfigure can now be used to assign a new IP address (mvDeviceConfigure) + to a GigE Vision compliant device. (mvTLIClientGigE-lib) + + CHANGED BEHAVIOUR: Internal native socket default buffer size increased. (mvTLIClientGigE-lib) + + CHANGED BEHAVIOUR: If no EEPROM info could be found the device is listed with (mvSIGMAfg-lib) + a default serial number (MV000000000). (mvTITANfg-lib) + + UPDATE: new HWUpdateFunction added, only for HW Testing (mvSIGMAfg-lib) + +08.01.2008 1.10.3 + BUGFIX: internal use of AOI-Parameter was wrong for cameras with more than (mvHYPERIONfg-lib) + one tap. + + NEW FEATURE: mvIMPACT Acquire compatible trigger handling for mvBlueCOUGAR-P (mvBlueCOUGAR-lib) + devices. + + CHANGED BEHAVIOUR: The increment for the AOI width property has been changed (mvHYPERIONfg-lib) + from 4 to 8. + +17.12.2007 1.10.2 + BUGFIX: Open -> Close -> Open resulted in no more images being captured. (mvTLIClientGigE-lib) + + NEW FEATURE: Support for digital output 3 and 4 added. (mvBlueCOUGAR firmware and GenICam XML-file) + +12.12.2007 1.10.1 + NEW FEATURE: Power over CameraLink added to the low level kernel (mvHYPERION low level HW driver) + drivers. This feature needs hardware revision >= 2.xx of HYPERION-CLe. + CameraLink clock detection available for hardware revision < 2.xx. + + NEW FEATURE: Digital inputs and additional digital outputs connector J6 (mvHYPERIONfg-lib) + added to IOSubSystem. This feature depends on firmware version + and will be available from firmware version 35 onwards. + + BUGFIX: Potential memory leak when closing the device while image requests (mvBlueFOX-lib) + are still in the input queue. + + NEW FEATURE: Support for the 10 bit version of the mvBlueFOX added. (mvBlueFOX-lib) + + BUGFIX: Certain low level USB HW initialisation errors are passed up to the (mvBlueFOX-lib) + user now. + + BUGFIX: Flash update added for mvHYPERION boards. (mvDeviceConfigure) + (bug related to Linux compilation of mvDeviceConfigure) + + NEW FEATURE: Handling of default_flash configuration added. (mvHYPERION low level HW driver) + + +21.11.2007 1.10.0 + CHANGED BEHAVIOUR: Functions and classes that have been declared deprecated (mvIMPACT_acquire.h) + for some time now have been removed from the C++ interface. This will + not break existing binaries, but will force you to change + your code during rebuilds when deprecated code was used by your + application. A list of functions that have been removed and their + replacement can be found in the device drivers manual under + 'C/C++ developer -> Porting existing code' + + BUGFIX: Camera description files that contain a '.' in their name couldn't be (mvHYPERIONfg-lib) + reloaded after exporting them, when trying to create a camera (mvTITANfg-lib) + description, that was already existing no error message was returned, (mvSIGMAfg-lib) + Camera descriptions that contained 'Generic' as part of their name + couldn't be exported and imported. + + BUGFIX: Local XML files no longer have to be DWORD aligned to be downloadable. (mvBlueCOUGAR-lib) + + NEW FEATURE: Initial version of the GigE Vision capture kernel driver added (mvBlueCOUGAR.msi) + to setup. + + BUGFIX: line scan mode: only first request will synchronize to next line, (mvHYPERION low level HW driver) + following request transfer directly next lines without breaks + + BUGFIX: digital io passthrough mode, inverted / notinverted can't be switched (mvHYPERION low level HW driver) + + BUGFIX: snap request with timeout = 0 never elapses. (mvHYPERION low level HW driver) + +07.11.2007 1.9.17 + BUGFIX: When programming periodically Pulse sequence on a digital output (mvHYPERIONfg-lib) + then it is now possible to define a longer pulse than the period of + the signal. + + BUGFIX: Non-standard lists under ImagingSubSystem/Camera will be stored as (mvBlueCOUGAR-lib) + well now. + + BUGFIX: Log output can be configured through mvDebugFlags.mvd now. (mvTLIClientGigE-lib) + + NEW FEATURE: wxPropView can draw overlays from special strings attached to the (wxPropView) + request. + +01.11.2007 1.9.16 + BUGFIX: Device specific interface for the mvBlueCOUGAR is working again. (mvBlueCOUGAR-lib) + (Bug introduced in version 1.9.15) + + NEW FEATURE: GenICam files will be searched under a specific directory (mvBlueCOUGAR-lib) + now if the device specifies the URL as a file. (mvBlueCOUGAR.msi) + On Windows this directory will be + %ALL USERS\Documents\MATRIX VISION\mvIMPACT Acquire\GenICam, + on Linux it will be + $HOME/etc//matrix-vision/mvimpact-acquire/genicam + + NEW FEATURE: IO subsystem improved, now it is possible to program single pulse (mvHYPERIONfg-lib) + and pulse sequences to digital output. New IO-System is not compatible + to previous version. + + NEW FEATURE: Flash update added for mvHYPERION boards. (mvDeviceConfigure) + + BUGFIX: Grey 8x4 medium mode, every 8 pixel was dark. (mvHYPERIONfg-lib) + + BUGFIX: Abort function, if switch off camera during acquisition sometimes + no reaction of the application any more. (mvHYPERIONfg-lib) + + NEW FEATURE: Firmware version will now be reported. (mvHYPERIONfg-lib) + +31.10.2007 1.9.15 + BUGFIX: When a digital output was switched to 'Manual' the device was set up (mvBlueCOUGAR-lib) + for flash output and vice versa. + (Device specific interface only) + + BUGFIX: AcquisitionMode changes haven't been taken into account. (mvBlueCOUGAR-lib) + (Device specific interface only) + +29.10.2007 1.9.14 + BUGFIX: Time stamp works correctly with every GEV compliant device now that correctly (mvBlueCOUGAR-lib) + implements the time stamp tick frequency registers and the timestamp itself. + + BUGFIX: 64-bit int properties that define a hex format string haven't been (mvPropHandling-lib) + assigned correctly when writing the string value without leading '0x' + (e.g. "c0a8001212"). + + BUGFIX: MFC version of PropView can be compiled again. + (Bug introduced in version 1.9.8) + + BUGFIX: TImpactBufferFlag::ibfRecyleBufHandle became (mvDeviceManager.h) + TImpactBufferFlag::ibfRecycleBufHandle (spelling mistake). + This will not break existing binaries, but will force you to change + your code during rebuilds when this flag was used by your + application. + + CHANGED BEHAVIOUR: The translation dictionary entries for the property (mvBlueFOX-lib) + SensorColorPattern have been adapted to all other occurrences of these + strings in other drivers(camera descriptions etc.). + + UPDATE: Improved stability. (mvBlueCOUGAR-lib) + + NEW FEATURE: When the resulting IMPACT image buffer returned by a device (all shipped packages) + is a raw Bayer image, the IMPACT buffer will be allocated with + the Bayer image buffer type IPL_BAYERMOSAICBUF now. + + NEW FEATURE: Property 'TriggerMoment' added to class (mvIMPACT_acquire.h) + mvIMPACT::acquire::PulseStartCOnfiguration + +23.10.2007 1.9.13 + CHANGED BEHAVIOUR: TBlueLYNXCameraExposeMode has been replaced by (mvIMPACT_acquire.h) + TCameraExposeMode. + + NEW FEATURE: mvBlueCOUGAR specific interface layout enhanced and some (mvBlueCOUGAR-lib) + minor bugs fixed. + + CHANGED BEHAVIOUR: Execution of mvIMPACT::acquire::Method::call and (mvPropHandling-lib) + OBJ_Execute speeded up a little. + + NEW FEATURE: New error code added to TRequestResult enum: rrDeviceAccessLost (mvDriverBaseEnums.h) + +=== CD2007/A === + +15.10.2007 1.9.12 + BUGFIX: YUV422Packed mode is returned correctly now for mvTITAN-RGB boards. (mvTITANfg-lib) + + NEW FEATURE: FVAL-PassThrough mode is possible for mvTITAN/mvGAMMA-CL. (mvTITANfg-lib) + (mvTITAN/mvGAMMA low level HW driver) + + BUGFIX: Trigger-Out can be used via pulse sequences also for mvGAMMA-CL. + + CHANGED BEHAVIOUR: initialiseHW ( Loading FPGA ) is always done by default (mvTITANfg-lib) + for TITAN boards. + + BUGFIX: 64-bit integer properties can be read as 32-bit values now. (mvPropHandling-lib) + This however is NOT recommended as it might result in loss of data and + is just meant for compatibility reasons. + + BUGFIX: Left-right mirror in YUV422-packed mode flipped the Y components (mvSIGMAfg-lib) + incorrectly. + + NEW FEATURE: Initial version of the mvBlueCOUGAR specific C++ interface. (mvIMPACT_acquire.h) + + NEW FEATURE: Function mvIMPACT::acquire::Property::allowsValueCombinations, (mvIMPACT_acquire.h) + class mvIMPACT::acquire::PulseStartConfiguration, + mvIMPACT::acquire::IOSubSystem::getPulseStartConfiguration, + mvIMPACT::acquire::IOSubSystem::getPulseStartConfigurationCount, + mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber:: + getValidSignalsForPassThroughModes, + mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber:: + getValidPassThroughSignalCount, + mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber:: + getValidPassThroughSignalValue, + mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber:: + getValidPassThroughSignalString + mvIMPACT::acquire::OutputSignalGeneratorFrameGrabber:: + definePassThroughSignal. + + CHANGED BEHAVIOUR: The class mvIMPACT::acquire::ImageProcessingBlueFOX (mvIMPACT_acquire.h) + is no longer available. As all its features are available for every + device there is only one class mvIMPACT::acquire::ImageProcessing + now. Please replace every occurrence of + mvIMPACT::acquire::ImageProcessingBlueFOX or + mvIMPACT::acquire::ImageProcessingBase in your code by + mvIMPACT::acquire::ImageProcessing. + This change will NOT break existing binaries thus compiled software + already shipped will continue to work! + + CHANGED BEHAVIOUR: Creating an instance of (mvIMPACT_acquire.h) + mvIMPACT::acquire::IOSubSystemBlueFOX no longer raises an internal + exception. This is NOT a bugfix but purely cosmetics. + +24.09.2007 1.9.11 + BUGFIX: mvBlueFOX-102aG could cause footer errors. (mvBlueFOX-lib) + New FPGA version 68. + + +19.09.2007 1.9.10 + BUGFIX: The properties 'HDOutput', 'VDOutput' and 'pixelClockOutput' (mvIMPACT_acquire.h) + were mapped to an incorrect data type. + + NEW FEATURE: mvIMPACT::acquire::Request::getInfoIterator function added. (mvIMPACT_acquire.h) + + NEW FEATURE: The visible data from the info list of a request can be (wxPropView) + displayed as an overlay now. + + BUGFIX: Closing a device in debug builds could result in a heap corruption. (mvTITAN/mvGAMMA low level HW driver) + + NEW FEATURE: Timeout handling and property 'ImageRequestTimeout_ms' (mvBlueCOUGAR-lib) + implemented. + + BUGFIX: First image is received correctly now. (mvBlueCOUGAR-lib) + + NEW FEATURE: FrameID as part of the Request infos implemented. (mvBlueCOUGAR-lib) + + NEW FEATURE: Support for chunk mode added. (mvBlueCOUGAR-lib) + +04.09.2007 1.9.9 + NEW BEHAVIOUR: 'Abort' button enabled during running live acquisition. (wxPropView) + + BUGFIX: Missing merge module mvBlueFOXKernelDriver.msm added to 32-bit (mvBlueFOX.msi) + installer package (Windows only). + + NEW FEATURE: The saturation filter can be used with RGB destination formats (mvBlueFOX-lib) + as well now. + + NEW FEATURE: Support for mvBlueCOUGAR devices added (so far Windows only). (mvBlueCOUGAR-lib) + (mvTLIClientGigE-lib) + +15.08.2007 1.9.8 + DEPRECATED API CODE: mvIMPACT::acquire::Request::getInfo and (mvIMPACT_acquire.h) + mvIMPACT::acquire::Request::getResult have been declared deprecated. + The information of the structures is available via direct property + access now, which is more flexible and more efficient. + + BUGFIX: DMR_GetImageRequestInfo and DMR_GetImageRequestInfoEx and (mvDeviceManager-lib) + mvIMPACT::acquire::Request::getInfo returned DMR_INTERNAL_ERROR as + internally this parameter became 64-bit integer but was handled as a + 32-bit integer. For backward compatibility this parameter will be + truncated to 32-bit now but the use of this functions is not recommended + any more. Also see comments above made above. + (Bug introduced in version 1.9.7) + + NEW FUNCTION: DMR_UpdateDeviceList, (mvDeviceManager-lib) + mvIMPACT::acquire::DeviceManager::updateDeviceList (mvIMPACT_acquire.h) + + BUGFIX: File mode didn't work correctly when damaged image files where present (mvVirtualDevice-lib) + in the selected directory. + + NEW FEATURE: Timestamp property implemented for request results. (mvVirtualDevice-lib) + + NEW BEHAVIOUR: As only the mvBlueFOX-124C and mvBlueFOX-102C support vertical (mvBlueFOX-lib) + color binning at the moment, vertical and full binning is no longer + available for other color versions of the mvBlueFOX. + + NEW BEHAVIOUR: The two buttons 'Live' and 'Stop' have been replaced by one (wxPropView) + 'Live' Push-Button + + BUGFIX: Bayer pattern for the color version of the mvBlueFOX-102C is decoded (mvBlueFOX-lib) + correctly again. + + BUGFIX: Crashes when switching between developers view and standard view (wxPropView) + while the selected device wasn't initialised. + + BUGFIX: dma_error handling improved, multitasking problem fixed (mvHYPERION low level HW_WDM_driver) + + BUGFIX: abort_request function improved, waits now until last request will be + signalled. (mvHYPERION low level HW_WDM_driver) + +27.07.2007 1.9.7 + BUGFIX: Potential memory leak fixed. (mvBlueFOX-lib) + + BUGFIX: Changes stored in the system settings list will be updated (mvHYPERIONfg-lib) + automatically at start-up. (mvTITANfg-lib) + (mvSIGMAfg-lib) + (mvVirtualDevice-lib) + + BUGFIX: Gain wasn't set correctly, when video channel was changed. (mvTITANfg-lib) + + NEW FEATURE: RequestInfo: Property 'TimeStamp_us' is now a 64-bit integer. (mvHYPERIONfg-lib) + (mvSIGMAfg-lib) + (mvVirtualDevice-lib) + (mvBlueFOX-lib) + (mvTITANfg-lib) + + BUGFIX: calculation lost images corrected (mvHYPERIONfg-lib) + + BUGFIX: time stamp calculation corrected (mvHYPERION low level HW_WDM_driver) + +24.07.2007 1.9.6 + BUGFIX: Combo box controls display the correct initial value again. (wxPropView) + (Bug introduced in version 1.9.5) + + NEW FEATURE: Doc string feature added to camera descriptions. (mvHYPERIONfg-lib) + (mvSIGMAfg-lib) + (mvTITANfg-lib) + + NEW BEHAVIOUR: general fpga_reset removed from abort_function + uart_init changed, now only minimal register access added. (mvHYPERION low level HW driver) + +19.07.2007 1.9.5 + BUGFIX: Writing image results improved. (mvHYPERIONfg-lib) + (Linux only) + + BUGFIX: Cancelling of a process now works correct. (mvHYPERIONfg-lib) + + BUGFIX: Serial port now works with interrupt. (mvHYPERIONfg-lib) + + BUGFIX: Undefined symbols error when opening an mvHYPERION on Linux from (mvHYPERIONfg-lib) + an application that dynamically loads the mvDeviceManager-lib + + BUGFIX: In case of USB Bus related transmission errors the data transfer (mvBlueFOX-lib) + will be restarted faster and more reliable now. + + BUGFIX: Linux only: Closing and reopening a mvBlueFOX device no longer (mvBlueFOX-lib) + causes a segmentation fault. + + BUGFIX: Linux only: Closing and reopening a mvBlueFOX device no longer (mvBlueFOX-lib) + creates an unused thread. + + BUGFIX: Linux only: 2 extra, unused threads no longer created for (mvBlueFOX-lib) + mvBlueFOX. + + BUGFIX: Switching the property 'FooterMode' from 'Off' to any other value (mvBlueFOX-lib) + while the driver was busy processing image requests could lead to + heap corruptions. + + BUGFIX: clserialWrite() result corrected (mvHYPERION-kernel-Linux) + + BUGFIX: Undefined symbols error when opening an mvBlueFOX on Linux from (mvBlueFOX-lib) + an application that dynamically loads the mvDeviceManager-lib + + BUGFIX: High CPU load under wxPropView after opening the camera. (mvBlueFOX-lib) + (Bug introduced in version 1.7.2, Linux only) + + NEW FEATURE: VB 6 sample uses enumerated properties now as well. (all shipped MSI-packages) + + NEW FEATURE: First version using the new version of the propgrid(1.2.7). (wxPropView) + +14.06.2007 1.9.4 + BUGFIX: 8 bit bitmap export changed the image data in a way that the exported (wxPropView) + image had a different histogram. + + BUGFIX: mvShowDisplayWindow sometimes returned too early (before all internal (mvDisplay-lib) + data structures have been set up correctly). + + BUGFIX: Property 'Info/DeviceDriverVersion' returns a correct release number (all shipped packages) + again. + (Bug introduced in version 1.9.2) + + BUGFIX: When an mvTITAN-RGB/G4 was operated in PAL mode certain error (mvTITANfg-lib) + conditions e.g. a wrong pixel clock couldn't be detected correctly. + + BUGFIX: Loading of settings during device init didn't update all the (mvTITANfg-lib) + properties (e.g. Connector/cameraOutputUsed) correctly. (mvSIGMAfg-lib) + + BUGFIX: The request info 'frameID' is now visible for the mvBlueFOX. (mvBlueFOX-lib) + Fixed issue with frame on demand mode/single frame capture mode. + Minor timing fixes. Repaired CCD 'expose on high' trigger mode. + Improved camera softstart by new firmware version 41. + + NEW FEATURE: New compatible way to handle the user data in case of a reconnect (mvBlueFOX-lib) + event for a device added. Now the user can select whether he wants + the cached data or if he wants the data to be refreshed from the + devices non-volatile memory. See property 'ReconnectBehaviour' for + details. + + BUGFIX: Critical Section added to the handling of common resoures for (mvHYPERIONfg-lib) + request-function and waitforrequest-function. + + NEW FEATURE: Medium camera support added. (mvHYPERIONfg-lib) + + NEW BEHAVIOUR: PWM Super-Softstart for mvBlueFOX devices added to firmware. (mvBlueFOX-lib) + (-> Firmware version 41) + + CHANGED: The translation string of the enum value 'rrOK' changed from (all shipped packages) + 'Ready' to 'OK'. + +23.05.2007 1.9.3 + BUGFIX: The displayed AOIs in scaled display mode used unscaled offsets. (wxPropView) + + BUGFIX: Under certain 32-bit Linux distributions wxPropView could crash (wxPropView) + while playing around with the spin controls for the histogram and + line profile. + + NEW FEATURE: Colour to channel description mapping added to histogram and (wxPropView) + line profile. + + BUGFIX: 'ctmOnDemand' trigger mode for mvBlueFOX 102ag (mvBlueFOX-lib) + + CHANGED: Min. width of the image for mvBlueFOX-102ag versions reduced from (mvBlueFOX-lib) + 200 to 20. + + BUGFIX: Capturing 2-4 sync. grey sources (co2xComposite, co3xComposite, (mvTITANfg-lib) + co4xComposite mode) resulted in incorrect images for the + mvTITAN-RGB/G3 and mvTITAN-RGB/G4. + (Bug introduced in version 1.7.5 with the introduction of the scaler + feature) + + NEW FEATURE: Signed 64-bit Windows driver available for mvHYPERION and (mvBlueFOX-x64.msi) + mvBlueFOX. These packages will run under every amd64/x64 based (mvHYPERION-x64.msi) + Windows version including Windows Vista. + + NEW FEATURE: New pixel formats introduced: ibpfRGB101010Packed, (all shipped packages) + ibpfRGB121212Packed, ibpfRGB141414Packed, ibpfRGB161616Packed. + + UPDATE: Newer MSI compiler used to create Windows installer packages. (all shipped MSI based packages) + +23.04.2007 1.9.2 + BUGFIX: Calling DMR_GetImageRequestBufferImageData after a failed call to (mvDeviceManager-lib) + DMR_ImageRequestWaitFor could lead to crashes. + + BUGFIX: Reading from the digital inputs of an mvGAMMA-CL or an mvTITAN-CL (mvTITANfg-lib) + returned incorrect results (triggerIN and syncIN have been flipped). + + BUGFIX: max. offsets for X/Y offsets for histogram and line profile. (wxPropView) + + BUGFIX: Spin controls will be used for properties defining a min. and max. (wxPropView) + value again. + (Bug introduced in version 1.9.0) + + UPDATE: Calibration parameters are available again for fine tuning (mvBlueFOX-lib) + the mvBlueFOX (CCD versions only). + + NEW FEATURE: class CameraDescriptionManager provides enhanced 'locate (mvIMPACT_acquire.h) + description via string' functionality now. Either the list name or + value of the property 'name' of the description can be passed to the + corresponding location function now. + + NEW FEATURE: 64-bit Windows driver available. Currently this driver can't be (mvBlueFOX-x64.msi) + installed on Windows Vista, as it's still not certified and Windows + Vista doesn't allow uncertified drivers to be installed. + + NEW FEATURE: mvVirtualDevice driver available for testing and/or developing (mvVirtualDevice.msi) + on Windows (32 and 64-bit) without MATRIX VISION hardware. (mvVirtualDevice-x64.msi) + + NEW FEATURE: Trigger modes 'ctmOnDemand', 'ctmOnRisingEdge', 'ctmOnLowLevel' (mvBlueFOX-lib) + and 'ctmOnHighLevel' for mvBlueFOX-102aG devices. + + NEW FEATURE: Trigger mode 'ctmContinuous' works with mbBlueFOX-102 devices (mvBlueFOX-lib) + under USB 1.1 now. + + NEW FEATURE: The histogram now also displays the pixel value where most values (wxPropView) + have been detected. + + NEW FEATURE: Some additional request info properties became accessible for (mvTITANfg-lib) + certain devices. (line counter for mvGAMMA-CL, mvTITAN-CL and + mvTITAN-DIG) + +17.04.2007 1.9.1 + BUGFIX: Some missing references to namespace 'std' added in function (mvIMPACT_acquire.h) + CameraDescriptionManager::update. + + NEW FEATURE: 64-bit integer properties now also available under .NET (mvIMPACT_acquire.h) + + NEW FEATURE: VB 6 sample provides more usable functions and types now (all shipped MSI-packages) + + UPDATE: Low level Linux kernel drivers direct transfer version simplified. (low level mvHYPERION Linux kernel) + With the versions before it was not possible to close the capture + stream from the camera. Every second image was lost. Also digital + I/O subsystem expanded. + + BUGFIX: memory leak removed Hyperion_lib deletes now all initialised (mvHYPERIONfg-lib) + modules. + +12.04.2007 1.9.0 + BUGFIX: DMR_CloseDevice doesn't return DMR_NOT_INITIALIZED on a successful (mvDeviceManager-lib) + device close any more. + + BUGFIX: HRTC programs stored with versions older than 1.8.2 could not be read (mvPropHandling-lib) + with current versions of the driver any more. + + BUGFIX: Increasing the number of request objects by writing to the (mvSampleDevice-lib) + 'RequestCount' property is working now. (mvBlueCOUGAR-lib) + (mvBlueLYNX-lib) + + NEW FEATURE: Support for 64-bit integer properties. (all shipped packages) + + NEW FEATURE: Some new component flags added. (mvPropHandling-lib) + + NEW FEATURE: Property 'flashType'. (mvBlueFOX-lib) + + NEW FEATURE: wxPropView can be used to store a recorded sequence to disc (wxPropView) + + NEW BEHAVIOUR: The default doc-string is an empty string now. (mvPropHandling-lib) + + NEW BEHAVIOUR: The default format string for pointer properties (vtPtr) (mvPropHandling-lib) + is "0x%x" now, while it used to be "%x". + + NEW BEHAVIOUR: The translation dictionary of the property 'triggerMode' (mvBlueFOX-lib) + only contains modes, which are available for the sensor installed + in the camera now. + +20.03.2007 1.8.7 + BUGFIX: mvTITAN/mvGAMMA devices can be initialised again. (mvTITANfg-lib) + (Bug introduced in version 1.8.6) + + UPDATE: mvTITAN/mvGAMMA devices can be used with Windows Vistas Aero layout. (low level HW driver) + + UPDATE: mvDELTA/mvSIGMA devices can be used with Windows Vistas Aero layout. (low level HW driver) + +14.03.2007 1.8.6 + BUGFIX: Calling DMR_GetDevice (or mvIMPACT::acquire::DeviceManager::getDevice) (mvDeviceManager-lib) + with an empty search string could result in a crash. + + BUGFIX: Calculation of vertical start position for non-interlaced cameras (mvSIGMAfg-lib) + corrected. + + NEW FEATURE: All MSI-based installer packages work on Windows Vista now. (all shipped MSI based packages) + + NEW FEATURE: 8 bpp BMP support added. (wxPropView) + + NEW FEATURE: Tool tip support added to property grid. (wxPropView) + + NEW FEATURE: Devices can store/load filter parameters for 'defective pixel (mvTITANfg-lib) + filter', 'Flat field filter' and 'Dark current filter' now. (mvSIGMAfg-lib) + (mvHYPERIONfg-lib) + (mvBlueCOUGAR-lib) + (mvBlueLYNX-lib) + + CHANGED BEHAVIOUR: mvDeviceManager no longer writes a log-file if none has (mvDeviceManager-lib) + has been specified via mvDebugFlags.mvd or if mvDebugFlags.mvd + couldn't be located. + +12.03.2007 1.8.5 + BUGFIX: DeviceManager classes close devices only when the last instance to (mvIMPACT_acquire.h) + the device manager is destroyed. (mvDeviceManager-lib) + + BUGFIX: When AGC and AEC where switched on and the initial exposure time was (mvBlueFOX-lib) + higher than the max. exposure time defined by the AEC controller + the controller circuit used incorrect exposure times. + + BUGFIX: class mvIMPACT::acquire::WhiteBalanceSettings did incorrectly bind (mvIMPACT_acquire.h) + the interface property greenGain to the drivers blueGain and + vice versa. + + BUGFIX: Certain format conversion after a Bayer conversion didn't work. (all shipped packages) + + NEW FEATURE: PNG support added. (wxPropView) + + NEW FEATURE: YUV histogram and profile support added. (wxPropView) + +22.02.2007 1.8.4 + BUGFIX: YUV422Planar is displayed correctly now on platforms that don't (wxPropView) + support RAW BITMAP access. + + BUGFIX: Some internal pixel format conversions on arm platforms. (all shipped packages) + + BUGFIX: Loading previously stored correction data for the defective pixels (mvBlueFOX-lib) + filter is working now. + + BUGFIX: Loading a setting at runtime after opening a device did not update (all shipped packages) + all data stored by some image processing filters. + + NEW FEATURE: Initial version of the I/O Subsystem. (mvHYPERIONfg-lib) + + NEW FEATURE: Mirror function supports the formats ibpfRGBx888Planar, ibpfYUV422Packed (all shipped packages) + and ibpfYUV422Planar now. + + NEW FEATURE: Deprecated interface functions, types, structs and classes will (mvIMPACT_acquire.h) + result in a compile time warning if supported by the compiler. + + CHANGED BEHAVIOUR: mvIMPACT::acquire::ComponentIterator prefix ++ operator (mvIMPACT_acquire.h) + return a self reference now. + + CHANGED BEHAVIOUR: C++ sample 'Properties' redesigned. + +15.02.2007 1.8.3 + NEW FEATURE: The device list now contains a new property 'DeviceClass' (all shipped packages) + + NEW FEATURE: Major revision of pixel format conversion section. (all shipped packages) + + BUGFIX: Some internal pixel format conversions (all arm builds) + + CHANGED BEHAVIOUR: mvBlueFOX-102aG cameras have a higher default gain now. (mvBlueFOX-lib) + The default gain has been increased by a factor of 1.375. This will + result in brighter images when changing the driver version. + +12.02.2007 1.8.2 + BUGFIX: Corrupt or inconsistent settings could lead to incomplete updates (mvPropHandling-lib) + + BUGFIX: Reading a property's attributes (such as min. or max.) performs a (mvPropHandling-lib) + data type check now. + + BUGFIX: in class mvIMPACT::acquire::WhiteBalanceSettings the properties (mvIMPACT_acquire.h) + 'redGain', 'blueGain', 'greenGain' and 'totalGain' have been declared + as integer properties while they are float properties. + + BUGFIX: missing assignment operator added to class mvIMPACT::acquire::Device. (mvIMPACT_acquire.h) + + BUGFIX: Cameras reach full frame rates again. (mvBlueFOX-lib) + (Bug introduced in version 1.8.0) + + CHANGED BEHAVIOUR: Type checks added to constructors of Property, Method and (mvIMPACT_acquire.h) + ComponentList classes. + + CHANGED BEHAVIOUR: The property 'Name' of each user data entry in the device (mvBlueFOX-lib) + list is no longer allowed to start with a '!' character. + +06.02.2007 1.8.1 + NEW FEATURE: Class 'mvIMPACT::acquire::ImageMemoryManager' added. (mvIMPACT_acquire.h) + + CHANGED BEHAVIOUR: mvIMPACT::acquire::TMemManMode has been renamed to (mvIMPACT_acquire.h) + mvIMPACT::acquire::TMemorymanagerMode, enums value names now start + with 'mmm' instead of 'mm'. + + CHANGED BEHAVIOUR: mvIMPACT::acquire::TPoolMode has been renamed to (mvIMPACT_acquire.h) + mvIMPACT::acquire::TMemoryManagerPoolMode, enums value names now start + with 'mmpm' instead of 'pm'. + +01.02.2007 1.8.0 + BUGFIX: On Windows destroying of windows works correctly now when calling (mvDisplay-lib) + 'mvDestroyImageWindow'. + + BUGFIX: Reprogramming the sensor (changing the expose time etc.) could (mvBlueFOX-lib) + be incomplete. + + BUGFIX: Setting 'ImageRequestTimeout_ms' to '0' results in a time-out, that (mvBlueFOX-lib) + never elapses. + + BUGFIX: some missing UNICODE conversions added. (wxPropView and mvDeviceConfigure) + + BUGFIX: Not all members of class mvIMPACT::acquire::CameraDescriptionManager (mvIMPACT_acquire.h) + have been initialised correctly. + UPDATE: Internal migration to libexpat 2.0.0. (all shipped MSI-based packages) + + CHANGED BEHAVIOUR: libexpat-lib is no longer shipped with the MSI packages, as (all shipped MSI based packages) + none of the modules depends on it any more. This might force you to + to modify existing installer projects. + + CHANGED BEHAVIOUR: Property 'Statistics/LostImagesCount' no longer available (mvBlueFOX-lib) + as on the mvBlueFOX we can't lose images in a way as counted by this + property. + + CHANGED BEHAVIOUR: Trigger mode 'ctmOnHighExpose' no longer available for CMOS (mvBlueFOX-lib) + versions as these sensors don't support this mode anyway. + + CHANGED BEHAVIOUR: TCameraTestMode::ctmImageDirectory removed from the (mvDriverBaseEnums.h) + interface as this value was reserved for internal tests anyway. + + NEW FEATURE: Some compile time warnings for Visual Studio 6.0 C/C++ added (mvIMPACT_acquire.h) + + NEW FEATURE: Calibration parameters added to user data list for fine tuning (mvBlueFOX-lib) + the mvBlueFOX(CCD versions only). + + NEW FEATURE: x64 sections added to Visual Studio 2005 makefiles for the sample (all *.vs2005.vcproj files) + programs. Compatible libraries will follow. + + NEW FEATURE: A new pixel format is available: YUV422Planar. (all shipped MSI based packages) + +10.01.2007 1.7.6 + BUGFIX: Active scaler could cause crashes. (mvBlueFOX-lib) + (Bug introduced in version 1.7.5) + + CHANGED BEHAVIOUR: By default warnings will no longer be written into the (all shipped packages) + log-files. + + CHANGED BEHAVIOUR: The sample 'ContinuousCaptureToAVIFile' allows the precise (all shipped packages) + setting of the capture frame rate for the mvBlueFOX now. + +03.01.2007 1.7.5 + NEW FEATURE: Property ImageDestination::scalerMode is now implemented for (all shipped packages) + every device. However so far scaling is done in software. Only + reducing the image size with mvDELTA/mvSIGMA devices will be done + with no additional CPU load. + + BUGFIX: Property 'ImageProcTime' in the 'Statistics' list is displaying (all shipped packages) + correct data again. + (Bug introduced in version 1.7.0) + +02.01.2007 1.7.4 + BUGFIX: 'ChannelData' typedef appeared twice which caused newer GCC versions (mvDeviceManager.h) + to fail compiling. + + BUGFIX: Defective pixels filter is working again. (all shipped packages) + (Bug introduced in version 1.7.0) + + BUGFIX: High CPU load under wxPropView for devices that do not support event (all shipped packages) + handling. + (Bug introduced in version 1.7.2) + + CHANGED BEHAVIOUR: Event handling stuff for C++ modified. See Porting (all shipped packages) + existing code section in manual. + + NEW FEATURE: Record feature added to mvPropView. (mvPropView) + + NEW FEATURE: Auto offset calibration speed now can be configured. (mvBlueFOX-lib) + + NEW FEATURE: Support for mvBlueFOX-102aG and mvBlueFOX-M102aG added. (mvBlueFOX-lib) + + NEW FEATURE: Property ImageDestination::scalerMode is now implemented for (mvSIGMAfg-lib) + mvDELTA/mvSIGMA devices. + +10.11.2006 1.7.3 + BUGFIX: Maximum number of supported boards no longer limited to 16. (mvSIGMAfg-lib) + + BUGFIX: On certain motherboards devices couldn't always be detected correctly. (low level driver for mvDELTA, mvSIGMA, mvTITAN and mvGAMMA boards) + + BUGFIX: Memory leak when opening and closing a device that supports (mvBlueFOX-lib) + events. (mvTITANfg-lib) + (Bug introduced in version 1.7.2) + + BUGFIX: Memory leak when opening a device, acquire at least one image (all shipped packages) + and closing the device again. + + BUGFIX: Memory leak when opening and closing a device that supports camera (mvTITANfg-lib) + descriptions. (mvSIGMAfg-lib) + (mvHYPERIONfg-lib) + + BUGFIX: Certain log messages didn't terminate correctly. (all shipped packages) + + BUGFIX: Several minor installer issues (Windows only) mostly introduced with (all shipped packages) + version 1.7.2. + + BUGFIX: Info property SensorFPGAVersion is set correctly again. (mvBlueFOX-lib) + (Bug introduced in version 1.6.6) + + BUGFIX: Test mode 'moving color' returns a Bayer image, that is converted (mvBlueFOX-lib) + in 'Auto' Bayer conversion mode automatically. From version 1.7.0 + to 1.7.2 no color image could be returned. + (Bug introduced in version 1.7.0) + + NEW FUNCTION: DMR_GetDriverHandle. (mvDeviceManager-lib) + + NEW FEATURE: Start/stop trigger modes added (mvTITAN/mvGAMMA-CL only) (mvTITANfg-lib) + +26.10.2006 1.7.2 + NEW FEATURE: Certain drivers/devices can now report certain events. For (all shipped packages) + details see documentation of the functions DMR_EventWaitFor and + DMR_EventGetData (C-developers) or the class EventSubSystem(C++, + .NET and Python developers). + + NEW SAMPLES: CameraDescriptions, EventHandling (all shipped packages) + + BUGFIX: Renaming existing camera description files now doesn't confuse the (mvTITANfg-lib) + driver any more. (mvSIGMAfg-lib) + + BUGFIX: Deadlocks when switching the powerMode property during a running image (mvBlueFOX-lib) + acquisition. + +=== CD2006/B === + +20.10.2006 1.7.1 + BUGFIX: mvDisplay-lib Crashes in all the 'ContinuousCapture' samples (sample source code) + on Hyper-threading machines. + + NEW SAMPLE: ContinuousCaptureAllFormats added to setup(Windows). (all shipped packages) + + NEW SAMPLE: SequenceCapture added to setup(Windows). (all shipped packages) + + BUGFIX: Missing files needed to compile ContinuousCaptureToAVIFile added. (all shipped packages) + + NEW FEATURE: Different view modes can be selected now for the property grid (wxPropView) + to allow C-developers to display the grid like it would be accessed + by the interface functions. + + NEW FEATURE: Support for resizeable vector properties added. (wxPropView) + + BUGFIX: Crashes when defining a new destination image with a greater line (mvDisplay-lib) + count, but a smaller overall pixel count. + + NEW FEATURE: 'ibfRecycleBufHandle' added to mvDeviceManager. (mvDeviceManager-lib) + + BUGFIX: Disconnecting an mvBlueFOX shortly before closing the device (mvblueFOX-lib) + could lead to a deadlock. + + BUGFIX: Corrected the visibility of some callbacks in the camera descriptions. (mvTITANfg-lib) + + BUGFIX: Acquisition from a 10 bit monochrome digital camera into an (mvTITANfg-lib) + RGB or YUV destination format now works correctly. + + CHANGED BEHAVIOUR: Some values and corresponding strings of the enum (mvDriverBaseEnums.h) + 'TCameraOutput' have been renamed. + + BUGFIX: Mono10 acquisition with mvGAMMA-G and mvTITAN-G1 works correctly (mvTITANfg-lib) + again. + (Bug introduced in version 1.7.0) + + BUGFIX: Incorrect gain and offset for images acquired with a destination (mvTITANfg-lib) + format different from 'Auto' with a mvTITAN-RGB/G3 or mvTITAN-RGB/G4. + + BUGFIX: Increasing the value count for properties that define a translation (mvPropHandling-lib) + dictionary could lead to crashes. + + BUGFIX: Installer no longer leaves the file 'Properties.vs2005.vcproj'. (all shipped packages) + (Bug introduced in version 1.6.5) + + BUGFIX: Internal conversion from Mono10-16 to another Mono10-16 format (all shipped packages) + corrected. + + BUGFIX: 'ContinuousCapture_C' sample revised. This sample now works with every + device. + + BUGFIX: Closing either wxPropView or mvDeviceConfigure while in minimized (mvDeviceConfigure) + could lead to situations, where applications could not restore (wxPropView) + their original size. + +29.09.2006 1.7.0 + NEW FEATURE: Property 'BayerParity' added to digital camera descriptions. (mvDeviceManager.h) + (mvTITANfg-lib) + (mvHYPERIONfg-lib) + + NEW FEATURE: 'Flat Field', 'Defective Pixel' and 'Dark Current' filter support (mvBlueFOX-lib) + ibpfMono10, ibpfMono12, ibpfMono14 and ibpfMono16 now. (mvTITANfg-lib) + This also includes a complete redesign of the internal processing (mvSIGMAfg-lib) + functions. (mvHYPERIONfg-lib) + + BUGFIX: copy constructor and assignment operator corrected for classes (mvIMPACT_acquire.h) + 'RTCtrProgram', 'OutputSignalGeneratorFrameGrabber' and + 'ImageProcessingBase'. + + CHANGED BEHAVIOUR: ImpactAcquireException behaves as described in changeset (mvIMPACT_acquire.h) + 1.6.5 again. Please note that this requires the CD2006/B version + of the mvIMPACT-SDK installation when using both the mvIMPACT-SDK + and the mvIMPACT.acquire interface. + + NEW FEATURE: Property Device::LoadSettings offers 'no auto load' option (all shipped packages) + now. + + BUGFIX: Pixel format ibpfRGBx888Planar is returned correctly again. (all shipped packages) + (Bug introduced in version 1.6.7) + + NEW FEATURE: mvBlueFOX devices now can use an updated kernel driver. Updates (mvDeviceConfigure) + for cameras already installed on a system can be performed via (mvBlueFOX-lib) + mvDeviceConfigure, new cameras connected to the system for the first (mvBlueFOX2.sys, version 1.0.0.0) + time will automatically use the new driver. The new driver will cause + less CPU load than the previous one. This applies to Windows systems + only. See documentation under GUI -> mvDeviceConfigure -> + how to update the kernel driver as well. + + BUGFIX: Property 'LineDelay_clk' is set correctly when reconnecting or opening (mvBlueFOX-lib) + an mvBlueFOX-102 device. + + NEW FEATURE: Property 'SensorTimingMode' added to CameraSettingsBlueFOX class. (mvBlueFOX-lib) + (mvIMPACT_acquire.h) + + NEW FEATURE: Class SystemBlueFOX offers a new property 'powerMode' now. (mvBlueFOX-lib) + + NEW FEATURE: Support for YUV formats added to mvDeviceManager (mvDeviceManager-lib) + +04.09.2006 1.6.9 + BUGFIX: Expose times larger than 250000 us result in correct images now for (mvBlueFOX-lib) + mvBlueFOX-121 models. + + NEW BEHAVIOUR: PWM Softstart for mvBlueFOX devices added to firmware. (mvBlueFOX-lib) + (-> Firmware version 37) + +29.08.2006 1.6.8 + NEW FEATURE: 'Browse' and 'Default' button added to log output configurator. (mvDeviceConfigure) + +22.08.2006 1.6.7 + BUGFIX: Project file for sample 'ContinuousCaptureToAVIFile' was missing (all shipped MSI based packages) + some source files and the linking of the vfw32.lib in the VS 6 project + file. + + BUGFIX: mvDeviceConfigure could crash when no recognized device could be (mvDeviceConfigure) + detected. + + NEW FEATURE: mvDeviceConfigure can start wxPropView for a device by double (mvDeviceConfigure) + clicking on a device in the list control of devices. This will (wxPropView) + open a new instance of wxPropView an start live acquisition + from that device. + +09.08.2006 1.6.6 + BUGFIX: DMR_DeleteUserDataEntry returns a correct error code now when an (all shipped packages) + invalid index has been passed to the function. + + BUGFIX: The real exposure time written to the camera has been incorrect in (mvBlueFOX-lib) + previous versions of the driver for mvBlueFOX-102G and mvBlueFOX-102C + devices. The lower the pixel clock the higher the difference between + desired and real exposure time. This will result in brighter images + when using older drivers and also when using older drivers an image + at a higher pixel clock will be brighter than an image with the same + exposure time at a lower pixel clock. + + BUGFIX: Properties, that store more than one value and that are assigned via (mvPropHandling-lib) + 'writeS' now safely convert the data. + + CHANGED BEHAVIOUR: The property 'Product' now contains a longer string (mvSIGMAfg-lib) + that is compliant with the other device drivers. + + BUGFIX: Properties displayed as a vector are handled correctly now (each (PropView) + element can only assign one parameter to the property). + + NEW FEATURE: Functions OBJ_GetFlagsS and OBJ_GetTypeS added to 'C' (mvDeviceManager.h) + compliant interface. + + NEW FEATURE: Functions DMR_ErrorCodeToString added to 'C' compliant (mvDeviceManager.h) + interface. + + NEW FEATURE: Functions Component::flagsS and Component::typeS added to (mvIMPACT_acquire.h) + C++ compliant interface. + + NEW FEATURE: ImpactAcqiureException::getErrorCodeAsString() (mvIMPACT_acquire.h) + static ImpactAcqiureException::getErrorCodeAsString( int errorCode ) + + CHANGED BEHAVIOUR: ImpactAcquireException does always derive from (mvIMPACT_acquire.h) + std::runtime_error now (see new features in version 1.6.5). The + behaviour described in version 1.6.5 will be implemented when there + is a new mvIMPACT-SDK release as otherwise old mvIMPACT-SDK C++ + applications will NOT compile with mvIMPACT Acquire version higher + than 1.6.5. + + BUGFIX: Missing reference to Instinf.msm added to merge file install for frame (all shipped MSI based frame grabber packages) + grabber devices + +10.07.2006 1.6.5 + BUGFIX: Timestamp in *.log-output is always positive now. (all shipped packages) + + BUGFIX: Appending to existing log files always produces consistent XML (all shipped packages) + output now. However appending to files is slow and should only + be used is necessary. See section 'logging' in the corresponding + manual. + + BUGFIX: XML file output on Linux now working correctly. (all shipped packages) + + NEW SAMPLE: ContinuousCaptureToAVIFile sample added to the C++ samples. (all shipped MSI based packages) + This sample can be used as a starting point for AVI capture + related applications. + + NEW FEATURE: Visual Studio 2005 workspace and project files added to sample (all shipped MSI based packages) + programs. + + NEW FEATURE: A new pixel format is available: RGB888Packed. (all shipped MSI based packages) + + CHANGED BEHAVIOUR: String representation of the pixel formats corrected in (all shipped MSI based packages) + the result structures. + + NEW FEATURE: 'OffsetAutoBlackLevel' property published for mvBlueFOX for C++ (mvIMPACT_acquire.h) + and all other high level languages. The property is located in class + CamerSettingsBlueFOX. + + NEW FEATURE: 'controllerDelay_Images' property published for mvBlueFOX for C++ (mvIMPACT_acquire.h) + and all other high level languages. The property is located in class + AutoControlParametersBlueFOX. + + NEW FEATURE: mvImpactAcquireException will now either be derived from (mvIMPACT_acquire.h) + std::runtime_error or (if mvIMPACT.h has been included before) + ImpactException. + + CHANGED BEHAVIOUR: Some typedefs that only have been used internally removed (mvIMPACT_acquire.h) + from the interface and made private class members. + + BUGFIX: Some C++ interface objects are now reference counted in order to (mvIMPACT_acquire.h) + avoid crashes under .NET + + NEW FEATURE: Enhanced error information output for mvTITAN and mvGAMMA (mvTITANfg-lib)) + boards. + + NEW BEHAVIOUR: When a CameraLink camera description contains valid data, (mvTITANfg-lib) + but data the used frame grabber can't cope with (e.g. a + description for a MEDIUM camera connected to a mvGAMMA-CL) the + Result structures 'result' entry will now return + 'rrCameraNotSupported'. + + NEW BEHAVIOUR: property 'VideoOutput' in the camera description list (mvTITANfg-lib) + and the property 'CameraOutputUsed' in the list 'Connector' (mvSIGMAfg-lib) + became read-only. + + BUGFIX: Disconnecting an mvBlueFOX USB camera could lead to crashes (mvBlueFOX-lib) + in very rare cases. + + BUGFIX: Reconnect restarts HRTC programs that where running before (mvBlueFOX-lib) + the device was removed. + + CHANGED BEHAVIOUR: mvBlueFOX devices return a more precise error (mvBlueFOX-lib) + information on failures during firmware update and modification + of the device ID. + + BUGFIX: Property values with a format specifier for hex (%x) haven't (mvPropHandling-lib) + always been converted from/to string correctly. + + NEW FEATURE: mvDeviceConfigure stores its current layout and restores (mvDeviceConfigure) + it on the next start-up. + + NEW FEATURE: mvDeviceConfigure can now be used to configure the way (mvDeviceConfigure) + *.log-output is generated(Action -> Configure Log output). + + NEW FEATURE: mvDeviceConfigure now detects device ID conflicts and informs (mvDeviceConfigure) + the user about it. + + BUGFIX: Minor display issues in the Windows version of wxPropView (wxPropView version) + + NEW FEATURE: Toolbar added to wxPropView. (wxPropView version) + +07.06.2006 1.6.4 + NEW FEATURE: The MFC based version of mvPropView is no longer the (all shipped MSI based packages) + default application to configure a device. Use the wxWidgets + based version instead, which is available for Linux as well and + offers more features like histogram, line profile, enhanced GUI + features. + + CHANGED BEHAVIOUR: The camera handling for frame grabber devices has been (mvTITANfg-lib) + simplified. Please see the section 'C++ developers -> Image (mvSIGMAfg-lib) + acquisition -> Working with camera descriptions' for details (mvHYPERIONfg-lib) + +29.05.2006 1.6.3 + NEW FEATURE: All MSI-based installers now offer a modify option in (all shipped MSI based packages) + maintenance mode. + + NEW FEATURE: Support for digital camera descriptions added to C++ + interface. + + BUGFIX: Auto offset programming could cause distortions in the image. (mvBlueFOX-lib) + Visible with large gain and short expose times(approx. 500 us) + and certain scenes. + +23.05.2006 1.6.2 + BUGFIX: Trying to log into a file, that couldn't be created could cause (all shipped packages) + crashes. + + NEW FEATURE: 'ScanClock' for mvTITAN-RGB, mvTITAN-G1 and mvGAMMA-G. (mvTITANfg-lib) + + BUGFIX: Property 'offset_pc' in class mvIMPACT::CameraSettingsFrameGrabber + has been renamed to 'offset_mV' and is bound correctly now. + + NEW FEATURE: 'FlashToExposeDelay_us' for mvBlueFOX devices. (mvBlueFOX-lib) + + BUGFIX: Statistical properties 'QueueTime_s' and 'CaptureTime_s' contain (mvBlueFOX-lib) + correct values again. + + BUGFIX: Overlay works when moving the display window out of the right (mvPropView) + or bottom of the visible desktop area. This only affects images + display in YUV422Packed mode. + +09.05.2006 1.6.1 + NEW FEATURE: The mvTITAN-RGB now support the setting of gain and offset (mvTITANfg-lib) + per channel(R, G and B) in RGB mode. + + NEW FEATURE: The mvTITAN-RGB/G4s PAL decoder is now supported. (mvTITANfg-lib) + + NEW FEATURE: Support for mvHYPERION-CLe boards added. (mvHYPERIONfg-lib) + + BUGFIX: Internal support for Mono10 - Mono16 pixel formats added for (mvTITANfg-lib) + mvTITAN-CL and mvTITAN-DIG boards. + + NEW FEATURE: mvBlueFOX 120C, 121C and 124C support horizontal color (mvBlueFOX-lib) + binning now, mvBlueFOX 124C also supports vertical color binning + +02.05.2006 1.6.0 + NEW FEATURE: Repair also reinstalls the low level frame grabber driver (all shipped MSI based packages) + now. + + NEW FEATURE: Image request control handling improved. See documentation of + class mvIMPACT::acquire::FunctionInterface(OOP developers only) + See also the 'porting existing code' section. + + NEW FEATURE: ComponentCollection::hObj() returns the underlying handle + for this collection. + + BUGFIX: logging into files is now multi-process safe. + + BUGFIX: sample 'continuousCaptureAllDevices' is now completely multi thread + safe. + + See the corresponding 'Porting existing code' section for details about + enhancements and deprecated stuff. + +=== CD2006/A === + +24.04.2006 1.5.0 + CHANGED BEHAVIOUR: The mvBlueFOX specific property 'USBRetransmit' has (mvBlueFOX-lib) + been renamed to 'USBRetransmitCount'. See the corresponding + 'Porting existing code' section for details. + + CHANGED BEHAVIOUR: The class mvIMPACT::acquire::Info has been renamed + to mvIMPACT::acquire::InfoBlueFOX. See the corresponding 'Porting + existing code' section for details. + + NEW FEATURE: Support for frame grabbers added (mvTITAN (RGB-G4, RGB-G3, CL, G1, DIG)) (mvTITANfg-lib) + mvGAMMA (G, CL), mvSIGMA(SLC, SQ), mvDELTA). (mvSIGMAfg-lib) + (mvDeviceManager-lib) + + NEW FEATURE/CHANGED BEHAVIOUR: mvPropView only checks for overlay (DD) (mvPropView) + when it needs it and displays a message on failure. DirectDraw + overlay is only needed/used for YUV422Packed images currently. + export/save operations can now be cancelled. + + NEW FEATURE: Logging is now fully supported. See corresponding section + in the manual. + + NEW FEATURE: A wxWidgets based version of mvPropView has been added to + the setup. It has some nice features(live histogram, line + profile) and a Linux version is available as well. However its + display performance is weaker than the MFC based mvPropView, which + is the reason, why no short cut will be created on the desktop. + However the higher CPU load is ONLY caused by the applications + way of displaying the images and has nothing to do with the + performance of the interface itself. It can be found in the + 'bin' folder of the installation. + +27.02.2006 1.4.6 + BUGFIX: UserData::getUserDataEntry( int nr ) const now behaves as stated + in the documentation. + + NEW FEATURE: UserData::validUserDataEntryIndexes(). + + UPDATE: mvBlueCOUGAR support added (mvDeviceManager-lib) + + BUGFIX: Calling 'imageRequestSingle' from one and 'imageRequestReset' from (mvBlueFOX-lib) + another thread could produce deadlocks. + +16.02.2006 1.4.5 + UPDATE: Internally the C++ interface now uses the class 'ExceptionFactory' + to create exceptions. + + BUGFIX: long time integration sometimes produced incorrect images. (mvBlueFOX-lib) + + BUGFIX: Return values of DMR_WriteUserDataToHardware corrected (mvBlueFOX-lib) + + BUGFIX: Writing empty user data entries to the device could leed to a state (mvBlueFOX-lib) + where the camera couldn't be accessed any more. + (Bug introduced in version 1.4.0) + + BUGFIX: Crashes when selecting planar destination formats under mvPropView (mvPropView) + (Bug introduced in version 1.4.0) + +23.01.2006 1.4.4 + BUGFIX: Function PropertyS::readBinary. + + BUGFIX: Properties UserData::memoryAvailable_bytes and + UserData::memoryConsumed_bytes bound correctly now. + + UPDATE: Improved sensor timing and therefore image quality for certain sensor (mvBlueFOX-lib) + operation modes. + + NEW FEATURE: sfFile flag added to TStorageFlag enum to allow explicit (mvPropHandling-lib) + declaration of file I/O. Previous versions interpreted the sfNative + flag NOT set as file output. This method is now deprecated but still + supported. New applications should us the sfFile flag. This also + allows to do file output AND native output with a single function + call (by combining(sfNative | sfFile)). + +20.01.2006 1.4.3 + NEW FEATURE: Interface to unlock certain features via a license file added (mvBlueFOX-lib) + (mvDeviceManager-lib version 1.4.3.23) + + NEW FEATURE: SDRAM memory support added for mvBlueFOX-M CCD versions. (mvBlueFOX-lib) + +17.01.2006 1.4.2 + NEW FEATURE: SDRAM memory support added for mvBlueFOX-M CMOS(102) versions. (mvBlueFOX-lib) + +03.01.2006 1.4.1 + BUGFIX: Spelling mistake introduced in version 1.4.0 corrected. This will not (mvPropHandling-lib) + allow to restore the calibration data for DarkFiled, FlatField + and DefectivePixels Filter without changing the corresponding section + in the Registry and/or the XML file. To restore these data rename + the list "DeficeSpeficData' to 'DeviceSpecificData'. + + NEW FEATURE: PropertyS::writeBinary and PropertyS::readBinary overloads. + + BUGFIX: Connecting a hot-plug device while mvPropView is already running (mvPropView) + is working correctly again. (mvDeviceManager-lib) + (Bug introduced in version 1.4.0) + +22.12.2005 1.4.0 + BUGFIX: DDraw overlay update didn't worked with some graphic adapters (mvPropView) + (Matrox P650, ATI X1300 etc..). + + BUGFIX: Status line image format. (mvPropView) + + BUGFIX: Now every transfer size with every sensor resolution is working (mvBlueFOX-lib) + + CHANGED BEHAVIOUR: The property 'UserData' has been replaced by a list (mvBlueFOX-lib) + of entries, that allow a more flexible management of user data. + This is an incompatible change and might force you to modify existing + code. Data stored in the device EEPROM with the old format will still + be readable. See the corresponding 'Porting existing code' section + for details. + + INCOMPATIBLE CHANGE: The class ImageBufferDescriptor does no longer support + the constructors + explicit ImageBufferDesc( ImageBuffer* p, bool boTakeOwnership = false ) + and explicit ImageBufferDesc( const ImageBuffer& source ); + See the corresponding 'Porting existing code' section for details. + + NEW FEATURE: ImageProcessing::defineFilterImageBuffer and + ImageProcessing::queryFilterImageBuffer. + + NEW FEATURE: class ExceptionFactory. + + NEW FEATURE: Binary data can be written to and read from string properties + now. + + BUGFIX: export/import of large string data (mvPropHandling-lib) + + NEW FEATURE: class ImageProcessingBlueFOX. It provides access to a new (mvBlueFOX-lib) + range of filter functions that address certain characteristics of + image sensors(Flat field filter, defective pixels filter, + dark current filter). + +04.11.2005 1.3.9 + NEW FEATURE: Default clock for CCD mvBlueFOX cameras set to 24MHz. (mvBlueFOX-lib) + 24MHz available for all mvBlueFOX CCD cameras now. + + UPDATE: Sensor timing for various mvBlueFOX cameras optimized. (mvBlueFOX-lib) + + NEW FEATURE: ComponentAccess::changedCounterAttr function. + + BUGFIX: Closing one device might stop all other devices from displaying (mvPropView) + live images. + + BUGFIX: Rapid switching between devices in live mode could leave requests (mvPropView) + locked until no more free requests where available thus resulting + in no more images being captured. + + BUGFIX: HRTC-program mode is restored correctly again. (mvBlueFOX-lib) + (Bug introduced in version 1.3.4) + + BUGFIX: Flash and HRTC program are stopped when closing the mvBlueFOX. (mvBlueFOX-lib) + + NEW FEATURE: Implemented basic log mechanism for mvBlueFOX devices. (mvBlueFOX-lib) + + BUGFIX: Bayer conversion on SSE2 compatible processors with more than one (mvBlueFOX-lib) + device in YUV mode in the same process. + +=== CD2005/C === + +04.10.2005 1.3.8 + BUGFIX: Hanging communication thread under NeuroCheck fixed (mvBlueFOX-lib) + (Bug introduced in version 1.3.6) + + NEW FEATURE: OBJ_GetIDictEntry and OBJ_GetFDictEntry function added. (mvDeviceManager-lib) + These functions can be used to query a single translation + dictionary entry instead of the complete dictionary and are meant for + use under VB or VB.NET and C# (from the mvIMPACT_NET-lib). + + NEW FEATURE: The device list now has a userData property ("UserData"), which (mvBlueFOX-lib) + can be used to store user specific data permanently into the device. + + BUGFIX: IOSubSystem::readInputRegister returns correct results now all the + time. + +09.09.2005 1.3.7 + BUGFIX: Overlapped expose mode is working again. (mvBlueFOX-lib) + (Bug introduced in version 1.3.6) + + NEW BEHAVIOUR: HRTC programs and settings only store the essential data (mvBlueFOX-lib) + now. (mvPropView) + +06.09.2005 1.3.6 + BUGFIX: RGBx888Packed mode when calling DMR_GetImpactRequestBufferEx (mvDeviceManager-lib) + with 'ibfUseRequestMemory' is working now. + + BUGFIX: DMR_GetImageRequestBufferImageData correctly supports the + RGBx888Planar mode now. + + BUGFIX: mvPropView is compilable again. (mvPropView) + + NEW FEATURE: mvPropView can display planar RGB images properly now. (mvPropView) + + BUGFIX: Structure alignment in mvDeviceManager.h set to 8 byte boundaries. + + NEW BEHAVIOUR: Compiler warning in + mvIMPACT::acquire::ImageProcessing::ImageProcessing removed. + + BUGFIX: Unplugging the mvBlueFOX during the init procedure is now handled (mvBlueFOX-lib) + correctly. + + BUGFIX: Unplugging the mvBlueFOX while capturing images and setting (mvBlueFOX-lib) + properties in now handled correctly. + + BUGFIX: With activated Bayer conversion the first image might have been (mvBlueFOX-lib) + in an incorrect format. + + NEW BEHAVIOUR: mvBlueFOX update speed enhanced. (mvBlueFOX-lib) + + BUGFIX: HRTC program files can be imported an stored correctly again (mvBlueFOX-lib) + (mvPropHandling-lib version 1.3.6.15) + +08.08.2005 1.3.5 + BUGFIX: Calling imageRequestReset with the device removed doesn't cause (mvBlueFOX-lib) + an access violation anymore. + + BUGFIX: Import of lists from the registry. (mvPropHandling-lib) + + BUGFIX: Check for available device features. (mvDeviceManager-lib) + +=== CD2005/B === + +02.08.2005 1.3.4 + NEW FEATURE: ibpfRGBx888Planar is now fully supported. (mvBlueFOX-lib) + + NEW FEATURE: Request::getIMPACTImage( TImpactBufferFlag flags ) const; (mvDeviceManager-lib) + which can be used to control the way the returned IMPACT buffers + are created and handled. + +28.07.2005 1.3.3 + NEW FUNCTIONS: IOSubSystem::getInputCount, IOSubSystem::getOutputCount + to query the number of available digital inputs and outputs for + a device. + + INCOMPATIBLE CHANGES: + - typedef for IntDict and FloatDict removed from + interface. Replace each occurrence of FloatDict by + std::vector >, each occurrence + of IntDict by std::vector >. + - class local enum for Property limits made global. + Property::minValue became plMinValue + Property::maxValue became plMaxValue + Property::stepWidth became plStepWidth + - RTCtrProgram::programSize became RTCtrProgram::getProgramSize. + - These changes became necessary for creating the .NET interface + and might force you to change existing code. + + NEW FEATURE: TWhiteBalanceParameter enum published an applied to + the property 'WhiteBalance' in the interface class + 'ImageProcessing'. + + NEW FEATURE: A new application has been added to the + setup('mvDeviceConfigure'). It can be used to perform firmware + updates and to assign unique device IDs. + + BUGFIX: Crashes when calling the update method for a (mvBlueFOX-lib) + HardwareRealtimeController without parameters. + + BUGFIX: A hardware real-time controller program is stopped automatically (mvBlueFOX-lib) + when it's modified. + + BUGFIX: trigger mode 'OnHighExpose' fixed. This trigger mode also sets (mvBlueFOX-lib) + the flag cfInvisible for the properties 'expose_us' and + 'FrameDelay_us' now as modifying these properties in this + trigger mode has no effect. + + BUGFIX: USB devices don't leave zombie windows in process memory. (mvBlueFOX-lib) + + UPDATE: Some missing return types added, slight modifications in the + template classes to allow compilation with Microsoft Visual Studio 2005. + + BUGFIX: mvDeviceManager returns correct error codes when calling the (mvDeviceManager-lib) + functions DMR_SetDeviceID or DMR_UpdateFirmware now. + + NEW FEATURE: IOSubsystem/HRTC programs can be stored as XML file as well now. (mvPropHandling-lib) + New error code: PROPHANDLING_CANT_SERIALIZE_DATA and new flag + cfDisallowSerialize. + + BUGFIX: FunctionInterface::saveSystem is working again. + +08.07.2005 1.3.2 + NEW FEATURE: Support for mvBlueFOX-102G/O4 and mvBlueFOX-102C/O4 (mvBlueFOX-lib) + added. + + NEW FEATRUE: HRTC programs are now stored in the registry as well. + +27.06.2005 1.3.1 + BUGFIX: DEV_REQUEST_CANT_UNLOCKED error code value corrected to -2115. (mvBlueFOX-lib) + + BUGFIX: mvPropView: Storing Bitmaps is working again. (mvPropView) + + NEW FEATURE: Base class ComponentCollection for CameraSettings, + ImageProcessing and ImageDestination. This allows to restore the + default values for every property managed by these objects. + + NEW FUNCTIONS: DMR_GetImageRequestBufferData(), (mvDeviceManager-lib) + DMR_GetImageRequestBufferChannelData(), + DMR_GetImageRequestBufferImageData() and + DMR_SetImageRequestBufferImageData(). + + BUGFIX: Expose readout for mvBlueFOX 102 series. (mvBlueFOX-lib) + + BUGFIX: AGC/AEC for mvBlueFOX 102 series. (mvBlueFOX-lib) + + BUGFIX: External trigger for mvBlueFOX CMOS series now working. (mvBlueFOX-lib) + + NEW SAMPLE: 'VBSample' to demonstrate how to access the devices under + Visual Basic .NET. + + NEW SAMPLE: 'DelphiSample' to demonstrate how to access the devices under + Borland Delphi 5.x and onwards. + + BUGFIX: Missing lib exports for functions DMR_SaveRTCtrProgram and (mvDeviceManager-lib) + DMR_LoadRTCtrProgram added. + + NEW BEHAVIOUR: The C++ interface header file and folder have been renamed + to achieve the same look and feel as the IMPACT CPP wrapper files. + mvi_acquire/mvi_acquire.h became mvIMPACT_CPP/mvIMPACT_acquire.h. + + NEW BEHAVIOUR: The class mvIMPACT_CPP::acquire::System has been renamed to + mvIMPACT_CPP::acquire::SystemSettings to avoid conflicting names under + .NET. + + NEW BEHAVIOUR: The function mvIMPACT::acquire::stringAllocator became a + static protected member of the class + mvIMPACT::acquire::ComponentAccess. + + NEW BEHAVIOUR: ::size_type return types changed to unsigned int (reason: + .NET support). + + NEW BEHAVIOUR: std::map and std::set dependencies removed from C++ wrapper + FunctionInterface::getAvaiableSettings now returns a string + vector instead of a string set(reason: .NET support). + +31.05.2005 1.3.0 + NEW BEHAVIOUR: The underlying C-API has been moved completely to the (mvDeviceManager-lib) + mvDeviceManager-lib. Applications compiled with and older version + of this interface MUST be recompiled, re-linked and maybe modified. + See the corresponding 'Porting existing code' section for details. + This allows to use the supported devices from other programming + languages (such as Visual Basic or Delphi) as well. + + BUGFIX: mvi_acquire.h has been adapted to work with the compiler bugs + of the Visual Studio 6.x compiler. + + NEW FEATURE: The setup has been reorganized. There are now workspaces + for Visual Studio 6.x, 7.x and Borland C++ Builder 6.x for all + Sample programs. + + NEW SAMPLE: ContinuousCapture_C shows how to work with the 'C' compliant + interface. + + NEW BEHAVIOUR: It's no longer necessary to link mvPropHandling.lib. (mvDeviceManager-lib) + Only mvDeviceManager.lib is needed now. + + UPDATE: Bayer conversion speed optimised for mvBlueFOX devices. (mvBlueFOX-lib) + + BUGFIX: mvBlueFOX 121 with 40MHz pixel clock is now working properly. (mvBlueFOX-lib) + + 1.2.2 NEW FEATURE: Hibernating support added for mvBlueFOX devices. (mvBlueFOX-lib) + + NEW BEHAVIOUR: Searching devices is now down in the mvDeviceManager-lib. (mvDeviceManager-lib) + This will require an up to date mvDeviceManager-lib on each + target system compiled with the actual version of the mvi_acquire.h! + + NEW BEHAVIOUR: Device::setID and Device::updateFirmware now call direct (mvDeviceManager-lib version 1.2.2.6) + exports of the mvDeviceManager-lib. + This will require an up to date mvDeviceManager-lib on each + target system compiled with the actual version of the mvi_acquire.h! + + NEW BEHAVIOUR: matchString function removed! + +28.04.2005 1.2.1 + BUGFIX: Missing implementations of the class ImageProcessing added. + + BUGFIX: Spelling mistakes in enum TBlueFOXTransferSize. + + NEW BEHAVIOUR: TBlueFOXFooterMode values renamed. + + NEW BEHAVIOUR: Image buffer state property removed from ImageBuffer class + as it became redundant. + + NEW PROPERTY: Info::SensorType. + + BUGFIX: Visibility flag for components in invisible sublists is (mvPropHandling-lib) + correct now. + + BUGFIX: import of XML ComponentLists. (mvPropHandling-lib) + + NEW FEATURE: AGC and AEC are available under mvPropView now. (mvBlueFOX-lib) + + NEW FEATURE: MirrorMode property (allows horizontal or vertical flipping (mvBlueFOX-lib) + of the image. See ImageProcessing::MirrorMode. + + NEW FEATURE: User controlled firmware update, EEPROM stored device ID. (mvBlueFOX-lib) + See Device::setID(), Device::updateFirmware(), Device::HWUpdateResult. + + NEW FEATURE: USB 1.1 support added for mvBlueFOX cameras. (mvBlueFOX-lib) + +20.04.2005 1.2.0 + NEW FUNCTION Property::readSArray. (mvPropHandling-lib) + + NEW BEHAVIOUR: FunctionInterface::createSetting and + FunctionInterface::createImageRequestControl don't throw exceptions + anymore, but return an error code if the call failed. + + BUGFIX: An error is reported, if XML-settings can't be located. (mvPropHandling-lib) + + BUGFIX: Error codes are reported by functions from class FunctionInterface (mvBlueFOX-lib) + Error codes can be from the error code range of TDEV_MGR_ERROR, + TDEVICE_DRIVER_ERROR or TPROPHANDLING_ERROR. + + NEW FEATURE: Real time control machines added to interface and driver. (mvBlueFOX-lib) + + NEW FEATURE: AGC and AEC controls added to interface and driver. (mvBlueFOX-lib) + + NEW BEHAVIOUR: Init speed, PnP speed optimised. (mvBlueFOX-lib) + + BUGFIX: mvPropView: OptionTree reacts faster and uses less CPU time. + + NEW FEATURE: TComponentFlag::cfShouldBeDisplayedAsList. (mvPropHandling-lib) + + UPDATE: C++ wrapper header structure reorganized. Now there is only one header + ( mvi_acquire.h ). + + NEW BEHAVIOUR: Certain things in the interface have been changed. Some + will force you to recompile your application, some will + even force you to modify existing code. We are still in the + beta stadium, but we are getting closer to a stable interface. + Some exported function modified or removed from mvPropHandling.h + + BUGFIX: Destroying a DeviceManager object doesn't leave invalid windows (mvDeviceManager-lib) + and threads any more. + + BUGFIX: mvDevMgrGetDevInfo, mvDevMgrSetParam made thread save. + + NEW BEHAVIOUR: Component::canWrite renamed to Component::isWriteable() + + NEW FEATURE: Component::isVisible, CameraSettingsBlueFOX, + AutoControlParameters. (subject to change! See documentation!) + + NEW BEHAVIOUR: Missing units added to some properties. + + BUGFIX: Various minor fixes. + +11.03.2005 1.1.1 + NEW BEHAVIOUR: In mvPropHandlingDataTypes.h the unsigned int constants (mvPropHandling-lib) + for defining the operation mode of search functions have been + renamed to avoid confusion with the TStorageFlag type. The leading + 'sf' has been renamed to 'sm'. The constant 'sfSearchSublists' has + been removed, as the underlying behaviour can be expressed by the + maximum search depth as well. This is an incompatible change which + might force you to modify existing source. + + NEW FEATURE: New TStorageFlag added: sfProcessInheritance. (mvPropHandling-lib) + + BUGFIX: Deadlock removed when multiple threads accessed the property (mvPropHandling-lib) + module. + + DOCUMENTATION UPDATED + + NEW FEATURE: New sample program added (ContinuousCaptureAllDevices), to + demonstrate how to access all supported devices found in the + current system in a single application. + + BUGFIX: PropertyS::read function caused an access violation when building + the result string when a NULL-pointer was returned by the function. + + BUGFIX: Noisy images for certain sensor types of the mvBlueFOX. (mvBlueFOX-lib) + + BUGFIX: Wrong colours in Bayer converted images for 1024*768 sensor. (mvBlueFOX-lib) + +< 11.03.2005 previous versions + diff --git a/Cigarette/MvIMPACT/mvPropHandling/Include/mvPropHandlingDatatypes.h b/Cigarette/MvIMPACT/mvPropHandling/Include/mvPropHandlingDatatypes.h new file mode 100644 index 0000000..d5a9226 --- /dev/null +++ b/Cigarette/MvIMPACT/mvPropHandling/Include/mvPropHandlingDatatypes.h @@ -0,0 +1,1011 @@ +//----------------------------------------------------------------------------- +// (C) Copyright 2005 - 2021 by MATRIX VISION GmbH +// +// This software is provided by MATRIX VISION GmbH "as is" +// and any express or implied warranties, including, but not limited to, the +// implied warranties of merchantability and fitness for a particular purpose +// are disclaimed. +// +// In no event shall MATRIX VISION GmbH 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 mvPropHandlingDatatypesH +#ifndef DOXYGEN_SHOULD_SKIP_THIS +# define mvPropHandlingDatatypesH mvPropHandlingDatatypesH +#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +//----------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +namespace mvIMPACT +{ +namespace acquire +{ +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +typedef __int64 int64_type; +typedef unsigned __int64 uint64_type; +# ifdef __BORLANDC__ // is Borland compiler? +# pragma option push -b // force enums to the size of integer +# endif // __BORLANDC__ +# elif defined(linux) || defined(__linux) || defined(__linux__) +# ifndef WRAP_ANY +# include +# endif // #ifndef WRAP_ANY +typedef int64_t int64_type; +typedef uint64_t uint64_type; +# else +# error "unsupported target environment" +# endif // #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +//============================================================================= +//========================= constants ========================================= +//============================================================================= +#ifdef __cplusplus +/// \brief A constant to check for an invalid ID returned from the property handling module. +const int INVALID_ID = -1; +# if !defined(DOXYGEN_CPP_DOCUMENTATION) && !defined(WRAP_ANY) +// property limits +/// \brief The index value to query the maximum value defined for this property. +const int PROP_MAX_VAL = -1; +/// \brief The index value to query the minimum value defined for this property. +const int PROP_MIN_VAL = -2; +/// \brief The index value to query the step width value defined for this property. +const int PROP_STEP_WIDTH = -3; +# ifndef DOXYGEN_SHOULD_SKIP_THIS +const int PROP_DEFAULT_VALUE = -4; +const int PROP_MAX_BINARY_BUFFER_SIZE = -5; +const int PROP_LAST_CONSTANT = PROP_MAX_BINARY_BUFFER_SIZE; +# endif // #ifdef DOXYGEN_SHOULD_SKIP_THIS +/// \brief Defines a default length for a string buffer. +/** + * The default max. length of a string returned by a call to functions, which + * call the C-layer and need to pass an allocated string buffer to that function. + */ +const unsigned int DEFAULT_STRING_SIZE_LIMIT = 8192; +# endif // #if !defined(DOXYGEN_CPP_DOCUMENTATION) && !defined(WRAP_ANY) +/// \brief A constant defining the unique identifier for the root component list containing all other lists. +const int ROOT_LIST = 0; +/// \brief A constant defining that property values will be read from an array property until the last value. +const int END_OF_LIST = -1; +// flags to define the search mode +/// \brief When set lists are not taken into account during a search. +/** + * When this flag is set list objects will not be taken into + * account during a search for a component. + */ +const unsigned int smIgnoreLists = 0x2; +/// \brief When set method objects are not taken into account during a search. +/** + * When this flag is set method objects will not be taken into + * account during a search for a component. + */ +const unsigned int smIgnoreMethods = 0x4; +/// \brief When set property objects are not taken into account during a search. +/** + * When this flag is set property objects will not be taken into + * account during a search for a component. + */ +const unsigned int smIgnoreProperties = 0x8; +#else // C compatible set of constants +# ifndef DOXYGEN_SHOULD_SKIP_THIS +# define INVALID_ID (-1) +# define PROP_MAX_VAL (-1) +# define PROP_MIN_VAL (-2) +# define PROP_STEP_WIDTH (-3) +# define PROP_DEFAULT_VALUE (-4) +# define PROP_MAX_BINARY_BUFFER_SIZE (-5) +# define PROP_LAST_CONSTANT (PROP_MAX_BINARY_BUFFER_SIZE) +# define DEFAULT_STRING_SIZE_LIMIT (8192) +# define END_OF_LIST (-1) +# define ROOT_LIST (0) +# define smIgnoreLists (0x2) +# define smIgnoreMethods (0x4) +# define smIgnoreProperties (0x8) +# endif // DOXYGEN_SHOULD_SKIP_THIS +#endif // #ifdef __cplusplus + +//============================================================================= +//========================= enumerations ====================================== +//============================================================================= +//----------------------------------------------------------------------------- +/// \brief Defines the type of callback to register. +/// \ingroup CommonInterface +enum TCallbackType +//----------------------------------------------------------------------------- +{ + /// \brief Execute callback whenever this component has been modified. + ctOnChanged = 0, + /// \brief Executed when a property's value is read. The callback is executed before the value is returned to the user. + /// This allows i.e. a driver to determine the value for this property only if the user is interested in its data. + ctOnReadData = 1, + /// \brief Executed when a property's value is written. The callback is executed before the value is actually assigned. + /// This allows i.e. a driver to validate if this is a valid value for the property. + ctOnWriteData = 2, + /// \brief Executed when a component is accessed (read or write) and some of the internal data needs to be refreshed from an external source. + /// The callback is executed before the component data is accessed. This allows i.e. a driver to update the data before. + ctOnRefreshCache = 3 +}; + +//----------------------------------------------------------------------------- +/// \enum TComponentFlag +/// \brief Flags defining access rights and other component properties +/** + * Flags defining access rights and other component properties + */ +/// \ingroup CommonInterface +enum TComponentFlag // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief This is used to define an inconsistent/invalid flag. + /** + * This e.g. can be used as a return value for a function, that could not + * calculate a valid flag mask. + */ + cfUndefined = 0x0, + /// \brief This component can be accessed for reading. + /** + * If this flag is set this component can be accessed for reading. This + * involves reading a property's data, reading a component list's elements + * reading the size of a component list and so on. + */ + cfReadAccess = 0x1, + /// \brief This component can be accessed for writing. + /** + * If this flag is set this component can be accessed for writing or modifying its data. + * This involves writing values to a property, adding components to a list and so on. + */ + cfWriteAccess = 0x2, + /// \brief This component can be accessed for both reading and writing. + /** + * This just combines mvIMPACT::acquire::cfReadAccess and + * mvIMPACT::acquire::cfWriteAccess + */ + cfRWAccess = cfReadAccess | cfWriteAccess, + /// \brief This components element count can be modified. + /** + * If this flag is set this components element count can't be modified. For a list this would mean, + * that the number of elements stored in this list can't be modified. For a property this means, + * that the number of values stored in the property can't be modified. + */ + cfFixedSize = 0x4, + //cfUserAllocatedMemory = 0x8, // no longer supported + /// \brief The component is shadowed by other settings currently if set. + /** + * This flag is used to specify that this component currently has no effect on the behaviour + * of the system. This flag is just meant as a hint for the user. The property module + * itself does NOT use this flag for anything. + */ + cfInvisible = 0x10, + /// \brief Allows combinations of translation dictionary entry as valid values. + /** + * If this flag is set for a property that defines a translation dictionary not + * only values, which are registered in the translation dictionary are allowed + * values for this property, but also values logical OR-ed together with values from + * the translation dictionary (these obviously can't be set as strings). + * + * A property defines two entries ("one", 1) and ("two", 2) then 1 | 2 = 3 will be a + * valid value as well, but "three" obviously won't. + * + * In a GUI application a property specifying this flag should be displayed + * as a set of check-box controls (one for each dictionary entry) or something + * similar. + * + * \note + * If this flag is specified for a component, which is not a property, it will have no + * effect on the behaviour of the component. Only integer properties can use this feature + */ + cfAllowValueCombinations = 0x20, + /// \brief Informs a displaying GUI that this component should be displayed as a list. + /** + * This flag e.g. can be set for an array property to inform a displaying GUI, that + * this property is best displayed as a list with a entry for each element. + * This flag is just meant as a hint for the user. The property module + * itself does NOT use this flag for anything. + */ + cfShouldBeDisplayedAsList = 0x40, + /// \brief If set this component or derived components can't be stored as external data. + cfDisallowSerialize = 0x80, + /// \brief If set this component is always cloned completely. + /** + * This results in the component being completely independent from its parent no matter + * whether it has been built while deriving or cloning a list and thus the components + * within this list and its sub-lists. + * + * This will change the behaviour to that effect that changing the parent component + * will no longer affect the 'derived' component. So + * different default values, constants and translation dictionaries for properties + * within an inheritance hierarchy can be defined. + * + * \note + * This feature is currently only supported for components of type + * mvIMPACT::acquire::ctPropInt, mvIMPACT::acquire::ctPropInt64 + * and mvIMPACT::acquire::ctPropFloat. + */ + cfAlwaysForceClone = 0x100, + /// \brief If set, this component is currently not available due to the setting of another feature. + /** + * In this case this feature can't be written to nor can it be read. + */ + cfNotAvailable = 0x200, + /// \brief If set, this feature has been defined, but so far has not been implemented. + cfNotImplemented = 0x400, + /// \brief Specifies a property, which contains binary data. + /** + * This flag is used to specify a property that contains data in binary format + */ + cfContainsBinaryData = 0x800, + /// \brief Informs a displaying GUI that this component should be displayed as an enumeration(e.g. with a combo box). + /** + * This flag e.g. can be set for a property to inform a displaying GUI, that + * this property is best displayed as a combo box or something similar. + * This flag is just meant as a hint for the user. The property module + * itself does NOT use this flag for anything. + * + * \since 1.12.57 + * + */ + cfShouldBeDisplayedAsEnumeration = 0x1000, + /// \brief This feature will \b ALWAYS execute internal update callbacks and will treat each write attempt to this feature as a value different from the current one. + cfAlwaysForceUpdate = 0x2000 +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + , cfLast = cfShouldBeDisplayedAsEnumeration +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +}; + +//----------------------------------------------------------------------------- +/// \brief Allowed values types for property objects +/// \ingroup CommonInterface +enum TValueType // flags_attribute, uint_type, internal_attribute +//----------------------------------------------------------------------------- +{ + /// \brief Defines a property for 32 bit integer types. + vtInt = 0x1, + /// \brief Defines a property for float types. + vtFloat, + /// \brief Defines a property for pointer types. + vtPtr, + /// \brief Defines a property for strings. + vtString, + /// \brief Defines a property for 64 bit integer types. + vtInt64 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid recommended representations for features. +/** + * These representations can be used to create a suitable GUI editor for a features. + * + * \since 2.14.0 + */ +/// \ingroup CommonInterface +enum TComponentRepresentation +//----------------------------------------------------------------------------- +{ + crUndefined = 0, + /// \brief Defines a feature with linear behaviour. One possible editor would be a slider with linear behaviour. + crLinear, + /// \brief Defines a feature with logarithmic behaviour. One possible editor would be a slider with logarithmic behaviour. + crLogarithmic, + /// \brief Defines a boolean feature. This could be displayed to the user as a check box. + crBoolean, + /// \brief Defines a feature representing a pure number. This could be displayed to the user as an edit control. + crPureNumber, + /// \brief Defines a feature representing a hexadecimal number. + crHexNumber, + /// \brief Defines a feature representing an IPv4 address. This could be displayed to the user as a custom IPv4 edit control. + crIPv4Address, + /// \brief Defines a feature representing a MAC address. This could be displayed to the user as a custom MAC address edit control. + crMACAddress, + /// \brief Defines a feature representing a file name. This could be displayed to the user as a file selection dialog. + crFileName, + /// \brief Defines a feature representing a directory name. This could be displayed to the user as a directory selection dialog. + crDirectoryName +}; + +//----------------------------------------------------------------------------- +/// \brief Allowed components handled by this module. +/** + * This module can handle the types listed in this enumeration only. + */ +/// \ingroup CommonInterface +enum TComponentType // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief A property type. + /** + * This type will never occur in a real world application. It's just used + * to build up the other types. Properties can be used to store user specific + * data in a structured way. + */ + ctProp = 0x00010000, + /// \brief A list object. + /** + * Lists can contain other components like lists, methods and properties. + * Thus lists can be used to build up hierarchical structures of different + * components. + */ + ctList = 0x00020000, + /// \brief A method object. + /** + * Method objects provide the possibility to organize functions in lists. + */ + ctMeth = 0x00040000, + /// \brief Defines a property for 32 bit integer values. + ctPropInt = ctProp | vtInt, // dot_net_code:ctPropInt = ctProp | TValueType.vtInt, + /// \brief Defines a property for floating point values. + ctPropFloat = ctProp | vtFloat, // dot_net_code:ctPropFloat = ctProp | TValueType.vtFloat, + /// \brief Defines a property for string values. + ctPropString = ctProp | vtString, // dot_net_code:ctPropString = ctProp | TValueType.vtString, + /// \brief Defines a property for pointer values. + ctPropPtr = ctProp | vtPtr, // dot_net_code:ctPropPtr = ctProp | TValueType.vtPtr, + /// \brief Defines a property for 64 bit integer values. + ctPropInt64 = ctProp | vtInt64 // dot_net_code:ctPropInt64 = ctProp | TValueType.vtInt64 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid recommended visibilities for features. +/** + * These visibilities can be used to create GUIs in which the user can select the + * amount of features he wants to access. + */ +/// \ingroup CommonInterface +enum TComponentVisibility +//----------------------------------------------------------------------------- +{ + /// \brief Defines a feature that should be visible for all users via the GUI and API. This is the default visibility if no visibility has been specified for a particular component. + cvBeginner = 0, + /// \brief Defines a feature that requires a more in-depth knowledge of the functionality. This is the preferred visibility level for all advanced features. + cvExpert = 1, + /// \brief Defines an advanced feature that if not configured correctly might result in unexpected behaviour. + cvGuru = 2, + /// \brief Defines a feature that should not be displayed in a GUI but is still accessible via API function calls. + cvInvisible = 3 +}; + +//----------------------------------------------------------------------------- +/// \brief Error codes of the module handling everything related to properties. +/// \ingroup CommonInterface +enum TPROPHANDLING_ERROR +//----------------------------------------------------------------------------- +{ + /// \brief The operation has been executed successfully. + /** + * \b [0] + */ + PROPHANDLING_NO_ERROR = 0, + /// \brief This component is not a list. + /** + * A list operation for this component has been called but this + * component does not reference a list. + * + * \n \b [-2000] + */ + PROPHANDLING_NOT_A_LIST = -2000, + /// \brief This component is not a property. + /** + * A property operation for this component has been called but + * this component does not reference a property. + * + * \n \b [-2001] + */ + PROPHANDLING_NOT_A_PROPERTY = -2001, + /// \brief This component is not a method. + /** + * A method operation for this component has been called but + * this component does not reference a method. + * + * \n \b [-2002] + */ + PROPHANDLING_NOT_A_METHOD = -2002, + /// \brief The caller has no read rights for this component. + /** + * It has been tried to read data from this component, but the + * caller has no read rights for this component. + * + * \n \b [-2003] + */ + PROPHANDLING_NO_READ_RIGHTS = -2003, + /// \brief The caller has no write rights for this component. + /** + * It has been tried to modify data of this component, but the + * caller has no write rights for this component. + * + * \n \b [-2004] + */ + PROPHANDLING_NO_WRITE_RIGHTS = -2004, + /// \brief The caller can't modify the size of this component. + /** + * It has been tried to modify the size of this list or + * the number of values stored by a property, but the caller doesn't + * have the required right to do this. + * + * This error will also be reported if the user tried to increase + * the number of values handled by a property above the maximum number + * of values it can handle. Therefore before resizing a property + * check if the new size might exceeds this maximum value by calling + * the appropriate function. + * + * \n \b [-2005] + */ + PROPHANDLING_NO_MODIFY_SIZE_RIGHTS = -2005, + /// \brief The two involved components are not compatible. + /** + * An operation requiring two compatible components has been + * called with two components, which are not compatible. + * + * \n \b [-2006] + */ + PROPHANDLING_INCOMPATIBLE_COMPONENTS = -2006, + //PROPHANDLING_NO_USER_ALLOCATED_MEMORY = -2007, // no longer supported + /// \brief One or more of the specified parameters are not supported by the function. + /** + * This error might also be generated if a certain feature is not available on the current + * platform. + * + * \n \b [-2008] + */ + PROPHANDLING_UNSUPPORTED_PARAMETER = -2008, + /// \brief Different sized value buffers have been passed. + /** + * While trying to read value pairs the caller passed two different + * sized value buffers to a function while one is too small to hold + * all the information. + * + * \n \b [-2009] + */ + PROPHANDLING_SIZE_MISMATCH = -2009, + /// \brief A feature that is not implemented so far has been requested. + /** + * The caller requested a feature, that hasn't been implemented so + * far. This error code is only provided for compatibility and will be + * set in very rare cases only. + * + * \n \b [-2010] + */ + PROPHANDLING_IMPLEMENTATION_MISSING = -2010, + /// \brief An access token object couldn't be created. + /** + * This can either happen, because the caller has not the rights required + * to create an access token or because the system runs very low on memory. + * + * \deprecated This error code currently is not used anywhere within this framework. + * It might be removed in a future version. + * + * \n \b [-2011] + */ + PROPHANDLING_ACCESSTOKEN_CREATION_FAILED = -2011, + /// \brief It has been tried to assign an invalid value to a property. + /** + * This can either happen if the value lies above or below the + * min. or max. value for a property or when it has been tried to + * write a value to a property, which is not in the properties translation + * dictionary (if it defines one). + * + * To find out, which values are allowed for the property in question + * the user should + * + * • check if the property defines a translation dictionary \n + * • check the allowed values within a translation dictionary if one is defined \n + * • check the min and max value for properties, that define limits \n + * + * \n \b [-2012] + */ + PROPHANDLING_INVALID_PROP_VALUE = -2012, + /// \brief The properties translation table has been corrupted. + /** + * The properties translation table has been corrupted for an unknown + * reason and can't be used anymore. + * + * \n \b [-2013] + */ + PROPHANDLING_PROP_TRANSLATION_TABLE_CORRUPTED = -2013, + /// \brief Invalid value index. + /** + * The caller tried to read a value from an invalid index from a property. + * Most properties store one value only, thus the only valid positive value + * index will be 0 (some negative index values are reserved for special + * values like e.g. the min/max value of a property). However some properties + * might store more than one value, thus the max. allowed index might + * be higher. The highest index allowed will always be the value count + * of a property minus one for properties with the mvIMPACT::acquire::cfFixedSize + * flag set. Other properties will automatically adjust the size once the user + * writes to an index out of bounds. + * + * \n \b [-2014] + */ + PROPHANDLING_PROP_VAL_ID_OUT_OF_BOUNDS = -2014, + /// \brief This property doesn't define a translation table. + /** + * The caller tried to modify a translation table, that hasn't been + * defined for this property. + * + * \n \b [-2015] + */ + PROPHANDLING_PROP_TRANSLATION_TABLE_NOT_DEFINED = -2015, + /// \brief An invalid value has been passed to the property. + /** + * Although properties are quite tolerant regarding the allowed assignment + * for them some value types can't be used to write all properties. + * As an example assigning a float value to an integer property would + * result in this error. + * + * Another reason for this error might be when a user tried to access e.g. a + * float property with functions meant to be used for int properties. + * + * \n \b [-2016] + */ + PROPHANDLING_INVALID_PROP_VALUE_TYPE = -2016, + /// \brief A too large value has been passed. + /** + * One or more of the values the caller tried to write to the + * property are larger than the max. allowed value for this property. + * + * \n \b [-2017] + */ + PROPHANDLING_PROP_VAL_TOO_LARGE = -2017, + /// \brief A too small value has been passed. + /** + * One or more of the values the caller tried to write to the + * property are smaller than the min. allowed value for this property. + * + * \n \b [-2018] + */ + PROPHANDLING_PROP_VAL_TOO_SMALL = -2018, + /// \brief The specified component could not be found. + /** + * \n \b [-2019] + */ + PROPHANDLING_COMPONENT_NOT_FOUND = -2019, + /// \brief An invalid list has been referenced. + /** + * \n \b [-2020] + */ + PROPHANDLING_LIST_ID_INVALID = -2020, + /// \brief An invalid component within a list has been referenced. + /** + * \n \b [-2021] + */ + PROPHANDLING_COMPONENT_ID_INVALID = -2021, + /// \brief The specified list index is occupied. + /** + * During the creation of a new component the caller tried + * the insert the newly created component into a list at a position + * already used to store another component. + * + * \n \b [-2022] + */ + PROPHANDLING_LIST_ENTRY_OCCUPIED = -2022, + /// \brief The specified component already has an owner. + /** + * The caller tried to assign an owner to a component that + * already has an owner. An owner once defined can't be modified + * anymore. + * + * \n \b [-2023] + */ + PROPHANDLING_COMPONENT_HAS_OWNER_ALREADY = -2023, + /// \brief It has been tried to register the same component at twice in the same list. + /** + * \n \b [-2024] + */ + PROPHANDLING_COMPONENT_ALREADY_REGISTERED = -2024, + /// \brief The desired data can't be accessed or found. + /** + * During loading or saving data this error can occur e.g. + * if it has been tried to import a setting from a location where + * the desired setting couldn't be found. Another reason for this error might + * be that the current user is not allowed to perform a certain operation on the + * desired data (e.g. a user tries to delete a setting that is stored with + * global scope but does not have elevated access rights). + * + * \n \b [-2025] + */ + PROPHANDLING_LIST_CANT_ACCESS_DATA = -2025, + /// \brief The function pointer of the referenced method object is invalid. + /** + * \n \b [-2026] + */ + PROPHANDLING_METHOD_PTR_INVALID = -2026, + /// \brief A method object has an invalid parameter list. + /** + * \n \b [-2027] + */ + PROPHANDLING_METHOD_INVALID_PARAM_LIST = -2027, + /// \brief This indicates an internal error occurred within the SWIG generated wrapper code, when working under Python. + /** + * \n \b [-2028] + */ + PROPHANDLING_SWIG_ERROR = -2028, + /// \brief A invalid input parameter has been passed to a function of this module. + /** + * In most cases this might be a unassigned pointer, where a valid pointer + * to a user defined storage location was expected. + * + * \n \b [-2029] + */ + PROPHANDLING_INVALID_INPUT_PARAMETER = -2029, + /// \brief The user tried to modify a registered callback, but no callback has been registered for this component. + /** + * \n \b [-2030] + */ + PROPHANDLING_COMPONENT_NO_CALLBACK_REGISTERED = -2030, + /// \brief The user tried to read data into a user supplied storage location, but the buffer was too small to accommodate the result. + /** + * \n \b [-2031] + */ + PROPHANDLING_INPUT_BUFFER_TOO_SMALL = -2031, + /// \brief The number of parameters is incorrect. + /** + * This error might occur if the user called a function with a variable number of input or output + * parameters and the number of parameters passed to the function does not match the + * number of required parameters. + * + * \n \b [-2032] + */ + PROPHANDLING_WRONG_PARAM_COUNT = -2032, + /// \brief The user tried to execute an operation, which is not supported by the component he is referring to. + /** + * \n \b [-2033] + */ + PROPHANDLING_UNSUPPORTED_OPERATION = -2033, + /// \brief The user tried to save(serialize) a property list without having the right to do this. + /** + * \n \b [-2034] + */ + PROPHANDLING_CANT_SERIALIZE_DATA = -2034, + /// \brief The user tried to use a file to update or create a component list, that does not contain valid data for this operation. + /** + * This e.g. might happen, if the file does not contain valid XML data or XML data that is not + * well formed. + * + * \n \b [-2035] + */ + PROPHANDLING_INVALID_FILE_CONTENT = -2035, + /// \brief This error will occur when the modules internal representation of the tree structure does not allow the allocation of a new list. + /** + * In this case either new list can't be allocated. The only way to solve this problem is to delete + * another list. + * + * \n \b [-2036] + */ + PROPHANDLING_CANT_ALLOCATE_LIST = -2036, + /// \brief The referenced list has no space left to register this component at the desired position. + /** + * There might however be an empty space within the list where this element could be registered, but + * no more components can be registered at the end of this list. + * + * \n \b [-2037] + */ + PROPHANDLING_CANT_REGISTER_COMPONENT = -2037, + /// \brief The user tried to assign a value to a property, that is invalid. + /** + * This will result in a detailed error message in the log-file. This error might + * arise e.g. when a string property doesn't allow the string to contain numbers. In this + * case trying to set the properties value to 'blabla7bla' would cause this error. + * + * \n \b [-2038] + */ + PROPHANDLING_PROP_VALIDATION_FAILED = -2038, + // If new error codes must be added this happens HERE! + // When adding a new value here NEVER forget to update the internal string AND exception table! +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Needed for compile time checks for invalid error code values + PROPHANDLING_PSEUDO_LAST_ASSIGNED_ERROR_CODE, + /// \brief A dummy constant to mark the last error code currently defined for property module related errors. + PROPHANDLING_LAST_ASSIGNED_ERROR_CODE = PROPHANDLING_PSEUDO_LAST_ASSIGNED_ERROR_CODE - 2, +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Defines the last valid error code value for the property module. + /** + * \n \b [-2099] + */ + PROPHANDLING_LAST_VALID_ERROR_CODE = -2099 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the way component lists are imported and exported. +/** + * Component lists can be imported and exported from/to XML files and + * (under Windows©) from/into the Registry. These flags define how + * this is done. + */ +/// \ingroup CommonInterface +enum TStorageFlag // flags_attribute, uint_type +//----------------------------------------------------------------------------- +{ + /// \brief A dummy flag to specify the default behaviour. + /** + * Store/load operations will done in XML format in this case. + */ + sfDefault = 0x00000000, + /// \brief Stores/loads the setting in/from a platform dependent location + /** + * Under Windows© the Registry will be used to as a platform dependent location, while under + * other platforms an XML file will be processed in the path specified as the settings name. + * + * \note + * Please note, that using this flag will introduce platform dependency. E.g. specifying this flag + * under Linux will process XML data, while under Windows© the Registry will be used. This is why + * A call to a load function with this flag with the corresponding XML file in the applications directory + * might succeed under Linux while it fails under Windows©. + */ + sfNative = 0x00000001, + /// \brief Stores/loads the setting in raw mode. + /** + * \note + * Under Windows© this mode only works in connection with the mvIMPACT::acquire::sfNative flag. + * In that case an arbitrary hive from the registry can be used to create a tree of lists and + * properties. This only makes sense for very special applications and therefore is not needed to + * write applications, that load and store current settings. + */ + sfRaw = 0x00000002, + /// \brief Stores lists volatile. + /** + * under Windows© when the mvIMPACT::acquire::sfNative flag is set this will store the + * component list as a volatile key in the Registry. This means that the data will remain in the + * Registry until the system is shut down. + */ + sfVolatile = 0x00000004, + /// \brief If set properties translation dictionaries will be processed for this import/export operation. + /** + * This option forces the function to process the translation dictionaries, which might + * be assigned to properties. + */ + sfProcessPropTranslationDict = 0x00000008, + /// \brief If set ALL entries in the store data will be created. + /** + * When loading a setting not only the current lists data will be updated, but also + * properties, lists or data, which is found in the storage location but not in the setting + * to update will be added to the setting as well. + */ + sfCreateMissingEntries = 0x00000010, + /// \brief If set read-only components will be processed for this import/export operation. + /** + * When importing, exporting or updating a component list components with the + * mvIMPACT::acquire::cfWriteAccess not set will be ignored. + */ + sfProcessReadOnlyComponents = 0x00000020, + /// \brief If set data for properties will no be updated. + /** + * If this flag is set the values stored by the property will be ignored for this import/export operation. + * \note + * This flag is ignored, if mvIMPACT::acquire::sfNative is specified. + */ + sfIgnorePropData = 0x00000040, + /// \brief If set the documentation string will be processed. + /** + * If this flag is set the documentation string will be processed for this import/export operation. + * \note + * This flag is ignored, if mvIMPACT::acquire::sfNative is specified. + */ + sfProcessDocString = 0x00000080, + /// \brief If set the defined constants for properties will be processed. + /** + * If this flag is set the defined constants for properties will be processed + * for this import/export operation. + */ + sfProcessPropConstantsDict = 0x00000100, + /// \brief If set the lists inheritance relationship will be processed. + /** + * If this flag is set the inheritance relationship between lists will be + * processed for the current import/export operation. + * + * \note + * Limitations: + * - derived lists must appear in a list after the parent list. So if a list is derived + * from another list, it has to be registered with a higher index either in the same list + * as the parent or in a list with a higher index then the list holding the parent in a top + * level list.

+ * Example for a legal structure: + * \code + * A + * |-B + * | |-parent + * | |-child + * |-C + * | |-child + * |-child + * \endcode

+ * Example for illegal structures: + * \code + * A + * |-child + * |-parent + * \endcode + * or + * \code + * A + * |-B + * | |-child + * |-parent + * \endcode + * - this feature is not available when mvIMPACT::acquire::sfNative is specified. + */ + sfProcessInheritance = 0x00000200, + /// \brief Specifies if basic data shall be processed. + /** + * For e.g. settings it's not necessary to import/export information about the value + * type for properties or the size of lists etc. as this information is available internally + * anyway. So interface functions dealing with settings should specify this flag in any case. + */ + sfIgnoreBasicData = 0x00000400, + /// \brief Specifies if invisible components shall be processed. + /** + * When invisible data doesn't need to be processed this flag can be specified. Invisible + * components do not influence the current systems behaviour. + * + * \note + * This feature is currently only supported for output operations and is ignored for input + * operations. + */ + sfIgnoreInvisible = 0x00000800, + /// \brief Stores/loads the setting in/from an XML file. + /** + * If this flag is specified the data will be imported/exported from/to an XML file. + */ + sfFile = 0x00001000, + /// \brief If set the display name will be processed. + /** + * If this flag is set the display name will be processed for this import/export operation. + * \note + * This flag is ignored, if mvIMPACT::acquire::sfNative is specified. + */ + sfProcessDisplayName = 0x00002000, + /// \brief Stores/loads the setting in/from RAM file. + /** + * If this flag is specified the data will be imported/exported from/to RAM. Data stored this way should be + * freed when no longer needed to avoid a waste of memory. However when shutting down mvIMPACT Acquire completely + * (e.g. when unloading the mvPropHandling library from memory all memory allocated by settings stored this way will be + * freed automatically). + * + * \note This flag must not be combined with mvIMPACT::acquire::sfNative or mvIMPACT::acquire::sfFile. + * \since 2.19.0 + */ + sfRAM = 0x4000, +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief For internal use only! + sfReserved1 = 0x00008000, + /// \brief For internal use only! + sfReserved2 = 0x00010000, +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + /// \brief Specifies if the 'is-default' flag for components shall be ignored during import/export operations. + /** + * If this flag is set the 'is-default' flag will not be processed during this import/export operation. + * \note + * This flag is ignored, if mvIMPACT::acquire::sfNative is specified. + */ + sfDontProcessDefault = 0x00020000, + /// \brief Processes GenICam sequencer set related data during a storage operation. + /** + * \note This flag will affect devices operated in GenICam interface layout only! + * \warning Settings stored this way cannot be loaded on systems running mvIMPACT Acquire versions smaller than 2.28.0. + * \since 2.28.0 + */ + sfProcessGenICamSequencerData = 0x00040000, + /// \brief Processes GenICam user set related data during a storage operation. + /** + * \note This flag will affect devices operated in GenICam interface layout only! + * \warning Settings stored this way cannot be loaded on systems running mvIMPACT Acquire versions smaller than 2.28.0. + * \since 2.28.0 + */ + sfProcessGenICamUserSetData = 0x00080000 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines valid storage locations for component list import, export and delete operations. +/** + * Component lists can be imported and exported from/to XML files, process RAM and + * (under Windows©) from/into the Registry. + * + * \since 2.19.0 + */ +/// \ingroup CommonInterface +enum TStorageLocation // uint_type +//----------------------------------------------------------------------------- +{ + /// \brief Stores/loads the setting in/from a platform dependent location + /** + * Under Windows© the Registry will be used to as a platform dependent location, while under + * other platforms an XML file will be processed in the path specified as the settings name. + * + * \note + * Please note, that using this mode will introduce platform dependency. E.g. specifying this mode + * under Linux will process XML data, while under Windows© the Registry will be used. This is why + * A call to a load function with this mode with the corresponding XML file in the applications directory + * might succeed under Linux while it fails under Windows©. + */ + slNative = 0x1, + /// \brief Stores/loads the setting in/from a platform dependent location + /** + * Under Windows© the Registry will be used to as a platform dependent location, while under + * other platforms an XML file will be processed in the path specified as the settings name. + * + * \note + * Please note, that using this mode will introduce platform dependency. E.g. specifying this mode + * under Linux will process XML data, while under Windows© the Registry will be used. This is why + * A call to a load function with this mode with the corresponding XML file in the applications directory + * might succeed under Linux while it fails under Windows©. + * + * \note + * Under Windows© with this mode an arbitrary hive from the registry can be used to create a tree of lists and + * properties. This only makes sense for very special applications and therefore is not needed to + * write applications, that load and store current settings. + */ + slNative_Raw = 0x3, + /// \brief Stores/loads the setting in/from an XML file + /** + * Setting data will be imported/exported from/to an XML file. + */ + slFile = 0x1000, + /// \brief Stores/loads the setting in/from RAM file + /** + * Setting data will be stored in the RAM of the current process. Data stored this way should be + * freed when no longer needed to avoid a waste of memory. However when shutting down mvIMPACT Acquire completely + * (e.g. when unloading the mvPropHandling library from memory all memory allocated by settings stored this way will be + * freed automatically). + */ + slRAM = 0x4000 +}; + +//----------------------------------------------------------------------------- +/// \brief Defines the scope for data import/export operations. +/// \ingroup CommonInterface +enum TScope +//----------------------------------------------------------------------------- +{ + /// \brief Save the setting as global as possible. + sGlobal = 0, + /// \brief Save the setting in a user specific location. + sUser = 1 +}; + +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +typedef enum TCallbackType TCallbackType; +typedef enum TComponentFlag TComponentFlag; +typedef enum TValueType TValueType; +typedef enum TComponentRepresentation TComponentRepresentation; +typedef enum TComponentType TComponentType; +typedef enum TComponentVisibility TComponentVisibility; +typedef enum TPROPHANDLING_ERROR TPROPHANDLING_ERROR; +typedef enum TStorageFlag TStorageFlag; +typedef enum TStorageLocation TStorageLocation; +typedef enum TScope TScope; +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +/// \brief A type to create a unique identifier for a callback. +/** + * \since 1.12.18 + */ +typedef void* CallbackHandle; + +// restore Borland compiler switch 'force enums to the size of integer' +#if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) +# ifdef _WIN32 +# ifdef __BORLANDC__ // is Borland compiler? +# pragma option pop +# endif // __BORLANDC__ +# endif // _WIN32 +#endif // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(WRAP_ANY) + +#if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) +} // namespace acquire +} // namespace mvIMPACT +#endif // #if defined(MVIMPACT_ACQUIRE_H_) || defined(DOXYGEN_CPP_DOCUMENTATION) + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // mvPropHandlingDatatypesH diff --git a/Cigarette/OpenCV455Simple/include/opencv2/calib3d.hpp b/Cigarette/OpenCV455Simple/include/opencv2/calib3d.hpp new file mode 100644 index 0000000..b3709c8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/calib3d.hpp @@ -0,0 +1,4024 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CALIB3D_HPP +#define OPENCV_CALIB3D_HPP + +#include "opencv2/core.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/core/affine.hpp" + +/** + @defgroup calib3d Camera Calibration and 3D Reconstruction + +The functions in this section use a so-called pinhole camera model. The view of a scene +is obtained by projecting a scene's 3D point \f$P_w\f$ into the image plane using a perspective +transformation which forms the corresponding pixel \f$p\f$. Both \f$P_w\f$ and \f$p\f$ are +represented in homogeneous coordinates, i.e. as 3D and 2D homogeneous vector respectively. You will +find a brief introduction to projective geometry, homogeneous vectors and homogeneous +transformations at the end of this section's introduction. For more succinct notation, we often drop +the 'homogeneous' and say vector instead of homogeneous vector. + +The distortion-free projective transformation given by a pinhole camera model is shown below. + +\f[s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w,\f] + +where \f$P_w\f$ is a 3D point expressed with respect to the world coordinate system, +\f$p\f$ is a 2D pixel in the image plane, \f$A\f$ is the camera intrinsic matrix, +\f$R\f$ and \f$t\f$ are the rotation and translation that describe the change of coordinates from +world to camera coordinate systems (or camera frame) and \f$s\f$ is the projective transformation's +arbitrary scaling and not part of the camera model. + +The camera intrinsic matrix \f$A\f$ (notation used as in @cite Zhang2000 and also generally notated +as \f$K\f$) projects 3D points given in the camera coordinate system to 2D pixel coordinates, i.e. + +\f[p = A P_c.\f] + +The camera intrinsic matrix \f$A\f$ is composed of the focal lengths \f$f_x\f$ and \f$f_y\f$, which are +expressed in pixel units, and the principal point \f$(c_x, c_y)\f$, that is usually close to the +image center: + +\f[A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1},\f] + +and thus + +\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} \vecthree{X_c}{Y_c}{Z_c}.\f] + +The matrix of intrinsic parameters does not depend on the scene viewed. So, once estimated, it can +be re-used as long as the focal length is fixed (in case of a zoom lens). Thus, if an image from the +camera is scaled by a factor, all of these parameters need to be scaled (multiplied/divided, +respectively) by the same factor. + +The joint rotation-translation matrix \f$[R|t]\f$ is the matrix product of a projective +transformation and a homogeneous transformation. The 3-by-4 projective transformation maps 3D points +represented in camera coordinates to 2D points in the image plane and represented in normalized +camera coordinates \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$: + +\f[Z_c \begin{bmatrix} +x' \\ +y' \\ +1 +\end{bmatrix} = \begin{bmatrix} +1 & 0 & 0 & 0 \\ +0 & 1 & 0 & 0 \\ +0 & 0 & 1 & 0 +\end{bmatrix} +\begin{bmatrix} +X_c \\ +Y_c \\ +Z_c \\ +1 +\end{bmatrix}.\f] + +The homogeneous transformation is encoded by the extrinsic parameters \f$R\f$ and \f$t\f$ and +represents the change of basis from world coordinate system \f$w\f$ to the camera coordinate sytem +\f$c\f$. Thus, given the representation of the point \f$P\f$ in world coordinates, \f$P_w\f$, we +obtain \f$P\f$'s representation in the camera coordinate system, \f$P_c\f$, by + +\f[P_c = \begin{bmatrix} +R & t \\ +0 & 1 +\end{bmatrix} P_w,\f] + +This homogeneous transformation is composed out of \f$R\f$, a 3-by-3 rotation matrix, and \f$t\f$, a +3-by-1 translation vector: + +\f[\begin{bmatrix} +R & t \\ +0 & 1 +\end{bmatrix} = \begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z \\ +0 & 0 & 0 & 1 +\end{bmatrix}, +\f] + +and therefore + +\f[\begin{bmatrix} +X_c \\ +Y_c \\ +Z_c \\ +1 +\end{bmatrix} = \begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z \\ +0 & 0 & 0 & 1 +\end{bmatrix} +\begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix}.\f] + +Combining the projective transformation and the homogeneous transformation, we obtain the projective +transformation that maps 3D points in world coordinates into 2D points in the image plane and in +normalized camera coordinates: + +\f[Z_c \begin{bmatrix} +x' \\ +y' \\ +1 +\end{bmatrix} = \begin{bmatrix} R|t \end{bmatrix} \begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix} = \begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z +\end{bmatrix} +\begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix},\f] + +with \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$. Putting the equations for instrincs and extrinsics together, we can write out +\f$s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w\f$ as + +\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} +\begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z +\end{bmatrix} +\begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix}.\f] + +If \f$Z_c \ne 0\f$, the transformation above is equivalent to the following, + +\f[\begin{bmatrix} +u \\ +v +\end{bmatrix} = \begin{bmatrix} +f_x X_c/Z_c + c_x \\ +f_y Y_c/Z_c + c_y +\end{bmatrix}\f] + +with + +\f[\vecthree{X_c}{Y_c}{Z_c} = \begin{bmatrix} +R|t +\end{bmatrix} \begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix}.\f] + +The following figure illustrates the pinhole camera model. + +![Pinhole camera model](pics/pinhole_camera_model.png) + +Real lenses usually have some distortion, mostly radial distortion, and slight tangential distortion. +So, the above model is extended as: + +\f[\begin{bmatrix} +u \\ +v +\end{bmatrix} = \begin{bmatrix} +f_x x'' + c_x \\ +f_y y'' + c_y +\end{bmatrix}\f] + +where + +\f[\begin{bmatrix} +x'' \\ +y'' +\end{bmatrix} = \begin{bmatrix} +x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + 2 p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4 \\ +y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\ +\end{bmatrix}\f] + +with + +\f[r^2 = x'^2 + y'^2\f] + +and + +\f[\begin{bmatrix} +x'\\ +y' +\end{bmatrix} = \begin{bmatrix} +X_c/Z_c \\ +Y_c/Z_c +\end{bmatrix},\f] + +if \f$Z_c \ne 0\f$. + +The distortion parameters are the radial coefficients \f$k_1\f$, \f$k_2\f$, \f$k_3\f$, \f$k_4\f$, \f$k_5\f$, and \f$k_6\f$ +,\f$p_1\f$ and \f$p_2\f$ are the tangential distortion coefficients, and \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, +are the thin prism distortion coefficients. Higher-order coefficients are not considered in OpenCV. + +The next figures show two common types of radial distortion: barrel distortion +(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing) +and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing). +Radial distortion is always monotonic for real lenses, +and if the estimator produces a non-monotonic result, +this should be considered a calibration failure. +More generally, radial distortion must be monotonic and the distortion function must be bijective. +A failed estimation result may look deceptively good near the image center +but will work poorly in e.g. AR/SFM applications. +The optimization method used in OpenCV camera calibration does not include these constraints as +the framework does not support the required integer programming and polynomial inequalities. +See [issue #15992](https://github.com/opencv/opencv/issues/15992) for additional information. + +![](pics/distortion_examples.png) +![](pics/distortion_examples2.png) + +In some cases, the image sensor may be tilted in order to focus an oblique plane in front of the +camera (Scheimpflug principle). This can be useful for particle image velocimetry (PIV) or +triangulation with a laser fan. The tilt causes a perspective distortion of \f$x''\f$ and +\f$y''\f$. This distortion can be modeled in the following way, see e.g. @cite Louhichi07. + +\f[\begin{bmatrix} +u \\ +v +\end{bmatrix} = \begin{bmatrix} +f_x x''' + c_x \\ +f_y y''' + c_y +\end{bmatrix},\f] + +where + +\f[s\vecthree{x'''}{y'''}{1} = +\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}(\tau_x, \tau_y)} +{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)} +{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\f] + +and the matrix \f$R(\tau_x, \tau_y)\f$ is defined by two rotations with angular parameter +\f$\tau_x\f$ and \f$\tau_y\f$, respectively, + +\f[ +R(\tau_x, \tau_y) = +\vecthreethree{\cos(\tau_y)}{0}{-\sin(\tau_y)}{0}{1}{0}{\sin(\tau_y)}{0}{\cos(\tau_y)} +\vecthreethree{1}{0}{0}{0}{\cos(\tau_x)}{\sin(\tau_x)}{0}{-\sin(\tau_x)}{\cos(\tau_x)} = +\vecthreethree{\cos(\tau_y)}{\sin(\tau_y)\sin(\tau_x)}{-\sin(\tau_y)\cos(\tau_x)} +{0}{\cos(\tau_x)}{\sin(\tau_x)} +{\sin(\tau_y)}{-\cos(\tau_y)\sin(\tau_x)}{\cos(\tau_y)\cos(\tau_x)}. +\f] + +In the functions below the coefficients are passed or returned as + +\f[(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f] + +vector. That is, if the vector contains four elements, it means that \f$k_3=0\f$ . The distortion +coefficients do not depend on the scene viewed. Thus, they also belong to the intrinsic camera +parameters. And they remain the same regardless of the captured image resolution. If, for example, a +camera has been calibrated on images of 320 x 240 resolution, absolutely the same distortion +coefficients can be used for 640 x 480 images from the same camera while \f$f_x\f$, \f$f_y\f$, +\f$c_x\f$, and \f$c_y\f$ need to be scaled appropriately. + +The functions below use the above model to do the following: + +- Project 3D points to the image plane given intrinsic and extrinsic parameters. +- Compute extrinsic parameters given intrinsic parameters, a few 3D points, and their +projections. +- Estimate intrinsic and extrinsic camera parameters from several views of a known calibration +pattern (every view is described by several 3D-2D point correspondences). +- Estimate the relative position and orientation of the stereo camera "heads" and compute the +*rectification* transformation that makes the camera optical axes parallel. + + Homogeneous Coordinates
+Homogeneous Coordinates are a system of coordinates that are used in projective geometry. Their use +allows to represent points at infinity by finite coordinates and simplifies formulas when compared +to the cartesian counterparts, e.g. they have the advantage that affine transformations can be +expressed as linear homogeneous transformation. + +One obtains the homogeneous vector \f$P_h\f$ by appending a 1 along an n-dimensional cartesian +vector \f$P\f$ e.g. for a 3D cartesian vector the mapping \f$P \rightarrow P_h\f$ is: + +\f[\begin{bmatrix} +X \\ +Y \\ +Z +\end{bmatrix} \rightarrow \begin{bmatrix} +X \\ +Y \\ +Z \\ +1 +\end{bmatrix}.\f] + +For the inverse mapping \f$P_h \rightarrow P\f$, one divides all elements of the homogeneous vector +by its last element, e.g. for a 3D homogeneous vector one gets its 2D cartesian counterpart by: + +\f[\begin{bmatrix} +X \\ +Y \\ +W +\end{bmatrix} \rightarrow \begin{bmatrix} +X / W \\ +Y / W +\end{bmatrix},\f] + +if \f$W \ne 0\f$. + +Due to this mapping, all multiples \f$k P_h\f$, for \f$k \ne 0\f$, of a homogeneous point represent +the same point \f$P_h\f$. An intuitive understanding of this property is that under a projective +transformation, all multiples of \f$P_h\f$ are mapped to the same point. This is the physical +observation one does for pinhole cameras, as all points along a ray through the camera's pinhole are +projected to the same image point, e.g. all points along the red ray in the image of the pinhole +camera model above would be mapped to the same image coordinate. This property is also the source +for the scale ambiguity s in the equation of the pinhole camera model. + +As mentioned, by using homogeneous coordinates we can express any change of basis parameterized by +\f$R\f$ and \f$t\f$ as a linear transformation, e.g. for the change of basis from coordinate system +0 to coordinate system 1 becomes: + +\f[P_1 = R P_0 + t \rightarrow P_{h_1} = \begin{bmatrix} +R & t \\ +0 & 1 +\end{bmatrix} P_{h_0}.\f] + +@note + - Many functions in this module take a camera intrinsic matrix as an input parameter. Although all + functions assume the same structure of this parameter, they may name it differently. The + parameter's description, however, will be clear in that a camera intrinsic matrix with the structure + shown above is required. + - A calibration sample for 3 cameras in a horizontal position can be found at + opencv_source_code/samples/cpp/3calibration.cpp + - A calibration sample based on a sequence of images can be found at + opencv_source_code/samples/cpp/calibration.cpp + - A calibration sample in order to do 3D reconstruction can be found at + opencv_source_code/samples/cpp/build3dmodel.cpp + - A calibration example on stereo calibration can be found at + opencv_source_code/samples/cpp/stereo_calib.cpp + - A calibration example on stereo matching can be found at + opencv_source_code/samples/cpp/stereo_match.cpp + - (Python) A camera calibration sample can be found at + opencv_source_code/samples/python/calibrate.py + + @{ + @defgroup calib3d_fisheye Fisheye camera model + + Definitions: Let P be a point in 3D of coordinates X in the world reference frame (stored in the + matrix X) The coordinate vector of P in the camera reference frame is: + + \f[Xc = R X + T\f] + + where R is the rotation matrix corresponding to the rotation vector om: R = rodrigues(om); call x, y + and z the 3 coordinates of Xc: + + \f[x = Xc_1 \\ y = Xc_2 \\ z = Xc_3\f] + + The pinhole projection coordinates of P is [a; b] where + + \f[a = x / z \ and \ b = y / z \\ r^2 = a^2 + b^2 \\ \theta = atan(r)\f] + + Fisheye distortion: + + \f[\theta_d = \theta (1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8)\f] + + The distorted point coordinates are [x'; y'] where + + \f[x' = (\theta_d / r) a \\ y' = (\theta_d / r) b \f] + + Finally, conversion into pixel coordinates: The final pixel coordinates vector [u; v] where: + + \f[u = f_x (x' + \alpha y') + c_x \\ + v = f_y y' + c_y\f] + + @defgroup calib3d_c C API + + @} + */ + +namespace cv +{ + +//! @addtogroup calib3d +//! @{ + +//! type of the robust estimation algorithm +enum { LMEDS = 4, //!< least-median of squares algorithm + RANSAC = 8, //!< RANSAC algorithm + RHO = 16, //!< RHO algorithm + USAC_DEFAULT = 32, //!< USAC algorithm, default settings + USAC_PARALLEL = 33, //!< USAC, parallel version + USAC_FM_8PTS = 34, //!< USAC, fundamental matrix 8 points + USAC_FAST = 35, //!< USAC, fast settings + USAC_ACCURATE = 36, //!< USAC, accurate settings + USAC_PROSAC = 37, //!< USAC, sorted points, runs PROSAC + USAC_MAGSAC = 38 //!< USAC, runs MAGSAC++ + }; + +enum SolvePnPMethod { + SOLVEPNP_ITERATIVE = 0, //!< Pose refinement using non-linear Levenberg-Marquardt minimization scheme @cite Madsen04 @cite Eade13 \n + //!< Initial solution for non-planar "objectPoints" needs at least 6 points and uses the DLT algorithm. \n + //!< Initial solution for planar "objectPoints" needs at least 4 points and uses pose from homography decomposition. + SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp + SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete + SOLVEPNP_DLS = 3, //!< **Broken implementation. Using this flag will fallback to EPnP.** \n + //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct + SOLVEPNP_UPNP = 4, //!< **Broken implementation. Using this flag will fallback to EPnP.** \n + //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive + SOLVEPNP_AP3P = 5, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17 + SOLVEPNP_IPPE = 6, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n + //!< Object points must be coplanar. + SOLVEPNP_IPPE_SQUARE = 7, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n + //!< This is a special case suitable for marker pose estimation.\n + //!< 4 coplanar object points must be defined in the following order: + //!< - point 0: [-squareLength / 2, squareLength / 2, 0] + //!< - point 1: [ squareLength / 2, squareLength / 2, 0] + //!< - point 2: [ squareLength / 2, -squareLength / 2, 0] + //!< - point 3: [-squareLength / 2, -squareLength / 2, 0] + SOLVEPNP_SQPNP = 8, //!< SQPnP: A Consistently Fast and Globally OptimalSolution to the Perspective-n-Point Problem @cite Terzakis2020SQPnP +#ifndef CV_DOXYGEN + SOLVEPNP_MAX_COUNT //!< Used for count +#endif +}; + +enum { CALIB_CB_ADAPTIVE_THRESH = 1, + CALIB_CB_NORMALIZE_IMAGE = 2, + CALIB_CB_FILTER_QUADS = 4, + CALIB_CB_FAST_CHECK = 8, + CALIB_CB_EXHAUSTIVE = 16, + CALIB_CB_ACCURACY = 32, + CALIB_CB_LARGER = 64, + CALIB_CB_MARKER = 128 + }; + +enum { CALIB_CB_SYMMETRIC_GRID = 1, + CALIB_CB_ASYMMETRIC_GRID = 2, + CALIB_CB_CLUSTERING = 4 + }; + +enum { CALIB_NINTRINSIC = 18, + CALIB_USE_INTRINSIC_GUESS = 0x00001, + CALIB_FIX_ASPECT_RATIO = 0x00002, + CALIB_FIX_PRINCIPAL_POINT = 0x00004, + CALIB_ZERO_TANGENT_DIST = 0x00008, + CALIB_FIX_FOCAL_LENGTH = 0x00010, + CALIB_FIX_K1 = 0x00020, + CALIB_FIX_K2 = 0x00040, + CALIB_FIX_K3 = 0x00080, + CALIB_FIX_K4 = 0x00800, + CALIB_FIX_K5 = 0x01000, + CALIB_FIX_K6 = 0x02000, + CALIB_RATIONAL_MODEL = 0x04000, + CALIB_THIN_PRISM_MODEL = 0x08000, + CALIB_FIX_S1_S2_S3_S4 = 0x10000, + CALIB_TILTED_MODEL = 0x40000, + CALIB_FIX_TAUX_TAUY = 0x80000, + CALIB_USE_QR = 0x100000, //!< use QR instead of SVD decomposition for solving. Faster but potentially less precise + CALIB_FIX_TANGENT_DIST = 0x200000, + // only for stereo + CALIB_FIX_INTRINSIC = 0x00100, + CALIB_SAME_FOCAL_LENGTH = 0x00200, + // for stereo rectification + CALIB_ZERO_DISPARITY = 0x00400, + CALIB_USE_LU = (1 << 17), //!< use LU instead of SVD decomposition for solving. much faster but potentially less precise + CALIB_USE_EXTRINSIC_GUESS = (1 << 22) //!< for stereoCalibrate + }; + +//! the algorithm for finding fundamental matrix +enum { FM_7POINT = 1, //!< 7-point algorithm + FM_8POINT = 2, //!< 8-point algorithm + FM_LMEDS = 4, //!< least-median algorithm. 7-point algorithm is used. + FM_RANSAC = 8 //!< RANSAC algorithm. It needs at least 15 points. 7-point algorithm is used. + }; + +enum HandEyeCalibrationMethod +{ + CALIB_HAND_EYE_TSAI = 0, //!< A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/Eye Calibration @cite Tsai89 + CALIB_HAND_EYE_PARK = 1, //!< Robot Sensor Calibration: Solving AX = XB on the Euclidean Group @cite Park94 + CALIB_HAND_EYE_HORAUD = 2, //!< Hand-eye Calibration @cite Horaud95 + CALIB_HAND_EYE_ANDREFF = 3, //!< On-line Hand-Eye Calibration @cite Andreff99 + CALIB_HAND_EYE_DANIILIDIS = 4 //!< Hand-Eye Calibration Using Dual Quaternions @cite Daniilidis98 +}; + +enum RobotWorldHandEyeCalibrationMethod +{ + CALIB_ROBOT_WORLD_HAND_EYE_SHAH = 0, //!< Solving the robot-world/hand-eye calibration problem using the kronecker product @cite Shah2013SolvingTR + CALIB_ROBOT_WORLD_HAND_EYE_LI = 1 //!< Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product @cite Li2010SimultaneousRA +}; + +enum SamplingMethod { SAMPLING_UNIFORM, SAMPLING_PROGRESSIVE_NAPSAC, SAMPLING_NAPSAC, + SAMPLING_PROSAC }; +enum LocalOptimMethod {LOCAL_OPTIM_NULL, LOCAL_OPTIM_INNER_LO, LOCAL_OPTIM_INNER_AND_ITER_LO, + LOCAL_OPTIM_GC, LOCAL_OPTIM_SIGMA}; +enum ScoreMethod {SCORE_METHOD_RANSAC, SCORE_METHOD_MSAC, SCORE_METHOD_MAGSAC, SCORE_METHOD_LMEDS}; +enum NeighborSearchMethod { NEIGH_FLANN_KNN, NEIGH_GRID, NEIGH_FLANN_RADIUS }; + +struct CV_EXPORTS_W_SIMPLE UsacParams +{ // in alphabetical order + CV_WRAP UsacParams(); + CV_PROP_RW double confidence; + CV_PROP_RW bool isParallel; + CV_PROP_RW int loIterations; + CV_PROP_RW LocalOptimMethod loMethod; + CV_PROP_RW int loSampleSize; + CV_PROP_RW int maxIterations; + CV_PROP_RW NeighborSearchMethod neighborsSearch; + CV_PROP_RW int randomGeneratorState; + CV_PROP_RW SamplingMethod sampler; + CV_PROP_RW ScoreMethod score; + CV_PROP_RW double threshold; +}; + +/** @brief Converts a rotation matrix to a rotation vector or vice versa. + +@param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3). +@param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively. +@param jacobian Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial +derivatives of the output array components with respect to the input array components. + +\f[\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\f] + +Inverse transformation can be also done easily, since + +\f[\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\f] + +A rotation vector is a convenient and most compact representation of a rotation matrix (since any +rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry +optimization procedures like @ref calibrateCamera, @ref stereoCalibrate, or @ref solvePnP . + +@note More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate +can be found in: + - A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi @cite Gallego2014ACF + +@note Useful information on SE(3) and Lie Groups can be found in: + - A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco @cite blanco2010tutorial + - Lie Groups for 2D and 3D Transformation, Ethan Eade @cite Eade17 + - A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan @cite Sol2018AML + */ +CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() ); + + + +/** Levenberg-Marquardt solver. Starting with the specified vector of parameters it + optimizes the target vector criteria "err" + (finds local minima of each target vector component absolute value). + + When needed, it calls user-provided callback. +*/ +class CV_EXPORTS LMSolver : public Algorithm +{ +public: + class CV_EXPORTS Callback + { + public: + virtual ~Callback() {} + /** + computes error and Jacobian for the specified vector of parameters + + @param param the current vector of parameters + @param err output vector of errors: err_i = actual_f_i - ideal_f_i + @param J output Jacobian: J_ij = d(err_i)/d(param_j) + + when J=noArray(), it means that it does not need to be computed. + Dimensionality of error vector and param vector can be different. + The callback should explicitly allocate (with "create" method) each output array + (unless it's noArray()). + */ + virtual bool compute(InputArray param, OutputArray err, OutputArray J) const = 0; + }; + + /** + Runs Levenberg-Marquardt algorithm using the passed vector of parameters as the start point. + The final vector of parameters (whether the algorithm converged or not) is stored at the same + vector. The method returns the number of iterations used. If it's equal to the previously specified + maxIters, there is a big chance the algorithm did not converge. + + @param param initial/final vector of parameters. + + Note that the dimensionality of parameter space is defined by the size of param vector, + and the dimensionality of optimized criteria is defined by the size of err vector + computed by the callback. + */ + virtual int run(InputOutputArray param) const = 0; + + /** + Sets the maximum number of iterations + @param maxIters the number of iterations + */ + virtual void setMaxIters(int maxIters) = 0; + /** + Retrieves the current maximum number of iterations + */ + virtual int getMaxIters() const = 0; + + /** + Creates Levenberg-Marquard solver + + @param cb callback + @param maxIters maximum number of iterations that can be further + modified using setMaxIters() method. + */ + static Ptr create(const Ptr& cb, int maxIters); + static Ptr create(const Ptr& cb, int maxIters, double eps); +}; + + + +/** @example samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp +An example program about pose estimation from coplanar points + +Check @ref tutorial_homography "the corresponding tutorial" for more details +*/ + +/** @brief Finds a perspective transformation between two planes. + +@param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2 +or vector\ . +@param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or +a vector\ . +@param method Method used to compute a homography matrix. The following methods are possible: +- **0** - a regular method using all the points, i.e., the least squares method +- @ref RANSAC - RANSAC-based robust method +- @ref LMEDS - Least-Median robust method +- @ref RHO - PROSAC-based robust method +@param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier +(used in the RANSAC and RHO methods only). That is, if +\f[\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} * \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\f] +then the point \f$i\f$ is considered as an outlier. If srcPoints and dstPoints are measured in pixels, +it usually makes sense to set this parameter somewhere in the range of 1 to 10. +@param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input +mask values are ignored. +@param maxIters The maximum number of RANSAC iterations. +@param confidence Confidence level, between 0 and 1. + +The function finds and returns the perspective transformation \f$H\f$ between the source and the +destination planes: + +\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] + +so that the back-projection error + +\f[\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\f] + +is minimized. If the parameter method is set to the default value 0, the function uses all the point +pairs to compute an initial homography estimate with a simple least-squares scheme. + +However, if not all of the point pairs ( \f$srcPoints_i\f$, \f$dstPoints_i\f$ ) fit the rigid perspective +transformation (that is, there are some outliers), this initial estimate will be poor. In this case, +you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different +random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix +using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the +computed homography (which is the number of inliers for RANSAC or the least median re-projection error for +LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and +the mask of inliers/outliers. + +Regardless of the method, robust or not, the computed homography matrix is refined further (using +inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the +re-projection error even more. + +The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to +distinguish inliers from outliers. The method LMeDS does not need any threshold but it works +correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the +noise is rather small, use the default method (method=0). + +The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is +determined up to a scale. Thus, it is normalized so that \f$h_{33}=1\f$. Note that whenever an \f$H\f$ matrix +cannot be estimated, an empty one will be returned. + +@sa +getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective, +perspectiveTransform + */ +CV_EXPORTS_W Mat findHomography( InputArray srcPoints, InputArray dstPoints, + int method = 0, double ransacReprojThreshold = 3, + OutputArray mask=noArray(), const int maxIters = 2000, + const double confidence = 0.995); + +/** @overload */ +CV_EXPORTS Mat findHomography( InputArray srcPoints, InputArray dstPoints, + OutputArray mask, int method = 0, double ransacReprojThreshold = 3 ); + + +CV_EXPORTS_W Mat findHomography(InputArray srcPoints, InputArray dstPoints, OutputArray mask, + const UsacParams ¶ms); + +/** @brief Computes an RQ decomposition of 3x3 matrices. + +@param src 3x3 input matrix. +@param mtxR Output 3x3 upper-triangular matrix. +@param mtxQ Output 3x3 orthogonal matrix. +@param Qx Optional output 3x3 rotation matrix around x-axis. +@param Qy Optional output 3x3 rotation matrix around y-axis. +@param Qz Optional output 3x3 rotation matrix around z-axis. + +The function computes a RQ decomposition using the given rotations. This function is used in +#decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera +and a rotation matrix. + +It optionally returns three rotation matrices, one for each axis, and the three Euler angles in +degrees (as the return value) that could be used in OpenGL. Note, there is always more than one +sequence of rotations about the three principal axes that results in the same orientation of an +object, e.g. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angles +are only one of the possible solutions. + */ +CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mtxQ, + OutputArray Qx = noArray(), + OutputArray Qy = noArray(), + OutputArray Qz = noArray()); + +/** @brief Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix. + +@param projMatrix 3x4 input projection matrix P. +@param cameraMatrix Output 3x3 camera intrinsic matrix \f$\cameramatrix{A}\f$. +@param rotMatrix Output 3x3 external rotation matrix R. +@param transVect Output 4x1 translation vector T. +@param rotMatrixX Optional 3x3 rotation matrix around x-axis. +@param rotMatrixY Optional 3x3 rotation matrix around y-axis. +@param rotMatrixZ Optional 3x3 rotation matrix around z-axis. +@param eulerAngles Optional three-element vector containing three Euler angles of rotation in +degrees. + +The function computes a decomposition of a projection matrix into a calibration and a rotation +matrix and the position of a camera. + +It optionally returns three rotation matrices, one for each axis, and three Euler angles that could +be used in OpenGL. Note, there is always more than one sequence of rotations about the three +principal axes that results in the same orientation of an object, e.g. see @cite Slabaugh . Returned +tree rotation matrices and corresponding three Euler angles are only one of the possible solutions. + +The function is based on RQDecomp3x3 . + */ +CV_EXPORTS_W void decomposeProjectionMatrix( InputArray projMatrix, OutputArray cameraMatrix, + OutputArray rotMatrix, OutputArray transVect, + OutputArray rotMatrixX = noArray(), + OutputArray rotMatrixY = noArray(), + OutputArray rotMatrixZ = noArray(), + OutputArray eulerAngles =noArray() ); + +/** @brief Computes partial derivatives of the matrix product for each multiplied matrix. + +@param A First multiplied matrix. +@param B Second multiplied matrix. +@param dABdA First output derivative matrix d(A\*B)/dA of size +\f$\texttt{A.rows*B.cols} \times {A.rows*A.cols}\f$ . +@param dABdB Second output derivative matrix d(A\*B)/dB of size +\f$\texttt{A.rows*B.cols} \times {B.rows*B.cols}\f$ . + +The function computes partial derivatives of the elements of the matrix product \f$A*B\f$ with regard to +the elements of each of the two input matrices. The function is used to compute the Jacobian +matrices in #stereoCalibrate but can also be used in any other similar optimization function. + */ +CV_EXPORTS_W void matMulDeriv( InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB ); + +/** @brief Combines two rotation-and-shift transformations. + +@param rvec1 First rotation vector. +@param tvec1 First translation vector. +@param rvec2 Second rotation vector. +@param tvec2 Second translation vector. +@param rvec3 Output rotation vector of the superposition. +@param tvec3 Output translation vector of the superposition. +@param dr3dr1 Optional output derivative of rvec3 with regard to rvec1 +@param dr3dt1 Optional output derivative of rvec3 with regard to tvec1 +@param dr3dr2 Optional output derivative of rvec3 with regard to rvec2 +@param dr3dt2 Optional output derivative of rvec3 with regard to tvec2 +@param dt3dr1 Optional output derivative of tvec3 with regard to rvec1 +@param dt3dt1 Optional output derivative of tvec3 with regard to tvec1 +@param dt3dr2 Optional output derivative of tvec3 with regard to rvec2 +@param dt3dt2 Optional output derivative of tvec3 with regard to tvec2 + +The functions compute: + +\f[\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\f] + +where \f$\mathrm{rodrigues}\f$ denotes a rotation vector to a rotation matrix transformation, and +\f$\mathrm{rodrigues}^{-1}\f$ denotes the inverse transformation. See Rodrigues for details. + +Also, the functions can compute the derivatives of the output vectors with regards to the input +vectors (see matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in +your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a +function that contains a matrix multiplication. + */ +CV_EXPORTS_W void composeRT( InputArray rvec1, InputArray tvec1, + InputArray rvec2, InputArray tvec2, + OutputArray rvec3, OutputArray tvec3, + OutputArray dr3dr1 = noArray(), OutputArray dr3dt1 = noArray(), + OutputArray dr3dr2 = noArray(), OutputArray dr3dt2 = noArray(), + OutputArray dt3dr1 = noArray(), OutputArray dt3dt1 = noArray(), + OutputArray dt3dr2 = noArray(), OutputArray dt3dt2 = noArray() ); + +/** @brief Projects 3D points to an image plane. + +@param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3 +1-channel or 1xN/Nx1 3-channel (or vector\ ), where N is the number of points in the view. +@param rvec The rotation vector (@ref Rodrigues) that, together with tvec, performs a change of +basis from world to camera coordinate system, see @ref calibrateCamera for details. +@param tvec The translation vector, see parameter description above. +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$ . If the vector is empty, the zero distortion coefficients are assumed. +@param imagePoints Output array of image points, 1xN/Nx1 2-channel, or +vector\ . +@param jacobian Optional output 2Nx(10+\) jacobian matrix of derivatives of image +points with respect to components of the rotation vector, translation vector, focal lengths, +coordinates of the principal point and the distortion coefficients. In the old interface different +components of the jacobian are returned via different output parameters. +@param aspectRatio Optional "fixed aspect ratio" parameter. If the parameter is not 0, the +function assumes that the aspect ratio (\f$f_x / f_y\f$) is fixed and correspondingly adjusts the +jacobian matrix. + +The function computes the 2D projections of 3D points to the image plane, given intrinsic and +extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial +derivatives of image points coordinates (as functions of all the input parameters) with respect to +the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global +optimization in @ref calibrateCamera, @ref solvePnP, and @ref stereoCalibrate. The function itself +can also be used to compute a re-projection error, given the current intrinsic and extrinsic +parameters. + +@note By setting rvec = tvec = \f$[0, 0, 0]\f$, or by setting cameraMatrix to a 3x3 identity matrix, +or by passing zero distortion coefficients, one can get various useful partial cases of the +function. This means, one can compute the distorted coordinates for a sparse set of points or apply +a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup. + */ +CV_EXPORTS_W void projectPoints( InputArray objectPoints, + InputArray rvec, InputArray tvec, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray imagePoints, + OutputArray jacobian = noArray(), + double aspectRatio = 0 ); + +/** @example samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp +An example program about homography from the camera displacement + +Check @ref tutorial_homography "the corresponding tutorial" for more details +*/ + +/** @brief Finds an object pose from 3D-2D point correspondences. + +@see @ref calib3d_solvePnP + +This function returns the rotation and the translation vectors that transform a 3D point expressed in the object +coordinate frame to the camera coordinate frame, using different methods: +- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): need 4 input points to return a unique solution. +- @ref SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. +- @ref SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation. +Number of input points must be 4. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] +- for all the other flags, number of input points must be >= 4 and object points can be in any configuration. + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or +1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. +@param tvec Output translation vector. +@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses +the provided rvec and tvec values as initial approximations of the rotation and translation +vectors, respectively, and further optimizes them. +@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags + +More information about Perspective-n-Points is described in @ref calib3d_solvePnP + +@note + - An example of how to use solvePnP for planar augmented reality can be found at + opencv_source_code/samples/python/plane_ar.py + - If you are using Python: + - Numpy array slices won't work as input because solvePnP requires contiguous + arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of + modules/calib3d/src/solvepnp.cpp version 2.4.9) + - The P3P algorithm requires image points to be in an array of shape (N,1,2) due + to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9) + which requires 2-channel information. + - Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of + it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints = + np.ascontiguousarray(D[:,:2]).reshape((N,1,2)) + - The methods @ref SOLVEPNP_DLS and @ref SOLVEPNP_UPNP cannot be used as the current implementations are + unstable and sometimes give completely wrong results. If you pass one of these two + flags, @ref SOLVEPNP_EPNP method will be used instead. + - The minimum number of points is 4 in the general case. In the case of @ref SOLVEPNP_P3P and @ref SOLVEPNP_AP3P + methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions + of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error). + - With @ref SOLVEPNP_ITERATIVE method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points + are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the + global solution to converge. + - With @ref SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar. + - With @ref SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation. + Number of input points must be 4. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] + - With @ref SOLVEPNP_SQPNP input points must be >= 3 + */ +CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvec, OutputArray tvec, + bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE ); + +/** @brief Finds an object pose from 3D-2D point correspondences using the RANSAC scheme. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or +1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. +@param tvec Output translation vector. +@param useExtrinsicGuess Parameter used for @ref SOLVEPNP_ITERATIVE. If true (1), the function uses +the provided rvec and tvec values as initial approximations of the rotation and translation +vectors, respectively, and further optimizes them. +@param iterationsCount Number of iterations. +@param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value +is the maximum allowed distance between the observed and computed point projections to consider it +an inlier. +@param confidence The probability that the algorithm produces a useful result. +@param inliers Output vector that contains indices of inliers in objectPoints and imagePoints . +@param flags Method for solving a PnP problem (see @ref solvePnP ). + +The function estimates an object pose given a set of object points, their corresponding image +projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such +a pose that minimizes reprojection error, that is, the sum of squared distances between the observed +projections imagePoints and the projected (using @ref projectPoints ) objectPoints. The use of RANSAC +makes the function resistant to outliers. + +@note + - An example of how to use solvePNPRansac for object detection can be found at + opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/ + - The default method used to estimate the camera pose for the Minimal Sample Sets step + is #SOLVEPNP_EPNP. Exceptions are: + - if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used. + - if the number of input points is equal to 4, #SOLVEPNP_P3P is used. + - The method used to estimate the camera pose using all the inliers is defined by the + flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case, + the method #SOLVEPNP_EPNP will be used instead. + */ +CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvec, OutputArray tvec, + bool useExtrinsicGuess = false, int iterationsCount = 100, + float reprojectionError = 8.0, double confidence = 0.99, + OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE ); + + +/* +Finds rotation and translation vector. +If cameraMatrix is given then run P3P. Otherwise run linear P6P and output cameraMatrix too. +*/ +CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints, + InputOutputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvec, OutputArray tvec, OutputArray inliers, + const UsacParams ¶ms=UsacParams()); + +/** @brief Finds an object pose from 3 3D-2D point correspondences. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or +1x3/3x1 3-channel. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel. + vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvecs Output rotation vectors (see @ref Rodrigues ) that, together with tvecs, brings points from +the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions. +@param tvecs Output translation vectors. +@param flags Method for solving a P3P problem: +- @ref SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang +"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete). +- @ref SOLVEPNP_AP3P Method is based on the paper of T. Ke and S. Roumeliotis. +"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17). + +The function estimates the object pose given 3 object points, their corresponding image +projections, as well as the camera intrinsic matrix and the distortion coefficients. + +@note +The solutions are sorted by reprojection errors (lowest to highest). + */ +CV_EXPORTS_W int solveP3P( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + int flags ); + +/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame +to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel, +where N is the number of points. vector\ can also be passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can also be passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Input/Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. Input values are used as an initial solution. +@param tvec Input/Output translation vector. Input values are used as an initial solution. +@param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm. + +The function refines the object pose given at least 3 object points, their corresponding image +projections, an initial solution for the rotation and translation vector, +as well as the camera intrinsic matrix and the distortion coefficients. +The function minimizes the projection error with respect to the rotation and the translation vectors, according +to a Levenberg-Marquardt iterative minimization @cite Madsen04 @cite Eade13 process. + */ +CV_EXPORTS_W void solvePnPRefineLM( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + InputOutputArray rvec, InputOutputArray tvec, + TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON)); + +/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame +to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel, +where N is the number of points. vector\ can also be passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can also be passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Input/Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. Input values are used as an initial solution. +@param tvec Input/Output translation vector. Input values are used as an initial solution. +@param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm. +@param VVSlambda Gain for the virtual visual servoing control law, equivalent to the \f$\alpha\f$ +gain in the Damped Gauss-Newton formulation. + +The function refines the object pose given at least 3 object points, their corresponding image +projections, an initial solution for the rotation and translation vector, +as well as the camera intrinsic matrix and the distortion coefficients. +The function minimizes the projection error with respect to the rotation and the translation vectors, using a +virtual visual servoing (VVS) @cite Chaumette06 @cite Marchand16 scheme. + */ +CV_EXPORTS_W void solvePnPRefineVVS( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + InputOutputArray rvec, InputOutputArray tvec, + TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON), + double VVSlambda = 1); + +/** @brief Finds an object pose from 3D-2D point correspondences. + +@see @ref calib3d_solvePnP + +This function returns a list of all the possible solutions (a solution is a +couple), depending on the number of input points and the chosen method: +- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points. +- @ref SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions. +- @ref SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation. +Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] +- for all the other flags, number of input points must be >= 4 and object points can be in any configuration. +Only 1 solution is returned. + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or +1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvecs Vector of output rotation vectors (see @ref Rodrigues ) that, together with tvecs, brings points from +the model coordinate system to the camera coordinate system. +@param tvecs Vector of output translation vectors. +@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses +the provided rvec and tvec values as initial approximations of the rotation and translation +vectors, respectively, and further optimizes them. +@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags +@param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is @ref SOLVEPNP_ITERATIVE +and useExtrinsicGuess is set to true. +@param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is @ref SOLVEPNP_ITERATIVE +and useExtrinsicGuess is set to true. +@param reprojectionError Optional vector of reprojection error, that is the RMS error +(\f$ \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \f$) between the input image points +and the 3D object points projected with the estimated pose. + +More information is described in @ref calib3d_solvePnP + +@note + - An example of how to use solvePnP for planar augmented reality can be found at + opencv_source_code/samples/python/plane_ar.py + - If you are using Python: + - Numpy array slices won't work as input because solvePnP requires contiguous + arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of + modules/calib3d/src/solvepnp.cpp version 2.4.9) + - The P3P algorithm requires image points to be in an array of shape (N,1,2) due + to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9) + which requires 2-channel information. + - Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of + it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints = + np.ascontiguousarray(D[:,:2]).reshape((N,1,2)) + - The methods @ref SOLVEPNP_DLS and @ref SOLVEPNP_UPNP cannot be used as the current implementations are + unstable and sometimes give completely wrong results. If you pass one of these two + flags, @ref SOLVEPNP_EPNP method will be used instead. + - The minimum number of points is 4 in the general case. In the case of @ref SOLVEPNP_P3P and @ref SOLVEPNP_AP3P + methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions + of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error). + - With @ref SOLVEPNP_ITERATIVE method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points + are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the + global solution to converge. + - With @ref SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar. + - With @ref SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation. + Number of input points must be 4. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] + */ +CV_EXPORTS_W int solvePnPGeneric( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE, + InputArray rvec = noArray(), InputArray tvec = noArray(), + OutputArray reprojectionError = noArray() ); + +/** @brief Finds an initial camera intrinsic matrix from 3D-2D point correspondences. + +@param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern +coordinate space. In the old interface all the per-view vectors are concatenated. See +#calibrateCamera for details. +@param imagePoints Vector of vectors of the projections of the calibration pattern points. In the +old interface all the per-view vectors are concatenated. +@param imageSize Image size in pixels used to initialize the principal point. +@param aspectRatio If it is zero or negative, both \f$f_x\f$ and \f$f_y\f$ are estimated independently. +Otherwise, \f$f_x = f_y * \texttt{aspectRatio}\f$ . + +The function estimates and returns an initial camera intrinsic matrix for the camera calibration process. +Currently, the function only supports planar calibration patterns, which are patterns where each +object point has z-coordinate =0. + */ +CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, + Size imageSize, double aspectRatio = 1.0 ); + +/** @brief Finds the positions of internal corners of the chessboard. + +@param image Source chessboard view. It must be an 8-bit grayscale or color image. +@param patternSize Number of inner corners per a chessboard row and column +( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ). +@param corners Output array of detected corners. +@param flags Various operation flags that can be zero or a combination of the following values: +- @ref CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black +and white, rather than a fixed threshold level (computed from the average image brightness). +- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before +applying fixed or adaptive thresholding. +- @ref CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter, +square-like shape) to filter out false quads extracted at the contour retrieval stage. +- @ref CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners, +and shortcut the call if none is found. This can drastically speed up the call in the +degenerate condition when no chessboard is observed. + +The function attempts to determine whether the input image is a view of the chessboard pattern and +locate the internal chessboard corners. The function returns a non-zero value if all of the corners +are found and they are placed in a certain order (row by row, left to right in every row). +Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example, +a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black +squares touch each other. The detected coordinates are approximate, and to determine their positions +more accurately, the function calls cornerSubPix. You also may use the function cornerSubPix with +different parameters if returned coordinates are not accurate enough. + +Sample usage of detecting and drawing chessboard corners: : +@code + Size patternsize(8,6); //interior number of corners + Mat gray = ....; //source image + vector corners; //this will be filled by the detected corners + + //CALIB_CB_FAST_CHECK saves a lot of time on images + //that do not contain any chessboard corners + bool patternfound = findChessboardCorners(gray, patternsize, corners, + CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + + CALIB_CB_FAST_CHECK); + + if(patternfound) + cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), + TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); + + drawChessboardCorners(img, patternsize, Mat(corners), patternfound); +@endcode +@note The function requires white space (like a square-thick border, the wider the better) around +the board to make the detection more robust in various environments. Otherwise, if there is no +border and the background is dark, the outer black squares cannot be segmented properly and so the +square grouping and ordering algorithm fails. + +Use gen_pattern.py (@ref tutorial_camera_calibration_pattern) to create checkerboard. + */ +CV_EXPORTS_W bool findChessboardCorners( InputArray image, Size patternSize, OutputArray corners, + int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE ); + +/* + Checks whether the image contains chessboard of the specific size or not. + If yes, nonzero value is returned. +*/ +CV_EXPORTS_W bool checkChessboard(InputArray img, Size size); + +/** @brief Finds the positions of internal corners of the chessboard using a sector based approach. + +@param image Source chessboard view. It must be an 8-bit grayscale or color image. +@param patternSize Number of inner corners per a chessboard row and column +( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ). +@param corners Output array of detected corners. +@param flags Various operation flags that can be zero or a combination of the following values: +- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection. +- @ref CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate. +- @ref CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects. +- @ref CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description). +- @ref CALIB_CB_MARKER The detected pattern must have a marker (see description). +This should be used if an accurate camera calibration is required. +@param meta Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)). +Each entry stands for one corner of the pattern and can have one of the following values: +- 0 = no meta data attached +- 1 = left-top corner of a black cell +- 2 = left-top corner of a white cell +- 3 = left-top corner of a black cell with a white marker dot +- 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner) + +The function is analog to #findChessboardCorners but uses a localized radon +transformation approximated by box filters being more robust to all sort of +noise, faster on larger images and is able to directly return the sub-pixel +position of the internal chessboard corners. The Method is based on the paper +@cite duda2018 "Accurate Detection and Localization of Checkerboard Corners for +Calibration" demonstrating that the returned sub-pixel positions are more +accurate than the one returned by cornerSubPix allowing a precise camera +calibration for demanding applications. + +In the case, the flags @ref CALIB_CB_LARGER or @ref CALIB_CB_MARKER are given, +the result can be recovered from the optional meta array. Both flags are +helpful to use calibration patterns exceeding the field of view of the camera. +These oversized patterns allow more accurate calibrations as corners can be +utilized, which are as close as possible to the image borders. For a +consistent coordinate system across all images, the optional marker (see image +below) can be used to move the origin of the board to the location where the +black circle is located. + +@note The function requires a white boarder with roughly the same width as one +of the checkerboard fields around the whole board to improve the detection in +various environments. In addition, because of the localized radon +transformation it is beneficial to use round corners for the field corners +which are located on the outside of the board. The following figure illustrates +a sample checkerboard optimized for the detection. However, any other checkerboard +can be used as well. + +Use gen_pattern.py (@ref tutorial_camera_calibration_pattern) to create checkerboard. +![Checkerboard](pics/checkerboard_radon.png) + */ +CV_EXPORTS_AS(findChessboardCornersSBWithMeta) +bool findChessboardCornersSB(InputArray image,Size patternSize, OutputArray corners, + int flags,OutputArray meta); +/** @overload */ +CV_EXPORTS_W inline +bool findChessboardCornersSB(InputArray image, Size patternSize, OutputArray corners, + int flags = 0) +{ + return findChessboardCornersSB(image, patternSize, corners, flags, noArray()); +} + +/** @brief Estimates the sharpness of a detected chessboard. + +Image sharpness, as well as brightness, are a critical parameter for accuracte +camera calibration. For accessing these parameters for filtering out +problematic calibraiton images, this method calculates edge profiles by traveling from +black to white chessboard cell centers. Based on this, the number of pixels is +calculated required to transit from black to white. This width of the +transition area is a good indication of how sharp the chessboard is imaged +and should be below ~3.0 pixels. + +@param image Gray image used to find chessboard corners +@param patternSize Size of a found chessboard pattern +@param corners Corners found by #findChessboardCornersSB +@param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength +@param vertical By default edge responses for horizontal lines are calculated +@param sharpness Optional output array with a sharpness value for calculated edge responses (see description) + +The optional sharpness array is of type CV_32FC1 and has for each calculated +profile one row with the following five entries: +* 0 = x coordinate of the underlying edge in the image +* 1 = y coordinate of the underlying edge in the image +* 2 = width of the transition area (sharpness) +* 3 = signal strength in the black cell (min brightness) +* 4 = signal strength in the white cell (max brightness) + +@return Scalar(average sharpness, average min brightness, average max brightness,0) +*/ +CV_EXPORTS_W Scalar estimateChessboardSharpness(InputArray image, Size patternSize, InputArray corners, + float rise_distance=0.8F,bool vertical=false, + OutputArray sharpness=noArray()); + + +//! finds subpixel-accurate positions of the chessboard corners +CV_EXPORTS_W bool find4QuadCornerSubpix( InputArray img, InputOutputArray corners, Size region_size ); + +/** @brief Renders the detected chessboard corners. + +@param image Destination image. It must be an 8-bit color image. +@param patternSize Number of inner corners per a chessboard row and column +(patternSize = cv::Size(points_per_row,points_per_column)). +@param corners Array of detected corners, the output of #findChessboardCorners. +@param patternWasFound Parameter indicating whether the complete board was found or not. The +return value of #findChessboardCorners should be passed here. + +The function draws individual chessboard corners detected either as red circles if the board was not +found, or as colored corners connected with lines if the board was found. + */ +CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize, + InputArray corners, bool patternWasFound ); + +/** @brief Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP + +@param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered. +@param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters. +\f$\cameramatrix{A}\f$ +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is empty, the zero distortion coefficients are assumed. +@param rvec Rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. +@param tvec Translation vector. +@param length Length of the painted axes in the same unit than tvec (usually in meters). +@param thickness Line thickness of the painted axes. + +This function draws the axes of the world/object coordinate system w.r.t. to the camera frame. +OX is drawn in red, OY in green and OZ in blue. + */ +CV_EXPORTS_W void drawFrameAxes(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs, + InputArray rvec, InputArray tvec, float length, int thickness=3); + +struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters +{ + CV_WRAP CirclesGridFinderParameters(); + CV_PROP_RW cv::Size2f densityNeighborhoodSize; + CV_PROP_RW float minDensity; + CV_PROP_RW int kmeansAttempts; + CV_PROP_RW int minDistanceToAddKeypoint; + CV_PROP_RW int keypointScale; + CV_PROP_RW float minGraphConfidence; + CV_PROP_RW float vertexGain; + CV_PROP_RW float vertexPenalty; + CV_PROP_RW float existingVertexGain; + CV_PROP_RW float edgeGain; + CV_PROP_RW float edgePenalty; + CV_PROP_RW float convexHullFactor; + CV_PROP_RW float minRNGEdgeSwitchDist; + + enum GridType + { + SYMMETRIC_GRID, ASYMMETRIC_GRID + }; + GridType gridType; + + CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING. + CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from prediction. Used by CALIB_CB_CLUSTERING. +}; + +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +typedef CirclesGridFinderParameters CirclesGridFinderParameters2; +#endif + +/** @brief Finds centers in the grid of circles. + +@param image grid view of input circles; it must be an 8-bit grayscale or color image. +@param patternSize number of circles per row and column +( patternSize = Size(points_per_row, points_per_colum) ). +@param centers output array of detected centers. +@param flags various operation flags that can be one of the following values: +- @ref CALIB_CB_SYMMETRIC_GRID uses symmetric pattern of circles. +- @ref CALIB_CB_ASYMMETRIC_GRID uses asymmetric pattern of circles. +- @ref CALIB_CB_CLUSTERING uses a special algorithm for grid detection. It is more robust to +perspective distortions but much more sensitive to background clutter. +@param blobDetector feature detector that finds blobs like dark circles on light background. + If `blobDetector` is NULL then `image` represents Point2f array of candidates. +@param parameters struct for finding circles in a grid pattern. + +The function attempts to determine whether the input image contains a grid of circles. If it is, the +function locates centers of the circles. The function returns a non-zero value if all of the centers +have been found and they have been placed in a certain order (row by row, left to right in every +row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0. + +Sample usage of detecting and drawing the centers of circles: : +@code + Size patternsize(7,7); //number of centers + Mat gray = ...; //source image + vector centers; //this will be filled by the detected centers + + bool patternfound = findCirclesGrid(gray, patternsize, centers); + + drawChessboardCorners(img, patternsize, Mat(centers), patternfound); +@endcode +@note The function requires white space (like a square-thick border, the wider the better) around +the board to make the detection more robust in various environments. + */ +CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, + OutputArray centers, int flags, + const Ptr &blobDetector, + const CirclesGridFinderParameters& parameters); + +/** @overload */ +CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, + OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID, + const Ptr &blobDetector = SimpleBlobDetector::create()); + +/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration +pattern. + +@param objectPoints In the new interface it is a vector of vectors of calibration pattern points in +the calibration pattern coordinate space (e.g. std::vector>). The outer +vector contains as many elements as the number of pattern views. If the same calibration pattern +is shown in each view and it is fully visible, all the vectors will be the same. Although, it is +possible to use partially occluded patterns or even different patterns in different views. Then, +the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's +XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig. +In the old interface all the vectors of object points from different views are concatenated +together. +@param imagePoints In the new interface it is a vector of vectors of the projections of calibration +pattern points (e.g. std::vector>). imagePoints.size() and +objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal, +respectively. In the old interface all the vectors of object points from different views are +concatenated together. +@param imageSize Size of the image used only to initialize the camera intrinsic matrix. +@param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix +\f$\cameramatrix{A}\f$ . If @ref CALIB_USE_INTRINSIC_GUESS +and/or @ref CALIB_FIX_ASPECT_RATIO, @ref CALIB_FIX_PRINCIPAL_POINT or @ref CALIB_FIX_FOCAL_LENGTH +are specified, some or all of fx, fy, cx, cy must be initialized before calling the function. +@param distCoeffs Input/output vector of distortion coefficients +\f$\distcoeffs\f$. +@param rvecs Output vector of rotation vectors (@ref Rodrigues ) estimated for each pattern view +(e.g. std::vector>). That is, each i-th rotation vector together with the corresponding +i-th translation vector (see the next output parameter description) brings the calibration pattern +from the object coordinate space (in which object points are specified) to the camera coordinate +space. In more technical terms, the tuple of the i-th rotation and translation vector performs +a change of basis from object coordinate space to camera coordinate space. Due to its duality, this +tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate +space. +@param tvecs Output vector of translation vectors estimated for each pattern view, see parameter +describtion above. +@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic +parameters. Order of deviations values: +\f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3, + s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero. +@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic +parameters. Order of deviations values: \f$(R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\f$ where M is +the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors. + @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view. +@param flags Different flags that may be zero or a combination of the following values: +- @ref CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of +fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image +center ( imageSize is used), and focal distances are computed in a least-squares fashion. +Note, that if intrinsic parameters are known, there is no need to use this function just to +estimate extrinsic parameters. Use @ref solvePnP instead. +- @ref CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global +optimization. It stays at the center or at a different location specified when + @ref CALIB_USE_INTRINSIC_GUESS is set too. +- @ref CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The +ratio fx/fy stays the same as in the input cameraMatrix . When + @ref CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are +ignored, only their ratio is computed and used further. +- @ref CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \f$(p_1, p_2)\f$ are set +to zeros and stay zero. +- @ref CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if + @ref CALIB_USE_INTRINSIC_GUESS is set. +- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 The corresponding radial distortion +coefficient is not changed during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is +set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the rational model and return 8 coefficients or more. +- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the thin prism model and return 12 coefficients or more. +- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the tilted sensor model and return 14 coefficients. +- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +@param criteria Termination criteria for the iterative optimization algorithm. + +@return the overall RMS re-projection error. + +The function estimates the intrinsic camera parameters and extrinsic parameters for each of the +views. The algorithm is based on @cite Zhang2000 and @cite BouguetMCT . The coordinates of 3D object +points and their corresponding 2D projections in each view must be specified. That may be achieved +by using an object with known geometry and easily detectable feature points. Such an object is +called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as +a calibration rig (see @ref findChessboardCorners). Currently, initialization of intrinsic +parameters (when @ref CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration +patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also +be used as long as initial cameraMatrix is provided. + +The algorithm performs the following steps: + +- Compute the initial intrinsic parameters (the option only available for planar calibration + patterns) or read them from the input parameters. The distortion coefficients are all set to + zeros initially unless some of CALIB_FIX_K? are specified. + +- Estimate the initial camera pose as if the intrinsic parameters have been already known. This is + done using @ref solvePnP . + +- Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, + that is, the total sum of squared distances between the observed feature points imagePoints and + the projected (using the current estimates for camera parameters and the poses) object points + objectPoints. See @ref projectPoints for details. + +@note + If you use a non-square (i.e. non-N-by-N) grid and @ref findChessboardCorners for calibration, + and @ref calibrateCamera returns bad values (zero distortion coefficients, \f$c_x\f$ and + \f$c_y\f$ very far from the image center, and/or large differences between \f$f_x\f$ and + \f$f_y\f$ (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) + instead of using patternSize=cvSize(cols,rows) in @ref findChessboardCorners. + +@sa + calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, + undistort + */ +CV_EXPORTS_AS(calibrateCameraExtended) double calibrateCamera( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray stdDeviationsIntrinsics, + OutputArray stdDeviationsExtrinsics, + OutputArray perViewErrors, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @overload */ +CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. + +This function is an extension of #calibrateCamera with the method of releasing object which was +proposed in @cite strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar +targets (calibration plates), this method can dramatically improve the precision of the estimated +camera parameters. Both the object-releasing method and standard method are supported by this +function. Use the parameter **iFixedPoint** for method selection. In the internal implementation, +#calibrateCamera is a wrapper for this function. + +@param objectPoints Vector of vectors of calibration pattern points in the calibration pattern +coordinate space. See #calibrateCamera for details. If the method of releasing object to be used, +the identical calibration board must be used in each view and it must be fully visible, and all +objectPoints[i] must be the same and all points should be roughly close to a plane. **The calibration +target has to be rigid, or at least static if the camera (rather than the calibration target) is +shifted for grabbing images.** +@param imagePoints Vector of vectors of the projections of calibration pattern points. See +#calibrateCamera for details. +@param imageSize Size of the image used only to initialize the intrinsic camera matrix. +@param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as +a switch for calibration method selection. If object-releasing method to be used, pass in the +parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will +make standard calibration method selected. Usually the top-right corner point of the calibration +board grid is recommended to be fixed when object-releasing method being utilized. According to +\cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front +and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and +newObjPoints are only possible if coordinates of these three fixed points are accurate enough. +@param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details. +@param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details. +@param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera +for details. +@param tvecs Output vector of translation vectors estimated for each pattern view. +@param newObjPoints The updated output vector of calibration pattern points. The coordinates might +be scaled based on three fixed points. The returned coordinates are accurate only if the above +mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter +is ignored with standard calibration method. +@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters. +See #calibrateCamera for details. +@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters. +See #calibrateCamera for details. +@param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates +of calibration pattern points. It has the same size and order as objectPoints[0] vector. This +parameter is ignored with standard calibration method. + @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view. +@param flags Different flags that may be zero or a combination of some predefined values. See +#calibrateCamera for details. If the method of releasing object is used, the calibration time may +be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially +less precise and less stable in some rare cases. +@param criteria Termination criteria for the iterative optimization algorithm. + +@return the overall RMS re-projection error. + +The function estimates the intrinsic camera parameters and extrinsic parameters for each of the +views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See +#calibrateCamera for other detailed explanations. +@sa + calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort + */ +CV_EXPORTS_AS(calibrateCameraROExtended) double calibrateCameraRO( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray newObjPoints, + OutputArray stdDeviationsIntrinsics, + OutputArray stdDeviationsExtrinsics, + OutputArray stdDeviationsObjPoints, + OutputArray perViewErrors, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @overload */ +CV_EXPORTS_W double calibrateCameraRO( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray newObjPoints, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @brief Computes useful camera characteristics from the camera intrinsic matrix. + +@param cameraMatrix Input camera intrinsic matrix that can be estimated by #calibrateCamera or +#stereoCalibrate . +@param imageSize Input image size in pixels. +@param apertureWidth Physical width in mm of the sensor. +@param apertureHeight Physical height in mm of the sensor. +@param fovx Output field of view in degrees along the horizontal sensor axis. +@param fovy Output field of view in degrees along the vertical sensor axis. +@param focalLength Focal length of the lens in mm. +@param principalPoint Principal point in mm. +@param aspectRatio \f$f_y/f_x\f$ + +The function computes various useful camera characteristics from the previously estimated camera +matrix. + +@note + Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for + the chessboard pitch (it can thus be any value). + */ +CV_EXPORTS_W void calibrationMatrixValues( InputArray cameraMatrix, Size imageSize, + double apertureWidth, double apertureHeight, + CV_OUT double& fovx, CV_OUT double& fovy, + CV_OUT double& focalLength, CV_OUT Point2d& principalPoint, + CV_OUT double& aspectRatio ); + +/** @brief Calibrates a stereo camera set up. This function finds the intrinsic parameters +for each of the two cameras and the extrinsic parameters between the two cameras. + +@param objectPoints Vector of vectors of the calibration pattern points. The same structure as +in @ref calibrateCamera. For each pattern view, both cameras need to see the same object +points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be +equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to +be equal for each i. +@param imagePoints1 Vector of vectors of the projections of the calibration pattern points, +observed by the first camera. The same structure as in @ref calibrateCamera. +@param imagePoints2 Vector of vectors of the projections of the calibration pattern points, +observed by the second camera. The same structure as in @ref calibrateCamera. +@param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in +@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below. +@param distCoeffs1 Input/output vector of distortion coefficients, the same as in +@ref calibrateCamera. +@param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for +cameraMatrix1. +@param distCoeffs2 Input/output lens distortion coefficients for the second camera. See +description for distCoeffs1. +@param imageSize Size of the image used only to initialize the camera intrinsic matrices. +@param R Output rotation matrix. Together with the translation vector T, this matrix brings +points given in the first camera's coordinate system to points in the second camera's +coordinate system. In more technical terms, the tuple of R and T performs a change of basis +from the first camera's coordinate system to the second camera's coordinate system. Due to its +duality, this tuple is equivalent to the position of the first camera with respect to the +second camera coordinate system. +@param T Output translation vector, see description above. +@param E Output essential matrix. +@param F Output fundamental matrix. +@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view. +@param flags Different flags that may be zero or a combination of the following values: +- @ref CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F +matrices are estimated. +- @ref CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters +according to the specified flags. Initial values are provided by the user. +- @ref CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further. +Otherwise R and T are initialized to the median value of the pattern views (each dimension separately). +- @ref CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization. +- @ref CALIB_FIX_FOCAL_LENGTH Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ . +- @ref CALIB_FIX_ASPECT_RATIO Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$ +. +- @ref CALIB_SAME_FOCAL_LENGTH Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ . +- @ref CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to +zeros and fix there. +- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 Do not change the corresponding radial +distortion coefficient during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, +the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_RATIONAL_MODEL Enable coefficients k4, k5, and k6. To provide the backward +compatibility, this extra flag should be explicitly specified to make the calibration +function use the rational model and return 8 coefficients. If the flag is not set, the +function computes and returns only 5 distortion coefficients. +- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the thin prism model and return 12 coefficients. If the flag is not +set, the function computes and returns only 5 distortion coefficients. +- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the tilted sensor model and return 14 coefficients. If the flag is not +set, the function computes and returns only 5 distortion coefficients. +- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +@param criteria Termination criteria for the iterative optimization algorithm. + +The function estimates the transformation between two cameras making a stereo pair. If one computes +the poses of an object relative to the first camera and to the second camera, +( \f$R_1\f$,\f$T_1\f$ ) and (\f$R_2\f$,\f$T_2\f$), respectively, for a stereo camera where the +relative position and orientation between the two cameras are fixed, then those poses definitely +relate to each other. This means, if the relative position and orientation (\f$R\f$,\f$T\f$) of the +two cameras is known, it is possible to compute (\f$R_2\f$,\f$T_2\f$) when (\f$R_1\f$,\f$T_1\f$) is +given. This is what the described function does. It computes (\f$R\f$,\f$T\f$) such that: + +\f[R_2=R R_1\f] +\f[T_2=R T_1 + T.\f] + +Therefore, one can compute the coordinate representation of a 3D point for the second camera's +coordinate system when given the point's coordinate representation in the first camera's coordinate +system: + +\f[\begin{bmatrix} +X_2 \\ +Y_2 \\ +Z_2 \\ +1 +\end{bmatrix} = \begin{bmatrix} +R & T \\ +0 & 1 +\end{bmatrix} \begin{bmatrix} +X_1 \\ +Y_1 \\ +Z_1 \\ +1 +\end{bmatrix}.\f] + + +Optionally, it computes the essential matrix E: + +\f[E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\f] + +where \f$T_i\f$ are components of the translation vector \f$T\f$ : \f$T=[T_0, T_1, T_2]^T\f$ . +And the function can also compute the fundamental matrix F: + +\f[F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\f] + +Besides the stereo-related information, the function can also perform a full calibration of each of +the two cameras. However, due to the high dimensionality of the parameter space and noise in the +input data, the function can diverge from the correct solution. If the intrinsic parameters can be +estimated with high accuracy for each of the cameras individually (for example, using +#calibrateCamera ), you are recommended to do so and then pass @ref CALIB_FIX_INTRINSIC flag to the +function along with the computed intrinsic parameters. Otherwise, if all the parameters are +estimated at once, it makes sense to restrict some parameters, for example, pass + @ref CALIB_SAME_FOCAL_LENGTH and @ref CALIB_ZERO_TANGENT_DIST flags, which is usually a +reasonable assumption. + +Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the +points in all the available views from both cameras. The function returns the final value of the +re-projection error. + */ +CV_EXPORTS_AS(stereoCalibrateExtended) double stereoCalibrate( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, + InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, + Size imageSize, InputOutputArray R,InputOutputArray T, OutputArray E, OutputArray F, + OutputArray perViewErrors, int flags = CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6) ); + +/// @overload +CV_EXPORTS_W double stereoCalibrate( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, + InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, + Size imageSize, OutputArray R,OutputArray T, OutputArray E, OutputArray F, + int flags = CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6) ); + +/** @brief Computes rectification transforms for each head of a calibrated stereo camera. + +@param cameraMatrix1 First camera intrinsic matrix. +@param distCoeffs1 First camera distortion parameters. +@param cameraMatrix2 Second camera intrinsic matrix. +@param distCoeffs2 Second camera distortion parameters. +@param imageSize Size of the image used for stereo calibration. +@param R Rotation matrix from the coordinate system of the first camera to the second camera, +see @ref stereoCalibrate. +@param T Translation vector from the coordinate system of the first camera to the second camera, +see @ref stereoCalibrate. +@param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix +brings points given in the unrectified first camera's coordinate system to points in the rectified +first camera's coordinate system. In more technical terms, it performs a change of basis from the +unrectified first camera's coordinate system to the rectified first camera's coordinate system. +@param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix +brings points given in the unrectified second camera's coordinate system to points in the rectified +second camera's coordinate system. In more technical terms, it performs a change of basis from the +unrectified second camera's coordinate system to the rectified second camera's coordinate system. +@param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first +camera, i.e. it projects points given in the rectified first camera coordinate system into the +rectified first camera's image. +@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second +camera, i.e. it projects points given in the rectified first camera coordinate system into the +rectified second camera's image. +@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see @ref reprojectImageTo3D). +@param flags Operation flags that may be zero or @ref CALIB_ZERO_DISPARITY . If the flag is set, +the function makes the principal points of each camera have the same pixel coordinates in the +rectified views. And if the flag is not set, the function may still shift the images in the +horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the +useful image area. +@param alpha Free scaling parameter. If it is -1 or absent, the function performs the default +scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified +images are zoomed and shifted so that only valid pixels are visible (no black areas after +rectification). alpha=1 means that the rectified image is decimated and shifted so that all the +pixels from the original images from the cameras are retained in the rectified images (no source +image pixels are lost). Any intermediate value yields an intermediate result between +those two extreme cases. +@param newImageSize New image resolution after rectification. The same size should be passed to +#initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) +is passed (default), it is set to the original imageSize . Setting it to a larger value can help you +preserve details in the original image, especially when there is a big radial distortion. +@param validPixROI1 Optional output rectangles inside the rectified images where all the pixels +are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller +(see the picture below). +@param validPixROI2 Optional output rectangles inside the rectified images where all the pixels +are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller +(see the picture below). + +The function computes the rotation matrices for each camera that (virtually) make both camera image +planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies +the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate +as input. As output, it provides two rotation matrices and also two projection matrices in the new +coordinates. The function distinguishes the following two cases: + +- **Horizontal stereo**: the first and the second camera views are shifted relative to each other + mainly along the x-axis (with possible small vertical shift). In the rectified images, the + corresponding epipolar lines in the left and right cameras are horizontal and have the same + y-coordinate. P1 and P2 look like: + + \f[\texttt{P1} = \begin{bmatrix} + f & 0 & cx_1 & 0 \\ + 0 & f & cy & 0 \\ + 0 & 0 & 1 & 0 + \end{bmatrix}\f] + + \f[\texttt{P2} = \begin{bmatrix} + f & 0 & cx_2 & T_x*f \\ + 0 & f & cy & 0 \\ + 0 & 0 & 1 & 0 + \end{bmatrix} ,\f] + + where \f$T_x\f$ is a horizontal shift between the cameras and \f$cx_1=cx_2\f$ if + @ref CALIB_ZERO_DISPARITY is set. + +- **Vertical stereo**: the first and the second camera views are shifted relative to each other + mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar + lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like: + + \f[\texttt{P1} = \begin{bmatrix} + f & 0 & cx & 0 \\ + 0 & f & cy_1 & 0 \\ + 0 & 0 & 1 & 0 + \end{bmatrix}\f] + + \f[\texttt{P2} = \begin{bmatrix} + f & 0 & cx & 0 \\ + 0 & f & cy_2 & T_y*f \\ + 0 & 0 & 1 & 0 + \end{bmatrix},\f] + + where \f$T_y\f$ is a vertical shift between the cameras and \f$cy_1=cy_2\f$ if + @ref CALIB_ZERO_DISPARITY is set. + +As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera +matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to +initialize the rectification map for each camera. + +See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through +the corresponding image regions. This means that the images are well rectified, which is what most +stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that +their interiors are all valid pixels. + +![image](pics/stereo_undistort.jpg) + */ +CV_EXPORTS_W void stereoRectify( InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + Size imageSize, InputArray R, InputArray T, + OutputArray R1, OutputArray R2, + OutputArray P1, OutputArray P2, + OutputArray Q, int flags = CALIB_ZERO_DISPARITY, + double alpha = -1, Size newImageSize = Size(), + CV_OUT Rect* validPixROI1 = 0, CV_OUT Rect* validPixROI2 = 0 ); + +/** @brief Computes a rectification transform for an uncalibrated stereo camera. + +@param points1 Array of feature points in the first image. +@param points2 The corresponding points in the second image. The same formats as in +#findFundamentalMat are supported. +@param F Input fundamental matrix. It can be computed from the same set of point pairs using +#findFundamentalMat . +@param imgSize Size of the image. +@param H1 Output rectification homography matrix for the first image. +@param H2 Output rectification homography matrix for the second image. +@param threshold Optional threshold used to filter out the outliers. If the parameter is greater +than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points +for which \f$|\texttt{points2[i]}^T*\texttt{F}*\texttt{points1[i]}|>\texttt{threshold}\f$ ) are +rejected prior to computing the homographies. Otherwise, all the points are considered inliers. + +The function computes the rectification transformations without knowing intrinsic parameters of the +cameras and their relative position in the space, which explains the suffix "uncalibrated". Another +related difference from #stereoRectify is that the function outputs not the rectification +transformations in the object (3D) space, but the planar perspective transformations encoded by the +homography matrices H1 and H2 . The function implements the algorithm @cite Hartley99 . + +@note + While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily + depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion, + it would be better to correct it before computing the fundamental matrix and calling this + function. For example, distortion coefficients can be estimated for each head of stereo camera + separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or + just the point coordinates can be corrected with #undistortPoints . + */ +CV_EXPORTS_W bool stereoRectifyUncalibrated( InputArray points1, InputArray points2, + InputArray F, Size imgSize, + OutputArray H1, OutputArray H2, + double threshold = 5 ); + +//! computes the rectification transformations for 3-head camera, where all the heads are on the same line. +CV_EXPORTS_W float rectify3Collinear( InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + InputArray cameraMatrix3, InputArray distCoeffs3, + InputArrayOfArrays imgpt1, InputArrayOfArrays imgpt3, + Size imageSize, InputArray R12, InputArray T12, + InputArray R13, InputArray T13, + OutputArray R1, OutputArray R2, OutputArray R3, + OutputArray P1, OutputArray P2, OutputArray P3, + OutputArray Q, double alpha, Size newImgSize, + CV_OUT Rect* roi1, CV_OUT Rect* roi2, int flags ); + +/** @brief Returns the new camera intrinsic matrix based on the free scaling parameter. + +@param cameraMatrix Input camera intrinsic matrix. +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param imageSize Original image size. +@param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are +valid) and 1 (when all the source image pixels are retained in the undistorted image). See +#stereoRectify for details. +@param newImgSize Image size after rectification. By default, it is set to imageSize . +@param validPixROI Optional output rectangle that outlines all-good-pixels region in the +undistorted image. See roi1, roi2 description in #stereoRectify . +@param centerPrincipalPoint Optional flag that indicates whether in the new camera intrinsic matrix the +principal point should be at the image center or not. By default, the principal point is chosen to +best fit a subset of the source image (determined by alpha) to the corrected image. +@return new_camera_matrix Output new camera intrinsic matrix. + +The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter. +By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original +image pixels if there is valuable information in the corners alpha=1 , or get something in between. +When alpha\>0 , the undistorted result is likely to have some black pixels corresponding to +"virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion +coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to +#initUndistortRectifyMap to produce the maps for #remap . + */ +CV_EXPORTS_W Mat getOptimalNewCameraMatrix( InputArray cameraMatrix, InputArray distCoeffs, + Size imageSize, double alpha, Size newImgSize = Size(), + CV_OUT Rect* validPixROI = 0, + bool centerPrincipalPoint = false); + +/** @brief Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$ + +@param[in] R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from gripper frame to robot base frame. +@param[in] t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from gripper frame to robot base frame. +@param[in] R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from calibration target frame to camera frame. +@param[in] t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from calibration target frame to camera frame. +@param[out] R_cam2gripper Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point +expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$). +@param[out] t_cam2gripper Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point +expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$). +@param[in] method One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod + +The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the +rotation then the translation (separable solutions) and the following methods are implemented: + - R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89 + - F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94 + - R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95 + +Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions), +with the following implemented methods: + - N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99 + - K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98 + +The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye") +mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand. + +The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot +end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting +the suitable transformations to the function, see below. + +![](pics/hand-eye_figure.png) + +The calibration procedure is the following: + - a static calibration pattern is used to estimate the transformation between the target frame + and the camera frame + - the robot gripper is moved in order to acquire several poses + - for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for + instance the robot kinematics +\f[ + \begin{bmatrix} + X_b\\ + Y_b\\ + Z_b\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} +\f] + - for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using + for instance a pose estimation method (PnP) from 2D-3D point correspondences +\f[ + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_t\\ + Y_t\\ + Z_t\\ + 1 + \end{bmatrix} +\f] + +The Hand-Eye calibration procedure returns the following homogeneous transformation +\f[ + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} +\f] + +This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\f$ equation: + - for an eye-in-hand configuration +\f[ + \begin{align*} + ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= + \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ + + (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &= + \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\ + + \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\ + \end{align*} +\f] + + - for an eye-to-hand configuration +\f[ + \begin{align*} + ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= + \hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ + + (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &= + \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\ + + \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\ + \end{align*} +\f] + +\note +Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration). +\note +A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation. +So at least 3 different poses are required, but it is strongly recommended to use many more poses. + + */ +CV_EXPORTS_W void calibrateHandEye( InputArrayOfArrays R_gripper2base, InputArrayOfArrays t_gripper2base, + InputArrayOfArrays R_target2cam, InputArrayOfArrays t_target2cam, + OutputArray R_cam2gripper, OutputArray t_cam2gripper, + HandEyeCalibrationMethod method=CALIB_HAND_EYE_TSAI ); + +/** @brief Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$ + +@param[in] R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from world frame to the camera frame. +@param[in] t_world2cam Translation part extracted from the homogeneous matrix that transforms a point +expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from world frame to the camera frame. +@param[in] R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from robot base frame to the gripper frame. +@param[in] t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from robot base frame to the gripper frame. +@param[out] R_base2world Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$). +@param[out] t_base2world Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$). +@param[out] R_gripper2cam Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$). +@param[out] t_gripper2cam Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$). +@param[in] method One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod + +The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the +rotation then the translation (separable solutions): + - M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR + +Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions), +with the following implemented method: + - A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA + +The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame +and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated. + +![](pics/robot-world_hand-eye_figure.png) + +The calibration procedure is the following: + - a static calibration pattern is used to estimate the transformation between the target frame + and the camera frame + - the robot gripper is moved in order to acquire several poses + - for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for + instance the robot kinematics +\f[ + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_b\\ + Y_b\\ + Z_b\\ + 1 + \end{bmatrix} +\f] + - for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using + for instance a pose estimation method (PnP) from 2D-3D point correspondences +\f[ + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_w\\ + Y_w\\ + Z_w\\ + 1 + \end{bmatrix} +\f] + +The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations +\f[ + \begin{bmatrix} + X_w\\ + Y_w\\ + Z_w\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{w}\textrm{R}_b & _{}^{w}\textrm{t}_b \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_b\\ + Y_b\\ + Z_b\\ + 1 + \end{bmatrix} +\f] +\f[ + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{c}\textrm{R}_g & _{}^{c}\textrm{t}_g \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} +\f] + +This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\f$ equation, with: + - \f$\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\f$ + - \f$\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\f$ + - \f$\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\f$ + - \f$\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\f$ + +\note +At least 3 measurements are required (input vectors size must be greater or equal to 3). + + */ +CV_EXPORTS_W void calibrateRobotWorldHandEye( InputArrayOfArrays R_world2cam, InputArrayOfArrays t_world2cam, + InputArrayOfArrays R_base2gripper, InputArrayOfArrays t_base2gripper, + OutputArray R_base2world, OutputArray t_base2world, + OutputArray R_gripper2cam, OutputArray t_gripper2cam, + RobotWorldHandEyeCalibrationMethod method=CALIB_ROBOT_WORLD_HAND_EYE_SHAH ); + +/** @brief Converts points from Euclidean to homogeneous space. + +@param src Input vector of N-dimensional points. +@param dst Output vector of N+1-dimensional points. + +The function converts points from Euclidean to homogeneous space by appending 1's to the tuple of +point coordinates. That is, each point (x1, x2, ..., xn) is converted to (x1, x2, ..., xn, 1). + */ +CV_EXPORTS_W void convertPointsToHomogeneous( InputArray src, OutputArray dst ); + +/** @brief Converts points from homogeneous to Euclidean space. + +@param src Input vector of N-dimensional points. +@param dst Output vector of N-1-dimensional points. + +The function converts points homogeneous to Euclidean space using perspective projection. That is, +each point (x1, x2, ... x(n-1), xn) is converted to (x1/xn, x2/xn, ..., x(n-1)/xn). When xn=0, the +output point coordinates will be (0,0,0,...). + */ +CV_EXPORTS_W void convertPointsFromHomogeneous( InputArray src, OutputArray dst ); + +/** @brief Converts points to/from homogeneous coordinates. + +@param src Input array or vector of 2D, 3D, or 4D points. +@param dst Output vector of 2D, 3D, or 4D points. + +The function converts 2D or 3D points from/to homogeneous coordinates by calling either +#convertPointsToHomogeneous or #convertPointsFromHomogeneous. + +@note The function is obsolete. Use one of the previous two functions instead. + */ +CV_EXPORTS void convertPointsHomogeneous( InputArray src, OutputArray dst ); + +/** @brief Calculates a fundamental matrix from the corresponding points in two images. + +@param points1 Array of N points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param method Method for computing a fundamental matrix. +- @ref FM_7POINT for a 7-point algorithm. \f$N = 7\f$ +- @ref FM_8POINT for an 8-point algorithm. \f$N \ge 8\f$ +- @ref FM_RANSAC for the RANSAC algorithm. \f$N \ge 8\f$ +- @ref FM_LMEDS for the LMedS algorithm. \f$N \ge 8\f$ +@param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level +of confidence (probability) that the estimated matrix is correct. +@param[out] mask optional output mask +@param maxIters The maximum number of robust method iterations. + +The epipolar geometry is described by the following equation: + +\f[[p_2; 1]^T F [p_1; 1] = 0\f] + +where \f$F\f$ is a fundamental matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the +second images, respectively. + +The function calculates the fundamental matrix using one of four methods listed above and returns +the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point +algorithm, the function may return up to 3 solutions ( \f$9 \times 3\f$ matrix that stores all 3 +matrices sequentially). + +The calculated fundamental matrix may be passed further to computeCorrespondEpilines that finds the +epipolar lines corresponding to the specified points. It can also be passed to +#stereoRectifyUncalibrated to compute the rectification transformation. : +@code + // Example. Estimation of fundamental matrix using the RANSAC algorithm + int point_count = 100; + vector points1(point_count); + vector points2(point_count); + + // initialize the points here ... + for( int i = 0; i < point_count; i++ ) + { + points1[i] = ...; + points2[i] = ...; + } + + Mat fundamental_matrix = + findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99); +@endcode + */ +CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2, + int method, double ransacReprojThreshold, double confidence, + int maxIters, OutputArray mask = noArray() ); + +/** @overload */ +CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2, + int method = FM_RANSAC, + double ransacReprojThreshold = 3., double confidence = 0.99, + OutputArray mask = noArray() ); + +/** @overload */ +CV_EXPORTS Mat findFundamentalMat( InputArray points1, InputArray points2, + OutputArray mask, int method = FM_RANSAC, + double ransacReprojThreshold = 3., double confidence = 0.99 ); + + +CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2, + OutputArray mask, const UsacParams ¶ms); + +/** @brief Calculates an essential matrix from the corresponding points in two images. + +@param points1 Array of N (N \>= 5) 2D points from the first image. The point coordinates should +be floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera intrinsic matrix. If this assumption does not hold for your use case, use +#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points +to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When +passing these coordinates, pass the identity matrix for this parameter. +@param method Method for computing an essential matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 +for the other points. The array is computed only in the RANSAC and LMedS methods. +@param maxIters The maximum number of robust method iterations. + +This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 . +@cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation: + +\f[[p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\f] + +where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the +second images, respectively. The result of this function may be passed further to +#decomposeEssentialMat or #recoverPose to recover the relative pose between cameras. + */ +CV_EXPORTS_W +Mat findEssentialMat( + InputArray points1, InputArray points2, + InputArray cameraMatrix, int method = RANSAC, + double prob = 0.999, double threshold = 1.0, + int maxIters = 1000, OutputArray mask = noArray() +); + +/** @overload */ +CV_EXPORTS +Mat findEssentialMat( + InputArray points1, InputArray points2, + InputArray cameraMatrix, int method, + double prob, double threshold, + OutputArray mask +); // TODO remove from OpenCV 5.0 + +/** @overload +@param points1 Array of N (N \>= 5) 2D points from the first image. The point coordinates should +be floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param focal focal length of the camera. Note that this function assumes that points1 and points2 +are feature points from cameras with same focal length and principal point. +@param pp principal point of the camera. +@param method Method for computing a fundamental matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 +for the other points. The array is computed only in the RANSAC and LMedS methods. +@param maxIters The maximum number of robust method iterations. + +This function differs from the one above that it computes camera intrinsic matrix from focal length and +principal point: + +\f[A = +\begin{bmatrix} +f & 0 & x_{pp} \\ +0 & f & y_{pp} \\ +0 & 0 & 1 +\end{bmatrix}\f] + */ +CV_EXPORTS_W +Mat findEssentialMat( + InputArray points1, InputArray points2, + double focal = 1.0, Point2d pp = Point2d(0, 0), + int method = RANSAC, double prob = 0.999, + double threshold = 1.0, int maxIters = 1000, + OutputArray mask = noArray() +); + +/** @overload */ +CV_EXPORTS +Mat findEssentialMat( + InputArray points1, InputArray points2, + double focal, Point2d pp, + int method, double prob, + double threshold, OutputArray mask +); // TODO remove from OpenCV 5.0 + +/** @brief Calculates an essential matrix from the corresponding points in two images from potentially two different cameras. + +@param points1 Array of N (N \>= 5) 2D points from the first image. The point coordinates should +be floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix1 Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera matrix. If this assumption does not hold for your use case, use +#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points +to normalized image coordinates, which are valid for the identity camera matrix. When +passing these coordinates, pass the identity matrix for this parameter. +@param cameraMatrix2 Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera matrix. If this assumption does not hold for your use case, use +#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points +to normalized image coordinates, which are valid for the identity camera matrix. When +passing these coordinates, pass the identity matrix for this parameter. +@param distCoeffs1 Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param distCoeffs2 Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param method Method for computing an essential matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 +for the other points. The array is computed only in the RANSAC and LMedS methods. + +This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 . +@cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation: + +\f[[p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\f] + +where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the +second images, respectively. The result of this function may be passed further to +#decomposeEssentialMat or #recoverPose to recover the relative pose between cameras. + */ +CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2, + InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + int method = RANSAC, + double prob = 0.999, double threshold = 1.0, + OutputArray mask = noArray() ); + + +CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2, + InputArray cameraMatrix1, InputArray cameraMatrix2, + InputArray dist_coeff1, InputArray dist_coeff2, OutputArray mask, + const UsacParams ¶ms); + +/** @brief Decompose an essential matrix to possible rotations and translation. + +@param E The input essential matrix. +@param R1 One possible rotation matrix. +@param R2 Another possible rotation matrix. +@param t One possible translation. + +This function decomposes the essential matrix E using svd decomposition @cite HartleyZ00. In +general, four possible poses exist for the decomposition of E. They are \f$[R_1, t]\f$, +\f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$. + +If E gives the epipolar constraint \f$[p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\f$ between the image +points \f$p_1\f$ in the first image and \f$p_2\f$ in second image, then any of the tuples +\f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$ is a change of basis from the first +camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one +can only get the direction of the translation. For this reason, the translation t is returned with +unit length. + */ +CV_EXPORTS_W void decomposeEssentialMat( InputArray E, OutputArray R1, OutputArray R2, OutputArray t ); + +/** @brief Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of +inliers that pass the check. + +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix1 Input/output camera matrix for the first camera, the same as in +@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below. +@param distCoeffs1 Input/output vector of distortion coefficients, the same as in +@ref calibrateCamera. +@param cameraMatrix2 Input/output camera matrix for the first camera, the same as in +@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below. +@param distCoeffs2 Input/output vector of distortion coefficients, the same as in +@ref calibrateCamera. +@param E The output essential matrix. +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +described below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param method Method for computing an essential matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. + +This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies +possible pose hypotheses by doing cheirality check. The cheirality check means that the +triangulated 3D points should have positive depth. Some details can be found in @cite Nister03. + +This function can be used to process the output E and mask from @ref findEssentialMat. In this +scenario, points1 and points2 are the same input for findEssentialMat.: +@code + // Example. Estimation of fundamental matrix using the RANSAC algorithm + int point_count = 100; + vector points1(point_count); + vector points2(point_count); + + // initialize the points here ... + for( int i = 0; i < point_count; i++ ) + { + points1[i] = ...; + points2[i] = ...; + } + + // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration. + Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2; + + // Output: Essential matrix, relative rotation and relative translation. + Mat E, R, t, mask; + + recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask); +@endcode + */ +CV_EXPORTS_W int recoverPose( InputArray points1, InputArray points2, + InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + OutputArray E, OutputArray R, OutputArray t, + int method = cv::RANSAC, double prob = 0.999, double threshold = 1.0, + InputOutputArray mask = noArray()); + +/** @brief Recovers the relative camera rotation and the translation from an estimated essential +matrix and the corresponding points in two images, using cheirality check. Returns the number of +inliers that pass the check. + +@param E The input essential matrix. +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera intrinsic matrix. +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +described below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. + +This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies +possible pose hypotheses by doing cheirality check. The cheirality check means that the +triangulated 3D points should have positive depth. Some details can be found in @cite Nister03. + +This function can be used to process the output E and mask from @ref findEssentialMat. In this +scenario, points1 and points2 are the same input for #findEssentialMat : +@code + // Example. Estimation of fundamental matrix using the RANSAC algorithm + int point_count = 100; + vector points1(point_count); + vector points2(point_count); + + // initialize the points here ... + for( int i = 0; i < point_count; i++ ) + { + points1[i] = ...; + points2[i] = ...; + } + + // cametra matrix with both focal lengths = 1, and principal point = (0, 0) + Mat cameraMatrix = Mat::eye(3, 3, CV_64F); + + Mat E, R, t, mask; + + E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask); + recoverPose(E, points1, points2, cameraMatrix, R, t, mask); +@endcode + */ +CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, + InputArray cameraMatrix, OutputArray R, OutputArray t, + InputOutputArray mask = noArray() ); + +/** @overload +@param E The input essential matrix. +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +description below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param focal Focal length of the camera. Note that this function assumes that points1 and points2 +are feature points from cameras with same focal length and principal point. +@param pp principal point of the camera. +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. + +This function differs from the one above that it computes camera intrinsic matrix from focal length and +principal point: + +\f[A = +\begin{bmatrix} +f & 0 & x_{pp} \\ +0 & f & y_{pp} \\ +0 & 0 & 1 +\end{bmatrix}\f] + */ +CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, + OutputArray R, OutputArray t, + double focal = 1.0, Point2d pp = Point2d(0, 0), + InputOutputArray mask = noArray() ); + +/** @overload +@param E The input essential matrix. +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1. +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera intrinsic matrix. +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +description below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite +points). +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. +@param triangulatedPoints 3D points which were reconstructed by triangulation. + +This function differs from the one above that it outputs the triangulated 3D point that are used for +the cheirality check. + */ +CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, + InputArray cameraMatrix, OutputArray R, OutputArray t, double distanceThresh, InputOutputArray mask = noArray(), + OutputArray triangulatedPoints = noArray()); + +/** @brief For points in an image of a stereo pair, computes the corresponding epilines in the other image. + +@param points Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or +vector\ . +@param whichImage Index of the image (1 or 2) that contains the points . +@param F Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify . +@param lines Output vector of the epipolar lines corresponding to the points in the other image. +Each line \f$ax + by + c=0\f$ is encoded by 3 numbers \f$(a, b, c)\f$ . + +For every point in one of the two images of a stereo pair, the function finds the equation of the +corresponding epipolar line in the other image. + +From the fundamental matrix definition (see #findFundamentalMat ), line \f$l^{(2)}_i\f$ in the second +image for the point \f$p^{(1)}_i\f$ in the first image (when whichImage=1 ) is computed as: + +\f[l^{(2)}_i = F p^{(1)}_i\f] + +And vice versa, when whichImage=2, \f$l^{(1)}_i\f$ is computed from \f$p^{(2)}_i\f$ as: + +\f[l^{(1)}_i = F^T p^{(2)}_i\f] + +Line coefficients are defined up to a scale. They are normalized so that \f$a_i^2+b_i^2=1\f$ . + */ +CV_EXPORTS_W void computeCorrespondEpilines( InputArray points, int whichImage, + InputArray F, OutputArray lines ); + +/** @brief This function reconstructs 3-dimensional points (in homogeneous coordinates) by using +their observations with a stereo camera. + +@param projMatr1 3x4 projection matrix of the first camera, i.e. this matrix projects 3D points +given in the world's coordinate system into the first image. +@param projMatr2 3x4 projection matrix of the second camera, i.e. this matrix projects 3D points +given in the world's coordinate system into the second image. +@param projPoints1 2xN array of feature points in the first image. In the case of the c++ version, +it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1. +@param projPoints2 2xN array of corresponding points in the second image. In the case of the c++ +version, it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1. +@param points4D 4xN array of reconstructed points in homogeneous coordinates. These points are +returned in the world's coordinate system. + +@note + Keep in mind that all input data should be of float type in order for this function to work. + +@note + If the projection matrices from @ref stereoRectify are used, then the returned points are + represented in the first camera's rectified coordinate system. + +@sa + reprojectImageTo3D + */ +CV_EXPORTS_W void triangulatePoints( InputArray projMatr1, InputArray projMatr2, + InputArray projPoints1, InputArray projPoints2, + OutputArray points4D ); + +/** @brief Refines coordinates of corresponding points. + +@param F 3x3 fundamental matrix. +@param points1 1xN array containing the first set of points. +@param points2 1xN array containing the second set of points. +@param newPoints1 The optimized points1. +@param newPoints2 The optimized points2. + +The function implements the Optimal Triangulation Method (see Multiple View Geometry for details). +For each given point correspondence points1[i] \<-\> points2[i], and a fundamental matrix F, it +computes the corrected correspondences newPoints1[i] \<-\> newPoints2[i] that minimize the geometric +error \f$d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\f$ (where \f$d(a,b)\f$ is the +geometric distance between points \f$a\f$ and \f$b\f$ ) subject to the epipolar constraint +\f$newPoints2^T * F * newPoints1 = 0\f$ . + */ +CV_EXPORTS_W void correctMatches( InputArray F, InputArray points1, InputArray points2, + OutputArray newPoints1, OutputArray newPoints2 ); + +/** @brief Filters off small noise blobs (speckles) in the disparity map + +@param img The input 16-bit signed disparity image +@param newVal The disparity value used to paint-off the speckles +@param maxSpeckleSize The maximum speckle size to consider it a speckle. Larger blobs are not +affected by the algorithm +@param maxDiff Maximum difference between neighbor disparity pixels to put them into the same +blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point +disparity map, where disparity values are multiplied by 16, this scale factor should be taken into +account when specifying this parameter value. +@param buf The optional temporary buffer to avoid memory allocation within the function. + */ +CV_EXPORTS_W void filterSpeckles( InputOutputArray img, double newVal, + int maxSpeckleSize, double maxDiff, + InputOutputArray buf = noArray() ); + +//! computes valid disparity ROI from the valid ROIs of the rectified images (that are returned by #stereoRectify) +CV_EXPORTS_W Rect getValidDisparityROI( Rect roi1, Rect roi2, + int minDisparity, int numberOfDisparities, + int blockSize ); + +//! validates disparity using the left-right check. The matrix "cost" should be computed by the stereo correspondence algorithm +CV_EXPORTS_W void validateDisparity( InputOutputArray disparity, InputArray cost, + int minDisparity, int numberOfDisparities, + int disp12MaxDisp = 1 ); + +/** @brief Reprojects a disparity image to 3D space. + +@param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit +floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no +fractional bits. If the disparity is 16-bit signed format, as computed by @ref StereoBM or +@ref StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before +being used here. +@param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of +_3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one +uses Q obtained by @ref stereoRectify, then the returned points are represented in the first +camera's rectified coordinate system. +@param Q \f$4 \times 4\f$ perspective transformation matrix that can be obtained with +@ref stereoRectify. +@param handleMissingValues Indicates, whether the function should handle missing values (i.e. +points where the disparity was not computed). If handleMissingValues=true, then pixels with the +minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed +to 3D points with a very large Z value (currently set to 10000). +@param ddepth The optional output array depth. If it is -1, the output image will have CV_32F +depth. ddepth can also be set to CV_16S, CV_32S or CV_32F. + +The function transforms a single-channel disparity map to a 3-channel image representing a 3D +surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it +computes: + +\f[\begin{bmatrix} +X \\ +Y \\ +Z \\ +W +\end{bmatrix} = Q \begin{bmatrix} +x \\ +y \\ +\texttt{disparity} (x,y) \\ +z +\end{bmatrix}.\f] + +@sa + To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform. + */ +CV_EXPORTS_W void reprojectImageTo3D( InputArray disparity, + OutputArray _3dImage, InputArray Q, + bool handleMissingValues = false, + int ddepth = -1 ); + +/** @brief Calculates the Sampson Distance between two points. + +The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as: +\f[ +sd( \texttt{pt1} , \texttt{pt2} )= +\frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2} +{((\texttt{F} \cdot \texttt{pt1})(0))^2 + +((\texttt{F} \cdot \texttt{pt1})(1))^2 + +((\texttt{F}^t \cdot \texttt{pt2})(0))^2 + +((\texttt{F}^t \cdot \texttt{pt2})(1))^2} +\f] +The fundamental matrix may be calculated using the #findFundamentalMat function. See @cite HartleyZ00 11.4.3 for details. +@param pt1 first homogeneous 2d point +@param pt2 second homogeneous 2d point +@param F fundamental matrix +@return The computed Sampson distance. +*/ +CV_EXPORTS_W double sampsonDistance(InputArray pt1, InputArray pt2, InputArray F); + +/** @brief Computes an optimal affine transformation between two 3D point sets. + +It computes +\f[ +\begin{bmatrix} +x\\ +y\\ +z\\ +\end{bmatrix} += +\begin{bmatrix} +a_{11} & a_{12} & a_{13}\\ +a_{21} & a_{22} & a_{23}\\ +a_{31} & a_{32} & a_{33}\\ +\end{bmatrix} +\begin{bmatrix} +X\\ +Y\\ +Z\\ +\end{bmatrix} ++ +\begin{bmatrix} +b_1\\ +b_2\\ +b_3\\ +\end{bmatrix} +\f] + +@param src First input 3D point set containing \f$(X,Y,Z)\f$. +@param dst Second input 3D point set containing \f$(x,y,z)\f$. +@param out Output 3D affine transformation matrix \f$3 \times 4\f$ of the form +\f[ +\begin{bmatrix} +a_{11} & a_{12} & a_{13} & b_1\\ +a_{21} & a_{22} & a_{23} & b_2\\ +a_{31} & a_{32} & a_{33} & b_3\\ +\end{bmatrix} +\f] +@param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier). +@param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as +an inlier. +@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything +between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation +significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. + +The function estimates an optimal 3D affine transformation between two 3D point sets using the +RANSAC algorithm. + */ +CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst, + OutputArray out, OutputArray inliers, + double ransacThreshold = 3, double confidence = 0.99); + +/** @brief Computes an optimal affine transformation between two 3D point sets. + +It computes \f$R,s,t\f$ minimizing \f$\sum{i} dst_i - c \cdot R \cdot src_i \f$ +where \f$R\f$ is a 3x3 rotation matrix, \f$t\f$ is a 3x1 translation vector and \f$s\f$ is a +scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least . +The estimated affine transform has a homogeneous scale which is a subclass of affine +transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3 +points each. + +@param src First input 3D point set. +@param dst Second input 3D point set. +@param scale If null is passed, the scale parameter c will be assumed to be 1.0. +Else the pointed-to variable will be set to the optimal scale. +@param force_rotation If true, the returned rotation will never be a reflection. +This might be unwanted, e.g. when optimizing a transform between a right- and a +left-handed coordinate system. +@return 3D affine transformation matrix \f$3 \times 4\f$ of the form +\f[T = +\begin{bmatrix} +R & t\\ +\end{bmatrix} +\f] + + */ +CV_EXPORTS_W cv::Mat estimateAffine3D(InputArray src, InputArray dst, + CV_OUT double* scale = nullptr, bool force_rotation = true); + +/** @brief Computes an optimal translation between two 3D point sets. + * + * It computes + * \f[ + * \begin{bmatrix} + * x\\ + * y\\ + * z\\ + * \end{bmatrix} + * = + * \begin{bmatrix} + * X\\ + * Y\\ + * Z\\ + * \end{bmatrix} + * + + * \begin{bmatrix} + * b_1\\ + * b_2\\ + * b_3\\ + * \end{bmatrix} + * \f] + * + * @param src First input 3D point set containing \f$(X,Y,Z)\f$. + * @param dst Second input 3D point set containing \f$(x,y,z)\f$. + * @param out Output 3D translation vector \f$3 \times 1\f$ of the form + * \f[ + * \begin{bmatrix} + * b_1 \\ + * b_2 \\ + * b_3 \\ + * \end{bmatrix} + * \f] + * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier). + * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as + * an inlier. + * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything + * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation + * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. + * + * The function estimates an optimal 3D translation between two 3D point sets using the + * RANSAC algorithm. + * */ +CV_EXPORTS_W int estimateTranslation3D(InputArray src, InputArray dst, + OutputArray out, OutputArray inliers, + double ransacThreshold = 3, double confidence = 0.99); + +/** @brief Computes an optimal affine transformation between two 2D point sets. + +It computes +\f[ +\begin{bmatrix} +x\\ +y\\ +\end{bmatrix} += +\begin{bmatrix} +a_{11} & a_{12}\\ +a_{21} & a_{22}\\ +\end{bmatrix} +\begin{bmatrix} +X\\ +Y\\ +\end{bmatrix} ++ +\begin{bmatrix} +b_1\\ +b_2\\ +\end{bmatrix} +\f] + +@param from First input 2D point set containing \f$(X,Y)\f$. +@param to Second input 2D point set containing \f$(x,y)\f$. +@param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier). +@param method Robust method used to compute transformation. The following methods are possible: +- @ref RANSAC - RANSAC-based robust method +- @ref LMEDS - Least-Median robust method +RANSAC is the default method. +@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider +a point as an inlier. Applies only to RANSAC. +@param maxIters The maximum number of robust method iterations. +@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything +between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation +significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. +@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt). +Passing 0 will disable refining, so the output matrix will be output of robust method. + +@return Output 2D affine transformation matrix \f$2 \times 3\f$ or empty matrix if transformation +could not be estimated. The returned matrix has the following form: +\f[ +\begin{bmatrix} +a_{11} & a_{12} & b_1\\ +a_{21} & a_{22} & b_2\\ +\end{bmatrix} +\f] + +The function estimates an optimal 2D affine transformation between two 2D point sets using the +selected robust algorithm. + +The computed transformation is then refined further (using only inliers) with the +Levenberg-Marquardt method to reduce the re-projection error even more. + +@note +The RANSAC method can handle practically any ratio of outliers but needs a threshold to +distinguish inliers from outliers. The method LMeDS does not need any threshold but it works +correctly only when there are more than 50% of inliers. + +@sa estimateAffinePartial2D, getAffineTransform +*/ +CV_EXPORTS_W cv::Mat estimateAffine2D(InputArray from, InputArray to, OutputArray inliers = noArray(), + int method = RANSAC, double ransacReprojThreshold = 3, + size_t maxIters = 2000, double confidence = 0.99, + size_t refineIters = 10); + + +CV_EXPORTS_W cv::Mat estimateAffine2D(InputArray pts1, InputArray pts2, OutputArray inliers, + const UsacParams ¶ms); + +/** @brief Computes an optimal limited affine transformation with 4 degrees of freedom between +two 2D point sets. + +@param from First input 2D point set. +@param to Second input 2D point set. +@param inliers Output vector indicating which points are inliers. +@param method Robust method used to compute transformation. The following methods are possible: +- @ref RANSAC - RANSAC-based robust method +- @ref LMEDS - Least-Median robust method +RANSAC is the default method. +@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider +a point as an inlier. Applies only to RANSAC. +@param maxIters The maximum number of robust method iterations. +@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything +between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation +significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. +@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt). +Passing 0 will disable refining, so the output matrix will be output of robust method. + +@return Output 2D affine transformation (4 degrees of freedom) matrix \f$2 \times 3\f$ or +empty matrix if transformation could not be estimated. + +The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to +combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust +estimation. + +The computed transformation is then refined further (using only inliers) with the +Levenberg-Marquardt method to reduce the re-projection error even more. + +Estimated transformation matrix is: +\f[ \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\ + \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y +\end{bmatrix} \f] +Where \f$ \theta \f$ is the rotation angle, \f$ s \f$ the scaling factor and \f$ t_x, t_y \f$ are +translations in \f$ x, y \f$ axes respectively. + +@note +The RANSAC method can handle practically any ratio of outliers but need a threshold to +distinguish inliers from outliers. The method LMeDS does not need any threshold but it works +correctly only when there are more than 50% of inliers. + +@sa estimateAffine2D, getAffineTransform +*/ +CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, OutputArray inliers = noArray(), + int method = RANSAC, double ransacReprojThreshold = 3, + size_t maxIters = 2000, double confidence = 0.99, + size_t refineIters = 10); + +/** @example samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp +An example program with homography decomposition. + +Check @ref tutorial_homography "the corresponding tutorial" for more details. +*/ + +/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s). + +@param H The input homography matrix between two images. +@param K The input camera intrinsic matrix. +@param rotations Array of rotation matrices. +@param translations Array of translation matrices. +@param normals Array of plane normal matrices. + +This function extracts relative camera motion between two views of a planar object and returns up to +four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of +the homography matrix H is described in detail in @cite Malis. + +If the homography H, induced by the plane, gives the constraint +\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] on the source image points +\f$p_i\f$ and the destination image points \f$p'_i\f$, then the tuple of rotations[k] and +translations[k] is a change of basis from the source camera's coordinate system to the destination +camera's coordinate system. However, by decomposing H, one can only get the translation normalized +by the (typically unknown) depth of the scene, i.e. its direction but with normalized length. + +If point correspondences are available, at least two solutions may further be invalidated, by +applying positive depth constraint, i.e. all points must be in front of the camera. + */ +CV_EXPORTS_W int decomposeHomographyMat(InputArray H, + InputArray K, + OutputArrayOfArrays rotations, + OutputArrayOfArrays translations, + OutputArrayOfArrays normals); + +/** @brief Filters homography decompositions based on additional information. + +@param rotations Vector of rotation matrices. +@param normals Vector of plane normal matrices. +@param beforePoints Vector of (rectified) visible reference points before the homography is applied +@param afterPoints Vector of (rectified) visible reference points after the homography is applied +@param possibleSolutions Vector of int indices representing the viable solution set after filtering +@param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function + +This function is intended to filter the output of the #decomposeHomographyMat based on additional +information as described in @cite Malis . The summary of the method: the #decomposeHomographyMat function +returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the +sets of points visible in the camera frame before and after the homography transformation is applied, +we can determine which are the true potential solutions and which are the opposites by verifying which +homographies are consistent with all visible reference points being in front of the camera. The inputs +are left unchanged; the filtered solution set is returned as indices into the existing one. + +*/ +CV_EXPORTS_W void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays rotations, + InputArrayOfArrays normals, + InputArray beforePoints, + InputArray afterPoints, + OutputArray possibleSolutions, + InputArray pointsMask = noArray()); + +/** @brief The base class for stereo correspondence algorithms. + */ +class CV_EXPORTS_W StereoMatcher : public Algorithm +{ +public: + enum { DISP_SHIFT = 4, + DISP_SCALE = (1 << DISP_SHIFT) + }; + + /** @brief Computes disparity map for the specified stereo pair + + @param left Left 8-bit single-channel image. + @param right Right image of the same size and the same type as the left one. + @param disparity Output disparity map. It has the same size as the input images. Some algorithms, + like StereoBM or StereoSGBM compute 16-bit fixed-point disparity map (where each disparity value + has 4 fractional bits), whereas other algorithms output 32-bit floating-point disparity map. + */ + CV_WRAP virtual void compute( InputArray left, InputArray right, + OutputArray disparity ) = 0; + + CV_WRAP virtual int getMinDisparity() const = 0; + CV_WRAP virtual void setMinDisparity(int minDisparity) = 0; + + CV_WRAP virtual int getNumDisparities() const = 0; + CV_WRAP virtual void setNumDisparities(int numDisparities) = 0; + + CV_WRAP virtual int getBlockSize() const = 0; + CV_WRAP virtual void setBlockSize(int blockSize) = 0; + + CV_WRAP virtual int getSpeckleWindowSize() const = 0; + CV_WRAP virtual void setSpeckleWindowSize(int speckleWindowSize) = 0; + + CV_WRAP virtual int getSpeckleRange() const = 0; + CV_WRAP virtual void setSpeckleRange(int speckleRange) = 0; + + CV_WRAP virtual int getDisp12MaxDiff() const = 0; + CV_WRAP virtual void setDisp12MaxDiff(int disp12MaxDiff) = 0; +}; + + +/** @brief Class for computing stereo correspondence using the block matching algorithm, introduced and +contributed to OpenCV by K. Konolige. + */ +class CV_EXPORTS_W StereoBM : public StereoMatcher +{ +public: + enum { PREFILTER_NORMALIZED_RESPONSE = 0, + PREFILTER_XSOBEL = 1 + }; + + CV_WRAP virtual int getPreFilterType() const = 0; + CV_WRAP virtual void setPreFilterType(int preFilterType) = 0; + + CV_WRAP virtual int getPreFilterSize() const = 0; + CV_WRAP virtual void setPreFilterSize(int preFilterSize) = 0; + + CV_WRAP virtual int getPreFilterCap() const = 0; + CV_WRAP virtual void setPreFilterCap(int preFilterCap) = 0; + + CV_WRAP virtual int getTextureThreshold() const = 0; + CV_WRAP virtual void setTextureThreshold(int textureThreshold) = 0; + + CV_WRAP virtual int getUniquenessRatio() const = 0; + CV_WRAP virtual void setUniquenessRatio(int uniquenessRatio) = 0; + + CV_WRAP virtual int getSmallerBlockSize() const = 0; + CV_WRAP virtual void setSmallerBlockSize(int blockSize) = 0; + + CV_WRAP virtual Rect getROI1() const = 0; + CV_WRAP virtual void setROI1(Rect roi1) = 0; + + CV_WRAP virtual Rect getROI2() const = 0; + CV_WRAP virtual void setROI2(Rect roi2) = 0; + + /** @brief Creates StereoBM object + + @param numDisparities the disparity search range. For each pixel algorithm will find the best + disparity from 0 (default minimum disparity) to numDisparities. The search range can then be + shifted by changing the minimum disparity. + @param blockSize the linear size of the blocks compared by the algorithm. The size should be odd + (as the block is centered at the current pixel). Larger block size implies smoother, though less + accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher + chance for algorithm to find a wrong correspondence. + + The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for + a specific stereo pair. + */ + CV_WRAP static Ptr create(int numDisparities = 0, int blockSize = 21); +}; + +/** @brief The class implements the modified H. Hirschmuller algorithm @cite HH08 that differs from the original +one as follows: + +- By default, the algorithm is single-pass, which means that you consider only 5 directions +instead of 8. Set mode=StereoSGBM::MODE_HH in createStereoSGBM to run the full variant of the +algorithm but beware that it may consume a lot of memory. +- The algorithm matches blocks, not individual pixels. Though, setting blockSize=1 reduces the +blocks to single pixels. +- Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi +sub-pixel metric from @cite BT98 is used. Though, the color images are supported as well. +- Some pre- and post- processing steps from K. Konolige algorithm StereoBM are included, for +example: pre-filtering (StereoBM::PREFILTER_XSOBEL type) and post-filtering (uniqueness +check, quadratic interpolation and speckle filtering). + +@note + - (Python) An example illustrating the use of the StereoSGBM matching algorithm can be found + at opencv_source_code/samples/python/stereo_match.py + */ +class CV_EXPORTS_W StereoSGBM : public StereoMatcher +{ +public: + enum + { + MODE_SGBM = 0, + MODE_HH = 1, + MODE_SGBM_3WAY = 2, + MODE_HH4 = 3 + }; + + CV_WRAP virtual int getPreFilterCap() const = 0; + CV_WRAP virtual void setPreFilterCap(int preFilterCap) = 0; + + CV_WRAP virtual int getUniquenessRatio() const = 0; + CV_WRAP virtual void setUniquenessRatio(int uniquenessRatio) = 0; + + CV_WRAP virtual int getP1() const = 0; + CV_WRAP virtual void setP1(int P1) = 0; + + CV_WRAP virtual int getP2() const = 0; + CV_WRAP virtual void setP2(int P2) = 0; + + CV_WRAP virtual int getMode() const = 0; + CV_WRAP virtual void setMode(int mode) = 0; + + /** @brief Creates StereoSGBM object + + @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes + rectification algorithms can shift images, so this parameter needs to be adjusted accordingly. + @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than + zero. In the current implementation, this parameter must be divisible by 16. + @param blockSize Matched block size. It must be an odd number \>=1 . Normally, it should be + somewhere in the 3..11 range. + @param P1 The first parameter controlling the disparity smoothness. See below. + @param P2 The second parameter controlling the disparity smoothness. The larger the values are, + the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1 + between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor + pixels. The algorithm requires P2 \> P1 . See stereo_match.cpp sample where some reasonably good + P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and + 32\*number_of_image_channels\*blockSize\*blockSize , respectively). + @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right + disparity check. Set it to a non-positive value to disable the check. + @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first + computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval. + The result values are passed to the Birchfield-Tomasi pixel cost function. + @param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function + value should "win" the second best value to consider the found match correct. Normally, a value + within the 5-15 range is good enough. + @param speckleWindowSize Maximum size of smooth disparity regions to consider their noise speckles + and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the + 50-200 range. + @param speckleRange Maximum disparity variation within each connected component. If you do speckle + filtering, set the parameter to a positive value, it will be implicitly multiplied by 16. + Normally, 1 or 2 is good enough. + @param mode Set it to StereoSGBM::MODE_HH to run the full-scale two-pass dynamic programming + algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and + huge for HD-size pictures. By default, it is set to false . + + The first constructor initializes StereoSGBM with all the default parameters. So, you only have to + set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter + to a custom value. + */ + CV_WRAP static Ptr create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3, + int P1 = 0, int P2 = 0, int disp12MaxDiff = 0, + int preFilterCap = 0, int uniquenessRatio = 0, + int speckleWindowSize = 0, int speckleRange = 0, + int mode = StereoSGBM::MODE_SGBM); +}; + + +//! cv::undistort mode +enum UndistortTypes +{ + PROJ_SPHERICAL_ORTHO = 0, + PROJ_SPHERICAL_EQRECT = 1 +}; + +/** @brief Transforms an image to compensate for lens distortion. + +The function transforms an image to compensate radial and tangential lens distortion. + +The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap +(with bilinear interpolation). See the former function for details of the transformation being +performed. + +Those pixels in the destination image, for which there is no correspondent pixels in the source +image, are filled with zeros (black color). + +A particular subset of the source image that will be visible in the corrected image can be regulated +by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate +newCameraMatrix depending on your requirements. + +The camera matrix and the distortion parameters can be determined using #calibrateCamera. If +the resolution of images is different from the resolution used at the calibration stage, \f$f_x, +f_y, c_x\f$ and \f$c_y\f$ need to be scaled accordingly, while the distortion coefficients remain +the same. + +@param src Input (distorted) image. +@param dst Output (corrected) image that has the same size and type as src . +@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param newCameraMatrix Camera matrix of the distorted image. By default, it is the same as +cameraMatrix but you may additionally scale and shift the result by using a different matrix. + */ +CV_EXPORTS_W void undistort( InputArray src, OutputArray dst, + InputArray cameraMatrix, + InputArray distCoeffs, + InputArray newCameraMatrix = noArray() ); + +/** @brief Computes the undistortion and rectification transformation map. + +The function computes the joint undistortion and rectification transformation and represents the +result in the form of maps for #remap. The undistorted image looks like original, as if it is +captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a +monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by +#getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera, +newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify . + +Also, this new camera is oriented differently in the coordinate space, according to R. That, for +example, helps to align two heads of a stereo camera so that the epipolar lines on both images +become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera). + +The function actually builds the maps for the inverse mapping algorithm that is used by #remap. That +is, for each pixel \f$(u, v)\f$ in the destination (corrected and rectified) image, the function +computes the corresponding coordinates in the source image (that is, in the original image from +camera). The following process is applied: +\f[ +\begin{array}{l} +x \leftarrow (u - {c'}_x)/{f'}_x \\ +y \leftarrow (v - {c'}_y)/{f'}_y \\ +{[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\ +x' \leftarrow X/W \\ +y' \leftarrow Y/W \\ +r^2 \leftarrow x'^2 + y'^2 \\ +x'' \leftarrow x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} ++ 2p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4\\ +y'' \leftarrow y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} ++ p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\ +s\vecthree{x'''}{y'''}{1} = +\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)} +{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)} +{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\ +map_x(u,v) \leftarrow x''' f_x + c_x \\ +map_y(u,v) \leftarrow y''' f_y + c_y +\end{array} +\f] +where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +are the distortion coefficients. + +In case of a stereo camera, this function is called twice: once for each camera head, after +#stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera +was not calibrated, it is still possible to compute the rectification transformations directly from +the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes +homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D +space. R can be computed from H as +\f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f] +where cameraMatrix can be chosen arbitrarily. + +@param cameraMatrix Input camera matrix \f$A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2 , +computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation +is assumed. In cvInitUndistortMap R assumed to be an identity matrix. +@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$. +@param size Undistorted image size. +@param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps +@param map1 The first output map. +@param map2 The second output map. + */ +CV_EXPORTS_W +void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, + InputArray R, InputArray newCameraMatrix, + Size size, int m1type, OutputArray map1, OutputArray map2); + +/** @brief Computes the projection and inverse-rectification transformation map. In essense, this is the inverse of +#initUndistortRectifyMap to accomodate stereo-rectification of projectors ('inverse-cameras') in projector-camera pairs. + +The function computes the joint projection and inverse rectification transformation and represents the +result in the form of maps for #remap. The projected image looks like a distorted version of the original which, +once projected by a projector, should visually match the original. In case of a monocular camera, newCameraMatrix +is usually equal to cameraMatrix, or it can be computed by +#getOptimalNewCameraMatrix for a better control over scaling. In case of a projector-camera pair, +newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify . + +The projector is oriented differently in the coordinate space, according to R. In case of projector-camera pairs, +this helps align the projector (in the same manner as #initUndistortRectifyMap for the camera) to create a stereo-rectified pair. This +allows epipolar lines on both images to become horizontal and have the same y-coordinate (in case of a horizontally aligned projector-camera pair). + +The function builds the maps for the inverse mapping algorithm that is used by #remap. That +is, for each pixel \f$(u, v)\f$ in the destination (projected and inverse-rectified) image, the function +computes the corresponding coordinates in the source image (that is, in the original digital image). The following process is applied: + +\f[ +\begin{array}{l} +\text{newCameraMatrix}\\ +x \leftarrow (u - {c'}_x)/{f'}_x \\ +y \leftarrow (v - {c'}_y)/{f'}_y \\ + +\\\text{Undistortion} +\\\scriptsize{\textit{though equation shown is for radial undistortion, function implements cv::undistortPoints()}}\\ +r^2 \leftarrow x^2 + y^2 \\ +\theta \leftarrow \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}\\ +x' \leftarrow \frac{x}{\theta} \\ +y' \leftarrow \frac{y}{\theta} \\ + +\\\text{Rectification}\\ +{[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\ +x'' \leftarrow X/W \\ +y'' \leftarrow Y/W \\ + +\\\text{cameraMatrix}\\ +map_x(u,v) \leftarrow x'' f_x + c_x \\ +map_y(u,v) \leftarrow y'' f_y + c_y +\end{array} +\f] +where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +are the distortion coefficients vector distCoeffs. + +In case of a stereo-rectified projector-camera pair, this function is called for the projector while #initUndistortRectifyMap is called for the camera head. +This is done after #stereoRectify, which in turn is called after #stereoCalibrate. If the projector-camera pair +is not calibrated, it is still possible to compute the rectification transformations directly from +the fundamental matrix using #stereoRectifyUncalibrated. For the projector and camera, the function computes +homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D +space. R can be computed from H as +\f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f] +where cameraMatrix can be chosen arbitrarily. + +@param cameraMatrix Input camera matrix \f$A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2, +computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation +is assumed. +@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$. +@param size Distorted image size. +@param m1type Type of the first output map. Can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps +@param map1 The first output map for #remap. +@param map2 The second output map for #remap. + */ +CV_EXPORTS_W +void initInverseRectificationMap( InputArray cameraMatrix, InputArray distCoeffs, + InputArray R, InputArray newCameraMatrix, + const Size& size, int m1type, OutputArray map1, OutputArray map2 ); + +//! initializes maps for #remap for wide-angle +CV_EXPORTS +float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs, + Size imageSize, int destImageWidth, + int m1type, OutputArray map1, OutputArray map2, + enum UndistortTypes projType = PROJ_SPHERICAL_EQRECT, double alpha = 0); +static inline +float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs, + Size imageSize, int destImageWidth, + int m1type, OutputArray map1, OutputArray map2, + int projType, double alpha = 0) +{ + return initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize, destImageWidth, + m1type, map1, map2, (UndistortTypes)projType, alpha); +} + +/** @brief Returns the default new camera matrix. + +The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when +centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true). + +In the latter case, the new camera matrix will be: + +\f[\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\f] + +where \f$f_x\f$ and \f$f_y\f$ are \f$(0,0)\f$ and \f$(1,1)\f$ elements of cameraMatrix, respectively. + +By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not +move the principal point. However, when you work with stereo, it is important to move the principal +points in both views to the same y-coordinate (which is required by most of stereo correspondence +algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for +each view where the principal points are located at the center. + +@param cameraMatrix Input camera matrix. +@param imgsize Camera view image size in pixels. +@param centerPrincipalPoint Location of the principal point in the new camera matrix. The +parameter indicates whether this location should be at the image center or not. + */ +CV_EXPORTS_W +Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgsize = Size(), + bool centerPrincipalPoint = false); + +/** @brief Computes the ideal point coordinates from the observed point coordinates. + +The function is similar to #undistort and #initUndistortRectifyMap but it operates on a +sparse set of points instead of a raster image. Also the function performs a reverse transformation +to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a +planar object, it does, up to a translation vector, if the proper R is specified. + +For each observed point coordinate \f$(u, v)\f$ the function computes: +\f[ +\begin{array}{l} +x^{"} \leftarrow (u - c_x)/f_x \\ +y^{"} \leftarrow (v - c_y)/f_y \\ +(x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\ +{[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\ +x \leftarrow X/W \\ +y \leftarrow Y/W \\ +\text{only performed if P is specified:} \\ +u' \leftarrow x {f'}_x + {c'}_x \\ +v' \leftarrow y {f'}_y + {c'}_y +\end{array} +\f] + +where *undistort* is an approximate iterative algorithm that estimates the normalized original +point coordinates out of the normalized distorted point coordinates ("normalized" means that the +coordinates do not depend on the camera matrix). + +The function can be used for both a stereo camera head or a monocular camera (when R is empty). +@param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or +vector\ ). +@param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector\ ) after undistortion and reverse perspective +transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates. +@param cameraMatrix Camera matrix \f$\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by +#stereoRectify can be passed here. If the matrix is empty, the identity transformation is used. +@param P New camera matrix (3x3) or new projection matrix (3x4) \f$\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\f$. P1 or P2 computed by +#stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used. + */ +CV_EXPORTS_W +void undistortPoints(InputArray src, OutputArray dst, + InputArray cameraMatrix, InputArray distCoeffs, + InputArray R = noArray(), InputArray P = noArray()); +/** @overload + @note Default version of #undistortPoints does 5 iterations to compute undistorted points. + */ +CV_EXPORTS_AS(undistortPointsIter) +void undistortPoints(InputArray src, OutputArray dst, + InputArray cameraMatrix, InputArray distCoeffs, + InputArray R, InputArray P, TermCriteria criteria); + +//! @} calib3d + +/** @brief The methods in this namespace use a so-called fisheye camera model. + @ingroup calib3d_fisheye +*/ +namespace fisheye +{ +//! @addtogroup calib3d_fisheye +//! @{ + + enum{ + CALIB_USE_INTRINSIC_GUESS = 1 << 0, + CALIB_RECOMPUTE_EXTRINSIC = 1 << 1, + CALIB_CHECK_COND = 1 << 2, + CALIB_FIX_SKEW = 1 << 3, + CALIB_FIX_K1 = 1 << 4, + CALIB_FIX_K2 = 1 << 5, + CALIB_FIX_K3 = 1 << 6, + CALIB_FIX_K4 = 1 << 7, + CALIB_FIX_INTRINSIC = 1 << 8, + CALIB_FIX_PRINCIPAL_POINT = 1 << 9, + CALIB_ZERO_DISPARITY = 1 << 10, + CALIB_FIX_FOCAL_LENGTH = 1 << 11 + }; + + /** @brief Projects points using fisheye model + + @param objectPoints Array of object points, 1xN/Nx1 3-channel (or vector\ ), where N is + the number of points in the view. + @param imagePoints Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or + vector\. + @param affine + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param alpha The skew coefficient. + @param jacobian Optional output 2Nx15 jacobian matrix of derivatives of image points with respect + to components of the focal lengths, coordinates of the principal point, distortion coefficients, + rotation vector, translation vector, and the skew. In the old interface different components of + the jacobian are returned via different output parameters. + + The function computes projections of 3D points to the image plane given intrinsic and extrinsic + camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of + image points coordinates (as functions of all the input parameters) with respect to the particular + parameters, intrinsic and/or extrinsic. + */ + CV_EXPORTS void projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine, + InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()); + + /** @overload */ + CV_EXPORTS_W void projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, + InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()); + + /** @brief Distorts 2D points using fisheye model. + + @param undistorted Array of object points, 1xN/Nx1 2-channel (or vector\ ), where N is + the number of points in the view. + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param alpha The skew coefficient. + @param distorted Output array of image points, 1xN/Nx1 2-channel, or vector\ . + + Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity. + This means if you want to transform back points undistorted with #fisheye::undistortPoints you have to + multiply them with \f$P^{-1}\f$. + */ + CV_EXPORTS_W void distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0); + + /** @brief Undistorts 2D points using fisheye model + + @param distorted Array of object points, 1xN/Nx1 2-channel (or vector\ ), where N is the + number of points in the view. + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 + 1-channel or 1x1 3-channel + @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4) + @param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector\ . + */ + CV_EXPORTS_W void undistortPoints(InputArray distorted, OutputArray undistorted, + InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray()); + + /** @brief Computes undistortion and rectification maps for image transform by #remap. If D is empty zero + distortion is used, if R or P is empty identity matrixes are used. + + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 + 1-channel or 1x1 3-channel + @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4) + @param size Undistorted image size. + @param m1type Type of the first output map that can be CV_32FC1 or CV_16SC2 . See #convertMaps + for details. + @param map1 The first output map. + @param map2 The second output map. + */ + CV_EXPORTS_W void initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, + const cv::Size& size, int m1type, OutputArray map1, OutputArray map2); + + /** @brief Transforms an image to compensate for fisheye lens distortion. + + @param distorted image with fisheye lens distortion. + @param undistorted Output image with compensated fisheye lens distortion. + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you + may additionally scale and shift the result by using a different matrix. + @param new_size the new size + + The function transforms an image to compensate radial and tangential lens distortion. + + The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap + (with bilinear interpolation). See the former function for details of the transformation being + performed. + + See below the results of undistortImage. + - a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3, + k_4, k_5, k_6) of distortion were optimized under calibration) + - b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2, + k_3, k_4) of fisheye distortion were optimized under calibration) + - c\) original image was captured with fisheye lens + + Pictures a) and b) almost the same. But if we consider points of image located far from the center + of image, we can notice that on image a) these points are distorted. + + ![image](pics/fisheye_undistorted.jpg) + */ + CV_EXPORTS_W void undistortImage(InputArray distorted, OutputArray undistorted, + InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size()); + + /** @brief Estimates new camera intrinsic matrix for undistortion or rectification. + + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param image_size Size of the image + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 + 1-channel or 1x1 3-channel + @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4) + @param balance Sets the new focal length in range between the min focal length and the max focal + length. Balance is in range of [0, 1]. + @param new_size the new size + @param fov_scale Divisor for new focal length. + */ + CV_EXPORTS_W void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R, + OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0); + + /** @brief Performs camera calibaration + + @param objectPoints vector of vectors of calibration pattern points in the calibration pattern + coordinate space. + @param imagePoints vector of vectors of the projections of calibration pattern points. + imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to + objectPoints[i].size() for each i. + @param image_size Size of the image used only to initialize the camera intrinsic matrix. + @param K Output 3x3 floating-point camera intrinsic matrix + \f$\cameramatrix{A}\f$ . If + @ref fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be + initialized before calling the function. + @param D Output vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view. + That is, each k-th rotation vector together with the corresponding k-th translation vector (see + the next output parameter description) brings the calibration pattern from the model coordinate + space (in which object points are specified) to the world coordinate space, that is, a real + position of the calibration pattern in the k-th pattern view (k=0.. *M* -1). + @param tvecs Output vector of translation vectors estimated for each pattern view. + @param flags Different flags that may be zero or a combination of the following values: + - @ref fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of + fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image + center ( imageSize is used), and focal distances are computed in a least-squares fashion. + - @ref fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration + of intrinsic optimization. + - @ref fisheye::CALIB_CHECK_COND The functions will check validity of condition number. + - @ref fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero. + - @ref fisheye::CALIB_FIX_K1,..., @ref fisheye::CALIB_FIX_K4 Selected distortion coefficients + are set to zeros and stay zero. + - @ref fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global +optimization. It stays at the center or at a different location specified when @ref fisheye::CALIB_USE_INTRINSIC_GUESS is set too. + - @ref fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global +optimization. It is the \f$max(width,height)/\pi\f$ or the provided \f$f_x\f$, \f$f_y\f$ when @ref fisheye::CALIB_USE_INTRINSIC_GUESS is set too. + @param criteria Termination criteria for the iterative optimization algorithm. + */ + CV_EXPORTS_W double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size, + InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)); + + /** @brief Stereo rectification for fisheye camera model + + @param K1 First camera intrinsic matrix. + @param D1 First camera distortion parameters. + @param K2 Second camera intrinsic matrix. + @param D2 Second camera distortion parameters. + @param imageSize Size of the image used for stereo calibration. + @param R Rotation matrix between the coordinate systems of the first and the second + cameras. + @param tvec Translation vector between coordinate systems of the cameras. + @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. + @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. + @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first + camera. + @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second + camera. + @param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ). + @param flags Operation flags that may be zero or @ref fisheye::CALIB_ZERO_DISPARITY . If the flag is set, + the function makes the principal points of each camera have the same pixel coordinates in the + rectified views. And if the flag is not set, the function may still shift the images in the + horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the + useful image area. + @param newImageSize New image resolution after rectification. The same size should be passed to + #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) + is passed (default), it is set to the original imageSize . Setting it to larger value can help you + preserve details in the original image, especially when there is a big radial distortion. + @param balance Sets the new focal length in range between the min focal length and the max focal + length. Balance is in range of [0, 1]. + @param fov_scale Divisor for new focal length. + */ + CV_EXPORTS_W void stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec, + OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(), + double balance = 0.0, double fov_scale = 1.0); + + /** @brief Performs stereo calibration + + @param objectPoints Vector of vectors of the calibration pattern points. + @param imagePoints1 Vector of vectors of the projections of the calibration pattern points, + observed by the first camera. + @param imagePoints2 Vector of vectors of the projections of the calibration pattern points, + observed by the second camera. + @param K1 Input/output first camera intrinsic matrix: + \f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If + any of @ref fisheye::CALIB_USE_INTRINSIC_GUESS , @ref fisheye::CALIB_FIX_INTRINSIC are specified, + some or all of the matrix components must be initialized. + @param D1 Input/output vector of distortion coefficients \f$\distcoeffsfisheye\f$ of 4 elements. + @param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 . + @param D2 Input/output lens distortion coefficients for the second camera. The parameter is + similar to D1 . + @param imageSize Size of the image used only to initialize camera intrinsic matrix. + @param R Output rotation matrix between the 1st and the 2nd camera coordinate systems. + @param T Output translation vector between the coordinate systems of the cameras. + @param flags Different flags that may be zero or a combination of the following values: + - @ref fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices + are estimated. + - @ref fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of + fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image + center (imageSize is used), and focal distances are computed in a least-squares fashion. + - @ref fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration + of intrinsic optimization. + - @ref fisheye::CALIB_CHECK_COND The functions will check validity of condition number. + - @ref fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero. + - @ref fisheye::CALIB_FIX_K1,..., @ref fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay + zero. + @param criteria Termination criteria for the iterative optimization algorithm. + */ + CV_EXPORTS_W double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize, + OutputArray R, OutputArray T, int flags = fisheye::CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)); + +//! @} calib3d_fisheye +} // end namespace fisheye + +} //end namespace cv + +#if 0 //def __cplusplus +////////////////////////////////////////////////////////////////////////////////////////// +class CV_EXPORTS CvLevMarq +{ +public: + CvLevMarq(); + CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + ~CvLevMarq(); + void init( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + bool update( const CvMat*& param, CvMat*& J, CvMat*& err ); + bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm ); + + void clear(); + void step(); + enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 }; + + cv::Ptr mask; + cv::Ptr prevParam; + cv::Ptr param; + cv::Ptr J; + cv::Ptr err; + cv::Ptr JtJ; + cv::Ptr JtJN; + cv::Ptr JtErr; + cv::Ptr JtJV; + cv::Ptr JtJW; + double prevErrNorm, errNorm; + int lambdaLg10; + CvTermCriteria criteria; + int state; + int iters; + bool completeSymmFlag; + int solveMethod; +}; +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/calib3d/calib3d.hpp b/Cigarette/OpenCV455Simple/include/opencv2/calib3d/calib3d.hpp new file mode 100644 index 0000000..b3da45e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/calib3d/calib3d.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/calib3d.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/calib3d/calib3d_c.h b/Cigarette/OpenCV455Simple/include/opencv2/calib3d/calib3d_c.h new file mode 100644 index 0000000..e2af07b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/calib3d/calib3d_c.h @@ -0,0 +1,150 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CALIB3D_C_H +#define OPENCV_CALIB3D_C_H + +#include "opencv2/core/types_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Calculates fundamental matrix given a set of corresponding points */ +#define CV_FM_7POINT 1 +#define CV_FM_8POINT 2 + +#define CV_LMEDS 4 +#define CV_RANSAC 8 + +#define CV_FM_LMEDS_ONLY CV_LMEDS +#define CV_FM_RANSAC_ONLY CV_RANSAC +#define CV_FM_LMEDS CV_LMEDS +#define CV_FM_RANSAC CV_RANSAC + +enum +{ + CV_ITERATIVE = 0, + CV_EPNP = 1, // F.Moreno-Noguer, V.Lepetit and P.Fua "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" + CV_P3P = 2, // X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang; "Complete Solution Classification for the Perspective-Three-Point Problem" + CV_DLS = 3 // Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP" +}; + +#define CV_CALIB_CB_ADAPTIVE_THRESH 1 +#define CV_CALIB_CB_NORMALIZE_IMAGE 2 +#define CV_CALIB_CB_FILTER_QUADS 4 +#define CV_CALIB_CB_FAST_CHECK 8 + +#define CV_CALIB_USE_INTRINSIC_GUESS 1 +#define CV_CALIB_FIX_ASPECT_RATIO 2 +#define CV_CALIB_FIX_PRINCIPAL_POINT 4 +#define CV_CALIB_ZERO_TANGENT_DIST 8 +#define CV_CALIB_FIX_FOCAL_LENGTH 16 +#define CV_CALIB_FIX_K1 32 +#define CV_CALIB_FIX_K2 64 +#define CV_CALIB_FIX_K3 128 +#define CV_CALIB_FIX_K4 2048 +#define CV_CALIB_FIX_K5 4096 +#define CV_CALIB_FIX_K6 8192 +#define CV_CALIB_RATIONAL_MODEL 16384 +#define CV_CALIB_THIN_PRISM_MODEL 32768 +#define CV_CALIB_FIX_S1_S2_S3_S4 65536 +#define CV_CALIB_TILTED_MODEL 262144 +#define CV_CALIB_FIX_TAUX_TAUY 524288 +#define CV_CALIB_FIX_TANGENT_DIST 2097152 + +#define CV_CALIB_NINTRINSIC 18 + +#define CV_CALIB_FIX_INTRINSIC 256 +#define CV_CALIB_SAME_FOCAL_LENGTH 512 + +#define CV_CALIB_ZERO_DISPARITY 1024 + +/* stereo correspondence parameters and functions */ +#define CV_STEREO_BM_NORMALIZED_RESPONSE 0 +#define CV_STEREO_BM_XSOBEL 1 + +#ifdef __cplusplus +} // extern "C" + +////////////////////////////////////////////////////////////////////////////////////////// +class CV_EXPORTS CvLevMarq +{ +public: + CvLevMarq(); + CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + ~CvLevMarq(); + void init( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + bool update( const CvMat*& param, CvMat*& J, CvMat*& err ); + bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm ); + + void clear(); + void step(); + enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 }; + + cv::Ptr mask; + cv::Ptr prevParam; + cv::Ptr param; + cv::Ptr J; + cv::Ptr err; + cv::Ptr JtJ; + cv::Ptr JtJN; + cv::Ptr JtErr; + cv::Ptr JtJV; + cv::Ptr JtJW; + double prevErrNorm, errNorm; + int lambdaLg10; + CvTermCriteria criteria; + int state; + int iters; + bool completeSymmFlag; + int solveMethod; +}; + +#endif + +#endif /* OPENCV_CALIB3D_C_H */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core.hpp new file mode 100644 index 0000000..70ea4f8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core.hpp @@ -0,0 +1,3344 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2015, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. +// Copyright (C) 2015, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_HPP +#define OPENCV_CORE_HPP + +#ifndef __cplusplus +# error core.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/base.hpp" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/traits.hpp" +#include "opencv2/core/matx.hpp" +#include "opencv2/core/types.hpp" +#include "opencv2/core/mat.hpp" +#include "opencv2/core/persistence.hpp" + +/** +@defgroup core Core functionality +@{ + @defgroup core_basic Basic structures + @defgroup core_c C structures and operations + @{ + @defgroup core_c_glue Connections with C++ + @} + @defgroup core_array Operations on arrays + @defgroup core_async Asynchronous API + @defgroup core_xml XML/YAML Persistence + @defgroup core_cluster Clustering + @defgroup core_utils Utility and system functions and macros + @{ + @defgroup core_logging Logging facilities + @defgroup core_utils_sse SSE utilities + @defgroup core_utils_neon NEON utilities + @defgroup core_utils_vsx VSX utilities + @defgroup core_utils_softfloat Softfloat support + @defgroup core_utils_samples Utility functions for OpenCV samples + @} + @defgroup core_opengl OpenGL interoperability + @defgroup core_ipp Intel IPP Asynchronous C/C++ Converters + @defgroup core_optim Optimization Algorithms + @defgroup core_directx DirectX interoperability + @defgroup core_eigen Eigen support + @defgroup core_opencl OpenCL support + @defgroup core_va_intel Intel VA-API/OpenCL (CL-VA) interoperability + @defgroup core_hal Hardware Acceleration Layer + @{ + @defgroup core_hal_functions Functions + @defgroup core_hal_interface Interface + @defgroup core_hal_intrin Universal intrinsics + @{ + @defgroup core_hal_intrin_impl Private implementation helpers + @} + @defgroup core_lowlevel_api Low-level API for external libraries / plugins + @} + @defgroup core_parallel Parallel Processing + @{ + @defgroup core_parallel_backend Parallel backends API + @} +@} + */ + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +/*! @brief Class passed to an error. + +This class encapsulates all or almost all necessary +information about the error happened in the program. The exception is +usually constructed and thrown implicitly via CV_Error and CV_Error_ macros. +@see error + */ +class CV_EXPORTS Exception : public std::exception +{ +public: + /*! + Default constructor + */ + Exception(); + /*! + Full constructor. Normally the constructor is not called explicitly. + Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used. + */ + Exception(int _code, const String& _err, const String& _func, const String& _file, int _line); + virtual ~Exception() throw(); + + /*! + \return the error description and the context as a text string. + */ + virtual const char *what() const throw() CV_OVERRIDE; + void formatMessage(); + + String msg; ///< the formatted error message + + int code; ///< error code @see CVStatus + String err; ///< error description + String func; ///< function name. Available only when the compiler supports getting it + String file; ///< source file name where the error has occurred + int line; ///< line number in the source file where the error has occurred +}; + +/*! @brief Signals an error and raises the exception. + +By default the function prints information about the error to stderr, +then it either stops if cv::setBreakOnError() had been called before or raises the exception. +It is possible to alternate error processing by using #redirectError(). +@param exc the exception raisen. +@deprecated drop this version + */ +CV_EXPORTS CV_NORETURN void error(const Exception& exc); + +enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently + SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted + //!< independently; this flag and the previous one are + //!< mutually exclusive. + SORT_ASCENDING = 0, //!< each matrix row is sorted in the ascending + //!< order. + SORT_DESCENDING = 16 //!< each matrix row is sorted in the + //!< descending order; this flag and the previous one are also + //!< mutually exclusive. + }; + +//! @} core_utils + +//! @addtogroup core +//! @{ + +//! Covariation flags +enum CovarFlags { + /** The output covariance matrix is calculated as: + \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...],\f] + The covariance matrix will be nsamples x nsamples. Such an unusual covariance matrix is used + for fast PCA of a set of very large vectors (see, for example, the EigenFaces technique for + face recognition). Eigenvalues of this "scrambled" matrix match the eigenvalues of the true + covariance matrix. The "true" eigenvectors can be easily calculated from the eigenvectors of + the "scrambled" covariance matrix. */ + COVAR_SCRAMBLED = 0, + /**The output covariance matrix is calculated as: + \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\f] + covar will be a square matrix of the same size as the total number of elements in each input + vector. One and only one of #COVAR_SCRAMBLED and #COVAR_NORMAL must be specified.*/ + COVAR_NORMAL = 1, + /** If the flag is specified, the function does not calculate mean from + the input vectors but, instead, uses the passed mean vector. This is useful if mean has been + pre-calculated or known in advance, or if the covariance matrix is calculated by parts. In + this case, mean is not a mean vector of the input sub-set of vectors but rather the mean + vector of the whole set.*/ + COVAR_USE_AVG = 2, + /** If the flag is specified, the covariance matrix is scaled. In the + "normal" mode, scale is 1./nsamples . In the "scrambled" mode, scale is the reciprocal of the + total number of elements in each input vector. By default (if the flag is not specified), the + covariance matrix is not scaled ( scale=1 ).*/ + COVAR_SCALE = 4, + /** If the flag is + specified, all the input vectors are stored as rows of the samples matrix. mean should be a + single-row vector in this case.*/ + COVAR_ROWS = 8, + /** If the flag is + specified, all the input vectors are stored as columns of the samples matrix. mean should be a + single-column vector in this case.*/ + COVAR_COLS = 16 +}; + +//! @addtogroup core_cluster +//! @{ + +//! k-Means flags +enum KmeansFlags { + /** Select random initial centers in each attempt.*/ + KMEANS_RANDOM_CENTERS = 0, + /** Use kmeans++ center initialization by Arthur and Vassilvitskii [Arthur2007].*/ + KMEANS_PP_CENTERS = 2, + /** During the first (and possibly the only) attempt, use the + user-supplied labels instead of computing them from the initial centers. For the second and + further attempts, use the random or semi-random centers. Use one of KMEANS_\*_CENTERS flag + to specify the exact method.*/ + KMEANS_USE_INITIAL_LABELS = 1 +}; + +//! @} core_cluster + +//! @addtogroup core_array +//! @{ + +enum ReduceTypes { REDUCE_SUM = 0, //!< the output is the sum of all rows/columns of the matrix. + REDUCE_AVG = 1, //!< the output is the mean vector of all rows/columns of the matrix. + REDUCE_MAX = 2, //!< the output is the maximum (column/row-wise) of all rows/columns of the matrix. + REDUCE_MIN = 3 //!< the output is the minimum (column/row-wise) of all rows/columns of the matrix. + }; + +//! @} core_array + +/** @brief Swaps two matrices +*/ +CV_EXPORTS void swap(Mat& a, Mat& b); +/** @overload */ +CV_EXPORTS void swap( UMat& a, UMat& b ); + +//! @} core + +//! @addtogroup core_array +//! @{ + +/** @brief Computes the source location of an extrapolated pixel. + +The function computes and returns the coordinate of a donor pixel corresponding to the specified +extrapolated pixel when using the specified extrapolation border mode. For example, if you use +cv::BORDER_WRAP mode in the horizontal direction, cv::BORDER_REFLECT_101 in the vertical direction and +want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img , it +looks like: +@code{.cpp} + float val = img.at(borderInterpolate(100, img.rows, cv::BORDER_REFLECT_101), + borderInterpolate(-5, img.cols, cv::BORDER_WRAP)); +@endcode +Normally, the function is not called directly. It is used inside filtering functions and also in +copyMakeBorder. +@param p 0-based coordinate of the extrapolated pixel along one of the axes, likely \<0 or \>= len +@param len Length of the array along the corresponding axis. +@param borderType Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and +#BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless +of p and len. + +@sa copyMakeBorder +*/ +CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType); + +/** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp +An example using copyMakeBorder function. +Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details +*/ + +/** @brief Forms a border around an image. + +The function copies the source image into the middle of the destination image. The areas to the +left, to the right, above and below the copied source image will be filled with extrapolated +pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but +what other more complex functions, including your own, may do to simplify image boundary handling. + +The function supports the mode when src is already in the middle of dst . In this case, the +function does not copy src itself but simply constructs the border, for example: + +@code{.cpp} + // let border be the same in all directions + int border=2; + // constructs a larger image to fit both the image and the border + Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth()); + // select the middle part of it w/o copying data + Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows)); + // convert image from RGB to grayscale + cvtColor(rgb, gray, COLOR_RGB2GRAY); + // form a border in-place + copyMakeBorder(gray, gray_buf, border, border, + border, border, BORDER_REPLICATE); + // now do some custom filtering ... + ... +@endcode +@note When the source image is a part (ROI) of a bigger image, the function will try to use the +pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as +if src was not a ROI, use borderType | #BORDER_ISOLATED. + +@param src Source image. +@param dst Destination image of the same type as src and the size Size(src.cols+left+right, +src.rows+top+bottom) . +@param top the top pixels +@param bottom the bottom pixels +@param left the left pixels +@param right Parameter specifying how many pixels in each direction from the source image rectangle +to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs +to be built. +@param borderType Border type. See borderInterpolate for details. +@param value Border value if borderType==BORDER_CONSTANT . + +@sa borderInterpolate +*/ +CV_EXPORTS_W void copyMakeBorder(InputArray src, OutputArray dst, + int top, int bottom, int left, int right, + int borderType, const Scalar& value = Scalar() ); + +/** @brief Calculates the per-element sum of two arrays or an array and a scalar. + +The function add calculates: +- Sum of two arrays when both input arrays have the same size and the same number of channels: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f] +- Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of +elements as `src1.channels()`: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f] +- Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of +elements as `src2.channels()`: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f] +where `I` is a multi-dimensional index of array elements. In case of multi-channel arrays, each +channel is processed independently. + +The first function in the list above can be replaced with matrix expressions: +@code{.cpp} + dst = src1 + src2; + dst += src1; // equivalent to add(dst, src1, dst); +@endcode +The input arrays and the output array can all have the same or different depths. For example, you +can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit +floating-point array. Depth of the output array is determined by the dtype parameter. In the second +and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can +be set to the default -1. In this case, the output array will have the same depth as the input +array, be it src1, src2 or both. +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and number of channels as the input array(s); the +depth is defined by dtype or src1/src2. +@param mask optional operation mask - 8-bit single channel array, that specifies elements of the +output array to be changed. +@param dtype optional depth of the output array (see the discussion below). +@sa subtract, addWeighted, scaleAdd, Mat::convertTo +*/ +CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask = noArray(), int dtype = -1); + +/** @brief Calculates the per-element difference between two arrays or array and a scalar. + +The function subtract calculates: +- Difference between two arrays, when both input arrays have the same size and the same number of +channels: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f] +- Difference between an array and a scalar, when src2 is constructed from Scalar or has the same +number of elements as `src1.channels()`: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f] +- Difference between a scalar and an array, when src1 is constructed from Scalar or has the same +number of elements as `src2.channels()`: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f] +- The reverse difference between a scalar and an array in the case of `SubRS`: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\f] +where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each +channel is processed independently. + +The first function in the list above can be replaced with matrix expressions: +@code{.cpp} + dst = src1 - src2; + dst -= src1; // equivalent to subtract(dst, src1, dst); +@endcode +The input arrays and the output array can all have the same or different depths. For example, you +can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of +the output array is determined by dtype parameter. In the second and third cases above, as well as +in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this +case the output array will have the same depth as the input array, be it src1, src2 or both. +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array of the same size and the same number of channels as the input array. +@param mask optional operation mask; this is an 8-bit single channel array that specifies elements +of the output array to be changed. +@param dtype optional depth of the output array +@sa add, addWeighted, scaleAdd, Mat::convertTo + */ +CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask = noArray(), int dtype = -1); + + +/** @brief Calculates the per-element scaled product of two arrays. + +The function multiply calculates the per-element product of two arrays: + +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\f] + +There is also a @ref MatrixExpressions -friendly variant of the first function. See Mat::mul . + +For a not-per-element matrix product, see gemm . + +@note Saturation is not applied when the output array has the depth +CV_32S. You may even get result of an incorrect sign in the case of +overflow. +@param src1 first input array. +@param src2 second input array of the same size and the same type as src1. +@param dst output array of the same size and type as src1. +@param scale optional scale factor. +@param dtype optional depth of the output array +@sa add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare, +Mat::convertTo +*/ +CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, + OutputArray dst, double scale = 1, int dtype = -1); + +/** @brief Performs per-element division of two arrays or a scalar by an array. + +The function cv::divide divides one array by another: +\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f] +or a scalar by an array when there is no src1 : +\f[\texttt{dst(I) = saturate(scale/src2(I))}\f] + +Different channels of multi-channel arrays are processed independently. + +For integer types when src2(I) is zero, dst(I) will also be zero. + +@note In case of floating point data there is no special defined behavior for zero src2(I) values. +Regular floating-point division is used. +Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values). + +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array. +@param src2 second input array of the same size and type as src1. +@param scale scalar factor. +@param dst output array of the same size and type as src2. +@param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in +case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth(). +@sa multiply, add, subtract +*/ +CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, + double scale = 1, int dtype = -1); + +/** @overload */ +CV_EXPORTS_W void divide(double scale, InputArray src2, + OutputArray dst, int dtype = -1); + +/** @brief Calculates the sum of a scaled array and another array. + +The function scaleAdd is one of the classical primitive linear algebra operations, known as DAXPY +or SAXPY in [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It calculates +the sum of a scaled array and another array: +\f[\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\f] +The function can also be emulated with a matrix expression, for example: +@code{.cpp} + Mat A(3, 3, CV_64F); + ... + A.row(0) = A.row(1)*2 + A.row(2); +@endcode +@param src1 first input array. +@param alpha scale factor for the first array. +@param src2 second input array of the same size and type as src1. +@param dst output array of the same size and type as src1. +@sa add, addWeighted, subtract, Mat::dot, Mat::convertTo +*/ +CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst); + +/** @example samples/cpp/tutorial_code/HighGUI/AddingImagesTrackbar.cpp +Check @ref tutorial_trackbar "the corresponding tutorial" for more details +*/ + +/** @brief Calculates the weighted sum of two arrays. + +The function addWeighted calculates the weighted sum of two arrays as follows: +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] +where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each +channel is processed independently. +The function can be replaced with a matrix expression: +@code{.cpp} + dst = src1*alpha + src2*beta + gamma; +@endcode +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array. +@param alpha weight of the first array elements. +@param src2 second input array of the same size and channel number as src1. +@param beta weight of the second array elements. +@param gamma scalar added to each sum. +@param dst output array that has the same size and number of channels as the input arrays. +@param dtype optional depth of the output array; when both input arrays have the same depth, dtype +can be set to -1, which will be equivalent to src1.depth(). +@sa add, subtract, scaleAdd, Mat::convertTo +*/ +CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, + double beta, double gamma, OutputArray dst, int dtype = -1); + +/** @brief Scales, calculates absolute values, and converts the result to 8-bit. + +On each element of the input array, the function convertScaleAbs +performs three operations sequentially: scaling, taking an absolute +value, conversion to an unsigned 8-bit type: +\f[\texttt{dst} (I)= \texttt{saturate\_cast} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\f] +In case of multi-channel arrays, the function processes each channel +independently. When the output is not 8-bit, the operation can be +emulated by calling the Mat::convertTo method (or by using matrix +expressions) and then by calculating an absolute value of the result. +For example: +@code{.cpp} + Mat_ A(30,30); + randu(A, Scalar(-100), Scalar(100)); + Mat_ B = A*5 + 3; + B = abs(B); + // Mat_ B = abs(A*5+3) will also do the job, + // but it will allocate a temporary matrix +@endcode +@param src input array. +@param dst output array. +@param alpha optional scale factor. +@param beta optional delta added to the scaled values. +@sa Mat::convertTo, cv::abs(const Mat&) +*/ +CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst, + double alpha = 1, double beta = 0); + +/** @brief Converts an array to half precision floating number. + +This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). CV_16S format is used to represent FP16 data. +There are two use modes (src -> dst): CV_32F -> CV_16S and CV_16S -> CV_32F. The input array has to have type of CV_32F or +CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error. +The format of half precision floating point is defined in IEEE 754-2008. + +@param src input array. +@param dst output array. +*/ +CV_EXPORTS_W void convertFp16(InputArray src, OutputArray dst); + +/** @brief Performs a look-up table transform of an array. + +The function LUT fills the output array with values from the look-up table. Indices of the entries +are taken from the input array. That is, the function processes each element of src as follows: +\f[\texttt{dst} (I) \leftarrow \texttt{lut(src(I) + d)}\f] +where +\f[d = \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\f] +@param src input array of 8-bit elements. +@param lut look-up table of 256 elements; in case of multi-channel input array, the table should +either have a single channel (in this case the same table is used for all channels) or the same +number of channels as in the input array. +@param dst output array of the same size and number of channels as src, and the same depth as lut. +@sa convertScaleAbs, Mat::convertTo +*/ +CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst); + +/** @brief Calculates the sum of array elements. + +The function cv::sum calculates and returns the sum of array elements, +independently for each channel. +@param src input array that must have from 1 to 4 channels. +@sa countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce +*/ +CV_EXPORTS_AS(sumElems) Scalar sum(InputArray src); + +/** @brief Counts non-zero array elements. + +The function returns the number of non-zero elements in src : +\f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f] +@param src single-channel array. +@sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix +*/ +CV_EXPORTS_W int countNonZero( InputArray src ); + +/** @brief Returns the list of locations of non-zero pixels + +Given a binary matrix (likely returned from an operation such +as threshold(), compare(), >, ==, etc, return all of +the non-zero indices as a cv::Mat or std::vector (x,y) +For example: +@code{.cpp} + cv::Mat binaryImage; // input, binary image + cv::Mat locations; // output, locations of non-zero pixels + cv::findNonZero(binaryImage, locations); + + // access pixel coordinates + Point pnt = locations.at(i); +@endcode +or +@code{.cpp} + cv::Mat binaryImage; // input, binary image + vector locations; // output, locations of non-zero pixels + cv::findNonZero(binaryImage, locations); + + // access pixel coordinates + Point pnt = locations[i]; +@endcode +@param src single-channel array +@param idx the output array, type of cv::Mat or std::vector, corresponding to non-zero indices in the input +*/ +CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx ); + +/** @brief Calculates an average (mean) of array elements. + +The function cv::mean calculates the mean value M of array elements, +independently for each channel, and return it: +\f[\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\f] +When all the mask elements are 0's, the function returns Scalar::all(0) +@param src input array that should have from 1 to 4 channels so that the result can be stored in +Scalar_ . +@param mask optional operation mask. +@sa countNonZero, meanStdDev, norm, minMaxLoc +*/ +CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray()); + +/** Calculates a mean and standard deviation of array elements. + +The function cv::meanStdDev calculates the mean and the standard deviation M +of array elements independently for each channel and returns it via the +output parameters: +\f[\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\f] +When all the mask elements are 0's, the function returns +mean=stddev=Scalar::all(0). +@note The calculated standard deviation is only the diagonal of the +complete normalized covariance matrix. If the full matrix is needed, you +can reshape the multi-channel array M x N to the single-channel array +M\*N x mtx.channels() (only possible when the matrix is continuous) and +then pass the matrix to calcCovarMatrix . +@param src input array that should have from 1 to 4 channels so that the results can be stored in +Scalar_ 's. +@param mean output parameter: calculated mean value. +@param stddev output parameter: calculated standard deviation. +@param mask optional operation mask. +@sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix +*/ +CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, + InputArray mask=noArray()); + +/** @brief Calculates the absolute norm of an array. + +This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\ + \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\ + \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2 +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\ + \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\ + \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5. +\f} +The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$. +It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$. +![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png) + +When the mask parameter is specified and it is not empty, the norm is + +If normType is not specified, #NORM_L2 is used. +calculated only over the region specified by the mask. + +Multi-channel input arrays are treated as single-channel arrays, that is, +the results for all channels are combined. + +Hamming norms can only be calculated with CV_8U depth arrays. + +@param src1 first input array. +@param normType type of the norm (see #NormTypes). +@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. +*/ +CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray()); + +/** @brief Calculates an absolute difference norm or a relative difference norm. + +This version of cv::norm calculates the absolute difference norm +or the relative difference norm of arrays src1 and src2. +The type of norm to calculate is specified using #NormTypes. + +@param src1 first input array. +@param src2 second input array of the same size and the same type as src1. +@param normType type of the norm (see #NormTypes). +@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. +*/ +CV_EXPORTS_W double norm(InputArray src1, InputArray src2, + int normType = NORM_L2, InputArray mask = noArray()); +/** @overload +@param src first input array. +@param normType type of the norm (see #NormTypes). +*/ +CV_EXPORTS double norm( const SparseMat& src, int normType ); + +/** @brief Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric. + +This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB), +between two input arrays src1 and src2. The arrays must have the same type. + +The PSNR is calculated as follows: + +\f[ +\texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) } +\f] + +where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data) +and MSE is the mean squared error between the two arrays. + +@param src1 first input array. +@param src2 second input array of the same size as src1. +@param R the maximum pixel value (255 by default) + + */ +CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2, double R=255.); + +/** @brief naive nearest neighbor finder + +see http://en.wikipedia.org/wiki/Nearest_neighbor_search +@todo document + */ +CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, + OutputArray dist, int dtype, OutputArray nidx, + int normType = NORM_L2, int K = 0, + InputArray mask = noArray(), int update = 0, + bool crosscheck = false); + +/** @brief Normalizes the norm or value range of an array. + +The function cv::normalize normalizes scale and shift the input array elements so that +\f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f] +(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that +\f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f] + +when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be +normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this +sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or +min-max but modify the whole array, you can use norm and Mat::convertTo. + +In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this, +the range transformation for sparse matrices is not allowed since it can shift the zero level. + +Possible usage with some positive example data: +@code{.cpp} + vector positiveData = { 2.0, 8.0, 10.0 }; + vector normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax; + + // Norm to probability (total count) + // sum(numbers) = 20.0 + // 2.0 0.1 (2.0/20.0) + // 8.0 0.4 (8.0/20.0) + // 10.0 0.5 (10.0/20.0) + normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1); + + // Norm to unit vector: ||positiveData|| = 1.0 + // 2.0 0.15 + // 8.0 0.62 + // 10.0 0.77 + normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2); + + // Norm to max element + // 2.0 0.2 (2.0/10.0) + // 8.0 0.8 (8.0/10.0) + // 10.0 1.0 (10.0/10.0) + normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF); + + // Norm to range [0.0;1.0] + // 2.0 0.0 (shift to left border) + // 8.0 0.75 (6.0/8.0) + // 10.0 1.0 (shift to right border) + normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX); +@endcode + +@param src input array. +@param dst output array of the same size as src . +@param alpha norm value to normalize to or the lower range boundary in case of the range +normalization. +@param beta upper range boundary in case of the range normalization; it is not used for the norm +normalization. +@param norm_type normalization type (see cv::NormTypes). +@param dtype when negative, the output array has the same type as src; otherwise, it has the same +number of channels as src and the depth =CV_MAT_DEPTH(dtype). +@param mask optional operation mask. +@sa norm, Mat::convertTo, SparseMat::convertTo +*/ +CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, + int norm_type = NORM_L2, int dtype = -1, InputArray mask = noArray()); + +/** @overload +@param src input array. +@param dst output array of the same size as src . +@param alpha norm value to normalize to or the lower range boundary in case of the range +normalization. +@param normType normalization type (see cv::NormTypes). +*/ +CV_EXPORTS void normalize( const SparseMat& src, SparseMat& dst, double alpha, int normType ); + +/** @brief Finds the global minimum and maximum in an array. + +The function cv::minMaxLoc finds the minimum and maximum element values and their positions. The +extremums are searched across the whole array or, if mask is not an empty array, in the specified +array region. + +The function do not work with multi-channel arrays. If you need to find minimum or maximum +elements across all the channels, use Mat::reshape first to reinterpret the array as +single-channel. Or you may extract the particular channel using either extractImageCOI , or +mixChannels , or split . +@param src input single-channel array. +@param minVal pointer to the returned minimum value; NULL is used if not required. +@param maxVal pointer to the returned maximum value; NULL is used if not required. +@param minLoc pointer to the returned minimum location (in 2D case); NULL is used if not required. +@param maxLoc pointer to the returned maximum location (in 2D case); NULL is used if not required. +@param mask optional mask used to select a sub-array. +@sa max, min, reduceArgMin, reduceArgMax, compare, inRange, extractImageCOI, mixChannels, split, Mat::reshape +*/ +CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal, + CV_OUT double* maxVal = 0, CV_OUT Point* minLoc = 0, + CV_OUT Point* maxLoc = 0, InputArray mask = noArray()); + +/** + * @brief Finds indices of min elements along provided axis + * + * @note + * - If input or output array is not continuous, this function will create an internal copy. + * - NaN handling is left unspecified, see patchNaNs(). + * - The returned index is always in bounds of input matrix. + * + * @param src input single-channel array. + * @param dst output array of type CV_32SC1 with the same dimensionality as src, + * except for axis being reduced - it should be set to 1. + * @param lastIndex whether to get the index of first or last occurrence of min. + * @param axis axis to reduce along. + * @sa reduceArgMax, minMaxLoc, min, max, compare, reduce + */ +CV_EXPORTS_W void reduceArgMin(InputArray src, OutputArray dst, int axis, bool lastIndex = false); + +/** + * @brief Finds indices of max elements along provided axis + * + * @note + * - If input or output array is not continuous, this function will create an internal copy. + * - NaN handling is left unspecified, see patchNaNs(). + * - The returned index is always in bounds of input matrix. + * + * @param src input single-channel array. + * @param dst output array of type CV_32SC1 with the same dimensionality as src, + * except for axis being reduced - it should be set to 1. + * @param lastIndex whether to get the index of first or last occurrence of max. + * @param axis axis to reduce along. + * @sa reduceArgMin, minMaxLoc, min, max, compare, reduce + */ +CV_EXPORTS_W void reduceArgMax(InputArray src, OutputArray dst, int axis, bool lastIndex = false); + +/** @brief Finds the global minimum and maximum in an array + +The function cv::minMaxIdx finds the minimum and maximum element values and their positions. The +extremums are searched across the whole array or, if mask is not an empty array, in the specified +array region. The function does not work with multi-channel arrays. If you need to find minimum or +maximum elements across all the channels, use Mat::reshape first to reinterpret the array as +single-channel. Or you may extract the particular channel using either extractImageCOI , or +mixChannels , or split . In case of a sparse matrix, the minimum is found among non-zero elements +only. +@note When minIdx is not NULL, it must have at least 2 elements (as well as maxIdx), even if src is +a single-row or single-column matrix. In OpenCV (following MATLAB) each array has at least 2 +dimensions, i.e. single-column matrix is Mx1 matrix (and therefore minIdx/maxIdx will be +(i1,0)/(i2,0)) and single-row matrix is 1xN matrix (and therefore minIdx/maxIdx will be +(0,j1)/(0,j2)). +@param src input single-channel array. +@param minVal pointer to the returned minimum value; NULL is used if not required. +@param maxVal pointer to the returned maximum value; NULL is used if not required. +@param minIdx pointer to the returned minimum location (in nD case); NULL is used if not required; +Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element +in each dimension are stored there sequentially. +@param maxIdx pointer to the returned maximum location (in nD case). NULL is used if not required. +@param mask specified array region +*/ +CV_EXPORTS void minMaxIdx(InputArray src, double* minVal, double* maxVal = 0, + int* minIdx = 0, int* maxIdx = 0, InputArray mask = noArray()); + +/** @overload +@param a input single-channel array. +@param minVal pointer to the returned minimum value; NULL is used if not required. +@param maxVal pointer to the returned maximum value; NULL is used if not required. +@param minIdx pointer to the returned minimum location (in nD case); NULL is used if not required; +Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element +in each dimension are stored there sequentially. +@param maxIdx pointer to the returned maximum location (in nD case). NULL is used if not required. +*/ +CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal, + double* maxVal, int* minIdx = 0, int* maxIdx = 0); + +/** @brief Reduces a matrix to a vector. + +The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of +1D vectors and performing the specified operation on the vectors until a single row/column is +obtained. For example, the function can be used to compute horizontal and vertical projections of a +raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one. +In case of #REDUCE_SUM and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy. +And multi-channel arrays are also supported in these two reduction modes. + +The following code demonstrates its usage for a single channel matrix. +@snippet snippets/core_reduce.cpp example + +And the following code demonstrates its usage for a two-channel matrix. +@snippet snippets/core_reduce.cpp example2 + +@param src input 2D matrix. +@param dst output vector. Its size and type is defined by dim and dtype parameters. +@param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to +a single row. 1 means that the matrix is reduced to a single column. +@param rtype reduction operation that could be one of #ReduceTypes +@param dtype when negative, the output vector will have the same type as the input matrix, +otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()). +@sa repeat, reduceArgMin, reduceArgMax +*/ +CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype = -1); + +/** @brief Creates one multi-channel array out of several single-channel ones. + +The function cv::merge merges several arrays to make a single multi-channel array. That is, each +element of the output array will be a concatenation of the elements of the input arrays, where +elements of i-th input array are treated as mv[i].channels()-element vectors. + +The function cv::split does the reverse operation. If you need to shuffle channels in some other +advanced way, use cv::mixChannels. + +The following example shows how to merge 3 single channel matrices into a single 3-channel matrix. +@snippet snippets/core_merge.cpp example + +@param mv input array of matrices to be merged; all the matrices in mv must have the same +size and the same depth. +@param count number of input matrices when mv is a plain C array; it must be greater than zero. +@param dst output array of the same size and the same depth as mv[0]; The number of channels will +be equal to the parameter count. +@sa mixChannels, split, Mat::reshape +*/ +CV_EXPORTS void merge(const Mat* mv, size_t count, OutputArray dst); + +/** @overload +@param mv input vector of matrices to be merged; all the matrices in mv must have the same +size and the same depth. +@param dst output array of the same size and the same depth as mv[0]; The number of channels will +be the total number of channels in the matrix array. + */ +CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst); + +/** @brief Divides a multi-channel array into several single-channel arrays. + +The function cv::split splits a multi-channel array into separate single-channel arrays: +\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f] +If you need to extract a single channel or do some other sophisticated channel permutation, use +mixChannels . + +The following example demonstrates how to split a 3-channel matrix into 3 single channel matrices. +@snippet snippets/core_split.cpp example + +@param src input multi-channel array. +@param mvbegin output array; the number of arrays must match src.channels(); the arrays themselves are +reallocated, if needed. +@sa merge, mixChannels, cvtColor +*/ +CV_EXPORTS void split(const Mat& src, Mat* mvbegin); + +/** @overload +@param m input multi-channel array. +@param mv output vector of arrays; the arrays themselves are reallocated, if needed. +*/ +CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv); + +/** @brief Copies specified channels from input arrays to the specified channels of +output arrays. + +The function cv::mixChannels provides an advanced mechanism for shuffling image channels. + +cv::split,cv::merge,cv::extractChannel,cv::insertChannel and some forms of cv::cvtColor are partial cases of cv::mixChannels. + +In the example below, the code splits a 4-channel BGRA image into a 3-channel BGR (with B and R +channels swapped) and a separate alpha-channel image: +@code{.cpp} + Mat bgra( 100, 100, CV_8UC4, Scalar(255,0,0,255) ); + Mat bgr( bgra.rows, bgra.cols, CV_8UC3 ); + Mat alpha( bgra.rows, bgra.cols, CV_8UC1 ); + + // forming an array of matrices is a quite efficient operation, + // because the matrix data is not copied, only the headers + Mat out[] = { bgr, alpha }; + // bgra[0] -> bgr[2], bgra[1] -> bgr[1], + // bgra[2] -> bgr[0], bgra[3] -> alpha[0] + int from_to[] = { 0,2, 1,1, 2,0, 3,3 }; + mixChannels( &bgra, 1, out, 2, from_to, 4 ); +@endcode +@note Unlike many other new-style C++ functions in OpenCV (see the introduction section and +Mat::create ), cv::mixChannels requires the output arrays to be pre-allocated before calling the +function. +@param src input array or vector of matrices; all of the matrices must have the same size and the +same depth. +@param nsrcs number of matrices in `src`. +@param dst output array or vector of matrices; all the matrices **must be allocated**; their size and +depth must be the same as in `src[0]`. +@param ndsts number of matrices in `dst`. +@param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is +a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in +dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to +src[0].channels()-1, the second input image channels are indexed from src[0].channels() to +src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image +channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is +filled with zero . +@param npairs number of index pairs in `fromTo`. +@sa split, merge, extractChannel, insertChannel, cvtColor +*/ +CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, + const int* fromTo, size_t npairs); + +/** @overload +@param src input array or vector of matrices; all of the matrices must have the same size and the +same depth. +@param dst output array or vector of matrices; all the matrices **must be allocated**; their size and +depth must be the same as in src[0]. +@param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is +a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in +dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to +src[0].channels()-1, the second input image channels are indexed from src[0].channels() to +src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image +channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is +filled with zero . +@param npairs number of index pairs in fromTo. +*/ +CV_EXPORTS void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst, + const int* fromTo, size_t npairs); + +/** @overload +@param src input array or vector of matrices; all of the matrices must have the same size and the +same depth. +@param dst output array or vector of matrices; all the matrices **must be allocated**; their size and +depth must be the same as in src[0]. +@param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is +a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in +dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to +src[0].channels()-1, the second input image channels are indexed from src[0].channels() to +src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image +channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is +filled with zero . +*/ +CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst, + const std::vector& fromTo); + +/** @brief Extracts a single channel from src (coi is 0-based index) +@param src input array +@param dst output array +@param coi index of channel to extract +@sa mixChannels, split +*/ +CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi); + +/** @brief Inserts a single channel to dst (coi is 0-based index) +@param src input array +@param dst output array +@param coi index of channel for insertion +@sa mixChannels, merge +*/ +CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi); + +/** @brief Flips a 2D array around vertical, horizontal, or both axes. + +The function cv::flip flips the array in one of three different ways (row +and column indices are 0-based): +\f[\texttt{dst} _{ij} = +\left\{ +\begin{array}{l l} +\texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\ +\texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\ +\texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\ +\end{array} +\right.\f] +The example scenarios of using the function are the following: +* Vertical flipping of the image (flipCode == 0) to switch between + top-left and bottom-left image origin. This is a typical operation + in video processing on Microsoft Windows\* OS. +* Horizontal flipping of the image with the subsequent horizontal + shift and absolute difference calculation to check for a + vertical-axis symmetry (flipCode \> 0). +* Simultaneous horizontal and vertical flipping of the image with + the subsequent shift and absolute difference calculation to check + for a central symmetry (flipCode \< 0). +* Reversing the order of point arrays (flipCode \> 0 or + flipCode == 0). +@param src input array. +@param dst output array of the same size and type as src. +@param flipCode a flag to specify how to flip the array; 0 means +flipping around the x-axis and positive value (for example, 1) means +flipping around y-axis. Negative value (for example, -1) means flipping +around both axes. +@sa transpose , repeat , completeSymm +*/ +CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode); + +enum RotateFlags { + ROTATE_90_CLOCKWISE = 0, //! A = (cv::Mat_(3, 2) << 1, 4, + 2, 5, + 3, 6); + cv::Mat_ B = (cv::Mat_(3, 2) << 7, 10, + 8, 11, + 9, 12); + + cv::Mat C; + cv::hconcat(A, B, C); + //C: + //[1, 4, 7, 10; + // 2, 5, 8, 11; + // 3, 6, 9, 12] + @endcode + @param src1 first input array to be considered for horizontal concatenation. + @param src2 second input array to be considered for horizontal concatenation. + @param dst output array. It has the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2. + */ +CV_EXPORTS void hconcat(InputArray src1, InputArray src2, OutputArray dst); +/** @overload + @code{.cpp} + std::vector matrices = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)), + cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)), + cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),}; + + cv::Mat out; + cv::hconcat( matrices, out ); + //out: + //[1, 2, 3; + // 1, 2, 3; + // 1, 2, 3; + // 1, 2, 3] + @endcode + @param src input array or vector of matrices. all of the matrices must have the same number of rows and the same depth. + @param dst output array. It has the same number of rows and depth as the src, and the sum of cols of the src. +same depth. + */ +CV_EXPORTS_W void hconcat(InputArrayOfArrays src, OutputArray dst); + +/** @brief Applies vertical concatenation to given matrices. + +The function vertically concatenates two or more cv::Mat matrices (with the same number of cols). +@code{.cpp} + cv::Mat matArray[] = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),}; + + cv::Mat out; + cv::vconcat( matArray, 3, out ); + //out: + //[1, 1, 1, 1; + // 2, 2, 2, 2; + // 3, 3, 3, 3] +@endcode +@param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth. +@param nsrc number of matrices in src. +@param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src. +@sa cv::hconcat(const Mat*, size_t, OutputArray), @sa cv::hconcat(InputArrayOfArrays, OutputArray) and @sa cv::hconcat(InputArray, InputArray, OutputArray) +*/ +CV_EXPORTS void vconcat(const Mat* src, size_t nsrc, OutputArray dst); +/** @overload + @code{.cpp} + cv::Mat_ A = (cv::Mat_(3, 2) << 1, 7, + 2, 8, + 3, 9); + cv::Mat_ B = (cv::Mat_(3, 2) << 4, 10, + 5, 11, + 6, 12); + + cv::Mat C; + cv::vconcat(A, B, C); + //C: + //[1, 7; + // 2, 8; + // 3, 9; + // 4, 10; + // 5, 11; + // 6, 12] + @endcode + @param src1 first input array to be considered for vertical concatenation. + @param src2 second input array to be considered for vertical concatenation. + @param dst output array. It has the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2. + */ +CV_EXPORTS void vconcat(InputArray src1, InputArray src2, OutputArray dst); +/** @overload + @code{.cpp} + std::vector matrices = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),}; + + cv::Mat out; + cv::vconcat( matrices, out ); + //out: + //[1, 1, 1, 1; + // 2, 2, 2, 2; + // 3, 3, 3, 3] + @endcode + @param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth + @param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src. +same depth. + */ +CV_EXPORTS_W void vconcat(InputArrayOfArrays src, OutputArray dst); + +/** @brief computes bitwise conjunction of the two arrays (dst = src1 & src2) +Calculates the per-element bit-wise conjunction of two arrays or an +array and a scalar. + +The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for: +* Two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +* An array and a scalar when src2 is constructed from Scalar or has + the same number of elements as `src1.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\f] +* A scalar and an array when src1 is constructed from Scalar or has + the same number of elements as `src2.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +In case of floating-point arrays, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel arrays, each channel is processed +independently. In the second and third cases above, the scalar is first +converted to the array type. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as the input +arrays. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2, + OutputArray dst, InputArray mask = noArray()); + +/** @brief Calculates the per-element bit-wise disjunction of two arrays or an +array and a scalar. + +The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for: +* Two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +* An array and a scalar when src2 is constructed from Scalar or has + the same number of elements as `src1.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\f] +* A scalar and an array when src1 is constructed from Scalar or has + the same number of elements as `src2.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +In case of floating-point arrays, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel arrays, each channel is processed +independently. In the second and third cases above, the scalar is first +converted to the array type. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as the input +arrays. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2, + OutputArray dst, InputArray mask = noArray()); + +/** @brief Calculates the per-element bit-wise "exclusive or" operation on two +arrays or an array and a scalar. + +The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or" +operation for: +* Two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +* An array and a scalar when src2 is constructed from Scalar or has + the same number of elements as `src1.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\f] +* A scalar and an array when src1 is constructed from Scalar or has + the same number of elements as `src2.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +In case of floating-point arrays, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel arrays, each channel is processed +independently. In the 2nd and 3rd cases above, the scalar is first +converted to the array type. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as the input +arrays. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2, + OutputArray dst, InputArray mask = noArray()); + +/** @brief Inverts every bit of an array. + +The function cv::bitwise_not calculates per-element bit-wise inversion of the input +array: +\f[\texttt{dst} (I) = \neg \texttt{src} (I)\f] +In case of a floating-point input array, its machine-specific bit +representation (usually IEEE754-compliant) is used for the operation. In +case of multi-channel arrays, each channel is processed independently. +@param src input array. +@param dst output array that has the same size and type as the input +array. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_not(InputArray src, OutputArray dst, + InputArray mask = noArray()); + +/** @brief Calculates the per-element absolute difference between two arrays or between an array and a scalar. + +The function cv::absdiff calculates: +* Absolute difference between two arrays when they have the same + size and type: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f] +* Absolute difference between an array and a scalar when the second + array is constructed from Scalar or has as many elements as the + number of channels in `src1`: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\f] +* Absolute difference between a scalar and an array when the first + array is constructed from Scalar or has as many elements as the + number of channels in `src2`: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\f] + where I is a multi-dimensional index of array elements. In case of + multi-channel arrays, each channel is processed independently. +@note Saturation is not applied when the arrays have the depth CV_32S. +You may even get a negative value in the case of overflow. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as input arrays. +@sa cv::abs(const Mat&) +*/ +CV_EXPORTS_W void absdiff(InputArray src1, InputArray src2, OutputArray dst); + +/** @brief This is an overloaded member function, provided for convenience (python) +Copies the matrix to another one. +When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data. +@param src source matrix. +@param dst Destination matrix. If it does not have a proper size or type before the operation, it is +reallocated. +@param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix +elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. +*/ + +void CV_EXPORTS_W copyTo(InputArray src, OutputArray dst, InputArray mask); +/** @brief Checks if array elements lie between the elements of two other arrays. + +The function checks the range as follows: +- For every element of a single-channel input array: + \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0\f] +- For two-channel arrays: + \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0 \land \texttt{lowerb} (I)_1 \leq \texttt{src} (I)_1 \leq \texttt{upperb} (I)_1\f] +- and so forth. + +That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the +specified 1D, 2D, 3D, ... box and 0 otherwise. + +When the lower and/or upper boundary parameters are scalars, the indexes +(I) at lowerb and upperb in the above formulas should be omitted. +@param src first input array. +@param lowerb inclusive lower boundary array or a scalar. +@param upperb inclusive upper boundary array or a scalar. +@param dst output array of the same size as src and CV_8U type. +*/ +CV_EXPORTS_W void inRange(InputArray src, InputArray lowerb, + InputArray upperb, OutputArray dst); + +/** @brief Performs the per-element comparison of two arrays or an array and scalar value. + +The function compares: +* Elements of two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\f] +* Elements of src1 with a scalar src2 when src2 is constructed from + Scalar or has a single element: + \f[\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\f] +* src1 with elements of src2 when src1 is constructed from Scalar or + has a single element: + \f[\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\f] +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: +@code{.cpp} + Mat dst1 = src1 >= src2; + Mat dst2 = src1 < 8; + ... +@endcode +@param src1 first input array or a scalar; when it is an array, it must have a single channel. +@param src2 second input array or a scalar; when it is an array, it must have a single channel. +@param dst output array of type ref CV_8U that has the same size and the same number of channels as + the input arrays. +@param cmpop a flag, that specifies correspondence between the arrays (cv::CmpTypes) +@sa checkRange, min, max, threshold +*/ +CV_EXPORTS_W void compare(InputArray src1, InputArray src2, OutputArray dst, int cmpop); + +/** @brief Calculates per-element minimum of two arrays or an array and a scalar. + +The function cv::min calculates the per-element minimum of two arrays: +\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f] +or array and a scalar: +\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\f] +@param src1 first input array. +@param src2 second input array of the same size and type as src1. +@param dst output array of the same size and type as src1. +@sa max, compare, inRange, minMaxLoc +*/ +CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void min(const Mat& src1, const Mat& src2, Mat& dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void min(const UMat& src1, const UMat& src2, UMat& dst); + +/** @brief Calculates per-element maximum of two arrays or an array and a scalar. + +The function cv::max calculates the per-element maximum of two arrays: +\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f] +or array and a scalar: +\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\f] +@param src1 first input array. +@param src2 second input array of the same size and type as src1 . +@param dst output array of the same size and type as src1. +@sa min, compare, inRange, minMaxLoc, @ref MatrixExpressions +*/ +CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void max(const Mat& src1, const Mat& src2, Mat& dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void max(const UMat& src1, const UMat& src2, UMat& dst); + +/** @brief Calculates a square root of array elements. + +The function cv::sqrt calculates a square root of each input array element. +In case of multi-channel arrays, each channel is processed +independently. The accuracy is approximately the same as of the built-in +std::sqrt . +@param src input floating-point array. +@param dst output array of the same size and type as src. +*/ +CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst); + +/** @brief Raises every array element to a power. + +The function cv::pow raises every element of the input array to power : +\f[\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\f] + +So, for a non-integer power exponent, the absolute values of input array +elements are used. However, it is possible to get true values for +negative values using some extra operations. In the example below, +computing the 5th root of array src shows: +@code{.cpp} + Mat mask = src < 0; + pow(src, 1./5, dst); + subtract(Scalar::all(0), dst, dst, mask); +@endcode +For some values of power, such as integer values, 0.5 and -0.5, +specialized faster algorithms are used. + +Special values (NaN, Inf) are not handled. +@param src input array. +@param power exponent of power. +@param dst output array of the same size and type as src. +@sa sqrt, exp, log, cartToPolar, polarToCart +*/ +CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst); + +/** @brief Calculates the exponent of every array element. + +The function cv::exp calculates the exponent of every element of the input +array: +\f[\texttt{dst} [I] = e^{ src(I) }\f] + +The maximum relative error is about 7e-6 for single-precision input and +less than 1e-10 for double-precision input. Currently, the function +converts denormalized values to zeros on output. Special values (NaN, +Inf) are not handled. +@param src input array. +@param dst output array of the same size and type as src. +@sa log , cartToPolar , polarToCart , phase , pow , sqrt , magnitude +*/ +CV_EXPORTS_W void exp(InputArray src, OutputArray dst); + +/** @brief Calculates the natural logarithm of every array element. + +The function cv::log calculates the natural logarithm of every element of the input array: +\f[\texttt{dst} (I) = \log (\texttt{src}(I)) \f] + +Output on zero, negative and special (NaN, Inf) values is undefined. + +@param src input array. +@param dst output array of the same size and type as src . +@sa exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude +*/ +CV_EXPORTS_W void log(InputArray src, OutputArray dst); + +/** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle. + +The function cv::polarToCart calculates the Cartesian coordinates of each 2D +vector represented by the corresponding elements of magnitude and angle: +\f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f] + +The relative accuracy of the estimated coordinates is about 1e-6. +@param magnitude input floating-point array of magnitudes of 2D vectors; +it can be an empty matrix (=Mat()), in this case, the function assumes +that all the magnitudes are =1; if it is not empty, it must have the +same size and type as angle. +@param angle input floating-point array of angles of 2D vectors. +@param x output array of x-coordinates of 2D vectors; it has the same +size and type as angle. +@param y output array of y-coordinates of 2D vectors; it has the same +size and type as angle. +@param angleInDegrees when true, the input angles are measured in +degrees, otherwise, they are measured in radians. +@sa cartToPolar, magnitude, phase, exp, log, pow, sqrt +*/ +CV_EXPORTS_W void polarToCart(InputArray magnitude, InputArray angle, + OutputArray x, OutputArray y, bool angleInDegrees = false); + +/** @brief Calculates the magnitude and angle of 2D vectors. + +The function cv::cartToPolar calculates either the magnitude, angle, or both +for every 2D vector (x(I),y(I)): +\f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f] + +The angles are calculated with accuracy about 0.3 degrees. For the point +(0,0), the angle is set to 0. +@param x array of x-coordinates; this must be a single-precision or +double-precision floating-point array. +@param y array of y-coordinates, that must have the same size and same type as x. +@param magnitude output array of magnitudes of the same size and type as x. +@param angle output array of angles that has the same size and type as +x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees). +@param angleInDegrees a flag, indicating whether the angles are measured +in radians (which is by default), or in degrees. +@sa Sobel, Scharr +*/ +CV_EXPORTS_W void cartToPolar(InputArray x, InputArray y, + OutputArray magnitude, OutputArray angle, + bool angleInDegrees = false); + +/** @brief Calculates the rotation angle of 2D vectors. + +The function cv::phase calculates the rotation angle of each 2D vector that +is formed from the corresponding elements of x and y : +\f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f] + +The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 , +the corresponding angle(I) is set to 0. +@param x input floating-point array of x-coordinates of 2D vectors. +@param y input array of y-coordinates of 2D vectors; it must have the +same size and the same type as x. +@param angle output array of vector angles; it has the same size and +same type as x . +@param angleInDegrees when true, the function calculates the angle in +degrees, otherwise, they are measured in radians. +*/ +CV_EXPORTS_W void phase(InputArray x, InputArray y, OutputArray angle, + bool angleInDegrees = false); + +/** @brief Calculates the magnitude of 2D vectors. + +The function cv::magnitude calculates the magnitude of 2D vectors formed +from the corresponding elements of x and y arrays: +\f[\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\f] +@param x floating-point array of x-coordinates of the vectors. +@param y floating-point array of y-coordinates of the vectors; it must +have the same size as x. +@param magnitude output array of the same size and type as x. +@sa cartToPolar, polarToCart, phase, sqrt +*/ +CV_EXPORTS_W void magnitude(InputArray x, InputArray y, OutputArray magnitude); + +/** @brief Checks every element of an input array for invalid values. + +The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal \> +-DBL_MAX and maxVal \< DBL_MAX, the function also checks that each value is between minVal and +maxVal. In case of multi-channel arrays, each channel is processed independently. If some values +are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the +function either returns false (when quiet=true) or throws an exception. +@param a input array. +@param quiet a flag, indicating whether the functions quietly return false when the array elements +are out of range or they throw an exception. +@param pos optional output parameter, when not NULL, must be a pointer to array of src.dims +elements. +@param minVal inclusive lower boundary of valid values range. +@param maxVal exclusive upper boundary of valid values range. +*/ +CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0, + double minVal = -DBL_MAX, double maxVal = DBL_MAX); + +/** @brief converts NaNs to the given number +@param a input/output matrix (CV_32F type). +@param val value to convert the NaNs +*/ +CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0); + +/** @brief Performs generalized matrix multiplication. + +The function cv::gemm performs generalized matrix multiplication similar to the +gemm functions in BLAS level 3. For example, +`gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)` +corresponds to +\f[\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\f] + +In case of complex (two-channel) data, performed a complex matrix +multiplication. + +The function can be replaced with a matrix expression. For example, the +above call can be replaced with: +@code{.cpp} + dst = alpha*src1.t()*src2 + beta*src3.t(); +@endcode +@param src1 first multiplied input matrix that could be real(CV_32FC1, +CV_64FC1) or complex(CV_32FC2, CV_64FC2). +@param src2 second multiplied input matrix of the same type as src1. +@param alpha weight of the matrix product. +@param src3 third optional delta matrix added to the matrix product; it +should have the same type as src1 and src2. +@param beta weight of src3. +@param dst output matrix; it has the proper size and the same type as +input matrices. +@param flags operation flags (cv::GemmFlags) +@sa mulTransposed , transform +*/ +CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha, + InputArray src3, double beta, OutputArray dst, int flags = 0); + +/** @brief Calculates the product of a matrix and its transposition. + +The function cv::mulTransposed calculates the product of src and its +transposition: +\f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\f] +if aTa=true , and +\f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\f] +otherwise. The function is used to calculate the covariance matrix. With +zero delta, it can be used as a faster substitute for general matrix +product A\*B when B=A' +@param src input single-channel matrix. Note that unlike gemm, the +function can multiply not only floating-point matrices. +@param dst output square matrix. +@param aTa Flag specifying the multiplication ordering. See the +description below. +@param delta Optional delta matrix subtracted from src before the +multiplication. When the matrix is empty ( delta=noArray() ), it is +assumed to be zero, that is, nothing is subtracted. If it has the same +size as src , it is simply subtracted. Otherwise, it is "repeated" (see +repeat ) to cover the full src and then subtracted. Type of the delta +matrix, when it is not empty, must be the same as the type of created +output matrix. See the dtype parameter description below. +@param scale Optional scale factor for the matrix product. +@param dtype Optional type of the output matrix. When it is negative, +the output matrix will have the same type as src . Otherwise, it will be +type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F . +@sa calcCovarMatrix, gemm, repeat, reduce +*/ +CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, + InputArray delta = noArray(), + double scale = 1, int dtype = -1 ); + +/** @brief Transposes a matrix. + +The function cv::transpose transposes the matrix src : +\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f] +@note No complex conjugation is done in case of a complex matrix. It +should be done separately if needed. +@param src input array. +@param dst output array of the same type as src. +*/ +CV_EXPORTS_W void transpose(InputArray src, OutputArray dst); + +/** @brief Performs the matrix transformation of every array element. + +The function cv::transform performs the matrix transformation of every +element of the array src and stores the results in dst : +\f[\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\f] +(when m.cols=src.channels() ), or +\f[\texttt{dst} (I) = \texttt{m} \cdot [ \texttt{src} (I); 1]\f] +(when m.cols=src.channels()+1 ) + +Every element of the N -channel array src is interpreted as N -element +vector that is transformed using the M x N or M x (N+1) matrix m to +M-element vector - the corresponding element of the output array dst . + +The function may be used for geometrical transformation of +N -dimensional points, arbitrary linear color space transformation (such +as various kinds of RGB to YUV transforms), shuffling the image +channels, and so forth. +@param src input array that must have as many channels (1 to 4) as +m.cols or m.cols-1. +@param dst output array of the same size and depth as src; it has as +many channels as m.rows. +@param m transformation 2x2 or 2x3 floating-point matrix. +@sa perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective +*/ +CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m ); + +/** @brief Performs the perspective matrix transformation of vectors. + +The function cv::perspectiveTransform transforms every element of src by +treating it as a 2D or 3D vector, in the following way: +\f[(x, y, z) \rightarrow (x'/w, y'/w, z'/w)\f] +where +\f[(x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1 \end{bmatrix}\f] +and +\f[w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\f] + +Here a 3D vector transformation is shown. In case of a 2D vector +transformation, the z component is omitted. + +@note The function transforms a sparse set of 2D or 3D vectors. If you +want to transform an image using perspective transformation, use +warpPerspective . If you have an inverse problem, that is, you want to +compute the most probable perspective transformation out of several +pairs of corresponding points, you can use getPerspectiveTransform or +findHomography . +@param src input two-channel or three-channel floating-point array; each +element is a 2D/3D vector to be transformed. +@param dst output array of the same size and type as src. +@param m 3x3 or 4x4 floating-point transformation matrix. +@sa transform, warpPerspective, getPerspectiveTransform, findHomography +*/ +CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst, InputArray m ); + +/** @brief Copies the lower or the upper half of a square matrix to its another half. + +The function cv::completeSymm copies the lower or the upper half of a square matrix to +its another half. The matrix diagonal remains unchanged: + - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i > j\f$ if + lowerToUpper=false + - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i < j\f$ if + lowerToUpper=true + +@param m input-output floating-point square matrix. +@param lowerToUpper operation flag; if true, the lower half is copied to +the upper half. Otherwise, the upper half is copied to the lower half. +@sa flip, transpose +*/ +CV_EXPORTS_W void completeSymm(InputOutputArray m, bool lowerToUpper = false); + +/** @brief Initializes a scaled identity matrix. + +The function cv::setIdentity initializes a scaled identity matrix: +\f[\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\f] + +The function can also be emulated using the matrix initializers and the +matrix expressions: +@code + Mat A = Mat::eye(4, 3, CV_32F)*5; + // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]] +@endcode +@param mtx matrix to initialize (not necessarily square). +@param s value to assign to diagonal elements. +@sa Mat::zeros, Mat::ones, Mat::setTo, Mat::operator= +*/ +CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s = Scalar(1)); + +/** @brief Returns the determinant of a square floating-point matrix. + +The function cv::determinant calculates and returns the determinant of the +specified matrix. For small matrices ( mtx.cols=mtx.rows\<=3 ), the +direct method is used. For larger matrices, the function uses LU +factorization with partial pivoting. + +For symmetric positively-determined matrices, it is also possible to use +eigen decomposition to calculate the determinant. +@param mtx input matrix that must have CV_32FC1 or CV_64FC1 type and +square size. +@sa trace, invert, solve, eigen, @ref MatrixExpressions +*/ +CV_EXPORTS_W double determinant(InputArray mtx); + +/** @brief Returns the trace of a matrix. + +The function cv::trace returns the sum of the diagonal elements of the +matrix mtx . +\f[\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\f] +@param mtx input matrix. +*/ +CV_EXPORTS_W Scalar trace(InputArray mtx); + +/** @brief Finds the inverse or pseudo-inverse of a matrix. + +The function cv::invert inverts the matrix src and stores the result in dst +. When the matrix src is singular or non-square, the function calculates +the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is +minimal, where I is an identity matrix. + +In case of the #DECOMP_LU method, the function returns non-zero value if +the inverse has been successfully calculated and 0 if src is singular. + +In case of the #DECOMP_SVD method, the function returns the inverse +condition number of src (the ratio of the smallest singular value to the +largest singular value) and 0 if src is singular. The SVD method +calculates a pseudo-inverse matrix if src is singular. + +Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with +non-singular square matrices that should also be symmetrical and +positively defined. In this case, the function stores the inverted +matrix in dst and returns non-zero. Otherwise, it returns 0. + +@param src input floating-point M x N matrix. +@param dst output matrix of N x M size and the same type as src. +@param flags inversion method (cv::DecompTypes) +@sa solve, SVD +*/ +CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags = DECOMP_LU); + +/** @brief Solves one or more linear systems or least-squares problems. + +The function cv::solve solves a linear system or least-squares problem (the +latter is possible with SVD or QR methods, or by specifying the flag +#DECOMP_NORMAL ): +\f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\f] + +If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1 +if src1 (or \f$\texttt{src1}^T\texttt{src1}\f$ ) is non-singular. Otherwise, +it returns 0. In the latter case, dst is not valid. Other methods find a +pseudo-solution in case of a singular left-hand side part. + +@note If you want to find a unity-norm solution of an under-defined +singular system \f$\texttt{src1}\cdot\texttt{dst}=0\f$ , the function solve +will not do the work. Use SVD::solveZ instead. + +@param src1 input matrix on the left-hand side of the system. +@param src2 input matrix on the right-hand side of the system. +@param dst output solution. +@param flags solution (matrix inversion) method (#DecompTypes) +@sa invert, SVD, eigen +*/ +CV_EXPORTS_W bool solve(InputArray src1, InputArray src2, + OutputArray dst, int flags = DECOMP_LU); + +/** @brief Sorts each row or each column of a matrix. + +The function cv::sort sorts each matrix row or each matrix column in +ascending or descending order. So you should pass two operation flags to +get desired behaviour. If you want to sort matrix rows or columns +lexicographically, you can use STL std::sort generic function with the +proper comparison predicate. + +@param src input single-channel array. +@param dst output array of the same size and type as src. +@param flags operation flags, a combination of #SortFlags +@sa sortIdx, randShuffle +*/ +CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags); + +/** @brief Sorts each row or each column of a matrix. + +The function cv::sortIdx sorts each matrix row or each matrix column in the +ascending or descending order. So you should pass two operation flags to +get desired behaviour. Instead of reordering the elements themselves, it +stores the indices of sorted elements in the output array. For example: +@code + Mat A = Mat::eye(3,3,CV_32F), B; + sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING); + // B will probably contain + // (because of equal elements in A some permutations are possible): + // [[1, 2, 0], [0, 2, 1], [0, 1, 2]] +@endcode +@param src input single-channel array. +@param dst output integer array of the same size as src. +@param flags operation flags that could be a combination of cv::SortFlags +@sa sort, randShuffle +*/ +CV_EXPORTS_W void sortIdx(InputArray src, OutputArray dst, int flags); + +/** @brief Finds the real roots of a cubic equation. + +The function solveCubic finds the real roots of a cubic equation: +- if coeffs is a 4-element vector: +\f[\texttt{coeffs} [0] x^3 + \texttt{coeffs} [1] x^2 + \texttt{coeffs} [2] x + \texttt{coeffs} [3] = 0\f] +- if coeffs is a 3-element vector: +\f[x^3 + \texttt{coeffs} [0] x^2 + \texttt{coeffs} [1] x + \texttt{coeffs} [2] = 0\f] + +The roots are stored in the roots array. +@param coeffs equation coefficients, an array of 3 or 4 elements. +@param roots output array of real roots that has 1 or 3 elements. +@return number of real roots. It can be 0, 1 or 2. +*/ +CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots); + +/** @brief Finds the real or complex roots of a polynomial equation. + +The function cv::solvePoly finds real and complex roots of a polynomial equation: +\f[\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\f] +@param coeffs array of polynomial coefficients. +@param roots output (complex) array of roots. +@param maxIters maximum number of iterations the algorithm does. +*/ +CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters = 300); + +/** @brief Calculates eigenvalues and eigenvectors of a symmetric matrix. + +The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric +matrix src: +@code + src*eigenvectors.row(i).t() = eigenvalues.at(i)*eigenvectors.row(i).t() +@endcode + +@note Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix. + +@param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical +(src ^T^ == src). +@param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored +in the descending order. +@param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the +eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding +eigenvalues. +@sa eigenNonSymmetric, completeSymm , PCA +*/ +CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues, + OutputArray eigenvectors = noArray()); + +/** @brief Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only). + +@note Assumes real eigenvalues. + +The function calculates eigenvalues and eigenvectors (optional) of the square matrix src: +@code + src*eigenvectors.row(i).t() = eigenvalues.at(i)*eigenvectors.row(i).t() +@endcode + +@param src input matrix (CV_32FC1 or CV_64FC1 type). +@param eigenvalues output vector of eigenvalues (type is the same type as src). +@param eigenvectors output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues. +@sa eigen +*/ +CV_EXPORTS_W void eigenNonSymmetric(InputArray src, OutputArray eigenvalues, + OutputArray eigenvectors); + +/** @brief Calculates the covariance matrix of a set of vectors. + +The function cv::calcCovarMatrix calculates the covariance matrix and, optionally, the mean vector of +the set of input vectors. +@param samples samples stored as separate matrices +@param nsamples number of samples +@param covar output covariance matrix of the type ctype and square size. +@param mean input or output (depending on the flags) array as the average value of the input vectors. +@param flags operation flags as a combination of #CovarFlags +@param ctype type of the matrixl; it equals 'CV_64F' by default. +@sa PCA, mulTransposed, Mahalanobis +@todo InputArrayOfArrays +*/ +CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, + int flags, int ctype = CV_64F); + +/** @overload +@note use #COVAR_ROWS or #COVAR_COLS flag +@param samples samples stored as rows/columns of a single matrix. +@param covar output covariance matrix of the type ctype and square size. +@param mean input or output (depending on the flags) array as the average value of the input vectors. +@param flags operation flags as a combination of #CovarFlags +@param ctype type of the matrixl; it equals 'CV_64F' by default. +*/ +CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, + InputOutputArray mean, int flags, int ctype = CV_64F); + +/** wrap PCA::operator() */ +CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, int maxComponents = 0); + +/** wrap PCA::operator() and add eigenvalues output parameter */ +CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, OutputArray eigenvalues, + int maxComponents = 0); + +/** wrap PCA::operator() */ +CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, double retainedVariance); + +/** wrap PCA::operator() and add eigenvalues output parameter */ +CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, OutputArray eigenvalues, + double retainedVariance); + +/** wrap PCA::project */ +CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean, + InputArray eigenvectors, OutputArray result); + +/** wrap PCA::backProject */ +CV_EXPORTS_W void PCABackProject(InputArray data, InputArray mean, + InputArray eigenvectors, OutputArray result); + +/** wrap SVD::compute */ +CV_EXPORTS_W void SVDecomp( InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags = 0 ); + +/** wrap SVD::backSubst */ +CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt, + InputArray rhs, OutputArray dst ); + +/** @brief Calculates the Mahalanobis distance between two vectors. + +The function cv::Mahalanobis calculates and returns the weighted distance between two vectors: +\f[d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\f] +The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using +the invert function (preferably using the #DECOMP_SVD method, as the most accurate). +@param v1 first 1D input vector. +@param v2 second 1D input vector. +@param icovar inverse covariance matrix. +*/ +CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar); + +/** @brief Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array. + +The function cv::dft performs one of the following: +- Forward the Fourier transform of a 1D vector of N elements: + \f[Y = F^{(N)} \cdot X,\f] + where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$ +- Inverse the Fourier transform of a 1D vector of N elements: + \f[\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\f] + where \f$F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\f$ +- Forward the 2D Fourier transform of a M x N matrix: + \f[Y = F^{(M)} \cdot X \cdot F^{(N)}\f] +- Inverse the 2D Fourier transform of a M x N matrix: + \f[\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\f] + +In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input +spectrum of the inverse Fourier transform can be represented in a packed format called *CCS* +(complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here +is how 2D *CCS* spectrum looks: +\f[\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\f] + +In case of 1D transform of a real vector, the output looks like the first row of the matrix above. + +So, the function chooses an operation mode depending on the flags and size of the input array: +- If #DFT_ROWS is set or the input array has a single row or single column, the function + performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set. + Otherwise, it performs a 2D transform. +- If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or + 2D transform: + - When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as + input. + - When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as + input. In case of 2D transform, it uses the packed format as shown above. In case of a + single 1D transform, it looks like the first row of the matrix above. In case of + multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix + looks like the first row of the matrix above. +- If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the + output is a complex array of the same size as input. The function performs a forward or + inverse 1D or 2D transform of the whole input array or each row of the input array + independently, depending on the flags DFT_INVERSE and DFT_ROWS. +- When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT + is set, the output is a real array of the same size as input. The function performs a 1D or 2D + inverse transformation of the whole input array or each individual row, depending on the flags + #DFT_INVERSE and #DFT_ROWS. + +If #DFT_SCALE is set, the scaling is done after the transformation. + +Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed +efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the +current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize +method. + +The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays: +@code + void convolveDFT(InputArray A, InputArray B, OutputArray C) + { + // reallocate the output array if needed + C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type()); + Size dftSize; + // calculate the size of DFT transform + dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1); + dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1); + + // allocate temporary buffers and initialize them with 0's + Mat tempA(dftSize, A.type(), Scalar::all(0)); + Mat tempB(dftSize, B.type(), Scalar::all(0)); + + // copy A and B to the top-left corners of tempA and tempB, respectively + Mat roiA(tempA, Rect(0,0,A.cols,A.rows)); + A.copyTo(roiA); + Mat roiB(tempB, Rect(0,0,B.cols,B.rows)); + B.copyTo(roiB); + + // now transform the padded A & B in-place; + // use "nonzeroRows" hint for faster processing + dft(tempA, tempA, 0, A.rows); + dft(tempB, tempB, 0, B.rows); + + // multiply the spectrums; + // the function handles packed spectrum representations well + mulSpectrums(tempA, tempB, tempA); + + // transform the product back from the frequency domain. + // Even though all the result rows will be non-zero, + // you need only the first C.rows of them, and thus you + // pass nonzeroRows == C.rows + dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows); + + // now copy the result back to C. + tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C); + + // all the temporary buffers will be deallocated automatically + } +@endcode +To optimize this sample, consider the following approaches: +- Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to + the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole + tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols) + rightmost columns of the matrices. +- This DFT-based convolution does not have to be applied to the whole big arrays, especially if B + is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts. + To do this, you need to split the output array C into multiple tiles. For each tile, estimate + which parts of A and B are required to calculate convolution in this tile. If the tiles in C are + too small, the speed will decrease a lot because of repeated work. In the ultimate case, when + each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution + algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and + there is also a slowdown because of bad cache locality. So, there is an optimal tile size + somewhere in the middle. +- If different tiles in C can be calculated in parallel and, thus, the convolution is done by + parts, the loop can be threaded. + +All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by +using them, you can get the performance even better than with the above theoretically optimal +implementation. Though, those two functions actually calculate cross-correlation, not convolution, +so you need to "flip" the second convolution operand B vertically and horizontally using flip . +@note +- An example using the discrete fourier transform can be found at + opencv_source_code/samples/cpp/dft.cpp +- (Python) An example using the dft functionality to perform Wiener deconvolution can be found + at opencv_source/samples/python/deconvolution.py +- (Python) An example rearranging the quadrants of a Fourier image can be found at + opencv_source/samples/python/dft.py +@param src input array that could be real or complex. +@param dst output array whose size and type depends on the flags . +@param flags transformation flags, representing a combination of the #DftFlags +@param nonzeroRows when the parameter is not zero, the function assumes that only the first +nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the +output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the +rows more efficiently and save some time; this technique is very useful for calculating array +cross-correlation or convolution using DFT. +@sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar , +magnitude , phase +*/ +CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0); + +/** @brief Calculates the inverse Discrete Fourier Transform of a 1D or 2D array. + +idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) . +@note None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of +dft or idft explicitly to make these transforms mutually inverse. +@sa dft, dct, idct, mulSpectrums, getOptimalDFTSize +@param src input floating-point real or complex array. +@param dst output array whose size and type depend on the flags. +@param flags operation flags (see dft and #DftFlags). +@param nonzeroRows number of dst rows to process; the rest of the rows have undefined content (see +the convolution sample in dft description. +*/ +CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0); + +/** @brief Performs a forward or inverse discrete Cosine transform of 1D or 2D array. + +The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D +floating-point array: +- Forward Cosine transform of a 1D vector of N elements: + \f[Y = C^{(N)} \cdot X\f] + where + \f[C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\f] + and + \f$\alpha_0=1\f$, \f$\alpha_j=2\f$ for *j \> 0*. +- Inverse Cosine transform of a 1D vector of N elements: + \f[X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\f] + (since \f$C^{(N)}\f$ is an orthogonal matrix, \f$C^{(N)} \cdot \left(C^{(N)}\right)^T = I\f$ ) +- Forward 2D Cosine transform of M x N matrix: + \f[Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\f] +- Inverse 2D Cosine transform of M x N matrix: + \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f] + +The function chooses the mode of operation by looking at the flags and size of the input array: +- If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it + is an inverse 1D or 2D transform. +- If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row. +- If the array is a single column or a single row, the function performs a 1D transform. +- If none of the above is true, the function performs a 2D transform. + +@note Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you +can pad the array when necessary. +Also, the function performance depends very much, and not monotonically, on the array size (see +getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT +of a vector of size N/2 . Thus, the optimal DCT size N1 \>= N can be calculated as: +@code + size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); } + N1 = getOptimalDCTSize(N); +@endcode +@param src input floating-point array. +@param dst output array of the same size and type as src . +@param flags transformation flags as a combination of cv::DftFlags (DCT_*) +@sa dft , getOptimalDFTSize , idct +*/ +CV_EXPORTS_W void dct(InputArray src, OutputArray dst, int flags = 0); + +/** @brief Calculates the inverse Discrete Cosine Transform of a 1D or 2D array. + +idct(src, dst, flags) is equivalent to dct(src, dst, flags | DCT_INVERSE). +@param src input floating-point single-channel array. +@param dst output array of the same size and type as src. +@param flags operation flags. +@sa dct, dft, idft, getOptimalDFTSize +*/ +CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags = 0); + +/** @brief Performs the per-element multiplication of two Fourier spectrums. + +The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex +matrices that are results of a real or complex Fourier transform. + +The function, together with dft and idft , may be used to calculate convolution (pass conjB=false ) +or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are +simply multiplied (per element) with an optional conjugation of the second-array elements. When the +arrays are real, they are assumed to be CCS-packed (see dft for details). +@param a first input array. +@param b second input array of the same size and type as src1 . +@param c output array of the same size and type as src1 . +@param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that +each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a `0` as value. +@param conjB optional flag that conjugates the second input array before the multiplication (true) +or not (false). +*/ +CV_EXPORTS_W void mulSpectrums(InputArray a, InputArray b, OutputArray c, + int flags, bool conjB = false); + +/** @brief Returns the optimal DFT size for a given vector size. + +DFT performance is not a monotonic function of a vector size. Therefore, when you calculate +convolution of two arrays or perform the spectral analysis of an array, it usually makes sense to +pad the input data with zeros to get a bit larger array that can be transformed much faster than the +original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the fastest to process. +Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2) +are also processed quite efficiently. + +The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize +so that the DFT of a vector of size N can be processed efficiently. In the current implementation N += 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r. + +The function returns a negative number if vecsize is too large (very close to INT_MAX ). + +While the function cannot be used directly to estimate the optimal vector size for DCT transform +(since the current DCT implementation supports only even-size vectors), it can be easily processed +as getOptimalDFTSize((vecsize+1)/2)\*2. +@param vecsize vector size. +@sa dft , dct , idft , idct , mulSpectrums +*/ +CV_EXPORTS_W int getOptimalDFTSize(int vecsize); + +/** @brief Returns the default random number generator. + +The function cv::theRNG returns the default random number generator. For each thread, there is a +separate random number generator, so you can use the function safely in multi-thread environments. +If you just need to get a single random number using this generator or initialize an array, you can +use randu or randn instead. But if you are going to generate many random numbers inside a loop, it +is much faster to use this function to retrieve the generator and then use RNG::operator _Tp() . +@sa RNG, randu, randn +*/ +CV_EXPORTS RNG& theRNG(); + +/** @brief Sets state of default random number generator. + +The function cv::setRNGSeed sets state of default random number generator to custom value. +@param seed new state for default random number generator +@sa RNG, randu, randn +*/ +CV_EXPORTS_W void setRNGSeed(int seed); + +/** @brief Generates a single uniformly-distributed random number or an array of random numbers. + +Non-template variant of the function fills the matrix dst with uniformly-distributed +random numbers from the specified range: +\f[\texttt{low} _c \leq \texttt{dst} (I)_c < \texttt{high} _c\f] +@param dst output array of random numbers; the array must be pre-allocated. +@param low inclusive lower boundary of the generated random numbers. +@param high exclusive upper boundary of the generated random numbers. +@sa RNG, randn, theRNG +*/ +CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high); + +/** @brief Fills the array with normally distributed random numbers. + +The function cv::randn fills the matrix dst with normally distributed random numbers with the specified +mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the +value range of the output array data type. +@param dst output array of random numbers; the array must be pre-allocated and have 1 to 4 channels. +@param mean mean value (expectation) of the generated random numbers. +@param stddev standard deviation of the generated random numbers; it can be either a vector (in +which case a diagonal standard deviation matrix is assumed) or a square matrix. +@sa RNG, randu +*/ +CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev); + +/** @brief Shuffles the array elements randomly. + +The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and +swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor . +@param dst input/output numerical 1D array. +@param iterFactor scale factor that determines the number of random swap operations (see the details +below). +@param rng optional random number generator used for shuffling; if it is zero, theRNG () is used +instead. +@sa RNG, sort +*/ +CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0); + +/** @brief Principal Component Analysis + +The class is used to calculate a special basis for a set of vectors. The +basis will consist of eigenvectors of the covariance matrix calculated +from the input set of vectors. The class %PCA can also transform +vectors to/from the new coordinate space defined by the basis. Usually, +in this new coordinate system, each vector from the original set (and +any linear combination of such vectors) can be quite accurately +approximated by taking its first few components, corresponding to the +eigenvectors of the largest eigenvalues of the covariance matrix. +Geometrically it means that you calculate a projection of the vector to +a subspace formed by a few eigenvectors corresponding to the dominant +eigenvalues of the covariance matrix. And usually such a projection is +very close to the original vector. So, you can represent the original +vector from a high-dimensional space with a much shorter vector +consisting of the projected vector's coordinates in the subspace. Such a +transformation is also known as Karhunen-Loeve Transform, or KLT. +See http://en.wikipedia.org/wiki/Principal_component_analysis + +The sample below is the function that takes two matrices. The first +function stores a set of vectors (a row per vector) that is used to +calculate PCA. The second function stores another "test" set of vectors +(a row per vector). First, these vectors are compressed with PCA, then +reconstructed back, and then the reconstruction error norm is computed +and printed for each vector. : + +@code{.cpp} +using namespace cv; + +PCA compressPCA(const Mat& pcaset, int maxComponents, + const Mat& testset, Mat& compressed) +{ + PCA pca(pcaset, // pass the data + Mat(), // we do not have a pre-computed mean vector, + // so let the PCA engine to compute it + PCA::DATA_AS_ROW, // indicate that the vectors + // are stored as matrix rows + // (use PCA::DATA_AS_COL if the vectors are + // the matrix columns) + maxComponents // specify, how many principal components to retain + ); + // if there is no test data, just return the computed basis, ready-to-use + if( !testset.data ) + return pca; + CV_Assert( testset.cols == pcaset.cols ); + + compressed.create(testset.rows, maxComponents, testset.type()); + + Mat reconstructed; + for( int i = 0; i < testset.rows; i++ ) + { + Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed; + // compress the vector, the result will be stored + // in the i-th row of the output matrix + pca.project(vec, coeffs); + // and then reconstruct it + pca.backProject(coeffs, reconstructed); + // and measure the error + printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2)); + } + return pca; +} +@endcode +@sa calcCovarMatrix, mulTransposed, SVD, dft, dct +*/ +class CV_EXPORTS PCA +{ +public: + enum Flags { DATA_AS_ROW = 0, //!< indicates that the input samples are stored as matrix rows + DATA_AS_COL = 1, //!< indicates that the input samples are stored as matrix columns + USE_AVG = 2 //! + }; + + /** @brief default constructor + + The default constructor initializes an empty %PCA structure. The other + constructors initialize the structure and call PCA::operator()(). + */ + PCA(); + + /** @overload + @param data input samples stored as matrix rows or matrix columns. + @param mean optional mean value; if the matrix is empty (@c noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout (PCA::Flags) + @param maxComponents maximum number of components that %PCA should + retain; by default, all the components are retained. + */ + PCA(InputArray data, InputArray mean, int flags, int maxComponents = 0); + + /** @overload + @param data input samples stored as matrix rows or matrix columns. + @param mean optional mean value; if the matrix is empty (noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout (PCA::Flags) + @param retainedVariance Percentage of variance that PCA should retain. + Using this parameter will let the PCA decided how many components to + retain but it will always keep at least 2. + */ + PCA(InputArray data, InputArray mean, int flags, double retainedVariance); + + /** @brief performs %PCA + + The operator performs %PCA of the supplied dataset. It is safe to reuse + the same PCA structure for multiple datasets. That is, if the structure + has been previously used with another dataset, the existing internal + data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref + mean are allocated and computed. + + The computed @ref eigenvalues are sorted from the largest to the smallest and + the corresponding @ref eigenvectors are stored as eigenvectors rows. + + @param data input samples stored as the matrix rows or as the matrix + columns. + @param mean optional mean value; if the matrix is empty (noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout. (Flags) + @param maxComponents maximum number of components that PCA should + retain; by default, all the components are retained. + */ + PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents = 0); + + /** @overload + @param data input samples stored as the matrix rows or as the matrix + columns. + @param mean optional mean value; if the matrix is empty (noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout. (PCA::Flags) + @param retainedVariance Percentage of variance that %PCA should retain. + Using this parameter will let the %PCA decided how many components to + retain but it will always keep at least 2. + */ + PCA& operator()(InputArray data, InputArray mean, int flags, double retainedVariance); + + /** @brief Projects vector(s) to the principal component subspace. + + The methods project one or more vectors to the principal component + subspace, where each vector projection is represented by coefficients in + the principal component basis. The first form of the method returns the + matrix that the second form writes to the result. So the first form can + be used as a part of expression while the second form can be more + efficient in a processing loop. + @param vec input vector(s); must have the same dimensionality and the + same layout as the input data used at %PCA phase, that is, if + DATA_AS_ROW are specified, then `vec.cols==data.cols` + (vector dimensionality) and `vec.rows` is the number of vectors to + project, and the same is true for the PCA::DATA_AS_COL case. + */ + Mat project(InputArray vec) const; + + /** @overload + @param vec input vector(s); must have the same dimensionality and the + same layout as the input data used at PCA phase, that is, if + DATA_AS_ROW are specified, then `vec.cols==data.cols` + (vector dimensionality) and `vec.rows` is the number of vectors to + project, and the same is true for the PCA::DATA_AS_COL case. + @param result output vectors; in case of PCA::DATA_AS_COL, the + output matrix has as many columns as the number of input vectors, this + means that `result.cols==vec.cols` and the number of rows match the + number of principal components (for example, `maxComponents` parameter + passed to the constructor). + */ + void project(InputArray vec, OutputArray result) const; + + /** @brief Reconstructs vectors from their PC projections. + + The methods are inverse operations to PCA::project. They take PC + coordinates of projected vectors and reconstruct the original vectors. + Unless all the principal components have been retained, the + reconstructed vectors are different from the originals. But typically, + the difference is small if the number of components is large enough (but + still much smaller than the original vector dimensionality). As a + result, PCA is used. + @param vec coordinates of the vectors in the principal component + subspace, the layout and size are the same as of PCA::project output + vectors. + */ + Mat backProject(InputArray vec) const; + + /** @overload + @param vec coordinates of the vectors in the principal component + subspace, the layout and size are the same as of PCA::project output + vectors. + @param result reconstructed vectors; the layout and size are the same as + of PCA::project input vectors. + */ + void backProject(InputArray vec, OutputArray result) const; + + /** @brief write PCA objects + + Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage + */ + void write(FileStorage& fs) const; + + /** @brief load PCA objects + + Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode + */ + void read(const FileNode& fn); + + Mat eigenvectors; //!< eigenvectors of the covariation matrix + Mat eigenvalues; //!< eigenvalues of the covariation matrix + Mat mean; //!< mean value subtracted before the projection and added after the back projection +}; + +/** @example samples/cpp/pca.cpp +An example using %PCA for dimensionality reduction while maintaining an amount of variance +*/ + +/** @example samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp +Check @ref tutorial_introduction_to_pca "the corresponding tutorial" for more details +*/ + +/** +@brief Linear Discriminant Analysis +@todo document this class +*/ +class CV_EXPORTS LDA +{ +public: + /** @brief constructor + Initializes a LDA with num_components (default 0). + */ + explicit LDA(int num_components = 0); + + /** Initializes and performs a Discriminant Analysis with Fisher's + Optimization Criterion on given data in src and corresponding labels + in labels. If 0 (or less) number of components are given, they are + automatically determined for given data in computation. + */ + LDA(InputArrayOfArrays src, InputArray labels, int num_components = 0); + + /** Serializes this object to a given filename. + */ + void save(const String& filename) const; + + /** Deserializes this object from a given filename. + */ + void load(const String& filename); + + /** Serializes this object to a given cv::FileStorage. + */ + void save(FileStorage& fs) const; + + /** Deserializes this object from a given cv::FileStorage. + */ + void load(const FileStorage& node); + + /** destructor + */ + ~LDA(); + + /** Compute the discriminants for data in src (row aligned) and labels. + */ + void compute(InputArrayOfArrays src, InputArray labels); + + /** Projects samples into the LDA subspace. + src may be one or more row aligned samples. + */ + Mat project(InputArray src); + + /** Reconstructs projections from the LDA subspace. + src may be one or more row aligned projections. + */ + Mat reconstruct(InputArray src); + + /** Returns the eigenvectors of this LDA. + */ + Mat eigenvectors() const { return _eigenvectors; } + + /** Returns the eigenvalues of this LDA. + */ + Mat eigenvalues() const { return _eigenvalues; } + + static Mat subspaceProject(InputArray W, InputArray mean, InputArray src); + static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src); + +protected: + int _num_components; + Mat _eigenvectors; + Mat _eigenvalues; + void lda(InputArrayOfArrays src, InputArray labels); +}; + +/** @brief Singular Value Decomposition + +Class for computing Singular Value Decomposition of a floating-point +matrix. The Singular Value Decomposition is used to solve least-square +problems, under-determined linear systems, invert matrices, compute +condition numbers, and so on. + +If you want to compute a condition number of a matrix or an absolute value of +its determinant, you do not need `u` and `vt`. You can pass +flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u +and vt must be computed, which is not necessary most of the time. + +@sa invert, solve, eigen, determinant +*/ +class CV_EXPORTS SVD +{ +public: + enum Flags { + /** allow the algorithm to modify the decomposed matrix; it can save space and speed up + processing. currently ignored. */ + MODIFY_A = 1, + /** indicates that only a vector of singular values `w` is to be processed, while u and vt + will be set to empty matrices */ + NO_UV = 2, + /** when the matrix is not square, by default the algorithm produces u and vt matrices of + sufficiently large size for the further A reconstruction; if, however, FULL_UV flag is + specified, u and vt will be full-size square orthogonal matrices.*/ + FULL_UV = 4 + }; + + /** @brief the default constructor + + initializes an empty SVD structure + */ + SVD(); + + /** @overload + initializes an empty SVD structure and then calls SVD::operator() + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param flags operation flags (SVD::Flags) + */ + SVD( InputArray src, int flags = 0 ); + + /** @brief the operator that performs SVD. The previously allocated u, w and vt are released. + + The operator performs the singular value decomposition of the supplied + matrix. The u,`vt` , and the vector of singular values w are stored in + the structure. The same SVD structure can be reused many times with + different matrices. Each time, if needed, the previous u,`vt` , and w + are reclaimed and the new matrices are created, which is all handled by + Mat::create. + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param flags operation flags (SVD::Flags) + */ + SVD& operator ()( InputArray src, int flags = 0 ); + + /** @brief decomposes matrix and stores the results to user-provided matrices + + The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor + and SVD::operator(), they store the results to the user-provided + matrices: + + @code{.cpp} + Mat A, w, u, vt; + SVD::compute(A, w, u, vt); + @endcode + + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param w calculated singular values + @param u calculated left singular vectors + @param vt transposed matrix of right singular vectors + @param flags operation flags - see SVD::Flags. + */ + static void compute( InputArray src, OutputArray w, + OutputArray u, OutputArray vt, int flags = 0 ); + + /** @overload + computes singular values of a matrix + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param w calculated singular values + @param flags operation flags - see SVD::Flags. + */ + static void compute( InputArray src, OutputArray w, int flags = 0 ); + + /** @brief performs back substitution + */ + static void backSubst( InputArray w, InputArray u, + InputArray vt, InputArray rhs, + OutputArray dst ); + + /** @brief solves an under-determined singular linear system + + The method finds a unit-length solution x of a singular linear system + A\*x = 0. Depending on the rank of A, there can be no solutions, a + single solution or an infinite number of solutions. In general, the + algorithm solves the following problem: + \f[dst = \arg \min _{x: \| x \| =1} \| src \cdot x \|\f] + @param src left-hand-side matrix. + @param dst found solution. + */ + static void solveZ( InputArray src, OutputArray dst ); + + /** @brief performs a singular value back substitution. + + The method calculates a back substitution for the specified right-hand + side: + + \f[\texttt{x} = \texttt{vt} ^T \cdot diag( \texttt{w} )^{-1} \cdot \texttt{u} ^T \cdot \texttt{rhs} \sim \texttt{A} ^{-1} \cdot \texttt{rhs}\f] + + Using this technique you can either get a very accurate solution of the + convenient linear system, or the best (in the least-squares terms) + pseudo-solution of an overdetermined linear system. + + @param rhs right-hand side of a linear system (u\*w\*v')\*dst = rhs to + be solved, where A has been previously decomposed. + + @param dst found solution of the system. + + @note Explicit SVD with the further back substitution only makes sense + if you need to solve many linear systems with the same left-hand side + (for example, src ). If all you need is to solve a single system + (possibly with multiple rhs immediately available), simply call solve + add pass #DECOMP_SVD there. It does absolutely the same thing. + */ + void backSubst( InputArray rhs, OutputArray dst ) const; + + /** @todo document */ + template static + void compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt ); + + /** @todo document */ + template static + void compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w ); + + /** @todo document */ + template static + void backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u, const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, Matx<_Tp, n, nb>& dst ); + + Mat u, w, vt; +}; + +/** @brief Random Number Generator + +Random number generator. It encapsulates the state (currently, a 64-bit +integer) and has methods to return scalar random values and to fill +arrays with random values. Currently it supports uniform and Gaussian +(normal) distributions. The generator uses Multiply-With-Carry +algorithm, introduced by G. Marsaglia ( + ). +Gaussian-distribution random numbers are generated using the Ziggurat +algorithm ( ), +introduced by G. Marsaglia and W. W. Tsang. +*/ +class CV_EXPORTS RNG +{ +public: + enum { UNIFORM = 0, + NORMAL = 1 + }; + + /** @brief constructor + + These are the RNG constructors. The first form sets the state to some + pre-defined value, equal to 2\*\*32-1 in the current implementation. The + second form sets the state to the specified value. If you passed state=0 + , the constructor uses the above default value instead to avoid the + singular random number sequence, consisting of all zeros. + */ + RNG(); + /** @overload + @param state 64-bit value used to initialize the RNG. + */ + RNG(uint64 state); + /**The method updates the state using the MWC algorithm and returns the + next 32-bit random number.*/ + unsigned next(); + + /**Each of the methods updates the state using the MWC algorithm and + returns the next random number of the specified type. In case of integer + types, the returned number is from the available value range for the + specified type. In case of floating-point types, the returned value is + from [0,1) range. + */ + operator uchar(); + /** @overload */ + operator schar(); + /** @overload */ + operator ushort(); + /** @overload */ + operator short(); + /** @overload */ + operator unsigned(); + /** @overload */ + operator int(); + /** @overload */ + operator float(); + /** @overload */ + operator double(); + + /** @brief returns a random integer sampled uniformly from [0, N). + + The methods transform the state using the MWC algorithm and return the + next random number. The first form is equivalent to RNG::next . The + second form returns the random number modulo N , which means that the + result is in the range [0, N) . + */ + unsigned operator ()(); + /** @overload + @param N upper non-inclusive boundary of the returned random number. + */ + unsigned operator ()(unsigned N); + + /** @brief returns uniformly distributed integer random number from [a,b) range + + The methods transform the state using the MWC algorithm and return the + next uniformly-distributed random number of the specified type, deduced + from the input parameter type, from the range [a, b) . There is a nuance + illustrated by the following sample: + + @code{.cpp} + RNG rng; + + // always produces 0 + double a = rng.uniform(0, 1); + + // produces double from [0, 1) + double a1 = rng.uniform((double)0, (double)1); + + // produces float from [0, 1) + float b = rng.uniform(0.f, 1.f); + + // produces double from [0, 1) + double c = rng.uniform(0., 1.); + + // may cause compiler error because of ambiguity: + // RNG::uniform(0, (int)0.999999)? or RNG::uniform((double)0, 0.99999)? + double d = rng.uniform(0, 0.999999); + @endcode + + The compiler does not take into account the type of the variable to + which you assign the result of RNG::uniform . The only thing that + matters to the compiler is the type of a and b parameters. So, if you + want a floating-point random number, but the range boundaries are + integer numbers, either put dots in the end, if they are constants, or + use explicit type cast operators, as in the a1 initialization above. + @param a lower inclusive boundary of the returned random number. + @param b upper non-inclusive boundary of the returned random number. + */ + int uniform(int a, int b); + /** @overload */ + float uniform(float a, float b); + /** @overload */ + double uniform(double a, double b); + + /** @brief Fills arrays with random numbers. + + @param mat 2D or N-dimensional matrix; currently matrices with more than + 4 channels are not supported by the methods, use Mat::reshape as a + possible workaround. + @param distType distribution type, RNG::UNIFORM or RNG::NORMAL. + @param a first distribution parameter; in case of the uniform + distribution, this is an inclusive lower boundary, in case of the normal + distribution, this is a mean value. + @param b second distribution parameter; in case of the uniform + distribution, this is a non-inclusive upper boundary, in case of the + normal distribution, this is a standard deviation (diagonal of the + standard deviation matrix or the full standard deviation matrix). + @param saturateRange pre-saturation flag; for uniform distribution only; + if true, the method will first convert a and b to the acceptable value + range (according to the mat datatype) and then will generate uniformly + distributed random numbers within the range [saturate(a), saturate(b)), + if saturateRange=false, the method will generate uniformly distributed + random numbers in the original range [a, b) and then will saturate them, + it means, for example, that + theRNG().fill(mat_8u, RNG::UNIFORM, -DBL_MAX, DBL_MAX) will likely + produce array mostly filled with 0's and 255's, since the range (0, 255) + is significantly smaller than [-DBL_MAX, DBL_MAX). + + Each of the methods fills the matrix with the random values from the + specified distribution. As the new numbers are generated, the RNG state + is updated accordingly. In case of multiple-channel images, every + channel is filled independently, which means that RNG cannot generate + samples from the multi-dimensional Gaussian distribution with + non-diagonal covariance matrix directly. To do that, the method + generates samples from multi-dimensional standard Gaussian distribution + with zero mean and identity covariation matrix, and then transforms them + using transform to get samples from the specified Gaussian distribution. + */ + void fill( InputOutputArray mat, int distType, InputArray a, InputArray b, bool saturateRange = false ); + + /** @brief Returns the next random number sampled from the Gaussian distribution + @param sigma standard deviation of the distribution. + + The method transforms the state using the MWC algorithm and returns the + next random number from the Gaussian distribution N(0,sigma) . That is, + the mean value of the returned random numbers is zero and the standard + deviation is the specified sigma . + */ + double gaussian(double sigma); + + uint64 state; + + bool operator ==(const RNG& other) const; +}; + +/** @brief Mersenne Twister random number generator + +Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c +@todo document +*/ +class CV_EXPORTS RNG_MT19937 +{ +public: + RNG_MT19937(); + RNG_MT19937(unsigned s); + void seed(unsigned s); + + unsigned next(); + + operator int(); + operator unsigned(); + operator float(); + operator double(); + + unsigned operator ()(unsigned N); + unsigned operator ()(); + + /** @brief returns uniformly distributed integer random number from [a,b) range*/ + int uniform(int a, int b); + /** @brief returns uniformly distributed floating-point random number from [a,b) range*/ + float uniform(float a, float b); + /** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range*/ + double uniform(double a, double b); + +private: + enum PeriodParameters {N = 624, M = 397}; + unsigned state[N]; + int mti; +}; + +//! @} core_array + +//! @addtogroup core_cluster +//! @{ + +/** @example samples/cpp/kmeans.cpp +An example on K-means clustering +*/ + +/** @brief Finds centers of clusters and groups input samples around the clusters. + +The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters +and groups the input samples around the clusters. As an output, \f$\texttt{bestLabels}_i\f$ contains a +0-based cluster index for the sample stored in the \f$i^{th}\f$ row of the samples matrix. + +@note +- (Python) An example on K-means clustering can be found at + opencv_source_code/samples/python/kmeans.py +@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed. +Examples of this array can be: +- Mat points(count, 2, CV_32F); +- Mat points(count, 1, CV_32FC2); +- Mat points(1, count, CV_32FC2); +- std::vector\ points(sampleCount); +@param K Number of clusters to split the set by. +@param bestLabels Input/output integer array that stores the cluster indices for every sample. +@param criteria The algorithm termination criteria, that is, the maximum number of iterations and/or +the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster +centers moves by less than criteria.epsilon on some iteration, the algorithm stops. +@param attempts Flag to specify the number of times the algorithm is executed using different +initial labellings. The algorithm returns the labels that yield the best compactness (see the last +function parameter). +@param flags Flag that can take values of cv::KmeansFlags +@param centers Output matrix of the cluster centers, one row per each cluster center. +@return The function returns the compactness measure that is computed as +\f[\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\f] +after every attempt. The best (minimum) value is chosen and the corresponding labels and the +compactness value are returned by the function. Basically, you can use only the core of the +function, set the number of attempts to 1, initialize labels each time using a custom algorithm, +pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best +(most-compact) clustering. +*/ +CV_EXPORTS_W double kmeans( InputArray data, int K, InputOutputArray bestLabels, + TermCriteria criteria, int attempts, + int flags, OutputArray centers = noArray() ); + +//! @} core_cluster + +//! @addtogroup core_basic +//! @{ + +/////////////////////////////// Formatted output of cv::Mat /////////////////////////// + +/** @todo document */ +class CV_EXPORTS Formatted +{ +public: + virtual const char* next() = 0; + virtual void reset() = 0; + virtual ~Formatted(); +}; + +/** @todo document */ +class CV_EXPORTS Formatter +{ +public: + enum FormatType { + FMT_DEFAULT = 0, + FMT_MATLAB = 1, + FMT_CSV = 2, + FMT_PYTHON = 3, + FMT_NUMPY = 4, + FMT_C = 5 + }; + + virtual ~Formatter(); + + virtual Ptr format(const Mat& mtx) const = 0; + + virtual void set16fPrecision(int p = 4) = 0; + virtual void set32fPrecision(int p = 8) = 0; + virtual void set64fPrecision(int p = 16) = 0; + virtual void setMultiline(bool ml = true) = 0; + + static Ptr get(Formatter::FormatType fmt = FMT_DEFAULT); + +}; + +static inline +String& operator << (String& out, Ptr fmtd) +{ + fmtd->reset(); + for(const char* str = fmtd->next(); str; str = fmtd->next()) + out += cv::String(str); + return out; +} + +static inline +String& operator << (String& out, const Mat& mtx) +{ + return out << Formatter::get()->format(mtx); +} + +//////////////////////////////////////// Algorithm //////////////////////////////////// + +class CV_EXPORTS Algorithm; + +template struct ParamType {}; + + +/** @brief This is a base class for all more or less complex algorithms in OpenCV + +especially for classes of algorithms, for which there can be multiple implementations. The examples +are stereo correspondence (for which there are algorithms like block matching, semi-global block +matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians +models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck +etc.). + +Here is example of SimpleBlobDetector use in your application via Algorithm interface: +@snippet snippets/core_various.cpp Algorithm +*/ +class CV_EXPORTS_W Algorithm +{ +public: + Algorithm(); + virtual ~Algorithm(); + + /** @brief Clears the algorithm state + */ + CV_WRAP virtual void clear() {} + + /** @brief Stores algorithm parameters in a file storage + */ + virtual void write(FileStorage& fs) const { CV_UNUSED(fs); } + + /** @brief simplified API for language bindings + * @overload + */ + CV_WRAP void write(const Ptr& fs, const String& name = String()) const; + + /** @brief Reads algorithm parameters from a file storage + */ + CV_WRAP virtual void read(const FileNode& fn) { CV_UNUSED(fn); } + + /** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read + */ + CV_WRAP virtual bool empty() const { return false; } + + /** @brief Reads algorithm from the file node + + This is static template method of Algorithm. It's usage is following (in the case of SVM): + @code + cv::FileStorage fsRead("example.xml", FileStorage::READ); + Ptr svm = Algorithm::read(fsRead.root()); + @endcode + In order to make this method work, the derived class must overwrite Algorithm::read(const + FileNode& fn) and also have static create() method without parameters + (or with all the optional parameters) + */ + template static Ptr<_Tp> read(const FileNode& fn) + { + Ptr<_Tp> obj = _Tp::create(); + obj->read(fn); + return !obj->empty() ? obj : Ptr<_Tp>(); + } + + /** @brief Loads algorithm from the file + + @param filename Name of the file to read. + @param objname The optional name of the node to read (if empty, the first top-level node will be used) + + This is static template method of Algorithm. It's usage is following (in the case of SVM): + @code + Ptr svm = Algorithm::load("my_svm_model.xml"); + @endcode + In order to make this method work, the derived class must overwrite Algorithm::read(const + FileNode& fn). + */ + template static Ptr<_Tp> load(const String& filename, const String& objname=String()) + { + FileStorage fs(filename, FileStorage::READ); + CV_Assert(fs.isOpened()); + FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname]; + if (fn.empty()) return Ptr<_Tp>(); + Ptr<_Tp> obj = _Tp::create(); + obj->read(fn); + return !obj->empty() ? obj : Ptr<_Tp>(); + } + + /** @brief Loads algorithm from a String + + @param strModel The string variable containing the model you want to load. + @param objname The optional name of the node to read (if empty, the first top-level node will be used) + + This is static template method of Algorithm. It's usage is following (in the case of SVM): + @code + Ptr svm = Algorithm::loadFromString(myStringModel); + @endcode + */ + template static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String()) + { + FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY); + FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname]; + Ptr<_Tp> obj = _Tp::create(); + obj->read(fn); + return !obj->empty() ? obj : Ptr<_Tp>(); + } + + /** Saves the algorithm to a file. + In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */ + CV_WRAP virtual void save(const String& filename) const; + + /** Returns the algorithm string identifier. + This string is used as top level xml/yml node tag when the object is saved to a file or string. */ + CV_WRAP virtual String getDefaultName() const; + +protected: + void writeFormat(FileStorage& fs) const; +}; + +enum struct Param { + INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, + UNSIGNED_INT=8, UINT64=9, UCHAR=11, SCALAR=12 +}; + + + +template<> struct ParamType +{ + typedef bool const_param_type; + typedef bool member_type; + + static const Param type = Param::BOOLEAN; +}; + +template<> struct ParamType +{ + typedef int const_param_type; + typedef int member_type; + + static const Param type = Param::INT; +}; + +template<> struct ParamType +{ + typedef double const_param_type; + typedef double member_type; + + static const Param type = Param::REAL; +}; + +template<> struct ParamType +{ + typedef const String& const_param_type; + typedef String member_type; + + static const Param type = Param::STRING; +}; + +template<> struct ParamType +{ + typedef const Mat& const_param_type; + typedef Mat member_type; + + static const Param type = Param::MAT; +}; + +template<> struct ParamType > +{ + typedef const std::vector& const_param_type; + typedef std::vector member_type; + + static const Param type = Param::MAT_VECTOR; +}; + +template<> struct ParamType +{ + typedef const Ptr& const_param_type; + typedef Ptr member_type; + + static const Param type = Param::ALGORITHM; +}; + +template<> struct ParamType +{ + typedef float const_param_type; + typedef float member_type; + + static const Param type = Param::FLOAT; +}; + +template<> struct ParamType +{ + typedef unsigned const_param_type; + typedef unsigned member_type; + + static const Param type = Param::UNSIGNED_INT; +}; + +template<> struct ParamType +{ + typedef uint64 const_param_type; + typedef uint64 member_type; + + static const Param type = Param::UINT64; +}; + +template<> struct ParamType +{ + typedef uchar const_param_type; + typedef uchar member_type; + + static const Param type = Param::UCHAR; +}; + +template<> struct ParamType +{ + typedef const Scalar& const_param_type; + typedef Scalar member_type; + + static const Param type = Param::SCALAR; +}; + +template +struct ParamType<_Tp, typename std::enable_if< std::is_enum<_Tp>::value >::type> +{ + typedef typename std::underlying_type<_Tp>::type const_param_type; + typedef typename std::underlying_type<_Tp>::type member_type; + + static const Param type = Param::INT; +}; + +//! @} core_basic + +} //namespace cv + +#include "opencv2/core/operations.hpp" +#include "opencv2/core/cvstd.inl.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/core/optim.hpp" +#include "opencv2/core/ovx.hpp" + +#endif /*OPENCV_CORE_HPP*/ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/affine.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/affine.hpp new file mode 100644 index 0000000..1806382 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/affine.hpp @@ -0,0 +1,678 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_AFFINE3_HPP +#define OPENCV_CORE_AFFINE3_HPP + +#ifdef __cplusplus + +#include + +namespace cv +{ + +//! @addtogroup core +//! @{ + + /** @brief Affine transform + * + * It represents a 4x4 homogeneous transformation matrix \f$T\f$ + * + * \f[T = + * \begin{bmatrix} + * R & t\\ + * 0 & 1\\ + * \end{bmatrix} + * \f] + * + * where \f$R\f$ is a 3x3 rotation matrix and \f$t\f$ is a 3x1 translation vector. + * + * You can specify \f$R\f$ either by a 3x3 rotation matrix or by a 3x1 rotation vector, + * which is converted to a 3x3 rotation matrix by the Rodrigues formula. + * + * To construct a matrix \f$T\f$ representing first rotation around the axis \f$r\f$ with rotation + * angle \f$|r|\f$ in radian (right hand rule) and then translation by the vector \f$t\f$, you can use + * + * @code + * cv::Vec3f r, t; + * cv::Affine3f T(r, t); + * @endcode + * + * If you already have the rotation matrix \f$R\f$, then you can use + * + * @code + * cv::Matx33f R; + * cv::Affine3f T(R, t); + * @endcode + * + * To extract the rotation matrix \f$R\f$ from \f$T\f$, use + * + * @code + * cv::Matx33f R = T.rotation(); + * @endcode + * + * To extract the translation vector \f$t\f$ from \f$T\f$, use + * + * @code + * cv::Vec3f t = T.translation(); + * @endcode + * + * To extract the rotation vector \f$r\f$ from \f$T\f$, use + * + * @code + * cv::Vec3f r = T.rvec(); + * @endcode + * + * Note that since the mapping from rotation vectors to rotation matrices + * is many to one. The returned rotation vector is not necessarily the one + * you used before to set the matrix. + * + * If you have two transformations \f$T = T_1 * T_2\f$, use + * + * @code + * cv::Affine3f T, T1, T2; + * T = T2.concatenate(T1); + * @endcode + * + * To get the inverse transform of \f$T\f$, use + * + * @code + * cv::Affine3f T, T_inv; + * T_inv = T.inv(); + * @endcode + * + */ + template + class Affine3 + { + public: + typedef T float_type; + typedef Matx Mat3; + typedef Matx Mat4; + typedef Vec Vec3; + + //! Default constructor. It represents a 4x4 identity matrix. + Affine3(); + + //! Augmented affine matrix + Affine3(const Mat4& affine); + + /** + * The resulting 4x4 matrix is + * + * \f[ + * \begin{bmatrix} + * R & t\\ + * 0 & 1\\ + * \end{bmatrix} + * \f] + * + * @param R 3x3 rotation matrix. + * @param t 3x1 translation vector. + */ + Affine3(const Mat3& R, const Vec3& t = Vec3::all(0)); + + /** + * Rodrigues vector. + * + * The last row of the current matrix is set to [0,0,0,1]. + * + * @param rvec 3x1 rotation vector. Its direction indicates the rotation axis and its length + * indicates the rotation angle in radian (using right hand rule). + * @param t 3x1 translation vector. + */ + Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0)); + + /** + * Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix. + * + * The last row of the current matrix is set to [0,0,0,1] when data is not 4x4. + * + * @param data 1-channel matrix. + * when it is 4x4, it is copied to the current matrix and t is not used. + * When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used. + * When it is 3x3, it is copied to the upper left 3x3 part of the current matrix. + * When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used + * to compute a 3x3 rotation matrix. + * @param t 3x1 translation vector. It is used only when data is neither 4x4 nor 3x4. + */ + explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0)); + + //! From 16-element array + explicit Affine3(const float_type* vals); + + //! Create an 4x4 identity transform + static Affine3 Identity(); + + /** + * Rotation matrix. + * + * Copy the rotation matrix to the upper left 3x3 part of the current matrix. + * The remaining elements of the current matrix are not changed. + * + * @param R 3x3 rotation matrix. + * + */ + void rotation(const Mat3& R); + + /** + * Rodrigues vector. + * + * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected. + * + * @param rvec 3x1 rotation vector. The direction indicates the rotation axis and + * its length indicates the rotation angle in radian (using the right thumb convention). + */ + void rotation(const Vec3& rvec); + + /** + * Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix. + * + * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected. + * + * @param data 1-channel matrix. + * When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix. + * When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula + * is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix. + */ + void rotation(const Mat& data); + + /** + * Copy the 3x3 matrix L to the upper left part of the current matrix + * + * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected. + * + * @param L 3x3 matrix. + */ + void linear(const Mat3& L); + + /** + * Copy t to the first three elements of the last column of the current matrix + * + * It sets the upper right 3x1 part of the matrix. The remaining part is unaffected. + * + * @param t 3x1 translation vector. + */ + void translation(const Vec3& t); + + //! @return the upper left 3x3 part + Mat3 rotation() const; + + //! @return the upper left 3x3 part + Mat3 linear() const; + + //! @return the upper right 3x1 part + Vec3 translation() const; + + //! Rodrigues vector. + //! @return a vector representing the upper left 3x3 rotation matrix of the current matrix. + //! @warning Since the mapping between rotation vectors and rotation matrices is many to one, + //! this function returns only one rotation vector that represents the current rotation matrix, + //! which is not necessarily the same one set by `rotation(const Vec3& rvec)`. + Vec3 rvec() const; + + //! @return the inverse of the current matrix. + Affine3 inv(int method = cv::DECOMP_SVD) const; + + //! a.rotate(R) is equivalent to Affine(R, 0) * a; + Affine3 rotate(const Mat3& R) const; + + //! a.rotate(rvec) is equivalent to Affine(rvec, 0) * a; + Affine3 rotate(const Vec3& rvec) const; + + //! a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix + Affine3 translate(const Vec3& t) const; + + //! a.concatenate(affine) is equivalent to affine * a; + Affine3 concatenate(const Affine3& affine) const; + + template operator Affine3() const; + + template Affine3 cast() const; + + Mat4 matrix; + +#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H + Affine3(const Eigen::Transform& affine); + Affine3(const Eigen::Transform& affine); + operator Eigen::Transform() const; + operator Eigen::Transform() const; +#endif + }; + + template static + Affine3 operator*(const Affine3& affine1, const Affine3& affine2); + + //! V is a 3-element vector with member fields x, y and z + template static + V operator*(const Affine3& affine, const V& vector); + + typedef Affine3 Affine3f; + typedef Affine3 Affine3d; + + static Vec3f operator*(const Affine3f& affine, const Vec3f& vector); + static Vec3d operator*(const Affine3d& affine, const Vec3d& vector); + + template class DataType< Affine3<_Tp> > + { + public: + typedef Affine3<_Tp> value_type; + typedef Affine3::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 16, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; + }; + + namespace traits { + template + struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; }; + template + struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; }; + } // namespace + +//! @} core + +} + +//! @cond IGNORED + +/////////////////////////////////////////////////////////////////////////////////// +// Implementation + +template inline +cv::Affine3::Affine3() + : matrix(Mat4::eye()) +{} + +template inline +cv::Affine3::Affine3(const Mat4& affine) + : matrix(affine) +{} + +template inline +cv::Affine3::Affine3(const Mat3& R, const Vec3& t) +{ + rotation(R); + translation(t); + matrix.val[12] = matrix.val[13] = matrix.val[14] = 0; + matrix.val[15] = 1; +} + +template inline +cv::Affine3::Affine3(const Vec3& _rvec, const Vec3& t) +{ + rotation(_rvec); + translation(t); + matrix.val[12] = matrix.val[13] = matrix.val[14] = 0; + matrix.val[15] = 1; +} + +template inline +cv::Affine3::Affine3(const cv::Mat& data, const Vec3& t) +{ + CV_Assert(data.type() == cv::traits::Type::value); + CV_Assert(data.channels() == 1); + + if (data.cols == 4 && data.rows == 4) + { + data.copyTo(matrix); + return; + } + else if (data.cols == 4 && data.rows == 3) + { + rotation(data(Rect(0, 0, 3, 3))); + translation(data(Rect(3, 0, 1, 3))); + } + else + { + rotation(data); + translation(t); + } + + matrix.val[12] = matrix.val[13] = matrix.val[14] = 0; + matrix.val[15] = 1; +} + +template inline +cv::Affine3::Affine3(const float_type* vals) : matrix(vals) +{} + +template inline +cv::Affine3 cv::Affine3::Identity() +{ + return Affine3(cv::Affine3::Mat4::eye()); +} + +template inline +void cv::Affine3::rotation(const Mat3& R) +{ + linear(R); +} + +template inline +void cv::Affine3::rotation(const Vec3& _rvec) +{ + double theta = norm(_rvec); + + if (theta < DBL_EPSILON) + rotation(Mat3::eye()); + else + { + double c = std::cos(theta); + double s = std::sin(theta); + double c1 = 1. - c; + double itheta = (theta != 0) ? 1./theta : 0.; + + Point3_ r = _rvec*itheta; + + Mat3 rrt( r.x*r.x, r.x*r.y, r.x*r.z, r.x*r.y, r.y*r.y, r.y*r.z, r.x*r.z, r.y*r.z, r.z*r.z ); + Mat3 r_x( 0, -r.z, r.y, r.z, 0, -r.x, -r.y, r.x, 0 ); + + // R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x] + // where [r_x] is [0 -rz ry; rz 0 -rx; -ry rx 0] + Mat3 R = c*Mat3::eye() + c1*rrt + s*r_x; + + rotation(R); + } +} + +//Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix; +template inline +void cv::Affine3::rotation(const cv::Mat& data) +{ + CV_Assert(data.type() == cv::traits::Type::value); + CV_Assert(data.channels() == 1); + + if (data.cols == 3 && data.rows == 3) + { + Mat3 R; + data.copyTo(R); + rotation(R); + } + else if ((data.cols == 3 && data.rows == 1) || (data.cols == 1 && data.rows == 3)) + { + Vec3 _rvec; + data.reshape(1, 3).copyTo(_rvec); + rotation(_rvec); + } + else + CV_Error(Error::StsError, "Input matrix can only be 3x3, 1x3 or 3x1"); +} + +template inline +void cv::Affine3::linear(const Mat3& L) +{ + matrix.val[0] = L.val[0]; matrix.val[1] = L.val[1]; matrix.val[ 2] = L.val[2]; + matrix.val[4] = L.val[3]; matrix.val[5] = L.val[4]; matrix.val[ 6] = L.val[5]; + matrix.val[8] = L.val[6]; matrix.val[9] = L.val[7]; matrix.val[10] = L.val[8]; +} + +template inline +void cv::Affine3::translation(const Vec3& t) +{ + matrix.val[3] = t[0]; matrix.val[7] = t[1]; matrix.val[11] = t[2]; +} + +template inline +typename cv::Affine3::Mat3 cv::Affine3::rotation() const +{ + return linear(); +} + +template inline +typename cv::Affine3::Mat3 cv::Affine3::linear() const +{ + typename cv::Affine3::Mat3 R; + R.val[0] = matrix.val[0]; R.val[1] = matrix.val[1]; R.val[2] = matrix.val[ 2]; + R.val[3] = matrix.val[4]; R.val[4] = matrix.val[5]; R.val[5] = matrix.val[ 6]; + R.val[6] = matrix.val[8]; R.val[7] = matrix.val[9]; R.val[8] = matrix.val[10]; + return R; +} + +template inline +typename cv::Affine3::Vec3 cv::Affine3::translation() const +{ + return Vec3(matrix.val[3], matrix.val[7], matrix.val[11]); +} + +template inline +typename cv::Affine3::Vec3 cv::Affine3::rvec() const +{ + cv::Vec3d w; + cv::Matx33d u, vt, R = rotation(); + cv::SVD::compute(R, w, u, vt, cv::SVD::FULL_UV + cv::SVD::MODIFY_A); + R = u * vt; + + double rx = R.val[7] - R.val[5]; + double ry = R.val[2] - R.val[6]; + double rz = R.val[3] - R.val[1]; + + double s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25); + double c = (R.val[0] + R.val[4] + R.val[8] - 1) * 0.5; + c = c > 1.0 ? 1.0 : c < -1.0 ? -1.0 : c; + double theta = std::acos(c); + + if( s < 1e-5 ) + { + if( c > 0 ) + rx = ry = rz = 0; + else + { + double t; + t = (R.val[0] + 1) * 0.5; + rx = std::sqrt(std::max(t, 0.0)); + t = (R.val[4] + 1) * 0.5; + ry = std::sqrt(std::max(t, 0.0)) * (R.val[1] < 0 ? -1.0 : 1.0); + t = (R.val[8] + 1) * 0.5; + rz = std::sqrt(std::max(t, 0.0)) * (R.val[2] < 0 ? -1.0 : 1.0); + + if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R.val[5] > 0) != (ry*rz > 0) ) + rz = -rz; + theta /= std::sqrt(rx*rx + ry*ry + rz*rz); + rx *= theta; + ry *= theta; + rz *= theta; + } + } + else + { + double vth = 1/(2*s); + vth *= theta; + rx *= vth; ry *= vth; rz *= vth; + } + + return cv::Vec3d(rx, ry, rz); +} + +template inline +cv::Affine3 cv::Affine3::inv(int method) const +{ + return matrix.inv(method); +} + +template inline +cv::Affine3 cv::Affine3::rotate(const Mat3& R) const +{ + Mat3 Lc = linear(); + Vec3 tc = translation(); + Mat4 result; + result.val[12] = result.val[13] = result.val[14] = 0; + result.val[15] = 1; + + for(int j = 0; j < 3; ++j) + { + for(int i = 0; i < 3; ++i) + { + float_type value = 0; + for(int k = 0; k < 3; ++k) + value += R(j, k) * Lc(k, i); + result(j, i) = value; + } + + result(j, 3) = R.row(j).dot(tc.t()); + } + return result; +} + +template inline +cv::Affine3 cv::Affine3::rotate(const Vec3& _rvec) const +{ + return rotate(Affine3f(_rvec).rotation()); +} + +template inline +cv::Affine3 cv::Affine3::translate(const Vec3& t) const +{ + Mat4 m = matrix; + m.val[ 3] += t[0]; + m.val[ 7] += t[1]; + m.val[11] += t[2]; + return m; +} + +template inline +cv::Affine3 cv::Affine3::concatenate(const Affine3& affine) const +{ + return (*this).rotate(affine.rotation()).translate(affine.translation()); +} + +template template inline +cv::Affine3::operator Affine3() const +{ + return Affine3(matrix); +} + +template template inline +cv::Affine3 cv::Affine3::cast() const +{ + return Affine3(matrix); +} + +template inline +cv::Affine3 cv::operator*(const cv::Affine3& affine1, const cv::Affine3& affine2) +{ + return affine2.concatenate(affine1); +} + +template inline +V cv::operator*(const cv::Affine3& affine, const V& v) +{ + const typename Affine3::Mat4& m = affine.matrix; + + V r; + r.x = m.val[0] * v.x + m.val[1] * v.y + m.val[ 2] * v.z + m.val[ 3]; + r.y = m.val[4] * v.x + m.val[5] * v.y + m.val[ 6] * v.z + m.val[ 7]; + r.z = m.val[8] * v.x + m.val[9] * v.y + m.val[10] * v.z + m.val[11]; + return r; +} + +static inline +cv::Vec3f cv::operator*(const cv::Affine3f& affine, const cv::Vec3f& v) +{ + const cv::Matx44f& m = affine.matrix; + cv::Vec3f r; + r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3]; + r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7]; + r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11]; + return r; +} + +static inline +cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v) +{ + const cv::Matx44d& m = affine.matrix; + cv::Vec3d r; + r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3]; + r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7]; + r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11]; + return r; +} + + + +#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H + +template inline +cv::Affine3::Affine3(const Eigen::Transform& affine) +{ + cv::Mat(4, 4, cv::traits::Type::value, affine.matrix().data()).copyTo(matrix); +} + +template inline +cv::Affine3::Affine3(const Eigen::Transform& affine) +{ + Eigen::Transform a = affine; + cv::Mat(4, 4, cv::traits::Type::value, a.matrix().data()).copyTo(matrix); +} + +template inline +cv::Affine3::operator Eigen::Transform() const +{ + Eigen::Transform r; + cv::Mat hdr(4, 4, cv::traits::Type::value, r.matrix().data()); + cv::Mat(matrix, false).copyTo(hdr); + return r; +} + +template inline +cv::Affine3::operator Eigen::Transform() const +{ + return this->operator Eigen::Transform(); +} + +#endif /* defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H */ + +//! @endcond + +#endif /* __cplusplus */ + +#endif /* OPENCV_CORE_AFFINE3_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/async.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/async.hpp new file mode 100644 index 0000000..54560c7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/async.hpp @@ -0,0 +1,105 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ASYNC_HPP +#define OPENCV_CORE_ASYNC_HPP + +#include + +#ifdef CV_CXX11 +//#include +#include +#endif + +namespace cv { + +/** @addtogroup core_async + +@{ +*/ + + +/** @brief Returns result of asynchronous operations + +Object has attached asynchronous state. +Assignment operator doesn't clone asynchronous state (it is shared between all instances). + +Result can be fetched via get() method only once. + +*/ +class CV_EXPORTS_W AsyncArray +{ +public: + ~AsyncArray() CV_NOEXCEPT; + CV_WRAP AsyncArray() CV_NOEXCEPT; + AsyncArray(const AsyncArray& o) CV_NOEXCEPT; + AsyncArray& operator=(const AsyncArray& o) CV_NOEXCEPT; + CV_WRAP void release() CV_NOEXCEPT; + + /** Fetch the result. + @param[out] dst destination array + + Waits for result until container has valid result. + Throws exception if exception was stored as a result. + + Throws exception on invalid container state. + + @note Result or stored exception can be fetched only once. + */ + CV_WRAP void get(OutputArray dst) const; + + /** Retrieving the result with timeout + @param[out] dst destination array + @param[in] timeoutNs timeout in nanoseconds, -1 for infinite wait + + @returns true if result is ready, false if the timeout has expired + + @note Result or stored exception can be fetched only once. + */ + bool get(OutputArray dst, int64 timeoutNs) const; + + CV_WRAP inline + bool get(OutputArray dst, double timeoutNs) const { return get(dst, (int64)timeoutNs); } + + bool wait_for(int64 timeoutNs) const; + + CV_WRAP inline + bool wait_for(double timeoutNs) const { return wait_for((int64)timeoutNs); } + + CV_WRAP bool valid() const CV_NOEXCEPT; + +#ifdef CV_CXX11 + inline AsyncArray(AsyncArray&& o) { p = o.p; o.p = NULL; } + inline AsyncArray& operator=(AsyncArray&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; } + + template + inline bool get(OutputArray dst, const std::chrono::duration<_Rep, _Period>& timeout) + { + return get(dst, (int64)(std::chrono::nanoseconds(timeout).count())); + } + + template + inline bool wait_for(const std::chrono::duration<_Rep, _Period>& timeout) + { + return wait_for((int64)(std::chrono::nanoseconds(timeout).count())); + } + +#if 0 + std::future getFutureMat() const; + std::future getFutureUMat() const; +#endif +#endif + + + // PImpl + struct Impl; friend struct Impl; + inline void* _getImpl() const CV_NOEXCEPT { return p; } +protected: + Impl* p; +}; + + +//! @} +} // namespace +#endif // OPENCV_CORE_ASYNC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/base.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/base.hpp new file mode 100644 index 0000000..21a61a4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/base.hpp @@ -0,0 +1,664 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2014, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_BASE_HPP +#define OPENCV_CORE_BASE_HPP + +#ifndef __cplusplus +# error base.hpp header must be compiled as C++ +#endif + +#include "opencv2/opencv_modules.hpp" + +#include +#include + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" + +namespace cv +{ + +//! @addtogroup core_utils +//! @{ + +namespace Error { +//! error codes +enum Code { + StsOk= 0, //!< everything is ok + StsBackTrace= -1, //!< pseudo error for back trace + StsError= -2, //!< unknown /unspecified error + StsInternal= -3, //!< internal error (bad state) + StsNoMem= -4, //!< insufficient memory + StsBadArg= -5, //!< function arg/param is bad + StsBadFunc= -6, //!< unsupported function + StsNoConv= -7, //!< iteration didn't converge + StsAutoTrace= -8, //!< tracing + HeaderIsNull= -9, //!< image header is NULL + BadImageSize= -10, //!< image size is invalid + BadOffset= -11, //!< offset is invalid + BadDataPtr= -12, //!< + BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix. + BadModelOrChSeq= -14, //!< + BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices. + BadNumChannel1U= -16, //!< + BadDepth= -17, //!< input image depth is not supported by the function + BadAlphaChannel= -18, //!< + BadOrder= -19, //!< number of dimensions is out of range + BadOrigin= -20, //!< incorrect input origin + BadAlign= -21, //!< incorrect input align + BadCallBack= -22, //!< + BadTileSize= -23, //!< + BadCOI= -24, //!< input COI is not supported + BadROISize= -25, //!< incorrect input roi + MaskIsTiled= -26, //!< + StsNullPtr= -27, //!< null pointer + StsVecLengthErr= -28, //!< incorrect vector length + StsFilterStructContentErr= -29, //!< incorrect filter structure content + StsKernelStructContentErr= -30, //!< incorrect transform kernel content + StsFilterOffsetErr= -31, //!< incorrect filter offset value + StsBadSize= -201, //!< the input/output structure size is incorrect + StsDivByZero= -202, //!< division by zero + StsInplaceNotSupported= -203, //!< in-place operation is not supported + StsObjectNotFound= -204, //!< request can't be completed + StsUnmatchedFormats= -205, //!< formats of input/output arrays differ + StsBadFlag= -206, //!< flag is wrong or not supported + StsBadPoint= -207, //!< bad CvPoint + StsBadMask= -208, //!< bad format of mask (neither 8uC1 nor 8sC1) + StsUnmatchedSizes= -209, //!< sizes of input/output structures do not match + StsUnsupportedFormat= -210, //!< the data format/type is not supported by the function + StsOutOfRange= -211, //!< some of parameters are out of range + StsParseError= -212, //!< invalid syntax/structure of the parsed file + StsNotImplemented= -213, //!< the requested function/feature is not implemented + StsBadMemBlock= -214, //!< an allocated block has been corrupted + StsAssert= -215, //!< assertion failed + GpuNotSupported= -216, //!< no CUDA support + GpuApiCallError= -217, //!< GPU API call error + OpenGlNotSupported= -218, //!< no OpenGL support + OpenGlApiCallError= -219, //!< OpenGL API call error + OpenCLApiCallError= -220, //!< OpenCL API call error + OpenCLDoubleNotSupported= -221, + OpenCLInitError= -222, //!< OpenCL initialization error + OpenCLNoAMDBlasFft= -223 +}; +} //Error + +//! @} core_utils + +//! @addtogroup core_array +//! @{ + +//! matrix decomposition types +enum DecompTypes { + /** Gaussian elimination with the optimal pivot element chosen. */ + DECOMP_LU = 0, + /** singular value decomposition (SVD) method; the system can be over-defined and/or the matrix + src1 can be singular */ + DECOMP_SVD = 1, + /** eigenvalue decomposition; the matrix src1 must be symmetrical */ + DECOMP_EIG = 2, + /** Cholesky \f$LL^T\f$ factorization; the matrix src1 must be symmetrical and positively + defined */ + DECOMP_CHOLESKY = 3, + /** QR factorization; the system can be over-defined and/or the matrix src1 can be singular */ + DECOMP_QR = 4, + /** while all the previous flags are mutually exclusive, this flag can be used together with + any of the previous; it means that the normal equations + \f$\texttt{src1}^T\cdot\texttt{src1}\cdot\texttt{dst}=\texttt{src1}^T\texttt{src2}\f$ are + solved instead of the original system + \f$\texttt{src1}\cdot\texttt{dst}=\texttt{src2}\f$ */ + DECOMP_NORMAL = 16 +}; + +/** norm types + +src1 and src2 denote input arrays. +*/ + +enum NormTypes { + /** + \f[ + norm = \forkthree + {\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) } + {\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) } + {\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_INF}\) } + \f] + */ + NORM_INF = 1, + /** + \f[ + norm = \forkthree + {\| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\)} + { \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) } + { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L1}\) } + \f]*/ + NORM_L1 = 2, + /** + \f[ + norm = \forkthree + { \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) } + { \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) } + { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) } + \f] + */ + NORM_L2 = 4, + /** + \f[ + norm = \forkthree + { \| \texttt{src1} \| _{L_2} ^{2} = \sum_I \texttt{src1}(I)^2} {if \(\texttt{normType} = \texttt{NORM_L2SQR}\)} + { \| \texttt{src1} - \texttt{src2} \| _{L_2} ^{2} = \sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2 }{if \(\texttt{normType} = \texttt{NORM_L2SQR}\) } + { \left(\frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}}\right)^2 }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2SQR}\) } + \f] + */ + NORM_L2SQR = 5, + /** + In the case of one input array, calculates the Hamming distance of the array from zero, + In the case of two input arrays, calculates the Hamming distance between the arrays. + */ + NORM_HAMMING = 6, + /** + Similar to NORM_HAMMING, but in the calculation, each two bits of the input sequence will + be added and treated as a single bit to be used in the same calculation as NORM_HAMMING. + */ + NORM_HAMMING2 = 7, + NORM_TYPE_MASK = 7, //!< bit-mask which can be used to separate norm type from norm flags + NORM_RELATIVE = 8, //!< flag + NORM_MINMAX = 32 //!< flag + }; + +//! comparison types +enum CmpTypes { CMP_EQ = 0, //!< src1 is equal to src2. + CMP_GT = 1, //!< src1 is greater than src2. + CMP_GE = 2, //!< src1 is greater than or equal to src2. + CMP_LT = 3, //!< src1 is less than src2. + CMP_LE = 4, //!< src1 is less than or equal to src2. + CMP_NE = 5 //!< src1 is unequal to src2. + }; + +//! generalized matrix multiplication flags +enum GemmFlags { GEMM_1_T = 1, //!< transposes src1 + GEMM_2_T = 2, //!< transposes src2 + GEMM_3_T = 4 //!< transposes src3 + }; + +enum DftFlags { + /** performs an inverse 1D or 2D transform instead of the default forward + transform. */ + DFT_INVERSE = 1, + /** scales the result: divide it by the number of array elements. Normally, it is + combined with DFT_INVERSE. */ + DFT_SCALE = 2, + /** performs a forward or inverse transform of every individual row of the input + matrix; this flag enables you to transform multiple vectors simultaneously and can be used to + decrease the overhead (which is sometimes several times larger than the processing itself) to + perform 3D and higher-dimensional transformations and so forth.*/ + DFT_ROWS = 4, + /** performs a forward transformation of 1D or 2D real array; the result, + though being a complex array, has complex-conjugate symmetry (*CCS*, see the function + description below for details), and such an array can be packed into a real array of the same + size as input, which is the fastest option and which is what the function does by default; + however, you may wish to get a full complex array (for simpler spectrum analysis, and so on) - + pass the flag to enable the function to produce a full-size complex output array. */ + DFT_COMPLEX_OUTPUT = 16, + /** performs an inverse transformation of a 1D or 2D complex array; the + result is normally a complex array of the same size, however, if the input array has + conjugate-complex symmetry (for example, it is a result of forward transformation with + DFT_COMPLEX_OUTPUT flag), the output is a real array; while the function itself does not + check whether the input is symmetrical or not, you can pass the flag and then the function + will assume the symmetry and produce the real output array (note that when the input is packed + into a real array and inverse transformation is executed, the function treats the input as a + packed complex-conjugate symmetrical array, and the output will also be a real array). */ + DFT_REAL_OUTPUT = 32, + /** specifies that input is complex input. If this flag is set, the input must have 2 channels. + On the other hand, for backwards compatibility reason, if input has 2 channels, input is + already considered complex. */ + DFT_COMPLEX_INPUT = 64, + /** performs an inverse 1D or 2D transform instead of the default forward transform. */ + DCT_INVERSE = DFT_INVERSE, + /** performs a forward or inverse transform of every individual row of the input + matrix. This flag enables you to transform multiple vectors simultaneously and can be used to + decrease the overhead (which is sometimes several times larger than the processing itself) to + perform 3D and higher-dimensional transforms and so forth.*/ + DCT_ROWS = DFT_ROWS +}; + +//! Various border types, image boundaries are denoted with `|` +//! @see borderInterpolate, copyMakeBorder +enum BorderTypes { + BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i` + BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh` + BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb` + BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg` + BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba` + BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno` + + BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_ISOLATED = 16 //!< do not look outside of ROI +}; + +//! @} core_array + +//! @addtogroup core_utils +//! @{ + +/*! @brief Signals an error and raises the exception. + +By default the function prints information about the error to stderr, +then it either stops if setBreakOnError() had been called before or raises the exception. +It is possible to alternate error processing by using redirectError(). +@param _code - error code (Error::Code) +@param _err - error description +@param _func - function name. Available only when the compiler supports getting it +@param _file - source file name where the error has occurred +@param _line - line number in the source file where the error has occurred +@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert + */ +CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _func, const char* _file, int _line); + +#ifdef CV_STATIC_ANALYSIS + +// In practice, some macro are not processed correctly (noreturn is not detected). +// We need to use simplified definition for them. +#define CV_Error(code, msg) do { (void)(code); (void)(msg); abort(); } while (0) +#define CV_Error_(code, args) do { (void)(code); (void)(cv::format args); abort(); } while (0) +#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0) + +#else // CV_STATIC_ANALYSIS + +/** @brief Call the error handler. + +Currently, the error handler prints the error code and the error message to the standard +error stream `stderr`. In the Debug configuration, it then provokes memory access violation, so that +the execution stack and all the parameters can be analyzed by the debugger. In the Release +configuration, the exception is thrown. + +@param code one of Error::Code +@param msg error message +*/ +#define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ ) + +/** @brief Call the error handler. + +This macro can be used to construct an error message on-fly to include some dynamic information, +for example: +@code + // note the extra parentheses around the formatted text message + CV_Error_(Error::StsOutOfRange, + ("the value at (%d, %d)=%g is out of range", badPt.x, badPt.y, badValue)); +@endcode +@param code one of Error::Code +@param args printf-like formatted error message in parentheses +*/ +#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ ) + +/** @brief Checks a condition at runtime and throws exception if it fails + +The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros +raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release +configurations while CV_DbgAssert is only retained in the Debug configuration. +*/ +#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0) + +#endif // CV_STATIC_ANALYSIS + +//! @cond IGNORED +#if !defined(__OPENCV_BUILD) // TODO: backward compatibility only +#ifndef CV_ErrorNoReturn +#define CV_ErrorNoReturn CV_Error +#endif +#ifndef CV_ErrorNoReturn_ +#define CV_ErrorNoReturn_ CV_Error_ +#endif +#endif + +#define CV_Assert_1 CV_Assert +#define CV_Assert_2( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_1( __VA_ARGS__ )) +#define CV_Assert_3( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_2( __VA_ARGS__ )) +#define CV_Assert_4( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_3( __VA_ARGS__ )) +#define CV_Assert_5( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_4( __VA_ARGS__ )) +#define CV_Assert_6( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_5( __VA_ARGS__ )) +#define CV_Assert_7( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_6( __VA_ARGS__ )) +#define CV_Assert_8( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_7( __VA_ARGS__ )) +#define CV_Assert_9( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_8( __VA_ARGS__ )) +#define CV_Assert_10( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_9( __VA_ARGS__ )) + +#define CV_Assert_N(...) do { __CV_EXPAND(__CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__)); } while(0) + +//! @endcond + +#if defined _DEBUG || defined CV_STATIC_ANALYSIS +# define CV_DbgAssert(expr) CV_Assert(expr) +#else +/** replaced with CV_Assert(expr) in Debug configuration */ +# define CV_DbgAssert(expr) +#endif + +/* + * Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor + * bit count of A exclusive XOR'ed with B + */ +struct CV_EXPORTS Hamming +{ + static const NormTypes normType = NORM_HAMMING; + typedef unsigned char ValueType; + typedef int ResultType; + + /** this will count the bits in a ^ b + */ + ResultType operator()( const unsigned char* a, const unsigned char* b, int size ) const; +}; + +typedef Hamming HammingLUT; + +/////////////////////////////////// inline norms //////////////////////////////////// + +template inline _Tp cv_abs(_Tp x) { return std::abs(x); } +inline int cv_abs(uchar x) { return x; } +inline int cv_abs(schar x) { return std::abs(x); } +inline int cv_abs(ushort x) { return x; } +inline int cv_abs(short x) { return std::abs(x); } + +template static inline +_AccTp normL2Sqr(const _Tp* a, int n) +{ + _AccTp s = 0; + int i=0; +#if CV_ENABLE_UNROLLED + for( ; i <= n - 4; i += 4 ) + { + _AccTp v0 = a[i], v1 = a[i+1], v2 = a[i+2], v3 = a[i+3]; + s += v0*v0 + v1*v1 + v2*v2 + v3*v3; + } +#endif + for( ; i < n; i++ ) + { + _AccTp v = a[i]; + s += v*v; + } + return s; +} + +template static inline +_AccTp normL1(const _Tp* a, int n) +{ + _AccTp s = 0; + int i = 0; +#if CV_ENABLE_UNROLLED + for(; i <= n - 4; i += 4 ) + { + s += (_AccTp)cv_abs(a[i]) + (_AccTp)cv_abs(a[i+1]) + + (_AccTp)cv_abs(a[i+2]) + (_AccTp)cv_abs(a[i+3]); + } +#endif + for( ; i < n; i++ ) + s += cv_abs(a[i]); + return s; +} + +template static inline +_AccTp normInf(const _Tp* a, int n) +{ + _AccTp s = 0; + for( int i = 0; i < n; i++ ) + s = std::max(s, (_AccTp)cv_abs(a[i])); + return s; +} + +template static inline +_AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) +{ + _AccTp s = 0; + int i= 0; +#if CV_ENABLE_UNROLLED + for(; i <= n - 4; i += 4 ) + { + _AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]); + s += v0*v0 + v1*v1 + v2*v2 + v3*v3; + } +#endif + for( ; i < n; i++ ) + { + _AccTp v = _AccTp(a[i] - b[i]); + s += v*v; + } + return s; +} + +static inline float normL2Sqr(const float* a, const float* b, int n) +{ + float s = 0.f; + for( int i = 0; i < n; i++ ) + { + float v = a[i] - b[i]; + s += v*v; + } + return s; +} + +template static inline +_AccTp normL1(const _Tp* a, const _Tp* b, int n) +{ + _AccTp s = 0; + int i= 0; +#if CV_ENABLE_UNROLLED + for(; i <= n - 4; i += 4 ) + { + _AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]); + s += std::abs(v0) + std::abs(v1) + std::abs(v2) + std::abs(v3); + } +#endif + for( ; i < n; i++ ) + { + _AccTp v = _AccTp(a[i] - b[i]); + s += std::abs(v); + } + return s; +} + +inline float normL1(const float* a, const float* b, int n) +{ + float s = 0.f; + for( int i = 0; i < n; i++ ) + { + s += std::abs(a[i] - b[i]); + } + return s; +} + +inline int normL1(const uchar* a, const uchar* b, int n) +{ + int s = 0; + for( int i = 0; i < n; i++ ) + { + s += std::abs(a[i] - b[i]); + } + return s; +} + +template static inline +_AccTp normInf(const _Tp* a, const _Tp* b, int n) +{ + _AccTp s = 0; + for( int i = 0; i < n; i++ ) + { + _AccTp v0 = a[i] - b[i]; + s = std::max(s, std::abs(v0)); + } + return s; +} + +/** @brief Computes the cube root of an argument. + + The function cubeRoot computes \f$\sqrt[3]{\texttt{val}}\f$. Negative arguments are handled correctly. + NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for + single-precision data. + @param val A function argument. + */ +CV_EXPORTS_W float cubeRoot(float val); + +/** @overload + +cubeRoot with argument of `double` type calls `std::cbrt(double)` +*/ +static inline +double cubeRoot(double val) +{ + return std::cbrt(val); +} + +/** @brief Calculates the angle of a 2D vector in degrees. + + The function fastAtan2 calculates the full-range angle of an input 2D vector. The angle is measured + in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees. + @param x x-coordinate of the vector. + @param y y-coordinate of the vector. + */ +CV_EXPORTS_W float fastAtan2(float y, float x); + +/** proxy for hal::LU */ +CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n); +/** proxy for hal::LU */ +CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n); +/** proxy for hal::Cholesky */ +CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n); +/** proxy for hal::Cholesky */ +CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n); + +////////////////// forward declarations for important OpenCV types ////////////////// + +//! @cond IGNORED + +template class Vec; +template class Matx; + +template class Complex; +template class Point_; +template class Point3_; +template class Size_; +template class Rect_; +template class Scalar_; + +class CV_EXPORTS RotatedRect; +class CV_EXPORTS Range; +class CV_EXPORTS TermCriteria; +class CV_EXPORTS KeyPoint; +class CV_EXPORTS DMatch; +class CV_EXPORTS RNG; + +class CV_EXPORTS Mat; +class CV_EXPORTS MatExpr; + +class CV_EXPORTS UMat; + +class CV_EXPORTS SparseMat; +typedef Mat MatND; + +template class Mat_; +template class SparseMat_; + +class CV_EXPORTS MatConstIterator; +class CV_EXPORTS SparseMatIterator; +class CV_EXPORTS SparseMatConstIterator; +template class MatIterator_; +template class MatConstIterator_; +template class SparseMatIterator_; +template class SparseMatConstIterator_; + +namespace ogl +{ + class CV_EXPORTS Buffer; + class CV_EXPORTS Texture2D; + class CV_EXPORTS Arrays; +} + +namespace cuda +{ + class CV_EXPORTS GpuMat; + class CV_EXPORTS HostMem; + class CV_EXPORTS Stream; + class CV_EXPORTS Event; +} + +namespace cudev +{ + template class GpuMat_; +} + +namespace ipp +{ +CV_EXPORTS unsigned long long getIppFeatures(); +CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL, + int line = 0); +CV_EXPORTS int getIppStatus(); +CV_EXPORTS String getIppErrorLocation(); +CV_EXPORTS_W bool useIPP(); +CV_EXPORTS_W void setUseIPP(bool flag); +CV_EXPORTS_W String getIppVersion(); + +// IPP Not-Exact mode. This function may force use of IPP then both IPP and OpenCV provide proper results +// but have internal accuracy differences which have too much direct or indirect impact on accuracy tests. +CV_EXPORTS_W bool useIPP_NotExact(); +CV_EXPORTS_W void setUseIPP_NotExact(bool flag); +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +static inline bool useIPP_NE() { return useIPP_NotExact(); } +static inline void setUseIPP_NE(bool flag) { setUseIPP_NotExact(flag); } +#endif + +} // ipp + +//! @endcond + +//! @} core_utils + + + + +} // cv + +#include "opencv2/core/neon_utils.hpp" +#include "opencv2/core/vsx_utils.hpp" +#include "opencv2/core/check.hpp" + +#endif //OPENCV_CORE_BASE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/bindings_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/bindings_utils.hpp new file mode 100644 index 0000000..22a86ff --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/bindings_utils.hpp @@ -0,0 +1,248 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_BINDINGS_UTILS_HPP +#define OPENCV_CORE_BINDINGS_UTILS_HPP + +#include +#include +#include + +#include + +namespace cv { namespace utils { +//! @addtogroup core_utils +//! @{ + +CV_EXPORTS_W String dumpInputArray(InputArray argument); + +CV_EXPORTS_W String dumpInputArrayOfArrays(InputArrayOfArrays argument); + +CV_EXPORTS_W String dumpInputOutputArray(InputOutputArray argument); + +CV_EXPORTS_W String dumpInputOutputArrayOfArrays(InputOutputArrayOfArrays argument); + +CV_WRAP static inline +String dumpBool(bool argument) +{ + return (argument) ? String("Bool: True") : String("Bool: False"); +} + +CV_WRAP static inline +String dumpInt(int argument) +{ + return cv::format("Int: %d", argument); +} + +CV_WRAP static inline +String dumpSizeT(size_t argument) +{ + std::ostringstream oss("size_t: ", std::ios::ate); + oss << argument; + return oss.str(); +} + +CV_WRAP static inline +String dumpFloat(float argument) +{ + return cv::format("Float: %.2f", argument); +} + +CV_WRAP static inline +String dumpDouble(double argument) +{ + return cv::format("Double: %.2f", argument); +} + +CV_WRAP static inline +String dumpCString(const char* argument) +{ + return cv::format("String: %s", argument); +} + +CV_WRAP static inline +String dumpString(const String& argument) +{ + return cv::format("String: %s", argument.c_str()); +} + +CV_WRAP static inline +String testOverloadResolution(int value, const Point& point = Point(42, 24)) +{ + return format("overload (int=%d, point=(x=%d, y=%d))", value, point.x, + point.y); +} + +CV_WRAP static inline +String testOverloadResolution(const Rect& rect) +{ + return format("overload (rect=(x=%d, y=%d, w=%d, h=%d))", rect.x, rect.y, + rect.width, rect.height); +} + +CV_WRAP static inline +String dumpRect(const Rect& argument) +{ + return format("rect: (x=%d, y=%d, w=%d, h=%d)", argument.x, argument.y, + argument.width, argument.height); +} + +CV_WRAP static inline +String dumpTermCriteria(const TermCriteria& argument) +{ + return format("term_criteria: (type=%d, max_count=%d, epsilon=%lf", + argument.type, argument.maxCount, argument.epsilon); +} + +CV_WRAP static inline +String dumpRotatedRect(const RotatedRect& argument) +{ + return format("rotated_rect: (c_x=%f, c_y=%f, w=%f, h=%f, a=%f)", + argument.center.x, argument.center.y, argument.size.width, + argument.size.height, argument.angle); +} + +CV_WRAP static inline +RotatedRect testRotatedRect(float x, float y, float w, float h, float angle) +{ + return RotatedRect(Point2f(x, y), Size2f(w, h), angle); +} + +CV_WRAP static inline +std::vector testRotatedRectVector(float x, float y, float w, float h, float angle) +{ + std::vector result; + for (int i = 0; i < 10; i++) + result.push_back(RotatedRect(Point2f(x + i, y + 2 * i), Size2f(w, h), angle + 10 * i)); + return result; +} + +CV_WRAP static inline +String dumpRange(const Range& argument) +{ + if (argument == Range::all()) + { + return "range: all"; + } + else + { + return format("range: (s=%d, e=%d)", argument.start, argument.end); + } +} + +CV_WRAP static inline +int testOverwriteNativeMethod(int argument) +{ + return argument; +} + +CV_WRAP static inline +String testReservedKeywordConversion(int positional_argument, int lambda = 2, int from = 3) +{ + return format("arg=%d, lambda=%d, from=%d", positional_argument, lambda, from); +} + +CV_EXPORTS_W String dumpVectorOfInt(const std::vector& vec); + +CV_EXPORTS_W String dumpVectorOfDouble(const std::vector& vec); + +CV_EXPORTS_W String dumpVectorOfRect(const std::vector& vec); + +CV_WRAP static inline +void generateVectorOfRect(size_t len, CV_OUT std::vector& vec) +{ + vec.resize(len); + if (len > 0) + { + RNG rng(12345); + Mat tmp(static_cast(len), 1, CV_32SC4); + rng.fill(tmp, RNG::UNIFORM, 10, 20); + tmp.copyTo(vec); + } +} + +CV_WRAP static inline +void generateVectorOfInt(size_t len, CV_OUT std::vector& vec) +{ + vec.resize(len); + if (len > 0) + { + RNG rng(554433); + Mat tmp(static_cast(len), 1, CV_32SC1); + rng.fill(tmp, RNG::UNIFORM, -10, 10); + tmp.copyTo(vec); + } +} + +CV_WRAP static inline +void generateVectorOfMat(size_t len, int rows, int cols, int dtype, CV_OUT std::vector& vec) +{ + vec.resize(len); + if (len > 0) + { + RNG rng(65431); + for (size_t i = 0; i < len; ++i) + { + vec[i].create(rows, cols, dtype); + rng.fill(vec[i], RNG::UNIFORM, 0, 10); + } + } +} + +CV_WRAP static inline +void testRaiseGeneralException() +{ + throw std::runtime_error("exception text"); +} + +CV_WRAP static inline +AsyncArray testAsyncArray(InputArray argument) +{ + AsyncPromise p; + p.setValue(argument); + return p.getArrayResult(); +} + +CV_WRAP static inline +AsyncArray testAsyncException() +{ + AsyncPromise p; + try + { + CV_Error(Error::StsOk, "Test: Generated async error"); + } + catch (const cv::Exception& e) + { + p.setException(e); + } + return p.getArrayResult(); +} + +namespace fs { + CV_EXPORTS_W cv::String getCacheDirectoryForDownloads(); +} // namespace fs + +//! @} // core_utils +} // namespace cv::utils + +//! @cond IGNORED + +CV_WRAP static inline +int setLogLevel(int level) +{ + // NB: Binding generators doesn't work with enums properly yet, so we define separate overload here + return cv::utils::logging::setLogLevel((cv::utils::logging::LogLevel)level); +} + +CV_WRAP static inline +int getLogLevel() +{ + return cv::utils::logging::getLogLevel(); +} + +//! @endcond IGNORED + +} // namespaces cv / utils + +#endif // OPENCV_CORE_BINDINGS_UTILS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/bufferpool.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/bufferpool.hpp new file mode 100644 index 0000000..4698e5d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/bufferpool.hpp @@ -0,0 +1,40 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. + +#ifndef OPENCV_CORE_BUFFER_POOL_HPP +#define OPENCV_CORE_BUFFER_POOL_HPP + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4265) +#endif + +namespace cv +{ + +//! @addtogroup core +//! @{ + +class BufferPoolController +{ +protected: + ~BufferPoolController() { } +public: + virtual size_t getReservedSize() const = 0; + virtual size_t getMaxReservedSize() const = 0; + virtual void setMaxReservedSize(size_t size) = 0; + virtual void freeAllReservedBuffers() = 0; +}; + +//! @} + +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif // OPENCV_CORE_BUFFER_POOL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/check.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/check.hpp new file mode 100644 index 0000000..d975223 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/check.hpp @@ -0,0 +1,160 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_CHECK_HPP +#define OPENCV_CORE_CHECK_HPP + +#include + +namespace cv { + +/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "" */ +CV_EXPORTS const char* depthToString(int depth); + +/** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or "" */ +CV_EXPORTS const String typeToString(int type); + + +//! @cond IGNORED +namespace detail { + +/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */ +CV_EXPORTS const char* depthToString_(int depth); + +/** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or cv::String() */ +CV_EXPORTS const cv::String typeToString_(int type); + +enum TestOp { + TEST_CUSTOM = 0, + TEST_EQ = 1, + TEST_NE = 2, + TEST_LE = 3, + TEST_LT = 4, + TEST_GE = 5, + TEST_GT = 6, + CV__LAST_TEST_OP +}; + +struct CheckContext { + const char* func; + const char* file; + int line; + enum TestOp testOp; + const char* message; + const char* p1_str; + const char* p2_str; +}; + +#ifndef CV__CHECK_FILENAME +# define CV__CHECK_FILENAME __FILE__ +#endif + +#ifndef CV__CHECK_FUNCTION +# if defined _MSC_VER +# define CV__CHECK_FUNCTION __FUNCSIG__ +# elif defined __GNUC__ +# define CV__CHECK_FUNCTION __PRETTY_FUNCTION__ +# else +# define CV__CHECK_FUNCTION "" +# endif +#endif + +#define CV__CHECK_LOCATION_VARNAME(id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_check_, id), __LINE__) +#define CV__DEFINE_CHECK_CONTEXT(id, message, testOp, p1_str, p2_str) \ + static const cv::detail::CheckContext CV__CHECK_LOCATION_VARNAME(id) = \ + { CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, "" message, "" p1_str, "" p2_str } + +CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_ v1, const Size_ v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); + +CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_ v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const std::string& v1, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx); + + +#define CV__TEST_EQ(v1, v2) ((v1) == (v2)) +#define CV__TEST_NE(v1, v2) ((v1) != (v2)) +#define CV__TEST_LE(v1, v2) ((v1) <= (v2)) +#define CV__TEST_LT(v1, v2) ((v1) < (v2)) +#define CV__TEST_GE(v1, v2) ((v1) >= (v2)) +#define CV__TEST_GT(v1, v2) ((v1) > (v2)) + +#define CV__CHECK(id, op, type, v1, v2, v1_str, v2_str, msg_str) do { \ + if(CV__TEST_##op((v1), (v2))) ; else { \ + CV__DEFINE_CHECK_CONTEXT(id, msg_str, cv::detail::TEST_ ## op, v1_str, v2_str); \ + cv::detail::check_failed_ ## type((v1), (v2), CV__CHECK_LOCATION_VARNAME(id)); \ + } \ +} while (0) + +#define CV__CHECK_CUSTOM_TEST(id, type, v, test_expr, v_str, test_expr_str, msg_str) do { \ + if(!!(test_expr)) ; else { \ + CV__DEFINE_CHECK_CONTEXT(id, msg_str, cv::detail::TEST_CUSTOM, v_str, test_expr_str); \ + cv::detail::check_failed_ ## type((v), CV__CHECK_LOCATION_VARNAME(id)); \ + } \ +} while (0) + +} // namespace +//! @endcond + + +/// Supported values of these types: int, float, double +#define CV_CheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg) + +/// Check with additional "decoding" of type values in error message +#define CV_CheckTypeEQ(t1, t2, msg) CV__CHECK(_, EQ, MatType, t1, t2, #t1, #t2, msg) +/// Check with additional "decoding" of depth values in error message +#define CV_CheckDepthEQ(d1, d2, msg) CV__CHECK(_, EQ, MatDepth, d1, d2, #d1, #d2, msg) + +#define CV_CheckChannelsEQ(c1, c2, msg) CV__CHECK(_, EQ, MatChannels, c1, c2, #c1, #c2, msg) + +/// Example: type == CV_8UC1 || type == CV_8UC3 +#define CV_CheckType(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatType, t, (test_expr), #t, #test_expr, msg) + +/// Example: depth == CV_32F || depth == CV_64F +#define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg) + +/// Example: v == A || v == B +#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg) + +/// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1") +// TODO define pretty-printers + +#ifndef NDEBUG +#define CV_DbgCheck(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg) +#define CV_DbgCheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg) +#else +#define CV_DbgCheck(v, test_expr, msg) do { } while (0) +#define CV_DbgCheckEQ(v1, v2, msg) do { } while (0) +#define CV_DbgCheckNE(v1, v2, msg) do { } while (0) +#define CV_DbgCheckLE(v1, v2, msg) do { } while (0) +#define CV_DbgCheckLT(v1, v2, msg) do { } while (0) +#define CV_DbgCheckGE(v1, v2, msg) do { } while (0) +#define CV_DbgCheckGT(v1, v2, msg) do { } while (0) +#endif + +} // namespace + +#endif // OPENCV_CORE_CHECK_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/core.hpp new file mode 100644 index 0000000..4389183 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/core.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/core.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/core_c.h b/Cigarette/OpenCV455Simple/include/opencv2/core/core_c.h new file mode 100644 index 0000000..09ac1e7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/core_c.h @@ -0,0 +1,3125 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + + +#ifndef OPENCV_CORE_C_H +#define OPENCV_CORE_C_H + +#include "opencv2/core/types_c.h" + +#ifdef __cplusplus +# ifdef _MSC_VER +/* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename' + which is incompatible with C + + It is OK to disable it because we only extend few plain structures with + C++ constructors for simpler interoperability with C++ API of the library +*/ +# pragma warning(disable:4190) +# elif defined __clang__ && __clang_major__ >= 3 +# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup core_c + @{ +*/ + +/****************************************************************************************\ +* Array allocation, deallocation, initialization and access to elements * +\****************************************************************************************/ + +/** `malloc` wrapper. + If there is no enough memory, the function + (as well as other OpenCV functions that call cvAlloc) + raises an error. */ +CVAPI(void*) cvAlloc( size_t size ); + +/** `free` wrapper. + Here and further all the memory releasing functions + (that all call cvFree) take double pointer in order to + to clear pointer to the data after releasing it. + Passing pointer to NULL pointer is Ok: nothing happens in this case +*/ +CVAPI(void) cvFree_( void* ptr ); +#define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0) + +/** @brief Creates an image header but does not allocate the image data. + +@param size Image width and height +@param depth Image depth (see cvCreateImage ) +@param channels Number of channels (see cvCreateImage ) + */ +CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); + +/** @brief Initializes an image header that was previously allocated. + +The returned IplImage\* points to the initialized header. +@param image Image header to initialize +@param size Image width and height +@param depth Image depth (see cvCreateImage ) +@param channels Number of channels (see cvCreateImage ) +@param origin Top-left IPL_ORIGIN_TL or bottom-left IPL_ORIGIN_BL +@param align Alignment for image rows, typically 4 or 8 bytes + */ +CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth, + int channels, int origin CV_DEFAULT(0), + int align CV_DEFAULT(4)); + +/** @brief Creates an image header and allocates the image data. + +This function call is equivalent to the following code: +@code + header = cvCreateImageHeader(size, depth, channels); + cvCreateData(header); +@endcode +@param size Image width and height +@param depth Bit depth of image elements. See IplImage for valid depths. +@param channels Number of channels per pixel. See IplImage for details. This function only creates +images with interleaved channels. + */ +CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); + +/** @brief Deallocates an image header. + +This call is an analogue of : +@code + if(image ) + { + iplDeallocate(*image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI); + *image = 0; + } +@endcode +but it does not use IPL functions by default (see the CV_TURN_ON_IPL_COMPATIBILITY macro). +@param image Double pointer to the image header + */ +CVAPI(void) cvReleaseImageHeader( IplImage** image ); + +/** @brief Deallocates the image header and the image data. + +This call is a shortened form of : +@code + if(*image ) + { + cvReleaseData(*image); + cvReleaseImageHeader(image); + } +@endcode +@param image Double pointer to the image header +*/ +CVAPI(void) cvReleaseImage( IplImage** image ); + +/** Creates a copy of IPL image (widthStep may differ) */ +CVAPI(IplImage*) cvCloneImage( const IplImage* image ); + +/** @brief Sets the channel of interest in an IplImage. + +If the ROI is set to NULL and the coi is *not* 0, the ROI is allocated. Most OpenCV functions do +*not* support the COI setting, so to process an individual image/matrix channel one may copy (via +cvCopy or cvSplit) the channel to a separate image/matrix, process it and then copy the result +back (via cvCopy or cvMerge) if needed. +@param image A pointer to the image header +@param coi The channel of interest. 0 - all channels are selected, 1 - first channel is selected, +etc. Note that the channel indices become 1-based. + */ +CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); + +/** @brief Returns the index of the channel of interest. + +Returns the channel of interest of in an IplImage. Returned values correspond to the coi in +cvSetImageCOI. +@param image A pointer to the image header + */ +CVAPI(int) cvGetImageCOI( const IplImage* image ); + +/** @brief Sets an image Region Of Interest (ROI) for a given rectangle. + +If the original image ROI was NULL and the rect is not the whole image, the ROI structure is +allocated. + +Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For +example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the +ROI, not the original image. +@param image A pointer to the image header +@param rect The ROI rectangle + */ +CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); + +/** @brief Resets the image ROI to include the entire image and releases the ROI structure. + +This produces a similar result to the following, but in addition it releases the ROI structure. : +@code + cvSetImageROI(image, cvRect(0, 0, image->width, image->height )); + cvSetImageCOI(image, 0); +@endcode +@param image A pointer to the image header + */ +CVAPI(void) cvResetImageROI( IplImage* image ); + +/** @brief Returns the image ROI. + +If there is no ROI set, cvRect(0,0,image-\>width,image-\>height) is returned. +@param image A pointer to the image header + */ +CVAPI(CvRect) cvGetImageROI( const IplImage* image ); + +/** @brief Creates a matrix header but does not allocate the matrix data. + +The function allocates a new matrix header and returns a pointer to it. The matrix data can then be +allocated using cvCreateData or set explicitly to user-allocated data via cvSetData. +@param rows Number of rows in the matrix +@param cols Number of columns in the matrix +@param type Type of the matrix elements, see cvCreateMat + */ +CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); + +#define CV_AUTOSTEP 0x7fffffff + +/** @brief Initializes a pre-allocated matrix header. + +This function is often used to process raw data with OpenCV matrix functions. For example, the +following code computes the matrix product of two matrices, stored as ordinary arrays: +@code + double a[] = { 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12 }; + + double b[] = { 1, 5, 9, + 2, 6, 10, + 3, 7, 11, + 4, 8, 12 }; + + double c[9]; + CvMat Ma, Mb, Mc ; + + cvInitMatHeader(&Ma, 3, 4, CV_64FC1, a); + cvInitMatHeader(&Mb, 4, 3, CV_64FC1, b); + cvInitMatHeader(&Mc, 3, 3, CV_64FC1, c); + + cvMatMulAdd(&Ma, &Mb, 0, &Mc); + // the c array now contains the product of a (3x4) and b (4x3) +@endcode +@param mat A pointer to the matrix header to be initialized +@param rows Number of rows in the matrix +@param cols Number of columns in the matrix +@param type Type of the matrix elements, see cvCreateMat . +@param data Optional: data pointer assigned to the matrix header +@param step Optional: full row width in bytes of the assigned data. By default, the minimal +possible step is used which assumes there are no gaps between subsequent rows of the matrix. + */ +CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols, + int type, void* data CV_DEFAULT(NULL), + int step CV_DEFAULT(CV_AUTOSTEP) ); + +/** @brief Creates a matrix header and allocates the matrix data. + +The function call is equivalent to the following code: +@code + CvMat* mat = cvCreateMatHeader(rows, cols, type); + cvCreateData(mat); +@endcode +@param rows Number of rows in the matrix +@param cols Number of columns in the matrix +@param type The type of the matrix elements in the form +CV_\\C\ , where S=signed, U=unsigned, F=float. For +example, CV _ 8UC1 means the elements are 8-bit unsigned and the there is 1 channel, and CV _ +32SC2 means the elements are 32-bit signed and there are 2 channels. + */ +CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); + +/** @brief Deallocates a matrix. + +The function decrements the matrix data reference counter and deallocates matrix header. If the data +reference counter is 0, it also deallocates the data. : +@code + if(*mat ) + cvDecRefData(*mat); + cvFree((void**)mat); +@endcode +@param mat Double pointer to the matrix + */ +CVAPI(void) cvReleaseMat( CvMat** mat ); + +/** @brief Decrements an array data reference counter. + +The function decrements the data reference counter in a CvMat or CvMatND if the reference counter + +pointer is not NULL. If the counter reaches zero, the data is deallocated. In the current +implementation the reference counter is not NULL only if the data was allocated using the +cvCreateData function. The counter will be NULL in other cases such as: external data was assigned +to the header using cvSetData, header is part of a larger matrix or image, or the header was +converted from an image or n-dimensional matrix header. +@param arr Pointer to an array header + */ +CV_INLINE void cvDecRefData( CvArr* arr ) +{ + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } +} + +/** @brief Increments array data reference counter. + +The function increments CvMat or CvMatND data reference counter and returns the new counter value if +the reference counter pointer is not NULL, otherwise it returns zero. +@param arr Array header + */ +CV_INLINE int cvIncRefData( CvArr* arr ) +{ + int refcount = 0; + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + return refcount; +} + + +/** Creates an exact copy of the input matrix (except, may be, step value) */ +CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); + + +/** @brief Returns matrix header corresponding to the rectangular sub-array of input image or matrix. + +The function returns header, corresponding to a specified rectangle of the input array. In other + +words, it allows the user to treat a rectangular part of input array as a stand-alone array. ROI is +taken into account by the function so the sub-array of ROI is actually extracted. +@param arr Input array +@param submat Pointer to the resultant sub-array header +@param rect Zero-based coordinates of the rectangle of interest + */ +CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); +#define cvGetSubArr cvGetSubRect + +/** @brief Returns array row or row span. + +The function returns the header, corresponding to a specified row/row span of the input array. +cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr, submat, row, row+1). +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param start_row Zero-based index of the starting row (inclusive) of the span +@param end_row Zero-based index of the ending row (exclusive) of the span +@param delta_row Index step in the row span. That is, the function extracts every delta_row -th +row from start_row and up to (but not including) end_row . + */ +CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat, + int start_row, int end_row, + int delta_row CV_DEFAULT(1)); + +/** @overload +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param row Zero-based index of the selected row +*/ +CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) +{ + return cvGetRows( arr, submat, row, row + 1, 1 ); +} + + +/** @brief Returns one of more array columns. + +The function returns the header, corresponding to a specified column span of the input array. That + +is, no data is copied. Therefore, any modifications of the submatrix will affect the original array. +If you need to copy the columns, use cvCloneMat. cvGetCol(arr, submat, col) is a shortcut for +cvGetCols(arr, submat, col, col+1). +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param start_col Zero-based index of the starting column (inclusive) of the span +@param end_col Zero-based index of the ending column (exclusive) of the span + */ +CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat, + int start_col, int end_col ); + +/** @overload +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param col Zero-based index of the selected column +*/ +CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col ) +{ + return cvGetCols( arr, submat, col, col + 1 ); +} + +/** @brief Returns one of array diagonals. + +The function returns the header, corresponding to a specified diagonal of the input array. +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param diag Index of the array diagonal. Zero value corresponds to the main diagonal, -1 +corresponds to the diagonal above the main, 1 corresponds to the diagonal below the main, and so +forth. + */ +CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat, + int diag CV_DEFAULT(0)); + +/** low-level scalar <-> raw data conversion functions */ +CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, + int extend_to_12 CV_DEFAULT(0) ); + +CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); + +/** @brief Creates a new matrix header but does not allocate the matrix data. + +The function allocates a header for a multi-dimensional dense array. The array data can further be +allocated using cvCreateData or set explicitly to user-allocated data via cvSetData. +@param dims Number of array dimensions +@param sizes Array of dimension sizes +@param type Type of array elements, see cvCreateMat + */ +CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); + +/** @brief Creates the header and allocates the data for a multi-dimensional dense array. + +This function call is equivalent to the following code: +@code + CvMatND* mat = cvCreateMatNDHeader(dims, sizes, type); + cvCreateData(mat); +@endcode +@param dims Number of array dimensions. This must not exceed CV_MAX_DIM (32 by default, but can be +changed at build time). +@param sizes Array of dimension sizes. +@param type Type of array elements, see cvCreateMat . + */ +CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); + +/** @brief Initializes a pre-allocated multi-dimensional array header. + +@param mat A pointer to the array header to be initialized +@param dims The number of array dimensions +@param sizes An array of dimension sizes +@param type Type of array elements, see cvCreateMat +@param data Optional data pointer assigned to the matrix header + */ +CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, + int type, void* data CV_DEFAULT(NULL) ); + +/** @brief Deallocates a multi-dimensional array. + +The function decrements the array data reference counter and releases the array header. If the +reference counter reaches 0, it also deallocates the data. : +@code + if(*mat ) + cvDecRefData(*mat); + cvFree((void**)mat); +@endcode +@param mat Double pointer to the array + */ +CV_INLINE void cvReleaseMatND( CvMatND** mat ) +{ + cvReleaseMat( (CvMat**)mat ); +} + +/** Creates a copy of CvMatND (except, may be, steps) */ +CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); + +/** @brief Creates sparse array. + +The function allocates a multi-dimensional sparse array. Initially the array contain no elements, +that is PtrND and other related functions will return 0 for every index. +@param dims Number of array dimensions. In contrast to the dense matrix, the number of dimensions is +practically unlimited (up to \f$2^{16}\f$ ). +@param sizes Array of dimension sizes +@param type Type of array elements. The same as for CvMat + */ +CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); + +/** @brief Deallocates sparse array. + +The function releases the sparse array and clears the array pointer upon exit. +@param mat Double pointer to the array + */ +CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); + +/** Creates a copy of CvSparseMat (except, may be, zero items) */ +CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); + +/** @brief Initializes sparse array elements iterator. + +The function initializes iterator of sparse array elements and returns pointer to the first element, +or NULL if the array is empty. +@param mat Input array +@param mat_iterator Initialized iterator + */ +CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, + CvSparseMatIterator* mat_iterator ); + +/** @brief Returns the next sparse matrix element + +The function moves iterator to the next sparse matrix element and returns pointer to it. In the +current version there is no any particular order of the elements, because they are stored in the +hash table. The sample below demonstrates how to iterate through the sparse matrix: +@code + // print all the non-zero sparse matrix elements and compute their sum + double sum = 0; + int i, dims = cvGetDims(sparsemat); + CvSparseMatIterator it; + CvSparseNode* node = cvInitSparseMatIterator(sparsemat, &it); + + for(; node != 0; node = cvGetNextSparseNode(&it)) + { + int* idx = CV_NODE_IDX(array, node); + float val = *(float*)CV_NODE_VAL(array, node); + printf("M"); + for(i = 0; i < dims; i++ ) + printf("[%d]", idx[i]); + printf("=%g\n", val); + + sum += val; + } + + printf("nTotal sum = %g\n", sum); +@endcode +@param mat_iterator Sparse array iterator + */ +CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator ) +{ + if( mat_iterator->node->next ) + return mat_iterator->node = mat_iterator->node->next; + else + { + int idx; + for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ ) + { + CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx]; + if( node ) + { + mat_iterator->curidx = idx; + return mat_iterator->node = node; + } + } + return NULL; + } +} + + +#define CV_MAX_ARR 10 + +/** matrix iterator: used for n-ary operations on dense arrays */ +typedef struct CvNArrayIterator +{ + int count; /**< number of arrays */ + int dims; /**< number of dimensions to iterate */ + CvSize size; /**< maximal common linear size: { width = size, height = 1 } */ + uchar* ptr[CV_MAX_ARR]; /**< pointers to the array slices */ + int stack[CV_MAX_DIM]; /**< for internal use */ + CvMatND* hdr[CV_MAX_ARR]; /**< pointers to the headers of the + matrices that are processed */ +} +CvNArrayIterator; + +#define CV_NO_DEPTH_CHECK 1 +#define CV_NO_CN_CHECK 2 +#define CV_NO_SIZE_CHECK 4 + +/** initializes iterator that traverses through several arrays simultaneously + (the function together with cvNextArraySlice is used for + N-ari element-wise operations) */ +CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs, + const CvArr* mask, CvMatND* stubs, + CvNArrayIterator* array_iterator, + int flags CV_DEFAULT(0) ); + +/** returns zero value if iteration is finished, non-zero (slice length) otherwise */ +CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); + + +/** @brief Returns type of array elements. + +The function returns type of the array elements. In the case of IplImage the type is converted to +CvMat-like representation. For example, if the image has been created as: +@code + IplImage* img = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3); +@endcode +The code cvGetElemType(img) will return CV_8UC3. +@param arr Input array + */ +CVAPI(int) cvGetElemType( const CvArr* arr ); + +/** @brief Return number of array dimensions + +The function returns the array dimensionality and the array of dimension sizes. In the case of +IplImage or CvMat it always returns 2 regardless of number of image/matrix rows. For example, the +following code calculates total number of array elements: +@code + int sizes[CV_MAX_DIM]; + int i, total = 1; + int dims = cvGetDims(arr, size); + for(i = 0; i < dims; i++ ) + total *= sizes[i]; +@endcode +@param arr Input array +@param sizes Optional output vector of the array dimension sizes. For 2d arrays the number of rows +(height) goes first, number of columns (width) next. + */ +CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) ); + + +/** @brief Returns array size along the specified dimension. + +@param arr Input array +@param index Zero-based dimension index (for matrices 0 means number of rows, 1 means number of +columns; for images 0 means height, 1 means width) + */ +CVAPI(int) cvGetDimSize( const CvArr* arr, int index ); + + +/** @brief Return pointer to a particular array element. + +The functions return a pointer to a specific array element. Number of array dimension should match +to the number of indices passed to the function except for cvPtr1D function that can be used for +sequential access to 1D, 2D or nD dense arrays. + +The functions can be used for sparse arrays as well - if the requested node does not exist they +create it and set it to zero. + +All these as well as other functions accessing array elements ( cvGetND , cvGetRealND , cvSet +, cvSetND , cvSetRealND ) raise an error in case if the element index is out of range. +@param arr Input array +@param idx0 The first zero-based component of the element index +@param type Optional output parameter: type of matrix elements + */ +CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL)); +/** @overload */ +CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) ); +/** @overload */ +CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, + int* type CV_DEFAULT(NULL)); +/** @overload +@param arr Input array +@param idx Array of the element indices +@param type Optional output parameter: type of matrix elements +@param create_node Optional input parameter for sparse matrices. Non-zero value of the parameter +means that the requested element is created if it does not exist already. +@param precalc_hashval Optional input parameter for sparse matrices. If the pointer is not NULL, +the function does not recalculate the node hash value, but takes it from the specified location. +It is useful for speeding up pair-wise operations (TODO: provide an example) +*/ +CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL), + int create_node CV_DEFAULT(1), + unsigned* precalc_hashval CV_DEFAULT(NULL)); + +/** @brief Return a specific array element. + +The functions return a specific array element. In the case of a sparse array the functions return 0 +if the requested node does not exist (no new node is created by the functions). +@param arr Input array +@param idx0 The first zero-based component of the element index + */ +CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 ); +/** @overload */ +CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 ); +/** @overload */ +CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +/** @overload +@param arr Input array +@param idx Array of the element indices +*/ +CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx ); + +/** @brief Return a specific element of single-channel 1D, 2D, 3D or nD array. + +Returns a specific element of a single-channel array. If the array has multiple channels, a runtime +error is raised. Note that Get?D functions can be used safely for both single-channel and +multiple-channel arrays though they are a bit slower. + +In the case of a sparse array the functions return 0 if the requested node does not exist (no new +node is created by the functions). +@param arr Input array. Must have a single channel. +@param idx0 The first zero-based component of the element index + */ +CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 ); +/** @overload */ +CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 ); +/** @overload */ +CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +/** @overload +@param arr Input array. Must have a single channel. +@param idx Array of the element indices +*/ +CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx ); + +/** @brief Change the particular array element. + +The functions assign the new value to a particular array element. In the case of a sparse array the +functions create the node if it does not exist yet. +@param arr Input array +@param idx0 The first zero-based component of the element index +@param value The assigned value + */ +CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value ); +/** @overload */ +CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value ); +/** @overload */ +CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); +/** @overload +@param arr Input array +@param idx Array of the element indices +@param value The assigned value +*/ +CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value ); + +/** @brief Change a specific array element. + +The functions assign a new value to a specific element of a single-channel array. If the array has +multiple channels, a runtime error is raised. Note that the Set\*D function can be used safely for +both single-channel and multiple-channel arrays, though they are a bit slower. + +In the case of a sparse array the functions create the node if it does not yet exist. +@param arr Input array +@param idx0 The first zero-based component of the element index +@param value The assigned value + */ +CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value ); +/** @overload */ +CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value ); +/** @overload */ +CVAPI(void) cvSetReal3D( CvArr* arr, int idx0, + int idx1, int idx2, double value ); +/** @overload +@param arr Input array +@param idx Array of the element indices +@param value The assigned value +*/ +CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value ); + +/** clears element of ND dense array, + in case of sparse arrays it deletes the specified node */ +CVAPI(void) cvClearND( CvArr* arr, const int* idx ); + +/** @brief Returns matrix header for arbitrary array. + +The function returns a matrix header for the input array that can be a matrix - CvMat, an image - +IplImage, or a multi-dimensional dense array - CvMatND (the third option is allowed only if +allowND != 0) . In the case of matrix the function simply returns the input pointer. In the case of +IplImage\* or CvMatND it initializes the header structure with parameters of the current image ROI +and returns &header. Because COI is not supported by CvMat, it is returned separately. + +The function provides an easy way to handle both types of arrays - IplImage and CvMat using the same +code. Input array must have non-zero data pointer, otherwise the function will report an error. + +@note If the input array is IplImage with planar data layout and COI set, the function returns the +pointer to the selected plane and COI == 0. This feature allows user to process IplImage structures +with planar data layout, even though OpenCV does not support such images. +@param arr Input array +@param header Pointer to CvMat structure used as a temporary buffer +@param coi Optional output parameter for storing COI +@param allowND If non-zero, the function accepts multi-dimensional dense arrays (CvMatND\*) and +returns 2D matrix (if CvMatND has two dimensions) or 1D matrix (when CvMatND has 1 dimension or +more than 2 dimensions). The CvMatND array must be continuous. +@sa cvGetImage, cvarrToMat. + */ +CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header, + int* coi CV_DEFAULT(NULL), + int allowND CV_DEFAULT(0)); + +/** @brief Returns image header for arbitrary array. + +The function returns the image header for the input array that can be a matrix (CvMat) or image +(IplImage). In the case of an image the function simply returns the input pointer. In the case of +CvMat it initializes an image_header structure with the parameters of the input matrix. Note that +if we transform IplImage to CvMat using cvGetMat and then transform CvMat back to IplImage using +this function, we will get different headers if the ROI is set in the original image. +@param arr Input array +@param image_header Pointer to IplImage structure used as a temporary buffer + */ +CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header ); + + +/** @brief Changes the shape of a multi-dimensional array without copying the data. + +The function is an advanced version of cvReshape that can work with multi-dimensional arrays as +well (though it can work with ordinary images and matrices) and change the number of dimensions. + +Below are the two samples from the cvReshape description rewritten using cvReshapeMatND: +@code + IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3); + IplImage gray_img_hdr, *gray_img; + gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr), &gray_img_hdr, 1, 0, 0); + ... + int size[] = { 2, 2, 2 }; + CvMatND* mat = cvCreateMatND(3, size, CV_32F); + CvMat row_header, *row; + row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0); +@endcode +In C, the header file for this function includes a convenient macro cvReshapeND that does away with +the sizeof_header parameter. So, the lines containing the call to cvReshapeMatND in the examples +may be replaced as follow: +@code + gray_img = (IplImage*)cvReshapeND(color_img, &gray_img_hdr, 1, 0, 0); + ... + row = (CvMat*)cvReshapeND(mat, &row_header, 0, 1, 0); +@endcode +@param arr Input array +@param sizeof_header Size of output header to distinguish between IplImage, CvMat and CvMatND +output headers +@param header Output header to be filled +@param new_cn New number of channels. new_cn = 0 means that the number of channels remains +unchanged. +@param new_dims New number of dimensions. new_dims = 0 means that the number of dimensions +remains the same. +@param new_sizes Array of new dimension sizes. Only new_dims-1 values are used, because the +total number of elements must remain the same. Thus, if new_dims = 1, new_sizes array is not +used. + */ +CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr, + int sizeof_header, CvArr* header, + int new_cn, int new_dims, int* new_sizes ); + +#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \ + cvReshapeMatND( (arr), sizeof(*(header)), (header), \ + (new_cn), (new_dims), (new_sizes)) + +/** @brief Changes shape of matrix/image without copying data. + +The function initializes the CvMat header so that it points to the same data as the original array +but has a different shape - different number of channels, different number of rows, or both. + +The following example code creates one image buffer and two image headers, the first is for a +320x240x3 image and the second is for a 960x240x1 image: +@code + IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3); + CvMat gray_mat_hdr; + IplImage gray_img_hdr, *gray_img; + cvReshape(color_img, &gray_mat_hdr, 1); + gray_img = cvGetImage(&gray_mat_hdr, &gray_img_hdr); +@endcode +And the next example converts a 3x3 matrix to a single 1x9 vector: +@code + CvMat* mat = cvCreateMat(3, 3, CV_32F); + CvMat row_header, *row; + row = cvReshape(mat, &row_header, 0, 1); +@endcode +@param arr Input array +@param header Output header to be filled +@param new_cn New number of channels. 'new_cn = 0' means that the number of channels remains +unchanged. +@param new_rows New number of rows. 'new_rows = 0' means that the number of rows remains +unchanged unless it needs to be changed according to new_cn value. +*/ +CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header, + int new_cn, int new_rows CV_DEFAULT(0) ); + +/** Repeats source 2d array several times in both horizontal and + vertical direction to fill destination array */ +CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst ); + +/** @brief Allocates array data + +The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of +matrix types OpenCV allocation functions are used. In the case of IplImage they are used unless +CV_TURN_ON_IPL_COMPATIBILITY() has been called before. In the latter case IPL functions are used +to allocate the data. +@param arr Array header + */ +CVAPI(void) cvCreateData( CvArr* arr ); + +/** @brief Releases array data. + +The function releases the array data. In the case of CvMat or CvMatND it simply calls +cvDecRefData(), that is the function can not deallocate external data. See also the note to +cvCreateData . +@param arr Array header + */ +CVAPI(void) cvReleaseData( CvArr* arr ); + +/** @brief Assigns user data to the array header. + +The function assigns user data to the array header. Header should be initialized before using +cvCreateMatHeader, cvCreateImageHeader, cvCreateMatNDHeader, cvInitMatHeader, +cvInitImageHeader or cvInitMatNDHeader. +@param arr Array header +@param data User data +@param step Full row length in bytes + */ +CVAPI(void) cvSetData( CvArr* arr, void* data, int step ); + +/** @brief Retrieves low-level information about the array. + +The function fills output variables with low-level information about the array data. All output + +parameters are optional, so some of the pointers may be set to NULL. If the array is IplImage with +ROI set, the parameters of ROI are returned. + +The following example shows how to get access to array elements. It computes absolute values of the +array elements : +@code + float* data; + int step; + CvSize size; + + cvGetRawData(array, (uchar**)&data, &step, &size); + step /= sizeof(data[0]); + + for(int y = 0; y < size.height; y++, data += step ) + for(int x = 0; x < size.width; x++ ) + data[x] = (float)fabs(data[x]); +@endcode +@param arr Array header +@param data Output pointer to the whole image origin or ROI origin if ROI is set +@param step Output full row length in bytes +@param roi_size Output ROI size + */ +CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data, + int* step CV_DEFAULT(NULL), + CvSize* roi_size CV_DEFAULT(NULL)); + +/** @brief Returns size of matrix or image ROI. + +The function returns number of rows (CvSize::height) and number of columns (CvSize::width) of the +input matrix or image. In the case of image the size of ROI is returned. +@param arr array header + */ +CVAPI(CvSize) cvGetSize( const CvArr* arr ); + +/** @brief Copies one array to another. + +The function copies selected elements from an input array to an output array: + +\f[\texttt{dst} (I)= \texttt{src} (I) \quad \text{if} \quad \texttt{mask} (I) \ne 0.\f] + +If any of the passed arrays is of IplImage type, then its ROI and COI fields are used. Both arrays +must have the same type, the same number of dimensions, and the same size. The function can also +copy sparse arrays (mask is not supported in this case). +@param src The source array +@param dst The destination array +@param mask Operation mask, 8-bit single channel array; specifies elements of the destination array +to be changed + */ +CVAPI(void) cvCopy( const CvArr* src, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Sets every element of an array to a given value. + +The function copies the scalar value to every selected element of the destination array: +\f[\texttt{arr} (I)= \texttt{value} \quad \text{if} \quad \texttt{mask} (I) \ne 0\f] +If array arr is of IplImage type, then is ROI used, but COI must not be set. +@param arr The destination array +@param value Fill value +@param mask Operation mask, 8-bit single channel array; specifies elements of the destination +array to be changed + */ +CVAPI(void) cvSet( CvArr* arr, CvScalar value, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Clears the array. + +The function clears the array. In the case of dense arrays (CvMat, CvMatND or IplImage), +cvZero(array) is equivalent to cvSet(array,cvScalarAll(0),0). In the case of sparse arrays all the +elements are removed. +@param arr Array to be cleared + */ +CVAPI(void) cvSetZero( CvArr* arr ); +#define cvZero cvSetZero + + +/** Splits a multi-channel array into the set of single-channel arrays or + extracts particular [color] plane */ +CVAPI(void) cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1, + CvArr* dst2, CvArr* dst3 ); + +/** Merges a set of single-channel arrays into the single multi-channel array + or inserts one particular [color] plane to the array */ +CVAPI(void) cvMerge( const CvArr* src0, const CvArr* src1, + const CvArr* src2, const CvArr* src3, + CvArr* dst ); + +/** Copies several channels from input arrays to + certain channels of output arrays */ +CVAPI(void) cvMixChannels( const CvArr** src, int src_count, + CvArr** dst, int dst_count, + const int* from_to, int pair_count ); + +/** @brief Converts one array to another with optional linear transformation. + +The function has several different purposes, and thus has several different names. It copies one +array to another with optional scaling, which is performed first, and/or optional type conversion, +performed after: + +\f[\texttt{dst} (I) = \texttt{scale} \texttt{src} (I) + ( \texttt{shift} _0, \texttt{shift} _1,...)\f] + +All the channels of multi-channel arrays are processed independently. + +The type of conversion is done with rounding and saturation, that is if the result of scaling + +conversion can not be represented exactly by a value of the destination array element type, it is +set to the nearest representable value on the real axis. +@param src Source array +@param dst Destination array +@param scale Scale factor +@param shift Value added to the scaled source array elements + */ +CVAPI(void) cvConvertScale( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScale cvConvertScale +#define cvScale cvConvertScale +#define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 ) + + +/** Performs linear transformation on every source array element, + stores absolute value of the result: + dst(x,y,c) = abs(scale*src(x,y,c)+shift). + destination array must have 8u type. + In other cases one may use cvConvertScale + cvAbsDiffS */ +CVAPI(void) cvConvertScaleAbs( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScaleAbs cvConvertScaleAbs + + +/** checks termination criteria validity and + sets eps to default_eps (if it is not set), + max_iter to default_max_iters (if it is not set) +*/ +CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria, + double default_eps, + int default_max_iters ); + +/****************************************************************************************\ +* Arithmetic, logic and comparison operations * +\****************************************************************************************/ + +/** dst(mask) = src1(mask) + src2(mask) */ +CVAPI(void) cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(mask) = src(mask) + value */ +CVAPI(void) cvAddS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(mask) = src1(mask) - src2(mask) */ +CVAPI(void) cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(mask) = src(mask) - value = src(mask) + (-value) */ +CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)) +{ + cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]), + dst, mask ); +} + +/** dst(mask) = value - src(mask) */ +CVAPI(void) cvSubRS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src1(idx) * src2(idx) * scale + (scaled element-wise multiplication of 2 arrays) */ +CVAPI(void) cvMul( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1) ); + +/** element-wise division/inversion with scaling: + dst(idx) = src1(idx) * scale / src2(idx) + or dst(idx) = scale / src2(idx) if src1 == 0 */ +CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1)); + +/** dst = src1 * scale + src2 */ +CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale, + const CvArr* src2, CvArr* dst ); +#define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C) + +/** dst = src1 * alpha + src2 * beta + gamma */ +CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha, + const CvArr* src2, double beta, + double gamma, CvArr* dst ); + +/** @brief Calculates the dot product of two arrays in Euclidean metrics. + +The function calculates and returns the Euclidean dot product of two arrays. + +\f[src1 \bullet src2 = \sum _I ( \texttt{src1} (I) \texttt{src2} (I))\f] + +In the case of multiple channel arrays, the results for all channels are accumulated. In particular, +cvDotProduct(a,a) where a is a complex vector, will return \f$||\texttt{a}||^2\f$. The function can +process multi-dimensional arrays, row by row, layer by layer, and so on. +@param src1 The first source array +@param src2 The second source array + */ +CVAPI(double) cvDotProduct( const CvArr* src1, const CvArr* src2 ); + +/** dst(idx) = src1(idx) & src2(idx) */ +CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src(idx) & value */ +CVAPI(void) cvAndS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src1(idx) | src2(idx) */ +CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src(idx) | value */ +CVAPI(void) cvOrS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src1(idx) ^ src2(idx) */ +CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src(idx) ^ value */ +CVAPI(void) cvXorS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = ~src(idx) */ +CVAPI(void) cvNot( const CvArr* src, CvArr* dst ); + +/** dst(idx) = lower(idx) <= src(idx) < upper(idx) */ +CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower, + const CvArr* upper, CvArr* dst ); + +/** dst(idx) = lower <= src(idx) < upper */ +CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower, + CvScalar upper, CvArr* dst ); + +#define CV_CMP_EQ 0 +#define CV_CMP_GT 1 +#define CV_CMP_GE 2 +#define CV_CMP_LT 3 +#define CV_CMP_LE 4 +#define CV_CMP_NE 5 + +/** The comparison operation support single-channel arrays only. + Destination image should be 8uC1 or 8sC1 */ + +/** dst(idx) = src1(idx) _cmp_op_ src2(idx) */ +CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op ); + +/** dst(idx) = src1(idx) _cmp_op_ value */ +CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op ); + +/** dst(idx) = min(src1(idx),src2(idx)) */ +CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** dst(idx) = max(src1(idx),src2(idx)) */ +CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** dst(idx) = min(src(idx),value) */ +CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst ); + +/** dst(idx) = max(src(idx),value) */ +CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst ); + +/** dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */ +CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** dst(x,y,c) = abs(src(x,y,c) - value(c)) */ +CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); +#define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0)) + +/****************************************************************************************\ +* Math operations * +\****************************************************************************************/ + +/** Does cartesian->polar coordinates conversion. + Either of output components (magnitude or angle) is optional */ +CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y, + CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL), + int angle_in_degrees CV_DEFAULT(0)); + +/** Does polar->cartesian coordinates conversion. + Either of output components (magnitude or angle) is optional. + If magnitude is missing it is assumed to be all 1's */ +CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle, + CvArr* x, CvArr* y, + int angle_in_degrees CV_DEFAULT(0)); + +/** Does powering: dst(idx) = src(idx)^power */ +CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power ); + +/** Does exponention: dst(idx) = exp(src(idx)). + Overflow is not handled yet. Underflow is handled. + Maximal relative error is ~7e-6 for single-precision input */ +CVAPI(void) cvExp( const CvArr* src, CvArr* dst ); + +/** Calculates natural logarithms: dst(idx) = log(abs(src(idx))). + Logarithm of 0 gives large negative number(~-700) + Maximal relative error is ~3e-7 for single-precision output +*/ +CVAPI(void) cvLog( const CvArr* src, CvArr* dst ); + +/** Fast arctangent calculation */ +CVAPI(float) cvFastArctan( float y, float x ); + +/** Fast cubic root calculation */ +CVAPI(float) cvCbrt( float value ); + +#define CV_CHECK_RANGE 1 +#define CV_CHECK_QUIET 2 +/** Checks array values for NaNs, Infs or simply for too large numbers + (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set, + no runtime errors is raised (function returns zero value in case of "bad" values). + Otherwise cvError is called */ +CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), + double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0)); +#define cvCheckArray cvCheckArr + +#define CV_RAND_UNI 0 +#define CV_RAND_NORMAL 1 + +/** @brief Fills an array with random numbers and updates the RNG state. + +The function fills the destination array with uniformly or normally distributed random numbers. +@param rng CvRNG state initialized by cvRNG +@param arr The destination array +@param dist_type Distribution type +> - **CV_RAND_UNI** uniform distribution +> - **CV_RAND_NORMAL** normal or Gaussian distribution +@param param1 The first parameter of the distribution. In the case of a uniform distribution it is +the inclusive lower boundary of the random numbers range. In the case of a normal distribution it +is the mean value of the random numbers. +@param param2 The second parameter of the distribution. In the case of a uniform distribution it +is the exclusive upper boundary of the random numbers range. In the case of a normal distribution +it is the standard deviation of the random numbers. +@sa randu, randn, RNG::fill. + */ +CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, + CvScalar param1, CvScalar param2 ); + +CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, + double iter_factor CV_DEFAULT(1.)); + +#define CV_SORT_EVERY_ROW 0 +#define CV_SORT_EVERY_COLUMN 1 +#define CV_SORT_ASCENDING 0 +#define CV_SORT_DESCENDING 16 + +CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), + CvArr* idxmat CV_DEFAULT(NULL), + int flags CV_DEFAULT(0)); + +/** Finds real roots of a cubic equation */ +CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots ); + +/** Finds all real and complex roots of a polynomial equation */ +CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2, + int maxiter CV_DEFAULT(20), int fig CV_DEFAULT(100)); + +/****************************************************************************************\ +* Matrix operations * +\****************************************************************************************/ + +/** @brief Calculates the cross product of two 3D vectors. + +The function calculates the cross product of two 3D vectors: +\f[\texttt{dst} = \texttt{src1} \times \texttt{src2}\f] +or: +\f[\begin{array}{l} \texttt{dst} _1 = \texttt{src1} _2 \texttt{src2} _3 - \texttt{src1} _3 \texttt{src2} _2 \\ \texttt{dst} _2 = \texttt{src1} _3 \texttt{src2} _1 - \texttt{src1} _1 \texttt{src2} _3 \\ \texttt{dst} _3 = \texttt{src1} _1 \texttt{src2} _2 - \texttt{src1} _2 \texttt{src2} _1 \end{array}\f] +@param src1 The first source vector +@param src2 The second source vector +@param dst The destination vector + */ +CVAPI(void) cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** Matrix transform: dst = A*B + C, C is optional */ +#define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 ) +#define cvMatMul( src1, src2, dst ) cvMatMulAdd( (src1), (src2), NULL, (dst)) + +#define CV_GEMM_A_T 1 +#define CV_GEMM_B_T 2 +#define CV_GEMM_C_T 4 +/** Extended matrix transform: + dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */ +CVAPI(void) cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, + const CvArr* src3, double beta, CvArr* dst, + int tABC CV_DEFAULT(0)); +#define cvMatMulAddEx cvGEMM + +/** Transforms each element of source array and stores + resultant vectors in destination array */ +CVAPI(void) cvTransform( const CvArr* src, CvArr* dst, + const CvMat* transmat, + const CvMat* shiftvec CV_DEFAULT(NULL)); +#define cvMatMulAddS cvTransform + +/** Does perspective transform on every element of input array */ +CVAPI(void) cvPerspectiveTransform( const CvArr* src, CvArr* dst, + const CvMat* mat ); + +/** Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */ +CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order, + const CvArr* delta CV_DEFAULT(NULL), + double scale CV_DEFAULT(1.) ); + +/** Transposes matrix. Square matrices can be transposed in-place */ +CVAPI(void) cvTranspose( const CvArr* src, CvArr* dst ); +#define cvT cvTranspose + +/** Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part */ +CVAPI(void) cvCompleteSymm( CvMat* matrix, int LtoR CV_DEFAULT(0) ); + +/** Mirror array data around horizontal (flip=0), + vertical (flip=1) or both(flip=-1) axises: + cvFlip(src) flips images vertically and sequences horizontally (inplace) */ +CVAPI(void) cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), + int flip_mode CV_DEFAULT(0)); +#define cvMirror cvFlip + + +#define CV_SVD_MODIFY_A 1 +#define CV_SVD_U_T 2 +#define CV_SVD_V_T 4 + +/** Performs Singular Value Decomposition of a matrix */ +CVAPI(void) cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL), + CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0)); + +/** Performs Singular Value Back Substitution (solves A*X = B): + flags must be the same as in cvSVD */ +CVAPI(void) cvSVBkSb( const CvArr* W, const CvArr* U, + const CvArr* V, const CvArr* B, + CvArr* X, int flags ); + +#define CV_LU 0 +#define CV_SVD 1 +#define CV_SVD_SYM 2 +#define CV_CHOLESKY 3 +#define CV_QR 4 +#define CV_NORMAL 16 + +/** Inverts matrix */ +CVAPI(double) cvInvert( const CvArr* src, CvArr* dst, + int method CV_DEFAULT(CV_LU)); +#define cvInv cvInvert + +/** Solves linear system (src1)*(dst) = (src2) + (returns 0 if src1 is a singular and CV_LU method is used) */ +CVAPI(int) cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst, + int method CV_DEFAULT(CV_LU)); + +/** Calculates determinant of input matrix */ +CVAPI(double) cvDet( const CvArr* mat ); + +/** Calculates trace of the matrix (sum of elements on the main diagonal) */ +CVAPI(CvScalar) cvTrace( const CvArr* mat ); + +/** Finds eigen values and vectors of a symmetric matrix */ +CVAPI(void) cvEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, + double eps CV_DEFAULT(0), + int lowindex CV_DEFAULT(-1), + int highindex CV_DEFAULT(-1)); + +///* Finds selected eigen values and vectors of a symmetric matrix */ +//CVAPI(void) cvSelectedEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, +// int lowindex, int highindex ); + +/** Makes an identity matrix (mat_ij = i == j) */ +CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) ); + +/** Fills matrix with given range of numbers */ +CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end ); + +/** @anchor core_c_CovarFlags +@name Flags for cvCalcCovarMatrix +@see cvCalcCovarMatrix + @{ +*/ + +/** flag for cvCalcCovarMatrix, transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */ +#define CV_COVAR_SCRAMBLED 0 + +/** flag for cvCalcCovarMatrix, [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */ +#define CV_COVAR_NORMAL 1 + +/** flag for cvCalcCovarMatrix, do not calc average (i.e. mean vector) - use the input vector instead + (useful for calculating covariance matrix by parts) */ +#define CV_COVAR_USE_AVG 2 + +/** flag for cvCalcCovarMatrix, scale the covariance matrix coefficients by number of the vectors */ +#define CV_COVAR_SCALE 4 + +/** flag for cvCalcCovarMatrix, all the input vectors are stored in a single matrix, as its rows */ +#define CV_COVAR_ROWS 8 + +/** flag for cvCalcCovarMatrix, all the input vectors are stored in a single matrix, as its columns */ +#define CV_COVAR_COLS 16 + +/** @} */ + +/** Calculates covariation matrix for a set of vectors +@see @ref core_c_CovarFlags "flags" +*/ +CVAPI(void) cvCalcCovarMatrix( const CvArr** vects, int count, + CvArr* cov_mat, CvArr* avg, int flags ); + +#define CV_PCA_DATA_AS_ROW 0 +#define CV_PCA_DATA_AS_COL 1 +#define CV_PCA_USE_AVG 2 +CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean, + CvArr* eigenvals, CvArr* eigenvects, int flags ); + +CVAPI(void) cvProjectPCA( const CvArr* data, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +CVAPI(void) cvBackProjectPCA( const CvArr* proj, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +/** Calculates Mahalanobis(weighted) distance */ +CVAPI(double) cvMahalanobis( const CvArr* vec1, const CvArr* vec2, const CvArr* mat ); +#define cvMahalonobis cvMahalanobis + +/****************************************************************************************\ +* Array Statistics * +\****************************************************************************************/ + +/** Finds sum of array elements */ +CVAPI(CvScalar) cvSum( const CvArr* arr ); + +/** Calculates number of non-zero pixels */ +CVAPI(int) cvCountNonZero( const CvArr* arr ); + +/** Calculates mean value of array elements */ +CVAPI(CvScalar) cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) ); + +/** Calculates mean and standard deviation of pixel values */ +CVAPI(void) cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** Finds global minimum, maximum and their positions */ +CVAPI(void) cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val, + CvPoint* min_loc CV_DEFAULT(NULL), + CvPoint* max_loc CV_DEFAULT(NULL), + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @anchor core_c_NormFlags + @name Flags for cvNorm and cvNormalize + @{ +*/ +#define CV_C 1 +#define CV_L1 2 +#define CV_L2 4 +#define CV_NORM_MASK 7 +#define CV_RELATIVE 8 +#define CV_DIFF 16 +#define CV_MINMAX 32 + +#define CV_DIFF_C (CV_DIFF | CV_C) +#define CV_DIFF_L1 (CV_DIFF | CV_L1) +#define CV_DIFF_L2 (CV_DIFF | CV_L2) +#define CV_RELATIVE_C (CV_RELATIVE | CV_C) +#define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1) +#define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2) +/** @} */ + +/** Finds norm, difference norm or relative difference norm for an array (or two arrays) +@see ref core_c_NormFlags "flags" +*/ +CVAPI(double) cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @see ref core_c_NormFlags "flags" */ +CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst, + double a CV_DEFAULT(1.), double b CV_DEFAULT(0.), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @anchor core_c_ReduceFlags + @name Flags for cvReduce + @{ +*/ +#define CV_REDUCE_SUM 0 +#define CV_REDUCE_AVG 1 +#define CV_REDUCE_MAX 2 +#define CV_REDUCE_MIN 3 +/** @} */ + +/** @see @ref core_c_ReduceFlags "flags" */ +CVAPI(void) cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1), + int op CV_DEFAULT(CV_REDUCE_SUM) ); + +/****************************************************************************************\ +* Discrete Linear Transforms and Related Functions * +\****************************************************************************************/ + +/** @anchor core_c_DftFlags + @name Flags for cvDFT, cvDCT and cvMulSpectrums + @{ + */ +#define CV_DXT_FORWARD 0 +#define CV_DXT_INVERSE 1 +#define CV_DXT_SCALE 2 /**< divide result by size of array */ +#define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE) +#define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE +#define CV_DXT_ROWS 4 /**< transform each row individually */ +#define CV_DXT_MUL_CONJ 8 /**< conjugate the second argument of cvMulSpectrums */ +/** @} */ + +/** Discrete Fourier Transform: + complex->complex, + real->ccs (forward), + ccs->real (inverse) +@see core_c_DftFlags "flags" +*/ +CVAPI(void) cvDFT( const CvArr* src, CvArr* dst, int flags, + int nonzero_rows CV_DEFAULT(0) ); +#define cvFFT cvDFT + +/** Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) +@see core_c_DftFlags "flags" +*/ +CVAPI(void) cvMulSpectrums( const CvArr* src1, const CvArr* src2, + CvArr* dst, int flags ); + +/** Finds optimal DFT vector size >= size0 */ +CVAPI(int) cvGetOptimalDFTSize( int size0 ); + +/** Discrete Cosine Transform +@see core_c_DftFlags "flags" +*/ +CVAPI(void) cvDCT( const CvArr* src, CvArr* dst, int flags ); + +/****************************************************************************************\ +* Dynamic data structures * +\****************************************************************************************/ + +/** Calculates length of sequence slice (with support of negative indices). */ +CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq ); + + +/** Creates new memory storage. + block_size == 0 means that default, + somewhat optimal size, is used (currently, it is 64K) */ +CVAPI(CvMemStorage*) cvCreateMemStorage( int block_size CV_DEFAULT(0)); + + +/** Creates a memory storage that will borrow memory blocks from parent storage */ +CVAPI(CvMemStorage*) cvCreateChildMemStorage( CvMemStorage* parent ); + + +/** Releases memory storage. All the children of a parent must be released before + the parent. A child storage returns all the blocks to parent when it is released */ +CVAPI(void) cvReleaseMemStorage( CvMemStorage** storage ); + + +/** Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) + to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... + do not free any memory. + A child storage returns all the blocks to the parent when it is cleared */ +CVAPI(void) cvClearMemStorage( CvMemStorage* storage ); + +/** Remember a storage "free memory" position */ +CVAPI(void) cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos ); + +/** Restore a storage "free memory" position */ +CVAPI(void) cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos ); + +/** Allocates continuous buffer of the specified size in the storage */ +CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); + +/** Allocates string in memory storage */ +//CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, +// int len CV_DEFAULT(-1) ); + +/** Creates new empty sequence that will reside in the specified storage */ +CVAPI(CvSeq*) cvCreateSeq( int seq_flags, size_t header_size, + size_t elem_size, CvMemStorage* storage ); + +/** Changes default size (granularity) of sequence blocks. + The default size is ~1Kbyte */ +CVAPI(void) cvSetSeqBlockSize( CvSeq* seq, int delta_elems ); + + +/** Adds new element to the end of sequence. Returns pointer to the element */ +CVAPI(schar*) cvSeqPush( CvSeq* seq, const void* element CV_DEFAULT(NULL)); + + +/** Adds new element to the beginning of sequence. Returns pointer to it */ +CVAPI(schar*) cvSeqPushFront( CvSeq* seq, const void* element CV_DEFAULT(NULL)); + + +/** Removes the last element from sequence and optionally saves it */ +CVAPI(void) cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/** Removes the first element from sequence and optioanally saves it */ +CVAPI(void) cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +#define CV_FRONT 1 +#define CV_BACK 0 +/** Adds several new elements to the end of sequence */ +CVAPI(void) cvSeqPushMulti( CvSeq* seq, const void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/** Removes several elements from the end of sequence and optionally saves them */ +CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/** Inserts a new element in the middle of sequence. + cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */ +CVAPI(schar*) cvSeqInsert( CvSeq* seq, int before_index, + const void* element CV_DEFAULT(NULL)); + +/** Removes specified sequence element */ +CVAPI(void) cvSeqRemove( CvSeq* seq, int index ); + + +/** Removes all the elements from the sequence. The freed memory + can be reused later only by the same sequence unless cvClearMemStorage + or cvRestoreMemStoragePos is called */ +CVAPI(void) cvClearSeq( CvSeq* seq ); + + +/** Retrieves pointer to specified sequence element. + Negative indices are supported and mean counting from the end + (e.g -1 means the last sequence element) */ +CVAPI(schar*) cvGetSeqElem( const CvSeq* seq, int index ); + +/** Calculates index of the specified sequence element. + Returns -1 if element does not belong to the sequence */ +CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element, + CvSeqBlock** block CV_DEFAULT(NULL) ); + +/** Initializes sequence writer. The new elements will be added to the end of sequence */ +CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer ); + + +/** Combination of cvCreateSeq and cvStartAppendToSeq */ +CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size, + int elem_size, CvMemStorage* storage, + CvSeqWriter* writer ); + +/** Closes sequence writer, updates sequence header and returns pointer + to the resultant sequence + (which may be useful if the sequence was created using cvStartWriteSeq)) +*/ +CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer ); + + +/** Updates sequence header. May be useful to get access to some of previously + written elements via cvGetSeqElem or sequence reader */ +CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer ); + + +/** Initializes sequence reader. + The sequence can be read in forward or backward direction */ +CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, + int reverse CV_DEFAULT(0) ); + + +/** Returns current sequence reader position (currently observed sequence element) */ +CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader ); + + +/** Changes sequence reader position. It may seek to an absolute or + to relative to the current position */ +CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index, + int is_relative CV_DEFAULT(0)); + +/** Copies sequence content to a continuous piece of memory */ +CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) ); + +/** Creates sequence header for array. + After that all the operations on sequences that do not alter the content + can be applied to the resultant sequence */ +CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size, + int elem_size, void* elements, int total, + CvSeq* seq, CvSeqBlock* block ); + +/** Extracts sequence slice (with or without copying sequence elements) */ +CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice, + CvMemStorage* storage CV_DEFAULT(NULL), + int copy_data CV_DEFAULT(0)); + +CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL)) +{ + return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 ); +} + +/** Removes sequence slice */ +CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ); + +/** Inserts a sequence or array into another sequence */ +CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); + +/** a < b ? -1 : a > b ? 1 : 0 */ +typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata ); + +/** Sorts sequence in-place given element comparison function */ +CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) ); + +/** Finds element in a [sorted] sequence */ +CVAPI(schar*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func, + int is_sorted, int* elem_idx, + void* userdata CV_DEFAULT(NULL) ); + +/** Reverses order of sequence elements in-place */ +CVAPI(void) cvSeqInvert( CvSeq* seq ); + +/** Splits sequence into one or more equivalence classes using the specified criteria */ +CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, + CvSeq** labels, CvCmpFunc is_equal, void* userdata ); + +/************ Internal sequence functions ************/ +CVAPI(void) cvChangeSeqBlock( void* reader, int direction ); +CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer ); + + +/** Creates a new set */ +CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size, + int elem_size, CvMemStorage* storage ); + +/** Adds new element to the set and returns pointer to it */ +CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL), + CvSetElem** inserted_elem CV_DEFAULT(NULL) ); + +/** Fast variant of cvSetAdd */ +CV_INLINE CvSetElem* cvSetNew( CvSet* set_header ) +{ + CvSetElem* elem = set_header->free_elems; + if( elem ) + { + set_header->free_elems = elem->next_free; + elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK; + set_header->active_count++; + } + else + cvSetAdd( set_header, NULL, &elem ); + return elem; +} + +/** Removes set element given its pointer */ +CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem ) +{ + CvSetElem* _elem = (CvSetElem*)elem; + assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ ); + _elem->next_free = set_header->free_elems; + _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG; + set_header->free_elems = _elem; + set_header->active_count--; +} + +/** Removes element from the set by its index */ +CVAPI(void) cvSetRemove( CvSet* set_header, int index ); + +/** Returns a set element by index. If the element doesn't belong to the set, + NULL is returned */ +CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int idx ) +{ + CvSetElem* elem = (CvSetElem*)(void *)cvGetSeqElem( (CvSeq*)set_header, idx ); + return elem && CV_IS_SET_ELEM( elem ) ? elem : 0; +} + +/** Removes all the elements from the set */ +CVAPI(void) cvClearSet( CvSet* set_header ); + +/** Creates new graph */ +CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size, + int vtx_size, int edge_size, + CvMemStorage* storage ); + +/** Adds new vertex to the graph */ +CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL), + CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) ); + + +/** Removes vertex from the graph together with all incident edges */ +CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index ); +CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx ); + + +/** Link two vertices specified by indices or pointers if they + are not connected or return pointer to already existing edge + connecting the vertices. + Functions return 1 if a new edge was created, 0 otherwise */ +CVAPI(int) cvGraphAddEdge( CvGraph* graph, + int start_idx, int end_idx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph, + CvGraphVtx* start_vtx, CvGraphVtx* end_vtx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +/** Remove edge connecting two vertices */ +CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx ); +CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, + CvGraphVtx* end_vtx ); + +/** Find edge connecting two vertices */ +CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx ); +CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph, + const CvGraphVtx* start_vtx, + const CvGraphVtx* end_vtx ); +#define cvGraphFindEdge cvFindGraphEdge +#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr + +/** Remove all vertices and edges from the graph */ +CVAPI(void) cvClearGraph( CvGraph* graph ); + + +/** Count number of edges incident to the vertex */ +CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx ); +CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx ); + + +/** Retrieves graph vertex by given index */ +#define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx)) + +/** Retrieves index of a graph vertex given its pointer */ +#define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK) + +/** Retrieves index of a graph edge given its pointer */ +#define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK) + +#define cvGraphGetVtxCount( graph ) ((graph)->active_count) +#define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count) + +#define CV_GRAPH_VERTEX 1 +#define CV_GRAPH_TREE_EDGE 2 +#define CV_GRAPH_BACK_EDGE 4 +#define CV_GRAPH_FORWARD_EDGE 8 +#define CV_GRAPH_CROSS_EDGE 16 +#define CV_GRAPH_ANY_EDGE 30 +#define CV_GRAPH_NEW_TREE 32 +#define CV_GRAPH_BACKTRACKING 64 +#define CV_GRAPH_OVER -1 + +#define CV_GRAPH_ALL_ITEMS -1 + +/** flags for graph vertices and edges */ +#define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30) +#define CV_IS_GRAPH_VERTEX_VISITED(vtx) \ + (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_IS_GRAPH_EDGE_VISITED(edge) \ + (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29) +#define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28) + +typedef struct CvGraphScanner +{ + CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */ + CvGraphVtx* dst; /* current graph edge destination vertex */ + CvGraphEdge* edge; /* current edge */ + + CvGraph* graph; /* the graph */ + CvSeq* stack; /* the graph vertex stack */ + int index; /* the lower bound of certainly visited vertices */ + int mask; /* event mask */ +} +CvGraphScanner; + +/** Creates new graph scanner. */ +CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph, + CvGraphVtx* vtx CV_DEFAULT(NULL), + int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)); + +/** Releases graph scanner. */ +CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner ); + +/** Get next graph element */ +CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner ); + +/** Creates a copy of graph */ +CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ); + + +/** Does look-up transformation. Elements of the source array + (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */ +CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut ); + + +/******************* Iteration through the sequence tree *****************/ +typedef struct CvTreeNodeIterator +{ + const void* node; + int level; + int max_level; +} +CvTreeNodeIterator; + +CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, + const void* first, int max_level ); +CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator ); +CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator ); + +/** Inserts sequence into tree with specified "parent" sequence. + If parent is equal to frame (e.g. the most external contour), + then added contour will have null pointer to parent. */ +CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame ); + +/** Removes contour from tree (together with the contour children). */ +CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame ); + +/** Gathers pointers to all the sequences, + accessible from the `first`, to the single sequence */ +CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, + CvMemStorage* storage ); + +/** The function implements the K-means algorithm for clustering an array of sample + vectors in a specified number of classes */ +#define CV_KMEANS_USE_INITIAL_LABELS 1 +CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, + CvTermCriteria termcrit, int attempts CV_DEFAULT(1), + CvRNG* rng CV_DEFAULT(0), int flags CV_DEFAULT(0), + CvArr* _centers CV_DEFAULT(0), double* compactness CV_DEFAULT(0) ); + +/****************************************************************************************\ +* System functions * +\****************************************************************************************/ + +/** Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ +CVAPI(int) cvUseOptimized( int on_off ); + +typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) + (int,int,int,char*,char*,int,int,int,int,int, + IplROI*,IplImage*,void*,IplTileInfo*); +typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int); +typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int); +typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int); +typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*); + +/** @brief Makes OpenCV use IPL functions for allocating IplImage and IplROI structures. + +Normally, the function is not called directly. Instead, a simple macro +CV_TURN_ON_IPL_COMPATIBILITY() is used that calls cvSetIPLAllocators and passes there pointers +to IPL allocation functions. : +@code + ... + CV_TURN_ON_IPL_COMPATIBILITY() + ... +@endcode +@param create_header pointer to a function, creating IPL image header. +@param allocate_data pointer to a function, allocating IPL image data. +@param deallocate pointer to a function, deallocating IPL image. +@param create_roi pointer to a function, creating IPL image ROI (i.e. Region of Interest). +@param clone_image pointer to a function, cloning an IPL image. + */ +CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, + Cv_iplAllocateImageData allocate_data, + Cv_iplDeallocate deallocate, + Cv_iplCreateROI create_roi, + Cv_iplCloneImage clone_image ); + +#define CV_TURN_ON_IPL_COMPATIBILITY() \ + cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ + iplDeallocate, iplCreateROI, iplCloneImage ) + +/****************************************************************************************\ +* Data Persistence * +\****************************************************************************************/ + +#if 0 +/********************************** High-level functions ********************************/ + +/** @brief Opens file storage for reading or writing data. + +The function opens file storage for reading or writing data. In the latter case, a new file is +created or an existing file is rewritten. The type of the read or written file is determined by the +filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON. + +At the same time, it also supports adding parameters like "example.xml?base64". + +The function returns a pointer to the CvFileStorage structure. +If the file cannot be opened then the function returns NULL. +@param filename Name of the file associated with the storage +@param memstorage Memory storage used for temporary data and for +: storing dynamic structures, such as CvSeq or CvGraph . If it is NULL, a temporary memory + storage is created and used. +@param flags Can be one of the following: +> - **CV_STORAGE_READ** the storage is open for reading +> - **CV_STORAGE_WRITE** the storage is open for writing + (use **CV_STORAGE_WRITE | CV_STORAGE_WRITE_BASE64** to write rawdata in Base64) +@param encoding + */ +CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage, + int flags, const char* encoding CV_DEFAULT(NULL) ); + +/** @brief Releases file storage. + +The function closes the file associated with the storage and releases all the temporary structures. +It must be called after all I/O operations with the storage are finished. +@param fs Double pointer to the released file storage + */ +CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs ); + +/** returns attribute value or 0 (NULL) if there is no such attribute */ +CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name ); + +/** @brief Starts writing a new structure. + +The function starts writing a compound structure (collection) that can be a sequence or a map. After +all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should +be called. The function can be used to group some objects or to implement the write function for a +some user object (see CvTypeInfo). +@param fs File storage +@param name Name of the written structure. The structure can be accessed by this name when the +storage is read. +@param struct_flags A combination one of the following values: +- **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ), + that is, its elements do not have a name. +- **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that + is, all its elements have names. +One and only one of the two above flags must be specified +- **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that + the structure is written as a flow (not as a block), which is more compact. It is + recommended to use this flag for structures or arrays whose elements are all scalars. +@param type_name Optional parameter - the object type name. In + case of XML it is written as a type_id attribute of the structure opening tag. In the case of + YAML it is written after a colon following the structure name (see the example in + CvFileStorage description). In case of JSON it is written as a name/value pair. + Mainly it is used with user objects. When the storage is read, the + encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ). +@param attributes This parameter is not used in the current implementation + */ +CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name, + int struct_flags, const char* type_name CV_DEFAULT(NULL), + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/** @brief Finishes writing to a file node collection. +@param fs File storage +@sa cvStartWriteStruct. + */ +CVAPI(void) cvEndWriteStruct( CvFileStorage* fs ); + +/** @brief Writes an integer value. + +The function writes a single integer value (with or without a name) to the file storage. +@param fs File storage +@param name Name of the written value. Should be NULL if and only if the parent structure is a +sequence. +@param value The written value + */ +CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value ); + +/** @brief Writes a floating-point value. + +The function writes a single floating-point value (with or without a name) to file storage. Special +values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf. + +The following example shows how to use the low-level writing functions to store custom structures, +such as termination criteria, without registering a new type. : +@code + void write_termcriteria( CvFileStorage* fs, const char* struct_name, + CvTermCriteria* termcrit ) + { + cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0)); + cvWriteComment( fs, "termination criteria", 1 ); // just a description + if( termcrit->type & CV_TERMCRIT_ITER ) + cvWriteInteger( fs, "max_iterations", termcrit->max_iter ); + if( termcrit->type & CV_TERMCRIT_EPS ) + cvWriteReal( fs, "accuracy", termcrit->epsilon ); + cvEndWriteStruct( fs ); + } +@endcode +@param fs File storage +@param name Name of the written value. Should be NULL if and only if the parent structure is a +sequence. +@param value The written value +*/ +CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value ); + +/** @brief Writes a text string. + +The function writes a text string to file storage. +@param fs File storage +@param name Name of the written string . Should be NULL if and only if the parent structure is a +sequence. +@param str The written text string +@param quote If non-zero, the written string is put in quotes, regardless of whether they are +required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when +the string starts with a digit or contains spaces). + */ +CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name, + const char* str, int quote CV_DEFAULT(0) ); + +/** @brief Writes a comment. + +The function writes a comment into file storage. The comments are skipped when the storage is read. +@param fs File storage +@param comment The written comment, single-line or multi-line +@param eol_comment If non-zero, the function tries to put the comment at the end of current line. +If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current +line, the comment starts a new line. + */ +CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment, + int eol_comment ); + +/** @brief Writes an object to file storage. + +The function writes an object to file storage. First, the appropriate type info is found using +cvTypeOf. Then, the write method associated with the type info is called. + +Attributes are used to customize the writing procedure. The standard types support the following +attributes (all the dt attributes have the same format as in cvWriteRawData): + +-# CvSeq + - **header_dt** description of user fields of the sequence header that follow CvSeq, or + CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or + point sequence) + - **dt** description of the sequence elements. + - **recursive** if the attribute is present and is not equal to "0" or "false", the whole + tree of sequences (contours) is stored. +-# CvGraph + - **header_dt** description of user fields of the graph header that follows CvGraph; + - **vertex_dt** description of user fields of graph vertices + - **edge_dt** description of user fields of graph edges (note that the edge weight is + always written, so there is no need to specify it explicitly) + +Below is the code that creates the YAML file shown in the CvFileStorage description: +@code + #include "cxcore.h" + + int main( int argc, char** argv ) + { + CvMat* mat = cvCreateMat( 3, 3, CV_32F ); + CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE ); + + cvSetIdentity( mat ); + cvWrite( fs, "A", mat, cvAttrList(0,0) ); + + cvReleaseFileStorage( &fs ); + cvReleaseMat( &mat ); + return 0; + } +@endcode +@param fs File storage +@param name Name of the written object. Should be NULL if and only if the parent structure is a +sequence. +@param ptr Pointer to the object +@param attributes The attributes of the object. They are specific for each particular type (see +the discussion below). + */ +CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr, + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/** @brief Starts the next stream. + +The function finishes the currently written stream and starts the next stream. In the case of XML +the file with multiple streams looks like this: +@code{.xml} + + + + + + + ... +@endcode +The YAML file will look like this: +@code{.yaml} + %YAML 1.0 + # stream #1 data + ... + --- + # stream #2 data +@endcode +This is useful for concatenating files or for resuming the writing process. +@param fs File storage + */ +CVAPI(void) cvStartNextStream( CvFileStorage* fs ); + +/** @brief Writes multiple numbers. + +The function writes an array, whose elements consist of single or multiple numbers. The function +call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single +call is more efficient. Note that because none of the elements have a name, they should be written +to a sequence rather than a map. +@param fs File storage +@param src Pointer to the written array +@param len Number of the array elements to write +@param dt Specification of each array element, see @ref format_spec "format specification" + */ +CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src, + int len, const char* dt ); + +/** @brief Writes multiple numbers in Base64. + +If either CV_STORAGE_WRITE_BASE64 or cv::FileStorage::WRITE_BASE64 is used, +this function will be the same as cvWriteRawData. If neither, the main +difference is that it outputs a sequence in Base64 encoding rather than +in plain text. + +This function can only be used to write a sequence with a type "binary". + +@param fs File storage +@param src Pointer to the written array +@param len Number of the array elements to write +@param dt Specification of each array element, see @ref format_spec "format specification" +*/ +CVAPI(void) cvWriteRawDataBase64( CvFileStorage* fs, const void* src, + int len, const char* dt ); + +/** @brief Returns a unique pointer for a given name. + +The function returns a unique pointer for each particular file node name. This pointer can be then +passed to the cvGetFileNode function that is faster than cvGetFileNodeByName because it compares +text strings by comparing pointers rather than the strings' content. + +Consider the following example where an array of points is encoded as a sequence of 2-entry maps: +@code + points: + - { x: 10, y: 10 } + - { x: 20, y: 20 } + - { x: 30, y: 30 } + # ... +@endcode +Then, it is possible to get hashed "x" and "y" pointers to speed up decoding of the points. : +@code + #include "cxcore.h" + + int main( int argc, char** argv ) + { + CvFileStorage* fs = cvOpenFileStorage( "points.yml", 0, CV_STORAGE_READ ); + CvStringHashNode* x_key = cvGetHashedNode( fs, "x", -1, 1 ); + CvStringHashNode* y_key = cvGetHashedNode( fs, "y", -1, 1 ); + CvFileNode* points = cvGetFileNodeByName( fs, 0, "points" ); + + if( CV_NODE_IS_SEQ(points->tag) ) + { + CvSeq* seq = points->data.seq; + int i, total = seq->total; + CvSeqReader reader; + cvStartReadSeq( seq, &reader, 0 ); + for( i = 0; i < total; i++ ) + { + CvFileNode* pt = (CvFileNode*)reader.ptr; + #if 1 // faster variant + CvFileNode* xnode = cvGetFileNode( fs, pt, x_key, 0 ); + CvFileNode* ynode = cvGetFileNode( fs, pt, y_key, 0 ); + assert( xnode && CV_NODE_IS_INT(xnode->tag) && + ynode && CV_NODE_IS_INT(ynode->tag)); + int x = xnode->data.i; // or x = cvReadInt( xnode, 0 ); + int y = ynode->data.i; // or y = cvReadInt( ynode, 0 ); + #elif 1 // slower variant; does not use x_key & y_key + CvFileNode* xnode = cvGetFileNodeByName( fs, pt, "x" ); + CvFileNode* ynode = cvGetFileNodeByName( fs, pt, "y" ); + assert( xnode && CV_NODE_IS_INT(xnode->tag) && + ynode && CV_NODE_IS_INT(ynode->tag)); + int x = xnode->data.i; // or x = cvReadInt( xnode, 0 ); + int y = ynode->data.i; // or y = cvReadInt( ynode, 0 ); + #else // the slowest yet the easiest to use variant + int x = cvReadIntByName( fs, pt, "x", 0 ); + int y = cvReadIntByName( fs, pt, "y", 0 ); + #endif + CV_NEXT_SEQ_ELEM( seq->elem_size, reader ); + printf(" + } + } + cvReleaseFileStorage( &fs ); + return 0; + } +@endcode +Please note that whatever method of accessing a map you are using, it is still much slower than +using plain sequences; for example, in the above example, it is more efficient to encode the points +as pairs of integers in a single numeric sequence. +@param fs File storage +@param name Literal node name +@param len Length of the name (if it is known apriori), or -1 if it needs to be calculated +@param create_missing Flag that specifies, whether an absent key should be added into the hash table +*/ +CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name, + int len CV_DEFAULT(-1), + int create_missing CV_DEFAULT(0)); + +/** @brief Retrieves one of the top-level nodes of the file storage. + +The function returns one of the top-level file nodes. The top-level nodes do not have a name, they +correspond to the streams that are stored one after another in the file storage. If the index is out +of range, the function returns a NULL pointer, so all the top-level nodes can be iterated by +subsequent calls to the function with stream_index=0,1,..., until the NULL pointer is returned. +This function can be used as a base for recursive traversal of the file storage. +@param fs File storage +@param stream_index Zero-based index of the stream. See cvStartNextStream . In most cases, +there is only one stream in the file; however, there can be several. + */ +CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs, + int stream_index CV_DEFAULT(0) ); + +/** @brief Finds a node in a map or file storage. + +The function finds a file node. It is a faster version of cvGetFileNodeByName (see +cvGetHashedKey discussion). Also, the function can insert a new node, if it is not in the map yet. +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. If both map and +key are NULLs, the function returns the root file node - a map that contains top-level nodes. +@param key Unique pointer to the node name, retrieved with cvGetHashedKey +@param create_missing Flag that specifies whether an absent node should be added to the map + */ +CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map, + const CvStringHashNode* key, + int create_missing CV_DEFAULT(0) ); + +/** @brief Finds a node in a map or file storage. + +The function finds a file node by name. The node is searched either in map or, if the pointer is +NULL, among the top-level file storage nodes. Using this function for maps and cvGetSeqElem (or +sequence reader) for sequences, it is possible to navigate through the file storage. To speed up +multiple queries for a certain key (e.g., in the case of an array of structures) one may use a +combination of cvGetHashedKey and cvGetFileNode. +@param fs File storage +@param map The parent map. If it is NULL, the function searches in all the top-level nodes +(streams), starting with the first one. +@param name The file node name + */ +CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs, + const CvFileNode* map, + const char* name ); + +/** @brief Retrieves an integer value from a file node. + +The function returns an integer that is represented by the file node. If the file node is NULL, the +default_value is returned (thus, it is convenient to call the function right after cvGetFileNode +without checking for a NULL pointer). If the file node has type CV_NODE_INT, then node-\>data.i is +returned. If the file node has type CV_NODE_REAL, then node-\>data.f is converted to an integer +and returned. Otherwise the error is reported. +@param node File node +@param default_value The value that is returned if node is NULL + */ +CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? node->data.i : + CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff; +} + +/** @brief Finds a file node and returns its value. + +The function is a simple superposition of cvGetFileNodeByName and cvReadInt. +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param default_value The value that is returned if the file node is not found + */ +CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, int default_value CV_DEFAULT(0) ) +{ + return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value ); +} + +/** @brief Retrieves a floating-point value from a file node. + +The function returns a floating-point value that is represented by the file node. If the file node +is NULL, the default_value is returned (thus, it is convenient to call the function right after +cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_REAL , +then node-\>data.f is returned. If the file node has type CV_NODE_INT , then node-:math:\>data.f +is converted to floating-point and returned. Otherwise the result is not determined. +@param node File node +@param default_value The value that is returned if node is NULL + */ +CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? (double)node->data.i : + CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300; +} + +/** @brief Finds a file node and returns its value. + +The function is a simple superposition of cvGetFileNodeByName and cvReadReal . +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param default_value The value that is returned if the file node is not found + */ +CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, double default_value CV_DEFAULT(0.) ) +{ + return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value ); +} + +/** @brief Retrieves a text string from a file node. + +The function returns a text string that is represented by the file node. If the file node is NULL, +the default_value is returned (thus, it is convenient to call the function right after +cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_STR , then +node-:math:\>data.str.ptr is returned. Otherwise the result is not determined. +@param node File node +@param default_value The value that is returned if node is NULL + */ +CV_INLINE const char* cvReadString( const CvFileNode* node, + const char* default_value CV_DEFAULT(NULL) ) +{ + return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0; +} + +/** @brief Finds a file node by its name and returns its value. + +The function is a simple superposition of cvGetFileNodeByName and cvReadString . +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param default_value The value that is returned if the file node is not found + */ +CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, const char* default_value CV_DEFAULT(NULL) ) +{ + return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +/** @brief Decodes an object and returns a pointer to it. + +The function decodes a user object (creates an object in a native representation from the file +storage subtree) and returns it. The object to be decoded must be an instance of a registered type +that supports the read method (see CvTypeInfo). The type of the object is determined by the type +name that is encoded in the file. If the object is a dynamic structure, it is created either in +memory storage and passed to cvOpenFileStorage or, if a NULL pointer was passed, in temporary +memory storage, which is released when cvReleaseFileStorage is called. Otherwise, if the object is +not a dynamic structure, it is created in a heap and should be released with a specialized function +or by using the generic cvRelease. +@param fs File storage +@param node The root object node +@param attributes Unused parameter + */ +CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node, + CvAttrList* attributes CV_DEFAULT(NULL)); + +/** @brief Finds an object by name and decodes it. + +The function is a simple superposition of cvGetFileNodeByName and cvRead. +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param attributes Unused parameter + */ +CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map, + const char* name, CvAttrList* attributes CV_DEFAULT(NULL) ) +{ + return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes ); +} + + +/** @brief Initializes the file node sequence reader. + +The function initializes the sequence reader to read data from a file node. The initialized reader +can be then passed to cvReadRawDataSlice. +@param fs File storage +@param src The file node (a sequence) to read numbers from +@param reader Pointer to the sequence reader + */ +CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, + CvSeqReader* reader ); + +/** @brief Initializes file node sequence reader. + +The function reads one or more elements from the file node, representing a sequence, to a +user-specified array. The total number of read sequence elements is a product of total and the +number of components in each array element. For example, if dt=2if, the function will read total\*3 +sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read +repeatedly by repositioning the reader using cvSetSeqReaderPos. +@param fs File storage +@param reader The sequence reader. Initialize it with cvStartReadRawData . +@param count The number of elements to read +@param dst Pointer to the destination array +@param dt Specification of each array element. It has the same format as in cvWriteRawData . + */ +CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, + int count, void* dst, const char* dt ); + +/** @brief Reads multiple numbers. + +The function reads elements from a file node that represents a sequence of scalars. +@param fs File storage +@param src The file node (a sequence) to read numbers from +@param dst Pointer to the destination array +@param dt Specification of each array element. It has the same format as in cvWriteRawData . + */ +CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, + void* dst, const char* dt ); + +/** @brief Writes a file node to another file storage. + +The function writes a copy of a file node to file storage. Possible applications of the function are +merging several file storages into one and conversion between XML, YAML and JSON formats. +@param fs Destination file storage +@param new_node_name New name of the file node in the destination file storage. To keep the +existing name, use cvcvGetFileNodeName +@param node The written node +@param embed If the written node is a collection and this parameter is not zero, no extra level of +hierarchy is created. Instead, all the elements of node are written into the currently written +structure. Of course, map elements can only be embedded into another map, and sequence elements +can only be embedded into another sequence. + */ +CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, + const CvFileNode* node, int embed ); + +/** @brief Returns the name of a file node. + +The function returns the name of a file node or NULL, if the file node does not have a name or if +node is NULL. +@param node File node + */ +CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node ); + +/*********************************** Adding own types ***********************************/ + +/** @brief Registers a new type. + +The function registers a new type, which is described by info . The function creates a copy of the +structure, so the user should delete it after calling the function. +@param info Type info structure + */ +CVAPI(void) cvRegisterType( const CvTypeInfo* info ); + +/** @brief Unregisters the type. + +The function unregisters a type with a specified name. If the name is unknown, it is possible to +locate the type info by an instance of the type using cvTypeOf or by iterating the type list, +starting from cvFirstType, and then calling cvUnregisterType(info-\>typeName). +@param type_name Name of an unregistered type + */ +CVAPI(void) cvUnregisterType( const char* type_name ); + +/** @brief Returns the beginning of a type list. + +The function returns the first type in the list of registered types. Navigation through the list can +be done via the prev and next fields of the CvTypeInfo structure. + */ +CVAPI(CvTypeInfo*) cvFirstType(void); + +/** @brief Finds a type by its name. + +The function finds a registered type by its name. It returns NULL if there is no type with the +specified name. +@param type_name Type name + */ +CVAPI(CvTypeInfo*) cvFindType( const char* type_name ); + +/** @brief Returns the type of an object. + +The function finds the type of a given object. It iterates through the list of registered types and +calls the is_instance function/method for every type info structure with that object until one of +them returns non-zero or until the whole list has been traversed. In the latter case, the function +returns NULL. +@param struct_ptr The object pointer + */ +CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr ); + +#endif + +/** @brief Releases an object. + + The function finds the type of a given object and calls release with the double pointer. + @param struct_ptr Double pointer to the object + */ +CVAPI(void) cvRelease( void** struct_ptr ); + +/** @brief Makes a clone of an object. + +The function finds the type of a given object and calls clone with the passed object. Of course, if +you know the object type, for example, struct_ptr is CvMat\*, it is faster to call the specific +function, like cvCloneMat. +@param struct_ptr The object to clone + */ +CVAPI(void*) cvClone( const void* struct_ptr ); + +/*********************************** Measuring Execution Time ***************************/ + +/** helper functions for RNG initialization and accurate time measurement: + uses internal clock counter on x86 */ +CVAPI(int64) cvGetTickCount( void ); +CVAPI(double) cvGetTickFrequency( void ); + +/*********************************** CPU capabilities ***********************************/ + +CVAPI(int) cvCheckHardwareSupport(int feature); + +/*********************************** Multi-Threading ************************************/ + +/** retrieve/set the number of threads used in OpenMP implementations */ +CVAPI(int) cvGetNumThreads( void ); +CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) ); +/** get index of the thread being executed */ +CVAPI(int) cvGetThreadNum( void ); + + +/********************************** Error Handling **************************************/ + +/** Get current OpenCV error status */ +CVAPI(int) cvGetErrStatus( void ); + +/** Sets error status silently */ +CVAPI(void) cvSetErrStatus( int status ); + +#define CV_ErrModeLeaf 0 /* Print error and exit program */ +#define CV_ErrModeParent 1 /* Print error and continue */ +#define CV_ErrModeSilent 2 /* Don't print and continue */ + +/** Retrieves current error processing mode */ +CVAPI(int) cvGetErrMode( void ); + +/** Sets error processing mode, returns previously used mode */ +CVAPI(int) cvSetErrMode( int mode ); + +/** Sets error status and performs some additional actions (displaying message box, + writing message to stderr, terminating application etc.) + depending on the current error mode */ +CVAPI(void) cvError( int status, const char* func_name, + const char* err_msg, const char* file_name, int line ); + +/** Retrieves textual description of the error given its code */ +CVAPI(const char*) cvErrorStr( int status ); + +/** Retrieves detailed information about the last error occurred */ +CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, + const char** filename, int* line ); + +/** Maps IPP error codes to the counterparts from OpenCV */ +CVAPI(int) cvErrorFromIppStatus( int ipp_status ); + +typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, int line, void* userdata ); + +/** Assigns a new error-handling function */ +CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, + void* userdata CV_DEFAULT(NULL), + void** prev_userdata CV_DEFAULT(NULL) ); + +/** Output nothing */ +CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +/** Output to console(fprintf(stderr,...)) */ +CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +/** Output to MessageBox(WIN32) */ +CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +#define OPENCV_ERROR(status,func,context) \ +cvError((status),(func),(context),__FILE__,__LINE__) + +#define OPENCV_ASSERT(expr,func,context) \ +{if (! (expr)) \ +{OPENCV_ERROR(CV_StsInternal,(func),(context));}} + +#define OPENCV_CALL( Func ) \ +{ \ +Func; \ +} + + +/** CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */ +#ifdef CV_NO_FUNC_NAMES +#define CV_FUNCNAME( Name ) +#define cvFuncName "" +#else +#define CV_FUNCNAME( Name ) \ +static char cvFuncName[] = Name +#endif + + +/** + CV_ERROR macro unconditionally raises error with passed code and message. + After raising error, control will be transferred to the exit label. + */ +#define CV_ERROR( Code, Msg ) \ +{ \ + cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \ + __CV_EXIT__; \ +} + +/** + CV_CHECK macro checks error status after CV (or IPL) + function call. If error detected, control will be transferred to the exit + label. + */ +#define CV_CHECK() \ +{ \ + if( cvGetErrStatus() < 0 ) \ + CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ +} + + +/** + CV_CALL macro calls CV (or IPL) function, checks error status and + signals a error if the function failed. Useful in "parent node" + error processing mode + */ +#define CV_CALL( Func ) \ +{ \ + Func; \ + CV_CHECK(); \ +} + + +/** Runtime assertion macro */ +#define CV_ASSERT( Condition ) \ +{ \ + if( !(Condition) ) \ + CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \ +} + +#define __CV_BEGIN__ { +#define __CV_END__ goto exit; exit: ; } +#define __CV_EXIT__ goto exit + +/** @} core_c */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#ifdef __cplusplus + +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @addtogroup core_c_glue +//! @{ + +/////////////////////////////////////////// glue /////////////////////////////////////////// + +//! converts array (CvMat or IplImage) to cv::Mat +CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, + bool allowND=true, int coiMode=0, + AutoBuffer* buf=0); + +static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) +{ + return cvarrToMat(arr, copyData, true, coiMode); +} + + +//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. +CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); +//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage +CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); + + + +////// specialized implementations of DefaultDeleter::operator() for classic OpenCV types ////// + +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvMat* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(IplImage* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvMatND* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvSparseMat* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvMemStorage* obj) const; }; + +////////////// convenient wrappers for operating old-style dynamic structures ////////////// + +template class SeqIterator; + +typedef Ptr MemStorage; + +/*! + Template Sequence Class derived from CvSeq + + The class provides more convenient access to sequence elements, + STL-style operations and iterators. + + \note The class is targeted for simple data types, + i.e. no constructors or destructors + are called for the sequence elements. +*/ +template class Seq +{ +public: + typedef SeqIterator<_Tp> iterator; + typedef SeqIterator<_Tp> const_iterator; + + //! the default constructor + Seq(); + //! the constructor for wrapping CvSeq structure. The real element type in CvSeq should match _Tp. + Seq(const CvSeq* seq); + //! creates the empty sequence that resides in the specified storage + Seq(MemStorage& storage, int headerSize = sizeof(CvSeq)); + //! returns read-write reference to the specified element + _Tp& operator [](int idx); + //! returns read-only reference to the specified element + const _Tp& operator[](int idx) const; + //! returns iterator pointing to the beginning of the sequence + SeqIterator<_Tp> begin() const; + //! returns iterator pointing to the element following the last sequence element + SeqIterator<_Tp> end() const; + //! returns the number of elements in the sequence + size_t size() const; + //! returns the type of sequence elements (CV_8UC1 ... CV_64FC(CV_CN_MAX) ...) + int type() const; + //! returns the depth of sequence elements (CV_8U ... CV_64F) + int depth() const; + //! returns the number of channels in each sequence element + int channels() const; + //! returns the size of each sequence element + size_t elemSize() const; + //! returns index of the specified sequence element + size_t index(const _Tp& elem) const; + //! appends the specified element to the end of the sequence + void push_back(const _Tp& elem); + //! appends the specified element to the front of the sequence + void push_front(const _Tp& elem); + //! appends zero or more elements to the end of the sequence + void push_back(const _Tp* elems, size_t count); + //! appends zero or more elements to the front of the sequence + void push_front(const _Tp* elems, size_t count); + //! inserts the specified element to the specified position + void insert(int idx, const _Tp& elem); + //! inserts zero or more elements to the specified position + void insert(int idx, const _Tp* elems, size_t count); + //! removes element at the specified position + void remove(int idx); + //! removes the specified subsequence + void remove(const Range& r); + + //! returns reference to the first sequence element + _Tp& front(); + //! returns read-only reference to the first sequence element + const _Tp& front() const; + //! returns reference to the last sequence element + _Tp& back(); + //! returns read-only reference to the last sequence element + const _Tp& back() const; + //! returns true iff the sequence contains no elements + bool empty() const; + + //! removes all the elements from the sequence + void clear(); + //! removes the first element from the sequence + void pop_front(); + //! removes the last element from the sequence + void pop_back(); + //! removes zero or more elements from the beginning of the sequence + void pop_front(_Tp* elems, size_t count); + //! removes zero or more elements from the end of the sequence + void pop_back(_Tp* elems, size_t count); + + //! copies the whole sequence or the sequence slice to the specified vector + void copyTo(std::vector<_Tp>& vec, const Range& range=Range::all()) const; + //! returns the vector containing all the sequence elements + operator std::vector<_Tp>() const; + + CvSeq* seq; +}; + + +/*! + STL-style Sequence Iterator inherited from the CvSeqReader structure +*/ +template class SeqIterator : public CvSeqReader +{ +public: + //! the default constructor + SeqIterator(); + //! the constructor setting the iterator to the beginning or to the end of the sequence + SeqIterator(const Seq<_Tp>& seq, bool seekEnd=false); + //! positions the iterator within the sequence + void seek(size_t pos); + //! reports the current iterator position + size_t tell() const; + //! returns reference to the current sequence element + _Tp& operator *(); + //! returns read-only reference to the current sequence element + const _Tp& operator *() const; + //! moves iterator to the next sequence element + SeqIterator& operator ++(); + //! moves iterator to the next sequence element + SeqIterator operator ++(int) const; + //! moves iterator to the previous sequence element + SeqIterator& operator --(); + //! moves iterator to the previous sequence element + SeqIterator operator --(int) const; + + //! moves iterator forward by the specified offset (possibly negative) + SeqIterator& operator +=(int); + //! moves iterator backward by the specified offset (possibly negative) + SeqIterator& operator -=(int); + + // this is index of the current element module seq->total*2 + // (to distinguish between 0 and seq->total) + int index; +}; + + + +// bridge C++ => C Seq API +CV_EXPORTS schar* seqPush( CvSeq* seq, const void* element=0); +CV_EXPORTS schar* seqPushFront( CvSeq* seq, const void* element=0); +CV_EXPORTS void seqPop( CvSeq* seq, void* element=0); +CV_EXPORTS void seqPopFront( CvSeq* seq, void* element=0); +CV_EXPORTS void seqPopMulti( CvSeq* seq, void* elements, + int count, int in_front=0 ); +CV_EXPORTS void seqRemove( CvSeq* seq, int index ); +CV_EXPORTS void clearSeq( CvSeq* seq ); +CV_EXPORTS schar* getSeqElem( const CvSeq* seq, int index ); +CV_EXPORTS void seqRemoveSlice( CvSeq* seq, CvSlice slice ); +CV_EXPORTS void seqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); + +template inline Seq<_Tp>::Seq() : seq(0) {} +template inline Seq<_Tp>::Seq( const CvSeq* _seq ) : seq((CvSeq*)_seq) +{ + CV_Assert(!_seq || _seq->elem_size == sizeof(_Tp)); +} + +template inline Seq<_Tp>::Seq( MemStorage& storage, + int headerSize ) +{ + CV_Assert(headerSize >= (int)sizeof(CvSeq)); + seq = cvCreateSeq(DataType<_Tp>::type, headerSize, sizeof(_Tp), storage); +} + +template inline _Tp& Seq<_Tp>::operator [](int idx) +{ return *(_Tp*)getSeqElem(seq, idx); } + +template inline const _Tp& Seq<_Tp>::operator [](int idx) const +{ return *(_Tp*)getSeqElem(seq, idx); } + +template inline SeqIterator<_Tp> Seq<_Tp>::begin() const +{ return SeqIterator<_Tp>(*this); } + +template inline SeqIterator<_Tp> Seq<_Tp>::end() const +{ return SeqIterator<_Tp>(*this, true); } + +template inline size_t Seq<_Tp>::size() const +{ return seq ? seq->total : 0; } + +template inline int Seq<_Tp>::type() const +{ return seq ? CV_MAT_TYPE(seq->flags) : 0; } + +template inline int Seq<_Tp>::depth() const +{ return seq ? CV_MAT_DEPTH(seq->flags) : 0; } + +template inline int Seq<_Tp>::channels() const +{ return seq ? CV_MAT_CN(seq->flags) : 0; } + +template inline size_t Seq<_Tp>::elemSize() const +{ return seq ? seq->elem_size : 0; } + +template inline size_t Seq<_Tp>::index(const _Tp& elem) const +{ return cvSeqElemIdx(seq, &elem); } + +template inline void Seq<_Tp>::push_back(const _Tp& elem) +{ cvSeqPush(seq, &elem); } + +template inline void Seq<_Tp>::push_front(const _Tp& elem) +{ cvSeqPushFront(seq, &elem); } + +template inline void Seq<_Tp>::push_back(const _Tp* elem, size_t count) +{ cvSeqPushMulti(seq, elem, (int)count, 0); } + +template inline void Seq<_Tp>::push_front(const _Tp* elem, size_t count) +{ cvSeqPushMulti(seq, elem, (int)count, 1); } + +template inline _Tp& Seq<_Tp>::back() +{ return *(_Tp*)getSeqElem(seq, -1); } + +template inline const _Tp& Seq<_Tp>::back() const +{ return *(const _Tp*)getSeqElem(seq, -1); } + +template inline _Tp& Seq<_Tp>::front() +{ return *(_Tp*)getSeqElem(seq, 0); } + +template inline const _Tp& Seq<_Tp>::front() const +{ return *(const _Tp*)getSeqElem(seq, 0); } + +template inline bool Seq<_Tp>::empty() const +{ return !seq || seq->total == 0; } + +template inline void Seq<_Tp>::clear() +{ if(seq) clearSeq(seq); } + +template inline void Seq<_Tp>::pop_back() +{ seqPop(seq); } + +template inline void Seq<_Tp>::pop_front() +{ seqPopFront(seq); } + +template inline void Seq<_Tp>::pop_back(_Tp* elem, size_t count) +{ seqPopMulti(seq, elem, (int)count, 0); } + +template inline void Seq<_Tp>::pop_front(_Tp* elem, size_t count) +{ seqPopMulti(seq, elem, (int)count, 1); } + +template inline void Seq<_Tp>::insert(int idx, const _Tp& elem) +{ seqInsert(seq, idx, &elem); } + +template inline void Seq<_Tp>::insert(int idx, const _Tp* elems, size_t count) +{ + CvMat m = cvMat(1, count, DataType<_Tp>::type, elems); + seqInsertSlice(seq, idx, &m); +} + +template inline void Seq<_Tp>::remove(int idx) +{ seqRemove(seq, idx); } + +template inline void Seq<_Tp>::remove(const Range& r) +{ seqRemoveSlice(seq, cvSlice(r.start, r.end)); } + +template inline void Seq<_Tp>::copyTo(std::vector<_Tp>& vec, const Range& range) const +{ + size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start; + vec.resize(len); + if( seq && len ) + cvCvtSeqToArray(seq, &vec[0], cvSlice(range)); +} + +template inline Seq<_Tp>::operator std::vector<_Tp>() const +{ + std::vector<_Tp> vec; + copyTo(vec); + return vec; +} + +template inline SeqIterator<_Tp>::SeqIterator() +{ memset(this, 0, sizeof(*this)); } + +template inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& _seq, bool seekEnd) +{ + cvStartReadSeq(_seq.seq, this); + index = seekEnd ? _seq.seq->total : 0; +} + +template inline void SeqIterator<_Tp>::seek(size_t pos) +{ + cvSetSeqReaderPos(this, (int)pos, false); + index = pos; +} + +template inline size_t SeqIterator<_Tp>::tell() const +{ return index; } + +template inline _Tp& SeqIterator<_Tp>::operator *() +{ return *(_Tp*)ptr; } + +template inline const _Tp& SeqIterator<_Tp>::operator *() const +{ return *(const _Tp*)ptr; } + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator ++() +{ + CV_NEXT_SEQ_ELEM(sizeof(_Tp), *this); + if( ++index >= seq->total*2 ) + index = 0; + return *this; +} + +template inline SeqIterator<_Tp> SeqIterator<_Tp>::operator ++(int) const +{ + SeqIterator<_Tp> it = *this; + ++*this; + return it; +} + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator --() +{ + CV_PREV_SEQ_ELEM(sizeof(_Tp), *this); + if( --index < 0 ) + index = seq->total*2-1; + return *this; +} + +template inline SeqIterator<_Tp> SeqIterator<_Tp>::operator --(int) const +{ + SeqIterator<_Tp> it = *this; + --*this; + return it; +} + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator +=(int delta) +{ + cvSetSeqReaderPos(this, delta, 1); + index += delta; + int n = seq->total*2; + if( index < 0 ) + index += n; + if( index >= n ) + index -= n; + return *this; +} + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator -=(int delta) +{ + return (*this += -delta); +} + +template inline ptrdiff_t operator - (const SeqIterator<_Tp>& a, + const SeqIterator<_Tp>& b) +{ + ptrdiff_t delta = a.index - b.index, n = a.seq->total; + if( delta > n || delta < -n ) + delta += delta < 0 ? n : -n; + return delta; +} + +template inline bool operator == (const SeqIterator<_Tp>& a, + const SeqIterator<_Tp>& b) +{ + return a.seq == b.seq && a.index == b.index; +} + +template inline bool operator != (const SeqIterator<_Tp>& a, + const SeqIterator<_Tp>& b) +{ + return !(a == b); +} + +//! @} + +} // cv + +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda.hpp new file mode 100644 index 0000000..716b8bf --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda.hpp @@ -0,0 +1,1270 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDA_HPP +#define OPENCV_CORE_CUDA_HPP + +#ifndef __cplusplus +# error cuda.hpp header must be compiled as C++ +#endif + +#include "opencv2/core.hpp" +#include "opencv2/core/cuda_types.hpp" + +/** + @defgroup cuda CUDA-accelerated Computer Vision + @{ + @defgroup cudacore Core part + @{ + @defgroup cudacore_init Initialization and Information + @defgroup cudacore_struct Data Structures + @} + @} + */ + +namespace cv { namespace cuda { + +//! @addtogroup cudacore_struct +//! @{ + +//=================================================================================== +// GpuMat +//=================================================================================== + +/** @brief Base storage class for GPU memory with reference counting. + +Its interface matches the Mat interface with the following limitations: + +- no arbitrary dimensions support (only 2D) +- no functions that return references to their data (because references on GPU are not valid for + CPU) +- no expression templates technique support + +Beware that the latter limitation may lead to overloaded matrix operators that cause memory +allocations. The GpuMat class is convertible to cuda::PtrStepSz and cuda::PtrStep so it can be +passed directly to the kernel. + +@note In contrast with Mat, in most cases GpuMat::isContinuous() == false . This means that rows are +aligned to a size depending on the hardware. Single-row GpuMat is always a continuous matrix. + +@note You are not recommended to leave static or global GpuMat variables allocated, that is, to rely +on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory +release function returns error if the CUDA context has been destroyed before. + +Some member functions are described as a "Blocking Call" while some are described as a +"Non-Blocking Call". Blocking functions are synchronous to host. It is guaranteed that the GPU +operation is finished when the function returns. However, non-blocking functions are asynchronous to +host. Those functions may return even if the GPU operation is not finished. + +Compared to their blocking counterpart, non-blocking functions accept Stream as an additional +argument. If a non-default stream is passed, the GPU operation may overlap with operations in other +streams. + +@sa Mat + */ +class CV_EXPORTS_W GpuMat +{ +public: + class CV_EXPORTS_W Allocator + { + public: + virtual ~Allocator() {} + + // allocator must fill data, step and refcount fields + virtual bool allocate(GpuMat* mat, int rows, int cols, size_t elemSize) = 0; + virtual void free(GpuMat* mat) = 0; + }; + + //! default allocator + CV_WRAP static GpuMat::Allocator* defaultAllocator(); + CV_WRAP static void setDefaultAllocator(GpuMat::Allocator* allocator); + + //! default constructor + CV_WRAP explicit GpuMat(GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! constructs GpuMat of the specified size and type + CV_WRAP GpuMat(int rows, int cols, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! constructs GpuMat and fills it with the specified value _s + CV_WRAP GpuMat(int rows, int cols, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! copy constructor + CV_WRAP GpuMat(const GpuMat& m); + + //! constructor for GpuMat headers pointing to user-allocated data + GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP); + GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP); + + //! creates a GpuMat header for a part of the bigger matrix + CV_WRAP GpuMat(const GpuMat& m, Range rowRange, Range colRange); + CV_WRAP GpuMat(const GpuMat& m, Rect roi); + + //! builds GpuMat from host memory (Blocking call) + CV_WRAP explicit GpuMat(InputArray arr, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! destructor - calls release() + ~GpuMat(); + + //! assignment operators + GpuMat& operator =(const GpuMat& m); + + //! allocates new GpuMat data unless the GpuMat already has specified size and type + CV_WRAP void create(int rows, int cols, int type); + CV_WRAP void create(Size size, int type); + + //! decreases reference counter, deallocate the data when reference counter reaches 0 + void release(); + + //! swaps with other smart pointer + CV_WRAP void swap(GpuMat& mat); + + /** @brief Performs data upload to GpuMat (Blocking call) + + This function copies data from host memory to device memory. As being a blocking call, it is + guaranteed that the copy operation is finished when this function returns. + */ + CV_WRAP void upload(InputArray arr); + + /** @brief Performs data upload to GpuMat (Non-Blocking call) + + This function copies data from host memory to device memory. As being a non-blocking call, this + function may return even if the copy operation is not finished. + + The copy operation may be overlapped with operations in other non-default streams if \p stream is + not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. + */ + CV_WRAP void upload(InputArray arr, Stream& stream); + + /** @brief Performs data download from GpuMat (Blocking call) + + This function copies data from device memory to host memory. As being a blocking call, it is + guaranteed that the copy operation is finished when this function returns. + */ + CV_WRAP void download(OutputArray dst) const; + + /** @brief Performs data download from GpuMat (Non-Blocking call) + + This function copies data from device memory to host memory. As being a non-blocking call, this + function may return even if the copy operation is not finished. + + The copy operation may be overlapped with operations in other non-default streams if \p stream is + not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. + */ + CV_WRAP void download(OutputArray dst, Stream& stream) const; + + //! returns deep copy of the GpuMat, i.e. the data is copied + CV_WRAP GpuMat clone() const; + + //! copies the GpuMat content to device memory (Blocking call) + CV_WRAP void copyTo(OutputArray dst) const; + + //! copies the GpuMat content to device memory (Non-Blocking call) + CV_WRAP void copyTo(OutputArray dst, Stream& stream) const; + + //! copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call) + CV_WRAP void copyTo(OutputArray dst, InputArray mask) const; + + //! copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call) + CV_WRAP void copyTo(OutputArray dst, InputArray mask, Stream& stream) const; + + //! sets some of the GpuMat elements to s (Blocking call) + CV_WRAP GpuMat& setTo(Scalar s); + + //! sets some of the GpuMat elements to s (Non-Blocking call) + CV_WRAP GpuMat& setTo(Scalar s, Stream& stream); + + //! sets some of the GpuMat elements to s, according to the mask (Blocking call) + CV_WRAP GpuMat& setTo(Scalar s, InputArray mask); + + //! sets some of the GpuMat elements to s, according to the mask (Non-Blocking call) + CV_WRAP GpuMat& setTo(Scalar s, InputArray mask, Stream& stream); + + //! converts GpuMat to another datatype (Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype) const; + + //! converts GpuMat to another datatype (Non-Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, Stream& stream) const; + + //! converts GpuMat to another datatype with scaling (Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const; + + //! converts GpuMat to another datatype with scaling (Non-Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const; + + //! converts GpuMat to another datatype with scaling (Non-Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta, Stream& stream) const; + + CV_WRAP void assignTo(GpuMat& m, int type = -1) const; + + //! returns pointer to y-th row + uchar* ptr(int y = 0); + const uchar* ptr(int y = 0) const; + + //! template version of the above method + template _Tp* ptr(int y = 0); + template const _Tp* ptr(int y = 0) const; + + template operator PtrStepSz<_Tp>() const; + template operator PtrStep<_Tp>() const; + + //! returns a new GpuMat header for the specified row + CV_WRAP GpuMat row(int y) const; + + //! returns a new GpuMat header for the specified column + CV_WRAP GpuMat col(int x) const; + + //! ... for the specified row span + CV_WRAP GpuMat rowRange(int startrow, int endrow) const; + CV_WRAP GpuMat rowRange(Range r) const; + + //! ... for the specified column span + CV_WRAP GpuMat colRange(int startcol, int endcol) const; + CV_WRAP GpuMat colRange(Range r) const; + + //! extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.) + GpuMat operator ()(Range rowRange, Range colRange) const; + GpuMat operator ()(Rect roi) const; + + //! creates alternative GpuMat header for the same data, with different + //! number of channels and/or different number of rows + CV_WRAP GpuMat reshape(int cn, int rows = 0) const; + + //! locates GpuMat header within a parent GpuMat + CV_WRAP void locateROI(Size& wholeSize, Point& ofs) const; + + //! moves/resizes the current GpuMat ROI inside the parent GpuMat + CV_WRAP GpuMat& adjustROI(int dtop, int dbottom, int dleft, int dright); + + //! returns true iff the GpuMat data is continuous + //! (i.e. when there are no gaps between successive rows) + CV_WRAP bool isContinuous() const; + + //! returns element size in bytes + CV_WRAP size_t elemSize() const; + + //! returns the size of element channel in bytes + CV_WRAP size_t elemSize1() const; + + //! returns element type + CV_WRAP int type() const; + + //! returns element type + CV_WRAP int depth() const; + + //! returns number of channels + CV_WRAP int channels() const; + + //! returns step/elemSize1() + CV_WRAP size_t step1() const; + + //! returns GpuMat size : width == number of columns, height == number of rows + CV_WRAP Size size() const; + + //! returns true if GpuMat data is NULL + CV_WRAP bool empty() const; + + // returns pointer to cuda memory + CV_WRAP void* cudaPtr() const; + + //! internal use method: updates the continuity flag + CV_WRAP void updateContinuityFlag(); + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + + //! the number of rows and columns + int rows, cols; + + //! a distance between successive rows in bytes; includes the gap if any + CV_PROP size_t step; + + //! pointer to the data + uchar* data; + + //! pointer to the reference counter; + //! when GpuMat points to user-allocated data, the pointer is NULL + int* refcount; + + //! helper fields used in locateROI and adjustROI + uchar* datastart; + const uchar* dataend; + + //! allocator + Allocator* allocator; +}; + +struct CV_EXPORTS_W GpuData +{ + explicit GpuData(size_t _size); + ~GpuData(); + + GpuData(const GpuData&) = delete; + GpuData& operator=(const GpuData&) = delete; + + GpuData(GpuData&&) = delete; + GpuData& operator=(GpuData&&) = delete; + + uchar* data; + size_t size; +}; + +class CV_EXPORTS_W GpuMatND +{ +public: + using SizeArray = std::vector; + using StepArray = std::vector; + using IndexArray = std::vector; + + //! destructor + ~GpuMatND(); + + //! default constructor + GpuMatND(); + + /** @overload + @param size Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + GpuMatND(SizeArray size, int type); + + /** @overload + @param size Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param step Array of _size.size()-1 steps in case of a multi-dimensional array (the last step is always + set to the element size). If not specified, the matrix is assumed to be continuous. + */ + GpuMatND(SizeArray size, int type, void* data, StepArray step = StepArray()); + + /** @brief Allocates GPU memory. + Suppose there is some GPU memory already allocated. In that case, this method may choose to reuse that + GPU memory under the specific condition: it must be of the same size and type, not externally allocated, + the GPU memory is continuous(i.e., isContinuous() is true), and is not a sub-matrix of another GpuMatND + (i.e., isSubmatrix() is false). In other words, this method guarantees that the GPU memory allocated by + this method is always continuous and is not a sub-region of another GpuMatND. + */ + void create(SizeArray size, int type); + + void release(); + + void swap(GpuMatND& m) noexcept; + + /** @brief Creates a full copy of the array and the underlying data. + The method creates a full copy of the array. It mimics the behavior of Mat::clone(), i.e. + the original step is not taken into account. So, the array copy is a continuous array + occupying total()\*elemSize() bytes. + */ + GpuMatND clone() const; + + /** @overload + This overload is non-blocking, so it may return even if the copy operation is not finished. + */ + GpuMatND clone(Stream& stream) const; + + /** @brief Extracts a sub-matrix. + The operator makes a new header for the specified sub-array of \*this. + The operator is an O(1) operation, that is, no matrix data is copied. + @param ranges Array of selected ranges along each dimension. + */ + GpuMatND operator()(const std::vector& ranges) const; + + /** @brief Creates a GpuMat header for a 2D plane part of an n-dim matrix. + @note The returned GpuMat is constructed with the constructor for user-allocated data. + That is, It does not perform reference counting. + @note This function does not increment this GpuMatND's reference counter. + */ + GpuMat createGpuMatHeader(IndexArray idx, Range rowRange, Range colRange) const; + + /** @overload + Creates a GpuMat header if this GpuMatND is effectively 2D. + @note The returned GpuMat is constructed with the constructor for user-allocated data. + That is, It does not perform reference counting. + @note This function does not increment this GpuMatND's reference counter. + */ + GpuMat createGpuMatHeader() const; + + /** @brief Extracts a 2D plane part of an n-dim matrix. + It differs from createGpuMatHeader(IndexArray, Range, Range) in that it clones a part of this + GpuMatND to the returned GpuMat. + @note This operator does not increment this GpuMatND's reference counter; + */ + GpuMat operator()(IndexArray idx, Range rowRange, Range colRange) const; + + /** @brief Extracts a 2D plane part of an n-dim matrix if this GpuMatND is effectively 2D. + It differs from createGpuMatHeader() in that it clones a part of this GpuMatND. + @note This operator does not increment this GpuMatND's reference counter; + */ + operator GpuMat() const; + + GpuMatND(const GpuMatND&) = default; + GpuMatND& operator=(const GpuMatND&) = default; + +#if defined(__GNUC__) && __GNUC__ < 5 + // error: function '...' defaulted on its first declaration with an exception-specification + // that differs from the implicit declaration '...' + + GpuMatND(GpuMatND&&) = default; + GpuMatND& operator=(GpuMatND&&) = default; +#else + GpuMatND(GpuMatND&&) noexcept = default; + GpuMatND& operator=(GpuMatND&&) noexcept = default; +#endif + + void upload(InputArray src); + void upload(InputArray src, Stream& stream); + void download(OutputArray dst) const; + void download(OutputArray dst, Stream& stream) const; + + //! returns true iff the GpuMatND data is continuous + //! (i.e. when there are no gaps between successive rows) + bool isContinuous() const; + + //! returns true if the matrix is a sub-matrix of another matrix + bool isSubmatrix() const; + + //! returns element size in bytes + size_t elemSize() const; + + //! returns the size of element channel in bytes + size_t elemSize1() const; + + //! returns true if data is null + bool empty() const; + + //! returns true if not empty and points to external(user-allocated) gpu memory + bool external() const; + + //! returns pointer to the first byte of the GPU memory + uchar* getDevicePtr() const; + + //! returns the total number of array elements + size_t total() const; + + //! returns the size of underlying memory in bytes + size_t totalMemSize() const; + + //! returns element type + int type() const; + +private: + //! internal use + void setFields(SizeArray size, int type, StepArray step = StepArray()); + +public: + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + + //! matrix dimensionality + int dims; + + //! shape of this array + SizeArray size; + + /*! step values + Their semantics is identical to the semantics of step for Mat. + */ + StepArray step; + +private: + /*! internal use + If this GpuMatND holds external memory, this is empty. + */ + std::shared_ptr data_; + + /*! internal use + If this GpuMatND manages memory with reference counting, this value is + always equal to data_->data. If this GpuMatND holds external memory, + data_ is empty and data points to the external memory. + */ + uchar* data; + + /*! internal use + If this GpuMatND is a sub-matrix of a larger matrix, this value is the + difference of the first byte between the sub-matrix and the whole matrix. + */ + size_t offset; +}; + +/** @brief Creates a continuous matrix. + +@param rows Row count. +@param cols Column count. +@param type Type of the matrix. +@param arr Destination matrix. This parameter changes only if it has a proper type and area ( +\f$\texttt{rows} \times \texttt{cols}\f$ ). + +Matrix is called continuous if its elements are stored continuously, that is, without gaps at the +end of each row. + */ +CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr); + +/** @brief Ensures that the size of a matrix is big enough and the matrix has a proper type. + +@param rows Minimum desired number of rows. +@param cols Minimum desired number of columns. +@param type Desired matrix type. +@param arr Destination matrix. + +The function does not reallocate memory if the matrix has proper attributes already. + */ +CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr); + +/** @brief BufferPool for use with CUDA streams + +BufferPool utilizes Stream's allocator to create new buffers for GpuMat's. It is +only useful when enabled with #setBufferPoolUsage. + +@code + setBufferPoolUsage(true); +@endcode + +@note #setBufferPoolUsage must be called \em before any Stream declaration. + +Users may specify custom allocator for Stream and may implement their own stream based +functions utilizing the same underlying GPU memory management. + +If custom allocator is not specified, BufferPool utilizes StackAllocator by +default. StackAllocator allocates a chunk of GPU device memory beforehand, +and when GpuMat is declared later on, it is given the pre-allocated memory. +This kind of strategy reduces the number of calls for memory allocating APIs +such as cudaMalloc or cudaMallocPitch. + +Below is an example that utilizes BufferPool with StackAllocator: + +@code + #include + + using namespace cv; + using namespace cv::cuda + + int main() + { + setBufferPoolUsage(true); // Tell OpenCV that we are going to utilize BufferPool + setBufferPoolConfig(getDevice(), 1024 * 1024 * 64, 2); // Allocate 64 MB, 2 stacks (default is 10 MB, 5 stacks) + + Stream stream1, stream2; // Each stream uses 1 stack + BufferPool pool1(stream1), pool2(stream2); + + GpuMat d_src1 = pool1.getBuffer(4096, 4096, CV_8UC1); // 16MB + GpuMat d_dst1 = pool1.getBuffer(4096, 4096, CV_8UC3); // 48MB, pool1 is now full + + GpuMat d_src2 = pool2.getBuffer(1024, 1024, CV_8UC1); // 1MB + GpuMat d_dst2 = pool2.getBuffer(1024, 1024, CV_8UC3); // 3MB + + cvtColor(d_src1, d_dst1, CV_GRAY2BGR, 0, stream1); + cvtColor(d_src2, d_dst2, CV_GRAY2BGR, 0, stream2); + } +@endcode + +If we allocate another GpuMat on pool1 in the above example, it will be carried out by +the DefaultAllocator since the stack for pool1 is full. + +@code + GpuMat d_add1 = pool1.getBuffer(1024, 1024, CV_8UC1); // Stack for pool1 is full, memory is allocated with DefaultAllocator +@endcode + +If a third stream is declared in the above example, allocating with #getBuffer +within that stream will also be carried out by the DefaultAllocator because we've run out of +stacks. + +@code + Stream stream3; // Only 2 stacks were allocated, we've run out of stacks + BufferPool pool3(stream3); + GpuMat d_src3 = pool3.getBuffer(1024, 1024, CV_8UC1); // Memory is allocated with DefaultAllocator +@endcode + +@warning When utilizing StackAllocator, deallocation order is important. + +Just like a stack, deallocation must be done in LIFO order. Below is an example of +erroneous usage that violates LIFO rule. If OpenCV is compiled in Debug mode, this +sample code will emit CV_Assert error. + +@code + int main() + { + setBufferPoolUsage(true); // Tell OpenCV that we are going to utilize BufferPool + Stream stream; // A default size (10 MB) stack is allocated to this stream + BufferPool pool(stream); + + GpuMat mat1 = pool.getBuffer(1024, 1024, CV_8UC1); // Allocate mat1 (1MB) + GpuMat mat2 = pool.getBuffer(1024, 1024, CV_8UC1); // Allocate mat2 (1MB) + + mat1.release(); // erroneous usage : mat2 must be deallocated before mat1 + } +@endcode + +Since C++ local variables are destroyed in the reverse order of construction, +the code sample below satisfies the LIFO rule. Local GpuMat's are deallocated +and the corresponding memory is automatically returned to the pool for later usage. + +@code + int main() + { + setBufferPoolUsage(true); // Tell OpenCV that we are going to utilize BufferPool + setBufferPoolConfig(getDevice(), 1024 * 1024 * 64, 2); // Allocate 64 MB, 2 stacks (default is 10 MB, 5 stacks) + + Stream stream1, stream2; // Each stream uses 1 stack + BufferPool pool1(stream1), pool2(stream2); + + for (int i = 0; i < 10; i++) + { + GpuMat d_src1 = pool1.getBuffer(4096, 4096, CV_8UC1); // 16MB + GpuMat d_dst1 = pool1.getBuffer(4096, 4096, CV_8UC3); // 48MB, pool1 is now full + + GpuMat d_src2 = pool2.getBuffer(1024, 1024, CV_8UC1); // 1MB + GpuMat d_dst2 = pool2.getBuffer(1024, 1024, CV_8UC3); // 3MB + + d_src1.setTo(Scalar(i), stream1); + d_src2.setTo(Scalar(i), stream2); + + cvtColor(d_src1, d_dst1, CV_GRAY2BGR, 0, stream1); + cvtColor(d_src2, d_dst2, CV_GRAY2BGR, 0, stream2); + // The order of destruction of the local variables is: + // d_dst2 => d_src2 => d_dst1 => d_src1 + // LIFO rule is satisfied, this code runs without error + } + } +@endcode + */ +class CV_EXPORTS_W BufferPool +{ +public: + + //! Gets the BufferPool for the given stream. + explicit BufferPool(Stream& stream); + + //! Allocates a new GpuMat of given size and type. + CV_WRAP GpuMat getBuffer(int rows, int cols, int type); + + //! Allocates a new GpuMat of given size and type. + CV_WRAP GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); } + + //! Returns the allocator associated with the stream. + CV_WRAP Ptr getAllocator() const { return allocator_; } + +private: + Ptr allocator_; +}; + +//! BufferPool management (must be called before Stream creation) +CV_EXPORTS_W void setBufferPoolUsage(bool on); +CV_EXPORTS_W void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount); + +//=================================================================================== +// HostMem +//=================================================================================== + +/** @brief Class with reference counting wrapping special memory type allocation functions from CUDA. + +Its interface is also Mat-like but with additional memory type parameters. + +- **PAGE_LOCKED** sets a page locked memory type used commonly for fast and asynchronous + uploading/downloading data from/to GPU. +- **SHARED** specifies a zero copy memory allocation that enables mapping the host memory to GPU + address space, if supported. +- **WRITE_COMBINED** sets the write combined buffer that is not cached by CPU. Such buffers are + used to supply GPU with data when GPU only reads it. The advantage is a better CPU cache + utilization. + +@note Allocation size of such memory types is usually limited. For more details, see *CUDA 2.2 +Pinned Memory APIs* document or *CUDA C Programming Guide*. + */ +class CV_EXPORTS_W HostMem +{ +public: + enum AllocType { PAGE_LOCKED = 1, SHARED = 2, WRITE_COMBINED = 4 }; + + static MatAllocator* getAllocator(HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + CV_WRAP explicit HostMem(HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + HostMem(const HostMem& m); + + CV_WRAP HostMem(int rows, int cols, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + CV_WRAP HostMem(Size size, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + //! creates from host memory with coping data + CV_WRAP explicit HostMem(InputArray arr, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + ~HostMem(); + + HostMem& operator =(const HostMem& m); + + //! swaps with other smart pointer + CV_WRAP void swap(HostMem& b); + + //! returns deep copy of the matrix, i.e. the data is copied + CV_WRAP HostMem clone() const; + + //! allocates new matrix data unless the matrix already has specified size and type. + CV_WRAP void create(int rows, int cols, int type); + void create(Size size, int type); + + //! creates alternative HostMem header for the same data, with different + //! number of channels and/or different number of rows + CV_WRAP HostMem reshape(int cn, int rows = 0) const; + + //! decrements reference counter and released memory if needed. + void release(); + + //! returns matrix header with disabled reference counting for HostMem data. + CV_WRAP Mat createMatHeader() const; + + /** @brief Maps CPU memory to GPU address space and creates the cuda::GpuMat header without reference counting + for it. + + This can be done only if memory was allocated with the SHARED flag and if it is supported by the + hardware. Laptops often share video and CPU memory, so address spaces can be mapped, which + eliminates an extra copy. + */ + GpuMat createGpuMatHeader() const; + + // Please see cv::Mat for descriptions + CV_WRAP bool isContinuous() const; + CV_WRAP size_t elemSize() const; + CV_WRAP size_t elemSize1() const; + CV_WRAP int type() const; + CV_WRAP int depth() const; + CV_WRAP int channels() const; + CV_WRAP size_t step1() const; + CV_WRAP Size size() const; + CV_WRAP bool empty() const; + + // Please see cv::Mat for descriptions + int flags; + int rows, cols; + CV_PROP size_t step; + + uchar* data; + int* refcount; + + uchar* datastart; + const uchar* dataend; + + AllocType alloc_type; +}; + +/** @brief Page-locks the memory of matrix and maps it for the device(s). + +@param m Input matrix. + */ +CV_EXPORTS_W void registerPageLocked(Mat& m); + +/** @brief Unmaps the memory of matrix and makes it pageable again. + +@param m Input matrix. + */ +CV_EXPORTS_W void unregisterPageLocked(Mat& m); + +//=================================================================================== +// Stream +//=================================================================================== + +/** @brief This class encapsulates a queue of asynchronous calls. + +@note Currently, you may face problems if an operation is enqueued twice with different data. Some +functions use the constant GPU memory, and next call may update the memory before the previous one +has been finished. But calling different operations asynchronously is safe because each operation +has its own constant buffer. Memory copy/upload/download/set operations to the buffers you hold are +also safe. + +@note The Stream class is not thread-safe. Please use different Stream objects for different CPU threads. + +@code +void thread1() +{ + cv::cuda::Stream stream1; + cv::cuda::func1(..., stream1); +} + +void thread2() +{ + cv::cuda::Stream stream2; + cv::cuda::func2(..., stream2); +} +@endcode + +@note By default all CUDA routines are launched in Stream::Null() object, if the stream is not specified by user. +In multi-threading environment the stream objects must be passed explicitly (see previous note). + */ +class CV_EXPORTS_W Stream +{ + typedef void (Stream::*bool_type)() const; + void this_type_does_not_support_comparisons() const {} + +public: + typedef void (*StreamCallback)(int status, void* userData); + + //! creates a new asynchronous stream + CV_WRAP Stream(); + + //! creates a new asynchronous stream with custom allocator + CV_WRAP Stream(const Ptr& allocator); + + /** @brief creates a new Stream using the cudaFlags argument to determine the behaviors of the stream + + @note The cudaFlags parameter is passed to the underlying api cudaStreamCreateWithFlags() and + supports the same parameter values. + @code + // creates an OpenCV cuda::Stream that manages an asynchronous, non-blocking, + // non-default CUDA stream + cv::cuda::Stream cvStream(cudaStreamNonBlocking); + @endcode + */ + CV_WRAP Stream(const size_t cudaFlags); + + /** @brief Returns true if the current stream queue is finished. Otherwise, it returns false. + */ + CV_WRAP bool queryIfComplete() const; + + /** @brief Blocks the current CPU thread until all operations in the stream are complete. + */ + CV_WRAP void waitForCompletion(); + + /** @brief Makes a compute stream wait on an event. + */ + CV_WRAP void waitEvent(const Event& event); + + /** @brief Adds a callback to be called on the host after all currently enqueued items in the stream have + completed. + + @note Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization + that may depend on outstanding device work or other callbacks that are not mandated to run earlier. + Callbacks without a mandated order (in independent streams) execute in undefined order and may be + serialized. + */ + void enqueueHostCallback(StreamCallback callback, void* userData); + + //! return Stream object for default CUDA stream + CV_WRAP static Stream& Null(); + + //! returns true if stream object is not default (!= 0) + operator bool_type() const; + + //! return Pointer to CUDA stream + CV_WRAP void* cudaPtr() const; + + class Impl; + +private: + Ptr impl_; + Stream(const Ptr& impl); + + friend struct StreamAccessor; + friend class BufferPool; + friend class DefaultDeviceInitializer; +}; + +class CV_EXPORTS_W Event +{ +public: + enum CreateFlags + { + DEFAULT = 0x00, /**< Default event flag */ + BLOCKING_SYNC = 0x01, /**< Event uses blocking synchronization */ + DISABLE_TIMING = 0x02, /**< Event will not record timing data */ + INTERPROCESS = 0x04 /**< Event is suitable for interprocess use. DisableTiming must be set */ + }; + + CV_WRAP explicit Event(Event::CreateFlags flags = Event::CreateFlags::DEFAULT); + + //! records an event + CV_WRAP void record(Stream& stream = Stream::Null()); + + //! queries an event's status + CV_WRAP bool queryIfComplete() const; + + //! waits for an event to complete + CV_WRAP void waitForCompletion(); + + //! computes the elapsed time between events + CV_WRAP static float elapsedTime(const Event& start, const Event& end); + + class Impl; + +private: + Ptr impl_; + Event(const Ptr& impl); + + friend struct EventAccessor; +}; + +//! @} cudacore_struct + +//=================================================================================== +// Initialization & Info +//=================================================================================== + +//! @addtogroup cudacore_init +//! @{ + +/** @brief Returns the number of installed CUDA-enabled devices. + +Use this function before any other CUDA functions calls. If OpenCV is compiled without CUDA support, +this function returns 0. If the CUDA driver is not installed, or is incompatible, this function +returns -1. + */ +CV_EXPORTS_W int getCudaEnabledDeviceCount(); + +/** @brief Sets a device and initializes it for the current thread. + +@param device System index of a CUDA device starting with 0. + +If the call of this function is omitted, a default device is initialized at the fist CUDA usage. + */ +CV_EXPORTS_W void setDevice(int device); + +/** @brief Returns the current device index set by cuda::setDevice or initialized by default. + */ +CV_EXPORTS_W int getDevice(); + +/** @brief Explicitly destroys and cleans up all resources associated with the current device in the current +process. + +Any subsequent API call to this device will reinitialize the device. + */ +CV_EXPORTS_W void resetDevice(); + +/** @brief Enumeration providing CUDA computing features. + */ +enum FeatureSet +{ + FEATURE_SET_COMPUTE_10 = 10, + FEATURE_SET_COMPUTE_11 = 11, + FEATURE_SET_COMPUTE_12 = 12, + FEATURE_SET_COMPUTE_13 = 13, + FEATURE_SET_COMPUTE_20 = 20, + FEATURE_SET_COMPUTE_21 = 21, + FEATURE_SET_COMPUTE_30 = 30, + FEATURE_SET_COMPUTE_32 = 32, + FEATURE_SET_COMPUTE_35 = 35, + FEATURE_SET_COMPUTE_50 = 50, + + GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11, + SHARED_ATOMICS = FEATURE_SET_COMPUTE_12, + NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13, + WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30, + DYNAMIC_PARALLELISM = FEATURE_SET_COMPUTE_35 +}; + +//! checks whether current device supports the given feature +CV_EXPORTS bool deviceSupports(FeatureSet feature_set); + +/** @brief Class providing a set of static methods to check what NVIDIA\* card architecture the CUDA module was +built for. + +According to the CUDA C Programming Guide Version 3.2: "PTX code produced for some specific compute +capability can always be compiled to binary code of greater or equal compute capability". + */ +class CV_EXPORTS_W TargetArchs +{ +public: + /** @brief The following method checks whether the module was built with the support of the given feature: + + @param feature_set Features to be checked. See :ocvcuda::FeatureSet. + */ + static bool builtWith(FeatureSet feature_set); + + /** @brief There is a set of methods to check whether the module contains intermediate (PTX) or binary CUDA + code for the given architecture(s): + + @param major Major compute capability version. + @param minor Minor compute capability version. + */ + CV_WRAP static bool has(int major, int minor); + CV_WRAP static bool hasPtx(int major, int minor); + CV_WRAP static bool hasBin(int major, int minor); + + CV_WRAP static bool hasEqualOrLessPtx(int major, int minor); + CV_WRAP static bool hasEqualOrGreater(int major, int minor); + CV_WRAP static bool hasEqualOrGreaterPtx(int major, int minor); + CV_WRAP static bool hasEqualOrGreaterBin(int major, int minor); +}; + +/** @brief Class providing functionality for querying the specified GPU properties. + */ +class CV_EXPORTS_W DeviceInfo +{ +public: + //! creates DeviceInfo object for the current GPU + CV_WRAP DeviceInfo(); + + /** @brief The constructors. + + @param device_id System index of the CUDA device starting with 0. + + Constructs the DeviceInfo object for the specified device. If device_id parameter is missed, it + constructs an object for the current device. + */ + CV_WRAP DeviceInfo(int device_id); + + /** @brief Returns system index of the CUDA device starting with 0. + */ + CV_WRAP int deviceID() const; + + //! ASCII string identifying device + const char* name() const; + + //! global memory available on device in bytes + CV_WRAP size_t totalGlobalMem() const; + + //! shared memory available per block in bytes + CV_WRAP size_t sharedMemPerBlock() const; + + //! 32-bit registers available per block + CV_WRAP int regsPerBlock() const; + + //! warp size in threads + CV_WRAP int warpSize() const; + + //! maximum pitch in bytes allowed by memory copies + CV_WRAP size_t memPitch() const; + + //! maximum number of threads per block + CV_WRAP int maxThreadsPerBlock() const; + + //! maximum size of each dimension of a block + CV_WRAP Vec3i maxThreadsDim() const; + + //! maximum size of each dimension of a grid + CV_WRAP Vec3i maxGridSize() const; + + //! clock frequency in kilohertz + CV_WRAP int clockRate() const; + + //! constant memory available on device in bytes + CV_WRAP size_t totalConstMem() const; + + //! major compute capability + CV_WRAP int majorVersion() const; + + //! minor compute capability + CV_WRAP int minorVersion() const; + + //! alignment requirement for textures + CV_WRAP size_t textureAlignment() const; + + //! pitch alignment requirement for texture references bound to pitched memory + CV_WRAP size_t texturePitchAlignment() const; + + //! number of multiprocessors on device + CV_WRAP int multiProcessorCount() const; + + //! specified whether there is a run time limit on kernels + CV_WRAP bool kernelExecTimeoutEnabled() const; + + //! device is integrated as opposed to discrete + CV_WRAP bool integrated() const; + + //! device can map host memory with cudaHostAlloc/cudaHostGetDevicePointer + CV_WRAP bool canMapHostMemory() const; + + enum ComputeMode + { + ComputeModeDefault, /**< default compute mode (Multiple threads can use cudaSetDevice with this device) */ + ComputeModeExclusive, /**< compute-exclusive-thread mode (Only one thread in one process will be able to use cudaSetDevice with this device) */ + ComputeModeProhibited, /**< compute-prohibited mode (No threads can use cudaSetDevice with this device) */ + ComputeModeExclusiveProcess /**< compute-exclusive-process mode (Many threads in one process will be able to use cudaSetDevice with this device) */ + }; + + //! compute mode + CV_WRAP DeviceInfo::ComputeMode computeMode() const; + + //! maximum 1D texture size + CV_WRAP int maxTexture1D() const; + + //! maximum 1D mipmapped texture size + CV_WRAP int maxTexture1DMipmap() const; + + //! maximum size for 1D textures bound to linear memory + CV_WRAP int maxTexture1DLinear() const; + + //! maximum 2D texture dimensions + CV_WRAP Vec2i maxTexture2D() const; + + //! maximum 2D mipmapped texture dimensions + CV_WRAP Vec2i maxTexture2DMipmap() const; + + //! maximum dimensions (width, height, pitch) for 2D textures bound to pitched memory + CV_WRAP Vec3i maxTexture2DLinear() const; + + //! maximum 2D texture dimensions if texture gather operations have to be performed + CV_WRAP Vec2i maxTexture2DGather() const; + + //! maximum 3D texture dimensions + CV_WRAP Vec3i maxTexture3D() const; + + //! maximum Cubemap texture dimensions + CV_WRAP int maxTextureCubemap() const; + + //! maximum 1D layered texture dimensions + CV_WRAP Vec2i maxTexture1DLayered() const; + + //! maximum 2D layered texture dimensions + CV_WRAP Vec3i maxTexture2DLayered() const; + + //! maximum Cubemap layered texture dimensions + CV_WRAP Vec2i maxTextureCubemapLayered() const; + + //! maximum 1D surface size + CV_WRAP int maxSurface1D() const; + + //! maximum 2D surface dimensions + CV_WRAP Vec2i maxSurface2D() const; + + //! maximum 3D surface dimensions + CV_WRAP Vec3i maxSurface3D() const; + + //! maximum 1D layered surface dimensions + CV_WRAP Vec2i maxSurface1DLayered() const; + + //! maximum 2D layered surface dimensions + CV_WRAP Vec3i maxSurface2DLayered() const; + + //! maximum Cubemap surface dimensions + CV_WRAP int maxSurfaceCubemap() const; + + //! maximum Cubemap layered surface dimensions + CV_WRAP Vec2i maxSurfaceCubemapLayered() const; + + //! alignment requirements for surfaces + CV_WRAP size_t surfaceAlignment() const; + + //! device can possibly execute multiple kernels concurrently + CV_WRAP bool concurrentKernels() const; + + //! device has ECC support enabled + CV_WRAP bool ECCEnabled() const; + + //! PCI bus ID of the device + CV_WRAP int pciBusID() const; + + //! PCI device ID of the device + CV_WRAP int pciDeviceID() const; + + //! PCI domain ID of the device + CV_WRAP int pciDomainID() const; + + //! true if device is a Tesla device using TCC driver, false otherwise + CV_WRAP bool tccDriver() const; + + //! number of asynchronous engines + CV_WRAP int asyncEngineCount() const; + + //! device shares a unified address space with the host + CV_WRAP bool unifiedAddressing() const; + + //! peak memory clock frequency in kilohertz + CV_WRAP int memoryClockRate() const; + + //! global memory bus width in bits + CV_WRAP int memoryBusWidth() const; + + //! size of L2 cache in bytes + CV_WRAP int l2CacheSize() const; + + //! maximum resident threads per multiprocessor + CV_WRAP int maxThreadsPerMultiProcessor() const; + + //! gets free and total device memory + CV_WRAP void queryMemory(size_t& totalMemory, size_t& freeMemory) const; + CV_WRAP size_t freeMemory() const; + CV_WRAP size_t totalMemory() const; + + /** @brief Provides information on CUDA feature support. + + @param feature_set Features to be checked. See cuda::FeatureSet. + + This function returns true if the device has the specified CUDA feature. Otherwise, it returns false + */ + bool supports(FeatureSet feature_set) const; + + /** @brief Checks the CUDA module and device compatibility. + + This function returns true if the CUDA module can be run on the specified device. Otherwise, it + returns false . + */ + CV_WRAP bool isCompatible() const; + +private: + int device_id_; +}; + +CV_EXPORTS_W void printCudaDeviceInfo(int device); +CV_EXPORTS_W void printShortCudaDeviceInfo(int device); + +/** @brief Converts an array to half precision floating number. + +@param _src input array. +@param _dst output array. +@param stream Stream for the asynchronous version. +@sa convertFp16 +*/ +CV_EXPORTS void convertFp16(InputArray _src, OutputArray _dst, Stream& stream = Stream::Null()); + +//! @} cudacore_init + +}} // namespace cv { namespace cuda { + + +#include "opencv2/core/cuda.inl.hpp" + +#endif /* OPENCV_CORE_CUDA_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda.inl.hpp new file mode 100644 index 0000000..3f2a0c7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda.inl.hpp @@ -0,0 +1,723 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDAINL_HPP +#define OPENCV_CORE_CUDAINL_HPP + +#include "opencv2/core/cuda.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { + +//=================================================================================== +// GpuMat +//=================================================================================== + +inline +GpuMat::GpuMat(Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{} + +inline +GpuMat::GpuMat(int rows_, int cols_, int type_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (rows_ > 0 && cols_ > 0) + create(rows_, cols_, type_); +} + +inline +GpuMat::GpuMat(Size size_, int type_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (size_.height > 0 && size_.width > 0) + create(size_.height, size_.width, type_); +} + +inline +GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (rows_ > 0 && cols_ > 0) + { + create(rows_, cols_, type_); + setTo(s_); + } +} + +inline +GpuMat::GpuMat(Size size_, int type_, Scalar s_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (size_.height > 0 && size_.width > 0) + { + create(size_.height, size_.width, type_); + setTo(s_); + } +} + +inline +GpuMat::GpuMat(const GpuMat& m) + : flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), allocator(m.allocator) +{ + if (refcount) + CV_XADD(refcount, 1); +} + +inline +GpuMat::GpuMat(InputArray arr, Allocator* allocator_) : + flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + upload(arr); +} + +inline +GpuMat::~GpuMat() +{ + release(); +} + +inline +GpuMat& GpuMat::operator =(const GpuMat& m) +{ + if (this != &m) + { + GpuMat temp(m); + swap(temp); + } + + return *this; +} + +inline +void GpuMat::create(Size size_, int type_) +{ + create(size_.height, size_.width, type_); +} + +inline +void GpuMat::swap(GpuMat& b) +{ + std::swap(flags, b.flags); + std::swap(rows, b.rows); + std::swap(cols, b.cols); + std::swap(step, b.step); + std::swap(data, b.data); + std::swap(datastart, b.datastart); + std::swap(dataend, b.dataend); + std::swap(refcount, b.refcount); + std::swap(allocator, b.allocator); +} + +inline +GpuMat GpuMat::clone() const +{ + GpuMat m; + copyTo(m); + return m; +} + +inline +void GpuMat::copyTo(OutputArray dst, InputArray mask) const +{ + copyTo(dst, mask, Stream::Null()); +} + +inline +GpuMat& GpuMat::setTo(Scalar s) +{ + return setTo(s, Stream::Null()); +} + +inline +GpuMat& GpuMat::setTo(Scalar s, InputArray mask) +{ + return setTo(s, mask, Stream::Null()); +} + +inline +void GpuMat::convertTo(OutputArray dst, int rtype) const +{ + convertTo(dst, rtype, Stream::Null()); +} + +inline +void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, double beta) const +{ + convertTo(dst, rtype, alpha, beta, Stream::Null()); +} + +inline +void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const +{ + convertTo(dst, rtype, alpha, 0.0, stream); +} + +inline +void GpuMat::assignTo(GpuMat& m, int _type) const +{ + if (_type < 0) + m = *this; + else + convertTo(m, _type); +} + +inline +uchar* GpuMat::ptr(int y) +{ + CV_DbgAssert( (unsigned)y < (unsigned)rows ); + return data + step * y; +} + +inline +const uchar* GpuMat::ptr(int y) const +{ + CV_DbgAssert( (unsigned)y < (unsigned)rows ); + return data + step * y; +} + +template inline +_Tp* GpuMat::ptr(int y) +{ + return (_Tp*)ptr(y); +} + +template inline +const _Tp* GpuMat::ptr(int y) const +{ + return (const _Tp*)ptr(y); +} + +template inline +GpuMat::operator PtrStepSz() const +{ + return PtrStepSz(rows, cols, (T*)data, step); +} + +template inline +GpuMat::operator PtrStep() const +{ + return PtrStep((T*)data, step); +} + +inline +GpuMat GpuMat::row(int y) const +{ + return GpuMat(*this, Range(y, y+1), Range::all()); +} + +inline +GpuMat GpuMat::col(int x) const +{ + return GpuMat(*this, Range::all(), Range(x, x+1)); +} + +inline +GpuMat GpuMat::rowRange(int startrow, int endrow) const +{ + return GpuMat(*this, Range(startrow, endrow), Range::all()); +} + +inline +GpuMat GpuMat::rowRange(Range r) const +{ + return GpuMat(*this, r, Range::all()); +} + +inline +GpuMat GpuMat::colRange(int startcol, int endcol) const +{ + return GpuMat(*this, Range::all(), Range(startcol, endcol)); +} + +inline +GpuMat GpuMat::colRange(Range r) const +{ + return GpuMat(*this, Range::all(), r); +} + +inline +GpuMat GpuMat::operator ()(Range rowRange_, Range colRange_) const +{ + return GpuMat(*this, rowRange_, colRange_); +} + +inline +GpuMat GpuMat::operator ()(Rect roi) const +{ + return GpuMat(*this, roi); +} + +inline +bool GpuMat::isContinuous() const +{ + return (flags & Mat::CONTINUOUS_FLAG) != 0; +} + +inline +size_t GpuMat::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t GpuMat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int GpuMat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int GpuMat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int GpuMat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +size_t GpuMat::step1() const +{ + return step / elemSize1(); +} + +inline +Size GpuMat::size() const +{ + return Size(cols, rows); +} + +inline +bool GpuMat::empty() const +{ + return data == 0; +} + +inline +void* GpuMat::cudaPtr() const +{ + return data; +} + +static inline +GpuMat createContinuous(int rows, int cols, int type) +{ + GpuMat m; + createContinuous(rows, cols, type, m); + return m; +} + +static inline +void createContinuous(Size size, int type, OutputArray arr) +{ + createContinuous(size.height, size.width, type, arr); +} + +static inline +GpuMat createContinuous(Size size, int type) +{ + GpuMat m; + createContinuous(size, type, m); + return m; +} + +static inline +void ensureSizeIsEnough(Size size, int type, OutputArray arr) +{ + ensureSizeIsEnough(size.height, size.width, type, arr); +} + +static inline +void swap(GpuMat& a, GpuMat& b) +{ + a.swap(b); +} + +//=================================================================================== +// GpuMatND +//=================================================================================== + +inline +GpuMatND::GpuMatND() : + flags(0), dims(0), data(nullptr), offset(0) +{ +} + +inline +GpuMatND::GpuMatND(SizeArray _size, int _type) : + flags(0), dims(0), data(nullptr), offset(0) +{ + create(std::move(_size), _type); +} + +inline +void GpuMatND::swap(GpuMatND& m) noexcept +{ + std::swap(*this, m); +} + +inline +bool GpuMatND::isContinuous() const +{ + return (flags & Mat::CONTINUOUS_FLAG) != 0; +} + +inline +bool GpuMatND::isSubmatrix() const +{ + return (flags & Mat::SUBMATRIX_FLAG) != 0; +} + +inline +size_t GpuMatND::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t GpuMatND::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +bool GpuMatND::empty() const +{ + return data == nullptr; +} + +inline +bool GpuMatND::external() const +{ + return !empty() && data_.use_count() == 0; +} + +inline +uchar* GpuMatND::getDevicePtr() const +{ + return data + offset; +} + +inline +size_t GpuMatND::total() const +{ + size_t p = 1; + for(auto s : size) + p *= s; + return p; +} + +inline +size_t GpuMatND::totalMemSize() const +{ + return size[0] * step[0]; +} + +inline +int GpuMatND::type() const +{ + return CV_MAT_TYPE(flags); +} + +//=================================================================================== +// HostMem +//=================================================================================== + +inline +HostMem::HostMem(AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ +} + +inline +HostMem::HostMem(const HostMem& m) + : flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), alloc_type(m.alloc_type) +{ + if( refcount ) + CV_XADD(refcount, 1); +} + +inline +HostMem::HostMem(int rows_, int cols_, int type_, AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ + if (rows_ > 0 && cols_ > 0) + create(rows_, cols_, type_); +} + +inline +HostMem::HostMem(Size size_, int type_, AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ + if (size_.height > 0 && size_.width > 0) + create(size_.height, size_.width, type_); +} + +inline +HostMem::HostMem(InputArray arr, AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ + arr.getMat().copyTo(*this); +} + +inline +HostMem::~HostMem() +{ + release(); +} + +inline +HostMem& HostMem::operator =(const HostMem& m) +{ + if (this != &m) + { + HostMem temp(m); + swap(temp); + } + + return *this; +} + +inline +void HostMem::swap(HostMem& b) +{ + std::swap(flags, b.flags); + std::swap(rows, b.rows); + std::swap(cols, b.cols); + std::swap(step, b.step); + std::swap(data, b.data); + std::swap(datastart, b.datastart); + std::swap(dataend, b.dataend); + std::swap(refcount, b.refcount); + std::swap(alloc_type, b.alloc_type); +} + +inline +HostMem HostMem::clone() const +{ + HostMem m(size(), type(), alloc_type); + createMatHeader().copyTo(m); + return m; +} + +inline +void HostMem::create(Size size_, int type_) +{ + create(size_.height, size_.width, type_); +} + +inline +Mat HostMem::createMatHeader() const +{ + return Mat(size(), type(), data, step); +} + +inline +bool HostMem::isContinuous() const +{ + return (flags & Mat::CONTINUOUS_FLAG) != 0; +} + +inline +size_t HostMem::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t HostMem::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int HostMem::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int HostMem::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int HostMem::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +size_t HostMem::step1() const +{ + return step / elemSize1(); +} + +inline +Size HostMem::size() const +{ + return Size(cols, rows); +} + +inline +bool HostMem::empty() const +{ + return data == 0; +} + +static inline +void swap(HostMem& a, HostMem& b) +{ + a.swap(b); +} + +//=================================================================================== +// Stream +//=================================================================================== + +inline +Stream::Stream(const Ptr& impl) + : impl_(impl) +{ +} + +//=================================================================================== +// Event +//=================================================================================== + +inline +Event::Event(const Ptr& impl) + : impl_(impl) +{ +} + +//=================================================================================== +// Initialization & Info +//=================================================================================== + +inline +bool TargetArchs::has(int major, int minor) +{ + return hasPtx(major, minor) || hasBin(major, minor); +} + +inline +bool TargetArchs::hasEqualOrGreater(int major, int minor) +{ + return hasEqualOrGreaterPtx(major, minor) || hasEqualOrGreaterBin(major, minor); +} + +inline +DeviceInfo::DeviceInfo() +{ + device_id_ = getDevice(); +} + +inline +DeviceInfo::DeviceInfo(int device_id) +{ + CV_Assert( device_id >= 0 && device_id < getCudaEnabledDeviceCount() ); + device_id_ = device_id; +} + +inline +int DeviceInfo::deviceID() const +{ + return device_id_; +} + +inline +size_t DeviceInfo::freeMemory() const +{ + size_t _totalMemory = 0, _freeMemory = 0; + queryMemory(_totalMemory, _freeMemory); + return _freeMemory; +} + +inline +size_t DeviceInfo::totalMemory() const +{ + size_t _totalMemory = 0, _freeMemory = 0; + queryMemory(_totalMemory, _freeMemory); + return _totalMemory; +} + +inline +bool DeviceInfo::supports(FeatureSet feature_set) const +{ + int version = majorVersion() * 10 + minorVersion(); + return version >= feature_set; +} + + +}} // namespace cv { namespace cuda { + +//=================================================================================== +// Mat +//=================================================================================== + +namespace cv { + +inline +Mat::Mat(const cuda::GpuMat& m) + : flags(0), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) +{ + m.download(*this); +} + +} + +//! @endcond + +#endif // OPENCV_CORE_CUDAINL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/block.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/block.hpp new file mode 100644 index 0000000..c277f0e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/block.hpp @@ -0,0 +1,211 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DEVICE_BLOCK_HPP +#define OPENCV_CUDA_DEVICE_BLOCK_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct Block + { + static __device__ __forceinline__ unsigned int id() + { + return blockIdx.x; + } + + static __device__ __forceinline__ unsigned int stride() + { + return blockDim.x * blockDim.y * blockDim.z; + } + + static __device__ __forceinline__ void sync() + { + __syncthreads(); + } + + static __device__ __forceinline__ int flattenedThreadId() + { + return threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x; + } + + template + static __device__ __forceinline__ void fill(It beg, It end, const T& value) + { + int STRIDE = stride(); + It t = beg + flattenedThreadId(); + + for(; t < end; t += STRIDE) + *t = value; + } + + template + static __device__ __forceinline__ void yota(OutIt beg, OutIt end, T value) + { + int STRIDE = stride(); + int tid = flattenedThreadId(); + value += tid; + + for(OutIt t = beg + tid; t < end; t += STRIDE, value += STRIDE) + *t = value; + } + + template + static __device__ __forceinline__ void copy(InIt beg, InIt end, OutIt out) + { + int STRIDE = stride(); + InIt t = beg + flattenedThreadId(); + OutIt o = out + (t - beg); + + for(; t < end; t += STRIDE, o += STRIDE) + *o = *t; + } + + template + static __device__ __forceinline__ void transform(InIt beg, InIt end, OutIt out, UnOp op) + { + int STRIDE = stride(); + InIt t = beg + flattenedThreadId(); + OutIt o = out + (t - beg); + + for(; t < end; t += STRIDE, o += STRIDE) + *o = op(*t); + } + + template + static __device__ __forceinline__ void transform(InIt1 beg1, InIt1 end1, InIt2 beg2, OutIt out, BinOp op) + { + int STRIDE = stride(); + InIt1 t1 = beg1 + flattenedThreadId(); + InIt2 t2 = beg2 + flattenedThreadId(); + OutIt o = out + (t1 - beg1); + + for(; t1 < end1; t1 += STRIDE, t2 += STRIDE, o += STRIDE) + *o = op(*t1, *t2); + } + + template + static __device__ __forceinline__ void reduce(volatile T* buffer, BinOp op) + { + int tid = flattenedThreadId(); + T val = buffer[tid]; + + if (CTA_SIZE >= 1024) { if (tid < 512) buffer[tid] = val = op(val, buffer[tid + 512]); __syncthreads(); } + if (CTA_SIZE >= 512) { if (tid < 256) buffer[tid] = val = op(val, buffer[tid + 256]); __syncthreads(); } + if (CTA_SIZE >= 256) { if (tid < 128) buffer[tid] = val = op(val, buffer[tid + 128]); __syncthreads(); } + if (CTA_SIZE >= 128) { if (tid < 64) buffer[tid] = val = op(val, buffer[tid + 64]); __syncthreads(); } + + if (tid < 32) + { + if (CTA_SIZE >= 64) { buffer[tid] = val = op(val, buffer[tid + 32]); } + if (CTA_SIZE >= 32) { buffer[tid] = val = op(val, buffer[tid + 16]); } + if (CTA_SIZE >= 16) { buffer[tid] = val = op(val, buffer[tid + 8]); } + if (CTA_SIZE >= 8) { buffer[tid] = val = op(val, buffer[tid + 4]); } + if (CTA_SIZE >= 4) { buffer[tid] = val = op(val, buffer[tid + 2]); } + if (CTA_SIZE >= 2) { buffer[tid] = val = op(val, buffer[tid + 1]); } + } + } + + template + static __device__ __forceinline__ T reduce(volatile T* buffer, T init, BinOp op) + { + int tid = flattenedThreadId(); + T val = buffer[tid] = init; + __syncthreads(); + + if (CTA_SIZE >= 1024) { if (tid < 512) buffer[tid] = val = op(val, buffer[tid + 512]); __syncthreads(); } + if (CTA_SIZE >= 512) { if (tid < 256) buffer[tid] = val = op(val, buffer[tid + 256]); __syncthreads(); } + if (CTA_SIZE >= 256) { if (tid < 128) buffer[tid] = val = op(val, buffer[tid + 128]); __syncthreads(); } + if (CTA_SIZE >= 128) { if (tid < 64) buffer[tid] = val = op(val, buffer[tid + 64]); __syncthreads(); } + + if (tid < 32) + { + if (CTA_SIZE >= 64) { buffer[tid] = val = op(val, buffer[tid + 32]); } + if (CTA_SIZE >= 32) { buffer[tid] = val = op(val, buffer[tid + 16]); } + if (CTA_SIZE >= 16) { buffer[tid] = val = op(val, buffer[tid + 8]); } + if (CTA_SIZE >= 8) { buffer[tid] = val = op(val, buffer[tid + 4]); } + if (CTA_SIZE >= 4) { buffer[tid] = val = op(val, buffer[tid + 2]); } + if (CTA_SIZE >= 2) { buffer[tid] = val = op(val, buffer[tid + 1]); } + } + __syncthreads(); + return buffer[0]; + } + + template + static __device__ __forceinline__ void reduce_n(T* data, unsigned int n, BinOp op) + { + int ftid = flattenedThreadId(); + int sft = stride(); + + if (sft < n) + { + for (unsigned int i = sft + ftid; i < n; i += sft) + data[ftid] = op(data[ftid], data[i]); + + __syncthreads(); + + n = sft; + } + + while (n > 1) + { + unsigned int half = n/2; + + if (ftid < half) + data[ftid] = op(data[ftid], data[n - ftid - 1]); + + __syncthreads(); + + n = n - half; + } + } + }; +}}} + +//! @endcond + +#endif /* OPENCV_CUDA_DEVICE_BLOCK_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/border_interpolate.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/border_interpolate.hpp new file mode 100644 index 0000000..874f705 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/border_interpolate.hpp @@ -0,0 +1,722 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_BORDER_INTERPOLATE_HPP +#define OPENCV_CUDA_BORDER_INTERPOLATE_HPP + +#include "saturate_cast.hpp" +#include "vec_traits.hpp" +#include "vec_math.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + ////////////////////////////////////////////////////////////// + // BrdConstant + + template struct BrdRowConstant + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowConstant(int width_, const D& val_ = VecTraits::all(0)) : width(width_), val(val_) {} + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return x >= 0 ? saturate_cast(data[x]) : val; + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return x < width ? saturate_cast(data[x]) : val; + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return (x >= 0 && x < width) ? saturate_cast(data[x]) : val; + } + + int width; + D val; + }; + + template struct BrdColConstant + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColConstant(int height_, const D& val_ = VecTraits::all(0)) : height(height_), val(val_) {} + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return y >= 0 ? saturate_cast(*(const T*)((const char*)data + y * step)) : val; + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return y < height ? saturate_cast(*(const T*)((const char*)data + y * step)) : val; + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return (y >= 0 && y < height) ? saturate_cast(*(const T*)((const char*)data + y * step)) : val; + } + + int height; + D val; + }; + + template struct BrdConstant + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdConstant(int height_, int width_, const D& val_ = VecTraits::all(0)) : height(height_), width(width_), val(val_) + { + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast(((const T*)((const uchar*)data + y * step))[x]) : val; + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast(src(y, x)) : val; + } + + int height; + int width; + D val; + }; + + ////////////////////////////////////////////////////////////// + // BrdReplicate + + template struct BrdRowReplicate + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowReplicate(int width) : last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdRowReplicate(int width, U) : last_col(width - 1) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::max(x, 0); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::min(x, last_col); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int last_col; + }; + + template struct BrdColReplicate + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColReplicate(int height) : last_row(height - 1) {} + template __host__ __device__ __forceinline__ BrdColReplicate(int height, U) : last_row(height - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::max(y, 0); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::min(y, last_row); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const T*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const T*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const T*)((const char*)data + idx_row(y) * step)); + } + + int last_row; + }; + + template struct BrdReplicate + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdReplicate(int height, int width) : last_row(height - 1), last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdReplicate(int height, int width, U) : last_row(height - 1), last_col(width - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::max(y, 0); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::min(y, last_row); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::max(x, 0); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::min(x, last_col); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int last_row; + int last_col; + }; + + ////////////////////////////////////////////////////////////// + // BrdReflect101 + + template struct BrdRowReflect101 + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowReflect101(int width) : last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdRowReflect101(int width, U) : last_col(width - 1) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::abs(x) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::abs(last_col - ::abs(last_col - x)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int last_col; + }; + + template struct BrdColReflect101 + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColReflect101(int height) : last_row(height - 1) {} + template __host__ __device__ __forceinline__ BrdColReflect101(int height, U) : last_row(height - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::abs(y) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::abs(last_row - ::abs(last_row - y)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row(y) * step)); + } + + int last_row; + }; + + template struct BrdReflect101 + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdReflect101(int height, int width) : last_row(height - 1), last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdReflect101(int height, int width, U) : last_row(height - 1), last_col(width - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::abs(y) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::abs(last_row - ::abs(last_row - y)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::abs(x) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::abs(last_col - ::abs(last_col - x)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int last_row; + int last_col; + }; + + ////////////////////////////////////////////////////////////// + // BrdReflect + + template struct BrdRowReflect + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowReflect(int width) : last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdRowReflect(int width, U) : last_col(width - 1) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (::abs(x) - (x < 0)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::abs(last_col - ::abs(last_col - x) + (x > last_col)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_high(::abs(x) - (x < 0)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int last_col; + }; + + template struct BrdColReflect + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColReflect(int height) : last_row(height - 1) {} + template __host__ __device__ __forceinline__ BrdColReflect(int height, U) : last_row(height - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (::abs(y) - (y < 0)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::abs(last_row - ::abs(last_row - y) + (y > last_row)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_high(::abs(y) - (y < 0)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row(y) * step)); + } + + int last_row; + }; + + template struct BrdReflect + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdReflect(int height, int width) : last_row(height - 1), last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdReflect(int height, int width, U) : last_row(height - 1), last_col(width - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (::abs(y) - (y < 0)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return /*::abs*/(last_row - ::abs(last_row - y) + (y > last_row)) /*% (last_row + 1)*/; + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (::abs(x) - (x < 0)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return (last_col - ::abs(last_col - x) + (x > last_col)); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int last_row; + int last_col; + }; + + ////////////////////////////////////////////////////////////// + // BrdWrap + + template struct BrdRowWrap + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowWrap(int width_) : width(width_) {} + template __host__ __device__ __forceinline__ BrdRowWrap(int width_, U) : width(width_) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (x >= 0) * x + (x < 0) * (x - ((x - width + 1) / width) * width); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return (x < width) * x + (x >= width) * (x % width); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_high(idx_col_low(x)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int width; + }; + + template struct BrdColWrap + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColWrap(int height_) : height(height_) {} + template __host__ __device__ __forceinline__ BrdColWrap(int height_, U) : height(height_) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (y >= 0) * y + (y < 0) * (y - ((y - height + 1) / height) * height); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return (y < height) * y + (y >= height) * (y % height); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_high(idx_row_low(y)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row(y) * step)); + } + + int height; + }; + + template struct BrdWrap + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdWrap(int height_, int width_) : + height(height_), width(width_) + { + } + template + __host__ __device__ __forceinline__ BrdWrap(int height_, int width_, U) : + height(height_), width(width_) + { + } + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (y >= 0) ? y : (y - ((y - height + 1) / height) * height); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return (y < height) ? y : (y % height); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_high(idx_row_low(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (x >= 0) ? x : (x - ((x - width + 1) / width) * width); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return (x < width) ? x : (x % width); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_high(idx_col_low(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int height; + int width; + }; + + ////////////////////////////////////////////////////////////// + // BorderReader + + template struct BorderReader + { + typedef typename B::result_type elem_type; + typedef typename Ptr2D::index_type index_type; + + __host__ __device__ __forceinline__ BorderReader(const Ptr2D& ptr_, const B& b_) : ptr(ptr_), b(b_) {} + + __device__ __forceinline__ elem_type operator ()(index_type y, index_type x) const + { + return b.at(y, x, ptr); + } + + Ptr2D ptr; + B b; + }; + + // under win32 there is some bug with templated types that passed as kernel parameters + // with this specialization all works fine + template struct BorderReader< Ptr2D, BrdConstant > + { + typedef typename BrdConstant::result_type elem_type; + typedef typename Ptr2D::index_type index_type; + + __host__ __device__ __forceinline__ BorderReader(const Ptr2D& src_, const BrdConstant& b) : + src(src_), height(b.height), width(b.width), val(b.val) + { + } + + __device__ __forceinline__ D operator ()(index_type y, index_type x) const + { + return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast(src(y, x)) : val; + } + + Ptr2D src; + int height; + int width; + D val; + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_BORDER_INTERPOLATE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/color.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/color.hpp new file mode 100644 index 0000000..dcce280 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/color.hpp @@ -0,0 +1,309 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_COLOR_HPP +#define OPENCV_CUDA_COLOR_HPP + +#include "detail/color_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + // All OPENCV_CUDA_IMPLEMENT_*_TRAITS(ColorSpace1_to_ColorSpace2, ...) macros implements + // template class ColorSpace1_to_ColorSpace2_traits + // { + // typedef ... functor_type; + // static __host__ __device__ functor_type create_functor(); + // }; + + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_rgba, 4, 4, 2) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgr_to_bgr555, 3, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgr_to_bgr565, 3, 0, 6) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgb_to_bgr555, 3, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgb_to_bgr565, 3, 2, 6) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgra_to_bgr555, 4, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgra_to_bgr565, 4, 0, 6) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgba_to_bgr555, 4, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgba_to_bgr565, 4, 2, 6) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_rgb, 3, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_rgb, 3, 2, 6) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_bgr, 3, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_bgr, 3, 0, 6) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_rgba, 4, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_rgba, 4, 2, 6) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_bgra, 4, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_bgra, 4, 0, 6) + + #undef OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(gray_to_bgr, 3) + OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(gray_to_bgra, 4) + + #undef OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(gray_to_bgr555, 5) + OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(gray_to_bgr565, 6) + + #undef OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(bgr555_to_gray, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(bgr565_to_gray, 6) + + #undef OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(rgb_to_gray, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(bgr_to_gray, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(rgba_to_gray, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(bgra_to_gray, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS + + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgb_to_YCrCb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgba_to_YCrCb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgb_to_YCrCb4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgba_to_YCrCb4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgr_to_YCrCb, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgra_to_YCrCb, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgr_to_YCrCb4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgra_to_YCrCb4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS + + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgb_to_xyz, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgba_to_xyz, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgb_to_xyz4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgba_to_xyz4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgr_to_xyz, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgra_to_xyz, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgr_to_xyz4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgra_to_xyz4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS + + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgb_to_hsv, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgba_to_hsv, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgb_to_hsv4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgba_to_hsv4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgr_to_hsv, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgra_to_hsv, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgr_to_hsv4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgra_to_hsv4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS + + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgb_to_hls, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgba_to_hls, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgb_to_hls4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgba_to_hls4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgr_to_hls, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgra_to_hls, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgr_to_hls4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgra_to_hls4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS + + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgb_to_lab, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgba_to_lab, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgb_to_lab4, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgba_to_lab4, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgr_to_lab, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgra_to_lab, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgr_to_lab4, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgra_to_lab4, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgb_to_lab, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgba_to_lab, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgb_to_lab4, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgba_to_lab4, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgr_to_lab, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgra_to_lab, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgr_to_lab4, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgra_to_lab4, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS + + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_rgb, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_rgb, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_rgba, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_rgba, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_bgr, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_bgr, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_bgra, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_bgra, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lrgb, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lrgb, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lrgba, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lrgba, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lbgr, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lbgr, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lbgra, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lbgra, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgb_to_luv, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgba_to_luv, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgb_to_luv4, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgba_to_luv4, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgr_to_luv, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgra_to_luv, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgr_to_luv4, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgra_to_luv4, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgb_to_luv, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgba_to_luv, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgb_to_luv4, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgba_to_luv4, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgr_to_luv, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgra_to_luv, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgr_to_luv4, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgra_to_luv4, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS + + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_rgb, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_rgb, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_rgba, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_rgba, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_bgr, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_bgr, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_bgra, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_bgra, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lrgb, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lrgb, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lrgba, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lrgba, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lbgr, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lbgr, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lbgra, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lbgra, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_COLOR_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/common.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/common.hpp new file mode 100644 index 0000000..80b2ff0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/common.hpp @@ -0,0 +1,123 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_COMMON_HPP +#define OPENCV_CUDA_COMMON_HPP + +#include +#include "opencv2/core/cuda_types.hpp" +#include "opencv2/core/cvdef.h" +#include "opencv2/core/base.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +#ifndef CV_PI_F + #ifndef CV_PI + #define CV_PI_F 3.14159265f + #else + #define CV_PI_F ((float)CV_PI) + #endif +#endif + +namespace cv { namespace cuda { + static inline void checkCudaError(cudaError_t err, const char* file, const int line, const char* func) + { + if (cudaSuccess != err) + cv::error(cv::Error::GpuApiCallError, cudaGetErrorString(err), func, file, line); + } +}} + +#ifndef cudaSafeCall + #define cudaSafeCall(expr) cv::cuda::checkCudaError(expr, __FILE__, __LINE__, CV_Func) +#endif + +namespace cv { namespace cuda +{ + template static inline bool isAligned(const T* ptr, size_t size) + { + return reinterpret_cast(ptr) % size == 0; + } + + static inline bool isAligned(size_t step, size_t size) + { + return step % size == 0; + } +}} + +namespace cv { namespace cuda +{ + namespace device + { + __host__ __device__ __forceinline__ int divUp(int total, int grain) + { + return (total + grain - 1) / grain; + } + + template inline void bindTexture(const textureReference* tex, const PtrStepSz& img) + { + cudaChannelFormatDesc desc = cudaCreateChannelDesc(); + cudaSafeCall( cudaBindTexture2D(0, tex, img.ptr(), &desc, img.cols, img.rows, img.step) ); + } + + template inline void createTextureObjectPitch2D(cudaTextureObject_t* tex, PtrStepSz& img, const cudaTextureDesc& texDesc) + { + cudaResourceDesc resDesc; + memset(&resDesc, 0, sizeof(resDesc)); + resDesc.resType = cudaResourceTypePitch2D; + resDesc.res.pitch2D.devPtr = static_cast(img.ptr()); + resDesc.res.pitch2D.height = img.rows; + resDesc.res.pitch2D.width = img.cols; + resDesc.res.pitch2D.pitchInBytes = img.step; + resDesc.res.pitch2D.desc = cudaCreateChannelDesc(); + + cudaSafeCall( cudaCreateTextureObject(tex, &resDesc, &texDesc, NULL) ); + } + } +}} + +//! @endcond + +#endif // OPENCV_CUDA_COMMON_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/datamov_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/datamov_utils.hpp new file mode 100644 index 0000000..6820d0f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/datamov_utils.hpp @@ -0,0 +1,113 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DATAMOV_UTILS_HPP +#define OPENCV_CUDA_DATAMOV_UTILS_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 200 + + // for Fermi memory space is detected automatically + template struct ForceGlob + { + __device__ __forceinline__ static void Load(const T* ptr, int offset, T& val) { val = ptr[offset]; } + }; + + #else // __CUDA_ARCH__ >= 200 + + #if defined(_WIN64) || defined(__LP64__) + // 64-bit register modifier for inlined asm + #define OPENCV_CUDA_ASM_PTR "l" + #else + // 32-bit register modifier for inlined asm + #define OPENCV_CUDA_ASM_PTR "r" + #endif + + template struct ForceGlob; + + #define OPENCV_CUDA_DEFINE_FORCE_GLOB(base_type, ptx_type, reg_mod) \ + template <> struct ForceGlob \ + { \ + __device__ __forceinline__ static void Load(const base_type* ptr, int offset, base_type& val) \ + { \ + asm("ld.global."#ptx_type" %0, [%1];" : "="#reg_mod(val) : OPENCV_CUDA_ASM_PTR(ptr + offset)); \ + } \ + }; + + #define OPENCV_CUDA_DEFINE_FORCE_GLOB_B(base_type, ptx_type) \ + template <> struct ForceGlob \ + { \ + __device__ __forceinline__ static void Load(const base_type* ptr, int offset, base_type& val) \ + { \ + asm("ld.global."#ptx_type" %0, [%1];" : "=r"(*reinterpret_cast(&val)) : OPENCV_CUDA_ASM_PTR(ptr + offset)); \ + } \ + }; + + OPENCV_CUDA_DEFINE_FORCE_GLOB_B(uchar, u8) + OPENCV_CUDA_DEFINE_FORCE_GLOB_B(schar, s8) + OPENCV_CUDA_DEFINE_FORCE_GLOB_B(char, b8) + OPENCV_CUDA_DEFINE_FORCE_GLOB (ushort, u16, h) + OPENCV_CUDA_DEFINE_FORCE_GLOB (short, s16, h) + OPENCV_CUDA_DEFINE_FORCE_GLOB (uint, u32, r) + OPENCV_CUDA_DEFINE_FORCE_GLOB (int, s32, r) + OPENCV_CUDA_DEFINE_FORCE_GLOB (float, f32, f) + OPENCV_CUDA_DEFINE_FORCE_GLOB (double, f64, d) + + #undef OPENCV_CUDA_DEFINE_FORCE_GLOB + #undef OPENCV_CUDA_DEFINE_FORCE_GLOB_B + #undef OPENCV_CUDA_ASM_PTR + + #endif // __CUDA_ARCH__ >= 200 +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_DATAMOV_UTILS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/color_detail.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/color_detail.hpp new file mode 100644 index 0000000..f4b4796 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/color_detail.hpp @@ -0,0 +1,2018 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_COLOR_DETAIL_HPP +#define OPENCV_CUDA_COLOR_DETAIL_HPP + +#include "../common.hpp" +#include "../vec_traits.hpp" +#include "../saturate_cast.hpp" +#include "../limits.hpp" +#include "../functional.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + #ifndef CV_DESCALE + #define CV_DESCALE(x, n) (((x) + (1 << ((n)-1))) >> (n)) + #endif + + namespace color_detail + { + template struct ColorChannel + { + typedef float worktype_f; + static __device__ __forceinline__ T max() { return numeric_limits::max(); } + static __device__ __forceinline__ T half() { return (T)(max()/2 + 1); } + }; + + template<> struct ColorChannel + { + typedef float worktype_f; + static __device__ __forceinline__ float max() { return 1.f; } + static __device__ __forceinline__ float half() { return 0.5f; } + }; + + template static __device__ __forceinline__ void setAlpha(typename TypeVec::vec_type& vec, T val) + { + } + + template static __device__ __forceinline__ void setAlpha(typename TypeVec::vec_type& vec, T val) + { + vec.w = val; + } + + template static __device__ __forceinline__ T getAlpha(const typename TypeVec::vec_type& vec) + { + return ColorChannel::max(); + } + + template static __device__ __forceinline__ T getAlpha(const typename TypeVec::vec_type& vec) + { + return vec.w; + } + + //constants for conversion from/to RGB and Gray, YUV, YCrCb according to BT.601 + constexpr float B2YF = 0.114f; + constexpr float G2YF = 0.587f; + constexpr float R2YF = 0.299f; + + //to YCbCr + constexpr float YCBF = 0.564f; // == 1/2/(1-B2YF) + constexpr float YCRF = 0.713f; // == 1/2/(1-R2YF) + const int YCBI = 9241; // == YCBF*16384 + const int YCRI = 11682; // == YCRF*16384 + //to YUV + constexpr float B2UF = 0.492f; + constexpr float R2VF = 0.877f; + const int B2UI = 8061; // == B2UF*16384 + const int R2VI = 14369; // == R2VF*16384 + //from YUV + constexpr float U2BF = 2.032f; + constexpr float U2GF = -0.395f; + constexpr float V2GF = -0.581f; + constexpr float V2RF = 1.140f; + const int U2BI = 33292; + const int U2GI = -6472; + const int V2GI = -9519; + const int V2RI = 18678; + //from YCrCb + constexpr float CB2BF = 1.773f; + constexpr float CB2GF = -0.344f; + constexpr float CR2GF = -0.714f; + constexpr float CR2RF = 1.403f; + const int CB2BI = 29049; + const int CB2GI = -5636; + const int CR2GI = -11698; + const int CR2RI = 22987; + + enum + { + yuv_shift = 14, + xyz_shift = 12, + gray_shift = 15, + R2Y = 4899, + G2Y = 9617, + B2Y = 1868, + RY15 = 9798, // == R2YF*32768 + 0.5 + GY15 = 19235, // == G2YF*32768 + 0.5 + BY15 = 3735, // == B2YF*32768 + 0.5 + BLOCK_SIZE = 256 + }; + } + +////////////////// Various 3/4-channel to 3/4-channel RGB transformations ///////////////// + + namespace color_detail + { + template struct RGB2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + dst.x = (&src.x)[bidx]; + dst.y = src.y; + dst.z = (&src.x)[bidx^2]; + setAlpha(dst, getAlpha(src)); + + return dst; + } + + __host__ __device__ __forceinline__ RGB2RGB() {} + __host__ __device__ __forceinline__ RGB2RGB(const RGB2RGB&) {} + }; + + template <> struct RGB2RGB : unary_function + { + __device__ uint operator()(uint src) const + { + uint dst = 0; + + dst |= (0xffu & (src >> 16)); + dst |= (0xffu & (src >> 8)) << 8; + dst |= (0xffu & (src)) << 16; + dst |= (0xffu & (src >> 24)) << 24; + + return dst; + } + + __host__ __device__ __forceinline__ RGB2RGB() {} + __host__ __device__ __forceinline__ RGB2RGB(const RGB2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +/////////// Transforming 16-bit (565 or 555) RGB to/from 24/32-bit (888[8]) RGB ////////// + + namespace color_detail + { + template struct RGB2RGB5x5Converter; + template struct RGB2RGB5x5Converter<6, bidx> + { + static __device__ __forceinline__ ushort cvt(const uchar3& src) + { + return (ushort)(((&src.x)[bidx] >> 3) | ((src.y & ~3) << 3) | (((&src.x)[bidx^2] & ~7) << 8)); + } + + static __device__ __forceinline__ ushort cvt(uint src) + { + uint b = 0xffu & (src >> (bidx * 8)); + uint g = 0xffu & (src >> 8); + uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + return (ushort)((b >> 3) | ((g & ~3) << 3) | ((r & ~7) << 8)); + } + }; + + template struct RGB2RGB5x5Converter<5, bidx> + { + static __device__ __forceinline__ ushort cvt(const uchar3& src) + { + return (ushort)(((&src.x)[bidx] >> 3) | ((src.y & ~7) << 2) | (((&src.x)[bidx^2] & ~7) << 7)); + } + + static __device__ __forceinline__ ushort cvt(uint src) + { + uint b = 0xffu & (src >> (bidx * 8)); + uint g = 0xffu & (src >> 8); + uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + uint a = 0xffu & (src >> 24); + return (ushort)((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7) | (a * 0x8000)); + } + }; + + template struct RGB2RGB5x5; + + template struct RGB2RGB5x5<3, bidx,green_bits> : unary_function + { + __device__ __forceinline__ ushort operator()(const uchar3& src) const + { + return RGB2RGB5x5Converter::cvt(src); + } + + __host__ __device__ __forceinline__ RGB2RGB5x5() {} + __host__ __device__ __forceinline__ RGB2RGB5x5(const RGB2RGB5x5&) {} + }; + + template struct RGB2RGB5x5<4, bidx,green_bits> : unary_function + { + __device__ __forceinline__ ushort operator()(uint src) const + { + return RGB2RGB5x5Converter::cvt(src); + } + + __host__ __device__ __forceinline__ RGB2RGB5x5() {} + __host__ __device__ __forceinline__ RGB2RGB5x5(const RGB2RGB5x5&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(name, scn, bidx, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2RGB5x5 functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template struct RGB5x52RGBConverter; + + template struct RGB5x52RGBConverter<5, bidx> + { + static __device__ __forceinline__ void cvt(uint src, uchar3& dst) + { + (&dst.x)[bidx] = src << 3; + dst.y = (src >> 2) & ~7; + (&dst.x)[bidx ^ 2] = (src >> 7) & ~7; + } + + static __device__ __forceinline__ void cvt(uint src, uint& dst) + { + dst = 0; + + dst |= (0xffu & (src << 3)) << (bidx * 8); + dst |= (0xffu & ((src >> 2) & ~7)) << 8; + dst |= (0xffu & ((src >> 7) & ~7)) << ((bidx ^ 2) * 8); + dst |= ((src & 0x8000) * 0xffu) << 24; + } + }; + + template struct RGB5x52RGBConverter<6, bidx> + { + static __device__ __forceinline__ void cvt(uint src, uchar3& dst) + { + (&dst.x)[bidx] = src << 3; + dst.y = (src >> 3) & ~3; + (&dst.x)[bidx ^ 2] = (src >> 8) & ~7; + } + + static __device__ __forceinline__ void cvt(uint src, uint& dst) + { + dst = 0xffu << 24; + + dst |= (0xffu & (src << 3)) << (bidx * 8); + dst |= (0xffu &((src >> 3) & ~3)) << 8; + dst |= (0xffu & ((src >> 8) & ~7)) << ((bidx ^ 2) * 8); + } + }; + + template struct RGB5x52RGB; + + template struct RGB5x52RGB<3, bidx, green_bits> : unary_function + { + __device__ __forceinline__ uchar3 operator()(ushort src) const + { + uchar3 dst; + RGB5x52RGBConverter::cvt(src, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB5x52RGB() {} + __host__ __device__ __forceinline__ RGB5x52RGB(const RGB5x52RGB&) {} + + }; + + template struct RGB5x52RGB<4, bidx, green_bits> : unary_function + { + __device__ __forceinline__ uint operator()(ushort src) const + { + uint dst; + RGB5x52RGBConverter::cvt(src, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB5x52RGB() {} + __host__ __device__ __forceinline__ RGB5x52RGB(const RGB5x52RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(name, dcn, bidx, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB5x52RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////// Grayscale to Color //////////////////////////////// + + namespace color_detail + { + template struct Gray2RGB : unary_function::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(T src) const + { + typename TypeVec::vec_type dst; + + dst.z = dst.y = dst.x = src; + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ Gray2RGB() {} + __host__ __device__ __forceinline__ Gray2RGB(const Gray2RGB&) {} + }; + + template <> struct Gray2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + uint dst = 0xffu << 24; + + dst |= src; + dst |= src << 8; + dst |= src << 16; + + return dst; + } + __host__ __device__ __forceinline__ Gray2RGB() {} + __host__ __device__ __forceinline__ Gray2RGB(const Gray2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(name, dcn) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Gray2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template struct Gray2RGB5x5Converter; + template<> struct Gray2RGB5x5Converter<6> + { + static __device__ __forceinline__ ushort cvt(uint t) + { + return (ushort)((t >> 3) | ((t & ~3) << 3) | ((t & ~7) << 8)); + } + }; + + template<> struct Gray2RGB5x5Converter<5> + { + static __device__ __forceinline__ ushort cvt(uint t) + { + t >>= 3; + return (ushort)(t | (t << 5) | (t << 10)); + } + }; + + template struct Gray2RGB5x5 : unary_function + { + __device__ __forceinline__ ushort operator()(uint src) const + { + return Gray2RGB5x5Converter::cvt(src); + } + + __host__ __device__ __forceinline__ Gray2RGB5x5() {} + __host__ __device__ __forceinline__ Gray2RGB5x5(const Gray2RGB5x5&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(name, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Gray2RGB5x5 functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////// Color to Grayscale //////////////////////////////// + + namespace color_detail + { + template struct RGB5x52GrayConverter; + template <> struct RGB5x52GrayConverter<6> + { + static __device__ __forceinline__ uchar cvt(uint t) + { + return (uchar)CV_DESCALE(((t << 3) & 0xf8) * BY15 + ((t >> 3) & 0xfc) * GY15 + ((t >> 8) & 0xf8) * RY15, gray_shift); + } + }; + + template <> struct RGB5x52GrayConverter<5> + { + static __device__ __forceinline__ uchar cvt(uint t) + { + return (uchar)CV_DESCALE(((t << 3) & 0xf8) * BY15 + ((t >> 2) & 0xf8) * GY15 + ((t >> 7) & 0xf8) * RY15, gray_shift); + } + }; + + template struct RGB5x52Gray : unary_function + { + __device__ __forceinline__ uchar operator()(uint src) const + { + return RGB5x52GrayConverter::cvt(src); + } + __host__ __device__ __forceinline__ RGB5x52Gray() {} + __host__ __device__ __forceinline__ RGB5x52Gray(const RGB5x52Gray&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(name, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB5x52Gray functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template static __device__ __forceinline__ T RGB2GrayConvert(const T* src) + { + return (T)CV_DESCALE((unsigned)(src[bidx] * BY15 + src[1] * GY15 + src[bidx^2] * RY15), gray_shift); + } + + template static __device__ __forceinline__ uchar RGB2GrayConvert(uint src) + { + uint b = 0xffu & (src >> (bidx * 8)); + uint g = 0xffu & (src >> 8); + uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + return CV_DESCALE((uint)(b * BY15 + g * GY15 + r * RY15), gray_shift); + } + + template static __device__ __forceinline__ float RGB2GrayConvert(const float* src) + { + return src[bidx] * B2YF + src[1] * G2YF + src[bidx^2] * R2YF; + } + + template struct RGB2Gray : unary_function::vec_type, T> + { + __device__ __forceinline__ T operator()(const typename TypeVec::vec_type& src) const + { + return RGB2GrayConvert(&src.x); + } + __host__ __device__ __forceinline__ RGB2Gray() {} + __host__ __device__ __forceinline__ RGB2Gray(const RGB2Gray&) {} + }; + + template struct RGB2Gray : unary_function + { + __device__ __forceinline__ uchar operator()(uint src) const + { + return RGB2GrayConvert(src); + } + __host__ __device__ __forceinline__ RGB2Gray() {} + __host__ __device__ __forceinline__ RGB2Gray(const RGB2Gray&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(name, scn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2Gray functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> YUV ////////////////////////////////////// + + namespace color_detail + { + __constant__ float c_RGB2YUVCoeffs_f[5] = { B2YF, G2YF, R2YF, B2UF, R2VF }; + __constant__ int c_RGB2YUVCoeffs_i[5] = { B2Y, G2Y, R2Y, B2UI, R2VI }; + + template static __device__ void RGB2YUVConvert(const T* src, D& dst) + { + const int delta = ColorChannel::half() * (1 << yuv_shift); + + const int Y = CV_DESCALE(src[0] * c_RGB2YUVCoeffs_i[bidx^2] + src[1] * c_RGB2YUVCoeffs_i[1] + src[2] * c_RGB2YUVCoeffs_i[bidx], yuv_shift); + const int Cr = CV_DESCALE((src[bidx^2] - Y) * c_RGB2YUVCoeffs_i[3] + delta, yuv_shift); + const int Cb = CV_DESCALE((src[bidx] - Y) * c_RGB2YUVCoeffs_i[4] + delta, yuv_shift); + + dst.x = saturate_cast(Y); + dst.y = saturate_cast(Cr); + dst.z = saturate_cast(Cb); + } + + template static __device__ __forceinline__ void RGB2YUVConvert(const float* src, D& dst) + { + dst.x = src[0] * c_RGB2YUVCoeffs_f[bidx^2] + src[1] * c_RGB2YUVCoeffs_f[1] + src[2] * c_RGB2YUVCoeffs_f[bidx]; + dst.y = (src[bidx^2] - dst.x) * c_RGB2YUVCoeffs_f[3] + ColorChannel::half(); + dst.z = (src[bidx] - dst.x) * c_RGB2YUVCoeffs_f[4] + ColorChannel::half(); + } + + template struct RGB2YUV + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + RGB2YUVConvert(&src.x, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB2YUV() {} + __host__ __device__ __forceinline__ RGB2YUV(const RGB2YUV&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2YUV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_YUV2RGBCoeffs_f[5] = { U2BF, U2GF, V2GF, V2RF }; + __constant__ int c_YUV2RGBCoeffs_i[5] = { U2BI, U2GI, V2GI, V2RI }; + + template static __device__ void YUV2RGBConvert(const T& src, D* dst) + { + const int b = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[3], yuv_shift); + + const int g = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[2] + + (src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[1], yuv_shift); + + const int r = src.x + CV_DESCALE((src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[0], yuv_shift); + + dst[bidx] = saturate_cast(b); + dst[1] = saturate_cast(g); + dst[bidx^2] = saturate_cast(r); + } + + template static __device__ uint YUV2RGBConvert(uint src) + { + const int x = 0xff & (src); + const int y = 0xff & (src >> 8); + const int z = 0xff & (src >> 16); + + const int b = x + CV_DESCALE((z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[3], yuv_shift); + + const int g = x + CV_DESCALE((z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[2] + + (y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[1], yuv_shift); + + const int r = x + CV_DESCALE((y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[0], yuv_shift); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(b) << (bidx * 8); + dst |= saturate_cast(g) << 8; + dst |= saturate_cast(r) << ((bidx ^ 2) * 8); + + return dst; + } + + template static __device__ __forceinline__ void YUV2RGBConvert(const T& src, float* dst) + { + dst[bidx] = src.x + (src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_f[3]; + + dst[1] = src.x + (src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_f[2] + + (src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_f[1]; + + dst[bidx^2] = src.x + (src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_f[0]; + } + + template struct YUV2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + YUV2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ YUV2RGB() {} + __host__ __device__ __forceinline__ YUV2RGB(const YUV2RGB&) {} + }; + + template struct YUV2RGB : unary_function + { + __device__ __forceinline__ uint operator ()(uint src) const + { + return YUV2RGBConvert(src); + } + __host__ __device__ __forceinline__ YUV2RGB() {} + __host__ __device__ __forceinline__ YUV2RGB(const YUV2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::YUV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> YCrCb ////////////////////////////////////// + + namespace color_detail + { + __constant__ float c_RGB2YCrCbCoeffs_f[5] = {R2YF, G2YF, B2YF, YCRF, YCBF}; + __constant__ int c_RGB2YCrCbCoeffs_i[5] = {R2Y, G2Y, B2Y, YCRI, YCBI}; + + template static __device__ void RGB2YCrCbConvert(const T* src, D& dst) + { + const int delta = ColorChannel::half() * (1 << yuv_shift); + + const int Y = CV_DESCALE(src[0] * c_RGB2YCrCbCoeffs_i[bidx^2] + src[1] * c_RGB2YCrCbCoeffs_i[1] + src[2] * c_RGB2YCrCbCoeffs_i[bidx], yuv_shift); + const int Cr = CV_DESCALE((src[bidx^2] - Y) * c_RGB2YCrCbCoeffs_i[3] + delta, yuv_shift); + const int Cb = CV_DESCALE((src[bidx] - Y) * c_RGB2YCrCbCoeffs_i[4] + delta, yuv_shift); + + dst.x = saturate_cast(Y); + dst.y = saturate_cast(Cr); + dst.z = saturate_cast(Cb); + } + + template static __device__ uint RGB2YCrCbConvert(uint src) + { + const int delta = ColorChannel::half() * (1 << yuv_shift); + + const int Y = CV_DESCALE((0xffu & src) * c_RGB2YCrCbCoeffs_i[bidx^2] + (0xffu & (src >> 8)) * c_RGB2YCrCbCoeffs_i[1] + (0xffu & (src >> 16)) * c_RGB2YCrCbCoeffs_i[bidx], yuv_shift); + const int Cr = CV_DESCALE(((0xffu & (src >> ((bidx ^ 2) * 8))) - Y) * c_RGB2YCrCbCoeffs_i[3] + delta, yuv_shift); + const int Cb = CV_DESCALE(((0xffu & (src >> (bidx * 8))) - Y) * c_RGB2YCrCbCoeffs_i[4] + delta, yuv_shift); + + uint dst = 0; + + dst |= saturate_cast(Y); + dst |= saturate_cast(Cr) << 8; + dst |= saturate_cast(Cb) << 16; + + return dst; + } + + template static __device__ __forceinline__ void RGB2YCrCbConvert(const float* src, D& dst) + { + dst.x = src[0] * c_RGB2YCrCbCoeffs_f[bidx^2] + src[1] * c_RGB2YCrCbCoeffs_f[1] + src[2] * c_RGB2YCrCbCoeffs_f[bidx]; + dst.y = (src[bidx^2] - dst.x) * c_RGB2YCrCbCoeffs_f[3] + ColorChannel::half(); + dst.z = (src[bidx] - dst.x) * c_RGB2YCrCbCoeffs_f[4] + ColorChannel::half(); + } + + template struct RGB2YCrCb + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + RGB2YCrCbConvert(&src.x, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB2YCrCb() {} + __host__ __device__ __forceinline__ RGB2YCrCb(const RGB2YCrCb&) {} + }; + + template struct RGB2YCrCb : unary_function + { + __device__ __forceinline__ uint operator ()(uint src) const + { + return RGB2YCrCbConvert(src); + } + + __host__ __device__ __forceinline__ RGB2YCrCb() {} + __host__ __device__ __forceinline__ RGB2YCrCb(const RGB2YCrCb&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2YCrCb functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_YCrCb2RGBCoeffs_f[5] = {CR2RF, CR2GF, CB2GF, CB2BF}; + __constant__ int c_YCrCb2RGBCoeffs_i[5] = {CR2RI, CR2GI, CB2GI, CB2BI}; + + template static __device__ void YCrCb2RGBConvert(const T& src, D* dst) + { + const int b = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[3], yuv_shift); + const int g = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[2] + (src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[1], yuv_shift); + const int r = src.x + CV_DESCALE((src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[0], yuv_shift); + + dst[bidx] = saturate_cast(b); + dst[1] = saturate_cast(g); + dst[bidx^2] = saturate_cast(r); + } + + template static __device__ uint YCrCb2RGBConvert(uint src) + { + const int x = 0xff & (src); + const int y = 0xff & (src >> 8); + const int z = 0xff & (src >> 16); + + const int b = x + CV_DESCALE((z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[3], yuv_shift); + const int g = x + CV_DESCALE((z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[2] + (y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[1], yuv_shift); + const int r = x + CV_DESCALE((y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[0], yuv_shift); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(b) << (bidx * 8); + dst |= saturate_cast(g) << 8; + dst |= saturate_cast(r) << ((bidx ^ 2) * 8); + + return dst; + } + + template __device__ __forceinline__ void YCrCb2RGBConvert(const T& src, float* dst) + { + dst[bidx] = src.x + (src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[3]; + dst[1] = src.x + (src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[2] + (src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[1]; + dst[bidx^2] = src.x + (src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[0]; + } + + template struct YCrCb2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + YCrCb2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ YCrCb2RGB() {} + __host__ __device__ __forceinline__ YCrCb2RGB(const YCrCb2RGB&) {} + }; + + template struct YCrCb2RGB : unary_function + { + __device__ __forceinline__ uint operator ()(uint src) const + { + return YCrCb2RGBConvert(src); + } + __host__ __device__ __forceinline__ YCrCb2RGB() {} + __host__ __device__ __forceinline__ YCrCb2RGB(const YCrCb2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::YCrCb2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +////////////////////////////////////// RGB <-> XYZ /////////////////////////////////////// + + namespace color_detail + { + __constant__ float c_RGB2XYZ_D65f[9] = { 0.412453f, 0.357580f, 0.180423f, 0.212671f, 0.715160f, 0.072169f, 0.019334f, 0.119193f, 0.950227f }; + __constant__ int c_RGB2XYZ_D65i[9] = { 1689, 1465, 739, 871, 2929, 296, 79, 488, 3892 }; + + template static __device__ __forceinline__ void RGB2XYZConvert(const T* src, D& dst) + { + dst.z = saturate_cast(CV_DESCALE(src[bidx^2] * c_RGB2XYZ_D65i[6] + src[1] * c_RGB2XYZ_D65i[7] + src[bidx] * c_RGB2XYZ_D65i[8], xyz_shift)); + dst.x = saturate_cast(CV_DESCALE(src[bidx^2] * c_RGB2XYZ_D65i[0] + src[1] * c_RGB2XYZ_D65i[1] + src[bidx] * c_RGB2XYZ_D65i[2], xyz_shift)); + dst.y = saturate_cast(CV_DESCALE(src[bidx^2] * c_RGB2XYZ_D65i[3] + src[1] * c_RGB2XYZ_D65i[4] + src[bidx] * c_RGB2XYZ_D65i[5], xyz_shift)); + } + + template static __device__ __forceinline__ uint RGB2XYZConvert(uint src) + { + const uint b = 0xffu & (src >> (bidx * 8)); + const uint g = 0xffu & (src >> 8); + const uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + + const uint x = saturate_cast(CV_DESCALE(r * c_RGB2XYZ_D65i[0] + g * c_RGB2XYZ_D65i[1] + b * c_RGB2XYZ_D65i[2], xyz_shift)); + const uint y = saturate_cast(CV_DESCALE(r * c_RGB2XYZ_D65i[3] + g * c_RGB2XYZ_D65i[4] + b * c_RGB2XYZ_D65i[5], xyz_shift)); + const uint z = saturate_cast(CV_DESCALE(r * c_RGB2XYZ_D65i[6] + g * c_RGB2XYZ_D65i[7] + b * c_RGB2XYZ_D65i[8], xyz_shift)); + + uint dst = 0; + + dst |= x; + dst |= y << 8; + dst |= z << 16; + + return dst; + } + + template static __device__ __forceinline__ void RGB2XYZConvert(const float* src, D& dst) + { + dst.x = src[bidx^2] * c_RGB2XYZ_D65f[0] + src[1] * c_RGB2XYZ_D65f[1] + src[bidx] * c_RGB2XYZ_D65f[2]; + dst.y = src[bidx^2] * c_RGB2XYZ_D65f[3] + src[1] * c_RGB2XYZ_D65f[4] + src[bidx] * c_RGB2XYZ_D65f[5]; + dst.z = src[bidx^2] * c_RGB2XYZ_D65f[6] + src[1] * c_RGB2XYZ_D65f[7] + src[bidx] * c_RGB2XYZ_D65f[8]; + } + + template struct RGB2XYZ + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2XYZConvert(&src.x, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2XYZ() {} + __host__ __device__ __forceinline__ RGB2XYZ(const RGB2XYZ&) {} + }; + + template struct RGB2XYZ : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return RGB2XYZConvert(src); + } + __host__ __device__ __forceinline__ RGB2XYZ() {} + __host__ __device__ __forceinline__ RGB2XYZ(const RGB2XYZ&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2XYZ functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_XYZ2sRGB_D65f[9] = { 3.240479f, -1.53715f, -0.498535f, -0.969256f, 1.875991f, 0.041556f, 0.055648f, -0.204043f, 1.057311f }; + __constant__ int c_XYZ2sRGB_D65i[9] = { 13273, -6296, -2042, -3970, 7684, 170, 228, -836, 4331 }; + + template static __device__ __forceinline__ void XYZ2RGBConvert(const T& src, D* dst) + { + dst[bidx^2] = saturate_cast(CV_DESCALE(src.x * c_XYZ2sRGB_D65i[0] + src.y * c_XYZ2sRGB_D65i[1] + src.z * c_XYZ2sRGB_D65i[2], xyz_shift)); + dst[1] = saturate_cast(CV_DESCALE(src.x * c_XYZ2sRGB_D65i[3] + src.y * c_XYZ2sRGB_D65i[4] + src.z * c_XYZ2sRGB_D65i[5], xyz_shift)); + dst[bidx] = saturate_cast(CV_DESCALE(src.x * c_XYZ2sRGB_D65i[6] + src.y * c_XYZ2sRGB_D65i[7] + src.z * c_XYZ2sRGB_D65i[8], xyz_shift)); + } + + template static __device__ __forceinline__ uint XYZ2RGBConvert(uint src) + { + const int x = 0xff & src; + const int y = 0xff & (src >> 8); + const int z = 0xff & (src >> 16); + + const uint r = saturate_cast(CV_DESCALE(x * c_XYZ2sRGB_D65i[0] + y * c_XYZ2sRGB_D65i[1] + z * c_XYZ2sRGB_D65i[2], xyz_shift)); + const uint g = saturate_cast(CV_DESCALE(x * c_XYZ2sRGB_D65i[3] + y * c_XYZ2sRGB_D65i[4] + z * c_XYZ2sRGB_D65i[5], xyz_shift)); + const uint b = saturate_cast(CV_DESCALE(x * c_XYZ2sRGB_D65i[6] + y * c_XYZ2sRGB_D65i[7] + z * c_XYZ2sRGB_D65i[8], xyz_shift)); + + uint dst = 0xffu << 24; + + dst |= b << (bidx * 8); + dst |= g << 8; + dst |= r << ((bidx ^ 2) * 8); + + return dst; + } + + template static __device__ __forceinline__ void XYZ2RGBConvert(const T& src, float* dst) + { + dst[bidx^2] = src.x * c_XYZ2sRGB_D65f[0] + src.y * c_XYZ2sRGB_D65f[1] + src.z * c_XYZ2sRGB_D65f[2]; + dst[1] = src.x * c_XYZ2sRGB_D65f[3] + src.y * c_XYZ2sRGB_D65f[4] + src.z * c_XYZ2sRGB_D65f[5]; + dst[bidx] = src.x * c_XYZ2sRGB_D65f[6] + src.y * c_XYZ2sRGB_D65f[7] + src.z * c_XYZ2sRGB_D65f[8]; + } + + template struct XYZ2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + XYZ2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ XYZ2RGB() {} + __host__ __device__ __forceinline__ XYZ2RGB(const XYZ2RGB&) {} + }; + + template struct XYZ2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return XYZ2RGBConvert(src); + } + __host__ __device__ __forceinline__ XYZ2RGB() {} + __host__ __device__ __forceinline__ XYZ2RGB(const XYZ2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::XYZ2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +////////////////////////////////////// RGB <-> HSV /////////////////////////////////////// + + namespace color_detail + { + __constant__ int c_HsvDivTable [256] = {0, 1044480, 522240, 348160, 261120, 208896, 174080, 149211, 130560, 116053, 104448, 94953, 87040, 80345, 74606, 69632, 65280, 61440, 58027, 54973, 52224, 49737, 47476, 45412, 43520, 41779, 40172, 38684, 37303, 36017, 34816, 33693, 32640, 31651, 30720, 29842, 29013, 28229, 27486, 26782, 26112, 25475, 24869, 24290, 23738, 23211, 22706, 22223, 21760, 21316, 20890, 20480, 20086, 19707, 19342, 18991, 18651, 18324, 18008, 17703, 17408, 17123, 16846, 16579, 16320, 16069, 15825, 15589, 15360, 15137, 14921, 14711, 14507, 14308, 14115, 13926, 13743, 13565, 13391, 13221, 13056, 12895, 12738, 12584, 12434, 12288, 12145, 12006, 11869, 11736, 11605, 11478, 11353, 11231, 11111, 10995, 10880, 10768, 10658, 10550, 10445, 10341, 10240, 10141, 10043, 9947, 9854, 9761, 9671, 9582, 9495, 9410, 9326, 9243, 9162, 9082, 9004, 8927, 8852, 8777, 8704, 8632, 8561, 8492, 8423, 8356, 8290, 8224, 8160, 8097, 8034, 7973, 7913, 7853, 7795, 7737, 7680, 7624, 7569, 7514, 7461, 7408, 7355, 7304, 7253, 7203, 7154, 7105, 7057, 7010, 6963, 6917, 6872, 6827, 6782, 6739, 6695, 6653, 6611, 6569, 6528, 6487, 6447, 6408, 6369, 6330, 6292, 6254, 6217, 6180, 6144, 6108, 6073, 6037, 6003, 5968, 5935, 5901, 5868, 5835, 5803, 5771, 5739, 5708, 5677, 5646, 5615, 5585, 5556, 5526, 5497, 5468, 5440, 5412, 5384, 5356, 5329, 5302, 5275, 5249, 5222, 5196, 5171, 5145, 5120, 5095, 5070, 5046, 5022, 4998, 4974, 4950, 4927, 4904, 4881, 4858, 4836, 4813, 4791, 4769, 4748, 4726, 4705, 4684, 4663, 4642, 4622, 4601, 4581, 4561, 4541, 4522, 4502, 4483, 4464, 4445, 4426, 4407, 4389, 4370, 4352, 4334, 4316, 4298, 4281, 4263, 4246, 4229, 4212, 4195, 4178, 4161, 4145, 4128, 4112, 4096}; + __constant__ int c_HsvDivTable180[256] = {0, 122880, 61440, 40960, 30720, 24576, 20480, 17554, 15360, 13653, 12288, 11171, 10240, 9452, 8777, 8192, 7680, 7228, 6827, 6467, 6144, 5851, 5585, 5343, 5120, 4915, 4726, 4551, 4389, 4237, 4096, 3964, 3840, 3724, 3614, 3511, 3413, 3321, 3234, 3151, 3072, 2997, 2926, 2858, 2793, 2731, 2671, 2614, 2560, 2508, 2458, 2409, 2363, 2318, 2276, 2234, 2194, 2156, 2119, 2083, 2048, 2014, 1982, 1950, 1920, 1890, 1862, 1834, 1807, 1781, 1755, 1731, 1707, 1683, 1661, 1638, 1617, 1596, 1575, 1555, 1536, 1517, 1499, 1480, 1463, 1446, 1429, 1412, 1396, 1381, 1365, 1350, 1336, 1321, 1307, 1293, 1280, 1267, 1254, 1241, 1229, 1217, 1205, 1193, 1182, 1170, 1159, 1148, 1138, 1127, 1117, 1107, 1097, 1087, 1078, 1069, 1059, 1050, 1041, 1033, 1024, 1016, 1007, 999, 991, 983, 975, 968, 960, 953, 945, 938, 931, 924, 917, 910, 904, 897, 890, 884, 878, 871, 865, 859, 853, 847, 842, 836, 830, 825, 819, 814, 808, 803, 798, 793, 788, 783, 778, 773, 768, 763, 759, 754, 749, 745, 740, 736, 731, 727, 723, 719, 714, 710, 706, 702, 698, 694, 690, 686, 683, 679, 675, 671, 668, 664, 661, 657, 654, 650, 647, 643, 640, 637, 633, 630, 627, 624, 621, 617, 614, 611, 608, 605, 602, 599, 597, 594, 591, 588, 585, 582, 580, 577, 574, 572, 569, 566, 564, 561, 559, 556, 554, 551, 549, 546, 544, 541, 539, 537, 534, 532, 530, 527, 525, 523, 521, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 497, 495, 493, 492, 490, 488, 486, 484, 482}; + __constant__ int c_HsvDivTable256[256] = {0, 174763, 87381, 58254, 43691, 34953, 29127, 24966, 21845, 19418, 17476, 15888, 14564, 13443, 12483, 11651, 10923, 10280, 9709, 9198, 8738, 8322, 7944, 7598, 7282, 6991, 6722, 6473, 6242, 6026, 5825, 5638, 5461, 5296, 5140, 4993, 4855, 4723, 4599, 4481, 4369, 4263, 4161, 4064, 3972, 3884, 3799, 3718, 3641, 3567, 3495, 3427, 3361, 3297, 3236, 3178, 3121, 3066, 3013, 2962, 2913, 2865, 2819, 2774, 2731, 2689, 2648, 2608, 2570, 2533, 2497, 2461, 2427, 2394, 2362, 2330, 2300, 2270, 2241, 2212, 2185, 2158, 2131, 2106, 2081, 2056, 2032, 2009, 1986, 1964, 1942, 1920, 1900, 1879, 1859, 1840, 1820, 1802, 1783, 1765, 1748, 1730, 1713, 1697, 1680, 1664, 1649, 1633, 1618, 1603, 1589, 1574, 1560, 1547, 1533, 1520, 1507, 1494, 1481, 1469, 1456, 1444, 1432, 1421, 1409, 1398, 1387, 1376, 1365, 1355, 1344, 1334, 1324, 1314, 1304, 1295, 1285, 1276, 1266, 1257, 1248, 1239, 1231, 1222, 1214, 1205, 1197, 1189, 1181, 1173, 1165, 1157, 1150, 1142, 1135, 1128, 1120, 1113, 1106, 1099, 1092, 1085, 1079, 1072, 1066, 1059, 1053, 1046, 1040, 1034, 1028, 1022, 1016, 1010, 1004, 999, 993, 987, 982, 976, 971, 966, 960, 955, 950, 945, 940, 935, 930, 925, 920, 915, 910, 906, 901, 896, 892, 887, 883, 878, 874, 869, 865, 861, 857, 853, 848, 844, 840, 836, 832, 828, 824, 820, 817, 813, 809, 805, 802, 798, 794, 791, 787, 784, 780, 777, 773, 770, 767, 763, 760, 757, 753, 750, 747, 744, 741, 737, 734, 731, 728, 725, 722, 719, 716, 713, 710, 708, 705, 702, 699, 696, 694, 691, 688, 685}; + + template static __device__ void RGB2HSVConvert(const uchar* src, D& dst) + { + const int hsv_shift = 12; + const int* hdiv_table = hr == 180 ? c_HsvDivTable180 : c_HsvDivTable256; + + int b = src[bidx], g = src[1], r = src[bidx^2]; + int h, s, v = b; + int vmin = b, diff; + int vr, vg; + + v = ::max(v, g); + v = ::max(v, r); + vmin = ::min(vmin, g); + vmin = ::min(vmin, r); + + diff = v - vmin; + vr = (v == r) * -1; + vg = (v == g) * -1; + + s = (diff * c_HsvDivTable[v] + (1 << (hsv_shift-1))) >> hsv_shift; + h = (vr & (g - b)) + (~vr & ((vg & (b - r + 2 * diff)) + ((~vg) & (r - g + 4 * diff)))); + h = (h * hdiv_table[diff] + (1 << (hsv_shift-1))) >> hsv_shift; + h += (h < 0) * hr; + + dst.x = saturate_cast(h); + dst.y = (uchar)s; + dst.z = (uchar)v; + } + + template static __device__ uint RGB2HSVConvert(uint src) + { + const int hsv_shift = 12; + const int* hdiv_table = hr == 180 ? c_HsvDivTable180 : c_HsvDivTable256; + + const int b = 0xff & (src >> (bidx * 8)); + const int g = 0xff & (src >> 8); + const int r = 0xff & (src >> ((bidx ^ 2) * 8)); + + int h, s, v = b; + int vmin = b, diff; + int vr, vg; + + v = ::max(v, g); + v = ::max(v, r); + vmin = ::min(vmin, g); + vmin = ::min(vmin, r); + + diff = v - vmin; + vr = (v == r) * -1; + vg = (v == g) * -1; + + s = (diff * c_HsvDivTable[v] + (1 << (hsv_shift-1))) >> hsv_shift; + h = (vr & (g - b)) + (~vr & ((vg & (b - r + 2 * diff)) + ((~vg) & (r - g + 4 * diff)))); + h = (h * hdiv_table[diff] + (1 << (hsv_shift-1))) >> hsv_shift; + h += (h < 0) * hr; + + uint dst = 0; + + dst |= saturate_cast(h); + dst |= (0xffu & s) << 8; + dst |= (0xffu & v) << 16; + + return dst; + } + + template static __device__ void RGB2HSVConvert(const float* src, D& dst) + { + const float hscale = hr * (1.f / 360.f); + + float b = src[bidx], g = src[1], r = src[bidx^2]; + float h, s, v; + + float vmin, diff; + + v = vmin = r; + v = fmax(v, g); + v = fmax(v, b); + vmin = fmin(vmin, g); + vmin = fmin(vmin, b); + + diff = v - vmin; + s = diff / (float)(::fabs(v) + numeric_limits::epsilon()); + diff = (float)(60. / (diff + numeric_limits::epsilon())); + + h = (v == r) * (g - b) * diff; + h += (v != r && v == g) * ((b - r) * diff + 120.f); + h += (v != r && v != g) * ((r - g) * diff + 240.f); + h += (h < 0) * 360.f; + + dst.x = h * hscale; + dst.y = s; + dst.z = v; + } + + template struct RGB2HSV + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2HSVConvert(&src.x, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2HSV() {} + __host__ __device__ __forceinline__ RGB2HSV(const RGB2HSV&) {} + }; + + template struct RGB2HSV : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return RGB2HSVConvert(src); + } + __host__ __device__ __forceinline__ RGB2HSV() {} + __host__ __device__ __forceinline__ RGB2HSV(const RGB2HSV&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ int c_HsvSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; + + template static __device__ void HSV2RGBConvert(const T& src, float* dst) + { + const float hscale = 6.f / hr; + + float h = src.x, s = src.y, v = src.z; + float b = v, g = v, r = v; + + if (s != 0) + { + h *= hscale; + + if( h < 0 ) + do h += 6; while( h < 0 ); + else if( h >= 6 ) + do h -= 6; while( h >= 6 ); + + int sector = __float2int_rd(h); + h -= sector; + + if ( (unsigned)sector >= 6u ) + { + sector = 0; + h = 0.f; + } + + float tab[4]; + tab[0] = v; + tab[1] = v * (1.f - s); + tab[2] = v * (1.f - s * h); + tab[3] = v * (1.f - s * (1.f - h)); + + b = tab[c_HsvSectorData[sector][0]]; + g = tab[c_HsvSectorData[sector][1]]; + r = tab[c_HsvSectorData[sector][2]]; + } + + dst[bidx] = b; + dst[1] = g; + dst[bidx^2] = r; + } + + template static __device__ void HSV2RGBConvert(const T& src, uchar* dst) + { + float3 buf; + + buf.x = src.x; + buf.y = src.y * (1.f / 255.f); + buf.z = src.z * (1.f / 255.f); + + HSV2RGBConvert(buf, &buf.x); + + dst[0] = saturate_cast(buf.x * 255.f); + dst[1] = saturate_cast(buf.y * 255.f); + dst[2] = saturate_cast(buf.z * 255.f); + } + + template static __device__ uint HSV2RGBConvert(uint src) + { + float3 buf; + + buf.x = src & 0xff; + buf.y = ((src >> 8) & 0xff) * (1.f/255.f); + buf.z = ((src >> 16) & 0xff) * (1.f/255.f); + + HSV2RGBConvert(buf, &buf.x); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(buf.x * 255.f); + dst |= saturate_cast(buf.y * 255.f) << 8; + dst |= saturate_cast(buf.z * 255.f) << 16; + + return dst; + } + + template struct HSV2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + HSV2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ HSV2RGB() {} + __host__ __device__ __forceinline__ HSV2RGB(const HSV2RGB&) {} + }; + + template struct HSV2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return HSV2RGBConvert(src); + } + __host__ __device__ __forceinline__ HSV2RGB() {} + __host__ __device__ __forceinline__ HSV2RGB(const HSV2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +/////////////////////////////////////// RGB <-> HLS //////////////////////////////////////// + + namespace color_detail + { + template static __device__ void RGB2HLSConvert(const float* src, D& dst) + { + const float hscale = hr * (1.f / 360.f); + + float b = src[bidx], g = src[1], r = src[bidx^2]; + float h = 0.f, s = 0.f, l; + float vmin, vmax, diff; + + vmax = vmin = r; + vmax = fmax(vmax, g); + vmax = fmax(vmax, b); + vmin = fmin(vmin, g); + vmin = fmin(vmin, b); + + diff = vmax - vmin; + l = (vmax + vmin) * 0.5f; + + if (diff > numeric_limits::epsilon()) + { + s = (l < 0.5f) * diff / (vmax + vmin); + s += (l >= 0.5f) * diff / (2.0f - vmax - vmin); + + diff = 60.f / diff; + + h = (vmax == r) * (g - b) * diff; + h += (vmax != r && vmax == g) * ((b - r) * diff + 120.f); + h += (vmax != r && vmax != g) * ((r - g) * diff + 240.f); + h += (h < 0.f) * 360.f; + } + + dst.x = h * hscale; + dst.y = l; + dst.z = s; + } + + template static __device__ void RGB2HLSConvert(const uchar* src, D& dst) + { + float3 buf; + + buf.x = src[0] * (1.f / 255.f); + buf.y = src[1] * (1.f / 255.f); + buf.z = src[2] * (1.f / 255.f); + + RGB2HLSConvert(&buf.x, buf); + + dst.x = saturate_cast(buf.x); + dst.y = saturate_cast(buf.y*255.f); + dst.z = saturate_cast(buf.z*255.f); + } + + template static __device__ uint RGB2HLSConvert(uint src) + { + float3 buf; + + buf.x = (0xff & src) * (1.f / 255.f); + buf.y = (0xff & (src >> 8)) * (1.f / 255.f); + buf.z = (0xff & (src >> 16)) * (1.f / 255.f); + + RGB2HLSConvert(&buf.x, buf); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(buf.x); + dst |= saturate_cast(buf.y * 255.f) << 8; + dst |= saturate_cast(buf.z * 255.f) << 16; + + return dst; + } + + template struct RGB2HLS + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2HLSConvert(&src.x, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2HLS() {} + __host__ __device__ __forceinline__ RGB2HLS(const RGB2HLS&) {} + }; + + template struct RGB2HLS : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return RGB2HLSConvert(src); + } + __host__ __device__ __forceinline__ RGB2HLS() {} + __host__ __device__ __forceinline__ RGB2HLS(const RGB2HLS&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ int c_HlsSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; + + template static __device__ void HLS2RGBConvert(const T& src, float* dst) + { + const float hscale = 6.0f / hr; + + float h = src.x, l = src.y, s = src.z; + float b = l, g = l, r = l; + + if (s != 0) + { + float p2 = (l <= 0.5f) * l * (1 + s); + p2 += (l > 0.5f) * (l + s - l * s); + float p1 = 2 * l - p2; + + h *= hscale; + + if( h < 0 ) + do h += 6; while( h < 0 ); + else if( h >= 6 ) + do h -= 6; while( h >= 6 ); + + int sector; + sector = __float2int_rd(h); + + h -= sector; + + float tab[4]; + tab[0] = p2; + tab[1] = p1; + tab[2] = p1 + (p2 - p1) * (1 - h); + tab[3] = p1 + (p2 - p1) * h; + + b = tab[c_HlsSectorData[sector][0]]; + g = tab[c_HlsSectorData[sector][1]]; + r = tab[c_HlsSectorData[sector][2]]; + } + + dst[bidx] = b; + dst[1] = g; + dst[bidx^2] = r; + } + + template static __device__ void HLS2RGBConvert(const T& src, uchar* dst) + { + float3 buf; + + buf.x = src.x; + buf.y = src.y * (1.f / 255.f); + buf.z = src.z * (1.f / 255.f); + + HLS2RGBConvert(buf, &buf.x); + + dst[0] = saturate_cast(buf.x * 255.f); + dst[1] = saturate_cast(buf.y * 255.f); + dst[2] = saturate_cast(buf.z * 255.f); + } + + template static __device__ uint HLS2RGBConvert(uint src) + { + float3 buf; + + buf.x = 0xff & src; + buf.y = (0xff & (src >> 8)) * (1.f / 255.f); + buf.z = (0xff & (src >> 16)) * (1.f / 255.f); + + HLS2RGBConvert(buf, &buf.x); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(buf.x * 255.f); + dst |= saturate_cast(buf.y * 255.f) << 8; + dst |= saturate_cast(buf.z * 255.f) << 16; + + return dst; + } + + template struct HLS2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + HLS2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ HLS2RGB() {} + __host__ __device__ __forceinline__ HLS2RGB(const HLS2RGB&) {} + }; + + template struct HLS2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return HLS2RGBConvert(src); + } + __host__ __device__ __forceinline__ HLS2RGB() {} + __host__ __device__ __forceinline__ HLS2RGB(const HLS2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> Lab ///////////////////////////////////// + + namespace color_detail + { + enum + { + LAB_CBRT_TAB_SIZE = 1024, + GAMMA_TAB_SIZE = 1024, + lab_shift = xyz_shift, + gamma_shift = 3, + lab_shift2 = (lab_shift + gamma_shift), + LAB_CBRT_TAB_SIZE_B = (256 * 3 / 2 * (1 << gamma_shift)) + }; + + __constant__ ushort c_sRGBGammaTab_b[] = {0,1,1,2,2,3,4,4,5,6,6,7,8,8,9,10,11,11,12,13,14,15,16,17,19,20,21,22,24,25,26,28,29,31,33,34,36,38,40,41,43,45,47,49,51,54,56,58,60,63,65,68,70,73,75,78,81,83,86,89,92,95,98,101,105,108,111,115,118,121,125,129,132,136,140,144,147,151,155,160,164,168,172,176,181,185,190,194,199,204,209,213,218,223,228,233,239,244,249,255,260,265,271,277,282,288,294,300,306,312,318,324,331,337,343,350,356,363,370,376,383,390,397,404,411,418,426,433,440,448,455,463,471,478,486,494,502,510,518,527,535,543,552,560,569,578,586,595,604,613,622,631,641,650,659,669,678,688,698,707,717,727,737,747,757,768,778,788,799,809,820,831,842,852,863,875,886,897,908,920,931,943,954,966,978,990,1002,1014,1026,1038,1050,1063,1075,1088,1101,1113,1126,1139,1152,1165,1178,1192,1205,1218,1232,1245,1259,1273,1287,1301,1315,1329,1343,1357,1372,1386,1401,1415,1430,1445,1460,1475,1490,1505,1521,1536,1551,1567,1583,1598,1614,1630,1646,1662,1678,1695,1711,1728,1744,1761,1778,1794,1811,1828,1846,1863,1880,1897,1915,1933,1950,1968,1986,2004,2022,2040}; + + __device__ __forceinline__ int LabCbrt_b(int i) + { + float x = i * (1.f / (255.f * (1 << gamma_shift))); + return (1 << lab_shift2) * (x < 0.008856f ? x * 7.787f + 0.13793103448275862f : ::cbrtf(x)); + } + + template + __device__ __forceinline__ void RGB2LabConvert_b(const T& src, D& dst) + { + const int Lscale = (116 * 255 + 50) / 100; + const int Lshift = -((16 * 255 * (1 << lab_shift2) + 50) / 100); + + int B = blueIdx == 0 ? src.x : src.z; + int G = src.y; + int R = blueIdx == 0 ? src.z : src.x; + + if (srgb) + { + B = c_sRGBGammaTab_b[B]; + G = c_sRGBGammaTab_b[G]; + R = c_sRGBGammaTab_b[R]; + } + else + { + B <<= 3; + G <<= 3; + R <<= 3; + } + + int fX = LabCbrt_b(CV_DESCALE(B * 778 + G * 1541 + R * 1777, lab_shift)); + int fY = LabCbrt_b(CV_DESCALE(B * 296 + G * 2929 + R * 871, lab_shift)); + int fZ = LabCbrt_b(CV_DESCALE(B * 3575 + G * 448 + R * 73, lab_shift)); + + int L = CV_DESCALE(Lscale * fY + Lshift, lab_shift2); + int a = CV_DESCALE(500 * (fX - fY) + 128 * (1 << lab_shift2), lab_shift2); + int b = CV_DESCALE(200 * (fY - fZ) + 128 * (1 << lab_shift2), lab_shift2); + + dst.x = saturate_cast(L); + dst.y = saturate_cast(a); + dst.z = saturate_cast(b); + } + + __device__ __forceinline__ float splineInterpolate(float x, const float* tab, int n) + { + int ix = ::min(::max(int(x), 0), n-1); + x -= ix; + tab += ix * 4; + return ((tab[3] * x + tab[2]) * x + tab[1]) * x + tab[0]; + } + + __constant__ float c_sRGBGammaTab[] = {0,7.55853e-05,0.,-7.51331e-13,7.55853e-05,7.55853e-05,-2.25399e-12,3.75665e-12,0.000151171,7.55853e-05,9.01597e-12,-6.99932e-12,0.000226756,7.55853e-05,-1.1982e-11,2.41277e-12,0.000302341,7.55853e-05,-4.74369e-12,1.19001e-11,0.000377927,7.55853e-05,3.09568e-11,-2.09095e-11,0.000453512,7.55853e-05,-3.17718e-11,1.35303e-11,0.000529097,7.55853e-05,8.81905e-12,-4.10782e-12,0.000604683,7.55853e-05,-3.50439e-12,2.90097e-12,0.000680268,7.55853e-05,5.19852e-12,-7.49607e-12,0.000755853,7.55853e-05,-1.72897e-11,2.70833e-11,0.000831439,7.55854e-05,6.39602e-11,-4.26295e-11,0.000907024,7.55854e-05,-6.39282e-11,2.70193e-11,0.000982609,7.55853e-05,1.71298e-11,-7.24017e-12,0.00105819,7.55853e-05,-4.59077e-12,1.94137e-12,0.00113378,7.55853e-05,1.23333e-12,-5.25291e-13,0.00120937,7.55853e-05,-3.42545e-13,1.59799e-13,0.00128495,7.55853e-05,1.36852e-13,-1.13904e-13,0.00136054,7.55853e-05,-2.04861e-13,2.95818e-13,0.00143612,7.55853e-05,6.82594e-13,-1.06937e-12,0.00151171,7.55853e-05,-2.52551e-12,3.98166e-12,0.00158729,7.55853e-05,9.41946e-12,-1.48573e-11,0.00166288,7.55853e-05,-3.51523e-11,5.54474e-11,0.00173846,7.55854e-05,1.3119e-10,-9.0517e-11,0.00181405,7.55854e-05,-1.40361e-10,7.37899e-11,0.00188963,7.55853e-05,8.10085e-11,-8.82272e-11,0.00196522,7.55852e-05,-1.83673e-10,1.62704e-10,0.0020408,7.55853e-05,3.04438e-10,-2.13341e-10,0.00211639,7.55853e-05,-3.35586e-10,2.25e-10,0.00219197,7.55853e-05,3.39414e-10,-2.20997e-10,0.00226756,7.55853e-05,-3.23576e-10,1.93326e-10,0.00234315,7.55853e-05,2.564e-10,-8.66446e-11,0.00241873,7.55855e-05,-3.53328e-12,-7.9578e-11,0.00249432,7.55853e-05,-2.42267e-10,1.72126e-10,0.0025699,7.55853e-05,2.74111e-10,-1.43265e-10,0.00264549,7.55854e-05,-1.55683e-10,-6.47292e-11,0.00272107,7.55849e-05,-3.4987e-10,8.67842e-10,0.00279666,7.55868e-05,2.25366e-09,-3.8723e-09,0.00287224,7.55797e-05,-9.36325e-09,1.5087e-08,0.00294783,7.56063e-05,3.58978e-08,-5.69415e-08,0.00302341,7.55072e-05,-1.34927e-07,2.13144e-07,0.003099,7.58768e-05,5.04507e-07,1.38713e-07,0.00317552,7.7302e-05,9.20646e-07,-1.55186e-07,0.00325359,7.86777e-05,4.55087e-07,4.26813e-08,0.00333276,7.97159e-05,5.83131e-07,-1.06495e-08,0.00341305,8.08502e-05,5.51182e-07,3.87467e-09,0.00349446,8.19642e-05,5.62806e-07,-1.92586e-10,0.00357698,8.30892e-05,5.62228e-07,1.0866e-09,0.00366063,8.4217e-05,5.65488e-07,5.02818e-10,0.00374542,8.53494e-05,5.66997e-07,8.60211e-10,0.00383133,8.6486e-05,5.69577e-07,7.13044e-10,0.00391839,8.76273e-05,5.71716e-07,4.78527e-10,0.00400659,8.87722e-05,5.73152e-07,1.09818e-09,0.00409594,8.99218e-05,5.76447e-07,2.50964e-10,0.00418644,9.10754e-05,5.772e-07,1.15762e-09,0.00427809,9.22333e-05,5.80672e-07,2.40865e-10,0.0043709,9.33954e-05,5.81395e-07,1.13854e-09,0.00446488,9.45616e-05,5.84811e-07,3.27267e-10,0.00456003,9.57322e-05,5.85792e-07,8.1197e-10,0.00465635,9.69062e-05,5.88228e-07,6.15823e-10,0.00475384,9.80845e-05,5.90076e-07,9.15747e-10,0.00485252,9.92674e-05,5.92823e-07,3.778e-10,0.00495238,0.000100454,5.93956e-07,8.32623e-10,0.00505343,0.000101645,5.96454e-07,4.82695e-10,0.00515567,0.000102839,5.97902e-07,9.61904e-10,0.00525911,0.000104038,6.00788e-07,3.26281e-10,0.00536375,0.00010524,6.01767e-07,9.926e-10,0.00546959,0.000106447,6.04745e-07,3.59933e-10,0.00557664,0.000107657,6.05824e-07,8.2728e-10,0.0056849,0.000108871,6.08306e-07,5.21898e-10,0.00579438,0.00011009,6.09872e-07,8.10492e-10,0.00590508,0.000111312,6.12303e-07,4.27046e-10,0.00601701,0.000112538,6.13585e-07,7.40878e-10,0.00613016,0.000113767,6.15807e-07,8.00469e-10,0.00624454,0.000115001,6.18209e-07,2.48178e-10,0.00636016,0.000116238,6.18953e-07,1.00073e-09,0.00647702,0.000117479,6.21955e-07,4.05654e-10,0.00659512,0.000118724,6.23172e-07,6.36192e-10,0.00671447,0.000119973,6.25081e-07,7.74927e-10,0.00683507,0.000121225,6.27406e-07,4.54975e-10,0.00695692,0.000122481,6.28771e-07,6.64841e-10,0.00708003,0.000123741,6.30765e-07,6.10972e-10,0.00720441,0.000125004,6.32598e-07,6.16543e-10,0.00733004,0.000126271,6.34448e-07,6.48204e-10,0.00745695,0.000127542,6.36392e-07,5.15835e-10,0.00758513,0.000128816,6.3794e-07,5.48103e-10,0.00771458,0.000130094,6.39584e-07,1.01706e-09,0.00784532,0.000131376,6.42635e-07,4.0283e-11,0.00797734,0.000132661,6.42756e-07,6.84471e-10,0.00811064,0.000133949,6.4481e-07,9.47144e-10,0.00824524,0.000135241,6.47651e-07,1.83472e-10,0.00838112,0.000136537,6.48201e-07,1.11296e-09,0.00851831,0.000137837,6.5154e-07,2.13163e-11,0.0086568,0.00013914,6.51604e-07,6.64462e-10,0.00879659,0.000140445,6.53598e-07,1.04613e-09,0.00893769,0.000141756,6.56736e-07,-1.92377e-10,0.0090801,0.000143069,6.56159e-07,1.58601e-09,0.00922383,0.000144386,6.60917e-07,-5.63754e-10,0.00936888,0.000145706,6.59226e-07,1.60033e-09,0.00951524,0.000147029,6.64027e-07,-2.49543e-10,0.00966294,0.000148356,6.63278e-07,1.26043e-09,0.00981196,0.000149687,6.67059e-07,-1.35572e-10,0.00996231,0.00015102,6.66653e-07,1.14458e-09,0.010114,0.000152357,6.70086e-07,2.13864e-10,0.010267,0.000153698,6.70728e-07,7.93856e-10,0.0104214,0.000155042,6.73109e-07,3.36077e-10,0.0105771,0.000156389,6.74118e-07,6.55765e-10,0.0107342,0.000157739,6.76085e-07,7.66211e-10,0.0108926,0.000159094,6.78384e-07,4.66116e-12,0.0110524,0.000160451,6.78398e-07,1.07775e-09,0.0112135,0.000161811,6.81631e-07,3.41023e-10,0.011376,0.000163175,6.82654e-07,3.5205e-10,0.0115398,0.000164541,6.8371e-07,1.04473e-09,0.0117051,0.000165912,6.86844e-07,1.25757e-10,0.0118717,0.000167286,6.87222e-07,3.14818e-10,0.0120396,0.000168661,6.88166e-07,1.40886e-09,0.012209,0.000170042,6.92393e-07,-3.62244e-10,0.0123797,0.000171425,6.91306e-07,9.71397e-10,0.0125518,0.000172811,6.9422e-07,2.02003e-10,0.0127253,0.0001742,6.94826e-07,1.01448e-09,0.0129002,0.000175593,6.97869e-07,3.96653e-10,0.0130765,0.00017699,6.99059e-07,1.92927e-10,0.0132542,0.000178388,6.99638e-07,6.94305e-10,0.0134333,0.00017979,7.01721e-07,7.55108e-10,0.0136138,0.000181195,7.03986e-07,1.05918e-11,0.0137957,0.000182603,7.04018e-07,1.06513e-09,0.013979,0.000184015,7.07214e-07,3.85512e-10,0.0141637,0.00018543,7.0837e-07,1.86769e-10,0.0143499,0.000186848,7.0893e-07,7.30116e-10,0.0145374,0.000188268,7.11121e-07,6.17983e-10,0.0147264,0.000189692,7.12975e-07,5.23282e-10,0.0149168,0.000191119,7.14545e-07,8.28398e-11,0.0151087,0.000192549,7.14793e-07,1.0081e-09,0.0153019,0.000193981,7.17817e-07,5.41244e-10,0.0154966,0.000195418,7.19441e-07,-3.7907e-10,0.0156928,0.000196856,7.18304e-07,1.90641e-09,0.0158903,0.000198298,7.24023e-07,-7.27387e-10,0.0160893,0.000199744,7.21841e-07,1.00317e-09,0.0162898,0.000201191,7.24851e-07,4.39949e-10,0.0164917,0.000202642,7.2617e-07,9.6234e-10,0.0166951,0.000204097,7.29057e-07,-5.64019e-10,0.0168999,0.000205554,7.27365e-07,1.29374e-09,0.0171062,0.000207012,7.31247e-07,9.77025e-10,0.017314,0.000208478,7.34178e-07,-1.47651e-09,0.0175232,0.000209942,7.29748e-07,3.06636e-09,0.0177338,0.00021141,7.38947e-07,-1.47573e-09,0.017946,0.000212884,7.3452e-07,9.7386e-10,0.0181596,0.000214356,7.37442e-07,1.30562e-09,0.0183747,0.000215835,7.41358e-07,-6.08376e-10,0.0185913,0.000217315,7.39533e-07,1.12785e-09,0.0188093,0.000218798,7.42917e-07,-1.77711e-10,0.0190289,0.000220283,7.42384e-07,1.44562e-09,0.0192499,0.000221772,7.46721e-07,-1.68825e-11,0.0194724,0.000223266,7.4667e-07,4.84533e-10,0.0196964,0.000224761,7.48124e-07,-5.85298e-11,0.0199219,0.000226257,7.47948e-07,1.61217e-09,0.0201489,0.000227757,7.52785e-07,-8.02136e-10,0.0203775,0.00022926,7.50378e-07,1.59637e-09,0.0206075,0.000230766,7.55167e-07,4.47168e-12,0.020839,0.000232276,7.55181e-07,2.48387e-10,0.021072,0.000233787,7.55926e-07,8.6474e-10,0.0213066,0.000235302,7.5852e-07,1.78299e-11,0.0215426,0.000236819,7.58573e-07,9.26567e-10,0.0217802,0.000238339,7.61353e-07,1.34529e-12,0.0220193,0.000239862,7.61357e-07,9.30659e-10,0.0222599,0.000241387,7.64149e-07,1.34529e-12,0.0225021,0.000242915,7.64153e-07,9.26567e-10,0.0227458,0.000244447,7.66933e-07,1.76215e-11,0.022991,0.00024598,7.66986e-07,8.65536e-10,0.0232377,0.000247517,7.69582e-07,2.45677e-10,0.023486,0.000249057,7.70319e-07,1.44193e-11,0.0237358,0.000250598,7.70363e-07,1.55918e-09,0.0239872,0.000252143,7.7504e-07,-6.63173e-10,0.0242401,0.000253691,7.73051e-07,1.09357e-09,0.0244946,0.000255241,7.76331e-07,1.41919e-11,0.0247506,0.000256793,7.76374e-07,7.12248e-10,0.0250082,0.000258348,7.78511e-07,8.62049e-10,0.0252673,0.000259908,7.81097e-07,-4.35061e-10,0.025528,0.000261469,7.79792e-07,8.7825e-10,0.0257902,0.000263031,7.82426e-07,6.47181e-10,0.0260541,0.000264598,7.84368e-07,2.58448e-10,0.0263194,0.000266167,7.85143e-07,1.81558e-10,0.0265864,0.000267738,7.85688e-07,8.78041e-10,0.0268549,0.000269312,7.88322e-07,3.15102e-11,0.027125,0.000270889,7.88417e-07,8.58525e-10,0.0273967,0.000272468,7.90992e-07,2.59812e-10,0.02767,0.000274051,7.91772e-07,-3.5224e-11,0.0279448,0.000275634,7.91666e-07,1.74377e-09,0.0282212,0.000277223,7.96897e-07,-1.35196e-09,0.0284992,0.000278813,7.92841e-07,1.80141e-09,0.0287788,0.000280404,7.98246e-07,-2.65629e-10,0.0290601,0.000281999,7.97449e-07,1.12374e-09,0.0293428,0.000283598,8.0082e-07,-5.04106e-10,0.0296272,0.000285198,7.99308e-07,8.92764e-10,0.0299132,0.000286799,8.01986e-07,6.58379e-10,0.0302008,0.000288405,8.03961e-07,1.98971e-10,0.0304901,0.000290014,8.04558e-07,4.08382e-10,0.0307809,0.000291624,8.05783e-07,3.01839e-11,0.0310733,0.000293236,8.05874e-07,1.33343e-09,0.0313673,0.000294851,8.09874e-07,2.2419e-10,0.031663,0.000296472,8.10547e-07,-3.67606e-10,0.0319603,0.000298092,8.09444e-07,1.24624e-09,0.0322592,0.000299714,8.13182e-07,-8.92025e-10,0.0325597,0.000301338,8.10506e-07,2.32183e-09,0.0328619,0.000302966,8.17472e-07,-9.44719e-10,0.0331657,0.000304598,8.14638e-07,1.45703e-09,0.0334711,0.000306232,8.19009e-07,-1.15805e-09,0.0337781,0.000307866,8.15535e-07,3.17507e-09,0.0340868,0.000309507,8.2506e-07,-4.09161e-09,0.0343971,0.000311145,8.12785e-07,5.74079e-09,0.0347091,0.000312788,8.30007e-07,-3.97034e-09,0.0350227,0.000314436,8.18096e-07,2.68985e-09,0.035338,0.00031608,8.26166e-07,6.61676e-10,0.0356549,0.000317734,8.28151e-07,-1.61123e-09,0.0359734,0.000319386,8.23317e-07,2.05786e-09,0.0362936,0.000321038,8.29491e-07,8.30388e-10,0.0366155,0.0003227,8.31982e-07,-1.65424e-09,0.036939,0.000324359,8.27019e-07,2.06129e-09,0.0372642,0.000326019,8.33203e-07,8.59719e-10,0.0375911,0.000327688,8.35782e-07,-1.77488e-09,0.0379196,0.000329354,8.30458e-07,2.51464e-09,0.0382498,0.000331023,8.38002e-07,-8.33135e-10,0.0385817,0.000332696,8.35502e-07,8.17825e-10,0.0389152,0.00033437,8.37956e-07,1.28718e-09,0.0392504,0.00033605,8.41817e-07,-2.2413e-09,0.0395873,0.000337727,8.35093e-07,3.95265e-09,0.0399258,0.000339409,8.46951e-07,-2.39332e-09,0.0402661,0.000341095,8.39771e-07,1.89533e-09,0.040608,0.000342781,8.45457e-07,-1.46271e-09,0.0409517,0.000344467,8.41069e-07,3.95554e-09,0.041297,0.000346161,8.52936e-07,-3.18369e-09,0.041644,0.000347857,8.43385e-07,1.32873e-09,0.0419927,0.000349548,8.47371e-07,1.59402e-09,0.0423431,0.000351248,8.52153e-07,-2.54336e-10,0.0426952,0.000352951,8.5139e-07,-5.76676e-10,0.043049,0.000354652,8.4966e-07,2.56114e-09,0.0434045,0.000356359,8.57343e-07,-2.21744e-09,0.0437617,0.000358067,8.50691e-07,2.58344e-09,0.0441206,0.000359776,8.58441e-07,-6.65826e-10,0.0444813,0.000361491,8.56444e-07,7.99218e-11,0.0448436,0.000363204,8.56684e-07,3.46063e-10,0.0452077,0.000364919,8.57722e-07,2.26116e-09,0.0455734,0.000366641,8.64505e-07,-1.94005e-09,0.045941,0.000368364,8.58685e-07,1.77384e-09,0.0463102,0.000370087,8.64007e-07,-1.43005e-09,0.0466811,0.000371811,8.59717e-07,3.94634e-09,0.0470538,0.000373542,8.71556e-07,-3.17946e-09,0.0474282,0.000375276,8.62017e-07,1.32104e-09,0.0478043,0.000377003,8.6598e-07,1.62045e-09,0.0481822,0.00037874,8.70842e-07,-3.52297e-10,0.0485618,0.000380481,8.69785e-07,-2.11211e-10,0.0489432,0.00038222,8.69151e-07,1.19716e-09,0.0493263,0.000383962,8.72743e-07,-8.52026e-10,0.0497111,0.000385705,8.70187e-07,2.21092e-09,0.0500977,0.000387452,8.76819e-07,-5.41339e-10,0.050486,0.000389204,8.75195e-07,-4.5361e-11,0.0508761,0.000390954,8.75059e-07,7.22669e-10,0.0512679,0.000392706,8.77227e-07,8.79936e-10,0.0516615,0.000394463,8.79867e-07,-5.17048e-10,0.0520568,0.000396222,8.78316e-07,1.18833e-09,0.0524539,0.000397982,8.81881e-07,-5.11022e-10,0.0528528,0.000399744,8.80348e-07,8.55683e-10,0.0532534,0.000401507,8.82915e-07,8.13562e-10,0.0536558,0.000403276,8.85356e-07,-3.84603e-10,0.05406,0.000405045,8.84202e-07,7.24962e-10,0.0544659,0.000406816,8.86377e-07,1.20986e-09,0.0548736,0.000408592,8.90006e-07,-1.83896e-09,0.0552831,0.000410367,8.84489e-07,2.42071e-09,0.0556944,0.000412143,8.91751e-07,-3.93413e-10,0.0561074,0.000413925,8.90571e-07,-8.46967e-10,0.0565222,0.000415704,8.8803e-07,3.78122e-09,0.0569388,0.000417491,8.99374e-07,-3.1021e-09,0.0573572,0.000419281,8.90068e-07,1.17658e-09,0.0577774,0.000421064,8.93597e-07,2.12117e-09,0.0581993,0.000422858,8.99961e-07,-2.21068e-09,0.0586231,0.000424651,8.93329e-07,2.9961e-09,0.0590486,0.000426447,9.02317e-07,-2.32311e-09,0.059476,0.000428244,8.95348e-07,2.57122e-09,0.0599051,0.000430043,9.03062e-07,-5.11098e-10,0.0603361,0.000431847,9.01528e-07,-5.27166e-10,0.0607688,0.000433649,8.99947e-07,2.61984e-09,0.0612034,0.000435457,9.07806e-07,-2.50141e-09,0.0616397,0.000437265,9.00302e-07,3.66045e-09,0.0620779,0.000439076,9.11283e-07,-4.68977e-09,0.0625179,0.000440885,8.97214e-07,7.64783e-09,0.0629597,0.000442702,9.20158e-07,-7.27499e-09,0.0634033,0.000444521,8.98333e-07,6.55113e-09,0.0638487,0.000446337,9.17986e-07,-4.02844e-09,0.0642959,0.000448161,9.05901e-07,2.11196e-09,0.064745,0.000449979,9.12236e-07,3.03125e-09,0.0651959,0.000451813,9.2133e-07,-6.78648e-09,0.0656486,0.000453635,9.00971e-07,9.21375e-09,0.0661032,0.000455464,9.28612e-07,-7.71684e-09,0.0665596,0.000457299,9.05462e-07,6.7522e-09,0.0670178,0.00045913,9.25718e-07,-4.3907e-09,0.0674778,0.000460968,9.12546e-07,3.36e-09,0.0679397,0.000462803,9.22626e-07,-1.59876e-09,0.0684034,0.000464644,9.1783e-07,3.0351e-09,0.068869,0.000466488,9.26935e-07,-3.09101e-09,0.0693364,0.000468333,9.17662e-07,1.8785e-09,0.0698057,0.000470174,9.23298e-07,3.02733e-09,0.0702768,0.00047203,9.3238e-07,-6.53722e-09,0.0707497,0.000473875,9.12768e-07,8.22054e-09,0.0712245,0.000475725,9.37429e-07,-3.99325e-09,0.0717012,0.000477588,9.2545e-07,3.01839e-10,0.0721797,0.00047944,9.26355e-07,2.78597e-09,0.0726601,0.000481301,9.34713e-07,-3.99507e-09,0.0731423,0.000483158,9.22728e-07,5.7435e-09,0.0736264,0.000485021,9.39958e-07,-4.07776e-09,0.0741123,0.000486888,9.27725e-07,3.11695e-09,0.0746002,0.000488753,9.37076e-07,-9.39394e-10,0.0750898,0.000490625,9.34258e-07,6.4055e-10,0.0755814,0.000492495,9.3618e-07,-1.62265e-09,0.0760748,0.000494363,9.31312e-07,5.84995e-09,0.0765701,0.000496243,9.48861e-07,-6.87601e-09,0.0770673,0.00049812,9.28233e-07,6.75296e-09,0.0775664,0.000499997,9.48492e-07,-5.23467e-09,0.0780673,0.000501878,9.32788e-07,6.73523e-09,0.0785701,0.000503764,9.52994e-07,-6.80514e-09,0.0790748,0.000505649,9.32578e-07,5.5842e-09,0.0795814,0.000507531,9.49331e-07,-6.30583e-10,0.0800899,0.000509428,9.47439e-07,-3.0618e-09,0.0806003,0.000511314,9.38254e-07,5.4273e-09,0.0811125,0.000513206,9.54536e-07,-3.74627e-09,0.0816267,0.000515104,9.43297e-07,2.10713e-09,0.0821427,0.000516997,9.49618e-07,2.76839e-09,0.0826607,0.000518905,9.57924e-07,-5.73006e-09,0.0831805,0.000520803,9.40733e-07,5.25072e-09,0.0837023,0.0005227,9.56486e-07,-3.71718e-10,0.084226,0.000524612,9.5537e-07,-3.76404e-09,0.0847515,0.000526512,9.44078e-07,7.97735e-09,0.085279,0.000528424,9.6801e-07,-5.79367e-09,0.0858084,0.000530343,9.50629e-07,2.96268e-10,0.0863397,0.000532245,9.51518e-07,4.6086e-09,0.0868729,0.000534162,9.65344e-07,-3.82947e-09,0.087408,0.000536081,9.53856e-07,3.25861e-09,0.087945,0.000537998,9.63631e-07,-1.7543e-09,0.088484,0.00053992,9.58368e-07,3.75849e-09,0.0890249,0.000541848,9.69644e-07,-5.82891e-09,0.0895677,0.00054377,9.52157e-07,4.65593e-09,0.0901124,0.000545688,9.66125e-07,2.10643e-09,0.0906591,0.000547627,9.72444e-07,-5.63099e-09,0.0912077,0.000549555,9.55551e-07,5.51627e-09,0.0917582,0.000551483,9.721e-07,-1.53292e-09,0.0923106,0.000553422,9.67501e-07,6.15311e-10,0.092865,0.000555359,9.69347e-07,-9.28291e-10,0.0934213,0.000557295,9.66562e-07,3.09774e-09,0.0939796,0.000559237,9.75856e-07,-4.01186e-09,0.0945398,0.000561177,9.6382e-07,5.49892e-09,0.095102,0.000563121,9.80317e-07,-3.08258e-09,0.0956661,0.000565073,9.71069e-07,-6.19176e-10,0.0962321,0.000567013,9.69212e-07,5.55932e-09,0.0968001,0.000568968,9.8589e-07,-6.71704e-09,0.09737,0.00057092,9.65738e-07,6.40762e-09,0.0979419,0.00057287,9.84961e-07,-4.0122e-09,0.0985158,0.000574828,9.72925e-07,2.19059e-09,0.0990916,0.000576781,9.79496e-07,2.70048e-09,0.0996693,0.000578748,9.87598e-07,-5.54193e-09,0.100249,0.000580706,9.70972e-07,4.56597e-09,0.100831,0.000582662,9.8467e-07,2.17923e-09,0.101414,0.000584638,9.91208e-07,-5.83232e-09,0.102,0.000586603,9.73711e-07,6.24884e-09,0.102588,0.000588569,9.92457e-07,-4.26178e-09,0.103177,0.000590541,9.79672e-07,3.34781e-09,0.103769,0.00059251,9.89715e-07,-1.67904e-09,0.104362,0.000594485,9.84678e-07,3.36839e-09,0.104958,0.000596464,9.94783e-07,-4.34397e-09,0.105555,0.000598441,9.81751e-07,6.55696e-09,0.106155,0.000600424,1.00142e-06,-6.98272e-09,0.106756,0.000602406,9.80474e-07,6.4728e-09,0.107359,0.000604386,9.99893e-07,-4.00742e-09,0.107965,0.000606374,9.8787e-07,2.10654e-09,0.108572,0.000608356,9.9419e-07,3.0318e-09,0.109181,0.000610353,1.00329e-06,-6.7832e-09,0.109793,0.00061234,9.82936e-07,9.1998e-09,0.110406,0.000614333,1.01054e-06,-7.6642e-09,0.111021,0.000616331,9.87543e-07,6.55579e-09,0.111639,0.000618326,1.00721e-06,-3.65791e-09,0.112258,0.000620329,9.96236e-07,6.25467e-10,0.112879,0.000622324,9.98113e-07,1.15593e-09,0.113503,0.000624323,1.00158e-06,2.20158e-09,0.114128,0.000626333,1.00819e-06,-2.51191e-09,0.114755,0.000628342,1.00065e-06,3.95517e-10,0.115385,0.000630345,1.00184e-06,9.29807e-10,0.116016,0.000632351,1.00463e-06,3.33599e-09,0.116649,0.00063437,1.01463e-06,-6.82329e-09,0.117285,0.000636379,9.94163e-07,9.05595e-09,0.117922,0.000638395,1.02133e-06,-7.04862e-09,0.118562,0.000640416,1.00019e-06,4.23737e-09,0.119203,0.000642429,1.0129e-06,-2.45033e-09,0.119847,0.000644448,1.00555e-06,5.56395e-09,0.120492,0.000646475,1.02224e-06,-4.9043e-09,0.121139,0.000648505,1.00753e-06,-8.47952e-10,0.121789,0.000650518,1.00498e-06,8.29622e-09,0.122441,0.000652553,1.02987e-06,-9.98538e-09,0.123094,0.000654582,9.99914e-07,9.2936e-09,0.12375,0.00065661,1.02779e-06,-4.83707e-09,0.124407,0.000658651,1.01328e-06,2.60411e-09,0.125067,0.000660685,1.0211e-06,-5.57945e-09,0.125729,0.000662711,1.00436e-06,1.22631e-08,0.126392,0.000664756,1.04115e-06,-1.36704e-08,0.127058,0.000666798,1.00014e-06,1.26161e-08,0.127726,0.000668836,1.03798e-06,-6.99155e-09,0.128396,0.000670891,1.01701e-06,4.48836e-10,0.129068,0.000672926,1.01836e-06,5.19606e-09,0.129742,0.000674978,1.03394e-06,-6.3319e-09,0.130418,0.000677027,1.01495e-06,5.2305e-09,0.131096,0.000679073,1.03064e-06,3.11123e-10,0.131776,0.000681135,1.03157e-06,-6.47511e-09,0.132458,0.000683179,1.01215e-06,1.06882e-08,0.133142,0.000685235,1.04421e-06,-6.47519e-09,0.133829,0.000687304,1.02479e-06,3.11237e-10,0.134517,0.000689355,1.02572e-06,5.23035e-09,0.135207,0.000691422,1.04141e-06,-6.3316e-09,0.1359,0.000693486,1.02242e-06,5.19484e-09,0.136594,0.000695546,1.038e-06,4.53497e-10,0.137291,0.000697623,1.03936e-06,-7.00891e-09,0.137989,0.000699681,1.01834e-06,1.2681e-08,0.13869,0.000701756,1.05638e-06,-1.39128e-08,0.139393,0.000703827,1.01464e-06,1.31679e-08,0.140098,0.000705896,1.05414e-06,-8.95659e-09,0.140805,0.000707977,1.02727e-06,7.75742e-09,0.141514,0.000710055,1.05055e-06,-7.17182e-09,0.142225,0.000712135,1.02903e-06,6.02862e-09,0.142938,0.000714211,1.04712e-06,-2.04163e-09,0.143653,0.000716299,1.04099e-06,2.13792e-09,0.144371,0.000718387,1.04741e-06,-6.51009e-09,0.14509,0.000720462,1.02787e-06,9.00123e-09,0.145812,0.000722545,1.05488e-06,3.07523e-10,0.146535,0.000724656,1.0558e-06,-1.02312e-08,0.147261,0.000726737,1.02511e-06,1.0815e-08,0.147989,0.000728819,1.05755e-06,-3.22681e-09,0.148719,0.000730925,1.04787e-06,2.09244e-09,0.14945,0.000733027,1.05415e-06,-5.143e-09,0.150185,0.00073512,1.03872e-06,3.57844e-09,0.150921,0.000737208,1.04946e-06,5.73027e-09,0.151659,0.000739324,1.06665e-06,-1.15983e-08,0.152399,0.000741423,1.03185e-06,1.08605e-08,0.153142,0.000743519,1.06443e-06,-2.04106e-09,0.153886,0.000745642,1.05831e-06,-2.69642e-09,0.154633,0.00074775,1.05022e-06,-2.07425e-09,0.155382,0.000749844,1.044e-06,1.09934e-08,0.156133,0.000751965,1.07698e-06,-1.20972e-08,0.156886,0.000754083,1.04069e-06,7.59288e-09,0.157641,0.000756187,1.06347e-06,-3.37305e-09,0.158398,0.000758304,1.05335e-06,5.89921e-09,0.159158,0.000760428,1.07104e-06,-5.32248e-09,0.159919,0.000762554,1.05508e-06,4.8927e-10,0.160683,0.000764666,1.05654e-06,3.36547e-09,0.161448,0.000766789,1.06664e-06,9.50081e-10,0.162216,0.000768925,1.06949e-06,-7.16568e-09,0.162986,0.000771043,1.04799e-06,1.28114e-08,0.163758,0.000773177,1.08643e-06,-1.42774e-08,0.164533,0.000775307,1.0436e-06,1.44956e-08,0.165309,0.000777438,1.08708e-06,-1.39025e-08,0.166087,0.00077957,1.04538e-06,1.13118e-08,0.166868,0.000781695,1.07931e-06,-1.54224e-09,0.167651,0.000783849,1.07468e-06,-5.14312e-09,0.168436,0.000785983,1.05925e-06,7.21381e-09,0.169223,0.000788123,1.0809e-06,-8.81096e-09,0.170012,0.000790259,1.05446e-06,1.31289e-08,0.170803,0.000792407,1.09385e-06,-1.39022e-08,0.171597,0.000794553,1.05214e-06,1.26775e-08,0.172392,0.000796695,1.09018e-06,-7.00557e-09,0.17319,0.000798855,1.06916e-06,4.43796e-10,0.17399,0.000800994,1.07049e-06,5.23031e-09,0.174792,0.000803151,1.08618e-06,-6.46397e-09,0.175596,0.000805304,1.06679e-06,5.72444e-09,0.176403,0.000807455,1.08396e-06,-1.53254e-09,0.177211,0.000809618,1.07937e-06,4.05673e-10,0.178022,0.000811778,1.08058e-06,-9.01916e-11,0.178835,0.000813939,1.08031e-06,-4.49821e-11,0.17965,0.000816099,1.08018e-06,2.70234e-10,0.180467,0.00081826,1.08099e-06,-1.03603e-09,0.181286,0.000820419,1.07788e-06,3.87392e-09,0.182108,0.000822587,1.0895e-06,4.41522e-10,0.182932,0.000824767,1.09083e-06,-5.63997e-09,0.183758,0.000826932,1.07391e-06,7.21707e-09,0.184586,0.000829101,1.09556e-06,-8.32718e-09,0.185416,0.000831267,1.07058e-06,1.11907e-08,0.186248,0.000833442,1.10415e-06,-6.63336e-09,0.187083,0.00083563,1.08425e-06,4.41484e-10,0.187919,0.0008378,1.08557e-06,4.86754e-09,0.188758,0.000839986,1.10017e-06,-5.01041e-09,0.189599,0.000842171,1.08514e-06,2.72811e-10,0.190443,0.000844342,1.08596e-06,3.91916e-09,0.191288,0.000846526,1.09772e-06,-1.04819e-09,0.192136,0.000848718,1.09457e-06,2.73531e-10,0.192985,0.000850908,1.0954e-06,-4.58916e-11,0.193837,0.000853099,1.09526e-06,-9.01158e-11,0.194692,0.000855289,1.09499e-06,4.06506e-10,0.195548,0.00085748,1.09621e-06,-1.53595e-09,0.196407,0.000859668,1.0916e-06,5.73717e-09,0.197267,0.000861869,1.10881e-06,-6.51164e-09,0.19813,0.000864067,1.08928e-06,5.40831e-09,0.198995,0.000866261,1.1055e-06,-2.20401e-10,0.199863,0.000868472,1.10484e-06,-4.52652e-09,0.200732,0.000870668,1.09126e-06,3.42508e-09,0.201604,0.000872861,1.10153e-06,5.72762e-09,0.202478,0.000875081,1.11872e-06,-1.14344e-08,0.203354,0.000877284,1.08441e-06,1.02076e-08,0.204233,0.000879484,1.11504e-06,4.06355e-10,0.205113,0.000881715,1.11626e-06,-1.18329e-08,0.205996,0.000883912,1.08076e-06,1.71227e-08,0.206881,0.000886125,1.13213e-06,-1.19546e-08,0.207768,0.000888353,1.09626e-06,8.93465e-10,0.208658,0.000890548,1.09894e-06,8.38062e-09,0.209549,0.000892771,1.12408e-06,-4.61353e-09,0.210443,0.000895006,1.11024e-06,-4.82756e-09,0.211339,0.000897212,1.09576e-06,9.02245e-09,0.212238,0.00089943,1.12283e-06,-1.45997e-09,0.213138,0.000901672,1.11845e-06,-3.18255e-09,0.214041,0.000903899,1.1089e-06,-7.11073e-10,0.214946,0.000906115,1.10677e-06,6.02692e-09,0.215853,0.000908346,1.12485e-06,-8.49548e-09,0.216763,0.00091057,1.09936e-06,1.30537e-08,0.217675,0.000912808,1.13852e-06,-1.3917e-08,0.218588,0.000915044,1.09677e-06,1.28121e-08,0.219505,0.000917276,1.13521e-06,-7.5288e-09,0.220423,0.000919523,1.11262e-06,2.40205e-09,0.221344,0.000921756,1.11983e-06,-2.07941e-09,0.222267,0.000923989,1.11359e-06,5.91551e-09,0.223192,0.000926234,1.13134e-06,-6.68149e-09,0.224119,0.000928477,1.11129e-06,5.90929e-09,0.225049,0.000930717,1.12902e-06,-2.05436e-09,0.22598,0.000932969,1.12286e-06,2.30807e-09,0.226915,0.000935222,1.12978e-06,-7.17796e-09,0.227851,0.00093746,1.10825e-06,1.15028e-08,0.228789,0.000939711,1.14276e-06,-9.03083e-09,0.22973,0.000941969,1.11566e-06,9.71932e-09,0.230673,0.00094423,1.14482e-06,-1.49452e-08,0.231619,0.000946474,1.09998e-06,2.02591e-08,0.232566,0.000948735,1.16076e-06,-2.13879e-08,0.233516,0.000950993,1.0966e-06,2.05888e-08,0.234468,0.000953247,1.15837e-06,-1.62642e-08,0.235423,0.000955515,1.10957e-06,1.46658e-08,0.236379,0.000957779,1.15357e-06,-1.25966e-08,0.237338,0.000960048,1.11578e-06,5.91793e-09,0.238299,0.000962297,1.13353e-06,3.82602e-09,0.239263,0.000964576,1.14501e-06,-6.3208e-09,0.240229,0.000966847,1.12605e-06,6.55613e-09,0.241197,0.000969119,1.14572e-06,-5.00268e-09,0.242167,0.000971395,1.13071e-06,-1.44659e-09,0.243139,0.000973652,1.12637e-06,1.07891e-08,0.244114,0.000975937,1.15874e-06,-1.19073e-08,0.245091,0.000978219,1.12302e-06,7.03782e-09,0.246071,0.000980486,1.14413e-06,-1.34276e-09,0.247052,0.00098277,1.1401e-06,-1.66669e-09,0.248036,0.000985046,1.1351e-06,8.00935e-09,0.249022,0.00098734,1.15913e-06,-1.54694e-08,0.250011,0.000989612,1.11272e-06,2.4066e-08,0.251002,0.000991909,1.18492e-06,-2.11901e-08,0.251995,0.000994215,1.12135e-06,1.08973e-09,0.25299,0.000996461,1.12462e-06,1.68311e-08,0.253988,0.000998761,1.17511e-06,-8.8094e-09,0.254987,0.00100109,1.14868e-06,-1.13958e-08,0.25599,0.00100335,1.1145e-06,2.45902e-08,0.256994,0.00100565,1.18827e-06,-2.73603e-08,0.258001,0.00100795,1.10618e-06,2.52464e-08,0.25901,0.00101023,1.18192e-06,-1.40207e-08,0.260021,0.00101256,1.13986e-06,1.03387e-09,0.261035,0.00101484,1.14296e-06,9.8853e-09,0.262051,0.00101715,1.17262e-06,-1.07726e-08,0.263069,0.00101947,1.1403e-06,3.40272e-09,0.26409,0.00102176,1.15051e-06,-2.83827e-09,0.265113,0.00102405,1.142e-06,7.95039e-09,0.266138,0.00102636,1.16585e-06,8.39047e-10,0.267166,0.00102869,1.16836e-06,-1.13066e-08,0.268196,0.00103099,1.13444e-06,1.4585e-08,0.269228,0.00103331,1.1782e-06,-1.72314e-08,0.270262,0.00103561,1.1265e-06,2.45382e-08,0.271299,0.00103794,1.20012e-06,-2.13166e-08,0.272338,0.00104028,1.13617e-06,1.12364e-09,0.273379,0.00104255,1.13954e-06,1.68221e-08,0.274423,0.00104488,1.19001e-06,-8.80736e-09,0.275469,0.00104723,1.16358e-06,-1.13948e-08,0.276518,0.00104953,1.1294e-06,2.45839e-08,0.277568,0.00105186,1.20315e-06,-2.73361e-08,0.278621,0.00105418,1.12114e-06,2.51559e-08,0.279677,0.0010565,1.19661e-06,-1.36832e-08,0.280734,0.00105885,1.15556e-06,-2.25706e-10,0.281794,0.00106116,1.15488e-06,1.45862e-08,0.282857,0.00106352,1.19864e-06,-2.83167e-08,0.283921,0.00106583,1.11369e-06,3.90759e-08,0.284988,0.00106817,1.23092e-06,-3.85801e-08,0.286058,0.00107052,1.11518e-06,2.58375e-08,0.287129,0.00107283,1.19269e-06,-5.16498e-09,0.288203,0.0010752,1.1772e-06,-5.17768e-09,0.28928,0.00107754,1.16167e-06,-3.92671e-09,0.290358,0.00107985,1.14988e-06,2.08846e-08,0.29144,0.00108221,1.21254e-06,-2.00072e-08,0.292523,0.00108458,1.15252e-06,-4.60659e-10,0.293609,0.00108688,1.15114e-06,2.18499e-08,0.294697,0.00108925,1.21669e-06,-2.73343e-08,0.295787,0.0010916,1.13468e-06,2.78826e-08,0.29688,0.00109395,1.21833e-06,-2.45915e-08,0.297975,0.00109632,1.14456e-06,1.08787e-08,0.299073,0.00109864,1.17719e-06,1.08788e-08,0.300172,0.00110102,1.20983e-06,-2.45915e-08,0.301275,0.00110337,1.13605e-06,2.78828e-08,0.302379,0.00110573,1.2197e-06,-2.73348e-08,0.303486,0.00110808,1.1377e-06,2.18518e-08,0.304595,0.00111042,1.20325e-06,-4.67556e-10,0.305707,0.00111283,1.20185e-06,-1.99816e-08,0.306821,0.00111517,1.14191e-06,2.07891e-08,0.307937,0.00111752,1.20427e-06,-3.57026e-09,0.309056,0.00111992,1.19356e-06,-6.50797e-09,0.310177,0.00112228,1.17404e-06,-2.00165e-10,0.3113,0.00112463,1.17344e-06,7.30874e-09,0.312426,0.001127,1.19536e-06,7.67424e-10,0.313554,0.00112939,1.19767e-06,-1.03784e-08,0.314685,0.00113176,1.16653e-06,1.09437e-08,0.315818,0.00113412,1.19936e-06,-3.59406e-09,0.316953,0.00113651,1.18858e-06,3.43251e-09,0.318091,0.0011389,1.19888e-06,-1.0136e-08,0.319231,0.00114127,1.16847e-06,7.30915e-09,0.320374,0.00114363,1.1904e-06,1.07018e-08,0.321518,0.00114604,1.2225e-06,-2.03137e-08,0.322666,0.00114842,1.16156e-06,1.09484e-08,0.323815,0.00115078,1.19441e-06,6.32224e-09,0.324967,0.00115319,1.21337e-06,-6.43509e-09,0.326122,0.00115559,1.19407e-06,-1.03842e-08,0.327278,0.00115795,1.16291e-06,1.81697e-08,0.328438,0.00116033,1.21742e-06,-2.6901e-09,0.329599,0.00116276,1.20935e-06,-7.40939e-09,0.330763,0.00116515,1.18713e-06,2.52533e-09,0.331929,0.00116754,1.1947e-06,-2.69191e-09,0.333098,0.00116992,1.18663e-06,8.24218e-09,0.334269,0.00117232,1.21135e-06,-4.74377e-10,0.335443,0.00117474,1.20993e-06,-6.34471e-09,0.336619,0.00117714,1.1909e-06,-3.94922e-09,0.337797,0.00117951,1.17905e-06,2.21417e-08,0.338978,0.00118193,1.24547e-06,-2.50128e-08,0.340161,0.00118435,1.17043e-06,1.8305e-08,0.341346,0.00118674,1.22535e-06,-1.84048e-08,0.342534,0.00118914,1.17013e-06,2.55121e-08,0.343725,0.00119156,1.24667e-06,-2.40389e-08,0.344917,0.00119398,1.17455e-06,1.10389e-08,0.346113,0.00119636,1.20767e-06,9.68574e-09,0.34731,0.0011988,1.23673e-06,-1.99797e-08,0.34851,0.00120122,1.17679e-06,1.06284e-08,0.349713,0.0012036,1.20867e-06,7.26868e-09,0.350917,0.00120604,1.23048e-06,-9.90072e-09,0.352125,0.00120847,1.20078e-06,2.53177e-09,0.353334,0.00121088,1.20837e-06,-2.26199e-10,0.354546,0.0012133,1.20769e-06,-1.62705e-09,0.355761,0.00121571,1.20281e-06,6.73435e-09,0.356978,0.00121813,1.22302e-06,4.49207e-09,0.358197,0.00122059,1.23649e-06,-2.47027e-08,0.359419,0.00122299,1.16238e-06,3.47142e-08,0.360643,0.00122542,1.26653e-06,-2.47472e-08,0.36187,0.00122788,1.19229e-06,4.66965e-09,0.363099,0.00123028,1.20629e-06,6.06872e-09,0.36433,0.00123271,1.2245e-06,8.57729e-10,0.365564,0.00123516,1.22707e-06,-9.49952e-09,0.366801,0.00123759,1.19858e-06,7.33792e-09,0.36804,0.00124001,1.22059e-06,9.95025e-09,0.369281,0.00124248,1.25044e-06,-1.73366e-08,0.370525,0.00124493,1.19843e-06,-2.08464e-10,0.371771,0.00124732,1.1978e-06,1.81704e-08,0.373019,0.00124977,1.25232e-06,-1.28683e-08,0.37427,0.00125224,1.21371e-06,3.50042e-09,0.375524,0.00125468,1.22421e-06,-1.1335e-09,0.37678,0.00125712,1.22081e-06,1.03345e-09,0.378038,0.00125957,1.22391e-06,-3.00023e-09,0.379299,0.00126201,1.21491e-06,1.09676e-08,0.380562,0.00126447,1.24781e-06,-1.10676e-08,0.381828,0.00126693,1.21461e-06,3.50042e-09,0.383096,0.00126937,1.22511e-06,-2.93403e-09,0.384366,0.00127181,1.21631e-06,8.23574e-09,0.385639,0.00127427,1.24102e-06,-2.06607e-10,0.386915,0.00127675,1.2404e-06,-7.40935e-09,0.388193,0.00127921,1.21817e-06,4.1761e-11,0.389473,0.00128165,1.21829e-06,7.24223e-09,0.390756,0.0012841,1.24002e-06,7.91564e-10,0.392042,0.00128659,1.2424e-06,-1.04086e-08,0.393329,0.00128904,1.21117e-06,1.10405e-08,0.39462,0.0012915,1.24429e-06,-3.951e-09,0.395912,0.00129397,1.23244e-06,4.7634e-09,0.397208,0.00129645,1.24673e-06,-1.51025e-08,0.398505,0.0012989,1.20142e-06,2.58443e-08,0.399805,0.00130138,1.27895e-06,-2.86702e-08,0.401108,0.00130385,1.19294e-06,2.92318e-08,0.402413,0.00130632,1.28064e-06,-2.86524e-08,0.403721,0.0013088,1.19468e-06,2.57731e-08,0.405031,0.00131127,1.272e-06,-1.48355e-08,0.406343,0.00131377,1.2275e-06,3.76652e-09,0.407658,0.00131623,1.23879e-06,-2.30784e-10,0.408976,0.00131871,1.2381e-06,-2.84331e-09,0.410296,0.00132118,1.22957e-06,1.16041e-08,0.411618,0.00132367,1.26438e-06,-1.37708e-08,0.412943,0.00132616,1.22307e-06,1.36768e-08,0.41427,0.00132865,1.2641e-06,-1.1134e-08,0.4156,0.00133114,1.2307e-06,1.05714e-09,0.416933,0.00133361,1.23387e-06,6.90538e-09,0.418267,0.00133609,1.25459e-06,1.12372e-09,0.419605,0.00133861,1.25796e-06,-1.14002e-08,0.420945,0.00134109,1.22376e-06,1.46747e-08,0.422287,0.00134358,1.26778e-06,-1.7496e-08,0.423632,0.00134606,1.21529e-06,2.5507e-08,0.424979,0.00134857,1.29182e-06,-2.49272e-08,0.426329,0.00135108,1.21703e-06,1.45972e-08,0.427681,0.00135356,1.26083e-06,-3.65935e-09,0.429036,0.00135607,1.24985e-06,4.00178e-11,0.430393,0.00135857,1.24997e-06,3.49917e-09,0.431753,0.00136108,1.26047e-06,-1.40366e-08,0.433116,0.00136356,1.21836e-06,2.28448e-08,0.43448,0.00136606,1.28689e-06,-1.77378e-08,0.435848,0.00136858,1.23368e-06,1.83043e-08,0.437218,0.0013711,1.28859e-06,-2.56769e-08,0.43859,0.0013736,1.21156e-06,2.47987e-08,0.439965,0.0013761,1.28595e-06,-1.39133e-08,0.441342,0.00137863,1.24421e-06,1.05202e-09,0.442722,0.00138112,1.24737e-06,9.70507e-09,0.444104,0.00138365,1.27649e-06,-1.00698e-08,0.445489,0.00138617,1.24628e-06,7.72123e-10,0.446877,0.00138867,1.24859e-06,6.98132e-09,0.448267,0.00139118,1.26954e-06,1.10477e-09,0.449659,0.00139373,1.27285e-06,-1.14003e-08,0.451054,0.00139624,1.23865e-06,1.4694e-08,0.452452,0.00139876,1.28273e-06,-1.75734e-08,0.453852,0.00140127,1.23001e-06,2.5797e-08,0.455254,0.00140381,1.3074e-06,-2.60097e-08,0.456659,0.00140635,1.22937e-06,1.86371e-08,0.458067,0.00140886,1.28529e-06,-1.8736e-08,0.459477,0.00141137,1.22908e-06,2.65048e-08,0.46089,0.00141391,1.30859e-06,-2.76784e-08,0.462305,0.00141645,1.22556e-06,2.46043e-08,0.463722,0.00141897,1.29937e-06,-1.11341e-08,0.465143,0.00142154,1.26597e-06,-9.87033e-09,0.466565,0.00142404,1.23636e-06,2.08131e-08,0.467991,0.00142657,1.2988e-06,-1.37773e-08,0.469419,0.00142913,1.25746e-06,4.49378e-09,0.470849,0.00143166,1.27094e-06,-4.19781e-09,0.472282,0.00143419,1.25835e-06,1.22975e-08,0.473717,0.00143674,1.29524e-06,-1.51902e-08,0.475155,0.00143929,1.24967e-06,1.86608e-08,0.476596,0.00144184,1.30566e-06,-2.96506e-08,0.478039,0.00144436,1.2167e-06,4.03368e-08,0.479485,0.00144692,1.33771e-06,-4.22896e-08,0.480933,0.00144947,1.21085e-06,3.94148e-08,0.482384,0.00145201,1.32909e-06,-2.59626e-08,0.483837,0.00145459,1.2512e-06,4.83124e-09,0.485293,0.0014571,1.2657e-06,6.63757e-09,0.486751,0.00145966,1.28561e-06,-1.57911e-09,0.488212,0.00146222,1.28087e-06,-3.21468e-10,0.489676,0.00146478,1.27991e-06,2.86517e-09,0.491142,0.00146735,1.2885e-06,-1.11392e-08,0.49261,0.00146989,1.25508e-06,1.18893e-08,0.494081,0.00147244,1.29075e-06,-6.61574e-09,0.495555,0.001475,1.27091e-06,1.45736e-08,0.497031,0.00147759,1.31463e-06,-2.18759e-08,0.49851,0.00148015,1.249e-06,1.33252e-08,0.499992,0.00148269,1.28897e-06,-1.62277e-09,0.501476,0.00148526,1.28411e-06,-6.83421e-09,0.502962,0.00148781,1.2636e-06,2.89596e-08,0.504451,0.00149042,1.35048e-06,-4.93997e-08,0.505943,0.00149298,1.20228e-06,4.94299e-08,0.507437,0.00149553,1.35057e-06,-2.91107e-08,0.508934,0.00149814,1.26324e-06,7.40848e-09,0.510434,0.00150069,1.28547e-06,-5.23187e-10,0.511936,0.00150326,1.2839e-06,-5.31585e-09,0.51344,0.00150581,1.26795e-06,2.17866e-08,0.514947,0.00150841,1.33331e-06,-2.22257e-08,0.516457,0.00151101,1.26663e-06,7.51178e-09,0.517969,0.00151357,1.28917e-06,-7.82128e-09,0.519484,0.00151613,1.2657e-06,2.37733e-08,0.521002,0.00151873,1.33702e-06,-2.76674e-08,0.522522,0.00152132,1.25402e-06,2.72917e-08,0.524044,0.00152391,1.3359e-06,-2.18949e-08,0.525569,0.00152652,1.27021e-06,6.83372e-10,0.527097,0.00152906,1.27226e-06,1.91613e-08,0.528628,0.00153166,1.32974e-06,-1.77241e-08,0.53016,0.00153427,1.27657e-06,-7.86963e-09,0.531696,0.0015368,1.25296e-06,4.92027e-08,0.533234,0.00153945,1.40057e-06,-6.9732e-08,0.534775,0.00154204,1.19138e-06,5.09114e-08,0.536318,0.00154458,1.34411e-06,-1.4704e-08,0.537864,0.00154722,1.3e-06,7.9048e-09,0.539413,0.00154984,1.32371e-06,-1.69152e-08,0.540964,0.00155244,1.27297e-06,1.51355e-10,0.542517,0.00155499,1.27342e-06,1.63099e-08,0.544074,0.00155758,1.32235e-06,-5.78647e-09,0.545633,0.00156021,1.30499e-06,6.83599e-09,0.547194,0.00156284,1.3255e-06,-2.15575e-08,0.548758,0.00156543,1.26083e-06,1.97892e-08,0.550325,0.00156801,1.32019e-06,2.00525e-09,0.551894,0.00157065,1.32621e-06,-2.78103e-08,0.553466,0.00157322,1.24278e-06,4.96314e-08,0.555041,0.00157586,1.39167e-06,-5.1506e-08,0.556618,0.00157849,1.23716e-06,3.71835e-08,0.558198,0.00158107,1.34871e-06,-3.76233e-08,0.55978,0.00158366,1.23584e-06,5.37052e-08,0.561365,0.00158629,1.39695e-06,-5.79884e-08,0.562953,0.00158891,1.22299e-06,5.90392e-08,0.564543,0.00159153,1.4001e-06,-5.89592e-08,0.566136,0.00159416,1.22323e-06,5.7588e-08,0.567731,0.00159678,1.39599e-06,-5.21835e-08,0.569329,0.00159941,1.23944e-06,3.19369e-08,0.57093,0.00160199,1.33525e-06,-1.59594e-08,0.572533,0.00160461,1.28737e-06,3.19006e-08,0.574139,0.00160728,1.38307e-06,-5.20383e-08,0.575748,0.00160989,1.22696e-06,5.70431e-08,0.577359,0.00161251,1.39809e-06,-5.69247e-08,0.578973,0.00161514,1.22731e-06,5.14463e-08,0.580589,0.00161775,1.38165e-06,-2.9651e-08,0.582208,0.00162042,1.2927e-06,7.55339e-09,0.58383,0.00162303,1.31536e-06,-5.62636e-10,0.585455,0.00162566,1.31367e-06,-5.30281e-09,0.587081,0.00162827,1.29776e-06,2.17738e-08,0.588711,0.00163093,1.36309e-06,-2.21875e-08,0.590343,0.00163359,1.29652e-06,7.37164e-09,0.591978,0.00163621,1.31864e-06,-7.29907e-09,0.593616,0.00163882,1.29674e-06,2.18247e-08,0.595256,0.00164148,1.36221e-06,-2.03952e-08,0.596899,0.00164414,1.30103e-06,1.51241e-10,0.598544,0.00164675,1.30148e-06,1.97902e-08,0.600192,0.00164941,1.36085e-06,-1.97074e-08,0.601843,0.00165207,1.30173e-06,-5.65175e-10,0.603496,0.00165467,1.30004e-06,2.1968e-08,0.605152,0.00165734,1.36594e-06,-2.77024e-08,0.606811,0.00165999,1.28283e-06,2.92369e-08,0.608472,0.00166264,1.37054e-06,-2.96407e-08,0.610136,0.00166529,1.28162e-06,2.97215e-08,0.611803,0.00166795,1.37079e-06,-2.96408e-08,0.613472,0.0016706,1.28186e-06,2.92371e-08,0.615144,0.00167325,1.36957e-06,-2.77031e-08,0.616819,0.00167591,1.28647e-06,2.19708e-08,0.618496,0.00167855,1.35238e-06,-5.75407e-10,0.620176,0.00168125,1.35065e-06,-1.9669e-08,0.621858,0.00168389,1.29164e-06,1.96468e-08,0.623544,0.00168653,1.35058e-06,6.86403e-10,0.625232,0.00168924,1.35264e-06,-2.23924e-08,0.626922,0.00169187,1.28547e-06,2.92788e-08,0.628615,0.00169453,1.3733e-06,-3.51181e-08,0.630311,0.00169717,1.26795e-06,5.15889e-08,0.63201,0.00169987,1.42272e-06,-5.2028e-08,0.633711,0.00170255,1.26663e-06,3.73139e-08,0.635415,0.0017052,1.37857e-06,-3.76227e-08,0.637121,0.00170784,1.2657e-06,5.35722e-08,0.63883,0.00171054,1.42642e-06,-5.74567e-08,0.640542,0.00171322,1.25405e-06,5.70456e-08,0.642257,0.0017159,1.42519e-06,-5.15163e-08,0.643974,0.00171859,1.27064e-06,2.98103e-08,0.645694,0.00172122,1.36007e-06,-8.12016e-09,0.647417,0.00172392,1.33571e-06,2.67039e-09,0.649142,0.0017266,1.34372e-06,-2.56152e-09,0.65087,0.00172928,1.33604e-06,7.57571e-09,0.6526,0.00173197,1.35876e-06,-2.77413e-08,0.654334,0.00173461,1.27554e-06,4.3785e-08,0.65607,0.00173729,1.40689e-06,-2.81896e-08,0.657808,0.00174002,1.32233e-06,9.36893e-09,0.65955,0.00174269,1.35043e-06,-9.28617e-09,0.661294,0.00174536,1.32257e-06,2.77757e-08,0.66304,0.00174809,1.4059e-06,-4.2212e-08,0.66479,0.00175078,1.27926e-06,2.1863e-08,0.666542,0.0017534,1.34485e-06,1.43648e-08,0.668297,0.00175613,1.38795e-06,-1.97177e-08,0.670054,0.00175885,1.3288e-06,4.90115e-09,0.671814,0.00176152,1.3435e-06,1.13232e-10,0.673577,0.00176421,1.34384e-06,-5.3542e-09,0.675343,0.00176688,1.32778e-06,2.13035e-08,0.677111,0.0017696,1.39169e-06,-2.02553e-08,0.678882,0.00177232,1.33092e-06,1.13005e-10,0.680656,0.00177499,1.33126e-06,1.98031e-08,0.682432,0.00177771,1.39067e-06,-1.97211e-08,0.684211,0.00178043,1.33151e-06,-5.2349e-10,0.685993,0.00178309,1.32994e-06,2.18151e-08,0.687777,0.00178582,1.39538e-06,-2.71325e-08,0.689564,0.00178853,1.31398e-06,2.71101e-08,0.691354,0.00179124,1.39531e-06,-2.17035e-08,0.693147,0.00179396,1.3302e-06,9.92865e-11,0.694942,0.00179662,1.3305e-06,2.13063e-08,0.69674,0.00179935,1.39442e-06,-2.57198e-08,0.698541,0.00180206,1.31726e-06,2.19682e-08,0.700344,0.00180476,1.38317e-06,-2.54852e-09,0.70215,0.00180752,1.37552e-06,-1.17741e-08,0.703959,0.00181023,1.3402e-06,-9.95999e-09,0.705771,0.00181288,1.31032e-06,5.16141e-08,0.707585,0.00181566,1.46516e-06,-7.72869e-08,0.709402,0.00181836,1.2333e-06,7.87197e-08,0.711222,0.00182106,1.46946e-06,-5.87781e-08,0.713044,0.00182382,1.29312e-06,3.71834e-08,0.714869,0.00182652,1.40467e-06,-3.03511e-08,0.716697,0.00182924,1.31362e-06,2.46161e-08,0.718528,0.00183194,1.38747e-06,-8.5087e-09,0.720361,0.00183469,1.36194e-06,9.41892e-09,0.722197,0.00183744,1.3902e-06,-2.91671e-08,0.724036,0.00184014,1.3027e-06,4.76448e-08,0.725878,0.00184288,1.44563e-06,-4.22028e-08,0.727722,0.00184565,1.31902e-06,1.95682e-09,0.729569,0.00184829,1.3249e-06,3.43754e-08,0.731419,0.00185104,1.42802e-06,-2.0249e-08,0.733271,0.00185384,1.36727e-06,-1.29838e-08,0.735126,0.00185654,1.32832e-06,1.25794e-08,0.736984,0.00185923,1.36606e-06,2.22711e-08,0.738845,0.00186203,1.43287e-06,-4.20594e-08,0.740708,0.00186477,1.3067e-06,2.67571e-08,0.742574,0.00186746,1.38697e-06,-5.36424e-09,0.744443,0.00187022,1.37087e-06,-5.30023e-09,0.746315,0.00187295,1.35497e-06,2.65653e-08,0.748189,0.00187574,1.43467e-06,-4.13564e-08,0.750066,0.00187848,1.3106e-06,1.9651e-08,0.751946,0.00188116,1.36955e-06,2.23572e-08,0.753828,0.00188397,1.43663e-06,-4.9475e-08,0.755714,0.00188669,1.2882e-06,5.63335e-08,0.757602,0.00188944,1.4572e-06,-5.66499e-08,0.759493,0.00189218,1.28725e-06,5.10567e-08,0.761386,0.00189491,1.44042e-06,-2.83677e-08,0.763283,0.00189771,1.35532e-06,2.80962e-09,0.765182,0.00190042,1.36375e-06,1.71293e-08,0.767083,0.0019032,1.41513e-06,-1.17221e-08,0.768988,0.001906,1.37997e-06,-2.98453e-08,0.770895,0.00190867,1.29043e-06,7.14987e-08,0.772805,0.00191146,1.50493e-06,-7.73354e-08,0.774718,0.00191424,1.27292e-06,5.90292e-08,0.776634,0.00191697,1.45001e-06,-3.9572e-08,0.778552,0.00191975,1.33129e-06,3.9654e-08,0.780473,0.00192253,1.45026e-06,-5.94395e-08,0.782397,0.00192525,1.27194e-06,7.88945e-08,0.784324,0.00192803,1.50862e-06,-7.73249e-08,0.786253,0.00193082,1.27665e-06,5.15913e-08,0.788185,0.00193352,1.43142e-06,-9.83099e-09,0.79012,0.00193636,1.40193e-06,-1.22672e-08,0.792058,0.00193912,1.36513e-06,-7.05275e-10,0.793999,0.00194185,1.36301e-06,1.50883e-08,0.795942,0.00194462,1.40828e-06,-4.33147e-11,0.797888,0.00194744,1.40815e-06,-1.49151e-08,0.799837,0.00195021,1.3634e-06,9.93244e-11,0.801788,0.00195294,1.3637e-06,1.45179e-08,0.803743,0.00195571,1.40725e-06,1.43363e-09,0.8057,0.00195853,1.41155e-06,-2.02525e-08,0.80766,0.00196129,1.35079e-06,1.99718e-08,0.809622,0.00196405,1.41071e-06,-3.01649e-11,0.811588,0.00196687,1.41062e-06,-1.9851e-08,0.813556,0.00196964,1.35107e-06,1.98296e-08,0.815527,0.0019724,1.41056e-06,1.37485e-10,0.817501,0.00197522,1.41097e-06,-2.03796e-08,0.819477,0.00197798,1.34983e-06,2.17763e-08,0.821457,0.00198074,1.41516e-06,-7.12085e-09,0.823439,0.00198355,1.3938e-06,6.70707e-09,0.825424,0.00198636,1.41392e-06,-1.97074e-08,0.827412,0.00198913,1.35479e-06,1.25179e-08,0.829402,0.00199188,1.39235e-06,2.92405e-08,0.831396,0.00199475,1.48007e-06,-6.98755e-08,0.833392,0.0019975,1.27044e-06,7.14477e-08,0.835391,0.00200026,1.48479e-06,-3.71014e-08,0.837392,0.00200311,1.37348e-06,1.73533e-08,0.839397,0.00200591,1.42554e-06,-3.23118e-08,0.841404,0.00200867,1.32861e-06,5.2289e-08,0.843414,0.00201148,1.48547e-06,-5.76348e-08,0.845427,0.00201428,1.31257e-06,5.9041e-08,0.847443,0.00201708,1.48969e-06,-5.93197e-08,0.849461,0.00201988,1.31173e-06,5.90289e-08,0.851482,0.00202268,1.48882e-06,-5.75864e-08,0.853507,0.00202549,1.31606e-06,5.21075e-08,0.855533,0.00202828,1.47238e-06,-3.16344e-08,0.857563,0.00203113,1.37748e-06,1.48257e-08,0.859596,0.00203393,1.42196e-06,-2.76684e-08,0.861631,0.00203669,1.33895e-06,3.62433e-08,0.863669,0.00203947,1.44768e-06,1.90463e-09,0.86571,0.00204237,1.45339e-06,-4.38617e-08,0.867754,0.00204515,1.32181e-06,5.43328e-08,0.8698,0.00204796,1.48481e-06,-5.42603e-08,0.87185,0.00205076,1.32203e-06,4.34989e-08,0.873902,0.00205354,1.45252e-06,-5.26029e-10,0.875957,0.00205644,1.45095e-06,-4.13949e-08,0.878015,0.00205922,1.32676e-06,4.68962e-08,0.880075,0.00206201,1.46745e-06,-2.69807e-08,0.882139,0.00206487,1.38651e-06,1.42181e-09,0.884205,0.00206764,1.39077e-06,2.12935e-08,0.886274,0.00207049,1.45465e-06,-2.69912e-08,0.888346,0.00207332,1.37368e-06,2.70664e-08,0.890421,0.00207615,1.45488e-06,-2.16698e-08,0.892498,0.00207899,1.38987e-06,8.14756e-12,0.894579,0.00208177,1.38989e-06,2.16371e-08,0.896662,0.00208462,1.45481e-06,-2.6952e-08,0.898748,0.00208744,1.37395e-06,2.65663e-08,0.900837,0.00209027,1.45365e-06,-1.97084e-08,0.902928,0.00209312,1.39452e-06,-7.33731e-09,0.905023,0.00209589,1.37251e-06,4.90578e-08,0.90712,0.00209878,1.51968e-06,-6.96845e-08,0.90922,0.00210161,1.31063e-06,5.08664e-08,0.911323,0.00210438,1.46323e-06,-1.45717e-08,0.913429,0.00210727,1.41952e-06,7.42038e-09,0.915538,0.00211013,1.44178e-06,-1.51097e-08,0.917649,0.00211297,1.39645e-06,-6.58618e-09,0.919764,0.00211574,1.37669e-06,4.14545e-08,0.921881,0.00211862,1.50105e-06,-4.00222e-08,0.924001,0.0021215,1.38099e-06,-5.7518e-10,0.926124,0.00212426,1.37926e-06,4.23229e-08,0.92825,0.00212714,1.50623e-06,-4.9507e-08,0.930378,0.00213001,1.35771e-06,3.64958e-08,0.93251,0.00213283,1.4672e-06,-3.68713e-08,0.934644,0.00213566,1.35658e-06,5.13848e-08,0.936781,0.00213852,1.51074e-06,-4.94585e-08,0.938921,0.0021414,1.36236e-06,2.72399e-08,0.941064,0.0021442,1.44408e-06,1.0372e-10,0.943209,0.00214709,1.44439e-06,-2.76547e-08,0.945358,0.0021499,1.36143e-06,5.09106e-08,0.947509,0.00215277,1.51416e-06,-5.67784e-08,0.949663,0.00215563,1.34382e-06,5.69935e-08,0.95182,0.00215849,1.5148e-06,-5.19861e-08,0.95398,0.00216136,1.35885e-06,3.17417e-08,0.956143,0.00216418,1.45407e-06,-1.53758e-08,0.958309,0.00216704,1.40794e-06,2.97615e-08,0.960477,0.00216994,1.49723e-06,-4.40657e-08,0.962649,0.00217281,1.36503e-06,2.72919e-08,0.964823,0.00217562,1.44691e-06,-5.49729e-09,0.967,0.0021785,1.43041e-06,-5.30273e-09,0.96918,0.00218134,1.41451e-06,2.67084e-08,0.971363,0.00218425,1.49463e-06,-4.19265e-08,0.973548,0.00218711,1.36885e-06,2.17881e-08,0.975737,0.00218992,1.43422e-06,1.43789e-08,0.977928,0.00219283,1.47735e-06,-1.96989e-08,0.980122,0.00219572,1.41826e-06,4.81221e-09,0.98232,0.00219857,1.43269e-06,4.50048e-10,0.98452,0.00220144,1.43404e-06,-6.61237e-09,0.986722,0.00220429,1.41421e-06,2.59993e-08,0.988928,0.0022072,1.4922e-06,-3.77803e-08,0.991137,0.00221007,1.37886e-06,5.9127e-09,0.993348,0.00221284,1.3966e-06,1.33339e-07,0.995563,0.00221604,1.79662e-06,-5.98872e-07,0.99778,0.00222015,0.,0.}; + + template + __device__ __forceinline__ void RGB2LabConvert_f(const T& src, D& dst) + { + const float _1_3 = 1.0f / 3.0f; + const float _a = 16.0f / 116.0f; + + float B = blueIdx == 0 ? src.x : src.z; + float G = src.y; + float R = blueIdx == 0 ? src.z : src.x; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + } + + float X = B * 0.189828f + G * 0.376219f + R * 0.433953f; + float Y = B * 0.072169f + G * 0.715160f + R * 0.212671f; + float Z = B * 0.872766f + G * 0.109477f + R * 0.017758f; + + float FX = X > 0.008856f ? ::powf(X, _1_3) : (7.787f * X + _a); + float FY = Y > 0.008856f ? ::powf(Y, _1_3) : (7.787f * Y + _a); + float FZ = Z > 0.008856f ? ::powf(Z, _1_3) : (7.787f * Z + _a); + + float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y); + float a = 500.f * (FX - FY); + float b = 200.f * (FY - FZ); + + dst.x = L; + dst.y = a; + dst.z = b; + } + + template struct RGB2Lab; + template + struct RGB2Lab + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LabConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Lab() {} + __host__ __device__ __forceinline__ RGB2Lab(const RGB2Lab&) {} + }; + template + struct RGB2Lab + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LabConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Lab() {} + __host__ __device__ __forceinline__ RGB2Lab(const RGB2Lab&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2Lab functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_sRGBInvGammaTab[] = {0,0.0126255,0.,-8.33961e-06,0.0126172,0.0126005,-2.50188e-05,4.1698e-05,0.0252344,0.0126756,0.000100075,-0.000158451,0.0378516,0.0124004,-0.000375277,-0.000207393,0.0496693,0.0110276,-0.000997456,0.00016837,0.0598678,0.00953783,-0.000492346,2.07235e-05,0.068934,0.00861531,-0.000430176,3.62876e-05,0.0771554,0.00786382,-0.000321313,1.87625e-05,0.0847167,0.00727748,-0.000265025,1.53594e-05,0.0917445,0.00679351,-0.000218947,1.10545e-05,0.0983301,0.00638877,-0.000185784,8.66984e-06,0.104542,0.00604322,-0.000159774,6.82996e-06,0.110432,0.00574416,-0.000139284,5.51008e-06,0.116042,0.00548212,-0.000122754,4.52322e-06,0.121406,0.00525018,-0.000109184,3.75557e-06,0.126551,0.00504308,-9.79177e-05,3.17134e-06,0.131499,0.00485676,-8.84037e-05,2.68469e-06,0.13627,0.004688,-8.03496e-05,2.31725e-06,0.14088,0.00453426,-7.33978e-05,2.00868e-06,0.145343,0.00439349,-6.73718e-05,1.74775e-06,0.149671,0.00426399,-6.21286e-05,1.53547e-06,0.153875,0.00414434,-5.75222e-05,1.364e-06,0.157963,0.00403338,-5.34301e-05,1.20416e-06,0.161944,0.00393014,-4.98177e-05,1.09114e-06,0.165825,0.00383377,-4.65443e-05,9.57987e-07,0.169613,0.00374356,-4.36703e-05,8.88359e-07,0.173314,0.00365888,-4.10052e-05,7.7849e-07,0.176933,0.00357921,-3.86697e-05,7.36254e-07,0.180474,0.00350408,-3.6461e-05,6.42534e-07,0.183942,0.00343308,-3.45334e-05,6.12614e-07,0.187342,0.00336586,-3.26955e-05,5.42894e-07,0.190675,0.00330209,-3.10669e-05,5.08967e-07,0.193947,0.00324149,-2.954e-05,4.75977e-07,0.197159,0.00318383,-2.8112e-05,4.18343e-07,0.200315,0.00312887,-2.6857e-05,4.13651e-07,0.203418,0.00307639,-2.5616e-05,3.70847e-07,0.206469,0.00302627,-2.45035e-05,3.3813e-07,0.209471,0.00297828,-2.34891e-05,3.32999e-07,0.212426,0.0029323,-2.24901e-05,2.96826e-07,0.215336,0.00288821,-2.15996e-05,2.82736e-07,0.218203,0.00284586,-2.07514e-05,2.70961e-07,0.221029,0.00280517,-1.99385e-05,2.42744e-07,0.223814,0.00276602,-1.92103e-05,2.33277e-07,0.226561,0.0027283,-1.85105e-05,2.2486e-07,0.229271,0.00269195,-1.78359e-05,2.08383e-07,0.231945,0.00265691,-1.72108e-05,1.93305e-07,0.234585,0.00262307,-1.66308e-05,1.80687e-07,0.237192,0.00259035,-1.60888e-05,1.86632e-07,0.239766,0.00255873,-1.55289e-05,1.60569e-07,0.24231,0.00252815,-1.50472e-05,1.54566e-07,0.244823,0.00249852,-1.45835e-05,1.59939e-07,0.247307,0.00246983,-1.41037e-05,1.29549e-07,0.249763,0.00244202,-1.3715e-05,1.41429e-07,0.252191,0.00241501,-1.32907e-05,1.39198e-07,0.254593,0.00238885,-1.28731e-05,1.06444e-07,0.256969,0.00236342,-1.25538e-05,1.2048e-07,0.25932,0.00233867,-1.21924e-05,1.26892e-07,0.261647,0.00231467,-1.18117e-05,8.72084e-08,0.26395,0.00229131,-1.15501e-05,1.20323e-07,0.26623,0.00226857,-1.11891e-05,8.71514e-08,0.268487,0.00224645,-1.09276e-05,9.73165e-08,0.270723,0.00222489,-1.06357e-05,8.98259e-08,0.272937,0.00220389,-1.03662e-05,7.98218e-08,0.275131,0.00218339,-1.01267e-05,9.75254e-08,0.277304,0.00216343,-9.83416e-06,6.65195e-08,0.279458,0.00214396,-9.63461e-06,8.34313e-08,0.281592,0.00212494,-9.38431e-06,7.65919e-08,0.283708,0.00210641,-9.15454e-06,5.7236e-08,0.285805,0.00208827,-8.98283e-06,8.18939e-08,0.287885,0.00207055,-8.73715e-06,6.2224e-08,0.289946,0.00205326,-8.55047e-06,5.66388e-08,0.291991,0.00203633,-8.38056e-06,6.88491e-08,0.294019,0.00201978,-8.17401e-06,5.53955e-08,0.296031,0.00200359,-8.00782e-06,6.71971e-08,0.298027,0.00198778,-7.80623e-06,3.34439e-08,0.300007,0.00197227,-7.7059e-06,6.7248e-08,0.301971,0.00195706,-7.50416e-06,5.51915e-08,0.303921,0.00194221,-7.33858e-06,3.98124e-08,0.305856,0.00192766,-7.21915e-06,5.37795e-08,0.307776,0.00191338,-7.05781e-06,4.30919e-08,0.309683,0.00189939,-6.92853e-06,4.20744e-08,0.311575,0.00188566,-6.80231e-06,5.68321e-08,0.313454,0.00187223,-6.63181e-06,2.86195e-08,0.31532,0.00185905,-6.54595e-06,3.73075e-08,0.317172,0.00184607,-6.43403e-06,6.05684e-08,0.319012,0.00183338,-6.25233e-06,1.84426e-08,0.320839,0.00182094,-6.197e-06,4.44757e-08,0.322654,0.00180867,-6.06357e-06,4.20729e-08,0.324456,0.00179667,-5.93735e-06,2.56511e-08,0.326247,0.00178488,-5.8604e-06,3.41368e-08,0.328026,0.00177326,-5.75799e-06,4.64177e-08,0.329794,0.00176188,-5.61874e-06,1.86107e-08,0.33155,0.0017507,-5.5629e-06,2.81511e-08,0.333295,0.00173966,-5.47845e-06,4.75987e-08,0.335029,0.00172884,-5.33565e-06,1.98726e-08,0.336753,0.00171823,-5.27604e-06,2.19226e-08,0.338466,0.00170775,-5.21027e-06,4.14483e-08,0.340169,0.00169745,-5.08592e-06,2.09017e-08,0.341861,0.00168734,-5.02322e-06,2.39561e-08,0.343543,0.00167737,-4.95135e-06,3.22852e-08,0.345216,0.00166756,-4.85449e-06,2.57173e-08,0.346878,0.00165793,-4.77734e-06,1.38569e-08,0.348532,0.00164841,-4.73577e-06,3.80634e-08,0.350175,0.00163906,-4.62158e-06,1.27043e-08,0.35181,0.00162985,-4.58347e-06,3.03279e-08,0.353435,0.00162078,-4.49249e-06,1.49961e-08,0.355051,0.00161184,-4.4475e-06,2.88977e-08,0.356659,0.00160303,-4.3608e-06,1.84241e-08,0.358257,0.00159436,-4.30553e-06,1.6616e-08,0.359848,0.0015858,-4.25568e-06,3.43218e-08,0.361429,0.00157739,-4.15272e-06,-4.89172e-09,0.363002,0.00156907,-4.16739e-06,4.48498e-08,0.364567,0.00156087,-4.03284e-06,4.30676e-09,0.366124,0.00155282,-4.01992e-06,2.73303e-08,0.367673,0.00154486,-3.93793e-06,5.58036e-09,0.369214,0.001537,-3.92119e-06,3.97554e-08,0.370747,0.00152928,-3.80193e-06,-1.55904e-08,0.372272,0.00152163,-3.8487e-06,5.24081e-08,0.37379,0.00151409,-3.69147e-06,-1.52272e-08,0.375301,0.00150666,-3.73715e-06,3.83028e-08,0.376804,0.0014993,-3.62225e-06,1.10278e-08,0.378299,0.00149209,-3.58916e-06,6.99326e-09,0.379788,0.00148493,-3.56818e-06,2.06038e-08,0.381269,0.00147786,-3.50637e-06,2.98009e-08,0.382744,0.00147093,-3.41697e-06,-2.05978e-08,0.384211,0.00146404,-3.47876e-06,5.25899e-08,0.385672,0.00145724,-3.32099e-06,-1.09471e-08,0.387126,0.00145056,-3.35383e-06,2.10009e-08,0.388573,0.00144392,-3.29083e-06,1.63501e-08,0.390014,0.00143739,-3.24178e-06,3.00641e-09,0.391448,0.00143091,-3.23276e-06,3.12282e-08,0.392875,0.00142454,-3.13908e-06,-8.70932e-09,0.394297,0.00141824,-3.16521e-06,3.34114e-08,0.395712,0.00141201,-3.06497e-06,-5.72754e-09,0.397121,0.00140586,-3.08215e-06,1.9301e-08,0.398524,0.00139975,-3.02425e-06,1.7931e-08,0.39992,0.00139376,-2.97046e-06,-1.61822e-09,0.401311,0.00138781,-2.97531e-06,1.83442e-08,0.402696,0.00138192,-2.92028e-06,1.76485e-08,0.404075,0.00137613,-2.86733e-06,4.68617e-10,0.405448,0.00137039,-2.86593e-06,1.02794e-08,0.406816,0.00136469,-2.83509e-06,1.80179e-08,0.408178,0.00135908,-2.78104e-06,7.05594e-09,0.409534,0.00135354,-2.75987e-06,1.33633e-08,0.410885,0.00134806,-2.71978e-06,-9.04568e-10,0.41223,0.00134261,-2.72249e-06,2.0057e-08,0.41357,0.00133723,-2.66232e-06,1.00841e-08,0.414905,0.00133194,-2.63207e-06,-7.88835e-10,0.416234,0.00132667,-2.63444e-06,2.28734e-08,0.417558,0.00132147,-2.56582e-06,-1.29785e-09,0.418877,0.00131633,-2.56971e-06,1.21205e-08,0.420191,0.00131123,-2.53335e-06,1.24202e-08,0.421499,0.0013062,-2.49609e-06,-2.19681e-09,0.422803,0.0013012,-2.50268e-06,2.61696e-08,0.424102,0.00129628,-2.42417e-06,-1.30747e-08,0.425396,0.00129139,-2.46339e-06,2.6129e-08,0.426685,0.00128654,-2.38501e-06,-2.03454e-09,0.427969,0.00128176,-2.39111e-06,1.18115e-08,0.429248,0.00127702,-2.35567e-06,1.43932e-08,0.430523,0.00127235,-2.31249e-06,-9.77965e-09,0.431793,0.00126769,-2.34183e-06,2.47253e-08,0.433058,0.00126308,-2.26766e-06,2.85278e-10,0.434319,0.00125855,-2.2668e-06,3.93614e-09,0.435575,0.00125403,-2.25499e-06,1.37722e-08,0.436827,0.00124956,-2.21368e-06,5.79803e-10,0.438074,0.00124513,-2.21194e-06,1.37112e-08,0.439317,0.00124075,-2.1708e-06,4.17973e-09,0.440556,0.00123642,-2.15826e-06,-6.27703e-10,0.44179,0.0012321,-2.16015e-06,2.81332e-08,0.44302,0.00122787,-2.07575e-06,-2.24985e-08,0.444246,0.00122365,-2.14324e-06,3.20586e-08,0.445467,0.00121946,-2.04707e-06,-1.6329e-08,0.446685,0.00121532,-2.09605e-06,3.32573e-08,0.447898,0.00121122,-1.99628e-06,-2.72927e-08,0.449107,0.00120715,-2.07816e-06,4.6111e-08,0.450312,0.00120313,-1.93983e-06,-3.79416e-08,0.451514,0.00119914,-2.05365e-06,4.60507e-08,0.452711,0.00119517,-1.9155e-06,-2.7052e-08,0.453904,0.00119126,-1.99666e-06,3.23551e-08,0.455093,0.00118736,-1.89959e-06,-1.29613e-08,0.456279,0.00118352,-1.93848e-06,1.94905e-08,0.45746,0.0011797,-1.88e-06,-5.39588e-09,0.458638,0.00117593,-1.89619e-06,2.09282e-09,0.459812,0.00117214,-1.88991e-06,2.68267e-08,0.460982,0.00116844,-1.80943e-06,-1.99925e-08,0.462149,0.00116476,-1.86941e-06,2.3341e-08,0.463312,0.00116109,-1.79939e-06,-1.37674e-08,0.464471,0.00115745,-1.84069e-06,3.17287e-08,0.465627,0.00115387,-1.7455e-06,-2.37407e-08,0.466779,0.00115031,-1.81673e-06,3.34315e-08,0.467927,0.00114677,-1.71643e-06,-2.05786e-08,0.469073,0.00114328,-1.77817e-06,1.90802e-08,0.470214,0.00113978,-1.72093e-06,3.86247e-09,0.471352,0.00113635,-1.70934e-06,-4.72759e-09,0.472487,0.00113292,-1.72352e-06,1.50478e-08,0.473618,0.00112951,-1.67838e-06,4.14108e-09,0.474746,0.00112617,-1.66595e-06,-1.80986e-09,0.47587,0.00112283,-1.67138e-06,3.09816e-09,0.476991,0.0011195,-1.66209e-06,1.92198e-08,0.478109,0.00111623,-1.60443e-06,-2.03726e-08,0.479224,0.00111296,-1.66555e-06,3.2468e-08,0.480335,0.00110973,-1.56814e-06,-2.00922e-08,0.481443,0.00110653,-1.62842e-06,1.80983e-08,0.482548,0.00110333,-1.57413e-06,7.30362e-09,0.48365,0.0011002,-1.55221e-06,-1.75107e-08,0.484749,0.00109705,-1.60475e-06,3.29373e-08,0.485844,0.00109393,-1.50594e-06,-2.48315e-08,0.486937,0.00109085,-1.58043e-06,3.65865e-08,0.488026,0.0010878,-1.47067e-06,-3.21078e-08,0.489112,0.00108476,-1.56699e-06,3.22397e-08,0.490195,0.00108172,-1.47027e-06,-7.44391e-09,0.491276,0.00107876,-1.49261e-06,-2.46428e-09,0.492353,0.00107577,-1.5e-06,1.73011e-08,0.493427,0.00107282,-1.4481e-06,-7.13552e-09,0.494499,0.0010699,-1.4695e-06,1.1241e-08,0.495567,0.001067,-1.43578e-06,-8.02637e-09,0.496633,0.0010641,-1.45986e-06,2.08645e-08,0.497695,0.00106124,-1.39726e-06,-1.58271e-08,0.498755,0.0010584,-1.44475e-06,1.26415e-08,0.499812,0.00105555,-1.40682e-06,2.48655e-08,0.500866,0.00105281,-1.33222e-06,-5.24988e-08,0.501918,0.00104999,-1.48972e-06,6.59206e-08,0.502966,0.00104721,-1.29196e-06,-3.237e-08,0.504012,0.00104453,-1.38907e-06,3.95479e-09,0.505055,0.00104176,-1.3772e-06,1.65509e-08,0.506096,0.00103905,-1.32755e-06,-1.05539e-08,0.507133,0.00103637,-1.35921e-06,2.56648e-08,0.508168,0.00103373,-1.28222e-06,-3.25007e-08,0.509201,0.00103106,-1.37972e-06,4.47336e-08,0.51023,0.00102844,-1.24552e-06,-2.72245e-08,0.511258,0.00102587,-1.32719e-06,4.55952e-09,0.512282,0.00102323,-1.31352e-06,8.98645e-09,0.513304,0.00102063,-1.28656e-06,1.90992e-08,0.514323,0.00101811,-1.22926e-06,-2.57786e-08,0.51534,0.00101557,-1.30659e-06,2.44104e-08,0.516355,0.00101303,-1.23336e-06,-1.22581e-08,0.517366,0.00101053,-1.27014e-06,2.4622e-08,0.518376,0.00100806,-1.19627e-06,-2.66253e-08,0.519383,0.00100559,-1.27615e-06,2.22744e-08,0.520387,0.00100311,-1.20932e-06,-2.8679e-09,0.521389,0.00100068,-1.21793e-06,-1.08029e-08,0.522388,0.000998211,-1.25034e-06,4.60795e-08,0.523385,0.000995849,-1.1121e-06,-5.4306e-08,0.52438,0.000993462,-1.27502e-06,5.19354e-08,0.525372,0.000991067,-1.11921e-06,-3.42262e-08,0.526362,0.000988726,-1.22189e-06,2.53646e-08,0.52735,0.000986359,-1.14579e-06,-7.62782e-09,0.528335,0.000984044,-1.16868e-06,5.14668e-09,0.529318,0.000981722,-1.15324e-06,-1.29589e-08,0.530298,0.000979377,-1.19211e-06,4.66888e-08,0.531276,0.000977133,-1.05205e-06,-5.45868e-08,0.532252,0.000974865,-1.21581e-06,5.24495e-08,0.533226,0.000972591,-1.05846e-06,-3.60019e-08,0.534198,0.000970366,-1.16647e-06,3.19537e-08,0.535167,0.000968129,-1.07061e-06,-3.2208e-08,0.536134,0.000965891,-1.16723e-06,3.72738e-08,0.537099,0.000963668,-1.05541e-06,2.32205e-09,0.538061,0.000961564,-1.04844e-06,-4.65618e-08,0.539022,0.000959328,-1.18813e-06,6.47159e-08,0.53998,0.000957146,-9.93979e-07,-3.3488e-08,0.540936,0.000955057,-1.09444e-06,9.63166e-09,0.54189,0.000952897,-1.06555e-06,-5.03871e-09,0.542842,0.000950751,-1.08066e-06,1.05232e-08,0.543792,0.000948621,-1.04909e-06,2.25503e-08,0.544739,0.000946591,-9.81444e-07,-4.11195e-08,0.545685,0.000944504,-1.1048e-06,2.27182e-08,0.546628,0.000942363,-1.03665e-06,9.85146e-09,0.54757,0.000940319,-1.00709e-06,-2.51938e-09,0.548509,0.000938297,-1.01465e-06,2.25858e-10,0.549446,0.000936269,-1.01397e-06,1.61598e-09,0.550381,0.000934246,-1.00913e-06,-6.68983e-09,0.551315,0.000932207,-1.0292e-06,2.51434e-08,0.552246,0.000930224,-9.53765e-07,-3.42793e-08,0.553175,0.000928214,-1.0566e-06,5.23688e-08,0.554102,0.000926258,-8.99497e-07,-5.59865e-08,0.555028,0.000924291,-1.06746e-06,5.23679e-08,0.555951,0.000922313,-9.10352e-07,-3.42763e-08,0.556872,0.00092039,-1.01318e-06,2.51326e-08,0.557792,0.000918439,-9.37783e-07,-6.64954e-09,0.558709,0.000916543,-9.57732e-07,1.46554e-09,0.559625,0.000914632,-9.53335e-07,7.87281e-10,0.560538,0.000912728,-9.50973e-07,-4.61466e-09,0.56145,0.000910812,-9.64817e-07,1.76713e-08,0.56236,0.000908935,-9.11804e-07,-6.46564e-09,0.563268,0.000907092,-9.312e-07,8.19121e-09,0.564174,0.000905255,-9.06627e-07,-2.62992e-08,0.565078,0.000903362,-9.85524e-07,3.74007e-08,0.565981,0.000901504,-8.73322e-07,-4.0942e-09,0.566882,0.000899745,-8.85605e-07,-2.1024e-08,0.56778,0.00089791,-9.48677e-07,2.85854e-08,0.568677,0.000896099,-8.62921e-07,-3.3713e-08,0.569573,0.000894272,-9.64059e-07,4.6662e-08,0.570466,0.000892484,-8.24073e-07,-3.37258e-08,0.571358,0.000890734,-9.25251e-07,2.86365e-08,0.572247,0.00088897,-8.39341e-07,-2.12155e-08,0.573135,0.000887227,-9.02988e-07,-3.37913e-09,0.574022,0.000885411,-9.13125e-07,3.47319e-08,0.574906,0.000883689,-8.08929e-07,-1.63394e-08,0.575789,0.000882022,-8.57947e-07,-2.8979e-08,0.57667,0.00088022,-9.44885e-07,7.26509e-08,0.57755,0.000878548,-7.26932e-07,-8.28106e-08,0.578427,0.000876845,-9.75364e-07,7.97774e-08,0.579303,0.000875134,-7.36032e-07,-5.74849e-08,0.580178,0.00087349,-9.08486e-07,3.09529e-08,0.58105,0.000871765,-8.15628e-07,-6.72206e-09,0.581921,0.000870114,-8.35794e-07,-4.06451e-09,0.582791,0.00086843,-8.47987e-07,2.29799e-08,0.583658,0.000866803,-7.79048e-07,-2.82503e-08,0.584524,0.00086516,-8.63799e-07,3.04167e-08,0.585388,0.000863524,-7.72548e-07,-3.38119e-08,0.586251,0.000861877,-8.73984e-07,4.52264e-08,0.587112,0.000860265,-7.38305e-07,-2.78842e-08,0.587972,0.000858705,-8.21958e-07,6.70567e-09,0.58883,0.000857081,-8.01841e-07,1.06161e-09,0.589686,0.000855481,-7.98656e-07,-1.09521e-08,0.590541,0.00085385,-8.31512e-07,4.27468e-08,0.591394,0.000852316,-7.03272e-07,-4.08257e-08,0.592245,0.000850787,-8.25749e-07,1.34677e-09,0.593095,0.000849139,-8.21709e-07,3.54387e-08,0.593944,0.000847602,-7.15393e-07,-2.38924e-08,0.59479,0.0008461,-7.8707e-07,5.26143e-10,0.595636,0.000844527,-7.85491e-07,2.17879e-08,0.596479,0.000843021,-7.20127e-07,-2.80733e-08,0.597322,0.000841497,-8.04347e-07,3.09005e-08,0.598162,0.000839981,-7.11646e-07,-3.5924e-08,0.599002,0.00083845,-8.19418e-07,5.3191e-08,0.599839,0.000836971,-6.59845e-07,-5.76307e-08,0.600676,0.000835478,-8.32737e-07,5.81227e-08,0.60151,0.000833987,-6.58369e-07,-5.56507e-08,0.602344,0.000832503,-8.25321e-07,4.52706e-08,0.603175,0.000830988,-6.89509e-07,-6.22236e-09,0.604006,0.000829591,-7.08176e-07,-2.03811e-08,0.604834,0.000828113,-7.6932e-07,2.8142e-08,0.605662,0.000826659,-6.84894e-07,-3.25822e-08,0.606488,0.000825191,-7.8264e-07,4.25823e-08,0.607312,0.000823754,-6.54893e-07,-1.85376e-08,0.608135,0.000822389,-7.10506e-07,-2.80365e-08,0.608957,0.000820883,-7.94616e-07,7.1079e-08,0.609777,0.000819507,-5.81379e-07,-7.74655e-08,0.610596,0.000818112,-8.13775e-07,5.9969e-08,0.611413,0.000816665,-6.33868e-07,-4.32013e-08,0.612229,0.000815267,-7.63472e-07,5.32313e-08,0.613044,0.0008139,-6.03778e-07,-5.05148e-08,0.613857,0.000812541,-7.55323e-07,2.96187e-08,0.614669,0.000811119,-6.66466e-07,-8.35545e-09,0.615479,0.000809761,-6.91533e-07,3.80301e-09,0.616288,0.00080839,-6.80124e-07,-6.85666e-09,0.617096,0.000807009,-7.00694e-07,2.36237e-08,0.617903,0.000805678,-6.29822e-07,-2.80336e-08,0.618708,0.000804334,-7.13923e-07,2.8906e-08,0.619511,0.000802993,-6.27205e-07,-2.79859e-08,0.620314,0.000801655,-7.11163e-07,2.34329e-08,0.621114,0.000800303,-6.40864e-07,-6.14108e-09,0.621914,0.000799003,-6.59287e-07,1.13151e-09,0.622712,0.000797688,-6.55893e-07,1.61507e-09,0.62351,0.000796381,-6.51048e-07,-7.59186e-09,0.624305,0.000795056,-6.73823e-07,2.87524e-08,0.6251,0.000793794,-5.87566e-07,-4.7813e-08,0.625893,0.000792476,-7.31005e-07,4.32901e-08,0.626685,0.000791144,-6.01135e-07,-6.13814e-09,0.627475,0.000789923,-6.19549e-07,-1.87376e-08,0.628264,0.000788628,-6.75762e-07,2.14837e-08,0.629052,0.000787341,-6.11311e-07,-7.59265e-09,0.629839,0.000786095,-6.34089e-07,8.88692e-09,0.630625,0.000784854,-6.07428e-07,-2.7955e-08,0.631409,0.000783555,-6.91293e-07,4.33285e-08,0.632192,0.000782302,-5.61307e-07,-2.61497e-08,0.632973,0.000781101,-6.39757e-07,1.6658e-09,0.633754,0.000779827,-6.34759e-07,1.94866e-08,0.634533,0.000778616,-5.76299e-07,-2.00076e-08,0.635311,0.000777403,-6.36322e-07,9.39091e-10,0.636088,0.000776133,-6.33505e-07,1.62512e-08,0.636863,0.000774915,-5.84751e-07,-6.33937e-09,0.637638,0.000773726,-6.03769e-07,9.10609e-09,0.638411,0.000772546,-5.76451e-07,-3.00849e-08,0.639183,0.000771303,-6.66706e-07,5.1629e-08,0.639953,0.000770125,-5.11819e-07,-5.7222e-08,0.640723,0.000768929,-6.83485e-07,5.80497e-08,0.641491,0.000767736,-5.09336e-07,-5.57674e-08,0.642259,0.000766551,-6.76638e-07,4.58105e-08,0.643024,0.000765335,-5.39206e-07,-8.26541e-09,0.643789,0.000764231,-5.64002e-07,-1.27488e-08,0.644553,0.000763065,-6.02249e-07,-3.44168e-10,0.645315,0.00076186,-6.03281e-07,1.41254e-08,0.646077,0.000760695,-5.60905e-07,3.44727e-09,0.646837,0.000759584,-5.50563e-07,-2.79144e-08,0.647596,0.000758399,-6.34307e-07,4.86057e-08,0.648354,0.000757276,-4.88489e-07,-4.72989e-08,0.64911,0.000756158,-6.30386e-07,2.13807e-08,0.649866,0.000754961,-5.66244e-07,2.13808e-08,0.65062,0.000753893,-5.02102e-07,-4.7299e-08,0.651374,0.000752746,-6.43999e-07,4.86059e-08,0.652126,0.000751604,-4.98181e-07,-2.79154e-08,0.652877,0.000750524,-5.81927e-07,3.45089e-09,0.653627,0.000749371,-5.71575e-07,1.41119e-08,0.654376,0.00074827,-5.29239e-07,-2.93748e-10,0.655123,0.00074721,-5.3012e-07,-1.29368e-08,0.65587,0.000746111,-5.68931e-07,-7.56355e-09,0.656616,0.000744951,-5.91621e-07,4.3191e-08,0.65736,0.000743897,-4.62048e-07,-4.59911e-08,0.658103,0.000742835,-6.00022e-07,2.15642e-08,0.658846,0.0007417,-5.35329e-07,1.93389e-08,0.659587,0.000740687,-4.77312e-07,-3.93152e-08,0.660327,0.000739615,-5.95258e-07,1.87126e-08,0.661066,0.00073848,-5.3912e-07,2.40695e-08,0.661804,0.000737474,-4.66912e-07,-5.53859e-08,0.662541,0.000736374,-6.33069e-07,7.82648e-08,0.663277,0.000735343,-3.98275e-07,-7.88593e-08,0.664012,0.00073431,-6.34853e-07,5.83585e-08,0.664745,0.000733215,-4.59777e-07,-3.53656e-08,0.665478,0.000732189,-5.65874e-07,2.34994e-08,0.66621,0.000731128,-4.95376e-07,9.72743e-10,0.66694,0.00073014,-4.92458e-07,-2.73903e-08,0.66767,0.000729073,-5.74629e-07,4.89839e-08,0.668398,0.000728071,-4.27677e-07,-4.93359e-08,0.669126,0.000727068,-5.75685e-07,2.91504e-08,0.669853,0.000726004,-4.88234e-07,-7.66109e-09,0.670578,0.000725004,-5.11217e-07,1.49392e-09,0.671303,0.000723986,-5.06735e-07,1.68533e-09,0.672026,0.000722978,-5.01679e-07,-8.23525e-09,0.672749,0.00072195,-5.26385e-07,3.12556e-08,0.67347,0.000720991,-4.32618e-07,-5.71825e-08,0.674191,0.000719954,-6.04166e-07,7.8265e-08,0.67491,0.00071898,-3.69371e-07,-7.70634e-08,0.675628,0.00071801,-6.00561e-07,5.11747e-08,0.676346,0.000716963,-4.47037e-07,-8.42615e-09,0.677062,0.000716044,-4.72315e-07,-1.747e-08,0.677778,0.000715046,-5.24725e-07,1.87015e-08,0.678493,0.000714053,-4.68621e-07,2.26856e-09,0.679206,0.000713123,-4.61815e-07,-2.77758e-08,0.679919,0.000712116,-5.45142e-07,4.92298e-08,0.68063,0.000711173,-3.97453e-07,-4.99339e-08,0.681341,0.000710228,-5.47255e-07,3.12967e-08,0.682051,0.000709228,-4.53365e-07,-1.56481e-08,0.68276,0.000708274,-5.00309e-07,3.12958e-08,0.683467,0.000707367,-4.06422e-07,-4.99303e-08,0.684174,0.000706405,-5.56213e-07,4.9216e-08,0.68488,0.00070544,-4.08565e-07,-2.77245e-08,0.685585,0.00070454,-4.91738e-07,2.07748e-09,0.686289,0.000703562,-4.85506e-07,1.94146e-08,0.686992,0.00070265,-4.27262e-07,-2.01314e-08,0.687695,0.000701735,-4.87656e-07,1.50616e-09,0.688396,0.000700764,-4.83137e-07,1.41067e-08,0.689096,0.00069984,-4.40817e-07,1.67168e-09,0.689795,0.000698963,-4.35802e-07,-2.07934e-08,0.690494,0.000698029,-4.98182e-07,2.18972e-08,0.691192,0.000697099,-4.32491e-07,-7.19092e-09,0.691888,0.000696212,-4.54064e-07,6.86642e-09,0.692584,0.000695325,-4.33464e-07,-2.02747e-08,0.693279,0.000694397,-4.94288e-07,1.46279e-08,0.693973,0.000693452,-4.50405e-07,2.13678e-08,0.694666,0.000692616,-3.86301e-07,-4.04945e-08,0.695358,0.000691721,-5.07785e-07,2.14009e-08,0.696049,0.00069077,-4.43582e-07,1.44955e-08,0.69674,0.000689926,-4.00096e-07,-1.97783e-08,0.697429,0.000689067,-4.5943e-07,5.01296e-09,0.698118,0.000688163,-4.44392e-07,-2.73521e-10,0.698805,0.000687273,-4.45212e-07,-3.91893e-09,0.699492,0.000686371,-4.56969e-07,1.59493e-08,0.700178,0.000685505,-4.09121e-07,-2.73351e-10,0.700863,0.000684686,-4.09941e-07,-1.4856e-08,0.701548,0.000683822,-4.54509e-07,9.25979e-11,0.702231,0.000682913,-4.54231e-07,1.44855e-08,0.702913,0.000682048,-4.10775e-07,1.56992e-09,0.703595,0.000681231,-4.06065e-07,-2.07652e-08,0.704276,0.000680357,-4.68361e-07,2.18864e-08,0.704956,0.000679486,-4.02701e-07,-7.17595e-09,0.705635,0.000678659,-4.24229e-07,6.81748e-09,0.706313,0.000677831,-4.03777e-07,-2.0094e-08,0.70699,0.000676963,-4.64059e-07,1.39538e-08,0.707667,0.000676077,-4.22197e-07,2.38835e-08,0.708343,0.000675304,-3.50547e-07,-4.98831e-08,0.709018,0.000674453,-5.00196e-07,5.64395e-08,0.709692,0.000673622,-3.30878e-07,-5.66657e-08,0.710365,0.00067279,-5.00875e-07,5.1014e-08,0.711037,0.000671942,-3.47833e-07,-2.81809e-08,0.711709,0.000671161,-4.32376e-07,2.10513e-09,0.712379,0.000670303,-4.2606e-07,1.97604e-08,0.713049,0.00066951,-3.66779e-07,-2.15422e-08,0.713718,0.000668712,-4.31406e-07,6.8038e-09,0.714387,0.000667869,-4.10994e-07,-5.67295e-09,0.715054,0.00066703,-4.28013e-07,1.5888e-08,0.715721,0.000666222,-3.80349e-07,1.72576e-09,0.716387,0.000665467,-3.75172e-07,-2.27911e-08,0.717052,0.000664648,-4.43545e-07,2.9834e-08,0.717716,0.00066385,-3.54043e-07,-3.69401e-08,0.718379,0.000663031,-4.64864e-07,5.83219e-08,0.719042,0.000662277,-2.89898e-07,-7.71382e-08,0.719704,0.000661465,-5.21313e-07,7.14171e-08,0.720365,0.000660637,-3.07061e-07,-2.97161e-08,0.721025,0.000659934,-3.96209e-07,-1.21575e-08,0.721685,0.000659105,-4.32682e-07,1.87412e-08,0.722343,0.000658296,-3.76458e-07,-3.2029e-09,0.723001,0.000657533,-3.86067e-07,-5.9296e-09,0.723659,0.000656743,-4.03856e-07,2.69213e-08,0.724315,0.000656016,-3.23092e-07,-4.21511e-08,0.724971,0.000655244,-4.49545e-07,2.24737e-08,0.725625,0.000654412,-3.82124e-07,1.18611e-08,0.726279,0.000653683,-3.46541e-07,-1.03132e-08,0.726933,0.000652959,-3.7748e-07,-3.02128e-08,0.727585,0.000652114,-4.68119e-07,7.15597e-08,0.728237,0.000651392,-2.5344e-07,-7.72119e-08,0.728888,0.000650654,-4.85075e-07,5.8474e-08,0.729538,0.000649859,-3.09654e-07,-3.74746e-08,0.730188,0.000649127,-4.22077e-07,3.18197e-08,0.730837,0.000648379,-3.26618e-07,-3.01997e-08,0.731485,0.000647635,-4.17217e-07,2.93747e-08,0.732132,0.000646888,-3.29093e-07,-2.76943e-08,0.732778,0.000646147,-4.12176e-07,2.17979e-08,0.733424,0.000645388,-3.46783e-07,1.07292e-10,0.734069,0.000644695,-3.46461e-07,-2.22271e-08,0.734713,0.000643935,-4.13142e-07,2.91963e-08,0.735357,0.000643197,-3.25553e-07,-3.49536e-08,0.736,0.000642441,-4.30414e-07,5.10133e-08,0.736642,0.000641733,-2.77374e-07,-4.98904e-08,0.737283,0.000641028,-4.27045e-07,2.93392e-08,0.737924,0.000640262,-3.39028e-07,-7.86156e-09,0.738564,0.000639561,-3.62612e-07,2.10703e-09,0.739203,0.000638842,-3.56291e-07,-5.6653e-10,0.739842,0.000638128,-3.57991e-07,1.59086e-10,0.740479,0.000637412,-3.57513e-07,-6.98321e-11,0.741116,0.000636697,-3.57723e-07,1.20214e-10,0.741753,0.000635982,-3.57362e-07,-4.10987e-10,0.742388,0.000635266,-3.58595e-07,1.5237e-09,0.743023,0.000634553,-3.54024e-07,-5.68376e-09,0.743657,0.000633828,-3.71075e-07,2.12113e-08,0.744291,0.00063315,-3.07441e-07,-1.95569e-08,0.744924,0.000632476,-3.66112e-07,-2.58816e-09,0.745556,0.000631736,-3.73877e-07,2.99096e-08,0.746187,0.000631078,-2.84148e-07,-5.74454e-08,0.746818,0.000630337,-4.56484e-07,8.06629e-08,0.747448,0.000629666,-2.14496e-07,-8.63922e-08,0.748077,0.000628978,-4.73672e-07,8.60918e-08,0.748706,0.000628289,-2.15397e-07,-7.91613e-08,0.749334,0.000627621,-4.5288e-07,5.17393e-08,0.749961,0.00062687,-2.97663e-07,-8.58662e-09,0.750588,0.000626249,-3.23422e-07,-1.73928e-08,0.751214,0.00062555,-3.75601e-07,1.85532e-08,0.751839,0.000624855,-3.19941e-07,2.78479e-09,0.752463,0.000624223,-3.11587e-07,-2.96923e-08,0.753087,0.000623511,-4.00664e-07,5.63799e-08,0.75371,0.000622879,-2.31524e-07,-7.66179e-08,0.754333,0.000622186,-4.61378e-07,7.12778e-08,0.754955,0.000621477,-2.47545e-07,-2.96794e-08,0.755576,0.000620893,-3.36583e-07,-1.21648e-08,0.756196,0.000620183,-3.73077e-07,1.87339e-08,0.756816,0.000619493,-3.16875e-07,-3.16622e-09,0.757435,0.00061885,-3.26374e-07,-6.0691e-09,0.758054,0.000618179,-3.44581e-07,2.74426e-08,0.758672,0.000617572,-2.62254e-07,-4.40968e-08,0.759289,0.000616915,-3.94544e-07,2.97352e-08,0.759906,0.000616215,-3.05338e-07,-1.52393e-08,0.760522,0.000615559,-3.51056e-07,3.12221e-08,0.761137,0.000614951,-2.5739e-07,-5.00443e-08,0.761751,0.000614286,-4.07523e-07,4.9746e-08,0.762365,0.00061362,-2.58285e-07,-2.97303e-08,0.762979,0.000613014,-3.47476e-07,9.57079e-09,0.763591,0.000612348,-3.18764e-07,-8.55287e-09,0.764203,0.000611685,-3.44422e-07,2.46407e-08,0.764815,0.00061107,-2.705e-07,-3.04053e-08,0.765426,0.000610437,-3.61716e-07,3.73759e-08,0.766036,0.000609826,-2.49589e-07,-5.94935e-08,0.766645,0.000609149,-4.28069e-07,8.13889e-08,0.767254,0.000608537,-1.83902e-07,-8.72483e-08,0.767862,0.000607907,-4.45647e-07,8.87901e-08,0.76847,0.000607282,-1.79277e-07,-8.90983e-08,0.769077,0.000606656,-4.46572e-07,8.87892e-08,0.769683,0.000606029,-1.80204e-07,-8.72446e-08,0.770289,0.000605407,-4.41938e-07,8.13752e-08,0.770894,0.000604768,-1.97812e-07,-5.94423e-08,0.771498,0.000604194,-3.76139e-07,3.71848e-08,0.772102,0.000603553,-2.64585e-07,-2.96922e-08,0.772705,0.000602935,-3.53661e-07,2.19793e-08,0.773308,0.000602293,-2.87723e-07,1.37955e-09,0.77391,0.000601722,-2.83585e-07,-2.74976e-08,0.774512,0.000601072,-3.66077e-07,4.9006e-08,0.775112,0.000600487,-2.19059e-07,-4.93171e-08,0.775712,0.000599901,-3.67011e-07,2.90531e-08,0.776312,0.000599254,-2.79851e-07,-7.29081e-09,0.776911,0.000598673,-3.01724e-07,1.10077e-10,0.777509,0.00059807,-3.01393e-07,6.85053e-09,0.778107,0.000597487,-2.80842e-07,-2.75123e-08,0.778704,0.000596843,-3.63379e-07,4.35939e-08,0.779301,0.000596247,-2.32597e-07,-2.7654e-08,0.779897,0.000595699,-3.15559e-07,7.41741e-09,0.780492,0.00059509,-2.93307e-07,-2.01562e-09,0.781087,0.000594497,-2.99354e-07,6.45059e-10,0.781681,0.000593901,-2.97418e-07,-5.64635e-10,0.782275,0.000593304,-2.99112e-07,1.61347e-09,0.782868,0.000592711,-2.94272e-07,-5.88926e-09,0.78346,0.000592105,-3.1194e-07,2.19436e-08,0.784052,0.000591546,-2.46109e-07,-2.22805e-08,0.784643,0.000590987,-3.1295e-07,7.57368e-09,0.785234,0.000590384,-2.90229e-07,-8.01428e-09,0.785824,0.00058978,-3.14272e-07,2.44834e-08,0.786414,0.000589225,-2.40822e-07,-3.03148e-08,0.787003,0.000588652,-3.31766e-07,3.7171e-08,0.787591,0.0005881,-2.20253e-07,-5.87646e-08,0.788179,0.000587483,-3.96547e-07,7.86782e-08,0.788766,0.000586926,-1.60512e-07,-7.71342e-08,0.789353,0.000586374,-3.91915e-07,5.10444e-08,0.789939,0.000585743,-2.38782e-07,-7.83422e-09,0.790524,0.000585242,-2.62284e-07,-1.97076e-08,0.791109,0.000584658,-3.21407e-07,2.70598e-08,0.791693,0.000584097,-2.40228e-07,-2.89269e-08,0.792277,0.000583529,-3.27008e-07,2.90431e-08,0.792861,0.000582963,-2.39879e-07,-2.76409e-08,0.793443,0.0005824,-3.22802e-07,2.1916e-08,0.794025,0.00058182,-2.57054e-07,-4.18368e-10,0.794607,0.000581305,-2.58309e-07,-2.02425e-08,0.795188,0.000580727,-3.19036e-07,2.17838e-08,0.795768,0.000580155,-2.53685e-07,-7.28814e-09,0.796348,0.000579625,-2.75549e-07,7.36871e-09,0.796928,0.000579096,-2.53443e-07,-2.21867e-08,0.797506,0.000578523,-3.20003e-07,2.17736e-08,0.798085,0.000577948,-2.54683e-07,-5.30296e-09,0.798662,0.000577423,-2.70592e-07,-5.61698e-10,0.799239,0.00057688,-2.72277e-07,7.54977e-09,0.799816,0.000576358,-2.49627e-07,-2.96374e-08,0.800392,0.00057577,-3.38539e-07,5.1395e-08,0.800968,0.000575247,-1.84354e-07,-5.67335e-08,0.801543,0.000574708,-3.54555e-07,5.63297e-08,0.802117,0.000574168,-1.85566e-07,-4.93759e-08,0.802691,0.000573649,-3.33693e-07,2.19646e-08,0.803264,0.000573047,-2.678e-07,2.1122e-08,0.803837,0.000572575,-2.04433e-07,-4.68482e-08,0.804409,0.000572026,-3.44978e-07,4.70613e-08,0.804981,0.000571477,-2.03794e-07,-2.21877e-08,0.805552,0.000571003,-2.70357e-07,-1.79153e-08,0.806123,0.000570408,-3.24103e-07,3.42443e-08,0.806693,0.000569863,-2.2137e-07,1.47556e-10,0.807263,0.000569421,-2.20928e-07,-3.48345e-08,0.807832,0.000568874,-3.25431e-07,1.99812e-08,0.808401,0.000568283,-2.65487e-07,1.45143e-08,0.808969,0.000567796,-2.21945e-07,-1.84338e-08,0.809536,0.000567297,-2.77246e-07,-3.83608e-10,0.810103,0.000566741,-2.78397e-07,1.99683e-08,0.81067,0.000566244,-2.18492e-07,-1.98848e-08,0.811236,0.000565747,-2.78146e-07,-3.38976e-11,0.811801,0.000565191,-2.78248e-07,2.00204e-08,0.812366,0.000564695,-2.18187e-07,-2.04429e-08,0.812931,0.000564197,-2.79516e-07,2.1467e-09,0.813495,0.000563644,-2.73076e-07,1.18561e-08,0.814058,0.000563134,-2.37507e-07,1.00334e-08,0.814621,0.000562689,-2.07407e-07,-5.19898e-08,0.815183,0.000562118,-3.63376e-07,7.87163e-08,0.815745,0.000561627,-1.27227e-07,-8.40616e-08,0.816306,0.000561121,-3.79412e-07,7.87163e-08,0.816867,0.000560598,-1.43263e-07,-5.19898e-08,0.817428,0.000560156,-2.99233e-07,1.00335e-08,0.817988,0.000559587,-2.69132e-07,1.18559e-08,0.818547,0.000559085,-2.33564e-07,2.14764e-09,0.819106,0.000558624,-2.27122e-07,-2.04464e-08,0.819664,0.000558108,-2.88461e-07,2.00334e-08,0.820222,0.000557591,-2.28361e-07,-8.24277e-11,0.820779,0.000557135,-2.28608e-07,-1.97037e-08,0.821336,0.000556618,-2.87719e-07,1.92925e-08,0.821893,0.000556101,-2.29841e-07,2.13831e-09,0.822448,0.000555647,-2.23427e-07,-2.78458e-08,0.823004,0.000555117,-3.06964e-07,4.96402e-08,0.823559,0.000554652,-1.58043e-07,-5.15058e-08,0.824113,0.000554181,-3.12561e-07,3.71737e-08,0.824667,0.000553668,-2.0104e-07,-3.75844e-08,0.82522,0.000553153,-3.13793e-07,5.35592e-08,0.825773,0.000552686,-1.53115e-07,-5.74431e-08,0.826326,0.000552207,-3.25444e-07,5.7004e-08,0.826878,0.000551728,-1.54433e-07,-5.13635e-08,0.827429,0.000551265,-3.08523e-07,2.92406e-08,0.82798,0.000550735,-2.20801e-07,-5.99424e-09,0.828531,0.000550276,-2.38784e-07,-5.26363e-09,0.829081,0.000549782,-2.54575e-07,2.70488e-08,0.82963,0.000549354,-1.73429e-07,-4.33268e-08,0.83018,0.000548878,-3.03409e-07,2.7049e-08,0.830728,0.000548352,-2.22262e-07,-5.26461e-09,0.831276,0.000547892,-2.38056e-07,-5.99057e-09,0.831824,0.000547397,-2.56027e-07,2.92269e-08,0.832371,0.000546973,-1.68347e-07,-5.13125e-08,0.832918,0.000546482,-3.22284e-07,5.68139e-08,0.833464,0.000546008,-1.51843e-07,-5.67336e-08,0.83401,0.000545534,-3.22043e-07,5.09113e-08,0.834555,0.000545043,-1.6931e-07,-2.77022e-08,0.8351,0.000544621,-2.52416e-07,2.92924e-10,0.835644,0.000544117,-2.51537e-07,2.65305e-08,0.836188,0.000543694,-1.71946e-07,-4.68105e-08,0.836732,0.00054321,-3.12377e-07,4.15021e-08,0.837275,0.000542709,-1.87871e-07,1.13355e-11,0.837817,0.000542334,-1.87837e-07,-4.15474e-08,0.838359,0.000541833,-3.12479e-07,4.69691e-08,0.838901,0.000541349,-1.71572e-07,-2.71196e-08,0.839442,0.000540925,-2.52931e-07,1.90462e-09,0.839983,0.000540425,-2.47217e-07,1.95011e-08,0.840523,0.000539989,-1.88713e-07,-2.03045e-08,0.841063,0.00053955,-2.49627e-07,2.11216e-09,0.841602,0.000539057,-2.4329e-07,1.18558e-08,0.842141,0.000538606,-2.07723e-07,1.00691e-08,0.842679,0.000538221,-1.77516e-07,-5.21324e-08,0.843217,0.00053771,-3.33913e-07,7.92513e-08,0.843755,0.00053728,-9.6159e-08,-8.60587e-08,0.844292,0.000536829,-3.54335e-07,8.61696e-08,0.844828,0.000536379,-9.58263e-08,-7.98057e-08,0.845364,0.000535948,-3.35243e-07,5.42394e-08,0.8459,0.00053544,-1.72525e-07,-1.79426e-08,0.846435,0.000535041,-2.26353e-07,1.75308e-08,0.84697,0.000534641,-1.73761e-07,-5.21806e-08,0.847505,0.000534137,-3.30302e-07,7.19824e-08,0.848038,0.000533692,-1.14355e-07,-5.69349e-08,0.848572,0.000533293,-2.8516e-07,3.65479e-08,0.849105,0.000532832,-1.75516e-07,-2.96519e-08,0.849638,0.000532392,-2.64472e-07,2.2455e-08,0.85017,0.000531931,-1.97107e-07,-5.63451e-10,0.850702,0.000531535,-1.98797e-07,-2.02011e-08,0.851233,0.000531077,-2.59401e-07,2.17634e-08,0.851764,0.000530623,-1.94111e-07,-7.24794e-09,0.852294,0.000530213,-2.15854e-07,7.22832e-09,0.852824,0.000529803,-1.94169e-07,-2.16653e-08,0.853354,0.00052935,-2.59165e-07,1.98283e-08,0.853883,0.000528891,-1.9968e-07,1.95678e-09,0.854412,0.000528497,-1.9381e-07,-2.76554e-08,0.85494,0.000528027,-2.76776e-07,4.90603e-08,0.855468,0.00052762,-1.29596e-07,-4.93764e-08,0.855995,0.000527213,-2.77725e-07,2.92361e-08,0.856522,0.000526745,-1.90016e-07,-7.96341e-09,0.857049,0.000526341,-2.13907e-07,2.61752e-09,0.857575,0.000525922,-2.06054e-07,-2.50665e-09,0.8581,0.000525502,-2.13574e-07,7.40906e-09,0.858626,0.000525097,-1.91347e-07,-2.71296e-08,0.859151,0.000524633,-2.72736e-07,4.15048e-08,0.859675,0.000524212,-1.48221e-07,-1.96802e-08,0.860199,0.000523856,-2.07262e-07,-2.23886e-08,0.860723,0.000523375,-2.74428e-07,4.96299e-08,0.861246,0.000522975,-1.25538e-07,-5.69216e-08,0.861769,0.000522553,-2.96303e-07,5.88473e-08,0.862291,0.000522137,-1.19761e-07,-5.92584e-08,0.862813,0.00052172,-2.97536e-07,5.8977e-08,0.863334,0.000521301,-1.20605e-07,-5.74403e-08,0.863855,0.000520888,-2.92926e-07,5.15751e-08,0.864376,0.000520457,-1.38201e-07,-2.96506e-08,0.864896,0.000520091,-2.27153e-07,7.42277e-09,0.865416,0.000519659,-2.04885e-07,-4.05057e-11,0.865936,0.00051925,-2.05006e-07,-7.26074e-09,0.866455,0.000518818,-2.26788e-07,2.90835e-08,0.866973,0.000518451,-1.39538e-07,-4.94686e-08,0.867492,0.000518024,-2.87944e-07,4.95814e-08,0.868009,0.000517597,-1.39199e-07,-2.96479e-08,0.868527,0.000517229,-2.28143e-07,9.40539e-09,0.869044,0.000516801,-1.99927e-07,-7.9737e-09,0.86956,0.000516378,-2.23848e-07,2.24894e-08,0.870077,0.000515997,-1.5638e-07,-2.23793e-08,0.870592,0.000515617,-2.23517e-07,7.42302e-09,0.871108,0.000515193,-2.01248e-07,-7.31283e-09,0.871623,0.000514768,-2.23187e-07,2.18283e-08,0.872137,0.000514387,-1.57702e-07,-2.03959e-08,0.872652,0.000514011,-2.1889e-07,1.50711e-10,0.873165,0.000513573,-2.18437e-07,1.97931e-08,0.873679,0.000513196,-1.59058e-07,-1.97183e-08,0.874192,0.000512819,-2.18213e-07,-5.24324e-10,0.874704,0.000512381,-2.19786e-07,2.18156e-08,0.875217,0.000512007,-1.54339e-07,-2.71336e-08,0.875728,0.000511616,-2.3574e-07,2.71141e-08,0.87624,0.000511226,-1.54398e-07,-2.17182e-08,0.876751,0.000510852,-2.19552e-07,1.54131e-10,0.877262,0.000510414,-2.1909e-07,2.11017e-08,0.877772,0.000510039,-1.55785e-07,-2.49562e-08,0.878282,0.000509652,-2.30654e-07,1.91183e-08,0.878791,0.000509248,-1.73299e-07,8.08751e-09,0.8793,0.000508926,-1.49036e-07,-5.14684e-08,0.879809,0.000508474,-3.03441e-07,7.85766e-08,0.880317,0.000508103,-6.77112e-08,-8.40242e-08,0.880825,0.000507715,-3.19784e-07,7.87063e-08,0.881333,0.000507312,-8.36649e-08,-5.19871e-08,0.88184,0.000506988,-2.39626e-07,1.00327e-08,0.882346,0.000506539,-2.09528e-07,1.18562e-08,0.882853,0.000506156,-1.73959e-07,2.14703e-09,0.883359,0.000505814,-1.67518e-07,-2.04444e-08,0.883864,0.000505418,-2.28851e-07,2.00258e-08,0.88437,0.00050502,-1.68774e-07,-5.42855e-11,0.884874,0.000504682,-1.68937e-07,-1.98087e-08,0.885379,0.000504285,-2.28363e-07,1.96842e-08,0.885883,0.000503887,-1.6931e-07,6.76342e-10,0.886387,0.000503551,-1.67281e-07,-2.23896e-08,0.88689,0.000503149,-2.3445e-07,2.92774e-08,0.887393,0.000502768,-1.46618e-07,-3.51152e-08,0.887896,0.00050237,-2.51963e-07,5.15787e-08,0.888398,0.00050202,-9.72271e-08,-5.19903e-08,0.8889,0.00050167,-2.53198e-07,3.71732e-08,0.889401,0.000501275,-1.41678e-07,-3.70978e-08,0.889902,0.00050088,-2.52972e-07,5.16132e-08,0.890403,0.000500529,-9.81321e-08,-5.01459e-08,0.890903,0.000500183,-2.4857e-07,2.9761e-08,0.891403,0.000499775,-1.59287e-07,-9.29351e-09,0.891903,0.000499428,-1.87167e-07,7.41301e-09,0.892402,0.000499076,-1.64928e-07,-2.03585e-08,0.892901,0.000498685,-2.26004e-07,1.44165e-08,0.893399,0.000498276,-1.82754e-07,2.22974e-08,0.893898,0.000497978,-1.15862e-07,-4.40013e-08,0.894395,0.000497614,-2.47866e-07,3.44985e-08,0.894893,0.000497222,-1.44371e-07,-3.43882e-08,0.89539,0.00049683,-2.47535e-07,4.34497e-08,0.895886,0.000496465,-1.17186e-07,-2.02012e-08,0.896383,0.00049617,-1.7779e-07,-2.22497e-08,0.896879,0.000495748,-2.44539e-07,4.95952e-08,0.897374,0.000495408,-9.57532e-08,-5.69217e-08,0.89787,0.000495045,-2.66518e-07,5.88823e-08,0.898364,0.000494689,-8.98713e-08,-5.93983e-08,0.898859,0.000494331,-2.68066e-07,5.95017e-08,0.899353,0.000493973,-8.95613e-08,-5.9399e-08,0.899847,0.000493616,-2.67758e-07,5.8885e-08,0.90034,0.000493257,-9.11033e-08,-5.69317e-08,0.900833,0.000492904,-2.61898e-07,4.96326e-08,0.901326,0.000492529,-1.13001e-07,-2.23893e-08,0.901819,0.000492236,-1.80169e-07,-1.968e-08,0.902311,0.000491817,-2.39209e-07,4.15047e-08,0.902802,0.000491463,-1.14694e-07,-2.71296e-08,0.903293,0.000491152,-1.96083e-07,7.409e-09,0.903784,0.000490782,-1.73856e-07,-2.50645e-09,0.904275,0.000490427,-1.81376e-07,2.61679e-09,0.904765,0.000490072,-1.73525e-07,-7.96072e-09,0.905255,0.000489701,-1.97407e-07,2.92261e-08,0.905745,0.000489394,-1.09729e-07,-4.93389e-08,0.906234,0.000489027,-2.57746e-07,4.89204e-08,0.906723,0.000488658,-1.10985e-07,-2.71333e-08,0.907211,0.000488354,-1.92385e-07,8.30861e-12,0.907699,0.00048797,-1.9236e-07,2.71001e-08,0.908187,0.000487666,-1.1106e-07,-4.88041e-08,0.908675,0.000487298,-2.57472e-07,4.89069e-08,0.909162,0.000486929,-1.10751e-07,-2.76143e-08,0.909649,0.000486625,-1.93594e-07,1.9457e-09,0.910135,0.000486244,-1.87757e-07,1.98315e-08,0.910621,0.000485928,-1.28262e-07,-2.16671e-08,0.911107,0.000485606,-1.93264e-07,7.23216e-09,0.911592,0.000485241,-1.71567e-07,-7.26152e-09,0.912077,0.000484877,-1.93352e-07,2.18139e-08,0.912562,0.000484555,-1.2791e-07,-2.03895e-08,0.913047,0.000484238,-1.89078e-07,1.39494e-10,0.913531,0.000483861,-1.8866e-07,1.98315e-08,0.914014,0.000483543,-1.29165e-07,-1.98609e-08,0.914498,0.000483225,-1.88748e-07,7.39912e-12,0.914981,0.000482847,-1.88726e-07,1.98313e-08,0.915463,0.000482529,-1.29232e-07,-1.9728e-08,0.915946,0.000482212,-1.88416e-07,-5.24035e-10,0.916428,0.000481833,-1.89988e-07,2.18241e-08,0.916909,0.000481519,-1.24516e-07,-2.71679e-08,0.917391,0.000481188,-2.06019e-07,2.72427e-08,0.917872,0.000480858,-1.24291e-07,-2.21985e-08,0.918353,0.000480543,-1.90886e-07,1.94644e-09,0.918833,0.000480167,-1.85047e-07,1.44127e-08,0.919313,0.00047984,-1.41809e-07,7.39438e-12,0.919793,0.000479556,-1.41787e-07,-1.44423e-08,0.920272,0.000479229,-1.85114e-07,-1.84291e-09,0.920751,0.000478854,-1.90642e-07,2.18139e-08,0.92123,0.000478538,-1.25201e-07,-2.58081e-08,0.921708,0.00047821,-2.02625e-07,2.18139e-08,0.922186,0.00047787,-1.37183e-07,-1.84291e-09,0.922664,0.00047759,-1.42712e-07,-1.44423e-08,0.923141,0.000477262,-1.86039e-07,7.34701e-12,0.923618,0.00047689,-1.86017e-07,1.44129e-08,0.924095,0.000476561,-1.42778e-07,1.94572e-09,0.924572,0.000476281,-1.36941e-07,-2.21958e-08,0.925048,0.000475941,-2.03528e-07,2.72327e-08,0.925523,0.000475615,-1.2183e-07,-2.71304e-08,0.925999,0.00047529,-2.03221e-07,2.16843e-08,0.926474,0.000474949,-1.38168e-07,-2.16005e-12,0.926949,0.000474672,-1.38175e-07,-2.16756e-08,0.927423,0.000474331,-2.03202e-07,2.71001e-08,0.927897,0.000474006,-1.21902e-07,-2.71201e-08,0.928371,0.000473681,-2.03262e-07,2.17757e-08,0.928845,0.00047334,-1.37935e-07,-3.78028e-10,0.929318,0.000473063,-1.39069e-07,-2.02636e-08,0.929791,0.000472724,-1.9986e-07,2.18276e-08,0.930263,0.000472389,-1.34377e-07,-7.44231e-09,0.930736,0.000472098,-1.56704e-07,7.94165e-09,0.931208,0.000471809,-1.32879e-07,-2.43243e-08,0.931679,0.00047147,-2.05851e-07,2.97508e-08,0.932151,0.000471148,-1.16599e-07,-3.50742e-08,0.932622,0.000470809,-2.21822e-07,5.09414e-08,0.933092,0.000470518,-6.89976e-08,-4.94821e-08,0.933563,0.000470232,-2.17444e-07,2.77775e-08,0.934033,0.00046988,-1.34111e-07,-2.02351e-09,0.934502,0.000469606,-1.40182e-07,-1.96835e-08,0.934972,0.000469267,-1.99232e-07,2.11529e-08,0.935441,0.000468932,-1.35774e-07,-5.32332e-09,0.93591,0.000468644,-1.51743e-07,1.40413e-10,0.936378,0.000468341,-1.51322e-07,4.76166e-09,0.936846,0.000468053,-1.37037e-07,-1.9187e-08,0.937314,0.000467721,-1.94598e-07,1.23819e-08,0.937782,0.000467369,-1.57453e-07,2.92642e-08,0.938249,0.000467142,-6.96601e-08,-6.98342e-08,0.938716,0.000466793,-2.79163e-07,7.12586e-08,0.939183,0.000466449,-6.53869e-08,-3.63863e-08,0.939649,0.000466209,-1.74546e-07,1.46818e-08,0.940115,0.000465904,-1.305e-07,-2.2341e-08,0.940581,0.000465576,-1.97523e-07,1.50774e-08,0.941046,0.000465226,-1.52291e-07,2.16359e-08,0.941511,0.000464986,-8.73832e-08,-4.20162e-08,0.941976,0.000464685,-2.13432e-07,2.72198e-08,0.942441,0.00046434,-1.31773e-07,-7.2581e-09,0.942905,0.000464055,-1.53547e-07,1.81263e-09,0.943369,0.000463753,-1.48109e-07,7.58386e-12,0.943832,0.000463457,-1.48086e-07,-1.84298e-09,0.944296,0.000463155,-1.53615e-07,7.36433e-09,0.944759,0.00046287,-1.31522e-07,-2.76143e-08,0.945221,0.000462524,-2.14365e-07,4.34883e-08,0.945684,0.000462226,-8.39003e-08,-2.71297e-08,0.946146,0.000461977,-1.65289e-07,5.42595e-09,0.946608,0.000461662,-1.49012e-07,5.42593e-09,0.947069,0.000461381,-1.32734e-07,-2.71297e-08,0.94753,0.000461034,-2.14123e-07,4.34881e-08,0.947991,0.000460736,-8.36585e-08,-2.76134e-08,0.948452,0.000460486,-1.66499e-07,7.36083e-09,0.948912,0.000460175,-1.44416e-07,-1.82993e-09,0.949372,0.000459881,-1.49906e-07,-4.11073e-11,0.949832,0.000459581,-1.50029e-07,1.99434e-09,0.950291,0.000459287,-1.44046e-07,-7.93627e-09,0.950751,0.000458975,-1.67855e-07,2.97507e-08,0.951209,0.000458728,-7.86029e-08,-5.1462e-08,0.951668,0.000458417,-2.32989e-07,5.6888e-08,0.952126,0.000458121,-6.2325e-08,-5.68806e-08,0.952584,0.000457826,-2.32967e-07,5.14251e-08,0.953042,0.000457514,-7.86914e-08,-2.96107e-08,0.953499,0.000457268,-1.67523e-07,7.41296e-09,0.953956,0.000456955,-1.45285e-07,-4.11262e-11,0.954413,0.000456665,-1.45408e-07,-7.24847e-09,0.95487,0.000456352,-1.67153e-07,2.9035e-08,0.955326,0.000456105,-8.00484e-08,-4.92869e-08,0.955782,0.000455797,-2.27909e-07,4.89032e-08,0.956238,0.000455488,-8.11994e-08,-2.71166e-08,0.956693,0.000455244,-1.62549e-07,-4.13678e-11,0.957148,0.000454919,-1.62673e-07,2.72821e-08,0.957603,0.000454675,-8.0827e-08,-4.94824e-08,0.958057,0.000454365,-2.29274e-07,5.14382e-08,0.958512,0.000454061,-7.49597e-08,-3.7061e-08,0.958965,0.0004538,-1.86143e-07,3.72013e-08,0.959419,0.000453539,-7.45389e-08,-5.21396e-08,0.959873,0.000453234,-2.30958e-07,5.21476e-08,0.960326,0.000452928,-7.45146e-08,-3.72416e-08,0.960778,0.000452667,-1.8624e-07,3.72143e-08,0.961231,0.000452407,-7.45967e-08,-5.20109e-08,0.961683,0.000452101,-2.30629e-07,5.16199e-08,0.962135,0.000451795,-7.57696e-08,-3.52595e-08,0.962587,0.000451538,-1.81548e-07,2.98133e-08,0.963038,0.000451264,-9.2108e-08,-2.43892e-08,0.963489,0.000451007,-1.65276e-07,8.13892e-09,0.96394,0.000450701,-1.40859e-07,-8.16647e-09,0.964391,0.000450394,-1.65358e-07,2.45269e-08,0.964841,0.000450137,-9.17775e-08,-3.03367e-08,0.965291,0.000449863,-1.82787e-07,3.7215e-08,0.965741,0.000449609,-7.11424e-08,-5.89188e-08,0.96619,0.00044929,-2.47899e-07,7.92509e-08,0.966639,0.000449032,-1.01462e-08,-7.92707e-08,0.967088,0.000448773,-2.47958e-07,5.90181e-08,0.967537,0.000448455,-7.0904e-08,-3.75925e-08,0.967985,0.0004482,-1.83681e-07,3.17471e-08,0.968433,0.000447928,-8.84401e-08,-2.97913e-08,0.968881,0.000447662,-1.77814e-07,2.78133e-08,0.969329,0.000447389,-9.4374e-08,-2.18572e-08,0.969776,0.000447135,-1.59946e-07,1.10134e-11,0.970223,0.000446815,-1.59913e-07,2.18132e-08,0.97067,0.000446561,-9.44732e-08,-2.76591e-08,0.971116,0.000446289,-1.7745e-07,2.92185e-08,0.971562,0.000446022,-8.97948e-08,-2.96104e-08,0.972008,0.000445753,-1.78626e-07,2.96185e-08,0.972454,0.000445485,-8.97706e-08,-2.92588e-08,0.972899,0.000445218,-1.77547e-07,2.78123e-08,0.973344,0.000444946,-9.41103e-08,-2.23856e-08,0.973789,0.000444691,-1.61267e-07,2.12559e-09,0.974233,0.000444374,-1.5489e-07,1.38833e-08,0.974678,0.000444106,-1.13241e-07,1.94591e-09,0.975122,0.000443886,-1.07403e-07,-2.16669e-08,0.975565,0.000443606,-1.72404e-07,2.5117e-08,0.976009,0.000443336,-9.70526e-08,-1.91963e-08,0.976452,0.000443085,-1.54642e-07,-7.93627e-09,0.976895,0.000442752,-1.7845e-07,5.09414e-08,0.977338,0.000442548,-2.56262e-08,-7.66201e-08,0.97778,0.000442266,-2.55486e-07,7.67249e-08,0.978222,0.000441986,-2.53118e-08,-5.14655e-08,0.978664,0.000441781,-1.79708e-07,9.92773e-09,0.979106,0.000441451,-1.49925e-07,1.17546e-08,0.979547,0.000441186,-1.14661e-07,2.65868e-09,0.979988,0.000440965,-1.06685e-07,-2.23893e-08,0.980429,0.000440684,-1.73853e-07,2.72939e-08,0.980869,0.000440419,-9.19716e-08,-2.71816e-08,0.98131,0.000440153,-1.73516e-07,2.18278e-08,0.98175,0.000439872,-1.08033e-07,-5.24833e-10,0.982189,0.000439654,-1.09607e-07,-1.97284e-08,0.982629,0.000439376,-1.68793e-07,1.98339e-08,0.983068,0.000439097,-1.09291e-07,-2.62901e-12,0.983507,0.000438879,-1.09299e-07,-1.98234e-08,0.983946,0.000438601,-1.68769e-07,1.96916e-08,0.984384,0.000438322,-1.09694e-07,6.6157e-10,0.984823,0.000438105,-1.0771e-07,-2.23379e-08,0.985261,0.000437823,-1.74723e-07,2.90855e-08,0.985698,0.00043756,-8.74669e-08,-3.43992e-08,0.986136,0.000437282,-1.90665e-07,4.89068e-08,0.986573,0.000437048,-4.39442e-08,-4.20188e-08,0.98701,0.000436834,-1.7e-07,-4.11073e-11,0.987446,0.000436494,-1.70124e-07,4.21832e-08,0.987883,0.00043628,-4.35742e-08,-4.94824e-08,0.988319,0.000436044,-1.92021e-07,3.6537e-08,0.988755,0.00043577,-8.24102e-08,-3.70611e-08,0.989191,0.000435494,-1.93593e-07,5.21026e-08,0.989626,0.000435263,-3.72855e-08,-5.21402e-08,0.990061,0.000435032,-1.93706e-07,3.7249e-08,0.990496,0.000434756,-8.19592e-08,-3.72512e-08,0.990931,0.000434481,-1.93713e-07,5.21511e-08,0.991365,0.00043425,-3.72595e-08,-5.21439e-08,0.991799,0.000434019,-1.93691e-07,3.72152e-08,0.992233,0.000433743,-8.20456e-08,-3.71123e-08,0.992667,0.000433468,-1.93382e-07,5.16292e-08,0.9931,0.000433236,-3.84947e-08,-5.01953e-08,0.993533,0.000433008,-1.89081e-07,2.99427e-08,0.993966,0.00043272,-9.92525e-08,-9.9708e-09,0.994399,0.000432491,-1.29165e-07,9.94051e-09,0.994831,0.000432263,-9.93434e-08,-2.97912e-08,0.995263,0.000431975,-1.88717e-07,4.96198e-08,0.995695,0.000431746,-3.98578e-08,-4.94785e-08,0.996127,0.000431518,-1.88293e-07,2.9085e-08,0.996558,0.000431229,-1.01038e-07,-7.25675e-09,0.996989,0.000431005,-1.22809e-07,-5.79945e-11,0.99742,0.000430759,-1.22983e-07,7.48873e-09,0.997851,0.000430536,-1.00516e-07,-2.98969e-08,0.998281,0.000430245,-1.90207e-07,5.24942e-08,0.998711,0.000430022,-3.27246e-08,-6.08706e-08,0.999141,0.000429774,-2.15336e-07,7.17788e-08,0.999571,0.000429392,0.,0.}; + + template + __device__ __forceinline__ void Lab2RGBConvert_f(const T& src, D& dst) + { + const float lThresh = 0.008856f * 903.3f; + const float fThresh = 7.787f * 0.008856f + 16.0f / 116.0f; + + float Y, fy; + + if (src.x <= lThresh) + { + Y = src.x / 903.3f; + fy = 7.787f * Y + 16.0f / 116.0f; + } + else + { + fy = (src.x + 16.0f) / 116.0f; + Y = fy * fy * fy; + } + + float X = src.y / 500.0f + fy; + float Z = fy - src.z / 200.0f; + + if (X <= fThresh) + X = (X - 16.0f / 116.0f) / 7.787f; + else + X = X * X * X; + + if (Z <= fThresh) + Z = (Z - 16.0f / 116.0f) / 7.787f; + else + Z = Z * Z * Z; + + float B = 0.052891f * X - 0.204043f * Y + 1.151152f * Z; + float G = -0.921235f * X + 1.875991f * Y + 0.045244f * Z; + float R = 3.079933f * X - 1.537150f * Y - 0.542782f * Z; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + } + + dst.x = blueIdx == 0 ? B : R; + dst.y = G; + dst.z = blueIdx == 0 ? R : B; + setAlpha(dst, ColorChannel::max()); + } + + template + __device__ __forceinline__ void Lab2RGBConvert_b(const T& src, D& dst) + { + float3 srcf, dstf; + + srcf.x = src.x * (100.f / 255.f); + srcf.y = src.y - 128; + srcf.z = src.z - 128; + + Lab2RGBConvert_f(srcf, dstf); + + dst.x = saturate_cast(dstf.x * 255.f); + dst.y = saturate_cast(dstf.y * 255.f); + dst.z = saturate_cast(dstf.z * 255.f); + setAlpha(dst, ColorChannel::max()); + } + + template struct Lab2RGB; + template + struct Lab2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Lab2RGBConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Lab2RGB() {} + __host__ __device__ __forceinline__ Lab2RGB(const Lab2RGB&) {} + }; + template + struct Lab2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Lab2RGBConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Lab2RGB() {} + __host__ __device__ __forceinline__ Lab2RGB(const Lab2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Lab2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> Luv ///////////////////////////////////// + + namespace color_detail + { + __constant__ float c_LabCbrtTab[] = {0.137931,0.0114066,0.,1.18859e-07,0.149338,0.011407,3.56578e-07,-5.79396e-07,0.160745,0.0114059,-1.38161e-06,2.16892e-06,0.172151,0.0114097,5.12516e-06,-8.0814e-06,0.183558,0.0113957,-1.9119e-05,3.01567e-05,0.194965,0.0114479,7.13509e-05,-0.000112545,0.206371,0.011253,-0.000266285,-0.000106493,0.217252,0.0104009,-0.000585765,7.32149e-05,0.22714,0.00944906,-0.00036612,1.21917e-05,0.236235,0.0087534,-0.000329545,2.01753e-05,0.244679,0.00815483,-0.000269019,1.24435e-05,0.252577,0.00765412,-0.000231689,1.05618e-05,0.26001,0.00722243,-0.000200003,8.26662e-06,0.267041,0.00684723,-0.000175203,6.76746e-06,0.27372,0.00651712,-0.000154901,5.61192e-06,0.280088,0.00622416,-0.000138065,4.67009e-06,0.286179,0.00596204,-0.000124055,3.99012e-06,0.292021,0.0057259,-0.000112085,3.36032e-06,0.297638,0.00551181,-0.000102004,2.95338e-06,0.30305,0.00531666,-9.31435e-05,2.52875e-06,0.308277,0.00513796,-8.55572e-05,2.22022e-06,0.313331,0.00497351,-7.88966e-05,1.97163e-06,0.318228,0.00482163,-7.29817e-05,1.7248e-06,0.322978,0.00468084,-6.78073e-05,1.55998e-06,0.327593,0.0045499,-6.31274e-05,1.36343e-06,0.332081,0.00442774,-5.90371e-05,1.27136e-06,0.336451,0.00431348,-5.5223e-05,1.09111e-06,0.34071,0.00420631,-5.19496e-05,1.0399e-06,0.344866,0.00410553,-4.88299e-05,9.18347e-07,0.348923,0.00401062,-4.60749e-05,8.29942e-07,0.352889,0.00392096,-4.35851e-05,7.98478e-07,0.356767,0.00383619,-4.11896e-05,6.84917e-07,0.360562,0.00375586,-3.91349e-05,6.63976e-07,0.36428,0.00367959,-3.7143e-05,5.93086e-07,0.367923,0.00360708,-3.53637e-05,5.6976e-07,0.371495,0.00353806,-3.36544e-05,4.95533e-07,0.375,0.00347224,-3.21678e-05,4.87951e-07,0.378441,0.00340937,-3.0704e-05,4.4349e-07,0.38182,0.00334929,-2.93735e-05,4.20297e-07,0.38514,0.0032918,-2.81126e-05,3.7872e-07,0.388404,0.00323671,-2.69764e-05,3.596e-07,0.391614,0.00318384,-2.58976e-05,3.5845e-07,0.394772,0.00313312,-2.48223e-05,2.92765e-07,0.397881,0.00308435,-2.3944e-05,3.18232e-07,0.400942,0.00303742,-2.29893e-05,2.82046e-07,0.403957,0.00299229,-2.21432e-05,2.52315e-07,0.406927,0.00294876,-2.13862e-05,2.58416e-07,0.409855,0.00290676,-2.0611e-05,2.33939e-07,0.412741,0.00286624,-1.99092e-05,2.36342e-07,0.415587,0.00282713,-1.92001e-05,1.916e-07,0.418396,0.00278931,-1.86253e-05,2.1915e-07,0.421167,0.00275271,-1.79679e-05,1.83498e-07,0.423901,0.00271733,-1.74174e-05,1.79343e-07,0.426602,0.00268303,-1.68794e-05,1.72013e-07,0.429268,0.00264979,-1.63633e-05,1.75686e-07,0.431901,0.00261759,-1.58363e-05,1.3852e-07,0.434503,0.00258633,-1.54207e-05,1.64304e-07,0.437074,0.00255598,-1.49278e-05,1.28136e-07,0.439616,0.00252651,-1.45434e-05,1.57618e-07,0.442128,0.0024979,-1.40705e-05,1.0566e-07,0.444612,0.00247007,-1.37535e-05,1.34998e-07,0.447068,0.00244297,-1.33485e-05,1.29207e-07,0.449498,0.00241666,-1.29609e-05,9.32347e-08,0.451902,0.00239102,-1.26812e-05,1.23703e-07,0.45428,0.00236603,-1.23101e-05,9.74072e-08,0.456634,0.0023417,-1.20179e-05,1.12518e-07,0.458964,0.002318,-1.16803e-05,7.83681e-08,0.46127,0.00229488,-1.14452e-05,1.10452e-07,0.463554,0.00227232,-1.11139e-05,7.58719e-08,0.465815,0.00225032,-1.08863e-05,9.2699e-08,0.468055,0.00222882,-1.06082e-05,8.97738e-08,0.470273,0.00220788,-1.03388e-05,5.4845e-08,0.47247,0.00218736,-1.01743e-05,1.0808e-07,0.474648,0.00216734,-9.85007e-06,4.9277e-08,0.476805,0.00214779,-9.70224e-06,8.22408e-08,0.478943,0.00212863,-9.45551e-06,6.87942e-08,0.481063,0.00210993,-9.24913e-06,5.98144e-08,0.483163,0.00209161,-9.06969e-06,7.93789e-08,0.485246,0.00207371,-8.83155e-06,3.99032e-08,0.487311,0.00205616,-8.71184e-06,8.88325e-08,0.489358,0.002039,-8.44534e-06,2.20004e-08,0.491389,0.00202218,-8.37934e-06,9.13872e-08,0.493403,0.0020057,-8.10518e-06,2.96829e-08,0.495401,0.00198957,-8.01613e-06,5.81028e-08,0.497382,0.00197372,-7.84183e-06,6.5731e-08,0.499348,0.00195823,-7.64463e-06,3.66019e-08,0.501299,0.00194305,-7.53483e-06,2.62811e-08,0.503234,0.00192806,-7.45598e-06,9.66907e-08,0.505155,0.00191344,-7.16591e-06,4.18928e-09,0.507061,0.00189912,-7.15334e-06,6.53665e-08,0.508953,0.00188501,-6.95724e-06,3.23686e-08,0.510831,0.00187119,-6.86014e-06,4.35774e-08,0.512696,0.0018576,-6.72941e-06,3.17406e-08,0.514547,0.00184424,-6.63418e-06,6.78785e-08,0.516384,0.00183117,-6.43055e-06,-5.23126e-09,0.518209,0.0018183,-6.44624e-06,7.22562e-08,0.520021,0.00180562,-6.22947e-06,1.42292e-08,0.52182,0.0017932,-6.18679e-06,4.9641e-08,0.523607,0.00178098,-6.03786e-06,2.56259e-08,0.525382,0.00176898,-5.96099e-06,2.66696e-08,0.527145,0.00175714,-5.88098e-06,4.65094e-08,0.528897,0.00174552,-5.74145e-06,2.57114e-08,0.530637,0.00173411,-5.66431e-06,2.94588e-08,0.532365,0.00172287,-5.57594e-06,3.52667e-08,0.534082,0.00171182,-5.47014e-06,8.28868e-09,0.535789,0.00170091,-5.44527e-06,5.07871e-08,0.537484,0.00169017,-5.29291e-06,2.69817e-08,0.539169,0.00167967,-5.21197e-06,2.01009e-08,0.540844,0.0016693,-5.15166e-06,1.18237e-08,0.542508,0.00165903,-5.11619e-06,5.18135e-08,0.544162,0.00164896,-4.96075e-06,1.9341e-08,0.545806,0.00163909,-4.90273e-06,-9.96867e-09,0.54744,0.00162926,-4.93263e-06,8.01382e-08,0.549064,0.00161963,-4.69222e-06,-1.25601e-08,0.550679,0.00161021,-4.7299e-06,2.97067e-08,0.552285,0.00160084,-4.64078e-06,1.29426e-08,0.553881,0.0015916,-4.60195e-06,3.77327e-08,0.555468,0.00158251,-4.48875e-06,1.49412e-08,0.557046,0.00157357,-4.44393e-06,2.17118e-08,0.558615,0.00156475,-4.3788e-06,1.74206e-08,0.560176,0.00155605,-4.32653e-06,2.78152e-08,0.561727,0.00154748,-4.24309e-06,-9.47239e-09,0.563271,0.00153896,-4.27151e-06,6.9679e-08,0.564805,0.00153063,-4.06247e-06,-3.08246e-08,0.566332,0.00152241,-4.15494e-06,5.36188e-08,0.56785,0.00151426,-3.99409e-06,-4.83594e-09,0.56936,0.00150626,-4.00859e-06,2.53293e-08,0.570863,0.00149832,-3.93261e-06,2.27286e-08,0.572357,0.00149052,-3.86442e-06,2.96541e-09,0.573844,0.0014828,-3.85552e-06,2.50147e-08,0.575323,0.00147516,-3.78048e-06,1.61842e-08,0.576794,0.00146765,-3.73193e-06,2.94582e-08,0.578258,0.00146028,-3.64355e-06,-1.48076e-08,0.579715,0.00145295,-3.68798e-06,2.97724e-08,0.581164,0.00144566,-3.59866e-06,1.49272e-08,0.582606,0.00143851,-3.55388e-06,2.97285e-08,0.584041,0.00143149,-3.46469e-06,-1.46323e-08,0.585469,0.00142451,-3.50859e-06,2.88004e-08,0.58689,0.00141758,-3.42219e-06,1.864e-08,0.588304,0.00141079,-3.36627e-06,1.58482e-08,0.589712,0.00140411,-3.31872e-06,-2.24279e-08,0.591112,0.00139741,-3.38601e-06,7.38639e-08,0.592507,0.00139085,-3.16441e-06,-3.46088e-08,0.593894,0.00138442,-3.26824e-06,4.96675e-09,0.595275,0.0013779,-3.25334e-06,7.4346e-08,0.59665,0.00137162,-3.0303e-06,-6.39319e-08,0.598019,0.00136536,-3.2221e-06,6.21725e-08,0.599381,0.00135911,-3.03558e-06,-5.94423e-09,0.600737,0.00135302,-3.05341e-06,2.12091e-08,0.602087,0.00134697,-2.98979e-06,-1.92876e-08,0.603431,0.00134094,-3.04765e-06,5.5941e-08,0.604769,0.00133501,-2.87983e-06,-2.56622e-08,0.606101,0.00132917,-2.95681e-06,4.67078e-08,0.607427,0.0013234,-2.81669e-06,-4.19592e-08,0.608748,0.00131764,-2.94257e-06,6.15243e-08,0.610062,0.00131194,-2.75799e-06,-2.53244e-08,0.611372,0.00130635,-2.83397e-06,3.97739e-08,0.612675,0.0013008,-2.71465e-06,-1.45618e-08,0.613973,0.00129533,-2.75833e-06,1.84733e-08,0.615266,0.00128986,-2.70291e-06,2.73606e-10,0.616553,0.00128446,-2.70209e-06,4.00367e-08,0.617835,0.00127918,-2.58198e-06,-4.12113e-08,0.619111,0.00127389,-2.70561e-06,6.52039e-08,0.620383,0.00126867,-2.51e-06,-4.07901e-08,0.621649,0.00126353,-2.63237e-06,3.83516e-08,0.62291,0.00125838,-2.51732e-06,6.59315e-09,0.624166,0.00125337,-2.49754e-06,-5.11939e-09,0.625416,0.00124836,-2.5129e-06,1.38846e-08,0.626662,0.00124337,-2.47124e-06,9.18514e-09,0.627903,0.00123846,-2.44369e-06,8.97952e-09,0.629139,0.0012336,-2.41675e-06,1.45012e-08,0.63037,0.00122881,-2.37325e-06,-7.37949e-09,0.631597,0.00122404,-2.39538e-06,1.50169e-08,0.632818,0.00121929,-2.35033e-06,6.91648e-09,0.634035,0.00121461,-2.32958e-06,1.69219e-08,0.635248,0.00121,-2.27882e-06,-1.49997e-08,0.636455,0.0012054,-2.32382e-06,4.30769e-08,0.637659,0.00120088,-2.19459e-06,-3.80986e-08,0.638857,0.00119638,-2.30888e-06,4.97134e-08,0.640051,0.00119191,-2.15974e-06,-4.15463e-08,0.641241,0.00118747,-2.28438e-06,5.68667e-08,0.642426,0.00118307,-2.11378e-06,-7.10641e-09,0.643607,0.00117882,-2.1351e-06,-2.8441e-08,0.644784,0.00117446,-2.22042e-06,6.12658e-08,0.645956,0.00117021,-2.03663e-06,-3.78083e-08,0.647124,0.00116602,-2.15005e-06,3.03627e-08,0.648288,0.00116181,-2.05896e-06,-2.40379e-08,0.649448,0.00115762,-2.13108e-06,6.57887e-08,0.650603,0.00115356,-1.93371e-06,-6.03028e-08,0.651755,0.00114951,-2.11462e-06,5.62134e-08,0.652902,0.00114545,-1.94598e-06,-4.53417e-08,0.654046,0.00114142,-2.082e-06,6.55489e-08,0.655185,0.00113745,-1.88536e-06,-3.80396e-08,0.656321,0.00113357,-1.99948e-06,2.70049e-08,0.657452,0.00112965,-1.91846e-06,-1.03755e-08,0.65858,0.00112578,-1.94959e-06,1.44973e-08,0.659704,0.00112192,-1.9061e-06,1.1991e-08,0.660824,0.00111815,-1.87012e-06,-2.85634e-09,0.66194,0.0011144,-1.87869e-06,-5.65782e-10,0.663053,0.00111064,-1.88039e-06,5.11947e-09,0.664162,0.0011069,-1.86503e-06,3.96924e-08,0.665267,0.00110328,-1.74595e-06,-4.46795e-08,0.666368,0.00109966,-1.87999e-06,1.98161e-08,0.667466,0.00109596,-1.82054e-06,2.502e-08,0.66856,0.00109239,-1.74548e-06,-6.86593e-10,0.669651,0.0010889,-1.74754e-06,-2.22739e-08,0.670738,0.00108534,-1.81437e-06,3.01776e-08,0.671821,0.0010818,-1.72383e-06,2.07732e-08,0.672902,0.00107841,-1.66151e-06,-5.36658e-08,0.673978,0.00107493,-1.82251e-06,7.46802e-08,0.675051,0.00107151,-1.59847e-06,-6.62411e-08,0.676121,0.00106811,-1.79719e-06,7.10748e-08,0.677188,0.00106473,-1.58397e-06,-3.92441e-08,0.678251,0.00106145,-1.7017e-06,2.62973e-08,0.679311,0.00105812,-1.62281e-06,-6.34035e-09,0.680367,0.00105486,-1.64183e-06,-9.36249e-10,0.68142,0.00105157,-1.64464e-06,1.00854e-08,0.68247,0.00104831,-1.61438e-06,2.01995e-08,0.683517,0.00104514,-1.55378e-06,-3.1279e-08,0.68456,0.00104194,-1.64762e-06,4.53114e-08,0.685601,0.00103878,-1.51169e-06,-3.07573e-08,0.686638,0.00103567,-1.60396e-06,1.81133e-08,0.687672,0.00103251,-1.54962e-06,1.79085e-08,0.688703,0.00102947,-1.49589e-06,-3.01428e-08,0.689731,0.00102639,-1.58632e-06,4.30583e-08,0.690756,0.00102334,-1.45715e-06,-2.28814e-08,0.691778,0.00102036,-1.52579e-06,-1.11373e-08,0.692797,0.00101727,-1.5592e-06,6.74305e-08,0.693812,0.00101436,-1.35691e-06,-7.97709e-08,0.694825,0.0010114,-1.59622e-06,7.28391e-08,0.695835,0.00100843,-1.37771e-06,-3.27715e-08,0.696842,0.00100558,-1.47602e-06,-1.35807e-09,0.697846,0.00100262,-1.48009e-06,3.82037e-08,0.698847,0.000999775,-1.36548e-06,-3.22474e-08,0.699846,0.000996948,-1.46223e-06,3.11809e-08,0.700841,0.000994117,-1.36868e-06,-3.28714e-08,0.701834,0.000991281,-1.4673e-06,4.07001e-08,0.702824,0.000988468,-1.3452e-06,-1.07197e-08,0.703811,0.000985746,-1.37736e-06,2.17866e-09,0.704795,0.000982998,-1.37082e-06,2.00521e-09,0.705777,0.000980262,-1.3648e-06,-1.01996e-08,0.706756,0.000977502,-1.3954e-06,3.87931e-08,0.707732,0.000974827,-1.27902e-06,-2.57632e-08,0.708706,0.000972192,-1.35631e-06,4.65513e-09,0.709676,0.000969493,-1.34235e-06,7.14257e-09,0.710645,0.00096683,-1.32092e-06,2.63791e-08,0.71161,0.000964267,-1.24178e-06,-5.30543e-08,0.712573,0.000961625,-1.40095e-06,6.66289e-08,0.713533,0.000959023,-1.20106e-06,-3.46474e-08,0.714491,0.000956517,-1.305e-06,1.23559e-08,0.715446,0.000953944,-1.26793e-06,-1.47763e-08,0.716399,0.000951364,-1.31226e-06,4.67494e-08,0.717349,0.000948879,-1.17201e-06,-5.3012e-08,0.718297,0.000946376,-1.33105e-06,4.60894e-08,0.719242,0.000943852,-1.19278e-06,-1.21366e-08,0.720185,0.00094143,-1.22919e-06,2.45673e-09,0.721125,0.000938979,-1.22182e-06,2.30966e-09,0.722063,0.000936543,-1.21489e-06,-1.16954e-08,0.722998,0.000934078,-1.24998e-06,4.44718e-08,0.723931,0.000931711,-1.11656e-06,-4.69823e-08,0.724861,0.000929337,-1.25751e-06,2.4248e-08,0.725789,0.000926895,-1.18477e-06,9.5949e-09,0.726715,0.000924554,-1.15598e-06,-3.02286e-09,0.727638,0.000922233,-1.16505e-06,2.49649e-09,0.72856,0.00091991,-1.15756e-06,-6.96321e-09,0.729478,0.000917575,-1.17845e-06,2.53564e-08,0.730395,0.000915294,-1.10238e-06,-3.48578e-08,0.731309,0.000912984,-1.20695e-06,5.44704e-08,0.732221,0.000910734,-1.04354e-06,-6.38144e-08,0.73313,0.000908455,-1.23499e-06,8.15781e-08,0.734038,0.00090623,-9.90253e-07,-8.3684e-08,0.734943,0.000903999,-1.2413e-06,7.43441e-08,0.735846,0.000901739,-1.01827e-06,-3.48787e-08,0.736746,0.000899598,-1.12291e-06,5.56596e-09,0.737645,0.000897369,-1.10621e-06,1.26148e-08,0.738541,0.000895194,-1.06837e-06,3.57935e-09,0.739435,0.000893068,-1.05763e-06,-2.69322e-08,0.740327,0.000890872,-1.13842e-06,4.45448e-08,0.741217,0.000888729,-1.00479e-06,-3.20376e-08,0.742105,0.000886623,-1.1009e-06,2.40011e-08,0.74299,0.000884493,-1.0289e-06,-4.36209e-09,0.743874,0.000882422,-1.04199e-06,-6.55268e-09,0.744755,0.000880319,-1.06164e-06,3.05728e-08,0.745634,0.000878287,-9.69926e-07,-5.61338e-08,0.746512,0.000876179,-1.13833e-06,7.4753e-08,0.747387,0.000874127,-9.14068e-07,-6.40644e-08,0.74826,0.000872106,-1.10626e-06,6.22955e-08,0.749131,0.000870081,-9.19375e-07,-6.59083e-08,0.75,0.000868044,-1.1171e-06,8.21284e-08,0.750867,0.000866056,-8.70714e-07,-8.37915e-08,0.751732,0.000864064,-1.12209e-06,7.42237e-08,0.752595,0.000862042,-8.99418e-07,-3.42894e-08,0.753456,0.00086014,-1.00229e-06,3.32955e-09,0.754315,0.000858146,-9.92297e-07,2.09712e-08,0.755173,0.000856224,-9.29384e-07,-2.76096e-08,0.756028,0.000854282,-1.01221e-06,2.98627e-08,0.756881,0.000852348,-9.22625e-07,-3.22365e-08,0.757733,0.000850406,-1.01933e-06,3.94786e-08,0.758582,0.000848485,-9.00898e-07,-6.46833e-09,0.75943,0.000846664,-9.20303e-07,-1.36052e-08,0.760275,0.000844783,-9.61119e-07,1.28447e-09,0.761119,0.000842864,-9.57266e-07,8.4674e-09,0.761961,0.000840975,-9.31864e-07,2.44506e-08,0.762801,0.000839185,-8.58512e-07,-4.6665e-08,0.763639,0.000837328,-9.98507e-07,4.30001e-08,0.764476,0.00083546,-8.69507e-07,-6.12609e-09,0.76531,0.000833703,-8.87885e-07,-1.84959e-08,0.766143,0.000831871,-9.43372e-07,2.05052e-08,0.766974,0.000830046,-8.81857e-07,-3.92026e-09,0.767803,0.000828271,-8.93618e-07,-4.82426e-09,0.768631,0.000826469,-9.0809e-07,2.32172e-08,0.769456,0.000824722,-8.38439e-07,-2.84401e-08,0.77028,0.00082296,-9.23759e-07,3.09386e-08,0.771102,0.000821205,-8.30943e-07,-3.57099e-08,0.771922,0.000819436,-9.38073e-07,5.22963e-08,0.772741,0.000817717,-7.81184e-07,-5.42658e-08,0.773558,0.000815992,-9.43981e-07,4.55579e-08,0.774373,0.000814241,-8.07308e-07,-8.75656e-09,0.775186,0.0008126,-8.33578e-07,-1.05315e-08,0.775998,0.000810901,-8.65172e-07,-8.72188e-09,0.776808,0.000809145,-8.91338e-07,4.54191e-08,0.777616,0.000807498,-7.5508e-07,-5.37454e-08,0.778423,0.000805827,-9.16317e-07,5.03532e-08,0.779228,0.000804145,-7.65257e-07,-2.84584e-08,0.780031,0.000802529,-8.50632e-07,3.87579e-09,0.780833,0.00080084,-8.39005e-07,1.29552e-08,0.781633,0.0007992,-8.00139e-07,3.90804e-09,0.782432,0.000797612,-7.88415e-07,-2.85874e-08,0.783228,0.000795949,-8.74177e-07,5.0837e-08,0.784023,0.000794353,-7.21666e-07,-5.55513e-08,0.784817,0.000792743,-8.8832e-07,5.21587e-08,0.785609,0.000791123,-7.31844e-07,-3.38744e-08,0.786399,0.000789558,-8.33467e-07,2.37342e-08,0.787188,0.000787962,-7.62264e-07,-1.45775e-09,0.787975,0.000786433,-7.66638e-07,-1.79034e-08,0.788761,0.000784846,-8.20348e-07,1.34665e-08,0.789545,0.000783246,-7.79948e-07,2.3642e-08,0.790327,0.000781757,-7.09022e-07,-4.84297e-08,0.791108,0.000780194,-8.54311e-07,5.08674e-08,0.791888,0.000778638,-7.01709e-07,-3.58303e-08,0.792666,0.000777127,-8.092e-07,3.28493e-08,0.793442,0.000775607,-7.10652e-07,-3.59624e-08,0.794217,0.000774078,-8.1854e-07,5.13959e-08,0.79499,0.000772595,-6.64352e-07,-5.04121e-08,0.795762,0.000771115,-8.15588e-07,3.10431e-08,0.796532,0.000769577,-7.22459e-07,-1.41557e-08,0.797301,0.00076809,-7.64926e-07,2.55795e-08,0.798069,0.000766636,-6.88187e-07,-2.85578e-08,0.798835,0.000765174,-7.73861e-07,2.90472e-08,0.799599,0.000763714,-6.86719e-07,-2.80262e-08,0.800362,0.000762256,-7.70798e-07,2.34531e-08,0.801123,0.000760785,-7.00438e-07,-6.18144e-09,0.801884,0.000759366,-7.18983e-07,1.27263e-09,0.802642,0.000757931,-7.15165e-07,1.09101e-09,0.803399,0.000756504,-7.11892e-07,-5.63675e-09,0.804155,0.000755064,-7.28802e-07,2.14559e-08,0.80491,0.00075367,-6.64434e-07,-2.05821e-08,0.805663,0.00075228,-7.26181e-07,1.26812e-09,0.806414,0.000750831,-7.22377e-07,1.55097e-08,0.807164,0.000749433,-6.75848e-07,-3.70216e-09,0.807913,0.00074807,-6.86954e-07,-7.0105e-10,0.80866,0.000746694,-6.89057e-07,6.5063e-09,0.809406,0.000745336,-6.69538e-07,-2.53242e-08,0.810151,0.000743921,-7.45511e-07,3.51858e-08,0.810894,0.000742535,-6.39953e-07,3.79034e-09,0.811636,0.000741267,-6.28582e-07,-5.03471e-08,0.812377,0.000739858,-7.79624e-07,7.83886e-08,0.813116,0.000738534,-5.44458e-07,-8.43935e-08,0.813854,0.000737192,-7.97638e-07,8.03714e-08,0.81459,0.000735838,-5.56524e-07,-5.82784e-08,0.815325,0.00073455,-7.31359e-07,3.35329e-08,0.816059,0.000733188,-6.3076e-07,-1.62486e-08,0.816792,0.000731878,-6.79506e-07,3.14614e-08,0.817523,0.000730613,-5.85122e-07,-4.99925e-08,0.818253,0.000729293,-7.35099e-07,4.92994e-08,0.818982,0.000727971,-5.87201e-07,-2.79959e-08,0.819709,0.000726712,-6.71189e-07,3.07959e-09,0.820435,0.000725379,-6.6195e-07,1.56777e-08,0.82116,0.000724102,-6.14917e-07,-6.18564e-09,0.821883,0.000722854,-6.33474e-07,9.06488e-09,0.822606,0.000721614,-6.06279e-07,-3.00739e-08,0.823327,0.000720311,-6.96501e-07,5.16262e-08,0.824046,0.000719073,-5.41623e-07,-5.72214e-08,0.824765,0.000717818,-7.13287e-07,5.80503e-08,0.825482,0.000716566,-5.39136e-07,-5.57703e-08,0.826198,0.00071532,-7.06447e-07,4.58215e-08,0.826912,0.000714045,-5.68983e-07,-8.30636e-09,0.827626,0.000712882,-5.93902e-07,-1.25961e-08,0.828338,0.000711656,-6.3169e-07,-9.13985e-10,0.829049,0.00071039,-6.34432e-07,1.62519e-08,0.829759,0.00070917,-5.85676e-07,-4.48904e-09,0.830468,0.000707985,-5.99143e-07,1.70418e-09,0.831175,0.000706792,-5.9403e-07,-2.32768e-09,0.831881,0.000705597,-6.01014e-07,7.60648e-09,0.832586,0.000704418,-5.78194e-07,-2.80982e-08,0.83329,0.000703177,-6.62489e-07,4.51817e-08,0.833993,0.000701988,-5.26944e-07,-3.34192e-08,0.834694,0.000700834,-6.27201e-07,2.88904e-08,0.835394,0.000699666,-5.4053e-07,-2.25378e-08,0.836093,0.000698517,-6.08143e-07,1.65589e-09,0.836791,0.000697306,-6.03176e-07,1.59142e-08,0.837488,0.000696147,-5.55433e-07,-5.70801e-09,0.838184,0.000695019,-5.72557e-07,6.91792e-09,0.838878,0.000693895,-5.51803e-07,-2.19637e-08,0.839571,0.000692725,-6.17694e-07,2.13321e-08,0.840263,0.000691554,-5.53698e-07,-3.75996e-09,0.840954,0.000690435,-5.64978e-07,-6.29219e-09,0.841644,0.000689287,-5.83855e-07,2.89287e-08,0.842333,0.000688206,-4.97068e-07,-4.98181e-08,0.843021,0.000687062,-6.46523e-07,5.11344e-08,0.843707,0.000685922,-4.9312e-07,-3.55102e-08,0.844393,0.00068483,-5.9965e-07,3.13019e-08,0.845077,0.000683724,-5.05745e-07,-3.00925e-08,0.84576,0.000682622,-5.96022e-07,2.94636e-08,0.846442,0.000681519,-5.07631e-07,-2.81572e-08,0.847123,0.000680419,-5.92103e-07,2.35606e-08,0.847803,0.000679306,-5.21421e-07,-6.48045e-09,0.848482,0.000678243,-5.40863e-07,2.36124e-09,0.849159,0.000677169,-5.33779e-07,-2.96461e-09,0.849836,0.000676092,-5.42673e-07,9.49728e-09,0.850512,0.000675035,-5.14181e-07,-3.50245e-08,0.851186,0.000673902,-6.19254e-07,7.09959e-08,0.851859,0.000672876,-4.06267e-07,-7.01453e-08,0.852532,0.000671853,-6.16703e-07,3.07714e-08,0.853203,0.000670712,-5.24388e-07,6.66423e-09,0.853873,0.000669684,-5.04396e-07,2.17629e-09,0.854542,0.000668681,-4.97867e-07,-1.53693e-08,0.855211,0.000667639,-5.43975e-07,-3.03752e-10,0.855878,0.000666551,-5.44886e-07,1.65844e-08,0.856544,0.000665511,-4.95133e-07,-6.42907e-09,0.857209,0.000664501,-5.1442e-07,9.13195e-09,0.857873,0.0006635,-4.87024e-07,-3.00987e-08,0.858536,0.000662435,-5.7732e-07,5.16584e-08,0.859198,0.000661436,-4.22345e-07,-5.73255e-08,0.859859,0.000660419,-5.94322e-07,5.84343e-08,0.860518,0.000659406,-4.19019e-07,-5.72022e-08,0.861177,0.000658396,-5.90626e-07,5.11653e-08,0.861835,0.000657368,-4.3713e-07,-2.82495e-08,0.862492,0.000656409,-5.21878e-07,2.22788e-09,0.863148,0.000655372,-5.15195e-07,1.9338e-08,0.863803,0.0006544,-4.5718e-07,-1.99754e-08,0.864457,0.000653425,-5.17107e-07,9.59024e-10,0.86511,0.000652394,-5.1423e-07,1.61393e-08,0.865762,0.000651414,-4.65812e-07,-5.91149e-09,0.866413,0.000650465,-4.83546e-07,7.50665e-09,0.867063,0.00064952,-4.61026e-07,-2.4115e-08,0.867712,0.000648526,-5.33371e-07,2.93486e-08,0.86836,0.000647547,-4.45325e-07,-3.36748e-08,0.869007,0.000646555,-5.4635e-07,4.57461e-08,0.869653,0.0006456,-4.09112e-07,-3.01002e-08,0.870298,0.000644691,-4.99412e-07,1.50501e-08,0.870942,0.000643738,-4.54262e-07,-3.01002e-08,0.871585,0.000642739,-5.44563e-07,4.57461e-08,0.872228,0.000641787,-4.07324e-07,-3.36748e-08,0.872869,0.000640871,-5.08349e-07,2.93486e-08,0.873509,0.000639943,-4.20303e-07,-2.4115e-08,0.874149,0.00063903,-4.92648e-07,7.50655e-09,0.874787,0.000638067,-4.70128e-07,-5.91126e-09,0.875425,0.000637109,-4.87862e-07,1.61385e-08,0.876062,0.000636182,-4.39447e-07,9.61961e-10,0.876697,0.000635306,-4.36561e-07,-1.99863e-08,0.877332,0.000634373,-4.9652e-07,1.93785e-08,0.877966,0.000633438,-4.38384e-07,2.07697e-09,0.878599,0.000632567,-4.32153e-07,-2.76864e-08,0.879231,0.00063162,-5.15212e-07,4.90641e-08,0.879862,0.000630737,-3.6802e-07,-4.93606e-08,0.880493,0.000629852,-5.16102e-07,2.9169e-08,0.881122,0.000628908,-4.28595e-07,-7.71083e-09,0.881751,0.000628027,-4.51727e-07,1.6744e-09,0.882378,0.000627129,-4.46704e-07,1.01317e-09,0.883005,0.000626239,-4.43665e-07,-5.72703e-09,0.883631,0.000625334,-4.60846e-07,2.1895e-08,0.884255,0.000624478,-3.95161e-07,-2.22481e-08,0.88488,0.000623621,-4.61905e-07,7.4928e-09,0.885503,0.00062272,-4.39427e-07,-7.72306e-09,0.886125,0.000621818,-4.62596e-07,2.33995e-08,0.886746,0.000620963,-3.92398e-07,-2.62704e-08,0.887367,0.000620099,-4.71209e-07,2.20775e-08,0.887987,0.000619223,-4.04976e-07,-2.43496e-09,0.888605,0.000618406,-4.12281e-07,-1.23377e-08,0.889223,0.000617544,-4.49294e-07,-7.81876e-09,0.88984,0.000616622,-4.72751e-07,4.36128e-08,0.890457,0.000615807,-3.41912e-07,-4.7423e-08,0.891072,0.000614981,-4.84181e-07,2.68698e-08,0.891687,0.000614093,-4.03572e-07,-4.51384e-10,0.8923,0.000613285,-4.04926e-07,-2.50643e-08,0.892913,0.0006124,-4.80119e-07,4.11038e-08,0.893525,0.000611563,-3.56808e-07,-2.01414e-08,0.894136,0.000610789,-4.17232e-07,-2.01426e-08,0.894747,0.000609894,-4.7766e-07,4.11073e-08,0.895356,0.000609062,-3.54338e-07,-2.50773e-08,0.895965,0.000608278,-4.2957e-07,-4.02954e-10,0.896573,0.000607418,-4.30779e-07,2.66891e-08,0.89718,0.000606636,-3.50711e-07,-4.67489e-08,0.897786,0.000605795,-4.90958e-07,4.10972e-08,0.898391,0.000604936,-3.67666e-07,1.56948e-09,0.898996,0.000604205,-3.62958e-07,-4.73751e-08,0.8996,0.000603337,-5.05083e-07,6.87214e-08,0.900202,0.000602533,-2.98919e-07,-4.86966e-08,0.900805,0.000601789,-4.45009e-07,6.85589e-09,0.901406,0.00060092,-4.24441e-07,2.1273e-08,0.902007,0.000600135,-3.60622e-07,-3.23434e-08,0.902606,0.000599317,-4.57652e-07,4.84959e-08,0.903205,0.000598547,-3.12164e-07,-4.24309e-08,0.903803,0.000597795,-4.39457e-07,2.01844e-09,0.904401,0.000596922,-4.33402e-07,3.43571e-08,0.904997,0.000596159,-3.30331e-07,-2.02374e-08,0.905593,0.000595437,-3.91043e-07,-1.30123e-08,0.906188,0.000594616,-4.3008e-07,1.26819e-08,0.906782,0.000593794,-3.92034e-07,2.18894e-08,0.907376,0.000593076,-3.26366e-07,-4.06349e-08,0.907968,0.000592301,-4.4827e-07,2.1441e-08,0.90856,0.000591469,-3.83947e-07,1.44754e-08,0.909151,0.000590744,-3.40521e-07,-1.97379e-08,0.909742,0.000590004,-3.99735e-07,4.87161e-09,0.910331,0.000589219,-3.8512e-07,2.51532e-10,0.91092,0.00058845,-3.84366e-07,-5.87776e-09,0.911508,0.000587663,-4.01999e-07,2.32595e-08,0.912096,0.000586929,-3.3222e-07,-2.75554e-08,0.912682,0.000586182,-4.14887e-07,2.73573e-08,0.913268,0.000585434,-3.32815e-07,-2.22692e-08,0.913853,0.000584702,-3.99622e-07,2.11486e-09,0.914437,0.000583909,-3.93278e-07,1.38098e-08,0.915021,0.000583164,-3.51848e-07,2.25042e-09,0.915604,0.000582467,-3.45097e-07,-2.28115e-08,0.916186,0.000581708,-4.13531e-07,2.93911e-08,0.916767,0.000580969,-3.25358e-07,-3.51481e-08,0.917348,0.000580213,-4.30803e-07,5.15967e-08,0.917928,0.000579506,-2.76012e-07,-5.20296e-08,0.918507,0.000578798,-4.32101e-07,3.73124e-08,0.919085,0.000578046,-3.20164e-07,-3.76154e-08,0.919663,0.000577293,-4.3301e-07,5.35447e-08,0.92024,0.000576587,-2.72376e-07,-5.7354e-08,0.920816,0.000575871,-4.44438e-07,5.66621e-08,0.921391,0.000575152,-2.74452e-07,-5.00851e-08,0.921966,0.000574453,-4.24707e-07,2.4469e-08,0.92254,0.000573677,-3.513e-07,1.18138e-08,0.923114,0.000573009,-3.15859e-07,-1.21195e-08,0.923686,0.000572341,-3.52217e-07,-2.29403e-08,0.924258,0.000571568,-4.21038e-07,4.4276e-08,0.924829,0.000570859,-2.8821e-07,-3.49546e-08,0.9254,0.000570178,-3.93074e-07,3.59377e-08,0.92597,0.000569499,-2.85261e-07,-4.91915e-08,0.926539,0.000568781,-4.32835e-07,4.16189e-08,0.927107,0.00056804,-3.07979e-07,1.92523e-09,0.927675,0.00056743,-3.02203e-07,-4.93198e-08,0.928242,0.000566678,-4.50162e-07,7.61447e-08,0.928809,0.000566006,-2.21728e-07,-7.6445e-08,0.929374,0.000565333,-4.51063e-07,5.08216e-08,0.929939,0.000564583,-2.98599e-07,-7.63212e-09,0.930503,0.000563963,-3.21495e-07,-2.02931e-08,0.931067,0.000563259,-3.82374e-07,2.92001e-08,0.93163,0.000562582,-2.94774e-07,-3.69025e-08,0.932192,0.000561882,-4.05482e-07,5.88053e-08,0.932754,0.000561247,-2.29066e-07,-7.91094e-08,0.933315,0.000560552,-4.66394e-07,7.88184e-08,0.933875,0.000559856,-2.29939e-07,-5.73501e-08,0.934434,0.000559224,-4.01989e-07,3.13727e-08,0.934993,0.000558514,-3.07871e-07,-8.53611e-09,0.935551,0.000557873,-3.33479e-07,2.77175e-09,0.936109,0.000557214,-3.25164e-07,-2.55091e-09,0.936666,0.000556556,-3.32817e-07,7.43188e-09,0.937222,0.000555913,-3.10521e-07,-2.71766e-08,0.937778,0.00055521,-3.92051e-07,4.167e-08,0.938333,0.000554551,-2.67041e-07,-2.02941e-08,0.938887,0.000553956,-3.27923e-07,-2.00984e-08,0.93944,0.00055324,-3.88218e-07,4.10828e-08,0.939993,0.000552587,-2.6497e-07,-2.50237e-08,0.940546,0.000551982,-3.40041e-07,-5.92583e-10,0.941097,0.0005513,-3.41819e-07,2.7394e-08,0.941648,0.000550698,-2.59637e-07,-4.93788e-08,0.942199,0.000550031,-4.07773e-07,5.09119e-08,0.942748,0.000549368,-2.55038e-07,-3.50595e-08,0.943297,0.000548753,-3.60216e-07,2.97214e-08,0.943846,0.000548122,-2.71052e-07,-2.42215e-08,0.944394,0.000547507,-3.43716e-07,7.55985e-09,0.944941,0.000546842,-3.21037e-07,-6.01796e-09,0.945487,0.000546182,-3.3909e-07,1.65119e-08,0.946033,0.000545553,-2.89555e-07,-4.2498e-10,0.946578,0.000544973,-2.9083e-07,-1.4812e-08,0.947123,0.000544347,-3.35266e-07,6.83068e-11,0.947667,0.000543676,-3.35061e-07,1.45388e-08,0.94821,0.00054305,-2.91444e-07,1.38123e-09,0.948753,0.000542471,-2.87301e-07,-2.00637e-08,0.949295,0.000541836,-3.47492e-07,1.92688e-08,0.949837,0.000541199,-2.89685e-07,2.59298e-09,0.950378,0.000540628,-2.81906e-07,-2.96407e-08,0.950918,0.000539975,-3.70829e-07,5.63652e-08,0.951458,0.000539402,-2.01733e-07,-7.66107e-08,0.951997,0.000538769,-4.31565e-07,7.12638e-08,0.952535,0.00053812,-2.17774e-07,-2.96305e-08,0.953073,0.000537595,-3.06665e-07,-1.23464e-08,0.95361,0.000536945,-3.43704e-07,1.94114e-08,0.954147,0.000536316,-2.8547e-07,-5.69451e-09,0.954683,0.000535728,-3.02554e-07,3.36666e-09,0.955219,0.000535133,-2.92454e-07,-7.77208e-09,0.955753,0.000534525,-3.1577e-07,2.77216e-08,0.956288,0.000533976,-2.32605e-07,-4.35097e-08,0.956821,0.00053338,-3.63134e-07,2.7108e-08,0.957354,0.000532735,-2.8181e-07,-5.31772e-09,0.957887,0.000532156,-2.97764e-07,-5.83718e-09,0.958419,0.000531543,-3.15275e-07,2.86664e-08,0.95895,0.000530998,-2.29276e-07,-4.9224e-08,0.959481,0.000530392,-3.76948e-07,4.90201e-08,0.960011,0.000529785,-2.29887e-07,-2.76471e-08,0.96054,0.000529243,-3.12829e-07,1.96385e-09,0.961069,0.000528623,-3.06937e-07,1.97917e-08,0.961598,0.000528068,-2.47562e-07,-2.15261e-08,0.962125,0.000527508,-3.1214e-07,6.70795e-09,0.962653,0.000526904,-2.92016e-07,-5.30573e-09,0.963179,0.000526304,-3.07934e-07,1.4515e-08,0.963705,0.000525732,-2.64389e-07,6.85048e-09,0.964231,0.000525224,-2.43837e-07,-4.19169e-08,0.964756,0.00052461,-3.69588e-07,4.1608e-08,0.96528,0.000523996,-2.44764e-07,-5.30598e-09,0.965804,0.000523491,-2.60682e-07,-2.03841e-08,0.966327,0.000522908,-3.21834e-07,2.72378e-08,0.966849,0.000522346,-2.40121e-07,-2.89625e-08,0.967371,0.000521779,-3.27008e-07,2.90075e-08,0.967893,0.000521212,-2.39986e-07,-2.74629e-08,0.968414,0.00052065,-3.22374e-07,2.12396e-08,0.968934,0.000520069,-2.58656e-07,2.10922e-09,0.969454,0.000519558,-2.52328e-07,-2.96765e-08,0.969973,0.000518964,-3.41357e-07,5.6992e-08,0.970492,0.000518452,-1.70382e-07,-7.90821e-08,0.97101,0.000517874,-4.07628e-07,8.05224e-08,0.971528,0.000517301,-1.66061e-07,-6.41937e-08,0.972045,0.000516776,-3.58642e-07,5.70429e-08,0.972561,0.00051623,-1.87513e-07,-4.47686e-08,0.973077,0.00051572,-3.21819e-07,2.82237e-09,0.973593,0.000515085,-3.13352e-07,3.34792e-08,0.974108,0.000514559,-2.12914e-07,-1.75298e-08,0.974622,0.000514081,-2.65503e-07,-2.29648e-08,0.975136,0.000513481,-3.34398e-07,4.97843e-08,0.975649,0.000512961,-1.85045e-07,-5.6963e-08,0.976162,0.00051242,-3.55934e-07,5.88585e-08,0.976674,0.000511885,-1.79359e-07,-5.92616e-08,0.977185,0.000511348,-3.57143e-07,5.89785e-08,0.977696,0.000510811,-1.80208e-07,-5.74433e-08,0.978207,0.000510278,-3.52538e-07,5.15854e-08,0.978717,0.000509728,-1.97781e-07,-2.9689e-08,0.979226,0.000509243,-2.86848e-07,7.56591e-09,0.979735,0.000508692,-2.64151e-07,-5.74649e-10,0.980244,0.000508162,-2.65875e-07,-5.26732e-09,0.980752,0.000507615,-2.81677e-07,2.16439e-08,0.981259,0.000507116,-2.16745e-07,-2.17037e-08,0.981766,0.000506618,-2.81856e-07,5.56636e-09,0.982272,0.000506071,-2.65157e-07,-5.61689e-10,0.982778,0.000505539,-2.66842e-07,-3.31963e-09,0.983283,0.000504995,-2.76801e-07,1.38402e-08,0.983788,0.000504483,-2.3528e-07,7.56339e-09,0.984292,0.000504035,-2.1259e-07,-4.40938e-08,0.984796,0.000503478,-3.44871e-07,4.96026e-08,0.985299,0.000502937,-1.96064e-07,-3.51071e-08,0.985802,0.000502439,-3.01385e-07,3.12212e-08,0.986304,0.00050193,-2.07721e-07,-3.0173e-08,0.986806,0.000501424,-2.9824e-07,2.9866e-08,0.987307,0.000500917,-2.08642e-07,-2.96865e-08,0.987808,0.000500411,-2.97702e-07,2.92753e-08,0.988308,0.000499903,-2.09876e-07,-2.78101e-08,0.988807,0.0004994,-2.93306e-07,2.23604e-08,0.989307,0.000498881,-2.26225e-07,-2.02681e-09,0.989805,0.000498422,-2.32305e-07,-1.42531e-08,0.990303,0.000497915,-2.75065e-07,-5.65232e-10,0.990801,0.000497363,-2.76761e-07,1.65141e-08,0.991298,0.000496859,-2.27218e-07,-5.88639e-09,0.991795,0.000496387,-2.44878e-07,7.0315e-09,0.992291,0.000495918,-2.23783e-07,-2.22396e-08,0.992787,0.000495404,-2.90502e-07,2.23224e-08,0.993282,0.00049489,-2.23535e-07,-7.44543e-09,0.993776,0.000494421,-2.45871e-07,7.45924e-09,0.994271,0.000493951,-2.23493e-07,-2.23915e-08,0.994764,0.000493437,-2.90668e-07,2.25021e-08,0.995257,0.000492923,-2.23161e-07,-8.01218e-09,0.99575,0.000492453,-2.47198e-07,9.54669e-09,0.996242,0.000491987,-2.18558e-07,-3.01746e-08,0.996734,0.000491459,-3.09082e-07,5.1547e-08,0.997225,0.000490996,-1.54441e-07,-5.68039e-08,0.997716,0.000490517,-3.24853e-07,5.64594e-08,0.998206,0.000490036,-1.55474e-07,-4.98245e-08,0.998696,0.000489576,-3.04948e-07,2.36292e-08,0.999186,0.000489037,-2.3406e-07,1.49121e-08,0.999674,0.000488613,-1.89324e-07,-2.3673e-08,1.00016,0.000488164,-2.60343e-07,2.01754e-08,1.00065,0.000487704,-1.99816e-07,-5.70288e-08,1.00114,0.000487133,-3.70903e-07,8.87303e-08,1.00162,0.000486657,-1.04712e-07,-5.94737e-08,1.00211,0.000486269,-2.83133e-07,2.99553e-08,1.0026,0.000485793,-1.93267e-07,-6.03474e-08,1.00308,0.000485225,-3.74309e-07,9.2225e-08,1.00357,0.000484754,-9.76345e-08,-7.0134e-08,1.00405,0.000484348,-3.08036e-07,6.91016e-08,1.00454,0.000483939,-1.00731e-07,-8.70633e-08,1.00502,0.000483476,-3.61921e-07,4.07328e-08,1.0055,0.000482875,-2.39723e-07,4.33413e-08,1.00599,0.000482525,-1.09699e-07,-9.48886e-08,1.00647,0.000482021,-3.94365e-07,9.77947e-08,1.00695,0.000481526,-1.00981e-07,-5.78713e-08,1.00743,0.00048115,-2.74595e-07,1.44814e-08,1.00791,0.000480645,-2.31151e-07,-5.42665e-11,1.00839,0.000480182,-2.31314e-07,-1.42643e-08,1.00887,0.000479677,-2.74106e-07,5.71115e-08,1.00935,0.0004793,-1.02772e-07,-9.49724e-08,1.00983,0.000478809,-3.87689e-07,8.43596e-08,1.01031,0.000478287,-1.3461e-07,-4.04755e-09,1.01079,0.000478006,-1.46753e-07,-6.81694e-08,1.01127,0.000477508,-3.51261e-07,3.83067e-08,1.01174,0.00047692,-2.36341e-07,3.41521e-08,1.01222,0.00047655,-1.33885e-07,-5.57058e-08,1.0127,0.000476115,-3.01002e-07,6.94616e-08,1.01317,0.000475721,-9.26174e-08,-1.02931e-07,1.01365,0.000475227,-4.01412e-07,1.03846e-07,1.01412,0.000474736,-8.98751e-08,-7.40321e-08,1.0146,0.000474334,-3.11971e-07,7.30735e-08,1.01507,0.00047393,-9.27508e-08,-9.90527e-08,1.01554,0.000473447,-3.89909e-07,8.47188e-08,1.01602,0.000472921,-1.35753e-07,-1.40381e-09,1.01649,0.000472645,-1.39964e-07,-7.91035e-08,1.01696,0.000472128,-3.77275e-07,7.93993e-08,1.01744,0.000471612,-1.39077e-07,-7.52607e-11,1.01791,0.000471334,-1.39302e-07,-7.90983e-08,1.01838,0.000470818,-3.76597e-07,7.80499e-08,1.01885,0.000470299,-1.42448e-07,5.31733e-09,1.01932,0.00047003,-1.26496e-07,-9.93193e-08,1.01979,0.000469479,-4.24453e-07,1.53541e-07,1.02026,0.00046909,3.617e-08,-1.57217e-07,1.02073,0.000468691,-4.35482e-07,1.177e-07,1.02119,0.000468173,-8.23808e-08,-7.51659e-08,1.02166,0.000467783,-3.07878e-07,6.37538e-08,1.02213,0.000467358,-1.16617e-07,-6.064e-08,1.0226,0.000466943,-2.98537e-07,5.9597e-08,1.02306,0.000466525,-1.19746e-07,-5.85386e-08,1.02353,0.00046611,-2.95362e-07,5.53482e-08,1.024,0.000465685,-1.29317e-07,-4.36449e-08,1.02446,0.000465296,-2.60252e-07,2.20268e-11,1.02493,0.000464775,-2.60186e-07,4.35568e-08,1.02539,0.000464386,-1.29516e-07,-5.50398e-08,1.02586,0.000463961,-2.94635e-07,5.73932e-08,1.02632,0.000463544,-1.22456e-07,-5.53236e-08,1.02678,0.000463133,-2.88426e-07,4.46921e-08,1.02725,0.000462691,-1.5435e-07,-4.23534e-09,1.02771,0.000462369,-1.67056e-07,-2.77507e-08,1.02817,0.000461952,-2.50308e-07,-3.97101e-09,1.02863,0.000461439,-2.62221e-07,4.36348e-08,1.02909,0.000461046,-1.31317e-07,-5.13589e-08,1.02955,0.000460629,-2.85394e-07,4.25913e-08,1.03001,0.000460186,-1.5762e-07,2.0285e-10,1.03047,0.000459871,-1.57011e-07,-4.34027e-08,1.03093,0.000459427,-2.87219e-07,5.41987e-08,1.03139,0.000459015,-1.24623e-07,-5.4183e-08,1.03185,0.000458604,-2.87172e-07,4.33239e-08,1.03231,0.000458159,-1.572e-07,9.65817e-11,1.03277,0.000457845,-1.56911e-07,-4.37103e-08,1.03323,0.0004574,-2.88041e-07,5.55351e-08,1.03368,0.000456991,-1.21436e-07,-5.9221e-08,1.03414,0.00045657,-2.99099e-07,6.21394e-08,1.0346,0.000456158,-1.1268e-07,-7.01275e-08,1.03505,0.000455723,-3.23063e-07,9.91614e-08,1.03551,0.000455374,-2.55788e-08,-8.80996e-08,1.03596,0.000455058,-2.89878e-07,1.48184e-08,1.03642,0.000454523,-2.45422e-07,2.88258e-08,1.03687,0.000454119,-1.58945e-07,-1.09125e-08,1.03733,0.000453768,-1.91682e-07,1.48241e-08,1.03778,0.000453429,-1.4721e-07,-4.83838e-08,1.03823,0.00045299,-2.92361e-07,5.95019e-08,1.03869,0.000452584,-1.13856e-07,-7.04146e-08,1.03914,0.000452145,-3.25099e-07,1.02947e-07,1.03959,0.000451803,-1.62583e-08,-1.02955e-07,1.04004,0.000451462,-3.25123e-07,7.04544e-08,1.04049,0.000451023,-1.1376e-07,-5.96534e-08,1.04094,0.000450616,-2.9272e-07,4.89499e-08,1.04139,0.000450178,-1.45871e-07,-1.69369e-08,1.04184,0.000449835,-1.96681e-07,1.87977e-08,1.04229,0.000449498,-1.40288e-07,-5.82539e-08,1.04274,0.000449043,-3.1505e-07,9.50087e-08,1.04319,0.000448698,-3.00238e-08,-8.33623e-08,1.04364,0.000448388,-2.80111e-07,2.20363e-11,1.04409,0.000447828,-2.80045e-07,8.32742e-08,1.04454,0.000447517,-3.02221e-08,-9.47002e-08,1.04498,0.000447173,-3.14323e-07,5.7108e-08,1.04543,0.000446716,-1.42999e-07,-1.45225e-08,1.04588,0.000446386,-1.86566e-07,9.82022e-10,1.04632,0.000446016,-1.8362e-07,1.05944e-08,1.04677,0.00044568,-1.51837e-07,-4.33597e-08,1.04721,0.000445247,-2.81916e-07,4.36352e-08,1.04766,0.000444814,-1.51011e-07,-1.19717e-08,1.0481,0.000444476,-1.86926e-07,4.25158e-09,1.04855,0.000444115,-1.74171e-07,-5.03461e-09,1.04899,0.000443751,-1.89275e-07,1.58868e-08,1.04944,0.00044342,-1.41614e-07,-5.85127e-08,1.04988,0.000442961,-3.17152e-07,9.89548e-08,1.05032,0.000442624,-2.0288e-08,-9.88878e-08,1.05076,0.000442287,-3.16951e-07,5.81779e-08,1.05121,0.000441827,-1.42418e-07,-1.46144e-08,1.05165,0.000441499,-1.86261e-07,2.79892e-10,1.05209,0.000441127,-1.85421e-07,1.34949e-08,1.05253,0.000440797,-1.44937e-07,-5.42594e-08,1.05297,0.000440344,-3.07715e-07,8.43335e-08,1.05341,0.000439982,-5.47146e-08,-4.46558e-08,1.05385,0.000439738,-1.88682e-07,-2.49193e-08,1.05429,0.000439286,-2.6344e-07,2.5124e-08,1.05473,0.000438835,-1.88068e-07,4.36328e-08,1.05517,0.000438589,-5.71699e-08,-8.04459e-08,1.05561,0.000438234,-2.98508e-07,3.97324e-08,1.05605,0.000437756,-1.79311e-07,4.07258e-08,1.05648,0.000437519,-5.71332e-08,-8.34263e-08,1.05692,0.000437155,-3.07412e-07,5.45608e-08,1.05736,0.000436704,-1.4373e-07,-1.56078e-08,1.05779,0.000436369,-1.90553e-07,7.87043e-09,1.05823,0.000436012,-1.66942e-07,-1.58739e-08,1.05867,0.00043563,-2.14563e-07,5.56251e-08,1.0591,0.000435368,-4.76881e-08,-8.74172e-08,1.05954,0.000435011,-3.0994e-07,5.56251e-08,1.05997,0.000434558,-1.43064e-07,-1.58739e-08,1.06041,0.000434224,-1.90686e-07,7.87042e-09,1.06084,0.000433866,-1.67075e-07,-1.56078e-08,1.06127,0.000433485,-2.13898e-07,5.45609e-08,1.06171,0.000433221,-5.02157e-08,-8.34263e-08,1.06214,0.00043287,-3.00495e-07,4.07258e-08,1.06257,0.000432391,-1.78317e-07,3.97325e-08,1.063,0.000432154,-5.91198e-08,-8.04464e-08,1.06344,0.000431794,-3.00459e-07,4.36347e-08,1.06387,0.000431324,-1.69555e-07,2.5117e-08,1.0643,0.000431061,-9.42041e-08,-2.48934e-08,1.06473,0.000430798,-1.68884e-07,-4.47527e-08,1.06516,0.000430326,-3.03142e-07,8.46951e-08,1.06559,0.000429973,-4.90573e-08,-5.56089e-08,1.06602,0.000429708,-2.15884e-07,1.85314e-08,1.06645,0.000429332,-1.6029e-07,-1.85166e-08,1.06688,0.000428956,-2.1584e-07,5.5535e-08,1.06731,0.000428691,-4.92347e-08,-8.44142e-08,1.06774,0.000428339,-3.02477e-07,4.37032e-08,1.06816,0.000427865,-1.71368e-07,2.88107e-08,1.06859,0.000427609,-8.49356e-08,-3.97367e-08,1.06902,0.00042732,-2.04146e-07,1.09267e-08,1.06945,0.000426945,-1.71365e-07,-3.97023e-09,1.06987,0.00042659,-1.83276e-07,4.9542e-09,1.0703,0.000426238,-1.68414e-07,-1.58466e-08,1.07073,0.000425854,-2.15953e-07,5.84321e-08,1.07115,0.000425597,-4.0657e-08,-9.86725e-08,1.07158,0.00042522,-3.36674e-07,9.78392e-08,1.072,0.00042484,-4.31568e-08,-5.42658e-08,1.07243,0.000424591,-2.05954e-07,1.45377e-11,1.07285,0.000424179,-2.0591e-07,5.42076e-08,1.07328,0.00042393,-4.32877e-08,-9.76357e-08,1.0737,0.00042355,-3.36195e-07,9.79165e-08,1.07412,0.000423172,-4.24451e-08,-5.56118e-08,1.07455,0.00042292,-2.09281e-07,5.32143e-09,1.07497,0.000422518,-1.93316e-07,3.43261e-08,1.07539,0.000422234,-9.0338e-08,-2.34165e-08,1.07581,0.000421983,-1.60588e-07,-5.98692e-08,1.07623,0.000421482,-3.40195e-07,1.43684e-07,1.07666,0.000421233,9.08574e-08,-1.5724e-07,1.07708,0.000420943,-3.80862e-07,1.27647e-07,1.0775,0.000420564,2.0791e-09,-1.1493e-07,1.07792,0.000420223,-3.4271e-07,9.36534e-08,1.07834,0.000419819,-6.17499e-08,-2.12653e-08,1.07876,0.000419632,-1.25546e-07,-8.59219e-09,1.07918,0.000419355,-1.51322e-07,-6.35752e-08,1.0796,0.000418861,-3.42048e-07,1.43684e-07,1.08002,0.000418608,8.90034e-08,-1.53532e-07,1.08043,0.000418326,-3.71593e-07,1.12817e-07,1.08085,0.000417921,-3.31414e-08,-5.93184e-08,1.08127,0.000417677,-2.11097e-07,5.24697e-09,1.08169,0.00041727,-1.95356e-07,3.83305e-08,1.0821,0.000416995,-8.03642e-08,-3.93597e-08,1.08252,0.000416716,-1.98443e-07,-1.0094e-10,1.08294,0.000416319,-1.98746e-07,3.97635e-08,1.08335,0.00041604,-7.94557e-08,-3.97437e-08,1.08377,0.000415762,-1.98687e-07,1.94215e-12,1.08419,0.000415365,-1.98681e-07,3.97359e-08,1.0846,0.000415087,-7.94732e-08,-3.97362e-08,1.08502,0.000414809,-1.98682e-07,-4.31063e-13,1.08543,0.000414411,-1.98683e-07,3.97379e-08,1.08584,0.000414133,-7.94694e-08,-3.97418e-08,1.08626,0.000413855,-1.98695e-07,2.00563e-11,1.08667,0.000413458,-1.98635e-07,3.96616e-08,1.08709,0.000413179,-7.965e-08,-3.9457e-08,1.0875,0.000412902,-1.98021e-07,-1.04281e-09,1.08791,0.000412502,-2.01149e-07,4.36282e-08,1.08832,0.000412231,-7.02648e-08,-5.42608e-08,1.08874,0.000411928,-2.33047e-07,5.42057e-08,1.08915,0.000411624,-7.04301e-08,-4.33527e-08,1.08956,0.000411353,-2.00488e-07,-4.07378e-12,1.08997,0.000410952,-2.005e-07,4.3369e-08,1.09038,0.000410681,-7.03934e-08,-5.42627e-08,1.09079,0.000410378,-2.33182e-07,5.44726e-08,1.0912,0.000410075,-6.97637e-08,-4.44186e-08,1.09161,0.000409802,-2.03019e-07,3.99235e-09,1.09202,0.000409408,-1.91042e-07,2.84491e-08,1.09243,0.000409111,-1.05695e-07,1.42043e-09,1.09284,0.000408904,-1.01434e-07,-3.41308e-08,1.09325,0.000408599,-2.03826e-07,1.58937e-08,1.09366,0.000408239,-1.56145e-07,-2.94438e-08,1.09406,0.000407838,-2.44476e-07,1.01881e-07,1.09447,0.000407655,6.11676e-08,-1.39663e-07,1.09488,0.000407358,-3.57822e-07,9.91432e-08,1.09529,0.00040694,-6.03921e-08,-1.84912e-08,1.09569,0.000406764,-1.15866e-07,-2.51785e-08,1.0961,0.000406457,-1.91401e-07,-4.03115e-12,1.09651,0.000406074,-1.91413e-07,2.51947e-08,1.09691,0.000405767,-1.15829e-07,1.84346e-08,1.09732,0.00040559,-6.05254e-08,-9.89332e-08,1.09772,0.000405172,-3.57325e-07,1.3888e-07,1.09813,0.000404874,5.93136e-08,-9.8957e-08,1.09853,0.000404696,-2.37557e-07,1.853e-08,1.09894,0.000404277,-1.81968e-07,2.48372e-08,1.09934,0.000403987,-1.07456e-07,1.33047e-09,1.09975,0.000403776,-1.03465e-07,-3.01591e-08,1.10015,0.000403479,-1.93942e-07,9.66054e-11,1.10055,0.000403091,-1.93652e-07,2.97727e-08,1.10096,0.000402793,-1.04334e-07,2.19273e-11,1.10136,0.000402585,-1.04268e-07,-2.98604e-08,1.10176,0.000402287,-1.93849e-07,2.10325e-10,1.10216,0.0004019,-1.93218e-07,2.90191e-08,1.10256,0.0004016,-1.06161e-07,2.92264e-09,1.10297,0.000401397,-9.73931e-08,-4.07096e-08,1.10337,0.00040108,-2.19522e-07,4.07067e-08,1.10377,0.000400763,-9.7402e-08,-2.90783e-09,1.10417,0.000400559,-1.06126e-07,-2.90754e-08,1.10457,0.00040026,-1.93352e-07,9.00021e-14,1.10497,0.000399873,-1.93351e-07,2.9075e-08,1.10537,0.000399574,-1.06126e-07,2.90902e-09,1.10577,0.00039937,-9.73992e-08,-4.07111e-08,1.10617,0.000399053,-2.19533e-07,4.07262e-08,1.10657,0.000398736,-9.73541e-08,-2.98424e-09,1.10697,0.000398533,-1.06307e-07,-2.87892e-08,1.10736,0.000398234,-1.92674e-07,-1.06824e-09,1.10776,0.000397845,-1.95879e-07,3.30622e-08,1.10816,0.000397552,-9.66926e-08,-1.19712e-08,1.10856,0.000397323,-1.32606e-07,1.48225e-08,1.10895,0.000397102,-8.81387e-08,-4.73187e-08,1.10935,0.000396784,-2.30095e-07,5.52429e-08,1.10975,0.00039649,-6.4366e-08,-5.44437e-08,1.11014,0.000396198,-2.27697e-07,4.33226e-08,1.11054,0.000395872,-9.77293e-08,3.62656e-10,1.11094,0.000395678,-9.66414e-08,-4.47732e-08,1.11133,0.00039535,-2.30961e-07,5.95208e-08,1.11173,0.000395067,-5.23985e-08,-7.41008e-08,1.11212,0.00039474,-2.74701e-07,1.17673e-07,1.11252,0.000394543,7.83181e-08,-1.58172e-07,1.11291,0.000394225,-3.96199e-07,1.57389e-07,1.1133,0.000393905,7.59679e-08,-1.13756e-07,1.1137,0.000393716,-2.653e-07,5.92165e-08,1.11409,0.000393363,-8.76507e-08,-3.90074e-09,1.11449,0.000393176,-9.93529e-08,-4.36136e-08,1.11488,0.000392846,-2.30194e-07,5.91457e-08,1.11527,0.000392563,-5.27564e-08,-7.376e-08,1.11566,0.000392237,-2.74037e-07,1.16685e-07,1.11606,0.000392039,7.60189e-08,-1.54562e-07,1.11645,0.000391727,-3.87667e-07,1.43935e-07,1.11684,0.000391384,4.4137e-08,-6.35487e-08,1.11723,0.000391281,-1.46509e-07,-8.94896e-09,1.11762,0.000390961,-1.73356e-07,-1.98647e-08,1.11801,0.000390555,-2.3295e-07,8.8408e-08,1.1184,0.000390354,3.22736e-08,-9.53486e-08,1.11879,0.000390133,-2.53772e-07,5.45677e-08,1.11918,0.000389789,-9.0069e-08,-3.71296e-09,1.11957,0.000389598,-1.01208e-07,-3.97159e-08,1.11996,0.000389276,-2.20355e-07,4.33671e-08,1.12035,0.000388966,-9.02542e-08,-1.45431e-08,1.12074,0.000388741,-1.33883e-07,1.48052e-08,1.12113,0.000388518,-8.94678e-08,-4.46778e-08,1.12152,0.000388205,-2.23501e-07,4.46966e-08,1.12191,0.000387892,-8.94114e-08,-1.48992e-08,1.12229,0.000387669,-1.34109e-07,1.49003e-08,1.12268,0.000387445,-8.94082e-08,-4.47019e-08,1.12307,0.000387132,-2.23514e-07,4.4698e-08,1.12345,0.000386819,-8.942e-08,-1.48806e-08,1.12384,0.000386596,-1.34062e-07,1.48245e-08,1.12423,0.000386372,-8.95885e-08,-4.44172e-08,1.12461,0.00038606,-2.2284e-07,4.36351e-08,1.125,0.000385745,-9.19348e-08,-1.09139e-08,1.12539,0.000385528,-1.24677e-07,2.05584e-11,1.12577,0.000385279,-1.24615e-07,1.08317e-08,1.12616,0.000385062,-9.21198e-08,-4.33473e-08,1.12654,0.000384748,-2.22162e-07,4.33481e-08,1.12693,0.000384434,-9.21174e-08,-1.08356e-08,1.12731,0.000384217,-1.24624e-07,-5.50907e-12,1.12769,0.000383968,-1.24641e-07,1.08577e-08,1.12808,0.000383751,-9.20679e-08,-4.34252e-08,1.12846,0.000383437,-2.22343e-07,4.36337e-08,1.12884,0.000383123,-9.14422e-08,-1.19005e-08,1.12923,0.000382904,-1.27144e-07,3.96813e-09,1.12961,0.000382662,-1.15239e-07,-3.97207e-09,1.12999,0.000382419,-1.27155e-07,1.19201e-08,1.13038,0.000382201,-9.1395e-08,-4.37085e-08,1.13076,0.000381887,-2.2252e-07,4.37046e-08,1.13114,0.000381573,-9.14068e-08,-1.19005e-08,1.13152,0.000381355,-1.27108e-07,3.89734e-09,1.1319,0.000381112,-1.15416e-07,-3.68887e-09,1.13228,0.00038087,-1.26483e-07,1.08582e-08,1.13266,0.00038065,-9.39083e-08,-3.97438e-08,1.13304,0.000380343,-2.1314e-07,2.89076e-08,1.13342,0.000380003,-1.26417e-07,4.33225e-08,1.1338,0.00037988,3.55072e-09,-8.29883e-08,1.13418,0.000379638,-2.45414e-07,5.0212e-08,1.13456,0.000379298,-9.47781e-08,1.34964e-09,1.13494,0.000379113,-9.07292e-08,-5.56105e-08,1.13532,0.000378764,-2.57561e-07,1.01883e-07,1.1357,0.000378555,4.80889e-08,-1.13504e-07,1.13608,0.000378311,-2.92423e-07,1.13713e-07,1.13646,0.000378067,4.87176e-08,-1.02931e-07,1.13683,0.000377856,-2.60076e-07,5.95923e-08,1.13721,0.000377514,-8.12988e-08,-1.62288e-08,1.13759,0.000377303,-1.29985e-07,5.32278e-09,1.13797,0.000377059,-1.14017e-07,-5.06237e-09,1.13834,0.000376816,-1.29204e-07,1.49267e-08,1.13872,0.000376602,-8.44237e-08,-5.46444e-08,1.1391,0.000376269,-2.48357e-07,8.44417e-08,1.13947,0.000376026,4.96815e-09,-4.47039e-08,1.13985,0.000375902,-1.29143e-07,-2.48355e-08,1.14023,0.000375569,-2.0365e-07,2.48368e-08,1.1406,0.000375236,-1.2914e-07,4.46977e-08,1.14098,0.000375112,4.95341e-09,-8.44184e-08,1.14135,0.000374869,-2.48302e-07,5.45572e-08,1.14173,0.000374536,-8.463e-08,-1.46013e-08,1.1421,0.000374323,-1.28434e-07,3.8478e-09,1.14247,0.000374077,-1.1689e-07,-7.89941e-10,1.14285,0.000373841,-1.1926e-07,-6.88042e-10,1.14322,0.0003736,-1.21324e-07,3.54213e-09,1.1436,0.000373368,-1.10698e-07,-1.34805e-08,1.14397,0.000373107,-1.51139e-07,5.03798e-08,1.14434,0.000372767,0.,0.}; + + template + __device__ __forceinline__ void RGB2LuvConvert_f(const T& src, D& dst) + { + const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); + const float _un = 13 * (4 * 0.950456f * _d); + const float _vn = 13 * (9 * _d); + + float B = blueIdx == 0 ? src.x : src.z; + float G = src.y; + float R = blueIdx == 0 ? src.z : src.x; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + } + + float X = R * 0.412453f + G * 0.357580f + B * 0.180423f; + float Y = R * 0.212671f + G * 0.715160f + B * 0.072169f; + float Z = R * 0.019334f + G * 0.119193f + B * 0.950227f; + + float L = splineInterpolate(Y * (LAB_CBRT_TAB_SIZE / 1.5f), c_LabCbrtTab, LAB_CBRT_TAB_SIZE); + L = 116.f * L - 16.f; + + const float d = (4 * 13) / ::fmaxf(X + 15 * Y + 3 * Z, numeric_limits::epsilon()); + float u = L * (X * d - _un); + float v = L * ((9 * 0.25f) * Y * d - _vn); + + dst.x = L; + dst.y = u; + dst.z = v; + } + + template + __device__ __forceinline__ void RGB2LuvConvert_b(const T& src, D& dst) + { + float3 srcf, dstf; + + srcf.x = src.x * (1.f / 255.f); + srcf.y = src.y * (1.f / 255.f); + srcf.z = src.z * (1.f / 255.f); + + RGB2LuvConvert_f(srcf, dstf); + + dst.x = saturate_cast(dstf.x * 2.55f); + dst.y = saturate_cast(dstf.y * 0.72033898305084743f + 96.525423728813564f); + dst.z = saturate_cast(dstf.z * 0.9732824427480916f + 136.259541984732824f); + } + + template struct RGB2Luv; + template + struct RGB2Luv + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LuvConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Luv() {} + __host__ __device__ __forceinline__ RGB2Luv(const RGB2Luv&) {} + }; + template + struct RGB2Luv + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LuvConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Luv() {} + __host__ __device__ __forceinline__ RGB2Luv(const RGB2Luv&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2Luv functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template + __device__ __forceinline__ void Luv2RGBConvert_f(const T& src, D& dst) + { + const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); + const float _un = 4 * 0.950456f * _d; + const float _vn = 9 * _d; + + float L = src.x; + float u = src.y; + float v = src.z; + + float Y = (L + 16.f) * (1.f / 116.f); + Y = Y * Y * Y; + + float d = (1.f / 13.f) / L; + u = u * d + _un; + v = v * d + _vn; + + float iv = 1.f / v; + float X = 2.25f * u * Y * iv; + float Z = (12 - 3 * u - 20 * v) * Y * 0.25f * iv; + + float B = 0.055648f * X - 0.204043f * Y + 1.057311f * Z; + float G = -0.969256f * X + 1.875991f * Y + 0.041556f * Z; + float R = 3.240479f * X - 1.537150f * Y - 0.498535f * Z; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + } + + dst.x = blueIdx == 0 ? B : R; + dst.y = G; + dst.z = blueIdx == 0 ? R : B; + setAlpha(dst, ColorChannel::max()); + } + + template + __device__ __forceinline__ void Luv2RGBConvert_b(const T& src, D& dst) + { + float3 srcf, dstf; + + srcf.x = src.x * (100.f / 255.f); + srcf.y = src.y * 1.388235294117647f - 134.f; + srcf.z = src.z * 1.027450980392157f - 140.f; + + Luv2RGBConvert_f(srcf, dstf); + + dst.x = saturate_cast(dstf.x * 255.f); + dst.y = saturate_cast(dstf.y * 255.f); + dst.z = saturate_cast(dstf.z * 255.f); + setAlpha(dst, ColorChannel::max()); + } + + template struct Luv2RGB; + template + struct Luv2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Luv2RGBConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Luv2RGB() {} + __host__ __device__ __forceinline__ Luv2RGB(const Luv2RGB&) {} + }; + template + struct Luv2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Luv2RGBConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Luv2RGB() {} + __host__ __device__ __forceinline__ Luv2RGB(const Luv2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Luv2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + #undef CV_DESCALE + +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_COLOR_DETAIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce.hpp new file mode 100644 index 0000000..8af20b0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce.hpp @@ -0,0 +1,365 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_REDUCE_DETAIL_HPP +#define OPENCV_CUDA_REDUCE_DETAIL_HPP + +#include +#include "../warp.hpp" +#include "../warp_shuffle.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace reduce_detail + { + template struct GetType; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple& smem, const ValTuple& val, unsigned int tid) + { + thrust::get(smem)[tid] = thrust::get(val); + + For::loadToSmem(smem, val, tid); + } + template + static __device__ void loadFromSmem(const PointerTuple& smem, const ValTuple& val, unsigned int tid) + { + thrust::get(val) = thrust::get(smem)[tid]; + + For::loadFromSmem(smem, val, tid); + } + + template + static __device__ void merge(const PointerTuple& smem, const ValTuple& val, unsigned int tid, unsigned int delta, const OpTuple& op) + { + typename GetType::type>::type reg = thrust::get(smem)[tid + delta]; + thrust::get(smem)[tid] = thrust::get(val) = thrust::get(op)(thrust::get(val), reg); + + For::merge(smem, val, tid, delta, op); + } + template + static __device__ void mergeShfl(const ValTuple& val, unsigned int delta, unsigned int width, const OpTuple& op) + { + typename GetType::type>::type reg = shfl_down(thrust::get(val), delta, width); + thrust::get(val) = thrust::get(op)(thrust::get(val), reg); + + For::mergeShfl(val, delta, width, op); + } + }; + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple&, const ValTuple&, unsigned int) + { + } + template + static __device__ void loadFromSmem(const PointerTuple&, const ValTuple&, unsigned int) + { + } + + template + static __device__ void merge(const PointerTuple&, const ValTuple&, unsigned int, unsigned int, const OpTuple&) + { + } + template + static __device__ void mergeShfl(const ValTuple&, unsigned int, unsigned int, const OpTuple&) + { + } + }; + + template + __device__ __forceinline__ void loadToSmem(volatile T* smem, T& val, unsigned int tid) + { + smem[tid] = val; + } + template + __device__ __forceinline__ void loadFromSmem(volatile T* smem, T& val, unsigned int tid) + { + val = smem[tid]; + } + template + __device__ __forceinline__ void loadToSmem(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadToSmem(smem, val, tid); + } + template + __device__ __forceinline__ void loadFromSmem(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadFromSmem(smem, val, tid); + } + + template + __device__ __forceinline__ void merge(volatile T* smem, T& val, unsigned int tid, unsigned int delta, const Op& op) + { + T reg = smem[tid + delta]; + smem[tid] = val = op(val, reg); + } + template + __device__ __forceinline__ void mergeShfl(T& val, unsigned int delta, unsigned int width, const Op& op) + { + T reg = shfl_down(val, delta, width); + val = op(val, reg); + } + template + __device__ __forceinline__ void merge(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid, + unsigned int delta, + const thrust::tuple& op) + { + For<0, thrust::tuple_size >::value>::merge(smem, val, tid, delta, op); + } + template + __device__ __forceinline__ void mergeShfl(const thrust::tuple& val, + unsigned int delta, + unsigned int width, + const thrust::tuple& op) + { + For<0, thrust::tuple_size >::value>::mergeShfl(val, delta, width, op); + } + + template struct Generic + { + template + static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op) + { + loadToSmem(smem, val, tid); + if (N >= 32) + __syncthreads(); + + if (N >= 2048) + { + if (tid < 1024) + merge(smem, val, tid, 1024, op); + + __syncthreads(); + } + if (N >= 1024) + { + if (tid < 512) + merge(smem, val, tid, 512, op); + + __syncthreads(); + } + if (N >= 512) + { + if (tid < 256) + merge(smem, val, tid, 256, op); + + __syncthreads(); + } + if (N >= 256) + { + if (tid < 128) + merge(smem, val, tid, 128, op); + + __syncthreads(); + } + if (N >= 128) + { + if (tid < 64) + merge(smem, val, tid, 64, op); + + __syncthreads(); + } + if (N >= 64) + { + if (tid < 32) + merge(smem, val, tid, 32, op); + } + + if (tid < 16) + { + merge(smem, val, tid, 16, op); + merge(smem, val, tid, 8, op); + merge(smem, val, tid, 4, op); + merge(smem, val, tid, 2, op); + merge(smem, val, tid, 1, op); + } + } + }; + + template + struct Unroll + { + static __device__ void loopShfl(Reference val, Op op, unsigned int N) + { + mergeShfl(val, I, N, op); + Unroll::loopShfl(val, op, N); + } + static __device__ void loop(Pointer smem, Reference val, unsigned int tid, Op op) + { + merge(smem, val, tid, I, op); + Unroll::loop(smem, val, tid, op); + } + }; + template + struct Unroll<0, Pointer, Reference, Op> + { + static __device__ void loopShfl(Reference, Op, unsigned int) + { + } + static __device__ void loop(Pointer, Reference, unsigned int, Op) + { + } + }; + + template struct WarpOptimized + { + template + static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + CV_UNUSED(smem); + CV_UNUSED(tid); + + Unroll::loopShfl(val, op, N); + #else + loadToSmem(smem, val, tid); + + if (tid < N / 2) + Unroll::loop(smem, val, tid, op); + #endif + } + }; + + template struct GenericOptimized32 + { + enum { M = N / 32 }; + + template + static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op) + { + const unsigned int laneId = Warp::laneId(); + + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + Unroll<16, Pointer, Reference, Op>::loopShfl(val, op, warpSize); + + if (laneId == 0) + loadToSmem(smem, val, tid / 32); + #else + loadToSmem(smem, val, tid); + + if (laneId < 16) + Unroll<16, Pointer, Reference, Op>::loop(smem, val, tid, op); + + __syncthreads(); + + if (laneId == 0) + loadToSmem(smem, val, tid / 32); + #endif + + __syncthreads(); + + loadFromSmem(smem, val, tid); + + if (tid < 32) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + Unroll::loopShfl(val, op, M); + #else + Unroll::loop(smem, val, tid, op); + #endif + } + } + }; + + template struct StaticIf; + template struct StaticIf + { + typedef T1 type; + }; + template struct StaticIf + { + typedef T2 type; + }; + + template struct IsPowerOf2 + { + enum { value = ((N != 0) && !(N & (N - 1))) }; + }; + + template struct Dispatcher + { + typedef typename StaticIf< + (N <= 32) && IsPowerOf2::value, + WarpOptimized, + typename StaticIf< + (N <= 1024) && IsPowerOf2::value, + GenericOptimized32, + Generic + >::type + >::type reductor; + }; + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_REDUCE_DETAIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce_key_val.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce_key_val.hpp new file mode 100644 index 0000000..df37c17 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce_key_val.hpp @@ -0,0 +1,502 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP +#define OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP + +#include +#include "../warp.hpp" +#include "../warp_shuffle.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace reduce_key_val_detail + { + template struct GetType; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple& smem, const ReferenceTuple& data, unsigned int tid) + { + thrust::get(smem)[tid] = thrust::get(data); + + For::loadToSmem(smem, data, tid); + } + template + static __device__ void loadFromSmem(const PointerTuple& smem, const ReferenceTuple& data, unsigned int tid) + { + thrust::get(data) = thrust::get(smem)[tid]; + + For::loadFromSmem(smem, data, tid); + } + + template + static __device__ void copyShfl(const ReferenceTuple& val, unsigned int delta, int width) + { + thrust::get(val) = shfl_down(thrust::get(val), delta, width); + + For::copyShfl(val, delta, width); + } + template + static __device__ void copy(const PointerTuple& svals, const ReferenceTuple& val, unsigned int tid, unsigned int delta) + { + thrust::get(svals)[tid] = thrust::get(val) = thrust::get(svals)[tid + delta]; + + For::copy(svals, val, tid, delta); + } + + template + static __device__ void mergeShfl(const KeyReferenceTuple& key, const ValReferenceTuple& val, const CmpTuple& cmp, unsigned int delta, int width) + { + typename GetType::type>::type reg = shfl_down(thrust::get(key), delta, width); + + if (thrust::get(cmp)(reg, thrust::get(key))) + { + thrust::get(key) = reg; + thrust::get(val) = shfl_down(thrust::get(val), delta, width); + } + + For::mergeShfl(key, val, cmp, delta, width); + } + template + static __device__ void merge(const KeyPointerTuple& skeys, const KeyReferenceTuple& key, + const ValPointerTuple& svals, const ValReferenceTuple& val, + const CmpTuple& cmp, + unsigned int tid, unsigned int delta) + { + typename GetType::type>::type reg = thrust::get(skeys)[tid + delta]; + + if (thrust::get(cmp)(reg, thrust::get(key))) + { + thrust::get(skeys)[tid] = thrust::get(key) = reg; + thrust::get(svals)[tid] = thrust::get(val) = thrust::get(svals)[tid + delta]; + } + + For::merge(skeys, key, svals, val, cmp, tid, delta); + } + }; + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple&, const ReferenceTuple&, unsigned int) + { + } + template + static __device__ void loadFromSmem(const PointerTuple&, const ReferenceTuple&, unsigned int) + { + } + + template + static __device__ void copyShfl(const ReferenceTuple&, unsigned int, int) + { + } + template + static __device__ void copy(const PointerTuple&, const ReferenceTuple&, unsigned int, unsigned int) + { + } + + template + static __device__ void mergeShfl(const KeyReferenceTuple&, const ValReferenceTuple&, const CmpTuple&, unsigned int, int) + { + } + template + static __device__ void merge(const KeyPointerTuple&, const KeyReferenceTuple&, + const ValPointerTuple&, const ValReferenceTuple&, + const CmpTuple&, + unsigned int, unsigned int) + { + } + }; + + ////////////////////////////////////////////////////// + // loadToSmem + + template + __device__ __forceinline__ void loadToSmem(volatile T* smem, T& data, unsigned int tid) + { + smem[tid] = data; + } + template + __device__ __forceinline__ void loadFromSmem(volatile T* smem, T& data, unsigned int tid) + { + data = smem[tid]; + } + template + __device__ __forceinline__ void loadToSmem(const thrust::tuple& smem, + const thrust::tuple& data, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadToSmem(smem, data, tid); + } + template + __device__ __forceinline__ void loadFromSmem(const thrust::tuple& smem, + const thrust::tuple& data, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadFromSmem(smem, data, tid); + } + + ////////////////////////////////////////////////////// + // copyVals + + template + __device__ __forceinline__ void copyValsShfl(V& val, unsigned int delta, int width) + { + val = shfl_down(val, delta, width); + } + template + __device__ __forceinline__ void copyVals(volatile V* svals, V& val, unsigned int tid, unsigned int delta) + { + svals[tid] = val = svals[tid + delta]; + } + template + __device__ __forceinline__ void copyValsShfl(const thrust::tuple& val, + unsigned int delta, + int width) + { + For<0, thrust::tuple_size >::value>::copyShfl(val, delta, width); + } + template + __device__ __forceinline__ void copyVals(const thrust::tuple& svals, + const thrust::tuple& val, + unsigned int tid, unsigned int delta) + { + For<0, thrust::tuple_size >::value>::copy(svals, val, tid, delta); + } + + ////////////////////////////////////////////////////// + // merge + + template + __device__ __forceinline__ void mergeShfl(K& key, V& val, const Cmp& cmp, unsigned int delta, int width) + { + K reg = shfl_down(key, delta, width); + + if (cmp(reg, key)) + { + key = reg; + copyValsShfl(val, delta, width); + } + } + template + __device__ __forceinline__ void merge(volatile K* skeys, K& key, volatile V* svals, V& val, const Cmp& cmp, unsigned int tid, unsigned int delta) + { + K reg = skeys[tid + delta]; + + if (cmp(reg, key)) + { + skeys[tid] = key = reg; + copyVals(svals, val, tid, delta); + } + } + template + __device__ __forceinline__ void mergeShfl(K& key, + const thrust::tuple& val, + const Cmp& cmp, + unsigned int delta, int width) + { + K reg = shfl_down(key, delta, width); + + if (cmp(reg, key)) + { + key = reg; + copyValsShfl(val, delta, width); + } + } + template + __device__ __forceinline__ void merge(volatile K* skeys, K& key, + const thrust::tuple& svals, + const thrust::tuple& val, + const Cmp& cmp, unsigned int tid, unsigned int delta) + { + K reg = skeys[tid + delta]; + + if (cmp(reg, key)) + { + skeys[tid] = key = reg; + copyVals(svals, val, tid, delta); + } + } + template + __device__ __forceinline__ void mergeShfl(const thrust::tuple& key, + const thrust::tuple& val, + const thrust::tuple& cmp, + unsigned int delta, int width) + { + For<0, thrust::tuple_size >::value>::mergeShfl(key, val, cmp, delta, width); + } + template + __device__ __forceinline__ void merge(const thrust::tuple& skeys, + const thrust::tuple& key, + const thrust::tuple& svals, + const thrust::tuple& val, + const thrust::tuple& cmp, + unsigned int tid, unsigned int delta) + { + For<0, thrust::tuple_size >::value>::merge(skeys, key, svals, val, cmp, tid, delta); + } + + ////////////////////////////////////////////////////// + // Generic + + template struct Generic + { + template + static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + loadToSmem(skeys, key, tid); + loadValsToSmem(svals, val, tid); + if (N >= 32) + __syncthreads(); + + if (N >= 2048) + { + if (tid < 1024) + merge(skeys, key, svals, val, cmp, tid, 1024); + + __syncthreads(); + } + if (N >= 1024) + { + if (tid < 512) + merge(skeys, key, svals, val, cmp, tid, 512); + + __syncthreads(); + } + if (N >= 512) + { + if (tid < 256) + merge(skeys, key, svals, val, cmp, tid, 256); + + __syncthreads(); + } + if (N >= 256) + { + if (tid < 128) + merge(skeys, key, svals, val, cmp, tid, 128); + + __syncthreads(); + } + if (N >= 128) + { + if (tid < 64) + merge(skeys, key, svals, val, cmp, tid, 64); + + __syncthreads(); + } + if (N >= 64) + { + if (tid < 32) + merge(skeys, key, svals, val, cmp, tid, 32); + } + + if (tid < 16) + { + merge(skeys, key, svals, val, cmp, tid, 16); + merge(skeys, key, svals, val, cmp, tid, 8); + merge(skeys, key, svals, val, cmp, tid, 4); + merge(skeys, key, svals, val, cmp, tid, 2); + merge(skeys, key, svals, val, cmp, tid, 1); + } + } + }; + + template + struct Unroll + { + static __device__ void loopShfl(KR key, VR val, Cmp cmp, unsigned int N) + { + mergeShfl(key, val, cmp, I, N); + Unroll::loopShfl(key, val, cmp, N); + } + static __device__ void loop(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + merge(skeys, key, svals, val, cmp, tid, I); + Unroll::loop(skeys, key, svals, val, tid, cmp); + } + }; + template + struct Unroll<0, KP, KR, VP, VR, Cmp> + { + static __device__ void loopShfl(KR, VR, Cmp, unsigned int) + { + } + static __device__ void loop(KP, KR, VP, VR, unsigned int, Cmp) + { + } + }; + + template struct WarpOptimized + { + template + static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + #if 0 // __CUDA_ARCH__ >= 300 + CV_UNUSED(skeys); + CV_UNUSED(svals); + CV_UNUSED(tid); + + Unroll::loopShfl(key, val, cmp, N); + #else + loadToSmem(skeys, key, tid); + loadToSmem(svals, val, tid); + + if (tid < N / 2) + Unroll::loop(skeys, key, svals, val, tid, cmp); + #endif + } + }; + + template struct GenericOptimized32 + { + enum { M = N / 32 }; + + template + static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + const unsigned int laneId = Warp::laneId(); + + #if 0 // __CUDA_ARCH__ >= 300 + Unroll<16, KP, KR, VP, VR, Cmp>::loopShfl(key, val, cmp, warpSize); + + if (laneId == 0) + { + loadToSmem(skeys, key, tid / 32); + loadToSmem(svals, val, tid / 32); + } + #else + loadToSmem(skeys, key, tid); + loadToSmem(svals, val, tid); + + if (laneId < 16) + Unroll<16, KP, KR, VP, VR, Cmp>::loop(skeys, key, svals, val, tid, cmp); + + __syncthreads(); + + if (laneId == 0) + { + loadToSmem(skeys, key, tid / 32); + loadToSmem(svals, val, tid / 32); + } + #endif + + __syncthreads(); + + loadFromSmem(skeys, key, tid); + + if (tid < 32) + { + #if 0 // __CUDA_ARCH__ >= 300 + loadFromSmem(svals, val, tid); + + Unroll::loopShfl(key, val, cmp, M); + #else + Unroll::loop(skeys, key, svals, val, tid, cmp); + #endif + } + } + }; + + template struct StaticIf; + template struct StaticIf + { + typedef T1 type; + }; + template struct StaticIf + { + typedef T2 type; + }; + + template struct IsPowerOf2 + { + enum { value = ((N != 0) && !(N & (N - 1))) }; + }; + + template struct Dispatcher + { + typedef typename StaticIf< + (N <= 32) && IsPowerOf2::value, + WarpOptimized, + typename StaticIf< + (N <= 1024) && IsPowerOf2::value, + GenericOptimized32, + Generic + >::type + >::type reductor; + }; + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/transform_detail.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/transform_detail.hpp new file mode 100644 index 0000000..1919848 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/transform_detail.hpp @@ -0,0 +1,392 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TRANSFORM_DETAIL_HPP +#define OPENCV_CUDA_TRANSFORM_DETAIL_HPP + +#include "../common.hpp" +#include "../vec_traits.hpp" +#include "../functional.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace transform_detail + { + //! Read Write Traits + + template struct UnaryReadWriteTraits + { + typedef typename TypeVec::vec_type read_type; + typedef typename TypeVec::vec_type write_type; + }; + + template struct BinaryReadWriteTraits + { + typedef typename TypeVec::vec_type read_type1; + typedef typename TypeVec::vec_type read_type2; + typedef typename TypeVec::vec_type write_type; + }; + + //! Transform kernels + + template struct OpUnroller; + template <> struct OpUnroller<1> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + } + }; + template <> struct OpUnroller<2> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src.y); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src1.y, src2.y); + } + }; + template <> struct OpUnroller<3> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src.z); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src1.y, src2.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src1.z, src2.z); + } + }; + template <> struct OpUnroller<4> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src.z); + if (mask(y, x_shifted + 3)) + dst.w = op(src.w); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src1.y, src2.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src1.z, src2.z); + if (mask(y, x_shifted + 3)) + dst.w = op(src1.w, src2.w); + } + }; + template <> struct OpUnroller<8> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.a0 = op(src.a0); + if (mask(y, x_shifted + 1)) + dst.a1 = op(src.a1); + if (mask(y, x_shifted + 2)) + dst.a2 = op(src.a2); + if (mask(y, x_shifted + 3)) + dst.a3 = op(src.a3); + if (mask(y, x_shifted + 4)) + dst.a4 = op(src.a4); + if (mask(y, x_shifted + 5)) + dst.a5 = op(src.a5); + if (mask(y, x_shifted + 6)) + dst.a6 = op(src.a6); + if (mask(y, x_shifted + 7)) + dst.a7 = op(src.a7); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.a0 = op(src1.a0, src2.a0); + if (mask(y, x_shifted + 1)) + dst.a1 = op(src1.a1, src2.a1); + if (mask(y, x_shifted + 2)) + dst.a2 = op(src1.a2, src2.a2); + if (mask(y, x_shifted + 3)) + dst.a3 = op(src1.a3, src2.a3); + if (mask(y, x_shifted + 4)) + dst.a4 = op(src1.a4, src2.a4); + if (mask(y, x_shifted + 5)) + dst.a5 = op(src1.a5, src2.a5); + if (mask(y, x_shifted + 6)) + dst.a6 = op(src1.a6, src2.a6); + if (mask(y, x_shifted + 7)) + dst.a7 = op(src1.a7, src2.a7); + } + }; + + template + static __global__ void transformSmart(const PtrStepSz src_, PtrStep dst_, const Mask mask, const UnOp op) + { + typedef TransformFunctorTraits ft; + typedef typename UnaryReadWriteTraits::read_type read_type; + typedef typename UnaryReadWriteTraits::write_type write_type; + + const int x = threadIdx.x + blockIdx.x * blockDim.x; + const int y = threadIdx.y + blockIdx.y * blockDim.y; + const int x_shifted = x * ft::smart_shift; + + if (y < src_.rows) + { + const T* src = src_.ptr(y); + D* dst = dst_.ptr(y); + + if (x_shifted + ft::smart_shift - 1 < src_.cols) + { + const read_type src_n_el = ((const read_type*)src)[x]; + OpUnroller::unroll(src_n_el, ((write_type*)dst)[x], mask, op, x_shifted, y); + } + else + { + for (int real_x = x_shifted; real_x < src_.cols; ++real_x) + { + if (mask(y, real_x)) + dst[real_x] = op(src[real_x]); + } + } + } + } + + template + __global__ static void transformSimple(const PtrStepSz src, PtrStep dst, const Mask mask, const UnOp op) + { + const int x = blockDim.x * blockIdx.x + threadIdx.x; + const int y = blockDim.y * blockIdx.y + threadIdx.y; + + if (x < src.cols && y < src.rows && mask(y, x)) + { + dst.ptr(y)[x] = op(src.ptr(y)[x]); + } + } + + template + static __global__ void transformSmart(const PtrStepSz src1_, const PtrStep src2_, PtrStep dst_, + const Mask mask, const BinOp op) + { + typedef TransformFunctorTraits ft; + typedef typename BinaryReadWriteTraits::read_type1 read_type1; + typedef typename BinaryReadWriteTraits::read_type2 read_type2; + typedef typename BinaryReadWriteTraits::write_type write_type; + + const int x = threadIdx.x + blockIdx.x * blockDim.x; + const int y = threadIdx.y + blockIdx.y * blockDim.y; + const int x_shifted = x * ft::smart_shift; + + if (y < src1_.rows) + { + const T1* src1 = src1_.ptr(y); + const T2* src2 = src2_.ptr(y); + D* dst = dst_.ptr(y); + + if (x_shifted + ft::smart_shift - 1 < src1_.cols) + { + const read_type1 src1_n_el = ((const read_type1*)src1)[x]; + const read_type2 src2_n_el = ((const read_type2*)src2)[x]; + + OpUnroller::unroll(src1_n_el, src2_n_el, ((write_type*)dst)[x], mask, op, x_shifted, y); + } + else + { + for (int real_x = x_shifted; real_x < src1_.cols; ++real_x) + { + if (mask(y, real_x)) + dst[real_x] = op(src1[real_x], src2[real_x]); + } + } + } + } + + template + static __global__ void transformSimple(const PtrStepSz src1, const PtrStep src2, PtrStep dst, + const Mask mask, const BinOp op) + { + const int x = blockDim.x * blockIdx.x + threadIdx.x; + const int y = blockDim.y * blockIdx.y + threadIdx.y; + + if (x < src1.cols && y < src1.rows && mask(y, x)) + { + const T1 src1_data = src1.ptr(y)[x]; + const T2 src2_data = src2.ptr(y)[x]; + dst.ptr(y)[x] = op(src1_data, src2_data); + } + } + + template struct TransformDispatcher; + template<> struct TransformDispatcher + { + template + static void call(PtrStepSz src, PtrStepSz dst, UnOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + const dim3 threads(ft::simple_block_dim_x, ft::simple_block_dim_y, 1); + const dim3 grid(divUp(src.cols, threads.x), divUp(src.rows, threads.y), 1); + + transformSimple<<>>(src, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + + template + static void call(PtrStepSz src1, PtrStepSz src2, PtrStepSz dst, BinOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + const dim3 threads(ft::simple_block_dim_x, ft::simple_block_dim_y, 1); + const dim3 grid(divUp(src1.cols, threads.x), divUp(src1.rows, threads.y), 1); + + transformSimple<<>>(src1, src2, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + }; + template<> struct TransformDispatcher + { + template + static void call(PtrStepSz src, PtrStepSz dst, UnOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + CV_StaticAssert(ft::smart_shift != 1, ""); + + if (!isAligned(src.data, ft::smart_shift * sizeof(T)) || !isAligned(src.step, ft::smart_shift * sizeof(T)) || + !isAligned(dst.data, ft::smart_shift * sizeof(D)) || !isAligned(dst.step, ft::smart_shift * sizeof(D))) + { + TransformDispatcher::call(src, dst, op, mask, stream); + return; + } + + const dim3 threads(ft::smart_block_dim_x, ft::smart_block_dim_y, 1); + const dim3 grid(divUp(src.cols, threads.x * ft::smart_shift), divUp(src.rows, threads.y), 1); + + transformSmart<<>>(src, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + + template + static void call(PtrStepSz src1, PtrStepSz src2, PtrStepSz dst, BinOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + CV_StaticAssert(ft::smart_shift != 1, ""); + + if (!isAligned(src1.data, ft::smart_shift * sizeof(T1)) || !isAligned(src1.step, ft::smart_shift * sizeof(T1)) || + !isAligned(src2.data, ft::smart_shift * sizeof(T2)) || !isAligned(src2.step, ft::smart_shift * sizeof(T2)) || + !isAligned(dst.data, ft::smart_shift * sizeof(D)) || !isAligned(dst.step, ft::smart_shift * sizeof(D))) + { + TransformDispatcher::call(src1, src2, dst, op, mask, stream); + return; + } + + const dim3 threads(ft::smart_block_dim_x, ft::smart_block_dim_y, 1); + const dim3 grid(divUp(src1.cols, threads.x * ft::smart_shift), divUp(src1.rows, threads.y), 1); + + transformSmart<<>>(src1, src2, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + }; + } // namespace transform_detail +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_TRANSFORM_DETAIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/type_traits_detail.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/type_traits_detail.hpp new file mode 100644 index 0000000..a78bd2c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/type_traits_detail.hpp @@ -0,0 +1,191 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP +#define OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP + +#include "../common.hpp" +#include "../vec_traits.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace type_traits_detail + { + template struct Select { typedef T1 type; }; + template struct Select { typedef T2 type; }; + + template struct IsSignedIntergral { enum {value = 0}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + + template struct IsUnsignedIntegral { enum {value = 0}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + + template struct IsIntegral { enum {value = IsSignedIntergral::value || IsUnsignedIntegral::value}; }; + template <> struct IsIntegral { enum {value = 1}; }; + template <> struct IsIntegral { enum {value = 1}; }; + + template struct IsFloat { enum {value = 0}; }; + template <> struct IsFloat { enum {value = 1}; }; + template <> struct IsFloat { enum {value = 1}; }; + + template struct IsVec { enum {value = 0}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + + template struct AddParameterType { typedef const U& type; }; + template struct AddParameterType { typedef U& type; }; + template <> struct AddParameterType { typedef void type; }; + + template struct ReferenceTraits + { + enum { value = false }; + typedef U type; + }; + template struct ReferenceTraits + { + enum { value = true }; + typedef U type; + }; + + template struct PointerTraits + { + enum { value = false }; + typedef void type; + }; + template struct PointerTraits + { + enum { value = true }; + typedef U type; + }; + template struct PointerTraits + { + enum { value = true }; + typedef U type; + }; + + template struct UnConst + { + typedef U type; + enum { value = 0 }; + }; + template struct UnConst + { + typedef U type; + enum { value = 1 }; + }; + template struct UnConst + { + typedef U& type; + enum { value = 1 }; + }; + + template struct UnVolatile + { + typedef U type; + enum { value = 0 }; + }; + template struct UnVolatile + { + typedef U type; + enum { value = 1 }; + }; + template struct UnVolatile + { + typedef U& type; + enum { value = 1 }; + }; + } // namespace type_traits_detail +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/vec_distance_detail.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/vec_distance_detail.hpp new file mode 100644 index 0000000..8283a99 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/detail/vec_distance_detail.hpp @@ -0,0 +1,121 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP +#define OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP + +#include "../datamov_utils.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace vec_distance_detail + { + template struct UnrollVecDiffCached + { + template + static __device__ void calcCheck(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int ind) + { + if (ind < len) + { + T1 val1 = *vecCached++; + + T2 val2; + ForceGlob::Load(vecGlob, ind, val2); + + dist.reduceIter(val1, val2); + + UnrollVecDiffCached::calcCheck(vecCached, vecGlob, len, dist, ind + THREAD_DIM); + } + } + + template + static __device__ void calcWithoutCheck(const T1* vecCached, const T2* vecGlob, Dist& dist) + { + T1 val1 = *vecCached++; + + T2 val2; + ForceGlob::Load(vecGlob, 0, val2); + vecGlob += THREAD_DIM; + + dist.reduceIter(val1, val2); + + UnrollVecDiffCached::calcWithoutCheck(vecCached, vecGlob, dist); + } + }; + template struct UnrollVecDiffCached + { + template + static __device__ __forceinline__ void calcCheck(const T1*, const T2*, int, Dist&, int) + { + } + + template + static __device__ __forceinline__ void calcWithoutCheck(const T1*, const T2*, Dist&) + { + } + }; + + template struct VecDiffCachedCalculator; + template struct VecDiffCachedCalculator + { + template + static __device__ __forceinline__ void calc(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int tid) + { + UnrollVecDiffCached::calcCheck(vecCached, vecGlob, len, dist, tid); + } + }; + template struct VecDiffCachedCalculator + { + template + static __device__ __forceinline__ void calc(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int tid) + { + UnrollVecDiffCached::calcWithoutCheck(vecCached, vecGlob + tid, dist); + } + }; + } // namespace vec_distance_detail +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/dynamic_smem.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/dynamic_smem.hpp new file mode 100644 index 0000000..42570c6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/dynamic_smem.hpp @@ -0,0 +1,88 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DYNAMIC_SMEM_HPP +#define OPENCV_CUDA_DYNAMIC_SMEM_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct DynamicSharedMem + { + __device__ __forceinline__ operator T*() + { + extern __shared__ int __smem[]; + return (T*)__smem; + } + + __device__ __forceinline__ operator const T*() const + { + extern __shared__ int __smem[]; + return (T*)__smem; + } + }; + + // specialize for double to avoid unaligned memory access compile errors + template<> struct DynamicSharedMem + { + __device__ __forceinline__ operator double*() + { + extern __shared__ double __smem_d[]; + return (double*)__smem_d; + } + + __device__ __forceinline__ operator const double*() const + { + extern __shared__ double __smem_d[]; + return (double*)__smem_d; + } + }; +}}} + +//! @endcond + +#endif // OPENCV_CUDA_DYNAMIC_SMEM_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/emulation.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/emulation.hpp new file mode 100644 index 0000000..17dc117 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/emulation.hpp @@ -0,0 +1,269 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_EMULATION_HPP_ +#define OPENCV_CUDA_EMULATION_HPP_ + +#include "common.hpp" +#include "warp_reduce.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct Emulation + { + + static __device__ __forceinline__ int syncthreadsOr(int pred) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 200) + // just campilation stab + return 0; +#else + return __syncthreads_or(pred); +#endif + } + + template + static __forceinline__ __device__ int Ballot(int predicate) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200) + return __ballot(predicate); +#else + __shared__ volatile int cta_buffer[CTA_SIZE]; + + int tid = threadIdx.x; + cta_buffer[tid] = predicate ? (1 << (tid & 31)) : 0; + return warp_reduce(cta_buffer); +#endif + } + + struct smem + { + enum { TAG_MASK = (1U << ( (sizeof(unsigned int) << 3) - 5U)) - 1U }; + + template + static __device__ __forceinline__ T atomicInc(T* address, T val) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120) + T count; + unsigned int tag = threadIdx.x << ( (sizeof(unsigned int) << 3) - 5U); + do + { + count = *address & TAG_MASK; + count = tag | (count + 1); + *address = count; + } while (*address != count); + + return (count & TAG_MASK) - 1; +#else + return ::atomicInc(address, val); +#endif + } + + template + static __device__ __forceinline__ T atomicAdd(T* address, T val) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120) + T count; + unsigned int tag = threadIdx.x << ( (sizeof(unsigned int) << 3) - 5U); + do + { + count = *address & TAG_MASK; + count = tag | (count + val); + *address = count; + } while (*address != count); + + return (count & TAG_MASK) - val; +#else + return ::atomicAdd(address, val); +#endif + } + + template + static __device__ __forceinline__ T atomicMin(T* address, T val) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120) + T count = ::min(*address, val); + do + { + *address = count; + } while (*address > count); + + return count; +#else + return ::atomicMin(address, val); +#endif + } + }; // struct cmem + + struct glob + { + static __device__ __forceinline__ int atomicAdd(int* address, int val) + { + return ::atomicAdd(address, val); + } + static __device__ __forceinline__ unsigned int atomicAdd(unsigned int* address, unsigned int val) + { + return ::atomicAdd(address, val); + } + static __device__ __forceinline__ float atomicAdd(float* address, float val) + { + #if __CUDA_ARCH__ >= 200 + return ::atomicAdd(address, val); + #else + int* address_as_i = (int*) address; + int old = *address_as_i, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_i, assumed, + __float_as_int(val + __int_as_float(assumed))); + } while (assumed != old); + return __int_as_float(old); + #endif + } + static __device__ __forceinline__ double atomicAdd(double* address, double val) + { + #if __CUDA_ARCH__ >= 130 + unsigned long long int* address_as_ull = (unsigned long long int*) address; + unsigned long long int old = *address_as_ull, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_ull, assumed, + __double_as_longlong(val + __longlong_as_double(assumed))); + } while (assumed != old); + return __longlong_as_double(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0; + #endif + } + + static __device__ __forceinline__ int atomicMin(int* address, int val) + { + return ::atomicMin(address, val); + } + static __device__ __forceinline__ float atomicMin(float* address, float val) + { + #if __CUDA_ARCH__ >= 120 + int* address_as_i = (int*) address; + int old = *address_as_i, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_i, assumed, + __float_as_int(::fminf(val, __int_as_float(assumed)))); + } while (assumed != old); + return __int_as_float(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0f; + #endif + } + static __device__ __forceinline__ double atomicMin(double* address, double val) + { + #if __CUDA_ARCH__ >= 130 + unsigned long long int* address_as_ull = (unsigned long long int*) address; + unsigned long long int old = *address_as_ull, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_ull, assumed, + __double_as_longlong(::fmin(val, __longlong_as_double(assumed)))); + } while (assumed != old); + return __longlong_as_double(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0; + #endif + } + + static __device__ __forceinline__ int atomicMax(int* address, int val) + { + return ::atomicMax(address, val); + } + static __device__ __forceinline__ float atomicMax(float* address, float val) + { + #if __CUDA_ARCH__ >= 120 + int* address_as_i = (int*) address; + int old = *address_as_i, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_i, assumed, + __float_as_int(::fmaxf(val, __int_as_float(assumed)))); + } while (assumed != old); + return __int_as_float(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0f; + #endif + } + static __device__ __forceinline__ double atomicMax(double* address, double val) + { + #if __CUDA_ARCH__ >= 130 + unsigned long long int* address_as_ull = (unsigned long long int*) address; + unsigned long long int old = *address_as_ull, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_ull, assumed, + __double_as_longlong(::fmax(val, __longlong_as_double(assumed)))); + } while (assumed != old); + return __longlong_as_double(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0; + #endif + } + }; + }; //struct Emulation +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif /* OPENCV_CUDA_EMULATION_HPP_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/filters.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/filters.hpp new file mode 100644 index 0000000..bf3147e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/filters.hpp @@ -0,0 +1,293 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_FILTERS_HPP +#define OPENCV_CUDA_FILTERS_HPP + +#include "saturate_cast.hpp" +#include "vec_traits.hpp" +#include "vec_math.hpp" +#include "type_traits.hpp" +#include "nppdefs.h" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct PointFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ PointFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f) + : src(src_) + { + CV_UNUSED(fx); + CV_UNUSED(fy); + } + + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + return src(__float2int_rz(y), __float2int_rz(x)); + } + + Ptr2D src; + }; + + template struct LinearFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ LinearFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f) + : src(src_) + { + CV_UNUSED(fx); + CV_UNUSED(fy); + } + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + typedef typename TypeVec::cn>::vec_type work_type; + + work_type out = VecTraits::all(0); + + const int x1 = __float2int_rd(x); + const int y1 = __float2int_rd(y); + if (x1 <= NPP_MIN_32S || x1 >= NPP_MAX_32S || y1 <= NPP_MIN_32S || y1 >= NPP_MAX_32S) + { + elem_type src_reg = src(y1, x1); + out = out + src_reg * 1.0f; + return saturate_cast(out); + } + const int x2 = x1 + 1; + const int y2 = y1 + 1; + + elem_type src_reg = src(y1, x1); + out = out + src_reg * ((x2 - x) * (y2 - y)); + + src_reg = src(y1, x2); + out = out + src_reg * ((x - x1) * (y2 - y)); + + src_reg = src(y2, x1); + out = out + src_reg * ((x2 - x) * (y - y1)); + + src_reg = src(y2, x2); + out = out + src_reg * ((x - x1) * (y - y1)); + + return saturate_cast(out); + } + + Ptr2D src; + }; + + template struct CubicFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + typedef typename TypeVec::cn>::vec_type work_type; + + explicit __host__ __device__ __forceinline__ CubicFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f) + : src(src_) + { + CV_UNUSED(fx); + CV_UNUSED(fy); + } + + static __device__ __forceinline__ float bicubicCoeff(float x_) + { + float x = fabsf(x_); + if (x <= 1.0f) + { + return x * x * (1.5f * x - 2.5f) + 1.0f; + } + else if (x < 2.0f) + { + return x * (x * (-0.5f * x + 2.5f) - 4.0f) + 2.0f; + } + else + { + return 0.0f; + } + } + + __device__ elem_type operator ()(float y, float x) const + { + const float xmin = ::ceilf(x - 2.0f); + const float xmax = ::floorf(x + 2.0f); + + const float ymin = ::ceilf(y - 2.0f); + const float ymax = ::floorf(y + 2.0f); + + work_type sum = VecTraits::all(0); + float wsum = 0.0f; + + for (float cy = ymin; cy <= ymax; cy += 1.0f) + { + for (float cx = xmin; cx <= xmax; cx += 1.0f) + { + const float w = bicubicCoeff(x - cx) * bicubicCoeff(y - cy); + sum = sum + w * src(__float2int_rd(cy), __float2int_rd(cx)); + wsum += w; + } + } + + work_type res = (!wsum)? VecTraits::all(0) : sum / wsum; + + return saturate_cast(res); + } + + Ptr2D src; + }; + // for integer scaling + template struct IntegerAreaFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ IntegerAreaFilter(const Ptr2D& src_, float scale_x_, float scale_y_) + : src(src_), scale_x(scale_x_), scale_y(scale_y_), scale(1.f / (scale_x * scale_y)) {} + + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + float fsx1 = x * scale_x; + float fsx2 = fsx1 + scale_x; + + int sx1 = __float2int_ru(fsx1); + int sx2 = __float2int_rd(fsx2); + + float fsy1 = y * scale_y; + float fsy2 = fsy1 + scale_y; + + int sy1 = __float2int_ru(fsy1); + int sy2 = __float2int_rd(fsy2); + + typedef typename TypeVec::cn>::vec_type work_type; + work_type out = VecTraits::all(0.f); + + for(int dy = sy1; dy < sy2; ++dy) + for(int dx = sx1; dx < sx2; ++dx) + { + out = out + src(dy, dx) * scale; + } + + return saturate_cast(out); + } + + Ptr2D src; + float scale_x, scale_y ,scale; + }; + + template struct AreaFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ AreaFilter(const Ptr2D& src_, float scale_x_, float scale_y_) + : src(src_), scale_x(scale_x_), scale_y(scale_y_){} + + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + float fsx1 = x * scale_x; + float fsx2 = fsx1 + scale_x; + + int sx1 = __float2int_ru(fsx1); + int sx2 = __float2int_rd(fsx2); + + float fsy1 = y * scale_y; + float fsy2 = fsy1 + scale_y; + + int sy1 = __float2int_ru(fsy1); + int sy2 = __float2int_rd(fsy2); + + float scale = 1.f / (fminf(scale_x, src.width - fsx1) * fminf(scale_y, src.height - fsy1)); + + typedef typename TypeVec::cn>::vec_type work_type; + work_type out = VecTraits::all(0.f); + + for (int dy = sy1; dy < sy2; ++dy) + { + for (int dx = sx1; dx < sx2; ++dx) + out = out + src(dy, dx) * scale; + + if (sx1 > fsx1) + out = out + src(dy, (sx1 -1) ) * ((sx1 - fsx1) * scale); + + if (sx2 < fsx2) + out = out + src(dy, sx2) * ((fsx2 -sx2) * scale); + } + + if (sy1 > fsy1) + for (int dx = sx1; dx < sx2; ++dx) + out = out + src( (sy1 - 1) , dx) * ((sy1 -fsy1) * scale); + + if (sy2 < fsy2) + for (int dx = sx1; dx < sx2; ++dx) + out = out + src(sy2, dx) * ((fsy2 -sy2) * scale); + + if ((sy1 > fsy1) && (sx1 > fsx1)) + out = out + src( (sy1 - 1) , (sx1 - 1)) * ((sy1 -fsy1) * (sx1 -fsx1) * scale); + + if ((sy1 > fsy1) && (sx2 < fsx2)) + out = out + src( (sy1 - 1) , sx2) * ((sy1 -fsy1) * (fsx2 -sx2) * scale); + + if ((sy2 < fsy2) && (sx2 < fsx2)) + out = out + src(sy2, sx2) * ((fsy2 -sy2) * (fsx2 -sx2) * scale); + + if ((sy2 < fsy2) && (sx1 > fsx1)) + out = out + src(sy2, (sx1 - 1)) * ((fsy2 -sy2) * (sx1 -fsx1) * scale); + + return saturate_cast(out); + } + + Ptr2D src; + float scale_x, scale_y; + int width, haight; + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_FILTERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/funcattrib.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/funcattrib.hpp new file mode 100644 index 0000000..f582080 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/funcattrib.hpp @@ -0,0 +1,79 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP +#define OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP + +#include + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + void printFuncAttrib(Func& func) + { + + cudaFuncAttributes attrs; + cudaFuncGetAttributes(&attrs, func); + + printf("=== Function stats ===\n"); + printf("Name: \n"); + printf("sharedSizeBytes = %d\n", attrs.sharedSizeBytes); + printf("constSizeBytes = %d\n", attrs.constSizeBytes); + printf("localSizeBytes = %d\n", attrs.localSizeBytes); + printf("maxThreadsPerBlock = %d\n", attrs.maxThreadsPerBlock); + printf("numRegs = %d\n", attrs.numRegs); + printf("ptxVersion = %d\n", attrs.ptxVersion); + printf("binaryVersion = %d\n", attrs.binaryVersion); + printf("\n"); + fflush(stdout); + } +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif /* OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/functional.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/functional.hpp new file mode 100644 index 0000000..9f53d87 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/functional.hpp @@ -0,0 +1,805 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_FUNCTIONAL_HPP +#define OPENCV_CUDA_FUNCTIONAL_HPP + +#include +#include "saturate_cast.hpp" +#include "vec_traits.hpp" +#include "type_traits.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + // Function Objects + template struct unary_function + { + typedef Argument argument_type; + typedef Result result_type; + }; + template struct binary_function + { + typedef Argument1 first_argument_type; + typedef Argument2 second_argument_type; + typedef Result result_type; + }; + + // Arithmetic Operations + template struct plus : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a + b; + } + __host__ __device__ __forceinline__ plus() {} + __host__ __device__ __forceinline__ plus(const plus&) {} + }; + + template struct minus : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a - b; + } + __host__ __device__ __forceinline__ minus() {} + __host__ __device__ __forceinline__ minus(const minus&) {} + }; + + template struct multiplies : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a * b; + } + __host__ __device__ __forceinline__ multiplies() {} + __host__ __device__ __forceinline__ multiplies(const multiplies&) {} + }; + + template struct divides : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a / b; + } + __host__ __device__ __forceinline__ divides() {} + __host__ __device__ __forceinline__ divides(const divides&) {} + }; + + template struct modulus : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a % b; + } + __host__ __device__ __forceinline__ modulus() {} + __host__ __device__ __forceinline__ modulus(const modulus&) {} + }; + + template struct negate : unary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a) const + { + return -a; + } + __host__ __device__ __forceinline__ negate() {} + __host__ __device__ __forceinline__ negate(const negate&) {} + }; + + // Comparison Operations + template struct equal_to : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a == b; + } + __host__ __device__ __forceinline__ equal_to() {} + __host__ __device__ __forceinline__ equal_to(const equal_to&) {} + }; + + template struct not_equal_to : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a != b; + } + __host__ __device__ __forceinline__ not_equal_to() {} + __host__ __device__ __forceinline__ not_equal_to(const not_equal_to&) {} + }; + + template struct greater : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a > b; + } + __host__ __device__ __forceinline__ greater() {} + __host__ __device__ __forceinline__ greater(const greater&) {} + }; + + template struct less : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a < b; + } + __host__ __device__ __forceinline__ less() {} + __host__ __device__ __forceinline__ less(const less&) {} + }; + + template struct greater_equal : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a >= b; + } + __host__ __device__ __forceinline__ greater_equal() {} + __host__ __device__ __forceinline__ greater_equal(const greater_equal&) {} + }; + + template struct less_equal : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a <= b; + } + __host__ __device__ __forceinline__ less_equal() {} + __host__ __device__ __forceinline__ less_equal(const less_equal&) {} + }; + + // Logical Operations + template struct logical_and : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a && b; + } + __host__ __device__ __forceinline__ logical_and() {} + __host__ __device__ __forceinline__ logical_and(const logical_and&) {} + }; + + template struct logical_or : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a || b; + } + __host__ __device__ __forceinline__ logical_or() {} + __host__ __device__ __forceinline__ logical_or(const logical_or&) {} + }; + + template struct logical_not : unary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a) const + { + return !a; + } + __host__ __device__ __forceinline__ logical_not() {} + __host__ __device__ __forceinline__ logical_not(const logical_not&) {} + }; + + // Bitwise Operations + template struct bit_and : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a & b; + } + __host__ __device__ __forceinline__ bit_and() {} + __host__ __device__ __forceinline__ bit_and(const bit_and&) {} + }; + + template struct bit_or : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a | b; + } + __host__ __device__ __forceinline__ bit_or() {} + __host__ __device__ __forceinline__ bit_or(const bit_or&) {} + }; + + template struct bit_xor : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a ^ b; + } + __host__ __device__ __forceinline__ bit_xor() {} + __host__ __device__ __forceinline__ bit_xor(const bit_xor&) {} + }; + + template struct bit_not : unary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType v) const + { + return ~v; + } + __host__ __device__ __forceinline__ bit_not() {} + __host__ __device__ __forceinline__ bit_not(const bit_not&) {} + }; + + // Generalized Identity Operations + template struct identity : unary_function + { + __device__ __forceinline__ typename TypeTraits::ParameterType operator()(typename TypeTraits::ParameterType x) const + { + return x; + } + __host__ __device__ __forceinline__ identity() {} + __host__ __device__ __forceinline__ identity(const identity&) {} + }; + + template struct project1st : binary_function + { + __device__ __forceinline__ typename TypeTraits::ParameterType operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return lhs; + } + __host__ __device__ __forceinline__ project1st() {} + __host__ __device__ __forceinline__ project1st(const project1st&) {} + }; + + template struct project2nd : binary_function + { + __device__ __forceinline__ typename TypeTraits::ParameterType operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return rhs; + } + __host__ __device__ __forceinline__ project2nd() {} + __host__ __device__ __forceinline__ project2nd(const project2nd&) {} + }; + + // Min/Max Operations + +#define OPENCV_CUDA_IMPLEMENT_MINMAX(name, type, op) \ + template <> struct name : binary_function \ + { \ + __device__ __forceinline__ type operator()(type lhs, type rhs) const {return op(lhs, rhs);} \ + __host__ __device__ __forceinline__ name() {}\ + __host__ __device__ __forceinline__ name(const name&) {}\ + }; + + template struct maximum : binary_function + { + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return max(lhs, rhs); + } + __host__ __device__ __forceinline__ maximum() {} + __host__ __device__ __forceinline__ maximum(const maximum&) {} + }; + + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, uchar, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, schar, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, char, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, ushort, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, short, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, int, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, uint, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, float, ::fmax) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, double, ::fmax) + + template struct minimum : binary_function + { + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return min(lhs, rhs); + } + __host__ __device__ __forceinline__ minimum() {} + __host__ __device__ __forceinline__ minimum(const minimum&) {} + }; + + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, uchar, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, schar, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, char, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, ushort, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, short, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, int, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, uint, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, float, ::fmin) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, double, ::fmin) + +#undef OPENCV_CUDA_IMPLEMENT_MINMAX + + // Math functions + + template struct abs_func : unary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType x) const + { + return abs(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ unsigned char operator ()(unsigned char x) const + { + return x; + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ signed char operator ()(signed char x) const + { + return ::abs((int)x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ char operator ()(char x) const + { + return ::abs((int)x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ unsigned short operator ()(unsigned short x) const + { + return x; + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ short operator ()(short x) const + { + return ::abs((int)x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ unsigned int operator ()(unsigned int x) const + { + return x; + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ int operator ()(int x) const + { + return ::abs(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ float operator ()(float x) const + { + return ::fabsf(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ double operator ()(double x) const + { + return ::fabs(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + +#define OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(name, func) \ + template struct name ## _func : unary_function \ + { \ + __device__ __forceinline__ float operator ()(typename TypeTraits::ParameterType v) const \ + { \ + return func ## f(v); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; \ + template <> struct name ## _func : unary_function \ + { \ + __device__ __forceinline__ double operator ()(double v) const \ + { \ + return func(v); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; + +#define OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(name, func) \ + template struct name ## _func : binary_function \ + { \ + __device__ __forceinline__ float operator ()(typename TypeTraits::ParameterType v1, typename TypeTraits::ParameterType v2) const \ + { \ + return func ## f(v1, v2); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; \ + template <> struct name ## _func : binary_function \ + { \ + __device__ __forceinline__ double operator ()(double v1, double v2) const \ + { \ + return func(v1, v2); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; + + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sqrt, ::sqrt) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp, ::exp) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp2, ::exp2) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp10, ::exp10) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log, ::log) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log2, ::log2) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log10, ::log10) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sin, ::sin) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(cos, ::cos) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(tan, ::tan) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(asin, ::asin) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(acos, ::acos) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(atan, ::atan) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sinh, ::sinh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(cosh, ::cosh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(tanh, ::tanh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(asinh, ::asinh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(acosh, ::acosh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(atanh, ::atanh) + + OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(hypot, ::hypot) + OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(atan2, ::atan2) + OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(pow, ::pow) + + #undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR + #undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR_NO_DOUBLE + #undef OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR + + template struct hypot_sqr_func : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType src1, typename TypeTraits::ParameterType src2) const + { + return src1 * src1 + src2 * src2; + } + __host__ __device__ __forceinline__ hypot_sqr_func() {} + __host__ __device__ __forceinline__ hypot_sqr_func(const hypot_sqr_func&) {} + }; + + // Saturate Cast Functor + template struct saturate_cast_func : unary_function + { + __device__ __forceinline__ D operator ()(typename TypeTraits::ParameterType v) const + { + return saturate_cast(v); + } + __host__ __device__ __forceinline__ saturate_cast_func() {} + __host__ __device__ __forceinline__ saturate_cast_func(const saturate_cast_func&) {} + }; + + // Threshold Functors + template struct thresh_binary_func : unary_function + { + __host__ __device__ __forceinline__ thresh_binary_func(T thresh_, T maxVal_) : thresh(thresh_), maxVal(maxVal_) {} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src > thresh) * maxVal; + } + + __host__ __device__ __forceinline__ thresh_binary_func() {} + __host__ __device__ __forceinline__ thresh_binary_func(const thresh_binary_func& other) + : thresh(other.thresh), maxVal(other.maxVal) {} + + T thresh; + T maxVal; + }; + + template struct thresh_binary_inv_func : unary_function + { + __host__ __device__ __forceinline__ thresh_binary_inv_func(T thresh_, T maxVal_) : thresh(thresh_), maxVal(maxVal_) {} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src <= thresh) * maxVal; + } + + __host__ __device__ __forceinline__ thresh_binary_inv_func() {} + __host__ __device__ __forceinline__ thresh_binary_inv_func(const thresh_binary_inv_func& other) + : thresh(other.thresh), maxVal(other.maxVal) {} + + T thresh; + T maxVal; + }; + + template struct thresh_trunc_func : unary_function + { + explicit __host__ __device__ __forceinline__ thresh_trunc_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return minimum()(src, thresh); + } + + __host__ __device__ __forceinline__ thresh_trunc_func() {} + __host__ __device__ __forceinline__ thresh_trunc_func(const thresh_trunc_func& other) + : thresh(other.thresh) {} + + T thresh; + }; + + template struct thresh_to_zero_func : unary_function + { + explicit __host__ __device__ __forceinline__ thresh_to_zero_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src > thresh) * src; + } + + __host__ __device__ __forceinline__ thresh_to_zero_func() {} + __host__ __device__ __forceinline__ thresh_to_zero_func(const thresh_to_zero_func& other) + : thresh(other.thresh) {} + + T thresh; + }; + + template struct thresh_to_zero_inv_func : unary_function + { + explicit __host__ __device__ __forceinline__ thresh_to_zero_inv_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src <= thresh) * src; + } + + __host__ __device__ __forceinline__ thresh_to_zero_inv_func() {} + __host__ __device__ __forceinline__ thresh_to_zero_inv_func(const thresh_to_zero_inv_func& other) + : thresh(other.thresh) {} + + T thresh; + }; + + // Function Object Adaptors + template struct unary_negate : unary_function + { + explicit __host__ __device__ __forceinline__ unary_negate(const Predicate& p) : pred(p) {} + + __device__ __forceinline__ bool operator()(typename TypeTraits::ParameterType x) const + { + return !pred(x); + } + + __host__ __device__ __forceinline__ unary_negate() {} + __host__ __device__ __forceinline__ unary_negate(const unary_negate& other) : pred(other.pred) {} + + Predicate pred; + }; + + template __host__ __device__ __forceinline__ unary_negate not1(const Predicate& pred) + { + return unary_negate(pred); + } + + template struct binary_negate : binary_function + { + explicit __host__ __device__ __forceinline__ binary_negate(const Predicate& p) : pred(p) {} + + __device__ __forceinline__ bool operator()(typename TypeTraits::ParameterType x, + typename TypeTraits::ParameterType y) const + { + return !pred(x,y); + } + + __host__ __device__ __forceinline__ binary_negate() {} + __host__ __device__ __forceinline__ binary_negate(const binary_negate& other) : pred(other.pred) {} + + Predicate pred; + }; + + template __host__ __device__ __forceinline__ binary_negate not2(const BinaryPredicate& pred) + { + return binary_negate(pred); + } + + template struct binder1st : unary_function + { + __host__ __device__ __forceinline__ binder1st(const Op& op_, const typename Op::first_argument_type& arg1_) : op(op_), arg1(arg1_) {} + + __device__ __forceinline__ typename Op::result_type operator ()(typename TypeTraits::ParameterType a) const + { + return op(arg1, a); + } + + __host__ __device__ __forceinline__ binder1st() {} + __host__ __device__ __forceinline__ binder1st(const binder1st& other) : op(other.op), arg1(other.arg1) {} + + Op op; + typename Op::first_argument_type arg1; + }; + + template __host__ __device__ __forceinline__ binder1st bind1st(const Op& op, const T& x) + { + return binder1st(op, typename Op::first_argument_type(x)); + } + + template struct binder2nd : unary_function + { + __host__ __device__ __forceinline__ binder2nd(const Op& op_, const typename Op::second_argument_type& arg2_) : op(op_), arg2(arg2_) {} + + __forceinline__ __device__ typename Op::result_type operator ()(typename TypeTraits::ParameterType a) const + { + return op(a, arg2); + } + + __host__ __device__ __forceinline__ binder2nd() {} + __host__ __device__ __forceinline__ binder2nd(const binder2nd& other) : op(other.op), arg2(other.arg2) {} + + Op op; + typename Op::second_argument_type arg2; + }; + + template __host__ __device__ __forceinline__ binder2nd bind2nd(const Op& op, const T& x) + { + return binder2nd(op, typename Op::second_argument_type(x)); + } + + // Functor Traits + template struct IsUnaryFunction + { + typedef char Yes; + struct No {Yes a[2];}; + + template static Yes check(unary_function); + static No check(...); + + static F makeF(); + + enum { value = (sizeof(check(makeF())) == sizeof(Yes)) }; + }; + + template struct IsBinaryFunction + { + typedef char Yes; + struct No {Yes a[2];}; + + template static Yes check(binary_function); + static No check(...); + + static F makeF(); + + enum { value = (sizeof(check(makeF())) == sizeof(Yes)) }; + }; + + namespace functional_detail + { + template struct UnOpShift { enum { shift = 1 }; }; + template struct UnOpShift { enum { shift = 4 }; }; + template struct UnOpShift { enum { shift = 2 }; }; + + template struct DefaultUnaryShift + { + enum { shift = UnOpShift::shift }; + }; + + template struct BinOpShift { enum { shift = 1 }; }; + template struct BinOpShift { enum { shift = 4 }; }; + template struct BinOpShift { enum { shift = 2 }; }; + + template struct DefaultBinaryShift + { + enum { shift = BinOpShift::shift }; + }; + + template ::value> struct ShiftDispatcher; + template struct ShiftDispatcher + { + enum { shift = DefaultUnaryShift::shift }; + }; + template struct ShiftDispatcher + { + enum { shift = DefaultBinaryShift::shift }; + }; + } + + template struct DefaultTransformShift + { + enum { shift = functional_detail::ShiftDispatcher::shift }; + }; + + template struct DefaultTransformFunctorTraits + { + enum { simple_block_dim_x = 16 }; + enum { simple_block_dim_y = 16 }; + + enum { smart_block_dim_x = 16 }; + enum { smart_block_dim_y = 16 }; + enum { smart_shift = DefaultTransformShift::shift }; + }; + + template struct TransformFunctorTraits : DefaultTransformFunctorTraits {}; + +#define OPENCV_CUDA_TRANSFORM_FUNCTOR_TRAITS(type) \ + template <> struct TransformFunctorTraits< type > : DefaultTransformFunctorTraits< type > +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_FUNCTIONAL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/limits.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/limits.hpp new file mode 100644 index 0000000..7e15ed6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/limits.hpp @@ -0,0 +1,128 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_LIMITS_HPP +#define OPENCV_CUDA_LIMITS_HPP + +#include +#include +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ +template struct numeric_limits; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static bool min() { return false; } + __device__ __forceinline__ static bool max() { return true; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static signed char min() { return SCHAR_MIN; } + __device__ __forceinline__ static signed char max() { return SCHAR_MAX; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static unsigned char min() { return 0; } + __device__ __forceinline__ static unsigned char max() { return UCHAR_MAX; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static short min() { return SHRT_MIN; } + __device__ __forceinline__ static short max() { return SHRT_MAX; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static unsigned short min() { return 0; } + __device__ __forceinline__ static unsigned short max() { return USHRT_MAX; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static int min() { return INT_MIN; } + __device__ __forceinline__ static int max() { return INT_MAX; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static unsigned int min() { return 0; } + __device__ __forceinline__ static unsigned int max() { return UINT_MAX; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static float min() { return FLT_MIN; } + __device__ __forceinline__ static float max() { return FLT_MAX; } + __device__ __forceinline__ static float epsilon() { return FLT_EPSILON; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static double min() { return DBL_MIN; } + __device__ __forceinline__ static double max() { return DBL_MAX; } + __device__ __forceinline__ static double epsilon() { return DBL_EPSILON; } + static const bool is_signed = true; +}; +}}} // namespace cv { namespace cuda { namespace cudev { + +//! @endcond + +#endif // OPENCV_CUDA_LIMITS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/reduce.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/reduce.hpp new file mode 100644 index 0000000..5de3650 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/reduce.hpp @@ -0,0 +1,209 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_REDUCE_HPP +#define OPENCV_CUDA_REDUCE_HPP + +#ifndef THRUST_DEBUG // eliminate -Wundef warning +#define THRUST_DEBUG 0 +#endif + +#include +#include "detail/reduce.hpp" +#include "detail/reduce_key_val.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + __device__ __forceinline__ void reduce(volatile T* smem, T& val, unsigned int tid, const Op& op) + { + reduce_detail::Dispatcher::reductor::template reduce(smem, val, tid, op); + } + template + __device__ __forceinline__ void reduce(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid, + const thrust::tuple& op) + { + reduce_detail::Dispatcher::reductor::template reduce< + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple&>(smem, val, tid, op); + } + + template + __device__ __forceinline__ void reduceKeyVal(volatile K* skeys, K& key, volatile V* svals, V& val, unsigned int tid, const Cmp& cmp) + { + reduce_key_val_detail::Dispatcher::reductor::template reduce(skeys, key, svals, val, tid, cmp); + } + template + __device__ __forceinline__ void reduceKeyVal(volatile K* skeys, K& key, + const thrust::tuple& svals, + const thrust::tuple& val, + unsigned int tid, const Cmp& cmp) + { + reduce_key_val_detail::Dispatcher::reductor::template reduce&, + const thrust::tuple&, + const Cmp&>(skeys, key, svals, val, tid, cmp); + } + template + __device__ __forceinline__ void reduceKeyVal(const thrust::tuple& skeys, + const thrust::tuple& key, + const thrust::tuple& svals, + const thrust::tuple& val, + unsigned int tid, + const thrust::tuple& cmp) + { + reduce_key_val_detail::Dispatcher::reductor::template reduce< + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple& + >(skeys, key, svals, val, tid, cmp); + } + + // smem_tuple + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0) + { + return thrust::make_tuple((volatile T0*) t0); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6, (volatile T7*) t7); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7, T8* t8) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6, (volatile T7*) t7, (volatile T8*) t8); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7, T8* t8, T9* t9) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6, (volatile T7*) t7, (volatile T8*) t8, (volatile T9*) t9); + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_REDUCE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/saturate_cast.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/saturate_cast.hpp new file mode 100644 index 0000000..c3a3d1c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/saturate_cast.hpp @@ -0,0 +1,292 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_SATURATE_CAST_HPP +#define OPENCV_CUDA_SATURATE_CAST_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template __device__ __forceinline__ _Tp saturate_cast(uchar v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(schar v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(ushort v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(short v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(uint v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(int v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(float v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(double v) { return _Tp(v); } + + template<> __device__ __forceinline__ uchar saturate_cast(schar v) + { + uint res = 0; + int vi = v; + asm("cvt.sat.u8.s8 %0, %1;" : "=r"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(short v) + { + uint res = 0; + asm("cvt.sat.u8.s16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(ushort v) + { + uint res = 0; + asm("cvt.sat.u8.u16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(int v) + { + uint res = 0; + asm("cvt.sat.u8.s32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(uint v) + { + uint res = 0; + asm("cvt.sat.u8.u32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(float v) + { + uint res = 0; + asm("cvt.rni.sat.u8.f32 %0, %1;" : "=r"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + uint res = 0; + asm("cvt.rni.sat.u8.f64 %0, %1;" : "=r"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ schar saturate_cast(uchar v) + { + uint res = 0; + uint vi = v; + asm("cvt.sat.s8.u8 %0, %1;" : "=r"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(short v) + { + uint res = 0; + asm("cvt.sat.s8.s16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(ushort v) + { + uint res = 0; + asm("cvt.sat.s8.u16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(int v) + { + uint res = 0; + asm("cvt.sat.s8.s32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(uint v) + { + uint res = 0; + asm("cvt.sat.s8.u32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(float v) + { + uint res = 0; + asm("cvt.rni.sat.s8.f32 %0, %1;" : "=r"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + uint res = 0; + asm("cvt.rni.sat.s8.f64 %0, %1;" : "=r"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ ushort saturate_cast(schar v) + { + ushort res = 0; + int vi = v; + asm("cvt.sat.u16.s8 %0, %1;" : "=h"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(short v) + { + ushort res = 0; + asm("cvt.sat.u16.s16 %0, %1;" : "=h"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(int v) + { + ushort res = 0; + asm("cvt.sat.u16.s32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(uint v) + { + ushort res = 0; + asm("cvt.sat.u16.u32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(float v) + { + ushort res = 0; + asm("cvt.rni.sat.u16.f32 %0, %1;" : "=h"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + ushort res = 0; + asm("cvt.rni.sat.u16.f64 %0, %1;" : "=h"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ short saturate_cast(ushort v) + { + short res = 0; + asm("cvt.sat.s16.u16 %0, %1;" : "=h"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(int v) + { + short res = 0; + asm("cvt.sat.s16.s32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(uint v) + { + short res = 0; + asm("cvt.sat.s16.u32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(float v) + { + short res = 0; + asm("cvt.rni.sat.s16.f32 %0, %1;" : "=h"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + short res = 0; + asm("cvt.rni.sat.s16.f64 %0, %1;" : "=h"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ int saturate_cast(uint v) + { + int res = 0; + asm("cvt.sat.s32.u32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ int saturate_cast(float v) + { + return __float2int_rn(v); + } + template<> __device__ __forceinline__ int saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + return __double2int_rn(v); + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ uint saturate_cast(schar v) + { + uint res = 0; + int vi = v; + asm("cvt.sat.u32.s8 %0, %1;" : "=r"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ uint saturate_cast(short v) + { + uint res = 0; + asm("cvt.sat.u32.s16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ uint saturate_cast(int v) + { + uint res = 0; + asm("cvt.sat.u32.s32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ uint saturate_cast(float v) + { + return __float2uint_rn(v); + } + template<> __device__ __forceinline__ uint saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + return __double2uint_rn(v); + #else + return saturate_cast((float)v); + #endif + } +}}} + +//! @endcond + +#endif /* OPENCV_CUDA_SATURATE_CAST_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/scan.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/scan.hpp new file mode 100644 index 0000000..e128fb0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/scan.hpp @@ -0,0 +1,258 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_SCAN_HPP +#define OPENCV_CUDA_SCAN_HPP + +#include "opencv2/core/cuda/common.hpp" +#include "opencv2/core/cuda/utility.hpp" +#include "opencv2/core/cuda/warp.hpp" +#include "opencv2/core/cuda/warp_shuffle.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + enum ScanKind { EXCLUSIVE = 0, INCLUSIVE = 1 }; + + template struct WarpScan + { + __device__ __forceinline__ WarpScan() {} + __device__ __forceinline__ WarpScan(const WarpScan& other) { CV_UNUSED(other); } + + __device__ __forceinline__ T operator()( volatile T *ptr , const unsigned int idx) + { + const unsigned int lane = idx & 31; + F op; + + if ( lane >= 1) ptr [idx ] = op(ptr [idx - 1], ptr [idx]); + if ( lane >= 2) ptr [idx ] = op(ptr [idx - 2], ptr [idx]); + if ( lane >= 4) ptr [idx ] = op(ptr [idx - 4], ptr [idx]); + if ( lane >= 8) ptr [idx ] = op(ptr [idx - 8], ptr [idx]); + if ( lane >= 16) ptr [idx ] = op(ptr [idx - 16], ptr [idx]); + + if( Kind == INCLUSIVE ) + return ptr [idx]; + else + return (lane > 0) ? ptr [idx - 1] : 0; + } + + __device__ __forceinline__ unsigned int index(const unsigned int tid) + { + return tid; + } + + __device__ __forceinline__ void init(volatile T *ptr){} + + static const int warp_offset = 0; + + typedef WarpScan merge; + }; + + template struct WarpScanNoComp + { + __device__ __forceinline__ WarpScanNoComp() {} + __device__ __forceinline__ WarpScanNoComp(const WarpScanNoComp& other) { CV_UNUSED(other); } + + __device__ __forceinline__ T operator()( volatile T *ptr , const unsigned int idx) + { + const unsigned int lane = threadIdx.x & 31; + F op; + + ptr [idx ] = op(ptr [idx - 1], ptr [idx]); + ptr [idx ] = op(ptr [idx - 2], ptr [idx]); + ptr [idx ] = op(ptr [idx - 4], ptr [idx]); + ptr [idx ] = op(ptr [idx - 8], ptr [idx]); + ptr [idx ] = op(ptr [idx - 16], ptr [idx]); + + if( Kind == INCLUSIVE ) + return ptr [idx]; + else + return (lane > 0) ? ptr [idx - 1] : 0; + } + + __device__ __forceinline__ unsigned int index(const unsigned int tid) + { + return (tid >> warp_log) * warp_smem_stride + 16 + (tid & warp_mask); + } + + __device__ __forceinline__ void init(volatile T *ptr) + { + ptr[threadIdx.x] = 0; + } + + static const int warp_smem_stride = 32 + 16 + 1; + static const int warp_offset = 16; + static const int warp_log = 5; + static const int warp_mask = 31; + + typedef WarpScanNoComp merge; + }; + + template struct BlockScan + { + __device__ __forceinline__ BlockScan() {} + __device__ __forceinline__ BlockScan(const BlockScan& other) { CV_UNUSED(other); } + + __device__ __forceinline__ T operator()(volatile T *ptr) + { + const unsigned int tid = threadIdx.x; + const unsigned int lane = tid & warp_mask; + const unsigned int warp = tid >> warp_log; + + Sc scan; + typename Sc::merge merge_scan; + const unsigned int idx = scan.index(tid); + + T val = scan(ptr, idx); + __syncthreads (); + + if( warp == 0) + scan.init(ptr); + __syncthreads (); + + if( lane == 31 ) + ptr [scan.warp_offset + warp ] = (Kind == INCLUSIVE) ? val : ptr [idx]; + __syncthreads (); + + if( warp == 0 ) + merge_scan(ptr, idx); + __syncthreads(); + + if ( warp > 0) + val = ptr [scan.warp_offset + warp - 1] + val; + __syncthreads (); + + ptr[idx] = val; + __syncthreads (); + + return val ; + } + + static const int warp_log = 5; + static const int warp_mask = 31; + }; + + template + __device__ T warpScanInclusive(T idata, volatile T* s_Data, unsigned int tid) + { + #if __CUDA_ARCH__ >= 300 + const unsigned int laneId = cv::cuda::device::Warp::laneId(); + + // scan on shuffl functions + #pragma unroll + for (int i = 1; i <= (OPENCV_CUDA_WARP_SIZE / 2); i *= 2) + { + const T n = cv::cuda::device::shfl_up(idata, i); + if (laneId >= i) + idata += n; + } + + return idata; + #else + unsigned int pos = 2 * tid - (tid & (OPENCV_CUDA_WARP_SIZE - 1)); + s_Data[pos] = 0; + pos += OPENCV_CUDA_WARP_SIZE; + s_Data[pos] = idata; + + s_Data[pos] += s_Data[pos - 1]; + s_Data[pos] += s_Data[pos - 2]; + s_Data[pos] += s_Data[pos - 4]; + s_Data[pos] += s_Data[pos - 8]; + s_Data[pos] += s_Data[pos - 16]; + + return s_Data[pos]; + #endif + } + + template + __device__ __forceinline__ T warpScanExclusive(T idata, volatile T* s_Data, unsigned int tid) + { + return warpScanInclusive(idata, s_Data, tid) - idata; + } + + template + __device__ T blockScanInclusive(T idata, volatile T* s_Data, unsigned int tid) + { + if (tiNumScanThreads > OPENCV_CUDA_WARP_SIZE) + { + //Bottom-level inclusive warp scan + T warpResult = warpScanInclusive(idata, s_Data, tid); + + //Save top elements of each warp for exclusive warp scan + //sync to wait for warp scans to complete (because s_Data is being overwritten) + __syncthreads(); + if ((tid & (OPENCV_CUDA_WARP_SIZE - 1)) == (OPENCV_CUDA_WARP_SIZE - 1)) + { + s_Data[tid >> OPENCV_CUDA_LOG_WARP_SIZE] = warpResult; + } + + //wait for warp scans to complete + __syncthreads(); + + if (tid < (tiNumScanThreads / OPENCV_CUDA_WARP_SIZE) ) + { + //grab top warp elements + T val = s_Data[tid]; + //calculate exclusive scan and write back to shared memory + s_Data[tid] = warpScanExclusive(val, s_Data, tid); + } + + //return updated warp scans with exclusive scan results + __syncthreads(); + + return warpResult + s_Data[tid >> OPENCV_CUDA_LOG_WARP_SIZE]; + } + else + { + return warpScanInclusive(idata, s_Data, tid); + } + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_SCAN_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/simd_functions.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/simd_functions.hpp new file mode 100644 index 0000000..3d8c2e0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/simd_functions.hpp @@ -0,0 +1,869 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +/* + * Copyright (c) 2013 NVIDIA Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of NVIDIA Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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 OPENCV_CUDA_SIMD_FUNCTIONS_HPP +#define OPENCV_CUDA_SIMD_FUNCTIONS_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + // 2 + + static __device__ __forceinline__ unsigned int vadd2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vadd2.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vadd.u32.u32.u32.sat %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = a ^ b; // sum bits + r = a + b; // actual sum + s = s ^ r; // determine carry-ins for each bit position + s = s & 0x00010000; // carry-in to high word (= carry-out from low word) + r = r - s; // subtract out carry-out from low word + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsub2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vsub2.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vsub.u32.u32.u32.sat %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = a ^ b; // sum bits + r = a - b; // actual sum + s = s ^ r; // determine carry-ins for each bit position + s = s & 0x00010000; // borrow to high word + r = r + s; // compensate for borrow from low word + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vabsdiff2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vabsdiff2.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vabsdiff.u32.u32.u32.sat %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t, u, v; + s = a & 0x0000ffff; // extract low halfword + r = b & 0x0000ffff; // extract low halfword + u = ::max(r, s); // maximum of low halfwords + v = ::min(r, s); // minimum of low halfwords + s = a & 0xffff0000; // extract high halfword + r = b & 0xffff0000; // extract high halfword + t = ::max(r, s); // maximum of high halfwords + s = ::min(r, s); // minimum of high halfwords + r = u | t; // maximum of both halfwords + s = v | s; // minimum of both halfwords + r = r - s; // |a - b| = max(a,b) - min(a,b); + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vavg2(unsigned int a, unsigned int b) + { + unsigned int r, s; + + // HAKMEM #23: a + b = 2 * (a & b) + (a ^ b) ==> + // (a + b) / 2 = (a & b) + ((a ^ b) >> 1) + s = a ^ b; + r = a & b; + s = s & 0xfffefffe; // ensure shift doesn't cross halfword boundaries + s = s >> 1; + s = r + s; + + return s; + } + + static __device__ __forceinline__ unsigned int vavrg2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vavrg2.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // HAKMEM #23: a + b = 2 * (a | b) - (a ^ b) ==> + // (a + b + 1) / 2 = (a | b) - ((a ^ b) >> 1) + unsigned int s; + s = a ^ b; + r = a | b; + s = s & 0xfffefffe; // ensure shift doesn't cross half-word boundaries + s = s >> 1; + r = r - s; + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vseteq2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.eq %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + r = r ^ c; // extract msbs, msb = 1 if r < 0x8000 + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r & ~c; // msb = 1, if r was 0x0000 + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpeq2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vseteq2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + r = r ^ c; // extract msbs, msb = 1 if r < 0x8000 + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r & ~c; // msb = 1, if r was 0x0000 + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetge2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.ge %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavrg2(a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpge2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetge2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavrg2(a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetgt2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.gt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg2(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80008000; // msbs = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpgt2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetgt2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg2(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80008000; // msbs = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetle2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.le %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg2(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmple2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetle2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg2(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetlt2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.lt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg2(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmplt2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetlt2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg2(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetne2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm ("vset2.u32.u32.ne %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r | c; // msb = 1, if r was not 0x0000 + c = c & 0x80008000; // extract msbs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpne2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetne2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r | c; // msb = 1, if r was not 0x0000 + c = c & 0x80008000; // extract msbs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vmax2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmax2.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmax.u32.u32.u32 %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t, u; + r = a & 0x0000ffff; // extract low halfword + s = b & 0x0000ffff; // extract low halfword + t = ::max(r, s); // maximum of low halfwords + r = a & 0xffff0000; // extract high halfword + s = b & 0xffff0000; // extract high halfword + u = ::max(r, s); // maximum of high halfwords + r = t | u; // combine halfword maximums + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vmin2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmin2.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmin.u32.u32.u32 %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t, u; + r = a & 0x0000ffff; // extract low halfword + s = b & 0x0000ffff; // extract low halfword + t = ::min(r, s); // minimum of low halfwords + r = a & 0xffff0000; // extract high halfword + s = b & 0xffff0000; // extract high halfword + u = ::min(r, s); // minimum of high halfwords + r = t | u; // combine halfword minimums + #endif + + return r; + } + + // 4 + + static __device__ __forceinline__ unsigned int vadd4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vadd4.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vadd.u32.u32.u32.sat %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t; + s = a ^ b; // sum bits + r = a & 0x7f7f7f7f; // clear msbs + t = b & 0x7f7f7f7f; // clear msbs + s = s & 0x80808080; // msb sum bits + r = r + t; // add without msbs, record carry-out in msbs + r = r ^ s; // sum of msb sum and carry-in bits, w/o carry-out + #endif /* __CUDA_ARCH__ >= 300 */ + + return r; + } + + static __device__ __forceinline__ unsigned int vsub4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vsub4.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vsub.u32.u32.u32.sat %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t; + s = a ^ ~b; // inverted sum bits + r = a | 0x80808080; // set msbs + t = b & 0x7f7f7f7f; // clear msbs + s = s & 0x80808080; // inverted msb sum bits + r = r - t; // subtract w/o msbs, record inverted borrows in msb + r = r ^ s; // combine inverted msb sum bits and borrows + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vavg4(unsigned int a, unsigned int b) + { + unsigned int r, s; + + // HAKMEM #23: a + b = 2 * (a & b) + (a ^ b) ==> + // (a + b) / 2 = (a & b) + ((a ^ b) >> 1) + s = a ^ b; + r = a & b; + s = s & 0xfefefefe; // ensure following shift doesn't cross byte boundaries + s = s >> 1; + s = r + s; + + return s; + } + + static __device__ __forceinline__ unsigned int vavrg4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vavrg4.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // HAKMEM #23: a + b = 2 * (a | b) - (a ^ b) ==> + // (a + b + 1) / 2 = (a | b) - ((a ^ b) >> 1) + unsigned int c; + c = a ^ b; + r = a | b; + c = c & 0xfefefefe; // ensure following shift doesn't cross byte boundaries + c = c >> 1; + r = r - c; + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vseteq4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.eq %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x00 if a == b + c = r | 0x80808080; // set msbs, to catch carry out + r = r ^ c; // extract msbs, msb = 1 if r < 0x80 + c = c - 0x01010101; // msb = 0, if r was 0x00 or 0x80 + c = r & ~c; // msb = 1, if r was 0x00 + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpeq4(unsigned int a, unsigned int b) + { + unsigned int r, t; + + #if __CUDA_ARCH__ >= 300 + r = vseteq4(a, b); + t = r << 8; // convert bool + r = t - r; // to mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + t = a ^ b; // 0x00 if a == b + r = t | 0x80808080; // set msbs, to catch carry out + t = t ^ r; // extract msbs, msb = 1 if t < 0x80 + r = r - 0x01010101; // msb = 0, if t was 0x00 or 0x80 + r = t & ~r; // msb = 1, if t was 0x00 + t = r >> 7; // build mask + t = r - t; // from + r = t | r; // msbs + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetle4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.le %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg4(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmple4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetle4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg4(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80808080; // msbs = carry-outs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetlt4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.lt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg4(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmplt4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetlt4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg4(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80808080; // msbs = carry-outs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetge4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.ge %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavrg4(a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpge4(unsigned int a, unsigned int b) + { + unsigned int r, s; + + #if __CUDA_ARCH__ >= 300 + r = vsetge4(a, b); + s = r << 8; // convert bool + r = s - r; // to mask + #else + asm ("not.b32 %0,%0;" : "+r"(b)); + r = vavrg4 (a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + r = r & 0x80808080; // msb = carry-outs + s = r >> 7; // build mask + s = r - s; // from + r = s | r; // msbs + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetgt4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.gt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg4(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpgt4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetgt4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg4(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetne4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.ne %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x00 if a == b + c = r | 0x80808080; // set msbs, to catch carry out + c = c - 0x01010101; // msb = 0, if r was 0x00 or 0x80 + c = r | c; // msb = 1, if r was not 0x00 + c = c & 0x80808080; // extract msbs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpne4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetne4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + r = a ^ b; // 0x00 if a == b + c = r | 0x80808080; // set msbs, to catch carry out + c = c - 0x01010101; // msb = 0, if r was 0x00 or 0x80 + c = r | c; // msb = 1, if r was not 0x00 + c = c & 0x80808080; // extract msbs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vabsdiff4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vabsdiff4.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vabsdiff.u32.u32.u32.sat %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = vcmpge4(a, b); // mask = 0xff if a >= b + r = a ^ b; // + s = (r & s) ^ b; // select a when a >= b, else select b => max(a,b) + r = s ^ r; // select a when b >= a, else select b => min(a,b) + r = s - r; // |a - b| = max(a,b) - min(a,b); + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vmax4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmax4.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmax.u32.u32.u32 %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = vcmpge4(a, b); // mask = 0xff if a >= b + r = a & s; // select a when b >= a + s = b & ~s; // select b when b < a + r = r | s; // combine byte selections + #endif + + return r; // byte-wise unsigned maximum + } + + static __device__ __forceinline__ unsigned int vmin4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmin4.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmin.u32.u32.u32 %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = vcmpge4(b, a); // mask = 0xff if a >= b + r = a & s; // select a when b >= a + s = b & ~s; // select b when b < a + r = r | s; // combine byte selections + #endif + + return r; + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_SIMD_FUNCTIONS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/transform.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/transform.hpp new file mode 100644 index 0000000..42aa6ea --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/transform.hpp @@ -0,0 +1,75 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TRANSFORM_HPP +#define OPENCV_CUDA_TRANSFORM_HPP + +#include "common.hpp" +#include "utility.hpp" +#include "detail/transform_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + static inline void transform(PtrStepSz src, PtrStepSz dst, UnOp op, const Mask& mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + transform_detail::TransformDispatcher::cn == 1 && VecTraits::cn == 1 && ft::smart_shift != 1>::call(src, dst, op, mask, stream); + } + + template + static inline void transform(PtrStepSz src1, PtrStepSz src2, PtrStepSz dst, BinOp op, const Mask& mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + transform_detail::TransformDispatcher::cn == 1 && VecTraits::cn == 1 && VecTraits::cn == 1 && ft::smart_shift != 1>::call(src1, src2, dst, op, mask, stream); + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_TRANSFORM_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/type_traits.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/type_traits.hpp new file mode 100644 index 0000000..8b7a3fd --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/type_traits.hpp @@ -0,0 +1,90 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TYPE_TRAITS_HPP +#define OPENCV_CUDA_TYPE_TRAITS_HPP + +#include "detail/type_traits_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct IsSimpleParameter + { + enum {value = type_traits_detail::IsIntegral::value || type_traits_detail::IsFloat::value || + type_traits_detail::PointerTraits::type>::value}; + }; + + template struct TypeTraits + { + typedef typename type_traits_detail::UnConst::type NonConstType; + typedef typename type_traits_detail::UnVolatile::type NonVolatileType; + typedef typename type_traits_detail::UnVolatile::type>::type UnqualifiedType; + typedef typename type_traits_detail::PointerTraits::type PointeeType; + typedef typename type_traits_detail::ReferenceTraits::type ReferredType; + + enum { isConst = type_traits_detail::UnConst::value }; + enum { isVolatile = type_traits_detail::UnVolatile::value }; + + enum { isReference = type_traits_detail::ReferenceTraits::value }; + enum { isPointer = type_traits_detail::PointerTraits::type>::value }; + + enum { isUnsignedInt = type_traits_detail::IsUnsignedIntegral::value }; + enum { isSignedInt = type_traits_detail::IsSignedIntergral::value }; + enum { isIntegral = type_traits_detail::IsIntegral::value }; + enum { isFloat = type_traits_detail::IsFloat::value }; + enum { isArith = isIntegral || isFloat }; + enum { isVec = type_traits_detail::IsVec::value }; + + typedef typename type_traits_detail::Select::value, + T, typename type_traits_detail::AddParameterType::type>::type ParameterType; + }; +}}} + +//! @endcond + +#endif // OPENCV_CUDA_TYPE_TRAITS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/utility.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/utility.hpp new file mode 100644 index 0000000..7f5db48 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/utility.hpp @@ -0,0 +1,230 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_UTILITY_HPP +#define OPENCV_CUDA_UTILITY_HPP + +#include "saturate_cast.hpp" +#include "datamov_utils.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct CV_EXPORTS ThrustAllocator + { + typedef uchar value_type; + virtual ~ThrustAllocator(); + virtual __device__ __host__ uchar* allocate(size_t numBytes) = 0; + virtual __device__ __host__ void deallocate(uchar* ptr, size_t numBytes) = 0; + static ThrustAllocator& getAllocator(); + static void setAllocator(ThrustAllocator* allocator); + }; + #define OPENCV_CUDA_LOG_WARP_SIZE (5) + #define OPENCV_CUDA_WARP_SIZE (1 << OPENCV_CUDA_LOG_WARP_SIZE) + #define OPENCV_CUDA_LOG_MEM_BANKS ((__CUDA_ARCH__ >= 200) ? 5 : 4) // 32 banks on fermi, 16 on tesla + #define OPENCV_CUDA_MEM_BANKS (1 << OPENCV_CUDA_LOG_MEM_BANKS) + + /////////////////////////////////////////////////////////////////////////////// + // swap + + template void __device__ __host__ __forceinline__ swap(T& a, T& b) + { + const T temp = a; + a = b; + b = temp; + } + + /////////////////////////////////////////////////////////////////////////////// + // Mask Reader + + struct SingleMask + { + explicit __host__ __device__ __forceinline__ SingleMask(PtrStepb mask_) : mask(mask_) {} + __host__ __device__ __forceinline__ SingleMask(const SingleMask& mask_): mask(mask_.mask){} + + __device__ __forceinline__ bool operator()(int y, int x) const + { + return mask.ptr(y)[x] != 0; + } + + PtrStepb mask; + }; + + struct SingleMaskChannels + { + __host__ __device__ __forceinline__ SingleMaskChannels(PtrStepb mask_, int channels_) + : mask(mask_), channels(channels_) {} + __host__ __device__ __forceinline__ SingleMaskChannels(const SingleMaskChannels& mask_) + :mask(mask_.mask), channels(mask_.channels){} + + __device__ __forceinline__ bool operator()(int y, int x) const + { + return mask.ptr(y)[x / channels] != 0; + } + + PtrStepb mask; + int channels; + }; + + struct MaskCollection + { + explicit __host__ __device__ __forceinline__ MaskCollection(PtrStepb* maskCollection_) + : maskCollection(maskCollection_) {} + + __device__ __forceinline__ MaskCollection(const MaskCollection& masks_) + : maskCollection(masks_.maskCollection), curMask(masks_.curMask){} + + __device__ __forceinline__ void next() + { + curMask = *maskCollection++; + } + __device__ __forceinline__ void setMask(int z) + { + curMask = maskCollection[z]; + } + + __device__ __forceinline__ bool operator()(int y, int x) const + { + uchar val; + return curMask.data == 0 || (ForceGlob::Load(curMask.ptr(y), x, val), (val != 0)); + } + + const PtrStepb* maskCollection; + PtrStepb curMask; + }; + + struct WithOutMask + { + __host__ __device__ __forceinline__ WithOutMask(){} + __host__ __device__ __forceinline__ WithOutMask(const WithOutMask&){} + + __device__ __forceinline__ void next() const + { + } + __device__ __forceinline__ void setMask(int) const + { + } + + __device__ __forceinline__ bool operator()(int, int) const + { + return true; + } + + __device__ __forceinline__ bool operator()(int, int, int) const + { + return true; + } + + static __device__ __forceinline__ bool check(int, int) + { + return true; + } + + static __device__ __forceinline__ bool check(int, int, int) + { + return true; + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // Solve linear system + + // solve 2x2 linear system Ax=b + template __device__ __forceinline__ bool solve2x2(const T A[2][2], const T b[2], T x[2]) + { + T det = A[0][0] * A[1][1] - A[1][0] * A[0][1]; + + if (det != 0) + { + double invdet = 1.0 / det; + + x[0] = saturate_cast(invdet * (b[0] * A[1][1] - b[1] * A[0][1])); + + x[1] = saturate_cast(invdet * (A[0][0] * b[1] - A[1][0] * b[0])); + + return true; + } + + return false; + } + + // solve 3x3 linear system Ax=b + template __device__ __forceinline__ bool solve3x3(const T A[3][3], const T b[3], T x[3]) + { + T det = A[0][0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) + - A[0][1] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) + + A[0][2] * (A[1][0] * A[2][1] - A[1][1] * A[2][0]); + + if (det != 0) + { + double invdet = 1.0 / det; + + x[0] = saturate_cast(invdet * + (b[0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) - + A[0][1] * (b[1] * A[2][2] - A[1][2] * b[2] ) + + A[0][2] * (b[1] * A[2][1] - A[1][1] * b[2] ))); + + x[1] = saturate_cast(invdet * + (A[0][0] * (b[1] * A[2][2] - A[1][2] * b[2] ) - + b[0] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) + + A[0][2] * (A[1][0] * b[2] - b[1] * A[2][0]))); + + x[2] = saturate_cast(invdet * + (A[0][0] * (A[1][1] * b[2] - b[1] * A[2][1]) - + A[0][1] * (A[1][0] * b[2] - b[1] * A[2][0]) + + b[0] * (A[1][0] * A[2][1] - A[1][1] * A[2][0]))); + + return true; + } + + return false; + } +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_UTILITY_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_distance.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_distance.hpp new file mode 100644 index 0000000..ef6e510 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_distance.hpp @@ -0,0 +1,232 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VEC_DISTANCE_HPP +#define OPENCV_CUDA_VEC_DISTANCE_HPP + +#include "reduce.hpp" +#include "functional.hpp" +#include "detail/vec_distance_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct L1Dist + { + typedef int value_type; + typedef int result_type; + + __device__ __forceinline__ L1Dist() : mySum(0) {} + + __device__ __forceinline__ void reduceIter(int val1, int val2) + { + mySum = __sad(val1, val2, mySum); + } + + template __device__ __forceinline__ void reduceAll(int* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator int() const + { + return mySum; + } + + int mySum; + }; + template <> struct L1Dist + { + typedef float value_type; + typedef float result_type; + + __device__ __forceinline__ L1Dist() : mySum(0.0f) {} + + __device__ __forceinline__ void reduceIter(float val1, float val2) + { + mySum += ::fabs(val1 - val2); + } + + template __device__ __forceinline__ void reduceAll(float* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator float() const + { + return mySum; + } + + float mySum; + }; + + struct L2Dist + { + typedef float value_type; + typedef float result_type; + + __device__ __forceinline__ L2Dist() : mySum(0.0f) {} + + __device__ __forceinline__ void reduceIter(float val1, float val2) + { + float reg = val1 - val2; + mySum += reg * reg; + } + + template __device__ __forceinline__ void reduceAll(float* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator float() const + { + return sqrtf(mySum); + } + + float mySum; + }; + + struct HammingDist + { + typedef int value_type; + typedef int result_type; + + __device__ __forceinline__ HammingDist() : mySum(0) {} + + __device__ __forceinline__ void reduceIter(int val1, int val2) + { + mySum += __popc(val1 ^ val2); + } + + template __device__ __forceinline__ void reduceAll(int* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator int() const + { + return mySum; + } + + int mySum; + }; + + // calc distance between two vectors in global memory + template + __device__ void calcVecDiffGlobal(const T1* vec1, const T2* vec2, int len, Dist& dist, typename Dist::result_type* smem, int tid) + { + for (int i = tid; i < len; i += THREAD_DIM) + { + T1 val1; + ForceGlob::Load(vec1, i, val1); + + T2 val2; + ForceGlob::Load(vec2, i, val2); + + dist.reduceIter(val1, val2); + } + + dist.reduceAll(smem, tid); + } + + // calc distance between two vectors, first vector is cached in register or shared memory, second vector is in global memory + template + __device__ __forceinline__ void calcVecDiffCached(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, typename Dist::result_type* smem, int tid) + { + vec_distance_detail::VecDiffCachedCalculator::calc(vecCached, vecGlob, len, dist, tid); + + dist.reduceAll(smem, tid); + } + + // calc distance between two vectors in global memory + template struct VecDiffGlobal + { + explicit __device__ __forceinline__ VecDiffGlobal(const T1* vec1_, int = 0, void* = 0, int = 0, int = 0) + { + vec1 = vec1_; + } + + template + __device__ __forceinline__ void calc(const T2* vec2, int len, Dist& dist, typename Dist::result_type* smem, int tid) const + { + calcVecDiffGlobal(vec1, vec2, len, dist, smem, tid); + } + + const T1* vec1; + }; + + // calc distance between two vectors, first vector is cached in register memory, second vector is in global memory + template struct VecDiffCachedRegister + { + template __device__ __forceinline__ VecDiffCachedRegister(const T1* vec1, int len, U* smem, int glob_tid, int tid) + { + if (glob_tid < len) + smem[glob_tid] = vec1[glob_tid]; + __syncthreads(); + + U* vec1ValsPtr = vec1Vals; + + #pragma unroll + for (int i = tid; i < MAX_LEN; i += THREAD_DIM) + *vec1ValsPtr++ = smem[i]; + + __syncthreads(); + } + + template + __device__ __forceinline__ void calc(const T2* vec2, int len, Dist& dist, typename Dist::result_type* smem, int tid) const + { + calcVecDiffCached(vec1Vals, vec2, len, dist, smem, tid); + } + + U vec1Vals[MAX_LEN / THREAD_DIM]; + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_VEC_DISTANCE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_math.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_math.hpp new file mode 100644 index 0000000..80b1303 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_math.hpp @@ -0,0 +1,923 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VECMATH_HPP +#define OPENCV_CUDA_VECMATH_HPP + +#include "vec_traits.hpp" +#include "saturate_cast.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + +// saturate_cast + +namespace vec_math_detail +{ + template struct SatCastHelper; + template struct SatCastHelper<1, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x)); + } + }; + template struct SatCastHelper<2, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x), saturate_cast(v.y)); + } + }; + template struct SatCastHelper<3, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x), saturate_cast(v.y), saturate_cast(v.z)); + } + }; + template struct SatCastHelper<4, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x), saturate_cast(v.y), saturate_cast(v.z), saturate_cast(v.w)); + } + }; + + template static __device__ __forceinline__ VecD saturate_cast_helper(const VecS& v) + { + return SatCastHelper::cn, VecD>::cast(v); + } +} + +template static __device__ __forceinline__ T saturate_cast(const uchar1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double1& v) {return vec_math_detail::saturate_cast_helper(v);} + +template static __device__ __forceinline__ T saturate_cast(const uchar2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double2& v) {return vec_math_detail::saturate_cast_helper(v);} + +template static __device__ __forceinline__ T saturate_cast(const uchar3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double3& v) {return vec_math_detail::saturate_cast_helper(v);} + +template static __device__ __forceinline__ T saturate_cast(const uchar4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double4& v) {return vec_math_detail::saturate_cast_helper(v);} + +// unary operators + +#define CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(op, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 operator op(const input_type ## 1 & a) \ + { \ + return VecTraits::make(op (a.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(const input_type ## 2 & a) \ + { \ + return VecTraits::make(op (a.x), op (a.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(const input_type ## 3 & a) \ + { \ + return VecTraits::make(op (a.x), op (a.y), op (a.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(const input_type ## 4 & a) \ + { \ + return VecTraits::make(op (a.x), op (a.y), op (a.z), op (a.w)); \ + } + +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, char, char) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, short, short) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, int, int) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, char, char) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, short, short) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, int, int) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, uint, uint) + +#undef CV_CUDEV_IMPLEMENT_VEC_UNARY_OP + +// unary functions + +#define CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(func_name, func, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 func_name(const input_type ## 1 & a) \ + { \ + return VecTraits::make(func (a.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(const input_type ## 2 & a) \ + { \ + return VecTraits::make(func (a.x), func (a.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(const input_type ## 3 & a) \ + { \ + return VecTraits::make(func (a.x), func (a.y), func (a.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(const input_type ## 4 & a) \ + { \ + return VecTraits::make(func (a.x), func (a.y), func (a.z), func (a.w)); \ + } + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(abs, ::fabsf, float, float) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrt, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::exp, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::log, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sin, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cos, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tan, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asin, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acos, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atan, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::cosh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acosh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanh, double, double) + +#undef CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC + +// binary operators (vec & vec) + +#define CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(op, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 operator op(const input_type ## 1 & a, const input_type ## 1 & b) \ + { \ + return VecTraits::make(a.x op b.x); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(const input_type ## 2 & a, const input_type ## 2 & b) \ + { \ + return VecTraits::make(a.x op b.x, a.y op b.y); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(const input_type ## 3 & a, const input_type ## 3 & b) \ + { \ + return VecTraits::make(a.x op b.x, a.y op b.y, a.z op b.z); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(const input_type ## 4 & a, const input_type ## 4 & b) \ + { \ + return VecTraits::make(a.x op b.x, a.y op b.y, a.z op b.z, a.w op b.w); \ + } + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, uint, uint) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, uint, uint) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, uint, uint) + +#undef CV_CUDEV_IMPLEMENT_VEC_BINARY_OP + +// binary operators (vec & scalar) + +#define CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(op, input_type, scalar_type, output_type) \ + __device__ __forceinline__ output_type ## 1 operator op(const input_type ## 1 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s); \ + } \ + __device__ __forceinline__ output_type ## 1 operator op(scalar_type s, const input_type ## 1 & b) \ + { \ + return VecTraits::make(s op b.x); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(const input_type ## 2 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s, a.y op s); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(scalar_type s, const input_type ## 2 & b) \ + { \ + return VecTraits::make(s op b.x, s op b.y); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(const input_type ## 3 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s, a.y op s, a.z op s); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(scalar_type s, const input_type ## 3 & b) \ + { \ + return VecTraits::make(s op b.x, s op b.y, s op b.z); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(const input_type ## 4 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s, a.y op s, a.z op s, a.w op s); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(scalar_type s, const input_type ## 4 & b) \ + { \ + return VecTraits::make(s op b.x, s op b.y, s op b.z, s op b.w); \ + } + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, uint, uint, uint) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, uint, uint, uint) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, uint, uint, uint) + +#undef CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP + +// binary function (vec & vec) + +#define CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(func_name, func, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 func_name(const input_type ## 1 & a, const input_type ## 1 & b) \ + { \ + return VecTraits::make(func (a.x, b.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(const input_type ## 2 & a, const input_type ## 2 & b) \ + { \ + return VecTraits::make(func (a.x, b.x), func (a.y, b.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(const input_type ## 3 & a, const input_type ## 3 & b) \ + { \ + return VecTraits::make(func (a.x, b.x), func (a.y, b.y), func (a.z, b.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(const input_type ## 4 & a, const input_type ## 4 & b) \ + { \ + return VecTraits::make(func (a.x, b.x), func (a.y, b.y), func (a.z, b.z), func (a.w, b.w)); \ + } + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::fmaxf, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::fmax, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::fminf, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::fmin, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, char, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, short, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, int, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypot, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, char, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, short, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, int, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2, double, double) + +#undef CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC + +// binary function (vec & scalar) + +#define CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(func_name, func, input_type, scalar_type, output_type) \ + __device__ __forceinline__ output_type ## 1 func_name(const input_type ## 1 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 1 func_name(scalar_type s, const input_type ## 1 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(const input_type ## 2 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s), func ((output_type) a.y, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(scalar_type s, const input_type ## 2 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x), func ((output_type) s, (output_type) b.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(const input_type ## 3 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s), func ((output_type) a.y, (output_type) s), func ((output_type) a.z, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(scalar_type s, const input_type ## 3 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x), func ((output_type) s, (output_type) b.y), func ((output_type) s, (output_type) b.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(const input_type ## 4 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s), func ((output_type) a.y, (output_type) s), func ((output_type) a.z, (output_type) s), func ((output_type) a.w, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(scalar_type s, const input_type ## 4 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x), func ((output_type) s, (output_type) b.y), func ((output_type) s, (output_type) b.z), func ((output_type) s, (output_type) b.w)); \ + } + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, double, double, double) + +#undef CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC + +}}} // namespace cv { namespace cuda { namespace device + +//! @endcond + +#endif // OPENCV_CUDA_VECMATH_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_traits.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_traits.hpp new file mode 100644 index 0000000..b5ff281 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/vec_traits.hpp @@ -0,0 +1,288 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VEC_TRAITS_HPP +#define OPENCV_CUDA_VEC_TRAITS_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct TypeVec; + + struct __align__(8) uchar8 + { + uchar a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ uchar8 make_uchar8(uchar a0, uchar a1, uchar a2, uchar a3, uchar a4, uchar a5, uchar a6, uchar a7) + { + uchar8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(8) char8 + { + schar a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ char8 make_char8(schar a0, schar a1, schar a2, schar a3, schar a4, schar a5, schar a6, schar a7) + { + char8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(16) ushort8 + { + ushort a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ ushort8 make_ushort8(ushort a0, ushort a1, ushort a2, ushort a3, ushort a4, ushort a5, ushort a6, ushort a7) + { + ushort8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(16) short8 + { + short a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ short8 make_short8(short a0, short a1, short a2, short a3, short a4, short a5, short a6, short a7) + { + short8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(32) uint8 + { + uint a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ uint8 make_uint8(uint a0, uint a1, uint a2, uint a3, uint a4, uint a5, uint a6, uint a7) + { + uint8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(32) int8 + { + int a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ int8 make_int8(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { + int8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(32) float8 + { + float a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ float8 make_float8(float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7) + { + float8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct double8 + { + double a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ double8 make_double8(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7) + { + double8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + +#define OPENCV_CUDA_IMPLEMENT_TYPE_VEC(type) \ + template<> struct TypeVec { typedef type vec_type; }; \ + template<> struct TypeVec { typedef type ## 1 vec_type; }; \ + template<> struct TypeVec { typedef type ## 2 vec_type; }; \ + template<> struct TypeVec { typedef type ## 2 vec_type; }; \ + template<> struct TypeVec { typedef type ## 3 vec_type; }; \ + template<> struct TypeVec { typedef type ## 3 vec_type; }; \ + template<> struct TypeVec { typedef type ## 4 vec_type; }; \ + template<> struct TypeVec { typedef type ## 4 vec_type; }; \ + template<> struct TypeVec { typedef type ## 8 vec_type; }; \ + template<> struct TypeVec { typedef type ## 8 vec_type; }; + + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(uchar) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(char) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(ushort) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(short) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(int) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(uint) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(float) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(double) + + #undef OPENCV_CUDA_IMPLEMENT_TYPE_VEC + + template<> struct TypeVec { typedef schar vec_type; }; + template<> struct TypeVec { typedef char2 vec_type; }; + template<> struct TypeVec { typedef char3 vec_type; }; + template<> struct TypeVec { typedef char4 vec_type; }; + template<> struct TypeVec { typedef char8 vec_type; }; + + template<> struct TypeVec { typedef uchar vec_type; }; + template<> struct TypeVec { typedef uchar2 vec_type; }; + template<> struct TypeVec { typedef uchar3 vec_type; }; + template<> struct TypeVec { typedef uchar4 vec_type; }; + template<> struct TypeVec { typedef uchar8 vec_type; }; + + template struct VecTraits; + +#define OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(type) \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=1}; \ + static __device__ __host__ __forceinline__ type all(type v) {return v;} \ + static __device__ __host__ __forceinline__ type make(type x) {return x;} \ + static __device__ __host__ __forceinline__ type make(const type* v) {return *v;} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=1}; \ + static __device__ __host__ __forceinline__ type ## 1 all(type v) {return make_ ## type ## 1(v);} \ + static __device__ __host__ __forceinline__ type ## 1 make(type x) {return make_ ## type ## 1(x);} \ + static __device__ __host__ __forceinline__ type ## 1 make(const type* v) {return make_ ## type ## 1(*v);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=2}; \ + static __device__ __host__ __forceinline__ type ## 2 all(type v) {return make_ ## type ## 2(v, v);} \ + static __device__ __host__ __forceinline__ type ## 2 make(type x, type y) {return make_ ## type ## 2(x, y);} \ + static __device__ __host__ __forceinline__ type ## 2 make(const type* v) {return make_ ## type ## 2(v[0], v[1]);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=3}; \ + static __device__ __host__ __forceinline__ type ## 3 all(type v) {return make_ ## type ## 3(v, v, v);} \ + static __device__ __host__ __forceinline__ type ## 3 make(type x, type y, type z) {return make_ ## type ## 3(x, y, z);} \ + static __device__ __host__ __forceinline__ type ## 3 make(const type* v) {return make_ ## type ## 3(v[0], v[1], v[2]);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=4}; \ + static __device__ __host__ __forceinline__ type ## 4 all(type v) {return make_ ## type ## 4(v, v, v, v);} \ + static __device__ __host__ __forceinline__ type ## 4 make(type x, type y, type z, type w) {return make_ ## type ## 4(x, y, z, w);} \ + static __device__ __host__ __forceinline__ type ## 4 make(const type* v) {return make_ ## type ## 4(v[0], v[1], v[2], v[3]);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=8}; \ + static __device__ __host__ __forceinline__ type ## 8 all(type v) {return make_ ## type ## 8(v, v, v, v, v, v, v, v);} \ + static __device__ __host__ __forceinline__ type ## 8 make(type a0, type a1, type a2, type a3, type a4, type a5, type a6, type a7) {return make_ ## type ## 8(a0, a1, a2, a3, a4, a5, a6, a7);} \ + static __device__ __host__ __forceinline__ type ## 8 make(const type* v) {return make_ ## type ## 8(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);} \ + }; + + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(uchar) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(ushort) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(short) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(int) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(uint) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(float) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(double) + + #undef OPENCV_CUDA_IMPLEMENT_VEC_TRAITS + + template<> struct VecTraits + { + typedef char elem_type; + enum {cn=1}; + static __device__ __host__ __forceinline__ char all(char v) {return v;} + static __device__ __host__ __forceinline__ char make(char x) {return x;} + static __device__ __host__ __forceinline__ char make(const char* x) {return *x;} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=1}; + static __device__ __host__ __forceinline__ schar all(schar v) {return v;} + static __device__ __host__ __forceinline__ schar make(schar x) {return x;} + static __device__ __host__ __forceinline__ schar make(const schar* x) {return *x;} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=1}; + static __device__ __host__ __forceinline__ char1 all(schar v) {return make_char1(v);} + static __device__ __host__ __forceinline__ char1 make(schar x) {return make_char1(x);} + static __device__ __host__ __forceinline__ char1 make(const schar* v) {return make_char1(v[0]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=2}; + static __device__ __host__ __forceinline__ char2 all(schar v) {return make_char2(v, v);} + static __device__ __host__ __forceinline__ char2 make(schar x, schar y) {return make_char2(x, y);} + static __device__ __host__ __forceinline__ char2 make(const schar* v) {return make_char2(v[0], v[1]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=3}; + static __device__ __host__ __forceinline__ char3 all(schar v) {return make_char3(v, v, v);} + static __device__ __host__ __forceinline__ char3 make(schar x, schar y, schar z) {return make_char3(x, y, z);} + static __device__ __host__ __forceinline__ char3 make(const schar* v) {return make_char3(v[0], v[1], v[2]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=4}; + static __device__ __host__ __forceinline__ char4 all(schar v) {return make_char4(v, v, v, v);} + static __device__ __host__ __forceinline__ char4 make(schar x, schar y, schar z, schar w) {return make_char4(x, y, z, w);} + static __device__ __host__ __forceinline__ char4 make(const schar* v) {return make_char4(v[0], v[1], v[2], v[3]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=8}; + static __device__ __host__ __forceinline__ char8 all(schar v) {return make_char8(v, v, v, v, v, v, v, v);} + static __device__ __host__ __forceinline__ char8 make(schar a0, schar a1, schar a2, schar a3, schar a4, schar a5, schar a6, schar a7) {return make_char8(a0, a1, a2, a3, a4, a5, a6, a7);} + static __device__ __host__ __forceinline__ char8 make(const schar* v) {return make_char8(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);} + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_VEC_TRAITS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp.hpp new file mode 100644 index 0000000..8af7e6a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp.hpp @@ -0,0 +1,139 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DEVICE_WARP_HPP +#define OPENCV_CUDA_DEVICE_WARP_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct Warp + { + enum + { + LOG_WARP_SIZE = 5, + WARP_SIZE = 1 << LOG_WARP_SIZE, + STRIDE = WARP_SIZE + }; + + /** \brief Returns the warp lane ID of the calling thread. */ + static __device__ __forceinline__ unsigned int laneId() + { + unsigned int ret; + asm("mov.u32 %0, %%laneid;" : "=r"(ret) ); + return ret; + } + + template + static __device__ __forceinline__ void fill(It beg, It end, const T& value) + { + for(It t = beg + laneId(); t < end; t += STRIDE) + *t = value; + } + + template + static __device__ __forceinline__ OutIt copy(InIt beg, InIt end, OutIt out) + { + for(InIt t = beg + laneId(); t < end; t += STRIDE, out += STRIDE) + *out = *t; + return out; + } + + template + static __device__ __forceinline__ OutIt transform(InIt beg, InIt end, OutIt out, UnOp op) + { + for(InIt t = beg + laneId(); t < end; t += STRIDE, out += STRIDE) + *out = op(*t); + return out; + } + + template + static __device__ __forceinline__ OutIt transform(InIt1 beg1, InIt1 end1, InIt2 beg2, OutIt out, BinOp op) + { + unsigned int lane = laneId(); + + InIt1 t1 = beg1 + lane; + InIt2 t2 = beg2 + lane; + for(; t1 < end1; t1 += STRIDE, t2 += STRIDE, out += STRIDE) + *out = op(*t1, *t2); + return out; + } + + template + static __device__ __forceinline__ T reduce(volatile T *ptr, BinOp op) + { + const unsigned int lane = laneId(); + + if (lane < 16) + { + T partial = ptr[lane]; + + ptr[lane] = partial = op(partial, ptr[lane + 16]); + ptr[lane] = partial = op(partial, ptr[lane + 8]); + ptr[lane] = partial = op(partial, ptr[lane + 4]); + ptr[lane] = partial = op(partial, ptr[lane + 2]); + ptr[lane] = partial = op(partial, ptr[lane + 1]); + } + + return *ptr; + } + + template + static __device__ __forceinline__ void yota(OutIt beg, OutIt end, T value) + { + unsigned int lane = laneId(); + value += lane; + + for(OutIt t = beg + lane; t < end; t += STRIDE, value += STRIDE) + *t = value; + } + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif /* OPENCV_CUDA_DEVICE_WARP_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp_reduce.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp_reduce.hpp new file mode 100644 index 0000000..530303d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp_reduce.hpp @@ -0,0 +1,76 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_WARP_REDUCE_HPP__ +#define OPENCV_CUDA_WARP_REDUCE_HPP__ + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + __device__ __forceinline__ T warp_reduce(volatile T *ptr , const unsigned int tid = threadIdx.x) + { + const unsigned int lane = tid & 31; // index of thread in warp (0..31) + + if (lane < 16) + { + T partial = ptr[tid]; + + ptr[tid] = partial = partial + ptr[tid + 16]; + ptr[tid] = partial = partial + ptr[tid + 8]; + ptr[tid] = partial = partial + ptr[tid + 4]; + ptr[tid] = partial = partial + ptr[tid + 2]; + ptr[tid] = partial = partial + ptr[tid + 1]; + } + + return ptr[tid - lane]; + } +}}} // namespace cv { namespace cuda { namespace cudev { + +//! @endcond + +#endif /* OPENCV_CUDA_WARP_REDUCE_HPP__ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp_shuffle.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp_shuffle.hpp new file mode 100644 index 0000000..0da54ae --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda/warp_shuffle.hpp @@ -0,0 +1,162 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_WARP_SHUFFLE_HPP +#define OPENCV_CUDA_WARP_SHUFFLE_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ +#if __CUDACC_VER_MAJOR__ >= 9 +# define __shfl(x, y, z) __shfl_sync(0xFFFFFFFFU, x, y, z) +# define __shfl_up(x, y, z) __shfl_up_sync(0xFFFFFFFFU, x, y, z) +# define __shfl_down(x, y, z) __shfl_down_sync(0xFFFFFFFFU, x, y, z) +#endif + template + __device__ __forceinline__ T shfl(T val, int srcLane, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return __shfl(val, srcLane, width); + #else + return T(); + #endif + } + __device__ __forceinline__ unsigned int shfl(unsigned int val, int srcLane, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return (unsigned int) __shfl((int) val, srcLane, width); + #else + return 0; + #endif + } + __device__ __forceinline__ double shfl(double val, int srcLane, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + int lo = __double2loint(val); + int hi = __double2hiint(val); + + lo = __shfl(lo, srcLane, width); + hi = __shfl(hi, srcLane, width); + + return __hiloint2double(hi, lo); + #else + return 0.0; + #endif + } + + template + __device__ __forceinline__ T shfl_down(T val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return __shfl_down(val, delta, width); + #else + return T(); + #endif + } + __device__ __forceinline__ unsigned int shfl_down(unsigned int val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return (unsigned int) __shfl_down((int) val, delta, width); + #else + return 0; + #endif + } + __device__ __forceinline__ double shfl_down(double val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + int lo = __double2loint(val); + int hi = __double2hiint(val); + + lo = __shfl_down(lo, delta, width); + hi = __shfl_down(hi, delta, width); + + return __hiloint2double(hi, lo); + #else + return 0.0; + #endif + } + + template + __device__ __forceinline__ T shfl_up(T val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return __shfl_up(val, delta, width); + #else + return T(); + #endif + } + __device__ __forceinline__ unsigned int shfl_up(unsigned int val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return (unsigned int) __shfl_up((int) val, delta, width); + #else + return 0; + #endif + } + __device__ __forceinline__ double shfl_up(double val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + int lo = __double2loint(val); + int hi = __double2hiint(val); + + lo = __shfl_up(lo, delta, width); + hi = __shfl_up(hi, delta, width); + + return __hiloint2double(hi, lo); + #else + return 0.0; + #endif + } +}}} + +# undef __shfl +# undef __shfl_up +# undef __shfl_down + +//! @endcond + +#endif // OPENCV_CUDA_WARP_SHUFFLE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda_stream_accessor.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda_stream_accessor.hpp new file mode 100644 index 0000000..deaf356 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda_stream_accessor.hpp @@ -0,0 +1,86 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP +#define OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP + +#ifndef __cplusplus +# error cuda_stream_accessor.hpp header must be compiled as C++ +#endif + +/** @file cuda_stream_accessor.hpp + * This is only header file that depends on CUDA Runtime API. All other headers are independent. + */ + +#include +#include "opencv2/core/cuda.hpp" + +namespace cv +{ + namespace cuda + { + +//! @addtogroup cudacore_struct +//! @{ + + /** @brief Class that enables getting cudaStream_t from cuda::Stream + */ + struct StreamAccessor + { + CV_EXPORTS static cudaStream_t getStream(const Stream& stream); + CV_EXPORTS static Stream wrapStream(cudaStream_t stream); + }; + + /** @brief Class that enables getting cudaEvent_t from cuda::Event + */ + struct EventAccessor + { + CV_EXPORTS static cudaEvent_t getEvent(const Event& event); + CV_EXPORTS static Event wrapEvent(cudaEvent_t event); + }; + +//! @} + + } +} + +#endif /* OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cuda_types.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda_types.hpp new file mode 100644 index 0000000..b33f061 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cuda_types.hpp @@ -0,0 +1,144 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDA_TYPES_HPP +#define OPENCV_CORE_CUDA_TYPES_HPP + +#ifndef __cplusplus +# error cuda_types.hpp header must be compiled as C++ +#endif + +#if defined(__OPENCV_BUILD) && defined(__clang__) +#pragma clang diagnostic ignored "-Winconsistent-missing-override" +#endif +#if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic ignored "-Wsuggest-override" +#endif + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +#ifdef __CUDACC__ + #define __CV_CUDA_HOST_DEVICE__ __host__ __device__ __forceinline__ +#else + #define __CV_CUDA_HOST_DEVICE__ +#endif + +namespace cv +{ + namespace cuda + { + + // Simple lightweight structures that encapsulates information about an image on device. + // It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile + + template struct DevPtr + { + typedef T elem_type; + typedef int index_type; + + enum { elem_size = sizeof(elem_type) }; + + T* data; + + __CV_CUDA_HOST_DEVICE__ DevPtr() : data(0) {} + __CV_CUDA_HOST_DEVICE__ DevPtr(T* data_) : data(data_) {} + + __CV_CUDA_HOST_DEVICE__ size_t elemSize() const { return elem_size; } + __CV_CUDA_HOST_DEVICE__ operator T*() { return data; } + __CV_CUDA_HOST_DEVICE__ operator const T*() const { return data; } + }; + + template struct PtrSz : public DevPtr + { + __CV_CUDA_HOST_DEVICE__ PtrSz() : size(0) {} + __CV_CUDA_HOST_DEVICE__ PtrSz(T* data_, size_t size_) : DevPtr(data_), size(size_) {} + + size_t size; + }; + + template struct PtrStep : public DevPtr + { + __CV_CUDA_HOST_DEVICE__ PtrStep() : step(0) {} + __CV_CUDA_HOST_DEVICE__ PtrStep(T* data_, size_t step_) : DevPtr(data_), step(step_) {} + + size_t step; + + __CV_CUDA_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)(((DevPtr*)this)->data) + y * step); } + __CV_CUDA_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)(((DevPtr*)this)->data) + y * step); } + + __CV_CUDA_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; } + __CV_CUDA_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; } + }; + + template struct PtrStepSz : public PtrStep + { + __CV_CUDA_HOST_DEVICE__ PtrStepSz() : cols(0), rows(0) {} + __CV_CUDA_HOST_DEVICE__ PtrStepSz(int rows_, int cols_, T* data_, size_t step_) + : PtrStep(data_, step_), cols(cols_), rows(rows_) {} + + template + explicit PtrStepSz(const PtrStepSz& d) : PtrStep((T*)d.data, d.step), cols(d.cols), rows(d.rows){} + + int cols; + int rows; + }; + + typedef PtrStepSz PtrStepSzb; + typedef PtrStepSz PtrStepSzus; + typedef PtrStepSz PtrStepSzf; + typedef PtrStepSz PtrStepSzi; + + typedef PtrStep PtrStepb; + typedef PtrStep PtrStepus; + typedef PtrStep PtrStepf; + typedef PtrStep PtrStepi; + + } +} + +//! @endcond + +#endif /* OPENCV_CORE_CUDA_TYPES_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cv_cpu_dispatch.h b/Cigarette/OpenCV455Simple/include/opencv2/core/cv_cpu_dispatch.h new file mode 100644 index 0000000..ab5a67d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cv_cpu_dispatch.h @@ -0,0 +1,368 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#if defined __OPENCV_BUILD \ + +#include "cv_cpu_config.h" +#include "cv_cpu_helper.h" + +#ifdef CV_CPU_DISPATCH_MODE +#define CV_CPU_OPTIMIZATION_NAMESPACE __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) +#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) { +#define CV_CPU_OPTIMIZATION_NAMESPACE_END } +#else +#define CV_CPU_OPTIMIZATION_NAMESPACE cpu_baseline +#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace cpu_baseline { +#define CV_CPU_OPTIMIZATION_NAMESPACE_END } +#define CV_CPU_BASELINE_MODE 1 +#endif + + +#define __CV_CPU_DISPATCH_CHAIN_END(fn, args, mode, ...) /* done */ +#define __CV_CPU_DISPATCH(fn, args, mode, ...) __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) +#define __CV_CPU_DISPATCH_EXPAND(fn, args, ...) __CV_EXPAND(__CV_CPU_DISPATCH(fn, args, __VA_ARGS__)) +#define CV_CPU_DISPATCH(fn, args, ...) __CV_CPU_DISPATCH_EXPAND(fn, args, __VA_ARGS__, END) // expand macros + + +#if defined CV_ENABLE_INTRINSICS \ + && !defined CV_DISABLE_OPTIMIZATION \ + && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ \ + +#ifdef CV_CPU_COMPILE_SSE2 +# include +# define CV_MMX 1 +# define CV_SSE 1 +# define CV_SSE2 1 +#endif +#ifdef CV_CPU_COMPILE_SSE3 +# include +# define CV_SSE3 1 +#endif +#ifdef CV_CPU_COMPILE_SSSE3 +# include +# define CV_SSSE3 1 +#endif +#ifdef CV_CPU_COMPILE_SSE4_1 +# include +# define CV_SSE4_1 1 +#endif +#ifdef CV_CPU_COMPILE_SSE4_2 +# include +# define CV_SSE4_2 1 +#endif +#ifdef CV_CPU_COMPILE_POPCNT +# ifdef _MSC_VER +# include +# if defined(_M_X64) +# define CV_POPCNT_U64 (int)_mm_popcnt_u64 +# endif +# define CV_POPCNT_U32 _mm_popcnt_u32 +# else +# include +# if defined(__x86_64__) +# define CV_POPCNT_U64 __builtin_popcountll +# endif +# define CV_POPCNT_U32 __builtin_popcount +# endif +# define CV_POPCNT 1 +#endif +#ifdef CV_CPU_COMPILE_AVX +# include +# define CV_AVX 1 +#endif +#ifdef CV_CPU_COMPILE_FP16 +# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) +# include +# else +# include +# endif +# define CV_FP16 1 +#endif +#ifdef CV_CPU_COMPILE_AVX2 +# include +# define CV_AVX2 1 +#endif +#ifdef CV_CPU_COMPILE_AVX_512F +# include +# define CV_AVX_512F 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_COMMON +# define CV_AVX512_COMMON 1 +# define CV_AVX_512CD 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_KNL +# define CV_AVX512_KNL 1 +# define CV_AVX_512ER 1 +# define CV_AVX_512PF 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_KNM +# define CV_AVX512_KNM 1 +# define CV_AVX_5124FMAPS 1 +# define CV_AVX_5124VNNIW 1 +# define CV_AVX_512VPOPCNTDQ 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_SKX +# define CV_AVX512_SKX 1 +# define CV_AVX_512VL 1 +# define CV_AVX_512BW 1 +# define CV_AVX_512DQ 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_CNL +# define CV_AVX512_CNL 1 +# define CV_AVX_512IFMA 1 +# define CV_AVX_512VBMI 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_CLX +# define CV_AVX512_CLX 1 +# define CV_AVX_512VNNI 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_ICL +# define CV_AVX512_ICL 1 +# undef CV_AVX_512IFMA +# define CV_AVX_512IFMA 1 +# undef CV_AVX_512VBMI +# define CV_AVX_512VBMI 1 +# undef CV_AVX_512VNNI +# define CV_AVX_512VNNI 1 +# define CV_AVX_512VBMI2 1 +# define CV_AVX_512BITALG 1 +# define CV_AVX_512VPOPCNTDQ 1 +#endif +#ifdef CV_CPU_COMPILE_FMA3 +# define CV_FMA3 1 +#endif + +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) +# include +# include +# define CV_NEON 1 +#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__)) +# include +# define CV_NEON 1 +#endif + +#if defined(__riscv) && defined(__riscv_vector) && defined(__riscv_vector_071) +# include +# define CV_RVV071 1 +#endif + +#if defined(__ARM_NEON__) || defined(__aarch64__) +# include +#endif + +#ifdef CV_CPU_COMPILE_VSX +# include +# undef vector +# undef pixel +# undef bool +# define CV_VSX 1 +#endif + +#ifdef CV_CPU_COMPILE_VSX3 +# define CV_VSX3 1 +#endif + +#ifdef CV_CPU_COMPILE_MSA +# include "hal/msa_macros.h" +# define CV_MSA 1 +#endif + +#ifdef __EMSCRIPTEN__ +# define CV_WASM_SIMD 1 +# include +#endif + +#if defined CV_CPU_COMPILE_RVV +# define CV_RVV 1 +# include +#endif + +#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__ + +#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX +struct VZeroUpperGuard { +#ifdef __GNUC__ + __attribute__((always_inline)) +#endif + inline VZeroUpperGuard() { _mm256_zeroupper(); } +#ifdef __GNUC__ + __attribute__((always_inline)) +#endif + inline ~VZeroUpperGuard() { _mm256_zeroupper(); } +}; +#define __CV_AVX_GUARD VZeroUpperGuard __vzeroupper_guard; CV_UNUSED(__vzeroupper_guard); +#endif + +#ifdef __CV_AVX_GUARD +#define CV_AVX_GUARD __CV_AVX_GUARD +#else +#define CV_AVX_GUARD +#endif + +#endif // __OPENCV_BUILD + + + +#if !defined __OPENCV_BUILD /* Compatibility code */ \ + && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ +#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) +# include +# define CV_MMX 1 +# define CV_SSE 1 +# define CV_SSE2 1 +#elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) +# include +# include +# define CV_NEON 1 +#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__)) +# include +# define CV_NEON 1 +#elif defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__) +# include +# undef vector +# undef pixel +# undef bool +# define CV_VSX 1 +#endif + +#ifdef __F16C__ +# include +# define CV_FP16 1 +#endif + +#endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code) + + + +#ifndef CV_MMX +# define CV_MMX 0 +#endif +#ifndef CV_SSE +# define CV_SSE 0 +#endif +#ifndef CV_SSE2 +# define CV_SSE2 0 +#endif +#ifndef CV_SSE3 +# define CV_SSE3 0 +#endif +#ifndef CV_SSSE3 +# define CV_SSSE3 0 +#endif +#ifndef CV_SSE4_1 +# define CV_SSE4_1 0 +#endif +#ifndef CV_SSE4_2 +# define CV_SSE4_2 0 +#endif +#ifndef CV_POPCNT +# define CV_POPCNT 0 +#endif +#ifndef CV_AVX +# define CV_AVX 0 +#endif +#ifndef CV_FP16 +# define CV_FP16 0 +#endif +#ifndef CV_AVX2 +# define CV_AVX2 0 +#endif +#ifndef CV_FMA3 +# define CV_FMA3 0 +#endif +#ifndef CV_AVX_512F +# define CV_AVX_512F 0 +#endif +#ifndef CV_AVX_512BW +# define CV_AVX_512BW 0 +#endif +#ifndef CV_AVX_512CD +# define CV_AVX_512CD 0 +#endif +#ifndef CV_AVX_512DQ +# define CV_AVX_512DQ 0 +#endif +#ifndef CV_AVX_512ER +# define CV_AVX_512ER 0 +#endif +#ifndef CV_AVX_512IFMA +# define CV_AVX_512IFMA 0 +#endif +#define CV_AVX_512IFMA512 CV_AVX_512IFMA // deprecated +#ifndef CV_AVX_512PF +# define CV_AVX_512PF 0 +#endif +#ifndef CV_AVX_512VBMI +# define CV_AVX_512VBMI 0 +#endif +#ifndef CV_AVX_512VL +# define CV_AVX_512VL 0 +#endif +#ifndef CV_AVX_5124FMAPS +# define CV_AVX_5124FMAPS 0 +#endif +#ifndef CV_AVX_5124VNNIW +# define CV_AVX_5124VNNIW 0 +#endif +#ifndef CV_AVX_512VPOPCNTDQ +# define CV_AVX_512VPOPCNTDQ 0 +#endif +#ifndef CV_AVX_512VNNI +# define CV_AVX_512VNNI 0 +#endif +#ifndef CV_AVX_512VBMI2 +# define CV_AVX_512VBMI2 0 +#endif +#ifndef CV_AVX_512BITALG +# define CV_AVX_512BITALG 0 +#endif +#ifndef CV_AVX512_COMMON +# define CV_AVX512_COMMON 0 +#endif +#ifndef CV_AVX512_KNL +# define CV_AVX512_KNL 0 +#endif +#ifndef CV_AVX512_KNM +# define CV_AVX512_KNM 0 +#endif +#ifndef CV_AVX512_SKX +# define CV_AVX512_SKX 0 +#endif +#ifndef CV_AVX512_CNL +# define CV_AVX512_CNL 0 +#endif +#ifndef CV_AVX512_CLX +# define CV_AVX512_CLX 0 +#endif +#ifndef CV_AVX512_ICL +# define CV_AVX512_ICL 0 +#endif + +#ifndef CV_NEON +# define CV_NEON 0 +#endif + +#ifndef CV_RVV071 +# define CV_RVV071 0 +#endif + +#ifndef CV_VSX +# define CV_VSX 0 +#endif + +#ifndef CV_VSX3 +# define CV_VSX3 0 +#endif + +#ifndef CV_MSA +# define CV_MSA 0 +#endif + +#ifndef CV_WASM_SIMD +# define CV_WASM_SIMD 0 +#endif + +#ifndef CV_RVV +# define CV_RVV 0 +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cv_cpu_helper.h b/Cigarette/OpenCV455Simple/include/opencv2/core/cv_cpu_helper.h new file mode 100644 index 0000000..39ae0b9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cv_cpu_helper.h @@ -0,0 +1,508 @@ +// AUTOGENERATED, DO NOT EDIT + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE +# define CV_TRY_SSE 1 +# define CV_CPU_FORCE_SSE 1 +# define CV_CPU_HAS_SUPPORT_SSE 1 +# define CV_CPU_CALL_SSE(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE_(fn, args) return (opt_SSE::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE +# define CV_TRY_SSE 1 +# define CV_CPU_FORCE_SSE 0 +# define CV_CPU_HAS_SUPPORT_SSE (cv::checkHardwareSupport(CV_CPU_SSE)) +# define CV_CPU_CALL_SSE(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args) +# define CV_CPU_CALL_SSE_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args) +#else +# define CV_TRY_SSE 0 +# define CV_CPU_FORCE_SSE 0 +# define CV_CPU_HAS_SUPPORT_SSE 0 +# define CV_CPU_CALL_SSE(fn, args) +# define CV_CPU_CALL_SSE_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE(fn, args, mode, ...) CV_CPU_CALL_SSE(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE2 +# define CV_TRY_SSE2 1 +# define CV_CPU_FORCE_SSE2 1 +# define CV_CPU_HAS_SUPPORT_SSE2 1 +# define CV_CPU_CALL_SSE2(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE2_(fn, args) return (opt_SSE2::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE2 +# define CV_TRY_SSE2 1 +# define CV_CPU_FORCE_SSE2 0 +# define CV_CPU_HAS_SUPPORT_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2)) +# define CV_CPU_CALL_SSE2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args) +# define CV_CPU_CALL_SSE2_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args) +#else +# define CV_TRY_SSE2 0 +# define CV_CPU_FORCE_SSE2 0 +# define CV_CPU_HAS_SUPPORT_SSE2 0 +# define CV_CPU_CALL_SSE2(fn, args) +# define CV_CPU_CALL_SSE2_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE2(fn, args, mode, ...) CV_CPU_CALL_SSE2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE3 +# define CV_TRY_SSE3 1 +# define CV_CPU_FORCE_SSE3 1 +# define CV_CPU_HAS_SUPPORT_SSE3 1 +# define CV_CPU_CALL_SSE3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE3_(fn, args) return (opt_SSE3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE3 +# define CV_TRY_SSE3 1 +# define CV_CPU_FORCE_SSE3 0 +# define CV_CPU_HAS_SUPPORT_SSE3 (cv::checkHardwareSupport(CV_CPU_SSE3)) +# define CV_CPU_CALL_SSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args) +# define CV_CPU_CALL_SSE3_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args) +#else +# define CV_TRY_SSE3 0 +# define CV_CPU_FORCE_SSE3 0 +# define CV_CPU_HAS_SUPPORT_SSE3 0 +# define CV_CPU_CALL_SSE3(fn, args) +# define CV_CPU_CALL_SSE3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE3(fn, args, mode, ...) CV_CPU_CALL_SSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSSE3 +# define CV_TRY_SSSE3 1 +# define CV_CPU_FORCE_SSSE3 1 +# define CV_CPU_HAS_SUPPORT_SSSE3 1 +# define CV_CPU_CALL_SSSE3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSSE3_(fn, args) return (opt_SSSE3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSSE3 +# define CV_TRY_SSSE3 1 +# define CV_CPU_FORCE_SSSE3 0 +# define CV_CPU_HAS_SUPPORT_SSSE3 (cv::checkHardwareSupport(CV_CPU_SSSE3)) +# define CV_CPU_CALL_SSSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args) +# define CV_CPU_CALL_SSSE3_(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args) +#else +# define CV_TRY_SSSE3 0 +# define CV_CPU_FORCE_SSSE3 0 +# define CV_CPU_HAS_SUPPORT_SSSE3 0 +# define CV_CPU_CALL_SSSE3(fn, args) +# define CV_CPU_CALL_SSSE3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSSE3(fn, args, mode, ...) CV_CPU_CALL_SSSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_1 +# define CV_TRY_SSE4_1 1 +# define CV_CPU_FORCE_SSE4_1 1 +# define CV_CPU_HAS_SUPPORT_SSE4_1 1 +# define CV_CPU_CALL_SSE4_1(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE4_1_(fn, args) return (opt_SSE4_1::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_1 +# define CV_TRY_SSE4_1 1 +# define CV_CPU_FORCE_SSE4_1 0 +# define CV_CPU_HAS_SUPPORT_SSE4_1 (cv::checkHardwareSupport(CV_CPU_SSE4_1)) +# define CV_CPU_CALL_SSE4_1(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args) +# define CV_CPU_CALL_SSE4_1_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args) +#else +# define CV_TRY_SSE4_1 0 +# define CV_CPU_FORCE_SSE4_1 0 +# define CV_CPU_HAS_SUPPORT_SSE4_1 0 +# define CV_CPU_CALL_SSE4_1(fn, args) +# define CV_CPU_CALL_SSE4_1_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE4_1(fn, args, mode, ...) CV_CPU_CALL_SSE4_1(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_2 +# define CV_TRY_SSE4_2 1 +# define CV_CPU_FORCE_SSE4_2 1 +# define CV_CPU_HAS_SUPPORT_SSE4_2 1 +# define CV_CPU_CALL_SSE4_2(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE4_2_(fn, args) return (opt_SSE4_2::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_2 +# define CV_TRY_SSE4_2 1 +# define CV_CPU_FORCE_SSE4_2 0 +# define CV_CPU_HAS_SUPPORT_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2)) +# define CV_CPU_CALL_SSE4_2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args) +# define CV_CPU_CALL_SSE4_2_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args) +#else +# define CV_TRY_SSE4_2 0 +# define CV_CPU_FORCE_SSE4_2 0 +# define CV_CPU_HAS_SUPPORT_SSE4_2 0 +# define CV_CPU_CALL_SSE4_2(fn, args) +# define CV_CPU_CALL_SSE4_2_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE4_2(fn, args, mode, ...) CV_CPU_CALL_SSE4_2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_POPCNT +# define CV_TRY_POPCNT 1 +# define CV_CPU_FORCE_POPCNT 1 +# define CV_CPU_HAS_SUPPORT_POPCNT 1 +# define CV_CPU_CALL_POPCNT(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_POPCNT_(fn, args) return (opt_POPCNT::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_POPCNT +# define CV_TRY_POPCNT 1 +# define CV_CPU_FORCE_POPCNT 0 +# define CV_CPU_HAS_SUPPORT_POPCNT (cv::checkHardwareSupport(CV_CPU_POPCNT)) +# define CV_CPU_CALL_POPCNT(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args) +# define CV_CPU_CALL_POPCNT_(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args) +#else +# define CV_TRY_POPCNT 0 +# define CV_CPU_FORCE_POPCNT 0 +# define CV_CPU_HAS_SUPPORT_POPCNT 0 +# define CV_CPU_CALL_POPCNT(fn, args) +# define CV_CPU_CALL_POPCNT_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_POPCNT(fn, args, mode, ...) CV_CPU_CALL_POPCNT(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX +# define CV_TRY_AVX 1 +# define CV_CPU_FORCE_AVX 1 +# define CV_CPU_HAS_SUPPORT_AVX 1 +# define CV_CPU_CALL_AVX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX_(fn, args) return (opt_AVX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX +# define CV_TRY_AVX 1 +# define CV_CPU_FORCE_AVX 0 +# define CV_CPU_HAS_SUPPORT_AVX (cv::checkHardwareSupport(CV_CPU_AVX)) +# define CV_CPU_CALL_AVX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args) +# define CV_CPU_CALL_AVX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args) +#else +# define CV_TRY_AVX 0 +# define CV_CPU_FORCE_AVX 0 +# define CV_CPU_HAS_SUPPORT_AVX 0 +# define CV_CPU_CALL_AVX(fn, args) +# define CV_CPU_CALL_AVX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX(fn, args, mode, ...) CV_CPU_CALL_AVX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FP16 +# define CV_TRY_FP16 1 +# define CV_CPU_FORCE_FP16 1 +# define CV_CPU_HAS_SUPPORT_FP16 1 +# define CV_CPU_CALL_FP16(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_FP16_(fn, args) return (opt_FP16::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FP16 +# define CV_TRY_FP16 1 +# define CV_CPU_FORCE_FP16 0 +# define CV_CPU_HAS_SUPPORT_FP16 (cv::checkHardwareSupport(CV_CPU_FP16)) +# define CV_CPU_CALL_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args) +# define CV_CPU_CALL_FP16_(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args) +#else +# define CV_TRY_FP16 0 +# define CV_CPU_FORCE_FP16 0 +# define CV_CPU_HAS_SUPPORT_FP16 0 +# define CV_CPU_CALL_FP16(fn, args) +# define CV_CPU_CALL_FP16_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_FP16(fn, args, mode, ...) CV_CPU_CALL_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX2 +# define CV_TRY_AVX2 1 +# define CV_CPU_FORCE_AVX2 1 +# define CV_CPU_HAS_SUPPORT_AVX2 1 +# define CV_CPU_CALL_AVX2(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX2_(fn, args) return (opt_AVX2::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX2 +# define CV_TRY_AVX2 1 +# define CV_CPU_FORCE_AVX2 0 +# define CV_CPU_HAS_SUPPORT_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2)) +# define CV_CPU_CALL_AVX2(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args) +# define CV_CPU_CALL_AVX2_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args) +#else +# define CV_TRY_AVX2 0 +# define CV_CPU_FORCE_AVX2 0 +# define CV_CPU_HAS_SUPPORT_AVX2 0 +# define CV_CPU_CALL_AVX2(fn, args) +# define CV_CPU_CALL_AVX2_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX2(fn, args, mode, ...) CV_CPU_CALL_AVX2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FMA3 +# define CV_TRY_FMA3 1 +# define CV_CPU_FORCE_FMA3 1 +# define CV_CPU_HAS_SUPPORT_FMA3 1 +# define CV_CPU_CALL_FMA3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_FMA3_(fn, args) return (opt_FMA3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FMA3 +# define CV_TRY_FMA3 1 +# define CV_CPU_FORCE_FMA3 0 +# define CV_CPU_HAS_SUPPORT_FMA3 (cv::checkHardwareSupport(CV_CPU_FMA3)) +# define CV_CPU_CALL_FMA3(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args) +# define CV_CPU_CALL_FMA3_(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args) +#else +# define CV_TRY_FMA3 0 +# define CV_CPU_FORCE_FMA3 0 +# define CV_CPU_HAS_SUPPORT_FMA3 0 +# define CV_CPU_CALL_FMA3(fn, args) +# define CV_CPU_CALL_FMA3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX_512F +# define CV_TRY_AVX_512F 1 +# define CV_CPU_FORCE_AVX_512F 1 +# define CV_CPU_HAS_SUPPORT_AVX_512F 1 +# define CV_CPU_CALL_AVX_512F(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX_512F_(fn, args) return (opt_AVX_512F::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX_512F +# define CV_TRY_AVX_512F 1 +# define CV_CPU_FORCE_AVX_512F 0 +# define CV_CPU_HAS_SUPPORT_AVX_512F (cv::checkHardwareSupport(CV_CPU_AVX_512F)) +# define CV_CPU_CALL_AVX_512F(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args) +# define CV_CPU_CALL_AVX_512F_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args) +#else +# define CV_TRY_AVX_512F 0 +# define CV_CPU_FORCE_AVX_512F 0 +# define CV_CPU_HAS_SUPPORT_AVX_512F 0 +# define CV_CPU_CALL_AVX_512F(fn, args) +# define CV_CPU_CALL_AVX_512F_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX_512F(fn, args, mode, ...) CV_CPU_CALL_AVX_512F(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_COMMON +# define CV_TRY_AVX512_COMMON 1 +# define CV_CPU_FORCE_AVX512_COMMON 1 +# define CV_CPU_HAS_SUPPORT_AVX512_COMMON 1 +# define CV_CPU_CALL_AVX512_COMMON(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_COMMON_(fn, args) return (opt_AVX512_COMMON::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_COMMON +# define CV_TRY_AVX512_COMMON 1 +# define CV_CPU_FORCE_AVX512_COMMON 0 +# define CV_CPU_HAS_SUPPORT_AVX512_COMMON (cv::checkHardwareSupport(CV_CPU_AVX512_COMMON)) +# define CV_CPU_CALL_AVX512_COMMON(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_COMMON) return (opt_AVX512_COMMON::fn args) +# define CV_CPU_CALL_AVX512_COMMON_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_COMMON) return (opt_AVX512_COMMON::fn args) +#else +# define CV_TRY_AVX512_COMMON 0 +# define CV_CPU_FORCE_AVX512_COMMON 0 +# define CV_CPU_HAS_SUPPORT_AVX512_COMMON 0 +# define CV_CPU_CALL_AVX512_COMMON(fn, args) +# define CV_CPU_CALL_AVX512_COMMON_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_COMMON(fn, args, mode, ...) CV_CPU_CALL_AVX512_COMMON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_KNL +# define CV_TRY_AVX512_KNL 1 +# define CV_CPU_FORCE_AVX512_KNL 1 +# define CV_CPU_HAS_SUPPORT_AVX512_KNL 1 +# define CV_CPU_CALL_AVX512_KNL(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_KNL_(fn, args) return (opt_AVX512_KNL::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_KNL +# define CV_TRY_AVX512_KNL 1 +# define CV_CPU_FORCE_AVX512_KNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNL (cv::checkHardwareSupport(CV_CPU_AVX512_KNL)) +# define CV_CPU_CALL_AVX512_KNL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNL) return (opt_AVX512_KNL::fn args) +# define CV_CPU_CALL_AVX512_KNL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNL) return (opt_AVX512_KNL::fn args) +#else +# define CV_TRY_AVX512_KNL 0 +# define CV_CPU_FORCE_AVX512_KNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNL 0 +# define CV_CPU_CALL_AVX512_KNL(fn, args) +# define CV_CPU_CALL_AVX512_KNL_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_KNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_KNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_KNM +# define CV_TRY_AVX512_KNM 1 +# define CV_CPU_FORCE_AVX512_KNM 1 +# define CV_CPU_HAS_SUPPORT_AVX512_KNM 1 +# define CV_CPU_CALL_AVX512_KNM(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_KNM_(fn, args) return (opt_AVX512_KNM::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_KNM +# define CV_TRY_AVX512_KNM 1 +# define CV_CPU_FORCE_AVX512_KNM 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNM (cv::checkHardwareSupport(CV_CPU_AVX512_KNM)) +# define CV_CPU_CALL_AVX512_KNM(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNM) return (opt_AVX512_KNM::fn args) +# define CV_CPU_CALL_AVX512_KNM_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNM) return (opt_AVX512_KNM::fn args) +#else +# define CV_TRY_AVX512_KNM 0 +# define CV_CPU_FORCE_AVX512_KNM 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNM 0 +# define CV_CPU_CALL_AVX512_KNM(fn, args) +# define CV_CPU_CALL_AVX512_KNM_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_KNM(fn, args, mode, ...) CV_CPU_CALL_AVX512_KNM(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_SKX +# define CV_TRY_AVX512_SKX 1 +# define CV_CPU_FORCE_AVX512_SKX 1 +# define CV_CPU_HAS_SUPPORT_AVX512_SKX 1 +# define CV_CPU_CALL_AVX512_SKX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_SKX_(fn, args) return (opt_AVX512_SKX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_SKX +# define CV_TRY_AVX512_SKX 1 +# define CV_CPU_FORCE_AVX512_SKX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_SKX (cv::checkHardwareSupport(CV_CPU_AVX512_SKX)) +# define CV_CPU_CALL_AVX512_SKX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_SKX) return (opt_AVX512_SKX::fn args) +# define CV_CPU_CALL_AVX512_SKX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_SKX) return (opt_AVX512_SKX::fn args) +#else +# define CV_TRY_AVX512_SKX 0 +# define CV_CPU_FORCE_AVX512_SKX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_SKX 0 +# define CV_CPU_CALL_AVX512_SKX(fn, args) +# define CV_CPU_CALL_AVX512_SKX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_SKX(fn, args, mode, ...) CV_CPU_CALL_AVX512_SKX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CNL +# define CV_TRY_AVX512_CNL 1 +# define CV_CPU_FORCE_AVX512_CNL 1 +# define CV_CPU_HAS_SUPPORT_AVX512_CNL 1 +# define CV_CPU_CALL_AVX512_CNL(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_CNL_(fn, args) return (opt_AVX512_CNL::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CNL +# define CV_TRY_AVX512_CNL 1 +# define CV_CPU_FORCE_AVX512_CNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CNL (cv::checkHardwareSupport(CV_CPU_AVX512_CNL)) +# define CV_CPU_CALL_AVX512_CNL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CNL) return (opt_AVX512_CNL::fn args) +# define CV_CPU_CALL_AVX512_CNL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CNL) return (opt_AVX512_CNL::fn args) +#else +# define CV_TRY_AVX512_CNL 0 +# define CV_CPU_FORCE_AVX512_CNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CNL 0 +# define CV_CPU_CALL_AVX512_CNL(fn, args) +# define CV_CPU_CALL_AVX512_CNL_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_CNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CLX +# define CV_TRY_AVX512_CLX 1 +# define CV_CPU_FORCE_AVX512_CLX 1 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX 1 +# define CV_CPU_CALL_AVX512_CLX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) return (opt_AVX512_CLX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CLX +# define CV_TRY_AVX512_CLX 1 +# define CV_CPU_FORCE_AVX512_CLX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX (cv::checkHardwareSupport(CV_CPU_AVX512_CLX)) +# define CV_CPU_CALL_AVX512_CLX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args) +#else +# define CV_TRY_AVX512_CLX 0 +# define CV_CPU_FORCE_AVX512_CLX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX 0 +# define CV_CPU_CALL_AVX512_CLX(fn, args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_CLX(fn, args, mode, ...) CV_CPU_CALL_AVX512_CLX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_ICL +# define CV_TRY_AVX512_ICL 1 +# define CV_CPU_FORCE_AVX512_ICL 1 +# define CV_CPU_HAS_SUPPORT_AVX512_ICL 1 +# define CV_CPU_CALL_AVX512_ICL(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_ICL_(fn, args) return (opt_AVX512_ICL::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_ICL +# define CV_TRY_AVX512_ICL 1 +# define CV_CPU_FORCE_AVX512_ICL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_ICL (cv::checkHardwareSupport(CV_CPU_AVX512_ICL)) +# define CV_CPU_CALL_AVX512_ICL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_ICL) return (opt_AVX512_ICL::fn args) +# define CV_CPU_CALL_AVX512_ICL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_ICL) return (opt_AVX512_ICL::fn args) +#else +# define CV_TRY_AVX512_ICL 0 +# define CV_CPU_FORCE_AVX512_ICL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_ICL 0 +# define CV_CPU_CALL_AVX512_ICL(fn, args) +# define CV_CPU_CALL_AVX512_ICL_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_ICL(fn, args, mode, ...) CV_CPU_CALL_AVX512_ICL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON +# define CV_TRY_NEON 1 +# define CV_CPU_FORCE_NEON 1 +# define CV_CPU_HAS_SUPPORT_NEON 1 +# define CV_CPU_CALL_NEON(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_NEON_(fn, args) return (opt_NEON::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON +# define CV_TRY_NEON 1 +# define CV_CPU_FORCE_NEON 0 +# define CV_CPU_HAS_SUPPORT_NEON (cv::checkHardwareSupport(CV_CPU_NEON)) +# define CV_CPU_CALL_NEON(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args) +# define CV_CPU_CALL_NEON_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args) +#else +# define CV_TRY_NEON 0 +# define CV_CPU_FORCE_NEON 0 +# define CV_CPU_HAS_SUPPORT_NEON 0 +# define CV_CPU_CALL_NEON(fn, args) +# define CV_CPU_CALL_NEON_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_MSA +# define CV_TRY_MSA 1 +# define CV_CPU_FORCE_MSA 1 +# define CV_CPU_HAS_SUPPORT_MSA 1 +# define CV_CPU_CALL_MSA(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_MSA_(fn, args) return (opt_MSA::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_MSA +# define CV_TRY_MSA 1 +# define CV_CPU_FORCE_MSA 0 +# define CV_CPU_HAS_SUPPORT_MSA (cv::checkHardwareSupport(CV_CPU_MSA)) +# define CV_CPU_CALL_MSA(fn, args) if (CV_CPU_HAS_SUPPORT_MSA) return (opt_MSA::fn args) +# define CV_CPU_CALL_MSA_(fn, args) if (CV_CPU_HAS_SUPPORT_MSA) return (opt_MSA::fn args) +#else +# define CV_TRY_MSA 0 +# define CV_CPU_FORCE_MSA 0 +# define CV_CPU_HAS_SUPPORT_MSA 0 +# define CV_CPU_CALL_MSA(fn, args) +# define CV_CPU_CALL_MSA_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_MSA(fn, args, mode, ...) CV_CPU_CALL_MSA(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX +# define CV_TRY_VSX 1 +# define CV_CPU_FORCE_VSX 1 +# define CV_CPU_HAS_SUPPORT_VSX 1 +# define CV_CPU_CALL_VSX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_VSX_(fn, args) return (opt_VSX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX +# define CV_TRY_VSX 1 +# define CV_CPU_FORCE_VSX 0 +# define CV_CPU_HAS_SUPPORT_VSX (cv::checkHardwareSupport(CV_CPU_VSX)) +# define CV_CPU_CALL_VSX(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args) +# define CV_CPU_CALL_VSX_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args) +#else +# define CV_TRY_VSX 0 +# define CV_CPU_FORCE_VSX 0 +# define CV_CPU_HAS_SUPPORT_VSX 0 +# define CV_CPU_CALL_VSX(fn, args) +# define CV_CPU_CALL_VSX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_VSX(fn, args, mode, ...) CV_CPU_CALL_VSX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX3 +# define CV_TRY_VSX3 1 +# define CV_CPU_FORCE_VSX3 1 +# define CV_CPU_HAS_SUPPORT_VSX3 1 +# define CV_CPU_CALL_VSX3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_VSX3_(fn, args) return (opt_VSX3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX3 +# define CV_TRY_VSX3 1 +# define CV_CPU_FORCE_VSX3 0 +# define CV_CPU_HAS_SUPPORT_VSX3 (cv::checkHardwareSupport(CV_CPU_VSX3)) +# define CV_CPU_CALL_VSX3(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args) +# define CV_CPU_CALL_VSX3_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args) +#else +# define CV_TRY_VSX3 0 +# define CV_CPU_FORCE_VSX3 0 +# define CV_CPU_HAS_SUPPORT_VSX3 0 +# define CV_CPU_CALL_VSX3(fn, args) +# define CV_CPU_CALL_VSX3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_VSX3(fn, args, mode, ...) CV_CPU_CALL_VSX3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_RVV +# define CV_TRY_RVV 1 +# define CV_CPU_FORCE_RVV 1 +# define CV_CPU_HAS_SUPPORT_RVV 1 +# define CV_CPU_CALL_RVV(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_RVV_(fn, args) return (opt_RVV::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_RVV +# define CV_TRY_RVV 1 +# define CV_CPU_FORCE_RVV 0 +# define CV_CPU_HAS_SUPPORT_RVV (cv::checkHardwareSupport(CV_CPU_RVV)) +# define CV_CPU_CALL_RVV(fn, args) if (CV_CPU_HAS_SUPPORT_RVV) return (opt_RVV::fn args) +# define CV_CPU_CALL_RVV_(fn, args) if (CV_CPU_HAS_SUPPORT_RVV) return (opt_RVV::fn args) +#else +# define CV_TRY_RVV 0 +# define CV_CPU_FORCE_RVV 0 +# define CV_CPU_HAS_SUPPORT_RVV 0 +# define CV_CPU_CALL_RVV(fn, args) +# define CV_CPU_CALL_RVV_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_RVV(fn, args, mode, ...) CV_CPU_CALL_RVV(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args) +#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cvdef.h b/Cigarette/OpenCV455Simple/include/opencv2/core/cvdef.h new file mode 100644 index 0000000..f785f32 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cvdef.h @@ -0,0 +1,967 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CVDEF_H +#define OPENCV_CORE_CVDEF_H + +#include "opencv2/core/version.hpp" + +//! @addtogroup core_utils +//! @{ + +#ifdef OPENCV_INCLUDE_PORT_FILE // User-provided header file with custom platform configuration +#include OPENCV_INCLUDE_PORT_FILE +#endif + +#if !defined CV_DOXYGEN && !defined CV_IGNORE_DEBUG_BUILD_GUARD +#if (defined(_MSC_VER) && (defined(DEBUG) || defined(_DEBUG))) || \ + (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_DEBUG_PEDANTIC)) +// Guard to prevent using of binary incompatible binaries / runtimes +// https://github.com/opencv/opencv/pull/9161 +#define CV__DEBUG_NS_BEGIN namespace debug_build_guard { +#define CV__DEBUG_NS_END } +namespace cv { namespace debug_build_guard { } using namespace debug_build_guard; } +#endif +#endif + +#ifndef CV__DEBUG_NS_BEGIN +#define CV__DEBUG_NS_BEGIN +#define CV__DEBUG_NS_END +#endif + + +#ifdef __OPENCV_BUILD +#include "cvconfig.h" +#endif + +#ifndef __CV_EXPAND +#define __CV_EXPAND(x) x +#endif + +#ifndef __CV_CAT +#define __CV_CAT__(x, y) x ## y +#define __CV_CAT_(x, y) __CV_CAT__(x, y) +#define __CV_CAT(x, y) __CV_CAT_(x, y) +#endif + +#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N +#define __CV_VA_NUM_ARGS(...) __CV_EXPAND(__CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) + +#ifdef CV_Func +// keep current value (through OpenCV port file) +#elif defined __GNUC__ || (defined (__cpluscplus) && (__cpluscplus >= 201103)) +#define CV_Func __func__ +#elif defined __clang__ && (__clang_minor__ * 100 + __clang_major__ >= 305) +#define CV_Func __func__ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION >= 199901) +#define CV_Func __func__ +#elif defined _MSC_VER +#define CV_Func __FUNCTION__ +#elif defined(__INTEL_COMPILER) && (_INTEL_COMPILER >= 600) +#define CV_Func __FUNCTION__ +#elif defined __IBMCPP__ && __IBMCPP__ >=500 +#define CV_Func __FUNCTION__ +#elif defined __BORLAND__ && (__BORLANDC__ >= 0x550) +#define CV_Func __FUNC__ +#else +#define CV_Func "" +#endif + +//! @cond IGNORED + +//////////////// static assert ///////////////// +#define CVAUX_CONCAT_EXP(a, b) a##b +#define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b) + +#if defined(__clang__) +# ifndef __has_extension +# define __has_extension __has_feature /* compatibility, for older versions of clang */ +# endif +# if __has_extension(cxx_static_assert) +# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) +# elif __has_extension(c_static_assert) +# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition) +# endif +#elif defined(__GNUC__) +# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) +# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) +# endif +#elif defined(_MSC_VER) +# if _MSC_VER >= 1600 /* MSVC 10 */ +# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) +# endif +#endif +#ifndef CV_StaticAssert +# if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302) +# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); }) +# else +namespace cv { + template struct CV_StaticAssert_failed; + template <> struct CV_StaticAssert_failed { enum { val = 1 }; }; + template struct CV_StaticAssert_test {}; +} +# define CV_StaticAssert(condition, reason)\ + typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__) +# endif +#endif + +// Suppress warning "-Wdeprecated-declarations" / C4996 +#if defined(_MSC_VER) + #define CV_DO_PRAGMA(x) __pragma(x) +#elif defined(__GNUC__) + #define CV_DO_PRAGMA(x) _Pragma (#x) +#else + #define CV_DO_PRAGMA(x) +#endif + +#ifdef _MSC_VER +#define CV_SUPPRESS_DEPRECATED_START \ + CV_DO_PRAGMA(warning(push)) \ + CV_DO_PRAGMA(warning(disable: 4996)) +#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop)) +#elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405)) +#define CV_SUPPRESS_DEPRECATED_START \ + CV_DO_PRAGMA(GCC diagnostic push) \ + CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop) +#else +#define CV_SUPPRESS_DEPRECATED_START +#define CV_SUPPRESS_DEPRECATED_END +#endif + +#define CV_UNUSED(name) (void)name + +//! @endcond + +// undef problematic defines sometimes defined by system headers (windows.h in particular) +#undef small +#undef min +#undef max +#undef abs +#undef Complex + +#if defined __cplusplus +#include +#else +#include +#endif + +#include "opencv2/core/hal/interface.h" + +#if defined __ICL +# define CV_ICC __ICL +#elif defined __ICC +# define CV_ICC __ICC +#elif defined __ECL +# define CV_ICC __ECL +#elif defined __ECC +# define CV_ICC __ECC +#elif defined __INTEL_COMPILER +# define CV_ICC __INTEL_COMPILER +#endif + +#ifndef CV_INLINE +# if defined __cplusplus +# define CV_INLINE static inline +# elif defined _MSC_VER +# define CV_INLINE __inline +# else +# define CV_INLINE static +# endif +#endif + +#ifndef CV_ALWAYS_INLINE +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#define CV_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define CV_ALWAYS_INLINE __forceinline +#else +#define CV_ALWAYS_INLINE inline +#endif +#endif + +#if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED) +# define CV_ENABLE_UNROLLED 0 +#else +# define CV_ENABLE_UNROLLED 1 +#endif + +#ifdef __GNUC__ +# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x))) +#elif defined _MSC_VER +# define CV_DECL_ALIGNED(x) __declspec(align(x)) +#else +# define CV_DECL_ALIGNED(x) +#endif + +/* CPU features and intrinsics support */ +#define CV_CPU_NONE 0 +#define CV_CPU_MMX 1 +#define CV_CPU_SSE 2 +#define CV_CPU_SSE2 3 +#define CV_CPU_SSE3 4 +#define CV_CPU_SSSE3 5 +#define CV_CPU_SSE4_1 6 +#define CV_CPU_SSE4_2 7 +#define CV_CPU_POPCNT 8 +#define CV_CPU_FP16 9 +#define CV_CPU_AVX 10 +#define CV_CPU_AVX2 11 +#define CV_CPU_FMA3 12 + +#define CV_CPU_AVX_512F 13 +#define CV_CPU_AVX_512BW 14 +#define CV_CPU_AVX_512CD 15 +#define CV_CPU_AVX_512DQ 16 +#define CV_CPU_AVX_512ER 17 +#define CV_CPU_AVX_512IFMA512 18 // deprecated +#define CV_CPU_AVX_512IFMA 18 +#define CV_CPU_AVX_512PF 19 +#define CV_CPU_AVX_512VBMI 20 +#define CV_CPU_AVX_512VL 21 +#define CV_CPU_AVX_512VBMI2 22 +#define CV_CPU_AVX_512VNNI 23 +#define CV_CPU_AVX_512BITALG 24 +#define CV_CPU_AVX_512VPOPCNTDQ 25 +#define CV_CPU_AVX_5124VNNIW 26 +#define CV_CPU_AVX_5124FMAPS 27 + +#define CV_CPU_NEON 100 + +#define CV_CPU_MSA 150 + +#define CV_CPU_RISCVV 170 + +#define CV_CPU_VSX 200 +#define CV_CPU_VSX3 201 + +#define CV_CPU_RVV 210 + +// CPU features groups +#define CV_CPU_AVX512_SKX 256 +#define CV_CPU_AVX512_COMMON 257 +#define CV_CPU_AVX512_KNL 258 +#define CV_CPU_AVX512_KNM 259 +#define CV_CPU_AVX512_CNL 260 +#define CV_CPU_AVX512_CLX 261 +#define CV_CPU_AVX512_ICL 262 + +// when adding to this list remember to update the following enum +#define CV_HARDWARE_MAX_FEATURE 512 + +/** @brief Available CPU features. +*/ +enum CpuFeatures { + CPU_MMX = 1, + CPU_SSE = 2, + CPU_SSE2 = 3, + CPU_SSE3 = 4, + CPU_SSSE3 = 5, + CPU_SSE4_1 = 6, + CPU_SSE4_2 = 7, + CPU_POPCNT = 8, + CPU_FP16 = 9, + CPU_AVX = 10, + CPU_AVX2 = 11, + CPU_FMA3 = 12, + + CPU_AVX_512F = 13, + CPU_AVX_512BW = 14, + CPU_AVX_512CD = 15, + CPU_AVX_512DQ = 16, + CPU_AVX_512ER = 17, + CPU_AVX_512IFMA512 = 18, // deprecated + CPU_AVX_512IFMA = 18, + CPU_AVX_512PF = 19, + CPU_AVX_512VBMI = 20, + CPU_AVX_512VL = 21, + CPU_AVX_512VBMI2 = 22, + CPU_AVX_512VNNI = 23, + CPU_AVX_512BITALG = 24, + CPU_AVX_512VPOPCNTDQ= 25, + CPU_AVX_5124VNNIW = 26, + CPU_AVX_5124FMAPS = 27, + + CPU_NEON = 100, + + CPU_MSA = 150, + + CPU_RISCVV = 170, + + CPU_VSX = 200, + CPU_VSX3 = 201, + + CPU_RVV = 210, + + CPU_AVX512_SKX = 256, //!< Skylake-X with AVX-512F/CD/BW/DQ/VL + CPU_AVX512_COMMON = 257, //!< Common instructions AVX-512F/CD for all CPUs that support AVX-512 + CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF + CPU_AVX512_KNM = 259, //!< Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ + CPU_AVX512_CNL = 260, //!< Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI + CPU_AVX512_CLX = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI + CPU_AVX512_ICL = 262, //!< Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ + + CPU_MAX_FEATURE = 512 // see CV_HARDWARE_MAX_FEATURE +}; + + +#include "cv_cpu_dispatch.h" + +#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64)) +// int*, int64* should be propertly aligned pointers on ARMv7 +#define CV_STRONG_ALIGNMENT 1 +#endif +#if !defined(CV_STRONG_ALIGNMENT) +#define CV_STRONG_ALIGNMENT 0 +#endif + +/* fundamental constants */ +#define CV_PI 3.1415926535897932384626433832795 +#define CV_2PI 6.283185307179586476925286766559 +#define CV_LOG2 0.69314718055994530941723212145818 + +#if defined __ARM_FP16_FORMAT_IEEE \ + && !defined __CUDACC__ +# define CV_FP16_TYPE 1 +#else +# define CV_FP16_TYPE 0 +#endif + +typedef union Cv16suf +{ + short i; + ushort u; +#if CV_FP16_TYPE + __fp16 h; +#endif +} +Cv16suf; + +typedef union Cv32suf +{ + int i; + unsigned u; + float f; +} +Cv32suf; + +typedef union Cv64suf +{ + int64 i; + uint64 u; + double f; +} +Cv64suf; + +#ifndef OPENCV_ABI_COMPATIBILITY +#define OPENCV_ABI_COMPATIBILITY 400 +#endif + +#ifdef __OPENCV_BUILD +# define DISABLE_OPENCV_3_COMPATIBILITY +# define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY +#endif + +#ifndef CV_EXPORTS +# if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined(CVAPI_EXPORTS) +# define CV_EXPORTS __declspec(dllexport) +# elif defined __GNUC__ && __GNUC__ >= 4 && (defined(CVAPI_EXPORTS) || defined(__APPLE__)) +# define CV_EXPORTS __attribute__ ((visibility ("default"))) +# endif +#endif + +#ifndef CV_EXPORTS +# define CV_EXPORTS +#endif + +#ifdef _MSC_VER +# define CV_EXPORTS_TEMPLATE +#else +# define CV_EXPORTS_TEMPLATE CV_EXPORTS +#endif + +#ifndef CV_DEPRECATED +# if defined(__GNUC__) +# define CV_DEPRECATED __attribute__ ((deprecated)) +# elif defined(_MSC_VER) +# define CV_DEPRECATED __declspec(deprecated) +# else +# define CV_DEPRECATED +# endif +#endif + +#ifndef CV_DEPRECATED_EXTERNAL +# if defined(__OPENCV_BUILD) +# define CV_DEPRECATED_EXTERNAL /* nothing */ +# else +# define CV_DEPRECATED_EXTERNAL CV_DEPRECATED +# endif +#endif + + +#ifndef CV_EXTERN_C +# ifdef __cplusplus +# define CV_EXTERN_C extern "C" +# else +# define CV_EXTERN_C +# endif +#endif + +/* special informative macros for wrapper generators */ +#define CV_EXPORTS_W CV_EXPORTS +#define CV_EXPORTS_W_SIMPLE CV_EXPORTS +#define CV_EXPORTS_AS(synonym) CV_EXPORTS +#define CV_EXPORTS_W_MAP CV_EXPORTS +#define CV_IN_OUT +#define CV_OUT +#define CV_PROP +#define CV_PROP_RW +#define CV_WRAP +#define CV_WRAP_AS(synonym) +#define CV_WRAP_MAPPABLE(mappable) +#define CV_WRAP_PHANTOM(phantom_header) +#define CV_WRAP_DEFAULT(val) + +/****************************************************************************************\ +* Matrix type (Mat) * +\****************************************************************************************/ + +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_CONT_FLAG_SHIFT 14 +#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) +#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) +#define CV_IS_CONT_MAT CV_IS_MAT_CONT +#define CV_SUBMAT_FLAG_SHIFT 15 +#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT) +#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG) + +/** Size of each channel item, + 0x28442211 = 0010 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ +#define CV_ELEM_SIZE1(type) ((0x28442211 >> CV_MAT_DEPTH(type)*4) & 15) + +#define CV_ELEM_SIZE(type) (CV_MAT_CN(type)*CV_ELEM_SIZE1(type)) + +#ifndef MIN +# define MIN(a,b) ((a) > (b) ? (b) : (a)) +#endif + +#ifndef MAX +# define MAX(a,b) ((a) < (b) ? (b) : (a)) +#endif + +///////////////////////////////////////// Enum operators /////////////////////////////////////// + +/** + +Provides compatibility operators for both classical and C++11 enum classes, +as well as exposing the C++11 enum class members for backwards compatibility + +@code + // Provides operators required for flag enums + CV_ENUM_FLAGS(AccessFlag) + + // Exposes the listed members of the enum class AccessFlag to the current namespace + CV_ENUM_CLASS_EXPOSE(AccessFlag, ACCESS_READ [, ACCESS_WRITE [, ...] ]); +@endcode +*/ + +#define __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST) \ +static const EnumType MEMBER_CONST = EnumType::MEMBER_CONST; \ + +#define __CV_ENUM_CLASS_EXPOSE_2(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_1(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_3(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_2(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_4(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_3(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_5(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_4(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_6(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_5(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_7(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_6(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_8(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_7(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_9(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_8(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_FLAGS_LOGICAL_NOT(EnumType) \ +static inline bool operator!(const EnumType& val) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return !static_cast(val); \ +} \ + +#define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \ +static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \ +{ \ + return static_cast(a) != static_cast(b); \ +} \ + +#define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \ +static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \ +{ \ + return static_cast(a) == static_cast(b); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \ +static inline EnumType operator~(const EnumType& val) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(~static_cast(val)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \ +static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(static_cast(a) | static_cast(b)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \ +static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(static_cast(a) & static_cast(b)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \ +static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(static_cast(a) ^ static_cast(b)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \ +static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \ +{ \ + _this = static_cast(static_cast(_this) | static_cast(val)); \ + return _this; \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \ +static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \ +{ \ + _this = static_cast(static_cast(_this) & static_cast(val)); \ + return _this; \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \ +static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \ +{ \ + _this = static_cast(static_cast(_this) ^ static_cast(val)); \ + return _this; \ +} \ + +#define CV_ENUM_CLASS_EXPOSE(EnumType, ...) \ +__CV_EXPAND(__CV_CAT(__CV_ENUM_CLASS_EXPOSE_, __CV_VA_NUM_ARGS(__VA_ARGS__))(EnumType, __VA_ARGS__)); \ + +#define CV_ENUM_FLAGS(EnumType) \ +__CV_ENUM_FLAGS_LOGICAL_NOT (EnumType) \ +__CV_ENUM_FLAGS_LOGICAL_EQ (EnumType, int) \ +__CV_ENUM_FLAGS_LOGICAL_NOT_EQ (EnumType, int) \ + \ +__CV_ENUM_FLAGS_BITWISE_NOT (EnumType) \ +__CV_ENUM_FLAGS_BITWISE_OR (EnumType, EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_AND (EnumType, EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_XOR (EnumType, EnumType, EnumType) \ + \ +__CV_ENUM_FLAGS_BITWISE_OR_EQ (EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_AND_EQ (EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType) \ + +/****************************************************************************************\ +* static analysys * +\****************************************************************************************/ + +// In practice, some macro are not processed correctly (noreturn is not detected). +// We need to use simplified definition for them. +#ifndef CV_STATIC_ANALYSIS +# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__) +# define CV_STATIC_ANALYSIS 1 +# endif +#else +# if defined(CV_STATIC_ANALYSIS) && !(__CV_CAT(1, CV_STATIC_ANALYSIS) == 1) // defined and not empty +# if 0 == CV_STATIC_ANALYSIS +# undef CV_STATIC_ANALYSIS +# endif +# endif +#endif + +/****************************************************************************************\ +* Thread sanitizer * +\****************************************************************************************/ +#ifndef CV_THREAD_SANITIZER +# if defined(__has_feature) +# if __has_feature(thread_sanitizer) +# define CV_THREAD_SANITIZER +# endif +# endif +#endif + +/****************************************************************************************\ +* exchange-add operation for atomic operations on reference counters * +\****************************************************************************************/ + +#ifdef CV_XADD + // allow to use user-defined macro +#elif defined __GNUC__ || defined __clang__ +# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER +# ifdef __ATOMIC_ACQ_REL +# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL) +# else +# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4) +# endif +# else +# if defined __ATOMIC_ACQ_REL && !defined __clang__ + // version for gcc >= 4.7 +# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL) +# else +# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta)) +# endif +# endif +#elif defined _MSC_VER && !defined RC_INVOKED +# include +# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta) +#else + #ifdef OPENCV_FORCE_UNSAFE_XADD + CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } + #else + #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)" + #endif +#endif + + +/****************************************************************************************\ +* CV_NORETURN attribute * +\****************************************************************************************/ + +#ifndef CV_NORETURN +# if defined(__GNUC__) +# define CV_NORETURN __attribute__((__noreturn__)) +# elif defined(_MSC_VER) && (_MSC_VER >= 1300) +# define CV_NORETURN __declspec(noreturn) +# else +# define CV_NORETURN /* nothing by default */ +# endif +#endif + +/****************************************************************************************\ +* CV_NODISCARD_STD attribute (C++17) * +* encourages the compiler to issue a warning if the return value is discarded * +\****************************************************************************************/ +#ifndef CV_NODISCARD_STD +# ifndef __has_cpp_attribute +// workaround preprocessor non-compliance https://reviews.llvm.org/D57851 +# define __has_cpp_attribute(__x) 0 +# endif +# if __has_cpp_attribute(nodiscard) +# define CV_NODISCARD_STD [[nodiscard]] +# elif __cplusplus >= 201703L +// available when compiler is C++17 compliant +# define CV_NODISCARD_STD [[nodiscard]] +# elif defined(__INTEL_COMPILER) + // see above, available when C++17 is enabled +# elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L +// available with VS2017 v15.3+ with /std:c++17 or higher; works on functions and classes +# define CV_NODISCARD_STD [[nodiscard]] +# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 700) && (__cplusplus >= 201103L) +// available with GCC 7.0+; works on functions, works or silently fails on classes +# define CV_NODISCARD_STD [[nodiscard]] +# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && (__cplusplus >= 201103L) +// available with GCC 4.8+ but it usually does nothing and can fail noisily -- therefore not used +// define CV_NODISCARD_STD [[gnu::warn_unused_result]] +# endif +#endif +#ifndef CV_NODISCARD_STD +# define CV_NODISCARD_STD /* nothing by default */ +#endif + + +/****************************************************************************************\ +* CV_NODISCARD attribute (deprecated, GCC only) * +* DONT USE: use instead the standard CV_NODISCARD_STD macro above * +* this legacy method silently fails to issue warning until some version * +* after gcc 6.3.0. Yet with gcc 7+ you can use the above standard method * +* which makes this method useless. Don't use it. * +* @deprecated use instead CV_NODISCARD_STD * +\****************************************************************************************/ +#ifndef CV_NODISCARD +# if defined(__GNUC__) +# define CV_NODISCARD __attribute__((__warn_unused_result__)) +# elif defined(__clang__) && defined(__has_attribute) +# if __has_attribute(__warn_unused_result__) +# define CV_NODISCARD __attribute__((__warn_unused_result__)) +# endif +# endif +#endif +#ifndef CV_NODISCARD +# define CV_NODISCARD /* nothing by default */ +#endif + + +/****************************************************************************************\ +* C++ 11 * +\****************************************************************************************/ +#ifndef CV_CXX11 +# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) +# define CV_CXX11 1 +# endif +#else +# if CV_CXX11 == 0 +# undef CV_CXX11 +# endif +#endif +#ifndef CV_CXX11 +# error "OpenCV 4.x+ requires enabled C++11 support" +#endif + +#define CV_CXX_MOVE_SEMANTICS 1 +#define CV_CXX_MOVE(x) std::move(x) +#define CV_CXX_STD_ARRAY 1 +#include +#ifndef CV_OVERRIDE +# define CV_OVERRIDE override +#endif +#ifndef CV_FINAL +# define CV_FINAL final +#endif + +#ifndef CV_NOEXCEPT +# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) +# define CV_NOEXCEPT noexcept +# endif +#endif +#ifndef CV_NOEXCEPT +# define CV_NOEXCEPT +#endif + +#ifndef CV_CONSTEXPR +# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) +# define CV_CONSTEXPR constexpr +# endif +#endif +#ifndef CV_CONSTEXPR +# define CV_CONSTEXPR +#endif + +// Integer types portatibility +#ifdef OPENCV_STDINT_HEADER +#include OPENCV_STDINT_HEADER +#elif defined(__cplusplus) +#if defined(_MSC_VER) && _MSC_VER < 1600 /* MSVS 2010 */ +namespace cv { +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +} +#elif defined(_MSC_VER) || __cplusplus >= 201103L +#include +namespace cv { +using std::int8_t; +using std::uint8_t; +using std::int16_t; +using std::uint16_t; +using std::int32_t; +using std::uint32_t; +using std::int64_t; +using std::uint64_t; +} +#else +#include +namespace cv { +typedef ::int8_t int8_t; +typedef ::uint8_t uint8_t; +typedef ::int16_t int16_t; +typedef ::uint16_t uint16_t; +typedef ::int32_t int32_t; +typedef ::uint32_t uint32_t; +typedef ::int64_t int64_t; +typedef ::uint64_t uint64_t; +} +#endif +#else // pure C +#include +#endif + +#ifdef __cplusplus +namespace cv +{ + +class float16_t +{ +public: +#if CV_FP16_TYPE + + float16_t() : h(0) {} + explicit float16_t(float x) { h = (__fp16)x; } + operator float() const { return (float)h; } + static float16_t fromBits(ushort w) + { + Cv16suf u; + u.u = w; + float16_t result; + result.h = u.h; + return result; + } + static float16_t zero() + { + float16_t result; + result.h = (__fp16)0; + return result; + } + ushort bits() const + { + Cv16suf u; + u.h = h; + return u.u; + } +protected: + __fp16 h; + +#else + float16_t() : w(0) {} + explicit float16_t(float x) + { + #if CV_FP16 + __m128 v = _mm_load_ss(&x); + w = (ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0)); + #else + Cv32suf in; + in.f = x; + unsigned sign = in.u & 0x80000000; + in.u ^= sign; + + if( in.u >= 0x47800000 ) + w = (ushort)(in.u > 0x7f800000 ? 0x7e00 : 0x7c00); + else + { + if (in.u < 0x38800000) + { + in.f += 0.5f; + w = (ushort)(in.u - 0x3f000000); + } + else + { + unsigned t = in.u + 0xc8000fff; + w = (ushort)((t + ((in.u >> 13) & 1)) >> 13); + } + } + + w = (ushort)(w | (sign >> 16)); + #endif + } + + operator float() const + { + #if CV_FP16 + float f; + _mm_store_ss(&f, _mm_cvtph_ps(_mm_cvtsi32_si128(w))); + return f; + #else + Cv32suf out; + + unsigned t = ((w & 0x7fff) << 13) + 0x38000000; + unsigned sign = (w & 0x8000) << 16; + unsigned e = w & 0x7c00; + + out.u = t + (1 << 23); + out.u = (e >= 0x7c00 ? t + 0x38000000 : + e == 0 ? (static_cast(out.f -= 6.103515625e-05f), out.u) : t) | sign; + return out.f; + #endif + } + + static float16_t fromBits(ushort b) + { + float16_t result; + result.w = b; + return result; + } + static float16_t zero() + { + float16_t result; + result.w = (ushort)0; + return result; + } + ushort bits() const { return w; } +protected: + ushort w; + +#endif +}; + +} +#endif + +//! @} + +#ifndef __cplusplus +#include "opencv2/core/fast_math.hpp" // define cvRound(double) +#endif + +#endif // OPENCV_CORE_CVDEF_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd.hpp new file mode 100644 index 0000000..6ce9e4b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd.hpp @@ -0,0 +1,190 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CVSTD_HPP +#define OPENCV_CORE_CVSTD_HPP + +#ifndef __cplusplus +# error cvstd.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" +#include +#include +#include + +#include + +// import useful primitives from stl +# include +# include +# include //for abs(int) +# include + +namespace cv +{ + static inline uchar abs(uchar a) { return a; } + static inline ushort abs(ushort a) { return a; } + static inline unsigned abs(unsigned a) { return a; } + static inline uint64 abs(uint64 a) { return a; } + + using std::min; + using std::max; + using std::abs; + using std::swap; + using std::sqrt; + using std::exp; + using std::pow; + using std::log; +} + +#include "cvstd_wrapper.hpp" + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +//////////////////////////// memory management functions //////////////////////////// + +/** @brief Allocates an aligned memory buffer. + +The function allocates the buffer of the specified size and returns it. When the buffer size is 16 +bytes or more, the returned buffer is aligned to 16 bytes. +@param bufSize Allocated buffer size. + */ +CV_EXPORTS void* fastMalloc(size_t bufSize); + +/** @brief Deallocates a memory buffer. + +The function deallocates the buffer allocated with fastMalloc . If NULL pointer is passed, the +function does nothing. C version of the function clears the pointer *pptr* to avoid problems with +double memory deallocation. +@param ptr Pointer to the allocated buffer. + */ +CV_EXPORTS void fastFree(void* ptr); + +/*! + The STL-compliant memory Allocator based on cv::fastMalloc() and cv::fastFree() +*/ +template class Allocator +{ +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + template class rebind { typedef Allocator other; }; + + explicit Allocator() {} + ~Allocator() {} + explicit Allocator(Allocator const&) {} + template + explicit Allocator(Allocator const&) {} + + // address + pointer address(reference r) { return &r; } + const_pointer address(const_reference r) { return &r; } + + pointer allocate(size_type count, const void* =0) { return reinterpret_cast(fastMalloc(count * sizeof (_Tp))); } + void deallocate(pointer p, size_type) { fastFree(p); } + + void construct(pointer p, const _Tp& v) { new(static_cast(p)) _Tp(v); } + void destroy(pointer p) { p->~_Tp(); } + + size_type max_size() const { return cv::max(static_cast<_Tp>(-1)/sizeof(_Tp), 1); } +}; + +//! @} core_utils + +//! @endcond + +//! @addtogroup core_basic +//! @{ + +//////////////////////////////// string class //////////////////////////////// + +class CV_EXPORTS FileNode; //for string constructor from FileNode + +typedef std::string String; + +#ifndef OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS + +//! @cond IGNORED +namespace details { +// std::tolower is int->int +static inline char char_tolower(char ch) +{ + return (char)std::tolower((int)ch); +} +// std::toupper is int->int +static inline char char_toupper(char ch) +{ + return (char)std::toupper((int)ch); +} +} // namespace details +//! @endcond + +static inline std::string toLowerCase(const std::string& str) +{ + std::string result(str); + std::transform(result.begin(), result.end(), result.begin(), details::char_tolower); + return result; +} + +static inline std::string toUpperCase(const std::string& str) +{ + std::string result(str); + std::transform(result.begin(), result.end(), result.begin(), details::char_toupper); + return result; +} + +#endif // OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS + +//! @} core_basic +} // cv + +#endif //OPENCV_CORE_CVSTD_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd.inl.hpp new file mode 100644 index 0000000..37ad1e6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd.inl.hpp @@ -0,0 +1,197 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CVSTDINL_HPP +#define OPENCV_CORE_CVSTDINL_HPP + +#include +#include +#include + +//! @cond IGNORED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4127 ) +#endif + +namespace cv +{ + +template class DataType< std::complex<_Tp> > +{ +public: + typedef std::complex<_Tp> value_type; + typedef value_type work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + depth = DataType::depth, + channels = 2, + fmt = DataType::fmt + ((channels - 1) << 8), + type = CV_MAKETYPE(depth, channels) }; + + typedef Vec vec_type; +}; + +static inline +std::ostream& operator << (std::ostream& out, Ptr fmtd) +{ + fmtd->reset(); + for(const char* str = fmtd->next(); str; str = fmtd->next()) + out << str; + return out; +} + +static inline +std::ostream& operator << (std::ostream& out, const Mat& mtx) +{ + return out << Formatter::get()->format(mtx); +} + +static inline +std::ostream& operator << (std::ostream& out, const UMat& m) +{ + return out << m.getMat(ACCESS_READ); +} + +template static inline +std::ostream& operator << (std::ostream& out, const Complex<_Tp>& c) +{ + return out << "(" << c.re << "," << c.im << ")"; +} + +template static inline +std::ostream& operator << (std::ostream& out, const std::vector >& vec) +{ + return out << Formatter::get()->format(Mat(vec)); +} + + +template static inline +std::ostream& operator << (std::ostream& out, const std::vector >& vec) +{ + return out << Formatter::get()->format(Mat(vec)); +} + + +template static inline +std::ostream& operator << (std::ostream& out, const Matx<_Tp, m, n>& matx) +{ + return out << Formatter::get()->format(Mat(matx)); +} + +template static inline +std::ostream& operator << (std::ostream& out, const Point_<_Tp>& p) +{ + out << "[" << p.x << ", " << p.y << "]"; + return out; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Point3_<_Tp>& p) +{ + out << "[" << p.x << ", " << p.y << ", " << p.z << "]"; + return out; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec) +{ + out << "["; + if (cv::traits::Depth<_Tp>::value <= CV_32S) + { + for (int i = 0; i < n - 1; ++i) { + out << (int)vec[i] << ", "; + } + out << (int)vec[n-1] << "]"; + } + else + { + for (int i = 0; i < n - 1; ++i) { + out << vec[i] << ", "; + } + out << vec[n-1] << "]"; + } + + return out; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Size_<_Tp>& size) +{ + return out << "[" << size.width << " x " << size.height << "]"; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect) +{ + return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]"; +} + +static inline std::ostream& operator << (std::ostream& out, const MatSize& msize) +{ + int i, dims = msize.dims(); + for( i = 0; i < dims; i++ ) + { + out << msize[i]; + if( i < dims-1 ) + out << " x "; + } + return out; +} + +static inline std::ostream &operator<< (std::ostream &s, cv::Range &r) +{ + return s << "[" << r.start << " : " << r.end << ")"; +} + +} // cv + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +//! @endcond + +#endif // OPENCV_CORE_CVSTDINL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd_wrapper.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd_wrapper.hpp new file mode 100644 index 0000000..25e0041 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/cvstd_wrapper.hpp @@ -0,0 +1,154 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_CVSTD_WRAPPER_HPP +#define OPENCV_CORE_CVSTD_WRAPPER_HPP + +#include "opencv2/core/cvdef.h" + +#include +#include // std::shared_ptr +#include // std::enable_if + +namespace cv { + +using std::nullptr_t; + +//! @addtogroup core_basic +//! @{ + +#ifdef CV_DOXYGEN + +template using Ptr = std::shared_ptr<_Tp>; // In ideal world it should look like this, but we need some compatibility workarounds below + +template static inline +Ptr<_Tp> makePtr(const A1&... a1) { return std::make_shared<_Tp>(a1...); } + +#else // cv::Ptr with compatibility workarounds + +// It should be defined for C-API types only. +// C++ types should use regular "delete" operator. +template struct DefaultDeleter; +#if 0 +{ + void operator()(Y* p) const; +}; +#endif + +namespace sfinae { +template +struct has_parenthesis_operator +{ +private: + template + static CV_CONSTEXPR std::true_type has_parenthesis_operator_check(typename std::is_same().operator()(std::declval()...))>::type, Ret>::type*); + + template static CV_CONSTEXPR std::false_type has_parenthesis_operator_check(...); + + typedef decltype(has_parenthesis_operator_check(0)) type; + +public: +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) + static CV_CONSTEXPR bool value = type::value; +#else + // support MSVS 2013 + static const int value = type::value; +#endif +}; +} // namespace sfinae + +template +struct has_custom_delete + : public std::false_type {}; + +// Force has_custom_delete to std::false_type when NVCC is compiling CUDA source files +#ifndef __CUDACC__ +template +struct has_custom_delete, void, T*>::value >::type > + : public std::true_type {}; +#endif + +template +struct Ptr : public std::shared_ptr +{ +#if 0 + using std::shared_ptr::shared_ptr; // GCC 5.x can't handle this +#else + inline Ptr() CV_NOEXCEPT : std::shared_ptr() {} + inline Ptr(nullptr_t) CV_NOEXCEPT : std::shared_ptr(nullptr) {} + template inline Ptr(Y* p, D d) : std::shared_ptr(p, d) {} + template inline Ptr(nullptr_t, D d) : std::shared_ptr(nullptr, d) {} + + template inline Ptr(const Ptr& r, T* ptr) CV_NOEXCEPT : std::shared_ptr(r, ptr) {} + + inline Ptr(const Ptr& o) CV_NOEXCEPT : std::shared_ptr(o) {} + inline Ptr(Ptr&& o) CV_NOEXCEPT : std::shared_ptr(std::move(o)) {} + + template inline Ptr(const Ptr& o) CV_NOEXCEPT : std::shared_ptr(o) {} + template inline Ptr(Ptr&& o) CV_NOEXCEPT : std::shared_ptr(std::move(o)) {} +#endif + inline Ptr(const std::shared_ptr& o) CV_NOEXCEPT : std::shared_ptr(o) {} + inline Ptr(std::shared_ptr&& o) CV_NOEXCEPT : std::shared_ptr(std::move(o)) {} + + // Overload with custom DefaultDeleter: Ptr(...) + template + inline Ptr(const std::true_type&, Y* ptr) : std::shared_ptr(ptr, DefaultDeleter()) {} + + // Overload without custom deleter: Ptr(...); + template + inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr(ptr) {} + + template + inline Ptr(Y* ptr) : Ptr(has_custom_delete(), ptr) {} + + // Overload with custom DefaultDeleter: Ptr(...) + template + inline void reset(const std::true_type&, Y* ptr) { std::shared_ptr::reset(ptr, DefaultDeleter()); } + + // Overload without custom deleter: Ptr(...); + template + inline void reset(const std::false_type&, Y* ptr) { std::shared_ptr::reset(ptr); } + + template + inline void reset(Y* ptr) { Ptr::reset(has_custom_delete(), ptr); } + + template + void reset(Y* ptr, Deleter d) { std::shared_ptr::reset(ptr, d); } + + void reset() CV_NOEXCEPT { std::shared_ptr::reset(); } + + Ptr& operator=(const Ptr& o) { std::shared_ptr::operator =(o); return *this; } + template inline Ptr& operator=(const Ptr& o) { std::shared_ptr::operator =(o); return *this; } + + T* operator->() const CV_NOEXCEPT { return std::shared_ptr::get();} + typename std::add_lvalue_reference::type operator*() const CV_NOEXCEPT { return *std::shared_ptr::get(); } + + // OpenCV 3.x methods (not a part of standard C++ library) + inline void release() { std::shared_ptr::reset(); } + inline operator T* () const { return std::shared_ptr::get(); } + inline bool empty() const { return std::shared_ptr::get() == nullptr; } + + template inline + Ptr staticCast() const CV_NOEXCEPT { return std::static_pointer_cast(*this); } + + template inline + Ptr constCast() const CV_NOEXCEPT { return std::const_pointer_cast(*this); } + + template inline + Ptr dynamicCast() const CV_NOEXCEPT { return std::dynamic_pointer_cast(*this); } +}; + +template static inline +Ptr<_Tp> makePtr(const A1&... a1) +{ + static_assert( !has_custom_delete<_Tp>::value, "Can't use this makePtr with custom DefaultDeleter"); + return (Ptr<_Tp>)std::make_shared<_Tp>(a1...); +} + +#endif // CV_DOXYGEN + +//! @} core_basic +} // cv + +#endif //OPENCV_CORE_CVSTD_WRAPPER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/detail/async_promise.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/detail/async_promise.hpp new file mode 100644 index 0000000..6eb3fb5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/detail/async_promise.hpp @@ -0,0 +1,71 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ASYNC_PROMISE_HPP +#define OPENCV_CORE_ASYNC_PROMISE_HPP + +#include "../async.hpp" + +#include "exception_ptr.hpp" + +namespace cv { + +/** @addtogroup core_async +@{ +*/ + + +/** @brief Provides result of asynchronous operations + +*/ +class CV_EXPORTS AsyncPromise +{ +public: + ~AsyncPromise() CV_NOEXCEPT; + AsyncPromise() CV_NOEXCEPT; + explicit AsyncPromise(const AsyncPromise& o) CV_NOEXCEPT; + AsyncPromise& operator=(const AsyncPromise& o) CV_NOEXCEPT; + void release() CV_NOEXCEPT; + + /** Returns associated AsyncArray + @note Can be called once + */ + AsyncArray getArrayResult(); + + /** Stores asynchronous result. + @param[in] value result + */ + void setValue(InputArray value); + + // TODO "move" setters + +#if CV__EXCEPTION_PTR + /** Stores exception. + @param[in] exception exception to be raised in AsyncArray + */ + void setException(std::exception_ptr exception); +#endif + + /** Stores exception. + @param[in] exception exception to be raised in AsyncArray + */ + void setException(const cv::Exception& exception); + +#ifdef CV_CXX11 + explicit AsyncPromise(AsyncPromise&& o) { p = o.p; o.p = NULL; } + AsyncPromise& operator=(AsyncPromise&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; } +#endif + + + // PImpl + typedef struct AsyncArray::Impl Impl; friend struct AsyncArray::Impl; + inline void* _getImpl() const CV_NOEXCEPT { return p; } +protected: + Impl* p; +}; + + +//! @} +} // namespace +#endif // OPENCV_CORE_ASYNC_PROMISE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/detail/dispatch_helper.impl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/detail/dispatch_helper.impl.hpp new file mode 100644 index 0000000..d6ec676 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/detail/dispatch_helper.impl.hpp @@ -0,0 +1,49 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP +#define OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP + +//! @cond IGNORED + +namespace cv { +namespace detail { + +template class Functor, typename... Args> +static inline void depthDispatch(const int depth, Args&&... args) +{ + switch (depth) + { + case CV_8U: + Functor{}(std::forward(args)...); + break; + case CV_8S: + Functor{}(std::forward(args)...); + break; + case CV_16U: + Functor{}(std::forward(args)...); + break; + case CV_16S: + Functor{}(std::forward(args)...); + break; + case CV_32S: + Functor{}(std::forward(args)...); + break; + case CV_32F: + Functor{}(std::forward(args)...); + break; + case CV_64F: + Functor{}(std::forward(args)...); + break; + case CV_16F: + default: + CV_Error(cv::Error::BadDepth, "Unsupported matrix type."); + }; +} + +}} + +//! @endcond + +#endif //OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/detail/exception_ptr.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/detail/exception_ptr.hpp new file mode 100644 index 0000000..d98ffc4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/detail/exception_ptr.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_DETAILS_EXCEPTION_PTR_H +#define OPENCV_CORE_DETAILS_EXCEPTION_PTR_H + +#ifndef CV__EXCEPTION_PTR +# if defined(__ANDROID__) && defined(ATOMIC_INT_LOCK_FREE) && ATOMIC_INT_LOCK_FREE < 2 +# define CV__EXCEPTION_PTR 0 // Not supported, details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58938 +# elif defined(CV_CXX11) +# define CV__EXCEPTION_PTR 1 +# elif defined(_MSC_VER) +# define CV__EXCEPTION_PTR (_MSC_VER >= 1600) +# elif defined(__clang__) +# define CV__EXCEPTION_PTR 0 // C++11 only (see above) +# elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) +# define CV__EXCEPTION_PTR (__GXX_EXPERIMENTAL_CXX0X__ > 0) +# endif +#endif +#ifndef CV__EXCEPTION_PTR +# define CV__EXCEPTION_PTR 0 +#elif CV__EXCEPTION_PTR +# include // std::exception_ptr +#endif + +#endif // OPENCV_CORE_DETAILS_EXCEPTION_PTR_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/directx.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/directx.hpp new file mode 100644 index 0000000..056a85a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/directx.hpp @@ -0,0 +1,184 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the copyright holders or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_DIRECTX_HPP +#define OPENCV_CORE_DIRECTX_HPP + +#include "mat.hpp" +#include "ocl.hpp" + +#if !defined(__d3d11_h__) +struct ID3D11Device; +struct ID3D11Texture2D; +#endif + +#if !defined(__d3d10_h__) +struct ID3D10Device; +struct ID3D10Texture2D; +#endif + +#if !defined(_D3D9_H_) +struct IDirect3DDevice9; +struct IDirect3DDevice9Ex; +struct IDirect3DSurface9; +#endif + + +namespace cv { namespace directx { + +namespace ocl { +using namespace cv::ocl; + +//! @addtogroup core_directx +// This section describes OpenCL and DirectX interoperability. +// +// To enable DirectX support, configure OpenCV using CMake with WITH_DIRECTX=ON . Note, DirectX is +// supported only on Windows. +// +// To use OpenCL functionality you should first initialize OpenCL context from DirectX resource. +// +//! @{ + +// TODO static functions in the Context class +//! @brief Creates OpenCL context from D3D11 device +// +//! @param pD3D11Device - pointer to D3D11 device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device); + +//! @brief Creates OpenCL context from D3D10 device +// +//! @param pD3D10Device - pointer to D3D10 device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device); + +//! @brief Creates OpenCL context from Direct3DDevice9Ex device +// +//! @param pDirect3DDevice9Ex - pointer to Direct3DDevice9Ex device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex); + +//! @brief Creates OpenCL context from Direct3DDevice9 device +// +//! @param pDirect3DDevice9 - pointer to Direct3Device9 device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9); + +//! @} + +} // namespace cv::directx::ocl + +//! @addtogroup core_directx +//! @{ + +//! @brief Converts InputArray to ID3D11Texture2D. If destination texture format is DXGI_FORMAT_NV12 then +//! input UMat expected to be in BGR format and data will be downsampled and color-converted to NV12. +// +//! @note Note: Destination texture must be allocated by application. Function does memory copy from src to +//! pD3D11Texture2D +// +//! @param src - source InputArray +//! @param pD3D11Texture2D - destination D3D11 texture +CV_EXPORTS void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D); + +//! @brief Converts ID3D11Texture2D to OutputArray. If input texture format is DXGI_FORMAT_NV12 then +//! data will be upsampled and color-converted to BGR format. +// +//! @note Note: Destination matrix will be re-allocated if it has not enough memory to match texture size. +//! function does memory copy from pD3D11Texture2D to dst +// +//! @param pD3D11Texture2D - source D3D11 texture +//! @param dst - destination OutputArray +CV_EXPORTS void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst); + +//! @brief Converts InputArray to ID3D10Texture2D +// +//! @note Note: function does memory copy from src to +//! pD3D10Texture2D +// +//! @param src - source InputArray +//! @param pD3D10Texture2D - destination D3D10 texture +CV_EXPORTS void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D); + +//! @brief Converts ID3D10Texture2D to OutputArray +// +//! @note Note: function does memory copy from pD3D10Texture2D +//! to dst +// +//! @param pD3D10Texture2D - source D3D10 texture +//! @param dst - destination OutputArray +CV_EXPORTS void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst); + +//! @brief Converts InputArray to IDirect3DSurface9 +// +//! @note Note: function does memory copy from src to +//! pDirect3DSurface9 +// +//! @param src - source InputArray +//! @param pDirect3DSurface9 - destination D3D10 texture +//! @param surfaceSharedHandle - shared handle +CV_EXPORTS void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurface9, void* surfaceSharedHandle = NULL); + +//! @brief Converts IDirect3DSurface9 to OutputArray +// +//! @note Note: function does memory copy from pDirect3DSurface9 +//! to dst +// +//! @param pDirect3DSurface9 - source D3D10 texture +//! @param dst - destination OutputArray +//! @param surfaceSharedHandle - shared handle +CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArray dst, void* surfaceSharedHandle = NULL); + +//! @brief Get OpenCV type from DirectX type +//! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11 +//! @return OpenCV type or -1 if there is no equivalent +CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11 + +//! @brief Get OpenCV type from DirectX type +//! @param iD3DFORMAT - enum D3DTYPE for D3D9 +//! @return OpenCV type or -1 if there is no equivalent +CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9 + +//! @} + +} } // namespace cv::directx + +#endif // OPENCV_CORE_DIRECTX_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/dualquaternion.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/dualquaternion.hpp new file mode 100644 index 0000000..1f644e9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/dualquaternion.hpp @@ -0,0 +1,979 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang +#ifndef OPENCV_CORE_DUALQUATERNION_HPP +#define OPENCV_CORE_DUALQUATERNION_HPP + +#include +#include + +namespace cv{ +//! @addtogroup core +//! @{ + +template class DualQuat; +template std::ostream& operator<<(std::ostream&, const DualQuat<_Tp>&); + +/** + * Dual quaternions were introduced to describe rotation together with translation while ordinary + * quaternions can only describe rotation. It can be used for shortest path pose interpolation, + * local pose optimization or volumetric deformation. More details can be found + * - https://en.wikipedia.org/wiki/Dual_quaternion + * - ["A beginners guide to dual-quaternions: what they are, how they work, and how to use them for 3D character hierarchies", Ben Kenwright, 2012](https://borodust.org/public/shared/beginner_dual_quats.pdf) + * - ["Dual Quaternions", Yan-Bin Jia, 2013](http://web.cs.iastate.edu/~cs577/handouts/dual-quaternion.pdf) + * - ["Geometric Skinning with Approximate Dual Quaternion Blending", Kavan, 2008](https://www.cs.utah.edu/~ladislav/kavan08geometric/kavan08geometric) + * - http://rodolphe-vaillant.fr/?e=29 + * + * A unit dual quaternion can be classically represented as: + * \f[ + * \begin{equation} + * \begin{split} + * \sigma &= \left(r+\frac{\epsilon}{2}tr\right)\\ + * &= [w, x, y, z, w\_, x\_, y\_, z\_] + * \end{split} + * \end{equation} + * \f] + * where \f$r, t\f$ represents the rotation (ordinary unit quaternion) and translation (pure ordinary quaternion) respectively. + * + * A general dual quaternions which consist of two quaternions is usually represented in form of: + * \f[ + * \sigma = p + \epsilon q + * \f] + * where the introduced dual unit \f$\epsilon\f$ satisfies \f$\epsilon^2 = \epsilon^3 =...=0\f$, and \f$p, q\f$ are quaternions. + * + * Alternatively, dual quaternions can also be interpreted as four components which are all [dual numbers](https://www.cs.utah.edu/~ladislav/kavan08geometric/kavan08geometric): + * \f[ + * \sigma = \hat{q}_w + \hat{q}_xi + \hat{q}_yj + \hat{q}_zk + * \f] + * If we set \f$\hat{q}_x, \hat{q}_y\f$ and \f$\hat{q}_z\f$ equal to 0, a dual quaternion is transformed to a dual number. see normalize(). + * + * If you want to create a dual quaternion, you can use: + * + * ``` + * using namespace cv; + * double angle = CV_PI; + * + * // create from eight number + * DualQuatd dq1(1, 2, 3, 4, 5, 6, 7, 8); //p = [1,2,3,4]. q=[5,6,7,8] + * + * // create from Vec + * Vec v{1,2,3,4,5,6,7,8}; + * DualQuatd dq_v{v}; + * + * // create from two quaternion + * Quatd p(1, 2, 3, 4); + * Quatd q(5, 6, 7, 8); + * DualQuatd dq2 = DualQuatd::createFromQuat(p, q); + * + * // create from an angle, an axis and a translation + * Vec3d axis{0, 0, 1}; + * Vec3d trans{3, 4, 5}; + * DualQuatd dq3 = DualQuatd::createFromAngleAxisTrans(angle, axis, trans); + * + * // If you already have an instance of class Affine3, then you can use + * Affine3d R = dq3.toAffine3(); + * DualQuatd dq4 = DualQuatd::createFromAffine3(R); + * + * // or create directly by affine transformation matrix Rt + * // see createFromMat() in detail for the form of Rt + * Matx44d Rt = dq3.toMat(); + * DualQuatd dq5 = DualQuatd::createFromMat(Rt); + * + * // Any rotation + translation movement can + * // be expressed as a rotation + translation around the same line in space (expressed by Plucker + * // coords), and here's a way to represent it this way. + * Vec3d axis{1, 1, 1}; // axis will be normalized in createFromPitch + * Vec3d trans{3, 4 ,5}; + * axis = axis / std::sqrt(axis.dot(axis));// The formula for computing moment that I use below requires a normalized axis + * Vec3d moment = 1.0 / 2 * (trans.cross(axis) + axis.cross(trans.cross(axis)) * + * std::cos(rotation_angle / 2) / std::sin(rotation_angle / 2)); + * double d = trans.dot(qaxis); + * DualQuatd dq6 = DualQuatd::createFromPitch(angle, d, axis, moment); + * ``` + * + * A point \f$v=(x, y, z)\f$ in form of dual quaternion is \f$[1+\epsilon v]=[1,0,0,0,0,x,y,z]\f$. + * The transformation of a point \f$v_1\f$ to another point \f$v_2\f$ under the dual quaternion \f$\sigma\f$ is + * \f[ + * 1 + \epsilon v_2 = \sigma * (1 + \epsilon v_1) * \sigma^{\star} + * \f] + * where \f$\sigma^{\star}=p^*-\epsilon q^*.\f$ + * + * A line in the \f$Pl\ddot{u}cker\f$ coordinates \f$(\hat{l}, m)\f$ defined by the dual quaternion \f$l=\hat{l}+\epsilon m\f$. + * To transform a line, \f[l_2 = \sigma * l_1 * \sigma^*,\f] where \f$\sigma=r+\frac{\epsilon}{2}rt\f$ and + * \f$\sigma^*=p^*+\epsilon q^*\f$. + * + * To extract the Vec or Vec, see toVec(); + * + * To extract the affine transformation matrix, see toMat(); + * + * To extract the instance of Affine3, see toAffine3(); + * + * If two quaternions \f$q_0, q_1\f$ are needed to be interpolated, you can use sclerp() + * ``` + * DualQuatd::sclerp(q0, q1, t) + * ``` + * or dqblend(). + * ``` + * DualQuatd::dqblend(q0, q1, t) + * ``` + * With more than two dual quaternions to be blended, you can use generalize linear dual quaternion blending + * with the corresponding weights, i.e. gdqblend(). + * + */ +template +class CV_EXPORTS DualQuat{ + static_assert(std::is_floating_point<_Tp>::value, "Dual quaternion only make sense with type of float or double"); + using value_type = _Tp; + +public: + static constexpr _Tp CV_DUAL_QUAT_EPS = (_Tp)1.e-6; + + DualQuat(); + + /** + * @brief create from eight same type numbers. + */ + DualQuat(const _Tp w, const _Tp x, const _Tp y, const _Tp z, const _Tp w_, const _Tp x_, const _Tp y_, const _Tp z_); + + /** + * @brief create from a double or float vector. + */ + DualQuat(const Vec<_Tp, 8> &q); + + _Tp w, x, y, z, w_, x_, y_, z_; + + /** + * @brief create Dual Quaternion from two same type quaternions p and q. + * A Dual Quaternion \f$\sigma\f$ has the form: + * \f[\sigma = p + \epsilon q\f] + * where p and q are defined as follows: + * \f[\begin{equation} + * \begin{split} + * p &= w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\\ + * q &= w\_ + x\_\boldsymbol{i} + y\_\boldsymbol{j} + z\_\boldsymbol{k}. + * \end{split} + * \end{equation} + * \f] + * The p and q are the real part and dual part respectively. + * @param realPart a quaternion, real part of dual quaternion. + * @param dualPart a quaternion, dual part of dual quaternion. + * @sa Quat + */ + static DualQuat<_Tp> createFromQuat(const Quat<_Tp> &realPart, const Quat<_Tp> &dualPart); + + /** + * @brief create a dual quaternion from a rotation angle \f$\theta\f$, a rotation axis + * \f$\boldsymbol{u}\f$ and a translation \f$\boldsymbol{t}\f$. + * It generates a dual quaternion \f$\sigma\f$ in the form of + * \f[\begin{equation} + * \begin{split} + * \sigma &= r + \frac{\epsilon}{2}\boldsymbol{t}r \\ + * &= [\cos(\frac{\theta}{2}), \boldsymbol{u}\sin(\frac{\theta}{2})] + * + \frac{\epsilon}{2}[0, \boldsymbol{t}][[\cos(\frac{\theta}{2}), + * \boldsymbol{u}\sin(\frac{\theta}{2})]]\\ + * &= \cos(\frac{\theta}{2}) + \boldsymbol{u}\sin(\frac{\theta}{2}) + * + \frac{\epsilon}{2}(-(\boldsymbol{t} \cdot \boldsymbol{u})\sin(\frac{\theta}{2}) + * + \boldsymbol{t}\cos(\frac{\theta}{2}) + \boldsymbol{u} \times \boldsymbol{t} \sin(\frac{\theta}{2})). + * \end{split} + * \end{equation}\f] + * @param angle rotation angle. + * @param axis rotation axis. + * @param translation a vector of length 3. + * @note Axis will be normalized in this function. And translation is applied + * after the rotation. Use @ref createFromQuat(r, r * t / 2) to create a dual quaternion + * which translation is applied before rotation. + * @sa Quat + */ + static DualQuat<_Tp> createFromAngleAxisTrans(const _Tp angle, const Vec<_Tp, 3> &axis, const Vec<_Tp, 3> &translation); + + /** + * @brief Transform this dual quaternion to an affine transformation matrix \f$M\f$. + * Dual quaternion consists of a rotation \f$r=[a,b,c,d]\f$ and a translation \f$t=[\Delta x,\Delta y,\Delta z]\f$. The + * affine transformation matrix \f$M\f$ has the form + * \f[ + * \begin{bmatrix} + * 1-2(e_2^2 +e_3^2) &2(e_1e_2-e_0e_3) &2(e_0e_2+e_1e_3) &\Delta x\\ + * 2(e_0e_3+e_1e_2) &1-2(e_1^2+e_3^2) &2(e_2e_3-e_0e_1) &\Delta y\\ + * 2(e_1e_3-e_0e_2) &2(e_0e_1+e_2e_3) &1-2(e_1^2-e_2^2) &\Delta z\\ + * 0&0&0&1 + * \end{bmatrix} + * \f] + * if A is a matrix consisting of n points to be transformed, this could be achieved by + * \f[ + * new\_A = M * A + * \f] + * where A has the form + * \f[ + * \begin{bmatrix} + * x_0& x_1& x_2&...&x_n\\ + * y_0& y_1& y_2&...&y_n\\ + * z_0& z_1& z_2&...&z_n\\ + * 1&1&1&...&1 + * \end{bmatrix} + * \f] + * where the same subscript represent the same point. The size of A should be \f$[4,n]\f$. + * and the same size for matrix new_A. + * @param _R 4x4 matrix that represents rotations and translation. + * @note Translation is applied after the rotation. Use createFromQuat(r, r * t / 2) to create + * a dual quaternion which translation is applied before rotation. + */ + static DualQuat<_Tp> createFromMat(InputArray _R); + + /** + * @brief create dual quaternion from an affine matrix. The definition of affine matrix can refer to createFromMat() + */ + static DualQuat<_Tp> createFromAffine3(const Affine3<_Tp> &R); + + /** + * @brief A dual quaternion is a vector in form of + * \f[ + * \begin{equation} + * \begin{split} + * \sigma &=\boldsymbol{p} + \epsilon \boldsymbol{q}\\ + * &= \cos\hat{\frac{\theta}{2}}+\overline{\hat{l}}\sin\frac{\hat{\theta}}{2} + * \end{split} + * \end{equation} + * \f] + * where \f$\hat{\theta}\f$ is dual angle and \f$\overline{\hat{l}}\f$ is dual axis: + * \f[ + * \hat{\theta}=\theta + \epsilon d,\\ + * \overline{\hat{l}}= \hat{l} +\epsilon m. + * \f] + * In this representation, \f$\theta\f$ is rotation angle and \f$(\hat{l},m)\f$ is the screw axis, d is the translation distance along the axis. + * + * @param angle rotation angle. + * @param d translation along the rotation axis. + * @param axis rotation axis represented by quaternion with w = 0. + * @param moment the moment of line, and it should be orthogonal to axis. + * @note Translation is applied after the rotation. Use createFromQuat(r, r * t / 2) to create + * a dual quaternion which translation is applied before rotation. + */ + static DualQuat<_Tp> createFromPitch(const _Tp angle, const _Tp d, const Vec<_Tp, 3> &axis, const Vec<_Tp, 3> &moment); + + /** + * @brief return a quaternion which represent the real part of dual quaternion. + * The definition of real part is in createFromQuat(). + * @sa createFromQuat, getDualPart + */ + Quat<_Tp> getRealPart() const; + + /** + * @brief return a quaternion which represent the dual part of dual quaternion. + * The definition of dual part is in createFromQuat(). + * @sa createFromQuat, getRealPart + */ + Quat<_Tp> getDualPart() const; + + /** + * @brief return the conjugate of a dual quaternion. + * \f[ + * \begin{equation} + * \begin{split} + * \sigma^* &= (p + \epsilon q)^* + * &= (p^* + \epsilon q^*) + * \end{split} + * \end{equation} + * \f] + * @param dq a dual quaternion. + */ + template + friend DualQuat conjugate(const DualQuat &dq); + + /** + * @brief return the conjugate of a dual quaternion. + * \f[ + * \begin{equation} + * \begin{split} + * \sigma^* &= (p + \epsilon q)^* + * &= (p^* + \epsilon q^*) + * \end{split} + * \end{equation} + * \f] + */ + DualQuat<_Tp> conjugate() const; + + /** + * @brief return the rotation in quaternion form. + */ + Quat<_Tp> getRotation(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the translation vector. + * The rotation \f$r\f$ in this dual quaternion \f$\sigma\f$ is applied before translation \f$t\f$. + * The dual quaternion \f$\sigma\f$ is defined as + * \f[\begin{equation} + * \begin{split} + * \sigma &= p + \epsilon q \\ + * &= r + \frac{\epsilon}{2}{t}r. + * \end{split} + * \end{equation}\f] + * Thus, the translation can be obtained as follows + * \f[t = 2qp^*.\f] + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + * @note This dual quaternion's translation is applied after the rotation. + */ + Vec<_Tp, 3> getTranslation(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the norm \f$||\sigma||\f$ of dual quaternion \f$\sigma = p + \epsilon q\f$. + * \f[ + * \begin{equation} + * \begin{split} + * ||\sigma|| &= \sqrt{\sigma * \sigma^*} \\ + * &= ||p|| + \epsilon \frac{p \cdot q}{||p||}. + * \end{split} + * \end{equation} + * \f] + * Generally speaking, the norm of a not unit dual + * quaternion is a dual number. For convenience, we return it in the form of a dual quaternion + * , i.e. + * \f[ ||\sigma|| = [||p||, 0, 0, 0, \frac{p \cdot q}{||p||}, 0, 0, 0].\f] + * + * @note The data type of dual number is dual quaternion. + */ + DualQuat<_Tp> norm() const; + + /** + * @brief return a normalized dual quaternion. + * A dual quaternion can be expressed as + * \f[ + * \begin{equation} + * \begin{split} + * \sigma &= p + \epsilon q\\ + * &=||\sigma||\left(r+\frac{1}{2}tr\right) + * \end{split} + * \end{equation} + * \f] + * where \f$r, t\f$ represents the rotation (ordinary quaternion) and translation (pure ordinary quaternion) respectively, + * and \f$||\sigma||\f$ is the norm of dual quaternion(a dual number). + * A dual quaternion is unit if and only if + * \f[ + * ||p||=1, p \cdot q=0 + * \f] + * where \f$\cdot\f$ means dot product. + * The process of normalization is + * \f[ + * \sigma_{u}=\frac{\sigma}{||\sigma||} + * \f] + * Next, we simply proof \f$\sigma_u\f$ is a unit dual quaternion: + * \f[ + * \renewcommand{\Im}{\operatorname{Im}} + * \begin{equation} + * \begin{split} + * \sigma_{u}=\frac{\sigma}{||\sigma||}&=\frac{p + \epsilon q}{||p||+\epsilon\frac{p\cdot q}{||p||}}\\ + * &=\frac{p}{||p||}+\epsilon\left(\frac{q}{||p||}-p\frac{p\cdot q}{||p||^3}\right)\\ + * &=\frac{p}{||p||}+\epsilon\frac{1}{||p||^2}\left(qp^{*}-p\cdot q\right)\frac{p}{||p||}\\ + * &=\frac{p}{||p||}+\epsilon\frac{1}{||p||^2}\Im(qp^*)\frac{p}{||p||}.\\ + * \end{split} + * \end{equation} + * \f] + * As expected, the real part is a rotation and dual part is a pure quaternion. + */ + DualQuat<_Tp> normalize() const; + + /** + * @brief if \f$\sigma = p + \epsilon q\f$ is a dual quaternion, p is not zero, + * the inverse dual quaternion is + * \f[\sigma^{-1} = \frac{\sigma^*}{||\sigma||^2}, \f] + * or equivalentlly, + * \f[\sigma^{-1} = p^{-1} - \epsilon p^{-1}qp^{-1}.\f] + * @param dq a dual quaternion. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion dq assume to be a unit dual quaternion + * and this function will save some computations. + */ + template + friend DualQuat inv(const DualQuat &dq, QuatAssumeType assumeUnit); + + /** + * @brief if \f$\sigma = p + \epsilon q\f$ is a dual quaternion, p is not zero, + * the inverse dual quaternion is + * \f[\sigma^{-1} = \frac{\sigma^*}{||\sigma||^2}, \f] + * or equivalentlly, + * \f[\sigma^{-1} = p^{-1} - \epsilon p^{-1}qp^{-1}.\f] + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> inv(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the dot product of two dual quaternion. + * @param p other dual quaternion. + */ + _Tp dot(DualQuat<_Tp> p) const; + + /** + ** @brief return the value of \f$p^t\f$ where p is a dual quaternion. + * This could be calculated as: + * \f[ + * p^t = \exp(t\ln p) + * \f] + * @param dq a dual quaternion. + * @param t index of power function. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion dq assume to be a unit dual quaternion + * and this function will save some computations. + */ + template + friend DualQuat power(const DualQuat &dq, const T t, QuatAssumeType assumeUnit); + + /** + ** @brief return the value of \f$p^t\f$ where p is a dual quaternion. + * This could be calculated as: + * \f[ + * p^t = \exp(t\ln p) + * \f] + * + * @param t index of power function. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> power(const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of \f$p^q\f$ where p and q are dual quaternions. + * This could be calculated as: + * \f[ + * p^q = \exp(q\ln p) + * \f] + * @param p a dual quaternion. + * @param q a dual quaternion. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion p assume to be a dual unit quaternion + * and this function will save some computations. + */ + template + friend DualQuat power(const DualQuat& p, const DualQuat& q, QuatAssumeType assumeUnit); + + /** + * @brief return the value of \f$p^q\f$ where p and q are dual quaternions. + * This could be calculated as: + * \f[ + * p^q = \exp(q\ln p) + * \f] + * + * @param q a dual quaternion + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a dual unit quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> power(const DualQuat<_Tp>& q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of exponential function value + * @param dq a dual quaternion. + */ + template + friend DualQuat exp(const DualQuat &dq); + + /** + * @brief return the value of exponential function value + */ + DualQuat<_Tp> exp() const; + + /** + * @brief return the value of logarithm function value + * + * @param dq a dual quaternion. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion dq assume to be a unit dual quaternion + * and this function will save some computations. + */ + template + friend DualQuat log(const DualQuat &dq, QuatAssumeType assumeUnit); + + /** + * @brief return the value of logarithm function value + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> log(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief Transform this dual quaternion to a vector. + */ + Vec<_Tp, 8> toVec() const; + + /** + * @brief Transform this dual quaternion to a affine transformation matrix + * the form of matrix, see createFromMat(). + */ + Matx<_Tp, 4, 4> toMat(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief Transform this dual quaternion to a instance of Affine3. + */ + Affine3<_Tp> toAffine3(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief The screw linear interpolation(ScLERP) is an extension of spherical linear interpolation of dual quaternion. + * If \f$\sigma_1\f$ and \f$\sigma_2\f$ are two dual quaternions representing the initial and final pose. + * The interpolation of ScLERP function can be defined as: + * \f[ + * ScLERP(t;\sigma_1,\sigma_2) = \sigma_1 * (\sigma_1^{-1} * \sigma_2)^t, t\in[0,1] + * \f] + * + * @param q1 a dual quaternion represents a initial pose. + * @param q2 a dual quaternion represents a final pose. + * @param t interpolation parameter + * @param directChange if true, it always return the shortest path. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + * + * For example + * ``` + * double angle1 = CV_PI / 2; + * Vec3d axis{0, 0, 1}; + * Vec3d t(0, 0, 3); + * DualQuatd initial = DualQuatd::createFromAngleAxisTrans(angle1, axis, t); + * double angle2 = CV_PI; + * DualQuatd final = DualQuatd::createFromAngleAxisTrans(angle2, axis, t); + * DualQuatd inter = DualQuatd::sclerp(initial, final, 0.5); + * ``` + */ + static DualQuat<_Tp> sclerp(const DualQuat<_Tp> &q1, const DualQuat<_Tp> &q2, const _Tp t, + bool directChange=true, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + /** + * @brief The method of Dual Quaternion linear Blending(DQB) is to compute a transformation between dual quaternion + * \f$q_1\f$ and \f$q_2\f$ and can be defined as: + * \f[ + * DQB(t;{\boldsymbol{q}}_1,{\boldsymbol{q}}_2)= + * \frac{(1-t){\boldsymbol{q}}_1+t{\boldsymbol{q}}_2}{||(1-t){\boldsymbol{q}}_1+t{\boldsymbol{q}}_2||}. + * \f] + * where \f$q_1\f$ and \f$q_2\f$ are unit dual quaternions representing the input transformations. + * If you want to use DQB that works for more than two rigid transformations, see @ref gdqblend + * + * @param q1 a unit dual quaternion representing the input transformations. + * @param q2 a unit dual quaternion representing the input transformations. + * @param t parameter \f$t\in[0,1]\f$. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + * + * @sa gdqblend + */ + static DualQuat<_Tp> dqblend(const DualQuat<_Tp> &q1, const DualQuat<_Tp> &q2, const _Tp t, + QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief The generalized Dual Quaternion linear Blending works for more than two rigid transformations. + * If these transformations are expressed as unit dual quaternions \f$q_1,...,q_n\f$ with convex weights + * \f$w = (w_1,...,w_n)\f$, the generalized DQB is simply + * \f[ + * gDQB(\boldsymbol{w};{\boldsymbol{q}}_1,...,{\boldsymbol{q}}_n)=\frac{w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n} + * {||w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n||}. + * \f] + * @param dualquat vector of dual quaternions + * @param weights vector of weights, the size of weights should be the same as dualquat, and the weights should + * satisfy \f$\sum_0^n w_{i} = 1\f$ and \f$w_i>0\f$. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, these dual quaternions assume to be unit quaternions + * and this function will save some computations. + * @note the type of weights' element should be the same as the date type of dual quaternion inside the dualquat. + */ + template + static DualQuat<_Tp> gdqblend(const Vec, cn> &dualquat, InputArray weights, + QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief The generalized Dual Quaternion linear Blending works for more than two rigid transformations. + * If these transformations are expressed as unit dual quaternions \f$q_1,...,q_n\f$ with convex weights + * \f$w = (w_1,...,w_n)\f$, the generalized DQB is simply + * \f[ + * gDQB(\boldsymbol{w};{\boldsymbol{q}}_1,...,{\boldsymbol{q}}_n)=\frac{w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n} + * {||w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n||}. + * \f] + * @param dualquat The dual quaternions which have 8 channels and 1 row or 1 col. + * @param weights vector of weights, the size of weights should be the same as dualquat, and the weights should + * satisfy \f$\sum_0^n w_{i} = 1\f$ and \f$w_i>0\f$. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, these dual quaternions assume to be unit quaternions + * and this function will save some computations. + * @note the type of weights' element should be the same as the date type of dual quaternion inside the dualquat. + */ + static DualQuat<_Tp> gdqblend(InputArray dualquat, InputArray weights, + QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief Return opposite dual quaternion \f$-p\f$ + * which satisfies \f$p + (-p) = 0.\f$ + * + * For example + * ``` + * DualQuatd q{1, 2, 3, 4, 5, 6, 7, 8}; + * std::cout << -q << std::endl; // [-1, -2, -3, -4, -5, -6, -7, -8] + * ``` + */ + DualQuat<_Tp> operator-() const; + + /** + * @brief return true if two dual quaternions p and q are nearly equal, i.e. when the absolute + * value of each \f$p_i\f$ and \f$q_i\f$ is less than CV_DUAL_QUAT_EPS. + */ + bool operator==(const DualQuat<_Tp>&) const; + + /** + * @brief Subtraction operator of two dual quaternions p and q. + * It returns a new dual quaternion that each value is the sum of \f$p_i\f$ and \f$-q_i\f$. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p - q << std::endl; //[-4, -4, -4, -4, 4, -4, -4, -4] + * ``` + */ + DualQuat<_Tp> operator-(const DualQuat<_Tp>&) const; + + /** + * @brief Subtraction assignment operator of two dual quaternions p and q. + * It subtracts right operand from the left operand and assign the result to left operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p -= q; // equivalent to p = p - q + * std::cout << p << std::endl; //[-4, -4, -4, -4, 4, -4, -4, -4] + * + * ``` + */ + DualQuat<_Tp>& operator-=(const DualQuat<_Tp>&); + + /** + * @brief Addition operator of two dual quaternions p and q. + * It returns a new dual quaternion that each value is the sum of \f$p_i\f$ and \f$q_i\f$. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p + q << std::endl; //[6, 8, 10, 12, 14, 16, 18, 20] + * ``` + */ + DualQuat<_Tp> operator+(const DualQuat<_Tp>&) const; + + /** + * @brief Addition assignment operator of two dual quaternions p and q. + * It adds right operand to the left operand and assign the result to left operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p += q; // equivalent to p = p + q + * std::cout << p << std::endl; //[6, 8, 10, 12, 14, 16, 18, 20] + * + * ``` + */ + DualQuat<_Tp>& operator+=(const DualQuat<_Tp>&); + + /** + * @brief Multiplication assignment operator of two quaternions. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication: + * The dual quaternion can be written as an ordered pair of quaternions [A, B]. Thus + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [A, B][C, D]\\ + * &=[AC, AD + BC] + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p *= q; + * std::cout << p << std::endl; //[-60, 12, 30, 24, -216, 80, 124, 120] + * ``` + */ + DualQuat<_Tp>& operator*=(const DualQuat<_Tp>&); + + /** + * @brief Multiplication assignment operator of a quaternions and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z, w\_, x\_, y\_, z\_] * s\\ + * &=[w s, x s, y s, z s, w\_ \space s, x\_ \space s, y\_ \space s, z\_ \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * p *= s; + * std::cout << p << std::endl; //[2, 4, 6, 8, 10, 12, 14, 16] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + DualQuat<_Tp> operator*=(const _Tp s); + + + /** + * @brief Multiplication operator of two dual quaternions q and p. + * Multiplies values on either side of the operator. + * + * Rule of dual quaternion multiplication: + * The dual quaternion can be written as an ordered pair of quaternions [A, B]. Thus + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [A, B][C, D]\\ + * &=[AC, AD + BC] + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p * q << std::endl; //[-60, 12, 30, 24, -216, 80, 124, 120] + * ``` + */ + DualQuat<_Tp> operator*(const DualQuat<_Tp>&) const; + + /** + * @brief Division operator of a dual quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of dual quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z, w\_, x\_, y\_, z\_] / s\\ + * &=[w/s, x/s, y/s, z/s, w\_/s, x\_/s, y\_/s, z\_/s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4] + * ``` + * @note the type of scalar should be equal to this dual quaternion. + */ + DualQuat<_Tp> operator/(const _Tp s) const; + + /** + * @brief Division operator of two dual quaternions p and q. + * Divides left hand operand by right hand operand. + * + * Rule of dual quaternion division with a dual quaternion: + * \f[ + * \begin{equation} + * \begin{split} + * p / q &= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p / q << std::endl; // equivalent to p * q.inv() + * ``` + */ + DualQuat<_Tp> operator/(const DualQuat<_Tp>&) const; + + /** + * @brief Division assignment operator of two dual quaternions p and q; + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of dual quaternion division with a quaternion: + * \f[ + * \begin{equation} + * \begin{split} + * p / q&= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p /= q; // equivalent to p = p * q.inv() + * std::cout << p << std::endl; + * ``` + */ + DualQuat<_Tp>& operator/=(const DualQuat<_Tp>&); + + /** + * @brief Division assignment operator of a dual quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of dual quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z, w\_, x\_, y\_ ,z\_] / s\\ + * &=[w / s, x / s, y / s, z / s, w\_ / \space s, x\_ / \space s, y\_ / \space s, z\_ / \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0;; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + Quat<_Tp>& operator/=(const _Tp s); + + /** + * @brief Addition operator of a scalar and a dual quaternions. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << scalar + p << std::endl; //[3.0, 2, 3, 4, 5, 6, 7, 8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator+(const T s, const DualQuat&); + + /** + * @brief Addition operator of a dual quaternions and a scalar. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << p + scalar << std::endl; //[3.0, 2, 3, 4, 5, 6, 7, 8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator+(const DualQuat&, const T s); + + /** + * @brief Multiplication operator of a scalar and a dual quaternions. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z, w\_, x\_, y\_, z\_] * s\\ + * &=[w s, x s, y s, z s, w\_ \space s, x\_ \space s, y\_ \space s, z\_ \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * std::cout << s * p << std::endl; //[2, 4, 6, 8, 10, 12, 14, 16] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator*(const T s, const DualQuat&); + + /** + * @brief Subtraction operator of a dual quaternion and a scalar. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << p - scalar << std::endl; //[-1, 2, 3, 4, 5, 6, 7, 8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator-(const DualQuat&, const T s); + + /** + * @brief Subtraction operator of a scalar and a dual quaternions. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << scalar - p << std::endl; //[1.0, -2, -3, -4, -5, -6, -7, -8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator-(const T s, const DualQuat&); + + /** + * @brief Multiplication operator of a dual quaternions and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z, w\_, x\_, y\_, z\_] * s\\ + * &=[w s, x s, y s, z s, w\_ \space s, x\_ \space s, y\_ \space s, z\_ \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * std::cout << p * s << std::endl; //[2, 4, 6, 8, 10, 12, 14, 16] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator*(const DualQuat&, const T s); + + template + friend std::ostream& cv::operator<<(std::ostream&, const DualQuat&); + +}; + +using DualQuatd = DualQuat; +using DualQuatf = DualQuat; + +//! @} core +}//namespace + +#include "dualquaternion.inl.hpp" + +#endif /* OPENCV_CORE_QUATERNION_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/dualquaternion.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/dualquaternion.inl.hpp new file mode 100644 index 0000000..6abb159 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/dualquaternion.inl.hpp @@ -0,0 +1,487 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang + +#ifndef OPENCV_CORE_DUALQUATERNION_INL_HPP +#define OPENCV_CORE_DUALQUATERNION_INL_HPP + +#ifndef OPENCV_CORE_DUALQUATERNION_HPP +#error This is not a standalone header. Include dualquaternion.hpp instead. +#endif + +/////////////////////////////////////////////////////////////////////////////////////// +//Implementation +namespace cv { + +template +DualQuat::DualQuat():w(0), x(0), y(0), z(0), w_(0), x_(0), y_(0), z_(0){}; + +template +DualQuat::DualQuat(const T vw, const T vx, const T vy, const T vz, const T _w, const T _x, const T _y, const T _z): + w(vw), x(vx), y(vy), z(vz), w_(_w), x_(_x), y_(_y), z_(_z){}; + +template +DualQuat::DualQuat(const Vec &q):w(q[0]), x(q[1]), y(q[2]), z(q[3]), + w_(q[4]), x_(q[5]), y_(q[6]), z_(q[7]){}; + +template +DualQuat DualQuat::createFromQuat(const Quat &realPart, const Quat &dualPart) +{ + T w = realPart.w; + T x = realPart.x; + T y = realPart.y; + T z = realPart.z; + T w_ = dualPart.w; + T x_ = dualPart.x; + T y_ = dualPart.y; + T z_ = dualPart.z; + return DualQuat(w, x, y, z, w_, x_, y_, z_); +} + +template +DualQuat DualQuat::createFromAngleAxisTrans(const T angle, const Vec &axis, const Vec &trans) +{ + Quat r = Quat::createFromAngleAxis(angle, axis); + Quat t{0, trans[0], trans[1], trans[2]}; + return createFromQuat(r, t * r * T(0.5)); +} + +template +DualQuat DualQuat::createFromMat(InputArray _R) +{ + CV_CheckTypeEQ(_R.type(), cv::traits::Type::value, ""); + if (_R.size() != Size(4, 4)) + { + CV_Error(Error::StsBadArg, "The input matrix must have 4 columns and 4 rows"); + } + Mat R = _R.getMat(); + Quat r = Quat::createFromRotMat(R.colRange(0, 3).rowRange(0, 3)); + Quat trans(0, R.at(0, 3), R.at(1, 3), R.at(2, 3)); + return createFromQuat(r, trans * r * T(0.5)); +} + +template +DualQuat DualQuat::createFromAffine3(const Affine3 &R) +{ + return createFromMat(R.matrix); +} + +template +DualQuat DualQuat::createFromPitch(const T angle, const T d, const Vec &axis, const Vec &moment) +{ + T half_angle = angle * T(0.5), half_d = d * T(0.5); + Quat qaxis = Quat(0, axis[0], axis[1], axis[2]).normalize(); + Quat qmoment = Quat(0, moment[0], moment[1], moment[2]); + qmoment -= qaxis * axis.dot(moment); + Quat dual = -half_d * std::sin(half_angle) + std::sin(half_angle) * qmoment + + half_d * std::cos(half_angle) * qaxis; + return createFromQuat(Quat::createFromAngleAxis(angle, axis), dual); +} + +template +inline bool DualQuat::operator==(const DualQuat &q) const +{ + return (abs(w - q.w) < CV_DUAL_QUAT_EPS && abs(x - q.x) < CV_DUAL_QUAT_EPS && + abs(y - q.y) < CV_DUAL_QUAT_EPS && abs(z - q.z) < CV_DUAL_QUAT_EPS && + abs(w_ - q.w_) < CV_DUAL_QUAT_EPS && abs(x_ - q.x_) < CV_DUAL_QUAT_EPS && + abs(y_ - q.y_) < CV_DUAL_QUAT_EPS && abs(z_ - q.z_) < CV_DUAL_QUAT_EPS); +} + +template +inline Quat DualQuat::getRealPart() const +{ + return Quat(w, x, y, z); +} + +template +inline Quat DualQuat::getDualPart() const +{ + return Quat(w_, x_, y_, z_); +} + +template +inline DualQuat conjugate(const DualQuat &dq) +{ + return dq.conjugate(); +} + +template +inline DualQuat DualQuat::conjugate() const +{ + return DualQuat(w, -x, -y, -z, w_, -x_, -y_, -z_); +} + +template +DualQuat DualQuat::norm() const +{ + Quat real = getRealPart(); + T realNorm = real.norm(); + Quat dual = getDualPart(); + if (realNorm < CV_DUAL_QUAT_EPS){ + return DualQuat(0, 0, 0, 0, 0, 0, 0, 0); + } + return DualQuat(realNorm, 0, 0, 0, real.dot(dual) / realNorm, 0, 0, 0); +} + +template +inline Quat DualQuat::getRotation(QuatAssumeType assumeUnit) const +{ + if (assumeUnit) + { + return getRealPart(); + } + return getRealPart().normalize(); +} + +template +inline Vec DualQuat::getTranslation(QuatAssumeType assumeUnit) const +{ + Quat trans = T(2.0) * (getDualPart() * getRealPart().inv(assumeUnit)); + return Vec{trans[1], trans[2], trans[3]}; +} + +template +DualQuat DualQuat::normalize() const +{ + Quat p = getRealPart(); + Quat q = getDualPart(); + T p_norm = p.norm(); + if (p_norm < CV_DUAL_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "Cannot normalize this dual quaternion: the norm is too small."); + } + Quat p_nr = p / p_norm; + Quat q_nr = q / p_norm; + return createFromQuat(p_nr, q_nr - p_nr * p_nr.dot(q_nr)); +} + +template +inline T DualQuat::dot(DualQuat q) const +{ + return q.w * w + q.x * x + q.y * y + q.z * z + q.w_ * w_ + q.x_ * x_ + q.y_ * y_ + q.z_ * z_; +} + +template +inline DualQuat inv(const DualQuat &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return dq.inv(assumeUnit); +} + +template +inline DualQuat DualQuat::inv(QuatAssumeType assumeUnit) const +{ + Quat real = getRealPart(); + Quat dual = getDualPart(); + return createFromQuat(real.inv(assumeUnit), -real.inv(assumeUnit) * dual * real.inv(assumeUnit)); +} + +template +inline DualQuat DualQuat::operator-(const DualQuat &q) const +{ + return DualQuat(w - q.w, x - q.x, y - q.y, z - q.z, w_ - q.w_, x_ - q.x_, y_ - q.y_, z_ - q.z_); +} + +template +inline DualQuat DualQuat::operator-() const +{ + return DualQuat(-w, -x, -y, -z, -w_, -x_, -y_, -z_); +} + +template +inline DualQuat DualQuat::operator+(const DualQuat &q) const +{ + return DualQuat(w + q.w, x + q.x, y + q.y, z + q.z, w_ + q.w_, x_ + q.x_, y_ + q.y_, z_ + q.z_); +} + +template +inline DualQuat& DualQuat::operator+=(const DualQuat &q) +{ + *this = *this + q; + return *this; +} + +template +inline DualQuat DualQuat::operator*(const DualQuat &q) const +{ + Quat A = getRealPart(); + Quat B = getDualPart(); + Quat C = q.getRealPart(); + Quat D = q.getDualPart(); + return DualQuat::createFromQuat(A * C, A * D + B * C); +} + +template +inline DualQuat& DualQuat::operator*=(const DualQuat &q) +{ + *this = *this * q; + return *this; +} + +template +inline DualQuat operator+(const T a, const DualQuat &q) +{ + return DualQuat(a + q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_); +} + +template +inline DualQuat operator+(const DualQuat &q, const T a) +{ + return DualQuat(a + q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_); +} + +template +inline DualQuat operator-(const DualQuat &q, const T a) +{ + return DualQuat(q.w - a, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_); +} + +template +inline DualQuat& DualQuat::operator-=(const DualQuat &q) +{ + *this = *this - q; + return *this; +} + +template +inline DualQuat operator-(const T a, const DualQuat &q) +{ + return DualQuat(a - q.w, -q.x, -q.y, -q.z, -q.w_, -q.x_, -q.y_, -q.z_); +} + +template +inline DualQuat operator*(const T a, const DualQuat &q) +{ + return DualQuat(q.w * a, q.x * a, q.y * a, q.z * a, q.w_ * a, q.x_ * a, q.y_ * a, q.z_ * a); +} + +template +inline DualQuat operator*(const DualQuat &q, const T a) +{ + return DualQuat(q.w * a, q.x * a, q.y * a, q.z * a, q.w_ * a, q.x_ * a, q.y_ * a, q.z_ * a); +} + +template +inline DualQuat DualQuat::operator/(const T a) const +{ + return DualQuat(w / a, x / a, y / a, z / a, w_ / a, x_ / a, y_ / a, z_ / a); +} + +template +inline DualQuat DualQuat::operator/(const DualQuat &q) const +{ + return *this * q.inv(); +} + +template +inline DualQuat& DualQuat::operator/=(const DualQuat &q) +{ + *this = *this / q; + return *this; +} + +template +std::ostream & operator<<(std::ostream &os, const DualQuat &q) +{ + os << "DualQuat " << Vec{q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_}; + return os; +} + +template +inline DualQuat exp(const DualQuat &dq) +{ + return dq.exp(); +} + +namespace detail { + +template +Matx<_Tp, 4, 4> jacob_exp(const Quat<_Tp> &q) +{ + _Tp nv = std::sqrt(q.x * q.x + q.y * q.y + q.z * q.z); + _Tp sinc_nv = abs(nv) < cv::DualQuat<_Tp>::CV_DUAL_QUAT_EPS ? _Tp(1.0) - nv * nv * _Tp(1.0/6.0) : std::sin(nv) / nv; + _Tp csiii_nv = abs(nv) < cv::DualQuat<_Tp>::CV_DUAL_QUAT_EPS ? -_Tp(1.0/3.0) : (std::cos(nv) - sinc_nv) / nv / nv; + Matx<_Tp, 4, 4> J_exp_quat { + std::cos(nv), -sinc_nv * q.x, -sinc_nv * q.y, -sinc_nv * q.z, + sinc_nv * q.x, csiii_nv * q.x * q.x + sinc_nv, csiii_nv * q.x * q.y, csiii_nv * q.x * q.z, + sinc_nv * q.y, csiii_nv * q.y * q.x, csiii_nv * q.y * q.y + sinc_nv, csiii_nv * q.y * q.z, + sinc_nv * q.z, csiii_nv * q.z * q.x, csiii_nv * q.z * q.y, csiii_nv * q.z * q.z + sinc_nv + }; + return std::exp(q.w) * J_exp_quat; +} + +} // namespace detail + +template +DualQuat DualQuat::exp() const +{ + Quat real = getRealPart(); + return createFromQuat(real.exp(), Quat(detail::jacob_exp(real) * getDualPart().toVec())); +} + +template +DualQuat log(const DualQuat &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return dq.log(assumeUnit); +} + +template +DualQuat DualQuat::log(QuatAssumeType assumeUnit) const +{ + Quat plog = getRealPart().log(assumeUnit); + Matx jacob = detail::jacob_exp(plog); + return createFromQuat(plog, Quat(jacob.inv() * getDualPart().toVec())); +} + +template +inline DualQuat power(const DualQuat &dq, const T t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return dq.power(t, assumeUnit); +} + +template +inline DualQuat DualQuat::power(const T t, QuatAssumeType assumeUnit) const +{ + return (t * log(assumeUnit)).exp(); +} + +template +inline DualQuat power(const DualQuat &p, const DualQuat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return p.power(q, assumeUnit); +} + +template +inline DualQuat DualQuat::power(const DualQuat &q, QuatAssumeType assumeUnit) const +{ + return (q * log(assumeUnit)).exp(); +} + +template +inline Vec DualQuat::toVec() const +{ + return Vec(w, x, y, z, w_, x_, y_, z_); +} + +template +Affine3 DualQuat::toAffine3(QuatAssumeType assumeUnit) const +{ + return Affine3(toMat(assumeUnit)); +} + +template +Matx DualQuat::toMat(QuatAssumeType assumeUnit) const +{ + Matx rot44 = getRotation(assumeUnit).toRotMat4x4(); + Vec translation = getTranslation(assumeUnit); + rot44(0, 3) = translation[0]; + rot44(1, 3) = translation[1]; + rot44(2, 3) = translation[2]; + return rot44; +} + +template +DualQuat DualQuat::sclerp(const DualQuat &q0, const DualQuat &q1, const T t, bool directChange, QuatAssumeType assumeUnit) +{ + DualQuat v0(q0), v1(q1); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + } + Quat v0Real = v0.getRealPart(); + Quat v1Real = v1.getRealPart(); + if (directChange && v1Real.dot(v0Real) < 0) + { + v0 = -v0; + } + DualQuat v0inv1 = v0.inv() * v1; + return v0 * v0inv1.power(t, QUAT_ASSUME_UNIT); +} + +template +DualQuat DualQuat::dqblend(const DualQuat &q1, const DualQuat &q2, const T t, QuatAssumeType assumeUnit) +{ + DualQuat v1(q1), v2(q2); + if (!assumeUnit) + { + v1 = v1.normalize(); + v2 = v2.normalize(); + } + if (v1.getRotation(assumeUnit).dot(v2.getRotation(assumeUnit)) < 0) + { + return ((1 - t) * v1 - t * v2).normalize(); + } + return ((1 - t) * v1 + t * v2).normalize(); +} + +template +DualQuat DualQuat::gdqblend(InputArray _dualquat, InputArray _weight, QuatAssumeType assumeUnit) +{ + CV_CheckTypeEQ(_weight.type(), cv::traits::Type::value, ""); + CV_CheckTypeEQ(_dualquat.type(), CV_MAKETYPE(CV_MAT_DEPTH(cv::traits::Type::value), 8), ""); + Size dq_s = _dualquat.size(); + if (dq_s != _weight.size() || (dq_s.height != 1 && dq_s.width != 1)) + { + CV_Error(Error::StsBadArg, "The size of weight must be the same as dualquat, both of them should be (1, n) or (n, 1)"); + } + Mat dualquat = _dualquat.getMat(), weight = _weight.getMat(); + const int cn = std::max(dq_s.width, dq_s.height); + if (!assumeUnit) + { + for (int i = 0; i < cn; ++i) + { + dualquat.at>(i) = DualQuat{dualquat.at>(i)}.normalize().toVec(); + } + } + Vec dq_blend = dualquat.at>(0) * weight.at(0); + Quat q0 = DualQuat {dualquat.at>(0)}.getRotation(assumeUnit); + for (int i = 1; i < cn; ++i) + { + T k = q0.dot(DualQuat{dualquat.at>(i)}.getRotation(assumeUnit)) < 0 ? -1: 1; + dq_blend = dq_blend + dualquat.at>(i) * k * weight.at(i); + } + return DualQuat{dq_blend}.normalize(); +} + +template +template +DualQuat DualQuat::gdqblend(const Vec, cn> &_dualquat, InputArray _weight, QuatAssumeType assumeUnit) +{ + Vec, cn> dualquat(_dualquat); + if (cn == 0) + { + return DualQuat(1, 0, 0, 0, 0, 0, 0, 0); + } + Mat dualquat_mat(cn, 1, CV_64FC(8)); + for (int i = 0; i < cn ; ++i) + { + dualquat_mat.at>(i) = dualquat[i].toVec(); + } + return gdqblend(dualquat_mat, _weight, assumeUnit); +} + +} //namespace cv + +#endif /*OPENCV_CORE_DUALQUATERNION_INL_HPP*/ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/eigen.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/eigen.hpp new file mode 100644 index 0000000..51f4147 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/eigen.hpp @@ -0,0 +1,402 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + + +#ifndef OPENCV_CORE_EIGEN_HPP +#define OPENCV_CORE_EIGEN_HPP + +#ifndef EIGEN_WORLD_VERSION +#error "Wrong usage of OpenCV's Eigen utility header. Include Eigen's headers first. See https://github.com/opencv/opencv/issues/17366" +#endif + +#include "opencv2/core.hpp" + +#if defined _MSC_VER && _MSC_VER >= 1200 +#define NOMINMAX // fix https://github.com/opencv/opencv/issues/17548 +#pragma warning( disable: 4714 ) //__forceinline is not inlined +#pragma warning( disable: 4127 ) //conditional expression is constant +#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data +#endif + +#if !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT) +#if EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 \ + && defined(CV_CXX11) && defined(CV_CXX_STD_ARRAY) +#include +#define OPENCV_EIGEN_TENSOR_SUPPORT 1 +#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 +#endif // !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT) + +namespace cv +{ + +/** @addtogroup core_eigen +These functions are provided for OpenCV-Eigen interoperability. They convert `Mat` +objects to corresponding `Eigen::Matrix` objects and vice-versa. Consult the [Eigen +documentation](https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html) for +information about the `Matrix` template type. + +@note Using these functions requires the `Eigen/Dense` or similar header to be +included before this header. +*/ +//! @{ + +#if defined(OPENCV_EIGEN_TENSOR_SUPPORT) || defined(CV_DOXYGEN) +/** @brief Converts an Eigen::Tensor to a cv::Mat. + +The method converts an Eigen::Tensor with shape (H x W x C) to a cv::Mat where: + H = number of rows + W = number of columns + C = number of channels + +Usage: +\code +Eigen::Tensor a_tensor(...); +// populate tensor with values +Mat a_mat; +eigen2cv(a_tensor, a_mat); +\endcode +*/ +template static inline +void eigen2cv( const Eigen::Tensor<_Tp, 3, _layout> &src, OutputArray dst ) +{ + if( !(_layout & Eigen::RowMajorBit) ) + { + const std::array shuffle{2, 1, 0}; + Eigen::Tensor<_Tp, 3, !_layout> row_major_tensor = src.swap_layout().shuffle(shuffle); + Mat _src(src.dimension(0), src.dimension(1), CV_MAKETYPE(DataType<_Tp>::type, src.dimension(2)), row_major_tensor.data()); + _src.copyTo(dst); + } + else + { + Mat _src(src.dimension(0), src.dimension(1), CV_MAKETYPE(DataType<_Tp>::type, src.dimension(2)), (void *)src.data()); + _src.copyTo(dst); + } +} + +/** @brief Converts a cv::Mat to an Eigen::Tensor. + +The method converts a cv::Mat to an Eigen Tensor with shape (H x W x C) where: + H = number of rows + W = number of columns + C = number of channels + +Usage: +\code +Mat a_mat(...); +// populate Mat with values +Eigen::Tensor a_tensor(...); +cv2eigen(a_mat, a_tensor); +\endcode +*/ +template static inline +void cv2eigen( const Mat &src, Eigen::Tensor<_Tp, 3, _layout> &dst ) +{ + if( !(_layout & Eigen::RowMajorBit) ) + { + Eigen::Tensor<_Tp, 3, !_layout> row_major_tensor(src.rows, src.cols, src.channels()); + Mat _dst(src.rows, src.cols, CV_MAKETYPE(DataType<_Tp>::type, src.channels()), row_major_tensor.data()); + if (src.type() == _dst.type()) + src.copyTo(_dst); + else + src.convertTo(_dst, _dst.type()); + const std::array shuffle{2, 1, 0}; + dst = row_major_tensor.swap_layout().shuffle(shuffle); + } + else + { + dst.resize(src.rows, src.cols, src.channels()); + Mat _dst(src.rows, src.cols, CV_MAKETYPE(DataType<_Tp>::type, src.channels()), dst.data()); + if (src.type() == _dst.type()) + src.copyTo(_dst); + else + src.convertTo(_dst, _dst.type()); + } +} + +/** @brief Maps cv::Mat data to an Eigen::TensorMap. + +The method wraps an existing Mat data array with an Eigen TensorMap of shape (H x W x C) where: + H = number of rows + W = number of columns + C = number of channels + +Explicit instantiation of the return type is required. + +@note Caller should be aware of the lifetime of the cv::Mat instance and take appropriate safety measures. +The cv::Mat instance will retain ownership of the data and the Eigen::TensorMap will lose access when the cv::Mat data is deallocated. + +The example below initializes a cv::Mat and produces an Eigen::TensorMap: +\code +float arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; +Mat a_mat(2, 2, CV_32FC3, arr); +Eigen::TensorMap> a_tensormap = cv2eigen_tensormap(a_mat); +\endcode +*/ +template static inline +Eigen::TensorMap> cv2eigen_tensormap(InputArray src) +{ + Mat mat = src.getMat(); + CV_CheckTypeEQ(mat.type(), CV_MAKETYPE(traits::Type<_Tp>::value, mat.channels()), ""); + return Eigen::TensorMap>((_Tp *)mat.data, mat.rows, mat.cols, mat.channels()); +} +#endif // OPENCV_EIGEN_TENSOR_SUPPORT + +template static inline +void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, OutputArray dst ) +{ + if( !(src.Flags & Eigen::RowMajorBit) ) + { + Mat _src(src.cols(), src.rows(), traits::Type<_Tp>::value, + (void*)src.data(), src.outerStride()*sizeof(_Tp)); + transpose(_src, dst); + } + else + { + Mat _src(src.rows(), src.cols(), traits::Type<_Tp>::value, + (void*)src.data(), src.outerStride()*sizeof(_Tp)); + _src.copyTo(dst); + } +} + +// Matx case +template static inline +void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, + Matx<_Tp, _rows, _cols>& dst ) +{ + if( !(src.Flags & Eigen::RowMajorBit) ) + { + dst = Matx<_Tp, _cols, _rows>(static_cast(src.data())).t(); + } + else + { + dst = Matx<_Tp, _rows, _cols>(static_cast(src.data())); + } +} + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) +{ + CV_DbgAssert(src.rows == _rows && src.cols == _cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else if( src.cols == src.rows ) + { + src.convertTo(_dst, _dst.type()); + transpose(_dst, _dst); + } + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +// Matx case +template static inline +void cv2eigen( const Matx<_Tp, _rows, _cols>& src, + Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) +{ + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(_cols, _rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(_rows, _cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + Mat(src).copyTo(_dst); + } +} + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) +{ + dst.resize(src.rows, src.cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else if( src.cols == src.rows ) + { + src.convertTo(_dst, _dst.type()); + transpose(_dst, _dst); + } + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +// Matx case +template static inline +void cv2eigen( const Matx<_Tp, _rows, _cols>& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) +{ + dst.resize(_rows, _cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(_cols, _rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(_rows, _cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + Mat(src).copyTo(_dst); + } +} + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) +{ + CV_Assert(src.cols == 1); + dst.resize(src.rows); + + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +// Matx case +template static inline +void cv2eigen( const Matx<_Tp, _rows, 1>& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) +{ + dst.resize(_rows); + + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(1, _rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(_rows, 1, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.copyTo(_dst); + } +} + + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) +{ + CV_Assert(src.rows == 1); + dst.resize(src.cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +//Matx +template static inline +void cv2eigen( const Matx<_Tp, 1, _cols>& src, + Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) +{ + dst.resize(_cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(_cols, 1, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(1, _cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + Mat(src).copyTo(_dst); + } +} + +//! @} + +} // cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/fast_math.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/fast_math.hpp new file mode 100644 index 0000000..eb4fbe2 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/fast_math.hpp @@ -0,0 +1,411 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_FAST_MATH_HPP +#define OPENCV_CORE_FAST_MATH_HPP + +#include "opencv2/core/cvdef.h" + +//! @addtogroup core_utils +//! @{ + +/****************************************************************************************\ +* fast math * +\****************************************************************************************/ + +#ifdef __cplusplus +# include +#else +# ifdef __BORLANDC__ +# include +# else +# include +# endif +#endif + +#if defined(__CUDACC__) + // nothing, intrinsics/asm code is not supported +#else + #if ((defined _MSC_VER && defined _M_X64) \ + || (defined __GNUC__ && defined __x86_64__ && defined __SSE2__)) \ + && !defined(OPENCV_SKIP_INCLUDE_EMMINTRIN_H) + #include + #endif + + #if defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 \ + && !defined(OPENCV_SKIP_INCLUDE_ALTIVEC_H) + #include + #undef vector + #undef bool + #undef pixel + #endif + + #if defined(CV_INLINE_ROUND_FLT) + // user-specified version + // CV_INLINE_ROUND_DBL should be defined too + #elif defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ + // 1. general scheme + #define ARM_ROUND(_value, _asm_string) \ + int res; \ + float temp; \ + CV_UNUSED(temp); \ + __asm__(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \ + return res + // 2. version for double + #ifdef __clang__ + #define CV_INLINE_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %[value] \n vmov %[res], %[temp]") + #else + #define CV_INLINE_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %P[value] \n vmov %[res], %[temp]") + #endif + // 3. version for float + #define CV_INLINE_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]") + #elif defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 + // P8 and newer machines can convert fp32/64 to int quickly. + #define CV_INLINE_ROUND_DBL(value) \ + int out; \ + double temp; \ + __asm__( "fctiw %[temp],%[in]\n\tmfvsrwz %[out],%[temp]\n\t" : [out] "=r" (out), [temp] "=d" (temp) : [in] "d" ((double)(value)) : ); \ + return out; + + // FP32 also works with FP64 routine above + #define CV_INLINE_ROUND_FLT(value) CV_INLINE_ROUND_DBL(value) + #endif + + #ifdef CV_INLINE_ISINF_FLT + // user-specified version + // CV_INLINE_ISINF_DBL should be defined too + #elif defined __PPC64__ && defined _ARCH_PWR9 && defined(scalar_test_data_class) + #define CV_INLINE_ISINF_DBL(value) return scalar_test_data_class(value, 0x30); + #define CV_INLINE_ISINF_FLT(value) CV_INLINE_ISINF_DBL(value) + #endif + + #ifdef CV_INLINE_ISNAN_FLT + // user-specified version + // CV_INLINE_ISNAN_DBL should be defined too + #elif defined __PPC64__ && defined _ARCH_PWR9 && defined(scalar_test_data_class) + #define CV_INLINE_ISNAN_DBL(value) return scalar_test_data_class(value, 0x40); + #define CV_INLINE_ISNAN_FLT(value) CV_INLINE_ISNAN_DBL(value) + #endif + + #if !defined(OPENCV_USE_FASTMATH_BUILTINS) \ + && ( \ + defined(__x86_64__) || defined(__i686__) \ + || defined(__arm__) \ + || defined(__PPC64__) \ + ) + /* Let builtin C math functions when available. Dedicated hardware is available to + round and convert FP values. */ + #define OPENCV_USE_FASTMATH_BUILTINS 1 + #endif + + /* Enable builtin math functions if possible, desired, and available. + Note, not all math functions inline equally. E.g lrint will not inline + without the -fno-math-errno option. */ + #if defined(CV_ICC) + // nothing + #elif defined(OPENCV_USE_FASTMATH_BUILTINS) && OPENCV_USE_FASTMATH_BUILTINS + #if defined(__clang__) + #define CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS + #if !defined(CV_INLINE_ISNAN_DBL) && __has_builtin(__builtin_isnan) + #define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value); + #endif + #if !defined(CV_INLINE_ISNAN_FLT) && __has_builtin(__builtin_isnan) + #define CV_INLINE_ISNAN_FLT(value) return __builtin_isnan(value); + #endif + #if !defined(CV_INLINE_ISINF_DBL) && __has_builtin(__builtin_isinf) + #define CV_INLINE_ISINF_DBL(value) return __builtin_isinf(value); + #endif + #if !defined(CV_INLINE_ISINF_FLT) && __has_builtin(__builtin_isinf) + #define CV_INLINE_ISINF_FLT(value) return __builtin_isinf(value); + #endif + #elif defined(__GNUC__) + #define CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS + #if !defined(CV_INLINE_ISNAN_DBL) + #define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value); + #endif + #if !defined(CV_INLINE_ISNAN_FLT) + #define CV_INLINE_ISNAN_FLT(value) return __builtin_isnanf(value); + #endif + #if !defined(CV_INLINE_ISINF_DBL) + #define CV_INLINE_ISINF_DBL(value) return __builtin_isinf(value); + #endif + #if !defined(CV_INLINE_ISINF_FLT) + #define CV_INLINE_ISINF_FLT(value) return __builtin_isinff(value); + #endif + #elif defined(_MSC_VER) + #if !defined(CV_INLINE_ISNAN_DBL) + #define CV_INLINE_ISNAN_DBL(value) return isnan(value); + #endif + #if !defined(CV_INLINE_ISNAN_FLT) + #define CV_INLINE_ISNAN_FLT(value) return isnan(value); + #endif + #if !defined(CV_INLINE_ISINF_DBL) + #define CV_INLINE_ISINF_DBL(value) return isinf(value); + #endif + #if !defined(CV_INLINE_ISINF_FLT) + #define CV_INLINE_ISINF_FLT(value) return isinf(value); + #endif + #endif + #endif + +#endif // defined(__CUDACC__) + +/** @brief Rounds floating-point number to the nearest integer + + @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the + result is not defined. + */ +CV_INLINE int +cvRound( double value ) +{ +#if defined CV_INLINE_ROUND_DBL + CV_INLINE_ROUND_DBL(value); +#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \ + && defined __SSE2__ && !defined __APPLE__) || CV_SSE2) \ + && !defined(__CUDACC__) + __m128d t = _mm_set_sd( value ); + return _mm_cvtsd_si32(t); +#elif defined _MSC_VER && defined _M_IX86 + int t; + __asm + { + fld value; + fistp t; + } + return t; +#elif defined CV_ICC || defined __GNUC__ + return (int)(lrint(value)); +#else + /* it's ok if round does not comply with IEEE754 standard; + the tests should allow +/-1 difference when the tested functions use round */ + return (int)(value + (value >= 0 ? 0.5 : -0.5)); +#endif +} + + +/** @brief Rounds floating-point number to the nearest integer not larger than the original. + + The function computes an integer i such that: + \f[i \le \texttt{value} < i+1\f] + @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the + result is not defined. + */ +CV_INLINE int cvFloor( double value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_floor(value); +#else + int i = (int)value; + return i - (i > value); +#endif +} + +/** @brief Rounds floating-point number to the nearest integer not smaller than the original. + + The function computes an integer i such that: + \f[i \le \texttt{value} < i+1\f] + @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the + result is not defined. + */ +CV_INLINE int cvCeil( double value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_ceil(value); +#else + int i = (int)value; + return i + (i < value); +#endif +} + +/** @brief Determines if the argument is Not A Number. + + @param value The input floating-point value + + The function returns 1 if the argument is Not A Number (as defined by IEEE754 standard), 0 + otherwise. */ +CV_INLINE int cvIsNaN( double value ) +{ +#if defined CV_INLINE_ISNAN_DBL + CV_INLINE_ISNAN_DBL(value); +#else + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) + + ((unsigned)ieee754.u != 0) > 0x7ff00000; +#endif +} + +/** @brief Determines if the argument is Infinity. + + @param value The input floating-point value + + The function returns 1 if the argument is a plus or minus infinity (as defined by IEEE754 standard) + and 0 otherwise. */ +CV_INLINE int cvIsInf( double value ) +{ +#if defined CV_INLINE_ISINF_DBL + CV_INLINE_ISINF_DBL(value); +#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__PPC64__) + Cv64suf ieee754; + ieee754.f = value; + return (ieee754.u & 0x7fffffff00000000) == + 0x7ff0000000000000; +#else + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && + (unsigned)ieee754.u == 0; +#endif +} + +#ifdef __cplusplus + +/** @overload */ +CV_INLINE int cvRound(float value) +{ +#if defined CV_INLINE_ROUND_FLT + CV_INLINE_ROUND_FLT(value); +#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \ + && defined __SSE2__ && !defined __APPLE__) || CV_SSE2) \ + && !defined(__CUDACC__) + __m128 t = _mm_set_ss( value ); + return _mm_cvtss_si32(t); +#elif defined _MSC_VER && defined _M_IX86 + int t; + __asm + { + fld value; + fistp t; + } + return t; +#elif defined CV_ICC || defined __GNUC__ + return (int)(lrintf(value)); +#else + /* it's ok if round does not comply with IEEE754 standard; + the tests should allow +/-1 difference when the tested functions use round */ + return (int)(value + (value >= 0 ? 0.5f : -0.5f)); +#endif +} + +/** @overload */ +CV_INLINE int cvRound( int value ) +{ + return value; +} + +/** @overload */ +CV_INLINE int cvFloor( float value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_floorf(value); +#else + int i = (int)value; + return i - (i > value); +#endif +} + +/** @overload */ +CV_INLINE int cvFloor( int value ) +{ + return value; +} + +/** @overload */ +CV_INLINE int cvCeil( float value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_ceilf(value); +#else + int i = (int)value; + return i + (i < value); +#endif +} + +/** @overload */ +CV_INLINE int cvCeil( int value ) +{ + return value; +} + +/** @overload */ +CV_INLINE int cvIsNaN( float value ) +{ +#if defined CV_INLINE_ISNAN_FLT + CV_INLINE_ISNAN_FLT(value); +#else + Cv32suf ieee754; + ieee754.f = value; + return (ieee754.u & 0x7fffffff) > 0x7f800000; +#endif +} + +/** @overload */ +CV_INLINE int cvIsInf( float value ) +{ +#if defined CV_INLINE_ISINF_FLT + CV_INLINE_ISINF_FLT(value); +#else + Cv32suf ieee754; + ieee754.f = value; + return (ieee754.u & 0x7fffffff) == 0x7f800000; +#endif +} + +#endif // __cplusplus + +//! @} core_utils + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/hal.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/hal.hpp new file mode 100644 index 0000000..0d68078 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/hal.hpp @@ -0,0 +1,256 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_HPP +#define OPENCV_HAL_HPP + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/hal/interface.h" + +namespace cv { namespace hal { + +//! @addtogroup core_hal_functions +//! @{ + +CV_EXPORTS int normHamming(const uchar* a, int n); +CV_EXPORTS int normHamming(const uchar* a, const uchar* b, int n); + +CV_EXPORTS int normHamming(const uchar* a, int n, int cellSize); +CV_EXPORTS int normHamming(const uchar* a, const uchar* b, int n, int cellSize); + +CV_EXPORTS int LU32f(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS int LU64f(double* A, size_t astep, int m, double* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky32f(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky64f(double* A, size_t astep, int m, double* b, size_t bstep, int n); +CV_EXPORTS void SVD32f(float* At, size_t astep, float* W, float* U, size_t ustep, float* Vt, size_t vstep, int m, int n, int flags); +CV_EXPORTS void SVD64f(double* At, size_t astep, double* W, double* U, size_t ustep, double* Vt, size_t vstep, int m, int n, int flags); +CV_EXPORTS int QR32f(float* A, size_t astep, int m, int n, int k, float* b, size_t bstep, float* hFactors); +CV_EXPORTS int QR64f(double* A, size_t astep, int m, int n, int k, double* b, size_t bstep, double* hFactors); + +CV_EXPORTS void gemm32f(const float* src1, size_t src1_step, const float* src2, size_t src2_step, + float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); +CV_EXPORTS void gemm64f(const double* src1, size_t src1_step, const double* src2, size_t src2_step, + double alpha, const double* src3, size_t src3_step, double beta, double* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); +CV_EXPORTS void gemm32fc(const float* src1, size_t src1_step, const float* src2, size_t src2_step, + float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); +CV_EXPORTS void gemm64fc(const double* src1, size_t src1_step, const double* src2, size_t src2_step, + double alpha, const double* src3, size_t src3_step, double beta, double* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); + +CV_EXPORTS int normL1_(const uchar* a, const uchar* b, int n); +CV_EXPORTS float normL1_(const float* a, const float* b, int n); +CV_EXPORTS float normL2Sqr_(const float* a, const float* b, int n); + +CV_EXPORTS void exp32f(const float* src, float* dst, int n); +CV_EXPORTS void exp64f(const double* src, double* dst, int n); +CV_EXPORTS void log32f(const float* src, float* dst, int n); +CV_EXPORTS void log64f(const double* src, double* dst, int n); + +CV_EXPORTS void fastAtan32f(const float* y, const float* x, float* dst, int n, bool angleInDegrees); +CV_EXPORTS void fastAtan64f(const double* y, const double* x, double* dst, int n, bool angleInDegrees); +CV_EXPORTS void magnitude32f(const float* x, const float* y, float* dst, int n); +CV_EXPORTS void magnitude64f(const double* x, const double* y, double* dst, int n); +CV_EXPORTS void sqrt32f(const float* src, float* dst, int len); +CV_EXPORTS void sqrt64f(const double* src, double* dst, int len); +CV_EXPORTS void invSqrt32f(const float* src, float* dst, int len); +CV_EXPORTS void invSqrt64f(const double* src, double* dst, int len); + +CV_EXPORTS void split8u(const uchar* src, uchar** dst, int len, int cn ); +CV_EXPORTS void split16u(const ushort* src, ushort** dst, int len, int cn ); +CV_EXPORTS void split32s(const int* src, int** dst, int len, int cn ); +CV_EXPORTS void split64s(const int64* src, int64** dst, int len, int cn ); + +CV_EXPORTS void merge8u(const uchar** src, uchar* dst, int len, int cn ); +CV_EXPORTS void merge16u(const ushort** src, ushort* dst, int len, int cn ); +CV_EXPORTS void merge32s(const int** src, int* dst, int len, int cn ); +CV_EXPORTS void merge64s(const int64** src, int64* dst, int len, int cn ); + +CV_EXPORTS void add8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void sub8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void max8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void min8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void absdiff8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void and8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void or8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void xor8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void not8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp8s(const schar* src1, size_t step1, const schar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp16s(const short* src1, size_t step1, const short* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp32s(const int* src1, size_t step1, const int* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp32f(const float* src1, size_t step1, const float* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp64f(const double* src1, size_t step1, const double* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); + +CV_EXPORTS void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale); + +CV_EXPORTS void div8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale); + +CV_EXPORTS void recip8u( const uchar *, size_t, const uchar * src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip8s( const schar *, size_t, const schar * src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip16u( const ushort *, size_t, const ushort * src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip16s( const short *, size_t, const short * src2, size_t step2, short* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip32s( const int *, size_t, const int * src2, size_t step2, int* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip32f( const float *, size_t, const float * src2, size_t step2, float* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip64f( const double *, size_t, const double * src2, size_t step2, double* dst, size_t step, int width, int height, void* scale); + +CV_EXPORTS void addWeighted8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _scalars ); +CV_EXPORTS void addWeighted8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scalars ); + +CV_EXPORTS void cvt16f32f( const float16_t* src, float* dst, int len ); +CV_EXPORTS void cvt32f16f( const float* src, float16_t* dst, int len ); + +CV_EXPORTS void addRNGBias32f( float* arr, const float* scaleBiasPairs, int len ); +CV_EXPORTS void addRNGBias64f( double* arr, const double* scaleBiasPairs, int len ); + +struct CV_EXPORTS DFT1D +{ + static Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0); + virtual void apply(const uchar *src, uchar *dst) = 0; + virtual ~DFT1D() {} +}; + +struct CV_EXPORTS DFT2D +{ + static Ptr create(int width, int height, int depth, + int src_channels, int dst_channels, + int flags, int nonzero_rows = 0); + virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; + virtual ~DFT2D() {} +}; + +struct CV_EXPORTS DCT2D +{ + static Ptr create(int width, int height, int depth, int flags); + virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; + virtual ~DCT2D() {} +}; + +//! @} core_hal + +//============================================================================= +// for binary compatibility with 3.0 + +//! @cond IGNORED + +CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n); + +CV_EXPORTS void exp(const float* src, float* dst, int n); +CV_EXPORTS void exp(const double* src, double* dst, int n); +CV_EXPORTS void log(const float* src, float* dst, int n); +CV_EXPORTS void log(const double* src, double* dst, int n); + +CV_EXPORTS void fastAtan2(const float* y, const float* x, float* dst, int n, bool angleInDegrees); +CV_EXPORTS void magnitude(const float* x, const float* y, float* dst, int n); +CV_EXPORTS void magnitude(const double* x, const double* y, double* dst, int n); +CV_EXPORTS void sqrt(const float* src, float* dst, int len); +CV_EXPORTS void sqrt(const double* src, double* dst, int len); +CV_EXPORTS void invSqrt(const float* src, float* dst, int len); +CV_EXPORTS void invSqrt(const double* src, double* dst, int len); + +//! @endcond + +}} //cv::hal + +#endif //OPENCV_HAL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/interface.h b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/interface.h new file mode 100644 index 0000000..6f0a83d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/interface.h @@ -0,0 +1,190 @@ +#ifndef OPENCV_CORE_HAL_INTERFACE_H +#define OPENCV_CORE_HAL_INTERFACE_H + +//! @addtogroup core_hal_interface +//! @{ + +//! @name Return codes +//! @{ +#define CV_HAL_ERROR_OK 0 +#define CV_HAL_ERROR_NOT_IMPLEMENTED 1 +#define CV_HAL_ERROR_UNKNOWN -1 +//! @} + +#ifdef __cplusplus +#include +#else +#include +#include +#endif + +//! @name Data types +//! primitive types +//! - schar - signed 1 byte integer +//! - uchar - unsigned 1 byte integer +//! - short - signed 2 byte integer +//! - ushort - unsigned 2 byte integer +//! - int - signed 4 byte integer +//! - uint - unsigned 4 byte integer +//! - int64 - signed 8 byte integer +//! - uint64 - unsigned 8 byte integer +//! @{ +#if !defined _MSC_VER && !defined __BORLANDC__ +# if defined __cplusplus && __cplusplus >= 201103L && !defined __APPLE__ +# include +# ifdef __NEWLIB__ + typedef unsigned int uint; +# else + typedef std::uint32_t uint; +# endif +# else +# include + typedef uint32_t uint; +# endif +#else + typedef unsigned uint; +#endif + +typedef signed char schar; + +#ifndef __IPL_H__ + typedef unsigned char uchar; + typedef unsigned short ushort; +#endif + +#if defined _MSC_VER || defined __BORLANDC__ + typedef __int64 int64; + typedef unsigned __int64 uint64; +# define CV_BIG_INT(n) n##I64 +# define CV_BIG_UINT(n) n##UI64 +#else + typedef int64_t int64; + typedef uint64_t uint64; +# define CV_BIG_INT(n) n##LL +# define CV_BIG_UINT(n) n##ULL +#endif + +#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" + +#define CV_CN_MAX 512 +#define CV_CN_SHIFT 3 +#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) + +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 +#define CV_16F 7 + +#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) +#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) + +#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKE_TYPE CV_MAKETYPE + +#define CV_8UC1 CV_MAKETYPE(CV_8U,1) +#define CV_8UC2 CV_MAKETYPE(CV_8U,2) +#define CV_8UC3 CV_MAKETYPE(CV_8U,3) +#define CV_8UC4 CV_MAKETYPE(CV_8U,4) +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) + +#define CV_8SC1 CV_MAKETYPE(CV_8S,1) +#define CV_8SC2 CV_MAKETYPE(CV_8S,2) +#define CV_8SC3 CV_MAKETYPE(CV_8S,3) +#define CV_8SC4 CV_MAKETYPE(CV_8S,4) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) + +#define CV_16UC1 CV_MAKETYPE(CV_16U,1) +#define CV_16UC2 CV_MAKETYPE(CV_16U,2) +#define CV_16UC3 CV_MAKETYPE(CV_16U,3) +#define CV_16UC4 CV_MAKETYPE(CV_16U,4) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) + +#define CV_16SC1 CV_MAKETYPE(CV_16S,1) +#define CV_16SC2 CV_MAKETYPE(CV_16S,2) +#define CV_16SC3 CV_MAKETYPE(CV_16S,3) +#define CV_16SC4 CV_MAKETYPE(CV_16S,4) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_32SC1 CV_MAKETYPE(CV_32S,1) +#define CV_32SC2 CV_MAKETYPE(CV_32S,2) +#define CV_32SC3 CV_MAKETYPE(CV_32S,3) +#define CV_32SC4 CV_MAKETYPE(CV_32S,4) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) + +#define CV_32FC1 CV_MAKETYPE(CV_32F,1) +#define CV_32FC2 CV_MAKETYPE(CV_32F,2) +#define CV_32FC3 CV_MAKETYPE(CV_32F,3) +#define CV_32FC4 CV_MAKETYPE(CV_32F,4) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) + +#define CV_64FC1 CV_MAKETYPE(CV_64F,1) +#define CV_64FC2 CV_MAKETYPE(CV_64F,2) +#define CV_64FC3 CV_MAKETYPE(CV_64F,3) +#define CV_64FC4 CV_MAKETYPE(CV_64F,4) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + +#define CV_16FC1 CV_MAKETYPE(CV_16F,1) +#define CV_16FC2 CV_MAKETYPE(CV_16F,2) +#define CV_16FC3 CV_MAKETYPE(CV_16F,3) +#define CV_16FC4 CV_MAKETYPE(CV_16F,4) +#define CV_16FC(n) CV_MAKETYPE(CV_16F,(n)) +//! @} + +//! @name Comparison operation +//! @sa cv::CmpTypes +//! @{ +#define CV_HAL_CMP_EQ 0 +#define CV_HAL_CMP_GT 1 +#define CV_HAL_CMP_GE 2 +#define CV_HAL_CMP_LT 3 +#define CV_HAL_CMP_LE 4 +#define CV_HAL_CMP_NE 5 +//! @} + +//! @name Border processing modes +//! @sa cv::BorderTypes +//! @{ +#define CV_HAL_BORDER_CONSTANT 0 +#define CV_HAL_BORDER_REPLICATE 1 +#define CV_HAL_BORDER_REFLECT 2 +#define CV_HAL_BORDER_WRAP 3 +#define CV_HAL_BORDER_REFLECT_101 4 +#define CV_HAL_BORDER_TRANSPARENT 5 +#define CV_HAL_BORDER_ISOLATED 16 +//! @} + +//! @name DFT flags +//! @{ +#define CV_HAL_DFT_INVERSE 1 +#define CV_HAL_DFT_SCALE 2 +#define CV_HAL_DFT_ROWS 4 +#define CV_HAL_DFT_COMPLEX_OUTPUT 16 +#define CV_HAL_DFT_REAL_OUTPUT 32 +#define CV_HAL_DFT_TWO_STAGE 64 +#define CV_HAL_DFT_STAGE_COLS 128 +#define CV_HAL_DFT_IS_CONTINUOUS 512 +#define CV_HAL_DFT_IS_INPLACE 1024 +//! @} + +//! @name SVD flags +//! @{ +#define CV_HAL_SVD_NO_UV 1 +#define CV_HAL_SVD_SHORT_UV 2 +#define CV_HAL_SVD_MODIFY_A 4 +#define CV_HAL_SVD_FULL_UV 8 +//! @} + +//! @name Gemm flags +//! @{ +#define CV_HAL_GEMM_1_T 1 +#define CV_HAL_GEMM_2_T 2 +#define CV_HAL_GEMM_3_T 4 +//! @} + +//! @} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin.hpp new file mode 100644 index 0000000..ac331f2 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin.hpp @@ -0,0 +1,706 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_INTRIN_HPP +#define OPENCV_HAL_INTRIN_HPP + +#include +#include +#include +#include "opencv2/core/cvdef.h" + +#define OPENCV_HAL_ADD(a, b) ((a) + (b)) +#define OPENCV_HAL_AND(a, b) ((a) & (b)) +#define OPENCV_HAL_NOP(a) (a) +#define OPENCV_HAL_1ST(a, b) (a) + +namespace { +inline unsigned int trailingZeros32(unsigned int value) { +#if defined(_MSC_VER) +#if (_MSC_VER < 1700) || defined(_M_ARM) || defined(_M_ARM64) + unsigned long index = 0; + _BitScanForward(&index, value); + return (unsigned int)index; +#elif defined(__clang__) + // clang-cl doesn't export _tzcnt_u32 for non BMI systems + return value ? __builtin_ctz(value) : 32; +#else + return _tzcnt_u32(value); +#endif +#elif defined(__GNUC__) || defined(__GNUG__) + return __builtin_ctz(value); +#elif defined(__ICC) || defined(__INTEL_COMPILER) + return _bit_scan_forward(value); +#elif defined(__clang__) + return llvm.cttz.i32(value, true); +#else + static const int MultiplyDeBruijnBitPosition[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; + return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27]; +#endif +} +} + +// unlike HAL API, which is in cv::hal, +// we put intrinsics into cv namespace to make its +// access from within opencv code more accessible +namespace cv { + +namespace hal { + +enum StoreMode +{ + STORE_UNALIGNED = 0, + STORE_ALIGNED = 1, + STORE_ALIGNED_NOCACHE = 2 +}; + +} + +// TODO FIXIT: Don't use "God" traits. Split on separate cases. +template struct V_TypeTraits +{ +}; + +#define CV_INTRIN_DEF_TYPE_TRAITS(type, int_type_, uint_type_, abs_type_, w_type_, q_type_, sum_type_) \ + template<> struct V_TypeTraits \ + { \ + typedef type value_type; \ + typedef int_type_ int_type; \ + typedef abs_type_ abs_type; \ + typedef uint_type_ uint_type; \ + typedef w_type_ w_type; \ + typedef q_type_ q_type; \ + typedef sum_type_ sum_type; \ + \ + static inline int_type reinterpret_int(type x) \ + { \ + union { type l; int_type i; } v; \ + v.l = x; \ + return v.i; \ + } \ + \ + static inline type reinterpret_from_int(int_type x) \ + { \ + union { type l; int_type i; } v; \ + v.i = x; \ + return v.l; \ + } \ + } + +#define CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(type, int_type_, uint_type_, abs_type_, w_type_, sum_type_) \ + template<> struct V_TypeTraits \ + { \ + typedef type value_type; \ + typedef int_type_ int_type; \ + typedef abs_type_ abs_type; \ + typedef uint_type_ uint_type; \ + typedef w_type_ w_type; \ + typedef sum_type_ sum_type; \ + \ + static inline int_type reinterpret_int(type x) \ + { \ + union { type l; int_type i; } v; \ + v.l = x; \ + return v.i; \ + } \ + \ + static inline type reinterpret_from_int(int_type x) \ + { \ + union { type l; int_type i; } v; \ + v.i = x; \ + return v.l; \ + } \ + } + +CV_INTRIN_DEF_TYPE_TRAITS(uchar, schar, uchar, uchar, ushort, unsigned, unsigned); +CV_INTRIN_DEF_TYPE_TRAITS(schar, schar, uchar, uchar, short, int, int); +CV_INTRIN_DEF_TYPE_TRAITS(ushort, short, ushort, ushort, unsigned, uint64, unsigned); +CV_INTRIN_DEF_TYPE_TRAITS(short, short, ushort, ushort, int, int64, int); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(unsigned, int, unsigned, unsigned, uint64, unsigned); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(int, int, unsigned, unsigned, int64, int); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(float, int, unsigned, float, double, float); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(uint64, int64, uint64, uint64, void, uint64); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(int64, int64, uint64, uint64, void, int64); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(double, int64, uint64, double, void, double); + +#ifndef CV_DOXYGEN + +#ifndef CV_CPU_OPTIMIZATION_HAL_NAMESPACE +#ifdef CV_FORCE_SIMD128_CPP + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_EMULATOR_CPP + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_EMULATOR_CPP { + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END } +#elif defined(CV_CPU_DISPATCH_MODE) + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) { + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END } +#else + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline { + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END } +#endif +#endif // CV_CPU_OPTIMIZATION_HAL_NAMESPACE + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END +using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE; +#endif +} + +#ifdef CV_DOXYGEN +# undef CV_AVX2 +# undef CV_SSE2 +# undef CV_NEON +# undef CV_VSX +# undef CV_FP16 +# undef CV_MSA +# undef CV_RVV +#endif + +#if (CV_SSE2 || CV_NEON || CV_VSX || CV_MSA || CV_WASM_SIMD || CV_RVV071 || CV_RVV) && !defined(CV_FORCE_SIMD128_CPP) +#define CV__SIMD_FORWARD 128 +#include "opencv2/core/hal/intrin_forward.hpp" +#endif + +#if CV_SSE2 && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_sse_em.hpp" +#include "opencv2/core/hal/intrin_sse.hpp" + +#elif CV_NEON && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_neon.hpp" + +#elif CV_RVV071 && !defined(CV_FORCE_SIMD128_CPP) +#define CV_SIMD128_CPP 0 +#include "opencv2/core/hal/intrin_rvv071.hpp" + +#elif CV_VSX && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_vsx.hpp" + +#elif CV_MSA && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_msa.hpp" + +#elif CV_WASM_SIMD && !defined(CV_FORCE_SIMD128_CPP) +#include "opencv2/core/hal/intrin_wasm.hpp" + +#elif CV_RVV && !defined(CV_FORCE_SIMD128_CPP) +#include "opencv2/core/hal/intrin_rvv.hpp" + +#else + +#include "opencv2/core/hal/intrin_cpp.hpp" + +#endif + +// AVX2 can be used together with SSE2, so +// we define those two sets of intrinsics at once. +// Most of the intrinsics do not conflict (the proper overloaded variant is +// resolved by the argument types, e.g. v_float32x4 ~ SSE2, v_float32x8 ~ AVX2), +// but some of AVX2 intrinsics get v256_ prefix instead of v_, e.g. v256_load() vs v_load(). +// Correspondingly, the wide intrinsics (which are mapped to the "widest" +// available instruction set) will get vx_ prefix +// (and will be mapped to v256_ counterparts) (e.g. vx_load() => v256_load()) +#if CV_AVX2 + +#define CV__SIMD_FORWARD 256 +#include "opencv2/core/hal/intrin_forward.hpp" +#include "opencv2/core/hal/intrin_avx.hpp" + +#endif + +// AVX512 can be used together with SSE2 and AVX2, so +// we define those sets of intrinsics at once. +// For some of AVX512 intrinsics get v512_ prefix instead of v_, e.g. v512_load() vs v_load(). +// Wide intrinsics will be mapped to v512_ counterparts in this case(e.g. vx_load() => v512_load()) +#if CV_AVX512_SKX + +#define CV__SIMD_FORWARD 512 +#include "opencv2/core/hal/intrin_forward.hpp" +#include "opencv2/core/hal/intrin_avx512.hpp" + +#endif + +//! @cond IGNORED + +namespace cv { + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN +#endif + +#ifndef CV_SIMD128 +#define CV_SIMD128 0 +#endif + +#ifndef CV_SIMD128_CPP +#define CV_SIMD128_CPP 0 +#endif + +#ifndef CV_SIMD128_64F +#define CV_SIMD128_64F 0 +#endif + +#ifndef CV_SIMD256 +#define CV_SIMD256 0 +#endif + +#ifndef CV_SIMD256_64F +#define CV_SIMD256_64F 0 +#endif + +#ifndef CV_SIMD512 +#define CV_SIMD512 0 +#endif + +#ifndef CV_SIMD512_64F +#define CV_SIMD512_64F 0 +#endif + +#ifndef CV_SIMD128_FP16 +#define CV_SIMD128_FP16 0 +#endif + +#ifndef CV_SIMD256_FP16 +#define CV_SIMD256_FP16 0 +#endif + +#ifndef CV_SIMD512_FP16 +#define CV_SIMD512_FP16 0 +#endif + +//================================================================================================== + +template struct V_RegTraits +{ +}; + +#define CV_DEF_REG_TRAITS(prefix, _reg, lane_type, suffix, _u_reg, _w_reg, _q_reg, _int_reg, _round_reg) \ + template<> struct V_RegTraits<_reg> \ + { \ + typedef _reg reg; \ + typedef _u_reg u_reg; \ + typedef _w_reg w_reg; \ + typedef _q_reg q_reg; \ + typedef _int_reg int_reg; \ + typedef _round_reg round_reg; \ + } + +#if CV_SIMD128 || CV_SIMD128_CPP + CV_DEF_REG_TRAITS(v, v_uint8x16, uchar, u8, v_uint8x16, v_uint16x8, v_uint32x4, v_int8x16, void); + CV_DEF_REG_TRAITS(v, v_int8x16, schar, s8, v_uint8x16, v_int16x8, v_int32x4, v_int8x16, void); + CV_DEF_REG_TRAITS(v, v_uint16x8, ushort, u16, v_uint16x8, v_uint32x4, v_uint64x2, v_int16x8, void); + CV_DEF_REG_TRAITS(v, v_int16x8, short, s16, v_uint16x8, v_int32x4, v_int64x2, v_int16x8, void); + CV_DEF_REG_TRAITS(v, v_uint32x4, unsigned, u32, v_uint32x4, v_uint64x2, void, v_int32x4, void); + CV_DEF_REG_TRAITS(v, v_int32x4, int, s32, v_uint32x4, v_int64x2, void, v_int32x4, void); +#if CV_SIMD128_64F || CV_SIMD128_CPP + CV_DEF_REG_TRAITS(v, v_float32x4, float, f32, v_float32x4, v_float64x2, void, v_int32x4, v_int32x4); +#else + CV_DEF_REG_TRAITS(v, v_float32x4, float, f32, v_float32x4, void, void, v_int32x4, v_int32x4); +#endif + CV_DEF_REG_TRAITS(v, v_uint64x2, uint64, u64, v_uint64x2, void, void, v_int64x2, void); + CV_DEF_REG_TRAITS(v, v_int64x2, int64, s64, v_uint64x2, void, void, v_int64x2, void); +#if CV_SIMD128_64F + CV_DEF_REG_TRAITS(v, v_float64x2, double, f64, v_float64x2, void, void, v_int64x2, v_int32x4); +#endif +#endif + +#if CV_SIMD256 + CV_DEF_REG_TRAITS(v256, v_uint8x32, uchar, u8, v_uint8x32, v_uint16x16, v_uint32x8, v_int8x32, void); + CV_DEF_REG_TRAITS(v256, v_int8x32, schar, s8, v_uint8x32, v_int16x16, v_int32x8, v_int8x32, void); + CV_DEF_REG_TRAITS(v256, v_uint16x16, ushort, u16, v_uint16x16, v_uint32x8, v_uint64x4, v_int16x16, void); + CV_DEF_REG_TRAITS(v256, v_int16x16, short, s16, v_uint16x16, v_int32x8, v_int64x4, v_int16x16, void); + CV_DEF_REG_TRAITS(v256, v_uint32x8, unsigned, u32, v_uint32x8, v_uint64x4, void, v_int32x8, void); + CV_DEF_REG_TRAITS(v256, v_int32x8, int, s32, v_uint32x8, v_int64x4, void, v_int32x8, void); + CV_DEF_REG_TRAITS(v256, v_float32x8, float, f32, v_float32x8, v_float64x4, void, v_int32x8, v_int32x8); + CV_DEF_REG_TRAITS(v256, v_uint64x4, uint64, u64, v_uint64x4, void, void, v_int64x4, void); + CV_DEF_REG_TRAITS(v256, v_int64x4, int64, s64, v_uint64x4, void, void, v_int64x4, void); + CV_DEF_REG_TRAITS(v256, v_float64x4, double, f64, v_float64x4, void, void, v_int64x4, v_int32x8); +#endif + +#if CV_SIMD512 + CV_DEF_REG_TRAITS(v512, v_uint8x64, uchar, u8, v_uint8x64, v_uint16x32, v_uint32x16, v_int8x64, void); + CV_DEF_REG_TRAITS(v512, v_int8x64, schar, s8, v_uint8x64, v_int16x32, v_int32x16, v_int8x64, void); + CV_DEF_REG_TRAITS(v512, v_uint16x32, ushort, u16, v_uint16x32, v_uint32x16, v_uint64x8, v_int16x32, void); + CV_DEF_REG_TRAITS(v512, v_int16x32, short, s16, v_uint16x32, v_int32x16, v_int64x8, v_int16x32, void); + CV_DEF_REG_TRAITS(v512, v_uint32x16, unsigned, u32, v_uint32x16, v_uint64x8, void, v_int32x16, void); + CV_DEF_REG_TRAITS(v512, v_int32x16, int, s32, v_uint32x16, v_int64x8, void, v_int32x16, void); + CV_DEF_REG_TRAITS(v512, v_float32x16, float, f32, v_float32x16, v_float64x8, void, v_int32x16, v_int32x16); + CV_DEF_REG_TRAITS(v512, v_uint64x8, uint64, u64, v_uint64x8, void, void, v_int64x8, void); + CV_DEF_REG_TRAITS(v512, v_int64x8, int64, s64, v_uint64x8, void, void, v_int64x8, void); + CV_DEF_REG_TRAITS(v512, v_float64x8, double, f64, v_float64x8, void, void, v_int64x8, v_int32x16); +#endif +//! @endcond + +#if CV_SIMD512 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 512) +#define CV__SIMD_NAMESPACE simd512 +namespace CV__SIMD_NAMESPACE { + #define CV_SIMD 1 + #define CV_SIMD_64F CV_SIMD512_64F + #define CV_SIMD_FP16 CV_SIMD512_FP16 + #define CV_SIMD_WIDTH 64 +//! @addtogroup core_hal_intrin +//! @{ + //! @brief Maximum available vector register capacity 8-bit unsigned integer values + typedef v_uint8x64 v_uint8; + //! @brief Maximum available vector register capacity 8-bit signed integer values + typedef v_int8x64 v_int8; + //! @brief Maximum available vector register capacity 16-bit unsigned integer values + typedef v_uint16x32 v_uint16; + //! @brief Maximum available vector register capacity 16-bit signed integer values + typedef v_int16x32 v_int16; + //! @brief Maximum available vector register capacity 32-bit unsigned integer values + typedef v_uint32x16 v_uint32; + //! @brief Maximum available vector register capacity 32-bit signed integer values + typedef v_int32x16 v_int32; + //! @brief Maximum available vector register capacity 64-bit unsigned integer values + typedef v_uint64x8 v_uint64; + //! @brief Maximum available vector register capacity 64-bit signed integer values + typedef v_int64x8 v_int64; + //! @brief Maximum available vector register capacity 32-bit floating point values (single precision) + typedef v_float32x16 v_float32; + #if CV_SIMD512_64F + //! @brief Maximum available vector register capacity 64-bit floating point values (double precision) + typedef v_float64x8 v_float64; + #endif +//! @} + + #define VXPREFIX(func) v512##func +} // namespace +using namespace CV__SIMD_NAMESPACE; +#elif CV_SIMD256 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 256) +#define CV__SIMD_NAMESPACE simd256 +namespace CV__SIMD_NAMESPACE { + #define CV_SIMD 1 + #define CV_SIMD_64F CV_SIMD256_64F + #define CV_SIMD_FP16 CV_SIMD256_FP16 + #define CV_SIMD_WIDTH 32 +//! @addtogroup core_hal_intrin +//! @{ + //! @brief Maximum available vector register capacity 8-bit unsigned integer values + typedef v_uint8x32 v_uint8; + //! @brief Maximum available vector register capacity 8-bit signed integer values + typedef v_int8x32 v_int8; + //! @brief Maximum available vector register capacity 16-bit unsigned integer values + typedef v_uint16x16 v_uint16; + //! @brief Maximum available vector register capacity 16-bit signed integer values + typedef v_int16x16 v_int16; + //! @brief Maximum available vector register capacity 32-bit unsigned integer values + typedef v_uint32x8 v_uint32; + //! @brief Maximum available vector register capacity 32-bit signed integer values + typedef v_int32x8 v_int32; + //! @brief Maximum available vector register capacity 64-bit unsigned integer values + typedef v_uint64x4 v_uint64; + //! @brief Maximum available vector register capacity 64-bit signed integer values + typedef v_int64x4 v_int64; + //! @brief Maximum available vector register capacity 32-bit floating point values (single precision) + typedef v_float32x8 v_float32; + #if CV_SIMD256_64F + //! @brief Maximum available vector register capacity 64-bit floating point values (double precision) + typedef v_float64x4 v_float64; + #endif +//! @} + + #define VXPREFIX(func) v256##func +} // namespace +using namespace CV__SIMD_NAMESPACE; +#elif (CV_SIMD128 || CV_SIMD128_CPP) && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 128) +#if defined CV_SIMD128_CPP +#define CV__SIMD_NAMESPACE simd128_cpp +#else +#define CV__SIMD_NAMESPACE simd128 +#endif +namespace CV__SIMD_NAMESPACE { + #define CV_SIMD CV_SIMD128 + #define CV_SIMD_64F CV_SIMD128_64F + #define CV_SIMD_WIDTH 16 +//! @addtogroup core_hal_intrin +//! @{ + //! @brief Maximum available vector register capacity 8-bit unsigned integer values + typedef v_uint8x16 v_uint8; + //! @brief Maximum available vector register capacity 8-bit signed integer values + typedef v_int8x16 v_int8; + //! @brief Maximum available vector register capacity 16-bit unsigned integer values + typedef v_uint16x8 v_uint16; + //! @brief Maximum available vector register capacity 16-bit signed integer values + typedef v_int16x8 v_int16; + //! @brief Maximum available vector register capacity 32-bit unsigned integer values + typedef v_uint32x4 v_uint32; + //! @brief Maximum available vector register capacity 32-bit signed integer values + typedef v_int32x4 v_int32; + //! @brief Maximum available vector register capacity 64-bit unsigned integer values + typedef v_uint64x2 v_uint64; + //! @brief Maximum available vector register capacity 64-bit signed integer values + typedef v_int64x2 v_int64; + //! @brief Maximum available vector register capacity 32-bit floating point values (single precision) + typedef v_float32x4 v_float32; + #if CV_SIMD128_64F + //! @brief Maximum available vector register capacity 64-bit floating point values (double precision) + typedef v_float64x2 v_float64; + #endif +//! @} + + #define VXPREFIX(func) v##func +} // namespace +using namespace CV__SIMD_NAMESPACE; +#endif + +namespace CV__SIMD_NAMESPACE { +//! @addtogroup core_hal_intrin +//! @{ + //! @name Wide init with value + //! @{ + //! @brief Create maximum available capacity vector with elements set to a specific value + inline v_uint8 vx_setall_u8(uchar v) { return VXPREFIX(_setall_u8)(v); } + inline v_int8 vx_setall_s8(schar v) { return VXPREFIX(_setall_s8)(v); } + inline v_uint16 vx_setall_u16(ushort v) { return VXPREFIX(_setall_u16)(v); } + inline v_int16 vx_setall_s16(short v) { return VXPREFIX(_setall_s16)(v); } + inline v_int32 vx_setall_s32(int v) { return VXPREFIX(_setall_s32)(v); } + inline v_uint32 vx_setall_u32(unsigned v) { return VXPREFIX(_setall_u32)(v); } + inline v_float32 vx_setall_f32(float v) { return VXPREFIX(_setall_f32)(v); } + inline v_int64 vx_setall_s64(int64 v) { return VXPREFIX(_setall_s64)(v); } + inline v_uint64 vx_setall_u64(uint64 v) { return VXPREFIX(_setall_u64)(v); } +#if CV_SIMD_64F + inline v_float64 vx_setall_f64(double v) { return VXPREFIX(_setall_f64)(v); } +#endif + //! @} + + //! @name Wide init with zero + //! @{ + //! @brief Create maximum available capacity vector with elements set to zero + inline v_uint8 vx_setzero_u8() { return VXPREFIX(_setzero_u8)(); } + inline v_int8 vx_setzero_s8() { return VXPREFIX(_setzero_s8)(); } + inline v_uint16 vx_setzero_u16() { return VXPREFIX(_setzero_u16)(); } + inline v_int16 vx_setzero_s16() { return VXPREFIX(_setzero_s16)(); } + inline v_int32 vx_setzero_s32() { return VXPREFIX(_setzero_s32)(); } + inline v_uint32 vx_setzero_u32() { return VXPREFIX(_setzero_u32)(); } + inline v_float32 vx_setzero_f32() { return VXPREFIX(_setzero_f32)(); } + inline v_int64 vx_setzero_s64() { return VXPREFIX(_setzero_s64)(); } + inline v_uint64 vx_setzero_u64() { return VXPREFIX(_setzero_u64)(); } +#if CV_SIMD_64F + inline v_float64 vx_setzero_f64() { return VXPREFIX(_setzero_f64)(); } +#endif + //! @} + + //! @name Wide load from memory + //! @{ + //! @brief Load maximum available capacity register contents from memory + inline v_uint8 vx_load(const uchar * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int8 vx_load(const schar * ptr) { return VXPREFIX(_load)(ptr); } + inline v_uint16 vx_load(const ushort * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int16 vx_load(const short * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int32 vx_load(const int * ptr) { return VXPREFIX(_load)(ptr); } + inline v_uint32 vx_load(const unsigned * ptr) { return VXPREFIX(_load)(ptr); } + inline v_float32 vx_load(const float * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int64 vx_load(const int64 * ptr) { return VXPREFIX(_load)(ptr); } + inline v_uint64 vx_load(const uint64 * ptr) { return VXPREFIX(_load)(ptr); } +#if CV_SIMD_64F + inline v_float64 vx_load(const double * ptr) { return VXPREFIX(_load)(ptr); } +#endif + //! @} + + //! @name Wide load from memory(aligned) + //! @{ + //! @brief Load maximum available capacity register contents from memory(aligned) + inline v_uint8 vx_load_aligned(const uchar * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int8 vx_load_aligned(const schar * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_uint16 vx_load_aligned(const ushort * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int16 vx_load_aligned(const short * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int32 vx_load_aligned(const int * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_uint32 vx_load_aligned(const unsigned * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_float32 vx_load_aligned(const float * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int64 vx_load_aligned(const int64 * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_uint64 vx_load_aligned(const uint64 * ptr) { return VXPREFIX(_load_aligned)(ptr); } +#if CV_SIMD_64F + inline v_float64 vx_load_aligned(const double * ptr) { return VXPREFIX(_load_aligned)(ptr); } +#endif + //! @} + + //! @name Wide load lower half from memory + //! @{ + //! @brief Load lower half of maximum available capacity register from memory + inline v_uint8 vx_load_low(const uchar * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int8 vx_load_low(const schar * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_uint16 vx_load_low(const ushort * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int16 vx_load_low(const short * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int32 vx_load_low(const int * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_uint32 vx_load_low(const unsigned * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_float32 vx_load_low(const float * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int64 vx_load_low(const int64 * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_uint64 vx_load_low(const uint64 * ptr) { return VXPREFIX(_load_low)(ptr); } +#if CV_SIMD_64F + inline v_float64 vx_load_low(const double * ptr) { return VXPREFIX(_load_low)(ptr); } +#endif + //! @} + + //! @name Wide load halfs from memory + //! @{ + //! @brief Load maximum available capacity register contents from two memory blocks + inline v_uint8 vx_load_halves(const uchar * ptr0, const uchar * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int8 vx_load_halves(const schar * ptr0, const schar * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_uint16 vx_load_halves(const ushort * ptr0, const ushort * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int16 vx_load_halves(const short * ptr0, const short * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int32 vx_load_halves(const int * ptr0, const int * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_uint32 vx_load_halves(const unsigned * ptr0, const unsigned * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_float32 vx_load_halves(const float * ptr0, const float * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int64 vx_load_halves(const int64 * ptr0, const int64 * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_uint64 vx_load_halves(const uint64 * ptr0, const uint64 * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } +#if CV_SIMD_64F + inline v_float64 vx_load_halves(const double * ptr0, const double * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } +#endif + //! @} + + //! @name Wide LUT of elements + //! @{ + //! @brief Load maximum available capacity register contents with array elements by provided indexes + inline v_uint8 vx_lut(const uchar * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int8 vx_lut(const schar * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_uint16 vx_lut(const ushort * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int16 vx_lut(const short* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int32 vx_lut(const int* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_uint32 vx_lut(const unsigned* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_float32 vx_lut(const float* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int64 vx_lut(const int64 * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_uint64 vx_lut(const uint64 * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } +#if CV_SIMD_64F + inline v_float64 vx_lut(const double* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } +#endif + //! @} + + //! @name Wide LUT of element pairs + //! @{ + //! @brief Load maximum available capacity register contents with array element pairs by provided indexes + inline v_uint8 vx_lut_pairs(const uchar * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int8 vx_lut_pairs(const schar * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_uint16 vx_lut_pairs(const ushort * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int16 vx_lut_pairs(const short* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int32 vx_lut_pairs(const int* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_uint32 vx_lut_pairs(const unsigned* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_float32 vx_lut_pairs(const float* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int64 vx_lut_pairs(const int64 * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_uint64 vx_lut_pairs(const uint64 * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } +#if CV_SIMD_64F + inline v_float64 vx_lut_pairs(const double* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } +#endif + //! @} + + //! @name Wide LUT of element quads + //! @{ + //! @brief Load maximum available capacity register contents with array element quads by provided indexes + inline v_uint8 vx_lut_quads(const uchar* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_int8 vx_lut_quads(const schar* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_uint16 vx_lut_quads(const ushort* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_int16 vx_lut_quads(const short* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_int32 vx_lut_quads(const int* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_uint32 vx_lut_quads(const unsigned* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_float32 vx_lut_quads(const float* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + //! @} + + //! @name Wide load with double expansion + //! @{ + //! @brief Load maximum available capacity register contents from memory with double expand + inline v_uint16 vx_load_expand(const uchar * ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_int16 vx_load_expand(const schar * ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_uint32 vx_load_expand(const ushort * ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_int32 vx_load_expand(const short* ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_int64 vx_load_expand(const int* ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_uint64 vx_load_expand(const unsigned* ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_float32 vx_load_expand(const float16_t * ptr) { return VXPREFIX(_load_expand)(ptr); } + //! @} + + //! @name Wide load with quad expansion + //! @{ + //! @brief Load maximum available capacity register contents from memory with quad expand + inline v_uint32 vx_load_expand_q(const uchar * ptr) { return VXPREFIX(_load_expand_q)(ptr); } + inline v_int32 vx_load_expand_q(const schar * ptr) { return VXPREFIX(_load_expand_q)(ptr); } + //! @} + + /** @brief SIMD processing state cleanup call */ + inline void vx_cleanup() { VXPREFIX(_cleanup)(); } + + +//! @cond IGNORED + + // backward compatibility + template static inline + void vx_store(_Tp* dst, const _Tvec& v) { return v_store(dst, v); } + // backward compatibility + template static inline + void vx_store_aligned(_Tp* dst, const _Tvec& v) { return v_store_aligned(dst, v); } + +//! @endcond + + +//! @} + #undef VXPREFIX +} // namespace + +//! @cond IGNORED +#ifndef CV_SIMD_64F +#define CV_SIMD_64F 0 +#endif + +#ifndef CV_SIMD_FP16 +#define CV_SIMD_FP16 0 //!< Defined to 1 on native support of operations with float16x8_t / float16x16_t (SIMD256) types +#endif + +#ifndef CV_SIMD +#define CV_SIMD 0 +#endif + +#include "simd_utils.impl.hpp" + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END +#endif + +} // cv:: + +//! @endcond + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_avx.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_avx.hpp new file mode 100644 index 0000000..979b616 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_avx.hpp @@ -0,0 +1,3177 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_INTRIN_AVX_HPP +#define OPENCV_HAL_INTRIN_AVX_HPP + +#define CV_SIMD256 1 +#define CV_SIMD256_64F 1 +#define CV_SIMD256_FP16 0 // no native operations with FP16 type. Only load/store from float32x8 are available (if CV_FP16 == 1) + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Utils //////////// + +inline __m256i _v256_combine(const __m128i& lo, const __m128i& hi) +{ return _mm256_inserti128_si256(_mm256_castsi128_si256(lo), hi, 1); } + +inline __m256 _v256_combine(const __m128& lo, const __m128& hi) +{ return _mm256_insertf128_ps(_mm256_castps128_ps256(lo), hi, 1); } + +inline __m256d _v256_combine(const __m128d& lo, const __m128d& hi) +{ return _mm256_insertf128_pd(_mm256_castpd128_pd256(lo), hi, 1); } + +inline int _v_cvtsi256_si32(const __m256i& a) +{ return _mm_cvtsi128_si32(_mm256_castsi256_si128(a)); } + +inline __m256i _v256_shuffle_odd_64(const __m256i& v) +{ return _mm256_permute4x64_epi64(v, _MM_SHUFFLE(3, 1, 2, 0)); } + +inline __m256d _v256_shuffle_odd_64(const __m256d& v) +{ return _mm256_permute4x64_pd(v, _MM_SHUFFLE(3, 1, 2, 0)); } + +template +inline __m256i _v256_permute2x128(const __m256i& a, const __m256i& b) +{ return _mm256_permute2x128_si256(a, b, imm); } + +template +inline __m256 _v256_permute2x128(const __m256& a, const __m256& b) +{ return _mm256_permute2f128_ps(a, b, imm); } + +template +inline __m256d _v256_permute2x128(const __m256d& a, const __m256d& b) +{ return _mm256_permute2f128_pd(a, b, imm); } + +template +inline _Tpvec v256_permute2x128(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(_v256_permute2x128(a.val, b.val)); } + +template +inline __m256i _v256_permute4x64(const __m256i& a) +{ return _mm256_permute4x64_epi64(a, imm); } + +template +inline __m256d _v256_permute4x64(const __m256d& a) +{ return _mm256_permute4x64_pd(a, imm); } + +template +inline _Tpvec v256_permute4x64(const _Tpvec& a) +{ return _Tpvec(_v256_permute4x64(a.val)); } + +inline __m128i _v256_extract_high(const __m256i& v) +{ return _mm256_extracti128_si256(v, 1); } + +inline __m128 _v256_extract_high(const __m256& v) +{ return _mm256_extractf128_ps(v, 1); } + +inline __m128d _v256_extract_high(const __m256d& v) +{ return _mm256_extractf128_pd(v, 1); } + +inline __m128i _v256_extract_low(const __m256i& v) +{ return _mm256_castsi256_si128(v); } + +inline __m128 _v256_extract_low(const __m256& v) +{ return _mm256_castps256_ps128(v); } + +inline __m128d _v256_extract_low(const __m256d& v) +{ return _mm256_castpd256_pd128(v); } + +inline __m256i _v256_packs_epu32(const __m256i& a, const __m256i& b) +{ + const __m256i m = _mm256_set1_epi32(65535); + __m256i am = _mm256_min_epu32(a, m); + __m256i bm = _mm256_min_epu32(b, m); + return _mm256_packus_epi32(am, bm); +} + +template +inline int _v256_extract_epi8(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi8(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 4)); + return _mm_extract_epi8(b, i & 15); // SSE4.1 +#endif +} + +template +inline int _v256_extract_epi16(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi16(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 3)); + return _mm_extract_epi16(b, i & 7); // SSE2 +#endif +} + +template +inline int _v256_extract_epi32(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi32(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 2)); + return _mm_extract_epi32(b, i & 3); // SSE4.1 +#endif +} + +template +inline int64 _v256_extract_epi64(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi64(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 1)); + return _mm_extract_epi64(b, i & 1); // SSE4.1 +#endif +} + +///////// Types //////////// + +struct v_uint8x32 +{ + typedef uchar lane_type; + enum { nlanes = 32 }; + __m256i val; + + explicit v_uint8x32(__m256i v) : val(v) {} + v_uint8x32(uchar v0, uchar v1, uchar v2, uchar v3, + uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, + uchar v12, uchar v13, uchar v14, uchar v15, + uchar v16, uchar v17, uchar v18, uchar v19, + uchar v20, uchar v21, uchar v22, uchar v23, + uchar v24, uchar v25, uchar v26, uchar v27, + uchar v28, uchar v29, uchar v30, uchar v31) + { + val = _mm256_setr_epi8((char)v0, (char)v1, (char)v2, (char)v3, + (char)v4, (char)v5, (char)v6 , (char)v7, (char)v8, (char)v9, + (char)v10, (char)v11, (char)v12, (char)v13, (char)v14, (char)v15, + (char)v16, (char)v17, (char)v18, (char)v19, (char)v20, (char)v21, + (char)v22, (char)v23, (char)v24, (char)v25, (char)v26, (char)v27, + (char)v28, (char)v29, (char)v30, (char)v31); + } + /* coverity[uninit_ctor]: suppress warning */ + v_uint8x32() {} + + uchar get0() const { return (uchar)_v_cvtsi256_si32(val); } +}; + +struct v_int8x32 +{ + typedef schar lane_type; + enum { nlanes = 32 }; + __m256i val; + + explicit v_int8x32(__m256i v) : val(v) {} + v_int8x32(schar v0, schar v1, schar v2, schar v3, + schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, + schar v12, schar v13, schar v14, schar v15, + schar v16, schar v17, schar v18, schar v19, + schar v20, schar v21, schar v22, schar v23, + schar v24, schar v25, schar v26, schar v27, + schar v28, schar v29, schar v30, schar v31) + { + val = _mm256_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, + v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, + v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31); + } + /* coverity[uninit_ctor]: suppress warning */ + v_int8x32() {} + + schar get0() const { return (schar)_v_cvtsi256_si32(val); } +}; + +struct v_uint16x16 +{ + typedef ushort lane_type; + enum { nlanes = 16 }; + __m256i val; + + explicit v_uint16x16(__m256i v) : val(v) {} + v_uint16x16(ushort v0, ushort v1, ushort v2, ushort v3, + ushort v4, ushort v5, ushort v6, ushort v7, + ushort v8, ushort v9, ushort v10, ushort v11, + ushort v12, ushort v13, ushort v14, ushort v15) + { + val = _mm256_setr_epi16((short)v0, (short)v1, (short)v2, (short)v3, + (short)v4, (short)v5, (short)v6, (short)v7, (short)v8, (short)v9, + (short)v10, (short)v11, (short)v12, (short)v13, (short)v14, (short)v15); + } + /* coverity[uninit_ctor]: suppress warning */ + v_uint16x16() {} + + ushort get0() const { return (ushort)_v_cvtsi256_si32(val); } +}; + +struct v_int16x16 +{ + typedef short lane_type; + enum { nlanes = 16 }; + __m256i val; + + explicit v_int16x16(__m256i v) : val(v) {} + v_int16x16(short v0, short v1, short v2, short v3, + short v4, short v5, short v6, short v7, + short v8, short v9, short v10, short v11, + short v12, short v13, short v14, short v15) + { + val = _mm256_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); + } + /* coverity[uninit_ctor]: suppress warning */ + v_int16x16() {} + + short get0() const { return (short)_v_cvtsi256_si32(val); } +}; + +struct v_uint32x8 +{ + typedef unsigned lane_type; + enum { nlanes = 8 }; + __m256i val; + + explicit v_uint32x8(__m256i v) : val(v) {} + v_uint32x8(unsigned v0, unsigned v1, unsigned v2, unsigned v3, + unsigned v4, unsigned v5, unsigned v6, unsigned v7) + { + val = _mm256_setr_epi32((unsigned)v0, (unsigned)v1, (unsigned)v2, + (unsigned)v3, (unsigned)v4, (unsigned)v5, (unsigned)v6, (unsigned)v7); + } + /* coverity[uninit_ctor]: suppress warning */ + v_uint32x8() {} + + unsigned get0() const { return (unsigned)_v_cvtsi256_si32(val); } +}; + +struct v_int32x8 +{ + typedef int lane_type; + enum { nlanes = 8 }; + __m256i val; + + explicit v_int32x8(__m256i v) : val(v) {} + v_int32x8(int v0, int v1, int v2, int v3, + int v4, int v5, int v6, int v7) + { + val = _mm256_setr_epi32(v0, v1, v2, v3, v4, v5, v6, v7); + } + /* coverity[uninit_ctor]: suppress warning */ + v_int32x8() {} + + int get0() const { return _v_cvtsi256_si32(val); } +}; + +struct v_float32x8 +{ + typedef float lane_type; + enum { nlanes = 8 }; + __m256 val; + + explicit v_float32x8(__m256 v) : val(v) {} + v_float32x8(float v0, float v1, float v2, float v3, + float v4, float v5, float v6, float v7) + { + val = _mm256_setr_ps(v0, v1, v2, v3, v4, v5, v6, v7); + } + /* coverity[uninit_ctor]: suppress warning */ + v_float32x8() {} + + float get0() const { return _mm_cvtss_f32(_mm256_castps256_ps128(val)); } +}; + +struct v_uint64x4 +{ + typedef uint64 lane_type; + enum { nlanes = 4 }; + __m256i val; + + explicit v_uint64x4(__m256i v) : val(v) {} + v_uint64x4(uint64 v0, uint64 v1, uint64 v2, uint64 v3) + { val = _mm256_setr_epi64x((int64)v0, (int64)v1, (int64)v2, (int64)v3); } + /* coverity[uninit_ctor]: suppress warning */ + v_uint64x4() {} + + uint64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (uint64)_mm_cvtsi128_si64(_mm256_castsi256_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm256_castsi256_si128(val)); + int b = _mm_cvtsi128_si32(_mm256_castsi256_si128(_mm256_srli_epi64(val, 32))); + return (unsigned)a | ((uint64)(unsigned)b << 32); + #endif + } +}; + +struct v_int64x4 +{ + typedef int64 lane_type; + enum { nlanes = 4 }; + __m256i val; + + explicit v_int64x4(__m256i v) : val(v) {} + v_int64x4(int64 v0, int64 v1, int64 v2, int64 v3) + { val = _mm256_setr_epi64x(v0, v1, v2, v3); } + /* coverity[uninit_ctor]: suppress warning */ + v_int64x4() {} + + int64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (int64)_mm_cvtsi128_si64(_mm256_castsi256_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm256_castsi256_si128(val)); + int b = _mm_cvtsi128_si32(_mm256_castsi256_si128(_mm256_srli_epi64(val, 32))); + return (int64)((unsigned)a | ((uint64)(unsigned)b << 32)); + #endif + } +}; + +struct v_float64x4 +{ + typedef double lane_type; + enum { nlanes = 4 }; + __m256d val; + + explicit v_float64x4(__m256d v) : val(v) {} + v_float64x4(double v0, double v1, double v2, double v3) + { val = _mm256_setr_pd(v0, v1, v2, v3); } + /* coverity[uninit_ctor]: suppress warning */ + v_float64x4() {} + + double get0() const { return _mm_cvtsd_f64(_mm256_castpd256_pd128(val)); } +}; + +//////////////// Load and store operations /////////////// + +#define OPENCV_HAL_IMPL_AVX_LOADSTORE(_Tpvec, _Tp) \ + inline _Tpvec v256_load(const _Tp* ptr) \ + { return _Tpvec(_mm256_loadu_si256((const __m256i*)ptr)); } \ + inline _Tpvec v256_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm256_load_si256((const __m256i*)ptr)); } \ + inline _Tpvec v256_load_low(const _Tp* ptr) \ + { \ + __m128i v128 = _mm_loadu_si128((const __m128i*)ptr); \ + return _Tpvec(_mm256_castsi128_si256(v128)); \ + } \ + inline _Tpvec v256_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + __m128i vlo = _mm_loadu_si128((const __m128i*)ptr0); \ + __m128i vhi = _mm_loadu_si128((const __m128i*)ptr1); \ + return _Tpvec(_v256_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_si256((__m256i*)ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm256_store_si256((__m256i*)ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm256_stream_si256((__m256i*)ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm256_storeu_si256((__m256i*)ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm256_stream_si256((__m256i*)ptr, a.val); \ + else \ + _mm256_store_si256((__m256i*)ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_si128((__m128i*)ptr, _v256_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_si128((__m128i*)ptr, _v256_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint8x32, uchar) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int8x32, schar) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint16x16, ushort) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int16x16, short) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint32x8, unsigned) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int32x8, int) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint64x4, uint64) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int64x4, int64) + +#define OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(_Tpvec, _Tp, suffix, halfreg) \ + inline _Tpvec v256_load(const _Tp* ptr) \ + { return _Tpvec(_mm256_loadu_##suffix(ptr)); } \ + inline _Tpvec v256_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm256_load_##suffix(ptr)); } \ + inline _Tpvec v256_load_low(const _Tp* ptr) \ + { \ + return _Tpvec(_mm256_cast##suffix##128_##suffix##256 \ + (_mm_loadu_##suffix(ptr))); \ + } \ + inline _Tpvec v256_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + halfreg vlo = _mm_loadu_##suffix(ptr0); \ + halfreg vhi = _mm_loadu_##suffix(ptr1); \ + return _Tpvec(_v256_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_##suffix(ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm256_store_##suffix(ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm256_stream_##suffix(ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm256_storeu_##suffix(ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm256_stream_##suffix(ptr, a.val); \ + else \ + _mm256_store_##suffix(ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_##suffix(ptr, _v256_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_##suffix(ptr, _v256_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(v_float32x8, float, ps, __m128) +OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(v_float64x4, double, pd, __m128d) + +#define OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, _Tpvecf, suffix, cast) \ + inline _Tpvec v_reinterpret_as_##suffix(const _Tpvecf& a) \ + { return _Tpvec(cast(a.val)); } + +#define OPENCV_HAL_IMPL_AVX_INIT(_Tpvec, _Tp, suffix, ssuffix, ctype_s) \ + inline _Tpvec v256_setzero_##suffix() \ + { return _Tpvec(_mm256_setzero_si256()); } \ + inline _Tpvec v256_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm256_set1_##ssuffix((ctype_s)v)); } \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint8x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int8x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint16x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int16x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint32x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int32x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint64x4, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int64x4, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_float32x8, suffix, _mm256_castps_si256) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_float64x4, suffix, _mm256_castpd_si256) + +OPENCV_HAL_IMPL_AVX_INIT(v_uint8x32, uchar, u8, epi8, char) +OPENCV_HAL_IMPL_AVX_INIT(v_int8x32, schar, s8, epi8, char) +OPENCV_HAL_IMPL_AVX_INIT(v_uint16x16, ushort, u16, epi16, short) +OPENCV_HAL_IMPL_AVX_INIT(v_int16x16, short, s16, epi16, short) +OPENCV_HAL_IMPL_AVX_INIT(v_uint32x8, unsigned, u32, epi32, int) +OPENCV_HAL_IMPL_AVX_INIT(v_int32x8, int, s32, epi32, int) +OPENCV_HAL_IMPL_AVX_INIT(v_uint64x4, uint64, u64, epi64x, int64) +OPENCV_HAL_IMPL_AVX_INIT(v_int64x4, int64, s64, epi64x, int64) + +#define OPENCV_HAL_IMPL_AVX_INIT_FLT(_Tpvec, _Tp, suffix, zsuffix, cast) \ + inline _Tpvec v256_setzero_##suffix() \ + { return _Tpvec(_mm256_setzero_##zsuffix()); } \ + inline _Tpvec v256_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm256_set1_##zsuffix(v)); } \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint8x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int8x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint16x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int16x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint32x8, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int32x8, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint64x4, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int64x4, suffix, cast) + +OPENCV_HAL_IMPL_AVX_INIT_FLT(v_float32x8, float, f32, ps, _mm256_castsi256_ps) +OPENCV_HAL_IMPL_AVX_INIT_FLT(v_float64x4, double, f64, pd, _mm256_castsi256_pd) + +inline v_float32x8 v_reinterpret_as_f32(const v_float32x8& a) +{ return a; } +inline v_float32x8 v_reinterpret_as_f32(const v_float64x4& a) +{ return v_float32x8(_mm256_castpd_ps(a.val)); } + +inline v_float64x4 v_reinterpret_as_f64(const v_float64x4& a) +{ return a; } +inline v_float64x4 v_reinterpret_as_f64(const v_float32x8& a) +{ return v_float64x4(_mm256_castps_pd(a.val)); } + +/* Recombine */ +/*#define OPENCV_HAL_IMPL_AVX_COMBINE(_Tpvec, perm) \ + inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(perm(a.val, b.val, 0x20)); } \ + inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(perm(a.val, b.val, 0x31)); } \ + inline void v_recombine(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ + { c = v_combine_low(a, b); d = v_combine_high(a, b); } + +#define OPENCV_HAL_IMPL_AVX_UNPACKS(_Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_COMBINE(_Tpvec, _mm256_permute2x128_si256) \ + inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, \ + _Tpvec& b0, _Tpvec& b1) \ + { \ + __m256i v0 = _v256_shuffle_odd_64(a0.val); \ + __m256i v1 = _v256_shuffle_odd_64(a1.val); \ + b0.val = _mm256_unpacklo_##suffix(v0, v1); \ + b1.val = _mm256_unpackhi_##suffix(v0, v1); \ + } + +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint64x4, epi64) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int64x4, epi64) +OPENCV_HAL_IMPL_AVX_COMBINE(v_float32x8, _mm256_permute2f128_ps) +OPENCV_HAL_IMPL_AVX_COMBINE(v_float64x4, _mm256_permute2f128_pd) + +inline void v_zip(const v_float32x8& a0, const v_float32x8& a1, v_float32x8& b0, v_float32x8& b1) +{ + __m256 v0 = _mm256_unpacklo_ps(a0.val, a1.val); + __m256 v1 = _mm256_unpackhi_ps(a0.val, a1.val); + v_recombine(v_float32x8(v0), v_float32x8(v1), b0, b1); +} + +inline void v_zip(const v_float64x4& a0, const v_float64x4& a1, v_float64x4& b0, v_float64x4& b1) +{ + __m256d v0 = _v_shuffle_odd_64(a0.val); + __m256d v1 = _v_shuffle_odd_64(a1.val); + b0.val = _mm256_unpacklo_pd(v0, v1); + b1.val = _mm256_unpackhi_pd(v0, v1); +}*/ + +//////////////// Variant Value reordering /////////////// + +// unpacks +#define OPENCV_HAL_IMPL_AVX_UNPACK(_Tpvec, suffix) \ + inline _Tpvec v256_unpacklo(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_unpacklo_##suffix(a.val, b.val)); } \ + inline _Tpvec v256_unpackhi(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_unpackhi_##suffix(a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint64x4, epi64) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int64x4, epi64) +OPENCV_HAL_IMPL_AVX_UNPACK(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_UNPACK(v_float64x4, pd) + +// blend +#define OPENCV_HAL_IMPL_AVX_BLEND(_Tpvec, suffix) \ + template \ + inline _Tpvec v256_blend(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_blend_##suffix(a.val, b.val, m)); } + +OPENCV_HAL_IMPL_AVX_BLEND(v_uint16x16, epi16) +OPENCV_HAL_IMPL_AVX_BLEND(v_int16x16, epi16) +OPENCV_HAL_IMPL_AVX_BLEND(v_uint32x8, epi32) +OPENCV_HAL_IMPL_AVX_BLEND(v_int32x8, epi32) +OPENCV_HAL_IMPL_AVX_BLEND(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_BLEND(v_float64x4, pd) + +template +inline v_uint64x4 v256_blend(const v_uint64x4& a, const v_uint64x4& b) +{ + enum {M0 = m}; + enum {M1 = (M0 | (M0 << 2)) & 0x33}; + enum {M2 = (M1 | (M1 << 1)) & 0x55}; + enum {MM = M2 | (M2 << 1)}; + return v_uint64x4(_mm256_blend_epi32(a.val, b.val, MM)); +} +template +inline v_int64x4 v256_blend(const v_int64x4& a, const v_int64x4& b) +{ return v_int64x4(v256_blend(v_uint64x4(a.val), v_uint64x4(b.val)).val); } + +// shuffle +// todo: emulate 64bit +#define OPENCV_HAL_IMPL_AVX_SHUFFLE(_Tpvec, intrin) \ + template \ + inline _Tpvec v256_shuffle(const _Tpvec& a) \ + { return _Tpvec(_mm256_##intrin(a.val, m)); } + +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_uint32x8, shuffle_epi32) +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_int32x8, shuffle_epi32) +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_float32x8, permute_ps) +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_float64x4, permute_pd) + +template +inline void v256_zip(const _Tpvec& a, const _Tpvec& b, _Tpvec& ab0, _Tpvec& ab1) +{ + ab0 = v256_unpacklo(a, b); + ab1 = v256_unpackhi(a, b); +} + +template +inline _Tpvec v256_combine_diagonal(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(_mm256_blend_epi32(a.val, b.val, 0xf0)); } + +inline v_float32x8 v256_combine_diagonal(const v_float32x8& a, const v_float32x8& b) +{ return v256_blend<0xf0>(a, b); } + +inline v_float64x4 v256_combine_diagonal(const v_float64x4& a, const v_float64x4& b) +{ return v256_blend<0xc>(a, b); } + +template +inline _Tpvec v256_alignr_128(const _Tpvec& a, const _Tpvec& b) +{ return v256_permute2x128<0x21>(a, b); } + +template +inline _Tpvec v256_alignr_64(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(_mm256_alignr_epi8(a.val, b.val, 8)); } +inline v_float64x4 v256_alignr_64(const v_float64x4& a, const v_float64x4& b) +{ return v_float64x4(_mm256_shuffle_pd(b.val, a.val, _MM_SHUFFLE(0, 0, 1, 1))); } +// todo: emulate float32 + +template +inline _Tpvec v256_swap_halves(const _Tpvec& a) +{ return v256_permute2x128<1>(a, a); } + +template +inline _Tpvec v256_reverse_64(const _Tpvec& a) +{ return v256_permute4x64<_MM_SHUFFLE(0, 1, 2, 3)>(a); } + +// ZIP +#define OPENCV_HAL_IMPL_AVX_ZIP(_Tpvec) \ + inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ + { return v256_permute2x128<0x20>(a, b); } \ + inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ + { return v256_permute2x128<0x31>(a, b); } \ + inline void v_recombine(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ + { \ + _Tpvec a1b0 = v256_alignr_128(a, b); \ + c = v256_combine_diagonal(a, a1b0); \ + d = v256_combine_diagonal(a1b0, b); \ + } \ + inline void v_zip(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& ab0, _Tpvec& ab1) \ + { \ + _Tpvec ab0ab2, ab1ab3; \ + v256_zip(a, b, ab0ab2, ab1ab3); \ + v_recombine(ab0ab2, ab1ab3, ab0, ab1); \ + } + +OPENCV_HAL_IMPL_AVX_ZIP(v_uint8x32) +OPENCV_HAL_IMPL_AVX_ZIP(v_int8x32) +OPENCV_HAL_IMPL_AVX_ZIP(v_uint16x16) +OPENCV_HAL_IMPL_AVX_ZIP(v_int16x16) +OPENCV_HAL_IMPL_AVX_ZIP(v_uint32x8) +OPENCV_HAL_IMPL_AVX_ZIP(v_int32x8) +OPENCV_HAL_IMPL_AVX_ZIP(v_uint64x4) +OPENCV_HAL_IMPL_AVX_ZIP(v_int64x4) +OPENCV_HAL_IMPL_AVX_ZIP(v_float32x8) +OPENCV_HAL_IMPL_AVX_ZIP(v_float64x4) + +////////// Arithmetic, bitwise and comparison operations ///////// + +/* Element-wise binary and unary operations */ + +/** Arithmetics **/ +#define OPENCV_HAL_IMPL_AVX_BIN_OP(bin_op, _Tpvec, intrin) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } \ + inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ + { a.val = intrin(a.val, b.val); return a; } + +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint8x32, _mm256_adds_epu8) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint8x32, _mm256_subs_epu8) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int8x32, _mm256_adds_epi8) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int8x32, _mm256_subs_epi8) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint16x16, _mm256_adds_epu16) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint16x16, _mm256_subs_epu16) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int16x16, _mm256_adds_epi16) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int16x16, _mm256_subs_epi16) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint32x8, _mm256_add_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint32x8, _mm256_sub_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_uint32x8, _mm256_mullo_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int32x8, _mm256_add_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int32x8, _mm256_sub_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_int32x8, _mm256_mullo_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint64x4, _mm256_add_epi64) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint64x4, _mm256_sub_epi64) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int64x4, _mm256_add_epi64) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int64x4, _mm256_sub_epi64) + +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_float32x8, _mm256_add_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_float32x8, _mm256_sub_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_float32x8, _mm256_mul_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(/, v_float32x8, _mm256_div_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_float64x4, _mm256_add_pd) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_float64x4, _mm256_sub_pd) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_float64x4, _mm256_mul_pd) +OPENCV_HAL_IMPL_AVX_BIN_OP(/, v_float64x4, _mm256_div_pd) + +// saturating multiply 8-bit, 16-bit +inline v_uint8x32 operator * (const v_uint8x32& a, const v_uint8x32& b) +{ + v_uint16x16 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_int8x32 operator * (const v_int8x32& a, const v_int8x32& b) +{ + v_int16x16 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_uint16x16 operator * (const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i pl = _mm256_mullo_epi16(a.val, b.val); + __m256i ph = _mm256_mulhi_epu16(a.val, b.val); + __m256i p0 = _mm256_unpacklo_epi16(pl, ph); + __m256i p1 = _mm256_unpackhi_epi16(pl, ph); + return v_uint16x16(_v256_packs_epu32(p0, p1)); +} +inline v_int16x16 operator * (const v_int16x16& a, const v_int16x16& b) +{ + __m256i pl = _mm256_mullo_epi16(a.val, b.val); + __m256i ph = _mm256_mulhi_epi16(a.val, b.val); + __m256i p0 = _mm256_unpacklo_epi16(pl, ph); + __m256i p1 = _mm256_unpackhi_epi16(pl, ph); + return v_int16x16(_mm256_packs_epi32(p0, p1)); +} +inline v_uint8x32& operator *= (v_uint8x32& a, const v_uint8x32& b) +{ a = a * b; return a; } +inline v_int8x32& operator *= (v_int8x32& a, const v_int8x32& b) +{ a = a * b; return a; } +inline v_uint16x16& operator *= (v_uint16x16& a, const v_uint16x16& b) +{ a = a * b; return a; } +inline v_int16x16& operator *= (v_int16x16& a, const v_int16x16& b) +{ a = a * b; return a; } + +/** Non-saturating arithmetics **/ +#define OPENCV_HAL_IMPL_AVX_BIN_FUNC(func, _Tpvec, intrin) \ + inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_uint8x32, _mm256_add_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_int8x32, _mm256_add_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_uint16x16, _mm256_add_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_int16x16, _mm256_add_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_uint8x32, _mm256_sub_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_int8x32, _mm256_sub_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_uint16x16, _mm256_sub_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_int16x16, _mm256_sub_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_mul_wrap, v_uint16x16, _mm256_mullo_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_mul_wrap, v_int16x16, _mm256_mullo_epi16) + +inline v_uint8x32 v_mul_wrap(const v_uint8x32& a, const v_uint8x32& b) +{ + __m256i ad = _mm256_srai_epi16(a.val, 8); + __m256i bd = _mm256_srai_epi16(b.val, 8); + __m256i p0 = _mm256_mullo_epi16(a.val, b.val); // even + __m256i p1 = _mm256_slli_epi16(_mm256_mullo_epi16(ad, bd), 8); // odd + + const __m256i b01 = _mm256_set1_epi32(0xFF00FF00); + return v_uint8x32(_mm256_blendv_epi8(p0, p1, b01)); +} +inline v_int8x32 v_mul_wrap(const v_int8x32& a, const v_int8x32& b) +{ + return v_reinterpret_as_s8(v_mul_wrap(v_reinterpret_as_u8(a), v_reinterpret_as_u8(b))); +} + +// Multiply and expand +inline void v_mul_expand(const v_uint8x32& a, const v_uint8x32& b, + v_uint16x16& c, v_uint16x16& d) +{ + v_uint16x16 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x32& a, const v_int8x32& b, + v_int16x16& c, v_int16x16& d) +{ + v_int16x16 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x16& a, const v_int16x16& b, + v_int32x8& c, v_int32x8& d) +{ + v_int16x16 vhi = v_int16x16(_mm256_mulhi_epi16(a.val, b.val)); + + v_int16x16 v0, v1; + v_zip(v_mul_wrap(a, b), vhi, v0, v1); + + c = v_reinterpret_as_s32(v0); + d = v_reinterpret_as_s32(v1); +} + +inline void v_mul_expand(const v_uint16x16& a, const v_uint16x16& b, + v_uint32x8& c, v_uint32x8& d) +{ + v_uint16x16 vhi = v_uint16x16(_mm256_mulhi_epu16(a.val, b.val)); + + v_uint16x16 v0, v1; + v_zip(v_mul_wrap(a, b), vhi, v0, v1); + + c = v_reinterpret_as_u32(v0); + d = v_reinterpret_as_u32(v1); +} + +inline void v_mul_expand(const v_uint32x8& a, const v_uint32x8& b, + v_uint64x4& c, v_uint64x4& d) +{ + __m256i v0 = _mm256_mul_epu32(a.val, b.val); + __m256i v1 = _mm256_mul_epu32(_mm256_srli_epi64(a.val, 32), _mm256_srli_epi64(b.val, 32)); + v_zip(v_uint64x4(v0), v_uint64x4(v1), c, d); +} + +inline v_int16x16 v_mul_hi(const v_int16x16& a, const v_int16x16& b) { return v_int16x16(_mm256_mulhi_epi16(a.val, b.val)); } +inline v_uint16x16 v_mul_hi(const v_uint16x16& a, const v_uint16x16& b) { return v_uint16x16(_mm256_mulhi_epu16(a.val, b.val)); } + +/** Bitwise shifts **/ +#define OPENCV_HAL_IMPL_AVX_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, srai) \ + inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm256_slli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ + { return _Tpsvec(_mm256_slli_##suffix(a.val, imm)); } \ + inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm256_srli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ + { return _Tpsvec(srai(a.val, imm)); } \ + template \ + inline _Tpuvec v_shl(const _Tpuvec& a) \ + { return _Tpuvec(_mm256_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shl(const _Tpsvec& a) \ + { return _Tpsvec(_mm256_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpuvec v_shr(const _Tpuvec& a) \ + { return _Tpuvec(_mm256_srli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shr(const _Tpsvec& a) \ + { return _Tpsvec(srai(a.val, imm)); } + +OPENCV_HAL_IMPL_AVX_SHIFT_OP(v_uint16x16, v_int16x16, epi16, _mm256_srai_epi16) +OPENCV_HAL_IMPL_AVX_SHIFT_OP(v_uint32x8, v_int32x8, epi32, _mm256_srai_epi32) + +inline __m256i _mm256_srai_epi64xx(const __m256i a, int imm) +{ + __m256i d = _mm256_set1_epi64x((int64)1 << 63); + __m256i r = _mm256_srli_epi64(_mm256_add_epi64(a, d), imm); + return _mm256_sub_epi64(r, _mm256_srli_epi64(d, imm)); +} +OPENCV_HAL_IMPL_AVX_SHIFT_OP(v_uint64x4, v_int64x4, epi64, _mm256_srai_epi64xx) + + +/** Bitwise logic **/ +#define OPENCV_HAL_IMPL_AVX_LOGIC_OP(_Tpvec, suffix, not_const) \ + OPENCV_HAL_IMPL_AVX_BIN_OP(&, _Tpvec, _mm256_and_##suffix) \ + OPENCV_HAL_IMPL_AVX_BIN_OP(|, _Tpvec, _mm256_or_##suffix) \ + OPENCV_HAL_IMPL_AVX_BIN_OP(^, _Tpvec, _mm256_xor_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { return _Tpvec(_mm256_xor_##suffix(a.val, not_const)); } + +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint8x32, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int8x32, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint16x16, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int16x16, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint32x8, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int32x8, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint64x4, si256, _mm256_set1_epi64x(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int64x4, si256, _mm256_set1_epi64x(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_float32x8, ps, _mm256_castsi256_ps(_mm256_set1_epi32(-1))) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_float64x4, pd, _mm256_castsi256_pd(_mm256_set1_epi32(-1))) + +/** Select **/ +#define OPENCV_HAL_IMPL_AVX_SELECT(_Tpvec, suffix) \ + inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_blendv_##suffix(b.val, a.val, mask.val)); } + +OPENCV_HAL_IMPL_AVX_SELECT(v_uint8x32, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_int8x32, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_uint16x16, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_int16x16, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_uint32x8, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_int32x8, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_SELECT(v_float64x4, pd) + +/** Comparison **/ +#define OPENCV_HAL_IMPL_AVX_CMP_OP_OV(_Tpvec) \ + inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ + { return ~(a == b); } \ + inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ + { return b > a; } \ + inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ + { return ~(a < b); } \ + inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ + { return b >= a; } + +#define OPENCV_HAL_IMPL_AVX_CMP_OP_INT(_Tpuvec, _Tpsvec, suffix, sbit) \ + inline _Tpuvec operator == (const _Tpuvec& a, const _Tpuvec& b) \ + { return _Tpuvec(_mm256_cmpeq_##suffix(a.val, b.val)); } \ + inline _Tpuvec operator > (const _Tpuvec& a, const _Tpuvec& b) \ + { \ + __m256i smask = _mm256_set1_##suffix(sbit); \ + return _Tpuvec(_mm256_cmpgt_##suffix( \ + _mm256_xor_si256(a.val, smask), \ + _mm256_xor_si256(b.val, smask))); \ + } \ + inline _Tpsvec operator == (const _Tpsvec& a, const _Tpsvec& b) \ + { return _Tpsvec(_mm256_cmpeq_##suffix(a.val, b.val)); } \ + inline _Tpsvec operator > (const _Tpsvec& a, const _Tpsvec& b) \ + { return _Tpsvec(_mm256_cmpgt_##suffix(a.val, b.val)); } \ + OPENCV_HAL_IMPL_AVX_CMP_OP_OV(_Tpuvec) \ + OPENCV_HAL_IMPL_AVX_CMP_OP_OV(_Tpsvec) + +OPENCV_HAL_IMPL_AVX_CMP_OP_INT(v_uint8x32, v_int8x32, epi8, (char)-128) +OPENCV_HAL_IMPL_AVX_CMP_OP_INT(v_uint16x16, v_int16x16, epi16, (short)-32768) +OPENCV_HAL_IMPL_AVX_CMP_OP_INT(v_uint32x8, v_int32x8, epi32, (int)0x80000000) + +#define OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(_Tpvec) \ + inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_cmpeq_epi64(a.val, b.val)); } \ + inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ + { return ~(a == b); } + +OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(v_uint64x4) +OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(v_int64x4) + +#define OPENCV_HAL_IMPL_AVX_CMP_FLT(bin_op, imm8, _Tpvec, suffix) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_cmp_##suffix(a.val, b.val, imm8)); } + +#define OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(_Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(==, _CMP_EQ_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(!=, _CMP_NEQ_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(<, _CMP_LT_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(>, _CMP_GT_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(<=, _CMP_LE_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(>=, _CMP_GE_OQ, _Tpvec, suffix) + +OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(v_float64x4, pd) + +inline v_float32x8 v_not_nan(const v_float32x8& a) +{ return v_float32x8(_mm256_cmp_ps(a.val, a.val, _CMP_ORD_Q)); } +inline v_float64x4 v_not_nan(const v_float64x4& a) +{ return v_float64x4(_mm256_cmp_pd(a.val, a.val, _CMP_ORD_Q)); } + +/** min/max **/ +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint8x32, _mm256_min_epu8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint8x32, _mm256_max_epu8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_int8x32, _mm256_min_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_int8x32, _mm256_max_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint16x16, _mm256_min_epu16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint16x16, _mm256_max_epu16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_int16x16, _mm256_min_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_int16x16, _mm256_max_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint32x8, _mm256_min_epu32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint32x8, _mm256_max_epu32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_int32x8, _mm256_min_epi32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_int32x8, _mm256_max_epi32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_float32x8, _mm256_min_ps) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_float32x8, _mm256_max_ps) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_float64x4, _mm256_min_pd) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_float64x4, _mm256_max_pd) + +/** Rotate **/ +template +inline v_uint8x32 v_rotate_left(const v_uint8x32& a, const v_uint8x32& b) +{ + enum {IMM_R = (16 - imm) & 0xFF}; + enum {IMM_R2 = (32 - imm) & 0xFF}; + + if (imm == 0) return a; + if (imm == 32) return b; + if (imm > 32) return v_uint8x32(); + + __m256i swap = _mm256_permute2x128_si256(a.val, b.val, 0x03); + if (imm == 16) return v_uint8x32(swap); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(a.val, swap, IMM_R)); + return v_uint8x32(_mm256_alignr_epi8(swap, b.val, IMM_R2)); // imm < 32 +} + +template +inline v_uint8x32 v_rotate_right(const v_uint8x32& a, const v_uint8x32& b) +{ + enum {IMM_L = (imm - 16) & 0xFF}; + + if (imm == 0) return a; + if (imm == 32) return b; + if (imm > 32) return v_uint8x32(); + + __m256i swap = _mm256_permute2x128_si256(a.val, b.val, 0x21); + if (imm == 16) return v_uint8x32(swap); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(swap, a.val, imm)); + return v_uint8x32(_mm256_alignr_epi8(b.val, swap, IMM_L)); +} + +template +inline v_uint8x32 v_rotate_left(const v_uint8x32& a) +{ + enum {IMM_L = (imm - 16) & 0xFF}; + enum {IMM_R = (16 - imm) & 0xFF}; + + if (imm == 0) return a; + if (imm > 32) return v_uint8x32(); + + // ESAC control[3] ? [127:0] = 0 + __m256i swapz = _mm256_permute2x128_si256(a.val, a.val, _MM_SHUFFLE(0, 0, 2, 0)); + if (imm == 16) return v_uint8x32(swapz); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(a.val, swapz, IMM_R)); + return v_uint8x32(_mm256_slli_si256(swapz, IMM_L)); +} + +template +inline v_uint8x32 v_rotate_right(const v_uint8x32& a) +{ + enum {IMM_L = (imm - 16) & 0xFF}; + + if (imm == 0) return a; + if (imm > 32) return v_uint8x32(); + + // ESAC control[3] ? [127:0] = 0 + __m256i swapz = _mm256_permute2x128_si256(a.val, a.val, _MM_SHUFFLE(2, 0, 0, 1)); + if (imm == 16) return v_uint8x32(swapz); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(swapz, a.val, imm)); + return v_uint8x32(_mm256_srli_si256(swapz, IMM_L)); +} + +#define OPENCV_HAL_IMPL_AVX_ROTATE_CAST(intrin, _Tpvec, cast) \ + template \ + inline _Tpvec intrin(const _Tpvec& a, const _Tpvec& b) \ + { \ + enum {IMMxW = imm * sizeof(typename _Tpvec::lane_type)}; \ + v_uint8x32 ret = intrin(v_reinterpret_as_u8(a), \ + v_reinterpret_as_u8(b)); \ + return _Tpvec(cast(ret.val)); \ + } \ + template \ + inline _Tpvec intrin(const _Tpvec& a) \ + { \ + enum {IMMxW = imm * sizeof(typename _Tpvec::lane_type)}; \ + v_uint8x32 ret = intrin(v_reinterpret_as_u8(a)); \ + return _Tpvec(cast(ret.val)); \ + } + +#define OPENCV_HAL_IMPL_AVX_ROTATE(_Tpvec) \ + OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_left, _Tpvec, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_right, _Tpvec, OPENCV_HAL_NOP) + +OPENCV_HAL_IMPL_AVX_ROTATE(v_int8x32) +OPENCV_HAL_IMPL_AVX_ROTATE(v_uint16x16) +OPENCV_HAL_IMPL_AVX_ROTATE(v_int16x16) +OPENCV_HAL_IMPL_AVX_ROTATE(v_uint32x8) +OPENCV_HAL_IMPL_AVX_ROTATE(v_int32x8) +OPENCV_HAL_IMPL_AVX_ROTATE(v_uint64x4) +OPENCV_HAL_IMPL_AVX_ROTATE(v_int64x4) + +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_left, v_float32x8, _mm256_castsi256_ps) +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_right, v_float32x8, _mm256_castsi256_ps) +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_left, v_float64x4, _mm256_castsi256_pd) +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_right, v_float64x4, _mm256_castsi256_pd) + +/** Reverse **/ +inline v_uint8x32 v_reverse(const v_uint8x32 &a) +{ + static const __m256i perm = _mm256_setr_epi8( + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); + __m256i vec = _mm256_shuffle_epi8(a.val, perm); + return v_uint8x32(_mm256_permute2x128_si256(vec, vec, 1)); +} + +inline v_int8x32 v_reverse(const v_int8x32 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x16 v_reverse(const v_uint16x16 &a) +{ + static const __m256i perm = _mm256_setr_epi8( + 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1, + 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1); + __m256i vec = _mm256_shuffle_epi8(a.val, perm); + return v_uint16x16(_mm256_permute2x128_si256(vec, vec, 1)); +} + +inline v_int16x16 v_reverse(const v_int16x16 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x8 v_reverse(const v_uint32x8 &a) +{ + static const __m256i perm = _mm256_setr_epi32(7, 6, 5, 4, 3, 2, 1, 0); + return v_uint32x8(_mm256_permutevar8x32_epi32(a.val, perm)); +} + +inline v_int32x8 v_reverse(const v_int32x8 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x8 v_reverse(const v_float32x8 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x4 v_reverse(const v_uint64x4 &a) +{ + return v_uint64x4(_mm256_permute4x64_epi64(a.val, _MM_SHUFFLE(0, 1, 2, 3))); +} + +inline v_int64x4 v_reverse(const v_int64x4 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x4 v_reverse(const v_float64x4 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +////////// Reduce and mask ///////// + +/** Reduce **/ +inline unsigned v_reduce_sum(const v_uint8x32& a) +{ + __m256i half = _mm256_sad_epu8(a.val, _mm256_setzero_si256()); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline int v_reduce_sum(const v_int8x32& a) +{ + __m256i half = _mm256_sad_epu8(_mm256_xor_si256(a.val, _mm256_set1_epi8((schar)-128)), _mm256_setzero_si256()); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))) - 4096; +} +#define OPENCV_HAL_IMPL_AVX_REDUCE_32(_Tpvec, sctype, func, intrin) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { \ + __m128i val = intrin(_v256_extract_low(a.val), _v256_extract_high(a.val)); \ + val = intrin(val, _mm_srli_si128(val,8)); \ + val = intrin(val, _mm_srli_si128(val,4)); \ + val = intrin(val, _mm_srli_si128(val,2)); \ + val = intrin(val, _mm_srli_si128(val,1)); \ + return (sctype)_mm_cvtsi128_si32(val); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_uint8x32, uchar, min, _mm_min_epu8) +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_int8x32, schar, min, _mm_min_epi8) +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_uint8x32, uchar, max, _mm_max_epu8) +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_int8x32, schar, max, _mm_max_epi8) + +#define OPENCV_HAL_IMPL_AVX_REDUCE_16(_Tpvec, sctype, func, intrin) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { \ + __m128i v0 = _v256_extract_low(a.val); \ + __m128i v1 = _v256_extract_high(a.val); \ + v0 = intrin(v0, v1); \ + v0 = intrin(v0, _mm_srli_si128(v0, 8)); \ + v0 = intrin(v0, _mm_srli_si128(v0, 4)); \ + v0 = intrin(v0, _mm_srli_si128(v0, 2)); \ + return (sctype) _mm_cvtsi128_si32(v0); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_uint16x16, ushort, min, _mm_min_epu16) +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_int16x16, short, min, _mm_min_epi16) +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_uint16x16, ushort, max, _mm_max_epu16) +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_int16x16, short, max, _mm_max_epi16) + +#define OPENCV_HAL_IMPL_AVX_REDUCE_8(_Tpvec, sctype, func, intrin) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { \ + __m128i v0 = _v256_extract_low(a.val); \ + __m128i v1 = _v256_extract_high(a.val); \ + v0 = intrin(v0, v1); \ + v0 = intrin(v0, _mm_srli_si128(v0, 8)); \ + v0 = intrin(v0, _mm_srli_si128(v0, 4)); \ + return (sctype) _mm_cvtsi128_si32(v0); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_uint32x8, unsigned, min, _mm_min_epu32) +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_int32x8, int, min, _mm_min_epi32) +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_uint32x8, unsigned, max, _mm_max_epu32) +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_int32x8, int, max, _mm_max_epi32) + +#define OPENCV_HAL_IMPL_AVX_REDUCE_FLT(func, intrin) \ + inline float v_reduce_##func(const v_float32x8& a) \ + { \ + __m128 v0 = _v256_extract_low(a.val); \ + __m128 v1 = _v256_extract_high(a.val); \ + v0 = intrin(v0, v1); \ + v0 = intrin(v0, _mm_permute_ps(v0, _MM_SHUFFLE(0, 0, 3, 2))); \ + v0 = intrin(v0, _mm_permute_ps(v0, _MM_SHUFFLE(0, 0, 0, 1))); \ + return _mm_cvtss_f32(v0); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_FLT(min, _mm_min_ps) +OPENCV_HAL_IMPL_AVX_REDUCE_FLT(max, _mm_max_ps) + +inline int v_reduce_sum(const v_int32x8& a) +{ + __m256i s0 = _mm256_hadd_epi32(a.val, a.val); + s0 = _mm256_hadd_epi32(s0, s0); + + __m128i s1 = _v256_extract_high(s0); + s1 = _mm_add_epi32(_v256_extract_low(s0), s1); + + return _mm_cvtsi128_si32(s1); +} + +inline unsigned v_reduce_sum(const v_uint32x8& a) +{ return v_reduce_sum(v_reinterpret_as_s32(a)); } + +inline int v_reduce_sum(const v_int16x16& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } +inline unsigned v_reduce_sum(const v_uint16x16& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } + +inline float v_reduce_sum(const v_float32x8& a) +{ + __m256 s0 = _mm256_hadd_ps(a.val, a.val); + s0 = _mm256_hadd_ps(s0, s0); + + __m128 s1 = _v256_extract_high(s0); + s1 = _mm_add_ps(_v256_extract_low(s0), s1); + + return _mm_cvtss_f32(s1); +} + +inline uint64 v_reduce_sum(const v_uint64x4& a) +{ + uint64 CV_DECL_ALIGNED(32) idx[2]; + _mm_store_si128((__m128i*)idx, _mm_add_epi64(_v256_extract_low(a.val), _v256_extract_high(a.val))); + return idx[0] + idx[1]; +} +inline int64 v_reduce_sum(const v_int64x4& a) +{ + int64 CV_DECL_ALIGNED(32) idx[2]; + _mm_store_si128((__m128i*)idx, _mm_add_epi64(_v256_extract_low(a.val), _v256_extract_high(a.val))); + return idx[0] + idx[1]; +} +inline double v_reduce_sum(const v_float64x4& a) +{ + __m256d s0 = _mm256_hadd_pd(a.val, a.val); + return _mm_cvtsd_f64(_mm_add_pd(_v256_extract_low(s0), _v256_extract_high(s0))); +} + +inline v_float32x8 v_reduce_sum4(const v_float32x8& a, const v_float32x8& b, + const v_float32x8& c, const v_float32x8& d) +{ + __m256 ab = _mm256_hadd_ps(a.val, b.val); + __m256 cd = _mm256_hadd_ps(c.val, d.val); + return v_float32x8(_mm256_hadd_ps(ab, cd)); +} + +inline unsigned v_reduce_sad(const v_uint8x32& a, const v_uint8x32& b) +{ + __m256i half = _mm256_sad_epu8(a.val, b.val); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_int8x32& a, const v_int8x32& b) +{ + __m256i half = _mm256_set1_epi8(0x7f); + half = _mm256_sad_epu8(_mm256_add_epi8(a.val, half), _mm256_add_epi8(b.val, half)); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_uint16x16& a, const v_uint16x16& b) +{ + v_uint32x8 l, h; + v_expand(v_add_wrap(a - b, b - a), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_int16x16& a, const v_int16x16& b) +{ + v_uint32x8 l, h; + v_expand(v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_uint32x8& a, const v_uint32x8& b) +{ + return v_reduce_sum(v_max(a, b) - v_min(a, b)); +} +inline unsigned v_reduce_sad(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 m = a < b; + return v_reduce_sum(v_reinterpret_as_u32(((a - b) ^ m) - m)); +} +inline float v_reduce_sad(const v_float32x8& a, const v_float32x8& b) +{ + return v_reduce_sum((a - b) & v_float32x8(_mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff)))); +} + +/** Popcount **/ +inline v_uint8x32 v_popcount(const v_uint8x32& a) +{ + __m256i _popcnt_table = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4); + __m256i _popcnt_mask = _mm256_set1_epi8(0x0F); + return v_uint8x32(_mm256_add_epi8(_mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256( a.val , _popcnt_mask)), + _mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256(_mm256_srli_epi16(a.val, 4), _popcnt_mask)))); +} +inline v_uint16x16 v_popcount(const v_uint16x16& a) +{ + v_uint8x32 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v256_setall_u16(0x00ff); +} +inline v_uint32x8 v_popcount(const v_uint32x8& a) +{ + v_uint8x32 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v256_setall_u32(0x000000ff); +} +inline v_uint64x4 v_popcount(const v_uint64x4& a) +{ + return v_uint64x4(_mm256_sad_epu8(v_popcount(v_reinterpret_as_u8(a)).val, _mm256_setzero_si256())); +} +inline v_uint8x32 v_popcount(const v_int8x32& a) +{ return v_popcount(v_reinterpret_as_u8(a)); } +inline v_uint16x16 v_popcount(const v_int16x16& a) +{ return v_popcount(v_reinterpret_as_u16(a)); } +inline v_uint32x8 v_popcount(const v_int32x8& a) +{ return v_popcount(v_reinterpret_as_u32(a)); } +inline v_uint64x4 v_popcount(const v_int64x4& a) +{ return v_popcount(v_reinterpret_as_u64(a)); } + +/** Mask **/ +inline int v_signmask(const v_int8x32& a) +{ return _mm256_movemask_epi8(a.val); } +inline int v_signmask(const v_uint8x32& a) +{ return v_signmask(v_reinterpret_as_s8(a)); } + +inline int v_signmask(const v_int16x16& a) +{ return v_signmask(v_pack(a, a)) & 0xFFFF; } +inline int v_signmask(const v_uint16x16& a) +{ return v_signmask(v_reinterpret_as_s16(a)); } + +inline int v_signmask(const v_float32x8& a) +{ return _mm256_movemask_ps(a.val); } +inline int v_signmask(const v_float64x4& a) +{ return _mm256_movemask_pd(a.val); } + +inline int v_signmask(const v_int32x8& a) +{ return v_signmask(v_reinterpret_as_f32(a)); } +inline int v_signmask(const v_uint32x8& a) +{ return v_signmask(v_reinterpret_as_f32(a)); } + +inline int v_signmask(const v_int64x4& a) +{ return v_signmask(v_reinterpret_as_f64(a)); } +inline int v_signmask(const v_uint64x4& a) +{ return v_signmask(v_reinterpret_as_f64(a)); } + +inline int v_scan_forward(const v_int8x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_uint8x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_int16x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_uint16x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_int32x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_uint32x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_float32x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_int64x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_uint64x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_float64x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } + +/** Checks **/ +#define OPENCV_HAL_IMPL_AVX_CHECK(_Tpvec, allmask) \ + inline bool v_check_all(const _Tpvec& a) { return v_signmask(a) == allmask; } \ + inline bool v_check_any(const _Tpvec& a) { return v_signmask(a) != 0; } +OPENCV_HAL_IMPL_AVX_CHECK(v_uint8x32, -1) +OPENCV_HAL_IMPL_AVX_CHECK(v_int8x32, -1) +OPENCV_HAL_IMPL_AVX_CHECK(v_uint32x8, 255) +OPENCV_HAL_IMPL_AVX_CHECK(v_int32x8, 255) +OPENCV_HAL_IMPL_AVX_CHECK(v_uint64x4, 15) +OPENCV_HAL_IMPL_AVX_CHECK(v_int64x4, 15) +OPENCV_HAL_IMPL_AVX_CHECK(v_float32x8, 255) +OPENCV_HAL_IMPL_AVX_CHECK(v_float64x4, 15) + +#define OPENCV_HAL_IMPL_AVX_CHECK_SHORT(_Tpvec) \ + inline bool v_check_all(const _Tpvec& a) { return (v_signmask(v_reinterpret_as_s8(a)) & 0xaaaaaaaa) == 0xaaaaaaaa; } \ + inline bool v_check_any(const _Tpvec& a) { return (v_signmask(v_reinterpret_as_s8(a)) & 0xaaaaaaaa) != 0; } +OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_uint16x16) +OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_int16x16) + +////////// Other math ///////// + +/** Some frequent operations **/ +#if CV_FMA3 +#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } +#else +#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } +#endif + +#define OPENCV_HAL_IMPL_AVX_MISC(_Tpvec, suffix) \ + inline _Tpvec v_sqrt(const _Tpvec& x) \ + { return _Tpvec(_mm256_sqrt_##suffix(x.val)); } \ + inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_fma(a, a, b * b); } \ + inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_sqrt(v_fma(a, a, b*b)); } + +OPENCV_HAL_IMPL_AVX_MULADD(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_MULADD(v_float64x4, pd) +OPENCV_HAL_IMPL_AVX_MISC(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_MISC(v_float64x4, pd) + +inline v_int32x8 v_fma(const v_int32x8& a, const v_int32x8& b, const v_int32x8& c) +{ + return a * b + c; +} + +inline v_int32x8 v_muladd(const v_int32x8& a, const v_int32x8& b, const v_int32x8& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x8 v_invsqrt(const v_float32x8& x) +{ + v_float32x8 half = x * v256_setall_f32(0.5); + v_float32x8 t = v_float32x8(_mm256_rsqrt_ps(x.val)); + // todo: _mm256_fnmsub_ps + t *= v256_setall_f32(1.5) - ((t * t) * half); + return t; +} + +inline v_float64x4 v_invsqrt(const v_float64x4& x) +{ + return v256_setall_f64(1.) / v_sqrt(x); +} + +/** Absolute values **/ +#define OPENCV_HAL_IMPL_AVX_ABS(_Tpvec, suffix) \ + inline v_u##_Tpvec v_abs(const v_##_Tpvec& x) \ + { return v_u##_Tpvec(_mm256_abs_##suffix(x.val)); } + +OPENCV_HAL_IMPL_AVX_ABS(int8x32, epi8) +OPENCV_HAL_IMPL_AVX_ABS(int16x16, epi16) +OPENCV_HAL_IMPL_AVX_ABS(int32x8, epi32) + +inline v_float32x8 v_abs(const v_float32x8& x) +{ return x & v_float32x8(_mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff))); } +inline v_float64x4 v_abs(const v_float64x4& x) +{ return x & v_float64x4(_mm256_castsi256_pd(_mm256_srli_epi64(_mm256_set1_epi64x(-1), 1))); } + +/** Absolute difference **/ +inline v_uint8x32 v_absdiff(const v_uint8x32& a, const v_uint8x32& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x16 v_absdiff(const v_uint16x16& a, const v_uint16x16& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x8 v_absdiff(const v_uint32x8& a, const v_uint32x8& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x32 v_absdiff(const v_int8x32& a, const v_int8x32& b) +{ + v_int8x32 d = v_sub_wrap(a, b); + v_int8x32 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} + +inline v_uint16x16 v_absdiff(const v_int16x16& a, const v_int16x16& b) +{ return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); } + +inline v_uint32x8 v_absdiff(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 d = a - b; + v_int32x8 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +inline v_float32x8 v_absdiff(const v_float32x8& a, const v_float32x8& b) +{ return v_abs(a - b); } + +inline v_float64x4 v_absdiff(const v_float64x4& a, const v_float64x4& b) +{ return v_abs(a - b); } + +/** Saturating absolute difference **/ +inline v_int8x32 v_absdiffs(const v_int8x32& a, const v_int8x32& b) +{ + v_int8x32 d = a - b; + v_int8x32 m = a < b; + return (d ^ m) - m; +} +inline v_int16x16 v_absdiffs(const v_int16x16& a, const v_int16x16& b) +{ return v_max(a, b) - v_min(a, b); } + +////////// Conversions ///////// + +/** Rounding **/ +inline v_int32x8 v_round(const v_float32x8& a) +{ return v_int32x8(_mm256_cvtps_epi32(a.val)); } + +inline v_int32x8 v_round(const v_float64x4& a) +{ return v_int32x8(_mm256_castsi128_si256(_mm256_cvtpd_epi32(a.val))); } + +inline v_int32x8 v_round(const v_float64x4& a, const v_float64x4& b) +{ + __m128i ai = _mm256_cvtpd_epi32(a.val), bi = _mm256_cvtpd_epi32(b.val); + return v_int32x8(_v256_combine(ai, bi)); +} + +inline v_int32x8 v_trunc(const v_float32x8& a) +{ return v_int32x8(_mm256_cvttps_epi32(a.val)); } + +inline v_int32x8 v_trunc(const v_float64x4& a) +{ return v_int32x8(_mm256_castsi128_si256(_mm256_cvttpd_epi32(a.val))); } + +inline v_int32x8 v_floor(const v_float32x8& a) +{ return v_int32x8(_mm256_cvttps_epi32(_mm256_floor_ps(a.val))); } + +inline v_int32x8 v_floor(const v_float64x4& a) +{ return v_trunc(v_float64x4(_mm256_floor_pd(a.val))); } + +inline v_int32x8 v_ceil(const v_float32x8& a) +{ return v_int32x8(_mm256_cvttps_epi32(_mm256_ceil_ps(a.val))); } + +inline v_int32x8 v_ceil(const v_float64x4& a) +{ return v_trunc(v_float64x4(_mm256_ceil_pd(a.val))); } + +/** To float **/ +inline v_float32x8 v_cvt_f32(const v_int32x8& a) +{ return v_float32x8(_mm256_cvtepi32_ps(a.val)); } + +inline v_float32x8 v_cvt_f32(const v_float64x4& a) +{ return v_float32x8(_mm256_castps128_ps256(_mm256_cvtpd_ps(a.val))); } + +inline v_float32x8 v_cvt_f32(const v_float64x4& a, const v_float64x4& b) +{ + __m128 af = _mm256_cvtpd_ps(a.val), bf = _mm256_cvtpd_ps(b.val); + return v_float32x8(_v256_combine(af, bf)); +} + +inline v_float64x4 v_cvt_f64(const v_int32x8& a) +{ return v_float64x4(_mm256_cvtepi32_pd(_v256_extract_low(a.val))); } + +inline v_float64x4 v_cvt_f64_high(const v_int32x8& a) +{ return v_float64x4(_mm256_cvtepi32_pd(_v256_extract_high(a.val))); } + +inline v_float64x4 v_cvt_f64(const v_float32x8& a) +{ return v_float64x4(_mm256_cvtps_pd(_v256_extract_low(a.val))); } + +inline v_float64x4 v_cvt_f64_high(const v_float32x8& a) +{ return v_float64x4(_mm256_cvtps_pd(_v256_extract_high(a.val))); } + +// from (Mysticial and wim) https://stackoverflow.com/q/41144668 +inline v_float64x4 v_cvt_f64(const v_int64x4& v) +{ + // constants encoded as floating-point + __m256i magic_i_lo = _mm256_set1_epi64x(0x4330000000000000); // 2^52 + __m256i magic_i_hi32 = _mm256_set1_epi64x(0x4530000080000000); // 2^84 + 2^63 + __m256i magic_i_all = _mm256_set1_epi64x(0x4530000080100000); // 2^84 + 2^63 + 2^52 + __m256d magic_d_all = _mm256_castsi256_pd(magic_i_all); + + // Blend the 32 lowest significant bits of v with magic_int_lo + __m256i v_lo = _mm256_blend_epi32(magic_i_lo, v.val, 0x55); + // Extract the 32 most significant bits of v + __m256i v_hi = _mm256_srli_epi64(v.val, 32); + // Flip the msb of v_hi and blend with 0x45300000 + v_hi = _mm256_xor_si256(v_hi, magic_i_hi32); + // Compute in double precision + __m256d v_hi_dbl = _mm256_sub_pd(_mm256_castsi256_pd(v_hi), magic_d_all); + // (v_hi - magic_d_all) + v_lo Do not assume associativity of floating point addition + __m256d result = _mm256_add_pd(v_hi_dbl, _mm256_castsi256_pd(v_lo)); + return v_float64x4(result); +} + +////////////// Lookup table access //////////////////// + +inline v_int8x32 v256_lut(const schar* tab, const int* idx) +{ + return v_int8x32(_mm256_setr_epi8(tab[idx[ 0]], tab[idx[ 1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[ 8]], tab[idx[ 9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]], + tab[idx[16]], tab[idx[17]], tab[idx[18]], tab[idx[19]], tab[idx[20]], tab[idx[21]], tab[idx[22]], tab[idx[23]], + tab[idx[24]], tab[idx[25]], tab[idx[26]], tab[idx[27]], tab[idx[28]], tab[idx[29]], tab[idx[30]], tab[idx[31]])); +} +inline v_int8x32 v256_lut_pairs(const schar* tab, const int* idx) +{ + return v_int8x32(_mm256_setr_epi16(*(const short*)(tab + idx[ 0]), *(const short*)(tab + idx[ 1]), *(const short*)(tab + idx[ 2]), *(const short*)(tab + idx[ 3]), + *(const short*)(tab + idx[ 4]), *(const short*)(tab + idx[ 5]), *(const short*)(tab + idx[ 6]), *(const short*)(tab + idx[ 7]), + *(const short*)(tab + idx[ 8]), *(const short*)(tab + idx[ 9]), *(const short*)(tab + idx[10]), *(const short*)(tab + idx[11]), + *(const short*)(tab + idx[12]), *(const short*)(tab + idx[13]), *(const short*)(tab + idx[14]), *(const short*)(tab + idx[15]))); +} +inline v_int8x32 v256_lut_quads(const schar* tab, const int* idx) +{ + return v_int8x32(_mm256_i32gather_epi32((const int*)tab, _mm256_loadu_si256((const __m256i*)idx), 1)); +} +inline v_uint8x32 v256_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v256_lut((const schar *)tab, idx)); } +inline v_uint8x32 v256_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v256_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x32 v256_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v256_lut_quads((const schar *)tab, idx)); } + +inline v_int16x16 v256_lut(const short* tab, const int* idx) +{ + return v_int16x16(_mm256_setr_epi16(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]])); +} +inline v_int16x16 v256_lut_pairs(const short* tab, const int* idx) +{ + return v_int16x16(_mm256_i32gather_epi32((const int*)tab, _mm256_loadu_si256((const __m256i*)idx), 2)); +} +inline v_int16x16 v256_lut_quads(const short* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int16x16(_mm256_i32gather_epi64((const long long int*)tab, _mm_loadu_si128((const __m128i*)idx), 2));//Looks like intrinsic has wrong definition +#else + return v_int16x16(_mm256_i32gather_epi64((const int64*)tab, _mm_loadu_si128((const __m128i*)idx), 2)); +#endif +} +inline v_uint16x16 v256_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v256_lut((const short *)tab, idx)); } +inline v_uint16x16 v256_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v256_lut_pairs((const short *)tab, idx)); } +inline v_uint16x16 v256_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v256_lut_quads((const short *)tab, idx)); } + +inline v_int32x8 v256_lut(const int* tab, const int* idx) +{ + return v_int32x8(_mm256_i32gather_epi32(tab, _mm256_loadu_si256((const __m256i*)idx), 4)); +} +inline v_int32x8 v256_lut_pairs(const int* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int32x8(_mm256_i32gather_epi64((const long long int*)tab, _mm_loadu_si128((const __m128i*)idx), 4)); +#else + return v_int32x8(_mm256_i32gather_epi64((const int64*)tab, _mm_loadu_si128((const __m128i*)idx), 4)); +#endif +} +inline v_int32x8 v256_lut_quads(const int* tab, const int* idx) +{ + return v_int32x8(_v256_combine(_mm_loadu_si128((const __m128i*)(tab + idx[0])), _mm_loadu_si128((const __m128i*)(tab + idx[1])))); +} +inline v_uint32x8 v256_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v256_lut((const int *)tab, idx)); } +inline v_uint32x8 v256_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v256_lut_pairs((const int *)tab, idx)); } +inline v_uint32x8 v256_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v256_lut_quads((const int *)tab, idx)); } + +inline v_int64x4 v256_lut(const int64* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int64x4(_mm256_i32gather_epi64((const long long int*)tab, _mm_loadu_si128((const __m128i*)idx), 8)); +#else + return v_int64x4(_mm256_i32gather_epi64(tab, _mm_loadu_si128((const __m128i*)idx), 8)); +#endif +} +inline v_int64x4 v256_lut_pairs(const int64* tab, const int* idx) +{ + return v_int64x4(_v256_combine(_mm_loadu_si128((const __m128i*)(tab + idx[0])), _mm_loadu_si128((const __m128i*)(tab + idx[1])))); +} +inline v_uint64x4 v256_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v256_lut((const int64 *)tab, idx)); } +inline v_uint64x4 v256_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v256_lut_pairs((const int64 *)tab, idx)); } + +inline v_float32x8 v256_lut(const float* tab, const int* idx) +{ + return v_float32x8(_mm256_i32gather_ps(tab, _mm256_loadu_si256((const __m256i*)idx), 4)); +} +inline v_float32x8 v256_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v256_lut_pairs((const int *)tab, idx)); } +inline v_float32x8 v256_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v256_lut_quads((const int *)tab, idx)); } + +inline v_float64x4 v256_lut(const double* tab, const int* idx) +{ + return v_float64x4(_mm256_i32gather_pd(tab, _mm_loadu_si128((const __m128i*)idx), 8)); +} +inline v_float64x4 v256_lut_pairs(const double* tab, const int* idx) { return v_float64x4(_v256_combine(_mm_loadu_pd(tab + idx[0]), _mm_loadu_pd(tab + idx[1]))); } + +inline v_int32x8 v_lut(const int* tab, const v_int32x8& idxvec) +{ + return v_int32x8(_mm256_i32gather_epi32(tab, idxvec.val, 4)); +} + +inline v_uint32x8 v_lut(const unsigned* tab, const v_int32x8& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x8 v_lut(const float* tab, const v_int32x8& idxvec) +{ + return v_float32x8(_mm256_i32gather_ps(tab, idxvec.val, 4)); +} + +inline v_float64x4 v_lut(const double* tab, const v_int32x8& idxvec) +{ + return v_float64x4(_mm256_i32gather_pd(tab, _mm256_castsi256_si128(idxvec.val), 8)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x8& idxvec, v_float32x8& x, v_float32x8& y) +{ + int CV_DECL_ALIGNED(32) idx[8]; + v_store_aligned(idx, idxvec); + __m128 z = _mm_setzero_ps(); + __m128 xy01, xy45, xy23, xy67; + xy01 = _mm_loadl_pi(z, (const __m64*)(tab + idx[0])); + xy01 = _mm_loadh_pi(xy01, (const __m64*)(tab + idx[1])); + xy45 = _mm_loadl_pi(z, (const __m64*)(tab + idx[4])); + xy45 = _mm_loadh_pi(xy45, (const __m64*)(tab + idx[5])); + __m256 xy0145 = _v256_combine(xy01, xy45); + xy23 = _mm_loadl_pi(z, (const __m64*)(tab + idx[2])); + xy23 = _mm_loadh_pi(xy23, (const __m64*)(tab + idx[3])); + xy67 = _mm_loadl_pi(z, (const __m64*)(tab + idx[6])); + xy67 = _mm_loadh_pi(xy67, (const __m64*)(tab + idx[7])); + __m256 xy2367 = _v256_combine(xy23, xy67); + + __m256 xxyy0145 = _mm256_unpacklo_ps(xy0145, xy2367); + __m256 xxyy2367 = _mm256_unpackhi_ps(xy0145, xy2367); + + x = v_float32x8(_mm256_unpacklo_ps(xxyy0145, xxyy2367)); + y = v_float32x8(_mm256_unpackhi_ps(xxyy0145, xxyy2367)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x8& idxvec, v_float64x4& x, v_float64x4& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_low(idx, idxvec); + __m128d xy0 = _mm_loadu_pd(tab + idx[0]); + __m128d xy2 = _mm_loadu_pd(tab + idx[2]); + __m128d xy1 = _mm_loadu_pd(tab + idx[1]); + __m128d xy3 = _mm_loadu_pd(tab + idx[3]); + __m256d xy02 = _v256_combine(xy0, xy2); + __m256d xy13 = _v256_combine(xy1, xy3); + + x = v_float64x4(_mm256_unpacklo_pd(xy02, xy13)); + y = v_float64x4(_mm256_unpackhi_pd(xy02, xy13)); +} + +inline v_int8x32 v_interleave_pairs(const v_int8x32& vec) +{ + return v_int8x32(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0d0e0c0b090a08, 0x0705060403010200, 0x0f0d0e0c0b090a08, 0x0705060403010200))); +} +inline v_uint8x32 v_interleave_pairs(const v_uint8x32& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x32 v_interleave_quads(const v_int8x32& vec) +{ + return v_int8x32(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0b0e0a0d090c08, 0x0703060205010400, 0x0f0b0e0a0d090c08, 0x0703060205010400))); +} +inline v_uint8x32 v_interleave_quads(const v_uint8x32& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x16 v_interleave_pairs(const v_int16x16& vec) +{ + return v_int16x16(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0e0b0a0d0c0908, 0x0706030205040100, 0x0f0e0b0a0d0c0908, 0x0706030205040100))); +} +inline v_uint16x16 v_interleave_pairs(const v_uint16x16& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x16 v_interleave_quads(const v_int16x16& vec) +{ + return v_int16x16(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0e07060d0c0504, 0x0b0a030209080100, 0x0f0e07060d0c0504, 0x0b0a030209080100))); +} +inline v_uint16x16 v_interleave_quads(const v_uint16x16& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x8 v_interleave_pairs(const v_int32x8& vec) +{ + return v_int32x8(_mm256_shuffle_epi32(vec.val, _MM_SHUFFLE(3, 1, 2, 0))); +} +inline v_uint32x8 v_interleave_pairs(const v_uint32x8& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x8 v_interleave_pairs(const v_float32x8& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x32 v_pack_triplets(const v_int8x32& vec) +{ + return v_int8x32(_mm256_permutevar8x32_epi32(_mm256_shuffle_epi8(vec.val, _mm256_broadcastsi128_si256(_mm_set_epi64x(0xffffff0f0e0d0c0a, 0x0908060504020100))), + _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} +inline v_uint8x32 v_pack_triplets(const v_uint8x32& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x16 v_pack_triplets(const v_int16x16& vec) +{ + return v_int16x16(_mm256_permutevar8x32_epi32(_mm256_shuffle_epi8(vec.val, _mm256_broadcastsi128_si256(_mm_set_epi64x(0xffff0f0e0d0c0b0a, 0x0908050403020100))), + _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} +inline v_uint16x16 v_pack_triplets(const v_uint16x16& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x8 v_pack_triplets(const v_int32x8& vec) +{ + return v_int32x8(_mm256_permutevar8x32_epi32(vec.val, _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} +inline v_uint32x8 v_pack_triplets(const v_uint32x8& vec) { return v_reinterpret_as_u32(v_pack_triplets(v_reinterpret_as_s32(vec))); } +inline v_float32x8 v_pack_triplets(const v_float32x8& vec) +{ + return v_float32x8(_mm256_permutevar8x32_ps(vec.val, _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} + +////////// Matrix operations ///////// + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x8 v_dotprod(const v_int16x16& a, const v_int16x16& b) +{ return v_int32x8(_mm256_madd_epi16(a.val, b.val)); } +inline v_int32x8 v_dotprod(const v_int16x16& a, const v_int16x16& b, const v_int32x8& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x4 v_dotprod(const v_int32x8& a, const v_int32x8& b) +{ + __m256i even = _mm256_mul_epi32(a.val, b.val); + __m256i odd = _mm256_mul_epi32(_mm256_srli_epi64(a.val, 32), _mm256_srli_epi64(b.val, 32)); + return v_int64x4(_mm256_add_epi64(even, odd)); +} +inline v_int64x4 v_dotprod(const v_int32x8& a, const v_int32x8& b, const v_int64x4& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x8 v_dotprod_expand(const v_uint8x32& a, const v_uint8x32& b) +{ + __m256i even_m = _mm256_set1_epi32(0xFF00FF00); + __m256i even_a = _mm256_blendv_epi8(a.val, _mm256_setzero_si256(), even_m); + __m256i odd_a = _mm256_srli_epi16(a.val, 8); + + __m256i even_b = _mm256_blendv_epi8(b.val, _mm256_setzero_si256(), even_m); + __m256i odd_b = _mm256_srli_epi16(b.val, 8); + + __m256i prod0 = _mm256_madd_epi16(even_a, even_b); + __m256i prod1 = _mm256_madd_epi16(odd_a, odd_b); + return v_uint32x8(_mm256_add_epi32(prod0, prod1)); +} +inline v_uint32x8 v_dotprod_expand(const v_uint8x32& a, const v_uint8x32& b, const v_uint32x8& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x8 v_dotprod_expand(const v_int8x32& a, const v_int8x32& b) +{ + __m256i even_a = _mm256_srai_epi16(_mm256_bslli_epi128(a.val, 1), 8); + __m256i odd_a = _mm256_srai_epi16(a.val, 8); + + __m256i even_b = _mm256_srai_epi16(_mm256_bslli_epi128(b.val, 1), 8); + __m256i odd_b = _mm256_srai_epi16(b.val, 8); + + __m256i prod0 = _mm256_madd_epi16(even_a, even_b); + __m256i prod1 = _mm256_madd_epi16(odd_a, odd_b); + return v_int32x8(_mm256_add_epi32(prod0, prod1)); +} +inline v_int32x8 v_dotprod_expand(const v_int8x32& a, const v_int8x32& b, const v_int32x8& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x4 v_dotprod_expand(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i mullo = _mm256_mullo_epi16(a.val, b.val); + __m256i mulhi = _mm256_mulhi_epu16(a.val, b.val); + __m256i mul0 = _mm256_unpacklo_epi16(mullo, mulhi); + __m256i mul1 = _mm256_unpackhi_epi16(mullo, mulhi); + + __m256i p02 = _mm256_blend_epi32(mul0, _mm256_setzero_si256(), 0xAA); + __m256i p13 = _mm256_srli_epi64(mul0, 32); + __m256i p46 = _mm256_blend_epi32(mul1, _mm256_setzero_si256(), 0xAA); + __m256i p57 = _mm256_srli_epi64(mul1, 32); + + __m256i p15_ = _mm256_add_epi64(p02, p13); + __m256i p9d_ = _mm256_add_epi64(p46, p57); + + return v_uint64x4(_mm256_add_epi64( + _mm256_unpacklo_epi64(p15_, p9d_), + _mm256_unpackhi_epi64(p15_, p9d_) + )); +} +inline v_uint64x4 v_dotprod_expand(const v_uint16x16& a, const v_uint16x16& b, const v_uint64x4& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x4 v_dotprod_expand(const v_int16x16& a, const v_int16x16& b) +{ + __m256i prod = _mm256_madd_epi16(a.val, b.val); + __m256i sign = _mm256_srai_epi32(prod, 31); + + __m256i lo = _mm256_unpacklo_epi32(prod, sign); + __m256i hi = _mm256_unpackhi_epi32(prod, sign); + + return v_int64x4(_mm256_add_epi64( + _mm256_unpacklo_epi64(lo, hi), + _mm256_unpackhi_epi64(lo, hi) + )); +} +inline v_int64x4 v_dotprod_expand(const v_int16x16& a, const v_int16x16& b, const v_int64x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x4 v_dotprod_expand(const v_int32x8& a, const v_int32x8& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x4 v_dotprod_expand(const v_int32x8& a, const v_int32x8& b, const v_float64x4& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x8 v_dotprod_fast(const v_int16x16& a, const v_int16x16& b) +{ return v_dotprod(a, b); } +inline v_int32x8 v_dotprod_fast(const v_int16x16& a, const v_int16x16& b, const v_int32x8& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x4 v_dotprod_fast(const v_int32x8& a, const v_int32x8& b) +{ return v_dotprod(a, b); } +inline v_int64x4 v_dotprod_fast(const v_int32x8& a, const v_int32x8& b, const v_int64x4& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x8 v_dotprod_expand_fast(const v_uint8x32& a, const v_uint8x32& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x8 v_dotprod_expand_fast(const v_uint8x32& a, const v_uint8x32& b, const v_uint32x8& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_int32x8 v_dotprod_expand_fast(const v_int8x32& a, const v_int8x32& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x8 v_dotprod_expand_fast(const v_int8x32& a, const v_int8x32& b, const v_int32x8& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x4 v_dotprod_expand_fast(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i mullo = _mm256_mullo_epi16(a.val, b.val); + __m256i mulhi = _mm256_mulhi_epu16(a.val, b.val); + __m256i mul0 = _mm256_unpacklo_epi16(mullo, mulhi); + __m256i mul1 = _mm256_unpackhi_epi16(mullo, mulhi); + + __m256i p02 = _mm256_blend_epi32(mul0, _mm256_setzero_si256(), 0xAA); + __m256i p13 = _mm256_srli_epi64(mul0, 32); + __m256i p46 = _mm256_blend_epi32(mul1, _mm256_setzero_si256(), 0xAA); + __m256i p57 = _mm256_srli_epi64(mul1, 32); + + __m256i p15_ = _mm256_add_epi64(p02, p13); + __m256i p9d_ = _mm256_add_epi64(p46, p57); + + return v_uint64x4(_mm256_add_epi64(p15_, p9d_)); +} +inline v_uint64x4 v_dotprod_expand_fast(const v_uint16x16& a, const v_uint16x16& b, const v_uint64x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x4 v_dotprod_expand_fast(const v_int16x16& a, const v_int16x16& b) +{ + __m256i prod = _mm256_madd_epi16(a.val, b.val); + __m256i sign = _mm256_srai_epi32(prod, 31); + __m256i lo = _mm256_unpacklo_epi32(prod, sign); + __m256i hi = _mm256_unpackhi_epi32(prod, sign); + return v_int64x4(_mm256_add_epi64(lo, hi)); +} +inline v_int64x4 v_dotprod_expand_fast(const v_int16x16& a, const v_int16x16& b, const v_int64x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +inline v_float64x4 v_dotprod_expand_fast(const v_int32x8& a, const v_int32x8& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x4 v_dotprod_expand_fast(const v_int32x8& a, const v_int32x8& b, const v_float64x4& c) +{ return v_dotprod_expand(a, b, c); } + +#define OPENCV_HAL_AVX_SPLAT2_PS(a, im) \ + v_float32x8(_mm256_permute_ps(a.val, _MM_SHUFFLE(im, im, im, im))) + +inline v_float32x8 v_matmul(const v_float32x8& v, const v_float32x8& m0, + const v_float32x8& m1, const v_float32x8& m2, + const v_float32x8& m3) +{ + v_float32x8 v04 = OPENCV_HAL_AVX_SPLAT2_PS(v, 0); + v_float32x8 v15 = OPENCV_HAL_AVX_SPLAT2_PS(v, 1); + v_float32x8 v26 = OPENCV_HAL_AVX_SPLAT2_PS(v, 2); + v_float32x8 v37 = OPENCV_HAL_AVX_SPLAT2_PS(v, 3); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, v37 * m3))); +} + +inline v_float32x8 v_matmuladd(const v_float32x8& v, const v_float32x8& m0, + const v_float32x8& m1, const v_float32x8& m2, + const v_float32x8& a) +{ + v_float32x8 v04 = OPENCV_HAL_AVX_SPLAT2_PS(v, 0); + v_float32x8 v15 = OPENCV_HAL_AVX_SPLAT2_PS(v, 1); + v_float32x8 v26 = OPENCV_HAL_AVX_SPLAT2_PS(v, 2); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, a))); +} + +#define OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(_Tpvec, suffix, cast_from, cast_to) \ + inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \ + { \ + __m256i t0 = cast_from(_mm256_unpacklo_##suffix(a0.val, a1.val)); \ + __m256i t1 = cast_from(_mm256_unpacklo_##suffix(a2.val, a3.val)); \ + __m256i t2 = cast_from(_mm256_unpackhi_##suffix(a0.val, a1.val)); \ + __m256i t3 = cast_from(_mm256_unpackhi_##suffix(a2.val, a3.val)); \ + b0.val = cast_to(_mm256_unpacklo_epi64(t0, t1)); \ + b1.val = cast_to(_mm256_unpackhi_epi64(t0, t1)); \ + b2.val = cast_to(_mm256_unpacklo_epi64(t2, t3)); \ + b3.val = cast_to(_mm256_unpackhi_epi64(t2, t3)); \ + } + +OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(v_uint32x8, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(v_int32x8, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(v_float32x8, ps, _mm256_castps_si256, _mm256_castsi256_ps) + +//////////////// Value reordering /////////////// + +/* Expand */ +#define OPENCV_HAL_IMPL_AVX_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ + inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ + { \ + b0.val = intrin(_v256_extract_low(a.val)); \ + b1.val = intrin(_v256_extract_high(a.val)); \ + } \ + inline _Tpwvec v_expand_low(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v256_extract_low(a.val))); } \ + inline _Tpwvec v_expand_high(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v256_extract_high(a.val))); } \ + inline _Tpwvec v256_load_expand(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadu_si128((const __m128i*)ptr); \ + return _Tpwvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX_EXPAND(v_uint8x32, v_uint16x16, uchar, _mm256_cvtepu8_epi16) +OPENCV_HAL_IMPL_AVX_EXPAND(v_int8x32, v_int16x16, schar, _mm256_cvtepi8_epi16) +OPENCV_HAL_IMPL_AVX_EXPAND(v_uint16x16, v_uint32x8, ushort, _mm256_cvtepu16_epi32) +OPENCV_HAL_IMPL_AVX_EXPAND(v_int16x16, v_int32x8, short, _mm256_cvtepi16_epi32) +OPENCV_HAL_IMPL_AVX_EXPAND(v_uint32x8, v_uint64x4, unsigned, _mm256_cvtepu32_epi64) +OPENCV_HAL_IMPL_AVX_EXPAND(v_int32x8, v_int64x4, int, _mm256_cvtepi32_epi64) + +#define OPENCV_HAL_IMPL_AVX_EXPAND_Q(_Tpvec, _Tp, intrin) \ + inline _Tpvec v256_load_expand_q(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadl_epi64((const __m128i*)ptr); \ + return _Tpvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX_EXPAND_Q(v_uint32x8, uchar, _mm256_cvtepu8_epi32) +OPENCV_HAL_IMPL_AVX_EXPAND_Q(v_int32x8, schar, _mm256_cvtepi8_epi32) + +/* pack */ +// 16 +inline v_int8x32 v_pack(const v_int16x16& a, const v_int16x16& b) +{ return v_int8x32(_v256_shuffle_odd_64(_mm256_packs_epi16(a.val, b.val))); } + +inline v_uint8x32 v_pack(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i t = _mm256_set1_epi16(255); + __m256i a1 = _mm256_min_epu16(a.val, t); + __m256i b1 = _mm256_min_epu16(b.val, t); + return v_uint8x32(_v256_shuffle_odd_64(_mm256_packus_epi16(a1, b1))); +} + +inline v_uint8x32 v_pack_u(const v_int16x16& a, const v_int16x16& b) +{ + return v_uint8x32(_v256_shuffle_odd_64(_mm256_packus_epi16(a.val, b.val))); +} + +inline void v_pack_store(schar* ptr, const v_int16x16& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(uchar* ptr, const v_uint16x16& a) +{ + const __m256i m = _mm256_set1_epi16(255); + __m256i am = _mm256_min_epu16(a.val, m); + am = _v256_shuffle_odd_64(_mm256_packus_epi16(am, am)); + v_store_low(ptr, v_uint8x32(am)); +} + +inline void v_pack_u_store(uchar* ptr, const v_int16x16& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + +template inline +v_uint8x32 v_rshr_pack(const v_uint16x16& a, const v_uint16x16& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + v_uint16x16 delta = v256_setall_u16((short)(1 << (n-1))); + return v_pack_u(v_reinterpret_as_s16((a + delta) >> n), + v_reinterpret_as_s16((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(uchar* ptr, const v_uint16x16& a) +{ + v_uint16x16 delta = v256_setall_u16((short)(1 << (n-1))); + v_pack_u_store(ptr, v_reinterpret_as_s16((a + delta) >> n)); +} + +template inline +v_uint8x32 v_rshr_pack_u(const v_int16x16& a, const v_int16x16& b) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(uchar* ptr, const v_int16x16& a) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int8x32 v_rshr_pack(const v_int16x16& a, const v_int16x16& b) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(schar* ptr, const v_int16x16& a) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + v_pack_store(ptr, (a + delta) >> n); +} + +// 32 +inline v_int16x16 v_pack(const v_int32x8& a, const v_int32x8& b) +{ return v_int16x16(_v256_shuffle_odd_64(_mm256_packs_epi32(a.val, b.val))); } + +inline v_uint16x16 v_pack(const v_uint32x8& a, const v_uint32x8& b) +{ return v_uint16x16(_v256_shuffle_odd_64(_v256_packs_epu32(a.val, b.val))); } + +inline v_uint16x16 v_pack_u(const v_int32x8& a, const v_int32x8& b) +{ return v_uint16x16(_v256_shuffle_odd_64(_mm256_packus_epi32(a.val, b.val))); } + +inline void v_pack_store(short* ptr, const v_int32x8& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(ushort* ptr, const v_uint32x8& a) +{ + const __m256i m = _mm256_set1_epi32(65535); + __m256i am = _mm256_min_epu32(a.val, m); + am = _v256_shuffle_odd_64(_mm256_packus_epi32(am, am)); + v_store_low(ptr, v_uint16x16(am)); +} + +inline void v_pack_u_store(ushort* ptr, const v_int32x8& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + + +template inline +v_uint16x16 v_rshr_pack(const v_uint32x8& a, const v_uint32x8& b) +{ + // we assume that n > 0, and so the shifted 32-bit values can be treated as signed numbers. + v_uint32x8 delta = v256_setall_u32(1 << (n-1)); + return v_pack_u(v_reinterpret_as_s32((a + delta) >> n), + v_reinterpret_as_s32((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(ushort* ptr, const v_uint32x8& a) +{ + v_uint32x8 delta = v256_setall_u32(1 << (n-1)); + v_pack_u_store(ptr, v_reinterpret_as_s32((a + delta) >> n)); +} + +template inline +v_uint16x16 v_rshr_pack_u(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(ushort* ptr, const v_int32x8& a) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int16x16 v_rshr_pack(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(short* ptr, const v_int32x8& a) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// 64 +// Non-saturating pack +inline v_uint32x8 v_pack(const v_uint64x4& a, const v_uint64x4& b) +{ + __m256i a0 = _mm256_shuffle_epi32(a.val, _MM_SHUFFLE(0, 0, 2, 0)); + __m256i b0 = _mm256_shuffle_epi32(b.val, _MM_SHUFFLE(0, 0, 2, 0)); + __m256i ab = _mm256_unpacklo_epi64(a0, b0); // a0, a1, b0, b1, a2, a3, b2, b3 + return v_uint32x8(_v256_shuffle_odd_64(ab)); +} + +inline v_int32x8 v_pack(const v_int64x4& a, const v_int64x4& b) +{ return v_reinterpret_as_s32(v_pack(v_reinterpret_as_u64(a), v_reinterpret_as_u64(b))); } + +inline void v_pack_store(unsigned* ptr, const v_uint64x4& a) +{ + __m256i a0 = _mm256_shuffle_epi32(a.val, _MM_SHUFFLE(0, 0, 2, 0)); + v_store_low(ptr, v_uint32x8(_v256_shuffle_odd_64(a0))); +} + +inline void v_pack_store(int* ptr, const v_int64x4& b) +{ v_pack_store((unsigned*)ptr, v_reinterpret_as_u64(b)); } + +template inline +v_uint32x8 v_rshr_pack(const v_uint64x4& a, const v_uint64x4& b) +{ + v_uint64x4 delta = v256_setall_u64((uint64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(unsigned* ptr, const v_uint64x4& a) +{ + v_uint64x4 delta = v256_setall_u64((uint64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +template inline +v_int32x8 v_rshr_pack(const v_int64x4& a, const v_int64x4& b) +{ + v_int64x4 delta = v256_setall_s64((int64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(int* ptr, const v_int64x4& a) +{ + v_int64x4 delta = v256_setall_s64((int64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// pack boolean +inline v_uint8x32 v_pack_b(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i ab = _mm256_packs_epi16(a.val, b.val); + return v_uint8x32(_v256_shuffle_odd_64(ab)); +} + +inline v_uint8x32 v_pack_b(const v_uint32x8& a, const v_uint32x8& b, + const v_uint32x8& c, const v_uint32x8& d) +{ + __m256i ab = _mm256_packs_epi32(a.val, b.val); + __m256i cd = _mm256_packs_epi32(c.val, d.val); + + __m256i abcd = _v256_shuffle_odd_64(_mm256_packs_epi16(ab, cd)); + return v_uint8x32(_mm256_shuffle_epi32(abcd, _MM_SHUFFLE(3, 1, 2, 0))); +} + +inline v_uint8x32 v_pack_b(const v_uint64x4& a, const v_uint64x4& b, const v_uint64x4& c, + const v_uint64x4& d, const v_uint64x4& e, const v_uint64x4& f, + const v_uint64x4& g, const v_uint64x4& h) +{ + __m256i ab = _mm256_packs_epi32(a.val, b.val); + __m256i cd = _mm256_packs_epi32(c.val, d.val); + __m256i ef = _mm256_packs_epi32(e.val, f.val); + __m256i gh = _mm256_packs_epi32(g.val, h.val); + + __m256i abcd = _mm256_packs_epi32(ab, cd); + __m256i efgh = _mm256_packs_epi32(ef, gh); + __m256i pkall = _v256_shuffle_odd_64(_mm256_packs_epi16(abcd, efgh)); + + __m256i rev = _mm256_alignr_epi8(pkall, pkall, 8); + return v_uint8x32(_mm256_unpacklo_epi16(pkall, rev)); +} + +/* Recombine */ +// its up there with load and store operations + +/* Extract */ +#define OPENCV_HAL_IMPL_AVX_EXTRACT(_Tpvec) \ + template \ + inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ + { return v_rotate_right(a, b); } + +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint8x32) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int8x32) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint16x16) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int16x16) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint32x8) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int32x8) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint64x4) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int64x4) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_float32x8) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_float64x4) + +template +inline uchar v_extract_n(v_uint8x32 a) +{ + return (uchar)_v256_extract_epi8(a.val); +} + +template +inline schar v_extract_n(v_int8x32 a) +{ + return (schar)v_extract_n(v_reinterpret_as_u8(a)); +} + +template +inline ushort v_extract_n(v_uint16x16 a) +{ + return (ushort)_v256_extract_epi16(a.val); +} + +template +inline short v_extract_n(v_int16x16 a) +{ + return (short)v_extract_n(v_reinterpret_as_u16(a)); +} + +template +inline uint v_extract_n(v_uint32x8 a) +{ + return (uint)_v256_extract_epi32(a.val); +} + +template +inline int v_extract_n(v_int32x8 a) +{ + return (int)v_extract_n(v_reinterpret_as_u32(a)); +} + +template +inline uint64 v_extract_n(v_uint64x4 a) +{ + return (uint64)_v256_extract_epi64(a.val); +} + +template +inline int64 v_extract_n(v_int64x4 v) +{ + return (int64)v_extract_n(v_reinterpret_as_u64(v)); +} + +template +inline float v_extract_n(v_float32x8 v) +{ + union { uint iv; float fv; } d; + d.iv = v_extract_n(v_reinterpret_as_u32(v)); + return d.fv; +} + +template +inline double v_extract_n(v_float64x4 v) +{ + union { uint64 iv; double dv; } d; + d.iv = v_extract_n(v_reinterpret_as_u64(v)); + return d.dv; +} + +template +inline v_uint32x8 v_broadcast_element(v_uint32x8 a) +{ + static const __m256i perm = _mm256_set1_epi32((char)i); + return v_uint32x8(_mm256_permutevar8x32_epi32(a.val, perm)); +} + +template +inline v_int32x8 v_broadcast_element(const v_int32x8 &a) +{ return v_reinterpret_as_s32(v_broadcast_element(v_reinterpret_as_u32(a))); } + +template +inline v_float32x8 v_broadcast_element(const v_float32x8 &a) +{ return v_reinterpret_as_f32(v_broadcast_element(v_reinterpret_as_u32(a))); } + + +///////////////////// load deinterleave ///////////////////////////// + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x32& a, v_uint8x32& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + + const __m256i sh = _mm256_setr_epi8(0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15, + 0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15); + __m256i p0 = _mm256_shuffle_epi8(ab0, sh); + __m256i p1 = _mm256_shuffle_epi8(ab1, sh); + __m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint8x32(a0); + b = v_uint8x32(b0); +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x16& a, v_uint16x16& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + + const __m256i sh = _mm256_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15, + 0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15); + __m256i p0 = _mm256_shuffle_epi8(ab0, sh); + __m256i p1 = _mm256_shuffle_epi8(ab1, sh); + __m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint16x16(a0); + b = v_uint16x16(b0); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + + enum { sh = 0+2*4+1*16+3*64 }; + __m256i p0 = _mm256_shuffle_epi32(ab0, sh); + __m256i p1 = _mm256_shuffle_epi32(ab1, sh); + __m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint32x8(a0); + b = v_uint32x8(b0); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x4& a, v_uint64x4& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 4)); + + __m256i pl = _mm256_permute2x128_si256(ab0, ab1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(ab0, ab1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint64x4(a0); + b = v_uint64x4(b0); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x32& a, v_uint8x32& b, v_uint8x32& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 64)); + + __m256i s02_low = _mm256_permute2x128_si256(bgr0, bgr2, 0 + 2*16); + __m256i s02_high = _mm256_permute2x128_si256(bgr0, bgr2, 1 + 3*16); + + const __m256i m0 = _mm256_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, + 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, + -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1); + + __m256i b0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_low, s02_high, m0), bgr1, m1); + __m256i g0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_high, s02_low, m1), bgr1, m0); + __m256i r0 = _mm256_blendv_epi8(_mm256_blendv_epi8(bgr1, s02_low, m0), s02_high, m1); + + const __m256i + sh_b = _mm256_setr_epi8(0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13, + 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13), + sh_g = _mm256_setr_epi8(1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, + 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14), + sh_r = _mm256_setr_epi8(2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, + 2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15); + b0 = _mm256_shuffle_epi8(b0, sh_b); + g0 = _mm256_shuffle_epi8(g0, sh_g); + r0 = _mm256_shuffle_epi8(r0, sh_r); + + a = v_uint8x32(b0); + b = v_uint8x32(g0); + c = v_uint8x32(r0); +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x16& a, v_uint16x16& b, v_uint16x16& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + + __m256i s02_low = _mm256_permute2x128_si256(bgr0, bgr2, 0 + 2*16); + __m256i s02_high = _mm256_permute2x128_si256(bgr0, bgr2, 1 + 3*16); + + const __m256i m0 = _mm256_setr_epi8(0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, + 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, + -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0); + __m256i b0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_low, s02_high, m0), bgr1, m1); + __m256i g0 = _mm256_blendv_epi8(_mm256_blendv_epi8(bgr1, s02_low, m0), s02_high, m1); + __m256i r0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_high, s02_low, m1), bgr1, m0); + const __m256i sh_b = _mm256_setr_epi8(0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11, + 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m256i sh_g = _mm256_setr_epi8(2, 3, 8, 9, 14, 15, 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, + 2, 3, 8, 9, 14, 15, 4, 5, 10, 11, 0, 1, 6, 7, 12, 13); + const __m256i sh_r = _mm256_setr_epi8(4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, + 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + b0 = _mm256_shuffle_epi8(b0, sh_b); + g0 = _mm256_shuffle_epi8(g0, sh_g); + r0 = _mm256_shuffle_epi8(r0, sh_r); + + a = v_uint16x16(b0); + b = v_uint16x16(g0); + c = v_uint16x16(r0); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8& b, v_uint32x8& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + + __m256i s02_low = _mm256_permute2x128_si256(bgr0, bgr2, 0 + 2*16); + __m256i s02_high = _mm256_permute2x128_si256(bgr0, bgr2, 1 + 3*16); + + __m256i b0 = _mm256_blend_epi32(_mm256_blend_epi32(s02_low, s02_high, 0x24), bgr1, 0x92); + __m256i g0 = _mm256_blend_epi32(_mm256_blend_epi32(s02_high, s02_low, 0x92), bgr1, 0x24); + __m256i r0 = _mm256_blend_epi32(_mm256_blend_epi32(bgr1, s02_low, 0x24), s02_high, 0x92); + + b0 = _mm256_shuffle_epi32(b0, 0x6c); + g0 = _mm256_shuffle_epi32(g0, 0xb1); + r0 = _mm256_shuffle_epi32(r0, 0xc6); + + a = v_uint32x8(b0); + b = v_uint32x8(g0); + c = v_uint32x8(r0); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x4& a, v_uint64x4& b, v_uint64x4& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 4)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + + __m256i s01 = _mm256_blend_epi32(bgr0, bgr1, 0xf0); + __m256i s12 = _mm256_blend_epi32(bgr1, bgr2, 0xf0); + __m256i s20r = _mm256_permute4x64_epi64(_mm256_blend_epi32(bgr2, bgr0, 0xf0), 0x1b); + __m256i b0 = _mm256_unpacklo_epi64(s01, s20r); + __m256i g0 = _mm256_alignr_epi8(s12, s01, 8); + __m256i r0 = _mm256_unpackhi_epi64(s20r, s12); + + a = v_uint64x4(b0); + b = v_uint64x4(g0); + c = v_uint64x4(r0); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x32& a, v_uint8x32& b, v_uint8x32& c, v_uint8x32& d ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 64)); + __m256i bgr3 = _mm256_loadu_si256((const __m256i*)(ptr + 96)); + const __m256i sh = _mm256_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, + 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + + __m256i p0 = _mm256_shuffle_epi8(bgr0, sh); + __m256i p1 = _mm256_shuffle_epi8(bgr1, sh); + __m256i p2 = _mm256_shuffle_epi8(bgr2, sh); + __m256i p3 = _mm256_shuffle_epi8(bgr3, sh); + + __m256i p01l = _mm256_unpacklo_epi32(p0, p1); + __m256i p01h = _mm256_unpackhi_epi32(p0, p1); + __m256i p23l = _mm256_unpacklo_epi32(p2, p3); + __m256i p23h = _mm256_unpackhi_epi32(p2, p3); + + __m256i pll = _mm256_permute2x128_si256(p01l, p23l, 0 + 2*16); + __m256i plh = _mm256_permute2x128_si256(p01l, p23l, 1 + 3*16); + __m256i phl = _mm256_permute2x128_si256(p01h, p23h, 0 + 2*16); + __m256i phh = _mm256_permute2x128_si256(p01h, p23h, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi32(pll, plh); + __m256i g0 = _mm256_unpackhi_epi32(pll, plh); + __m256i r0 = _mm256_unpacklo_epi32(phl, phh); + __m256i a0 = _mm256_unpackhi_epi32(phl, phh); + + a = v_uint8x32(b0); + b = v_uint8x32(g0); + c = v_uint8x32(r0); + d = v_uint8x32(a0); +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x16& a, v_uint16x16& b, v_uint16x16& c, v_uint16x16& d ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + __m256i bgr3 = _mm256_loadu_si256((const __m256i*)(ptr + 48)); + const __m256i sh = _mm256_setr_epi8(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15, + 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15); + __m256i p0 = _mm256_shuffle_epi8(bgr0, sh); + __m256i p1 = _mm256_shuffle_epi8(bgr1, sh); + __m256i p2 = _mm256_shuffle_epi8(bgr2, sh); + __m256i p3 = _mm256_shuffle_epi8(bgr3, sh); + + __m256i p01l = _mm256_unpacklo_epi32(p0, p1); + __m256i p01h = _mm256_unpackhi_epi32(p0, p1); + __m256i p23l = _mm256_unpacklo_epi32(p2, p3); + __m256i p23h = _mm256_unpackhi_epi32(p2, p3); + + __m256i pll = _mm256_permute2x128_si256(p01l, p23l, 0 + 2*16); + __m256i plh = _mm256_permute2x128_si256(p01l, p23l, 1 + 3*16); + __m256i phl = _mm256_permute2x128_si256(p01h, p23h, 0 + 2*16); + __m256i phh = _mm256_permute2x128_si256(p01h, p23h, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi32(pll, plh); + __m256i g0 = _mm256_unpackhi_epi32(pll, plh); + __m256i r0 = _mm256_unpacklo_epi32(phl, phh); + __m256i a0 = _mm256_unpackhi_epi32(phl, phh); + + a = v_uint16x16(b0); + b = v_uint16x16(g0); + c = v_uint16x16(r0); + d = v_uint16x16(a0); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8& b, v_uint32x8& c, v_uint32x8& d ) +{ + __m256i p0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i p1 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + __m256i p2 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + __m256i p3 = _mm256_loadu_si256((const __m256i*)(ptr + 24)); + + __m256i p01l = _mm256_unpacklo_epi32(p0, p1); + __m256i p01h = _mm256_unpackhi_epi32(p0, p1); + __m256i p23l = _mm256_unpacklo_epi32(p2, p3); + __m256i p23h = _mm256_unpackhi_epi32(p2, p3); + + __m256i pll = _mm256_permute2x128_si256(p01l, p23l, 0 + 2*16); + __m256i plh = _mm256_permute2x128_si256(p01l, p23l, 1 + 3*16); + __m256i phl = _mm256_permute2x128_si256(p01h, p23h, 0 + 2*16); + __m256i phh = _mm256_permute2x128_si256(p01h, p23h, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi32(pll, plh); + __m256i g0 = _mm256_unpackhi_epi32(pll, plh); + __m256i r0 = _mm256_unpacklo_epi32(phl, phh); + __m256i a0 = _mm256_unpackhi_epi32(phl, phh); + + a = v_uint32x8(b0); + b = v_uint32x8(g0); + c = v_uint32x8(r0); + d = v_uint32x8(a0); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x4& a, v_uint64x4& b, v_uint64x4& c, v_uint64x4& d ) +{ + __m256i bgra0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgra1 = _mm256_loadu_si256((const __m256i*)(ptr + 4)); + __m256i bgra2 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + __m256i bgra3 = _mm256_loadu_si256((const __m256i*)(ptr + 12)); + + __m256i l02 = _mm256_permute2x128_si256(bgra0, bgra2, 0 + 2*16); + __m256i h02 = _mm256_permute2x128_si256(bgra0, bgra2, 1 + 3*16); + __m256i l13 = _mm256_permute2x128_si256(bgra1, bgra3, 0 + 2*16); + __m256i h13 = _mm256_permute2x128_si256(bgra1, bgra3, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi64(l02, l13); + __m256i g0 = _mm256_unpackhi_epi64(l02, l13); + __m256i r0 = _mm256_unpacklo_epi64(h02, h13); + __m256i a0 = _mm256_unpackhi_epi64(h02, h13); + + a = v_uint64x4(b0); + b = v_uint64x4(g0); + c = v_uint64x4(r0); + d = v_uint64x4(a0); +} + +///////////////////////////// store interleave ///////////////////////////////////// + +inline void v_store_interleave( uchar* ptr, const v_uint8x32& x, const v_uint8x32& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi8(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi8(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 32), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 32), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 32), xy1); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x16& x, const v_uint16x16& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi16(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi16(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 16), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 16), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 16), xy1); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x8& x, const v_uint32x8& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi32(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi32(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 8), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 8), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 8), xy1); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x4& x, const v_uint64x4& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi64(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi64(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 4), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 4), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 4), xy1); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x32& a, const v_uint8x32& b, const v_uint8x32& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + const __m256i sh_b = _mm256_setr_epi8( + 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5, + 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5); + const __m256i sh_g = _mm256_setr_epi8( + 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, + 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10); + const __m256i sh_r = _mm256_setr_epi8( + 10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, + 10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15); + + __m256i b0 = _mm256_shuffle_epi8(a.val, sh_b); + __m256i g0 = _mm256_shuffle_epi8(b.val, sh_g); + __m256i r0 = _mm256_shuffle_epi8(c.val, sh_r); + + const __m256i m0 = _mm256_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, + 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, + 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); + + __m256i p0 = _mm256_blendv_epi8(_mm256_blendv_epi8(b0, g0, m0), r0, m1); + __m256i p1 = _mm256_blendv_epi8(_mm256_blendv_epi8(g0, r0, m0), b0, m1); + __m256i p2 = _mm256_blendv_epi8(_mm256_blendv_epi8(r0, b0, m0), g0, m1); + + __m256i bgr0 = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i bgr1 = _mm256_permute2x128_si256(p2, p0, 0 + 3*16); + __m256i bgr2 = _mm256_permute2x128_si256(p1, p2, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 32), bgr1); + _mm256_stream_si256((__m256i*)(ptr + 64), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 32), bgr1); + _mm256_store_si256((__m256i*)(ptr + 64), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgr1); + _mm256_storeu_si256((__m256i*)(ptr + 64), bgr2); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x16& a, const v_uint16x16& b, const v_uint16x16& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + const __m256i sh_b = _mm256_setr_epi8( + 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11, + 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m256i sh_g = _mm256_setr_epi8( + 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, + 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5); + const __m256i sh_r = _mm256_setr_epi8( + 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, + 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + + __m256i b0 = _mm256_shuffle_epi8(a.val, sh_b); + __m256i g0 = _mm256_shuffle_epi8(b.val, sh_g); + __m256i r0 = _mm256_shuffle_epi8(c.val, sh_r); + + const __m256i m0 = _mm256_setr_epi8(0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, + 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, + -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0); + + __m256i p0 = _mm256_blendv_epi8(_mm256_blendv_epi8(b0, g0, m0), r0, m1); + __m256i p1 = _mm256_blendv_epi8(_mm256_blendv_epi8(g0, r0, m0), b0, m1); + __m256i p2 = _mm256_blendv_epi8(_mm256_blendv_epi8(r0, b0, m0), g0, m1); + + __m256i bgr0 = _mm256_permute2x128_si256(p0, p2, 0 + 2*16); + //__m256i bgr1 = p1; + __m256i bgr2 = _mm256_permute2x128_si256(p0, p2, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 16), p1); + _mm256_stream_si256((__m256i*)(ptr + 32), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 16), p1); + _mm256_store_si256((__m256i*)(ptr + 32), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 16), p1); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgr2); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x8& a, const v_uint32x8& b, const v_uint32x8& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i b0 = _mm256_shuffle_epi32(a.val, 0x6c); + __m256i g0 = _mm256_shuffle_epi32(b.val, 0xb1); + __m256i r0 = _mm256_shuffle_epi32(c.val, 0xc6); + + __m256i p0 = _mm256_blend_epi32(_mm256_blend_epi32(b0, g0, 0x92), r0, 0x24); + __m256i p1 = _mm256_blend_epi32(_mm256_blend_epi32(g0, r0, 0x92), b0, 0x24); + __m256i p2 = _mm256_blend_epi32(_mm256_blend_epi32(r0, b0, 0x92), g0, 0x24); + + __m256i bgr0 = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + //__m256i bgr1 = p2; + __m256i bgr2 = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 8), p2); + _mm256_stream_si256((__m256i*)(ptr + 16), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 8), p2); + _mm256_store_si256((__m256i*)(ptr + 16), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 8), p2); + _mm256_storeu_si256((__m256i*)(ptr + 16), bgr2); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x4& a, const v_uint64x4& b, const v_uint64x4& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i s01 = _mm256_unpacklo_epi64(a.val, b.val); + __m256i s12 = _mm256_unpackhi_epi64(b.val, c.val); + __m256i s20 = _mm256_blend_epi32(c.val, a.val, 0xcc); + + __m256i bgr0 = _mm256_permute2x128_si256(s01, s20, 0 + 2*16); + __m256i bgr1 = _mm256_blend_epi32(s01, s12, 0x0f); + __m256i bgr2 = _mm256_permute2x128_si256(s20, s12, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 4), bgr1); + _mm256_stream_si256((__m256i*)(ptr + 8), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 4), bgr1); + _mm256_store_si256((__m256i*)(ptr + 8), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 4), bgr1); + _mm256_storeu_si256((__m256i*)(ptr + 8), bgr2); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x32& a, const v_uint8x32& b, + const v_uint8x32& c, const v_uint8x32& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi8(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi8(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi8(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi8(c.val, d.val); + + __m256i bgra0_ = _mm256_unpacklo_epi16(bg0, ra0); + __m256i bgra1_ = _mm256_unpackhi_epi16(bg0, ra0); + __m256i bgra2_ = _mm256_unpacklo_epi16(bg1, ra1); + __m256i bgra3_ = _mm256_unpackhi_epi16(bg1, ra1); + + __m256i bgra0 = _mm256_permute2x128_si256(bgra0_, bgra1_, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bgra0_, bgra1_, 1 + 3*16); + __m256i bgra1 = _mm256_permute2x128_si256(bgra2_, bgra3_, 0 + 2*16); + __m256i bgra3 = _mm256_permute2x128_si256(bgra2_, bgra3_, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 32), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 64), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 96), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 32), bgra1); + _mm256_store_si256((__m256i*)(ptr + 64), bgra2); + _mm256_store_si256((__m256i*)(ptr + 96), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 64), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 96), bgra3); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x16& a, const v_uint16x16& b, + const v_uint16x16& c, const v_uint16x16& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi16(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi16(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi16(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi16(c.val, d.val); + + __m256i bgra0_ = _mm256_unpacklo_epi32(bg0, ra0); + __m256i bgra1_ = _mm256_unpackhi_epi32(bg0, ra0); + __m256i bgra2_ = _mm256_unpacklo_epi32(bg1, ra1); + __m256i bgra3_ = _mm256_unpackhi_epi32(bg1, ra1); + + __m256i bgra0 = _mm256_permute2x128_si256(bgra0_, bgra1_, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bgra0_, bgra1_, 1 + 3*16); + __m256i bgra1 = _mm256_permute2x128_si256(bgra2_, bgra3_, 0 + 2*16); + __m256i bgra3 = _mm256_permute2x128_si256(bgra2_, bgra3_, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 16), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 32), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 48), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 16), bgra1); + _mm256_store_si256((__m256i*)(ptr + 32), bgra2); + _mm256_store_si256((__m256i*)(ptr + 48), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 16), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 48), bgra3); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x8& a, const v_uint32x8& b, + const v_uint32x8& c, const v_uint32x8& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi32(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi32(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi32(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi32(c.val, d.val); + + __m256i bgra0_ = _mm256_unpacklo_epi64(bg0, ra0); + __m256i bgra1_ = _mm256_unpackhi_epi64(bg0, ra0); + __m256i bgra2_ = _mm256_unpacklo_epi64(bg1, ra1); + __m256i bgra3_ = _mm256_unpackhi_epi64(bg1, ra1); + + __m256i bgra0 = _mm256_permute2x128_si256(bgra0_, bgra1_, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bgra0_, bgra1_, 1 + 3*16); + __m256i bgra1 = _mm256_permute2x128_si256(bgra2_, bgra3_, 0 + 2*16); + __m256i bgra3 = _mm256_permute2x128_si256(bgra2_, bgra3_, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 8), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 16), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 24), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 8), bgra1); + _mm256_store_si256((__m256i*)(ptr + 16), bgra2); + _mm256_store_si256((__m256i*)(ptr + 24), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 8), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 16), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 24), bgra3); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x4& a, const v_uint64x4& b, + const v_uint64x4& c, const v_uint64x4& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi64(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi64(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi64(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi64(c.val, d.val); + + __m256i bgra0 = _mm256_permute2x128_si256(bg0, ra0, 0 + 2*16); + __m256i bgra1 = _mm256_permute2x128_si256(bg1, ra1, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bg0, ra0, 1 + 3*16); + __m256i bgra3 = _mm256_permute2x128_si256(bg1, ra1, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 4), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 8), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 12), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 4), bgra1); + _mm256_store_si256((__m256i*)(ptr + 8), bgra2); + _mm256_store_si256((__m256i*)(ptr + 12), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 4), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 8), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 12), bgra3); + } +} + +#define OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, const _Tpvec0& c0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int8x32, schar, s8, v_uint8x32, uchar, u8) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int16x16, short, s16, v_uint16x16, ushort, u16) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int32x8, int, s32, v_uint32x8, unsigned, u32) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_float32x8, float, f32, v_uint32x8, unsigned, u32) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int64x4, int64, s64, v_uint64x4, uint64, u64) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_float64x4, double, f64, v_uint64x4, uint64, u64) + +// +// FP16 +// + +inline v_float32x8 v256_load_expand(const float16_t* ptr) +{ +#if CV_FP16 + return v_float32x8(_mm256_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr))); +#else + float CV_DECL_ALIGNED(32) buf[8]; + for (int i = 0; i < 8; i++) + buf[i] = (float)ptr[i]; + return v256_load_aligned(buf); +#endif +} + +inline void v_pack_store(float16_t* ptr, const v_float32x8& a) +{ +#if CV_FP16 + __m128i ah = _mm256_cvtps_ph(a.val, 0); + _mm_storeu_si128((__m128i*)ptr, ah); +#else + float CV_DECL_ALIGNED(32) buf[8]; + v_store_aligned(buf, a); + for (int i = 0; i < 8; i++) + ptr[i] = float16_t(buf[i]); +#endif +} + +// +// end of FP16 +// + +inline void v256_cleanup() { _mm256_zeroall(); } + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: + +#endif // OPENCV_HAL_INTRIN_AVX_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_avx512.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_avx512.hpp new file mode 100644 index 0000000..d20d6dd --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_avx512.hpp @@ -0,0 +1,3090 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_INTRIN_AVX512_HPP +#define OPENCV_HAL_INTRIN_AVX512_HPP + +#if defined(_MSC_VER) && (_MSC_VER < 1920/*MSVS2019*/) +# pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned +# pragma warning(disable:4309) // 'argument': truncation of constant value +# pragma warning(disable:4310) // cast truncates constant value +#endif + +#define CVT_ROUND_MODES_IMPLEMENTED 0 + +#define CV_SIMD512 1 +#define CV_SIMD512_64F 1 +#define CV_SIMD512_FP16 0 // no native operations with FP16 type. Only load/store from float32x8 are available (if CV_FP16 == 1) + +#define _v512_set_epu64(a7, a6, a5, a4, a3, a2, a1, a0) _mm512_set_epi64((int64)(a7),(int64)(a6),(int64)(a5),(int64)(a4),(int64)(a3),(int64)(a2),(int64)(a1),(int64)(a0)) +#define _v512_set_epu32(a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _mm512_set_epi64(((int64)(a15)<<32)|(int64)(a14), ((int64)(a13)<<32)|(int64)(a12), ((int64)(a11)<<32)|(int64)(a10), ((int64)( a9)<<32)|(int64)( a8), \ + ((int64)( a7)<<32)|(int64)( a6), ((int64)( a5)<<32)|(int64)( a4), ((int64)( a3)<<32)|(int64)( a2), ((int64)( a1)<<32)|(int64)( a0)) +#define _v512_set_epu16(a31, a30, a29, a28, a27, a26, a25, a24, a23, a22, a21, a20, a19, a18, a17, a16, \ + a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _v512_set_epu32(((unsigned)(a31)<<16)|(unsigned)(a30), ((unsigned)(a29)<<16)|(unsigned)(a28), ((unsigned)(a27)<<16)|(unsigned)(a26), ((unsigned)(a25)<<16)|(unsigned)(a24), \ + ((unsigned)(a23)<<16)|(unsigned)(a22), ((unsigned)(a21)<<16)|(unsigned)(a20), ((unsigned)(a19)<<16)|(unsigned)(a18), ((unsigned)(a17)<<16)|(unsigned)(a16), \ + ((unsigned)(a15)<<16)|(unsigned)(a14), ((unsigned)(a13)<<16)|(unsigned)(a12), ((unsigned)(a11)<<16)|(unsigned)(a10), ((unsigned)( a9)<<16)|(unsigned)( a8), \ + ((unsigned)( a7)<<16)|(unsigned)( a6), ((unsigned)( a5)<<16)|(unsigned)( a4), ((unsigned)( a3)<<16)|(unsigned)( a2), ((unsigned)( a1)<<16)|(unsigned)( a0)) +#define _v512_set_epu8(a63, a62, a61, a60, a59, a58, a57, a56, a55, a54, a53, a52, a51, a50, a49, a48, \ + a47, a46, a45, a44, a43, a42, a41, a40, a39, a38, a37, a36, a35, a34, a33, a32, \ + a31, a30, a29, a28, a27, a26, a25, a24, a23, a22, a21, a20, a19, a18, a17, a16, \ + a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _v512_set_epu32(((unsigned)(a63)<<24)|((unsigned)(a62)<<16)|((unsigned)(a61)<<8)|(unsigned)(a60),((unsigned)(a59)<<24)|((unsigned)(a58)<<16)|((unsigned)(a57)<<8)|(unsigned)(a56), \ + ((unsigned)(a55)<<24)|((unsigned)(a54)<<16)|((unsigned)(a53)<<8)|(unsigned)(a52),((unsigned)(a51)<<24)|((unsigned)(a50)<<16)|((unsigned)(a49)<<8)|(unsigned)(a48), \ + ((unsigned)(a47)<<24)|((unsigned)(a46)<<16)|((unsigned)(a45)<<8)|(unsigned)(a44),((unsigned)(a43)<<24)|((unsigned)(a42)<<16)|((unsigned)(a41)<<8)|(unsigned)(a40), \ + ((unsigned)(a39)<<24)|((unsigned)(a38)<<16)|((unsigned)(a37)<<8)|(unsigned)(a36),((unsigned)(a35)<<24)|((unsigned)(a34)<<16)|((unsigned)(a33)<<8)|(unsigned)(a32), \ + ((unsigned)(a31)<<24)|((unsigned)(a30)<<16)|((unsigned)(a29)<<8)|(unsigned)(a28),((unsigned)(a27)<<24)|((unsigned)(a26)<<16)|((unsigned)(a25)<<8)|(unsigned)(a24), \ + ((unsigned)(a23)<<24)|((unsigned)(a22)<<16)|((unsigned)(a21)<<8)|(unsigned)(a20),((unsigned)(a19)<<24)|((unsigned)(a18)<<16)|((unsigned)(a17)<<8)|(unsigned)(a16), \ + ((unsigned)(a15)<<24)|((unsigned)(a14)<<16)|((unsigned)(a13)<<8)|(unsigned)(a12),((unsigned)(a11)<<24)|((unsigned)(a10)<<16)|((unsigned)( a9)<<8)|(unsigned)( a8), \ + ((unsigned)( a7)<<24)|((unsigned)( a6)<<16)|((unsigned)( a5)<<8)|(unsigned)( a4),((unsigned)( a3)<<24)|((unsigned)( a2)<<16)|((unsigned)( a1)<<8)|(unsigned)( a0)) +#define _v512_set_epi8(a63, a62, a61, a60, a59, a58, a57, a56, a55, a54, a53, a52, a51, a50, a49, a48, \ + a47, a46, a45, a44, a43, a42, a41, a40, a39, a38, a37, a36, a35, a34, a33, a32, \ + a31, a30, a29, a28, a27, a26, a25, a24, a23, a22, a21, a20, a19, a18, a17, a16, \ + a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _v512_set_epu8((uchar)(a63), (uchar)(a62), (uchar)(a61), (uchar)(a60), (uchar)(a59), (uchar)(a58), (uchar)(a57), (uchar)(a56), \ + (uchar)(a55), (uchar)(a54), (uchar)(a53), (uchar)(a52), (uchar)(a51), (uchar)(a50), (uchar)(a49), (uchar)(a48), \ + (uchar)(a47), (uchar)(a46), (uchar)(a45), (uchar)(a44), (uchar)(a43), (uchar)(a42), (uchar)(a41), (uchar)(a40), \ + (uchar)(a39), (uchar)(a38), (uchar)(a37), (uchar)(a36), (uchar)(a35), (uchar)(a34), (uchar)(a33), (uchar)(a32), \ + (uchar)(a31), (uchar)(a30), (uchar)(a29), (uchar)(a28), (uchar)(a27), (uchar)(a26), (uchar)(a25), (uchar)(a24), \ + (uchar)(a23), (uchar)(a22), (uchar)(a21), (uchar)(a20), (uchar)(a19), (uchar)(a18), (uchar)(a17), (uchar)(a16), \ + (uchar)(a15), (uchar)(a14), (uchar)(a13), (uchar)(a12), (uchar)(a11), (uchar)(a10), (uchar)( a9), (uchar)( a8), \ + (uchar)( a7), (uchar)( a6), (uchar)( a5), (uchar)( a4), (uchar)( a3), (uchar)( a2), (uchar)( a1), (uchar)( a0)) + +#ifndef _mm512_cvtpd_pslo +#ifdef _mm512_zextsi256_si512 +#define _mm512_cvtpd_pslo(a) _mm512_zextps256_ps512(_mm512_cvtpd_ps(a)) +#else +//if preferred way to extend with zeros is unavailable +#define _mm512_cvtpd_pslo(a) _mm512_castps256_ps512(_mm512_cvtpd_ps(a)) +#endif +#endif +///////// Utils //////////// + +namespace +{ + +inline __m512i _v512_combine(const __m256i& lo, const __m256i& hi) +{ return _mm512_inserti32x8(_mm512_castsi256_si512(lo), hi, 1); } + +inline __m512 _v512_combine(const __m256& lo, const __m256& hi) +{ return _mm512_insertf32x8(_mm512_castps256_ps512(lo), hi, 1); } + +inline __m512d _v512_combine(const __m256d& lo, const __m256d& hi) +{ return _mm512_insertf64x4(_mm512_castpd256_pd512(lo), hi, 1); } + +inline int _v_cvtsi512_si32(const __m512i& a) +{ return _mm_cvtsi128_si32(_mm512_castsi512_si128(a)); } + +inline __m256i _v512_extract_high(const __m512i& v) +{ return _mm512_extracti32x8_epi32(v, 1); } + +inline __m256 _v512_extract_high(const __m512& v) +{ return _mm512_extractf32x8_ps(v, 1); } + +inline __m256d _v512_extract_high(const __m512d& v) +{ return _mm512_extractf64x4_pd(v, 1); } + +inline __m256i _v512_extract_low(const __m512i& v) +{ return _mm512_castsi512_si256(v); } + +inline __m256 _v512_extract_low(const __m512& v) +{ return _mm512_castps512_ps256(v); } + +inline __m256d _v512_extract_low(const __m512d& v) +{ return _mm512_castpd512_pd256(v); } + +inline __m512i _v512_insert(const __m512i& a, const __m256i& b) +{ return _mm512_inserti32x8(a, b, 0); } + +inline __m512 _v512_insert(const __m512& a, const __m256& b) +{ return _mm512_insertf32x8(a, b, 0); } + +inline __m512d _v512_insert(const __m512d& a, const __m256d& b) +{ return _mm512_insertf64x4(a, b, 0); } + +} + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Types //////////// + +struct v_uint8x64 +{ + typedef uchar lane_type; + enum { nlanes = 64 }; + __m512i val; + + explicit v_uint8x64(__m512i v) : val(v) {} + v_uint8x64(uchar v0, uchar v1, uchar v2, uchar v3, + uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, + uchar v12, uchar v13, uchar v14, uchar v15, + uchar v16, uchar v17, uchar v18, uchar v19, + uchar v20, uchar v21, uchar v22, uchar v23, + uchar v24, uchar v25, uchar v26, uchar v27, + uchar v28, uchar v29, uchar v30, uchar v31, + uchar v32, uchar v33, uchar v34, uchar v35, + uchar v36, uchar v37, uchar v38, uchar v39, + uchar v40, uchar v41, uchar v42, uchar v43, + uchar v44, uchar v45, uchar v46, uchar v47, + uchar v48, uchar v49, uchar v50, uchar v51, + uchar v52, uchar v53, uchar v54, uchar v55, + uchar v56, uchar v57, uchar v58, uchar v59, + uchar v60, uchar v61, uchar v62, uchar v63) + { + val = _v512_set_epu8(v63, v62, v61, v60, v59, v58, v57, v56, v55, v54, v53, v52, v51, v50, v49, v48, + v47, v46, v45, v44, v43, v42, v41, v40, v39, v38, v37, v36, v35, v34, v33, v32, + v31, v30, v29, v28, v27, v26, v25, v24, v23, v22, v21, v20, v19, v18, v17, v16, + v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0); + } + v_uint8x64() {} + + static inline v_uint8x64 zero() { return v_uint8x64(_mm512_setzero_si512()); } + + uchar get0() const { return (uchar)_v_cvtsi512_si32(val); } +}; + +struct v_int8x64 +{ + typedef schar lane_type; + enum { nlanes = 64 }; + __m512i val; + + explicit v_int8x64(__m512i v) : val(v) {} + v_int8x64(schar v0, schar v1, schar v2, schar v3, + schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, + schar v12, schar v13, schar v14, schar v15, + schar v16, schar v17, schar v18, schar v19, + schar v20, schar v21, schar v22, schar v23, + schar v24, schar v25, schar v26, schar v27, + schar v28, schar v29, schar v30, schar v31, + schar v32, schar v33, schar v34, schar v35, + schar v36, schar v37, schar v38, schar v39, + schar v40, schar v41, schar v42, schar v43, + schar v44, schar v45, schar v46, schar v47, + schar v48, schar v49, schar v50, schar v51, + schar v52, schar v53, schar v54, schar v55, + schar v56, schar v57, schar v58, schar v59, + schar v60, schar v61, schar v62, schar v63) + { + val = _v512_set_epi8(v63, v62, v61, v60, v59, v58, v57, v56, v55, v54, v53, v52, v51, v50, v49, v48, + v47, v46, v45, v44, v43, v42, v41, v40, v39, v38, v37, v36, v35, v34, v33, v32, + v31, v30, v29, v28, v27, v26, v25, v24, v23, v22, v21, v20, v19, v18, v17, v16, + v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0); + } + v_int8x64() {} + + static inline v_int8x64 zero() { return v_int8x64(_mm512_setzero_si512()); } + + schar get0() const { return (schar)_v_cvtsi512_si32(val); } +}; + +struct v_uint16x32 +{ + typedef ushort lane_type; + enum { nlanes = 32 }; + __m512i val; + + explicit v_uint16x32(__m512i v) : val(v) {} + v_uint16x32(ushort v0, ushort v1, ushort v2, ushort v3, + ushort v4, ushort v5, ushort v6, ushort v7, + ushort v8, ushort v9, ushort v10, ushort v11, + ushort v12, ushort v13, ushort v14, ushort v15, + ushort v16, ushort v17, ushort v18, ushort v19, + ushort v20, ushort v21, ushort v22, ushort v23, + ushort v24, ushort v25, ushort v26, ushort v27, + ushort v28, ushort v29, ushort v30, ushort v31) + { + val = _v512_set_epu16(v31, v30, v29, v28, v27, v26, v25, v24, v23, v22, v21, v20, v19, v18, v17, v16, + v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0); + } + v_uint16x32() {} + + static inline v_uint16x32 zero() { return v_uint16x32(_mm512_setzero_si512()); } + + ushort get0() const { return (ushort)_v_cvtsi512_si32(val); } +}; + +struct v_int16x32 +{ + typedef short lane_type; + enum { nlanes = 32 }; + __m512i val; + + explicit v_int16x32(__m512i v) : val(v) {} + v_int16x32(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7, + short v8, short v9, short v10, short v11, short v12, short v13, short v14, short v15, + short v16, short v17, short v18, short v19, short v20, short v21, short v22, short v23, + short v24, short v25, short v26, short v27, short v28, short v29, short v30, short v31) + { + val = _v512_set_epu16((ushort)v31, (ushort)v30, (ushort)v29, (ushort)v28, (ushort)v27, (ushort)v26, (ushort)v25, (ushort)v24, + (ushort)v23, (ushort)v22, (ushort)v21, (ushort)v20, (ushort)v19, (ushort)v18, (ushort)v17, (ushort)v16, + (ushort)v15, (ushort)v14, (ushort)v13, (ushort)v12, (ushort)v11, (ushort)v10, (ushort)v9 , (ushort)v8, + (ushort)v7 , (ushort)v6 , (ushort)v5 , (ushort)v4 , (ushort)v3 , (ushort)v2 , (ushort)v1 , (ushort)v0); + } + v_int16x32() {} + + static inline v_int16x32 zero() { return v_int16x32(_mm512_setzero_si512()); } + + short get0() const { return (short)_v_cvtsi512_si32(val); } +}; + +struct v_uint32x16 +{ + typedef unsigned lane_type; + enum { nlanes = 16 }; + __m512i val; + + explicit v_uint32x16(__m512i v) : val(v) {} + v_uint32x16(unsigned v0, unsigned v1, unsigned v2, unsigned v3, + unsigned v4, unsigned v5, unsigned v6, unsigned v7, + unsigned v8, unsigned v9, unsigned v10, unsigned v11, + unsigned v12, unsigned v13, unsigned v14, unsigned v15) + { + val = _mm512_setr_epi32((int)v0, (int)v1, (int)v2, (int)v3, (int)v4, (int)v5, (int)v6, (int)v7, + (int)v8, (int)v9, (int)v10, (int)v11, (int)v12, (int)v13, (int)v14, (int)v15); + } + v_uint32x16() {} + + static inline v_uint32x16 zero() { return v_uint32x16(_mm512_setzero_si512()); } + + unsigned get0() const { return (unsigned)_v_cvtsi512_si32(val); } +}; + +struct v_int32x16 +{ + typedef int lane_type; + enum { nlanes = 16 }; + __m512i val; + + explicit v_int32x16(__m512i v) : val(v) {} + v_int32x16(int v0, int v1, int v2, int v3, int v4, int v5, int v6, int v7, + int v8, int v9, int v10, int v11, int v12, int v13, int v14, int v15) + { + val = _mm512_setr_epi32(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + v_int32x16() {} + + static inline v_int32x16 zero() { return v_int32x16(_mm512_setzero_si512()); } + + int get0() const { return _v_cvtsi512_si32(val); } +}; + +struct v_float32x16 +{ + typedef float lane_type; + enum { nlanes = 16 }; + __m512 val; + + explicit v_float32x16(__m512 v) : val(v) {} + v_float32x16(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, + float v8, float v9, float v10, float v11, float v12, float v13, float v14, float v15) + { + val = _mm512_setr_ps(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + v_float32x16() {} + + static inline v_float32x16 zero() { return v_float32x16(_mm512_setzero_ps()); } + + float get0() const { return _mm_cvtss_f32(_mm512_castps512_ps128(val)); } +}; + +struct v_uint64x8 +{ + typedef uint64 lane_type; + enum { nlanes = 8 }; + __m512i val; + + explicit v_uint64x8(__m512i v) : val(v) {} + v_uint64x8(uint64 v0, uint64 v1, uint64 v2, uint64 v3, uint64 v4, uint64 v5, uint64 v6, uint64 v7) + { val = _mm512_setr_epi64((int64)v0, (int64)v1, (int64)v2, (int64)v3, (int64)v4, (int64)v5, (int64)v6, (int64)v7); } + v_uint64x8() {} + + static inline v_uint64x8 zero() { return v_uint64x8(_mm512_setzero_si512()); } + + uint64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (uint64)_mm_cvtsi128_si64(_mm512_castsi512_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm512_castsi512_si128(val)); + int b = _mm_cvtsi128_si32(_mm512_castsi512_si128(_mm512_srli_epi64(val, 32))); + return (unsigned)a | ((uint64)(unsigned)b << 32); + #endif + } +}; + +struct v_int64x8 +{ + typedef int64 lane_type; + enum { nlanes = 8 }; + __m512i val; + + explicit v_int64x8(__m512i v) : val(v) {} + v_int64x8(int64 v0, int64 v1, int64 v2, int64 v3, int64 v4, int64 v5, int64 v6, int64 v7) + { val = _mm512_setr_epi64(v0, v1, v2, v3, v4, v5, v6, v7); } + v_int64x8() {} + + static inline v_int64x8 zero() { return v_int64x8(_mm512_setzero_si512()); } + + int64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (int64)_mm_cvtsi128_si64(_mm512_castsi512_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm512_castsi512_si128(val)); + int b = _mm_cvtsi128_si32(_mm512_castsi512_si128(_mm512_srli_epi64(val, 32))); + return (int64)((unsigned)a | ((uint64)(unsigned)b << 32)); + #endif + } +}; + +struct v_float64x8 +{ + typedef double lane_type; + enum { nlanes = 8 }; + __m512d val; + + explicit v_float64x8(__m512d v) : val(v) {} + v_float64x8(double v0, double v1, double v2, double v3, double v4, double v5, double v6, double v7) + { val = _mm512_setr_pd(v0, v1, v2, v3, v4, v5, v6, v7); } + v_float64x8() {} + + static inline v_float64x8 zero() { return v_float64x8(_mm512_setzero_pd()); } + + double get0() const { return _mm_cvtsd_f64(_mm512_castpd512_pd128(val)); } +}; + +//////////////// Load and store operations /////////////// + +#define OPENCV_HAL_IMPL_AVX512_LOADSTORE(_Tpvec, _Tp) \ + inline _Tpvec v512_load(const _Tp* ptr) \ + { return _Tpvec(_mm512_loadu_si512((const __m512i*)ptr)); } \ + inline _Tpvec v512_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm512_load_si512((const __m512i*)ptr)); } \ + inline _Tpvec v512_load_low(const _Tp* ptr) \ + { \ + __m256i v256 = _mm256_loadu_si256((const __m256i*)ptr); \ + return _Tpvec(_mm512_castsi256_si512(v256)); \ + } \ + inline _Tpvec v512_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + __m256i vlo = _mm256_loadu_si256((const __m256i*)ptr0); \ + __m256i vhi = _mm256_loadu_si256((const __m256i*)ptr1); \ + return _Tpvec(_v512_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm512_storeu_si512((__m512i*)ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm512_store_si512((__m512i*)ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm512_stream_si512((__m512i*)ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm512_storeu_si512((__m512i*)ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm512_stream_si512((__m512i*)ptr, a.val); \ + else \ + _mm512_store_si512((__m512i*)ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_si256((__m256i*)ptr, _v512_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_si256((__m256i*)ptr, _v512_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint8x64, uchar) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int8x64, schar) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint16x32, ushort) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int16x32, short) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint32x16, unsigned) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int32x16, int) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint64x8, uint64) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int64x8, int64) + +#define OPENCV_HAL_IMPL_AVX512_LOADSTORE_FLT(_Tpvec, _Tp, suffix, halfreg) \ + inline _Tpvec v512_load(const _Tp* ptr) \ + { return _Tpvec(_mm512_loadu_##suffix(ptr)); } \ + inline _Tpvec v512_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm512_load_##suffix(ptr)); } \ + inline _Tpvec v512_load_low(const _Tp* ptr) \ + { \ + return _Tpvec(_mm512_cast##suffix##256_##suffix##512 \ + (_mm256_loadu_##suffix(ptr))); \ + } \ + inline _Tpvec v512_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + halfreg vlo = _mm256_loadu_##suffix(ptr0); \ + halfreg vhi = _mm256_loadu_##suffix(ptr1); \ + return _Tpvec(_v512_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm512_storeu_##suffix(ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm512_store_##suffix(ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm512_stream_##suffix(ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm512_storeu_##suffix(ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm512_stream_##suffix(ptr, a.val); \ + else \ + _mm512_store_##suffix(ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_##suffix(ptr, _v512_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_##suffix(ptr, _v512_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX512_LOADSTORE_FLT(v_float32x16, float, ps, __m256) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_FLT(v_float64x8, double, pd, __m256d) + +#define OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, _Tpvecf, suffix, cast) \ + inline _Tpvec v_reinterpret_as_##suffix(const _Tpvecf& a) \ + { return _Tpvec(cast(a.val)); } + +#define OPENCV_HAL_IMPL_AVX512_INIT(_Tpvec, _Tp, suffix, ssuffix, ctype_s) \ + inline _Tpvec v512_setzero_##suffix() \ + { return _Tpvec(_mm512_setzero_si512()); } \ + inline _Tpvec v512_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm512_set1_##ssuffix((ctype_s)v)); } \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint8x64, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int8x64, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint16x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int16x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint32x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int32x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint64x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int64x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_float32x16, suffix, _mm512_castps_si512) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_float64x8, suffix, _mm512_castpd_si512) + +OPENCV_HAL_IMPL_AVX512_INIT(v_uint8x64, uchar, u8, epi8, char) +OPENCV_HAL_IMPL_AVX512_INIT(v_int8x64, schar, s8, epi8, char) +OPENCV_HAL_IMPL_AVX512_INIT(v_uint16x32, ushort, u16, epi16, short) +OPENCV_HAL_IMPL_AVX512_INIT(v_int16x32, short, s16, epi16, short) +OPENCV_HAL_IMPL_AVX512_INIT(v_uint32x16, unsigned, u32, epi32, int) +OPENCV_HAL_IMPL_AVX512_INIT(v_int32x16, int, s32, epi32, int) +OPENCV_HAL_IMPL_AVX512_INIT(v_uint64x8, uint64, u64, epi64, int64) +OPENCV_HAL_IMPL_AVX512_INIT(v_int64x8, int64, s64, epi64, int64) + +#define OPENCV_HAL_IMPL_AVX512_INIT_FLT(_Tpvec, _Tp, suffix, zsuffix, cast) \ + inline _Tpvec v512_setzero_##suffix() \ + { return _Tpvec(_mm512_setzero_##zsuffix()); } \ + inline _Tpvec v512_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm512_set1_##zsuffix(v)); } \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint8x64, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int8x64, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint16x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int16x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint32x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int32x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint64x8, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int64x8, suffix, cast) + +OPENCV_HAL_IMPL_AVX512_INIT_FLT(v_float32x16, float, f32, ps, _mm512_castsi512_ps) +OPENCV_HAL_IMPL_AVX512_INIT_FLT(v_float64x8, double, f64, pd, _mm512_castsi512_pd) + +inline v_float32x16 v_reinterpret_as_f32(const v_float32x16& a) +{ return a; } +inline v_float32x16 v_reinterpret_as_f32(const v_float64x8& a) +{ return v_float32x16(_mm512_castpd_ps(a.val)); } + +inline v_float64x8 v_reinterpret_as_f64(const v_float64x8& a) +{ return a; } +inline v_float64x8 v_reinterpret_as_f64(const v_float32x16& a) +{ return v_float64x8(_mm512_castps_pd(a.val)); } + +// FP16 +inline v_float32x16 v512_load_expand(const float16_t* ptr) +{ + return v_float32x16(_mm512_cvtph_ps(_mm256_loadu_si256((const __m256i*)ptr))); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x16& a) +{ + __m256i ah = _mm512_cvtps_ph(a.val, 0); + _mm256_storeu_si256((__m256i*)ptr, ah); +} + +/* Recombine & ZIP */ +inline void v_zip(const v_int8x64& a, const v_int8x64& b, v_int8x64& ab0, v_int8x64& ab1) +{ +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8( 95, 31, 94, 30, 93, 29, 92, 28, 91, 27, 90, 26, 89, 25, 88, 24, + 87, 23, 86, 22, 85, 21, 84, 20, 83, 19, 82, 18, 81, 17, 80, 16, + 79, 15, 78, 14, 77, 13, 76, 12, 75, 11, 74, 10, 73, 9, 72, 8, + 71, 7, 70, 6, 69, 5, 68, 4, 67, 3, 66, 2, 65, 1, 64, 0); + ab0 = v_int8x64(_mm512_permutex2var_epi8(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu8(127, 63, 126, 62, 125, 61, 124, 60, 123, 59, 122, 58, 121, 57, 120, 56, + 119, 55, 118, 54, 117, 53, 116, 52, 115, 51, 114, 50, 113, 49, 112, 48, + 111, 47, 110, 46, 109, 45, 108, 44, 107, 43, 106, 42, 105, 41, 104, 40, + 103, 39, 102, 38, 101, 37, 100, 36, 99, 35, 98, 34, 97, 33, 96, 32); + ab1 = v_int8x64(_mm512_permutex2var_epi8(a.val, mask1, b.val)); +#else + __m512i low = _mm512_unpacklo_epi8(a.val, b.val); + __m512i high = _mm512_unpackhi_epi8(a.val, b.val); + ab0 = v_int8x64(_mm512_permutex2var_epi64(low, _v512_set_epu64(11, 10, 3, 2, 9, 8, 1, 0), high)); + ab1 = v_int8x64(_mm512_permutex2var_epi64(low, _v512_set_epu64(15, 14, 7, 6, 13, 12, 5, 4), high)); +#endif +} +inline void v_zip(const v_int16x32& a, const v_int16x32& b, v_int16x32& ab0, v_int16x32& ab1) +{ + __m512i mask0 = _v512_set_epu16(47, 15, 46, 14, 45, 13, 44, 12, 43, 11, 42, 10, 41, 9, 40, 8, + 39, 7, 38, 6, 37, 5, 36, 4, 35, 3, 34, 2, 33, 1, 32, 0); + ab0 = v_int16x32(_mm512_permutex2var_epi16(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu16(63, 31, 62, 30, 61, 29, 60, 28, 59, 27, 58, 26, 57, 25, 56, 24, + 55, 23, 54, 22, 53, 21, 52, 20, 51, 19, 50, 18, 49, 17, 48, 16); + ab1 = v_int16x32(_mm512_permutex2var_epi16(a.val, mask1, b.val)); +} +inline void v_zip(const v_int32x16& a, const v_int32x16& b, v_int32x16& ab0, v_int32x16& ab1) +{ + __m512i mask0 = _v512_set_epu32(23, 7, 22, 6, 21, 5, 20, 4, 19, 3, 18, 2, 17, 1, 16, 0); + ab0 = v_int32x16(_mm512_permutex2var_epi32(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu32(31, 15, 30, 14, 29, 13, 28, 12, 27, 11, 26, 10, 25, 9, 24, 8); + ab1 = v_int32x16(_mm512_permutex2var_epi32(a.val, mask1, b.val)); +} +inline void v_zip(const v_int64x8& a, const v_int64x8& b, v_int64x8& ab0, v_int64x8& ab1) +{ + __m512i mask0 = _v512_set_epu64(11, 3, 10, 2, 9, 1, 8, 0); + ab0 = v_int64x8(_mm512_permutex2var_epi64(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu64(15, 7, 14, 6, 13, 5, 12, 4); + ab1 = v_int64x8(_mm512_permutex2var_epi64(a.val, mask1, b.val)); +} + +inline void v_zip(const v_uint8x64& a, const v_uint8x64& b, v_uint8x64& ab0, v_uint8x64& ab1) +{ + v_int8x64 i0, i1; + v_zip(v_reinterpret_as_s8(a), v_reinterpret_as_s8(b), i0, i1); + ab0 = v_reinterpret_as_u8(i0); + ab1 = v_reinterpret_as_u8(i1); +} +inline void v_zip(const v_uint16x32& a, const v_uint16x32& b, v_uint16x32& ab0, v_uint16x32& ab1) +{ + v_int16x32 i0, i1; + v_zip(v_reinterpret_as_s16(a), v_reinterpret_as_s16(b), i0, i1); + ab0 = v_reinterpret_as_u16(i0); + ab1 = v_reinterpret_as_u16(i1); +} +inline void v_zip(const v_uint32x16& a, const v_uint32x16& b, v_uint32x16& ab0, v_uint32x16& ab1) +{ + v_int32x16 i0, i1; + v_zip(v_reinterpret_as_s32(a), v_reinterpret_as_s32(b), i0, i1); + ab0 = v_reinterpret_as_u32(i0); + ab1 = v_reinterpret_as_u32(i1); +} +inline void v_zip(const v_uint64x8& a, const v_uint64x8& b, v_uint64x8& ab0, v_uint64x8& ab1) +{ + v_int64x8 i0, i1; + v_zip(v_reinterpret_as_s64(a), v_reinterpret_as_s64(b), i0, i1); + ab0 = v_reinterpret_as_u64(i0); + ab1 = v_reinterpret_as_u64(i1); +} +inline void v_zip(const v_float32x16& a, const v_float32x16& b, v_float32x16& ab0, v_float32x16& ab1) +{ + v_int32x16 i0, i1; + v_zip(v_reinterpret_as_s32(a), v_reinterpret_as_s32(b), i0, i1); + ab0 = v_reinterpret_as_f32(i0); + ab1 = v_reinterpret_as_f32(i1); +} +inline void v_zip(const v_float64x8& a, const v_float64x8& b, v_float64x8& ab0, v_float64x8& ab1) +{ + v_int64x8 i0, i1; + v_zip(v_reinterpret_as_s64(a), v_reinterpret_as_s64(b), i0, i1); + ab0 = v_reinterpret_as_f64(i0); + ab1 = v_reinterpret_as_f64(i1); +} + +#define OPENCV_HAL_IMPL_AVX512_COMBINE(_Tpvec, suffix) \ + inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_v512_combine(_v512_extract_low(a.val), _v512_extract_low(b.val))); } \ + inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_v512_insert(b.val, _v512_extract_high(a.val))); } \ + inline void v_recombine(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ + { \ + c.val = _v512_combine(_v512_extract_low(a.val),_v512_extract_low(b.val)); \ + d.val = _v512_insert(b.val,_v512_extract_high(a.val)); \ + } + + +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint8x64, epi8) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int8x64, epi8) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint16x32, epi16) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int16x32, epi16) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint32x16, epi32) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int32x16, epi32) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint64x8, epi64) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int64x8, epi64) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_float64x8, pd) + +////////// Arithmetic, bitwise and comparison operations ///////// + +/* Element-wise binary and unary operations */ + +/** Non-saturating arithmetics **/ +#define OPENCV_HAL_IMPL_AVX512_BIN_FUNC(func, _Tpvec, intrin) \ + inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_uint8x64, _mm512_add_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_int8x64, _mm512_add_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_uint16x32, _mm512_add_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_int16x32, _mm512_add_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_uint8x64, _mm512_sub_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_int8x64, _mm512_sub_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_uint16x32, _mm512_sub_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_int16x32, _mm512_sub_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_mul_wrap, v_uint16x32, _mm512_mullo_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_mul_wrap, v_int16x32, _mm512_mullo_epi16) + +inline v_uint8x64 v_mul_wrap(const v_uint8x64& a, const v_uint8x64& b) +{ + __m512i ad = _mm512_srai_epi16(a.val, 8); + __m512i bd = _mm512_srai_epi16(b.val, 8); + __m512i p0 = _mm512_mullo_epi16(a.val, b.val); // even + __m512i p1 = _mm512_slli_epi16(_mm512_mullo_epi16(ad, bd), 8); // odd + return v_uint8x64(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, p0, p1)); +} +inline v_int8x64 v_mul_wrap(const v_int8x64& a, const v_int8x64& b) +{ + return v_reinterpret_as_s8(v_mul_wrap(v_reinterpret_as_u8(a), v_reinterpret_as_u8(b))); +} + +#define OPENCV_HAL_IMPL_AVX512_BIN_OP(bin_op, _Tpvec, intrin) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } \ + inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ + { a.val = intrin(a.val, b.val); return a; } + +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint32x16, _mm512_add_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint32x16, _mm512_sub_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int32x16, _mm512_add_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int32x16, _mm512_sub_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint64x8, _mm512_add_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint64x8, _mm512_sub_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int64x8, _mm512_add_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int64x8, _mm512_sub_epi64) + +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_uint32x16, _mm512_mullo_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_int32x16, _mm512_mullo_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_uint64x8, _mm512_mullo_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_int64x8, _mm512_mullo_epi64) + +/** Saturating arithmetics **/ +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint8x64, _mm512_adds_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint8x64, _mm512_subs_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int8x64, _mm512_adds_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int8x64, _mm512_subs_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint16x32, _mm512_adds_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint16x32, _mm512_subs_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int16x32, _mm512_adds_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int16x32, _mm512_subs_epi16) + +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_float32x16, _mm512_add_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_float32x16, _mm512_sub_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_float32x16, _mm512_mul_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(/, v_float32x16, _mm512_div_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_float64x8, _mm512_add_pd) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_float64x8, _mm512_sub_pd) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_float64x8, _mm512_mul_pd) +OPENCV_HAL_IMPL_AVX512_BIN_OP(/, v_float64x8, _mm512_div_pd) + +// saturating multiply +inline v_uint8x64 operator * (const v_uint8x64& a, const v_uint8x64& b) +{ + v_uint16x32 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_int8x64 operator * (const v_int8x64& a, const v_int8x64& b) +{ + v_int16x32 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_uint16x32 operator * (const v_uint16x32& a, const v_uint16x32& b) +{ + __m512i pl = _mm512_mullo_epi16(a.val, b.val); + __m512i ph = _mm512_mulhi_epu16(a.val, b.val); + __m512i p0 = _mm512_unpacklo_epi16(pl, ph); + __m512i p1 = _mm512_unpackhi_epi16(pl, ph); + + const __m512i m = _mm512_set1_epi32(65535); + return v_uint16x32(_mm512_packus_epi32(_mm512_min_epu32(p0, m), _mm512_min_epu32(p1, m))); +} +inline v_int16x32 operator * (const v_int16x32& a, const v_int16x32& b) +{ + __m512i pl = _mm512_mullo_epi16(a.val, b.val); + __m512i ph = _mm512_mulhi_epi16(a.val, b.val); + __m512i p0 = _mm512_unpacklo_epi16(pl, ph); + __m512i p1 = _mm512_unpackhi_epi16(pl, ph); + return v_int16x32(_mm512_packs_epi32(p0, p1)); +} + +inline v_uint8x64& operator *= (v_uint8x64& a, const v_uint8x64& b) +{ a = a * b; return a; } +inline v_int8x64& operator *= (v_int8x64& a, const v_int8x64& b) +{ a = a * b; return a; } +inline v_uint16x32& operator *= (v_uint16x32& a, const v_uint16x32& b) +{ a = a * b; return a; } +inline v_int16x32& operator *= (v_int16x32& a, const v_int16x32& b) +{ a = a * b; return a; } + +inline v_int16x32 v_mul_hi(const v_int16x32& a, const v_int16x32& b) { return v_int16x32(_mm512_mulhi_epi16(a.val, b.val)); } +inline v_uint16x32 v_mul_hi(const v_uint16x32& a, const v_uint16x32& b) { return v_uint16x32(_mm512_mulhi_epu16(a.val, b.val)); } + +// Multiply and expand +inline void v_mul_expand(const v_uint8x64& a, const v_uint8x64& b, + v_uint16x32& c, v_uint16x32& d) +{ + v_uint16x32 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x64& a, const v_int8x64& b, + v_int16x32& c, v_int16x32& d) +{ + v_int16x32 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x32& a, const v_int16x32& b, + v_int32x16& c, v_int32x16& d) +{ + v_int16x32 v0, v1; + v_zip(v_mul_wrap(a, b), v_mul_hi(a, b), v0, v1); + + c = v_reinterpret_as_s32(v0); + d = v_reinterpret_as_s32(v1); +} + +inline void v_mul_expand(const v_uint16x32& a, const v_uint16x32& b, + v_uint32x16& c, v_uint32x16& d) +{ + v_uint16x32 v0, v1; + v_zip(v_mul_wrap(a, b), v_mul_hi(a, b), v0, v1); + + c = v_reinterpret_as_u32(v0); + d = v_reinterpret_as_u32(v1); +} + +inline void v_mul_expand(const v_uint32x16& a, const v_uint32x16& b, + v_uint64x8& c, v_uint64x8& d) +{ + v_zip(v_uint64x8(_mm512_mul_epu32(a.val, b.val)), + v_uint64x8(_mm512_mul_epu32(_mm512_srli_epi64(a.val, 32), _mm512_srli_epi64(b.val, 32))), c, d); +} + +inline void v_mul_expand(const v_int32x16& a, const v_int32x16& b, + v_int64x8& c, v_int64x8& d) +{ + v_zip(v_int64x8(_mm512_mul_epi32(a.val, b.val)), + v_int64x8(_mm512_mul_epi32(_mm512_srli_epi64(a.val, 32), _mm512_srli_epi64(b.val, 32))), c, d); +} + +/** Bitwise shifts **/ +#define OPENCV_HAL_IMPL_AVX512_SHIFT_OP(_Tpuvec, _Tpsvec, suffix) \ + inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm512_slli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ + { return _Tpsvec(_mm512_slli_##suffix(a.val, imm)); } \ + inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm512_srli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ + { return _Tpsvec(_mm512_srai_##suffix(a.val, imm)); } \ + template \ + inline _Tpuvec v_shl(const _Tpuvec& a) \ + { return _Tpuvec(_mm512_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shl(const _Tpsvec& a) \ + { return _Tpsvec(_mm512_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpuvec v_shr(const _Tpuvec& a) \ + { return _Tpuvec(_mm512_srli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shr(const _Tpsvec& a) \ + { return _Tpsvec(_mm512_srai_##suffix(a.val, imm)); } + +OPENCV_HAL_IMPL_AVX512_SHIFT_OP(v_uint16x32, v_int16x32, epi16) +OPENCV_HAL_IMPL_AVX512_SHIFT_OP(v_uint32x16, v_int32x16, epi32) +OPENCV_HAL_IMPL_AVX512_SHIFT_OP(v_uint64x8, v_int64x8, epi64) + + +/** Bitwise logic **/ +#define OPENCV_HAL_IMPL_AVX512_LOGIC_OP(_Tpvec, suffix, not_const) \ + OPENCV_HAL_IMPL_AVX512_BIN_OP(&, _Tpvec, _mm512_and_##suffix) \ + OPENCV_HAL_IMPL_AVX512_BIN_OP(|, _Tpvec, _mm512_or_##suffix) \ + OPENCV_HAL_IMPL_AVX512_BIN_OP(^, _Tpvec, _mm512_xor_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { return _Tpvec(_mm512_xor_##suffix(a.val, not_const)); } + +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint8x64, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int8x64, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint16x32, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int16x32, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint32x16, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int32x16, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint64x8, si512, _mm512_set1_epi64(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int64x8, si512, _mm512_set1_epi64(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_float32x16, ps, _mm512_castsi512_ps(_mm512_set1_epi32(-1))) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_float64x8, pd, _mm512_castsi512_pd(_mm512_set1_epi32(-1))) + +/** Select **/ +#define OPENCV_HAL_IMPL_AVX512_SELECT(_Tpvec, suffix, zsuf) \ + inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm512_mask_blend_##suffix(_mm512_cmp_##suffix##_mask(mask.val, _mm512_setzero_##zsuf(), _MM_CMPINT_EQ), a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint8x64, epi8, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int8x64, epi8, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint16x32, epi16, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int16x32, epi16, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint32x16, epi32, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int32x16, epi32, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint64x8, epi64, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int64x8, epi64, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_float32x16, ps, ps) +OPENCV_HAL_IMPL_AVX512_SELECT(v_float64x8, pd, pd) + +/** Comparison **/ +#define OPENCV_HAL_IMPL_AVX512_CMP_INT(bin_op, imm8, _Tpvec, sufcmp, sufset, tval) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm512_maskz_set1_##sufset(_mm512_cmp_##sufcmp##_mask(a.val, b.val, imm8), tval)); } + +#define OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(_Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(==, _MM_CMPINT_EQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(!=, _MM_CMPINT_NE, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(<, _MM_CMPINT_LT, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(>, _MM_CMPINT_NLE, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(<=, _MM_CMPINT_LE, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(>=, _MM_CMPINT_NLT, _Tpvec, sufcmp, sufset, tval) + +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint8x64, epu8, epi8, (char)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int8x64, epi8, epi8, (char)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint16x32, epu16, epi16, (short)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int16x32, epi16, epi16, (short)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint32x16, epu32, epi32, (int)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int32x16, epi32, epi32, (int)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint64x8, epu64, epi64, (int64)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int64x8, epi64, epi64, (int64)-1) + +#define OPENCV_HAL_IMPL_AVX512_CMP_FLT(bin_op, imm8, _Tpvec, sufcmp, sufset, tval) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm512_castsi512_##sufcmp(_mm512_maskz_set1_##sufset(_mm512_cmp_##sufcmp##_mask(a.val, b.val, imm8), tval))); } + +#define OPENCV_HAL_IMPL_AVX512_CMP_OP_FLT(_Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(==, _CMP_EQ_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(!=, _CMP_NEQ_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(<, _CMP_LT_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(>, _CMP_GT_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(<=, _CMP_LE_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(>=, _CMP_GE_OQ, _Tpvec, sufcmp, sufset, tval) + +OPENCV_HAL_IMPL_AVX512_CMP_OP_FLT(v_float32x16, ps, epi32, (int)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_FLT(v_float64x8, pd, epi64, (int64)-1) + +inline v_float32x16 v_not_nan(const v_float32x16& a) +{ return v_float32x16(_mm512_castsi512_ps(_mm512_maskz_set1_epi32(_mm512_cmp_ps_mask(a.val, a.val, _CMP_ORD_Q), (int)-1))); } +inline v_float64x8 v_not_nan(const v_float64x8& a) +{ return v_float64x8(_mm512_castsi512_pd(_mm512_maskz_set1_epi64(_mm512_cmp_pd_mask(a.val, a.val, _CMP_ORD_Q), (int64)-1))); } + +/** min/max **/ +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint8x64, _mm512_min_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint8x64, _mm512_max_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int8x64, _mm512_min_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int8x64, _mm512_max_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint16x32, _mm512_min_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint16x32, _mm512_max_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int16x32, _mm512_min_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int16x32, _mm512_max_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint32x16, _mm512_min_epu32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint32x16, _mm512_max_epu32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int32x16, _mm512_min_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int32x16, _mm512_max_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint64x8, _mm512_min_epu64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint64x8, _mm512_max_epu64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int64x8, _mm512_min_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int64x8, _mm512_max_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_float32x16, _mm512_min_ps) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_float32x16, _mm512_max_ps) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_float64x8, _mm512_min_pd) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_float64x8, _mm512_max_pd) + +/** Rotate **/ +namespace { + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64&) { return v_int8x64(); }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64& b) + { + return v_int8x64(_mm512_or_si512(_mm512_srli_epi32(_mm512_alignr_epi32(b.val, a.val, imm32 ), imm4 *8), + _mm512_slli_epi32(_mm512_alignr_epi32(b.val, a.val, imm32 + 1), (4-imm4)*8))); + }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64& b) + { + return v_int8x64(_mm512_or_si512(_mm512_srli_epi32(_mm512_alignr_epi32(b.val, a.val, 15), imm4 *8), + _mm512_slli_epi32( b.val, (4-imm4)*8))); + }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) + { + return v_int8x64(_mm512_or_si512(_mm512_srli_epi32(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, imm32 - 16), imm4 *8), + _mm512_slli_epi32(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, imm32 - 15), (4-imm4)*8))); + }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) + { return v_int8x64(_mm512_srli_epi32(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, 15), imm4*8)); }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64& b) + { return v_int8x64(_mm512_alignr_epi32(b.val, a.val, imm32)); }}; + template<> + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64&) { return a; }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) + { return v_int8x64(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, imm32 - 16)); }}; + template<> + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) { return b; }}; + template<> + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64&) { return v_int8x64(); }}; +} +template inline v_int8x64 v_rotate_right(const v_int8x64& a, const v_int8x64& b) +{ + return imm >= 128 ? v_int8x64() : +#if CV_AVX_512VBMI + v_int8x64(_mm512_permutex2var_epi8(a.val, + _v512_set_epu8(0x3f + imm, 0x3e + imm, 0x3d + imm, 0x3c + imm, 0x3b + imm, 0x3a + imm, 0x39 + imm, 0x38 + imm, + 0x37 + imm, 0x36 + imm, 0x35 + imm, 0x34 + imm, 0x33 + imm, 0x32 + imm, 0x31 + imm, 0x30 + imm, + 0x2f + imm, 0x2e + imm, 0x2d + imm, 0x2c + imm, 0x2b + imm, 0x2a + imm, 0x29 + imm, 0x28 + imm, + 0x27 + imm, 0x26 + imm, 0x25 + imm, 0x24 + imm, 0x23 + imm, 0x22 + imm, 0x21 + imm, 0x20 + imm, + 0x1f + imm, 0x1e + imm, 0x1d + imm, 0x1c + imm, 0x1b + imm, 0x1a + imm, 0x19 + imm, 0x18 + imm, + 0x17 + imm, 0x16 + imm, 0x15 + imm, 0x14 + imm, 0x13 + imm, 0x12 + imm, 0x11 + imm, 0x10 + imm, + 0x0f + imm, 0x0e + imm, 0x0d + imm, 0x0c + imm, 0x0b + imm, 0x0a + imm, 0x09 + imm, 0x08 + imm, + 0x07 + imm, 0x06 + imm, 0x05 + imm, 0x04 + imm, 0x03 + imm, 0x02 + imm, 0x01 + imm, 0x00 + imm), b.val)); +#else + _v_rotate_right 15), imm/4>::eval(a, b); +#endif +} +template +inline v_int8x64 v_rotate_left(const v_int8x64& a, const v_int8x64& b) +{ + if (imm == 0) return a; + if (imm == 64) return b; + if (imm >= 128) return v_int8x64(); +#if CV_AVX_512VBMI + return v_int8x64(_mm512_permutex2var_epi8(b.val, + _v512_set_epi8(0x7f - imm,0x7e - imm,0x7d - imm,0x7c - imm,0x7b - imm,0x7a - imm,0x79 - imm,0x78 - imm, + 0x77 - imm,0x76 - imm,0x75 - imm,0x74 - imm,0x73 - imm,0x72 - imm,0x71 - imm,0x70 - imm, + 0x6f - imm,0x6e - imm,0x6d - imm,0x6c - imm,0x6b - imm,0x6a - imm,0x69 - imm,0x68 - imm, + 0x67 - imm,0x66 - imm,0x65 - imm,0x64 - imm,0x63 - imm,0x62 - imm,0x61 - imm,0x60 - imm, + 0x5f - imm,0x5e - imm,0x5d - imm,0x5c - imm,0x5b - imm,0x5a - imm,0x59 - imm,0x58 - imm, + 0x57 - imm,0x56 - imm,0x55 - imm,0x54 - imm,0x53 - imm,0x52 - imm,0x51 - imm,0x50 - imm, + 0x4f - imm,0x4e - imm,0x4d - imm,0x4c - imm,0x4b - imm,0x4a - imm,0x49 - imm,0x48 - imm, + 0x47 - imm,0x46 - imm,0x45 - imm,0x44 - imm,0x43 - imm,0x42 - imm,0x41 - imm,0x40 - imm), a.val)); +#else + return imm < 64 ? v_rotate_right<64 - imm>(b, a) : v_rotate_right<128 - imm>(v512_setzero_s8(), b); +#endif +} +template +inline v_int8x64 v_rotate_right(const v_int8x64& a) +{ + if (imm == 0) return a; + if (imm >= 64) return v_int8x64(); +#if CV_AVX_512VBMI + return v_int8x64(_mm512_maskz_permutexvar_epi8(0xFFFFFFFFFFFFFFFF >> imm, + _v512_set_epu8(0x3f + imm,0x3e + imm,0x3d + imm,0x3c + imm,0x3b + imm,0x3a + imm,0x39 + imm,0x38 + imm, + 0x37 + imm,0x36 + imm,0x35 + imm,0x34 + imm,0x33 + imm,0x32 + imm,0x31 + imm,0x30 + imm, + 0x2f + imm,0x2e + imm,0x2d + imm,0x2c + imm,0x2b + imm,0x2a + imm,0x29 + imm,0x28 + imm, + 0x27 + imm,0x26 + imm,0x25 + imm,0x24 + imm,0x23 + imm,0x22 + imm,0x21 + imm,0x20 + imm, + 0x1f + imm,0x1e + imm,0x1d + imm,0x1c + imm,0x1b + imm,0x1a + imm,0x19 + imm,0x18 + imm, + 0x17 + imm,0x16 + imm,0x15 + imm,0x14 + imm,0x13 + imm,0x12 + imm,0x11 + imm,0x10 + imm, + 0x0f + imm,0x0e + imm,0x0d + imm,0x0c + imm,0x0b + imm,0x0a + imm,0x09 + imm,0x08 + imm, + 0x07 + imm,0x06 + imm,0x05 + imm,0x04 + imm,0x03 + imm,0x02 + imm,0x01 + imm,0x00 + imm), a.val)); +#else + return v_rotate_right(a, v512_setzero_s8()); +#endif +} +template +inline v_int8x64 v_rotate_left(const v_int8x64& a) +{ + if (imm == 0) return a; + if (imm >= 64) return v_int8x64(); +#if CV_AVX_512VBMI + return v_int8x64(_mm512_maskz_permutexvar_epi8(0xFFFFFFFFFFFFFFFF << imm, + _v512_set_epi8(0x3f - imm,0x3e - imm,0x3d - imm,0x3c - imm,0x3b - imm,0x3a - imm,0x39 - imm,0x38 - imm, + 0x37 - imm,0x36 - imm,0x35 - imm,0x34 - imm,0x33 - imm,0x32 - imm,0x31 - imm,0x30 - imm, + 0x2f - imm,0x2e - imm,0x2d - imm,0x2c - imm,0x2b - imm,0x2a - imm,0x29 - imm,0x28 - imm, + 0x27 - imm,0x26 - imm,0x25 - imm,0x24 - imm,0x23 - imm,0x22 - imm,0x21 - imm,0x20 - imm, + 0x1f - imm,0x1e - imm,0x1d - imm,0x1c - imm,0x1b - imm,0x1a - imm,0x19 - imm,0x18 - imm, + 0x17 - imm,0x16 - imm,0x15 - imm,0x14 - imm,0x13 - imm,0x12 - imm,0x11 - imm,0x10 - imm, + 0x0f - imm,0x0e - imm,0x0d - imm,0x0c - imm,0x0b - imm,0x0a - imm,0x09 - imm,0x08 - imm, + 0x07 - imm,0x06 - imm,0x05 - imm,0x04 - imm,0x03 - imm,0x02 - imm,0x01 - imm,0x00 - imm), a.val)); +#else + return v_rotate_right<64 - imm>(v512_setzero_s8(), a); +#endif +} + +#define OPENCV_HAL_IMPL_AVX512_ROTATE_PM(_Tpvec, suffix) \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ return v_reinterpret_as_##suffix(v_rotate_left(v_reinterpret_as_s8(a), v_reinterpret_as_s8(b))); } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ return v_reinterpret_as_##suffix(v_rotate_right(v_reinterpret_as_s8(a), v_reinterpret_as_s8(b))); } \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ return v_reinterpret_as_##suffix(v_rotate_left(v_reinterpret_as_s8(a))); } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ return v_reinterpret_as_##suffix(v_rotate_right(v_reinterpret_as_s8(a))); } + +#define OPENCV_HAL_IMPL_AVX512_ROTATE_EC(_Tpvec, suffix) \ +template \ +inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + enum { SHIFT2 = (_Tpvec::nlanes - imm) }; \ + enum { MASK = ((1 << _Tpvec::nlanes) - 1) }; \ + if (imm == 0) return a; \ + if (imm == _Tpvec::nlanes) return b; \ + if (imm >= 2*_Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_mask_expand_##suffix(_mm512_maskz_compress_##suffix((MASK << SHIFT2)&MASK, b.val), (MASK << (imm))&MASK, a.val)); \ +} \ +template \ +inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + enum { SHIFT2 = (_Tpvec::nlanes - imm) }; \ + enum { MASK = ((1 << _Tpvec::nlanes) - 1) }; \ + if (imm == 0) return a; \ + if (imm == _Tpvec::nlanes) return b; \ + if (imm >= 2*_Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_mask_expand_##suffix(_mm512_maskz_compress_##suffix((MASK << (imm))&MASK, a.val), (MASK << SHIFT2)&MASK, b.val)); \ +} \ +template \ +inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + if (imm == 0) return a; \ + if (imm >= _Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_maskz_expand_##suffix((1 << _Tpvec::nlanes) - (1 << (imm)), a.val)); \ +} \ +template \ +inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + if (imm == 0) return a; \ + if (imm >= _Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_maskz_compress_##suffix((1 << _Tpvec::nlanes) - (1 << (imm)), a.val)); \ +} + +OPENCV_HAL_IMPL_AVX512_ROTATE_PM(v_uint8x64, u8) +OPENCV_HAL_IMPL_AVX512_ROTATE_PM(v_uint16x32, u16) +OPENCV_HAL_IMPL_AVX512_ROTATE_PM(v_int16x32, s16) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_uint32x16, epi32) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_int32x16, epi32) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_uint64x8, epi64) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_int64x8, epi64) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_float64x8, pd) + +/** Reverse **/ +inline v_uint8x64 v_reverse(const v_uint8x64 &a) +{ +#if CV_AVX_512VBMI + static const __m512i perm = _mm512_set_epi32( + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f, + 0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f, + 0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f); + return v_uint8x64(_mm512_permutexvar_epi8(perm, a.val)); +#else + static const __m512i shuf = _mm512_set_epi32( + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f); + static const __m512i perm = _mm512_set_epi64(1, 0, 3, 2, 5, 4, 7, 6); + __m512i vec = _mm512_shuffle_epi8(a.val, shuf); + return v_uint8x64(_mm512_permutexvar_epi64(perm, vec)); +#endif +} + +inline v_int8x64 v_reverse(const v_int8x64 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x32 v_reverse(const v_uint16x32 &a) +{ +#if CV_AVX_512VBMI + static const __m512i perm = _mm512_set_epi32( + 0x00000001, 0x00020003, 0x00040005, 0x00060007, + 0x00080009, 0x000a000b, 0x000c000d, 0x000e000f, + 0x00100011, 0x00120013, 0x00140015, 0x00160017, + 0x00180019, 0x001a001b, 0x001c001d, 0x001e001f); + return v_uint16x32(_mm512_permutexvar_epi16(perm, a.val)); +#else + static const __m512i shuf = _mm512_set_epi32( + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e, + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e, + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e, + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e); + static const __m512i perm = _mm512_set_epi64(1, 0, 3, 2, 5, 4, 7, 6); + __m512i vec = _mm512_shuffle_epi8(a.val, shuf); + return v_uint16x32(_mm512_permutexvar_epi64(perm, vec)); +#endif +} + +inline v_int16x32 v_reverse(const v_int16x32 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x16 v_reverse(const v_uint32x16 &a) +{ + static const __m512i perm = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,14, 15); + return v_uint32x16(_mm512_permutexvar_epi32(perm, a.val)); +} + +inline v_int32x16 v_reverse(const v_int32x16 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x16 v_reverse(const v_float32x16 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x8 v_reverse(const v_uint64x8 &a) +{ + static const __m512i perm = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); + return v_uint64x8(_mm512_permutexvar_epi64(perm, a.val)); +} + +inline v_int64x8 v_reverse(const v_int64x8 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x8 v_reverse(const v_float64x8 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +////////// Reduce ///////// + +/** Reduce **/ +#define OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64(a, b) a + b +#define OPENCV_HAL_IMPL_AVX512_REDUCE_8(sctype, func, _Tpvec, ifunc, scop) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + sctype CV_DECL_ALIGNED(64) idx[2]; \ + _mm_store_si128((__m128i*)idx, _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1))); \ + return scop(idx[0], idx[1]); } +OPENCV_HAL_IMPL_AVX512_REDUCE_8(uint64, min, v_uint64x8, min_epu64, min) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(uint64, max, v_uint64x8, max_epu64, max) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(uint64, sum, v_uint64x8, add_epi64, OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(int64, min, v_int64x8, min_epi64, min) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(int64, max, v_int64x8, max_epi64, max) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(int64, sum, v_int64x8, add_epi64, OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_8F(func, ifunc, scop) \ + inline double v_reduce_##func(const v_float64x8& a) \ + { __m256d half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + double CV_DECL_ALIGNED(64) idx[2]; \ + _mm_store_pd(idx, _mm_##ifunc(_mm256_castpd256_pd128(half), _mm256_extractf128_pd(half, 1))); \ + return scop(idx[0], idx[1]); } +OPENCV_HAL_IMPL_AVX512_REDUCE_8F(min, min_pd, min) +OPENCV_HAL_IMPL_AVX512_REDUCE_8F(max, max_pd, max) +OPENCV_HAL_IMPL_AVX512_REDUCE_8F(sum, add_pd, OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_16(sctype, func, _Tpvec, ifunc) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128i quarter = _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 8)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 4)); \ + return (sctype)_mm_cvtsi128_si32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_16(uint, min, v_uint32x16, min_epu32) +OPENCV_HAL_IMPL_AVX512_REDUCE_16(uint, max, v_uint32x16, max_epu32) +OPENCV_HAL_IMPL_AVX512_REDUCE_16(int, min, v_int32x16, min_epi32) +OPENCV_HAL_IMPL_AVX512_REDUCE_16(int, max, v_int32x16, max_epi32) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_16F(func, ifunc) \ + inline float v_reduce_##func(const v_float32x16& a) \ + { __m256 half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128 quarter = _mm_##ifunc(_mm256_castps256_ps128(half), _mm256_extractf128_ps(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_permute_ps(quarter, _MM_SHUFFLE(0, 0, 3, 2))); \ + quarter = _mm_##ifunc(quarter, _mm_permute_ps(quarter, _MM_SHUFFLE(0, 0, 0, 1))); \ + return _mm_cvtss_f32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_16F(min, min_ps) +OPENCV_HAL_IMPL_AVX512_REDUCE_16F(max, max_ps) + +inline float v_reduce_sum(const v_float32x16& a) +{ + __m256 half = _mm256_add_ps(_v512_extract_low(a.val), _v512_extract_high(a.val)); + __m128 quarter = _mm_add_ps(_mm256_castps256_ps128(half), _mm256_extractf128_ps(half, 1)); + quarter = _mm_hadd_ps(quarter, quarter); + return _mm_cvtss_f32(_mm_hadd_ps(quarter, quarter)); +} +inline int v_reduce_sum(const v_int32x16& a) +{ + __m256i half = _mm256_add_epi32(_v512_extract_low(a.val), _v512_extract_high(a.val)); + __m128i quarter = _mm_add_epi32(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); + quarter = _mm_hadd_epi32(quarter, quarter); + return _mm_cvtsi128_si32(_mm_hadd_epi32(quarter, quarter)); +} +inline uint v_reduce_sum(const v_uint32x16& a) +{ return (uint)v_reduce_sum(v_reinterpret_as_s32(a)); } + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_32(sctype, func, _Tpvec, ifunc) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128i quarter = _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 8)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 4)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 2)); \ + return (sctype)_mm_cvtsi128_si32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_32(ushort, min, v_uint16x32, min_epu16) +OPENCV_HAL_IMPL_AVX512_REDUCE_32(ushort, max, v_uint16x32, max_epu16) +OPENCV_HAL_IMPL_AVX512_REDUCE_32(short, min, v_int16x32, min_epi16) +OPENCV_HAL_IMPL_AVX512_REDUCE_32(short, max, v_int16x32, max_epi16) + +inline int v_reduce_sum(const v_int16x32& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } +inline uint v_reduce_sum(const v_uint16x32& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_64(sctype, func, _Tpvec, ifunc) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128i quarter = _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 8)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 4)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 2)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 1)); \ + return (sctype)_mm_cvtsi128_si32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_64(uchar, min, v_uint8x64, min_epu8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64(uchar, max, v_uint8x64, max_epu8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64(schar, min, v_int8x64, min_epi8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64(schar, max, v_int8x64, max_epi8) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_64_SUM(sctype, _Tpvec, suffix) \ + inline sctype v_reduce_sum(const _Tpvec& a) \ + { __m512i a16 = _mm512_add_epi16(_mm512_cvt##suffix##_epi16(_v512_extract_low(a.val)), \ + _mm512_cvt##suffix##_epi16(_v512_extract_high(a.val))); \ + a16 = _mm512_cvtepi16_epi32(_mm256_add_epi16(_v512_extract_low(a16), _v512_extract_high(a16))); \ + __m256i a8 = _mm256_add_epi32(_v512_extract_low(a16), _v512_extract_high(a16)); \ + __m128i a4 = _mm_add_epi32(_mm256_castsi256_si128(a8), _mm256_extracti128_si256(a8, 1)); \ + a4 = _mm_hadd_epi32(a4, a4); \ + return (sctype)_mm_cvtsi128_si32(_mm_hadd_epi32(a4, a4)); } +OPENCV_HAL_IMPL_AVX512_REDUCE_64_SUM(uint, v_uint8x64, epu8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64_SUM(int, v_int8x64, epi8) + +inline v_float32x16 v_reduce_sum4(const v_float32x16& a, const v_float32x16& b, + const v_float32x16& c, const v_float32x16& d) +{ + __m256 abl = _mm256_hadd_ps(_v512_extract_low(a.val), _v512_extract_low(b.val)); + __m256 abh = _mm256_hadd_ps(_v512_extract_high(a.val), _v512_extract_high(b.val)); + __m256 cdl = _mm256_hadd_ps(_v512_extract_low(c.val), _v512_extract_low(d.val)); + __m256 cdh = _mm256_hadd_ps(_v512_extract_high(c.val), _v512_extract_high(d.val)); + return v_float32x16(_v512_combine(_mm256_hadd_ps(abl, cdl), _mm256_hadd_ps(abh, cdh))); +} + +inline unsigned v_reduce_sad(const v_uint8x64& a, const v_uint8x64& b) +{ + __m512i val = _mm512_sad_epu8(a.val, b.val); + __m256i half = _mm256_add_epi32(_v512_extract_low(val), _v512_extract_high(val)); + __m128i quarter = _mm_add_epi32(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_int8x64& a, const v_int8x64& b) +{ + __m512i val = _mm512_set1_epi8(-128); + val = _mm512_sad_epu8(_mm512_add_epi8(a.val, val), _mm512_add_epi8(b.val, val)); + __m256i half = _mm256_add_epi32(_v512_extract_low(val), _v512_extract_high(val)); + __m128i quarter = _mm_add_epi32(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_uint16x32& a, const v_uint16x32& b) +{ return v_reduce_sum(v_add_wrap(a - b, b - a)); } +inline unsigned v_reduce_sad(const v_int16x32& a, const v_int16x32& b) +{ return v_reduce_sum(v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b)))); } +inline unsigned v_reduce_sad(const v_uint32x16& a, const v_uint32x16& b) +{ return v_reduce_sum(v_max(a, b) - v_min(a, b)); } +inline unsigned v_reduce_sad(const v_int32x16& a, const v_int32x16& b) +{ return v_reduce_sum(v_reinterpret_as_u32(v_max(a, b) - v_min(a, b))); } +inline float v_reduce_sad(const v_float32x16& a, const v_float32x16& b) +{ return v_reduce_sum((a - b) & v_float32x16(_mm512_castsi512_ps(_mm512_set1_epi32(0x7fffffff)))); } +inline double v_reduce_sad(const v_float64x8& a, const v_float64x8& b) +{ return v_reduce_sum((a - b) & v_float64x8(_mm512_castsi512_pd(_mm512_set1_epi64(0x7fffffffffffffff)))); } + +/** Popcount **/ +inline v_uint8x64 v_popcount(const v_int8x64& a) +{ +#if CV_AVX_512BITALG + return v_uint8x64(_mm512_popcnt_epi8(a.val)); +#elif CV_AVX_512VBMI + __m512i _popcnt_table0 = _v512_set_epu8(7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3, + 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1, + 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1, + 4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0); + __m512i _popcnt_table1 = _v512_set_epu8(7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3, + 6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, + 6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, + 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1); + return v_uint8x64(_mm512_sub_epi8(_mm512_permutex2var_epi8(_popcnt_table0, a.val, _popcnt_table1), _mm512_movm_epi8(_mm512_movepi8_mask(a.val)))); +#else + __m512i _popcnt_table = _mm512_set4_epi32(0x04030302, 0x03020201, 0x03020201, 0x02010100); + __m512i _popcnt_mask = _mm512_set1_epi8(0x0F); + + return v_uint8x64(_mm512_add_epi8(_mm512_shuffle_epi8(_popcnt_table, _mm512_and_si512( a.val, _popcnt_mask)), + _mm512_shuffle_epi8(_popcnt_table, _mm512_and_si512(_mm512_srli_epi16(a.val, 4), _popcnt_mask)))); +#endif +} +inline v_uint16x32 v_popcount(const v_int16x32& a) +{ +#if CV_AVX_512BITALG + return v_uint16x32(_mm512_popcnt_epi16(a.val)); +#elif CV_AVX_512VPOPCNTDQ + __m512i zero = _mm512_setzero_si512(); + return v_uint16x32(_mm512_packs_epi32(_mm512_popcnt_epi32(_mm512_unpacklo_epi16(a.val, zero)), + _mm512_popcnt_epi32(_mm512_unpackhi_epi16(a.val, zero)))); +#else + v_uint8x64 p = v_popcount(v_reinterpret_as_s8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v512_setall_u16(0x00ff); +#endif +} +inline v_uint32x16 v_popcount(const v_int32x16& a) +{ +#if CV_AVX_512VPOPCNTDQ + return v_uint32x16(_mm512_popcnt_epi32(a.val)); +#else + v_uint8x64 p = v_popcount(v_reinterpret_as_s8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v512_setall_u32(0x000000ff); +#endif +} +inline v_uint64x8 v_popcount(const v_int64x8& a) +{ +#if CV_AVX_512VPOPCNTDQ + return v_uint64x8(_mm512_popcnt_epi64(a.val)); +#else + return v_uint64x8(_mm512_sad_epu8(v_popcount(v_reinterpret_as_s8(a)).val, _mm512_setzero_si512())); +#endif +} + + +inline v_uint8x64 v_popcount(const v_uint8x64& a) { return v_popcount(v_reinterpret_as_s8 (a)); } +inline v_uint16x32 v_popcount(const v_uint16x32& a) { return v_popcount(v_reinterpret_as_s16(a)); } +inline v_uint32x16 v_popcount(const v_uint32x16& a) { return v_popcount(v_reinterpret_as_s32(a)); } +inline v_uint64x8 v_popcount(const v_uint64x8& a) { return v_popcount(v_reinterpret_as_s64(a)); } + + +////////// Other math ///////// + +/** Some frequent operations **/ +#if CV_FMA3 +#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } +#else +#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } +#endif + +#define OPENCV_HAL_IMPL_AVX512_MISC(_Tpvec, suffix) \ + inline _Tpvec v_sqrt(const _Tpvec& x) \ + { return _Tpvec(_mm512_sqrt_##suffix(x.val)); } \ + inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_fma(a, a, b * b); } \ + inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_sqrt(v_fma(a, a, b * b)); } + +OPENCV_HAL_IMPL_AVX512_MULADD(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_MULADD(v_float64x8, pd) +OPENCV_HAL_IMPL_AVX512_MISC(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_MISC(v_float64x8, pd) + +inline v_int32x16 v_fma(const v_int32x16& a, const v_int32x16& b, const v_int32x16& c) +{ return a * b + c; } +inline v_int32x16 v_muladd(const v_int32x16& a, const v_int32x16& b, const v_int32x16& c) +{ return v_fma(a, b, c); } + +inline v_float32x16 v_invsqrt(const v_float32x16& x) +{ +#if CV_AVX_512ER + return v_float32x16(_mm512_rsqrt28_ps(x.val)); +#else + v_float32x16 half = x * v512_setall_f32(0.5); + v_float32x16 t = v_float32x16(_mm512_rsqrt14_ps(x.val)); + t *= v512_setall_f32(1.5) - ((t * t) * half); + return t; +#endif +} + +inline v_float64x8 v_invsqrt(const v_float64x8& x) +{ +#if CV_AVX_512ER + return v_float64x8(_mm512_rsqrt28_pd(x.val)); +#else + return v512_setall_f64(1.) / v_sqrt(x); +// v_float64x8 half = x * v512_setall_f64(0.5); +// v_float64x8 t = v_float64x8(_mm512_rsqrt14_pd(x.val)); +// t *= v512_setall_f64(1.5) - ((t * t) * half); +// t *= v512_setall_f64(1.5) - ((t * t) * half); +// return t; +#endif +} + +/** Absolute values **/ +#define OPENCV_HAL_IMPL_AVX512_ABS(_Tpvec, _Tpuvec, suffix) \ + inline _Tpuvec v_abs(const _Tpvec& x) \ + { return _Tpuvec(_mm512_abs_##suffix(x.val)); } + +OPENCV_HAL_IMPL_AVX512_ABS(v_int8x64, v_uint8x64, epi8) +OPENCV_HAL_IMPL_AVX512_ABS(v_int16x32, v_uint16x32, epi16) +OPENCV_HAL_IMPL_AVX512_ABS(v_int32x16, v_uint32x16, epi32) +OPENCV_HAL_IMPL_AVX512_ABS(v_int64x8, v_uint64x8, epi64) + +inline v_float32x16 v_abs(const v_float32x16& x) +{ +#ifdef _mm512_abs_pd + return v_float32x16(_mm512_abs_ps(x.val)); +#else + return v_float32x16(_mm512_castsi512_ps(_mm512_and_si512(_mm512_castps_si512(x.val), + _v512_set_epu64(0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, + 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF)))); +#endif +} + +inline v_float64x8 v_abs(const v_float64x8& x) +{ +#ifdef _mm512_abs_pd + #if defined __GNUC__ && (__GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ <= 3) || (__GNUC__ == 8 && __GNUC_MINOR__ <= 2)) + // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87476 + return v_float64x8(_mm512_abs_pd(_mm512_castpd_ps(x.val))); + #else + return v_float64x8(_mm512_abs_pd(x.val)); + #endif +#else + return v_float64x8(_mm512_castsi512_pd(_mm512_and_si512(_mm512_castpd_si512(x.val), + _v512_set_epu64(0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, + 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF)))); +#endif +} + +/** Absolute difference **/ +inline v_uint8x64 v_absdiff(const v_uint8x64& a, const v_uint8x64& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x32 v_absdiff(const v_uint16x32& a, const v_uint16x32& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x16 v_absdiff(const v_uint32x16& a, const v_uint32x16& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x64 v_absdiff(const v_int8x64& a, const v_int8x64& b) +{ + v_int8x64 d = v_sub_wrap(a, b); + v_int8x64 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} + +inline v_uint16x32 v_absdiff(const v_int16x32& a, const v_int16x32& b) +{ return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); } + +inline v_uint32x16 v_absdiff(const v_int32x16& a, const v_int32x16& b) +{ + v_int32x16 d = a - b; + v_int32x16 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +inline v_float32x16 v_absdiff(const v_float32x16& a, const v_float32x16& b) +{ return v_abs(a - b); } + +inline v_float64x8 v_absdiff(const v_float64x8& a, const v_float64x8& b) +{ return v_abs(a - b); } + +/** Saturating absolute difference **/ +inline v_int8x64 v_absdiffs(const v_int8x64& a, const v_int8x64& b) +{ + v_int8x64 d = a - b; + v_int8x64 m = a < b; + return (d ^ m) - m; +} +inline v_int16x32 v_absdiffs(const v_int16x32& a, const v_int16x32& b) +{ return v_max(a, b) - v_min(a, b); } + +////////// Conversions ///////// + +/** Rounding **/ +inline v_int32x16 v_round(const v_float32x16& a) +{ return v_int32x16(_mm512_cvtps_epi32(a.val)); } + +inline v_int32x16 v_round(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvtpd_epi32(a.val))); } + +inline v_int32x16 v_round(const v_float64x8& a, const v_float64x8& b) +{ return v_int32x16(_v512_combine(_mm512_cvtpd_epi32(a.val), _mm512_cvtpd_epi32(b.val))); } + +inline v_int32x16 v_trunc(const v_float32x16& a) +{ return v_int32x16(_mm512_cvttps_epi32(a.val)); } + +inline v_int32x16 v_trunc(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvttpd_epi32(a.val))); } + +#if CVT_ROUND_MODES_IMPLEMENTED +inline v_int32x16 v_floor(const v_float32x16& a) +{ return v_int32x16(_mm512_cvt_roundps_epi32(a.val, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)); } + +inline v_int32x16 v_floor(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvt_roundpd_epi32(a.val, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC))); } + +inline v_int32x16 v_ceil(const v_float32x16& a) +{ return v_int32x16(_mm512_cvt_roundps_epi32(a.val, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)); } + +inline v_int32x16 v_ceil(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvt_roundpd_epi32(a.val, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC))); } +#else +inline v_int32x16 v_floor(const v_float32x16& a) +{ return v_int32x16(_mm512_cvtps_epi32(_mm512_roundscale_ps(a.val, 1))); } + +inline v_int32x16 v_floor(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvtpd_epi32(_mm512_roundscale_pd(a.val, 1)))); } + +inline v_int32x16 v_ceil(const v_float32x16& a) +{ return v_int32x16(_mm512_cvtps_epi32(_mm512_roundscale_ps(a.val, 2))); } + +inline v_int32x16 v_ceil(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvtpd_epi32(_mm512_roundscale_pd(a.val, 2)))); } +#endif + +/** To float **/ +inline v_float32x16 v_cvt_f32(const v_int32x16& a) +{ return v_float32x16(_mm512_cvtepi32_ps(a.val)); } + +inline v_float32x16 v_cvt_f32(const v_float64x8& a) +{ return v_float32x16(_mm512_cvtpd_pslo(a.val)); } + +inline v_float32x16 v_cvt_f32(const v_float64x8& a, const v_float64x8& b) +{ return v_float32x16(_v512_combine(_mm512_cvtpd_ps(a.val), _mm512_cvtpd_ps(b.val))); } + +inline v_float64x8 v_cvt_f64(const v_int32x16& a) +{ return v_float64x8(_mm512_cvtepi32_pd(_v512_extract_low(a.val))); } + +inline v_float64x8 v_cvt_f64_high(const v_int32x16& a) +{ return v_float64x8(_mm512_cvtepi32_pd(_v512_extract_high(a.val))); } + +inline v_float64x8 v_cvt_f64(const v_float32x16& a) +{ return v_float64x8(_mm512_cvtps_pd(_v512_extract_low(a.val))); } + +inline v_float64x8 v_cvt_f64_high(const v_float32x16& a) +{ return v_float64x8(_mm512_cvtps_pd(_v512_extract_high(a.val))); } + +// from (Mysticial and wim) https://stackoverflow.com/q/41144668 +inline v_float64x8 v_cvt_f64(const v_int64x8& v) +{ +#if CV_AVX_512DQ + return v_float64x8(_mm512_cvtepi64_pd(v.val)); +#else + // constants encoded as floating-point + __m512i magic_i_lo = _mm512_set1_epi64(0x4330000000000000); // 2^52 + __m512i magic_i_hi32 = _mm512_set1_epi64(0x4530000080000000); // 2^84 + 2^63 + __m512i magic_i_all = _mm512_set1_epi64(0x4530000080100000); // 2^84 + 2^63 + 2^52 + __m512d magic_d_all = _mm512_castsi512_pd(magic_i_all); + + // Blend the 32 lowest significant bits of v with magic_int_lo + __m512i v_lo = _mm512_mask_blend_epi32(0x5555, magic_i_lo, v.val); + // Extract the 32 most significant bits of v + __m512i v_hi = _mm512_srli_epi64(v.val, 32); + // Flip the msb of v_hi and blend with 0x45300000 + v_hi = _mm512_xor_si512(v_hi, magic_i_hi32); + // Compute in double precision + __m512d v_hi_dbl = _mm512_sub_pd(_mm512_castsi512_pd(v_hi), magic_d_all); + // (v_hi - magic_d_all) + v_lo Do not assume associativity of floating point addition + __m512d result = _mm512_add_pd(v_hi_dbl, _mm512_castsi512_pd(v_lo)); + return v_float64x8(result); +#endif +} + +////////////// Lookup table access //////////////////// + +inline v_int8x64 v512_lut(const schar* tab, const int* idx) +{ + __m128i p0 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx ), (const int *)tab, 1)); + __m128i p1 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 1), (const int *)tab, 1)); + __m128i p2 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 2), (const int *)tab, 1)); + __m128i p3 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 3), (const int *)tab, 1)); + return v_int8x64(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_castsi128_si512(p0), p1, 1), p2, 2), p3, 3)); +} +inline v_int8x64 v512_lut_pairs(const schar* tab, const int* idx) +{ + __m256i p0 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx ), (const int *)tab, 1)); + __m256i p1 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 1), (const int *)tab, 1)); + return v_int8x64(_v512_combine(p0, p1)); +} +inline v_int8x64 v512_lut_quads(const schar* tab, const int* idx) +{ + return v_int8x64(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx), (const int *)tab, 1)); +} +inline v_uint8x64 v512_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v512_lut((const schar *)tab, idx)); } +inline v_uint8x64 v512_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v512_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x64 v512_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v512_lut_quads((const schar *)tab, idx)); } + +inline v_int16x32 v512_lut(const short* tab, const int* idx) +{ + __m256i p0 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx ), (const int *)tab, 2)); + __m256i p1 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 1), (const int *)tab, 2)); + return v_int16x32(_v512_combine(p0, p1)); +} +inline v_int16x32 v512_lut_pairs(const short* tab, const int* idx) +{ + return v_int16x32(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx), (const int *)tab, 2)); +} +inline v_int16x32 v512_lut_quads(const short* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int16x32(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const long long int*)tab, 2)); +#else + return v_int16x32(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const int64*)tab, 2)); +#endif +} +inline v_uint16x32 v512_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v512_lut((const short *)tab, idx)); } +inline v_uint16x32 v512_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v512_lut_pairs((const short *)tab, idx)); } +inline v_uint16x32 v512_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v512_lut_quads((const short *)tab, idx)); } + +inline v_int32x16 v512_lut(const int* tab, const int* idx) +{ + return v_int32x16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx), tab, 4)); +} +inline v_int32x16 v512_lut_pairs(const int* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int32x16(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const long long int*)tab, 4)); +#else + return v_int32x16(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const int64*)tab, 4)); +#endif +} +inline v_int32x16 v512_lut_quads(const int* tab, const int* idx) +{ + return v_int32x16(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_castsi128_si512( + _mm_loadu_si128((const __m128i*)(tab + idx[0]))), + _mm_loadu_si128((const __m128i*)(tab + idx[1])), 1), + _mm_loadu_si128((const __m128i*)(tab + idx[2])), 2), + _mm_loadu_si128((const __m128i*)(tab + idx[3])), 3)); +} +inline v_uint32x16 v512_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v512_lut((const int *)tab, idx)); } +inline v_uint32x16 v512_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v512_lut_pairs((const int *)tab, idx)); } +inline v_uint32x16 v512_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v512_lut_quads((const int *)tab, idx)); } + +inline v_int64x8 v512_lut(const int64* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int64x8(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const long long int*)tab, 8)); +#else + return v_int64x8(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), tab , 8)); +#endif +} +inline v_int64x8 v512_lut_pairs(const int64* tab, const int* idx) +{ + return v_int64x8(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_castsi128_si512( + _mm_loadu_si128((const __m128i*)(tab + idx[0]))), + _mm_loadu_si128((const __m128i*)(tab + idx[1])), 1), + _mm_loadu_si128((const __m128i*)(tab + idx[2])), 2), + _mm_loadu_si128((const __m128i*)(tab + idx[3])), 3)); +} +inline v_uint64x8 v512_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v512_lut((const int64 *)tab, idx)); } +inline v_uint64x8 v512_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v512_lut_pairs((const int64 *)tab, idx)); } + +inline v_float32x16 v512_lut(const float* tab, const int* idx) +{ + return v_float32x16(_mm512_i32gather_ps(_mm512_loadu_si512((const __m512i*)idx), tab, 4)); +} +inline v_float32x16 v512_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v512_lut_pairs((const int *)tab, idx)); } +inline v_float32x16 v512_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v512_lut_quads((const int *)tab, idx)); } + +inline v_float64x8 v512_lut(const double* tab, const int* idx) +{ + return v_float64x8(_mm512_i32gather_pd(_mm256_loadu_si256((const __m256i*)idx), tab, 8)); +} +inline v_float64x8 v512_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x8(_mm512_insertf64x2(_mm512_insertf64x2(_mm512_insertf64x2(_mm512_castpd128_pd512( + _mm_loadu_pd(tab + idx[0])), + _mm_loadu_pd(tab + idx[1]), 1), + _mm_loadu_pd(tab + idx[2]), 2), + _mm_loadu_pd(tab + idx[3]), 3)); +} + +inline v_int32x16 v_lut(const int* tab, const v_int32x16& idxvec) +{ + return v_int32x16(_mm512_i32gather_epi32(idxvec.val, tab, 4)); +} + +inline v_uint32x16 v_lut(const unsigned* tab, const v_int32x16& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x16 v_lut(const float* tab, const v_int32x16& idxvec) +{ + return v_float32x16(_mm512_i32gather_ps(idxvec.val, tab, 4)); +} + +inline v_float64x8 v_lut(const double* tab, const v_int32x16& idxvec) +{ + return v_float64x8(_mm512_i32gather_pd(_v512_extract_low(idxvec.val), tab, 8)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x16& idxvec, v_float32x16& x, v_float32x16& y) +{ + x.val = _mm512_i32gather_ps(idxvec.val, tab, 4); + y.val = _mm512_i32gather_ps(idxvec.val, &tab[1], 4); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x16& idxvec, v_float64x8& x, v_float64x8& y) +{ + x.val = _mm512_i32gather_pd(_v512_extract_low(idxvec.val), tab, 8); + y.val = _mm512_i32gather_pd(_v512_extract_low(idxvec.val), &tab[1], 8); +} + +inline v_int8x64 v_interleave_pairs(const v_int8x64& vec) +{ + return v_int8x64(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0d0e0c, 0x0b090a08, 0x07050604, 0x03010200))); +} +inline v_uint8x64 v_interleave_pairs(const v_uint8x64& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x64 v_interleave_quads(const v_int8x64& vec) +{ + return v_int8x64(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0b0e0a, 0x0d090c08, 0x07030602, 0x05010400))); +} +inline v_uint8x64 v_interleave_quads(const v_uint8x64& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x32 v_interleave_pairs(const v_int16x32& vec) +{ + return v_int16x32(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0e0b0a, 0x0d0c0908, 0x07060302, 0x05040100))); +} +inline v_uint16x32 v_interleave_pairs(const v_uint16x32& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x32 v_interleave_quads(const v_int16x32& vec) +{ + return v_int16x32(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0e0706, 0x0d0c0504, 0x0b0a0302, 0x09080100))); +} +inline v_uint16x32 v_interleave_quads(const v_uint16x32& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x16 v_interleave_pairs(const v_int32x16& vec) +{ + return v_int32x16(_mm512_shuffle_epi32(vec.val, _MM_PERM_ACBD)); +} +inline v_uint32x16 v_interleave_pairs(const v_uint32x16& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x16 v_interleave_pairs(const v_float32x16& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x64 v_pack_triplets(const v_int8x64& vec) +{ + return v_int8x64(_mm512_permutexvar_epi32(_v512_set_epu64(0x0000000f0000000f, 0x0000000f0000000f, 0x0000000e0000000d, 0x0000000c0000000a, + 0x0000000900000008, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000), + _mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0xffffff0f, 0x0e0d0c0a, 0x09080605, 0x04020100)))); +} +inline v_uint8x64 v_pack_triplets(const v_uint8x64& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x32 v_pack_triplets(const v_int16x32& vec) +{ + return v_int16x32(_mm512_permutexvar_epi16(_v512_set_epu64(0x001f001f001f001f, 0x001f001f001f001f, 0x001e001d001c001a, 0x0019001800160015, + 0x0014001200110010, 0x000e000d000c000a, 0x0009000800060005, 0x0004000200010000), vec.val)); +} +inline v_uint16x32 v_pack_triplets(const v_uint16x32& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x16 v_pack_triplets(const v_int32x16& vec) +{ + return v_int32x16(_mm512_permutexvar_epi32(_v512_set_epu64(0x0000000f0000000f, 0x0000000f0000000f, 0x0000000e0000000d, 0x0000000c0000000a, + 0x0000000900000008, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000), vec.val)); +} +inline v_uint32x16 v_pack_triplets(const v_uint32x16& vec) { return v_reinterpret_as_u32(v_pack_triplets(v_reinterpret_as_s32(vec))); } +inline v_float32x16 v_pack_triplets(const v_float32x16& vec) +{ + return v_float32x16(_mm512_permutexvar_ps(_v512_set_epu64(0x0000000f0000000f, 0x0000000f0000000f, 0x0000000e0000000d, 0x0000000c0000000a, + 0x0000000900000008, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000), vec.val)); +} + +////////// Matrix operations ///////// + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x16 v_dotprod(const v_int16x32& a, const v_int16x32& b) +{ return v_int32x16(_mm512_madd_epi16(a.val, b.val)); } +inline v_int32x16 v_dotprod(const v_int16x32& a, const v_int16x32& b, const v_int32x16& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x8 v_dotprod(const v_int32x16& a, const v_int32x16& b) +{ + __m512i even = _mm512_mul_epi32(a.val, b.val); + __m512i odd = _mm512_mul_epi32(_mm512_srli_epi64(a.val, 32), _mm512_srli_epi64(b.val, 32)); + return v_int64x8(_mm512_add_epi64(even, odd)); +} +inline v_int64x8 v_dotprod(const v_int32x16& a, const v_int32x16& b, const v_int64x8& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x16 v_dotprod_expand(const v_uint8x64& a, const v_uint8x64& b) +{ + __m512i even_a = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, a.val, _mm512_setzero_si512()); + __m512i odd_a = _mm512_srli_epi16(a.val, 8); + + __m512i even_b = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, b.val, _mm512_setzero_si512()); + __m512i odd_b = _mm512_srli_epi16(b.val, 8); + + __m512i prod0 = _mm512_madd_epi16(even_a, even_b); + __m512i prod1 = _mm512_madd_epi16(odd_a, odd_b); + return v_uint32x16(_mm512_add_epi32(prod0, prod1)); +} +inline v_uint32x16 v_dotprod_expand(const v_uint8x64& a, const v_uint8x64& b, const v_uint32x16& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x16 v_dotprod_expand(const v_int8x64& a, const v_int8x64& b) +{ + __m512i even_a = _mm512_srai_epi16(_mm512_bslli_epi128(a.val, 1), 8); + __m512i odd_a = _mm512_srai_epi16(a.val, 8); + + __m512i even_b = _mm512_srai_epi16(_mm512_bslli_epi128(b.val, 1), 8); + __m512i odd_b = _mm512_srai_epi16(b.val, 8); + + __m512i prod0 = _mm512_madd_epi16(even_a, even_b); + __m512i prod1 = _mm512_madd_epi16(odd_a, odd_b); + return v_int32x16(_mm512_add_epi32(prod0, prod1)); +} +inline v_int32x16 v_dotprod_expand(const v_int8x64& a, const v_int8x64& b, const v_int32x16& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x8 v_dotprod_expand(const v_uint16x32& a, const v_uint16x32& b) +{ + __m512i mullo = _mm512_mullo_epi16(a.val, b.val); + __m512i mulhi = _mm512_mulhi_epu16(a.val, b.val); + __m512i mul0 = _mm512_unpacklo_epi16(mullo, mulhi); + __m512i mul1 = _mm512_unpackhi_epi16(mullo, mulhi); + + __m512i p02 = _mm512_mask_blend_epi32(0xAAAA, mul0, _mm512_setzero_si512()); + __m512i p13 = _mm512_srli_epi64(mul0, 32); + __m512i p46 = _mm512_mask_blend_epi32(0xAAAA, mul1, _mm512_setzero_si512()); + __m512i p57 = _mm512_srli_epi64(mul1, 32); + + __m512i p15_ = _mm512_add_epi64(p02, p13); + __m512i p9d_ = _mm512_add_epi64(p46, p57); + + return v_uint64x8(_mm512_add_epi64( + _mm512_unpacklo_epi64(p15_, p9d_), + _mm512_unpackhi_epi64(p15_, p9d_) + )); +} +inline v_uint64x8 v_dotprod_expand(const v_uint16x32& a, const v_uint16x32& b, const v_uint64x8& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x8 v_dotprod_expand(const v_int16x32& a, const v_int16x32& b) +{ + __m512i prod = _mm512_madd_epi16(a.val, b.val); + __m512i even = _mm512_srai_epi64(_mm512_bslli_epi128(prod, 4), 32); + __m512i odd = _mm512_srai_epi64(prod, 32); + return v_int64x8(_mm512_add_epi64(even, odd)); +} +inline v_int64x8 v_dotprod_expand(const v_int16x32& a, const v_int16x32& b, const v_int64x8& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x8 v_dotprod_expand(const v_int32x16& a, const v_int32x16& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x8 v_dotprod_expand(const v_int32x16& a, const v_int32x16& b, const v_float64x8& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x16 v_dotprod_fast(const v_int16x32& a, const v_int16x32& b) +{ return v_dotprod(a, b); } +inline v_int32x16 v_dotprod_fast(const v_int16x32& a, const v_int16x32& b, const v_int32x16& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x8 v_dotprod_fast(const v_int32x16& a, const v_int32x16& b) +{ return v_dotprod(a, b); } +inline v_int64x8 v_dotprod_fast(const v_int32x16& a, const v_int32x16& b, const v_int64x8& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x16 v_dotprod_expand_fast(const v_uint8x64& a, const v_uint8x64& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x16 v_dotprod_expand_fast(const v_uint8x64& a, const v_uint8x64& b, const v_uint32x16& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_int32x16 v_dotprod_expand_fast(const v_int8x64& a, const v_int8x64& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x16 v_dotprod_expand_fast(const v_int8x64& a, const v_int8x64& b, const v_int32x16& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x8 v_dotprod_expand_fast(const v_uint16x32& a, const v_uint16x32& b) +{ + __m512i mullo = _mm512_mullo_epi16(a.val, b.val); + __m512i mulhi = _mm512_mulhi_epu16(a.val, b.val); + __m512i mul0 = _mm512_unpacklo_epi16(mullo, mulhi); + __m512i mul1 = _mm512_unpackhi_epi16(mullo, mulhi); + + __m512i p02 = _mm512_mask_blend_epi32(0xAAAA, mul0, _mm512_setzero_si512()); + __m512i p13 = _mm512_srli_epi64(mul0, 32); + __m512i p46 = _mm512_mask_blend_epi32(0xAAAA, mul1, _mm512_setzero_si512()); + __m512i p57 = _mm512_srli_epi64(mul1, 32); + + __m512i p15_ = _mm512_add_epi64(p02, p13); + __m512i p9d_ = _mm512_add_epi64(p46, p57); + return v_uint64x8(_mm512_add_epi64(p15_, p9d_)); +} +inline v_uint64x8 v_dotprod_expand_fast(const v_uint16x32& a, const v_uint16x32& b, const v_uint64x8& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x8 v_dotprod_expand_fast(const v_int16x32& a, const v_int16x32& b) +{ return v_dotprod_expand(a, b); } +inline v_int64x8 v_dotprod_expand_fast(const v_int16x32& a, const v_int16x32& b, const v_int64x8& c) +{ return v_dotprod_expand(a, b, c); } + +// 32 >> 64f +inline v_float64x8 v_dotprod_expand_fast(const v_int32x16& a, const v_int32x16& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x8 v_dotprod_expand_fast(const v_int32x16& a, const v_int32x16& b, const v_float64x8& c) +{ return v_dotprod_expand(a, b) + c; } + + +#define OPENCV_HAL_AVX512_SPLAT2_PS(a, im) \ + v_float32x16(_mm512_permute_ps(a.val, _MM_SHUFFLE(im, im, im, im))) + +inline v_float32x16 v_matmul(const v_float32x16& v, + const v_float32x16& m0, const v_float32x16& m1, + const v_float32x16& m2, const v_float32x16& m3) +{ + v_float32x16 v04 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 0); + v_float32x16 v15 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 1); + v_float32x16 v26 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 2); + v_float32x16 v37 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 3); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, v37 * m3))); +} + +inline v_float32x16 v_matmuladd(const v_float32x16& v, + const v_float32x16& m0, const v_float32x16& m1, + const v_float32x16& m2, const v_float32x16& a) +{ + v_float32x16 v04 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 0); + v_float32x16 v15 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 1); + v_float32x16 v26 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 2); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, a))); +} + +#define OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(_Tpvec, suffix, cast_from, cast_to) \ + inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \ + { \ + __m512i t0 = cast_from(_mm512_unpacklo_##suffix(a0.val, a1.val)); \ + __m512i t1 = cast_from(_mm512_unpacklo_##suffix(a2.val, a3.val)); \ + __m512i t2 = cast_from(_mm512_unpackhi_##suffix(a0.val, a1.val)); \ + __m512i t3 = cast_from(_mm512_unpackhi_##suffix(a2.val, a3.val)); \ + b0.val = cast_to(_mm512_unpacklo_epi64(t0, t1)); \ + b1.val = cast_to(_mm512_unpackhi_epi64(t0, t1)); \ + b2.val = cast_to(_mm512_unpacklo_epi64(t2, t3)); \ + b3.val = cast_to(_mm512_unpackhi_epi64(t2, t3)); \ + } + +OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(v_uint32x16, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(v_int32x16, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(v_float32x16, ps, _mm512_castps_si512, _mm512_castsi512_ps) + +//////////////// Value reordering /////////////// + +/* Expand */ +#define OPENCV_HAL_IMPL_AVX512_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ + inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ + { \ + b0.val = intrin(_v512_extract_low(a.val)); \ + b1.val = intrin(_v512_extract_high(a.val)); \ + } \ + inline _Tpwvec v_expand_low(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v512_extract_low(a.val))); } \ + inline _Tpwvec v_expand_high(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v512_extract_high(a.val))); } \ + inline _Tpwvec v512_load_expand(const _Tp* ptr) \ + { \ + __m256i a = _mm256_loadu_si256((const __m256i*)ptr); \ + return _Tpwvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX512_EXPAND(v_uint8x64, v_uint16x32, uchar, _mm512_cvtepu8_epi16) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_int8x64, v_int16x32, schar, _mm512_cvtepi8_epi16) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_uint16x32, v_uint32x16, ushort, _mm512_cvtepu16_epi32) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_int16x32, v_int32x16, short, _mm512_cvtepi16_epi32) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_uint32x16, v_uint64x8, unsigned, _mm512_cvtepu32_epi64) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_int32x16, v_int64x8, int, _mm512_cvtepi32_epi64) + +#define OPENCV_HAL_IMPL_AVX512_EXPAND_Q(_Tpvec, _Tp, intrin) \ + inline _Tpvec v512_load_expand_q(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadu_si128((const __m128i*)ptr); \ + return _Tpvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX512_EXPAND_Q(v_uint32x16, uchar, _mm512_cvtepu8_epi32) +OPENCV_HAL_IMPL_AVX512_EXPAND_Q(v_int32x16, schar, _mm512_cvtepi8_epi32) + +/* pack */ +// 16 +inline v_int8x64 v_pack(const v_int16x32& a, const v_int16x32& b) +{ return v_int8x64(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packs_epi16(a.val, b.val))); } + +inline v_uint8x64 v_pack(const v_uint16x32& a, const v_uint16x32& b) +{ + const __m512i t = _mm512_set1_epi16(255); + return v_uint8x64(_v512_combine(_mm512_cvtepi16_epi8(_mm512_min_epu16(a.val, t)), _mm512_cvtepi16_epi8(_mm512_min_epu16(b.val, t)))); +} + +inline v_uint8x64 v_pack_u(const v_int16x32& a, const v_int16x32& b) +{ + return v_uint8x64(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packus_epi16(a.val, b.val))); +} + +inline void v_pack_store(schar* ptr, const v_int16x32& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(uchar* ptr, const v_uint16x32& a) +{ + const __m512i m = _mm512_set1_epi16(255); + _mm256_storeu_si256((__m256i*)ptr, _mm512_cvtepi16_epi8(_mm512_min_epu16(a.val, m))); +} + +inline void v_pack_u_store(uchar* ptr, const v_int16x32& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + +template inline +v_uint8x64 v_rshr_pack(const v_uint16x32& a, const v_uint16x32& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + v_uint16x32 delta = v512_setall_u16((short)(1 << (n-1))); + return v_pack_u(v_reinterpret_as_s16((a + delta) >> n), + v_reinterpret_as_s16((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(uchar* ptr, const v_uint16x32& a) +{ + v_uint16x32 delta = v512_setall_u16((short)(1 << (n-1))); + v_pack_u_store(ptr, v_reinterpret_as_s16((a + delta) >> n)); +} + +template inline +v_uint8x64 v_rshr_pack_u(const v_int16x32& a, const v_int16x32& b) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(uchar* ptr, const v_int16x32& a) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int8x64 v_rshr_pack(const v_int16x32& a, const v_int16x32& b) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(schar* ptr, const v_int16x32& a) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + v_pack_store(ptr, (a + delta) >> n); +} + +// 32 +inline v_int16x32 v_pack(const v_int32x16& a, const v_int32x16& b) +{ return v_int16x32(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packs_epi32(a.val, b.val))); } + +inline v_uint16x32 v_pack(const v_uint32x16& a, const v_uint32x16& b) +{ + const __m512i m = _mm512_set1_epi32(65535); + return v_uint16x32(_v512_combine(_mm512_cvtepi32_epi16(_mm512_min_epu32(a.val, m)), _mm512_cvtepi32_epi16(_mm512_min_epu32(b.val, m)))); +} + +inline v_uint16x32 v_pack_u(const v_int32x16& a, const v_int32x16& b) +{ return v_uint16x32(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packus_epi32(a.val, b.val))); } + +inline void v_pack_store(short* ptr, const v_int32x16& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(ushort* ptr, const v_uint32x16& a) +{ + const __m512i m = _mm512_set1_epi32(65535); + _mm256_storeu_si256((__m256i*)ptr, _mm512_cvtepi32_epi16(_mm512_min_epu32(a.val, m))); +} + +inline void v_pack_u_store(ushort* ptr, const v_int32x16& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + + +template inline +v_uint16x32 v_rshr_pack(const v_uint32x16& a, const v_uint32x16& b) +{ + v_uint32x16 delta = v512_setall_u32(1 << (n-1)); + return v_pack_u(v_reinterpret_as_s32((a + delta) >> n), + v_reinterpret_as_s32((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(ushort* ptr, const v_uint32x16& a) +{ + v_uint32x16 delta = v512_setall_u32(1 << (n-1)); + v_pack_u_store(ptr, v_reinterpret_as_s32((a + delta) >> n)); +} + +template inline +v_uint16x32 v_rshr_pack_u(const v_int32x16& a, const v_int32x16& b) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(ushort* ptr, const v_int32x16& a) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int16x32 v_rshr_pack(const v_int32x16& a, const v_int32x16& b) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(short* ptr, const v_int32x16& a) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// 64 +// Non-saturating pack +inline v_uint32x16 v_pack(const v_uint64x8& a, const v_uint64x8& b) +{ return v_uint32x16(_v512_combine(_mm512_cvtepi64_epi32(a.val), _mm512_cvtepi64_epi32(b.val))); } + +inline v_int32x16 v_pack(const v_int64x8& a, const v_int64x8& b) +{ return v_reinterpret_as_s32(v_pack(v_reinterpret_as_u64(a), v_reinterpret_as_u64(b))); } + +inline void v_pack_store(unsigned* ptr, const v_uint64x8& a) +{ _mm256_storeu_si256((__m256i*)ptr, _mm512_cvtepi64_epi32(a.val)); } + +inline void v_pack_store(int* ptr, const v_int64x8& b) +{ v_pack_store((unsigned*)ptr, v_reinterpret_as_u64(b)); } + +template inline +v_uint32x16 v_rshr_pack(const v_uint64x8& a, const v_uint64x8& b) +{ + v_uint64x8 delta = v512_setall_u64((uint64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(unsigned* ptr, const v_uint64x8& a) +{ + v_uint64x8 delta = v512_setall_u64((uint64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +template inline +v_int32x16 v_rshr_pack(const v_int64x8& a, const v_int64x8& b) +{ + v_int64x8 delta = v512_setall_s64((int64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(int* ptr, const v_int64x8& a) +{ + v_int64x8 delta = v512_setall_s64((int64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// pack boolean +inline v_uint8x64 v_pack_b(const v_uint16x32& a, const v_uint16x32& b) +{ return v_uint8x64(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packs_epi16(a.val, b.val))); } + +inline v_uint8x64 v_pack_b(const v_uint32x16& a, const v_uint32x16& b, + const v_uint32x16& c, const v_uint32x16& d) +{ + __m512i ab = _mm512_packs_epi32(a.val, b.val); + __m512i cd = _mm512_packs_epi32(c.val, d.val); + + return v_uint8x64(_mm512_permutexvar_epi32(_v512_set_epu32(15, 11, 7, 3, 14, 10, 6, 2, 13, 9, 5, 1, 12, 8, 4, 0), _mm512_packs_epi16(ab, cd))); +} + +inline v_uint8x64 v_pack_b(const v_uint64x8& a, const v_uint64x8& b, const v_uint64x8& c, + const v_uint64x8& d, const v_uint64x8& e, const v_uint64x8& f, + const v_uint64x8& g, const v_uint64x8& h) +{ + __m512i ab = _mm512_packs_epi32(a.val, b.val); + __m512i cd = _mm512_packs_epi32(c.val, d.val); + __m512i ef = _mm512_packs_epi32(e.val, f.val); + __m512i gh = _mm512_packs_epi32(g.val, h.val); + + __m512i abcd = _mm512_packs_epi32(ab, cd); + __m512i efgh = _mm512_packs_epi32(ef, gh); + + return v_uint8x64(_mm512_permutexvar_epi16(_v512_set_epu16(31, 23, 15, 7, 30, 22, 14, 6, 29, 21, 13, 5, 28, 20, 12, 4, + 27, 19, 11, 3, 26, 18, 10, 2, 25, 17, 9, 1, 24, 16, 8, 0), _mm512_packs_epi16(abcd, efgh))); +} + +/* Recombine */ +// its up there with load and store operations + +/* Extract */ +#define OPENCV_HAL_IMPL_AVX512_EXTRACT(_Tpvec) \ + template \ + inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ + { return v_rotate_right(a, b); } + +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint8x64) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int8x64) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint16x32) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int16x32) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint32x16) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int32x16) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint64x8) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int64x8) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_float32x16) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_float64x8) + +#define OPENCV_HAL_IMPL_AVX512_EXTRACT_N(_Tpvec, _Tp) \ +template inline _Tp v_extract_n(_Tpvec v) { return v_rotate_right(v).get0(); } + +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint8x64, uchar) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int8x64, schar) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint16x32, ushort) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int16x32, short) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint32x16, uint) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int32x16, int) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint64x8, uint64) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int64x8, int64) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_float32x16, float) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_float64x8, double) + +template +inline v_uint32x16 v_broadcast_element(v_uint32x16 a) +{ + static const __m512i perm = _mm512_set1_epi32((char)i); + return v_uint32x16(_mm512_permutexvar_epi32(perm, a.val)); +} + +template +inline v_int32x16 v_broadcast_element(const v_int32x16 &a) +{ return v_reinterpret_as_s32(v_broadcast_element(v_reinterpret_as_u32(a))); } + +template +inline v_float32x16 v_broadcast_element(const v_float32x16 &a) +{ return v_reinterpret_as_f32(v_broadcast_element(v_reinterpret_as_u32(a))); } + + +///////////////////// load deinterleave ///////////////////////////// + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x64& a, v_uint8x64& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8(126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, + 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, + 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu8(127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107, 105, 103, 101, 99, 97, + 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, + 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint8x64(_mm512_permutex2var_epi8(ab0, mask0, ab1)); + b = v_uint8x64(_mm512_permutex2var_epi8(ab0, mask1, ab1)); +#else + __m512i mask0 = _mm512_set4_epi32(0x0f0d0b09, 0x07050301, 0x0e0c0a08, 0x06040200); + __m512i a0b0 = _mm512_shuffle_epi8(ab0, mask0); + __m512i a1b1 = _mm512_shuffle_epi8(ab1, mask0); + __m512i mask1 = _v512_set_epu64(14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask2 = _v512_set_epu64(15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint8x64(_mm512_permutex2var_epi64(a0b0, mask1, a1b1)); + b = v_uint8x64(_mm512_permutex2var_epi64(a0b0, mask2, a1b1)); +#endif +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x32& a, v_uint16x32& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i mask0 = _v512_set_epu16(62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu16(63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint16x32(_mm512_permutex2var_epi16(ab0, mask0, ab1)); + b = v_uint16x32(_mm512_permutex2var_epi16(ab0, mask1, ab1)); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x16& a, v_uint32x16& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i mask0 = _v512_set_epu32(30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu32(31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint32x16(_mm512_permutex2var_epi32(ab0, mask0, ab1)); + b = v_uint32x16(_mm512_permutex2var_epi32(ab0, mask1, ab1)); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x8& a, v_uint64x8& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 8)); + __m512i mask0 = _v512_set_epu64(14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu64(15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint64x8(_mm512_permutex2var_epi64(ab0, mask0, ab1)); + b = v_uint64x8(_mm512_permutex2var_epi64(ab0, mask1, ab1)); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x64& a, v_uint8x64& b, v_uint8x64& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 128)); + +#if CV_AVX_512VBMI2 + __m512i mask0 = _v512_set_epu8(126, 123, 120, 117, 114, 111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81, + 78, 75, 72, 69, 66, 63, 60, 57, 54, 51, 48, 45, 42, 39, 36, 33, + 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 62, 59, 56, 53, 50, + 47, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2); + __m512i r0b01 = _mm512_permutex2var_epi8(bgr0, mask0, bgr1); + __m512i b1g12 = _mm512_permutex2var_epi8(bgr1, mask0, bgr2); + __m512i r12b2 = _mm512_permutex2var_epi8(bgr1, + _v512_set_epu8(125, 122, 119, 116, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, + 77, 74, 71, 68, 65, 127, 124, 121, 118, 115, 112, 109, 106, 103, 100, 97, + 94, 91, 88, 85, 82, 79, 76, 73, 70, 67, 64, 61, 58, 55, 52, 49, + 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1), bgr2); + a = v_uint8x64(_mm512_mask_compress_epi8(r12b2, 0xffffffffffe00000, r0b01)); + b = v_uint8x64(_mm512_mask_compress_epi8(b1g12, 0x2492492492492492, bgr0)); + c = v_uint8x64(_mm512_mask_expand_epi8(r0b01, 0xffffffffffe00000, r12b2)); +#elif CV_AVX_512VBMI + __m512i b0g0b1 = _mm512_mask_blend_epi8(0xb6db6db6db6db6db, bgr1, bgr0); + __m512i g1r1g2 = _mm512_mask_blend_epi8(0xb6db6db6db6db6db, bgr2, bgr1); + __m512i r2b2r0 = _mm512_mask_blend_epi8(0xb6db6db6db6db6db, bgr0, bgr2); + a = v_uint8x64(_mm512_permutex2var_epi8(b0g0b1, _v512_set_epu8(125, 122, 119, 116, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, + 77, 74, 71, 68, 65, 63, 61, 60, 58, 57, 55, 54, 52, 51, 49, 48, + 46, 45, 43, 42, 40, 39, 37, 36, 34, 33, 31, 30, 28, 27, 25, 24, + 23, 21, 20, 18, 17, 15, 14, 12, 11, 9, 8, 6, 5, 3, 2, 0), bgr2)); + b = v_uint8x64(_mm512_permutex2var_epi8(g1r1g2, _v512_set_epu8( 63, 61, 60, 58, 57, 55, 54, 52, 51, 49, 48, 46, 45, 43, 42, 40, + 39, 37, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20, 18, 17, + 15, 14, 12, 11, 9, 8, 6, 5, 3, 2, 0, 126, 123, 120, 117, 114, + 111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81, 78, 75, 72, 69, 66), bgr0)); + c = v_uint8x64(_mm512_permutex2var_epi8(r2b2r0, _v512_set_epu8( 63, 60, 57, 54, 51, 48, 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, + 15, 12, 9, 6, 3, 0, 125, 122, 119, 116, 113, 110, 107, 104, 101, 98, + 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 65, 62, 59, 56, 53, 50, + 47, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2), bgr1)); +#else + __m512i mask0 = _v512_set_epu16(61, 58, 55, 52, 49, 46, 43, 40, 37, 34, 63, 60, 57, 54, 51, 48, + 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0); + __m512i b01g1 = _mm512_permutex2var_epi16(bgr0, mask0, bgr1); + __m512i r12b2 = _mm512_permutex2var_epi16(bgr1, mask0, bgr2); + __m512i g20r0 = _mm512_permutex2var_epi16(bgr2, mask0, bgr0); + + __m512i b0g0 = _mm512_mask_blend_epi32(0xf800, b01g1, r12b2); + __m512i r0b1 = _mm512_permutex2var_epi16(bgr1, _v512_set_epu16(42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 29, 26, 23, 20, 17, + 14, 11, 8, 5, 2, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43), g20r0); + __m512i g1r1 = _mm512_alignr_epi32(r12b2, g20r0, 11); + a = v_uint8x64(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, b0g0, r0b1)); + c = v_uint8x64(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, r0b1, g1r1)); + b = v_uint8x64(_mm512_shuffle_epi8(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, g1r1, b0g0), _mm512_set4_epi32(0x0e0f0c0d, 0x0a0b0809, 0x06070405, 0x02030001))); +#endif +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x32& a, v_uint16x32& b, v_uint16x32& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + + __m512i mask0 = _v512_set_epu16(61, 58, 55, 52, 49, 46, 43, 40, 37, 34, 63, 60, 57, 54, 51, 48, + 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0); + __m512i b01g1 = _mm512_permutex2var_epi16(bgr0, mask0, bgr1); + __m512i r12b2 = _mm512_permutex2var_epi16(bgr1, mask0, bgr2); + __m512i g20r0 = _mm512_permutex2var_epi16(bgr2, mask0, bgr0); + + a = v_uint16x32(_mm512_mask_blend_epi32(0xf800, b01g1, r12b2)); + b = v_uint16x32(_mm512_permutex2var_epi16(bgr1, _v512_set_epu16(42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 29, 26, 23, 20, 17, + 14, 11, 8, 5, 2, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43), g20r0)); + c = v_uint16x32(_mm512_alignr_epi32(r12b2, g20r0, 11)); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x16& a, v_uint32x16& b, v_uint32x16& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + + __m512i mask0 = _v512_set_epu32(29, 26, 23, 20, 17, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0); + __m512i b01r1 = _mm512_permutex2var_epi32(bgr0, mask0, bgr1); + __m512i g12b2 = _mm512_permutex2var_epi32(bgr1, mask0, bgr2); + __m512i r20g0 = _mm512_permutex2var_epi32(bgr2, mask0, bgr0); + + a = v_uint32x16(_mm512_mask_blend_epi32(0xf800, b01r1, g12b2)); + b = v_uint32x16(_mm512_alignr_epi32(g12b2, r20g0, 11)); + c = v_uint32x16(_mm512_permutex2var_epi32(bgr1, _v512_set_epu32(21, 20, 19, 18, 17, 16, 13, 10, 7, 4, 1, 26, 25, 24, 23, 22), r20g0)); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x8& a, v_uint64x8& b, v_uint64x8& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 8)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + + __m512i mask0 = _v512_set_epu64(13, 10, 15, 12, 9, 6, 3, 0); + __m512i b01g1 = _mm512_permutex2var_epi64(bgr0, mask0, bgr1); + __m512i r12b2 = _mm512_permutex2var_epi64(bgr1, mask0, bgr2); + __m512i g20r0 = _mm512_permutex2var_epi64(bgr2, mask0, bgr0); + + a = v_uint64x8(_mm512_mask_blend_epi64(0xc0, b01g1, r12b2)); + c = v_uint64x8(_mm512_alignr_epi64(r12b2, g20r0, 6)); + b = v_uint64x8(_mm512_permutex2var_epi64(bgr1, _v512_set_epu64(10, 9, 8, 5, 2, 13, 12, 11), g20r0)); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x64& a, v_uint8x64& b, v_uint8x64& c, v_uint8x64& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 128)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 192)); + +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8(126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, + 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, + 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu8(127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107, 105, 103, 101, 99, 97, + 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, + 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi8(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi8(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi8(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi8(bgra2, mask1, bgra3); + + a = v_uint8x64(_mm512_permutex2var_epi8(br01, mask0, br23)); + c = v_uint8x64(_mm512_permutex2var_epi8(br01, mask1, br23)); + b = v_uint8x64(_mm512_permutex2var_epi8(ga01, mask0, ga23)); + d = v_uint8x64(_mm512_permutex2var_epi8(ga01, mask1, ga23)); +#else + __m512i mask = _mm512_set4_epi32(0x0f0b0703, 0x0e0a0602, 0x0d090501, 0x0c080400); + __m512i b0g0r0a0 = _mm512_shuffle_epi8(bgra0, mask); + __m512i b1g1r1a1 = _mm512_shuffle_epi8(bgra1, mask); + __m512i b2g2r2a2 = _mm512_shuffle_epi8(bgra2, mask); + __m512i b3g3r3a3 = _mm512_shuffle_epi8(bgra3, mask); + + __m512i mask0 = _v512_set_epu32(30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu32(31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi32(b0g0r0a0, mask0, b1g1r1a1); + __m512i ga01 = _mm512_permutex2var_epi32(b0g0r0a0, mask1, b1g1r1a1); + __m512i br23 = _mm512_permutex2var_epi32(b2g2r2a2, mask0, b3g3r3a3); + __m512i ga23 = _mm512_permutex2var_epi32(b2g2r2a2, mask1, b3g3r3a3); + + a = v_uint8x64(_mm512_permutex2var_epi32(br01, mask0, br23)); + c = v_uint8x64(_mm512_permutex2var_epi32(br01, mask1, br23)); + b = v_uint8x64(_mm512_permutex2var_epi32(ga01, mask0, ga23)); + d = v_uint8x64(_mm512_permutex2var_epi32(ga01, mask1, ga23)); +#endif +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x32& a, v_uint16x32& b, v_uint16x32& c, v_uint16x32& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 96)); + + __m512i mask0 = _v512_set_epu16(62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu16(63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi16(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi16(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi16(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi16(bgra2, mask1, bgra3); + + a = v_uint16x32(_mm512_permutex2var_epi16(br01, mask0, br23)); + c = v_uint16x32(_mm512_permutex2var_epi16(br01, mask1, br23)); + b = v_uint16x32(_mm512_permutex2var_epi16(ga01, mask0, ga23)); + d = v_uint16x32(_mm512_permutex2var_epi16(ga01, mask1, ga23)); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x16& a, v_uint32x16& b, v_uint32x16& c, v_uint32x16& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 48)); + + __m512i mask0 = _v512_set_epu32(30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu32(31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi32(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi32(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi32(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi32(bgra2, mask1, bgra3); + + a = v_uint32x16(_mm512_permutex2var_epi32(br01, mask0, br23)); + c = v_uint32x16(_mm512_permutex2var_epi32(br01, mask1, br23)); + b = v_uint32x16(_mm512_permutex2var_epi32(ga01, mask0, ga23)); + d = v_uint32x16(_mm512_permutex2var_epi32(ga01, mask1, ga23)); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x8& a, v_uint64x8& b, v_uint64x8& c, v_uint64x8& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 8)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 24)); + + __m512i mask0 = _v512_set_epu64(14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu64(15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi64(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi64(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi64(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi64(bgra2, mask1, bgra3); + + a = v_uint64x8(_mm512_permutex2var_epi64(br01, mask0, br23)); + c = v_uint64x8(_mm512_permutex2var_epi64(br01, mask1, br23)); + b = v_uint64x8(_mm512_permutex2var_epi64(ga01, mask0, ga23)); + d = v_uint64x8(_mm512_permutex2var_epi64(ga01, mask1, ga23)); +} + +///////////////////////////// store interleave ///////////////////////////////////// + +inline void v_store_interleave( uchar* ptr, const v_uint8x64& x, const v_uint8x64& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint8x64 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 64), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 64), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 64), high.val); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x32& x, const v_uint16x32& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint16x32 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 32), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 32), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 32), high.val); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x16& x, const v_uint32x16& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint32x16 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 16), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 16), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 16), high.val); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x8& x, const v_uint64x8& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint64x8 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 8), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 8), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 8), high.val); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x64& a, const v_uint8x64& b, const v_uint8x64& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8(127, 84, 20, 126, 83, 19, 125, 82, 18, 124, 81, 17, 123, 80, 16, 122, + 79, 15, 121, 78, 14, 120, 77, 13, 119, 76, 12, 118, 75, 11, 117, 74, + 10, 116, 73, 9, 115, 72, 8, 114, 71, 7, 113, 70, 6, 112, 69, 5, + 111, 68, 4, 110, 67, 3, 109, 66, 2, 108, 65, 1, 107, 64, 0, 106); + __m512i mask1 = _v512_set_epu8( 21, 42, 105, 20, 41, 104, 19, 40, 103, 18, 39, 102, 17, 38, 101, 16, + 37, 100, 15, 36, 99, 14, 35, 98, 13, 34, 97, 12, 33, 96, 11, 32, + 95, 10, 31, 94, 9, 30, 93, 8, 29, 92, 7, 28, 91, 6, 27, 90, + 5, 26, 89, 4, 25, 88, 3, 24, 87, 2, 23, 86, 1, 22, 85, 0); + __m512i mask2 = _v512_set_epu8(106, 127, 63, 105, 126, 62, 104, 125, 61, 103, 124, 60, 102, 123, 59, 101, + 122, 58, 100, 121, 57, 99, 120, 56, 98, 119, 55, 97, 118, 54, 96, 117, + 53, 95, 116, 52, 94, 115, 51, 93, 114, 50, 92, 113, 49, 91, 112, 48, + 90, 111, 47, 89, 110, 46, 88, 109, 45, 87, 108, 44, 86, 107, 43, 85); + __m512i r2g0r0 = _mm512_permutex2var_epi8(b.val, mask0, c.val); + __m512i b0r1b1 = _mm512_permutex2var_epi8(a.val, mask1, c.val); + __m512i g1b2g2 = _mm512_permutex2var_epi8(a.val, mask2, b.val); + + __m512i bgr0 = _mm512_mask_blend_epi8(0x9249249249249249, r2g0r0, b0r1b1); + __m512i bgr1 = _mm512_mask_blend_epi8(0x9249249249249249, b0r1b1, g1b2g2); + __m512i bgr2 = _mm512_mask_blend_epi8(0x9249249249249249, g1b2g2, r2g0r0); +#else + __m512i g1g0 = _mm512_shuffle_epi8(b.val, _mm512_set4_epi32(0x0e0f0c0d, 0x0a0b0809, 0x06070405, 0x02030001)); + __m512i b0g0 = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, a.val, g1g0); + __m512i r0b1 = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, c.val, a.val); + __m512i g1r1 = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, g1g0, c.val); + + __m512i mask0 = _v512_set_epu16(42, 10, 31, 41, 9, 30, 40, 8, 29, 39, 7, 28, 38, 6, 27, 37, + 5, 26, 36, 4, 25, 35, 3, 24, 34, 2, 23, 33, 1, 22, 32, 0); + __m512i mask1 = _v512_set_epu16(21, 52, 41, 20, 51, 40, 19, 50, 39, 18, 49, 38, 17, 48, 37, 16, + 47, 36, 15, 46, 35, 14, 45, 34, 13, 44, 33, 12, 43, 32, 11, 42); + __m512i mask2 = _v512_set_epu16(63, 31, 20, 62, 30, 19, 61, 29, 18, 60, 28, 17, 59, 27, 16, 58, + 26, 15, 57, 25, 14, 56, 24, 13, 55, 23, 12, 54, 22, 11, 53, 21); + __m512i b0g0b2 = _mm512_permutex2var_epi16(b0g0, mask0, r0b1); + __m512i r1b1r0 = _mm512_permutex2var_epi16(b0g0, mask1, g1r1); + __m512i g2r2g1 = _mm512_permutex2var_epi16(r0b1, mask2, g1r1); + + __m512i bgr0 = _mm512_mask_blend_epi16(0x24924924, b0g0b2, r1b1r0); + __m512i bgr1 = _mm512_mask_blend_epi16(0x24924924, r1b1r0, g2r2g1); + __m512i bgr2 = _mm512_mask_blend_epi16(0x24924924, g2r2g1, b0g0b2); +#endif + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 64), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 128), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 64), bgr1); + _mm512_store_si512((__m512i*)(ptr + 128), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 128), bgr2); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x32& a, const v_uint16x32& b, const v_uint16x32& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m512i mask0 = _v512_set_epu16(42, 10, 31, 41, 9, 30, 40, 8, 29, 39, 7, 28, 38, 6, 27, 37, + 5, 26, 36, 4, 25, 35, 3, 24, 34, 2, 23, 33, 1, 22, 32, 0); + __m512i mask1 = _v512_set_epu16(21, 52, 41, 20, 51, 40, 19, 50, 39, 18, 49, 38, 17, 48, 37, 16, + 47, 36, 15, 46, 35, 14, 45, 34, 13, 44, 33, 12, 43, 32, 11, 42); + __m512i mask2 = _v512_set_epu16(63, 31, 20, 62, 30, 19, 61, 29, 18, 60, 28, 17, 59, 27, 16, 58, + 26, 15, 57, 25, 14, 56, 24, 13, 55, 23, 12, 54, 22, 11, 53, 21); + __m512i b0g0b2 = _mm512_permutex2var_epi16(a.val, mask0, b.val); + __m512i r1b1r0 = _mm512_permutex2var_epi16(a.val, mask1, c.val); + __m512i g2r2g1 = _mm512_permutex2var_epi16(b.val, mask2, c.val); + + __m512i bgr0 = _mm512_mask_blend_epi16(0x24924924, b0g0b2, r1b1r0); + __m512i bgr1 = _mm512_mask_blend_epi16(0x24924924, r1b1r0, g2r2g1); + __m512i bgr2 = _mm512_mask_blend_epi16(0x24924924, g2r2g1, b0g0b2); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 32), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 64), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 32), bgr1); + _mm512_store_si512((__m512i*)(ptr + 64), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgr2); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x16& a, const v_uint32x16& b, const v_uint32x16& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m512i mask0 = _v512_set_epu32(26, 31, 15, 25, 30, 14, 24, 29, 13, 23, 28, 12, 22, 27, 11, 21); + __m512i mask1 = _v512_set_epu32(31, 10, 25, 30, 9, 24, 29, 8, 23, 28, 7, 22, 27, 6, 21, 26); + __m512i g1b2g2 = _mm512_permutex2var_epi32(a.val, mask0, b.val); + __m512i r2r1b1 = _mm512_permutex2var_epi32(a.val, mask1, c.val); + + __m512i bgr0 = _mm512_mask_expand_epi32(_mm512_mask_expand_epi32(_mm512_maskz_expand_epi32(0x9249, a.val), 0x2492, b.val), 0x4924, c.val); + __m512i bgr1 = _mm512_mask_blend_epi32(0x9249, r2r1b1, g1b2g2); + __m512i bgr2 = _mm512_mask_blend_epi32(0x9249, g1b2g2, r2r1b1); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 16), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 32), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 16), bgr1); + _mm512_store_si512((__m512i*)(ptr + 32), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgr2); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x8& a, const v_uint64x8& b, const v_uint64x8& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m512i mask0 = _v512_set_epu64( 5, 12, 7, 4, 11, 6, 3, 10); + __m512i mask1 = _v512_set_epu64(15, 7, 4, 14, 6, 3, 13, 5); + __m512i r1b1b2 = _mm512_permutex2var_epi64(a.val, mask0, c.val); + __m512i g2r2g1 = _mm512_permutex2var_epi64(b.val, mask1, c.val); + + __m512i bgr0 = _mm512_mask_expand_epi64(_mm512_mask_expand_epi64(_mm512_maskz_expand_epi64(0x49, a.val), 0x92, b.val), 0x24, c.val); + __m512i bgr1 = _mm512_mask_blend_epi64(0xdb, g2r2g1, r1b1b2); + __m512i bgr2 = _mm512_mask_blend_epi64(0xdb, r1b1b2, g2r2g1); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 8), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 16), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 8), bgr1); + _mm512_store_si512((__m512i*)(ptr + 16), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 8), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgr2); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x64& a, const v_uint8x64& b, + const v_uint8x64& c, const v_uint8x64& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint8x64 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint8x64 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 64), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 128), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 192), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 64), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 128), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 192), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 128), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 192), bgra3.val); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x32& a, const v_uint16x32& b, + const v_uint16x32& c, const v_uint16x32& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint16x32 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint16x32 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 32), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 64), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 96), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 32), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 64), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 96), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 96), bgra3.val); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x16& a, const v_uint32x16& b, + const v_uint32x16& c, const v_uint32x16& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint32x16 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint32x16 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 16), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 32), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 48), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 16), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 32), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 48), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 48), bgra3.val); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x8& a, const v_uint64x8& b, + const v_uint64x8& c, const v_uint64x8& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint64x8 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint64x8 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 8), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 16), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 24), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 8), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 16), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 24), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 8), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 24), bgra3.val); + } +} + +#define OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, const _Tpvec0& c0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int8x64, schar, s8, v_uint8x64, uchar, u8) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int16x32, short, s16, v_uint16x32, ushort, u16) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int32x16, int, s32, v_uint32x16, unsigned, u32) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_float32x16, float, f32, v_uint32x16, unsigned, u32) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int64x8, int64, s64, v_uint64x8, uint64, u64) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_float64x8, double, f64, v_uint64x8, uint64, u64) + +////////// Mask and checks ///////// + +/** Mask **/ +inline int64 v_signmask(const v_int8x64& a) { return (int64)_mm512_movepi8_mask(a.val); } +inline int v_signmask(const v_int16x32& a) { return (int)_mm512_cmp_epi16_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline int v_signmask(const v_int32x16& a) { return (int)_mm512_cmp_epi32_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline int v_signmask(const v_int64x8& a) { return (int)_mm512_cmp_epi64_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } + +inline int64 v_signmask(const v_uint8x64& a) { return v_signmask(v_reinterpret_as_s8(a)); } +inline int v_signmask(const v_uint16x32& a) { return v_signmask(v_reinterpret_as_s16(a)); } +inline int v_signmask(const v_uint32x16& a) { return v_signmask(v_reinterpret_as_s32(a)); } +inline int v_signmask(const v_uint64x8& a) { return v_signmask(v_reinterpret_as_s64(a)); } +inline int v_signmask(const v_float32x16& a) { return v_signmask(v_reinterpret_as_s32(a)); } +inline int v_signmask(const v_float64x8& a) { return v_signmask(v_reinterpret_as_s64(a)); } + +/** Checks **/ +inline bool v_check_all(const v_int8x64& a) { return !(bool)_mm512_cmp_epi8_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int8x64& a) { return (bool)_mm512_movepi8_mask(a.val); } +inline bool v_check_all(const v_int16x32& a) { return !(bool)_mm512_cmp_epi16_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int16x32& a) { return (bool)_mm512_cmp_epi16_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline bool v_check_all(const v_int32x16& a) { return !(bool)_mm512_cmp_epi32_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int32x16& a) { return (bool)_mm512_cmp_epi32_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline bool v_check_all(const v_int64x8& a) { return !(bool)_mm512_cmp_epi64_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int64x8& a) { return (bool)_mm512_cmp_epi64_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } + +inline bool v_check_all(const v_float32x16& a) { return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_float32x16& a) { return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_float64x8& a) { return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_float64x8& a) { return v_check_any(v_reinterpret_as_s64(a)); } +inline bool v_check_all(const v_uint8x64& a) { return v_check_all(v_reinterpret_as_s8(a)); } +inline bool v_check_all(const v_uint16x32& a) { return v_check_all(v_reinterpret_as_s16(a)); } +inline bool v_check_all(const v_uint32x16& a) { return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_uint64x8& a) { return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_uint8x64& a) { return v_check_any(v_reinterpret_as_s8(a)); } +inline bool v_check_any(const v_uint16x32& a) { return v_check_any(v_reinterpret_as_s16(a)); } +inline bool v_check_any(const v_uint32x16& a) { return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_uint64x8& a) { return v_check_any(v_reinterpret_as_s64(a)); } + +inline int v_scan_forward(const v_int8x64& a) +{ + int64 mask = _mm512_movepi8_mask(a.val); + int mask32 = (int)mask; + return mask != 0 ? mask32 != 0 ? trailingZeros32(mask32) : 32 + trailingZeros32((int)(mask >> 32)) : 0; +} +inline int v_scan_forward(const v_uint8x64& a) { return v_scan_forward(v_reinterpret_as_s8(a)); } +inline int v_scan_forward(const v_int16x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))); } +inline int v_scan_forward(const v_uint16x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))); } +inline int v_scan_forward(const v_int32x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 2; } +inline int v_scan_forward(const v_uint32x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 2; } +inline int v_scan_forward(const v_float32x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 2; } +inline int v_scan_forward(const v_int64x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 4; } +inline int v_scan_forward(const v_uint64x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 4; } +inline int v_scan_forward(const v_float64x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 4; } + +inline void v512_cleanup() { _mm256_zeroall(); } + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: + +#endif // OPENCV_HAL_INTRIN_AVX_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_cpp.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_cpp.hpp new file mode 100644 index 0000000..4622214 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_cpp.hpp @@ -0,0 +1,3320 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_INTRIN_CPP_HPP +#define OPENCV_HAL_INTRIN_CPP_HPP + +#include +#include +#include +#include "opencv2/core/saturate.hpp" + +//! @cond IGNORED +#define CV_SIMD128_CPP 1 +#if defined(CV_FORCE_SIMD128_CPP) +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +#endif +#if defined(CV_DOXYGEN) +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +#define CV_SIMD256 1 +#define CV_SIMD256_64F 1 +#define CV_SIMD512 1 +#define CV_SIMD512_64F 1 +#else +#define CV_SIMD256 0 // Explicitly disable SIMD256 and SIMD512 support for scalar intrinsic implementation +#define CV_SIMD512 0 // to avoid warnings during compilation +#endif +//! @endcond + +namespace cv +{ + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN +#endif + +/** @addtogroup core_hal_intrin + +"Universal intrinsics" is a types and functions set intended to simplify vectorization of code on +different platforms. Currently a few different SIMD extensions on different architectures are supported. +128 bit registers of various types support is implemented for a wide range of architectures +including x86(__SSE/SSE2/SSE4.2__), ARM(__NEON__), PowerPC(__VSX__), MIPS(__MSA__). +256 bit long registers are supported on x86(__AVX2__) and 512 bit long registers are supported on x86(__AVX512__). +In case when there is no SIMD extension available during compilation, fallback C++ implementation of intrinsics +will be chosen and code will work as expected although it could be slower. + +### Types + +There are several types representing packed values vector registers, each type is +implemented as a structure based on a one SIMD register. + +- cv::v_uint8 and cv::v_int8: 8-bit integer values (unsigned/signed) - char +- cv::v_uint16 and cv::v_int16: 16-bit integer values (unsigned/signed) - short +- cv::v_uint32 and cv::v_int32: 32-bit integer values (unsigned/signed) - int +- cv::v_uint64 and cv::v_int64: 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32: 32-bit floating point values (signed) - float +- cv::v_float64: 64-bit floating point values (signed) - double + +Exact bit length(and value quantity) of listed types is compile time deduced and depends on architecture SIMD +capabilities chosen as available during compilation of the library. All the types contains __nlanes__ enumeration +to check for exact value quantity of the type. + +In case the exact bit length of the type is important it is possible to use specific fixed length register types. + +There are several types representing 128-bit registers. + +- cv::v_uint8x16 and cv::v_int8x16: sixteen 8-bit integer values (unsigned/signed) - char +- cv::v_uint16x8 and cv::v_int16x8: eight 16-bit integer values (unsigned/signed) - short +- cv::v_uint32x4 and cv::v_int32x4: four 32-bit integer values (unsigned/signed) - int +- cv::v_uint64x2 and cv::v_int64x2: two 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32x4: four 32-bit floating point values (signed) - float +- cv::v_float64x2: two 64-bit floating point values (signed) - double + +There are several types representing 256-bit registers. + +- cv::v_uint8x32 and cv::v_int8x32: thirty two 8-bit integer values (unsigned/signed) - char +- cv::v_uint16x16 and cv::v_int16x16: sixteen 16-bit integer values (unsigned/signed) - short +- cv::v_uint32x8 and cv::v_int32x8: eight 32-bit integer values (unsigned/signed) - int +- cv::v_uint64x4 and cv::v_int64x4: four 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32x8: eight 32-bit floating point values (signed) - float +- cv::v_float64x4: four 64-bit floating point values (signed) - double + +@note +256 bit registers at the moment implemented for AVX2 SIMD extension only, if you want to use this type directly, +don't forget to check the CV_SIMD256 preprocessor definition: +@code +#if CV_SIMD256 +//... +#endif +@endcode + +There are several types representing 512-bit registers. + +- cv::v_uint8x64 and cv::v_int8x64: sixty four 8-bit integer values (unsigned/signed) - char +- cv::v_uint16x32 and cv::v_int16x32: thirty two 16-bit integer values (unsigned/signed) - short +- cv::v_uint32x16 and cv::v_int32x16: sixteen 32-bit integer values (unsigned/signed) - int +- cv::v_uint64x8 and cv::v_int64x8: eight 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32x16: sixteen 32-bit floating point values (signed) - float +- cv::v_float64x8: eight 64-bit floating point values (signed) - double +@note +512 bit registers at the moment implemented for AVX512 SIMD extension only, if you want to use this type directly, +don't forget to check the CV_SIMD512 preprocessor definition. + +@note +cv::v_float64x2 is not implemented in NEON variant, if you want to use this type, don't forget to +check the CV_SIMD128_64F preprocessor definition. + +### Load and store operations + +These operations allow to set contents of the register explicitly or by loading it from some memory +block and to save contents of the register to memory block. + +There are variable size register load operations that provide result of maximum available size +depending on chosen platform capabilities. +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +- Other create methods: +vx_setall_s8, vx_setall_u8, ..., +vx_setzero_u8, vx_setzero_s8, ... +- Memory load operations: +vx_load, vx_load_aligned, vx_load_low, vx_load_halves, +- Memory operations with expansion of values: +vx_load_expand, vx_load_expand_q + +Also there are fixed size register load/store operations. + +For 128 bit registers +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +@ref v_reg::v_reg(_Tp s0, _Tp s1) "from two values", ... +- Other create methods: +@ref v_setall_s8, @ref v_setall_u8, ..., +@ref v_setzero_u8, @ref v_setzero_s8, ... +- Memory load operations: +@ref v_load, @ref v_load_aligned, @ref v_load_low, @ref v_load_halves, +- Memory operations with expansion of values: +@ref v_load_expand, @ref v_load_expand_q + +For 256 bit registers(check CV_SIMD256 preprocessor definition) +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +@ref v_reg::v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3) "from four values", ... +- Other create methods: +@ref v256_setall_s8, @ref v256_setall_u8, ..., +@ref v256_setzero_u8, @ref v256_setzero_s8, ... +- Memory load operations: +@ref v256_load, @ref v256_load_aligned, @ref v256_load_low, @ref v256_load_halves, +- Memory operations with expansion of values: +@ref v256_load_expand, @ref v256_load_expand_q + +For 512 bit registers(check CV_SIMD512 preprocessor definition) +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +@ref v_reg::v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3, _Tp s4, _Tp s5, _Tp s6, _Tp s7) "from eight values", ... +- Other create methods: +@ref v512_setall_s8, @ref v512_setall_u8, ..., +@ref v512_setzero_u8, @ref v512_setzero_s8, ... +- Memory load operations: +@ref v512_load, @ref v512_load_aligned, @ref v512_load_low, @ref v512_load_halves, +- Memory operations with expansion of values: +@ref v512_load_expand, @ref v512_load_expand_q + +Store to memory operations are similar across different platform capabilities: +@ref v_store, @ref v_store_aligned, +@ref v_store_high, @ref v_store_low + +### Value reordering + +These operations allow to reorder or recombine elements in one or multiple vectors. + +- Interleave, deinterleave (2, 3 and 4 channels): @ref v_load_deinterleave, @ref v_store_interleave +- Expand: @ref v_expand, @ref v_expand_low, @ref v_expand_high +- Pack: @ref v_pack, @ref v_pack_u, @ref v_pack_b, @ref v_rshr_pack, @ref v_rshr_pack_u, +@ref v_pack_store, @ref v_pack_u_store, @ref v_rshr_pack_store, @ref v_rshr_pack_u_store +- Recombine: @ref v_zip, @ref v_recombine, @ref v_combine_low, @ref v_combine_high +- Reverse: @ref v_reverse +- Extract: @ref v_extract + + +### Arithmetic, bitwise and comparison operations + +Element-wise binary and unary operations. + +- Arithmetics: +@ref operator +(const v_reg &a, const v_reg &b) "+", +@ref operator -(const v_reg &a, const v_reg &b) "-", +@ref operator *(const v_reg &a, const v_reg &b) "*", +@ref operator /(const v_reg &a, const v_reg &b) "/", +@ref v_mul_expand + +- Non-saturating arithmetics: @ref v_add_wrap, @ref v_sub_wrap + +- Bitwise shifts: +@ref operator <<(const v_reg &a, int s) "<<", +@ref operator >>(const v_reg &a, int s) ">>", +@ref v_shl, @ref v_shr + +- Bitwise logic: +@ref operator &(const v_reg &a, const v_reg &b) "&", +@ref operator |(const v_reg &a, const v_reg &b) "|", +@ref operator ^(const v_reg &a, const v_reg &b) "^", +@ref operator ~(const v_reg &a) "~" + +- Comparison: +@ref operator >(const v_reg &a, const v_reg &b) ">", +@ref operator >=(const v_reg &a, const v_reg &b) ">=", +@ref operator <(const v_reg &a, const v_reg &b) "<", +@ref operator <=(const v_reg &a, const v_reg &b) "<=", +@ref operator ==(const v_reg &a, const v_reg &b) "==", +@ref operator !=(const v_reg &a, const v_reg &b) "!=" + +- min/max: @ref v_min, @ref v_max + +### Reduce and mask + +Most of these operations return only one value. + +- Reduce: @ref v_reduce_min, @ref v_reduce_max, @ref v_reduce_sum, @ref v_popcount +- Mask: @ref v_signmask, @ref v_check_all, @ref v_check_any, @ref v_select + +### Other math + +- Some frequent operations: @ref v_sqrt, @ref v_invsqrt, @ref v_magnitude, @ref v_sqr_magnitude +- Absolute values: @ref v_abs, @ref v_absdiff, @ref v_absdiffs + +### Conversions + +Different type conversions and casts: + +- Rounding: @ref v_round, @ref v_floor, @ref v_ceil, @ref v_trunc, +- To float: @ref v_cvt_f32, @ref v_cvt_f64 +- Reinterpret: @ref v_reinterpret_as_u8, @ref v_reinterpret_as_s8, ... + +### Matrix operations + +In these operations vectors represent matrix rows/columns: @ref v_dotprod, @ref v_dotprod_fast, +@ref v_dotprod_expand, @ref v_dotprod_expand_fast, @ref v_matmul, @ref v_transpose4x4 + +### Usability + +Most operations are implemented only for some subset of the available types, following matrices +shows the applicability of different operations to the types. + +Regular integers: + +| Operations\\Types | uint 8 | int 8 | uint 16 | int 16 | uint 32 | int 32 | +|-------------------|:-:|:-:|:-:|:-:|:-:|:-:| +|load, store | x | x | x | x | x | x | +|interleave | x | x | x | x | x | x | +|expand | x | x | x | x | x | x | +|expand_low | x | x | x | x | x | x | +|expand_high | x | x | x | x | x | x | +|expand_q | x | x | | | | | +|add, sub | x | x | x | x | x | x | +|add_wrap, sub_wrap | x | x | x | x | | | +|mul_wrap | x | x | x | x | | | +|mul | x | x | x | x | x | x | +|mul_expand | x | x | x | x | x | | +|compare | x | x | x | x | x | x | +|shift | | | x | x | x | x | +|dotprod | | | | x | | x | +|dotprod_fast | | | | x | | x | +|dotprod_expand | x | x | x | x | | x | +|dotprod_expand_fast| x | x | x | x | | x | +|logical | x | x | x | x | x | x | +|min, max | x | x | x | x | x | x | +|absdiff | x | x | x | x | x | x | +|absdiffs | | x | | x | | | +|reduce | x | x | x | x | x | x | +|mask | x | x | x | x | x | x | +|pack | x | x | x | x | x | x | +|pack_u | x | | x | | | | +|pack_b | x | | | | | | +|unpack | x | x | x | x | x | x | +|extract | x | x | x | x | x | x | +|rotate (lanes) | x | x | x | x | x | x | +|cvt_flt32 | | | | | | x | +|cvt_flt64 | | | | | | x | +|transpose4x4 | | | | | x | x | +|reverse | x | x | x | x | x | x | +|extract_n | x | x | x | x | x | x | +|broadcast_element | | | | | x | x | + +Big integers: + +| Operations\\Types | uint 64 | int 64 | +|-------------------|:-:|:-:| +|load, store | x | x | +|add, sub | x | x | +|shift | x | x | +|logical | x | x | +|reverse | x | x | +|extract | x | x | +|rotate (lanes) | x | x | +|cvt_flt64 | | x | +|extract_n | x | x | + +Floating point: + +| Operations\\Types | float 32 | float 64 | +|-------------------|:-:|:-:| +|load, store | x | x | +|interleave | x | | +|add, sub | x | x | +|mul | x | x | +|div | x | x | +|compare | x | x | +|min, max | x | x | +|absdiff | x | x | +|reduce | x | | +|mask | x | x | +|unpack | x | x | +|cvt_flt32 | | x | +|cvt_flt64 | x | | +|sqrt, abs | x | x | +|float math | x | x | +|transpose4x4 | x | | +|extract | x | x | +|rotate (lanes) | x | x | +|reverse | x | x | +|extract_n | x | x | +|broadcast_element | x | | + + @{ */ + +template struct v_reg +{ +//! @cond IGNORED + typedef _Tp lane_type; + enum { nlanes = n }; +// !@endcond + + /** @brief Constructor + + Initializes register with data from memory + @param ptr pointer to memory block with data for register */ + explicit v_reg(const _Tp* ptr) { for( int i = 0; i < n; i++ ) s[i] = ptr[i]; } + + /** @brief Constructor + + Initializes register with two 64-bit values */ + v_reg(_Tp s0, _Tp s1) { s[0] = s0; s[1] = s1; } + + /** @brief Constructor + + Initializes register with four 32-bit values */ + v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3) { s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; } + + /** @brief Constructor + + Initializes register with eight 16-bit values */ + v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3, + _Tp s4, _Tp s5, _Tp s6, _Tp s7) + { + s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; + s[4] = s4; s[5] = s5; s[6] = s6; s[7] = s7; + } + + /** @brief Constructor + + Initializes register with sixteen 8-bit values */ + v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3, + _Tp s4, _Tp s5, _Tp s6, _Tp s7, + _Tp s8, _Tp s9, _Tp s10, _Tp s11, + _Tp s12, _Tp s13, _Tp s14, _Tp s15) + { + s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; + s[4] = s4; s[5] = s5; s[6] = s6; s[7] = s7; + s[8] = s8; s[9] = s9; s[10] = s10; s[11] = s11; + s[12] = s12; s[13] = s13; s[14] = s14; s[15] = s15; + } + + /** @brief Default constructor + + Does not initialize anything*/ + v_reg() {} + + /** @brief Copy constructor */ + v_reg(const v_reg<_Tp, n> & r) + { + for( int i = 0; i < n; i++ ) + s[i] = r.s[i]; + } + /** @brief Access first value + + Returns value of the first lane according to register type, for example: + @code{.cpp} + v_int32x4 r(1, 2, 3, 4); + int v = r.get0(); // returns 1 + v_uint64x2 r(1, 2); + uint64_t v = r.get0(); // returns 1 + @endcode + */ + _Tp get0() const { return s[0]; } + +//! @cond IGNORED + _Tp get(const int i) const { return s[i]; } + v_reg<_Tp, n> high() const + { + v_reg<_Tp, n> c; + int i; + for( i = 0; i < n/2; i++ ) + { + c.s[i] = s[i+(n/2)]; + c.s[i+(n/2)] = 0; + } + return c; + } + + static v_reg<_Tp, n> zero() + { + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = (_Tp)0; + return c; + } + + static v_reg<_Tp, n> all(_Tp s) + { + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = s; + return c; + } + + template v_reg<_Tp2, n2> reinterpret_as() const + { + size_t bytes = std::min(sizeof(_Tp2)*n2, sizeof(_Tp)*n); + v_reg<_Tp2, n2> c; + std::memcpy(&c.s[0], &s[0], bytes); + return c; + } + + v_reg& operator=(const v_reg<_Tp, n> & r) + { + for( int i = 0; i < n; i++ ) + s[i] = r.s[i]; + return *this; + } + + _Tp s[n]; +//! @endcond +}; + +/** @brief Sixteen 8-bit unsigned integer values */ +typedef v_reg v_uint8x16; +/** @brief Sixteen 8-bit signed integer values */ +typedef v_reg v_int8x16; +/** @brief Eight 16-bit unsigned integer values */ +typedef v_reg v_uint16x8; +/** @brief Eight 16-bit signed integer values */ +typedef v_reg v_int16x8; +/** @brief Four 32-bit unsigned integer values */ +typedef v_reg v_uint32x4; +/** @brief Four 32-bit signed integer values */ +typedef v_reg v_int32x4; +/** @brief Four 32-bit floating point values (single precision) */ +typedef v_reg v_float32x4; +/** @brief Two 64-bit floating point values (double precision) */ +typedef v_reg v_float64x2; +/** @brief Two 64-bit unsigned integer values */ +typedef v_reg v_uint64x2; +/** @brief Two 64-bit signed integer values */ +typedef v_reg v_int64x2; + +#if CV_SIMD256 +/** @brief Thirty two 8-bit unsigned integer values */ +typedef v_reg v_uint8x32; +/** @brief Thirty two 8-bit signed integer values */ +typedef v_reg v_int8x32; +/** @brief Sixteen 16-bit unsigned integer values */ +typedef v_reg v_uint16x16; +/** @brief Sixteen 16-bit signed integer values */ +typedef v_reg v_int16x16; +/** @brief Eight 32-bit unsigned integer values */ +typedef v_reg v_uint32x8; +/** @brief Eight 32-bit signed integer values */ +typedef v_reg v_int32x8; +/** @brief Eight 32-bit floating point values (single precision) */ +typedef v_reg v_float32x8; +/** @brief Four 64-bit floating point values (double precision) */ +typedef v_reg v_float64x4; +/** @brief Four 64-bit unsigned integer values */ +typedef v_reg v_uint64x4; +/** @brief Four 64-bit signed integer values */ +typedef v_reg v_int64x4; +#endif + +#if CV_SIMD512 +/** @brief Sixty four 8-bit unsigned integer values */ +typedef v_reg v_uint8x64; +/** @brief Sixty four 8-bit signed integer values */ +typedef v_reg v_int8x64; +/** @brief Thirty two 16-bit unsigned integer values */ +typedef v_reg v_uint16x32; +/** @brief Thirty two 16-bit signed integer values */ +typedef v_reg v_int16x32; +/** @brief Sixteen 32-bit unsigned integer values */ +typedef v_reg v_uint32x16; +/** @brief Sixteen 32-bit signed integer values */ +typedef v_reg v_int32x16; +/** @brief Sixteen 32-bit floating point values (single precision) */ +typedef v_reg v_float32x16; +/** @brief Eight 64-bit floating point values (double precision) */ +typedef v_reg v_float64x8; +/** @brief Eight 64-bit unsigned integer values */ +typedef v_reg v_uint64x8; +/** @brief Eight 64-bit signed integer values */ +typedef v_reg v_int64x8; +#endif + +enum { + simd128_width = 16, +#if CV_SIMD256 + simd256_width = 32, +#endif +#if CV_SIMD512 + simd512_width = 64, + simdmax_width = simd512_width +#elif CV_SIMD256 + simdmax_width = simd256_width +#else + simdmax_width = simd128_width +#endif +}; + +/** @brief Add values + +For all types. */ +template CV_INLINE v_reg<_Tp, n> operator+(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator+=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Subtract values + +For all types. */ +template CV_INLINE v_reg<_Tp, n> operator-(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator-=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Multiply values + +For 16- and 32-bit integer types and floating types. */ +template CV_INLINE v_reg<_Tp, n> operator*(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator*=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Divide values + +For floating types only. */ +template CV_INLINE v_reg<_Tp, n> operator/(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator/=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + + +/** @brief Bitwise AND + +Only for integer types. */ +template CV_INLINE v_reg<_Tp, n> operator&(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator&=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Bitwise OR + +Only for integer types. */ +template CV_INLINE v_reg<_Tp, n> operator|(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator|=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Bitwise XOR + +Only for integer types.*/ +template CV_INLINE v_reg<_Tp, n> operator^(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator^=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Bitwise NOT + +Only for integer types.*/ +template CV_INLINE v_reg<_Tp, n> operator~(const v_reg<_Tp, n>& a); + + +#ifndef CV_DOXYGEN + +#define CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(macro_name, ...) \ +__CV_EXPAND(macro_name(uchar, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(schar, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(ushort, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(short, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(unsigned, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(int, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(uint64, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(int64, __VA_ARGS__)) \ + +#define CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(macro_name, ...) \ +__CV_EXPAND(macro_name(float, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(double, __VA_ARGS__)) \ + +#define CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES(macro_name, ...) \ +CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(macro_name, __VA_ARGS__) \ +CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(macro_name, __VA_ARGS__) \ + +#define CV__HAL_INTRIN_IMPL_BIN_OP_(_Tp, bin_op) \ +template inline \ +v_reg<_Tp, n> operator bin_op (const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = saturate_cast<_Tp>(a.s[i] bin_op b.s[i]); \ + return c; \ +} \ +template inline \ +v_reg<_Tp, n>& operator bin_op##= (v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + for( int i = 0; i < n; i++ ) \ + a.s[i] = saturate_cast<_Tp>(a.s[i] bin_op b.s[i]); \ + return a; \ +} + +#define CV__HAL_INTRIN_IMPL_BIN_OP(bin_op) CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES(CV__HAL_INTRIN_IMPL_BIN_OP_, bin_op) + +CV__HAL_INTRIN_IMPL_BIN_OP(+) +CV__HAL_INTRIN_IMPL_BIN_OP(-) +CV__HAL_INTRIN_IMPL_BIN_OP(*) +CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(CV__HAL_INTRIN_IMPL_BIN_OP_, /) + +#define CV__HAL_INTRIN_IMPL_BIT_OP_(_Tp, bit_op) \ +template CV_INLINE \ +v_reg<_Tp, n> operator bit_op (const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + typedef typename V_TypeTraits<_Tp>::int_type itype; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int((itype)(V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) bit_op \ + V_TypeTraits<_Tp>::reinterpret_int(b.s[i]))); \ + return c; \ +} \ +template CV_INLINE \ +v_reg<_Tp, n>& operator bit_op##= (v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + typedef typename V_TypeTraits<_Tp>::int_type itype; \ + for( int i = 0; i < n; i++ ) \ + a.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int((itype)(V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) bit_op \ + V_TypeTraits<_Tp>::reinterpret_int(b.s[i]))); \ + return a; \ +} + +#define CV__HAL_INTRIN_IMPL_BIT_OP(bit_op) \ +CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(CV__HAL_INTRIN_IMPL_BIT_OP_, bit_op) \ +CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(CV__HAL_INTRIN_IMPL_BIT_OP_, bit_op) /* TODO: FIXIT remove this after masks refactoring */ + + +CV__HAL_INTRIN_IMPL_BIT_OP(&) +CV__HAL_INTRIN_IMPL_BIT_OP(|) +CV__HAL_INTRIN_IMPL_BIT_OP(^) + +#define CV__HAL_INTRIN_IMPL_BITWISE_NOT_(_Tp, dummy) \ +template CV_INLINE \ +v_reg<_Tp, n> operator ~ (const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int(~V_TypeTraits<_Tp>::reinterpret_int(a.s[i])); \ + return c; \ +} \ + +CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(CV__HAL_INTRIN_IMPL_BITWISE_NOT_, ~) + +#endif // !CV_DOXYGEN + + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_MATH_FUNC(func, cfunc, _Tp2) \ +template inline v_reg<_Tp2, n> func(const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp2, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = cfunc(a.s[i]); \ + return c; \ +} + +/** @brief Square root of elements + +Only for floating point types.*/ +OPENCV_HAL_IMPL_MATH_FUNC(v_sqrt, std::sqrt, _Tp) + +//! @cond IGNORED +OPENCV_HAL_IMPL_MATH_FUNC(v_sin, std::sin, _Tp) +OPENCV_HAL_IMPL_MATH_FUNC(v_cos, std::cos, _Tp) +OPENCV_HAL_IMPL_MATH_FUNC(v_exp, std::exp, _Tp) +OPENCV_HAL_IMPL_MATH_FUNC(v_log, std::log, _Tp) +//! @endcond + +/** @brief Absolute value of elements + +Only for floating point types.*/ +OPENCV_HAL_IMPL_MATH_FUNC(v_abs, (typename V_TypeTraits<_Tp>::abs_type)std::abs, + typename V_TypeTraits<_Tp>::abs_type) + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_MINMAX_FUNC(func, cfunc) \ +template inline v_reg<_Tp, n> func(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = cfunc(a.s[i], b.s[i]); \ + return c; \ +} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(func, cfunc) \ +template inline _Tp func(const v_reg<_Tp, n>& a) \ +{ \ + _Tp c = a.s[0]; \ + for( int i = 1; i < n; i++ ) \ + c = cfunc(c, a.s[i]); \ + return c; \ +} + +/** @brief Choose min values for each pair + +Scheme: +@code +{A1 A2 ...} +{B1 B2 ...} +-------------- +{min(A1,B1) min(A2,B2) ...} +@endcode +For all types except 64-bit integer. */ +OPENCV_HAL_IMPL_MINMAX_FUNC(v_min, std::min) + +/** @brief Choose max values for each pair + +Scheme: +@code +{A1 A2 ...} +{B1 B2 ...} +-------------- +{max(A1,B1) max(A2,B2) ...} +@endcode +For all types except 64-bit integer. */ +OPENCV_HAL_IMPL_MINMAX_FUNC(v_max, std::max) + +/** @brief Find one min value + +Scheme: +@code +{A1 A2 A3 ...} => min(A1,A2,A3,...) +@endcode +For all types except 64-bit integer and 64-bit floating point types. */ +OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(v_reduce_min, std::min) + +/** @brief Find one max value + +Scheme: +@code +{A1 A2 A3 ...} => max(A1,A2,A3,...) +@endcode +For all types except 64-bit integer and 64-bit floating point types. */ +OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(v_reduce_max, std::max) + +static const unsigned char popCountTable[] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; +/** @brief Count the 1 bits in the vector lanes and return result as corresponding unsigned type + +Scheme: +@code +{A1 A2 A3 ...} => {popcount(A1), popcount(A2), popcount(A3), ...} +@endcode +For all integer types. */ +template +inline v_reg::abs_type, n> v_popcount(const v_reg<_Tp, n>& a) +{ + v_reg::abs_type, n> b = v_reg::abs_type, n>::zero(); + for (int i = 0; i < n*(int)sizeof(_Tp); i++) + b.s[i/sizeof(_Tp)] += popCountTable[v_reinterpret_as_u8(a).s[i]]; + return b; +} + + +//! @cond IGNORED +template +inline void v_minmax( const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + v_reg<_Tp, n>& minval, v_reg<_Tp, n>& maxval ) +{ + for( int i = 0; i < n; i++ ) + { + minval.s[i] = std::min(a.s[i], b.s[i]); + maxval.s[i] = std::max(a.s[i], b.s[i]); + } +} +//! @endcond + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_CMP_OP(cmp_op) \ +template \ +inline v_reg<_Tp, n> operator cmp_op(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + typedef typename V_TypeTraits<_Tp>::int_type itype; \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int((itype)-(int)(a.s[i] cmp_op b.s[i])); \ + return c; \ +} + +/** @brief Less-than comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(<) + +/** @brief Greater-than comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(>) + +/** @brief Less-than or equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(<=) + +/** @brief Greater-than or equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(>=) + +/** @brief Equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(==) + +/** @brief Not equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(!=) + +template +inline v_reg v_not_nan(const v_reg& a) +{ + typedef typename V_TypeTraits::int_type itype; + v_reg c; + for (int i = 0; i < n; i++) + c.s[i] = V_TypeTraits::reinterpret_from_int((itype)-(int)(a.s[i] == a.s[i])); + return c; +} +template +inline v_reg v_not_nan(const v_reg& a) +{ + typedef typename V_TypeTraits::int_type itype; + v_reg c; + for (int i = 0; i < n; i++) + c.s[i] = V_TypeTraits::reinterpret_from_int((itype)-(int)(a.s[i] == a.s[i])); + return c; +} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_ARITHM_OP(func, bin_op, cast_op, _Tp2) \ +template \ +inline v_reg<_Tp2, n> func(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + typedef _Tp2 rtype; \ + v_reg c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = cast_op(a.s[i] bin_op b.s[i]); \ + return c; \ +} + +/** @brief Add values without saturation + +For 8- and 16-bit integer values. */ +OPENCV_HAL_IMPL_ARITHM_OP(v_add_wrap, +, (_Tp), _Tp) + +/** @brief Subtract values without saturation + +For 8- and 16-bit integer values. */ +OPENCV_HAL_IMPL_ARITHM_OP(v_sub_wrap, -, (_Tp), _Tp) + +/** @brief Multiply values without saturation + +For 8- and 16-bit integer values. */ +OPENCV_HAL_IMPL_ARITHM_OP(v_mul_wrap, *, (_Tp), _Tp) + +//! @cond IGNORED +template inline T _absdiff(T a, T b) +{ + return a > b ? a - b : b - a; +} +//! @endcond + +/** @brief Absolute difference + +Returns \f$ |a - b| \f$ converted to corresponding unsigned type. +Example: +@code{.cpp} +v_int32x4 a, b; // {1, 2, 3, 4} and {4, 3, 2, 1} +v_uint32x4 c = v_absdiff(a, b); // result is {3, 1, 1, 3} +@endcode +For 8-, 16-, 32-bit integer source types. */ +template +inline v_reg::abs_type, n> v_absdiff(const v_reg<_Tp, n>& a, const v_reg<_Tp, n> & b) +{ + typedef typename V_TypeTraits<_Tp>::abs_type rtype; + v_reg c; + const rtype mask = (rtype)(std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0); + for( int i = 0; i < n; i++ ) + { + rtype ua = a.s[i] ^ mask; + rtype ub = b.s[i] ^ mask; + c.s[i] = _absdiff(ua, ub); + } + return c; +} + +/** @overload + +For 32-bit floating point values */ +template inline v_reg v_absdiff(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + c.s[i] = _absdiff(a.s[i], b.s[i]); + return c; +} + +/** @overload + +For 64-bit floating point values */ +template inline v_reg v_absdiff(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + c.s[i] = _absdiff(a.s[i], b.s[i]); + return c; +} + +/** @brief Saturating absolute difference + +Returns \f$ saturate(|a - b|) \f$ . +For 8-, 16-bit signed integer source types. */ +template +inline v_reg<_Tp, n> v_absdiffs(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++) + c.s[i] = saturate_cast<_Tp>(std::abs(a.s[i] - b.s[i])); + return c; +} + +/** @brief Inversed square root + +Returns \f$ 1/sqrt(a) \f$ +For floating point types only. */ +template +inline v_reg<_Tp, n> v_invsqrt(const v_reg<_Tp, n>& a) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = 1.f/std::sqrt(a.s[i]); + return c; +} + +/** @brief Magnitude + +Returns \f$ sqrt(a^2 + b^2) \f$ +For floating point types only. */ +template +inline v_reg<_Tp, n> v_magnitude(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = std::sqrt(a.s[i]*a.s[i] + b.s[i]*b.s[i]); + return c; +} + +/** @brief Square of the magnitude + +Returns \f$ a^2 + b^2 \f$ +For floating point types only. */ +template +inline v_reg<_Tp, n> v_sqr_magnitude(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = a.s[i]*a.s[i] + b.s[i]*b.s[i]; + return c; +} + +/** @brief Multiply and add + + Returns \f$ a*b + c \f$ + For floating point types and signed 32bit int only. */ +template +inline v_reg<_Tp, n> v_fma(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg<_Tp, n>& c) +{ + v_reg<_Tp, n> d; + for( int i = 0; i < n; i++ ) + d.s[i] = a.s[i]*b.s[i] + c.s[i]; + return d; +} + +/** @brief A synonym for v_fma */ +template +inline v_reg<_Tp, n> v_muladd(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg<_Tp, n>& c) +{ + return v_fma(a, b, c); +} + +/** @brief Dot product of elements + +Multiply values in two registers and sum adjacent result pairs. + +Scheme: +@code + {A1 A2 ...} // 16-bit +x {B1 B2 ...} // 16-bit +------------- +{A1B1+A2B2 ...} // 32-bit + +@endcode +*/ +template inline v_reg::w_type, n/2> +v_dotprod(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (w_type)a.s[i*2]*b.s[i*2] + (w_type)a.s[i*2+1]*b.s[i*2+1]; + return c; +} + +/** @brief Dot product of elements + +Same as cv::v_dotprod, but add a third element to the sum of adjacent pairs. +Scheme: +@code + {A1 A2 ...} // 16-bit +x {B1 B2 ...} // 16-bit +------------- + {A1B1+A2B2+C1 ...} // 32-bit +@endcode +*/ +template inline v_reg::w_type, n/2> +v_dotprod(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::w_type, n / 2>& c) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg s; + for( int i = 0; i < (n/2); i++ ) + s.s[i] = (w_type)a.s[i*2]*b.s[i*2] + (w_type)a.s[i*2+1]*b.s[i*2+1] + c.s[i]; + return s; +} + +/** @brief Fast Dot product of elements + +Same as cv::v_dotprod, but it may perform unorder sum between result pairs in some platforms, +this intrinsic can be used if the sum among all lanes is only matters +and also it should be yielding better performance on the affected platforms. + +*/ +template inline v_reg::w_type, n/2> +v_dotprod_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ return v_dotprod(a, b); } + +/** @brief Fast Dot product of elements + +Same as cv::v_dotprod_fast, but add a third element to the sum of adjacent pairs. +*/ +template inline v_reg::w_type, n/2> +v_dotprod_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::w_type, n / 2>& c) +{ return v_dotprod(a, b, c); } + +/** @brief Dot product of elements and expand + +Multiply values in two registers and expand the sum of adjacent result pairs. + +Scheme: +@code + {A1 A2 A3 A4 ...} // 8-bit +x {B1 B2 B3 B4 ...} // 8-bit +------------- + {A1B1+A2B2+A3B3+A4B4 ...} // 32-bit + +@endcode +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg s; + for( int i = 0; i < (n/4); i++ ) + s.s[i] = (q_type)a.s[i*4 ]*b.s[i*4 ] + (q_type)a.s[i*4 + 1]*b.s[i*4 + 1] + + (q_type)a.s[i*4 + 2]*b.s[i*4 + 2] + (q_type)a.s[i*4 + 3]*b.s[i*4 + 3]; + return s; +} + +/** @brief Dot product of elements + +Same as cv::v_dotprod_expand, but add a third element to the sum of adjacent pairs. +Scheme: +@code + {A1 A2 A3 A4 ...} // 8-bit +x {B1 B2 B3 B4 ...} // 8-bit +------------- + {A1B1+A2B2+A3B3+A4B4+C1 ...} // 32-bit +@endcode +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::q_type, n / 4>& c) +{ + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg s; + for( int i = 0; i < (n/4); i++ ) + s.s[i] = (q_type)a.s[i*4 ]*b.s[i*4 ] + (q_type)a.s[i*4 + 1]*b.s[i*4 + 1] + + (q_type)a.s[i*4 + 2]*b.s[i*4 + 2] + (q_type)a.s[i*4 + 3]*b.s[i*4 + 3] + c.s[i]; + return s; +} + +/** @brief Fast Dot product of elements and expand + +Multiply values in two registers and expand the sum of adjacent result pairs. + +Same as cv::v_dotprod_expand, but it may perform unorder sum between result pairs in some platforms, +this intrinsic can be used if the sum among all lanes is only matters +and also it should be yielding better performance on the affected platforms. + +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ return v_dotprod_expand(a, b); } + +/** @brief Fast Dot product of elements + +Same as cv::v_dotprod_expand_fast, but add a third element to the sum of adjacent pairs. +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::q_type, n / 4>& c) +{ return v_dotprod_expand(a, b, c); } + +/** @brief Multiply and expand + +Multiply values two registers and store results in two registers with wider pack type. +Scheme: +@code + {A B C D} // 32-bit +x {E F G H} // 32-bit +--------------- +{AE BF} // 64-bit + {CG DH} // 64-bit +@endcode +Example: +@code{.cpp} +v_uint32x4 a, b; // {1,2,3,4} and {2,2,2,2} +v_uint64x2 c, d; // results +v_mul_expand(a, b, c, d); // c, d = {2,4}, {6, 8} +@endcode +Implemented only for 16- and unsigned 32-bit source types (v_int16x8, v_uint16x8, v_uint32x4). +*/ +template inline void v_mul_expand(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + v_reg::w_type, n/2>& c, + v_reg::w_type, n/2>& d) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = (w_type)a.s[i]*b.s[i]; + d.s[i] = (w_type)a.s[i+(n/2)]*b.s[i+(n/2)]; + } +} + +/** @brief Multiply and extract high part + +Multiply values two registers and store high part of the results. +Implemented only for 16-bit source types (v_int16x8, v_uint16x8). Returns \f$ a*b >> 16 \f$ +*/ +template inline v_reg<_Tp, n> v_mul_hi(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg<_Tp, n> c; + for (int i = 0; i < n; i++) + c.s[i] = (_Tp)(((w_type)a.s[i] * b.s[i]) >> sizeof(_Tp)*8); + return c; +} + +//! @cond IGNORED +template inline void v_hsum(const v_reg<_Tp, n>& a, + v_reg::w_type, n/2>& c) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = (w_type)a.s[i*2] + a.s[i*2+1]; + } +} +//! @endcond + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_SHIFT_OP(shift_op) \ +template inline v_reg<_Tp, n> operator shift_op(const v_reg<_Tp, n>& a, int imm) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = (_Tp)(a.s[i] shift_op imm); \ + return c; \ +} + +/** @brief Bitwise shift left + +For 16-, 32- and 64-bit integer values. */ +OPENCV_HAL_IMPL_SHIFT_OP(<< ) + +/** @brief Bitwise shift right + +For 16-, 32- and 64-bit integer values. */ +OPENCV_HAL_IMPL_SHIFT_OP(>> ) + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(suffix,opA,opB) \ +template inline v_reg<_Tp, n> v_rotate_##suffix(const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp, n> b; \ + for (int i = 0; i < n; i++) \ + { \ + int sIndex = i opA imm; \ + if (0 <= sIndex && sIndex < n) \ + { \ + b.s[i] = a.s[sIndex]; \ + } \ + else \ + { \ + b.s[i] = 0; \ + } \ + } \ + return b; \ +} \ +template inline v_reg<_Tp, n> v_rotate_##suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + for (int i = 0; i < n; i++) \ + { \ + int aIndex = i opA imm; \ + int bIndex = i opA imm opB n; \ + if (0 <= bIndex && bIndex < n) \ + { \ + c.s[i] = b.s[bIndex]; \ + } \ + else if (0 <= aIndex && aIndex < n) \ + { \ + c.s[i] = a.s[aIndex]; \ + } \ + else \ + { \ + c.s[i] = 0; \ + } \ + } \ + return c; \ +} + +/** @brief Element shift left among vector + +For all type */ +OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(left, -, +) + +/** @brief Element shift right among vector + +For all type */ +OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(right, +, -) + +/** @brief Sum packed values + +Scheme: +@code +{A1 A2 A3 ...} => sum{A1,A2,A3,...} +@endcode +*/ +template inline typename V_TypeTraits<_Tp>::sum_type v_reduce_sum(const v_reg<_Tp, n>& a) +{ + typename V_TypeTraits<_Tp>::sum_type c = a.s[0]; + for( int i = 1; i < n; i++ ) + c += a.s[i]; + return c; +} + +/** @brief Sums all elements of each input vector, returns the vector of sums + + Scheme: + @code + result[0] = a[0] + a[1] + a[2] + a[3] + result[1] = b[0] + b[1] + b[2] + b[3] + result[2] = c[0] + c[1] + c[2] + c[3] + result[3] = d[0] + d[1] + d[2] + d[3] + @endcode +*/ +template inline v_reg v_reduce_sum4(const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg r; + for(int i = 0; i < (n/4); i++) + { + r.s[i*4 + 0] = a.s[i*4 + 0] + a.s[i*4 + 1] + a.s[i*4 + 2] + a.s[i*4 + 3]; + r.s[i*4 + 1] = b.s[i*4 + 0] + b.s[i*4 + 1] + b.s[i*4 + 2] + b.s[i*4 + 3]; + r.s[i*4 + 2] = c.s[i*4 + 0] + c.s[i*4 + 1] + c.s[i*4 + 2] + c.s[i*4 + 3]; + r.s[i*4 + 3] = d.s[i*4 + 0] + d.s[i*4 + 1] + d.s[i*4 + 2] + d.s[i*4 + 3]; + } + return r; +} + +/** @brief Sum absolute differences of values + +Scheme: +@code +{A1 A2 A3 ...} {B1 B2 B3 ...} => sum{ABS(A1-B1),abs(A2-B2),abs(A3-B3),...} +@endcode +For all types except 64-bit types.*/ +template inline typename V_TypeTraits< typename V_TypeTraits<_Tp>::abs_type >::sum_type v_reduce_sad(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typename V_TypeTraits< typename V_TypeTraits<_Tp>::abs_type >::sum_type c = _absdiff(a.s[0], b.s[0]); + for (int i = 1; i < n; i++) + c += _absdiff(a.s[i], b.s[i]); + return c; +} + +/** @brief Get negative values mask +@deprecated v_signmask depends on a lane count heavily and therefore isn't universal enough + +Returned value is a bit mask with bits set to 1 on places corresponding to negative packed values indexes. +Example: +@code{.cpp} +v_int32x4 r; // set to {-1, -1, 1, 1} +int mask = v_signmask(r); // mask = 3 <== 00000000 00000000 00000000 00000011 +@endcode +*/ +template inline int v_signmask(const v_reg<_Tp, n>& a) +{ + int mask = 0; + for( int i = 0; i < n; i++ ) + mask |= (V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) < 0) << i; + return mask; +} + +/** @brief Get first negative lane index + +Returned value is an index of first negative lane (undefined for input of all positive values) +Example: +@code{.cpp} +v_int32x4 r; // set to {0, 0, -1, -1} +int idx = v_heading_zeros(r); // idx = 2 +@endcode +*/ +template inline int v_scan_forward(const v_reg<_Tp, n>& a) +{ + for (int i = 0; i < n; i++) + if(V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) < 0) + return i; + return 0; +} + +/** @brief Check if all packed values are less than zero + +Unsigned values will be casted to signed: `uchar 254 => char -2`. +*/ +template inline bool v_check_all(const v_reg<_Tp, n>& a) +{ + for( int i = 0; i < n; i++ ) + if( V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) >= 0 ) + return false; + return true; +} + +/** @brief Check if any of packed values is less than zero + +Unsigned values will be casted to signed: `uchar 254 => char -2`. +*/ +template inline bool v_check_any(const v_reg<_Tp, n>& a) +{ + for( int i = 0; i < n; i++ ) + if( V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) < 0 ) + return true; + return false; +} + +/** @brief Per-element select (blend operation) + +Return value will be built by combining values _a_ and _b_ using the following scheme: + result[i] = mask[i] ? a[i] : b[i]; + +@note: _mask_ element values are restricted to these values: +- 0: select element from _b_ +- 0xff/0xffff/etc: select element from _a_ +(fully compatible with bitwise-based operator) +*/ +template inline v_reg<_Tp, n> v_select(const v_reg<_Tp, n>& mask, + const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef V_TypeTraits<_Tp> Traits; + typedef typename Traits::int_type int_type; + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + { + int_type m = Traits::reinterpret_int(mask.s[i]); + CV_DbgAssert(m == 0 || m == (~(int_type)0)); // restrict mask values: 0 or 0xff/0xffff/etc + c.s[i] = m ? a.s[i] : b.s[i]; + } + return c; +} + +/** @brief Expand values to the wider pack type + +Copy contents of register to two registers with 2x wider pack type. +Scheme: +@code + int32x4 int64x2 int64x2 +{A B C D} ==> {A B} , {C D} +@endcode */ +template inline void v_expand(const v_reg<_Tp, n>& a, + v_reg::w_type, n/2>& b0, + v_reg::w_type, n/2>& b1) +{ + for( int i = 0; i < (n/2); i++ ) + { + b0.s[i] = a.s[i]; + b1.s[i] = a.s[i+(n/2)]; + } +} + +/** @brief Expand lower values to the wider pack type + +Same as cv::v_expand, but return lower half of the vector. + +Scheme: +@code + int32x4 int64x2 +{A B C D} ==> {A B} +@endcode */ +template +inline v_reg::w_type, n/2> +v_expand_low(const v_reg<_Tp, n>& a) +{ + v_reg::w_type, n/2> b; + for( int i = 0; i < (n/2); i++ ) + b.s[i] = a.s[i]; + return b; +} + +/** @brief Expand higher values to the wider pack type + +Same as cv::v_expand_low, but expand higher half of the vector instead. + +Scheme: +@code + int32x4 int64x2 +{A B C D} ==> {C D} +@endcode */ +template +inline v_reg::w_type, n/2> +v_expand_high(const v_reg<_Tp, n>& a) +{ + v_reg::w_type, n/2> b; + for( int i = 0; i < (n/2); i++ ) + b.s[i] = a.s[i+(n/2)]; + return b; +} + +//! @cond IGNORED +template inline v_reg::int_type, n> + v_reinterpret_as_int(const v_reg<_Tp, n>& a) +{ + v_reg::int_type, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = V_TypeTraits<_Tp>::reinterpret_int(a.s[i]); + return c; +} + +template inline v_reg::uint_type, n> + v_reinterpret_as_uint(const v_reg<_Tp, n>& a) +{ + v_reg::uint_type, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = V_TypeTraits<_Tp>::reinterpret_uint(a.s[i]); + return c; +} +//! @endcond + +/** @brief Interleave two vectors + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +--------------- + {A1 B1 A2 B2} and {A3 B3 A4 B4} +@endcode +For all types except 64-bit. +*/ +template inline void v_zip( const v_reg<_Tp, n>& a0, const v_reg<_Tp, n>& a1, + v_reg<_Tp, n>& b0, v_reg<_Tp, n>& b1 ) +{ + int i; + for( i = 0; i < n/2; i++ ) + { + b0.s[i*2] = a0.s[i]; + b0.s[i*2+1] = a1.s[i]; + } + for( ; i < n; i++ ) + { + b1.s[i*2-n] = a0.s[i]; + b1.s[i*2-n+1] = a1.s[i]; + } +} + +/** @brief Load register contents from memory + +@param ptr pointer to memory block with data +@return register object + +@note Returned type will be detected from passed pointer type, for example uchar ==> cv::v_uint8x16, int ==> cv::v_int32x4, etc. + +@note Use vx_load version to get maximum available register length result + +@note Alignment requirement: +if CV_STRONG_ALIGNMENT=1 then passed pointer must be aligned (`sizeof(lane type)` should be enough). +Do not cast pointer types without runtime check for pointer alignment (like `uchar*` => `int*`). + */ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + return v_reg<_Tp, simd128_width / sizeof(_Tp)>(ptr); +} + +#if CV_SIMD256 +/** @brief Load 256-bit length register contents from memory + +@param ptr pointer to memory block with data +@return register object + +@note Returned type will be detected from passed pointer type, for example uchar ==> cv::v_uint8x32, int ==> cv::v_int32x8, etc. + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load version to get maximum available register length result + +@note Alignment requirement: +if CV_STRONG_ALIGNMENT=1 then passed pointer must be aligned (`sizeof(lane type)` should be enough). +Do not cast pointer types without runtime check for pointer alignment (like `uchar*` => `int*`). + */ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + return v_reg<_Tp, simd256_width / sizeof(_Tp)>(ptr); +} +#endif + +#if CV_SIMD512 +/** @brief Load 512-bit length register contents from memory + +@param ptr pointer to memory block with data +@return register object + +@note Returned type will be detected from passed pointer type, for example uchar ==> cv::v_uint8x64, int ==> cv::v_int32x16, etc. + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load version to get maximum available register length result + +@note Alignment requirement: +if CV_STRONG_ALIGNMENT=1 then passed pointer must be aligned (`sizeof(lane type)` should be enough). +Do not cast pointer types without runtime check for pointer alignment (like `uchar*` => `int*`). + */ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + return v_reg<_Tp, simd512_width / sizeof(_Tp)>(ptr); +} +#endif + +/** @brief Load register contents from memory (aligned) + +similar to cv::v_load, but source memory block should be aligned (to 16-byte boundary in case of SIMD128, 32-byte - SIMD256, etc) + +@note Use vx_load_aligned version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load_aligned(const _Tp* ptr) +{ + CV_Assert(isAligned)>(ptr)); + return v_reg<_Tp, simd128_width / sizeof(_Tp)>(ptr); +} + +#if CV_SIMD256 +/** @brief Load register contents from memory (aligned) + +similar to cv::v256_load, but source memory block should be aligned (to 32-byte boundary in case of SIMD256, 64-byte - SIMD512, etc) + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_aligned version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load_aligned(const _Tp* ptr) +{ + CV_Assert(isAligned)>(ptr)); + return v_reg<_Tp, simd256_width / sizeof(_Tp)>(ptr); +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from memory (aligned) + +similar to cv::v512_load, but source memory block should be aligned (to 64-byte boundary in case of SIMD512, etc) + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_aligned version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load_aligned(const _Tp* ptr) +{ + CV_Assert(isAligned)>(ptr)); + return v_reg<_Tp, simd512_width / sizeof(_Tp)>(ptr); +} +#endif + +/** @brief Load 64-bits of data to lower part (high part is undefined). + +@param ptr memory block containing data for first half (0..n/2) + +@code{.cpp} +int lo[2] = { 1, 2 }; +v_int32x4 r = v_load_low(lo); +@endcode + +@note Use vx_load_low version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load_low(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for( int i = 0; i < c.nlanes/2; i++ ) + { + c.s[i] = ptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load 128-bits of data to lower part (high part is undefined). + +@param ptr memory block containing data for first half (0..n/2) + +@code{.cpp} +int lo[4] = { 1, 2, 3, 4 }; +v_int32x8 r = v256_load_low(lo); +@endcode + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_low version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load_low(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_reg<_Tp, simd256_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load 256-bits of data to lower part (high part is undefined). + +@param ptr memory block containing data for first half (0..n/2) + +@code{.cpp} +int lo[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; +v_int32x16 r = v512_load_low(lo); +@endcode + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_low version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load_low(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_reg<_Tp, simd512_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +/** @brief Load register contents from two memory blocks + +@param loptr memory block containing data for first half (0..n/2) +@param hiptr memory block containing data for second half (n/2..n) + +@code{.cpp} +int lo[2] = { 1, 2 }, hi[2] = { 3, 4 }; +v_int32x4 r = v_load_halves(lo, hi); +@endcode + +@note Use vx_load_halves version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load_halves(const _Tp* loptr, const _Tp* hiptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(loptr)); + CV_Assert(isAligned(hiptr)); +#endif + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for( int i = 0; i < c.nlanes/2; i++ ) + { + c.s[i] = loptr[i]; + c.s[i+c.nlanes/2] = hiptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load register contents from two memory blocks + +@param loptr memory block containing data for first half (0..n/2) +@param hiptr memory block containing data for second half (n/2..n) + +@code{.cpp} +int lo[4] = { 1, 2, 3, 4 }, hi[4] = { 5, 6, 7, 8 }; +v_int32x8 r = v256_load_halves(lo, hi); +@endcode + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_halves version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load_halves(const _Tp* loptr, const _Tp* hiptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(loptr)); + CV_Assert(isAligned(hiptr)); +#endif + v_reg<_Tp, simd256_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = loptr[i]; + c.s[i + c.nlanes / 2] = hiptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from two memory blocks + +@param loptr memory block containing data for first half (0..n/2) +@param hiptr memory block containing data for second half (n/2..n) + +@code{.cpp} +int lo[4] = { 1, 2, 3, 4, 5, 6, 7, 8 }, hi[4] = { 9, 10, 11, 12, 13, 14, 15, 16 }; +v_int32x16 r = v512_load_halves(lo, hi); +@endcode + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_halves version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load_halves(const _Tp* loptr, const _Tp* hiptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(loptr)); + CV_Assert(isAligned(hiptr)); +#endif + v_reg<_Tp, simd512_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = loptr[i]; + c.s[i + c.nlanes / 2] = hiptr[i]; + } + return c; +} +#endif + +/** @brief Load register contents from memory with double expand + +Same as cv::v_load, but result pack type will be 2x wider than memory type. + +@code{.cpp} +short buf[4] = {1, 2, 3, 4}; // type is int16 +v_int32x4 r = v_load_expand(buf); // r = {1, 2, 3, 4} - type is int32 +@endcode +For 8-, 16-, 32-bit integer source types. + +@note Use vx_load_expand version to get maximum available register length result +*/ +template +inline v_reg::w_type, simd128_width / sizeof(typename V_TypeTraits<_Tp>::w_type)> +v_load_expand(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + { + c.s[i] = ptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load register contents from memory with double expand + +Same as cv::v256_load, but result pack type will be 2x wider than memory type. + +@code{.cpp} +short buf[8] = {1, 2, 3, 4, 5, 6, 7, 8}; // type is int16 +v_int32x8 r = v256_load_expand(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8} - type is int32 +@endcode +For 8-, 16-, 32-bit integer source types. + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_expand version to get maximum available register length result +*/ +template +inline v_reg::w_type, simd256_width / sizeof(typename V_TypeTraits<_Tp>::w_type)> +v256_load_expand(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from memory with double expand + +Same as cv::v512_load, but result pack type will be 2x wider than memory type. + +@code{.cpp} +short buf[8] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // type is int16 +v_int32x16 r = v512_load_expand(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} - type is int32 +@endcode +For 8-, 16-, 32-bit integer source types. + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_expand version to get maximum available register length result +*/ +template +inline v_reg::w_type, simd512_width / sizeof(typename V_TypeTraits<_Tp>::w_type)> +v512_load_expand(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +/** @brief Load register contents from memory with quad expand + +Same as cv::v_load_expand, but result type is 4 times wider than source. +@code{.cpp} +char buf[4] = {1, 2, 3, 4}; // type is int8 +v_int32x4 r = v_load_expand_q(buf); // r = {1, 2, 3, 4} - type is int32 +@endcode +For 8-bit integer source types. + +@note Use vx_load_expand_q version to get maximum available register length result +*/ +template +inline v_reg::q_type, simd128_width / sizeof(typename V_TypeTraits<_Tp>::q_type)> +v_load_expand_q(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + { + c.s[i] = ptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load register contents from memory with quad expand + +Same as cv::v256_load_expand, but result type is 4 times wider than source. +@code{.cpp} +char buf[8] = {1, 2, 3, 4, 5, 6, 7, 8}; // type is int8 +v_int32x8 r = v256_load_expand_q(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8} - type is int32 +@endcode +For 8-bit integer source types. + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_expand_q version to get maximum available register length result +*/ +template +inline v_reg::q_type, simd256_width / sizeof(typename V_TypeTraits<_Tp>::q_type)> +v256_load_expand_q(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from memory with quad expand + +Same as cv::v512_load_expand, but result type is 4 times wider than source. +@code{.cpp} +char buf[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // type is int8 +v_int32x16 r = v512_load_expand_q(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} - type is int32 +@endcode +For 8-bit integer source types. + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_expand_q version to get maximum available register length result +*/ +template +inline v_reg::q_type, simd512_width / sizeof(typename V_TypeTraits<_Tp>::q_type)> +v512_load_expand_q(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +/** @brief Load and deinterleave (2 channels) + +Load data from memory deinterleave and store to 2 registers. +Scheme: +@code +{A1 B1 A2 B2 ...} ==> {A1 A2 ...}, {B1 B2 ...} +@endcode +For all types except 64-bit. */ +template inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a, + v_reg<_Tp, n>& b) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i2; + for( i = i2 = 0; i < n; i++, i2 += 2 ) + { + a.s[i] = ptr[i2]; + b.s[i] = ptr[i2+1]; + } +} + +/** @brief Load and deinterleave (3 channels) + +Load data from memory deinterleave and store to 3 registers. +Scheme: +@code +{A1 B1 C1 A2 B2 C2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...} +@endcode +For all types except 64-bit. */ +template inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a, + v_reg<_Tp, n>& b, v_reg<_Tp, n>& c) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i3; + for( i = i3 = 0; i < n; i++, i3 += 3 ) + { + a.s[i] = ptr[i3]; + b.s[i] = ptr[i3+1]; + c.s[i] = ptr[i3+2]; + } +} + +/** @brief Load and deinterleave (4 channels) + +Load data from memory deinterleave and store to 4 registers. +Scheme: +@code +{A1 B1 C1 D1 A2 B2 C2 D2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...} +@endcode +For all types except 64-bit. */ +template +inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a, + v_reg<_Tp, n>& b, v_reg<_Tp, n>& c, + v_reg<_Tp, n>& d) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i4; + for( i = i4 = 0; i < n; i++, i4 += 4 ) + { + a.s[i] = ptr[i4]; + b.s[i] = ptr[i4+1]; + c.s[i] = ptr[i4+2]; + d.s[i] = ptr[i4+3]; + } +} + +/** @brief Interleave and store (2 channels) + +Interleave and store data from 2 registers to memory. +Scheme: +@code +{A1 A2 ...}, {B1 B2 ...} ==> {A1 B1 A2 B2 ...} +@endcode +For all types except 64-bit. */ +template +inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a, + const v_reg<_Tp, n>& b, + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i2; + for( i = i2 = 0; i < n; i++, i2 += 2 ) + { + ptr[i2] = a.s[i]; + ptr[i2+1] = b.s[i]; + } +} + +/** @brief Interleave and store (3 channels) + +Interleave and store data from 3 registers to memory. +Scheme: +@code +{A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...} ==> {A1 B1 C1 A2 B2 C2 ...} +@endcode +For all types except 64-bit. */ +template +inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a, + const v_reg<_Tp, n>& b, const v_reg<_Tp, n>& c, + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i3; + for( i = i3 = 0; i < n; i++, i3 += 3 ) + { + ptr[i3] = a.s[i]; + ptr[i3+1] = b.s[i]; + ptr[i3+2] = c.s[i]; + } +} + +/** @brief Interleave and store (4 channels) + +Interleave and store data from 4 registers to memory. +Scheme: +@code +{A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...} ==> {A1 B1 C1 D1 A2 B2 C2 D2 ...} +@endcode +For all types except 64-bit. */ +template inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a, + const v_reg<_Tp, n>& b, const v_reg<_Tp, n>& c, + const v_reg<_Tp, n>& d, + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i4; + for( i = i4 = 0; i < n; i++, i4 += 4 ) + { + ptr[i4] = a.s[i]; + ptr[i4+1] = b.s[i]; + ptr[i4+2] = c.s[i]; + ptr[i4+3] = d.s[i]; + } +} + +/** @brief Store data to memory + +Store register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {A B C D} +@endcode +Pointer can be unaligned. */ +template +inline void v_store(_Tp* ptr, const v_reg<_Tp, n>& a) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + for( int i = 0; i < n; i++ ) + ptr[i] = a.s[i]; +} + +template +inline void v_store(_Tp* ptr, const v_reg<_Tp, n>& a, hal::StoreMode /*mode*/) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_store(ptr, a); +} + +/** @brief Store data to memory (lower half) + +Store lower half of register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {A B} +@endcode */ +template +inline void v_store_low(_Tp* ptr, const v_reg<_Tp, n>& a) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + for( int i = 0; i < (n/2); i++ ) + ptr[i] = a.s[i]; +} + +/** @brief Store data to memory (higher half) + +Store higher half of register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {C D} +@endcode */ +template +inline void v_store_high(_Tp* ptr, const v_reg<_Tp, n>& a) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + for( int i = 0; i < (n/2); i++ ) + ptr[i] = a.s[i+(n/2)]; +} + +/** @brief Store data to memory (aligned) + +Store register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {A B C D} +@endcode +Pointer __should__ be aligned by 16-byte boundary. */ +template +inline void v_store_aligned(_Tp* ptr, const v_reg<_Tp, n>& a) +{ + CV_Assert(isAligned)>(ptr)); + v_store(ptr, a); +} + +template +inline void v_store_aligned_nocache(_Tp* ptr, const v_reg<_Tp, n>& a) +{ + CV_Assert(isAligned)>(ptr)); + v_store(ptr, a); +} + +template +inline void v_store_aligned(_Tp* ptr, const v_reg<_Tp, n>& a, hal::StoreMode /*mode*/) +{ + CV_Assert(isAligned)>(ptr)); + v_store(ptr, a); +} + +/** @brief Combine vector from first elements of two vectors + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +--------------- + {A1 A2 B1 B2} +@endcode +For all types except 64-bit. */ +template +inline v_reg<_Tp, n> v_combine_low(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = a.s[i]; + c.s[i+(n/2)] = b.s[i]; + } + return c; +} + +/** @brief Combine vector from last elements of two vectors + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +--------------- + {A3 A4 B3 B4} +@endcode +For all types except 64-bit. */ +template +inline v_reg<_Tp, n> v_combine_high(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = a.s[i+(n/2)]; + c.s[i+(n/2)] = b.s[i+(n/2)]; + } + return c; +} + +/** @brief Combine two vectors from lower and higher parts of two other vectors + +@code{.cpp} +low = cv::v_combine_low(a, b); +high = cv::v_combine_high(a, b); +@endcode */ +template +inline void v_recombine(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + v_reg<_Tp, n>& low, v_reg<_Tp, n>& high) +{ + for( int i = 0; i < (n/2); i++ ) + { + low.s[i] = a.s[i]; + low.s[i+(n/2)] = b.s[i]; + high.s[i] = a.s[i+(n/2)]; + high.s[i+(n/2)] = b.s[i+(n/2)]; + } +} + +/** @brief Vector reverse order + +Reverse the order of the vector +Scheme: +@code + REG {A1 ... An} ==> REG {An ... A1} +@endcode +For all types. */ +template +inline v_reg<_Tp, n> v_reverse(const v_reg<_Tp, n>& a) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = a.s[n-i-1]; + return c; +} + +/** @brief Vector extract + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +======================== +shift = 1 {A2 A3 A4 B1} +shift = 2 {A3 A4 B1 B2} +shift = 3 {A4 B1 B2 B3} +@endcode +Restriction: 0 <= shift < nlanes + +Usage: +@code +v_int32x4 a, b, c; +c = v_extract<2>(a, b); +@endcode +For all types. */ +template +inline v_reg<_Tp, n> v_extract(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> r; + const int shift = n - s; + int i = 0; + for (; i < shift; ++i) + r.s[i] = a.s[i+s]; + for (; i < n; ++i) + r.s[i] = b.s[i-shift]; + return r; +} + +/** @brief Vector extract + +Scheme: +Return the s-th element of v. +Restriction: 0 <= s < nlanes + +Usage: +@code +v_int32x4 a; +int r; +r = v_extract_n<2>(a); +@endcode +For all types. */ +template +inline _Tp v_extract_n(const v_reg<_Tp, n>& v) +{ + CV_DbgAssert(s >= 0 && s < n); + return v.s[s]; +} + +/** @brief Broadcast i-th element of vector + +Scheme: +@code +{ v[0] v[1] v[2] ... v[SZ] } => { v[i], v[i], v[i] ... v[i] } +@endcode +Restriction: 0 <= i < nlanes +Supported types: 32-bit integers and floats (s32/u32/f32) + */ +template +inline v_reg<_Tp, n> v_broadcast_element(const v_reg<_Tp, n>& a) +{ + CV_DbgAssert(i >= 0 && i < n); + return v_reg<_Tp, n>::all(a.s[i]); +} + +/** @brief Round elements + +Rounds each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_round(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = cvRound(a.s[i]); + return c; +} + +/** @overload */ +template inline v_reg v_round(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvRound(a.s[i]); + c.s[i+n] = cvRound(b.s[i]); + } + return c; +} + +/** @brief Floor elements + +Floor each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_floor(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = cvFloor(a.s[i]); + return c; +} + +/** @brief Ceil elements + +Ceil each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_ceil(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = cvCeil(a.s[i]); + return c; +} + +/** @brief Truncate elements + +Truncate each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_trunc(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = (int)(a.s[i]); + return c; +} + +/** @overload */ +template inline v_reg v_round(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvRound(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @overload */ +template inline v_reg v_floor(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvFloor(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @overload */ +template inline v_reg v_ceil(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvCeil(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @overload */ +template inline v_reg v_trunc(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = (int)(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @brief Convert to float + +Supported input type is cv::v_int32. */ +template inline v_reg v_cvt_f32(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = (float)a.s[i]; + return c; +} + +/** @brief Convert lower half to float + +Supported input type is cv::v_float64. */ +template inline v_reg v_cvt_f32(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = (float)a.s[i]; + c.s[i+n] = 0; + } + return c; +} + +/** @brief Convert to float + +Supported input type is cv::v_float64. */ +template inline v_reg v_cvt_f32(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = (float)a.s[i]; + c.s[i+n] = (float)b.s[i]; + } + return c; +} + +/** @brief Convert lower half to double + +Supported input type is cv::v_int32. */ +template CV_INLINE v_reg v_cvt_f64(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i]; + return c; +} + +/** @brief Convert to double high part of vector + +Supported input type is cv::v_int32. */ +template CV_INLINE v_reg v_cvt_f64_high(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i + (n/2)]; + return c; +} + +/** @brief Convert lower half to double + +Supported input type is cv::v_float32. */ +template CV_INLINE v_reg v_cvt_f64(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i]; + return c; +} + +/** @brief Convert to double high part of vector + +Supported input type is cv::v_float32. */ +template CV_INLINE v_reg v_cvt_f64_high(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i + (n/2)]; + return c; +} + +/** @brief Convert to double + +Supported input type is cv::v_int64. */ +template CV_INLINE v_reg v_cvt_f64(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = (double)a.s[i]; + return c; +} + + +template inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_lut(const _Tp* tab, const int* idx) +{ + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes; i++) + c.s[i] = tab[idx[i]]; + return c; +} +template inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_lut_pairs(const _Tp* tab, const int* idx) +{ + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes; i++) + c.s[i] = tab[idx[i / 2] + i % 2]; + return c; +} +template inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_lut_quads(const _Tp* tab, const int* idx) +{ + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes; i++) + c.s[i] = tab[idx[i / 4] + i % 4]; + return c; +} + +template inline v_reg v_lut(const int* tab, const v_reg& idx) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = tab[idx.s[i]]; + return c; +} + +template inline v_reg v_lut(const unsigned* tab, const v_reg& idx) +{ + v_reg c; + for (int i = 0; i < n; i++) + c.s[i] = tab[idx.s[i]]; + return c; +} + +template inline v_reg v_lut(const float* tab, const v_reg& idx) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = tab[idx.s[i]]; + return c; +} + +template inline v_reg v_lut(const double* tab, const v_reg& idx) +{ + v_reg c; + for( int i = 0; i < n/2; i++ ) + c.s[i] = tab[idx.s[i]]; + return c; +} + + +template inline void v_lut_deinterleave(const float* tab, const v_reg& idx, + v_reg& x, v_reg& y) +{ + for( int i = 0; i < n; i++ ) + { + int j = idx.s[i]; + x.s[i] = tab[j]; + y.s[i] = tab[j+1]; + } +} + +template inline void v_lut_deinterleave(const double* tab, const v_reg& idx, + v_reg& x, v_reg& y) +{ + for( int i = 0; i < n; i++ ) + { + int j = idx.s[i]; + x.s[i] = tab[j]; + y.s[i] = tab[j+1]; + } +} + +template inline v_reg<_Tp, n> v_interleave_pairs(const v_reg<_Tp, n>& vec) +{ + v_reg<_Tp, n> c; + for (int i = 0; i < n/4; i++) + { + c.s[4*i ] = vec.s[4*i ]; + c.s[4*i+1] = vec.s[4*i+2]; + c.s[4*i+2] = vec.s[4*i+1]; + c.s[4*i+3] = vec.s[4*i+3]; + } + return c; +} + +template inline v_reg<_Tp, n> v_interleave_quads(const v_reg<_Tp, n>& vec) +{ + v_reg<_Tp, n> c; + for (int i = 0; i < n/8; i++) + { + c.s[8*i ] = vec.s[8*i ]; + c.s[8*i+1] = vec.s[8*i+4]; + c.s[8*i+2] = vec.s[8*i+1]; + c.s[8*i+3] = vec.s[8*i+5]; + c.s[8*i+4] = vec.s[8*i+2]; + c.s[8*i+5] = vec.s[8*i+6]; + c.s[8*i+6] = vec.s[8*i+3]; + c.s[8*i+7] = vec.s[8*i+7]; + } + return c; +} + +template inline v_reg<_Tp, n> v_pack_triplets(const v_reg<_Tp, n>& vec) +{ + v_reg<_Tp, n> c; + for (int i = 0; i < n/4; i++) + { + c.s[3*i ] = vec.s[4*i ]; + c.s[3*i+1] = vec.s[4*i+1]; + c.s[3*i+2] = vec.s[4*i+2]; + } + return c; +} + +/** @brief Transpose 4x4 matrix + +Scheme: +@code +a0 {A1 A2 A3 A4} +a1 {B1 B2 B3 B4} +a2 {C1 C2 C3 C4} +a3 {D1 D2 D3 D4} +=============== +b0 {A1 B1 C1 D1} +b1 {A2 B2 C2 D2} +b2 {A3 B3 C3 D3} +b3 {A4 B4 C4 D4} +@endcode +*/ +template +inline void v_transpose4x4( v_reg<_Tp, n>& a0, const v_reg<_Tp, n>& a1, + const v_reg<_Tp, n>& a2, const v_reg<_Tp, n>& a3, + v_reg<_Tp, n>& b0, v_reg<_Tp, n>& b1, + v_reg<_Tp, n>& b2, v_reg<_Tp, n>& b3 ) +{ + for (int i = 0; i < n / 4; i++) + { + b0.s[0 + i*4] = a0.s[0 + i*4]; b0.s[1 + i*4] = a1.s[0 + i*4]; + b0.s[2 + i*4] = a2.s[0 + i*4]; b0.s[3 + i*4] = a3.s[0 + i*4]; + b1.s[0 + i*4] = a0.s[1 + i*4]; b1.s[1 + i*4] = a1.s[1 + i*4]; + b1.s[2 + i*4] = a2.s[1 + i*4]; b1.s[3 + i*4] = a3.s[1 + i*4]; + b2.s[0 + i*4] = a0.s[2 + i*4]; b2.s[1 + i*4] = a1.s[2 + i*4]; + b2.s[2 + i*4] = a2.s[2 + i*4]; b2.s[3 + i*4] = a3.s[2 + i*4]; + b3.s[0 + i*4] = a0.s[3 + i*4]; b3.s[1 + i*4] = a1.s[3 + i*4]; + b3.s[2 + i*4] = a2.s[3 + i*4]; b3.s[3 + i*4] = a3.s[3 + i*4]; + } +} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_INIT_ZERO(_Tpvec, prefix, suffix) \ +inline _Tpvec prefix##_setzero_##suffix() { return _Tpvec::zero(); } + +//! @name Init with zero +//! @{ +//! @brief Create new vector with zero elements +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint8x16, v, u8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int8x16, v, s8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint16x8, v, u16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int16x8, v, s16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint32x4, v, u32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int32x4, v, s32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float32x4, v, f32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float64x2, v, f64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint64x2, v, u64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int64x2, v, s64) + +#if CV_SIMD256 +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint8x32, v256, u8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int8x32, v256, s8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint16x16, v256, u16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int16x16, v256, s16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint32x8, v256, u32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int32x8, v256, s32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float32x8, v256, f32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float64x4, v256, f64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint64x4, v256, u64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int64x4, v256, s64) +#endif + +#if CV_SIMD512 +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint8x64, v512, u8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int8x64, v512, s8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint16x32, v512, u16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int16x32, v512, s16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint32x16, v512, u32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int32x16, v512, s32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float32x16, v512, f32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float64x8, v512, f64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint64x8, v512, u64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int64x8, v512, s64) +#endif +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_INIT_VAL(_Tpvec, _Tp, prefix, suffix) \ +inline _Tpvec prefix##_setall_##suffix(_Tp val) { return _Tpvec::all(val); } + +//! @name Init with value +//! @{ +//! @brief Create new vector with elements set to a specific value +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint8x16, uchar, v, u8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int8x16, schar, v, s8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint16x8, ushort, v, u16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int16x8, short, v, s16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint32x4, unsigned, v, u32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int32x4, int, v, s32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float32x4, float, v, f32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float64x2, double, v, f64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint64x2, uint64, v, u64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int64x2, int64, v, s64) + +#if CV_SIMD256 +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint8x32, uchar, v256, u8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int8x32, schar, v256, s8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint16x16, ushort, v256, u16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int16x16, short, v256, s16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint32x8, unsigned, v256, u32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int32x8, int, v256, s32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float32x8, float, v256, f32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float64x4, double, v256, f64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint64x4, uint64, v256, u64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int64x4, int64, v256, s64) +#endif + +#if CV_SIMD512 +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint8x64, uchar, v512, u8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int8x64, schar, v512, s8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint16x32, ushort, v512, u16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int16x32, short, v512, s16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint32x16, unsigned, v512, u32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int32x16, int, v512, s32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float32x16, float, v512, f32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float64x8, double, v512, f64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint64x8, uint64, v512, u64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int64x8, int64, v512, s64) +#endif +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_REINTERPRET(_Tp, suffix) \ +template inline v_reg<_Tp, n0*sizeof(_Tp0)/sizeof(_Tp)> \ + v_reinterpret_as_##suffix(const v_reg<_Tp0, n0>& a) \ +{ return a.template reinterpret_as<_Tp, n0*sizeof(_Tp0)/sizeof(_Tp)>(); } + +//! @name Reinterpret +//! @{ +//! @brief Convert vector to different type without modifying underlying data. +OPENCV_HAL_IMPL_C_REINTERPRET(uchar, u8) +OPENCV_HAL_IMPL_C_REINTERPRET(schar, s8) +OPENCV_HAL_IMPL_C_REINTERPRET(ushort, u16) +OPENCV_HAL_IMPL_C_REINTERPRET(short, s16) +OPENCV_HAL_IMPL_C_REINTERPRET(unsigned, u32) +OPENCV_HAL_IMPL_C_REINTERPRET(int, s32) +OPENCV_HAL_IMPL_C_REINTERPRET(float, f32) +OPENCV_HAL_IMPL_C_REINTERPRET(double, f64) +OPENCV_HAL_IMPL_C_REINTERPRET(uint64, u64) +OPENCV_HAL_IMPL_C_REINTERPRET(int64, s64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_SHIFTL(_Tp) \ +template inline v_reg<_Tp, n> v_shl(const v_reg<_Tp, n>& a) \ +{ return a << shift; } + +//! @name Left shift +//! @{ +//! @brief Shift left +OPENCV_HAL_IMPL_C_SHIFTL(ushort) +OPENCV_HAL_IMPL_C_SHIFTL(short) +OPENCV_HAL_IMPL_C_SHIFTL(unsigned) +OPENCV_HAL_IMPL_C_SHIFTL(int) +OPENCV_HAL_IMPL_C_SHIFTL(uint64) +OPENCV_HAL_IMPL_C_SHIFTL(int64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_SHIFTR(_Tp) \ +template inline v_reg<_Tp, n> v_shr(const v_reg<_Tp, n>& a) \ +{ return a >> shift; } + +//! @name Right shift +//! @{ +//! @brief Shift right +OPENCV_HAL_IMPL_C_SHIFTR(ushort) +OPENCV_HAL_IMPL_C_SHIFTR(short) +OPENCV_HAL_IMPL_C_SHIFTR(unsigned) +OPENCV_HAL_IMPL_C_SHIFTR(int) +OPENCV_HAL_IMPL_C_SHIFTR(uint64) +OPENCV_HAL_IMPL_C_SHIFTR(int64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_RSHIFTR(_Tp) \ +template inline v_reg<_Tp, n> v_rshr(const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = (_Tp)((a.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ + return c; \ +} + +//! @name Rounding shift +//! @{ +//! @brief Rounding shift right +OPENCV_HAL_IMPL_C_RSHIFTR(ushort) +OPENCV_HAL_IMPL_C_RSHIFTR(short) +OPENCV_HAL_IMPL_C_RSHIFTR(unsigned) +OPENCV_HAL_IMPL_C_RSHIFTR(int) +OPENCV_HAL_IMPL_C_RSHIFTR(uint64) +OPENCV_HAL_IMPL_C_RSHIFTR(int64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_PACK(_Tp, _Tpn, pack_suffix, cast) \ +template inline v_reg<_Tpn, 2*n> v_##pack_suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tpn, 2*n> c; \ + for( int i = 0; i < n; i++ ) \ + { \ + c.s[i] = cast<_Tpn>(a.s[i]); \ + c.s[i+n] = cast<_Tpn>(b.s[i]); \ + } \ + return c; \ +} + +//! @name Pack +//! @{ +//! @brief Pack values from two vectors to one +//! +//! Return vector type have twice more elements than input vector types. Variant with _u_ suffix also +//! converts to corresponding unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_PACK(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(int, ushort, pack_u, saturate_cast) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_RSHR_PACK(_Tp, _Tpn, pack_suffix, cast) \ +template inline v_reg<_Tpn, 2*n> v_rshr_##pack_suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tpn, 2*n> c; \ + for( int i = 0; i < n; i++ ) \ + { \ + c.s[i] = cast<_Tpn>((a.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ + c.s[i+n] = cast<_Tpn>((b.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ + } \ + return c; \ +} + +//! @name Pack with rounding shift +//! @{ +//! @brief Pack values from two vectors to one with rounding shift +//! +//! Values from the input vectors will be shifted right by _n_ bits with rounding, converted to narrower +//! type and returned in the result vector. Variant with _u_ suffix converts to unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_RSHR_PACK(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(int, ushort, pack_u, saturate_cast) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_PACK_STORE(_Tp, _Tpn, pack_suffix, cast) \ +template inline void v_##pack_suffix##_store(_Tpn* ptr, const v_reg<_Tp, n>& a) \ +{ \ + for( int i = 0; i < n; i++ ) \ + ptr[i] = cast<_Tpn>(a.s[i]); \ +} + +//! @name Pack and store +//! @{ +//! @brief Store values from the input vector into memory with pack +//! +//! Values will be stored into memory with conversion to narrower type. +//! Variant with _u_ suffix converts to corresponding unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_PACK_STORE(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(int, ushort, pack_u, saturate_cast) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(_Tp, _Tpn, pack_suffix, cast) \ +template inline void v_rshr_##pack_suffix##_store(_Tpn* ptr, const v_reg<_Tp, n>& a) \ +{ \ + for( int i = 0; i < n; i++ ) \ + ptr[i] = cast<_Tpn>((a.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ +} + +//! @name Pack and store with rounding shift +//! @{ +//! @brief Store values from the input vector into memory with pack +//! +//! Values will be shifted _n_ bits right with rounding, converted to narrower type and stored into +//! memory. Variant with _u_ suffix converts to unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(int, ushort, pack_u, saturate_cast) +//! @} + +//! @cond IGNORED +template +inline void _pack_b(_Tpm* mptr, const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + for (int i = 0; i < n; ++i) + { + mptr[i] = (_Tpm)a.s[i]; + mptr[i + n] = (_Tpm)b.s[i]; + } +} +//! @endcond + +//! @name Pack boolean values +//! @{ +//! @brief Pack boolean values from multiple vectors to one unsigned 8-bit integer vector +//! +//! @note Must provide valid boolean values to guarantee same result for all architectures. + +/** @brief +//! For 16-bit boolean values + +Scheme: +@code +a {0xFFFF 0 0 0xFFFF 0 0xFFFF 0xFFFF 0} +b {0xFFFF 0 0xFFFF 0 0 0xFFFF 0 0xFFFF} +=============== +{ + 0xFF 0 0 0xFF 0 0xFF 0xFF 0 + 0xFF 0 0xFF 0 0 0xFF 0 0xFF +} +@endcode */ + +template inline v_reg v_pack_b(const v_reg& a, const v_reg& b) +{ + v_reg mask; + _pack_b(mask.s, a, b); + return mask; +} + +/** @overload +For 32-bit boolean values + +Scheme: +@code +a {0xFFFF.. 0 0 0xFFFF..} +b {0 0xFFFF.. 0xFFFF.. 0} +c {0xFFFF.. 0 0xFFFF.. 0} +d {0 0xFFFF.. 0 0xFFFF..} +=============== +{ + 0xFF 0 0 0xFF 0 0xFF 0xFF 0 + 0xFF 0 0xFF 0 0 0xFF 0 0xFF +} +@endcode */ + +template inline v_reg v_pack_b(const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg mask; + _pack_b(mask.s, a, b); + _pack_b(mask.s + 2*n, c, d); + return mask; +} + +/** @overload +For 64-bit boolean values + +Scheme: +@code +a {0xFFFF.. 0} +b {0 0xFFFF..} +c {0xFFFF.. 0} +d {0 0xFFFF..} + +e {0xFFFF.. 0} +f {0xFFFF.. 0} +g {0 0xFFFF..} +h {0 0xFFFF..} +=============== +{ + 0xFF 0 0 0xFF 0xFF 0 0 0xFF + 0xFF 0 0xFF 0 0 0xFF 0 0xFF +} +@endcode */ +template inline v_reg v_pack_b(const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d, + const v_reg& e, const v_reg& f, + const v_reg& g, const v_reg& h) +{ + v_reg mask; + _pack_b(mask.s, a, b); + _pack_b(mask.s + 2*n, c, d); + _pack_b(mask.s + 4*n, e, f); + _pack_b(mask.s + 6*n, g, h); + return mask; +} +//! @} + +/** @brief Matrix multiplication + +Scheme: +@code +{A0 A1 A2 A3} |V0| +{B0 B1 B2 B3} |V1| +{C0 C1 C2 C3} |V2| +{D0 D1 D2 D3} x |V3| +==================== +{R0 R1 R2 R3}, where: +R0 = A0V0 + B0V1 + C0V2 + D0V3, +R1 = A1V0 + B1V1 + C1V2 + D1V3 +... +@endcode +*/ +template +inline v_reg v_matmul(const v_reg& v, + const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg res; + for (int i = 0; i < n / 4; i++) + { + res.s[0 + i*4] = v.s[0 + i*4] * a.s[0 + i*4] + v.s[1 + i*4] * b.s[0 + i*4] + v.s[2 + i*4] * c.s[0 + i*4] + v.s[3 + i*4] * d.s[0 + i*4]; + res.s[1 + i*4] = v.s[0 + i*4] * a.s[1 + i*4] + v.s[1 + i*4] * b.s[1 + i*4] + v.s[2 + i*4] * c.s[1 + i*4] + v.s[3 + i*4] * d.s[1 + i*4]; + res.s[2 + i*4] = v.s[0 + i*4] * a.s[2 + i*4] + v.s[1 + i*4] * b.s[2 + i*4] + v.s[2 + i*4] * c.s[2 + i*4] + v.s[3 + i*4] * d.s[2 + i*4]; + res.s[3 + i*4] = v.s[0 + i*4] * a.s[3 + i*4] + v.s[1 + i*4] * b.s[3 + i*4] + v.s[2 + i*4] * c.s[3 + i*4] + v.s[3 + i*4] * d.s[3 + i*4]; + } + return res; +} + +/** @brief Matrix multiplication and add + +Scheme: +@code +{A0 A1 A2 A3} |V0| |D0| +{B0 B1 B2 B3} |V1| |D1| +{C0 C1 C2 C3} x |V2| + |D2| +==================== |D3| +{R0 R1 R2 R3}, where: +R0 = A0V0 + B0V1 + C0V2 + D0, +R1 = A1V0 + B1V1 + C1V2 + D1 +... +@endcode +*/ +template +inline v_reg v_matmuladd(const v_reg& v, + const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg res; + for (int i = 0; i < n / 4; i++) + { + res.s[0 + i * 4] = v.s[0 + i * 4] * a.s[0 + i * 4] + v.s[1 + i * 4] * b.s[0 + i * 4] + v.s[2 + i * 4] * c.s[0 + i * 4] + d.s[0 + i * 4]; + res.s[1 + i * 4] = v.s[0 + i * 4] * a.s[1 + i * 4] + v.s[1 + i * 4] * b.s[1 + i * 4] + v.s[2 + i * 4] * c.s[1 + i * 4] + d.s[1 + i * 4]; + res.s[2 + i * 4] = v.s[0 + i * 4] * a.s[2 + i * 4] + v.s[1 + i * 4] * b.s[2 + i * 4] + v.s[2 + i * 4] * c.s[2 + i * 4] + d.s[2 + i * 4]; + res.s[3 + i * 4] = v.s[0 + i * 4] * a.s[3 + i * 4] + v.s[1 + i * 4] * b.s[3 + i * 4] + v.s[2 + i * 4] * c.s[3 + i * 4] + d.s[3 + i * 4]; + } + return res; +} + + +template inline v_reg v_dotprod_expand(const v_reg& a, const v_reg& b) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_cvt_f64_high(a) * v_cvt_f64_high(b)); } +template inline v_reg v_dotprod_expand(const v_reg& a, const v_reg& b, + const v_reg& c) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_fma(v_cvt_f64_high(a), v_cvt_f64_high(b), c)); } + +template inline v_reg v_dotprod_expand_fast(const v_reg& a, const v_reg& b) +{ return v_dotprod_expand(a, b); } +template inline v_reg v_dotprod_expand_fast(const v_reg& a, const v_reg& b, + const v_reg& c) +{ return v_dotprod_expand(a, b, c); } + +////// FP16 support /////// + +inline v_reg +v_load_expand(const float16_t* ptr) +{ + v_reg v; + for( int i = 0; i < v.nlanes; i++ ) + { + v.s[i] = ptr[i]; + } + return v; +} +#if CV_SIMD256 +inline v_reg +v256_load_expand(const float16_t* ptr) +{ + v_reg v; + for (int i = 0; i < v.nlanes; i++) + { + v.s[i] = ptr[i]; + } + return v; +} +#endif +#if CV_SIMD512 +inline v_reg +v512_load_expand(const float16_t* ptr) +{ + v_reg v; + for (int i = 0; i < v.nlanes; i++) + { + v.s[i] = ptr[i]; + } + return v; +} +#endif + +template inline void +v_pack_store(float16_t* ptr, const v_reg& v) +{ + for( int i = 0; i < v.nlanes; i++ ) + { + ptr[i] = float16_t(v.s[i]); + } +} + +inline void v_cleanup() {} +#if CV_SIMD256 +inline void v256_cleanup() {} +#endif +#if CV_SIMD512 +inline void v512_cleanup() {} +#endif + +//! @} + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END +#endif +} + +#if !defined(CV_DOXYGEN) +#undef CV_SIMD256 +#undef CV_SIMD512 +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_forward.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_forward.hpp new file mode 100644 index 0000000..979f15a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_forward.hpp @@ -0,0 +1,191 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef CV__SIMD_FORWARD +#error "Need to pre-define forward width" +#endif + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +/** Types **/ +#if CV__SIMD_FORWARD == 1024 +// [todo] 1024 +#error "1024-long ops not implemented yet" +#elif CV__SIMD_FORWARD == 512 +// 512 +#define __CV_VX(fun) v512_##fun +#define __CV_V_UINT8 v_uint8x64 +#define __CV_V_INT8 v_int8x64 +#define __CV_V_UINT16 v_uint16x32 +#define __CV_V_INT16 v_int16x32 +#define __CV_V_UINT32 v_uint32x16 +#define __CV_V_INT32 v_int32x16 +#define __CV_V_UINT64 v_uint64x8 +#define __CV_V_INT64 v_int64x8 +#define __CV_V_FLOAT32 v_float32x16 +#define __CV_V_FLOAT64 v_float64x8 +struct v_uint8x64; +struct v_int8x64; +struct v_uint16x32; +struct v_int16x32; +struct v_uint32x16; +struct v_int32x16; +struct v_uint64x8; +struct v_int64x8; +struct v_float32x16; +struct v_float64x8; +#elif CV__SIMD_FORWARD == 256 +// 256 +#define __CV_VX(fun) v256_##fun +#define __CV_V_UINT8 v_uint8x32 +#define __CV_V_INT8 v_int8x32 +#define __CV_V_UINT16 v_uint16x16 +#define __CV_V_INT16 v_int16x16 +#define __CV_V_UINT32 v_uint32x8 +#define __CV_V_INT32 v_int32x8 +#define __CV_V_UINT64 v_uint64x4 +#define __CV_V_INT64 v_int64x4 +#define __CV_V_FLOAT32 v_float32x8 +#define __CV_V_FLOAT64 v_float64x4 +struct v_uint8x32; +struct v_int8x32; +struct v_uint16x16; +struct v_int16x16; +struct v_uint32x8; +struct v_int32x8; +struct v_uint64x4; +struct v_int64x4; +struct v_float32x8; +struct v_float64x4; +#else +// 128 +#define __CV_VX(fun) v_##fun +#define __CV_V_UINT8 v_uint8x16 +#define __CV_V_INT8 v_int8x16 +#define __CV_V_UINT16 v_uint16x8 +#define __CV_V_INT16 v_int16x8 +#define __CV_V_UINT32 v_uint32x4 +#define __CV_V_INT32 v_int32x4 +#define __CV_V_UINT64 v_uint64x2 +#define __CV_V_INT64 v_int64x2 +#define __CV_V_FLOAT32 v_float32x4 +#define __CV_V_FLOAT64 v_float64x2 +struct v_uint8x16; +struct v_int8x16; +struct v_uint16x8; +struct v_int16x8; +struct v_uint32x4; +struct v_int32x4; +struct v_uint64x2; +struct v_int64x2; +struct v_float32x4; +struct v_float64x2; +#endif + +/** Value reordering **/ + +// Expansion +void v_expand(const __CV_V_UINT8&, __CV_V_UINT16&, __CV_V_UINT16&); +void v_expand(const __CV_V_INT8&, __CV_V_INT16&, __CV_V_INT16&); +void v_expand(const __CV_V_UINT16&, __CV_V_UINT32&, __CV_V_UINT32&); +void v_expand(const __CV_V_INT16&, __CV_V_INT32&, __CV_V_INT32&); +void v_expand(const __CV_V_UINT32&, __CV_V_UINT64&, __CV_V_UINT64&); +void v_expand(const __CV_V_INT32&, __CV_V_INT64&, __CV_V_INT64&); +// Low Expansion +__CV_V_UINT16 v_expand_low(const __CV_V_UINT8&); +__CV_V_INT16 v_expand_low(const __CV_V_INT8&); +__CV_V_UINT32 v_expand_low(const __CV_V_UINT16&); +__CV_V_INT32 v_expand_low(const __CV_V_INT16&); +__CV_V_UINT64 v_expand_low(const __CV_V_UINT32&); +__CV_V_INT64 v_expand_low(const __CV_V_INT32&); +// High Expansion +__CV_V_UINT16 v_expand_high(const __CV_V_UINT8&); +__CV_V_INT16 v_expand_high(const __CV_V_INT8&); +__CV_V_UINT32 v_expand_high(const __CV_V_UINT16&); +__CV_V_INT32 v_expand_high(const __CV_V_INT16&); +__CV_V_UINT64 v_expand_high(const __CV_V_UINT32&); +__CV_V_INT64 v_expand_high(const __CV_V_INT32&); +// Load & Low Expansion +__CV_V_UINT16 __CV_VX(load_expand)(const uchar*); +__CV_V_INT16 __CV_VX(load_expand)(const schar*); +__CV_V_UINT32 __CV_VX(load_expand)(const ushort*); +__CV_V_INT32 __CV_VX(load_expand)(const short*); +__CV_V_UINT64 __CV_VX(load_expand)(const uint*); +__CV_V_INT64 __CV_VX(load_expand)(const int*); +// Load lower 8-bit and expand into 32-bit +__CV_V_UINT32 __CV_VX(load_expand_q)(const uchar*); +__CV_V_INT32 __CV_VX(load_expand_q)(const schar*); + +// Saturating Pack +__CV_V_UINT8 v_pack(const __CV_V_UINT16&, const __CV_V_UINT16&); +__CV_V_INT8 v_pack(const __CV_V_INT16&, const __CV_V_INT16&); +__CV_V_UINT16 v_pack(const __CV_V_UINT32&, const __CV_V_UINT32&); +__CV_V_INT16 v_pack(const __CV_V_INT32&, const __CV_V_INT32&); +// Non-saturating Pack +__CV_V_UINT32 v_pack(const __CV_V_UINT64&, const __CV_V_UINT64&); +__CV_V_INT32 v_pack(const __CV_V_INT64&, const __CV_V_INT64&); +// Pack signed integers with unsigned saturation +__CV_V_UINT8 v_pack_u(const __CV_V_INT16&, const __CV_V_INT16&); +__CV_V_UINT16 v_pack_u(const __CV_V_INT32&, const __CV_V_INT32&); + +/** Arithmetic, bitwise and comparison operations **/ + +// Non-saturating multiply +#if CV_VSX +template +Tvec v_mul_wrap(const Tvec& a, const Tvec& b); +#else +__CV_V_UINT8 v_mul_wrap(const __CV_V_UINT8&, const __CV_V_UINT8&); +__CV_V_INT8 v_mul_wrap(const __CV_V_INT8&, const __CV_V_INT8&); +__CV_V_UINT16 v_mul_wrap(const __CV_V_UINT16&, const __CV_V_UINT16&); +__CV_V_INT16 v_mul_wrap(const __CV_V_INT16&, const __CV_V_INT16&); +#endif + +// Multiply and expand +#if CV_VSX +template +void v_mul_expand(const Tvec& a, const Tvec& b, Twvec& c, Twvec& d); +#else +void v_mul_expand(const __CV_V_UINT8&, const __CV_V_UINT8&, __CV_V_UINT16&, __CV_V_UINT16&); +void v_mul_expand(const __CV_V_INT8&, const __CV_V_INT8&, __CV_V_INT16&, __CV_V_INT16&); +void v_mul_expand(const __CV_V_UINT16&, const __CV_V_UINT16&, __CV_V_UINT32&, __CV_V_UINT32&); +void v_mul_expand(const __CV_V_INT16&, const __CV_V_INT16&, __CV_V_INT32&, __CV_V_INT32&); +void v_mul_expand(const __CV_V_UINT32&, const __CV_V_UINT32&, __CV_V_UINT64&, __CV_V_UINT64&); +void v_mul_expand(const __CV_V_INT32&, const __CV_V_INT32&, __CV_V_INT64&, __CV_V_INT64&); +#endif + +// Conversions +__CV_V_FLOAT32 v_cvt_f32(const __CV_V_INT32& a); +__CV_V_FLOAT32 v_cvt_f32(const __CV_V_FLOAT64& a); +__CV_V_FLOAT32 v_cvt_f32(const __CV_V_FLOAT64& a, const __CV_V_FLOAT64& b); +__CV_V_FLOAT64 v_cvt_f64(const __CV_V_INT32& a); +__CV_V_FLOAT64 v_cvt_f64_high(const __CV_V_INT32& a); +__CV_V_FLOAT64 v_cvt_f64(const __CV_V_FLOAT32& a); +__CV_V_FLOAT64 v_cvt_f64_high(const __CV_V_FLOAT32& a); +__CV_V_FLOAT64 v_cvt_f64(const __CV_V_INT64& a); + +/** Cleanup **/ +#undef CV__SIMD_FORWARD +#undef __CV_VX +#undef __CV_V_UINT8 +#undef __CV_V_INT8 +#undef __CV_V_UINT16 +#undef __CV_V_INT16 +#undef __CV_V_UINT32 +#undef __CV_V_INT32 +#undef __CV_V_UINT64 +#undef __CV_V_INT64 +#undef __CV_V_FLOAT32 +#undef __CV_V_FLOAT64 + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: \ No newline at end of file diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_msa.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_msa.hpp new file mode 100644 index 0000000..a1fbb09 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_msa.hpp @@ -0,0 +1,1887 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_HAL_INTRIN_MSA_HPP +#define OPENCV_HAL_INTRIN_MSA_HPP + +#include +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @cond IGNORED +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 + +//MSA implements 128-bit wide vector registers shared with the 64-bit wide floating-point unit registers. +//MSA and FPU can not be both present, unless the FPU has 64-bit floating-point registers. +#define CV_SIMD128_64F 1 + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(v16u8 v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = msa_ld1q_u8(v); + } + + uchar get0() const + { + return msa_getq_lane_u8(val, 0); + } + + v16u8 val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(v16i8 v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = msa_ld1q_s8(v); + } + + schar get0() const + { + return msa_getq_lane_s8(val, 0); + } + + v16i8 val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(v8u16 v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = msa_ld1q_u16(v); + } + + ushort get0() const + { + return msa_getq_lane_u16(val, 0); + } + + v8u16 val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(v8i16 v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = msa_ld1q_s16(v); + } + + short get0() const + { + return msa_getq_lane_s16(val, 0); + } + + v8i16 val; +}; + +struct v_uint32x4 +{ + typedef unsigned int lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(v4u32 v) : val(v) {} + v_uint32x4(unsigned int v0, unsigned int v1, unsigned int v2, unsigned int v3) + { + unsigned int v[] = {v0, v1, v2, v3}; + val = msa_ld1q_u32(v); + } + + unsigned int get0() const + { + return msa_getq_lane_u32(val, 0); + } + + v4u32 val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(v4i32 v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = msa_ld1q_s32(v); + } + + int get0() const + { + return msa_getq_lane_s32(val, 0); + } + + v4i32 val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(v4f32 v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = msa_ld1q_f32(v); + } + + float get0() const + { + return msa_getq_lane_f32(val, 0); + } + + v4f32 val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(v2u64 v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = msa_ld1q_u64(v); + } + + uint64 get0() const + { + return msa_getq_lane_u64(val, 0); + } + + v2u64 val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(v2i64 v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = msa_ld1q_s64(v); + } + + int64 get0() const + { + return msa_getq_lane_s64(val, 0); + } + + v2i64 val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(v2f64 v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = msa_ld1q_f64(v); + } + + double get0() const + { + return msa_getq_lane_f64(val, 0); + } + + v2f64 val; +}; + +#define OPENCV_HAL_IMPL_MSA_INIT(_Tpv, _Tp, suffix) \ +inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(msa_dupq_n_##suffix((_Tp)0)); } \ +inline v_##_Tpv v_setall_##suffix(_Tp v) { return v_##_Tpv(msa_dupq_n_##suffix(v)); } \ +inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16(MSA_TPV_REINTERPRET(v16u8, v.val)); } \ +inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16(MSA_TPV_REINTERPRET(v16i8, v.val)); } \ +inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8(MSA_TPV_REINTERPRET(v8u16, v.val)); } \ +inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8(MSA_TPV_REINTERPRET(v8i16, v.val)); } \ +inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4(MSA_TPV_REINTERPRET(v4u32, v.val)); } \ +inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4(MSA_TPV_REINTERPRET(v4i32, v.val)); } \ +inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2(MSA_TPV_REINTERPRET(v2u64, v.val)); } \ +inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2(MSA_TPV_REINTERPRET(v2i64, v.val)); } \ +inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4(MSA_TPV_REINTERPRET(v4f32, v.val)); } \ +inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2(MSA_TPV_REINTERPRET(v2f64, v.val)); } + +OPENCV_HAL_IMPL_MSA_INIT(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_MSA_INIT(int8x16, schar, s8) +OPENCV_HAL_IMPL_MSA_INIT(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_MSA_INIT(int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_INIT(uint32x4, unsigned int, u32) +OPENCV_HAL_IMPL_MSA_INIT(int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_INIT(uint64x2, uint64, u64) +OPENCV_HAL_IMPL_MSA_INIT(int64x2, int64, s64) +OPENCV_HAL_IMPL_MSA_INIT(float32x4, float, f32) +OPENCV_HAL_IMPL_MSA_INIT(float64x2, double, f64) + +#define OPENCV_HAL_IMPL_MSA_PACK(_Tpvec, _Tpwvec, pack, mov, rshr) \ +inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + return _Tpvec(mov(a.val, b.val)); \ +} \ +template inline \ +_Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + return _Tpvec(rshr(a.val, b.val, n)); \ +} + +OPENCV_HAL_IMPL_MSA_PACK(v_uint8x16, v_uint16x8, pack, msa_qpack_u16, msa_qrpackr_u16) +OPENCV_HAL_IMPL_MSA_PACK(v_int8x16, v_int16x8, pack, msa_qpack_s16, msa_qrpackr_s16) +OPENCV_HAL_IMPL_MSA_PACK(v_uint16x8, v_uint32x4, pack, msa_qpack_u32, msa_qrpackr_u32) +OPENCV_HAL_IMPL_MSA_PACK(v_int16x8, v_int32x4, pack, msa_qpack_s32, msa_qrpackr_s32) +OPENCV_HAL_IMPL_MSA_PACK(v_uint32x4, v_uint64x2, pack, msa_pack_u64, msa_rpackr_u64) +OPENCV_HAL_IMPL_MSA_PACK(v_int32x4, v_int64x2, pack, msa_pack_s64, msa_rpackr_s64) +OPENCV_HAL_IMPL_MSA_PACK(v_uint8x16, v_int16x8, pack_u, msa_qpacku_s16, msa_qrpackru_s16) +OPENCV_HAL_IMPL_MSA_PACK(v_uint16x8, v_int32x4, pack_u, msa_qpacku_s32, msa_qrpackru_s32) + +#define OPENCV_HAL_IMPL_MSA_PACK_STORE(_Tpvec, _Tp, hreg, suffix, _Tpwvec, pack, mov, rshr) \ +inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = mov(a.val); \ + msa_st1_##suffix(ptr, a1); \ +} \ +template inline \ +void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = rshr(a.val, n); \ + msa_st1_##suffix(ptr, a1); \ +} + +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint8x16, uchar, v8u8, u8, v_uint16x8, pack, msa_qmovn_u16, msa_qrshrn_n_u16) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_int8x16, schar, v8i8, s8, v_int16x8, pack, msa_qmovn_s16, msa_qrshrn_n_s16) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint16x8, ushort, v4u16, u16, v_uint32x4, pack, msa_qmovn_u32, msa_qrshrn_n_u32) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_int16x8, short, v4i16, s16, v_int32x4, pack, msa_qmovn_s32, msa_qrshrn_n_s32) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint32x4, unsigned, v2u32, u32, v_uint64x2, pack, msa_movn_u64, msa_rshrn_n_u64) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_int32x4, int, v2i32, s32, v_int64x2, pack, msa_movn_s64, msa_rshrn_n_s64) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint8x16, uchar, v8u8, u8, v_int16x8, pack_u, msa_qmovun_s16, msa_qrshrun_n_s16) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint16x8, ushort, v4u16, u16, v_int32x4, pack_u, msa_qmovun_s32, msa_qrshrun_n_s32) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint8x16(msa_pack_u16(a.val, b.val)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + return v_uint8x16(msa_pack_u16(msa_pack_u32(a.val, b.val), msa_pack_u32(c.val, d.val))); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + v8u16 abcd = msa_pack_u32(msa_pack_u64(a.val, b.val), msa_pack_u64(c.val, d.val)); + v8u16 efgh = msa_pack_u32(msa_pack_u64(e.val, f.val), msa_pack_u64(g.val, h.val)); + return v_uint8x16(msa_pack_u16(abcd, efgh)); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + v4f32 v0 = v.val; + v4f32 res = msa_mulq_lane_f32(m0.val, v0, 0); + res = msa_mlaq_lane_f32(res, m1.val, v0, 1); + res = msa_mlaq_lane_f32(res, m2.val, v0, 2); + res = msa_mlaq_lane_f32(res, m3.val, v0, 3); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + v4f32 v0 = v.val; + v4f32 res = msa_mulq_lane_f32(m0.val, v0, 0); + res = msa_mlaq_lane_f32(res, m1.val, v0, 1); + res = msa_mlaq_lane_f32(res, m2.val, v0, 2); + res = msa_addq_f32(res, a.val); + return v_float32x4(res); +} + +#define OPENCV_HAL_IMPL_MSA_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint8x16, msa_qaddq_u8) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint8x16, msa_qsubq_u8) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int8x16, msa_qaddq_s8) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int8x16, msa_qsubq_s8) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint16x8, msa_qaddq_u16) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint16x8, msa_qsubq_u16) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int16x8, msa_qaddq_s16) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int16x8, msa_qsubq_s16) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int32x4, msa_addq_s32) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int32x4, msa_subq_s32) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_int32x4, msa_mulq_s32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint32x4, msa_addq_u32) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint32x4, msa_subq_u32) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_uint32x4, msa_mulq_u32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_float32x4, msa_addq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_float32x4, msa_subq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_float32x4, msa_mulq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int64x2, msa_addq_s64) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int64x2, msa_subq_s64) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint64x2, msa_addq_u64) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint64x2, msa_subq_u64) +OPENCV_HAL_IMPL_MSA_BIN_OP(/, v_float32x4, msa_divq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_float64x2, msa_addq_f64) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_float64x2, msa_subq_f64) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_float64x2, msa_mulq_f64) +OPENCV_HAL_IMPL_MSA_BIN_OP(/, v_float64x2, msa_divq_f64) + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_MSA_MUL_SAT(_Tpvec, _Tpwvec) \ +inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ +} \ +inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ +{a = a * b; return a; } + +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_uint16x8, v_uint32x4) + +// Multiply and expand +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + v16i8 a_lo, a_hi, b_lo, b_hi; + + ILVRL_B2_SB(a.val, msa_dupq_n_s8(0), a_lo, a_hi); + ILVRL_B2_SB(b.val, msa_dupq_n_s8(0), b_lo, b_hi); + c.val = msa_mulq_s16(msa_paddlq_s8(a_lo), msa_paddlq_s8(b_lo)); + d.val = msa_mulq_s16(msa_paddlq_s8(a_hi), msa_paddlq_s8(b_hi)); +} + +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + v16u8 a_lo, a_hi, b_lo, b_hi; + + ILVRL_B2_UB(a.val, msa_dupq_n_u8(0), a_lo, a_hi); + ILVRL_B2_UB(b.val, msa_dupq_n_u8(0), b_lo, b_hi); + c.val = msa_mulq_u16(msa_paddlq_u8(a_lo), msa_paddlq_u8(b_lo)); + d.val = msa_mulq_u16(msa_paddlq_u8(a_hi), msa_paddlq_u8(b_hi)); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + v8i16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_SH(a.val, msa_dupq_n_s16(0), a_lo, a_hi); + ILVRL_H2_SH(b.val, msa_dupq_n_s16(0), b_lo, b_hi); + c.val = msa_mulq_s32(msa_paddlq_s16(a_lo), msa_paddlq_s16(b_lo)); + d.val = msa_mulq_s32(msa_paddlq_s16(a_hi), msa_paddlq_s16(b_hi)); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + v8u16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_UH(a.val, msa_dupq_n_u16(0), a_lo, a_hi); + ILVRL_H2_UH(b.val, msa_dupq_n_u16(0), b_lo, b_hi); + c.val = msa_mulq_u32(msa_paddlq_u16(a_lo), msa_paddlq_u16(b_lo)); + d.val = msa_mulq_u32(msa_paddlq_u16(a_hi), msa_paddlq_u16(b_hi)); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + v4u32 a_lo, a_hi, b_lo, b_hi; + + ILVRL_W2_UW(a.val, msa_dupq_n_u32(0), a_lo, a_hi); + ILVRL_W2_UW(b.val, msa_dupq_n_u32(0), b_lo, b_hi); + c.val = msa_mulq_u64(msa_paddlq_u32(a_lo), msa_paddlq_u32(b_lo)); + d.val = msa_mulq_u64(msa_paddlq_u32(a_hi), msa_paddlq_u32(b_hi)); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + v8i16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_SH(a.val, msa_dupq_n_s16(0), a_lo, a_hi); + ILVRL_H2_SH(b.val, msa_dupq_n_s16(0), b_lo, b_hi); + + return v_int16x8(msa_packr_s32(msa_mulq_s32(msa_paddlq_s16(a_lo), msa_paddlq_s16(b_lo)), + msa_mulq_s32(msa_paddlq_s16(a_hi), msa_paddlq_s16(b_hi)), 16)); +} + +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + v8u16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_UH(a.val, msa_dupq_n_u16(0), a_lo, a_hi); + ILVRL_H2_UH(b.val, msa_dupq_n_u16(0), b_lo, b_hi); + + return v_uint16x8(msa_packr_u32(msa_mulq_u32(msa_paddlq_u16(a_lo), msa_paddlq_u16(b_lo)), + msa_mulq_u32(msa_paddlq_u16(a_hi), msa_paddlq_u16(b_hi)), 16)); +} + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ return v_int32x4(msa_dotp_s_w(a.val, b.val)); } +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_int32x4(msa_dpadd_s_w(c.val , a.val, b.val)); } + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ return v_int64x2(msa_dotp_s_d(a.val, b.val)); } +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_int64x2(msa_dpadd_s_d(c.val , a.val, b.val)); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + v8u16 even_a = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8), 8); + v8u16 odd_a = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8); + v8u16 even_b = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8), 8); + v8u16 odd_b = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8); + v4u32 prod = msa_dotp_u_w(even_a, even_b); + return v_uint32x4(msa_dpadd_u_w(prod, odd_a, odd_b)); +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ + v8u16 even_a = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8), 8); + v8u16 odd_a = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8); + v8u16 even_b = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8), 8); + v8u16 odd_b = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8); + v4u32 prod = msa_dpadd_u_w(c.val, even_a, even_b); + return v_uint32x4(msa_dpadd_u_w(prod, odd_a, odd_b)); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + v8i16 prod = msa_dotp_s_h(a.val, b.val); + return v_int32x4(msa_hadd_s32(prod, prod)); +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + v4u32 even_a = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16), 16); + v4u32 odd_a = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16); + v4u32 even_b = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16), 16); + v4u32 odd_b = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16); + v2u64 prod = msa_dotp_u_d(even_a, even_b); + return v_uint64x2(msa_dpadd_u_d(prod, odd_a, odd_b)); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, + const v_uint64x2& c) +{ + v4u32 even_a = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16), 16); + v4u32 odd_a = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16); + v4u32 even_b = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16), 16); + v4u32 odd_b = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16); + v2u64 prod = msa_dpadd_u_d(c.val, even_a, even_b); + return v_uint64x2(msa_dpadd_u_d(prod, odd_a, odd_b)); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v4i32 prod = msa_dotp_s_w(a.val, b.val); + return v_int64x2(msa_hadd_s64(prod, prod)); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b, c); } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b, c); } + +#define OPENCV_HAL_IMPL_MSA_LOGIC_OP(_Tpvec, _Tpv, suffix) \ +OPENCV_HAL_IMPL_MSA_BIN_OP(&, _Tpvec, msa_andq_##suffix) \ +OPENCV_HAL_IMPL_MSA_BIN_OP(|, _Tpvec, msa_orrq_##suffix) \ +OPENCV_HAL_IMPL_MSA_BIN_OP(^, _Tpvec, msa_eorq_##suffix) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_mvnq_u8(MSA_TPV_REINTERPRET(v16u8, a.val)))); \ +} + +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint8x16, v16u8, u8) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int8x16, v16i8, s8) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint16x8, v8u16, u16) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int16x8, v8i16, s16) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint32x4, v4u32, u32) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int32x4, v4i32, s32) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint64x2, v2u64, u64) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int64x2, v2i64, s64) + +#define OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(MSA_TPV_REINTERPRET(v4f32, intrin(MSA_TPV_REINTERPRET(v4i32, a.val), MSA_TPV_REINTERPRET(v4i32, b.val)))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a.val = MSA_TPV_REINTERPRET(v4f32, intrin(MSA_TPV_REINTERPRET(v4i32, a.val), MSA_TPV_REINTERPRET(v4i32, b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(&, msa_andq_s32) +OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(|, msa_orrq_s32) +OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(^, msa_eorq_s32) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_mvnq_s32(MSA_TPV_REINTERPRET(v4i32, a.val)))); +} + +/* v_abs */ +#define OPENCV_HAL_IMPL_MSA_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ +inline _Tpuvec v_abs(const _Tpsvec& a) \ +{ \ + return v_reinterpret_as_##usuffix(_Tpsvec(msa_absq_##ssuffix(a.val))); \ +} + +OPENCV_HAL_IMPL_MSA_ABS(v_uint8x16, v_int8x16, u8, s8) +OPENCV_HAL_IMPL_MSA_ABS(v_uint16x8, v_int16x8, u16, s16) +OPENCV_HAL_IMPL_MSA_ABS(v_uint32x4, v_int32x4, u32, s32) + +/* v_abs(float), v_sqrt, v_invsqrt */ +#define OPENCV_HAL_IMPL_MSA_BASIC_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a) \ +{ \ + return _Tpvec(intrin(a.val)); \ +} + +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float32x4, v_abs, msa_absq_f32) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float64x2, v_abs, msa_absq_f64) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float32x4, v_sqrt, msa_sqrtq_f32) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float32x4, v_invsqrt, msa_rsqrtq_f32) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float64x2, v_sqrt, msa_sqrtq_f64) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float64x2, v_invsqrt, msa_rsqrtq_f64) + +#define OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(MSA_TPV_REINTERPRET(v2f64, intrin(MSA_TPV_REINTERPRET(v2i64, a.val), MSA_TPV_REINTERPRET(v2i64, b.val)))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a.val = MSA_TPV_REINTERPRET(v2f64, intrin(MSA_TPV_REINTERPRET(v2i64, a.val), MSA_TPV_REINTERPRET(v2i64, b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(&, msa_andq_s64) +OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(|, msa_orrq_s64) +OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(^, msa_eorq_s64) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_mvnq_s32(MSA_TPV_REINTERPRET(v4i32, a.val)))); +} + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_MSA_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_min, msa_minq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_max, msa_maxq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_min, msa_minq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_max, msa_maxq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_min, msa_minq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_max, msa_maxq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_min, msa_minq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_max, msa_maxq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint32x4, v_min, msa_minq_u32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint32x4, v_max, msa_maxq_u32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int32x4, v_min, msa_minq_s32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int32x4, v_max, msa_maxq_s32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float32x4, v_min, msa_minq_f32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float32x4, v_max, msa_maxq_f32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float64x2, v_min, msa_minq_f64) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float64x2, v_max, msa_maxq_f64) + +#define OPENCV_HAL_IMPL_MSA_INT_CMP_OP(_Tpvec, _Tpv, suffix, not_suffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_ceqq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_mvnq_##not_suffix(msa_ceqq_##suffix(a.val, b.val)))); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cltq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cgtq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cleq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cgeq_##suffix(a.val, b.val))); } + +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint8x16, v16u8, u8, u8) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int8x16, v16i8, s8, u8) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint16x8, v8u16, u16, u16) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int16x8, v8i16, s16, u16) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint32x4, v4u32, u32, u32) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int32x4, v4i32, s32, u32) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_float32x4, v4f32, f32, u32) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint64x2, v2u64, u64, u64) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int64x2, v2i64, s64, u64) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_float64x2, v2f64, f64, u64) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ceqq_f32(a.val, a.val))); } +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_ceqq_f64(a.val, a.val))); } + +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_add_wrap, msa_addq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_add_wrap, msa_addq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_add_wrap, msa_addq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_add_wrap, msa_addq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_sub_wrap, msa_subq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_sub_wrap, msa_subq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_sub_wrap, msa_subq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_sub_wrap, msa_subq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_mul_wrap, msa_mulq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_mul_wrap, msa_mulq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_mul_wrap, msa_mulq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_mul_wrap, msa_mulq_s16) + +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_absdiff, msa_abdq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_absdiff, msa_abdq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint32x4, v_absdiff, msa_abdq_u32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float32x4, v_absdiff, msa_abdq_f32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float64x2, v_absdiff, msa_abdq_f64) + +/** Saturating absolute difference **/ +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_absdiffs, msa_qabdq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_absdiffs, msa_qabdq_s16) + +#define OPENCV_HAL_IMPL_MSA_BIN_FUNC2(_Tpvec, _Tpvec2, _Tpv, func, intrin) \ +inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec2(MSA_TPV_REINTERPRET(_Tpv, intrin(a.val, b.val))); \ +} + +OPENCV_HAL_IMPL_MSA_BIN_FUNC2(v_int8x16, v_uint8x16, v16u8, v_absdiff, msa_abdq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC2(v_int16x8, v_uint16x8, v8u16, v_absdiff, msa_abdq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC2(v_int32x4, v_uint32x4, v4u32, v_absdiff, msa_abdq_s32) + +/* v_magnitude, v_sqr_magnitude, v_fma, v_muladd */ +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(msa_mlaq_f32(msa_mulq_f32(a.val, a.val), b.val, b.val)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(msa_mlaq_f32(msa_mulq_f32(a.val, a.val), b.val, b.val)); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_float32x4(msa_mlaq_f32(c.val, a.val, b.val)); +} + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(msa_mlaq_s32(c.val, a.val, b.val)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(msa_mlaq_f64(msa_mulq_f64(a.val, a.val), b.val, b.val)); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(msa_mlaq_f64(msa_mulq_f64(a.val, a.val), b.val, b.val)); +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(msa_mlaq_f64(c.val, a.val, b.val)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} + +// trade efficiency for convenience +#define OPENCV_HAL_IMPL_MSA_SHIFT_OP(_Tpvec, suffix, _Tps, ssuffix) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ return _Tpvec(msa_shlq_##suffix(a.val, msa_dupq_n_##ssuffix((_Tps)n))); } \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ return _Tpvec(msa_shrq_##suffix(a.val, msa_dupq_n_##ssuffix((_Tps)n))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec(msa_shlq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec(msa_shrq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_rshr(const _Tpvec& a) \ +{ return _Tpvec(msa_rshrq_n_##suffix(a.val, n)); } + +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint8x16, u8, schar, s8) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int8x16, s8, schar, s8) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint16x8, u16, short, s16) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int16x8, s16, short, s16) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint32x4, u32, int, s32) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int32x4, s32, int, s32) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint64x2, u64, int64, s64) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int64x2, s64, int64, s64) + +/* v_rotate_right, v_rotate_left */ +#define OPENCV_HAL_IMPL_MSA_ROTATE_OP(_Tpvec, _Tpv, _Tpvs, suffix) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##suffix(0), n))); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(msa_dupq_n_##suffix(0), MSA_TPV_REINTERPRET(_Tpvs, a.val), _Tpvec::nlanes - n))); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ \ + return a; \ +} \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), MSA_TPV_REINTERPRET(_Tpvs, b.val), n))); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, b.val), MSA_TPV_REINTERPRET(_Tpvs, a.val), _Tpvec::nlanes - n))); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ \ + CV_UNUSED(b); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint8x16, v16u8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int8x16, v16i8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint16x8, v8u16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int16x8, v8i16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_float32x4, v4f32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint64x2, v2u64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int64x2, v2i64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_float64x2, v2f64, v2i64, s64) + +#define OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(msa_ld1q_##suffix(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(msa_ld1q_##suffix(ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(msa_combine_##suffix(msa_ld1_##suffix(ptr), msa_dup_n_##suffix((_Tp)0))); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ return _Tpvec(msa_combine_##suffix(msa_ld1_##suffix(ptr0), msa_ld1_##suffix(ptr1))); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ \ + int n = _Tpvec::nlanes; \ + for( int i = 0; i < (n/2); i++ ) \ + ptr[i] = a.val[i]; \ +} \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + int n = _Tpvec::nlanes; \ + for( int i = 0; i < (n/2); i++ ) \ + ptr[i] = a.val[i+(n/2)]; \ +} + +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_float32x4, float, f32) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_float64x2, double, f64) + + +/** Reverse **/ +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + v_uint8x16 c = v_uint8x16((v16u8)__builtin_msa_vshf_b((v16i8)((v2i64){0x08090A0B0C0D0E0F, 0x0001020304050607}), msa_dupq_n_s8(0), (v16i8)a.val)); + return c; +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + v_uint16x8 c = v_uint16x8((v8u16)__builtin_msa_vshf_h((v8i16)((v2i64){0x0004000500060007, 0x0000000100020003}), msa_dupq_n_s16(0), (v8i16)a.val)); + return c; +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + v_uint32x4 c; + c.val[0] = a.val[3]; + c.val[1] = a.val[2]; + c.val[2] = a.val[1]; + c.val[3] = a.val[0]; + return c; +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + v_uint64x2 c; + c.val[0] = a.val[1]; + c.val[1] = a.val[0]; + return c; +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_8U(func, cfunc) \ +inline unsigned short v_reduce_##func(const v_uint16x8& a) \ +{ \ + v8u16 a_lo, a_hi; \ + ILVRL_H2_UH(a.val, msa_dupq_n_u16(0), a_lo, a_hi); \ + v4u32 b = msa_##func##q_u32(msa_paddlq_u16(a_lo), msa_paddlq_u16(a_hi)); \ + v4u32 b_lo, b_hi; \ + ILVRL_W2_UW(b, msa_dupq_n_u32(0), b_lo, b_hi); \ + v2u64 c = msa_##func##q_u64(msa_paddlq_u32(b_lo), msa_paddlq_u32(b_hi)); \ + return (unsigned short)cfunc(c[0], c[1]); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8U(max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8U(min, std::min) + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_8S(func, cfunc) \ +inline short v_reduce_##func(const v_int16x8& a) \ +{ \ + v8i16 a_lo, a_hi; \ + ILVRL_H2_SH(a.val, msa_dupq_n_s16(0), a_lo, a_hi); \ + v4i32 b = msa_##func##q_s32(msa_paddlq_s16(a_lo), msa_paddlq_s16(a_hi)); \ + v4i32 b_lo, b_hi; \ + ILVRL_W2_SW(b, msa_dupq_n_s32(0), b_lo, b_hi); \ + v2i64 c = msa_##func##q_s64(msa_paddlq_s32(b_lo), msa_paddlq_s32(b_hi)); \ + return (short)cfunc(c[0], c[1]); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8S(max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8S(min, std::min) + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(_Tpvec, scalartype, func, cfunc) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return (scalartype)cfunc(cfunc(a.val[0], a.val[1]), cfunc(a.val[2], a.val[3])); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_int32x4, int, max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_int32x4, int, min, std::min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_float32x4, float, max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_float32x4, float, min, std::min) + + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(_Tpvec, scalartype, _Tpvec2, func) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpvec2 a1, a2; \ + v_expand(a, a1, a2); \ + return (scalartype)v_reduce_##func(v_##func(a1, a2)); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_uint8x16, uchar, v_uint16x8, min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_uint8x16, uchar, v_uint16x8, max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_int8x16, char, v_int16x8, min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_int8x16, char, v_int16x8, max) + + + +#define OPENCV_HAL_IMPL_MSA_REDUCE_SUM(_Tpvec, scalartype, suffix) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + return (scalartype)msa_sum_##suffix(a.val); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_uint8x16, unsigned char, u8) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_int8x16, char, s8) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_uint16x8, unsigned short, u16) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_float32x4, float, f32) + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ return (uint64)(msa_getq_lane_u64(a.val, 0) + msa_getq_lane_u64(a.val, 1)); } +inline int64 v_reduce_sum(const v_int64x2& a) +{ return (int64)(msa_getq_lane_s64(a.val, 0) + msa_getq_lane_s64(a.val, 1)); } +inline double v_reduce_sum(const v_float64x2& a) +{ + return msa_getq_lane_f64(a.val, 0) + msa_getq_lane_f64(a.val, 1); +} + +/* v_reduce_sum4, v_reduce_sad */ +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + v4f32 u0 = msa_addq_f32(MSA_TPV_REINTERPRET(v4f32, msa_ilvevq_s32(MSA_TPV_REINTERPRET(v4i32, b.val), MSA_TPV_REINTERPRET(v4i32, a.val))), + MSA_TPV_REINTERPRET(v4f32, msa_ilvodq_s32(MSA_TPV_REINTERPRET(v4i32, b.val), MSA_TPV_REINTERPRET(v4i32, a.val)))); // a0+a1 b0+b1 a2+a3 b2+b3 + v4f32 u1 = msa_addq_f32(MSA_TPV_REINTERPRET(v4f32, msa_ilvevq_s32(MSA_TPV_REINTERPRET(v4i32, d.val), MSA_TPV_REINTERPRET(v4i32, c.val))), + MSA_TPV_REINTERPRET(v4f32, msa_ilvodq_s32(MSA_TPV_REINTERPRET(v4i32, d.val), MSA_TPV_REINTERPRET(v4i32, c.val)))); // c0+c1 d0+d1 c2+c3 d2+d3 + + return v_float32x4(msa_addq_f32(MSA_TPV_REINTERPRET(v4f32, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, u1), MSA_TPV_REINTERPRET(v2i64, u0))), + MSA_TPV_REINTERPRET(v4f32, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, u1), MSA_TPV_REINTERPRET(v2i64, u0))))); +} + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + v16u8 t0 = msa_abdq_u8(a.val, b.val); + v8u16 t1 = msa_paddlq_u8(t0); + v4u32 t2 = msa_paddlq_u16(t1); + return msa_sum_u32(t2); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + v16u8 t0 = MSA_TPV_REINTERPRET(v16u8, msa_abdq_s8(a.val, b.val)); + v8u16 t1 = msa_paddlq_u8(t0); + v4u32 t2 = msa_paddlq_u16(t1); + return msa_sum_u32(t2); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + v8u16 t0 = msa_abdq_u16(a.val, b.val); + v4u32 t1 = msa_paddlq_u16(t0); + return msa_sum_u32(t1); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + v8u16 t0 = MSA_TPV_REINTERPRET(v8u16, msa_abdq_s16(a.val, b.val)); + v4u32 t1 = msa_paddlq_u16(t0); + return msa_sum_u32(t1); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + v4u32 t0 = msa_abdq_u32(a.val, b.val); + return msa_sum_u32(t0); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + v4u32 t0 = MSA_TPV_REINTERPRET(v4u32, msa_abdq_s32(a.val, b.val)); + return msa_sum_u32(t0); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + v4f32 t0 = msa_abdq_f32(a.val, b.val); + return msa_sum_f32(t0); +} + +/* v_popcount */ +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE8(_Tpvec) \ +inline v_uint8x16 v_popcount(const _Tpvec& a) \ +{ \ + v16u8 t = MSA_TPV_REINTERPRET(v16u8, msa_cntq_s8(MSA_TPV_REINTERPRET(v16i8, a.val))); \ + return v_uint8x16(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE8(v_uint8x16) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE8(v_int8x16) + +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE16(_Tpvec) \ +inline v_uint16x8 v_popcount(const _Tpvec& a) \ +{ \ + v8u16 t = MSA_TPV_REINTERPRET(v8u16, msa_cntq_s16(MSA_TPV_REINTERPRET(v8i16, a.val))); \ + return v_uint16x8(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE16(v_uint16x8) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE16(v_int16x8) + +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE32(_Tpvec) \ +inline v_uint32x4 v_popcount(const _Tpvec& a) \ +{ \ + v4u32 t = MSA_TPV_REINTERPRET(v4u32, msa_cntq_s32(MSA_TPV_REINTERPRET(v4i32, a.val))); \ + return v_uint32x4(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE32(v_uint32x4) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE32(v_int32x4) + +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE64(_Tpvec) \ +inline v_uint64x2 v_popcount(const _Tpvec& a) \ +{ \ + v2u64 t = MSA_TPV_REINTERPRET(v2u64, msa_cntq_s64(MSA_TPV_REINTERPRET(v2i64, a.val))); \ + return v_uint64x2(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE64(v_uint64x2) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE64(v_int64x2) + +inline int v_signmask(const v_uint8x16& a) +{ + v8i8 m0 = msa_create_s8(CV_BIG_UINT(0x0706050403020100)); + v16u8 v0 = msa_shlq_u8(msa_shrq_n_u8(a.val, 7), msa_combine_s8(m0, m0)); + v8u16 v1 = msa_paddlq_u8(v0); + v4u32 v2 = msa_paddlq_u16(v1); + v2u64 v3 = msa_paddlq_u32(v2); + return (int)msa_getq_lane_u64(v3, 0) + ((int)msa_getq_lane_u64(v3, 1) << 8); +} +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } + +inline int v_signmask(const v_uint16x8& a) +{ + v4i16 m0 = msa_create_s16(CV_BIG_UINT(0x0003000200010000)); + v8u16 v0 = msa_shlq_u16(msa_shrq_n_u16(a.val, 15), msa_combine_s16(m0, m0)); + v4u32 v1 = msa_paddlq_u16(v0); + v2u64 v2 = msa_paddlq_u32(v1); + return (int)msa_getq_lane_u64(v2, 0) + ((int)msa_getq_lane_u64(v2, 1) << 4); +} +inline int v_signmask(const v_int16x8& a) +{ return v_signmask(v_reinterpret_as_u16(a)); } + +inline int v_signmask(const v_uint32x4& a) +{ + v2i32 m0 = msa_create_s32(CV_BIG_UINT(0x0000000100000000)); + v4u32 v0 = msa_shlq_u32(msa_shrq_n_u32(a.val, 31), msa_combine_s32(m0, m0)); + v2u64 v1 = msa_paddlq_u32(v0); + return (int)msa_getq_lane_u64(v1, 0) + ((int)msa_getq_lane_u64(v1, 1) << 2); +} +inline int v_signmask(const v_int32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } + +inline int v_signmask(const v_uint64x2& a) +{ + v2u64 v0 = msa_shrq_n_u64(a.val, 63); + return (int)msa_getq_lane_u64(v0, 0) + ((int)msa_getq_lane_u64(v0, 1) << 1); +} +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(a)); } + +#define OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(_Tpvec, _Tpvec2, suffix, shift) \ +inline bool v_check_all(const v_##_Tpvec& a) \ +{ \ + _Tpvec2 v0 = msa_shrq_n_##suffix(msa_mvnq_##suffix(a.val), shift); \ + v2u64 v1 = MSA_TPV_REINTERPRET(v2u64, v0); \ + return (msa_getq_lane_u64(v1, 0) | msa_getq_lane_u64(v1, 1)) == 0; \ +} \ +inline bool v_check_any(const v_##_Tpvec& a) \ +{ \ + _Tpvec2 v0 = msa_shrq_n_##suffix(a.val, shift); \ + v2u64 v1 = MSA_TPV_REINTERPRET(v2u64, v0); \ + return (msa_getq_lane_u64(v1, 0) | msa_getq_lane_u64(v1, 1)) != 0; \ +} + +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint8x16, v16u8, u8, 7) +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint16x8, v8u16, u16, 15) +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint32x4, v4u32, u32, 31) +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint64x2, v2u64, u64, 63) + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } + +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } + +/* v_select */ +#define OPENCV_HAL_IMPL_MSA_SELECT(_Tpvec, _Tpv, _Tpvu) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_bslq_u8(MSA_TPV_REINTERPRET(_Tpvu, mask.val), \ + MSA_TPV_REINTERPRET(_Tpvu, b.val), MSA_TPV_REINTERPRET(_Tpvu, a.val)))); \ +} + +OPENCV_HAL_IMPL_MSA_SELECT(v_uint8x16, v16u8, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_int8x16, v16i8, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_uint16x8, v8u16, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_int16x8, v8i16, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_uint32x4, v4u32, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_int32x4, v4i32, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_float32x4, v4f32, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_float64x2, v2f64, v16u8) + +#define OPENCV_HAL_IMPL_MSA_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix, ssuffix, _Tpv, _Tpvs) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + _Tpv a_lo = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + _Tpv a_hi = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + b0.val = msa_paddlq_##suffix(a_lo); \ + b1.val = msa_paddlq_##suffix(a_hi); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + _Tpv a_lo = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + return _Tpwvec(msa_paddlq_##suffix(a_lo)); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + _Tpv a_hi = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + return _Tpwvec(msa_paddlq_##suffix(a_hi)); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(msa_movl_##suffix(msa_ld1_##suffix(ptr))); \ +} + +OPENCV_HAL_IMPL_MSA_EXPAND(v_uint8x16, v_uint16x8, uchar, u8, s8, v16u8, v16i8) +OPENCV_HAL_IMPL_MSA_EXPAND(v_int8x16, v_int16x8, schar, s8, s8, v16i8, v16i8) +OPENCV_HAL_IMPL_MSA_EXPAND(v_uint16x8, v_uint32x4, ushort, u16, s16, v8u16, v8i16) +OPENCV_HAL_IMPL_MSA_EXPAND(v_int16x8, v_int32x4, short, s16, s16, v8i16, v8i16) +OPENCV_HAL_IMPL_MSA_EXPAND(v_uint32x4, v_uint64x2, uint, u32, s32, v4u32, v4i32) +OPENCV_HAL_IMPL_MSA_EXPAND(v_int32x4, v_int64x2, int, s32, s32, v4i32, v4i32) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + return v_uint32x4((v4u32){ptr[0], ptr[1], ptr[2], ptr[3]}); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + return v_int32x4((v4i32){ptr[0], ptr[1], ptr[2], ptr[3]}); +} + +/* v_zip, v_combine_low, v_combine_high, v_recombine */ +#define OPENCV_HAL_IMPL_MSA_UNPACKS(_Tpvec, _Tpv, _Tpvs, ssuffix) \ +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) \ +{ \ + b0.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ + b1.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ +} \ +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val)))); \ +} \ +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val)))); \ +} \ +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) \ +{ \ + c.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val))); \ + d.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val))); \ +} + +OPENCV_HAL_IMPL_MSA_UNPACKS(v_uint8x16, v16u8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_int8x16, v16i8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_uint16x8, v8u16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_int16x8, v8i16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_float32x4, v4f32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_float64x2, v2f64, v2i64, s64) + +/* v_extract */ +#define OPENCV_HAL_IMPL_MSA_EXTRACT(_Tpvec, _Tpv, _Tpvs, suffix) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), MSA_TPV_REINTERPRET(_Tpvs, b.val), s))); \ +} + +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint8x16, v16u8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int8x16, v16i8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint16x8, v8u16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int16x8, v8i16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint64x2, v2u64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int64x2, v2i64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_float32x4, v4f32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_float64x2, v2f64, v2i64, s64) + +/* v_round, v_floor, v_ceil, v_trunc */ +inline v_int32x4 v_round(const v_float32x4& a) +{ + return v_int32x4(msa_cvttintq_s32_f32(a.val)); +} + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + v4i32 a1 = msa_cvttintq_s32_f32(a.val); + return v_int32x4(msa_addq_s32(a1, MSA_TPV_REINTERPRET(v4i32, msa_cgtq_f32(msa_cvtfintq_f32_s32(a1), a.val)))); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + v4i32 a1 = msa_cvttintq_s32_f32(a.val); + return v_int32x4(msa_subq_s32(a1, MSA_TPV_REINTERPRET(v4i32, msa_cgtq_f32(a.val, msa_cvtfintq_f32_s32(a1))))); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ + return v_int32x4(msa_cvttruncq_s32_f32(a.val)); +} + +inline v_int32x4 v_round(const v_float64x2& a) +{ + return v_int32x4(msa_pack_s64(msa_cvttintq_s64_f64(a.val), msa_dupq_n_s64(0))); +} + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + return v_int32x4(msa_pack_s64(msa_cvttintq_s64_f64(a.val), msa_cvttintq_s64_f64(b.val))); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + v2f64 a1 = msa_cvtrintq_f64(a.val); + return v_int32x4(msa_pack_s64(msa_addq_s64(msa_cvttruncq_s64_f64(a1), MSA_TPV_REINTERPRET(v2i64, msa_cgtq_f64(a1, a.val))), msa_dupq_n_s64(0))); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + v2f64 a1 = msa_cvtrintq_f64(a.val); + return v_int32x4(msa_pack_s64(msa_subq_s64(msa_cvttruncq_s64_f64(a1), MSA_TPV_REINTERPRET(v2i64, msa_cgtq_f64(a.val, a1))), msa_dupq_n_s64(0))); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + return v_int32x4(msa_pack_s64(msa_cvttruncq_s64_f64(a.val), msa_dupq_n_s64(0))); +} + +#define OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(_Tpvec, _Tpv, _Tpvs, ssuffix) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, \ + _Tpvec& b2, _Tpvec& b3) \ +{ \ + _Tpv t00 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ + _Tpv t01 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ + _Tpv t10 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a3.val), MSA_TPV_REINTERPRET(_Tpvs, a2.val))); \ + _Tpv t11 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a3.val), MSA_TPV_REINTERPRET(_Tpvs, a2.val))); \ + b0.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, t10), MSA_TPV_REINTERPRET(v2i64, t00))); \ + b1.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, t10), MSA_TPV_REINTERPRET(v2i64, t00))); \ + b2.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, t11), MSA_TPV_REINTERPRET(v2i64, t01))); \ + b3.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, t11), MSA_TPV_REINTERPRET(v2i64, t01))); \ +} + +OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(v_float32x4, v4f32, v4i32, s32) + +#define OPENCV_HAL_IMPL_MSA_INTERLEAVED(_Tpvec, _Tp, suffix) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ +{ \ + msa_ld2q_##suffix(ptr, &a.val, &b.val); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ +{ \ + msa_ld3q_##suffix(ptr, &a.val, &b.val, &c.val); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ + v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + msa_ld4q_##suffix(ptr, &a.val, &b.val, &c.val, &d.val); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + msa_st2q_##suffix(ptr, a.val, b.val); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + msa_st3q_##suffix(ptr, a.val, b.val, c.val); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, const v_##_Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + msa_st4q_##suffix(ptr, a.val, b.val, c.val, d.val); \ +} + +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int8x16, schar, s8) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(float32x4, float, f32) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint64x2, uint64, u64) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int64x2, int64, s64) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(float64x2, double, f64) + +/* v_cvt_f32, v_cvt_f64, v_cvt_f64_high */ +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(msa_cvtfintq_f32_s32(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + return v_float32x4(msa_cvtfq_f32_f64(a.val, msa_dupq_n_f64(0.0f))); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + return v_float32x4(msa_cvtfq_f32_f64(a.val, b.val)); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + return v_float64x2(msa_cvtflq_f64_f32(msa_cvtfintq_f32_s32(a.val))); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + return v_float64x2(msa_cvtfhq_f64_f32(msa_cvtfintq_f32_s32(a.val))); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + return v_float64x2(msa_cvtflq_f64_f32(a.val)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + return v_float64x2(msa_cvtfhq_f64_f32(a.val)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ + return v_float64x2(msa_cvtfintq_f64_s64(a.val)); +} + +////////////// Lookup table access //////////////////// +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(msa_ld1q_s8(elems)); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(msa_ld1q_s8(elems)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(msa_ld1q_s8(elems)); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(msa_ld1q_s16(elems)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(msa_ld1q_s16(elems)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(msa_combine_s16(msa_ld1_s16(tab + idx[0]), msa_ld1_s16(tab + idx[1]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(msa_ld1q_s32(elems)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(msa_combine_s32(msa_ld1_s32(tab + idx[0]), msa_ld1_s32(tab + idx[1]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(msa_ld1q_s32(tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(msa_combine_s64(msa_create_s64(tab[idx[0]]), msa_create_s64(tab[idx[1]]))); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(msa_ld1q_s64(tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(msa_ld1q_f32(elems)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + uint64 CV_DECL_ALIGNED(32) elems[2] = + { + *(uint64*)(tab + idx[0]), + *(uint64*)(tab + idx[1]) + }; + return v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ld1q_u64(elems))); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(msa_ld1q_f32(tab + idx[0])); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + return v_int32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned CV_DECL_ALIGNED(32) elems[4] = + { + tab[msa_getq_lane_s32(idxvec.val, 0)], + tab[msa_getq_lane_s32(idxvec.val, 1)], + tab[msa_getq_lane_s32(idxvec.val, 2)], + tab[msa_getq_lane_s32(idxvec.val, 3)] + }; + return v_uint32x4(msa_ld1q_u32(elems)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + v4f32 xy02 = msa_combine_f32(msa_ld1_f32(tab + idx[0]), msa_ld1_f32(tab + idx[2])); + v4f32 xy13 = msa_combine_f32(msa_ld1_f32(tab + idx[1]), msa_ld1_f32(tab + idx[3])); + x = v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ilvevq_s32(MSA_TPV_REINTERPRET(v4i32, xy13), MSA_TPV_REINTERPRET(v4i32, xy02)))); + y = v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ilvodq_s32(MSA_TPV_REINTERPRET(v4i32, xy13), MSA_TPV_REINTERPRET(v4i32, xy02)))); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + v_int8x16 c = v_int8x16(__builtin_msa_vshf_b((v16i8)((v2i64){0x0705060403010200, 0x0F0D0E0C0B090A08}), msa_dupq_n_s8(0), vec.val)); + return c; +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + v_int8x16 c = v_int8x16(__builtin_msa_vshf_b((v16i8)((v2i64){0x0703060205010400, 0x0F0B0E0A0D090C08}), msa_dupq_n_s8(0), vec.val)); + return c; +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + v_int16x8 c = v_int16x8(__builtin_msa_vshf_h((v8i16)((v2i64){0x0003000100020000, 0x0007000500060004}), msa_dupq_n_s16(0), vec.val)); + return c; +} + +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } + +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + v_int16x8 c = v_int16x8(__builtin_msa_vshf_h((v8i16)((v2i64){0x0005000100040000, 0x0007000300060002}), msa_dupq_n_s16(0), vec.val)); + return c; +} + +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + v_int32x4 c; + c.val[0] = vec.val[0]; + c.val[1] = vec.val[2]; + c.val[2] = vec.val[1]; + c.val[3] = vec.val[3]; + return c; +} + +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + v_int8x16 c = v_int8x16(__builtin_msa_vshf_b((v16i8)((v2i64){0x0908060504020100, 0x131211100E0D0C0A}), msa_dupq_n_s8(0), vec.val)); + return c; +} + +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + v_int16x8 c = v_int16x8(__builtin_msa_vshf_h((v8i16)((v2i64){0x0004000200010000, 0x0009000800060005}), msa_dupq_n_s16(0), vec.val)); + return c; +} + +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + double CV_DECL_ALIGNED(32) elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_float64x2(msa_ld1q_f64(elems)); +} + +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(msa_ld1q_f64(tab + idx[0])); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + v2f64 xy0 = msa_ld1q_f64(tab + idx[0]); + v2f64 xy1 = msa_ld1q_f64(tab + idx[1]); + x = v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_ilvevq_s64(MSA_TPV_REINTERPRET(v2i64, xy1), MSA_TPV_REINTERPRET(v2i64, xy0)))); + y = v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_ilvodq_s64(MSA_TPV_REINTERPRET(v2i64, xy1), MSA_TPV_REINTERPRET(v2i64, xy0)))); +} + +template +inline typename _Tp::lane_type v_extract_n(const _Tp& a) +{ + return v_rotate_right(a).get0(); +} + +template +inline v_uint32x4 v_broadcast_element(const v_uint32x4& a) +{ + return v_setall_u32(v_extract_n(a)); +} +template +inline v_int32x4 v_broadcast_element(const v_int32x4& a) +{ + return v_setall_s32(v_extract_n(a)); +} +template +inline v_float32x4 v_broadcast_element(const v_float32x4& a) +{ + return v_setall_f32(v_extract_n(a)); +} + +////// FP16 support /////// +#if CV_FP16 +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ +#ifndef msa_ld1_f16 + v4f16 v = (v4f16)msa_ld1_s16((const short*)ptr); +#else + v4f16 v = msa_ld1_f16((const __fp16*)ptr); +#endif + return v_float32x4(msa_cvt_f32_f16(v)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + v4f16 hv = msa_cvt_f16_f32(v.val); + +#ifndef msa_st1_f16 + msa_st1_s16((short*)ptr, (int16x4_t)hv); +#else + msa_st1_f16((__fp16*)ptr, hv); +#endif +} +#else +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + float buf[4]; + for( int i = 0; i < 4; i++ ) + buf[i] = (float)ptr[i]; + return v_load(buf); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + float buf[4]; + v_store(buf, v); + for( int i = 0; i < 4; i++ ) + ptr[i] = (float16_t)buf[i]; +} +#endif + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_neon.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_neon.hpp new file mode 100644 index 0000000..e17972a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_neon.hpp @@ -0,0 +1,2613 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_INTRIN_NEON_HPP +#define OPENCV_HAL_INTRIN_NEON_HPP + +#include +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 +#if defined(__aarch64__) || defined(_M_ARM64) +#define CV_SIMD128_64F 1 +#else +#define CV_SIMD128_64F 0 +#endif + +// The following macro checks if the code is being compiled for the +// AArch64 execution state of Armv8, to enable the 128-bit +// intrinsics. The macro `__ARM_64BIT_STATE` is the one recommended by +// the Arm C Language Extension (ACLE) specifications [1] to check the +// availability of 128-bit intrinsics, and it is supporrted by clang +// and gcc. The macro `_M_ARM64` is the equivalent one for Microsoft +// Visual Studio [2] . +// +// [1] https://developer.arm.com/documentation/101028/0012/13--Advanced-SIMD--Neon--intrinsics +// [2] https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros +#if defined(__ARM_64BIT_STATE) || defined(_M_ARM64) +#define CV_NEON_AARCH64 1 +#else +#define CV_NEON_AARCH64 0 +#endif + +// TODO +#define CV_NEON_DOT 0 + +//////////// Utils //////////// + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv& a, const _Tpv& b, _Tpv& c, _Tpv& d) \ + { c = vuzp1q_##suffix(a, b); d = vuzp2q_##suffix(a, b); } +#define OPENCV_HAL_IMPL_NEON_UNZIP_L(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv&a, const _Tpv&b, _Tpv& c, _Tpv& d) \ + { c = vuzp1_##suffix(a, b); d = vuzp2_##suffix(a, b); } +#else +#define OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv& a, const _Tpv& b, _Tpv& c, _Tpv& d) \ + { _Tpvx2 ab = vuzpq_##suffix(a, b); c = ab.val[0]; d = ab.val[1]; } +#define OPENCV_HAL_IMPL_NEON_UNZIP_L(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv& a, const _Tpv& b, _Tpv& c, _Tpv& d) \ + { _Tpvx2 ab = vuzp_##suffix(a, b); c = ab.val[0]; d = ab.val[1]; } +#endif + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) \ + template static inline \ + _Tpv vreinterpretq_##suffix##_f64(T a) { return (_Tpv) a; } \ + template static inline \ + float64x2_t vreinterpretq_f64_##suffix(T a) { return (float64x2_t) a; } +#else +#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) +#endif + +#define OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(_Tpv, _Tpvl, suffix) \ + OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv##_t, _Tpv##x2_t, suffix) \ + OPENCV_HAL_IMPL_NEON_UNZIP_L(_Tpvl##_t, _Tpvl##x2_t, suffix) \ + OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv##_t, suffix) + +#define OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_I64(_Tpv, _Tpvl, suffix) \ + OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv##_t, suffix) + +#define OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_F64(_Tpv, _Tpvl, suffix) \ + OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv##_t, _Tpv##x2_t, suffix) + +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(uint8x16, uint8x8, u8) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(int8x16, int8x8, s8) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(uint16x8, uint16x4, u16) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(int16x8, int16x4, s16) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(uint32x4, uint32x2, u32) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(int32x4, int32x2, s32) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(float32x4, float32x2, f32) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_I64(uint64x2, uint64x1, u64) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_I64(int64x2, int64x1, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_F64(float64x2, float64x1,f64) +#endif + +//////////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(uint8x16_t v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = vld1q_u8(v); + } + uchar get0() const + { + return vgetq_lane_u8(val, 0); + } + + uint8x16_t val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(int8x16_t v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = vld1q_s8(v); + } + schar get0() const + { + return vgetq_lane_s8(val, 0); + } + + int8x16_t val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(uint16x8_t v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = vld1q_u16(v); + } + ushort get0() const + { + return vgetq_lane_u16(val, 0); + } + + uint16x8_t val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(int16x8_t v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = vld1q_s16(v); + } + short get0() const + { + return vgetq_lane_s16(val, 0); + } + + int16x8_t val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(uint32x4_t v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + val = vld1q_u32(v); + } + unsigned get0() const + { + return vgetq_lane_u32(val, 0); + } + + uint32x4_t val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(int32x4_t v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = vld1q_s32(v); + } + int get0() const + { + return vgetq_lane_s32(val, 0); + } + int32x4_t val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(float32x4_t v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = vld1q_f32(v); + } + float get0() const + { + return vgetq_lane_f32(val, 0); + } + float32x4_t val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(uint64x2_t v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = vld1q_u64(v); + } + uint64 get0() const + { + return vgetq_lane_u64(val, 0); + } + uint64x2_t val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(int64x2_t v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = vld1q_s64(v); + } + int64 get0() const + { + return vgetq_lane_s64(val, 0); + } + int64x2_t val; +}; + +#if CV_SIMD128_64F +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(float64x2_t v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = vld1q_f64(v); + } + double get0() const + { + return vgetq_lane_f64(val, 0); + } + float64x2_t val; +}; +#endif + +#define OPENCV_HAL_IMPL_NEON_INIT(_Tpv, _Tp, suffix) \ +inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(vdupq_n_##suffix((_Tp)0)); } \ +inline v_##_Tpv v_setall_##suffix(_Tp v) { return v_##_Tpv(vdupq_n_##suffix(v)); } \ +inline _Tpv##_t vreinterpretq_##suffix##_##suffix(_Tpv##_t v) { return v; } \ +inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16(vreinterpretq_u8_##suffix(v.val)); } \ +inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16(vreinterpretq_s8_##suffix(v.val)); } \ +inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8(vreinterpretq_u16_##suffix(v.val)); } \ +inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8(vreinterpretq_s16_##suffix(v.val)); } \ +inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4(vreinterpretq_u32_##suffix(v.val)); } \ +inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4(vreinterpretq_s32_##suffix(v.val)); } \ +inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2(vreinterpretq_u64_##suffix(v.val)); } \ +inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2(vreinterpretq_s64_##suffix(v.val)); } \ +inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4(vreinterpretq_f32_##suffix(v.val)); } + +OPENCV_HAL_IMPL_NEON_INIT(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_INIT(int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_INIT(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_INIT(int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_INIT(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_NEON_INIT(int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_INIT(uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_INIT(int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_INIT(float32x4, float, f32) +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_INIT_64(_Tpv, suffix) \ +inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2(vreinterpretq_f64_##suffix(v.val)); } +OPENCV_HAL_IMPL_NEON_INIT(float64x2, double, f64) +OPENCV_HAL_IMPL_NEON_INIT_64(uint8x16, u8) +OPENCV_HAL_IMPL_NEON_INIT_64(int8x16, s8) +OPENCV_HAL_IMPL_NEON_INIT_64(uint16x8, u16) +OPENCV_HAL_IMPL_NEON_INIT_64(int16x8, s16) +OPENCV_HAL_IMPL_NEON_INIT_64(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_INIT_64(int32x4, s32) +OPENCV_HAL_IMPL_NEON_INIT_64(uint64x2, u64) +OPENCV_HAL_IMPL_NEON_INIT_64(int64x2, s64) +OPENCV_HAL_IMPL_NEON_INIT_64(float32x4, f32) +OPENCV_HAL_IMPL_NEON_INIT_64(float64x2, f64) +#endif + +#define OPENCV_HAL_IMPL_NEON_PACK(_Tpvec, _Tp, hreg, suffix, _Tpwvec, pack, mov, rshr) \ +inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + hreg a1 = mov(a.val), b1 = mov(b.val); \ + return _Tpvec(vcombine_##suffix(a1, b1)); \ +} \ +inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = mov(a.val); \ + vst1_##suffix(ptr, a1); \ +} \ +template inline \ +_Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + hreg a1 = rshr(a.val, n); \ + hreg b1 = rshr(b.val, n); \ + return _Tpvec(vcombine_##suffix(a1, b1)); \ +} \ +template inline \ +void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = rshr(a.val, n); \ + vst1_##suffix(ptr, a1); \ +} + +OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_uint16x8, pack, vqmovn_u16, vqrshrn_n_u16) +OPENCV_HAL_IMPL_NEON_PACK(v_int8x16, schar, int8x8_t, s8, v_int16x8, pack, vqmovn_s16, vqrshrn_n_s16) +OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_uint32x4, pack, vqmovn_u32, vqrshrn_n_u32) +OPENCV_HAL_IMPL_NEON_PACK(v_int16x8, short, int16x4_t, s16, v_int32x4, pack, vqmovn_s32, vqrshrn_n_s32) +OPENCV_HAL_IMPL_NEON_PACK(v_uint32x4, unsigned, uint32x2_t, u32, v_uint64x2, pack, vmovn_u64, vrshrn_n_u64) +OPENCV_HAL_IMPL_NEON_PACK(v_int32x4, int, int32x2_t, s32, v_int64x2, pack, vmovn_s64, vrshrn_n_s64) + +OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, pack_u, vqmovun_s16, vqrshrun_n_s16) +OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, pack_u, vqmovun_s32, vqrshrun_n_s32) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + uint8x16_t ab = vcombine_u8(vmovn_u16(a.val), vmovn_u16(b.val)); + return v_uint8x16(ab); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + uint16x8_t nab = vcombine_u16(vmovn_u32(a.val), vmovn_u32(b.val)); + uint16x8_t ncd = vcombine_u16(vmovn_u32(c.val), vmovn_u32(d.val)); + return v_uint8x16(vcombine_u8(vmovn_u16(nab), vmovn_u16(ncd))); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + uint32x4_t ab = vcombine_u32(vmovn_u64(a.val), vmovn_u64(b.val)); + uint32x4_t cd = vcombine_u32(vmovn_u64(c.val), vmovn_u64(d.val)); + uint32x4_t ef = vcombine_u32(vmovn_u64(e.val), vmovn_u64(f.val)); + uint32x4_t gh = vcombine_u32(vmovn_u64(g.val), vmovn_u64(h.val)); + + uint16x8_t abcd = vcombine_u16(vmovn_u32(ab), vmovn_u32(cd)); + uint16x8_t efgh = vcombine_u16(vmovn_u32(ef), vmovn_u32(gh)); + return v_uint8x16(vcombine_u8(vmovn_u16(abcd), vmovn_u16(efgh))); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val); + float32x4_t res = vmulq_lane_f32(m0.val, vl, 0); + res = vmlaq_lane_f32(res, m1.val, vl, 1); + res = vmlaq_lane_f32(res, m2.val, vh, 0); + res = vmlaq_lane_f32(res, m3.val, vh, 1); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val); + float32x4_t res = vmulq_lane_f32(m0.val, vl, 0); + res = vmlaq_lane_f32(res, m1.val, vl, 1); + res = vmlaq_lane_f32(res, m2.val, vh, 0); + res = vaddq_f32(res, a.val); + return v_float32x4(res); +} + +#define OPENCV_HAL_IMPL_NEON_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint8x16, vqaddq_u8) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint8x16, vqsubq_u8) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int8x16, vqaddq_s8) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int8x16, vqsubq_s8) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint16x8, vqaddq_u16) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint16x8, vqsubq_u16) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int16x8, vqaddq_s16) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int16x8, vqsubq_s16) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int32x4, vaddq_s32) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int32x4, vsubq_s32) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_int32x4, vmulq_s32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint32x4, vaddq_u32) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint32x4, vsubq_u32) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_uint32x4, vmulq_u32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float32x4, vaddq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float32x4, vsubq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float32x4, vmulq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int64x2, vaddq_s64) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int64x2, vsubq_s64) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint64x2, vaddq_u64) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint64x2, vsubq_u64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float32x4, vdivq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float64x2, vaddq_f64) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float64x2, vsubq_f64) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float64x2, vmulq_f64) +OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float64x2, vdivq_f64) +#else +inline v_float32x4 operator / (const v_float32x4& a, const v_float32x4& b) +{ + float32x4_t reciprocal = vrecpeq_f32(b.val); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + return v_float32x4(vmulq_f32(a.val, reciprocal)); +} +inline v_float32x4& operator /= (v_float32x4& a, const v_float32x4& b) +{ + float32x4_t reciprocal = vrecpeq_f32(b.val); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + a.val = vmulq_f32(a.val, reciprocal); + return a; +} +#endif + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_NEON_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_uint16x8, v_uint32x4) + +// Multiply and expand +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + c.val = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_s8(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_s8(vget_high_s8(a.val), vget_high_s8(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + c.val = vmull_u8(vget_low_u8(a.val), vget_low_u8(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_u8(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_u8(vget_high_u8(a.val), vget_high_u8(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + c.val = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_s16(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + c.val = vmull_u16(vget_low_u16(a.val), vget_low_u16(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_u16(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + c.val = vmull_u32(vget_low_u32(a.val), vget_low_u32(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_u32(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_u32(vget_high_u32(a.val), vget_high_u32(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + return v_int16x8(vcombine_s16( + vshrn_n_s32(vmull_s16( vget_low_s16(a.val), vget_low_s16(b.val)), 16), + vshrn_n_s32( +#if CV_NEON_AARCH64 + vmull_high_s16(a.val, b.val) +#else // #if CV_NEON_AARCH64 + vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)) +#endif // #if CV_NEON_AARCH64 + , 16) + )); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint16x8(vcombine_u16( + vshrn_n_u32(vmull_u16( vget_low_u16(a.val), vget_low_u16(b.val)), 16), + vshrn_n_u32( +#if CV_NEON_AARCH64 + vmull_high_u16(a.val, b.val) +#else // #if CV_NEON_AARCH64 + vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)) +#endif // #if CV_NEON_AARCH64 + , 16) + )); +} + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + int16x8_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int16x4_t a0 = vget_low_s16(uzp1); + int16x4_t b0 = vget_high_s16(uzp1); + int16x4_t a1 = vget_low_s16(uzp2); + int16x4_t b1 = vget_high_s16(uzp2); + int32x4_t p = vmull_s16(a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +} +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + int16x8_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int16x4_t a0 = vget_low_s16(uzp1); + int16x4_t b0 = vget_high_s16(uzp1); + int16x4_t a1 = vget_low_s16(uzp2); + int16x4_t b1 = vget_high_s16(uzp2); + int32x4_t p = vmlal_s16(c.val, a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +} + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + int32x4_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int32x2_t a0 = vget_low_s32(uzp1); + int32x2_t b0 = vget_high_s32(uzp1); + int32x2_t a1 = vget_low_s32(uzp2); + int32x2_t b1 = vget_high_s32(uzp2); + int64x2_t p = vmull_s32(a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + int32x4_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int32x2_t a0 = vget_low_s32(uzp1); + int32x2_t b0 = vget_high_s32(uzp1); + int32x2_t a1 = vget_low_s32(uzp2); + int32x2_t b1 = vget_high_s32(uzp2); + int64x2_t p = vmlal_s32(c.val, a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(vdupq_n_u32(0), a.val, b.val)); +#else + const uint8x16_t zero = vreinterpretq_u8_u32(vdupq_n_u32(0)); + const uint8x16_t mask = vreinterpretq_u8_u32(vdupq_n_u32(0x00FF00FF)); + const uint16x8_t zero32 = vreinterpretq_u16_u32(vdupq_n_u32(0)); + const uint16x8_t mask32 = vreinterpretq_u16_u32(vdupq_n_u32(0x0000FFFF)); + + uint16x8_t even = vmulq_u16(vreinterpretq_u16_u8(vbslq_u8(mask, a.val, zero)), + vreinterpretq_u16_u8(vbslq_u8(mask, b.val, zero))); + uint16x8_t odd = vmulq_u16(vshrq_n_u16(vreinterpretq_u16_u8(a.val), 8), + vshrq_n_u16(vreinterpretq_u16_u8(b.val), 8)); + + uint32x4_t s0 = vaddq_u32(vreinterpretq_u32_u16(vbslq_u16(mask32, even, zero32)), + vreinterpretq_u32_u16(vbslq_u16(mask32, odd, zero32))); + uint32x4_t s1 = vaddq_u32(vshrq_n_u32(vreinterpretq_u32_u16(even), 16), + vshrq_n_u32(vreinterpretq_u32_u16(odd), 16)); + return v_uint32x4(vaddq_u32(s0, s1)); +#endif +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, + const v_uint32x4& c) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(c.val, a.val, b.val)); +#else + return v_dotprod_expand(a, b) + c; +#endif +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(vdupq_n_s32(0), a.val, b.val)); +#else + int16x8_t p0 = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); + int16x8_t p1 = vmull_s8(vget_high_s8(a.val), vget_high_s8(b.val)); + int16x8_t uzp1, uzp2; + _v128_unzip(p0, p1, uzp1, uzp2); + int16x8_t sum = vaddq_s16(uzp1, uzp2); + int16x4_t uzpl1, uzpl2; + _v128_unzip(vget_low_s16(sum), vget_high_s16(sum), uzpl1, uzpl2); + return v_int32x4(vaddl_s16(uzpl1, uzpl2)); +#endif +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(c.val, a.val, b.val)); +#else + return v_dotprod_expand(a, b) + c; +#endif +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + const uint16x8_t zero = vreinterpretq_u16_u32(vdupq_n_u32(0)); + const uint16x8_t mask = vreinterpretq_u16_u32(vdupq_n_u32(0x0000FFFF)); + + uint32x4_t even = vmulq_u32(vreinterpretq_u32_u16(vbslq_u16(mask, a.val, zero)), + vreinterpretq_u32_u16(vbslq_u16(mask, b.val, zero))); + uint32x4_t odd = vmulq_u32(vshrq_n_u32(vreinterpretq_u32_u16(a.val), 16), + vshrq_n_u32(vreinterpretq_u32_u16(b.val), 16)); + uint32x4_t uzp1, uzp2; + _v128_unzip(even, odd, uzp1, uzp2); + uint64x2_t s0 = vaddl_u32(vget_low_u32(uzp1), vget_high_u32(uzp1)); + uint64x2_t s1 = vaddl_u32(vget_low_u32(uzp2), vget_high_u32(uzp2)); + return v_uint64x2(vaddq_u64(s0, s1)); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + int32x4_t p0 = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); + int32x4_t p1 = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)); + + int32x4_t uzp1, uzp2; + _v128_unzip(p0, p1, uzp1, uzp2); + int32x4_t sum = vaddq_s32(uzp1, uzp2); + + int32x2_t uzpl1, uzpl2; + _v128_unzip(vget_low_s32(sum), vget_high_s32(sum), uzpl1, uzpl2); + return v_int64x2(vaddl_s32(uzpl1, uzpl2)); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, + const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, + const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } +#endif + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ +#if CV_NEON_AARCH64 + int32x4_t p = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); + return v_int32x4(vmlal_high_s16(p, a.val, b.val)); +#else + int16x4_t a0 = vget_low_s16(a.val); + int16x4_t a1 = vget_high_s16(a.val); + int16x4_t b0 = vget_low_s16(b.val); + int16x4_t b1 = vget_high_s16(b.val); + int32x4_t p = vmull_s16(a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +#endif +} +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ +#if CV_NEON_AARCH64 + int32x4_t p = vmlal_s16(c.val, vget_low_s16(a.val), vget_low_s16(b.val)); + return v_int32x4(vmlal_high_s16(p, a.val, b.val)); +#else + int16x4_t a0 = vget_low_s16(a.val); + int16x4_t a1 = vget_high_s16(a.val); + int16x4_t b0 = vget_low_s16(b.val); + int16x4_t b1 = vget_high_s16(b.val); + int32x4_t p = vmlal_s16(c.val, a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +#endif +} + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_NEON_AARCH64 + int64x2_t p = vmull_s32(vget_low_s32(a.val), vget_low_s32(b.val)); + return v_int64x2(vmlal_high_s32(p, a.val, b.val)); +#else + int32x2_t a0 = vget_low_s32(a.val); + int32x2_t a1 = vget_high_s32(a.val); + int32x2_t b0 = vget_low_s32(b.val); + int32x2_t b1 = vget_high_s32(b.val); + int64x2_t p = vmull_s32(a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +#endif +} +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ +#if CV_NEON_AARCH64 + int64x2_t p = vmlal_s32(c.val, vget_low_s32(a.val), vget_low_s32(b.val)); + return v_int64x2(vmlal_high_s32(p, a.val, b.val)); +#else + int32x2_t a0 = vget_low_s32(a.val); + int32x2_t a1 = vget_high_s32(a.val); + int32x2_t b0 = vget_low_s32(b.val); + int32x2_t b1 = vget_high_s32(b.val); + int64x2_t p = vmlal_s32(c.val, a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +#endif +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(vdupq_n_u32(0), a.val, b.val)); +#else + uint16x8_t p0 = vmull_u8(vget_low_u8(a.val), vget_low_u8(b.val)); + uint16x8_t p1 = vmull_u8(vget_high_u8(a.val), vget_high_u8(b.val)); + uint32x4_t s0 = vaddl_u16(vget_low_u16(p0), vget_low_u16(p1)); + uint32x4_t s1 = vaddl_u16(vget_high_u16(p0), vget_high_u16(p1)); + return v_uint32x4(vaddq_u32(s0, s1)); +#endif +} +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(c.val, a.val, b.val)); +#else + return v_dotprod_expand_fast(a, b) + c; +#endif +} + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(vdupq_n_s32(0), a.val, b.val)); +#else + int16x8_t prod = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); + prod = vmlal_s8(prod, vget_high_s8(a.val), vget_high_s8(b.val)); + return v_int32x4(vaddl_s16(vget_low_s16(prod), vget_high_s16(prod))); +#endif +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(c.val, a.val, b.val)); +#else + return v_dotprod_expand_fast(a, b) + c; +#endif +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + uint32x4_t p0 = vmull_u16(vget_low_u16(a.val), vget_low_u16(b.val)); + uint32x4_t p1 = vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)); + uint64x2_t s0 = vaddl_u32(vget_low_u32(p0), vget_high_u32(p0)); + uint64x2_t s1 = vaddl_u32(vget_low_u32(p1), vget_high_u32(p1)); + return v_uint64x2(vaddq_u64(s0, s1)); +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + int32x4_t prod = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); + prod = vmlal_s16(prod, vget_high_s16(a.val), vget_high_s16(b.val)); + return v_int64x2(vaddl_s32(vget_low_s32(prod), vget_high_s32(prod))); +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod_fast(a, b)); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } +#endif + + +#define OPENCV_HAL_IMPL_NEON_LOGIC_OP(_Tpvec, suffix) \ + OPENCV_HAL_IMPL_NEON_BIN_OP(&, _Tpvec, vandq_##suffix) \ + OPENCV_HAL_IMPL_NEON_BIN_OP(|, _Tpvec, vorrq_##suffix) \ + OPENCV_HAL_IMPL_NEON_BIN_OP(^, _Tpvec, veorq_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { \ + return _Tpvec(vreinterpretq_##suffix##_u8(vmvnq_u8(vreinterpretq_u8_##suffix(a.val)))); \ + } + +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint8x16, u8) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int8x16, s8) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint16x8, u16) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int16x8, s16) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint32x4, u32) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int32x4, s32) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint64x2, u64) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int64x2, s64) + +#define OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(vreinterpretq_f32_s32(intrin(vreinterpretq_s32_f32(a.val), vreinterpretq_s32_f32(b.val)))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a.val = vreinterpretq_f32_s32(intrin(vreinterpretq_s32_f32(a.val), vreinterpretq_s32_f32(b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(&, vandq_s32) +OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(|, vorrq_s32) +OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(^, veorq_s32) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4(vreinterpretq_f32_s32(vmvnq_s32(vreinterpretq_s32_f32(a.val)))); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(vsqrtq_f32(x.val)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + v_float32x4 one = v_setall_f32(1.0f); + return one / v_sqrt(x); +} +#else +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + float32x4_t x1 = vmaxq_f32(x.val, vdupq_n_f32(FLT_MIN)); + float32x4_t e = vrsqrteq_f32(x1); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); + return v_float32x4(vmulq_f32(x.val, e)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + float32x4_t e = vrsqrteq_f32(x.val); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e); + return v_float32x4(e); +} +#endif + +#define OPENCV_HAL_IMPL_NEON_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ +inline _Tpuvec v_abs(const _Tpsvec& a) { return v_reinterpret_as_##usuffix(_Tpsvec(vabsq_##ssuffix(a.val))); } + +OPENCV_HAL_IMPL_NEON_ABS(v_uint8x16, v_int8x16, u8, s8) +OPENCV_HAL_IMPL_NEON_ABS(v_uint16x8, v_int16x8, u16, s16) +OPENCV_HAL_IMPL_NEON_ABS(v_uint32x4, v_int32x4, u32, s32) + +inline v_float32x4 v_abs(v_float32x4 x) +{ return v_float32x4(vabsq_f32(x.val)); } + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val)))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a.val = vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(&, vandq_s64) +OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(|, vorrq_s64) +OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(^, veorq_s64) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2(vreinterpretq_f64_s32(vmvnq_s32(vreinterpretq_s32_f64(a.val)))); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(vsqrtq_f64(x.val)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + v_float64x2 one = v_setall_f64(1.0f); + return one / v_sqrt(x); +} + +inline v_float64x2 v_abs(v_float64x2 x) +{ return v_float64x2(vabsq_f64(x.val)); } +#endif + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_NEON_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_min, vminq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_max, vmaxq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_min, vminq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_max, vmaxq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_min, vminq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_max, vmaxq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_min, vminq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_max, vmaxq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_min, vminq_u32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_max, vmaxq_u32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_min, vminq_s32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_max, vmaxq_s32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_min, vminq_f32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_max, vmaxq_f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_min, vminq_f64) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_max, vmaxq_f64) +#endif + +#if CV_SIMD128_64F +inline int64x2_t vmvnq_s64(int64x2_t a) +{ + int64x2_t vx = vreinterpretq_s64_u32(vdupq_n_u32(0xFFFFFFFF)); + return veorq_s64(a, vx); +} +inline uint64x2_t vmvnq_u64(uint64x2_t a) +{ + uint64x2_t vx = vreinterpretq_u64_u32(vdupq_n_u32(0xFFFFFFFF)); + return veorq_u64(a, vx); +} +#endif +#define OPENCV_HAL_IMPL_NEON_INT_CMP_OP(_Tpvec, cast, suffix, not_suffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vceqq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vmvnq_##not_suffix(vceqq_##suffix(a.val, b.val)))); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcltq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcgtq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcleq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcgeq_##suffix(a.val, b.val))); } + +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint8x16, OPENCV_HAL_NOP, u8, u8) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int8x16, vreinterpretq_s8_u8, s8, u8) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint16x8, OPENCV_HAL_NOP, u16, u16) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int16x8, vreinterpretq_s16_u16, s16, u16) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint32x4, OPENCV_HAL_NOP, u32, u32) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int32x4, vreinterpretq_s32_u32, s32, u32) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float32x4, vreinterpretq_f32_u32, f32, u32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint64x2, OPENCV_HAL_NOP, u64, u64) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int64x2, vreinterpretq_s64_u64, s64, u64) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float64x2, vreinterpretq_f64_u64, f64, u64) +#endif + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(vreinterpretq_f32_u32(vceqq_f32(a.val, a.val))); } +#if CV_SIMD128_64F +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(vreinterpretq_f64_u64(vceqq_f64(a.val, a.val))); } +#endif + +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_add_wrap, vaddq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_add_wrap, vaddq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_add_wrap, vaddq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_add_wrap, vaddq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_sub_wrap, vsubq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_sub_wrap, vsubq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_sub_wrap, vsubq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_sub_wrap, vsubq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_mul_wrap, vmulq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_mul_wrap, vmulq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_mul_wrap, vmulq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_mul_wrap, vmulq_s16) + +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_absdiff, vabdq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_absdiff, vabdq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_absdiff, vabdq_u32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_absdiff, vabdq_f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_absdiff, vabdq_f64) +#endif + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ return v_int8x16(vqabsq_s8(vqsubq_s8(a.val, b.val))); } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_int16x8(vqabsq_s16(vqsubq_s16(a.val, b.val))); } + +#define OPENCV_HAL_IMPL_NEON_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \ +inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec2(cast(intrin(a.val, b.val))); \ +} + +OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int8x16, v_uint8x16, vreinterpretq_u8_s8, v_absdiff, vabdq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int16x8, v_uint16x8, vreinterpretq_u16_s16, v_absdiff, vabdq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int32x4, v_uint32x4, vreinterpretq_u32_s32, v_absdiff, vabdq_s32) + +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val)); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ +#if CV_SIMD128_64F + // ARMv8, which adds support for 64-bit floating-point (so CV_SIMD128_64F is defined), + // also adds FMA support both for single- and double-precision floating-point vectors + return v_float32x4(vfmaq_f32(c.val, a.val, b.val)); +#else + return v_float32x4(vmlaq_f32(c.val, a.val, b.val)); +#endif +} + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(vmlaq_s32(c.val, a.val, b.val)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val))); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val))); +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(vfmaq_f64(c.val, a.val, b.val)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} +#endif + +// trade efficiency for convenience +#define OPENCV_HAL_IMPL_NEON_SHIFT_OP(_Tpvec, suffix, _Tps, ssuffix) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ return _Tpvec(vshlq_##suffix(a.val, vdupq_n_##ssuffix((_Tps)n))); } \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ return _Tpvec(vshlq_##suffix(a.val, vdupq_n_##ssuffix((_Tps)-n))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec(vshlq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec(vshrq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_rshr(const _Tpvec& a) \ +{ return _Tpvec(vrshrq_n_##suffix(a.val, n)); } + +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint8x16, u8, schar, s8) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int8x16, s8, schar, s8) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint16x8, u16, short, s16) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int16x8, s16, short, s16) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint32x4, u32, int, s32) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int32x4, s32, int, s32) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint64x2, u64, int64, s64) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int64x2, s64, int64, s64) + +#define OPENCV_HAL_IMPL_NEON_ROTATE_OP(_Tpvec, suffix) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ return _Tpvec(vextq_##suffix(a.val, vdupq_n_##suffix(0), n)); } \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ return _Tpvec(vextq_##suffix(vdupq_n_##suffix(0), a.val, _Tpvec::nlanes - n)); } \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vextq_##suffix(a.val, b.val, n)); } \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vextq_##suffix(b.val, a.val, _Tpvec::nlanes - n)); } \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ CV_UNUSED(b); return a; } + +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint8x16, u8) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int8x16, s8) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint16x8, u16) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int16x8, s16) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint32x4, u32) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int32x4, s32) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_float32x4, f32) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint64x2, u64) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int64x2, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_float64x2, f64) +#endif + +#if defined(__clang__) && defined(__aarch64__) +// avoid LD2 instruction. details: https://github.com/opencv/opencv/issues/14863 +#define OPENCV_HAL_IMPL_NEON_LOAD_LOW_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ \ +typedef uint64 CV_DECL_ALIGNED(1) unaligned_uint64; \ +uint64 v = *(unaligned_uint64*)ptr; \ +return _Tpvec(v_reinterpret_as_##suffix(v_uint64x2(v, (uint64)123456))); \ +} +#else +#define OPENCV_HAL_IMPL_NEON_LOAD_LOW_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr), vdup_n_##suffix((_Tp)0))); } +#endif + +#define OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(vld1q_##suffix(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(vld1q_##suffix(ptr)); } \ +OPENCV_HAL_IMPL_NEON_LOAD_LOW_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr0), vld1_##suffix(ptr1))); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ vst1_##suffix(ptr, vget_low_##suffix(a.val)); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ vst1_##suffix(ptr, vget_high_##suffix(a.val)); } + +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64) +#endif + +inline unsigned v_reduce_sum(const v_uint8x16& a) +{ +#if CV_NEON_AARCH64 + uint16_t t0 = vaddlvq_u8(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(a.val)); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline int v_reduce_sum(const v_int8x16& a) +{ +#if CV_NEON_AARCH64 + int16_t t0 = vaddlvq_s8(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + int32x4_t t0 = vpaddlq_s16(vpaddlq_s8(a.val)); + int32x2_t t1 = vpadd_s32(vget_low_s32(t0), vget_high_s32(t0)); + return vget_lane_s32(vpadd_s32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sum(const v_uint16x8& a) +{ +#if CV_NEON_AARCH64 + uint32_t t0 = vaddlvq_u16(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(a.val); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline int v_reduce_sum(const v_int16x8& a) +{ +#if CV_NEON_AARCH64 + int32_t t0 = vaddlvq_s16(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + int32x4_t t0 = vpaddlq_s16(a.val); + int32x2_t t1 = vpadd_s32(vget_low_s32(t0), vget_high_s32(t0)); + return vget_lane_s32(vpadd_s32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return v##vectorfunc##vq_##suffix(a.val); \ +} +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ + a0 = vp##vectorfunc##_##suffix(a0, a0); \ + a0 = vp##vectorfunc##_##suffix(a0, a0); \ + return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, a0),0); \ +} +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_uint8x16, uint8x8, uchar, max, max, u8) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_uint8x16, uint8x8, uchar, min, min, u8) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_int8x16, int8x8, schar, max, max, s8) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_int8x16, int8x8, schar, min, min, s8) + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return v##vectorfunc##vq_##suffix(a.val); \ +} +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ + a0 = vp##vectorfunc##_##suffix(a0, a0); \ + return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, a0),0); \ +} +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, ushort, max, max, u16) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, ushort, min, min, u16) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, max, max, s16) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, min, min, s16) + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return v##vectorfunc##vq_##suffix(a.val); \ +} +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ + return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, vget_high_##suffix(a.val)),0); \ +} +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, sum, add, u32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, max, max, u32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, min, min, u32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, sum, add, s32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, max, max, s32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, min, min, s32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, sum, add, f32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, max, max, f32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, min, min, f32) + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ +#if CV_NEON_AARCH64 + return vaddvq_u64(a.val); +#else // #if CV_NEON_AARCH64 + return vget_lane_u64(vadd_u64(vget_low_u64(a.val), vget_high_u64(a.val)),0); +#endif // #if CV_NEON_AARCH64 +} +inline int64 v_reduce_sum(const v_int64x2& a) +{ +#if CV_NEON_AARCH64 + return vaddvq_s64(a.val); +#else // #if CV_NEON_AARCH64 + return vget_lane_s64(vadd_s64(vget_low_s64(a.val), vget_high_s64(a.val)),0); +#endif // #if CV_NEON_AARCH64 +} +#if CV_SIMD128_64F +inline double v_reduce_sum(const v_float64x2& a) +{ + return vaddvq_f64(a.val); +} +#endif + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ +#if CV_NEON_AARCH64 + float32x4_t ab = vpaddq_f32(a.val, b.val); // a0+a1 a2+a3 b0+b1 b2+b3 + float32x4_t cd = vpaddq_f32(c.val, d.val); // c0+c1 d0+d1 c2+c3 d2+d3 + return v_float32x4(vpaddq_f32(ab, cd)); // sumA sumB sumC sumD +#else // #if CV_NEON_AARCH64 + float32x4x2_t ab = vtrnq_f32(a.val, b.val); + float32x4x2_t cd = vtrnq_f32(c.val, d.val); + + float32x4_t u0 = vaddq_f32(ab.val[0], ab.val[1]); // a0+a1 b0+b1 a2+a3 b2+b3 + float32x4_t u1 = vaddq_f32(cd.val[0], cd.val[1]); // c0+c1 d0+d1 c2+c3 d2+d3 + + float32x4_t v0 = vcombine_f32(vget_low_f32(u0), vget_low_f32(u1)); + float32x4_t v1 = vcombine_f32(vget_high_f32(u0), vget_high_f32(u1)); + + return v_float32x4(vaddq_f32(v0, v1)); +#endif // #if CV_NEON_AARCH64 +} + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ +#if CV_NEON_AARCH64 + uint8x16_t t0 = vabdq_u8(a.val, b.val); + uint16_t t1 = vaddlvq_u8(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vabdq_u8(a.val, b.val))); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_NEON_AARCH64 + uint8x16_t t0 = vreinterpretq_u8_s8(vabdq_s8(a.val, b.val)); + uint16_t t1 = vaddlvq_u8(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vreinterpretq_u8_s8(vabdq_s8(a.val, b.val)))); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ +#if CV_NEON_AARCH64 + uint16x8_t t0 = vabdq_u16(a.val, b.val); + uint32_t t1 = vaddlvq_u16(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vabdq_u16(a.val, b.val)); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ +#if CV_NEON_AARCH64 + uint16x8_t t0 = vreinterpretq_u16_s16(vabdq_s16(a.val, b.val)); + uint32_t t1 = vaddlvq_u16(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vreinterpretq_u16_s16(vabdq_s16(a.val, b.val))); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ +#if CV_NEON_AARCH64 + uint32x4_t t0 = vabdq_u32(a.val, b.val); + uint32_t t1 = vaddvq_u32(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vabdq_u32(a.val, b.val); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_NEON_AARCH64 + uint32x4_t t0 = vreinterpretq_u32_s32(vabdq_s32(a.val, b.val)); + uint32_t t1 = vaddvq_u32(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vreinterpretq_u32_s32(vabdq_s32(a.val, b.val)); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ +#if CV_NEON_AARCH64 + float32x4_t t0 = vabdq_f32(a.val, b.val); + return vaddvq_f32(t0); +#else // #if CV_NEON_AARCH64 + float32x4_t t0 = vabdq_f32(a.val, b.val); + float32x2_t t1 = vpadd_f32(vget_low_f32(t0), vget_high_f32(t0)); + return vget_lane_f32(vpadd_f32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} + +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ return v_uint8x16(vcntq_u8(a.val)); } +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_uint8x16(vcntq_u8(vreinterpretq_u8_s8(a.val))); } +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ return v_uint16x8(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_u16(a.val)))); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_uint16x8(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_s16(a.val)))); } +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ return v_uint32x4(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_u32(a.val))))); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_uint32x4(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_s32(a.val))))); } +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ return v_uint64x2(vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_u64(a.val)))))); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_uint64x2(vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_s64(a.val)))))); } + +inline int v_signmask(const v_uint8x16& a) +{ +#if CV_NEON_AARCH64 + const int8x16_t signPosition = {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7}; + const uint8x16_t byteOrder = {0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15}; + uint8x16_t v0 = vshlq_u8(vshrq_n_u8(a.val, 7), signPosition); + uint8x16_t v1 = vqtbl1q_u8(v0, byteOrder); + uint32_t t0 = vaddlvq_u16(vreinterpretq_u16_u8(v1)); + return t0; +#else // #if CV_NEON_AARCH64 + int8x8_t m0 = vcreate_s8(CV_BIG_UINT(0x0706050403020100)); + uint8x16_t v0 = vshlq_u8(vshrq_n_u8(a.val, 7), vcombine_s8(m0, m0)); + uint64x2_t v1 = vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(v0))); + return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 8); +#endif // #if CV_NEON_AARCH64 +} + +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } + +inline int v_signmask(const v_uint16x8& a) +{ +#if CV_NEON_AARCH64 + const int16x8_t signPosition = {0,1,2,3,4,5,6,7}; + uint16x8_t v0 = vshlq_u16(vshrq_n_u16(a.val, 15), signPosition); + uint32_t t0 = vaddlvq_u16(v0); + return t0; +#else // #if CV_NEON_AARCH64 + int16x4_t m0 = vcreate_s16(CV_BIG_UINT(0x0003000200010000)); + uint16x8_t v0 = vshlq_u16(vshrq_n_u16(a.val, 15), vcombine_s16(m0, m0)); + uint64x2_t v1 = vpaddlq_u32(vpaddlq_u16(v0)); + return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 4); +#endif // #if CV_NEON_AARCH64 +} +inline int v_signmask(const v_int16x8& a) +{ return v_signmask(v_reinterpret_as_u16(a)); } + +inline int v_signmask(const v_uint32x4& a) +{ +#if CV_NEON_AARCH64 + const int32x4_t signPosition = {0,1,2,3}; + uint32x4_t v0 = vshlq_u32(vshrq_n_u32(a.val, 31), signPosition); + uint32_t t0 = vaddvq_u32(v0); + return t0; +#else // #if CV_NEON_AARCH64 + int32x2_t m0 = vcreate_s32(CV_BIG_UINT(0x0000000100000000)); + uint32x4_t v0 = vshlq_u32(vshrq_n_u32(a.val, 31), vcombine_s32(m0, m0)); + uint64x2_t v1 = vpaddlq_u32(v0); + return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 2); +#endif // #if CV_NEON_AARCH64 +} +inline int v_signmask(const v_int32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_uint64x2& a) +{ +#if CV_NEON_AARCH64 + const int64x2_t signPosition = {0,1}; + uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), signPosition); + uint64_t t0 = vaddvq_u64(v0); + return t0; +#else // #if CV_NEON_AARCH64 + int64x1_t m0 = vdup_n_s64(0); + uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), vcombine_s64(m0, m0)); + return (int)vgetq_lane_u64(v0, 0) + ((int)vgetq_lane_u64(v0, 1) << 1); +#endif // #if CV_NEON_AARCH64 +} +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#if CV_SIMD128_64F +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#endif + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(a)); } +#if CV_SIMD128_64F +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(a)); } +#endif + +#if CV_NEON_AARCH64 + #define OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(_Tpvec, suffix, shift) \ + inline bool v_check_all(const v_##_Tpvec& a) \ + { \ + return (vminvq_##suffix(a.val) >> shift) != 0; \ + } \ + inline bool v_check_any(const v_##_Tpvec& a) \ + { \ + return (vmaxvq_##suffix(a.val) >> shift) != 0; \ + } +#else // #if CV_NEON_AARCH64 + #define OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(_Tpvec, suffix, shift) \ + inline bool v_check_all(const v_##_Tpvec& a) \ + { \ + _Tpvec##_t v0 = vshrq_n_##suffix(vmvnq_##suffix(a.val), shift); \ + uint64x2_t v1 = vreinterpretq_u64_##suffix(v0); \ + return (vgetq_lane_u64(v1, 0) | vgetq_lane_u64(v1, 1)) == 0; \ + } \ + inline bool v_check_any(const v_##_Tpvec& a) \ + { \ + _Tpvec##_t v0 = vshrq_n_##suffix(a.val, shift); \ + uint64x2_t v1 = vreinterpretq_u64_##suffix(v0); \ + return (vgetq_lane_u64(v1, 0) | vgetq_lane_u64(v1, 1)) != 0; \ + } +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint8x16, u8, 7) +OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint16x8, u16, 15) +OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint32x4, u32, 31) + +inline bool v_check_all(const v_uint64x2& a) +{ + uint64x2_t v0 = vshrq_n_u64(a.val, 63); + return (vgetq_lane_u64(v0, 0) & vgetq_lane_u64(v0, 1)) == 1; +} +inline bool v_check_any(const v_uint64x2& a) +{ + uint64x2_t v0 = vshrq_n_u64(a.val, 63); + return (vgetq_lane_u64(v0, 0) | vgetq_lane_u64(v0, 1)) != 0; +} + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } + +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +#if CV_SIMD128_64F +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +#endif + +#define OPENCV_HAL_IMPL_NEON_SELECT(_Tpvec, suffix, usuffix) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vbslq_##suffix(vreinterpretq_##usuffix##_##suffix(mask.val), a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_NEON_SELECT(v_uint8x16, u8, u8) +OPENCV_HAL_IMPL_NEON_SELECT(v_int8x16, s8, u8) +OPENCV_HAL_IMPL_NEON_SELECT(v_uint16x8, u16, u16) +OPENCV_HAL_IMPL_NEON_SELECT(v_int16x8, s16, u16) +OPENCV_HAL_IMPL_NEON_SELECT(v_uint32x4, u32, u32) +OPENCV_HAL_IMPL_NEON_SELECT(v_int32x4, s32, u32) +OPENCV_HAL_IMPL_NEON_SELECT(v_float32x4, f32, u32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_SELECT(v_float64x2, f64, u64) +#endif + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = vmovl_##suffix(vget_low_##suffix(a.val)); \ + b1.val = vmovl_high_##suffix(a.val); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_##suffix(vget_low_##suffix(a.val))); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_high_##suffix(a.val)); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(vmovl_##suffix(vld1_##suffix(ptr))); \ +} +#else +#define OPENCV_HAL_IMPL_NEON_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = vmovl_##suffix(vget_low_##suffix(a.val)); \ + b1.val = vmovl_##suffix(vget_high_##suffix(a.val)); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_##suffix(vget_low_##suffix(a.val))); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_##suffix(vget_high_##suffix(a.val))); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(vmovl_##suffix(vld1_##suffix(ptr))); \ +} +#endif + +OPENCV_HAL_IMPL_NEON_EXPAND(v_uint8x16, v_uint16x8, uchar, u8) +OPENCV_HAL_IMPL_NEON_EXPAND(v_int8x16, v_int16x8, schar, s8) +OPENCV_HAL_IMPL_NEON_EXPAND(v_uint16x8, v_uint32x4, ushort, u16) +OPENCV_HAL_IMPL_NEON_EXPAND(v_int16x8, v_int32x4, short, s16) +OPENCV_HAL_IMPL_NEON_EXPAND(v_uint32x4, v_uint64x2, uint, u32) +OPENCV_HAL_IMPL_NEON_EXPAND(v_int32x4, v_int64x2, int, s32) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + typedef unsigned int CV_DECL_ALIGNED(1) unaligned_uint; + uint8x8_t v0 = vcreate_u8(*(unaligned_uint*)ptr); + uint16x4_t v1 = vget_low_u16(vmovl_u8(v0)); + return v_uint32x4(vmovl_u16(v1)); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + typedef unsigned int CV_DECL_ALIGNED(1) unaligned_uint; + int8x8_t v0 = vcreate_s8(*(unaligned_uint*)ptr); + int16x4_t v1 = vget_low_s16(vmovl_s8(v0)); + return v_int32x4(vmovl_s16(v1)); +} + +#if defined(__aarch64__) || defined(_M_ARM64) +#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + b0.val = vzip1q_##suffix(a0.val, a1.val); \ + b1.val = vzip2q_##suffix(a0.val, a1.val); \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \ + d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \ +} +#else +#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + _Tpvec##x2_t p = vzipq_##suffix(a0.val, a1.val); \ + b0.val = p.val[0]; \ + b1.val = p.val[1]; \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \ + d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \ +} +#endif + +OPENCV_HAL_IMPL_NEON_UNPACKS(uint8x16, u8) +OPENCV_HAL_IMPL_NEON_UNPACKS(int8x16, s8) +OPENCV_HAL_IMPL_NEON_UNPACKS(uint16x8, u16) +OPENCV_HAL_IMPL_NEON_UNPACKS(int16x8, s16) +OPENCV_HAL_IMPL_NEON_UNPACKS(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_UNPACKS(int32x4, s32) +OPENCV_HAL_IMPL_NEON_UNPACKS(float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_UNPACKS(float64x2, f64) +#endif + +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + uint8x16_t vec = vrev64q_u8(a.val); + return v_uint8x16(vextq_u8(vec, vec, 8)); +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + uint16x8_t vec = vrev64q_u16(a.val); + return v_uint16x8(vextq_u16(vec, vec, 4)); +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + uint32x4_t vec = vrev64q_u32(a.val); + return v_uint32x4(vextq_u32(vec, vec, 2)); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + uint64x2_t vec = a.val; + uint64x1_t vec_lo = vget_low_u64(vec); + uint64x1_t vec_hi = vget_high_u64(vec); + return v_uint64x2(vcombine_u64(vec_hi, vec_lo)); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +#if CV_SIMD128_64F +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } +#endif + +#define OPENCV_HAL_IMPL_NEON_EXTRACT(_Tpvec, suffix) \ +template \ +inline v_##_Tpvec v_extract(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vextq_##suffix(a.val, b.val, s)); \ +} + +OPENCV_HAL_IMPL_NEON_EXTRACT(uint8x16, u8) +OPENCV_HAL_IMPL_NEON_EXTRACT(int8x16, s8) +OPENCV_HAL_IMPL_NEON_EXTRACT(uint16x8, u16) +OPENCV_HAL_IMPL_NEON_EXTRACT(int16x8, s16) +OPENCV_HAL_IMPL_NEON_EXTRACT(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_EXTRACT(int32x4, s32) +OPENCV_HAL_IMPL_NEON_EXTRACT(uint64x2, u64) +OPENCV_HAL_IMPL_NEON_EXTRACT(int64x2, s64) +OPENCV_HAL_IMPL_NEON_EXTRACT(float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_EXTRACT(float64x2, f64) +#endif + +#define OPENCV_HAL_IMPL_NEON_EXTRACT_N(_Tpvec, _Tp, suffix) \ +template inline _Tp v_extract_n(_Tpvec v) { return vgetq_lane_##suffix(v.val, i); } + +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint32x4, uint, u32) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_float64x2, double, f64) +#endif + +#define OPENCV_HAL_IMPL_NEON_BROADCAST(_Tpvec, _Tp, suffix) \ +template inline _Tpvec v_broadcast_element(_Tpvec v) { _Tp t = v_extract_n(v); return v_setall_##suffix(t); } + +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint32x4, uint, u32) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BROADCAST(v_float64x2, double, f64) +#endif + +#if CV_SIMD128_64F +inline v_int32x4 v_round(const v_float32x4& a) +{ + float32x4_t a_ = a.val; + int32x4_t result; + __asm__ ("fcvtns %0.4s, %1.4s" + : "=w"(result) + : "w"(a_) + : /* No clobbers */); + return v_int32x4(result); +} +#else +inline v_int32x4 v_round(const v_float32x4& a) +{ + static const int32x4_t v_sign = vdupq_n_s32(1 << 31), + v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f)); + + int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(a.val))); + return v_int32x4(vcvtq_s32_f32(vaddq_f32(a.val, vreinterpretq_f32_s32(v_addition)))); +} +#endif +inline v_int32x4 v_floor(const v_float32x4& a) +{ + int32x4_t a1 = vcvtq_s32_f32(a.val); + uint32x4_t mask = vcgtq_f32(vcvtq_f32_s32(a1), a.val); + return v_int32x4(vaddq_s32(a1, vreinterpretq_s32_u32(mask))); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + int32x4_t a1 = vcvtq_s32_f32(a.val); + uint32x4_t mask = vcgtq_f32(a.val, vcvtq_f32_s32(a1)); + return v_int32x4(vsubq_s32(a1, vreinterpretq_s32_u32(mask))); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(vcvtq_s32_f32(a.val)); } + +#if CV_SIMD128_64F +inline v_int32x4 v_round(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); +} + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), vmovn_s64(vcvtaq_s64_f64(b.val)))); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + int64x2_t a1 = vcvtq_s64_f64(a.val); + uint64x2_t mask = vcgtq_f64(vcvtq_f64_s64(a1), a.val); + a1 = vaddq_s64(a1, vreinterpretq_s64_u64(mask)); + return v_int32x4(vcombine_s32(vmovn_s64(a1), zero)); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + int64x2_t a1 = vcvtq_s64_f64(a.val); + uint64x2_t mask = vcgtq_f64(a.val, vcvtq_f64_s64(a1)); + a1 = vsubq_s64(a1, vreinterpretq_s64_u64(mask)); + return v_int32x4(vcombine_s32(vmovn_s64(a1), zero)); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); +} +#endif + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(_Tpvec, suffix) \ +inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ + const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ + v_##_Tpvec& b0, v_##_Tpvec& b1, \ + v_##_Tpvec& b2, v_##_Tpvec& b3) \ +{ \ + /* -- Pass 1: 64b transpose */ \ + _Tpvec##_t t0 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn1q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a0.val), \ + vreinterpretq_##suffix##64_##suffix##32(a2.val))); \ + _Tpvec##_t t1 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn1q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a1.val), \ + vreinterpretq_##suffix##64_##suffix##32(a3.val))); \ + _Tpvec##_t t2 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn2q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a0.val), \ + vreinterpretq_##suffix##64_##suffix##32(a2.val))); \ + _Tpvec##_t t3 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn2q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a1.val), \ + vreinterpretq_##suffix##64_##suffix##32(a3.val))); \ + /* -- Pass 2: 32b transpose */ \ + b0.val = vtrn1q_##suffix##32(t0, t1); \ + b1.val = vtrn2q_##suffix##32(t0, t1); \ + b2.val = vtrn1q_##suffix##32(t2, t3); \ + b3.val = vtrn2q_##suffix##32(t2, t3); \ +} + +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(uint32x4, u) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(int32x4, s) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(float32x4, f) +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(_Tpvec, suffix) \ +inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ + const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ + v_##_Tpvec& b0, v_##_Tpvec& b1, \ + v_##_Tpvec& b2, v_##_Tpvec& b3) \ +{ \ + /* m00 m01 m02 m03 */ \ + /* m10 m11 m12 m13 */ \ + /* m20 m21 m22 m23 */ \ + /* m30 m31 m32 m33 */ \ + _Tpvec##x2_t t0 = vtrnq_##suffix(a0.val, a1.val); \ + _Tpvec##x2_t t1 = vtrnq_##suffix(a2.val, a3.val); \ + /* m00 m10 m02 m12 */ \ + /* m01 m11 m03 m13 */ \ + /* m20 m30 m22 m32 */ \ + /* m21 m31 m23 m33 */ \ + b0.val = vcombine_##suffix(vget_low_##suffix(t0.val[0]), vget_low_##suffix(t1.val[0])); \ + b1.val = vcombine_##suffix(vget_low_##suffix(t0.val[1]), vget_low_##suffix(t1.val[1])); \ + b2.val = vcombine_##suffix(vget_high_##suffix(t0.val[0]), vget_high_##suffix(t1.val[0])); \ + b3.val = vcombine_##suffix(vget_high_##suffix(t0.val[1]), vget_high_##suffix(t1.val[1])); \ +} + +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(int32x4, s32) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(float32x4, f32) +#endif // #if CV_NEON_AARCH64 + +#define OPENCV_HAL_IMPL_NEON_INTERLEAVED(_Tpvec, _Tp, suffix) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ +{ \ + _Tpvec##x2_t v = vld2q_##suffix(ptr); \ + a.val = v.val[0]; \ + b.val = v.val[1]; \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ +{ \ + _Tpvec##x3_t v = vld3q_##suffix(ptr); \ + a.val = v.val[0]; \ + b.val = v.val[1]; \ + c.val = v.val[2]; \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ + v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + _Tpvec##x4_t v = vld4q_##suffix(ptr); \ + a.val = v.val[0]; \ + b.val = v.val[1]; \ + c.val = v.val[2]; \ + d.val = v.val[3]; \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + _Tpvec##x2_t v; \ + v.val[0] = a.val; \ + v.val[1] = b.val; \ + vst2q_##suffix(ptr, v); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + _Tpvec##x3_t v; \ + v.val[0] = a.val; \ + v.val[1] = b.val; \ + v.val[2] = c.val; \ + vst3q_##suffix(ptr, v); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, const v_##_Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec##x4_t v; \ + v.val[0] = a.val; \ + v.val[1] = b.val; \ + v.val[2] = c.val; \ + v.val[3] = d.val; \ + vst4q_##suffix(ptr, v); \ +} + +#define OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(tp, suffix) \ +inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, v_##tp##x2& b ) \ +{ \ + tp##x1_t a0 = vld1_##suffix(ptr); \ + tp##x1_t b0 = vld1_##suffix(ptr + 1); \ + tp##x1_t a1 = vld1_##suffix(ptr + 2); \ + tp##x1_t b1 = vld1_##suffix(ptr + 3); \ + a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ + b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ +} \ + \ +inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, \ + v_##tp##x2& b, v_##tp##x2& c ) \ +{ \ + tp##x1_t a0 = vld1_##suffix(ptr); \ + tp##x1_t b0 = vld1_##suffix(ptr + 1); \ + tp##x1_t c0 = vld1_##suffix(ptr + 2); \ + tp##x1_t a1 = vld1_##suffix(ptr + 3); \ + tp##x1_t b1 = vld1_##suffix(ptr + 4); \ + tp##x1_t c1 = vld1_##suffix(ptr + 5); \ + a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ + b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ + c = v_##tp##x2(vcombine_##suffix(c0, c1)); \ +} \ + \ +inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, v_##tp##x2& b, \ + v_##tp##x2& c, v_##tp##x2& d ) \ +{ \ + tp##x1_t a0 = vld1_##suffix(ptr); \ + tp##x1_t b0 = vld1_##suffix(ptr + 1); \ + tp##x1_t c0 = vld1_##suffix(ptr + 2); \ + tp##x1_t d0 = vld1_##suffix(ptr + 3); \ + tp##x1_t a1 = vld1_##suffix(ptr + 4); \ + tp##x1_t b1 = vld1_##suffix(ptr + 5); \ + tp##x1_t c1 = vld1_##suffix(ptr + 6); \ + tp##x1_t d1 = vld1_##suffix(ptr + 7); \ + a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ + b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ + c = v_##tp##x2(vcombine_##suffix(c0, c1)); \ + d = v_##tp##x2(vcombine_##suffix(d0, d1)); \ +} \ + \ +inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, const v_##tp##x2& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ + vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ + vst1_##suffix(ptr + 2, vget_high_##suffix(a.val)); \ + vst1_##suffix(ptr + 3, vget_high_##suffix(b.val)); \ +} \ + \ +inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, \ + const v_##tp##x2& b, const v_##tp##x2& c, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ + vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ + vst1_##suffix(ptr + 2, vget_low_##suffix(c.val)); \ + vst1_##suffix(ptr + 3, vget_high_##suffix(a.val)); \ + vst1_##suffix(ptr + 4, vget_high_##suffix(b.val)); \ + vst1_##suffix(ptr + 5, vget_high_##suffix(c.val)); \ +} \ + \ +inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, const v_##tp##x2& b, \ + const v_##tp##x2& c, const v_##tp##x2& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ + vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ + vst1_##suffix(ptr + 2, vget_low_##suffix(c.val)); \ + vst1_##suffix(ptr + 3, vget_low_##suffix(d.val)); \ + vst1_##suffix(ptr + 4, vget_high_##suffix(a.val)); \ + vst1_##suffix(ptr + 5, vget_high_##suffix(b.val)); \ + vst1_##suffix(ptr + 6, vget_high_##suffix(c.val)); \ + vst1_##suffix(ptr + 7, vget_high_##suffix(d.val)); \ +} + +OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_INTERLEAVED(float64x2, double, f64) +#endif + +OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(int64, s64) +OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(uint64, u64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(vcvtq_f32_s32(a.val)); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + float32x2_t zero = vdup_n_f32(0.0f); + return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), zero)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), vcvt_f32_f64(b.val))); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_low_s32(a.val)))); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_high_s32(a.val)))); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vget_low_f32(a.val))); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vget_high_f32(a.val))); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ return v_float64x2(vcvtq_f64_s64(a.val)); } + +#endif + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(vld1q_s8(elems)); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(vld1q_s8(elems)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(vld1q_s8(elems)); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(vld1q_s16(elems)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(vld1q_s16(elems)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(vcombine_s16(vld1_s16(tab + idx[0]), vld1_s16(tab + idx[1]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(vld1q_s32(elems)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(vcombine_s32(vld1_s32(tab + idx[0]), vld1_s32(tab + idx[1]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vld1q_s32(tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(vcombine_s64(vcreate_s64(tab[idx[0]]), vcreate_s64(tab[idx[1]]))); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(vld1q_s64(tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(vld1q_f32(elems)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + typedef uint64 CV_DECL_ALIGNED(1) unaligned_uint64; + + uint64 CV_DECL_ALIGNED(32) elems[2] = + { + *(unaligned_uint64*)(tab + idx[0]), + *(unaligned_uint64*)(tab + idx[1]) + }; + return v_float32x4(vreinterpretq_f32_u64(vld1q_u64(elems))); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(vld1q_f32(tab + idx[0])); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + tab[vgetq_lane_s32(idxvec.val, 2)], + tab[vgetq_lane_s32(idxvec.val, 3)] + }; + return v_int32x4(vld1q_s32(elems)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned CV_DECL_ALIGNED(32) elems[4] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + tab[vgetq_lane_s32(idxvec.val, 2)], + tab[vgetq_lane_s32(idxvec.val, 3)] + }; + return v_uint32x4(vld1q_u32(elems)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + tab[vgetq_lane_s32(idxvec.val, 2)], + tab[vgetq_lane_s32(idxvec.val, 3)] + }; + return v_float32x4(vld1q_f32(elems)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + /*int CV_DECL_ALIGNED(32) idx[4]; + v_store(idx, idxvec); + + float32x4_t xy02 = vcombine_f32(vld1_f32(tab + idx[0]), vld1_f32(tab + idx[2])); + float32x4_t xy13 = vcombine_f32(vld1_f32(tab + idx[1]), vld1_f32(tab + idx[3])); + + float32x4x2_t xxyy = vuzpq_f32(xy02, xy13); + x = v_float32x4(xxyy.val[0]); + y = v_float32x4(xxyy.val[1]);*/ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); + y = v_float32x4(tab[idx[0]+1], tab[idx[1]+1], tab[idx[2]+1], tab[idx[3]+1]); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + return v_int8x16(vcombine_s8(vtbl1_s8(vget_low_s8(vec.val), vcreate_s8(0x0705060403010200)), vtbl1_s8(vget_high_s8(vec.val), vcreate_s8(0x0705060403010200)))); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + return v_int8x16(vcombine_s8(vtbl1_s8(vget_low_s8(vec.val), vcreate_s8(0x0703060205010400)), vtbl1_s8(vget_high_s8(vec.val), vcreate_s8(0x0703060205010400)))); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + return v_int16x8(vreinterpretq_s16_s8(vcombine_s8(vtbl1_s8(vget_low_s8(vreinterpretq_s8_s16(vec.val)), vcreate_s8(0x0706030205040100)), vtbl1_s8(vget_high_s8(vreinterpretq_s8_s16(vec.val)), vcreate_s8(0x0706030205040100))))); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + int16x4x2_t res = vzip_s16(vget_low_s16(vec.val), vget_high_s16(vec.val)); + return v_int16x8(vcombine_s16(res.val[0], res.val[1])); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + int32x2x2_t res = vzip_s32(vget_low_s32(vec.val), vget_high_s32(vec.val)); + return v_int32x4(vcombine_s32(res.val[0], res.val[1])); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + return v_int8x16(vextq_s8(vcombine_s8(vtbl1_s8(vget_low_s8(vec.val), vcreate_s8(0x0605040201000000)), vtbl1_s8(vget_high_s8(vec.val), vcreate_s8(0x0807060504020100))), vdupq_n_s8(0), 2)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + return v_int16x8(vreinterpretq_s16_s8(vextq_s8(vcombine_s8(vtbl1_s8(vget_low_s8(vreinterpretq_s8_s16(vec.val)), vcreate_s8(0x0504030201000000)), vget_high_s8(vreinterpretq_s8_s16(vec.val))), vdupq_n_s8(0), 2))); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#if CV_SIMD128_64F +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + double CV_DECL_ALIGNED(32) elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_float64x2(vld1q_f64(elems)); +} + +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(vld1q_f64(tab + idx[0])); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + double CV_DECL_ALIGNED(32) elems[2] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + }; + return v_float64x2(vld1q_f64(elems)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float64x2(tab[idx[0]], tab[idx[1]]); + y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); +} +#endif + +////// FP16 support /////// +#if CV_FP16 +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + float16x4_t v = + #ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro + (float16x4_t)vld1_s16((const short*)ptr); + #else + vld1_f16((const __fp16*)ptr); + #endif + return v_float32x4(vcvt_f32_f16(v)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + float16x4_t hv = vcvt_f16_f32(v.val); + + #ifndef vst1_f16 // APPLE compiler defines vst1_f16 as macro + vst1_s16((short*)ptr, (int16x4_t)hv); + #else + vst1_f16((__fp16*)ptr, hv); + #endif +} +#else +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + const int N = 4; + float buf[N]; + for( int i = 0; i < N; i++ ) buf[i] = (float)ptr[i]; + return v_load(buf); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + const int N = 4; + float buf[N]; + v_store(buf, v); + for( int i = 0; i < N; i++ ) ptr[i] = float16_t(buf[i]); +} +#endif + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv.hpp new file mode 100644 index 0000000..fe6c077 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv.hpp @@ -0,0 +1,2887 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// The original implementation has been contributed by Yin Zhang. +// Copyright (C) 2020, Institute of Software, Chinese Academy of Sciences. + +#ifndef OPENCV_HAL_INTRIN_RVV_HPP +#define OPENCV_HAL_INTRIN_RVV_HPP + +#include + +namespace cv +{ + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 + +//////////// Unsupported native intrinsics in C++ //////////// +// The following types have been defined in clang, but not in GCC yet. +#ifndef __clang__ + +struct vuint8mf2_t +{ + uchar val[8] = {0}; + vuint8mf2_t() {} + vuint8mf2_t(const uchar* ptr) + { + for (int i = 0; i < 8; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vint8mf2_t +{ + schar val[8] = {0}; + vint8mf2_t() {} + vint8mf2_t(const schar* ptr) + { + for (int i = 0; i < 8; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vuint16mf2_t +{ + ushort val[4] = {0}; + vuint16mf2_t() {} + vuint16mf2_t(const ushort* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vint16mf2_t +{ + short val[4] = {0}; + vint16mf2_t() {} + vint16mf2_t(const short* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vuint32mf2_t +{ + unsigned val[2] = {0}; + vuint32mf2_t() {} + vuint32mf2_t(const unsigned* ptr) + { + val[0] = ptr[0]; + val[1] = ptr[1]; + } +}; +struct vint32mf2_t +{ + int val[2] = {0}; + vint32mf2_t() {} + vint32mf2_t(const int* ptr) + { + val[0] = ptr[0]; + val[1] = ptr[1]; + } +}; +struct vfloat32mf2_t +{ + float val[2] = {0}; + vfloat32mf2_t() {} + vfloat32mf2_t(const float* ptr) + { + val[0] = ptr[0]; + val[1] = ptr[1]; + } +}; +struct vuint64mf2_t +{ + uint64 val[1] = {0}; + vuint64mf2_t() {} + vuint64mf2_t(const uint64* ptr) + { + val[0] = ptr[0]; + } +}; +struct vint64mf2_t +{ + int64 val[1] = {0}; + vint64mf2_t() {} + vint64mf2_t(const int64* ptr) + { + val[0] = ptr[0]; + } +}; +struct vfloat64mf2_t +{ + double val[1] = {0}; + vfloat64mf2_t() {} + vfloat64mf2_t(const double* ptr) + { + val[0] = ptr[0]; + } +}; +struct vuint8mf4_t +{ + uchar val[4] = {0}; + vuint8mf4_t() {} + vuint8mf4_t(const uchar* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vint8mf4_t +{ + schar val[4] = {0}; + vint8mf4_t() {} + vint8mf4_t(const schar* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; + +#define OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(_Tpvec, _Tp, suffix, width, n) \ +inline _Tpvec vle##width##_v_##suffix##mf2(const _Tp* ptr, size_t vl) \ +{ \ + CV_UNUSED(vl); \ + return _Tpvec(ptr); \ +} \ +inline void vse##width##_v_##suffix##mf2(_Tp* ptr, _Tpvec v, size_t vl) \ +{ \ + CV_UNUSED(vl); \ + for (int i = 0; i < n; ++i) \ + { \ + ptr[i] = v.val[i]; \ + } \ +} + +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint8mf2_t, uint8_t, u8, 8, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint8mf2_t, int8_t, i8, 8, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint16mf2_t, uint16_t, u16, 16, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint16mf2_t, int16_t, i16, 16, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint32mf2_t, uint32_t, u32, 32, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint32mf2_t, int32_t, i32, 32, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vfloat32mf2_t, float32_t, f32, 32, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint64mf2_t, uint64_t, u64, 64, 1) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint64mf2_t, int64_t, i64, 64, 1) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vfloat64mf2_t, float64_t, f64, 64, 1) + + +#define OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(_Tpwvec, _Tpvec, _wTp, wcvt, suffix, width, n) \ +inline _Tpwvec wcvt (_Tpvec v, size_t vl) \ +{ \ + _wTp tmp[n]; \ + for (int i = 0; i < n; ++i) \ + { \ + tmp[i] = (_wTp)v.val[i]; \ + } \ + return vle##width##_v_##suffix##m1(tmp, vl); \ +} + +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vuint16m1_t, vuint8mf2_t, ushort, vwcvtu_x_x_v_u16m1, u16, 16, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vint16m1_t, vint8mf2_t, short, vwcvt_x_x_v_i16m1, i16, 16, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vuint32m1_t, vuint16mf2_t, unsigned, vwcvtu_x_x_v_u32m1, u32, 32, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vint32m1_t, vint16mf2_t, int, vwcvt_x_x_v_i32m1, i32, 32, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vuint64m1_t, vuint32mf2_t, uint64, vwcvtu_x_x_v_u64m1, u64, 64, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vint64m1_t, vint32mf2_t, int64, vwcvt_x_x_v_i64m1, i64, 64, 2) + +inline vuint8mf4_t vle8_v_u8mf4 (const uint8_t *base, size_t vl) +{ + CV_UNUSED(vl); + return vuint8mf4_t(base); +} +inline vint8mf4_t vle8_v_i8mf4 (const int8_t *base, size_t vl) +{ + CV_UNUSED(vl); + return vint8mf4_t(base); +} + +inline vuint16mf2_t vwcvtu_x_x_v_u16mf2 (vuint8mf4_t src, size_t vl) +{ + ushort tmp[4]; + for (int i = 0; i < 4; ++i) + { + tmp[i] = (ushort)src.val[i]; + } + return vle16_v_u16mf2(tmp, vl); +} +inline vint16mf2_t vwcvt_x_x_v_i16mf2 (vint8mf4_t src, size_t vl) +{ + short tmp[4]; + for (int i = 0; i < 4; ++i) + { + tmp[i] = (short)src.val[i]; + } + return vle16_v_i16mf2(tmp, vl); +} +#endif + +//////////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(vuint8m1_t v) + { + vse8_v_u8m1(val, v, nlanes); + } + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint8m1_t() const + { + return vle8_v_u8m1(val, nlanes); + } + uchar get0() const + { + return val[0]; + } + + uchar val[16]; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(vint8m1_t v) + { + vse8_v_i8m1(val, v, nlanes); + } + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint8m1_t() const + { + return vle8_v_i8m1(val, nlanes); + } + schar get0() const + { + return val[0]; + } + + schar val[16]; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(vuint16m1_t v) + { + vse16_v_u16m1(val, v, nlanes); + } + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint16m1_t() const + { + return vle16_v_u16m1(val, nlanes); + } + ushort get0() const + { + return val[0]; + } + + ushort val[8]; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(vint16m1_t v) + { + vse16_v_i16m1(val, v, nlanes); + } + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint16m1_t() const + { + return vle16_v_i16m1(val, nlanes); + } + short get0() const + { + return val[0]; + } + + short val[8]; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(vuint32m1_t v) + { + vse32_v_u32m1(val, v, nlanes); + } + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint32m1_t() const + { + return vle32_v_u32m1(val, nlanes); + } + unsigned get0() const + { + return val[0]; + } + + unsigned val[4]; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(vint32m1_t v) + { + vse32_v_i32m1(val, v, nlanes); + } + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint32m1_t() const + { + return vle32_v_i32m1(val, nlanes); + } + int get0() const + { + return val[0]; + } + int val[4]; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(vfloat32m1_t v) + { + vse32_v_f32m1(val, v, nlanes); + } + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vfloat32m1_t() const + { + return vle32_v_f32m1(val, nlanes); + } + float get0() const + { + return val[0]; + } + float val[4]; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(vuint64m1_t v) + { + vse64_v_u64m1(val, v, nlanes); + } + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint64m1_t() const + { + return vle64_v_u64m1(val, nlanes); + } + uint64 get0() const + { + return val[0]; + } + + uint64 val[2]; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(vint64m1_t v) + { + vse64_v_i64m1(val, v, nlanes); + } + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint64m1_t() const + { + return vle64_v_i64m1(val, nlanes); + } + int64 get0() const + { + return val[0]; + } + + int64 val[2]; +}; + +#if CV_SIMD128_64F +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(vfloat64m1_t v) + { + vse64_v_f64m1(val, v, nlanes); + } + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vfloat64m1_t() const + { + return vle64_v_f64m1(val, nlanes); + } + double get0() const + { + return val[0]; + } + + double val[2]; +}; +#endif + + +//////////// Initial //////////// + +#define OPENCV_HAL_IMPL_RVV_INIT_INTEGER(_Tpvec, _Tp, suffix1, suffix2, vl) \ +inline v_##_Tpvec v_setzero_##suffix1() \ +{ \ + return v_##_Tpvec(vmv_v_x_##suffix2##m1(0, vl)); \ +} \ +inline v_##_Tpvec v_setall_##suffix1(_Tp v) \ +{ \ + return v_##_Tpvec(vmv_v_x_##suffix2##m1(v, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint8x16, uchar, u8, u8, 16) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int8x16, schar, s8, i8, 16) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint16x8, ushort, u16, u16, 8) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int16x8, short, s16, i16, 8) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint32x4, unsigned, u32, u32, 4) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int32x4, int, s32, i32, 4) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint64x2, uint64, u64, u64, 2) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int64x2, int64, s64, i64, 2) + +#define OPENCV_HAL_IMPL_RVV_INIT_FP(_Tpv, _Tp, suffix, vl) \ +inline v_##_Tpv v_setzero_##suffix() \ +{ \ + return v_##_Tpv(vfmv_v_f_##suffix##m1(0, vl)); \ +} \ +inline v_##_Tpv v_setall_##suffix(_Tp v) \ +{ \ + return v_##_Tpv(vfmv_v_f_##suffix##m1(v, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_INIT_FP(float32x4, float, f32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_INIT_FP(float64x2, double, f64, 2) +#endif + +//////////// Reinterpret //////////// + +#define OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(_Tpvec, suffix) \ +inline v_##_Tpvec v_reinterpret_as_##suffix(const v_##_Tpvec& v) { return v; } + +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint8x16, u8) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int8x16, s8) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint16x8, u16) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int16x8, s16) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint32x4, u32) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int32x4, s32) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(float32x4, f32) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint64x2, u64) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int64x2, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(float64x2, f64) +#endif + +#define OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(_Tpvec1, _Tpvec2, suffix1, suffix2, nsuffix1, nsuffix2) \ +inline v_##_Tpvec1 v_reinterpret_as_##suffix1(const v_##_Tpvec2& v) \ +{ \ + return v_##_Tpvec1(vreinterpret_v_##nsuffix2##m1_##nsuffix1##m1(v));\ +} \ +inline v_##_Tpvec2 v_reinterpret_as_##suffix2(const v_##_Tpvec1& v) \ +{ \ + return v_##_Tpvec2(vreinterpret_v_##nsuffix1##m1_##nsuffix2##m1(v));\ +} + +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, int8x16, u8, s8, u8, i8) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint16x8, int16x8, u16, s16, u16, i16) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint32x4, int32x4, u32, s32, u32, i32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint32x4, float32x4, u32, f32, u32, f32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int32x4, float32x4, s32, f32, i32, f32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint64x2, int64x2, u64, s64, u64, i64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint64x2, float64x2, u64, f64, u64, f64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int64x2, float64x2, s64, f64, i64, f64) +#endif +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, uint16x8, u8, u16, u8, u16) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, uint32x4, u8, u32, u8, u32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, uint64x2, u8, u64, u8, u64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint16x8, uint32x4, u16, u32, u16, u32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint16x8, uint64x2, u16, u64, u16, u64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint32x4, uint64x2, u32, u64, u32, u64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int8x16, int16x8, s8, s16, i8, i16) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int8x16, int32x4, s8, s32, i8, i32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int8x16, int64x2, s8, s64, i8, i64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int16x8, int32x4, s16, s32, i16, i32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int16x8, int64x2, s16, s64, i16, i64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int32x4, int64x2, s32, s64, i32, i64) + + +#define OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(_Tpvec1, _Tpvec2, suffix1, suffix2, nsuffix1, nsuffix2, width1, width2) \ +inline v_##_Tpvec1 v_reinterpret_as_##suffix1(const v_##_Tpvec2& v) \ +{ \ + return v_##_Tpvec1(vreinterpret_v_##nsuffix1##width2##m1_##nsuffix1##width1##m1(vreinterpret_v_##nsuffix2##width2##m1_##nsuffix1##width2##m1(v)));\ +} \ +inline v_##_Tpvec2 v_reinterpret_as_##suffix2(const v_##_Tpvec1& v) \ +{ \ + return v_##_Tpvec2(vreinterpret_v_##nsuffix1##width2##m1_##nsuffix2##width2##m1(vreinterpret_v_##nsuffix1##width1##m1_##nsuffix1##width2##m1(v)));\ +} + +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, int16x8, u8, s16, u, i, 8, 16) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, int32x4, u8, s32, u, i, 8, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, int64x2, u8, s64, u, i, 8, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, int8x16, u16, s8, u, i, 16, 8) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, int32x4, u16, s32, u, i, 16, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, int64x2, u16, s64, u, i, 16, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, int8x16, u32, s8, u, i, 32, 8) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, int16x8, u32, s16, u, i, 32, 16) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, int64x2, u32, s64, u, i, 32, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, int8x16, u64, s8, u, i, 64, 8) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, int16x8, u64, s16, u, i, 64, 16) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, int32x4, u64, s32, u, i, 64, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, float32x4, u8, f32, u, f, 8, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, float32x4, u16, f32, u, f, 16, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, float32x4, u64, f32, u, f, 64, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int8x16, float32x4, s8, f32, i, f, 8, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int16x8, float32x4, s16, f32, i, f, 16, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int64x2, float32x4, s64, f32, i, f, 64, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, float64x2, u8, f64, u, f, 8, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, float64x2, u16, f64, u, f, 16, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, float64x2, u32, f64, u, f, 32, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int8x16, float64x2, s8, f64, i, f, 8, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int16x8, float64x2, s16, f64, i, f, 16, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int32x4, float64x2, s32, f64, i, f, 32, 64) + +// Three times reinterpret +inline v_float32x4 v_reinterpret_as_f32(const v_float64x2& v) \ +{ \ + return v_float32x4(vreinterpret_v_u32m1_f32m1(vreinterpret_v_u64m1_u32m1(vreinterpret_v_f64m1_u64m1(v))));\ +} \ +inline v_float64x2 v_reinterpret_as_f64(const v_float32x4& v) \ +{ \ + return v_float64x2(vreinterpret_v_u64m1_f64m1(vreinterpret_v_u32m1_u64m1(vreinterpret_v_f32m1_u32m1(v))));\ +} + +////////////// Extract ////////////// + +#define OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(_Tpvec, _Tp, suffix, vmv, vl) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, s, vl), b, _Tpvec::nlanes - s, vl)); \ +} \ +template inline _Tp v_extract_n(_Tpvec v) \ +{ \ + return _Tp(vmv(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), v, i, vl))); \ +} + + +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint8x16, uchar, u8, vmv_x_s_u8m1_u8, 16) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int8x16, schar, i8, vmv_x_s_i8m1_i8, 16) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint16x8, ushort, u16, vmv_x_s_u16m1_u16, 8) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int16x8, short, i16, vmv_x_s_i16m1_i16, 8) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint32x4, uint, u32, vmv_x_s_u32m1_u32, 4) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int32x4, int, i32, vmv_x_s_i32m1_i32, 4) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint64x2, uint64, u64, vmv_x_s_u64m1_u64, 2) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int64x2, int64, i64, vmv_x_s_i64m1_i64, 2) + +#define OPENCV_HAL_IMPL_RVV_EXTRACT_FP(_Tpvec, _Tp, suffix, vmv, vl) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, s, vl), b, _Tpvec::nlanes - s, vl)); \ +} \ +template inline _Tp v_extract_n(_Tpvec v) \ +{ \ + return _Tp(vmv(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), v, i, vl))); \ +} + +OPENCV_HAL_IMPL_RVV_EXTRACT_FP(v_float32x4, float, f32, vfmv_f_s_f32m1_f32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_EXTRACT_FP(v_float64x2, double, f64, vfmv_f_s_f64m1_f64, 2) +#endif + +////////////// Load/Store ////////////// + +#define OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(_Tpvec, _nTpvec, _Tp, hvl, vl, width, suffix, vmv) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ \ + return _Tpvec(vle##width##_v_##suffix##m1(ptr, vl)); \ +} \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ \ + return _Tpvec(vle##width##_v_##suffix##m1(ptr, vl)); \ +} \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ \ + _Tpvec res = _Tpvec(vle##width##_v_##suffix##m1(ptr, hvl)); \ + return res; \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, hvl); \ +} \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, vslidedown_vx_##suffix##m1(vmv(0, vl), a, hvl, vl), hvl); \ +} + +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint8x16, vuint8m1_t, uchar, 8, 16, 8, u8, vmv_v_x_u8m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int8x16, vint8m1_t, schar, 8, 16, 8, i8, vmv_v_x_i8m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint16x8, vuint16m1_t, ushort, 4, 8, 16, u16, vmv_v_x_u16m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int16x8, vint16m1_t, short, 4, 8, 16, i16, vmv_v_x_i16m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint32x4, vuint32m1_t, unsigned, 2, 4, 32, u32, vmv_v_x_u32m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int32x4, vint32m1_t, int, 2, 4, 32, i32, vmv_v_x_i32m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint64x2, vuint64m1_t, uint64, 1, 2, 64, u64, vmv_v_x_u64m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int64x2, vint64m1_t, int64, 1, 2, 64, i64, vmv_v_x_i64m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float32x4, vfloat32m1_t, float, 2, 4, 32, f32, vfmv_v_f_f32m1) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float64x2, vfloat64m1_t, double, 1, 2, 64, f64, vfmv_v_f_f64m1) +#endif + +inline v_int8x16 v_load_halves(const schar* ptr0, const schar* ptr1) +{ + schar elems[16] = + { + ptr0[0], ptr0[1], ptr0[2], ptr0[3], ptr0[4], ptr0[5], ptr0[6], ptr0[7], + ptr1[0], ptr1[1], ptr1[2], ptr1[3], ptr1[4], ptr1[5], ptr1[6], ptr1[7] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_uint8x16 v_load_halves(const uchar* ptr0, const uchar* ptr1) { return v_reinterpret_as_u8(v_load_halves((schar*)ptr0, (schar*)ptr1)); } + +inline v_int16x8 v_load_halves(const short* ptr0, const short* ptr1) +{ + short elems[8] = + { + ptr0[0], ptr0[1], ptr0[2], ptr0[3], ptr1[0], ptr1[1], ptr1[2], ptr1[3] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_uint16x8 v_load_halves(const ushort* ptr0, const ushort* ptr1) { return v_reinterpret_as_u16(v_load_halves((short*)ptr0, (short*)ptr1)); } + +inline v_int32x4 v_load_halves(const int* ptr0, const int* ptr1) +{ + int elems[4] = + { + ptr0[0], ptr0[1], ptr1[0], ptr1[1] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} +inline v_float32x4 v_load_halves(const float* ptr0, const float* ptr1) +{ + float elems[4] = + { + ptr0[0], ptr0[1], ptr1[0], ptr1[1] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} +inline v_uint32x4 v_load_halves(const unsigned* ptr0, const unsigned* ptr1) { return v_reinterpret_as_u32(v_load_halves((int*)ptr0, (int*)ptr1)); } + +inline v_int64x2 v_load_halves(const int64* ptr0, const int64* ptr1) +{ + int64 elems[2] = + { + ptr0[0], ptr1[0] + }; + return v_int64x2(vle64_v_i64m1(elems, 2)); +} +inline v_uint64x2 v_load_halves(const uint64* ptr0, const uint64* ptr1) { return v_reinterpret_as_u64(v_load_halves((int64*)ptr0, (int64*)ptr1)); } + +#if CV_SIMD128_64F +inline v_float64x2 v_load_halves(const double* ptr0, const double* ptr1) +{ + double elems[2] = + { + ptr0[0], ptr1[0] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} +#endif + + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + schar elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + schar elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + short elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + int elems[4] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vle32_v_i32m1(tab + idx[0], 4)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + int64_t elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_int64x2(vle64_v_i64m1(elems, 2)); +} +inline v_int64x2 v_lut_pairs(const int64* tab, const int* idx) +{ + return v_int64x2(vle64_v_i64m1(tab + idx[0], 2)); +} +inline v_uint64x2 v_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + float elems[4] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(vle32_v_f32m1(tab + idx[0], 4)); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int elems[4] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)], + tab[v_extract_n<2>(idxvec)], + tab[v_extract_n<3>(idxvec)] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned elems[4] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)], + tab[v_extract_n<2>(idxvec)], + tab[v_extract_n<3>(idxvec)] + }; + return v_uint32x4(vle32_v_u32m1(elems, 4)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + float elems[4] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)], + tab[v_extract_n<2>(idxvec)], + tab[v_extract_n<3>(idxvec)] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + int idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); + y = v_float32x4(tab[idx[0]+1], tab[idx[1]+1], tab[idx[2]+1], tab[idx[3]+1]); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + double elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(vle64_v_f64m1(tab + idx[0], 2)); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + double elems[2] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int idx[4] = {0}; + v_store_aligned(idx, idxvec); + + x = v_float64x2(tab[idx[0]], tab[idx[1]]); + y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); +} +#endif + +////////////// Pack boolean //////////////////// + +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + ushort ptr[16] = {0}; + v_store(ptr, a); + v_store(ptr + 8, b); + return v_uint8x16(vnsrl_wx_u8m1(vle16_v_u16m2(ptr, 16), 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + unsigned ptr[16] = {0}; + v_store(ptr, a); + v_store(ptr + 4, b); + v_store(ptr + 8, c); + v_store(ptr + 12, d); + return v_uint8x16(vnsrl_wx_u8m1(vnsrl_wx_u16m2(vle32_v_u32m4(ptr, 16), 0, 16), 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + uint64 ptr[16] = {0}; + v_store(ptr, a); + v_store(ptr + 2, b); + v_store(ptr + 4, c); + v_store(ptr + 6, d); + v_store(ptr + 8, e); + v_store(ptr + 10, f); + v_store(ptr + 12, g); + v_store(ptr + 14, h); + return v_uint8x16(vnsrl_wx_u8m1(vnsrl_wx_u16m2(vnsrl_wx_u32m4(vle64_v_u64m8(ptr, 16), 0, 16), 0, 16), 0, 16)); +} + +////////////// Arithmetics ////////////// +#define OPENCV_HAL_IMPL_RVV_BIN_OP(bin_op, _Tpvec, intrin, vl) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a, b, vl)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a = _Tpvec(intrin(a, b, vl)); \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint8x16, vsaddu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint8x16, vssubu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint8x16, vdivu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int8x16, vsadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int8x16, vssub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int8x16, vdiv_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint16x8, vsaddu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint16x8, vssubu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint16x8, vdivu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int16x8, vsadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int16x8, vssub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int16x8, vdiv_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint32x4, vadd_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint32x4, vsub_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_uint32x4, vmul_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint32x4, vdivu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int32x4, vadd_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int32x4, vsub_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_int32x4, vmul_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int32x4, vdiv_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_float32x4, vfadd_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_float32x4, vfsub_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_float32x4, vfmul_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_float32x4, vfdiv_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint64x2, vadd_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint64x2, vsub_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_uint64x2, vmul_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint64x2, vdivu_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int64x2, vadd_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int64x2, vsub_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_int64x2, vmul_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int64x2, vdiv_vv_i64m1, 2) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_float64x2, vfadd_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_float64x2, vfsub_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_float64x2, vfmul_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_float64x2, vfdiv_vv_f64m1, 2) +#endif + + +////////////// Bitwise logic ////////////// + +#define OPENCV_HAL_IMPL_RVV_LOGIC_OP(_Tpvec, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_BIN_OP(&, _Tpvec, vand_vv_##suffix##m1, vl) \ +OPENCV_HAL_IMPL_RVV_BIN_OP(|, _Tpvec, vor_vv_##suffix##m1, vl) \ +OPENCV_HAL_IMPL_RVV_BIN_OP(^, _Tpvec, vxor_vv_##suffix##m1, vl) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ \ + return _Tpvec(vnot_v_##suffix##m1(a, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int64x2, i64, 2) + +#define OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(vreinterpret_v_i32m1_f32m1(intrin(vreinterpret_v_f32m1_i32m1(a), vreinterpret_v_f32m1_i32m1(b), 4))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a = v_float32x4(vreinterpret_v_i32m1_f32m1(intrin(vreinterpret_v_f32m1_i32m1(a), vreinterpret_v_f32m1_i32m1(b), 4))); \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(&, vand_vv_i32m1) +OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(|, vor_vv_i32m1) +OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(^, vxor_vv_i32m1) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4(vreinterpret_v_i32m1_f32m1(vnot_v_i32m1(vreinterpret_v_f32m1_i32m1(a), 4))); +} + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(vreinterpret_v_i64m1_f64m1(intrin(vreinterpret_v_f64m1_i64m1(a), vreinterpret_v_f64m1_i64m1(b), 2))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a = v_float64x2(vreinterpret_v_i64m1_f64m1(intrin(vreinterpret_v_f64m1_i64m1(a), vreinterpret_v_f64m1_i64m1(b), 2))); \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(&, vand_vv_i64m1) +OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(|, vor_vv_i64m1) +OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(^, vxor_vv_i64m1) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2(vreinterpret_v_i64m1_f64m1(vnot_v_i64m1(vreinterpret_v_f64m1_i64m1(a), 2))); +} +#endif + +////////////// Bitwise shifts ////////////// + +#define OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(_Tpvec, suffix, vl) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsrl_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ \ + return _Tpvec(vsrl_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} + +#define OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(_Tpvec, suffix, vl) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsra_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ \ + return _Tpvec(vsra_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} + +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int64x2, i64, 2) + + +////////////// Comparison ////////////// + +#define OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, op, intrin, suffix, vl) \ +inline _Tpvec operator op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + uint64_t ones = -1; \ + return _Tpvec(vmerge_vxm_##suffix##m1(intrin(a, b, vl), vmv_v_x_##suffix##m1(0, vl), ones, vl)); \ +} + +#define OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, op, intrin, suffix, vl) \ +inline _Tpvec operator op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + union { uint64 u; double d; } ones; ones.u = -1; \ + return _Tpvec(vfmerge_vfm_##suffix##m1(intrin(a, b, vl), vfmv_v_f_##suffix##m1(0, vl), ones.d, vl)); \ +} + +#define OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(_Tpvec, suffix, width, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, ==, vmseq_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, !=, vmsne_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <, vmsltu_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >, vmsgtu_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <=, vmsleu_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >=, vmsgeu_vv_##suffix##m1_b##width, suffix, vl) + +#define OPENCV_HAL_IMPL_RVV_SIGNED_CMP(_Tpvec, suffix, width, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, ==, vmseq_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, !=, vmsne_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <, vmslt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >, vmsgt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <=, vmsle_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >=, vmsge_vv_##suffix##m1_b##width, suffix, vl) + +#define OPENCV_HAL_IMPL_RVV_FLOAT_CMP(_Tpvec, suffix, width, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, ==, vmfeq_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, !=, vmfne_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, <, vmflt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, >, vmfgt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, <=, vmfle_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, >=, vmfge_vv_##suffix##m1_b##width, suffix, vl) + + +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint8x16, u8, 8, 16) +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint16x8, u16, 16, 8) +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint32x4, u32, 32, 4) +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint64x2, u64, 64, 2) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int8x16, i8, 8, 16) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int16x8, i16, 16, 8) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int32x4, i32, 32, 4) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int64x2, i64, 64, 2) +OPENCV_HAL_IMPL_RVV_FLOAT_CMP(v_float32x4, f32, 32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_FLOAT_CMP(v_float64x2, f64, 64, 2) +#endif + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return a == a; } + +#if CV_SIMD128_64F +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return a == a; } +#endif + +////////////// Min/Max ////////////// + +#define OPENCV_HAL_IMPL_RVV_BIN_FUNC(_Tpvec, func, intrin, vl) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a, b, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_min, vminu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_max, vmaxu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_min, vmin_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_max, vmax_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_min, vminu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_max, vmaxu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_min, vmin_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_max, vmax_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint32x4, v_min, vminu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint32x4, v_max, vmaxu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int32x4, v_min, vmin_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int32x4, v_max, vmax_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float32x4, v_min, vfmin_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float32x4, v_max, vfmax_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint64x2, v_min, vminu_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint64x2, v_max, vmaxu_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int64x2, v_min, vmin_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int64x2, v_max, vmax_vv_i64m1, 2) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float64x2, v_min, vfmin_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float64x2, v_max, vfmax_vv_f64m1, 2) +#endif + +////////////// Arithmetics wrap ////////////// + +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_add_wrap, vadd_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_add_wrap, vadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_add_wrap, vadd_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_add_wrap, vadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_sub_wrap, vsub_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_sub_wrap, vsub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_sub_wrap, vsub_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_sub_wrap, vsub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_mul_wrap, vmul_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_mul_wrap, vmul_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_mul_wrap, vmul_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_mul_wrap, vmul_vv_i16m1, 8) + +////////////// Reduce ////////////// + +#define OPENCV_HAL_IMPL_RVV_REDUCE_SUM(_Tpvec, _wTpvec, _nwTpvec, scalartype, suffix, wsuffix, vl, red) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + _nwTpvec zero = vmv_v_x_##wsuffix##m1(0, vl); \ + _nwTpvec res = vmv_v_x_##wsuffix##m1(0, vl); \ + res = v##red##_vs_##suffix##m1_##wsuffix##m1(res, a, zero, vl); \ + return (scalartype)(_wTpvec(res).get0()); \ +} + +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint8x16, v_uint16x8, vuint16m1_t, unsigned, u8, u16, 16, wredsumu) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int8x16, v_int16x8, vint16m1_t, int, i8, i16, 16, wredsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint16x8, v_uint32x4, vuint32m1_t, unsigned, u16, u32, 8, wredsumu) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int16x8, v_int32x4, vint32m1_t, int, i16, i32, 8, wredsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint32x4, v_uint64x2, vuint64m1_t, unsigned, u32, u64, 4, wredsumu) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int32x4, v_int64x2, vint64m1_t, int, i32, i64, 4, wredsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint64x2, v_uint64x2, vuint64m1_t, uint64, u64, u64, 2, redsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int64x2, v_int64x2, vint64m1_t, int64, i64, i64, 2, redsum) + +#define OPENCV_HAL_IMPL_RVV_REDUCE_SUM_FP(_Tpvec, _wTpvec, _nwTpvec, scalartype, suffix, wsuffix, vl, red) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + _nwTpvec zero = vfmv_v_f_##wsuffix##m1(0, vl); \ + _nwTpvec res = vfmv_v_f_##wsuffix##m1(0, vl); \ + res = v##red##_vs_##suffix##m1_##wsuffix##m1(res, a, zero, vl); \ + return (scalartype)(_wTpvec(res).get0()); \ +} + +// vfredsum for float has renamed to fredosum, also updated in GNU. +OPENCV_HAL_IMPL_RVV_REDUCE_SUM_FP(v_float32x4, v_float32x4, vfloat32m1_t, float, f32, f32, 4, fredosum) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_REDUCE_SUM_FP(v_float64x2, v_float64x2, vfloat64m1_t, double, f64, f64, 2, fredosum) +#endif + + +#define OPENCV_HAL_IMPL_RVV_REDUCE(_Tpvec, func, scalartype, suffix, vl, red) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpvec res = _Tpvec(v##red##_vs_##suffix##m1_##suffix##m1(a, a, a, vl)); \ + return scalartype(res.get0()); \ +} + +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint8x16, min, uchar, u8, 16, redminu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int8x16, min, schar, i8, 16, redmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint16x8, min, ushort, u16, 8, redminu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int16x8, min, short, i16, 8, redmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint32x4, min, unsigned, u32, 4, redminu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int32x4, min, int, i32, 4, redmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_float32x4, min, float, f32, 4, fredmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint8x16, max, uchar, u8, 16, redmaxu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int8x16, max, schar, i8, 16, redmax) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint16x8, max, ushort, u16, 8, redmaxu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int16x8, max, short, i16, 8, redmax) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint32x4, max, unsigned, u32, 4, redmaxu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int32x4, max, int, i32, 4, redmax) +OPENCV_HAL_IMPL_RVV_REDUCE(v_float32x4, max, float, f32, 4, fredmax) + + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + float elems[4] = + { + v_reduce_sum(a), + v_reduce_sum(b), + v_reduce_sum(c), + v_reduce_sum(d) + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} + +////////////// Square-Root ////////////// + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(vfsqrt_v_f32m1(x, 4)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + v_float32x4 one = v_setall_f32(1.0f); + return one / v_sqrt(x); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(vfsqrt_v_f64m1(x, 4)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + v_float64x2 one = v_setall_f64(1.0f); + return one / v_sqrt(x); +} +#endif + +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(vfmacc_vv_f32m1(vfmul_vv_f32m1(a, a, 4), b, b, 4)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vfmacc_vv_f32m1(vfmul_vv_f32m1(a, a, 4), b, b, 4)); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(vfmacc_vv_f64m1(vfmul_vv_f64m1(a, a, 2), b, b, 2)); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vfmacc_vv_f64m1(vfmul_vv_f64m1(a, a, 2), b, b, 2)); +} +#endif + +////////////// Multiply-Add ////////////// + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_float32x4(vfmacc_vv_f32m1(c, a, b, 4)); +} +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(vmacc_vv_i32m1(c, a, b, 4)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(vfmacc_vv_f64m1(c, a, b, 2)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} +#endif + +////////////// Check all/any ////////////// + +// use overloaded vcpop in clang, no casting like (vuint64m1_t) is needed. +#ifndef __clang__ +#define OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(_Tpvec, suffix, shift, vl) \ +inline bool v_check_all(const _Tpvec& a) \ +{ \ + v_uint64x2 v = v_uint64x2((vuint64m1_t)vsrl_vx_##suffix##m1(vnot_v_##suffix##m1(a, vl), shift, vl)); \ + return (v.val[0] | v.val[1]) == 0; \ +} \ +inline bool v_check_any(const _Tpvec& a) \ +{ \ + v_uint64x2 v = v_uint64x2((vuint64m1_t)vsrl_vx_##suffix##m1(a, shift, vl)); \ + return (v.val[0] | v.val[1]) != 0; \ +} + +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint8x16, u8, 7, 16) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint16x8, u16, 15, 8) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint32x4, u32, 31, 4) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint64x2, u64, 63, 2) + + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } + +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } + +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } + +#if CV_SIMD128_64F +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +#endif +#else +#define OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(_Tpvec, vl) \ +inline bool v_check_all(const _Tpvec& a) \ +{ \ + return vcpop(vmslt(a, 0, vl), vl) == vl; \ +} \ +inline bool v_check_any(const _Tpvec& a) \ +{ \ + return vcpop(vmslt(a, 0, vl), vl) != 0; \ +} + +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int8x16, 16) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int16x8, 8) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int32x4, 4) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int64x2, 2) + + +inline bool v_check_all(const v_uint8x16& a) +{ return v_check_all(v_reinterpret_as_s8(a)); } +inline bool v_check_any(const v_uint8x16& a) +{ return v_check_any(v_reinterpret_as_s8(a)); } + +inline bool v_check_all(const v_uint16x8& a) +{ return v_check_all(v_reinterpret_as_s16(a)); } +inline bool v_check_any(const v_uint16x8& a) +{ return v_check_any(v_reinterpret_as_s16(a)); } + +inline bool v_check_all(const v_uint32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_uint32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } + +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } + +inline bool v_check_all(const v_uint64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_uint64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } + +#if CV_SIMD128_64F +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } +#endif +#endif +////////////// abs ////////////// + +#define OPENCV_HAL_IMPL_RVV_ABSDIFF(_Tpvec, abs) \ +inline _Tpvec v_##abs(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return v_max(a, b) - v_min(a, b); \ +} + +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_uint8x16, absdiff) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_uint16x8, absdiff) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_uint32x4, absdiff) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_float32x4, absdiff) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_float64x2, absdiff) +#endif +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_int8x16, absdiffs) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_int16x8, absdiffs) + +// use reinterpret instead of c-style casting. +#ifndef __clang__ +#define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, vl) \ +inline _rTpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _rTpvec(rshr((_nwTpvec)sub(v_max(a, b), v_min(a, b), vl), 0, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int8x16, v_uint8x16, vuint16m2_t, vwsub_vv_i16m2, vnclipu_wx_u8m1, 16) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int16x8, v_uint16x8, vuint32m2_t, vwsub_vv_i32m2, vnclipu_wx_u16m1, 8) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int32x4, v_uint32x4, vuint64m2_t, vwsub_vv_i64m2, vnclipu_wx_u32m1, 4) +#else +#define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, width, vl) \ +inline _rTpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _rTpvec(rshr(vreinterpret_u##width##m2(sub(v_max(a, b), v_min(a, b), vl)), 0, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int8x16, v_uint8x16, vuint16m2_t, vwsub_vv_i16m2, vnclipu_wx_u8m1, 16, 16) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int16x8, v_uint16x8, vuint32m2_t, vwsub_vv_i32m2, vnclipu_wx_u16m1, 32, 8) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int32x4, v_uint32x4, vuint64m2_t, vwsub_vv_i64m2, vnclipu_wx_u32m1, 64, 4) +#endif +#define OPENCV_HAL_IMPL_RVV_ABS(_Tprvec, _Tpvec, suffix) \ +inline _Tprvec v_abs(const _Tpvec& a) \ +{ \ + return v_absdiff(a, v_setzero_##suffix()); \ +} + +OPENCV_HAL_IMPL_RVV_ABS(v_uint8x16, v_int8x16, s8) +OPENCV_HAL_IMPL_RVV_ABS(v_uint16x8, v_int16x8, s16) +OPENCV_HAL_IMPL_RVV_ABS(v_uint32x4, v_int32x4, s32) +OPENCV_HAL_IMPL_RVV_ABS(v_float32x4, v_float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_ABS(v_float64x2, v_float64x2, f64) +#endif + + +#define OPENCV_HAL_IMPL_RVV_REDUCE_SAD(_Tpvec, scalartype) \ +inline scalartype v_reduce_sad(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return v_reduce_sum(v_absdiff(a, b)); \ +} + +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_uint8x16, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_int8x16, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_uint16x8, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_int16x8, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_uint32x4, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_int32x4, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_float32x4, float) + +////////////// Select ////////////// + +#define OPENCV_HAL_IMPL_RVV_SELECT(_Tpvec, merge, ne, vl) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(merge(ne(mask, 0, vl), b, a, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_SELECT(v_uint8x16, vmerge_vvm_u8m1, vmsne_vx_u8m1_b8, 16) +OPENCV_HAL_IMPL_RVV_SELECT(v_int8x16, vmerge_vvm_i8m1, vmsne_vx_i8m1_b8, 16) +OPENCV_HAL_IMPL_RVV_SELECT(v_uint16x8, vmerge_vvm_u16m1, vmsne_vx_u16m1_b16, 8) +OPENCV_HAL_IMPL_RVV_SELECT(v_int16x8, vmerge_vvm_i16m1, vmsne_vx_i16m1_b16, 8) +OPENCV_HAL_IMPL_RVV_SELECT(v_uint32x4, vmerge_vvm_u32m1, vmsne_vx_u32m1_b32, 4) +OPENCV_HAL_IMPL_RVV_SELECT(v_int32x4, vmerge_vvm_i32m1, vmsne_vx_i32m1_b32, 4) +OPENCV_HAL_IMPL_RVV_SELECT(v_float32x4, vmerge_vvm_f32m1, vmfne_vf_f32m1_b32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_SELECT(v_float64x2, vmerge_vvm_f64m1, vmfne_vf_f64m1_b64, 2) +#endif + +////////////// Rotate shift ////////////// + +#define OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(_Tpvec, suffix, vl) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, n, vl), b, _Tpvec::nlanes - n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), b, _Tpvec::nlanes - n, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ CV_UNUSED(b); return a; } + +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int64x2, i64, 2) + +#define OPENCV_HAL_IMPL_RVV_ROTATE_FP(_Tpvec, suffix, vl) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, n, vl), b, _Tpvec::nlanes - n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), b, _Tpvec::nlanes - n, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ CV_UNUSED(b); return a; } + +OPENCV_HAL_IMPL_RVV_ROTATE_FP(v_float32x4, f32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_ROTATE_FP(v_float64x2, f64, 2) +#endif + +////////////// Convert to float ////////////// + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(vfcvt_f_x_v_f32m1(a, 4)); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + double arr[4] = {a.val[0], a.val[1], 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_float32x4(vfncvt_f_f_w_f32m1(tmp, 4)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + double arr[4] = {a.val[0], a.val[1], b.val[0], b.val[1]}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_float32x4(vfncvt_f_f_w_f32m1(tmp, 4)); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_x_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[0], ptr[1] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_x_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[2], ptr[3] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_f_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[0], ptr[1] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_f_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[2], ptr[3] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ + return v_float64x2(vfcvt_f_x_v_f64m1(a, 2)); +} +#endif + +////////////// Broadcast ////////////// + +#define OPENCV_HAL_IMPL_RVV_BROADCAST(_Tpvec, suffix) \ +template inline _Tpvec v_broadcast_element(_Tpvec v) \ +{ \ + return v_setall_##suffix(v_extract_n(v)); \ +} + +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint8x16, u8) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int8x16, s8) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint16x8, u16) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int16x8, s16) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint32x4, u32) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int32x4, s32) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint64x2, u64) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int64x2, s64) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_BROADCAST(v_float64x2, f64) +#endif + +////////////// Transpose4x4 ////////////// + +#define OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(_Tpvec, _Tp, suffix) \ +inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ + const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ + v_##_Tpvec& b0, v_##_Tpvec& b1, \ + v_##_Tpvec& b2, v_##_Tpvec& b3) \ +{ \ + _Tp elems0[4] = \ + { \ + v_extract_n<0>(a0), \ + v_extract_n<0>(a1), \ + v_extract_n<0>(a2), \ + v_extract_n<0>(a3) \ + }; \ + b0 = v_load(elems0); \ + _Tp elems1[4] = \ + { \ + v_extract_n<1>(a0), \ + v_extract_n<1>(a1), \ + v_extract_n<1>(a2), \ + v_extract_n<1>(a3) \ + }; \ + b1 = v_load(elems1); \ + _Tp elems2[4] = \ + { \ + v_extract_n<2>(a0), \ + v_extract_n<2>(a1), \ + v_extract_n<2>(a2), \ + v_extract_n<2>(a3) \ + }; \ + b2 = v_load(elems2); \ + _Tp elems3[4] = \ + { \ + v_extract_n<3>(a0), \ + v_extract_n<3>(a1), \ + v_extract_n<3>(a2), \ + v_extract_n<3>(a3) \ + }; \ + b3 = v_load(elems3); \ +} + +OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(int32x4, int, i32) +OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(float32x4, float, f32) + +////////////// Reverse ////////////// + +#define OPENCV_HAL_IMPL_RVV_REVERSE(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_reverse(const _Tpvec& a) \ +{ \ + _Tp ptr[_Tpvec::nlanes] = {0}; \ + _Tp ptra[_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + for (int i = 0; i < _Tpvec::nlanes; i++) \ + { \ + ptr[i] = ptra[_Tpvec::nlanes-i-1]; \ + } \ + return v_load(ptr); \ +} + +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int8x16, schar, i8) +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int16x8, short, i16) +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int32x4, int, i32) +OPENCV_HAL_IMPL_RVV_REVERSE(v_float32x4, float, f32) +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int64x2, int64, i64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_REVERSE(v_float64x2, double, f64) +#endif + +//////////// Value reordering //////////// + +#define OPENCV_HAL_IMPL_RVV_EXPAND(_Tpwvec, _Tp, _Tpvec, width, suffix, wcvt, vl) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + _Tp lptr[_Tpvec::nlanes/2] = {0}; \ + _Tp hptr[_Tpvec::nlanes/2] = {0}; \ + v_store_low(lptr, a); \ + v_store_high(hptr, a); \ + b0 = _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(lptr, vl), vl)); \ + b1 = _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(hptr, vl), vl)); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + _Tp lptr[_Tpvec::nlanes/2] = {0}; \ + v_store_low(lptr, a); \ + return _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(lptr, vl), vl)); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + _Tp hptr[_Tpvec::nlanes/2] = {0}; \ + v_store_high(hptr, a); \ + return _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(hptr, vl), vl)); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(ptr, vl), vl)); \ +} + +OPENCV_HAL_IMPL_RVV_EXPAND(v_uint16x8, uchar, v_uint8x16, 8, u8, vwcvtu_x_x_v_u16m1, 8) +OPENCV_HAL_IMPL_RVV_EXPAND(v_int16x8, schar, v_int8x16, 8, i8, vwcvt_x_x_v_i16m1, 8) +OPENCV_HAL_IMPL_RVV_EXPAND(v_uint32x4, ushort, v_uint16x8, 16, u16, vwcvtu_x_x_v_u32m1, 4) +OPENCV_HAL_IMPL_RVV_EXPAND(v_int32x4, short, v_int16x8, 16, i16, vwcvt_x_x_v_i32m1, 4) +OPENCV_HAL_IMPL_RVV_EXPAND(v_uint64x2, uint, v_uint32x4, 32, u32, vwcvtu_x_x_v_u64m1, 2) +OPENCV_HAL_IMPL_RVV_EXPAND(v_int64x2, int, v_int32x4, 32, i32, vwcvt_x_x_v_i64m1, 2) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + return v_uint32x4(vwcvtu_x_x_v_u32m1(vwcvtu_x_x_v_u16mf2(vle8_v_u8mf4(ptr, 4), 4), 4)); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + return v_int32x4(vwcvt_x_x_v_i32m1(vwcvt_x_x_v_i16mf2(vle8_v_i8mf4(ptr, 4), 4), 4)); +} + + +#define OPENCV_HAL_IMPL_RVV_PACK(_Tpvec, _Tp, _wTpvec, _wTp, hwidth, width, hsuffix, suffix, rshr, shr, hvl, vl) \ +inline _Tpvec v_pack(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(shr(vle##width##_v_##suffix##m2(arr, vl), 0, vl)); \ +} \ +inline void v_pack_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + vse##hwidth##_v_##hsuffix##m1(ptr, shr(vle##width##_v_##suffix##m2(arr, vl), 0, vl), hvl); \ +} \ +template inline \ +_Tpvec v_rshr_pack(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(rshr(vle##width##_v_##suffix##m2(arr, vl), n, vl)); \ +} \ +template inline \ +void v_rshr_pack_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + vse##hwidth##_v_##hsuffix##m1(ptr, _Tpvec(rshr(vle##width##_v_##suffix##m2(arr, vl), n, vl)), hvl); \ +} + +OPENCV_HAL_IMPL_RVV_PACK(v_uint8x16, uchar, v_uint16x8, ushort, 8, 16, u8, u16, vnclipu_wx_u8m1, vnclipu_wx_u8m1, 8, 16) +OPENCV_HAL_IMPL_RVV_PACK(v_int8x16, schar, v_int16x8, short, 8, 16, i8, i16, vnclip_wx_i8m1, vnclip_wx_i8m1, 8, 16) +OPENCV_HAL_IMPL_RVV_PACK(v_uint16x8, ushort, v_uint32x4, unsigned, 16, 32, u16, u32, vnclipu_wx_u16m1, vnclipu_wx_u16m1, 4, 8) +OPENCV_HAL_IMPL_RVV_PACK(v_int16x8, short, v_int32x4, int, 16, 32, i16, i32, vnclip_wx_i16m1, vnclip_wx_i16m1, 4, 8) +OPENCV_HAL_IMPL_RVV_PACK(v_uint32x4, unsigned, v_uint64x2, uint64, 32, 64, u32, u64, vnclipu_wx_u32m1, vnsrl_wx_u32m1, 2, 4) +OPENCV_HAL_IMPL_RVV_PACK(v_int32x4, int, v_int64x2, int64, 32, 64, i32, i64, vnclip_wx_i32m1, vnsra_wx_i32m1, 2, 4) + + +#define OPENCV_HAL_IMPL_RVV_PACK_U(_Tpvec, _Tp, _wTpvec, _wTp, hwidth, width, hsuffix, suffix, rshr, cast, hvl, vl) \ +inline _Tpvec v_pack_u(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), 0, vl)); \ +} \ +inline void v_pack_u_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + vse##hwidth##_v_##hsuffix##m1(ptr, rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), 0, vl), hvl); \ +} \ +template inline \ +_Tpvec v_rshr_pack_u(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), n, vl)); \ +} \ +template inline \ +void v_rshr_pack_u_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + v_store(ptr, _Tpvec(rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), n, vl))); \ +} + +OPENCV_HAL_IMPL_RVV_PACK_U(v_uint8x16, uchar, v_int16x8, short, 8, 16, u8, i16, vnclipu_wx_u8m1, vreinterpret_v_i16m2_u16m2, 8, 16) +OPENCV_HAL_IMPL_RVV_PACK_U(v_uint16x8, ushort, v_int32x4, int, 16, 32, u16, i32, vnclipu_wx_u16m1, vreinterpret_v_i32m2_u32m2, 4, 8) + + +#define OPENCV_HAL_IMPL_RVV_UNPACKS(_Tpvec, _Tp, suffix) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + _Tp ptra0[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptra1[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb0[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb1[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra0, a0); \ + v_store(ptra1, a1); \ + int i; \ + for( i = 0; i < v_##_Tpvec::nlanes/2; i++ ) \ + { \ + ptrb0[i*2] = ptra0[i]; \ + ptrb0[i*2+1] = ptra1[i]; \ + } \ + for( ; i < v_##_Tpvec::nlanes; i++ ) \ + { \ + ptrb1[i*2-v_##_Tpvec::nlanes] = ptra0[i]; \ + ptrb1[i*2-v_##_Tpvec::nlanes+1] = ptra1[i]; \ + } \ + b0 = v_load(ptrb0); \ + b1 = v_load(ptrb1); \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes/2] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes/2] = {0}; \ + v_store_low(ptra, a); \ + v_store_low(ptrb, b); \ + return v_load_halves(ptra, ptrb); \ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes/2] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes/2] = {0}; \ + v_store_high(ptra, a); \ + v_store_high(ptrb, b); \ + return v_load_halves(ptra, ptrb); \ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c = v_combine_low(a, b); \ + d = v_combine_high(a, b); \ +} + +OPENCV_HAL_IMPL_RVV_UNPACKS(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RVV_UNPACKS(int8x16, schar, i8) +OPENCV_HAL_IMPL_RVV_UNPACKS(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RVV_UNPACKS(int16x8, short, i16) +OPENCV_HAL_IMPL_RVV_UNPACKS(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_UNPACKS(int32x4, int, i32) +OPENCV_HAL_IMPL_RVV_UNPACKS(float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_UNPACKS(float64x2, double, f64) +#endif + + +#define OPENCV_HAL_IMPL_RVV_INTERLEAVED(_Tpvec, _Tp) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + int i, i2; \ + for( i = i2 = 0; i < v_##_Tpvec::nlanes; i++, i2 += 2 ) \ + { \ + ptra[i] = ptr[i2]; \ + ptrb[i] = ptr[i2+1]; \ + } \ + a = v_load(ptra); \ + b = v_load(ptrb); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + int i, i3; \ + for( i = i3 = 0; i < v_##_Tpvec::nlanes; i++, i3 += 3 ) \ + { \ + ptra[i] = ptr[i3]; \ + ptrb[i] = ptr[i3+1]; \ + ptrc[i] = ptr[i3+2]; \ + } \ + a = v_load(ptra); \ + b = v_load(ptrb); \ + c = v_load(ptrc); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ + v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrd[v_##_Tpvec::nlanes] = {0}; \ + int i, i4; \ + for( i = i4 = 0; i < v_##_Tpvec::nlanes; i++, i4 += 4 ) \ + { \ + ptra[i] = ptr[i4]; \ + ptrb[i] = ptr[i4+1]; \ + ptrc[i] = ptr[i4+2]; \ + ptrd[i] = ptr[i4+3]; \ + } \ + a = v_load(ptra); \ + b = v_load(ptrb); \ + c = v_load(ptrc); \ + d = v_load(ptrd); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + int i, i2; \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + v_store(ptrb, b); \ + for( i = i2 = 0; i < v_##_Tpvec::nlanes; i++, i2 += 2 ) \ + { \ + ptr[i2] = ptra[i]; \ + ptr[i2+1] = ptrb[i]; \ + } \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + int i, i3; \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + v_store(ptrb, b); \ + v_store(ptrc, c); \ + for( i = i3 = 0; i < v_##_Tpvec::nlanes; i++, i3 += 3 ) \ + { \ + ptr[i3] = ptra[i]; \ + ptr[i3+1] = ptrb[i]; \ + ptr[i3+2] = ptrc[i]; \ + } \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, const v_##_Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + int i, i4; \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrd[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + v_store(ptrb, b); \ + v_store(ptrc, c); \ + v_store(ptrd, d); \ + for( i = i4 = 0; i < v_##_Tpvec::nlanes; i++, i4 += 4 ) \ + { \ + ptr[i4] = ptra[i]; \ + ptr[i4+1] = ptrb[i]; \ + ptr[i4+2] = ptrc[i]; \ + ptr[i4+3] = ptrd[i]; \ + } \ +} \ +inline v_##_Tpvec v_interleave_pairs(const v_##_Tpvec& vec) \ +{ \ + _Tp ptr[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrvec[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptrvec, vec); \ + for (int i = 0; i < v_##_Tpvec::nlanes/4; i++) \ + { \ + ptr[4*i ] = ptrvec[4*i ]; \ + ptr[4*i+1] = ptrvec[4*i+2]; \ + ptr[4*i+2] = ptrvec[4*i+1]; \ + ptr[4*i+3] = ptrvec[4*i+3]; \ + } \ + return v_load(ptr); \ +} \ +inline v_##_Tpvec v_interleave_quads(const v_##_Tpvec& vec) \ +{ \ + _Tp ptr[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrvec[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptrvec, vec); \ + for (int i = 0; i < v_##_Tpvec::nlanes/8; i++) \ + { \ + ptr[8*i ] = ptrvec[4*i ]; \ + ptr[8*i+1] = ptrvec[4*i+4]; \ + ptr[8*i+2] = ptrvec[4*i+1]; \ + ptr[8*i+3] = ptrvec[4*i+5]; \ + ptr[8*i+4] = ptrvec[4*i+2]; \ + ptr[8*i+5] = ptrvec[4*i+6]; \ + ptr[8*i+6] = ptrvec[4*i+3]; \ + ptr[8*i+7] = ptrvec[4*i+7]; \ + } \ + return v_load(ptr); \ +} + +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint8x16, uchar) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int8x16, schar) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint16x8, ushort) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int16x8, short) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint32x4, unsigned) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int32x4, int) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(float32x4, float) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint64x2, uint64) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int64x2, int64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_INTERLEAVED(float64x2, double) +#endif + +//////////// PopCount //////////// + +static const unsigned char popCountTable[] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; + +#define OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(_rTpvec, _Tpvec, _rTp, _Tp, suffix) \ +inline _rTpvec v_popcount(const _Tpvec& a) \ +{ \ + uchar ptra[16] = {0}; \ + v_store(ptra, v_reinterpret_as_u8(a)); \ + _rTp ptr[_Tpvec::nlanes] = {0}; \ + v_store(ptr, v_setzero_##suffix()); \ + for (int i = 0; i < _Tpvec::nlanes*(int)sizeof(_Tp); i++) \ + ptr[i/sizeof(_Tp)] += popCountTable[ptra[i]]; \ + return v_load(ptr); \ +} + +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint8x16, v_uint8x16, uchar, uchar, u8) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint8x16, v_int8x16, uchar, schar, u8) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint16x8, v_uint16x8, ushort, ushort, u16) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint16x8, v_int16x8, ushort, short, u16) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint32x4, v_uint32x4, unsigned, unsigned, u32) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint32x4, v_int32x4, unsigned, int, u32) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint64x2, v_uint64x2, uint64, uint64, u64) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint64x2, v_int64x2, uint64, int64, u64) + +//////////// SignMask //////////// + +#define OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(_Tpvec, _Tp, suffix, vl, shift) \ +inline int v_signmask(const _Tpvec& a) \ +{ \ + int mask = 0; \ + _Tpvec tmp = _Tpvec(vsrl_vx_##suffix##m1(a, shift, vl)); \ + for( int i = 0; i < _Tpvec::nlanes; i++ ) \ + mask |= (int)(tmp.val[i]) << i; \ + return mask; \ +} + +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint8x16, uchar, u8, 16, 7) +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint16x8, ushort, u16, 8, 15) +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint32x4, unsigned, u32, 4, 31) +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint64x2, uint64, u64, 2, 63) + +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } +inline int v_signmask(const v_int16x8& a) +{ return v_signmask(v_reinterpret_as_u16(a)); } +inline int v_signmask(const v_int32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#if CV_SIMD128_64F +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#endif + + +//////////// Scan forward //////////// + +#define OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(_Tpvec, _Tp, suffix) \ +inline int v_scan_forward(const _Tpvec& a) \ +{ \ + _Tp ptr[_Tpvec::nlanes] = {0}; \ + v_store(ptr, v_reinterpret_as_##suffix(a)); \ + for (int i = 0; i < _Tpvec::nlanes; i++) \ + if(int(ptr[i]) < 0) \ + return i; \ + return 0; \ +} + +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int16x8, short, s16) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int32x4, int, s32) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float32x4, float, f32) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int64x2, int64, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float64x2, double, f64) +#endif + +//////////// Pack triplets //////////// + +// use reinterpret instead of c-style casting. +#ifndef __clang__ +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)vint8m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); +} + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vint16m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) +{ + return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); +} + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#else + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int8x16(vreinterpret_i8m1(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16))); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); +} + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int16x8(v_reinterpret_as_s16(v_uint8x16(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16)))); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) +{ + return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); +} + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#endif + +////// FP16 support /////// + +#if CV_FP16 +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + return v_float32x4(vfwcvt_f_f_v_f32m1(vle16_v_f16mf2(ptr, 4), 4)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + vse16_v_f16mf2(ptr, vfncvt_f_f_w_f16mf2(v, 4), 4); +} +#else +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + const int N = 4; + float buf[N]; + for( int i = 0; i < N; i++ ) buf[i] = (float)ptr[i]; + return v_load(buf); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + const int N = 4; + float buf[N]; + v_store(buf, v); + for( int i = 0; i < N; i++ ) ptr[i] = float16_t(buf[i]); +} +#endif + +////////////// Rounding ////////////// + +inline v_int32x4 v_round(const v_float32x4& a) +{ + return v_int32x4(vfcvt_x_f_v_i32m1(a, 4)); +} + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + v_float32x4 ZP5 = v_setall_f32(0.5f); + v_float32x4 t = a - ZP5; + return v_int32x4(vfcvt_x_f_v_i32m1(t, 4)); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + v_float32x4 ZP5 = v_setall_f32(0.5f); + v_float32x4 t = a + ZP5; + return v_int32x4(vfcvt_x_f_v_i32m1(t, 4)); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ + return v_int32x4(vfcvt_rtz_x_f_v_i32m1(a, 4)); +} +#if CV_SIMD128_64F +inline v_int32x4 v_round(const v_float64x2& a) +{ + double arr[4] = {a.val[0], a.val[1], 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + double arr[4] = {a.val[0], a.val[1], b.val[0], b.val[1]}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + double arr[4] = {a.val[0]-0.5f, a.val[1]-0.5f, 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + double arr[4] = {a.val[0]+0.5f, a.val[1]+0.5f, 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + double arr[4] = {a.val[0], a.val[1], 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_rtz_x_f_w_i32m1(tmp, 4)); +} +#endif + + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + int ptr[8] = {0}; + v_int32x4 t1, t2; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2; +} +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + int ptr[8] = {0}; + v_int32x4 t1, t2; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2 + c; +} + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + int64 ptr[4] = {0}; + v_int64x2 t1, t2; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2; +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + int64 ptr[4] = {0}; + v_int64x2 t1, t2; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2 + c; +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + unsigned ptr[16] = {0}; + v_uint32x4 t1, t2, t3, t4; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, + const v_uint32x4& c) +{ + unsigned ptr[16] = {0}; + v_uint32x4 t1, t2, t3, t4; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + int ptr[16] = {0}; + v_int32x4 t1, t2, t3, t4; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ + int ptr[16] = {0}; + v_int32x4 t1, t2, t3, t4; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + uint64 ptr[8] = {0}; + v_uint64x2 t1, t2, t3, t4; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ + uint64 ptr[8] = {0}; + v_uint64x2 t1, t2, t3, t4; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + int64 ptr[8] = {0}; + v_int64x2 t1, t2, t3, t4; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, + const v_int64x2& c) +{ + int64 ptr[8] = {0}; + v_int64x2 t1, t2, t3, t4; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, + const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } +#endif + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ + int ptr[8] = {0}; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + return t1 + t2; +} +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + int ptr[8] = {0}; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + return t1 + t2 + c; +} + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ + int64 ptr[4] = {0}; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + return t1 + t2; +} +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + int64 ptr[4] = {0}; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + return t1 + t2 + c; +} + + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ + unsigned ptr[16] = {0}; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_uint32x4 t1 = v_load(ptr); + v_uint32x4 t2 = v_load(ptr+4); + v_uint32x4 t3 = v_load(ptr+8); + v_uint32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4; +} +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ + unsigned ptr[16] = {0}; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_uint32x4 t1 = v_load(ptr); + v_uint32x4 t2 = v_load(ptr+4); + v_uint32x4 t3 = v_load(ptr+8); + v_uint32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4 + c; +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ + int ptr[16] = {0}; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + v_int32x4 t3 = v_load(ptr+8); + v_int32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4; +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ + int ptr[16] = {0}; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + v_int32x4 t3 = v_load(ptr+8); + v_int32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4 + c; +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + uint64 ptr[8] = {0}; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_uint64x2 t1 = v_load(ptr); + v_uint64x2 t2 = v_load(ptr+2); + v_uint64x2 t3 = v_load(ptr+4); + v_uint64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4; +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ + uint64 ptr[8] = {0}; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_uint64x2 t1 = v_load(ptr); + v_uint64x2 t2 = v_load(ptr+2); + v_uint64x2 t3 = v_load(ptr+4); + v_uint64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4 + c; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + int64 ptr[8] = {0}; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + v_int64x2 t3 = v_load(ptr+4); + v_int64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ + int64 ptr[8] = {0}; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + v_int64x2 t3 = v_load(ptr+4); + v_int64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4 + c; +} + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod_fast(a, b)); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } +#endif + + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0, v_extract_n<0>(v), 4); + res = vfmacc_vf_f32m1(res, v_extract_n<1>(v), m1, 4); + res = vfmacc_vf_f32m1(res, v_extract_n<2>(v), m2, 4); + res = vfmacc_vf_f32m1(res, v_extract_n<3>(v), m3, 4); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0, v_extract_n<0>(v), 4); + res = vfmacc_vf_f32m1(res, v_extract_n<1>(v), m1, 4); + res = vfmacc_vf_f32m1(res, v_extract_n<2>(v), m2, 4); + return v_float32x4(res) + a; +} + +#define OPENCV_HAL_IMPL_RVV_MUL_EXPAND(_Tpvec, _Tpwvec, _Tpw, suffix, wmul, width, vl, hvl) \ +inline void v_mul_expand(const _Tpvec& a, const _Tpvec& b, _Tpwvec& c, _Tpwvec& d) \ +{ \ + _Tpw ptr[_Tpwvec::nlanes*2] = {0}; \ + vse##width##_v_##suffix##m2(ptr, wmul(a, b, vl), vl); \ + c = _Tpwvec(vle##width##_v_##suffix##m1(ptr, hvl)); \ + d = _Tpwvec(vle##width##_v_##suffix##m1(ptr+_Tpwvec::nlanes, hvl)); \ +} + +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_uint8x16, v_uint16x8, ushort, u16, vwmulu_vv_u16m2, 16, 16, 8) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_int8x16, v_int16x8, short, i16, vwmul_vv_i16m2, 16, 16, 8) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_uint16x8, v_uint32x4, unsigned, u32, vwmulu_vv_u32m2, 32, 8, 4) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_int16x8, v_int32x4, int, i32, vwmul_vv_i32m2, 32, 8, 4) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_uint32x4, v_uint64x2, uint64, u64, vwmulu_vv_u64m2, 64, 4, 2) + + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + return v_int16x8(vnsra_wx_i16m1(vwmul_vv_i32m2(a, b, 8), 16, 8)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint16x8(vnsrl_wx_u16m1(vwmulu_vv_u32m2(a, b, 8), 16, 8)); +} + + +//////// Saturating Multiply //////// + +#define OPENCV_HAL_IMPL_RVV_MUL_SAT(_Tpvec, _wTpvec) \ +inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ +{ \ + _wTpvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ +} \ +inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a = a * b; \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_uint16x8, v_uint32x4) +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_int16x8, v_int32x4) + + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + + +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv071.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv071.hpp new file mode 100644 index 0000000..2bdc622 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv071.hpp @@ -0,0 +1,2545 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +// Copyright (C) 2015, PingTouGe Semiconductor Co., Ltd., all rights reserved. + +#ifndef OPENCV_HAL_INTRIN_RISCVV_HPP +#define OPENCV_HAL_INTRIN_RISCVV_HPP + +#include +#include +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +//////////// Types //////////// +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(vuint8m1_t v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = (vuint8m1_t)vle_v_u8m1((unsigned char*)v, 16); + } + uchar get0() const + { + return vmv_x_s_u8m1_u8(val, 16); + } + + vuint8m1_t val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(vint8m1_t v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = (vint8m1_t)vle_v_i8m1((schar*)v, 16); + } + schar get0() const + { + return vmv_x_s_i8m1_i8(val, 16); + } + + vint8m1_t val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(vuint16m1_t v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = (vuint16m1_t)vle_v_u16m1((unsigned short*)v, 8); + } + ushort get0() const + { + return vmv_x_s_u16m1_u16(val, 8); + } + + vuint16m1_t val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(vint16m1_t v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = (vint16m1_t)vle_v_i16m1((signed short*)v, 8); + } + short get0() const + { + return vmv_x_s_i16m1_i16(val, 8); + } + + vint16m1_t val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(vuint32m1_t v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + val = (vuint32m1_t)vle_v_u32m1((unsigned int*)v, 4); + } + unsigned get0() const + { + return vmv_x_s_u32m1_u32(val, 4); + } + + vuint32m1_t val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(vint32m1_t v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = (vint32m1_t)vle_v_i32m1((signed int*)v, 4); + } + int get0() const + { + return vmv_x_s_i32m1_i32(val, 4); + } + vint32m1_t val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(vfloat32m1_t v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = (vfloat32m1_t)vle_v_f32m1((float*)v, 4); + } + float get0() const + { + return vfmv_f_s_f32m1_f32(val, 4); + } + vfloat32m1_t val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(vuint64m1_t v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = (vuint64m1_t)vle_v_u64m1((unsigned long*)v, 2); + } + uint64 get0() const + { + return vmv_x_s_u64m1_u64(val, 2); + } + vuint64m1_t val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(vint64m1_t v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = (vint64m1_t)vle_v_i64m1((long*)v, 2); + } + int64 get0() const + { + return vmv_x_s_i64m1_i64(val, 2); + } + vint64m1_t val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(vfloat64m1_t v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = (vfloat64m1_t)vle_v_f64m1((double*)v, 2); + } + double get0() const + { + return vfmv_f_s_f64m1_f64(val, 2); + } + vfloat64m1_t val; +}; + +#define OPENCV_HAL_IMPL_RISCVV_INIT(_Tpv, _Tp, suffix) \ +inline _Tp##m1_t vreinterpretq_##suffix##_##suffix(_Tp##m1_t v) { return v; } \ +inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16((vuint8m1_t)(v.val)); } \ +inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16((vint8m1_t)(v.val)); } \ +inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8((vuint16m1_t)(v.val)); } \ +inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8((vint16m1_t)(v.val)); } \ +inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4((vuint32m1_t)(v.val)); } \ +inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4((vint32m1_t)(v.val)); } \ +inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2((vuint64m1_t)(v.val)); } \ +inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2((vint64m1_t)(v.val)); } \ +inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4((vfloat32m1_t)(v.val)); }\ +inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2((vfloat64m1_t)(v.val)); } + + +OPENCV_HAL_IMPL_RISCVV_INIT(uint8x16, vuint8, u8) +OPENCV_HAL_IMPL_RISCVV_INIT(int8x16, vint8, s8) +OPENCV_HAL_IMPL_RISCVV_INIT(uint16x8, vuint16, u16) +OPENCV_HAL_IMPL_RISCVV_INIT(int16x8, vint16, s16) +OPENCV_HAL_IMPL_RISCVV_INIT(uint32x4, vuint32, u32) +OPENCV_HAL_IMPL_RISCVV_INIT(int32x4, vint32, s32) +OPENCV_HAL_IMPL_RISCVV_INIT(uint64x2, vuint64, u64) +OPENCV_HAL_IMPL_RISCVV_INIT(int64x2, vint64, s64) +OPENCV_HAL_IMPL_RISCVV_INIT(float64x2, vfloat64, f64) +OPENCV_HAL_IMPL_RISCVV_INIT(float32x4, vfloat32, f32) +#define OPENCV_HAL_IMPL_RISCVV_INIT_SET(__Tp, _Tp, suffix, len, num) \ +inline v_##_Tp##x##num v_setzero_##suffix() { return v_##_Tp##x##num((v##_Tp##m1_t){0}); } \ +inline v_##_Tp##x##num v_setall_##suffix(__Tp v) { return v_##_Tp##x##num(vmv_v_x_##len##m1(v, num)); } + +OPENCV_HAL_IMPL_RISCVV_INIT_SET(uchar, uint8, u8, u8, 16) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(char, int8, s8, i8, 16) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(ushort, uint16, u16, u16, 8) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(short, int16, s16, i16, 8) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(unsigned int, uint32, u32, u32, 4) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(int, int32, s32, i32, 4) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(unsigned long, uint64, u64, u64, 2) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(long, int64, s64, i64, 2) +inline v_float32x4 v_setzero_f32() { return v_float32x4((vfloat32m1_t){0}); } +inline v_float32x4 v_setall_f32(float v) { return v_float32x4(vfmv_v_f_f32m1(v, 4)); } + +inline v_float64x2 v_setzero_f64() { return v_float64x2(vfmv_v_f_f64m1(0, 2)); } +inline v_float64x2 v_setall_f64(double v) { return v_float64x2(vfmv_v_f_f64m1(v, 2)); } + + +#define OPENCV_HAL_IMPL_RISCVV_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +#define OPENCV_HAL_IMPL_RISCVV_BIN_OPN(bin_op, _Tpvec, intrin, num) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val, num)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val, num); \ + return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint8x16, vsaddu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint8x16, vssubu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int8x16, vsadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int8x16, vssub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint16x8, vsaddu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint16x8, vssubu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int16x8, vsadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int16x8, vssub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int32x4, vsadd_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int32x4, vssub_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_int32x4, vmul_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint32x4, vadd_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint32x4, vsub_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_uint32x4, vmul_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int64x2, vsadd_vv_i64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int64x2, vssub_vv_i64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint64x2, vadd_vv_u64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint64x2, vsub_vv_u64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_float32x4, vfadd_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_float32x4, vfsub_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_float32x4, vfmul_vv_f32m1, 4) +inline v_float32x4 operator / (const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vfdiv_vv_f32m1(a.val, b.val, 4)); +} +inline v_float32x4& operator /= (v_float32x4& a, const v_float32x4& b) +{ + a.val = vfdiv_vv_f32m1(a.val, b.val, 4); + return a; +} + +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_float64x2, vfadd_vv_f64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_float64x2, vfsub_vv_f64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_float64x2, vfmul_vv_f64m1, 2) +inline v_float64x2 operator / (const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vfdiv_vv_f64m1(a.val, b.val, 2)); +} +inline v_float64x2& operator /= (v_float64x2& a, const v_float64x2& b) +{ + a.val = vfdiv_vv_f64m1(a.val, b.val, 2); + return a; +} +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_RISCVV_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +#define OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(_Tpvec, func, intrin, num) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val, num)); \ +} +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_min, vminu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_max, vmaxu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_min, vmin_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_max, vmax_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_min, vminu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_max, vmaxu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_min, vmin_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_max, vmax_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint32x4, v_min, vminu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint32x4, v_max, vmaxu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int32x4, v_min, vmin_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int32x4, v_max, vmax_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float32x4, v_min, vfmin_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float32x4, v_max, vfmax_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float64x2, v_min, vfmin_vv_f64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float64x2, v_max, vfmax_vv_f64m1, 2) + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(vfsqrt_v_f32m1(x.val, 4)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + return v_float32x4(vfrdiv_vf_f32m1(vfsqrt_v_f32m1(x.val, 4), 1, 4)); +} + +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(vfmacc_vv_f32m1(vfmul_vv_f32m1(a.val, a.val, 4), b.val, b.val, 4)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vfmacc_vv_f32m1(vfmul_vv_f32m1(a.val, a.val, 4), b.val, b.val, 4)); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_float32x4(vfmacc_vv_f32m1(c.val, a.val, b.val, 4)); +} + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(vmacc_vv_i32m1(c.val, a.val, b.val, 4)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0.val, v.val[0], 4);//vmuli_f32(m0.val, v.val, 0); + res = vfmacc_vf_f32m1(res, v.val[1], m1.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfmacc_vf_f32m1(res, v.val[2], m2.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfmacc_vf_f32m1(res, v.val[3], m3.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0.val, v.val[0], 4);//vmuli_f32(m0.val, v.val, 0); + res = vfmacc_vf_f32m1(res, v.val[1], m1.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfmacc_vf_f32m1(res, v.val[2], m2.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfadd_vv_f32m1(res, a.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + return v_float32x4(res); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(vfsqrt_v_f64m1(x.val, 2)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + return v_float64x2(vfrdiv_vf_f64m1(vfsqrt_v_f64m1(x.val, 2), 1, 2)); +} + +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(vfmacc_vv_f64m1(vfmul_vv_f64m1(a.val, a.val, 2), b.val, b.val, 2)); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vfmacc_vv_f64m1(vfmul_vv_f64m1(a.val, a.val, 2), b.val, b.val, 2)); +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(vfmacc_vv_f64m1(c.val, a.val, b.val, 2)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} + +#define OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(_Tpvec, suffix, num) \ + OPENCV_HAL_IMPL_RISCVV_BIN_OPN(&, _Tpvec, vand_vv_##suffix, num) \ + OPENCV_HAL_IMPL_RISCVV_BIN_OPN(|, _Tpvec, vor_vv_##suffix, num) \ + OPENCV_HAL_IMPL_RISCVV_BIN_OPN(^, _Tpvec, vxor_vv_##suffix, num) \ + inline _Tpvec operator ~ (const _Tpvec & a) \ + { \ + return _Tpvec(vnot_v_##suffix(a.val, num)); \ + } + +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint8x16, u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint16x8, u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint32x4, u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint64x2, u64m1, 2) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int8x16, i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int16x8, i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int32x4, i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int64x2, i64m1, 2) + +#define OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(vfloat32m1_t(intrin(vint32m1_t(a.val), vint32m1_t(b.val), 4))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a.val = vfloat32m1_t(intrin(vint32m1_t(a.val), vint32m1_t(b.val), 4)); \ + return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(&, vand_vv_i32m1) +OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(|, vor_vv_i32m1) +OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(^, vxor_vv_i32m1) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4((vfloat32m1_t)(vnot_v_i32m1((vint32m1_t)(a.val), 4))); +} + +#define OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(vfloat64m1_t(intrin(vint64m1_t(a.val), vint64m1_t(b.val), 2))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a.val = vfloat64m1_t(intrin(vint64m1_t(a.val), vint64m1_t(b.val), 2)); \ + return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(&, vand_vv_i64m1) +OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(|, vor_vv_i64m1) +OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(^, vxor_vv_i64m1) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2((vfloat64m1_t)(vnot_v_i64m1((vint64m1_t)(a.val), 2))); +} +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + return v_int16x8(vmulh_vv_i16m1(a.val, b.val, 8)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint16x8(vmulhu_vv_u16m1(a.val, b.val, 8)); +} + +//#define OPENCV_HAL_IMPL_RISCVV_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ +//inline _Tpuvec v_abs(const _Tpsvec& a) { \ +// E##xm1_t mask=vmflt_vf_e32xm1_f32m1(x.val, 0.0, 4); + +//OPENCV_HAL_IMPL_RISCVV_ABS(v_uint8x16, v_int8x16, u8, s8) +//OPENCV_HAL_IMPL_RISCVV_ABS(v_uint16x8, v_int16x8, u16, s16) +//OPENCV_HAL_IMPL_RISCVV_ABS(v_uint32x4, v_int32x4, u32, s32) + +inline v_uint32x4 v_abs(v_int32x4 x) +{ + vbool32_t mask=vmslt_vx_i32m1_b32(x.val, 0, 4); + return v_uint32x4((vuint32m1_t)vrsub_vx_i32m1_m(mask, x.val, x.val, 0, 4)); +} + +inline v_uint16x8 v_abs(v_int16x8 x) +{ + vbool16_t mask=vmslt_vx_i16m1_b16(x.val, 0, 8); + return v_uint16x8((vuint16m1_t)vrsub_vx_i16m1_m(mask, x.val, x.val, 0, 8)); +} + +inline v_uint8x16 v_abs(v_int8x16 x) +{ + vbool8_t mask=vmslt_vx_i8m1_b8(x.val, 0, 16); + return v_uint8x16((vuint8m1_t)vrsub_vx_i8m1_m(mask, x.val, x.val, 0, 16)); +} + +inline v_float32x4 v_abs(v_float32x4 x) +{ + return (v_float32x4)vfsgnjx_vv_f32m1(x.val, x.val, 4); +} + +inline v_float64x2 v_abs(v_float64x2 x) +{ + return (v_float64x2)vfsgnjx_vv_f64m1(x.val, x.val, 2); +} + +inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b) +{ + vfloat32m1_t ret = vfsub_vv_f32m1(a.val, b.val, 4); + return (v_float32x4)vfsgnjx_vv_f32m1(ret, ret, 4); +} + +inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b) +{ + vfloat64m1_t ret = vfsub_vv_f64m1(a.val, b.val, 2); + return (v_float64x2)vfsgnjx_vv_f64m1(ret, ret, 2); +} + +#define OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(bit, num) \ +inline v_uint##bit##x##num v_absdiff(v_uint##bit##x##num a, v_uint##bit##x##num b){ \ + vuint##bit##m1_t vmax = vmaxu_vv_u##bit##m1(a.val, b.val, num); \ + vuint##bit##m1_t vmin = vminu_vv_u##bit##m1(a.val, b.val, num); \ + return v_uint##bit##x##num(vsub_vv_u##bit##m1(vmax, vmin, num));\ +} + +OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(8, 16) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(16, 8) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(32, 4) + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(v_int8x16 a, v_int8x16 b){ + vint8m1_t vmax = vmax_vv_i8m1(a.val, b.val, 16); + vint8m1_t vmin = vmin_vv_i8m1(a.val, b.val, 16); + return v_int8x16(vssub_vv_i8m1(vmax, vmin, 16)); +} +inline v_int16x8 v_absdiffs(v_int16x8 a, v_int16x8 b){ + vint16m1_t vmax = vmax_vv_i16m1(a.val, b.val, 8); + vint16m1_t vmin = vmin_vv_i16m1(a.val, b.val, 8); + return v_int16x8(vssub_vv_i16m1(vmax, vmin, 8)); +} + +#define OPENCV_HAL_IMPL_RISCVV_ABSDIFF(_Tpvec, _Tpv, num) \ +inline v_uint##_Tpvec v_absdiff(v_int##_Tpvec a, v_int##_Tpvec b){ \ + vint##_Tpv##_t max = vmax_vv_i##_Tpv(a.val, b.val, num);\ + vint##_Tpv##_t min = vmin_vv_i##_Tpv(a.val, b.val, num);\ + return v_uint##_Tpvec((vuint##_Tpv##_t)vsub_vv_i##_Tpv(max, min, num)); \ +} + +OPENCV_HAL_IMPL_RISCVV_ABSDIFF(8x16, 8m1, 16) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF(16x8, 16m1, 8) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF(32x4, 32m1, 4) + +// Multiply and expand +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + vint16m2_t res = vundefined_i16m2(); + res = vwmul_vv_i16m2(a.val, b.val, 16); + c.val = vget_i16m2_i16m1(res, 0); + d.val = vget_i16m2_i16m1(res, 1); +} + +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + vuint16m2_t res = vundefined_u16m2(); + res = vwmulu_vv_u16m2(a.val, b.val, 16); + c.val = vget_u16m2_u16m1(res, 0); + d.val = vget_u16m2_u16m1(res, 1); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + vint32m2_t res = vundefined_i32m2(); + res = vwmul_vv_i32m2(a.val, b.val, 8); + c.val = vget_i32m2_i32m1(res, 0); + d.val = vget_i32m2_i32m1(res, 1); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + vuint32m2_t res = vundefined_u32m2(); + res = vwmulu_vv_u32m2(a.val, b.val, 8); + c.val = vget_u32m2_u32m1(res, 0); + d.val = vget_u32m2_u32m1(res, 1); +} + +inline void v_mul_expand(const v_int32x4& a, const v_int32x4& b, + v_int64x2& c, v_int64x2& d) +{ + vint64m2_t res = vundefined_i64m2(); + res = vwmul_vv_i64m2(a.val, b.val, 4); + c.val = vget_i64m2_i64m1(res, 0); + d.val = vget_i64m2_i64m1(res, 1); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + vuint64m2_t res = vundefined_u64m2(); + res = vwmulu_vv_u64m2(a.val, b.val, 4); + c.val = vget_u64m2_u64m1(res, 0); + d.val = vget_u64m2_u64m1(res, 1); +} + +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_add_wrap, vadd_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_add_wrap, vadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_add_wrap, vadd_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_add_wrap, vadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_sub_wrap, vsub_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_sub_wrap, vsub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_sub_wrap, vsub_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_sub_wrap, vsub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_mul_wrap, vmul_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_mul_wrap, vmul_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_mul_wrap, vmul_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_mul_wrap, vmul_vv_i16m1, 8) +//////// Dot Product //////// +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t res = vundefined_i32m2(); + res = vwmul_vv_i32m2(a.val, b.val, 8); + res = vrgather_vv_i32m2(res, (vuint32m2_t){0, 2, 4, 6, 1, 3, 5, 7}, 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(res, 0), vget_i32m2_i32m1(res, 1), 4)); +} +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + vint32m2_t res = vundefined_i32m2(); + res = vwmul_vv_i32m2(a.val, b.val, 8); + res = vrgather_vv_i32m2(res, (vuint32m2_t){0, 2, 4, 6, 1, 3, 5, 7}, 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(res, 0),vget_i32m2_i32m1(res, 1), 4), c.val, 4)); +} + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + vint64m2_t res = vundefined_i64m2(); + res = vwmul_vv_i64m2(a.val, b.val, 4); + res = vrgather_vv_i64m2(res, (vuint64m2_t){0, 2, 1, 3}, 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(res, 0), vget_i64m2_i64m1(res, 1), 2)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + vint64m2_t res = vundefined_i64m2(); + res = vwmul_vv_i64m2(a.val, b.val, 4); + res = vrgather_vv_i64m2(res, (vuint64m2_t){0, 2, 1, 3}, 4); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(res, 0), vget_i64m2_i64m1(res, 1), 2), c.val, 2)); +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v1 = vrgather_vv_u16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4)); +} + +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, + const v_uint32x4& c) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v1 = vrgather_vv_u16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4), c.val, 4)); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v1 = vrgather_vv_i16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4)); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v1 = vrgather_vv_i16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4), c.val, 4)); +} + +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v1 = vrgather_vv_u32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2)); +} + +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, + const v_uint64x2& c) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v1 = vrgather_vv_u32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2), c.val, 2)); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v1 = vrgather_vv_i32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2)); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, + const v_int64x2& c) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v1 = vrgather_vv_i32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2), c.val, 2)); +} + +//////// Fast Dot Product //////// +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t v1 = vundefined_i32m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4)); +} + +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + vint32m2_t v1 = vundefined_i32m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4), c.val, 4)); +} + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ + vint64m2_t v1 = vundefined_i64m2(); + v1 = vwmul_vv_i64m2(a.val, b.val, 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(v1, 0), vget_i64m2_i64m1(v1, 1), 2)); +} +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + vint64m2_t v1 = vundefined_i64m2(); + v1 = vwmul_vv_i64m2(a.val, b.val, 8); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v1, 0), vget_i64m2_i64m1(v1, 1), 4), c.val, 4)); +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4)); +} + +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4), c.val, 4)); +} + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4)); +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4), c.val, 4)); +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2)); +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2), c.val, 2)); +} + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2)); +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2), c.val, 2)); +} + + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(_Tpvec, _Tpvec2, len, scalartype, func, intrin, num) \ +inline scalartype v_reduce_##func(const v_##_Tpvec##x##num& a) \ +{\ + v##_Tpvec2##m1_t val = vmv_v_x_##len##m1(0, num); \ + val = intrin(val, a.val, val, num); \ + return vmv_x_s_##len##m1_##len(val, num); \ +} + + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(_Tpvec, _Tpvec2, scalartype, func, funcu, num) \ +inline scalartype v_reduce_##func(const v_##_Tpvec##x##num& a) \ +{\ + v##_Tpvec##m1_t val = (v##_Tpvec##m1_t)vmv_v_x_i8m1(0, num); \ + val = v##funcu##_vs_##_Tpvec2##m1_##_Tpvec2##m1(val, a.val, a.val, num); \ + return val[0]; \ +} +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int8, int16, i16, int, sum, vwredsum_vs_i8m1_i16m1, 16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int16, int32, i32, int, sum, vwredsum_vs_i16m1_i32m1, 8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int32, int64, i64, int, sum, vwredsum_vs_i32m1_i64m1, 4) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint8, uint16, u16, unsigned, sum, vwredsumu_vs_u8m1_u16m1, 16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint16, uint32, u32, unsigned, sum, vwredsumu_vs_u16m1_u32m1, 8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint32, uint64, u64, unsigned, sum, vwredsumu_vs_u32m1_u64m1, 4) +inline float v_reduce_sum(const v_float32x4& a) \ +{\ + vfloat32m1_t val = vfmv_v_f_f32m1(0.0, 4); \ + val = vfredsum_vs_f32m1_f32m1(val, a.val, val, 4); \ + return vfmv_f_s_f32m1_f32(val, 4); \ +} +inline double v_reduce_sum(const v_float64x2& a) \ +{\ + vfloat64m1_t val = vfmv_v_f_f64m1(0.0, 2); \ + val = vfredsum_vs_f64m1_f64m1(val, a.val, val, 2); \ + return vfmv_f_s_f64m1_f64(val, 2); \ +} +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ return vext_x_v_u64m1_u64((vuint64m1_t)a.val, 0, 2)+vext_x_v_u64m1_u64((vuint64m1_t)a.val, 1, 2); } + +inline int64 v_reduce_sum(const v_int64x2& a) +{ return vext_x_v_i64m1_i64((vint64m1_t)a.val, 0, 2)+vext_x_v_i64m1_i64((vint64m1_t)a.val, 1, 2); } + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(func) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int8, i8, int, func, red##func, 16) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int16, i16, int, func, red##func, 8) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int32, i32, int, func, red##func, 4) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int64, i64, int, func, red##func, 2) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint8, u8, unsigned, func, red##func##u, 16) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint16, u16, unsigned, func, red##func##u, 8) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint32, u32, unsigned, func, red##func##u, 4) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(float32, f32, float, func, fred##func, 4) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(max) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(min) + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + vfloat32m1_t a0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t b0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t c0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t d0 = vfmv_v_f_f32m1(0.0, 4); + a0 = vfredsum_vs_f32m1_f32m1(a0, a.val, a0, 4); + b0 = vfredsum_vs_f32m1_f32m1(b0, b.val, b0, 4); + c0 = vfredsum_vs_f32m1_f32m1(c0, c.val, c0, 4); + d0 = vfredsum_vs_f32m1_f32m1(d0, d.val, d0, 4); + return v_float32x4(a0[0], b0[0], c0[0], d0[0]); +} + +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + vfloat32m1_t a0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t x = vfsub_vv_f32m1(a.val, b.val, 4); + vbool32_t mask=vmflt_vf_f32m1_b32(x, 0, 4); + vfloat32m1_t val = vfrsub_vf_f32m1_m(mask, x, x, 0, 4); + a0 = vfredsum_vs_f32m1_f32m1(a0, val, a0, 4); + return a0[0]; +} + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(_Tpvec, _Tpvec2) \ +inline unsigned v_reduce_sad(const _Tpvec& a, const _Tpvec&b){ \ + _Tpvec2 x = v_absdiff(a, b); \ + return v_reduce_sum(x); \ +} + +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int8x16, v_uint8x16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint8x16, v_uint8x16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int16x8, v_uint16x8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint16x8, v_uint16x8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int32x4, v_uint32x4) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint32x4, v_uint32x4) + +#define OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(_Tpvec, _Tp, _T, num, uv) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmseq_vv_##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmsne_vv_##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmslt##uv##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmslt##uv##_Tp##_b##_T(b.val, a.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmsle##uv##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmsle##uv##_Tp##_b##_T(b.val, a.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ + +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int8x16, i8m1, 8, 16, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int16x8, i16m1, 16, 8, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int32x4, i32m1, 32, 4, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int64x2, i64m1, 64, 2, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint8x16, u8m1, 8, 16, u_vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint16x8, u16m1, 16, 8, u_vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint32x4, u32m1, 32, 4, u_vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint64x2, u64m1, 64, 2, u_vv_) + +//TODO: == +inline v_float32x4 operator == (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfeq_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator != (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfne_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator < (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmflt_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator <= (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfle_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator > (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfgt_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator >= (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfge_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ + vbool32_t mask = vmford_vv_f32m1_b32(a.val, a.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} + +//TODO: == +inline v_float64x2 operator == (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfeq_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator != (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfne_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator < (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmflt_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator <= (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfle_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator > (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfgt_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator >= (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfge_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ + vbool64_t mask = vmford_vv_f64m1_b64(a.val, a.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +#define OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(_Tp, _T) \ +inline void v_transpose4x4(const v_##_Tp##32x4& a0, const v_##_Tp##32x4& a1, \ + const v_##_Tp##32x4& a2, const v_##_Tp##32x4& a3, \ + v_##_Tp##32x4& b0, v_##_Tp##32x4& b1, \ + v_##_Tp##32x4& b2, v_##_Tp##32x4& b3) \ +{ \ + v##_Tp##32m4_t val = vundefined_##_T##m4(); \ + val = vset_##_T##m4(val, 0, a0.val); \ + val = vset_##_T##m4(val, 1, a1.val); \ + val = vset_##_T##m4(val, 2, a2.val); \ + val = vset_##_T##m4(val, 3, a3.val); \ + val = vrgather_vv_##_T##m4(val, (vuint32m4_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); \ + b0.val = vget_##_T##m4_##_T##m1(val, 0); \ + b1.val = vget_##_T##m4_##_T##m1(val, 1); \ + b2.val = vget_##_T##m4_##_T##m1(val, 2); \ + b3.val = vget_##_T##m4_##_T##m1(val, 3); \ +} +OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(uint, u32) +OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(int, i32) +OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(float, f32) + + +#define OPENCV_HAL_IMPL_RISCVV_SHIFT_LEFT(_Tpvec, suffix, _T, num) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ return _Tpvec((vsll_vx_##_T##m1(a.val, n, num))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec((vsll_vx_##_T##m1(a.val, n, num))); } + +#define OPENCV_HAL_IMPL_RISCVV_SHIFT_RIGHT(_Tpvec, suffix, _T, num, intric) \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ return _Tpvec((v##intric##_vx_##_T##m1(a.val, n, num))); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec((v##intric##_vx_##_T##m1(a.val, n, num))); }\ +template inline _Tpvec v_rshr(const _Tpvec& a) \ +{ return _Tpvec((v##intric##_vx_##_T##m1(vadd_vx_##_T##m1(a.val, 1<<(n-1), num), n, num))); } + +// trade efficiency for convenience +#define OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(suffix, _T, num, intrin) \ +OPENCV_HAL_IMPL_RISCVV_SHIFT_LEFT(v_##suffix##x##num, suffix, _T, num) \ +OPENCV_HAL_IMPL_RISCVV_SHIFT_RIGHT(v_##suffix##x##num, suffix, _T, num, intrin) + +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint8, u8, 16, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint16, u16, 8, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint32, u32, 4, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint64, u64, 2, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int8, i8, 16, sra) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int16, i16, 8, sra) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int32, i32, 4, sra) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int64, i64, 2, sra) + +#if 0 +#define VUP4(n) {0, 1, 2, 3} +#define VUP8(n) {0, 1, 2, 3, 4, 5, 6, 7} +#define VUP16(n) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} +#define VUP2(n) {0, 1} +#endif +#define OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(_Tpvec, suffix, _T, num, num2, vmv, len) \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + suffix##m1_t tmp = vmv##_##_T##m1(0, num);\ + tmp = vslideup_vx_##_T##m1_m(vmset_m_##len(num), tmp, a.val, n, num);\ + return _Tpvec(tmp);\ +} \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(vslidedown_vx_##_T##m1(a.val, n, num));\ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + suffix##m2_t tmp = vundefined_##_T##m2(); \ + tmp = vset_##_T##m2(tmp, 0, a.val); \ + tmp = vset_##_T##m2(tmp, 1, b.val); \ + tmp = vslidedown_vx_##_T##m2(tmp, n, num2);\ + return _Tpvec(vget_##_T##m2_##_T##m1(tmp, 0));\ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + suffix##m2_t tmp = vundefined_##_T##m2(); \ + tmp = vset_##_T##m2(tmp, 0, b.val); \ + tmp = vset_##_T##m2(tmp, 1, a.val); \ + tmp = vslideup_vx_##_T##m2(tmp, n, num2);\ + return _Tpvec(vget_##_T##m2_##_T##m1(tmp, 1));\ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ \ + CV_UNUSED(b); return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint8x16, vuint8, u8, 16, 32, vmv_v_x, b8) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int8x16, vint8, i8, 16, 32, vmv_v_x, b8) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint16x8, vuint16, u16, 8, 16, vmv_v_x, b16) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int16x8, vint16, i16, 8, 16, vmv_v_x, b16) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint32x4, vuint32, u32, 4, 8, vmv_v_x, b32) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int32x4, vint32, i32, 4, 8, vmv_v_x, b32) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint64x2, vuint64, u64, 2, 4, vmv_v_x, b64) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int64x2, vint64, i64, 2, 4, vmv_v_x, b64) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_float32x4, vfloat32, f32, 4, 8, vfmv_v_f, b32) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_float64x2, vfloat64, f64, 2, 4, vfmv_v_f, b64) + +#define OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(_Tpvec, _Tp, _Tp2, len, hnum, num) \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + typedef uint64 CV_DECL_ALIGNED(1) unaligned_uint64; \ + vuint64m1_t tmp = {*(unaligned_uint64*)ptr0, *(unaligned_uint64*)ptr1};\ + return _Tpvec(_Tp2##_t(tmp)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(vle_v_##len(ptr, hnum)); }\ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(vle_v_##len(ptr, num)); } \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec((_Tp2##_t)vle_v_##len((const _Tp *)ptr, num)); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, hnum);}\ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + _Tp2##_t a0 = vslidedown_vx_##len(a.val, hnum, num); \ + vse_v_##len(ptr, a0, hnum);}\ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, num); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, num); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, num); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ vse_v_##len(ptr, a.val, num); } + +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint8x16, uchar, vuint8m1, u8m1, 8, 16) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int8x16, schar, vint8m1, i8m1, 8, 16) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint16x8, ushort, vuint16m1, u16m1, 4, 8) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int16x8, short, vint16m1, i16m1, 4, 8) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint32x4, unsigned, vuint32m1, u32m1, 2, 4) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int32x4, int, vint32m1, i32m1, 2, 4) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint64x2, unsigned long, vuint64m1, u64m1, 1, 2) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int64x2, long, vint64m1, i64m1, 1, 2) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_float32x4, float, vfloat32m1, f32m1, 2, 4) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_float64x2, double, vfloat64m1, f64m1, 1, 2) + + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ +#if 1 + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(vle_v_i8m1(elems, 16)); +#else + int32xm4_t index32 = vlev_int32xm4(idx, 16); + vint16m2_t index16 = vnsra_vx_i16m2_int32xm4(index32, 0, 16); + vint8m1_t index = vnsra_vx_i8m1_i16m2(index16, 0, 16); + return v_int8x16(vlxbv_i8m1(tab, index, 16)); +#endif +} + +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx){ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(vle_v_i8m1(elems, 16)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(vle_v_i8m1(elems, 16)); +} + +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(vle_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(vle_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3] + }; + return v_int16x8(vle_v_i16m1(elems, 8)); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(vle_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1] + }; + return v_int32x4(vle_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vle_v_i32m1(tab+idx[0], 4)); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + vint64m1_t res = {tab[idx[0]], tab[idx[1]]}; + return v_int64x2(res); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(vle_v_i64m1(tab+idx[0], 2)); +} + +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) +{ + vuint64m1_t res = {tab[idx[0]], tab[idx[1]]}; + return v_uint64x2(res); +} +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) +{ + return v_uint64x2(vle_v_u64m1(tab+idx[0], 2)); +} + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(vle_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[0]+1], + tab[idx[1]], + tab[idx[1]+1] + }; + return v_float32x4(vle_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(vle_v_f32m1(tab + idx[0], 4)); +} +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + vfloat64m1_t res = {tab[idx[0]], tab[idx[1]]}; + return v_float64x2(res); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(vle_v_f64m1(tab+idx[0], 2)); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idxvec.val[0]], + tab[idxvec.val[1]], + tab[idxvec.val[2]], + tab[idxvec.val[3]] + }; + return v_int32x4(vle_v_i32m1(elems, 4)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned CV_DECL_ALIGNED(32) elems[4] = + { + tab[idxvec.val[0]], + tab[idxvec.val[1]], + tab[idxvec.val[2]], + tab[idxvec.val[3]] + }; + return v_uint32x4(vle_v_u32m1(elems, 4)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idxvec.val[0]], + tab[idxvec.val[1]], + tab[idxvec.val[2]], + tab[idxvec.val[3]] + }; + return v_float32x4(vle_v_f32m1(elems, 4)); +} +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + vfloat64m1_t res = {tab[idxvec.val[0]], tab[idxvec.val[1]]}; + return v_float64x2(res); +} +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + vint32m1_t index_x = vmul_vx_i32m1(idxvec.val, 4, 4); + vint32m1_t index_y = vadd_vx_i32m1(index_x, 4, 4); + + x.val = vlxe_v_f32m1(tab, index_x, 4); + y.val = vlxe_v_f32m1(tab, index_y, 4); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float64x2(tab[idx[0]], tab[idx[1]]); + y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); +} + +#define OPENCV_HAL_IMPL_RISCVV_PACKS(_Tp, _Tp2, _T2, num2, _T1, num, intrin, shr, _Type) \ +inline v_##_Tp##x##num v_pack(const v_##_Tp2##x##num2& a, const v_##_Tp2##x##num2& b) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, b.val); \ + return v_##_Tp##x##num(shr##_##_T1##m1(tmp, 0, num)); \ +}\ +template inline \ +v_##_Tp##x##num v_rshr_pack(const v_##_Tp2##x##num2& a, const v_##_Tp2##x##num2& b) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, b.val); \ + return v_##_Tp##x##num(intrin##_##_T1##m1(tmp, n, num)); \ +}\ +inline void v_pack_store(_Type* ptr, const v_##_Tp2##x##num2& a) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, vmv_v_x_##_T2##m1(0, num2)); \ + asm("" ::: "memory"); \ + vse_v_##_T1##m1(ptr, shr##_##_T1##m1(tmp, 0, num), num2); \ +}\ +template inline \ +void v_rshr_pack_store(_Type* ptr, const v_##_Tp2##x##num2& a) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, vmv_v_x_##_T2##m1(0, num2)); \ + vse_v_##_T1##m1(ptr, intrin##_##_T1##m1(tmp, n, num), num2); \ +} +OPENCV_HAL_IMPL_RISCVV_PACKS(int8, int16, i16, 8, i8, 16, vnclip_vx, vnclip_vx, signed char) +OPENCV_HAL_IMPL_RISCVV_PACKS(int16, int32, i32, 4, i16, 8, vnclip_vx, vnclip_vx, signed short) +OPENCV_HAL_IMPL_RISCVV_PACKS(int32, int64, i64, 2, i32, 4, vnclip_vx, vnsra_vx, int) +OPENCV_HAL_IMPL_RISCVV_PACKS(uint8, uint16, u16, 8, u8, 16, vnclipu_vx, vnclipu_vx, unsigned char) +OPENCV_HAL_IMPL_RISCVV_PACKS(uint16, uint32, u32, 4, u16, 8, vnclipu_vx, vnclipu_vx, unsigned short) +OPENCV_HAL_IMPL_RISCVV_PACKS(uint32, uint64, u64, 2, u32, 4, vnclipu_vx, vnsrl_vx, unsigned int) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + vuint16m2_t tmp = vundefined_u16m2(); \ + tmp = vset_u16m2(tmp, 0, a.val); \ + tmp = vset_u16m2(tmp, 1, b.val); \ + return v_uint8x16(vnsrl_vx_u8m1(tmp, 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + vuint32m4_t vabcd = vundefined_u32m4(); \ + vuint16m2_t v16 = vundefined_u16m2(); \ + vabcd = vset_u32m4(vabcd, 0, a.val); \ + vabcd = vset_u32m4(vabcd, 1, b.val); \ + vabcd = vset_u32m4(vabcd, 2, c.val); \ + vabcd = vset_u32m4(vabcd, 3, d.val); \ + v16 = vnsrl_vx_u16m2(vabcd, 0, 16); + return v_uint8x16(vnsrl_vx_u8m1(v16, 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + vuint64m8_t v64 = vundefined_u64m8(); \ + vuint32m4_t v32 = vundefined_u32m4(); \ + vuint16m2_t v16 = vundefined_u16m2(); \ + v64 = vset_u64m8(v64, 0, a.val); \ + v64 = vset_u64m8(v64, 1, b.val); \ + v64 = vset_u64m8(v64, 2, c.val); \ + v64 = vset_u64m8(v64, 3, d.val); \ + v64 = vset_u64m8(v64, 4, e.val); \ + v64 = vset_u64m8(v64, 5, f.val); \ + v64 = vset_u64m8(v64, 6, g.val); \ + v64 = vset_u64m8(v64, 7, h.val); \ + v32 = vnsrl_vx_u32m4(v64, 0, 16); + v16 = vnsrl_vx_u16m2(v32, 0, 16); + return v_uint8x16(vnsrl_vx_u8m1(v16, 0, 16)); +} + +//inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) \ +//{ \ +// int16xm2_u tmp; \ +// tmp.m1[0] = (vint16m1_t)a.val; \ +// tmp.m1[1] = (vint16m1_t)b.val; \ +// e8xm1_t mask = (e8xm1_t)vmsge_vx_e16xm2_i16m2(tmp.v, 0, 16);\ +// return v_uint8x16(vnclipuvi_mask_u8m1_u16m2(vmv_v_x_u8m1(0, 16), (vuint16m2_t)tmp.v, 0, mask, 16)); +//} + +#define OPENCV_HAL_IMPL_RISCVV_PACK_U(tp1, num1, tp2, num2, _Tp) \ +inline v_uint##tp1##x##num1 v_pack_u(const v_int##tp2##x##num2& a, const v_int##tp2##x##num2& b) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + tmp = vset_##i##tp2##m2(tmp, 1, b.val); \ + vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + return v_uint##tp1##x##num1(vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val, 0, num1)); \ +} \ +inline void v_pack_u_store(_Tp* ptr, const v_int##tp2##x##num2& a) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + return vse_v_u##tp1##m1(ptr, vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val, 0, num1), num2); \ +} \ +template inline \ +v_uint##tp1##x##num1 v_rshr_pack_u(const v_int##tp2##x##num2& a, const v_int##tp2##x##num2& b) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + tmp = vset_##i##tp2##m2(tmp, 1, b.val); \ + vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + return v_uint##tp1##x##num1(vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val, n, num1)); \ +} \ +template inline \ +void v_rshr_pack_u_store(_Tp* ptr, const v_int##tp2##x##num2& a) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + vint##tp2##m2_t val_ = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + vuint##tp1##m1_t val = vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val_, n, num1); \ + return vse_v_u##tp1##m1(ptr, val, num2);\ +} +OPENCV_HAL_IMPL_RISCVV_PACK_U(8, 16, 16, 8, unsigned char ) +OPENCV_HAL_IMPL_RISCVV_PACK_U(16, 8, 32, 4, unsigned short) + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_RISCVV_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_uint16x8, v_uint32x4) + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +static const signed char popCountTable[256] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; + +inline vuint8m1_t vcnt_u8(vuint8m1_t val){ + vuint8m1_t v0 = val & 1; + return vlxe_v_u8m1((unsigned char*)popCountTable, val >> 1, 16)+v0; +} + +inline v_uint8x16 +v_popcount(const v_uint8x16& a) +{ + return v_uint8x16(vcnt_u8(a.val)); +} + +inline v_uint8x16 +v_popcount(const v_int8x16& a) +{ + return v_uint8x16(vcnt_u8((vuint8m1_t)a.val)); +} + +inline v_uint16x8 +v_popcount(const v_uint16x8& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0E0C0A0806040200, 0, 0x0F0D0B0907050301, 0}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 8); + return v_uint16x8(vget_u16m2_u16m1(res, 0)); +} + +inline v_uint16x8 +v_popcount(const v_int16x8& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0E0C0A0806040200, 0, 0x0F0D0B0907050301, 0}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 8); + return v_uint16x8(vget_u16m2_u16m1(res, 0)); +} + +inline v_uint32x4 +v_popcount(const v_uint32x4& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0xFFFFFFFF0C080400, 0xFFFFFFFF0D090501, + 0xFFFFFFFF0E0A0602, 0xFFFFFFFF0F0B0703}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res_ = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 16); + vuint32m2_t res = vwaddu_vv_u32m2(vget_u16m2_u16m1(res_, 0), vget_u16m2_u16m1(res_, 1), 8); + return v_uint32x4(vget_u32m2_u32m1(res, 0)); +} + +inline v_uint32x4 +v_popcount(const v_int32x4& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0xFFFFFFFF0C080400, 0xFFFFFFFF0D090501, + 0xFFFFFFFF0E0A0602, 0xFFFFFFFF0F0B0703}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res_ = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 16); + vuint32m2_t res = vwaddu_vv_u32m2(vget_u16m2_u16m1(res_, 0), vget_u16m2_u16m1(res_, 1), 8); + return v_uint32x4(vget_u32m2_u32m1(res, 0)); +} + +inline v_uint64x2 +v_popcount(const v_uint64x2& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0706050403020100, 0x0000000000000000, + 0x0F0E0D0C0B0A0908, 0x0000000000000000}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint8m1_t zero = vmv_v_x_u8m1(0, 16); + vuint8m1_t res1 = zero; + vuint8m1_t res2 = zero; + res1 = vredsum_vs_u8m1_u8m1(res1, vget_u8m2_u8m1(tmp, 0), zero, 8); + res2 = vredsum_vs_u8m1_u8m1(res2, vget_u8m2_u8m1(tmp, 1), zero, 8); + + return v_uint64x2((unsigned long)vmv_x_s_u8m1_u8(res1, 8), (unsigned long)vmv_x_s_u8m1_u8(res2, 8)); +} + +inline v_uint64x2 +v_popcount(const v_int64x2& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0706050403020100, 0x0000000000000000, + 0x0F0E0D0C0B0A0908, 0x0000000000000000}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint8m1_t zero = vmv_v_x_u8m1(0, 16); + vuint8m1_t res1 = zero; + vuint8m1_t res2 = zero; + res1 = vredsum_vs_u8m1_u8m1(res1, vget_u8m2_u8m1(tmp, 0), zero, 8); + res2 = vredsum_vs_u8m1_u8m1(res2, vget_u8m2_u8m1(tmp, 1), zero, 8); + + return v_uint64x2((unsigned long)vmv_x_s_u8m1_u8(res1, 8), (unsigned long)vmv_x_s_u8m1_u8(res2, 8)); +} + +#define SMASK 1, 2, 4, 8, 16, 32, 64, 128 +inline int v_signmask(const v_uint8x16& a) +{ + vuint8m1_t t0 = vsrl_vx_u8m1(a.val, 7, 16); + vuint8m1_t m1 = (vuint8m1_t){SMASK, SMASK}; + vuint16m2_t t1 = vwmulu_vv_u16m2(t0, m1, 16); + vuint32m1_t res = vmv_v_x_u32m1(0, 4); + vuint32m2_t t2 = vwmulu_vx_u32m2(vget_u16m2_u16m1(t1, 1), 256, 8); + res = vredsum_vs_u32m2_u32m1(res, t2, res, 8); + res = vwredsumu_vs_u16m1_u32m1(res, vget_u16m2_u16m1(t1, 0), res, 8); + return vmv_x_s_u32m1_u32(res, 8); +} +inline int v_signmask(const v_int8x16& a) +{ + vuint8m1_t t0 = vsrl_vx_u8m1((vuint8m1_t)a.val, 7, 16); + vuint8m1_t m1 = (vuint8m1_t){SMASK, SMASK}; + vint16m2_t t1 = (vint16m2_t)vwmulu_vv_u16m2(t0, m1, 16); + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m2_t t2 = vwmul_vx_i32m2(vget_i16m2_i16m1(t1, 1), 256, 8); + res = vredsum_vs_i32m2_i32m1(res, t2, res, 8); + res = vwredsum_vs_i16m1_i32m1(res, vget_i16m2_i16m1(t1, 0), res, 8); + return vmv_x_s_i32m1_i32(res, 8); +} + +inline int v_signmask(const v_int16x8& a) +{ + vint16m1_t t0 = (vint16m1_t)vsrl_vx_u16m1((vuint16m1_t)a.val, 15, 8); + vint16m1_t m1 = (vint16m1_t){SMASK}; + vint16m1_t t1 = vmul_vv_i16m1(t0, m1, 8); + vint16m1_t res = vmv_v_x_i16m1(0, 8); + res = vredsum_vs_i16m1_i16m1(res, t1, res, 8); + return vmv_x_s_i16m1_i16(res, 8); +} +inline int v_signmask(const v_uint16x8& a) +{ + vint16m1_t t0 = (vint16m1_t)vsrl_vx_u16m1((vuint16m1_t)a.val, 15, 8); + vint16m1_t m1 = (vint16m1_t){SMASK}; + vint16m1_t t1 = vmul_vv_i16m1(t0, m1, 8); + vint16m1_t res = vmv_v_x_i16m1(0, 8); + res = vredsum_vs_i16m1_i16m1(res, t1, res, 8); + return vmv_x_s_i16m1_i16(res, 8); +} +inline int v_signmask(const v_int32x4& a) +{ + vint32m1_t t0 = (vint32m1_t)vsrl_vx_u32m1((vuint32m1_t)a.val, 31, 4); + vint32m1_t m1 = (vint32m1_t){1, 2, 4, 8}; + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m1_t t1 = vmul_vv_i32m1(t0, m1, 4); + res = vredsum_vs_i32m1_i32m1(res, t1, res, 4); + return vmv_x_s_i32m1_i32(res, 4); +} +inline int v_signmask(const v_uint32x4& a) +{ + vint32m1_t t0 = (vint32m1_t)vsrl_vx_u32m1(a.val, 31, 4); + vint32m1_t m1 = (vint32m1_t){1, 2, 4, 8}; + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m1_t t1 = vmul_vv_i32m1(t0, m1, 4); + res = vredsum_vs_i32m1_i32m1(res, t1, res, 4); + return vmv_x_s_i32m1_i32(res, 4); +} +inline int v_signmask(const v_uint64x2& a) +{ + vuint64m1_t v0 = vsrl_vx_u64m1(a.val, 63, 2); + int res = (int)vext_x_v_u64m1_u64(v0, 0, 2) + ((int)vext_x_v_u64m1_u64(v0, 1, 2) << 1); + return res; +} +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +inline int v_signmask(const v_float32x4& a) +{ + vint32m1_t t0 = (vint32m1_t)vsrl_vx_u32m1((vuint32m1_t)a.val, 31, 4); + vint32m1_t m1 = (vint32m1_t){1, 2, 4, 8}; + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m1_t t1 = vmul_vv_i32m1(t0, m1, 4); + res = vredsum_vs_i32m1_i32m1(res, t1, res, 4); + return vmv_x_s_i32m1_i32(res, 4); +} + +inline int v_scan_forward(const v_int8x16& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint8x16& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_int16x8& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint16x8& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_int32x4& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint32x4& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_float32x4& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_int64x2& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint64x2& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } + +#define OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(_Tpvec, suffix, _T, shift, num) \ +inline bool v_check_all(const v_##_Tpvec& a) \ +{ \ + suffix##m1_t v0 = vsrl_vx_##_T(vnot_v_##_T(a.val, num), shift, num); \ + vuint64m1_t v1 = vuint64m1_t(v0); \ + return (v1[0] | v1[1]) == 0; \ +} \ +inline bool v_check_any(const v_##_Tpvec& a) \ +{ \ + suffix##m1_t v0 = vsrl_vx_##_T(a.val, shift, num); \ + vuint64m1_t v1 = vuint64m1_t(v0); \ + return (v1[0] | v1[1]) != 0; \ +} + +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint8x16, vuint8, u8m1, 7, 16) +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint16x8, vuint16, u16m1, 15, 8) +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint32x4, vuint32, u32m1, 31, 4) +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint64x2, vuint64, u64m1, 63, 2) + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } + +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } + +#define OPENCV_HAL_IMPL_RISCVV_SELECT(_Tpvec, suffix, _Tpvec2, num) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vmerge_vvm_##suffix(_Tpvec2(mask.val), b.val, a.val, num)); \ +} + +OPENCV_HAL_IMPL_RISCVV_SELECT(v_int8x16, i8m1, vbool8_t, 16) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_int16x8, i16m1, vbool16_t, 8) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_int32x4, i32m1, vbool32_t, 4) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint8x16, u8m1, vbool8_t, 16) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint16x8, u16m1, vbool16_t, 8) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint32x4, u32m1, vbool32_t, 4) +inline v_float32x4 v_select(const v_float32x4& mask, const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4((vfloat32m1_t)vmerge_vvm_u32m1((vbool32_t)mask.val, (vuint32m1_t)b.val, (vuint32m1_t)a.val, 4)); +} +inline v_float64x2 v_select(const v_float64x2& mask, const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2((vfloat64m1_t)vmerge_vvm_u64m1((vbool64_t)mask.val, (vuint64m1_t)b.val, (vuint64m1_t)a.val, 2)); +} + +#define OPENCV_HAL_IMPL_RISCVV_EXPAND(add, _Tpvec, _Tpwvec, _Tp, _Tp1, num1, _Tp2, num2, _T1, _T2) \ +inline void v_expand(const _Tpvec& a, v_##_Tpwvec& b0, v_##_Tpwvec& b1) \ +{ \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(a.val, vmv_v_x_##_Tp1(0, num1), num1); \ + b0.val = vget_##_Tp2##m2_##_Tp2##m1(b, 0); \ + b1.val = vget_##_Tp2##m2_##_Tp2##m1(b, 1); \ +} \ +inline v_##_Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(a.val, vmv_v_x_##_Tp1(0, num2), num2); \ + return v_##_Tpwvec(vget_##_Tp2##m2_##_Tp2##m1(b, 0)); \ +} \ +inline v_##_Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(a.val, vmv_v_x_##_Tp1(0, num1), num1); \ + return v_##_Tpwvec(vget_##_Tp2##m2_##_Tp2##m1(b, 1)); \ +} \ +inline v_##_Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + _T2##_t val = vle##_v_##_Tp1(ptr, num2); \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(val, vmv_v_x_##_Tp1(0, num2), num2); \ + return v_##_Tpwvec(vget_##_Tp2##m2_##_Tp2##m1(b, 0)); \ +} + +OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint8x16, uint16x8, uchar, u8m1, 16, u16, 8, vuint16m2, vuint8m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint16x8, uint32x4, ushort, u16m1, 8, u32, 4, vuint32m2, vuint16m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint32x4, uint64x2, uint, u32m1, 4, u64, 2, vuint64m2, vuint32m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int8x16, int16x8, schar, i8m1, 16, i16, 8, vint16m2, vint8m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int16x8, int32x4, short, i16m1, 8, i32, 4, vint32m2, vint16m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int32x4, int64x2, int, i32m1, 4, i64, 2, vint64m2, vint32m1) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + vuint16m2_t b = vundefined_u16m2(); + vuint32m2_t c = vundefined_u32m2(); + vuint8m1_t val = vle_v_u8m1(ptr, 4); \ + b = vwaddu_vv_u16m2(val, vmv_v_x_u8m1(0, 4), 4); \ + c = vwaddu_vv_u32m2(vget_u16m2_u16m1(b, 0), vmv_v_x_u16m1(0, 4), 4); \ + return v_uint32x4(vget_u32m2_u32m1(c, 0)); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + vint16m2_t b = vundefined_i16m2(); + vint32m2_t c = vundefined_i32m2(); + vint8m1_t val = vle_v_i8m1(ptr, 4); \ + b = vwadd_vv_i16m2(val, vmv_v_x_i8m1(0, 4), 4); \ + c = vwadd_vv_i32m2(vget_i16m2_i16m1(b, 0), vmv_v_x_i16m1(0, 4), 4); \ + return v_int32x4(vget_i32m2_i32m1(c, 0)); +} +#define VITL_16 (vuint64m2_t){0x1303120211011000, 0x1707160615051404, 0x1B0B1A0A19091808, 0x1F0F1E0E1D0D1C0C} +#define VITL_8 (vuint64m2_t){0x0009000100080000, 0x000B0003000A0002, 0x000D0005000C0004, 0x000F0007000E0006} +#define VITL_4 (vuint64m2_t){0x0000000400000000, 0x0000000500000001, 0x0000000600000002, 0x0000000700000003} +#define VITL_2 (vuint64m2_t){0, 2, 1, 3} +#define LOW_4 0x0000000100000000, 0x0000000500000004 +#define LOW_8 0x0003000200010000, 0x000B000A00090008 +#define LOW_16 0x0706050403020100, 0x1716151413121110 +#define HIGH_4 0x0000000300000002, 0x0000000700000006 +#define HIGH_8 0x0007000600050004, 0x000F000E000D000C +#define HIGH_16 0x0F0E0D0C0B0A0908, 0x1F1E1D1C1B1A1918 +#define OPENCV_HAL_IMPL_RISCVV_UNPACKS(_Tpvec, _Tp, _T, _UTp, _UT, num, num2, len, numh) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + v##_Tp##m2_t tmp = vundefined_##_T##m2();\ + tmp = vset_##_T##m2(tmp, 0, a0.val); \ + tmp = vset_##_T##m2(tmp, 1, a1.val); \ + vuint64m2_t mask = VITL_##num; \ + tmp = (v##_Tp##m2_t)vrgather_vv_##_T##m2((v##_Tp##m2_t)tmp, (v##_UTp##m2_t)mask, num2); \ + b0.val = vget_##_T##m2_##_T##m1(tmp, 0); \ + b1.val = vget_##_T##m2_##_T##m1(tmp, 1); \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + v##_Tp##m1_t b0 = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a.val, b.val, numh, num); \ + return v_##_Tpvec(b0);\ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + v##_Tp##m1_t b0 = vslidedown_vx_##_T##m1(b.val, numh, num); \ + v##_Tp##m1_t a0 = vslidedown_vx_##_T##m1(a.val, numh, num); \ + v##_Tp##m1_t b1 = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a0, b0, numh, num); \ + return v_##_Tpvec(b1);\ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c.val = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a.val, b.val, numh, num); \ + v##_Tp##m1_t b0 = vslidedown_vx_##_T##m1(b.val, numh, num); \ + v##_Tp##m1_t a0 = vslidedown_vx_##_T##m1(a.val, numh, num); \ + d.val = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a0, b0, numh, num); \ +} + +OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint8x16, uint8, u8, uint8, u8, 16, 32, b8, 8) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(int8x16, int8, i8, uint8, u8, 16, 32, b8, 8) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint16x8, uint16, u16, uint16, u16, 8, 16, b16, 4) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(int16x8, int16, i16, uint16, u16, 8, 16, b16, 4) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint32x4, uint32, u32, uint32, u32, 4, 8, b32, 2) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(int32x4, int32, i32, uint32, u32, 4, 8, b32, 2) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(float32x4, float32, f32, uint32, u32, 4, 8, b32, 2) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(float64x2, float64, f64, uint64, u64, 2, 4, b64, 1) + +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + vuint64m1_t mask = (vuint64m1_t){0x08090A0B0C0D0E0F, 0x0001020304050607}; + return v_uint8x16(vrgather_vv_u8m1(a.val, (vuint8m1_t)mask, 16)); +} +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ + vint64m1_t mask = (vint64m1_t){0x08090A0B0C0D0E0F, 0x0001020304050607}; + return v_int8x16(vrgather_vv_i8m1(a.val, (vuint8m1_t)mask, 16)); +} + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + vuint64m1_t mask = (vuint64m1_t){0x0004000500060007, 0x000000100020003}; + return v_uint16x8(vrgather_vv_u16m1(a.val, (vuint16m1_t)mask, 8)); +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ + vint64m1_t mask = (vint64m1_t){0x0004000500060007, 0x000000100020003}; + return v_int16x8(vrgather_vv_i16m1(a.val, (vuint16m1_t)mask, 8)); +} +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + return v_uint32x4(vrgather_vv_u32m1(a.val, (vuint32m1_t){3, 2, 1, 0}, 4)); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ + return v_int32x4(vrgather_vv_i32m1(a.val, (vuint32m1_t){3, 2, 1, 0}, 4)); +} + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + return v_uint64x2(a.val[1], a.val[0]); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ + return v_int64x2(a.val[1], a.val[0]); +} + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ + return v_float64x2(a.val[1], a.val[0]); +} + +#define OPENCV_HAL_IMPL_RISCVV_EXTRACT(_Tpvec, suffix, size) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ return v_rotate_right(a, b);} +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint8x16, u8, 0) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int8x16, s8, 0) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint16x8, u16, 1) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int16x8, s16, 1) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint32x4, u32, 2) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int32x4, s32, 2) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint64x2, u64, 3) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int64x2, s64, 3) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_float32x4, f32, 2) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_float64x2, f64, 3) + + +#define OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(_Tpvec, _Tp, suffix) \ +template inline _Tp v_extract_n(_Tpvec v) { return v.val[i]; } + +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int16x8, short, s16) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint32x4, uint, u32) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int32x4, int, s32) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_float32x4, float, f32) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_float64x2, double, f64) + +#define OPENCV_HAL_IMPL_RISCVV_BROADCAST(_Tpvec, _Tp, num) \ +template inline _Tpvec v_broadcast_element(_Tpvec v) { return _Tpvec(vrgather_vx_##_Tp##m1(v.val, i, num)); } + +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int64x2, i64, 2) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_float32x4, f32, 4) +inline v_int32x4 v_round(const v_float32x4& a) +{ + __builtin_riscv_fsrm(0); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} +inline v_int32x4 v_floor(const v_float32x4& a) +{ + __builtin_riscv_fsrm(2); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + __builtin_riscv_fsrm(3); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ + __builtin_riscv_fsrm(1); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_round(const v_float64x2& a) +{ + __builtin_riscv_fsrm(0); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + //_val = vset_f64m2(_val, 1, a.val); + _val = vset_f64m2(_val, 1, vfmv_v_f_f64m1(0, 2)); + vint32m1_t val = vfncvt_x_f_v_i32m1(_val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + __builtin_riscv_fsrm(0); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + _val = vset_f64m2(_val, 1, b.val); + vint32m1_t val = vfncvt_x_f_v_i32m1(_val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} +inline v_int32x4 v_floor(const v_float64x2& a) +{ + __builtin_riscv_fsrm(2); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)aval, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + __builtin_riscv_fsrm(3); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)aval, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + __builtin_riscv_fsrm(1); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)aval, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +#define OPENCV_HAL_IMPL_RISCVV_LOAD_DEINTERLEAVED(intrin, _Tpvec, num, _Tp, _T) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b) \ +{ \ + v##_Tpvec##m1x2_t ret = intrin##2e_v_##_T##m1x2(ptr, num);\ + a.val = vget_##_T##m1x2_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x2_##_T##m1(ret, 1); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, v_##_Tpvec##x##num& c) \ +{ \ + v##_Tpvec##m1x3_t ret = intrin##3e_v_##_T##m1x3(ptr, num);\ + a.val = vget_##_T##m1x3_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x3_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x3_##_T##m1(ret, 2); \ +}\ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, \ + v_##_Tpvec##x##num& c, v_##_Tpvec##x##num& d) \ +{ \ + v##_Tpvec##m1x4_t ret = intrin##4e_v_##_T##m1x4(ptr, num);\ + a.val = vget_##_T##m1x4_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x4_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x4_##_T##m1(ret, 2); \ + d.val = vget_##_T##m1x4_##_T##m1(ret, 3); \ +} \ + +#define OPENCV_HAL_IMPL_RISCVV_STORE_INTERLEAVED(intrin, _Tpvec, num, _Tp, _T) \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x2_t ret = vundefined_##_T##m1x2(); \ + ret = vset_##_T##m1x2(ret, 0, a.val); \ + ret = vset_##_T##m1x2(ret, 1, b.val); \ + intrin##2e_v_##_T##m1x2(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x3_t ret = vundefined_##_T##m1x3(); \ + ret = vset_##_T##m1x3(ret, 0, a.val); \ + ret = vset_##_T##m1x3(ret, 1, b.val); \ + ret = vset_##_T##m1x3(ret, 2, c.val); \ + intrin##3e_v_##_T##m1x3(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, const v_##_Tpvec##x##num& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + v##_Tpvec##m1x4_t ret = vundefined_##_T##m1x4(); \ + ret = vset_##_T##m1x4(ret, 0, a.val); \ + ret = vset_##_T##m1x4(ret, 1, b.val); \ + ret = vset_##_T##m1x4(ret, 2, c.val); \ + ret = vset_##_T##m1x4(ret, 3, d.val); \ + intrin##4e_v_##_T##m1x4(ptr, ret, num); \ +} + +#define OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(_Tpvec, _Tp, num, ld, st, _T) \ +OPENCV_HAL_IMPL_RISCVV_LOAD_DEINTERLEAVED(ld, _Tpvec, num, _Tp, _T) \ +OPENCV_HAL_IMPL_RISCVV_STORE_INTERLEAVED(st, _Tpvec, num, _Tp, _T) + +//OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint8, uchar, ) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int8, schar, 16, vlseg, vsseg, i8) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int16, short, 8, vlseg, vsseg, i16) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int32, int, 4, vlseg, vsseg, i32) + +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint8, unsigned char, 16, vlseg, vsseg, u8) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint16, unsigned short, 8, vlseg, vsseg, u16) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint32, unsigned int, 4, vlseg, vsseg, u32) + +#define OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(_Tpvec, _Tp, num, _T) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b) \ +{ \ + v##_Tpvec##m1x2_t ret = vlseg2e_v_##_T##m1x2(ptr, num); \ + a.val = vget_##_T##m1x2_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x2_##_T##m1(ret, 1); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, v_##_Tpvec##x##num& c) \ +{ \ + v##_Tpvec##m1x3_t ret = vlseg3e_v_##_T##m1x3(ptr, num); \ + a.val = vget_##_T##m1x3_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x3_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x3_##_T##m1(ret, 2); \ +}\ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, \ + v_##_Tpvec##x##num& c, v_##_Tpvec##x##num& d) \ +{ \ + v##_Tpvec##m1x4_t ret = vlseg4e_v_##_T##m1x4(ptr, num); \ + a.val = vget_##_T##m1x4_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x4_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x4_##_T##m1(ret, 2); \ + d.val = vget_##_T##m1x4_##_T##m1(ret, 3); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x2_t ret = vundefined_##_T##m1x2(); \ + ret = vset_##_T##m1x2(ret, 0, a.val); \ + ret = vset_##_T##m1x2(ret, 1, b.val); \ + vsseg2e_v_##_T##m1x2(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x3_t ret = vundefined_##_T##m1x3(); \ + ret = vset_##_T##m1x3(ret, 0, a.val); \ + ret = vset_##_T##m1x3(ret, 1, b.val); \ + ret = vset_##_T##m1x3(ret, 2, c.val); \ + vsseg3e_v_##_T##m1x3(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, const v_##_Tpvec##x##num& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + v##_Tpvec##m1x4_t ret = vundefined_##_T##m1x4(); \ + ret = vset_##_T##m1x4(ret, 0, a.val); \ + ret = vset_##_T##m1x4(ret, 1, b.val); \ + ret = vset_##_T##m1x4(ret, 2, c.val); \ + ret = vset_##_T##m1x4(ret, 3, d.val); \ + vsseg4e_v_##_T##m1x4(ptr, ret, num); \ +} +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(float32, float, 4, f32) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(float64, double, 2, f64) + +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(uint64, unsigned long, 2, u64) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(int64, long, 2, i64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(vfcvt_f_x_v_f32m1(a.val, 4)); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + return v_float32x4(aval); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + _val = vset_f64m2(_val, 1, b.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 4); + return v_float32x4(aval); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + vfloat32m1_t val = vfcvt_f_x_v_f32m1(a.val, 4); + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 0)); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + vfloat32m1_t val = vfcvt_f_x_v_f32m1(a.val, 4); + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 1)); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(a.val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 0)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(a.val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 1)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ + return v_float64x2(vfcvt_f_x_v_f64m1(a.val, 2)); +} + +#endif +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + vuint64m1_t m0 = {0x0705060403010200, 0x0F0D0E0C0B090A08}; + return v_int8x16(vrgather_vv_i8m1(vec.val, (vuint8m1_t)m0, 16)); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); +} + +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + vuint64m1_t m0 = {0x0703060205010400, 0x0F0B0E0A0D090C08}; + return v_int8x16(vrgather_vv_i8m1(vec.val, (vuint8m1_t)m0, 16)); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); +} + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + vuint64m1_t m0 = {0x0706030205040100, 0x0F0E0B0A0D0C0908}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vec.val, (vuint8m1_t)m0, 16)); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + vuint64m1_t m0 = {0x0B0A030209080100, 0x0F0E07060D0C0504}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + vuint64m1_t m0 = {0x0B0A090803020100, 0x0F0E0D0C07060504}; + return v_int32x4((vint32m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + vuint64m1_t m0 = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + vuint64m1_t m0 = {0x0908050403020100, 0xFFFFFFFF0D0C0B0A}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, + const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ + vint64m2_t v1 = vwmul_vv_i64m2(a.val, b.val, 4); + vfloat64m1_t res = vfcvt_f_x_v_f64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v1, 0), vget_i64m2_i64m1(v1, 1), 2), 2); + return v_float64x2(res); +} +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ v_float64x2 res = v_dotprod_expand_fast(a, b); + return res + c; } +#endif +////// FP16 support /////// +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + vfloat16m1_t v = vle_v_f16m1((__fp16*)ptr, 4); + vfloat32m2_t v32 = vfwcvt_f_f_v_f32m2(v, 4); + return v_float32x4(vget_f32m2_f32m1(v32, 0)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + vfloat32m2_t v32 = vundefined_f32m2(); + v32 = vset_f32m2(v32, 0, v.val); + vfloat16m1_t hv = vfncvt_f_f_v_f16m1(v32, 4); + vse_v_f16m1((__fp16*)ptr, hv, 4); +} + + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_sse.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_sse.hpp new file mode 100644 index 0000000..443ee16 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_sse.hpp @@ -0,0 +1,3467 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_SSE_HPP +#define OPENCV_HAL_SSE_HPP + +#include +#include "opencv2/core/utility.hpp" + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +#define CV_SIMD128_FP16 0 // no native operations with FP16 type. + +namespace cv +{ + +//! @cond IGNORED + +// +// Compilation troubleshooting: +// - MSVC: error C2719: 'a': formal parameter with requested alignment of 16 won't be aligned +// Replace parameter declaration to const reference: +// -v_int32x4 a +// +const v_int32x4& a +// + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + typedef __m128i vector_type; + enum { nlanes = 16 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint8x16() {} + explicit v_uint8x16(__m128i v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + val = _mm_setr_epi8((char)v0, (char)v1, (char)v2, (char)v3, + (char)v4, (char)v5, (char)v6, (char)v7, + (char)v8, (char)v9, (char)v10, (char)v11, + (char)v12, (char)v13, (char)v14, (char)v15); + } + + uchar get0() const + { + return (uchar)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + typedef __m128i vector_type; + enum { nlanes = 16 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int8x16() {} + explicit v_int8x16(__m128i v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + val = _mm_setr_epi8((char)v0, (char)v1, (char)v2, (char)v3, + (char)v4, (char)v5, (char)v6, (char)v7, + (char)v8, (char)v9, (char)v10, (char)v11, + (char)v12, (char)v13, (char)v14, (char)v15); + } + + schar get0() const + { + return (schar)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + typedef __m128i vector_type; + enum { nlanes = 8 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint16x8() {} + explicit v_uint16x8(__m128i v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + val = _mm_setr_epi16((short)v0, (short)v1, (short)v2, (short)v3, + (short)v4, (short)v5, (short)v6, (short)v7); + } + + ushort get0() const + { + return (ushort)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + typedef __m128i vector_type; + enum { nlanes = 8 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int16x8() {} + explicit v_int16x8(__m128i v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + val = _mm_setr_epi16((short)v0, (short)v1, (short)v2, (short)v3, + (short)v4, (short)v5, (short)v6, (short)v7); + } + + short get0() const + { + return (short)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + typedef __m128i vector_type; + enum { nlanes = 4 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint32x4() {} + explicit v_uint32x4(__m128i v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + val = _mm_setr_epi32((int)v0, (int)v1, (int)v2, (int)v3); + } + + unsigned get0() const + { + return (unsigned)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + typedef __m128i vector_type; + enum { nlanes = 4 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int32x4() {} + explicit v_int32x4(__m128i v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + val = _mm_setr_epi32(v0, v1, v2, v3); + } + + int get0() const + { + return _mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + typedef __m128 vector_type; + enum { nlanes = 4 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_float32x4() {} + explicit v_float32x4(__m128 v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + val = _mm_setr_ps(v0, v1, v2, v3); + } + + float get0() const + { + return _mm_cvtss_f32(val); + } + + __m128 val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + typedef __m128i vector_type; + enum { nlanes = 2 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint64x2() {} + explicit v_uint64x2(__m128i v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { +#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__) + val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1); +#elif defined(__GNUC__) + val = _mm_setr_epi64((__m64)v0, (__m64)v1); +#else + val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32)); +#endif + } + + uint64 get0() const + { + #if !defined(__x86_64__) && !defined(_M_X64) + int a = _mm_cvtsi128_si32(val); + int b = _mm_cvtsi128_si32(_mm_srli_epi64(val, 32)); + return (unsigned)a | ((uint64)(unsigned)b << 32); + #else + return (uint64)_mm_cvtsi128_si64(val); + #endif + } + + __m128i val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + typedef __m128i vector_type; + enum { nlanes = 2 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int64x2() {} + explicit v_int64x2(__m128i v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { +#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__) + val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1); +#elif defined(__GNUC__) + val = _mm_setr_epi64((__m64)v0, (__m64)v1); +#else + val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32)); +#endif + } + + int64 get0() const + { + #if !defined(__x86_64__) && !defined(_M_X64) + int a = _mm_cvtsi128_si32(val); + int b = _mm_cvtsi128_si32(_mm_srli_epi64(val, 32)); + return (int64)((unsigned)a | ((uint64)(unsigned)b << 32)); + #else + return _mm_cvtsi128_si64(val); + #endif + } + + __m128i val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + typedef __m128d vector_type; + enum { nlanes = 2 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_float64x2() {} + explicit v_float64x2(__m128d v) : val(v) {} + v_float64x2(double v0, double v1) + { + val = _mm_setr_pd(v0, v1); + } + + double get0() const + { + return _mm_cvtsd_f64(val); + } + + __m128d val; +}; + +namespace hal_sse_internal +{ + template + to_sse_type v_sse_reinterpret_as(const from_sse_type& val); + +#define OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(to_sse_type, from_sse_type, sse_cast_intrin) \ + template<> inline \ + to_sse_type v_sse_reinterpret_as(const from_sse_type& a) \ + { return sse_cast_intrin(a); } + + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128i, __m128i, OPENCV_HAL_NOP) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128i, __m128, _mm_castps_si128) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128i, __m128d, _mm_castpd_si128) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128, __m128i, _mm_castsi128_ps) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128, __m128, OPENCV_HAL_NOP) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128, __m128d, _mm_castpd_ps) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128d, __m128i, _mm_castsi128_pd) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128d, __m128, _mm_castps_pd) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128d, __m128d, OPENCV_HAL_NOP) +} + +#define OPENCV_HAL_IMPL_SSE_INITVEC(_Tpvec, _Tp, suffix, zsuffix, ssuffix, _Tps, cast) \ +inline _Tpvec v_setzero_##suffix() { return _Tpvec(_mm_setzero_##zsuffix()); } \ +inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(_mm_set1_##ssuffix((_Tps)v)); } \ +template inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0& a) \ +{ return _Tpvec(cast(a.val)); } + +OPENCV_HAL_IMPL_SSE_INITVEC(v_uint8x16, uchar, u8, si128, epi8, schar, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_int8x16, schar, s8, si128, epi8, schar, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_uint16x8, ushort, u16, si128, epi16, short, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_int16x8, short, s16, si128, epi16, short, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_uint32x4, unsigned, u32, si128, epi32, int, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_int32x4, int, s32, si128, epi32, int, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_float32x4, float, f32, ps, ps, float, _mm_castsi128_ps) +OPENCV_HAL_IMPL_SSE_INITVEC(v_float64x2, double, f64, pd, pd, double, _mm_castsi128_pd) + +inline v_uint64x2 v_setzero_u64() { return v_uint64x2(_mm_setzero_si128()); } +inline v_int64x2 v_setzero_s64() { return v_int64x2(_mm_setzero_si128()); } +inline v_uint64x2 v_setall_u64(uint64 val) { return v_uint64x2(val, val); } +inline v_int64x2 v_setall_s64(int64 val) { return v_int64x2(val, val); } + +template inline +v_uint64x2 v_reinterpret_as_u64(const _Tpvec& a) { return v_uint64x2(a.val); } +template inline +v_int64x2 v_reinterpret_as_s64(const _Tpvec& a) { return v_int64x2(a.val); } +inline v_float32x4 v_reinterpret_as_f32(const v_uint64x2& a) +{ return v_float32x4(_mm_castsi128_ps(a.val)); } +inline v_float32x4 v_reinterpret_as_f32(const v_int64x2& a) +{ return v_float32x4(_mm_castsi128_ps(a.val)); } +inline v_float64x2 v_reinterpret_as_f64(const v_uint64x2& a) +{ return v_float64x2(_mm_castsi128_pd(a.val)); } +inline v_float64x2 v_reinterpret_as_f64(const v_int64x2& a) +{ return v_float64x2(_mm_castsi128_pd(a.val)); } + +#define OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(_Tpvec, suffix) \ +inline _Tpvec v_reinterpret_as_##suffix(const v_float32x4& a) \ +{ return _Tpvec(_mm_castps_si128(a.val)); } \ +inline _Tpvec v_reinterpret_as_##suffix(const v_float64x2& a) \ +{ return _Tpvec(_mm_castpd_si128(a.val)); } + +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint8x16, u8) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int8x16, s8) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint16x8, u16) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int16x8, s16) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint32x4, u32) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int32x4, s32) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint64x2, u64) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int64x2, s64) + +inline v_float32x4 v_reinterpret_as_f32(const v_float32x4& a) {return a; } +inline v_float64x2 v_reinterpret_as_f64(const v_float64x2& a) {return a; } +inline v_float32x4 v_reinterpret_as_f32(const v_float64x2& a) {return v_float32x4(_mm_castpd_ps(a.val)); } +inline v_float64x2 v_reinterpret_as_f64(const v_float32x4& a) {return v_float64x2(_mm_castps_pd(a.val)); } + +//////////////// PACK /////////////// +inline v_uint8x16 v_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + __m128i delta = _mm_set1_epi16(255); + return v_uint8x16(_mm_packus_epi16(_mm_subs_epu16(a.val, _mm_subs_epu16(a.val, delta)), + _mm_subs_epu16(b.val, _mm_subs_epu16(b.val, delta)))); +} + +inline void v_pack_store(uchar* ptr, const v_uint16x8& a) +{ + __m128i delta = _mm_set1_epi16(255); + __m128i a1 = _mm_subs_epu16(a.val, _mm_subs_epu16(a.val, delta)); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a1, a1)); +} + +inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) +{ return v_uint8x16(_mm_packus_epi16(a.val, b.val)); } + +inline void v_pack_u_store(uchar* ptr, const v_int16x8& a) +{ _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a.val, a.val)); } + +template inline +v_uint8x16 v_rshr_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + return v_uint8x16(_mm_packus_epi16(_mm_srli_epi16(_mm_adds_epu16(a.val, delta), n), + _mm_srli_epi16(_mm_adds_epu16(b.val, delta), n))); +} + +template inline +void v_rshr_pack_store(uchar* ptr, const v_uint16x8& a) +{ + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + __m128i a1 = _mm_srli_epi16(_mm_adds_epu16(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a1, a1)); +} + +template inline +v_uint8x16 v_rshr_pack_u(const v_int16x8& a, const v_int16x8& b) +{ + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + return v_uint8x16(_mm_packus_epi16(_mm_srai_epi16(_mm_adds_epi16(a.val, delta), n), + _mm_srai_epi16(_mm_adds_epi16(b.val, delta), n))); +} + +template inline +void v_rshr_pack_u_store(uchar* ptr, const v_int16x8& a) +{ + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + __m128i a1 = _mm_srai_epi16(_mm_adds_epi16(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a1, a1)); +} + +inline v_int8x16 v_pack(const v_int16x8& a, const v_int16x8& b) +{ return v_int8x16(_mm_packs_epi16(a.val, b.val)); } + +inline void v_pack_store(schar* ptr, const v_int16x8& a) +{ _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi16(a.val, a.val)); } + +template inline +v_int8x16 v_rshr_pack(const v_int16x8& a, const v_int16x8& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + return v_int8x16(_mm_packs_epi16(_mm_srai_epi16(_mm_adds_epi16(a.val, delta), n), + _mm_srai_epi16(_mm_adds_epi16(b.val, delta), n))); +} +template inline +void v_rshr_pack_store(schar* ptr, const v_int16x8& a) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + __m128i a1 = _mm_srai_epi16(_mm_adds_epi16(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi16(a1, a1)); +} + + +// byte-wise "mask ? a : b" +inline __m128i v_select_si128(__m128i mask, __m128i a, __m128i b) +{ +#if CV_SSE4_1 + return _mm_blendv_epi8(b, a, mask); +#else + return _mm_xor_si128(b, _mm_and_si128(_mm_xor_si128(a, b), mask)); +#endif +} + +inline v_uint16x8 v_pack(const v_uint32x4& a, const v_uint32x4& b) +{ return v_uint16x8(_v128_packs_epu32(a.val, b.val)); } + +inline void v_pack_store(ushort* ptr, const v_uint32x4& a) +{ + __m128i z = _mm_setzero_si128(), maxval32 = _mm_set1_epi32(65535), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(v_select_si128(_mm_cmpgt_epi32(z, a.val), maxval32, a.val), delta32); + __m128i r = _mm_packs_epi32(a1, a1); + _mm_storel_epi64((__m128i*)ptr, _mm_sub_epi16(r, _mm_set1_epi16(-32768))); +} + +template inline +v_uint16x8 v_rshr_pack(const v_uint32x4& a, const v_uint32x4& b) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srli_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i b1 = _mm_sub_epi32(_mm_srli_epi32(_mm_add_epi32(b.val, delta), n), delta32); + return v_uint16x8(_mm_sub_epi16(_mm_packs_epi32(a1, b1), _mm_set1_epi16(-32768))); +} + +template inline +void v_rshr_pack_store(ushort* ptr, const v_uint32x4& a) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srli_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + _mm_storel_epi64((__m128i*)ptr, a2); +} + +inline v_uint16x8 v_pack_u(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_uint16x8(_mm_packus_epi32(a.val, b.val)); +#else + __m128i delta32 = _mm_set1_epi32(32768); + + // preliminary saturate negative values to zero + __m128i a1 = _mm_and_si128(a.val, _mm_cmpgt_epi32(a.val, _mm_set1_epi32(0))); + __m128i b1 = _mm_and_si128(b.val, _mm_cmpgt_epi32(b.val, _mm_set1_epi32(0))); + + __m128i r = _mm_packs_epi32(_mm_sub_epi32(a1, delta32), _mm_sub_epi32(b1, delta32)); + return v_uint16x8(_mm_sub_epi16(r, _mm_set1_epi16(-32768))); +#endif +} + +inline void v_pack_u_store(ushort* ptr, const v_int32x4& a) +{ +#if CV_SSE4_1 + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi32(a.val, a.val)); +#else + __m128i delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(a.val, delta32); + __m128i r = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + _mm_storel_epi64((__m128i*)ptr, r); +#endif +} + +template inline +v_uint16x8 v_rshr_pack_u(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + __m128i delta = _mm_set1_epi32(1 << (n - 1)); + return v_uint16x8(_mm_packus_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), + _mm_srai_epi32(_mm_add_epi32(b.val, delta), n))); +#else + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + __m128i b1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(b.val, delta), n), delta32); + __m128i b2 = _mm_sub_epi16(_mm_packs_epi32(b1, b1), _mm_set1_epi16(-32768)); + return v_uint16x8(_mm_unpacklo_epi64(a2, b2)); +#endif +} + +template inline +void v_rshr_pack_u_store(ushort* ptr, const v_int32x4& a) +{ +#if CV_SSE4_1 + __m128i delta = _mm_set1_epi32(1 << (n - 1)); + __m128i a1 = _mm_srai_epi32(_mm_add_epi32(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi32(a1, a1)); +#else + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + _mm_storel_epi64((__m128i*)ptr, a2); +#endif +} + +inline v_int16x8 v_pack(const v_int32x4& a, const v_int32x4& b) +{ return v_int16x8(_mm_packs_epi32(a.val, b.val)); } + +inline void v_pack_store(short* ptr, const v_int32x4& a) +{ + _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi32(a.val, a.val)); +} + +template inline +v_int16x8 v_rshr_pack(const v_int32x4& a, const v_int32x4& b) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)); + return v_int16x8(_mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), + _mm_srai_epi32(_mm_add_epi32(b.val, delta), n))); +} + +template inline +void v_rshr_pack_store(short* ptr, const v_int32x4& a) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)); + __m128i a1 = _mm_srai_epi32(_mm_add_epi32(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi32(a1, a1)); +} + + +// [a0 0 | b0 0] [a1 0 | b1 0] +inline v_uint32x4 v_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + __m128i v0 = _mm_unpacklo_epi32(a.val, b.val); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a.val, b.val); // b0 b1 0 0 + return v_uint32x4(_mm_unpacklo_epi32(v0, v1)); +} + +inline void v_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + __m128i a1 = _mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a1); +} + +// [a0 0 | b0 0] [a1 0 | b1 0] +inline v_int32x4 v_pack(const v_int64x2& a, const v_int64x2& b) +{ + __m128i v0 = _mm_unpacklo_epi32(a.val, b.val); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a.val, b.val); // b0 b1 0 0 + return v_int32x4(_mm_unpacklo_epi32(v0, v1)); +} + +inline void v_pack_store(int* ptr, const v_int64x2& a) +{ + __m128i a1 = _mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a1); +} + +template inline +v_uint32x4 v_rshr_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + uint64 delta = (uint64)1 << (n-1); + v_uint64x2 delta2(delta, delta); + __m128i a1 = _mm_srli_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i b1 = _mm_srli_epi64(_mm_add_epi64(b.val, delta2.val), n); + __m128i v0 = _mm_unpacklo_epi32(a1, b1); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a1, b1); // b0 b1 0 0 + return v_uint32x4(_mm_unpacklo_epi32(v0, v1)); +} + +template inline +void v_rshr_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + uint64 delta = (uint64)1 << (n-1); + v_uint64x2 delta2(delta, delta); + __m128i a1 = _mm_srli_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i a2 = _mm_shuffle_epi32(a1, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a2); +} + +inline __m128i v_sign_epi64(__m128i a) +{ + return _mm_shuffle_epi32(_mm_srai_epi32(a, 31), _MM_SHUFFLE(3, 3, 1, 1)); // x m0 | x m1 +} + +inline __m128i v_srai_epi64(__m128i a, int imm) +{ + __m128i smask = v_sign_epi64(a); + return _mm_xor_si128(_mm_srli_epi64(_mm_xor_si128(a, smask), imm), smask); +} + +template inline +v_int32x4 v_rshr_pack(const v_int64x2& a, const v_int64x2& b) +{ + int64 delta = (int64)1 << (n-1); + v_int64x2 delta2(delta, delta); + __m128i a1 = v_srai_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i b1 = v_srai_epi64(_mm_add_epi64(b.val, delta2.val), n); + __m128i v0 = _mm_unpacklo_epi32(a1, b1); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a1, b1); // b0 b1 0 0 + return v_int32x4(_mm_unpacklo_epi32(v0, v1)); +} + +template inline +void v_rshr_pack_store(int* ptr, const v_int64x2& a) +{ + int64 delta = (int64)1 << (n-1); + v_int64x2 delta2(delta, delta); + __m128i a1 = v_srai_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i a2 = _mm_shuffle_epi32(a1, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a2); +} + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + __m128i ab = _mm_packs_epi16(a.val, b.val); + return v_uint8x16(ab); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + __m128i ab = _mm_packs_epi32(a.val, b.val); + __m128i cd = _mm_packs_epi32(c.val, d.val); + return v_uint8x16(_mm_packs_epi16(ab, cd)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + __m128i ab = _mm_packs_epi32(a.val, b.val); + __m128i cd = _mm_packs_epi32(c.val, d.val); + __m128i ef = _mm_packs_epi32(e.val, f.val); + __m128i gh = _mm_packs_epi32(g.val, h.val); + + __m128i abcd = _mm_packs_epi32(ab, cd); + __m128i efgh = _mm_packs_epi32(ef, gh); + return v_uint8x16(_mm_packs_epi16(abcd, efgh)); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + __m128 v0 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(0, 0, 0, 0)), m0.val); + __m128 v1 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(1, 1, 1, 1)), m1.val); + __m128 v2 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(2, 2, 2, 2)), m2.val); + __m128 v3 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(3, 3, 3, 3)), m3.val); + + return v_float32x4(_mm_add_ps(_mm_add_ps(v0, v1), _mm_add_ps(v2, v3))); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + __m128 v0 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(0, 0, 0, 0)), m0.val); + __m128 v1 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(1, 1, 1, 1)), m1.val); + __m128 v2 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(2, 2, 2, 2)), m2.val); + + return v_float32x4(_mm_add_ps(_mm_add_ps(v0, v1), _mm_add_ps(v2, a.val))); +} + +#define OPENCV_HAL_IMPL_SSE_BIN_OP(bin_op, _Tpvec, intrin) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { \ + return _Tpvec(intrin(a.val, b.val)); \ + } \ + inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ + { \ + a.val = intrin(a.val, b.val); \ + return a; \ + } + +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint8x16, _mm_adds_epu8) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint8x16, _mm_subs_epu8) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int8x16, _mm_adds_epi8) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int8x16, _mm_subs_epi8) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint16x8, _mm_adds_epu16) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint16x8, _mm_subs_epu16) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int16x8, _mm_adds_epi16) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int16x8, _mm_subs_epi16) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint32x4, _mm_add_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint32x4, _mm_sub_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_uint32x4, _v128_mullo_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int32x4, _mm_add_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int32x4, _mm_sub_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_int32x4, _v128_mullo_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_float32x4, _mm_add_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_float32x4, _mm_sub_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_float32x4, _mm_mul_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(/, v_float32x4, _mm_div_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_float64x2, _mm_add_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_float64x2, _mm_sub_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_float64x2, _mm_mul_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(/, v_float64x2, _mm_div_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint64x2, _mm_add_epi64) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint64x2, _mm_sub_epi64) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int64x2, _mm_add_epi64) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int64x2, _mm_sub_epi64) + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_SSE_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_uint16x8, v_uint32x4) +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_int16x8, v_int32x4) + +// Multiply and expand +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + v_uint16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + v_int16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + __m128i v0 = _mm_mullo_epi16(a.val, b.val); + __m128i v1 = _mm_mulhi_epi16(a.val, b.val); + c.val = _mm_unpacklo_epi16(v0, v1); + d.val = _mm_unpackhi_epi16(v0, v1); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + __m128i v0 = _mm_mullo_epi16(a.val, b.val); + __m128i v1 = _mm_mulhi_epu16(a.val, b.val); + c.val = _mm_unpacklo_epi16(v0, v1); + d.val = _mm_unpackhi_epi16(v0, v1); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + __m128i c0 = _mm_mul_epu32(a.val, b.val); + __m128i c1 = _mm_mul_epu32(_mm_srli_epi64(a.val, 32), _mm_srli_epi64(b.val, 32)); + c.val = _mm_unpacklo_epi64(c0, c1); + d.val = _mm_unpackhi_epi64(c0, c1); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) { return v_int16x8(_mm_mulhi_epi16(a.val, b.val)); } +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) { return v_uint16x8(_mm_mulhi_epu16(a.val, b.val)); } + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ return v_int32x4(_mm_madd_epi16(a.val, b.val)); } +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + __m128i even = _mm_mul_epi32(a.val, b.val); + __m128i odd = _mm_mul_epi32(_mm_srli_epi64(a.val, 32), _mm_srli_epi64(b.val, 32)); + return v_int64x2(_mm_add_epi64(even, odd)); +#else + __m128i even_u = _mm_mul_epu32(a.val, b.val); + __m128i odd_u = _mm_mul_epu32(_mm_srli_epi64(a.val, 32), _mm_srli_epi64(b.val, 32)); + // convert unsigned to signed high multiplication (from: Agner Fog(veclib) and H S Warren: Hacker's delight, 2003, p. 132) + __m128i a_sign = _mm_srai_epi32(a.val, 31); + __m128i b_sign = _mm_srai_epi32(b.val, 31); + // |x * sign of x + __m128i axb = _mm_and_si128(a.val, b_sign); + __m128i bxa = _mm_and_si128(b.val, a_sign); + // sum of sign corrections + __m128i ssum = _mm_add_epi32(bxa, axb); + __m128i even_ssum = _mm_slli_epi64(ssum, 32); + __m128i odd_ssum = _mm_and_si128(ssum, _mm_set_epi32(-1, 0, -1, 0)); + // convert to signed and prod + return v_int64x2(_mm_add_epi64(_mm_sub_epi64(even_u, even_ssum), _mm_sub_epi64(odd_u, odd_ssum))); +#endif +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i a0 = _mm_srli_epi16(_mm_slli_si128(a.val, 1), 8); // even + __m128i a1 = _mm_srli_epi16(a.val, 8); // odd + __m128i b0 = _mm_srli_epi16(_mm_slli_si128(b.val, 1), 8); + __m128i b1 = _mm_srli_epi16(b.val, 8); + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_uint32x4(_mm_add_epi32(p0, p1)); +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + __m128i a0 = _mm_srai_epi16(_mm_slli_si128(a.val, 1), 8); // even + __m128i a1 = _mm_srai_epi16(a.val, 8); // odd + __m128i b0 = _mm_srai_epi16(_mm_slli_si128(b.val, 1), 8); + __m128i b1 = _mm_srai_epi16(b.val, 8); + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_int32x4(_mm_add_epi32(p0, p1)); +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 c, d; + v_mul_expand(a, b, c, d); + + v_uint64x2 c0, c1, d0, d1; + v_expand(c, c0, c1); + v_expand(d, d0, d1); + + c0 += c1; d0 += d1; + return v_uint64x2(_mm_add_epi64( + _mm_unpacklo_epi64(c0.val, d0.val), + _mm_unpackhi_epi64(c0.val, d0.val) + )); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return v_int64x2(_mm_add_epi64( + _mm_unpacklo_epi64(c.val, d.val), + _mm_unpackhi_epi64(c.val, d.val) + )); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_cvt_f64(v_dotprod(a, b)); +#else + v_float64x2 c = v_cvt_f64(a) * v_cvt_f64(b); + v_float64x2 d = v_cvt_f64_high(a) * v_cvt_f64_high(b); + + return v_float64x2(_mm_add_pd( + _mm_unpacklo_pd(c.val, d.val), + _mm_unpackhi_pd(c.val, d.val) + )); +#endif +} +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod_fast(a, b) + c; } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i a0 = v_expand_low(a).val; + __m128i a1 = v_expand_high(a).val; + __m128i b0 = v_expand_low(b).val; + __m128i b1 = v_expand_high(b).val; + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_uint32x4(_mm_add_epi32(p0, p1)); +} +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_SSE4_1 + __m128i a0 = _mm_cvtepi8_epi16(a.val); + __m128i a1 = v_expand_high(a).val; + __m128i b0 = _mm_cvtepi8_epi16(b.val); + __m128i b1 = v_expand_high(b).val; + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_int32x4(_mm_add_epi32(p0, p1)); +#else + return v_dotprod_expand(a, b); +#endif +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 c, d; + v_mul_expand(a, b, c, d); + + v_uint64x2 c0, c1, d0, d1; + v_expand(c, c0, c1); + v_expand(d, d0, d1); + + c0 += c1; d0 += d1; + return c0 + d0; +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return c + d; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c); +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_cvt_f64_high(a) * v_cvt_f64_high(b)); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_fma(v_cvt_f64_high(a), v_cvt_f64_high(b), c)); } + +#define OPENCV_HAL_IMPL_SSE_LOGIC_OP(_Tpvec, suffix, not_const) \ + OPENCV_HAL_IMPL_SSE_BIN_OP(&, _Tpvec, _mm_and_##suffix) \ + OPENCV_HAL_IMPL_SSE_BIN_OP(|, _Tpvec, _mm_or_##suffix) \ + OPENCV_HAL_IMPL_SSE_BIN_OP(^, _Tpvec, _mm_xor_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { \ + return _Tpvec(_mm_xor_##suffix(a.val, not_const)); \ + } + +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint8x16, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int8x16, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint16x8, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int16x8, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint32x4, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int32x4, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint64x2, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int64x2, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_float32x4, ps, _mm_castsi128_ps(_mm_set1_epi32(-1))) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_float64x2, pd, _mm_castsi128_pd(_mm_set1_epi32(-1))) + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ return v_float32x4(_mm_sqrt_ps(x.val)); } + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + const __m128 _0_5 = _mm_set1_ps(0.5f), _1_5 = _mm_set1_ps(1.5f); + __m128 t = x.val; + __m128 h = _mm_mul_ps(t, _0_5); + t = _mm_rsqrt_ps(t); + t = _mm_mul_ps(t, _mm_sub_ps(_1_5, _mm_mul_ps(_mm_mul_ps(t, t), h))); + return v_float32x4(t); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ return v_float64x2(_mm_sqrt_pd(x.val)); } + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + const __m128d v_1 = _mm_set1_pd(1.); + return v_float64x2(_mm_div_pd(v_1, _mm_sqrt_pd(x.val))); +} + +#define OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(_Tpuvec, _Tpsvec, func, suffix, subWidth) \ +inline _Tpuvec v_abs(const _Tpsvec& x) \ +{ return _Tpuvec(_mm_##func##_ep##suffix(x.val, _mm_sub_ep##subWidth(_mm_setzero_si128(), x.val))); } + +OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(v_uint8x16, v_int8x16, min, u8, i8) +OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(v_uint16x8, v_int16x8, max, i16, i16) +inline v_uint32x4 v_abs(const v_int32x4& x) +{ + __m128i s = _mm_srli_epi32(x.val, 31); + __m128i f = _mm_srai_epi32(x.val, 31); + return v_uint32x4(_mm_add_epi32(_mm_xor_si128(x.val, f), s)); +} +inline v_float32x4 v_abs(const v_float32x4& x) +{ return v_float32x4(_mm_and_ps(x.val, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)))); } +inline v_float64x2 v_abs(const v_float64x2& x) +{ + return v_float64x2(_mm_and_pd(x.val, + _mm_castsi128_pd(_mm_srli_epi64(_mm_set1_epi32(-1), 1)))); +} + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_SSE_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_min, _mm_min_epu8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_max, _mm_max_epu8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_min, _mm_min_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_max, _mm_max_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float32x4, v_min, _mm_min_ps) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float32x4, v_max, _mm_max_ps) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float64x2, v_min, _mm_min_pd) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float64x2, v_max, _mm_max_pd) + +inline v_int8x16 v_min(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_SSE4_1 + return v_int8x16(_mm_min_epi8(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi8((char)-128); + return v_int8x16(_mm_xor_si128(delta, _mm_min_epu8(_mm_xor_si128(a.val, delta), + _mm_xor_si128(b.val, delta)))); +#endif +} +inline v_int8x16 v_max(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_SSE4_1 + return v_int8x16(_mm_max_epi8(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi8((char)-128); + return v_int8x16(_mm_xor_si128(delta, _mm_max_epu8(_mm_xor_si128(a.val, delta), + _mm_xor_si128(b.val, delta)))); +#endif +} +inline v_uint16x8 v_min(const v_uint16x8& a, const v_uint16x8& b) +{ +#if CV_SSE4_1 + return v_uint16x8(_mm_min_epu16(a.val, b.val)); +#else + return v_uint16x8(_mm_subs_epu16(a.val, _mm_subs_epu16(a.val, b.val))); +#endif +} +inline v_uint16x8 v_max(const v_uint16x8& a, const v_uint16x8& b) +{ +#if CV_SSE4_1 + return v_uint16x8(_mm_max_epu16(a.val, b.val)); +#else + return v_uint16x8(_mm_adds_epu16(_mm_subs_epu16(a.val, b.val), b.val)); +#endif +} +inline v_uint32x4 v_min(const v_uint32x4& a, const v_uint32x4& b) +{ +#if CV_SSE4_1 + return v_uint32x4(_mm_min_epu32(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi32((int)0x80000000); + __m128i mask = _mm_cmpgt_epi32(_mm_xor_si128(a.val, delta), _mm_xor_si128(b.val, delta)); + return v_uint32x4(v_select_si128(mask, b.val, a.val)); +#endif +} +inline v_uint32x4 v_max(const v_uint32x4& a, const v_uint32x4& b) +{ +#if CV_SSE4_1 + return v_uint32x4(_mm_max_epu32(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi32((int)0x80000000); + __m128i mask = _mm_cmpgt_epi32(_mm_xor_si128(a.val, delta), _mm_xor_si128(b.val, delta)); + return v_uint32x4(v_select_si128(mask, a.val, b.val)); +#endif +} +inline v_int32x4 v_min(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_int32x4(_mm_min_epi32(a.val, b.val)); +#else + return v_int32x4(v_select_si128(_mm_cmpgt_epi32(a.val, b.val), b.val, a.val)); +#endif +} +inline v_int32x4 v_max(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_int32x4(_mm_max_epi32(a.val, b.val)); +#else + return v_int32x4(v_select_si128(_mm_cmpgt_epi32(a.val, b.val), a.val, b.val)); +#endif +} + +#define OPENCV_HAL_IMPL_SSE_INT_CMP_OP(_Tpuvec, _Tpsvec, suffix, sbit) \ +inline _Tpuvec operator == (const _Tpuvec& a, const _Tpuvec& b) \ +{ return _Tpuvec(_mm_cmpeq_##suffix(a.val, b.val)); } \ +inline _Tpuvec operator != (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpuvec(_mm_xor_si128(_mm_cmpeq_##suffix(a.val, b.val), not_mask)); \ +} \ +inline _Tpsvec operator == (const _Tpsvec& a, const _Tpsvec& b) \ +{ return _Tpsvec(_mm_cmpeq_##suffix(a.val, b.val)); } \ +inline _Tpsvec operator != (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpsvec(_mm_xor_si128(_mm_cmpeq_##suffix(a.val, b.val), not_mask)); \ +} \ +inline _Tpuvec operator < (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + return _Tpuvec(_mm_cmpgt_##suffix(_mm_xor_si128(b.val, smask), _mm_xor_si128(a.val, smask))); \ +} \ +inline _Tpuvec operator > (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + return _Tpuvec(_mm_cmpgt_##suffix(_mm_xor_si128(a.val, smask), _mm_xor_si128(b.val, smask))); \ +} \ +inline _Tpuvec operator <= (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + __m128i not_mask = _mm_set1_epi32(-1); \ + __m128i res = _mm_cmpgt_##suffix(_mm_xor_si128(a.val, smask), _mm_xor_si128(b.val, smask)); \ + return _Tpuvec(_mm_xor_si128(res, not_mask)); \ +} \ +inline _Tpuvec operator >= (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + __m128i not_mask = _mm_set1_epi32(-1); \ + __m128i res = _mm_cmpgt_##suffix(_mm_xor_si128(b.val, smask), _mm_xor_si128(a.val, smask)); \ + return _Tpuvec(_mm_xor_si128(res, not_mask)); \ +} \ +inline _Tpsvec operator < (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + return _Tpsvec(_mm_cmpgt_##suffix(b.val, a.val)); \ +} \ +inline _Tpsvec operator > (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + return _Tpsvec(_mm_cmpgt_##suffix(a.val, b.val)); \ +} \ +inline _Tpsvec operator <= (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpsvec(_mm_xor_si128(_mm_cmpgt_##suffix(a.val, b.val), not_mask)); \ +} \ +inline _Tpsvec operator >= (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpsvec(_mm_xor_si128(_mm_cmpgt_##suffix(b.val, a.val), not_mask)); \ +} + +OPENCV_HAL_IMPL_SSE_INT_CMP_OP(v_uint8x16, v_int8x16, epi8, (char)-128) +OPENCV_HAL_IMPL_SSE_INT_CMP_OP(v_uint16x8, v_int16x8, epi16, (short)-32768) +OPENCV_HAL_IMPL_SSE_INT_CMP_OP(v_uint32x4, v_int32x4, epi32, (int)0x80000000) + +#define OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(_Tpvec, suffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpeq_##suffix(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpneq_##suffix(a.val, b.val)); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmplt_##suffix(a.val, b.val)); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpgt_##suffix(a.val, b.val)); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmple_##suffix(a.val, b.val)); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpge_##suffix(a.val, b.val)); } + +OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float32x4, ps) +OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float64x2, pd) + +#if CV_SSE4_1 +#define OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(_Tpvec) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpeq_epi64(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return ~(a == b); } +#else +#define OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(_Tpvec) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ __m128i cmp = _mm_cmpeq_epi32(a.val, b.val); \ + return _Tpvec(_mm_and_si128(cmp, _mm_shuffle_epi32(cmp, _MM_SHUFFLE(2, 3, 0, 1)))); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return ~(a == b); } +#endif + +OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_uint64x2) +OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_int64x2) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(_mm_cmpord_ps(a.val, a.val)); } +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(_mm_cmpord_pd(a.val, a.val)); } + +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_add_wrap, _mm_add_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_add_wrap, _mm_add_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_add_wrap, _mm_add_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_add_wrap, _mm_add_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_sub_wrap, _mm_sub_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_sub_wrap, _mm_sub_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_sub_wrap, _mm_sub_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_sub_wrap, _mm_sub_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_mul_wrap, _mm_mullo_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_mul_wrap, _mm_mullo_epi16) + +inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i ad = _mm_srai_epi16(a.val, 8); + __m128i bd = _mm_srai_epi16(b.val, 8); + __m128i p0 = _mm_mullo_epi16(a.val, b.val); // even + __m128i p1 = _mm_slli_epi16(_mm_mullo_epi16(ad, bd), 8); // odd + const __m128i b01 = _mm_set1_epi32(0xFF00FF00); + return v_uint8x16(_v128_blendv_epi8(p0, p1, b01)); +} +inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b) +{ + return v_reinterpret_as_s8(v_mul_wrap(v_reinterpret_as_u8(a), v_reinterpret_as_u8(b))); +} + +/** Absolute difference **/ + +inline v_uint8x16 v_absdiff(const v_uint8x16& a, const v_uint8x16& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x8 v_absdiff(const v_uint16x8& a, const v_uint16x8& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x4 v_absdiff(const v_uint32x4& a, const v_uint32x4& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x16 v_absdiff(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = v_sub_wrap(a, b); + v_int8x16 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} +inline v_uint16x8 v_absdiff(const v_int16x8& a, const v_int16x8& b) +{ + return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); +} +inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b) +{ + v_int32x4 d = a - b; + v_int32x4 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = a - b; + v_int8x16 m = a < b; + return (d ^ m) - m; + } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_max(a, b) - v_min(a, b); } + + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return a * b + c; +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ +#if CV_FMA3 + return v_float32x4(_mm_fmadd_ps(a.val, b.val, c.val)); +#else + return v_float32x4(_mm_add_ps(_mm_mul_ps(a.val, b.val), c.val)); +#endif +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ +#if CV_FMA3 + return v_float64x2(_mm_fmadd_pd(a.val, b.val, c.val)); +#else + return v_float64x2(_mm_add_pd(_mm_mul_pd(a.val, b.val), c.val)); +#endif +} + +#define OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(_Tpvec, _Tp, _Tpreg, suffix, absmask_vec) \ +inline _Tpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpreg absmask = _mm_castsi128_##suffix(absmask_vec); \ + return _Tpvec(_mm_and_##suffix(_mm_sub_##suffix(a.val, b.val), absmask)); \ +} \ +inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpvec res = v_fma(a, a, b*b); \ + return _Tpvec(_mm_sqrt_##suffix(res.val)); \ +} \ +inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return v_fma(a, a, b*b); \ +} \ +inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ \ + return v_fma(a, b, c); \ +} + +OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(v_float32x4, float, __m128, ps, _mm_set1_epi32((int)0x7fffffff)) +OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(v_float64x2, double, __m128d, pd, _mm_srli_epi64(_mm_set1_epi32(-1), 1)) + +#define OPENCV_HAL_IMPL_SSE_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, srai) \ +inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(_mm_srli_##suffix(a.val, imm)); \ +} \ +inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(srai(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shl(const _Tpuvec& a) \ +{ \ + return _Tpuvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shl(const _Tpsvec& a) \ +{ \ + return _Tpsvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shr(const _Tpuvec& a) \ +{ \ + return _Tpuvec(_mm_srli_##suffix(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shr(const _Tpsvec& a) \ +{ \ + return _Tpsvec(srai(a.val, imm)); \ +} + +OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint16x8, v_int16x8, epi16, _mm_srai_epi16) +OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint32x4, v_int32x4, epi32, _mm_srai_epi32) +OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64) + +namespace hal_sse_internal +{ + template 16)), + bool is_first = (imm == 0), + bool is_half = (imm == 8), + bool is_second = (imm == 16), + bool is_other = (((imm > 0) && (imm < 8)) || ((imm > 8) && (imm < 16)))> + class v_sse_palignr_u8_class; + + template + class v_sse_palignr_u8_class; + + template + class v_sse_palignr_u8_class + { + public: + inline __m128i operator()(const __m128i& a, const __m128i&) const + { + return a; + } + }; + + template + class v_sse_palignr_u8_class + { + public: + inline __m128i operator()(const __m128i& a, const __m128i& b) const + { + return _mm_unpacklo_epi64(_mm_unpackhi_epi64(a, a), b); + } + }; + + template + class v_sse_palignr_u8_class + { + public: + inline __m128i operator()(const __m128i&, const __m128i& b) const + { + return b; + } + }; + + template + class v_sse_palignr_u8_class + { +#if CV_SSSE3 + public: + inline __m128i operator()(const __m128i& a, const __m128i& b) const + { + return _mm_alignr_epi8(b, a, imm); + } +#else + public: + inline __m128i operator()(const __m128i& a, const __m128i& b) const + { + enum { imm2 = (sizeof(__m128i) - imm) }; + return _mm_or_si128(_mm_srli_si128(a, imm), _mm_slli_si128(b, imm2)); + } +#endif + }; + + template + inline __m128i v_sse_palignr_u8(const __m128i& a, const __m128i& b) + { + CV_StaticAssert((imm >= 0) && (imm <= 16), "Invalid imm for v_sse_palignr_u8."); + return v_sse_palignr_u8_class()(a, b); + } +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a) +{ + using namespace hal_sse_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + _mm_srli_si128( + v_sse_reinterpret_as<__m128i>(a.val), imm2))); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a) +{ + using namespace hal_sse_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + _mm_slli_si128( + v_sse_reinterpret_as<__m128i>(a.val), imm2))); +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_sse_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + v_sse_palignr_u8( + v_sse_reinterpret_as<__m128i>(a.val), + v_sse_reinterpret_as<__m128i>(b.val)))); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_sse_internal; + enum { imm2 = ((_Tpvec::nlanes - imm) * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + v_sse_palignr_u8( + v_sse_reinterpret_as<__m128i>(b.val), + v_sse_reinterpret_as<__m128i>(a.val)))); +} + +#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(_Tpvec, _Tp) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(_mm_loadu_si128((const __m128i*)ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(_mm_load_si128((const __m128i*)ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(_mm_loadl_epi64((const __m128i*)ptr)); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + return _Tpvec(_mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i*)ptr0), \ + _mm_loadl_epi64((const __m128i*)ptr1))); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storeu_si128((__m128i*)ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ _mm_store_si128((__m128i*)ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ _mm_stream_si128((__m128i*)ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ +{ \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm_storeu_si128((__m128i*)ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm_stream_si128((__m128i*)ptr, a.val); \ + else \ + _mm_store_si128((__m128i*)ptr, a.val); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storel_epi64((__m128i*)ptr, a.val); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storel_epi64((__m128i*)ptr, _mm_unpackhi_epi64(a.val, a.val)); } + +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint8x16, uchar) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int8x16, schar) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint16x8, ushort) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int16x8, short) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint32x4, unsigned) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int32x4, int) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint64x2, uint64) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int64x2, int64) + +#define OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(_mm_loadu_##suffix(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(_mm_load_##suffix(ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(_mm_castsi128_##suffix(_mm_loadl_epi64((const __m128i*)ptr))); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + return _Tpvec(_mm_castsi128_##suffix( \ + _mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i*)ptr0), \ + _mm_loadl_epi64((const __m128i*)ptr1)))); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storeu_##suffix(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ _mm_store_##suffix(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ _mm_stream_##suffix(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ +{ \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm_storeu_##suffix(ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm_stream_##suffix(ptr, a.val); \ + else \ + _mm_store_##suffix(ptr, a.val); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storel_epi64((__m128i*)ptr, _mm_cast##suffix##_si128(a.val)); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + __m128i a1 = _mm_cast##suffix##_si128(a.val); \ + _mm_storel_epi64((__m128i*)ptr, _mm_unpackhi_epi64(a1, a1)); \ +} + +OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps) +OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd) + +inline unsigned v_reduce_sum(const v_uint8x16& a) +{ + __m128i half = _mm_sad_epu8(a.val, _mm_setzero_si128()); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))); +} +inline int v_reduce_sum(const v_int8x16& a) +{ + __m128i half = _mm_set1_epi8((schar)-128); + half = _mm_sad_epu8(_mm_xor_si128(a.val, half), _mm_setzero_si128()); + return _mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))) - 2048; +} +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_16(func) \ +inline schar v_reduce_##func(const v_int8x16& a) \ +{ \ + __m128i val = a.val; \ + __m128i smask = _mm_set1_epi8((schar)-128); \ + val = _mm_xor_si128(val, smask); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,2)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,1)); \ + return (schar)_mm_cvtsi128_si32(val) ^ (schar)-128; \ +} \ +inline uchar v_reduce_##func(const v_uint8x16& a) \ +{ \ + __m128i val = a.val; \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,2)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,1)); \ + return (uchar)_mm_cvtsi128_si32(val); \ +} +OPENCV_HAL_IMPL_SSE_REDUCE_OP_16(max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_16(min) + +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(_Tpvec, scalartype, func, suffix, sbit) \ +inline scalartype v_reduce_##func(const v_##_Tpvec& a) \ +{ \ + __m128i val = a.val; \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,2)); \ + return (scalartype)_mm_cvtsi128_si32(val); \ +} \ +inline unsigned scalartype v_reduce_##func(const v_u##_Tpvec& a) \ +{ \ + __m128i val = a.val; \ + __m128i smask = _mm_set1_epi16(sbit); \ + val = _mm_xor_si128(val, smask); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,2)); \ + return (unsigned scalartype)(_mm_cvtsi128_si32(val) ^ sbit); \ +} +OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, max, epi16, (short)-32768) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, min, epi16, (short)-32768) + +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(_Tpvec, scalartype, regtype, suffix, cast_from, cast_to, extract) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + regtype val = a.val; \ + val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 8))); \ + val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 4))); \ + return (scalartype)_mm_cvt##extract(val); \ +} + +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(_Tpvec, scalartype, func, scalar_func) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + scalartype CV_DECL_ALIGNED(16) buf[4]; \ + v_store_aligned(buf, a); \ + scalartype s0 = scalar_func(buf[0], buf[1]); \ + scalartype s1 = scalar_func(buf[2], buf[3]); \ + return scalar_func(s0, s1); \ +} + +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_uint32x4, unsigned, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_int32x4, int, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_float32x4, float, __m128, ps, _mm_castps_si128, _mm_castsi128_ps, ss_f32) + +inline int v_reduce_sum(const v_int16x8& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } +inline unsigned v_reduce_sum(const v_uint16x8& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ + uint64 CV_DECL_ALIGNED(32) idx[2]; + v_store_aligned(idx, a); + return idx[0] + idx[1]; +} +inline int64 v_reduce_sum(const v_int64x2& a) +{ + int64 CV_DECL_ALIGNED(32) idx[2]; + v_store_aligned(idx, a); + return idx[0] + idx[1]; +} +inline double v_reduce_sum(const v_float64x2& a) +{ + double CV_DECL_ALIGNED(32) idx[2]; + v_store_aligned(idx, a); + return idx[0] + idx[1]; +} + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ +#if CV_SSE3 + __m128 ab = _mm_hadd_ps(a.val, b.val); + __m128 cd = _mm_hadd_ps(c.val, d.val); + return v_float32x4(_mm_hadd_ps(ab, cd)); +#else + __m128 ac = _mm_add_ps(_mm_unpacklo_ps(a.val, c.val), _mm_unpackhi_ps(a.val, c.val)); + __m128 bd = _mm_add_ps(_mm_unpacklo_ps(b.val, d.val), _mm_unpackhi_ps(b.val, d.val)); + return v_float32x4(_mm_add_ps(_mm_unpacklo_ps(ac, bd), _mm_unpackhi_ps(ac, bd))); +#endif +} + +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, max, std::max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, min, std::min) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, max, std::max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, min, std::min) + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i half = _mm_sad_epu8(a.val, b.val); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + __m128i half = _mm_set1_epi8(0x7f); + half = _mm_sad_epu8(_mm_add_epi8(a.val, half), _mm_add_epi8(b.val, half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} + +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ + __m128i m1 = _mm_set1_epi32(0x55555555); + __m128i m2 = _mm_set1_epi32(0x33333333); + __m128i m4 = _mm_set1_epi32(0x0f0f0f0f); + __m128i p = a.val; + p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 1), m1), _mm_and_si128(p, m1)); + p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 2), m2), _mm_and_si128(p, m2)); + p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 4), m4), _mm_and_si128(p, m4)); + return v_uint8x16(p); +} +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v_setall_u16(0x00ff); +} +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v_setall_u32(0x000000ff); +} +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ + return v_uint64x2(_mm_sad_epu8(v_popcount(v_reinterpret_as_u8(a)).val, _mm_setzero_si128())); +} +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_popcount(v_reinterpret_as_u8(a)); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_popcount(v_reinterpret_as_u16(a)); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_popcount(v_reinterpret_as_u32(a)); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_popcount(v_reinterpret_as_u64(a)); } + +#define OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(_Tpvec, suffix, cast_op, allmask) \ +inline int v_signmask(const _Tpvec& a) { return _mm_movemask_##suffix(cast_op(a.val)); } \ +inline bool v_check_all(const _Tpvec& a) { return _mm_movemask_##suffix(cast_op(a.val)) == allmask; } \ +inline bool v_check_any(const _Tpvec& a) { return _mm_movemask_##suffix(cast_op(a.val)) != 0; } +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_uint8x16, epi8, OPENCV_HAL_NOP, 65535) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int8x16, epi8, OPENCV_HAL_NOP, 65535) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_uint32x4, ps, _mm_castsi128_ps, 15) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int32x4, ps, _mm_castsi128_ps, 15) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_uint64x2, pd, _mm_castsi128_pd, 3) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int64x2, pd, _mm_castsi128_pd, 3) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_float32x4, ps, OPENCV_HAL_NOP, 15) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_float64x2, pd, OPENCV_HAL_NOP, 3) + +#define OPENCV_HAL_IMPL_SSE_CHECK_SIGNS_SHORT(_Tpvec) \ +inline int v_signmask(const _Tpvec& a) { return _mm_movemask_epi8(_mm_packs_epi16(a.val, a.val)) & 255; } \ +inline bool v_check_all(const _Tpvec& a) { return (_mm_movemask_epi8(a.val) & 0xaaaa) == 0xaaaa; } \ +inline bool v_check_any(const _Tpvec& a) { return (_mm_movemask_epi8(a.val) & 0xaaaa) != 0; } +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS_SHORT(v_uint16x8) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS_SHORT(v_int16x8) + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } + +#if CV_SSE4_1 +#define OPENCV_HAL_IMPL_SSE_SELECT(_Tpvec, cast_ret, cast, suffix) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(cast_ret(_mm_blendv_##suffix(cast(b.val), cast(a.val), cast(mask.val)))); \ +} + +OPENCV_HAL_IMPL_SSE_SELECT(v_uint8x16, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_int8x16, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint16x8, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_int16x8, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint32x4, _mm_castps_si128, _mm_castsi128_ps, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, _mm_castps_si128, _mm_castsi128_ps, ps) +// OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, TBD, TBD, pd) +// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, TBD, TBD, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, OPENCV_HAL_NOP, OPENCV_HAL_NOP, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, OPENCV_HAL_NOP, OPENCV_HAL_NOP, pd) + +#else // CV_SSE4_1 + +#define OPENCV_HAL_IMPL_SSE_SELECT(_Tpvec, suffix) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(_mm_xor_##suffix(b.val, _mm_and_##suffix(_mm_xor_##suffix(b.val, a.val), mask.val))); \ +} + +OPENCV_HAL_IMPL_SSE_SELECT(v_uint8x16, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_int8x16, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint16x8, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_int16x8, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint32x4, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, si128) +// OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, si128) +// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, pd) +#endif + +/* Expand */ +#define OPENCV_HAL_IMPL_SSE_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ + inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ + { \ + b0.val = intrin(a.val); \ + b1.val = __CV_CAT(intrin, _high)(a.val); \ + } \ + inline _Tpwvec v_expand_low(const _Tpvec& a) \ + { return _Tpwvec(intrin(a.val)); } \ + inline _Tpwvec v_expand_high(const _Tpvec& a) \ + { return _Tpwvec(__CV_CAT(intrin, _high)(a.val)); } \ + inline _Tpwvec v_load_expand(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadl_epi64((const __m128i*)ptr); \ + return _Tpwvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_SSE_EXPAND(v_uint8x16, v_uint16x8, uchar, _v128_cvtepu8_epi16) +OPENCV_HAL_IMPL_SSE_EXPAND(v_int8x16, v_int16x8, schar, _v128_cvtepi8_epi16) +OPENCV_HAL_IMPL_SSE_EXPAND(v_uint16x8, v_uint32x4, ushort, _v128_cvtepu16_epi32) +OPENCV_HAL_IMPL_SSE_EXPAND(v_int16x8, v_int32x4, short, _v128_cvtepi16_epi32) +OPENCV_HAL_IMPL_SSE_EXPAND(v_uint32x4, v_uint64x2, unsigned, _v128_cvtepu32_epi64) +OPENCV_HAL_IMPL_SSE_EXPAND(v_int32x4, v_int64x2, int, _v128_cvtepi32_epi64) + +#define OPENCV_HAL_IMPL_SSE_EXPAND_Q(_Tpvec, _Tp, intrin) \ + inline _Tpvec v_load_expand_q(const _Tp* ptr) \ + { \ + __m128i a = _mm_cvtsi32_si128(*(const int*)ptr); \ + return _Tpvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_SSE_EXPAND_Q(v_uint32x4, uchar, _v128_cvtepu8_epi32) +OPENCV_HAL_IMPL_SSE_EXPAND_Q(v_int32x4, schar, _v128_cvtepi8_epi32) + +#define OPENCV_HAL_IMPL_SSE_UNPACKS(_Tpvec, suffix, cast_from, cast_to) \ +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) \ +{ \ + b0.val = _mm_unpacklo_##suffix(a0.val, a1.val); \ + b1.val = _mm_unpackhi_##suffix(a0.val, a1.val); \ +} \ +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ +{ \ + __m128i a1 = cast_from(a.val), b1 = cast_from(b.val); \ + return _Tpvec(cast_to(_mm_unpacklo_epi64(a1, b1))); \ +} \ +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ +{ \ + __m128i a1 = cast_from(a.val), b1 = cast_from(b.val); \ + return _Tpvec(cast_to(_mm_unpackhi_epi64(a1, b1))); \ +} \ +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) \ +{ \ + __m128i a1 = cast_from(a.val), b1 = cast_from(b.val); \ + c.val = cast_to(_mm_unpacklo_epi64(a1, b1)); \ + d.val = cast_to(_mm_unpackhi_epi64(a1, b1)); \ +} + +OPENCV_HAL_IMPL_SSE_UNPACKS(v_uint8x16, epi8, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_int8x16, epi8, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_uint16x8, epi16, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_int16x8, epi16, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_uint32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_int32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_float32x4, ps, _mm_castps_si128, _mm_castsi128_ps) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_float64x2, pd, _mm_castpd_si128, _mm_castsi128_pd) + +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ +#if CV_SSSE3 + static const __m128i perm = _mm_setr_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); + return v_uint8x16(_mm_shuffle_epi8(a.val, perm)); +#else + uchar CV_DECL_ALIGNED(32) d[16]; + v_store_aligned(d, a); + return v_uint8x16(d[15], d[14], d[13], d[12], d[11], d[10], d[9], d[8], d[7], d[6], d[5], d[4], d[3], d[2], d[1], d[0]); +#endif +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ +#if CV_SSSE3 + static const __m128i perm = _mm_setr_epi8(14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1); + return v_uint16x8(_mm_shuffle_epi8(a.val, perm)); +#else + __m128i r = _mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 1, 2, 3)); + r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(2, 3, 0, 1)); + r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(2, 3, 0, 1)); + return v_uint16x8(r); +#endif +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + return v_uint32x4(_mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 1, 2, 3))); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + return v_uint64x2(_mm_shuffle_epi32(a.val, _MM_SHUFFLE(1, 0, 3, 2))); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +template +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) +{ + return v_rotate_right(a, b); +} + +inline v_int32x4 v_round(const v_float32x4& a) +{ return v_int32x4(_mm_cvtps_epi32(a.val)); } + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + __m128i a1 = _mm_cvtps_epi32(a.val); + __m128i mask = _mm_castps_si128(_mm_cmpgt_ps(_mm_cvtepi32_ps(a1), a.val)); + return v_int32x4(_mm_add_epi32(a1, mask)); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + __m128i a1 = _mm_cvtps_epi32(a.val); + __m128i mask = _mm_castps_si128(_mm_cmpgt_ps(a.val, _mm_cvtepi32_ps(a1))); + return v_int32x4(_mm_sub_epi32(a1, mask)); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(_mm_cvttps_epi32(a.val)); } + +inline v_int32x4 v_round(const v_float64x2& a) +{ return v_int32x4(_mm_cvtpd_epi32(a.val)); } + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + __m128i ai = _mm_cvtpd_epi32(a.val), bi = _mm_cvtpd_epi32(b.val); + return v_int32x4(_mm_unpacklo_epi64(ai, bi)); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + __m128i a1 = _mm_cvtpd_epi32(a.val); + __m128i mask = _mm_castpd_si128(_mm_cmpgt_pd(_mm_cvtepi32_pd(a1), a.val)); + mask = _mm_srli_si128(_mm_slli_si128(mask, 4), 8); // m0 m0 m1 m1 => m0 m1 0 0 + return v_int32x4(_mm_add_epi32(a1, mask)); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + __m128i a1 = _mm_cvtpd_epi32(a.val); + __m128i mask = _mm_castpd_si128(_mm_cmpgt_pd(a.val, _mm_cvtepi32_pd(a1))); + mask = _mm_srli_si128(_mm_slli_si128(mask, 4), 8); // m0 m0 m1 m1 => m0 m1 0 0 + return v_int32x4(_mm_sub_epi32(a1, mask)); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ return v_int32x4(_mm_cvttpd_epi32(a.val)); } + +#define OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(_Tpvec, suffix, cast_from, cast_to) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, \ + _Tpvec& b2, _Tpvec& b3) \ +{ \ + __m128i t0 = cast_from(_mm_unpacklo_##suffix(a0.val, a1.val)); \ + __m128i t1 = cast_from(_mm_unpacklo_##suffix(a2.val, a3.val)); \ + __m128i t2 = cast_from(_mm_unpackhi_##suffix(a0.val, a1.val)); \ + __m128i t3 = cast_from(_mm_unpackhi_##suffix(a2.val, a3.val)); \ +\ + b0.val = cast_to(_mm_unpacklo_epi64(t0, t1)); \ + b1.val = cast_to(_mm_unpackhi_epi64(t0, t1)); \ + b2.val = cast_to(_mm_unpacklo_epi64(t2, t3)); \ + b3.val = cast_to(_mm_unpackhi_epi64(t2, t3)); \ +} + +OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_uint32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_int32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_float32x4, ps, _mm_castps_si128, _mm_castsi128_ps) + +// load deinterleave +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b) +{ + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + + __m128i t10 = _mm_unpacklo_epi8(t00, t01); + __m128i t11 = _mm_unpackhi_epi8(t00, t01); + + __m128i t20 = _mm_unpacklo_epi8(t10, t11); + __m128i t21 = _mm_unpackhi_epi8(t10, t11); + + __m128i t30 = _mm_unpacklo_epi8(t20, t21); + __m128i t31 = _mm_unpackhi_epi8(t20, t21); + + a.val = _mm_unpacklo_epi8(t30, t31); + b.val = _mm_unpackhi_epi8(t30, t31); +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c) +{ +#if CV_SSE4_1 + const __m128i m0 = _mm_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); + const __m128i m1 = _mm_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + __m128i s0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i s1 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + __m128i s2 = _mm_loadu_si128((const __m128i*)(ptr + 32)); + __m128i a0 = _mm_blendv_epi8(_mm_blendv_epi8(s0, s1, m0), s2, m1); + __m128i b0 = _mm_blendv_epi8(_mm_blendv_epi8(s1, s2, m0), s0, m1); + __m128i c0 = _mm_blendv_epi8(_mm_blendv_epi8(s2, s0, m0), s1, m1); + const __m128i sh_b = _mm_setr_epi8(0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13); + const __m128i sh_g = _mm_setr_epi8(1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14); + const __m128i sh_r = _mm_setr_epi8(2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15); + a0 = _mm_shuffle_epi8(a0, sh_b); + b0 = _mm_shuffle_epi8(b0, sh_g); + c0 = _mm_shuffle_epi8(c0, sh_r); + a.val = a0; + b.val = b0; + c.val = c0; +#elif CV_SSSE3 + const __m128i m0 = _mm_setr_epi8(0, 3, 6, 9, 12, 15, 1, 4, 7, 10, 13, 2, 5, 8, 11, 14); + const __m128i m1 = _mm_alignr_epi8(m0, m0, 11); + const __m128i m2 = _mm_alignr_epi8(m0, m0, 6); + + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 32)); + + __m128i s0 = _mm_shuffle_epi8(t0, m0); + __m128i s1 = _mm_shuffle_epi8(t1, m1); + __m128i s2 = _mm_shuffle_epi8(t2, m2); + + t0 = _mm_alignr_epi8(s1, _mm_slli_si128(s0, 10), 5); + a.val = _mm_alignr_epi8(s2, t0, 5); + + t1 = _mm_alignr_epi8(_mm_srli_si128(s1, 5), _mm_slli_si128(s0, 5), 6); + b.val = _mm_alignr_epi8(_mm_srli_si128(s2, 5), t1, 5); + + t2 = _mm_alignr_epi8(_mm_srli_si128(s2, 10), s1, 11); + c.val = _mm_alignr_epi8(t2, s0, 11); +#else + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + __m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 32)); + + __m128i t10 = _mm_unpacklo_epi8(t00, _mm_unpackhi_epi64(t01, t01)); + __m128i t11 = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t00, t00), t02); + __m128i t12 = _mm_unpacklo_epi8(t01, _mm_unpackhi_epi64(t02, t02)); + + __m128i t20 = _mm_unpacklo_epi8(t10, _mm_unpackhi_epi64(t11, t11)); + __m128i t21 = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t10, t10), t12); + __m128i t22 = _mm_unpacklo_epi8(t11, _mm_unpackhi_epi64(t12, t12)); + + __m128i t30 = _mm_unpacklo_epi8(t20, _mm_unpackhi_epi64(t21, t21)); + __m128i t31 = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t20, t20), t22); + __m128i t32 = _mm_unpacklo_epi8(t21, _mm_unpackhi_epi64(t22, t22)); + + a.val = _mm_unpacklo_epi8(t30, _mm_unpackhi_epi64(t31, t31)); + b.val = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t30, t30), t32); + c.val = _mm_unpacklo_epi8(t31, _mm_unpackhi_epi64(t32, t32)); +#endif +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c, v_uint8x16& d) +{ + __m128i u0 = _mm_loadu_si128((const __m128i*)ptr); // a0 b0 c0 d0 a1 b1 c1 d1 ... + __m128i u1 = _mm_loadu_si128((const __m128i*)(ptr + 16)); // a4 b4 c4 d4 ... + __m128i u2 = _mm_loadu_si128((const __m128i*)(ptr + 32)); // a8 b8 c8 d8 ... + __m128i u3 = _mm_loadu_si128((const __m128i*)(ptr + 48)); // a12 b12 c12 d12 ... + + __m128i v0 = _mm_unpacklo_epi8(u0, u2); // a0 a8 b0 b8 ... + __m128i v1 = _mm_unpackhi_epi8(u0, u2); // a2 a10 b2 b10 ... + __m128i v2 = _mm_unpacklo_epi8(u1, u3); // a4 a12 b4 b12 ... + __m128i v3 = _mm_unpackhi_epi8(u1, u3); // a6 a14 b6 b14 ... + + u0 = _mm_unpacklo_epi8(v0, v2); // a0 a4 a8 a12 ... + u1 = _mm_unpacklo_epi8(v1, v3); // a2 a6 a10 a14 ... + u2 = _mm_unpackhi_epi8(v0, v2); // a1 a5 a9 a13 ... + u3 = _mm_unpackhi_epi8(v1, v3); // a3 a7 a11 a15 ... + + v0 = _mm_unpacklo_epi8(u0, u1); // a0 a2 a4 a6 ... + v1 = _mm_unpacklo_epi8(u2, u3); // a1 a3 a5 a7 ... + v2 = _mm_unpackhi_epi8(u0, u1); // c0 c2 c4 c6 ... + v3 = _mm_unpackhi_epi8(u2, u3); // c1 c3 c5 c7 ... + + a.val = _mm_unpacklo_epi8(v0, v1); + b.val = _mm_unpackhi_epi8(v0, v1); + c.val = _mm_unpacklo_epi8(v2, v3); + d.val = _mm_unpackhi_epi8(v2, v3); +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b) +{ + __m128i v0 = _mm_loadu_si128((__m128i*)(ptr)); // a0 b0 a1 b1 a2 b2 a3 b3 + __m128i v1 = _mm_loadu_si128((__m128i*)(ptr + 8)); // a4 b4 a5 b5 a6 b6 a7 b7 + + __m128i v2 = _mm_unpacklo_epi16(v0, v1); // a0 a4 b0 b4 a1 a5 b1 b5 + __m128i v3 = _mm_unpackhi_epi16(v0, v1); // a2 a6 b2 b6 a3 a7 b3 b7 + __m128i v4 = _mm_unpacklo_epi16(v2, v3); // a0 a2 a4 a6 b0 b2 b4 b6 + __m128i v5 = _mm_unpackhi_epi16(v2, v3); // a1 a3 a5 a7 b1 b3 b5 b7 + + a.val = _mm_unpacklo_epi16(v4, v5); // a0 a1 a2 a3 a4 a5 a6 a7 + b.val = _mm_unpackhi_epi16(v4, v5); // b0 b1 ab b3 b4 b5 b6 b7 +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c) +{ +#if CV_SSE4_1 + __m128i v0 = _mm_loadu_si128((__m128i*)(ptr)); + __m128i v1 = _mm_loadu_si128((__m128i*)(ptr + 8)); + __m128i v2 = _mm_loadu_si128((__m128i*)(ptr + 16)); + __m128i a0 = _mm_blend_epi16(_mm_blend_epi16(v0, v1, 0x92), v2, 0x24); + __m128i b0 = _mm_blend_epi16(_mm_blend_epi16(v2, v0, 0x92), v1, 0x24); + __m128i c0 = _mm_blend_epi16(_mm_blend_epi16(v1, v2, 0x92), v0, 0x24); + + const __m128i sh_a = _mm_setr_epi8(0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m128i sh_b = _mm_setr_epi8(2, 3, 8, 9, 14, 15, 4, 5, 10, 11, 0, 1, 6, 7, 12, 13); + const __m128i sh_c = _mm_setr_epi8(4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + a0 = _mm_shuffle_epi8(a0, sh_a); + b0 = _mm_shuffle_epi8(b0, sh_b); + c0 = _mm_shuffle_epi8(c0, sh_c); + + a.val = a0; + b.val = b0; + c.val = c0; +#else + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 8)); + __m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + + __m128i t10 = _mm_unpacklo_epi16(t00, _mm_unpackhi_epi64(t01, t01)); + __m128i t11 = _mm_unpacklo_epi16(_mm_unpackhi_epi64(t00, t00), t02); + __m128i t12 = _mm_unpacklo_epi16(t01, _mm_unpackhi_epi64(t02, t02)); + + __m128i t20 = _mm_unpacklo_epi16(t10, _mm_unpackhi_epi64(t11, t11)); + __m128i t21 = _mm_unpacklo_epi16(_mm_unpackhi_epi64(t10, t10), t12); + __m128i t22 = _mm_unpacklo_epi16(t11, _mm_unpackhi_epi64(t12, t12)); + + a.val = _mm_unpacklo_epi16(t20, _mm_unpackhi_epi64(t21, t21)); + b.val = _mm_unpacklo_epi16(_mm_unpackhi_epi64(t20, t20), t22); + c.val = _mm_unpacklo_epi16(t21, _mm_unpackhi_epi64(t22, t22)); +#endif +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c, v_uint16x8& d) +{ + __m128i u0 = _mm_loadu_si128((const __m128i*)ptr); // a0 b0 c0 d0 a1 b1 c1 d1 + __m128i u1 = _mm_loadu_si128((const __m128i*)(ptr + 8)); // a2 b2 c2 d2 ... + __m128i u2 = _mm_loadu_si128((const __m128i*)(ptr + 16)); // a4 b4 c4 d4 ... + __m128i u3 = _mm_loadu_si128((const __m128i*)(ptr + 24)); // a6 b6 c6 d6 ... + + __m128i v0 = _mm_unpacklo_epi16(u0, u2); // a0 a4 b0 b4 ... + __m128i v1 = _mm_unpackhi_epi16(u0, u2); // a1 a5 b1 b5 ... + __m128i v2 = _mm_unpacklo_epi16(u1, u3); // a2 a6 b2 b6 ... + __m128i v3 = _mm_unpackhi_epi16(u1, u3); // a3 a7 b3 b7 ... + + u0 = _mm_unpacklo_epi16(v0, v2); // a0 a2 a4 a6 ... + u1 = _mm_unpacklo_epi16(v1, v3); // a1 a3 a5 a7 ... + u2 = _mm_unpackhi_epi16(v0, v2); // c0 c2 c4 c6 ... + u3 = _mm_unpackhi_epi16(v1, v3); // c1 c3 c5 c7 ... + + a.val = _mm_unpacklo_epi16(u0, u1); + b.val = _mm_unpackhi_epi16(u0, u1); + c.val = _mm_unpacklo_epi16(u2, u3); + d.val = _mm_unpackhi_epi16(u2, u3); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b) +{ + __m128i v0 = _mm_loadu_si128((__m128i*)(ptr)); // a0 b0 a1 b1 + __m128i v1 = _mm_loadu_si128((__m128i*)(ptr + 4)); // a2 b2 a3 b3 + + __m128i v2 = _mm_unpacklo_epi32(v0, v1); // a0 a2 b0 b2 + __m128i v3 = _mm_unpackhi_epi32(v0, v1); // a1 a3 b1 b3 + + a.val = _mm_unpacklo_epi32(v2, v3); // a0 a1 a2 a3 + b.val = _mm_unpackhi_epi32(v2, v3); // b0 b1 ab b3 +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c) +{ + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 4)); + __m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 8)); + + __m128i t10 = _mm_unpacklo_epi32(t00, _mm_unpackhi_epi64(t01, t01)); + __m128i t11 = _mm_unpacklo_epi32(_mm_unpackhi_epi64(t00, t00), t02); + __m128i t12 = _mm_unpacklo_epi32(t01, _mm_unpackhi_epi64(t02, t02)); + + a.val = _mm_unpacklo_epi32(t10, _mm_unpackhi_epi64(t11, t11)); + b.val = _mm_unpacklo_epi32(_mm_unpackhi_epi64(t10, t10), t12); + c.val = _mm_unpacklo_epi32(t11, _mm_unpackhi_epi64(t12, t12)); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c, v_uint32x4& d) +{ + v_uint32x4 s0(_mm_loadu_si128((const __m128i*)ptr)); // a0 b0 c0 d0 + v_uint32x4 s1(_mm_loadu_si128((const __m128i*)(ptr + 4))); // a1 b1 c1 d1 + v_uint32x4 s2(_mm_loadu_si128((const __m128i*)(ptr + 8))); // a2 b2 c2 d2 + v_uint32x4 s3(_mm_loadu_si128((const __m128i*)(ptr + 12))); // a3 b3 c3 d3 + + v_transpose4x4(s0, s1, s2, s3, a, b, c, d); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b) +{ + __m128 u0 = _mm_loadu_ps(ptr); // a0 b0 a1 b1 + __m128 u1 = _mm_loadu_ps((ptr + 4)); // a2 b2 a3 b3 + + a.val = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(2, 0, 2, 0)); // a0 a1 a2 a3 + b.val = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(3, 1, 3, 1)); // b0 b1 ab b3 +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c) +{ + __m128 t0 = _mm_loadu_ps(ptr + 0); + __m128 t1 = _mm_loadu_ps(ptr + 4); + __m128 t2 = _mm_loadu_ps(ptr + 8); + + __m128 at12 = _mm_shuffle_ps(t1, t2, _MM_SHUFFLE(0, 1, 0, 2)); + a.val = _mm_shuffle_ps(t0, at12, _MM_SHUFFLE(2, 0, 3, 0)); + + __m128 bt01 = _mm_shuffle_ps(t0, t1, _MM_SHUFFLE(0, 0, 0, 1)); + __m128 bt12 = _mm_shuffle_ps(t1, t2, _MM_SHUFFLE(0, 2, 0, 3)); + b.val = _mm_shuffle_ps(bt01, bt12, _MM_SHUFFLE(2, 0, 2, 0)); + + __m128 ct01 = _mm_shuffle_ps(t0, t1, _MM_SHUFFLE(0, 1, 0, 2)); + c.val = _mm_shuffle_ps(ct01, t2, _MM_SHUFFLE(3, 0, 2, 0)); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c, v_float32x4& d) +{ + __m128 t0 = _mm_loadu_ps(ptr + 0); + __m128 t1 = _mm_loadu_ps(ptr + 4); + __m128 t2 = _mm_loadu_ps(ptr + 8); + __m128 t3 = _mm_loadu_ps(ptr + 12); + __m128 t02lo = _mm_unpacklo_ps(t0, t2); + __m128 t13lo = _mm_unpacklo_ps(t1, t3); + __m128 t02hi = _mm_unpackhi_ps(t0, t2); + __m128 t13hi = _mm_unpackhi_ps(t1, t3); + a.val = _mm_unpacklo_ps(t02lo, t13lo); + b.val = _mm_unpackhi_ps(t02lo, t13lo); + c.val = _mm_unpacklo_ps(t02hi, t13hi); + d.val = _mm_unpackhi_ps(t02hi, t13hi); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b) +{ + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2)); + + a = v_uint64x2(_mm_unpacklo_epi64(t0, t1)); + b = v_uint64x2(_mm_unpackhi_epi64(t0, t1)); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b, v_uint64x2& c) +{ + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); // a0, b0 + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2)); // c0, a1 + __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 4)); // b1, c1 + + t1 = _mm_shuffle_epi32(t1, 0x4e); // a1, c0 + + a = v_uint64x2(_mm_unpacklo_epi64(t0, t1)); + b = v_uint64x2(_mm_unpacklo_epi64(_mm_unpackhi_epi64(t0, t0), t2)); + c = v_uint64x2(_mm_unpackhi_epi64(t1, t2)); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, + v_uint64x2& b, v_uint64x2& c, v_uint64x2& d) +{ + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); // a0 b0 + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2)); // c0 d0 + __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 4)); // a1 b1 + __m128i t3 = _mm_loadu_si128((const __m128i*)(ptr + 6)); // c1 d1 + + a = v_uint64x2(_mm_unpacklo_epi64(t0, t2)); + b = v_uint64x2(_mm_unpackhi_epi64(t0, t2)); + c = v_uint64x2(_mm_unpacklo_epi64(t1, t3)); + d = v_uint64x2(_mm_unpackhi_epi64(t1, t3)); +} + +// store interleave + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi8(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi8(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 16), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 16), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 16), v1); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ +#if CV_SSE4_1 + const __m128i sh_a = _mm_setr_epi8(0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5); + const __m128i sh_b = _mm_setr_epi8(5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10); + const __m128i sh_c = _mm_setr_epi8(10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15); + __m128i a0 = _mm_shuffle_epi8(a.val, sh_a); + __m128i b0 = _mm_shuffle_epi8(b.val, sh_b); + __m128i c0 = _mm_shuffle_epi8(c.val, sh_c); + + const __m128i m0 = _mm_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); + const __m128i m1 = _mm_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + __m128i v0 = _mm_blendv_epi8(_mm_blendv_epi8(a0, b0, m1), c0, m0); + __m128i v1 = _mm_blendv_epi8(_mm_blendv_epi8(b0, c0, m1), a0, m0); + __m128i v2 = _mm_blendv_epi8(_mm_blendv_epi8(c0, a0, m1), b0, m0); +#elif CV_SSSE3 + const __m128i m0 = _mm_setr_epi8(0, 6, 11, 1, 7, 12, 2, 8, 13, 3, 9, 14, 4, 10, 15, 5); + const __m128i m1 = _mm_setr_epi8(5, 11, 0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10); + const __m128i m2 = _mm_setr_epi8(10, 0, 5, 11, 1, 6, 12, 2, 7, 13, 3, 8, 14, 4, 9, 15); + + __m128i t0 = _mm_alignr_epi8(b.val, _mm_slli_si128(a.val, 10), 5); + t0 = _mm_alignr_epi8(c.val, t0, 5); + __m128i v0 = _mm_shuffle_epi8(t0, m0); + + __m128i t1 = _mm_alignr_epi8(_mm_srli_si128(b.val, 5), _mm_slli_si128(a.val, 5), 6); + t1 = _mm_alignr_epi8(_mm_srli_si128(c.val, 5), t1, 5); + __m128i v1 = _mm_shuffle_epi8(t1, m1); + + __m128i t2 = _mm_alignr_epi8(_mm_srli_si128(c.val, 10), b.val, 11); + t2 = _mm_alignr_epi8(t2, a.val, 11); + __m128i v2 = _mm_shuffle_epi8(t2, m2); +#else + __m128i z = _mm_setzero_si128(); + __m128i ab0 = _mm_unpacklo_epi8(a.val, b.val); + __m128i ab1 = _mm_unpackhi_epi8(a.val, b.val); + __m128i c0 = _mm_unpacklo_epi8(c.val, z); + __m128i c1 = _mm_unpackhi_epi8(c.val, z); + + __m128i p00 = _mm_unpacklo_epi16(ab0, c0); + __m128i p01 = _mm_unpackhi_epi16(ab0, c0); + __m128i p02 = _mm_unpacklo_epi16(ab1, c1); + __m128i p03 = _mm_unpackhi_epi16(ab1, c1); + + __m128i p10 = _mm_unpacklo_epi32(p00, p01); + __m128i p11 = _mm_unpackhi_epi32(p00, p01); + __m128i p12 = _mm_unpacklo_epi32(p02, p03); + __m128i p13 = _mm_unpackhi_epi32(p02, p03); + + __m128i p20 = _mm_unpacklo_epi64(p10, p11); + __m128i p21 = _mm_unpackhi_epi64(p10, p11); + __m128i p22 = _mm_unpacklo_epi64(p12, p13); + __m128i p23 = _mm_unpackhi_epi64(p12, p13); + + p20 = _mm_slli_si128(p20, 1); + p22 = _mm_slli_si128(p22, 1); + + __m128i p30 = _mm_slli_epi64(_mm_unpacklo_epi32(p20, p21), 8); + __m128i p31 = _mm_srli_epi64(_mm_unpackhi_epi32(p20, p21), 8); + __m128i p32 = _mm_slli_epi64(_mm_unpacklo_epi32(p22, p23), 8); + __m128i p33 = _mm_srli_epi64(_mm_unpackhi_epi32(p22, p23), 8); + + __m128i p40 = _mm_unpacklo_epi64(p30, p31); + __m128i p41 = _mm_unpackhi_epi64(p30, p31); + __m128i p42 = _mm_unpacklo_epi64(p32, p33); + __m128i p43 = _mm_unpackhi_epi64(p32, p33); + + __m128i v0 = _mm_or_si128(_mm_srli_si128(p40, 2), _mm_slli_si128(p41, 10)); + __m128i v1 = _mm_or_si128(_mm_srli_si128(p41, 6), _mm_slli_si128(p42, 6)); + __m128i v2 = _mm_or_si128(_mm_srli_si128(p42, 10), _mm_slli_si128(p43, 2)); +#endif + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 16), v1); + _mm_stream_si128((__m128i*)(ptr + 32), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 16), v1); + _mm_store_si128((__m128i*)(ptr + 32), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 16), v1); + _mm_storeu_si128((__m128i*)(ptr + 32), v2); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, const v_uint8x16& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + __m128i u0 = _mm_unpacklo_epi8(a.val, c.val); // a0 c0 a1 c1 ... + __m128i u1 = _mm_unpackhi_epi8(a.val, c.val); // a8 c8 a9 c9 ... + __m128i u2 = _mm_unpacklo_epi8(b.val, d.val); // b0 d0 b1 d1 ... + __m128i u3 = _mm_unpackhi_epi8(b.val, d.val); // b8 d8 b9 d9 ... + + __m128i v0 = _mm_unpacklo_epi8(u0, u2); // a0 b0 c0 d0 ... + __m128i v1 = _mm_unpackhi_epi8(u0, u2); // a4 b4 c4 d4 ... + __m128i v2 = _mm_unpacklo_epi8(u1, u3); // a8 b8 c8 d8 ... + __m128i v3 = _mm_unpackhi_epi8(u1, u3); // a12 b12 c12 d12 ... + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 16), v1); + _mm_stream_si128((__m128i*)(ptr + 32), v2); + _mm_stream_si128((__m128i*)(ptr + 48), v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 16), v1); + _mm_store_si128((__m128i*)(ptr + 32), v2); + _mm_store_si128((__m128i*)(ptr + 48), v3); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 16), v1); + _mm_storeu_si128((__m128i*)(ptr + 32), v2); + _mm_storeu_si128((__m128i*)(ptr + 48), v3); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi16(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi16(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 8), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 8), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 8), v1); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, + const v_uint16x8& b, const v_uint16x8& c, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ +#if CV_SSE4_1 + const __m128i sh_a = _mm_setr_epi8(0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m128i sh_b = _mm_setr_epi8(10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5); + const __m128i sh_c = _mm_setr_epi8(4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + __m128i a0 = _mm_shuffle_epi8(a.val, sh_a); + __m128i b0 = _mm_shuffle_epi8(b.val, sh_b); + __m128i c0 = _mm_shuffle_epi8(c.val, sh_c); + + __m128i v0 = _mm_blend_epi16(_mm_blend_epi16(a0, b0, 0x92), c0, 0x24); + __m128i v1 = _mm_blend_epi16(_mm_blend_epi16(c0, a0, 0x92), b0, 0x24); + __m128i v2 = _mm_blend_epi16(_mm_blend_epi16(b0, c0, 0x92), a0, 0x24); +#else + __m128i z = _mm_setzero_si128(); + __m128i ab0 = _mm_unpacklo_epi16(a.val, b.val); + __m128i ab1 = _mm_unpackhi_epi16(a.val, b.val); + __m128i c0 = _mm_unpacklo_epi16(c.val, z); + __m128i c1 = _mm_unpackhi_epi16(c.val, z); + + __m128i p10 = _mm_unpacklo_epi32(ab0, c0); + __m128i p11 = _mm_unpackhi_epi32(ab0, c0); + __m128i p12 = _mm_unpacklo_epi32(ab1, c1); + __m128i p13 = _mm_unpackhi_epi32(ab1, c1); + + __m128i p20 = _mm_unpacklo_epi64(p10, p11); + __m128i p21 = _mm_unpackhi_epi64(p10, p11); + __m128i p22 = _mm_unpacklo_epi64(p12, p13); + __m128i p23 = _mm_unpackhi_epi64(p12, p13); + + p20 = _mm_slli_si128(p20, 2); + p22 = _mm_slli_si128(p22, 2); + + __m128i p30 = _mm_unpacklo_epi64(p20, p21); + __m128i p31 = _mm_unpackhi_epi64(p20, p21); + __m128i p32 = _mm_unpacklo_epi64(p22, p23); + __m128i p33 = _mm_unpackhi_epi64(p22, p23); + + __m128i v0 = _mm_or_si128(_mm_srli_si128(p30, 2), _mm_slli_si128(p31, 10)); + __m128i v1 = _mm_or_si128(_mm_srli_si128(p31, 6), _mm_slli_si128(p32, 6)); + __m128i v2 = _mm_or_si128(_mm_srli_si128(p32, 10), _mm_slli_si128(p33, 2)); +#endif + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 8), v1); + _mm_stream_si128((__m128i*)(ptr + 16), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 8), v1); + _mm_store_si128((__m128i*)(ptr + 16), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 8), v1); + _mm_storeu_si128((__m128i*)(ptr + 16), v2); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + const v_uint16x8& c, const v_uint16x8& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + __m128i u0 = _mm_unpacklo_epi16(a.val, c.val); // a0 c0 a1 c1 ... + __m128i u1 = _mm_unpackhi_epi16(a.val, c.val); // a4 c4 a5 c5 ... + __m128i u2 = _mm_unpacklo_epi16(b.val, d.val); // b0 d0 b1 d1 ... + __m128i u3 = _mm_unpackhi_epi16(b.val, d.val); // b4 d4 b5 d5 ... + + __m128i v0 = _mm_unpacklo_epi16(u0, u2); // a0 b0 c0 d0 ... + __m128i v1 = _mm_unpackhi_epi16(u0, u2); // a2 b2 c2 d2 ... + __m128i v2 = _mm_unpacklo_epi16(u1, u3); // a4 b4 c4 d4 ... + __m128i v3 = _mm_unpackhi_epi16(u1, u3); // a6 b6 c6 d6 ... + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 8), v1); + _mm_stream_si128((__m128i*)(ptr + 16), v2); + _mm_stream_si128((__m128i*)(ptr + 24), v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 8), v1); + _mm_store_si128((__m128i*)(ptr + 16), v2); + _mm_store_si128((__m128i*)(ptr + 24), v3); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 8), v1); + _mm_storeu_si128((__m128i*)(ptr + 16), v2); + _mm_storeu_si128((__m128i*)(ptr + 24), v3); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi32(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi32(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 4), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 4), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 4), v1); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + v_uint32x4 z = v_setzero_u32(), u0, u1, u2, u3; + v_transpose4x4(a, b, c, z, u0, u1, u2, u3); + + __m128i v0 = _mm_or_si128(u0.val, _mm_slli_si128(u1.val, 12)); + __m128i v1 = _mm_or_si128(_mm_srli_si128(u1.val, 4), _mm_slli_si128(u2.val, 8)); + __m128i v2 = _mm_or_si128(_mm_srli_si128(u2.val, 8), _mm_slli_si128(u3.val, 4)); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 4), v1); + _mm_stream_si128((__m128i*)(ptr + 8), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 4), v1); + _mm_store_si128((__m128i*)(ptr + 8), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 4), v1); + _mm_storeu_si128((__m128i*)(ptr + 8), v2); + } +} + +inline void v_store_interleave(unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + v_uint32x4 v0, v1, v2, v3; + v_transpose4x4(a, b, c, d, v0, v1, v2, v3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0.val); + _mm_stream_si128((__m128i*)(ptr + 4), v1.val); + _mm_stream_si128((__m128i*)(ptr + 8), v2.val); + _mm_stream_si128((__m128i*)(ptr + 12), v3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0.val); + _mm_store_si128((__m128i*)(ptr + 4), v1.val); + _mm_store_si128((__m128i*)(ptr + 8), v2.val); + _mm_store_si128((__m128i*)(ptr + 12), v3.val); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0.val); + _mm_storeu_si128((__m128i*)(ptr + 4), v1.val); + _mm_storeu_si128((__m128i*)(ptr + 8), v2.val); + _mm_storeu_si128((__m128i*)(ptr + 12), v3.val); + } +} + +// 2-channel, float only +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128 v0 = _mm_unpacklo_ps(a.val, b.val); // a0 b0 a1 b1 + __m128 v1 = _mm_unpackhi_ps(a.val, b.val); // a2 b2 a3 b3 + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_ps(ptr, v0); + _mm_stream_ps(ptr + 4, v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_ps(ptr, v0); + _mm_store_ps(ptr + 4, v1); + } + else + { + _mm_storeu_ps(ptr, v0); + _mm_storeu_ps(ptr + 4, v1); + } +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128 u0 = _mm_shuffle_ps(a.val, b.val, _MM_SHUFFLE(0, 0, 0, 0)); + __m128 u1 = _mm_shuffle_ps(c.val, a.val, _MM_SHUFFLE(1, 1, 0, 0)); + __m128 v0 = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(2, 0, 2, 0)); + __m128 u2 = _mm_shuffle_ps(b.val, c.val, _MM_SHUFFLE(1, 1, 1, 1)); + __m128 u3 = _mm_shuffle_ps(a.val, b.val, _MM_SHUFFLE(2, 2, 2, 2)); + __m128 v1 = _mm_shuffle_ps(u2, u3, _MM_SHUFFLE(2, 0, 2, 0)); + __m128 u4 = _mm_shuffle_ps(c.val, a.val, _MM_SHUFFLE(3, 3, 2, 2)); + __m128 u5 = _mm_shuffle_ps(b.val, c.val, _MM_SHUFFLE(3, 3, 3, 3)); + __m128 v2 = _mm_shuffle_ps(u4, u5, _MM_SHUFFLE(2, 0, 2, 0)); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_ps(ptr, v0); + _mm_stream_ps(ptr + 4, v1); + _mm_stream_ps(ptr + 8, v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_ps(ptr, v0); + _mm_store_ps(ptr + 4, v1); + _mm_store_ps(ptr + 8, v2); + } + else + { + _mm_storeu_ps(ptr, v0); + _mm_storeu_ps(ptr + 4, v1); + _mm_storeu_ps(ptr + 8, v2); + } +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128 u0 = _mm_unpacklo_ps(a.val, c.val); + __m128 u1 = _mm_unpacklo_ps(b.val, d.val); + __m128 u2 = _mm_unpackhi_ps(a.val, c.val); + __m128 u3 = _mm_unpackhi_ps(b.val, d.val); + __m128 v0 = _mm_unpacklo_ps(u0, u1); + __m128 v2 = _mm_unpacklo_ps(u2, u3); + __m128 v1 = _mm_unpackhi_ps(u0, u1); + __m128 v3 = _mm_unpackhi_ps(u2, u3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_ps(ptr, v0); + _mm_stream_ps(ptr + 4, v1); + _mm_stream_ps(ptr + 8, v2); + _mm_stream_ps(ptr + 12, v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_ps(ptr, v0); + _mm_store_ps(ptr + 4, v1); + _mm_store_ps(ptr + 8, v2); + _mm_store_ps(ptr + 12, v3); + } + else + { + _mm_storeu_ps(ptr, v0); + _mm_storeu_ps(ptr + 4, v1); + _mm_storeu_ps(ptr + 8, v2); + _mm_storeu_ps(ptr + 12, v3); + } +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi64(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi64(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 2), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 2), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 2), v1); + } +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi64(a.val, b.val); + __m128i v1 = _mm_unpacklo_epi64(c.val, _mm_unpackhi_epi64(a.val, a.val)); + __m128i v2 = _mm_unpackhi_epi64(b.val, c.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 2), v1); + _mm_stream_si128((__m128i*)(ptr + 4), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 2), v1); + _mm_store_si128((__m128i*)(ptr + 4), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 2), v1); + _mm_storeu_si128((__m128i*)(ptr + 4), v2); + } +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, const v_uint64x2& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi64(a.val, b.val); + __m128i v1 = _mm_unpacklo_epi64(c.val, d.val); + __m128i v2 = _mm_unpackhi_epi64(a.val, b.val); + __m128i v3 = _mm_unpackhi_epi64(c.val, d.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 2), v1); + _mm_stream_si128((__m128i*)(ptr + 4), v2); + _mm_stream_si128((__m128i*)(ptr + 6), v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 2), v1); + _mm_store_si128((__m128i*)(ptr + 4), v2); + _mm_store_si128((__m128i*)(ptr + 6), v3); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 2), v1); + _mm_storeu_si128((__m128i*)(ptr + 4), v2); + _mm_storeu_si128((__m128i*)(ptr + 6), v3); + } +} + +#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int8x16, schar, s8, v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int16x8, short, s16, v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int32x4, int, s32, v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int64x2, int64, s64, v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_float64x2, double, f64, v_uint64x2, uint64, u64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(_mm_cvtepi32_ps(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + return v_float32x4(_mm_cvtpd_ps(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + return v_float32x4(_mm_movelh_ps(_mm_cvtpd_ps(a.val), _mm_cvtpd_ps(b.val))); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + return v_float64x2(_mm_cvtepi32_pd(a.val)); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + return v_float64x2(_mm_cvtepi32_pd(_mm_srli_si128(a.val,8))); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + return v_float64x2(_mm_cvtps_pd(a.val)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + return v_float64x2(_mm_cvtps_pd(_mm_movehl_ps(a.val, a.val))); +} + +// from (Mysticial and wim) https://stackoverflow.com/q/41144668 +inline v_float64x2 v_cvt_f64(const v_int64x2& v) +{ + // constants encoded as floating-point + __m128i magic_i_hi32 = _mm_set1_epi64x(0x4530000080000000); // 2^84 + 2^63 + __m128i magic_i_all = _mm_set1_epi64x(0x4530000080100000); // 2^84 + 2^63 + 2^52 + __m128d magic_d_all = _mm_castsi128_pd(magic_i_all); + // Blend the 32 lowest significant bits of v with magic_int_lo +#if CV_SSE4_1 + __m128i magic_i_lo = _mm_set1_epi64x(0x4330000000000000); // 2^52 + __m128i v_lo = _mm_blend_epi16(v.val, magic_i_lo, 0xcc); +#else + __m128i magic_i_lo = _mm_set1_epi32(0x43300000); // 2^52 + __m128i v_lo = _mm_unpacklo_epi32(_mm_shuffle_epi32(v.val, _MM_SHUFFLE(0, 0, 2, 0)), magic_i_lo); +#endif + // Extract the 32 most significant bits of v + __m128i v_hi = _mm_srli_epi64(v.val, 32); + // Flip the msb of v_hi and blend with 0x45300000 + v_hi = _mm_xor_si128(v_hi, magic_i_hi32); + // Compute in double precision + __m128d v_hi_dbl = _mm_sub_pd(_mm_castsi128_pd(v_hi), magic_d_all); + // (v_hi - magic_d_all) + v_lo Do not assume associativity of floating point addition + __m128d result = _mm_add_pd(v_hi_dbl, _mm_castsi128_pd(v_lo)); + return v_float64x2(result); +} + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int8x16(_mm_setr_epi8(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]])); +#else + return v_int8x16(_mm_setr_epi64( + _mm_setr_pi8(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]]), + _mm_setr_pi8(tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]]) + )); +#endif +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int8x16(_mm_setr_epi16(*(const short*)(tab + idx[0]), *(const short*)(tab + idx[1]), *(const short*)(tab + idx[2]), *(const short*)(tab + idx[3]), + *(const short*)(tab + idx[4]), *(const short*)(tab + idx[5]), *(const short*)(tab + idx[6]), *(const short*)(tab + idx[7]))); +#else + return v_int8x16(_mm_setr_epi64( + _mm_setr_pi16(*(const short*)(tab + idx[0]), *(const short*)(tab + idx[1]), *(const short*)(tab + idx[2]), *(const short*)(tab + idx[3])), + _mm_setr_pi16(*(const short*)(tab + idx[4]), *(const short*)(tab + idx[5]), *(const short*)(tab + idx[6]), *(const short*)(tab + idx[7])) + )); +#endif +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int8x16(_mm_setr_epi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1]), + *(const int*)(tab + idx[2]), *(const int*)(tab + idx[3]))); +#else + return v_int8x16(_mm_setr_epi64( + _mm_setr_pi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1])), + _mm_setr_pi32(*(const int*)(tab + idx[2]), *(const int*)(tab + idx[3])) + )); +#endif +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((const schar *)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int16x8(_mm_setr_epi16(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], + tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]])); +#else + return v_int16x8(_mm_setr_epi64( + _mm_setr_pi16(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]), + _mm_setr_pi16(tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]) + )); +#endif +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int16x8(_mm_setr_epi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1]), + *(const int*)(tab + idx[2]), *(const int*)(tab + idx[3]))); +#else + return v_int16x8(_mm_setr_epi64( + _mm_setr_pi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1])), + _mm_setr_pi32(*(const int*)(tab + idx[2]), *(const int*)(tab + idx[3])) + )); +#endif +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(_mm_set_epi64x(*(const int64_t*)(tab + idx[1]), *(const int64_t*)(tab + idx[0]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((const short *)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((const short *)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((const short *)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int32x4(_mm_setr_epi32(tab[idx[0]], tab[idx[1]], + tab[idx[2]], tab[idx[3]])); +#else + return v_int32x4(_mm_setr_epi64( + _mm_setr_pi32(tab[idx[0]], tab[idx[1]]), + _mm_setr_pi32(tab[idx[2]], tab[idx[3]]) + )); +#endif +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(_mm_set_epi64x(*(const int64_t*)(tab + idx[1]), *(const int64_t*)(tab + idx[0]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(_mm_loadu_si128((const __m128i*)(tab + idx[0]))); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((const int *)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((const int *)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((const int *)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(_mm_set_epi64x(tab[idx[1]], tab[idx[0]])); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(_mm_loadu_si128((const __m128i*)(tab + idx[0]))); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + return v_float32x4(_mm_setr_ps(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]])); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_pairs((const int *)tab, idx)); } +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_quads((const int *)tab, idx)); } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + return v_float64x2(_mm_setr_pd(tab[idx[0]], tab[idx[1]])); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) { return v_float64x2(_mm_castsi128_pd(_mm_loadu_si128((const __m128i*)(tab + idx[0])))); } + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + return v_int32x4(_mm_setr_epi32(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]])); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + return v_float32x4(_mm_setr_ps(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]])); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + int idx[2]; + v_store_low(idx, idxvec); + return v_float64x2(_mm_setr_pd(tab[idx[0]], tab[idx[1]])); +} + +// loads pairs from the table and deinterleaves them, e.g. returns: +// x = (tab[idxvec[0], tab[idxvec[1]], tab[idxvec[2]], tab[idxvec[3]]), +// y = (tab[idxvec[0]+1], tab[idxvec[1]+1], tab[idxvec[2]+1], tab[idxvec[3]+1]) +// note that the indices are float's indices, not the float-pair indices. +// in theory, this function can be used to implement bilinear interpolation, +// when idxvec are the offsets within the image. +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + __m128 z = _mm_setzero_ps(); + __m128 xy01 = _mm_loadl_pi(z, (__m64*)(tab + idx[0])); + __m128 xy23 = _mm_loadl_pi(z, (__m64*)(tab + idx[2])); + xy01 = _mm_loadh_pi(xy01, (__m64*)(tab + idx[1])); + xy23 = _mm_loadh_pi(xy23, (__m64*)(tab + idx[3])); + __m128 xxyy02 = _mm_unpacklo_ps(xy01, xy23); + __m128 xxyy13 = _mm_unpackhi_ps(xy01, xy23); + x = v_float32x4(_mm_unpacklo_ps(xxyy02, xxyy13)); + y = v_float32x4(_mm_unpackhi_ps(xxyy02, xxyy13)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int idx[2]; + v_store_low(idx, idxvec); + __m128d xy0 = _mm_loadu_pd(tab + idx[0]); + __m128d xy1 = _mm_loadu_pd(tab + idx[1]); + x = v_float64x2(_mm_unpacklo_pd(xy0, xy1)); + y = v_float64x2(_mm_unpackhi_pd(xy0, xy1)); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ +#if CV_SSSE3 + return v_int8x16(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0d0e0c0b090a08, 0x0705060403010200))); +#else + __m128i a = _mm_shufflelo_epi16(vec.val, _MM_SHUFFLE(3, 1, 2, 0)); + a = _mm_shufflehi_epi16(a, _MM_SHUFFLE(3, 1, 2, 0)); + a = _mm_shuffle_epi32(a, _MM_SHUFFLE(3, 1, 2, 0)); + return v_int8x16(_mm_unpacklo_epi8(a, _mm_unpackhi_epi64(a, a))); +#endif +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ +#if CV_SSSE3 + return v_int8x16(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0b0e0a0d090c08, 0x0703060205010400))); +#else + __m128i a = _mm_shuffle_epi32(vec.val, _MM_SHUFFLE(3, 1, 2, 0)); + return v_int8x16(_mm_unpacklo_epi8(a, _mm_unpackhi_epi64(a, a))); +#endif +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ +#if CV_SSSE3 + return v_int16x8(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0e0b0a0d0c0908, 0x0706030205040100))); +#else + __m128i a = _mm_shufflelo_epi16(vec.val, _MM_SHUFFLE(3, 1, 2, 0)); + return v_int16x8(_mm_shufflehi_epi16(a, _MM_SHUFFLE(3, 1, 2, 0))); +#endif +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ +#if CV_SSSE3 + return v_int16x8(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0e07060d0c0504, 0x0b0a030209080100))); +#else + return v_int16x8(_mm_unpacklo_epi16(vec.val, _mm_unpackhi_epi64(vec.val, vec.val))); +#endif +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + return v_int32x4(_mm_shuffle_epi32(vec.val, _MM_SHUFFLE(3, 1, 2, 0))); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ +#if CV_SSSE3 + return v_int8x16(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0xffffff0f0e0d0c0a, 0x0908060504020100))); +#else + __m128i mask = _mm_set1_epi64x(0x00000000FFFFFFFF); + __m128i a = _mm_srli_si128(_mm_or_si128(_mm_andnot_si128(mask, vec.val), _mm_and_si128(mask, _mm_sll_epi32(vec.val, _mm_set_epi64x(0, 8)))), 1); + return v_int8x16(_mm_srli_si128(_mm_shufflelo_epi16(a, _MM_SHUFFLE(2, 1, 0, 3)), 2)); +#endif +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ +#if CV_SSSE3 + return v_int16x8(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0xffff0f0e0d0c0b0a, 0x0908050403020100))); +#else + return v_int16x8(_mm_srli_si128(_mm_shufflelo_epi16(vec.val, _MM_SHUFFLE(2, 1, 0, 3)), 2)); +#endif +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +template +inline uchar v_extract_n(const v_uint8x16& v) +{ +#if CV_SSE4_1 + return (uchar)_mm_extract_epi8(v.val, i); +#else + return v_rotate_right(v).get0(); +#endif +} + +template +inline schar v_extract_n(const v_int8x16& v) +{ + return (schar)v_extract_n(v_reinterpret_as_u8(v)); +} + +template +inline ushort v_extract_n(const v_uint16x8& v) +{ + return (ushort)_mm_extract_epi16(v.val, i); +} + +template +inline short v_extract_n(const v_int16x8& v) +{ + return (short)v_extract_n(v_reinterpret_as_u16(v)); +} + +template +inline uint v_extract_n(const v_uint32x4& v) +{ +#if CV_SSE4_1 + return (uint)_mm_extract_epi32(v.val, i); +#else + return v_rotate_right(v).get0(); +#endif +} + +template +inline int v_extract_n(const v_int32x4& v) +{ + return (int)v_extract_n(v_reinterpret_as_u32(v)); +} + +template +inline uint64 v_extract_n(const v_uint64x2& v) +{ +#ifdef CV__SIMD_NATIVE_mm_extract_epi64 + return (uint64)_v128_extract_epi64(v.val); +#else + return v_rotate_right(v).get0(); +#endif +} + +template +inline int64 v_extract_n(const v_int64x2& v) +{ + return (int64)v_extract_n(v_reinterpret_as_u64(v)); +} + +template +inline float v_extract_n(const v_float32x4& v) +{ + union { uint iv; float fv; } d; + d.iv = v_extract_n(v_reinterpret_as_u32(v)); + return d.fv; +} + +template +inline double v_extract_n(const v_float64x2& v) +{ + union { uint64 iv; double dv; } d; + d.iv = v_extract_n(v_reinterpret_as_u64(v)); + return d.dv; +} + +template +inline v_int32x4 v_broadcast_element(const v_int32x4& v) +{ + return v_int32x4(_mm_shuffle_epi32(v.val, _MM_SHUFFLE(i,i,i,i))); +} + +template +inline v_uint32x4 v_broadcast_element(const v_uint32x4& v) +{ + return v_uint32x4(_mm_shuffle_epi32(v.val, _MM_SHUFFLE(i,i,i,i))); +} + +template +inline v_float32x4 v_broadcast_element(const v_float32x4& v) +{ + return v_float32x4(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE((char)i,(char)i,(char)i,(char)i))); +} + +////////////// FP16 support /////////////////////////// + +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ +#if CV_FP16 + return v_float32x4(_mm_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr))); +#else + const __m128i z = _mm_setzero_si128(), delta = _mm_set1_epi32(0x38000000); + const __m128i signmask = _mm_set1_epi32(0x80000000), maxexp = _mm_set1_epi32(0x7c000000); + const __m128 deltaf = _mm_castsi128_ps(_mm_set1_epi32(0x38800000)); + __m128i bits = _mm_unpacklo_epi16(z, _mm_loadl_epi64((const __m128i*)ptr)); // h << 16 + __m128i e = _mm_and_si128(bits, maxexp), sign = _mm_and_si128(bits, signmask); + __m128i t = _mm_add_epi32(_mm_srli_epi32(_mm_xor_si128(bits, sign), 3), delta); // ((h & 0x7fff) << 13) + delta + __m128i zt = _mm_castps_si128(_mm_sub_ps(_mm_castsi128_ps(_mm_add_epi32(t, _mm_set1_epi32(1 << 23))), deltaf)); + + t = _mm_add_epi32(t, _mm_and_si128(delta, _mm_cmpeq_epi32(maxexp, e))); + __m128i zmask = _mm_cmpeq_epi32(e, z); + __m128i ft = v_select_si128(zmask, zt, t); + return v_float32x4(_mm_castsi128_ps(_mm_or_si128(ft, sign))); +#endif +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ +#if CV_FP16 + __m128i fp16_value = _mm_cvtps_ph(v.val, 0); + _mm_storel_epi64((__m128i*)ptr, fp16_value); +#else + const __m128i signmask = _mm_set1_epi32(0x80000000); + const __m128i rval = _mm_set1_epi32(0x3f000000); + + __m128i t = _mm_castps_si128(v.val); + __m128i sign = _mm_srai_epi32(_mm_and_si128(t, signmask), 16); + t = _mm_andnot_si128(signmask, t); + + __m128i finitemask = _mm_cmpgt_epi32(_mm_set1_epi32(0x47800000), t); + __m128i isnan = _mm_cmpgt_epi32(t, _mm_set1_epi32(0x7f800000)); + __m128i naninf = v_select_si128(isnan, _mm_set1_epi32(0x7e00), _mm_set1_epi32(0x7c00)); + __m128i tinymask = _mm_cmpgt_epi32(_mm_set1_epi32(0x38800000), t); + __m128i tt = _mm_castps_si128(_mm_add_ps(_mm_castsi128_ps(t), _mm_castsi128_ps(rval))); + tt = _mm_sub_epi32(tt, rval); + __m128i odd = _mm_and_si128(_mm_srli_epi32(t, 13), _mm_set1_epi32(1)); + __m128i nt = _mm_add_epi32(t, _mm_set1_epi32(0xc8000fff)); + nt = _mm_srli_epi32(_mm_add_epi32(nt, odd), 13); + t = v_select_si128(tinymask, tt, nt); + t = v_select_si128(finitemask, t, naninf); + t = _mm_or_si128(t, sign); + t = _mm_packs_epi32(t, t); + _mm_storel_epi64((__m128i*)ptr, t); +#endif +} + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_sse_em.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_sse_em.hpp new file mode 100644 index 0000000..6fb0881 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_sse_em.hpp @@ -0,0 +1,180 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_INTRIN_SSE_EM_HPP +#define OPENCV_HAL_INTRIN_SSE_EM_HPP + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define OPENCV_HAL_SSE_WRAP_1(fun, tp) \ + inline tp _v128_##fun(const tp& a) \ + { return _mm_##fun(a); } + +#define OPENCV_HAL_SSE_WRAP_2(fun, tp) \ + inline tp _v128_##fun(const tp& a, const tp& b) \ + { return _mm_##fun(a, b); } + +#define OPENCV_HAL_SSE_WRAP_3(fun, tp) \ + inline tp _v128_##fun(const tp& a, const tp& b, const tp& c) \ + { return _mm_##fun(a, b, c); } + +///////////////////////////// XOP ///////////////////////////// + +// [todo] define CV_XOP +#if 1 // CV_XOP +inline __m128i _v128_comgt_epu32(const __m128i& a, const __m128i& b) +{ + const __m128i delta = _mm_set1_epi32((int)0x80000000); + return _mm_cmpgt_epi32(_mm_xor_si128(a, delta), _mm_xor_si128(b, delta)); +} +// wrapping XOP +#else +OPENCV_HAL_SSE_WRAP_2(_v128_comgt_epu32, __m128i) +#endif // !CV_XOP + +///////////////////////////// SSE4.1 ///////////////////////////// + +#if !CV_SSE4_1 + +/** Swizzle **/ +inline __m128i _v128_blendv_epi8(const __m128i& a, const __m128i& b, const __m128i& mask) +{ return _mm_xor_si128(a, _mm_and_si128(_mm_xor_si128(b, a), mask)); } + +/** Convert **/ +// 8 >> 16 +inline __m128i _v128_cvtepu8_epi16(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi8(a, z); +} +inline __m128i _v128_cvtepi8_epi16(const __m128i& a) +{ return _mm_srai_epi16(_mm_unpacklo_epi8(a, a), 8); } +// 8 >> 32 +inline __m128i _v128_cvtepu8_epi32(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi16(_mm_unpacklo_epi8(a, z), z); +} +inline __m128i _v128_cvtepi8_epi32(const __m128i& a) +{ + __m128i r = _mm_unpacklo_epi8(a, a); + r = _mm_unpacklo_epi8(r, r); + return _mm_srai_epi32(r, 24); +} +// 16 >> 32 +inline __m128i _v128_cvtepu16_epi32(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi16(a, z); +} +inline __m128i _v128_cvtepi16_epi32(const __m128i& a) +{ return _mm_srai_epi32(_mm_unpacklo_epi16(a, a), 16); } +// 32 >> 64 +inline __m128i _v128_cvtepu32_epi64(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi32(a, z); +} +inline __m128i _v128_cvtepi32_epi64(const __m128i& a) +{ return _mm_unpacklo_epi32(a, _mm_srai_epi32(a, 31)); } + +/** Arithmetic **/ +inline __m128i _v128_mullo_epi32(const __m128i& a, const __m128i& b) +{ + __m128i c0 = _mm_mul_epu32(a, b); + __m128i c1 = _mm_mul_epu32(_mm_srli_epi64(a, 32), _mm_srli_epi64(b, 32)); + __m128i d0 = _mm_unpacklo_epi32(c0, c1); + __m128i d1 = _mm_unpackhi_epi32(c0, c1); + return _mm_unpacklo_epi64(d0, d1); +} + +/** Math **/ +inline __m128i _v128_min_epu32(const __m128i& a, const __m128i& b) +{ return _v128_blendv_epi8(a, b, _v128_comgt_epu32(a, b)); } + +// wrapping SSE4.1 +#else +OPENCV_HAL_SSE_WRAP_1(cvtepu8_epi16, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi8_epi16, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepu8_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi8_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepu16_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi16_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepu32_epi64, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi32_epi64, __m128i) +OPENCV_HAL_SSE_WRAP_2(min_epu32, __m128i) +OPENCV_HAL_SSE_WRAP_2(mullo_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_3(blendv_epi8, __m128i) +#endif // !CV_SSE4_1 + +///////////////////////////// Revolutionary ///////////////////////////// + +/** Convert **/ +// 16 << 8 +inline __m128i _v128_cvtepu8_epi16_high(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpackhi_epi8(a, z); +} +inline __m128i _v128_cvtepi8_epi16_high(const __m128i& a) +{ return _mm_srai_epi16(_mm_unpackhi_epi8(a, a), 8); } +// 32 << 16 +inline __m128i _v128_cvtepu16_epi32_high(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpackhi_epi16(a, z); +} +inline __m128i _v128_cvtepi16_epi32_high(const __m128i& a) +{ return _mm_srai_epi32(_mm_unpackhi_epi16(a, a), 16); } +// 64 << 32 +inline __m128i _v128_cvtepu32_epi64_high(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpackhi_epi32(a, z); +} +inline __m128i _v128_cvtepi32_epi64_high(const __m128i& a) +{ return _mm_unpackhi_epi32(a, _mm_srai_epi32(a, 31)); } + +/** Miscellaneous **/ +inline __m128i _v128_packs_epu32(const __m128i& a, const __m128i& b) +{ + const __m128i m = _mm_set1_epi32(65535); + __m128i am = _v128_min_epu32(a, m); + __m128i bm = _v128_min_epu32(b, m); +#if CV_SSE4_1 + return _mm_packus_epi32(am, bm); +#else + const __m128i d = _mm_set1_epi32(32768), nd = _mm_set1_epi16(-32768); + am = _mm_sub_epi32(am, d); + bm = _mm_sub_epi32(bm, d); + am = _mm_packs_epi32(am, bm); + return _mm_sub_epi16(am, nd); +#endif +} + +template +inline int64 _v128_extract_epi64(const __m128i& a) +{ +#if defined(CV__SIMD_HAVE_mm_extract_epi64) || (CV_SSE4_1 && (defined(__x86_64__)/*GCC*/ || defined(_M_X64)/*MSVC*/)) +#define CV__SIMD_NATIVE_mm_extract_epi64 1 + return _mm_extract_epi64(a, i); +#else + CV_DECL_ALIGNED(16) int64 tmp[2]; + _mm_store_si128((__m128i*)tmp, a); + return tmp[i]; +#endif +} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: + +#endif // OPENCV_HAL_INTRIN_SSE_EM_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_vsx.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_vsx.hpp new file mode 100644 index 0000000..b198643 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_vsx.hpp @@ -0,0 +1,1608 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_VSX_HPP +#define OPENCV_HAL_VSX_HPP + +#include +#include "opencv2/core/utility.hpp" + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + vec_uchar16 val; + + explicit v_uint8x16(const vec_uchar16& v) : val(v) + {} + v_uint8x16() + {} + v_uint8x16(vec_bchar16 v) : val(vec_uchar16_c(v)) + {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + : val(vec_uchar16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)) + {} + + static inline v_uint8x16 zero() { return v_uint8x16(vec_uchar16_z); } + + uchar get0() const + { return vec_extract(val, 0); } +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + vec_char16 val; + + explicit v_int8x16(const vec_char16& v) : val(v) + {} + v_int8x16() + {} + v_int8x16(vec_bchar16 v) : val(vec_char16_c(v)) + {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + : val(vec_char16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)) + {} + + static inline v_int8x16 zero() { return v_int8x16(vec_char16_z); } + + schar get0() const + { return vec_extract(val, 0); } +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + vec_ushort8 val; + + explicit v_uint16x8(const vec_ushort8& v) : val(v) + {} + v_uint16x8() + {} + v_uint16x8(vec_bshort8 v) : val(vec_ushort8_c(v)) + {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + : val(vec_ushort8_set(v0, v1, v2, v3, v4, v5, v6, v7)) + {} + + static inline v_uint16x8 zero() { return v_uint16x8(vec_ushort8_z); } + + ushort get0() const + { return vec_extract(val, 0); } +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + vec_short8 val; + + explicit v_int16x8(const vec_short8& v) : val(v) + {} + v_int16x8() + {} + v_int16x8(vec_bshort8 v) : val(vec_short8_c(v)) + {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + : val(vec_short8_set(v0, v1, v2, v3, v4, v5, v6, v7)) + {} + + static inline v_int16x8 zero() { return v_int16x8(vec_short8_z); } + + short get0() const + { return vec_extract(val, 0); } +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + vec_uint4 val; + + explicit v_uint32x4(const vec_uint4& v) : val(v) + {} + v_uint32x4() + {} + v_uint32x4(vec_bint4 v) : val(vec_uint4_c(v)) + {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) : val(vec_uint4_set(v0, v1, v2, v3)) + {} + + static inline v_uint32x4 zero() { return v_uint32x4(vec_uint4_z); } + + uint get0() const + { return vec_extract(val, 0); } +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + vec_int4 val; + + explicit v_int32x4(const vec_int4& v) : val(v) + {} + v_int32x4() + {} + v_int32x4(vec_bint4 v) : val(vec_int4_c(v)) + {} + v_int32x4(int v0, int v1, int v2, int v3) : val(vec_int4_set(v0, v1, v2, v3)) + {} + + static inline v_int32x4 zero() { return v_int32x4(vec_int4_z); } + + int get0() const + { return vec_extract(val, 0); } +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + vec_float4 val; + + explicit v_float32x4(const vec_float4& v) : val(v) + {} + v_float32x4() + {} + v_float32x4(vec_bint4 v) : val(vec_float4_c(v)) + {} + v_float32x4(float v0, float v1, float v2, float v3) : val(vec_float4_set(v0, v1, v2, v3)) + {} + + static inline v_float32x4 zero() { return v_float32x4(vec_float4_z); } + + float get0() const + { return vec_extract(val, 0); } +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + vec_udword2 val; + + explicit v_uint64x2(const vec_udword2& v) : val(v) + {} + v_uint64x2() + {} + v_uint64x2(vec_bdword2 v) : val(vec_udword2_c(v)) + {} + v_uint64x2(uint64 v0, uint64 v1) : val(vec_udword2_set(v0, v1)) + {} + + static inline v_uint64x2 zero() { return v_uint64x2(vec_udword2_z); } + + uint64 get0() const + { return vec_extract(val, 0); } +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + vec_dword2 val; + + explicit v_int64x2(const vec_dword2& v) : val(v) + {} + v_int64x2() + {} + v_int64x2(vec_bdword2 v) : val(vec_dword2_c(v)) + {} + v_int64x2(int64 v0, int64 v1) : val(vec_dword2_set(v0, v1)) + {} + + static inline v_int64x2 zero() { return v_int64x2(vec_dword2_z); } + + int64 get0() const + { return vec_extract(val, 0); } +}; + +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + vec_double2 val; + + explicit v_float64x2(const vec_double2& v) : val(v) + {} + v_float64x2() + {} + v_float64x2(vec_bdword2 v) : val(vec_double2_c(v)) + {} + v_float64x2(double v0, double v1) : val(vec_double2_set(v0, v1)) + {} + + static inline v_float64x2 zero() { return v_float64x2(vec_double2_z); } + + double get0() const + { return vec_extract(val, 0); } +}; + +#define OPENCV_HAL_IMPL_VSX_EXTRACT_N(_Tpvec, _Tp) \ +template inline _Tp v_extract_n(VSX_UNUSED(_Tpvec v)) { return vec_extract(v.val, i); } + +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint8x16, uchar) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int8x16, schar) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint16x8, ushort) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int16x8, short) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint32x4, uint) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int32x4, int) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint64x2, uint64) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int64x2, int64) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float32x4, float) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double) + +//////////////// Load and store operations /////////////// + +/* + * clang-5 aborted during parse "vec_xxx_c" only if it's + * inside a function template which is defined by preprocessor macro. + * + * if vec_xxx_c defined as C++ cast, clang-5 will pass it +*/ +#define OPENCV_HAL_IMPL_VSX_INITVEC(_Tpvec, _Tp, suffix, cast) \ +inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); } \ +inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));} \ +template inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a) \ +{ return _Tpvec((cast)a.val); } + +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint8x16, uchar, u8, vec_uchar16) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int8x16, schar, s8, vec_char16) +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint16x8, ushort, u16, vec_ushort8) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int16x8, short, s16, vec_short8) +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint32x4, uint, u32, vec_uint4) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int32x4, int, s32, vec_int4) +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint64x2, uint64, u64, vec_udword2) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int64x2, int64, s64, vec_dword2) +OPENCV_HAL_IMPL_VSX_INITVEC(v_float32x4, float, f32, vec_float4) +OPENCV_HAL_IMPL_VSX_INITVEC(v_float64x2, double, f64, vec_double2) + +#define OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, ld, ld_a, st, st_a) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(ld(0, ptr)); } \ +inline _Tpvec v_load_aligned(VSX_UNUSED(const _Tp* ptr)) \ +{ return _Tpvec(ld_a(0, ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(vec_ld_l8(ptr)); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ return _Tpvec(vec_mergesqh(vec_ld_l8(ptr0), vec_ld_l8(ptr1))); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ st(a.val, 0, ptr); } \ +inline void v_store_aligned(VSX_UNUSED(_Tp* ptr), const _Tpvec& a) \ +{ st_a(a.val, 0, ptr); } \ +inline void v_store_aligned_nocache(VSX_UNUSED(_Tp* ptr), const _Tpvec& a) \ +{ st_a(a.val, 0, ptr); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ +{ if(mode == hal::STORE_UNALIGNED) st(a.val, 0, ptr); else st_a(a.val, 0, ptr); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ vec_st_l8(a.val, ptr); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ vec_st_h8(a.val, ptr); } + +// working around gcc bug for aligned ld/st +// if runtime check for vec_ld/st fail we failback to unaligned ld/st +// https://github.com/opencv/opencv/issues/13211 +#ifdef CV_COMPILER_VSX_BROKEN_ALIGNED + #define OPENCV_HAL_IMPL_VSX_LOADSTORE(_Tpvec, _Tp) \ + OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, vsx_ld, vsx_ld, vsx_st, vsx_st) +#else + #define OPENCV_HAL_IMPL_VSX_LOADSTORE(_Tpvec, _Tp) \ + OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, vsx_ld, vec_ld, vsx_st, vec_st) +#endif + +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_uint8x16, uchar) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_int8x16, schar) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_uint16x8, ushort) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_int16x8, short) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_uint32x4, uint) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_int32x4, int) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_float32x4, float) + +OPENCV_HAL_IMPL_VSX_LOADSTORE_C(v_float64x2, double, vsx_ld, vsx_ld, vsx_st, vsx_st) +OPENCV_HAL_IMPL_VSX_LOADSTORE_C(v_uint64x2, uint64, vsx_ld2, vsx_ld2, vsx_st2, vsx_st2) +OPENCV_HAL_IMPL_VSX_LOADSTORE_C(v_int64x2, int64, vsx_ld2, vsx_ld2, vsx_st2, vsx_st2) + +//////////////// Value reordering /////////////// + +/* de&interleave */ +#define OPENCV_HAL_IMPL_VSX_INTERLEAVE(_Tp, _Tpvec) \ +inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b) \ +{ vec_ld_deinterleave(ptr, a.val, b.val);} \ +inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, \ + _Tpvec& b, _Tpvec& c) \ +{ vec_ld_deinterleave(ptr, a.val, b.val, c.val); } \ +inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ +{ vec_ld_deinterleave(ptr, a.val, b.val, c.val, d.val); } \ +inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ vec_st_interleave(a.val, b.val, ptr); } \ +inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, \ + const _Tpvec& b, const _Tpvec& c, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ vec_st_interleave(a.val, b.val, c.val, ptr); } \ +inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \ + const _Tpvec& c, const _Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ vec_st_interleave(a.val, b.val, c.val, d.val, ptr); } + +OPENCV_HAL_IMPL_VSX_INTERLEAVE(uchar, v_uint8x16) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(schar, v_int8x16) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(ushort, v_uint16x8) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(short, v_int16x8) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(uint, v_uint32x4) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(int, v_int32x4) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(float, v_float32x4) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(double, v_float64x2) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(int64, v_int64x2) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(uint64, v_uint64x2) + +/* Expand */ +#define OPENCV_HAL_IMPL_VSX_EXPAND(_Tpvec, _Tpwvec, _Tp, fl, fh) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = fh(a.val); \ + b1.val = fl(a.val); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ return _Tpwvec(fh(a.val)); } \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ return _Tpwvec(fl(a.val)); } \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ return _Tpwvec(fh(vec_ld_l8(ptr))); } + +OPENCV_HAL_IMPL_VSX_EXPAND(v_uint8x16, v_uint16x8, uchar, vec_unpacklu, vec_unpackhu) +OPENCV_HAL_IMPL_VSX_EXPAND(v_int8x16, v_int16x8, schar, vec_unpackl, vec_unpackh) +OPENCV_HAL_IMPL_VSX_EXPAND(v_uint16x8, v_uint32x4, ushort, vec_unpacklu, vec_unpackhu) +OPENCV_HAL_IMPL_VSX_EXPAND(v_int16x8, v_int32x4, short, vec_unpackl, vec_unpackh) +OPENCV_HAL_IMPL_VSX_EXPAND(v_uint32x4, v_uint64x2, uint, vec_unpacklu, vec_unpackhu) +OPENCV_HAL_IMPL_VSX_EXPAND(v_int32x4, v_int64x2, int, vec_unpackl, vec_unpackh) + +/* Load and zero expand a 4 byte value into the second dword, first is don't care. */ +#if !defined(CV_COMPILER_VSX_BROKEN_ASM) + #define _LXSIWZX(out, ptr, T) __asm__ ("lxsiwzx %x0, 0, %1\r\n" : "=wa"(out) : "r" (ptr) : "memory"); +#else + /* This is compiler-agnostic, but will introduce an unneeded splat on the critical path. */ + #define _LXSIWZX(out, ptr, T) out = (T)vec_udword2_sp(*(uint32_t*)(ptr)); +#endif + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + // Zero-extend the extra 24B instead of unpacking. Usually faster in small kernel + // Likewise note, value is zero extended and upper 4 bytes are zero'ed. + vec_uchar16 pmu = {8, 12, 12, 12, 9, 12, 12, 12, 10, 12, 12, 12, 11, 12, 12, 12}; + vec_uchar16 out; + + _LXSIWZX(out, ptr, vec_uchar16); + out = vec_perm(out, out, pmu); + return v_uint32x4((vec_uint4)out); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + vec_char16 out; + vec_short8 outs; + vec_int4 outw; + + _LXSIWZX(out, ptr, vec_char16); + outs = vec_unpackl(out); + outw = vec_unpackh(outs); + return v_int32x4(outw); +} + +/* pack */ +#define OPENCV_HAL_IMPL_VSX_PACK(_Tpvec, _Tp, _Tpwvec, _Tpvn, _Tpdel, sfnc, pkfnc, addfnc, pack) \ +inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + return _Tpvec(pkfnc(a.val, b.val)); \ +} \ +inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + vec_st_l8(pkfnc(a.val, a.val), ptr); \ +} \ +template \ +inline _Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + const __vector _Tpvn vn = vec_splats((_Tpvn)n); \ + const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \ + return _Tpvec(pkfnc(sfnc(addfnc(a.val, delta), vn), sfnc(addfnc(b.val, delta), vn))); \ +} \ +template \ +inline void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + const __vector _Tpvn vn = vec_splats((_Tpvn)n); \ + const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \ + vec_st_l8(pkfnc(sfnc(addfnc(a.val, delta), vn), delta), ptr); \ +} + +OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_uint16x8, unsigned short, unsigned short, + vec_sr, vec_packs, vec_adds, pack) +OPENCV_HAL_IMPL_VSX_PACK(v_int8x16, schar, v_int16x8, unsigned short, short, + vec_sra, vec_packs, vec_adds, pack) + +OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_uint32x4, unsigned int, unsigned int, + vec_sr, vec_packs, vec_add, pack) +OPENCV_HAL_IMPL_VSX_PACK(v_int16x8, short, v_int32x4, unsigned int, int, + vec_sra, vec_packs, vec_add, pack) + +OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_uint64x2, unsigned long long, unsigned long long, + vec_sr, vec_pack, vec_add, pack) +OPENCV_HAL_IMPL_VSX_PACK(v_int32x4, int, v_int64x2, unsigned long long, long long, + vec_sra, vec_pack, vec_add, pack) + +OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_int16x8, unsigned short, short, + vec_sra, vec_packsu, vec_adds, pack_u) +OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_int32x4, unsigned int, int, + vec_sra, vec_packsu, vec_add, pack_u) +// Following variant is not implemented on other platforms: +//OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_int64x2, unsigned long long, long long, +// vec_sra, vec_packsu, vec_add, pack_u) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + vec_uchar16 ab = vec_pack(a.val, b.val); + return v_uint8x16(ab); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + vec_ushort8 ab = vec_pack(a.val, b.val); + vec_ushort8 cd = vec_pack(c.val, d.val); + return v_uint8x16(vec_pack(ab, cd)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + vec_uint4 ab = vec_pack(a.val, b.val); + vec_uint4 cd = vec_pack(c.val, d.val); + vec_uint4 ef = vec_pack(e.val, f.val); + vec_uint4 gh = vec_pack(g.val, h.val); + + vec_ushort8 abcd = vec_pack(ab, cd); + vec_ushort8 efgh = vec_pack(ef, gh); + return v_uint8x16(vec_pack(abcd, efgh)); +} + +/* Recombine */ +template +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) +{ + b0.val = vec_mergeh(a0.val, a1.val); + b1.val = vec_mergel(a0.val, a1.val); +} + +template +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(vec_mergesql(a.val, b.val)); } + +template +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(vec_mergesqh(a.val, b.val)); } + +template +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) +{ + c.val = vec_mergesqh(a.val, b.val); + d.val = vec_mergesql(a.val, b.val); +} + +////////// Arithmetic, bitwise and comparison operations ///////// + +/* Element-wise binary and unary operations */ +/** Arithmetics **/ +#define OPENCV_HAL_IMPL_VSX_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(intrin(a.val, b.val)); } \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ a.val = intrin(a.val, b.val); return a; } + +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint8x16, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint8x16, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int8x16, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int8x16, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint16x8, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint16x8, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int16x8, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int16x8, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint32x4, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint32x4, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_uint32x4, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int32x4, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int32x4, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_int32x4, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float32x4, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float32x4, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float32x4, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float32x4, vec_div) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float64x2, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float64x2, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float64x2, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float64x2, vec_div) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint64x2, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint64x2, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int64x2, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int64x2, vec_sub) + +// saturating multiply +#define OPENCV_HAL_IMPL_VSX_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_uint16x8, v_uint32x4) + +template +inline void v_mul_expand(const Tvec& a, const Tvec& b, Twvec& c, Twvec& d) +{ + Twvec p0 = Twvec(vec_mule(a.val, b.val)); + Twvec p1 = Twvec(vec_mulo(a.val, b.val)); + v_zip(p0, p1, c, d); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + vec_int4 p0 = vec_mule(a.val, b.val); + vec_int4 p1 = vec_mulo(a.val, b.val); + static const vec_uchar16 perm = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}; + return v_int16x8(vec_perm(vec_short8_c(p0), vec_short8_c(p1), perm)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + vec_uint4 p0 = vec_mule(a.val, b.val); + vec_uint4 p1 = vec_mulo(a.val, b.val); + static const vec_uchar16 perm = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}; + return v_uint16x8(vec_perm(vec_ushort8_c(p0), vec_ushort8_c(p1), perm)); +} + +/** Non-saturating arithmetics **/ +#define OPENCV_HAL_IMPL_VSX_BIN_FUNC(func, intrin) \ +template \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(intrin(a.val, b.val)); } + +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_add_wrap, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_sub_wrap, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_mul_wrap, vec_mul) + +/** Bitwise shifts **/ +#define OPENCV_HAL_IMPL_VSX_SHIFT_OP(_Tpvec, shr, splfunc) \ +inline _Tpvec operator << (const _Tpvec& a, int imm) \ +{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \ +inline _Tpvec operator >> (const _Tpvec& a, int imm) \ +{ return _Tpvec(shr(a.val, splfunc(imm))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec(shr(a.val, splfunc(imm))); } + +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint8x16, vec_sr, vec_uchar16_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint16x8, vec_sr, vec_ushort8_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint32x4, vec_sr, vec_uint4_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint64x2, vec_sr, vec_udword2_sp) +// algebraic right shift +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int8x16, vec_sra, vec_uchar16_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int16x8, vec_sra, vec_ushort8_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int32x4, vec_sra, vec_uint4_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int64x2, vec_sra, vec_udword2_sp) + +/** Bitwise logic **/ +#define OPENCV_HAL_IMPL_VSX_LOGIC_OP(_Tpvec) \ +OPENCV_HAL_IMPL_VSX_BIN_OP(&, _Tpvec, vec_and) \ +OPENCV_HAL_IMPL_VSX_BIN_OP(|, _Tpvec, vec_or) \ +OPENCV_HAL_IMPL_VSX_BIN_OP(^, _Tpvec, vec_xor) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ return _Tpvec(vec_not(a.val)); } + +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint8x16) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int8x16) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint16x8) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int16x8) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint32x4) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int32x4) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint64x2) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int64x2) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float32x4) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float64x2) + +/** Bitwise select **/ +#define OPENCV_HAL_IMPL_VSX_SELECT(_Tpvec, cast) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_sel(b.val, a.val, cast(mask.val))); } + +OPENCV_HAL_IMPL_VSX_SELECT(v_uint8x16, vec_bchar16_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_int8x16, vec_bchar16_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_uint16x8, vec_bshort8_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_int16x8, vec_bshort8_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_uint32x4, vec_bint4_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_int32x4, vec_bint4_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_float32x4, vec_bint4_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c) + +/** Comparison **/ +#define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpeq(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpne(a.val, b.val)); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmplt(a.val, b.val)); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpgt(a.val, b.val)); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmple(a.val, b.val)); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpge(a.val, b.val)); } + +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint8x16) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int8x16) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint16x8) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int16x8) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint32x4) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int32x4) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float32x4) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float64x2) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint64x2) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int64x2) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(vec_cmpeq(a.val, a.val)); } +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(vec_cmpeq(a.val, a.val)); } + +/** min/max **/ +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_min, vec_min) +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_max, vec_max) + +/** Rotate **/ +#define OPENCV_IMPL_VSX_ROTATE(_Tpvec, suffix, shf, cast) \ +template \ +inline _Tpvec v_rotate_##suffix(const _Tpvec& a) \ +{ \ + const int wd = imm * sizeof(typename _Tpvec::lane_type); \ + if (wd > 15) \ + return _Tpvec::zero(); \ + return _Tpvec((cast)shf(vec_uchar16_c(a.val), vec_uchar16_sp(wd << 3))); \ +} + +#define OPENCV_IMPL_VSX_ROTATE_LR(_Tpvec, cast) \ +OPENCV_IMPL_VSX_ROTATE(_Tpvec, left, vec_slo, cast) \ +OPENCV_IMPL_VSX_ROTATE(_Tpvec, right, vec_sro, cast) + +OPENCV_IMPL_VSX_ROTATE_LR(v_uint8x16, vec_uchar16) +OPENCV_IMPL_VSX_ROTATE_LR(v_int8x16, vec_char16) +OPENCV_IMPL_VSX_ROTATE_LR(v_uint16x8, vec_ushort8) +OPENCV_IMPL_VSX_ROTATE_LR(v_int16x8, vec_short8) +OPENCV_IMPL_VSX_ROTATE_LR(v_uint32x4, vec_uint4) +OPENCV_IMPL_VSX_ROTATE_LR(v_int32x4, vec_int4) +OPENCV_IMPL_VSX_ROTATE_LR(v_float32x4, vec_float4) +OPENCV_IMPL_VSX_ROTATE_LR(v_uint64x2, vec_udword2) +OPENCV_IMPL_VSX_ROTATE_LR(v_int64x2, vec_dword2) +OPENCV_IMPL_VSX_ROTATE_LR(v_float64x2, vec_double2) + +template +inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) +{ + enum { CV_SHIFT = 16 - imm * (sizeof(typename _Tpvec::lane_type)) }; + if (CV_SHIFT == 16) + return a; +#ifdef __IBMCPP__ + return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT & 15)); +#else + return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT)); +#endif +} + +template +inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) +{ + enum { CV_SHIFT = imm * (sizeof(typename _Tpvec::lane_type)) }; + if (CV_SHIFT == 16) + return b; + return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT)); +} + +#define OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, suffix, rg1, rg2) \ +template \ +inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \ +{ \ + if (imm == 1) \ + return _Tpvec(vec_permi(rg1.val, rg2.val, 2)); \ + return imm ? b : a; \ +} + +#define OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(_Tpvec) \ +OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, left, b, a) \ +OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, right, a, b) + +OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_float64x2) +OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_uint64x2) +OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_int64x2) + +/* Reverse */ +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + static const vec_uchar16 perm = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_uint8x16(vec_perm(vec, vec, perm)); +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + static const vec_uchar16 perm = {14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_reinterpret_as_u16(v_uint8x16(vec_perm(vec, vec, perm))); +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + static const vec_uchar16 perm = {12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_reinterpret_as_u32(v_uint8x16(vec_perm(vec, vec, perm))); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + static const vec_uchar16 perm = {8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_reinterpret_as_u64(v_uint8x16(vec_perm(vec, vec, perm))); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +/* Extract */ +template +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) +{ return v_rotate_right(a, b); } + +////////// Reduce and mask ///////// + +/** Reduce **/ +inline uint v_reduce_sum(const v_uint8x16& a) +{ + const vec_uint4 zero4 = vec_uint4_z; + vec_uint4 sum4 = vec_sum4s(a.val, zero4); + return (uint)vec_extract(vec_sums(vec_int4_c(sum4), vec_int4_c(zero4)), 3); +} +inline int v_reduce_sum(const v_int8x16& a) +{ + const vec_int4 zero4 = vec_int4_z; + vec_int4 sum4 = vec_sum4s(a.val, zero4); + return (int)vec_extract(vec_sums(sum4, zero4), 3); +} +inline int v_reduce_sum(const v_int16x8& a) +{ + const vec_int4 zero = vec_int4_z; + return saturate_cast(vec_extract(vec_sums(vec_sum4s(a.val, zero), zero), 3)); +} +inline uint v_reduce_sum(const v_uint16x8& a) +{ + const vec_int4 v4 = vec_int4_c(vec_unpackhu(vec_adds(a.val, vec_sld(a.val, a.val, 8)))); + return saturate_cast(vec_extract(vec_sums(v4, vec_int4_z), 3)); +} + +#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(_Tpvec, _Tpvec2, scalartype, suffix, func) \ +inline scalartype v_reduce_##suffix(const _Tpvec& a) \ +{ \ + const _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \ + return vec_extract(func(rs, vec_sld(rs, rs, 4)), 0); \ +} +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, sum, vec_add) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, sum, vec_add) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, sum, vec_add) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, min, vec_min) + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ + return vec_extract(vec_add(a.val, vec_permi(a.val, a.val, 3)), 0); +} +inline int64 v_reduce_sum(const v_int64x2& a) +{ + return vec_extract(vec_add(a.val, vec_permi(a.val, a.val, 3)), 0); +} +inline double v_reduce_sum(const v_float64x2& a) +{ + return vec_extract(vec_add(a.val, vec_permi(a.val, a.val, 3)), 0); +} + +#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(_Tpvec, _Tpvec2, scalartype, suffix, func) \ +inline scalartype v_reduce_##suffix(const _Tpvec& a) \ +{ \ + _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \ + rs = func(rs, vec_sld(rs, rs, 4)); \ + return vec_extract(func(rs, vec_sld(rs, rs, 2)), 0); \ +} +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, min, vec_min) + +#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(_Tpvec, _Tpvec2, scalartype, suffix, func) \ +inline scalartype v_reduce_##suffix(const _Tpvec& a) \ +{ \ + _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \ + rs = func(rs, vec_sld(rs, rs, 4)); \ + rs = func(rs, vec_sld(rs, rs, 2)); \ + return vec_extract(func(rs, vec_sld(rs, rs, 1)), 0); \ +} +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_uint8x16, vec_uchar16, uchar, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_uint8x16, vec_uchar16, uchar, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_int8x16, vec_char16, schar, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_int8x16, vec_char16, schar, min, vec_min) + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + vec_float4 ac = vec_add(vec_mergel(a.val, c.val), vec_mergeh(a.val, c.val)); + ac = vec_add(ac, vec_sld(ac, ac, 8)); + + vec_float4 bd = vec_add(vec_mergel(b.val, d.val), vec_mergeh(b.val, d.val)); + bd = vec_add(bd, vec_sld(bd, bd, 8)); + return v_float32x4(vec_mergeh(ac, bd)); +} + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + const vec_uint4 zero4 = vec_uint4_z; + vec_uint4 sum4 = vec_sum4s(vec_absd(a.val, b.val), zero4); + return (unsigned)vec_extract(vec_sums(vec_int4_c(sum4), vec_int4_c(zero4)), 3); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + const vec_int4 zero4 = vec_int4_z; + vec_char16 ad = vec_abss(vec_subs(a.val, b.val)); + vec_int4 sum4 = vec_sum4s(ad, zero4); + return (unsigned)vec_extract(vec_sums(sum4, zero4), 3); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + vec_ushort8 ad = vec_absd(a.val, b.val); + VSX_UNUSED(vec_int4) sum = vec_sums(vec_int4_c(vec_unpackhu(ad)) + vec_int4_c(vec_unpacklu(ad)), vec_int4_z); + return (unsigned)vec_extract(sum, 3); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + const vec_int4 zero4 = vec_int4_z; + vec_short8 ad = vec_abss(vec_subs(a.val, b.val)); + vec_int4 sum4 = vec_sum4s(ad, zero4); + return (unsigned)vec_extract(vec_sums(sum4, zero4), 3); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + const vec_uint4 ad = vec_absd(a.val, b.val); + const vec_uint4 rd = vec_add(ad, vec_sld(ad, ad, 8)); + return vec_extract(vec_add(rd, vec_sld(rd, rd, 4)), 0); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + vec_int4 ad = vec_abss(vec_sub(a.val, b.val)); + return (unsigned)vec_extract(vec_sums(ad, vec_int4_z), 3); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + const vec_float4 ad = vec_abs(vec_sub(a.val, b.val)); + const vec_float4 rd = vec_add(ad, vec_sld(ad, ad, 8)); + return vec_extract(vec_add(rd, vec_sld(rd, rd, 4)), 0); +} + +/** Popcount **/ +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ return v_uint8x16(vec_popcntu(a.val)); } +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_uint8x16(vec_popcntu(a.val)); } +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ return v_uint16x8(vec_popcntu(a.val)); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_uint16x8(vec_popcntu(a.val)); } +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ return v_uint32x4(vec_popcntu(a.val)); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_uint32x4(vec_popcntu(a.val)); } +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ return v_uint64x2(vec_popcntu(a.val)); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_uint64x2(vec_popcntu(a.val)); } + +/** Mask **/ +inline int v_signmask(const v_uint8x16& a) +{ + static const vec_uchar16 qperm = {120, 112, 104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0}; + return vec_extract((vec_int4)vec_vbpermq(v_reinterpret_as_u8(a).val, qperm), 2); +} +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } + +inline int v_signmask(const v_int16x8& a) +{ + static const vec_uchar16 qperm = {112, 96, 80, 64, 48, 32, 16, 0, 128, 128, 128, 128, 128, 128, 128, 128}; + return vec_extract((vec_int4)vec_vbpermq(v_reinterpret_as_u8(a).val, qperm), 2); +} +inline int v_signmask(const v_uint16x8& a) +{ return v_signmask(v_reinterpret_as_s16(a)); } + +inline int v_signmask(const v_int32x4& a) +{ + static const vec_uchar16 qperm = {96, 64, 32, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}; + return vec_extract((vec_int4)vec_vbpermq(v_reinterpret_as_u8(a).val, qperm), 2); +} +inline int v_signmask(const v_uint32x4& a) +{ return v_signmask(v_reinterpret_as_s32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_s32(a)); } + +inline int v_signmask(const v_int64x2& a) +{ + VSX_UNUSED(const vec_dword2) sv = vec_sr(a.val, vec_udword2_sp(63)); + return (int)vec_extract(sv, 0) | (int)vec_extract(sv, 1) << 1; +} +inline int v_signmask(const v_uint64x2& a) +{ return v_signmask(v_reinterpret_as_s64(a)); } +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_s64(a)); } + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(a)); } + +template +inline bool v_check_all(const _Tpvec& a) +{ return vec_all_lt(a.val, _Tpvec::zero().val); } +inline bool v_check_all(const v_uint8x16& a) +{ return v_check_all(v_reinterpret_as_s8(a)); } +inline bool v_check_all(const v_uint16x8& a) +{ return v_check_all(v_reinterpret_as_s16(a)); } +inline bool v_check_all(const v_uint32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_uint64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } + +template +inline bool v_check_any(const _Tpvec& a) +{ return vec_any_lt(a.val, _Tpvec::zero().val); } +inline bool v_check_any(const v_uint8x16& a) +{ return v_check_any(v_reinterpret_as_s8(a)); } +inline bool v_check_any(const v_uint16x8& a) +{ return v_check_any(v_reinterpret_as_s16(a)); } +inline bool v_check_any(const v_uint32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_uint64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } + +////////// Other math ///////// + +/** Some frequent operations **/ +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ return v_float32x4(vec_sqrt(x.val)); } +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ return v_float64x2(vec_sqrt(x.val)); } + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ return v_float32x4(vec_rsqrt(x.val)); } +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ return v_float64x2(vec_rsqrt(x.val)); } + +#define OPENCV_HAL_IMPL_VSX_MULADD(_Tpvec) \ +inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_sqrt(vec_madd(a.val, a.val, vec_mul(b.val, b.val)))); } \ +inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_madd(a.val, a.val, vec_mul(b.val, b.val))); } \ +inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ return _Tpvec(vec_madd(a.val, b.val, c.val)); } \ +inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ return _Tpvec(vec_madd(a.val, b.val, c.val)); } + +OPENCV_HAL_IMPL_VSX_MULADD(v_float32x4) +OPENCV_HAL_IMPL_VSX_MULADD(v_float64x2) + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ return a * b + c; } + +// TODO: exp, log, sin, cos + +/** Absolute values **/ +inline v_uint8x16 v_abs(const v_int8x16& x) +{ return v_uint8x16(vec_uchar16_c(vec_abs(x.val))); } + +inline v_uint16x8 v_abs(const v_int16x8& x) +{ return v_uint16x8(vec_ushort8_c(vec_abs(x.val))); } + +inline v_uint32x4 v_abs(const v_int32x4& x) +{ return v_uint32x4(vec_uint4_c(vec_abs(x.val))); } + +inline v_float32x4 v_abs(const v_float32x4& x) +{ return v_float32x4(vec_abs(x.val)); } + +inline v_float64x2 v_abs(const v_float64x2& x) +{ return v_float64x2(vec_abs(x.val)); } + +/** Absolute difference **/ +// unsigned +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_absdiff, vec_absd) + +inline v_uint8x16 v_absdiff(const v_int8x16& a, const v_int8x16& b) +{ return v_reinterpret_as_u8(v_sub_wrap(v_max(a, b), v_min(a, b))); } +inline v_uint16x8 v_absdiff(const v_int16x8& a, const v_int16x8& b) +{ return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); } +inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b) +{ return v_reinterpret_as_u32(v_max(a, b) - v_min(a, b)); } + +inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b) +{ return v_abs(a - b); } +inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b) +{ return v_abs(a - b); } + +/** Absolute difference for signed integers **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ return v_int8x16(vec_abss(vec_subs(a.val, b.val))); } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_int16x8(vec_abss(vec_subs(a.val, b.val))); } + +////////// Conversions ///////// + +/** Rounding **/ +inline v_int32x4 v_round(const v_float32x4& a) +{ return v_int32x4(vec_cts(vec_rint(a.val))); } + +inline v_int32x4 v_round(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_rint(a.val)), vec_int4_z)); } + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_rint(a.val)), vec_ctso(vec_rint(b.val)))); } + +inline v_int32x4 v_floor(const v_float32x4& a) +{ return v_int32x4(vec_cts(vec_floor(a.val))); } + +inline v_int32x4 v_floor(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_floor(a.val)), vec_int4_z)); } + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ return v_int32x4(vec_cts(vec_ceil(a.val))); } + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_ceil(a.val)), vec_int4_z)); } + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(vec_cts(a.val)); } + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(a.val), vec_int4_z)); } + +/** To float **/ +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ return v_float32x4(vec_ctf(a.val)); } + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ return v_float32x4(vec_mergesqo(vec_cvfo(a.val), vec_float4_z)); } + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ return v_float32x4(vec_mergesqo(vec_cvfo(a.val), vec_cvfo(b.val))); } + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ return v_float64x2(vec_ctdo(vec_mergeh(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ return v_float64x2(vec_ctdo(vec_mergel(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ return v_float64x2(vec_cvfo(vec_mergeh(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ return v_float64x2(vec_cvfo(vec_mergel(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ return v_float64x2(vec_ctd(a.val)); } + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]]); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + return v_reinterpret_as_s8(v_int16x8(*(const short*)(tab+idx[0]), *(const short*)(tab+idx[1]), *(const short*)(tab+idx[2]), *(const short*)(tab+idx[3]), + *(const short*)(tab+idx[4]), *(const short*)(tab+idx[5]), *(const short*)(tab+idx[6]), *(const short*)(tab+idx[7]))); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + return v_reinterpret_as_s8(v_int32x4(*(const int*)(tab+idx[0]), *(const int*)(tab+idx[1]), *(const int*)(tab+idx[2]), *(const int*)(tab+idx[3]))); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((const schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((const schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((const schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + return v_reinterpret_as_s16(v_int32x4(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1]), *(const int*)(tab + idx[2]), *(const int*)(tab + idx[3]))); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_reinterpret_as_s16(v_int64x2(*(const int64*)(tab + idx[0]), *(const int64*)(tab + idx[1]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((const short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((const short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((const short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + return v_int32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_reinterpret_as_s32(v_int64x2(*(const int64*)(tab + idx[0]), *(const int64*)(tab + idx[1]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vsx_ld(0, tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((const int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((const int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((const int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(vsx_ld2(0, tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_pairs((const int*)tab, idx)); } +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) { return v_load(tab + *idx); } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) { return v_load(tab + *idx); } + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + const int idx[4] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1), + vec_extract(idxvec.val, 2), + vec_extract(idxvec.val, 3) + }; + return v_int32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + const int idx[4] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1), + vec_extract(idxvec.val, 2), + vec_extract(idxvec.val, 3) + }; + return v_uint32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + const int idx[4] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1), + vec_extract(idxvec.val, 2), + vec_extract(idxvec.val, 3) + }; + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + const int idx[2] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1) + }; + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + vec_float4 xy0 = vec_ld_l8(tab + vec_extract(idxvec.val, 0)); + vec_float4 xy1 = vec_ld_l8(tab + vec_extract(idxvec.val, 1)); + vec_float4 xy2 = vec_ld_l8(tab + vec_extract(idxvec.val, 2)); + vec_float4 xy3 = vec_ld_l8(tab + vec_extract(idxvec.val, 3)); + vec_float4 xy02 = vec_mergeh(xy0, xy2); // x0, x2, y0, y2 + vec_float4 xy13 = vec_mergeh(xy1, xy3); // x1, x3, y1, y3 + x.val = vec_mergeh(xy02, xy13); + y.val = vec_mergel(xy02, xy13); +} +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + vec_double2 xy0 = vsx_ld(vec_extract(idxvec.val, 0), tab); + vec_double2 xy1 = vsx_ld(vec_extract(idxvec.val, 1), tab); + x.val = vec_mergeh(xy0, xy1); + y.val = vec_mergel(xy0, xy1); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + static const vec_uchar16 perm = {0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15}; + return v_int8x16(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } + +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + static const vec_uchar16 perm = {0, 4, 1, 5, 2, 6, 3, 7, 8, 12, 9, 13, 10, 14, 11, 15}; + return v_int8x16(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + static const vec_uchar16 perm = {0,1, 4,5, 2,3, 6,7, 8,9, 12,13, 10,11, 14,15}; + return v_int16x8(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) +{ return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } + +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + static const vec_uchar16 perm = {0,1, 8,9, 2,3, 10,11, 4,5, 12,13, 6,7, 14,15}; + return v_int16x8(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) +{ return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + static const vec_uchar16 perm = {0,1,2,3, 8,9,10,11, 4,5,6,7, 12,13,14,15}; + return v_int32x4(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) +{ return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) +{ return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + static const vec_uchar16 perm = {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15, 15, 15, 15}; + return v_int8x16(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + static const vec_uchar16 perm = {0,1, 2,3, 4,5, 8,9, 10,11, 12,13, 14,15, 14,15}; + return v_int16x8(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) +{ return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) +{ return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) +{ return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) +{ return vec; } + +/////// FP16 support //////// + +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + vec_ushort8 vf16 = vec_ld_l8((const ushort*)ptr); +#if CV_VSX3 && defined(vec_extract_fp_from_shorth) + return v_float32x4(vec_extract_fp_from_shorth(vf16)); +#elif CV_VSX3 && !defined(CV_COMPILER_VSX_BROKEN_ASM) + vec_float4 vf32; + __asm__ __volatile__ ("xvcvhpsp %x0,%x1" : "=wa" (vf32) : "wa" (vec_mergeh(vf16, vf16))); + return v_float32x4(vf32); +#else + const vec_int4 z = vec_int4_z, delta = vec_int4_sp(0x38000000); + const vec_int4 signmask = vec_int4_sp(0x80000000); + const vec_int4 maxexp = vec_int4_sp(0x7c000000); + const vec_float4 deltaf = vec_float4_c(vec_int4_sp(0x38800000)); + + vec_int4 bits = vec_int4_c(vec_mergeh(vec_short8_c(z), vec_short8_c(vf16))); + vec_int4 e = vec_and(bits, maxexp), sign = vec_and(bits, signmask); + vec_int4 t = vec_add(vec_sr(vec_xor(bits, sign), vec_uint4_sp(3)), delta); // ((h & 0x7fff) << 13) + delta + vec_int4 zt = vec_int4_c(vec_sub(vec_float4_c(vec_add(t, vec_int4_sp(1 << 23))), deltaf)); + + t = vec_add(t, vec_and(delta, vec_cmpeq(maxexp, e))); + vec_bint4 zmask = vec_cmpeq(e, z); + vec_int4 ft = vec_sel(t, zt, zmask); + return v_float32x4(vec_float4_c(vec_or(ft, sign))); +#endif +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ +// fixme: Is there any builtin op or intrinsic that cover "xvcvsphp"? +#if CV_VSX3 && !defined(CV_COMPILER_VSX_BROKEN_ASM) + vec_ushort8 vf16; + __asm__ __volatile__ ("xvcvsphp %x0,%x1" : "=wa" (vf16) : "wa" (v.val)); + vec_st_l8(vec_mergesqe(vf16, vf16), ptr); +#else + const vec_int4 signmask = vec_int4_sp(0x80000000); + const vec_int4 rval = vec_int4_sp(0x3f000000); + + vec_int4 t = vec_int4_c(v.val); + vec_int4 sign = vec_sra(vec_and(t, signmask), vec_uint4_sp(16)); + t = vec_and(vec_nor(signmask, signmask), t); + + vec_bint4 finitemask = vec_cmpgt(vec_int4_sp(0x47800000), t); + vec_bint4 isnan = vec_cmpgt(t, vec_int4_sp(0x7f800000)); + vec_int4 naninf = vec_sel(vec_int4_sp(0x7c00), vec_int4_sp(0x7e00), isnan); + vec_bint4 tinymask = vec_cmpgt(vec_int4_sp(0x38800000), t); + vec_int4 tt = vec_int4_c(vec_add(vec_float4_c(t), vec_float4_c(rval))); + tt = vec_sub(tt, rval); + vec_int4 odd = vec_and(vec_sr(t, vec_uint4_sp(13)), vec_int4_sp(1)); + vec_int4 nt = vec_add(t, vec_int4_sp(0xc8000fff)); + nt = vec_sr(vec_add(nt, odd), vec_uint4_sp(13)); + t = vec_sel(nt, tt, tinymask); + t = vec_sel(naninf, t, finitemask); + t = vec_or(t, sign); + vec_st_l8(vec_packs(t, t), ptr); +#endif +} + +inline void v_cleanup() {} + + +/** Reinterpret **/ +/** its up there with load and store operations **/ + +////////// Matrix operations ///////// + +//////// Dot Product //////// +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)); } +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_int32x4(vec_msum(a.val, b.val, c.val)); } + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + vec_dword2 even = vec_mule(a.val, b.val); + vec_dword2 odd = vec_mulo(a.val, b.val); + return v_int64x2(vec_add(even, odd)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_uint32x4(vec_msum(a.val, b.val, c.val)); } +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)); } + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + const vec_ushort8 eight = vec_ushort8_sp(8); + vec_short8 a0 = vec_sra((vec_short8)vec_sld(a.val, a.val, 1), eight); // even + vec_short8 a1 = vec_sra((vec_short8)a.val, eight); // odd + vec_short8 b0 = vec_sra((vec_short8)vec_sld(b.val, b.val, 1), eight); + vec_short8 b1 = vec_sra((vec_short8)b.val, eight); + return v_int32x4(vec_msum(a0, b0, vec_msum(a1, b1, vec_int4_z))); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ + const vec_ushort8 eight = vec_ushort8_sp(8); + vec_short8 a0 = vec_sra((vec_short8)vec_sld(a.val, a.val, 1), eight); // even + vec_short8 a1 = vec_sra((vec_short8)a.val, eight); // odd + vec_short8 b0 = vec_sra((vec_short8)vec_sld(b.val, b.val, 1), eight); + vec_short8 b1 = vec_sra((vec_short8)b.val, eight); + return v_int32x4(vec_msum(a0, b0, vec_msum(a1, b1, c.val))); +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + const vec_uint4 zero = vec_uint4_z; + vec_uint4 even = vec_mule(a.val, b.val); + vec_uint4 odd = vec_mulo(a.val, b.val); + vec_udword2 e0 = (vec_udword2)vec_mergee(even, zero); + vec_udword2 e1 = (vec_udword2)vec_mergeo(even, zero); + vec_udword2 o0 = (vec_udword2)vec_mergee(odd, zero); + vec_udword2 o1 = (vec_udword2)vec_mergeo(odd, zero); + vec_udword2 s0 = vec_add(e0, o0); + vec_udword2 s1 = vec_add(e1, o1); + return v_uint64x2(vec_add(s0, s1)); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return v_int64x2(vec_add(vec_mergeh(c.val, d.val), vec_mergel(c.val, d.val))); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; } +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; } + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ + vec_short8 a0 = vec_unpackh(a.val); + vec_short8 a1 = vec_unpackl(a.val); + vec_short8 b0 = vec_unpackh(b.val); + vec_short8 b1 = vec_unpackl(b.val); + return v_int32x4(vec_msum(a0, b0, vec_msum(a1, b1, vec_int4_z))); +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return c + d; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + const vec_float4 v0 = vec_splat(v.val, 0); + const vec_float4 v1 = vec_splat(v.val, 1); + const vec_float4 v2 = vec_splat(v.val, 2); + VSX_UNUSED(const vec_float4) v3 = vec_splat(v.val, 3); + return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, vec_mul(v3, m3.val))))); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + const vec_float4 v0 = vec_splat(v.val, 0); + const vec_float4 v1 = vec_splat(v.val, 1); + const vec_float4 v2 = vec_splat(v.val, 2); + return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, a.val)))); +} + +#define OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(_Tpvec, _Tpvec2) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \ +{ \ + _Tpvec2 a02 = vec_mergeh(a0.val, a2.val); \ + _Tpvec2 a13 = vec_mergeh(a1.val, a3.val); \ + b0.val = vec_mergeh(a02, a13); \ + b1.val = vec_mergel(a02, a13); \ + a02 = vec_mergel(a0.val, a2.val); \ + a13 = vec_mergel(a1.val, a3.val); \ + b2.val = vec_mergeh(a02, a13); \ + b3.val = vec_mergel(a02, a13); \ +} +OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_uint32x4, vec_uint4) +OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_int32x4, vec_int4) +OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_float32x4, vec_float4) + +template +inline Tvec v_broadcast_element(const Tvec& v) +{ return Tvec(vec_splat(v.val, i)); } + + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif // OPENCV_HAL_VSX_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_wasm.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_wasm.hpp new file mode 100644 index 0000000..b4178af --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/intrin_wasm.hpp @@ -0,0 +1,2782 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_HAL_INTRIN_WASM_HPP +#define OPENCV_HAL_INTRIN_WASM_HPP + +#include +#include +#include +#include "opencv2/core/saturate.hpp" + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 0 // Now all implementation of f64 use fallback, so disable it. +#define CV_SIMD128_FP16 0 + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) < (1038046) +// handle renames: https://github.com/emscripten-core/emscripten/pull/9440 (https://github.com/emscripten-core/emscripten/commit/755d5b46cb84d0aa120c10981b11d05646c29673) +#define wasm_i32x4_trunc_saturate_f32x4 wasm_trunc_saturate_i32x4_f32x4 +#define wasm_u32x4_trunc_saturate_f32x4 wasm_trunc_saturate_u32x4_f32x4 +#define wasm_i64x2_trunc_saturate_f64x2 wasm_trunc_saturate_i64x2_f64x2 +#define wasm_u64x2_trunc_saturate_f64x2 wasm_trunc_saturate_u64x2_f64x2 +#define wasm_f32x4_convert_i32x4 wasm_convert_f32x4_i32x4 +#define wasm_f32x4_convert_u32x4 wasm_convert_f32x4_u32x4 +#define wasm_f64x2_convert_i64x2 wasm_convert_f64x2_i64x2 +#define wasm_f64x2_convert_u64x2 wasm_convert_f64x2_u64x2 +#endif // COMPATIBILITY: <1.38.46 + +///////// Types /////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + typedef v128_t vector_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(v128_t v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = wasm_v128_load(v); + } + + uchar get0() const + { + return (uchar)wasm_i8x16_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + typedef v128_t vector_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(v128_t v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = wasm_v128_load(v); + } + + schar get0() const + { + return wasm_i8x16_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + typedef v128_t vector_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(v128_t v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = wasm_v128_load(v); + } + + ushort get0() const + { + return (ushort)wasm_i16x8_extract_lane(val, 0); // wasm_u16x8_extract_lane() unimplemented yet + } + + v128_t val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + typedef v128_t vector_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(v128_t v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = wasm_v128_load(v); + } + + short get0() const + { + return wasm_i16x8_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + typedef v128_t vector_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(v128_t v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + val = wasm_v128_load(v); + } + + unsigned get0() const + { + return (unsigned)wasm_i32x4_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + typedef v128_t vector_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(v128_t v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = wasm_v128_load(v); + } + + int get0() const + { + return wasm_i32x4_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + typedef v128_t vector_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(v128_t v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = wasm_v128_load(v); + } + + float get0() const + { + return wasm_f32x4_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + typedef v128_t vector_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(v128_t v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = wasm_v128_load(v); + } + + uint64 get0() const + { + return (uint64)wasm_i64x2_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + typedef v128_t vector_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(v128_t v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = wasm_v128_load(v); + } + + int64 get0() const + { + return wasm_i64x2_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + typedef v128_t vector_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(v128_t v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = wasm_v128_load(v); + } + + double get0() const + { + return wasm_f64x2_extract_lane(val, 0); + } + + v128_t val; +}; + +namespace +{ +#define OPENCV_HAL_IMPL_REINTERPRET_INT(ft, tt) \ +inline tt reinterpret_int(ft x) { union { ft l; tt i; } v; v.l = x; return v.i; } +OPENCV_HAL_IMPL_REINTERPRET_INT(uchar, schar) +OPENCV_HAL_IMPL_REINTERPRET_INT(schar, schar) +OPENCV_HAL_IMPL_REINTERPRET_INT(ushort, short) +OPENCV_HAL_IMPL_REINTERPRET_INT(short, short) +OPENCV_HAL_IMPL_REINTERPRET_INT(unsigned, int) +OPENCV_HAL_IMPL_REINTERPRET_INT(int, int) +OPENCV_HAL_IMPL_REINTERPRET_INT(float, int) +OPENCV_HAL_IMPL_REINTERPRET_INT(uint64, int64) +OPENCV_HAL_IMPL_REINTERPRET_INT(int64, int64) +OPENCV_HAL_IMPL_REINTERPRET_INT(double, int64) + +static const unsigned char popCountTable[] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; +} // namespace + +static v128_t wasm_unpacklo_i8x16(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,16,1,17,2,18,3,19,4,20,5,21,6,22,7,23); +} + +static v128_t wasm_unpacklo_i16x8(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,1,16,17,2,3,18,19,4,5,20,21,6,7,22,23); +} + +static v128_t wasm_unpacklo_i32x4(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,1,2,3,16,17,18,19,4,5,6,7,20,21,22,23); +} + +static v128_t wasm_unpacklo_i64x2(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); +} + +static v128_t wasm_unpackhi_i8x16(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,24,9,25,10,26,11,27,12,28,13,29,14,30,15,31); +} + +static v128_t wasm_unpackhi_i16x8(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,9,24,25,10,11,26,27,12,13,28,29,14,15,30,31); +} + +static v128_t wasm_unpackhi_i32x4(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,9,10,11,24,25,26,27,12,13,14,15,28,29,30,31); +} + +static v128_t wasm_unpackhi_i64x2(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); +} + +/** Convert **/ +// 8 >> 16 +inline v128_t v128_cvtu8x16_i16x8(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i8x16(a, z); +} +inline v128_t v128_cvti8x16_i16x8(const v128_t& a) +{ return wasm_i16x8_shr(wasm_unpacklo_i8x16(a, a), 8); } +// 8 >> 32 +inline v128_t v128_cvtu8x16_i32x4(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i16x8(wasm_unpacklo_i8x16(a, z), z); +} +inline v128_t v128_cvti8x16_i32x4(const v128_t& a) +{ + v128_t r = wasm_unpacklo_i8x16(a, a); + r = wasm_unpacklo_i8x16(r, r); + return wasm_i32x4_shr(r, 24); +} +// 16 >> 32 +inline v128_t v128_cvtu16x8_i32x4(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i16x8(a, z); +} +inline v128_t v128_cvti16x8_i32x4(const v128_t& a) +{ return wasm_i32x4_shr(wasm_unpacklo_i16x8(a, a), 16); } +// 32 >> 64 +inline v128_t v128_cvtu32x4_i64x2(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i32x4(a, z); +} +inline v128_t v128_cvti32x4_i64x2(const v128_t& a) +{ return wasm_unpacklo_i32x4(a, wasm_i32x4_shr(a, 31)); } + +// 16 << 8 +inline v128_t v128_cvtu8x16_i16x8_high(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpackhi_i8x16(a, z); +} +inline v128_t v128_cvti8x16_i16x8_high(const v128_t& a) +{ return wasm_i16x8_shr(wasm_unpackhi_i8x16(a, a), 8); } +// 32 << 16 +inline v128_t v128_cvtu16x8_i32x4_high(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpackhi_i16x8(a, z); +} +inline v128_t v128_cvti16x8_i32x4_high(const v128_t& a) +{ return wasm_i32x4_shr(wasm_unpackhi_i16x8(a, a), 16); } +// 64 << 32 +inline v128_t v128_cvtu32x4_i64x2_high(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpackhi_i32x4(a, z); +} +inline v128_t v128_cvti32x4_i64x2_high(const v128_t& a) +{ return wasm_unpackhi_i32x4(a, wasm_i32x4_shr(a, 31)); } + +#define OPENCV_HAL_IMPL_WASM_INITVEC(_Tpvec, _Tp, suffix, zsuffix, _Tps) \ +inline _Tpvec v_setzero_##suffix() { return _Tpvec(wasm_##zsuffix##_splat((_Tps)0)); } \ +inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(wasm_##zsuffix##_splat((_Tps)v)); } \ +template inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0& a) \ +{ return _Tpvec(a.val); } + +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint8x16, uchar, u8, i8x16, schar) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int8x16, schar, s8, i8x16, schar) +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint16x8, ushort, u16, i16x8, short) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int16x8, short, s16, i16x8, short) +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint32x4, unsigned, u32, i32x4, int) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int32x4, int, s32, i32x4, int) +OPENCV_HAL_IMPL_WASM_INITVEC(v_float32x4, float, f32, f32x4, float) +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint64x2, uint64, u64, i64x2, int64) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int64x2, int64, s64, i64x2, int64) +OPENCV_HAL_IMPL_WASM_INITVEC(v_float64x2, double, f64, f64x2, double) + +//////////////// PACK /////////////// +inline v_uint8x16 v_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u16x8_gt(b.val, maxval)); + return v_uint8x16(wasm_v8x16_shuffle(a1, b1, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +inline v_int8x16 v_pack(const v_int16x8& a, const v_int16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i16x8_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i16x8_lt(b1, minval)); + return v_int8x16(wasm_v8x16_shuffle(a2, b2, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +inline v_uint16x8 v_pack(const v_uint32x4& a, const v_uint32x4& b) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u32x4_gt(b.val, maxval)); + return v_uint16x8(wasm_v8x16_shuffle(a1, b1, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +inline v_int16x8 v_pack(const v_int32x4& a, const v_int32x4& b) +{ + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i32x4_splat(-32768); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i32x4_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i32x4_lt(b1, minval)); + return v_int16x8(wasm_v8x16_shuffle(a2, b2, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +inline v_uint32x4 v_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + return v_uint32x4(wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +inline v_int32x4 v_pack(const v_int64x2& a, const v_int64x2& b) +{ + return v_int32x4(wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i16x8_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i16x8_lt(b1, minval)); + return v_uint8x16(wasm_v8x16_shuffle(a2, b2, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +inline v_uint16x8 v_pack_u(const v_int32x4& a, const v_int32x4& b) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i32x4_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i32x4_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i32x4_lt(b1, minval)); + return v_uint16x8(wasm_v8x16_shuffle(a2, b2, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} + +template +inline v_uint8x16 v_rshr_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_u16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t b1 = wasm_u16x8_shr(wasm_i16x8_add(b.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u16x8_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_u16x8_gt(b1, maxval)); + return v_uint8x16(wasm_v8x16_shuffle(a2, b2, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +template +inline v_int8x16 v_rshr_pack(const v_int16x8& a, const v_int16x8& b) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t b1 = wasm_i16x8_shr(wasm_i16x8_add(b.val, delta), n); + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i16x8_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i16x8_lt(b1, minval)); + return v_int8x16(wasm_v8x16_shuffle(a3, b3, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +template +inline v_uint16x8 v_rshr_pack(const v_uint32x4& a, const v_uint32x4& b) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_u32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t b1 = wasm_u32x4_shr(wasm_i32x4_add(b.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u32x4_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_u32x4_gt(b1, maxval)); + return v_uint16x8(wasm_v8x16_shuffle(a2, b2, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +template +inline v_int16x8 v_rshr_pack(const v_int32x4& a, const v_int32x4& b) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t b1 = wasm_i32x4_shr(wasm_i32x4_add(b.val, delta), n); + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i16x8_splat(-32768); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i32x4_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i32x4_lt(b1, minval)); + return v_int16x8(wasm_v8x16_shuffle(a3, b3, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +template +inline v_uint32x4 v_rshr_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_u64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t b1 = wasm_u64x2_shr(wasm_i64x2_add(b.val, delta), n); + return v_uint32x4(wasm_v8x16_shuffle(a1, b1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +template +inline v_int32x4 v_rshr_pack(const v_int64x2& a, const v_int64x2& b) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_i64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t b1 = wasm_i64x2_shr(wasm_i64x2_add(b.val, delta), n); + return v_int32x4(wasm_v8x16_shuffle(a1, b1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +template +inline v_uint8x16 v_rshr_pack_u(const v_int16x8& a, const v_int16x8& b) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t b1 = wasm_i16x8_shr(wasm_i16x8_add(b.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i16x8_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i16x8_lt(b1, minval)); + return v_uint8x16(wasm_v8x16_shuffle(a3, b3, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +template +inline v_uint16x8 v_rshr_pack_u(const v_int32x4& a, const v_int32x4& b) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t b1 = wasm_i32x4_shr(wasm_i32x4_add(b.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i16x8_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i32x4_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i32x4_lt(b1, minval)); + return v_uint16x8(wasm_v8x16_shuffle(a3, b3, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} + +inline void v_pack_store(uchar* ptr, const v_uint16x8& a) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u16x8_gt(a.val, maxval)); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(schar* ptr, const v_int16x8& a) +{ + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + schar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(ushort* ptr, const v_uint32x4& a) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u32x4_gt(a.val, maxval)); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(short* ptr, const v_int32x4& a) +{ + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i32x4_splat(-32768); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + short t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + v128_t r = wasm_v8x16_shuffle(a.val, a.val, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + unsigned t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(int* ptr, const v_int64x2& a) +{ + v128_t r = wasm_v8x16_shuffle(a.val, a.val, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + int t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_u_store(uchar* ptr, const v_int16x8& a) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_u_store(ushort* ptr, const v_int32x4& a) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i32x4_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} + +template +inline void v_rshr_pack_store(uchar* ptr, const v_uint16x8& a) +{ + v128_t delta = wasm_i16x8_splat((short)(1 << (n-1))); + v128_t a1 = wasm_u16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u16x8_gt(a1, maxval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(schar* ptr, const v_int16x8& a) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + schar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(ushort* ptr, const v_uint32x4& a) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_u32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u32x4_gt(a1, maxval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(short* ptr, const v_int32x4& a) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i32x4_splat(-32768); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + short t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_u64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + unsigned t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(int* ptr, const v_int64x2& a) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_i64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + int t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_u_store(uchar* ptr, const v_int16x8& a) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_u_store(ushort* ptr, const v_int32x4& a) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i32x4_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} + +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u16x8_gt(b.val, maxval)); + return v_uint8x16(wasm_v8x16_shuffle(a1, b1, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + v128_t maxval = wasm_i32x4_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u32x4_gt(b.val, maxval)); + v128_t c1 = wasm_v128_bitselect(maxval, c.val, wasm_u32x4_gt(c.val, maxval)); + v128_t d1 = wasm_v128_bitselect(maxval, d.val, wasm_u32x4_gt(d.val, maxval)); + v128_t ab = wasm_v8x16_shuffle(a1, b1, 0,4,8,12,16,20,24,28,0,4,8,12,16,20,24,28); + v128_t cd = wasm_v8x16_shuffle(c1, d1, 0,4,8,12,16,20,24,28,0,4,8,12,16,20,24,28); + return v_uint8x16(wasm_v8x16_shuffle(ab, cd, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + v128_t maxval = wasm_i32x4_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, ((__u64x2)(a.val) > (__u64x2)maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, ((__u64x2)(b.val) > (__u64x2)maxval)); + v128_t c1 = wasm_v128_bitselect(maxval, c.val, ((__u64x2)(c.val) > (__u64x2)maxval)); + v128_t d1 = wasm_v128_bitselect(maxval, d.val, ((__u64x2)(d.val) > (__u64x2)maxval)); + v128_t e1 = wasm_v128_bitselect(maxval, e.val, ((__u64x2)(e.val) > (__u64x2)maxval)); + v128_t f1 = wasm_v128_bitselect(maxval, f.val, ((__u64x2)(f.val) > (__u64x2)maxval)); + v128_t g1 = wasm_v128_bitselect(maxval, g.val, ((__u64x2)(g.val) > (__u64x2)maxval)); + v128_t h1 = wasm_v128_bitselect(maxval, h.val, ((__u64x2)(h.val) > (__u64x2)maxval)); + v128_t ab = wasm_v8x16_shuffle(a1, b1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t cd = wasm_v8x16_shuffle(c1, d1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t ef = wasm_v8x16_shuffle(e1, f1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t gh = wasm_v8x16_shuffle(g1, h1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t abcd = wasm_v8x16_shuffle(ab, cd, 0,1,2,3,16,17,18,19,0,1,2,3,16,17,18,19); + v128_t efgh = wasm_v8x16_shuffle(ef, gh, 0,1,2,3,16,17,18,19,0,1,2,3,16,17,18,19); + return v_uint8x16(wasm_v8x16_shuffle(abcd, efgh, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23)); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + v128_t v0 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 0)); + v128_t v1 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 1)); + v128_t v2 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 2)); + v128_t v3 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 3)); + v0 = wasm_f32x4_mul(v0, m0.val); + v1 = wasm_f32x4_mul(v1, m1.val); + v2 = wasm_f32x4_mul(v2, m2.val); + v3 = wasm_f32x4_mul(v3, m3.val); + + return v_float32x4(wasm_f32x4_add(wasm_f32x4_add(v0, v1), wasm_f32x4_add(v2, v3))); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + v128_t v0 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 0)); + v128_t v1 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 1)); + v128_t v2 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 2)); + v0 = wasm_f32x4_mul(v0, m0.val); + v1 = wasm_f32x4_mul(v1, m1.val); + v2 = wasm_f32x4_mul(v2, m2.val); + + return v_float32x4(wasm_f32x4_add(wasm_f32x4_add(v0, v1), wasm_f32x4_add(v2, a.val))); +} + +#define OPENCV_HAL_IMPL_WASM_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint8x16, wasm_u8x16_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint8x16, wasm_u8x16_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int8x16, wasm_i8x16_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int8x16, wasm_i8x16_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint16x8, wasm_u16x8_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint16x8, wasm_u16x8_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int16x8, wasm_i16x8_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int16x8, wasm_i16x8_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint32x4, wasm_i32x4_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint32x4, wasm_i32x4_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_uint32x4, wasm_i32x4_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int32x4, wasm_i32x4_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int32x4, wasm_i32x4_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_int32x4, wasm_i32x4_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_float32x4, wasm_f32x4_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_float32x4, wasm_f32x4_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_float32x4, wasm_f32x4_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(/, v_float32x4, wasm_f32x4_div) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint64x2, wasm_i64x2_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint64x2, wasm_i64x2_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int64x2, wasm_i64x2_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int64x2, wasm_i64x2_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_float64x2, wasm_f64x2_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_float64x2, wasm_f64x2_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_float64x2, wasm_f64x2_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(/, v_float64x2, wasm_f64x2_div) + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_WASM_MUL_SAT(_Tpvec, _Tpwvec) \ +inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ +} \ +inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ +{ a = a * b; return a; } + +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_uint16x8, v_uint32x4) +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_int16x8, v_int32x4) + +// Multiply and expand +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + v_uint16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + v_int16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + v_int32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c.val = wasm_i32x4_mul(a0.val, b0.val); + d.val = wasm_i32x4_mul(a1.val, b1.val); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + v_uint32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c.val = wasm_i32x4_mul(a0.val, b0.val); + d.val = wasm_i32x4_mul(a1.val, b1.val); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + v_uint64x2 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c.val = ((__u64x2)(a0.val) * (__u64x2)(b0.val)); + d.val = ((__u64x2)(a1.val) * (__u64x2)(b1.val)); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + v128_t c = wasm_i32x4_mul(a0.val, b0.val); + v128_t d = wasm_i32x4_mul(a1.val, b1.val); + return v_int16x8(wasm_v8x16_shuffle(c, d, 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + v128_t c = wasm_i32x4_mul(a0.val, b0.val); + v128_t d = wasm_i32x4_mul(a1.val, b1.val); + return v_uint16x8(wasm_v8x16_shuffle(c, d, 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31)); +} + +//////// Dot Product //////// + +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + v128_t a0 = wasm_i32x4_shr(wasm_i32x4_shl(a.val, 16), 16); + v128_t a1 = wasm_i32x4_shr(a.val, 16); + v128_t b0 = wasm_i32x4_shr(wasm_i32x4_shl(b.val, 16), 16); + v128_t b1 = wasm_i32x4_shr(b.val, 16); + v128_t c = wasm_i32x4_mul(a0, b0); + v128_t d = wasm_i32x4_mul(a1, b1); + return v_int32x4(wasm_i32x4_add(c, d)); +} + +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b) + c; } + +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + v128_t a0 = wasm_i64x2_shr(wasm_i64x2_shl(a.val, 32), 32); + v128_t a1 = wasm_i64x2_shr(a.val, 32); + v128_t b0 = wasm_i64x2_shr(wasm_i64x2_shl(b.val, 32), 32); + v128_t b1 = wasm_i64x2_shr(b.val, 32); + v128_t c = (v128_t)((__i64x2)a0 * (__i64x2)b0); + v128_t d = (v128_t)((__i64x2)a1 * (__i64x2)b1); + return v_int64x2(wasm_i64x2_add(c, d)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + return v_dotprod(a, b) + c; +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + v128_t a0 = wasm_u16x8_shr(wasm_i16x8_shl(a.val, 8), 8); + v128_t a1 = wasm_u16x8_shr(a.val, 8); + v128_t b0 = wasm_u16x8_shr(wasm_i16x8_shl(b.val, 8), 8); + v128_t b1 = wasm_u16x8_shr(b.val, 8); + return v_uint32x4(( + v_dotprod(v_int16x8(a0), v_int16x8(b0)) + + v_dotprod(v_int16x8(a1), v_int16x8(b1))).val + ); +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + v128_t a0 = wasm_i16x8_shr(wasm_i16x8_shl(a.val, 8), 8); + v128_t a1 = wasm_i16x8_shr(a.val, 8); + v128_t b0 = wasm_i16x8_shr(wasm_i16x8_shl(b.val, 8), 8); + v128_t b1 = wasm_i16x8_shr(b.val, 8); + return v_int32x4( + v_dotprod(v_int16x8(a0), v_int16x8(b0)) + + v_dotprod(v_int16x8(a1), v_int16x8(b1)) + ); +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t a0 = wasm_u32x4_shr(wasm_i32x4_shl(a.val, 16), 16); + v128_t a1 = wasm_u32x4_shr(a.val, 16); + v128_t b0 = wasm_u32x4_shr(wasm_i32x4_shl(b.val, 16), 16); + v128_t b1 = wasm_u32x4_shr(b.val, 16); + return v_uint64x2(( + v_dotprod(v_int32x4(a0), v_int32x4(b0)) + + v_dotprod(v_int32x4(a1), v_int32x4(b1))).val + ); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v128_t a0 = wasm_i32x4_shr(wasm_i32x4_shl(a.val, 16), 16); + v128_t a1 = wasm_i32x4_shr(a.val, 16); + v128_t b0 = wasm_i32x4_shr(wasm_i32x4_shl(b.val, 16), 16); + v128_t b1 = wasm_i32x4_shr(b.val, 16); + return v_int64x2(( + v_dotprod(v_int32x4(a0), v_int32x4(b0)) + + v_dotprod(v_int32x4(a1), v_int32x4(b1))) + ); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b, c); } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b, c); } + +#define OPENCV_HAL_IMPL_WASM_LOGIC_OP(_Tpvec) \ +OPENCV_HAL_IMPL_WASM_BIN_OP(&, _Tpvec, wasm_v128_and) \ +OPENCV_HAL_IMPL_WASM_BIN_OP(|, _Tpvec, wasm_v128_or) \ +OPENCV_HAL_IMPL_WASM_BIN_OP(^, _Tpvec, wasm_v128_xor) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ \ + return _Tpvec(wasm_v128_not(a.val)); \ +} + +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint8x16) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int8x16) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint16x8) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int16x8) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint32x4) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int32x4) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint64x2) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int64x2) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_float32x4) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_float64x2) + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(wasm_f32x4_sqrt(x.val)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + const v128_t _1_0 = wasm_f32x4_splat(1.0); + return v_float32x4(wasm_f32x4_div(_1_0, wasm_f32x4_sqrt(x.val))); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(wasm_f64x2_sqrt(x.val)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + const v128_t _1_0 = wasm_f64x2_splat(1.0); + return v_float64x2(wasm_f64x2_div(_1_0, wasm_f64x2_sqrt(x.val))); +} + +#define OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(_Tpuvec, _Tpsvec, suffix, zsuffix, shiftWidth) \ +inline _Tpuvec v_abs(const _Tpsvec& x) \ +{ \ + v128_t s = wasm_##suffix##_shr(x.val, shiftWidth); \ + v128_t f = wasm_##zsuffix##_shr(x.val, shiftWidth); \ + return _Tpuvec(wasm_##zsuffix##_add(wasm_v128_xor(x.val, f), s)); \ +} + +OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(v_uint8x16, v_int8x16, u8x16, i8x16, 7) +OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(v_uint16x8, v_int16x8, u16x8, i16x8, 15) +OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(v_uint32x4, v_int32x4, u32x4, i32x4, 31) + +inline v_float32x4 v_abs(const v_float32x4& x) +{ return v_float32x4(wasm_f32x4_abs(x.val)); } +inline v_float64x2 v_abs(const v_float64x2& x) +{ + return v_float64x2(wasm_f64x2_abs(x.val)); +} + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_WASM_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float32x4, v_min, wasm_f32x4_min) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float32x4, v_max, wasm_f32x4_max) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float64x2, v_min, wasm_f64x2_min) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float64x2, v_max, wasm_f64x2_max) + +#define OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(_Tpvec, suffix) \ +inline _Tpvec v_min(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_v128_bitselect(b.val, a.val, wasm_##suffix##_gt(a.val, b.val))); \ +} \ +inline _Tpvec v_max(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_v128_bitselect(a.val, b.val, wasm_##suffix##_gt(a.val, b.val))); \ +} + +OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(v_int8x16, i8x16) +OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(v_int16x8, i16x8) +OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(v_int32x4, i32x4) + +#define OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(_Tpvec, suffix, deltaNum) \ +inline _Tpvec v_min(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t delta = wasm_##suffix##_splat(deltaNum); \ + v128_t mask = wasm_##suffix##_gt(wasm_v128_xor(a.val, delta), wasm_v128_xor(b.val, delta)); \ + return _Tpvec(wasm_v128_bitselect(b.val, a.val, mask)); \ +} \ +inline _Tpvec v_max(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t delta = wasm_##suffix##_splat(deltaNum); \ + v128_t mask = wasm_##suffix##_gt(wasm_v128_xor(a.val, delta), wasm_v128_xor(b.val, delta)); \ + return _Tpvec(wasm_v128_bitselect(a.val, b.val, mask)); \ +} + +OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(v_uint8x16, i8x16, (schar)0x80) +OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(v_uint16x8, i16x8, (short)0x8000) +OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(v_uint32x4, i32x4, (int)0x80000000) + +#define OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(_Tpvec, suffix, esuffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##esuffix##_eq(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##esuffix##_ne(a.val, b.val)); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_lt(a.val, b.val)); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_gt(a.val, b.val)); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_le(a.val, b.val)); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_ge(a.val, b.val)); } + +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint8x16, u8x16, i8x16) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int8x16, i8x16, i8x16) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint16x8, u16x8, i16x8) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int16x8, i16x8, i16x8) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint32x4, u32x4, i32x4) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int32x4, i32x4, i32x4) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_float32x4, f32x4, f32x4) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_float64x2, f64x2, f64x2) + +#define OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(_Tpvec, cast) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return cast(v_reinterpret_as_f64(a) == v_reinterpret_as_f64(b)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return cast(v_reinterpret_as_f64(a) != v_reinterpret_as_f64(b)); } + +OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(v_uint64x2, v_reinterpret_as_u64) +OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(v_int64x2, v_reinterpret_as_s64) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ + v128_t z = wasm_i32x4_splat(0x7fffffff); + v128_t t = wasm_i32x4_splat(0x7f800000); + return v_float32x4(wasm_u32x4_lt(wasm_v128_and(a.val, z), t)); +} +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ + v128_t z = wasm_i64x2_splat(0x7fffffffffffffff); + v128_t t = wasm_i64x2_splat(0x7ff0000000000000); + return v_float64x2((__u64x2)(wasm_v128_and(a.val, z)) < (__u64x2)t); +} + +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_add_wrap, wasm_i8x16_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_add_wrap, wasm_i8x16_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_add_wrap, wasm_i16x8_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_add_wrap, wasm_i16x8_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_sub_wrap, wasm_i8x16_sub) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_sub_wrap, wasm_i8x16_sub) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_sub_wrap, wasm_i16x8_sub) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_sub_wrap, wasm_i16x8_sub) +#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) >= (1039012) +// details: https://github.com/opencv/opencv/issues/18097 ( https://github.com/emscripten-core/emscripten/issues/12018 ) +// 1.39.12: https://github.com/emscripten-core/emscripten/commit/cd801d0f110facfd694212a3c8b2ed2ffcd630e2 +inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b) +{ + uchar a_[16], b_[16]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + for (int i = 0; i < 16; i++) + a_[i] = (uchar)(a_[i] * b_[i]); + return v_uint8x16(wasm_v128_load(a_)); +} +inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b) +{ + schar a_[16], b_[16]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + for (int i = 0; i < 16; i++) + a_[i] = (schar)(a_[i] * b_[i]); + return v_int8x16(wasm_v128_load(a_)); +} +#else +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_mul_wrap, wasm_i8x16_mul) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_mul_wrap, wasm_i8x16_mul) +#endif +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_mul_wrap, wasm_i16x8_mul) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_mul_wrap, wasm_i16x8_mul) + + +/** Absolute difference **/ + +inline v_uint8x16 v_absdiff(const v_uint8x16& a, const v_uint8x16& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x8 v_absdiff(const v_uint16x8& a, const v_uint16x8& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x4 v_absdiff(const v_uint32x4& a, const v_uint32x4& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x16 v_absdiff(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = v_sub_wrap(a, b); + v_int8x16 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} +inline v_uint16x8 v_absdiff(const v_int16x8& a, const v_int16x8& b) +{ + return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); +} +inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b) +{ + v_int32x4 d = a - b; + v_int32x4 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = a - b; + v_int8x16 m = a < b; + return (d ^ m) - m; + } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_max(a, b) - v_min(a, b); } + + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return a * b + c; +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return a * b + c; +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return a * b + c; +} + +inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b) +{ + v128_t absmask_vec = wasm_i32x4_splat(0x7fffffff); + return v_float32x4(wasm_v128_and(wasm_f32x4_sub(a.val, b.val), absmask_vec)); +} +inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b) +{ + v128_t absmask_vec = wasm_u64x2_shr(wasm_i32x4_splat(-1), 1); + return v_float64x2(wasm_v128_and(wasm_f64x2_sub(a.val, b.val), absmask_vec)); +} + +#define OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(_Tpvec, suffix) \ +inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t a_Square = wasm_##suffix##_mul(a.val, a.val); \ + v128_t b_Square = wasm_##suffix##_mul(b.val, b.val); \ + return _Tpvec(wasm_##suffix##_sqrt(wasm_##suffix##_add(a_Square, b_Square))); \ +} \ +inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t a_Square = wasm_##suffix##_mul(a.val, a.val); \ + v128_t b_Square = wasm_##suffix##_mul(b.val, b.val); \ + return _Tpvec(wasm_##suffix##_add(a_Square, b_Square)); \ +} \ +inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ \ + return _Tpvec(wasm_##suffix##_add(wasm_##suffix##_mul(a.val, b.val), c.val)); \ +} + +OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float32x4, f32x4) +OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float64x2, f64x2) + +#define OPENCV_HAL_IMPL_WASM_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, ssuffix) \ +inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(wasm_##ssuffix##_shr(a.val, imm)); \ +} \ +inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(wasm_##suffix##_shr(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shl(const _Tpuvec& a) \ +{ \ + return _Tpuvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shl(const _Tpsvec& a) \ +{ \ + return _Tpsvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shr(const _Tpuvec& a) \ +{ \ + return _Tpuvec(wasm_##ssuffix##_shr(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shr(const _Tpsvec& a) \ +{ \ + return _Tpsvec(wasm_##suffix##_shr(a.val, imm)); \ +} + +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint8x16, v_int8x16, i8x16, u8x16) +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint16x8, v_int16x8, i16x8, u16x8) +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint32x4, v_int32x4, i32x4, u32x4) +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint64x2, v_int64x2, i64x2, u64x2) + +namespace hal_wasm_internal +{ + template 16)), + bool is_first = (imm == 0), + bool is_second = (imm == 16), + bool is_other = (((imm > 0) && (imm < 16)))> + class v_wasm_palignr_u8_class; + + template + class v_wasm_palignr_u8_class; + + template + class v_wasm_palignr_u8_class + { + public: + inline v128_t operator()(const v128_t& a, const v128_t&) const + { + return a; + } + }; + + template + class v_wasm_palignr_u8_class + { + public: + inline v128_t operator()(const v128_t&, const v128_t& b) const + { + return b; + } + }; + + template + class v_wasm_palignr_u8_class + { + public: + inline v128_t operator()(const v128_t& a, const v128_t& b) const + { + enum { imm2 = (sizeof(v128_t) - imm) }; + return wasm_v8x16_shuffle(a, b, + imm, imm+1, imm+2, imm+3, + imm+4, imm+5, imm+6, imm+7, + imm+8, imm+9, imm+10, imm+11, + imm+12, imm+13, imm+14, imm+15); + } + }; + + template + inline v128_t v_wasm_palignr_u8(const v128_t& a, const v128_t& b) + { + CV_StaticAssert((imm >= 0) && (imm <= 16), "Invalid imm for v_wasm_palignr_u8."); + return v_wasm_palignr_u8_class()(a, b); + } +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a) +{ + using namespace hal_wasm_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + v128_t z = wasm_i8x16_splat(0); + return _Tpvec(v_wasm_palignr_u8(a.val, z)); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a) +{ + using namespace hal_wasm_internal; + enum { imm2 = ((_Tpvec::nlanes - imm) * sizeof(typename _Tpvec::lane_type)) }; + v128_t z = wasm_i8x16_splat(0); + return _Tpvec(v_wasm_palignr_u8(z, a.val)); +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_wasm_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_wasm_palignr_u8(a.val, b.val)); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_wasm_internal; + enum { imm2 = ((_Tpvec::nlanes - imm) * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_wasm_palignr_u8(b.val, a.val)); +} + +#define OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(_Tpvec, _Tp) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(wasm_v128_load(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(wasm_v128_load(ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ \ + _Tp tmp[_Tpvec::nlanes] = {0}; \ + for (int i=0; i<_Tpvec::nlanes/2; ++i) { \ + tmp[i] = ptr[i]; \ + } \ + return _Tpvec(wasm_v128_load(tmp)); \ +} \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + _Tp tmp[_Tpvec::nlanes]; \ + for (int i=0; i<_Tpvec::nlanes/2; ++i) { \ + tmp[i] = ptr0[i]; \ + tmp[i+_Tpvec::nlanes/2] = ptr1[i]; \ + } \ + return _Tpvec(wasm_v128_load(tmp)); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ wasm_v128_store(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ wasm_v128_store(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ wasm_v128_store(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ \ + wasm_v128_store(ptr, a.val); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + for (int i = 0; i < (_Tpvec::nlanes / 2); i++) \ + ptr[i] = a_[i]; \ +} \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + for (int i = 0; i < (_Tpvec::nlanes / 2); i++) \ + ptr[i] = a_[i + (_Tpvec::nlanes / 2)]; \ +} + +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint8x16, uchar) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int8x16, schar) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint16x8, ushort) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int16x8, short) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint32x4, unsigned) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int32x4, int) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint64x2, uint64) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int64x2, int64) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_float32x4, float) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_float64x2, double) + + +/** Reverse **/ +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ return v_uint8x16(wasm_v8x16_shuffle(a.val, a.val, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)); } + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ return v_uint16x8(wasm_v8x16_shuffle(a.val, a.val, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1)); } + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ return v_uint32x4(wasm_v8x16_shuffle(a.val, a.val, 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3)); } + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ return v_uint64x2(wasm_v8x16_shuffle(a.val, a.val, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7)); } + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + + +#define OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(_Tpvec, scalartype, regtype, suffix, esuffix) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + regtype val = a.val; \ + val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7)); \ + val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3)); \ + return (scalartype)wasm_##esuffix##_extract_lane(val, 0); \ +} + +OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(v_uint32x4, unsigned, v128_t, i32x4, i32x4) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(v_int32x4, int, v128_t, i32x4, i32x4) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(v_float32x4, float, v128_t, f32x4, f32x4) + +// To do: Optimize v_reduce_sum with wasm intrin. +// Now use fallback implementation as there is no widening op in wasm intrin. + +#define OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(_Tpvec, scalartype) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + scalartype c = a_[0]; \ + for (int i = 1; i < _Tpvec::nlanes; i++) \ + c += a_[i]; \ + return c; \ +} + +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint8x16, unsigned) +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int8x16, int) +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint16x8, unsigned) +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int16x8, int) + + +#define OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(_Tpvec, scalartype, regtype, suffix, esuffix) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + regtype val = a.val; \ + val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7)); \ + return (scalartype)wasm_##esuffix##_extract_lane(val, 0); \ +} +OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_uint64x2, uint64, v128_t, i64x2, i64x2) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_int64x2, int64, v128_t, i64x2, i64x2) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_float64x2, double, v128_t, f64x2,f64x2) + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + v128_t ac = wasm_f32x4_add(wasm_unpacklo_i32x4(a.val, c.val), wasm_unpackhi_i32x4(a.val, c.val)); + v128_t bd = wasm_f32x4_add(wasm_unpacklo_i32x4(b.val, d.val), wasm_unpackhi_i32x4(b.val, d.val)); + return v_float32x4(wasm_f32x4_add(wasm_unpacklo_i32x4(ac, bd), wasm_unpackhi_i32x4(ac, bd))); +} + +#define OPENCV_HAL_IMPL_WASM_REDUCE_OP(_Tpvec, scalartype, func, scalar_func) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + scalartype buf[_Tpvec::nlanes]; \ + v_store(buf, a); \ + scalartype tmp = buf[0]; \ + for (int i=1; i<_Tpvec::nlanes; ++i) { \ + tmp = scalar_func(tmp, buf[i]); \ + } \ + return tmp; \ +} + +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint8x16, uchar, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint8x16, uchar, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int8x16, schar, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int8x16, schar, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint16x8, ushort, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint16x8, ushort, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int16x8, short, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int16x8, short, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint32x4, unsigned, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint32x4, unsigned, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int32x4, int, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int32x4, int, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_float32x4, float, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_float32x4, float, min, std::min) + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + v_uint16x8 l16, h16; + v_uint32x4 l16_l32, l16_h32, h16_l32, h16_h32; + v_expand(v_absdiff(a, b), l16, h16); + v_expand(l16, l16_l32, l16_h32); + v_expand(h16, h16_l32, h16_h32); + return v_reduce_sum(l16_l32+l16_h32+h16_l32+h16_h32); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + v_uint16x8 l16, h16; + v_uint32x4 l16_l32, l16_h32, h16_l32, h16_h32; + v_expand(v_absdiff(a, b), l16, h16); + v_expand(l16, l16_l32, l16_h32); + v_expand(h16, h16_l32, h16_h32); + return v_reduce_sum(l16_l32+l16_h32+h16_l32+h16_h32); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} + +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ + v128_t m1 = wasm_i32x4_splat(0x55555555); + v128_t m2 = wasm_i32x4_splat(0x33333333); + v128_t m4 = wasm_i32x4_splat(0x0f0f0f0f); + v128_t p = a.val; + p = wasm_i32x4_add(wasm_v128_and(wasm_u32x4_shr(p, 1), m1), wasm_v128_and(p, m1)); + p = wasm_i32x4_add(wasm_v128_and(wasm_u32x4_shr(p, 2), m2), wasm_v128_and(p, m2)); + p = wasm_i32x4_add(wasm_v128_and(wasm_u32x4_shr(p, 4), m4), wasm_v128_and(p, m4)); + return v_uint8x16(p); +} +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v_setall_u16(0x00ff); +} +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v_setall_u32(0x000000ff); +} +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ + uint64 a_[2], b_[2] = { 0 }; + wasm_v128_store(a_, a.val); + for (int i = 0; i < 16; i++) + b_[i / 8] += popCountTable[((uint8_t*)a_)[i]]; + return v_uint64x2(wasm_v128_load(b_)); +} +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_popcount(v_reinterpret_as_u8(a)); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_popcount(v_reinterpret_as_u16(a)); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_popcount(v_reinterpret_as_u32(a)); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_popcount(v_reinterpret_as_u64(a)); } + +#define OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(_Tpvec, suffix, scalarType) \ +inline int v_signmask(const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + int mask = 0; \ + for (int i = 0; i < _Tpvec::nlanes; i++) \ + mask |= (reinterpret_int(a_[i]) < 0) << i; \ + return mask; \ +} \ +inline bool v_check_all(const _Tpvec& a) \ +{ return wasm_i8x16_all_true(wasm_##suffix##_lt(a.val, wasm_##suffix##_splat(0))); } \ +inline bool v_check_any(const _Tpvec& a) \ +{ return wasm_i8x16_any_true(wasm_##suffix##_lt(a.val, wasm_##suffix##_splat(0)));; } + +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint8x16, i8x16, schar) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int8x16, i8x16, schar) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint16x8, i16x8, short) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int16x8, i16x8, short) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint32x4, i32x4, int) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int32x4, i32x4, int) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_float32x4, i32x4, float) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_float64x2, f64x2, double) + +#define OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(_Tpvec, suffix, esuffix) \ +inline bool v_check_all(const _Tpvec& a) \ +{ \ + v128_t masked = v_reinterpret_as_##esuffix(a).val; \ + masked = wasm_i32x4_replace_lane(masked, 0, 0xffffffff); \ + masked = wasm_i32x4_replace_lane(masked, 2, 0xffffffff); \ + return wasm_i8x16_all_true(wasm_##suffix##_lt(masked, wasm_##suffix##_splat(0))); \ +} \ +inline bool v_check_any(const _Tpvec& a) \ +{ \ + v128_t masked = v_reinterpret_as_##esuffix(a).val; \ + masked = wasm_i32x4_replace_lane(masked, 0, 0x0); \ + masked = wasm_i32x4_replace_lane(masked, 2, 0x0); \ + return wasm_i8x16_any_true(wasm_##suffix##_lt(masked, wasm_##suffix##_splat(0))); \ +} \ + +OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(v_int64x2, i32x4, s32) +OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(v_uint64x2, i32x4, u32) + + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } + +#define OPENCV_HAL_IMPL_WASM_SELECT(_Tpvec) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_v128_bitselect(a.val, b.val, mask.val)); \ +} + +OPENCV_HAL_IMPL_WASM_SELECT(v_uint8x16) +OPENCV_HAL_IMPL_WASM_SELECT(v_int8x16) +OPENCV_HAL_IMPL_WASM_SELECT(v_uint16x8) +OPENCV_HAL_IMPL_WASM_SELECT(v_int16x8) +OPENCV_HAL_IMPL_WASM_SELECT(v_uint32x4) +OPENCV_HAL_IMPL_WASM_SELECT(v_int32x4) +OPENCV_HAL_IMPL_WASM_SELECT(v_uint64x2) +OPENCV_HAL_IMPL_WASM_SELECT(v_int64x2) +OPENCV_HAL_IMPL_WASM_SELECT(v_float32x4) +OPENCV_HAL_IMPL_WASM_SELECT(v_float64x2) + +#define OPENCV_HAL_IMPL_WASM_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = intrin(a.val); \ + b1.val = __CV_CAT(intrin, _high)(a.val); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ return _Tpwvec(intrin(a.val)); } \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ return _Tpwvec(__CV_CAT(intrin, _high)(a.val)); } \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + v128_t a = wasm_v128_load(ptr); \ + return _Tpwvec(intrin(a)); \ +} + +OPENCV_HAL_IMPL_WASM_EXPAND(v_uint8x16, v_uint16x8, uchar, v128_cvtu8x16_i16x8) +OPENCV_HAL_IMPL_WASM_EXPAND(v_int8x16, v_int16x8, schar, v128_cvti8x16_i16x8) +OPENCV_HAL_IMPL_WASM_EXPAND(v_uint16x8, v_uint32x4, ushort, v128_cvtu16x8_i32x4) +OPENCV_HAL_IMPL_WASM_EXPAND(v_int16x8, v_int32x4, short, v128_cvti16x8_i32x4) +OPENCV_HAL_IMPL_WASM_EXPAND(v_uint32x4, v_uint64x2, unsigned, v128_cvtu32x4_i64x2) +OPENCV_HAL_IMPL_WASM_EXPAND(v_int32x4, v_int64x2, int, v128_cvti32x4_i64x2) + +#define OPENCV_HAL_IMPL_WASM_EXPAND_Q(_Tpvec, _Tp, intrin) \ +inline _Tpvec v_load_expand_q(const _Tp* ptr) \ +{ \ + v128_t a = wasm_v128_load(ptr); \ + return _Tpvec(intrin(a)); \ +} + +OPENCV_HAL_IMPL_WASM_EXPAND_Q(v_uint32x4, uchar, v128_cvtu8x16_i32x4) +OPENCV_HAL_IMPL_WASM_EXPAND_Q(v_int32x4, schar, v128_cvti8x16_i32x4) + +#define OPENCV_HAL_IMPL_WASM_UNPACKS(_Tpvec, suffix) \ +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) \ +{ \ + b0.val = wasm_unpacklo_##suffix(a0.val, a1.val); \ + b1.val = wasm_unpackhi_##suffix(a0.val, a1.val); \ +} \ +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_unpacklo_i64x2(a.val, b.val)); \ +} \ +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_unpackhi_i64x2(a.val, b.val)); \ +} \ +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) \ +{ \ + c.val = wasm_unpacklo_i64x2(a.val, b.val); \ + d.val = wasm_unpackhi_i64x2(a.val, b.val); \ +} + +OPENCV_HAL_IMPL_WASM_UNPACKS(v_uint8x16, i8x16) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_int8x16, i8x16) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_uint16x8, i16x8) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_int16x8, i16x8) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_uint32x4, i32x4) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_int32x4, i32x4) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_float32x4, i32x4) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_float64x2, i64x2) + +template +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) +{ + return v_rotate_right(a, b); +} + +inline v_int32x4 v_round(const v_float32x4& a) +{ + v128_t h = wasm_f32x4_splat(0.5); + return v_int32x4(wasm_i32x4_trunc_saturate_f32x4(wasm_f32x4_add(a.val, h))); +} + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + v128_t a1 = wasm_i32x4_trunc_saturate_f32x4(a.val); + v128_t mask = wasm_f32x4_lt(a.val, wasm_f32x4_convert_i32x4(a1)); + return v_int32x4(wasm_i32x4_add(a1, mask)); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + v128_t a1 = wasm_i32x4_trunc_saturate_f32x4(a.val); + v128_t mask = wasm_f32x4_gt(a.val, wasm_f32x4_convert_i32x4(a1)); + return v_int32x4(wasm_i32x4_sub(a1, mask)); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(wasm_i32x4_trunc_saturate_f32x4(a.val)); } + +#define OPENCV_HAL_IMPL_WASM_MATH_FUNC(func, cfunc) \ +inline v_int32x4 func(const v_float64x2& a) \ +{ \ + double a_[2]; \ + wasm_v128_store(a_, a.val); \ + int c_[4]; \ + c_[0] = cfunc(a_[0]); \ + c_[1] = cfunc(a_[1]); \ + c_[2] = 0; \ + c_[3] = 0; \ + return v_int32x4(wasm_v128_load(c_)); \ +} + +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_round, cvRound) +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_floor, cvFloor) +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_ceil, cvCeil) +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_trunc, int) + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + double a_[2], b_[2]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + int c_[4]; + c_[0] = cvRound(a_[0]); + c_[1] = cvRound(a_[1]); + c_[2] = cvRound(b_[0]); + c_[3] = cvRound(b_[1]); + return v_int32x4(wasm_v128_load(c_)); +} + +#define OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(_Tpvec, suffix) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, \ + _Tpvec& b2, _Tpvec& b3) \ +{ \ + v128_t t0 = wasm_unpacklo_##suffix(a0.val, a1.val); \ + v128_t t1 = wasm_unpacklo_##suffix(a2.val, a3.val); \ + v128_t t2 = wasm_unpackhi_##suffix(a0.val, a1.val); \ + v128_t t3 = wasm_unpackhi_##suffix(a2.val, a3.val); \ +\ + b0.val = wasm_unpacklo_i64x2(t0, t1); \ + b1.val = wasm_unpackhi_i64x2(t0, t1); \ + b2.val = wasm_unpacklo_i64x2(t2, t3); \ + b3.val = wasm_unpackhi_i64x2(t2, t3); \ +} + +OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(v_uint32x4, i32x4) +OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(v_int32x4, i32x4) +OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(v_float32x4, i32x4) + +// load deinterleave +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b) +{ + v128_t t00 = wasm_v128_load(ptr); + v128_t t01 = wasm_v128_load(ptr + 16); + + a.val = wasm_v8x16_shuffle(t00, t01, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30); + b.val = wasm_v8x16_shuffle(t00, t01, 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31); +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c) +{ + v128_t t00 = wasm_v128_load(ptr); + v128_t t01 = wasm_v128_load(ptr + 16); + v128_t t02 = wasm_v128_load(ptr + 32); + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,3,6,9,12,15,18,21,24,27,30,1,2,4,5,7); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 1,4,7,10,13,16,19,22,25,28,31,0,2,3,5,6); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 2,5,8,11,14,17,20,23,26,29,0,1,3,4,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,17,20,23,26,29); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,10,18,21,24,27,30); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,8,9,16,19,22,25,28,31); +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c, v_uint8x16& d) +{ + v128_t u0 = wasm_v128_load(ptr); // a0 b0 c0 d0 a1 b1 c1 d1 ... + v128_t u1 = wasm_v128_load(ptr + 16); // a4 b4 c4 d4 ... + v128_t u2 = wasm_v128_load(ptr + 32); // a8 b8 c8 d8 ... + v128_t u3 = wasm_v128_load(ptr + 48); // a12 b12 c12 d12 ... + + v128_t v0 = wasm_v8x16_shuffle(u0, u1, 0,4,8,12,16,20,24,28,1,5,9,13,17,21,25,29); + v128_t v1 = wasm_v8x16_shuffle(u2, u3, 0,4,8,12,16,20,24,28,1,5,9,13,17,21,25,29); + v128_t v2 = wasm_v8x16_shuffle(u0, u1, 2,6,10,14,18,22,26,30,3,7,11,15,19,23,27,31); + v128_t v3 = wasm_v8x16_shuffle(u2, u3, 2,6,10,14,18,22,26,30,3,7,11,15,19,23,27,31); + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + b.val = wasm_v8x16_shuffle(v0, v1, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); + c.val = wasm_v8x16_shuffle(v2, v3, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + d.val = wasm_v8x16_shuffle(v2, v3, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b) +{ + v128_t v0 = wasm_v128_load(ptr); // a0 b0 a1 b1 a2 b2 a3 b3 + v128_t v1 = wasm_v128_load(ptr + 8); // a4 b4 a5 b5 a6 b6 a7 b7 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29); // a0 a1 a2 a3 a4 a5 a6 a7 + b.val = wasm_v8x16_shuffle(v0, v1, 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31); // b0 b1 ab b3 b4 b5 b6 b7 +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c) +{ + v128_t t00 = wasm_v128_load(ptr); // a0 b0 c0 a1 b1 c1 a2 b2 + v128_t t01 = wasm_v128_load(ptr + 8); // c2 a3 b3 c3 a4 b4 c4 a5 + v128_t t02 = wasm_v128_load(ptr + 16); // b5 c5 a6 b6 c6 a7 b7 c7 + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,1,6,7,12,13,18,19,24,25,30,31,2,3,4,5); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 2,3,8,9,14,15,20,21,26,27,0,1,4,5,6,7); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 4,5,10,11,16,17,22,23,28,29,0,1,2,3,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,11,20,21,26,27); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,16,17,22,23,28,29); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,8,9,18,19,24,25,30,31); +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c, v_uint16x8& d) +{ + v128_t u0 = wasm_v128_load(ptr); // a0 b0 c0 d0 a1 b1 c1 d1 + v128_t u1 = wasm_v128_load(ptr + 8); // a2 b2 c2 d2 ... + v128_t u2 = wasm_v128_load(ptr + 16); // a4 b4 c4 d4 ... + v128_t u3 = wasm_v128_load(ptr + 24); // a6 b6 c6 d6 ... + + v128_t v0 = wasm_v8x16_shuffle(u0, u1, 0,1,8,9,16,17,24,25,2,3,10,11,18,19,26,27); // a0 a1 a2 a3 b0 b1 b2 b3 + v128_t v1 = wasm_v8x16_shuffle(u2, u3, 0,1,8,9,16,17,24,25,2,3,10,11,18,19,26,27); // a4 a5 a6 a7 b4 b5 b6 b7 + v128_t v2 = wasm_v8x16_shuffle(u0, u1, 4,5,12,13,20,21,28,29,6,7,14,15,22,23,30,31); // c0 c1 c2 c3 d0 d1 d2 d3 + v128_t v3 = wasm_v8x16_shuffle(u2, u3, 4,5,12,13,20,21,28,29,6,7,14,15,22,23,30,31); // c4 c5 c6 c7 d4 d5 d6 d7 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + b.val = wasm_v8x16_shuffle(v0, v1, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); + c.val = wasm_v8x16_shuffle(v2, v3, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + d.val = wasm_v8x16_shuffle(v2, v3, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b) +{ + v128_t v0 = wasm_v128_load(ptr); // a0 b0 a1 b1 + v128_t v1 = wasm_v128_load(ptr + 4); // a2 b2 a3 b3 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27); // a0 a1 a2 a3 + b.val = wasm_v8x16_shuffle(v0, v1, 4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31); // b0 b1 b2 b3 +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c) +{ + v128_t t00 = wasm_v128_load(ptr); // a0 b0 c0 a1 + v128_t t01 = wasm_v128_load(ptr + 4); // b2 c2 a3 b3 + v128_t t02 = wasm_v128_load(ptr + 8); // c3 a4 b4 c4 + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,1,2,3,12,13,14,15,24,25,26,27,4,5,6,7); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 4,5,6,7,16,17,18,19,28,29,30,31,0,1,2,3); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 8,9,10,11,20,21,22,23,0,1,2,3,4,5,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,11,20,21,22,23); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,10,11,24,25,26,27); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,16,17,18,19,28,29,30,31); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c, v_uint32x4& d) +{ + v_uint32x4 s0(wasm_v128_load(ptr)); // a0 b0 c0 d0 + v_uint32x4 s1(wasm_v128_load(ptr + 4)); // a1 b1 c1 d1 + v_uint32x4 s2(wasm_v128_load(ptr + 8)); // a2 b2 c2 d2 + v_uint32x4 s3(wasm_v128_load(ptr + 12)); // a3 b3 c3 d3 + + v_transpose4x4(s0, s1, s2, s3, a, b, c, d); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b) +{ + v128_t v0 = wasm_v128_load(ptr); // a0 b0 a1 b1 + v128_t v1 = wasm_v128_load((ptr + 4)); // a2 b2 a3 b3 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27); // a0 a1 a2 a3 + b.val = wasm_v8x16_shuffle(v0, v1, 4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31); // b0 b1 b2 b3 +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c) +{ + v128_t t00 = wasm_v128_load(ptr); // a0 b0 c0 a1 + v128_t t01 = wasm_v128_load(ptr + 4); // b2 c2 a3 b3 + v128_t t02 = wasm_v128_load(ptr + 8); // c3 a4 b4 c4 + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,1,2,3,12,13,14,15,24,25,26,27,4,5,6,7); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 4,5,6,7,16,17,18,19,28,29,30,31,0,1,2,3); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 8,9,10,11,20,21,22,23,0,1,2,3,4,5,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,11,20,21,22,23); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,10,11,24,25,26,27); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,16,17,18,19,28,29,30,31); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c, v_float32x4& d) +{ + v_float32x4 s0(wasm_v128_load(ptr)); // a0 b0 c0 d0 + v_float32x4 s1(wasm_v128_load(ptr + 4)); // a1 b1 c1 d1 + v_float32x4 s2(wasm_v128_load(ptr + 8)); // a2 b2 c2 d2 + v_float32x4 s3(wasm_v128_load(ptr + 12)); // a3 b3 c3 d3 + + v_transpose4x4(s0, s1, s2, s3, a, b, c, d); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b) +{ + v128_t t0 = wasm_v128_load(ptr); // a0 b0 + v128_t t1 = wasm_v128_load(ptr + 2); // a1 b1 + + a.val = wasm_unpacklo_i64x2(t0, t1); + b.val = wasm_unpackhi_i64x2(t0, t1); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b, v_uint64x2& c) +{ + v128_t t0 = wasm_v128_load(ptr); // a0, b0 + v128_t t1 = wasm_v128_load(ptr + 2); // c0, a1 + v128_t t2 = wasm_v128_load(ptr + 4); // b1, c1 + + a.val = wasm_v8x16_shuffle(t0, t1, 0,1,2,3,4,5,6,7,24,25,26,27,28,29,30,31); + b.val = wasm_v8x16_shuffle(t0, t2, 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23); + c.val = wasm_v8x16_shuffle(t1, t2, 0,1,2,3,4,5,6,7,24,25,26,27,28,29,30,31); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, + v_uint64x2& b, v_uint64x2& c, v_uint64x2& d) +{ + v128_t t0 = wasm_v128_load(ptr); // a0 b0 + v128_t t1 = wasm_v128_load(ptr + 2); // c0 d0 + v128_t t2 = wasm_v128_load(ptr + 4); // a1 b1 + v128_t t3 = wasm_v128_load(ptr + 6); // c1 d1 + + a.val = wasm_unpacklo_i64x2(t0, t2); + b.val = wasm_unpackhi_i64x2(t0, t2); + c.val = wasm_unpacklo_i64x2(t1, t3); + d.val = wasm_unpackhi_i64x2(t1, t3); +} + +// store interleave + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i8x16(a.val, b.val); + v128_t v1 = wasm_unpackhi_i8x16(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 16, v1); +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,16,0,1,17,0,2,18,0,3,19,0,4,20,0,5); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 21,0,6,22,0,7,23,0,8,24,0,9,25,0,10,26); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 0,11,27,0,12,28,0,13,29,0,14,30,0,15,31,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,16,3,4,17,6,7,18,9,10,19,12,13,20,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 0,21,2,3,22,5,6,23,8,9,24,11,12,25,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 26,1,2,27,4,5,28,7,8,29,10,11,30,13,14,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 16, t11); + wasm_v128_store(ptr + 32, t12); +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, const v_uint8x16& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + v128_t u0 = wasm_unpacklo_i8x16(a.val, c.val); // a0 c0 a1 c1 ... + v128_t u1 = wasm_unpackhi_i8x16(a.val, c.val); // a8 c8 a9 c9 ... + v128_t u2 = wasm_unpacklo_i8x16(b.val, d.val); // b0 d0 b1 d1 ... + v128_t u3 = wasm_unpackhi_i8x16(b.val, d.val); // b8 d8 b9 d9 ... + + v128_t v0 = wasm_unpacklo_i8x16(u0, u2); // a0 b0 c0 d0 ... + v128_t v1 = wasm_unpackhi_i8x16(u0, u2); // a4 b4 c4 d4 ... + v128_t v2 = wasm_unpacklo_i8x16(u1, u3); // a8 b8 c8 d8 ... + v128_t v3 = wasm_unpackhi_i8x16(u1, u3); // a12 b12 c12 d12 ... + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 16, v1); + wasm_v128_store(ptr + 32, v2); + wasm_v128_store(ptr + 48, v3); +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i16x8(a.val, b.val); + v128_t v1 = wasm_unpackhi_i16x8(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 8, v1); +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, + const v_uint16x8& b, const v_uint16x8& c, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,1,16,17,0,0,2,3,18,19,0,0,4,5,20,21); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 0,0,6,7,22,23,0,0,8,9,24,25,0,0,10,11); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 26,27,0,0,12,13,28,29,0,0,14,15,30,31,0,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,2,3,16,17,6,7,8,9,18,19,12,13,14,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 20,21,2,3,4,5,22,23,8,9,10,11,24,25,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 0,1,26,27,4,5,6,7,28,29,10,11,12,13,30,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 8, t11); + wasm_v128_store(ptr + 16, t12); +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + const v_uint16x8& c, const v_uint16x8& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + v128_t u0 = wasm_unpacklo_i16x8(a.val, c.val); // a0 c0 a1 c1 ... + v128_t u1 = wasm_unpackhi_i16x8(a.val, c.val); // a4 c4 a5 c5 ... + v128_t u2 = wasm_unpacklo_i16x8(b.val, d.val); // b0 d0 b1 d1 ... + v128_t u3 = wasm_unpackhi_i16x8(b.val, d.val); // b4 d4 b5 d5 ... + + v128_t v0 = wasm_unpacklo_i16x8(u0, u2); // a0 b0 c0 d0 ... + v128_t v1 = wasm_unpackhi_i16x8(u0, u2); // a2 b2 c2 d2 ... + v128_t v2 = wasm_unpacklo_i16x8(u1, u3); // a4 b4 c4 d4 ... + v128_t v3 = wasm_unpackhi_i16x8(u1, u3); // a6 b6 c6 d6 ... + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 8, v1); + wasm_v128_store(ptr + 16, v2); + wasm_v128_store(ptr + 24, v3); +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i32x4(a.val, b.val); + v128_t v1 = wasm_unpackhi_i32x4(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 4, v1); +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,16,17,18,19,0,0,0,0,4,5,6,7); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 20,21,22,23,0,0,0,0,8,9,10,11,24,25,26,27); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 0,0,0,0,12,13,14,15,28,29,30,31,0,0,0,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,2,3,4,5,6,7,16,17,18,19,12,13,14,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 0,1,2,3,20,21,22,23,8,9,10,11,12,13,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 24,25,26,27,4,5,6,7,8,9,10,11,28,29,30,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 4, t11); + wasm_v128_store(ptr + 8, t12); +} + +inline void v_store_interleave(unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v_uint32x4 v0, v1, v2, v3; + v_transpose4x4(a, b, c, d, v0, v1, v2, v3); + + wasm_v128_store(ptr, v0.val); + wasm_v128_store(ptr + 4, v1.val); + wasm_v128_store(ptr + 8, v2.val); + wasm_v128_store(ptr + 12, v3.val); +} + +// 2-channel, float only +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i32x4(a.val, b.val); + v128_t v1 = wasm_unpackhi_i32x4(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 4, v1); +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,16,17,18,19,0,0,0,0,4,5,6,7); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 20,21,22,23,0,0,0,0,8,9,10,11,24,25,26,27); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 0,0,0,0,12,13,14,15,28,29,30,31,0,0,0,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,2,3,4,5,6,7,16,17,18,19,12,13,14,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 0,1,2,3,20,21,22,23,8,9,10,11,12,13,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 24,25,26,27,4,5,6,7,8,9,10,11,28,29,30,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 4, t11); + wasm_v128_store(ptr + 8, t12); +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v_float32x4 v0, v1, v2, v3; + v_transpose4x4(a, b, c, d, v0, v1, v2, v3); + + wasm_v128_store(ptr, v0.val); + wasm_v128_store(ptr + 4, v1.val); + wasm_v128_store(ptr + 8, v2.val); + wasm_v128_store(ptr + 12, v3.val); +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i64x2(a.val, b.val); + v128_t v1 = wasm_unpackhi_i64x2(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 2, v1); +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + v128_t v1 = wasm_v8x16_shuffle(a.val, c.val, 16,17,18,19,20,21,22,23,8,9,10,11,12,13,14,15); + v128_t v2 = wasm_v8x16_shuffle(b.val, c.val, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 2, v1); + wasm_v128_store(ptr + 4, v2); +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, const v_uint64x2& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i64x2(a.val, b.val); + v128_t v1 = wasm_unpacklo_i64x2(c.val, d.val); + v128_t v2 = wasm_unpackhi_i64x2(a.val, b.val); + v128_t v3 = wasm_unpackhi_i64x2(c.val, d.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 2, v1); + wasm_v128_store(ptr + 4, v2); + wasm_v128_store(ptr + 6, v3); +} + +#define OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int8x16, schar, s8, v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int16x8, short, s16, v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int32x4, int, s32, v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int64x2, int64, s64, v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_float64x2, double, f64, v_uint64x2, uint64, u64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(wasm_f32x4_convert_i32x4(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + double a_[2]; + wasm_v128_store(a_, a.val); + float c_[4]; + c_[0] = (float)(a_[0]); + c_[1] = (float)(a_[1]); + c_[2] = 0; + c_[3] = 0; + return v_float32x4(wasm_v128_load(c_)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + double a_[2], b_[2]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + float c_[4]; + c_[0] = (float)(a_[0]); + c_[1] = (float)(a_[1]); + c_[2] = (float)(b_[0]); + c_[3] = (float)(b_[1]); + return v_float32x4(wasm_v128_load(c_)); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ +#ifdef __wasm_unimplemented_simd128__ + v128_t p = v128_cvti32x4_i64x2(a.val); + return v_float64x2(wasm_f64x2_convert_i64x2(p)); +#else + int a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[0]); + c_[1] = (double)(a_[1]); + return v_float64x2(wasm_v128_load(c_)); +#endif +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ +#ifdef __wasm_unimplemented_simd128__ + v128_t p = v128_cvti32x4_i64x2_high(a.val); + return v_float64x2(wasm_f64x2_convert_i64x2(p)); +#else + int a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[2]); + c_[1] = (double)(a_[3]); + return v_float64x2(wasm_v128_load(c_)); +#endif +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + float a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[0]); + c_[1] = (double)(a_[1]); + return v_float64x2(wasm_v128_load(c_)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + float a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[2]); + c_[1] = (double)(a_[3]); + return v_float64x2(wasm_v128_load(c_)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ +#ifdef __wasm_unimplemented_simd128__ + return v_float64x2(wasm_f64x2_convert_i64x2(a.val)); +#else + int64 a_[2]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[0]); + c_[1] = (double)(a_[1]); + return v_float64x2(wasm_v128_load(c_)); +#endif +} + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]]); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[0]+1], tab[idx[1]], tab[idx[1]+1], tab[idx[2]], tab[idx[2]+1], tab[idx[3]], tab[idx[3]+1], + tab[idx[4]], tab[idx[4]+1], tab[idx[5]], tab[idx[5]+1], tab[idx[6]], tab[idx[6]+1], tab[idx[7]], tab[idx[7]+1]); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[0]+1], tab[idx[0]+2], tab[idx[0]+3], tab[idx[1]], tab[idx[1]+1], tab[idx[1]+2], tab[idx[1]+3], + tab[idx[2]], tab[idx[2]+1], tab[idx[2]+2], tab[idx[2]+3], tab[idx[3]], tab[idx[3]+1], tab[idx[3]+2], tab[idx[3]+3]); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((const schar *)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], + tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[0]+1], tab[idx[1]], tab[idx[1]+1], + tab[idx[2]], tab[idx[2]+1], tab[idx[3]], tab[idx[3]+1]); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[0]+1], tab[idx[0]+2], tab[idx[0]+3], + tab[idx[1]], tab[idx[1]+1], tab[idx[1]+2], tab[idx[1]+3]); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((const short *)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((const short *)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((const short *)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + return v_int32x4(tab[idx[0]], tab[idx[1]], + tab[idx[2]], tab[idx[3]]); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(tab[idx[0]], tab[idx[0]+1], + tab[idx[1]], tab[idx[1]+1]); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(wasm_v128_load(tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((const int *)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((const int *)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((const int *)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(wasm_v128_load(tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_pairs((const int *)tab, idx)); } +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_quads((const int *)tab, idx)); } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(wasm_v128_load(tab + idx[0])); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + return v_int32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)]); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + return v_float32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)]); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + return v_float64x2(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)]); +} + +// loads pairs from the table and deinterleaves them, e.g. returns: +// x = (tab[idxvec[0], tab[idxvec[1]], tab[idxvec[2]], tab[idxvec[3]]), +// y = (tab[idxvec[0]+1], tab[idxvec[1]+1], tab[idxvec[2]+1], tab[idxvec[3]+1]) +// note that the indices are float's indices, not the float-pair indices. +// in theory, this function can be used to implement bilinear interpolation, +// when idxvec are the offsets within the image. +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + x = v_float32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)]); + y = v_float32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)+1], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)+1], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)+1], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)+1]); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + v128_t xy0 = wasm_v128_load(tab + wasm_i32x4_extract_lane(idxvec.val, 0)); + v128_t xy1 = wasm_v128_load(tab + wasm_i32x4_extract_lane(idxvec.val, 1)); + x.val = wasm_unpacklo_i64x2(xy0, xy1); + y.val = wasm_unpacklo_i64x2(xy0, xy1); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + return v_int8x16(wasm_v8x16_shuffle(vec.val, vec.val, 0,2,1,3,4,6,5,7,8,10,9,11,12,14,13,15)); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + return v_int8x16(wasm_v8x16_shuffle(vec.val, vec.val, 0,4,1,5,2,6,3,7,8,12,9,13,10,14,11,15)); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + return v_int16x8(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15)); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + return v_int16x8(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,8,9,2,3,10,11,4,5,12,13,6,7,14,15)); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + return v_int32x4(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,3,8,9,10,11,4,5,6,7,12,13,14,15)); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) +{ + return v_float32x4(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,3,8,9,10,11,4,5,6,7,12,13,14,15)); +} + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + return v_int8x16(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,4,5,6,8,9,10,12,13,14,16,16,16,16)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + return v_int16x8(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,3,4,5,8,9,10,11,12,13,14,15,6,7)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +template +inline typename _Tp::lane_type v_extract_n(const _Tp& a) +{ + return v_rotate_right(a).get0(); +} + +template +inline v_uint32x4 v_broadcast_element(const v_uint32x4& a) +{ + return v_setall_u32(v_extract_n(a)); +} +template +inline v_int32x4 v_broadcast_element(const v_int32x4& a) +{ + return v_setall_s32(v_extract_n(a)); +} +template +inline v_float32x4 v_broadcast_element(const v_float32x4& a) +{ + return v_setall_f32(v_extract_n(a)); +} + + +////////////// FP16 support /////////////////////////// + +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + float a[4]; + for (int i = 0; i < 4; i++) + a[i] = ptr[i]; + return v_float32x4(wasm_v128_load(a)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + double v_[4]; + wasm_v128_store(v_, v.val); + ptr[0] = float16_t(v_[0]); + ptr[1] = float16_t(v_[1]); + ptr[2] = float16_t(v_[2]); + ptr[3] = float16_t(v_[3]); +} + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/msa_macros.h b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/msa_macros.h new file mode 100644 index 0000000..bd6ddb1 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/msa_macros.h @@ -0,0 +1,1558 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_HAL_MSA_MACROS_H +#define OPENCV_CORE_HAL_MSA_MACROS_H + +#ifdef __mips_msa +#include "msa.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Define 64 bits vector types */ +typedef signed char v8i8 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned char v8u8 __attribute__ ((vector_size(8), aligned(8))); +typedef short v4i16 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned short v4u16 __attribute__ ((vector_size(8), aligned(8))); +typedef int v2i32 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned int v2u32 __attribute__ ((vector_size(8), aligned(8))); +typedef long long v1i64 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned long long v1u64 __attribute__ ((vector_size(8), aligned(8))); +typedef float v2f32 __attribute__ ((vector_size(8), aligned(8))); +typedef double v1f64 __attribute__ ((vector_size(8), aligned(8))); + + +/* Load values from the given memory a 64-bit vector. */ +#define msa_ld1_s8(__a) (*((v8i8*)(__a))) +#define msa_ld1_s16(__a) (*((v4i16*)(__a))) +#define msa_ld1_s32(__a) (*((v2i32*)(__a))) +#define msa_ld1_s64(__a) (*((v1i64*)(__a))) +#define msa_ld1_u8(__a) (*((v8u8*)(__a))) +#define msa_ld1_u16(__a) (*((v4u16*)(__a))) +#define msa_ld1_u32(__a) (*((v2u32*)(__a))) +#define msa_ld1_u64(__a) (*((v1u64*)(__a))) +#define msa_ld1_f32(__a) (*((v2f32*)(__a))) +#define msa_ld1_f64(__a) (*((v1f64*)(__a))) + +/* Load values from the given memory address to a 128-bit vector */ +#define msa_ld1q_s8(__a) ((v16i8)__builtin_msa_ld_b(__a, 0)) +#define msa_ld1q_s16(__a) ((v8i16)__builtin_msa_ld_h(__a, 0)) +#define msa_ld1q_s32(__a) ((v4i32)__builtin_msa_ld_w(__a, 0)) +#define msa_ld1q_s64(__a) ((v2i64)__builtin_msa_ld_d(__a, 0)) +#define msa_ld1q_u8(__a) ((v16u8)__builtin_msa_ld_b(__a, 0)) +#define msa_ld1q_u16(__a) ((v8u16)__builtin_msa_ld_h(__a, 0)) +#define msa_ld1q_u32(__a) ((v4u32)__builtin_msa_ld_w(__a, 0)) +#define msa_ld1q_u64(__a) ((v2u64)__builtin_msa_ld_d(__a, 0)) +#define msa_ld1q_f32(__a) ((v4f32)__builtin_msa_ld_w(__a, 0)) +#define msa_ld1q_f64(__a) ((v2f64)__builtin_msa_ld_d(__a, 0)) + +/* Store 64bits vector elements values to the given memory address. */ +#define msa_st1_s8(__a, __b) (*((v8i8*)(__a)) = __b) +#define msa_st1_s16(__a, __b) (*((v4i16*)(__a)) = __b) +#define msa_st1_s32(__a, __b) (*((v2i32*)(__a)) = __b) +#define msa_st1_s64(__a, __b) (*((v1i64*)(__a)) = __b) +#define msa_st1_u8(__a, __b) (*((v8u8*)(__a)) = __b) +#define msa_st1_u16(__a, __b) (*((v4u16*)(__a)) = __b) +#define msa_st1_u32(__a, __b) (*((v2u32*)(__a)) = __b) +#define msa_st1_u64(__a, __b) (*((v1u64*)(__a)) = __b) +#define msa_st1_f32(__a, __b) (*((v2f32*)(__a)) = __b) +#define msa_st1_f64(__a, __b) (*((v1f64*)(__a)) = __b) + +/* Store the values of elements in the 128 bits vector __a to the given memory address __a. */ +#define msa_st1q_s8(__a, __b) (__builtin_msa_st_b((v16i8)(__b), __a, 0)) +#define msa_st1q_s16(__a, __b) (__builtin_msa_st_h((v8i16)(__b), __a, 0)) +#define msa_st1q_s32(__a, __b) (__builtin_msa_st_w((v4i32)(__b), __a, 0)) +#define msa_st1q_s64(__a, __b) (__builtin_msa_st_d((v2i64)(__b), __a, 0)) +#define msa_st1q_u8(__a, __b) (__builtin_msa_st_b((v16i8)(__b), __a, 0)) +#define msa_st1q_u16(__a, __b) (__builtin_msa_st_h((v8i16)(__b), __a, 0)) +#define msa_st1q_u32(__a, __b) (__builtin_msa_st_w((v4i32)(__b), __a, 0)) +#define msa_st1q_u64(__a, __b) (__builtin_msa_st_d((v2i64)(__b), __a, 0)) +#define msa_st1q_f32(__a, __b) (__builtin_msa_st_w((v4i32)(__b), __a, 0)) +#define msa_st1q_f64(__a, __b) (__builtin_msa_st_d((v2i64)(__b), __a, 0)) + +/* Store the value of the element with the index __c in vector __a to the given memory address __a. */ +#define msa_st1_lane_s8(__a, __b, __c) (*((int8_t*)(__a)) = __b[__c]) +#define msa_st1_lane_s16(__a, __b, __c) (*((int16_t*)(__a)) = __b[__c]) +#define msa_st1_lane_s32(__a, __b, __c) (*((int32_t*)(__a)) = __b[__c]) +#define msa_st1_lane_s64(__a, __b, __c) (*((int64_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u8(__a, __b, __c) (*((uint8_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u16(__a, __b, __c) (*((uint16_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u32(__a, __b, __c) (*((uint32_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u64(__a, __b, __c) (*((uint64_t*)(__a)) = __b[__c]) +#define msa_st1_lane_f32(__a, __b, __c) (*((float*)(__a)) = __b[__c]) +#define msa_st1_lane_f64(__a, __b, __c) (*((double*)(__a)) = __b[__c]) +#define msa_st1q_lane_s8(__a, __b, __c) (*((int8_t*)(__a)) = (int8_t)__builtin_msa_copy_s_b(__b, __c)) +#define msa_st1q_lane_s16(__a, __b, __c) (*((int16_t*)(__a)) = (int16_t)__builtin_msa_copy_s_h(__b, __c)) +#define msa_st1q_lane_s32(__a, __b, __c) (*((int32_t*)(__a)) = __builtin_msa_copy_s_w(__b, __c)) +#define msa_st1q_lane_s64(__a, __b, __c) (*((int64_t*)(__a)) = __builtin_msa_copy_s_d(__b, __c)) +#define msa_st1q_lane_u8(__a, __b, __c) (*((uint8_t*)(__a)) = (uint8_t)__builtin_msa_copy_u_b((v16i8)(__b), __c)) +#define msa_st1q_lane_u16(__a, __b, __c) (*((uint16_t*)(__a)) = (uint16_t)__builtin_msa_copy_u_h((v8i16)(__b), __c)) +#define msa_st1q_lane_u32(__a, __b, __c) (*((uint32_t*)(__a)) = __builtin_msa_copy_u_w((v4i32)(__b), __c)) +#define msa_st1q_lane_u64(__a, __b, __c) (*((uint64_t*)(__a)) = __builtin_msa_copy_u_d((v2i64)(__b), __c)) +#define msa_st1q_lane_f32(__a, __b, __c) (*((float*)(__a)) = __b[__c]) +#define msa_st1q_lane_f64(__a, __b, __c) (*((double*)(__a)) = __b[__c]) + +/* Duplicate elements for 64-bit doubleword vectors */ +#define msa_dup_n_s8(__a) ((v8i8)__builtin_msa_copy_s_d((v2i64)__builtin_msa_fill_b((int32_t)(__a)), 0)) +#define msa_dup_n_s16(__a) ((v4i16)__builtin_msa_copy_s_d((v2i64)__builtin_msa_fill_h((int32_t)(__a)), 0)) +#define msa_dup_n_s32(__a) ((v2i32){__a, __a}) +#define msa_dup_n_s64(__a) ((v1i64){__a}) +#define msa_dup_n_u8(__a) ((v8u8)__builtin_msa_copy_u_d((v2i64)__builtin_msa_fill_b((int32_t)(__a)), 0)) +#define msa_dup_n_u16(__a) ((v4u16)__builtin_msa_copy_u_d((v2i64)__builtin_msa_fill_h((int32_t)(__a)), 0)) +#define msa_dup_n_u32(__a) ((v2u32){__a, __a}) +#define msa_dup_n_u64(__a) ((v1u64){__a}) +#define msa_dup_n_f32(__a) ((v2f32){__a, __a}) +#define msa_dup_n_f64(__a) ((v1f64){__a}) + +/* Duplicate elements for 128-bit quadword vectors */ +#define msa_dupq_n_s8(__a) (__builtin_msa_fill_b((int32_t)(__a))) +#define msa_dupq_n_s16(__a) (__builtin_msa_fill_h((int32_t)(__a))) +#define msa_dupq_n_s32(__a) (__builtin_msa_fill_w((int32_t)(__a))) +#define msa_dupq_n_s64(__a) (__builtin_msa_fill_d((int64_t)(__a))) +#define msa_dupq_n_u8(__a) ((v16u8)__builtin_msa_fill_b((int32_t)(__a))) +#define msa_dupq_n_u16(__a) ((v8u16)__builtin_msa_fill_h((int32_t)(__a))) +#define msa_dupq_n_u32(__a) ((v4u32)__builtin_msa_fill_w((int32_t)(__a))) +#define msa_dupq_n_u64(__a) ((v2u64)__builtin_msa_fill_d((int64_t)(__a))) +#define msa_dupq_n_f32(__a) ((v4f32){__a, __a, __a, __a}) +#define msa_dupq_n_f64(__a) ((v2f64){__a, __a}) +#define msa_dupq_lane_s8(__a, __b) (__builtin_msa_splat_b(__a, __b)) +#define msa_dupq_lane_s16(__a, __b) (__builtin_msa_splat_h(__a, __b)) +#define msa_dupq_lane_s32(__a, __b) (__builtin_msa_splat_w(__a, __b)) +#define msa_dupq_lane_s64(__a, __b) (__builtin_msa_splat_d(__a, __b)) +#define msa_dupq_lane_u8(__a, __b) ((v16u8)__builtin_msa_splat_b((v16i8)(__a), __b)) +#define msa_dupq_lane_u16(__a, __b) ((v8u16)__builtin_msa_splat_h((v8i16)(__a), __b)) +#define msa_dupq_lane_u32(__a, __b) ((v4u32)__builtin_msa_splat_w((v4i32)(__a), __b)) +#define msa_dupq_lane_u64(__a, __b) ((v2u64)__builtin_msa_splat_d((v2i64)(__a), __b)) + +/* Create a 64 bits vector */ +#define msa_create_s8(__a) ((v8i8)((uint64_t)(__a))) +#define msa_create_s16(__a) ((v4i16)((uint64_t)(__a))) +#define msa_create_s32(__a) ((v2i32)((uint64_t)(__a))) +#define msa_create_s64(__a) ((v1i64)((uint64_t)(__a))) +#define msa_create_u8(__a) ((v8u8)((uint64_t)(__a))) +#define msa_create_u16(__a) ((v4u16)((uint64_t)(__a))) +#define msa_create_u32(__a) ((v2u32)((uint64_t)(__a))) +#define msa_create_u64(__a) ((v1u64)((uint64_t)(__a))) +#define msa_create_f32(__a) ((v2f32)((uint64_t)(__a))) +#define msa_create_f64(__a) ((v1f64)((uint64_t)(__a))) + +/* Sign extends or zero extends each element in a 64 bits vector to twice its original length, and places the results in a 128 bits vector. */ +/*Transform v8i8 to v8i16*/ +#define msa_movl_s8(__a) \ +((v8i16){(__a)[0], (__a)[1], (__a)[2], (__a)[3], \ + (__a)[4], (__a)[5], (__a)[6], (__a)[7]}) + +/*Transform v8u8 to v8u16*/ +#define msa_movl_u8(__a) \ +((v8u16){(__a)[0], (__a)[1], (__a)[2], (__a)[3], \ + (__a)[4], (__a)[5], (__a)[6], (__a)[7]}) + +/*Transform v4i16 to v8i16*/ +#define msa_movl_s16(__a) ((v4i32){(__a)[0], (__a)[1], (__a)[2], (__a)[3]}) + +/*Transform v2i32 to v4i32*/ +#define msa_movl_s32(__a) ((v2i64){(__a)[0], (__a)[1]}) + +/*Transform v4u16 to v8u16*/ +#define msa_movl_u16(__a) ((v4u32){(__a)[0], (__a)[1], (__a)[2], (__a)[3]}) + +/*Transform v2u32 to v4u32*/ +#define msa_movl_u32(__a) ((v2u64){(__a)[0], (__a)[1]}) + +/* Copies the least significant half of each element of a 128 bits vector into the corresponding elements of a 64 bits vector. */ +#define msa_movn_s16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)(__a)); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_movn_s32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)(__a)); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_movn_s64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)(__a)); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_movn_u16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)(__a)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_movn_u32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)(__a)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_movn_u64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)(__a)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* qmovn */ +#define msa_qmovn_s16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_s_h((v8i16)(__a), 7)); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_s32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_s_w((v4i32)(__a), 15)); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_s64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_s_d((v2i64)(__a), 31)); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_u16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_u_h((v8u16)(__a), 7)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_u32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_u_w((v4u32)(__a), 15)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_u64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_u_d((v2u64)(__a), 31)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* qmovun */ +#define msa_qmovun_s16(__a) \ +({ \ + v8i16 __d = __builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a)); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_u_h((v8u16)__d, 7)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qmovun_s32(__a) \ +({ \ + v4i32 __d = __builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a)); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_u_w((v4u32)__d, 15)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qmovun_s64(__a) \ +({ \ + v2i64 __d = __builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a)); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_u_d((v2u64)__d, 31)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, and places the results in a 64 bits vector. */ +#define msa_shrn_n_s16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srai_h((v8i16)(__a), (int)(__b))); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_s32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srai_w((v4i32)(__a), (int)(__b))); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_s64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srai_d((v2i64)(__a), (int)(__b))); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_u16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srli_h((v8i16)(__a), (int)(__b))); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_u32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srli_w((v4i32)(__a), (int)(__b))); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_u64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srli_d((v2i64)(__a), (int)(__b))); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, and places the results in a 64 bits vector. */ +#define msa_rshrn_n_s16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srari_h((v8i16)(__a), (int)__b)); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_s32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srari_w((v4i32)(__a), (int)__b)); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_s64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srari_d((v2i64)(__a), (int)__b)); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_u16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srlri_h((v8i16)(__a), (int)__b)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_u32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srlri_w((v4i32)(__a), (int)__b)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_u64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srlri_d((v2i64)(__a), (int)__b)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, saturate the results and them in a 64 bits vector. */ +#define msa_qrshrn_n_s16(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_sat_s_h(__builtin_msa_srari_h((v8i16)(__a), (int)(__b)), 7); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__d); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_s32(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_sat_s_w(__builtin_msa_srari_w((v4i32)(__a), (int)(__b)), 15); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__d); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_s64(__a, __b) \ +({ \ + v2i64 __d = __builtin_msa_sat_s_d(__builtin_msa_srari_d((v2i64)(__a), (int)(__b)), 31); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__d); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_u16(__a, __b) \ +({ \ + v8u16 __d = __builtin_msa_sat_u_h((v8u16)__builtin_msa_srlri_h((v8i16)(__a), (int)(__b)), 7); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__d); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_u32(__a, __b) \ +({ \ + v4u32 __d = __builtin_msa_sat_u_w((v4u32)__builtin_msa_srlri_w((v4i32)(__a), (int)(__b)), 15); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__d); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_u64(__a, __b) \ +({ \ + v2u64 __d = __builtin_msa_sat_u_d((v2u64)__builtin_msa_srlri_d((v2i64)(__a), (int)(__b)), 31); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__d); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, saturate the results and them in a 64 bits vector. + Input is signed and output is unsigned. */ +#define msa_qrshrun_n_s16(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_srlri_h(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a)), (int)(__b)); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_u_h((v8u16)__d, 7)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrun_n_s32(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_srlri_w(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a)), (int)(__b)); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_u_w((v4u32)__d, 15)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrun_n_s64(__a, __b) \ +({ \ + v2i64 __d = __builtin_msa_srlri_d(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a)), (int)(__b)); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_u_d((v2u64)__d, 31)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +/* pack */ +#define msa_pack_s16(__a, __b) (__builtin_msa_pckev_b((v16i8)(__b), (v16i8)(__a))) +#define msa_pack_s32(__a, __b) (__builtin_msa_pckev_h((v8i16)(__b), (v8i16)(__a))) +#define msa_pack_s64(__a, __b) (__builtin_msa_pckev_w((v4i32)(__b), (v4i32)(__a))) +#define msa_pack_u16(__a, __b) ((v16u8)__builtin_msa_pckev_b((v16i8)(__b), (v16i8)(__a))) +#define msa_pack_u32(__a, __b) ((v8u16)__builtin_msa_pckev_h((v8i16)(__b), (v8i16)(__a))) +#define msa_pack_u64(__a, __b) ((v4u32)__builtin_msa_pckev_w((v4i32)(__b), (v4i32)(__a))) + +/* qpack */ +#define msa_qpack_s16(__a, __b) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_s_h((v8i16)(__b), 7), (v16i8)__builtin_msa_sat_s_h((v8i16)(__a), 7))) +#define msa_qpack_s32(__a, __b) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_s_w((v4i32)(__b), 15), (v8i16)__builtin_msa_sat_s_w((v4i32)(__a), 15))) +#define msa_qpack_s64(__a, __b) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_s_d((v2i64)(__b), 31), (v4i32)__builtin_msa_sat_s_d((v2i64)(__a), 31))) +#define msa_qpack_u16(__a, __b) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)(__b), 7), (v16i8)__builtin_msa_sat_u_h((v8u16)(__a), 7))) +#define msa_qpack_u32(__a, __b) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)(__b), 15), (v8i16)__builtin_msa_sat_u_w((v4u32)(__a), 15))) +#define msa_qpack_u64(__a, __b) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)(__b), 31), (v4i32)__builtin_msa_sat_u_d((v2u64)(__a), 31))) + +/* qpacku */ +#define msa_qpacku_s16(__a, __b) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__b))), 7), \ + (v16i8)__builtin_msa_sat_u_h((v8u16)(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a))), 7))) +#define msa_qpacku_s32(__a, __b) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__b))), 15), \ + (v8i16)__builtin_msa_sat_u_w((v4u32)(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a))), 15))) +#define msa_qpacku_s64(__a, __b) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__b))), 31), \ + (v4i32)__builtin_msa_sat_u_d((v2u64)(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a))), 31))) + +/* packr */ +#define msa_packr_s16(__a, __b, __c) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_srai_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srai_h((v8i16)(__a), (int)(__c)))) +#define msa_packr_s32(__a, __b, __c) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_srai_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srai_w((v4i32)(__a), (int)(__c)))) +#define msa_packr_s64(__a, __b, __c) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_srai_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srai_d((v2i64)(__a), (int)(__c)))) +#define msa_packr_u16(__a, __b, __c) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_srli_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srli_h((v8i16)(__a), (int)(__c)))) +#define msa_packr_u32(__a, __b, __c) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_srli_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srli_w((v4i32)(__a), (int)(__c)))) +#define msa_packr_u64(__a, __b, __c) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_srli_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srli_d((v2i64)(__a), (int)(__c)))) + +/* rpackr */ +#define msa_rpackr_s16(__a, __b, __c) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_srari_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srari_h((v8i16)(__a), (int)(__c)))) +#define msa_rpackr_s32(__a, __b, __c) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_srari_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srari_w((v4i32)(__a), (int)(__c)))) +#define msa_rpackr_s64(__a, __b, __c) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_srari_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srari_d((v2i64)(__a), (int)(__c)))) +#define msa_rpackr_u16(__a, __b, __c) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_srlri_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srlri_h((v8i16)(__a), (int)(__c)))) +#define msa_rpackr_u32(__a, __b, __c) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_srlri_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srlri_w((v4i32)(__a), (int)(__c)))) +#define msa_rpackr_u64(__a, __b, __c) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_srlri_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srlri_d((v2i64)(__a), (int)(__c)))) + +/* qrpackr */ +#define msa_qrpackr_s16(__a, __b, __c) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_s_h(__builtin_msa_srari_h((v8i16)(__b), (int)(__c)), 7), \ + (v16i8)__builtin_msa_sat_s_h(__builtin_msa_srari_h((v8i16)(__a), (int)(__c)), 7))) +#define msa_qrpackr_s32(__a, __b, __c) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_s_w(__builtin_msa_srari_w((v4i32)(__b), (int)(__c)), 15), \ + (v8i16)__builtin_msa_sat_s_w(__builtin_msa_srari_w((v4i32)(__a), (int)(__c)), 15))) +#define msa_qrpackr_s64(__a, __b, __c) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_s_d(__builtin_msa_srari_d((v2i64)(__b), (int)(__c)), 31), \ + (v4i32)__builtin_msa_sat_s_d(__builtin_msa_srari_d((v2i64)(__a), (int)(__c)), 31))) +#define msa_qrpackr_u16(__a, __b, __c) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)__builtin_msa_srlri_h((v8i16)(__b), (int)(__c)), 7), \ + (v16i8)__builtin_msa_sat_u_h((v8u16)__builtin_msa_srlri_h((v8i16)(__a), (int)(__c)), 7))) +#define msa_qrpackr_u32(__a, __b, __c) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)__builtin_msa_srlri_w((v4i32)(__b), (int)(__c)), 15), \ + (v8i16)__builtin_msa_sat_u_w((v4u32)__builtin_msa_srlri_w((v4i32)(__a), (int)(__c)), 15))) +#define msa_qrpackr_u64(__a, __b, __c) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)__builtin_msa_srlri_d((v2i64)(__b), (int)(__c)), 31), \ + (v4i32)__builtin_msa_sat_u_d((v2u64)__builtin_msa_srlri_d((v2i64)(__a), (int)(__c)), 31))) + +/* qrpackru */ +#define msa_qrpackru_s16(__a, __b, __c) \ +({ \ + v8i16 __d = __builtin_msa_srlri_h(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a)), (int)(__c)); \ + v8i16 __e = __builtin_msa_srlri_h(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__b)), (int)(__c)); \ + (v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)__e, 7), (v16i8)__builtin_msa_sat_u_h((v8u16)__d, 7)); \ +}) + +#define msa_qrpackru_s32(__a, __b, __c) \ +({ \ + v4i32 __d = __builtin_msa_srlri_w(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a)), (int)(__c)); \ + v4i32 __e = __builtin_msa_srlri_w(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__b)), (int)(__c)); \ + (v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)__e, 15), (v8i16)__builtin_msa_sat_u_w((v4u32)__d, 15)); \ +}) + +#define msa_qrpackru_s64(__a, __b, __c) \ +({ \ + v2i64 __d = __builtin_msa_srlri_d(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a)), (int)(__c)); \ + v2i64 __e = __builtin_msa_srlri_d(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__b)), (int)(__c)); \ + (v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)__e, 31), (v4i32)__builtin_msa_sat_u_d((v2u64)__d, 31)); \ +}) + +/* Minimum values between corresponding elements in the two vectors are written to the returned vector. */ +#define msa_minq_s8(__a, __b) (__builtin_msa_min_s_b(__a, __b)) +#define msa_minq_s16(__a, __b) (__builtin_msa_min_s_h(__a, __b)) +#define msa_minq_s32(__a, __b) (__builtin_msa_min_s_w(__a, __b)) +#define msa_minq_s64(__a, __b) (__builtin_msa_min_s_d(__a, __b)) +#define msa_minq_u8(__a, __b) ((v16u8)__builtin_msa_min_u_b(__a, __b)) +#define msa_minq_u16(__a, __b) ((v8u16)__builtin_msa_min_u_h(__a, __b)) +#define msa_minq_u32(__a, __b) ((v4u32)__builtin_msa_min_u_w(__a, __b)) +#define msa_minq_u64(__a, __b) ((v2u64)__builtin_msa_min_u_d(__a, __b)) +#define msa_minq_f32(__a, __b) (__builtin_msa_fmin_w(__a, __b)) +#define msa_minq_f64(__a, __b) (__builtin_msa_fmin_d(__a, __b)) + +/* Maximum values between corresponding elements in the two vectors are written to the returned vector. */ +#define msa_maxq_s8(__a, __b) (__builtin_msa_max_s_b(__a, __b)) +#define msa_maxq_s16(__a, __b) (__builtin_msa_max_s_h(__a, __b)) +#define msa_maxq_s32(__a, __b) (__builtin_msa_max_s_w(__a, __b)) +#define msa_maxq_s64(__a, __b) (__builtin_msa_max_s_d(__a, __b)) +#define msa_maxq_u8(__a, __b) ((v16u8)__builtin_msa_max_u_b(__a, __b)) +#define msa_maxq_u16(__a, __b) ((v8u16)__builtin_msa_max_u_h(__a, __b)) +#define msa_maxq_u32(__a, __b) ((v4u32)__builtin_msa_max_u_w(__a, __b)) +#define msa_maxq_u64(__a, __b) ((v2u64)__builtin_msa_max_u_d(__a, __b)) +#define msa_maxq_f32(__a, __b) (__builtin_msa_fmax_w(__a, __b)) +#define msa_maxq_f64(__a, __b) (__builtin_msa_fmax_d(__a, __b)) + +/* Vector type reinterpretion */ +#define MSA_TPV_REINTERPRET(_Tpv, Vec) ((_Tpv)(Vec)) + +/* Add the odd elements in vector __a with the even elements in vector __b to double width elements in the returned vector. */ +/* v8i16 msa_hadd_s16 ((v16i8)__a, (v16i8)__b) */ +#define msa_hadd_s16(__a, __b) (__builtin_msa_hadd_s_h((v16i8)(__a), (v16i8)(__b))) +/* v4i32 msa_hadd_s32 ((v8i16)__a, (v8i16)__b) */ +#define msa_hadd_s32(__a, __b) (__builtin_msa_hadd_s_w((v8i16)(__a), (v8i16)(__b))) +/* v2i64 msa_hadd_s64 ((v4i32)__a, (v4i32)__b) */ +#define msa_hadd_s64(__a, __b) (__builtin_msa_hadd_s_d((v4i32)(__a), (v4i32)(__b))) + +/* Copy even elements in __a to the left half and even elements in __b to the right half and return the result vector. */ +#define msa_pckev_s8(__a, __b) (__builtin_msa_pckev_b((v16i8)(__a), (v16i8)(__b))) +#define msa_pckev_s16(__a, __b) (__builtin_msa_pckev_h((v8i16)(__a), (v8i16)(__b))) +#define msa_pckev_s32(__a, __b) (__builtin_msa_pckev_w((v4i32)(__a), (v4i32)(__b))) +#define msa_pckev_s64(__a, __b) (__builtin_msa_pckev_d((v2i64)(__a), (v2i64)(__b))) + +/* Copy even elements in __a to the left half and even elements in __b to the right half and return the result vector. */ +#define msa_pckod_s8(__a, __b) (__builtin_msa_pckod_b((v16i8)(__a), (v16i8)(__b))) +#define msa_pckod_s16(__a, __b) (__builtin_msa_pckod_h((v8i16)(__a), (v8i16)(__b))) +#define msa_pckod_s32(__a, __b) (__builtin_msa_pckod_w((v4i32)(__a), (v4i32)(__b))) +#define msa_pckod_s64(__a, __b) (__builtin_msa_pckod_d((v2i64)(__a), (v2i64)(__b))) + +#ifdef _MIPSEB +#define LANE_IMM0_1(x) (0b1 - ((x) & 0b1)) +#define LANE_IMM0_3(x) (0b11 - ((x) & 0b11)) +#define LANE_IMM0_7(x) (0b111 - ((x) & 0b111)) +#define LANE_IMM0_15(x) (0b1111 - ((x) & 0b1111)) +#else +#define LANE_IMM0_1(x) ((x) & 0b1) +#define LANE_IMM0_3(x) ((x) & 0b11) +#define LANE_IMM0_7(x) ((x) & 0b111) +#define LANE_IMM0_15(x) ((x) & 0b1111) +#endif + +#define msa_get_lane_u8(__a, __b) ((uint8_t)(__a)[LANE_IMM0_7(__b)]) +#define msa_get_lane_s8(__a, __b) ((int8_t)(__a)[LANE_IMM0_7(__b)]) +#define msa_get_lane_u16(__a, __b) ((uint16_t)(__a)[LANE_IMM0_3(__b)]) +#define msa_get_lane_s16(__a, __b) ((int16_t)(__a)[LANE_IMM0_3(__b)]) +#define msa_get_lane_u32(__a, __b) ((uint32_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_s32(__a, __b) ((int32_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_f32(__a, __b) ((float)(__a)[LANE_IMM0_3(__b)]) +#define msa_get_lane_s64(__a, __b) ((int64_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_u64(__a, __b) ((uint64_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_f64(__a, __b) ((double)(__a)[LANE_IMM0_1(__b)]) +#define msa_getq_lane_u8(__a, imm0_15) ((uint8_t)__builtin_msa_copy_u_b((v16i8)(__a), imm0_15)) +#define msa_getq_lane_s8(__a, imm0_15) ((int8_t)__builtin_msa_copy_s_b(__a, imm0_15)) +#define msa_getq_lane_u16(__a, imm0_7) ((uint16_t)__builtin_msa_copy_u_h((v8i16)(__a), imm0_7)) +#define msa_getq_lane_s16(__a, imm0_7) ((int16_t)__builtin_msa_copy_s_h(__a, imm0_7)) +#define msa_getq_lane_u32(__a, imm0_3) __builtin_msa_copy_u_w((v4i32)(__a), imm0_3) +#define msa_getq_lane_s32 __builtin_msa_copy_s_w +#define msa_getq_lane_f32(__a, __b) ((float)(__a)[LANE_IMM0_3(__b)]) +#define msa_getq_lane_f64(__a, __b) ((double)(__a)[LANE_IMM0_1(__b)]) +#if (__mips == 64) +#define msa_getq_lane_u64(__a, imm0_1) __builtin_msa_copy_u_d((v2i64)(__a), imm0_1) +#define msa_getq_lane_s64 __builtin_msa_copy_s_d +#else +#define msa_getq_lane_u64(__a, imm0_1) ((uint64_t)(__a)[LANE_IMM0_1(imm0_1)]) +#define msa_getq_lane_s64(__a, imm0_1) ((int64_t)(__a)[LANE_IMM0_1(imm0_1)]) +#endif + +/* combine */ +#if (__mips == 64) +#define __COMBINE_64_64(__TYPE, a, b) ((__TYPE)((v2u64){((v1u64)(a))[0], ((v1u64)(b))[0]})) +#else +#define __COMBINE_64_64(__TYPE, a, b) ((__TYPE)((v4u32){((v2u32)(a))[0], ((v2u32)(a))[1], \ + ((v2u32)(b))[0], ((v2u32)(b))[1]})) +#endif + +/* v16i8 msa_combine_s8 (v8i8 __a, v8i8 __b) */ +#define msa_combine_s8(__a, __b) __COMBINE_64_64(v16i8, __a, __b) + +/* v8i16 msa_combine_s16(v4i16 __a, v4i16 __b) */ +#define msa_combine_s16(__a, __b) __COMBINE_64_64(v8i16, __a, __b) + +/* v4i32 msa_combine_s32(v2i32 __a, v2i32 __b) */ +#define msa_combine_s32(__a, __b) __COMBINE_64_64(v4i32, __a, __b) + +/* v2i64 msa_combine_s64(v1i64 __a, v1i64 __b) */ +#define msa_combine_s64(__a, __b) __COMBINE_64_64(v2i64, __a, __b) + +/* v4f32 msa_combine_f32(v2f32 __a, v2f32 __b) */ +#define msa_combine_f32(__a, __b) __COMBINE_64_64(v4f32, __a, __b) + +/* v16u8 msa_combine_u8(v8u8 __a, v8u8 __b) */ +#define msa_combine_u8(__a, __b) __COMBINE_64_64(v16u8, __a, __b) + +/* v8u16 msa_combine_u16(v4u16 __a, v4u16 __b) */ +#define msa_combine_u16(__a, __b) __COMBINE_64_64(v8u16, __a, __b) + +/* v4u32 msa_combine_u32(v2u32 __a, v2u32 __b) */ +#define msa_combine_u32(__a, __b) __COMBINE_64_64(v4u32, __a, __b) + +/* v2u64 msa_combine_u64(v1u64 __a, v1u64 __b) */ +#define msa_combine_u64(__a, __b) __COMBINE_64_64(v2u64, __a, __b) + +/* v2f64 msa_combine_f64(v1f64 __a, v1f64 __b) */ +#define msa_combine_f64(__a, __b) __COMBINE_64_64(v2f64, __a, __b) + +/* get_low, get_high */ +#if (__mips == 64) +#define __GET_LOW(__TYPE, a) ((__TYPE)((v1u64)(__builtin_msa_copy_u_d((v2i64)(a), 0)))) +#define __GET_HIGH(__TYPE, a) ((__TYPE)((v1u64)(__builtin_msa_copy_u_d((v2i64)(a), 1)))) +#else +#define __GET_LOW(__TYPE, a) ((__TYPE)(((v2u64)(a))[0])) +#define __GET_HIGH(__TYPE, a) ((__TYPE)(((v2u64)(a))[1])) +#endif + +/* v8i8 msa_get_low_s8(v16i8 __a) */ +#define msa_get_low_s8(__a) __GET_LOW(v8i8, __a) + +/* v4i16 msa_get_low_s16(v8i16 __a) */ +#define msa_get_low_s16(__a) __GET_LOW(v4i16, __a) + +/* v2i32 msa_get_low_s32(v4i32 __a) */ +#define msa_get_low_s32(__a) __GET_LOW(v2i32, __a) + +/* v1i64 msa_get_low_s64(v2i64 __a) */ +#define msa_get_low_s64(__a) __GET_LOW(v1i64, __a) + +/* v8u8 msa_get_low_u8(v16u8 __a) */ +#define msa_get_low_u8(__a) __GET_LOW(v8u8, __a) + +/* v4u16 msa_get_low_u16(v8u16 __a) */ +#define msa_get_low_u16(__a) __GET_LOW(v4u16, __a) + +/* v2u32 msa_get_low_u32(v4u32 __a) */ +#define msa_get_low_u32(__a) __GET_LOW(v2u32, __a) + +/* v1u64 msa_get_low_u64(v2u64 __a) */ +#define msa_get_low_u64(__a) __GET_LOW(v1u64, __a) + +/* v2f32 msa_get_low_f32(v4f32 __a) */ +#define msa_get_low_f32(__a) __GET_LOW(v2f32, __a) + +/* v1f64 msa_get_low_f64(v2f64 __a) */ +#define msa_get_low_f64(__a) __GET_LOW(v1f64, __a) + +/* v8i8 msa_get_high_s8(v16i8 __a) */ +#define msa_get_high_s8(__a) __GET_HIGH(v8i8, __a) + +/* v4i16 msa_get_high_s16(v8i16 __a) */ +#define msa_get_high_s16(__a) __GET_HIGH(v4i16, __a) + +/* v2i32 msa_get_high_s32(v4i32 __a) */ +#define msa_get_high_s32(__a) __GET_HIGH(v2i32, __a) + +/* v1i64 msa_get_high_s64(v2i64 __a) */ +#define msa_get_high_s64(__a) __GET_HIGH(v1i64, __a) + +/* v8u8 msa_get_high_u8(v16u8 __a) */ +#define msa_get_high_u8(__a) __GET_HIGH(v8u8, __a) + +/* v4u16 msa_get_high_u16(v8u16 __a) */ +#define msa_get_high_u16(__a) __GET_HIGH(v4u16, __a) + +/* v2u32 msa_get_high_u32(v4u32 __a) */ +#define msa_get_high_u32(__a) __GET_HIGH(v2u32, __a) + +/* v1u64 msa_get_high_u64(v2u64 __a) */ +#define msa_get_high_u64(__a) __GET_HIGH(v1u64, __a) + +/* v2f32 msa_get_high_f32(v4f32 __a) */ +#define msa_get_high_f32(__a) __GET_HIGH(v2f32, __a) + +/* v1f64 msa_get_high_f64(v2f64 __a) */ +#define msa_get_high_f64(__a) __GET_HIGH(v1f64, __a) + +/* ri = ai * b[lane] */ +/* v4f32 msa_mulq_lane_f32(v4f32 __a, v4f32 __b, const int __lane) */ +#define msa_mulq_lane_f32(__a, __b, __lane) ((__a) * msa_getq_lane_f32(__b, __lane)) + +/* ri = ai + bi * c[lane] */ +/* v4f32 msa_mlaq_lane_f32(v4f32 __a, v4f32 __b, v4f32 __c, const int __lane) */ +#define msa_mlaq_lane_f32(__a, __b, __c, __lane) ((__a) + ((__b) * msa_getq_lane_f32(__c, __lane))) + +/* uint16_t msa_sum_u16(v8u16 __a)*/ +#define msa_sum_u16(__a) \ +({ \ + v4u32 _b; \ + v2u64 _c; \ + _b = __builtin_msa_hadd_u_w(__a, __a); \ + _c = __builtin_msa_hadd_u_d(_b, _b); \ + (uint16_t)(_c[0] + _c[1]); \ +}) + +/* int16_t msa_sum_s16(v8i16 __a) */ +#define msa_sum_s16(__a) \ +({ \ + v4i32 _b; \ + v2i64 _c; \ + _b = __builtin_msa_hadd_s_w(__a, __a); \ + _c = __builtin_msa_hadd_s_d(_b, _b); \ + (int16_t)(_c[0] + _c[1]); \ +}) + + +/* uint32_t msa_sum_u32(v4u32 __a)*/ +#define msa_sum_u32(__a) \ +({ \ + v2u64 _b; \ + _b = __builtin_msa_hadd_u_d(__a, __a); \ + (uint32_t)(_b[0] + _b[1]); \ +}) + +/* int32_t msa_sum_s32(v4i32 __a)*/ +#define msa_sum_s32(__a) \ +({ \ + v2i64 _b; \ + _b = __builtin_msa_hadd_s_d(__a, __a); \ + (int32_t)(_b[0] + _b[1]); \ +}) + +/* uint8_t msa_sum_u8(v16u8 __a)*/ +#define msa_sum_u8(__a) \ +({ \ + v8u16 _b16; \ + v4u32 _c32; \ + _b16 = __builtin_msa_hadd_u_h(__a, __a); \ + _c32 = __builtin_msa_hadd_u_w(_b16, _b16); \ + (uint8_t)msa_sum_u32(_c32); \ +}) + +/* int8_t msa_sum_s8(v16s8 __a)*/ +#define msa_sum_s8(__a) \ +({ \ + v8i16 _b16; \ + v4i32 _c32; \ + _b16 = __builtin_msa_hadd_s_h(__a, __a); \ + _c32 = __builtin_msa_hadd_s_w(_b16, _b16); \ + (int8_t)msa_sum_s32(_c32); \ +}) + +/* float msa_sum_f32(v4f32 __a)*/ +#define msa_sum_f32(__a) ((__a)[0] + (__a)[1] + (__a)[2] + (__a)[3]) + +/* v8u16 msa_paddlq_u8(v16u8 __a) */ +#define msa_paddlq_u8(__a) (__builtin_msa_hadd_u_h(__a, __a)) + +/* v8i16 msa_paddlq_s8(v16i8 __a) */ +#define msa_paddlq_s8(__a) (__builtin_msa_hadd_s_h(__a, __a)) + +/* v4u32 msa_paddlq_u16 (v8u16 __a)*/ +#define msa_paddlq_u16(__a) (__builtin_msa_hadd_u_w(__a, __a)) + +/* v4i32 msa_paddlq_s16 (v8i16 __a)*/ +#define msa_paddlq_s16(__a) (__builtin_msa_hadd_s_w(__a, __a)) + +/* v2u64 msa_paddlq_u32(v4u32 __a) */ +#define msa_paddlq_u32(__a) (__builtin_msa_hadd_u_d(__a, __a)) + +/* v2i64 msa_paddlq_s32(v4i32 __a) */ +#define msa_paddlq_s32(__a) (__builtin_msa_hadd_s_d(__a, __a)) + +#define V8U8_2_V8U16(x) {(uint16_t)x[0], (uint16_t)x[1], (uint16_t)x[2], (uint16_t)x[3], \ + (uint16_t)x[4], (uint16_t)x[5], (uint16_t)x[6], (uint16_t)x[7]} +#define V8U8_2_V8I16(x) {(int16_t)x[0], (int16_t)x[1], (int16_t)x[2], (int16_t)x[3], \ + (int16_t)x[4], (int16_t)x[5], (int16_t)x[6], (int16_t)x[7]} +#define V8I8_2_V8I16(x) {(int16_t)x[0], (int16_t)x[1], (int16_t)x[2], (int16_t)x[3], \ + (int16_t)x[4], (int16_t)x[5], (int16_t)x[6], (int16_t)x[7]} +#define V4U16_2_V4U32(x) {(uint32_t)x[0], (uint32_t)x[1], (uint32_t)x[2], (uint32_t)x[3]} +#define V4U16_2_V4I32(x) {(int32_t)x[0], (int32_t)x[1], (int32_t)x[2], (int32_t)x[3]} +#define V4I16_2_V4I32(x) {(int32_t)x[0], (int32_t)x[1], (int32_t)x[2], (int32_t)x[3]} +#define V2U32_2_V2U64(x) {(uint64_t)x[0], (uint64_t)x[1]} +#define V2U32_2_V2I64(x) {(int64_t)x[0], (int64_t)x[1]} + +/* v8u16 msa_mull_u8(v8u8 __a, v8u8 __b) */ +#define msa_mull_u8(__a, __b) ((v8u16)__builtin_msa_mulv_h((v8i16)V8U8_2_V8I16(__a), (v8i16)V8U8_2_V8I16(__b))) + +/* v8i16 msa_mull_s8(v8i8 __a, v8i8 __b)*/ +#define msa_mull_s8(__a, __b) (__builtin_msa_mulv_h((v8i16)V8I8_2_V8I16(__a), (v8i16)V8I8_2_V8I16(__b))) + +/* v4u32 msa_mull_u16(v4u16 __a, v4u16 __b) */ +#define msa_mull_u16(__a, __b) ((v4u32)__builtin_msa_mulv_w((v4i32)V4U16_2_V4I32(__a), (v4i32)V4U16_2_V4I32(__b))) + +/* v4i32 msa_mull_s16(v4i16 __a, v4i16 __b) */ +#define msa_mull_s16(__a, __b) (__builtin_msa_mulv_w((v4i32)V4I16_2_V4I32(__a), (v4i32)V4I16_2_V4I32(__b))) + +/* v2u64 msa_mull_u32(v2u32 __a, v2u32 __b) */ +#define msa_mull_u32(__a, __b) ((v2u64)__builtin_msa_mulv_d((v2i64)V2U32_2_V2I64(__a), (v2i64)V2U32_2_V2I64(__b))) + +/* bitwise and: __builtin_msa_and_v */ +#define msa_andq_u8(__a, __b) ((v16u8)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s8(__a, __b) ((v16i8)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_u16(__a, __b) ((v8u16)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s16(__a, __b) ((v8i16)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_u32(__a, __b) ((v4u32)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s32(__a, __b) ((v4i32)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_u64(__a, __b) ((v2u64)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s64(__a, __b) ((v2i64)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) + +/* bitwise or: __builtin_msa_or_v */ +#define msa_orrq_u8(__a, __b) ((v16u8)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s8(__a, __b) ((v16i8)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_u16(__a, __b) ((v8u16)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s16(__a, __b) ((v8i16)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_u32(__a, __b) ((v4u32)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s32(__a, __b) ((v4i32)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_u64(__a, __b) ((v2u64)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s64(__a, __b) ((v2i64)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) + +/* bitwise xor: __builtin_msa_xor_v */ +#define msa_eorq_u8(__a, __b) ((v16u8)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s8(__a, __b) ((v16i8)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_u16(__a, __b) ((v8u16)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s16(__a, __b) ((v8i16)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_u32(__a, __b) ((v4u32)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s32(__a, __b) ((v4i32)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_u64(__a, __b) ((v2u64)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s64(__a, __b) ((v2i64)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) + +/* bitwise not: v16u8 __builtin_msa_xori_b (v16u8, 0xff) */ +#define msa_mvnq_u8(__a) ((v16u8)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s8(__a) ((v16i8)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_u16(__a) ((v8u16)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s16(__a) ((v8i16)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_u32(__a) ((v4u32)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s32(__a) ((v4i32)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_u64(__a) ((v2u64)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s64(__a) ((v2i64)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) + +/* compare equal: ceq -> ri = ai == bi ? 1...1:0...0 */ +#define msa_ceqq_u8(__a, __b) ((v16u8)__builtin_msa_ceq_b((v16i8)(__a), (v16i8)(__b))) +#define msa_ceqq_s8(__a, __b) ((v16u8)__builtin_msa_ceq_b((v16i8)(__a), (v16i8)(__b))) +#define msa_ceqq_u16(__a, __b) ((v8u16)__builtin_msa_ceq_h((v8i16)(__a), (v8i16)(__b))) +#define msa_ceqq_s16(__a, __b) ((v8u16)__builtin_msa_ceq_h((v8i16)(__a), (v8i16)(__b))) +#define msa_ceqq_u32(__a, __b) ((v4u32)__builtin_msa_ceq_w((v4i32)(__a), (v4i32)(__b))) +#define msa_ceqq_s32(__a, __b) ((v4u32)__builtin_msa_ceq_w((v4i32)(__a), (v4i32)(__b))) +#define msa_ceqq_f32(__a, __b) ((v4u32)__builtin_msa_fceq_w((v4f32)(__a), (v4f32)(__b))) +#define msa_ceqq_u64(__a, __b) ((v2u64)__builtin_msa_ceq_d((v2i64)(__a), (v2i64)(__b))) +#define msa_ceqq_s64(__a, __b) ((v2u64)__builtin_msa_ceq_d((v2i64)(__a), (v2i64)(__b))) +#define msa_ceqq_f64(__a, __b) ((v2u64)__builtin_msa_fceq_d((v2f64)(__a), (v2f64)(__b))) + +/* Compare less-than: clt -> ri = ai < bi ? 1...1:0...0 */ +#define msa_cltq_u8(__a, __b) ((v16u8)__builtin_msa_clt_u_b((v16u8)(__a), (v16u8)(__b))) +#define msa_cltq_s8(__a, __b) ((v16u8)__builtin_msa_clt_s_b((v16i8)(__a), (v16i8)(__b))) +#define msa_cltq_u16(__a, __b) ((v8u16)__builtin_msa_clt_u_h((v8u16)(__a), (v8u16)(__b))) +#define msa_cltq_s16(__a, __b) ((v8u16)__builtin_msa_clt_s_h((v8i16)(__a), (v8i16)(__b))) +#define msa_cltq_u32(__a, __b) ((v4u32)__builtin_msa_clt_u_w((v4u32)(__a), (v4u32)(__b))) +#define msa_cltq_s32(__a, __b) ((v4u32)__builtin_msa_clt_s_w((v4i32)(__a), (v4i32)(__b))) +#define msa_cltq_f32(__a, __b) ((v4u32)__builtin_msa_fclt_w((v4f32)(__a), (v4f32)(__b))) +#define msa_cltq_u64(__a, __b) ((v2u64)__builtin_msa_clt_u_d((v2u64)(__a), (v2u64)(__b))) +#define msa_cltq_s64(__a, __b) ((v2u64)__builtin_msa_clt_s_d((v2i64)(__a), (v2i64)(__b))) +#define msa_cltq_f64(__a, __b) ((v2u64)__builtin_msa_fclt_d((v2f64)(__a), (v2f64)(__b))) + +/* compare greater-than: cgt -> ri = ai > bi ? 1...1:0...0 */ +#define msa_cgtq_u8(__a, __b) ((v16u8)__builtin_msa_clt_u_b((v16u8)(__b), (v16u8)(__a))) +#define msa_cgtq_s8(__a, __b) ((v16u8)__builtin_msa_clt_s_b((v16i8)(__b), (v16i8)(__a))) +#define msa_cgtq_u16(__a, __b) ((v8u16)__builtin_msa_clt_u_h((v8u16)(__b), (v8u16)(__a))) +#define msa_cgtq_s16(__a, __b) ((v8u16)__builtin_msa_clt_s_h((v8i16)(__b), (v8i16)(__a))) +#define msa_cgtq_u32(__a, __b) ((v4u32)__builtin_msa_clt_u_w((v4u32)(__b), (v4u32)(__a))) +#define msa_cgtq_s32(__a, __b) ((v4u32)__builtin_msa_clt_s_w((v4i32)(__b), (v4i32)(__a))) +#define msa_cgtq_f32(__a, __b) ((v4u32)__builtin_msa_fclt_w((v4f32)(__b), (v4f32)(__a))) +#define msa_cgtq_u64(__a, __b) ((v2u64)__builtin_msa_clt_u_d((v2u64)(__b), (v2u64)(__a))) +#define msa_cgtq_s64(__a, __b) ((v2u64)__builtin_msa_clt_s_d((v2i64)(__b), (v2i64)(__a))) +#define msa_cgtq_f64(__a, __b) ((v2u64)__builtin_msa_fclt_d((v2f64)(__b), (v2f64)(__a))) + +/* compare less-equal: cle -> ri = ai <= bi ? 1...1:0...0 */ +#define msa_cleq_u8(__a, __b) ((v16u8)__builtin_msa_cle_u_b((v16u8)(__a), (v16u8)(__b))) +#define msa_cleq_s8(__a, __b) ((v16u8)__builtin_msa_cle_s_b((v16i8)(__a), (v16i8)(__b))) +#define msa_cleq_u16(__a, __b) ((v8u16)__builtin_msa_cle_u_h((v8u16)(__a), (v8u16)(__b))) +#define msa_cleq_s16(__a, __b) ((v8u16)__builtin_msa_cle_s_h((v8i16)(__a), (v8i16)(__b))) +#define msa_cleq_u32(__a, __b) ((v4u32)__builtin_msa_cle_u_w((v4u32)(__a), (v4u32)(__b))) +#define msa_cleq_s32(__a, __b) ((v4u32)__builtin_msa_cle_s_w((v4i32)(__a), (v4i32)(__b))) +#define msa_cleq_f32(__a, __b) ((v4u32)__builtin_msa_fcle_w((v4f32)(__a), (v4f32)(__b))) +#define msa_cleq_u64(__a, __b) ((v2u64)__builtin_msa_cle_u_d((v2u64)(__a), (v2u64)(__b))) +#define msa_cleq_s64(__a, __b) ((v2u64)__builtin_msa_cle_s_d((v2i64)(__a), (v2i64)(__b))) +#define msa_cleq_f64(__a, __b) ((v2u64)__builtin_msa_fcle_d((v2f64)(__a), (v2f64)(__b))) + +/* compare greater-equal: cge -> ri = ai >= bi ? 1...1:0...0 */ +#define msa_cgeq_u8(__a, __b) ((v16u8)__builtin_msa_cle_u_b((v16u8)(__b), (v16u8)(__a))) +#define msa_cgeq_s8(__a, __b) ((v16u8)__builtin_msa_cle_s_b((v16i8)(__b), (v16i8)(__a))) +#define msa_cgeq_u16(__a, __b) ((v8u16)__builtin_msa_cle_u_h((v8u16)(__b), (v8u16)(__a))) +#define msa_cgeq_s16(__a, __b) ((v8u16)__builtin_msa_cle_s_h((v8i16)(__b), (v8i16)(__a))) +#define msa_cgeq_u32(__a, __b) ((v4u32)__builtin_msa_cle_u_w((v4u32)(__b), (v4u32)(__a))) +#define msa_cgeq_s32(__a, __b) ((v4u32)__builtin_msa_cle_s_w((v4i32)(__b), (v4i32)(__a))) +#define msa_cgeq_f32(__a, __b) ((v4u32)__builtin_msa_fcle_w((v4f32)(__b), (v4f32)(__a))) +#define msa_cgeq_u64(__a, __b) ((v2u64)__builtin_msa_cle_u_d((v2u64)(__b), (v2u64)(__a))) +#define msa_cgeq_s64(__a, __b) ((v2u64)__builtin_msa_cle_s_d((v2i64)(__b), (v2i64)(__a))) +#define msa_cgeq_f64(__a, __b) ((v2u64)__builtin_msa_fcle_d((v2f64)(__b), (v2f64)(__a))) + +/* Shift Left Logical: shl -> ri = ai << bi; */ +#define msa_shlq_u8(__a, __b) ((v16u8)__builtin_msa_sll_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shlq_s8(__a, __b) ((v16i8)__builtin_msa_sll_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shlq_u16(__a, __b) ((v8u16)__builtin_msa_sll_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shlq_s16(__a, __b) ((v8i16)__builtin_msa_sll_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shlq_u32(__a, __b) ((v4u32)__builtin_msa_sll_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shlq_s32(__a, __b) ((v4i32)__builtin_msa_sll_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shlq_u64(__a, __b) ((v2u64)__builtin_msa_sll_d((v2i64)(__a), (v2i64)(__b))) +#define msa_shlq_s64(__a, __b) ((v2i64)__builtin_msa_sll_d((v2i64)(__a), (v2i64)(__b))) + +/* Immediate Shift Left Logical: shl -> ri = ai << imm; */ +#define msa_shlq_n_u8(__a, __imm) ((v16u8)__builtin_msa_slli_b((v16i8)(__a), __imm)) +#define msa_shlq_n_s8(__a, __imm) ((v16i8)__builtin_msa_slli_b((v16i8)(__a), __imm)) +#define msa_shlq_n_u16(__a, __imm) ((v8u16)__builtin_msa_slli_h((v8i16)(__a), __imm)) +#define msa_shlq_n_s16(__a, __imm) ((v8i16)__builtin_msa_slli_h((v8i16)(__a), __imm)) +#define msa_shlq_n_u32(__a, __imm) ((v4u32)__builtin_msa_slli_w((v4i32)(__a), __imm)) +#define msa_shlq_n_s32(__a, __imm) ((v4i32)__builtin_msa_slli_w((v4i32)(__a), __imm)) +#define msa_shlq_n_u64(__a, __imm) ((v2u64)__builtin_msa_slli_d((v2i64)(__a), __imm)) +#define msa_shlq_n_s64(__a, __imm) ((v2i64)__builtin_msa_slli_d((v2i64)(__a), __imm)) + +/* shift right: shrq -> ri = ai >> bi; */ +#define msa_shrq_u8(__a, __b) ((v16u8)__builtin_msa_srl_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shrq_s8(__a, __b) ((v16i8)__builtin_msa_sra_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shrq_u16(__a, __b) ((v8u16)__builtin_msa_srl_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shrq_s16(__a, __b) ((v8i16)__builtin_msa_sra_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shrq_u32(__a, __b) ((v4u32)__builtin_msa_srl_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shrq_s32(__a, __b) ((v4i32)__builtin_msa_sra_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shrq_u64(__a, __b) ((v2u64)__builtin_msa_srl_d((v2i64)(__a), (v2i64)(__b))) +#define msa_shrq_s64(__a, __b) ((v2i64)__builtin_msa_sra_d((v2i64)(__a), (v2i64)(__b))) + +/* Immediate Shift Right: shr -> ri = ai >> imm; */ +#define msa_shrq_n_u8(__a, __imm) ((v16u8)__builtin_msa_srli_b((v16i8)(__a), __imm)) +#define msa_shrq_n_s8(__a, __imm) ((v16i8)__builtin_msa_srai_b((v16i8)(__a), __imm)) +#define msa_shrq_n_u16(__a, __imm) ((v8u16)__builtin_msa_srli_h((v8i16)(__a), __imm)) +#define msa_shrq_n_s16(__a, __imm) ((v8i16)__builtin_msa_srai_h((v8i16)(__a), __imm)) +#define msa_shrq_n_u32(__a, __imm) ((v4u32)__builtin_msa_srli_w((v4i32)(__a), __imm)) +#define msa_shrq_n_s32(__a, __imm) ((v4i32)__builtin_msa_srai_w((v4i32)(__a), __imm)) +#define msa_shrq_n_u64(__a, __imm) ((v2u64)__builtin_msa_srli_d((v2i64)(__a), __imm)) +#define msa_shrq_n_s64(__a, __imm) ((v2i64)__builtin_msa_srai_d((v2i64)(__a), __imm)) + +/* Immediate Shift Right Rounded: shr -> ri = ai >> (rounded)imm; */ +#define msa_rshrq_n_u8(__a, __imm) ((v16u8)__builtin_msa_srlri_b((v16i8)(__a), __imm)) +#define msa_rshrq_n_s8(__a, __imm) ((v16i8)__builtin_msa_srari_b((v16i8)(__a), __imm)) +#define msa_rshrq_n_u16(__a, __imm) ((v8u16)__builtin_msa_srlri_h((v8i16)(__a), __imm)) +#define msa_rshrq_n_s16(__a, __imm) ((v8i16)__builtin_msa_srari_h((v8i16)(__a), __imm)) +#define msa_rshrq_n_u32(__a, __imm) ((v4u32)__builtin_msa_srlri_w((v4i32)(__a), __imm)) +#define msa_rshrq_n_s32(__a, __imm) ((v4i32)__builtin_msa_srari_w((v4i32)(__a), __imm)) +#define msa_rshrq_n_u64(__a, __imm) ((v2u64)__builtin_msa_srlri_d((v2i64)(__a), __imm)) +#define msa_rshrq_n_s64(__a, __imm) ((v2i64)__builtin_msa_srari_d((v2i64)(__a), __imm)) + +/* Vector saturating rounding shift left, qrshl -> ri = ai << bi; */ +#define msa_qrshrq_s32(a, b) ((v4i32)__msa_srar_w((v4i32)(a), (v4i32)(b))) + +/* Rename the msa builtin func to unify the name style for intrin_msa.hpp */ +#define msa_qaddq_u8 __builtin_msa_adds_u_b +#define msa_qaddq_s8 __builtin_msa_adds_s_b +#define msa_qaddq_u16 __builtin_msa_adds_u_h +#define msa_qaddq_s16 __builtin_msa_adds_s_h +#define msa_qaddq_u32 __builtin_msa_adds_u_w +#define msa_qaddq_s32 __builtin_msa_adds_s_w +#define msa_qaddq_u64 __builtin_msa_adds_u_d +#define msa_qaddq_s64 __builtin_msa_adds_s_d +#define msa_addq_u8(a, b) ((v16u8)__builtin_msa_addv_b((v16i8)(a), (v16i8)(b))) +#define msa_addq_s8 __builtin_msa_addv_b +#define msa_addq_u16(a, b) ((v8u16)__builtin_msa_addv_h((v8i16)(a), (v8i16)(b))) +#define msa_addq_s16 __builtin_msa_addv_h +#define msa_addq_u32(a, b) ((v4u32)__builtin_msa_addv_w((v4i32)(a), (v4i32)(b))) +#define msa_addq_s32 __builtin_msa_addv_w +#define msa_addq_f32 __builtin_msa_fadd_w +#define msa_addq_u64(a, b) ((v2u64)__builtin_msa_addv_d((v2i64)(a), (v2i64)(b))) +#define msa_addq_s64 __builtin_msa_addv_d +#define msa_addq_f64 __builtin_msa_fadd_d +#define msa_qsubq_u8 __builtin_msa_subs_u_b +#define msa_qsubq_s8 __builtin_msa_subs_s_b +#define msa_qsubq_u16 __builtin_msa_subs_u_h +#define msa_qsubq_s16 __builtin_msa_subs_s_h +#define msa_subq_u8(a, b) ((v16u8)__builtin_msa_subv_b((v16i8)(a), (v16i8)(b))) +#define msa_subq_s8 __builtin_msa_subv_b +#define msa_subq_u16(a, b) ((v8u16)__builtin_msa_subv_h((v8i16)(a), (v8i16)(b))) +#define msa_subq_s16 __builtin_msa_subv_h +#define msa_subq_u32(a, b) ((v4u32)__builtin_msa_subv_w((v4i32)(a), (v4i32)(b))) +#define msa_subq_s32 __builtin_msa_subv_w +#define msa_subq_f32 __builtin_msa_fsub_w +#define msa_subq_u64(a, b) ((v2u64)__builtin_msa_subv_d((v2i64)(a), (v2i64)(b))) +#define msa_subq_s64 __builtin_msa_subv_d +#define msa_subq_f64 __builtin_msa_fsub_d +#define msa_mulq_u8(a, b) ((v16u8)__builtin_msa_mulv_b((v16i8)(a), (v16i8)(b))) +#define msa_mulq_s8(a, b) ((v16i8)__builtin_msa_mulv_b((v16i8)(a), (v16i8)(b))) +#define msa_mulq_u16(a, b) ((v8u16)__builtin_msa_mulv_h((v8i16)(a), (v8i16)(b))) +#define msa_mulq_s16(a, b) ((v8i16)__builtin_msa_mulv_h((v8i16)(a), (v8i16)(b))) +#define msa_mulq_u32(a, b) ((v4u32)__builtin_msa_mulv_w((v4i32)(a), (v4i32)(b))) +#define msa_mulq_s32(a, b) ((v4i32)__builtin_msa_mulv_w((v4i32)(a), (v4i32)(b))) +#define msa_mulq_u64(a, b) ((v2u64)__builtin_msa_mulv_d((v2i64)(a), (v2i64)(b))) +#define msa_mulq_s64(a, b) ((v2i64)__builtin_msa_mulv_d((v2i64)(a), (v2i64)(b))) +#define msa_mulq_f32 __builtin_msa_fmul_w +#define msa_mulq_f64 __builtin_msa_fmul_d +#define msa_divq_f32 __builtin_msa_fdiv_w +#define msa_divq_f64 __builtin_msa_fdiv_d +#define msa_dotp_s_h __builtin_msa_dotp_s_h +#define msa_dotp_s_w __builtin_msa_dotp_s_w +#define msa_dotp_s_d __builtin_msa_dotp_s_d +#define msa_dotp_u_h __builtin_msa_dotp_u_h +#define msa_dotp_u_w __builtin_msa_dotp_u_w +#define msa_dotp_u_d __builtin_msa_dotp_u_d +#define msa_dpadd_s_h __builtin_msa_dpadd_s_h +#define msa_dpadd_s_w __builtin_msa_dpadd_s_w +#define msa_dpadd_s_d __builtin_msa_dpadd_s_d +#define msa_dpadd_u_h __builtin_msa_dpadd_u_h +#define msa_dpadd_u_w __builtin_msa_dpadd_u_w +#define msa_dpadd_u_d __builtin_msa_dpadd_u_d + +#define ILVRL_B2(RTYPE, in0, in1, low, hi) do { \ + low = (RTYPE)__builtin_msa_ilvr_b((v16i8)(in0), (v16i8)(in1)); \ + hi = (RTYPE)__builtin_msa_ilvl_b((v16i8)(in0), (v16i8)(in1)); \ + } while (0) +#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__) +#define ILVRL_B2_SB(...) ILVRL_B2(v16i8, __VA_ARGS__) +#define ILVRL_B2_UH(...) ILVRL_B2(v8u16, __VA_ARGS__) +#define ILVRL_B2_SH(...) ILVRL_B2(v8i16, __VA_ARGS__) +#define ILVRL_B2_SW(...) ILVRL_B2(v4i32, __VA_ARGS__) + +#define ILVRL_H2(RTYPE, in0, in1, low, hi) do { \ + low = (RTYPE)__builtin_msa_ilvr_h((v8i16)(in0), (v8i16)(in1)); \ + hi = (RTYPE)__builtin_msa_ilvl_h((v8i16)(in0), (v8i16)(in1)); \ + } while (0) +#define ILVRL_H2_UB(...) ILVRL_H2(v16u8, __VA_ARGS__) +#define ILVRL_H2_SB(...) ILVRL_H2(v16i8, __VA_ARGS__) +#define ILVRL_H2_UH(...) ILVRL_H2(v8u16, __VA_ARGS__) +#define ILVRL_H2_SH(...) ILVRL_H2(v8i16, __VA_ARGS__) +#define ILVRL_H2_SW(...) ILVRL_H2(v4i32, __VA_ARGS__) +#define ILVRL_H2_UW(...) ILVRL_H2(v4u32, __VA_ARGS__) + +#define ILVRL_W2(RTYPE, in0, in1, low, hi) do { \ + low = (RTYPE)__builtin_msa_ilvr_w((v4i32)(in0), (v4i32)(in1)); \ + hi = (RTYPE)__builtin_msa_ilvl_w((v4i32)(in0), (v4i32)(in1)); \ + } while (0) +#define ILVRL_W2_UB(...) ILVRL_W2(v16u8, __VA_ARGS__) +#define ILVRL_W2_SH(...) ILVRL_W2(v8i16, __VA_ARGS__) +#define ILVRL_W2_SW(...) ILVRL_W2(v4i32, __VA_ARGS__) +#define ILVRL_W2_UW(...) ILVRL_W2(v4u32, __VA_ARGS__) + +/* absq, qabsq (r = |a|;) */ +#define msa_absq_s8(a) __builtin_msa_add_a_b(a, __builtin_msa_fill_b(0)) +#define msa_absq_s16(a) __builtin_msa_add_a_h(a, __builtin_msa_fill_h(0)) +#define msa_absq_s32(a) __builtin_msa_add_a_w(a, __builtin_msa_fill_w(0)) +#define msa_absq_s64(a) __builtin_msa_add_a_d(a, __builtin_msa_fill_d(0)) +#define msa_absq_f32(a) ((v4f32)__builtin_msa_bclri_w((v4u32)(a), 31)) +#define msa_absq_f64(a) ((v2f64)__builtin_msa_bclri_d((v2u64)(a), 63)) +#define msa_qabsq_s8(a) __builtin_msa_adds_a_b(a, __builtin_msa_fill_b(0)) +#define msa_qabsq_s16(a) __builtin_msa_adds_a_h(a, __builtin_msa_fill_h(0)) +#define msa_qabsq_s32(a) __builtin_msa_adds_a_w(a, __builtin_msa_fill_w(0)) +#define msa_qabsq_s64(a) __builtin_msa_adds_a_d(a, __builtin_msa_fill_d(0)) + +/* abdq, qabdq (r = |a - b|;) */ +#define msa_abdq_u8 __builtin_msa_asub_u_b +#define msa_abdq_s8 __builtin_msa_asub_s_b +#define msa_abdq_u16 __builtin_msa_asub_u_h +#define msa_abdq_s16 __builtin_msa_asub_s_h +#define msa_abdq_u32 __builtin_msa_asub_u_w +#define msa_abdq_s32 __builtin_msa_asub_s_w +#define msa_abdq_u64 __builtin_msa_asub_u_d +#define msa_abdq_s64 __builtin_msa_asub_s_d +#define msa_abdq_f32(a, b) msa_absq_f32(__builtin_msa_fsub_w(a, b)) +#define msa_abdq_f64(a, b) msa_absq_f64(__builtin_msa_fsub_d(a, b)) +#define msa_qabdq_s8(a, b) msa_qabsq_s8(__builtin_msa_subs_s_b(a, b)) +#define msa_qabdq_s16(a, b) msa_qabsq_s16(__builtin_msa_subs_s_h(a, b)) +#define msa_qabdq_s32(a, b) msa_qabsq_s32(__builtin_msa_subs_s_w(a, b)) +#define msa_qabdq_s64(a, b) msa_qabsq_s64(__builtin_msa_subs_s_d(a, b)) + +/* sqrtq, rsqrtq */ +#define msa_sqrtq_f32 __builtin_msa_fsqrt_w +#define msa_sqrtq_f64 __builtin_msa_fsqrt_d +#define msa_rsqrtq_f32 __builtin_msa_frsqrt_w +#define msa_rsqrtq_f64 __builtin_msa_frsqrt_d + + +/* mlaq: r = a + b * c; */ +__extension__ extern __inline v4i32 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_s32(v4i32 __a, v4i32 __b, v4i32 __c) +{ + __asm__ volatile("maddv.w %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +__extension__ extern __inline v2i64 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_s64(v2i64 __a, v2i64 __b, v2i64 __c) +{ + __asm__ volatile("maddv.d %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +__extension__ extern __inline v4f32 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_f32(v4f32 __a, v4f32 __b, v4f32 __c) +{ + __asm__ volatile("fmadd.w %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +__extension__ extern __inline v2f64 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_f64(v2f64 __a, v2f64 __b, v2f64 __c) +{ + __asm__ volatile("fmadd.d %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +/* cntq */ +#define msa_cntq_s8 __builtin_msa_pcnt_b +#define msa_cntq_s16 __builtin_msa_pcnt_h +#define msa_cntq_s32 __builtin_msa_pcnt_w +#define msa_cntq_s64 __builtin_msa_pcnt_d + +/* bslq (a: mask; r = b(if a == 0); r = c(if a == 1);) */ +#define msa_bslq_u8 __builtin_msa_bsel_v + +/* ilvrq, ilvlq (For EL only, ilvrq: b0, a0, b1, a1; ilvlq: b2, a2, b3, a3;) */ +#define msa_ilvrq_s8 __builtin_msa_ilvr_b +#define msa_ilvrq_s16 __builtin_msa_ilvr_h +#define msa_ilvrq_s32 __builtin_msa_ilvr_w +#define msa_ilvrq_s64 __builtin_msa_ilvr_d +#define msa_ilvlq_s8 __builtin_msa_ilvl_b +#define msa_ilvlq_s16 __builtin_msa_ilvl_h +#define msa_ilvlq_s32 __builtin_msa_ilvl_w +#define msa_ilvlq_s64 __builtin_msa_ilvl_d + +/* ilvevq, ilvodq (ilvevq: b0, a0, b2, a2; ilvodq: b1, a1, b3, a3; ) */ +#define msa_ilvevq_s8 __builtin_msa_ilvev_b +#define msa_ilvevq_s16 __builtin_msa_ilvev_h +#define msa_ilvevq_s32 __builtin_msa_ilvev_w +#define msa_ilvevq_s64 __builtin_msa_ilvev_d +#define msa_ilvodq_s8 __builtin_msa_ilvod_b +#define msa_ilvodq_s16 __builtin_msa_ilvod_h +#define msa_ilvodq_s32 __builtin_msa_ilvod_w +#define msa_ilvodq_s64 __builtin_msa_ilvod_d + +/* extq (r = (a || b); a concatenation b and get elements from index c) */ +#ifdef _MIPSEB +#define msa_extq_s8(a, b, c) \ +(__builtin_msa_vshf_b(__builtin_msa_subv_b((v16i8)((v2i64){0x1716151413121110, 0x1F1E1D1C1B1A1918}), __builtin_msa_fill_b(c)), a, b)) +#define msa_extq_s16(a, b, c) \ +(__builtin_msa_vshf_h(__builtin_msa_subv_h((v8i16)((v2i64){0x000B000A00090008, 0x000F000E000D000C}), __builtin_msa_fill_h(c)), a, b)) +#define msa_extq_s32(a, b, c) \ +(__builtin_msa_vshf_w(__builtin_msa_subv_w((v4i32)((v2i64){0x0000000500000004, 0x0000000700000006}), __builtin_msa_fill_w(c)), a, b)) +#define msa_extq_s64(a, b, c) \ +(__builtin_msa_vshf_d(__builtin_msa_subv_d((v2i64){0x0000000000000002, 0x0000000000000003}, __builtin_msa_fill_d(c)), a, b)) +#else +#define msa_extq_s8(a, b, c) \ +(__builtin_msa_vshf_b(__builtin_msa_addv_b((v16i8)((v2i64){0x0706050403020100, 0x0F0E0D0C0B0A0908}), __builtin_msa_fill_b(c)), b, a)) +#define msa_extq_s16(a, b, c) \ +(__builtin_msa_vshf_h(__builtin_msa_addv_h((v8i16)((v2i64){0x0003000200010000, 0x0007000600050004}), __builtin_msa_fill_h(c)), b, a)) +#define msa_extq_s32(a, b, c) \ +(__builtin_msa_vshf_w(__builtin_msa_addv_w((v4i32)((v2i64){0x0000000100000000, 0x0000000300000002}), __builtin_msa_fill_w(c)), b, a)) +#define msa_extq_s64(a, b, c) \ +(__builtin_msa_vshf_d(__builtin_msa_addv_d((v2i64){0x0000000000000000, 0x0000000000000001}, __builtin_msa_fill_d(c)), b, a)) +#endif /* _MIPSEB */ + +/* cvttruncq, cvttintq, cvtrintq */ +#define msa_cvttruncq_u32_f32 __builtin_msa_ftrunc_u_w +#define msa_cvttruncq_s32_f32 __builtin_msa_ftrunc_s_w +#define msa_cvttruncq_u64_f64 __builtin_msa_ftrunc_u_d +#define msa_cvttruncq_s64_f64 __builtin_msa_ftrunc_s_d +#define msa_cvttintq_u32_f32 __builtin_msa_ftint_u_w +#define msa_cvttintq_s32_f32 __builtin_msa_ftint_s_w +#define msa_cvttintq_u64_f64 __builtin_msa_ftint_u_d +#define msa_cvttintq_s64_f64 __builtin_msa_ftint_s_d +#define msa_cvtrintq_f32 __builtin_msa_frint_w +#define msa_cvtrintq_f64 __builtin_msa_frint_d + +/* cvtfintq, cvtfq */ +#define msa_cvtfintq_f32_u32 __builtin_msa_ffint_u_w +#define msa_cvtfintq_f32_s32 __builtin_msa_ffint_s_w +#define msa_cvtfintq_f64_u64 __builtin_msa_ffint_u_d +#define msa_cvtfintq_f64_s64 __builtin_msa_ffint_s_d +#define msa_cvtfq_f32_f64 __builtin_msa_fexdo_w +#define msa_cvtflq_f64_f32 __builtin_msa_fexupr_d +#define msa_cvtfhq_f64_f32 __builtin_msa_fexupl_d + +#define msa_addl_u8(a, b) ((v8u16)__builtin_msa_addv_h((v8i16)V8U8_2_V8I16(a), (v8i16)V8U8_2_V8I16(b))) +#define msa_addl_s8(a, b) (__builtin_msa_addv_h((v8i16)V8I8_2_V8I16(a), (v8i16)V8I8_2_V8I16(b))) +#define msa_addl_u16(a, b) ((v4u32)__builtin_msa_addv_w((v4i32)V4U16_2_V4I32(a), (v4i32)V4U16_2_V4I32(b))) +#define msa_addl_s16(a, b) (__builtin_msa_addv_w((v4i32)V4I16_2_V4I32(a), (v4i32)V4I16_2_V4I32(b))) +#define msa_subl_s16(a, b) (__builtin_msa_subv_w((v4i32)V4I16_2_V4I32(a), (v4i32)V4I16_2_V4I32(b))) +#define msa_recpeq_f32 __builtin_msa_frcp_w +#define msa_recpsq_f32(a, b) (__builtin_msa_fsub_w(msa_dupq_n_f32(2.0f), __builtin_msa_fmul_w(a, b))) + +#define MSA_INTERLEAVED_IMPL_LOAD2_STORE2(_Tp, _Tpv, _Tpvs, suffix, df, nlanes) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld2q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + nlanes); \ + *a = (_Tpv)__builtin_msa_pckev_##df((_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_pckod_##df((_Tpvs)v1, (_Tpvs)v0); \ +} \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st2q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b) \ +{ \ + msa_st1q_##suffix(ptr, (_Tpv)__builtin_msa_ilvr_##df((_Tpvs)b, (_Tpvs)a)); \ + msa_st1q_##suffix(ptr + nlanes, (_Tpv)__builtin_msa_ilvl_##df((_Tpvs)b, (_Tpvs)a)); \ +} + +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint8_t, v16u8, v16i8, u8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int8_t, v16i8, v16i8, s8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint16_t, v8u16, v8i16, u16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int16_t, v8i16, v8i16, s16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint32_t, v4u32, v4i32, u32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int32_t, v4i32, v4i32, s32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(float, v4f32, v4i32, f32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint64_t, v2u64, v2i64, u64, d, 2) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int64_t, v2i64, v2i64, s64, d, 2) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(double, v2f64, v2i64, f64, d, 2) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_LOAD3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 16); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 32); \ + _Tpvs v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0704011F1F1F1F1F, 0x1F1C191613100D0A}), (_Tpvs)v0, (_Tpvs)v1); \ + *a = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x1716150E0B080502, 0x1F1E1D1C1B1A1918}), v3, (_Tpvs)v2); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0603001F1F1F1F1F, 0x1E1B1815120F0C09}), (_Tpvs)v0, (_Tpvs)v1); \ + *b = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x1716150D0A070401, 0x1F1E1D1C1B1A1918}), v3, (_Tpvs)v2); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x05021F1F1F1F1F1F, 0x1D1A1714110E0B08}), (_Tpvs)v0, (_Tpvs)v1); \ + *c = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x17160F0C09060300, 0x1F1E1D1C1B1A1918}), v3, (_Tpvs)v2); \ +} +#else +#define MSA_INTERLEAVED_IMPL_LOAD3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 16); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 32); \ + _Tpvs v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x15120F0C09060300, 0x00000000001E1B18}), (_Tpvs)v1, (_Tpvs)v0); \ + *a = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x0706050403020100, 0x1D1A1714110A0908}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x1613100D0A070401, 0x00000000001F1C19}), (_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x0706050403020100, 0x1E1B1815120A0908}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x1714110E0B080502, 0x0000000000001D1A}), (_Tpvs)v1, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x0706050403020100, 0x1F1C191613100908}), (_Tpvs)v2, v3); \ +} +#endif + +MSA_INTERLEAVED_IMPL_LOAD3_8(uint8_t, v16u8, v16i8, u8) +MSA_INTERLEAVED_IMPL_LOAD3_8(int8_t, v16i8, v16i8, s8) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_LOAD3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 8); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 16); \ + _Tpvs v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x00030000000F000F, 0x000F000C00090006}), (_Tpvs)v1, (_Tpvs)v0); \ + *a = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000A00050002, 0x000F000E000D000C}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0002000F000F000F, 0x000E000B00080005}), (_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000700040001, 0x000F000E000D000C}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0001000F000F000F, 0x000D000A00070004}), (_Tpvs)v1, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000600030000, 0x000F000E000D000C}), (_Tpvs)v2, v3); \ +} +#else +#define MSA_INTERLEAVED_IMPL_LOAD3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 8); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 16); \ + _Tpvs v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0009000600030000, 0x00000000000F000C}), (_Tpvs)v1, (_Tpvs)v0); \ + *a = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x0003000200010000, 0x000D000A00050004}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000A000700040001, 0x000000000000000D}), (_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x0003000200010000, 0x000E000B00080004}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000800050002, 0x000000000000000E}), (_Tpvs)v1, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x0003000200010000, 0x000F000C00090004}), (_Tpvs)v2, v3); \ +} +#endif + +MSA_INTERLEAVED_IMPL_LOAD3_16(uint16_t, v8u16, v8i16, u16) +MSA_INTERLEAVED_IMPL_LOAD3_16(int16_t, v8i16, v8i16, s16) + +#define MSA_INTERLEAVED_IMPL_LOAD3_32(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v00 = msa_ld1q_##suffix(ptr); \ + _Tpv v01 = msa_ld1q_##suffix(ptr + 4); \ + _Tpv v02 = msa_ld1q_##suffix(ptr + 8); \ + _Tpvs v10 = __builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v01, (v2i64)v01), (_Tpvs)v00); \ + _Tpvs v11 = __builtin_msa_ilvr_w((_Tpvs)v02, (_Tpvs)__builtin_msa_ilvl_d((v2i64)v00, (v2i64)v00)); \ + _Tpvs v12 = __builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v02, (v2i64)v02), (_Tpvs)v01); \ + *a = (_Tpv)__builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v11, (v2i64)v11), v10); \ + *b = (_Tpv)__builtin_msa_ilvr_w(v12, (_Tpvs)__builtin_msa_ilvl_d((v2i64)v10, (v2i64)v10)); \ + *c = (_Tpv)__builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v12, (v2i64)v12), v11); \ +} + +MSA_INTERLEAVED_IMPL_LOAD3_32(uint32_t, v4u32, v4i32, u32) +MSA_INTERLEAVED_IMPL_LOAD3_32(int32_t, v4i32, v4i32, s32) +MSA_INTERLEAVED_IMPL_LOAD3_32(float, v4f32, v4i32, f32) + +#define MSA_INTERLEAVED_IMPL_LOAD3_64(_Tp, _Tpv, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + *((_Tp*)a) = *ptr; *((_Tp*)b) = *(ptr + 1); *((_Tp*)c) = *(ptr + 2); \ + *((_Tp*)a + 1) = *(ptr + 3); *((_Tp*)b + 1) = *(ptr + 4); *((_Tp*)c + 1) = *(ptr + 5); \ +} + +MSA_INTERLEAVED_IMPL_LOAD3_64(uint64_t, v2u64, u64) +MSA_INTERLEAVED_IMPL_LOAD3_64(int64_t, v2i64, s64) +MSA_INTERLEAVED_IMPL_LOAD3_64(double, v2f64, f64) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_STORE3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0F0E0D0C0B1F1F1F, 0x1F1E1D1C1B1A1F1F}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0D1C140C1B130B1A, 0x1F170F1E160E1D15}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0A09080706051F1F, 0x19181716151F1F1F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x1D14071C13061B12, 0x170A1F16091E1508}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x04030201001F1F1F, 0x14131211101F1F1F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x15021C14011B1300, 0x051F17041E16031D}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 32, (_Tpv)v1); \ +} +#else +#define MSA_INTERLEAVED_IMPL_STORE3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0000050403020100, 0x0000001413121110}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0A02110901100800, 0x05140C04130B0312}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0000000A09080706, 0x00001A1918171615}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x170A011609001508, 0x0D04190C03180B02}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0000000F0E0D0C0B, 0x0000001F1E1D1C1B}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x021C09011B08001A, 0x1F0C041E0B031D0A}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 32, (_Tpv)v1); \ +} +#endif + +MSA_INTERLEAVED_IMPL_STORE3_8(uint8_t, v16u8, v16i8, u8) +MSA_INTERLEAVED_IMPL_STORE3_8(int8_t, v16i8, v16i8, s8) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_STORE3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000700060005000F, 0x000F000E000D000F}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000A0006000D0009, 0x000F000B0007000E}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x00040003000F000F, 0x000C000B000A000F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000E000A0003000D, 0x0005000F000B0004}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000200010000000F, 0x00090008000F000F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0001000E00090000, 0x000B0002000F000A}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ +} +#else +#define MSA_INTERLEAVED_IMPL_STORE3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0000000200010000, 0x0000000A00090008}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0001000800040000, 0x0006000200090005}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0000000500040003, 0x00000000000C000B}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B00040000000A, 0x0002000C00050001}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0000000000070006, 0x0000000F000E000D}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x00050000000D0004, 0x000F00060001000E}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ +} +#endif + +MSA_INTERLEAVED_IMPL_STORE3_16(uint16_t, v8u16, v8i16, u16) +MSA_INTERLEAVED_IMPL_STORE3_16(int16_t, v8i16, v8i16, s16) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_STORE3_32(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000300000007, 0x0000000700000006}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000300000006, 0x0000000700000005}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000200000001, 0x0000000500000007}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000700000004, 0x0000000500000002}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 4, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000007, 0x0000000400000007}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000500000000, 0x0000000100000007}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ +} +#else +#define MSA_INTERLEAVED_IMPL_STORE3_32(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000100000000, 0x0000000000000004}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000200000000, 0x0000000100000004}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000002, 0x0000000600000005}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000500000002, 0x0000000300000000}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 4, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000003, 0x0000000000000007}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000006, 0x0000000700000002}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ +} +#endif + +MSA_INTERLEAVED_IMPL_STORE3_32(uint32_t, v4u32, v4i32, u32) +MSA_INTERLEAVED_IMPL_STORE3_32(int32_t, v4i32, v4i32, s32) +MSA_INTERLEAVED_IMPL_STORE3_32(float, v4f32, v4i32, f32) + +#define MSA_INTERLEAVED_IMPL_STORE3_64(_Tp, _Tpv, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + *ptr = a[0]; *(ptr + 1) = b[0]; *(ptr + 2) = c[0]; \ + *(ptr + 3) = a[1]; *(ptr + 4) = b[1]; *(ptr + 5) = c[1]; \ +} + +MSA_INTERLEAVED_IMPL_STORE3_64(uint64_t, v2u64, u64) +MSA_INTERLEAVED_IMPL_STORE3_64(int64_t, v2i64, s64) +MSA_INTERLEAVED_IMPL_STORE3_64(double, v2f64, f64) + +#define MSA_INTERLEAVED_IMPL_LOAD4_STORE4(_Tp, _Tpv, _Tpvs, suffix, df, nlanes) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld4q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c, _Tpv* d) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + nlanes); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + nlanes * 2); \ + _Tpv v3 = msa_ld1q_##suffix(ptr + nlanes * 3); \ + _Tpvs t0 = __builtin_msa_pckev_##df((_Tpvs)v1, (_Tpvs)v0); \ + _Tpvs t1 = __builtin_msa_pckev_##df((_Tpvs)v3, (_Tpvs)v2); \ + _Tpvs t2 = __builtin_msa_pckod_##df((_Tpvs)v1, (_Tpvs)v0); \ + _Tpvs t3 = __builtin_msa_pckod_##df((_Tpvs)v3, (_Tpvs)v2); \ + *a = (_Tpv)__builtin_msa_pckev_##df(t1, t0); \ + *b = (_Tpv)__builtin_msa_pckev_##df(t3, t2); \ + *c = (_Tpv)__builtin_msa_pckod_##df(t1, t0); \ + *d = (_Tpv)__builtin_msa_pckod_##df(t3, t2); \ +} \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st4q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c, const _Tpv d) \ +{ \ + _Tpvs v0 = __builtin_msa_ilvr_##df((_Tpvs)c, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_ilvr_##df((_Tpvs)d, (_Tpvs)b); \ + _Tpvs v2 = __builtin_msa_ilvl_##df((_Tpvs)c, (_Tpvs)a); \ + _Tpvs v3 = __builtin_msa_ilvl_##df((_Tpvs)d, (_Tpvs)b); \ + msa_st1q_##suffix(ptr, (_Tpv)__builtin_msa_ilvr_##df(v1, v0)); \ + msa_st1q_##suffix(ptr + nlanes, (_Tpv)__builtin_msa_ilvl_##df(v1, v0)); \ + msa_st1q_##suffix(ptr + 2 * nlanes, (_Tpv)__builtin_msa_ilvr_##df(v3, v2)); \ + msa_st1q_##suffix(ptr + 3 * nlanes, (_Tpv)__builtin_msa_ilvl_##df(v3, v2)); \ +} + +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(uint8_t, v16u8, v16i8, u8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(int8_t, v16i8, v16i8, s8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(uint16_t, v8u16, v8i16, u16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(int16_t, v8i16, v8i16, s16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(uint32_t, v4u32, v4i32, u32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(int32_t, v4i32, v4i32, s32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(float, v4f32, v4i32, f32, w, 4) + +#define MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld4q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c, _Tpv* d) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 2); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 4); \ + _Tpv v3 = msa_ld1q_##suffix(ptr + 6); \ + *a = (_Tpv)__builtin_msa_ilvr_d((_Tpvs)v2, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_ilvl_d((_Tpvs)v2, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_ilvr_d((_Tpvs)v3, (_Tpvs)v1); \ + *d = (_Tpv)__builtin_msa_ilvl_d((_Tpvs)v3, (_Tpvs)v1); \ +} \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st4q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c, const _Tpv d) \ +{ \ + msa_st1q_##suffix(ptr, (_Tpv)__builtin_msa_ilvr_d((_Tpvs)b, (_Tpvs)a)); \ + msa_st1q_##suffix(ptr + 2, (_Tpv)__builtin_msa_ilvr_d((_Tpvs)d, (_Tpvs)c)); \ + msa_st1q_##suffix(ptr + 4, (_Tpv)__builtin_msa_ilvl_d((_Tpvs)b, (_Tpvs)a)); \ + msa_st1q_##suffix(ptr + 6, (_Tpv)__builtin_msa_ilvl_d((_Tpvs)d, (_Tpvs)c)); \ +} + +MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(uint64_t, v2u64, v2i64, u64) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(int64_t, v2i64, v2i64, s64) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(double, v2f64, v2i64, f64) + +__extension__ extern __inline v8i16 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_qdmulhq_n_s16(v8i16 a, int16_t b) +{ + v8i16 a_lo, a_hi; + ILVRL_H2_SH(a, msa_dupq_n_s16(0), a_lo, a_hi); + return msa_packr_s32(msa_shlq_n_s32(msa_mulq_s32(msa_paddlq_s16(a_lo), msa_dupq_n_s32(b)), 1), + msa_shlq_n_s32(msa_mulq_s32(msa_paddlq_s16(a_hi), msa_dupq_n_s32(b)), 1), 16); +} + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /*__mips_msa*/ +#endif /* OPENCV_CORE_MSA_MACROS_H */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/hal/simd_utils.impl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/simd_utils.impl.hpp new file mode 100644 index 0000000..fff8f94 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/hal/simd_utils.impl.hpp @@ -0,0 +1,146 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +// This header is not standalone. Don't include directly, use "intrin.hpp" instead. +#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp + + +#if CV_SIMD128 || CV_SIMD128_CPP + +template struct Type2Vec128_Traits; +#define CV_INTRIN_DEF_TYPE2VEC128_TRAITS(type_, vec_type_) \ + template<> struct Type2Vec128_Traits \ + { \ + typedef vec_type_ vec_type; \ + } + +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uchar, v_uint8x16); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(schar, v_int8x16); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(ushort, v_uint16x8); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(short, v_int16x8); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(unsigned, v_uint32x4); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int, v_int32x4); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(float, v_float32x4); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uint64, v_uint64x2); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int64, v_int64x2); +#if CV_SIMD128_64F +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(double, v_float64x2); +#endif + +template static inline +typename Type2Vec128_Traits<_T>::vec_type v_setall(const _T& a); + +template<> inline Type2Vec128_Traits< uchar>::vec_type v_setall< uchar>(const uchar& a) { return v_setall_u8(a); } +template<> inline Type2Vec128_Traits< schar>::vec_type v_setall< schar>(const schar& a) { return v_setall_s8(a); } +template<> inline Type2Vec128_Traits::vec_type v_setall(const ushort& a) { return v_setall_u16(a); } +template<> inline Type2Vec128_Traits< short>::vec_type v_setall< short>(const short& a) { return v_setall_s16(a); } +template<> inline Type2Vec128_Traits< uint>::vec_type v_setall< uint>(const uint& a) { return v_setall_u32(a); } +template<> inline Type2Vec128_Traits< int>::vec_type v_setall< int>(const int& a) { return v_setall_s32(a); } +template<> inline Type2Vec128_Traits::vec_type v_setall(const uint64& a) { return v_setall_u64(a); } +template<> inline Type2Vec128_Traits< int64>::vec_type v_setall< int64>(const int64& a) { return v_setall_s64(a); } +template<> inline Type2Vec128_Traits< float>::vec_type v_setall< float>(const float& a) { return v_setall_f32(a); } +#if CV_SIMD128_64F +template<> inline Type2Vec128_Traits::vec_type v_setall(const double& a) { return v_setall_f64(a); } +#endif + +#endif // SIMD128 + + +#if CV_SIMD256 + +template struct Type2Vec256_Traits; +#define CV_INTRIN_DEF_TYPE2VEC256_TRAITS(type_, vec_type_) \ + template<> struct Type2Vec256_Traits \ + { \ + typedef vec_type_ vec_type; \ + } + +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uchar, v_uint8x32); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(schar, v_int8x32); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(ushort, v_uint16x16); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(short, v_int16x16); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(unsigned, v_uint32x8); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int, v_int32x8); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(float, v_float32x8); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uint64, v_uint64x4); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int64, v_int64x4); +#if CV_SIMD256_64F +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(double, v_float64x4); +#endif + +template static inline +typename Type2Vec256_Traits<_T>::vec_type v256_setall(const _T& a); + +template<> inline Type2Vec256_Traits< uchar>::vec_type v256_setall< uchar>(const uchar& a) { return v256_setall_u8(a); } +template<> inline Type2Vec256_Traits< schar>::vec_type v256_setall< schar>(const schar& a) { return v256_setall_s8(a); } +template<> inline Type2Vec256_Traits::vec_type v256_setall(const ushort& a) { return v256_setall_u16(a); } +template<> inline Type2Vec256_Traits< short>::vec_type v256_setall< short>(const short& a) { return v256_setall_s16(a); } +template<> inline Type2Vec256_Traits< uint>::vec_type v256_setall< uint>(const uint& a) { return v256_setall_u32(a); } +template<> inline Type2Vec256_Traits< int>::vec_type v256_setall< int>(const int& a) { return v256_setall_s32(a); } +template<> inline Type2Vec256_Traits::vec_type v256_setall(const uint64& a) { return v256_setall_u64(a); } +template<> inline Type2Vec256_Traits< int64>::vec_type v256_setall< int64>(const int64& a) { return v256_setall_s64(a); } +template<> inline Type2Vec256_Traits< float>::vec_type v256_setall< float>(const float& a) { return v256_setall_f32(a); } +#if CV_SIMD256_64F +template<> inline Type2Vec256_Traits::vec_type v256_setall(const double& a) { return v256_setall_f64(a); } +#endif + +#endif // SIMD256 + + +#if CV_SIMD512 + +template struct Type2Vec512_Traits; +#define CV_INTRIN_DEF_TYPE2VEC512_TRAITS(type_, vec_type_) \ + template<> struct Type2Vec512_Traits \ + { \ + typedef vec_type_ vec_type; \ + } + +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uchar, v_uint8x64); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(schar, v_int8x64); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(ushort, v_uint16x32); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(short, v_int16x32); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(unsigned, v_uint32x16); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int, v_int32x16); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(float, v_float32x16); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uint64, v_uint64x8); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int64, v_int64x8); +#if CV_SIMD512_64F +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(double, v_float64x8); +#endif + +template static inline +typename Type2Vec512_Traits<_T>::vec_type v512_setall(const _T& a); + +template<> inline Type2Vec512_Traits< uchar>::vec_type v512_setall< uchar>(const uchar& a) { return v512_setall_u8(a); } +template<> inline Type2Vec512_Traits< schar>::vec_type v512_setall< schar>(const schar& a) { return v512_setall_s8(a); } +template<> inline Type2Vec512_Traits::vec_type v512_setall(const ushort& a) { return v512_setall_u16(a); } +template<> inline Type2Vec512_Traits< short>::vec_type v512_setall< short>(const short& a) { return v512_setall_s16(a); } +template<> inline Type2Vec512_Traits< uint>::vec_type v512_setall< uint>(const uint& a) { return v512_setall_u32(a); } +template<> inline Type2Vec512_Traits< int>::vec_type v512_setall< int>(const int& a) { return v512_setall_s32(a); } +template<> inline Type2Vec512_Traits::vec_type v512_setall(const uint64& a) { return v512_setall_u64(a); } +template<> inline Type2Vec512_Traits< int64>::vec_type v512_setall< int64>(const int64& a) { return v512_setall_s64(a); } +template<> inline Type2Vec512_Traits< float>::vec_type v512_setall< float>(const float& a) { return v512_setall_f32(a); } +#if CV_SIMD512_64F +template<> inline Type2Vec512_Traits::vec_type v512_setall(const double& a) { return v512_setall_f64(a); } +#endif + +#endif // SIMD512 + + +#if CV_SIMD_WIDTH == 16 +template static inline +typename Type2Vec128_Traits<_T>::vec_type vx_setall(const _T& a) { return v_setall(a); } +#elif CV_SIMD_WIDTH == 32 +template static inline +typename Type2Vec256_Traits<_T>::vec_type vx_setall(const _T& a) { return v256_setall(a); } +#elif CV_SIMD_WIDTH == 64 +template static inline +typename Type2Vec512_Traits<_T>::vec_type vx_setall(const _T& a) { return v512_setall(a); } +#else +#error "Build configuration error, unsupported CV_SIMD_WIDTH" +#endif + + +#endif // OPENCV_HAL_INTRIN_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/mat.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/mat.hpp new file mode 100644 index 0000000..1ef0eb5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/mat.hpp @@ -0,0 +1,3766 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_MAT_HPP +#define OPENCV_CORE_MAT_HPP + +#ifndef __cplusplus +# error mat.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/matx.hpp" +#include "opencv2/core/types.hpp" + +#include "opencv2/core/bufferpool.hpp" + +#include + +namespace cv +{ + +//! @addtogroup core_basic +//! @{ + +enum AccessFlag { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, + ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 }; +CV_ENUM_FLAGS(AccessFlag) +__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, int, AccessFlag) + +CV__DEBUG_NS_BEGIN + +class CV_EXPORTS _OutputArray; + +//////////////////////// Input/Output Array Arguments ///////////////////////////////// + +/** @brief This is the proxy class for passing read-only input arrays into OpenCV functions. + +It is defined as: +@code + typedef const _InputArray& InputArray; +@endcode +where _InputArray is a class that can be constructed from `Mat`, `Mat_`, `Matx`, +`std::vector`, `std::vector >`, `std::vector`, `std::vector >`, +`UMat`, `std::vector` or `double`. It can also be constructed from a matrix expression. + +Since this is mostly implementation-level class, and its interface may change in future versions, we +do not describe it in details. There are a few key things, though, that should be kept in mind: + +- When you see in the reference manual or in OpenCV source code a function that takes + InputArray, it means that you can actually pass `Mat`, `Matx`, `vector` etc. (see above the + complete list). +- Optional input arguments: If some of the input arrays may be empty, pass cv::noArray() (or + simply cv::Mat() as you probably did before). +- The class is designed solely for passing parameters. That is, normally you *should not* + declare class members, local and global variables of this type. +- If you want to design your own function or a class method that can operate of arrays of + multiple types, you can use InputArray (or OutputArray) for the respective parameters. Inside + a function you should use _InputArray::getMat() method to construct a matrix header for the + array (without copying data). _InputArray::kind() can be used to distinguish Mat from + `vector<>` etc., but normally it is not needed. + +Here is how you can use a function that takes InputArray : +@code + std::vector vec; + // points or a circle + for( int i = 0; i < 30; i++ ) + vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)), + (float)(100 - 30*sin(i*CV_PI*2/5)))); + cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20)); +@endcode +That is, we form an STL vector containing points, and apply in-place affine transformation to the +vector using the 2x3 matrix created inline as `Matx` instance. + +Here is how such a function can be implemented (for simplicity, we implement a very specific case of +it, according to the assertion statement inside) : +@code + void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m) + { + // get Mat headers for input arrays. This is O(1) operation, + // unless _src and/or _m are matrix expressions. + Mat src = _src.getMat(), m = _m.getMat(); + CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); + + // [re]create the output array so that it has the proper size and type. + // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. + _dst.create(src.size(), src.type()); + Mat dst = _dst.getMat(); + + for( int i = 0; i < src.rows; i++ ) + for( int j = 0; j < src.cols; j++ ) + { + Point2f pt = src.at(i, j); + dst.at(i, j) = Point2f(m.at(0, 0)*pt.x + + m.at(0, 1)*pt.y + + m.at(0, 2), + m.at(1, 0)*pt.x + + m.at(1, 1)*pt.y + + m.at(1, 2)); + } + } +@endcode +There is another related type, InputArrayOfArrays, which is currently defined as a synonym for +InputArray: +@code + typedef InputArray InputArrayOfArrays; +@endcode +It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate +synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation +level their use is similar, but _InputArray::getMat(idx) should be used to get header for the +idx-th component of the outer vector and _InputArray::size().area() should be used to find the +number of components (vectors/matrices) of the outer vector. + +In general, type support is limited to cv::Mat types. Other types are forbidden. +But in some cases we need to support passing of custom non-general Mat types, like arrays of cv::KeyPoint, cv::DMatch, etc. +This data is not intended to be interpreted as an image data, or processed somehow like regular cv::Mat. +To pass such custom type use rawIn() / rawOut() / rawInOut() wrappers. +Custom type is wrapped as Mat-compatible `CV_8UC` values (N = sizeof(T), N <= CV_CN_MAX). + */ +class CV_EXPORTS _InputArray +{ +public: + enum KindFlag { + KIND_SHIFT = 16, + FIXED_TYPE = 0x8000 << KIND_SHIFT, + FIXED_SIZE = 0x4000 << KIND_SHIFT, + KIND_MASK = 31 << KIND_SHIFT, + + NONE = 0 << KIND_SHIFT, + MAT = 1 << KIND_SHIFT, + MATX = 2 << KIND_SHIFT, + STD_VECTOR = 3 << KIND_SHIFT, + STD_VECTOR_VECTOR = 4 << KIND_SHIFT, + STD_VECTOR_MAT = 5 << KIND_SHIFT, +#if OPENCV_ABI_COMPATIBILITY < 500 + EXPR = 6 << KIND_SHIFT, //!< removed: https://github.com/opencv/opencv/pull/17046 +#endif + OPENGL_BUFFER = 7 << KIND_SHIFT, + CUDA_HOST_MEM = 8 << KIND_SHIFT, + CUDA_GPU_MAT = 9 << KIND_SHIFT, + UMAT =10 << KIND_SHIFT, + STD_VECTOR_UMAT =11 << KIND_SHIFT, + STD_BOOL_VECTOR =12 << KIND_SHIFT, + STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT, +#if OPENCV_ABI_COMPATIBILITY < 500 + STD_ARRAY =14 << KIND_SHIFT, //!< removed: https://github.com/opencv/opencv/issues/18897 +#endif + STD_ARRAY_MAT =15 << KIND_SHIFT + }; + + _InputArray(); + _InputArray(int _flags, void* _obj); + _InputArray(const Mat& m); + _InputArray(const MatExpr& expr); + _InputArray(const std::vector& vec); + template _InputArray(const Mat_<_Tp>& m); + template _InputArray(const std::vector<_Tp>& vec); + _InputArray(const std::vector& vec); + template _InputArray(const std::vector >& vec); + _InputArray(const std::vector >&) = delete; // not supported + template _InputArray(const std::vector >& vec); + template _InputArray(const _Tp* vec, int n); + template _InputArray(const Matx<_Tp, m, n>& matx); + _InputArray(const double& val); + _InputArray(const cuda::GpuMat& d_mat); + _InputArray(const std::vector& d_mat_array); + _InputArray(const ogl::Buffer& buf); + _InputArray(const cuda::HostMem& cuda_mem); + template _InputArray(const cudev::GpuMat_<_Tp>& m); + _InputArray(const UMat& um); + _InputArray(const std::vector& umv); + + template _InputArray(const std::array<_Tp, _Nm>& arr); + template _InputArray(const std::array& arr); + + template static _InputArray rawIn(const std::vector<_Tp>& vec); + template static _InputArray rawIn(const std::array<_Tp, _Nm>& arr); + + Mat getMat(int idx=-1) const; + Mat getMat_(int idx=-1) const; + UMat getUMat(int idx=-1) const; + void getMatVector(std::vector& mv) const; + void getUMatVector(std::vector& umv) const; + void getGpuMatVector(std::vector& gpumv) const; + cuda::GpuMat getGpuMat() const; + ogl::Buffer getOGlBuffer() const; + + int getFlags() const; + void* getObj() const; + Size getSz() const; + + _InputArray::KindFlag kind() const; + int dims(int i=-1) const; + int cols(int i=-1) const; + int rows(int i=-1) const; + Size size(int i=-1) const; + int sizend(int* sz, int i=-1) const; + bool sameSize(const _InputArray& arr) const; + size_t total(int i=-1) const; + int type(int i=-1) const; + int depth(int i=-1) const; + int channels(int i=-1) const; + bool isContinuous(int i=-1) const; + bool isSubmatrix(int i=-1) const; + bool empty() const; + void copyTo(const _OutputArray& arr) const; + void copyTo(const _OutputArray& arr, const _InputArray & mask) const; + size_t offset(int i=-1) const; + size_t step(int i=-1) const; + bool isMat() const; + bool isUMat() const; + bool isMatVector() const; + bool isUMatVector() const; + bool isMatx() const; + bool isVector() const; + bool isGpuMat() const; + bool isGpuMatVector() const; + ~_InputArray(); + +protected: + int flags; + void* obj; + Size sz; + + void init(int _flags, const void* _obj); + void init(int _flags, const void* _obj, Size _sz); +}; +CV_ENUM_FLAGS(_InputArray::KindFlag) +__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, int, _InputArray::KindFlag) + +/** @brief This type is very similar to InputArray except that it is used for input/output and output function +parameters. + +Just like with InputArray, OpenCV users should not care about OutputArray, they just pass `Mat`, +`vector` etc. to the functions. The same limitation as for `InputArray`: *Do not explicitly +create OutputArray instances* applies here too. + +If you want to make your function polymorphic (i.e. accept different arrays as output parameters), +it is also not very difficult. Take the sample above as the reference. Note that +_OutputArray::create() needs to be called before _OutputArray::getMat(). This way you guarantee +that the output array is properly allocated. + +Optional output parameters. If you do not need certain output array to be computed and returned to +you, pass cv::noArray(), just like you would in the case of optional input array. At the +implementation level, use _OutputArray::needed() to check if certain output array needs to be +computed or not. + +There are several synonyms for OutputArray that are used to assist automatic Python/Java/... wrapper +generators: +@code + typedef OutputArray OutputArrayOfArrays; + typedef OutputArray InputOutputArray; + typedef OutputArray InputOutputArrayOfArrays; +@endcode + */ +class CV_EXPORTS _OutputArray : public _InputArray +{ +public: + enum DepthMask + { + DEPTH_MASK_8U = 1 << CV_8U, + DEPTH_MASK_8S = 1 << CV_8S, + DEPTH_MASK_16U = 1 << CV_16U, + DEPTH_MASK_16S = 1 << CV_16S, + DEPTH_MASK_32S = 1 << CV_32S, + DEPTH_MASK_32F = 1 << CV_32F, + DEPTH_MASK_64F = 1 << CV_64F, + DEPTH_MASK_16F = 1 << CV_16F, + DEPTH_MASK_ALL = (DEPTH_MASK_64F<<1)-1, + DEPTH_MASK_ALL_BUT_8S = DEPTH_MASK_ALL & ~DEPTH_MASK_8S, + DEPTH_MASK_ALL_16F = (DEPTH_MASK_16F<<1)-1, + DEPTH_MASK_FLT = DEPTH_MASK_32F + DEPTH_MASK_64F + }; + + _OutputArray(); + _OutputArray(int _flags, void* _obj); + _OutputArray(Mat& m); + _OutputArray(std::vector& vec); + _OutputArray(cuda::GpuMat& d_mat); + _OutputArray(std::vector& d_mat); + _OutputArray(ogl::Buffer& buf); + _OutputArray(cuda::HostMem& cuda_mem); + template _OutputArray(cudev::GpuMat_<_Tp>& m); + template _OutputArray(std::vector<_Tp>& vec); + _OutputArray(std::vector& vec) = delete; // not supported + template _OutputArray(std::vector >& vec); + _OutputArray(std::vector >&) = delete; // not supported + template _OutputArray(std::vector >& vec); + template _OutputArray(Mat_<_Tp>& m); + template _OutputArray(_Tp* vec, int n); + template _OutputArray(Matx<_Tp, m, n>& matx); + _OutputArray(UMat& m); + _OutputArray(std::vector& vec); + + _OutputArray(const Mat& m); + _OutputArray(const std::vector& vec); + _OutputArray(const cuda::GpuMat& d_mat); + _OutputArray(const std::vector& d_mat); + _OutputArray(const ogl::Buffer& buf); + _OutputArray(const cuda::HostMem& cuda_mem); + template _OutputArray(const cudev::GpuMat_<_Tp>& m); + template _OutputArray(const std::vector<_Tp>& vec); + template _OutputArray(const std::vector >& vec); + template _OutputArray(const std::vector >& vec); + template _OutputArray(const Mat_<_Tp>& m); + template _OutputArray(const _Tp* vec, int n); + template _OutputArray(const Matx<_Tp, m, n>& matx); + _OutputArray(const UMat& m); + _OutputArray(const std::vector& vec); + + template _OutputArray(std::array<_Tp, _Nm>& arr); + template _OutputArray(const std::array<_Tp, _Nm>& arr); + template _OutputArray(std::array& arr); + template _OutputArray(const std::array& arr); + + template static _OutputArray rawOut(std::vector<_Tp>& vec); + template static _OutputArray rawOut(std::array<_Tp, _Nm>& arr); + + bool fixedSize() const; + bool fixedType() const; + bool needed() const; + Mat& getMatRef(int i=-1) const; + UMat& getUMatRef(int i=-1) const; + cuda::GpuMat& getGpuMatRef() const; + std::vector& getGpuMatVecRef() const; + ogl::Buffer& getOGlBufferRef() const; + cuda::HostMem& getHostMemRef() const; + void create(Size sz, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; + void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; + void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; + void createSameSize(const _InputArray& arr, int mtype) const; + void release() const; + void clear() const; + void setTo(const _InputArray& value, const _InputArray & mask = _InputArray()) const; + + void assign(const UMat& u) const; + void assign(const Mat& m) const; + + void assign(const std::vector& v) const; + void assign(const std::vector& v) const; + + void move(UMat& u) const; + void move(Mat& m) const; +}; + + +class CV_EXPORTS _InputOutputArray : public _OutputArray +{ +public: + _InputOutputArray(); + _InputOutputArray(int _flags, void* _obj); + _InputOutputArray(Mat& m); + _InputOutputArray(std::vector& vec); + _InputOutputArray(cuda::GpuMat& d_mat); + _InputOutputArray(ogl::Buffer& buf); + _InputOutputArray(cuda::HostMem& cuda_mem); + template _InputOutputArray(cudev::GpuMat_<_Tp>& m); + template _InputOutputArray(std::vector<_Tp>& vec); + _InputOutputArray(std::vector& vec) = delete; // not supported + template _InputOutputArray(std::vector >& vec); + template _InputOutputArray(std::vector >& vec); + template _InputOutputArray(Mat_<_Tp>& m); + template _InputOutputArray(_Tp* vec, int n); + template _InputOutputArray(Matx<_Tp, m, n>& matx); + _InputOutputArray(UMat& m); + _InputOutputArray(std::vector& vec); + + _InputOutputArray(const Mat& m); + _InputOutputArray(const std::vector& vec); + _InputOutputArray(const cuda::GpuMat& d_mat); + _InputOutputArray(const std::vector& d_mat); + _InputOutputArray(const ogl::Buffer& buf); + _InputOutputArray(const cuda::HostMem& cuda_mem); + template _InputOutputArray(const cudev::GpuMat_<_Tp>& m); + template _InputOutputArray(const std::vector<_Tp>& vec); + template _InputOutputArray(const std::vector >& vec); + template _InputOutputArray(const std::vector >& vec); + template _InputOutputArray(const Mat_<_Tp>& m); + template _InputOutputArray(const _Tp* vec, int n); + template _InputOutputArray(const Matx<_Tp, m, n>& matx); + _InputOutputArray(const UMat& m); + _InputOutputArray(const std::vector& vec); + + template _InputOutputArray(std::array<_Tp, _Nm>& arr); + template _InputOutputArray(const std::array<_Tp, _Nm>& arr); + template _InputOutputArray(std::array& arr); + template _InputOutputArray(const std::array& arr); + + template static _InputOutputArray rawInOut(std::vector<_Tp>& vec); + template _InputOutputArray rawInOut(std::array<_Tp, _Nm>& arr); + +}; + +/** Helper to wrap custom types. @see InputArray */ +template static inline _InputArray rawIn(_Tp& v); +/** Helper to wrap custom types. @see InputArray */ +template static inline _OutputArray rawOut(_Tp& v); +/** Helper to wrap custom types. @see InputArray */ +template static inline _InputOutputArray rawInOut(_Tp& v); + +CV__DEBUG_NS_END + +typedef const _InputArray& InputArray; +typedef InputArray InputArrayOfArrays; +typedef const _OutputArray& OutputArray; +typedef OutputArray OutputArrayOfArrays; +typedef const _InputOutputArray& InputOutputArray; +typedef InputOutputArray InputOutputArrayOfArrays; + +CV_EXPORTS InputOutputArray noArray(); + +/////////////////////////////////// MatAllocator ////////////////////////////////////// + +//! Usage flags for allocator +enum UMatUsageFlags +{ + USAGE_DEFAULT = 0, + + // buffer allocation policy is platform and usage specific + USAGE_ALLOCATE_HOST_MEMORY = 1 << 0, + USAGE_ALLOCATE_DEVICE_MEMORY = 1 << 1, + USAGE_ALLOCATE_SHARED_MEMORY = 1 << 2, // It is not equal to: USAGE_ALLOCATE_HOST_MEMORY | USAGE_ALLOCATE_DEVICE_MEMORY + + __UMAT_USAGE_FLAGS_32BIT = 0x7fffffff // Binary compatibility hint +}; + +struct CV_EXPORTS UMatData; + +/** @brief Custom array allocator +*/ +class CV_EXPORTS MatAllocator +{ +public: + MatAllocator() {} + virtual ~MatAllocator() {} + + // let's comment it off for now to detect and fix all the uses of allocator + //virtual void allocate(int dims, const int* sizes, int type, int*& refcount, + // uchar*& datastart, uchar*& data, size_t* step) = 0; + //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; + virtual UMatData* allocate(int dims, const int* sizes, int type, + void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0; + virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0; + virtual void deallocate(UMatData* data) const = 0; + virtual void map(UMatData* data, AccessFlag accessflags) const; + virtual void unmap(UMatData* data) const; + virtual void download(UMatData* data, void* dst, int dims, const size_t sz[], + const size_t srcofs[], const size_t srcstep[], + const size_t dststep[]) const; + virtual void upload(UMatData* data, const void* src, int dims, const size_t sz[], + const size_t dstofs[], const size_t dststep[], + const size_t srcstep[]) const; + virtual void copy(UMatData* srcdata, UMatData* dstdata, int dims, const size_t sz[], + const size_t srcofs[], const size_t srcstep[], + const size_t dstofs[], const size_t dststep[], bool sync) const; + + // default implementation returns DummyBufferPoolController + virtual BufferPoolController* getBufferPoolController(const char* id = NULL) const; +}; + + +//////////////////////////////// MatCommaInitializer ////////////////////////////////// + +/** @brief Comma-separated Matrix Initializer + + The class instances are usually not created explicitly. + Instead, they are created on "matrix << firstValue" operator. + + The sample below initializes 2x2 rotation matrix: + + \code + double angle = 30, a = cos(angle*CV_PI/180), b = sin(angle*CV_PI/180); + Mat R = (Mat_(2,2) << a, -b, b, a); + \endcode +*/ +template class MatCommaInitializer_ +{ +public: + //! the constructor, created by "matrix << firstValue" operator, where matrix is cv::Mat + MatCommaInitializer_(Mat_<_Tp>* _m); + //! the operator that takes the next value and put it to the matrix + template MatCommaInitializer_<_Tp>& operator , (T2 v); + //! another form of conversion operator + operator Mat_<_Tp>() const; +protected: + MatIterator_<_Tp> it; +}; + + +/////////////////////////////////////// Mat /////////////////////////////////////////// + +// note that umatdata might be allocated together +// with the matrix data, not as a separate object. +// therefore, it does not have constructor or destructor; +// it should be explicitly initialized using init(). +struct CV_EXPORTS UMatData +{ + enum MemoryFlag { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2, + DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24, + USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64, + ASYNC_CLEANUP=128 + }; + UMatData(const MatAllocator* allocator); + ~UMatData(); + + // provide atomic access to the structure + void lock(); + void unlock(); + + bool hostCopyObsolete() const; + bool deviceCopyObsolete() const; + bool deviceMemMapped() const; + bool copyOnMap() const; + bool tempUMat() const; + bool tempCopiedUMat() const; + void markHostCopyObsolete(bool flag); + void markDeviceCopyObsolete(bool flag); + void markDeviceMemMapped(bool flag); + + const MatAllocator* prevAllocator; + const MatAllocator* currAllocator; + int urefcount; + int refcount; + uchar* data; + uchar* origdata; + size_t size; + + UMatData::MemoryFlag flags; + void* handle; + void* userdata; + int allocatorFlags_; + int mapcount; + UMatData* originalUMatData; + std::shared_ptr allocatorContext; +}; +CV_ENUM_FLAGS(UMatData::MemoryFlag) + + +struct CV_EXPORTS MatSize +{ + explicit MatSize(int* _p) CV_NOEXCEPT; + int dims() const CV_NOEXCEPT; + Size operator()() const; + const int& operator[](int i) const; + int& operator[](int i); + operator const int*() const CV_NOEXCEPT; // TODO OpenCV 4.0: drop this + bool operator == (const MatSize& sz) const CV_NOEXCEPT; + bool operator != (const MatSize& sz) const CV_NOEXCEPT; + + int* p; +}; + +struct CV_EXPORTS MatStep +{ + MatStep() CV_NOEXCEPT; + explicit MatStep(size_t s) CV_NOEXCEPT; + const size_t& operator[](int i) const CV_NOEXCEPT; + size_t& operator[](int i) CV_NOEXCEPT; + operator size_t() const; + MatStep& operator = (size_t s); + + size_t* p; + size_t buf[2]; +protected: + MatStep& operator = (const MatStep&); +}; + +/** @example samples/cpp/cout_mat.cpp +An example demonstrating the serial out capabilities of cv::Mat +*/ + + /** @brief n-dimensional dense array class \anchor CVMat_Details + +The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It +can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel +volumes, vector fields, point clouds, tensors, histograms (though, very high-dimensional histograms +may be better stored in a SparseMat ). The data layout of the array `M` is defined by the array +`M.step[]`, so that the address of element \f$(i_0,...,i_{M.dims-1})\f$, where \f$0\leq i_k= M.step[i+1]` (in fact, `M.step[i] >= M.step[i+1]*M.size[i+1]` ). This means +that 2-dimensional matrices are stored row-by-row, 3-dimensional matrices are stored plane-by-plane, +and so on. M.step[M.dims-1] is minimal and always equal to the element size M.elemSize() . + +So, the data layout in Mat is compatible with the majority of dense array types from the standard +toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device bitmaps), and others, +that is, with any array that uses *steps* (or *strides*) to compute the position of a pixel. +Due to this compatibility, it is possible to make a Mat header for user-allocated data and process +it in-place using OpenCV functions. + +There are many different ways to create a Mat object. The most popular options are listed below: + +- Use the create(nrows, ncols, type) method or the similar Mat(nrows, ncols, type[, fillValue]) +constructor. A new array of the specified size and type is allocated. type has the same meaning as +in the cvCreateMat method. For example, CV_8UC1 means a 8-bit single-channel array, CV_32FC2 +means a 2-channel (complex) floating-point array, and so on. +@code + // make a 7x7 complex matrix filled with 1+3j. + Mat M(7,7,CV_32FC2,Scalar(1,3)); + // and now turn M to a 100x60 15-channel 8-bit matrix. + // The old content will be deallocated + M.create(100,60,CV_8UC(15)); +@endcode +As noted in the introduction to this chapter, create() allocates only a new array when the shape +or type of the current array are different from the specified ones. + +- Create a multi-dimensional array: +@code + // create a 100x100x100 8-bit array + int sz[] = {100, 100, 100}; + Mat bigCube(3, sz, CV_8U, Scalar::all(0)); +@endcode +It passes the number of dimensions =1 to the Mat constructor but the created array will be +2-dimensional with the number of columns set to 1. So, Mat::dims is always \>= 2 (can also be 0 +when the array is empty). + +- Use a copy constructor or assignment operator where there can be an array or expression on the +right side (see below). As noted in the introduction, the array assignment is an O(1) operation +because it only copies the header and increases the reference counter. The Mat::clone() method can +be used to get a full (deep) copy of the array when you need it. + +- Construct a header for a part of another array. It can be a single row, single column, several +rows, several columns, rectangular region in the array (called a *minor* in algebra) or a +diagonal. Such operations are also O(1) because the new header references the same data. You can +actually modify a part of the array using this feature, for example: +@code + // add the 5-th row, multiplied by 3 to the 3rd row + M.row(3) = M.row(3) + M.row(5)*3; + // now copy the 7-th column to the 1-st column + // M.col(1) = M.col(7); // this will not work + Mat M1 = M.col(1); + M.col(7).copyTo(M1); + // create a new 320x240 image + Mat img(Size(320,240),CV_8UC3); + // select a ROI + Mat roi(img, Rect(10,10,100,100)); + // fill the ROI with (0,255,0) (which is green in RGB space); + // the original 320x240 image will be modified + roi = Scalar(0,255,0); +@endcode +Due to the additional datastart and dataend members, it is possible to compute a relative +sub-array position in the main *container* array using locateROI(): +@code + Mat A = Mat::eye(10, 10, CV_32S); + // extracts A columns, 1 (inclusive) to 3 (exclusive). + Mat B = A(Range::all(), Range(1, 3)); + // extracts B rows, 5 (inclusive) to 9 (exclusive). + // that is, C \~ A(Range(5, 9), Range(1, 3)) + Mat C = B(Range(5, 9), Range::all()); + Size size; Point ofs; + C.locateROI(size, ofs); + // size will be (width=10,height=10) and the ofs will be (x=1, y=5) +@endcode +As in case of whole matrices, if you need a deep copy, use the `clone()` method of the extracted +sub-matrices. + +- Make a header for user-allocated data. It can be useful to do the following: + -# Process "foreign" data using OpenCV (for example, when you implement a DirectShow\* filter or + a processing module for gstreamer, and so on). For example: + @code + Mat process_video_frame(const unsigned char* pixels, + int width, int height, int step) + { + // wrap input buffer + Mat img(height, width, CV_8UC3, (unsigned char*)pixels, step); + + Mat result; + GaussianBlur(img, result, Size(7, 7), 1.5, 1.5); + + return result; + } + @endcode + -# Quickly initialize small matrices and/or get a super-fast element access. + @code + double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}}; + Mat M = Mat(3, 3, CV_64F, m).inv(); + @endcode + . + +- Use MATLAB-style array initializers, zeros(), ones(), eye(), for example: +@code + // create a double-precision identity matrix and add it to M. + M += Mat::eye(M.rows, M.cols, CV_64F); +@endcode + +- Use a comma-separated initializer: +@code + // create a 3x3 double-precision identity matrix + Mat M = (Mat_(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1); +@endcode +With this approach, you first call a constructor of the Mat class with the proper parameters, and +then you just put `<< operator` followed by comma-separated values that can be constants, +variables, expressions, and so on. Also, note the extra parentheses required to avoid compilation +errors. + +Once the array is created, it is automatically managed via a reference-counting mechanism. If the +array header is built on top of user-allocated data, you should handle the data by yourself. The +array data is deallocated when no one points to it. If you want to release the data pointed by a +array header before the array destructor is called, use Mat::release(). + +The next important thing to learn about the array class is element access. This manual already +described how to compute an address of each array element. Normally, you are not required to use the +formula directly in the code. If you know the array element type (which can be retrieved using the +method Mat::type() ), you can access the element \f$M_{ij}\f$ of a 2-dimensional array as: +@code + M.at(i,j) += 1.f; +@endcode +assuming that `M` is a double-precision floating-point array. There are several variants of the method +at for a different number of dimensions. + +If you need to process a whole row of a 2D array, the most efficient way is to get the pointer to +the row first, and then just use the plain C operator [] : +@code + // compute sum of positive matrix elements + // (assuming that M is a double-precision matrix) + double sum=0; + for(int i = 0; i < M.rows; i++) + { + const double* Mi = M.ptr(i); + for(int j = 0; j < M.cols; j++) + sum += std::max(Mi[j], 0.); + } +@endcode +Some operations, like the one above, do not actually depend on the array shape. They just process +elements of an array one by one (or elements from multiple arrays that have the same coordinates, +for example, array addition). Such operations are called *element-wise*. It makes sense to check +whether all the input/output arrays are continuous, namely, have no gaps at the end of each row. If +yes, process them as a long single row: +@code + // compute the sum of positive matrix elements, optimized variant + double sum=0; + int cols = M.cols, rows = M.rows; + if(M.isContinuous()) + { + cols *= rows; + rows = 1; + } + for(int i = 0; i < rows; i++) + { + const double* Mi = M.ptr(i); + for(int j = 0; j < cols; j++) + sum += std::max(Mi[j], 0.); + } +@endcode +In case of the continuous matrix, the outer loop body is executed just once. So, the overhead is +smaller, which is especially noticeable in case of small matrices. + +Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows: +@code + // compute sum of positive matrix elements, iterator-based variant + double sum=0; + MatConstIterator_ it = M.begin(), it_end = M.end(); + for(; it != it_end; ++it) + sum += std::max(*it, 0.); +@endcode +The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, +including std::sort(). + +@note Matrix Expressions and arithmetic see MatExpr +*/ +class CV_EXPORTS Mat +{ +public: + /** + These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + The constructed matrix can further be assigned to another matrix or matrix expression or can be + allocated with Mat::create . In the former case, the old content is de-referenced. + */ + Mat() CV_NOEXCEPT; + + /** @overload + @param rows Number of rows in a 2D array. + @param cols Number of columns in a 2D array. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(int rows, int cols, int type); + + /** @overload + @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + number of columns go in the reverse order. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(Size size, int type); + + /** @overload + @param rows Number of rows in a 2D array. + @param cols Number of columns in a 2D array. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(int rows, int cols, int type, const Scalar& s); + + /** @overload + @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + number of columns go in the reverse order. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(Size size, int type, const Scalar& s); + + /** @overload + @param ndims Array dimensionality. + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(int ndims, const int* sizes, int type); + + /** @overload + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(const std::vector& sizes, int type); + + /** @overload + @param ndims Array dimensionality. + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(int ndims, const int* sizes, int type, const Scalar& s); + + /** @overload + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(const std::vector& sizes, int type, const Scalar& s); + + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + */ + Mat(const Mat& m); + + /** @overload + @param rows Number of rows in a 2D array. + @param cols Number of columns in a 2D array. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param step Number of bytes each matrix row occupies. The value should include the padding bytes at + the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + */ + Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP); + + /** @overload + @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + number of columns go in the reverse order. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param step Number of bytes each matrix row occupies. The value should include the padding bytes at + the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + */ + Mat(Size size, int type, void* data, size_t step=AUTO_STEP); + + /** @overload + @param ndims Array dimensionality. + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + set to the element size). If not specified, the matrix is assumed to be continuous. + */ + Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0); + + /** @overload + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + set to the element size). If not specified, the matrix is assumed to be continuous. + */ + Mat(const std::vector& sizes, int type, void* data, const size_t* steps=0); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param rowRange Range of the m rows to take. As usual, the range start is inclusive and the range + end is exclusive. Use Range::all() to take all the rows. + @param colRange Range of the m columns to take. Use Range::all() to take all the columns. + */ + Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all()); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param roi Region of interest. + */ + Mat(const Mat& m, const Rect& roi); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param ranges Array of selected ranges of m along each dimensionality. + */ + Mat(const Mat& m, const Range* ranges); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param ranges Array of selected ranges of m along each dimensionality. + */ + Mat(const Mat& m, const std::vector& ranges); + + /** @overload + @param vec STL vector whose elements form the matrix. The matrix has a single column and the number + of rows equal to the number of vector elements. Type of the matrix matches the type of vector + elements. The constructor can handle arbitrary types, for which there is a properly declared + DataType . This means that the vector elements must be primitive numbers or uni-type numerical + tuples of numbers. Mixed-type structures are not supported. The corresponding constructor is + explicit. Since STL vectors are not automatically converted to Mat instances, you should write + Mat(vec) explicitly. Unless you copy the data into the matrix ( copyData=true ), no new elements + will be added to the vector because it can potentially yield vector data reallocation, and, thus, + the matrix data pointer will be invalid. + @param copyData Flag to specify whether the underlying data of the STL vector should be copied + to (true) or shared with (false) the newly constructed matrix. When the data is copied, the + allocated buffer is managed using Mat reference counting mechanism. While the data is shared, + the reference counter is NULL, and you should not deallocate the data until the matrix is not + destructed. + */ + template explicit Mat(const std::vector<_Tp>& vec, bool copyData=false); + + /** @overload + */ + template::value>::type> + explicit Mat(const std::initializer_list<_Tp> list); + + /** @overload + */ + template explicit Mat(const std::initializer_list sizes, const std::initializer_list<_Tp> list); + + /** @overload + */ + template explicit Mat(const std::array<_Tp, _Nm>& arr, bool copyData=false); + + /** @overload + */ + template explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true); + + /** @overload + */ + template explicit Mat(const Matx<_Tp, m, n>& mtx, bool copyData=true); + + /** @overload + */ + template explicit Mat(const Point_<_Tp>& pt, bool copyData=true); + + /** @overload + */ + template explicit Mat(const Point3_<_Tp>& pt, bool copyData=true); + + /** @overload + */ + template explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer); + + //! download data from GpuMat + explicit Mat(const cuda::GpuMat& m); + + //! destructor - calls release() + ~Mat(); + + /** @brief assignment operators + + These are available assignment operators. Since they all are very different, make sure to read the + operator parameters description. + @param m Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that + no data is copied but the data is shared and the reference counter, if any, is incremented. Before + assigning new data, the old data is de-referenced via Mat::release . + */ + Mat& operator = (const Mat& m); + + /** @overload + @param expr Assigned matrix expression object. As opposite to the first form of the assignment + operation, the second form can reuse already allocated matrix if it has the right size and type to + fit the matrix expression result. It is automatically handled by the real function that the matrix + expressions is expanded to. For example, C=A+B is expanded to add(A, B, C), and add takes care of + automatic C reallocation. + */ + Mat& operator = (const MatExpr& expr); + + //! retrieve UMat from Mat + UMat getUMat(AccessFlag accessFlags, UMatUsageFlags usageFlags = USAGE_DEFAULT) const; + + /** @brief Creates a matrix header for the specified matrix row. + + The method makes a new header for the specified matrix row and returns it. This is an O(1) + operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + original matrix. Here is the example of one of the classical basic matrix processing operations, + axpy, used by LU and many other algorithms: + @code + inline void matrix_axpy(Mat& A, int i, int j, double alpha) + { + A.row(i) += A.row(j)*alpha; + } + @endcode + @note In the current implementation, the following code does not work as expected: + @code + Mat A; + ... + A.row(i) = A.row(j); // will not work + @endcode + This happens because A.row(i) forms a temporary header that is further assigned to another header. + Remember that each of these operations is O(1), that is, no data is copied. Thus, the above + assignment is not true if you may have expected the j-th row to be copied to the i-th row. To + achieve that, you should either turn this simple assignment into an expression or use the + Mat::copyTo method: + @code + Mat A; + ... + // works, but looks a bit obscure. + A.row(i) = A.row(j) + 0; + // this is a bit longer, but the recommended method. + A.row(j).copyTo(A.row(i)); + @endcode + @param y A 0-based row index. + */ + Mat row(int y) const; + + /** @brief Creates a matrix header for the specified matrix column. + + The method makes a new header for the specified matrix column and returns it. This is an O(1) + operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + original matrix. See also the Mat::row description. + @param x A 0-based column index. + */ + Mat col(int x) const; + + /** @brief Creates a matrix header for the specified row span. + + The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and + Mat::col , this is an O(1) operation. + @param startrow An inclusive 0-based start index of the row span. + @param endrow An exclusive 0-based ending index of the row span. + */ + Mat rowRange(int startrow, int endrow) const; + + /** @overload + @param r Range structure containing both the start and the end indices. + */ + Mat rowRange(const Range& r) const; + + /** @brief Creates a matrix header for the specified column span. + + The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and + Mat::col , this is an O(1) operation. + @param startcol An inclusive 0-based start index of the column span. + @param endcol An exclusive 0-based ending index of the column span. + */ + Mat colRange(int startcol, int endcol) const; + + /** @overload + @param r Range structure containing both the start and the end indices. + */ + Mat colRange(const Range& r) const; + + /** @brief Extracts a diagonal from a matrix + + The method makes a new header for the specified matrix diagonal. The new matrix is represented as a + single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. + @param d index of the diagonal, with the following values: + - `d=0` is the main diagonal. + - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set + immediately below the main one. + - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set + immediately above the main one. + For example: + @code + Mat m = (Mat_(3,3) << + 1,2,3, + 4,5,6, + 7,8,9); + Mat d0 = m.diag(0); + Mat d1 = m.diag(1); + Mat d_1 = m.diag(-1); + @endcode + The resulting matrices are + @code + d0 = + [1; + 5; + 9] + d1 = + [2; + 6] + d_1 = + [4; + 8] + @endcode + */ + Mat diag(int d=0) const; + + /** @brief creates a diagonal matrix + + The method creates a square diagonal matrix from specified main diagonal. + @param d One-dimensional matrix that represents the main diagonal. + */ + CV_NODISCARD_STD static Mat diag(const Mat& d); + + /** @brief Creates a full copy of the array and the underlying data. + + The method creates a full copy of the array. The original step[] is not taken into account. So, the + array copy is a continuous array occupying total()*elemSize() bytes. + */ + CV_NODISCARD_STD Mat clone() const; + + /** @brief Copies the matrix to another one. + + The method copies the matrix data to another matrix. Before copying the data, the method invokes : + @code + m.create(this->size(), this->type()); + @endcode + so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the + function does not handle the case of a partial overlap between the source and the destination + matrices. + + When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, + the newly allocated matrix is initialized with all zeros before copying the data. + @param m Destination matrix. If it does not have a proper size or type before the operation, it is + reallocated. + */ + void copyTo( OutputArray m ) const; + + /** @overload + @param m Destination matrix. If it does not have a proper size or type before the operation, it is + reallocated. + @param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. + */ + void copyTo( OutputArray m, InputArray mask ) const; + + /** @brief Converts an array to another data type with optional scaling. + + The method converts source pixel values to the target data type. saturate_cast\<\> is applied at + the end to avoid possible overflows: + + \f[m(x,y) = saturate \_ cast( \alpha (*this)(x,y) + \beta )\f] + @param m output matrix; if it does not have a proper size or type before the operation, it is + reallocated. + @param rtype desired output matrix type or, rather, the depth since the number of channels are the + same as the input has; if rtype is negative, the output matrix will have the same type as the input. + @param alpha optional scale factor. + @param beta optional delta added to the scaled values. + */ + void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + + /** @brief Provides a functional form of convertTo. + + This is an internally used method called by the @ref MatrixExpressions engine. + @param m Destination array. + @param type Desired destination array depth (or -1 if it should be the same as the source type). + */ + void assignTo( Mat& m, int type=-1 ) const; + + /** @brief Sets all or some of the array elements to the specified value. + @param s Assigned scalar converted to the actual array type. + */ + Mat& operator = (const Scalar& s); + + /** @brief Sets all or some of the array elements to the specified value. + + This is an advanced variant of the Mat::operator=(const Scalar& s) operator. + @param value Assigned scalar converted to the actual array type. + @param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels + */ + Mat& setTo(InputArray value, InputArray mask=noArray()); + + /** @brief Changes the shape and/or the number of channels of a 2D matrix without copying the data. + + The method makes a new matrix header for \*this elements. The new matrix may have a different size + and/or different number of channels. Any combination is possible if: + - No extra elements are included into the new matrix and no elements are excluded. Consequently, + the product rows\*cols\*channels() must stay the same after the transformation. + - No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + rows, or the operation changes the indices of elements row in some other way, the matrix must be + continuous. See Mat::isContinuous . + + For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + points as a 3xN matrix, do the following: + @code + std::vector vec; + ... + Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + // Also, an O(1) operation + t(); // finally, transpose the Nx3 matrix. + // This involves copying all the elements + @endcode + @param cn New number of channels. If the parameter is 0, the number of channels remains the same. + @param rows New number of rows. If the parameter is 0, the number of rows remains the same. + */ + Mat reshape(int cn, int rows=0) const; + + /** @overload */ + Mat reshape(int cn, int newndims, const int* newsz) const; + + /** @overload */ + Mat reshape(int cn, const std::vector& newshape) const; + + /** @brief Transposes a matrix. + + The method performs matrix transposition by means of matrix expressions. It does not perform the + actual transposition but returns a temporary matrix transposition object that can be further used as + a part of more complex matrix expressions or can be assigned to a matrix: + @code + Mat A1 = A + Mat::eye(A.size(), A.type())*lambda; + Mat C = A1.t()*A1; // compute (A + lambda*I)^t * (A + lamda*I) + @endcode + */ + MatExpr t() const; + + /** @brief Inverses a matrix. + + The method performs a matrix inversion by means of matrix expressions. This means that a temporary + matrix inversion object is returned by the method and can be used further as a part of more complex + matrix expressions or can be assigned to a matrix. + @param method Matrix inversion method. One of cv::DecompTypes + */ + MatExpr inv(int method=DECOMP_LU) const; + + /** @brief Performs an element-wise multiplication or division of the two matrices. + + The method returns a temporary object encoding per-element array multiplication, with optional + scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator. + + Example: + @code + Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5) + @endcode + @param m Another array of the same type and the same size as \*this, or a matrix expression. + @param scale Optional scale factor. + */ + MatExpr mul(InputArray m, double scale=1) const; + + /** @brief Computes a cross-product of two 3-element vectors. + + The method computes a cross-product of two 3-element vectors. The vectors must be 3-element + floating-point vectors of the same shape and size. The result is another 3-element vector of the + same shape and type as operands. + @param m Another cross-product operand. + */ + Mat cross(InputArray m) const; + + /** @brief Computes a dot-product of two vectors. + + The method computes a dot-product of two matrices. If the matrices are not single-column or + single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D + vectors. The vectors must have the same size and type. If the matrices have more than one channel, + the dot products from all the channels are summed together. + @param m another dot-product operand. + */ + double dot(InputArray m) const; + + /** @brief Returns a zero array of the specified size and type. + + The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant + array as a function parameter, part of a matrix expression, or as a matrix initializer: + @code + Mat A; + A = Mat::zeros(3, 3, CV_32F); + @endcode + In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. + Otherwise, the existing matrix A is filled with zeros. + @param rows Number of rows. + @param cols Number of columns. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr zeros(int rows, int cols, int type); + + /** @overload + @param size Alternative to the matrix size specification Size(cols, rows) . + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr zeros(Size size, int type); + + /** @overload + @param ndims Array dimensionality. + @param sz Array of integers specifying the array shape. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr zeros(int ndims, const int* sz, int type); + + /** @brief Returns an array of all 1's of the specified size and type. + + The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using + this method you can initialize an array with an arbitrary value, using the following Matlab idiom: + @code + Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. + @endcode + The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it + just remembers the scale factor (3 in this case) and use it when actually invoking the matrix + initializer. + @note In case of multi-channels type, only the first channel will be initialized with 1's, the + others will be set to 0's. + @param rows Number of rows. + @param cols Number of columns. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr ones(int rows, int cols, int type); + + /** @overload + @param size Alternative to the matrix size specification Size(cols, rows) . + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr ones(Size size, int type); + + /** @overload + @param ndims Array dimensionality. + @param sz Array of integers specifying the array shape. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr ones(int ndims, const int* sz, int type); + + /** @brief Returns an identity matrix of the specified size and type. + + The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to + Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: + @code + // make a 4x4 diagonal matrix with 0.1's on the diagonal. + Mat A = Mat::eye(4, 4, CV_32F)*0.1; + @endcode + @note In case of multi-channels type, identity matrix will be initialized only for the first channel, + the others will be set to 0's + @param rows Number of rows. + @param cols Number of columns. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr eye(int rows, int cols, int type); + + /** @overload + @param size Alternative matrix size specification as Size(cols, rows) . + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr eye(Size size, int type); + + /** @brief Allocates new array data if needed. + + This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays + call this method for each output array. The method uses the following algorithm: + + -# If the current array shape and the type match the new ones, return immediately. Otherwise, + de-reference the previous data by calling Mat::release. + -# Initialize the new header. + -# Allocate the new data of total()\*elemSize() bytes. + -# Allocate the new, associated with the data, reference counter and set it to 1. + + Such a scheme makes the memory management robust and efficient at the same time and helps avoid + extra typing for you. This means that usually there is no need to explicitly allocate output arrays. + That is, instead of writing: + @code + Mat color; + ... + Mat gray(color.rows, color.cols, color.depth()); + cvtColor(color, gray, COLOR_BGR2GRAY); + @endcode + you can simply write: + @code + Mat color; + ... + Mat gray; + cvtColor(color, gray, COLOR_BGR2GRAY); + @endcode + because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array + internally. + @param rows New number of rows. + @param cols New number of columns. + @param type New matrix type. + */ + void create(int rows, int cols, int type); + + /** @overload + @param size Alternative new matrix size specification: Size(cols, rows) + @param type New matrix type. + */ + void create(Size size, int type); + + /** @overload + @param ndims New array dimensionality. + @param sizes Array of integers specifying a new array shape. + @param type New matrix type. + */ + void create(int ndims, const int* sizes, int type); + + /** @overload + @param sizes Array of integers specifying a new array shape. + @param type New matrix type. + */ + void create(const std::vector& sizes, int type); + + /** @brief Increments the reference counter. + + The method increments the reference counter associated with the matrix data. If the matrix header + points to an external data set (see Mat::Mat ), the reference counter is NULL, and the method has no + effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It + is called implicitly by the matrix assignment operator. The reference counter increment is an atomic + operation on the platforms that support it. Thus, it is safe to operate on the same matrices + asynchronously in different threads. + */ + void addref(); + + /** @brief Decrements the reference counter and deallocates the matrix if needed. + + The method decrements the reference counter associated with the matrix data. When the reference + counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers + are set to NULL's. If the matrix header points to an external data set (see Mat::Mat ), the + reference counter is NULL, and the method has no effect in this case. + + This method can be called manually to force the matrix data deallocation. But since this method is + automatically called in the destructor, or by any other method that changes the data pointer, it is + usually not needed. The reference counter decrement and check for 0 is an atomic operation on the + platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in + different threads. + */ + void release(); + + //! internal use function, consider to use 'release' method instead; deallocates the matrix data + void deallocate(); + //! internal use function; properly re-allocates _size, _step arrays + void copySize(const Mat& m); + + /** @brief Reserves space for the certain number of rows. + + The method reserves space for sz rows. If the matrix already has enough space to store sz rows, + nothing happens. If the matrix is reallocated, the first Mat::rows rows are preserved. The method + emulates the corresponding method of the STL vector class. + @param sz Number of rows. + */ + void reserve(size_t sz); + + /** @brief Reserves space for the certain number of bytes. + + The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes, + nothing happens. If matrix has to be reallocated its previous content could be lost. + @param sz Number of bytes. + */ + void reserveBuffer(size_t sz); + + /** @brief Changes the number of matrix rows. + + The methods change the number of matrix rows. If the matrix is reallocated, the first + min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL + vector class. + @param sz New number of rows. + */ + void resize(size_t sz); + + /** @overload + @param sz New number of rows. + @param s Value assigned to the newly added elements. + */ + void resize(size_t sz, const Scalar& s); + + //! internal function + void push_back_(const void* elem); + + /** @brief Adds elements to the bottom of the matrix. + + The methods add one or more elements to the bottom of the matrix. They emulate the corresponding + method of the STL vector class. When elem is Mat , its type and the number of columns must be the + same as in the container matrix. + @param elem Added element(s). + */ + template void push_back(const _Tp& elem); + + /** @overload + @param elem Added element(s). + */ + template void push_back(const Mat_<_Tp>& elem); + + /** @overload + @param elem Added element(s). + */ + template void push_back(const std::vector<_Tp>& elem); + + /** @overload + @param m Added line(s). + */ + void push_back(const Mat& m); + + /** @brief Removes elements from the bottom of the matrix. + + The method removes one or more rows from the bottom of the matrix. + @param nelems Number of removed rows. If it is greater than the total number of rows, an exception + is thrown. + */ + void pop_back(size_t nelems=1); + + /** @brief Locates the matrix header within a parent matrix. + + After you extracted a submatrix from a matrix using Mat::row, Mat::col, Mat::rowRange, + Mat::colRange, and others, the resultant submatrix points just to the part of the original big + matrix. However, each submatrix contains information (represented by datastart and dataend + fields) that helps reconstruct the original matrix size and the position of the extracted + submatrix within the original matrix. The method locateROI does exactly that. + @param wholeSize Output parameter that contains the size of the whole matrix containing *this* + as a part. + @param ofs Output parameter that contains an offset of *this* inside the whole matrix. + */ + void locateROI( Size& wholeSize, Point& ofs ) const; + + /** @brief Adjusts a submatrix size and position within the parent matrix. + + The method is complimentary to Mat::locateROI . The typical use of these functions is to determine + the submatrix position within the parent matrix and then shift the position somehow. Typically, it + can be required for filtering operations when pixels outside of the ROI should be taken into + account. When all the method parameters are positive, the ROI needs to grow in all directions by the + specified amount, for example: + @code + A.adjustROI(2, 2, 2, 2); + @endcode + In this example, the matrix size is increased by 4 elements in each direction. The matrix is shifted + by 2 elements to the left and 2 elements up, which brings in all the necessary pixels for the + filtering with the 5x5 kernel. + + adjustROI forces the adjusted ROI to be inside of the parent matrix that is boundaries of the + adjusted ROI are constrained by boundaries of the parent matrix. For example, if the submatrix A is + located in the first row of a parent matrix and you called A.adjustROI(2, 2, 2, 2) then A will not + be increased in the upward direction. + + The function is used internally by the OpenCV filtering functions, like filter2D , morphological + operations, and so on. + @param dtop Shift of the top submatrix boundary upwards. + @param dbottom Shift of the bottom submatrix boundary downwards. + @param dleft Shift of the left submatrix boundary to the left. + @param dright Shift of the right submatrix boundary to the right. + @sa copyMakeBorder + */ + Mat& adjustROI( int dtop, int dbottom, int dleft, int dright ); + + /** @brief Extracts a rectangular submatrix. + + The operators make a new header for the specified sub-array of \*this . They are the most + generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, + `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, + the operators are O(1) operations, that is, no matrix data is copied. + @param rowRange Start and end row of the extracted submatrix. The upper boundary is not included. To + select all the rows, use Range::all(). + @param colRange Start and end column of the extracted submatrix. The upper boundary is not included. + To select all the columns, use Range::all(). + */ + Mat operator()( Range rowRange, Range colRange ) const; + + /** @overload + @param roi Extracted submatrix specified as a rectangle. + */ + Mat operator()( const Rect& roi ) const; + + /** @overload + @param ranges Array of selected ranges along each array dimension. + */ + Mat operator()( const Range* ranges ) const; + + /** @overload + @param ranges Array of selected ranges along each array dimension. + */ + Mat operator()(const std::vector& ranges) const; + + template operator std::vector<_Tp>() const; + template operator Vec<_Tp, n>() const; + template operator Matx<_Tp, m, n>() const; + + template operator std::array<_Tp, _Nm>() const; + + /** @brief Reports whether the matrix is continuous or not. + + The method returns true if the matrix elements are stored continuously without gaps at the end of + each row. Otherwise, it returns false. Obviously, 1x1 or 1xN matrices are always continuous. + Matrices created with Mat::create are always continuous. But if you extract a part of the matrix + using Mat::col, Mat::diag, and so on, or constructed a matrix header for externally allocated data, + such matrices may no longer have this property. + + The continuity flag is stored as a bit in the Mat::flags field and is computed automatically when + you construct a matrix header. Thus, the continuity check is a very fast operation, though + theoretically it could be done as follows: + @code + // alternative implementation of Mat::isContinuous() + bool myCheckMatContinuity(const Mat& m) + { + //return (m.flags & Mat::CONTINUOUS_FLAG) != 0; + return m.rows == 1 || m.step == m.cols*m.elemSize(); + } + @endcode + The method is used in quite a few of OpenCV functions. The point is that element-wise operations + (such as arithmetic and logical operations, math functions, alpha blending, color space + transformations, and others) do not depend on the image geometry. Thus, if all the input and output + arrays are continuous, the functions can process them as very long single-row vectors. The example + below illustrates how an alpha-blending function can be implemented: + @code + template + void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) + { + const float alpha_scale = (float)std::numeric_limits::max(), + inv_scale = 1.f/alpha_scale; + + CV_Assert( src1.type() == src2.type() && + src1.type() == CV_MAKETYPE(traits::Depth::value, 4) && + src1.size() == src2.size()); + Size size = src1.size(); + dst.create(size, src1.type()); + + // here is the idiom: check the arrays for continuity and, + // if this is the case, + // treat the arrays as 1D vectors + if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() ) + { + size.width *= size.height; + size.height = 1; + } + size.width *= 4; + + for( int i = 0; i < size.height; i++ ) + { + // when the arrays are continuous, + // the outer loop is executed only once + const T* ptr1 = src1.ptr(i); + const T* ptr2 = src2.ptr(i); + T* dptr = dst.ptr(i); + + for( int j = 0; j < size.width; j += 4 ) + { + float alpha = ptr1[j+3]*inv_scale, beta = ptr2[j+3]*inv_scale; + dptr[j] = saturate_cast(ptr1[j]*alpha + ptr2[j]*beta); + dptr[j+1] = saturate_cast(ptr1[j+1]*alpha + ptr2[j+1]*beta); + dptr[j+2] = saturate_cast(ptr1[j+2]*alpha + ptr2[j+2]*beta); + dptr[j+3] = saturate_cast((1 - (1-alpha)*(1-beta))*alpha_scale); + } + } + } + @endcode + This approach, while being very simple, can boost the performance of a simple element-operation by + 10-20 percents, especially if the image is rather small and the operation is quite simple. + + Another OpenCV idiom in this function, a call of Mat::create for the destination array, that + allocates the destination array unless it already has the proper size and type. And while the newly + allocated arrays are always continuous, you still need to check the destination array because + Mat::create does not always allocate a new matrix. + */ + bool isContinuous() const; + + //! returns true if the matrix is a submatrix of another matrix + bool isSubmatrix() const; + + /** @brief Returns the matrix element size in bytes. + + The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , + the method returns 3\*sizeof(short) or 6. + */ + size_t elemSize() const; + + /** @brief Returns the size of each matrix element channel in bytes. + + The method returns the matrix element channel size in bytes, that is, it ignores the number of + channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2. + */ + size_t elemSize1() const; + + /** @brief Returns the type of a matrix element. + + The method returns a matrix element type. This is an identifier compatible with the CvMat type + system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. + */ + int type() const; + + /** @brief Returns the depth of a matrix element. + + The method returns the identifier of the matrix element depth (the type of each individual channel). + For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of + matrix types contains the following values: + - CV_8U - 8-bit unsigned integers ( 0..255 ) + - CV_8S - 8-bit signed integers ( -128..127 ) + - CV_16U - 16-bit unsigned integers ( 0..65535 ) + - CV_16S - 16-bit signed integers ( -32768..32767 ) + - CV_32S - 32-bit signed integers ( -2147483648..2147483647 ) + - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) + - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) + */ + int depth() const; + + /** @brief Returns the number of matrix channels. + + The method returns the number of matrix channels. + */ + int channels() const; + + /** @brief Returns a normalized step. + + The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an + arbitrary matrix element. + */ + size_t step1(int i=0) const; + + /** @brief Returns true if the array has no elements. + + The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and + resize() methods `M.total() == 0` does not imply that `M.data == NULL`. + */ + bool empty() const; + + /** @brief Returns the total number of array elements. + + The method returns the number of array elements (a number of pixels if the array represents an + image). + */ + size_t total() const; + + /** @brief Returns the total number of array elements. + + The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim + */ + size_t total(int startDim, int endDim=INT_MAX) const; + + /** + * @param elemChannels Number of channels or number of columns the matrix should have. + * For a 2-D matrix, when the matrix has only 1 column, then it should have + * elemChannels channels; When the matrix has only 1 channel, + * then it should have elemChannels columns. + * For a 3-D matrix, it should have only one channel. Furthermore, + * if the number of planes is not one, then the number of rows + * within every plane has to be 1; if the number of rows within + * every plane is not 1, then the number of planes has to be 1. + * @param depth The depth the matrix should have. Set it to -1 when any depth is fine. + * @param requireContinuous Set it to true to require the matrix to be continuous + * @return -1 if the requirement is not satisfied. + * Otherwise, it returns the number of elements in the matrix. Note + * that an element may have multiple channels. + * + * The following code demonstrates its usage for a 2-d matrix: + * @snippet snippets/core_mat_checkVector.cpp example-2d + * + * The following code demonstrates its usage for a 3-d matrix: + * @snippet snippets/core_mat_checkVector.cpp example-3d + */ + int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + + /** @brief Returns a pointer to the specified matrix row. + + The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + Mat::isContinuous to know how to use these methods. + @param i0 A 0-based row index. + */ + uchar* ptr(int i0=0); + /** @overload */ + const uchar* ptr(int i0=0) const; + + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + uchar* ptr(int row, int col); + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + const uchar* ptr(int row, int col) const; + + /** @overload */ + uchar* ptr(int i0, int i1, int i2); + /** @overload */ + const uchar* ptr(int i0, int i1, int i2) const; + + /** @overload */ + uchar* ptr(const int* idx); + /** @overload */ + const uchar* ptr(const int* idx) const; + /** @overload */ + template uchar* ptr(const Vec& idx); + /** @overload */ + template const uchar* ptr(const Vec& idx) const; + + /** @overload */ + template _Tp* ptr(int i0=0); + /** @overload */ + template const _Tp* ptr(int i0=0) const; + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template _Tp* ptr(int row, int col); + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template const _Tp* ptr(int row, int col) const; + /** @overload */ + template _Tp* ptr(int i0, int i1, int i2); + /** @overload */ + template const _Tp* ptr(int i0, int i1, int i2) const; + /** @overload */ + template _Tp* ptr(const int* idx); + /** @overload */ + template const _Tp* ptr(const int* idx) const; + /** @overload */ + template _Tp* ptr(const Vec& idx); + /** @overload */ + template const _Tp* ptr(const Vec& idx) const; + + /** @brief Returns a reference to the specified array element. + + The template methods return a reference to the specified array element. For the sake of higher + performance, the index range checks are only performed in the Debug configuration. + + Note that the variants with a single index (i) can be used to access elements of single-row or + single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + + The example below initializes a Hilbert matrix: + @code + Mat H(100, 100, CV_64F); + for(int i = 0; i < H.rows; i++) + for(int j = 0; j < H.cols; j++) + H.at(i,j)=1./(i+j+1); + @endcode + + Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + + @param i0 Index along the dimension 0 + */ + template _Tp& at(int i0=0); + /** @overload + @param i0 Index along the dimension 0 + */ + template const _Tp& at(int i0=0) const; + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template _Tp& at(int row, int col); + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template const _Tp& at(int row, int col) const; + + /** @overload + @param i0 Index along the dimension 0 + @param i1 Index along the dimension 1 + @param i2 Index along the dimension 2 + */ + template _Tp& at(int i0, int i1, int i2); + /** @overload + @param i0 Index along the dimension 0 + @param i1 Index along the dimension 1 + @param i2 Index along the dimension 2 + */ + template const _Tp& at(int i0, int i1, int i2) const; + + /** @overload + @param idx Array of Mat::dims indices. + */ + template _Tp& at(const int* idx); + /** @overload + @param idx Array of Mat::dims indices. + */ + template const _Tp& at(const int* idx) const; + + /** @overload */ + template _Tp& at(const Vec& idx); + /** @overload */ + template const _Tp& at(const Vec& idx) const; + + /** @overload + special versions for 2D arrays (especially convenient for referencing image pixels) + @param pt Element position specified as Point(j,i) . + */ + template _Tp& at(Point pt); + /** @overload + special versions for 2D arrays (especially convenient for referencing image pixels) + @param pt Element position specified as Point(j,i) . + */ + template const _Tp& at(Point pt) const; + + /** @brief Returns the matrix iterator and sets it to the first matrix element. + + The methods return the matrix read-only or read-write iterators. The use of matrix iterators is very + similar to the use of bi-directional STL iterators. In the example below, the alpha blending + function is rewritten using the matrix iterators: + @code + template + void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) + { + typedef Vec VT; + + const float alpha_scale = (float)std::numeric_limits::max(), + inv_scale = 1.f/alpha_scale; + + CV_Assert( src1.type() == src2.type() && + src1.type() == traits::Type::value && + src1.size() == src2.size()); + Size size = src1.size(); + dst.create(size, src1.type()); + + MatConstIterator_ it1 = src1.begin(), it1_end = src1.end(); + MatConstIterator_ it2 = src2.begin(); + MatIterator_ dst_it = dst.begin(); + + for( ; it1 != it1_end; ++it1, ++it2, ++dst_it ) + { + VT pix1 = *it1, pix2 = *it2; + float alpha = pix1[3]*inv_scale, beta = pix2[3]*inv_scale; + *dst_it = VT(saturate_cast(pix1[0]*alpha + pix2[0]*beta), + saturate_cast(pix1[1]*alpha + pix2[1]*beta), + saturate_cast(pix1[2]*alpha + pix2[2]*beta), + saturate_cast((1 - (1-alpha)*(1-beta))*alpha_scale)); + } + } + @endcode + */ + template MatIterator_<_Tp> begin(); + template MatConstIterator_<_Tp> begin() const; + + /** @brief Same as begin() but for inverse traversal + */ + template std::reverse_iterator> rbegin(); + template std::reverse_iterator> rbegin() const; + + /** @brief Returns the matrix iterator and sets it to the after-last matrix element. + + The methods return the matrix read-only or read-write iterators, set to the point following the last + matrix element. + */ + template MatIterator_<_Tp> end(); + template MatConstIterator_<_Tp> end() const; + + /** @brief Same as end() but for inverse traversal + */ + template std::reverse_iterator< MatIterator_<_Tp>> rend(); + template std::reverse_iterator< MatConstIterator_<_Tp>> rend() const; + + + /** @brief Runs the given functor over all matrix elements in parallel. + + The operation passed as argument has to be a function pointer, a function object or a lambda(C++11). + + Example 1. All of the operations below put 0xFF the first channel of all matrix elements: + @code + Mat image(1920, 1080, CV_8UC3); + typedef cv::Point3_ Pixel; + + // first. raw pointer access. + for (int r = 0; r < image.rows; ++r) { + Pixel* ptr = image.ptr(r, 0); + const Pixel* ptr_end = ptr + image.cols; + for (; ptr != ptr_end; ++ptr) { + ptr->x = 255; + } + } + + // Using MatIterator. (Simple but there are a Iterator's overhead) + for (Pixel &p : cv::Mat_(image)) { + p.x = 255; + } + + // Parallel execution with function object. + struct Operator { + void operator ()(Pixel &pixel, const int * position) { + pixel.x = 255; + } + }; + image.forEach(Operator()); + + // Parallel execution using C++11 lambda. + image.forEach([](Pixel &p, const int * position) -> void { + p.x = 255; + }); + @endcode + Example 2. Using the pixel's position: + @code + // Creating 3D matrix (255 x 255 x 255) typed uint8_t + // and initialize all elements by the value which equals elements position. + // i.e. pixels (x,y,z) = (1,2,3) is (b,g,r) = (1,2,3). + + int sizes[] = { 255, 255, 255 }; + typedef cv::Point3_ Pixel; + + Mat_ image = Mat::zeros(3, sizes, CV_8UC3); + + image.forEach([&](Pixel& pixel, const int position[]) -> void { + pixel.x = position[0]; + pixel.y = position[1]; + pixel.z = position[2]; + }); + @endcode + */ + template void forEach(const Functor& operation); + /** @overload */ + template void forEach(const Functor& operation) const; + + Mat(Mat&& m); + Mat& operator = (Mat&& m); + + enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; + enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + //! the matrix dimensionality, >= 2 + int dims; + //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + int rows, cols; + //! pointer to the data + uchar* data; + + //! helper fields used in locateROI and adjustROI + const uchar* datastart; + const uchar* dataend; + const uchar* datalimit; + + //! custom allocator + MatAllocator* allocator; + //! and the standard allocator + static MatAllocator* getStdAllocator(); + static MatAllocator* getDefaultAllocator(); + static void setDefaultAllocator(MatAllocator* allocator); + + //! internal use method: updates the continuity flag + void updateContinuityFlag(); + + //! interaction with UMat + UMatData* u; + + MatSize size; + MatStep step; + +protected: + template void forEach_impl(const Functor& operation); +}; + + +///////////////////////////////// Mat_<_Tp> //////////////////////////////////// + +/** @brief Template matrix class derived from Mat + +@code{.cpp} + template class Mat_ : public Mat + { + public: + // ... some specific methods + // and + // no new extra fields + }; +@endcode +The class `Mat_<_Tp>` is a *thin* template wrapper on top of the Mat class. It does not have any +extra data fields. Nor this class nor Mat has any virtual methods. Thus, references or pointers to +these two classes can be freely but carefully converted one to another. For example: +@code{.cpp} + // create a 100x100 8-bit matrix + Mat M(100,100,CV_8U); + // this will be compiled fine. no any data conversion will be done. + Mat_& M1 = (Mat_&)M; + // the program is likely to crash at the statement below + M1(99,99) = 1.f; +@endcode +While Mat is sufficient in most cases, Mat_ can be more convenient if you use a lot of element +access operations and if you know matrix type at the compilation time. Note that +`Mat::at(int y,int x)` and `Mat_::operator()(int y,int x)` do absolutely the same +and run at the same speed, but the latter is certainly shorter: +@code{.cpp} + Mat_ M(20,20); + for(int i = 0; i < M.rows; i++) + for(int j = 0; j < M.cols; j++) + M(i,j) = 1./(i+j+1); + Mat E, V; + eigen(M,E,V); + cout << E.at(0,0)/E.at(M.rows-1,0); +@endcode +To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter: +@code{.cpp} + // allocate a 320x240 color image and fill it with green (in RGB space) + Mat_ img(240, 320, Vec3b(0,255,0)); + // now draw a diagonal white line + for(int i = 0; i < 100; i++) + img(i,i)=Vec3b(255,255,255); + // and now scramble the 2nd (red) channel of each pixel + for(int i = 0; i < img.rows; i++) + for(int j = 0; j < img.cols; j++) + img(i,j)[2] ^= (uchar)(i ^ j); +@endcode +Mat_ is fully compatible with C++11 range-based for loop. For example such loop +can be used to safely apply look-up table: +@code{.cpp} +void applyTable(Mat_& I, const uchar* const table) +{ + for(auto& pixel : I) + { + pixel = table[pixel]; + } +} +@endcode + */ +template class Mat_ : public Mat +{ +public: + typedef _Tp value_type; + typedef typename DataType<_Tp>::channel_type channel_type; + typedef MatIterator_<_Tp> iterator; + typedef MatConstIterator_<_Tp> const_iterator; + + //! default constructor + Mat_() CV_NOEXCEPT; + //! equivalent to Mat(_rows, _cols, DataType<_Tp>::type) + Mat_(int _rows, int _cols); + //! constructor that sets each matrix element to specified value + Mat_(int _rows, int _cols, const _Tp& value); + //! equivalent to Mat(_size, DataType<_Tp>::type) + explicit Mat_(Size _size); + //! constructor that sets each matrix element to specified value + Mat_(Size _size, const _Tp& value); + //! n-dim array constructor + Mat_(int _ndims, const int* _sizes); + //! n-dim array constructor that sets each matrix element to specified value + Mat_(int _ndims, const int* _sizes, const _Tp& value); + //! copy/conversion constructor. If m is of different type, it's converted + Mat_(const Mat& m); + //! copy constructor + Mat_(const Mat_& m); + //! constructs a matrix on top of user-allocated data. step is in bytes(!!!), regardless of the type + Mat_(int _rows, int _cols, _Tp* _data, size_t _step=AUTO_STEP); + //! constructs n-dim matrix on top of user-allocated data. steps are in bytes(!!!), regardless of the type + Mat_(int _ndims, const int* _sizes, _Tp* _data, const size_t* _steps=0); + //! selects a submatrix + Mat_(const Mat_& m, const Range& rowRange, const Range& colRange=Range::all()); + //! selects a submatrix + Mat_(const Mat_& m, const Rect& roi); + //! selects a submatrix, n-dim version + Mat_(const Mat_& m, const Range* ranges); + //! selects a submatrix, n-dim version + Mat_(const Mat_& m, const std::vector& ranges); + //! from a matrix expression + explicit Mat_(const MatExpr& e); + //! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column + explicit Mat_(const std::vector<_Tp>& vec, bool copyData=false); + template explicit Mat_(const Vec::channel_type, n>& vec, bool copyData=true); + template explicit Mat_(const Matx::channel_type, m, n>& mtx, bool copyData=true); + explicit Mat_(const Point_::channel_type>& pt, bool copyData=true); + explicit Mat_(const Point3_::channel_type>& pt, bool copyData=true); + explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); + + Mat_(std::initializer_list<_Tp> values); + explicit Mat_(const std::initializer_list sizes, const std::initializer_list<_Tp> values); + + template explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false); + + Mat_& operator = (const Mat& m); + Mat_& operator = (const Mat_& m); + //! set all the elements to s. + Mat_& operator = (const _Tp& s); + //! assign a matrix expression + Mat_& operator = (const MatExpr& e); + + //! iterators; they are smart enough to skip gaps in the end of rows + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + //reverse iterators + std::reverse_iterator rbegin(); + std::reverse_iterator rend(); + std::reverse_iterator rbegin() const; + std::reverse_iterator rend() const; + + //! template methods for for operation over all matrix elements. + // the operations take care of skipping gaps in the end of rows (if any) + template void forEach(const Functor& operation); + template void forEach(const Functor& operation) const; + + //! equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type) + void create(int _rows, int _cols); + //! equivalent to Mat::create(_size, DataType<_Tp>::type) + void create(Size _size); + //! equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type) + void create(int _ndims, const int* _sizes); + //! equivalent to Mat::release() + void release(); + //! cross-product + Mat_ cross(const Mat_& m) const; + //! data type conversion + template operator Mat_() const; + //! overridden forms of Mat::row() etc. + Mat_ row(int y) const; + Mat_ col(int x) const; + Mat_ diag(int d=0) const; + CV_NODISCARD_STD Mat_ clone() const; + + //! overridden forms of Mat::elemSize() etc. + size_t elemSize() const; + size_t elemSize1() const; + int type() const; + int depth() const; + int channels() const; + size_t step1(int i=0) const; + //! returns step()/sizeof(_Tp) + size_t stepT(int i=0) const; + + //! overridden forms of Mat::zeros() etc. Data type is omitted, of course + CV_NODISCARD_STD static MatExpr zeros(int rows, int cols); + CV_NODISCARD_STD static MatExpr zeros(Size size); + CV_NODISCARD_STD static MatExpr zeros(int _ndims, const int* _sizes); + CV_NODISCARD_STD static MatExpr ones(int rows, int cols); + CV_NODISCARD_STD static MatExpr ones(Size size); + CV_NODISCARD_STD static MatExpr ones(int _ndims, const int* _sizes); + CV_NODISCARD_STD static MatExpr eye(int rows, int cols); + CV_NODISCARD_STD static MatExpr eye(Size size); + + //! some more overridden methods + Mat_& adjustROI( int dtop, int dbottom, int dleft, int dright ); + Mat_ operator()( const Range& rowRange, const Range& colRange ) const; + Mat_ operator()( const Rect& roi ) const; + Mat_ operator()( const Range* ranges ) const; + Mat_ operator()(const std::vector& ranges) const; + + //! more convenient forms of row and element access operators + _Tp* operator [](int y); + const _Tp* operator [](int y) const; + + //! returns reference to the specified element + _Tp& operator ()(const int* idx); + //! returns read-only reference to the specified element + const _Tp& operator ()(const int* idx) const; + + //! returns reference to the specified element + template _Tp& operator ()(const Vec& idx); + //! returns read-only reference to the specified element + template const _Tp& operator ()(const Vec& idx) const; + + //! returns reference to the specified element (1D case) + _Tp& operator ()(int idx0); + //! returns read-only reference to the specified element (1D case) + const _Tp& operator ()(int idx0) const; + //! returns reference to the specified element (2D case) + _Tp& operator ()(int row, int col); + //! returns read-only reference to the specified element (2D case) + const _Tp& operator ()(int row, int col) const; + //! returns reference to the specified element (3D case) + _Tp& operator ()(int idx0, int idx1, int idx2); + //! returns read-only reference to the specified element (3D case) + const _Tp& operator ()(int idx0, int idx1, int idx2) const; + + _Tp& operator ()(Point pt); + const _Tp& operator ()(Point pt) const; + + //! conversion to vector. + operator std::vector<_Tp>() const; + + //! conversion to array. + template operator std::array<_Tp, _Nm>() const; + + //! conversion to Vec + template operator Vec::channel_type, n>() const; + //! conversion to Matx + template operator Matx::channel_type, m, n>() const; + + Mat_(Mat_&& m); + Mat_& operator = (Mat_&& m); + + Mat_(Mat&& m); + Mat_& operator = (Mat&& m); + + Mat_(MatExpr&& e); +}; + +typedef Mat_ Mat1b; +typedef Mat_ Mat2b; +typedef Mat_ Mat3b; +typedef Mat_ Mat4b; + +typedef Mat_ Mat1s; +typedef Mat_ Mat2s; +typedef Mat_ Mat3s; +typedef Mat_ Mat4s; + +typedef Mat_ Mat1w; +typedef Mat_ Mat2w; +typedef Mat_ Mat3w; +typedef Mat_ Mat4w; + +typedef Mat_ Mat1i; +typedef Mat_ Mat2i; +typedef Mat_ Mat3i; +typedef Mat_ Mat4i; + +typedef Mat_ Mat1f; +typedef Mat_ Mat2f; +typedef Mat_ Mat3f; +typedef Mat_ Mat4f; + +typedef Mat_ Mat1d; +typedef Mat_ Mat2d; +typedef Mat_ Mat3d; +typedef Mat_ Mat4d; + +/** @todo document */ +class CV_EXPORTS UMat +{ +public: + //! default constructor + UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT) CV_NOEXCEPT; + //! constructs 2D matrix of the specified size and type + // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) + UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + //! constructs 2D matrix and fills it with the specified value _s. + UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + + //! constructs n-dimensional matrix + UMat(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int ndims, const int* sizes, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + + //! copy constructor + UMat(const UMat& m); + + //! creates a matrix header for a part of the bigger matrix + UMat(const UMat& m, const Range& rowRange, const Range& colRange=Range::all()); + UMat(const UMat& m, const Rect& roi); + UMat(const UMat& m, const Range* ranges); + UMat(const UMat& m, const std::vector& ranges); + + // FIXIT copyData=false is not implemented, drop this in favor of cv::Mat (OpenCV 5.0) + //! builds matrix from std::vector with or without copying the data + template explicit UMat(const std::vector<_Tp>& vec, bool copyData=false); + + //! destructor - calls release() + ~UMat(); + //! assignment operators + UMat& operator = (const UMat& m); + + Mat getMat(AccessFlag flags) const; + + //! returns a new matrix header for the specified row + UMat row(int y) const; + //! returns a new matrix header for the specified column + UMat col(int x) const; + //! ... for the specified row span + UMat rowRange(int startrow, int endrow) const; + UMat rowRange(const Range& r) const; + //! ... for the specified column span + UMat colRange(int startcol, int endcol) const; + UMat colRange(const Range& r) const; + //! ... for the specified diagonal + //! (d=0 - the main diagonal, + //! >0 - a diagonal from the upper half, + //! <0 - a diagonal from the lower half) + UMat diag(int d=0) const; + //! constructs a square diagonal matrix which main diagonal is vector "d" + CV_NODISCARD_STD static UMat diag(const UMat& d, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat diag(const UMat& d) { return diag(d, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + + //! returns deep copy of the matrix, i.e. the data is copied + CV_NODISCARD_STD UMat clone() const; + //! copies the matrix content to "m". + // It calls m.create(this->size(), this->type()). + void copyTo( OutputArray m ) const; + //! copies those matrix elements to "m" that are marked with non-zero mask elements. + void copyTo( OutputArray m, InputArray mask ) const; + //! converts matrix to another datatype with optional scaling. See cvConvertScale. + void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + + void assignTo( UMat& m, int type=-1 ) const; + + //! sets every matrix element to s + UMat& operator = (const Scalar& s); + //! sets some of the matrix elements to s, according to the mask + UMat& setTo(InputArray value, InputArray mask=noArray()); + //! creates alternative matrix header for the same data, with different + // number of channels and/or different number of rows. see cvReshape. + UMat reshape(int cn, int rows=0) const; + UMat reshape(int cn, int newndims, const int* newsz) const; + + //! matrix transposition by means of matrix expressions + UMat t() const; + //! matrix inversion by means of matrix expressions + UMat inv(int method=DECOMP_LU) const; + //! per-element matrix multiplication by means of matrix expressions + UMat mul(InputArray m, double scale=1) const; + + //! computes dot-product + double dot(InputArray m) const; + + //! Matlab-style matrix initialization + CV_NODISCARD_STD static UMat zeros(int rows, int cols, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat zeros(Size size, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat zeros(int ndims, const int* sz, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat zeros(int rows, int cols, int type) { return zeros(rows, cols, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat zeros(Size size, int type) { return zeros(size, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat zeros(int ndims, const int* sz, int type) { return zeros(ndims, sz, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat ones(int rows, int cols, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat ones(Size size, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat ones(int ndims, const int* sz, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat ones(int rows, int cols, int type) { return ones(rows, cols, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat ones(Size size, int type) { return ones(size, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat ones(int ndims, const int* sz, int type) { return ones(ndims, sz, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat eye(int rows, int cols, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat eye(Size size, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat eye(int rows, int cols, int type) { return eye(rows, cols, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat eye(Size size, int type) { return eye(size, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + + //! allocates new matrix data unless the matrix already has specified size and type. + // previous data is unreferenced if needed. + void create(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(const std::vector& sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + + //! increases the reference counter; use with care to avoid memleaks + void addref(); + //! decreases reference counter; + // deallocates the data when reference counter reaches 0. + void release(); + + //! deallocates the matrix data + void deallocate(); + //! internal use function; properly re-allocates _size, _step arrays + void copySize(const UMat& m); + + //! locates matrix header within a parent matrix. See below + void locateROI( Size& wholeSize, Point& ofs ) const; + //! moves/resizes the current matrix ROI inside the parent matrix. + UMat& adjustROI( int dtop, int dbottom, int dleft, int dright ); + //! extracts a rectangular sub-matrix + // (this is a generalized form of row, rowRange etc.) + UMat operator()( Range rowRange, Range colRange ) const; + UMat operator()( const Rect& roi ) const; + UMat operator()( const Range* ranges ) const; + UMat operator()(const std::vector& ranges) const; + + //! returns true iff the matrix data is continuous + // (i.e. when there are no gaps between successive rows). + // similar to CV_IS_MAT_CONT(cvmat->type) + bool isContinuous() const; + + //! returns true if the matrix is a submatrix of another matrix + bool isSubmatrix() const; + + //! returns element size in bytes, + // similar to CV_ELEM_SIZE(cvmat->type) + size_t elemSize() const; + //! returns the size of element channel in bytes. + size_t elemSize1() const; + //! returns element type, similar to CV_MAT_TYPE(cvmat->type) + int type() const; + //! returns element type, similar to CV_MAT_DEPTH(cvmat->type) + int depth() const; + //! returns element type, similar to CV_MAT_CN(cvmat->type) + int channels() const; + //! returns step/elemSize1() + size_t step1(int i=0) const; + //! returns true if matrix data is NULL + bool empty() const; + //! returns the total number of matrix elements + size_t total() const; + + //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise + int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + + UMat(UMat&& m); + UMat& operator = (UMat&& m); + + /*! Returns the OpenCL buffer handle on which UMat operates on. + The UMat instance should be kept alive during the use of the handle to prevent the buffer to be + returned to the OpenCV buffer pool. + */ + void* handle(AccessFlag accessFlags) const; + void ndoffset(size_t* ofs) const; + + enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; + enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + + //! the matrix dimensionality, >= 2 + int dims; + + //! number of rows in the matrix; -1 when the matrix has more than 2 dimensions + int rows; + + //! number of columns in the matrix; -1 when the matrix has more than 2 dimensions + int cols; + + //! custom allocator + MatAllocator* allocator; + + //! usage flags for allocator; recommend do not set directly, instead set during construct/create/getUMat + UMatUsageFlags usageFlags; + + //! and the standard allocator + static MatAllocator* getStdAllocator(); + + //! internal use method: updates the continuity flag + void updateContinuityFlag(); + + //! black-box container of UMat data + UMatData* u; + + //! offset of the submatrix (or 0) + size_t offset; + + //! dimensional size of the matrix; accessible in various formats + MatSize size; + + //! number of bytes each matrix element/row/plane/dimension occupies + MatStep step; + +protected: +}; + + +/////////////////////////// multi-dimensional sparse matrix ////////////////////////// + +/** @brief The class SparseMat represents multi-dimensional sparse numerical arrays. + +Such a sparse array can store elements of any type that Mat can store. *Sparse* means that only +non-zero elements are stored (though, as a result of operations on a sparse matrix, some of its +stored elements can actually become 0. It is up to you to detect such elements and delete them +using SparseMat::erase ). The non-zero elements are stored in a hash table that grows when it is +filled so that the search time is O(1) in average (regardless of whether element is there or not). +Elements can be accessed using the following methods: +- Query operations (SparseMat::ptr and the higher-level SparseMat::ref, SparseMat::value and + SparseMat::find), for example: + @code + const int dims = 5; + int size[5] = {10, 10, 10, 10, 10}; + SparseMat sparse_mat(dims, size, CV_32F); + for(int i = 0; i < 1000; i++) + { + int idx[dims]; + for(int k = 0; k < dims; k++) + idx[k] = rand() % size[k]; + sparse_mat.ref(idx) += 1.f; + } + cout << "nnz = " << sparse_mat.nzcount() << endl; + @endcode +- Sparse matrix iterators. They are similar to MatIterator but different from NAryMatIterator. + That is, the iteration loop is familiar to STL users: + @code + // prints elements of a sparse floating-point matrix + // and the sum of elements. + SparseMatConstIterator_ + it = sparse_mat.begin(), + it_end = sparse_mat.end(); + double s = 0; + int dims = sparse_mat.dims(); + for(; it != it_end; ++it) + { + // print element indices and the element value + const SparseMat::Node* n = it.node(); + printf("("); + for(int i = 0; i < dims; i++) + printf("%d%s", n->idx[i], i < dims-1 ? ", " : ")"); + printf(": %g\n", it.value()); + s += *it; + } + printf("Element sum is %g\n", s); + @endcode + If you run this loop, you will notice that elements are not enumerated in a logical order + (lexicographical, and so on). They come in the same order as they are stored in the hash table + (semi-randomly). You may collect pointers to the nodes and sort them to get the proper ordering. + Note, however, that pointers to the nodes may become invalid when you add more elements to the + matrix. This may happen due to possible buffer reallocation. +- Combination of the above 2 methods when you need to process 2 or more sparse matrices + simultaneously. For example, this is how you can compute unnormalized cross-correlation of the 2 + floating-point sparse matrices: + @code + double cross_corr(const SparseMat& a, const SparseMat& b) + { + const SparseMat *_a = &a, *_b = &b; + // if b contains less elements than a, + // it is faster to iterate through b + if(_a->nzcount() > _b->nzcount()) + std::swap(_a, _b); + SparseMatConstIterator_ it = _a->begin(), + it_end = _a->end(); + double ccorr = 0; + for(; it != it_end; ++it) + { + // take the next element from the first matrix + float avalue = *it; + const Node* anode = it.node(); + // and try to find an element with the same index in the second matrix. + // since the hash value depends only on the element index, + // reuse the hash value stored in the node + float bvalue = _b->value(anode->idx,&anode->hashval); + ccorr += avalue*bvalue; + } + return ccorr; + } + @endcode + */ +class CV_EXPORTS SparseMat +{ +public: + typedef SparseMatIterator iterator; + typedef SparseMatConstIterator const_iterator; + + enum { MAGIC_VAL=0x42FD0000, MAX_DIM=32, HASH_SCALE=0x5bd1e995, HASH_BIT=0x80000000 }; + + //! the sparse matrix header + struct CV_EXPORTS Hdr + { + Hdr(int _dims, const int* _sizes, int _type); + void clear(); + int refcount; + int dims; + int valueOffset; + size_t nodeSize; + size_t nodeCount; + size_t freeList; + std::vector pool; + std::vector hashtab; + int size[MAX_DIM]; + }; + + //! sparse matrix node - element of a hash table + struct CV_EXPORTS Node + { + //! hash value + size_t hashval; + //! index of the next node in the same hash table entry + size_t next; + //! index of the matrix element + int idx[MAX_DIM]; + }; + + /** @brief Various SparseMat constructors. + */ + SparseMat(); + + /** @overload + @param dims Array dimensionality. + @param _sizes Sparce matrix size on all dementions. + @param _type Sparse matrix data type. + */ + SparseMat(int dims, const int* _sizes, int _type); + + /** @overload + @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted + to sparse representation. + */ + SparseMat(const SparseMat& m); + + /** @overload + @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted + to sparse representation. + */ + explicit SparseMat(const Mat& m); + + //! the destructor + ~SparseMat(); + + //! assignment operator. This is O(1) operation, i.e. no data is copied + SparseMat& operator = (const SparseMat& m); + //! equivalent to the corresponding constructor + SparseMat& operator = (const Mat& m); + + //! creates full copy of the matrix + CV_NODISCARD_STD SparseMat clone() const; + + //! copies all the data to the destination matrix. All the previous content of m is erased + void copyTo( SparseMat& m ) const; + //! converts sparse matrix to dense matrix. + void copyTo( Mat& m ) const; + //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type + void convertTo( SparseMat& m, int rtype, double alpha=1 ) const; + //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. + /*! + @param [out] m - output matrix; if it does not have a proper size or type before the operation, + it is reallocated + @param [in] rtype - desired output matrix type or, rather, the depth since the number of channels + are the same as the input has; if rtype is negative, the output matrix will have the + same type as the input. + @param [in] alpha - optional scale factor + @param [in] beta - optional delta added to the scaled values + */ + void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const; + + // not used now + void assignTo( SparseMat& m, int type=-1 ) const; + + //! reallocates sparse matrix. + /*! + If the matrix already had the proper size and type, + it is simply cleared with clear(), otherwise, + the old matrix is released (using release()) and the new one is allocated. + */ + void create(int dims, const int* _sizes, int _type); + //! sets all the sparse matrix elements to 0, which means clearing the hash table. + void clear(); + //! manually increments the reference counter to the header. + void addref(); + // decrements the header reference counter. When the counter reaches 0, the header and all the underlying data are deallocated. + void release(); + + //! converts sparse matrix to the old-style representation; all the elements are copied. + //operator CvSparseMat*() const; + //! returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements) + size_t elemSize() const; + //! returns elemSize()/channels() + size_t elemSize1() const; + + //! returns type of sparse matrix elements + int type() const; + //! returns the depth of sparse matrix elements + int depth() const; + //! returns the number of channels + int channels() const; + + //! returns the array of sizes, or NULL if the matrix is not allocated + const int* size() const; + //! returns the size of i-th matrix dimension (or 0) + int size(int i) const; + //! returns the matrix dimensionality + int dims() const; + //! returns the number of non-zero elements (=the number of hash table nodes) + size_t nzcount() const; + + //! computes the element hash value (1D case) + size_t hash(int i0) const; + //! computes the element hash value (2D case) + size_t hash(int i0, int i1) const; + //! computes the element hash value (3D case) + size_t hash(int i0, int i1, int i2) const; + //! computes the element hash value (nD case) + size_t hash(const int* idx) const; + + //!@{ + /*! + specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case. + return pointer to the matrix element. + - if the element is there (it's non-zero), the pointer to it is returned + - if it's not there and createMissing=false, NULL pointer is returned + - if it's not there and createMissing=true, then the new element + is created and initialized with 0. Pointer to it is returned + - if the optional hashval pointer is not NULL, the element hash value is + not computed, but *hashval is taken instead. + */ + //! returns pointer to the specified element (1D case) + uchar* ptr(int i0, bool createMissing, size_t* hashval=0); + //! returns pointer to the specified element (2D case) + uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0); + //! returns pointer to the specified element (3D case) + uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0); + //! returns pointer to the specified element (nD case) + uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0); + //!@} + + //!@{ + /*! + return read-write reference to the specified sparse matrix element. + + `ref<_Tp>(i0,...[,hashval])` is equivalent to `*(_Tp*)ptr(i0,...,true[,hashval])`. + The methods always return a valid reference. + If the element did not exist, it is created and initialized with 0. + */ + //! returns reference to the specified element (1D case) + template _Tp& ref(int i0, size_t* hashval=0); + //! returns reference to the specified element (2D case) + template _Tp& ref(int i0, int i1, size_t* hashval=0); + //! returns reference to the specified element (3D case) + template _Tp& ref(int i0, int i1, int i2, size_t* hashval=0); + //! returns reference to the specified element (nD case) + template _Tp& ref(const int* idx, size_t* hashval=0); + //!@} + + //!@{ + /*! + return value of the specified sparse matrix element. + + `value<_Tp>(i0,...[,hashval])` is equivalent to + @code + { const _Tp* p = find<_Tp>(i0,...[,hashval]); return p ? *p : _Tp(); } + @endcode + + That is, if the element did not exist, the methods return 0. + */ + //! returns value of the specified element (1D case) + template _Tp value(int i0, size_t* hashval=0) const; + //! returns value of the specified element (2D case) + template _Tp value(int i0, int i1, size_t* hashval=0) const; + //! returns value of the specified element (3D case) + template _Tp value(int i0, int i1, int i2, size_t* hashval=0) const; + //! returns value of the specified element (nD case) + template _Tp value(const int* idx, size_t* hashval=0) const; + //!@} + + //!@{ + /*! + Return pointer to the specified sparse matrix element if it exists + + `find<_Tp>(i0,...[,hashval])` is equivalent to `(_const Tp*)ptr(i0,...false[,hashval])`. + + If the specified element does not exist, the methods return NULL. + */ + //! returns pointer to the specified element (1D case) + template const _Tp* find(int i0, size_t* hashval=0) const; + //! returns pointer to the specified element (2D case) + template const _Tp* find(int i0, int i1, size_t* hashval=0) const; + //! returns pointer to the specified element (3D case) + template const _Tp* find(int i0, int i1, int i2, size_t* hashval=0) const; + //! returns pointer to the specified element (nD case) + template const _Tp* find(const int* idx, size_t* hashval=0) const; + //!@} + + //! erases the specified element (2D case) + void erase(int i0, int i1, size_t* hashval=0); + //! erases the specified element (3D case) + void erase(int i0, int i1, int i2, size_t* hashval=0); + //! erases the specified element (nD case) + void erase(const int* idx, size_t* hashval=0); + + //!@{ + /*! + return the sparse matrix iterator pointing to the first sparse matrix element + */ + //! returns the sparse matrix iterator at the matrix beginning + SparseMatIterator begin(); + //! returns the sparse matrix iterator at the matrix beginning + template SparseMatIterator_<_Tp> begin(); + //! returns the read-only sparse matrix iterator at the matrix beginning + SparseMatConstIterator begin() const; + //! returns the read-only sparse matrix iterator at the matrix beginning + template SparseMatConstIterator_<_Tp> begin() const; + //!@} + /*! + return the sparse matrix iterator pointing to the element following the last sparse matrix element + */ + //! returns the sparse matrix iterator at the matrix end + SparseMatIterator end(); + //! returns the read-only sparse matrix iterator at the matrix end + SparseMatConstIterator end() const; + //! returns the typed sparse matrix iterator at the matrix end + template SparseMatIterator_<_Tp> end(); + //! returns the typed read-only sparse matrix iterator at the matrix end + template SparseMatConstIterator_<_Tp> end() const; + + //! returns the value stored in the sparse martix node + template _Tp& value(Node* n); + //! returns the value stored in the sparse martix node + template const _Tp& value(const Node* n) const; + + ////////////// some internal-use methods /////////////// + Node* node(size_t nidx); + const Node* node(size_t nidx) const; + + uchar* newNode(const int* idx, size_t hashval); + void removeNode(size_t hidx, size_t nidx, size_t previdx); + void resizeHashTab(size_t newsize); + + int flags; + Hdr* hdr; +}; + + + +///////////////////////////////// SparseMat_<_Tp> //////////////////////////////////// + +/** @brief Template sparse n-dimensional array class derived from SparseMat + +SparseMat_ is a thin wrapper on top of SparseMat created in the same way as Mat_ . It simplifies +notation of some operations: +@code + int sz[] = {10, 20, 30}; + SparseMat_ M(3, sz); + ... + M.ref(1, 2, 3) = M(4, 5, 6) + M(7, 8, 9); +@endcode + */ +template class SparseMat_ : public SparseMat +{ +public: + typedef SparseMatIterator_<_Tp> iterator; + typedef SparseMatConstIterator_<_Tp> const_iterator; + + //! the default constructor + SparseMat_(); + //! the full constructor equivalent to SparseMat(dims, _sizes, DataType<_Tp>::type) + SparseMat_(int dims, const int* _sizes); + //! the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted + SparseMat_(const SparseMat& m); + //! the copy constructor. This is O(1) operation - no data is copied + SparseMat_(const SparseMat_& m); + //! converts dense matrix to the sparse form + SparseMat_(const Mat& m); + //! converts the old-style sparse matrix to the C++ class. All the elements are copied + //SparseMat_(const CvSparseMat* m); + //! the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted + SparseMat_& operator = (const SparseMat& m); + //! the assignment operator. This is O(1) operation - no data is copied + SparseMat_& operator = (const SparseMat_& m); + //! converts dense matrix to the sparse form + SparseMat_& operator = (const Mat& m); + + //! makes full copy of the matrix. All the elements are duplicated + CV_NODISCARD_STD SparseMat_ clone() const; + //! equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type) + void create(int dims, const int* _sizes); + //! converts sparse matrix to the old-style CvSparseMat. All the elements are copied + //operator CvSparseMat*() const; + + //! returns type of the matrix elements + int type() const; + //! returns depth of the matrix elements + int depth() const; + //! returns the number of channels in each matrix element + int channels() const; + + //! equivalent to SparseMat::ref<_Tp>(i0, hashval) + _Tp& ref(int i0, size_t* hashval=0); + //! equivalent to SparseMat::ref<_Tp>(i0, i1, hashval) + _Tp& ref(int i0, int i1, size_t* hashval=0); + //! equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval) + _Tp& ref(int i0, int i1, int i2, size_t* hashval=0); + //! equivalent to SparseMat::ref<_Tp>(idx, hashval) + _Tp& ref(const int* idx, size_t* hashval=0); + + //! equivalent to SparseMat::value<_Tp>(i0, hashval) + _Tp operator()(int i0, size_t* hashval=0) const; + //! equivalent to SparseMat::value<_Tp>(i0, i1, hashval) + _Tp operator()(int i0, int i1, size_t* hashval=0) const; + //! equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval) + _Tp operator()(int i0, int i1, int i2, size_t* hashval=0) const; + //! equivalent to SparseMat::value<_Tp>(idx, hashval) + _Tp operator()(const int* idx, size_t* hashval=0) const; + + //! returns sparse matrix iterator pointing to the first sparse matrix element + SparseMatIterator_<_Tp> begin(); + //! returns read-only sparse matrix iterator pointing to the first sparse matrix element + SparseMatConstIterator_<_Tp> begin() const; + //! returns sparse matrix iterator pointing to the element following the last sparse matrix element + SparseMatIterator_<_Tp> end(); + //! returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element + SparseMatConstIterator_<_Tp> end() const; +}; + + + +////////////////////////////////// MatConstIterator ////////////////////////////////// + +class CV_EXPORTS MatConstIterator +{ +public: + typedef uchar* value_type; + typedef ptrdiff_t difference_type; + typedef const uchar** pointer; + typedef uchar* reference; + + typedef std::random_access_iterator_tag iterator_category; + + //! default constructor + MatConstIterator(); + //! constructor that sets the iterator to the beginning of the matrix + MatConstIterator(const Mat* _m); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator(const Mat* _m, int _row, int _col=0); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator(const Mat* _m, Point _pt); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator(const Mat* _m, const int* _idx); + //! copy constructor + MatConstIterator(const MatConstIterator& it); + + //! copy operator + MatConstIterator& operator = (const MatConstIterator& it); + //! returns the current matrix element + const uchar* operator *() const; + //! returns the i-th matrix element, relative to the current + const uchar* operator [](ptrdiff_t i) const; + + //! shifts the iterator forward by the specified number of elements + MatConstIterator& operator += (ptrdiff_t ofs); + //! shifts the iterator backward by the specified number of elements + MatConstIterator& operator -= (ptrdiff_t ofs); + //! decrements the iterator + MatConstIterator& operator --(); + //! decrements the iterator + MatConstIterator operator --(int); + //! increments the iterator + MatConstIterator& operator ++(); + //! increments the iterator + MatConstIterator operator ++(int); + //! returns the current iterator position + Point pos() const; + //! returns the current iterator position + void pos(int* _idx) const; + + ptrdiff_t lpos() const; + void seek(ptrdiff_t ofs, bool relative = false); + void seek(const int* _idx, bool relative = false); + + const Mat* m; + size_t elemSize; + const uchar* ptr; + const uchar* sliceStart; + const uchar* sliceEnd; +}; + + + +////////////////////////////////// MatConstIterator_ ///////////////////////////////// + +/** @brief Matrix read-only iterator + */ +template +class MatConstIterator_ : public MatConstIterator +{ +public: + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + + typedef std::random_access_iterator_tag iterator_category; + + //! default constructor + MatConstIterator_(); + //! constructor that sets the iterator to the beginning of the matrix + MatConstIterator_(const Mat_<_Tp>* _m); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col=0); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator_(const Mat_<_Tp>* _m, Point _pt); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator_(const Mat_<_Tp>* _m, const int* _idx); + //! copy constructor + MatConstIterator_(const MatConstIterator_& it); + + //! copy operator + MatConstIterator_& operator = (const MatConstIterator_& it); + //! returns the current matrix element + const _Tp& operator *() const; + //! returns the i-th matrix element, relative to the current + const _Tp& operator [](ptrdiff_t i) const; + + //! shifts the iterator forward by the specified number of elements + MatConstIterator_& operator += (ptrdiff_t ofs); + //! shifts the iterator backward by the specified number of elements + MatConstIterator_& operator -= (ptrdiff_t ofs); + //! decrements the iterator + MatConstIterator_& operator --(); + //! decrements the iterator + MatConstIterator_ operator --(int); + //! increments the iterator + MatConstIterator_& operator ++(); + //! increments the iterator + MatConstIterator_ operator ++(int); + //! returns the current iterator position + Point pos() const; +}; + + + +//////////////////////////////////// MatIterator_ //////////////////////////////////// + +/** @brief Matrix read-write iterator +*/ +template +class MatIterator_ : public MatConstIterator_<_Tp> +{ +public: + typedef _Tp* pointer; + typedef _Tp& reference; + + typedef std::random_access_iterator_tag iterator_category; + + //! the default constructor + MatIterator_(); + //! constructor that sets the iterator to the beginning of the matrix + MatIterator_(Mat_<_Tp>* _m); + //! constructor that sets the iterator to the specified element of the matrix + MatIterator_(Mat_<_Tp>* _m, int _row, int _col=0); + //! constructor that sets the iterator to the specified element of the matrix + MatIterator_(Mat_<_Tp>* _m, Point _pt); + //! constructor that sets the iterator to the specified element of the matrix + MatIterator_(Mat_<_Tp>* _m, const int* _idx); + //! copy constructor + MatIterator_(const MatIterator_& it); + //! copy operator + MatIterator_& operator = (const MatIterator_<_Tp>& it ); + + //! returns the current matrix element + _Tp& operator *() const; + //! returns the i-th matrix element, relative to the current + _Tp& operator [](ptrdiff_t i) const; + + //! shifts the iterator forward by the specified number of elements + MatIterator_& operator += (ptrdiff_t ofs); + //! shifts the iterator backward by the specified number of elements + MatIterator_& operator -= (ptrdiff_t ofs); + //! decrements the iterator + MatIterator_& operator --(); + //! decrements the iterator + MatIterator_ operator --(int); + //! increments the iterator + MatIterator_& operator ++(); + //! increments the iterator + MatIterator_ operator ++(int); +}; + + + +/////////////////////////////// SparseMatConstIterator /////////////////////////////// + +/** @brief Read-Only Sparse Matrix Iterator. + + Here is how to use the iterator to compute the sum of floating-point sparse matrix elements: + + \code + SparseMatConstIterator it = m.begin(), it_end = m.end(); + double s = 0; + CV_Assert( m.type() == CV_32F ); + for( ; it != it_end; ++it ) + s += it.value(); + \endcode +*/ +class CV_EXPORTS SparseMatConstIterator +{ +public: + //! the default constructor + SparseMatConstIterator(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatConstIterator(const SparseMat* _m); + //! the copy constructor + SparseMatConstIterator(const SparseMatConstIterator& it); + + //! the assignment operator + SparseMatConstIterator& operator = (const SparseMatConstIterator& it); + + //! template method returning the current matrix element + template const _Tp& value() const; + //! returns the current node of the sparse matrix. it.node->idx is the current element index + const SparseMat::Node* node() const; + + //! moves iterator to the previous element + SparseMatConstIterator& operator --(); + //! moves iterator to the previous element + SparseMatConstIterator operator --(int); + //! moves iterator to the next element + SparseMatConstIterator& operator ++(); + //! moves iterator to the next element + SparseMatConstIterator operator ++(int); + + //! moves iterator to the element after the last element + void seekEnd(); + + const SparseMat* m; + size_t hashidx; + uchar* ptr; +}; + + + +////////////////////////////////// SparseMatIterator ///////////////////////////////// + +/** @brief Read-write Sparse Matrix Iterator + + The class is similar to cv::SparseMatConstIterator, + but can be used for in-place modification of the matrix elements. +*/ +class CV_EXPORTS SparseMatIterator : public SparseMatConstIterator +{ +public: + //! the default constructor + SparseMatIterator(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatIterator(SparseMat* _m); + //! the full constructor setting the iterator to the specified sparse matrix element + SparseMatIterator(SparseMat* _m, const int* idx); + //! the copy constructor + SparseMatIterator(const SparseMatIterator& it); + + //! the assignment operator + SparseMatIterator& operator = (const SparseMatIterator& it); + //! returns read-write reference to the current sparse matrix element + template _Tp& value() const; + //! returns pointer to the current sparse matrix node. it.node->idx is the index of the current element (do not modify it!) + SparseMat::Node* node() const; + + //! moves iterator to the next element + SparseMatIterator& operator ++(); + //! moves iterator to the next element + SparseMatIterator operator ++(int); +}; + + + +/////////////////////////////// SparseMatConstIterator_ ////////////////////////////// + +/** @brief Template Read-Only Sparse Matrix Iterator Class. + + This is the derived from SparseMatConstIterator class that + introduces more convenient operator *() for accessing the current element. +*/ +template class SparseMatConstIterator_ : public SparseMatConstIterator +{ +public: + + typedef std::forward_iterator_tag iterator_category; + + //! the default constructor + SparseMatConstIterator_(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatConstIterator_(const SparseMat_<_Tp>* _m); + SparseMatConstIterator_(const SparseMat* _m); + //! the copy constructor + SparseMatConstIterator_(const SparseMatConstIterator_& it); + + //! the assignment operator + SparseMatConstIterator_& operator = (const SparseMatConstIterator_& it); + //! the element access operator + const _Tp& operator *() const; + + //! moves iterator to the next element + SparseMatConstIterator_& operator ++(); + //! moves iterator to the next element + SparseMatConstIterator_ operator ++(int); +}; + + + +///////////////////////////////// SparseMatIterator_ ///////////////////////////////// + +/** @brief Template Read-Write Sparse Matrix Iterator Class. + + This is the derived from cv::SparseMatConstIterator_ class that + introduces more convenient operator *() for accessing the current element. +*/ +template class SparseMatIterator_ : public SparseMatConstIterator_<_Tp> +{ +public: + + typedef std::forward_iterator_tag iterator_category; + + //! the default constructor + SparseMatIterator_(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatIterator_(SparseMat_<_Tp>* _m); + SparseMatIterator_(SparseMat* _m); + //! the copy constructor + SparseMatIterator_(const SparseMatIterator_& it); + + //! the assignment operator + SparseMatIterator_& operator = (const SparseMatIterator_& it); + //! returns the reference to the current element + _Tp& operator *() const; + + //! moves the iterator to the next element + SparseMatIterator_& operator ++(); + //! moves the iterator to the next element + SparseMatIterator_ operator ++(int); +}; + + + +/////////////////////////////////// NAryMatIterator ////////////////////////////////// + +/** @brief n-ary multi-dimensional array iterator. + +Use the class to implement unary, binary, and, generally, n-ary element-wise operations on +multi-dimensional arrays. Some of the arguments of an n-ary function may be continuous arrays, some +may be not. It is possible to use conventional MatIterator 's for each array but incrementing all of +the iterators after each small operations may be a big overhead. In this case consider using +NAryMatIterator to iterate through several matrices simultaneously as long as they have the same +geometry (dimensionality and all the dimension sizes are the same). On each iteration `it.planes[0]`, +`it.planes[1]`,... will be the slices of the corresponding matrices. + +The example below illustrates how you can compute a normalized and threshold 3D color histogram: +@code + void computeNormalizedColorHist(const Mat& image, Mat& hist, int N, double minProb) + { + const int histSize[] = {N, N, N}; + + // make sure that the histogram has a proper size and type + hist.create(3, histSize, CV_32F); + + // and clear it + hist = Scalar(0); + + // the loop below assumes that the image + // is a 8-bit 3-channel. check it. + CV_Assert(image.type() == CV_8UC3); + MatConstIterator_ it = image.begin(), + it_end = image.end(); + for( ; it != it_end; ++it ) + { + const Vec3b& pix = *it; + hist.at(pix[0]*N/256, pix[1]*N/256, pix[2]*N/256) += 1.f; + } + + minProb *= image.rows*image.cols; + + // initialize iterator (the style is different from STL). + // after initialization the iterator will contain + // the number of slices or planes the iterator will go through. + // it simultaneously increments iterators for several matrices + // supplied as a null terminated list of pointers + const Mat* arrays[] = {&hist, 0}; + Mat planes[1]; + NAryMatIterator itNAry(arrays, planes, 1); + double s = 0; + // iterate through the matrix. on each iteration + // itNAry.planes[i] (of type Mat) will be set to the current plane + // of the i-th n-dim matrix passed to the iterator constructor. + for(int p = 0; p < itNAry.nplanes; p++, ++itNAry) + { + threshold(itNAry.planes[0], itNAry.planes[0], minProb, 0, THRESH_TOZERO); + s += sum(itNAry.planes[0])[0]; + } + + s = 1./s; + itNAry = NAryMatIterator(arrays, planes, 1); + for(int p = 0; p < itNAry.nplanes; p++, ++itNAry) + itNAry.planes[0] *= s; + } +@endcode + */ +class CV_EXPORTS NAryMatIterator +{ +public: + //! the default constructor + NAryMatIterator(); + //! the full constructor taking arbitrary number of n-dim matrices + NAryMatIterator(const Mat** arrays, uchar** ptrs, int narrays=-1); + //! the full constructor taking arbitrary number of n-dim matrices + NAryMatIterator(const Mat** arrays, Mat* planes, int narrays=-1); + //! the separate iterator initialization method + void init(const Mat** arrays, Mat* planes, uchar** ptrs, int narrays=-1); + + //! proceeds to the next plane of every iterated matrix + NAryMatIterator& operator ++(); + //! proceeds to the next plane of every iterated matrix (postfix increment operator) + NAryMatIterator operator ++(int); + + //! the iterated arrays + const Mat** arrays; + //! the current planes + Mat* planes; + //! data pointers + uchar** ptrs; + //! the number of arrays + int narrays; + //! the number of hyper-planes that the iterator steps through + size_t nplanes; + //! the size of each segment (in elements) + size_t size; +protected: + int iterdepth; + size_t idx; +}; + + + +///////////////////////////////// Matrix Expressions ///////////////////////////////// + +class CV_EXPORTS MatOp +{ +public: + MatOp(); + virtual ~MatOp(); + + virtual bool elementWise(const MatExpr& expr) const; + virtual void assign(const MatExpr& expr, Mat& m, int type=-1) const = 0; + virtual void roi(const MatExpr& expr, const Range& rowRange, + const Range& colRange, MatExpr& res) const; + virtual void diag(const MatExpr& expr, int d, MatExpr& res) const; + virtual void augAssignAdd(const MatExpr& expr, Mat& m) const; + virtual void augAssignSubtract(const MatExpr& expr, Mat& m) const; + virtual void augAssignMultiply(const MatExpr& expr, Mat& m) const; + virtual void augAssignDivide(const MatExpr& expr, Mat& m) const; + virtual void augAssignAnd(const MatExpr& expr, Mat& m) const; + virtual void augAssignOr(const MatExpr& expr, Mat& m) const; + virtual void augAssignXor(const MatExpr& expr, Mat& m) const; + + virtual void add(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; + virtual void add(const MatExpr& expr1, const Scalar& s, MatExpr& res) const; + + virtual void subtract(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; + virtual void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const; + + virtual void multiply(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const; + virtual void multiply(const MatExpr& expr1, double s, MatExpr& res) const; + + virtual void divide(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const; + virtual void divide(double s, const MatExpr& expr, MatExpr& res) const; + + virtual void abs(const MatExpr& expr, MatExpr& res) const; + + virtual void transpose(const MatExpr& expr, MatExpr& res) const; + virtual void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; + virtual void invert(const MatExpr& expr, int method, MatExpr& res) const; + + virtual Size size(const MatExpr& expr) const; + virtual int type(const MatExpr& expr) const; +}; + +/** @brief Matrix expression representation +@anchor MatrixExpressions +This is a list of implemented matrix operations that can be combined in arbitrary complex +expressions (here A, B stand for matrices ( Mat ), s for a scalar ( Scalar ), alpha for a +real-valued scalar ( double )): +- Addition, subtraction, negation: `A+B`, `A-B`, `A+s`, `A-s`, `s+A`, `s-A`, `-A` +- Scaling: `A*alpha` +- Per-element multiplication and division: `A.mul(B)`, `A/B`, `alpha/A` +- Matrix multiplication: `A*B` +- Transposition: `A.t()` (means AT) +- Matrix inversion and pseudo-inversion, solving linear systems and least-squares problems: + `A.inv([method]) (~ A-1)`, `A.inv([method])*B (~ X: AX=B)` +- Comparison: `A cmpop B`, `A cmpop alpha`, `alpha cmpop A`, where *cmpop* is one of + `>`, `>=`, `==`, `!=`, `<=`, `<`. The result of comparison is an 8-bit single channel mask whose + elements are set to 255 (if the particular element or pair of elements satisfy the condition) or + 0. +- Bitwise logical operations: `A logicop B`, `A logicop s`, `s logicop A`, `~A`, where *logicop* is one of + `&`, `|`, `^`. +- Element-wise minimum and maximum: `min(A, B)`, `min(A, alpha)`, `max(A, B)`, `max(A, alpha)` +- Element-wise absolute value: `abs(A)` +- Cross-product, dot-product: `A.cross(B)`, `A.dot(B)` +- Any function of matrix or matrices and scalars that returns a matrix or a scalar, such as norm, + mean, sum, countNonZero, trace, determinant, repeat, and others. +- Matrix initializers ( Mat::eye(), Mat::zeros(), Mat::ones() ), matrix comma-separated + initializers, matrix constructors and operators that extract sub-matrices (see Mat description). +- Mat_() constructors to cast the result to the proper type. +@note Comma-separated initializers and probably some other operations may require additional +explicit Mat() or Mat_() constructor calls to resolve a possible ambiguity. + +Here are examples of matrix expressions: +@code + // compute pseudo-inverse of A, equivalent to A.inv(DECOMP_SVD) + SVD svd(A); + Mat pinvA = svd.vt.t()*Mat::diag(1./svd.w)*svd.u.t(); + + // compute the new vector of parameters in the Levenberg-Marquardt algorithm + x -= (A.t()*A + lambda*Mat::eye(A.cols,A.cols,A.type())).inv(DECOMP_CHOLESKY)*(A.t()*err); + + // sharpen image using "unsharp mask" algorithm + Mat blurred; double sigma = 1, threshold = 5, amount = 1; + GaussianBlur(img, blurred, Size(), sigma, sigma); + Mat lowContrastMask = abs(img - blurred) < threshold; + Mat sharpened = img*(1+amount) + blurred*(-amount); + img.copyTo(sharpened, lowContrastMask); +@endcode +*/ +class CV_EXPORTS MatExpr +{ +public: + MatExpr(); + explicit MatExpr(const Mat& m); + + MatExpr(const MatOp* _op, int _flags, const Mat& _a = Mat(), const Mat& _b = Mat(), + const Mat& _c = Mat(), double _alpha = 1, double _beta = 1, const Scalar& _s = Scalar()); + + operator Mat() const; + template operator Mat_<_Tp>() const; + + Size size() const; + int type() const; + + MatExpr row(int y) const; + MatExpr col(int x) const; + MatExpr diag(int d = 0) const; + MatExpr operator()( const Range& rowRange, const Range& colRange ) const; + MatExpr operator()( const Rect& roi ) const; + + MatExpr t() const; + MatExpr inv(int method = DECOMP_LU) const; + MatExpr mul(const MatExpr& e, double scale=1) const; + MatExpr mul(const Mat& m, double scale=1) const; + + Mat cross(const Mat& m) const; + double dot(const Mat& m) const; + + void swap(MatExpr& b); + + const MatOp* op; + int flags; + + Mat a, b, c; + double alpha, beta; + Scalar s; +}; + +//! @} core_basic + +//! @relates cv::MatExpr +//! @{ +CV_EXPORTS MatExpr operator + (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator + (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator + (const Scalar& s, const Mat& a); +CV_EXPORTS MatExpr operator + (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator + (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator + (const MatExpr& e, const Scalar& s); +CV_EXPORTS MatExpr operator + (const Scalar& s, const MatExpr& e); +CV_EXPORTS MatExpr operator + (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator + (const Mat& a, const Matx<_Tp, m, n>& b) { return a + Mat(b); } +template static inline +MatExpr operator + (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) + b; } + +CV_EXPORTS MatExpr operator - (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator - (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator - (const Scalar& s, const Mat& a); +CV_EXPORTS MatExpr operator - (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator - (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator - (const MatExpr& e, const Scalar& s); +CV_EXPORTS MatExpr operator - (const Scalar& s, const MatExpr& e); +CV_EXPORTS MatExpr operator - (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator - (const Mat& a, const Matx<_Tp, m, n>& b) { return a - Mat(b); } +template static inline +MatExpr operator - (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) - b; } + +CV_EXPORTS MatExpr operator - (const Mat& m); +CV_EXPORTS MatExpr operator - (const MatExpr& e); + +CV_EXPORTS MatExpr operator * (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator * (const Mat& a, double s); +CV_EXPORTS MatExpr operator * (double s, const Mat& a); +CV_EXPORTS MatExpr operator * (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator * (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator * (const MatExpr& e, double s); +CV_EXPORTS MatExpr operator * (double s, const MatExpr& e); +CV_EXPORTS MatExpr operator * (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator * (const Mat& a, const Matx<_Tp, m, n>& b) { return a * Mat(b); } +template static inline +MatExpr operator * (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) * b; } + +CV_EXPORTS MatExpr operator / (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator / (const Mat& a, double s); +CV_EXPORTS MatExpr operator / (double s, const Mat& a); +CV_EXPORTS MatExpr operator / (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator / (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator / (const MatExpr& e, double s); +CV_EXPORTS MatExpr operator / (double s, const MatExpr& e); +CV_EXPORTS MatExpr operator / (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator / (const Mat& a, const Matx<_Tp, m, n>& b) { return a / Mat(b); } +template static inline +MatExpr operator / (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) / b; } + +CV_EXPORTS MatExpr operator < (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator < (const Mat& a, double s); +CV_EXPORTS MatExpr operator < (double s, const Mat& a); +template static inline +MatExpr operator < (const Mat& a, const Matx<_Tp, m, n>& b) { return a < Mat(b); } +template static inline +MatExpr operator < (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) < b; } + +CV_EXPORTS MatExpr operator <= (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator <= (const Mat& a, double s); +CV_EXPORTS MatExpr operator <= (double s, const Mat& a); +template static inline +MatExpr operator <= (const Mat& a, const Matx<_Tp, m, n>& b) { return a <= Mat(b); } +template static inline +MatExpr operator <= (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) <= b; } + +CV_EXPORTS MatExpr operator == (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator == (const Mat& a, double s); +CV_EXPORTS MatExpr operator == (double s, const Mat& a); +template static inline +MatExpr operator == (const Mat& a, const Matx<_Tp, m, n>& b) { return a == Mat(b); } +template static inline +MatExpr operator == (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) == b; } + +CV_EXPORTS MatExpr operator != (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator != (const Mat& a, double s); +CV_EXPORTS MatExpr operator != (double s, const Mat& a); +template static inline +MatExpr operator != (const Mat& a, const Matx<_Tp, m, n>& b) { return a != Mat(b); } +template static inline +MatExpr operator != (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) != b; } + +CV_EXPORTS MatExpr operator >= (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator >= (const Mat& a, double s); +CV_EXPORTS MatExpr operator >= (double s, const Mat& a); +template static inline +MatExpr operator >= (const Mat& a, const Matx<_Tp, m, n>& b) { return a >= Mat(b); } +template static inline +MatExpr operator >= (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) >= b; } + +CV_EXPORTS MatExpr operator > (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator > (const Mat& a, double s); +CV_EXPORTS MatExpr operator > (double s, const Mat& a); +template static inline +MatExpr operator > (const Mat& a, const Matx<_Tp, m, n>& b) { return a > Mat(b); } +template static inline +MatExpr operator > (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) > b; } + +CV_EXPORTS MatExpr operator & (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator & (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator & (const Scalar& s, const Mat& a); +template static inline +MatExpr operator & (const Mat& a, const Matx<_Tp, m, n>& b) { return a & Mat(b); } +template static inline +MatExpr operator & (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) & b; } + +CV_EXPORTS MatExpr operator | (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator | (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator | (const Scalar& s, const Mat& a); +template static inline +MatExpr operator | (const Mat& a, const Matx<_Tp, m, n>& b) { return a | Mat(b); } +template static inline +MatExpr operator | (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) | b; } + +CV_EXPORTS MatExpr operator ^ (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator ^ (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator ^ (const Scalar& s, const Mat& a); +template static inline +MatExpr operator ^ (const Mat& a, const Matx<_Tp, m, n>& b) { return a ^ Mat(b); } +template static inline +MatExpr operator ^ (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) ^ b; } + +CV_EXPORTS MatExpr operator ~(const Mat& m); + +CV_EXPORTS MatExpr min(const Mat& a, const Mat& b); +CV_EXPORTS MatExpr min(const Mat& a, double s); +CV_EXPORTS MatExpr min(double s, const Mat& a); +template static inline +MatExpr min (const Mat& a, const Matx<_Tp, m, n>& b) { return min(a, Mat(b)); } +template static inline +MatExpr min (const Matx<_Tp, m, n>& a, const Mat& b) { return min(Mat(a), b); } + +CV_EXPORTS MatExpr max(const Mat& a, const Mat& b); +CV_EXPORTS MatExpr max(const Mat& a, double s); +CV_EXPORTS MatExpr max(double s, const Mat& a); +template static inline +MatExpr max (const Mat& a, const Matx<_Tp, m, n>& b) { return max(a, Mat(b)); } +template static inline +MatExpr max (const Matx<_Tp, m, n>& a, const Mat& b) { return max(Mat(a), b); } + +/** @brief Calculates an absolute value of each matrix element. + +abs is a meta-function that is expanded to one of absdiff or convertScaleAbs forms: +- C = abs(A-B) is equivalent to `absdiff(A, B, C)` +- C = abs(A) is equivalent to `absdiff(A, Scalar::all(0), C)` +- C = `Mat_ >(abs(A*alpha + beta))` is equivalent to `convertScaleAbs(A, C, alpha, +beta)` + +The output matrix has the same size and the same type as the input one except for the last case, +where C is depth=CV_8U . +@param m matrix. +@sa @ref MatrixExpressions, absdiff, convertScaleAbs + */ +CV_EXPORTS MatExpr abs(const Mat& m); +/** @overload +@param e matrix expression. +*/ +CV_EXPORTS MatExpr abs(const MatExpr& e); +//! @} relates cv::MatExpr + +} // cv + +#include "opencv2/core/mat.inl.hpp" + +#endif // OPENCV_CORE_MAT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/mat.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/mat.inl.hpp new file mode 100644 index 0000000..886b82c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/mat.inl.hpp @@ -0,0 +1,3422 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_MATRIX_OPERATIONS_HPP +#define OPENCV_CORE_MATRIX_OPERATIONS_HPP + +#ifndef __cplusplus +# error mat.inl.hpp header must be compiled as C++ +#endif + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4127 ) +#endif + +#if defined(CV_SKIP_DISABLE_CLANG_ENUM_WARNINGS) + // nothing +#elif defined(CV_FORCE_DISABLE_CLANG_ENUM_WARNINGS) + #define CV_DISABLE_CLANG_ENUM_WARNINGS +#elif defined(__clang__) && defined(__has_warning) + #if __has_warning("-Wdeprecated-enum-enum-conversion") && __has_warning("-Wdeprecated-anon-enum-enum-conversion") + #define CV_DISABLE_CLANG_ENUM_WARNINGS + #endif +#endif +#ifdef CV_DISABLE_CLANG_ENUM_WARNINGS +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion" +#pragma clang diagnostic ignored "-Wdeprecated-anon-enum-enum-conversion" +#endif + +namespace cv +{ +CV__DEBUG_NS_BEGIN + + +//! @cond IGNORED + +////////////////////////// Custom (raw) type wrapper ////////////////////////// + +template static inline +int rawType() +{ + CV_StaticAssert(sizeof(_Tp) <= CV_CN_MAX, "sizeof(_Tp) is too large"); + const int elemSize = sizeof(_Tp); + return (int)CV_MAKETYPE(CV_8U, elemSize); +} + +//////////////////////// Input/Output Arrays //////////////////////// + +inline void _InputArray::init(int _flags, const void* _obj) +{ flags = _flags; obj = (void*)_obj; } + +inline void _InputArray::init(int _flags, const void* _obj, Size _sz) +{ flags = _flags; obj = (void*)_obj; sz = _sz; } + +inline void* _InputArray::getObj() const { return obj; } +inline int _InputArray::getFlags() const { return flags; } +inline Size _InputArray::getSz() const { return sz; } + +inline _InputArray::_InputArray() { init(0 + NONE, 0); } +inline _InputArray::_InputArray(int _flags, void* _obj) { init(_flags, _obj); } +inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); } +inline _InputArray::_InputArray(const UMat& m) { init(UMAT+ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::vector<_Tp>& vec) +{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); } + +template inline +_InputArray::_InputArray(const std::array& arr) +{ init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); } + +inline +_InputArray::_InputArray(const std::vector& vec) +{ init(FIXED_TYPE + STD_BOOL_VECTOR + traits::Type::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, &mtx, Size(n, m)); } + +template inline +_InputArray::_InputArray(const _Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, vec, Size(n, 1)); } + +template inline +_InputArray::_InputArray(const Mat_<_Tp>& m) +{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_READ, &m); } + +inline _InputArray::_InputArray(const double& val) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F + ACCESS_READ, &val, Size(1,1)); } + +inline _InputArray::_InputArray(const cuda::GpuMat& d_mat) +{ init(CUDA_GPU_MAT + ACCESS_READ, &d_mat); } + +inline _InputArray::_InputArray(const std::vector& d_mat) +{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_READ, &d_mat);} + +inline _InputArray::_InputArray(const ogl::Buffer& buf) +{ init(OPENGL_BUFFER + ACCESS_READ, &buf); } + +inline _InputArray::_InputArray(const cuda::HostMem& cuda_mem) +{ init(CUDA_HOST_MEM + ACCESS_READ, &cuda_mem); } + +template inline +_InputArray _InputArray::rawIn(const std::vector<_Tp>& vec) +{ + _InputArray v; + v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_READ; + v.obj = (void*)&vec; + return v; +} + +template inline +_InputArray _InputArray::rawIn(const std::array<_Tp, _Nm>& arr) +{ + _InputArray v; + v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ; + v.obj = (void*)arr.data(); + v.sz = Size(1, _Nm); + return v; +} + +inline _InputArray::~_InputArray() {} + +inline Mat _InputArray::getMat(int i) const +{ + if( kind() == MAT && i < 0 ) + return *(const Mat*)obj; + return getMat_(i); +} + +inline bool _InputArray::isMat() const { return kind() == _InputArray::MAT; } +inline bool _InputArray::isUMat() const { return kind() == _InputArray::UMAT; } +inline bool _InputArray::isMatVector() const { return kind() == _InputArray::STD_VECTOR_MAT; } +inline bool _InputArray::isUMatVector() const { return kind() == _InputArray::STD_VECTOR_UMAT; } +inline bool _InputArray::isMatx() const { return kind() == _InputArray::MATX; } +inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR || + kind() == _InputArray::STD_BOOL_VECTOR || + (kind() == _InputArray::MATX && (sz.width <= 1 || sz.height <= 1)); } +inline bool _InputArray::isGpuMat() const { return kind() == _InputArray::CUDA_GPU_MAT; } +inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::STD_VECTOR_CUDA_GPU_MAT; } + +//////////////////////////////////////////////////////////////////////////////////////// + +inline _OutputArray::_OutputArray() { init(NONE + ACCESS_WRITE, 0); } +inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags + ACCESS_WRITE, _obj); } +inline _OutputArray::_OutputArray(Mat& m) { init(MAT+ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_MAT + ACCESS_WRITE, &vec); } +inline _OutputArray::_OutputArray(UMat& m) { init(UMAT + ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(std::vector<_Tp>& vec) +{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(std::array& arr) +{ init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(Mat_<_Tp>& m) +{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } + +template inline +_OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } + +template inline +_OutputArray::_OutputArray(_Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } + +template inline +_OutputArray::_OutputArray(const std::vector<_Tp>& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(const std::array& arr) +{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(const Mat_<_Tp>& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } + +template inline +_OutputArray::_OutputArray(const Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } + +template inline +_OutputArray::_OutputArray(const _Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } + +inline _OutputArray::_OutputArray(cuda::GpuMat& d_mat) +{ init(CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } + +inline _OutputArray::_OutputArray(std::vector& d_mat) +{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_WRITE, &d_mat);} + +inline _OutputArray::_OutputArray(ogl::Buffer& buf) +{ init(OPENGL_BUFFER + ACCESS_WRITE, &buf); } + +inline _OutputArray::_OutputArray(cuda::HostMem& cuda_mem) +{ init(CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } + +inline _OutputArray::_OutputArray(const Mat& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_WRITE, &m); } + +inline _OutputArray::_OutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_WRITE, &vec); } + +inline _OutputArray::_OutputArray(const UMat& m) +{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_WRITE, &m); } + +inline _OutputArray::_OutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } + +inline _OutputArray::_OutputArray(const cuda::GpuMat& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } + + +inline _OutputArray::_OutputArray(const ogl::Buffer& buf) +{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_WRITE, &buf); } + +inline _OutputArray::_OutputArray(const cuda::HostMem& cuda_mem) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } + +template inline +_OutputArray _OutputArray::rawOut(std::vector<_Tp>& vec) +{ + _OutputArray v; + v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_WRITE; + v.obj = (void*)&vec; + return v; +} + +template inline +_OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr) +{ + _OutputArray v; + v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE; + v.obj = (void*)arr.data(); + v.sz = Size(1, _Nm); + return v; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +inline _InputOutputArray::_InputOutputArray() { init(0+ACCESS_RW, 0); } +inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags+ACCESS_RW, _obj); } +inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT+ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); } +inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec) +{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(std::array& arr) +{ init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(Mat_<_Tp>& m) +{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } + +template inline +_InputOutputArray::_InputOutputArray(Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } + +template inline +_InputOutputArray::_InputOutputArray(_Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } + +template inline +_InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(const std::array& arr) +{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(const Mat_<_Tp>& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } + +template inline +_InputOutputArray::_InputOutputArray(const Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } + +template inline +_InputOutputArray::_InputOutputArray(const _Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } + +inline _InputOutputArray::_InputOutputArray(cuda::GpuMat& d_mat) +{ init(CUDA_GPU_MAT + ACCESS_RW, &d_mat); } + +inline _InputOutputArray::_InputOutputArray(ogl::Buffer& buf) +{ init(OPENGL_BUFFER + ACCESS_RW, &buf); } + +inline _InputOutputArray::_InputOutputArray(cuda::HostMem& cuda_mem) +{ init(CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } + +inline _InputOutputArray::_InputOutputArray(const Mat& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_RW, &m); } + +inline _InputOutputArray::_InputOutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_RW, &vec); } + +inline _InputOutputArray::_InputOutputArray(const UMat& m) +{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_RW, &m); } + +inline _InputOutputArray::_InputOutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_RW, &vec); } + +inline _InputOutputArray::_InputOutputArray(const cuda::GpuMat& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_RW, &d_mat); } + +inline _InputOutputArray::_InputOutputArray(const std::vector& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} + +template<> inline _InputOutputArray::_InputOutputArray(std::vector& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} + +inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf) +{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_RW, &buf); } + +inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } + +template inline +_InputOutputArray _InputOutputArray::rawInOut(std::vector<_Tp>& vec) +{ + _InputOutputArray v; + v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_RW; + v.obj = (void*)&vec; + return v; +} + +template inline +_InputOutputArray _InputOutputArray::rawInOut(std::array<_Tp, _Nm>& arr) +{ + _InputOutputArray v; + v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW; + v.obj = (void*)arr.data(); + v.sz = Size(1, _Nm); + return v; +} + + +template static inline _InputArray rawIn(_Tp& v) { return _InputArray::rawIn(v); } +template static inline _OutputArray rawOut(_Tp& v) { return _OutputArray::rawOut(v); } +template static inline _InputOutputArray rawInOut(_Tp& v) { return _InputOutputArray::rawInOut(v); } + +CV__DEBUG_NS_END + +//////////////////////////////////////////// Mat ////////////////////////////////////////// + +template inline +Mat::Mat(const std::vector<_Tp>& vec, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), + cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if(vec.empty()) + return; + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)&vec[0]; + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); +} + +template inline +Mat::Mat(const std::initializer_list<_Tp> list) + : Mat() +{ + CV_Assert(list.size() != 0); + Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this); +} + +template inline +Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp> list) + : Mat() +{ + size_t size_total = 1; + for(auto s : sizes) + size_total *= s; + CV_Assert(list.size() != 0); + CV_Assert(size_total == list.size()); + Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this); +} + +template inline +Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), + cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if(arr.empty()) + return; + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)arr.data(); + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat((int)arr.size(), 1, traits::Type<_Tp>::value, (uchar*)arr.data()).copyTo(*this); +} + +template inline +Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)vec.val; + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat(n, 1, traits::Type<_Tp>::value, (void*)vec.val).copyTo(*this); +} + + +template inline +Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = cols * sizeof(_Tp); + step[1] = sizeof(_Tp); + datastart = data = (uchar*)M.val; + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat(m, n, traits::Type<_Tp>::value, (uchar*)M.val).copyTo(*this); +} + +template inline +Mat::Mat(const Point_<_Tp>& pt, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)&pt.x; + datalimit = dataend = datastart + rows * step[0]; + } + else + { + create(2, 1, traits::Type<_Tp>::value); + ((_Tp*)data)[0] = pt.x; + ((_Tp*)data)[1] = pt.y; + } +} + +template inline +Mat::Mat(const Point3_<_Tp>& pt, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)&pt.x; + datalimit = dataend = datastart + rows * step[0]; + } + else + { + create(3, 1, traits::Type<_Tp>::value); + ((_Tp*)data)[0] = pt.x; + ((_Tp*)data)[1] = pt.y; + ((_Tp*)data)[2] = pt.z; + } +} + +template inline +Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), + datastart(0), dataend(0), allocator(0), u(0), size(&rows) +{ + *this = commaInitializer.operator Mat_<_Tp>(); +} + +inline +Mat Mat::row(int y) const +{ + return Mat(*this, Range(y, y + 1), Range::all()); +} + +inline +Mat Mat::col(int x) const +{ + return Mat(*this, Range::all(), Range(x, x + 1)); +} + +inline +Mat Mat::rowRange(int startrow, int endrow) const +{ + return Mat(*this, Range(startrow, endrow), Range::all()); +} + +inline +Mat Mat::rowRange(const Range& r) const +{ + return Mat(*this, r, Range::all()); +} + +inline +Mat Mat::colRange(int startcol, int endcol) const +{ + return Mat(*this, Range::all(), Range(startcol, endcol)); +} + +inline +Mat Mat::colRange(const Range& r) const +{ + return Mat(*this, Range::all(), r); +} + +inline +Mat Mat::operator()( Range _rowRange, Range _colRange ) const +{ + return Mat(*this, _rowRange, _colRange); +} + +inline +Mat Mat::operator()( const Rect& roi ) const +{ + return Mat(*this, roi); +} + +inline +Mat Mat::operator()(const Range* ranges) const +{ + return Mat(*this, ranges); +} + +inline +Mat Mat::operator()(const std::vector& ranges) const +{ + return Mat(*this, ranges); +} + +inline +bool Mat::isContinuous() const +{ + return (flags & CONTINUOUS_FLAG) != 0; +} + +inline +bool Mat::isSubmatrix() const +{ + return (flags & SUBMATRIX_FLAG) != 0; +} + +inline +size_t Mat::elemSize() const +{ + size_t res = dims > 0 ? step.p[dims - 1] : 0; + CV_DbgAssert(res != 0); + return res; +} + +inline +size_t Mat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int Mat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int Mat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int Mat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +uchar* Mat::ptr(int y) +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return data + step.p[0] * y; +} + +inline +const uchar* Mat::ptr(int y) const +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return data + step.p[0] * y; +} + +template inline +_Tp* Mat::ptr(int y) +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return (_Tp*)(data + step.p[0] * y); +} + +template inline +const _Tp* Mat::ptr(int y) const +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return (const _Tp*)(data + step.p[0] * y); +} + +inline +uchar* Mat::ptr(int i0, int i1) +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return data + i0 * step.p[0] + i1 * step.p[1]; +} + +inline +const uchar* Mat::ptr(int i0, int i1) const +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return data + i0 * step.p[0] + i1 * step.p[1]; +} + +template inline +_Tp* Mat::ptr(int i0, int i1) +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return (_Tp*)(data + i0 * step.p[0] + i1 * step.p[1]); +} + +template inline +const _Tp* Mat::ptr(int i0, int i1) const +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return (const _Tp*)(data + i0 * step.p[0] + i1 * step.p[1]); +} + +inline +uchar* Mat::ptr(int i0, int i1, int i2) +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]; +} + +inline +const uchar* Mat::ptr(int i0, int i1, int i2) const +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]; +} + +template inline +_Tp* Mat::ptr(int i0, int i1, int i2) +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return (_Tp*)(data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]); +} + +template inline +const _Tp* Mat::ptr(int i0, int i1, int i2) const +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return (const _Tp*)(data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]); +} + +inline +uchar* Mat::ptr(const int* idx) +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return p; +} + +inline +const uchar* Mat::ptr(const int* idx) const +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return p; +} + +template inline +_Tp* Mat::ptr(const int* idx) +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return (_Tp*)p; +} + +template inline +const _Tp* Mat::ptr(const int* idx) const +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return (const _Tp*)p; +} + +template inline +uchar* Mat::ptr(const Vec& idx) +{ + return Mat::ptr(idx.val); +} + +template inline +const uchar* Mat::ptr(const Vec& idx) const +{ + return Mat::ptr(idx.val); +} + +template inline +_Tp* Mat::ptr(const Vec& idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return Mat::ptr<_Tp>(idx.val); +} + +template inline +const _Tp* Mat::ptr(const Vec& idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return Mat::ptr<_Tp>(idx.val); +} + + +template inline +_Tp& Mat::at(int i0, int i1) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((_Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +const _Tp& Mat::at(int i0, int i1) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((const _Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +_Tp& Mat::at(Point pt) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((_Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +const _Tp& Mat::at(Point pt) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((const _Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +_Tp& Mat::at(int i0) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)(size.p[0] * size.p[1])); + CV_DbgAssert(elemSize() == sizeof(_Tp)); + if( isContinuous() || size.p[0] == 1 ) + return ((_Tp*)data)[i0]; + if( size.p[1] == 1 ) + return *(_Tp*)(data + step.p[0] * i0); + int i = i0 / cols, j = i0 - i * cols; + return ((_Tp*)(data + step.p[0] * i))[j]; +} + +template inline +const _Tp& Mat::at(int i0) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)(size.p[0] * size.p[1])); + CV_DbgAssert(elemSize() == sizeof(_Tp)); + if( isContinuous() || size.p[0] == 1 ) + return ((const _Tp*)data)[i0]; + if( size.p[1] == 1 ) + return *(const _Tp*)(data + step.p[0] * i0); + int i = i0 / cols, j = i0 - i * cols; + return ((const _Tp*)(data + step.p[0] * i))[j]; +} + +template inline +_Tp& Mat::at(int i0, int i1, int i2) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(_Tp*)ptr(i0, i1, i2); +} + +template inline +const _Tp& Mat::at(int i0, int i1, int i2) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(const _Tp*)ptr(i0, i1, i2); +} + +template inline +_Tp& Mat::at(const int* idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(_Tp*)ptr(idx); +} + +template inline +const _Tp& Mat::at(const int* idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(const _Tp*)ptr(idx); +} + +template inline +_Tp& Mat::at(const Vec& idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(_Tp*)ptr(idx.val); +} + +template inline +const _Tp& Mat::at(const Vec& idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(const _Tp*)ptr(idx.val); +} + +template inline +MatConstIterator_<_Tp> Mat::begin() const +{ + if (empty()) + return MatConstIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return MatConstIterator_<_Tp>((const Mat_<_Tp>*)this); +} + +template inline +std::reverse_iterator> Mat::rbegin() const +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this); + it += total(); + return std::reverse_iterator> (it); +} + +template inline +MatConstIterator_<_Tp> Mat::end() const +{ + if (empty()) + return MatConstIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this); + it += total(); + return it; +} + +template inline +std::reverse_iterator> Mat::rend() const +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return std::reverse_iterator>((const Mat_<_Tp>*)this); +} + +template inline +MatIterator_<_Tp> Mat::begin() +{ + if (empty()) + return MatIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return MatIterator_<_Tp>((Mat_<_Tp>*)this); +} + +template inline +std::reverse_iterator> Mat::rbegin() +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatIterator_<_Tp> it((Mat_<_Tp>*)this); + it += total(); + return std::reverse_iterator>(it); +} + +template inline +MatIterator_<_Tp> Mat::end() +{ + if (empty()) + return MatIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatIterator_<_Tp> it((Mat_<_Tp>*)this); + it += total(); + return it; +} + +template inline +std::reverse_iterator> Mat::rend() +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return std::reverse_iterator>(MatIterator_<_Tp>((Mat_<_Tp>*)this)); +} + +template inline +void Mat::forEach(const Functor& operation) { + this->forEach_impl<_Tp>(operation); +} + +template inline +void Mat::forEach(const Functor& operation) const { + // call as not const + (const_cast(this))->forEach<_Tp>(operation); +} + +template inline +Mat::operator std::vector<_Tp>() const +{ + std::vector<_Tp> v; + copyTo(v); + return v; +} + +template inline +Mat::operator std::array<_Tp, _Nm>() const +{ + std::array<_Tp, _Nm> v; + copyTo(v); + return v; +} + +template inline +Mat::operator Vec<_Tp, n>() const +{ + CV_Assert( data && dims <= 2 && (rows == 1 || cols == 1) && + rows + cols - 1 == n && channels() == 1 ); + + if( isContinuous() && type() == traits::Type<_Tp>::value ) + return Vec<_Tp, n>((_Tp*)data); + Vec<_Tp, n> v; + Mat tmp(rows, cols, traits::Type<_Tp>::value, v.val); + convertTo(tmp, tmp.type()); + return v; +} + +template inline +Mat::operator Matx<_Tp, m, n>() const +{ + CV_Assert( data && dims <= 2 && rows == m && cols == n && channels() == 1 ); + + if( isContinuous() && type() == traits::Type<_Tp>::value ) + return Matx<_Tp, m, n>((_Tp*)data); + Matx<_Tp, m, n> mtx; + Mat tmp(rows, cols, traits::Type<_Tp>::value, mtx.val); + convertTo(tmp, tmp.type()); + return mtx; +} + +template inline +void Mat::push_back(const _Tp& elem) +{ + if( !data ) + { + *this = Mat(1, 1, traits::Type<_Tp>::value, (void*)&elem).clone(); + return; + } + CV_Assert(traits::Type<_Tp>::value == type() && cols == 1 + /* && dims == 2 (cols == 1 implies dims == 2) */); + const uchar* tmp = dataend + step[0]; + if( !isSubmatrix() && isContinuous() && tmp <= datalimit ) + { + *(_Tp*)(data + (size.p[0]++) * step.p[0]) = elem; + dataend = tmp; + } + else + push_back_(&elem); +} + +template inline +void Mat::push_back(const Mat_<_Tp>& m) +{ + push_back((const Mat&)m); +} + +template<> inline +void Mat::push_back(const MatExpr& expr) +{ + push_back(static_cast(expr)); +} + + +template inline +void Mat::push_back(const std::vector<_Tp>& v) +{ + push_back(Mat(v)); +} + + +///////////////////////////// MatSize //////////////////////////// + +inline +MatSize::MatSize(int* _p) CV_NOEXCEPT + : p(_p) {} + +inline +int MatSize::dims() const CV_NOEXCEPT +{ + return (p - 1)[0]; +} + +inline +Size MatSize::operator()() const +{ + CV_DbgAssert(dims() <= 2); + return Size(p[1], p[0]); +} + +inline +const int& MatSize::operator[](int i) const +{ + CV_DbgAssert(i < dims()); +#ifdef __OPENCV_BUILD + CV_DbgAssert(i >= 0); +#endif + return p[i]; +} + +inline +int& MatSize::operator[](int i) +{ + CV_DbgAssert(i < dims()); +#ifdef __OPENCV_BUILD + CV_DbgAssert(i >= 0); +#endif + return p[i]; +} + +inline +MatSize::operator const int*() const CV_NOEXCEPT +{ + return p; +} + +inline +bool MatSize::operator != (const MatSize& sz) const CV_NOEXCEPT +{ + return !(*this == sz); +} + + + +///////////////////////////// MatStep //////////////////////////// + +inline +MatStep::MatStep() CV_NOEXCEPT +{ + p = buf; p[0] = p[1] = 0; +} + +inline +MatStep::MatStep(size_t s) CV_NOEXCEPT +{ + p = buf; p[0] = s; p[1] = 0; +} + +inline +const size_t& MatStep::operator[](int i) const CV_NOEXCEPT +{ + return p[i]; +} + +inline +size_t& MatStep::operator[](int i) CV_NOEXCEPT +{ + return p[i]; +} + +inline MatStep::operator size_t() const +{ + CV_DbgAssert( p == buf ); + return buf[0]; +} + +inline MatStep& MatStep::operator = (size_t s) +{ + CV_DbgAssert( p == buf ); + buf[0] = s; + return *this; +} + + + +////////////////////////////// Mat_<_Tp> //////////////////////////// + +template inline +Mat_<_Tp>::Mat_() CV_NOEXCEPT + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; +} + +template inline +Mat_<_Tp>::Mat_(int _rows, int _cols) + : Mat(_rows, _cols, traits::Type<_Tp>::value) +{ +} + +template inline +Mat_<_Tp>::Mat_(int _rows, int _cols, const _Tp& value) + : Mat(_rows, _cols, traits::Type<_Tp>::value) +{ + *this = value; +} + +template inline +Mat_<_Tp>::Mat_(Size _sz) + : Mat(_sz.height, _sz.width, traits::Type<_Tp>::value) +{} + +template inline +Mat_<_Tp>::Mat_(Size _sz, const _Tp& value) + : Mat(_sz.height, _sz.width, traits::Type<_Tp>::value) +{ + *this = value; +} + +template inline +Mat_<_Tp>::Mat_(int _dims, const int* _sz) + : Mat(_dims, _sz, traits::Type<_Tp>::value) +{} + +template inline +Mat_<_Tp>::Mat_(int _dims, const int* _sz, const _Tp& _s) + : Mat(_dims, _sz, traits::Type<_Tp>::value, Scalar(_s)) +{} + +template inline +Mat_<_Tp>::Mat_(int _dims, const int* _sz, _Tp* _data, const size_t* _steps) + : Mat(_dims, _sz, traits::Type<_Tp>::value, _data, _steps) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const Range* ranges) + : Mat(m, ranges) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const std::vector& ranges) + : Mat(m, ranges) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat& m) + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + *this = m; +} + +template inline +Mat_<_Tp>::Mat_(const Mat_& m) + : Mat(m) +{} + +template inline +Mat_<_Tp>::Mat_(int _rows, int _cols, _Tp* _data, size_t steps) + : Mat(_rows, _cols, traits::Type<_Tp>::value, _data, steps) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_& m, const Range& _rowRange, const Range& _colRange) + : Mat(m, _rowRange, _colRange) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi) + : Mat(m, roi) +{} + +template template inline +Mat_<_Tp>::Mat_(const Vec::channel_type, n>& vec, bool copyData) + : Mat(n / DataType<_Tp>::channels, 1, traits::Type<_Tp>::value, (void*)&vec) +{ + CV_Assert(n%DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template template inline +Mat_<_Tp>::Mat_(const Matx::channel_type, m, n>& M, bool copyData) + : Mat(m, n / DataType<_Tp>::channels, traits::Type<_Tp>::value, (void*)&M) +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template inline +Mat_<_Tp>::Mat_(const Point_::channel_type>& pt, bool copyData) + : Mat(2 / DataType<_Tp>::channels, 1, traits::Type<_Tp>::value, (void*)&pt) +{ + CV_Assert(2 % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template inline +Mat_<_Tp>::Mat_(const Point3_::channel_type>& pt, bool copyData) + : Mat(3 / DataType<_Tp>::channels, 1, traits::Type<_Tp>::value, (void*)&pt) +{ + CV_Assert(3 % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template inline +Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer) + : Mat(commaInitializer) +{} + +template inline +Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData) + : Mat(vec, copyData) +{} + +template inline +Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list) + : Mat(list) +{} + +template inline +Mat_<_Tp>::Mat_(const std::initializer_list sizes, std::initializer_list<_Tp> list) + : Mat(sizes, list) +{} + +template template inline +Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData) + : Mat(arr, copyData) +{} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) +{ + if (m.empty()) + { + release(); + return *this; + } + if( traits::Type<_Tp>::value == m.type() ) + { + Mat::operator = (m); + return *this; + } + if( traits::Depth<_Tp>::value == m.depth() ) + { + return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0)); + } + CV_Assert(DataType<_Tp>::channels == m.channels() || m.empty()); + m.convertTo(*this, type()); + return *this; +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat_& m) +{ + Mat::operator=(m); + return *this; +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const _Tp& s) +{ + typedef typename DataType<_Tp>::vec_type VT; + Mat::operator=(Scalar((const VT&)s)); + return *this; +} + +template inline +void Mat_<_Tp>::create(int _rows, int _cols) +{ + Mat::create(_rows, _cols, traits::Type<_Tp>::value); +} + +template inline +void Mat_<_Tp>::create(Size _sz) +{ + Mat::create(_sz, traits::Type<_Tp>::value); +} + +template inline +void Mat_<_Tp>::create(int _dims, const int* _sz) +{ + Mat::create(_dims, _sz, traits::Type<_Tp>::value); +} + +template inline +void Mat_<_Tp>::release() +{ + Mat::release(); + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; +} + +template inline +Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const +{ + return Mat_<_Tp>(Mat::cross(m)); +} + +template template inline +Mat_<_Tp>::operator Mat_() const +{ + return Mat_(static_cast(*this)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::row(int y) const +{ + return Mat_(*this, Range(y, y+1), Range::all()); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::col(int x) const +{ + return Mat_(*this, Range::all(), Range(x, x+1)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::diag(int d) const +{ + return Mat_(Mat::diag(d)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::clone() const +{ + return Mat_(Mat::clone()); +} + +template inline +size_t Mat_<_Tp>::elemSize() const +{ + CV_DbgAssert( Mat::elemSize() == sizeof(_Tp) ); + return sizeof(_Tp); +} + +template inline +size_t Mat_<_Tp>::elemSize1() const +{ + CV_DbgAssert( Mat::elemSize1() == sizeof(_Tp) / DataType<_Tp>::channels ); + return sizeof(_Tp) / DataType<_Tp>::channels; +} + +template inline +int Mat_<_Tp>::type() const +{ + CV_DbgAssert( Mat::type() == traits::Type<_Tp>::value ); + return traits::Type<_Tp>::value; +} + +template inline +int Mat_<_Tp>::depth() const +{ + CV_DbgAssert( Mat::depth() == traits::Depth<_Tp>::value ); + return traits::Depth<_Tp>::value; +} + +template inline +int Mat_<_Tp>::channels() const +{ + CV_DbgAssert( Mat::channels() == DataType<_Tp>::channels ); + return DataType<_Tp>::channels; +} + +template inline +size_t Mat_<_Tp>::stepT(int i) const +{ + return step.p[i] / elemSize(); +} + +template inline +size_t Mat_<_Tp>::step1(int i) const +{ + return step.p[i] / elemSize1(); +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright ) +{ + return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()( const Range& _rowRange, const Range& _colRange ) const +{ + return Mat_<_Tp>(*this, _rowRange, _colRange); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()( const Rect& roi ) const +{ + return Mat_<_Tp>(*this, roi); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()( const Range* ranges ) const +{ + return Mat_<_Tp>(*this, ranges); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector& ranges) const +{ + return Mat_<_Tp>(*this, ranges); +} + +template inline +_Tp* Mat_<_Tp>::operator [](int y) +{ + CV_DbgAssert( 0 <= y && y < size.p[0] ); + return (_Tp*)(data + y*step.p[0]); +} + +template inline +const _Tp* Mat_<_Tp>::operator [](int y) const +{ + CV_DbgAssert( 0 <= y && y < size.p[0] ); + return (const _Tp*)(data + y*step.p[0]); +} + +template inline +_Tp& Mat_<_Tp>::operator ()(int i0, int i1) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((_Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(int i0, int i1) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((const _Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +_Tp& Mat_<_Tp>::operator ()(Point pt) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)pt.x < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((_Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(Point pt) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)pt.x < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((const _Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +_Tp& Mat_<_Tp>::operator ()(const int* idx) +{ + return Mat::at<_Tp>(idx); +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(const int* idx) const +{ + return Mat::at<_Tp>(idx); +} + +template template inline +_Tp& Mat_<_Tp>::operator ()(const Vec& idx) +{ + return Mat::at<_Tp>(idx); +} + +template template inline +const _Tp& Mat_<_Tp>::operator ()(const Vec& idx) const +{ + return Mat::at<_Tp>(idx); +} + +template inline +_Tp& Mat_<_Tp>::operator ()(int i0) +{ + return this->at<_Tp>(i0); +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(int i0) const +{ + return this->at<_Tp>(i0); +} + +template inline +_Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) +{ + return this->at<_Tp>(i0, i1, i2); +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) const +{ + return this->at<_Tp>(i0, i1, i2); +} + +template inline +Mat_<_Tp>::operator std::vector<_Tp>() const +{ + std::vector<_Tp> v; + copyTo(v); + return v; +} + +template template inline +Mat_<_Tp>::operator std::array<_Tp, _Nm>() const +{ + std::array<_Tp, _Nm> a; + copyTo(a); + return a; +} + +template template inline +Mat_<_Tp>::operator Vec::channel_type, n>() const +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + +#if defined _MSC_VER + const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) + return pMat->operator Vec::channel_type, n>(); +#else + return this->Mat::operator Vec::channel_type, n>(); +#endif +} + +template template inline +Mat_<_Tp>::operator Matx::channel_type, m, n>() const +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + +#if defined _MSC_VER + const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) + Matx::channel_type, m, n> res = pMat->operator Matx::channel_type, m, n>(); + return res; +#else + Matx::channel_type, m, n> res = this->Mat::operator Matx::channel_type, m, n>(); + return res; +#endif +} + +template inline +MatConstIterator_<_Tp> Mat_<_Tp>::begin() const +{ + return Mat::begin<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rbegin() const +{ + return Mat::rbegin<_Tp>(); +} + +template inline +MatConstIterator_<_Tp> Mat_<_Tp>::end() const +{ + return Mat::end<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rend() const +{ + return Mat::rend<_Tp>(); +} + +template inline +MatIterator_<_Tp> Mat_<_Tp>::begin() +{ + return Mat::begin<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rbegin() +{ + return Mat::rbegin<_Tp>(); +} + +template inline +MatIterator_<_Tp> Mat_<_Tp>::end() +{ + return Mat::end<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rend() +{ + return Mat::rend<_Tp>(); +} + +template template inline +void Mat_<_Tp>::forEach(const Functor& operation) { + Mat::forEach<_Tp, Functor>(operation); +} + +template template inline +void Mat_<_Tp>::forEach(const Functor& operation) const { + Mat::forEach<_Tp, Functor>(operation); +} + +template inline +Mat_<_Tp>::Mat_(Mat_&& m) + : Mat(std::move(m)) +{ +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m) +{ + Mat::operator = (std::move(m)); + return *this; +} + +template inline +Mat_<_Tp>::Mat_(Mat&& m) + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + *this = std::move(m); +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m) +{ + if (m.empty()) + { + release(); + return *this; + } + if( traits::Type<_Tp>::value == m.type() ) + { + Mat::operator = ((Mat&&)m); + return *this; + } + if( traits::Depth<_Tp>::value == m.depth() ) + { + Mat::operator = ((Mat&&)m.reshape(DataType<_Tp>::channels, m.dims, 0)); + return *this; + } + CV_DbgAssert(DataType<_Tp>::channels == m.channels()); + m.convertTo(*this, type()); + return *this; +} + +template inline +Mat_<_Tp>::Mat_(MatExpr&& e) + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + *this = Mat(e); +} + + +///////////////////////////// SparseMat ///////////////////////////// + +inline +SparseMat SparseMat::clone() const +{ + SparseMat temp; + this->copyTo(temp); + return temp; +} + +inline +size_t SparseMat::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t SparseMat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int SparseMat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int SparseMat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int SparseMat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +const int* SparseMat::size() const +{ + return hdr ? hdr->size : 0; +} + +inline +int SparseMat::size(int i) const +{ + if( hdr ) + { + CV_DbgAssert((unsigned)i < (unsigned)hdr->dims); + return hdr->size[i]; + } + return 0; +} + +inline +int SparseMat::dims() const +{ + return hdr ? hdr->dims : 0; +} + +inline +size_t SparseMat::nzcount() const +{ + return hdr ? hdr->nodeCount : 0; +} + +template inline +_Tp& SparseMat::ref(int i0, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(i0, true, hashval); +} + +template inline +_Tp& SparseMat::ref(int i0, int i1, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, true, hashval); +} + +template inline +_Tp& SparseMat::ref(int i0, int i1, int i2, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, i2, true, hashval); +} + +template inline +_Tp& SparseMat::ref(const int* idx, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(idx, true, hashval); +} + +template inline +_Tp SparseMat::value(int i0, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); + return p ? *p : _Tp(); +} + +template inline +_Tp SparseMat::value(int i0, int i1, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); + return p ? *p : _Tp(); +} + +template inline +_Tp SparseMat::value(int i0, int i1, int i2, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); + return p ? *p : _Tp(); +} + +template inline +_Tp SparseMat::value(const int* idx, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); + return p ? *p : _Tp(); +} + +template inline +const _Tp* SparseMat::find(int i0, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); +} + +template inline +const _Tp* SparseMat::find(int i0, int i1, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); +} + +template inline +const _Tp* SparseMat::find(int i0, int i1, int i2, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); +} + +template inline +const _Tp* SparseMat::find(const int* idx, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); +} + +template inline +_Tp& SparseMat::value(Node* n) +{ + return *(_Tp*)((uchar*)n + hdr->valueOffset); +} + +template inline +const _Tp& SparseMat::value(const Node* n) const +{ + return *(const _Tp*)((const uchar*)n + hdr->valueOffset); +} + +inline +SparseMat::Node* SparseMat::node(size_t nidx) +{ + return (Node*)(void*)&hdr->pool[nidx]; +} + +inline +const SparseMat::Node* SparseMat::node(size_t nidx) const +{ + return (const Node*)(const void*)&hdr->pool[nidx]; +} + +inline +SparseMatIterator SparseMat::begin() +{ + return SparseMatIterator(this); +} + +inline +SparseMatConstIterator SparseMat::begin() const +{ + return SparseMatConstIterator(this); +} + +inline +SparseMatIterator SparseMat::end() +{ + SparseMatIterator it(this); + it.seekEnd(); + return it; +} + +inline +SparseMatConstIterator SparseMat::end() const +{ + SparseMatConstIterator it(this); + it.seekEnd(); + return it; +} + +template inline +SparseMatIterator_<_Tp> SparseMat::begin() +{ + return SparseMatIterator_<_Tp>(this); +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat::begin() const +{ + return SparseMatConstIterator_<_Tp>(this); +} + +template inline +SparseMatIterator_<_Tp> SparseMat::end() +{ + SparseMatIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat::end() const +{ + SparseMatConstIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + + + +///////////////////////////// SparseMat_ //////////////////////////// + +template inline +SparseMat_<_Tp>::SparseMat_() +{ + flags = MAGIC_VAL + traits::Type<_Tp>::value; +} + +template inline +SparseMat_<_Tp>::SparseMat_(int _dims, const int* _sizes) + : SparseMat(_dims, _sizes, traits::Type<_Tp>::value) +{} + +template inline +SparseMat_<_Tp>::SparseMat_(const SparseMat& m) +{ + if( m.type() == traits::Type<_Tp>::value ) + *this = (const SparseMat_<_Tp>&)m; + else + m.convertTo(*this, traits::Type<_Tp>::value); +} + +template inline +SparseMat_<_Tp>::SparseMat_(const SparseMat_<_Tp>& m) +{ + this->flags = m.flags; + this->hdr = m.hdr; + if( this->hdr ) + CV_XADD(&this->hdr->refcount, 1); +} + +template inline +SparseMat_<_Tp>::SparseMat_(const Mat& m) +{ + SparseMat sm(m); + *this = sm; +} + +template inline +SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const SparseMat_<_Tp>& m) +{ + if( this != &m ) + { + if( m.hdr ) CV_XADD(&m.hdr->refcount, 1); + release(); + flags = m.flags; + hdr = m.hdr; + } + return *this; +} + +template inline +SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const SparseMat& m) +{ + if( m.type() == traits::Type<_Tp>::value ) + return (*this = (const SparseMat_<_Tp>&)m); + m.convertTo(*this, traits::Type<_Tp>::value); + return *this; +} + +template inline +SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const Mat& m) +{ + return (*this = SparseMat(m)); +} + +template inline +SparseMat_<_Tp> SparseMat_<_Tp>::clone() const +{ + SparseMat_<_Tp> m; + this->copyTo(m); + return m; +} + +template inline +void SparseMat_<_Tp>::create(int _dims, const int* _sizes) +{ + SparseMat::create(_dims, _sizes, traits::Type<_Tp>::value); +} + +template inline +int SparseMat_<_Tp>::type() const +{ + return traits::Type<_Tp>::value; +} + +template inline +int SparseMat_<_Tp>::depth() const +{ + return traits::Depth<_Tp>::value; +} + +template inline +int SparseMat_<_Tp>::channels() const +{ + return DataType<_Tp>::channels; +} + +template inline +_Tp& SparseMat_<_Tp>::ref(int i0, size_t* hashval) +{ + return SparseMat::ref<_Tp>(i0, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(int i0, size_t* hashval) const +{ + return SparseMat::value<_Tp>(i0, hashval); +} + +template inline +_Tp& SparseMat_<_Tp>::ref(int i0, int i1, size_t* hashval) +{ + return SparseMat::ref<_Tp>(i0, i1, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(int i0, int i1, size_t* hashval) const +{ + return SparseMat::value<_Tp>(i0, i1, hashval); +} + +template inline +_Tp& SparseMat_<_Tp>::ref(int i0, int i1, int i2, size_t* hashval) +{ + return SparseMat::ref<_Tp>(i0, i1, i2, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(int i0, int i1, int i2, size_t* hashval) const +{ + return SparseMat::value<_Tp>(i0, i1, i2, hashval); +} + +template inline +_Tp& SparseMat_<_Tp>::ref(const int* idx, size_t* hashval) +{ + return SparseMat::ref<_Tp>(idx, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(const int* idx, size_t* hashval) const +{ + return SparseMat::value<_Tp>(idx, hashval); +} + +template inline +SparseMatIterator_<_Tp> SparseMat_<_Tp>::begin() +{ + return SparseMatIterator_<_Tp>(this); +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::begin() const +{ + return SparseMatConstIterator_<_Tp>(this); +} + +template inline +SparseMatIterator_<_Tp> SparseMat_<_Tp>::end() +{ + SparseMatIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::end() const +{ + SparseMatConstIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + + + +////////////////////////// MatConstIterator ///////////////////////// + +inline +MatConstIterator::MatConstIterator() + : m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0) +{} + +inline +MatConstIterator::MatConstIterator(const Mat* _m) + : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) +{ + if( m && m->isContinuous() ) + { + CV_Assert(!m->empty()); + sliceStart = m->ptr(); + sliceEnd = sliceStart + m->total()*elemSize; + } + seek((const int*)0); +} + +inline +MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col) + : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) +{ + CV_Assert(m && m->dims <= 2); + if( m->isContinuous() ) + { + CV_Assert(!m->empty()); + sliceStart = m->ptr(); + sliceEnd = sliceStart + m->total()*elemSize; + } + int idx[] = {_row, _col}; + seek(idx); +} + +inline +MatConstIterator::MatConstIterator(const Mat* _m, Point _pt) + : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) +{ + CV_Assert(m && m->dims <= 2); + if( m->isContinuous() ) + { + CV_Assert(!m->empty()); + sliceStart = m->ptr(); + sliceEnd = sliceStart + m->total()*elemSize; + } + int idx[] = {_pt.y, _pt.x}; + seek(idx); +} + +inline +MatConstIterator::MatConstIterator(const MatConstIterator& it) + : m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd) +{} + +inline +MatConstIterator& MatConstIterator::operator = (const MatConstIterator& it ) +{ + m = it.m; elemSize = it.elemSize; ptr = it.ptr; + sliceStart = it.sliceStart; sliceEnd = it.sliceEnd; + return *this; +} + +inline +const uchar* MatConstIterator::operator *() const +{ + return ptr; +} + +inline MatConstIterator& MatConstIterator::operator += (ptrdiff_t ofs) +{ + if( !m || ofs == 0 ) + return *this; + ptrdiff_t ofsb = ofs*elemSize; + ptr += ofsb; + if( ptr < sliceStart || sliceEnd <= ptr ) + { + ptr -= ofsb; + seek(ofs, true); + } + return *this; +} + +inline +MatConstIterator& MatConstIterator::operator -= (ptrdiff_t ofs) +{ + return (*this += -ofs); +} + +inline +MatConstIterator& MatConstIterator::operator --() +{ + if( m && (ptr -= elemSize) < sliceStart ) + { + ptr += elemSize; + seek(-1, true); + } + return *this; +} + +inline +MatConstIterator MatConstIterator::operator --(int) +{ + MatConstIterator b = *this; + *this += -1; + return b; +} + +inline +MatConstIterator& MatConstIterator::operator ++() +{ + if( m && (ptr += elemSize) >= sliceEnd ) + { + ptr -= elemSize; + seek(1, true); + } + return *this; +} + +inline MatConstIterator MatConstIterator::operator ++(int) +{ + MatConstIterator b = *this; + *this += 1; + return b; +} + + +static inline +bool operator == (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.m == b.m && a.ptr == b.ptr; +} + +static inline +bool operator != (const MatConstIterator& a, const MatConstIterator& b) +{ + return !(a == b); +} + +static inline +bool operator < (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr < b.ptr; +} + +static inline +bool operator > (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr > b.ptr; +} + +static inline +bool operator <= (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr <= b.ptr; +} + +static inline +bool operator >= (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr >= b.ptr; +} + +static inline +ptrdiff_t operator - (const MatConstIterator& b, const MatConstIterator& a) +{ + if( a.m != b.m ) + return ((size_t)(-1) >> 1); + if( a.sliceEnd == b.sliceEnd ) + return (b.ptr - a.ptr)/static_cast(b.elemSize); + + return b.lpos() - a.lpos(); +} + +static inline +MatConstIterator operator + (const MatConstIterator& a, ptrdiff_t ofs) +{ + MatConstIterator b = a; + return b += ofs; +} + +static inline +MatConstIterator operator + (ptrdiff_t ofs, const MatConstIterator& a) +{ + MatConstIterator b = a; + return b += ofs; +} + +static inline +MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t ofs) +{ + MatConstIterator b = a; + return b += -ofs; +} + + +inline +const uchar* MatConstIterator::operator [](ptrdiff_t i) const +{ + return *(*this + i); +} + + + +///////////////////////// MatConstIterator_ ///////////////////////// + +template inline +MatConstIterator_<_Tp>::MatConstIterator_() +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m) + : MatConstIterator(_m) +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col) + : MatConstIterator(_m, _row, _col) +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m, Point _pt) + : MatConstIterator(_m, _pt) +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const MatConstIterator_& it) + : MatConstIterator(it) +{} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator = (const MatConstIterator_& it ) +{ + MatConstIterator::operator = (it); + return *this; +} + +template inline +const _Tp& MatConstIterator_<_Tp>::operator *() const +{ + return *(_Tp*)(this->ptr); +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator += (ptrdiff_t ofs) +{ + MatConstIterator::operator += (ofs); + return *this; +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator -= (ptrdiff_t ofs) +{ + return (*this += -ofs); +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator --() +{ + MatConstIterator::operator --(); + return *this; +} + +template inline +MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator --(int) +{ + MatConstIterator_ b = *this; + MatConstIterator::operator --(); + return b; +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator ++() +{ + MatConstIterator::operator ++(); + return *this; +} + +template inline +MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator ++(int) +{ + MatConstIterator_ b = *this; + MatConstIterator::operator ++(); + return b; +} + + +template inline +Point MatConstIterator_<_Tp>::pos() const +{ + if( !m ) + return Point(); + CV_DbgAssert( m->dims <= 2 ); + if( m->isContinuous() ) + { + ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m->data; + int y = (int)(ofs / m->cols); + int x = (int)(ofs - (ptrdiff_t)y * m->cols); + return Point(x, y); + } + else + { + ptrdiff_t ofs = (uchar*)ptr - m->data; + int y = (int)(ofs / m->step); + int x = (int)((ofs - y * m->step)/sizeof(_Tp)); + return Point(x, y); + } +} + + +template static inline +bool operator == (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) +{ + return a.m == b.m && a.ptr == b.ptr; +} + +template static inline +bool operator != (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) +{ + return a.m != b.m || a.ptr != b.ptr; +} + +template static inline +MatConstIterator_<_Tp> operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatConstIterator_<_Tp>&)t; +} + +template static inline +MatConstIterator_<_Tp> operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatConstIterator_<_Tp>&)t; +} + +template static inline +MatConstIterator_<_Tp> operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a - ofs; + return (MatConstIterator_<_Tp>&)t; +} + +template inline +const _Tp& MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const +{ + return *(_Tp*)MatConstIterator::operator [](i); +} + + + +//////////////////////////// MatIterator_ /////////////////////////// + +template inline +MatIterator_<_Tp>::MatIterator_() + : MatConstIterator_<_Tp>() +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m) + : MatConstIterator_<_Tp>(_m) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, int _row, int _col) + : MatConstIterator_<_Tp>(_m, _row, _col) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, Point _pt) + : MatConstIterator_<_Tp>(_m, _pt) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, const int* _idx) + : MatConstIterator_<_Tp>(_m, _idx) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(const MatIterator_& it) + : MatConstIterator_<_Tp>(it) +{} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator = (const MatIterator_<_Tp>& it ) +{ + MatConstIterator::operator = (it); + return *this; +} + +template inline +_Tp& MatIterator_<_Tp>::operator *() const +{ + return *(_Tp*)(this->ptr); +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator += (ptrdiff_t ofs) +{ + MatConstIterator::operator += (ofs); + return *this; +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator -= (ptrdiff_t ofs) +{ + MatConstIterator::operator += (-ofs); + return *this; +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator --() +{ + MatConstIterator::operator --(); + return *this; +} + +template inline +MatIterator_<_Tp> MatIterator_<_Tp>::operator --(int) +{ + MatIterator_ b = *this; + MatConstIterator::operator --(); + return b; +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator ++() +{ + MatConstIterator::operator ++(); + return *this; +} + +template inline +MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(int) +{ + MatIterator_ b = *this; + MatConstIterator::operator ++(); + return b; +} + +template inline +_Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const +{ + return *(*this + i); +} + + +template static inline +bool operator == (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) +{ + return a.m == b.m && a.ptr == b.ptr; +} + +template static inline +bool operator != (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) +{ + return a.m != b.m || a.ptr != b.ptr; +} + +template static inline +MatIterator_<_Tp> operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatIterator_<_Tp>&)t; +} + +template static inline +MatIterator_<_Tp> operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatIterator_<_Tp>&)t; +} + +template static inline +MatIterator_<_Tp> operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a - ofs; + return (MatIterator_<_Tp>&)t; +} + + + +/////////////////////// SparseMatConstIterator ////////////////////// + +inline +SparseMatConstIterator::SparseMatConstIterator() + : m(0), hashidx(0), ptr(0) +{} + +inline +SparseMatConstIterator::SparseMatConstIterator(const SparseMatConstIterator& it) + : m(it.m), hashidx(it.hashidx), ptr(it.ptr) +{} + +inline SparseMatConstIterator& SparseMatConstIterator::operator = (const SparseMatConstIterator& it) +{ + if( this != &it ) + { + m = it.m; + hashidx = it.hashidx; + ptr = it.ptr; + } + return *this; +} + +template inline +const _Tp& SparseMatConstIterator::value() const +{ + return *(const _Tp*)ptr; +} + +inline +const SparseMat::Node* SparseMatConstIterator::node() const +{ + return (ptr && m && m->hdr) ? (const SparseMat::Node*)(const void*)(ptr - m->hdr->valueOffset) : 0; +} + +inline +SparseMatConstIterator SparseMatConstIterator::operator ++(int) +{ + SparseMatConstIterator it = *this; + ++*this; + return it; +} + +inline +void SparseMatConstIterator::seekEnd() +{ + if( m && m->hdr ) + { + hashidx = m->hdr->hashtab.size(); + ptr = 0; + } +} + + +static inline +bool operator == (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) +{ + return it1.m == it2.m && it1.ptr == it2.ptr; +} + +static inline +bool operator != (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) +{ + return !(it1 == it2); +} + + + +///////////////////////// SparseMatIterator ///////////////////////// + +inline +SparseMatIterator::SparseMatIterator() +{} + +inline +SparseMatIterator::SparseMatIterator(SparseMat* _m) + : SparseMatConstIterator(_m) +{} + +inline +SparseMatIterator::SparseMatIterator(const SparseMatIterator& it) + : SparseMatConstIterator(it) +{} + +inline +SparseMatIterator& SparseMatIterator::operator = (const SparseMatIterator& it) +{ + (SparseMatConstIterator&)*this = it; + return *this; +} + +template inline +_Tp& SparseMatIterator::value() const +{ + return *(_Tp*)ptr; +} + +inline +SparseMat::Node* SparseMatIterator::node() const +{ + return (SparseMat::Node*)SparseMatConstIterator::node(); +} + +inline +SparseMatIterator& SparseMatIterator::operator ++() +{ + SparseMatConstIterator::operator ++(); + return *this; +} + +inline +SparseMatIterator SparseMatIterator::operator ++(int) +{ + SparseMatIterator it = *this; + ++*this; + return it; +} + + + +////////////////////// SparseMatConstIterator_ ////////////////////// + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_() +{} + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat_<_Tp>* _m) + : SparseMatConstIterator(_m) +{} + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat* _m) + : SparseMatConstIterator(_m) +{ + CV_Assert( _m->type() == traits::Type<_Tp>::value ); +} + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMatConstIterator_<_Tp>& it) + : SparseMatConstIterator(it) +{} + +template inline +SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator = (const SparseMatConstIterator_<_Tp>& it) +{ + return reinterpret_cast&> + (*reinterpret_cast(this) = + reinterpret_cast(it)); +} + +template inline +const _Tp& SparseMatConstIterator_<_Tp>::operator *() const +{ + return *(const _Tp*)this->ptr; +} + +template inline +SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator ++() +{ + SparseMatConstIterator::operator ++(); + return *this; +} + +template inline +SparseMatConstIterator_<_Tp> SparseMatConstIterator_<_Tp>::operator ++(int) +{ + SparseMatConstIterator_<_Tp> it = *this; + SparseMatConstIterator::operator ++(); + return it; +} + + + +///////////////////////// SparseMatIterator_ //////////////////////// + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_() +{} + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m) + : SparseMatConstIterator_<_Tp>(_m) +{} + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat* _m) + : SparseMatConstIterator_<_Tp>(_m) +{} + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_(const SparseMatIterator_<_Tp>& it) + : SparseMatConstIterator_<_Tp>(it) +{} + +template inline +SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator = (const SparseMatIterator_<_Tp>& it) +{ + return reinterpret_cast&> + (*reinterpret_cast(this) = + reinterpret_cast(it)); +} + +template inline +_Tp& SparseMatIterator_<_Tp>::operator *() const +{ + return *(_Tp*)this->ptr; +} + +template inline +SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator ++() +{ + SparseMatConstIterator::operator ++(); + return *this; +} + +template inline +SparseMatIterator_<_Tp> SparseMatIterator_<_Tp>::operator ++(int) +{ + SparseMatIterator_<_Tp> it = *this; + SparseMatConstIterator::operator ++(); + return it; +} + + + +//////////////////////// MatCommaInitializer_ /////////////////////// + +template inline +MatCommaInitializer_<_Tp>::MatCommaInitializer_(Mat_<_Tp>* _m) + : it(_m) +{} + +template template inline +MatCommaInitializer_<_Tp>& MatCommaInitializer_<_Tp>::operator , (T2 v) +{ + CV_DbgAssert( this->it < ((const Mat_<_Tp>*)this->it.m)->end() ); + *this->it = _Tp(v); + ++this->it; + return *this; +} + +template inline +MatCommaInitializer_<_Tp>::operator Mat_<_Tp>() const +{ + CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() ); + return Mat_<_Tp>(*this->it.m); +} + + +template static inline +MatCommaInitializer_<_Tp> operator << (const Mat_<_Tp>& m, T2 val) +{ + MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m); + return (commaInitializer, val); +} + + + +///////////////////////// Matrix Expressions //////////////////////// + +inline +Mat& Mat::operator = (const MatExpr& e) +{ + e.op->assign(e, *this); + return *this; +} + +template inline +Mat_<_Tp>::Mat_(const MatExpr& e) +{ + e.op->assign(e, *this, traits::Type<_Tp>::value); +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) +{ + e.op->assign(e, *this, traits::Type<_Tp>::value); + return *this; +} + +template inline +MatExpr Mat_<_Tp>::zeros(int rows, int cols) +{ + return Mat::zeros(rows, cols, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::zeros(Size sz) +{ + return Mat::zeros(sz, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::ones(int rows, int cols) +{ + return Mat::ones(rows, cols, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::ones(Size sz) +{ + return Mat::ones(sz, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::eye(int rows, int cols) +{ + return Mat::eye(rows, cols, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::eye(Size sz) +{ + return Mat::eye(sz, traits::Type<_Tp>::value); +} + +inline +MatExpr::MatExpr() + : op(0), flags(0), a(Mat()), b(Mat()), c(Mat()), alpha(0), beta(0), s() +{} + +inline +MatExpr::MatExpr(const MatOp* _op, int _flags, const Mat& _a, const Mat& _b, + const Mat& _c, double _alpha, double _beta, const Scalar& _s) + : op(_op), flags(_flags), a(_a), b(_b), c(_c), alpha(_alpha), beta(_beta), s(_s) +{} + +inline +MatExpr::operator Mat() const +{ + Mat m; + op->assign(*this, m); + return m; +} + +template inline +MatExpr::operator Mat_<_Tp>() const +{ + Mat_<_Tp> m; + op->assign(*this, m, traits::Type<_Tp>::value); + return m; +} + + +template static inline +MatExpr min(const Mat_<_Tp>& a, const Mat_<_Tp>& b) +{ + return cv::min((const Mat&)a, (const Mat&)b); +} + +template static inline +MatExpr min(const Mat_<_Tp>& a, double s) +{ + return cv::min((const Mat&)a, s); +} + +template static inline +MatExpr min(double s, const Mat_<_Tp>& a) +{ + return cv::min((const Mat&)a, s); +} + +template static inline +MatExpr max(const Mat_<_Tp>& a, const Mat_<_Tp>& b) +{ + return cv::max((const Mat&)a, (const Mat&)b); +} + +template static inline +MatExpr max(const Mat_<_Tp>& a, double s) +{ + return cv::max((const Mat&)a, s); +} + +template static inline +MatExpr max(double s, const Mat_<_Tp>& a) +{ + return cv::max((const Mat&)a, s); +} + +template static inline +MatExpr abs(const Mat_<_Tp>& m) +{ + return cv::abs((const Mat&)m); +} + + +static inline +Mat& operator += (Mat& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, a); + return a; +} + +static inline +const Mat& operator += (const Mat& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator += (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, (Mat&)a); + return a; +} + +static inline +Mat& operator -= (Mat& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, a); + return a; +} + +static inline +const Mat& operator -= (const Mat& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator -= (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, (Mat&)a); + return a; +} + +static inline +Mat& operator *= (Mat& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, a); + return a; +} + +static inline +const Mat& operator *= (const Mat& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator *= (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, (Mat&)a); + return a; +} + +static inline +Mat& operator /= (Mat& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, a); + return a; +} + +static inline +const Mat& operator /= (const Mat& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator /= (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, (Mat&)a); + return a; +} + + +//////////////////////////////// UMat //////////////////////////////// + +template inline +UMat::UMat(const std::vector<_Tp>& vec, bool copyData) +: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), +cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) +{ + if(vec.empty()) + return; + if( !copyData ) + { + // !!!TODO!!! + CV_Error(Error::StsNotImplemented, ""); + } + else + Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); +} + +inline +UMat UMat::row(int y) const +{ + return UMat(*this, Range(y, y + 1), Range::all()); +} + +inline +UMat UMat::col(int x) const +{ + return UMat(*this, Range::all(), Range(x, x + 1)); +} + +inline +UMat UMat::rowRange(int startrow, int endrow) const +{ + return UMat(*this, Range(startrow, endrow), Range::all()); +} + +inline +UMat UMat::rowRange(const Range& r) const +{ + return UMat(*this, r, Range::all()); +} + +inline +UMat UMat::colRange(int startcol, int endcol) const +{ + return UMat(*this, Range::all(), Range(startcol, endcol)); +} + +inline +UMat UMat::colRange(const Range& r) const +{ + return UMat(*this, Range::all(), r); +} + +inline +UMat UMat::operator()( Range _rowRange, Range _colRange ) const +{ + return UMat(*this, _rowRange, _colRange); +} + +inline +UMat UMat::operator()( const Rect& roi ) const +{ + return UMat(*this, roi); +} + +inline +UMat UMat::operator()(const Range* ranges) const +{ + return UMat(*this, ranges); +} + +inline +UMat UMat::operator()(const std::vector& ranges) const +{ + return UMat(*this, ranges); +} + +inline +bool UMat::isContinuous() const +{ + return (flags & CONTINUOUS_FLAG) != 0; +} + +inline +bool UMat::isSubmatrix() const +{ + return (flags & SUBMATRIX_FLAG) != 0; +} + +inline +size_t UMat::elemSize() const +{ + size_t res = dims > 0 ? step.p[dims - 1] : 0; + CV_DbgAssert(res != 0); + return res; +} + +inline +size_t UMat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int UMat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int UMat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int UMat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +size_t UMat::step1(int i) const +{ + return step.p[i] / elemSize1(); +} + + +inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; } +inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; } +inline bool UMatData::deviceMemMapped() const { return (flags & DEVICE_MEM_MAPPED) != 0; } +inline bool UMatData::copyOnMap() const { return (flags & COPY_ON_MAP) != 0; } +inline bool UMatData::tempUMat() const { return (flags & TEMP_UMAT) != 0; } +inline bool UMatData::tempCopiedUMat() const { return (flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; } + +inline void UMatData::markDeviceMemMapped(bool flag) +{ + if(flag) + flags |= DEVICE_MEM_MAPPED; + else + flags &= ~DEVICE_MEM_MAPPED; +} + +inline void UMatData::markHostCopyObsolete(bool flag) +{ + if(flag) + flags |= HOST_COPY_OBSOLETE; + else + flags &= ~HOST_COPY_OBSOLETE; +} +inline void UMatData::markDeviceCopyObsolete(bool flag) +{ + if(flag) + flags |= DEVICE_COPY_OBSOLETE; + else + flags &= ~DEVICE_COPY_OBSOLETE; +} + +//! @endcond + +static inline +void swap(MatExpr& a, MatExpr& b) { a.swap(b); } + +} //cv + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#ifdef CV_DISABLE_CLANG_ENUM_WARNINGS +#undef CV_DISABLE_CLANG_ENUM_WARNINGS +#pragma clang diagnostic pop +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/matx.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/matx.hpp new file mode 100644 index 0000000..3c92e3a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/matx.hpp @@ -0,0 +1,1508 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_MATX_HPP +#define OPENCV_CORE_MATX_HPP + +#ifndef __cplusplus +# error matx.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/base.hpp" +#include "opencv2/core/traits.hpp" +#include "opencv2/core/saturate.hpp" + +#include + +namespace cv +{ + +//! @addtogroup core_basic +//! @{ + +////////////////////////////// Small Matrix /////////////////////////// + +//! @cond IGNORED +// FIXIT Remove this (especially CV_EXPORTS modifier) +struct CV_EXPORTS Matx_AddOp { Matx_AddOp() {} Matx_AddOp(const Matx_AddOp&) {} }; +struct CV_EXPORTS Matx_SubOp { Matx_SubOp() {} Matx_SubOp(const Matx_SubOp&) {} }; +struct CV_EXPORTS Matx_ScaleOp { Matx_ScaleOp() {} Matx_ScaleOp(const Matx_ScaleOp&) {} }; +struct CV_EXPORTS Matx_MulOp { Matx_MulOp() {} Matx_MulOp(const Matx_MulOp&) {} }; +struct CV_EXPORTS Matx_DivOp { Matx_DivOp() {} Matx_DivOp(const Matx_DivOp&) {} }; +struct CV_EXPORTS Matx_MatMulOp { Matx_MatMulOp() {} Matx_MatMulOp(const Matx_MatMulOp&) {} }; +struct CV_EXPORTS Matx_TOp { Matx_TOp() {} Matx_TOp(const Matx_TOp&) {} }; +//! @endcond + +/** @brief Template class for small matrices whose type and size are known at compilation time + +If you need a more flexible type, use Mat . The elements of the matrix M are accessible using the +M(i,j) notation. Most of the common matrix operations (see also @ref MatrixExpressions ) are +available. To do an operation on Matx that is not implemented, you can easily convert the matrix to +Mat and backwards: +@code{.cpp} + Matx33f m(1, 2, 3, + 4, 5, 6, + 7, 8, 9); + cout << sum(Mat(m*m.t())) << endl; +@endcode +Except of the plain constructor which takes a list of elements, Matx can be initialized from a C-array: +@code{.cpp} + float values[] = { 1, 2, 3}; + Matx31f m(values); +@endcode +In case if C++11 features are available, std::initializer_list can be also used to initialize Matx: +@code{.cpp} + Matx31f m = { 1, 2, 3}; +@endcode + */ +template class Matx +{ +public: + enum { + rows = m, + cols = n, + channels = rows*cols, +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + depth = traits::Type<_Tp>::value, + type = CV_MAKETYPE(depth, channels), +#endif + shortdim = (m < n ? m : n) + }; + + typedef _Tp value_type; + typedef Matx<_Tp, m, n> mat_type; + typedef Matx<_Tp, shortdim, 1> diag_type; + + //! default constructor + Matx(); + + explicit Matx(_Tp v0); //!< 1x1 matrix + Matx(_Tp v0, _Tp v1); //!< 1x2 or 2x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2); //!< 1x3 or 3x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 1x4, 2x2 or 4x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 1x5 or 5x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 1x6, 2x3, 3x2 or 6x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 1x7 or 7x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 1x8, 2x4, 4x2 or 8x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 1x9, 3x3 or 9x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 1x10, 2x5 or 5x2 or 10x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, + _Tp v4, _Tp v5, _Tp v6, _Tp v7, + _Tp v8, _Tp v9, _Tp v10, _Tp v11); //!< 1x12, 2x6, 3x4, 4x3, 6x2 or 12x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, + _Tp v4, _Tp v5, _Tp v6, _Tp v7, + _Tp v8, _Tp v9, _Tp v10, _Tp v11, + _Tp v12, _Tp v13); //!< 1x14, 2x7, 7x2 or 14x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, + _Tp v4, _Tp v5, _Tp v6, _Tp v7, + _Tp v8, _Tp v9, _Tp v10, _Tp v11, + _Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix + explicit Matx(const _Tp* vals); //!< initialize from a plain array + + Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list + + CV_NODISCARD_STD static Matx all(_Tp alpha); + CV_NODISCARD_STD static Matx zeros(); + CV_NODISCARD_STD static Matx ones(); + CV_NODISCARD_STD static Matx eye(); + CV_NODISCARD_STD static Matx diag(const diag_type& d); + /** @brief Generates uniformly distributed random numbers + @param a Range boundary. + @param b The other range boundary (boundaries don't have to be ordered, the lower boundary is inclusive, + the upper one is exclusive). + */ + CV_NODISCARD_STD static Matx randu(_Tp a, _Tp b); + /** @brief Generates normally distributed random numbers + @param a Mean value. + @param b Standard deviation. + */ + CV_NODISCARD_STD static Matx randn(_Tp a, _Tp b); + + //! dot product computed with the default precision + _Tp dot(const Matx<_Tp, m, n>& v) const; + + //! dot product computed in double-precision arithmetics + double ddot(const Matx<_Tp, m, n>& v) const; + + //! conversion to another data type + template operator Matx() const; + + //! change the matrix shape + template Matx<_Tp, m1, n1> reshape() const; + + //! extract part of the matrix + template Matx<_Tp, m1, n1> get_minor(int base_row, int base_col) const; + + //! extract the matrix row + Matx<_Tp, 1, n> row(int i) const; + + //! extract the matrix column + Matx<_Tp, m, 1> col(int i) const; + + //! extract the matrix diagonal + diag_type diag() const; + + //! transpose the matrix + Matx<_Tp, n, m> t() const; + + //! invert the matrix + Matx<_Tp, n, m> inv(int method=DECOMP_LU, bool *p_is_ok = NULL) const; + + //! solve linear system + template Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const; + Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const; + + //! multiply two matrices element-wise + Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const; + + //! divide two matrices element-wise + Matx<_Tp, m, n> div(const Matx<_Tp, m, n>& a) const; + + //! element access + const _Tp& operator ()(int row, int col) const; + _Tp& operator ()(int row, int col); + + //! 1D element access + const _Tp& operator ()(int i) const; + _Tp& operator ()(int i); + + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp); + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp); + template Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp); + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp); + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp); + template Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp); + Matx(const Matx<_Tp, n, m>& a, Matx_TOp); + + _Tp val[m*n]; //< matrix elements +}; + +typedef Matx Matx12f; +typedef Matx Matx12d; +typedef Matx Matx13f; +typedef Matx Matx13d; +typedef Matx Matx14f; +typedef Matx Matx14d; +typedef Matx Matx16f; +typedef Matx Matx16d; + +typedef Matx Matx21f; +typedef Matx Matx21d; +typedef Matx Matx31f; +typedef Matx Matx31d; +typedef Matx Matx41f; +typedef Matx Matx41d; +typedef Matx Matx61f; +typedef Matx Matx61d; + +typedef Matx Matx22f; +typedef Matx Matx22d; +typedef Matx Matx23f; +typedef Matx Matx23d; +typedef Matx Matx32f; +typedef Matx Matx32d; + +typedef Matx Matx33f; +typedef Matx Matx33d; + +typedef Matx Matx34f; +typedef Matx Matx34d; +typedef Matx Matx43f; +typedef Matx Matx43d; + +typedef Matx Matx44f; +typedef Matx Matx44d; +typedef Matx Matx66f; +typedef Matx Matx66d; + +/*! + traits +*/ +template class DataType< Matx<_Tp, m, n> > +{ +public: + typedef Matx<_Tp, m, n> value_type; + typedef Matx::work_type, m, n> work_type; + typedef _Tp channel_type; + typedef value_type vec_type; + + enum { generic_type = 0, + channels = m * n, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; +}; + +namespace traits { +template +struct Depth< Matx<_Tp, m, n> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Matx<_Tp, m, n> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, n*m) }; }; +} // namespace + + +/** @brief Comma-separated Matrix Initializer +*/ +template class MatxCommaInitializer +{ +public: + MatxCommaInitializer(Matx<_Tp, m, n>* _mtx); + template MatxCommaInitializer<_Tp, m, n>& operator , (T2 val); + Matx<_Tp, m, n> operator *() const; + + Matx<_Tp, m, n>* dst; + int idx; +}; + +/* + Utility methods +*/ +template static double determinant(const Matx<_Tp, m, m>& a); +template static double trace(const Matx<_Tp, m, n>& a); +template static double norm(const Matx<_Tp, m, n>& M); +template static double norm(const Matx<_Tp, m, n>& M, int normType); + + + +/////////////////////// Vec (used as element of multi-channel images ///////////////////// + +/** @brief Template class for short numerical vectors, a partial case of Matx + +This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) on which you +can perform basic arithmetical operations, access individual elements using [] operator etc. The +vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., which +elements are dynamically allocated in the heap. + +The template takes 2 parameters: +@tparam _Tp element type +@tparam cn the number of elements + +In addition to the universal notation like Vec, you can use shorter aliases +for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec. + +It is possible to convert Vec\ to/from Point_, Vec\ to/from Point3_ , and Vec\ +to CvScalar or Scalar_. Use operator[] to access the elements of Vec. + +All the expected vector operations are also implemented: +- v1 = v2 + v3 +- v1 = v2 - v3 +- v1 = v2 \* scale +- v1 = scale \* v2 +- v1 = -v2 +- v1 += v2 and other augmenting operations +- v1 == v2, v1 != v2 +- norm(v1) (euclidean norm) +The Vec class is commonly used to describe pixel types of multi-channel arrays. See Mat for details. +*/ +template class Vec : public Matx<_Tp, cn, 1> +{ +public: + typedef _Tp value_type; + enum { + channels = cn, +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + depth = Matx<_Tp, cn, 1>::depth, + type = CV_MAKETYPE(depth, channels), +#endif + _dummy_enum_finalizer = 0 + }; + + //! default constructor + Vec(); + + Vec(_Tp v0); //!< 1-element vector constructor + Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor + explicit Vec(const _Tp* values); + + Vec(std::initializer_list<_Tp>); + + Vec(const Vec<_Tp, cn>& v); + + static Vec all(_Tp alpha); + + //! per-element multiplication + Vec mul(const Vec<_Tp, cn>& v) const; + + //! conjugation (makes sense for complex numbers and quaternions) + Vec conj() const; + + /*! + cross product of the two 3D vectors. + + For other dimensionalities the exception is raised + */ + Vec cross(const Vec& v) const; + //! conversion to another data type + template operator Vec() const; + + /*! element access */ + const _Tp& operator [](int i) const; + _Tp& operator[](int i); + const _Tp& operator ()(int i) const; + _Tp& operator ()(int i); + +#ifdef CV_CXX11 + Vec<_Tp, cn>& operator=(const Vec<_Tp, cn>& rhs) = default; +#endif + + Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp); + Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp); + template Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp); +}; + +/** @name Shorter aliases for the most popular specializations of Vec + @{ +*/ +typedef Vec Vec2b; +typedef Vec Vec3b; +typedef Vec Vec4b; + +typedef Vec Vec2s; +typedef Vec Vec3s; +typedef Vec Vec4s; + +typedef Vec Vec2w; +typedef Vec Vec3w; +typedef Vec Vec4w; + +typedef Vec Vec2i; +typedef Vec Vec3i; +typedef Vec Vec4i; +typedef Vec Vec6i; +typedef Vec Vec8i; + +typedef Vec Vec2f; +typedef Vec Vec3f; +typedef Vec Vec4f; +typedef Vec Vec6f; + +typedef Vec Vec2d; +typedef Vec Vec3d; +typedef Vec Vec4d; +typedef Vec Vec6d; +/** @} */ + +/*! + traits +*/ +template class DataType< Vec<_Tp, cn> > +{ +public: + typedef Vec<_Tp, cn> value_type; + typedef Vec::work_type, cn> work_type; + typedef _Tp channel_type; + typedef value_type vec_type; + + enum { generic_type = 0, + channels = cn, + fmt = DataType::fmt + ((channels - 1) << 8), +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + depth = DataType::depth, + type = CV_MAKETYPE(depth, channels), +#endif + _dummy_enum_finalizer = 0 + }; +}; + +namespace traits { +template +struct Depth< Vec<_Tp, cn> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Vec<_Tp, cn> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, cn) }; }; +} // namespace + + +/** @brief Comma-separated Vec Initializer +*/ +template class VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1> +{ +public: + VecCommaInitializer(Vec<_Tp, m>* _vec); + template VecCommaInitializer<_Tp, m>& operator , (T2 val); + Vec<_Tp, m> operator *() const; +}; + +template static Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v); + +//! @} core_basic + +//! @cond IGNORED + +///////////////////////////////////// helper classes ///////////////////////////////////// +namespace internal +{ + +template struct Matx_DetOp +{ + double operator ()(const Matx<_Tp, m, m>& a) const + { + Matx<_Tp, m, m> temp = a; + double p = LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0); + if( p == 0 ) + return p; + for( int i = 0; i < m; i++ ) + p *= temp(i, i); + return p; + } +}; + +template struct Matx_DetOp<_Tp, 1> +{ + double operator ()(const Matx<_Tp, 1, 1>& a) const + { + return a(0,0); + } +}; + +template struct Matx_DetOp<_Tp, 2> +{ + double operator ()(const Matx<_Tp, 2, 2>& a) const + { + return a(0,0)*a(1,1) - a(0,1)*a(1,0); + } +}; + +template struct Matx_DetOp<_Tp, 3> +{ + double operator ()(const Matx<_Tp, 3, 3>& a) const + { + return a(0,0)*(a(1,1)*a(2,2) - a(2,1)*a(1,2)) - + a(0,1)*(a(1,0)*a(2,2) - a(2,0)*a(1,2)) + + a(0,2)*(a(1,0)*a(2,1) - a(2,0)*a(1,1)); + } +}; + +template Vec<_Tp, 2> inline conjugate(const Vec<_Tp, 2>& v) +{ + return Vec<_Tp, 2>(v[0], -v[1]); +} + +template Vec<_Tp, 4> inline conjugate(const Vec<_Tp, 4>& v) +{ + return Vec<_Tp, 4>(v[0], -v[1], -v[2], -v[3]); +} + +} // internal + + + +////////////////////////////////// Matx Implementation /////////////////////////////////// + +template inline +Matx<_Tp, m, n>::Matx() +{ + for(int i = 0; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0) +{ + val[0] = v0; + for(int i = 1; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1) +{ + CV_StaticAssert(channels >= 2, "Matx should have at least 2 elements."); + val[0] = v0; val[1] = v1; + for(int i = 2; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2) +{ + CV_StaticAssert(channels >= 3, "Matx should have at least 3 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; + for(int i = 3; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3) +{ + CV_StaticAssert(channels >= 4, "Matx should have at least 4 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + for(int i = 4; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4) +{ + CV_StaticAssert(channels >= 5, "Matx should have at least 5 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; val[4] = v4; + for(int i = 5; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5) +{ + CV_StaticAssert(channels >= 6, "Matx should have at least 6 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; + for(int i = 6; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6) +{ + CV_StaticAssert(channels >= 7, "Matx should have at least 7 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; + for(int i = 7; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7) +{ + CV_StaticAssert(channels >= 8, "Matx should have at least 8 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + for(int i = 8; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8) +{ + CV_StaticAssert(channels >= 9, "Matx should have at least 9 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; + for(int i = 9; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9) +{ + CV_StaticAssert(channels >= 10, "Matx should have at least 10 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; + for(int i = 10; i < channels; i++) val[i] = _Tp(0); +} + + +template inline +Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11) +{ + CV_StaticAssert(channels >= 12, "Matx should have at least 12 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; + for(int i = 12; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13) +{ + CV_StaticAssert(channels >= 14, "Matx should have at least 14 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; + val[12] = v12; val[13] = v13; + for (int i = 14; i < channels; i++) val[i] = _Tp(0); +} + + +template inline +Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13, _Tp v14, _Tp v15) +{ + CV_StaticAssert(channels >= 16, "Matx should have at least 16 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; + val[12] = v12; val[13] = v13; val[14] = v14; val[15] = v15; + for(int i = 16; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(const _Tp* values) +{ + for( int i = 0; i < channels; i++ ) val[i] = values[i]; +} + +template inline +Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list) +{ + CV_DbgAssert(list.size() == channels); + int i = 0; + for(const auto& elem : list) + { + val[i++] = elem; + } +} + +template inline +Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha) +{ + Matx<_Tp, m, n> M; + for( int i = 0; i < m*n; i++ ) M.val[i] = alpha; + return M; +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::zeros() +{ + return all(0); +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::ones() +{ + return all(1); +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::eye() +{ + Matx<_Tp,m,n> M; + for(int i = 0; i < shortdim; i++) + M(i,i) = 1; + return M; +} + +template inline +_Tp Matx<_Tp, m, n>::dot(const Matx<_Tp, m, n>& M) const +{ + _Tp s = 0; + for( int i = 0; i < channels; i++ ) s += val[i]*M.val[i]; + return s; +} + +template inline +double Matx<_Tp, m, n>::ddot(const Matx<_Tp, m, n>& M) const +{ + double s = 0; + for( int i = 0; i < channels; i++ ) s += (double)val[i]*M.val[i]; + return s; +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const typename Matx<_Tp,m,n>::diag_type& d) +{ + Matx<_Tp,m,n> M; + for(int i = 0; i < shortdim; i++) + M(i,i) = d(i, 0); + return M; +} + +template template +inline Matx<_Tp, m, n>::operator Matx() const +{ + Matx M; + for( int i = 0; i < m*n; i++ ) M.val[i] = saturate_cast(val[i]); + return M; +} + +template template inline +Matx<_Tp, m1, n1> Matx<_Tp, m, n>::reshape() const +{ + CV_StaticAssert(m1*n1 == m*n, "Input and destnarion matrices must have the same number of elements"); + return (const Matx<_Tp, m1, n1>&)*this; +} + +template +template inline +Matx<_Tp, m1, n1> Matx<_Tp, m, n>::get_minor(int base_row, int base_col) const +{ + CV_DbgAssert(0 <= base_row && base_row+m1 <= m && 0 <= base_col && base_col+n1 <= n); + Matx<_Tp, m1, n1> s; + for( int di = 0; di < m1; di++ ) + for( int dj = 0; dj < n1; dj++ ) + s(di, dj) = (*this)(base_row+di, base_col+dj); + return s; +} + +template inline +Matx<_Tp, 1, n> Matx<_Tp, m, n>::row(int i) const +{ + CV_DbgAssert((unsigned)i < (unsigned)m); + return Matx<_Tp, 1, n>(&val[i*n]); +} + +template inline +Matx<_Tp, m, 1> Matx<_Tp, m, n>::col(int j) const +{ + CV_DbgAssert((unsigned)j < (unsigned)n); + Matx<_Tp, m, 1> v; + for( int i = 0; i < m; i++ ) + v.val[i] = val[i*n + j]; + return v; +} + +template inline +typename Matx<_Tp, m, n>::diag_type Matx<_Tp, m, n>::diag() const +{ + diag_type d; + for( int i = 0; i < shortdim; i++ ) + d.val[i] = val[i*n + i]; + return d; +} + +template inline +const _Tp& Matx<_Tp, m, n>::operator()(int row_idx, int col_idx) const +{ + CV_DbgAssert( (unsigned)row_idx < (unsigned)m && (unsigned)col_idx < (unsigned)n ); + return this->val[row_idx*n + col_idx]; +} + +template inline +_Tp& Matx<_Tp, m, n>::operator ()(int row_idx, int col_idx) +{ + CV_DbgAssert( (unsigned)row_idx < (unsigned)m && (unsigned)col_idx < (unsigned)n ); + return val[row_idx*n + col_idx]; +} + +template inline +const _Tp& Matx<_Tp, m, n>::operator ()(int i) const +{ + CV_StaticAssert(m == 1 || n == 1, "Single index indexation requires matrix to be a column or a row"); + CV_DbgAssert( (unsigned)i < (unsigned)(m+n-1) ); + return val[i]; +} + +template inline +_Tp& Matx<_Tp, m, n>::operator ()(int i) +{ + CV_StaticAssert(m == 1 || n == 1, "Single index indexation requires matrix to be a column or a row"); + CV_DbgAssert( (unsigned)i < (unsigned)(m+n-1) ); + return val[i]; +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] + b.val[i]); +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] - b.val[i]); +} + +template template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] * alpha); +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] * b.val[i]); +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] / b.val[i]); +} + +template template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp) +{ + for( int i = 0; i < m; i++ ) + for( int j = 0; j < n; j++ ) + { + _Tp s = 0; + for( int k = 0; k < l; k++ ) + s += a(i, k) * b(k, j); + val[i*n + j] = s; + } +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, n, m>& a, Matx_TOp) +{ + for( int i = 0; i < m; i++ ) + for( int j = 0; j < n; j++ ) + val[i*n + j] = a(j, i); +} + +template inline +Matx<_Tp, m, n> Matx<_Tp, m, n>::mul(const Matx<_Tp, m, n>& a) const +{ + return Matx<_Tp, m, n>(*this, a, Matx_MulOp()); +} + +template inline +Matx<_Tp, m, n> Matx<_Tp, m, n>::div(const Matx<_Tp, m, n>& a) const +{ + return Matx<_Tp, m, n>(*this, a, Matx_DivOp()); +} + +template inline +Matx<_Tp, n, m> Matx<_Tp, m, n>::t() const +{ + return Matx<_Tp, n, m>(*this, Matx_TOp()); +} + +template inline +Vec<_Tp, n> Matx<_Tp, m, n>::solve(const Vec<_Tp, m>& rhs, int method) const +{ + Matx<_Tp, n, 1> x = solve((const Matx<_Tp, m, 1>&)(rhs), method); + return (Vec<_Tp, n>&)(x); +} + +template static inline +double determinant(const Matx<_Tp, m, m>& a) +{ + return cv::internal::Matx_DetOp<_Tp, m>()(a); +} + +template static inline +double trace(const Matx<_Tp, m, n>& a) +{ + _Tp s = 0; + for( int i = 0; i < std::min(m, n); i++ ) + s += a(i,i); + return s; +} + +template static inline +double norm(const Matx<_Tp, m, n>& M) +{ + return std::sqrt(normL2Sqr<_Tp, double>(M.val, m*n)); +} + +template static inline +double norm(const Matx<_Tp, m, n>& M, int normType) +{ + switch(normType) { + case NORM_INF: + return (double)normInf<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n); + case NORM_L1: + return (double)normL1<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n); + case NORM_L2SQR: + return (double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n); + default: + case NORM_L2: + return std::sqrt((double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n)); + } +} + + + +//////////////////////////////// matx comma initializer ////////////////////////////////// + +template static inline +MatxCommaInitializer<_Tp, m, n> operator << (const Matx<_Tp, m, n>& mtx, _T2 val) +{ + MatxCommaInitializer<_Tp, m, n> commaInitializer((Matx<_Tp, m, n>*)&mtx); + return (commaInitializer, val); +} + +template inline +MatxCommaInitializer<_Tp, m, n>::MatxCommaInitializer(Matx<_Tp, m, n>* _mtx) + : dst(_mtx), idx(0) +{} + +template template inline +MatxCommaInitializer<_Tp, m, n>& MatxCommaInitializer<_Tp, m, n>::operator , (_T2 value) +{ + CV_DbgAssert( idx < m*n ); + dst->val[idx++] = saturate_cast<_Tp>(value); + return *this; +} + +template inline +Matx<_Tp, m, n> MatxCommaInitializer<_Tp, m, n>::operator *() const +{ + CV_DbgAssert( idx == n*m ); + return *dst; +} + + + +/////////////////////////////////// Vec Implementation /////////////////////////////////// + +template inline +Vec<_Tp, cn>::Vec() {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0) + : Matx<_Tp, cn, 1>(v0) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1) + : Matx<_Tp, cn, 1>(v0, v1) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2) + : Matx<_Tp, cn, 1>(v0, v1, v2) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) {} + +template inline +Vec<_Tp, cn>::Vec(const _Tp* values) + : Matx<_Tp, cn, 1>(values) {} + +template inline +Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list) + : Matx<_Tp, cn, 1>(list) {} + +template inline +Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m) + : Matx<_Tp, cn, 1>(m.val) {} + +template inline +Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp op) + : Matx<_Tp, cn, 1>(a, b, op) {} + +template inline +Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp op) + : Matx<_Tp, cn, 1>(a, b, op) {} + +template template inline +Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp op) + : Matx<_Tp, cn, 1>(a, alpha, op) {} + +template inline +Vec<_Tp, cn> Vec<_Tp, cn>::all(_Tp alpha) +{ + Vec v; + for( int i = 0; i < cn; i++ ) v.val[i] = alpha; + return v; +} + +template inline +Vec<_Tp, cn> Vec<_Tp, cn>::mul(const Vec<_Tp, cn>& v) const +{ + Vec<_Tp, cn> w; + for( int i = 0; i < cn; i++ ) w.val[i] = saturate_cast<_Tp>(this->val[i]*v.val[i]); + return w; +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template inline +Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>&) const +{ + CV_StaticAssert(cn == 3, "for arbitrary-size vector there is no cross-product defined"); + return Vec<_Tp, cn>(); +} + +template<> inline +Vec Vec::cross(const Vec& v) const +{ + return Vec(this->val[1]*v.val[2] - this->val[2]*v.val[1], + this->val[2]*v.val[0] - this->val[0]*v.val[2], + this->val[0]*v.val[1] - this->val[1]*v.val[0]); +} + +template<> inline +Vec Vec::cross(const Vec& v) const +{ + return Vec(this->val[1]*v.val[2] - this->val[2]*v.val[1], + this->val[2]*v.val[0] - this->val[0]*v.val[2], + this->val[0]*v.val[1] - this->val[1]*v.val[0]); +} + +template template inline +Vec<_Tp, cn>::operator Vec() const +{ + Vec v; + for( int i = 0; i < cn; i++ ) v.val[i] = saturate_cast(this->val[i]); + return v; +} + +template inline +const _Tp& Vec<_Tp, cn>::operator [](int i) const +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +_Tp& Vec<_Tp, cn>::operator [](int i) +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +const _Tp& Vec<_Tp, cn>::operator ()(int i) const +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +_Tp& Vec<_Tp, cn>::operator ()(int i) +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v) +{ + double nv = norm(v); + return v * (nv ? 1./nv : 0.); +} + + + +//////////////////////////////// vec comma initializer ////////////////////////////////// + + +template static inline +VecCommaInitializer<_Tp, cn> operator << (const Vec<_Tp, cn>& vec, _T2 val) +{ + VecCommaInitializer<_Tp, cn> commaInitializer((Vec<_Tp, cn>*)&vec); + return (commaInitializer, val); +} + +template inline +VecCommaInitializer<_Tp, cn>::VecCommaInitializer(Vec<_Tp, cn>* _vec) + : MatxCommaInitializer<_Tp, cn, 1>(_vec) +{} + +template template inline +VecCommaInitializer<_Tp, cn>& VecCommaInitializer<_Tp, cn>::operator , (_T2 value) +{ + CV_DbgAssert( this->idx < cn ); + this->dst->val[this->idx++] = saturate_cast<_Tp>(value); + return *this; +} + +template inline +Vec<_Tp, cn> VecCommaInitializer<_Tp, cn>::operator *() const +{ + CV_DbgAssert( this->idx == cn ); + return *this->dst; +} + +//! @endcond + +///////////////////////////// Matx out-of-class operators //////////////////////////////// + +//! @relates cv::Matx +//! @{ + +template static inline +Matx<_Tp1, m, n>& operator += (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]); + return a; +} + +template static inline +Matx<_Tp1, m, n>& operator -= (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]); + return a; +} + +template static inline +Matx<_Tp, m, n> operator + (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + return Matx<_Tp, m, n>(a, b, Matx_AddOp()); +} + +template static inline +Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + return Matx<_Tp, m, n>(a, b, Matx_SubOp()); +} + +template static inline +Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, int alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); + return a; +} + +template static inline +Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, float alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); + return a; +} + +template static inline +Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, double alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); + return a; +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, int alpha) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, float alpha) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, double alpha) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (int alpha, const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (float alpha, const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, float alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = a.val[i] / alpha; + return a; +} + +template static inline +Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, double alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = a.val[i] / alpha; + return a; +} + +template static inline +Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha) +{ + return Matx<_Tp, m, n>(a, 1.f/alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, double alpha) +{ + return Matx<_Tp, m, n>(a, 1./alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, -1, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b) +{ + return Matx<_Tp, m, n>(a, b, Matx_MatMulOp()); +} + +template static inline +Vec<_Tp, m> operator * (const Matx<_Tp, m, n>& a, const Vec<_Tp, n>& b) +{ + Matx<_Tp, m, 1> c(a, b, Matx_MatMulOp()); + return (const Vec<_Tp, m>&)(c); +} + +template static inline +bool operator == (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + for( int i = 0; i < m*n; i++ ) + if( a.val[i] != b.val[i] ) return false; + return true; +} + +template static inline +bool operator != (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + return !(a == b); +} + +//! @} + +////////////////////////////// Vec out-of-class operators //////////////////////////////// + +//! @relates cv::Vec +//! @{ + +template static inline +Vec<_Tp1, cn>& operator += (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b) +{ + for( int i = 0; i < cn; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]); + return a; +} + +template static inline +Vec<_Tp1, cn>& operator -= (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b) +{ + for( int i = 0; i < cn; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]); + return a; +} + +template static inline +Vec<_Tp, cn> operator + (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b) +{ + return Vec<_Tp, cn>(a, b, Matx_AddOp()); +} + +template static inline +Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b) +{ + return Vec<_Tp, cn>(a, b, Matx_SubOp()); +} + +template static inline +Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, int alpha) +{ + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*alpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, float alpha) +{ + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*alpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, double alpha) +{ + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*alpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, int alpha) +{ + double ialpha = 1./alpha; + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*ialpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, float alpha) +{ + float ialpha = 1.f/alpha; + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*ialpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, double alpha) +{ + double ialpha = 1./alpha; + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*ialpha); + return a; +} + +template static inline +Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, int alpha) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (int alpha, const Vec<_Tp, cn>& a) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, float alpha) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (float alpha, const Vec<_Tp, cn>& a) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, double alpha) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (double alpha, const Vec<_Tp, cn>& a) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, int alpha) +{ + return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, float alpha) +{ + return Vec<_Tp, cn>(a, 1.f/alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, double alpha) +{ + return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a) +{ + Vec<_Tp,cn> t; + for( int i = 0; i < cn; i++ ) t.val[i] = saturate_cast<_Tp>(-a.val[i]); + return t; +} + +template inline Vec<_Tp, 4> operator * (const Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2) +{ + return Vec<_Tp, 4>(saturate_cast<_Tp>(v1[0]*v2[0] - v1[1]*v2[1] - v1[2]*v2[2] - v1[3]*v2[3]), + saturate_cast<_Tp>(v1[0]*v2[1] + v1[1]*v2[0] + v1[2]*v2[3] - v1[3]*v2[2]), + saturate_cast<_Tp>(v1[0]*v2[2] - v1[1]*v2[3] + v1[2]*v2[0] + v1[3]*v2[1]), + saturate_cast<_Tp>(v1[0]*v2[3] + v1[1]*v2[2] - v1[2]*v2[1] + v1[3]*v2[0])); +} + +template inline Vec<_Tp, 4>& operator *= (Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2) +{ + v1 = v1 * v2; + return v1; +} + +//! @} + +} // cv + +#endif // OPENCV_CORE_MATX_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/neon_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/neon_utils.hpp new file mode 100644 index 0000000..573ba99 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/neon_utils.hpp @@ -0,0 +1,128 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_NEON_UTILS_HPP +#define OPENCV_HAL_NEON_UTILS_HPP + +#include "opencv2/core/cvdef.h" + +//! @addtogroup core_utils_neon +//! @{ + +#if CV_NEON + +inline int32x2_t cv_vrnd_s32_f32(float32x2_t v) +{ + static int32x2_t v_sign = vdup_n_s32(1 << 31), + v_05 = vreinterpret_s32_f32(vdup_n_f32(0.5f)); + + int32x2_t v_addition = vorr_s32(v_05, vand_s32(v_sign, vreinterpret_s32_f32(v))); + return vcvt_s32_f32(vadd_f32(v, vreinterpret_f32_s32(v_addition))); +} + +inline int32x4_t cv_vrndq_s32_f32(float32x4_t v) +{ + static int32x4_t v_sign = vdupq_n_s32(1 << 31), + v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f)); + + int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(v))); + return vcvtq_s32_f32(vaddq_f32(v, vreinterpretq_f32_s32(v_addition))); +} + +inline uint32x2_t cv_vrnd_u32_f32(float32x2_t v) +{ + static float32x2_t v_05 = vdup_n_f32(0.5f); + return vcvt_u32_f32(vadd_f32(v, v_05)); +} + +inline uint32x4_t cv_vrndq_u32_f32(float32x4_t v) +{ + static float32x4_t v_05 = vdupq_n_f32(0.5f); + return vcvtq_u32_f32(vaddq_f32(v, v_05)); +} + +inline float32x4_t cv_vrecpq_f32(float32x4_t val) +{ + float32x4_t reciprocal = vrecpeq_f32(val); + reciprocal = vmulq_f32(vrecpsq_f32(val, reciprocal), reciprocal); + reciprocal = vmulq_f32(vrecpsq_f32(val, reciprocal), reciprocal); + return reciprocal; +} + +inline float32x2_t cv_vrecp_f32(float32x2_t val) +{ + float32x2_t reciprocal = vrecpe_f32(val); + reciprocal = vmul_f32(vrecps_f32(val, reciprocal), reciprocal); + reciprocal = vmul_f32(vrecps_f32(val, reciprocal), reciprocal); + return reciprocal; +} + +inline float32x4_t cv_vrsqrtq_f32(float32x4_t val) +{ + float32x4_t e = vrsqrteq_f32(val); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(e, e), val), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(e, e), val), e); + return e; +} + +inline float32x2_t cv_vrsqrt_f32(float32x2_t val) +{ + float32x2_t e = vrsqrte_f32(val); + e = vmul_f32(vrsqrts_f32(vmul_f32(e, e), val), e); + e = vmul_f32(vrsqrts_f32(vmul_f32(e, e), val), e); + return e; +} + +inline float32x4_t cv_vsqrtq_f32(float32x4_t val) +{ + return cv_vrecpq_f32(cv_vrsqrtq_f32(val)); +} + +inline float32x2_t cv_vsqrt_f32(float32x2_t val) +{ + return cv_vrecp_f32(cv_vrsqrt_f32(val)); +} + +#endif + +//! @} + +#endif // OPENCV_HAL_NEON_UTILS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/ocl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/ocl.hpp new file mode 100644 index 0000000..4503fa0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/ocl.hpp @@ -0,0 +1,917 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the OpenCV Foundation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OPENCL_HPP +#define OPENCV_OPENCL_HPP + +#include "opencv2/core.hpp" +#include +#include + +namespace cv { namespace ocl { + +//! @addtogroup core_opencl +//! @{ + +CV_EXPORTS_W bool haveOpenCL(); +CV_EXPORTS_W bool useOpenCL(); +CV_EXPORTS_W bool haveAmdBlas(); +CV_EXPORTS_W bool haveAmdFft(); +CV_EXPORTS_W void setUseOpenCL(bool flag); +CV_EXPORTS_W void finish(); + +CV_EXPORTS bool haveSVM(); + +class CV_EXPORTS Context; +class CV_EXPORTS_W_SIMPLE Device; +class CV_EXPORTS Kernel; +class CV_EXPORTS Program; +class CV_EXPORTS ProgramSource; +class CV_EXPORTS Queue; +class CV_EXPORTS PlatformInfo; +class CV_EXPORTS Image2D; + +class CV_EXPORTS_W_SIMPLE Device +{ +public: + CV_WRAP Device() CV_NOEXCEPT; + explicit Device(void* d); + Device(const Device& d); + Device& operator = (const Device& d); + Device(Device&& d) CV_NOEXCEPT; + Device& operator = (Device&& d) CV_NOEXCEPT; + CV_WRAP ~Device(); + + void set(void* d); + + enum + { + TYPE_DEFAULT = (1 << 0), + TYPE_CPU = (1 << 1), + TYPE_GPU = (1 << 2), + TYPE_ACCELERATOR = (1 << 3), + TYPE_DGPU = TYPE_GPU + (1 << 16), + TYPE_IGPU = TYPE_GPU + (1 << 17), + TYPE_ALL = 0xFFFFFFFF + }; + + CV_WRAP String name() const; + CV_WRAP String extensions() const; + CV_WRAP bool isExtensionSupported(const String& extensionName) const; + CV_WRAP String version() const; + CV_WRAP String vendorName() const; + CV_WRAP String OpenCL_C_Version() const; + CV_WRAP String OpenCLVersion() const; + CV_WRAP int deviceVersionMajor() const; + CV_WRAP int deviceVersionMinor() const; + CV_WRAP String driverVersion() const; + void* ptr() const; + + CV_WRAP int type() const; + + CV_WRAP int addressBits() const; + CV_WRAP bool available() const; + CV_WRAP bool compilerAvailable() const; + CV_WRAP bool linkerAvailable() const; + + enum + { + FP_DENORM=(1 << 0), + FP_INF_NAN=(1 << 1), + FP_ROUND_TO_NEAREST=(1 << 2), + FP_ROUND_TO_ZERO=(1 << 3), + FP_ROUND_TO_INF=(1 << 4), + FP_FMA=(1 << 5), + FP_SOFT_FLOAT=(1 << 6), + FP_CORRECTLY_ROUNDED_DIVIDE_SQRT=(1 << 7) + }; + CV_WRAP int doubleFPConfig() const; + CV_WRAP int singleFPConfig() const; + CV_WRAP int halfFPConfig() const; + + CV_WRAP bool endianLittle() const; + CV_WRAP bool errorCorrectionSupport() const; + + enum + { + EXEC_KERNEL=(1 << 0), + EXEC_NATIVE_KERNEL=(1 << 1) + }; + CV_WRAP int executionCapabilities() const; + + CV_WRAP size_t globalMemCacheSize() const; + + enum + { + NO_CACHE=0, + READ_ONLY_CACHE=1, + READ_WRITE_CACHE=2 + }; + CV_WRAP int globalMemCacheType() const; + CV_WRAP int globalMemCacheLineSize() const; + CV_WRAP size_t globalMemSize() const; + + CV_WRAP size_t localMemSize() const; + enum + { + NO_LOCAL_MEM=0, + LOCAL_IS_LOCAL=1, + LOCAL_IS_GLOBAL=2 + }; + CV_WRAP int localMemType() const; + CV_WRAP bool hostUnifiedMemory() const; + + CV_WRAP bool imageSupport() const; + + CV_WRAP bool imageFromBufferSupport() const; + uint imagePitchAlignment() const; + uint imageBaseAddressAlignment() const; + + /// deprecated, use isExtensionSupported() method (probably with "cl_khr_subgroups" value) + CV_WRAP bool intelSubgroupsSupport() const; + + CV_WRAP size_t image2DMaxWidth() const; + CV_WRAP size_t image2DMaxHeight() const; + + CV_WRAP size_t image3DMaxWidth() const; + CV_WRAP size_t image3DMaxHeight() const; + CV_WRAP size_t image3DMaxDepth() const; + + CV_WRAP size_t imageMaxBufferSize() const; + CV_WRAP size_t imageMaxArraySize() const; + + enum + { + UNKNOWN_VENDOR=0, + VENDOR_AMD=1, + VENDOR_INTEL=2, + VENDOR_NVIDIA=3 + }; + CV_WRAP int vendorID() const; + // FIXIT + // dev.isAMD() doesn't work for OpenCL CPU devices from AMD OpenCL platform. + // This method should use platform name instead of vendor name. + // After fix restore code in arithm.cpp: ocl_compare() + CV_WRAP inline bool isAMD() const { return vendorID() == VENDOR_AMD; } + CV_WRAP inline bool isIntel() const { return vendorID() == VENDOR_INTEL; } + CV_WRAP inline bool isNVidia() const { return vendorID() == VENDOR_NVIDIA; } + + CV_WRAP int maxClockFrequency() const; + CV_WRAP int maxComputeUnits() const; + CV_WRAP int maxConstantArgs() const; + CV_WRAP size_t maxConstantBufferSize() const; + + CV_WRAP size_t maxMemAllocSize() const; + CV_WRAP size_t maxParameterSize() const; + + CV_WRAP int maxReadImageArgs() const; + CV_WRAP int maxWriteImageArgs() const; + CV_WRAP int maxSamplers() const; + + CV_WRAP size_t maxWorkGroupSize() const; + CV_WRAP int maxWorkItemDims() const; + void maxWorkItemSizes(size_t*) const; + + CV_WRAP int memBaseAddrAlign() const; + + CV_WRAP int nativeVectorWidthChar() const; + CV_WRAP int nativeVectorWidthShort() const; + CV_WRAP int nativeVectorWidthInt() const; + CV_WRAP int nativeVectorWidthLong() const; + CV_WRAP int nativeVectorWidthFloat() const; + CV_WRAP int nativeVectorWidthDouble() const; + CV_WRAP int nativeVectorWidthHalf() const; + + CV_WRAP int preferredVectorWidthChar() const; + CV_WRAP int preferredVectorWidthShort() const; + CV_WRAP int preferredVectorWidthInt() const; + CV_WRAP int preferredVectorWidthLong() const; + CV_WRAP int preferredVectorWidthFloat() const; + CV_WRAP int preferredVectorWidthDouble() const; + CV_WRAP int preferredVectorWidthHalf() const; + + CV_WRAP size_t printfBufferSize() const; + CV_WRAP size_t profilingTimerResolution() const; + + CV_WRAP static const Device& getDefault(); + + /** + * @param d OpenCL handle (cl_device_id). clRetainDevice() is called on success. + * + * @note Ownership of the passed device is passed to OpenCV on success. + * The caller should additionally call `clRetainDevice` on it if it intends + * to continue using the device. + */ + static Device fromHandle(void* d); + + struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + + +class CV_EXPORTS Context +{ +public: + Context() CV_NOEXCEPT; + explicit Context(int dtype); //!< @deprecated + ~Context(); + Context(const Context& c); + Context& operator= (const Context& c); + Context(Context&& c) CV_NOEXCEPT; + Context& operator = (Context&& c) CV_NOEXCEPT; + + /** @deprecated */ + bool create(); + /** @deprecated */ + bool create(int dtype); + + size_t ndevices() const; + Device& device(size_t idx) const; + Program getProg(const ProgramSource& prog, + const String& buildopt, String& errmsg); + void unloadProg(Program& prog); + + + /** Get thread-local OpenCL context (initialize if necessary) */ +#if 0 // OpenCV 5.0 + static Context& getDefault(); +#else + static Context& getDefault(bool initialize = true); +#endif + + /** @returns cl_context value */ + void* ptr() const; + + /** + * @brief Get OpenCL context property specified on context creation + * @param propertyId Property id (CL_CONTEXT_* as defined in cl_context_properties type) + * @returns Property value if property was specified on clCreateContext, or NULL if context created without the property + */ + void* getOpenCLContextProperty(int propertyId) const; + + bool useSVM() const; + void setUseSVM(bool enabled); + + /** + * @param context OpenCL handle (cl_context). clRetainContext() is called on success + */ + static Context fromHandle(void* context); + static Context fromDevice(const ocl::Device& device); + static Context create(const std::string& configuration); + + void release(); + + class CV_EXPORTS UserContext { + public: + virtual ~UserContext(); + }; + template + inline void setUserContext(const std::shared_ptr& userContext) { + setUserContext(typeid(T), userContext); + } + template + inline std::shared_ptr getUserContext() { + return std::dynamic_pointer_cast(getUserContext(typeid(T))); + } + void setUserContext(std::type_index typeId, const std::shared_ptr& userContext); + std::shared_ptr getUserContext(std::type_index typeId); + + struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +// TODO OpenCV 5.0 +//protected: + Impl* p; +}; + +/** @deprecated */ +class CV_EXPORTS Platform +{ +public: + Platform() CV_NOEXCEPT; + ~Platform(); + Platform(const Platform& p); + Platform& operator = (const Platform& p); + Platform(Platform&& p) CV_NOEXCEPT; + Platform& operator = (Platform&& p) CV_NOEXCEPT; + + void* ptr() const; + + /** @deprecated */ + static Platform& getDefault(); + + struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + +/** @brief Attaches OpenCL context to OpenCV +@note + OpenCV will check if available OpenCL platform has platformName name, then assign context to + OpenCV and call `clRetainContext` function. The deviceID device will be used as target device and + new command queue will be created. +@param platformName name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime +@param platformID ID of platform attached context was created for +@param context OpenCL context to be attached to OpenCV +@param deviceID ID of device, must be created from attached context +*/ +CV_EXPORTS void attachContext(const String& platformName, void* platformID, void* context, void* deviceID); + +/** @brief Convert OpenCL buffer to UMat +@note + OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV. Memory + content is not copied from `clBuffer` to UMat. Instead, buffer handle assigned to UMat and + `clRetainMemObject` is called. +@param cl_mem_buffer source clBuffer handle +@param step num of bytes in single row +@param rows number of rows +@param cols number of cols +@param type OpenCV type of image +@param dst destination UMat +*/ +CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst); + +/** @brief Convert OpenCL image2d_t to UMat +@note + OpenCL `image2d_t` (cl_mem_image), should be compatible with OpenCV UMat formats. Memory content + is copied from image to UMat with `clEnqueueCopyImageToBuffer` function. +@param cl_mem_image source image2d_t handle +@param dst destination UMat +*/ +CV_EXPORTS void convertFromImage(void* cl_mem_image, UMat& dst); + +// TODO Move to internal header +/// @deprecated +void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); + +class CV_EXPORTS Queue +{ +public: + Queue() CV_NOEXCEPT; + explicit Queue(const Context& c, const Device& d=Device()); + ~Queue(); + Queue(const Queue& q); + Queue& operator = (const Queue& q); + Queue(Queue&& q) CV_NOEXCEPT; + Queue& operator = (Queue&& q) CV_NOEXCEPT; + + bool create(const Context& c=Context(), const Device& d=Device()); + void finish(); + void* ptr() const; + static Queue& getDefault(); + + /// @brief Returns OpenCL command queue with enable profiling mode support + const Queue& getProfilingQueue() const; + + struct Impl; friend struct Impl; + inline Impl* getImpl() const { return p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + + +class CV_EXPORTS KernelArg +{ +public: + enum { LOCAL=1, READ_ONLY=2, WRITE_ONLY=4, READ_WRITE=6, CONSTANT=8, PTR_ONLY = 16, NO_SIZE=256 }; + KernelArg(int _flags, UMat* _m, int wscale=1, int iwscale=1, const void* _obj=0, size_t _sz=0); + KernelArg() CV_NOEXCEPT; + + static KernelArg Local(size_t localMemSize) + { return KernelArg(LOCAL, 0, 1, 1, 0, localMemSize); } + static KernelArg PtrWriteOnly(const UMat& m) + { return KernelArg(PTR_ONLY+WRITE_ONLY, (UMat*)&m); } + static KernelArg PtrReadOnly(const UMat& m) + { return KernelArg(PTR_ONLY+READ_ONLY, (UMat*)&m); } + static KernelArg PtrReadWrite(const UMat& m) + { return KernelArg(PTR_ONLY+READ_WRITE, (UMat*)&m); } + static KernelArg ReadWrite(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_WRITE, (UMat*)&m, wscale, iwscale); } + static KernelArg ReadWriteNoSize(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_WRITE+NO_SIZE, (UMat*)&m, wscale, iwscale); } + static KernelArg ReadOnly(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_ONLY, (UMat*)&m, wscale, iwscale); } + static KernelArg WriteOnly(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(WRITE_ONLY, (UMat*)&m, wscale, iwscale); } + static KernelArg ReadOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); } + static KernelArg WriteOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(WRITE_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); } + static KernelArg Constant(const Mat& m); + template static KernelArg Constant(const _Tp* arr, size_t n) + { return KernelArg(CONSTANT, 0, 1, 1, (void*)arr, n); } + + int flags; + UMat* m; + const void* obj; + size_t sz; + int wscale, iwscale; +}; + + +class CV_EXPORTS Kernel +{ +public: + Kernel() CV_NOEXCEPT; + Kernel(const char* kname, const Program& prog); + Kernel(const char* kname, const ProgramSource& prog, + const String& buildopts = String(), String* errmsg=0); + ~Kernel(); + Kernel(const Kernel& k); + Kernel& operator = (const Kernel& k); + Kernel(Kernel&& k) CV_NOEXCEPT; + Kernel& operator = (Kernel&& k) CV_NOEXCEPT; + + bool empty() const; + bool create(const char* kname, const Program& prog); + bool create(const char* kname, const ProgramSource& prog, + const String& buildopts, String* errmsg=0); + + int set(int i, const void* value, size_t sz); + int set(int i, const Image2D& image2D); + int set(int i, const UMat& m); + int set(int i, const KernelArg& arg); + template int set(int i, const _Tp& value) + { return set(i, &value, sizeof(value)); } + + +protected: + template inline + int set_args_(int i, const _Tp0& a0) { return set(i, a0); } + template inline + int set_args_(int i, const _Tp0& a0, const _Tps&... rest_args) { i = set(i, a0); return set_args_(i, rest_args...); } +public: + /** @brief Setup OpenCL Kernel arguments. + Avoid direct using of set(i, ...) methods. + @code + bool ok = kernel + .args( + srcUMat, dstUMat, + (float)some_float_param + ).run(ndims, globalSize, localSize); + if (!ok) return false; + @endcode + */ + template inline + Kernel& args(const _Tps&... kernel_args) { set_args_(0, kernel_args...); return *this; } + + /** @brief Run the OpenCL kernel (globalsize value may be adjusted) + + @param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3. + @param globalsize work items for each dimension. It is not the final globalsize passed to + OpenCL. Each dimension will be adjusted to the nearest integer divisible by the corresponding + value in localsize. If localsize is NULL, it will still be adjusted depending on dims. The + adjusted values are greater than or equal to the original values. + @param localsize work-group size for each dimension. + @param sync specify whether to wait for OpenCL computation to finish before return. + @param q command queue + + @note Use run_() if your kernel code doesn't support adjusted globalsize. + */ + bool run(int dims, size_t globalsize[], + size_t localsize[], bool sync, const Queue& q=Queue()); + + /** @brief Run the OpenCL kernel + * + * @param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3. + * @param globalsize work items for each dimension. This value is passed to OpenCL without changes. + * @param localsize work-group size for each dimension. + * @param sync specify whether to wait for OpenCL computation to finish before return. + * @param q command queue + */ + bool run_(int dims, size_t globalsize[], size_t localsize[], bool sync, const Queue& q=Queue()); + + bool runTask(bool sync, const Queue& q=Queue()); + + /** @brief Similar to synchronized run_() call with returning of kernel execution time + * + * Separate OpenCL command queue may be used (with CL_QUEUE_PROFILING_ENABLE) + * @return Execution time in nanoseconds or negative number on error + */ + int64 runProfiling(int dims, size_t globalsize[], size_t localsize[], const Queue& q=Queue()); + + size_t workGroupSize() const; + size_t preferedWorkGroupSizeMultiple() const; + bool compileWorkGroupSize(size_t wsz[]) const; + size_t localMemSize() const; + + void* ptr() const; + struct Impl; + +protected: + Impl* p; +}; + +class CV_EXPORTS Program +{ +public: + Program() CV_NOEXCEPT; + Program(const ProgramSource& src, + const String& buildflags, String& errmsg); + Program(const Program& prog); + Program& operator = (const Program& prog); + Program(Program&& prog) CV_NOEXCEPT; + Program& operator = (Program&& prog) CV_NOEXCEPT; + ~Program(); + + bool create(const ProgramSource& src, + const String& buildflags, String& errmsg); + + void* ptr() const; + + /** + * @brief Query device-specific program binary. + * + * Returns RAW OpenCL executable binary without additional attachments. + * + * @sa ProgramSource::fromBinary + * + * @param[out] binary output buffer + */ + void getBinary(std::vector& binary) const; + + struct Impl; friend struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +public: +#ifndef OPENCV_REMOVE_DEPRECATED_API + // TODO Remove this + CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead + CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary) + CV_DEPRECATED const ProgramSource& source() const; // implementation removed + CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced + CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced +#endif +}; + + +class CV_EXPORTS ProgramSource +{ +public: + typedef uint64 hash_t; // deprecated + + ProgramSource() CV_NOEXCEPT; + explicit ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash); + explicit ProgramSource(const String& prog); // deprecated + explicit ProgramSource(const char* prog); // deprecated + ~ProgramSource(); + ProgramSource(const ProgramSource& prog); + ProgramSource& operator = (const ProgramSource& prog); + ProgramSource(ProgramSource&& prog) CV_NOEXCEPT; + ProgramSource& operator = (ProgramSource&& prog) CV_NOEXCEPT; + + const String& source() const; // deprecated + hash_t hash() const; // deprecated + + + /** @brief Describe OpenCL program binary. + * Do not call clCreateProgramWithBinary() and/or clBuildProgram(). + * + * Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies). + * + * This kind of binary is not portable between platforms in general - it is specific to OpenCL vendor / device / driver version. + * + * @param module name of program owner module + * @param name unique name of program (module+name is used as key for OpenCL program caching) + * @param binary buffer address. See buffer lifetime requirement in description. + * @param size buffer size + * @param buildOptions additional program-related build options passed to clBuildProgram() + * @return created ProgramSource object + */ + static ProgramSource fromBinary(const String& module, const String& name, + const unsigned char* binary, const size_t size, + const cv::String& buildOptions = cv::String()); + + /** @brief Describe OpenCL program in SPIR format. + * Do not call clCreateProgramWithBinary() and/or clBuildProgram(). + * + * Supports SPIR 1.2 by default (pass '-spir-std=X.Y' in buildOptions to override this behavior) + * + * Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies). + * + * Programs in this format are portable between OpenCL implementations with 'khr_spir' extension: + * https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/cl_khr_spir.html + * (but they are not portable between different platforms: 32-bit / 64-bit) + * + * Note: these programs can't support vendor specific extensions, like 'cl_intel_subgroups'. + * + * @param module name of program owner module + * @param name unique name of program (module+name is used as key for OpenCL program caching) + * @param binary buffer address. See buffer lifetime requirement in description. + * @param size buffer size + * @param buildOptions additional program-related build options passed to clBuildProgram() + * (these options are added automatically: '-x spir' and '-spir-std=1.2') + * @return created ProgramSource object. + */ + static ProgramSource fromSPIR(const String& module, const String& name, + const unsigned char* binary, const size_t size, + const cv::String& buildOptions = cv::String()); + + //OpenCL 2.1+ only + //static Program fromSPIRV(const String& module, const String& name, + // const unsigned char* binary, const size_t size, + // const cv::String& buildOptions = cv::String()); + + struct Impl; friend struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + +class CV_EXPORTS PlatformInfo +{ +public: + PlatformInfo() CV_NOEXCEPT; + /** + * @param id pointer cl_platform_id (cl_platform_id*) + */ + explicit PlatformInfo(void* id); + ~PlatformInfo(); + + PlatformInfo(const PlatformInfo& i); + PlatformInfo& operator =(const PlatformInfo& i); + PlatformInfo(PlatformInfo&& i) CV_NOEXCEPT; + PlatformInfo& operator = (PlatformInfo&& i) CV_NOEXCEPT; + + String name() const; + String vendor() const; + + /// See CL_PLATFORM_VERSION + String version() const; + int versionMajor() const; + int versionMinor() const; + + int deviceNumber() const; + void getDevice(Device& device, int d) const; + + struct Impl; + bool empty() const { return !p; } +protected: + Impl* p; +}; + +CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf); +CV_EXPORTS const char* typeToStr(int t); +CV_EXPORTS const char* memopTypeToStr(int t); +CV_EXPORTS const char* vecopTypeToStr(int t); +CV_EXPORTS const char* getOpenCLErrorString(int errorCode); +CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1, const char * name = NULL); +CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); + + +enum OclVectorStrategy +{ + // all matrices have its own vector width + OCL_VECTOR_OWN = 0, + // all matrices have maximal vector width among all matrices + // (useful for cases when matrices have different data types) + OCL_VECTOR_MAX = 1, + + // default strategy + OCL_VECTOR_DEFAULT = OCL_VECTOR_OWN +}; + +CV_EXPORTS int predictOptimalVectorWidth(InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), + InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), + InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray(), + OclVectorStrategy strat = OCL_VECTOR_DEFAULT); + +CV_EXPORTS int checkOptimalVectorWidth(const int *vectorWidths, + InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), + InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), + InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray(), + OclVectorStrategy strat = OCL_VECTOR_DEFAULT); + +// with OCL_VECTOR_MAX strategy +CV_EXPORTS int predictOptimalVectorWidthMax(InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), + InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), + InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray()); + +CV_EXPORTS void buildOptionsAddMatrixDescription(String& buildOptions, const String& name, InputArray _m); + +class CV_EXPORTS Image2D +{ +public: + Image2D() CV_NOEXCEPT; + + /** + @param src UMat object from which to get image properties and data + @param norm flag to enable the use of normalized channel data types + @param alias flag indicating that the image should alias the src UMat. If true, changes to the + image or src will be reflected in both objects. + */ + explicit Image2D(const UMat &src, bool norm = false, bool alias = false); + Image2D(const Image2D & i); + ~Image2D(); + + Image2D & operator = (const Image2D & i); + Image2D(Image2D &&) CV_NOEXCEPT; + Image2D &operator=(Image2D &&) CV_NOEXCEPT; + + /** Indicates if creating an aliased image should succeed. + Depends on the underlying platform and the dimensions of the UMat. + */ + static bool canCreateAlias(const UMat &u); + + /** Indicates if the image format is supported. + */ + static bool isFormatSupported(int depth, int cn, bool norm); + + void* ptr() const; +protected: + struct Impl; + Impl* p; +}; + +class CV_EXPORTS Timer +{ +public: + Timer(const Queue& q); + ~Timer(); + void start(); + void stop(); + + uint64 durationNS() const; //< duration in nanoseconds + +protected: + struct Impl; + Impl* const p; + +private: + Timer(const Timer&); // disabled + Timer& operator=(const Timer&); // disabled +}; + +CV_EXPORTS MatAllocator* getOpenCLAllocator(); + + +class CV_EXPORTS_W OpenCLExecutionContext +{ +public: + OpenCLExecutionContext() = default; + ~OpenCLExecutionContext() = default; + + OpenCLExecutionContext(const OpenCLExecutionContext&) = default; + OpenCLExecutionContext(OpenCLExecutionContext&&) = default; + + OpenCLExecutionContext& operator=(const OpenCLExecutionContext&) = default; + OpenCLExecutionContext& operator=(OpenCLExecutionContext&&) = default; + + /** Get associated ocl::Context */ + Context& getContext() const; + /** Get the single default associated ocl::Device */ + Device& getDevice() const; + /** Get the single ocl::Queue that is associated with the ocl::Context and + * the single default ocl::Device + */ + Queue& getQueue() const; + + bool useOpenCL() const; + void setUseOpenCL(bool flag); + + /** Get OpenCL execution context of current thread. + * + * Initialize OpenCL execution context if it is empty + * - create new + * - reuse context of the main thread (threadID = 0) + */ + static OpenCLExecutionContext& getCurrent(); + + /** Get OpenCL execution context of current thread (can be empty) */ + static OpenCLExecutionContext& getCurrentRef(); + + /** Bind this OpenCL execution context to current thread. + * + * Context can't be empty. + * + * @note clFinish is not called for queue of previous execution context + */ + void bind() const; + + /** Creates new execution context with same OpenCV context and device + * + * @param q OpenCL queue + */ + OpenCLExecutionContext cloneWithNewQueue(const ocl::Queue& q) const; + /** @overload */ + OpenCLExecutionContext cloneWithNewQueue() const; + + /** @brief Creates OpenCL execution context + * OpenCV will check if available OpenCL platform has platformName name, + * then assign context to OpenCV. + * The deviceID device will be used as target device and a new command queue will be created. + * + * @note On success, ownership of one reference of the context and device is taken. + * The caller should additionally call `clRetainContext` and/or `clRetainDevice` + * to increase the reference count if it wishes to continue using them. + * + * @param platformName name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime + * @param platformID ID of platform attached context was created for (cl_platform_id) + * @param context OpenCL context to be attached to OpenCV (cl_context) + * @param deviceID OpenCL device (cl_device_id) + */ + static OpenCLExecutionContext create(const std::string& platformName, void* platformID, void* context, void* deviceID); + + /** @brief Creates OpenCL execution context + * + * @param context non-empty OpenCL context + * @param device non-empty OpenCL device (must be a part of context) + * @param queue non-empty OpenCL queue for provided context and device + */ + static OpenCLExecutionContext create(const Context& context, const Device& device, const ocl::Queue& queue); + /** @overload */ + static OpenCLExecutionContext create(const Context& context, const Device& device); + + struct Impl; + inline bool empty() const { return !p; } + void release(); +protected: + std::shared_ptr p; +}; + +class OpenCLExecutionContextScope +{ + OpenCLExecutionContext ctx_; +public: + inline OpenCLExecutionContextScope(const OpenCLExecutionContext& ctx) + { + CV_Assert(!ctx.empty()); + ctx_ = OpenCLExecutionContext::getCurrentRef(); + ctx.bind(); + } + + inline ~OpenCLExecutionContextScope() + { + if (!ctx_.empty()) + { + ctx_.bind(); + } + } +}; + +#ifdef __OPENCV_BUILD +namespace internal { + +CV_EXPORTS bool isOpenCLForced(); +#define OCL_FORCE_CHECK(condition) (cv::ocl::internal::isOpenCLForced() || (condition)) + +CV_EXPORTS bool isPerformanceCheckBypassed(); +#define OCL_PERFORMANCE_CHECK(condition) (cv::ocl::internal::isPerformanceCheckBypassed() || (condition)) + +CV_EXPORTS bool isCLBuffer(UMat& u); + +} // namespace internal +#endif + +//! @} + +}} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/ocl_genbase.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/ocl_genbase.hpp new file mode 100644 index 0000000..5334cf1 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/ocl_genbase.hpp @@ -0,0 +1,69 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the OpenCV Foundation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OPENCL_GENBASE_HPP +#define OPENCV_OPENCL_GENBASE_HPP + +//! @cond IGNORED + +namespace cv { +namespace ocl { + +class ProgramSource; + +namespace internal { + +struct CV_EXPORTS ProgramEntry +{ + const char* module; + const char* name; + const char* programCode; + const char* programHash; + ProgramSource* pProgramSource; + + operator ProgramSource& () const; +}; + +} } } // namespace + +//! @endcond + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/ocl_defs.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/ocl_defs.hpp new file mode 100644 index 0000000..14df750 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/ocl_defs.hpp @@ -0,0 +1,82 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_CORE_OPENCL_DEFS_HPP +#define OPENCV_CORE_OPENCL_DEFS_HPP + +#include "opencv2/core/utility.hpp" +#include "cvconfig.h" + +namespace cv { namespace ocl { +#ifdef HAVE_OPENCL +/// Call is similar to useOpenCL() but doesn't try to load OpenCL runtime or create OpenCL context +CV_EXPORTS bool isOpenCLActivated(); +#else +static inline bool isOpenCLActivated() { return false; } +#endif +}} // namespace + + +//#define CV_OPENCL_RUN_ASSERT + +#ifdef HAVE_OPENCL + +#ifdef CV_OPENCL_RUN_VERBOSE +#define CV_OCL_RUN_(condition, func, ...) \ + { \ + if (cv::ocl::isOpenCLActivated() && (condition) && func) \ + { \ + printf("%s: OpenCL implementation is running\n", CV_Func); \ + fflush(stdout); \ + CV_IMPL_ADD(CV_IMPL_OCL); \ + return __VA_ARGS__; \ + } \ + else \ + { \ + printf("%s: Plain implementation is running\n", CV_Func); \ + fflush(stdout); \ + } \ + } +#elif defined CV_OPENCL_RUN_ASSERT +#define CV_OCL_RUN_(condition, func, ...) \ + { \ + if (cv::ocl::isOpenCLActivated() && (condition)) \ + { \ + if(func) \ + { \ + CV_IMPL_ADD(CV_IMPL_OCL); \ + } \ + else \ + { \ + CV_Error(cv::Error::StsAssert, #func); \ + } \ + return __VA_ARGS__; \ + } \ + } +#else +#define CV_OCL_RUN_(condition, func, ...) \ +try \ +{ \ + if (cv::ocl::isOpenCLActivated() && (condition) && func) \ + { \ + CV_IMPL_ADD(CV_IMPL_OCL); \ + return __VA_ARGS__; \ + } \ +} \ +catch (const cv::Exception& e) \ +{ \ + CV_UNUSED(e); /* TODO: Add some logging here */ \ +} +#endif + +#else +#define CV_OCL_RUN_(condition, func, ...) +#endif + +#define CV_OCL_RUN(condition, func) CV_OCL_RUN_(condition, func) + +#endif // OPENCV_CORE_OPENCL_DEFS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/opencl_info.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/opencl_info.hpp new file mode 100644 index 0000000..3ead76e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/opencl_info.hpp @@ -0,0 +1,212 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include + +#include +#include + +#ifndef DUMP_CONFIG_PROPERTY +#define DUMP_CONFIG_PROPERTY(...) +#endif + +#ifndef DUMP_MESSAGE_STDOUT +#define DUMP_MESSAGE_STDOUT(...) do { std::cout << __VA_ARGS__ << std::endl; } while (false) +#endif + +namespace cv { + +namespace { +static std::string bytesToStringRepr(size_t value) +{ + size_t b = value % 1024; + value /= 1024; + + size_t kb = value % 1024; + value /= 1024; + + size_t mb = value % 1024; + value /= 1024; + + size_t gb = value; + + std::ostringstream stream; + + if (gb > 0) + stream << gb << " GB "; + if (mb > 0) + stream << mb << " MB "; + if (kb > 0) + stream << kb << " KB "; + if (b > 0) + stream << b << " B"; + + std::string s = stream.str(); + if (s[s.size() - 1] == ' ') + s = s.substr(0, s.size() - 1); + return s; +} + +static String getDeviceTypeString(const cv::ocl::Device& device) +{ + if (device.type() == cv::ocl::Device::TYPE_CPU) { + return "CPU"; + } + + if (device.type() == cv::ocl::Device::TYPE_GPU) { + if (device.hostUnifiedMemory()) { + return "iGPU"; + } else { + return "dGPU"; + } + } + + return "unknown"; +} +} // namespace + +static void dumpOpenCLInformation() +{ + using namespace cv::ocl; + + try + { + if (!haveOpenCL() || !useOpenCL()) + { + DUMP_MESSAGE_STDOUT("OpenCL is disabled"); + DUMP_CONFIG_PROPERTY("cv_ocl", "disabled"); + return; + } + + std::vector platforms; + cv::ocl::getPlatfomsInfo(platforms); + if (platforms.empty()) + { + DUMP_MESSAGE_STDOUT("OpenCL is not available"); + DUMP_CONFIG_PROPERTY("cv_ocl", "not available"); + return; + } + + DUMP_MESSAGE_STDOUT("OpenCL Platforms: "); + for (size_t i = 0; i < platforms.size(); i++) + { + const PlatformInfo* platform = &platforms[i]; + DUMP_MESSAGE_STDOUT(" " << platform->name()); + Device current_device; + for (int j = 0; j < platform->deviceNumber(); j++) + { + platform->getDevice(current_device, j); + String deviceTypeStr = getDeviceTypeString(current_device); + DUMP_MESSAGE_STDOUT( " " << deviceTypeStr << ": " << current_device.name() << " (" << current_device.version() << ")"); + DUMP_CONFIG_PROPERTY( cv::format("cv_ocl_platform_%d_device_%d", (int)i, j ), + cv::format("(Platform=%s)(Type=%s)(Name=%s)(Version=%s)", + platform->name().c_str(), deviceTypeStr.c_str(), current_device.name().c_str(), current_device.version().c_str()) ); + } + } + const Device& device = Device::getDefault(); + if (!device.available()) + CV_Error(Error::OpenCLInitError, "OpenCL device is not available"); + + DUMP_MESSAGE_STDOUT("Current OpenCL device: "); + + String deviceTypeStr = getDeviceTypeString(device); + DUMP_MESSAGE_STDOUT(" Type = " << deviceTypeStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceType", deviceTypeStr); + + DUMP_MESSAGE_STDOUT(" Name = " << device.name()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceName", device.name()); + + DUMP_MESSAGE_STDOUT(" Version = " << device.version()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceVersion", device.version()); + + DUMP_MESSAGE_STDOUT(" Driver version = " << device.driverVersion()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_driverVersion", device.driverVersion()); + + DUMP_MESSAGE_STDOUT(" Address bits = " << device.addressBits()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_addressBits", device.addressBits()); + + DUMP_MESSAGE_STDOUT(" Compute units = " << device.maxComputeUnits()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_maxComputeUnits", device.maxComputeUnits()); + + DUMP_MESSAGE_STDOUT(" Max work group size = " << device.maxWorkGroupSize()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_maxWorkGroupSize", device.maxWorkGroupSize()); + + std::string localMemorySizeStr = bytesToStringRepr(device.localMemSize()); + DUMP_MESSAGE_STDOUT(" Local memory size = " << localMemorySizeStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_localMemSize", device.localMemSize()); + + std::string maxMemAllocSizeStr = bytesToStringRepr(device.maxMemAllocSize()); + DUMP_MESSAGE_STDOUT(" Max memory allocation size = " << maxMemAllocSizeStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_maxMemAllocSize", device.maxMemAllocSize()); + + const char* doubleSupportStr = device.doubleFPConfig() > 0 ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Double support = " << doubleSupportStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_haveDoubleSupport", device.doubleFPConfig() > 0); + + const char* halfSupportStr = device.halfFPConfig() > 0 ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Half support = " << halfSupportStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_haveHalfSupport", device.halfFPConfig() > 0); + + const char* isUnifiedMemoryStr = device.hostUnifiedMemory() ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Host unified memory = " << isUnifiedMemoryStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_hostUnifiedMemory", device.hostUnifiedMemory()); + + DUMP_MESSAGE_STDOUT(" Device extensions:"); + String extensionsStr = device.extensions(); + size_t pos = 0; + while (pos < extensionsStr.size()) + { + size_t pos2 = extensionsStr.find(' ', pos); + if (pos2 == String::npos) + pos2 = extensionsStr.size(); + if (pos2 > pos) + { + String extensionName = extensionsStr.substr(pos, pos2 - pos); + DUMP_MESSAGE_STDOUT(" " << extensionName); + } + pos = pos2 + 1; + } + DUMP_CONFIG_PROPERTY("cv_ocl_current_extensions", extensionsStr); + + const char* haveAmdBlasStr = haveAmdBlas() ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Has AMD Blas = " << haveAmdBlasStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_AmdBlas", haveAmdBlas()); + + const char* haveAmdFftStr = haveAmdFft() ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Has AMD Fft = " << haveAmdFftStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_AmdFft", haveAmdFft()); + + + DUMP_MESSAGE_STDOUT(" Preferred vector width char = " << device.preferredVectorWidthChar()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthChar", device.preferredVectorWidthChar()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width short = " << device.preferredVectorWidthShort()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthShort", device.preferredVectorWidthShort()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width int = " << device.preferredVectorWidthInt()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthInt", device.preferredVectorWidthInt()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width long = " << device.preferredVectorWidthLong()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthLong", device.preferredVectorWidthLong()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width float = " << device.preferredVectorWidthFloat()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthFloat", device.preferredVectorWidthFloat()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width double = " << device.preferredVectorWidthDouble()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthDouble", device.preferredVectorWidthDouble()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width half = " << device.preferredVectorWidthHalf()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthHalf", device.preferredVectorWidthHalf()); + } + catch (...) + { + DUMP_MESSAGE_STDOUT("Exception. Can't dump OpenCL info"); + DUMP_MESSAGE_STDOUT("OpenCL device not available"); + DUMP_CONFIG_PROPERTY("cv_ocl", "not available"); + } +} +#undef DUMP_MESSAGE_STDOUT +#undef DUMP_CONFIG_PROPERTY + +} // namespace diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/opencl_svm.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/opencl_svm.hpp new file mode 100644 index 0000000..7453082 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/opencl/opencl_svm.hpp @@ -0,0 +1,81 @@ +/* See LICENSE file in the root OpenCV directory */ + +#ifndef OPENCV_CORE_OPENCL_SVM_HPP +#define OPENCV_CORE_OPENCL_SVM_HPP + +// +// Internal usage only (binary compatibility is not guaranteed) +// +#ifndef __OPENCV_BUILD +#error Internal header file +#endif + +#if defined(HAVE_OPENCL) && defined(HAVE_OPENCL_SVM) +#include "runtime/opencl_core.hpp" +#include "runtime/opencl_svm_20.hpp" +#include "runtime/opencl_svm_hsa_extension.hpp" + +namespace cv { namespace ocl { namespace svm { + +struct SVMCapabilities +{ + enum Value + { + SVM_COARSE_GRAIN_BUFFER = (1 << 0), + SVM_FINE_GRAIN_BUFFER = (1 << 1), + SVM_FINE_GRAIN_SYSTEM = (1 << 2), + SVM_ATOMICS = (1 << 3), + }; + int value_; + + SVMCapabilities(int capabilities = 0) : value_(capabilities) { } + operator int() const { return value_; } + + inline bool isNoSVMSupport() const { return value_ == 0; } + inline bool isSupportCoarseGrainBuffer() const { return (value_ & SVM_COARSE_GRAIN_BUFFER) != 0; } + inline bool isSupportFineGrainBuffer() const { return (value_ & SVM_FINE_GRAIN_BUFFER) != 0; } + inline bool isSupportFineGrainSystem() const { return (value_ & SVM_FINE_GRAIN_SYSTEM) != 0; } + inline bool isSupportAtomics() const { return (value_ & SVM_ATOMICS) != 0; } +}; + +CV_EXPORTS const SVMCapabilities getSVMCapabilitites(const ocl::Context& context); + +struct SVMFunctions +{ + clSVMAllocAMD_fn fn_clSVMAlloc; + clSVMFreeAMD_fn fn_clSVMFree; + clSetKernelArgSVMPointerAMD_fn fn_clSetKernelArgSVMPointer; + //clSetKernelExecInfoAMD_fn fn_clSetKernelExecInfo; + //clEnqueueSVMFreeAMD_fn fn_clEnqueueSVMFree; + clEnqueueSVMMemcpyAMD_fn fn_clEnqueueSVMMemcpy; + clEnqueueSVMMemFillAMD_fn fn_clEnqueueSVMMemFill; + clEnqueueSVMMapAMD_fn fn_clEnqueueSVMMap; + clEnqueueSVMUnmapAMD_fn fn_clEnqueueSVMUnmap; + + inline SVMFunctions() + : fn_clSVMAlloc(NULL), fn_clSVMFree(NULL), + fn_clSetKernelArgSVMPointer(NULL), /*fn_clSetKernelExecInfo(NULL),*/ + /*fn_clEnqueueSVMFree(NULL),*/ fn_clEnqueueSVMMemcpy(NULL), fn_clEnqueueSVMMemFill(NULL), + fn_clEnqueueSVMMap(NULL), fn_clEnqueueSVMUnmap(NULL) + { + // nothing + } + + inline bool isValid() const + { + return fn_clSVMAlloc != NULL && fn_clSVMFree && fn_clSetKernelArgSVMPointer && + /*fn_clSetKernelExecInfo && fn_clEnqueueSVMFree &&*/ fn_clEnqueueSVMMemcpy && + fn_clEnqueueSVMMemFill && fn_clEnqueueSVMMap && fn_clEnqueueSVMUnmap; + } +}; + +// We should guarantee that SVMFunctions lifetime is not less than context's lifetime +CV_EXPORTS const SVMFunctions* getSVMFunctions(const ocl::Context& context); + +CV_EXPORTS bool useSVM(UMatUsageFlags usageFlags); + +}}} //namespace cv::ocl::svm +#endif + +#endif // OPENCV_CORE_OPENCL_SVM_HPP +/* End of file. */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/opengl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/opengl.hpp new file mode 100644 index 0000000..a311ce2 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/opengl.hpp @@ -0,0 +1,725 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_OPENGL_HPP +#define OPENCV_CORE_OPENGL_HPP + +#ifndef __cplusplus +# error opengl.hpp header must be compiled as C++ +#endif + +#include "opencv2/core.hpp" +#include "ocl.hpp" + +namespace cv { namespace ogl { + +/** @addtogroup core_opengl +This section describes OpenGL interoperability. + +To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is +supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not +supported). For GTK backend gtkglext-1.0 library is required. + +To use OpenGL functionality you should first create OpenGL context (window or frame buffer). You can +do this with namedWindow function or with other OpenGL toolkit (GLUT, for example). +*/ +//! @{ + +/////////////////// OpenGL Objects /////////////////// + +/** @brief Smart pointer for OpenGL buffer object with reference counting. + +Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL +context. These can be used to store vertex data, pixel data retrieved from images or the +framebuffer, and a variety of other things. + +ogl::Buffer has interface similar with Mat interface and represents 2D array memory. + +ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory. + */ +class CV_EXPORTS Buffer +{ +public: + /** @brief The target defines how you intend to use the buffer object. + */ + enum Target + { + ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data + ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example) + PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures + PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures + }; + + enum Access + { + READ_ONLY = 0x88B8, + WRITE_ONLY = 0x88B9, + READ_WRITE = 0x88BA + }; + + /** @brief The constructors. + + Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + */ + Buffer(); + + /** @overload + @param arows Number of rows in a 2D array. + @param acols Number of columns in a 2D array. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param abufId Buffer object name. + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param abufId Buffer object name. + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false); + + /** @overload + @param arows Number of rows in a 2D array. + @param acols Number of columns in a 2D array. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @brief Allocates memory for ogl::Buffer object. + + @param arows Number of rows in a 2D array. + @param acols Number of columns in a 2D array. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @brief Decrements the reference counter and destroys the buffer object if needed. + + The function will call setAutoRelease(true) . + */ + void release(); + + /** @brief Sets auto release mode. + + The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was + bound to a window it could be released at any time (user can close a window). If object's destructor + is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy + OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). + This function can force ogl::Buffer destructor to destroy OpenGL object. + @param flag Auto release mode (if true, release will be called in object's destructor). + */ + void setAutoRelease(bool flag); + + /** @brief Copies from host/device memory to OpenGL buffer. + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload */ + void copyFrom(InputArray arr, cuda::Stream& stream, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @brief Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. + + @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or + ogl::Buffer ). + */ + void copyTo(OutputArray arr) const; + + /** @overload */ + void copyTo(OutputArray arr, cuda::Stream& stream) const; + + /** @brief Creates a full copy of the buffer object and the underlying data. + + @param target Buffer usage for destination buffer. + @param autoRelease Auto release mode for destination buffer. + */ + Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const; + + /** @brief Binds OpenGL buffer to the specified buffer binding point. + + @param target Binding point. See cv::ogl::Buffer::Target . + */ + void bind(Target target) const; + + /** @brief Unbind any buffers from the specified binding point. + + @param target Binding point. See cv::ogl::Buffer::Target . + */ + static void unbind(Target target); + + /** @brief Maps OpenGL buffer to host memory. + + mapHost maps to the client's address space the entire data store of the buffer object. The data can + then be directly read and/or written relative to the returned pointer, depending on the specified + access policy. + + A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used. + + This operation can lead to memory transfers between host and device. + + Only one buffer object can be mapped at a time. + @param access Access policy, indicating whether it will be possible to read from, write to, or both + read from and write to the buffer object's mapped data store. The symbolic constant must be + ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE . + */ + Mat mapHost(Access access); + + /** @brief Unmaps OpenGL buffer. + */ + void unmapHost(); + + //! map to device memory (blocking) + cuda::GpuMat mapDevice(); + void unmapDevice(); + + /** @brief Maps OpenGL buffer to CUDA device memory. + + This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time. + + A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used. + */ + cuda::GpuMat mapDevice(cuda::Stream& stream); + + /** @brief Unmaps OpenGL buffer. + */ + void unmapDevice(cuda::Stream& stream); + + int rows() const; + int cols() const; + Size size() const; + bool empty() const; + + int type() const; + int depth() const; + int channels() const; + int elemSize() const; + int elemSize1() const; + + //! get OpenGL opject id + unsigned int bufId() const; + + class Impl; + +private: + Ptr impl_; + int rows_; + int cols_; + int type_; +}; + +/** @brief Smart pointer for OpenGL 2D texture memory with reference counting. + */ +class CV_EXPORTS Texture2D +{ +public: + /** @brief An Image Format describes the way that the images in Textures store their data. + */ + enum Format + { + NONE = 0, + DEPTH_COMPONENT = 0x1902, //!< Depth + RGB = 0x1907, //!< Red, Green, Blue + RGBA = 0x1908 //!< Red, Green, Blue, Alpha + }; + + /** @brief The constructors. + + Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + host/device memory. + */ + Texture2D(); + + /** @overload */ + Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false); + + /** @overload */ + Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false); + + /** @overload + @param arows Number of rows. + @param acols Number of columns. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Texture2D(int arows, int acols, Format aformat, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Texture2D(Size asize, Format aformat, bool autoRelease = false); + + /** @overload + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + explicit Texture2D(InputArray arr, bool autoRelease = false); + + /** @brief Allocates memory for ogl::Texture2D object. + + @param arows Number of rows. + @param acols Number of columns. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(int arows, int acols, Format aformat, bool autoRelease = false); + /** @overload + @param asize 2D array size. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(Size asize, Format aformat, bool autoRelease = false); + + /** @brief Decrements the reference counter and destroys the texture object if needed. + + The function will call setAutoRelease(true) . + */ + void release(); + + /** @brief Sets auto release mode. + + @param flag Auto release mode (if true, release will be called in object's destructor). + + The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was + bound to a window it could be released at any time (user can close a window). If object's destructor + is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't + destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL + context). This function can force ogl::Texture2D destructor to destroy OpenGL object. + */ + void setAutoRelease(bool flag); + + /** @brief Copies from host/device memory to OpenGL texture. + + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void copyFrom(InputArray arr, bool autoRelease = false); + + /** @brief Copies from OpenGL texture to host/device memory or another OpenGL texture object. + + @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or + ogl::Texture2D ). + @param ddepth Destination depth. + @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture). + */ + void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const; + + /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target. + */ + void bind() const; + + int rows() const; + int cols() const; + Size size() const; + bool empty() const; + + Format format() const; + + //! get OpenGL opject id + unsigned int texId() const; + + class Impl; + +private: + Ptr impl_; + int rows_; + int cols_; + Format format_; +}; + +/** @brief Wrapper for OpenGL Client-Side Vertex arrays. + +ogl::Arrays stores vertex data in ogl::Buffer objects. + */ +class CV_EXPORTS Arrays +{ +public: + /** @brief Default constructor + */ + Arrays(); + + /** @brief Sets an array of vertex coordinates. + @param vertex array with vertex coordinates, can be both host and device memory. + */ + void setVertexArray(InputArray vertex); + + /** @brief Resets vertex coordinates. + */ + void resetVertexArray(); + + /** @brief Sets an array of vertex colors. + @param color array with vertex colors, can be both host and device memory. + */ + void setColorArray(InputArray color); + + /** @brief Resets vertex colors. + */ + void resetColorArray(); + + /** @brief Sets an array of vertex normals. + @param normal array with vertex normals, can be both host and device memory. + */ + void setNormalArray(InputArray normal); + + /** @brief Resets vertex normals. + */ + void resetNormalArray(); + + /** @brief Sets an array of vertex texture coordinates. + @param texCoord array with vertex texture coordinates, can be both host and device memory. + */ + void setTexCoordArray(InputArray texCoord); + + /** @brief Resets vertex texture coordinates. + */ + void resetTexCoordArray(); + + /** @brief Releases all inner buffers. + */ + void release(); + + /** @brief Sets auto release mode all inner buffers. + @param flag Auto release mode. + */ + void setAutoRelease(bool flag); + + /** @brief Binds all vertex arrays. + */ + void bind() const; + + /** @brief Returns the vertex count. + */ + int size() const; + bool empty() const; + +private: + int size_; + Buffer vertex_; + Buffer color_; + Buffer normal_; + Buffer texCoord_; +}; + +/////////////////// Render Functions /////////////////// + +//! render mode +enum RenderModes { + POINTS = 0x0000, + LINES = 0x0001, + LINE_LOOP = 0x0002, + LINE_STRIP = 0x0003, + TRIANGLES = 0x0004, + TRIANGLE_STRIP = 0x0005, + TRIANGLE_FAN = 0x0006, + QUADS = 0x0007, + QUAD_STRIP = 0x0008, + POLYGON = 0x0009 +}; + +/** @brief Render OpenGL texture or primitives. +@param tex Texture to draw. +@param wndRect Region of window, where to draw a texture (normalized coordinates). +@param texRect Region of texture to draw (normalized coordinates). + */ +CV_EXPORTS void render(const Texture2D& tex, + Rect_ wndRect = Rect_(0.0, 0.0, 1.0, 1.0), + Rect_ texRect = Rect_(0.0, 0.0, 1.0, 1.0)); + +/** @overload +@param arr Array of privitives vertices. +@param mode Render mode. One of cv::ogl::RenderModes +@param color Color for all vertices. Will be used if arr doesn't contain color array. +*/ +CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255)); + +/** @overload +@param arr Array of privitives vertices. +@param indices Array of vertices indices (host or device memory). +@param mode Render mode. One of cv::ogl::RenderModes +@param color Color for all vertices. Will be used if arr doesn't contain color array. +*/ +CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255)); + +/////////////////// CL-GL Interoperability Functions /////////////////// + +namespace ocl { +using namespace cv::ocl; + +// TODO static functions in the Context class +/** @brief Creates OpenCL context from GL. +@return Returns reference to OpenCL Context + */ +CV_EXPORTS Context& initializeContextFromGL(); + +} // namespace cv::ogl::ocl + +/** @brief Converts InputArray to Texture2D object. +@param src - source InputArray. +@param texture - destination Texture2D object. + */ +CV_EXPORTS void convertToGLTexture2D(InputArray src, Texture2D& texture); + +/** @brief Converts Texture2D object to OutputArray. +@param texture - source Texture2D object. +@param dst - destination OutputArray. + */ +CV_EXPORTS void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst); + +/** @brief Maps Buffer object to process on CL side (convert to UMat). + +Function creates CL buffer from GL one, and then constructs UMat that can be used +to process buffer data with OpenCV functions. Note that in current implementation +UMat constructed this way doesn't own corresponding GL buffer object, so it is +the user responsibility to close down CL/GL buffers relationships by explicitly +calling unmapGLBuffer() function. +@param buffer - source Buffer object. +@param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE). +@return Returns UMat object + */ +CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags = ACCESS_READ | ACCESS_WRITE); + +/** @brief Unmaps Buffer object (releases UMat, previously mapped from Buffer). + +Function must be called explicitly by the user for each UMat previously constructed +by the call to mapGLBuffer() function. +@param u - source UMat, created by mapGLBuffer(). + */ +CV_EXPORTS void unmapGLBuffer(UMat& u); + +//! @} +}} // namespace cv::ogl + +namespace cv { namespace cuda { + +/** @brief Sets a CUDA device and initializes it for the current thread with OpenGL interoperability. + +This function should be explicitly called after OpenGL context creation and before any CUDA calls. +@param device System index of a CUDA device starting with 0. +@ingroup core_opengl + */ +CV_EXPORTS void setGlDevice(int device = 0); + +}} + +//! @cond IGNORED + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +inline +cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +{ + create(arows, acols, atype, target, autoRelease); +} + +inline +cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +{ + create(asize, atype, target, autoRelease); +} + +inline +void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease) +{ + create(asize.height, asize.width, atype, target, autoRelease); +} + +inline +int cv::ogl::Buffer::rows() const +{ + return rows_; +} + +inline +int cv::ogl::Buffer::cols() const +{ + return cols_; +} + +inline +cv::Size cv::ogl::Buffer::size() const +{ + return Size(cols_, rows_); +} + +inline +bool cv::ogl::Buffer::empty() const +{ + return rows_ == 0 || cols_ == 0; +} + +inline +int cv::ogl::Buffer::type() const +{ + return type_; +} + +inline +int cv::ogl::Buffer::depth() const +{ + return CV_MAT_DEPTH(type_); +} + +inline +int cv::ogl::Buffer::channels() const +{ + return CV_MAT_CN(type_); +} + +inline +int cv::ogl::Buffer::elemSize() const +{ + return CV_ELEM_SIZE(type_); +} + +inline +int cv::ogl::Buffer::elemSize1() const +{ + return CV_ELEM_SIZE1(type_); +} + +/////// + +inline +cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE) +{ + create(arows, acols, aformat, autoRelease); +} + +inline +cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE) +{ + create(asize, aformat, autoRelease); +} + +inline +void cv::ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease) +{ + create(asize.height, asize.width, aformat, autoRelease); +} + +inline +int cv::ogl::Texture2D::rows() const +{ + return rows_; +} + +inline +int cv::ogl::Texture2D::cols() const +{ + return cols_; +} + +inline +cv::Size cv::ogl::Texture2D::size() const +{ + return Size(cols_, rows_); +} + +inline +bool cv::ogl::Texture2D::empty() const +{ + return rows_ == 0 || cols_ == 0; +} + +inline +cv::ogl::Texture2D::Format cv::ogl::Texture2D::format() const +{ + return format_; +} + +/////// + +inline +cv::ogl::Arrays::Arrays() : size_(0) +{ +} + +inline +int cv::ogl::Arrays::size() const +{ + return size_; +} + +inline +bool cv::ogl::Arrays::empty() const +{ + return size_ == 0; +} + +//! @endcond + +#endif /* OPENCV_CORE_OPENGL_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/operations.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/operations.hpp new file mode 100644 index 0000000..bde28c4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/operations.hpp @@ -0,0 +1,594 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_OPERATIONS_HPP +#define OPENCV_CORE_OPERATIONS_HPP + +#ifndef __cplusplus +# error operations.hpp header must be compiled as C++ +#endif + +#include + +#if defined(__GNUC__) || defined(__clang__) // at least GCC 3.1+, clang 3.5+ +# if defined(__MINGW_PRINTF_FORMAT) // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. +# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (__MINGW_PRINTF_FORMAT, string_idx, first_to_check))) +# else +# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (printf, string_idx, first_to_check))) +# endif +#else +# define CV_FORMAT_PRINTF(A, B) +#endif + +//! @cond IGNORED + +namespace cv +{ + +////////////////////////////// Matx methods depending on core API ///////////////////////////// + +namespace internal +{ + +template struct Matx_FastInvOp +{ + bool operator()(const Matx<_Tp, m, n>& a, Matx<_Tp, n, m>& b, int method) const + { + return invert(a, b, method) != 0; + } +}; + +template struct Matx_FastInvOp<_Tp, m, m> +{ + bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const + { + if (method == DECOMP_LU || method == DECOMP_CHOLESKY) + { + Matx<_Tp, m, m> temp = a; + + // assume that b is all 0's on input => make it a unity matrix + for (int i = 0; i < m; i++) + b(i, i) = (_Tp)1; + + if (method == DECOMP_CHOLESKY) + return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m); + + return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0; + } + else + { + return invert(a, b, method) != 0; + } + } +}; + +template struct Matx_FastInvOp<_Tp, 2, 2> +{ + bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int /*method*/) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + b(1,1) = a(0,0)*d; + b(0,0) = a(1,1)*d; + b(0,1) = -a(0,1)*d; + b(1,0) = -a(1,0)*d; + return true; + } +}; + +template struct Matx_FastInvOp<_Tp, 3, 3> +{ + bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int /*method*/) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + b(0,0) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) * d; + b(0,1) = (a(0,2) * a(2,1) - a(0,1) * a(2,2)) * d; + b(0,2) = (a(0,1) * a(1,2) - a(0,2) * a(1,1)) * d; + + b(1,0) = (a(1,2) * a(2,0) - a(1,0) * a(2,2)) * d; + b(1,1) = (a(0,0) * a(2,2) - a(0,2) * a(2,0)) * d; + b(1,2) = (a(0,2) * a(1,0) - a(0,0) * a(1,2)) * d; + + b(2,0) = (a(1,0) * a(2,1) - a(1,1) * a(2,0)) * d; + b(2,1) = (a(0,1) * a(2,0) - a(0,0) * a(2,1)) * d; + b(2,2) = (a(0,0) * a(1,1) - a(0,1) * a(1,0)) * d; + return true; + } +}; + + +template struct Matx_FastSolveOp +{ + bool operator()(const Matx<_Tp, m, l>& a, const Matx<_Tp, m, n>& b, + Matx<_Tp, l, n>& x, int method) const + { + return cv::solve(a, b, x, method); + } +}; + +template struct Matx_FastSolveOp<_Tp, m, m, n> +{ + bool operator()(const Matx<_Tp, m, m>& a, const Matx<_Tp, m, n>& b, + Matx<_Tp, m, n>& x, int method) const + { + if (method == DECOMP_LU || method == DECOMP_CHOLESKY) + { + Matx<_Tp, m, m> temp = a; + x = b; + if( method == DECOMP_CHOLESKY ) + return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n); + + return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0; + } + else + { + return cv::solve(a, b, x, method); + } + } +}; + +template struct Matx_FastSolveOp<_Tp, 2, 2, 1> +{ + bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b, + Matx<_Tp, 2, 1>& x, int) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + x(0) = (b(0)*a(1,1) - b(1)*a(0,1))*d; + x(1) = (b(1)*a(0,0) - b(0)*a(1,0))*d; + return true; + } +}; + +template struct Matx_FastSolveOp<_Tp, 3, 3, 1> +{ + bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b, + Matx<_Tp, 3, 1>& x, int) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + x(0) = d*(b(0)*(a(1,1)*a(2,2) - a(1,2)*a(2,1)) - + a(0,1)*(b(1)*a(2,2) - a(1,2)*b(2)) + + a(0,2)*(b(1)*a(2,1) - a(1,1)*b(2))); + + x(1) = d*(a(0,0)*(b(1)*a(2,2) - a(1,2)*b(2)) - + b(0)*(a(1,0)*a(2,2) - a(1,2)*a(2,0)) + + a(0,2)*(a(1,0)*b(2) - b(1)*a(2,0))); + + x(2) = d*(a(0,0)*(a(1,1)*b(2) - b(1)*a(2,1)) - + a(0,1)*(a(1,0)*b(2) - b(1)*a(2,0)) + + b(0)*(a(1,0)*a(2,1) - a(1,1)*a(2,0))); + return true; + } +}; + +} // internal + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::randu(_Tp a, _Tp b) +{ + Matx<_Tp,m,n> M; + cv::randu(M, Scalar(a), Scalar(b)); + return M; +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::randn(_Tp a, _Tp b) +{ + Matx<_Tp,m,n> M; + cv::randn(M, Scalar(a), Scalar(b)); + return M; +} + +template inline +Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const +{ + Matx<_Tp, n, m> b; + bool ok = cv::internal::Matx_FastInvOp<_Tp, m, n>()(*this, b, method); + if (p_is_ok) *p_is_ok = ok; + return ok ? b : Matx<_Tp, n, m>::zeros(); +} + +template template inline +Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) const +{ + Matx<_Tp, n, l> x; + bool ok = cv::internal::Matx_FastSolveOp<_Tp, m, n, l>()(*this, rhs, x, method); + return ok ? x : Matx<_Tp, n, l>::zeros(); +} + + + +////////////////////////// Augmenting algebraic & logical operations ////////////////////////// + +#define CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \ + static inline A& operator op (A& a, const B& b) { cvop; return a; } + +#define CV_MAT_AUG_OPERATOR(op, cvop, A, B) \ + CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \ + CV_MAT_AUG_OPERATOR1(op, cvop, const A, B) + +#define CV_MAT_AUG_OPERATOR_T(op, cvop, A, B) \ + template CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \ + template CV_MAT_AUG_OPERATOR1(op, cvop, const A, B) + +#define CV_MAT_AUG_OPERATOR_TN(op, cvop, A) \ + template static inline A& operator op (A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } \ + template static inline const A& operator op (const A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } + +CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat) +CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, -1, b), Mat, double) +CV_MAT_AUG_OPERATOR_T(*=, a.convertTo(a, -1, b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat) +CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (/=, cv::divide(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR (/=, a.convertTo((Mat&)a, -1, 1./b), Mat, double) +CV_MAT_AUG_OPERATOR_T(/=, a.convertTo((Mat&)a, -1, 1./b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +#undef CV_MAT_AUG_OPERATOR_TN +#undef CV_MAT_AUG_OPERATOR_T +#undef CV_MAT_AUG_OPERATOR +#undef CV_MAT_AUG_OPERATOR1 + + + +///////////////////////////////////////////// SVD ///////////////////////////////////////////// + +inline SVD::SVD() {} +inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); } +inline void SVD::solveZ( InputArray m, OutputArray _dst ) +{ + Mat mtx = m.getMat(); + SVD svd(mtx, (mtx.rows >= mtx.cols ? 0 : SVD::FULL_UV)); + _dst.create(svd.vt.cols, 1, svd.vt.type()); + Mat dst = _dst.getMat(); + svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst); +} + +template inline void + SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt ) +{ + CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector."); + Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false); + SVD::compute(_a, _w, _u, _vt); + CV_Assert(_w.data == (uchar*)&w.val[0] && _u.data == (uchar*)&u.val[0] && _vt.data == (uchar*)&vt.val[0]); +} + +template inline void +SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w ) +{ + CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector."); + Mat _a(a, false), _w(w, false); + SVD::compute(_a, _w); + CV_Assert(_w.data == (uchar*)&w.val[0]); +} + +template inline void +SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u, + const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, + Matx<_Tp, n, nb>& dst ) +{ + CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector."); + Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false); + SVD::backSubst(_w, _u, _vt, _rhs, _dst); + CV_Assert(_dst.data == (uchar*)&dst.val[0]); +} + + + +/////////////////////////////////// Multiply-with-Carry RNG /////////////////////////////////// + +inline RNG::RNG() { state = 0xffffffff; } +inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; } + +inline RNG::operator uchar() { return (uchar)next(); } +inline RNG::operator schar() { return (schar)next(); } +inline RNG::operator ushort() { return (ushort)next(); } +inline RNG::operator short() { return (short)next(); } +inline RNG::operator int() { return (int)next(); } +inline RNG::operator unsigned() { return next(); } +inline RNG::operator float() { return next()*2.3283064365386962890625e-10f; } +inline RNG::operator double() { unsigned t = next(); return (((uint64)t << 32) | next()) * 5.4210108624275221700372640043497e-20; } + +inline unsigned RNG::operator ()(unsigned N) { return (unsigned)uniform(0,N); } +inline unsigned RNG::operator ()() { return next(); } + +inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next() % (b - a) + a); } +inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; } +inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; } + +inline bool RNG::operator ==(const RNG& other) const { return state == other.state; } + +inline unsigned RNG::next() +{ + state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32); + return (unsigned)state; +} + +//! returns the next uniformly-distributed random number of the specified type +template static inline _Tp randu() +{ + return (_Tp)theRNG(); +} + +///////////////////////////////// Formatted string generation ///////////////////////////////// + +/** @brief Returns a text string formatted using the printf-like expression. + +The function acts like sprintf but forms and returns an STL string. It can be used to form an error +message in the Exception constructor. +@param fmt printf-compatible formatting specifiers. + +**Note**: +|Type|Specifier| +|-|-| +|`const char*`|`%s`| +|`char`|`%c`| +|`float` / `double`|`%f`,`%g`| +|`int`, `long`, `long long`|`%d`, `%ld`, ``%lld`| +|`unsigned`, `unsigned long`, `unsigned long long`|`%u`, `%lu`, `%llu`| +|`uint64` -> `uintmax_t`, `int64` -> `intmax_t`|`%ju`, `%jd`| +|`size_t`|`%zu`| + */ +CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2); + +///////////////////////////////// Formatted output of cv::Mat ///////////////////////////////// + +static inline +Ptr format(InputArray mtx, Formatter::FormatType fmt) +{ + return Formatter::get(fmt)->format(mtx.getMat()); +} + +static inline +int print(Ptr fmtd, FILE* stream = stdout) +{ + int written = 0; + fmtd->reset(); + for(const char* str = fmtd->next(); str; str = fmtd->next()) + written += fputs(str, stream); + + return written; +} + +static inline +int print(const Mat& mtx, FILE* stream = stdout) +{ + return print(Formatter::get()->format(mtx), stream); +} + +static inline +int print(const UMat& mtx, FILE* stream = stdout) +{ + return print(Formatter::get()->format(mtx.getMat(ACCESS_READ)), stream); +} + +template static inline +int print(const std::vector >& vec, FILE* stream = stdout) +{ + return print(Formatter::get()->format(Mat(vec)), stream); +} + +template static inline +int print(const std::vector >& vec, FILE* stream = stdout) +{ + return print(Formatter::get()->format(Mat(vec)), stream); +} + +template static inline +int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout) +{ + return print(Formatter::get()->format(cv::Mat(matx)), stream); +} + +//! @endcond + +/****************************************************************************************\ +* Auxiliary algorithms * +\****************************************************************************************/ + +/** @brief Splits an element set into equivalency classes. + +The generic function partition implements an \f$O(N^2)\f$ algorithm for splitting a set of \f$N\f$ elements +into one or more equivalency classes, as described in + . The function returns the number of +equivalency classes. +@param _vec Set of elements stored as a vector. +@param labels Output vector of labels. It contains as many elements as vec. Each label labels[i] is +a 0-based cluster index of `vec[i]`. +@param predicate Equivalence predicate (pointer to a boolean function of two arguments or an +instance of the class that has the method bool operator()(const _Tp& a, const _Tp& b) ). The +predicate returns true when the elements are certainly in the same class, and returns false if they +may or may not be in the same class. +@ingroup core_cluster +*/ +template int +partition( const std::vector<_Tp>& _vec, std::vector& labels, + _EqPredicate predicate=_EqPredicate()) +{ + int i, j, N = (int)_vec.size(); + const _Tp* vec = &_vec[0]; + + const int PARENT=0; + const int RANK=1; + + std::vector _nodes(N*2); + int (*nodes)[2] = (int(*)[2])&_nodes[0]; + + // The first O(N) pass: create N single-vertex trees + for(i = 0; i < N; i++) + { + nodes[i][PARENT]=-1; + nodes[i][RANK] = 0; + } + + // The main O(N^2) pass: merge connected components + for( i = 0; i < N; i++ ) + { + int root = i; + + // find root + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + + for( j = 0; j < N; j++ ) + { + if( i == j || !predicate(vec[i], vec[j])) + continue; + int root2 = j; + + while( nodes[root2][PARENT] >= 0 ) + root2 = nodes[root2][PARENT]; + + if( root2 != root ) + { + // unite both trees + int rank = nodes[root][RANK], rank2 = nodes[root2][RANK]; + if( rank > rank2 ) + nodes[root2][PARENT] = root; + else + { + nodes[root][PARENT] = root2; + nodes[root2][RANK] += rank == rank2; + root = root2; + } + CV_Assert( nodes[root][PARENT] < 0 ); + + int k = j, parent; + + // compress the path from node2 to root + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + + // compress the path from node to root + k = i; + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + } + } + } + + // Final O(N) pass: enumerate classes + labels.resize(N); + int nclasses = 0; + + for( i = 0; i < N; i++ ) + { + int root = i; + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + // re-use the rank as the class label + if( nodes[root][RANK] >= 0 ) + nodes[root][RANK] = ~nclasses++; + labels[i] = ~nodes[root][RANK]; + } + + return nclasses; +} + +} // cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/optim.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/optim.hpp new file mode 100644 index 0000000..f61a2b9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/optim.hpp @@ -0,0 +1,302 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the OpenCV Foundation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OPTIM_HPP +#define OPENCV_OPTIM_HPP + +#include "opencv2/core.hpp" + +namespace cv +{ + +/** @addtogroup core_optim +The algorithms in this section minimize or maximize function value within specified constraints or +without any constraints. +@{ +*/ + +/** @brief Basic interface for all solvers + */ +class CV_EXPORTS MinProblemSolver : public Algorithm +{ +public: + /** @brief Represents function being optimized + */ + class CV_EXPORTS Function + { + public: + virtual ~Function() {} + virtual int getDims() const = 0; + virtual double getGradientEps() const; + virtual double calc(const double* x) const = 0; + virtual void getGradient(const double* x,double* grad); + }; + + /** @brief Getter for the optimized function. + + The optimized function is represented by Function interface, which requires derivatives to + implement the calc(double*) and getDim() methods to evaluate the function. + + @return Smart-pointer to an object that implements Function interface - it represents the + function that is being optimized. It can be empty, if no function was given so far. + */ + virtual Ptr getFunction() const = 0; + + /** @brief Setter for the optimized function. + + *It should be called at least once before the call to* minimize(), as default value is not usable. + + @param f The new function to optimize. + */ + virtual void setFunction(const Ptr& f) = 0; + + /** @brief Getter for the previously set terminal criteria for this algorithm. + + @return Deep copy of the terminal criteria used at the moment. + */ + virtual TermCriteria getTermCriteria() const = 0; + + /** @brief Set terminal criteria for solver. + + This method *is not necessary* to be called before the first call to minimize(), as the default + value is sensible. + + Algorithm stops when the number of function evaluations done exceeds termcrit.maxCount, when + the function values at the vertices of simplex are within termcrit.epsilon range or simplex + becomes so small that it can enclosed in a box with termcrit.epsilon sides, whatever comes + first. + @param termcrit Terminal criteria to be used, represented as cv::TermCriteria structure. + */ + virtual void setTermCriteria(const TermCriteria& termcrit) = 0; + + /** @brief actually runs the algorithm and performs the minimization. + + The sole input parameter determines the centroid of the starting simplex (roughly, it tells + where to start), all the others (terminal criteria, initial step, function to be minimized) are + supposed to be set via the setters before the call to this method or the default values (not + always sensible) will be used. + + @param x The initial point, that will become a centroid of an initial simplex. After the algorithm + will terminate, it will be set to the point where the algorithm stops, the point of possible + minimum. + @return The value of a function at the point found. + */ + virtual double minimize(InputOutputArray x) = 0; +}; + +/** @brief This class is used to perform the non-linear non-constrained minimization of a function, + +defined on an `n`-dimensional Euclidean space, using the **Nelder-Mead method**, also known as +**downhill simplex method**. The basic idea about the method can be obtained from +. + +It should be noted, that this method, although deterministic, is rather a heuristic and therefore +may converge to a local minima, not necessary a global one. It is iterative optimization technique, +which at each step uses an information about the values of a function evaluated only at `n+1` +points, arranged as a *simplex* in `n`-dimensional space (hence the second name of the method). At +each step new point is chosen to evaluate function at, obtained value is compared with previous +ones and based on this information simplex changes it's shape , slowly moving to the local minimum. +Thus this method is using *only* function values to make decision, on contrary to, say, Nonlinear +Conjugate Gradient method (which is also implemented in optim). + +Algorithm stops when the number of function evaluations done exceeds termcrit.maxCount, when the +function values at the vertices of simplex are within termcrit.epsilon range or simplex becomes so +small that it can enclosed in a box with termcrit.epsilon sides, whatever comes first, for some +defined by user positive integer termcrit.maxCount and positive non-integer termcrit.epsilon. + +@note DownhillSolver is a derivative of the abstract interface +cv::MinProblemSolver, which in turn is derived from the Algorithm interface and is used to +encapsulate the functionality, common to all non-linear optimization algorithms in the optim +module. + +@note term criteria should meet following condition: +@code + termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0 +@endcode + */ +class CV_EXPORTS DownhillSolver : public MinProblemSolver +{ +public: + /** @brief Returns the initial step that will be used in downhill simplex algorithm. + + @param step Initial step that will be used in algorithm. Note, that although corresponding setter + accepts column-vectors as well as row-vectors, this method will return a row-vector. + @see DownhillSolver::setInitStep + */ + virtual void getInitStep(OutputArray step) const=0; + + /** @brief Sets the initial step that will be used in downhill simplex algorithm. + + Step, together with initial point (given in DownhillSolver::minimize) are two `n`-dimensional + vectors that are used to determine the shape of initial simplex. Roughly said, initial point + determines the position of a simplex (it will become simplex's centroid), while step determines the + spread (size in each dimension) of a simplex. To be more precise, if \f$s,x_0\in\mathbb{R}^n\f$ are + the initial step and initial point respectively, the vertices of a simplex will be: + \f$v_0:=x_0-\frac{1}{2} s\f$ and \f$v_i:=x_0+s_i\f$ for \f$i=1,2,\dots,n\f$ where \f$s_i\f$ denotes + projections of the initial step of *n*-th coordinate (the result of projection is treated to be + vector given by \f$s_i:=e_i\cdot\left\f$, where \f$e_i\f$ form canonical basis) + + @param step Initial step that will be used in algorithm. Roughly said, it determines the spread + (size in each dimension) of an initial simplex. + */ + virtual void setInitStep(InputArray step)=0; + + /** @brief This function returns the reference to the ready-to-use DownhillSolver object. + + All the parameters are optional, so this procedure can be called even without parameters at + all. In this case, the default values will be used. As default value for terminal criteria are + the only sensible ones, MinProblemSolver::setFunction() and DownhillSolver::setInitStep() + should be called upon the obtained object, if the respective parameters were not given to + create(). Otherwise, the two ways (give parameters to createDownhillSolver() or miss them out + and call the MinProblemSolver::setFunction() and DownhillSolver::setInitStep()) are absolutely + equivalent (and will drop the same errors in the same way, should invalid input be detected). + @param f Pointer to the function that will be minimized, similarly to the one you submit via + MinProblemSolver::setFunction. + @param initStep Initial step, that will be used to construct the initial simplex, similarly to the one + you submit via MinProblemSolver::setInitStep. + @param termcrit Terminal criteria to the algorithm, similarly to the one you submit via + MinProblemSolver::setTermCriteria. + */ + static Ptr create(const Ptr& f=Ptr(), + InputArray initStep=Mat_(1,1,0.0), + TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5000,0.000001)); +}; + +/** @brief This class is used to perform the non-linear non-constrained minimization of a function +with known gradient, + +defined on an *n*-dimensional Euclidean space, using the **Nonlinear Conjugate Gradient method**. +The implementation was done based on the beautifully clear explanatory article [An Introduction to +the Conjugate Gradient Method Without the Agonizing +Pain](http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf) by Jonathan Richard +Shewchuk. The method can be seen as an adaptation of a standard Conjugate Gradient method (see, for +example ) for numerically solving the +systems of linear equations. + +It should be noted, that this method, although deterministic, is rather a heuristic method and +therefore may converge to a local minima, not necessary a global one. What is even more disastrous, +most of its behaviour is ruled by gradient, therefore it essentially cannot distinguish between +local minima and maxima. Therefore, if it starts sufficiently near to the local maximum, it may +converge to it. Another obvious restriction is that it should be possible to compute the gradient of +a function at any point, thus it is preferable to have analytic expression for gradient and +computational burden should be born by the user. + +The latter responsibility is accomplished via the getGradient method of a +MinProblemSolver::Function interface (which represents function being optimized). This method takes +point a point in *n*-dimensional space (first argument represents the array of coordinates of that +point) and compute its gradient (it should be stored in the second argument as an array). + +@note class ConjGradSolver thus does not add any new methods to the basic MinProblemSolver interface. + +@note term criteria should meet following condition: +@code + termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0 + // or + termcrit.type == TermCriteria::MAX_ITER) && termcrit.maxCount > 0 +@endcode + */ +class CV_EXPORTS ConjGradSolver : public MinProblemSolver +{ +public: + /** @brief This function returns the reference to the ready-to-use ConjGradSolver object. + + All the parameters are optional, so this procedure can be called even without parameters at + all. In this case, the default values will be used. As default value for terminal criteria are + the only sensible ones, MinProblemSolver::setFunction() should be called upon the obtained + object, if the function was not given to create(). Otherwise, the two ways (submit it to + create() or miss it out and call the MinProblemSolver::setFunction()) are absolutely equivalent + (and will drop the same errors in the same way, should invalid input be detected). + @param f Pointer to the function that will be minimized, similarly to the one you submit via + MinProblemSolver::setFunction. + @param termcrit Terminal criteria to the algorithm, similarly to the one you submit via + MinProblemSolver::setTermCriteria. + */ + static Ptr create(const Ptr& f=Ptr(), + TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5000,0.000001)); +}; + +//! return codes for cv::solveLP() function +enum SolveLPResult +{ + SOLVELP_UNBOUNDED = -2, //!< problem is unbounded (target function can achieve arbitrary high values) + SOLVELP_UNFEASIBLE = -1, //!< problem is unfeasible (there are no points that satisfy all the constraints imposed) + SOLVELP_SINGLE = 0, //!< there is only one maximum for target function + SOLVELP_MULTI = 1 //!< there are multiple maxima for target function - the arbitrary one is returned +}; + +/** @brief Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method). + +What we mean here by "linear programming problem" (or LP problem, for short) can be formulated as: + +\f[\mbox{Maximize } c\cdot x\\ + \mbox{Subject to:}\\ + Ax\leq b\\ + x\geq 0\f] + +Where \f$c\f$ is fixed `1`-by-`n` row-vector, \f$A\f$ is fixed `m`-by-`n` matrix, \f$b\f$ is fixed `m`-by-`1` +column vector and \f$x\f$ is an arbitrary `n`-by-`1` column vector, which satisfies the constraints. + +Simplex algorithm is one of many algorithms that are designed to handle this sort of problems +efficiently. Although it is not optimal in theoretical sense (there exist algorithms that can solve +any problem written as above in polynomial time, while simplex method degenerates to exponential +time for some special cases), it is well-studied, easy to implement and is shown to work well for +real-life purposes. + +The particular implementation is taken almost verbatim from **Introduction to Algorithms, third +edition** by T. H. Cormen, C. E. Leiserson, R. L. Rivest and Clifford Stein. In particular, the +Bland's rule is used to prevent cycling. + +@param Func This row-vector corresponds to \f$c\f$ in the LP problem formulation (see above). It should +contain 32- or 64-bit floating point numbers. As a convenience, column-vector may be also submitted, +in the latter case it is understood to correspond to \f$c^T\f$. +@param Constr `m`-by-`n+1` matrix, whose rightmost column corresponds to \f$b\f$ in formulation above +and the remaining to \f$A\f$. It should contain 32- or 64-bit floating point numbers. +@param z The solution will be returned here as a column-vector - it corresponds to \f$c\f$ in the +formulation above. It will contain 64-bit floating point numbers. +@return One of cv::SolveLPResult + */ +CV_EXPORTS_W int solveLP(InputArray Func, InputArray Constr, OutputArray z); + +//! @} + +}// cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/ovx.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/ovx.hpp new file mode 100644 index 0000000..8bb7d54 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/ovx.hpp @@ -0,0 +1,28 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2016, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +// OpenVX related definitions and declarations + +#pragma once +#ifndef OPENCV_OVX_HPP +#define OPENCV_OVX_HPP + +#include "cvdef.h" + +namespace cv +{ +/// Check if use of OpenVX is possible +CV_EXPORTS_W bool haveOpenVX(); + +/// Check if use of OpenVX is enabled +CV_EXPORTS_W bool useOpenVX(); + +/// Enable/disable use of OpenVX +CV_EXPORTS_W void setUseOpenVX(bool flag); +} // namespace cv + +#endif // OPENCV_OVX_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp new file mode 100644 index 0000000..b172cac --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp @@ -0,0 +1,72 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP +#define OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP + +#include "opencv2/core/parallel/parallel_backend.hpp" + +#if !defined(_OPENMP) && !defined(OPENCV_SKIP_OPENMP_PRESENSE_CHECK) +#error "This file must be compiled with enabled OpenMP" +#endif + +#include + +namespace cv { namespace parallel { namespace openmp { + +/** OpenMP parallel_for API implementation + * + * @sa setParallelForBackend + * @ingroup core_parallel_backend + */ +class ParallelForBackend : public ParallelForAPI +{ +protected: + int numThreads; + int numThreadsMax; +public: + ParallelForBackend() + { + numThreads = 0; + numThreadsMax = omp_get_max_threads(); + } + + virtual ~ParallelForBackend() {} + + virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) CV_OVERRIDE + { +#pragma omp parallel for schedule(dynamic) num_threads(numThreads > 0 ? numThreads : numThreadsMax) + for (int i = 0; i < tasks; ++i) + body_callback(i, i + 1, callback_data); + } + + virtual int getThreadNum() const CV_OVERRIDE + { + return omp_get_thread_num(); + } + + virtual int getNumThreads() const CV_OVERRIDE + { + return numThreads > 0 + ? numThreads + : numThreadsMax; + } + + virtual int setNumThreads(int nThreads) CV_OVERRIDE + { + int oldNumThreads = numThreads; + numThreads = nThreads; + // nothing needed as numThreads is used in #pragma omp parallel for directly + return oldNumThreads; + } + + const char* getName() const CV_OVERRIDE + { + return "openmp"; + } +}; + +}}} // namespace + +#endif // OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp new file mode 100644 index 0000000..04b0c4c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp @@ -0,0 +1,153 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_PARALLEL_FOR_TBB_HPP +#define OPENCV_CORE_PARALLEL_FOR_TBB_HPP + +#include "opencv2/core/parallel/parallel_backend.hpp" +#include + +#ifndef TBB_SUPPRESS_DEPRECATED_MESSAGES // supress warning +#define TBB_SUPPRESS_DEPRECATED_MESSAGES 1 +#endif +#include "tbb/tbb.h" +#if !defined(TBB_INTERFACE_VERSION) +#error "Unknows/unsupported TBB version" +#endif + +#if TBB_INTERFACE_VERSION >= 8000 +#include "tbb/task_arena.h" +#endif + +namespace cv { namespace parallel { namespace tbb { + +using namespace ::tbb; + +#if TBB_INTERFACE_VERSION >= 8000 +static tbb::task_arena& getArena() +{ + static tbb::task_arena tbbArena(tbb::task_arena::automatic); + return tbbArena; +} +#else +static tbb::task_scheduler_init& getScheduler() +{ + static tbb::task_scheduler_init tbbScheduler(tbb::task_scheduler_init::deferred); + return tbbScheduler; +} +#endif + +/** TBB parallel_for API implementation + * + * @sa setParallelForBackend + * @ingroup core_parallel_backend + */ +class ParallelForBackend : public ParallelForAPI +{ +protected: + int numThreads; + int numThreadsMax; +public: + ParallelForBackend() + { + CV_LOG_INFO(NULL, "Initializing TBB parallel backend: TBB_INTERFACE_VERSION=" << TBB_INTERFACE_VERSION); + numThreads = 0; +#if TBB_INTERFACE_VERSION >= 8000 + (void)getArena(); +#else + (void)getScheduler(); +#endif + } + + virtual ~ParallelForBackend() {} + + class CallbackProxy + { + const FN_parallel_for_body_cb_t& callback; + void* const callback_data; + const int tasks; + public: + inline CallbackProxy(int tasks_, FN_parallel_for_body_cb_t& callback_, void* callback_data_) + : callback(callback_), callback_data(callback_data_), tasks(tasks_) + { + // nothing + } + + void operator()(const tbb::blocked_range& range) const + { + this->callback(range.begin(), range.end(), callback_data); + } + + void operator()() const + { + tbb::parallel_for(tbb::blocked_range(0, tasks), *this); + } + }; + + virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) CV_OVERRIDE + { + CallbackProxy task(tasks, body_callback, callback_data); +#if TBB_INTERFACE_VERSION >= 8000 + getArena().execute(task); +#else + task(); +#endif + } + + virtual int getThreadNum() const CV_OVERRIDE + { +#if TBB_INTERFACE_VERSION >= 9100 + return tbb::this_task_arena::current_thread_index(); +#elif TBB_INTERFACE_VERSION >= 8000 + return tbb::task_arena::current_thread_index(); +#else + return 0; +#endif + } + + virtual int getNumThreads() const CV_OVERRIDE + { +#if TBB_INTERFACE_VERSION >= 9100 + return getArena().max_concurrency(); +#elif TBB_INTERFACE_VERSION >= 8000 + return numThreads > 0 + ? numThreads + : tbb::task_scheduler_init::default_num_threads(); +#else + return getScheduler().is_active() + ? numThreads + : tbb::task_scheduler_init::default_num_threads(); +#endif + } + + virtual int setNumThreads(int nThreads) CV_OVERRIDE + { + int oldNumThreads = numThreads; + numThreads = nThreads; + +#if TBB_INTERFACE_VERSION >= 8000 + auto& tbbArena = getArena(); + if (tbbArena.is_active()) + tbbArena.terminate(); + if (numThreads > 0) + tbbArena.initialize(numThreads); +#else + auto& tbbScheduler = getScheduler(); + if (tbbScheduler.is_active()) + tbbScheduler.terminate(); + if (numThreads > 0) + tbbScheduler.initialize(numThreads); +#endif + return oldNumThreads; + } + + const char* getName() const CV_OVERRIDE + { + return "tbb"; + } +}; + +}}} // namespace + +#endif // OPENCV_CORE_PARALLEL_FOR_TBB_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/parallel_backend.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/parallel_backend.hpp new file mode 100644 index 0000000..c3e8333 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/parallel/parallel_backend.hpp @@ -0,0 +1,90 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_PARALLEL_BACKEND_HPP +#define OPENCV_CORE_PARALLEL_BACKEND_HPP + +#include "opencv2/core/cvdef.h" +#include + +namespace cv { namespace parallel { +#ifndef CV_API_CALL +#define CV_API_CALL +#endif + +/** @addtogroup core_parallel_backend + * @{ + * API below is provided to resolve problem of CPU resource over-subscription by multiple thread pools from different multi-threading frameworks. + * This is common problem for cases when OpenCV compiled threading framework is different from the Users Applications framework. + * + * Applications can replace OpenCV `parallel_for()` backend with own implementation (to reuse Application's thread pool). + * + * + * ### Backend API usage examples + * + * #### Intel TBB + * + * - include header with simple implementation of TBB backend: + * @snippet parallel_backend/example-tbb.cpp tbb_include + * - execute backend replacement code: + * @snippet parallel_backend/example-tbb.cpp tbb_backend + * - configuration of compiler/linker options is responsibility of Application's scripts + * + * #### OpenMP + * + * - include header with simple implementation of OpenMP backend: + * @snippet parallel_backend/example-openmp.cpp openmp_include + * - execute backend replacement code: + * @snippet parallel_backend/example-openmp.cpp openmp_backend + * - Configuration of compiler/linker options is responsibility of Application's scripts + * + * + * ### Plugins support + * + * Runtime configuration options: + * - change backend priority: `OPENCV_PARALLEL_PRIORITY_=9999` + * - disable backend: `OPENCV_PARALLEL_PRIORITY_=0` + * - specify list of backends with high priority (>100000): `OPENCV_PARALLEL_PRIORITY_LIST=TBB,OPENMP`. Unknown backends are registered as new plugins. + * + */ + +/** Interface for parallel_for backends implementations + * + * @sa setParallelForBackend + */ +class CV_EXPORTS ParallelForAPI +{ +public: + virtual ~ParallelForAPI(); + + typedef void (CV_API_CALL *FN_parallel_for_body_cb_t)(int start, int end, void* data); + + virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) = 0; + + virtual int getThreadNum() const = 0; + + virtual int getNumThreads() const = 0; + + virtual int setNumThreads(int nThreads) = 0; + + virtual const char* getName() const = 0; +}; + +/** @brief Replace OpenCV parallel_for backend + * + * Application can replace OpenCV `parallel_for()` backend with own implementation. + * + * @note This call is not thread-safe. Consider calling this function from the `main()` before any other OpenCV processing functions (and without any other created threads). + */ +CV_EXPORTS void setParallelForBackend(const std::shared_ptr& api, bool propagateNumThreads = true); + +/** @brief Change OpenCV parallel_for backend + * + * @note This call is not thread-safe. Consider calling this function from the `main()` before any other OpenCV processing functions (and without any other created threads). + */ +CV_EXPORTS_W bool setParallelForBackend(const std::string& backendName, bool propagateNumThreads = true); + +//! @} +}} // namespace +#endif // OPENCV_CORE_PARALLEL_BACKEND_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/persistence.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/persistence.hpp new file mode 100644 index 0000000..276f640 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/persistence.hpp @@ -0,0 +1,1350 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_PERSISTENCE_HPP +#define OPENCV_CORE_PERSISTENCE_HPP + +#ifndef CV_DOXYGEN +/// Define to support persistence legacy formats +#define CV__LEGACY_PERSISTENCE +#endif + +#ifndef __cplusplus +# error persistence.hpp header must be compiled as C++ +#endif + +//! @addtogroup core_c +//! @{ + +/** @brief "black box" representation of the file storage associated with a file on disk. + +Several functions that are described below take CvFileStorage\* as inputs and allow the user to +save or to load hierarchical collections that consist of scalar values, standard CXCore objects +(such as matrices, sequences, graphs), and user-defined objects. + +OpenCV can read and write data in XML (), YAML () or +JSON () formats. Below is an example of 3x3 floating-point identity matrix A, +stored in XML and YAML files +using CXCore functions: +XML: +@code{.xml} + + + + 3 + 3 +
f
+ 1. 0. 0. 0. 1. 0. 0. 0. 1. +
+
+@endcode +YAML: +@code{.yaml} + %YAML:1.0 + A: !!opencv-matrix + rows: 3 + cols: 3 + dt: f + data: [ 1., 0., 0., 0., 1., 0., 0., 0., 1.] +@endcode +As it can be seen from the examples, XML uses nested tags to represent hierarchy, while YAML uses +indentation for that purpose (similar to the Python programming language). + +The same functions can read and write data in both formats; the particular format is determined by +the extension of the opened file, ".xml" for XML files, ".yml" or ".yaml" for YAML and ".json" for +JSON. + */ + +//! @} core_c + +#include "opencv2/core/types.hpp" +#include "opencv2/core/mat.hpp" + +namespace cv { + +/** @addtogroup core_xml + +XML/YAML/JSON file storages. {#xml_storage} +======================= +Writing to a file storage. +-------------------------- +You can store and then restore various OpenCV data structures to/from XML (), +YAML () or JSON () formats. Also, it is possible to store +and load arbitrarily complex data structures, which include OpenCV data structures, as well as +primitive data types (integer and floating-point numbers and text strings) as their elements. + +Use the following procedure to write something to XML, YAML or JSON: +-# Create new FileStorage and open it for writing. It can be done with a single call to +FileStorage::FileStorage constructor that takes a filename, or you can use the default constructor +and then call FileStorage::open. Format of the file (XML, YAML or JSON) is determined from the filename +extension (".xml", ".yml"/".yaml" and ".json", respectively) +-# Write all the data you want using the streaming operator `<<`, just like in the case of STL +streams. +-# Close the file using FileStorage::release. FileStorage destructor also closes the file. + +Here is an example: +@code + #include "opencv2/core.hpp" + #include + + using namespace cv; + + int main(int, char** argv) + { + FileStorage fs("test.yml", FileStorage::WRITE); + + fs << "frameCount" << 5; + time_t rawtime; time(&rawtime); + fs << "calibrationDate" << asctime(localtime(&rawtime)); + Mat cameraMatrix = (Mat_(3,3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1); + Mat distCoeffs = (Mat_(5,1) << 0.1, 0.01, -0.001, 0, 0); + fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs; + fs << "features" << "["; + for( int i = 0; i < 3; i++ ) + { + int x = rand() % 640; + int y = rand() % 480; + uchar lbp = rand() % 256; + + fs << "{:" << "x" << x << "y" << y << "lbp" << "[:"; + for( int j = 0; j < 8; j++ ) + fs << ((lbp >> j) & 1); + fs << "]" << "}"; + } + fs << "]"; + fs.release(); + return 0; + } +@endcode +The sample above stores to YML an integer, a text string (calibration date), 2 matrices, and a custom +structure "feature", which includes feature coordinates and LBP (local binary pattern) value. Here +is output of the sample: +@code{.yaml} +%YAML:1.0 +frameCount: 5 +calibrationDate: "Fri Jun 17 14:09:29 2011\n" +cameraMatrix: !!opencv-matrix + rows: 3 + cols: 3 + dt: d + data: [ 1000., 0., 320., 0., 1000., 240., 0., 0., 1. ] +distCoeffs: !!opencv-matrix + rows: 5 + cols: 1 + dt: d + data: [ 1.0000000000000001e-01, 1.0000000000000000e-02, + -1.0000000000000000e-03, 0., 0. ] +features: + - { x:167, y:49, lbp:[ 1, 0, 0, 1, 1, 0, 1, 1 ] } + - { x:298, y:130, lbp:[ 0, 0, 0, 1, 0, 0, 1, 1 ] } + - { x:344, y:158, lbp:[ 1, 1, 0, 0, 0, 0, 1, 0 ] } +@endcode + +As an exercise, you can replace ".yml" with ".xml" or ".json" in the sample above and see, how the +corresponding XML file will look like. + +Several things can be noted by looking at the sample code and the output: + +- The produced YAML (and XML/JSON) consists of heterogeneous collections that can be nested. There are + 2 types of collections: named collections (mappings) and unnamed collections (sequences). In mappings + each element has a name and is accessed by name. This is similar to structures and std::map in + C/C++ and dictionaries in Python. In sequences elements do not have names, they are accessed by + indices. This is similar to arrays and std::vector in C/C++ and lists, tuples in Python. + "Heterogeneous" means that elements of each single collection can have different types. + + Top-level collection in YAML/XML/JSON is a mapping. Each matrix is stored as a mapping, and the matrix + elements are stored as a sequence. Then, there is a sequence of features, where each feature is + represented a mapping, and lbp value in a nested sequence. + +- When you write to a mapping (a structure), you write element name followed by its value. When you + write to a sequence, you simply write the elements one by one. OpenCV data structures (such as + cv::Mat) are written in absolutely the same way as simple C data structures - using `<<` + operator. + +- To write a mapping, you first write the special string `{` to the storage, then write the + elements as pairs (`fs << << `) and then write the closing + `}`. + +- To write a sequence, you first write the special string `[`, then write the elements, then + write the closing `]`. + +- In YAML/JSON (but not XML), mappings and sequences can be written in a compact Python-like inline + form. In the sample above matrix elements, as well as each feature, including its lbp value, is + stored in such inline form. To store a mapping/sequence in a compact form, put `:` after the + opening character, e.g. use `{:` instead of `{` and `[:` instead of `[`. When the + data is written to XML, those extra `:` are ignored. + +Reading data from a file storage. +--------------------------------- +To read the previously written XML, YAML or JSON file, do the following: +-# Open the file storage using FileStorage::FileStorage constructor or FileStorage::open method. + In the current implementation the whole file is parsed and the whole representation of file + storage is built in memory as a hierarchy of file nodes (see FileNode) + +-# Read the data you are interested in. Use FileStorage::operator [], FileNode::operator [] + and/or FileNodeIterator. + +-# Close the storage using FileStorage::release. + +Here is how to read the file created by the code sample above: +@code + FileStorage fs2("test.yml", FileStorage::READ); + + // first method: use (type) operator on FileNode. + int frameCount = (int)fs2["frameCount"]; + + String date; + // second method: use FileNode::operator >> + fs2["calibrationDate"] >> date; + + Mat cameraMatrix2, distCoeffs2; + fs2["cameraMatrix"] >> cameraMatrix2; + fs2["distCoeffs"] >> distCoeffs2; + + cout << "frameCount: " << frameCount << endl + << "calibration date: " << date << endl + << "camera matrix: " << cameraMatrix2 << endl + << "distortion coeffs: " << distCoeffs2 << endl; + + FileNode features = fs2["features"]; + FileNodeIterator it = features.begin(), it_end = features.end(); + int idx = 0; + std::vector lbpval; + + // iterate through a sequence using FileNodeIterator + for( ; it != it_end; ++it, idx++ ) + { + cout << "feature #" << idx << ": "; + cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp: ("; + // you can also easily read numerical arrays using FileNode >> std::vector operator. + (*it)["lbp"] >> lbpval; + for( int i = 0; i < (int)lbpval.size(); i++ ) + cout << " " << (int)lbpval[i]; + cout << ")" << endl; + } + fs2.release(); +@endcode + +Format specification {#format_spec} +-------------------- +`([count]{u|c|w|s|i|f|d})`... where the characters correspond to fundamental C++ types: +- `u` 8-bit unsigned number +- `c` 8-bit signed number +- `w` 16-bit unsigned number +- `s` 16-bit signed number +- `i` 32-bit signed number +- `f` single precision floating-point number +- `d` double precision floating-point number +- `r` pointer, 32 lower bits of which are written as a signed integer. The type can be used to + store structures with links between the elements. + +`count` is the optional counter of values of a given type. For example, `2if` means that each array +element is a structure of 2 integers, followed by a single-precision floating-point number. The +equivalent notations of the above specification are `iif`, `2i1f` and so forth. Other examples: `u` +means that the array consists of bytes, and `2d` means the array consists of pairs of doubles. + +@see @ref samples/cpp/filestorage.cpp +*/ + +//! @{ + +/** @example samples/cpp/filestorage.cpp +A complete example using the FileStorage interface +*/ + +////////////////////////// XML & YAML I/O ////////////////////////// + +class CV_EXPORTS FileNode; +class CV_EXPORTS FileNodeIterator; + +/** @brief XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or +reading data to/from a file. + */ +class CV_EXPORTS_W FileStorage +{ +public: + //! file storage mode + enum Mode + { + READ = 0, //!< value, open the file for reading + WRITE = 1, //!< value, open the file for writing + APPEND = 2, //!< value, open the file for appending + MEMORY = 4, //!< flag, read data from source or write data to the internal buffer (which is + //!< returned by FileStorage::release) + FORMAT_MASK = (7<<3), //!< mask for format flags + FORMAT_AUTO = 0, //!< flag, auto format + FORMAT_XML = (1<<3), //!< flag, XML format + FORMAT_YAML = (2<<3), //!< flag, YAML format + FORMAT_JSON = (3<<3), //!< flag, JSON format + + BASE64 = 64, //!< flag, write rawdata in Base64 by default. (consider using WRITE_BASE64) + WRITE_BASE64 = BASE64 | WRITE, //!< flag, enable both WRITE and BASE64 + }; + enum State + { + UNDEFINED = 0, + VALUE_EXPECTED = 1, + NAME_EXPECTED = 2, + INSIDE_MAP = 4 + }; + + /** @brief The constructors. + + The full constructor opens the file. Alternatively you can use the default constructor and then + call FileStorage::open. + */ + CV_WRAP FileStorage(); + + /** @overload + @copydoc open() + */ + CV_WRAP FileStorage(const String& filename, int flags, const String& encoding=String()); + + //! the destructor. calls release() + virtual ~FileStorage(); + + /** @brief Opens a file. + + See description of parameters in FileStorage::FileStorage. The method calls FileStorage::release + before opening the file. + @param filename Name of the file to open or the text string to read the data from. + Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON + respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both + FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify + the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters. + You can use this format, "*?base64" (e.g. "file.json?base64" (case sensitive)), as an alternative to + FileStorage::BASE64 flag. + @param flags Mode of operation. One of FileStorage::Mode + @param encoding Encoding of the file. Note that UTF-16 XML encoding is not supported currently and + you should use 8-bit encoding instead of it. + */ + CV_WRAP virtual bool open(const String& filename, int flags, const String& encoding=String()); + + /** @brief Checks whether the file is opened. + + @returns true if the object is associated with the current file and false otherwise. It is a + good practice to call this method after you tried to open a file. + */ + CV_WRAP virtual bool isOpened() const; + + /** @brief Closes the file and releases all the memory buffers. + + Call this method after all I/O operations with the storage are finished. + */ + CV_WRAP virtual void release(); + + /** @brief Closes the file and releases all the memory buffers. + + Call this method after all I/O operations with the storage are finished. If the storage was + opened for writing data and FileStorage::WRITE was specified + */ + CV_WRAP virtual String releaseAndGetString(); + + /** @brief Returns the first element of the top-level mapping. + @returns The first element of the top-level mapping. + */ + CV_WRAP FileNode getFirstTopLevelNode() const; + + /** @brief Returns the top-level mapping + @param streamidx Zero-based index of the stream. In most cases there is only one stream in the file. + However, YAML supports multiple streams and so there can be several. + @returns The top-level mapping. + */ + CV_WRAP FileNode root(int streamidx=0) const; + + /** @brief Returns the specified element of the top-level mapping. + @param nodename Name of the file node. + @returns Node with the given name. + */ + FileNode operator[](const String& nodename) const; + + /** @overload */ + CV_WRAP_AS(getNode) FileNode operator[](const char* nodename) const; + + /** + * @brief Simplified writing API to use with bindings. + * @param name Name of the written object. When writing to sequences (a.k.a. "arrays"), pass an empty string. + * @param val Value of the written object. + */ + CV_WRAP void write(const String& name, int val); + /// @overload + CV_WRAP void write(const String& name, double val); + /// @overload + CV_WRAP void write(const String& name, const String& val); + /// @overload + CV_WRAP void write(const String& name, const Mat& val); + /// @overload + CV_WRAP void write(const String& name, const std::vector& val); + + /** @brief Writes multiple numbers. + + Writes one or more numbers of the specified format to the currently written structure. Usually it is + more convenient to use operator `<<` instead of this method. + @param fmt Specification of each array element, see @ref format_spec "format specification" + @param vec Pointer to the written array. + @param len Number of the uchar elements to write. + */ + void writeRaw( const String& fmt, const void* vec, size_t len ); + + /** @brief Writes a comment. + + The function writes a comment into file storage. The comments are skipped when the storage is read. + @param comment The written comment, single-line or multi-line + @param append If true, the function tries to put the comment at the end of current line. + Else if the comment is multi-line, or if it does not fit at the end of the current + line, the comment starts a new line. + */ + CV_WRAP void writeComment(const String& comment, bool append = false); + + /** @brief Starts to write a nested structure (sequence or a mapping). + @param name name of the structure. When writing to sequences (a.k.a. "arrays"), pass an empty string. + @param flags type of the structure (FileNode::MAP or FileNode::SEQ (both with optional FileNode::FLOW)). + @param typeName optional name of the type you store. The effect of setting this depends on the storage format. + I.e. if the format has a specification for storing type information, this parameter is used. + */ + CV_WRAP void startWriteStruct(const String& name, int flags, const String& typeName=String()); + + /** @brief Finishes writing nested structure (should pair startWriteStruct()) + */ + CV_WRAP void endWriteStruct(); + + /** @brief Returns the normalized object name for the specified name of a file. + @param filename Name of a file + @returns The normalized object name. + */ + static String getDefaultObjectName(const String& filename); + + /** @brief Returns the current format. + * @returns The current format, see FileStorage::Mode + */ + CV_WRAP int getFormat() const; + + int state; + std::string elname; + + class Impl; + Ptr p; +}; + +/** @brief File Storage Node class. + +The node is used to store each and every element of the file storage opened for reading. When +XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of +nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of +other nodes. There can be named collections (mappings) where each element has a name and it is +accessed by a name, and ordered collections (sequences) where elements do not have names but rather +accessed by index. Type of the file node can be determined using FileNode::type method. + +Note that file nodes are only used for navigating file storages opened for reading. When a file +storage is opened for writing, no data is stored in memory after it is written. + */ +class CV_EXPORTS_W_SIMPLE FileNode +{ +public: + //! type of the file storage node + enum + { + NONE = 0, //!< empty node + INT = 1, //!< an integer + REAL = 2, //!< floating-point number + FLOAT = REAL, //!< synonym or REAL + STR = 3, //!< text string in UTF-8 encoding + STRING = STR, //!< synonym for STR + SEQ = 4, //!< sequence + MAP = 5, //!< mapping + TYPE_MASK = 7, + + FLOW = 8, //!< compact representation of a sequence or mapping. Used only by YAML writer + UNIFORM = 8, //!< if set, means that all the collection elements are numbers of the same type (real's or int's). + //!< UNIFORM is used only when reading FileStorage; FLOW is used only when writing. So they share the same bit + EMPTY = 16, //!< empty structure (sequence or mapping) + NAMED = 32 //!< the node has a name (i.e. it is element of a mapping). + }; + /** @brief The constructors. + + These constructors are used to create a default file node, construct it from obsolete structures or + from the another file node. + */ + CV_WRAP FileNode(); + + /** @overload + @param fs Pointer to the file storage structure. + @param blockIdx Index of the memory block where the file node is stored + @param ofs Offset in bytes from the beginning of the serialized storage + + @deprecated + */ + FileNode(const FileStorage* fs, size_t blockIdx, size_t ofs); + + /** @overload + @param node File node to be used as initialization for the created file node. + */ + FileNode(const FileNode& node); + + FileNode& operator=(const FileNode& node); + + /** @brief Returns element of a mapping node or a sequence node. + @param nodename Name of an element in the mapping node. + @returns Returns the element with the given identifier. + */ + FileNode operator[](const String& nodename) const; + + /** @overload + @param nodename Name of an element in the mapping node. + */ + CV_WRAP_AS(getNode) FileNode operator[](const char* nodename) const; + + /** @overload + @param i Index of an element in the sequence node. + */ + CV_WRAP_AS(at) FileNode operator[](int i) const; + + /** @brief Returns keys of a mapping node. + @returns Keys of a mapping node. + */ + CV_WRAP std::vector keys() const; + + /** @brief Returns type of the node. + @returns Type of the node. See FileNode::Type + */ + CV_WRAP int type() const; + + //! returns true if the node is empty + CV_WRAP bool empty() const; + //! returns true if the node is a "none" object + CV_WRAP bool isNone() const; + //! returns true if the node is a sequence + CV_WRAP bool isSeq() const; + //! returns true if the node is a mapping + CV_WRAP bool isMap() const; + //! returns true if the node is an integer + CV_WRAP bool isInt() const; + //! returns true if the node is a floating-point number + CV_WRAP bool isReal() const; + //! returns true if the node is a text string + CV_WRAP bool isString() const; + //! returns true if the node has a name + CV_WRAP bool isNamed() const; + //! returns the node name or an empty string if the node is nameless + CV_WRAP std::string name() const; + //! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise. + CV_WRAP size_t size() const; + //! returns raw size of the FileNode in bytes + CV_WRAP size_t rawSize() const; + //! returns the node content as an integer. If the node stores floating-point number, it is rounded. + operator int() const; + //! returns the node content as float + operator float() const; + //! returns the node content as double + operator double() const; + //! returns the node content as text string + inline operator std::string() const { return this->string(); } + + static bool isMap(int flags); + static bool isSeq(int flags); + static bool isCollection(int flags); + static bool isEmptyCollection(int flags); + static bool isFlow(int flags); + + uchar* ptr(); + const uchar* ptr() const; + + //! returns iterator pointing to the first node element + FileNodeIterator begin() const; + //! returns iterator pointing to the element following the last node element + FileNodeIterator end() const; + + /** @brief Reads node elements to the buffer with the specified format. + + Usually it is more convenient to use operator `>>` instead of this method. + @param fmt Specification of each array element. See @ref format_spec "format specification" + @param vec Pointer to the destination array. + @param len Number of bytes to read (buffer size limit). If it is greater than number of + remaining elements then all of them will be read. + */ + void readRaw( const String& fmt, void* vec, size_t len ) const; + + /** Internal method used when reading FileStorage. + Sets the type (int, real or string) and value of the previously created node. + */ + void setValue( int type, const void* value, int len=-1 ); + + //! Simplified reading API to use with bindings. + CV_WRAP double real() const; + //! Simplified reading API to use with bindings. + CV_WRAP std::string string() const; + //! Simplified reading API to use with bindings. + CV_WRAP Mat mat() const; + + //protected: + FileNode(FileStorage::Impl* fs, size_t blockIdx, size_t ofs); + + FileStorage::Impl* fs; + size_t blockIdx; + size_t ofs; +}; + + +/** @brief used to iterate through sequences and mappings. + + A standard STL notation, with node.begin(), node.end() denoting the beginning and the end of a + sequence, stored in node. See the data reading sample in the beginning of the section. + */ +class CV_EXPORTS FileNodeIterator +{ +public: + /** @brief The constructors. + + These constructors are used to create a default iterator, set it to specific element in a file node + or construct it from another iterator. + */ + FileNodeIterator(); + + /** @overload + @param node File node - the collection to iterate over; + it can be a scalar (equivalent to 1-element collection) or "none" (equivalent to empty collection). + @param seekEnd - true if iterator needs to be set after the last element of the node; + that is: + * node.begin() => FileNodeIterator(node, false) + * node.end() => FileNodeIterator(node, true) + */ + FileNodeIterator(const FileNode& node, bool seekEnd); + + /** @overload + @param it Iterator to be used as initialization for the created iterator. + */ + FileNodeIterator(const FileNodeIterator& it); + + FileNodeIterator& operator=(const FileNodeIterator& it); + + //! returns the currently observed element + FileNode operator *() const; + + //! moves iterator to the next node + FileNodeIterator& operator ++ (); + //! moves iterator to the next node + FileNodeIterator operator ++ (int); + //! moves iterator forward by the specified offset (possibly negative) + FileNodeIterator& operator += (int ofs); + + /** @brief Reads node elements to the buffer with the specified format. + + Usually it is more convenient to use operator `>>` instead of this method. + @param fmt Specification of each array element. See @ref format_spec "format specification" + @param vec Pointer to the destination array. + @param len Number of bytes to read (buffer size limit). If it is greater than number of + remaining elements then all of them will be read. + */ + FileNodeIterator& readRaw( const String& fmt, void* vec, + size_t len=(size_t)INT_MAX ); + + //! returns the number of remaining (not read yet) elements + size_t remaining() const; + + bool equalTo(const FileNodeIterator& it) const; + +protected: + FileStorage::Impl* fs; + size_t blockIdx; + size_t ofs; + size_t blockSize; + size_t nodeNElems; + size_t idx; +}; + +//! @} core_xml + +/////////////////// XML & YAML I/O implementation ////////////////// + +//! @relates cv::FileStorage +//! @{ + +CV_EXPORTS void write( FileStorage& fs, const String& name, int value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, float value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, double value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, const String& value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, const Mat& value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, const SparseMat& value ); +#ifdef CV__LEGACY_PERSISTENCE +CV_EXPORTS void write( FileStorage& fs, const String& name, const std::vector& value); +CV_EXPORTS void write( FileStorage& fs, const String& name, const std::vector& value); +#endif + +CV_EXPORTS void writeScalar( FileStorage& fs, int value ); +CV_EXPORTS void writeScalar( FileStorage& fs, float value ); +CV_EXPORTS void writeScalar( FileStorage& fs, double value ); +CV_EXPORTS void writeScalar( FileStorage& fs, const String& value ); + +//! @} + +//! @relates cv::FileNode +//! @{ + +CV_EXPORTS void read(const FileNode& node, int& value, int default_value); +CV_EXPORTS void read(const FileNode& node, float& value, float default_value); +CV_EXPORTS void read(const FileNode& node, double& value, double default_value); +CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value); +CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() ); +CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat = SparseMat() ); +#ifdef CV__LEGACY_PERSISTENCE +CV_EXPORTS void read(const FileNode& node, std::vector& keypoints); +CV_EXPORTS void read(const FileNode& node, std::vector& matches); +#endif +CV_EXPORTS void read(const FileNode& node, KeyPoint& value, const KeyPoint& default_value); +CV_EXPORTS void read(const FileNode& node, DMatch& value, const DMatch& default_value); + +template static inline void read(const FileNode& node, Point_<_Tp>& value, const Point_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 2 ? default_value : Point_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1])); +} + +template static inline void read(const FileNode& node, Point3_<_Tp>& value, const Point3_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 3 ? default_value : Point3_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]), + saturate_cast<_Tp>(temp[2])); +} + +template static inline void read(const FileNode& node, Size_<_Tp>& value, const Size_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 2 ? default_value : Size_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1])); +} + +template static inline void read(const FileNode& node, Complex<_Tp>& value, const Complex<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 2 ? default_value : Complex<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1])); +} + +template static inline void read(const FileNode& node, Rect_<_Tp>& value, const Rect_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 4 ? default_value : Rect_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]), + saturate_cast<_Tp>(temp[2]), saturate_cast<_Tp>(temp[3])); +} + +template static inline void read(const FileNode& node, Vec<_Tp, cn>& value, const Vec<_Tp, cn>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != cn ? default_value : Vec<_Tp, cn>(&temp[0]); +} + +template static inline void read(const FileNode& node, Matx<_Tp, m, n>& value, const Matx<_Tp, m, n>& default_matx = Matx<_Tp, m, n>()) +{ + Mat temp; + read(node, temp); // read as a Mat class + + if (temp.empty()) + value = default_matx; + else + value = Matx<_Tp, m, n>(temp); +} + +template static inline void read(const FileNode& node, Scalar_<_Tp>& value, const Scalar_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 4 ? default_value : Scalar_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]), + saturate_cast<_Tp>(temp[2]), saturate_cast<_Tp>(temp[3])); +} + +static inline void read(const FileNode& node, Range& value, const Range& default_value) +{ + Point2i temp(value.start, value.end); const Point2i default_temp = Point2i(default_value.start, default_value.end); + read(node, temp, default_temp); + value.start = temp.x; value.end = temp.y; +} + +//! @} + +/** @brief Writes string to a file storage. +@relates cv::FileStorage + */ +CV_EXPORTS FileStorage& operator << (FileStorage& fs, const String& str); + +//! @cond IGNORED + +namespace internal +{ + class CV_EXPORTS WriteStructContext + { + public: + WriteStructContext(FileStorage& _fs, const String& name, int flags, const String& typeName = String()); + ~WriteStructContext(); + private: + FileStorage* fs; + }; + + template class VecWriterProxy + { + public: + VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} + void operator()(const std::vector<_Tp>& vec) const + { + size_t count = vec.size(); + for (size_t i = 0; i < count; i++) + write(*fs, vec[i]); + } + private: + FileStorage* fs; + }; + + template class VecWriterProxy<_Tp, 1> + { + public: + VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} + void operator()(const std::vector<_Tp>& vec) const + { + int _fmt = traits::SafeFmt<_Tp>::fmt; + char fmt[] = { (char)((_fmt >> 8) + '1'), (char)_fmt, '\0' }; + fs->writeRaw(fmt, !vec.empty() ? (uchar*)&vec[0] : 0, vec.size() * sizeof(_Tp)); + } + private: + FileStorage* fs; + }; + + template class VecReaderProxy + { + public: + VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} + void operator()(std::vector<_Tp>& vec, size_t count) const + { + count = std::min(count, it->remaining()); + vec.resize(count); + for (size_t i = 0; i < count; i++, ++(*it)) + read(**it, vec[i], _Tp()); + } + private: + FileNodeIterator* it; + }; + + template class VecReaderProxy<_Tp, 1> + { + public: + VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} + void operator()(std::vector<_Tp>& vec, size_t count) const + { + size_t remaining = it->remaining(); + size_t cn = DataType<_Tp>::channels; + int _fmt = traits::SafeFmt<_Tp>::fmt; + CV_Assert((_fmt >> 8) < 9); + char fmt[] = { (char)((_fmt >> 8)+'1'), (char)_fmt, '\0' }; + CV_Assert((remaining % cn) == 0); + size_t remaining1 = remaining / cn; + count = count > remaining1 ? remaining1 : count; + vec.resize(count); + it->readRaw(fmt, !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp)); + } + private: + FileNodeIterator* it; + }; + +} // internal + +//! @endcond + +//! @relates cv::FileStorage +//! @{ + +template static inline +void write(FileStorage& fs, const _Tp& value) +{ + write(fs, String(), value); +} + +template<> inline +void write( FileStorage& fs, const int& value ) +{ + writeScalar(fs, value); +} + +template<> inline +void write( FileStorage& fs, const float& value ) +{ + writeScalar(fs, value); +} + +template<> inline +void write( FileStorage& fs, const double& value ) +{ + writeScalar(fs, value); +} + +template<> inline +void write( FileStorage& fs, const String& value ) +{ + writeScalar(fs, value); +} + +template static inline +void write(FileStorage& fs, const Point_<_Tp>& pt ) +{ + write(fs, pt.x); + write(fs, pt.y); +} + +template static inline +void write(FileStorage& fs, const Point3_<_Tp>& pt ) +{ + write(fs, pt.x); + write(fs, pt.y); + write(fs, pt.z); +} + +template static inline +void write(FileStorage& fs, const Size_<_Tp>& sz ) +{ + write(fs, sz.width); + write(fs, sz.height); +} + +template static inline +void write(FileStorage& fs, const Complex<_Tp>& c ) +{ + write(fs, c.re); + write(fs, c.im); +} + +template static inline +void write(FileStorage& fs, const Rect_<_Tp>& r ) +{ + write(fs, r.x); + write(fs, r.y); + write(fs, r.width); + write(fs, r.height); +} + +template static inline +void write(FileStorage& fs, const Vec<_Tp, cn>& v ) +{ + for(int i = 0; i < cn; i++) + write(fs, v.val[i]); +} + +template static inline +void write(FileStorage& fs, const Matx<_Tp, m, n>& x ) +{ + write(fs, Mat(x)); // write as a Mat class +} + +template static inline +void write(FileStorage& fs, const Scalar_<_Tp>& s ) +{ + write(fs, s.val[0]); + write(fs, s.val[1]); + write(fs, s.val[2]); + write(fs, s.val[3]); +} + +static inline +void write(FileStorage& fs, const Range& r ) +{ + write(fs, r.start); + write(fs, r.end); +} + +template static inline +void write( FileStorage& fs, const std::vector<_Tp>& vec ) +{ + cv::internal::VecWriterProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> w(&fs); + w(vec); +} + +template static inline +void write(FileStorage& fs, const String& name, const Point_<_Tp>& pt ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, pt); +} + +template static inline +void write(FileStorage& fs, const String& name, const Point3_<_Tp>& pt ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, pt); +} + +template static inline +void write(FileStorage& fs, const String& name, const Size_<_Tp>& sz ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, sz); +} + +template static inline +void write(FileStorage& fs, const String& name, const Complex<_Tp>& c ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, c); +} + +template static inline +void write(FileStorage& fs, const String& name, const Rect_<_Tp>& r ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, r); +} + +template static inline +void write(FileStorage& fs, const String& name, const Vec<_Tp, cn>& v ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, v); +} + +template static inline +void write(FileStorage& fs, const String& name, const Matx<_Tp, m, n>& x ) +{ + write(fs, name, Mat(x)); // write as a Mat class +} + +template static inline +void write(FileStorage& fs, const String& name, const Scalar_<_Tp>& s ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, s); +} + +static inline +void write(FileStorage& fs, const String& name, const Range& r ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, r); +} + +static inline +void write(FileStorage& fs, const String& name, const KeyPoint& kpt) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, kpt.pt.x); + write(fs, kpt.pt.y); + write(fs, kpt.size); + write(fs, kpt.angle); + write(fs, kpt.response); + write(fs, kpt.octave); + write(fs, kpt.class_id); +} + +static inline +void write(FileStorage& fs, const String& name, const DMatch& m) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, m.queryIdx); + write(fs, m.trainIdx); + write(fs, m.imgIdx); + write(fs, m.distance); +} + +template::value >::type* = nullptr> +static inline void write( FileStorage& fs, const String& name, const _Tp& val ) +{ + write(fs, name, static_cast(val)); +} + +template static inline +void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+(traits::SafeFmt<_Tp>::fmt != 0 ? FileNode::FLOW : 0)); + write(fs, vec); +} + +template static inline +void write( FileStorage& fs, const String& name, const std::vector< std::vector<_Tp> >& vec ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ); + for(size_t i = 0; i < vec.size(); i++) + { + cv::internal::WriteStructContext ws_(fs, name, FileNode::SEQ+(traits::SafeFmt<_Tp>::fmt != 0 ? FileNode::FLOW : 0)); + write(fs, vec[i]); + } +} + +#ifdef CV__LEGACY_PERSISTENCE +// This code is not needed anymore, but it is preserved here to keep source compatibility +// Implementation is similar to templates instantiations +static inline void write(FileStorage& fs, const KeyPoint& kpt) { write(fs, String(), kpt); } +static inline void write(FileStorage& fs, const DMatch& m) { write(fs, String(), m); } +static inline void write(FileStorage& fs, const std::vector& vec) +{ + cv::internal::VecWriterProxy w(&fs); + w(vec); +} +static inline void write(FileStorage& fs, const std::vector& vec) +{ + cv::internal::VecWriterProxy w(&fs); + w(vec); + +} +#endif + +//! @} FileStorage + +//! @relates cv::FileNode +//! @{ + +static inline +void read(const FileNode& node, bool& value, bool default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = temp != 0; +} + +static inline +void read(const FileNode& node, uchar& value, uchar default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +static inline +void read(const FileNode& node, schar& value, schar default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +static inline +void read(const FileNode& node, ushort& value, ushort default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +static inline +void read(const FileNode& node, short& value, short default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +template static inline +void read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount = (size_t)INT_MAX ) +{ + cv::internal::VecReaderProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> r(&it); + r(vec, maxCount); +} + +template::value >::type* = nullptr> +static inline void read(const FileNode& node, _Tp& value, const _Tp& default_value = static_cast<_Tp>(0)) +{ + int temp; + read(node, temp, static_cast(default_value)); + value = static_cast<_Tp>(temp); +} + +template static inline +void read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>& default_value = std::vector<_Tp>() ) +{ + if(node.empty()) + vec = default_value; + else + { + FileNodeIterator it = node.begin(); + read( it, vec ); + } +} + +static inline +void read( const FileNode& node, std::vector& vec, const std::vector& default_value ) +{ + if(node.empty()) + vec = default_value; + else + read(node, vec); +} + +static inline +void read( const FileNode& node, std::vector& vec, const std::vector& default_value ) +{ + if(node.empty()) + vec = default_value; + else + read(node, vec); +} + +//! @} FileNode + +//! @relates cv::FileStorage +//! @{ + +/** @brief Writes data to a file storage. + */ +template static inline +FileStorage& operator << (FileStorage& fs, const _Tp& value) +{ + if( !fs.isOpened() ) + return fs; + if( fs.state == FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP ) + CV_Error( Error::StsError, "No element name has been given" ); + write( fs, fs.elname, value ); + if( fs.state & FileStorage::INSIDE_MAP ) + fs.state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP; + return fs; +} + +/** @brief Writes data to a file storage. + */ +static inline +FileStorage& operator << (FileStorage& fs, const char* str) +{ + return (fs << String(str)); +} + +/** @brief Writes data to a file storage. + */ +static inline +FileStorage& operator << (FileStorage& fs, char* value) +{ + return (fs << String(value)); +} + +//! @} FileStorage + +//! @relates cv::FileNodeIterator +//! @{ + +/** @brief Reads data from a file storage. + */ +template static inline +FileNodeIterator& operator >> (FileNodeIterator& it, _Tp& value) +{ + read( *it, value, _Tp()); + return ++it; +} + +/** @brief Reads data from a file storage. + */ +template static inline +FileNodeIterator& operator >> (FileNodeIterator& it, std::vector<_Tp>& vec) +{ + cv::internal::VecReaderProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> r(&it); + r(vec, (size_t)INT_MAX); + return it; +} + +//! @} FileNodeIterator + +//! @relates cv::FileNode +//! @{ + +/** @brief Reads data from a file storage. + */ +template static inline +void operator >> (const FileNode& n, _Tp& value) +{ + read( n, value, _Tp()); +} + +/** @brief Reads data from a file storage. + */ +template static inline +void operator >> (const FileNode& n, std::vector<_Tp>& vec) +{ + FileNodeIterator it = n.begin(); + it >> vec; +} + +/** @brief Reads KeyPoint from a file storage. +*/ +//It needs special handling because it contains two types of fields, int & float. +static inline +void operator >> (const FileNode& n, KeyPoint& kpt) +{ + FileNodeIterator it = n.begin(); + it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave >> kpt.class_id; +} + +#ifdef CV__LEGACY_PERSISTENCE +static inline +void operator >> (const FileNode& n, std::vector& vec) +{ + read(n, vec); +} +static inline +void operator >> (const FileNode& n, std::vector& vec) +{ + read(n, vec); +} +#endif + +/** @brief Reads DMatch from a file storage. +*/ +//It needs special handling because it contains two types of fields, int & float. +static inline +void operator >> (const FileNode& n, DMatch& m) +{ + FileNodeIterator it = n.begin(); + it >> m.queryIdx >> m.trainIdx >> m.imgIdx >> m.distance; +} + +//! @} FileNode + +//! @relates cv::FileNodeIterator +//! @{ + +CV_EXPORTS bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2); +CV_EXPORTS bool operator != (const FileNodeIterator& it1, const FileNodeIterator& it2); + +static inline +ptrdiff_t operator - (const FileNodeIterator& it1, const FileNodeIterator& it2) +{ + return it2.remaining() - it1.remaining(); +} + +static inline +bool operator < (const FileNodeIterator& it1, const FileNodeIterator& it2) +{ + return it1.remaining() > it2.remaining(); +} + +//! @} FileNodeIterator + +} // cv + +#endif // OPENCV_CORE_PERSISTENCE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/quaternion.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/quaternion.hpp new file mode 100644 index 0000000..8c21501 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/quaternion.hpp @@ -0,0 +1,1696 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang +#ifndef OPENCV_CORE_QUATERNION_HPP +#define OPENCV_CORE_QUATERNION_HPP + +#include +#include +#include +namespace cv +{ +//! @addtogroup core +//! @{ + +//! Unit quaternion flag +enum QuatAssumeType +{ + /** + * This flag is specified by default. + * If this flag is specified, the input quaternions are assumed to be not unit quaternions. + * It can guarantee the correctness of the calculations, + * although the calculation speed will be slower than the flag QUAT_ASSUME_UNIT. + */ + QUAT_ASSUME_NOT_UNIT, + /** + * If this flag is specified, the input quaternions are assumed to be unit quaternions which + * will save some computations. However, if this flag is specified without unit quaternion, + * the program correctness of the result will not be guaranteed. + */ + QUAT_ASSUME_UNIT +}; + +class QuatEnum +{ +public: + /** @brief Enum of Euler angles type. + * + * Without considering the possibility of using two different convertions for the definition of the rotation axes , + * there exists twelve possible sequences of rotation axes, divided into two groups: + * - Proper Euler angles (Z-X-Z, X-Y-X, Y-Z-Y, Z-Y-Z, X-Z-X, Y-X-Y) + * - Tait–Bryan angles (X-Y-Z, Y-Z-X, Z-X-Y, X-Z-Y, Z-Y-X, Y-X-Z). + * + * The three elemental rotations may be [extrinsic](https://en.wikipedia.org/wiki/Euler_angles#Definition_by_extrinsic_rotations) + * (rotations about the axes *xyz* of the original coordinate system, which is assumed to remain motionless), + * or [intrinsic](https://en.wikipedia.org/wiki/Euler_angles#Definition_by_intrinsic_rotations)(rotations about the axes of the rotating coordinate system *XYZ*, solidary with the moving body, which changes its orientation after each elemental rotation). + * + * + * Extrinsic and intrinsic rotations are relevant. + * + * The definition of the Euler angles is as following, + * - \f$\theta_1 \f$ represents the first rotation angle, + * - \f$\theta_2 \f$ represents the second rotation angle, + * - \f$\theta_3 \f$ represents the third rotation angle. + * + * For intrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:\f[R =X(\theta_1) Y(\theta_2) Z(\theta_3) \f] + * For extrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:\f[R =Z({\theta_3}) Y({\theta_2}) X({\theta_1})\f] + * where + * \f[X({\theta})={\begin{bmatrix}1&0&0\\0&\cos {\theta_1} &-\sin {\theta_1} \\0&\sin {\theta_1} &\cos {\theta_1} \\\end{bmatrix}}, + * Y({\theta})={\begin{bmatrix}\cos \theta_{2}&0&\sin \theta_{2}\\0&1 &0 \\\ -sin \theta_2& 0&\cos \theta_{2} \\\end{bmatrix}}, + * Z({\theta})={\begin{bmatrix}\cos\theta_{3} &-\sin \theta_3&0\\\sin \theta_3 &\cos \theta_3 &0\\0&0&1\\\end{bmatrix}}. + * \f] + * + * The function is designed according to this set of conventions: + * - [Right handed](https://en.wikipedia.org/wiki/Right_hand_rule) reference frames are adopted, and the [right hand rule](https://en.wikipedia.org/wiki/Right_hand_rule) is used to determine the sign of angles. + * - Each matrix is meant to represent an [active rotation](https://en.wikipedia.org/wiki/Active_and_passive_transformation) (the composing and composed matrices + * are supposed to act on the coordinates of vectors defined in the initial fixed reference frame and give as a result the coordinates of a rotated vector defined in the same reference frame). + * - For \f$\theta_1\f$ and \f$\theta_3\f$, the valid range is (−π, π]. + * + * For \f$\theta_2\f$, the valid range is [−π/2, π/2] or [0, π]. + * + * For Tait–Bryan angles, the valid range of \f$\theta_2\f$ is [−π/2, π/2]. When transforming a quaternion to Euler angles, the solution of Euler angles is unique in condition of \f$ \theta_2 \in (−π/2, π/2)\f$ . + * If \f$\theta_2 = −π/2 \f$ or \f$ \theta_2 = π/2\f$, there are infinite solutions. The common name for this situation is gimbal lock. + * For Proper Euler angles,the valid range of \f$\theta_2\f$ is in [0, π]. The solutions of Euler angles are unique in condition of \f$ \theta_2 \in (0, π)\f$ . If \f$\theta_2 =0 \f$ or \f$\theta_2 =π \f$, + * there are infinite solutions and gimbal lock will occur. + */ + enum EulerAnglesType + { + INT_XYZ, ///< Intrinsic rotations with the Euler angles type X-Y-Z + INT_XZY, ///< Intrinsic rotations with the Euler angles type X-Z-Y + INT_YXZ, ///< Intrinsic rotations with the Euler angles type Y-X-Z + INT_YZX, ///< Intrinsic rotations with the Euler angles type Y-Z-X + INT_ZXY, ///< Intrinsic rotations with the Euler angles type Z-X-Y + INT_ZYX, ///< Intrinsic rotations with the Euler angles type Z-Y-X + INT_XYX, ///< Intrinsic rotations with the Euler angles type X-Y-X + INT_XZX, ///< Intrinsic rotations with the Euler angles type X-Z-X + INT_YXY, ///< Intrinsic rotations with the Euler angles type Y-X-Y + INT_YZY, ///< Intrinsic rotations with the Euler angles type Y-Z-Y + INT_ZXZ, ///< Intrinsic rotations with the Euler angles type Z-X-Z + INT_ZYZ, ///< Intrinsic rotations with the Euler angles type Z-Y-Z + + EXT_XYZ, ///< Extrinsic rotations with the Euler angles type X-Y-Z + EXT_XZY, ///< Extrinsic rotations with the Euler angles type X-Z-Y + EXT_YXZ, ///< Extrinsic rotations with the Euler angles type Y-X-Z + EXT_YZX, ///< Extrinsic rotations with the Euler angles type Y-Z-X + EXT_ZXY, ///< Extrinsic rotations with the Euler angles type Z-X-Y + EXT_ZYX, ///< Extrinsic rotations with the Euler angles type Z-Y-X + EXT_XYX, ///< Extrinsic rotations with the Euler angles type X-Y-X + EXT_XZX, ///< Extrinsic rotations with the Euler angles type X-Z-X + EXT_YXY, ///< Extrinsic rotations with the Euler angles type Y-X-Y + EXT_YZY, ///< Extrinsic rotations with the Euler angles type Y-Z-Y + EXT_ZXZ, ///< Extrinsic rotations with the Euler angles type Z-X-Z + EXT_ZYZ, ///< Extrinsic rotations with the Euler angles type Z-Y-Z + #ifndef CV_DOXYGEN + EULER_ANGLES_MAX_VALUE + #endif + }; + +}; + +template class Quat; +template std::ostream& operator<<(std::ostream&, const Quat<_Tp>&); + +/** + * Quaternion is a number system that extends the complex numbers. It can be expressed as a + * rotation in three-dimensional space. + * A quaternion is generally represented in the form: + * \f[q = w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\f] + * \f[q = [w, x, y, z]\f] + * \f[q = [w, \boldsymbol{v}] \f] + * \f[q = ||q||[\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f] + * \f[q = ||q||[\cos\psi, \boldsymbol{u}\sin\psi]\f] + * where \f$\psi = \frac{\theta}{2}\f$, \f$\theta\f$ represents rotation angle, + * \f$\boldsymbol{u} = [u_x, u_y, u_z]\f$ represents normalized rotation axis, + * and \f$||q||\f$ represents the norm of \f$q\f$. + * + * A unit quaternion is usually represents rotation, which has the form: + * \f[q = [\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f] + * + * To create a quaternion representing the rotation around the axis \f$\boldsymbol{u}\f$ + * with angle \f$\theta\f$, you can use + * ``` + * using namespace cv; + * double angle = CV_PI; + * Vec3d axis = {0, 0, 1}; + * Quatd q = Quatd::createFromAngleAxis(angle, axis); + * ``` + * + * You can simply use four same type number to create a quaternion + * ``` + * Quatd q(1, 2, 3, 4); + * ``` + * Or use a Vec4d or Vec4f vector. + * ``` + * Vec4d vec{1, 2, 3, 4}; + * Quatd q(vec); + * ``` + * + * ``` + * Vec4f vec{1, 2, 3, 4}; + * Quatf q(vec); + * ``` + * + * If you already have a 3x3 rotation matrix R, then you can use + * ``` + * Quatd q = Quatd::createFromRotMat(R); + * ``` + * + * If you already have a rotation vector rvec which has the form of `angle * axis`, then you can use + * ``` + * Quatd q = Quatd::createFromRvec(rvec); + * ``` + * + * To extract the rotation matrix from quaternion, see toRotMat3x3() + * + * To extract the Vec4d or Vec4f, see toVec() + * + * To extract the rotation vector, see toRotVec() + * + * If there are two quaternions \f$q_0, q_1\f$ are needed to interpolate, you can use nlerp(), slerp() or spline() + * ``` + * Quatd::nlerp(q0, q1, t) + * + * Quatd::slerp(q0, q1, t) + * + * Quatd::spline(q0, q0, q1, q1, t) + * ``` + * spline can smoothly connect rotations of multiple quaternions + * + * Three ways to get an element in Quaternion + * ``` + * Quatf q(1,2,3,4); + * std::cout << q.w << std::endl; // w=1, x=2, y=3, z=4 + * std::cout << q[0] << std::endl; // q[0]=1, q[1]=2, q[2]=3, q[3]=4 + * std::cout << q.at(0) << std::endl; + * ``` + */ +template +class Quat +{ + static_assert(std::is_floating_point<_Tp>::value, "Quaternion only make sense with type of float or double"); + using value_type = _Tp; +public: + static constexpr _Tp CV_QUAT_EPS = (_Tp)1.e-6; + static constexpr _Tp CV_QUAT_CONVERT_THRESHOLD = (_Tp)1.e-6; + + Quat(); + + /** + * @brief From Vec4d or Vec4f. + */ + explicit Quat(const Vec<_Tp, 4> &coeff); + + /** + * @brief from four numbers. + */ + Quat(_Tp w, _Tp x, _Tp y, _Tp z); + + /** + * @brief from an angle, axis. Axis will be normalized in this function. And + * it generates + * \f[q = [\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f] + * where \f$\psi = \frac{\theta}{2}\f$, \f$\theta\f$ is the rotation angle. + */ + static Quat<_Tp> createFromAngleAxis(const _Tp angle, const Vec<_Tp, 3> &axis); + + /** + * @brief from a 3x3 rotation matrix. + */ + static Quat<_Tp> createFromRotMat(InputArray R); + + /** + * @brief from a rotation vector + * \f$r\f$ has the form \f$\theta \cdot \boldsymbol{u}\f$, where \f$\theta\f$ + * represents rotation angle and \f$\boldsymbol{u}\f$ represents normalized rotation axis. + * + * Angle and axis could be easily derived as: + * \f[ + * \begin{equation} + * \begin{split} + * \psi &= ||r||\\ + * \boldsymbol{u} &= \frac{r}{\theta} + * \end{split} + * \end{equation} + * \f] + * Then a quaternion can be calculated by + * \f[q = [\cos\psi, \boldsymbol{u}\sin\psi]\f] + * where \f$\psi = \theta / 2 \f$ + */ + static Quat<_Tp> createFromRvec(InputArray rvec); + + /** + * @brief + * from Euler angles + * + * A quaternion can be generated from Euler angles by combining the quaternion representations of the Euler rotations. + * + * For example, if we use intrinsic rotations in the order of X-Y-Z,\f$\theta_1 \f$ is rotation around the X-axis, \f$\theta_2 \f$ is rotation around the Y-axis, + * \f$\theta_3 \f$ is rotation around the Z-axis. The final quaternion q can be calculated by + * + * \f[ {q} = q_{X, \theta_1} q_{Y, \theta_2} q_{Z, \theta_3}\f] + * where \f$ q_{X, \theta_1} \f$ is created from @ref createFromXRot, \f$ q_{Y, \theta_2} \f$ is created from @ref createFromYRot, + * \f$ q_{Z, \theta_3} \f$ is created from @ref createFromZRot. + * @param angles the Euler angles in a vector of length 3 + * @param eulerAnglesType the convertion Euler angles type + */ + static Quat<_Tp> createFromEulerAngles(const Vec<_Tp, 3> &angles, QuatEnum::EulerAnglesType eulerAnglesType); + + /** + * @brief get a quaternion from a rotation about the Y-axis by \f$\theta\f$ . + * \f[q = \cos(\theta/2)+0 i+ sin(\theta/2) j +0k \f] + */ + static Quat<_Tp> createFromYRot(const _Tp theta); + + /** + * @brief get a quaternion from a rotation about the X-axis by \f$\theta\f$ . + * \f[q = \cos(\theta/2)+sin(\theta/2) i +0 j +0 k \f] + */ + static Quat<_Tp> createFromXRot(const _Tp theta); + + /** + * @brief get a quaternion from a rotation about the Z-axis by \f$\theta\f$. + * \f[q = \cos(\theta/2)+0 i +0 j +sin(\theta/2) k \f] + */ + static Quat<_Tp> createFromZRot(const _Tp theta); + + /** + * @brief a way to get element. + * @param index over a range [0, 3]. + * + * A quaternion q + * + * q.at(0) is equivalent to q.w, + * + * q.at(1) is equivalent to q.x, + * + * q.at(2) is equivalent to q.y, + * + * q.at(3) is equivalent to q.z. + */ + _Tp at(size_t index) const; + + /** + * @brief return the conjugate of this quaternion. + * \f[q.conjugate() = (w, -x, -y, -z).\f] + */ + Quat<_Tp> conjugate() const; + + /** + * + * @brief return the value of exponential value. + * \f[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||})\sin||\boldsymbol{v}||\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example: + * ``` + * Quatd q{1,2,3,4}; + * cout << exp(q) << endl; + * ``` + */ + template + friend Quat exp(const Quat &q); + + /** + * @brief return the value of exponential value. + * \f[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q{1,2,3,4}; + * cout << q.exp() << endl; + * ``` + */ + Quat<_Tp> exp() const; + + /** + * @brief return the value of logarithm function. + * \f[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}.\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q1{1,2,3,4}; + * cout << log(q1) << endl; + * ``` + */ + template + friend Quat log(const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return the value of logarithm function. + * \f[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}\f]. + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.log(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * Quatd q1(1,2,3,4); + * q1.normalize().log(assumeUnit); + * ``` + */ + Quat<_Tp> log(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of power function with index \f$x\f$. + * \f[q^x = ||q||(cos(x\theta) + \boldsymbol{u}sin(x\theta))).\f] + * @param q a quaternion. + * @param x index of exponentiation. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * power(q, 2.0); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * double angle = CV_PI; + * Vec3d axis{0, 0, 1}; + * Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle + * power(q1, 2.0, assumeUnit);//This assumeUnit means q1 is a unit quaternion. + * ``` + * @note the type of the index should be the same as the quaternion. + */ + template + friend Quat power(const Quat &q, const T x, QuatAssumeType assumeUnit); + + /** + * @brief return the value of power function with index \f$x\f$. + * \f[q^x = ||q||(\cos(x\theta) + \boldsymbol{u}\sin(x\theta))).\f] + * @param x index of exponentiation. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.power(2.0); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * double angle = CV_PI; + * Vec3d axis{0, 0, 1}; + * Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle + * q1.power(2.0, assumeUnit); //This assumeUnt means q1 is a unit quaternion + * ``` + */ + Quat<_Tp> power(const _Tp x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return \f$\sqrt{q}\f$. + * @param q a quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatf q(1,2,3,4); + * sqrt(q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = {1,0,0,0}; + * sqrt(q, assumeUnit); //This assumeUnit means q is a unit quaternion. + * ``` + */ + template + friend Quat sqrt(const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return \f$\sqrt{q}\f$. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatf q(1,2,3,4); + * q.sqrt(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = {1,0,0,0}; + * q.sqrt(assumeUnit); //This assumeUnit means q is a unit quaternion + * ``` + */ + Quat<_Tp> sqrt(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of power function with quaternion \f$q\f$. + * \f[p^q = e^{q\ln(p)}.\f] + * @param p base quaternion of power function. + * @param q index quaternion of power function. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion \f$p\f$ assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd p(1,2,3,4); + * Quatd q(5,6,7,8); + * power(p, q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * p = p.normalize(); + * power(p, q, assumeUnit); //This assumeUnit means p is a unit quaternion + * ``` + */ + template + friend Quat power(const Quat &p, const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return the value of power function with quaternion \f$q\f$. + * \f[p^q = e^{q\ln(p)}.\f] + * @param q index quaternion of power function. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd p(1,2,3,4); + * Quatd q(5,6,7,8); + * p.power(q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * p = p.normalize(); + * p.power(q, assumeUnit); //This assumeUnit means p is a unit quaternion + * ``` + */ + Quat<_Tp> power(const Quat<_Tp> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the crossProduct between \f$p = (a, b, c, d) = (a, \boldsymbol{u})\f$ and \f$q = (w, x, y, z) = (w, \boldsymbol{v})\f$. + * \f[p \times q = \frac{pq- qp}{2}\f] + * \f[p \times q = \boldsymbol{u} \times \boldsymbol{v}\f] + * \f[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k \f] + * + * For example + * ``` + * Quatd q{1,2,3,4}; + * Quatd p{5,6,7,8}; + * crossProduct(p, q); + * ``` + */ + template + friend Quat crossProduct(const Quat &p, const Quat &q); + + /** + * @brief return the crossProduct between \f$p = (a, b, c, d) = (a, \boldsymbol{u})\f$ and \f$q = (w, x, y, z) = (w, \boldsymbol{v})\f$. + * \f[p \times q = \frac{pq- qp}{2}.\f] + * \f[p \times q = \boldsymbol{u} \times \boldsymbol{v}.\f] + * \f[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k. \f] + * + * For example + * ``` + * Quatd q{1,2,3,4}; + * Quatd p{5,6,7,8}; + * p.crossProduct(q) + * ``` + */ + Quat<_Tp> crossProduct(const Quat<_Tp> &q) const; + + /** + * @brief return the norm of quaternion. + * \f[||q|| = \sqrt{w^2 + x^2 + y^2 + z^2}.\f] + */ + _Tp norm() const; + + /** + * @brief return a normalized \f$p\f$. + * \f[p = \frac{q}{||q||}\f] + * where \f$p\f$ satisfies \f$(p.x)^2 + (p.y)^2 + (p.z)^2 + (p.w)^2 = 1.\f$ + */ + Quat<_Tp> normalize() const; + + /** + * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$ + * which satisfies \f$q * q^{-1} = 1\f$. + * @param q a quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * inv(q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = q.normalize(); + * inv(q, assumeUnit);//This assumeUnit means p is a unit quaternion + * ``` + */ + template + friend Quat inv(const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$ + * satisfying \f$q * q^{-1} = 1\f$. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.inv(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = q.normalize(); + * q.inv(assumeUnit); //assumeUnit means p is a unit quaternion + * ``` + */ + Quat<_Tp> inv(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return sinh value of quaternion q, sinh could be calculated as: + * \f[\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * sinh(q); + * ``` + */ + template + friend Quat sinh(const Quat &q); + + /** + * @brief return sinh value of this quaternion, sinh could be calculated as: + * \f$\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\f$ + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.sinh(); + * ``` + */ + Quat<_Tp> sinh() const; + + /** + * @brief return cosh value of quaternion q, cosh could be calculated as: + * \f[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sin(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * cosh(q); + * ``` + */ + template + friend Quat cosh(const Quat &q); + + /** + * @brief return cosh value of this quaternion, cosh could be calculated as: + * \f[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}sin(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.cosh(); + * ``` + */ + Quat<_Tp> cosh() const; + + /** + * @brief return tanh value of quaternion q, tanh could be calculated as: + * \f[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\f] + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * tanh(q); + * ``` + * @sa sinh, cosh + */ + template + friend Quat tanh(const Quat &q); + + /** + * @brief return tanh value of this quaternion, tanh could be calculated as: + * \f[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\f] + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.tanh(); + * ``` + * @sa sinh, cosh + */ + Quat<_Tp> tanh() const; + + /** + * @brief return tanh value of quaternion q, sin could be calculated as: + * \f[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * sin(q); + * ``` + */ + template + friend Quat sin(const Quat &q); + + /** + * @brief return sin value of this quaternion, sin could be calculated as: + * \f[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.sin(); + * ``` + */ + Quat<_Tp> sin() const; + + /** + * @brief return sin value of quaternion q, cos could be calculated as: + * \f[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * cos(q); + * ``` + */ + template + friend Quat cos(const Quat &q); + + /** + * @brief return cos value of this quaternion, cos could be calculated as: + * \f[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.cos(); + * ``` + */ + Quat<_Tp> cos() const; + + /** + * @brief return tan value of quaternion q, tan could be calculated as: + * \f[\tan(q) = \frac{\sin(q)}{\cos(q)}.\f] + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * tan(q); + * ``` + */ + template + friend Quat tan(const Quat &q); + + /** + * @brief return tan value of this quaternion, tan could be calculated as: + * \f[\tan(q) = \frac{\sin(q)}{\cos(q)}.\f] + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.tan(); + * ``` + */ + Quat<_Tp> tan() const; + + /** + * @brief return arcsin value of quaternion q, arcsin could be calculated as: + * \f[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * asin(q); + * ``` + */ + template + friend Quat asin(const Quat &q); + + /** + * @brief return arcsin value of this quaternion, arcsin could be calculated as: + * \f[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.asin(); + * ``` + */ + Quat<_Tp> asin() const; + + /** + * @brief return arccos value of quaternion q, arccos could be calculated as: + * \f[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * acos(q); + * ``` + */ + template + friend Quat acos(const Quat &q); + + /** + * @brief return arccos value of this quaternion, arccos could be calculated as: + * \f[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.acos(); + * ``` + */ + Quat<_Tp> acos() const; + + /** + * @brief return arctan value of quaternion q, arctan could be calculated as: + * \f[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * atan(q); + * ``` + */ + template + friend Quat atan(const Quat &q); + + /** + * @brief return arctan value of this quaternion, arctan could be calculated as: + * \f[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.atan(); + * ``` + */ + Quat<_Tp> atan() const; + + /** + * @brief return arcsinh value of quaternion q, arcsinh could be calculated as: + * \f[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\f]. + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * asinh(q); + * ``` + */ + template + friend Quat asinh(const Quat &q); + + /** + * @brief return arcsinh value of this quaternion, arcsinh could be calculated as: + * \f[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\f]. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.asinh(); + * ``` + */ + Quat<_Tp> asinh() const; + + /** + * @brief return arccosh value of quaternion q, arccosh could be calculated as: + * \f[arccosh(q) = \ln(q + \sqrt{q^2 - 1})\f]. + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * acosh(q); + * ``` + */ + template + friend Quat acosh(const Quat &q); + + /** + * @brief return arccosh value of this quaternion, arccosh could be calculated as: + * \f[arcosh(q) = \ln(q + \sqrt{q^2 - 1})\f]. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.acosh(); + * ``` + */ + Quat<_Tp> acosh() const; + + /** + * @brief return arctanh value of quaternion q, arctanh could be calculated as: + * \f[arctanh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\f]. + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * atanh(q); + * ``` + */ + template + friend Quat atanh(const Quat &q); + + /** + * @brief return arctanh value of this quaternion, arctanh could be calculated as: + * \f[arcsinh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\f]. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.atanh(); + * ``` + */ + Quat<_Tp> atanh() const; + + /** + * @brief return true if this quaternion is a unit quaternion. + * @param eps tolerance scope of normalization. The eps could be defined as + * + * \f[eps = |1 - dotValue|\f] where \f[dotValue = (this.w^2 + this.x^2 + this,y^2 + this.z^2).\f] + * And this function will consider it is normalized when the dotValue over a range \f$[1-eps, 1+eps]\f$. + */ + bool isNormal(_Tp eps=CV_QUAT_EPS) const; + + /** + * @brief to throw an error if this quaternion is not a unit quaternion. + * @param eps tolerance scope of normalization. + * @sa isNormal + */ + void assertNormal(_Tp eps=CV_QUAT_EPS) const; + + /** + * @brief transform a quaternion to a 3x3 rotation matrix. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. Otherwise, this function will normalize this + * quaternion at first then do the transformation. + * + * @note Matrix A which is to be rotated should have the form + * \f[\begin{bmatrix} + * x_0& x_1& x_2&...&x_n\\ + * y_0& y_1& y_2&...&y_n\\ + * z_0& z_1& z_2&...&z_n + * \end{bmatrix}\f] + * where the same subscript represents a point. The shape of A assume to be [3, n] + * The points matrix A can be rotated by toRotMat3x3() * A. + * The result has 3 rows and n columns too. + + * For example + * ``` + * double angle = CV_PI; + * Vec3d axis{0,0,1}; + * Quatd q_unit = Quatd::createFromAngleAxis(angle, axis); //quaternion could also be get by interpolation by two or more quaternions. + * + * //assume there is two points (1,0,0) and (1,0,1) to be rotated + * Mat pointsA = (Mat_(2, 3) << 1,0,0,1,0,1); + * //change the shape + * pointsA = pointsA.t(); + * // rotate 180 degrees around the z axis + * Mat new_point = q_unit.toRotMat3x3() * pointsA; + * // print two points + * cout << new_point << endl; + * ``` + */ + Matx<_Tp, 3, 3> toRotMat3x3(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief transform a quaternion to a 4x4 rotation matrix. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. Otherwise, this function will normalize this + * quaternion at first then do the transformation. + * + * The operations is similar as toRotMat3x3 + * except that the points matrix should have the form + * \f[\begin{bmatrix} + * x_0& x_1& x_2&...&x_n\\ + * y_0& y_1& y_2&...&y_n\\ + * z_0& z_1& z_2&...&z_n\\ + * 0&0&0&...&0 + * \end{bmatrix}\f] + * + * @sa toRotMat3x3 + */ + + Matx<_Tp, 4, 4> toRotMat4x4(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief transform the this quaternion to a Vec. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.toVec(); + * ``` + */ + Vec<_Tp, 4> toVec() const; + + /** + * @brief transform this quaternion to a Rotation vector. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. + * Rotation vector rVec is defined as: + * \f[ rVec = [\theta v_x, \theta v_y, \theta v_z]\f] + * where \f$\theta\f$ represents rotation angle, and \f$\boldsymbol{v}\f$ represents the normalized rotation axis. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.toRotVec(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q.normalize().toRotVec(assumeUnit); //answer is same as q.toRotVec(). + * ``` + */ + Vec<_Tp, 3> toRotVec(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief get the angle of quaternion, it returns the rotation angle. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. + * \f[\psi = 2 *arccos(\frac{w}{||q||})\f] + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.getAngle(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q.normalize().getAngle(assumeUnit);//same as q.getAngle(). + * ``` + * @note It always return the value between \f$[0, 2\pi]\f$. + */ + _Tp getAngle(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief get the axis of quaternion, it returns a vector of length 3. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. + * + * the unit axis \f$\boldsymbol{u}\f$ is defined by + * \f[\begin{equation} + * \begin{split} + * \boldsymbol{v} + * &= \boldsymbol{u} ||\boldsymbol{v}||\\ + * &= \boldsymbol{u}||q||sin(\frac{\theta}{2}) + * \end{split} + * \end{equation}\f] + * where \f$v=[x, y ,z]\f$ and \f$\theta\f$ represents rotation angle. + * + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.getAxis(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q.normalize().getAxis(assumeUnit);//same as q.getAxis() + * ``` + */ + Vec<_Tp, 3> getAxis(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the dot between quaternion \f$q\f$ and this quaternion. + * + * dot(p, q) is a good metric of how close the quaternions are. + * Indeed, consider the unit quaternion difference \f$p^{-1} * q\f$, its real part is dot(p, q). + * At the same time its real part is equal to \f$\cos(\beta/2)\f$ where \f$\beta\f$ is + * an angle of rotation between p and q, i.e., + * Therefore, the closer dot(p, q) to 1, + * the smaller rotation between them. + * \f[p \cdot q = p.w \cdot q.w + p.x \cdot q.x + p.y \cdot q.y + p.z \cdot q.z\f] + * @param q the other quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * Quatd p(5,6,7,8); + * p.dot(q); + * ``` + */ + _Tp dot(Quat<_Tp> q) const; + + /** + * @brief To calculate the interpolation from \f$q_0\f$ to \f$q_1\f$ by Linear Interpolation(Nlerp) + * For two quaternions, this interpolation curve can be displayed as: + * \f[Lerp(q_0, q_1, t) = (1 - t)q_0 + tq_1.\f] + * Obviously, the lerp will interpolate along a straight line if we think of \f$q_0\f$ and \f$q_1\f$ as a vector + * in a two-dimensional space. When \f$t = 0\f$, it returns \f$q_0\f$ and when \f$t= 1\f$, it returns \f$q_1\f$. + * \f$t\f$ should to be ranged in \f$[0, 1]\f$ normally. + * @param q0 a quaternion used in linear interpolation. + * @param q1 a quaternion used in linear interpolation. + * @param t percent of vector \f$\overrightarrow{q_0q_1}\f$ over a range [0, 1]. + * @note it returns a non-unit quaternion. + */ + static Quat<_Tp> lerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t); + + /** + * @brief To calculate the interpolation from \f$q_0\f$ to \f$q_1\f$ by Normalized Linear Interpolation(Nlerp). + * it returns a normalized quaternion of Linear Interpolation(Lerp). + * \f[ Nlerp(q_0, q_1, t) = \frac{(1 - t)q_0 + tq_1}{||(1 - t)q_0 + tq_1||}.\f] + * The interpolation will always choose the shortest path but the constant speed is not guaranteed. + * @param q0 a quaternion used in normalized linear interpolation. + * @param q1 a quaternion used in normalized linear interpolation. + * @param t percent of vector \f$\overrightarrow{q_0q_1}\f$ over a range [0, 1]. + * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all inputs + quaternion will be normalized inside the function. + * @sa lerp + */ + static Quat<_Tp> nlerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + @brief To calculate the interpolation between \f$q_0\f$ and \f$q_1\f$ by Spherical Linear + Interpolation(Slerp), which can be defined as: + \f[ Slerp(q_0, q_1, t) = \frac{\sin((1-t)\theta)}{\sin(\theta)}q_0 + \frac{\sin(t\theta)}{\sin(\theta)}q_1\f] + where \f$\theta\f$ can be calculated as: + \f[\theta=cos^{-1}(q_0\cdot q_1)\f] + resulting from the both of their norm is unit. + @param q0 a quaternion used in Slerp. + @param q1 a quaternion used in Slerp. + @param t percent of angle between \f$q_0\f$ and \f$q_1\f$ over a range [0, 1]. + @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternions. Otherwise, all input + quaternions will be normalized inside the function. + @param directChange if QUAT_ASSUME_UNIT, the interpolation will choose the nearest path. + @note If the interpolation angle is small, the error between Nlerp and Slerp is not so large. To improve efficiency and + avoid zero division error, we use Nlerp instead of Slerp. + */ + static Quat<_Tp> slerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT, bool directChange=true); + + /** + * @brief To calculate the interpolation between \f$q_0\f$,\f$q_1\f$,\f$q_2\f$,\f$q_3\f$ by Spherical and quadrangle(Squad). This could be defined as: + * \f[Squad(q_i, s_i, s_{i+1}, q_{i+1}, t) = Slerp(Slerp(q_i, q_{i+1}, t), Slerp(s_i, s_{i+1}, t), 2t(1-t))\f] + * where + * \f[s_i = q_i\exp(-\frac{\log(q^*_iq_{i+1}) + \log(q^*_iq_{i-1})}{4})\f] + * + * The Squad expression is analogous to the \f$B\acute{e}zier\f$ curve, but involves spherical linear + * interpolation instead of simple linear interpolation. Each \f$s_i\f$ needs to be calculated by three + * quaternions. + * + * @param q0 the first quaternion. + * @param s0 the second quaternion. + * @param s1 the third quaternion. + * @param q1 thr fourth quaternion. + * @param t interpolation parameter of quadratic and linear interpolation over a range \f$[0, 1]\f$. + * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all input + * quaternions will be normalized inside the function. + * @param directChange if QUAT_ASSUME_UNIT, squad will find the nearest path to interpolate. + * @sa interPoint, spline + */ + static Quat<_Tp> squad(const Quat<_Tp> &q0, const Quat<_Tp> &s0, + const Quat<_Tp> &s1, const Quat<_Tp> &q1, + const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT, + bool directChange=true); + + /** + * @brief This is the part calculation of squad. + * To calculate the intermedia quaternion \f$s_i\f$ between each three quaternion + * \f[s_i = q_i\exp(-\frac{\log(q^*_iq_{i+1}) + \log(q^*_iq_{i-1})}{4}).\f] + * @param q0 the first quaternion. + * @param q1 the second quaternion. + * @param q2 the third quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all input + * quaternions will be normalized inside the function. + * @sa squad + */ + static Quat<_Tp> interPoint(const Quat<_Tp> &q0, const Quat<_Tp> &q1, + const Quat<_Tp> &q2, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief to calculate a quaternion which is the result of a \f$C^1\f$ continuous + * spline curve constructed by squad at the ratio t. Here, the interpolation values are + * between \f$q_1\f$ and \f$q_2\f$. \f$q_0\f$ and \f$q_2\f$ are used to ensure the \f$C^1\f$ + * continuity. if t = 0, it returns \f$q_1\f$, if t = 1, it returns \f$q_2\f$. + * @param q0 the first input quaternion to ensure \f$C^1\f$ continuity. + * @param q1 the second input quaternion. + * @param q2 the third input quaternion. + * @param q3 the fourth input quaternion the same use of \f$q1\f$. + * @param t ratio over a range [0, 1]. + * @param assumeUnit if QUAT_ASSUME_UNIT, \f$q_0, q_1, q_2, q_3\f$ assume to be unit quaternion. Otherwise, all input + * quaternions will be normalized inside the function. + * + * For example: + * + * If there are three double quaternions \f$v_0, v_1, v_2\f$ waiting to be interpolated. + * + * Interpolation between \f$v_0\f$ and \f$v_1\f$ with a ratio \f$t_0\f$ could be calculated as + * ``` + * Quatd::spline(v0, v0, v1, v2, t0); + * ``` + * Interpolation between \f$v_1\f$ and \f$v_2\f$ with a ratio \f$t_0\f$ could be calculated as + * ``` + * Quatd::spline(v0, v1, v2, v2, t0); + * ``` + * @sa squad, slerp + */ + static Quat<_Tp> spline(const Quat<_Tp> &q0, const Quat<_Tp> &q1, + const Quat<_Tp> &q2, const Quat<_Tp> &q3, + const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief Return opposite quaternion \f$-p\f$ + * which satisfies \f$p + (-p) = 0.\f$ + * + * For example + * ``` + * Quatd q{1, 2, 3, 4}; + * std::cout << -q << std::endl; // [-1, -2, -3, -4] + * ``` + */ + Quat<_Tp> operator-() const; + + /** + * @brief return true if two quaternions p and q are nearly equal, i.e. when the absolute + * value of each \f$p_i\f$ and \f$q_i\f$ is less than CV_QUAT_EPS. + */ + bool operator==(const Quat<_Tp>&) const; + + /** + * @brief Addition operator of two quaternions p and q. + * It returns a new quaternion that each value is the sum of \f$p_i\f$ and \f$q_i\f$. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p + q << std::endl; //[6, 8, 10, 12] + * ``` + */ + Quat<_Tp> operator+(const Quat<_Tp>&) const; + + /** + * @brief Addition assignment operator of two quaternions p and q. + * It adds right operand to the left operand and assign the result to left operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p += q; // equivalent to p = p + q + * std::cout << p << std::endl; //[6, 8, 10, 12] + * + * ``` + */ + Quat<_Tp>& operator+=(const Quat<_Tp>&); + + /** + * @brief Subtraction operator of two quaternions p and q. + * It returns a new quaternion that each value is the sum of \f$p_i\f$ and \f$-q_i\f$. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p - q << std::endl; //[-4, -4, -4, -4] + * ``` + */ + Quat<_Tp> operator-(const Quat<_Tp>&) const; + + /** + * @brief Subtraction assignment operator of two quaternions p and q. + * It subtracts right operand from the left operand and assign the result to left operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p -= q; // equivalent to p = p - q + * std::cout << p << std::endl; //[-4, -4, -4, -4] + * + * ``` + */ + Quat<_Tp>& operator-=(const Quat<_Tp>&); + + /** + * @brief Multiplication assignment operator of two quaternions q and p. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication: + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [p_0, \boldsymbol{u}]*[q_0, \boldsymbol{v}]\\ + * &=[p_0q_0 - \boldsymbol{u}\cdot \boldsymbol{v}, p_0\boldsymbol{v} + q_0\boldsymbol{u}+ \boldsymbol{u}\times \boldsymbol{v}]. + * \end{split} + * \end{equation} + * \f] + * where \f$\cdot\f$ means dot product and \f$\times \f$ means cross product. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p *= q; // equivalent to p = p * q + * std::cout << p << std::endl; //[-60, 12, 30, 24] + * ``` + */ + Quat<_Tp>& operator*=(const Quat<_Tp>&); + + /** + * @brief Multiplication assignment operator of a quaternions and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z] * s\\ + * &=[w * s, x * s, y * s, z * s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * p *= s; // equivalent to p = p * s + * std::cout << p << std::endl; //[2.0, 4.0, 6.0, 8.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + Quat<_Tp>& operator*=(const _Tp s); + + /** + * @brief Multiplication operator of two quaternions q and p. + * Multiplies values on either side of the operator. + * + * Rule of quaternion multiplication: + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [p_0, \boldsymbol{u}]*[q_0, \boldsymbol{v}]\\ + * &=[p_0q_0 - \boldsymbol{u}\cdot \boldsymbol{v}, p_0\boldsymbol{v} + q_0\boldsymbol{u}+ \boldsymbol{u}\times \boldsymbol{v}]. + * \end{split} + * \end{equation} + * \f] + * where \f$\cdot\f$ means dot product and \f$\times \f$ means cross product. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p * q << std::endl; //[-60, 12, 30, 24] + * ``` + */ + Quat<_Tp> operator*(const Quat<_Tp>&) const; + + /** + * @brief Division operator of a quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z] / s\\ + * &=[w/s, x/s, y/s, z/s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1, 1.5, 2] + * ``` + * @note the type of scalar should be equal to this quaternion. + */ + Quat<_Tp> operator/(const _Tp s) const; + + /** + * @brief Division operator of two quaternions p and q. + * Divides left hand operand by right hand operand. + * + * Rule of quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / q &= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p / q << std::endl; // equivalent to p * q.inv() + * ``` + */ + Quat<_Tp> operator/(const Quat<_Tp>&) const; + + /** + * @brief Division assignment operator of a quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z] / s\\ + * &=[w / s, x / s, y / s, z / s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0;; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1.0, 1.5, 2.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + Quat<_Tp>& operator/=(const _Tp s); + + /** + * @brief Division assignment operator of two quaternions p and q; + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of quaternion division with a quaternion: + * \f[ + * \begin{equation} + * \begin{split} + * p / q&= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p /= q; // equivalent to p = p * q.inv() + * std::cout << p << std::endl; + * ``` + */ + Quat<_Tp>& operator/=(const Quat<_Tp>&); + + _Tp& operator[](std::size_t n); + + const _Tp& operator[](std::size_t n) const; + + /** + * @brief Subtraction operator of a scalar and a quaternions. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << scalar - p << std::endl; //[1.0, -2, -3, -4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator-(const T s, const Quat&); + + /** + * @brief Subtraction operator of a quaternions and a scalar. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << p - scalar << std::endl; //[-1.0, 2, 3, 4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator-(const Quat&, const T s); + + /** + * @brief Addition operator of a quaternions and a scalar. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << scalar + p << std::endl; //[3.0, 2, 3, 4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator+(const T s, const Quat&); + + /** + * @brief Addition operator of a quaternions and a scalar. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << p + scalar << std::endl; //[3.0, 2, 3, 4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator+(const Quat&, const T s); + + /** + * @brief Multiplication operator of a scalar and a quaternions. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z] * s\\ + * &=[w * s, x * s, y * s, z * s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * std::cout << s * p << std::endl; //[2.0, 4.0, 6.0, 8.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator*(const T s, const Quat&); + + /** + * @brief Multiplication operator of a quaternion and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z] * s\\ + * &=[w * s, x * s, y * s, z * s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * std::cout << p * s << std::endl; //[2.0, 4.0, 6.0, 8.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator*(const Quat&, const T s); + + template + friend std::ostream& cv::operator<<(std::ostream&, const Quat&); + + /** + * @brief Transform a quaternion q to Euler angles. + * + * + * When transforming a quaternion \f$q = w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\f$ to Euler angles, rotation matrix M can be calculated by: + * \f[ \begin{aligned} {M} &={\begin{bmatrix}1-2(y^{2}+z^{2})&2(xy-zx)&2(xz+yw)\\2(xy+zw)&1-2(x^{2}+z^{2})&2(yz-xw)\\2(xz-yw)&2(yz+xw)&1-2(x^{2}+y^{2})\end{bmatrix}}\end{aligned}.\f] + * On the other hand, the rotation matrix can be obtained from Euler angles. + * Using intrinsic rotations with Euler angles type XYZ as an example, + * \f$\theta_1 \f$, \f$\theta_2 \f$, \f$\theta_3 \f$ are three angles for Euler angles, the rotation matrix R can be calculated by:\f[R =X(\theta_1)Y(\theta_2)Z(\theta_3) + * ={\begin{bmatrix}\cos\theta_{2}\cos\theta_{3}&-\cos\theta_{2}\sin\theta_{3}&\sin\theta_{2}\\\cos\theta_{1}\sin\theta_{3}+\cos\theta_{3}\sin\theta_{1}\sin\theta_{2}&\cos\theta_{1}\cos\theta_{3}-\sin\theta_{1}\sin\theta_{2}\sin\theta_{3}&-\cos\theta_{2}\sin\theta_{1}\\\sin\theta_{1}\sin\theta_{3}-\cos\theta_{1}\cos\theta_{3}\sin\theta_{2}&\cos\theta_{3}\sin\theta_{1}+\cos\theta_{1}\sin\theta_{2}\sin\theta_{3}&\cos\theta_{1}\cos_{2}\end{bmatrix}}\f] + * Rotation matrix M and R are equal. As long as \f$ s_{2} \neq 1 \f$, by comparing each element of two matrices ,the solution is\f$\begin{cases} \theta_1 = \arctan2(-m_{23},m_{33})\\\theta_2 = arcsin(m_{13}) \\\theta_3 = \arctan2(-m_{12},m_{11}) \end{cases}\f$. + * + * When \f$ s_{2}=1\f$ or \f$ s_{2}=-1\f$, the gimbal lock occurs. The function will prompt "WARNING: Gimbal Lock will occur. Euler angles is non-unique. For intrinsic rotations, we set the third angle to 0, and for external rotation, we set the first angle to 0.". + * + * When \f$ s_{2}=1\f$ , + * The rotation matrix R is \f$R = {\begin{bmatrix}0&0&1\\\sin(\theta_1+\theta_3)&\cos(\theta_1+\theta_3)&0\\-\cos(\theta_1+\theta_3)&\sin(\theta_1+\theta_3)&0\end{bmatrix}}\f$. + * + * The number of solutions is infinite with the condition \f$\begin{cases} \theta_1+\theta_3 = \arctan2(m_{21},m_{22})\\ \theta_2=\pi/2 \end{cases}\ \f$. + * + * We set \f$ \theta_3 = 0\f$, the solution is \f$\begin{cases} \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \end{cases}\f$. + * + * When \f$ s_{2}=-1\f$, + * The rotation matrix R is \f$X_{1}Y_{2}Z_{3}={\begin{bmatrix}0&0&-1\\-\sin(\theta_1-\theta_3)&\cos(\theta_1-\theta_3)&0\\\cos(\theta_1-\theta_3)&\sin(\theta_1-\theta_3)&0\end{bmatrix}}\f$. + * + * The number of solutions is infinite with the condition \f$\begin{cases} \theta_1+\theta_3 = \arctan2(m_{32},m_{22})\\ \theta_2=\pi/2 \end{cases}\ \f$. + * + * We set \f$ \theta_3 = 0\f$, the solution is \f$ \begin{cases}\theta_1=\arctan2(m_{32},m_{22}) \\ \theta_2=-\pi/2\\ \theta_3=0\end{cases}\f$. + * + * Since \f$ sin \theta\in [-1,1] \f$ and \f$ cos \theta \in [-1,1] \f$, the unnormalized quaternion will cause computational troubles. For this reason, this function will normalize the quaternion at first and @ref QuatAssumeType is not needed. + * + * When the gimbal lock occurs, we set \f$\theta_3 = 0\f$ for intrinsic rotations or \f$\theta_1 = 0\f$ for extrinsic rotations. + * + * As a result, for every Euler angles type, we can get solution as shown in the following table. + * EulerAnglesType | Ordinary | \f$\theta_2 = π/2\f$ | \f$\theta_2 = -π/2\f$ + * ------------- | -------------| -------------| ------------- + * INT_XYZ|\f$ \theta_1 = \arctan2(-m_{23},m_{33})\\\theta_2 = \arcsin(m_{13}) \\\theta_3= \arctan2(-m_{12},m_{11}) \f$|\f$ \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{32},m_{22})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_XZY|\f$ \theta_1 = \arctan2(m_{32},m_{22})\\\theta_2 = -\arcsin(m_{12}) \\\theta_3= \arctan2(m_{13},m_{11}) \f$|\f$ \theta_1=\arctan2(m_{31},m_{33})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{23},m_{33})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_YXZ|\f$ \theta_1 = \arctan2(m_{13},m_{33})\\\theta_2 = -\arcsin(m_{23}) \\\theta_3= \arctan2(m_{21},m_{22}) \f$|\f$ \theta_1=\arctan2(m_{12},m_{11})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{12},m_{11})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_YZX|\f$ \theta_1 = \arctan2(-m_{31},m_{11})\\\theta_2 = \arcsin(m_{21}) \\\theta_3= \arctan2(-m_{23},m_{22}) \f$|\f$ \theta_1=\arctan2(m_{13},m_{33})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{13},m_{12})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_ZXY|\f$ \theta_1 = \arctan2(-m_{12},m_{22})\\\theta_2 = \arcsin(m_{32}) \\\theta_3= \arctan2(-m_{31},m_{33}) \f$|\f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_ZYX|\f$ \theta_1 = \arctan2(m_{21},m_{11})\\\theta_2 = \arcsin(-m_{31}) \\\theta_3= \arctan2(m_{32},m_{33}) \f$|\f$ \theta_1=\arctan2(m_{23},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{12},m_{22})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * EXT_XYZ|\f$ \theta_1 = \arctan2(m_{32},m_{33})\\\theta_2 = \arcsin(-m_{31}) \\\ \theta_3 = \arctan2(m_{21},m_{11})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{23},m_{22}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{12},m_{22}) \f$ + * EXT_XZY|\f$ \theta_1 = \arctan2(-m_{23},m_{22})\\\theta_2 = \arcsin(m_{21}) \\\theta_3= \arctan2(-m_{31},m_{11})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{13},m_{33}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{13},m_{12}) \f$ + * EXT_YXZ|\f$ \theta_1 = \arctan2(-m_{31},m_{33}) \\\theta_2 = \arcsin(m_{32}) \\\theta_3= \arctan2(-m_{12},m_{22})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{21},m_{11}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{21},m_{11}) \f$ + * EXT_YZX|\f$ \theta_1 = \arctan2(m_{13},m_{11})\\\theta_2 = -\arcsin(m_{12}) \\\theta_3= \arctan2(m_{32},m_{22})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{31},m_{33}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{23},m_{33}) \f$ + * EXT_ZXY|\f$ \theta_1 = \arctan2(m_{21},m_{22})\\\theta_2 = -\arcsin(m_{23}) \\\theta_3= \arctan2(m_{13},m_{33})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{12},m_{11}) \f$|\f$ \theta_1= 0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{12},m_{11}) \f$ + * EXT_ZYX|\f$ \theta_1 = \arctan2(-m_{12},m_{11})\\\theta_2 = \arcsin(m_{13}) \\\theta_3= \arctan2(-m_{23},m_{33})\f$|\f$ \theta_1=0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{21},m_{22}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{32},m_{22}) \f$ + * + * EulerAnglesType | Ordinary | \f$\theta_2 = 0\f$ | \f$\theta_2 = π\f$ + * ------------- | -------------| -------------| ------------- + * INT_XYX| \f$ \theta_1 = \arctan2(m_{21},-m_{31})\\\theta_2 =\arccos(m_{11}) \\\theta_3 = \arctan2(m_{12},m_{13}) \f$| \f$ \theta_1=\arctan2(m_{32},m_{33})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{23},m_{22})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_XZX| \f$ \theta_1 = \arctan2(m_{31},m_{21})\\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{13},-m_{12}) \f$| \f$ \theta_1=\arctan2(m_{32},m_{33})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(-m_{32},m_{33})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_YXY| \f$ \theta_1 = \arctan2(m_{12},m_{32})\\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{21},-m_{23}) \f$| \f$ \theta_1=\arctan2(m_{13},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(-m_{31},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_YZY| \f$ \theta_1 = \arctan2(m_{32},-m_{12})\\\theta_2 = \arccos(m_{22}) \\\theta_3 =\arctan2(m_{23},m_{21}) \f$| \f$ \theta_1=\arctan2(m_{13},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{13},-m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_ZXZ| \f$ \theta_1 = \arctan2(-m_{13},m_{23})\\\theta_2 = \arccos(m_{33}) \\\theta_3 =\arctan2(m_{31},m_{32}) \f$| \f$ \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_ZYZ| \f$ \theta_1 = \arctan2(m_{23},m_{13})\\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(m_{32},-m_{31}) \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * EXT_XYX| \f$ \theta_1 = \arctan2(m_{12},m_{13}) \\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{21},-m_{31})\f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{32},m_{33}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3= \arctan2(m_{23},m_{22}) \f$ + * EXT_XZX| \f$ \theta_1 = \arctan2(m_{13},-m_{12})\\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{31},m_{21})\f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{32},m_{33}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(-m_{32},m_{33}) \f$ + * EXT_YXY| \f$ \theta_1 = \arctan2(m_{21},-m_{23})\\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{12},m_{32}) \f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{13},m_{11}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(-m_{31},m_{11}) \f$ + * EXT_YZY| \f$ \theta_1 = \arctan2(m_{23},m_{21}) \\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{32},-m_{12}) \f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{13},m_{11}) \f$| \f$ \theta_1=0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{13},-m_{11}) \f$ + * EXT_ZXZ| \f$ \theta_1 = \arctan2(m_{31},m_{32}) \\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(-m_{13},m_{23})\f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{21},m_{22}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{21},m_{11}) \f$ + * EXT_ZYZ| \f$ \theta_1 = \arctan2(m_{32},-m_{31})\\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(m_{23},m_{13}) \f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{21},m_{11}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{21},m_{11}) \f$ + * + * @param eulerAnglesType the convertion Euler angles type + */ + + Vec<_Tp, 3> toEulerAngles(QuatEnum::EulerAnglesType eulerAnglesType); + + _Tp w, x, y, z; + +}; + +template +Quat inv(const Quat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat sinh(const Quat &q); + +template +Quat cosh(const Quat &q); + +template +Quat tanh(const Quat &q); + +template +Quat sin(const Quat &q); + +template +Quat cos(const Quat &q); + +template +Quat tan(const Quat &q); + +template +Quat asinh(const Quat &q); + +template +Quat acosh(const Quat &q); + +template +Quat atanh(const Quat &q); + +template +Quat asin(const Quat &q); + +template +Quat acos(const Quat &q); + +template +Quat atan(const Quat &q); + +template +Quat power(const Quat &q, const Quat &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat exp(const Quat &q); + +template +Quat log(const Quat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat power(const Quat& q, const T x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat crossProduct(const Quat &p, const Quat &q); + +template +Quat sqrt(const Quat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat operator*(const T, const Quat&); + +template +Quat operator*(const Quat&, const T); + +template +std::ostream& operator<<(std::ostream&, const Quat&); + +using Quatd = Quat; +using Quatf = Quat; + +//! @} core +} + +#include "opencv2/core/quaternion.inl.hpp" + +#endif /* OPENCV_CORE_QUATERNION_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/quaternion.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/quaternion.inl.hpp new file mode 100644 index 0000000..29a16d9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/quaternion.inl.hpp @@ -0,0 +1,1063 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang + +#ifndef OPENCV_CORE_QUATERNION_INL_HPP +#define OPENCV_CORE_QUATERNION_INL_HPP + +#ifndef OPENCV_CORE_QUATERNION_HPP +#erorr This is not a standalone header. Include quaternion.hpp instead. +#endif + +//@cond IGNORE +/////////////////////////////////////////////////////////////////////////////////////// +//Implementation +namespace cv { + +template +Quat::Quat() : w(0), x(0), y(0), z(0) {} + +template +Quat::Quat(const Vec &coeff):w(coeff[0]), x(coeff[1]), y(coeff[2]), z(coeff[3]){} + +template +Quat::Quat(const T qw, const T qx, const T qy, const T qz):w(qw), x(qx), y(qy), z(qz){} + +template +Quat Quat::createFromAngleAxis(const T angle, const Vec &axis) +{ + T w, x, y, z; + T vNorm = std::sqrt(axis.dot(axis)); + if (vNorm < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "this quaternion does not represent a rotation"); + } + const T angle_half = angle * T(0.5); + w = std::cos(angle_half); + const T sin_v = std::sin(angle_half); + const T sin_norm = sin_v / vNorm; + x = sin_norm * axis[0]; + y = sin_norm * axis[1]; + z = sin_norm * axis[2]; + return Quat(w, x, y, z); +} + +template +Quat Quat::createFromRotMat(InputArray _R) +{ + CV_CheckTypeEQ(_R.type(), cv::traits::Type::value, ""); + if (_R.rows() != 3 || _R.cols() != 3) + { + CV_Error(Error::StsBadArg, "Cannot convert matrix to quaternion: rotation matrix should be a 3x3 matrix"); + } + Matx R; + _R.copyTo(R); + + T S, w, x, y, z; + T trace = R(0, 0) + R(1, 1) + R(2, 2); + if (trace > 0) + { + S = std::sqrt(trace + 1) * T(2); + x = (R(1, 2) - R(2, 1)) / S; + y = (R(2, 0) - R(0, 2)) / S; + z = (R(0, 1) - R(1, 0)) / S; + w = -T(0.25) * S; + } + else if (R(0, 0) > R(1, 1) && R(0, 0) > R(2, 2)) + { + + S = std::sqrt(T(1.0) + R(0, 0) - R(1, 1) - R(2, 2)) * T(2); + x = -T(0.25) * S; + y = -(R(1, 0) + R(0, 1)) / S; + z = -(R(0, 2) + R(2, 0)) / S; + w = (R(1, 2) - R(2, 1)) / S; + } + else if (R(1, 1) > R(2, 2)) + { + S = std::sqrt(T(1.0) - R(0, 0) + R(1, 1) - R(2, 2)) * T(2); + x = (R(0, 1) + R(1, 0)) / S; + y = T(0.25) * S; + z = (R(1, 2) + R(2, 1)) / S; + w = (R(0, 2) - R(2, 0)) / S; + } + else + { + S = std::sqrt(T(1.0) - R(0, 0) - R(1, 1) + R(2, 2)) * T(2); + x = (R(0, 2) + R(2, 0)) / S; + y = (R(1, 2) + R(2, 1)) / S; + z = T(0.25) * S; + w = -(R(0, 1) - R(1, 0)) / S; + } + return Quat (w, x, y, z); +} + +template +Quat Quat::createFromRvec(InputArray _rvec) +{ + if (!((_rvec.cols() == 1 && _rvec.rows() == 3) || (_rvec.cols() == 3 && _rvec.rows() == 1))) { + CV_Error(Error::StsBadArg, "Cannot convert rotation vector to quaternion: The length of rotation vector should be 3"); + } + Vec rvec; + _rvec.copyTo(rvec); + T psi = std::sqrt(rvec.dot(rvec)); + if (abs(psi) < CV_QUAT_EPS) { + return Quat (1, 0, 0, 0); + } + Vec axis = rvec / psi; + return createFromAngleAxis(psi, axis); +} + +template +inline Quat Quat::operator-() const +{ + return Quat(-w, -x, -y, -z); +} + + +template +inline bool Quat::operator==(const Quat &q) const +{ + return (abs(w - q.w) < CV_QUAT_EPS && abs(x - q.x) < CV_QUAT_EPS && abs(y - q.y) < CV_QUAT_EPS && abs(z - q.z) < CV_QUAT_EPS); +} + +template +inline Quat Quat::operator+(const Quat &q1) const +{ + return Quat(w + q1.w, x + q1.x, y + q1.y, z + q1.z); +} + +template +inline Quat operator+(const T a, const Quat& q) +{ + return Quat(q.w + a, q.x, q.y, q.z); +} + +template +inline Quat operator+(const Quat& q, const T a) +{ + return Quat(q.w + a, q.x, q.y, q.z); +} + +template +inline Quat operator-(const T a, const Quat& q) +{ + return Quat(a - q.w, -q.x, -q.y, -q.z); +} + +template +inline Quat operator-(const Quat& q, const T a) +{ + return Quat(q.w - a, q.x, q.y, q.z); +} + +template +inline Quat Quat::operator-(const Quat &q1) const +{ + return Quat(w - q1.w, x - q1.x, y - q1.y, z - q1.z); +} + +template +inline Quat& Quat::operator+=(const Quat &q1) +{ + w += q1.w; + x += q1.x; + y += q1.y; + z += q1.z; + return *this; +} + +template +inline Quat& Quat::operator-=(const Quat &q1) +{ + w -= q1.w; + x -= q1.x; + y -= q1.y; + z -= q1.z; + return *this; +} + +template +inline Quat Quat::operator*(const Quat &q1) const +{ + Vec q{w, x, y, z}; + Vec q2{q1.w, q1.x, q1.y, q1.z}; + return Quat(q * q2); +} + + +template +Quat operator*(const Quat &q1, const T a) +{ + return Quat(a * q1.w, a * q1.x, a * q1.y, a * q1.z); +} + +template +Quat operator*(const T a, const Quat &q1) +{ + return Quat(a * q1.w, a * q1.x, a * q1.y, a * q1.z); +} + +template +inline Quat& Quat::operator*=(const Quat &q1) +{ + T qw, qx, qy, qz; + qw = w * q1.w - x * q1.x - y * q1.y - z * q1.z; + qx = x * q1.w + w * q1.x + y * q1.z - z * q1.y; + qy = y * q1.w + w * q1.y + z * q1.x - x * q1.z; + qz = z * q1.w + w * q1.z + x * q1.y - y * q1.x; + w = qw; + x = qx; + y = qy; + z = qz; + return *this; +} + +template +inline Quat& Quat::operator/=(const Quat &q1) +{ + Quat q(*this * q1.inv()); + w = q.w; + x = q.x; + y = q.y; + z = q.z; + return *this; +} +template +Quat& Quat::operator*=(const T q1) +{ + w *= q1; + x *= q1; + y *= q1; + z *= q1; + return *this; +} + +template +inline Quat& Quat::operator/=(const T a) +{ + const T a_inv = 1.0 / a; + w *= a_inv; + x *= a_inv; + y *= a_inv; + z *= a_inv; + return *this; +} + +template +inline Quat Quat::operator/(const T a) const +{ + const T a_inv = T(1.0) / a; + return Quat(w * a_inv, x * a_inv, y * a_inv, z * a_inv); +} + +template +inline Quat Quat::operator/(const Quat &q) const +{ + return *this * q.inv(); +} + +template +inline const T& Quat::operator[](std::size_t n) const +{ + switch (n) { + case 0: + return w; + case 1: + return x; + case 2: + return y; + case 3: + return z; + default: + CV_Error(Error::StsOutOfRange, "subscript exceeds the index range"); + } +} + +template +inline T& Quat::operator[](std::size_t n) +{ + switch (n) { + case 0: + return w; + case 1: + return x; + case 2: + return y; + case 3: + return z; + default: + CV_Error(Error::StsOutOfRange, "subscript exceeds the index range"); + } +} + +template +std::ostream & operator<<(std::ostream &os, const Quat &q) +{ + os << "Quat " << Vec{q.w, q.x, q.y, q.z}; + return os; +} + +template +inline T Quat::at(size_t index) const +{ + return (*this)[index]; +} + +template +inline Quat Quat::conjugate() const +{ + return Quat(w, -x, -y, -z); +} + +template +inline T Quat::norm() const +{ + return std::sqrt(dot(*this)); +} + +template +Quat exp(const Quat &q) +{ + return q.exp(); +} + +template +Quat Quat::exp() const +{ + Vec v{x, y, z}; + T normV = std::sqrt(v.dot(v)); + T k = normV < CV_QUAT_EPS ? 1 : std::sin(normV) / normV; + return std::exp(w) * Quat(std::cos(normV), v[0] * k, v[1] * k, v[2] * k); +} + +template +Quat log(const Quat &q, QuatAssumeType assumeUnit) +{ + return q.log(assumeUnit); +} + +template +Quat Quat::log(QuatAssumeType assumeUnit) const +{ + Vec v{x, y, z}; + T vNorm = std::sqrt(v.dot(v)); + if (assumeUnit) + { + T k = vNorm < CV_QUAT_EPS ? 1 : std::acos(w) / vNorm; + return Quat(0, v[0] * k, v[1] * k, v[2] * k); + } + T qNorm = norm(); + if (qNorm < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "Cannot apply this quaternion to log function: undefined"); + } + T k = vNorm < CV_QUAT_EPS ? 1 : std::acos(w / qNorm) / vNorm; + return Quat(std::log(qNorm), v[0] * k, v[1] * k, v[2] *k); +} + +template +inline Quat power(const Quat &q1, const T alpha, QuatAssumeType assumeUnit) +{ + return q1.power(alpha, assumeUnit); +} + +template +inline Quat Quat::power(const T alpha, QuatAssumeType assumeUnit) const +{ + if (x * x + y * y + z * z > CV_QUAT_EPS) + { + T angle = getAngle(assumeUnit); + Vec axis = getAxis(assumeUnit); + if (assumeUnit) + { + return createFromAngleAxis(alpha * angle, axis); + } + return std::pow(norm(), alpha) * createFromAngleAxis(alpha * angle, axis); + } + else + { + return std::pow(norm(), alpha) * Quat(w, x, y, z); + } +} + + +template +inline Quat sqrt(const Quat &q, QuatAssumeType assumeUnit) +{ + return q.sqrt(assumeUnit); +} + +template +inline Quat Quat::sqrt(QuatAssumeType assumeUnit) const +{ + return power(0.5, assumeUnit); +} + + +template +inline Quat power(const Quat &p, const Quat &q, QuatAssumeType assumeUnit) +{ + return p.power(q, assumeUnit); +} + + +template +inline Quat Quat::power(const Quat &q, QuatAssumeType assumeUnit) const +{ + return cv::exp(q * log(assumeUnit)); +} + +template +inline T Quat::dot(Quat q1) const +{ + return w * q1.w + x * q1.x + y * q1.y + z * q1.z; +} + + +template +inline Quat crossProduct(const Quat &p, const Quat &q) +{ + return p.crossProduct(q); +} + + +template +inline Quat Quat::crossProduct(const Quat &q) const +{ + return Quat (0, y * q.z - z * q.y, z * q.x - x * q.z, x * q.y - q.x * y); +} + +template +inline Quat Quat::normalize() const +{ + T normVal = norm(); + if (normVal < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "Cannot normalize this quaternion: the norm is too small."); + } + return Quat(w / normVal, x / normVal, y / normVal, z / normVal) ; +} + +template +inline Quat inv(const Quat &q, QuatAssumeType assumeUnit) +{ + return q.inv(assumeUnit); +} + + +template +inline Quat Quat::inv(QuatAssumeType assumeUnit) const +{ + if (assumeUnit) + { + return conjugate(); + } + T norm2 = dot(*this); + if (norm2 < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "This quaternion do not have inverse quaternion"); + } + return conjugate() / norm2; +} + +template +inline Quat sinh(const Quat &q) +{ + return q.sinh(); +} + + +template +inline Quat Quat::sinh() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::cosh(w) * std::sin(vNorm) / vNorm; + return Quat(std::sinh(w) * std::cos(vNorm), v[0] * k, v[1] * k, v[2] * k); +} + + +template +inline Quat cosh(const Quat &q) +{ + return q.cosh(); +} + + +template +inline Quat Quat::cosh() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::sinh(w) * std::sin(vNorm) / vNorm; + return Quat(std::cosh(w) * std::cos(vNorm), v[0] * k, v[1] * k, v[2] * k); +} + +template +inline Quat tanh(const Quat &q) +{ + return q.tanh(); +} + +template +inline Quat Quat::tanh() const +{ + return sinh() * cosh().inv(); +} + + +template +inline Quat sin(const Quat &q) +{ + return q.sin(); +} + + +template +inline Quat Quat::sin() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::cos(w) * std::sinh(vNorm) / vNorm; + return Quat(std::sin(w) * std::cosh(vNorm), v[0] * k, v[1] * k, v[2] * k); +} + +template +inline Quat cos(const Quat &q) +{ + return q.cos(); +} + +template +inline Quat Quat::cos() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::sin(w) * std::sinh(vNorm) / vNorm; + return Quat(std::cos(w) * std::cosh(vNorm), -v[0] * k, -v[1] * k, -v[2] * k); +} + +template +inline Quat tan(const Quat &q) +{ + return q.tan(); +} + +template +inline Quat Quat::tan() const +{ + return sin() * cos().inv(); +} + +template +inline Quat asinh(const Quat &q) +{ + return q.asinh(); +} + +template +inline Quat Quat::asinh() const +{ + return cv::log(*this + cv::power(*this * *this + Quat(1, 0, 0, 0), 0.5)); +} + +template +inline Quat acosh(const Quat &q) +{ + return q.acosh(); +} + +template +inline Quat Quat::acosh() const +{ + return cv::log(*this + cv::power(*this * *this - Quat(1,0,0,0), 0.5)); +} + +template +inline Quat atanh(const Quat &q) +{ + return q.atanh(); +} + +template +inline Quat Quat::atanh() const +{ + Quat ident(1, 0, 0, 0); + Quat c1 = (ident + *this).log(); + Quat c2 = (ident - *this).log(); + return 0.5 * (c1 - c2); +} + +template +inline Quat asin(const Quat &q) +{ + return q.asin(); +} + +template +inline Quat Quat::asin() const +{ + Quat v(0, x, y, z); + T vNorm = v.norm(); + T k = vNorm < CV_QUAT_EPS ? 1 : vNorm; + return -v / k * (*this * v / k).asinh(); +} + +template +inline Quat acos(const Quat &q) +{ + return q.acos(); +} + +template +inline Quat Quat::acos() const +{ + Quat v(0, x, y, z); + T vNorm = v.norm(); + T k = vNorm < CV_QUAT_EPS ? 1 : vNorm; + return -v / k * acosh(); +} + +template +inline Quat atan(const Quat &q) +{ + return q.atan(); +} + +template +inline Quat Quat::atan() const +{ + Quat v(0, x, y, z); + T vNorm = v.norm(); + T k = vNorm < CV_QUAT_EPS ? 1 : vNorm; + return -v / k * (*this * v / k).atanh(); +} + +template +inline T Quat::getAngle(QuatAssumeType assumeUnit) const +{ + if (assumeUnit) + { + return 2 * std::acos(w); + } + if (norm() < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "This quaternion does not represent a rotation"); + } + return 2 * std::acos(w / norm()); +} + +template +inline Vec Quat::getAxis(QuatAssumeType assumeUnit) const +{ + T angle = getAngle(assumeUnit); + const T sin_v = std::sin(angle * 0.5); + if (assumeUnit) + { + return Vec{x, y, z} / sin_v; + } + return Vec {x, y, z} / (norm() * sin_v); +} + +template +Matx Quat::toRotMat4x4(QuatAssumeType assumeUnit) const +{ + T a = w, b = x, c = y, d = z; + if (!assumeUnit) + { + Quat qTemp = normalize(); + a = qTemp.w; + b = qTemp.x; + c = qTemp.y; + d = qTemp.z; + } + Matx R{ + 1 - 2 * (c * c + d * d), 2 * (b * c - a * d) , 2 * (b * d + a * c) , 0, + 2 * (b * c + a * d) , 1 - 2 * (b * b + d * d), 2 * (c * d - a * b) , 0, + 2 * (b * d - a * c) , 2 * (c * d + a * b) , 1 - 2 * (b * b + c * c), 0, + 0 , 0 , 0 , 1, + }; + return R; +} + +template +Matx Quat::toRotMat3x3(QuatAssumeType assumeUnit) const +{ + T a = w, b = x, c = y, d = z; + if (!assumeUnit) + { + Quat qTemp = normalize(); + a = qTemp.w; + b = qTemp.x; + c = qTemp.y; + d = qTemp.z; + } + Matx R{ + 1 - 2 * (c * c + d * d), 2 * (b * c - a * d) , 2 * (b * d + a * c), + 2 * (b * c + a * d) , 1 - 2 * (b * b + d * d), 2 * (c * d - a * b), + 2 * (b * d - a * c) , 2 * (c * d + a * b) , 1 - 2 * (b * b + c * c) + }; + return R; +} + +template +Vec Quat::toRotVec(QuatAssumeType assumeUnit) const +{ + T angle = getAngle(assumeUnit); + Vec axis = getAxis(assumeUnit); + return angle * axis; +} + +template +Vec Quat::toVec() const +{ + return Vec{w, x, y, z}; +} + +template +Quat Quat::lerp(const Quat &q0, const Quat &q1, const T t) +{ + return (1 - t) * q0 + t * q1; +} + +template +Quat Quat::slerp(const Quat &q0, const Quat &q1, const T t, QuatAssumeType assumeUnit, bool directChange) +{ + Quatd v0(q0); + Quatd v1(q1); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + } + T cosTheta = v0.dot(v1); + constexpr T DOT_THRESHOLD = 0.995; + if (cosTheta > DOT_THRESHOLD) + { + return nlerp(v0, v1, t, QUAT_ASSUME_UNIT); + } + + if (directChange && cosTheta < 0) + { + v0 = -v0; + cosTheta = -cosTheta; + } + T sinTheta = std::sqrt(1 - cosTheta * cosTheta); + T angle = atan2(sinTheta, cosTheta); + return (std::sin((1 - t) * angle) / (sinTheta) * v0 + std::sin(t * angle) / (sinTheta) * v1).normalize(); +} + + +template +inline Quat Quat::nlerp(const Quat &q0, const Quat &q1, const T t, QuatAssumeType assumeUnit) +{ + Quat v0(q0), v1(q1); + if (v1.dot(v0) < 0) + { + v0 = -v0; + } + if (assumeUnit) + { + return ((1 - t) * v0 + t * v1).normalize(); + } + v0 = v0.normalize(); + v1 = v1.normalize(); + return ((1 - t) * v0 + t * v1).normalize(); +} + + +template +inline bool Quat::isNormal(T eps) const +{ + + double normVar = norm(); + if ((normVar > 1 - eps) && (normVar < 1 + eps)) + return true; + return false; +} + +template +inline void Quat::assertNormal(T eps) const +{ + if (!isNormal(eps)) + CV_Error(Error::StsBadArg, "Quaternion should be normalized"); +} + + +template +inline Quat Quat::squad(const Quat &q0, const Quat &q1, + const Quat &q2, const Quat &q3, + const T t, QuatAssumeType assumeUnit, + bool directChange) +{ + Quat v0(q0), v1(q1), v2(q2), v3(q3); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + v2 = v2.normalize(); + v3 = v3.normalize(); + } + + Quat c0 = slerp(v0, v3, t, assumeUnit, directChange); + Quat c1 = slerp(v1, v2, t, assumeUnit, directChange); + return slerp(c0, c1, 2 * t * (1 - t), assumeUnit, directChange); +} + +template +Quat Quat::interPoint(const Quat &q0, const Quat &q1, + const Quat &q2, QuatAssumeType assumeUnit) +{ + Quat v0(q0), v1(q1), v2(q2); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + v2 = v2.normalize(); + } + return v1 * cv::exp(-(cv::log(v1.conjugate() * v0, assumeUnit) + (cv::log(v1.conjugate() * v2, assumeUnit))) / 4); +} + +template +Quat Quat::spline(const Quat &q0, const Quat &q1, const Quat &q2, const Quat &q3, const T t, QuatAssumeType assumeUnit) +{ + Quatd v0(q0), v1(q1), v2(q2), v3(q3); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + v2 = v2.normalize(); + v3 = v3.normalize(); + } + T cosTheta; + std::vector> vec{v0, v1, v2, v3}; + for (size_t i = 0; i < 3; ++i) + { + cosTheta = vec[i].dot(vec[i + 1]); + if (cosTheta < 0) + { + vec[i + 1] = -vec[i + 1]; + } + } + Quat s1 = interPoint(vec[0], vec[1], vec[2], QUAT_ASSUME_UNIT); + Quat s2 = interPoint(vec[1], vec[2], vec[3], QUAT_ASSUME_UNIT); + return squad(vec[1], s1, s2, vec[2], t, assumeUnit, QUAT_ASSUME_NOT_UNIT); +} + +namespace detail { + +template static +Quat createFromAxisRot(int axis, const T theta) +{ + if (axis == 0) + return Quat::createFromXRot(theta); + if (axis == 1) + return Quat::createFromYRot(theta); + if (axis == 2) + return Quat::createFromZRot(theta); + CV_Assert(0); +} + +inline bool isIntAngleType(QuatEnum::EulerAnglesType eulerAnglesType) +{ + return eulerAnglesType < QuatEnum::EXT_XYZ; +} + +inline bool isTaitBryan(QuatEnum::EulerAnglesType eulerAnglesType) +{ + return eulerAnglesType/6 == 1 || eulerAnglesType/6 == 3; +} +} // namespace detail + +template +Quat Quat::createFromYRot(const T theta) +{ + return Quat{std::cos(theta * 0.5f), 0, std::sin(theta * 0.5f), 0}; +} + +template +Quat Quat::createFromXRot(const T theta){ + return Quat{std::cos(theta * 0.5f), std::sin(theta * 0.5f), 0, 0}; +} + +template +Quat Quat::createFromZRot(const T theta){ + return Quat{std::cos(theta * 0.5f), 0, 0, std::sin(theta * 0.5f)}; +} + + +template +Quat Quat::createFromEulerAngles(const Vec &angles, QuatEnum::EulerAnglesType eulerAnglesType) { + CV_Assert(eulerAnglesType < QuatEnum::EulerAnglesType::EULER_ANGLES_MAX_VALUE); + static const int rotationAxis[24][3] = { + {0, 1, 2}, ///< Intrinsic rotations with the Euler angles type X-Y-Z + {0, 2, 1}, ///< Intrinsic rotations with the Euler angles type X-Z-Y + {1, 0, 2}, ///< Intrinsic rotations with the Euler angles type Y-X-Z + {1, 2, 0}, ///< Intrinsic rotations with the Euler angles type Y-Z-X + {2, 0, 1}, ///< Intrinsic rotations with the Euler angles type Z-X-Y + {2, 1, 0}, ///< Intrinsic rotations with the Euler angles type Z-Y-X + {0, 1, 0}, ///< Intrinsic rotations with the Euler angles type X-Y-X + {0, 2, 0}, ///< Intrinsic rotations with the Euler angles type X-Z-X + {1, 0, 1}, ///< Intrinsic rotations with the Euler angles type Y-X-Y + {1, 2, 1}, ///< Intrinsic rotations with the Euler angles type Y-Z-Y + {2, 0, 2}, ///< Intrinsic rotations with the Euler angles type Z-X-Z + {2, 1, 2}, ///< Intrinsic rotations with the Euler angles type Z-Y-Z + {0, 1, 2}, ///< Extrinsic rotations with the Euler angles type X-Y-Z + {0, 2, 1}, ///< Extrinsic rotations with the Euler angles type X-Z-Y + {1, 0, 2}, ///< Extrinsic rotations with the Euler angles type Y-X-Z + {1, 2, 0}, ///< Extrinsic rotations with the Euler angles type Y-Z-X + {2, 0, 1}, ///< Extrinsic rotations with the Euler angles type Z-X-Y + {2, 1, 0}, ///< Extrinsic rotations with the Euler angles type Z-Y-X + {0, 1, 0}, ///< Extrinsic rotations with the Euler angles type X-Y-X + {0, 2, 0}, ///< Extrinsic rotations with the Euler angles type X-Z-X + {1, 0, 1}, ///< Extrinsic rotations with the Euler angles type Y-X-Y + {1, 2, 1}, ///< Extrinsic rotations with the Euler angles type Y-Z-Y + {2, 0, 2}, ///< Extrinsic rotations with the Euler angles type Z-X-Z + {2, 1, 2} ///< Extrinsic rotations with the Euler angles type Z-Y-Z + }; + Quat q1 = detail::createFromAxisRot(rotationAxis[eulerAnglesType][0], angles(0)); + Quat q2 = detail::createFromAxisRot(rotationAxis[eulerAnglesType][1], angles(1)); + Quat q3 = detail::createFromAxisRot(rotationAxis[eulerAnglesType][2], angles(2)); + if (detail::isIntAngleType(eulerAnglesType)) + { + return q1 * q2 * q3; + } + else // (!detail::isIntAngleType(eulerAnglesType)) + { + return q3 * q2 * q1; + } +} + +template +Vec Quat::toEulerAngles(QuatEnum::EulerAnglesType eulerAnglesType){ + CV_Assert(eulerAnglesType < QuatEnum::EulerAnglesType::EULER_ANGLES_MAX_VALUE); + Matx33d R = toRotMat3x3(); + enum { + C_ZERO, + C_PI, + C_PI_2, + N_CONSTANTS, + R_0_0 = N_CONSTANTS, R_0_1, R_0_2, + R_1_0, R_1_1, R_1_2, + R_2_0, R_2_1, R_2_2 + }; + static const T constants_[N_CONSTANTS] = { + 0, // C_ZERO + (T)CV_PI, // C_PI + (T)(CV_PI * 0.5) // C_PI_2, -C_PI_2 + }; + static const int rotationR_[24][12] = { + {+R_0_2, +R_1_0, +R_1_1, C_PI_2, +R_2_1, +R_1_1, -C_PI_2, -R_1_2, +R_2_2, +R_0_2, -R_0_1, +R_0_0}, // INT_XYZ + {+R_0_1, -R_1_2, +R_2_2, -C_PI_2, +R_2_0, +R_2_2, C_PI_2, +R_2_1, +R_1_1, -R_0_1, +R_0_2, +R_0_0}, // INT_XZY + {+R_1_2, -R_0_1, +R_0_0, -C_PI_2, +R_0_1, +R_0_0, C_PI_2, +R_0_2, +R_2_2, -R_1_2, +R_1_0, +R_1_1}, // INT_YXZ + {+R_1_0, +R_0_2, +R_2_2, C_PI_2, +R_0_2, +R_0_1, -C_PI_2, -R_2_0, +R_0_0, +R_1_0, -R_1_2, +R_1_1}, // INT_YZX + {+R_2_1, +R_1_0, +R_0_0, C_PI_2, +R_1_0, +R_0_0, -C_PI_2, -R_0_1, +R_1_1, +R_2_1, -R_2_0, +R_2_2}, // INT_ZXY + {+R_2_0, -R_0_1, +R_1_1, -C_PI_2, +R_1_2, +R_1_1, C_PI_2, +R_1_0, +R_0_0, -R_2_0, +R_2_1, +R_2_2}, // INT_ZYX + {+R_0_0, +R_2_1, +R_2_2, C_ZERO, +R_1_2, +R_1_1, C_PI, +R_1_0, -R_2_0, +R_0_0, +R_0_1, +R_0_2}, // INT_XYX + {+R_0_0, +R_2_1, +R_2_2, C_ZERO, -R_2_1, +R_2_2, C_PI, +R_2_0, +R_1_0, +R_0_0, +R_0_2, -R_0_1}, // INT_XZX + {+R_1_1, +R_0_2, +R_0_0, C_ZERO, -R_2_0, +R_0_0, C_PI, +R_0_1, +R_2_1, +R_1_1, +R_1_0, -R_1_2}, // INT_YXY + {+R_1_1, +R_0_2, +R_0_0, C_ZERO, +R_0_2, -R_0_0, C_PI, +R_2_1, -R_0_1, +R_1_1, +R_1_2, +R_1_0}, // INT_YZY + {+R_2_2, +R_1_0, +R_1_1, C_ZERO, +R_1_0, +R_0_0, C_PI, +R_0_2, -R_1_2, +R_2_2, +R_2_0, +R_2_1}, // INT_ZXZ + {+R_2_2, +R_1_0, +R_0_0, C_ZERO, +R_1_0, +R_0_0, C_PI, +R_1_2, +R_0_2, +R_2_2, +R_2_1, -R_2_0}, // INT_ZYZ + + {+R_2_0, -C_PI_2, -R_0_1, +R_1_1, C_PI_2, +R_1_2, +R_1_1, +R_2_1, +R_2_2, -R_2_0, +R_1_0, +R_0_0}, // EXT_XYZ + {+R_1_0, C_PI_2, +R_0_2, +R_2_2, -C_PI_2, +R_0_2, +R_0_1, -R_1_2, +R_1_1, +R_1_0, -R_2_0, +R_0_0}, // EXT_XZY + {+R_2_1, C_PI_2, +R_1_0, +R_0_0, -C_PI_2, +R_1_0, +R_0_0, -R_2_0, +R_2_2, +R_2_1, -R_0_1, +R_1_1}, // EXT_YXZ + {+R_0_2, -C_PI_2, -R_1_2, +R_2_2, C_PI_2, +R_2_0, +R_2_2, +R_0_2, +R_0_0, -R_0_1, +R_2_1, +R_1_1}, // EXT_YZX + {+R_1_2, -C_PI_2, -R_0_1, +R_0_0, C_PI_2, +R_0_1, +R_0_0, +R_1_0, +R_1_1, -R_1_2, +R_0_2, +R_2_2}, // EXT_ZXY + {+R_0_2, C_PI_2, +R_1_0, +R_1_1, -C_PI_2, +R_2_1, +R_1_1, -R_0_1, +R_0_0, +R_0_2, -R_1_2, +R_2_2}, // EXT_ZYX + {+R_0_0, C_ZERO, +R_2_1, +R_2_2, C_PI, +R_1_2, +R_1_1, +R_0_1, +R_0_2, +R_0_0, +R_1_0, -R_2_0}, // EXT_XYX + {+R_0_0, C_ZERO, +R_2_1, +R_2_2, C_PI, +R_2_1, +R_2_2, +R_0_2, -R_0_1, +R_0_0, +R_2_0, +R_1_0}, // EXT_XZX + {+R_1_1, C_ZERO, +R_0_2, +R_0_0, C_PI, -R_2_0, +R_0_0, +R_1_0, -R_1_2, +R_1_1, +R_0_1, +R_2_1}, // EXT_YXY + {+R_1_1, C_ZERO, +R_0_2, +R_0_0, C_PI, +R_0_2, -R_0_0, +R_1_2, +R_1_0, +R_1_1, +R_2_1, -R_0_1}, // EXT_YZY + {+R_2_2, C_ZERO, +R_1_0, +R_1_1, C_PI, +R_1_0, +R_0_0, +R_2_0, +R_2_1, +R_2_2, +R_0_2, -R_1_2}, // EXT_ZXZ + {+R_2_2, C_ZERO, +R_1_0, +R_0_0, C_PI, +R_1_0, +R_0_0, +R_2_1, -R_2_0, +R_2_2, +R_1_2, +R_0_2}, // EXT_ZYZ + }; + T rotationR[12]; + for (int i = 0; i < 12; i++) + { + int id = rotationR_[eulerAnglesType][i]; + unsigned idx = std::abs(id); + T value = 0.0f; + if (idx < N_CONSTANTS) + { + value = constants_[idx]; + } + else + { + unsigned r_idx = idx - N_CONSTANTS; + CV_DbgAssert(r_idx < 9); + value = R.val[r_idx]; + } + bool isNegative = id < 0; + if (isNegative) + value = -value; + rotationR[i] = value; + } + Vec angles; + if (detail::isIntAngleType(eulerAnglesType)) + { + if (abs(rotationR[0] - 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the third angle to 0"); + angles = {std::atan2(rotationR[1], rotationR[2]), rotationR[3], 0}; + return angles; + } + else if(abs(rotationR[0] + 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the third angle to 0"); + angles = {std::atan2(rotationR[4], rotationR[5]), rotationR[6], 0}; + return angles; + } + } + else // (!detail::isIntAngleType(eulerAnglesType)) + { + if (abs(rotationR[0] - 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the first angle to 0"); + angles = {0, rotationR[1], std::atan2(rotationR[2], rotationR[3])}; + return angles; + } + else if (abs(rotationR[0] + 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the first angle to 0"); + angles = {0, rotationR[4], std::atan2(rotationR[5], rotationR[6])}; + return angles; + } + } + + angles(0) = std::atan2(rotationR[7], rotationR[8]); + if (detail::isTaitBryan(eulerAnglesType)) + angles(1) = std::acos(rotationR[9]); + else + angles(1) = std::asin(rotationR[9]); + angles(2) = std::atan2(rotationR[10], rotationR[11]); + return angles; +} + +} // namepsace +//! @endcond + +#endif /*OPENCV_CORE_QUATERNION_INL_HPP*/ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/saturate.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/saturate.hpp new file mode 100644 index 0000000..8127e3d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/saturate.hpp @@ -0,0 +1,179 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2014, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_SATURATE_HPP +#define OPENCV_CORE_SATURATE_HPP + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/fast_math.hpp" + +namespace cv +{ + +//! @addtogroup core_utils +//! @{ + +/////////////// saturate_cast (used in image & signal processing) /////////////////// + +/** @brief Template function for accurate conversion from one primitive type to another. + + The function saturate_cast resembles the standard C++ cast operations, such as static_cast\() + and others. It perform an efficient and accurate conversion from one primitive type to another + (see the introduction chapter). saturate in the name means that when the input value v is out of the + range of the target type, the result is not formed just by taking low bits of the input, but instead + the value is clipped. For example: + @code + uchar a = saturate_cast(-100); // a = 0 (UCHAR_MIN) + short b = saturate_cast(33333.33333); // b = 32767 (SHRT_MAX) + @endcode + Such clipping is done when the target type is unsigned char , signed char , unsigned short or + signed short . For 32-bit integers, no clipping is done. + + When the parameter is a floating-point value and the target type is an integer (8-, 16- or 32-bit), + the floating-point value is first rounded to the nearest integer and then clipped if needed (when + the target type is 8- or 16-bit). + + @param v Function parameter. + @sa add, subtract, multiply, divide, Mat::convertTo + */ +template static inline _Tp saturate_cast(uchar v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(schar v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(ushort v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(short v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(unsigned v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(int v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(float v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(double v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(int64 v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(uint64 v) { return _Tp(v); } + +template<> inline uchar saturate_cast(schar v) { return (uchar)std::max((int)v, 0); } +template<> inline uchar saturate_cast(ushort v) { return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); } +template<> inline uchar saturate_cast(int v) { return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); } +template<> inline uchar saturate_cast(short v) { return saturate_cast((int)v); } +template<> inline uchar saturate_cast(unsigned v) { return (uchar)std::min(v, (unsigned)UCHAR_MAX); } +template<> inline uchar saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline uchar saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline uchar saturate_cast(int64 v) { return (uchar)((uint64)v <= (uint64)UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); } +template<> inline uchar saturate_cast(uint64 v) { return (uchar)std::min(v, (uint64)UCHAR_MAX); } + +template<> inline schar saturate_cast(uchar v) { return (schar)std::min((int)v, SCHAR_MAX); } +template<> inline schar saturate_cast(ushort v) { return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); } +template<> inline schar saturate_cast(int v) { return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); } +template<> inline schar saturate_cast(short v) { return saturate_cast((int)v); } +template<> inline schar saturate_cast(unsigned v) { return (schar)std::min(v, (unsigned)SCHAR_MAX); } +template<> inline schar saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline schar saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline schar saturate_cast(int64 v) { return (schar)((uint64)((int64)v-SCHAR_MIN) <= (uint64)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); } +template<> inline schar saturate_cast(uint64 v) { return (schar)std::min(v, (uint64)SCHAR_MAX); } + +template<> inline ushort saturate_cast(schar v) { return (ushort)std::max((int)v, 0); } +template<> inline ushort saturate_cast(short v) { return (ushort)std::max((int)v, 0); } +template<> inline ushort saturate_cast(int v) { return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); } +template<> inline ushort saturate_cast(unsigned v) { return (ushort)std::min(v, (unsigned)USHRT_MAX); } +template<> inline ushort saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline ushort saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline ushort saturate_cast(int64 v) { return (ushort)((uint64)v <= (uint64)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); } +template<> inline ushort saturate_cast(uint64 v) { return (ushort)std::min(v, (uint64)USHRT_MAX); } + +template<> inline short saturate_cast(ushort v) { return (short)std::min((int)v, SHRT_MAX); } +template<> inline short saturate_cast(int v) { return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); } +template<> inline short saturate_cast(unsigned v) { return (short)std::min(v, (unsigned)SHRT_MAX); } +template<> inline short saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline short saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline short saturate_cast(int64 v) { return (short)((uint64)((int64)v - SHRT_MIN) <= (uint64)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); } +template<> inline short saturate_cast(uint64 v) { return (short)std::min(v, (uint64)SHRT_MAX); } + +template<> inline int saturate_cast(unsigned v) { return (int)std::min(v, (unsigned)INT_MAX); } +template<> inline int saturate_cast(int64 v) { return (int)((uint64)(v - INT_MIN) <= (uint64)UINT_MAX ? v : v > 0 ? INT_MAX : INT_MIN); } +template<> inline int saturate_cast(uint64 v) { return (int)std::min(v, (uint64)INT_MAX); } +template<> inline int saturate_cast(float v) { return cvRound(v); } +template<> inline int saturate_cast(double v) { return cvRound(v); } + +template<> inline unsigned saturate_cast(schar v) { return (unsigned)std::max(v, (schar)0); } +template<> inline unsigned saturate_cast(short v) { return (unsigned)std::max(v, (short)0); } +template<> inline unsigned saturate_cast(int v) { return (unsigned)std::max(v, (int)0); } +template<> inline unsigned saturate_cast(int64 v) { return (unsigned)((uint64)v <= (uint64)UINT_MAX ? v : v > 0 ? UINT_MAX : 0); } +template<> inline unsigned saturate_cast(uint64 v) { return (unsigned)std::min(v, (uint64)UINT_MAX); } +// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc. +template<> inline unsigned saturate_cast(float v) { return static_cast(cvRound(v)); } +template<> inline unsigned saturate_cast(double v) { return static_cast(cvRound(v)); } + +template<> inline uint64 saturate_cast(schar v) { return (uint64)std::max(v, (schar)0); } +template<> inline uint64 saturate_cast(short v) { return (uint64)std::max(v, (short)0); } +template<> inline uint64 saturate_cast(int v) { return (uint64)std::max(v, (int)0); } +template<> inline uint64 saturate_cast(int64 v) { return (uint64)std::max(v, (int64)0); } + +template<> inline int64 saturate_cast(uint64 v) { return (int64)std::min(v, (uint64)LLONG_MAX); } + +/** @overload */ +template static inline _Tp saturate_cast(float16_t v) { return saturate_cast<_Tp>((float)v); } + +// in theory, we could use a LUT for 8u/8s->16f conversion, +// but with hardware support for FP32->FP16 conversion the current approach is preferable +template<> inline float16_t saturate_cast(uchar v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(schar v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(ushort v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(short v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(unsigned v){ return float16_t((float)v); } +template<> inline float16_t saturate_cast(int v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(uint64 v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(int64 v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(float v) { return float16_t(v); } +template<> inline float16_t saturate_cast(double v) { return float16_t((float)v); } + +//! @} + +} // cv + +#endif // OPENCV_CORE_SATURATE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/simd_intrinsics.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/simd_intrinsics.hpp new file mode 100644 index 0000000..2658d92 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/simd_intrinsics.hpp @@ -0,0 +1,87 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_SIMD_INTRINSICS_HPP +#define OPENCV_CORE_SIMD_INTRINSICS_HPP + +/** +Helper header to support SIMD intrinsics (universal intrinsics) in user code. +Intrinsics documentation: https://docs.opencv.org/4.x/df/d91/group__core__hal__intrin.html + + +Checks of target CPU instruction set based on compiler definitions don't work well enough. +More reliable solutions require utilization of configuration systems (like CMake). + +So, probably you need to specify your own configuration. + +You can do that via CMake in this way: + add_definitions(/DOPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp) +or + add_definitions(/DOPENCV_SIMD_CONFIG_INCLUDE_DIR=1) + +Additionally you may need to add include directory to your files: + include_directories("${CMAKE_CURRENT_LIST_DIR}/opencv_config_${MYTARGET}") + +These files can be pre-generated for target configurations of your application +or generated by CMake on the fly (use CMAKE_BINARY_DIR for that). + +Notes: +- H/W capability checks are still responsibility of your application +- runtime dispatching is not covered by this helper header +*/ + +#ifdef __OPENCV_BUILD +#error "Use core/hal/intrin.hpp during OpenCV build" +#endif + +#ifdef OPENCV_HAL_INTRIN_HPP +#error "core/simd_intrinsics.hpp must be included before core/hal/intrin.hpp" +#endif + +#include "opencv2/core/cvdef.h" + +#ifdef OPENCV_SIMD_CONFIG_HEADER +#include CVAUX_STR(OPENCV_SIMD_CONFIG_HEADER) +#elif defined(OPENCV_SIMD_CONFIG_INCLUDE_DIR) +#include "opencv_simd_config.hpp" // corresponding directory should be added via -I compiler parameter +#else // custom config headers + +#if (!defined(CV_AVX_512F) || !CV_AVX_512F) && (defined(__AVX512__) || defined(__AVX512F__)) +# include +# undef CV_AVX_512F +# define CV_AVX_512F 1 +# ifndef OPENCV_SIMD_DONT_ASSUME_SKX // Skylake-X with AVX-512F/CD/BW/DQ/VL +# undef CV_AVX512_SKX +# define CV_AVX512_SKX 1 +# undef CV_AVX_512CD +# define CV_AVX_512CD 1 +# undef CV_AVX_512BW +# define CV_AVX_512BW 1 +# undef CV_AVX_512DQ +# define CV_AVX_512DQ 1 +# undef CV_AVX_512VL +# define CV_AVX_512VL 1 +# endif +#endif // AVX512 + +// GCC/Clang: -mavx2 +// MSVC: /arch:AVX2 +#if defined __AVX2__ +# include +# undef CV_AVX2 +# define CV_AVX2 1 +# if defined __F16C__ +# undef CV_FP16 +# define CV_FP16 1 +# endif +#endif + +#endif + +// SSE / NEON / VSX is handled by cv_cpu_dispatch.h compatibility block +#include "cv_cpu_dispatch.h" + +#include "hal/intrin.hpp" + +#endif // OPENCV_CORE_SIMD_INTRINSICS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/softfloat.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/softfloat.hpp new file mode 100644 index 0000000..485e15c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/softfloat.hpp @@ -0,0 +1,514 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +// This file is based on files from package issued with the following license: + +/*============================================================================ + +This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic +Package, Release 3c, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the +University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS 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. + +=============================================================================*/ + +#pragma once +#ifndef softfloat_h +#define softfloat_h 1 + +#include "cvdef.h" + +namespace cv +{ + +/** @addtogroup core_utils_softfloat + + [SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is a software implementation + of floating-point calculations according to IEEE 754 standard. + All calculations are done in integers, that's why they are machine-independent and bit-exact. + This library can be useful in accuracy-critical parts like look-up tables generation, tests, etc. + OpenCV contains a subset of SoftFloat partially rewritten to C++. + + ### Types + + There are two basic types: @ref softfloat and @ref softdouble. + These types are binary compatible with float and double types respectively + and support conversions to/from them. + Other types from original SoftFloat library like fp16 or fp128 were thrown away + as well as quiet/signaling NaN support, on-the-fly rounding mode switch + and exception flags (though exceptions can be implemented in the future). + + ### Operations + + Both types support the following: + - Construction from signed and unsigned 32-bit and 64 integers, + float/double or raw binary representation + - Conversions between each other, to float or double and to int + using @ref cvRound, @ref cvTrunc, @ref cvFloor, @ref cvCeil or a bunch of + saturate_cast functions + - Add, subtract, multiply, divide, remainder, square root, FMA with absolute precision + - Comparison operations + - Explicit sign, exponent and significand manipulation through get/set methods, + number state indicators (isInf, isNan, isSubnormal) + - Type-specific constants like eps, minimum/maximum value, best pi approximation, etc. + - min(), max(), abs(), exp(), log() and pow() functions + +*/ +//! @{ + +struct softfloat; +struct softdouble; + +struct CV_EXPORTS softfloat +{ +public: + /** @brief Default constructor */ + softfloat() { v = 0; } + /** @brief Copy constructor */ + softfloat( const softfloat& c) { v = c.v; } + /** @brief Assign constructor */ + softfloat& operator=( const softfloat& c ) + { + if(&c != this) v = c.v; + return *this; + } + /** @brief Construct from raw + + Builds new value from raw binary representation + */ + static const softfloat fromRaw( const uint32_t a ) { softfloat x; x.v = a; return x; } + + /** @brief Construct from integer */ + explicit softfloat( const uint32_t ); + explicit softfloat( const uint64_t ); + explicit softfloat( const int32_t ); + explicit softfloat( const int64_t ); + +#ifdef CV_INT32_T_IS_LONG_INT + // for platforms with int32_t = long int + explicit softfloat( const int a ) { *this = softfloat(static_cast(a)); } +#endif + + /** @brief Construct from float */ + explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; } + + /** @brief Type casts */ + operator softdouble() const; + operator float() const { Cv32suf s; s.u = v; return s.f; } + + /** @brief Basic arithmetics */ + softfloat operator + (const softfloat&) const; + softfloat operator - (const softfloat&) const; + softfloat operator * (const softfloat&) const; + softfloat operator / (const softfloat&) const; + softfloat operator - () const { softfloat x; x.v = v ^ (1U << 31); return x; } + + /** @brief Remainder operator + + A quote from original SoftFloat manual: + + > The IEEE Standard remainder operation computes the value + > a - n * b, where n is the integer closest to a / b. + > If a / b is exactly halfway between two integers, n is the even integer + > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding. + > Depending on the relative magnitudes of the operands, the remainder functions + > can take considerably longer to execute than the other SoftFloat functions. + > This is an inherent characteristic of the remainder operation itself and is not a flaw + > in the SoftFloat implementation. + */ + softfloat operator % (const softfloat&) const; + + softfloat& operator += (const softfloat& a) { *this = *this + a; return *this; } + softfloat& operator -= (const softfloat& a) { *this = *this - a; return *this; } + softfloat& operator *= (const softfloat& a) { *this = *this * a; return *this; } + softfloat& operator /= (const softfloat& a) { *this = *this / a; return *this; } + softfloat& operator %= (const softfloat& a) { *this = *this % a; return *this; } + + /** @brief Comparison operations + + - Any operation with NaN produces false + + The only exception is when x is NaN: x != y for any y. + - Positive and negative zeros are equal + */ + bool operator == ( const softfloat& ) const; + bool operator != ( const softfloat& ) const; + bool operator > ( const softfloat& ) const; + bool operator >= ( const softfloat& ) const; + bool operator < ( const softfloat& ) const; + bool operator <= ( const softfloat& ) const; + + /** @brief NaN state indicator */ + inline bool isNaN() const { return (v & 0x7fffffff) > 0x7f800000; } + /** @brief Inf state indicator */ + inline bool isInf() const { return (v & 0x7fffffff) == 0x7f800000; } + /** @brief Subnormal number indicator */ + inline bool isSubnormal() const { return ((v >> 23) & 0xFF) == 0; } + + /** @brief Get sign bit */ + inline bool getSign() const { return (v >> 31) != 0; } + /** @brief Construct a copy with new sign bit */ + inline softfloat setSign(bool sign) const { softfloat x; x.v = (v & ((1U << 31) - 1)) | ((uint32_t)sign << 31); return x; } + /** @brief Get 0-based exponent */ + inline int getExp() const { return ((v >> 23) & 0xFF) - 127; } + /** @brief Construct a copy with new 0-based exponent */ + inline softfloat setExp(int e) const { softfloat x; x.v = (v & 0x807fffff) | (((e + 127) & 0xFF) << 23 ); return x; } + + /** @brief Get a fraction part + + Returns a number 1 <= x < 2 with the same significand + */ + inline softfloat getFrac() const + { + uint_fast32_t vv = (v & 0x007fffff) | (127 << 23); + return softfloat::fromRaw(vv); + } + /** @brief Construct a copy with provided significand + + Constructs a copy of a number with significand taken from parameter + */ + inline softfloat setFrac(const softfloat& s) const + { + softfloat x; + x.v = (v & 0xff800000) | (s.v & 0x007fffff); + return x; + } + + /** @brief Zero constant */ + static softfloat zero() { return softfloat::fromRaw( 0 ); } + /** @brief Positive infinity constant */ + static softfloat inf() { return softfloat::fromRaw( 0xFF << 23 ); } + /** @brief Default NaN constant */ + static softfloat nan() { return softfloat::fromRaw( 0x7fffffff ); } + /** @brief One constant */ + static softfloat one() { return softfloat::fromRaw( 127 << 23 ); } + /** @brief Smallest normalized value */ + static softfloat min() { return softfloat::fromRaw( 0x01 << 23 ); } + /** @brief Difference between 1 and next representable value */ + static softfloat eps() { return softfloat::fromRaw( (127 - 23) << 23 ); } + /** @brief Biggest finite value */ + static softfloat max() { return softfloat::fromRaw( (0xFF << 23) - 1 ); } + /** @brief Correct pi approximation */ + static softfloat pi() { return softfloat::fromRaw( 0x40490fdb ); } + + uint32_t v; +}; + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +struct CV_EXPORTS softdouble +{ +public: + /** @brief Default constructor */ + softdouble() : v(0) { } + /** @brief Copy constructor */ + softdouble( const softdouble& c) { v = c.v; } + /** @brief Assign constructor */ + softdouble& operator=( const softdouble& c ) + { + if(&c != this) v = c.v; + return *this; + } + /** @brief Construct from raw + + Builds new value from raw binary representation + */ + static softdouble fromRaw( const uint64_t a ) { softdouble x; x.v = a; return x; } + + /** @brief Construct from integer */ + explicit softdouble( const uint32_t ); + explicit softdouble( const uint64_t ); + explicit softdouble( const int32_t ); + explicit softdouble( const int64_t ); + +#ifdef CV_INT32_T_IS_LONG_INT + // for platforms with int32_t = long int + explicit softdouble( const int a ) { *this = softdouble(static_cast(a)); } +#endif + + /** @brief Construct from double */ + explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; } + + /** @brief Type casts */ + operator softfloat() const; + operator double() const { Cv64suf s; s.u = v; return s.f; } + + /** @brief Basic arithmetics */ + softdouble operator + (const softdouble&) const; + softdouble operator - (const softdouble&) const; + softdouble operator * (const softdouble&) const; + softdouble operator / (const softdouble&) const; + softdouble operator - () const { softdouble x; x.v = v ^ (1ULL << 63); return x; } + + /** @brief Remainder operator + + A quote from original SoftFloat manual: + + > The IEEE Standard remainder operation computes the value + > a - n * b, where n is the integer closest to a / b. + > If a / b is exactly halfway between two integers, n is the even integer + > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding. + > Depending on the relative magnitudes of the operands, the remainder functions + > can take considerably longer to execute than the other SoftFloat functions. + > This is an inherent characteristic of the remainder operation itself and is not a flaw + > in the SoftFloat implementation. + */ + softdouble operator % (const softdouble&) const; + + softdouble& operator += (const softdouble& a) { *this = *this + a; return *this; } + softdouble& operator -= (const softdouble& a) { *this = *this - a; return *this; } + softdouble& operator *= (const softdouble& a) { *this = *this * a; return *this; } + softdouble& operator /= (const softdouble& a) { *this = *this / a; return *this; } + softdouble& operator %= (const softdouble& a) { *this = *this % a; return *this; } + + /** @brief Comparison operations + + - Any operation with NaN produces false + + The only exception is when x is NaN: x != y for any y. + - Positive and negative zeros are equal + */ + bool operator == ( const softdouble& ) const; + bool operator != ( const softdouble& ) const; + bool operator > ( const softdouble& ) const; + bool operator >= ( const softdouble& ) const; + bool operator < ( const softdouble& ) const; + bool operator <= ( const softdouble& ) const; + + /** @brief NaN state indicator */ + inline bool isNaN() const { return (v & 0x7fffffffffffffff) > 0x7ff0000000000000; } + /** @brief Inf state indicator */ + inline bool isInf() const { return (v & 0x7fffffffffffffff) == 0x7ff0000000000000; } + /** @brief Subnormal number indicator */ + inline bool isSubnormal() const { return ((v >> 52) & 0x7FF) == 0; } + + /** @brief Get sign bit */ + inline bool getSign() const { return (v >> 63) != 0; } + /** @brief Construct a copy with new sign bit */ + softdouble setSign(bool sign) const { softdouble x; x.v = (v & ((1ULL << 63) - 1)) | ((uint_fast64_t)(sign) << 63); return x; } + /** @brief Get 0-based exponent */ + inline int getExp() const { return ((v >> 52) & 0x7FF) - 1023; } + /** @brief Construct a copy with new 0-based exponent */ + inline softdouble setExp(int e) const + { + softdouble x; + x.v = (v & 0x800FFFFFFFFFFFFF) | ((uint_fast64_t)((e + 1023) & 0x7FF) << 52); + return x; + } + + /** @brief Get a fraction part + + Returns a number 1 <= x < 2 with the same significand + */ + inline softdouble getFrac() const + { + uint_fast64_t vv = (v & 0x000FFFFFFFFFFFFF) | ((uint_fast64_t)(1023) << 52); + return softdouble::fromRaw(vv); + } + /** @brief Construct a copy with provided significand + + Constructs a copy of a number with significand taken from parameter + */ + inline softdouble setFrac(const softdouble& s) const + { + softdouble x; + x.v = (v & 0xFFF0000000000000) | (s.v & 0x000FFFFFFFFFFFFF); + return x; + } + + /** @brief Zero constant */ + static softdouble zero() { return softdouble::fromRaw( 0 ); } + /** @brief Positive infinity constant */ + static softdouble inf() { return softdouble::fromRaw( (uint_fast64_t)(0x7FF) << 52 ); } + /** @brief Default NaN constant */ + static softdouble nan() { return softdouble::fromRaw( CV_BIG_INT(0x7FFFFFFFFFFFFFFF) ); } + /** @brief One constant */ + static softdouble one() { return softdouble::fromRaw( (uint_fast64_t)( 1023) << 52 ); } + /** @brief Smallest normalized value */ + static softdouble min() { return softdouble::fromRaw( (uint_fast64_t)( 0x01) << 52 ); } + /** @brief Difference between 1 and next representable value */ + static softdouble eps() { return softdouble::fromRaw( (uint_fast64_t)( 1023 - 52 ) << 52 ); } + /** @brief Biggest finite value */ + static softdouble max() { return softdouble::fromRaw( ((uint_fast64_t)(0x7FF) << 52) - 1 ); } + /** @brief Correct pi approximation */ + static softdouble pi() { return softdouble::fromRaw( CV_BIG_INT(0x400921FB54442D18) ); } + + uint64_t v; +}; + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +/** @brief Fused Multiplication and Addition + +Computes (a*b)+c with single rounding +*/ +CV_EXPORTS softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c); +CV_EXPORTS softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c); + +/** @brief Square root */ +CV_EXPORTS softfloat sqrt( const softfloat& a ); +CV_EXPORTS softdouble sqrt( const softdouble& a ); +} + +/*---------------------------------------------------------------------------- +| Ported from OpenCV and added for usability +*----------------------------------------------------------------------------*/ + +/** @brief Truncates number to integer with minimum magnitude */ +CV_EXPORTS int cvTrunc(const cv::softfloat& a); +CV_EXPORTS int cvTrunc(const cv::softdouble& a); + +/** @brief Rounds a number to nearest even integer */ +CV_EXPORTS int cvRound(const cv::softfloat& a); +CV_EXPORTS int cvRound(const cv::softdouble& a); + +/** @brief Rounds a number to nearest even long long integer */ +CV_EXPORTS int64_t cvRound64(const cv::softdouble& a); + +/** @brief Rounds a number down to integer */ +CV_EXPORTS int cvFloor(const cv::softfloat& a); +CV_EXPORTS int cvFloor(const cv::softdouble& a); + +/** @brief Rounds number up to integer */ +CV_EXPORTS int cvCeil(const cv::softfloat& a); +CV_EXPORTS int cvCeil(const cv::softdouble& a); + +namespace cv +{ +/** @brief Saturate casts */ +template static inline _Tp saturate_cast(softfloat a) { return _Tp(a); } +template static inline _Tp saturate_cast(softdouble a) { return _Tp(a); } + +template<> inline uchar saturate_cast(softfloat a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); } +template<> inline uchar saturate_cast(softdouble a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); } + +template<> inline schar saturate_cast(softfloat a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); } +template<> inline schar saturate_cast(softdouble a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); } + +template<> inline ushort saturate_cast(softfloat a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); } +template<> inline ushort saturate_cast(softdouble a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); } + +template<> inline short saturate_cast(softfloat a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); } +template<> inline short saturate_cast(softdouble a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); } + +template<> inline int saturate_cast(softfloat a) { return cvRound(a); } +template<> inline int saturate_cast(softdouble a) { return cvRound(a); } + +template<> inline int64_t saturate_cast(softfloat a) { return cvRound(a); } +template<> inline int64_t saturate_cast(softdouble a) { return cvRound64(a); } + +/** @brief Saturate cast to unsigned integer and unsigned long long integer +We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc. +*/ +template<> inline unsigned saturate_cast(softfloat a) { return cvRound(a); } +template<> inline unsigned saturate_cast(softdouble a) { return cvRound(a); } + +template<> inline uint64_t saturate_cast(softfloat a) { return cvRound(a); } +template<> inline uint64_t saturate_cast(softdouble a) { return cvRound64(a); } + +/** @brief Min and Max functions */ +inline softfloat min(const softfloat& a, const softfloat& b) { return (a > b) ? b : a; } +inline softdouble min(const softdouble& a, const softdouble& b) { return (a > b) ? b : a; } + +inline softfloat max(const softfloat& a, const softfloat& b) { return (a > b) ? a : b; } +inline softdouble max(const softdouble& a, const softdouble& b) { return (a > b) ? a : b; } + +/** @brief Absolute value */ +inline softfloat abs( softfloat a) { softfloat x; x.v = a.v & ((1U << 31) - 1); return x; } +inline softdouble abs( softdouble a) { softdouble x; x.v = a.v & ((1ULL << 63) - 1); return x; } + +/** @brief Exponent + +Special cases: +- exp(NaN) is NaN +- exp(-Inf) == 0 +- exp(+Inf) == +Inf +*/ +CV_EXPORTS softfloat exp( const softfloat& a); +CV_EXPORTS softdouble exp( const softdouble& a); + +/** @brief Natural logarithm + +Special cases: +- log(NaN), log(x < 0) are NaN +- log(0) == -Inf +*/ +CV_EXPORTS softfloat log( const softfloat& a ); +CV_EXPORTS softdouble log( const softdouble& a ); + +/** @brief Raising to the power + +Special cases: +- x**NaN is NaN for any x +- ( |x| == 1 )**Inf is NaN +- ( |x| > 1 )**+Inf or ( |x| < 1 )**-Inf is +Inf +- ( |x| > 1 )**-Inf or ( |x| < 1 )**+Inf is 0 +- x ** 0 == 1 for any x +- x ** 1 == 1 for any x +- NaN ** y is NaN for any other y +- Inf**(y < 0) == 0 +- Inf ** y is +Inf for any other y +- (x < 0)**y is NaN for any other y if x can't be correctly rounded to integer +- 0 ** 0 == 1 +- 0 ** (y < 0) is +Inf +- 0 ** (y > 0) is 0 +*/ +CV_EXPORTS softfloat pow( const softfloat& a, const softfloat& b); +CV_EXPORTS softdouble pow( const softdouble& a, const softdouble& b); + +/** @brief Cube root + +Special cases: +- cbrt(NaN) is NaN +- cbrt(+/-Inf) is +/-Inf +*/ +CV_EXPORTS softfloat cbrt( const softfloat& a ); + +/** @brief Sine + +Special cases: +- sin(Inf) or sin(NaN) is NaN +- sin(x) == x when sin(x) is close to zero +*/ +CV_EXPORTS softdouble sin( const softdouble& a ); + +/** @brief Cosine + * +Special cases: +- cos(Inf) or cos(NaN) is NaN +- cos(x) == +/- 1 when cos(x) is close to +/- 1 +*/ +CV_EXPORTS softdouble cos( const softdouble& a ); + +//! @} core_utils_softfloat + +} // cv:: + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/sse_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/sse_utils.hpp new file mode 100644 index 0000000..0906583 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/sse_utils.hpp @@ -0,0 +1,652 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_SSE_UTILS_HPP +#define OPENCV_CORE_SSE_UTILS_HPP + +#ifndef __cplusplus +# error sse_utils.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" + +//! @addtogroup core_utils_sse +//! @{ + +#if CV_SSE2 + +inline void _mm_deinterleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi8(v_r0, v_g0); + __m128i layer1_chunk1 = _mm_unpackhi_epi8(v_r0, v_g0); + __m128i layer1_chunk2 = _mm_unpacklo_epi8(v_r1, v_g1); + __m128i layer1_chunk3 = _mm_unpackhi_epi8(v_r1, v_g1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi8(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk1 = _mm_unpackhi_epi8(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk2 = _mm_unpacklo_epi8(layer1_chunk1, layer1_chunk3); + __m128i layer2_chunk3 = _mm_unpackhi_epi8(layer1_chunk1, layer1_chunk3); + + __m128i layer3_chunk0 = _mm_unpacklo_epi8(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk1 = _mm_unpackhi_epi8(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk2 = _mm_unpacklo_epi8(layer2_chunk1, layer2_chunk3); + __m128i layer3_chunk3 = _mm_unpackhi_epi8(layer2_chunk1, layer2_chunk3); + + __m128i layer4_chunk0 = _mm_unpacklo_epi8(layer3_chunk0, layer3_chunk2); + __m128i layer4_chunk1 = _mm_unpackhi_epi8(layer3_chunk0, layer3_chunk2); + __m128i layer4_chunk2 = _mm_unpacklo_epi8(layer3_chunk1, layer3_chunk3); + __m128i layer4_chunk3 = _mm_unpackhi_epi8(layer3_chunk1, layer3_chunk3); + + v_r0 = _mm_unpacklo_epi8(layer4_chunk0, layer4_chunk2); + v_r1 = _mm_unpackhi_epi8(layer4_chunk0, layer4_chunk2); + v_g0 = _mm_unpacklo_epi8(layer4_chunk1, layer4_chunk3); + v_g1 = _mm_unpackhi_epi8(layer4_chunk1, layer4_chunk3); +} + +inline void _mm_deinterleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi8(v_r0, v_g1); + __m128i layer1_chunk1 = _mm_unpackhi_epi8(v_r0, v_g1); + __m128i layer1_chunk2 = _mm_unpacklo_epi8(v_r1, v_b0); + __m128i layer1_chunk3 = _mm_unpackhi_epi8(v_r1, v_b0); + __m128i layer1_chunk4 = _mm_unpacklo_epi8(v_g0, v_b1); + __m128i layer1_chunk5 = _mm_unpackhi_epi8(v_g0, v_b1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi8(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk1 = _mm_unpackhi_epi8(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk2 = _mm_unpacklo_epi8(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk3 = _mm_unpackhi_epi8(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk4 = _mm_unpacklo_epi8(layer1_chunk2, layer1_chunk5); + __m128i layer2_chunk5 = _mm_unpackhi_epi8(layer1_chunk2, layer1_chunk5); + + __m128i layer3_chunk0 = _mm_unpacklo_epi8(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk1 = _mm_unpackhi_epi8(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk2 = _mm_unpacklo_epi8(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk3 = _mm_unpackhi_epi8(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk4 = _mm_unpacklo_epi8(layer2_chunk2, layer2_chunk5); + __m128i layer3_chunk5 = _mm_unpackhi_epi8(layer2_chunk2, layer2_chunk5); + + __m128i layer4_chunk0 = _mm_unpacklo_epi8(layer3_chunk0, layer3_chunk3); + __m128i layer4_chunk1 = _mm_unpackhi_epi8(layer3_chunk0, layer3_chunk3); + __m128i layer4_chunk2 = _mm_unpacklo_epi8(layer3_chunk1, layer3_chunk4); + __m128i layer4_chunk3 = _mm_unpackhi_epi8(layer3_chunk1, layer3_chunk4); + __m128i layer4_chunk4 = _mm_unpacklo_epi8(layer3_chunk2, layer3_chunk5); + __m128i layer4_chunk5 = _mm_unpackhi_epi8(layer3_chunk2, layer3_chunk5); + + v_r0 = _mm_unpacklo_epi8(layer4_chunk0, layer4_chunk3); + v_r1 = _mm_unpackhi_epi8(layer4_chunk0, layer4_chunk3); + v_g0 = _mm_unpacklo_epi8(layer4_chunk1, layer4_chunk4); + v_g1 = _mm_unpackhi_epi8(layer4_chunk1, layer4_chunk4); + v_b0 = _mm_unpacklo_epi8(layer4_chunk2, layer4_chunk5); + v_b1 = _mm_unpackhi_epi8(layer4_chunk2, layer4_chunk5); +} + +inline void _mm_deinterleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi8(v_r0, v_b0); + __m128i layer1_chunk1 = _mm_unpackhi_epi8(v_r0, v_b0); + __m128i layer1_chunk2 = _mm_unpacklo_epi8(v_r1, v_b1); + __m128i layer1_chunk3 = _mm_unpackhi_epi8(v_r1, v_b1); + __m128i layer1_chunk4 = _mm_unpacklo_epi8(v_g0, v_a0); + __m128i layer1_chunk5 = _mm_unpackhi_epi8(v_g0, v_a0); + __m128i layer1_chunk6 = _mm_unpacklo_epi8(v_g1, v_a1); + __m128i layer1_chunk7 = _mm_unpackhi_epi8(v_g1, v_a1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi8(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk1 = _mm_unpackhi_epi8(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk2 = _mm_unpacklo_epi8(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk3 = _mm_unpackhi_epi8(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk4 = _mm_unpacklo_epi8(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk5 = _mm_unpackhi_epi8(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk6 = _mm_unpacklo_epi8(layer1_chunk3, layer1_chunk7); + __m128i layer2_chunk7 = _mm_unpackhi_epi8(layer1_chunk3, layer1_chunk7); + + __m128i layer3_chunk0 = _mm_unpacklo_epi8(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk1 = _mm_unpackhi_epi8(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk2 = _mm_unpacklo_epi8(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk3 = _mm_unpackhi_epi8(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk4 = _mm_unpacklo_epi8(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk5 = _mm_unpackhi_epi8(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk6 = _mm_unpacklo_epi8(layer2_chunk3, layer2_chunk7); + __m128i layer3_chunk7 = _mm_unpackhi_epi8(layer2_chunk3, layer2_chunk7); + + __m128i layer4_chunk0 = _mm_unpacklo_epi8(layer3_chunk0, layer3_chunk4); + __m128i layer4_chunk1 = _mm_unpackhi_epi8(layer3_chunk0, layer3_chunk4); + __m128i layer4_chunk2 = _mm_unpacklo_epi8(layer3_chunk1, layer3_chunk5); + __m128i layer4_chunk3 = _mm_unpackhi_epi8(layer3_chunk1, layer3_chunk5); + __m128i layer4_chunk4 = _mm_unpacklo_epi8(layer3_chunk2, layer3_chunk6); + __m128i layer4_chunk5 = _mm_unpackhi_epi8(layer3_chunk2, layer3_chunk6); + __m128i layer4_chunk6 = _mm_unpacklo_epi8(layer3_chunk3, layer3_chunk7); + __m128i layer4_chunk7 = _mm_unpackhi_epi8(layer3_chunk3, layer3_chunk7); + + v_r0 = _mm_unpacklo_epi8(layer4_chunk0, layer4_chunk4); + v_r1 = _mm_unpackhi_epi8(layer4_chunk0, layer4_chunk4); + v_g0 = _mm_unpacklo_epi8(layer4_chunk1, layer4_chunk5); + v_g1 = _mm_unpackhi_epi8(layer4_chunk1, layer4_chunk5); + v_b0 = _mm_unpacklo_epi8(layer4_chunk2, layer4_chunk6); + v_b1 = _mm_unpackhi_epi8(layer4_chunk2, layer4_chunk6); + v_a0 = _mm_unpacklo_epi8(layer4_chunk3, layer4_chunk7); + v_a1 = _mm_unpackhi_epi8(layer4_chunk3, layer4_chunk7); +} + +inline void _mm_interleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i v_mask = _mm_set1_epi16(0x00ff); + + __m128i layer4_chunk0 = _mm_packus_epi16(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer4_chunk2 = _mm_packus_epi16(_mm_srli_epi16(v_r0, 8), _mm_srli_epi16(v_r1, 8)); + __m128i layer4_chunk1 = _mm_packus_epi16(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer4_chunk3 = _mm_packus_epi16(_mm_srli_epi16(v_g0, 8), _mm_srli_epi16(v_g1, 8)); + + __m128i layer3_chunk0 = _mm_packus_epi16(_mm_and_si128(layer4_chunk0, v_mask), _mm_and_si128(layer4_chunk1, v_mask)); + __m128i layer3_chunk2 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk0, 8), _mm_srli_epi16(layer4_chunk1, 8)); + __m128i layer3_chunk1 = _mm_packus_epi16(_mm_and_si128(layer4_chunk2, v_mask), _mm_and_si128(layer4_chunk3, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk2, 8), _mm_srli_epi16(layer4_chunk3, 8)); + + __m128i layer2_chunk0 = _mm_packus_epi16(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk2 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk0, 8), _mm_srli_epi16(layer3_chunk1, 8)); + __m128i layer2_chunk1 = _mm_packus_epi16(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk2, 8), _mm_srli_epi16(layer3_chunk3, 8)); + + __m128i layer1_chunk0 = _mm_packus_epi16(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk2 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk0, 8), _mm_srli_epi16(layer2_chunk1, 8)); + __m128i layer1_chunk1 = _mm_packus_epi16(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk2, 8), _mm_srli_epi16(layer2_chunk3, 8)); + + v_r0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk0, 8), _mm_srli_epi16(layer1_chunk1, 8)); + v_r1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_g1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk2, 8), _mm_srli_epi16(layer1_chunk3, 8)); +} + +inline void _mm_interleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i v_mask = _mm_set1_epi16(0x00ff); + + __m128i layer4_chunk0 = _mm_packus_epi16(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer4_chunk3 = _mm_packus_epi16(_mm_srli_epi16(v_r0, 8), _mm_srli_epi16(v_r1, 8)); + __m128i layer4_chunk1 = _mm_packus_epi16(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer4_chunk4 = _mm_packus_epi16(_mm_srli_epi16(v_g0, 8), _mm_srli_epi16(v_g1, 8)); + __m128i layer4_chunk2 = _mm_packus_epi16(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer4_chunk5 = _mm_packus_epi16(_mm_srli_epi16(v_b0, 8), _mm_srli_epi16(v_b1, 8)); + + __m128i layer3_chunk0 = _mm_packus_epi16(_mm_and_si128(layer4_chunk0, v_mask), _mm_and_si128(layer4_chunk1, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk0, 8), _mm_srli_epi16(layer4_chunk1, 8)); + __m128i layer3_chunk1 = _mm_packus_epi16(_mm_and_si128(layer4_chunk2, v_mask), _mm_and_si128(layer4_chunk3, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk2, 8), _mm_srli_epi16(layer4_chunk3, 8)); + __m128i layer3_chunk2 = _mm_packus_epi16(_mm_and_si128(layer4_chunk4, v_mask), _mm_and_si128(layer4_chunk5, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk4, 8), _mm_srli_epi16(layer4_chunk5, 8)); + + __m128i layer2_chunk0 = _mm_packus_epi16(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk0, 8), _mm_srli_epi16(layer3_chunk1, 8)); + __m128i layer2_chunk1 = _mm_packus_epi16(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk2, 8), _mm_srli_epi16(layer3_chunk3, 8)); + __m128i layer2_chunk2 = _mm_packus_epi16(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk4, 8), _mm_srli_epi16(layer3_chunk5, 8)); + + __m128i layer1_chunk0 = _mm_packus_epi16(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk0, 8), _mm_srli_epi16(layer2_chunk1, 8)); + __m128i layer1_chunk1 = _mm_packus_epi16(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk2, 8), _mm_srli_epi16(layer2_chunk3, 8)); + __m128i layer1_chunk2 = _mm_packus_epi16(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk4, 8), _mm_srli_epi16(layer2_chunk5, 8)); + + v_r0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk0, 8), _mm_srli_epi16(layer1_chunk1, 8)); + v_r1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk2, 8), _mm_srli_epi16(layer1_chunk3, 8)); + v_g0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_b1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk4, 8), _mm_srli_epi16(layer1_chunk5, 8)); +} + +inline void _mm_interleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i v_mask = _mm_set1_epi16(0x00ff); + + __m128i layer4_chunk0 = _mm_packus_epi16(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer4_chunk4 = _mm_packus_epi16(_mm_srli_epi16(v_r0, 8), _mm_srli_epi16(v_r1, 8)); + __m128i layer4_chunk1 = _mm_packus_epi16(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer4_chunk5 = _mm_packus_epi16(_mm_srli_epi16(v_g0, 8), _mm_srli_epi16(v_g1, 8)); + __m128i layer4_chunk2 = _mm_packus_epi16(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer4_chunk6 = _mm_packus_epi16(_mm_srli_epi16(v_b0, 8), _mm_srli_epi16(v_b1, 8)); + __m128i layer4_chunk3 = _mm_packus_epi16(_mm_and_si128(v_a0, v_mask), _mm_and_si128(v_a1, v_mask)); + __m128i layer4_chunk7 = _mm_packus_epi16(_mm_srli_epi16(v_a0, 8), _mm_srli_epi16(v_a1, 8)); + + __m128i layer3_chunk0 = _mm_packus_epi16(_mm_and_si128(layer4_chunk0, v_mask), _mm_and_si128(layer4_chunk1, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk0, 8), _mm_srli_epi16(layer4_chunk1, 8)); + __m128i layer3_chunk1 = _mm_packus_epi16(_mm_and_si128(layer4_chunk2, v_mask), _mm_and_si128(layer4_chunk3, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk2, 8), _mm_srli_epi16(layer4_chunk3, 8)); + __m128i layer3_chunk2 = _mm_packus_epi16(_mm_and_si128(layer4_chunk4, v_mask), _mm_and_si128(layer4_chunk5, v_mask)); + __m128i layer3_chunk6 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk4, 8), _mm_srli_epi16(layer4_chunk5, 8)); + __m128i layer3_chunk3 = _mm_packus_epi16(_mm_and_si128(layer4_chunk6, v_mask), _mm_and_si128(layer4_chunk7, v_mask)); + __m128i layer3_chunk7 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk6, 8), _mm_srli_epi16(layer4_chunk7, 8)); + + __m128i layer2_chunk0 = _mm_packus_epi16(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk0, 8), _mm_srli_epi16(layer3_chunk1, 8)); + __m128i layer2_chunk1 = _mm_packus_epi16(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk2, 8), _mm_srli_epi16(layer3_chunk3, 8)); + __m128i layer2_chunk2 = _mm_packus_epi16(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk6 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk4, 8), _mm_srli_epi16(layer3_chunk5, 8)); + __m128i layer2_chunk3 = _mm_packus_epi16(_mm_and_si128(layer3_chunk6, v_mask), _mm_and_si128(layer3_chunk7, v_mask)); + __m128i layer2_chunk7 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk6, 8), _mm_srli_epi16(layer3_chunk7, 8)); + + __m128i layer1_chunk0 = _mm_packus_epi16(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk0, 8), _mm_srli_epi16(layer2_chunk1, 8)); + __m128i layer1_chunk1 = _mm_packus_epi16(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk2, 8), _mm_srli_epi16(layer2_chunk3, 8)); + __m128i layer1_chunk2 = _mm_packus_epi16(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk6 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk4, 8), _mm_srli_epi16(layer2_chunk5, 8)); + __m128i layer1_chunk3 = _mm_packus_epi16(_mm_and_si128(layer2_chunk6, v_mask), _mm_and_si128(layer2_chunk7, v_mask)); + __m128i layer1_chunk7 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk6, 8), _mm_srli_epi16(layer2_chunk7, 8)); + + v_r0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_b0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk0, 8), _mm_srli_epi16(layer1_chunk1, 8)); + v_r1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk2, 8), _mm_srli_epi16(layer1_chunk3, 8)); + v_g0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_a0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk4, 8), _mm_srli_epi16(layer1_chunk5, 8)); + v_g1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk6, v_mask), _mm_and_si128(layer1_chunk7, v_mask)); + v_a1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk6, 8), _mm_srli_epi16(layer1_chunk7, 8)); +} + +inline void _mm_deinterleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi16(v_r0, v_g0); + __m128i layer1_chunk1 = _mm_unpackhi_epi16(v_r0, v_g0); + __m128i layer1_chunk2 = _mm_unpacklo_epi16(v_r1, v_g1); + __m128i layer1_chunk3 = _mm_unpackhi_epi16(v_r1, v_g1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi16(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk1 = _mm_unpackhi_epi16(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk2 = _mm_unpacklo_epi16(layer1_chunk1, layer1_chunk3); + __m128i layer2_chunk3 = _mm_unpackhi_epi16(layer1_chunk1, layer1_chunk3); + + __m128i layer3_chunk0 = _mm_unpacklo_epi16(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk1 = _mm_unpackhi_epi16(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk2 = _mm_unpacklo_epi16(layer2_chunk1, layer2_chunk3); + __m128i layer3_chunk3 = _mm_unpackhi_epi16(layer2_chunk1, layer2_chunk3); + + v_r0 = _mm_unpacklo_epi16(layer3_chunk0, layer3_chunk2); + v_r1 = _mm_unpackhi_epi16(layer3_chunk0, layer3_chunk2); + v_g0 = _mm_unpacklo_epi16(layer3_chunk1, layer3_chunk3); + v_g1 = _mm_unpackhi_epi16(layer3_chunk1, layer3_chunk3); +} + +inline void _mm_deinterleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi16(v_r0, v_g1); + __m128i layer1_chunk1 = _mm_unpackhi_epi16(v_r0, v_g1); + __m128i layer1_chunk2 = _mm_unpacklo_epi16(v_r1, v_b0); + __m128i layer1_chunk3 = _mm_unpackhi_epi16(v_r1, v_b0); + __m128i layer1_chunk4 = _mm_unpacklo_epi16(v_g0, v_b1); + __m128i layer1_chunk5 = _mm_unpackhi_epi16(v_g0, v_b1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi16(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk1 = _mm_unpackhi_epi16(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk2 = _mm_unpacklo_epi16(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk3 = _mm_unpackhi_epi16(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk4 = _mm_unpacklo_epi16(layer1_chunk2, layer1_chunk5); + __m128i layer2_chunk5 = _mm_unpackhi_epi16(layer1_chunk2, layer1_chunk5); + + __m128i layer3_chunk0 = _mm_unpacklo_epi16(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk1 = _mm_unpackhi_epi16(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk2 = _mm_unpacklo_epi16(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk3 = _mm_unpackhi_epi16(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk4 = _mm_unpacklo_epi16(layer2_chunk2, layer2_chunk5); + __m128i layer3_chunk5 = _mm_unpackhi_epi16(layer2_chunk2, layer2_chunk5); + + v_r0 = _mm_unpacklo_epi16(layer3_chunk0, layer3_chunk3); + v_r1 = _mm_unpackhi_epi16(layer3_chunk0, layer3_chunk3); + v_g0 = _mm_unpacklo_epi16(layer3_chunk1, layer3_chunk4); + v_g1 = _mm_unpackhi_epi16(layer3_chunk1, layer3_chunk4); + v_b0 = _mm_unpacklo_epi16(layer3_chunk2, layer3_chunk5); + v_b1 = _mm_unpackhi_epi16(layer3_chunk2, layer3_chunk5); +} + +inline void _mm_deinterleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi16(v_r0, v_b0); + __m128i layer1_chunk1 = _mm_unpackhi_epi16(v_r0, v_b0); + __m128i layer1_chunk2 = _mm_unpacklo_epi16(v_r1, v_b1); + __m128i layer1_chunk3 = _mm_unpackhi_epi16(v_r1, v_b1); + __m128i layer1_chunk4 = _mm_unpacklo_epi16(v_g0, v_a0); + __m128i layer1_chunk5 = _mm_unpackhi_epi16(v_g0, v_a0); + __m128i layer1_chunk6 = _mm_unpacklo_epi16(v_g1, v_a1); + __m128i layer1_chunk7 = _mm_unpackhi_epi16(v_g1, v_a1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi16(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk1 = _mm_unpackhi_epi16(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk2 = _mm_unpacklo_epi16(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk3 = _mm_unpackhi_epi16(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk4 = _mm_unpacklo_epi16(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk5 = _mm_unpackhi_epi16(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk6 = _mm_unpacklo_epi16(layer1_chunk3, layer1_chunk7); + __m128i layer2_chunk7 = _mm_unpackhi_epi16(layer1_chunk3, layer1_chunk7); + + __m128i layer3_chunk0 = _mm_unpacklo_epi16(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk1 = _mm_unpackhi_epi16(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk2 = _mm_unpacklo_epi16(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk3 = _mm_unpackhi_epi16(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk4 = _mm_unpacklo_epi16(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk5 = _mm_unpackhi_epi16(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk6 = _mm_unpacklo_epi16(layer2_chunk3, layer2_chunk7); + __m128i layer3_chunk7 = _mm_unpackhi_epi16(layer2_chunk3, layer2_chunk7); + + v_r0 = _mm_unpacklo_epi16(layer3_chunk0, layer3_chunk4); + v_r1 = _mm_unpackhi_epi16(layer3_chunk0, layer3_chunk4); + v_g0 = _mm_unpacklo_epi16(layer3_chunk1, layer3_chunk5); + v_g1 = _mm_unpackhi_epi16(layer3_chunk1, layer3_chunk5); + v_b0 = _mm_unpacklo_epi16(layer3_chunk2, layer3_chunk6); + v_b1 = _mm_unpackhi_epi16(layer3_chunk2, layer3_chunk6); + v_a0 = _mm_unpacklo_epi16(layer3_chunk3, layer3_chunk7); + v_a1 = _mm_unpackhi_epi16(layer3_chunk3, layer3_chunk7); +} + +#if CV_SSE4_1 + +inline void _mm_interleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i v_mask = _mm_set1_epi32(0x0000ffff); + + __m128i layer3_chunk0 = _mm_packus_epi32(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer3_chunk2 = _mm_packus_epi32(_mm_srli_epi32(v_r0, 16), _mm_srli_epi32(v_r1, 16)); + __m128i layer3_chunk1 = _mm_packus_epi32(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi32(_mm_srli_epi32(v_g0, 16), _mm_srli_epi32(v_g1, 16)); + + __m128i layer2_chunk0 = _mm_packus_epi32(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk2 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk0, 16), _mm_srli_epi32(layer3_chunk1, 16)); + __m128i layer2_chunk1 = _mm_packus_epi32(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk2, 16), _mm_srli_epi32(layer3_chunk3, 16)); + + __m128i layer1_chunk0 = _mm_packus_epi32(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk2 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk0, 16), _mm_srli_epi32(layer2_chunk1, 16)); + __m128i layer1_chunk1 = _mm_packus_epi32(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk2, 16), _mm_srli_epi32(layer2_chunk3, 16)); + + v_r0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk0, 16), _mm_srli_epi32(layer1_chunk1, 16)); + v_r1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_g1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk2, 16), _mm_srli_epi32(layer1_chunk3, 16)); +} + +inline void _mm_interleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i v_mask = _mm_set1_epi32(0x0000ffff); + + __m128i layer3_chunk0 = _mm_packus_epi32(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi32(_mm_srli_epi32(v_r0, 16), _mm_srli_epi32(v_r1, 16)); + __m128i layer3_chunk1 = _mm_packus_epi32(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi32(_mm_srli_epi32(v_g0, 16), _mm_srli_epi32(v_g1, 16)); + __m128i layer3_chunk2 = _mm_packus_epi32(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi32(_mm_srli_epi32(v_b0, 16), _mm_srli_epi32(v_b1, 16)); + + __m128i layer2_chunk0 = _mm_packus_epi32(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk0, 16), _mm_srli_epi32(layer3_chunk1, 16)); + __m128i layer2_chunk1 = _mm_packus_epi32(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk2, 16), _mm_srli_epi32(layer3_chunk3, 16)); + __m128i layer2_chunk2 = _mm_packus_epi32(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk4, 16), _mm_srli_epi32(layer3_chunk5, 16)); + + __m128i layer1_chunk0 = _mm_packus_epi32(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk0, 16), _mm_srli_epi32(layer2_chunk1, 16)); + __m128i layer1_chunk1 = _mm_packus_epi32(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk2, 16), _mm_srli_epi32(layer2_chunk3, 16)); + __m128i layer1_chunk2 = _mm_packus_epi32(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk4, 16), _mm_srli_epi32(layer2_chunk5, 16)); + + v_r0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk0, 16), _mm_srli_epi32(layer1_chunk1, 16)); + v_r1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk2, 16), _mm_srli_epi32(layer1_chunk3, 16)); + v_g0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_b1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk4, 16), _mm_srli_epi32(layer1_chunk5, 16)); +} + +inline void _mm_interleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i v_mask = _mm_set1_epi32(0x0000ffff); + + __m128i layer3_chunk0 = _mm_packus_epi32(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi32(_mm_srli_epi32(v_r0, 16), _mm_srli_epi32(v_r1, 16)); + __m128i layer3_chunk1 = _mm_packus_epi32(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi32(_mm_srli_epi32(v_g0, 16), _mm_srli_epi32(v_g1, 16)); + __m128i layer3_chunk2 = _mm_packus_epi32(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer3_chunk6 = _mm_packus_epi32(_mm_srli_epi32(v_b0, 16), _mm_srli_epi32(v_b1, 16)); + __m128i layer3_chunk3 = _mm_packus_epi32(_mm_and_si128(v_a0, v_mask), _mm_and_si128(v_a1, v_mask)); + __m128i layer3_chunk7 = _mm_packus_epi32(_mm_srli_epi32(v_a0, 16), _mm_srli_epi32(v_a1, 16)); + + __m128i layer2_chunk0 = _mm_packus_epi32(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk0, 16), _mm_srli_epi32(layer3_chunk1, 16)); + __m128i layer2_chunk1 = _mm_packus_epi32(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk2, 16), _mm_srli_epi32(layer3_chunk3, 16)); + __m128i layer2_chunk2 = _mm_packus_epi32(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk6 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk4, 16), _mm_srli_epi32(layer3_chunk5, 16)); + __m128i layer2_chunk3 = _mm_packus_epi32(_mm_and_si128(layer3_chunk6, v_mask), _mm_and_si128(layer3_chunk7, v_mask)); + __m128i layer2_chunk7 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk6, 16), _mm_srli_epi32(layer3_chunk7, 16)); + + __m128i layer1_chunk0 = _mm_packus_epi32(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk0, 16), _mm_srli_epi32(layer2_chunk1, 16)); + __m128i layer1_chunk1 = _mm_packus_epi32(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk2, 16), _mm_srli_epi32(layer2_chunk3, 16)); + __m128i layer1_chunk2 = _mm_packus_epi32(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk6 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk4, 16), _mm_srli_epi32(layer2_chunk5, 16)); + __m128i layer1_chunk3 = _mm_packus_epi32(_mm_and_si128(layer2_chunk6, v_mask), _mm_and_si128(layer2_chunk7, v_mask)); + __m128i layer1_chunk7 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk6, 16), _mm_srli_epi32(layer2_chunk7, 16)); + + v_r0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_b0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk0, 16), _mm_srli_epi32(layer1_chunk1, 16)); + v_r1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk2, 16), _mm_srli_epi32(layer1_chunk3, 16)); + v_g0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_a0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk4, 16), _mm_srli_epi32(layer1_chunk5, 16)); + v_g1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk6, v_mask), _mm_and_si128(layer1_chunk7, v_mask)); + v_a1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk6, 16), _mm_srli_epi32(layer1_chunk7, 16)); +} + +#endif // CV_SSE4_1 + +inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1) +{ + __m128 layer1_chunk0 = _mm_unpacklo_ps(v_r0, v_g0); + __m128 layer1_chunk1 = _mm_unpackhi_ps(v_r0, v_g0); + __m128 layer1_chunk2 = _mm_unpacklo_ps(v_r1, v_g1); + __m128 layer1_chunk3 = _mm_unpackhi_ps(v_r1, v_g1); + + __m128 layer2_chunk0 = _mm_unpacklo_ps(layer1_chunk0, layer1_chunk2); + __m128 layer2_chunk1 = _mm_unpackhi_ps(layer1_chunk0, layer1_chunk2); + __m128 layer2_chunk2 = _mm_unpacklo_ps(layer1_chunk1, layer1_chunk3); + __m128 layer2_chunk3 = _mm_unpackhi_ps(layer1_chunk1, layer1_chunk3); + + v_r0 = _mm_unpacklo_ps(layer2_chunk0, layer2_chunk2); + v_r1 = _mm_unpackhi_ps(layer2_chunk0, layer2_chunk2); + v_g0 = _mm_unpacklo_ps(layer2_chunk1, layer2_chunk3); + v_g1 = _mm_unpackhi_ps(layer2_chunk1, layer2_chunk3); +} + +inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, + __m128 & v_g1, __m128 & v_b0, __m128 & v_b1) +{ + __m128 layer1_chunk0 = _mm_unpacklo_ps(v_r0, v_g1); + __m128 layer1_chunk1 = _mm_unpackhi_ps(v_r0, v_g1); + __m128 layer1_chunk2 = _mm_unpacklo_ps(v_r1, v_b0); + __m128 layer1_chunk3 = _mm_unpackhi_ps(v_r1, v_b0); + __m128 layer1_chunk4 = _mm_unpacklo_ps(v_g0, v_b1); + __m128 layer1_chunk5 = _mm_unpackhi_ps(v_g0, v_b1); + + __m128 layer2_chunk0 = _mm_unpacklo_ps(layer1_chunk0, layer1_chunk3); + __m128 layer2_chunk1 = _mm_unpackhi_ps(layer1_chunk0, layer1_chunk3); + __m128 layer2_chunk2 = _mm_unpacklo_ps(layer1_chunk1, layer1_chunk4); + __m128 layer2_chunk3 = _mm_unpackhi_ps(layer1_chunk1, layer1_chunk4); + __m128 layer2_chunk4 = _mm_unpacklo_ps(layer1_chunk2, layer1_chunk5); + __m128 layer2_chunk5 = _mm_unpackhi_ps(layer1_chunk2, layer1_chunk5); + + v_r0 = _mm_unpacklo_ps(layer2_chunk0, layer2_chunk3); + v_r1 = _mm_unpackhi_ps(layer2_chunk0, layer2_chunk3); + v_g0 = _mm_unpacklo_ps(layer2_chunk1, layer2_chunk4); + v_g1 = _mm_unpackhi_ps(layer2_chunk1, layer2_chunk4); + v_b0 = _mm_unpacklo_ps(layer2_chunk2, layer2_chunk5); + v_b1 = _mm_unpackhi_ps(layer2_chunk2, layer2_chunk5); +} + +inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1, + __m128 & v_b0, __m128 & v_b1, __m128 & v_a0, __m128 & v_a1) +{ + __m128 layer1_chunk0 = _mm_unpacklo_ps(v_r0, v_b0); + __m128 layer1_chunk1 = _mm_unpackhi_ps(v_r0, v_b0); + __m128 layer1_chunk2 = _mm_unpacklo_ps(v_r1, v_b1); + __m128 layer1_chunk3 = _mm_unpackhi_ps(v_r1, v_b1); + __m128 layer1_chunk4 = _mm_unpacklo_ps(v_g0, v_a0); + __m128 layer1_chunk5 = _mm_unpackhi_ps(v_g0, v_a0); + __m128 layer1_chunk6 = _mm_unpacklo_ps(v_g1, v_a1); + __m128 layer1_chunk7 = _mm_unpackhi_ps(v_g1, v_a1); + + __m128 layer2_chunk0 = _mm_unpacklo_ps(layer1_chunk0, layer1_chunk4); + __m128 layer2_chunk1 = _mm_unpackhi_ps(layer1_chunk0, layer1_chunk4); + __m128 layer2_chunk2 = _mm_unpacklo_ps(layer1_chunk1, layer1_chunk5); + __m128 layer2_chunk3 = _mm_unpackhi_ps(layer1_chunk1, layer1_chunk5); + __m128 layer2_chunk4 = _mm_unpacklo_ps(layer1_chunk2, layer1_chunk6); + __m128 layer2_chunk5 = _mm_unpackhi_ps(layer1_chunk2, layer1_chunk6); + __m128 layer2_chunk6 = _mm_unpacklo_ps(layer1_chunk3, layer1_chunk7); + __m128 layer2_chunk7 = _mm_unpackhi_ps(layer1_chunk3, layer1_chunk7); + + v_r0 = _mm_unpacklo_ps(layer2_chunk0, layer2_chunk4); + v_r1 = _mm_unpackhi_ps(layer2_chunk0, layer2_chunk4); + v_g0 = _mm_unpacklo_ps(layer2_chunk1, layer2_chunk5); + v_g1 = _mm_unpackhi_ps(layer2_chunk1, layer2_chunk5); + v_b0 = _mm_unpacklo_ps(layer2_chunk2, layer2_chunk6); + v_b1 = _mm_unpackhi_ps(layer2_chunk2, layer2_chunk6); + v_a0 = _mm_unpacklo_ps(layer2_chunk3, layer2_chunk7); + v_a1 = _mm_unpackhi_ps(layer2_chunk3, layer2_chunk7); +} + +inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1) +{ + enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) }; + + __m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo); + __m128 layer2_chunk2 = _mm_shuffle_ps(v_r0, v_r1, mask_hi); + __m128 layer2_chunk1 = _mm_shuffle_ps(v_g0, v_g1, mask_lo); + __m128 layer2_chunk3 = _mm_shuffle_ps(v_g0, v_g1, mask_hi); + + __m128 layer1_chunk0 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_lo); + __m128 layer1_chunk2 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_hi); + __m128 layer1_chunk1 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_lo); + __m128 layer1_chunk3 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_hi); + + v_r0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_lo); + v_g0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_hi); + v_r1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_lo); + v_g1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_hi); +} + +inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, + __m128 & v_g1, __m128 & v_b0, __m128 & v_b1) +{ + enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) }; + + __m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo); + __m128 layer2_chunk3 = _mm_shuffle_ps(v_r0, v_r1, mask_hi); + __m128 layer2_chunk1 = _mm_shuffle_ps(v_g0, v_g1, mask_lo); + __m128 layer2_chunk4 = _mm_shuffle_ps(v_g0, v_g1, mask_hi); + __m128 layer2_chunk2 = _mm_shuffle_ps(v_b0, v_b1, mask_lo); + __m128 layer2_chunk5 = _mm_shuffle_ps(v_b0, v_b1, mask_hi); + + __m128 layer1_chunk0 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_lo); + __m128 layer1_chunk3 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_hi); + __m128 layer1_chunk1 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_lo); + __m128 layer1_chunk4 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_hi); + __m128 layer1_chunk2 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_lo); + __m128 layer1_chunk5 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_hi); + + v_r0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_lo); + v_g1 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_hi); + v_r1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_lo); + v_b0 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_hi); + v_g0 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_lo); + v_b1 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_hi); +} + +inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1, + __m128 & v_b0, __m128 & v_b1, __m128 & v_a0, __m128 & v_a1) +{ + enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) }; + + __m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo); + __m128 layer2_chunk4 = _mm_shuffle_ps(v_r0, v_r1, mask_hi); + __m128 layer2_chunk1 = _mm_shuffle_ps(v_g0, v_g1, mask_lo); + __m128 layer2_chunk5 = _mm_shuffle_ps(v_g0, v_g1, mask_hi); + __m128 layer2_chunk2 = _mm_shuffle_ps(v_b0, v_b1, mask_lo); + __m128 layer2_chunk6 = _mm_shuffle_ps(v_b0, v_b1, mask_hi); + __m128 layer2_chunk3 = _mm_shuffle_ps(v_a0, v_a1, mask_lo); + __m128 layer2_chunk7 = _mm_shuffle_ps(v_a0, v_a1, mask_hi); + + __m128 layer1_chunk0 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_lo); + __m128 layer1_chunk4 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_hi); + __m128 layer1_chunk1 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_lo); + __m128 layer1_chunk5 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_hi); + __m128 layer1_chunk2 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_lo); + __m128 layer1_chunk6 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_hi); + __m128 layer1_chunk3 = _mm_shuffle_ps(layer2_chunk6, layer2_chunk7, mask_lo); + __m128 layer1_chunk7 = _mm_shuffle_ps(layer2_chunk6, layer2_chunk7, mask_hi); + + v_r0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_lo); + v_b0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_hi); + v_r1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_lo); + v_b1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_hi); + v_g0 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_lo); + v_a0 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_hi); + v_g1 = _mm_shuffle_ps(layer1_chunk6, layer1_chunk7, mask_lo); + v_a1 = _mm_shuffle_ps(layer1_chunk6, layer1_chunk7, mask_hi); +} + +#endif // CV_SSE2 + +//! @} + +#endif //OPENCV_CORE_SSE_UTILS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/traits.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/traits.hpp new file mode 100644 index 0000000..52ab083 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/traits.hpp @@ -0,0 +1,417 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_TRAITS_HPP +#define OPENCV_CORE_TRAITS_HPP + +#include "opencv2/core/cvdef.h" + +namespace cv +{ + +//#define OPENCV_TRAITS_ENABLE_DEPRECATED + +//! @addtogroup core_basic +//! @{ + +/** @brief Template "trait" class for OpenCV primitive data types. + +@note Deprecated. This is replaced by "single purpose" traits: traits::Type and traits::Depth + +A primitive OpenCV data type is one of unsigned char, bool, signed char, unsigned short, signed +short, int, float, double, or a tuple of values of one of these types, where all the values in the +tuple have the same type. Any primitive type from the list can be defined by an identifier in the +form CV_\{U|S|F}C(\), for example: uchar \~ CV_8UC1, 3-element +floating-point tuple \~ CV_32FC3, and so on. A universal OpenCV structure that is able to store a +single instance of such a primitive data type is Vec. Multiple instances of such a type can be +stored in a std::vector, Mat, Mat_, SparseMat, SparseMat_, or any other container that is able to +store Vec instances. + +The DataType class is basically used to provide a description of such primitive data types without +adding any fields or methods to the corresponding classes (and it is actually impossible to add +anything to primitive C/C++ data types). This technique is known in C++ as class traits. It is not +DataType itself that is used but its specialized versions, such as: +@code + template<> class DataType + { + typedef uchar value_type; + typedef int work_type; + typedef uchar channel_type; + enum { channel_type = CV_8U, channels = 1, fmt='u', type = CV_8U }; + }; + ... + template DataType > + { + typedef std::complex<_Tp> value_type; + typedef std::complex<_Tp> work_type; + typedef _Tp channel_type; + // DataDepth is another helper trait class + enum { depth = DataDepth<_Tp>::value, channels=2, + fmt=(channels-1)*256+DataDepth<_Tp>::fmt, + type=CV_MAKETYPE(depth, channels) }; + }; + ... +@endcode +The main purpose of this class is to convert compilation-time type information to an +OpenCV-compatible data type identifier, for example: +@code + // allocates a 30x40 floating-point matrix + Mat A(30, 40, DataType::type); + + Mat B = Mat_ >(3, 3); + // the statement below will print 6, 2 , that is depth == CV_64F, channels == 2 + cout << B.depth() << ", " << B.channels() << endl; +@endcode +So, such traits are used to tell OpenCV which data type you are working with, even if such a type is +not native to OpenCV. For example, the matrix B initialization above is compiled because OpenCV +defines the proper specialized template class DataType\ \> . This mechanism is also +useful (and used in OpenCV this way) for generic algorithms implementations. + +@note Default values were dropped to stop confusing developers about using of unsupported types (see #7599) +*/ +template class DataType +{ +public: +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + typedef _Tp value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 1, + depth = -1, + channels = 1, + fmt = 0, + type = CV_MAKETYPE(depth, channels) + }; +#endif +}; + +template<> class DataType +{ +public: + typedef bool value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8U, + channels = 1, + fmt = (int)'u', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef uchar value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8U, + channels = 1, + fmt = (int)'u', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef schar value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8S, + channels = 1, + fmt = (int)'c', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef schar value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8S, + channels = 1, + fmt = (int)'c', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef ushort value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_16U, + channels = 1, + fmt = (int)'w', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef short value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_16S, + channels = 1, + fmt = (int)'s', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef int value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_32S, + channels = 1, + fmt = (int)'i', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef float value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_32F, + channels = 1, + fmt = (int)'f', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef double value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_64F, + channels = 1, + fmt = (int)'d', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef float16_t value_type; + typedef float work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_16F, + channels = 1, + fmt = (int)'h', + type = CV_MAKETYPE(depth, channels) + }; +}; + +/** @brief A helper class for cv::DataType + +The class is specialized for each fundamental numerical data type supported by OpenCV. It provides +DataDepth::value constant. +*/ +template class DataDepth +{ +public: + enum + { + value = DataType<_Tp>::depth, + fmt = DataType<_Tp>::fmt + }; +}; + + +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + +template class TypeDepth +{ +#ifdef OPENCV_TRAITS_ENABLE_LEGACY_DEFAULTS + enum { depth = CV_USRTYPE1 }; + typedef void value_type; +#endif +}; + +template<> class TypeDepth +{ + enum { depth = CV_8U }; + typedef uchar value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_8S }; + typedef schar value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_16U }; + typedef ushort value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_16S }; + typedef short value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_32S }; + typedef int value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_32F }; + typedef float value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_64F }; + typedef double value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_16F }; + typedef float16_t value_type; +}; + +#endif + +//! @} + +namespace traits { + +namespace internal { +#define CV_CREATE_MEMBER_CHECK(X) \ +template class CheckMember_##X { \ + struct Fallback { int X; }; \ + struct Derived : T, Fallback { }; \ + template struct Check; \ + typedef char CV_NO[1]; \ + typedef char CV_YES[2]; \ + template static CV_NO & func(Check *); \ + template static CV_YES & func(...); \ +public: \ + typedef CheckMember_##X type; \ + enum { value = sizeof(func(0)) == sizeof(CV_YES) }; \ +}; + +CV_CREATE_MEMBER_CHECK(fmt) +CV_CREATE_MEMBER_CHECK(type) + +} // namespace internal + + +template +struct Depth +{ enum { value = DataType::depth }; }; + +template +struct Type +{ enum { value = DataType::type }; }; + +/** Similar to traits::Type but has value = -1 in case of unknown type (instead of compiler error) */ +template >::value > +struct SafeType {}; + +template +struct SafeType +{ enum { value = -1 }; }; + +template +struct SafeType +{ enum { value = Type::value }; }; + + +template >::value > +struct SafeFmt {}; + +template +struct SafeFmt +{ enum { fmt = 0 }; }; + +template +struct SafeFmt +{ enum { fmt = DataType::fmt }; }; + + +} // namespace + +} // cv + +#endif // OPENCV_CORE_TRAITS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/types.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/types.hpp new file mode 100644 index 0000000..2867520 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/types.hpp @@ -0,0 +1,2439 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_TYPES_HPP +#define OPENCV_CORE_TYPES_HPP + +#ifndef __cplusplus +# error types.hpp header must be compiled as C++ +#endif + +#include +#include +#include +#include + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/matx.hpp" + +namespace cv +{ + +//! @addtogroup core_basic +//! @{ + +//////////////////////////////// Complex ////////////////////////////// + +/** @brief A complex number class. + + The template class is similar and compatible with std::complex, however it provides slightly + more convenient access to the real and imaginary parts using through the simple field access, as opposite + to std::complex::real() and std::complex::imag(). +*/ +template class Complex +{ +public: + + //! default constructor + Complex(); + Complex( _Tp _re, _Tp _im = 0 ); + + //! conversion to another data type + template operator Complex() const; + //! conjugation + Complex conj() const; + + _Tp re, im; //< the real and the imaginary parts +}; + +typedef Complex Complexf; +typedef Complex Complexd; + +template class DataType< Complex<_Tp> > +{ +public: + typedef Complex<_Tp> value_type; + typedef value_type work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = DataType::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Complex<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Complex<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +} // namespace + + +//////////////////////////////// Point_ //////////////////////////////// + +/** @brief Template class for 2D points specified by its coordinates `x` and `y`. + +An instance of the class is interchangeable with C structures, CvPoint and CvPoint2D32f . There is +also a cast operator to convert point coordinates to the specified type. The conversion from +floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion +uses this operation for each of the coordinates. Besides the class members listed in the +declaration above, the following operations on points are implemented: +@code + pt1 = pt2 + pt3; + pt1 = pt2 - pt3; + pt1 = pt2 * a; + pt1 = a * pt2; + pt1 = pt2 / a; + pt1 += pt2; + pt1 -= pt2; + pt1 *= a; + pt1 /= a; + double value = norm(pt); // L2 norm + pt1 == pt2; + pt1 != pt2; +@endcode +For your convenience, the following type aliases are defined: +@code + typedef Point_ Point2i; + typedef Point2i Point; + typedef Point_ Point2f; + typedef Point_ Point2d; +@endcode +Example: +@code + Point2f a(0.3f, 0.f), b(0.f, 0.4f); + Point pt = (a + b)*10.f; + cout << pt.x << ", " << pt.y << endl; +@endcode +*/ +template class Point_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Point_(); + Point_(_Tp _x, _Tp _y); +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 + Point_(const Point_& pt); + Point_(Point_&& pt) CV_NOEXCEPT = default; +#elif OPENCV_ABI_COMPATIBILITY < 500 + Point_(const Point_& pt) = default; + Point_(Point_&& pt) CV_NOEXCEPT = default; +#endif + Point_(const Size_<_Tp>& sz); + Point_(const Vec<_Tp, 2>& v); + +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 + Point_& operator = (const Point_& pt); + Point_& operator = (Point_&& pt) CV_NOEXCEPT = default; +#elif OPENCV_ABI_COMPATIBILITY < 500 + Point_& operator = (const Point_& pt) = default; + Point_& operator = (Point_&& pt) CV_NOEXCEPT = default; +#endif + //! conversion to another data type + template operator Point_<_Tp2>() const; + + //! conversion to the old-style C structures + operator Vec<_Tp, 2>() const; + + //! dot product + _Tp dot(const Point_& pt) const; + //! dot product computed in double-precision arithmetics + double ddot(const Point_& pt) const; + //! cross-product + double cross(const Point_& pt) const; + //! checks whether the point is inside the specified rectangle + bool inside(const Rect_<_Tp>& r) const; + _Tp x; //!< x coordinate of the point + _Tp y; //!< y coordinate of the point +}; + +typedef Point_ Point2i; +typedef Point_ Point2l; +typedef Point_ Point2f; +typedef Point_ Point2d; +typedef Point2i Point; + +template class DataType< Point_<_Tp> > +{ +public: + typedef Point_<_Tp> value_type; + typedef Point_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Point_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Point_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +} // namespace + + +//////////////////////////////// Point3_ //////////////////////////////// + +/** @brief Template class for 3D points specified by its coordinates `x`, `y` and `z`. + +An instance of the class is interchangeable with the C structure CvPoint2D32f . Similarly to +Point_ , the coordinates of 3D points can be converted to another type. The vector arithmetic and +comparison operations are also supported. + +The following Point3_\<\> aliases are available: +@code + typedef Point3_ Point3i; + typedef Point3_ Point3f; + typedef Point3_ Point3d; +@endcode +@see cv::Point3i, cv::Point3f and cv::Point3d +*/ +template class Point3_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Point3_(); + Point3_(_Tp _x, _Tp _y, _Tp _z); +#if OPENCV_ABI_COMPATIBILITY < 500 + Point3_(const Point3_& pt) = default; + Point3_(Point3_&& pt) CV_NOEXCEPT = default; +#endif + explicit Point3_(const Point_<_Tp>& pt); + Point3_(const Vec<_Tp, 3>& v); + +#if OPENCV_ABI_COMPATIBILITY < 500 + Point3_& operator = (const Point3_& pt) = default; + Point3_& operator = (Point3_&& pt) CV_NOEXCEPT = default; +#endif + //! conversion to another data type + template operator Point3_<_Tp2>() const; + //! conversion to cv::Vec<> + operator Vec<_Tp, 3>() const; + + //! dot product + _Tp dot(const Point3_& pt) const; + //! dot product computed in double-precision arithmetics + double ddot(const Point3_& pt) const; + //! cross product of the 2 3D points + Point3_ cross(const Point3_& pt) const; + _Tp x; //!< x coordinate of the 3D point + _Tp y; //!< y coordinate of the 3D point + _Tp z; //!< z coordinate of the 3D point +}; + +typedef Point3_ Point3i; +typedef Point3_ Point3f; +typedef Point3_ Point3d; + +template class DataType< Point3_<_Tp> > +{ +public: + typedef Point3_<_Tp> value_type; + typedef Point3_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 3, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Point3_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Point3_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) }; }; +} // namespace + +//////////////////////////////// Size_ //////////////////////////////// + +/** @brief Template class for specifying the size of an image or rectangle. + +The class includes two members called width and height. The structure can be converted to and from +the old OpenCV structures CvSize and CvSize2D32f . The same set of arithmetic and comparison +operations as for Point_ is available. + +OpenCV defines the following Size_\<\> aliases: +@code + typedef Size_ Size2i; + typedef Size2i Size; + typedef Size_ Size2f; +@endcode +*/ +template class Size_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Size_(); + Size_(_Tp _width, _Tp _height); +#if OPENCV_ABI_COMPATIBILITY < 500 + Size_(const Size_& sz) = default; + Size_(Size_&& sz) CV_NOEXCEPT = default; +#endif + Size_(const Point_<_Tp>& pt); + +#if OPENCV_ABI_COMPATIBILITY < 500 + Size_& operator = (const Size_& sz) = default; + Size_& operator = (Size_&& sz) CV_NOEXCEPT = default; +#endif + //! the area (width*height) + _Tp area() const; + //! aspect ratio (width/height) + double aspectRatio() const; + //! true if empty + bool empty() const; + + //! conversion of another data type. + template operator Size_<_Tp2>() const; + + _Tp width; //!< the width + _Tp height; //!< the height +}; + +typedef Size_ Size2i; +typedef Size_ Size2l; +typedef Size_ Size2f; +typedef Size_ Size2d; +typedef Size2i Size; + +template class DataType< Size_<_Tp> > +{ +public: + typedef Size_<_Tp> value_type; + typedef Size_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = DataType::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Size_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Size_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +} // namespace + +//////////////////////////////// Rect_ //////////////////////////////// + +/** @brief Template class for 2D rectangles + +described by the following parameters: +- Coordinates of the top-left corner. This is a default interpretation of Rect_::x and Rect_::y + in OpenCV. Though, in your algorithms you may count x and y from the bottom-left corner. +- Rectangle width and height. + +OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the +right and bottom boundaries are not. For example, the method Rect_::contains returns true if + +\f[x \leq pt.x < x+width, + y \leq pt.y < y+height\f] + +Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect_\ ) is +implemented as: +@code + for(int y = roi.y; y < roi.y + roi.height; y++) + for(int x = roi.x; x < roi.x + roi.width; x++) + { + // ... + } +@endcode +In addition to the class members, the following operations on rectangles are implemented: +- \f$\texttt{rect} = \texttt{rect} \pm \texttt{point}\f$ (shifting a rectangle by a certain offset) +- \f$\texttt{rect} = \texttt{rect} \pm \texttt{size}\f$ (expanding or shrinking a rectangle by a + certain amount) +- rect += point, rect -= point, rect += size, rect -= size (augmenting operations) +- rect = rect1 & rect2 (rectangle intersection) +- rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 ) +- rect &= rect1, rect |= rect1 (and the corresponding augmenting operations) +- rect == rect1, rect != rect1 (rectangle comparison) + +This is an example how the partial ordering on rectangles can be established (rect1 \f$\subseteq\f$ +rect2): +@code + template inline bool + operator <= (const Rect_<_Tp>& r1, const Rect_<_Tp>& r2) + { + return (r1 & r2) == r1; + } +@endcode +For your convenience, the Rect_\<\> alias is available: cv::Rect +*/ +template class Rect_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Rect_(); + Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height); +#if OPENCV_ABI_COMPATIBILITY < 500 + Rect_(const Rect_& r) = default; + Rect_(Rect_&& r) CV_NOEXCEPT = default; +#endif + Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz); + Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2); + +#if OPENCV_ABI_COMPATIBILITY < 500 + Rect_& operator = (const Rect_& r) = default; + Rect_& operator = (Rect_&& r) CV_NOEXCEPT = default; +#endif + //! the top-left corner + Point_<_Tp> tl() const; + //! the bottom-right corner + Point_<_Tp> br() const; + + //! size (width, height) of the rectangle + Size_<_Tp> size() const; + //! area (width*height) of the rectangle + _Tp area() const; + //! true if empty + bool empty() const; + + //! conversion to another data type + template operator Rect_<_Tp2>() const; + + //! checks whether the rectangle contains the point + bool contains(const Point_<_Tp>& pt) const; + + _Tp x; //!< x coordinate of the top-left corner + _Tp y; //!< y coordinate of the top-left corner + _Tp width; //!< width of the rectangle + _Tp height; //!< height of the rectangle +}; + +typedef Rect_ Rect2i; +typedef Rect_ Rect2f; +typedef Rect_ Rect2d; +typedef Rect2i Rect; + +template class DataType< Rect_<_Tp> > +{ +public: + typedef Rect_<_Tp> value_type; + typedef Rect_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 4, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Rect_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +} // namespace + +///////////////////////////// RotatedRect ///////////////////////////// + +/** @brief The class represents rotated (i.e. not up-right) rectangles on a plane. + +Each rectangle is specified by the center point (mass center), length of each side (represented by +#Size2f structure) and the rotation angle in degrees. + +The sample below demonstrates how to use RotatedRect: +@snippet snippets/core_various.cpp RotatedRect_demo +![image](pics/rotatedrect.png) + +@sa CamShift, fitEllipse, minAreaRect, CvBox2D +*/ +class CV_EXPORTS RotatedRect +{ +public: + //! default constructor + RotatedRect(); + /** full constructor + @param center The rectangle mass center. + @param size Width and height of the rectangle. + @param angle The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., + the rectangle becomes an up-right rectangle. + */ + RotatedRect(const Point2f& center, const Size2f& size, float angle); + /** + Any 3 end points of the RotatedRect. They must be given in order (either clockwise or + anticlockwise). + */ + RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3); + + /** returns 4 vertices of the rectangle + @param pts The points array for storing rectangle vertices. The order is bottomLeft, topLeft, topRight, bottomRight. + */ + void points(Point2f pts[]) const; + //! returns the minimal up-right integer rectangle containing the rotated rectangle + Rect boundingRect() const; + //! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images + Rect_ boundingRect2f() const; + //! returns the rectangle mass center + Point2f center; + //! returns width and height of the rectangle + Size2f size; + //! returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. + float angle; +}; + +template<> class DataType< RotatedRect > +{ +public: + typedef RotatedRect value_type; + typedef value_type work_type; + typedef float channel_type; + + enum { generic_type = 0, + channels = (int)sizeof(value_type)/sizeof(channel_type), // 5 + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template<> +struct Depth< RotatedRect > { enum { value = Depth::value }; }; +template<> +struct Type< RotatedRect > { enum { value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)) }; }; +} // namespace + + +//////////////////////////////// Range ///////////////////////////////// + +/** @brief Template class specifying a continuous subsequence (slice) of a sequence. + +The class is used to specify a row or a column span in a matrix ( Mat ) and for many other purposes. +Range(a,b) is basically the same as a:b in Matlab or a..b in Python. As in Python, start is an +inclusive left boundary of the range and end is an exclusive right boundary of the range. Such a +half-opened interval is usually denoted as \f$[start,end)\f$ . + +The static method Range::all() returns a special variable that means "the whole sequence" or "the +whole range", just like " : " in Matlab or " ... " in Python. All the methods and functions in +OpenCV that take Range support this special Range::all() value. But, of course, in case of your own +custom processing, you will probably have to check and handle it explicitly: +@code + void my_function(..., const Range& r, ....) + { + if(r == Range::all()) { + // process all the data + } + else { + // process [r.start, r.end) + } + } +@endcode +*/ +class CV_EXPORTS Range +{ +public: + Range(); + Range(int _start, int _end); + int size() const; + bool empty() const; + static Range all(); + + int start, end; +}; + +template<> class DataType +{ +public: + typedef Range value_type; + typedef value_type work_type; + typedef int channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template<> +struct Depth< Range > { enum { value = Depth::value }; }; +template<> +struct Type< Range > { enum { value = CV_MAKETYPE(Depth::value, 2) }; }; +} // namespace + + +//////////////////////////////// Scalar_ /////////////////////////////// + +/** @brief Template class for a 4-element vector derived from Vec. + +Being derived from Vec\<_Tp, 4\> , Scalar\_ and Scalar can be used just as typical 4-element +vectors. In addition, they can be converted to/from CvScalar . The type Scalar is widely used in +OpenCV to pass pixel values. +*/ +template class Scalar_ : public Vec<_Tp, 4> +{ +public: + //! default constructor + Scalar_(); + Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0); + Scalar_(_Tp v0); + + Scalar_(const Scalar_& s); + Scalar_(Scalar_&& s) CV_NOEXCEPT; + + Scalar_& operator=(const Scalar_& s); + Scalar_& operator=(Scalar_&& s) CV_NOEXCEPT; + + template + Scalar_(const Vec<_Tp2, cn>& v); + + //! returns a scalar with all elements set to v0 + static Scalar_<_Tp> all(_Tp v0); + + //! conversion to another data type + template operator Scalar_() const; + + //! per-element product + Scalar_<_Tp> mul(const Scalar_<_Tp>& a, double scale=1 ) const; + + //! returns (v0, -v1, -v2, -v3) + Scalar_<_Tp> conj() const; + + //! returns true iff v1 == v2 == v3 == 0 + bool isReal() const; +}; + +typedef Scalar_ Scalar; + +template class DataType< Scalar_<_Tp> > +{ +public: + typedef Scalar_<_Tp> value_type; + typedef Scalar_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 4, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Scalar_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +} // namespace + + +/////////////////////////////// KeyPoint //////////////////////////////// + +/** @brief Data structure for salient point detectors. + +The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint +detectors, such as Harris corner detector, #FAST, %StarDetector, %SURF, %SIFT etc. + +The keypoint is characterized by the 2D position, scale (proportional to the diameter of the +neighborhood that needs to be taken into account), orientation and some other parameters. The +keypoint neighborhood is then analyzed by another algorithm that builds a descriptor (usually +represented as a feature vector). The keypoints representing the same object in different images +can then be matched using %KDTree or another method. +*/ +class CV_EXPORTS_W_SIMPLE KeyPoint +{ +public: + //! the default constructor + CV_WRAP KeyPoint(); + /** + @param pt x & y coordinates of the keypoint + @param size keypoint diameter + @param angle keypoint orientation + @param response keypoint detector response on the keypoint (that is, strength of the keypoint) + @param octave pyramid octave in which the keypoint has been detected + @param class_id object id + */ + KeyPoint(Point2f pt, float size, float angle=-1, float response=0, int octave=0, int class_id=-1); + /** + @param x x-coordinate of the keypoint + @param y y-coordinate of the keypoint + @param size keypoint diameter + @param angle keypoint orientation + @param response keypoint detector response on the keypoint (that is, strength of the keypoint) + @param octave pyramid octave in which the keypoint has been detected + @param class_id object id + */ + CV_WRAP KeyPoint(float x, float y, float size, float angle=-1, float response=0, int octave=0, int class_id=-1); + + size_t hash() const; + + /** + This method converts vector of keypoints to vector of points or the reverse, where each keypoint is + assigned the same size and the same orientation. + + @param keypoints Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB + @param points2f Array of (x,y) coordinates of each keypoint + @param keypointIndexes Array of indexes of keypoints to be converted to points. (Acts like a mask to + convert only specified keypoints) + */ + CV_WRAP static void convert(const std::vector& keypoints, + CV_OUT std::vector& points2f, + const std::vector& keypointIndexes=std::vector()); + /** @overload + @param points2f Array of (x,y) coordinates of each keypoint + @param keypoints Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB + @param size keypoint diameter + @param response keypoint detector response on the keypoint (that is, strength of the keypoint) + @param octave pyramid octave in which the keypoint has been detected + @param class_id object id + */ + CV_WRAP static void convert(const std::vector& points2f, + CV_OUT std::vector& keypoints, + float size=1, float response=1, int octave=0, int class_id=-1); + + /** + This method computes overlap for pair of keypoints. Overlap is the ratio between area of keypoint + regions' intersection and area of keypoint regions' union (considering keypoint region as circle). + If they don't overlap, we get zero. If they coincide at same location with same size, we get 1. + @param kp1 First keypoint + @param kp2 Second keypoint + */ + CV_WRAP static float overlap(const KeyPoint& kp1, const KeyPoint& kp2); + + CV_PROP_RW Point2f pt; //!< coordinates of the keypoints + CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood + CV_PROP_RW float angle; //!< computed orientation of the keypoint (-1 if not applicable); + //!< it's in [0,360) degrees and measured relative to + //!< image coordinate system, ie in clockwise. + CV_PROP_RW float response; //!< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling + CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has been extracted + CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to) +}; + +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED +template<> class DataType +{ +public: + typedef KeyPoint value_type; + typedef float work_type; + typedef float channel_type; + + enum { generic_type = 0, + depth = DataType::depth, + channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 7 + fmt = DataType::fmt + ((channels - 1) << 8), + type = CV_MAKETYPE(depth, channels) + }; + + typedef Vec vec_type; +}; +#endif + + +//////////////////////////////// DMatch ///////////////////////////////// + +/** @brief Class for matching keypoint descriptors + +query descriptor index, train descriptor index, train image index, and distance between +descriptors. +*/ +class CV_EXPORTS_W_SIMPLE DMatch +{ +public: + CV_WRAP DMatch(); + CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance); + CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance); + + CV_PROP_RW int queryIdx; //!< query descriptor index + CV_PROP_RW int trainIdx; //!< train descriptor index + CV_PROP_RW int imgIdx; //!< train image index + + CV_PROP_RW float distance; + + // less is better + bool operator<(const DMatch &m) const; +}; + +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED +template<> class DataType +{ +public: + typedef DMatch value_type; + typedef int work_type; + typedef int channel_type; + + enum { generic_type = 0, + depth = DataType::depth, + channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 4 + fmt = DataType::fmt + ((channels - 1) << 8), + type = CV_MAKETYPE(depth, channels) + }; + + typedef Vec vec_type; +}; +#endif + + +///////////////////////////// TermCriteria ////////////////////////////// + +/** @brief The class defining termination criteria for iterative algorithms. + +You can initialize it by default constructor and then override any parameters, or the structure may +be fully initialized using the advanced variant of the constructor. +*/ +class CV_EXPORTS TermCriteria +{ +public: + /** + Criteria type, can be one of: COUNT, EPS or COUNT + EPS + */ + enum Type + { + COUNT=1, //!< the maximum number of iterations or elements to compute + MAX_ITER=COUNT, //!< ditto + EPS=2 //!< the desired accuracy or change in parameters at which the iterative algorithm stops + }; + + //! default constructor + TermCriteria(); + /** + @param type The type of termination criteria, one of TermCriteria::Type + @param maxCount The maximum number of iterations or elements to compute. + @param epsilon The desired accuracy or change in parameters at which the iterative algorithm stops. + */ + TermCriteria(int type, int maxCount, double epsilon); + + inline bool isValid() const + { + const bool isCount = (type & COUNT) && maxCount > 0; + const bool isEps = (type & EPS) && !cvIsNaN(epsilon); + return isCount || isEps; + } + + int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS + int maxCount; //!< the maximum number of iterations/elements + double epsilon; //!< the desired accuracy +}; + + +//! @} core_basic + +///////////////////////// raster image moments ////////////////////////// + +//! @addtogroup imgproc_shape +//! @{ + +/** @brief struct returned by cv::moments + +The spatial moments \f$\texttt{Moments::m}_{ji}\f$ are computed as: + +\f[\texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot y^i \right )\f] + +The central moments \f$\texttt{Moments::mu}_{ji}\f$ are computed as: + +\f[\texttt{mu} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot (x - \bar{x} )^j \cdot (y - \bar{y} )^i \right )\f] + +where \f$(\bar{x}, \bar{y})\f$ is the mass center: + +\f[\bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} = \frac{\texttt{m}_{01}}{\texttt{m}_{00}}\f] + +The normalized central moments \f$\texttt{Moments::nu}_{ij}\f$ are computed as: + +\f[\texttt{nu} _{ji}= \frac{\texttt{mu}_{ji}}{\texttt{m}_{00}^{(i+j)/2+1}} .\f] + +@note +\f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$ +\f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$ , hence the values are not +stored. + +The moments of a contour are defined in the same way but computed using the Green's formula (see +). So, due to a limited raster resolution, the moments +computed for a contour are slightly different from the moments computed for the same rasterized +contour. + +@note +Since the contour moments are computed using Green formula, you may get seemingly odd results for +contours with self-intersections, e.g. a zero area (m00) for butterfly-shaped contours. + */ +class CV_EXPORTS_W_MAP Moments +{ +public: + //! the default constructor + Moments(); + //! the full constructor + Moments(double m00, double m10, double m01, double m20, double m11, + double m02, double m30, double m21, double m12, double m03 ); + ////! the conversion from CvMoments + //Moments( const CvMoments& moments ); + ////! the conversion to CvMoments + //operator CvMoments() const; + + //! @name spatial moments + //! @{ + CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; + //! @} + + //! @name central moments + //! @{ + CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03; + //! @} + + //! @name central normalized moments + //! @{ + CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03; + //! @} +}; + +template<> class DataType +{ +public: + typedef Moments value_type; + typedef double work_type; + typedef double channel_type; + + enum { generic_type = 0, + channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24 + fmt = DataType::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template<> +struct Depth< Moments > { enum { value = Depth::value }; }; +template<> +struct Type< Moments > { enum { value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))) }; }; +} // namespace + +//! @} imgproc_shape + +//! @cond IGNORED + +///////////////////////////////////////////////////////////////////////// +///////////////////////////// Implementation //////////////////////////// +///////////////////////////////////////////////////////////////////////// + +//////////////////////////////// Complex //////////////////////////////// + +template inline +Complex<_Tp>::Complex() + : re(0), im(0) {} + +template inline +Complex<_Tp>::Complex( _Tp _re, _Tp _im ) + : re(_re), im(_im) {} + +template template inline +Complex<_Tp>::operator Complex() const +{ + return Complex(saturate_cast(re), saturate_cast(im)); +} + +template inline +Complex<_Tp> Complex<_Tp>::conj() const +{ + return Complex<_Tp>(re, -im); +} + + +template static inline +bool operator == (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return a.re == b.re && a.im == b.im; +} + +template static inline +bool operator != (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return a.re != b.re || a.im != b.im; +} + +template static inline +Complex<_Tp> operator + (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return Complex<_Tp>( a.re + b.re, a.im + b.im ); +} + +template static inline +Complex<_Tp>& operator += (Complex<_Tp>& a, const Complex<_Tp>& b) +{ + a.re += b.re; a.im += b.im; + return a; +} + +template static inline +Complex<_Tp> operator - (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return Complex<_Tp>( a.re - b.re, a.im - b.im ); +} + +template static inline +Complex<_Tp>& operator -= (Complex<_Tp>& a, const Complex<_Tp>& b) +{ + a.re -= b.re; a.im -= b.im; + return a; +} + +template static inline +Complex<_Tp> operator - (const Complex<_Tp>& a) +{ + return Complex<_Tp>(-a.re, -a.im); +} + +template static inline +Complex<_Tp> operator * (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return Complex<_Tp>( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re ); +} + +template static inline +Complex<_Tp> operator * (const Complex<_Tp>& a, _Tp b) +{ + return Complex<_Tp>( a.re*b, a.im*b ); +} + +template static inline +Complex<_Tp> operator * (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>( a.re*b, a.im*b ); +} + +template static inline +Complex<_Tp> operator + (const Complex<_Tp>& a, _Tp b) +{ + return Complex<_Tp>( a.re + b, a.im ); +} + +template static inline +Complex<_Tp> operator - (const Complex<_Tp>& a, _Tp b) +{ return Complex<_Tp>( a.re - b, a.im ); } + +template static inline +Complex<_Tp> operator + (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>( a.re + b, a.im ); +} + +template static inline +Complex<_Tp> operator - (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>( b - a.re, -a.im ); +} + +template static inline +Complex<_Tp>& operator += (Complex<_Tp>& a, _Tp b) +{ + a.re += b; return a; +} + +template static inline +Complex<_Tp>& operator -= (Complex<_Tp>& a, _Tp b) +{ + a.re -= b; return a; +} + +template static inline +Complex<_Tp>& operator *= (Complex<_Tp>& a, _Tp b) +{ + a.re *= b; a.im *= b; return a; +} + +template static inline +double abs(const Complex<_Tp>& a) +{ + return std::sqrt( (double)a.re*a.re + (double)a.im*a.im); +} + +template static inline +Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + double t = 1./((double)b.re*b.re + (double)b.im*b.im); + return Complex<_Tp>( (_Tp)((a.re*b.re + a.im*b.im)*t), + (_Tp)((-a.re*b.im + a.im*b.re)*t) ); +} + +template static inline +Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b) +{ + a = a / b; + return a; +} + +template static inline +Complex<_Tp> operator / (const Complex<_Tp>& a, _Tp b) +{ + _Tp t = (_Tp)1/b; + return Complex<_Tp>( a.re*t, a.im*t ); +} + +template static inline +Complex<_Tp> operator / (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>(b)/a; +} + +template static inline +Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b) +{ + _Tp t = (_Tp)1/b; + a.re *= t; a.im *= t; return a; +} + + + +//////////////////////////////// 2D Point /////////////////////////////// + +template inline +Point_<_Tp>::Point_() + : x(0), y(0) {} + +template inline +Point_<_Tp>::Point_(_Tp _x, _Tp _y) + : x(_x), y(_y) {} + +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 +template inline +Point_<_Tp>::Point_(const Point_& pt) + : x(pt.x), y(pt.y) {} +#endif + +template inline +Point_<_Tp>::Point_(const Size_<_Tp>& sz) + : x(sz.width), y(sz.height) {} + +template inline +Point_<_Tp>::Point_(const Vec<_Tp,2>& v) + : x(v[0]), y(v[1]) {} + +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 +template inline +Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) +{ + x = pt.x; y = pt.y; + return *this; +} +#endif + +template template inline +Point_<_Tp>::operator Point_<_Tp2>() const +{ + return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); +} + +template inline +Point_<_Tp>::operator Vec<_Tp, 2>() const +{ + return Vec<_Tp, 2>(x, y); +} + +template inline +_Tp Point_<_Tp>::dot(const Point_& pt) const +{ + return saturate_cast<_Tp>(x*pt.x + y*pt.y); +} + +template inline +double Point_<_Tp>::ddot(const Point_& pt) const +{ + return (double)x*(double)(pt.x) + (double)y*(double)(pt.y); +} + +template inline +double Point_<_Tp>::cross(const Point_& pt) const +{ + return (double)x*pt.y - (double)y*pt.x; +} + +template inline bool +Point_<_Tp>::inside( const Rect_<_Tp>& r ) const +{ + return r.contains(*this); +} + + +template static inline +Point_<_Tp>& operator += (Point_<_Tp>& a, const Point_<_Tp>& b) +{ + a.x += b.x; + a.y += b.y; + return a; +} + +template static inline +Point_<_Tp>& operator -= (Point_<_Tp>& a, const Point_<_Tp>& b) +{ + a.x -= b.x; + a.y -= b.y; + return a; +} + +template static inline +Point_<_Tp>& operator *= (Point_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + return a; +} + +template static inline +Point_<_Tp>& operator *= (Point_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + return a; +} + +template static inline +Point_<_Tp>& operator *= (Point_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +double norm(const Point_<_Tp>& pt) +{ + return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y); +} + +template static inline +bool operator == (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return a.x == b.x && a.y == b.y; +} + +template static inline +bool operator != (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return a.x != b.x || a.y != b.y; +} + +template static inline +Point_<_Tp> operator + (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y) ); +} + +template static inline +Point_<_Tp> operator - (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y) ); +} + +template static inline +Point_<_Tp> operator - (const Point_<_Tp>& a) +{ + return Point_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y) ); +} + +template static inline +Point_<_Tp> operator * (const Point_<_Tp>& a, int b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); +} + +template static inline +Point_<_Tp> operator * (int a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); +} + +template static inline +Point_<_Tp> operator * (const Point_<_Tp>& a, float b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); +} + +template static inline +Point_<_Tp> operator * (float a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); +} + +template static inline +Point_<_Tp> operator * (const Point_<_Tp>& a, double b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); +} + +template static inline +Point_<_Tp> operator * (double a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); +} + +template static inline +Point_<_Tp> operator * (const Matx<_Tp, 2, 2>& a, const Point_<_Tp>& b) +{ + Matx<_Tp, 2, 1> tmp = a * Vec<_Tp,2>(b.x, b.y); + return Point_<_Tp>(tmp.val[0], tmp.val[1]); +} + +template static inline +Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b) +{ + Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, 1); + return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, int b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, float b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, double b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + + +template static inline _AccTp normL2Sqr(const Point_& pt); +template static inline _AccTp normL2Sqr(const Point_& pt); +template static inline _AccTp normL2Sqr(const Point_& pt); +template static inline _AccTp normL2Sqr(const Point_& pt); + +template<> inline int normL2Sqr(const Point_& pt) { return pt.dot(pt); } +template<> inline int64 normL2Sqr(const Point_& pt) { return pt.dot(pt); } +template<> inline float normL2Sqr(const Point_& pt) { return pt.dot(pt); } +template<> inline double normL2Sqr(const Point_& pt) { return pt.dot(pt); } + +template<> inline double normL2Sqr(const Point_& pt) { return pt.ddot(pt); } +template<> inline double normL2Sqr(const Point_& pt) { return pt.ddot(pt); } + + + +//////////////////////////////// 3D Point /////////////////////////////// + +template inline +Point3_<_Tp>::Point3_() + : x(0), y(0), z(0) {} + +template inline +Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) + : x(_x), y(_y), z(_z) {} + +template inline +Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) + : x(pt.x), y(pt.y), z(_Tp()) {} + +template inline +Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v) + : x(v[0]), y(v[1]), z(v[2]) {} + +template template inline +Point3_<_Tp>::operator Point3_<_Tp2>() const +{ + return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); +} + +template inline +Point3_<_Tp>::operator Vec<_Tp, 3>() const +{ + return Vec<_Tp, 3>(x, y, z); +} + +template inline +_Tp Point3_<_Tp>::dot(const Point3_& pt) const +{ + return saturate_cast<_Tp>(x*pt.x + y*pt.y + z*pt.z); +} + +template inline +double Point3_<_Tp>::ddot(const Point3_& pt) const +{ + return (double)x*pt.x + (double)y*pt.y + (double)z*pt.z; +} + +template inline +Point3_<_Tp> Point3_<_Tp>::cross(const Point3_<_Tp>& pt) const +{ + return Point3_<_Tp>(y*pt.z - z*pt.y, z*pt.x - x*pt.z, x*pt.y - y*pt.x); +} + + +template static inline +Point3_<_Tp>& operator += (Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + a.x += b.x; + a.y += b.y; + a.z += b.z; + return a; +} + +template static inline +Point3_<_Tp>& operator -= (Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + a.x -= b.x; + a.y -= b.y; + a.z -= b.z; + return a; +} + +template static inline +Point3_<_Tp>& operator *= (Point3_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + a.z = saturate_cast<_Tp>(a.z * b); + return a; +} + +template static inline +Point3_<_Tp>& operator *= (Point3_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + a.z = saturate_cast<_Tp>(a.z * b); + return a; +} + +template static inline +Point3_<_Tp>& operator *= (Point3_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + a.z = saturate_cast<_Tp>(a.z * b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +double norm(const Point3_<_Tp>& pt) +{ + return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y + (double)pt.z*pt.z); +} + +template static inline +bool operator == (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return a.x == b.x && a.y == b.y && a.z == b.z; +} + +template static inline +bool operator != (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return a.x != b.x || a.y != b.y || a.z != b.z; +} + +template static inline +Point3_<_Tp> operator + (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y), saturate_cast<_Tp>(a.z + b.z)); +} + +template static inline +Point3_<_Tp> operator - (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y), saturate_cast<_Tp>(a.z - b.z)); +} + +template static inline +Point3_<_Tp> operator - (const Point3_<_Tp>& a) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y), saturate_cast<_Tp>(-a.z) ); +} + +template static inline +Point3_<_Tp> operator * (const Point3_<_Tp>& a, int b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b), saturate_cast<_Tp>(a.z*b) ); +} + +template static inline +Point3_<_Tp> operator * (int a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) ); +} + +template static inline +Point3_<_Tp> operator * (const Point3_<_Tp>& a, float b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) ); +} + +template static inline +Point3_<_Tp> operator * (float a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) ); +} + +template static inline +Point3_<_Tp> operator * (const Point3_<_Tp>& a, double b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) ); +} + +template static inline +Point3_<_Tp> operator * (double a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) ); +} + +template static inline +Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point3_<_Tp>& b) +{ + Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, b.z); + return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); +} + +template static inline +Matx<_Tp, 4, 1> operator * (const Matx<_Tp, 4, 4>& a, const Point3_<_Tp>& b) +{ + return a * Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1); +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, int b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, float b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, double b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + + + +////////////////////////////////// Size ///////////////////////////////// + +template inline +Size_<_Tp>::Size_() + : width(0), height(0) {} + +template inline +Size_<_Tp>::Size_(_Tp _width, _Tp _height) + : width(_width), height(_height) {} + +template inline +Size_<_Tp>::Size_(const Point_<_Tp>& pt) + : width(pt.x), height(pt.y) {} + +template template inline +Size_<_Tp>::operator Size_<_Tp2>() const +{ + return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); +} + +template inline +_Tp Size_<_Tp>::area() const +{ + const _Tp result = width * height; + CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer + || width == 0 || result / width == height); // make sure the result fits in the return value + return result; +} + +template inline +double Size_<_Tp>::aspectRatio() const +{ + return width / static_cast(height); +} + +template inline +bool Size_<_Tp>::empty() const +{ + return width <= 0 || height <= 0; +} + + +template static inline +Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b) +{ + a.width *= b; + a.height *= b; + return a; +} + +template static inline +Size_<_Tp> operator * (const Size_<_Tp>& a, _Tp b) +{ + Size_<_Tp> tmp(a); + tmp *= b; + return tmp; +} + +template static inline +Size_<_Tp>& operator /= (Size_<_Tp>& a, _Tp b) +{ + a.width /= b; + a.height /= b; + return a; +} + +template static inline +Size_<_Tp> operator / (const Size_<_Tp>& a, _Tp b) +{ + Size_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Size_<_Tp>& operator += (Size_<_Tp>& a, const Size_<_Tp>& b) +{ + a.width += b.width; + a.height += b.height; + return a; +} + +template static inline +Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + Size_<_Tp> tmp(a); + tmp += b; + return tmp; +} + +template static inline +Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b) +{ + a.width -= b.width; + a.height -= b.height; + return a; +} + +template static inline +Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + Size_<_Tp> tmp(a); + tmp -= b; + return tmp; +} + +template static inline +bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + return a.width == b.width && a.height == b.height; +} + +template static inline +bool operator != (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + return !(a == b); +} + + + +////////////////////////////////// Rect ///////////////////////////////// + +template inline +Rect_<_Tp>::Rect_() + : x(0), y(0), width(0), height(0) {} + +template inline +Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height) + : x(_x), y(_y), width(_width), height(_height) {} + +template inline +Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz) + : x(org.x), y(org.y), width(sz.width), height(sz.height) {} + +template inline +Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2) +{ + x = std::min(pt1.x, pt2.x); + y = std::min(pt1.y, pt2.y); + width = std::max(pt1.x, pt2.x) - x; + height = std::max(pt1.y, pt2.y) - y; +} + +template inline +Point_<_Tp> Rect_<_Tp>::tl() const +{ + return Point_<_Tp>(x,y); +} + +template inline +Point_<_Tp> Rect_<_Tp>::br() const +{ + return Point_<_Tp>(x + width, y + height); +} + +template inline +Size_<_Tp> Rect_<_Tp>::size() const +{ + return Size_<_Tp>(width, height); +} + +template inline +_Tp Rect_<_Tp>::area() const +{ + const _Tp result = width * height; + CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer + || width == 0 || result / width == height); // make sure the result fits in the return value + return result; +} + +template inline +bool Rect_<_Tp>::empty() const +{ + return width <= 0 || height <= 0; +} + +template template inline +Rect_<_Tp>::operator Rect_<_Tp2>() const +{ + return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); +} + +template inline +bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const +{ + return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height; +} + + +template static inline +Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Point_<_Tp>& b ) +{ + a.x += b.x; + a.y += b.y; + return a; +} + +template static inline +Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Point_<_Tp>& b ) +{ + a.x -= b.x; + a.y -= b.y; + return a; +} + +template static inline +Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b ) +{ + a.width += b.width; + a.height += b.height; + return a; +} + +template static inline +Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b ) +{ + const _Tp width = a.width - b.width; + const _Tp height = a.height - b.height; + CV_DbgAssert(width >= 0 && height >= 0); + a.width = width; + a.height = height; + return a; +} + +template static inline +Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b ) +{ + if (a.empty() || b.empty()) { + a = Rect(); + return a; + } + const Rect_<_Tp>& Rx_min = (a.x < b.x) ? a : b; + const Rect_<_Tp>& Rx_max = (a.x < b.x) ? b : a; + const Rect_<_Tp>& Ry_min = (a.y < b.y) ? a : b; + const Rect_<_Tp>& Ry_max = (a.y < b.y) ? b : a; + // Looking at the formula below, we will compute Rx_min.width - (Rx_max.x - Rx_min.x) + // but we want to avoid overflows. Rx_min.width >= 0 and (Rx_max.x - Rx_min.x) >= 0 + // by definition so the difference does not overflow. The only thing that can overflow + // is (Rx_max.x - Rx_min.x). And it can only overflow if Rx_min.x < 0. + // Let us first deal with the following case. + if ((Rx_min.x < 0 && Rx_min.x + Rx_min.width < Rx_max.x) || + (Ry_min.y < 0 && Ry_min.y + Ry_min.height < Ry_max.y)) { + a = Rect(); + return a; + } + // We now know that either Rx_min.x >= 0, or + // Rx_min.x < 0 && Rx_min.x + Rx_min.width >= Rx_max.x and therefore + // Rx_min.width >= (Rx_max.x - Rx_min.x) which means (Rx_max.x - Rx_min.x) + // is inferior to a valid int and therefore does not overflow. + a.width = std::min(Rx_min.width - (Rx_max.x - Rx_min.x), Rx_max.width); + a.height = std::min(Ry_min.height - (Ry_max.y - Ry_min.y), Ry_max.height); + a.x = Rx_max.x; + a.y = Ry_max.y; + if (a.empty()) + a = Rect(); + return a; +} + +template static inline +Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b ) +{ + if (a.empty()) { + a = b; + } + else if (!b.empty()) { + _Tp x1 = std::min(a.x, b.x); + _Tp y1 = std::min(a.y, b.y); + a.width = std::max(a.x + a.width, b.x + b.width) - x1; + a.height = std::max(a.y + a.height, b.y + b.height) - y1; + a.x = x1; + a.y = y1; + } + return a; +} + +template static inline +bool operator == (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + +template static inline +bool operator != (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height; +} + +template static inline +Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Point_<_Tp>& b) +{ + return Rect_<_Tp>( a.x + b.x, a.y + b.y, a.width, a.height ); +} + +template static inline +Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Point_<_Tp>& b) +{ + return Rect_<_Tp>( a.x - b.x, a.y - b.y, a.width, a.height ); +} + +template static inline +Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b) +{ + return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height ); +} + +template static inline +Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Size_<_Tp>& b) +{ + const _Tp width = a.width - b.width; + const _Tp height = a.height - b.height; + CV_DbgAssert(width >= 0 && height >= 0); + return Rect_<_Tp>( a.x, a.y, width, height ); +} + +template static inline +Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + Rect_<_Tp> c = a; + return c &= b; +} + +template static inline +Rect_<_Tp> operator | (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + Rect_<_Tp> c = a; + return c |= b; +} + +/** + * @brief measure dissimilarity between two sample sets + * + * computes the complement of the Jaccard Index as described in . + * For rectangles this reduces to computing the intersection over the union. + */ +template static inline +double jaccardDistance(const Rect_<_Tp>& a, const Rect_<_Tp>& b) { + _Tp Aa = a.area(); + _Tp Ab = b.area(); + + if ((Aa + Ab) <= std::numeric_limits<_Tp>::epsilon()) { + // jaccard_index = 1 -> distance = 0 + return 0.0; + } + + double Aab = (a & b).area(); + // distance = 1 - jaccard_index + return 1.0 - Aab / (Aa + Ab - Aab); +} + +////////////////////////////// RotatedRect ////////////////////////////// + +inline +RotatedRect::RotatedRect() + : center(), size(), angle(0) {} + +inline +RotatedRect::RotatedRect(const Point2f& _center, const Size2f& _size, float _angle) + : center(_center), size(_size), angle(_angle) {} + +///////////////////////////////// Range ///////////////////////////////// + +inline +Range::Range() + : start(0), end(0) {} + +inline +Range::Range(int _start, int _end) + : start(_start), end(_end) {} + +inline +int Range::size() const +{ + return end - start; +} + +inline +bool Range::empty() const +{ + return start == end; +} + +inline +Range Range::all() +{ + return Range(INT_MIN, INT_MAX); +} + + +static inline +bool operator == (const Range& r1, const Range& r2) +{ + return r1.start == r2.start && r1.end == r2.end; +} + +static inline +bool operator != (const Range& r1, const Range& r2) +{ + return !(r1 == r2); +} + +static inline +bool operator !(const Range& r) +{ + return r.start == r.end; +} + +static inline +Range operator & (const Range& r1, const Range& r2) +{ + Range r(std::max(r1.start, r2.start), std::min(r1.end, r2.end)); + r.end = std::max(r.end, r.start); + return r; +} + +static inline +Range& operator &= (Range& r1, const Range& r2) +{ + r1 = r1 & r2; + return r1; +} + +static inline +Range operator + (const Range& r1, int delta) +{ + return Range(r1.start + delta, r1.end + delta); +} + +static inline +Range operator + (int delta, const Range& r1) +{ + return Range(r1.start + delta, r1.end + delta); +} + +static inline +Range operator - (const Range& r1, int delta) +{ + return r1 + (-delta); +} + + + +///////////////////////////////// Scalar //////////////////////////////// + +template inline +Scalar_<_Tp>::Scalar_() +{ + this->val[0] = this->val[1] = this->val[2] = this->val[3] = 0; +} + +template inline +Scalar_<_Tp>::Scalar_(_Tp v0, _Tp v1, _Tp v2, _Tp v3) +{ + this->val[0] = v0; + this->val[1] = v1; + this->val[2] = v2; + this->val[3] = v3; +} + +template inline +Scalar_<_Tp>::Scalar_(const Scalar_<_Tp>& s) : Vec<_Tp, 4>(s) { +} + +template inline +Scalar_<_Tp>::Scalar_(Scalar_<_Tp>&& s) CV_NOEXCEPT { + this->val[0] = std::move(s.val[0]); + this->val[1] = std::move(s.val[1]); + this->val[2] = std::move(s.val[2]); + this->val[3] = std::move(s.val[3]); +} + +template inline +Scalar_<_Tp>& Scalar_<_Tp>::operator=(const Scalar_<_Tp>& s) { + this->val[0] = s.val[0]; + this->val[1] = s.val[1]; + this->val[2] = s.val[2]; + this->val[3] = s.val[3]; + return *this; +} + +template inline +Scalar_<_Tp>& Scalar_<_Tp>::operator=(Scalar_<_Tp>&& s) CV_NOEXCEPT { + this->val[0] = std::move(s.val[0]); + this->val[1] = std::move(s.val[1]); + this->val[2] = std::move(s.val[2]); + this->val[3] = std::move(s.val[3]); + return *this; +} + +template template inline +Scalar_<_Tp>::Scalar_(const Vec<_Tp2, cn>& v) +{ + int i; + for( i = 0; i < (cn < 4 ? cn : 4); i++ ) + this->val[i] = cv::saturate_cast<_Tp>(v.val[i]); + for( ; i < 4; i++ ) + this->val[i] = 0; +} + +template inline +Scalar_<_Tp>::Scalar_(_Tp v0) +{ + this->val[0] = v0; + this->val[1] = this->val[2] = this->val[3] = 0; +} + +template inline +Scalar_<_Tp> Scalar_<_Tp>::all(_Tp v0) +{ + return Scalar_<_Tp>(v0, v0, v0, v0); +} + + +template inline +Scalar_<_Tp> Scalar_<_Tp>::mul(const Scalar_<_Tp>& a, double scale ) const +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(this->val[0] * a.val[0] * scale), + saturate_cast<_Tp>(this->val[1] * a.val[1] * scale), + saturate_cast<_Tp>(this->val[2] * a.val[2] * scale), + saturate_cast<_Tp>(this->val[3] * a.val[3] * scale)); +} + +template inline +Scalar_<_Tp> Scalar_<_Tp>::conj() const +{ + return Scalar_<_Tp>(saturate_cast<_Tp>( this->val[0]), + saturate_cast<_Tp>(-this->val[1]), + saturate_cast<_Tp>(-this->val[2]), + saturate_cast<_Tp>(-this->val[3])); +} + +template inline +bool Scalar_<_Tp>::isReal() const +{ + return this->val[1] == 0 && this->val[2] == 0 && this->val[3] == 0; +} + + +template template inline +Scalar_<_Tp>::operator Scalar_() const +{ + return Scalar_(saturate_cast(this->val[0]), + saturate_cast(this->val[1]), + saturate_cast(this->val[2]), + saturate_cast(this->val[3])); +} + + +template static inline +Scalar_<_Tp>& operator += (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a.val[0] += b.val[0]; + a.val[1] += b.val[1]; + a.val[2] += b.val[2]; + a.val[3] += b.val[3]; + return a; +} + +template static inline +Scalar_<_Tp>& operator -= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a.val[0] -= b.val[0]; + a.val[1] -= b.val[1]; + a.val[2] -= b.val[2]; + a.val[3] -= b.val[3]; + return a; +} + +template static inline +Scalar_<_Tp>& operator *= ( Scalar_<_Tp>& a, _Tp v ) +{ + a.val[0] *= v; + a.val[1] *= v; + a.val[2] *= v; + a.val[3] *= v; + return a; +} + +template static inline +bool operator == ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b ) +{ + return a.val[0] == b.val[0] && a.val[1] == b.val[1] && + a.val[2] == b.val[2] && a.val[3] == b.val[3]; +} + +template static inline +bool operator != ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b ) +{ + return a.val[0] != b.val[0] || a.val[1] != b.val[1] || + a.val[2] != b.val[2] || a.val[3] != b.val[3]; +} + +template static inline +Scalar_<_Tp> operator + (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return Scalar_<_Tp>(a.val[0] + b.val[0], + a.val[1] + b.val[1], + a.val[2] + b.val[2], + a.val[3] + b.val[3]); +} + +template static inline +Scalar_<_Tp> operator - (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]), + saturate_cast<_Tp>(a.val[1] - b.val[1]), + saturate_cast<_Tp>(a.val[2] - b.val[2]), + saturate_cast<_Tp>(a.val[3] - b.val[3])); +} + +template static inline +Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, _Tp alpha) +{ + return Scalar_<_Tp>(a.val[0] * alpha, + a.val[1] * alpha, + a.val[2] * alpha, + a.val[3] * alpha); +} + +template static inline +Scalar_<_Tp> operator * (_Tp alpha, const Scalar_<_Tp>& a) +{ + return a*alpha; +} + +template static inline +Scalar_<_Tp> operator - (const Scalar_<_Tp>& a) +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(-a.val[0]), + saturate_cast<_Tp>(-a.val[1]), + saturate_cast<_Tp>(-a.val[2]), + saturate_cast<_Tp>(-a.val[3])); +} + + +template static inline +Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]), + saturate_cast<_Tp>(a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]), + saturate_cast<_Tp>(a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]), + saturate_cast<_Tp>(a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0])); +} + +template static inline +Scalar_<_Tp>& operator *= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a = a * b; + return a; +} + +template static inline +Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, _Tp alpha) +{ + return Scalar_<_Tp>(a.val[0] / alpha, + a.val[1] / alpha, + a.val[2] / alpha, + a.val[3] / alpha); +} + +template static inline +Scalar_ operator / (const Scalar_& a, float alpha) +{ + float s = 1 / alpha; + return Scalar_(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s); +} + +template static inline +Scalar_ operator / (const Scalar_& a, double alpha) +{ + double s = 1 / alpha; + return Scalar_(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s); +} + +template static inline +Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, _Tp alpha) +{ + a = a / alpha; + return a; +} + +template static inline +Scalar_<_Tp> operator / (_Tp a, const Scalar_<_Tp>& b) +{ + _Tp s = a / (b[0]*b[0] + b[1]*b[1] + b[2]*b[2] + b[3]*b[3]); + return b.conj() * s; +} + +template static inline +Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return a * ((_Tp)1 / b); +} + +template static inline +Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a = a / b; + return a; +} + +template static inline +Scalar operator * (const Matx<_Tp, 4, 4>& a, const Scalar& b) +{ + Matx c((Matx)a, b, Matx_MatMulOp()); + return reinterpret_cast(c); +} + +template<> inline +Scalar operator * (const Matx& a, const Scalar& b) +{ + Matx c(a, b, Matx_MatMulOp()); + return reinterpret_cast(c); +} + + + +//////////////////////////////// KeyPoint /////////////////////////////// + +inline +KeyPoint::KeyPoint() + : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {} + +inline +KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle, float _response, int _octave, int _class_id) + : pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} + +inline +KeyPoint::KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) + : pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} + + + +///////////////////////////////// DMatch //////////////////////////////// + +inline +DMatch::DMatch() + : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {} + +inline +DMatch::DMatch(int _queryIdx, int _trainIdx, float _distance) + : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), distance(_distance) {} + +inline +DMatch::DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) + : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), distance(_distance) {} + +inline +bool DMatch::operator < (const DMatch &m) const +{ + return distance < m.distance; +} + + + +////////////////////////////// TermCriteria ///////////////////////////// + +inline +TermCriteria::TermCriteria() + : type(0), maxCount(0), epsilon(0) {} + +inline +TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon) + : type(_type), maxCount(_maxCount), epsilon(_epsilon) {} + +//! @endcond + +} // cv + +#endif //OPENCV_CORE_TYPES_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/types_c.h b/Cigarette/OpenCV455Simple/include/opencv2/core/types_c.h new file mode 100644 index 0000000..32f3c8c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/types_c.h @@ -0,0 +1,2126 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_TYPES_H +#define OPENCV_CORE_TYPES_H + +#ifdef CV__ENABLE_C_API_CTORS // invalid C API ctors (must be removed) +#if defined(_WIN32) && !defined(CV__SKIP_MESSAGE_MALFORMED_C_API_CTORS) +#error "C API ctors don't work on Win32: https://github.com/opencv/opencv/issues/15990" +#endif +#endif + +//#define CV__VALIDATE_UNUNITIALIZED_VARS 1 // C++11 & GCC only + +#ifdef __cplusplus + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#define CV_STRUCT_INITIALIZER {0,} +#else +#if defined(__GNUC__) && __GNUC__ == 4 // GCC 4.x warns on "= {}" initialization, fixed in GCC 5.0 +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif +#define CV_STRUCT_INITIALIZER {} +#endif + +#else +#define CV_STRUCT_INITIALIZER {0} +#endif + + +#ifdef HAVE_IPL +# ifndef __IPL_H__ +# if defined _WIN32 +# include +# else +# include +# endif +# endif +#elif defined __IPL_H__ +# define HAVE_IPL +#endif + +#include "opencv2/core/cvdef.h" + +#ifndef SKIP_INCLUDES +#include +#include +#include +#include +#endif // SKIP_INCLUDES + +#if defined _WIN32 +# define CV_CDECL __cdecl +# define CV_STDCALL __stdcall +#else +# define CV_CDECL +# define CV_STDCALL +#endif + +#ifndef CV_DEFAULT +# ifdef __cplusplus +# define CV_DEFAULT(val) = val +# else +# define CV_DEFAULT(val) +# endif +#endif + +#ifndef CV_EXTERN_C_FUNCPTR +# ifdef __cplusplus +# define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } +# else +# define CV_EXTERN_C_FUNCPTR(x) typedef x +# endif +#endif + +#ifndef CVAPI +# define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL +#endif + +#ifndef CV_IMPL +# define CV_IMPL CV_EXTERN_C +#endif + +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif + +/** @addtogroup core_c + @{ +*/ + +/** @brief This is the "metatype" used *only* as a function parameter. + +It denotes that the function accepts arrays of multiple types, such as IplImage*, CvMat* or even +CvSeq* sometimes. The particular array type is determined at runtime by analyzing the first 4 +bytes of the header. In C++ interface the role of CvArr is played by InputArray and OutputArray. + */ +typedef void CvArr; + +typedef int CVStatus; + +/** @see cv::Error::Code */ +enum { + CV_StsOk= 0, /**< everything is ok */ + CV_StsBackTrace= -1, /**< pseudo error for back trace */ + CV_StsError= -2, /**< unknown /unspecified error */ + CV_StsInternal= -3, /**< internal error (bad state) */ + CV_StsNoMem= -4, /**< insufficient memory */ + CV_StsBadArg= -5, /**< function arg/param is bad */ + CV_StsBadFunc= -6, /**< unsupported function */ + CV_StsNoConv= -7, /**< iter. didn't converge */ + CV_StsAutoTrace= -8, /**< tracing */ + CV_HeaderIsNull= -9, /**< image header is NULL */ + CV_BadImageSize= -10, /**< image size is invalid */ + CV_BadOffset= -11, /**< offset is invalid */ + CV_BadDataPtr= -12, /**/ + CV_BadStep= -13, /**< image step is wrong, this may happen for a non-continuous matrix */ + CV_BadModelOrChSeq= -14, /**/ + CV_BadNumChannels= -15, /**< bad number of channels, for example, some functions accept only single channel matrices */ + CV_BadNumChannel1U= -16, /**/ + CV_BadDepth= -17, /**< input image depth is not supported by the function */ + CV_BadAlphaChannel= -18, /**/ + CV_BadOrder= -19, /**< number of dimensions is out of range */ + CV_BadOrigin= -20, /**< incorrect input origin */ + CV_BadAlign= -21, /**< incorrect input align */ + CV_BadCallBack= -22, /**/ + CV_BadTileSize= -23, /**/ + CV_BadCOI= -24, /**< input COI is not supported */ + CV_BadROISize= -25, /**< incorrect input roi */ + CV_MaskIsTiled= -26, /**/ + CV_StsNullPtr= -27, /**< null pointer */ + CV_StsVecLengthErr= -28, /**< incorrect vector length */ + CV_StsFilterStructContentErr= -29, /**< incorrect filter structure content */ + CV_StsKernelStructContentErr= -30, /**< incorrect transform kernel content */ + CV_StsFilterOffsetErr= -31, /**< incorrect filter offset value */ + CV_StsBadSize= -201, /**< the input/output structure size is incorrect */ + CV_StsDivByZero= -202, /**< division by zero */ + CV_StsInplaceNotSupported= -203, /**< in-place operation is not supported */ + CV_StsObjectNotFound= -204, /**< request can't be completed */ + CV_StsUnmatchedFormats= -205, /**< formats of input/output arrays differ */ + CV_StsBadFlag= -206, /**< flag is wrong or not supported */ + CV_StsBadPoint= -207, /**< bad CvPoint */ + CV_StsBadMask= -208, /**< bad format of mask (neither 8uC1 nor 8sC1)*/ + CV_StsUnmatchedSizes= -209, /**< sizes of input/output structures do not match */ + CV_StsUnsupportedFormat= -210, /**< the data format/type is not supported by the function*/ + CV_StsOutOfRange= -211, /**< some of parameters are out of range */ + CV_StsParseError= -212, /**< invalid syntax/structure of the parsed file */ + CV_StsNotImplemented= -213, /**< the requested function/feature is not implemented */ + CV_StsBadMemBlock= -214, /**< an allocated block has been corrupted */ + CV_StsAssert= -215, /**< assertion failed */ + CV_GpuNotSupported= -216, /**< no CUDA support */ + CV_GpuApiCallError= -217, /**< GPU API call error */ + CV_OpenGlNotSupported= -218, /**< no OpenGL support */ + CV_OpenGlApiCallError= -219, /**< OpenGL API call error */ + CV_OpenCLApiCallError= -220, /**< OpenCL API call error */ + CV_OpenCLDoubleNotSupported= -221, + CV_OpenCLInitError= -222, /**< OpenCL initialization error */ + CV_OpenCLNoAMDBlasFft= -223 +}; + +/****************************************************************************************\ +* Common macros and inline functions * +\****************************************************************************************/ + +#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t)) + +/** min & max without jumps */ +#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1))) + +#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1))) + +/** absolute value without jumps */ +#ifndef __cplusplus +# define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0)) +#else +# define CV_IABS(a) abs(a) +#endif +#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b))) +#define CV_SIGN(a) CV_CMP((a),0) + +#define cvInvSqrt(value) ((float)(1./sqrt(value))) +#define cvSqrt(value) ((float)sqrt(value)) + + +/*************** Random number generation *******************/ + +typedef uint64 CvRNG; + +#define CV_RNG_COEFF 4164903690U + +/** @brief Initializes a random number generator state. + +The function initializes a random number generator and returns the state. The pointer to the state +can be then passed to the cvRandInt, cvRandReal and cvRandArr functions. In the current +implementation a multiply-with-carry generator is used. +@param seed 64-bit value used to initiate a random sequence +@sa the C++ class RNG replaced CvRNG. + */ +CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1)) +{ + CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1; + return rng; +} + +/** @brief Returns a 32-bit unsigned integer and updates RNG. + +The function returns a uniformly-distributed random 32-bit unsigned integer and updates the RNG +state. It is similar to the rand() function from the C runtime library, except that OpenCV functions +always generates a 32-bit random number, regardless of the platform. +@param rng CvRNG state initialized by cvRNG. + */ +CV_INLINE unsigned cvRandInt( CvRNG* rng ) +{ + uint64 temp = *rng; + temp = (uint64)(unsigned)temp*CV_RNG_COEFF + (temp >> 32); + *rng = temp; + return (unsigned)temp; +} + +/** @brief Returns a floating-point random number and updates RNG. + +The function returns a uniformly-distributed random floating-point number between 0 and 1 (1 is not +included). +@param rng RNG state initialized by cvRNG + */ +CV_INLINE double cvRandReal( CvRNG* rng ) +{ + return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */; +} + +/****************************************************************************************\ +* Image type (IplImage) * +\****************************************************************************************/ + +#ifndef HAVE_IPL + +/* + * The following definitions (until #endif) + * is an extract from IPL headers. + * Copyright (c) 1995 Intel Corporation. + */ +#define IPL_DEPTH_SIGN 0x80000000 + +#define IPL_DEPTH_1U 1 +#define IPL_DEPTH_8U 8 +#define IPL_DEPTH_16U 16 +#define IPL_DEPTH_32F 32 + +#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8) +#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16) +#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32) + +#define IPL_DATA_ORDER_PIXEL 0 +#define IPL_DATA_ORDER_PLANE 1 + +#define IPL_ORIGIN_TL 0 +#define IPL_ORIGIN_BL 1 + +#define IPL_ALIGN_4BYTES 4 +#define IPL_ALIGN_8BYTES 8 +#define IPL_ALIGN_16BYTES 16 +#define IPL_ALIGN_32BYTES 32 + +#define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES +#define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES + +#define IPL_BORDER_CONSTANT 0 +#define IPL_BORDER_REPLICATE 1 +#define IPL_BORDER_REFLECT 2 +#define IPL_BORDER_WRAP 3 + +#ifdef __cplusplus +typedef struct _IplImage IplImage; +CV_EXPORTS _IplImage cvIplImage(const cv::Mat& m); +#endif + +/** The IplImage is taken from the Intel Image Processing Library, in which the format is native. OpenCV +only supports a subset of possible IplImage formats, as outlined in the parameter list above. + +In addition to the above restrictions, OpenCV handles ROIs differently. OpenCV functions require +that the image size or ROI size of all source and destination images match exactly. On the other +hand, the Intel Image Processing Library processes the area of intersection between the source and +destination images (or ROIs), allowing them to vary independently. +*/ +typedef struct +_IplImage +{ + int nSize; /**< sizeof(IplImage) */ + int ID; /**< version (=0)*/ + int nChannels; /**< Most of OpenCV functions support 1,2,3 or 4 channels */ + int alphaChannel; /**< Ignored by OpenCV */ + int depth; /**< Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, + IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported. */ + char colorModel[4]; /**< Ignored by OpenCV */ + char channelSeq[4]; /**< ditto */ + int dataOrder; /**< 0 - interleaved color channels, 1 - separate color channels. + cvCreateImage can only create interleaved images */ + int origin; /**< 0 - top-left origin, + 1 - bottom-left origin (Windows bitmaps style). */ + int align; /**< Alignment of image rows (4 or 8). + OpenCV ignores it and uses widthStep instead. */ + int width; /**< Image width in pixels. */ + int height; /**< Image height in pixels. */ + struct _IplROI *roi; /**< Image ROI. If NULL, the whole image is selected. */ + struct _IplImage *maskROI; /**< Must be NULL. */ + void *imageId; /**< " " */ + struct _IplTileInfo *tileInfo; /**< " " */ + int imageSize; /**< Image data size in bytes + (==image->height*image->widthStep + in case of interleaved data)*/ + char *imageData; /**< Pointer to aligned image data. */ + int widthStep; /**< Size of aligned image row in bytes. */ + int BorderMode[4]; /**< Ignored by OpenCV. */ + int BorderConst[4]; /**< Ditto. */ + char *imageDataOrigin; /**< Pointer to very origin of image data + (not necessarily aligned) - + needed for correct deallocation */ + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + _IplImage() + { + memset(this, 0, sizeof(*this)); // valid for POD structure + nSize = sizeof(IplImage); + } + _IplImage(const cv::Mat& m) { *this = cvIplImage(m); } +#endif +} +IplImage; + +CV_INLINE IplImage cvIplImage() +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + IplImage self = CV_STRUCT_INITIALIZER; self.nSize = sizeof(IplImage); return self; +#else + return _IplImage(); +#endif +} + +typedef struct _IplTileInfo IplTileInfo; + +typedef struct _IplROI +{ + int coi; /**< 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/ + int xOffset; + int yOffset; + int width; + int height; +} +IplROI; + +typedef struct _IplConvKernel +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + int *values; + int nShiftR; +} +IplConvKernel; + +typedef struct _IplConvKernelFP +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + float *values; +} +IplConvKernelFP; + +#define IPL_IMAGE_HEADER 1 +#define IPL_IMAGE_DATA 2 +#define IPL_IMAGE_ROI 4 + +#endif/*HAVE_IPL*/ + +/** extra border mode */ +#define IPL_BORDER_REFLECT_101 4 +#define IPL_BORDER_TRANSPARENT 5 + +#define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage)) +#define CV_TYPE_NAME_IMAGE "opencv-image" + +#define CV_IS_IMAGE_HDR(img) \ + ((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage)) + +#define CV_IS_IMAGE(img) \ + (CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->imageData != NULL) + +/** for storing double-precision + floating point data in IplImage's */ +#define IPL_DEPTH_64F 64 + +/** get reference to pixel at (col,row), + for multi-channel images (col) should be multiplied by number of channels */ +#define CV_IMAGE_ELEM( image, elemtype, row, col ) \ + (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)]) + +/****************************************************************************************\ +* Matrix type (CvMat) * +\****************************************************************************************/ + +#define CV_AUTO_STEP 0x7fffffff +#define CV_WHOLE_ARR cvSlice( 0, 0x3fffffff ) + +#define CV_MAGIC_MASK 0xFFFF0000 +#define CV_MAT_MAGIC_VAL 0x42420000 +#define CV_TYPE_NAME_MAT "opencv-matrix" + +#ifdef __cplusplus +typedef struct CvMat CvMat; +CV_INLINE CvMat cvMat(const cv::Mat& m); +#endif + +/** Matrix elements are stored row by row. Element (i, j) (i - 0-based row index, j - 0-based column +index) of a matrix can be retrieved or modified using CV_MAT_ELEM macro: + + uchar pixval = CV_MAT_ELEM(grayimg, uchar, i, j) + CV_MAT_ELEM(cameraMatrix, float, 0, 2) = image.width*0.5f; + +To access multiple-channel matrices, you can use +CV_MAT_ELEM(matrix, type, i, j\*nchannels + channel_idx). + +@deprecated CvMat is now obsolete; consider using Mat instead. + */ +typedef struct CvMat +{ + int type; + int step; + + /* for internal use only */ + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + short* s; + int* i; + float* fl; + double* db; + } data; + +#ifdef __cplusplus + union + { + int rows; + int height; + }; + + union + { + int cols; + int width; + }; +#else + int rows; + int cols; +#endif + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvMat() {} + CvMat(const cv::Mat& m) { *this = cvMat(m); } +#endif +} +CvMat; + + +#define CV_IS_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ + ((const CvMat*)(mat))->cols > 0 && ((const CvMat*)(mat))->rows > 0) + +#define CV_IS_MAT_HDR_Z(mat) \ + ((mat) != NULL && \ + (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ + ((const CvMat*)(mat))->cols >= 0 && ((const CvMat*)(mat))->rows >= 0) + +#define CV_IS_MAT(mat) \ + (CV_IS_MAT_HDR(mat) && ((const CvMat*)(mat))->data.ptr != NULL) + +#define CV_IS_MASK_ARR(mat) \ + (((mat)->type & (CV_MAT_TYPE_MASK & ~CV_8SC1)) == 0) + +#define CV_ARE_TYPES_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_TYPE_MASK) == 0) + +#define CV_ARE_CNS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_CN_MASK) == 0) + +#define CV_ARE_DEPTHS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_DEPTH_MASK) == 0) + +#define CV_ARE_SIZES_EQ(mat1, mat2) \ + ((mat1)->rows == (mat2)->rows && (mat1)->cols == (mat2)->cols) + +#define CV_IS_MAT_CONST(mat) \ + (((mat)->rows|(mat)->cols) == 1) + +#define IPL2CV_DEPTH(depth) \ + ((((CV_8U)+(CV_16U<<4)+(CV_32F<<8)+(CV_64F<<16)+(CV_8S<<20)+ \ + (CV_16S<<24)+(CV_32S<<28)) >> ((((depth) & 0xF0) >> 2) + \ + (((depth) & IPL_DEPTH_SIGN) ? 20 : 0))) & 15) + +/** Inline constructor. No data is allocated internally!!! + * (Use together with cvCreateData, or use cvCreateMat instead to + * get a matrix with allocated data): + */ +CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)) +{ + CvMat m; + + assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); + type = CV_MAT_TYPE(type); + m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; + m.cols = cols; + m.rows = rows; + m.step = m.cols*CV_ELEM_SIZE(type); + m.data.ptr = (uchar*)data; + m.refcount = NULL; + m.hdr_refcount = 0; + + return m; +} + +#ifdef __cplusplus + +CV_INLINE CvMat cvMat(const cv::Mat& m) +{ + CvMat self; + CV_DbgAssert(m.dims <= 2); + self = cvMat(m.rows, m.dims == 1 ? 1 : m.cols, m.type(), m.data); + self.step = (int)m.step[0]; + self.type = (self.type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG); + return self; +} +CV_INLINE CvMat cvMat() +{ +#if !defined(CV__ENABLE_C_API_CTORS) + CvMat self = CV_STRUCT_INITIALIZER; return self; +#else + return CvMat(); +#endif +} +CV_INLINE CvMat cvMat(const CvMat& m) +{ +#if !defined(CV__ENABLE_C_API_CTORS) + CvMat self = CV_STRUCT_INITIALIZER; memcpy(&self, &m, sizeof(self)); return self; +#else + return CvMat(m); +#endif +} + +#endif // __cplusplus + + +#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \ + (assert( (unsigned)(row) < (unsigned)(mat).rows && \ + (unsigned)(col) < (unsigned)(mat).cols ), \ + (mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col)) + +#define CV_MAT_ELEM_PTR( mat, row, col ) \ + CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) ) + +#define CV_MAT_ELEM( mat, elemtype, row, col ) \ + (*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype))) + +/** @brief Returns the particular element of single-channel floating-point matrix. + +The function is a fast replacement for cvGetReal2D in the case of single-channel floating-point +matrices. It is faster because it is inline, it does fewer checks for array type and array element +type, and it checks for the row and column ranges only in debug mode. +@param mat Input matrix +@param row The zero-based index of row +@param col The zero-based index of column + */ +CV_INLINE double cvmGet( const CvMat* mat, int row, int col ) +{ + int type; + + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + return ((float*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col]; + else + { + assert( type == CV_64FC1 ); + return ((double*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col]; + } +} + +/** @brief Sets a specific element of a single-channel floating-point matrix. + +The function is a fast replacement for cvSetReal2D in the case of single-channel floating-point +matrices. It is faster because it is inline, it does fewer checks for array type and array element +type, and it checks for the row and column ranges only in debug mode. +@param mat The matrix +@param row The zero-based index of row +@param col The zero-based index of column +@param value The new value of the matrix element + */ +CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) +{ + int type; + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + ((float*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value; + else + { + assert( type == CV_64FC1 ); + ((double*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col] = value; + } +} + + +CV_INLINE int cvIplDepth( int type ) +{ + int depth = CV_MAT_DEPTH(type); + return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || + depth == CV_32S ? IPL_DEPTH_SIGN : 0); +} + + +/****************************************************************************************\ +* Multi-dimensional dense array (CvMatND) * +\****************************************************************************************/ + +#define CV_MATND_MAGIC_VAL 0x42430000 +#define CV_TYPE_NAME_MATND "opencv-nd-matrix" + +#define CV_MAX_DIM 32 + +#ifdef __cplusplus +typedef struct CvMatND CvMatND; +CV_EXPORTS CvMatND cvMatND(const cv::Mat& m); +#endif + +/** + @deprecated consider using cv::Mat instead + */ +typedef struct +CvMatND +{ + int type; + int dims; + + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + float* fl; + double* db; + int* i; + short* s; + } data; + + struct + { + int size; + int step; + } + dim[CV_MAX_DIM]; + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvMatND() {} + CvMatND(const cv::Mat& m) { *this = cvMatND(m); } +#endif +} +CvMatND; + + +CV_INLINE CvMatND cvMatND() +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvMatND self = CV_STRUCT_INITIALIZER; return self; +#else + return CvMatND(); +#endif +} + +#define CV_IS_MATND_HDR(mat) \ + ((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL) + +#define CV_IS_MATND(mat) \ + (CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL) + + +/****************************************************************************************\ +* Multi-dimensional sparse array (CvSparseMat) * +\****************************************************************************************/ + +#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000 +#define CV_TYPE_NAME_SPARSE_MAT "opencv-sparse-matrix" + +struct CvSet; + +typedef struct CvSparseMat +{ + int type; + int dims; + int* refcount; + int hdr_refcount; + + struct CvSet* heap; + void** hashtable; + int hashsize; + int valoffset; + int idxoffset; + int size[CV_MAX_DIM]; + +#ifdef __cplusplus + CV_EXPORTS void copyToSparseMat(cv::SparseMat& m) const; +#endif +} +CvSparseMat; + +#ifdef __cplusplus +CV_EXPORTS CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m); +#endif + +#define CV_IS_SPARSE_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL) + +#define CV_IS_SPARSE_MAT(mat) \ + CV_IS_SPARSE_MAT_HDR(mat) + +/**************** iteration through a sparse array *****************/ + +typedef struct CvSparseNode +{ + unsigned hashval; + struct CvSparseNode* next; +} +CvSparseNode; + +typedef struct CvSparseMatIterator +{ + CvSparseMat* mat; + CvSparseNode* node; + int curidx; +} +CvSparseMatIterator; + +#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset)) +#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset)) + +/****************************************************************************************\ +* Histogram * +\****************************************************************************************/ + +typedef int CvHistType; + +#define CV_HIST_MAGIC_VAL 0x42450000 +#define CV_HIST_UNIFORM_FLAG (1 << 10) + +/** indicates whether bin ranges are set already or not */ +#define CV_HIST_RANGES_FLAG (1 << 11) + +#define CV_HIST_ARRAY 0 +#define CV_HIST_SPARSE 1 +#define CV_HIST_TREE CV_HIST_SPARSE + +/** should be used as a parameter only, + it turns to CV_HIST_UNIFORM_FLAG of hist->type */ +#define CV_HIST_UNIFORM 1 + +typedef struct CvHistogram +{ + int type; + CvArr* bins; + float thresh[CV_MAX_DIM][2]; /**< For uniform histograms. */ + float** thresh2; /**< For non-uniform histograms. */ + CvMatND mat; /**< Embedded matrix header for array histograms. */ +} +CvHistogram; + +#define CV_IS_HIST( hist ) \ + ((hist) != NULL && \ + (((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \ + (hist)->bins != NULL) + +#define CV_IS_UNIFORM_HIST( hist ) \ + (((hist)->type & CV_HIST_UNIFORM_FLAG) != 0) + +#define CV_IS_SPARSE_HIST( hist ) \ + CV_IS_SPARSE_MAT((hist)->bins) + +#define CV_HIST_HAS_RANGES( hist ) \ + (((hist)->type & CV_HIST_RANGES_FLAG) != 0) + +/****************************************************************************************\ +* Other supplementary data type definitions * +\****************************************************************************************/ + +/*************************************** CvRect *****************************************/ +/** @sa Rect_ */ +typedef struct CvRect +{ + int x; + int y; + int width; + int height; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvRect() __attribute__(( warning("Non-initialized variable") )) {}; + template CvRect(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 4); + x = y = width = height = 0; + if (list.size() == 4) + { + x = list.begin()[0]; y = list.begin()[1]; width = list.begin()[2]; height = list.begin()[3]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvRect(int _x = 0, int _y = 0, int w = 0, int h = 0): x(_x), y(_y), width(w), height(h) {} + template + CvRect(const cv::Rect_<_Tp>& r): x(cv::saturate_cast(r.x)), y(cv::saturate_cast(r.y)), width(cv::saturate_cast(r.width)), height(cv::saturate_cast(r.height)) {} +#endif +#ifdef __cplusplus + template + operator cv::Rect_<_Tp>() const { return cv::Rect_<_Tp>((_Tp)x, (_Tp)y, (_Tp)width, (_Tp)height); } +#endif +} +CvRect; + +/** constructs CvRect structure. */ +CV_INLINE CvRect cvRect( int x, int y, int width, int height ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvRect r = {x, y, width, height}; +#else + CvRect r(x, y , width, height); +#endif + return r; +} +#ifdef __cplusplus +CV_INLINE CvRect cvRect(const cv::Rect& rc) { return cvRect(rc.x, rc.y, rc.width, rc.height); } +#endif + +CV_INLINE IplROI cvRectToROI( CvRect rect, int coi ) +{ + IplROI roi; + roi.xOffset = rect.x; + roi.yOffset = rect.y; + roi.width = rect.width; + roi.height = rect.height; + roi.coi = coi; + + return roi; +} + + +CV_INLINE CvRect cvROIToRect( IplROI roi ) +{ + return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height ); +} + +/*********************************** CvTermCriteria *************************************/ + +#define CV_TERMCRIT_ITER 1 +#define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER +#define CV_TERMCRIT_EPS 2 + +/** @sa TermCriteria + */ +typedef struct CvTermCriteria +{ + int type; /**< may be combination of + CV_TERMCRIT_ITER + CV_TERMCRIT_EPS */ + int max_iter; + double epsilon; +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvTermCriteria(int _type = 0, int _iter = 0, double _eps = 0) : type(_type), max_iter(_iter), epsilon(_eps) {} + CvTermCriteria(const cv::TermCriteria& t) : type(t.type), max_iter(t.maxCount), epsilon(t.epsilon) {} +#endif +#ifdef __cplusplus + operator cv::TermCriteria() const { return cv::TermCriteria(type, max_iter, epsilon); } +#endif +} +CvTermCriteria; + +CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvTermCriteria t = { type, max_iter, (float)epsilon}; +#else + CvTermCriteria t(type, max_iter, epsilon); +#endif + return t; +} +#ifdef __cplusplus +CV_INLINE CvTermCriteria cvTermCriteria(const cv::TermCriteria& t) { return cvTermCriteria(t.type, t.maxCount, t.epsilon); } +#endif + + +/******************************* CvPoint and variants ***********************************/ + +typedef struct CvPoint +{ + int x; + int y; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + x = y = 0; + if (list.size() == 2) + { + x = list.begin()[0]; y = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvPoint(int _x = 0, int _y = 0): x(_x), y(_y) {} + template + CvPoint(const cv::Point_<_Tp>& pt): x((int)pt.x), y((int)pt.y) {} +#endif +#ifdef __cplusplus + template + operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); } +#endif +} +CvPoint; + +/** constructs CvPoint structure. */ +CV_INLINE CvPoint cvPoint( int x, int y ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint p = {x, y}; +#else + CvPoint p(x, y); +#endif + return p; +} +#ifdef __cplusplus +CV_INLINE CvPoint cvPoint(const cv::Point& pt) { return cvPoint(pt.x, pt.y); } +#endif + +typedef struct CvPoint2D32f +{ + float x; + float y; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint2D32f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint2D32f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + x = y = 0; + if (list.size() == 2) + { + x = list.begin()[0]; y = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvPoint2D32f(float _x = 0, float _y = 0): x(_x), y(_y) {} + template + CvPoint2D32f(const cv::Point_<_Tp>& pt): x((float)pt.x), y((float)pt.y) {} +#endif +#ifdef __cplusplus + template + operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); } +#endif +} +CvPoint2D32f; + +/** constructs CvPoint2D32f structure. */ +CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint2D32f p = { (float)x, (float)y }; +#else + CvPoint2D32f p((float)x, (float)y); +#endif + return p; +} + +#ifdef __cplusplus +template +CvPoint2D32f cvPoint2D32f(const cv::Point_<_Tp>& pt) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint2D32f p = { (float)pt.x, (float)pt.y }; +#else + CvPoint2D32f p((float)pt.x, (float)pt.y); +#endif + return p; +} +#endif + +/** converts CvPoint to CvPoint2D32f. */ +CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point ) +{ + return cvPoint2D32f( (float)point.x, (float)point.y ); +} + +/** converts CvPoint2D32f to CvPoint. */ +CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint ipt = { cvRound(point.x), cvRound(point.y) }; +#else + CvPoint ipt(cvRound(point.x), cvRound(point.y)); +#endif + return ipt; +} + + +typedef struct CvPoint3D32f +{ + float x; + float y; + float z; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint3D32f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint3D32f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 3); + x = y = z = 0; + if (list.size() == 3) + { + x = list.begin()[0]; y = list.begin()[1]; z = list.begin()[2]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvPoint3D32f(float _x = 0, float _y = 0, float _z = 0): x(_x), y(_y), z(_z) {} + template + CvPoint3D32f(const cv::Point3_<_Tp>& pt): x((float)pt.x), y((float)pt.y), z((float)pt.z) {} +#endif +#ifdef __cplusplus + template + operator cv::Point3_<_Tp>() const { return cv::Point3_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y), cv::saturate_cast<_Tp>(z)); } +#endif +} +CvPoint3D32f; + +/** constructs CvPoint3D32f structure. */ +CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint3D32f p = { (float)x, (float)y, (float)z }; +#else + CvPoint3D32f p((float)x, (float)y, (float)z); +#endif + return p; +} + +#ifdef __cplusplus +template +CvPoint3D32f cvPoint3D32f(const cv::Point3_<_Tp>& pt) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint3D32f p = { (float)pt.x, (float)pt.y, (float)pt.z }; +#else + CvPoint3D32f p((float)pt.x, (float)pt.y, (float)pt.z); +#endif + return p; +} +#endif + + +typedef struct CvPoint2D64f +{ + double x; + double y; +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint2D64f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint2D64f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + x = y = 0; + if (list.size() == 2) + { + x = list.begin()[0]; y = list.begin()[1]; + } + }; +#endif +} +CvPoint2D64f; + +/** constructs CvPoint2D64f structure.*/ +CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y ) +{ + CvPoint2D64f p = { x, y }; + return p; +} + + +typedef struct CvPoint3D64f +{ + double x; + double y; + double z; +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint3D64f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint3D64f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 3); + x = y = z = 0; + if (list.size() == 3) + { + x = list.begin()[0]; y = list.begin()[1]; z = list.begin()[2]; + } + }; +#endif +} +CvPoint3D64f; + +/** constructs CvPoint3D64f structure. */ +CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z ) +{ + CvPoint3D64f p = { x, y, z }; + return p; +} + + +/******************************** CvSize's & CvBox **************************************/ + +typedef struct CvSize +{ + int width; + int height; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvSize() __attribute__(( warning("Non-initialized variable") )) {} + template CvSize(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + width = 0; height = 0; + if (list.size() == 2) + { + width = list.begin()[0]; height = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvSize(int w = 0, int h = 0): width(w), height(h) {} + template + CvSize(const cv::Size_<_Tp>& sz): width(cv::saturate_cast(sz.width)), height(cv::saturate_cast(sz.height)) {} +#endif +#ifdef __cplusplus + template + operator cv::Size_<_Tp>() const { return cv::Size_<_Tp>(cv::saturate_cast<_Tp>(width), cv::saturate_cast<_Tp>(height)); } +#endif +} +CvSize; + +/** constructs CvSize structure. */ +CV_INLINE CvSize cvSize( int width, int height ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize s = { width, height }; +#else + CvSize s(width, height); +#endif + return s; +} + +#ifdef __cplusplus +CV_INLINE CvSize cvSize(const cv::Size& sz) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize s = { sz.width, sz.height }; +#else + CvSize s(sz.width, sz.height); +#endif + return s; +} +#endif + +typedef struct CvSize2D32f +{ + float width; + float height; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvSize2D32f() __attribute__(( warning("Non-initialized variable") )) {} + template CvSize2D32f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + width = 0; height = 0; + if (list.size() == 2) + { + width = list.begin()[0]; height = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvSize2D32f(float w = 0, float h = 0): width(w), height(h) {} + template + CvSize2D32f(const cv::Size_<_Tp>& sz): width(cv::saturate_cast(sz.width)), height(cv::saturate_cast(sz.height)) {} +#endif +#ifdef __cplusplus + template + operator cv::Size_<_Tp>() const { return cv::Size_<_Tp>(cv::saturate_cast<_Tp>(width), cv::saturate_cast<_Tp>(height)); } +#endif +} +CvSize2D32f; + +/** constructs CvSize2D32f structure. */ +CV_INLINE CvSize2D32f cvSize2D32f( double width, double height ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize2D32f s = { (float)width, (float)height }; +#else + CvSize2D32f s((float)width, (float)height); +#endif + return s; +} +#ifdef __cplusplus +template +CvSize2D32f cvSize2D32f(const cv::Size_<_Tp>& sz) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize2D32f s = { (float)sz.width, (float)sz.height }; +#else + CvSize2D32f s((float)sz.width, (float)sz.height); +#endif + return s; +} +#endif + +/** @sa RotatedRect + */ +typedef struct CvBox2D +{ + CvPoint2D32f center; /**< Center of the box. */ + CvSize2D32f size; /**< Box width and length. */ + float angle; /**< Angle between the horizontal axis */ + /**< and the first side (i.e. length) in degrees */ + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) : center(c), size(s), angle(a) {} + CvBox2D(const cv::RotatedRect& rr) : center(rr.center), size(rr.size), angle(rr.angle) {} +#endif +#ifdef __cplusplus + operator cv::RotatedRect() const { return cv::RotatedRect(center, size, angle); } +#endif +} +CvBox2D; + + +#ifdef __cplusplus +CV_INLINE CvBox2D cvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) +{ + CvBox2D self; + self.center = c; + self.size = s; + self.angle = a; + return self; +} +CV_INLINE CvBox2D cvBox2D(const cv::RotatedRect& rr) +{ + CvBox2D self; + self.center = cvPoint2D32f(rr.center); + self.size = cvSize2D32f(rr.size); + self.angle = rr.angle; + return self; +} +#endif + + +/** Line iterator state: */ +typedef struct CvLineIterator +{ + /** Pointer to the current point: */ + uchar* ptr; + + /* Bresenham algorithm state: */ + int err; + int plus_delta; + int minus_delta; + int plus_step; + int minus_step; +} +CvLineIterator; + + + +/************************************* CvSlice ******************************************/ +#define CV_WHOLE_SEQ_END_INDEX 0x3fffffff +#define CV_WHOLE_SEQ cvSlice(0, CV_WHOLE_SEQ_END_INDEX) + +typedef struct CvSlice +{ + int start_index, end_index; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvSlice() __attribute__(( warning("Non-initialized variable") )) {} + template CvSlice(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + start_index = end_index = 0; + if (list.size() == 2) + { + start_index = list.begin()[0]; end_index = list.begin()[1]; + } + }; +#endif +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) && !defined(__CUDACC__) + CvSlice(int start = 0, int end = 0) : start_index(start), end_index(end) {} + CvSlice(const cv::Range& r) { *this = (r.start != INT_MIN && r.end != INT_MAX) ? CvSlice(r.start, r.end) : CvSlice(0, CV_WHOLE_SEQ_END_INDEX); } + operator cv::Range() const { return (start_index == 0 && end_index == CV_WHOLE_SEQ_END_INDEX ) ? cv::Range::all() : cv::Range(start_index, end_index); } +#endif +} +CvSlice; + +CV_INLINE CvSlice cvSlice( int start, int end ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) && !defined(__CUDACC__)) + CvSlice slice = { start, end }; +#else + CvSlice slice(start, end); +#endif + return slice; +} + +#if defined(__cplusplus) +CV_INLINE CvSlice cvSlice(const cv::Range& r) +{ + CvSlice slice = (r.start != INT_MIN && r.end != INT_MAX) ? cvSlice(r.start, r.end) : cvSlice(0, CV_WHOLE_SEQ_END_INDEX); + return slice; +} +#endif + + +/************************************* CvScalar *****************************************/ +/** @sa Scalar_ + */ +typedef struct CvScalar +{ + double val[4]; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvScalar() __attribute__(( warning("Non-initialized variable") )) {} + CvScalar(const std::initializer_list list) + { + CV_Assert(list.size() == 0 || list.size() == 4); + val[0] = val[1] = val[2] = val[3] = 0; + if (list.size() == 4) + { + val[0] = list.begin()[0]; val[1] = list.begin()[1]; val[2] = list.begin()[2]; val[3] = list.begin()[3]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvScalar() {} + CvScalar(double d0, double d1 = 0, double d2 = 0, double d3 = 0) { val[0] = d0; val[1] = d1; val[2] = d2; val[3] = d3; } + template + CvScalar(const cv::Scalar_<_Tp>& s) { val[0] = s.val[0]; val[1] = s.val[1]; val[2] = s.val[2]; val[3] = s.val[3]; } + template + CvScalar(const cv::Vec<_Tp, cn>& v) + { + int i; + for( i = 0; i < (cn < 4 ? cn : 4); i++ ) val[i] = v.val[i]; + for( ; i < 4; i++ ) val[i] = 0; + } +#endif +#ifdef __cplusplus + template + operator cv::Scalar_<_Tp>() const { return cv::Scalar_<_Tp>(cv::saturate_cast<_Tp>(val[0]), cv::saturate_cast<_Tp>(val[1]), cv::saturate_cast<_Tp>(val[2]), cv::saturate_cast<_Tp>(val[3])); } +#endif +} +CvScalar; + +CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0), + double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0)) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = val0; scalar.val[1] = val1; + scalar.val[2] = val2; scalar.val[3] = val3; + return scalar; +} + +#ifdef __cplusplus +CV_INLINE CvScalar cvScalar() +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; + return scalar; +} +CV_INLINE CvScalar cvScalar(const cv::Scalar& s) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = s.val[0]; + scalar.val[1] = s.val[1]; + scalar.val[2] = s.val[2]; + scalar.val[3] = s.val[3]; + return scalar; +} +#endif + +CV_INLINE CvScalar cvRealScalar( double val0 ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = val0; + scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; + return scalar; +} + +CV_INLINE CvScalar cvScalarAll( double val0123 ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = val0123; + scalar.val[1] = val0123; + scalar.val[2] = val0123; + scalar.val[3] = val0123; + return scalar; +} + +/****************************************************************************************\ +* Dynamic Data structures * +\****************************************************************************************/ + +/******************************** Memory storage ****************************************/ + +typedef struct CvMemBlock +{ + struct CvMemBlock* prev; + struct CvMemBlock* next; +} +CvMemBlock; + +#define CV_STORAGE_MAGIC_VAL 0x42890000 + +typedef struct CvMemStorage +{ + int signature; + CvMemBlock* bottom; /**< First allocated block. */ + CvMemBlock* top; /**< Current memory block - top of the stack. */ + struct CvMemStorage* parent; /**< We get new blocks from parent as needed. */ + int block_size; /**< Block size. */ + int free_space; /**< Remaining free space in current block. */ +} +CvMemStorage; + +#define CV_IS_STORAGE(storage) \ + ((storage) != NULL && \ + (((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) == CV_STORAGE_MAGIC_VAL) + + +typedef struct CvMemStoragePos +{ + CvMemBlock* top; + int free_space; +} +CvMemStoragePos; + + +/*********************************** Sequence *******************************************/ + +typedef struct CvSeqBlock +{ + struct CvSeqBlock* prev; /**< Previous sequence block. */ + struct CvSeqBlock* next; /**< Next sequence block. */ + int start_index; /**< Index of the first element in the block + */ + /**< sequence->first->start_index. */ + int count; /**< Number of elements in the block. */ + schar* data; /**< Pointer to the first element of the block. */ +} +CvSeqBlock; + + +#define CV_TREE_NODE_FIELDS(node_type) \ + int flags; /**< Miscellaneous flags. */ \ + int header_size; /**< Size of sequence header. */ \ + struct node_type* h_prev; /**< Previous sequence. */ \ + struct node_type* h_next; /**< Next sequence. */ \ + struct node_type* v_prev; /**< 2nd previous sequence. */ \ + struct node_type* v_next /**< 2nd next sequence. */ + +/** + Read/Write sequence. + Elements can be dynamically inserted to or deleted from the sequence. +*/ +#define CV_SEQUENCE_FIELDS() \ + CV_TREE_NODE_FIELDS(CvSeq); \ + int total; /**< Total number of elements. */ \ + int elem_size; /**< Size of sequence element in bytes. */ \ + schar* block_max; /**< Maximal bound of the last block. */ \ + schar* ptr; /**< Current write pointer. */ \ + int delta_elems; /**< Grow seq this many at a time. */ \ + CvMemStorage* storage; /**< Where the seq is stored. */ \ + CvSeqBlock* free_blocks; /**< Free blocks list. */ \ + CvSeqBlock* first; /**< Pointer to the first sequence block. */ + +typedef struct CvSeq +{ + CV_SEQUENCE_FIELDS() +} +CvSeq; + +#define CV_TYPE_NAME_SEQ "opencv-sequence" +#define CV_TYPE_NAME_SEQ_TREE "opencv-sequence-tree" + +/*************************************** Set ********************************************/ +/** @brief Set + Order is not preserved. There can be gaps between sequence elements. + After the element has been inserted it stays in the same place all the time. + The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists. +*/ +#define CV_SET_ELEM_FIELDS(elem_type) \ + int flags; \ + struct elem_type* next_free; + +typedef struct CvSetElem +{ + CV_SET_ELEM_FIELDS(CvSetElem) +} +CvSetElem; + +#define CV_SET_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvSetElem* free_elems; \ + int active_count; + +typedef struct CvSet +{ + CV_SET_FIELDS() +} +CvSet; + + +#define CV_SET_ELEM_IDX_MASK ((1 << 26) - 1) +#define CV_SET_ELEM_FREE_FLAG (1 << (sizeof(int)*8-1)) + +/** Checks whether the element pointed by ptr belongs to a set or not */ +#define CV_IS_SET_ELEM( ptr ) (((CvSetElem*)(ptr))->flags >= 0) + +/************************************* Graph ********************************************/ + +/** @name Graph + +We represent a graph as a set of vertices. Vertices contain their adjacency lists (more exactly, +pointers to first incoming or outcoming edge (or 0 if isolated vertex)). Edges are stored in +another set. There is a singly-linked list of incoming/outcoming edges for each vertex. + +Each edge consists of: + +- Two pointers to the starting and ending vertices (vtx[0] and vtx[1] respectively). + + A graph may be oriented or not. In the latter case, edges between vertex i to vertex j are not +distinguished during search operations. + +- Two pointers to next edges for the starting and ending vertices, where next[0] points to the +next edge in the vtx[0] adjacency list and next[1] points to the next edge in the vtx[1] +adjacency list. + +@see CvGraphEdge, CvGraphVtx, CvGraphVtx2D, CvGraph +@{ +*/ +#define CV_GRAPH_EDGE_FIELDS() \ + int flags; \ + float weight; \ + struct CvGraphEdge* next[2]; \ + struct CvGraphVtx* vtx[2]; + + +#define CV_GRAPH_VERTEX_FIELDS() \ + int flags; \ + struct CvGraphEdge* first; + + +typedef struct CvGraphEdge +{ + CV_GRAPH_EDGE_FIELDS() +} +CvGraphEdge; + +typedef struct CvGraphVtx +{ + CV_GRAPH_VERTEX_FIELDS() +} +CvGraphVtx; + +typedef struct CvGraphVtx2D +{ + CV_GRAPH_VERTEX_FIELDS() + CvPoint2D32f* ptr; +} +CvGraphVtx2D; + +/** + Graph is "derived" from the set (this is set a of vertices) + and includes another set (edges) +*/ +#define CV_GRAPH_FIELDS() \ + CV_SET_FIELDS() \ + CvSet* edges; + +typedef struct CvGraph +{ + CV_GRAPH_FIELDS() +} +CvGraph; + +#define CV_TYPE_NAME_GRAPH "opencv-graph" + +/** @} */ + +/*********************************** Chain/Contour *************************************/ + +typedef struct CvChain +{ + CV_SEQUENCE_FIELDS() + CvPoint origin; +} +CvChain; + +#define CV_CONTOUR_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvRect rect; \ + int color; \ + int reserved[3]; + +typedef struct CvContour +{ + CV_CONTOUR_FIELDS() +} +CvContour; + +typedef CvContour CvPoint2DSeq; + +/****************************************************************************************\ +* Sequence types * +\****************************************************************************************/ + +#define CV_SEQ_MAGIC_VAL 0x42990000 + +#define CV_IS_SEQ(seq) \ + ((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL) + +#define CV_SET_MAGIC_VAL 0x42980000 +#define CV_IS_SET(set) \ + ((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL) + +#define CV_SEQ_ELTYPE_BITS 12 +#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1) + +#define CV_SEQ_ELTYPE_POINT CV_32SC2 /**< (x,y) */ +#define CV_SEQ_ELTYPE_CODE CV_8UC1 /**< freeman code: 0..7 */ +#define CV_SEQ_ELTYPE_GENERIC 0 +#define CV_SEQ_ELTYPE_PTR CV_MAKE_TYPE(CV_8U, 8 /*sizeof(void*)*/) +#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /**< &(x,y) */ +#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /**< #(x,y) */ +#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /**< &next_o, &next_d, &vtx_o, &vtx_d */ +#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /**< first_edge, &(x,y) */ +#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /**< vertex of the binary tree */ +#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /**< connected component */ +#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /**< (x,y,z) */ + +#define CV_SEQ_KIND_BITS 2 +#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<flags & CV_SEQ_ELTYPE_MASK) +#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK ) + +/** flag checking */ +#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC)) + +#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE) +#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0) +#define CV_IS_SEQ_CONVEX( seq ) 0 +#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0) +#define CV_IS_SEQ_SIMPLE( seq ) 1 + +/** type checking macros */ +#define CV_IS_SEQ_POINT_SET( seq ) \ + ((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2)) + +#define CV_IS_SEQ_POINT_SUBSET( seq ) \ + (CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT) + +#define CV_IS_SEQ_POLYLINE( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq)) + +#define CV_IS_SEQ_POLYGON( seq ) \ + (CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq)) + +#define CV_IS_SEQ_CHAIN( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1) + +#define CV_IS_SEQ_CONTOUR( seq ) \ + (CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq))) + +#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \ + (CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq )) + +#define CV_IS_SEQ_POLYGON_TREE( seq ) \ + (CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \ + CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE ) + +#define CV_IS_GRAPH( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH) + +#define CV_IS_GRAPH_ORIENTED( seq ) \ + (((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0) + +#define CV_IS_SUBDIV2D( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D) + +/****************************************************************************************/ +/* Sequence writer & reader */ +/****************************************************************************************/ + +#define CV_SEQ_WRITER_FIELDS() \ + int header_size; \ + CvSeq* seq; /**< the sequence written */ \ + CvSeqBlock* block; /**< current block */ \ + schar* ptr; /**< pointer to free space */ \ + schar* block_min; /**< pointer to the beginning of block*/\ + schar* block_max; /**< pointer to the end of block */ + +typedef struct CvSeqWriter +{ + CV_SEQ_WRITER_FIELDS() +} +CvSeqWriter; + + +#define CV_SEQ_READER_FIELDS() \ + int header_size; \ + CvSeq* seq; /**< sequence, beign read */ \ + CvSeqBlock* block; /**< current block */ \ + schar* ptr; /**< pointer to element be read next */ \ + schar* block_min; /**< pointer to the beginning of block */\ + schar* block_max; /**< pointer to the end of block */ \ + int delta_index;/**< = seq->first->start_index */ \ + schar* prev_elem; /**< pointer to previous element */ + +typedef struct CvSeqReader +{ + CV_SEQ_READER_FIELDS() +} +CvSeqReader; + +/****************************************************************************************/ +/* Operations on sequences */ +/****************************************************************************************/ + +#define CV_SEQ_ELEM( seq, elem_type, index ) \ +/** assert gives some guarantee that parameter is valid */ \ +( assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && \ + (seq)->elem_size == sizeof(elem_type)), \ + (elem_type*)((seq)->first && (unsigned)index < \ + (unsigned)((seq)->first->count) ? \ + (seq)->first->data + (index) * sizeof(elem_type) : \ + cvGetSeqElem( (CvSeq*)(seq), (index) ))) +#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) ) + +/** Add element to sequence: */ +#define CV_WRITE_SEQ_ELEM_VAR( elem_ptr, writer ) \ +{ \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + memcpy((writer).ptr, elem_ptr, (writer).seq->elem_size);\ + (writer).ptr += (writer).seq->elem_size; \ +} + +#define CV_WRITE_SEQ_ELEM( elem, writer ) \ +{ \ + assert( (writer).seq->elem_size == sizeof(elem)); \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + assert( (writer).ptr <= (writer).block_max - sizeof(elem));\ + memcpy((writer).ptr, &(elem), sizeof(elem)); \ + (writer).ptr += sizeof(elem); \ +} + + +/** Move reader position forward: */ +#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr += (elem_size)) >= (reader).block_max ) \ + { \ + cvChangeSeqBlock( &(reader), 1 ); \ + } \ +} + + +/** Move reader position backward: */ +#define CV_PREV_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr -= (elem_size)) < (reader).block_min ) \ + { \ + cvChangeSeqBlock( &(reader), -1 ); \ + } \ +} + +/** Read element and move read position forward: */ +#define CV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy( &(elem), (reader).ptr, sizeof((elem))); \ + CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \ +} + +/** Read element and move read position backward: */ +#define CV_REV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy(&(elem), (reader).ptr, sizeof((elem))); \ + CV_PREV_SEQ_ELEM( sizeof(elem), reader ) \ +} + + +#define CV_READ_CHAIN_POINT( _pt, reader ) \ +{ \ + (_pt) = (reader).pt; \ + if( (reader).ptr ) \ + { \ + CV_READ_SEQ_ELEM( (reader).code, (reader)); \ + assert( ((reader).code & ~7) == 0 ); \ + (reader).pt.x += (reader).deltas[(int)(reader).code][0]; \ + (reader).pt.y += (reader).deltas[(int)(reader).code][1]; \ + } \ +} + +#define CV_CURRENT_POINT( reader ) (*((CvPoint*)((reader).ptr))) +#define CV_PREV_POINT( reader ) (*((CvPoint*)((reader).prev_elem))) + +#define CV_READ_EDGE( pt1, pt2, reader ) \ +{ \ + assert( sizeof(pt1) == sizeof(CvPoint) && \ + sizeof(pt2) == sizeof(CvPoint) && \ + reader.seq->elem_size == sizeof(CvPoint)); \ + (pt1) = CV_PREV_POINT( reader ); \ + (pt2) = CV_CURRENT_POINT( reader ); \ + (reader).prev_elem = (reader).ptr; \ + CV_NEXT_SEQ_ELEM( sizeof(CvPoint), (reader)); \ +} + +/************ Graph macros ************/ + +/** Return next graph edge for given vertex: */ +#define CV_NEXT_GRAPH_EDGE( edge, vertex ) \ + (assert((edge)->vtx[0] == (vertex) || (edge)->vtx[1] == (vertex)), \ + (edge)->next[(edge)->vtx[1] == (vertex)]) + + + +/****************************************************************************************\ +* Data structures for persistence (a.k.a serialization) functionality * +\****************************************************************************************/ + +#if 0 + +/** "black box" file storage */ +typedef struct CvFileStorage CvFileStorage; + +/** Storage flags: */ +#define CV_STORAGE_READ 0 +#define CV_STORAGE_WRITE 1 +#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE +#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE +#define CV_STORAGE_APPEND 2 +#define CV_STORAGE_MEMORY 4 +#define CV_STORAGE_FORMAT_MASK (7<<3) +#define CV_STORAGE_FORMAT_AUTO 0 +#define CV_STORAGE_FORMAT_XML 8 +#define CV_STORAGE_FORMAT_YAML 16 +#define CV_STORAGE_FORMAT_JSON 24 +#define CV_STORAGE_BASE64 64 +#define CV_STORAGE_WRITE_BASE64 (CV_STORAGE_BASE64 | CV_STORAGE_WRITE) + +/** @brief List of attributes. : + +In the current implementation, attributes are used to pass extra parameters when writing user +objects (see cvWrite). XML attributes inside tags are not supported, aside from the object type +specification (type_id attribute). +@see cvAttrList, cvAttrValue + */ +typedef struct CvAttrList +{ + const char** attr; /**< NULL-terminated array of (attribute_name,attribute_value) pairs. */ + struct CvAttrList* next; /**< Pointer to next chunk of the attributes list. */ +} +CvAttrList; + +/** initializes CvAttrList structure */ +CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL), + CvAttrList* next CV_DEFAULT(NULL) ) +{ + CvAttrList l; + l.attr = attr; + l.next = next; + + return l; +} + +struct CvTypeInfo; + +#define CV_NODE_NONE 0 +#define CV_NODE_INT 1 +#define CV_NODE_INTEGER CV_NODE_INT +#define CV_NODE_REAL 2 +#define CV_NODE_FLOAT CV_NODE_REAL +#define CV_NODE_STR 3 +#define CV_NODE_STRING CV_NODE_STR +#define CV_NODE_REF 4 /**< not used */ +#define CV_NODE_SEQ 5 +#define CV_NODE_MAP 6 +#define CV_NODE_TYPE_MASK 7 + +#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK) + +/** file node flags */ +#define CV_NODE_FLOW 8 /**= CV_NODE_SEQ) +#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0) +#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0) +#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0) +#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0) + +#define CV_NODE_SEQ_SIMPLE 256 +#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0) + +typedef struct CvString +{ + int len; + char* ptr; +} +CvString; + +/** All the keys (names) of elements in the read file storage + are stored in the hash to speed up the lookup operations: */ +typedef struct CvStringHashNode +{ + unsigned hashval; + CvString str; + struct CvStringHashNode* next; +} +CvStringHashNode; + +typedef struct CvGenericHash CvFileNodeHash; + +/** Basic element of the file storage - scalar or collection: */ +typedef struct CvFileNode +{ + int tag; + struct CvTypeInfo* info; /**< type information + (only for user-defined object, for others it is 0) */ + union + { + double f; /**< scalar floating-point number */ + int i; /**< scalar integer number */ + CvString str; /**< text string */ + CvSeq* seq; /**< sequence (ordered collection of file nodes) */ + CvFileNodeHash* map; /**< map (collection of named file nodes) */ + } data; +} +CvFileNode; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr ); +typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr ); +typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); +typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name, + const void* struct_ptr, CvAttrList attributes ); +typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); +#ifdef __cplusplus +} +#endif + +/** @brief Type information + +The structure contains information about one of the standard or user-defined types. Instances of the +type may or may not contain a pointer to the corresponding CvTypeInfo structure. In any case, there +is a way to find the type info structure for a given object using the cvTypeOf function. +Alternatively, type info can be found by type name using cvFindType, which is used when an object +is read from file storage. The user can register a new type with cvRegisterType that adds the type +information structure into the beginning of the type list. Thus, it is possible to create +specialized types from generic standard types and override the basic methods. + */ +typedef struct CvTypeInfo +{ + int flags; /**< not used */ + int header_size; /**< sizeof(CvTypeInfo) */ + struct CvTypeInfo* prev; /**< previous registered type in the list */ + struct CvTypeInfo* next; /**< next registered type in the list */ + const char* type_name; /**< type name, written to file storage */ + CvIsInstanceFunc is_instance; /**< checks if the passed object belongs to the type */ + CvReleaseFunc release; /**< releases object (memory etc.) */ + CvReadFunc read; /**< reads object from file storage */ + CvWriteFunc write; /**< writes object to file storage */ + CvCloneFunc clone; /**< creates a copy of the object */ +} +CvTypeInfo; +#endif + +/** @} */ + +#endif /*OPENCV_CORE_TYPES_H*/ + +/* End of file. */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utility.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utility.hpp new file mode 100644 index 0000000..108c0d9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utility.hpp @@ -0,0 +1,1229 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_UTILITY_H +#define OPENCV_CORE_UTILITY_H + +#ifndef __cplusplus +# error utility.hpp header must be compiled as C++ +#endif + +#if defined(check) +# warning Detected Apple 'check' macro definition, it can cause build conflicts. Please, include this header before any Apple headers. +#endif + +#include "opencv2/core.hpp" +#include + +#include + +#if !defined(_M_CEE) +#include // std::mutex, std::lock_guard +#endif + +namespace cv +{ + +//! @addtogroup core_utils +//! @{ + +/** @brief Automatically Allocated Buffer Class + + The class is used for temporary buffers in functions and methods. + If a temporary buffer is usually small (a few K's of memory), + but its size depends on the parameters, it makes sense to create a small + fixed-size array on stack and use it if it's large enough. If the required buffer size + is larger than the fixed size, another buffer of sufficient size is allocated dynamically + and released after the processing. Therefore, in typical cases, when the buffer size is small, + there is no overhead associated with malloc()/free(). + At the same time, there is no limit on the size of processed data. + + This is what AutoBuffer does. The template takes 2 parameters - type of the buffer elements and + the number of stack-allocated elements. Here is how the class is used: + + \code + void my_func(const cv::Mat& m) + { + cv::AutoBuffer buf(1000); // create automatic buffer containing 1000 floats + + buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used, + // otherwise the buffer of "m.rows" floats will be allocated + // dynamically and deallocated in cv::AutoBuffer destructor + ... + } + \endcode +*/ +#ifdef OPENCV_ENABLE_MEMORY_SANITIZER +template class AutoBuffer +#else +template class AutoBuffer +#endif +{ +public: + typedef _Tp value_type; + + //! the default constructor + AutoBuffer(); + //! constructor taking the real buffer size + explicit AutoBuffer(size_t _size); + + //! the copy constructor + AutoBuffer(const AutoBuffer<_Tp, fixed_size>& buf); + //! the assignment operator + AutoBuffer<_Tp, fixed_size>& operator = (const AutoBuffer<_Tp, fixed_size>& buf); + + //! destructor. calls deallocate() + ~AutoBuffer(); + + //! allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used + void allocate(size_t _size); + //! deallocates the buffer if it was dynamically allocated + void deallocate(); + //! resizes the buffer and preserves the content + void resize(size_t _size); + //! returns the current buffer size + size_t size() const; + //! returns pointer to the real buffer, stack-allocated or heap-allocated + inline _Tp* data() { return ptr; } + //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated + inline const _Tp* data() const { return ptr; } + +#if !defined(OPENCV_DISABLE_DEPRECATED_COMPATIBILITY) // use to .data() calls instead + //! returns pointer to the real buffer, stack-allocated or heap-allocated + operator _Tp* () { return ptr; } + //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated + operator const _Tp* () const { return ptr; } +#else + //! returns a reference to the element at specified location. No bounds checking is performed in Release builds. + inline _Tp& operator[] (size_t i) { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; } + //! returns a reference to the element at specified location. No bounds checking is performed in Release builds. + inline const _Tp& operator[] (size_t i) const { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; } +#endif + +protected: + //! pointer to the real buffer, can point to buf if the buffer is small enough + _Tp* ptr; + //! size of the real buffer + size_t sz; + //! pre-allocated buffer. At least 1 element to confirm C++ standard requirements + _Tp buf[(fixed_size > 0) ? fixed_size : 1]; +}; + +/** @brief Sets/resets the break-on-error mode. + +When the break-on-error mode is set, the default error handler issues a hardware exception, which +can make debugging more convenient. + +\return the previous state + */ +CV_EXPORTS bool setBreakOnError(bool flag); + +extern "C" typedef int (*ErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, + int line, void* userdata ); + + +/** @brief Sets the new error handler and the optional user data. + + The function sets the new error handler, called from cv::error(). + + \param errCallback the new error handler. If NULL, the default error handler is used. + \param userdata the optional user data pointer, passed to the callback. + \param prevUserdata the optional output parameter where the previous user data pointer is stored + + \return the previous error handler +*/ +CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0); + +CV_EXPORTS String tempfile( const char* suffix = 0); +CV_EXPORTS void glob(String pattern, std::vector& result, bool recursive = false); + +/** @brief OpenCV will try to set the number of threads for the next parallel region. + +If threads == 0, OpenCV will disable threading optimizations and run all it's functions +sequentially. Passing threads \< 0 will reset threads number to system default. This function must +be called outside of parallel region. + +OpenCV will try to run its functions with specified threads number, but some behaviour differs from +framework: +- `TBB` - User-defined parallel constructions will run with the same threads number, if + another is not specified. If later on user creates his own scheduler, OpenCV will use it. +- `OpenMP` - No special defined behaviour. +- `Concurrency` - If threads == 1, OpenCV will disable threading optimizations and run its + functions sequentially. +- `GCD` - Supports only values \<= 0. +- `C=` - No special defined behaviour. +@param nthreads Number of threads used by OpenCV. +@sa getNumThreads, getThreadNum + */ +CV_EXPORTS_W void setNumThreads(int nthreads); + +/** @brief Returns the number of threads used by OpenCV for parallel regions. + +Always returns 1 if OpenCV is built without threading support. + +The exact meaning of return value depends on the threading framework used by OpenCV library: +- `TBB` - The number of threads, that OpenCV will try to use for parallel regions. If there is + any tbb::thread_scheduler_init in user code conflicting with OpenCV, then function returns + default number of threads used by TBB library. +- `OpenMP` - An upper bound on the number of threads that could be used to form a new team. +- `Concurrency` - The number of threads, that OpenCV will try to use for parallel regions. +- `GCD` - Unsupported; returns the GCD thread pool limit (512) for compatibility. +- `C=` - The number of threads, that OpenCV will try to use for parallel regions, if before + called setNumThreads with threads \> 0, otherwise returns the number of logical CPUs, + available for the process. +@sa setNumThreads, getThreadNum + */ +CV_EXPORTS_W int getNumThreads(); + +/** @brief Returns the index of the currently executed thread within the current parallel region. Always +returns 0 if called outside of parallel region. + +@deprecated Current implementation doesn't corresponding to this documentation. + +The exact meaning of the return value depends on the threading framework used by OpenCV library: +- `TBB` - Unsupported with current 4.1 TBB release. Maybe will be supported in future. +- `OpenMP` - The thread number, within the current team, of the calling thread. +- `Concurrency` - An ID for the virtual processor that the current context is executing on (0 + for master thread and unique number for others, but not necessary 1,2,3,...). +- `GCD` - System calling thread's ID. Never returns 0 inside parallel region. +- `C=` - The index of the current parallel task. +@sa setNumThreads, getNumThreads + */ +CV_EXPORTS_W int getThreadNum(); + +/** @brief Returns full configuration time cmake output. + +Returned value is raw cmake output including version control system revision, compiler version, +compiler flags, enabled modules and third party libraries, etc. Output format depends on target +architecture. + */ +CV_EXPORTS_W const String& getBuildInformation(); + +/** @brief Returns library version string + +For example "3.4.1-dev". + +@sa getMajorVersion, getMinorVersion, getRevisionVersion +*/ +CV_EXPORTS_W String getVersionString(); + +/** @brief Returns major library version */ +CV_EXPORTS_W int getVersionMajor(); + +/** @brief Returns minor library version */ +CV_EXPORTS_W int getVersionMinor(); + +/** @brief Returns revision field of the library version */ +CV_EXPORTS_W int getVersionRevision(); + +/** @brief Returns the number of ticks. + +The function returns the number of ticks after the certain event (for example, when the machine was +turned on). It can be used to initialize RNG or to measure a function execution time by reading the +tick count before and after the function call. +@sa getTickFrequency, TickMeter + */ +CV_EXPORTS_W int64 getTickCount(); + +/** @brief Returns the number of ticks per second. + +The function returns the number of ticks per second. That is, the following code computes the +execution time in seconds: +@code + double t = (double)getTickCount(); + // do something ... + t = ((double)getTickCount() - t)/getTickFrequency(); +@endcode +@sa getTickCount, TickMeter + */ +CV_EXPORTS_W double getTickFrequency(); + +/** @brief a Class to measure passing time. + +The class computes passing time by counting the number of ticks per second. That is, the following code computes the +execution time in seconds: +@snippet snippets/core_various.cpp TickMeter_total + +It is also possible to compute the average time over multiple runs: +@snippet snippets/core_various.cpp TickMeter_average + +@sa getTickCount, getTickFrequency +*/ +class CV_EXPORTS_W TickMeter +{ +public: + //! the default constructor + CV_WRAP TickMeter() + { + reset(); + } + + //! starts counting ticks. + CV_WRAP void start() + { + startTime = cv::getTickCount(); + } + + //! stops counting ticks. + CV_WRAP void stop() + { + int64 time = cv::getTickCount(); + if (startTime == 0) + return; + ++counter; + sumTime += (time - startTime); + startTime = 0; + } + + //! returns counted ticks. + CV_WRAP int64 getTimeTicks() const + { + return sumTime; + } + + //! returns passed time in microseconds. + CV_WRAP double getTimeMicro() const + { + return getTimeMilli()*1e3; + } + + //! returns passed time in milliseconds. + CV_WRAP double getTimeMilli() const + { + return getTimeSec()*1e3; + } + + //! returns passed time in seconds. + CV_WRAP double getTimeSec() const + { + return (double)getTimeTicks() / getTickFrequency(); + } + + //! returns internal counter value. + CV_WRAP int64 getCounter() const + { + return counter; + } + + //! returns average FPS (frames per second) value. + CV_WRAP double getFPS() const + { + const double sec = getTimeSec(); + if (sec < DBL_EPSILON) + return 0.; + return counter / sec; + } + + //! returns average time in seconds + CV_WRAP double getAvgTimeSec() const + { + if (counter <= 0) + return 0.; + return getTimeSec() / counter; + } + + //! returns average time in milliseconds + CV_WRAP double getAvgTimeMilli() const + { + return getAvgTimeSec() * 1e3; + } + + //! resets internal values. + CV_WRAP void reset() + { + startTime = 0; + sumTime = 0; + counter = 0; + } + +private: + int64 counter; + int64 sumTime; + int64 startTime; +}; + +/** @brief output operator +@code +TickMeter tm; +tm.start(); +// do something ... +tm.stop(); +std::cout << tm; +@endcode +*/ + +static inline +std::ostream& operator << (std::ostream& out, const TickMeter& tm) +{ + return out << tm.getTimeSec() << "sec"; +} + +/** @brief Returns the number of CPU ticks. + +The function returns the current number of CPU ticks on some architectures (such as x86, x64, +PowerPC). On other platforms the function is equivalent to getTickCount. It can also be used for +very accurate time measurements, as well as for RNG initialization. Note that in case of multi-CPU +systems a thread, from which getCPUTickCount is called, can be suspended and resumed at another CPU +with its own counter. So, theoretically (and practically) the subsequent calls to the function do +not necessary return the monotonously increasing values. Also, since a modern CPU varies the CPU +frequency depending on the load, the number of CPU clocks spent in some code cannot be directly +converted to time units. Therefore, getTickCount is generally a preferable solution for measuring +execution time. + */ +CV_EXPORTS_W int64 getCPUTickCount(); + +/** @brief Returns true if the specified feature is supported by the host hardware. + +The function returns true if the host hardware supports the specified feature. When user calls +setUseOptimized(false), the subsequent calls to checkHardwareSupport() will return false until +setUseOptimized(true) is called. This way user can dynamically switch on and off the optimized code +in OpenCV. +@param feature The feature of interest, one of cv::CpuFeatures + */ +CV_EXPORTS_W bool checkHardwareSupport(int feature); + +/** @brief Returns feature name by ID + +Returns empty string if feature is not defined +*/ +CV_EXPORTS_W String getHardwareFeatureName(int feature); + +/** @brief Returns list of CPU features enabled during compilation. + +Returned value is a string containing space separated list of CPU features with following markers: + +- no markers - baseline features +- prefix `*` - features enabled in dispatcher +- suffix `?` - features enabled but not available in HW + +Example: `SSE SSE2 SSE3 *SSE4.1 *SSE4.2 *FP16 *AVX *AVX2 *AVX512-SKX?` +*/ +CV_EXPORTS_W std::string getCPUFeaturesLine(); + +/** @brief Returns the number of logical CPUs available for the process. + */ +CV_EXPORTS_W int getNumberOfCPUs(); + + +/** @brief Aligns a pointer to the specified number of bytes. + +The function returns the aligned pointer of the same type as the input pointer: +\f[\texttt{(_Tp*)(((size_t)ptr + n-1) & -n)}\f] +@param ptr Aligned pointer. +@param n Alignment size that must be a power of two. + */ +template static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp)) +{ + CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2 + return (_Tp*)(((size_t)ptr + n-1) & -n); +} + +/** @brief Aligns a buffer size to the specified number of bytes. + +The function returns the minimum number that is greater than or equal to sz and is divisible by n : +\f[\texttt{(sz + n-1) & -n}\f] +@param sz Buffer size to align. +@param n Alignment size that must be a power of two. + */ +static inline size_t alignSize(size_t sz, int n) +{ + CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2 + return (sz + n-1) & -n; +} + +/** @brief Integer division with result round up. + +Use this function instead of `ceil((float)a / b)` expressions. + +@sa alignSize +*/ +static inline int divUp(int a, unsigned int b) +{ + CV_DbgAssert(a >= 0); + return (a + b - 1) / b; +} +/** @overload */ +static inline size_t divUp(size_t a, unsigned int b) +{ + return (a + b - 1) / b; +} + +/** @brief Round first value up to the nearest multiple of second value. + +Use this function instead of `ceil((float)a / b) * b` expressions. + +@sa divUp +*/ +static inline int roundUp(int a, unsigned int b) +{ + CV_DbgAssert(a >= 0); + return a + b - 1 - (a + b -1) % b; +} +/** @overload */ +static inline size_t roundUp(size_t a, unsigned int b) +{ + return a + b - 1 - (a + b - 1) % b; +} + +/** @brief Alignment check of passed values + +Usage: `isAligned(...)` + +@note Alignment(N) must be a power of 2 (2**k, 2^k) +*/ +template static inline +bool isAligned(const T& data) +{ + CV_StaticAssert((N & (N - 1)) == 0, ""); // power of 2 + return (((size_t)data) & (N - 1)) == 0; +} +/** @overload */ +template static inline +bool isAligned(const void* p1) +{ + return isAligned((size_t)p1); +} +/** @overload */ +template static inline +bool isAligned(const void* p1, const void* p2) +{ + return isAligned(((size_t)p1)|((size_t)p2)); +} +/** @overload */ +template static inline +bool isAligned(const void* p1, const void* p2, const void* p3) +{ + return isAligned(((size_t)p1)|((size_t)p2)|((size_t)p3)); +} +/** @overload */ +template static inline +bool isAligned(const void* p1, const void* p2, const void* p3, const void* p4) +{ + return isAligned(((size_t)p1)|((size_t)p2)|((size_t)p3)|((size_t)p4)); +} + +/** @brief Enables or disables the optimized code. + +The function can be used to dynamically turn on and off optimized dispatched code (code that uses SSE4.2, AVX/AVX2, +and other instructions on the platforms that support it). It sets a global flag that is further +checked by OpenCV functions. Since the flag is not checked in the inner OpenCV loops, it is only +safe to call the function on the very top level in your application where you can be sure that no +other OpenCV function is currently executed. + +By default, the optimized code is enabled unless you disable it in CMake. The current status can be +retrieved using useOptimized. +@param onoff The boolean flag specifying whether the optimized code should be used (onoff=true) +or not (onoff=false). + */ +CV_EXPORTS_W void setUseOptimized(bool onoff); + +/** @brief Returns the status of optimized code usage. + +The function returns true if the optimized code is enabled. Otherwise, it returns false. + */ +CV_EXPORTS_W bool useOptimized(); + +static inline size_t getElemSize(int type) { return (size_t)CV_ELEM_SIZE(type); } + +/////////////////////////////// Parallel Primitives ////////////////////////////////// + +/** @brief Base class for parallel data processors + +@ingroup core_parallel +*/ +class CV_EXPORTS ParallelLoopBody +{ +public: + virtual ~ParallelLoopBody(); + virtual void operator() (const Range& range) const = 0; +}; + +/** @brief Parallel data processor + +@ingroup core_parallel +*/ +CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.); + +//! @ingroup core_parallel +class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody +{ +private: + std::function m_functor; +public: + inline + ParallelLoopBodyLambdaWrapper(std::function functor) + : m_functor(functor) + { + // nothing + } + + virtual void operator() (const cv::Range& range) const CV_OVERRIDE + { + m_functor(range); + } +}; + +//! @ingroup core_parallel +static inline +void parallel_for_(const Range& range, std::function functor, double nstripes=-1.) +{ + parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes); +} + + +/////////////////////////////// forEach method of cv::Mat //////////////////////////// +template inline +void Mat::forEach_impl(const Functor& operation) { + if (false) { + operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast(0)); + // If your compiler fails in this line. + // Please check that your functor signature is + // (_Tp&, const int*) <- multi-dimensional + // or (_Tp&, void*) <- in case you don't need current idx. + } + + CV_Assert(!empty()); + CV_Assert(this->total() / this->size[this->dims - 1] <= INT_MAX); + const int LINES = static_cast(this->total() / this->size[this->dims - 1]); + + class PixelOperationWrapper :public ParallelLoopBody + { + public: + PixelOperationWrapper(Mat_<_Tp>* const frame, const Functor& _operation) + : mat(frame), op(_operation) {} + virtual ~PixelOperationWrapper(){} + // ! Overloaded virtual operator + // convert range call to row call. + virtual void operator()(const Range &range) const CV_OVERRIDE + { + const int DIMS = mat->dims; + const int COLS = mat->size[DIMS - 1]; + if (DIMS <= 2) { + for (int row = range.start; row < range.end; ++row) { + this->rowCall2(row, COLS); + } + } else { + std::vector idx(DIMS); /// idx is modified in this->rowCall + idx[DIMS - 2] = range.start - 1; + + for (int line_num = range.start; line_num < range.end; ++line_num) { + idx[DIMS - 2]++; + for (int i = DIMS - 2; i >= 0; --i) { + if (idx[i] >= mat->size[i]) { + idx[i - 1] += idx[i] / mat->size[i]; + idx[i] %= mat->size[i]; + continue; // carry-over; + } + else { + break; + } + } + this->rowCall(&idx[0], COLS, DIMS); + } + } + } + private: + Mat_<_Tp>* const mat; + const Functor op; + // ! Call operator for each elements in this row. + inline void rowCall(int* const idx, const int COLS, const int DIMS) const { + int &col = idx[DIMS - 1]; + col = 0; + _Tp* pixel = &(mat->template at<_Tp>(idx)); + + while (col < COLS) { + op(*pixel, const_cast(idx)); + pixel++; col++; + } + col = 0; + } + // ! Call operator for each elements in this row. 2d mat special version. + inline void rowCall2(const int row, const int COLS) const { + union Index{ + int body[2]; + operator const int*() const { + return reinterpret_cast(this); + } + int& operator[](const int i) { + return body[i]; + } + } idx = {{row, 0}}; + // Special union is needed to avoid + // "error: array subscript is above array bounds [-Werror=array-bounds]" + // when call the functor `op` such that access idx[3]. + + _Tp* pixel = &(mat->template at<_Tp>(idx)); + const _Tp* const pixel_end = pixel + COLS; + while(pixel < pixel_end) { + op(*pixel++, static_cast(idx)); + idx[1]++; + } + } + PixelOperationWrapper& operator=(const PixelOperationWrapper &) { + CV_Assert(false); + // We can not remove this implementation because Visual Studio warning C4822. + return *this; + } + }; + + parallel_for_(cv::Range(0, LINES), PixelOperationWrapper(reinterpret_cast*>(this), operation)); +} + +/////////////////////////// Synchronization Primitives /////////////////////////////// + +#if !defined(_M_CEE) +#ifndef OPENCV_DISABLE_THREAD_SUPPORT +typedef std::recursive_mutex Mutex; +typedef std::lock_guard AutoLock; +#else // OPENCV_DISABLE_THREAD_SUPPORT +// Custom (failing) implementation of `std::recursive_mutex`. +struct Mutex { + void lock(){ + CV_Error(cv::Error::StsNotImplemented, + "cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON"); + } + void unlock(){ + CV_Error(cv::Error::StsNotImplemented, + "cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON"); + } +}; +// Stub for cv::AutoLock when threads are disabled. +struct AutoLock { + AutoLock(Mutex &) { } +}; +#endif // OPENCV_DISABLE_THREAD_SUPPORT +#endif // !defined(_M_CEE) + + +/** @brief Designed for command line parsing + +The sample below demonstrates how to use CommandLineParser: +@code + CommandLineParser parser(argc, argv, keys); + parser.about("Application name v1.0.0"); + + if (parser.has("help")) + { + parser.printMessage(); + return 0; + } + + int N = parser.get("N"); + double fps = parser.get("fps"); + String path = parser.get("path"); + + use_time_stamp = parser.has("timestamp"); + + String img1 = parser.get(0); + String img2 = parser.get(1); + + int repeat = parser.get(2); + + if (!parser.check()) + { + parser.printErrors(); + return 0; + } +@endcode + +### Keys syntax + +The keys parameter is a string containing several blocks, each one is enclosed in curly braces and +describes one argument. Each argument contains three parts separated by the `|` symbol: + +-# argument names is a space-separated list of option synonyms (to mark argument as positional, prefix it with the `@` symbol) +-# default value will be used if the argument was not provided (can be empty) +-# help message (can be empty) + +For example: + +@code{.cpp} + const String keys = + "{help h usage ? | | print this message }" + "{@image1 | | image1 for compare }" + "{@image2 || image2 for compare }" + "{@repeat |1 | number }" + "{path |. | path to file }" + "{fps | -1.0 | fps for output video }" + "{N count |100 | count of objects }" + "{ts timestamp | | use time stamp }" + ; +} +@endcode + +Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method. +Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their +actual value instead. + +String keys like `get("@image1")` return the empty string `""` by default - even with an empty default value. +Use the special `` default value to enforce that the returned string must not be empty. (like in `get("@image2")`) + +### Usage + +For the described keys: + +@code{.sh} + # Good call (3 positional parameters: image1, image2 and repeat; N is 200, ts is true) + $ ./app -N=200 1.png 2.jpg 19 -ts + + # Bad call + $ ./app -fps=aaa + ERRORS: + Parameter 'fps': can not convert: [aaa] to [double] +@endcode + */ +class CV_EXPORTS CommandLineParser +{ +public: + + /** @brief Constructor + + Initializes command line parser object + + @param argc number of command line arguments (from main()) + @param argv array of command line arguments (from main()) + @param keys string describing acceptable command line parameters (see class description for syntax) + */ + CommandLineParser(int argc, const char* const argv[], const String& keys); + + /** @brief Copy constructor */ + CommandLineParser(const CommandLineParser& parser); + + /** @brief Assignment operator */ + CommandLineParser& operator = (const CommandLineParser& parser); + + /** @brief Destructor */ + ~CommandLineParser(); + + /** @brief Returns application path + + This method returns the path to the executable from the command line (`argv[0]`). + + For example, if the application has been started with such a command: + @code{.sh} + $ ./bin/my-executable + @endcode + this method will return `./bin`. + */ + String getPathToApplication() const; + + /** @brief Access arguments by name + + Returns argument converted to selected type. If the argument is not known or can not be + converted to selected type, the error flag is set (can be checked with @ref check). + + For example, define: + @code{.cpp} + String keys = "{N count||}"; + @endcode + + Call: + @code{.sh} + $ ./my-app -N=20 + # or + $ ./my-app --count=20 + @endcode + + Access: + @code{.cpp} + int N = parser.get("N"); + @endcode + + @param name name of the argument + @param space_delete remove spaces from the left and right of the string + @tparam T the argument will be converted to this type if possible + + @note You can access positional arguments by their `@`-prefixed name: + @code{.cpp} + parser.get("@image"); + @endcode + */ + template + T get(const String& name, bool space_delete = true) const + { + T val = T(); + getByName(name, space_delete, ParamType::type, (void*)&val); + return val; + } + + /** @brief Access positional arguments by index + + Returns argument converted to selected type. Indexes are counted from zero. + + For example, define: + @code{.cpp} + String keys = "{@arg1||}{@arg2||}" + @endcode + + Call: + @code{.sh} + ./my-app abc qwe + @endcode + + Access arguments: + @code{.cpp} + String val_1 = parser.get(0); // returns "abc", arg1 + String val_2 = parser.get(1); // returns "qwe", arg2 + @endcode + + @param index index of the argument + @param space_delete remove spaces from the left and right of the string + @tparam T the argument will be converted to this type if possible + */ + template + T get(int index, bool space_delete = true) const + { + T val = T(); + getByIndex(index, space_delete, ParamType::type, (void*)&val); + return val; + } + + /** @brief Check if field was provided in the command line + + @param name argument name to check + */ + bool has(const String& name) const; + + /** @brief Check for parsing errors + + Returns false if error occurred while accessing the parameters (bad conversion, missing arguments, + etc.). Call @ref printErrors to print error messages list. + */ + bool check() const; + + /** @brief Set the about message + + The about message will be shown when @ref printMessage is called, right before arguments table. + */ + void about(const String& message); + + /** @brief Print help message + + This method will print standard help message containing the about message and arguments description. + + @sa about + */ + void printMessage() const; + + /** @brief Print list of errors occurred + + @sa check + */ + void printErrors() const; + +protected: + void getByName(const String& name, bool space_delete, Param type, void* dst) const; + void getByIndex(int index, bool space_delete, Param type, void* dst) const; + + struct Impl; + Impl* impl; +}; + +//! @} core_utils + +//! @cond IGNORED + +/////////////////////////////// AutoBuffer implementation //////////////////////////////////////// + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer() +{ + ptr = buf; + sz = fixed_size; +} + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size) +{ + ptr = buf; + sz = fixed_size; + allocate(_size); +} + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf ) +{ + ptr = buf; + sz = fixed_size; + allocate(abuf.size()); + for( size_t i = 0; i < sz; i++ ) + ptr[i] = abuf.ptr[i]; +} + +template inline AutoBuffer<_Tp, fixed_size>& +AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf) +{ + if( this != &abuf ) + { + deallocate(); + allocate(abuf.size()); + for( size_t i = 0; i < sz; i++ ) + ptr[i] = abuf.ptr[i]; + } + return *this; +} + +template inline +AutoBuffer<_Tp, fixed_size>::~AutoBuffer() +{ deallocate(); } + +template inline void +AutoBuffer<_Tp, fixed_size>::allocate(size_t _size) +{ + if(_size <= sz) + { + sz = _size; + return; + } + deallocate(); + sz = _size; + if(_size > fixed_size) + { + ptr = new _Tp[_size]; + } +} + +template inline void +AutoBuffer<_Tp, fixed_size>::deallocate() +{ + if( ptr != buf ) + { + delete[] ptr; + ptr = buf; + sz = fixed_size; + } +} + +template inline void +AutoBuffer<_Tp, fixed_size>::resize(size_t _size) +{ + if(_size <= sz) + { + sz = _size; + return; + } + size_t i, prevsize = sz, minsize = MIN(prevsize, _size); + _Tp* prevptr = ptr; + + ptr = _size > fixed_size ? new _Tp[_size] : buf; + sz = _size; + + if( ptr != prevptr ) + for( i = 0; i < minsize; i++ ) + ptr[i] = prevptr[i]; + for( i = prevsize; i < _size; i++ ) + ptr[i] = _Tp(); + + if( prevptr != buf ) + delete[] prevptr; +} + +template inline size_t +AutoBuffer<_Tp, fixed_size>::size() const +{ return sz; } + +//! @endcond + + +// Basic Node class for tree building +template +class CV_EXPORTS Node +{ +public: + Node() + { + m_pParent = 0; + } + Node(OBJECT& payload) : m_payload(payload) + { + m_pParent = 0; + } + ~Node() + { + removeChilds(); + if (m_pParent) + { + int idx = m_pParent->findChild(this); + if (idx >= 0) + m_pParent->m_childs.erase(m_pParent->m_childs.begin() + idx); + } + } + + Node* findChild(OBJECT& payload) const + { + for(size_t i = 0; i < this->m_childs.size(); i++) + { + if(this->m_childs[i]->m_payload == payload) + return this->m_childs[i]; + } + return NULL; + } + + int findChild(Node *pNode) const + { + for (size_t i = 0; i < this->m_childs.size(); i++) + { + if(this->m_childs[i] == pNode) + return (int)i; + } + return -1; + } + + void addChild(Node *pNode) + { + if(!pNode) + return; + + CV_Assert(pNode->m_pParent == 0); + pNode->m_pParent = this; + this->m_childs.push_back(pNode); + } + + void removeChilds() + { + for(size_t i = 0; i < m_childs.size(); i++) + { + m_childs[i]->m_pParent = 0; // avoid excessive parent vector trimming + delete m_childs[i]; + } + m_childs.clear(); + } + + int getDepth() + { + int count = 0; + Node *pParent = m_pParent; + while(pParent) count++, pParent = pParent->m_pParent; + return count; + } + +public: + OBJECT m_payload; + Node* m_pParent; + std::vector*> m_childs; +}; + + +namespace samples { + +//! @addtogroup core_utils_samples +// This section describes utility functions for OpenCV samples. +// +// @note Implementation of these utilities is not thread-safe. +// +//! @{ + +/** @brief Try to find requested data file + +Search directories: + +1. Directories passed via `addSamplesDataSearchPath()` +2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable +3. OPENCV_SAMPLES_DATA_PATH environment variable + If parameter value is not empty and nothing is found then stop searching. +4. Detects build/install path based on: + a. current working directory (CWD) + b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage) +5. Scan `/{,data,samples/data}` directories if build directory is detected or the current directory is in source tree. +6. Scan `/share/OpenCV` directory if install directory is detected. + +@see cv::utils::findDataFile + +@param relative_path Relative path to data file +@param required Specify "file not found" handling. + If true, function prints information message and raises cv::Exception. + If false, function returns empty result +@param silentMode Disables messages +@return Returns path (absolute or relative to the current directory) or empty string if file is not found +*/ +CV_EXPORTS_W cv::String findFile(const cv::String& relative_path, bool required = true, bool silentMode = false); + +CV_EXPORTS_W cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode = false); + +inline cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode) +{ + cv::String res = findFile(relative_path, false, silentMode); + if (res.empty()) + return relative_path; + return res; +} + +/** @brief Override search data path by adding new search location + +Use this only to override default behavior +Passed paths are used in LIFO order. + +@param path Path to used samples data +*/ +CV_EXPORTS_W void addSamplesDataSearchPath(const cv::String& path); + +/** @brief Append samples search data sub directory + +General usage is to add OpenCV modules name (`/modules//samples/data` -> `/samples/data` + `modules//samples/data`). +Passed subdirectories are used in LIFO order. + +@param subdir samples data sub directory +*/ +CV_EXPORTS_W void addSamplesDataSearchSubDirectory(const cv::String& subdir); + +//! @} +} // namespace samples + +namespace utils { + +CV_EXPORTS int getThreadID(); + +} // namespace + +} //namespace cv + +#ifdef CV_COLLECT_IMPL_DATA +#include "opencv2/core/utils/instrumentation.hpp" +#else +/// Collect implementation data on OpenCV function call. Requires ENABLE_IMPL_COLLECTION build option. +#define CV_IMPL_ADD(impl) +#endif + +#endif //OPENCV_CORE_UTILITY_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.hpp new file mode 100644 index 0000000..79e9338 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.hpp @@ -0,0 +1,29 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ALLOCATOR_STATS_HPP +#define OPENCV_CORE_ALLOCATOR_STATS_HPP + +#include "../cvdef.h" + +namespace cv { namespace utils { + +class AllocatorStatisticsInterface +{ +protected: + AllocatorStatisticsInterface() {} + virtual ~AllocatorStatisticsInterface() {} +public: + virtual uint64_t getCurrentUsage() const = 0; + virtual uint64_t getTotalUsage() const = 0; + virtual uint64_t getNumberOfAllocations() const = 0; + virtual uint64_t getPeakUsage() const = 0; + + /** set peak usage = current usage */ + virtual void resetPeakUsage() = 0; +}; + +}} // namespace + +#endif // OPENCV_CORE_ALLOCATOR_STATS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.impl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.impl.hpp new file mode 100644 index 0000000..eb5ecde --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.impl.hpp @@ -0,0 +1,158 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP +#define OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP + +#include "./allocator_stats.hpp" + +//#define OPENCV_DISABLE_ALLOCATOR_STATS + +#ifdef CV_CXX11 + +#include + +#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE +#if defined(__GNUC__) && (\ + (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4) || \ + (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \ + ) +#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int +#endif +#endif + +#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE +#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE long long +#endif + +#else // CV_CXX11 + +#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE +#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int // CV_XADD supports int only +#endif + +#endif // CV_CXX11 + +namespace cv { namespace utils { + +#ifdef CV__ALLOCATOR_STATS_LOG +namespace { +#endif + +class AllocatorStatistics : public AllocatorStatisticsInterface +{ +#ifdef OPENCV_DISABLE_ALLOCATOR_STATS + +public: + AllocatorStatistics() {} + ~AllocatorStatistics() CV_OVERRIDE {} + + uint64_t getCurrentUsage() const CV_OVERRIDE { return 0; } + uint64_t getTotalUsage() const CV_OVERRIDE { return 0; } + uint64_t getNumberOfAllocations() const CV_OVERRIDE { return 0; } + uint64_t getPeakUsage() const CV_OVERRIDE { return 0; } + + /** set peak usage = current usage */ + void resetPeakUsage() CV_OVERRIDE {}; + + void onAllocate(size_t /*sz*/) {} + void onFree(size_t /*sz*/) {} + +#elif defined(CV_CXX11) + +protected: + typedef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE counter_t; + std::atomic curr, total, total_allocs, peak; +public: + AllocatorStatistics() {} + ~AllocatorStatistics() CV_OVERRIDE {} + + uint64_t getCurrentUsage() const CV_OVERRIDE { return (uint64_t)curr.load(); } + uint64_t getTotalUsage() const CV_OVERRIDE { return (uint64_t)total.load(); } + uint64_t getNumberOfAllocations() const CV_OVERRIDE { return (uint64_t)total_allocs.load(); } + uint64_t getPeakUsage() const CV_OVERRIDE { return (uint64_t)peak.load(); } + + /** set peak usage = current usage */ + void resetPeakUsage() CV_OVERRIDE { peak.store(curr.load()); } + + // Controller interface + void onAllocate(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("allocate: %lld (curr=%lld)", (long long int)sz, (long long int)curr.load())); +#endif + + counter_t new_curr = curr.fetch_add((counter_t)sz) + (counter_t)sz; + + // peak = std::max((uint64_t)peak, new_curr); + auto prev_peak = peak.load(); + while (prev_peak < new_curr) + { + if (peak.compare_exchange_weak(prev_peak, new_curr)) + break; + } + // end of peak = max(...) + + total += (counter_t)sz; + total_allocs++; + } + void onFree(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("free: %lld (curr=%lld)", (long long int)sz, (long long int)curr.load())); +#endif + curr -= (counter_t)sz; + } + +#else // non C++11 + +protected: + typedef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE counter_t; + volatile counter_t curr, total, total_allocs, peak; // overflow is possible, CV_XADD operates with 'int' only +public: + AllocatorStatistics() + : curr(0), total(0), total_allocs(0), peak(0) + {} + ~AllocatorStatistics() CV_OVERRIDE {} + + uint64_t getCurrentUsage() const CV_OVERRIDE { return (uint64_t)curr; } + uint64_t getTotalUsage() const CV_OVERRIDE { return (uint64_t)total; } + uint64_t getNumberOfAllocations() const CV_OVERRIDE { return (uint64_t)total_allocs; } + uint64_t getPeakUsage() const CV_OVERRIDE { return (uint64_t)peak; } + + void resetPeakUsage() CV_OVERRIDE { peak = curr; } + + // Controller interface + void onAllocate(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("allocate: %lld (curr=%lld)", (long long int)sz, (long long int)curr)); +#endif + + counter_t new_curr = (counter_t)CV_XADD(&curr, (counter_t)sz) + (counter_t)sz; + + peak = std::max((counter_t)peak, new_curr); // non-thread safe + + //CV_XADD(&total, (uint64_t)sz); // overflow with int, non-reliable... + total += sz; + + CV_XADD(&total_allocs, (counter_t)1); + } + void onFree(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("free: %lld (curr=%lld)", (long long int)sz, (long long int)curr)); +#endif + CV_XADD(&curr, (counter_t)-sz); + } +#endif +}; + +#ifdef CV__ALLOCATOR_STATS_LOG +} // namespace +#endif + +}} // namespace + +#endif // OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/filesystem.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/filesystem.hpp new file mode 100644 index 0000000..a98d220 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/filesystem.hpp @@ -0,0 +1,82 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_UTILS_FILESYSTEM_HPP +#define OPENCV_UTILS_FILESYSTEM_HPP + +namespace cv { namespace utils { namespace fs { + + +CV_EXPORTS bool exists(const cv::String& path); +CV_EXPORTS bool isDirectory(const cv::String& path); + +CV_EXPORTS void remove_all(const cv::String& path); + + +CV_EXPORTS cv::String getcwd(); + +/** @brief Converts path p to a canonical absolute path + * Symlinks are processed if there is support for them on running platform. + * + * @param path input path. Target file/directory should exist. + */ +CV_EXPORTS cv::String canonical(const cv::String& path); + +/** Join path components */ +CV_EXPORTS cv::String join(const cv::String& base, const cv::String& path); + +/** Get parent directory */ +CV_EXPORTS cv::String getParent(const cv::String &path); +CV_EXPORTS std::wstring getParent(const std::wstring& path); + +/** + * Generate a list of all files that match the globbing pattern. + * + * Result entries are prefixed by base directory path. + * + * @param directory base directory + * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results + * @param[out] result result of globing. + * @param recursive scan nested directories too + * @param includeDirectories include directories into results list + */ +CV_EXPORTS void glob(const cv::String& directory, const cv::String& pattern, + CV_OUT std::vector& result, + bool recursive = false, bool includeDirectories = false); + +/** + * Generate a list of all files that match the globbing pattern. + * + * @param directory base directory + * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results + * @param[out] result globbing result with relative paths from base directory + * @param recursive scan nested directories too + * @param includeDirectories include directories into results list + */ +CV_EXPORTS void glob_relative(const cv::String& directory, const cv::String& pattern, + CV_OUT std::vector& result, + bool recursive = false, bool includeDirectories = false); + + +CV_EXPORTS bool createDirectory(const cv::String& path); +CV_EXPORTS bool createDirectories(const cv::String& path); + +#ifdef __OPENCV_BUILD +// TODO +//CV_EXPORTS cv::String getTempDirectory(); + +/** + * @brief Returns directory to store OpenCV cache files + * Create sub-directory in common OpenCV cache directory if it doesn't exist. + * @param sub_directory_name name of sub-directory. NULL or "" value asks to return root cache directory. + * @param configuration_name optional name of configuration parameter name which overrides default behavior. + * @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user. + */ +CV_EXPORTS cv::String getCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL); + +#endif + +}}} // namespace + +#endif // OPENCV_UTILS_FILESYSTEM_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/instrumentation.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/instrumentation.hpp new file mode 100644 index 0000000..3639867 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/instrumentation.hpp @@ -0,0 +1,125 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_UTILS_INSTR_HPP +#define OPENCV_UTILS_INSTR_HPP + +#include +#include + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +#ifdef CV_COLLECT_IMPL_DATA +CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays +CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays +// Get stored implementation flags and functions names arrays +// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function +CV_EXPORTS int getImpl(std::vector &impl, std::vector &funName); + +CV_EXPORTS bool useCollection(); // return implementation collection state +CV_EXPORTS void setUseCollection(bool flag); // set implementation collection state + +#define CV_IMPL_PLAIN 0x01 // native CPU OpenCV implementation +#define CV_IMPL_OCL 0x02 // OpenCL implementation +#define CV_IMPL_IPP 0x04 // IPP implementation +#define CV_IMPL_MT 0x10 // multithreaded implementation + +#undef CV_IMPL_ADD +#define CV_IMPL_ADD(impl) \ + if(cv::useCollection()) \ + { \ + cv::addImpl(impl, CV_Func); \ + } +#endif + +// Instrumentation external interface +namespace instr +{ + +#if !defined OPENCV_ABI_CHECK + +enum TYPE +{ + TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function + TYPE_MARKER, // Information marker + TYPE_WRAPPER, // Wrapper function for implementation + TYPE_FUN, // Simple function call +}; + +enum IMPL +{ + IMPL_PLAIN = 0, + IMPL_IPP, + IMPL_OPENCL, +}; + +struct NodeDataTls +{ + NodeDataTls() + { + m_ticksTotal = 0; + } + uint64 m_ticksTotal; +}; + +class CV_EXPORTS NodeData +{ +public: + NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, void* retAddress = NULL, bool alwaysExpand = false, cv::instr::TYPE instrType = TYPE_GENERAL, cv::instr::IMPL implType = IMPL_PLAIN); + NodeData(NodeData &ref); + ~NodeData(); + NodeData& operator=(const NodeData&); + + cv::String m_funName; + cv::instr::TYPE m_instrType; + cv::instr::IMPL m_implType; + const char* m_fileName; + int m_lineNum; + void* m_retAddress; + bool m_alwaysExpand; + bool m_funError; + + volatile int m_counter; + volatile uint64 m_ticksTotal; + TLSDataAccumulator m_tls; + int m_threads; + + // No synchronization + double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; } + double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; } +}; +bool operator==(const NodeData& lhs, const NodeData& rhs); + +typedef Node InstrNode; + +CV_EXPORTS InstrNode* getTrace(); + +#endif // !defined OPENCV_ABI_CHECK + + +CV_EXPORTS bool useInstrumentation(); +CV_EXPORTS void setUseInstrumentation(bool flag); +CV_EXPORTS void resetTrace(); + +enum FLAGS +{ + FLAGS_NONE = 0, + FLAGS_MAPPING = 0x01, + FLAGS_EXPAND_SAME_NAMES = 0x02, +}; + +CV_EXPORTS void setFlags(FLAGS modeFlags); +static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); } +CV_EXPORTS FLAGS getFlags(); + +} // namespace instr + +//! @} + +} // namespace + +#endif // OPENCV_UTILS_TLS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logger.defines.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logger.defines.hpp new file mode 100644 index 0000000..7d73f02 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logger.defines.hpp @@ -0,0 +1,42 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_LOGGER_DEFINES_HPP +#define OPENCV_LOGGER_DEFINES_HPP + +//! @addtogroup core_logging +//! @{ + +// Supported logging levels and their semantic +#define CV_LOG_LEVEL_SILENT 0 //!< for using in setLogLevel() call +#define CV_LOG_LEVEL_FATAL 1 //!< Fatal (critical) error (unrecoverable internal error) +#define CV_LOG_LEVEL_ERROR 2 //!< Error message +#define CV_LOG_LEVEL_WARN 3 //!< Warning message +#define CV_LOG_LEVEL_INFO 4 //!< Info message +#define CV_LOG_LEVEL_DEBUG 5 //!< Debug message. Disabled in the "Release" build. +#define CV_LOG_LEVEL_VERBOSE 6 //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build. + +namespace cv { +namespace utils { +namespace logging { + +//! Supported logging levels and their semantic +enum LogLevel { + LOG_LEVEL_SILENT = 0, //!< for using in setLogVevel() call + LOG_LEVEL_FATAL = 1, //!< Fatal (critical) error (unrecoverable internal error) + LOG_LEVEL_ERROR = 2, //!< Error message + LOG_LEVEL_WARNING = 3, //!< Warning message + LOG_LEVEL_INFO = 4, //!< Info message + LOG_LEVEL_DEBUG = 5, //!< Debug message. Disabled in the "Release" build. + LOG_LEVEL_VERBOSE = 6, //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build. +#ifndef CV_DOXYGEN + ENUM_LOG_LEVEL_FORCE_INT = INT_MAX +#endif +}; + +}}} // namespace + +//! @} + +#endif // OPENCV_LOGGER_DEFINES_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logger.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logger.hpp new file mode 100644 index 0000000..accb860 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logger.hpp @@ -0,0 +1,218 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_LOGGER_HPP +#define OPENCV_LOGGER_HPP + +#include +#include +#include // INT_MAX + +#include "logger.defines.hpp" +#include "logtag.hpp" + +namespace cv { +namespace utils { +namespace logging { + +//! @addtogroup core_logging +//! @{ + +/** Set global logging level +@return previous logging level +*/ +CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel); +/** Get global logging level */ +CV_EXPORTS LogLevel getLogLevel(); + +CV_EXPORTS void registerLogTag(cv::utils::logging::LogTag* plogtag); + +CV_EXPORTS void setLogTagLevel(const char* tag, cv::utils::logging::LogLevel level); + +CV_EXPORTS cv::utils::logging::LogLevel getLogTagLevel(const char* tag); + +namespace internal { + +/** Get global log tag */ +CV_EXPORTS cv::utils::logging::LogTag* getGlobalLogTag(); + +/** Write log message */ +CV_EXPORTS void writeLogMessage(LogLevel logLevel, const char* message); + +/** Write log message */ +CV_EXPORTS void writeLogMessageEx(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message); + +} // namespace + +struct LogTagAuto + : public LogTag +{ + inline LogTagAuto(const char* _name, LogLevel _level) + : LogTag(_name, _level) + { + registerLogTag(this); + } +}; + +/** + * \def CV_LOG_STRIP_LEVEL + * + * Define CV_LOG_STRIP_LEVEL=CV_LOG_LEVEL_[DEBUG|INFO|WARN|ERROR|FATAL|SILENT] to compile out anything at that and before that logging level + */ +#ifndef CV_LOG_STRIP_LEVEL +# if defined NDEBUG +# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG +# else +# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE +# endif +#endif + +#define CV_LOGTAG_PTR_CAST(expr) static_cast(expr) + +// CV_LOGTAG_EXPAND_NAME is intended to be re-defined (undef and then define again) +// to allows logging users to use a shorter name argument when calling +// CV_LOG_WITH_TAG or its related macros such as CV_LOG_INFO. +// +// This macro is intended to modify the tag argument as a string (token), via +// preprocessor token pasting or metaprogramming techniques. A typical usage +// is to apply a prefix, such as +// ...... #define CV_LOGTAG_EXPAND_NAME(tag) cv_logtag_##tag +// +// It is permitted to re-define to a hard-coded expression, ignoring the tag. +// This would work identically like the CV_LOGTAG_FALLBACK macro. +// +// Important: When the logging macro is called with tag being NULL, a user-defined +// CV_LOGTAG_EXPAND_NAME may expand it into cv_logtag_0, cv_logtag_NULL, or +// cv_logtag_nullptr. Use with care. Also be mindful of C++ symbol redefinitions. +// +// If there is significant amount of logging code with tag being NULL, it is +// recommended to use (re-define) CV_LOGTAG_FALLBACK to inject locally a default +// tag at the beginning of a compilation unit, to minimize lines of code changes. +// +#define CV_LOGTAG_EXPAND_NAME(tag) tag + +// CV_LOGTAG_FALLBACK is intended to be re-defined (undef and then define again) +// by any other compilation units to provide a log tag when the logging statement +// does not specify one. The macro needs to expand into a C++ expression that can +// be static_cast into (cv::utils::logging::LogTag*). Null (nullptr) is permitted. +#define CV_LOGTAG_FALLBACK nullptr + +// CV_LOGTAG_GLOBAL is the tag used when a log tag is not specified in the logging +// statement nor the compilation unit. The macro needs to expand into a C++ +// expression that can be static_cast into (cv::utils::logging::LogTag*). Must be +// non-null. Do not re-define. +#define CV_LOGTAG_GLOBAL cv::utils::logging::internal::getGlobalLogTag() + +#define CV_LOG_WITH_TAG(tag, msgLevel, extra_check0, extra_check1, ...) \ + for(;;) { \ + extra_check0; \ + const auto cv_temp_msglevel = (cv::utils::logging::LogLevel)(msgLevel); \ + if (cv_temp_msglevel >= (CV_LOG_STRIP_LEVEL)) break; \ + auto cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_EXPAND_NAME(tag)); \ + if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_FALLBACK); \ + if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_GLOBAL); \ + if (cv_temp_logtagptr && (cv_temp_msglevel > cv_temp_logtagptr->level)) break; \ + extra_check1; \ + std::stringstream cv_temp_logstream; \ + cv_temp_logstream << __VA_ARGS__; \ + cv::utils::logging::internal::writeLogMessageEx( \ + cv_temp_msglevel, \ + (cv_temp_logtagptr ? cv_temp_logtagptr->name : nullptr), \ + __FILE__, \ + __LINE__, \ + CV_Func, \ + cv_temp_logstream.str().c_str()); \ + break; \ + } + +#define CV_LOG_FATAL(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , , __VA_ARGS__) +#define CV_LOG_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , , __VA_ARGS__) +#define CV_LOG_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , , __VA_ARGS__) +#define CV_LOG_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , , __VA_ARGS__) +#define CV_LOG_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , , __VA_ARGS__) +#define CV_LOG_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , , __VA_ARGS__) + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO +#undef CV_LOG_INFO +#define CV_LOG_INFO(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG +#undef CV_LOG_DEBUG +#define CV_LOG_DEBUG(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE +#undef CV_LOG_VERBOSE +#define CV_LOG_VERBOSE(tag, v, ...) +#endif + +//! @cond IGNORED +#define CV__LOG_ONCE_CHECK_PRE \ + static bool _cv_log_once_ ## __LINE__ = false; \ + if (_cv_log_once_ ## __LINE__) break; + +#define CV__LOG_ONCE_CHECK_POST \ + _cv_log_once_ ## __LINE__ = true; + +#define CV__LOG_IF_CHECK(logging_cond) \ + if (!(logging_cond)) break; + +//! @endcond + + +// CV_LOG_ONCE_XXX macros + +#define CV_LOG_ONCE_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO +#undef CV_LOG_ONCE_INFO +#define CV_LOG_ONCE_INFO(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG +#undef CV_LOG_ONCE_DEBUG +#define CV_LOG_ONCE_DEBUG(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE +#undef CV_LOG_ONCE_VERBOSE +#define CV_LOG_ONCE_VERBOSE(tag, v, ...) +#endif + + +// CV_LOG_IF_XXX macros + +#define CV_LOG_IF_FATAL(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_ERROR(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_WARNING(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_INFO(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_DEBUG(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO +#undef CV_LOG_IF_INFO +#define CV_LOG_IF_INFO(tag, logging_cond, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG +#undef CV_LOG_IF_DEBUG +#define CV_LOG_IF_DEBUG(tag, logging_cond, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE +#undef CV_LOG_IF_VERBOSE +#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) +#endif + + +//! @} + +}}} // namespace + +#endif // OPENCV_LOGGER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logtag.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logtag.hpp new file mode 100644 index 0000000..4089720 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/logtag.hpp @@ -0,0 +1,28 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_LOGTAG_HPP +#define OPENCV_CORE_LOGTAG_HPP + +#include "opencv2/core/cvstd.hpp" +#include "logger.defines.hpp" + +namespace cv { +namespace utils { +namespace logging { + +struct LogTag +{ + const char* name; + LogLevel level; + + inline LogTag(const char* _name, LogLevel _level) + : name(_name) + , level(_level) + {} +}; + +}}} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/tls.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/tls.hpp new file mode 100644 index 0000000..124caeb --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/tls.hpp @@ -0,0 +1,235 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_UTILS_TLS_HPP +#define OPENCV_UTILS_TLS_HPP + +#ifndef OPENCV_CORE_UTILITY_H +#error "tls.hpp must be included after opencv2/core/utility.hpp or opencv2/core.hpp" +#endif + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +namespace details { class TlsStorage; } + +/** TLS container base implementation + * + * Don't use directly. + * + * @sa TLSData, TLSDataAccumulator templates + */ +class CV_EXPORTS TLSDataContainer +{ +protected: + TLSDataContainer(); + virtual ~TLSDataContainer(); + + /// @deprecated use detachData() instead + void gatherData(std::vector &data) const; + /// get TLS data and detach all data from threads (similar to cleanup() call) + void detachData(std::vector& data); + + void* getData() const; + void release(); + +protected: + virtual void* createDataInstance() const = 0; + virtual void deleteDataInstance(void* pData) const = 0; + +private: + int key_; + + friend class cv::details::TlsStorage; // core/src/system.cpp + +public: + void cleanup(); //!< Release created TLS data container objects. It is similar to release() call, but it keeps TLS container valid. + +private: + // Disable copy/assign (noncopyable pattern) + TLSDataContainer(TLSDataContainer &) = delete; + TLSDataContainer& operator =(const TLSDataContainer &) = delete; +}; + + +/** @brief Simple TLS data class + * + * @sa TLSDataAccumulator + */ +template +class TLSData : protected TLSDataContainer +{ +public: + inline TLSData() {} + inline ~TLSData() { release(); } + + inline T* get() const { return (T*)getData(); } //!< Get data associated with key + inline T& getRef() const { T* ptr = (T*)getData(); CV_DbgAssert(ptr); return *ptr; } //!< Get data associated with key + + /// Release associated thread data + inline void cleanup() + { + TLSDataContainer::cleanup(); + } + +protected: + /// Wrapper to allocate data by template + virtual void* createDataInstance() const CV_OVERRIDE { return new T; } + /// Wrapper to release data by template + virtual void deleteDataInstance(void* pData) const CV_OVERRIDE { delete (T*)pData; } +}; + + +/// TLS data accumulator with gathering methods +template +class TLSDataAccumulator : public TLSData +{ + mutable cv::Mutex mutex; + mutable std::vector dataFromTerminatedThreads; + std::vector detachedData; + bool cleanupMode; +public: + TLSDataAccumulator() : cleanupMode(false) {} + ~TLSDataAccumulator() + { + release(); + } + + /** @brief Get data from all threads + * @deprecated replaced by detachData() + * + * Lifetime of vector data is valid until next detachData()/cleanup()/release() calls + * + * @param[out] data result buffer (should be empty) + */ + void gather(std::vector &data) const + { + CV_Assert(cleanupMode == false); // state is not valid + CV_Assert(data.empty()); + { + std::vector &dataVoid = reinterpret_cast&>(data); + TLSDataContainer::gatherData(dataVoid); + } + { + AutoLock lock(mutex); + data.reserve(data.size() + dataFromTerminatedThreads.size()); + for (typename std::vector::const_iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i) + { + data.push_back((T*)*i); + } + } + } + + /** @brief Get and detach data from all threads + * + * Call cleanupDetachedData() when returned vector is not needed anymore. + * + * @return Vector with associated data. Content is preserved (including lifetime of attached data pointers) until next detachData()/cleanupDetachedData()/cleanup()/release() calls + */ + std::vector& detachData() + { + CV_Assert(cleanupMode == false); // state is not valid + std::vector dataVoid; + { + TLSDataContainer::detachData(dataVoid); + } + { + AutoLock lock(mutex); + detachedData.reserve(dataVoid.size() + dataFromTerminatedThreads.size()); + for (typename std::vector::const_iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i) + { + detachedData.push_back((T*)*i); + } + dataFromTerminatedThreads.clear(); + for (typename std::vector::const_iterator i = dataVoid.begin(); i != dataVoid.end(); ++i) + { + detachedData.push_back((T*)(void*)*i); + } + } + dataVoid.clear(); + return detachedData; + } + + /// Release associated thread data returned by detachData() call + void cleanupDetachedData() + { + AutoLock lock(mutex); + cleanupMode = true; + _cleanupDetachedData(); + cleanupMode = false; + } + + /// Release associated thread data + void cleanup() + { + cleanupMode = true; + TLSDataContainer::cleanup(); + + AutoLock lock(mutex); + _cleanupDetachedData(); + _cleanupTerminatedData(); + cleanupMode = false; + } + + /// Release associated thread data and free TLS key + void release() + { + cleanupMode = true; + TLSDataContainer::release(); + { + AutoLock lock(mutex); + _cleanupDetachedData(); + _cleanupTerminatedData(); + } + } + +protected: + // synchronized + void _cleanupDetachedData() + { + for (typename std::vector::iterator i = detachedData.begin(); i != detachedData.end(); ++i) + { + deleteDataInstance((T*)*i); + } + detachedData.clear(); + } + + // synchronized + void _cleanupTerminatedData() + { + for (typename std::vector::iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i) + { + deleteDataInstance((T*)*i); + } + dataFromTerminatedThreads.clear(); + } + +protected: + virtual void* createDataInstance() const CV_OVERRIDE + { + // Note: we can collect all allocated data here, but this would require raced mutex locks + return new T; + } + virtual void deleteDataInstance(void* pData) const CV_OVERRIDE + { + if (cleanupMode) + { + delete (T*)pData; + } + else + { + AutoLock lock(mutex); + dataFromTerminatedThreads.push_back((T*)pData); + } + } +}; + + +//! @} + +} // namespace + +#endif // OPENCV_UTILS_TLS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/utils/trace.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/trace.hpp new file mode 100644 index 0000000..ef5d35b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/utils/trace.hpp @@ -0,0 +1,252 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_TRACE_HPP +#define OPENCV_TRACE_HPP + +#include + +namespace cv { +namespace utils { +namespace trace { + +//! @addtogroup core_logging +//! @{ + +//! Macro to trace function +#define CV_TRACE_FUNCTION() + +#define CV_TRACE_FUNCTION_SKIP_NESTED() + +//! Trace code scope. +//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "initialize". +#define CV_TRACE_REGION(name_as_static_string_literal) +//! mark completed of the current opened region and create new one +//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "step1". +#define CV_TRACE_REGION_NEXT(name_as_static_string_literal) + +//! Macro to trace argument value +#define CV_TRACE_ARG(arg_id) + +//! Macro to trace argument value (expanded version) +#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) + +//! @cond IGNORED +#define CV_TRACE_NS cv::utils::trace + +#if !defined(OPENCV_DISABLE_TRACE) && defined(__EMSCRIPTEN__) +#define OPENCV_DISABLE_TRACE 1 +#endif + +namespace details { + +#ifndef __OPENCV_TRACE +# if defined __OPENCV_BUILD && !defined __OPENCV_TESTS && !defined __OPENCV_APPS +# define __OPENCV_TRACE 1 +# else +# define __OPENCV_TRACE 0 +# endif +#endif + +#ifndef CV_TRACE_FILENAME +# define CV_TRACE_FILENAME __FILE__ +#endif + +#ifndef CV__TRACE_FUNCTION +# if defined _MSC_VER +# define CV__TRACE_FUNCTION __FUNCSIG__ +# elif defined __GNUC__ +# define CV__TRACE_FUNCTION __PRETTY_FUNCTION__ +# else +# define CV__TRACE_FUNCTION "" +# endif +#endif + +//! Thread-local instance (usually allocated on stack) +class CV_EXPORTS Region +{ +public: + struct LocationExtraData; + struct LocationStaticStorage + { + LocationExtraData** ppExtra; //< implementation specific data + const char* name; //< region name (function name or other custom name) + const char* filename; //< source code filename + int line; //< source code line + int flags; //< flags (implementation code path: Plain, IPP, OpenCL) + }; + + Region(const LocationStaticStorage& location); + inline ~Region() + { + if (implFlags != 0) + destroy(); + CV_DbgAssert(implFlags == 0); + CV_DbgAssert(pImpl == NULL); + } + + class Impl; + Impl* pImpl; // NULL if current region is not active + int implFlags; // see RegionFlag, 0 if region is ignored + + bool isActive() const { return pImpl != NULL; } + + void destroy(); +private: + Region(const Region&); // disabled + Region& operator= (const Region&); // disabled +}; + +//! Specify region flags +enum RegionLocationFlag { + REGION_FLAG_FUNCTION = (1 << 0), //< region is function (=1) / nested named region (=0) + REGION_FLAG_APP_CODE = (1 << 1), //< region is Application code (=1) / OpenCV library code (=0) + REGION_FLAG_SKIP_NESTED = (1 << 2), //< avoid processing of nested regions + + REGION_FLAG_IMPL_IPP = (1 << 16), //< region is part of IPP code path + REGION_FLAG_IMPL_OPENCL = (2 << 16), //< region is part of OpenCL code path + REGION_FLAG_IMPL_OPENVX = (3 << 16), //< region is part of OpenVX code path + + REGION_FLAG_IMPL_MASK = (15 << 16), + + REGION_FLAG_REGION_FORCE = (1 << 30), + REGION_FLAG_REGION_NEXT = (1 << 31), //< close previous region (see #CV_TRACE_REGION_NEXT macro) + + ENUM_REGION_FLAG_FORCE_INT = INT_MAX +}; + +struct CV_EXPORTS TraceArg { +public: + struct ExtraData; + ExtraData** ppExtra; + const char* name; + int flags; +}; +/** @brief Add meta information to current region (function) + * See CV_TRACE_ARG macro + * @param arg argument information structure (global static cache) + * @param value argument value (can by dynamic string literal in case of string, static allocation is not required) + */ +CV_EXPORTS void traceArg(const TraceArg& arg, const char* value); +//! @overload +CV_EXPORTS void traceArg(const TraceArg& arg, int value); +//! @overload +CV_EXPORTS void traceArg(const TraceArg& arg, int64 value); +//! @overload +CV_EXPORTS void traceArg(const TraceArg& arg, double value); + +#define CV__TRACE_LOCATION_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_, loc_id), __LINE__) +#define CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_extra_, loc_id) , __LINE__) + +#define CV__TRACE_DEFINE_LOCATION_(loc_id, name, flags) \ + static CV_TRACE_NS::details::Region::LocationExtraData* CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) = 0; \ + static const CV_TRACE_NS::details::Region::LocationStaticStorage \ + CV__TRACE_LOCATION_VARNAME(loc_id) = { &(CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id)), name, CV_TRACE_FILENAME, __LINE__, flags}; + +#define CV__TRACE_DEFINE_LOCATION_FN(name, flags) CV__TRACE_DEFINE_LOCATION_(fn, name, ((flags) | CV_TRACE_NS::details::REGION_FLAG_FUNCTION)) + + +#define CV__TRACE_OPENCV_FUNCTION() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, 0); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_OPENCV_FUNCTION_NAME(name) \ + CV__TRACE_DEFINE_LOCATION_FN(name, 0); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_APP_FUNCTION() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_APP_FUNCTION_NAME(name) \ + CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + + +#define CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_OPENCV_FUNCTION_NAME_SKIP_NESTED(name) \ + CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_APP_FUNCTION_SKIP_NESTED() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED | CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + + +#define CV__TRACE_REGION_(name_as_static_string_literal, flags) \ + CV__TRACE_DEFINE_LOCATION_(region, name_as_static_string_literal, flags); \ + CV_TRACE_NS::details::Region CVAUX_CONCAT(__region_, __LINE__)(CV__TRACE_LOCATION_VARNAME(region)); + +#define CV__TRACE_REGION(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, 0) +#define CV__TRACE_REGION_NEXT(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, CV_TRACE_NS::details::REGION_FLAG_REGION_NEXT) + +#define CV__TRACE_ARG_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_ ## arg_id, __LINE__) +#define CV__TRACE_ARG_EXTRA_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_extra_ ## arg_id, __LINE__) + +#define CV__TRACE_DEFINE_ARG_(arg_id, name, flags) \ + static CV_TRACE_NS::details::TraceArg::ExtraData* CV__TRACE_ARG_EXTRA_VARNAME(arg_id) = 0; \ + static const CV_TRACE_NS::details::TraceArg \ + CV__TRACE_ARG_VARNAME(arg_id) = { &(CV__TRACE_ARG_EXTRA_VARNAME(arg_id)), name, flags }; + +#define CV__TRACE_ARG_VALUE(arg_id, arg_name, value) \ + CV__TRACE_DEFINE_ARG_(arg_id, arg_name, 0); \ + CV_TRACE_NS::details::traceArg((CV__TRACE_ARG_VARNAME(arg_id)), value); + +#define CV__TRACE_ARG(arg_id) CV_TRACE_ARG_VALUE(arg_id, #arg_id, (arg_id)) + +} // namespace + +#ifndef OPENCV_DISABLE_TRACE +#undef CV_TRACE_FUNCTION +#undef CV_TRACE_FUNCTION_SKIP_NESTED +#if __OPENCV_TRACE +#define CV_TRACE_FUNCTION CV__TRACE_OPENCV_FUNCTION +#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED +#else +#define CV_TRACE_FUNCTION CV__TRACE_APP_FUNCTION +#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_APP_FUNCTION_SKIP_NESTED +#endif + +#undef CV_TRACE_REGION +#define CV_TRACE_REGION CV__TRACE_REGION + +#undef CV_TRACE_REGION_NEXT +#define CV_TRACE_REGION_NEXT CV__TRACE_REGION_NEXT + +#undef CV_TRACE_ARG_VALUE +#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) \ + if (__region_fn.isActive()) \ + { \ + CV__TRACE_ARG_VALUE(arg_id, arg_name, value); \ + } + +#undef CV_TRACE_ARG +#define CV_TRACE_ARG CV__TRACE_ARG + +#endif // OPENCV_DISABLE_TRACE + +#ifdef OPENCV_TRACE_VERBOSE +#define CV_TRACE_FUNCTION_VERBOSE CV_TRACE_FUNCTION +#define CV_TRACE_REGION_VERBOSE CV_TRACE_REGION +#define CV_TRACE_REGION_NEXT_VERBOSE CV_TRACE_REGION_NEXT +#define CV_TRACE_ARG_VALUE_VERBOSE CV_TRACE_ARG_VALUE +#define CV_TRACE_ARG_VERBOSE CV_TRACE_ARG +#else +#define CV_TRACE_FUNCTION_VERBOSE(...) +#define CV_TRACE_REGION_VERBOSE(...) +#define CV_TRACE_REGION_NEXT_VERBOSE(...) +#define CV_TRACE_ARG_VALUE_VERBOSE(...) +#define CV_TRACE_ARG_VERBOSE(...) +#endif + +//! @endcond + +//! @} + +}}} // namespace + +#endif // OPENCV_TRACE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/va_intel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/va_intel.hpp new file mode 100644 index 0000000..b37ce75 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/va_intel.hpp @@ -0,0 +1,75 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2015, Itseez, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_CORE_VA_INTEL_HPP +#define OPENCV_CORE_VA_INTEL_HPP + +#ifndef __cplusplus +# error va_intel.hpp header must be compiled as C++ +#endif + +#include "opencv2/core.hpp" +#include "ocl.hpp" + +#if defined(HAVE_VA) +# include "va/va.h" +#else // HAVE_VA +# if !defined(_VA_H_) + typedef void* VADisplay; + typedef unsigned int VASurfaceID; +# endif // !_VA_H_ +#endif // HAVE_VA + +namespace cv { namespace va_intel { + +/** @addtogroup core_va_intel +This section describes Intel VA-API/OpenCL (CL-VA) interoperability. + +To enable basic VA interoperability build OpenCV with libva library integration enabled: `-DWITH_VA=ON` (corresponding dev package should be installed). + +To enable advanced CL-VA interoperability support on Intel HW, enable option: `-DWITH_VA_INTEL=ON` (OpenCL integration should be enabled which is the default setting). Special runtime environment should be set up in order to use this feature: correct combination of [libva](https://github.com/intel/libva), [OpenCL runtime](https://github.com/intel/compute-runtime) and [media driver](https://github.com/intel/media-driver) should be installed. + +Check usage example for details: samples/va_intel/va_intel_interop.cpp +*/ +//! @{ + +/////////////////// CL-VA Interoperability Functions /////////////////// + +namespace ocl { +using namespace cv::ocl; + +// TODO static functions in the Context class +/** @brief Creates OpenCL context from VA. +@param display - VADisplay for which CL interop should be established. +@param tryInterop - try to set up for interoperability, if true; set up for use slow copy if false. +@return Returns reference to OpenCL Context + */ +CV_EXPORTS Context& initializeContextFromVA(VADisplay display, bool tryInterop = true); + +} // namespace cv::va_intel::ocl + +/** @brief Converts InputArray to VASurfaceID object. +@param display - VADisplay object. +@param src - source InputArray. +@param surface - destination VASurfaceID object. +@param size - size of image represented by VASurfaceID object. + */ +CV_EXPORTS void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size); + +/** @brief Converts VASurfaceID object to OutputArray. +@param display - VADisplay object. +@param surface - source VASurfaceID object. +@param size - size of image represented by VASurfaceID object. +@param dst - destination OutputArray. + */ +CV_EXPORTS void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, OutputArray dst); + +//! @} + +}} // namespace cv::va_intel + +#endif /* OPENCV_CORE_VA_INTEL_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/version.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/version.hpp new file mode 100644 index 0000000..2fbd499 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/version.hpp @@ -0,0 +1,26 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VERSION_HPP +#define OPENCV_VERSION_HPP + +#define CV_VERSION_MAJOR 4 +#define CV_VERSION_MINOR 5 +#define CV_VERSION_REVISION 5 +#define CV_VERSION_STATUS "" + +#define CVAUX_STR_EXP(__A) #__A +#define CVAUX_STR(__A) CVAUX_STR_EXP(__A) + +#define CVAUX_STRW_EXP(__A) L ## #__A +#define CVAUX_STRW(__A) CVAUX_STRW_EXP(__A) + +#define CV_VERSION CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS + +/* old style version constants*/ +#define CV_MAJOR_VERSION CV_VERSION_MAJOR +#define CV_MINOR_VERSION CV_VERSION_MINOR +#define CV_SUBMINOR_VERSION CV_VERSION_REVISION + +#endif // OPENCV_VERSION_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/core/vsx_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/core/vsx_utils.hpp new file mode 100644 index 0000000..68863ff --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/core/vsx_utils.hpp @@ -0,0 +1,1042 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_VSX_UTILS_HPP +#define OPENCV_HAL_VSX_UTILS_HPP + +#include "opencv2/core/cvdef.h" + +#ifndef SKIP_INCLUDES +# include +#endif + +//! @addtogroup core_utils_vsx +//! @{ +#if CV_VSX + +#define __VSX_S16__(c, v) (c){v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, v} +#define __VSX_S8__(c, v) (c){v, v, v, v, v, v, v, v} +#define __VSX_S4__(c, v) (c){v, v, v, v} +#define __VSX_S2__(c, v) (c){v, v} + +typedef __vector unsigned char vec_uchar16; +#define vec_uchar16_set(...) (vec_uchar16){__VA_ARGS__} +#define vec_uchar16_sp(c) (__VSX_S16__(vec_uchar16, (unsigned char)c)) +#define vec_uchar16_c(v) ((vec_uchar16)(v)) +#define vec_uchar16_z vec_uchar16_sp(0) + +typedef __vector signed char vec_char16; +#define vec_char16_set(...) (vec_char16){__VA_ARGS__} +#define vec_char16_sp(c) (__VSX_S16__(vec_char16, (signed char)c)) +#define vec_char16_c(v) ((vec_char16)(v)) +#define vec_char16_z vec_char16_sp(0) + +typedef __vector unsigned short vec_ushort8; +#define vec_ushort8_set(...) (vec_ushort8){__VA_ARGS__} +#define vec_ushort8_sp(c) (__VSX_S8__(vec_ushort8, (unsigned short)c)) +#define vec_ushort8_c(v) ((vec_ushort8)(v)) +#define vec_ushort8_z vec_ushort8_sp(0) + +typedef __vector signed short vec_short8; +#define vec_short8_set(...) (vec_short8){__VA_ARGS__} +#define vec_short8_sp(c) (__VSX_S8__(vec_short8, (signed short)c)) +#define vec_short8_c(v) ((vec_short8)(v)) +#define vec_short8_z vec_short8_sp(0) + +typedef __vector unsigned int vec_uint4; +#define vec_uint4_set(...) (vec_uint4){__VA_ARGS__} +#define vec_uint4_sp(c) (__VSX_S4__(vec_uint4, (unsigned int)c)) +#define vec_uint4_c(v) ((vec_uint4)(v)) +#define vec_uint4_z vec_uint4_sp(0) + +typedef __vector signed int vec_int4; +#define vec_int4_set(...) (vec_int4){__VA_ARGS__} +#define vec_int4_sp(c) (__VSX_S4__(vec_int4, (signed int)c)) +#define vec_int4_c(v) ((vec_int4)(v)) +#define vec_int4_z vec_int4_sp(0) + +typedef __vector float vec_float4; +#define vec_float4_set(...) (vec_float4){__VA_ARGS__} +#define vec_float4_sp(c) (__VSX_S4__(vec_float4, c)) +#define vec_float4_c(v) ((vec_float4)(v)) +#define vec_float4_z vec_float4_sp(0) + +typedef __vector unsigned long long vec_udword2; +#define vec_udword2_set(...) (vec_udword2){__VA_ARGS__} +#define vec_udword2_sp(c) (__VSX_S2__(vec_udword2, (unsigned long long)c)) +#define vec_udword2_c(v) ((vec_udword2)(v)) +#define vec_udword2_z vec_udword2_sp(0) + +typedef __vector signed long long vec_dword2; +#define vec_dword2_set(...) (vec_dword2){__VA_ARGS__} +#define vec_dword2_sp(c) (__VSX_S2__(vec_dword2, (signed long long)c)) +#define vec_dword2_c(v) ((vec_dword2)(v)) +#define vec_dword2_z vec_dword2_sp(0) + +typedef __vector double vec_double2; +#define vec_double2_set(...) (vec_double2){__VA_ARGS__} +#define vec_double2_c(v) ((vec_double2)(v)) +#define vec_double2_sp(c) (__VSX_S2__(vec_double2, c)) +#define vec_double2_z vec_double2_sp(0) + +#define vec_bchar16 __vector __bool char +#define vec_bchar16_set(...) (vec_bchar16){__VA_ARGS__} +#define vec_bchar16_c(v) ((vec_bchar16)(v)) + +#define vec_bshort8 __vector __bool short +#define vec_bshort8_set(...) (vec_bshort8){__VA_ARGS__} +#define vec_bshort8_c(v) ((vec_bshort8)(v)) + +#define vec_bint4 __vector __bool int +#define vec_bint4_set(...) (vec_bint4){__VA_ARGS__} +#define vec_bint4_c(v) ((vec_bint4)(v)) + +#define vec_bdword2 __vector __bool long long +#define vec_bdword2_set(...) (vec_bdword2){__VA_ARGS__} +#define vec_bdword2_c(v) ((vec_bdword2)(v)) + +#define VSX_FINLINE(tp) extern inline tp __attribute__((always_inline)) + +#define VSX_REDIRECT_1RG(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) { return fn2(a); } + +#define VSX_REDIRECT_2RG(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a, const rg& b) { return fn2(a, b); } + +/* + * GCC VSX compatibility +**/ +#if defined(__GNUG__) && !defined(__clang__) + +// inline asm helper +#define VSX_IMPL_1RG(rt, rg, opc, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ rt rs; __asm__ __volatile__(#opc" %x0,%x1" : "=wa" (rs) : "wa" (a)); return rs; } + +#define VSX_IMPL_1VRG(rt, rg, opc, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ rt rs; __asm__ __volatile__(#opc" %0,%1" : "=v" (rs) : "v" (a)); return rs; } + +#define VSX_IMPL_2VRG_F(rt, rg, fopc, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a, const rg& b) \ +{ rt rs; __asm__ __volatile__(fopc : "=v" (rs) : "v" (a), "v" (b)); return rs; } + +#define VSX_IMPL_2VRG(rt, rg, opc, fnm) VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%1,%2", fnm) + +#if __GNUG__ < 8 + + // Support for int4 -> dword2 expanding multiply was added in GCC 8. + #ifdef vec_mule + #undef vec_mule + #endif + #ifdef vec_mulo + #undef vec_mulo + #endif + + VSX_REDIRECT_2RG(vec_ushort8, vec_uchar16, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_short8, vec_char16, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_int4, vec_short8, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_uint4, vec_ushort8, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_ushort8, vec_uchar16, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_short8, vec_char16, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_int4, vec_short8, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_uint4, vec_ushort8, vec_mulo, __builtin_vec_mulo) + + // dword2 support arrived in ISA 2.07 and GCC 8+ + VSX_IMPL_2VRG(vec_dword2, vec_int4, vmulosw, vec_mule) + VSX_IMPL_2VRG(vec_udword2, vec_uint4, vmulouw, vec_mule) + VSX_IMPL_2VRG(vec_dword2, vec_int4, vmulesw, vec_mulo) + VSX_IMPL_2VRG(vec_udword2, vec_uint4, vmuleuw, vec_mulo) + +#endif + +#if __GNUG__ < 7 +// up to GCC 6 vec_mul only supports precisions and llong +# ifdef vec_mul +# undef vec_mul +# endif +/* + * there's no a direct instruction for supporting 8-bit, 16-bit multiplication in ISA 2.07, + * XLC Implement it by using instruction "multiply even", "multiply odd" and "permute" +**/ +# define VSX_IMPL_MULH(Tvec, cperm) \ + VSX_FINLINE(Tvec) vec_mul(const Tvec& a, const Tvec& b) \ + { \ + static const vec_uchar16 ev_od = {cperm}; \ + return vec_perm((Tvec)vec_mule(a, b), (Tvec)vec_mulo(a, b), ev_od); \ + } + #define VSX_IMPL_MULH_P16 0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30 + VSX_IMPL_MULH(vec_char16, VSX_IMPL_MULH_P16) + VSX_IMPL_MULH(vec_uchar16, VSX_IMPL_MULH_P16) + #define VSX_IMPL_MULH_P8 0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29 + VSX_IMPL_MULH(vec_short8, VSX_IMPL_MULH_P8) + VSX_IMPL_MULH(vec_ushort8, VSX_IMPL_MULH_P8) + // vmuluwm can be used for unsigned or signed integers, that's what they said + VSX_IMPL_2VRG(vec_int4, vec_int4, vmuluwm, vec_mul) + VSX_IMPL_2VRG(vec_uint4, vec_uint4, vmuluwm, vec_mul) + // redirect to GCC builtin vec_mul, since it already supports precisions and llong + VSX_REDIRECT_2RG(vec_float4, vec_float4, vec_mul, __builtin_vec_mul) + VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mul, __builtin_vec_mul) + VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mul, __builtin_vec_mul) + VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mul, __builtin_vec_mul) +#endif // __GNUG__ < 7 + +#if __GNUG__ < 6 +/* + * Instruction "compare greater than or equal" in ISA 2.07 only supports single + * and double precision. + * In XLC and new versions of GCC implement integers by using instruction "greater than" and NOR. +**/ +# ifdef vec_cmpge +# undef vec_cmpge +# endif +# ifdef vec_cmple +# undef vec_cmple +# endif +# define vec_cmple(a, b) vec_cmpge(b, a) +# define VSX_IMPL_CMPGE(rt, rg, opc, fnm) \ + VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%2,%1\n\t xxlnor %x0,%x0,%x0", fnm) + + VSX_IMPL_CMPGE(vec_bchar16, vec_char16, vcmpgtsb, vec_cmpge) + VSX_IMPL_CMPGE(vec_bchar16, vec_uchar16, vcmpgtub, vec_cmpge) + VSX_IMPL_CMPGE(vec_bshort8, vec_short8, vcmpgtsh, vec_cmpge) + VSX_IMPL_CMPGE(vec_bshort8, vec_ushort8, vcmpgtuh, vec_cmpge) + VSX_IMPL_CMPGE(vec_bint4, vec_int4, vcmpgtsw, vec_cmpge) + VSX_IMPL_CMPGE(vec_bint4, vec_uint4, vcmpgtuw, vec_cmpge) + VSX_IMPL_CMPGE(vec_bdword2, vec_dword2, vcmpgtsd, vec_cmpge) + VSX_IMPL_CMPGE(vec_bdword2, vec_udword2, vcmpgtud, vec_cmpge) + +// redirect to GCC builtin cmpge, since it already supports precisions + VSX_REDIRECT_2RG(vec_bint4, vec_float4, vec_cmpge, __builtin_vec_cmpge) + VSX_REDIRECT_2RG(vec_bdword2, vec_double2, vec_cmpge, __builtin_vec_cmpge) + +// up to gcc5 vec_nor doesn't support bool long long +# undef vec_nor + template + VSX_REDIRECT_2RG(T, T, vec_nor, __builtin_vec_nor) + + VSX_FINLINE(vec_bdword2) vec_nor(const vec_bdword2& a, const vec_bdword2& b) + { return vec_bdword2_c(__builtin_vec_nor(vec_dword2_c(a), vec_dword2_c(b))); } + +// vec_packs doesn't support double words in gcc4 and old versions of gcc5 +# undef vec_packs + VSX_REDIRECT_2RG(vec_char16, vec_short8, vec_packs, __builtin_vec_packs) + VSX_REDIRECT_2RG(vec_uchar16, vec_ushort8, vec_packs, __builtin_vec_packs) + VSX_REDIRECT_2RG(vec_short8, vec_int4, vec_packs, __builtin_vec_packs) + VSX_REDIRECT_2RG(vec_ushort8, vec_uint4, vec_packs, __builtin_vec_packs) + + VSX_IMPL_2VRG_F(vec_int4, vec_dword2, "vpksdss %0,%2,%1", vec_packs) + VSX_IMPL_2VRG_F(vec_uint4, vec_udword2, "vpkudus %0,%2,%1", vec_packs) +#endif // __GNUG__ < 6 + +#if __GNUG__ < 5 +// vec_xxpermdi in gcc4 missing little-endian supports just like clang +# define vec_permi(a, b, c) vec_xxpermdi(b, a, (3 ^ (((c) & 1) << 1 | (c) >> 1))) +// same as vec_xxpermdi +# undef vec_vbpermq + VSX_IMPL_2VRG(vec_udword2, vec_uchar16, vbpermq, vec_vbpermq) + VSX_IMPL_2VRG(vec_dword2, vec_char16, vbpermq, vec_vbpermq) +#else +# define vec_permi vec_xxpermdi +#endif // __GNUG__ < 5 + +// shift left double by word immediate +#ifndef vec_sldw +# define vec_sldw __builtin_vsx_xxsldwi +#endif + +// vector population count +VSX_IMPL_1VRG(vec_uchar16, vec_uchar16, vpopcntb, vec_popcntu) +VSX_IMPL_1VRG(vec_uchar16, vec_char16, vpopcntb, vec_popcntu) +VSX_IMPL_1VRG(vec_ushort8, vec_ushort8, vpopcnth, vec_popcntu) +VSX_IMPL_1VRG(vec_ushort8, vec_short8, vpopcnth, vec_popcntu) +VSX_IMPL_1VRG(vec_uint4, vec_uint4, vpopcntw, vec_popcntu) +VSX_IMPL_1VRG(vec_uint4, vec_int4, vpopcntw, vec_popcntu) +VSX_IMPL_1VRG(vec_udword2, vec_udword2, vpopcntd, vec_popcntu) +VSX_IMPL_1VRG(vec_udword2, vec_dword2, vpopcntd, vec_popcntu) + +// converts between single and double-precision +VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, __builtin_vsx_xvcvdpsp) +VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, __builtin_vsx_xvcvspdp) + +// converts word and doubleword to double-precision +#undef vec_ctd +VSX_IMPL_1RG(vec_double2, vec_int4, xvcvsxwdp, vec_ctdo) +VSX_IMPL_1RG(vec_double2, vec_uint4, xvcvuxwdp, vec_ctdo) +VSX_IMPL_1RG(vec_double2, vec_dword2, xvcvsxddp, vec_ctd) +VSX_IMPL_1RG(vec_double2, vec_udword2, xvcvuxddp, vec_ctd) + +// converts word and doubleword to single-precision +#undef vec_ctf +VSX_IMPL_1RG(vec_float4, vec_int4, xvcvsxwsp, vec_ctf) +VSX_IMPL_1RG(vec_float4, vec_uint4, xvcvuxwsp, vec_ctf) +VSX_IMPL_1RG(vec_float4, vec_dword2, xvcvsxdsp, vec_ctfo) +VSX_IMPL_1RG(vec_float4, vec_udword2, xvcvuxdsp, vec_ctfo) + +// converts single and double precision to signed word +#undef vec_cts +VSX_IMPL_1RG(vec_int4, vec_double2, xvcvdpsxws, vec_ctso) +VSX_IMPL_1RG(vec_int4, vec_float4, xvcvspsxws, vec_cts) + +// converts single and double precision to unsigned word +#undef vec_ctu +VSX_IMPL_1RG(vec_uint4, vec_double2, xvcvdpuxws, vec_ctuo) +VSX_IMPL_1RG(vec_uint4, vec_float4, xvcvspuxws, vec_ctu) + +// converts single and double precision to signed doubleword +#undef vec_ctsl +VSX_IMPL_1RG(vec_dword2, vec_double2, xvcvdpsxds, vec_ctsl) +VSX_IMPL_1RG(vec_dword2, vec_float4, xvcvspsxds, vec_ctslo) + +// converts single and double precision to unsigned doubleword +#undef vec_ctul +VSX_IMPL_1RG(vec_udword2, vec_double2, xvcvdpuxds, vec_ctul) +VSX_IMPL_1RG(vec_udword2, vec_float4, xvcvspuxds, vec_ctulo) + +// just in case if GCC doesn't define it +#ifndef vec_xl +# define vec_xl vec_vsx_ld +# define vec_xst vec_vsx_st +#endif + +#endif // GCC VSX compatibility + +/* + * CLANG VSX compatibility +**/ +#if defined(__clang__) && !defined(__IBMCPP__) + +/* + * CLANG doesn't support %x in the inline asm template which fixes register number + * when using any of the register constraints wa, wd, wf + * + * For more explanation checkout PowerPC and IBM RS6000 in https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html + * Also there's already an open bug https://bugs.llvm.org/show_bug.cgi?id=31837 + * + * So we're not able to use inline asm and only use built-in functions that CLANG supports + * and use __builtin_convertvector if clang missing any of vector conversions built-in functions + * + * todo: clang asm template bug is fixed, need to reconsider the current workarounds. +*/ + +// convert vector helper +#define VSX_IMPL_CONVERT(rt, rg, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) { return __builtin_convertvector(a, rt); } + +#if __clang_major__ < 5 +// implement vec_permi in a dirty way +# define VSX_IMPL_CLANG_4_PERMI(Tvec) \ + VSX_FINLINE(Tvec) vec_permi(const Tvec& a, const Tvec& b, unsigned const char c) \ + { \ + switch (c) \ + { \ + case 0: \ + return vec_mergeh(a, b); \ + case 1: \ + return vec_mergel(vec_mergeh(a, a), b); \ + case 2: \ + return vec_mergeh(vec_mergel(a, a), b); \ + default: \ + return vec_mergel(a, b); \ + } \ + } + VSX_IMPL_CLANG_4_PERMI(vec_udword2) + VSX_IMPL_CLANG_4_PERMI(vec_dword2) + VSX_IMPL_CLANG_4_PERMI(vec_double2) + +// vec_xxsldwi is missing in clang 4 +# define vec_xxsldwi(a, b, c) vec_sld(a, b, (c) * 4) +#else +// vec_xxpermdi is missing little-endian supports in clang 4 just like gcc4 +# define vec_permi(a, b, c) vec_xxpermdi(b, a, (3 ^ (((c) & 1) << 1 | (c) >> 1))) +#endif // __clang_major__ < 5 + +// shift left double by word immediate +#ifndef vec_sldw +# define vec_sldw vec_xxsldwi +#endif + +// Implement vec_rsqrt since clang only supports vec_rsqrte +#ifndef vec_rsqrt + VSX_FINLINE(vec_float4) vec_rsqrt(const vec_float4& a) + { return vec_div(vec_float4_sp(1), vec_sqrt(a)); } + + VSX_FINLINE(vec_double2) vec_rsqrt(const vec_double2& a) + { return vec_div(vec_double2_sp(1), vec_sqrt(a)); } +#endif + +// vec_promote missing support for doubleword +VSX_FINLINE(vec_dword2) vec_promote(long long a, int b) +{ + vec_dword2 ret = vec_dword2_z; + ret[b & 1] = a; + return ret; +} + +VSX_FINLINE(vec_udword2) vec_promote(unsigned long long a, int b) +{ + vec_udword2 ret = vec_udword2_z; + ret[b & 1] = a; + return ret; +} + +// vec_popcnt should return unsigned but clang has different thought just like gcc in vec_vpopcnt +#define VSX_IMPL_POPCNTU(Tvec, Tvec2, ucast) \ +VSX_FINLINE(Tvec) vec_popcntu(const Tvec2& a) \ +{ return ucast(vec_popcnt(a)); } +VSX_IMPL_POPCNTU(vec_uchar16, vec_char16, vec_uchar16_c); +VSX_IMPL_POPCNTU(vec_ushort8, vec_short8, vec_ushort8_c); +VSX_IMPL_POPCNTU(vec_uint4, vec_int4, vec_uint4_c); +VSX_IMPL_POPCNTU(vec_udword2, vec_dword2, vec_udword2_c); +// redirect unsigned types +VSX_REDIRECT_1RG(vec_uchar16, vec_uchar16, vec_popcntu, vec_popcnt) +VSX_REDIRECT_1RG(vec_ushort8, vec_ushort8, vec_popcntu, vec_popcnt) +VSX_REDIRECT_1RG(vec_uint4, vec_uint4, vec_popcntu, vec_popcnt) +VSX_REDIRECT_1RG(vec_udword2, vec_udword2, vec_popcntu, vec_popcnt) + +// converts between single and double precision +VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, __builtin_vsx_xvcvdpsp) +VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, __builtin_vsx_xvcvspdp) + +// converts word and doubleword to double-precision +#ifdef vec_ctd +# undef vec_ctd +#endif +VSX_REDIRECT_1RG(vec_double2, vec_int4, vec_ctdo, __builtin_vsx_xvcvsxwdp) +VSX_REDIRECT_1RG(vec_double2, vec_uint4, vec_ctdo, __builtin_vsx_xvcvuxwdp) + +VSX_IMPL_CONVERT(vec_double2, vec_dword2, vec_ctd) +VSX_IMPL_CONVERT(vec_double2, vec_udword2, vec_ctd) + +// converts word and doubleword to single-precision +#if __clang_major__ > 4 +# undef vec_ctf +#endif +VSX_IMPL_CONVERT(vec_float4, vec_int4, vec_ctf) +VSX_IMPL_CONVERT(vec_float4, vec_uint4, vec_ctf) +VSX_REDIRECT_1RG(vec_float4, vec_dword2, vec_ctfo, __builtin_vsx_xvcvsxdsp) +VSX_REDIRECT_1RG(vec_float4, vec_udword2, vec_ctfo, __builtin_vsx_xvcvuxdsp) + +// converts single and double precision to signed word +#if __clang_major__ > 4 +# undef vec_cts +#endif +VSX_REDIRECT_1RG(vec_int4, vec_double2, vec_ctso, __builtin_vsx_xvcvdpsxws) +VSX_IMPL_CONVERT(vec_int4, vec_float4, vec_cts) + +// converts single and double precision to unsigned word +#if __clang_major__ > 4 +# undef vec_ctu +#endif +VSX_REDIRECT_1RG(vec_uint4, vec_double2, vec_ctuo, __builtin_vsx_xvcvdpuxws) +VSX_IMPL_CONVERT(vec_uint4, vec_float4, vec_ctu) + +// converts single and double precision to signed doubleword +#ifdef vec_ctsl +# undef vec_ctsl +#endif +VSX_IMPL_CONVERT(vec_dword2, vec_double2, vec_ctsl) +// __builtin_convertvector unable to convert, xvcvspsxds is missing on it +VSX_FINLINE(vec_dword2) vec_ctslo(const vec_float4& a) +{ return vec_ctsl(vec_cvfo(a)); } + +// converts single and double precision to unsigned doubleword +#ifdef vec_ctul +# undef vec_ctul +#endif +VSX_IMPL_CONVERT(vec_udword2, vec_double2, vec_ctul) +// __builtin_convertvector unable to convert, xvcvspuxds is missing on it +VSX_FINLINE(vec_udword2) vec_ctulo(const vec_float4& a) +{ return vec_ctul(vec_cvfo(a)); } + +#endif // CLANG VSX compatibility + +/* + * Common GCC, CLANG compatibility +**/ +#if defined(__GNUG__) && !defined(__IBMCPP__) + +#ifdef vec_cvf +# undef vec_cvf +#endif + +#define VSX_IMPL_CONV_EVEN_4_2(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ return fn2(vec_sldw(a, a, 1)); } + +VSX_IMPL_CONV_EVEN_4_2(vec_double2, vec_float4, vec_cvf, vec_cvfo) +VSX_IMPL_CONV_EVEN_4_2(vec_double2, vec_int4, vec_ctd, vec_ctdo) +VSX_IMPL_CONV_EVEN_4_2(vec_double2, vec_uint4, vec_ctd, vec_ctdo) + +VSX_IMPL_CONV_EVEN_4_2(vec_dword2, vec_float4, vec_ctsl, vec_ctslo) +VSX_IMPL_CONV_EVEN_4_2(vec_udword2, vec_float4, vec_ctul, vec_ctulo) + +#define VSX_IMPL_CONV_EVEN_2_4(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ \ + rt v4 = fn2(a); \ + return vec_sldw(v4, v4, 3); \ +} + +VSX_IMPL_CONV_EVEN_2_4(vec_float4, vec_double2, vec_cvf, vec_cvfo) +VSX_IMPL_CONV_EVEN_2_4(vec_float4, vec_dword2, vec_ctf, vec_ctfo) +VSX_IMPL_CONV_EVEN_2_4(vec_float4, vec_udword2, vec_ctf, vec_ctfo) + +VSX_IMPL_CONV_EVEN_2_4(vec_int4, vec_double2, vec_cts, vec_ctso) +VSX_IMPL_CONV_EVEN_2_4(vec_uint4, vec_double2, vec_ctu, vec_ctuo) + +// Only for Eigen! +/* + * changing behavior of conversion intrinsics for gcc has effect on Eigen + * so we redefine old behavior again only on gcc, clang +*/ +#if !defined(__clang__) || __clang_major__ > 4 + // ignoring second arg since Eigen only truncates toward zero +# define VSX_IMPL_CONV_2VARIANT(rt, rg, fnm, fn2) \ + VSX_FINLINE(rt) fnm(const rg& a, int only_truncate) \ + { \ + assert(only_truncate == 0); \ + CV_UNUSED(only_truncate); \ + return fn2(a); \ + } + VSX_IMPL_CONV_2VARIANT(vec_int4, vec_float4, vec_cts, vec_cts) + VSX_IMPL_CONV_2VARIANT(vec_uint4, vec_float4, vec_ctu, vec_ctu) + VSX_IMPL_CONV_2VARIANT(vec_float4, vec_int4, vec_ctf, vec_ctf) + VSX_IMPL_CONV_2VARIANT(vec_float4, vec_uint4, vec_ctf, vec_ctf) + // define vec_cts for converting double precision to signed doubleword + // which isn't compatible with xlc but its okay since Eigen only uses it for gcc + VSX_IMPL_CONV_2VARIANT(vec_dword2, vec_double2, vec_cts, vec_ctsl) +#endif // Eigen + +#endif // Common GCC, CLANG compatibility + +/* + * XLC VSX compatibility +**/ +#if defined(__IBMCPP__) + +// vector population count +#define vec_popcntu vec_popcnt + +// overload and redirect with setting second arg to zero +// since we only support conversions without the second arg +#define VSX_IMPL_OVERLOAD_Z2(rt, rg, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) { return fnm(a, 0); } + +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_int4, vec_ctd) +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_uint4, vec_ctd) +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_dword2, vec_ctd) +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_udword2, vec_ctd) + +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_int4, vec_ctf) +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_uint4, vec_ctf) +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_dword2, vec_ctf) +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_udword2, vec_ctf) + +VSX_IMPL_OVERLOAD_Z2(vec_int4, vec_double2, vec_cts) +VSX_IMPL_OVERLOAD_Z2(vec_int4, vec_float4, vec_cts) + +VSX_IMPL_OVERLOAD_Z2(vec_uint4, vec_double2, vec_ctu) +VSX_IMPL_OVERLOAD_Z2(vec_uint4, vec_float4, vec_ctu) + +VSX_IMPL_OVERLOAD_Z2(vec_dword2, vec_double2, vec_ctsl) +VSX_IMPL_OVERLOAD_Z2(vec_dword2, vec_float4, vec_ctsl) + +VSX_IMPL_OVERLOAD_Z2(vec_udword2, vec_double2, vec_ctul) +VSX_IMPL_OVERLOAD_Z2(vec_udword2, vec_float4, vec_ctul) + +// fixme: implement conversions of odd-numbered elements in a dirty way +// since xlc doesn't support VSX registers operand in inline asm. +#define VSX_IMPL_CONV_ODD_4_2(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) { return fn2(vec_sldw(a, a, 3)); } + +VSX_IMPL_CONV_ODD_4_2(vec_double2, vec_float4, vec_cvfo, vec_cvf) +VSX_IMPL_CONV_ODD_4_2(vec_double2, vec_int4, vec_ctdo, vec_ctd) +VSX_IMPL_CONV_ODD_4_2(vec_double2, vec_uint4, vec_ctdo, vec_ctd) + +VSX_IMPL_CONV_ODD_4_2(vec_dword2, vec_float4, vec_ctslo, vec_ctsl) +VSX_IMPL_CONV_ODD_4_2(vec_udword2, vec_float4, vec_ctulo, vec_ctul) + +#define VSX_IMPL_CONV_ODD_2_4(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ \ + rt v4 = fn2(a); \ + return vec_sldw(v4, v4, 1); \ +} + +VSX_IMPL_CONV_ODD_2_4(vec_float4, vec_double2, vec_cvfo, vec_cvf) +VSX_IMPL_CONV_ODD_2_4(vec_float4, vec_dword2, vec_ctfo, vec_ctf) +VSX_IMPL_CONV_ODD_2_4(vec_float4, vec_udword2, vec_ctfo, vec_ctf) + +VSX_IMPL_CONV_ODD_2_4(vec_int4, vec_double2, vec_ctso, vec_cts) +VSX_IMPL_CONV_ODD_2_4(vec_uint4, vec_double2, vec_ctuo, vec_ctu) + +#endif // XLC VSX compatibility + +// ignore GCC warning that caused by -Wunused-but-set-variable in rare cases +#if defined(__GNUG__) && !defined(__clang__) +# define VSX_UNUSED(Tvec) Tvec __attribute__((__unused__)) +#else // CLANG, XLC +# define VSX_UNUSED(Tvec) Tvec +#endif + +// gcc can find his way in casting log int and XLC, CLANG ambiguous +#if defined(__clang__) || defined(__IBMCPP__) + VSX_FINLINE(vec_udword2) vec_splats(uint64 v) + { return vec_splats((unsigned long long) v); } + + VSX_FINLINE(vec_dword2) vec_splats(int64 v) + { return vec_splats((long long) v); } + + VSX_FINLINE(vec_udword2) vec_promote(uint64 a, int b) + { return vec_promote((unsigned long long) a, b); } + + VSX_FINLINE(vec_dword2) vec_promote(int64 a, int b) + { return vec_promote((long long) a, b); } +#endif + +/* + * implement vsx_ld(offset, pointer), vsx_st(vector, offset, pointer) + * load and set using offset depend on the pointer type + * + * implement vsx_ldf(offset, pointer), vsx_stf(vector, offset, pointer) + * load and set using offset depend on fixed bytes size + * + * Note: In clang vec_xl and vec_xst fails to load unaligned addresses + * so we are using vec_vsx_ld, vec_vsx_st instead +*/ + +#if defined(__clang__) && !defined(__IBMCPP__) +# define vsx_ldf vec_vsx_ld +# define vsx_stf vec_vsx_st +#else // GCC , XLC +# define vsx_ldf vec_xl +# define vsx_stf vec_xst +#endif + +#define VSX_OFFSET(o, p) ((o) * sizeof(*(p))) +#define vsx_ld(o, p) vsx_ldf(VSX_OFFSET(o, p), p) +#define vsx_st(v, o, p) vsx_stf(v, VSX_OFFSET(o, p), p) + +/* + * implement vsx_ld2(offset, pointer), vsx_st2(vector, offset, pointer) to load and store double words + * In GCC vec_xl and vec_xst it maps to vec_vsx_ld, vec_vsx_st which doesn't support long long + * and in CLANG we are using vec_vsx_ld, vec_vsx_st because vec_xl, vec_xst fails to load unaligned addresses + * + * In XLC vec_xl and vec_xst fail to cast int64(long int) to long long +*/ +#if (defined(__GNUG__) || defined(__clang__)) && !defined(__IBMCPP__) + VSX_FINLINE(vec_udword2) vsx_ld2(long o, const uint64* p) + { return vec_udword2_c(vsx_ldf(VSX_OFFSET(o, p), (unsigned int*)p)); } + + VSX_FINLINE(vec_dword2) vsx_ld2(long o, const int64* p) + { return vec_dword2_c(vsx_ldf(VSX_OFFSET(o, p), (int*)p)); } + + VSX_FINLINE(void) vsx_st2(const vec_udword2& vec, long o, uint64* p) + { vsx_stf(vec_uint4_c(vec), VSX_OFFSET(o, p), (unsigned int*)p); } + + VSX_FINLINE(void) vsx_st2(const vec_dword2& vec, long o, int64* p) + { vsx_stf(vec_int4_c(vec), VSX_OFFSET(o, p), (int*)p); } +#else // XLC + VSX_FINLINE(vec_udword2) vsx_ld2(long o, const uint64* p) + { return vsx_ldf(VSX_OFFSET(o, p), (unsigned long long*)p); } + + VSX_FINLINE(vec_dword2) vsx_ld2(long o, const int64* p) + { return vsx_ldf(VSX_OFFSET(o, p), (long long*)p); } + + VSX_FINLINE(void) vsx_st2(const vec_udword2& vec, long o, uint64* p) + { vsx_stf(vec, VSX_OFFSET(o, p), (unsigned long long*)p); } + + VSX_FINLINE(void) vsx_st2(const vec_dword2& vec, long o, int64* p) + { vsx_stf(vec, VSX_OFFSET(o, p), (long long*)p); } +#endif + +// Store lower 8 byte +#define vec_st_l8(v, p) *((uint64*)(p)) = vec_extract(vec_udword2_c(v), 0) + +// Store higher 8 byte +#define vec_st_h8(v, p) *((uint64*)(p)) = vec_extract(vec_udword2_c(v), 1) + +// Load 64-bits of integer data to lower part +#define VSX_IMPL_LOAD_L8(Tvec, Tp) \ +VSX_FINLINE(Tvec) vec_ld_l8(const Tp *p) \ +{ return ((Tvec)vec_promote(*((uint64*)p), 0)); } + +VSX_IMPL_LOAD_L8(vec_uchar16, uchar) +VSX_IMPL_LOAD_L8(vec_char16, schar) +VSX_IMPL_LOAD_L8(vec_ushort8, ushort) +VSX_IMPL_LOAD_L8(vec_short8, short) +VSX_IMPL_LOAD_L8(vec_uint4, uint) +VSX_IMPL_LOAD_L8(vec_int4, int) +VSX_IMPL_LOAD_L8(vec_float4, float) +VSX_IMPL_LOAD_L8(vec_udword2, uint64) +VSX_IMPL_LOAD_L8(vec_dword2, int64) +VSX_IMPL_LOAD_L8(vec_double2, double) + +// logical not +#define vec_not(a) vec_nor(a, a) + +// power9 yaya +// not equal +#ifndef vec_cmpne +# define vec_cmpne(a, b) vec_not(vec_cmpeq(a, b)) +#endif + +// absolute difference +#ifndef vec_absd +# define vec_absd(a, b) vec_sub(vec_max(a, b), vec_min(a, b)) +#endif + +/* + * Implement vec_unpacklu and vec_unpackhu + * since vec_unpackl, vec_unpackh only support signed integers +**/ +#define VSX_IMPL_UNPACKU(rt, rg, zero) \ +VSX_FINLINE(rt) vec_unpacklu(const rg& a) \ +{ return (rt)(vec_mergel(a, zero)); } \ +VSX_FINLINE(rt) vec_unpackhu(const rg& a) \ +{ return (rt)(vec_mergeh(a, zero)); } + +VSX_IMPL_UNPACKU(vec_ushort8, vec_uchar16, vec_uchar16_z) +VSX_IMPL_UNPACKU(vec_uint4, vec_ushort8, vec_ushort8_z) +VSX_IMPL_UNPACKU(vec_udword2, vec_uint4, vec_uint4_z) + +/* + * Implement vec_mergesqe and vec_mergesqo + * Merges the sequence values of even and odd elements of two vectors +*/ +#define VSX_IMPL_PERM(rt, fnm, ...) \ +VSX_FINLINE(rt) fnm(const rt& a, const rt& b) \ +{ static const vec_uchar16 perm = {__VA_ARGS__}; return vec_perm(a, b, perm); } + +// 16 +#define perm16_mergesqe 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 +#define perm16_mergesqo 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 +VSX_IMPL_PERM(vec_uchar16, vec_mergesqe, perm16_mergesqe) +VSX_IMPL_PERM(vec_uchar16, vec_mergesqo, perm16_mergesqo) +VSX_IMPL_PERM(vec_char16, vec_mergesqe, perm16_mergesqe) +VSX_IMPL_PERM(vec_char16, vec_mergesqo, perm16_mergesqo) +// 8 +#define perm8_mergesqe 0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29 +#define perm8_mergesqo 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 +VSX_IMPL_PERM(vec_ushort8, vec_mergesqe, perm8_mergesqe) +VSX_IMPL_PERM(vec_ushort8, vec_mergesqo, perm8_mergesqo) +VSX_IMPL_PERM(vec_short8, vec_mergesqe, perm8_mergesqe) +VSX_IMPL_PERM(vec_short8, vec_mergesqo, perm8_mergesqo) +// 4 +#define perm4_mergesqe 0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27 +#define perm4_mergesqo 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31 +VSX_IMPL_PERM(vec_uint4, vec_mergesqe, perm4_mergesqe) +VSX_IMPL_PERM(vec_uint4, vec_mergesqo, perm4_mergesqo) +VSX_IMPL_PERM(vec_int4, vec_mergesqe, perm4_mergesqe) +VSX_IMPL_PERM(vec_int4, vec_mergesqo, perm4_mergesqo) +VSX_IMPL_PERM(vec_float4, vec_mergesqe, perm4_mergesqe) +VSX_IMPL_PERM(vec_float4, vec_mergesqo, perm4_mergesqo) +// 2 +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqe, vec_mergeh) +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqo, vec_mergel) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqe, vec_mergeh) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqo, vec_mergel) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqe, vec_mergeh) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqo, vec_mergel) + +/* + * Implement vec_mergesqh and vec_mergesql + * Merges the sequence most and least significant halves of two vectors +*/ +#define VSX_IMPL_MERGESQHL(Tvec) \ +VSX_FINLINE(Tvec) vec_mergesqh(const Tvec& a, const Tvec& b) \ +{ return (Tvec)vec_mergeh(vec_udword2_c(a), vec_udword2_c(b)); } \ +VSX_FINLINE(Tvec) vec_mergesql(const Tvec& a, const Tvec& b) \ +{ return (Tvec)vec_mergel(vec_udword2_c(a), vec_udword2_c(b)); } +VSX_IMPL_MERGESQHL(vec_uchar16) +VSX_IMPL_MERGESQHL(vec_char16) +VSX_IMPL_MERGESQHL(vec_ushort8) +VSX_IMPL_MERGESQHL(vec_short8) +VSX_IMPL_MERGESQHL(vec_uint4) +VSX_IMPL_MERGESQHL(vec_int4) +VSX_IMPL_MERGESQHL(vec_float4) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqh, vec_mergeh) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesql, vec_mergel) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqh, vec_mergeh) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesql, vec_mergel) +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqh, vec_mergeh) +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesql, vec_mergel) + + +// 2 and 4 channels interleave for all types except 2 lanes +#define VSX_IMPL_ST_INTERLEAVE(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, Tp* ptr) \ +{ \ + vsx_stf(vec_mergeh(a, b), 0, ptr); \ + vsx_stf(vec_mergel(a, b), 16, ptr); \ +} \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, const Tvec& d, Tp* ptr) \ +{ \ + Tvec ac = vec_mergeh(a, c); \ + Tvec bd = vec_mergeh(b, d); \ + vsx_stf(vec_mergeh(ac, bd), 0, ptr); \ + vsx_stf(vec_mergel(ac, bd), 16, ptr); \ + ac = vec_mergel(a, c); \ + bd = vec_mergel(b, d); \ + vsx_stf(vec_mergeh(ac, bd), 32, ptr); \ + vsx_stf(vec_mergel(ac, bd), 48, ptr); \ +} +VSX_IMPL_ST_INTERLEAVE(uchar, vec_uchar16) +VSX_IMPL_ST_INTERLEAVE(schar, vec_char16) +VSX_IMPL_ST_INTERLEAVE(ushort, vec_ushort8) +VSX_IMPL_ST_INTERLEAVE(short, vec_short8) +VSX_IMPL_ST_INTERLEAVE(uint, vec_uint4) +VSX_IMPL_ST_INTERLEAVE(int, vec_int4) +VSX_IMPL_ST_INTERLEAVE(float, vec_float4) + +// 2 and 4 channels deinterleave for 16 lanes +#define VSX_IMPL_ST_DINTERLEAVE_8(Tp, Tvec) \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(16, ptr); \ + a = vec_mergesqe(v0, v1); \ + b = vec_mergesqo(v0, v1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(16, ptr); \ + Tvec v2 = vsx_ld(32, ptr); \ + Tvec v3 = vsx_ld(48, ptr); \ + Tvec m0 = vec_mergesqe(v0, v1); \ + Tvec m1 = vec_mergesqe(v2, v3); \ + a = vec_mergesqe(m0, m1); \ + c = vec_mergesqo(m0, m1); \ + m0 = vec_mergesqo(v0, v1); \ + m1 = vec_mergesqo(v2, v3); \ + b = vec_mergesqe(m0, m1); \ + d = vec_mergesqo(m0, m1); \ +} +VSX_IMPL_ST_DINTERLEAVE_8(uchar, vec_uchar16) +VSX_IMPL_ST_DINTERLEAVE_8(schar, vec_char16) + +// 2 and 4 channels deinterleave for 8 lanes +#define VSX_IMPL_ST_DINTERLEAVE_16(Tp, Tvec) \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(8, ptr); \ + a = vec_mergesqe(v0, v1); \ + b = vec_mergesqo(v0, v1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(8, ptr); \ + Tvec m0 = vec_mergeh(v0, v1); \ + Tvec m1 = vec_mergel(v0, v1); \ + Tvec ab0 = vec_mergeh(m0, m1); \ + Tvec cd0 = vec_mergel(m0, m1); \ + v0 = vsx_ld(16, ptr); \ + v1 = vsx_ld(24, ptr); \ + m0 = vec_mergeh(v0, v1); \ + m1 = vec_mergel(v0, v1); \ + Tvec ab1 = vec_mergeh(m0, m1); \ + Tvec cd1 = vec_mergel(m0, m1); \ + a = vec_mergesqh(ab0, ab1); \ + b = vec_mergesql(ab0, ab1); \ + c = vec_mergesqh(cd0, cd1); \ + d = vec_mergesql(cd0, cd1); \ +} +VSX_IMPL_ST_DINTERLEAVE_16(ushort, vec_ushort8) +VSX_IMPL_ST_DINTERLEAVE_16(short, vec_short8) + +// 2 and 4 channels deinterleave for 4 lanes +#define VSX_IMPL_ST_DINTERLEAVE_32(Tp, Tvec) \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + a = vsx_ld(0, ptr); \ + b = vsx_ld(4, ptr); \ + Tvec m0 = vec_mergeh(a, b); \ + Tvec m1 = vec_mergel(a, b); \ + a = vec_mergeh(m0, m1); \ + b = vec_mergel(m0, m1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(4, ptr); \ + Tvec v2 = vsx_ld(8, ptr); \ + Tvec v3 = vsx_ld(12, ptr); \ + Tvec m0 = vec_mergeh(v0, v2); \ + Tvec m1 = vec_mergeh(v1, v3); \ + a = vec_mergeh(m0, m1); \ + b = vec_mergel(m0, m1); \ + m0 = vec_mergel(v0, v2); \ + m1 = vec_mergel(v1, v3); \ + c = vec_mergeh(m0, m1); \ + d = vec_mergel(m0, m1); \ +} +VSX_IMPL_ST_DINTERLEAVE_32(uint, vec_uint4) +VSX_IMPL_ST_DINTERLEAVE_32(int, vec_int4) +VSX_IMPL_ST_DINTERLEAVE_32(float, vec_float4) + +// 2 and 4 channels interleave and deinterleave for 2 lanes +#define VSX_IMPL_ST_D_INTERLEAVE_64(Tp, Tvec, ld_func, st_func) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, Tp* ptr) \ +{ \ + st_func(vec_mergeh(a, b), 0, ptr); \ + st_func(vec_mergel(a, b), 2, ptr); \ +} \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, const Tvec& d, Tp* ptr) \ +{ \ + st_func(vec_mergeh(a, b), 0, ptr); \ + st_func(vec_mergeh(c, d), 2, ptr); \ + st_func(vec_mergel(a, b), 4, ptr); \ + st_func(vec_mergel(c, d), 6, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + Tvec m0 = ld_func(0, ptr); \ + Tvec m1 = ld_func(2, ptr); \ + a = vec_mergeh(m0, m1); \ + b = vec_mergel(m0, m1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = ld_func(0, ptr); \ + Tvec v1 = ld_func(2, ptr); \ + Tvec v2 = ld_func(4, ptr); \ + Tvec v3 = ld_func(6, ptr); \ + a = vec_mergeh(v0, v2); \ + b = vec_mergel(v0, v2); \ + c = vec_mergeh(v1, v3); \ + d = vec_mergel(v1, v3); \ +} +VSX_IMPL_ST_D_INTERLEAVE_64(int64, vec_dword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_D_INTERLEAVE_64(uint64, vec_udword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_D_INTERLEAVE_64(double, vec_double2, vsx_ld, vsx_st) + +/* 3 channels */ +#define VSX_IMPL_ST_INTERLEAVE_3CH_16(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + static const vec_uchar16 a12 = {0, 16, 0, 1, 17, 0, 2, 18, 0, 3, 19, 0, 4, 20, 0, 5}; \ + static const vec_uchar16 a123 = {0, 1, 16, 3, 4, 17, 6, 7, 18, 9, 10, 19, 12, 13, 20, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, a12), c, a123), 0, ptr); \ + static const vec_uchar16 b12 = {21, 0, 6, 22, 0, 7, 23, 0, 8, 24, 0, 9, 25, 0, 10, 26}; \ + static const vec_uchar16 b123 = {0, 21, 2, 3, 22, 5, 6, 23, 8, 9, 24, 11, 12, 25, 14, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, b12), c, b123), 16, ptr); \ + static const vec_uchar16 c12 = {0, 11, 27, 0, 12, 28, 0, 13, 29, 0, 14, 30, 0, 15, 31, 0}; \ + static const vec_uchar16 c123 = {26, 1, 2, 27, 4, 5, 28, 7, 8, 29, 10, 11, 30, 13, 14, 31}; \ + vsx_st(vec_perm(vec_perm(a, b, c12), c, c123), 32, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = vsx_ld(0, ptr); \ + Tvec v2 = vsx_ld(16, ptr); \ + Tvec v3 = vsx_ld(32, ptr); \ + static const vec_uchar16 a12_perm = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 a123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 17, 20, 23, 26, 29}; \ + a = vec_perm(vec_perm(v1, v2, a12_perm), v3, a123_perm); \ + static const vec_uchar16 b12_perm = {1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 b123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 18, 21, 24, 27, 30}; \ + b = vec_perm(vec_perm(v1, v2, b12_perm), v3, b123_perm); \ + static const vec_uchar16 c12_perm = {2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 0, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 c123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 19, 22, 25, 28, 31}; \ + c = vec_perm(vec_perm(v1, v2, c12_perm), v3, c123_perm); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_16(uchar, vec_uchar16) +VSX_IMPL_ST_INTERLEAVE_3CH_16(schar, vec_char16) + +#define VSX_IMPL_ST_INTERLEAVE_3CH_8(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + static const vec_uchar16 a12 = {0, 1, 16, 17, 0, 0, 2, 3, 18, 19, 0, 0, 4, 5, 20, 21}; \ + static const vec_uchar16 a123 = {0, 1, 2, 3, 16, 17, 6, 7, 8, 9, 18, 19, 12, 13, 14, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, a12), c, a123), 0, ptr); \ + static const vec_uchar16 b12 = {0, 0, 6, 7, 22, 23, 0, 0, 8, 9, 24, 25, 0, 0, 10, 11}; \ + static const vec_uchar16 b123 = {20, 21, 2, 3, 4, 5, 22, 23, 8, 9, 10, 11, 24, 25, 14, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, b12), c, b123), 8, ptr); \ + static const vec_uchar16 c12 = {26, 27, 0, 0, 12, 13, 28, 29, 0, 0, 14, 15, 30, 31, 0, 0}; \ + static const vec_uchar16 c123 = {0, 1, 26, 27, 4, 5, 6, 7, 28, 29, 10, 11, 12, 13, 30, 31}; \ + vsx_st(vec_perm(vec_perm(a, b, c12), c, c123), 16, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = vsx_ld(0, ptr); \ + Tvec v2 = vsx_ld(8, ptr); \ + Tvec v3 = vsx_ld(16, ptr); \ + static const vec_uchar16 a12_perm = {0, 1, 6, 7, 12, 13, 18, 19, 24, 25, 30, 31, 0, 0, 0, 0}; \ + static const vec_uchar16 a123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 26, 27}; \ + a = vec_perm(vec_perm(v1, v2, a12_perm), v3, a123_perm); \ + static const vec_uchar16 b12_perm = {2, 3, 8, 9, 14, 15, 20, 21, 26, 27, 0, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 b123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 22, 23, 28, 29}; \ + b = vec_perm(vec_perm(v1, v2, b12_perm), v3, b123_perm); \ + static const vec_uchar16 c12_perm = {4, 5, 10, 11, 16, 17, 22, 23, 28, 29, 0, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 c123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 19, 24, 25, 30, 31}; \ + c = vec_perm(vec_perm(v1, v2, c12_perm), v3, c123_perm); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_8(ushort, vec_ushort8) +VSX_IMPL_ST_INTERLEAVE_3CH_8(short, vec_short8) + +#define VSX_IMPL_ST_INTERLEAVE_3CH_4(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + Tvec hbc = vec_mergeh(b, c); \ + static const vec_uchar16 ahbc = {0, 1, 2, 3, 16, 17, 18, 19, 20, 21, 22, 23, 4, 5, 6, 7}; \ + vsx_st(vec_perm(a, hbc, ahbc), 0, ptr); \ + Tvec lab = vec_mergel(a, b); \ + vsx_st(vec_sld(lab, hbc, 8), 4, ptr); \ + static const vec_uchar16 clab = {8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 12, 13, 14, 15};\ + vsx_st(vec_perm(c, lab, clab), 8, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = vsx_ld(0, ptr); \ + Tvec v2 = vsx_ld(4, ptr); \ + Tvec v3 = vsx_ld(8, ptr); \ + static const vec_uchar16 flp = {0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31}; \ + a = vec_perm(v1, vec_sld(v3, v2, 8), flp); \ + static const vec_uchar16 flp2 = {28, 29, 30, 31, 0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19}; \ + b = vec_perm(v2, vec_sld(v1, v3, 8), flp2); \ + c = vec_perm(vec_sld(v2, v1, 8), v3, flp); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_4(uint, vec_uint4) +VSX_IMPL_ST_INTERLEAVE_3CH_4(int, vec_int4) +VSX_IMPL_ST_INTERLEAVE_3CH_4(float, vec_float4) + +#define VSX_IMPL_ST_INTERLEAVE_3CH_2(Tp, Tvec, ld_func, st_func) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + st_func(vec_mergeh(a, b), 0, ptr); \ + st_func(vec_permi(c, a, 1), 2, ptr); \ + st_func(vec_mergel(b, c), 4, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, \ + Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = ld_func(0, ptr); \ + Tvec v2 = ld_func(2, ptr); \ + Tvec v3 = ld_func(4, ptr); \ + a = vec_permi(v1, v2, 1); \ + b = vec_permi(v1, v3, 2); \ + c = vec_permi(v2, v3, 1); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_2(int64, vec_dword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_INTERLEAVE_3CH_2(uint64, vec_udword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_INTERLEAVE_3CH_2(double, vec_double2, vsx_ld, vsx_st) + +#endif // CV_VSX + +//! @} + +#endif // OPENCV_HAL_VSX_UTILS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/cvconfig.h b/Cigarette/OpenCV455Simple/include/opencv2/cvconfig.h new file mode 100644 index 0000000..922e589 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/cvconfig.h @@ -0,0 +1,149 @@ +#ifndef OPENCV_CVCONFIG_H_INCLUDED +#define OPENCV_CVCONFIG_H_INCLUDED + +/* OpenCV compiled as static or dynamic libs */ +#define BUILD_SHARED_LIBS + +/* OpenCV intrinsics optimized code */ +#define CV_ENABLE_INTRINSICS + +/* OpenCV additional optimized code */ +/* #undef CV_DISABLE_OPTIMIZATION */ + +/* Compile for 'real' NVIDIA GPU architectures */ +#define CUDA_ARCH_BIN "" + +/* NVIDIA GPU features are used */ +#define CUDA_ARCH_FEATURES "" + +/* Compile for 'virtual' NVIDIA PTX architectures */ +#define CUDA_ARCH_PTX "" + +/* AMD's Basic Linear Algebra Subprograms Library*/ +/* #undef HAVE_CLAMDBLAS */ + +/* AMD's OpenCL Fast Fourier Transform Library*/ +/* #undef HAVE_CLAMDFFT */ + +/* Clp support */ +/* #undef HAVE_CLP */ + +/* NVIDIA CUDA Runtime API*/ +/* #undef HAVE_CUDA */ + +/* NVIDIA CUDA Basic Linear Algebra Subprograms (BLAS) API*/ +/* #undef HAVE_CUBLAS */ + +/* NVIDIA CUDA Deep Neural Network (cuDNN) API*/ +/* #undef HAVE_CUDNN */ + +/* NVIDIA CUDA Fast Fourier Transform (FFT) API*/ +/* #undef HAVE_CUFFT */ + +/* DirectX */ +#define HAVE_DIRECTX +#define HAVE_DIRECTX_NV12 +#define HAVE_D3D11 +#define HAVE_D3D10 +#define HAVE_D3D9 + +/* Eigen Matrix & Linear Algebra Library */ +/* #undef HAVE_EIGEN */ + +/* Geospatial Data Abstraction Library */ +/* #undef HAVE_GDAL */ + +/* Halide support */ +/* #undef HAVE_HALIDE */ + +/* Vulkan support */ +/* #undef HAVE_VULKAN */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Intel Integrated Performance Primitives */ +#define HAVE_IPP +#define HAVE_IPP_ICV +#define HAVE_IPP_IW +#define HAVE_IPP_IW_LL + +/* JPEG-2000 codec */ +#define HAVE_OPENJPEG +/* #undef HAVE_JASPER */ + +/* IJG JPEG codec */ +#define HAVE_JPEG + +/* libpng/png.h needs to be included */ +/* #undef HAVE_LIBPNG_PNG_H */ + +/* GDCM DICOM codec */ +/* #undef HAVE_GDCM */ + +/* NVIDIA Video Decoding API*/ +/* #undef HAVE_NVCUVID */ +/* #undef HAVE_NVCUVID_HEADER */ +/* #undef HAVE_DYNLINK_NVCUVID_HEADER */ + +/* NVIDIA Video Encoding API*/ +/* #undef HAVE_NVCUVENC */ + +/* OpenCL Support */ +#define HAVE_OPENCL +/* #undef HAVE_OPENCL_STATIC */ +/* #undef HAVE_OPENCL_SVM */ + +/* NVIDIA OpenCL D3D Extensions support */ +#define HAVE_OPENCL_D3D11_NV + +/* OpenEXR codec */ +#define HAVE_OPENEXR + +/* OpenGL support*/ +/* #undef HAVE_OPENGL */ + +/* PNG codec */ +#define HAVE_PNG + +/* Posix threads (pthreads) */ +/* #undef HAVE_PTHREAD */ + +/* parallel_for with pthreads */ +/* #undef HAVE_PTHREADS_PF */ + +/* Intel Threading Building Blocks */ +/* #undef HAVE_TBB */ + +/* Ste||ar Group High Performance ParallelX */ +/* #undef HAVE_HPX */ + +/* TIFF codec */ +#define HAVE_TIFF + +/* Define if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* VA library (libva) */ +/* #undef HAVE_VA */ + +/* Intel VA-API/OpenCL */ +/* #undef HAVE_VA_INTEL */ + +/* Lapack */ +/* #undef HAVE_LAPACK */ + +/* Library was compiled with functions instrumentation */ +/* #undef ENABLE_INSTRUMENTATION */ + +/* OpenVX */ +/* #undef HAVE_OPENVX */ + +/* OpenCV trace utilities */ +#define OPENCV_TRACE + +/* Library QR-code decoding */ +#define HAVE_QUIRC + +#endif // OPENCV_CVCONFIG_H_INCLUDED diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn.hpp new file mode 100644 index 0000000..97f2fe3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn.hpp @@ -0,0 +1,78 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_HPP +#define OPENCV_DNN_HPP + +// This is an umbrella header to include into you project. +// We are free to change headers layout in dnn subfolder, so please include +// this header for future compatibility + + +/** @defgroup dnn Deep Neural Network module + @{ + This module contains: + - API for new layers creation, layers are building bricks of neural networks; + - set of built-in most-useful Layers; + - API to construct and modify comprehensive neural networks from layers; + - functionality for loading serialized networks models from different frameworks. + + Functionality of this module is designed only for forward pass computations (i.e. network testing). + A network training is in principle not supported. + @} +*/ +/** @example samples/dnn/classification.cpp +Check @ref tutorial_dnn_googlenet "the corresponding tutorial" for more details +*/ +/** @example samples/dnn/colorization.cpp +*/ +/** @example samples/dnn/object_detection.cpp +Check @ref tutorial_dnn_yolo "the corresponding tutorial" for more details +*/ +/** @example samples/dnn/openpose.cpp +*/ +/** @example samples/dnn/segmentation.cpp +*/ +/** @example samples/dnn/text_detection.cpp +*/ +#include + +#endif /* OPENCV_DNN_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/all_layers.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/all_layers.hpp new file mode 100644 index 0000000..44b16f7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/all_layers.hpp @@ -0,0 +1,1011 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_ALL_LAYERS_HPP +#define OPENCV_DNN_DNN_ALL_LAYERS_HPP +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ + +/** @defgroup dnnLayerList Partial List of Implemented Layers + @{ + This subsection of dnn module contains information about built-in layers and their descriptions. + + Classes listed here, in fact, provides C++ API for creating instances of built-in layers. + In addition to this way of layers instantiation, there is a more common factory API (see @ref dnnLayerFactory), it allows to create layers dynamically (by name) and register new ones. + You can use both API, but factory API is less convenient for native C++ programming and basically designed for use inside importers (see @ref readNetFromCaffe(), @ref readNetFromTorch(), @ref readNetFromTensorflow()). + + Built-in layers partially reproduce functionality of corresponding Caffe and Torch7 layers. + In particular, the following layers and Caffe importer were tested to reproduce Caffe functionality: + - Convolution + - Deconvolution + - Pooling + - InnerProduct + - TanH, ReLU, Sigmoid, BNLL, Power, AbsVal + - Softmax + - Reshape, Flatten, Slice, Split + - LRN + - MVN + - Dropout (since it does nothing on forward pass -)) +*/ + + class CV_EXPORTS BlankLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + /** + * Constant layer produces the same data blob at an every forward pass. + */ + class CV_EXPORTS ConstLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + //! LSTM recurrent layer + class CV_EXPORTS LSTMLayer : public Layer + { + public: + /** Creates instance of LSTM layer */ + static Ptr create(const LayerParams& params); + + /** @deprecated Use LayerParams::blobs instead. + @brief Set trained weights for LSTM layer. + + LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights. + + Let @f$x_t@f$ be current input, @f$h_t@f$ be current output, @f$c_t@f$ be current state. + Than current output and current cell state is computed as follows: + @f{eqnarray*}{ + h_t &= o_t \odot tanh(c_t), \\ + c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\ + @f} + where @f$\odot@f$ is per-element multiply operation and @f$i_t, f_t, o_t, g_t@f$ is internal gates that are computed using learned weights. + + Gates are computed as follows: + @f{eqnarray*}{ + i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\ + f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\ + o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\ + g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\ + @f} + where @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices: + @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$. + + For simplicity and performance purposes we use @f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] @f$ + (i.e. @f$W_x@f$ is vertical concatenation of @f$ W_{x?} @f$), @f$ W_x \in R^{4N_h \times N_x} @f$. + The same for @f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} @f$ + and for @f$ b = [b_i; b_f, b_o, b_g]@f$, @f$b \in R^{4N_h} @f$. + + @param Wh is matrix defining how previous output is transformed to internal gates (i.e. according to above mentioned notation is @f$ W_h @f$) + @param Wx is matrix defining how current input is transformed to internal gates (i.e. according to above mentioned notation is @f$ W_x @f$) + @param b is bias vector (i.e. according to above mentioned notation is @f$ b @f$) + */ + CV_DEPRECATED virtual void setWeights(const Mat &Wh, const Mat &Wx, const Mat &b) = 0; + + /** @brief Specifies shape of output blob which will be [[`T`], `N`] + @p outTailShape. + * @details If this parameter is empty or unset then @p outTailShape = [`Wh`.size(0)] will be used, + * where `Wh` is parameter from setWeights(). + */ + virtual void setOutShape(const MatShape &outTailShape = MatShape()) = 0; + + /** @deprecated Use flag `produce_cell_output` in LayerParams. + * @brief Specifies either interpret first dimension of input blob as timestamp dimension either as sample. + * + * If flag is set to true then shape of input blob will be interpreted as [`T`, `N`, `[data dims]`] where `T` specifies number of timestamps, `N` is number of independent streams. + * In this case each forward() call will iterate through `T` timestamps and update layer's state `T` times. + * + * If flag is set to false then shape of input blob will be interpreted as [`N`, `[data dims]`]. + * In this case each forward() call will make one iteration and produce one timestamp with shape [`N`, `[out dims]`]. + */ + CV_DEPRECATED virtual void setUseTimstampsDim(bool use = true) = 0; + + /** @deprecated Use flag `use_timestamp_dim` in LayerParams. + * @brief If this flag is set to true then layer will produce @f$ c_t @f$ as second output. + * @details Shape of the second output is the same as first output. + */ + CV_DEPRECATED virtual void setProduceCellOutput(bool produce = false) = 0; + + /* In common case it use single input with @f$x_t@f$ values to compute output(s) @f$h_t@f$ (and @f$c_t@f$). + * @param input should contain packed values @f$x_t@f$ + * @param output contains computed outputs: @f$h_t@f$ (and @f$c_t@f$ if setProduceCellOutput() flag was set to true). + * + * If setUseTimstampsDim() is set to true then @p input[0] should has at least two dimensions with the following shape: [`T`, `N`, `[data dims]`], + * where `T` specifies number of timestamps, `N` is number of independent streams (i.e. @f$ x_{t_0 + t}^{stream} @f$ is stored inside @p input[0][t, stream, ...]). + * + * If setUseTimstampsDim() is set to false then @p input[0] should contain single timestamp, its shape should has form [`N`, `[data dims]`] with at least one dimension. + * (i.e. @f$ x_{t}^{stream} @f$ is stored inside @p input[0][stream, ...]). + */ + + int inputNameToIndex(String inputName) CV_OVERRIDE; + int outputNameToIndex(const String& outputName) CV_OVERRIDE; + }; + + /** @brief GRU recurrent one-layer + * + * Accepts input sequence and computes the final hidden state for each element in the batch. + * + * - input[0] containing the features of the input sequence. + * input[0] should have shape [`T`, `N`, `data_dims`] where `T` is sequence length, `N` is batch size, `data_dims` is input size + * - output would have shape [`T`, `N`, `D` * `hidden_size`] where `D = 2` if layer is bidirectional otherwise `D = 1` + * + * Depends on the following attributes: + * - hidden_size - Number of neurons in the hidden layer + * - direction - RNN could be bidirectional or forward + * + * The final hidden state @f$ h_t @f$ computes by the following formulas: + * + @f{eqnarray*}{ + r_t = \sigma(W_{ir} x_t + b_{ir} + W_{hr} h_{(t-1)} + b_{hr}) \\ + z_t = \sigma(W_{iz} x_t + b_{iz} + W_{hz} h_{(t-1)} + b_{hz}) \\ + n_t = \tanh(W_{in} x_t + b_{in} + r_t \odot (W_{hn} h_{(t-1)}+ b_{hn})) \\ + h_t = (1 - z_t) \odot n_t + z_t \odot h_{(t-1)} \\ + @f} + * Where @f$x_t@f$ is current input, @f$h_{(t-1)}@f$ is previous or initial hidden state. + * + * @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices: + * @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$. + * + * @f$\odot@f$ is per-element multiply operation. + */ + class CV_EXPORTS GRULayer : public Layer + { + public: + /** Creates instance of GRU layer */ + static Ptr create(const LayerParams& params); + }; + + /** @brief Classical recurrent layer + + Accepts two inputs @f$x_t@f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t@f$ and @f$h_t@f$. + + - input: should contain packed input @f$x_t@f$. + - output: should contain output @f$o_t@f$ (and @f$h_t@f$ if setProduceHiddenOutput() is set to true). + + input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t@f$ respectively. + + output[0] will have shape [`T`, `N`, @f$N_o@f$], where @f$N_o@f$ is number of rows in @f$ W_{xo} @f$ matrix. + + If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h@f$], where @f$N_h@f$ is number of rows in @f$ W_{hh} @f$ matrix. + */ + class CV_EXPORTS RNNLayer : public Layer + { + public: + /** Creates instance of RNNLayer */ + static Ptr create(const LayerParams& params); + + /** Setups learned weights. + + Recurrent-layer behavior on each step is defined by current input @f$ x_t @f$, previous state @f$ h_t @f$ and learned weights as follows: + @f{eqnarray*}{ + h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\ + o_t &= tanh&(W_{ho} h_t + b_o), + @f} + + @param Wxh is @f$ W_{xh} @f$ matrix + @param bh is @f$ b_{h} @f$ vector + @param Whh is @f$ W_{hh} @f$ matrix + @param Who is @f$ W_{xo} @f$ matrix + @param bo is @f$ b_{o} @f$ vector + */ + virtual void setWeights(const Mat &Wxh, const Mat &bh, const Mat &Whh, const Mat &Who, const Mat &bo) = 0; + + /** @brief If this flag is set to true then layer will produce @f$ h_t @f$ as second output. + * @details Shape of the second output is the same as first output. + */ + virtual void setProduceHiddenOutput(bool produce = false) = 0; + + }; + + class CV_EXPORTS BaseConvolutionLayer : public Layer + { + public: + CV_DEPRECATED_EXTERNAL Size kernel, stride, pad, dilation, adjustPad; + std::vector adjust_pads; + std::vector kernel_size, strides, dilations; + std::vector pads_begin, pads_end; + String padMode; + int numOutput; + }; + + class CV_EXPORTS ConvolutionLayer : public BaseConvolutionLayer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ConvolutionLayerInt8 : public BaseConvolutionLayer + { + public: + int input_zp, output_zp; + float output_sc; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS DeconvolutionLayer : public BaseConvolutionLayer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS LRNLayer : public Layer + { + public: + int type; + + int size; + float alpha, beta, bias; + bool normBySize; + + static Ptr create(const LayerParams& params); + }; + + + /** @brief ArgMax/ArgMin layer + * @note returns indices as floats, which means the supported range is [-2^24; 2^24] + */ + class CV_EXPORTS ArgLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS PoolingLayer : public Layer + { + public: + int type; + std::vector kernel_size, strides; + std::vector pads_begin, pads_end; + bool globalPooling; //!< Flag is true if at least one of the axes is global pooled. + std::vector isGlobalPooling; + bool computeMaxIdx; + String padMode; + bool ceilMode; + // If true for average pooling with padding, divide an every output region + // by a whole kernel area. Otherwise exclude zero padded values and divide + // by number of real values. + bool avePoolPaddedArea; + // ROIPooling parameters. + Size pooledSize; + float spatialScale; + // PSROIPooling parameters. + int psRoiOutChannels; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS PoolingLayerInt8 : public PoolingLayer + { + public: + int input_zp, output_zp; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS SoftmaxLayer : public Layer + { + public: + bool logSoftMax; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS SoftmaxLayerInt8 : public SoftmaxLayer + { + public: + float output_sc; + int output_zp; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS InnerProductLayer : public Layer + { + public: + int axis; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS InnerProductLayerInt8 : public InnerProductLayer + { + public: + int output_zp; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS MVNLayer : public Layer + { + public: + float eps; + bool normVariance, acrossChannels; + + static Ptr create(const LayerParams& params); + }; + + /* Reshaping */ + + class CV_EXPORTS ReshapeLayer : public Layer + { + public: + MatShape newShapeDesc; + Range newShapeRange; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS FlattenLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS QuantizeLayer : public Layer + { + public: + float scale; + int zeropoint; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS DequantizeLayer : public Layer + { + public: + float scale; + int zeropoint; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS RequantizeLayer : public Layer + { + public: + float scale, shift; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ConcatLayer : public Layer + { + public: + int axis; + /** + * @brief Add zero padding in case of concatenation of blobs with different + * spatial sizes. + * + * Details: https://github.com/torch/nn/blob/master/doc/containers.md#depthconcat + */ + bool padding; + int paddingValue; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SplitLayer : public Layer + { + public: + int outputsCount; //!< Number of copies that will be produced (is ignored when negative). + + static Ptr create(const LayerParams ¶ms); + }; + + /** + * Slice layer has several modes: + * 1. Caffe mode + * @param[in] axis Axis of split operation + * @param[in] slice_point Array of split points + * + * Number of output blobs equals to number of split points plus one. The + * first blob is a slice on input from 0 to @p slice_point[0] - 1 by @p axis, + * the second output blob is a slice of input from @p slice_point[0] to + * @p slice_point[1] - 1 by @p axis and the last output blob is a slice of + * input from @p slice_point[-1] up to the end of @p axis size. + * + * 2. TensorFlow mode + * @param begin Vector of start indices + * @param size Vector of sizes + * + * More convenient numpy-like slice. One and only output blob + * is a slice `input[begin[0]:begin[0]+size[0], begin[1]:begin[1]+size[1], ...]` + * + * 3. Torch mode + * @param axis Axis of split operation + * + * Split input blob on the equal parts by @p axis. + */ + class CV_EXPORTS SliceLayer : public Layer + { + public: + /** + * @brief Vector of slice ranges. + * + * The first dimension equals number of output blobs. + * Inner vector has slice ranges for the first number of input dimensions. + */ + std::vector > sliceRanges; + std::vector > sliceSteps; + int axis; + int num_split; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS PermuteLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /** + * Permute channels of 4-dimensional input blob. + * @param group Number of groups to split input channels and pick in turns + * into output blob. + * + * \f[ groupSize = \frac{number\ of\ channels}{group} \f] + * \f[ output(n, c, h, w) = input(n, groupSize \times (c \% group) + \lfloor \frac{c}{group} \rfloor, h, w) \f] + * Read more at https://arxiv.org/pdf/1707.01083.pdf + */ + class CV_EXPORTS ShuffleChannelLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + + int group; + }; + + /** + * @brief Adds extra values for specific axes. + * @param paddings Vector of paddings in format + * @code + * [ pad_before, pad_after, // [0]th dimension + * pad_before, pad_after, // [1]st dimension + * ... + * pad_before, pad_after ] // [n]th dimension + * @endcode + * that represents number of padded values at every dimension + * starting from the first one. The rest of dimensions won't + * be padded. + * @param value Value to be padded. Defaults to zero. + * @param type Padding type: 'constant', 'reflect' + * @param input_dims Torch's parameter. If @p input_dims is not equal to the + * actual input dimensionality then the `[0]th` dimension + * is considered as a batch dimension and @p paddings are shifted + * to a one dimension. Defaults to `-1` that means padding + * corresponding to @p paddings. + */ + class CV_EXPORTS PaddingLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /* Activations */ + class CV_EXPORTS ActivationLayer : public Layer + { + public: + virtual void forwardSlice(const float* src, float* dst, int len, + size_t outPlaneSize, int cn0, int cn1) const {}; + virtual void forwardSlice(const int* src, const int* lut, int* dst, int len, + size_t outPlaneSize, int cn0, int cn1) const {}; + virtual void forwardSlice(const int8_t* src, const int8_t* lut, int8_t* dst, int len, + size_t outPlaneSize, int cn0, int cn1) const {}; + }; + + class CV_EXPORTS ReLULayer : public ActivationLayer + { + public: + float negativeSlope; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ReLU6Layer : public ActivationLayer + { + public: + float minValue, maxValue; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ChannelsPReLULayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ELULayer : public ActivationLayer + { + public: + float alpha; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS TanHLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SwishLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS MishLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SigmoidLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS BNLLLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AbsLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS PowerLayer : public ActivationLayer + { + public: + float power, scale, shift; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ExpLayer : public ActivationLayer + { + public: + float base, scale, shift; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CeilLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS FloorLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS LogLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS RoundLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SqrtLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS NotLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AcosLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AcoshLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AsinLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AsinhLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AtanLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AtanhLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CosLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CoshLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ErfLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS HardSwishLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SinLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SinhLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SoftplusLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SoftsignLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS TanLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CeluLayer : public ActivationLayer + { + public: + float alpha; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS HardSigmoidLayer : public ActivationLayer + { + public: + float alpha; + float beta; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SeluLayer : public ActivationLayer + { + public: + float alpha; + float gamma; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ThresholdedReluLayer : public ActivationLayer + { + public: + float alpha; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ActivationLayerInt8 : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + /* Layers used in semantic segmentation */ + + class CV_EXPORTS CropLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + /** @brief Element wise operation on inputs + + Extra optional parameters: + - "operation" as string. Values are "sum" (default), "prod", "max", "div", "min" + - "coeff" as float array. Specify weights of inputs for SUM operation + - "output_channels_mode" as string. Values are "same" (default, all input must have the same layout), "input_0", "input_0_truncate", "max_input_channels" + */ + class CV_EXPORTS EltwiseLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS EltwiseLayerInt8 : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS BatchNormLayer : public ActivationLayer + { + public: + bool hasWeights, hasBias; + float epsilon; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS BatchNormLayerInt8 : public BatchNormLayer + { + public: + float input_sc, output_sc; + int input_zp, output_zp; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS MaxUnpoolLayer : public Layer + { + public: + Size poolKernel; + Size poolPad; + Size poolStride; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ScaleLayer : public Layer + { + public: + bool hasBias; + int axis; + String mode; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ScaleLayerInt8 : public ScaleLayer + { + public: + float output_sc; + int output_zp; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ShiftLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ShiftLayerInt8 : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CompareLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS DataAugmentationLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CorrelationLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS AccumLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS FlowWarpLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS PriorBoxLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ReorgLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS RegionLayer : public Layer + { + public: + float nmsThreshold; + + static Ptr create(const LayerParams& params); + }; + + /** + * @brief Detection output layer. + * + * The layer size is: @f$ (1 \times 1 \times N \times 7) @f$ + * where N is [keep_top_k] parameter multiplied by batch size. Each row is: + * [image_id, label, confidence, xmin, ymin, xmax, ymax] + * where image_id is the index of image input in the batch. + */ + class CV_EXPORTS DetectionOutputLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /** + * @brief \f$ L_p \f$ - normalization layer. + * @param p Normalization factor. The most common `p = 1` for \f$ L_1 \f$ - + * normalization or `p = 2` for \f$ L_2 \f$ - normalization or a custom one. + * @param eps Parameter \f$ \epsilon \f$ to prevent a division by zero. + * @param across_spatial If true, normalize an input across all non-batch dimensions. + * Otherwise normalize an every channel separately. + * + * Across spatial: + * @f[ + * norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\ + * dst(x, y, c) = \frac{ src(x, y, c) }{norm} + * @f] + * + * Channel wise normalization: + * @f[ + * norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\ + * dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)} + * @f] + * + * Where `x, y` - spatial coordinates, `c` - channel. + * + * An every sample in the batch is normalized separately. Optionally, + * output is scaled by the trained parameters. + */ + class CV_EXPORTS NormalizeBBoxLayer : public Layer + { + public: + float pnorm, epsilon; + CV_DEPRECATED_EXTERNAL bool acrossSpatial; + + static Ptr create(const LayerParams& params); + }; + + /** + * @brief Resize input 4-dimensional blob by nearest neighbor or bilinear strategy. + * + * Layer is used to support TensorFlow's resize_nearest_neighbor and resize_bilinear ops. + */ + class CV_EXPORTS ResizeLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /** + * @brief Bilinear resize layer from https://github.com/cdmh/deeplab-public-ver2 + * + * It differs from @ref ResizeLayer in output shape and resize scales computations. + */ + class CV_EXPORTS InterpLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ProposalLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CropAndResizeLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CumSumLayer : public Layer + { + public: + int exclusive; + int reverse; + + static Ptr create(const LayerParams& params); + }; + +//! @} +//! @} +CV__DNN_INLINE_NS_END +} +} +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/dict.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/dict.hpp new file mode 100644 index 0000000..463d314 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/dict.hpp @@ -0,0 +1,160 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#include +#include +#include + +#include + +#ifndef OPENCV_DNN_DNN_DICT_HPP +#define OPENCV_DNN_DNN_DICT_HPP + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ + +/** @brief This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64. + * @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers. + */ +struct CV_EXPORTS_W DictValue +{ + DictValue(const DictValue &r); + DictValue(bool i) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = i ? 1 : 0; } //!< Constructs integer scalar + DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = i; } //!< Constructs integer scalar + CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = i; } //!< Constructs integer scalar + DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = p; } //!< Constructs integer scalar + CV_WRAP DictValue(double p) : type(Param::REAL), pd(new AutoBuffer) { (*pd)[0] = p; } //!< Constructs floating point scalar + CV_WRAP DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer) { (*ps)[0] = s; } //!< Constructs string scalar + DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer) { (*ps)[0] = s; } //!< @overload + + template + static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array + template + static DictValue arrayReal(TypeIter begin, int size); //!< Constructs floating point array + template + static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings + + template + T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns its. + + int size() const; + + CV_WRAP bool isInt() const; + CV_WRAP bool isString() const; + CV_WRAP bool isReal() const; + + CV_WRAP int getIntValue(int idx = -1) const; + CV_WRAP double getRealValue(int idx = -1) const; + CV_WRAP String getStringValue(int idx = -1) const; + + DictValue &operator=(const DictValue &r); + + friend std::ostream &operator<<(std::ostream &stream, const DictValue &dictv); + + ~DictValue(); + +private: + + Param type; + + union + { + AutoBuffer *pi; + AutoBuffer *pd; + AutoBuffer *ps; + void *pv; + }; + + DictValue(Param _type, void *_p) : type(_type), pv(_p) {} + void release(); +}; + +/** @brief This class implements name-value dictionary, values are instances of DictValue. */ +class CV_EXPORTS Dict +{ + typedef std::map _Dict; + _Dict dict; + +public: + + //! Checks a presence of the @p key in the dictionary. + bool has(const String &key) const; + + //! If the @p key in the dictionary then returns pointer to its value, else returns NULL. + DictValue *ptr(const String &key); + + /** @overload */ + const DictValue *ptr(const String &key) const; + + //! If the @p key in the dictionary then returns its value, else an error will be generated. + const DictValue &get(const String &key) const; + + /** @overload */ + template + T get(const String &key) const; + + //! If the @p key in the dictionary then returns its value, else returns @p defaultValue. + template + T get(const String &key, const T &defaultValue) const; + + //! Sets new @p value for the @p key, or adds new key-value pair into the dictionary. + template + const T &set(const String &key, const T &value); + + //! Erase @p key from the dictionary. + void erase(const String &key); + + friend std::ostream &operator<<(std::ostream &stream, const Dict &dict); + + std::map::const_iterator begin() const; + + std::map::const_iterator end() const; +}; + +//! @} +CV__DNN_INLINE_NS_END +} +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/dnn.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/dnn.hpp new file mode 100644 index 0000000..d6b29cf --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/dnn.hpp @@ -0,0 +1,1696 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_HPP +#define OPENCV_DNN_DNN_HPP + +#include +#include +#include "opencv2/core/async.hpp" + +#include "../dnn/version.hpp" + +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ + + typedef std::vector MatShape; + + /** + * @brief Enum of computation backends supported by layers. + * @see Net::setPreferableBackend + */ + enum Backend + { + //! DNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if + //! OpenCV is built with Intel's Inference Engine library or + //! DNN_BACKEND_OPENCV otherwise. + DNN_BACKEND_DEFAULT = 0, + DNN_BACKEND_HALIDE, + DNN_BACKEND_INFERENCE_ENGINE, //!< Intel's Inference Engine computational backend + //!< @sa setInferenceEngineBackendType + DNN_BACKEND_OPENCV, + DNN_BACKEND_VKCOM, + DNN_BACKEND_CUDA, + DNN_BACKEND_WEBNN, +#ifdef __OPENCV_BUILD + DNN_BACKEND_INFERENCE_ENGINE_NGRAPH = 1000000, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType() + DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType() +#endif + }; + + /** + * @brief Enum of target devices for computations. + * @see Net::setPreferableTarget + */ + enum Target + { + DNN_TARGET_CPU = 0, + DNN_TARGET_OPENCL, + DNN_TARGET_OPENCL_FP16, + DNN_TARGET_MYRIAD, + DNN_TARGET_VULKAN, + DNN_TARGET_FPGA, //!< FPGA device with CPU fallbacks using Inference Engine's Heterogeneous plugin. + DNN_TARGET_CUDA, + DNN_TARGET_CUDA_FP16, + DNN_TARGET_HDDL + }; + + CV_EXPORTS std::vector< std::pair > getAvailableBackends(); + CV_EXPORTS_W std::vector getAvailableTargets(dnn::Backend be); + + /** + * @brief Enables detailed logging of the DNN model loading with CV DNN API. + * @param[in] isDiagnosticsMode Indicates whether diagnostic mode should be set. + * + * Diagnostic mode provides detailed logging of the model loading stage to explore + * potential problems (ex.: not implemented layer type). + * + * @note In diagnostic mode series of assertions will be skipped, it can lead to the + * expected application crash. + */ + CV_EXPORTS void enableModelDiagnostics(bool isDiagnosticsMode); + + /** @brief This class provides all data needed to initialize layer. + * + * It includes dictionary with scalar params (which can be read by using Dict interface), + * blob params #blobs and optional meta information: #name and #type of layer instance. + */ + class CV_EXPORTS LayerParams : public Dict + { + public: + //TODO: Add ability to name blob params + std::vector blobs; //!< List of learned parameters stored as blobs. + + String name; //!< Name of the layer instance (optional, can be used internal purposes). + String type; //!< Type name which was used for creating layer by layer factory (optional). + }; + + /** + * @brief Derivatives of this class encapsulates functions of certain backends. + */ + class BackendNode + { + public: + BackendNode(int backendId); + + virtual ~BackendNode(); //!< Virtual destructor to make polymorphism. + + int backendId; //!< Backend identifier. + }; + + /** + * @brief Derivatives of this class wraps cv::Mat for different backends and targets. + */ + class BackendWrapper + { + public: + BackendWrapper(int backendId, int targetId); + + /** + * @brief Wrap cv::Mat for specific backend and target. + * @param[in] targetId Target identifier. + * @param[in] m cv::Mat for wrapping. + * + * Make CPU->GPU data transfer if it's require for the target. + */ + BackendWrapper(int targetId, const cv::Mat& m); + + /** + * @brief Make wrapper for reused cv::Mat. + * @param[in] base Wrapper of cv::Mat that will be reused. + * @param[in] shape Specific shape. + * + * Initialize wrapper from another one. It'll wrap the same host CPU + * memory and mustn't allocate memory on device(i.e. GPU). It might + * has different shape. Use in case of CPU memory reusing for reuse + * associated memory on device too. + */ + BackendWrapper(const Ptr& base, const MatShape& shape); + + virtual ~BackendWrapper(); //!< Virtual destructor to make polymorphism. + + /** + * @brief Transfer data to CPU host memory. + */ + virtual void copyToHost() = 0; + + /** + * @brief Indicate that an actual data is on CPU. + */ + virtual void setHostDirty() = 0; + + int backendId; //!< Backend identifier. + int targetId; //!< Target identifier. + }; + + class CV_EXPORTS ActivationLayer; + + /** @brief This interface class allows to build new Layers - are building blocks of networks. + * + * Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs. + * Also before using the new layer into networks you must register your layer by using one of @ref dnnLayerFactory "LayerFactory" macros. + */ + class CV_EXPORTS_W Layer : public Algorithm + { + public: + + //! List of learned parameters must be stored here to allow read them by using Net::getParam(). + CV_PROP_RW std::vector blobs; + + /** @brief Computes and sets internal parameters according to inputs, outputs and blobs. + * @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead + * @param[in] input vector of already allocated input blobs + * @param[out] output vector of already allocated output blobs + * + * If this method is called after network has allocated all memory for input and output blobs + * and before inferencing. + */ + CV_DEPRECATED_EXTERNAL + virtual void finalize(const std::vector &input, std::vector &output); + + /** @brief Computes and sets internal parameters according to inputs, outputs and blobs. + * @param[in] inputs vector of already allocated input blobs + * @param[out] outputs vector of already allocated output blobs + * + * If this method is called after network has allocated all memory for input and output blobs + * and before inferencing. + */ + CV_WRAP virtual void finalize(InputArrayOfArrays inputs, OutputArrayOfArrays outputs); + + /** @brief Given the @p input blobs, computes the output @p blobs. + * @deprecated Use Layer::forward(InputArrayOfArrays, OutputArrayOfArrays, OutputArrayOfArrays) instead + * @param[in] input the input blobs. + * @param[out] output allocated output blobs, which will store results of the computation. + * @param[out] internals allocated internal blobs + */ + CV_DEPRECATED_EXTERNAL + virtual void forward(std::vector &input, std::vector &output, std::vector &internals); + + /** @brief Given the @p input blobs, computes the output @p blobs. + * @param[in] inputs the input blobs. + * @param[out] outputs allocated output blobs, which will store results of the computation. + * @param[out] internals allocated internal blobs + */ + virtual void forward(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals); + + /** @brief Tries to quantize the given layer and compute the quantization parameters required for fixed point implementation. + * @param[in] scales input and output scales. + * @param[in] zeropoints input and output zeropoints. + * @param[out] params Quantized parameters required for fixed point implementation of that layer. + * @returns True if layer can be quantized. + */ + virtual bool tryQuantize(const std::vector > &scales, + const std::vector > &zeropoints, LayerParams& params); + + /** @brief Given the @p input blobs, computes the output @p blobs. + * @param[in] inputs the input blobs. + * @param[out] outputs allocated output blobs, which will store results of the computation. + * @param[out] internals allocated internal blobs + */ + void forward_fallback(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals); + + /** @brief + * @overload + * @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead + */ + CV_DEPRECATED_EXTERNAL + void finalize(const std::vector &inputs, CV_OUT std::vector &outputs); + + /** @brief + * @overload + * @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead + */ + CV_DEPRECATED std::vector finalize(const std::vector &inputs); + + /** @brief Allocates layer and computes output. + * @deprecated This method will be removed in the future release. + */ + CV_DEPRECATED CV_WRAP void run(const std::vector &inputs, CV_OUT std::vector &outputs, + CV_IN_OUT std::vector &internals); + + /** @brief Returns index of input blob into the input array. + * @param inputName label of input blob + * + * Each layer input and output can be labeled to easily identify them using "%[.output_name]" notation. + * This method maps label of input blob to its index into input vector. + */ + virtual int inputNameToIndex(String inputName); + /** @brief Returns index of output blob in output array. + * @see inputNameToIndex() + */ + CV_WRAP virtual int outputNameToIndex(const String& outputName); + + /** + * @brief Ask layer if it support specific backend for doing computations. + * @param[in] backendId computation backend identifier. + * @see Backend + */ + virtual bool supportBackend(int backendId); + + /** + * @brief Returns Halide backend node. + * @param[in] inputs Input Halide buffers. + * @see BackendNode, BackendWrapper + * + * Input buffers should be exactly the same that will be used in forward invocations. + * Despite we can use Halide::ImageParam based on input shape only, + * it helps prevent some memory management issues (if something wrong, + * Halide tests will be failed). + */ + virtual Ptr initHalide(const std::vector > &inputs); + + virtual Ptr initInfEngine(const std::vector > &inputs); + + virtual Ptr initNgraph(const std::vector > &inputs, const std::vector >& nodes); + + virtual Ptr initVkCom(const std::vector > &inputs); + + virtual Ptr initWebnn(const std::vector > &inputs, const std::vector >& nodes); + + /** + * @brief Returns a CUDA backend node + * + * @param context void pointer to CSLContext object + * @param inputs layer inputs + * @param outputs layer outputs + */ + virtual Ptr initCUDA( + void *context, + const std::vector>& inputs, + const std::vector>& outputs + ); + + /** + * @brief Automatic Halide scheduling based on layer hyper-parameters. + * @param[in] node Backend node with Halide functions. + * @param[in] inputs Blobs that will be used in forward invocations. + * @param[in] outputs Blobs that will be used in forward invocations. + * @param[in] targetId Target identifier + * @see BackendNode, Target + * + * Layer don't use own Halide::Func members because we can have applied + * layers fusing. In this way the fused function should be scheduled. + */ + virtual void applyHalideScheduler(Ptr& node, + const std::vector &inputs, + const std::vector &outputs, + int targetId) const; + + /** + * @brief Implement layers fusing. + * @param[in] node Backend node of bottom layer. + * @see BackendNode + * + * Actual for graph-based backends. If layer attached successfully, + * returns non-empty cv::Ptr to node of the same backend. + * Fuse only over the last function. + */ + virtual Ptr tryAttach(const Ptr& node); + + /** + * @brief Tries to attach to the layer the subsequent activation layer, i.e. do the layer fusion in a partial case. + * @param[in] layer The subsequent activation layer. + * + * Returns true if the activation layer has been attached successfully. + */ + virtual bool setActivation(const Ptr& layer); + + /** + * @brief Try to fuse current layer with a next one + * @param[in] top Next layer to be fused. + * @returns True if fusion was performed. + */ + virtual bool tryFuse(Ptr& top); + + /** + * @brief Returns parameters of layers with channel-wise multiplication and addition. + * @param[out] scale Channel-wise multipliers. Total number of values should + * be equal to number of channels. + * @param[out] shift Channel-wise offsets. Total number of values should + * be equal to number of channels. + * + * Some layers can fuse their transformations with further layers. + * In example, convolution + batch normalization. This way base layer + * use weights from layer after it. Fused layer is skipped. + * By default, @p scale and @p shift are empty that means layer has no + * element-wise multiplications or additions. + */ + virtual void getScaleShift(Mat& scale, Mat& shift) const; + + /** + * @brief Returns scale and zeropoint of layers + * @param[out] scale Output scale + * @param[out] zeropoint Output zeropoint + * + * By default, @p scale is 1 and @p zeropoint is 0. + */ + virtual void getScaleZeropoint(float& scale, int& zeropoint) const; + + + /** + * @brief "Deattaches" all the layers, attached to particular layer. + */ + virtual void unsetAttached(); + + virtual bool getMemoryShapes(const std::vector &inputs, + const int requiredOutputs, + std::vector &outputs, + std::vector &internals) const; + + virtual int64 getFLOPS(const std::vector &inputs, + const std::vector &outputs) const {CV_UNUSED(inputs); CV_UNUSED(outputs); return 0;} + + virtual bool updateMemoryShapes(const std::vector &inputs); + + CV_PROP String name; //!< Name of the layer instance, can be used for logging or other internal purposes. + CV_PROP String type; //!< Type name which was used for creating layer by layer factory. + CV_PROP int preferableTarget; //!< prefer target for layer forwarding + + Layer(); + explicit Layer(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields. + void setParamsFrom(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields. + virtual ~Layer(); + }; + + /** @brief This class allows to create and manipulate comprehensive artificial neural networks. + * + * Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, + * and edges specify relationships between layers inputs and outputs. + * + * Each network layer has unique integer id and unique string name inside its network. + * LayerId can store either layer name or layer id. + * + * This class supports reference counting of its instances, i. e. copies point to the same instance. + */ + class CV_EXPORTS_W_SIMPLE Net + { + public: + + CV_WRAP Net(); //!< Default constructor. + CV_WRAP ~Net(); //!< Destructor frees the net only if there aren't references to the net anymore. + + /** @brief Create a network from Intel's Model Optimizer intermediate representation (IR). + * @param[in] xml XML configuration file with network's topology. + * @param[in] bin Binary file with trained weights. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_WRAP static Net readFromModelOptimizer(const String& xml, const String& bin); + + /** @brief Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). + * @param[in] bufferModelConfig buffer with model's configuration. + * @param[in] bufferWeights buffer with model's trained weights. + * @returns Net object. + */ + CV_WRAP static + Net readFromModelOptimizer(const std::vector& bufferModelConfig, const std::vector& bufferWeights); + + /** @brief Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). + * @param[in] bufferModelConfigPtr buffer pointer of model's configuration. + * @param[in] bufferModelConfigSize buffer size of model's configuration. + * @param[in] bufferWeightsPtr buffer pointer of model's trained weights. + * @param[in] bufferWeightsSize buffer size of model's trained weights. + * @returns Net object. + */ + static + Net readFromModelOptimizer(const uchar* bufferModelConfigPtr, size_t bufferModelConfigSize, + const uchar* bufferWeightsPtr, size_t bufferWeightsSize); + + /** Returns true if there are no layers in the network. */ + CV_WRAP bool empty() const; + + /** @brief Dump net to String + * @returns String with structure, hyperparameters, backend, target and fusion + * Call method after setInput(). To see correct backend, target and fusion run after forward(). + */ + CV_WRAP String dump(); + /** @brief Dump net structure, hyperparameters, backend, target and fusion to dot file + * @param path path to output file with .dot extension + * @see dump() + */ + CV_WRAP void dumpToFile(const String& path); + /** @brief Adds new layer to the net. + * @param name unique name of the adding layer. + * @param type typename of the adding layer (type must be registered in LayerRegister). + * @param dtype datatype of output blobs. + * @param params parameters which will be used to initialize the creating layer. + * @returns unique identifier of created layer, or -1 if a failure will happen. + */ + int addLayer(const String &name, const String &type, const int &dtype, LayerParams ¶ms); + + /** @overload Datatype of output blobs set to default CV_32F */ + int addLayer(const String &name, const String &type, LayerParams ¶ms); + + /** @brief Adds new layer and connects its first input to the first output of previously added layer. + * @see addLayer() + */ + int addLayerToPrev(const String &name, const String &type, const int &dtype, LayerParams ¶ms); + + /** @overload */ + int addLayerToPrev(const String &name, const String &type, LayerParams ¶ms); + + /** @brief Converts string name of the layer to the integer identifier. + * @returns id of the layer, or -1 if the layer wasn't found. + */ + CV_WRAP int getLayerId(const String &layer); + + CV_WRAP std::vector getLayerNames() const; + + /** @brief Container for strings and integers. */ + typedef DictValue LayerId; + + /** @brief Returns pointer to layer with specified id or name which the network use. */ + CV_WRAP Ptr getLayer(LayerId layerId); + + /** @brief Returns pointers to input layers of specific layer. */ + std::vector > getLayerInputs(LayerId layerId); // FIXIT: CV_WRAP + + /** @brief Connects output of the first layer to input of the second layer. + * @param outPin descriptor of the first layer output. + * @param inpPin descriptor of the second layer input. + * + * Descriptors have the following template <layer_name>[.input_number]: + * - the first part of the template layer_name is string name of the added layer. + * If this part is empty then the network input pseudo layer will be used; + * - the second optional part of the template input_number + * is either number of the layer input, either label one. + * If this part is omitted then the first layer input will be used. + * + * @see setNetInputs(), Layer::inputNameToIndex(), Layer::outputNameToIndex() + */ + CV_WRAP void connect(String outPin, String inpPin); + + /** @brief Connects #@p outNum output of the first layer to #@p inNum input of the second layer. + * @param outLayerId identifier of the first layer + * @param outNum number of the first layer output + * @param inpLayerId identifier of the second layer + * @param inpNum number of the second layer input + */ + void connect(int outLayerId, int outNum, int inpLayerId, int inpNum); + + /** @brief Sets outputs names of the network input pseudo layer. + * + * Each net always has special own the network input pseudo layer with id=0. + * This layer stores the user blobs only and don't make any computations. + * In fact, this layer provides the only way to pass user data into the network. + * As any other layer, this layer can label its outputs and this function provides an easy way to do this. + */ + CV_WRAP void setInputsNames(const std::vector &inputBlobNames); + + /** @brief Specify shape of network input. + */ + CV_WRAP void setInputShape(const String &inputName, const MatShape& shape); + + /** @brief Runs forward pass to compute output of layer with name @p outputName. + * @param outputName name for layer which output is needed to get + * @return blob for first output of specified layer. + * @details By default runs forward pass for the whole network. + */ + CV_WRAP Mat forward(const String& outputName = String()); + + /** @brief Runs forward pass to compute output of layer with name @p outputName. + * @param outputName name for layer which output is needed to get + * @details By default runs forward pass for the whole network. + * + * This is an asynchronous version of forward(const String&). + * dnn::DNN_BACKEND_INFERENCE_ENGINE backend is required. + */ + CV_WRAP AsyncArray forwardAsync(const String& outputName = String()); + + /** @brief Runs forward pass to compute output of layer with name @p outputName. + * @param outputBlobs contains all output blobs for specified layer. + * @param outputName name for layer which output is needed to get + * @details If @p outputName is empty, runs forward pass for the whole network. + */ + CV_WRAP void forward(OutputArrayOfArrays outputBlobs, const String& outputName = String()); + + /** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames. + * @param outputBlobs contains blobs for first outputs of specified layers. + * @param outBlobNames names for layers which outputs are needed to get + */ + CV_WRAP void forward(OutputArrayOfArrays outputBlobs, + const std::vector& outBlobNames); + + /** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames. + * @param outputBlobs contains all output blobs for each layer specified in @p outBlobNames. + * @param outBlobNames names for layers which outputs are needed to get + */ + CV_WRAP_AS(forwardAndRetrieve) void forward(CV_OUT std::vector >& outputBlobs, + const std::vector& outBlobNames); + + /** @brief Returns a quantized Net from a floating-point Net. + * @param calibData Calibration data to compute the quantization parameters. + * @param inputsDtype Datatype of quantized net's inputs. Can be CV_32F or CV_8S. + * @param outputsDtype Datatype of quantized net's outputs. Can be CV_32F or CV_8S. + */ + CV_WRAP Net quantize(InputArrayOfArrays calibData, int inputsDtype, int outputsDtype); + + /** @brief Returns input scale and zeropoint for a quantized Net. + * @param scales output parameter for returning input scales. + * @param zeropoints output parameter for returning input zeropoints. + */ + CV_WRAP void getInputDetails(CV_OUT std::vector& scales, CV_OUT std::vector& zeropoints) const; + + /** @brief Returns output scale and zeropoint for a quantized Net. + * @param scales output parameter for returning output scales. + * @param zeropoints output parameter for returning output zeropoints. + */ + CV_WRAP void getOutputDetails(CV_OUT std::vector& scales, CV_OUT std::vector& zeropoints) const; + + /** + * @brief Compile Halide layers. + * @param[in] scheduler Path to YAML file with scheduling directives. + * @see setPreferableBackend + * + * Schedule layers that support Halide backend. Then compile them for + * specific target. For layers that not represented in scheduling file + * or if no manual scheduling used at all, automatic scheduling will be applied. + */ + CV_WRAP void setHalideScheduler(const String& scheduler); + + /** + * @brief Ask network to use specific computation backend where it supported. + * @param[in] backendId backend identifier. + * @see Backend + * + * If OpenCV is compiled with Intel's Inference Engine library, DNN_BACKEND_DEFAULT + * means DNN_BACKEND_INFERENCE_ENGINE. Otherwise it equals to DNN_BACKEND_OPENCV. + */ + CV_WRAP void setPreferableBackend(int backendId); + + /** + * @brief Ask network to make computations on specific target device. + * @param[in] targetId target identifier. + * @see Target + * + * List of supported combinations backend / target: + * | | DNN_BACKEND_OPENCV | DNN_BACKEND_INFERENCE_ENGINE | DNN_BACKEND_HALIDE | DNN_BACKEND_CUDA | + * |------------------------|--------------------|------------------------------|--------------------|-------------------| + * | DNN_TARGET_CPU | + | + | + | | + * | DNN_TARGET_OPENCL | + | + | + | | + * | DNN_TARGET_OPENCL_FP16 | + | + | | | + * | DNN_TARGET_MYRIAD | | + | | | + * | DNN_TARGET_FPGA | | + | | | + * | DNN_TARGET_CUDA | | | | + | + * | DNN_TARGET_CUDA_FP16 | | | | + | + * | DNN_TARGET_HDDL | | + | | | + */ + CV_WRAP void setPreferableTarget(int targetId); + + /** @brief Sets the new input value for the network + * @param blob A new blob. Should have CV_32F or CV_8U depth. + * @param name A name of input layer. + * @param scalefactor An optional normalization scale. + * @param mean An optional mean subtraction values. + * @see connect(String, String) to know format of the descriptor. + * + * If scale or mean values are specified, a final input blob is computed + * as: + * \f[input(n,c,h,w) = scalefactor \times (blob(n,c,h,w) - mean_c)\f] + */ + CV_WRAP void setInput(InputArray blob, const String& name = "", + double scalefactor = 1.0, const Scalar& mean = Scalar()); + + /** @brief Sets the new value for the learned param of the layer. + * @param layer name or id of the layer. + * @param numParam index of the layer parameter in the Layer::blobs array. + * @param blob the new value. + * @see Layer::blobs + * @note If shape of the new blob differs from the previous shape, + * then the following forward pass may fail. + */ + CV_WRAP void setParam(LayerId layer, int numParam, const Mat &blob); + + /** @brief Returns parameter blob of the layer. + * @param layer name or id of the layer. + * @param numParam index of the layer parameter in the Layer::blobs array. + * @see Layer::blobs + */ + CV_WRAP Mat getParam(LayerId layer, int numParam = 0); + + /** @brief Returns indexes of layers with unconnected outputs. + */ + CV_WRAP std::vector getUnconnectedOutLayers() const; + + /** @brief Returns names of layers with unconnected outputs. + */ + CV_WRAP std::vector getUnconnectedOutLayersNames() const; + + /** @brief Returns input and output shapes for all layers in loaded model; + * preliminary inferencing isn't necessary. + * @param netInputShapes shapes for all input blobs in net input layer. + * @param layersIds output parameter for layer IDs. + * @param inLayersShapes output parameter for input layers shapes; + * order is the same as in layersIds + * @param outLayersShapes output parameter for output layers shapes; + * order is the same as in layersIds + */ + CV_WRAP void getLayersShapes(const std::vector& netInputShapes, + CV_OUT std::vector& layersIds, + CV_OUT std::vector >& inLayersShapes, + CV_OUT std::vector >& outLayersShapes) const; + + /** @overload */ + CV_WRAP void getLayersShapes(const MatShape& netInputShape, + CV_OUT std::vector& layersIds, + CV_OUT std::vector >& inLayersShapes, + CV_OUT std::vector >& outLayersShapes) const; + + /** @brief Returns input and output shapes for layer with specified + * id in loaded model; preliminary inferencing isn't necessary. + * @param netInputShape shape input blob in net input layer. + * @param layerId id for layer. + * @param inLayerShapes output parameter for input layers shapes; + * order is the same as in layersIds + * @param outLayerShapes output parameter for output layers shapes; + * order is the same as in layersIds + */ + void getLayerShapes(const MatShape& netInputShape, + const int layerId, + CV_OUT std::vector& inLayerShapes, + CV_OUT std::vector& outLayerShapes) const; // FIXIT: CV_WRAP + + /** @overload */ + void getLayerShapes(const std::vector& netInputShapes, + const int layerId, + CV_OUT std::vector& inLayerShapes, + CV_OUT std::vector& outLayerShapes) const; // FIXIT: CV_WRAP + + /** @brief Computes FLOP for whole loaded model with specified input shapes. + * @param netInputShapes vector of shapes for all net inputs. + * @returns computed FLOP. + */ + CV_WRAP int64 getFLOPS(const std::vector& netInputShapes) const; + /** @overload */ + CV_WRAP int64 getFLOPS(const MatShape& netInputShape) const; + /** @overload */ + CV_WRAP int64 getFLOPS(const int layerId, + const std::vector& netInputShapes) const; + /** @overload */ + CV_WRAP int64 getFLOPS(const int layerId, + const MatShape& netInputShape) const; + + /** @brief Returns list of types for layer used in model. + * @param layersTypes output parameter for returning types. + */ + CV_WRAP void getLayerTypes(CV_OUT std::vector& layersTypes) const; + + /** @brief Returns count of layers of specified type. + * @param layerType type. + * @returns count of layers + */ + CV_WRAP int getLayersCount(const String& layerType) const; + + /** @brief Computes bytes number which are required to store + * all weights and intermediate blobs for model. + * @param netInputShapes vector of shapes for all net inputs. + * @param weights output parameter to store resulting bytes for weights. + * @param blobs output parameter to store resulting bytes for intermediate blobs. + */ + void getMemoryConsumption(const std::vector& netInputShapes, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; // FIXIT: CV_WRAP + /** @overload */ + CV_WRAP void getMemoryConsumption(const MatShape& netInputShape, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; + /** @overload */ + CV_WRAP void getMemoryConsumption(const int layerId, + const std::vector& netInputShapes, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; + /** @overload */ + CV_WRAP void getMemoryConsumption(const int layerId, + const MatShape& netInputShape, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; + + /** @brief Computes bytes number which are required to store + * all weights and intermediate blobs for each layer. + * @param netInputShapes vector of shapes for all net inputs. + * @param layerIds output vector to save layer IDs. + * @param weights output parameter to store resulting bytes for weights. + * @param blobs output parameter to store resulting bytes for intermediate blobs. + */ + void getMemoryConsumption(const std::vector& netInputShapes, + CV_OUT std::vector& layerIds, + CV_OUT std::vector& weights, + CV_OUT std::vector& blobs) const; // FIXIT: CV_WRAP + /** @overload */ + void getMemoryConsumption(const MatShape& netInputShape, + CV_OUT std::vector& layerIds, + CV_OUT std::vector& weights, + CV_OUT std::vector& blobs) const; // FIXIT: CV_WRAP + + /** @brief Enables or disables layer fusion in the network. + * @param fusion true to enable the fusion, false to disable. The fusion is enabled by default. + */ + CV_WRAP void enableFusion(bool fusion); + + /** @brief Returns overall time for inference and timings (in ticks) for layers. + * + * Indexes in returned vector correspond to layers ids. Some layers can be fused with others, + * in this case zero ticks count will be return for that skipped layers. Supported by DNN_BACKEND_OPENCV on DNN_TARGET_CPU only. + * + * @param[out] timings vector for tick timings for all layers. + * @return overall ticks for model inference. + */ + CV_WRAP int64 getPerfProfile(CV_OUT std::vector& timings); + + private: + struct Impl; + Ptr impl; + }; + + /** @brief Reads a network model stored in Darknet model files. + * @param cfgFile path to the .cfg file with text description of the network architecture. + * @param darknetModel path to the .weights file with learned network. + * @returns Network object that ready to do forward, throw an exception in failure cases. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String()); + + /** @brief Reads a network model stored in Darknet model files. + * @param bufferCfg A buffer contains a content of .cfg file with text description of the network architecture. + * @param bufferModel A buffer contains a content of .weights file with learned network. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromDarknet(const std::vector& bufferCfg, + const std::vector& bufferModel = std::vector()); + + /** @brief Reads a network model stored in Darknet model files. + * @param bufferCfg A buffer contains a content of .cfg file with text description of the network architecture. + * @param lenCfg Number of bytes to read from bufferCfg + * @param bufferModel A buffer contains a content of .weights file with learned network. + * @param lenModel Number of bytes to read from bufferModel + * @returns Net object. + */ + CV_EXPORTS Net readNetFromDarknet(const char *bufferCfg, size_t lenCfg, + const char *bufferModel = NULL, size_t lenModel = 0); + + /** @brief Reads a network model stored in Caffe framework's format. + * @param prototxt path to the .prototxt file with text description of the network architecture. + * @param caffeModel path to the .caffemodel file with learned network. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String()); + + /** @brief Reads a network model stored in Caffe model in memory. + * @param bufferProto buffer containing the content of the .prototxt file + * @param bufferModel buffer containing the content of the .caffemodel file + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromCaffe(const std::vector& bufferProto, + const std::vector& bufferModel = std::vector()); + + /** @brief Reads a network model stored in Caffe model in memory. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + * @param bufferProto buffer containing the content of the .prototxt file + * @param lenProto length of bufferProto + * @param bufferModel buffer containing the content of the .caffemodel file + * @param lenModel length of bufferModel + * @returns Net object. + */ + CV_EXPORTS Net readNetFromCaffe(const char *bufferProto, size_t lenProto, + const char *bufferModel = NULL, size_t lenModel = 0); + + /** @brief Reads a network model stored in TensorFlow framework's format. + * @param model path to the .pb file with binary protobuf description of the network architecture + * @param config path to the .pbtxt file that contains text graph definition in protobuf format. + * Resulting Net object is built by text graph using weights from a binary one that + * let us make it more flexible. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromTensorflow(const String &model, const String &config = String()); + + /** @brief Reads a network model stored in TensorFlow framework's format. + * @param bufferModel buffer containing the content of the pb file + * @param bufferConfig buffer containing the content of the pbtxt file + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromTensorflow(const std::vector& bufferModel, + const std::vector& bufferConfig = std::vector()); + + /** @brief Reads a network model stored in TensorFlow framework's format. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + * @param bufferModel buffer containing the content of the pb file + * @param lenModel length of bufferModel + * @param bufferConfig buffer containing the content of the pbtxt file + * @param lenConfig length of bufferConfig + */ + CV_EXPORTS Net readNetFromTensorflow(const char *bufferModel, size_t lenModel, + const char *bufferConfig = NULL, size_t lenConfig = 0); + + /** + * @brief Reads a network model stored in Torch7 framework's format. + * @param model path to the file, dumped from Torch by using torch.save() function. + * @param isBinary specifies whether the network was serialized in ascii mode or binary. + * @param evaluate specifies testing phase of network. If true, it's similar to evaluate() method in Torch. + * @returns Net object. + * + * @note Ascii mode of Torch serializer is more preferable, because binary mode extensively use `long` type of C language, + * which has various bit-length on different systems. + * + * The loading file must contain serialized nn.Module object + * with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors. + * + * List of supported layers (i.e. object instances derived from Torch nn.Module class): + * - nn.Sequential + * - nn.Parallel + * - nn.Concat + * - nn.Linear + * - nn.SpatialConvolution + * - nn.SpatialMaxPooling, nn.SpatialAveragePooling + * - nn.ReLU, nn.TanH, nn.Sigmoid + * - nn.Reshape + * - nn.SoftMax, nn.LogSoftMax + * + * Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported. + */ + CV_EXPORTS_W Net readNetFromTorch(const String &model, bool isBinary = true, bool evaluate = true); + + /** + * @brief Read deep learning network represented in one of the supported formats. + * @param[in] model Binary file contains trained weights. The following file + * extensions are expected for models from different frameworks: + * * `*.caffemodel` (Caffe, http://caffe.berkeleyvision.org/) + * * `*.pb` (TensorFlow, https://www.tensorflow.org/) + * * `*.t7` | `*.net` (Torch, http://torch.ch/) + * * `*.weights` (Darknet, https://pjreddie.com/darknet/) + * * `*.bin` (DLDT, https://software.intel.com/openvino-toolkit) + * * `*.onnx` (ONNX, https://onnx.ai/) + * @param[in] config Text file contains network configuration. It could be a + * file with the following extensions: + * * `*.prototxt` (Caffe, http://caffe.berkeleyvision.org/) + * * `*.pbtxt` (TensorFlow, https://www.tensorflow.org/) + * * `*.cfg` (Darknet, https://pjreddie.com/darknet/) + * * `*.xml` (DLDT, https://software.intel.com/openvino-toolkit) + * @param[in] framework Explicit framework name tag to determine a format. + * @returns Net object. + * + * This function automatically detects an origin framework of trained model + * and calls an appropriate function such @ref readNetFromCaffe, @ref readNetFromTensorflow, + * @ref readNetFromTorch or @ref readNetFromDarknet. An order of @p model and @p config + * arguments does not matter. + */ + CV_EXPORTS_W Net readNet(const String& model, const String& config = "", const String& framework = ""); + + /** + * @brief Read deep learning network represented in one of the supported formats. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + * @param[in] framework Name of origin framework. + * @param[in] bufferModel A buffer with a content of binary file with weights + * @param[in] bufferConfig A buffer with a content of text file contains network configuration. + * @returns Net object. + */ + CV_EXPORTS_W Net readNet(const String& framework, const std::vector& bufferModel, + const std::vector& bufferConfig = std::vector()); + + /** @brief Loads blob which was serialized as torch.Tensor object of Torch7 framework. + * @warning This function has the same limitations as readNetFromTorch(). + */ + CV_EXPORTS_W Mat readTorchBlob(const String &filename, bool isBinary = true); + + /** @brief Load a network from Intel's Model Optimizer intermediate representation. + * @param[in] xml XML configuration file with network's topology. + * @param[in] bin Binary file with trained weights. + * @returns Net object. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_EXPORTS_W + Net readNetFromModelOptimizer(const String &xml, const String &bin); + + /** @brief Load a network from Intel's Model Optimizer intermediate representation. + * @param[in] bufferModelConfig Buffer contains XML configuration with network's topology. + * @param[in] bufferWeights Buffer contains binary data with trained weights. + * @returns Net object. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_EXPORTS_W + Net readNetFromModelOptimizer(const std::vector& bufferModelConfig, const std::vector& bufferWeights); + + /** @brief Load a network from Intel's Model Optimizer intermediate representation. + * @param[in] bufferModelConfigPtr Pointer to buffer which contains XML configuration with network's topology. + * @param[in] bufferModelConfigSize Binary size of XML configuration data. + * @param[in] bufferWeightsPtr Pointer to buffer which contains binary data with trained weights. + * @param[in] bufferWeightsSize Binary size of trained weights data. + * @returns Net object. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_EXPORTS + Net readNetFromModelOptimizer(const uchar* bufferModelConfigPtr, size_t bufferModelConfigSize, + const uchar* bufferWeightsPtr, size_t bufferWeightsSize); + + /** @brief Reads a network model ONNX. + * @param onnxFile path to the .onnx file with text description of the network architecture. + * @returns Network object that ready to do forward, throw an exception in failure cases. + */ + CV_EXPORTS_W Net readNetFromONNX(const String &onnxFile); + + /** @brief Reads a network model from ONNX + * in-memory buffer. + * @param buffer memory address of the first byte of the buffer. + * @param sizeBuffer size of the buffer. + * @returns Network object that ready to do forward, throw an exception + * in failure cases. + */ + CV_EXPORTS Net readNetFromONNX(const char* buffer, size_t sizeBuffer); + + /** @brief Reads a network model from ONNX + * in-memory buffer. + * @param buffer in-memory buffer that stores the ONNX model bytes. + * @returns Network object that ready to do forward, throw an exception + * in failure cases. + */ + CV_EXPORTS_W Net readNetFromONNX(const std::vector& buffer); + + /** @brief Creates blob from .pb file. + * @param path to the .pb file with input tensor. + * @returns Mat. + */ + CV_EXPORTS_W Mat readTensorFromONNX(const String& path); + + /** @brief Creates 4-dimensional blob from image. Optionally resizes and crops @p image from center, + * subtract @p mean values, scales values by @p scalefactor, swap Blue and Red channels. + * @param image input image (with 1-, 3- or 4-channels). + * @param size spatial size for output image + * @param mean scalar with mean values which are subtracted from channels. Values are intended + * to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true. + * @param scalefactor multiplier for @p image values. + * @param swapRB flag which indicates that swap first and last channels + * in 3-channel image is necessary. + * @param crop flag which indicates whether image will be cropped after resize or not + * @param ddepth Depth of output blob. Choose CV_32F or CV_8U. + * @details if @p crop is true, input image is resized so one side after resize is equal to corresponding + * dimension in @p size and another one is equal or larger. Then, crop from the center is performed. + * If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. + * @returns 4-dimensional Mat with NCHW dimensions order. + */ + CV_EXPORTS_W Mat blobFromImage(InputArray image, double scalefactor=1.0, const Size& size = Size(), + const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, + int ddepth=CV_32F); + + /** @brief Creates 4-dimensional blob from image. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + */ + CV_EXPORTS void blobFromImage(InputArray image, OutputArray blob, double scalefactor=1.0, + const Size& size = Size(), const Scalar& mean = Scalar(), + bool swapRB=false, bool crop=false, int ddepth=CV_32F); + + + /** @brief Creates 4-dimensional blob from series of images. Optionally resizes and + * crops @p images from center, subtract @p mean values, scales values by @p scalefactor, + * swap Blue and Red channels. + * @param images input images (all with 1-, 3- or 4-channels). + * @param size spatial size for output image + * @param mean scalar with mean values which are subtracted from channels. Values are intended + * to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true. + * @param scalefactor multiplier for @p images values. + * @param swapRB flag which indicates that swap first and last channels + * in 3-channel image is necessary. + * @param crop flag which indicates whether image will be cropped after resize or not + * @param ddepth Depth of output blob. Choose CV_32F or CV_8U. + * @details if @p crop is true, input image is resized so one side after resize is equal to corresponding + * dimension in @p size and another one is equal or larger. Then, crop from the center is performed. + * If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. + * @returns 4-dimensional Mat with NCHW dimensions order. + */ + CV_EXPORTS_W Mat blobFromImages(InputArrayOfArrays images, double scalefactor=1.0, + Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, + int ddepth=CV_32F); + + /** @brief Creates 4-dimensional blob from series of images. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + */ + CV_EXPORTS void blobFromImages(InputArrayOfArrays images, OutputArray blob, + double scalefactor=1.0, Size size = Size(), + const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, + int ddepth=CV_32F); + + /** @brief Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure + * (std::vector). + * @param[in] blob_ 4 dimensional array (images, channels, height, width) in floating point precision (CV_32F) from + * which you would like to extract the images. + * @param[out] images_ array of 2D Mat containing the images extracted from the blob in floating point precision + * (CV_32F). They are non normalized neither mean added. The number of returned images equals the first dimension + * of the blob (batch size). Every image has a number of channels equals to the second dimension of the blob (depth). + */ + CV_EXPORTS_W void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_); + + /** @brief Convert all weights of Caffe network to half precision floating point. + * @param src Path to origin model from Caffe framework contains single + * precision floating point weights (usually has `.caffemodel` extension). + * @param dst Path to destination model with updated weights. + * @param layersTypes Set of layers types which parameters will be converted. + * By default, converts only Convolutional and Fully-Connected layers' + * weights. + * + * @note Shrinked model has no origin float32 weights so it can't be used + * in origin Caffe framework anymore. However the structure of data + * is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe. + * So the resulting model may be used there. + */ + CV_EXPORTS_W void shrinkCaffeModel(const String& src, const String& dst, + const std::vector& layersTypes = std::vector()); + + /** @brief Create a text representation for a binary network stored in protocol buffer format. + * @param[in] model A path to binary network. + * @param[in] output A path to output text file to be created. + * + * @note To reduce output file size, trained weights are not included. + */ + CV_EXPORTS_W void writeTextGraph(const String& model, const String& output); + + /** @brief Performs non maximum suppression given boxes and corresponding scores. + + * @param bboxes a set of bounding boxes to apply NMS. + * @param scores a set of corresponding confidences. + * @param score_threshold a threshold used to filter boxes by score. + * @param nms_threshold a threshold used in non maximum suppression. + * @param indices the kept indices of bboxes after NMS. + * @param eta a coefficient in adaptive threshold formula: \f$nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\f$. + * @param top_k if `>0`, keep at most @p top_k picked indices. + */ + CV_EXPORTS void NMSBoxes(const std::vector& bboxes, const std::vector& scores, + const float score_threshold, const float nms_threshold, + CV_OUT std::vector& indices, + const float eta = 1.f, const int top_k = 0); + + CV_EXPORTS_W void NMSBoxes(const std::vector& bboxes, const std::vector& scores, + const float score_threshold, const float nms_threshold, + CV_OUT std::vector& indices, + const float eta = 1.f, const int top_k = 0); + + CV_EXPORTS_AS(NMSBoxesRotated) void NMSBoxes(const std::vector& bboxes, const std::vector& scores, + const float score_threshold, const float nms_threshold, + CV_OUT std::vector& indices, + const float eta = 1.f, const int top_k = 0); + + /** + * @brief Enum of Soft NMS methods. + * @see softNMSBoxes + */ + enum class SoftNMSMethod + { + SOFTNMS_LINEAR = 1, + SOFTNMS_GAUSSIAN = 2 + }; + + /** @brief Performs soft non maximum suppression given boxes and corresponding scores. + * Reference: https://arxiv.org/abs/1704.04503 + * @param bboxes a set of bounding boxes to apply Soft NMS. + * @param scores a set of corresponding confidences. + * @param updated_scores a set of corresponding updated confidences. + * @param score_threshold a threshold used to filter boxes by score. + * @param nms_threshold a threshold used in non maximum suppression. + * @param indices the kept indices of bboxes after NMS. + * @param top_k keep at most @p top_k picked indices. + * @param sigma parameter of Gaussian weighting. + * @param method Gaussian or linear. + * @see SoftNMSMethod + */ + CV_EXPORTS_W void softNMSBoxes(const std::vector& bboxes, + const std::vector& scores, + CV_OUT std::vector& updated_scores, + const float score_threshold, + const float nms_threshold, + CV_OUT std::vector& indices, + size_t top_k = 0, + const float sigma = 0.5, + SoftNMSMethod method = SoftNMSMethod::SOFTNMS_GAUSSIAN); + + + /** @brief This class is presented high-level API for neural networks. + * + * Model allows to set params for preprocessing input image. + * Model creates net from file with trained weights and config, + * sets preprocessing input and runs forward pass. + */ + class CV_EXPORTS_W_SIMPLE Model + { + public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + Model(); + + Model(const Model&) = default; + Model(Model&&) = default; + Model& operator=(const Model&) = default; + Model& operator=(Model&&) = default; + + /** + * @brief Create model from deep learning network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP Model(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP Model(const Net& network); + + /** @brief Set input size for frame. + * @param[in] size New input size. + * @note If shape of the new blob less than 0, then frame size not change. + */ + CV_WRAP Model& setInputSize(const Size& size); + + /** @overload + * @param[in] width New input width. + * @param[in] height New input height. + */ + CV_WRAP inline + Model& setInputSize(int width, int height) { return setInputSize(Size(width, height)); } + + /** @brief Set mean value for frame. + * @param[in] mean Scalar with mean values which are subtracted from channels. + */ + CV_WRAP Model& setInputMean(const Scalar& mean); + + /** @brief Set scalefactor value for frame. + * @param[in] scale Multiplier for frame values. + */ + CV_WRAP Model& setInputScale(double scale); + + /** @brief Set flag crop for frame. + * @param[in] crop Flag which indicates whether image will be cropped after resize or not. + */ + CV_WRAP Model& setInputCrop(bool crop); + + /** @brief Set flag swapRB for frame. + * @param[in] swapRB Flag which indicates that swap first and last channels. + */ + CV_WRAP Model& setInputSwapRB(bool swapRB); + + /** @brief Set preprocessing parameters for frame. + * @param[in] size New input size. + * @param[in] mean Scalar with mean values which are subtracted from channels. + * @param[in] scale Multiplier for frame values. + * @param[in] swapRB Flag which indicates that swap first and last channels. + * @param[in] crop Flag which indicates whether image will be cropped after resize or not. + * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) ) + */ + CV_WRAP void setInputParams(double scale = 1.0, const Size& size = Size(), + const Scalar& mean = Scalar(), bool swapRB = false, bool crop = false); + + /** @brief Given the @p input frame, create input blob, run net and return the output @p blobs. + * @param[in] frame The input image. + * @param[out] outs Allocated output blobs, which will store results of the computation. + */ + CV_WRAP void predict(InputArray frame, OutputArrayOfArrays outs) const; + + + // ============================== Net proxy methods ============================== + // Never expose methods with network implementation details, like: + // - addLayer, addLayerToPrev, connect, setInputsNames, setInputShape, setParam, getParam + // - getLayer*, getUnconnectedOutLayers, getUnconnectedOutLayersNames, getLayersShapes + // - forward* methods, setInput + + /// @sa Net::setPreferableBackend + CV_WRAP Model& setPreferableBackend(dnn::Backend backendId); + /// @sa Net::setPreferableTarget + CV_WRAP Model& setPreferableTarget(dnn::Target targetId); + + CV_DEPRECATED_EXTERNAL + operator Net&() const { return getNetwork_(); } + + //protected: - internal/tests usage only + Net& getNetwork_() const; + inline Net& getNetwork_() { return const_cast(this)->getNetwork_(); } + + struct Impl; + inline Impl* getImpl() const { return impl.get(); } + inline Impl& getImplRef() const { CV_DbgAssert(impl); return *impl.get(); } + protected: + Ptr impl; + }; + + /** @brief This class represents high-level API for classification models. + * + * ClassificationModel allows to set params for preprocessing input image. + * ClassificationModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and return top-1 prediction. + */ + class CV_EXPORTS_W_SIMPLE ClassificationModel : public Model + { + public: + /** + * @brief Create classification model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP ClassificationModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP ClassificationModel(const Net& network); + + /** @brief Given the @p input frame, create input blob, run net and return top-1 prediction. + * @param[in] frame The input image. + */ + std::pair classify(InputArray frame); + + /** @overload */ + CV_WRAP void classify(InputArray frame, CV_OUT int& classId, CV_OUT float& conf); + }; + + /** @brief This class represents high-level API for keypoints models + * + * KeypointsModel allows to set params for preprocessing input image. + * KeypointsModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and returns the x and y coordinates of each detected keypoint + */ + class CV_EXPORTS_W_SIMPLE KeypointsModel: public Model + { + public: + /** + * @brief Create keypoints model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP KeypointsModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP KeypointsModel(const Net& network); + + /** @brief Given the @p input frame, create input blob, run net + * @param[in] frame The input image. + * @param thresh minimum confidence threshold to select a keypoint + * @returns a vector holding the x and y coordinates of each detected keypoint + * + */ + CV_WRAP std::vector estimate(InputArray frame, float thresh=0.5); + }; + + /** @brief This class represents high-level API for segmentation models + * + * SegmentationModel allows to set params for preprocessing input image. + * SegmentationModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and returns the class prediction for each pixel. + */ + class CV_EXPORTS_W_SIMPLE SegmentationModel: public Model + { + public: + /** + * @brief Create segmentation model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP SegmentationModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP SegmentationModel(const Net& network); + + /** @brief Given the @p input frame, create input blob, run net + * @param[in] frame The input image. + * @param[out] mask Allocated class prediction for each pixel + */ + CV_WRAP void segment(InputArray frame, OutputArray mask); + }; + + /** @brief This class represents high-level API for object detection networks. + * + * DetectionModel allows to set params for preprocessing input image. + * DetectionModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and return result detections. + * For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported. + */ + class CV_EXPORTS_W_SIMPLE DetectionModel : public Model + { + public: + /** + * @brief Create detection model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP DetectionModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP DetectionModel(const Net& network); + + CV_DEPRECATED_EXTERNAL // avoid using in C++ code (need to fix bindings first) + DetectionModel(); + + /** + * @brief nmsAcrossClasses defaults to false, + * such that when non max suppression is used during the detect() function, it will do so per-class. + * This function allows you to toggle this behaviour. + * @param[in] value The new value for nmsAcrossClasses + */ + CV_WRAP DetectionModel& setNmsAcrossClasses(bool value); + + /** + * @brief Getter for nmsAcrossClasses. This variable defaults to false, + * such that when non max suppression is used during the detect() function, it will do so only per-class + */ + CV_WRAP bool getNmsAcrossClasses(); + + /** @brief Given the @p input frame, create input blob, run net and return result detections. + * @param[in] frame The input image. + * @param[out] classIds Class indexes in result detection. + * @param[out] confidences A set of corresponding confidences. + * @param[out] boxes A set of bounding boxes. + * @param[in] confThreshold A threshold used to filter boxes by confidences. + * @param[in] nmsThreshold A threshold used in non maximum suppression. + */ + CV_WRAP void detect(InputArray frame, CV_OUT std::vector& classIds, + CV_OUT std::vector& confidences, CV_OUT std::vector& boxes, + float confThreshold = 0.5f, float nmsThreshold = 0.0f); + }; + + +/** @brief This class represents high-level API for text recognition networks. + * + * TextRecognitionModel allows to set params for preprocessing input image. + * TextRecognitionModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and return recognition result. + * For TextRecognitionModel, CRNN-CTC is supported. + */ +class CV_EXPORTS_W_SIMPLE TextRecognitionModel : public Model +{ +public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextRecognitionModel(); + + /** + * @brief Create Text Recognition model from deep learning network + * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method + * @param[in] network Net object + */ + CV_WRAP TextRecognitionModel(const Net& network); + + /** + * @brief Create text recognition model from network represented in one of the supported formats + * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method + * @param[in] model Binary file contains trained weights + * @param[in] config Text file contains network configuration + */ + CV_WRAP inline + TextRecognitionModel(const std::string& model, const std::string& config = "") + : TextRecognitionModel(readNet(model, config)) { /* nothing */ } + + /** + * @brief Set the decoding method of translating the network output into string + * @param[in] decodeType The decoding method of translating the network output into string, currently supported type: + * - `"CTC-greedy"` greedy decoding for the output of CTC-based methods + * - `"CTC-prefix-beam-search"` Prefix beam search decoding for the output of CTC-based methods + */ + CV_WRAP + TextRecognitionModel& setDecodeType(const std::string& decodeType); + + /** + * @brief Get the decoding method + * @return the decoding method + */ + CV_WRAP + const std::string& getDecodeType() const; + + /** + * @brief Set the decoding method options for `"CTC-prefix-beam-search"` decode usage + * @param[in] beamSize Beam size for search + * @param[in] vocPruneSize Parameter to optimize big vocabulary search, + * only take top @p vocPruneSize tokens in each search step, @p vocPruneSize <= 0 stands for disable this prune. + */ + CV_WRAP + TextRecognitionModel& setDecodeOptsCTCPrefixBeamSearch(int beamSize, int vocPruneSize = 0); + + /** + * @brief Set the vocabulary for recognition. + * @param[in] vocabulary the associated vocabulary of the network. + */ + CV_WRAP + TextRecognitionModel& setVocabulary(const std::vector& vocabulary); + + /** + * @brief Get the vocabulary for recognition. + * @return vocabulary the associated vocabulary + */ + CV_WRAP + const std::vector& getVocabulary() const; + + /** + * @brief Given the @p input frame, create input blob, run net and return recognition result + * @param[in] frame The input image + * @return The text recognition result + */ + CV_WRAP + std::string recognize(InputArray frame) const; + + /** + * @brief Given the @p input frame, create input blob, run net and return recognition result + * @param[in] frame The input image + * @param[in] roiRects List of text detection regions of interest (cv::Rect, CV_32SC4). ROIs is be cropped as the network inputs + * @param[out] results A set of text recognition results. + */ + CV_WRAP + void recognize(InputArray frame, InputArrayOfArrays roiRects, CV_OUT std::vector& results) const; +}; + + +/** @brief Base class for text detection networks + */ +class CV_EXPORTS_W_SIMPLE TextDetectionModel : public Model +{ +protected: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextDetectionModel(); + +public: + + /** @brief Performs detection + * + * Given the input @p frame, prepare network input, run network inference, post-process network output and return result detections. + * + * Each result is quadrangle's 4 points in this order: + * - bottom-left + * - top-left + * - top-right + * - bottom-right + * + * Use cv::getPerspectiveTransform function to retrive image region without perspective transformations. + * + * @note If DL model doesn't support that kind of output then result may be derived from detectTextRectangles() output. + * + * @param[in] frame The input image + * @param[out] detections array with detections' quadrangles (4 points per result) + * @param[out] confidences array with detection confidences + */ + CV_WRAP + void detect( + InputArray frame, + CV_OUT std::vector< std::vector >& detections, + CV_OUT std::vector& confidences + ) const; + + /** @overload */ + CV_WRAP + void detect( + InputArray frame, + CV_OUT std::vector< std::vector >& detections + ) const; + + /** @brief Performs detection + * + * Given the input @p frame, prepare network input, run network inference, post-process network output and return result detections. + * + * Each result is rotated rectangle. + * + * @note Result may be inaccurate in case of strong perspective transformations. + * + * @param[in] frame the input image + * @param[out] detections array with detections' RotationRect results + * @param[out] confidences array with detection confidences + */ + CV_WRAP + void detectTextRectangles( + InputArray frame, + CV_OUT std::vector& detections, + CV_OUT std::vector& confidences + ) const; + + /** @overload */ + CV_WRAP + void detectTextRectangles( + InputArray frame, + CV_OUT std::vector& detections + ) const; +}; + +/** @brief This class represents high-level API for text detection DL networks compatible with EAST model. + * + * Configurable parameters: + * - (float) confThreshold - used to filter boxes by confidences, default: 0.5f + * - (float) nmsThreshold - used in non maximum suppression, default: 0.0f + */ +class CV_EXPORTS_W_SIMPLE TextDetectionModel_EAST : public TextDetectionModel +{ +public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextDetectionModel_EAST(); + + /** + * @brief Create text detection algorithm from deep learning network + * @param[in] network Net object + */ + CV_WRAP TextDetectionModel_EAST(const Net& network); + + /** + * @brief Create text detection model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP inline + TextDetectionModel_EAST(const std::string& model, const std::string& config = "") + : TextDetectionModel_EAST(readNet(model, config)) { /* nothing */ } + + /** + * @brief Set the detection confidence threshold + * @param[in] confThreshold A threshold used to filter boxes by confidences + */ + CV_WRAP + TextDetectionModel_EAST& setConfidenceThreshold(float confThreshold); + + /** + * @brief Get the detection confidence threshold + */ + CV_WRAP + float getConfidenceThreshold() const; + + /** + * @brief Set the detection NMS filter threshold + * @param[in] nmsThreshold A threshold used in non maximum suppression + */ + CV_WRAP + TextDetectionModel_EAST& setNMSThreshold(float nmsThreshold); + + /** + * @brief Get the detection confidence threshold + */ + CV_WRAP + float getNMSThreshold() const; +}; + +/** @brief This class represents high-level API for text detection DL networks compatible with DB model. + * + * Related publications: @cite liao2020real + * Paper: https://arxiv.org/abs/1911.08947 + * For more information about the hyper-parameters setting, please refer to https://github.com/MhLiao/DB + * + * Configurable parameters: + * - (float) binaryThreshold - The threshold of the binary map. It is usually set to 0.3. + * - (float) polygonThreshold - The threshold of text polygons. It is usually set to 0.5, 0.6, and 0.7. Default is 0.5f + * - (double) unclipRatio - The unclip ratio of the detected text region, which determines the output size. It is usually set to 2.0. + * - (int) maxCandidates - The max number of the output results. + */ +class CV_EXPORTS_W_SIMPLE TextDetectionModel_DB : public TextDetectionModel +{ +public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextDetectionModel_DB(); + + /** + * @brief Create text detection algorithm from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP TextDetectionModel_DB(const Net& network); + + /** + * @brief Create text detection model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP inline + TextDetectionModel_DB(const std::string& model, const std::string& config = "") + : TextDetectionModel_DB(readNet(model, config)) { /* nothing */ } + + CV_WRAP TextDetectionModel_DB& setBinaryThreshold(float binaryThreshold); + CV_WRAP float getBinaryThreshold() const; + + CV_WRAP TextDetectionModel_DB& setPolygonThreshold(float polygonThreshold); + CV_WRAP float getPolygonThreshold() const; + + CV_WRAP TextDetectionModel_DB& setUnclipRatio(double unclipRatio); + CV_WRAP double getUnclipRatio() const; + + CV_WRAP TextDetectionModel_DB& setMaxCandidates(int maxCandidates); + CV_WRAP int getMaxCandidates() const; +}; + +//! @} +CV__DNN_INLINE_NS_END +} +} + +#include +#include + +/// @deprecated Include this header directly from application. Automatic inclusion will be removed +#include + +#endif /* OPENCV_DNN_DNN_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/dnn.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/dnn.inl.hpp new file mode 100644 index 0000000..8312a41 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/dnn.inl.hpp @@ -0,0 +1,412 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_INL_HPP +#define OPENCV_DNN_DNN_INL_HPP + +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +template +DictValue DictValue::arrayInt(TypeIter begin, int size) +{ + DictValue res(Param::INT, new AutoBuffer(size)); + for (int j = 0; j < size; begin++, j++) + (*res.pi)[j] = *begin; + return res; +} + +template +DictValue DictValue::arrayReal(TypeIter begin, int size) +{ + DictValue res(Param::REAL, new AutoBuffer(size)); + for (int j = 0; j < size; begin++, j++) + (*res.pd)[j] = *begin; + return res; +} + +template +DictValue DictValue::arrayString(TypeIter begin, int size) +{ + DictValue res(Param::STRING, new AutoBuffer(size)); + for (int j = 0; j < size; begin++, j++) + (*res.ps)[j] = *begin; + return res; +} + +template<> +inline DictValue DictValue::get(int idx) const +{ + CV_Assert(idx == -1); + return *this; +} + +template<> +inline int64 DictValue::get(int idx) const +{ + CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size())); + idx = (idx == -1) ? 0 : idx; + + if (type == Param::INT) + { + return (*pi)[idx]; + } + else if (type == Param::REAL) + { + double doubleValue = (*pd)[idx]; + + double fracpart, intpart; + fracpart = std::modf(doubleValue, &intpart); + CV_Assert(fracpart == 0.0); + + return (int64)doubleValue; + } + else if (type == Param::STRING) + { + return std::atoi((*ps)[idx].c_str()); + } + else + { + CV_Assert(isInt() || isReal() || isString()); + return 0; + } +} + +template<> +inline int DictValue::get(int idx) const +{ + return (int)get(idx); +} + +inline int DictValue::getIntValue(int idx) const +{ + return (int)get(idx); +} + +template<> +inline unsigned DictValue::get(int idx) const +{ + return (unsigned)get(idx); +} + +template<> +inline bool DictValue::get(int idx) const +{ + return (get(idx) != 0); +} + +template<> +inline double DictValue::get(int idx) const +{ + CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size())); + idx = (idx == -1) ? 0 : idx; + + if (type == Param::REAL) + { + return (*pd)[idx]; + } + else if (type == Param::INT) + { + return (double)(*pi)[idx]; + } + else if (type == Param::STRING) + { + return std::atof((*ps)[idx].c_str()); + } + else + { + CV_Assert(isReal() || isInt() || isString()); + return 0; + } +} + +inline double DictValue::getRealValue(int idx) const +{ + return get(idx); +} + +template<> +inline float DictValue::get(int idx) const +{ + return (float)get(idx); +} + +template<> +inline String DictValue::get(int idx) const +{ + CV_Assert(isString()); + CV_Assert((idx == -1 && ps->size() == 1) || (idx >= 0 && idx < (int)ps->size())); + return (*ps)[(idx == -1) ? 0 : idx]; +} + + +inline String DictValue::getStringValue(int idx) const +{ + return get(idx); +} + +inline void DictValue::release() +{ + switch (type) + { + case Param::INT: + delete pi; + break; + case Param::STRING: + delete ps; + break; + case Param::REAL: + delete pd; + break; + case Param::BOOLEAN: + case Param::MAT: + case Param::MAT_VECTOR: + case Param::ALGORITHM: + case Param::FLOAT: + case Param::UNSIGNED_INT: + case Param::UINT64: + case Param::UCHAR: + case Param::SCALAR: + break; // unhandled + } +} + +inline DictValue::~DictValue() +{ + release(); +} + +inline DictValue & DictValue::operator=(const DictValue &r) +{ + if (&r == this) + return *this; + + if (r.type == Param::INT) + { + AutoBuffer *tmp = new AutoBuffer(*r.pi); + release(); + pi = tmp; + } + else if (r.type == Param::STRING) + { + AutoBuffer *tmp = new AutoBuffer(*r.ps); + release(); + ps = tmp; + } + else if (r.type == Param::REAL) + { + AutoBuffer *tmp = new AutoBuffer(*r.pd); + release(); + pd = tmp; + } + + type = r.type; + + return *this; +} + +inline DictValue::DictValue(const DictValue &r) + : pv(NULL) +{ + type = r.type; + + if (r.type == Param::INT) + pi = new AutoBuffer(*r.pi); + else if (r.type == Param::STRING) + ps = new AutoBuffer(*r.ps); + else if (r.type == Param::REAL) + pd = new AutoBuffer(*r.pd); +} + +inline bool DictValue::isString() const +{ + return (type == Param::STRING); +} + +inline bool DictValue::isInt() const +{ + return (type == Param::INT); +} + +inline bool DictValue::isReal() const +{ + return (type == Param::REAL || type == Param::INT); +} + +inline int DictValue::size() const +{ + switch (type) + { + case Param::INT: + return (int)pi->size(); + case Param::STRING: + return (int)ps->size(); + case Param::REAL: + return (int)pd->size(); + case Param::BOOLEAN: + case Param::MAT: + case Param::MAT_VECTOR: + case Param::ALGORITHM: + case Param::FLOAT: + case Param::UNSIGNED_INT: + case Param::UINT64: + case Param::UCHAR: + case Param::SCALAR: + break; // unhandled + } + CV_Error_(Error::StsInternal, ("Unhandled type (%d)", static_cast(type))); +} + +inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv) +{ + int i; + + if (dictv.isInt()) + { + for (i = 0; i < dictv.size() - 1; i++) + stream << dictv.get(i) << ", "; + stream << dictv.get(i); + } + else if (dictv.isReal()) + { + for (i = 0; i < dictv.size() - 1; i++) + stream << dictv.get(i) << ", "; + stream << dictv.get(i); + } + else if (dictv.isString()) + { + for (i = 0; i < dictv.size() - 1; i++) + stream << "\"" << dictv.get(i) << "\", "; + stream << dictv.get(i); + } + + return stream; +} + +///////////////////////////////////////////////////////////////// + +inline bool Dict::has(const String &key) const +{ + return dict.count(key) != 0; +} + +inline DictValue *Dict::ptr(const String &key) +{ + _Dict::iterator i = dict.find(key); + return (i == dict.end()) ? NULL : &i->second; +} + +inline const DictValue *Dict::ptr(const String &key) const +{ + _Dict::const_iterator i = dict.find(key); + return (i == dict.end()) ? NULL : &i->second; +} + +inline const DictValue &Dict::get(const String &key) const +{ + _Dict::const_iterator i = dict.find(key); + if (i == dict.end()) + CV_Error(Error::StsObjectNotFound, "Required argument \"" + key + "\" not found into dictionary"); + return i->second; +} + +template +inline T Dict::get(const String &key) const +{ + return this->get(key).get(); +} + +template +inline T Dict::get(const String &key, const T &defaultValue) const +{ + _Dict::const_iterator i = dict.find(key); + + if (i != dict.end()) + return i->second.get(); + else + return defaultValue; +} + +template +inline const T &Dict::set(const String &key, const T &value) +{ + _Dict::iterator i = dict.find(key); + + if (i != dict.end()) + i->second = DictValue(value); + else + dict.insert(std::make_pair(key, DictValue(value))); + + return value; +} + +inline void Dict::erase(const String &key) +{ + dict.erase(key); +} + +inline std::ostream &operator<<(std::ostream &stream, const Dict &dict) +{ + Dict::_Dict::const_iterator it; + for (it = dict.dict.begin(); it != dict.dict.end(); it++) + stream << it->first << " : " << it->second << "\n"; + + return stream; +} + +inline std::map::const_iterator Dict::begin() const +{ + return dict.begin(); +} + +inline std::map::const_iterator Dict::end() const +{ + return dict.end(); +} + +CV__DNN_INLINE_NS_END +} +} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/layer.details.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/layer.details.hpp new file mode 100644 index 0000000..1133da5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/layer.details.hpp @@ -0,0 +1,78 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +#ifndef OPENCV_DNN_LAYER_DETAILS_HPP +#define OPENCV_DNN_LAYER_DETAILS_HPP + +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +/** @brief Registers layer constructor in runtime. +* @param type string, containing type name of the layer. +* @param constructorFunc pointer to the function of type LayerRegister::Constructor, which creates the layer. +* @details This macros must be placed inside the function code. +*/ +#define CV_DNN_REGISTER_LAYER_FUNC(type, constructorFunc) \ + cv::dnn::LayerFactory::registerLayer(#type, constructorFunc); + +/** @brief Registers layer class in runtime. + * @param type string, containing type name of the layer. + * @param class C++ class, derived from Layer. + * @details This macros must be placed inside the function code. + */ +#define CV_DNN_REGISTER_LAYER_CLASS(type, class) \ + cv::dnn::LayerFactory::registerLayer(#type, cv::dnn::details::_layerDynamicRegisterer); + +/** @brief Registers layer constructor on module load time. +* @param type string, containing type name of the layer. +* @param constructorFunc pointer to the function of type LayerRegister::Constructor, which creates the layer. +* @details This macros must be placed outside the function code. +*/ +#define CV_DNN_REGISTER_LAYER_FUNC_STATIC(type, constructorFunc) \ +static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, constructorFunc); + +/** @brief Registers layer class on module load time. + * @param type string, containing type name of the layer. + * @param class C++ class, derived from Layer. + * @details This macros must be placed outside the function code. + */ +#define CV_DNN_REGISTER_LAYER_CLASS_STATIC(type, class) \ +Ptr __LayerStaticRegisterer_func_##type(LayerParams ¶ms) \ + { return Ptr(new class(params)); } \ +static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, __LayerStaticRegisterer_func_##type); + +namespace details { + +template +Ptr _layerDynamicRegisterer(LayerParams ¶ms) +{ + return Ptr(LayerClass::create(params)); +} + +//allows automatically register created layer on module load time +class _LayerStaticRegisterer +{ + String type; +public: + + _LayerStaticRegisterer(const String &layerType, LayerFactory::Constructor layerConstructor) + { + this->type = layerType; + LayerFactory::registerLayer(layerType, layerConstructor); + } + + ~_LayerStaticRegisterer() + { + LayerFactory::unregisterLayer(type); + } +}; + +} // namespace +CV__DNN_INLINE_NS_END +}} // namespace + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/layer.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/layer.hpp new file mode 100644 index 0000000..8500599 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/layer.hpp @@ -0,0 +1,85 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_LAYER_HPP +#define OPENCV_DNN_LAYER_HPP +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ +//! +//! @defgroup dnnLayerFactory Utilities for New Layers Registration +//! @{ + +/** @brief %Layer factory allows to create instances of registered layers. */ +class CV_EXPORTS LayerFactory +{ +public: + + //! Each Layer class must provide this function to the factory + typedef Ptr(*Constructor)(LayerParams ¶ms); + + //! Registers the layer class with typename @p type and specified @p constructor. Thread-safe. + static void registerLayer(const String &type, Constructor constructor); + + //! Unregisters registered layer with specified type name. Thread-safe. + static void unregisterLayer(const String &type); + + /** @brief Creates instance of registered layer. + * @param type type name of creating layer. + * @param params parameters which will be used for layer initialization. + * @note Thread-safe. + */ + static Ptr createLayerInstance(const String &type, LayerParams& params); + +private: + LayerFactory(); +}; + +//! @} +//! @} +CV__DNN_INLINE_NS_END +} +} +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/shape_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/shape_utils.hpp new file mode 100644 index 0000000..4c610f6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/shape_utils.hpp @@ -0,0 +1,259 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_SHAPE_UTILS_HPP +#define OPENCV_DNN_DNN_SHAPE_UTILS_HPP + +#include +#include // CV_MAX_DIM +#include +#include +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +//Slicing + +struct _Range : public cv::Range +{ + _Range(const Range &r) : cv::Range(r) {} + _Range(int start_, int size_ = 1) : cv::Range(start_, start_ + size_) {} +}; + +static inline Mat slice(const Mat &m, const _Range &r0) +{ + Range ranges[CV_MAX_DIM]; + for (int i = 1; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + return m(&ranges[0]); +} + +static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1) +{ + CV_Assert(m.dims >= 2); + Range ranges[CV_MAX_DIM]; + for (int i = 2; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + ranges[1] = r1; + return m(&ranges[0]); +} + +static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2) +{ + CV_Assert(m.dims >= 3); + Range ranges[CV_MAX_DIM]; + for (int i = 3; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + ranges[1] = r1; + ranges[2] = r2; + return m(&ranges[0]); +} + +static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, const _Range &r3) +{ + CV_Assert(m.dims >= 4); + Range ranges[CV_MAX_DIM]; + for (int i = 4; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + ranges[1] = r1; + ranges[2] = r2; + ranges[3] = r3; + return m(&ranges[0]); +} + +static inline Mat getPlane(const Mat &m, int n, int cn) +{ + CV_Assert(m.dims > 2); + int sz[CV_MAX_DIM]; + for(int i = 2; i < m.dims; i++) + { + sz[i-2] = m.size.p[i]; + } + return Mat(m.dims - 2, sz, m.type(), (void*)m.ptr(n, cn)); +} + +static inline MatShape shape(const int* dims, const int n) +{ + MatShape shape; + shape.assign(dims, dims + n); + return shape; +} + +static inline MatShape shape(const Mat& mat) +{ + return shape(mat.size.p, mat.dims); +} + +static inline MatShape shape(const MatSize& sz) +{ + return shape(sz.p, sz.dims()); +} + +static inline MatShape shape(const UMat& mat) +{ + return shape(mat.size.p, mat.dims); +} + +#if 0 // issues with MatExpr wrapped into InputArray +static inline +MatShape shape(InputArray input) +{ + int sz[CV_MAX_DIM]; + int ndims = input.sizend(sz); + return shape(sz, ndims); +} +#endif + +namespace {inline bool is_neg(int i) { return i < 0; }} + +static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1) +{ + int dims[] = {a0, a1, a2, a3}; + MatShape s = shape(dims, 4); + s.erase(std::remove_if(s.begin(), s.end(), is_neg), s.end()); + return s; +} + +static inline int total(const MatShape& shape, int start = -1, int end = -1) +{ + if (start == -1) start = 0; + if (end == -1) end = (int)shape.size(); + + if (shape.empty()) + return 0; + + int elems = 1; + CV_Assert(start <= (int)shape.size() && end <= (int)shape.size() && + start <= end); + for(int i = start; i < end; i++) + { + elems *= shape[i]; + } + return elems; +} + +static inline MatShape concat(const MatShape& a, const MatShape& b) +{ + MatShape c = a; + c.insert(c.end(), b.begin(), b.end()); + + return c; +} + +static inline std::string toString(const MatShape& shape, const String& name = "") +{ + std::ostringstream ss; + if (!name.empty()) + ss << name << ' '; + ss << '['; + for(size_t i = 0, n = shape.size(); i < n; ++i) + ss << ' ' << shape[i]; + ss << " ]"; + return ss.str(); +} +static inline void print(const MatShape& shape, const String& name = "") +{ + std::cout << toString(shape, name) << std::endl; +} +static inline std::ostream& operator<<(std::ostream &out, const MatShape& shape) +{ + out << toString(shape); + return out; +} + +/// @brief Converts axis from `[-dims; dims)` (similar to Python's slice notation) to `[0; dims)` range. +static inline +int normalize_axis(int axis, int dims) +{ + CV_Check(axis, axis >= -dims && axis < dims, ""); + axis = (axis < 0) ? (dims + axis) : axis; + CV_DbgCheck(axis, axis >= 0 && axis < dims, ""); + return axis; +} + +static inline +int normalize_axis(int axis, const MatShape& shape) +{ + return normalize_axis(axis, (int)shape.size()); +} + +static inline +Range normalize_axis_range(const Range& r, int axisSize) +{ + if (r == Range::all()) + return Range(0, axisSize); + CV_CheckGE(r.start, 0, ""); + Range clamped(r.start, + r.end > 0 ? std::min(r.end, axisSize) : axisSize + r.end + 1); + CV_DbgCheckGE(clamped.start, 0, ""); + CV_CheckLT(clamped.start, clamped.end, ""); + CV_CheckLE(clamped.end, axisSize, ""); + return clamped; +} + +static inline +bool isAllOnes(const MatShape &inputShape, int startPos, int endPos) +{ + CV_Assert(!inputShape.empty()); + + CV_CheckGE((int) inputShape.size(), startPos, ""); + CV_CheckGE(startPos, 0, ""); + CV_CheckLE(startPos, endPos, ""); + CV_CheckLE((size_t)endPos, inputShape.size(), ""); + + for (size_t i = startPos; i < endPos; i++) + { + if (inputShape[i] != 1) + return false; + } + return true; +} + +CV__DNN_INLINE_NS_END +} +} +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/utils/debug_utils.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/utils/debug_utils.hpp new file mode 100644 index 0000000..71dd3ab --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/utils/debug_utils.hpp @@ -0,0 +1,24 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_DNN_UTILS_DEBUG_UTILS_HPP +#define OPENCV_DNN_UTILS_DEBUG_UTILS_HPP + +#include "../dnn.hpp" + +namespace cv { namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +/** + * @brief Skip model import after diagnostic run in readNet() functions. + * @param[in] skip Indicates whether to skip the import. + * + * This is an internal OpenCV function not intended for users. + */ +CV_EXPORTS void skipModelImport(bool skip); + +CV__DNN_INLINE_NS_END +}} // namespace + +#endif // OPENCV_DNN_UTILS_DEBUG_UTILS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/utils/inference_engine.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/utils/inference_engine.hpp new file mode 100644 index 0000000..333b1bf --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/utils/inference_engine.hpp @@ -0,0 +1,76 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_DNN_UTILS_INF_ENGINE_HPP +#define OPENCV_DNN_UTILS_INF_ENGINE_HPP + +#include "../dnn.hpp" + +namespace cv { namespace dnn { +CV__DNN_INLINE_NS_BEGIN + + +/* Values for 'OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE' parameter */ +#define CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API "NN_BUILDER" +#define CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH "NGRAPH" + +/** @brief Returns Inference Engine internal backend API. + * + * See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros. + * + * Default value is controlled through `OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE` runtime parameter (environment variable). + */ +CV_EXPORTS_W cv::String getInferenceEngineBackendType(); + +/** @brief Specify Inference Engine internal backend API. + * + * See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros. + * + * @returns previous value of internal backend API + */ +CV_EXPORTS_W cv::String setInferenceEngineBackendType(const cv::String& newBackendType); + + +/** @brief Release a Myriad device (binded by OpenCV). + * + * Single Myriad device cannot be shared across multiple processes which uses + * Inference Engine's Myriad plugin. + */ +CV_EXPORTS_W void resetMyriadDevice(); + + +/* Values for 'OPENCV_DNN_IE_VPU_TYPE' parameter */ +#define CV_DNN_INFERENCE_ENGINE_VPU_TYPE_UNSPECIFIED "" +/// Intel(R) Movidius(TM) Neural Compute Stick, NCS (USB 03e7:2150), Myriad2 (https://software.intel.com/en-us/movidius-ncs) +#define CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_2 "Myriad2" +/// Intel(R) Neural Compute Stick 2, NCS2 (USB 03e7:2485), MyriadX (https://software.intel.com/ru-ru/neural-compute-stick) +#define CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X "MyriadX" +#define CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE "ARM_COMPUTE" +#define CV_DNN_INFERENCE_ENGINE_CPU_TYPE_X86 "X86" + + +/** @brief Returns Inference Engine VPU type. + * + * See values of `CV_DNN_INFERENCE_ENGINE_VPU_TYPE_*` macros. + */ +CV_EXPORTS_W cv::String getInferenceEngineVPUType(); + +/** @brief Returns Inference Engine CPU type. + * + * Specify OpenVINO plugin: CPU or ARM. + */ +CV_EXPORTS_W cv::String getInferenceEngineCPUType(); + +/** @brief Release a HDDL plugin. + */ +CV_EXPORTS_W void releaseHDDLPlugin(); + + +CV__DNN_INLINE_NS_END +}} // namespace + +#endif // OPENCV_DNN_UTILS_INF_ENGINE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/dnn/version.hpp b/Cigarette/OpenCV455Simple/include/opencv2/dnn/version.hpp new file mode 100644 index 0000000..a0a1754 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/dnn/version.hpp @@ -0,0 +1,21 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_DNN_VERSION_HPP +#define OPENCV_DNN_VERSION_HPP + +/// Use with major OpenCV version only. +#define OPENCV_DNN_API_VERSION 20211220 + +#if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_INLINE_NS +#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION) +#define CV__DNN_INLINE_NS_BEGIN namespace CV__DNN_INLINE_NS { +#define CV__DNN_INLINE_NS_END } +namespace cv { namespace dnn { namespace CV__DNN_INLINE_NS { } using namespace CV__DNN_INLINE_NS; }} +#else +#define CV__DNN_INLINE_NS_BEGIN +#define CV__DNN_INLINE_NS_END +#endif + +#endif // OPENCV_DNN_VERSION_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/features2d.hpp b/Cigarette/OpenCV455Simple/include/opencv2/features2d.hpp new file mode 100644 index 0000000..26c2b95 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/features2d.hpp @@ -0,0 +1,1535 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_FEATURES_2D_HPP +#define OPENCV_FEATURES_2D_HPP + +#include "opencv2/opencv_modules.hpp" +#include "opencv2/core.hpp" + +#ifdef HAVE_OPENCV_FLANN +#include "opencv2/flann/miniflann.hpp" +#endif + +/** + @defgroup features2d 2D Features Framework + @{ + @defgroup features2d_main Feature Detection and Description + @defgroup features2d_match Descriptor Matchers + +Matchers of keypoint descriptors in OpenCV have wrappers with a common interface that enables you to +easily switch between different algorithms solving the same problem. This section is devoted to +matching descriptors that are represented as vectors in a multidimensional space. All objects that +implement vector descriptor matchers inherit the DescriptorMatcher interface. + + @defgroup features2d_draw Drawing Function of Keypoints and Matches + @defgroup features2d_category Object Categorization + +This section describes approaches based on local 2D features and used to categorize objects. + + @defgroup feature2d_hal Hardware Acceleration Layer + @{ + @defgroup features2d_hal_interface Interface + @} + @} + */ + +namespace cv +{ + +//! @addtogroup features2d_main +//! @{ + +// //! writes vector of keypoints to the file storage +// CV_EXPORTS void write(FileStorage& fs, const String& name, const std::vector& keypoints); +// //! reads vector of keypoints from the specified file storage node +// CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector& keypoints); + +/** @brief A class filters a vector of keypoints. + + Because now it is difficult to provide a convenient interface for all usage scenarios of the + keypoints filter class, it has only several needed by now static methods. + */ +class CV_EXPORTS KeyPointsFilter +{ +public: + KeyPointsFilter(){} + + /* + * Remove keypoints within borderPixels of an image edge. + */ + static void runByImageBorder( std::vector& keypoints, Size imageSize, int borderSize ); + /* + * Remove keypoints of sizes out of range. + */ + static void runByKeypointSize( std::vector& keypoints, float minSize, + float maxSize=FLT_MAX ); + /* + * Remove keypoints from some image by mask for pixels of this image. + */ + static void runByPixelsMask( std::vector& keypoints, const Mat& mask ); + /* + * Remove duplicated keypoints. + */ + static void removeDuplicated( std::vector& keypoints ); + /* + * Remove duplicated keypoints and sort the remaining keypoints + */ + static void removeDuplicatedSorted( std::vector& keypoints ); + + /* + * Retain the specified number of the best keypoints (according to the response) + */ + static void retainBest( std::vector& keypoints, int npoints ); +}; + + +/************************************ Base Classes ************************************/ + +/** @brief Abstract base class for 2D image feature detectors and descriptor extractors +*/ +#ifdef __EMSCRIPTEN__ +class CV_EXPORTS_W Feature2D : public Algorithm +#else +class CV_EXPORTS_W Feature2D : public virtual Algorithm +#endif +{ +public: + virtual ~Feature2D(); + + /** @brief Detects keypoints in an image (first variant) or image set (second variant). + + @param image Image. + @param keypoints The detected keypoints. In the second variant of the method keypoints[i] is a set + of keypoints detected in images[i] . + @param mask Mask specifying where to look for keypoints (optional). It must be a 8-bit integer + matrix with non-zero values in the region of interest. + */ + CV_WRAP virtual void detect( InputArray image, + CV_OUT std::vector& keypoints, + InputArray mask=noArray() ); + + /** @overload + @param images Image set. + @param keypoints The detected keypoints. In the second variant of the method keypoints[i] is a set + of keypoints detected in images[i] . + @param masks Masks for each input image specifying where to look for keypoints (optional). + masks[i] is a mask for images[i]. + */ + CV_WRAP virtual void detect( InputArrayOfArrays images, + CV_OUT std::vector >& keypoints, + InputArrayOfArrays masks=noArray() ); + + /** @brief Computes the descriptors for a set of keypoints detected in an image (first variant) or image set + (second variant). + + @param image Image. + @param keypoints Input collection of keypoints. Keypoints for which a descriptor cannot be + computed are removed. Sometimes new keypoints can be added, for example: SIFT duplicates keypoint + with several dominant orientations (for each orientation). + @param descriptors Computed descriptors. In the second variant of the method descriptors[i] are + descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the + descriptor for keypoint j-th keypoint. + */ + CV_WRAP virtual void compute( InputArray image, + CV_OUT CV_IN_OUT std::vector& keypoints, + OutputArray descriptors ); + + /** @overload + + @param images Image set. + @param keypoints Input collection of keypoints. Keypoints for which a descriptor cannot be + computed are removed. Sometimes new keypoints can be added, for example: SIFT duplicates keypoint + with several dominant orientations (for each orientation). + @param descriptors Computed descriptors. In the second variant of the method descriptors[i] are + descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the + descriptor for keypoint j-th keypoint. + */ + CV_WRAP virtual void compute( InputArrayOfArrays images, + CV_OUT CV_IN_OUT std::vector >& keypoints, + OutputArrayOfArrays descriptors ); + + /** Detects keypoints and computes the descriptors */ + CV_WRAP virtual void detectAndCompute( InputArray image, InputArray mask, + CV_OUT std::vector& keypoints, + OutputArray descriptors, + bool useProvidedKeypoints=false ); + + CV_WRAP virtual int descriptorSize() const; + CV_WRAP virtual int descriptorType() const; + CV_WRAP virtual int defaultNorm() const; + + CV_WRAP void write( const String& fileName ) const; + + CV_WRAP void read( const String& fileName ); + + virtual void write( FileStorage&) const CV_OVERRIDE; + + // see corresponding cv::Algorithm method + CV_WRAP virtual void read( const FileNode&) CV_OVERRIDE; + + //! Return true if detector object is empty + CV_WRAP virtual bool empty() const CV_OVERRIDE; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; + + // see corresponding cv::Algorithm method + CV_WRAP inline void write(const Ptr& fs, const String& name = String()) const { Algorithm::write(fs, name); } +}; + +/** Feature detectors in OpenCV have wrappers with a common interface that enables you to easily switch +between different algorithms solving the same problem. All objects that implement keypoint detectors +inherit the FeatureDetector interface. */ +typedef Feature2D FeatureDetector; + +/** Extractors of keypoint descriptors in OpenCV have wrappers with a common interface that enables you +to easily switch between different algorithms solving the same problem. This section is devoted to +computing descriptors represented as vectors in a multidimensional space. All objects that implement +the vector descriptor extractors inherit the DescriptorExtractor interface. + */ +typedef Feature2D DescriptorExtractor; + + +/** @brief Class for implementing the wrapper which makes detectors and extractors to be affine invariant, +described as ASIFT in @cite YM11 . +*/ +class CV_EXPORTS_W AffineFeature : public Feature2D +{ +public: + /** + @param backend The detector/extractor you want to use as backend. + @param maxTilt The highest power index of tilt factor. 5 is used in the paper as tilt sampling range n. + @param minTilt The lowest power index of tilt factor. 0 is used in the paper. + @param tiltStep Tilt sampling step \f$\delta_t\f$ in Algorithm 1 in the paper. + @param rotateStepBase Rotation sampling step factor b in Algorithm 1 in the paper. + */ + CV_WRAP static Ptr create(const Ptr& backend, + int maxTilt = 5, int minTilt = 0, float tiltStep = 1.4142135623730951f, float rotateStepBase = 72); + + CV_WRAP virtual void setViewParams(const std::vector& tilts, const std::vector& rolls) = 0; + CV_WRAP virtual void getViewParams(std::vector& tilts, std::vector& rolls) const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +typedef AffineFeature AffineFeatureDetector; +typedef AffineFeature AffineDescriptorExtractor; + + +/** @brief Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform +(SIFT) algorithm by D. Lowe @cite Lowe04 . +*/ +class CV_EXPORTS_W SIFT : public Feature2D +{ +public: + /** + @param nfeatures The number of best features to retain. The features are ranked by their scores + (measured in SIFT algorithm as the local contrast) + + @param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The + number of octaves is computed automatically from the image resolution. + + @param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform + (low-contrast) regions. The larger the threshold, the less features are produced by the detector. + + @note The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When + nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set + this argument to 0.09. + + @param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning + is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are + filtered out (more features are retained). + + @param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image + is captured with a weak camera with soft lenses, you might want to reduce the number. + */ + CV_WRAP static Ptr create(int nfeatures = 0, int nOctaveLayers = 3, + double contrastThreshold = 0.04, double edgeThreshold = 10, + double sigma = 1.6); + + /** @brief Create SIFT with specified descriptorType. + @param nfeatures The number of best features to retain. The features are ranked by their scores + (measured in SIFT algorithm as the local contrast) + + @param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The + number of octaves is computed automatically from the image resolution. + + @param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform + (low-contrast) regions. The larger the threshold, the less features are produced by the detector. + + @note The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When + nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set + this argument to 0.09. + + @param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning + is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are + filtered out (more features are retained). + + @param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image + is captured with a weak camera with soft lenses, you might want to reduce the number. + + @param descriptorType The type of descriptors. Only CV_32F and CV_8U are supported. + */ + CV_WRAP static Ptr create(int nfeatures, int nOctaveLayers, + double contrastThreshold, double edgeThreshold, + double sigma, int descriptorType); + + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +typedef SIFT SiftFeatureDetector; +typedef SIFT SiftDescriptorExtractor; + + +/** @brief Class implementing the BRISK keypoint detector and descriptor extractor, described in @cite LCS11 . + */ +class CV_EXPORTS_W BRISK : public Feature2D +{ +public: + /** @brief The BRISK constructor + + @param thresh AGAST detection threshold score. + @param octaves detection octaves. Use 0 to do single scale. + @param patternScale apply this scale to the pattern used for sampling the neighbourhood of a + keypoint. + */ + CV_WRAP static Ptr create(int thresh=30, int octaves=3, float patternScale=1.0f); + + /** @brief The BRISK constructor for a custom pattern + + @param radiusList defines the radii (in pixels) where the samples around a keypoint are taken (for + keypoint scale 1). + @param numberList defines the number of sampling points on the sampling circle. Must be the same + size as radiusList.. + @param dMax threshold for the short pairings used for descriptor formation (in pixels for keypoint + scale 1). + @param dMin threshold for the long pairings used for orientation determination (in pixels for + keypoint scale 1). + @param indexChange index remapping of the bits. */ + CV_WRAP static Ptr create(const std::vector &radiusList, const std::vector &numberList, + float dMax=5.85f, float dMin=8.2f, const std::vector& indexChange=std::vector()); + + /** @brief The BRISK constructor for a custom pattern, detection threshold and octaves + + @param thresh AGAST detection threshold score. + @param octaves detection octaves. Use 0 to do single scale. + @param radiusList defines the radii (in pixels) where the samples around a keypoint are taken (for + keypoint scale 1). + @param numberList defines the number of sampling points on the sampling circle. Must be the same + size as radiusList.. + @param dMax threshold for the short pairings used for descriptor formation (in pixels for keypoint + scale 1). + @param dMin threshold for the long pairings used for orientation determination (in pixels for + keypoint scale 1). + @param indexChange index remapping of the bits. */ + CV_WRAP static Ptr create(int thresh, int octaves, const std::vector &radiusList, + const std::vector &numberList, float dMax=5.85f, float dMin=8.2f, + const std::vector& indexChange=std::vector()); + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; + + /** @brief Set detection threshold. + @param threshold AGAST detection threshold score. + */ + CV_WRAP virtual void setThreshold(int threshold) { CV_UNUSED(threshold); return; } + CV_WRAP virtual int getThreshold() const { return -1; } + + /** @brief Set detection octaves. + @param octaves detection octaves. Use 0 to do single scale. + */ + CV_WRAP virtual void setOctaves(int octaves) { CV_UNUSED(octaves); return; } + CV_WRAP virtual int getOctaves() const { return -1; } +}; + +/** @brief Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor + +described in @cite RRKB11 . The algorithm uses FAST in pyramids to detect stable keypoints, selects +the strongest features using FAST or Harris response, finds their orientation using first-order +moments and computes the descriptors using BRIEF (where the coordinates of random point pairs (or +k-tuples) are rotated according to the measured orientation). + */ +class CV_EXPORTS_W ORB : public Feature2D +{ +public: + enum ScoreType { HARRIS_SCORE=0, FAST_SCORE=1 }; + static const int kBytes = 32; + + /** @brief The ORB constructor + + @param nfeatures The maximum number of features to retain. + @param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical + pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor + will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor + will mean that to cover certain scale range you will need more pyramid levels and so the speed + will suffer. + @param nlevels The number of pyramid levels. The smallest level will have linear size equal to + input_image_linear_size/pow(scaleFactor, nlevels - firstLevel). + @param edgeThreshold This is size of the border where the features are not detected. It should + roughly match the patchSize parameter. + @param firstLevel The level of pyramid to put source image to. Previous layers are filled + with upscaled source image. + @param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The + default value 2 means the BRIEF where we take a random point pair and compare their brightnesses, + so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3 + random points (of course, those point coordinates are random, but they are generated from the + pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel + rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such + output will occupy 2 bits, and therefore it will need a special variant of Hamming distance, + denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each + bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3). + @param scoreType The default HARRIS_SCORE means that Harris algorithm is used to rank features + (the score is written to KeyPoint::score and is used to retain best nfeatures features); + FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints, + but it is a little faster to compute. + @param patchSize size of the patch used by the oriented BRIEF descriptor. Of course, on smaller + pyramid layers the perceived image area covered by a feature will be larger. + @param fastThreshold the fast threshold + */ + CV_WRAP static Ptr create(int nfeatures=500, float scaleFactor=1.2f, int nlevels=8, int edgeThreshold=31, + int firstLevel=0, int WTA_K=2, ORB::ScoreType scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold=20); + + CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0; + CV_WRAP virtual int getMaxFeatures() const = 0; + + CV_WRAP virtual void setScaleFactor(double scaleFactor) = 0; + CV_WRAP virtual double getScaleFactor() const = 0; + + CV_WRAP virtual void setNLevels(int nlevels) = 0; + CV_WRAP virtual int getNLevels() const = 0; + + CV_WRAP virtual void setEdgeThreshold(int edgeThreshold) = 0; + CV_WRAP virtual int getEdgeThreshold() const = 0; + + CV_WRAP virtual void setFirstLevel(int firstLevel) = 0; + CV_WRAP virtual int getFirstLevel() const = 0; + + CV_WRAP virtual void setWTA_K(int wta_k) = 0; + CV_WRAP virtual int getWTA_K() const = 0; + + CV_WRAP virtual void setScoreType(ORB::ScoreType scoreType) = 0; + CV_WRAP virtual ORB::ScoreType getScoreType() const = 0; + + CV_WRAP virtual void setPatchSize(int patchSize) = 0; + CV_WRAP virtual int getPatchSize() const = 0; + + CV_WRAP virtual void setFastThreshold(int fastThreshold) = 0; + CV_WRAP virtual int getFastThreshold() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @brief Maximally stable extremal region extractor + +The class encapsulates all the parameters of the %MSER extraction algorithm (see [wiki +article](http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions)). + +- there are two different implementation of %MSER: one for grey image, one for color image + +- the grey image algorithm is taken from: @cite nister2008linear ; the paper claims to be faster +than union-find method; it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop. + +- the color image algorithm is taken from: @cite forssen2007maximally ; it should be much slower +than grey image method ( 3~4 times ) + +- (Python) A complete example showing the use of the %MSER detector can be found at samples/python/mser.py +*/ +class CV_EXPORTS_W MSER : public Feature2D +{ +public: + /** @brief Full constructor for %MSER detector + + @param delta it compares \f$(size_{i}-size_{i-delta})/size_{i-delta}\f$ + @param min_area prune the area which smaller than minArea + @param max_area prune the area which bigger than maxArea + @param max_variation prune the area have similar size to its children + @param min_diversity for color image, trace back to cut off mser with diversity less than min_diversity + @param max_evolution for color image, the evolution steps + @param area_threshold for color image, the area threshold to cause re-initialize + @param min_margin for color image, ignore too small margin + @param edge_blur_size for color image, the aperture size for edge blur + */ + CV_WRAP static Ptr create( int delta=5, int min_area=60, int max_area=14400, + double max_variation=0.25, double min_diversity=.2, + int max_evolution=200, double area_threshold=1.01, + double min_margin=0.003, int edge_blur_size=5 ); + + /** @brief Detect %MSER regions + + @param image input image (8UC1, 8UC3 or 8UC4, must be greater or equal than 3x3) + @param msers resulting list of point sets + @param bboxes resulting bounding boxes + */ + CV_WRAP virtual void detectRegions( InputArray image, + CV_OUT std::vector >& msers, + CV_OUT std::vector& bboxes ) = 0; + + CV_WRAP virtual void setDelta(int delta) = 0; + CV_WRAP virtual int getDelta() const = 0; + + CV_WRAP virtual void setMinArea(int minArea) = 0; + CV_WRAP virtual int getMinArea() const = 0; + + CV_WRAP virtual void setMaxArea(int maxArea) = 0; + CV_WRAP virtual int getMaxArea() const = 0; + + CV_WRAP virtual void setPass2Only(bool f) = 0; + CV_WRAP virtual bool getPass2Only() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +//! @} features2d_main + +//! @addtogroup features2d_main +//! @{ + +/** @brief Wrapping class for feature detection using the FAST method. : + */ +class CV_EXPORTS_W FastFeatureDetector : public Feature2D +{ +public: + enum DetectorType + { + TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2 + }; + enum + { + THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, FAST_N=10002 + }; + + + CV_WRAP static Ptr create( int threshold=10, + bool nonmaxSuppression=true, + FastFeatureDetector::DetectorType type=FastFeatureDetector::TYPE_9_16 ); + + CV_WRAP virtual void setThreshold(int threshold) = 0; + CV_WRAP virtual int getThreshold() const = 0; + + CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; + CV_WRAP virtual bool getNonmaxSuppression() const = 0; + + CV_WRAP virtual void setType(FastFeatureDetector::DetectorType type) = 0; + CV_WRAP virtual FastFeatureDetector::DetectorType getType() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @overload */ +CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + +/** @brief Detects corners using the FAST algorithm + +@param image grayscale image where keypoints (corners) are detected. +@param keypoints keypoints detected on the image. +@param threshold threshold on difference between intensity of the central pixel and pixels of a +circle around this pixel. +@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners +(keypoints). +@param type one of the three neighborhoods as defined in the paper: +FastFeatureDetector::TYPE_9_16, FastFeatureDetector::TYPE_7_12, +FastFeatureDetector::TYPE_5_8 + +Detects corners using the FAST algorithm by @cite Rosten06 . + +@note In Python API, types are given as cv.FAST_FEATURE_DETECTOR_TYPE_5_8, +cv.FAST_FEATURE_DETECTOR_TYPE_7_12 and cv.FAST_FEATURE_DETECTOR_TYPE_9_16. For corner +detection, use cv.FAST.detect() method. + */ +CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression, FastFeatureDetector::DetectorType type ); + +//! @} features2d_main + +//! @addtogroup features2d_main +//! @{ + +/** @brief Wrapping class for feature detection using the AGAST method. : + */ +class CV_EXPORTS_W AgastFeatureDetector : public Feature2D +{ +public: + enum DetectorType + { + AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3, + }; + + enum + { + THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001, + }; + + CV_WRAP static Ptr create( int threshold=10, + bool nonmaxSuppression=true, + AgastFeatureDetector::DetectorType type = AgastFeatureDetector::OAST_9_16); + + CV_WRAP virtual void setThreshold(int threshold) = 0; + CV_WRAP virtual int getThreshold() const = 0; + + CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; + CV_WRAP virtual bool getNonmaxSuppression() const = 0; + + CV_WRAP virtual void setType(AgastFeatureDetector::DetectorType type) = 0; + CV_WRAP virtual AgastFeatureDetector::DetectorType getType() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @overload */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + +/** @brief Detects corners using the AGAST algorithm + +@param image grayscale image where keypoints (corners) are detected. +@param keypoints keypoints detected on the image. +@param threshold threshold on difference between intensity of the central pixel and pixels of a +circle around this pixel. +@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners +(keypoints). +@param type one of the four neighborhoods as defined in the paper: +AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, +AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16 + +For non-Intel platforms, there is a tree optimised variant of AGAST with same numerical results. +The 32-bit binary tree tables were generated automatically from original code using perl script. +The perl script and examples of tree generation are placed in features2d/doc folder. +Detects corners using the AGAST algorithm by @cite mair2010_agast . + + */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type ); + +/** @brief Wrapping class for feature detection using the goodFeaturesToTrack function. : + */ +class CV_EXPORTS_W GFTTDetector : public Feature2D +{ +public: + CV_WRAP static Ptr create( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1, + int blockSize=3, bool useHarrisDetector=false, double k=0.04 ); + CV_WRAP static Ptr create( int maxCorners, double qualityLevel, double minDistance, + int blockSize, int gradiantSize, bool useHarrisDetector=false, double k=0.04 ); + CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0; + CV_WRAP virtual int getMaxFeatures() const = 0; + + CV_WRAP virtual void setQualityLevel(double qlevel) = 0; + CV_WRAP virtual double getQualityLevel() const = 0; + + CV_WRAP virtual void setMinDistance(double minDistance) = 0; + CV_WRAP virtual double getMinDistance() const = 0; + + CV_WRAP virtual void setBlockSize(int blockSize) = 0; + CV_WRAP virtual int getBlockSize() const = 0; + + CV_WRAP virtual void setHarrisDetector(bool val) = 0; + CV_WRAP virtual bool getHarrisDetector() const = 0; + + CV_WRAP virtual void setK(double k) = 0; + CV_WRAP virtual double getK() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @brief Class for extracting blobs from an image. : + +The class implements a simple algorithm for extracting blobs from an image: + +1. Convert the source image to binary images by applying thresholding with several thresholds from + minThreshold (inclusive) to maxThreshold (exclusive) with distance thresholdStep between + neighboring thresholds. +2. Extract connected components from every binary image by findContours and calculate their + centers. +3. Group centers from several binary images by their coordinates. Close centers form one group that + corresponds to one blob, which is controlled by the minDistBetweenBlobs parameter. +4. From the groups, estimate final centers of blobs and their radiuses and return as locations and + sizes of keypoints. + +This class performs several filtrations of returned blobs. You should set filterBy\* to true/false +to turn on/off corresponding filtration. Available filtrations: + +- **By color**. This filter compares the intensity of a binary image at the center of a blob to +blobColor. If they differ, the blob is filtered out. Use blobColor = 0 to extract dark blobs +and blobColor = 255 to extract light blobs. +- **By area**. Extracted blobs have an area between minArea (inclusive) and maxArea (exclusive). +- **By circularity**. Extracted blobs have circularity +(\f$\frac{4*\pi*Area}{perimeter * perimeter}\f$) between minCircularity (inclusive) and +maxCircularity (exclusive). +- **By ratio of the minimum inertia to maximum inertia**. Extracted blobs have this ratio +between minInertiaRatio (inclusive) and maxInertiaRatio (exclusive). +- **By convexity**. Extracted blobs have convexity (area / area of blob convex hull) between +minConvexity (inclusive) and maxConvexity (exclusive). + +Default values of parameters are tuned to extract dark circular blobs. + */ +class CV_EXPORTS_W SimpleBlobDetector : public Feature2D +{ +public: + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW float thresholdStep; + CV_PROP_RW float minThreshold; + CV_PROP_RW float maxThreshold; + CV_PROP_RW size_t minRepeatability; + CV_PROP_RW float minDistBetweenBlobs; + + CV_PROP_RW bool filterByColor; + CV_PROP_RW uchar blobColor; + + CV_PROP_RW bool filterByArea; + CV_PROP_RW float minArea, maxArea; + + CV_PROP_RW bool filterByCircularity; + CV_PROP_RW float minCircularity, maxCircularity; + + CV_PROP_RW bool filterByInertia; + CV_PROP_RW float minInertiaRatio, maxInertiaRatio; + + CV_PROP_RW bool filterByConvexity; + CV_PROP_RW float minConvexity, maxConvexity; + + void read( const FileNode& fn ); + void write( FileStorage& fs ) const; + }; + + CV_WRAP static Ptr + create(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params()); + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +//! @} features2d_main + +//! @addtogroup features2d_main +//! @{ + +/** @brief Class implementing the KAZE keypoint detector and descriptor extractor, described in @cite ABD12 . + +@note AKAZE descriptor can only be used with KAZE or AKAZE keypoints .. [ABD12] KAZE Features. Pablo +F. Alcantarilla, Adrien Bartoli and Andrew J. Davison. In European Conference on Computer Vision +(ECCV), Fiorenze, Italy, October 2012. +*/ +class CV_EXPORTS_W KAZE : public Feature2D +{ +public: + enum DiffusivityType + { + DIFF_PM_G1 = 0, + DIFF_PM_G2 = 1, + DIFF_WEICKERT = 2, + DIFF_CHARBONNIER = 3 + }; + + /** @brief The KAZE constructor + + @param extended Set to enable extraction of extended (128-byte) descriptor. + @param upright Set to enable use of upright descriptors (non rotation-invariant). + @param threshold Detector response threshold to accept point + @param nOctaves Maximum octave evolution of the image + @param nOctaveLayers Default number of sublevels per scale level + @param diffusivity Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + DIFF_CHARBONNIER + */ + CV_WRAP static Ptr create(bool extended=false, bool upright=false, + float threshold = 0.001f, + int nOctaves = 4, int nOctaveLayers = 4, + KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2); + + CV_WRAP virtual void setExtended(bool extended) = 0; + CV_WRAP virtual bool getExtended() const = 0; + + CV_WRAP virtual void setUpright(bool upright) = 0; + CV_WRAP virtual bool getUpright() const = 0; + + CV_WRAP virtual void setThreshold(double threshold) = 0; + CV_WRAP virtual double getThreshold() const = 0; + + CV_WRAP virtual void setNOctaves(int octaves) = 0; + CV_WRAP virtual int getNOctaves() const = 0; + + CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0; + CV_WRAP virtual int getNOctaveLayers() const = 0; + + CV_WRAP virtual void setDiffusivity(KAZE::DiffusivityType diff) = 0; + CV_WRAP virtual KAZE::DiffusivityType getDiffusivity() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @brief Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13. + +@details AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe. + +@note When you need descriptors use Feature2D::detectAndCompute, which +provides better performance. When using Feature2D::detect followed by +Feature2D::compute scale space pyramid is computed twice. + +@note AKAZE implements T-API. When image is passed as UMat some parts of the algorithm +will use OpenCL. + +@note [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear +Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In +British Machine Vision Conference (BMVC), Bristol, UK, September 2013. + +*/ +class CV_EXPORTS_W AKAZE : public Feature2D +{ +public: + // AKAZE descriptor type + enum DescriptorType + { + DESCRIPTOR_KAZE_UPRIGHT = 2, ///< Upright descriptors, not invariant to rotation + DESCRIPTOR_KAZE = 3, + DESCRIPTOR_MLDB_UPRIGHT = 4, ///< Upright descriptors, not invariant to rotation + DESCRIPTOR_MLDB = 5 + }; + + /** @brief The AKAZE constructor + + @param descriptor_type Type of the extracted descriptor: DESCRIPTOR_KAZE, + DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT. + @param descriptor_size Size of the descriptor in bits. 0 -\> Full size + @param descriptor_channels Number of channels in the descriptor (1, 2, 3) + @param threshold Detector response threshold to accept point + @param nOctaves Maximum octave evolution of the image + @param nOctaveLayers Default number of sublevels per scale level + @param diffusivity Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + DIFF_CHARBONNIER + */ + CV_WRAP static Ptr create(AKAZE::DescriptorType descriptor_type = AKAZE::DESCRIPTOR_MLDB, + int descriptor_size = 0, int descriptor_channels = 3, + float threshold = 0.001f, int nOctaves = 4, + int nOctaveLayers = 4, KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2); + + CV_WRAP virtual void setDescriptorType(AKAZE::DescriptorType dtype) = 0; + CV_WRAP virtual AKAZE::DescriptorType getDescriptorType() const = 0; + + CV_WRAP virtual void setDescriptorSize(int dsize) = 0; + CV_WRAP virtual int getDescriptorSize() const = 0; + + CV_WRAP virtual void setDescriptorChannels(int dch) = 0; + CV_WRAP virtual int getDescriptorChannels() const = 0; + + CV_WRAP virtual void setThreshold(double threshold) = 0; + CV_WRAP virtual double getThreshold() const = 0; + + CV_WRAP virtual void setNOctaves(int octaves) = 0; + CV_WRAP virtual int getNOctaves() const = 0; + + CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0; + CV_WRAP virtual int getNOctaveLayers() const = 0; + + CV_WRAP virtual void setDiffusivity(KAZE::DiffusivityType diff) = 0; + CV_WRAP virtual KAZE::DiffusivityType getDiffusivity() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +//! @} features2d_main + +/****************************************************************************************\ +* Distance * +\****************************************************************************************/ + +template +struct CV_EXPORTS Accumulator +{ + typedef T Type; +}; + +template<> struct Accumulator { typedef float Type; }; +template<> struct Accumulator { typedef float Type; }; +template<> struct Accumulator { typedef float Type; }; +template<> struct Accumulator { typedef float Type; }; + +/* + * Squared Euclidean distance functor + */ +template +struct CV_EXPORTS SL2 +{ + static const NormTypes normType = NORM_L2SQR; + typedef T ValueType; + typedef typename Accumulator::Type ResultType; + + ResultType operator()( const T* a, const T* b, int size ) const + { + return normL2Sqr(a, b, size); + } +}; + +/* + * Euclidean distance functor + */ +template +struct L2 +{ + static const NormTypes normType = NORM_L2; + typedef T ValueType; + typedef typename Accumulator::Type ResultType; + + ResultType operator()( const T* a, const T* b, int size ) const + { + return (ResultType)std::sqrt((double)normL2Sqr(a, b, size)); + } +}; + +/* + * Manhattan distance (city block distance) functor + */ +template +struct L1 +{ + static const NormTypes normType = NORM_L1; + typedef T ValueType; + typedef typename Accumulator::Type ResultType; + + ResultType operator()( const T* a, const T* b, int size ) const + { + return normL1(a, b, size); + } +}; + +/****************************************************************************************\ +* DescriptorMatcher * +\****************************************************************************************/ + +//! @addtogroup features2d_match +//! @{ + +/** @brief Abstract base class for matching keypoint descriptors. + +It has two groups of match methods: for matching descriptors of an image with another image or with +an image set. + */ +class CV_EXPORTS_W DescriptorMatcher : public Algorithm +{ +public: + enum MatcherType + { + FLANNBASED = 1, + BRUTEFORCE = 2, + BRUTEFORCE_L1 = 3, + BRUTEFORCE_HAMMING = 4, + BRUTEFORCE_HAMMINGLUT = 5, + BRUTEFORCE_SL2 = 6 + }; + + virtual ~DescriptorMatcher(); + + /** @brief Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor + collection. + + If the collection is not empty, the new descriptors are added to existing train descriptors. + + @param descriptors Descriptors to add. Each descriptors[i] is a set of descriptors from the same + train image. + */ + CV_WRAP virtual void add( InputArrayOfArrays descriptors ); + + /** @brief Returns a constant link to the train descriptor collection trainDescCollection . + */ + CV_WRAP const std::vector& getTrainDescriptors() const; + + /** @brief Clears the train descriptor collections. + */ + CV_WRAP virtual void clear() CV_OVERRIDE; + + /** @brief Returns true if there are no train descriptors in the both collections. + */ + CV_WRAP virtual bool empty() const CV_OVERRIDE; + + /** @brief Returns true if the descriptor matcher supports masking permissible matches. + */ + CV_WRAP virtual bool isMaskSupported() const = 0; + + /** @brief Trains a descriptor matcher + + Trains a descriptor matcher (for example, the flann index). In all methods to match, the method + train() is run every time before matching. Some descriptor matchers (for example, BruteForceMatcher) + have an empty implementation of this method. Other matchers really train their inner structures (for + example, FlannBasedMatcher trains flann::Index ). + */ + CV_WRAP virtual void train(); + + /** @brief Finds the best match for each descriptor from a query set. + + @param queryDescriptors Query set of descriptors. + @param trainDescriptors Train set of descriptors. This set is not added to the train descriptors + collection stored in the class object. + @param matches Matches. If a query descriptor is masked out in mask , no match is added for this + descriptor. So, matches size may be smaller than the query descriptors count. + @param mask Mask specifying permissible matches between an input query and train matrices of + descriptors. + + In the first variant of this method, the train descriptors are passed as an input argument. In the + second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is + used. Optional mask (or masks) can be passed to specify which query and training descriptors can be + matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if + mask.at\(i,j) is non-zero. + */ + CV_WRAP void match( InputArray queryDescriptors, InputArray trainDescriptors, + CV_OUT std::vector& matches, InputArray mask=noArray() ) const; + + /** @brief Finds the k best matches for each descriptor from a query set. + + @param queryDescriptors Query set of descriptors. + @param trainDescriptors Train set of descriptors. This set is not added to the train descriptors + collection stored in the class object. + @param mask Mask specifying permissible matches between an input query and train matrices of + descriptors. + @param matches Matches. Each matches[i] is k or less matches for the same query descriptor. + @param k Count of best matches found per each query descriptor or less if a query descriptor has + less than k possible matches in total. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + + These extended variants of DescriptorMatcher::match methods find several best matches for each query + descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match + for the details about query and train descriptors. + */ + CV_WRAP void knnMatch( InputArray queryDescriptors, InputArray trainDescriptors, + CV_OUT std::vector >& matches, int k, + InputArray mask=noArray(), bool compactResult=false ) const; + + /** @brief For each query descriptor, finds the training descriptors not farther than the specified distance. + + @param queryDescriptors Query set of descriptors. + @param trainDescriptors Train set of descriptors. This set is not added to the train descriptors + collection stored in the class object. + @param matches Found matches. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + @param maxDistance Threshold for the distance between matched descriptors. Distance means here + metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured + in Pixels)! + @param mask Mask specifying permissible matches between an input query and train matrices of + descriptors. + + For each query descriptor, the methods find such training descriptors that the distance between the + query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are + returned in the distance increasing order. + */ + CV_WRAP void radiusMatch( InputArray queryDescriptors, InputArray trainDescriptors, + CV_OUT std::vector >& matches, float maxDistance, + InputArray mask=noArray(), bool compactResult=false ) const; + + /** @overload + @param queryDescriptors Query set of descriptors. + @param matches Matches. If a query descriptor is masked out in mask , no match is added for this + descriptor. So, matches size may be smaller than the query descriptors count. + @param masks Set of masks. Each masks[i] specifies permissible matches between the input query + descriptors and stored train descriptors from the i-th image trainDescCollection[i]. + */ + CV_WRAP void match( InputArray queryDescriptors, CV_OUT std::vector& matches, + InputArrayOfArrays masks=noArray() ); + /** @overload + @param queryDescriptors Query set of descriptors. + @param matches Matches. Each matches[i] is k or less matches for the same query descriptor. + @param k Count of best matches found per each query descriptor or less if a query descriptor has + less than k possible matches in total. + @param masks Set of masks. Each masks[i] specifies permissible matches between the input query + descriptors and stored train descriptors from the i-th image trainDescCollection[i]. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + */ + CV_WRAP void knnMatch( InputArray queryDescriptors, CV_OUT std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ); + /** @overload + @param queryDescriptors Query set of descriptors. + @param matches Found matches. + @param maxDistance Threshold for the distance between matched descriptors. Distance means here + metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured + in Pixels)! + @param masks Set of masks. Each masks[i] specifies permissible matches between the input query + descriptors and stored train descriptors from the i-th image trainDescCollection[i]. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + */ + CV_WRAP void radiusMatch( InputArray queryDescriptors, CV_OUT std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ); + + + CV_WRAP void write( const String& fileName ) const + { + FileStorage fs(fileName, FileStorage::WRITE); + write(fs); + } + + CV_WRAP void read( const String& fileName ) + { + FileStorage fs(fileName, FileStorage::READ); + read(fs.root()); + } + // Reads matcher object from a file node + // see corresponding cv::Algorithm method + CV_WRAP virtual void read( const FileNode& ) CV_OVERRIDE; + // Writes matcher object to a file storage + virtual void write( FileStorage& ) const CV_OVERRIDE; + + /** @brief Clones the matcher. + + @param emptyTrainData If emptyTrainData is false, the method creates a deep copy of the object, + that is, copies both parameters and train data. If emptyTrainData is true, the method creates an + object copy with the current parameters but with empty train data. + */ + CV_WRAP CV_NODISCARD_STD virtual Ptr clone( bool emptyTrainData=false ) const = 0; + + /** @brief Creates a descriptor matcher of a given type with the default parameters (using default + constructor). + + @param descriptorMatcherType Descriptor matcher type. Now the following matcher types are + supported: + - `BruteForce` (it uses L2 ) + - `BruteForce-L1` + - `BruteForce-Hamming` + - `BruteForce-Hamming(2)` + - `FlannBased` + */ + CV_WRAP static Ptr create( const String& descriptorMatcherType ); + + CV_WRAP static Ptr create( const DescriptorMatcher::MatcherType& matcherType ); + + + // see corresponding cv::Algorithm method + CV_WRAP inline void write(const Ptr& fs, const String& name = String()) const { Algorithm::write(fs, name); } + +protected: + /** + * Class to work with descriptors from several images as with one merged matrix. + * It is used e.g. in FlannBasedMatcher. + */ + class CV_EXPORTS DescriptorCollection + { + public: + DescriptorCollection(); + DescriptorCollection( const DescriptorCollection& collection ); + virtual ~DescriptorCollection(); + + // Vector of matrices "descriptors" will be merged to one matrix "mergedDescriptors" here. + void set( const std::vector& descriptors ); + virtual void clear(); + + const Mat& getDescriptors() const; + const Mat getDescriptor( int imgIdx, int localDescIdx ) const; + const Mat getDescriptor( int globalDescIdx ) const; + void getLocalIdx( int globalDescIdx, int& imgIdx, int& localDescIdx ) const; + + int size() const; + + protected: + Mat mergedDescriptors; + std::vector startIdxs; + }; + + //! In fact the matching is implemented only by the following two methods. These methods suppose + //! that the class object has been trained already. Public match methods call these methods + //! after calling train(). + virtual void knnMatchImpl( InputArray queryDescriptors, std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) = 0; + virtual void radiusMatchImpl( InputArray queryDescriptors, std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) = 0; + + static bool isPossibleMatch( InputArray mask, int queryIdx, int trainIdx ); + static bool isMaskedOut( InputArrayOfArrays masks, int queryIdx ); + + CV_NODISCARD_STD static Mat clone_op( Mat m ) { return m.clone(); } + void checkMasks( InputArrayOfArrays masks, int queryDescriptorsCount ) const; + + //! Collection of descriptors from train images. + std::vector trainDescCollection; + std::vector utrainDescCollection; +}; + +/** @brief Brute-force descriptor matcher. + +For each descriptor in the first set, this matcher finds the closest descriptor in the second set +by trying each one. This descriptor matcher supports masking permissible matches of descriptor +sets. + */ +class CV_EXPORTS_W BFMatcher : public DescriptorMatcher +{ +public: + /** @brief Brute-force matcher constructor (obsolete). Please use BFMatcher.create() + * + * + */ + CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false ); + + virtual ~BFMatcher() {} + + virtual bool isMaskSupported() const CV_OVERRIDE { return true; } + + /** @brief Brute-force matcher create method. + @param normType One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are + preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and + BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor + description). + @param crossCheck If it is false, this is will be default BFMatcher behaviour when it finds the k + nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with + k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the + matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent + pairs. Such technique usually produces best results with minimal number of outliers when there are + enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper. + */ + CV_WRAP static Ptr create( int normType=NORM_L2, bool crossCheck=false ) ; + + CV_NODISCARD_STD virtual Ptr clone( bool emptyTrainData=false ) const CV_OVERRIDE; +protected: + virtual void knnMatchImpl( InputArray queryDescriptors, std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + virtual void radiusMatchImpl( InputArray queryDescriptors, std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + + int normType; + bool crossCheck; +}; + +#if defined(HAVE_OPENCV_FLANN) || defined(CV_DOXYGEN) + +/** @brief Flann-based descriptor matcher. + +This matcher trains cv::flann::Index on a train descriptor collection and calls its nearest search +methods to find the best matches. So, this matcher may be faster when matching a large train +collection than the brute force matcher. FlannBasedMatcher does not support masking permissible +matches of descriptor sets because flann::Index does not support this. : + */ +class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher +{ +public: + CV_WRAP FlannBasedMatcher( const Ptr& indexParams=makePtr(), + const Ptr& searchParams=makePtr() ); + + virtual void add( InputArrayOfArrays descriptors ) CV_OVERRIDE; + virtual void clear() CV_OVERRIDE; + + // Reads matcher object from a file node + virtual void read( const FileNode& ) CV_OVERRIDE; + // Writes matcher object to a file storage + virtual void write( FileStorage& ) const CV_OVERRIDE; + + virtual void train() CV_OVERRIDE; + virtual bool isMaskSupported() const CV_OVERRIDE; + + CV_WRAP static Ptr create(); + + CV_NODISCARD_STD virtual Ptr clone( bool emptyTrainData=false ) const CV_OVERRIDE; +protected: + static void convertToDMatches( const DescriptorCollection& descriptors, + const Mat& indices, const Mat& distances, + std::vector >& matches ); + + virtual void knnMatchImpl( InputArray queryDescriptors, std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + virtual void radiusMatchImpl( InputArray queryDescriptors, std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + + Ptr indexParams; + Ptr searchParams; + Ptr flannIndex; + + DescriptorCollection mergedDescriptors; + int addedDescCount; +}; + +#endif + +//! @} features2d_match + +/****************************************************************************************\ +* Drawing functions * +\****************************************************************************************/ + +//! @addtogroup features2d_draw +//! @{ + +enum struct DrawMatchesFlags +{ + DEFAULT = 0, //!< Output image matrix will be created (Mat::create), + //!< i.e. existing memory of output image may be reused. + //!< Two source image, matches and single keypoints will be drawn. + //!< For each keypoint only the center point will be drawn (without + //!< the circle around keypoint with keypoint size and orientation). + DRAW_OVER_OUTIMG = 1, //!< Output image matrix will not be created (Mat::create). + //!< Matches will be drawn on existing content of output image. + NOT_DRAW_SINGLE_POINTS = 2, //!< Single keypoints will not be drawn. + DRAW_RICH_KEYPOINTS = 4 //!< For each keypoint the circle around keypoint with keypoint size and + //!< orientation will be drawn. +}; +CV_ENUM_FLAGS(DrawMatchesFlags) + +/** @brief Draws keypoints. + +@param image Source image. +@param keypoints Keypoints from the source image. +@param outImage Output image. Its content depends on the flags value defining what is drawn in the +output image. See possible flags bit values below. +@param color Color of keypoints. +@param flags Flags setting drawing features. Possible flags bit values are defined by +DrawMatchesFlags. See details above in drawMatches . + +@note +For Python API, flags are modified as cv.DRAW_MATCHES_FLAGS_DEFAULT, +cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG, +cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS + */ +CV_EXPORTS_W void drawKeypoints( InputArray image, const std::vector& keypoints, InputOutputArray outImage, + const Scalar& color=Scalar::all(-1), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +/** @brief Draws the found matches of keypoints from two images. + +@param img1 First source image. +@param keypoints1 Keypoints from the first source image. +@param img2 Second source image. +@param keypoints2 Keypoints from the second source image. +@param matches1to2 Matches from the first image to the second one, which means that keypoints1[i] +has a corresponding point in keypoints2[matches[i]] . +@param outImg Output image. Its content depends on the flags value defining what is drawn in the +output image. See possible flags bit values below. +@param matchColor Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1) +, the color is generated randomly. +@param singlePointColor Color of single keypoints (circles), which means that keypoints do not +have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly. +@param matchesMask Mask determining which matches are drawn. If the mask is empty, all matches are +drawn. +@param flags Flags setting drawing features. Possible flags bit values are defined by +DrawMatchesFlags. + +This function draws matches of keypoints from two images in the output image. Match is a line +connecting two keypoints (circles). See cv::DrawMatchesFlags. + */ +CV_EXPORTS_W void drawMatches( InputArray img1, const std::vector& keypoints1, + InputArray img2, const std::vector& keypoints2, + const std::vector& matches1to2, InputOutputArray outImg, + const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), + const std::vector& matchesMask=std::vector(), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +/** @overload */ +CV_EXPORTS_W void drawMatches( InputArray img1, const std::vector& keypoints1, + InputArray img2, const std::vector& keypoints2, + const std::vector& matches1to2, InputOutputArray outImg, + const int matchesThickness, const Scalar& matchColor=Scalar::all(-1), + const Scalar& singlePointColor=Scalar::all(-1), const std::vector& matchesMask=std::vector(), + DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +CV_EXPORTS_AS(drawMatchesKnn) void drawMatches( InputArray img1, const std::vector& keypoints1, + InputArray img2, const std::vector& keypoints2, + const std::vector >& matches1to2, InputOutputArray outImg, + const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), + const std::vector >& matchesMask=std::vector >(), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +//! @} features2d_draw + +/****************************************************************************************\ +* Functions to evaluate the feature detectors and [generic] descriptor extractors * +\****************************************************************************************/ + +CV_EXPORTS void evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2, + std::vector* keypoints1, std::vector* keypoints2, + float& repeatability, int& correspCount, + const Ptr& fdetector=Ptr() ); + +CV_EXPORTS void computeRecallPrecisionCurve( const std::vector >& matches1to2, + const std::vector >& correctMatches1to2Mask, + std::vector& recallPrecisionCurve ); + +CV_EXPORTS float getRecall( const std::vector& recallPrecisionCurve, float l_precision ); +CV_EXPORTS int getNearestPoint( const std::vector& recallPrecisionCurve, float l_precision ); + +/****************************************************************************************\ +* Bag of visual words * +\****************************************************************************************/ + +//! @addtogroup features2d_category +//! @{ + +/** @brief Abstract base class for training the *bag of visual words* vocabulary from a set of descriptors. + +For details, see, for example, *Visual Categorization with Bags of Keypoints* by Gabriella Csurka, +Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. : + */ +class CV_EXPORTS_W BOWTrainer +{ +public: + BOWTrainer(); + virtual ~BOWTrainer(); + + /** @brief Adds descriptors to a training set. + + @param descriptors Descriptors to add to a training set. Each row of the descriptors matrix is a + descriptor. + + The training set is clustered using clustermethod to construct the vocabulary. + */ + CV_WRAP void add( const Mat& descriptors ); + + /** @brief Returns a training set of descriptors. + */ + CV_WRAP const std::vector& getDescriptors() const; + + /** @brief Returns the count of all descriptors stored in the training set. + */ + CV_WRAP int descriptorsCount() const; + + CV_WRAP virtual void clear(); + + /** @overload */ + CV_WRAP virtual Mat cluster() const = 0; + + /** @brief Clusters train descriptors. + + @param descriptors Descriptors to cluster. Each row of the descriptors matrix is a descriptor. + Descriptors are not added to the inner train descriptor set. + + The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first + variant of the method, train descriptors stored in the object are clustered. In the second variant, + input descriptors are clustered. + */ + CV_WRAP virtual Mat cluster( const Mat& descriptors ) const = 0; + +protected: + std::vector descriptors; + int size; +}; + +/** @brief kmeans -based class to train visual vocabulary using the *bag of visual words* approach. : + */ +class CV_EXPORTS_W BOWKMeansTrainer : public BOWTrainer +{ +public: + /** @brief The constructor. + + @see cv::kmeans + */ + CV_WRAP BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(), + int attempts=3, int flags=KMEANS_PP_CENTERS ); + virtual ~BOWKMeansTrainer(); + + // Returns trained vocabulary (i.e. cluster centers). + CV_WRAP virtual Mat cluster() const CV_OVERRIDE; + CV_WRAP virtual Mat cluster( const Mat& descriptors ) const CV_OVERRIDE; + +protected: + + int clusterCount; + TermCriteria termcrit; + int attempts; + int flags; +}; + +/** @brief Class to compute an image descriptor using the *bag of visual words*. + +Such a computation consists of the following steps: + +1. Compute descriptors for a given image and its keypoints set. +2. Find the nearest visual words from the vocabulary for each keypoint descriptor. +3. Compute the bag-of-words image descriptor as is a normalized histogram of vocabulary words +encountered in the image. The i-th bin of the histogram is a frequency of i-th word of the +vocabulary in the given image. + */ +class CV_EXPORTS_W BOWImgDescriptorExtractor +{ +public: + /** @brief The constructor. + + @param dextractor Descriptor extractor that is used to compute descriptors for an input image and + its keypoints. + @param dmatcher Descriptor matcher that is used to find the nearest word of the trained vocabulary + for each keypoint descriptor of the image. + */ + CV_WRAP BOWImgDescriptorExtractor( const Ptr& dextractor, + const Ptr& dmatcher ); + /** @overload */ + BOWImgDescriptorExtractor( const Ptr& dmatcher ); + virtual ~BOWImgDescriptorExtractor(); + + /** @brief Sets a visual vocabulary. + + @param vocabulary Vocabulary (can be trained using the inheritor of BOWTrainer ). Each row of the + vocabulary is a visual word (cluster center). + */ + CV_WRAP void setVocabulary( const Mat& vocabulary ); + + /** @brief Returns the set vocabulary. + */ + CV_WRAP const Mat& getVocabulary() const; + + /** @brief Computes an image descriptor using the set visual vocabulary. + + @param image Image, for which the descriptor is computed. + @param keypoints Keypoints detected in the input image. + @param imgDescriptor Computed output image descriptor. + @param pointIdxsOfClusters Indices of keypoints that belong to the cluster. This means that + pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary) + returned if it is non-zero. + @param descriptors Descriptors of the image keypoints that are returned if they are non-zero. + */ + void compute( InputArray image, std::vector& keypoints, OutputArray imgDescriptor, + std::vector >* pointIdxsOfClusters=0, Mat* descriptors=0 ); + /** @overload + @param keypointDescriptors Computed descriptors to match with vocabulary. + @param imgDescriptor Computed output image descriptor. + @param pointIdxsOfClusters Indices of keypoints that belong to the cluster. This means that + pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary) + returned if it is non-zero. + */ + void compute( InputArray keypointDescriptors, OutputArray imgDescriptor, + std::vector >* pointIdxsOfClusters=0 ); + // compute() is not constant because DescriptorMatcher::match is not constant + + CV_WRAP_AS(compute) void compute2( const Mat& image, std::vector& keypoints, CV_OUT Mat& imgDescriptor ) + { compute(image,keypoints,imgDescriptor); } + + /** @brief Returns an image descriptor size if the vocabulary is set. Otherwise, it returns 0. + */ + CV_WRAP int descriptorSize() const; + + /** @brief Returns an image descriptor type. + */ + CV_WRAP int descriptorType() const; + +protected: + Mat vocabulary; + Ptr dextractor; + Ptr dmatcher; +}; + +//! @} features2d_category + +//! @} features2d + +} /* namespace cv */ + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/features2d/features2d.hpp b/Cigarette/OpenCV455Simple/include/opencv2/features2d/features2d.hpp new file mode 100644 index 0000000..e81df0a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/features2d/features2d.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/features2d.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/features2d/hal/interface.h b/Cigarette/OpenCV455Simple/include/opencv2/features2d/hal/interface.h new file mode 100644 index 0000000..bc3b084 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/features2d/hal/interface.h @@ -0,0 +1,33 @@ +#ifndef OPENCV_FEATURE2D_HAL_INTERFACE_H +#define OPENCV_FEATURE2D_HAL_INTERFACE_H + +#include "opencv2/core/cvdef.h" +//! @addtogroup features2d_hal_interface +//! @{ + +//! @name Fast feature detector types +//! @sa cv::FastFeatureDetector +//! @{ +#define CV_HAL_TYPE_5_8 0 +#define CV_HAL_TYPE_7_12 1 +#define CV_HAL_TYPE_9_16 2 +//! @} + +//! @name Key point +//! @sa cv::KeyPoint +//! @{ +struct CV_EXPORTS cvhalKeyPoint +{ + float x; + float y; + float size; + float angle; + float response; + int octave; + int class_id; +}; +//! @} + +//! @} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann.hpp b/Cigarette/OpenCV455Simple/include/opencv2/flann.hpp new file mode 100644 index 0000000..0468903 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann.hpp @@ -0,0 +1,629 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_FLANN_HPP +#define OPENCV_FLANN_HPP + +#include "opencv2/core.hpp" +#include "opencv2/flann/miniflann.hpp" +#include "opencv2/flann/flann_base.hpp" + +/** +@defgroup flann Clustering and Search in Multi-Dimensional Spaces + +This section documents OpenCV's interface to the FLANN library. FLANN (Fast Library for Approximate +Nearest Neighbors) is a library that contains a collection of algorithms optimized for fast nearest +neighbor search in large datasets and for high dimensional features. More information about FLANN +can be found in @cite Muja2009 . +*/ + +namespace cvflann +{ + CV_EXPORTS flann_distance_t flann_distance_type(); + CV_DEPRECATED CV_EXPORTS void set_distance_type(flann_distance_t distance_type, int order); +} + + +namespace cv +{ +namespace flann +{ + + +//! @addtogroup flann +//! @{ + +template struct CvType {}; +template <> struct CvType { static int type() { return CV_8U; } }; +template <> struct CvType { static int type() { return CV_8S; } }; +template <> struct CvType { static int type() { return CV_16U; } }; +template <> struct CvType { static int type() { return CV_16S; } }; +template <> struct CvType { static int type() { return CV_32S; } }; +template <> struct CvType { static int type() { return CV_32F; } }; +template <> struct CvType { static int type() { return CV_64F; } }; + + +// bring the flann parameters into this namespace +using ::cvflann::get_param; +using ::cvflann::print_params; + +// bring the flann distances into this namespace +using ::cvflann::L2_Simple; +using ::cvflann::L2; +using ::cvflann::L1; +using ::cvflann::MinkowskiDistance; +using ::cvflann::MaxDistance; +using ::cvflann::HammingLUT; +using ::cvflann::Hamming; +using ::cvflann::Hamming2; +using ::cvflann::DNAmmingLUT; +using ::cvflann::DNAmming2; +using ::cvflann::HistIntersectionDistance; +using ::cvflann::HellingerDistance; +using ::cvflann::ChiSquareDistance; +using ::cvflann::KL_Divergence; + + +/** @brief The FLANN nearest neighbor index class. This class is templated with the type of elements for which +the index is built. + +`Distance` functor specifies the metric to be used to calculate the distance between two points. +There are several `Distance` functors that are readily available: + +cv::cvflann::L2_Simple - Squared Euclidean distance functor. +This is the simpler, unrolled version. This is preferable for very low dimensionality data (eg 3D points) + +cv::flann::L2 - Squared Euclidean distance functor, optimized version. + +cv::flann::L1 - Manhattan distance functor, optimized version. + +cv::flann::MinkowskiDistance - The Minkowsky distance functor. +This is highly optimised with loop unrolling. +The computation of squared root at the end is omitted for efficiency. + +cv::flann::MaxDistance - The max distance functor. It computes the +maximum distance between two vectors. This distance is not a valid kdtree distance, it's not +dimensionwise additive. + +cv::flann::HammingLUT - %Hamming distance functor. It counts the bit +differences between two strings using a lookup table implementation. + +cv::flann::Hamming - %Hamming distance functor. Population count is +performed using library calls, if available. Lookup table implementation is used as a fallback. + +cv::flann::Hamming2 - %Hamming distance functor. Population count is +implemented in 12 arithmetic operations (one of which is multiplication). + +cv::flann::DNAmmingLUT - %Adaptation of the Hamming distance functor to DNA comparison. +As the four bases A, C, G, T of the DNA (or A, G, C, U for RNA) can be coded on 2 bits, +it counts the bits pairs differences between two sequences using a lookup table implementation. + +cv::flann::DNAmming2 - %Adaptation of the Hamming distance functor to DNA comparison. +Bases differences count are vectorised thanks to arithmetic operations using standard +registers (AVX2 and AVX-512 should come in a near future). + +cv::flann::HistIntersectionDistance - The histogram +intersection distance functor. + +cv::flann::HellingerDistance - The Hellinger distance functor. + +cv::flann::ChiSquareDistance - The chi-square distance functor. + +cv::flann::KL_Divergence - The Kullback-Leibler divergence functor. + +Although the provided implementations cover a vast range of cases, it is also possible to use +a custom implementation. The distance functor is a class whose `operator()` computes the distance +between two features. If the distance is also a kd-tree compatible distance, it should also provide an +`accum_dist()` method that computes the distance between individual feature dimensions. + +In addition to `operator()` and `accum_dist()`, a distance functor should also define the +`ElementType` and the `ResultType` as the types of the elements it operates on and the type of the +result it computes. If a distance functor can be used as a kd-tree distance (meaning that the full +distance between a pair of features can be accumulated from the partial distances between the +individual dimensions) a typedef `is_kdtree_distance` should be present inside the distance functor. +If the distance is not a kd-tree distance, but it's a distance in a vector space (the individual +dimensions of the elements it operates on can be accessed independently) a typedef +`is_vector_space_distance` should be defined inside the functor. If neither typedef is defined, the +distance is assumed to be a metric distance and will only be used with indexes operating on +generic metric distances. + */ +template +class GenericIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + /** @brief Constructs a nearest neighbor search index for a given dataset. + + @param features Matrix of containing the features(points) to index. The size of the matrix is + num_features x feature_dimensionality and the data type of the elements in the matrix must + coincide with the type of the index. + @param params Structure containing the index parameters. The type of index that will be + constructed depends on the type of this parameter. See the description. + @param distance + + The method constructs a fast search structure from a set of features using the specified algorithm + with specified parameters, as defined by params. params is a reference to one of the following class + IndexParams descendants: + + - **LinearIndexParams** When passing an object of this type, the index will perform a linear, + brute-force search. : + @code + struct LinearIndexParams : public IndexParams + { + }; + @endcode + - **KDTreeIndexParams** When passing an object of this type the index constructed will consist of + a set of randomized kd-trees which will be searched in parallel. : + @code + struct KDTreeIndexParams : public IndexParams + { + KDTreeIndexParams( int trees = 4 ); + }; + @endcode + - **HierarchicalClusteringIndexParams** When passing an object of this type the index constructed + will be a hierarchical tree of clusters, dividing each set of points into n clusters whose centers + are picked among the points without further refinement of their position. + This algorithm fits both floating, integer and binary vectors. : + @code + struct HierarchicalClusteringIndexParams : public IndexParams + { + HierarchicalClusteringIndexParams( + int branching = 32, + flann_centers_init_t centers_init = CENTERS_RANDOM, + int trees = 4, + int leaf_size = 100); + + }; + @endcode + - **KMeansIndexParams** When passing an object of this type the index constructed will be a + hierarchical k-means tree (one tree by default), dividing each set of points into n clusters + whose barycenters are refined iteratively. + Note that this algorithm has been extended to the support of binary vectors as an alternative + to LSH when knn search speed is the criterium. It will also outperform LSH when processing + directly (i.e. without the use of MCA/PCA) datasets whose points share mostly the same values + for most of the dimensions. It is recommended to set more than one tree with binary data. : + @code + struct KMeansIndexParams : public IndexParams + { + KMeansIndexParams( + int branching = 32, + int iterations = 11, + flann_centers_init_t centers_init = CENTERS_RANDOM, + float cb_index = 0.2, + int trees = 1); + }; + @endcode + - **CompositeIndexParams** When using a parameters object of this type the index created + combines the randomized kd-trees and the hierarchical k-means tree. : + @code + struct CompositeIndexParams : public IndexParams + { + CompositeIndexParams( + int trees = 4, + int branching = 32, + int iterations = 11, + flann_centers_init_t centers_init = CENTERS_RANDOM, + float cb_index = 0.2 ); + }; + @endcode + - **LshIndexParams** When using a parameters object of this type the index created uses + multi-probe LSH (by Multi-Probe LSH: Efficient Indexing for High-Dimensional Similarity Search + by Qin Lv, William Josephson, Zhe Wang, Moses Charikar, Kai Li., Proceedings of the 33rd + International Conference on Very Large Data Bases (VLDB). Vienna, Austria. September 2007). + This algorithm is designed for binary vectors. : + @code + struct LshIndexParams : public IndexParams + { + LshIndexParams( + int table_number, + int key_size, + int multi_probe_level ); + }; + @endcode + - **AutotunedIndexParams** When passing an object of this type the index created is + automatically tuned to offer the best performance, by choosing the optimal index type + (randomized kd-trees, hierarchical kmeans, linear) and parameters for the dataset provided. : + @code + struct AutotunedIndexParams : public IndexParams + { + AutotunedIndexParams( + float target_precision = 0.9, + float build_weight = 0.01, + float memory_weight = 0, + float sample_fraction = 0.1 ); + }; + @endcode + - **SavedIndexParams** This object type is used for loading a previously saved index from the + disk. : + @code + struct SavedIndexParams : public IndexParams + { + SavedIndexParams( String filename ); + }; + @endcode + */ + GenericIndex(const Mat& features, const ::cvflann::IndexParams& params, Distance distance = Distance()); + + ~GenericIndex(); + + /** @brief Performs a K-nearest neighbor search for a given query point using the index. + + @param query The query point + @param indices Vector that will contain the indices of the K-nearest neighbors found. It must have + at least knn size. + @param dists Vector that will contain the distances to the K-nearest neighbors found. It must have + at least knn size. + @param knn Number of nearest neighbors to search for. + @param params SearchParams + */ + void knnSearch(const std::vector& query, std::vector& indices, + std::vector& dists, int knn, const ::cvflann::SearchParams& params); + void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& params); + + /** @brief Performs a radius nearest neighbor search for a given query point using the index. + + @param query The query point. + @param indices Vector that will contain the indices of the nearest neighbors found. + @param dists Vector that will contain the distances to the nearest neighbors found. It has the same + number of elements as indices. + @param radius The search radius. + @param params SearchParams + + This function returns the number of nearest neighbors found. + */ + int radiusSearch(const std::vector& query, std::vector& indices, + std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); + int radiusSearch(const Mat& query, Mat& indices, Mat& dists, + DistanceType radius, const ::cvflann::SearchParams& params); + + void save(String filename) { nnIndex->save(filename); } + + int veclen() const { return nnIndex->veclen(); } + + int size() const { return (int)nnIndex->size(); } + + ::cvflann::IndexParams getParameters() { return nnIndex->getParameters(); } + + CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() { return nnIndex->getIndexParameters(); } + +private: + ::cvflann::Index* nnIndex; + Mat _dataset; +}; + +//! @cond IGNORED + +#define FLANN_DISTANCE_CHECK \ + if ( ::cvflann::flann_distance_type() != cvflann::FLANN_DIST_L2) { \ + printf("[WARNING] You are using cv::flann::Index (or cv::flann::GenericIndex) and have also changed "\ + "the distance using cvflann::set_distance_type. This is no longer working as expected "\ + "(cv::flann::Index always uses L2). You should create the index templated on the distance, "\ + "for example for L1 distance use: GenericIndex< L1 > \n"); \ + } + + +template +GenericIndex::GenericIndex(const Mat& dataset, const ::cvflann::IndexParams& params, Distance distance) +: _dataset(dataset) +{ + CV_Assert(dataset.type() == CvType::type()); + CV_Assert(dataset.isContinuous()); + ::cvflann::Matrix m_dataset((ElementType*)_dataset.ptr(0), _dataset.rows, _dataset.cols); + + nnIndex = new ::cvflann::Index(m_dataset, params, distance); + + FLANN_DISTANCE_CHECK + + nnIndex->buildIndex(); +} + +template +GenericIndex::~GenericIndex() +{ + delete nnIndex; +} + +template +void GenericIndex::knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& searchParams) +{ + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + FLANN_DISTANCE_CHECK + + nnIndex->knnSearch(m_query,m_indices,m_dists,knn,searchParams); +} + + +template +void GenericIndex::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams) +{ + CV_Assert(queries.type() == CvType::type()); + CV_Assert(queries.isContinuous()); + ::cvflann::Matrix m_queries((ElementType*)queries.ptr(0), queries.rows, queries.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + FLANN_DISTANCE_CHECK + + nnIndex->knnSearch(m_queries,m_indices,m_dists,knn, searchParams); +} + +template +int GenericIndex::radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) +{ + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + FLANN_DISTANCE_CHECK + + return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); +} + +template +int GenericIndex::radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) +{ + CV_Assert(query.type() == CvType::type()); + CV_Assert(query.isContinuous()); + ::cvflann::Matrix m_query((ElementType*)query.ptr(0), query.rows, query.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + FLANN_DISTANCE_CHECK + + return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); +} + +/** + * @deprecated Use GenericIndex class instead + */ +template +class Index_ +{ +public: + typedef typename L2::ElementType ElementType; + typedef typename L2::ResultType DistanceType; + + CV_DEPRECATED Index_(const Mat& dataset, const ::cvflann::IndexParams& params) + { + printf("[WARNING] The cv::flann::Index_ class is deperecated, use cv::flann::GenericIndex instead\n"); + + CV_Assert(dataset.type() == CvType::type()); + CV_Assert(dataset.isContinuous()); + ::cvflann::Matrix m_dataset((ElementType*)dataset.ptr(0), dataset.rows, dataset.cols); + + if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L2 ) { + nnIndex_L1 = NULL; + nnIndex_L2 = new ::cvflann::Index< L2 >(m_dataset, params); + } + else if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L1 ) { + nnIndex_L1 = new ::cvflann::Index< L1 >(m_dataset, params); + nnIndex_L2 = NULL; + } + else { + printf("[ERROR] cv::flann::Index_ only provides backwards compatibility for the L1 and L2 distances. " + "For other distance types you must use cv::flann::GenericIndex\n"); + CV_Assert(0); + } + if (nnIndex_L1) nnIndex_L1->buildIndex(); + if (nnIndex_L2) nnIndex_L2->buildIndex(); + } + CV_DEPRECATED ~Index_() + { + if (nnIndex_L1) delete nnIndex_L1; + if (nnIndex_L2) delete nnIndex_L2; + } + + CV_DEPRECATED void knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& searchParams) + { + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + if (nnIndex_L1) nnIndex_L1->knnSearch(m_query,m_indices,m_dists,knn,searchParams); + if (nnIndex_L2) nnIndex_L2->knnSearch(m_query,m_indices,m_dists,knn,searchParams); + } + CV_DEPRECATED void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams) + { + CV_Assert(queries.type() == CvType::type()); + CV_Assert(queries.isContinuous()); + ::cvflann::Matrix m_queries((ElementType*)queries.ptr(0), queries.rows, queries.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + if (nnIndex_L1) nnIndex_L1->knnSearch(m_queries,m_indices,m_dists,knn, searchParams); + if (nnIndex_L2) nnIndex_L2->knnSearch(m_queries,m_indices,m_dists,knn, searchParams); + } + + CV_DEPRECATED int radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) + { + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + } + + CV_DEPRECATED int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) + { + CV_Assert(query.type() == CvType::type()); + CV_Assert(query.isContinuous()); + ::cvflann::Matrix m_query((ElementType*)query.ptr(0), query.rows, query.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + } + + CV_DEPRECATED void save(String filename) + { + if (nnIndex_L1) nnIndex_L1->save(filename); + if (nnIndex_L2) nnIndex_L2->save(filename); + } + + CV_DEPRECATED int veclen() const + { + if (nnIndex_L1) return nnIndex_L1->veclen(); + if (nnIndex_L2) return nnIndex_L2->veclen(); + } + + CV_DEPRECATED int size() const + { + if (nnIndex_L1) return nnIndex_L1->size(); + if (nnIndex_L2) return nnIndex_L2->size(); + } + + CV_DEPRECATED ::cvflann::IndexParams getParameters() + { + if (nnIndex_L1) return nnIndex_L1->getParameters(); + if (nnIndex_L2) return nnIndex_L2->getParameters(); + + } + + CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() + { + if (nnIndex_L1) return nnIndex_L1->getIndexParameters(); + if (nnIndex_L2) return nnIndex_L2->getIndexParameters(); + } + +private: + // providing backwards compatibility for L2 and L1 distances (most common) + ::cvflann::Index< L2 >* nnIndex_L2; + ::cvflann::Index< L1 >* nnIndex_L1; +}; + +//! @endcond + +/** @brief Clusters features using hierarchical k-means algorithm. + +@param features The points to be clustered. The matrix must have elements of type +Distance::ElementType. +@param centers The centers of the clusters obtained. The matrix must have type +Distance::CentersType. The number of rows in this matrix represents the number of clusters desired, +however, because of the way the cut in the hierarchical tree is chosen, the number of clusters +computed will be the highest number of the form (branching-1)\*k+1 that's lower than the number of +clusters desired, where branching is the tree's branching factor (see description of the +KMeansIndexParams). +@param params Parameters used in the construction of the hierarchical k-means tree. +@param d Distance to be used for clustering. + +The method clusters the given feature vectors by constructing a hierarchical k-means tree and +choosing a cut in the tree that minimizes the cluster's variance. It returns the number of clusters +found. + */ +template +int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params, + Distance d = Distance()) +{ + typedef typename Distance::ElementType ElementType; + typedef typename Distance::CentersType CentersType; + + CV_Assert(features.type() == CvType::type()); + CV_Assert(features.isContinuous()); + ::cvflann::Matrix m_features((ElementType*)features.ptr(0), features.rows, features.cols); + + CV_Assert(centers.type() == CvType::type()); + CV_Assert(centers.isContinuous()); + ::cvflann::Matrix m_centers((CentersType*)centers.ptr(0), centers.rows, centers.cols); + + return ::cvflann::hierarchicalClustering(m_features, m_centers, params, d); +} + +//! @cond IGNORED + +template +CV_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params) +{ + printf("[WARNING] cv::flann::hierarchicalClustering is deprecated, use " + "cv::flann::hierarchicalClustering instead\n"); + + if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L2 ) { + return hierarchicalClustering< L2 >(features, centers, params); + } + else if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L1 ) { + return hierarchicalClustering< L1 >(features, centers, params); + } + else { + printf("[ERROR] cv::flann::hierarchicalClustering only provides backwards " + "compatibility for the L1 and L2 distances. " + "For other distance types you must use cv::flann::hierarchicalClustering\n"); + CV_Assert(0); + } +} + +//! @endcond + +//! @} flann + +} } // namespace cv::flann + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/all_indices.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/all_indices.h new file mode 100644 index 0000000..03877ab --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/all_indices.h @@ -0,0 +1,162 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_ALL_INDICES_H_ +#define OPENCV_FLANN_ALL_INDICES_H_ + +//! @cond IGNORED + +#include "general.h" + +#include "nn_index.h" +#include "kdtree_index.h" +#include "kdtree_single_index.h" +#include "kmeans_index.h" +#include "composite_index.h" +#include "linear_index.h" +#include "hierarchical_clustering_index.h" +#include "lsh_index.h" +#include "autotuned_index.h" + + +namespace cvflann +{ + +template +struct index_creator +{ + static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) + { + flann_algorithm_t index_type = get_param(params, "algorithm"); + + NNIndex* nnIndex; + switch (index_type) { + case FLANN_INDEX_LINEAR: + nnIndex = new LinearIndex(dataset, params, distance); + break; + case FLANN_INDEX_KDTREE_SINGLE: + nnIndex = new KDTreeSingleIndex(dataset, params, distance); + break; + case FLANN_INDEX_KDTREE: + nnIndex = new KDTreeIndex(dataset, params, distance); + break; + case FLANN_INDEX_KMEANS: + nnIndex = new KMeansIndex(dataset, params, distance); + break; + case FLANN_INDEX_COMPOSITE: + nnIndex = new CompositeIndex(dataset, params, distance); + break; + case FLANN_INDEX_AUTOTUNED: + nnIndex = new AutotunedIndex(dataset, params, distance); + break; + case FLANN_INDEX_HIERARCHICAL: + nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); + break; + case FLANN_INDEX_LSH: + nnIndex = new LshIndex(dataset, params, distance); + break; + default: + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); + } + + return nnIndex; + } +}; + +template +struct index_creator +{ + static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) + { + flann_algorithm_t index_type = get_param(params, "algorithm"); + + NNIndex* nnIndex; + switch (index_type) { + case FLANN_INDEX_LINEAR: + nnIndex = new LinearIndex(dataset, params, distance); + break; + case FLANN_INDEX_KMEANS: + nnIndex = new KMeansIndex(dataset, params, distance); + break; + case FLANN_INDEX_HIERARCHICAL: + nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); + break; + case FLANN_INDEX_LSH: + nnIndex = new LshIndex(dataset, params, distance); + break; + default: + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); + } + + return nnIndex; + } +}; + +template +struct index_creator +{ + static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) + { + flann_algorithm_t index_type = get_param(params, "algorithm"); + + NNIndex* nnIndex; + switch (index_type) { + case FLANN_INDEX_LINEAR: + nnIndex = new LinearIndex(dataset, params, distance); + break; + case FLANN_INDEX_KMEANS: + nnIndex = new KMeansIndex(dataset, params, distance); + break; + case FLANN_INDEX_HIERARCHICAL: + nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); + break; + case FLANN_INDEX_LSH: + nnIndex = new LshIndex(dataset, params, distance); + break; + default: + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); + } + + return nnIndex; + } +}; + +template +NNIndex* create_index_by_type(const Matrix& dataset, const IndexParams& params, const Distance& distance) +{ + return index_creator::create(dataset, params,distance); +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_ALL_INDICES_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/allocator.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/allocator.h new file mode 100644 index 0000000..d5870a0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/allocator.h @@ -0,0 +1,196 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_ALLOCATOR_H_ +#define OPENCV_FLANN_ALLOCATOR_H_ + +//! @cond IGNORED + +#include +#include + + +namespace cvflann +{ + +/** + * Allocates (using C's malloc) a generic type T. + * + * Params: + * count = number of instances to allocate. + * Returns: pointer (of type T*) to memory buffer + */ +template +T* allocate(size_t count = 1) +{ + T* mem = (T*) ::malloc(sizeof(T)*count); + return mem; +} + + +/** + * Pooled storage allocator + * + * The following routines allow for the efficient allocation of storage in + * small chunks from a specified pool. Rather than allowing each structure + * to be freed individually, an entire pool of storage is freed at once. + * This method has two advantages over just using malloc() and free(). First, + * it is far more efficient for allocating small objects, as there is + * no overhead for remembering all the information needed to free each + * object or consolidating fragmented memory. Second, the decision about + * how long to keep an object is made at the time of allocation, and there + * is no need to track down all the objects to free them. + * + */ + +const size_t WORDSIZE=16; +const size_t BLOCKSIZE=8192; + +class PooledAllocator +{ + /* We maintain memory alignment to word boundaries by requiring that all + allocations be in multiples of the machine wordsize. */ + /* Size of machine word in bytes. Must be power of 2. */ + /* Minimum number of bytes requested at a time from the system. Must be multiple of WORDSIZE. */ + + + int remaining; /* Number of bytes left in current block of storage. */ + void* base; /* Pointer to base of current block of storage. */ + void* loc; /* Current location in block to next allocate memory. */ + int blocksize; + + +public: + int usedMemory; + int wastedMemory; + + /** + Default constructor. Initializes a new pool. + */ + PooledAllocator(int blockSize = BLOCKSIZE) + { + blocksize = blockSize; + remaining = 0; + base = NULL; + loc = NULL; + + usedMemory = 0; + wastedMemory = 0; + } + + /** + * Destructor. Frees all the memory allocated in this pool. + */ + ~PooledAllocator() + { + void* prev; + + while (base != NULL) { + prev = *((void**) base); /* Get pointer to prev block. */ + ::free(base); + base = prev; + } + } + + /** + * Returns a pointer to a piece of new memory of the given size in bytes + * allocated from the pool. + */ + void* allocateMemory(int size) + { + int blockSize; + + /* Round size up to a multiple of wordsize. The following expression + only works for WORDSIZE that is a power of 2, by masking last bits of + incremented size to zero. + */ + size = (size + (WORDSIZE - 1)) & ~(WORDSIZE - 1); + + /* Check whether a new block must be allocated. Note that the first word + of a block is reserved for a pointer to the previous block. + */ + if (size > remaining) { + + wastedMemory += remaining; + + /* Allocate new storage. */ + blockSize = (size + sizeof(void*) + (WORDSIZE-1) > BLOCKSIZE) ? + size + sizeof(void*) + (WORDSIZE-1) : BLOCKSIZE; + + // use the standard C malloc to allocate memory + void* m = ::malloc(blockSize); + if (!m) { + fprintf(stderr,"Failed to allocate memory.\n"); + return NULL; + } + + /* Fill first word of new block with pointer to previous block. */ + ((void**) m)[0] = base; + base = m; + + int shift = 0; + //int shift = (WORDSIZE - ( (((size_t)m) + sizeof(void*)) & (WORDSIZE-1))) & (WORDSIZE-1); + + remaining = blockSize - sizeof(void*) - shift; + loc = ((char*)m + sizeof(void*) + shift); + } + void* rloc = loc; + loc = (char*)loc + size; + remaining -= size; + + usedMemory += size; + + return rloc; + } + + /** + * Allocates (using this pool) a generic type T. + * + * Params: + * count = number of instances to allocate. + * Returns: pointer (of type T*) to memory buffer + */ + template + T* allocate(size_t count = 1) + { + T* mem = (T*) this->allocateMemory((int)(sizeof(T)*count)); + return mem; + } + +private: + PooledAllocator(const PooledAllocator &); // copy disabled + PooledAllocator& operator=(const PooledAllocator &); // assign disabled +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_ALLOCATOR_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/any.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/any.h new file mode 100644 index 0000000..4906fec --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/any.h @@ -0,0 +1,332 @@ +#ifndef OPENCV_FLANN_ANY_H_ +#define OPENCV_FLANN_ANY_H_ +/* + * (C) Copyright Christopher Diggins 2005-2011 + * (C) Copyright Pablo Aguilar 2005 + * (C) Copyright Kevlin Henney 2001 + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt + * + * Adapted for FLANN by Marius Muja + */ + +//! @cond IGNORED + +#include "defines.h" +#include +#include +#include + +namespace cvflann +{ + +namespace anyimpl +{ + +struct bad_any_cast +{ +}; + +struct empty_any +{ +}; + +inline std::ostream& operator <<(std::ostream& out, const empty_any&) +{ + out << "[empty_any]"; + return out; +} + +struct base_any_policy +{ + virtual void static_delete(void** x) = 0; + virtual void copy_from_value(void const* src, void** dest) = 0; + virtual void clone(void* const* src, void** dest) = 0; + virtual void move(void* const* src, void** dest) = 0; + virtual void* get_value(void** src) = 0; + virtual const void* get_value(void* const * src) = 0; + virtual ::size_t get_size() = 0; + virtual const std::type_info& type() = 0; + virtual void print(std::ostream& out, void* const* src) = 0; + virtual ~base_any_policy() {} +}; + +template +struct typed_base_any_policy : base_any_policy +{ + virtual ::size_t get_size() CV_OVERRIDE { return sizeof(T); } + virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); } + +}; + +template +struct small_any_policy CV_FINAL : typed_base_any_policy +{ + virtual void static_delete(void**) CV_OVERRIDE { } + virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE + { + new (dest) T(* reinterpret_cast(src)); + } + virtual void clone(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; } + virtual void move(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; } + virtual void* get_value(void** src) CV_OVERRIDE { return reinterpret_cast(src); } + virtual const void* get_value(void* const * src) CV_OVERRIDE { return reinterpret_cast(src); } + virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast(src); } +}; + +template +struct big_any_policy CV_FINAL : typed_base_any_policy +{ + virtual void static_delete(void** x) CV_OVERRIDE + { + if (* x) delete (* reinterpret_cast(x)); + *x = NULL; + } + virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE + { + *dest = new T(*reinterpret_cast(src)); + } + virtual void clone(void* const* src, void** dest) CV_OVERRIDE + { + *dest = new T(**reinterpret_cast(src)); + } + virtual void move(void* const* src, void** dest) CV_OVERRIDE + { + (*reinterpret_cast(dest))->~T(); + **reinterpret_cast(dest) = **reinterpret_cast(src); + } + virtual void* get_value(void** src) CV_OVERRIDE { return *src; } + virtual const void* get_value(void* const * src) CV_OVERRIDE { return *src; } + virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast(*src); } +}; + +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << int(*reinterpret_cast(*src)); +} + +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << int(*reinterpret_cast(*src)); +} + +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << (*reinterpret_cast(*src)).c_str(); +} + +template +struct choose_policy +{ + typedef big_any_policy type; +}; + +template +struct choose_policy +{ + typedef small_any_policy type; +}; + +struct any; + +/// Choosing the policy for an any type is illegal, but should never happen. +/// This is designed to throw a compiler error. +template<> +struct choose_policy +{ + typedef void type; +}; + +/// Specializations for small types. +#define SMALL_POLICY(TYPE) \ + template<> \ + struct choose_policy { typedef small_any_policy type; \ + } + +SMALL_POLICY(signed char); +SMALL_POLICY(unsigned char); +SMALL_POLICY(signed short); +SMALL_POLICY(unsigned short); +SMALL_POLICY(signed int); +SMALL_POLICY(unsigned int); +SMALL_POLICY(signed long); +SMALL_POLICY(unsigned long); +SMALL_POLICY(float); +SMALL_POLICY(bool); + +#undef SMALL_POLICY + +template +class SinglePolicy +{ + SinglePolicy(); + SinglePolicy(const SinglePolicy& other); + SinglePolicy& operator=(const SinglePolicy& other); + +public: + static base_any_policy* get_policy(); +}; + +/// This function will return a different policy for each type. +template +inline base_any_policy* SinglePolicy::get_policy() +{ + static typename choose_policy::type policy; + return &policy; +} + +} // namespace anyimpl + +struct any +{ +private: + // fields + anyimpl::base_any_policy* policy; + void* object; + +public: + /// Initializing constructor. + template + any(const T& x) + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { + assign(x); + } + + /// Empty constructor. + any() + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { } + + /// Special initializing constructor for string literals. + any(const char* x) + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { + assign(x); + } + + /// Copy constructor. + any(const any& x) + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { + assign(x); + } + + /// Destructor. + ~any() + { + policy->static_delete(&object); + } + + /// Assignment function from another any. + any& assign(const any& x) + { + reset(); + policy = x.policy; + policy->clone(&x.object, &object); + return *this; + } + + /// Assignment function. + template + any& assign(const T& x) + { + reset(); + policy = anyimpl::SinglePolicy::get_policy(); + policy->copy_from_value(&x, &object); + return *this; + } + + /// Assignment operator. + template + any& operator=(const T& x) + { + return assign(x); + } + + /// Assignment operator. Template-based version above doesn't work as expected. We need regular assignment operator here. + any& operator=(const any& x) + { + return assign(x); + } + + /// Assignment operator, specialed for literal strings. + /// They have types like const char [6] which don't work as expected. + any& operator=(const char* x) + { + return assign(x); + } + + /// Utility functions + any& swap(any& x) + { + std::swap(policy, x.policy); + std::swap(object, x.object); + return *this; + } + + /// Cast operator. You can only cast to the original type. + template + T& cast() + { + if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); + T* r = reinterpret_cast(policy->get_value(&object)); + return *r; + } + + /// Cast operator. You can only cast to the original type. + template + const T& cast() const + { + if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); + const T* r = reinterpret_cast(policy->get_value(&object)); + return *r; + } + + /// Returns true if the any contains no value. + bool empty() const + { + return policy->type() == typeid(anyimpl::empty_any); + } + + /// Frees any allocated memory, and sets the value to NULL. + void reset() + { + policy->static_delete(&object); + policy = anyimpl::SinglePolicy::get_policy(); + } + + /// Returns true if the two types are the same. + bool compatible(const any& x) const + { + return policy->type() == x.policy->type(); + } + + /// Returns if the type is compatible with the policy + template + bool has_type() + { + return policy->type() == typeid(T); + } + + const std::type_info& type() const + { + return policy->type(); + } + + friend std::ostream& operator <<(std::ostream& out, const any& any_val); +}; + +inline std::ostream& operator <<(std::ostream& out, const any& any_val) +{ + any_val.policy->print(out,&any_val.object); + return out; +} + +} + +//! @endcond + +#endif // OPENCV_FLANN_ANY_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/autotuned_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/autotuned_index.h new file mode 100644 index 0000000..d90f739 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/autotuned_index.h @@ -0,0 +1,594 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_AUTOTUNED_INDEX_H_ +#define OPENCV_FLANN_AUTOTUNED_INDEX_H_ + +//! @cond IGNORED + +#include + +#include "nn_index.h" +#include "ground_truth.h" +#include "index_testing.h" +#include "sampling.h" +#include "kdtree_index.h" +#include "kdtree_single_index.h" +#include "kmeans_index.h" +#include "composite_index.h" +#include "linear_index.h" +#include "logger.h" + +namespace cvflann +{ + +template +NNIndex* create_index_by_type(const Matrix& dataset, const IndexParams& params, const Distance& distance); + + +struct AutotunedIndexParams : public IndexParams +{ + AutotunedIndexParams(float target_precision = 0.8, float build_weight = 0.01, float memory_weight = 0, float sample_fraction = 0.1) + { + (*this)["algorithm"] = FLANN_INDEX_AUTOTUNED; + // precision desired (used for autotuning, -1 otherwise) + (*this)["target_precision"] = target_precision; + // build tree time weighting factor + (*this)["build_weight"] = build_weight; + // index memory weighting factor + (*this)["memory_weight"] = memory_weight; + // what fraction of the dataset to use for autotuning + (*this)["sample_fraction"] = sample_fraction; + } +}; + + +template +class AutotunedIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + AutotunedIndex(const Matrix& inputData, const IndexParams& params = AutotunedIndexParams(), Distance d = Distance()) : + dataset_(inputData), distance_(d) + { + target_precision_ = get_param(params, "target_precision",0.8f); + build_weight_ = get_param(params,"build_weight", 0.01f); + memory_weight_ = get_param(params, "memory_weight", 0.0f); + sample_fraction_ = get_param(params,"sample_fraction", 0.1f); + bestIndex_ = NULL; + speedup_ = 0; + } + + AutotunedIndex(const AutotunedIndex&); + AutotunedIndex& operator=(const AutotunedIndex&); + + virtual ~AutotunedIndex() + { + if (bestIndex_ != NULL) { + delete bestIndex_; + bestIndex_ = NULL; + } + } + + /** + * Method responsible with building the index. + */ + virtual void buildIndex() CV_OVERRIDE + { + std::ostringstream stream; + bestParams_ = estimateBuildParams(); + print_params(bestParams_, stream); + Logger::info("----------------------------------------------------\n"); + Logger::info("Autotuned parameters:\n"); + Logger::info("%s", stream.str().c_str()); + Logger::info("----------------------------------------------------\n"); + + bestIndex_ = create_index_by_type(dataset_, bestParams_, distance_); + bestIndex_->buildIndex(); + speedup_ = estimateSearchParams(bestSearchParams_); + stream.str(std::string()); + print_params(bestSearchParams_, stream); + Logger::info("----------------------------------------------------\n"); + Logger::info("Search parameters:\n"); + Logger::info("%s", stream.str().c_str()); + Logger::info("----------------------------------------------------\n"); + } + + /** + * Saves the index to a stream + */ + virtual void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, (int)bestIndex_->getType()); + bestIndex_->saveIndex(stream); + save_value(stream, get_param(bestSearchParams_, "checks")); + } + + /** + * Loads the index from a stream + */ + virtual void loadIndex(FILE* stream) CV_OVERRIDE + { + int index_type; + + load_value(stream, index_type); + IndexParams params; + params["algorithm"] = (flann_algorithm_t)index_type; + bestIndex_ = create_index_by_type(dataset_, params, distance_); + bestIndex_->loadIndex(stream); + int checks; + load_value(stream, checks); + bestSearchParams_["checks"] = checks; + } + + /** + * Method that searches for nearest-neighbors + */ + virtual void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + int checks = get_param(searchParams,"checks",FLANN_CHECKS_AUTOTUNED); + if (checks == FLANN_CHECKS_AUTOTUNED) { + bestIndex_->findNeighbors(result, vec, bestSearchParams_); + } + else { + bestIndex_->findNeighbors(result, vec, searchParams); + } + } + + + IndexParams getParameters() const CV_OVERRIDE + { + return bestIndex_->getParameters(); + } + + SearchParams getSearchParameters() const + { + return bestSearchParams_; + } + + float getSpeedup() const + { + return speedup_; + } + + + /** + * Number of features in this index. + */ + virtual size_t size() const CV_OVERRIDE + { + return bestIndex_->size(); + } + + /** + * The length of each vector in this index. + */ + virtual size_t veclen() const CV_OVERRIDE + { + return bestIndex_->veclen(); + } + + /** + * The amount of memory (in bytes) this index uses. + */ + virtual int usedMemory() const CV_OVERRIDE + { + return bestIndex_->usedMemory(); + } + + /** + * Algorithm name + */ + virtual flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_AUTOTUNED; + } + +private: + + struct CostData + { + float searchTimeCost; + float buildTimeCost; + float memoryCost; + float totalCost; + IndexParams params; + }; + + void evaluate_kmeans(CostData& cost) + { + StartStopTimer t; + int checks; + const int nn = 1; + + Logger::info("KMeansTree using params: max_iterations=%d, branching=%d\n", + get_param(cost.params,"iterations"), + get_param(cost.params,"branching")); + KMeansIndex kmeans(sampledDataset_, cost.params, distance_); + // measure index build time + t.start(); + kmeans.buildIndex(); + t.stop(); + float buildTime = (float)t.value; + + // measure search time + float searchTime = test_index_precision(kmeans, sampledDataset_, testDataset_, gt_matches_, target_precision_, checks, distance_, nn); + + float datasetMemory = float(sampledDataset_.rows * sampledDataset_.cols * sizeof(float)); + cost.memoryCost = (kmeans.usedMemory() + datasetMemory) / datasetMemory; + cost.searchTimeCost = searchTime; + cost.buildTimeCost = buildTime; + Logger::info("KMeansTree buildTime=%g, searchTime=%g, build_weight=%g\n", buildTime, searchTime, build_weight_); + } + + + void evaluate_kdtree(CostData& cost) + { + StartStopTimer t; + int checks; + const int nn = 1; + + Logger::info("KDTree using params: trees=%d\n", get_param(cost.params,"trees")); + KDTreeIndex kdtree(sampledDataset_, cost.params, distance_); + + t.start(); + kdtree.buildIndex(); + t.stop(); + float buildTime = (float)t.value; + + //measure search time + float searchTime = test_index_precision(kdtree, sampledDataset_, testDataset_, gt_matches_, target_precision_, checks, distance_, nn); + + float datasetMemory = float(sampledDataset_.rows * sampledDataset_.cols * sizeof(float)); + cost.memoryCost = (kdtree.usedMemory() + datasetMemory) / datasetMemory; + cost.searchTimeCost = searchTime; + cost.buildTimeCost = buildTime; + Logger::info("KDTree buildTime=%g, searchTime=%g\n", buildTime, searchTime); + } + + + // struct KMeansSimpleDownhillFunctor { + // + // Autotune& autotuner; + // KMeansSimpleDownhillFunctor(Autotune& autotuner_) : autotuner(autotuner_) {} + // + // float operator()(int* params) { + // + // float maxFloat = numeric_limits::max(); + // + // if (params[0]<2) return maxFloat; + // if (params[1]<0) return maxFloat; + // + // CostData c; + // c.params["algorithm"] = KMEANS; + // c.params["centers-init"] = CENTERS_RANDOM; + // c.params["branching"] = params[0]; + // c.params["max-iterations"] = params[1]; + // + // autotuner.evaluate_kmeans(c); + // + // return c.timeCost; + // + // } + // }; + // + // struct KDTreeSimpleDownhillFunctor { + // + // Autotune& autotuner; + // KDTreeSimpleDownhillFunctor(Autotune& autotuner_) : autotuner(autotuner_) {} + // + // float operator()(int* params) { + // float maxFloat = numeric_limits::max(); + // + // if (params[0]<1) return maxFloat; + // + // CostData c; + // c.params["algorithm"] = KDTREE; + // c.params["trees"] = params[0]; + // + // autotuner.evaluate_kdtree(c); + // + // return c.timeCost; + // + // } + // }; + + + + void optimizeKMeans(std::vector& costs) + { + Logger::info("KMEANS, Step 1: Exploring parameter space\n"); + + // explore kmeans parameters space using combinations of the parameters below + int maxIterations[] = { 1, 5, 10, 15 }; + int branchingFactors[] = { 16, 32, 64, 128, 256 }; + + int kmeansParamSpaceSize = FLANN_ARRAY_LEN(maxIterations) * FLANN_ARRAY_LEN(branchingFactors); + costs.reserve(costs.size() + kmeansParamSpaceSize); + + // evaluate kmeans for all parameter combinations + for (size_t i = 0; i < FLANN_ARRAY_LEN(maxIterations); ++i) { + for (size_t j = 0; j < FLANN_ARRAY_LEN(branchingFactors); ++j) { + CostData cost; + cost.params["algorithm"] = FLANN_INDEX_KMEANS; + cost.params["centers_init"] = FLANN_CENTERS_RANDOM; + cost.params["iterations"] = maxIterations[i]; + cost.params["branching"] = branchingFactors[j]; + + evaluate_kmeans(cost); + costs.push_back(cost); + } + } + + // Logger::info("KMEANS, Step 2: simplex-downhill optimization\n"); + // + // const int n = 2; + // // choose initial simplex points as the best parameters so far + // int kmeansNMPoints[n*(n+1)]; + // float kmeansVals[n+1]; + // for (int i=0;i& costs) + { + Logger::info("KD-TREE, Step 1: Exploring parameter space\n"); + + // explore kd-tree parameters space using the parameters below + int testTrees[] = { 1, 4, 8, 16, 32 }; + + // evaluate kdtree for all parameter combinations + for (size_t i = 0; i < FLANN_ARRAY_LEN(testTrees); ++i) { + CostData cost; + cost.params["algorithm"] = FLANN_INDEX_KDTREE; + cost.params["trees"] = testTrees[i]; + + evaluate_kdtree(cost); + costs.push_back(cost); + } + + // Logger::info("KD-TREE, Step 2: simplex-downhill optimization\n"); + // + // const int n = 1; + // // choose initial simplex points as the best parameters so far + // int kdtreeNMPoints[n*(n+1)]; + // float kdtreeVals[n+1]; + // for (int i=0;i costs; + + int sampleSize = int(sample_fraction_ * dataset_.rows); + int testSampleSize = std::min(sampleSize / 10, 1000); + + Logger::info("Entering autotuning, dataset size: %d, sampleSize: %d, testSampleSize: %d, target precision: %g\n", dataset_.rows, sampleSize, testSampleSize, target_precision_); + + // For a very small dataset, it makes no sense to build any fancy index, just + // use linear search + if (testSampleSize < 10) { + Logger::info("Choosing linear, dataset too small\n"); + return LinearIndexParams(); + } + + // We use a fraction of the original dataset to speedup the autotune algorithm + sampledDataset_ = random_sample(dataset_, sampleSize); + // We use a cross-validation approach, first we sample a testset from the dataset + testDataset_ = random_sample(sampledDataset_, testSampleSize, true); + + // We compute the ground truth using linear search + Logger::info("Computing ground truth... \n"); + gt_matches_ = Matrix(new int[testDataset_.rows], testDataset_.rows, 1); + StartStopTimer t; + t.start(); + compute_ground_truth(sampledDataset_, testDataset_, gt_matches_, 0, distance_); + t.stop(); + + CostData linear_cost; + linear_cost.searchTimeCost = (float)t.value; + linear_cost.buildTimeCost = 0; + linear_cost.memoryCost = 0; + linear_cost.params["algorithm"] = FLANN_INDEX_LINEAR; + + costs.push_back(linear_cost); + + // Start parameter autotune process + Logger::info("Autotuning parameters...\n"); + + optimizeKMeans(costs); + optimizeKDTree(costs); + + float bestTimeCost = costs[0].searchTimeCost; + for (size_t i = 0; i < costs.size(); ++i) { + float timeCost = costs[i].buildTimeCost * build_weight_ + costs[i].searchTimeCost; + if (timeCost < bestTimeCost) { + bestTimeCost = timeCost; + } + } + + float bestCost = costs[0].searchTimeCost / bestTimeCost; + IndexParams bestParams = costs[0].params; + if (bestTimeCost > 0) { + for (size_t i = 0; i < costs.size(); ++i) { + float crtCost = (costs[i].buildTimeCost * build_weight_ + costs[i].searchTimeCost) / bestTimeCost + + memory_weight_ * costs[i].memoryCost; + if (crtCost < bestCost) { + bestCost = crtCost; + bestParams = costs[i].params; + } + } + } + + delete[] gt_matches_.data; + delete[] testDataset_.data; + delete[] sampledDataset_.data; + + return bestParams; + } + + + + /** + * Estimates the search time parameters needed to get the desired precision. + * Precondition: the index is built + * Postcondition: the searchParams will have the optimum params set, also the speedup obtained over linear search. + */ + float estimateSearchParams(SearchParams& searchParams) + { + const int nn = 1; + const size_t SAMPLE_COUNT = 1000; + + CV_Assert(bestIndex_ != NULL && "Requires a valid index"); // must have a valid index + + float speedup = 0; + + int samples = (int)std::min(dataset_.rows / 10, SAMPLE_COUNT); + if (samples > 0) { + Matrix testDataset = random_sample(dataset_, samples); + + Logger::info("Computing ground truth\n"); + + // we need to compute the ground truth first + Matrix gt_matches(new int[testDataset.rows], testDataset.rows, 1); + StartStopTimer t; + t.start(); + compute_ground_truth(dataset_, testDataset, gt_matches, 1, distance_); + t.stop(); + float linear = (float)t.value; + + int checks; + Logger::info("Estimating number of checks\n"); + + float searchTime; + float cb_index; + if (bestIndex_->getType() == FLANN_INDEX_KMEANS) { + Logger::info("KMeans algorithm, estimating cluster border factor\n"); + KMeansIndex* kmeans = (KMeansIndex*)bestIndex_; + float bestSearchTime = -1; + float best_cb_index = -1; + int best_checks = -1; + for (cb_index = 0; cb_index < 1.1f; cb_index += 0.2f) { + kmeans->set_cb_index(cb_index); + searchTime = test_index_precision(*kmeans, dataset_, testDataset, gt_matches, target_precision_, checks, distance_, nn, 1); + if ((searchTime < bestSearchTime) || (bestSearchTime == -1)) { + bestSearchTime = searchTime; + best_cb_index = cb_index; + best_checks = checks; + } + } + searchTime = bestSearchTime; + cb_index = best_cb_index; + checks = best_checks; + + kmeans->set_cb_index(best_cb_index); + Logger::info("Optimum cb_index: %g\n", cb_index); + bestParams_["cb_index"] = cb_index; + } + else { + searchTime = test_index_precision(*bestIndex_, dataset_, testDataset, gt_matches, target_precision_, checks, distance_, nn, 1); + } + + Logger::info("Required number of checks: %d \n", checks); + searchParams["checks"] = checks; + + speedup = linear / searchTime; + + delete[] gt_matches.data; + delete[] testDataset.data; + } + + return speedup; + } + +private: + NNIndex* bestIndex_; + + IndexParams bestParams_; + SearchParams bestSearchParams_; + + Matrix sampledDataset_; + Matrix testDataset_; + Matrix gt_matches_; + + float speedup_; + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + /** + * Index parameters + */ + float target_precision_; + float build_weight_; + float memory_weight_; + float sample_fraction_; + + Distance distance_; + + +}; +} + +//! @endcond + +#endif /* OPENCV_FLANN_AUTOTUNED_INDEX_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/composite_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/composite_index.h new file mode 100644 index 0000000..f1af41a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/composite_index.h @@ -0,0 +1,197 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_COMPOSITE_INDEX_H_ +#define OPENCV_FLANN_COMPOSITE_INDEX_H_ + +//! @cond IGNORED + +#include "nn_index.h" +#include "kdtree_index.h" +#include "kmeans_index.h" + +namespace cvflann +{ + +/** + * Index parameters for the CompositeIndex. + */ +struct CompositeIndexParams : public IndexParams +{ + CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11, + flann_centers_init_t centers_init = FLANN_CENTERS_RANDOM, float cb_index = 0.2 ) + { + (*this)["algorithm"] = FLANN_INDEX_KMEANS; + // number of randomized trees to use (for kdtree) + (*this)["trees"] = trees; + // branching factor + (*this)["branching"] = branching; + // max iterations to perform in one kmeans clustering (kmeans tree) + (*this)["iterations"] = iterations; + // algorithm used for picking the initial cluster centers for kmeans tree + (*this)["centers_init"] = centers_init; + // cluster boundary index. Used when searching the kmeans tree + (*this)["cb_index"] = cb_index; + } +}; + + +/** + * This index builds a kd-tree index and a k-means index and performs nearest + * neighbour search both indexes. This gives a slight boost in search performance + * as some of the neighbours that are missed by one index are found by the other. + */ +template +class CompositeIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + /** + * Index constructor + * @param inputData dataset containing the points to index + * @param params Index parameters + * @param d Distance functor + * @return + */ + CompositeIndex(const Matrix& inputData, const IndexParams& params = CompositeIndexParams(), + Distance d = Distance()) : index_params_(params) + { + kdtree_index_ = new KDTreeIndex(inputData, params, d); + kmeans_index_ = new KMeansIndex(inputData, params, d); + + } + + CompositeIndex(const CompositeIndex&); + CompositeIndex& operator=(const CompositeIndex&); + + virtual ~CompositeIndex() + { + delete kdtree_index_; + delete kmeans_index_; + } + + /** + * @return The index type + */ + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_COMPOSITE; + } + + /** + * @return Size of the index + */ + size_t size() const CV_OVERRIDE + { + return kdtree_index_->size(); + } + + /** + * \returns The dimensionality of the features in this index. + */ + size_t veclen() const CV_OVERRIDE + { + return kdtree_index_->veclen(); + } + + /** + * \returns The amount of memory (in bytes) used by the index. + */ + int usedMemory() const CV_OVERRIDE + { + return kmeans_index_->usedMemory() + kdtree_index_->usedMemory(); + } + + /** + * \brief Builds the index + */ + void buildIndex() CV_OVERRIDE + { + Logger::info("Building kmeans tree...\n"); + kmeans_index_->buildIndex(); + Logger::info("Building kdtree tree...\n"); + kdtree_index_->buildIndex(); + } + + /** + * \brief Saves the index to a stream + * \param stream The stream to save the index to + */ + void saveIndex(FILE* stream) CV_OVERRIDE + { + kmeans_index_->saveIndex(stream); + kdtree_index_->saveIndex(stream); + } + + /** + * \brief Loads the index from a stream + * \param stream The stream from which the index is loaded + */ + void loadIndex(FILE* stream) CV_OVERRIDE + { + kmeans_index_->loadIndex(stream); + kdtree_index_->loadIndex(stream); + } + + /** + * \returns The index parameters + */ + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + + /** + * \brief Method that searches for nearest-neighbours + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + kmeans_index_->findNeighbors(result, vec, searchParams); + kdtree_index_->findNeighbors(result, vec, searchParams); + } + +private: + /** The k-means index */ + KMeansIndex* kmeans_index_; + + /** The kd-tree index */ + KDTreeIndex* kdtree_index_; + + /** The index parameters */ + const IndexParams index_params_; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_COMPOSITE_INDEX_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/config.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/config.h new file mode 100644 index 0000000..c9342c0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/config.h @@ -0,0 +1,42 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_CONFIG_H_ +#define OPENCV_FLANN_CONFIG_H_ + +//! @cond IGNORED + +#ifdef FLANN_VERSION_ +#undef FLANN_VERSION_ +#endif +#define FLANN_VERSION_ "1.6.10" + +//! @endcond + +#endif /* OPENCV_FLANN_CONFIG_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/defines.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/defines.h new file mode 100644 index 0000000..8ab8329 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/defines.h @@ -0,0 +1,169 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_DEFINES_H_ +#define OPENCV_FLANN_DEFINES_H_ + +//! @cond IGNORED + +#include "config.h" + +#ifdef FLANN_EXPORT +#undef FLANN_EXPORT +#endif +#ifdef _WIN32 +/* win32 dll export/import directives */ + #ifdef FLANN_EXPORTS + #define FLANN_EXPORT __declspec(dllexport) + #elif defined(FLANN_STATIC) + #define FLANN_EXPORT + #else + #define FLANN_EXPORT __declspec(dllimport) + #endif +#else +/* unix needs nothing */ + #define FLANN_EXPORT +#endif + + +#undef FLANN_PLATFORM_32_BIT +#undef FLANN_PLATFORM_64_BIT +#if defined __amd64__ || defined __x86_64__ || defined _WIN64 || defined _M_X64 +#define FLANN_PLATFORM_64_BIT +#else +#define FLANN_PLATFORM_32_BIT +#endif + + +#undef FLANN_ARRAY_LEN +#define FLANN_ARRAY_LEN(a) (sizeof(a)/sizeof(a[0])) + +namespace cvflann { + +/* Nearest neighbour index algorithms */ +enum flann_algorithm_t +{ + FLANN_INDEX_LINEAR = 0, + FLANN_INDEX_KDTREE = 1, + FLANN_INDEX_KMEANS = 2, + FLANN_INDEX_COMPOSITE = 3, + FLANN_INDEX_KDTREE_SINGLE = 4, + FLANN_INDEX_HIERARCHICAL = 5, + FLANN_INDEX_LSH = 6, + FLANN_INDEX_SAVED = 254, + FLANN_INDEX_AUTOTUNED = 255, + + // deprecated constants, should use the FLANN_INDEX_* ones instead + LINEAR = 0, + KDTREE = 1, + KMEANS = 2, + COMPOSITE = 3, + KDTREE_SINGLE = 4, + SAVED = 254, + AUTOTUNED = 255 +}; + + + +enum flann_centers_init_t +{ + FLANN_CENTERS_RANDOM = 0, + FLANN_CENTERS_GONZALES = 1, + FLANN_CENTERS_KMEANSPP = 2, + FLANN_CENTERS_GROUPWISE = 3, + + // deprecated constants, should use the FLANN_CENTERS_* ones instead + CENTERS_RANDOM = 0, + CENTERS_GONZALES = 1, + CENTERS_KMEANSPP = 2 +}; + +enum flann_log_level_t +{ + FLANN_LOG_NONE = 0, + FLANN_LOG_FATAL = 1, + FLANN_LOG_ERROR = 2, + FLANN_LOG_WARN = 3, + FLANN_LOG_INFO = 4 +}; + +enum flann_distance_t +{ + FLANN_DIST_EUCLIDEAN = 1, + FLANN_DIST_L2 = 1, + FLANN_DIST_MANHATTAN = 2, + FLANN_DIST_L1 = 2, + FLANN_DIST_MINKOWSKI = 3, + FLANN_DIST_MAX = 4, + FLANN_DIST_HIST_INTERSECT = 5, + FLANN_DIST_HELLINGER = 6, + FLANN_DIST_CHI_SQUARE = 7, + FLANN_DIST_CS = 7, + FLANN_DIST_KULLBACK_LEIBLER = 8, + FLANN_DIST_KL = 8, + FLANN_DIST_HAMMING = 9, + FLANN_DIST_DNAMMING = 10, + + // deprecated constants, should use the FLANN_DIST_* ones instead + EUCLIDEAN = 1, + MANHATTAN = 2, + MINKOWSKI = 3, + MAX_DIST = 4, + HIST_INTERSECT = 5, + HELLINGER = 6, + CS = 7, + KL = 8, + KULLBACK_LEIBLER = 8 +}; + +enum flann_datatype_t +{ + FLANN_INT8 = 0, + FLANN_INT16 = 1, + FLANN_INT32 = 2, + FLANN_INT64 = 3, + FLANN_UINT8 = 4, + FLANN_UINT16 = 5, + FLANN_UINT32 = 6, + FLANN_UINT64 = 7, + FLANN_FLOAT32 = 8, + FLANN_FLOAT64 = 9 +}; + +enum +{ + FLANN_CHECKS_UNLIMITED = -1, + FLANN_CHECKS_AUTOTUNED = -2 +}; + +} + +//! @endcond + +#endif /* OPENCV_FLANN_DEFINES_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/dist.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/dist.h new file mode 100644 index 0000000..608f8a5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/dist.h @@ -0,0 +1,1292 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_DIST_H_ +#define OPENCV_FLANN_DIST_H_ + +//! @cond IGNORED + +#include +#include +#include +#ifdef _MSC_VER +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +#include "defines.h" + +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) +# include +#endif + +#if defined(__ARM_NEON__) && !defined(__CUDACC__) +# include "arm_neon.h" +#endif + +namespace cvflann +{ + +template +inline T abs(T x) { return (x<0) ? -x : x; } + +template<> +inline int abs(int x) { return ::abs(x); } + +template<> +inline float abs(float x) { return fabsf(x); } + +template<> +inline double abs(double x) { return fabs(x); } + + +template +inline TargetType round(float x) { return static_cast(x); } + +template<> +inline unsigned int round(float x) { return static_cast(x + 0.5f); } + +template<> +inline unsigned short round(float x) { return static_cast(x + 0.5f); } + +template<> +inline unsigned char round(float x) { return static_cast(x + 0.5f); } + +template<> +inline long long round(float x) { return static_cast(x + 0.5f); } + +template<> +inline long round(float x) { return static_cast(x + 0.5f); } + +template<> +inline int round(float x) { return static_cast(x + 0.5f) - (x<0); } + +template<> +inline short round(float x) { return static_cast(x + 0.5f) - (x<0); } + +template<> +inline char round(float x) { return static_cast(x + 0.5f) - (x<0); } + + +template +inline TargetType round(double x) { return static_cast(x); } + +template<> +inline unsigned int round(double x) { return static_cast(x + 0.5); } + +template<> +inline unsigned short round(double x) { return static_cast(x + 0.5); } + +template<> +inline unsigned char round(double x) { return static_cast(x + 0.5); } + +template<> +inline long long round(double x) { return static_cast(x + 0.5); } + +template<> +inline long round(double x) { return static_cast(x + 0.5); } + +template<> +inline int round(double x) { return static_cast(x + 0.5) - (x<0); } + +template<> +inline short round(double x) { return static_cast(x + 0.5) - (x<0); } + +template<> +inline char round(double x) { return static_cast(x + 0.5) - (x<0); } + + +template +struct Accumulator { typedef T Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; + +#undef True +#undef False + +class True +{ +public: + static const bool val = true; +}; + +class False +{ +public: + static const bool val = false; +}; + + +/* + * This is a "zero iterator". It basically behaves like a zero filled + * array to all algorithms that use arrays as iterators (STL style). + * It's useful when there's a need to compute the distance between feature + * and origin it and allows for better compiler optimisation than using a + * zero-filled array. + */ +template +struct ZeroIterator +{ + + T operator*() + { + return 0; + } + + T operator[](int) + { + return 0; + } + + const ZeroIterator& operator ++() + { + return *this; + } + + ZeroIterator operator ++(int) + { + return *this; + } + + ZeroIterator& operator+=(int) + { + return *this; + } + +}; + + + +/** + * Squared Euclidean distance functor. + * + * This is the simpler, unrolled version. This is preferable for + * very low dimensionality data (eg 3D points) + */ +template +struct L2_Simple +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + ResultType result = ResultType(); + ResultType diff; + for(size_t i = 0; i < size; ++i ) { + diff = (ResultType)(*a++ - *b++); + result += diff*diff; + } + return result; + } + + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return (a-b)*(a-b); + } +}; + + + +/** + * Squared Euclidean distance functor, optimized version + */ +template +struct L2 +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the squared Euclidean distance between two vectors. + * + * This is highly optimised, with loop unrolling, as it is one + * of the most expensive inner loops. + * + * The computation of squared root at the end is omitted for + * efficiency. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = (ResultType)(a[0] - b[0]); + diff1 = (ResultType)(a[1] - b[1]); + diff2 = (ResultType)(a[2] - b[2]); + diff3 = (ResultType)(a[3] - b[3]); + result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3; + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = (ResultType)(*a++ - *b++); + result += diff0 * diff0; + } + return result; + } + + /** + * Partial euclidean distance, using just one dimension. This is used by the + * kd-tree when computing partial distances while traversing the tree. + * + * Squared root is omitted for efficiency. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return (a-b)*(a-b); + } +}; + + +/* + * Manhattan distance functor, optimized version + */ +template +struct L1 +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the Manhattan (L_1) distance between two vectors. + * + * This is highly optimised, with loop unrolling, as it is one + * of the most expensive inner loops. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = (ResultType)abs(a[0] - b[0]); + diff1 = (ResultType)abs(a[1] - b[1]); + diff2 = (ResultType)abs(a[2] - b[2]); + diff3 = (ResultType)abs(a[3] - b[3]); + result += diff0 + diff1 + diff2 + diff3; + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = (ResultType)abs(*a++ - *b++); + result += diff0; + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return abs(a-b); + } +}; + + + +template +struct MinkowskiDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + int order; + + MinkowskiDistance(int order_) : order(order_) {} + + /** + * Compute the Minkowsky (L_p) distance between two vectors. + * + * This is highly optimised, with loop unrolling, as it is one + * of the most expensive inner loops. + * + * The computation of squared root at the end is omitted for + * efficiency. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = (ResultType)abs(a[0] - b[0]); + diff1 = (ResultType)abs(a[1] - b[1]); + diff2 = (ResultType)abs(a[2] - b[2]); + diff3 = (ResultType)abs(a[3] - b[3]); + result += pow(diff0,order) + pow(diff1,order) + pow(diff2,order) + pow(diff3,order); + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = (ResultType)abs(*a++ - *b++); + result += pow(diff0,order); + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return pow(static_cast(abs(a-b)),order); + } +}; + + + +template +struct MaxDistance +{ + typedef False is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the max distance (L_infinity) between two vectors. + * + * This distance is not a valid kdtree distance, it's not dimensionwise additive. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = abs(a[0] - b[0]); + diff1 = abs(a[1] - b[1]); + diff2 = abs(a[2] - b[2]); + diff3 = abs(a[3] - b[3]); + if (diff0>result) {result = diff0; } + if (diff1>result) {result = diff1; } + if (diff2>result) {result = diff2; } + if (diff3>result) {result = diff3; } + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = abs(*a++ - *b++); + result = (diff0>result) ? diff0 : result; + } + return result; + } + + /* This distance functor is not dimension-wise additive, which + * makes it an invalid kd-tree distance, not implementing the accum_dist method */ + +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor + * bit count of A exclusive XOR'ed with B + */ +struct HammingLUT +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef unsigned char ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** this will count the bits in a ^ b + */ + template + ResultType operator()(const unsigned char* a, const Iterator2 b, size_t size) const + { + static const uchar popCountTable[] = + { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 + }; + ResultType result = 0; + const unsigned char* b2 = reinterpret_cast (b); + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i] ^ b2[i]]; + } + return result; + } + + + ResultType operator()(const unsigned char* a, const ZeroIterator b, size_t size) const + { + (void)b; + static const uchar popCountTable[] = + { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 + }; + ResultType result = 0; + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i]]; + } + return result; + } +}; + +/** + * Hamming distance functor (pop count between two binary vectors, i.e. xor them and count the number of bits set) + * That code was taken from brief.cpp in OpenCV + */ +template +struct Hamming +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + + typedef T ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + template + ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + ResultType result = 0; +#if defined(__ARM_NEON__) && !defined(__CUDACC__) + { + const unsigned char* a2 = reinterpret_cast (a); + const unsigned char* b2 = reinterpret_cast (b); + uint32x4_t bits = vmovq_n_u32(0); + for (size_t i = 0; i < size; i += 16) { + uint8x16_t A_vec = vld1q_u8 (a2 + i); + uint8x16_t B_vec = vld1q_u8 (b2 + i); + uint8x16_t AxorB = veorq_u8 (A_vec, B_vec); + uint8x16_t bitsSet = vcntq_u8 (AxorB); + uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet); + uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8); + bits = vaddq_u32(bits, bitSet4); + } + uint64x2_t bitSet2 = vpaddlq_u32 (bits); + result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0); + result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2); + } +#elif defined(__GNUC__) + { + //for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll) + typedef unsigned long long pop_t; + const size_t modulo = size % sizeof(pop_t); + const pop_t* a2 = reinterpret_cast (a); + const pop_t* b2 = reinterpret_cast (b); + const pop_t* a2_end = a2 + (size / sizeof(pop_t)); + + for (; a2 != a2_end; ++a2, ++b2) result += __builtin_popcountll((*a2) ^ (*b2)); + + if (modulo) { + //in the case where size is not dividable by sizeof(size_t) + //need to mask off the bits at the end + pop_t a_final = 0, b_final = 0; + memcpy(&a_final, a2, modulo); + memcpy(&b_final, b2, modulo); + result += __builtin_popcountll(a_final ^ b_final); + } + } +#else // NO NEON and NOT GNUC + HammingLUT lut; + result = lut(reinterpret_cast (a), + reinterpret_cast (b), size); +#endif + return result; + } + + + template + ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const + { + (void)b; + ResultType result = 0; +#if defined(__ARM_NEON__) && !defined(__CUDACC__) + { + const unsigned char* a2 = reinterpret_cast (a); + uint32x4_t bits = vmovq_n_u32(0); + for (size_t i = 0; i < size; i += 16) { + uint8x16_t A_vec = vld1q_u8 (a2 + i); + uint8x16_t bitsSet = vcntq_u8 (A_vec); + uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet); + uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8); + bits = vaddq_u32(bits, bitSet4); + } + uint64x2_t bitSet2 = vpaddlq_u32 (bits); + result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0); + result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2); + } +#elif defined(__GNUC__) + { + //for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll) + typedef unsigned long long pop_t; + const size_t modulo = size % sizeof(pop_t); + const pop_t* a2 = reinterpret_cast (a); + const pop_t* a2_end = a2 + (size / sizeof(pop_t)); + + for (; a2 != a2_end; ++a2) result += __builtin_popcountll(*a2); + + if (modulo) { + //in the case where size is not dividable by sizeof(size_t) + //need to mask off the bits at the end + pop_t a_final = 0; + memcpy(&a_final, a2, modulo); + result += __builtin_popcountll(a_final); + } + } +#else // NO NEON and NOT GNUC + HammingLUT lut; + result = lut(reinterpret_cast (a), b, size); +#endif + return result; + } +}; + +template +struct Hamming2 +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef T ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** This is popcount_3() from: + * http://en.wikipedia.org/wiki/Hamming_weight */ + unsigned int popcnt32(uint32_t n) const + { + n -= ((n >> 1) & 0x55555555); + n = (n & 0x33333333) + ((n >> 2) & 0x33333333); + return (((n + (n >> 4))& 0xF0F0F0F)* 0x1010101) >> 24; + } + +#ifdef FLANN_PLATFORM_64_BIT + unsigned int popcnt64(uint64_t n) const + { + n -= ((n >> 1) & 0x5555555555555555); + n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333); + return (((n + (n >> 4))& 0x0f0f0f0f0f0f0f0f)* 0x0101010101010101) >> 56; + } +#endif + + template + ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + const uint64_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa ^ *pb); + ++pa; + ++pb; + } +#else + const uint32_t* pa = reinterpret_cast(a); + const uint32_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa ^ *pb); + ++pa; + ++pb; + } +#endif + return result; + } + + + template + ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + + (void)b; +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa); + ++pa; + } +#else + const uint32_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa); + ++pa; + } +#endif + return result; + } + +private: +#ifdef FLANN_PLATFORM_64_BIT + static const size_t long_word_size_ = sizeof(uint64_t)/sizeof(unsigned char); +#else + static const size_t long_word_size_ = sizeof(uint32_t)/sizeof(unsigned char); +#endif +}; + + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +struct DNAmmingLUT +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef unsigned char ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** this will count the bits in a ^ b + */ + template + ResultType operator()(const unsigned char* a, const Iterator2 b, size_t size) const + { + static const uchar popCountTable[] = + { + 0, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4 + }; + ResultType result = 0; + const unsigned char* b2 = reinterpret_cast (b); + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i] ^ b2[i]]; + } + return result; + } + + + ResultType operator()(const unsigned char* a, const ZeroIterator b, size_t size) const + { + (void)b; + static const uchar popCountTable[] = + { + 0, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4 + }; + ResultType result = 0; + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i]]; + } + return result; + } +}; + + +template +struct DNAmming2 +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef T ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** This is popcount_3() from: + * http://en.wikipedia.org/wiki/Hamming_weight */ + unsigned int popcnt32(uint32_t n) const + { + n = ((n >> 1) | n) & 0x55555555; + n = (n & 0x33333333) + ((n >> 2) & 0x33333333); + return (((n + (n >> 4))& 0x0F0F0F0F)* 0x01010101) >> 24; + } + +#ifdef FLANN_PLATFORM_64_BIT + unsigned int popcnt64(uint64_t n) const + { + n = ((n >> 1) | n) & 0x5555555555555555; + n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333); + return (((n + (n >> 4))& 0x0f0f0f0f0f0f0f0f)* 0x0101010101010101) >> 56; + } +#endif + + template + ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + const uint64_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa ^ *pb); + ++pa; + ++pb; + } +#else + const uint32_t* pa = reinterpret_cast(a); + const uint32_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa ^ *pb); + ++pa; + ++pb; + } +#endif + return result; + } + + + template + ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + + (void)b; +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa); + ++pa; + } +#else + const uint32_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa); + ++pa; + } +#endif + return result; + } + +private: +#ifdef FLANN_PLATFORM_64_BIT + static const size_t long_word_size_= sizeof(uint64_t)/sizeof(unsigned char); +#else + static const size_t long_word_size_= sizeof(uint32_t)/sizeof(unsigned char); +#endif +}; + + + +template +struct HistIntersectionDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the histogram intersection distance + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType min0, min1, min2, min3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + min0 = (ResultType)(a[0] < b[0] ? a[0] : b[0]); + min1 = (ResultType)(a[1] < b[1] ? a[1] : b[1]); + min2 = (ResultType)(a[2] < b[2] ? a[2] : b[2]); + min3 = (ResultType)(a[3] < b[3] ? a[3] : b[3]); + result += min0 + min1 + min2 + min3; + a += 4; + b += 4; + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + min0 = (ResultType)(*a < *b ? *a : *b); + result += min0; + ++a; + ++b; + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return a +struct HellingerDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the Hellinger distance + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = sqrt(static_cast(a[0])) - sqrt(static_cast(b[0])); + diff1 = sqrt(static_cast(a[1])) - sqrt(static_cast(b[1])); + diff2 = sqrt(static_cast(a[2])) - sqrt(static_cast(b[2])); + diff3 = sqrt(static_cast(a[3])) - sqrt(static_cast(b[3])); + result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3; + a += 4; + b += 4; + } + while (a < last) { + diff0 = sqrt(static_cast(*a++)) - sqrt(static_cast(*b++)); + result += diff0 * diff0; + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + ResultType diff = sqrt(static_cast(a)) - sqrt(static_cast(b)); + return diff * diff; + } +}; + + +template +struct ChiSquareDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the chi-square distance + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType sum, diff; + Iterator1 last = a + size; + + while (a < last) { + sum = (ResultType)(*a + *b); + if (sum>0) { + diff = (ResultType)(*a - *b); + result += diff*diff/sum; + } + ++a; + ++b; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + ResultType result = ResultType(); + ResultType sum, diff; + + sum = (ResultType)(a+b); + if (sum>0) { + diff = (ResultType)(a-b); + result = diff*diff/sum; + } + return result; + } +}; + + +template +struct KL_Divergence +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the Kullback-Leibler divergence + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + Iterator1 last = a + size; + + while (a < last) { + if ( *a != 0 && *b != 0 ) { + ResultType ratio = (ResultType)(*a / *b); + if (ratio>0) { + result += *a * log(ratio); + } + } + ++a; + ++b; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + ResultType result = ResultType(); + if( a != 0 && b != 0 ) { + ResultType ratio = (ResultType)(a / b); + if (ratio>0) { + result = a * log(ratio); + } + } + return result; + } +}; + + +/* + * Depending on processed distances, some of them are already squared (e.g. L2) + * and some are not (e.g.Hamming). In KMeans++ for instance we want to be sure + * we are working on ^2 distances, thus following templates to ensure that. + */ +template +struct squareDistance +{ + typedef typename Distance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist*dist; } +}; + + +template +struct squareDistance, ElementType> +{ + typedef typename L2_Simple::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + +template +struct squareDistance, ElementType> +{ + typedef typename L2::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + + +template +struct squareDistance, ElementType> +{ + typedef typename MinkowskiDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + +template +struct squareDistance, ElementType> +{ + typedef typename HellingerDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + +template +struct squareDistance, ElementType> +{ + typedef typename ChiSquareDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + + +template +typename Distance::ResultType ensureSquareDistance( typename Distance::ResultType dist ) +{ + typedef typename Distance::ElementType ElementType; + + squareDistance dummy; + return dummy( dist ); +} + + +/* + * ...a template to tell the user if the distance he is working with is actually squared + */ + +template +struct isSquareDist +{ + bool operator()() { return false; } +}; + + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + + +template +bool isSquareDistance() +{ + typedef typename Distance::ElementType ElementType; + + isSquareDist dummy; + return dummy(); +} + +/* + * ...and a template to ensure the user that he will process the normal distance, + * and not squared distance, without losing processing time calling sqrt(ensureSquareDistance) + * that will result in doing actually sqrt(dist*dist) for L1 distance for instance. + */ +template +struct simpleDistance +{ + typedef typename Distance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + + +template +struct simpleDistance, ElementType> +{ + typedef typename L2_Simple::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + +template +struct simpleDistance, ElementType> +{ + typedef typename L2::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + + +template +struct simpleDistance, ElementType> +{ + typedef typename MinkowskiDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + +template +struct simpleDistance, ElementType> +{ + typedef typename HellingerDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + +template +struct simpleDistance, ElementType> +{ + typedef typename ChiSquareDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + + +template +typename Distance::ResultType ensureSimpleDistance( typename Distance::ResultType dist ) +{ + typedef typename Distance::ElementType ElementType; + + simpleDistance dummy; + return dummy( dist ); +} + +} + +//! @endcond + +#endif //OPENCV_FLANN_DIST_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/dummy.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/dummy.h new file mode 100644 index 0000000..c176f2e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/dummy.h @@ -0,0 +1,16 @@ + +#ifndef OPENCV_FLANN_DUMMY_H_ +#define OPENCV_FLANN_DUMMY_H_ + +//! @cond IGNORED + +namespace cvflann +{ + +CV_DEPRECATED inline void dummyfunc() {} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_DUMMY_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/dynamic_bitset.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/dynamic_bitset.h new file mode 100644 index 0000000..a00ce1b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/dynamic_bitset.h @@ -0,0 +1,163 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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. + *************************************************************************/ + +/*********************************************************************** + * Author: Vincent Rabaud + *************************************************************************/ + +#ifndef OPENCV_FLANN_DYNAMIC_BITSET_H_ +#define OPENCV_FLANN_DYNAMIC_BITSET_H_ + +//! @cond IGNORED + +#ifndef FLANN_USE_BOOST +# define FLANN_USE_BOOST 0 +#endif +//#define FLANN_USE_BOOST 1 +#if FLANN_USE_BOOST +#include +typedef boost::dynamic_bitset<> DynamicBitset; +#else + +#include + +#include "dist.h" + +namespace cvflann { + +/** Class re-implementing the boost version of it + * This helps not depending on boost, it also does not do the bound checks + * and has a way to reset a block for speed + */ +class DynamicBitset +{ +public: + /** default constructor + */ + DynamicBitset() : size_(0) + { + } + + /** only constructor we use in our code + * @param sz the size of the bitset (in bits) + */ + DynamicBitset(size_t sz) + { + resize(sz); + reset(); + } + + /** Sets all the bits to 0 + */ + void clear() + { + std::fill(bitset_.begin(), bitset_.end(), 0); + } + + /** @brief checks if the bitset is empty + * @return true if the bitset is empty + */ + bool empty() const + { + return bitset_.empty(); + } + + /** set all the bits to 0 + */ + void reset() + { + std::fill(bitset_.begin(), bitset_.end(), 0); + } + + /** @brief set one bit to 0 + * @param index + */ + void reset(size_t index) + { + bitset_[index / cell_bit_size_] &= ~(size_t(1) << (index % cell_bit_size_)); + } + + /** @brief sets a specific bit to 0, and more bits too + * This function is useful when resetting a given set of bits so that the + * whole bitset ends up being 0: if that's the case, we don't care about setting + * other bits to 0 + * @param index + */ + void reset_block(size_t index) + { + bitset_[index / cell_bit_size_] = 0; + } + + /** resize the bitset so that it contains at least sz bits + * @param sz + */ + void resize(size_t sz) + { + size_ = sz; + bitset_.resize(sz / cell_bit_size_ + 1); + } + + /** set a bit to true + * @param index the index of the bit to set to 1 + */ + void set(size_t index) + { + bitset_[index / cell_bit_size_] |= size_t(1) << (index % cell_bit_size_); + } + + /** gives the number of contained bits + */ + size_t size() const + { + return size_; + } + + /** check if a bit is set + * @param index the index of the bit to check + * @return true if the bit is set + */ + bool test(size_t index) const + { + return (bitset_[index / cell_bit_size_] & (size_t(1) << (index % cell_bit_size_))) != 0; + } + +private: + std::vector bitset_; + size_t size_; + static const unsigned int cell_bit_size_ = CHAR_BIT * sizeof(size_t); +}; + +} // namespace cvflann + +#endif + +//! @endcond + +#endif // OPENCV_FLANN_DYNAMIC_BITSET_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/flann.hpp b/Cigarette/OpenCV455Simple/include/opencv2/flann/flann.hpp new file mode 100644 index 0000000..227683f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/flann.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/flann.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/flann_base.hpp b/Cigarette/OpenCV455Simple/include/opencv2/flann/flann_base.hpp new file mode 100644 index 0000000..258ec38 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/flann_base.hpp @@ -0,0 +1,299 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_BASE_HPP_ +#define OPENCV_FLANN_BASE_HPP_ + +//! @cond IGNORED + +#include +#include + +#include "general.h" +#include "matrix.h" +#include "params.h" +#include "saving.h" + +#include "all_indices.h" + +namespace cvflann +{ + +/** + * Sets the log level used for all flann functions + * @param level Verbosity level + */ +inline void log_verbosity(int level) +{ + if (level >= 0) { + Logger::setLevel(level); + } +} + +/** + * (Deprecated) Index parameters for creating a saved index. + */ +struct SavedIndexParams : public IndexParams +{ + SavedIndexParams(cv::String filename) + { + (* this)["algorithm"] = FLANN_INDEX_SAVED; + (*this)["filename"] = filename; + } +}; + + +template +NNIndex* load_saved_index(const Matrix& dataset, const cv::String& filename, Distance distance) +{ + typedef typename Distance::ElementType ElementType; + + FILE* fin = fopen(filename.c_str(), "rb"); + if (fin == NULL) { + return NULL; + } + IndexHeader header = load_header(fin); + if (header.data_type != Datatype::type()) { + fclose(fin); + FLANN_THROW(cv::Error::StsError, "Datatype of saved index is different than of the one to be created."); + } + if ((size_t(header.rows) != dataset.rows)||(size_t(header.cols) != dataset.cols)) { + fclose(fin); + FLANN_THROW(cv::Error::StsError, "The index saved belongs to a different dataset"); + } + + IndexParams params; + params["algorithm"] = header.index_type; + NNIndex* nnIndex = create_index_by_type(dataset, params, distance); + nnIndex->loadIndex(fin); + fclose(fin); + + return nnIndex; +} + + +template +class Index : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + Index(const Matrix& features, const IndexParams& params, Distance distance = Distance() ) + : index_params_(params) + { + flann_algorithm_t index_type = get_param(params,"algorithm"); + loaded_ = false; + + if (index_type == FLANN_INDEX_SAVED) { + nnIndex_ = load_saved_index(features, get_param(params,"filename"), distance); + loaded_ = true; + } + else { + nnIndex_ = create_index_by_type(features, params, distance); + } + } + + ~Index() + { + delete nnIndex_; + } + + /** + * Builds the index. + */ + void buildIndex() CV_OVERRIDE + { + if (!loaded_) { + nnIndex_->buildIndex(); + } + } + + void save(cv::String filename) + { + FILE* fout = fopen(filename.c_str(), "wb"); + if (fout == NULL) { + FLANN_THROW(cv::Error::StsError, "Cannot open file"); + } + save_header(fout, *nnIndex_); + saveIndex(fout); + fclose(fout); + } + + /** + * \brief Saves the index to a stream + * \param stream The stream to save the index to + */ + virtual void saveIndex(FILE* stream) CV_OVERRIDE + { + nnIndex_->saveIndex(stream); + } + + /** + * \brief Loads the index from a stream + * \param stream The stream from which the index is loaded + */ + virtual void loadIndex(FILE* stream) CV_OVERRIDE + { + nnIndex_->loadIndex(stream); + } + + /** + * \returns number of features in this index. + */ + size_t veclen() const CV_OVERRIDE + { + return nnIndex_->veclen(); + } + + /** + * \returns The dimensionality of the features in this index. + */ + size_t size() const CV_OVERRIDE + { + return nnIndex_->size(); + } + + /** + * \returns The index type (kdtree, kmeans,...) + */ + flann_algorithm_t getType() const CV_OVERRIDE + { + return nnIndex_->getType(); + } + + /** + * \returns The amount of memory (in bytes) used by the index. + */ + virtual int usedMemory() const CV_OVERRIDE + { + return nnIndex_->usedMemory(); + } + + + /** + * \returns The index parameters + */ + IndexParams getParameters() const CV_OVERRIDE + { + return nnIndex_->getParameters(); + } + + /** + * \brief Perform k-nearest neighbor search + * \param[in] queries The query points for which to find the nearest neighbors + * \param[out] indices The indices of the nearest neighbors found + * \param[out] dists Distances to the nearest neighbors found + * \param[in] knn Number of nearest neighbors to return + * \param[in] params Search parameters + */ + void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE + { + nnIndex_->knnSearch(queries, indices, dists, knn, params); + } + + /** + * \brief Perform radius search + * \param[in] query The query point + * \param[out] indices The indinces of the neighbors found within the given radius + * \param[out] dists The distances to the nearest neighbors found + * \param[in] radius The radius used for search + * \param[in] params Search parameters + * \returns Number of neighbors found + */ + int radiusSearch(const Matrix& query, Matrix& indices, Matrix& dists, float radius, const SearchParams& params) CV_OVERRIDE + { + return nnIndex_->radiusSearch(query, indices, dists, radius, params); + } + + /** + * \brief Method that searches for nearest-neighbours + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + nnIndex_->findNeighbors(result, vec, searchParams); + } + + /** + * \brief Returns actual index + */ + CV_DEPRECATED NNIndex* getIndex() + { + return nnIndex_; + } + + /** + * \brief Returns index parameters. + * \deprecated use getParameters() instead. + */ + CV_DEPRECATED const IndexParams* getIndexParameters() + { + return &index_params_; + } + +private: + /** Pointer to actual index class */ + NNIndex* nnIndex_; + /** Indices if the index was loaded from a file */ + bool loaded_; + /** Parameters passed to the index */ + IndexParams index_params_; + + Index(const Index &); // copy disabled + Index& operator=(const Index &); // assign disabled +}; + +/** + * Performs a hierarchical clustering of the points passed as argument and then takes a cut in the + * the clustering tree to return a flat clustering. + * @param[in] points Points to be clustered + * @param centers The computed cluster centres. Matrix should be preallocated and centers.rows is the + * number of clusters requested. + * @param params Clustering parameters (The same as for cvflann::KMeansIndex) + * @param d Distance to be used for clustering (eg: cvflann::L2) + * @return number of clusters computed (can be different than clusters.rows and is the highest number + * of the form (branching-1)*K+1 smaller than clusters.rows). + */ +template +int hierarchicalClustering(const Matrix& points, Matrix& centers, + const KMeansIndexParams& params, Distance d = Distance()) +{ + KMeansIndex kmeans(points, params, d); + kmeans.buildIndex(); + + int clusterNum = kmeans.getClusterCenters(centers); + return clusterNum; +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_BASE_HPP_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/general.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/general.h new file mode 100644 index 0000000..29fa8be --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/general.h @@ -0,0 +1,63 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_GENERAL_H_ +#define OPENCV_FLANN_GENERAL_H_ + +#if CV_VERSION_MAJOR <= 4 + +//! @cond IGNORED + +#include "opencv2/core.hpp" + +namespace cvflann +{ + +class FLANNException : public cv::Exception +{ +public: + FLANNException(const char* message) : cv::Exception(0, message, "", __FILE__, __LINE__) { } + + FLANNException(const cv::String& message) : cv::Exception(0, message, "", __FILE__, __LINE__) { } +}; + +} + +#define FLANN_THROW(TYPE, STR) throw FLANNException(STR) + +#else + +#define FLANN_THROW(TYPE, STR) CV_Error(TYPE, STR) + +#endif + +//! @endcond + +#endif /* OPENCV_FLANN_GENERAL_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/ground_truth.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/ground_truth.h new file mode 100644 index 0000000..17f2a8e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/ground_truth.h @@ -0,0 +1,98 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_GROUND_TRUTH_H_ +#define OPENCV_FLANN_GROUND_TRUTH_H_ + +//! @cond IGNORED + +#include "dist.h" +#include "matrix.h" + + +namespace cvflann +{ + +template +void find_nearest(const Matrix& dataset, typename Distance::ElementType* query, int* matches, int nn, + int skip = 0, Distance distance = Distance()) +{ + typedef typename Distance::ResultType DistanceType; + int n = nn + skip; + + std::vector match(n); + std::vector dists(n); + + dists[0] = distance(dataset[0], query, dataset.cols); + match[0] = 0; + int dcnt = 1; + + for (size_t i=1; i=1 && dists[j] +void compute_ground_truth(const Matrix& dataset, const Matrix& testset, Matrix& matches, + int skip=0, Distance d = Distance()) +{ + for (size_t i=0; i(dataset, testset[i], matches[i], (int)matches.cols, skip, d); + } +} + + +} + +//! @endcond + +#endif //OPENCV_FLANN_GROUND_TRUTH_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/hdf5.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/hdf5.h new file mode 100644 index 0000000..7554384 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/hdf5.h @@ -0,0 +1,235 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_HDF5_H_ +#define OPENCV_FLANN_HDF5_H_ + +//! @cond IGNORED + +#include + +#include "matrix.h" + + +namespace cvflann +{ + +namespace +{ + +template +hid_t get_hdf5_type() +{ + throw FLANNException("Unsupported type for IO operations"); +} + +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_CHAR; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_UCHAR; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_SHORT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_USHORT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_INT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_UINT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_LONG; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_ULONG; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_FLOAT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_DOUBLE; } +} + + +#define CHECK_ERROR(x,y) if ((x)<0) throw FLANNException((y)); + +template +void save_to_file(const cvflann::Matrix& dataset, const String& filename, const String& name) +{ + +#if H5Eset_auto_vers == 2 + H5Eset_auto( H5E_DEFAULT, NULL, NULL ); +#else + H5Eset_auto( NULL, NULL ); +#endif + + herr_t status; + hid_t file_id; + file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); + if (file_id < 0) { + file_id = H5Fcreate(filename.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT); + } + CHECK_ERROR(file_id,"Error creating hdf5 file."); + + hsize_t dimsf[2]; // dataset dimensions + dimsf[0] = dataset.rows; + dimsf[1] = dataset.cols; + + hid_t space_id = H5Screate_simple(2, dimsf, NULL); + hid_t memspace_id = H5Screate_simple(2, dimsf, NULL); + + hid_t dataset_id; +#if H5Dcreate_vers == 2 + dataset_id = H5Dcreate2(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); +#else + dataset_id = H5Dcreate(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT); +#endif + + if (dataset_id<0) { +#if H5Dopen_vers == 2 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif + } + CHECK_ERROR(dataset_id,"Error creating or opening dataset in file."); + + status = H5Dwrite(dataset_id, get_hdf5_type(), memspace_id, space_id, H5P_DEFAULT, dataset.data ); + CHECK_ERROR(status, "Error writing to dataset"); + + H5Sclose(memspace_id); + H5Sclose(space_id); + H5Dclose(dataset_id); + H5Fclose(file_id); + +} + + +template +void load_from_file(cvflann::Matrix& dataset, const String& filename, const String& name) +{ + herr_t status; + hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); + CHECK_ERROR(file_id,"Error opening hdf5 file."); + + hid_t dataset_id; +#if H5Dopen_vers == 2 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif + CHECK_ERROR(dataset_id,"Error opening dataset in file."); + + hid_t space_id = H5Dget_space(dataset_id); + + hsize_t dims_out[2]; + H5Sget_simple_extent_dims(space_id, dims_out, NULL); + + dataset = cvflann::Matrix(new T[dims_out[0]*dims_out[1]], dims_out[0], dims_out[1]); + + status = H5Dread(dataset_id, get_hdf5_type(), H5S_ALL, H5S_ALL, H5P_DEFAULT, dataset[0]); + CHECK_ERROR(status, "Error reading dataset"); + + H5Sclose(space_id); + H5Dclose(dataset_id); + H5Fclose(file_id); +} + + +#ifdef HAVE_MPI + +namespace mpi +{ +/** + * Loads a the hyperslice corresponding to this processor from a hdf5 file. + * @param flann_dataset Dataset where the data is loaded + * @param filename HDF5 file name + * @param name Name of dataset inside file + */ +template +void load_from_file(cvflann::Matrix& dataset, const String& filename, const String& name) +{ + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + int mpi_size, mpi_rank; + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + herr_t status; + + hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(plist_id, comm, info); + hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, plist_id); + CHECK_ERROR(file_id,"Error opening hdf5 file."); + H5Pclose(plist_id); + hid_t dataset_id; +#if H5Dopen_vers == 2 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif + CHECK_ERROR(dataset_id,"Error opening dataset in file."); + + hid_t space_id = H5Dget_space(dataset_id); + hsize_t dims[2]; + H5Sget_simple_extent_dims(space_id, dims, NULL); + + hsize_t count[2]; + hsize_t offset[2]; + + hsize_t item_cnt = dims[0]/mpi_size+(dims[0]%mpi_size==0 ? 0 : 1); + hsize_t cnt = (mpi_rank(), memspace_id, space_id, plist_id, dataset.data); + CHECK_ERROR(status, "Error reading dataset"); + + H5Pclose(plist_id); + H5Sclose(space_id); + H5Sclose(memspace_id); + H5Dclose(dataset_id); + H5Fclose(file_id); +} +} +#endif // HAVE_MPI +} // namespace cvflann::mpi + +//! @endcond + +#endif /* OPENCV_FLANN_HDF5_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/heap.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/heap.h new file mode 100644 index 0000000..8cace20 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/heap.h @@ -0,0 +1,244 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_HEAP_H_ +#define OPENCV_FLANN_HEAP_H_ + +//! @cond IGNORED + +#include +#include + +#include + +namespace cvflann +{ + +// TODO: Define x > y operator and use std::greater instead +template +struct greater +{ + bool operator()(const T& x, const T& y) const + { + return y < x; + } +}; + +/** + * Priority Queue Implementation + * + * The priority queue is implemented with a heap. A heap is a complete + * (full) binary tree in which each parent is less than both of its + * children, but the order of the children is unspecified. + */ +template +class Heap +{ + /** + * Storage array for the heap. + * Type T must be comparable. + */ + std::vector heap; +public: + /** + * \brief Constructs a heap with a pre-allocated capacity + * + * \param capacity heap maximum capacity + */ + Heap(const int capacity) + { + reserve(capacity); + } + + /** + * \brief Move-constructs a heap from an external vector + * + * \param vec external vector + */ + Heap(std::vector&& vec) + : heap(std::move(vec)) + { + std::make_heap(heap.begin(), heap.end(), greater()); + } + + /** + * + * \returns heap size + */ + int size() const + { + return (int)heap.size(); + } + + /** + * + * \returns heap capacity + */ + int capacity() const + { + return (int)heap.capacity(); + } + + /** + * \brief Tests if the heap is empty + * + * \returns true is heap empty, false otherwise + */ + bool empty() + { + return heap.empty(); + } + + /** + * \brief Clears the heap. + */ + void clear() + { + heap.clear(); + } + + /** + * \brief Sets the heap maximum capacity. + * + * \param capacity heap maximum capacity + */ + void reserve(const int capacity) + { + heap.reserve(capacity); + } + + /** + * \brief Inserts a new element in the heap. + * + * We select the next empty leaf node, and then keep moving any larger + * parents down until the right location is found to store this element. + * + * \param value the new element to be inserted in the heap + */ + void insert(T value) + { + /* If heap is full, then return without adding this element. */ + if (size() == capacity()) { + return; + } + + heap.push_back(value); + std::push_heap(heap.begin(), heap.end(), greater()); + } + + /** + * \brief Returns the node of minimum value from the heap (top of the heap). + * + * \param[out] value parameter used to return the min element + * \returns false if heap empty + */ + bool popMin(T& value) + { + if (empty()) { + return false; + } + + value = heap[0]; + std::pop_heap(heap.begin(), heap.end(), greater()); + heap.pop_back(); + + return true; /* Return old last node. */ + } + + /** + * \brief Returns a shared heap for the given memory pool ID. + * + * It constructs the heap if it does not already exists. + * + * \param poolId a user-chosen hashable ID for identifying the heap. + * For thread-safe operations, using current thread ID is a good choice. + * \param capacity heap maximum capacity + * \param iterThreshold remove heaps that were not reused for more than specified iterations count + * if iterThreshold value is less 2, it will be internally adjusted to twice the number of CPU threads + * \returns pointer to the heap + */ + template + static cv::Ptr> getPooledInstance( + const HashableT& poolId, const int capacity, int iterThreshold = 0) + { + static cv::Mutex mutex; + const cv::AutoLock lock(mutex); + + struct HeapMapValueType { + cv::Ptr> heapPtr; + int iterCounter; + }; + typedef std::unordered_map HeapMapType; + + static HeapMapType heapsPool; + typename HeapMapType::iterator heapIt = heapsPool.find(poolId); + + if (heapIt == heapsPool.end()) + { + // Construct the heap as it does not already exists + HeapMapValueType heapAndTimePair = {cv::makePtr>(capacity), 0}; + const std::pair& emplaceResult = heapsPool.emplace(poolId, std::move(heapAndTimePair)); + CV_CheckEQ(static_cast(emplaceResult.second), 1, "Failed to insert the heap into its memory pool"); + heapIt = emplaceResult.first; + } + else + { + CV_CheckEQ(heapIt->second.heapPtr.use_count(), 1, "Cannot modify a heap that is currently accessed by another caller"); + heapIt->second.heapPtr->clear(); + heapIt->second.heapPtr->reserve(capacity); + heapIt->second.iterCounter = 0; + } + + if (iterThreshold <= 1) { + iterThreshold = 2 * cv::getNumThreads(); + } + + // Remove heaps that were not reused for more than given iterThreshold + typename HeapMapType::iterator cleanupIt = heapsPool.begin(); + while (cleanupIt != heapsPool.end()) + { + if (cleanupIt->second.iterCounter++ > iterThreshold) + { + CV_Assert(cleanupIt != heapIt); + cleanupIt = heapsPool.erase(cleanupIt); + continue; + } + ++cleanupIt; + } + + return heapIt->second.heapPtr; + } +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_HEAP_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/hierarchical_clustering_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/hierarchical_clustering_index.h new file mode 100644 index 0000000..60662e7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/hierarchical_clustering_index.h @@ -0,0 +1,846 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ +#define OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include +#include + +#include "general.h" +#include "nn_index.h" +#include "dist.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + + +namespace cvflann +{ + +struct HierarchicalClusteringIndexParams : public IndexParams +{ + HierarchicalClusteringIndexParams(int branching = 32, + flann_centers_init_t centers_init = FLANN_CENTERS_RANDOM, + int trees = 4, int leaf_size = 100) + { + (*this)["algorithm"] = FLANN_INDEX_HIERARCHICAL; + // The branching factor used in the hierarchical clustering + (*this)["branching"] = branching; + // Algorithm used for picking the initial cluster centers + (*this)["centers_init"] = centers_init; + // number of parallel trees to build + (*this)["trees"] = trees; + // maximum leaf size + (*this)["leaf_size"] = leaf_size; + } +}; + + +/** + * Hierarchical index + * + * Contains a tree constructed through a hierarchical clustering + * and other information for indexing a set of points for nearest-neighbour matching. + */ +template +class HierarchicalClusteringIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + +private: + + + typedef void (HierarchicalClusteringIndex::* centersAlgFunction)(int, int*, int, int*, int&); + + /** + * The function used for choosing the cluster centers. + */ + centersAlgFunction chooseCenters; + + + + /** + * Chooses the initial centers in the k-means clustering in a random manner. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * indices_length = length of indices vector + * + */ + void chooseCentersRandom(int k, int* dsindices, int indices_length, int* centers, int& centers_length) + { + UniqueRandom r(indices_length); + + int index; + for (index=0; index=0 && rnd < n); + + centers[0] = dsindices[rnd]; + + int index; + for (index=1; indexbest_val) { + best_val = dist; + best_index = j; + } + } + if (best_index!=-1) { + centers[index] = dsindices[best_index]; + } + else { + break; + } + } + centers_length = index; + } + + + /** + * Chooses the initial centers in the k-means using the algorithm + * proposed in the KMeans++ paper: + * Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding + * + * Implementation of this function was converted from the one provided in Arthur's code. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * Returns: + */ + void chooseCentersKMeanspp(int k, int* dsindices, int indices_length, int* centers, int& centers_length) + { + int n = indices_length; + + double currentPot = 0; + DistanceType* closestDistSq = new DistanceType[n]; + + // Choose one random center and set the closestDistSq values + int index = rand_int(n); + CV_DbgAssert(index >=0 && index < n); + centers[0] = dsindices[index]; + + // Computing distance^2 will have the advantage of even higher probability further to pick new centers + // far from previous centers (and this complies to "k-means++: the advantages of careful seeding" article) + for (int i = 0; i < n; i++) { + closestDistSq[i] = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols); + closestDistSq[i] = ensureSquareDistance( closestDistSq[i] ); + currentPot += closestDistSq[i]; + } + + + const int numLocalTries = 1; + + // Choose each center + int centerCount; + for (centerCount = 1; centerCount < k; centerCount++) { + + // Repeat several trials + double bestNewPot = -1; + int bestNewIndex = 0; + for (int localTrial = 0; localTrial < numLocalTries; localTrial++) { + + // Choose our center - have to be slightly careful to return a valid answer even accounting + // for possible rounding errors + double randVal = rand_double(currentPot); + for (index = 0; index < n-1; index++) { + if (randVal <= closestDistSq[index]) break; + else randVal -= closestDistSq[index]; + } + + // Compute the new potential + double newPot = 0; + for (int i = 0; i < n; i++) { + DistanceType dist = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols); + newPot += std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + + // Store the best result + if ((bestNewPot < 0)||(newPot < bestNewPot)) { + bestNewPot = newPot; + bestNewIndex = index; + } + } + + // Add the appropriate center + centers[centerCount] = dsindices[bestNewIndex]; + currentPot = bestNewPot; + for (int i = 0; i < n; i++) { + DistanceType dist = distance(dataset[dsindices[i]], dataset[dsindices[bestNewIndex]], dataset.cols); + closestDistSq[i] = std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + } + + centers_length = centerCount; + + delete[] closestDistSq; + } + + + /** + * Chooses the initial centers in a way inspired by Gonzales (by Pierre-Emmanuel Viel): + * select the first point of the list as a candidate, then parse the points list. If another + * point is further than current candidate from the other centers, test if it is a good center + * of a local aggregation. If it is, replace current candidate by this point. And so on... + * + * Used with KMeansIndex that computes centers coordinates by averaging positions of clusters points, + * this doesn't make a real difference with previous methods. But used with HierarchicalClusteringIndex + * class that pick centers among existing points instead of computing the barycenters, there is a real + * improvement. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * Returns: + */ + void GroupWiseCenterChooser(int k, int* dsindices, int indices_length, int* centers, int& centers_length) + { + const float kSpeedUpFactor = 1.3f; + + int n = indices_length; + + DistanceType* closestDistSq = new DistanceType[n]; + + // Choose one random center and set the closestDistSq values + int index = rand_int(n); + CV_DbgAssert(index >=0 && index < n); + centers[0] = dsindices[index]; + + for (int i = 0; i < n; i++) { + closestDistSq[i] = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols); + } + + + // Choose each center + int centerCount; + for (centerCount = 1; centerCount < k; centerCount++) { + + // Repeat several trials + double bestNewPot = -1; + int bestNewIndex = 0; + DistanceType furthest = 0; + for (index = 0; index < n; index++) { + + // We will test only the potential of the points further than current candidate + if( closestDistSq[index] > kSpeedUpFactor * (float)furthest ) { + + // Compute the new potential + double newPot = 0; + for (int i = 0; i < n; i++) { + newPot += std::min( distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols) + , closestDistSq[i] ); + } + + // Store the best result + if ((bestNewPot < 0)||(newPot <= bestNewPot)) { + bestNewPot = newPot; + bestNewIndex = index; + furthest = closestDistSq[index]; + } + } + } + + // Add the appropriate center + centers[centerCount] = dsindices[bestNewIndex]; + for (int i = 0; i < n; i++) { + closestDistSq[i] = std::min( distance(dataset[dsindices[i]], dataset[dsindices[bestNewIndex]], dataset.cols) + , closestDistSq[i] ); + } + } + + centers_length = centerCount; + + delete[] closestDistSq; + } + + +public: + + + /** + * Index constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the hierarchical k-means algorithm + */ + HierarchicalClusteringIndex(const Matrix& inputData, const IndexParams& index_params = HierarchicalClusteringIndexParams(), + Distance d = Distance()) + : dataset(inputData), params(index_params), root(NULL), indices(NULL), distance(d) + { + memoryCounter = 0; + + size_ = dataset.rows; + veclen_ = dataset.cols; + + branching_ = get_param(params,"branching",32); + centers_init_ = get_param(params,"centers_init", FLANN_CENTERS_RANDOM); + trees_ = get_param(params,"trees",4); + leaf_size_ = get_param(params,"leaf_size",100); + + if (centers_init_==FLANN_CENTERS_RANDOM) { + chooseCenters = &HierarchicalClusteringIndex::chooseCentersRandom; + } + else if (centers_init_==FLANN_CENTERS_GONZALES) { + chooseCenters = &HierarchicalClusteringIndex::chooseCentersGonzales; + } + else if (centers_init_==FLANN_CENTERS_KMEANSPP) { + chooseCenters = &HierarchicalClusteringIndex::chooseCentersKMeanspp; + } + else if (centers_init_==FLANN_CENTERS_GROUPWISE) { + chooseCenters = &HierarchicalClusteringIndex::GroupWiseCenterChooser; + } + else { + FLANN_THROW(cv::Error::StsError, "Unknown algorithm for choosing initial centers."); + } + + root = new NodePtr[trees_]; + indices = new int*[trees_]; + + for (int i=0; i(); + computeClustering(root[i], indices[i], (int)size_, branching_,0); + } + } + + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_HIERARCHICAL; + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, branching_); + save_value(stream, trees_); + save_value(stream, centers_init_); + save_value(stream, leaf_size_); + save_value(stream, memoryCounter); + for (int i=0; i& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + + const int maxChecks = get_param(searchParams,"checks",32); + const bool explore_all_trees = get_param(searchParams,"explore_all_trees",false); + + // Priority queue storing intermediate branches in the best-bin-first search + const cv::Ptr>& heap = Heap::getPooledInstance(cv::utils::getThreadID(), (int)size_); + + std::vector checked(size_,false); + int checks = 0; + for (int i=0; i= maxChecks) && result.full()) + break; + } + + BranchSt branch; + while (heap->popMin(branch) && (checks BranchSt; + + + + void save_tree(FILE* stream, NodePtr node, int num) + { + save_value(stream, *node); + if (node->childs==NULL) { + int indices_offset = (int)(node->indices - indices[num]); + save_value(stream, indices_offset); + } + else { + for(int i=0; ichilds[i], num); + } + } + } + + + void load_tree(FILE* stream, NodePtr& node, int num) + { + node = pool.allocate(); + load_value(stream, *node); + if (node->childs==NULL) { + int indices_offset; + load_value(stream, indices_offset); + node->indices = indices[num] + indices_offset; + } + else { + node->childs = pool.allocate(branching_); + for(int i=0; ichilds[i], num); + } + } + } + + + /** + * Release the inner elements of indices[] + */ + void free_indices() + { + if (indices!=NULL) { + for(int i=0; inew_dist) { + labels[i] = j; + dist = new_dist; + } + } + cost += dist; + } + } + + /** + * The method responsible with actually doing the recursive hierarchical + * clustering + * + * Params: + * node = the node to cluster + * indices = indices of the points belonging to the current node + * branching = the branching factor to use in the clustering + * + * TODO: for 1-sized clusters don't store a cluster center (it's the same as the single cluster point) + */ + void computeClustering(NodePtr node, int* dsindices, int indices_length, int branching, int level) + { + node->size = indices_length; + node->level = level; + + if (indices_length < leaf_size_) { // leaf node + node->indices = dsindices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + std::vector centers(branching); + std::vector labels(indices_length); + + int centers_length; + (this->*chooseCenters)(branching, dsindices, indices_length, ¢ers[0], centers_length); + + if (centers_lengthindices = dsindices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + + // assign points to clusters + DistanceType cost; + computeLabels(dsindices, indices_length, ¢ers[0], centers_length, &labels[0], cost); + + node->childs = pool.allocate(branching); + int start = 0; + int end = start; + for (int i=0; ichilds[i] = pool.allocate(); + node->childs[i]->pivot = centers[i]; + node->childs[i]->indices = NULL; + computeClustering(node->childs[i],dsindices+start, end-start, branching, level+1); + start=end; + } + } + + + + /** + * Performs one descent in the hierarchical k-means tree. The branches not + * visited are stored in a priority queue. + * + * Params: + * node = node to explore + * result = container for the k-nearest neighbors found + * vec = query points + * checks = how many points in the dataset have been checked so far + * maxChecks = maximum dataset points to checks + */ + + + void findNN(NodePtr node, ResultSet& result, const ElementType* vec, int& checks, int maxChecks, + const cv::Ptr>& heap, std::vector& checked, bool explore_all_trees = false) + { + if (node->childs==NULL) { + if (!explore_all_trees && (checks>=maxChecks) && result.full()) { + return; + } + for (int i=0; isize; ++i) { + int index = node->indices[i]; + if (!checked[index]) { + DistanceType dist = distance(dataset[index], vec, veclen_); + result.addPoint(dist, index); + checked[index] = true; + ++checks; + } + } + } + else { + DistanceType* domain_distances = new DistanceType[branching_]; + int best_index = 0; + domain_distances[best_index] = distance(vec, dataset[node->childs[best_index]->pivot], veclen_); + for (int i=1; ichilds[i]->pivot], veclen_); + if (domain_distances[i]insert(BranchSt(node->childs[i],domain_distances[i])); + } + } + delete[] domain_distances; + findNN(node->childs[best_index],result,vec, checks, maxChecks, heap, checked, explore_all_trees); + } + } + +private: + + + /** + * The dataset used by this index + */ + const Matrix dataset; + + /** + * Parameters used by this index + */ + IndexParams params; + + + /** + * Number of features in the dataset. + */ + size_t size_; + + /** + * Length of each feature. + */ + size_t veclen_; + + /** + * The root node in the tree. + */ + NodePtr* root; + + /** + * Array of indices to vectors in the dataset. + */ + int** indices; + + + /** + * The distance + */ + Distance distance; + + /** + * Pooled memory allocator. + * + * Using a pooled memory allocator is more efficient + * than allocating memory directly when there is a large + * number small of memory allocations. + */ + PooledAllocator pool; + + /** + * Memory occupied by the index. + */ + int memoryCounter; + + /** index parameters */ + int branching_; + int trees_; + flann_centers_init_t centers_init_; + int leaf_size_; + + +}; + +} + +//! @endcond + +#endif /* OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/index_testing.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/index_testing.h new file mode 100644 index 0000000..207adef --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/index_testing.h @@ -0,0 +1,321 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_INDEX_TESTING_H_ +#define OPENCV_FLANN_INDEX_TESTING_H_ + +//! @cond IGNORED + +#include +#include + +#include "matrix.h" +#include "nn_index.h" +#include "result_set.h" +#include "logger.h" +#include "timer.h" + + +namespace cvflann +{ + +inline int countCorrectMatches(int* neighbors, int* groundTruth, int n) +{ + int count = 0; + for (int i=0; i +typename Distance::ResultType computeDistanceRaport(const Matrix& inputData, typename Distance::ElementType* target, + int* neighbors, int* groundTruth, int veclen, int n, const Distance& distance) +{ + typedef typename Distance::ResultType DistanceType; + + DistanceType ret = 0; + for (int i=0; i +float search_with_ground_truth(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, int nn, int checks, + float& time, typename Distance::ResultType& dist, const Distance& distance, int skipMatches) +{ + typedef typename Distance::ResultType DistanceType; + + if (matches.cols resultSet(nn+skipMatches); + SearchParams searchParams(checks); + + std::vector indices(nn+skipMatches); + std::vector dists(nn+skipMatches); + int* neighbors = &indices[skipMatches]; + + int correct = 0; + DistanceType distR = 0; + StartStopTimer t; + int repeats = 0; + while (t.value<0.2) { + repeats++; + t.start(); + correct = 0; + distR = 0; + for (size_t i = 0; i < testData.rows; i++) { + resultSet.init(&indices[0], &dists[0]); + index.findNeighbors(resultSet, testData[i], searchParams); + + correct += countCorrectMatches(neighbors,matches[i], nn); + distR += computeDistanceRaport(inputData, testData[i], neighbors, matches[i], (int)testData.cols, nn, distance); + } + t.stop(); + } + time = float(t.value/repeats); + + float precicion = (float)correct/(nn*testData.rows); + + dist = distR/(testData.rows*nn); + + Logger::info("%8d %10.4g %10.5g %10.5g %10.5g\n", + checks, precicion, time, 1000.0 * time / testData.rows, dist); + + return precicion; +} + + +template +float test_index_checks(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, + int checks, float& precision, const Distance& distance, int nn = 1, int skipMatches = 0) +{ + typedef typename Distance::ResultType DistanceType; + + Logger::info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n"); + Logger::info("---------------------------------------------------------\n"); + + float time = 0; + DistanceType dist = 0; + precision = search_with_ground_truth(index, inputData, testData, matches, nn, checks, time, dist, distance, skipMatches); + + return time; +} + +template +float test_index_precision(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, + float precision, int& checks, const Distance& distance, int nn = 1, int skipMatches = 0) +{ + typedef typename Distance::ResultType DistanceType; + const float SEARCH_EPS = 0.001f; + + Logger::info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n"); + Logger::info("---------------------------------------------------------\n"); + + int c2 = 1; + float p2; + int c1 = 1; + //float p1; + float time; + DistanceType dist; + + p2 = search_with_ground_truth(index, inputData, testData, matches, nn, c2, time, dist, distance, skipMatches); + + if (p2>precision) { + Logger::info("Got as close as I can\n"); + checks = c2; + return time; + } + + while (p2SEARCH_EPS) { + Logger::info("Start linear estimation\n"); + // after we got to values in the vecinity of the desired precision + // use linear approximation get a better estimation + + cx = (c1+c2)/2; + realPrecision = search_with_ground_truth(index, inputData, testData, matches, nn, cx, time, dist, distance, skipMatches); + while (fabs(realPrecision-precision)>SEARCH_EPS) { + + if (realPrecision +void test_index_precisions(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, + float* precisions, int precisions_length, const Distance& distance, int nn = 1, int skipMatches = 0, float maxTime = 0) +{ + typedef typename Distance::ResultType DistanceType; + + const float SEARCH_EPS = 0.001; + + // make sure precisions array is sorted + std::sort(precisions, precisions+precisions_length); + + int pindex = 0; + float precision = precisions[pindex]; + + Logger::info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n"); + Logger::info("---------------------------------------------------------\n"); + + int c2 = 1; + float p2; + + int c1 = 1; + float p1; + + float time; + DistanceType dist; + + p2 = search_with_ground_truth(index, inputData, testData, matches, nn, c2, time, dist, distance, skipMatches); + + // if precision for 1 run down the tree is already + // better then some of the requested precisions, then + // skip those + while (precisions[pindex] 0)&&(time > maxTime)&&(p2SEARCH_EPS) { + Logger::info("Start linear estimation\n"); + // after we got to values in the vecinity of the desired precision + // use linear approximation get a better estimation + + cx = (c1+c2)/2; + realPrecision = search_with_ground_truth(index, inputData, testData, matches, nn, cx, time, dist, distance, skipMatches); + while (fabs(realPrecision-precision)>SEARCH_EPS) { + + if (realPrecision +#include +#include + +#include "nn_index.h" +#include "dynamic_bitset.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + + +namespace cvflann +{ + +struct KDTreeIndexParams : public IndexParams +{ + KDTreeIndexParams(int trees = 4) + { + (*this)["algorithm"] = FLANN_INDEX_KDTREE; + (*this)["trees"] = trees; + } +}; + + +/** + * Randomized kd-tree index + * + * Contains the k-d trees and other information for indexing a set of points + * for nearest-neighbor matching. + */ +template +class KDTreeIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + + /** + * KDTree constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the kdtree algorithm + */ + KDTreeIndex(const Matrix& inputData, const IndexParams& params = KDTreeIndexParams(), + Distance d = Distance() ) : + dataset_(inputData), index_params_(params), distance_(d) + { + size_ = dataset_.rows; + veclen_ = dataset_.cols; + + trees_ = get_param(index_params_,"trees",4); + tree_roots_ = new NodePtr[trees_]; + + // Create a permutable array of indices to the input vectors. + vind_.resize(size_); + for (size_t i = 0; i < size_; ++i) { + vind_[i] = int(i); + } + + mean_ = new DistanceType[veclen_]; + var_ = new DistanceType[veclen_]; + } + + + KDTreeIndex(const KDTreeIndex&); + KDTreeIndex& operator=(const KDTreeIndex&); + + /** + * Standard destructor + */ + ~KDTreeIndex() + { + if (tree_roots_!=NULL) { + delete[] tree_roots_; + } + delete[] mean_; + delete[] var_; + } + + /** + * Builds the index + */ + void buildIndex() CV_OVERRIDE + { + /* Construct the randomized trees. */ + for (int i = 0; i < trees_; i++) { + /* Randomize the order of vectors to allow for unbiased sampling. */ +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::randShuffle(vind_); +#else + std::random_shuffle(vind_.begin(), vind_.end()); +#endif + + tree_roots_[i] = divideTree(&vind_[0], int(size_) ); + } + } + + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_KDTREE; + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, trees_); + for (int i=0; i& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + const int maxChecks = get_param(searchParams,"checks", 32); + const float epsError = 1+get_param(searchParams,"eps",0.0f); + const bool explore_all_trees = get_param(searchParams,"explore_all_trees",false); + + if (maxChecks==FLANN_CHECKS_UNLIMITED) { + getExactNeighbors(result, vec, epsError); + } + else { + getNeighbors(result, vec, maxChecks, epsError, explore_all_trees); + } + } + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + +private: + + + /*--------------------- Internal Data Structures --------------------------*/ + struct Node + { + /** + * Dimension used for subdivision. + */ + int divfeat; + /** + * The values used for subdivision. + */ + DistanceType divval; + /** + * The child nodes. + */ + Node* child1, * child2; + }; + typedef Node* NodePtr; + typedef BranchStruct BranchSt; + typedef BranchSt* Branch; + + + + void save_tree(FILE* stream, NodePtr tree) + { + save_value(stream, *tree); + if (tree->child1!=NULL) { + save_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + save_tree(stream, tree->child2); + } + } + + + void load_tree(FILE* stream, NodePtr& tree) + { + tree = pool_.allocate(); + load_value(stream, *tree); + if (tree->child1!=NULL) { + load_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + load_tree(stream, tree->child2); + } + } + + + /** + * Create a tree node that subdivides the list of vecs from vind[first] + * to vind[last]. The routine is called recursively on each sublist. + * Place a pointer to this new tree node in the location pTree. + * + * Params: pTree = the new node to create + * first = index of the first vector + * last = index of the last vector + */ + NodePtr divideTree(int* ind, int count) + { + NodePtr node = pool_.allocate(); // allocate memory + + /* If too few exemplars remain, then make this a leaf node. */ + if ( count == 1) { + node->child1 = node->child2 = NULL; /* Mark as leaf node. */ + node->divfeat = *ind; /* Store index of this vec. */ + } + else { + int idx; + int cutfeat; + DistanceType cutval; + meanSplit(ind, count, idx, cutfeat, cutval); + + node->divfeat = cutfeat; + node->divval = cutval; + node->child1 = divideTree(ind, idx); + node->child2 = divideTree(ind+idx, count-idx); + } + + return node; + } + + + /** + * Choose which feature to use in order to subdivide this set of vectors. + * Make a random choice among those with the highest variance, and use + * its variance as the threshold value. + */ + void meanSplit(int* ind, int count, int& index, int& cutfeat, DistanceType& cutval) + { + memset(mean_,0,veclen_*sizeof(DistanceType)); + memset(var_,0,veclen_*sizeof(DistanceType)); + + /* Compute mean values. Only the first SAMPLE_MEAN values need to be + sampled to get a good estimate. + */ + int cnt = std::min((int)SAMPLE_MEAN+1, count); + for (int j = 0; j < cnt; ++j) { + ElementType* v = dataset_[ind[j]]; + for (size_t k=0; kcount/2) index = lim1; + else if (lim2 v[topind[num-1]])) { + /* Put this element at end of topind. */ + if (num < RAND_DIM) { + topind[num++] = i; /* Add to list. */ + } + else { + topind[num-1] = i; /* Replace last element. */ + } + /* Bubble end value down to right location by repeated swapping. */ + int j = num - 1; + while (j > 0 && v[topind[j]] > v[topind[j-1]]) { + std::swap(topind[j], topind[j-1]); + --j; + } + } + } + /* Select a random integer in range [0,num-1], and return that index. */ + int rnd = rand_int(num); + return (int)topind[rnd]; + } + + + /** + * Subdivide the list of points by a plane perpendicular on axe corresponding + * to the 'cutfeat' dimension at 'cutval' position. + * + * On return: + * dataset[ind[0..lim1-1]][cutfeat]cutval + */ + void planeSplit(int* ind, int count, int cutfeat, DistanceType cutval, int& lim1, int& lim2) + { + /* Move vector indices for left subtree to front of list. */ + int left = 0; + int right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]=cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + lim1 = left; + right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]<=cutval) ++left; + while (left<=right && dataset_[ind[right]][cutfeat]>cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + lim2 = left; + } + + /** + * Performs an exact nearest neighbor search. The exact search performs a full + * traversal of the tree. + */ + void getExactNeighbors(ResultSet& result, const ElementType* vec, float epsError) + { + // checkID -= 1; /* Set a different unique ID for each search. */ + + if (trees_ > 1) { + fprintf(stderr,"It doesn't make any sense to use more than one tree for exact search"); + } + if (trees_>0) { + searchLevelExact(result, vec, tree_roots_[0], 0.0, epsError); + } + CV_Assert(result.full()); + } + + /** + * Performs the approximate nearest-neighbor search. The search is approximate + * because the tree traversal is abandoned after a given number of descends in + * the tree. + */ + void getNeighbors(ResultSet& result, const ElementType* vec, + int maxCheck, float epsError, bool explore_all_trees = false) + { + int i; + BranchSt branch; + int checkCount = 0; + DynamicBitset checked(size_); + + // Priority queue storing intermediate branches in the best-bin-first search + const cv::Ptr>& heap = Heap::getPooledInstance(cv::utils::getThreadID(), (int)size_); + + /* Search once through each tree down to root. */ + for (i = 0; i < trees_; ++i) { + searchLevel(result, vec, tree_roots_[i], 0, checkCount, maxCheck, + epsError, heap, checked, explore_all_trees); + if (!explore_all_trees && (checkCount >= maxCheck) && result.full()) + break; + } + + /* Keep searching other branches from heap until finished. */ + while ( heap->popMin(branch) && (checkCount < maxCheck || !result.full() )) { + searchLevel(result, vec, branch.node, branch.mindist, checkCount, maxCheck, + epsError, heap, checked, false); + } + + CV_Assert(result.full()); + } + + + /** + * Search starting from a given node of the tree. Based on any mismatches at + * higher levels, all exemplars below this level must have a distance of + * at least "mindistsq". + */ + void searchLevel(ResultSet& result_set, const ElementType* vec, NodePtr node, DistanceType mindist, int& checkCount, int maxCheck, + float epsError, const cv::Ptr>& heap, DynamicBitset& checked, bool explore_all_trees = false) + { + if (result_set.worstDist()child1 == NULL)&&(node->child2 == NULL)) { + /* Do not check same node more than once when searching multiple trees. + Once a vector is checked, we set its location in vind to the + current checkID. + */ + int index = node->divfeat; + if ( checked.test(index) || + (!explore_all_trees && (checkCount>=maxCheck) && result_set.full()) ) { + return; + } + checked.set(index); + checkCount++; + + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result_set.addPoint(dist,index); + + return; + } + + /* Which child branch should be taken first? */ + ElementType val = vec[node->divfeat]; + DistanceType diff = val - node->divval; + NodePtr bestChild = (diff < 0) ? node->child1 : node->child2; + NodePtr otherChild = (diff < 0) ? node->child2 : node->child1; + + /* Create a branch record for the branch not taken. Add distance + of this feature boundary (we don't attempt to correct for any + use of this feature in a parent node, which is unlikely to + happen and would have only a small effect). Don't bother + adding more branches to heap after halfway point, as cost of + adding exceeds their value. + */ + + DistanceType new_distsq = mindist + distance_.accum_dist(val, node->divval, node->divfeat); + // if (2 * checkCount < maxCheck || !result.full()) { + if ((new_distsq*epsError < result_set.worstDist())|| !result_set.full()) { + heap->insert( BranchSt(otherChild, new_distsq) ); + } + + /* Call recursively to search next level down. */ + searchLevel(result_set, vec, bestChild, mindist, checkCount, maxCheck, epsError, heap, checked); + } + + /** + * Performs an exact search in the tree starting from a node. + */ + void searchLevelExact(ResultSet& result_set, const ElementType* vec, const NodePtr node, DistanceType mindist, const float epsError) + { + /* If this is a leaf node, then do check and return. */ + if ((node->child1 == NULL)&&(node->child2 == NULL)) { + int index = node->divfeat; + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result_set.addPoint(dist,index); + return; + } + + /* Which child branch should be taken first? */ + ElementType val = vec[node->divfeat]; + DistanceType diff = val - node->divval; + NodePtr bestChild = (diff < 0) ? node->child1 : node->child2; + NodePtr otherChild = (diff < 0) ? node->child2 : node->child1; + + /* Create a branch record for the branch not taken. Add distance + of this feature boundary (we don't attempt to correct for any + use of this feature in a parent node, which is unlikely to + happen and would have only a small effect). Don't bother + adding more branches to heap after halfway point, as cost of + adding exceeds their value. + */ + + DistanceType new_distsq = mindist + distance_.accum_dist(val, node->divval, node->divfeat); + + /* Call recursively to search next level down. */ + searchLevelExact(result_set, vec, bestChild, mindist, epsError); + + if (new_distsq*epsError<=result_set.worstDist()) { + searchLevelExact(result_set, vec, otherChild, new_distsq, epsError); + } + } + + +private: + + enum + { + /** + * To improve efficiency, only SAMPLE_MEAN random values are used to + * compute the mean and variance at each level when building a tree. + * A value of 100 seems to perform as well as using all values. + */ + SAMPLE_MEAN = 100, + /** + * Top random dimensions to consider + * + * When creating random trees, the dimension on which to subdivide is + * selected at random from among the top RAND_DIM dimensions with the + * highest variance. A value of 5 works well. + */ + RAND_DIM=5 + }; + + + /** + * Number of randomized trees that are used + */ + int trees_; + + /** + * Array of indices to vectors in the dataset. + */ + std::vector vind_; + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + IndexParams index_params_; + + size_t size_; + size_t veclen_; + + + DistanceType* mean_; + DistanceType* var_; + + + /** + * Array of k-d trees used to find neighbours. + */ + NodePtr* tree_roots_; + + /** + * Pooled memory allocator. + * + * Using a pooled memory allocator is more efficient + * than allocating memory directly when there is a large + * number small of memory allocations. + */ + PooledAllocator pool_; + + Distance distance_; + + +}; // class KDTreeForest + +} + +//! @endcond + +#endif //OPENCV_FLANN_KDTREE_INDEX_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/kdtree_single_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/kdtree_single_index.h new file mode 100644 index 0000000..ed95c3d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/kdtree_single_index.h @@ -0,0 +1,645 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_ +#define OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include + +#include "nn_index.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + +namespace cvflann +{ + +struct KDTreeSingleIndexParams : public IndexParams +{ + KDTreeSingleIndexParams(int leaf_max_size = 10, bool reorder = true, int dim = -1) + { + (*this)["algorithm"] = FLANN_INDEX_KDTREE_SINGLE; + (*this)["leaf_max_size"] = leaf_max_size; + (*this)["reorder"] = reorder; + (*this)["dim"] = dim; + } +}; + + +/** + * Randomized kd-tree index + * + * Contains the k-d trees and other information for indexing a set of points + * for nearest-neighbor matching. + */ +template +class KDTreeSingleIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + + /** + * KDTree constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the kdtree algorithm + */ + KDTreeSingleIndex(const Matrix& inputData, const IndexParams& params = KDTreeSingleIndexParams(), + Distance d = Distance() ) : + dataset_(inputData), index_params_(params), distance_(d) + { + size_ = dataset_.rows; + dim_ = dataset_.cols; + root_node_ = 0; + int dim_param = get_param(params,"dim",-1); + if (dim_param>0) dim_ = dim_param; + leaf_max_size_ = get_param(params,"leaf_max_size",10); + reorder_ = get_param(params,"reorder",true); + + // Create a permutable array of indices to the input vectors. + vind_.resize(size_); + for (size_t i = 0; i < size_; i++) { + vind_[i] = (int)i; + } + } + + KDTreeSingleIndex(const KDTreeSingleIndex&); + KDTreeSingleIndex& operator=(const KDTreeSingleIndex&); + + /** + * Standard destructor + */ + ~KDTreeSingleIndex() + { + if (reorder_) delete[] data_.data; + } + + /** + * Builds the index + */ + void buildIndex() CV_OVERRIDE + { + computeBoundingBox(root_bbox_); + root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree + + if (reorder_) { + delete[] data_.data; + data_ = cvflann::Matrix(new ElementType[size_*dim_], size_, dim_); + for (size_t i=0; i& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE + { + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); + + KNNSimpleResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.init(indices[i], dists[i]); + findNeighbors(resultSet, queries[i], params); + } + } + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + + /** + * Find set of nearest neighbors to vec. Their indices are stored inside + * the result object. + * + * Params: + * result = the result object in which the indices of the nearest-neighbors are stored + * vec = the vector for which to search the nearest neighbors + * maxCheck = the maximum number of restarts (in a best-bin-first manner) + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + float epsError = 1+get_param(searchParams,"eps",0.0f); + + std::vector dists(dim_,0); + DistanceType distsq = computeInitialDistances(vec, dists); + searchLevel(result, vec, root_node_, distsq, dists, epsError); + } + +private: + + + /*--------------------- Internal Data Structures --------------------------*/ + struct Node + { + /** + * Indices of points in leaf node + */ + int left, right; + /** + * Dimension used for subdivision. + */ + int divfeat; + /** + * The values used for subdivision. + */ + DistanceType divlow, divhigh; + /** + * The child nodes. + */ + Node* child1, * child2; + }; + typedef Node* NodePtr; + + + struct Interval + { + DistanceType low, high; + }; + + typedef std::vector BoundingBox; + + typedef BranchStruct BranchSt; + typedef BranchSt* Branch; + + + + + void save_tree(FILE* stream, NodePtr tree) + { + save_value(stream, *tree); + if (tree->child1!=NULL) { + save_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + save_tree(stream, tree->child2); + } + } + + + void load_tree(FILE* stream, NodePtr& tree) + { + tree = pool_.allocate(); + load_value(stream, *tree); + if (tree->child1!=NULL) { + load_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + load_tree(stream, tree->child2); + } + } + + + void computeBoundingBox(BoundingBox& bbox) + { + bbox.resize(dim_); + for (size_t i=0; ibbox[i].high) bbox[i].high = (DistanceType)dataset_[k][i]; + } + } + } + + + /** + * Create a tree node that subdivides the list of vecs from vind[first] + * to vind[last]. The routine is called recursively on each sublist. + * Place a pointer to this new tree node in the location pTree. + * + * Params: pTree = the new node to create + * first = index of the first vector + * last = index of the last vector + */ + NodePtr divideTree(int left, int right, BoundingBox& bbox) + { + NodePtr node = pool_.allocate(); // allocate memory + + /* If too few exemplars remain, then make this a leaf node. */ + if ( (right-left) <= leaf_max_size_) { + node->child1 = node->child2 = NULL; /* Mark as leaf node. */ + node->left = left; + node->right = right; + + // compute bounding-box of leaf points + for (size_t i=0; idataset_[vind_[k]][i]) bbox[i].low=(DistanceType)dataset_[vind_[k]][i]; + if (bbox[i].highdivfeat = cutfeat; + + BoundingBox left_bbox(bbox); + left_bbox[cutfeat].high = cutval; + node->child1 = divideTree(left, left+idx, left_bbox); + + BoundingBox right_bbox(bbox); + right_bbox[cutfeat].low = cutval; + node->child2 = divideTree(left+idx, right, right_bbox); + + node->divlow = left_bbox[cutfeat].high; + node->divhigh = right_bbox[cutfeat].low; + + for (size_t i=0; imax_elem) max_elem = val; + } + } + + void middleSplit(int* ind, int count, int& index, int& cutfeat, DistanceType& cutval, const BoundingBox& bbox) + { + // find the largest span from the approximate bounding box + ElementType max_span = bbox[0].high-bbox[0].low; + cutfeat = 0; + cutval = (bbox[0].high+bbox[0].low)/2; + for (size_t i=1; imax_span) { + max_span = span; + cutfeat = i; + cutval = (bbox[i].high+bbox[i].low)/2; + } + } + + // compute exact span on the found dimension + ElementType min_elem, max_elem; + computeMinMax(ind, count, cutfeat, min_elem, max_elem); + cutval = (min_elem+max_elem)/2; + max_span = max_elem - min_elem; + + // check if a dimension of a largest span exists + size_t k = cutfeat; + for (size_t i=0; imax_span) { + computeMinMax(ind, count, i, min_elem, max_elem); + span = max_elem - min_elem; + if (span>max_span) { + max_span = span; + cutfeat = i; + cutval = (min_elem+max_elem)/2; + } + } + } + int lim1, lim2; + planeSplit(ind, count, cutfeat, cutval, lim1, lim2); + + if (lim1>count/2) index = lim1; + else if (lim2max_span) { + max_span = span; + } + } + DistanceType max_spread = -1; + cutfeat = 0; + for (size_t i=0; i(DistanceType)((1-EPS)*max_span)) { + ElementType min_elem, max_elem; + computeMinMax(ind, count, (int)i, min_elem, max_elem); + DistanceType spread = (DistanceType)(max_elem-min_elem); + if (spread>max_spread) { + cutfeat = (int)i; + max_spread = spread; + } + } + } + // split in the middle + DistanceType split_val = (bbox[cutfeat].low+bbox[cutfeat].high)/2; + ElementType min_elem, max_elem; + computeMinMax(ind, count, cutfeat, min_elem, max_elem); + + if (split_valmax_elem) cutval = (DistanceType)max_elem; + else cutval = split_val; + + int lim1, lim2; + planeSplit(ind, count, cutfeat, cutval, lim1, lim2); + + if (lim1>count/2) index = lim1; + else if (lim2cutval + */ + void planeSplit(int* ind, int count, int cutfeat, DistanceType cutval, int& lim1, int& lim2) + { + /* Move vector indices for left subtree to front of list. */ + int left = 0; + int right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]=cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + /* If either list is empty, it means that all remaining features + * are identical. Split in the middle to maintain a balanced tree. + */ + lim1 = left; + right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]<=cutval) ++left; + while (left<=right && dataset_[ind[right]][cutfeat]>cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + lim2 = left; + } + + DistanceType computeInitialDistances(const ElementType* vec, std::vector& dists) + { + DistanceType distsq = 0.0; + + for (size_t i = 0; i < dim_; ++i) { + if (vec[i] < root_bbox_[i].low) { + dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, (int)i); + distsq += dists[i]; + } + if (vec[i] > root_bbox_[i].high) { + dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, (int)i); + distsq += dists[i]; + } + } + + return distsq; + } + + /** + * Performs an exact search in the tree starting from a node. + */ + void searchLevel(ResultSet& result_set, const ElementType* vec, const NodePtr node, DistanceType mindistsq, + std::vector& dists, const float epsError) + { + /* If this is a leaf node, then do check and return. */ + if ((node->child1 == NULL)&&(node->child2 == NULL)) { + DistanceType worst_dist = result_set.worstDist(); + if (reorder_) { + for (int i=node->left; iright; ++i) { + DistanceType dist = distance_(vec, data_[i], dim_, worst_dist); + if (distleft; iright; ++i) { + DistanceType dist = distance_(vec, data_[vind_[i]], dim_, worst_dist); + if (distdivfeat; + ElementType val = vec[idx]; + DistanceType diff1 = val - node->divlow; + DistanceType diff2 = val - node->divhigh; + + NodePtr bestChild; + NodePtr otherChild; + DistanceType cut_dist; + if ((diff1+diff2)<0) { + bestChild = node->child1; + otherChild = node->child2; + cut_dist = distance_.accum_dist(val, node->divhigh, idx); + } + else { + bestChild = node->child2; + otherChild = node->child1; + cut_dist = distance_.accum_dist( val, node->divlow, idx); + } + + /* Call recursively to search next level down. */ + searchLevel(result_set, vec, bestChild, mindistsq, dists, epsError); + + DistanceType dst = dists[idx]; + mindistsq = mindistsq + cut_dist - dst; + dists[idx] = cut_dist; + if (mindistsq*epsError<=result_set.worstDist()) { + searchLevel(result_set, vec, otherChild, mindistsq, dists, epsError); + } + dists[idx] = dst; + } + +private: + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + IndexParams index_params_; + + int leaf_max_size_; + bool reorder_; + + + /** + * Array of indices to vectors in the dataset. + */ + std::vector vind_; + + Matrix data_; + + size_t size_; + size_t dim_; + + /** + * Array of k-d trees used to find neighbours. + */ + NodePtr root_node_; + + BoundingBox root_bbox_; + + /** + * Pooled memory allocator. + * + * Using a pooled memory allocator is more efficient + * than allocating memory directly when there is a large + * number small of memory allocations. + */ + PooledAllocator pool_; + + Distance distance_; +}; // class KDTree + +} + +//! @endcond + +#endif //OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/kmeans_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/kmeans_index.h new file mode 100644 index 0000000..fd7fe2b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/kmeans_index.h @@ -0,0 +1,1819 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_KMEANS_INDEX_H_ +#define OPENCV_FLANN_KMEANS_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include +#include + +#include "general.h" +#include "nn_index.h" +#include "dist.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" +#include "logger.h" + +#define BITS_PER_CHAR 8 +#define BITS_PER_BASE 2 // for DNA/RNA sequences +#define BASE_PER_CHAR (BITS_PER_CHAR/BITS_PER_BASE) +#define HISTOS_PER_BASE (1< +class KMeansIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + typedef typename Distance::CentersType CentersType; + + typedef typename Distance::is_kdtree_distance is_kdtree_distance; + typedef typename Distance::is_vector_space_distance is_vector_space_distance; + + + + typedef void (KMeansIndex::* centersAlgFunction)(int, int*, int, int*, int&); + + /** + * The function used for choosing the cluster centers. + */ + centersAlgFunction chooseCenters; + + + + /** + * Chooses the initial centers in the k-means clustering in a random manner. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * indices_length = length of indices vector + * + */ + void chooseCentersRandom(int k, int* indices, int indices_length, int* centers, int& centers_length) + { + UniqueRandom r(indices_length); + + int index; + for (index=0; index=0 && rnd < n); + + centers[0] = indices[rnd]; + + int index; + for (index=1; indexbest_val) { + best_val = dist; + best_index = j; + } + } + if (best_index!=-1) { + centers[index] = indices[best_index]; + } + else { + break; + } + } + centers_length = index; + } + + + /** + * Chooses the initial centers in the k-means using the algorithm + * proposed in the KMeans++ paper: + * Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding + * + * Implementation of this function was converted from the one provided in Arthur's code. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * Returns: + */ + void chooseCentersKMeanspp(int k, int* indices, int indices_length, int* centers, int& centers_length) + { + int n = indices_length; + + double currentPot = 0; + DistanceType* closestDistSq = new DistanceType[n]; + + // Choose one random center and set the closestDistSq values + int index = rand_int(n); + CV_DbgAssert(index >=0 && index < n); + centers[0] = indices[index]; + + for (int i = 0; i < n; i++) { + closestDistSq[i] = distance_(dataset_[indices[i]], dataset_[indices[index]], dataset_.cols); + closestDistSq[i] = ensureSquareDistance( closestDistSq[i] ); + currentPot += closestDistSq[i]; + } + + + const int numLocalTries = 1; + + // Choose each center + int centerCount; + for (centerCount = 1; centerCount < k; centerCount++) { + + // Repeat several trials + double bestNewPot = -1; + int bestNewIndex = -1; + for (int localTrial = 0; localTrial < numLocalTries; localTrial++) { + + // Choose our center - have to be slightly careful to return a valid answer even accounting + // for possible rounding errors + double randVal = rand_double(currentPot); + for (index = 0; index < n-1; index++) { + if (randVal <= closestDistSq[index]) break; + else randVal -= closestDistSq[index]; + } + + // Compute the new potential + double newPot = 0; + for (int i = 0; i < n; i++) { + DistanceType dist = distance_(dataset_[indices[i]], dataset_[indices[index]], dataset_.cols); + newPot += std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + + // Store the best result + if ((bestNewPot < 0)||(newPot < bestNewPot)) { + bestNewPot = newPot; + bestNewIndex = index; + } + } + + // Add the appropriate center + centers[centerCount] = indices[bestNewIndex]; + currentPot = bestNewPot; + for (int i = 0; i < n; i++) { + DistanceType dist = distance_(dataset_[indices[i]], dataset_[indices[bestNewIndex]], dataset_.cols); + closestDistSq[i] = std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + } + + centers_length = centerCount; + + delete[] closestDistSq; + } + + + +public: + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_KMEANS; + } + + template + class KMeansDistanceComputer : public cv::ParallelLoopBody + { + public: + KMeansDistanceComputer(Distance _distance, const Matrix& _dataset, + const int _branching, const int* _indices, const CentersContainerType& _dcenters, + const size_t _veclen, std::vector &_new_centroids, + std::vector &_sq_dists) + : distance(_distance) + , dataset(_dataset) + , branching(_branching) + , indices(_indices) + , dcenters(_dcenters) + , veclen(_veclen) + , new_centroids(_new_centroids) + , sq_dists(_sq_dists) + { + } + + void operator()(const cv::Range& range) const CV_OVERRIDE + { + const int begin = range.start; + const int end = range.end; + + for( int i = begin; inew_sq_dist) { + new_centroid = j; + sq_dist = new_sq_dist; + } + } + sq_dists[i] = sq_dist; + new_centroids[i] = new_centroid; + } + } + + private: + Distance distance; + const Matrix& dataset; + const int branching; + const int* indices; + const CentersContainerType& dcenters; + const size_t veclen; + std::vector &new_centroids; + std::vector &sq_dists; + KMeansDistanceComputer& operator=( const KMeansDistanceComputer & ) { return *this; } + }; + + /** + * Index constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the hierarchical k-means algorithm + */ + KMeansIndex(const Matrix& inputData, const IndexParams& params = KMeansIndexParams(), + Distance d = Distance()) + : dataset_(inputData), index_params_(params), root_(NULL), indices_(NULL), distance_(d) + { + memoryCounter_ = 0; + + size_ = dataset_.rows; + veclen_ = dataset_.cols; + + branching_ = get_param(params,"branching",32); + trees_ = get_param(params,"trees",1); + iterations_ = get_param(params,"iterations",11); + if (iterations_<0) { + iterations_ = (std::numeric_limits::max)(); + } + centers_init_ = get_param(params,"centers_init",FLANN_CENTERS_RANDOM); + + if (centers_init_==FLANN_CENTERS_RANDOM) { + chooseCenters = &KMeansIndex::chooseCentersRandom; + } + else if (centers_init_==FLANN_CENTERS_GONZALES) { + chooseCenters = &KMeansIndex::chooseCentersGonzales; + } + else if (centers_init_==FLANN_CENTERS_KMEANSPP) { + chooseCenters = &KMeansIndex::chooseCentersKMeanspp; + } + else { + FLANN_THROW(cv::Error::StsBadArg, "Unknown algorithm for choosing initial centers."); + } + cb_index_ = 0.4f; + + root_ = new KMeansNodePtr[trees_]; + indices_ = new int*[trees_]; + + for (int i=0; i(); + std::memset(root_[i], 0, sizeof(KMeansNode)); + + Distance* dummy = NULL; + computeNodeStatistics(root_[i], indices_[i], (unsigned int)size_, dummy); + + computeClustering(root_[i], indices_[i], (int)size_, branching_,0); + } + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, branching_); + save_value(stream, iterations_); + save_value(stream, memoryCounter_); + save_value(stream, cb_index_); + save_value(stream, trees_); + for (int i=0; i& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + + const int maxChecks = get_param(searchParams,"checks",32); + + if (maxChecks==FLANN_CHECKS_UNLIMITED) { + findExactNN(root_[0], result, vec); + } + else { + // Priority queue storing intermediate branches in the best-bin-first search + const cv::Ptr>& heap = Heap::getPooledInstance(cv::utils::getThreadID(), (int)size_); + + int checks = 0; + for (int i=0; i= maxChecks) && result.full()) + break; + } + + BranchSt branch; + while (heap->popMin(branch) && (checks& centers) + { + int numClusters = centers.rows; + if (numClusters<1) { + FLANN_THROW(cv::Error::StsBadArg, "Number of clusters must be at least 1"); + } + + DistanceType variance; + KMeansNodePtr* clusters = new KMeansNodePtr[numClusters]; + + int clusterCount = getMinVarianceClusters(root_[0], clusters, numClusters, variance); + + Logger::info("Clusters requested: %d, returning %d\n",numClusters, clusterCount); + + for (int i=0; ipivot; + for (size_t j=0; j BranchSt; + + + + + void save_tree(FILE* stream, KMeansNodePtr node, int num) + { + save_value(stream, *node); + save_value(stream, *(node->pivot), (int)veclen_); + if (node->childs==NULL) { + int indices_offset = (int)(node->indices - indices_[num]); + save_value(stream, indices_offset); + } + else { + for(int i=0; ichilds[i], num); + } + } + } + + + void load_tree(FILE* stream, KMeansNodePtr& node, int num) + { + node = pool_.allocate(); + load_value(stream, *node); + node->pivot = new CentersType[veclen_]; + load_value(stream, *(node->pivot), (int)veclen_); + if (node->childs==NULL) { + int indices_offset; + load_value(stream, indices_offset); + node->indices = indices_[num] + indices_offset; + } + else { + node->childs = pool_.allocate(branching_); + for(int i=0; ichilds[i], num); + } + } + } + + + /** + * Helper function + */ + void free_centers(KMeansNodePtr node) + { + delete[] node->pivot; + if (node->childs!=NULL) { + for (int k=0; kchilds[k]); + } + } + } + + void free_centers() + { + if (root_ != NULL) { + for(int i=0; i(), veclen_); + } + float length = static_cast(indices_length); + for (size_t j=0; j( mean[j] / static_cast(indices_length) ); + } + variance /= static_cast( length ); + variance -= distance_(mean, ZeroIterator(), veclen_); + + DistanceType radius = 0; + for (unsigned int i=0; iradius) { + radius = tmp; + } + } + + node->variance = variance; + node->radius = radius; + node->pivot = mean; + } + + + void computeBitfieldNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length) + { + const unsigned int accumulator_veclen = static_cast( + veclen_*sizeof(CentersType)*BITS_PER_CHAR); + + unsigned long long variance = 0ull; + CentersType* mean = new CentersType[veclen_]; + memoryCounter_ += int(veclen_*sizeof(CentersType)); + unsigned int* mean_accumulator = new unsigned int[accumulator_veclen]; + + memset(mean_accumulator, 0, sizeof(unsigned int)*accumulator_veclen); + + for (unsigned int i=0; i( ensureSquareDistance( + distance_(dataset_[indices[i]], ZeroIterator(), veclen_))); + unsigned char* vec = (unsigned char*)dataset_[indices[i]]; + for (size_t k=0, l=0; k>1) & 0x01; + mean_accumulator[k+2] += (vec[l]>>2) & 0x01; + mean_accumulator[k+3] += (vec[l]>>3) & 0x01; + mean_accumulator[k+4] += (vec[l]>>4) & 0x01; + mean_accumulator[k+5] += (vec[l]>>5) & 0x01; + mean_accumulator[k+6] += (vec[l]>>6) & 0x01; + mean_accumulator[k+7] += (vec[l]>>7) & 0x01; + } + } + double cnt = static_cast(indices_length); + unsigned char* char_mean = (unsigned char*)mean; + for (size_t k=0, l=0; k( + (((int)(0.5 + (double)(mean_accumulator[k]) / cnt))) + | (((int)(0.5 + (double)(mean_accumulator[k+1]) / cnt))<<1) + | (((int)(0.5 + (double)(mean_accumulator[k+2]) / cnt))<<2) + | (((int)(0.5 + (double)(mean_accumulator[k+3]) / cnt))<<3) + | (((int)(0.5 + (double)(mean_accumulator[k+4]) / cnt))<<4) + | (((int)(0.5 + (double)(mean_accumulator[k+5]) / cnt))<<5) + | (((int)(0.5 + (double)(mean_accumulator[k+6]) / cnt))<<6) + | (((int)(0.5 + (double)(mean_accumulator[k+7]) / cnt))<<7)); + } + variance = static_cast( + 0.5 + static_cast(variance) / static_cast(indices_length)); + variance -= static_cast( + ensureSquareDistance( + distance_(mean, ZeroIterator(), veclen_))); + + DistanceType radius = 0; + for (unsigned int i=0; iradius) { + radius = tmp; + } + } + + node->variance = static_cast(variance); + node->radius = radius; + node->pivot = mean; + + delete[] mean_accumulator; + } + + + void computeDnaNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length) + { + const unsigned int histos_veclen = static_cast( + veclen_*sizeof(CentersType)*(HISTOS_PER_BASE*BASE_PER_CHAR)); + + unsigned long long variance = 0ull; + unsigned int* histograms = new unsigned int[histos_veclen]; + memset(histograms, 0, sizeof(unsigned int)*histos_veclen); + + for (unsigned int i=0; i( ensureSquareDistance( + distance_(dataset_[indices[i]], ZeroIterator(), veclen_))); + + unsigned char* vec = (unsigned char*)dataset_[indices[i]]; + for (size_t k=0, l=0; k>2) & 0x03)]++; + histograms[k + 8 + ((vec[l]>>4) & 0x03)]++; + histograms[k +12 + ((vec[l]>>6) & 0x03)]++; + } + } + + CentersType* mean = new CentersType[veclen_]; + memoryCounter_ += int(veclen_*sizeof(CentersType)); + unsigned char* char_mean = (unsigned char*)mean; + unsigned int* h = histograms; + for (size_t k=0, l=0; k h[k+1] ? h[k+2] > h[k+3] ? h[k] > h[k+2] ? 0x00 : 0x10 + : h[k] > h[k+3] ? 0x00 : 0x11 + : h[k+2] > h[k+3] ? h[k+1] > h[k+2] ? 0x01 : 0x10 + : h[k+1] > h[k+3] ? 0x01 : 0x11) + | (h[k+4]>h[k+5] ? h[k+6] > h[k+7] ? h[k+4] > h[k+6] ? 0x00 : 0x1000 + : h[k+4] > h[k+7] ? 0x00 : 0x1100 + : h[k+6] > h[k+7] ? h[k+5] > h[k+6] ? 0x0100 : 0x1000 + : h[k+5] > h[k+7] ? 0x0100 : 0x1100) + | (h[k+8]>h[k+9] ? h[k+10]>h[k+11] ? h[k+8] >h[k+10] ? 0x00 : 0x100000 + : h[k+8] >h[k+11] ? 0x00 : 0x110000 + : h[k+10]>h[k+11] ? h[k+9] >h[k+10] ? 0x010000 : 0x100000 + : h[k+9] >h[k+11] ? 0x010000 : 0x110000) + | (h[k+12]>h[k+13] ? h[k+14]>h[k+15] ? h[k+12] >h[k+14] ? 0x00 : 0x10000000 + : h[k+12] >h[k+15] ? 0x00 : 0x11000000 + : h[k+14]>h[k+15] ? h[k+13] >h[k+14] ? 0x01000000 : 0x10000000 + : h[k+13] >h[k+15] ? 0x01000000 : 0x11000000); + } + variance = static_cast( + 0.5 + static_cast(variance) / static_cast(indices_length)); + variance -= static_cast( + ensureSquareDistance( + distance_(mean, ZeroIterator(), veclen_))); + + DistanceType radius = 0; + for (unsigned int i=0; iradius) { + radius = tmp; + } + } + + node->variance = static_cast(variance); + node->radius = radius; + node->pivot = mean; + + delete[] histograms; + } + + + template + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const DistType* identifier) + { + (void)identifier; + computeNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::HammingLUT* identifier) + { + (void)identifier; + computeBitfieldNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::Hamming* identifier) + { + (void)identifier; + computeBitfieldNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::Hamming2* identifier) + { + (void)identifier; + computeBitfieldNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::DNAmmingLUT* identifier) + { + (void)identifier; + computeDnaNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::DNAmming2* identifier) + { + (void)identifier; + computeDnaNodeStatistics(node, indices, indices_length); + } + + + void refineClustering(int* indices, int indices_length, int branching, CentersType** centers, + std::vector& radiuses, int* belongs_to, int* count) + { + cv::AutoBuffer dcenters_buf(branching*veclen_); + Matrix dcenters(dcenters_buf.data(), branching, veclen_); + + bool converged = false; + int iteration = 0; + while (!converged && iteration new_centroids(indices_length); + std::vector sq_dists(indices_length); + + // reassign points to clusters + KMeansDistanceComputer > invoker( + distance_, dataset_, branching, indices, dcenters, veclen_, new_centroids, sq_dists); + parallel_for_(cv::Range(0, (int)indices_length), invoker); + + for (int i=0; i < (int)indices_length; ++i) { + DistanceType sq_dist(sq_dists[i]); + int new_centroid(new_centroids[i]); + if (sq_dist > radiuses[new_centroid]) { + radiuses[new_centroid] = sq_dist; + } + if (new_centroid != belongs_to[i]) { + count[belongs_to[i]]--; + count[new_centroid]++; + belongs_to[i] = new_centroid; + converged = false; + } + } + + for (int i=0; i& radiuses, int* belongs_to, int* count) + { + for (int i=0; i( + veclen_*sizeof(ElementType)*BITS_PER_CHAR); + cv::AutoBuffer dcenters_buf(branching*accumulator_veclen); + Matrix dcenters(dcenters_buf.data(), branching, accumulator_veclen); + + bool converged = false; + int iteration = 0; + while (!converged && iteration>1) & 0x01; + dcenter[k+2] += (vec[l]>>2) & 0x01; + dcenter[k+3] += (vec[l]>>3) & 0x01; + dcenter[k+4] += (vec[l]>>4) & 0x01; + dcenter[k+5] += (vec[l]>>5) & 0x01; + dcenter[k+6] += (vec[l]>>6) & 0x01; + dcenter[k+7] += (vec[l]>>7) & 0x01; + } + } + for (int i=0; i(count[i]); + unsigned int* dcenter = dcenters[i]; + unsigned char* charCenter = (unsigned char*)centers[i]; + for (size_t k=0, l=0; k( + (((int)(0.5 + (double)(dcenter[k]) / cnt))) + | (((int)(0.5 + (double)(dcenter[k+1]) / cnt))<<1) + | (((int)(0.5 + (double)(dcenter[k+2]) / cnt))<<2) + | (((int)(0.5 + (double)(dcenter[k+3]) / cnt))<<3) + | (((int)(0.5 + (double)(dcenter[k+4]) / cnt))<<4) + | (((int)(0.5 + (double)(dcenter[k+5]) / cnt))<<5) + | (((int)(0.5 + (double)(dcenter[k+6]) / cnt))<<6) + | (((int)(0.5 + (double)(dcenter[k+7]) / cnt))<<7)); + } + } + + std::vector new_centroids(indices_length); + std::vector dists(indices_length); + + // reassign points to clusters + KMeansDistanceComputer invoker( + distance_, dataset_, branching, indices, centers, veclen_, new_centroids, dists); + parallel_for_(cv::Range(0, (int)indices_length), invoker); + + for (int i=0; i < indices_length; ++i) { + DistanceType dist(dists[i]); + int new_centroid(new_centroids[i]); + if (dist > radiuses[new_centroid]) { + radiuses[new_centroid] = dist; + } + if (new_centroid != belongs_to[i]) { + count[belongs_to[i]]--; + count[new_centroid]++; + belongs_to[i] = new_centroid; + converged = false; + } + } + + for (int i=0; i& radiuses, int* belongs_to, int* count) + { + for (int i=0; i( + veclen_*sizeof(CentersType)*(HISTOS_PER_BASE*BASE_PER_CHAR)); + cv::AutoBuffer histos_buf(branching*histos_veclen); + Matrix histos(histos_buf.data(), branching, histos_veclen); + + bool converged = false; + int iteration = 0; + while (!converged && iteration>2) & 0x03)]++; + h[k + 8 + ((vec[l]>>4) & 0x03)]++; + h[k +12 + ((vec[l]>>6) & 0x03)]++; + } + } + for (int i=0; i h[k+1] ? h[k+2] > h[k+3] ? h[k] > h[k+2] ? 0x00 : 0x10 + : h[k] > h[k+3] ? 0x00 : 0x11 + : h[k+2] > h[k+3] ? h[k+1] > h[k+2] ? 0x01 : 0x10 + : h[k+1] > h[k+3] ? 0x01 : 0x11) + | (h[k+4]>h[k+5] ? h[k+6] > h[k+7] ? h[k+4] > h[k+6] ? 0x00 : 0x1000 + : h[k+4] > h[k+7] ? 0x00 : 0x1100 + : h[k+6] > h[k+7] ? h[k+5] > h[k+6] ? 0x0100 : 0x1000 + : h[k+5] > h[k+7] ? 0x0100 : 0x1100) + | (h[k+8]>h[k+9] ? h[k+10]>h[k+11] ? h[k+8] >h[k+10] ? 0x00 : 0x100000 + : h[k+8] >h[k+11] ? 0x00 : 0x110000 + : h[k+10]>h[k+11] ? h[k+9] >h[k+10] ? 0x010000 : 0x100000 + : h[k+9] >h[k+11] ? 0x010000 : 0x110000) + | (h[k+12]>h[k+13] ? h[k+14]>h[k+15] ? h[k+12] >h[k+14] ? 0x00 : 0x10000000 + : h[k+12] >h[k+15] ? 0x00 : 0x11000000 + : h[k+14]>h[k+15] ? h[k+13] >h[k+14] ? 0x01000000 : 0x10000000 + : h[k+13] >h[k+15] ? 0x01000000 : 0x11000000); + } + } + + std::vector new_centroids(indices_length); + std::vector dists(indices_length); + + // reassign points to clusters + KMeansDistanceComputer invoker( + distance_, dataset_, branching, indices, centers, veclen_, new_centroids, dists); + parallel_for_(cv::Range(0, (int)indices_length), invoker); + + for (int i=0; i < indices_length; ++i) { + DistanceType dist(dists[i]); + int new_centroid(new_centroids[i]); + if (dist > radiuses[new_centroid]) { + radiuses[new_centroid] = dist; + } + if (new_centroid != belongs_to[i]) { + count[belongs_to[i]]--; + count[new_centroid]++; + belongs_to[i] = new_centroid; + converged = false; + } + } + + for (int i=0; i& radiuses, int* belongs_to, int* count) + { + // compute kmeans clustering for each of the resulting clusters + node->childs = pool_.allocate(branching); + int start = 0; + int end = start; + for (int c=0; c(), veclen_); + variance += d; + mean_radius += static_cast( sqrt(d) ); + std::swap(indices[i],indices[end]); + std::swap(belongs_to[i],belongs_to[end]); + end++; + } + } + variance /= s; + mean_radius /= s; + variance -= distance_(centers[c], ZeroIterator(), veclen_); + + node->childs[c] = pool_.allocate(); + std::memset(node->childs[c], 0, sizeof(KMeansNode)); + node->childs[c]->radius = radiuses[c]; + node->childs[c]->pivot = centers[c]; + node->childs[c]->variance = variance; + node->childs[c]->mean_radius = mean_radius; + computeClustering(node->childs[c],indices+start, end-start, branching, level+1); + start=end; + } + } + + + void computeAnyBitfieldSubClustering(KMeansNodePtr node, int* indices, int indices_length, + int branching, int level, CentersType** centers, + std::vector& radiuses, int* belongs_to, int* count) + { + // compute kmeans clustering for each of the resulting clusters + node->childs = pool_.allocate(branching); + int start = 0; + int end = start; + for (int c=0; c(), veclen_); + variance += static_cast( ensureSquareDistance(d) ); + mean_radius += ensureSimpleDistance(d); + std::swap(indices[i],indices[end]); + std::swap(belongs_to[i],belongs_to[end]); + end++; + } + } + mean_radius = static_cast( + 0.5f + static_cast(mean_radius) / static_cast(s)); + variance = static_cast( + 0.5 + static_cast(variance) / static_cast(s)); + variance -= static_cast( + ensureSquareDistance( + distance_(centers[c], ZeroIterator(), veclen_))); + + node->childs[c] = pool_.allocate(); + std::memset(node->childs[c], 0, sizeof(KMeansNode)); + node->childs[c]->radius = radiuses[c]; + node->childs[c]->pivot = centers[c]; + node->childs[c]->variance = static_cast(variance); + node->childs[c]->mean_radius = mean_radius; + computeClustering(node->childs[c],indices+start, end-start, branching, level+1); + start=end; + } + } + + + template + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const DistType* identifier) + { + (void)identifier; + refineClustering(indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + /** + * The methods responsible with doing the recursive hierarchical clustering on + * binary vectors. + * As some might have heard that KMeans on binary data doesn't make sense, + * it's worth a little explanation why it actually fairly works. As + * with the Hierarchical Clustering algortihm, we seed several centers for the + * current node by picking some of its points. Then in a first pass each point + * of the node is then related to its closest center. Now let's have a look at + * the 5 central dimensions of the 9 following points: + * + * xxxxxx11100xxxxx (1) + * xxxxxx11010xxxxx (2) + * xxxxxx11001xxxxx (3) + * xxxxxx10110xxxxx (4) + * xxxxxx10101xxxxx (5) + * xxxxxx10011xxxxx (6) + * xxxxxx01110xxxxx (7) + * xxxxxx01101xxxxx (8) + * xxxxxx01011xxxxx (9) + * sum _____ + * of 1: 66555 + * + * Even if the barycenter notion doesn't apply, we can set a center + * xxxxxx11111xxxxx that will better fit the five dimensions we are focusing + * on for these points. + * + * Note that convergence isn't ensured anymore. In practice, using Gonzales + * as seeding algorithm should be fine for getting convergence ("iterations" + * value can be set to -1). But with KMeans++ seeding you should definitely + * set a maximum number of iterations (but make it higher than the "iterations" + * default value of 11). + * + * Params: + * node = the node to cluster + * indices = indices of the points belonging to the current node + * indices_length = number of points in the current node + * branching = the branching factor to use in the clustering + * level = 0 for the root node, it increases with the subdivision levels + * centers = clusters centers to compute + * radiuses = radiuses of clusters + * belongs_to = LookUp Table returning, for a given indice id, the center id it belongs to + * count = array storing the number of indices for a given center id + * identifier = dummy pointer on an instance of Distance (use to branch correctly among templates) + */ + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::HammingLUT* identifier) + { + (void)identifier; + refineBitfieldClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::Hamming* identifier) + { + (void)identifier; + refineBitfieldClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::Hamming2* identifier) + { + (void)identifier; + refineBitfieldClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::DNAmmingLUT* identifier) + { + (void)identifier; + refineDnaClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::DNAmming2* identifier) + { + (void)identifier; + refineDnaClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + /** + * The method responsible with actually doing the recursive hierarchical + * clustering + * + * Params: + * node = the node to cluster + * indices = indices of the points belonging to the current node + * branching = the branching factor to use in the clustering + * + * TODO: for 1-sized clusters don't store a cluster center (it's the same as the single cluster point) + */ + void computeClustering(KMeansNodePtr node, int* indices, int indices_length, int branching, int level) + { + node->size = indices_length; + node->level = level; + + if (indices_length < branching) { + node->indices = indices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + cv::AutoBuffer centers_idx_buf(branching); + int* centers_idx = centers_idx_buf.data(); + int centers_length; + (this->*chooseCenters)(branching, indices, indices_length, centers_idx, centers_length); + + if (centers_lengthindices = indices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + + std::vector radiuses(branching); + cv::AutoBuffer count_buf(branching); + int* count = count_buf.data(); + for (int i=0; i belongs_to_buf(indices_length); + int* belongs_to = belongs_to_buf.data(); + for (int i=0; inew_sq_dist) { + belongs_to[i] = j; + sq_dist = new_sq_dist; + } + } + if (sq_dist>radiuses[belongs_to[i]]) { + radiuses[belongs_to[i]] = sq_dist; + } + count[belongs_to[i]]++; + } + + CentersType** centers = new CentersType*[branching]; + + Distance* dummy = NULL; + refineAndSplitClustering(node, indices, indices_length, branching, level, + centers, radiuses, belongs_to, count, dummy); + + delete[] centers; + } + + + /** + * Performs one descent in the hierarchical k-means tree. The branches not + * visited are stored in a priority queue. + * + * Params: + * node = node to explore + * result = container for the k-nearest neighbors found + * vec = query points + * checks = how many points in the dataset have been checked so far + * maxChecks = maximum dataset points to checks + */ + + + void findNN(KMeansNodePtr node, ResultSet& result, const ElementType* vec, int& checks, int maxChecks, + const cv::Ptr>& heap) + { + // Ignore those clusters that are too far away + { + DistanceType bsq = distance_(vec, node->pivot, veclen_); + DistanceType rsq = node->radius; + DistanceType wsq = result.worstDist(); + + if (isSquareDistance()) + { + DistanceType val = bsq-rsq-wsq; + if ((val>0) && (val*val > 4*rsq*wsq)) + return; + } + else + { + if (bsq-rsq > wsq) + return; + } + } + + if (node->childs==NULL) { + if ((checks>=maxChecks) && result.full()) { + return; + } + checks += node->size; + for (int i=0; isize; ++i) { + int index = node->indices[i]; + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result.addPoint(dist, index); + } + } + else { + DistanceType* domain_distances = new DistanceType[branching_]; + int closest_center = exploreNodeBranches(node, vec, domain_distances, heap); + delete[] domain_distances; + findNN(node->childs[closest_center],result,vec, checks, maxChecks, heap); + } + } + + /** + * Helper function that computes the nearest childs of a node to a given query point. + * Params: + * node = the node + * q = the query point + * distances = array with the distances to each child node. + * Returns: + */ + int exploreNodeBranches(KMeansNodePtr node, const ElementType* q, DistanceType* domain_distances, const cv::Ptr>& heap) + { + + int best_index = 0; + domain_distances[best_index] = distance_(q, node->childs[best_index]->pivot, veclen_); + for (int i=1; ichilds[i]->pivot, veclen_); + if (domain_distances[i]childs[best_index]->pivot; + for (int i=0; i( + cb_index_*node->childs[i]->variance ); + + // float dist_to_border = getDistanceToBorder(node.childs[i].pivot,best_center,q); + // if (domain_distances[i]insert(BranchSt(node->childs[i],domain_distances[i])); + } + } + + return best_index; + } + + + /** + * Function the performs exact nearest neighbor search by traversing the entire tree. + */ + void findExactNN(KMeansNodePtr node, ResultSet& result, const ElementType* vec) + { + // Ignore those clusters that are too far away + { + DistanceType bsq = distance_(vec, node->pivot, veclen_); + DistanceType rsq = node->radius; + DistanceType wsq = result.worstDist(); + + if (isSquareDistance()) + { + DistanceType val = bsq-rsq-wsq; + if ((val>0) && (val*val > 4*rsq*wsq)) + return; + } + else + { + if (bsq-rsq > wsq) + return; + } + } + + + if (node->childs==NULL) { + for (int i=0; isize; ++i) { + int index = node->indices[i]; + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result.addPoint(dist, index); + } + } + else { + int* sort_indices = new int[branching_]; + + getCenterOrdering(node, vec, sort_indices); + + for (int i=0; ichilds[sort_indices[i]],result,vec); + } + + delete[] sort_indices; + } + } + + + /** + * Helper function. + * + * I computes the order in which to traverse the child nodes of a particular node. + */ + void getCenterOrdering(KMeansNodePtr node, const ElementType* q, int* sort_indices) + { + DistanceType* domain_distances = new DistanceType[branching_]; + for (int i=0; ichilds[i]->pivot, veclen_); + + int j=0; + while (domain_distances[j]j; --k) { + domain_distances[k] = domain_distances[k-1]; + sort_indices[k] = sort_indices[k-1]; + } + domain_distances[j] = dist; + sort_indices[j] = i; + } + delete[] domain_distances; + } + + /** + * Method that computes the squared distance from the query point q + * from inside region with center c to the border between this + * region and the region with center p + */ + DistanceType getDistanceToBorder(DistanceType* p, DistanceType* c, DistanceType* q) + { + DistanceType sum = 0; + DistanceType sum2 = 0; + + for (int i=0; ivariance*root->size; + + while (clusterCount::max)(); + int splitIndex = -1; + + for (int i=0; ichilds != NULL) { + + DistanceType variance = meanVariance - clusters[i]->variance*clusters[i]->size; + + for (int j=0; jchilds[j]->variance*clusters[i]->childs[j]->size; + } + if (variance clusters_length) break; + + meanVariance = minVariance; + + // split node + KMeansNodePtr toSplit = clusters[splitIndex]; + clusters[splitIndex] = toSplit->childs[0]; + for (int i=1; ichilds[i]; + } + } + + varianceValue = meanVariance/root->size; + return clusterCount; + } + +private: + /** The branching factor used in the hierarchical k-means clustering */ + int branching_; + + /** Number of kmeans trees (default is one) */ + int trees_; + + /** Maximum number of iterations to use when performing k-means clustering */ + int iterations_; + + /** Algorithm for choosing the cluster centers */ + flann_centers_init_t centers_init_; + + /** + * Cluster border index. This is used in the tree search phase when determining + * the closest cluster to explore next. A zero value takes into account only + * the cluster centres, a value greater then zero also take into account the size + * of the cluster. + */ + float cb_index_; + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + /** Index parameters */ + IndexParams index_params_; + + /** + * Number of features in the dataset. + */ + size_t size_; + + /** + * Length of each feature. + */ + size_t veclen_; + + /** + * The root node in the tree. + */ + KMeansNodePtr* root_; + + /** + * Array of indices to vectors in the dataset. + */ + int** indices_; + + /** + * The distance + */ + Distance distance_; + + /** + * Pooled memory allocator. + */ + PooledAllocator pool_; + + /** + * Memory occupied by the index. + */ + int memoryCounter_; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_KMEANS_INDEX_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/linear_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/linear_index.h new file mode 100644 index 0000000..6428c0d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/linear_index.h @@ -0,0 +1,135 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_LINEAR_INDEX_H_ +#define OPENCV_FLANN_LINEAR_INDEX_H_ + +//! @cond IGNORED + +#include "nn_index.h" + +namespace cvflann +{ + +struct LinearIndexParams : public IndexParams +{ + LinearIndexParams() + { + (* this)["algorithm"] = FLANN_INDEX_LINEAR; + } +}; + +template +class LinearIndex : public NNIndex +{ +public: + + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + + LinearIndex(const Matrix& inputData, const IndexParams& params = LinearIndexParams(), + Distance d = Distance()) : + dataset_(inputData), index_params_(params), distance_(d) + { + } + + LinearIndex(const LinearIndex&); + LinearIndex& operator=(const LinearIndex&); + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_LINEAR; + } + + + size_t size() const CV_OVERRIDE + { + return dataset_.rows; + } + + size_t veclen() const CV_OVERRIDE + { + return dataset_.cols; + } + + + int usedMemory() const CV_OVERRIDE + { + return 0; + } + + void buildIndex() CV_OVERRIDE + { + /* nothing to do here for linear search */ + } + + void saveIndex(FILE*) CV_OVERRIDE + { + /* nothing to do here for linear search */ + } + + + void loadIndex(FILE*) CV_OVERRIDE + { + /* nothing to do here for linear search */ + + index_params_["algorithm"] = getType(); + } + + void findNeighbors(ResultSet& resultSet, const ElementType* vec, const SearchParams& /*searchParams*/) CV_OVERRIDE + { + ElementType* data = dataset_.data; + for (size_t i = 0; i < dataset_.rows; ++i, data += dataset_.cols) { + DistanceType dist = distance_(data, vec, dataset_.cols); + resultSet.addPoint(dist, (int)i); + } + } + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + +private: + /** The dataset */ + const Matrix dataset_; + /** Index parameters */ + IndexParams index_params_; + /** Index distance */ + Distance distance_; + +}; + +} + +//! @endcond + +#endif // OPENCV_FLANN_LINEAR_INDEX_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/logger.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/logger.h new file mode 100644 index 0000000..8911812 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/logger.h @@ -0,0 +1,139 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_LOGGER_H +#define OPENCV_FLANN_LOGGER_H + +//! @cond IGNORED + +#include +#include + +#include "defines.h" + + +namespace cvflann +{ + +class Logger +{ + Logger() : stream(stdout), logLevel(FLANN_LOG_WARN) {} + + ~Logger() + { + if ((stream!=NULL)&&(stream!=stdout)) { + fclose(stream); + } + } + + static Logger& instance() + { + static Logger logger; + return logger; + } + + void _setDestination(const char* name) + { + if (name==NULL) { + stream = stdout; + } + else { +#ifdef _MSC_VER + if (fopen_s(&stream, name, "w") != 0) + stream = NULL; +#else + stream = fopen(name,"w"); +#endif + if (stream == NULL) { + stream = stdout; + } + } + } + + int _log(int level, const char* fmt, va_list arglist) + { + if (level > logLevel ) return -1; + int ret = vfprintf(stream, fmt, arglist); + return ret; + } + +public: + /** + * Sets the logging level. All messages with lower priority will be ignored. + * @param level Logging level + */ + static void setLevel(int level) { instance().logLevel = level; } + + /** + * Sets the logging destination + * @param name Filename or NULL for console + */ + static void setDestination(const char* name) { instance()._setDestination(name); } + + /** + * Print log message + * @param level Log level + * @param fmt Message format + * @return + */ + static int log(int level, const char* fmt, ...) + { + va_list arglist; + va_start(arglist, fmt); + int ret = instance()._log(level,fmt,arglist); + va_end(arglist); + return ret; + } + +#define LOG_METHOD(NAME,LEVEL) \ + static int NAME(const char* fmt, ...) \ + { \ + va_list ap; \ + va_start(ap, fmt); \ + int ret = instance()._log(LEVEL, fmt, ap); \ + va_end(ap); \ + return ret; \ + } + + LOG_METHOD(fatal, FLANN_LOG_FATAL) + LOG_METHOD(error, FLANN_LOG_ERROR) + LOG_METHOD(warn, FLANN_LOG_WARN) + LOG_METHOD(info, FLANN_LOG_INFO) + +private: + FILE* stream; + int logLevel; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_LOGGER_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/lsh_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/lsh_index.h new file mode 100644 index 0000000..b5e87f6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/lsh_index.h @@ -0,0 +1,403 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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. + *************************************************************************/ + +/*********************************************************************** + * Author: Vincent Rabaud + *************************************************************************/ + +#ifndef OPENCV_FLANN_LSH_INDEX_H_ +#define OPENCV_FLANN_LSH_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include +#include + +#include "nn_index.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "lsh_table.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) //disable unreachable code +#endif + +namespace cvflann +{ + +struct LshIndexParams : public IndexParams +{ + LshIndexParams(int table_number = 12, int key_size = 20, int multi_probe_level = 2) + { + (*this)["algorithm"] = FLANN_INDEX_LSH; + // The number of hash tables to use + (*this)["table_number"] = table_number; + // The length of the key in the hash tables + (*this)["key_size"] = key_size; + // Number of levels to use in multi-probe (0 for standard LSH) + (*this)["multi_probe_level"] = multi_probe_level; + } +}; + +/** + * Locality-sensitive hashing index + * + * Contains the tables and other information for indexing a set of points + * for nearest-neighbor matching. + */ +template +class LshIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + /** Constructor + * @param input_data dataset with the input features + * @param params parameters passed to the LSH algorithm + * @param d the distance used + */ + LshIndex(const Matrix& input_data, const IndexParams& params = LshIndexParams(), + Distance d = Distance()) : + dataset_(input_data), index_params_(params), distance_(d) + { + // cv::flann::IndexParams sets integer params as 'int', so it is used with get_param + // in place of 'unsigned int' + table_number_ = get_param(index_params_,"table_number",12); + key_size_ = get_param(index_params_,"key_size",20); + multi_probe_level_ = get_param(index_params_,"multi_probe_level",2); + + feature_size_ = (unsigned)dataset_.cols; + fill_xor_mask(0, key_size_, multi_probe_level_, xor_masks_); + } + + + LshIndex(const LshIndex&); + LshIndex& operator=(const LshIndex&); + + /** + * Builds the index + */ + void buildIndex() CV_OVERRIDE + { + tables_.resize(table_number_); + for (int i = 0; i < table_number_; ++i) { + lsh::LshTable& table = tables_[i]; + table = lsh::LshTable(feature_size_, key_size_); + + // Add the features to the table + table.add(dataset_); + } + } + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_LSH; + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream,table_number_); + save_value(stream,key_size_); + save_value(stream,multi_probe_level_); + save_value(stream, dataset_); + } + + void loadIndex(FILE* stream) CV_OVERRIDE + { + load_value(stream, table_number_); + load_value(stream, key_size_); + load_value(stream, multi_probe_level_); + load_value(stream, dataset_); + // Building the index is so fast we can afford not storing it + buildIndex(); + + index_params_["algorithm"] = getType(); + index_params_["table_number"] = table_number_; + index_params_["key_size"] = key_size_; + index_params_["multi_probe_level"] = multi_probe_level_; + } + + /** + * Returns size of index. + */ + size_t size() const CV_OVERRIDE + { + return dataset_.rows; + } + + /** + * Returns the length of an index feature. + */ + size_t veclen() const CV_OVERRIDE + { + return feature_size_; + } + + /** + * Computes the index memory usage + * Returns: memory used by the index + */ + int usedMemory() const CV_OVERRIDE + { + return (int)(dataset_.rows * sizeof(int)); + } + + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + + /** + * \brief Perform k-nearest neighbor search + * \param[in] queries The query points for which to find the nearest neighbors + * \param[out] indices The indices of the nearest neighbors found + * \param[out] dists Distances to the nearest neighbors found + * \param[in] knn Number of nearest neighbors to return + * \param[in] params Search parameters + */ + virtual void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE + { + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); + + + KNNUniqueResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.clear(); + std::fill_n(indices[i], knn, -1); + std::fill_n(dists[i], knn, std::numeric_limits::max()); + findNeighbors(resultSet, queries[i], params); + if (get_param(params,"sorted",true)) resultSet.sortAndCopy(indices[i], dists[i], knn); + else resultSet.copy(indices[i], dists[i], knn); + } + } + + + /** + * Find set of nearest neighbors to vec. Their indices are stored inside + * the result object. + * + * Params: + * result = the result object in which the indices of the nearest-neighbors are stored + * vec = the vector for which to search the nearest neighbors + * maxCheck = the maximum number of restarts (in a best-bin-first manner) + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& /*searchParams*/) CV_OVERRIDE + { + getNeighbors(vec, result); + } + +private: + /** Defines the comparator on score and index + */ + typedef std::pair ScoreIndexPair; + struct SortScoreIndexPairOnSecond + { + bool operator()(const ScoreIndexPair& left, const ScoreIndexPair& right) const + { + return left.second < right.second; + } + }; + + /** Fills the different xor masks to use when getting the neighbors in multi-probe LSH + * @param key the key we build neighbors from + * @param lowest_index the lowest index of the bit set + * @param level the multi-probe level we are at + * @param xor_masks all the xor mask + */ + void fill_xor_mask(lsh::BucketKey key, int lowest_index, unsigned int level, + std::vector& xor_masks) + { + xor_masks.push_back(key); + if (level == 0) return; + for (int index = lowest_index - 1; index >= 0; --index) { + // Create a new key + lsh::BucketKey new_key = key | (1 << index); + fill_xor_mask(new_key, index, level - 1, xor_masks); + } + } + + /** Performs the approximate nearest-neighbor search. + * @param vec the feature to analyze + * @param do_radius flag indicating if we check the radius too + * @param radius the radius if it is a radius search + * @param do_k flag indicating if we limit the number of nn + * @param k_nn the number of nearest neighbors + * @param checked_average used for debugging + */ + void getNeighbors(const ElementType* vec, bool /*do_radius*/, float radius, bool do_k, unsigned int k_nn, + float& /*checked_average*/) + { + static std::vector score_index_heap; + + if (do_k) { + unsigned int worst_score = std::numeric_limits::max(); + typename std::vector >::const_iterator table = tables_.begin(); + typename std::vector >::const_iterator table_end = tables_.end(); + for (; table != table_end; ++table) { + size_t key = table->getKey(vec); + std::vector::const_iterator xor_mask = xor_masks_.begin(); + std::vector::const_iterator xor_mask_end = xor_masks_.end(); + for (; xor_mask != xor_mask_end; ++xor_mask) { + size_t sub_key = key ^ (*xor_mask); + const lsh::Bucket* bucket = table->getBucketFromKey(sub_key); + if (bucket == 0) continue; + + // Go over each descriptor index + std::vector::const_iterator training_index = bucket->begin(); + std::vector::const_iterator last_training_index = bucket->end(); + DistanceType hamming_distance; + + // Process the rest of the candidates + for (; training_index < last_training_index; ++training_index) { + hamming_distance = distance_(vec, dataset_[*training_index], dataset_.cols); + + if (hamming_distance < worst_score) { + // Insert the new element + score_index_heap.push_back(ScoreIndexPair(hamming_distance, training_index)); + std::push_heap(score_index_heap.begin(), score_index_heap.end()); + + if (score_index_heap.size() > (unsigned int)k_nn) { + // Remove the highest distance value as we have too many elements + std::pop_heap(score_index_heap.begin(), score_index_heap.end()); + score_index_heap.pop_back(); + // Keep track of the worst score + worst_score = score_index_heap.front().first; + } + } + } + } + } + } + else { + typename std::vector >::const_iterator table = tables_.begin(); + typename std::vector >::const_iterator table_end = tables_.end(); + for (; table != table_end; ++table) { + size_t key = table->getKey(vec); + std::vector::const_iterator xor_mask = xor_masks_.begin(); + std::vector::const_iterator xor_mask_end = xor_masks_.end(); + for (; xor_mask != xor_mask_end; ++xor_mask) { + size_t sub_key = key ^ (*xor_mask); + const lsh::Bucket* bucket = table->getBucketFromKey(sub_key); + if (bucket == 0) continue; + + // Go over each descriptor index + std::vector::const_iterator training_index = bucket->begin(); + std::vector::const_iterator last_training_index = bucket->end(); + DistanceType hamming_distance; + + // Process the rest of the candidates + for (; training_index < last_training_index; ++training_index) { + // Compute the Hamming distance + hamming_distance = distance_(vec, dataset_[*training_index], dataset_.cols); + if (hamming_distance < radius) score_index_heap.push_back(ScoreIndexPair(hamming_distance, training_index)); + } + } + } + } + } + + /** Performs the approximate nearest-neighbor search. + * This is a slower version than the above as it uses the ResultSet + * @param vec the feature to analyze + */ + void getNeighbors(const ElementType* vec, ResultSet& result) + { + typename std::vector >::const_iterator table = tables_.begin(); + typename std::vector >::const_iterator table_end = tables_.end(); + for (; table != table_end; ++table) { + size_t key = table->getKey(vec); + std::vector::const_iterator xor_mask = xor_masks_.begin(); + std::vector::const_iterator xor_mask_end = xor_masks_.end(); + for (; xor_mask != xor_mask_end; ++xor_mask) { + size_t sub_key = key ^ (*xor_mask); + const lsh::Bucket* bucket = table->getBucketFromKey((lsh::BucketKey)sub_key); + if (bucket == 0) continue; + + // Go over each descriptor index + std::vector::const_iterator training_index = bucket->begin(); + std::vector::const_iterator last_training_index = bucket->end(); + DistanceType hamming_distance; + + // Process the rest of the candidates + for (; training_index < last_training_index; ++training_index) { + // Compute the Hamming distance + hamming_distance = distance_(vec, dataset_[*training_index], (int)dataset_.cols); + result.addPoint(hamming_distance, *training_index); + } + } + } + } + + /** The different hash tables */ + std::vector > tables_; + + /** The data the LSH tables where built from */ + Matrix dataset_; + + /** The size of the features (as ElementType[]) */ + unsigned int feature_size_; + + IndexParams index_params_; + + /** table number */ + int table_number_; + /** key size */ + int key_size_; + /** How far should we look for neighbors in multi-probe LSH */ + int multi_probe_level_; + + /** The XOR masks to apply to a key to get the neighboring buckets */ + std::vector xor_masks_; + + Distance distance_; +}; +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +//! @endcond + +#endif //OPENCV_FLANN_LSH_INDEX_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/lsh_table.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/lsh_table.h new file mode 100644 index 0000000..a189562 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/lsh_table.h @@ -0,0 +1,525 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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. + *************************************************************************/ + +/*********************************************************************** + * Author: Vincent Rabaud + *************************************************************************/ + +#ifndef OPENCV_FLANN_LSH_TABLE_H_ +#define OPENCV_FLANN_LSH_TABLE_H_ + +//! @cond IGNORED + +#include +#include +#include +#include +// TODO as soon as we use C++0x, use the code in USE_UNORDERED_MAP +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define USE_UNORDERED_MAP 1 +#else +# define USE_UNORDERED_MAP 0 +#endif +#if USE_UNORDERED_MAP +#include +#else +#include +#endif +#include +#include + +#include "dynamic_bitset.h" +#include "matrix.h" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) //disable unreachable code +#endif + + +namespace cvflann +{ + +namespace lsh +{ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** What is stored in an LSH bucket + */ +typedef uint32_t FeatureIndex; +/** The id from which we can get a bucket back in an LSH table + */ +typedef unsigned int BucketKey; + +/** A bucket in an LSH table + */ +typedef std::vector Bucket; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** POD for stats about an LSH table + */ +struct LshStats +{ + std::vector bucket_sizes_; + size_t n_buckets_; + size_t bucket_size_mean_; + size_t bucket_size_median_; + size_t bucket_size_min_; + size_t bucket_size_max_; + size_t bucket_size_std_dev; + /** Each contained vector contains three value: beginning/end for interval, number of elements in the bin + */ + std::vector > size_histogram_; +}; + +/** Overload the << operator for LshStats + * @param out the streams + * @param stats the stats to display + * @return the streams + */ +inline std::ostream& operator <<(std::ostream& out, const LshStats& stats) +{ + int w = 20; + out << "Lsh Table Stats:\n" << std::setw(w) << std::setiosflags(std::ios::right) << "N buckets : " + << stats.n_buckets_ << "\n" << std::setw(w) << std::setiosflags(std::ios::right) << "mean size : " + << std::setiosflags(std::ios::left) << stats.bucket_size_mean_ << "\n" << std::setw(w) + << std::setiosflags(std::ios::right) << "median size : " << stats.bucket_size_median_ << "\n" << std::setw(w) + << std::setiosflags(std::ios::right) << "min size : " << std::setiosflags(std::ios::left) + << stats.bucket_size_min_ << "\n" << std::setw(w) << std::setiosflags(std::ios::right) << "max size : " + << std::setiosflags(std::ios::left) << stats.bucket_size_max_; + + // Display the histogram + out << std::endl << std::setw(w) << std::setiosflags(std::ios::right) << "histogram : " + << std::setiosflags(std::ios::left); + for (std::vector >::const_iterator iterator = stats.size_histogram_.begin(), end = + stats.size_histogram_.end(); iterator != end; ++iterator) out << (*iterator)[0] << "-" << (*iterator)[1] << ": " << (*iterator)[2] << ", "; + + return out; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Lsh hash table. As its key is a sub-feature, and as usually + * the size of it is pretty small, we keep it as a continuous memory array. + * The value is an index in the corpus of features (we keep it as an unsigned + * int for pure memory reasons, it could be a size_t) + */ +template +class LshTable +{ +public: + /** A container of all the feature indices. Optimized for space + */ +#if USE_UNORDERED_MAP + typedef std::unordered_map BucketsSpace; +#else + typedef std::map BucketsSpace; +#endif + + /** A container of all the feature indices. Optimized for speed + */ + typedef std::vector BucketsSpeed; + + /** Default constructor + */ + LshTable() + { + key_size_ = 0; + feature_size_ = 0; + speed_level_ = kArray; + } + + /** Default constructor + * Create the mask and allocate the memory + * @param feature_size is the size of the feature (considered as a ElementType[]) + * @param key_size is the number of bits that are turned on in the feature + */ + LshTable(unsigned int feature_size, unsigned int key_size) + { + feature_size_ = feature_size; + CV_UNUSED(key_size); + CV_Error(cv::Error::StsUnsupportedFormat, "LSH is not implemented for that type" ); + } + + /** Add a feature to the table + * @param value the value to store for that feature + * @param feature the feature itself + */ + void add(unsigned int value, const ElementType* feature) + { + // Add the value to the corresponding bucket + BucketKey key = (lsh::BucketKey)getKey(feature); + + switch (speed_level_) { + case kArray: + // That means we get the buckets from an array + buckets_speed_[key].push_back(value); + break; + case kBitsetHash: + // That means we can check the bitset for the presence of a key + key_bitset_.set(key); + buckets_space_[key].push_back(value); + break; + case kHash: + { + // That means we have to check for the hash table for the presence of a key + buckets_space_[key].push_back(value); + break; + } + } + } + + /** Add a set of features to the table + * @param dataset the values to store + */ + void add(Matrix dataset) + { +#if USE_UNORDERED_MAP + buckets_space_.rehash((buckets_space_.size() + dataset.rows) * 1.2); +#endif + // Add the features to the table + for (unsigned int i = 0; i < dataset.rows; ++i) add(i, dataset[i]); + // Now that the table is full, optimize it for speed/space + optimize(); + } + + /** Get a bucket given the key + * @param key + * @return + */ + inline const Bucket* getBucketFromKey(BucketKey key) const + { + // Generate other buckets + switch (speed_level_) { + case kArray: + // That means we get the buckets from an array + return &buckets_speed_[key]; + break; + case kBitsetHash: + // That means we can check the bitset for the presence of a key + if (key_bitset_.test(key)) return &buckets_space_.find(key)->second; + else return 0; + break; + case kHash: + { + // That means we have to check for the hash table for the presence of a key + BucketsSpace::const_iterator bucket_it, bucket_end = buckets_space_.end(); + bucket_it = buckets_space_.find(key); + // Stop here if that bucket does not exist + if (bucket_it == bucket_end) return 0; + else return &bucket_it->second; + break; + } + } + return 0; + } + + /** Compute the sub-signature of a feature + */ + size_t getKey(const ElementType* /*feature*/) const + { + CV_Error(cv::Error::StsUnsupportedFormat, "LSH is not implemented for that type" ); + return 0; + } + + /** Get statistics about the table + * @return + */ + LshStats getStats() const; + +private: + /** defines the speed fo the implementation + * kArray uses a vector for storing data + * kBitsetHash uses a hash map but checks for the validity of a key with a bitset + * kHash uses a hash map only + */ + enum SpeedLevel + { + kArray, kBitsetHash, kHash + }; + + /** Initialize some variables + */ + void initialize(size_t key_size) + { + const size_t key_size_lower_bound = 1; + //a value (size_t(1) << key_size) must fit the size_t type so key_size has to be strictly less than size of size_t + const size_t key_size_upper_bound = (std::min)(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT); + if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound) + { + CV_Error(cv::Error::StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound)); + } + + speed_level_ = kHash; + key_size_ = (unsigned)key_size; + } + + /** Optimize the table for speed/space + */ + void optimize() + { + // If we are already using the fast storage, no need to do anything + if (speed_level_ == kArray) return; + + // Use an array if it will be more than half full + if (buckets_space_.size() > ((size_t(1) << key_size_) / 2)) { + speed_level_ = kArray; + // Fill the array version of it + buckets_speed_.resize(size_t(1) << key_size_); + for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) buckets_speed_[key_bucket->first] = key_bucket->second; + + // Empty the hash table + buckets_space_.clear(); + return; + } + + // If the bitset is going to use less than 10% of the RAM of the hash map (at least 1 size_t for the key and two + // for the vector) or less than 512MB (key_size_ <= 30) + if (((std::max(buckets_space_.size(), buckets_speed_.size()) * CHAR_BIT * 3 * sizeof(BucketKey)) / 10 + >= (size_t(1) << key_size_)) || (key_size_ <= 32)) { + speed_level_ = kBitsetHash; + key_bitset_.resize(size_t(1) << key_size_); + key_bitset_.reset(); + // Try with the BucketsSpace + for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) key_bitset_.set(key_bucket->first); + } + else { + speed_level_ = kHash; + key_bitset_.clear(); + } + } + + /** The vector of all the buckets if they are held for speed + */ + BucketsSpeed buckets_speed_; + + /** The hash table of all the buckets in case we cannot use the speed version + */ + BucketsSpace buckets_space_; + + /** What is used to store the data */ + SpeedLevel speed_level_; + + /** If the subkey is small enough, it will keep track of which subkeys are set through that bitset + * That is just a speedup so that we don't look in the hash table (which can be mush slower that checking a bitset) + */ + DynamicBitset key_bitset_; + + /** The size of the sub-signature in bits + */ + unsigned int key_size_; + + unsigned int feature_size_; + + // Members only used for the unsigned char specialization + /** The mask to apply to a feature to get the hash key + * Only used in the unsigned char case + */ + std::vector mask_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Specialization for unsigned char + +template<> +inline LshTable::LshTable(unsigned int feature_size, unsigned int subsignature_size) +{ + feature_size_ = feature_size; + initialize(subsignature_size); + // Allocate the mask + mask_ = std::vector((feature_size * sizeof(char) + sizeof(size_t) - 1) / sizeof(size_t), 0); + + // A bit brutal but fast to code + std::vector indices(feature_size * CHAR_BIT); + for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = (int)i; +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::randShuffle(indices); +#else + std::random_shuffle(indices.begin(), indices.end()); +#endif + + // Generate a random set of order of subsignature_size_ bits + for (unsigned int i = 0; i < key_size_; ++i) { + size_t index = indices[i]; + + // Set that bit in the mask + size_t divisor = CHAR_BIT * sizeof(size_t); + size_t idx = index / divisor; //pick the right size_t index + mask_[idx] |= size_t(1) << (index % divisor); //use modulo to find the bit offset + } + + // Set to 1 if you want to display the mask for debug +#if 0 + { + size_t bcount = 0; + BOOST_FOREACH(size_t mask_block, mask_){ + out << std::setw(sizeof(size_t) * CHAR_BIT / 4) << std::setfill('0') << std::hex << mask_block + << std::endl; + bcount += __builtin_popcountll(mask_block); + } + out << "bit count : " << std::dec << bcount << std::endl; + out << "mask size : " << mask_.size() << std::endl; + return out; + } +#endif +} + +/** Return the Subsignature of a feature + * @param feature the feature to analyze + */ +template<> +inline size_t LshTable::getKey(const unsigned char* feature) const +{ + // no need to check if T is dividable by sizeof(size_t) like in the Hamming + // distance computation as we have a mask + // FIXIT: This is bad assumption, because we reading tail bytes after of the allocated features buffer + const size_t* feature_block_ptr = reinterpret_cast ((const void*)feature); + + // Figure out the subsignature of the feature + // Given the feature ABCDEF, and the mask 001011, the output will be + // 000CEF + size_t subsignature = 0; + size_t bit_index = 1; + + for (unsigned i = 0; i < feature_size_; i += sizeof(size_t)) { + // get the mask and signature blocks + size_t feature_block; + if (i <= feature_size_ - sizeof(size_t)) + { + feature_block = *feature_block_ptr; + } + else + { + size_t tmp = 0; + memcpy(&tmp, feature_block_ptr, feature_size_ - i); // preserve bytes order + feature_block = tmp; + } + size_t mask_block = mask_[i / sizeof(size_t)]; + while (mask_block) { + // Get the lowest set bit in the mask block + size_t lowest_bit = mask_block & (-(ptrdiff_t)mask_block); + // Add it to the current subsignature if necessary + subsignature += (feature_block & lowest_bit) ? bit_index : 0; + // Reset the bit in the mask block + mask_block ^= lowest_bit; + // increment the bit index for the subsignature + bit_index <<= 1; + } + // Check the next feature block + ++feature_block_ptr; + } + return subsignature; +} + +template<> +inline LshStats LshTable::getStats() const +{ + LshStats stats; + stats.bucket_size_mean_ = 0; + if ((buckets_speed_.empty()) && (buckets_space_.empty())) { + stats.n_buckets_ = 0; + stats.bucket_size_median_ = 0; + stats.bucket_size_min_ = 0; + stats.bucket_size_max_ = 0; + return stats; + } + + if (!buckets_speed_.empty()) { + for (BucketsSpeed::const_iterator pbucket = buckets_speed_.begin(); pbucket != buckets_speed_.end(); ++pbucket) { + stats.bucket_sizes_.push_back((lsh::FeatureIndex)pbucket->size()); + stats.bucket_size_mean_ += pbucket->size(); + } + stats.bucket_size_mean_ /= buckets_speed_.size(); + stats.n_buckets_ = buckets_speed_.size(); + } + else { + for (BucketsSpace::const_iterator x = buckets_space_.begin(); x != buckets_space_.end(); ++x) { + stats.bucket_sizes_.push_back((lsh::FeatureIndex)x->second.size()); + stats.bucket_size_mean_ += x->second.size(); + } + stats.bucket_size_mean_ /= buckets_space_.size(); + stats.n_buckets_ = buckets_space_.size(); + } + + std::sort(stats.bucket_sizes_.begin(), stats.bucket_sizes_.end()); + + // BOOST_FOREACH(int size, stats.bucket_sizes_) + // std::cout << size << " "; + // std::cout << std::endl; + stats.bucket_size_median_ = stats.bucket_sizes_[stats.bucket_sizes_.size() / 2]; + stats.bucket_size_min_ = stats.bucket_sizes_.front(); + stats.bucket_size_max_ = stats.bucket_sizes_.back(); + + // TODO compute mean and std + /*float mean, stddev; + stats.bucket_size_mean_ = mean; + stats.bucket_size_std_dev = stddev;*/ + + // Include a histogram of the buckets + unsigned int bin_start = 0; + unsigned int bin_end = 20; + bool is_new_bin = true; + for (std::vector::iterator iterator = stats.bucket_sizes_.begin(), end = stats.bucket_sizes_.end(); iterator + != end; ) + if (*iterator < bin_end) { + if (is_new_bin) { + stats.size_histogram_.push_back(std::vector(3, 0)); + stats.size_histogram_.back()[0] = bin_start; + stats.size_histogram_.back()[1] = bin_end - 1; + is_new_bin = false; + } + ++stats.size_histogram_.back()[2]; + ++iterator; + } + else { + bin_start += 20; + bin_end += 20; + is_new_bin = true; + } + + return stats; +} + +// End the two namespaces +} +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//! @endcond + +#endif /* OPENCV_FLANN_LSH_TABLE_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/matrix.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/matrix.h new file mode 100644 index 0000000..fb871bd --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/matrix.h @@ -0,0 +1,118 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_DATASET_H_ +#define OPENCV_FLANN_DATASET_H_ + +//! @cond IGNORED + +#include + +namespace cvflann +{ + +/** + * Class that implements a simple rectangular matrix stored in a memory buffer and + * provides convenient matrix-like access using the [] operators. + */ +template +class Matrix +{ +public: + typedef T type; + + size_t rows; + size_t cols; + size_t stride; + T* data; + + Matrix() : rows(0), cols(0), stride(0), data(NULL) + { + } + + Matrix(T* data_, size_t rows_, size_t cols_, size_t stride_ = 0) : + rows(rows_), cols(cols_), stride(stride_), data(data_) + { + if (stride==0) stride = cols; + } + + /** + * Convenience function for deallocating the storage data. + */ + CV_DEPRECATED void free() + { + fprintf(stderr, "The cvflann::Matrix::free() method is deprecated " + "and it does not do any memory deallocation any more. You are" + "responsible for deallocating the matrix memory (by doing" + "'delete[] matrix.data' for example)"); + } + + /** + * Operator that return a (pointer to a) row of the data. + */ + T* operator[](size_t index) const + { + return data+index*stride; + } +}; + + +class UntypedMatrix +{ +public: + size_t rows; + size_t cols; + void* data; + flann_datatype_t type; + + UntypedMatrix(void* data_, long rows_, long cols_) : + rows(rows_), cols(cols_), data(data_) + { + } + + ~UntypedMatrix() + { + } + + + template + Matrix as() + { + return Matrix((T*)data, rows, cols); + } +}; + + + +} + +//! @endcond + +#endif //OPENCV_FLANN_DATASET_H_ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/miniflann.hpp b/Cigarette/OpenCV455Simple/include/opencv2/flann/miniflann.hpp new file mode 100644 index 0000000..b8df92d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/miniflann.hpp @@ -0,0 +1,185 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_MINIFLANN_HPP +#define OPENCV_MINIFLANN_HPP + +//! @cond IGNORED + +#include "opencv2/core.hpp" +#include "opencv2/flann/defines.h" + +namespace cv +{ + +namespace flann +{ + +enum FlannIndexType { + FLANN_INDEX_TYPE_8U = CV_8U, + FLANN_INDEX_TYPE_8S = CV_8S, + FLANN_INDEX_TYPE_16U = CV_16U, + FLANN_INDEX_TYPE_16S = CV_16S, + FLANN_INDEX_TYPE_32S = CV_32S, + FLANN_INDEX_TYPE_32F = CV_32F, + FLANN_INDEX_TYPE_64F = CV_64F, + FLANN_INDEX_TYPE_STRING, + FLANN_INDEX_TYPE_BOOL, + FLANN_INDEX_TYPE_ALGORITHM, + LAST_VALUE_FLANN_INDEX_TYPE = FLANN_INDEX_TYPE_ALGORITHM +}; + +struct CV_EXPORTS IndexParams +{ + IndexParams(); + ~IndexParams(); + + String getString(const String& key, const String& defaultVal=String()) const; + int getInt(const String& key, int defaultVal=-1) const; + double getDouble(const String& key, double defaultVal=-1) const; + + void setString(const String& key, const String& value); + void setInt(const String& key, int value); + void setDouble(const String& key, double value); + void setFloat(const String& key, float value); + void setBool(const String& key, bool value); + void setAlgorithm(int value); + + // FIXIT: replace by void write(FileStorage& fs) const + read() + void getAll(std::vector& names, + std::vector& types, + std::vector& strValues, + std::vector& numValues) const; + + void* params; + +private: + IndexParams(const IndexParams &); // copy disabled + IndexParams& operator=(const IndexParams &); // assign disabled +}; + +struct CV_EXPORTS KDTreeIndexParams : public IndexParams +{ + KDTreeIndexParams(int trees=4); +}; + +struct CV_EXPORTS LinearIndexParams : public IndexParams +{ + LinearIndexParams(); +}; + +struct CV_EXPORTS CompositeIndexParams : public IndexParams +{ + CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11, + cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2f ); +}; + +struct CV_EXPORTS AutotunedIndexParams : public IndexParams +{ + AutotunedIndexParams(float target_precision = 0.8f, float build_weight = 0.01f, + float memory_weight = 0, float sample_fraction = 0.1f); +}; + +struct CV_EXPORTS HierarchicalClusteringIndexParams : public IndexParams +{ + HierarchicalClusteringIndexParams(int branching = 32, + cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, int trees = 4, int leaf_size = 100 ); +}; + +struct CV_EXPORTS KMeansIndexParams : public IndexParams +{ + KMeansIndexParams(int branching = 32, int iterations = 11, + cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2f ); +}; + +struct CV_EXPORTS LshIndexParams : public IndexParams +{ + LshIndexParams(int table_number, int key_size, int multi_probe_level); +}; + +struct CV_EXPORTS SavedIndexParams : public IndexParams +{ + SavedIndexParams(const String& filename); +}; + +struct CV_EXPORTS SearchParams : public IndexParams +{ + SearchParams( int checks, float eps, bool sorted, bool explore_all_trees ); + SearchParams( int checks = 32, float eps = 0, bool sorted = true ); +}; + +class CV_EXPORTS_W Index +{ +public: + CV_WRAP Index(); + CV_WRAP Index(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2); + virtual ~Index(); + + CV_WRAP virtual void build(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2); + CV_WRAP virtual void knnSearch(InputArray query, OutputArray indices, + OutputArray dists, int knn, const SearchParams& params=SearchParams()); + + CV_WRAP virtual int radiusSearch(InputArray query, OutputArray indices, + OutputArray dists, double radius, int maxResults, + const SearchParams& params=SearchParams()); + + CV_WRAP virtual void save(const String& filename) const; + CV_WRAP virtual bool load(InputArray features, const String& filename); + CV_WRAP virtual void release(); + CV_WRAP cvflann::flann_distance_t getDistance() const; + CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const; + +protected: + bool load_(const String& filename); + + cvflann::flann_distance_t distType; + cvflann::flann_algorithm_t algo; + int featureType; + void* index; + Mat features_clone; // index may store features pointer internally for searching, so avoid dangling pointers: https://github.com/opencv/opencv/issues/17553 +}; + +} } // namespace cv::flann + +//! @endcond + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/nn_index.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/nn_index.h new file mode 100644 index 0000000..23a1de7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/nn_index.h @@ -0,0 +1,180 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_NNINDEX_H +#define OPENCV_FLANN_NNINDEX_H + +#include "matrix.h" +#include "result_set.h" +#include "params.h" + +//! @cond IGNORED + +namespace cvflann +{ + +/** + * Nearest-neighbour index base class + */ +template +class NNIndex +{ + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + +public: + + virtual ~NNIndex() {} + + /** + * \brief Builds the index + */ + virtual void buildIndex() = 0; + + /** + * \brief Perform k-nearest neighbor search + * \param[in] queries The query points for which to find the nearest neighbors + * \param[out] indices The indices of the nearest neighbors found + * \param[out] dists Distances to the nearest neighbors found + * \param[in] knn Number of nearest neighbors to return + * \param[in] params Search parameters + */ + virtual void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) + { + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); + +#if 0 + KNNResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.init(indices[i], dists[i]); + findNeighbors(resultSet, queries[i], params); + } +#else + KNNUniqueResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.clear(); + findNeighbors(resultSet, queries[i], params); + if (get_param(params,"sorted",true)) resultSet.sortAndCopy(indices[i], dists[i], knn); + else resultSet.copy(indices[i], dists[i], knn); + } +#endif + } + + /** + * \brief Perform radius search + * \param[in] query The query point + * \param[out] indices The indinces of the neighbors found within the given radius + * \param[out] dists The distances to the nearest neighbors found + * \param[in] radius The radius used for search + * \param[in] params Search parameters + * \returns Number of neighbors found + */ + virtual int radiusSearch(const Matrix& query, Matrix& indices, Matrix& dists, float radius, const SearchParams& params) + { + if (query.rows != 1) { + fprintf(stderr, "I can only search one feature at a time for range search\n"); + return -1; + } + CV_Assert(query.cols == veclen()); + CV_Assert(indices.cols == dists.cols); + + int n = 0; + int* indices_ptr = NULL; + DistanceType* dists_ptr = NULL; + if (indices.cols > 0) { + n = (int)indices.cols; + indices_ptr = indices[0]; + dists_ptr = dists[0]; + } + + RadiusUniqueResultSet resultSet((DistanceType)radius); + resultSet.clear(); + findNeighbors(resultSet, query[0], params); + if (n>0) { + if (get_param(params,"sorted",true)) resultSet.sortAndCopy(indices_ptr, dists_ptr, n); + else resultSet.copy(indices_ptr, dists_ptr, n); + } + + return (int)resultSet.size(); + } + + /** + * \brief Saves the index to a stream + * \param stream The stream to save the index to + */ + virtual void saveIndex(FILE* stream) = 0; + + /** + * \brief Loads the index from a stream + * \param stream The stream from which the index is loaded + */ + virtual void loadIndex(FILE* stream) = 0; + + /** + * \returns number of features in this index. + */ + virtual size_t size() const = 0; + + /** + * \returns The dimensionality of the features in this index. + */ + virtual size_t veclen() const = 0; + + /** + * \returns The amount of memory (in bytes) used by the index. + */ + virtual int usedMemory() const = 0; + + /** + * \returns The index type (kdtree, kmeans,...) + */ + virtual flann_algorithm_t getType() const = 0; + + /** + * \returns The index parameters + */ + virtual IndexParams getParameters() const = 0; + + + /** + * \brief Method that searches for nearest-neighbours + */ + virtual void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) = 0; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_NNINDEX_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/object_factory.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/object_factory.h new file mode 100644 index 0000000..5cc45ad --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/object_factory.h @@ -0,0 +1,95 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_OBJECT_FACTORY_H_ +#define OPENCV_FLANN_OBJECT_FACTORY_H_ + +//! @cond IGNORED + +#include + +namespace cvflann +{ + +class CreatorNotFound +{ +}; + +template +class ObjectFactory +{ + typedef ObjectFactory ThisClass; + typedef std::map ObjectRegistry; + + // singleton class, private constructor + ObjectFactory() {} + +public: + + bool subscribe(UniqueIdType id, ObjectCreator creator) + { + if (object_registry.find(id) != object_registry.end()) return false; + + object_registry[id] = creator; + return true; + } + + bool unregister(UniqueIdType id) + { + return object_registry.erase(id) == 1; + } + + ObjectCreator create(UniqueIdType id) + { + typename ObjectRegistry::const_iterator iter = object_registry.find(id); + + if (iter == object_registry.end()) { + throw CreatorNotFound(); + } + + return iter->second; + } + + static ThisClass& instance() + { + static ThisClass the_factory; + return the_factory; + } +private: + ObjectRegistry object_registry; +}; + +} + +//! @endcond + +#endif /* OPENCV_FLANN_OBJECT_FACTORY_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/params.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/params.h new file mode 100644 index 0000000..c9093cd --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/params.h @@ -0,0 +1,116 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_PARAMS_H_ +#define OPENCV_FLANN_PARAMS_H_ + +//! @cond IGNORED + +#include "any.h" +#include "general.h" +#include +#include + + +namespace cvflann +{ + +typedef std::map IndexParams; + +struct SearchParams : public IndexParams +{ + SearchParams(int checks = 32, float eps = 0, bool sorted = true ) + { + init(checks, eps, sorted, false); + } + + SearchParams(int checks, float eps, bool sorted, bool explore_all_trees ) + { + init(checks, eps, sorted, explore_all_trees); + } + + void init(int checks = 32, float eps = 0, bool sorted = true, bool explore_all_trees = false ) + { + // how many leafs to visit when searching for neighbours (-1 for unlimited) + (*this)["checks"] = checks; + // search for eps-approximate neighbours (default: 0) + (*this)["eps"] = eps; + // only for radius search, require neighbours sorted by distance (default: true) + (*this)["sorted"] = sorted; + // if false, search stops at the tree reaching the number of max checks (original behavior). + // When true, we do a descent in each tree and. Like before the alternative paths + // stored in the heap are not be processed further when max checks is reached. + (*this)["explore_all_trees"] = explore_all_trees; + } +}; + + +template +T get_param(const IndexParams& params, cv::String name, const T& default_value) +{ + IndexParams::const_iterator it = params.find(name); + if (it != params.end()) { + return it->second.cast(); + } + else { + return default_value; + } +} + +template +T get_param(const IndexParams& params, cv::String name) +{ + IndexParams::const_iterator it = params.find(name); + if (it != params.end()) { + return it->second.cast(); + } + else { + FLANN_THROW(cv::Error::StsBadArg, cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); + } +} + +inline void print_params(const IndexParams& params, std::ostream& stream) +{ + IndexParams::const_iterator it; + + for(it=params.begin(); it!=params.end(); ++it) { + stream << it->first << " : " << it->second << std::endl; + } +} + +inline void print_params(const IndexParams& params) +{ + print_params(params, std::cout); +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_PARAMS_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/random.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/random.h new file mode 100644 index 0000000..2c1809c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/random.h @@ -0,0 +1,157 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_RANDOM_H +#define OPENCV_FLANN_RANDOM_H + +//! @cond IGNORED + +#include +#include +#include + +namespace cvflann +{ + +inline int rand() +{ +#ifndef OPENCV_FLANN_USE_STD_RAND +# if INT_MAX == RAND_MAX + int v = cv::theRNG().next() & INT_MAX; +# else + int v = cv::theRNG().uniform(0, RAND_MAX + 1); +# endif +#else + int v = std::rand(); +#endif // OPENCV_FLANN_USE_STD_RAND + return v; +} + +/** + * Seeds the random number generator + * @param seed Random seed + */ +inline void seed_random(unsigned int seed) +{ +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::theRNG() = cv::RNG(seed); +#else + std::srand(seed); +#endif +} + +/* + * Generates a random double value. + */ +/** + * Generates a random double value. + * @param high Upper limit + * @param low Lower limit + * @return Random double value + */ +inline double rand_double(double high = 1.0, double low = 0) +{ + return low + ((high-low) * (rand() / (RAND_MAX + 1.0))); +} + +/** + * Generates a random integer value. + * @param high Upper limit + * @param low Lower limit + * @return Random integer value + */ +inline int rand_int(int high = RAND_MAX, int low = 0) +{ + return low + (int) ( double(high-low) * (rand() / (RAND_MAX + 1.0))); +} + +/** + * Random number generator that returns a distinct number from + * the [0,n) interval each time. + */ +class UniqueRandom +{ + std::vector vals_; + int size_; + int counter_; + +public: + /** + * Constructor. + * @param n Size of the interval from which to generate + * @return + */ + UniqueRandom(int n) + { + init(n); + } + + /** + * Initializes the number generator. + * @param n the size of the interval from which to generate random numbers. + */ + void init(int n) + { + // create and initialize an array of size n + vals_.resize(n); + size_ = n; + for (int i = 0; i < size_; ++i) vals_[i] = i; + + // shuffle the elements in the array +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::randShuffle(vals_); +#else + std::random_shuffle(vals_.begin(), vals_.end()); +#endif + + counter_ = 0; + } + + /** + * Return a distinct random integer in greater or equal to 0 and less + * than 'n' on each call. It should be called maximum 'n' times. + * Returns: a random integer + */ + int next() + { + if (counter_ == size_) { + return -1; + } + else { + return vals_[counter_++]; + } + } +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_RANDOM_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/result_set.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/result_set.h new file mode 100644 index 0000000..47ad231 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/result_set.h @@ -0,0 +1,548 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_RESULTSET_H +#define OPENCV_FLANN_RESULTSET_H + +//! @cond IGNORED + +#include +#include +#include +#include +#include +#include + +namespace cvflann +{ + +/* This record represents a branch point when finding neighbors in + the tree. It contains a record of the minimum distance to the query + point, as well as the node at which the search resumes. + */ + +template +struct BranchStruct +{ + T node; /* Tree node at which search resumes */ + DistanceType mindist; /* Minimum distance to query for all nodes below. */ + + BranchStruct() {} + BranchStruct(const T& aNode, DistanceType dist) : node(aNode), mindist(dist) {} + + bool operator<(const BranchStruct& rhs) const + { + return mindist +class ResultSet +{ +public: + virtual ~ResultSet() {} + + virtual bool full() const = 0; + + virtual void addPoint(DistanceType dist, int index) = 0; + + virtual DistanceType worstDist() const = 0; + +}; + +/** + * KNNSimpleResultSet does not ensure that the element it holds are unique. + * Is used in those cases where the nearest neighbour algorithm used does not + * attempt to insert the same element multiple times. + */ +template +class KNNSimpleResultSet : public ResultSet +{ + int* indices; + DistanceType* dists; + int capacity; + int count; + DistanceType worst_distance_; + +public: + KNNSimpleResultSet(int capacity_) : capacity(capacity_), count(0) + { + } + + void init(int* indices_, DistanceType* dists_) + { + indices = indices_; + dists = dists_; + count = 0; + worst_distance_ = (std::numeric_limits::max)(); + dists[capacity-1] = worst_distance_; + } + + size_t size() const + { + return count; + } + + bool full() const CV_OVERRIDE + { + return count == capacity; + } + + + void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + if (dist >= worst_distance_) return; + int i; + for (i=count; i>0; --i) { +#ifdef FLANN_FIRST_MATCH + if ( (dists[i-1]>dist) || ((dist==dists[i-1])&&(indices[i-1]>index)) ) +#else + if (dists[i-1]>dist) +#endif + { + if (i +class KNNResultSet : public ResultSet +{ + int* indices; + DistanceType* dists; + int capacity; + int count; + DistanceType worst_distance_; + +public: + KNNResultSet(int capacity_) + : indices(NULL), dists(NULL), capacity(capacity_), count(0), worst_distance_(0) + { + } + + void init(int* indices_, DistanceType* dists_) + { + indices = indices_; + dists = dists_; + count = 0; + worst_distance_ = (std::numeric_limits::max)(); + dists[capacity-1] = worst_distance_; + } + + size_t size() const + { + return count; + } + + bool full() const CV_OVERRIDE + { + return count == capacity; + } + + + void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + CV_DbgAssert(indices); + CV_DbgAssert(dists); + if (dist >= worst_distance_) return; + int i; + for (i = count; i > 0; --i) { +#ifdef FLANN_FIRST_MATCH + if ( (dists[i-1]<=dist) && ((dist!=dists[i-1])||(indices[i-1]<=index)) ) +#else + if (dists[i-1]<=dist) +#endif + { + // Check for duplicate indices + for (int j = i; dists[j] == dist && j--;) { + if (indices[j] == index) { + return; + } + } + break; + } + } + + if (count < capacity) ++count; + for (int j = count-1; j > i; --j) { + dists[j] = dists[j-1]; + indices[j] = indices[j-1]; + } + dists[i] = dist; + indices[i] = index; + worst_distance_ = dists[capacity-1]; + } + + DistanceType worstDist() const CV_OVERRIDE + { + return worst_distance_; + } +}; + + +/** + * A result-set class used when performing a radius based search. + */ +template +class RadiusResultSet : public ResultSet +{ + DistanceType radius; + int* indices; + DistanceType* dists; + size_t capacity; + size_t count; + +public: + RadiusResultSet(DistanceType radius_, int* indices_, DistanceType* dists_, int capacity_) : + radius(radius_), indices(indices_), dists(dists_), capacity(capacity_) + { + init(); + } + + ~RadiusResultSet() + { + } + + void init() + { + count = 0; + } + + size_t size() const + { + return count; + } + + bool full() const + { + return true; + } + + void addPoint(DistanceType dist, int index) + { + if (dist0)&&(count < capacity)) { + dists[count] = dist; + indices[count] = index; + } + count++; + } + } + + DistanceType worstDist() const + { + return radius; + } + +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the k NN neighbors + * Faster than KNNResultSet as it uses a binary heap and does not maintain two arrays + */ +template +class UniqueResultSet : public ResultSet +{ +public: + struct DistIndex + { + DistIndex(DistanceType dist, unsigned int index) : + dist_(dist), index_(index) + { + } + bool operator<(const DistIndex dist_index) const + { + return (dist_ < dist_index.dist_) || ((dist_ == dist_index.dist_) && index_ < dist_index.index_); + } + DistanceType dist_; + unsigned int index_; + }; + + /** Default constructor */ + UniqueResultSet() : + is_full_(false), worst_distance_(std::numeric_limits::max()) + { + } + + /** Check the status of the set + * @return true if we have k NN + */ + inline bool full() const CV_OVERRIDE + { + return is_full_; + } + + /** Remove all elements in the set + */ + virtual void clear() = 0; + + /** Copy the set to two C arrays + * @param indices pointer to a C array of indices + * @param dist pointer to a C array of distances + * @param n_neighbors the number of neighbors to copy + */ + virtual void copy(int* indices, DistanceType* dist, int n_neighbors = -1) const + { + if (n_neighbors < 0) { + for (typename std::set::const_iterator dist_index = dist_indices_.begin(), dist_index_end = + dist_indices_.end(); dist_index != dist_index_end; ++dist_index, ++indices, ++dist) { + *indices = dist_index->index_; + *dist = dist_index->dist_; + } + } + else { + int i = 0; + for (typename std::set::const_iterator dist_index = dist_indices_.begin(), dist_index_end = + dist_indices_.end(); (dist_index != dist_index_end) && (i < n_neighbors); ++dist_index, ++indices, ++dist, ++i) { + *indices = dist_index->index_; + *dist = dist_index->dist_; + } + } + } + + /** Copy the set to two C arrays but sort it according to the distance first + * @param indices pointer to a C array of indices + * @param dist pointer to a C array of distances + * @param n_neighbors the number of neighbors to copy + */ + virtual void sortAndCopy(int* indices, DistanceType* dist, int n_neighbors = -1) const + { + copy(indices, dist, n_neighbors); + } + + /** The number of neighbors in the set + * @return + */ + size_t size() const + { + return dist_indices_.size(); + } + + /** The distance of the furthest neighbor + * If we don't have enough neighbors, it returns the max possible value + * @return + */ + inline DistanceType worstDist() const CV_OVERRIDE + { + return worst_distance_; + } +protected: + /** Flag to say if the set is full */ + bool is_full_; + + /** The worst distance found so far */ + DistanceType worst_distance_; + + /** The best candidates so far */ + std::set dist_indices_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the k NN neighbors + * Faster than KNNResultSet as it uses a binary heap and does not maintain two arrays + */ +template +class KNNUniqueResultSet : public UniqueResultSet +{ +public: + /** Constructor + * @param capacity the number of neighbors to store at max + */ + KNNUniqueResultSet(unsigned int capacity) : capacity_(capacity) + { + this->is_full_ = false; + this->clear(); + } + + /** Add a possible candidate to the best neighbors + * @param dist distance for that neighbor + * @param index index of that neighbor + */ + inline void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + // Don't do anything if we are worse than the worst + if (dist >= worst_distance_) return; + dist_indices_.insert(DistIndex(dist, index)); + + if (is_full_) { + if (dist_indices_.size() > capacity_) { + dist_indices_.erase(*dist_indices_.rbegin()); + worst_distance_ = dist_indices_.rbegin()->dist_; + } + } + else if (dist_indices_.size() == capacity_) { + is_full_ = true; + worst_distance_ = dist_indices_.rbegin()->dist_; + } + } + + /** Remove all elements in the set + */ + void clear() CV_OVERRIDE + { + dist_indices_.clear(); + worst_distance_ = std::numeric_limits::max(); + is_full_ = false; + } + +protected: + typedef typename UniqueResultSet::DistIndex DistIndex; + using UniqueResultSet::is_full_; + using UniqueResultSet::worst_distance_; + using UniqueResultSet::dist_indices_; + + /** The number of neighbors to keep */ + unsigned int capacity_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the radius nearest neighbors + * It is more accurate than RadiusResult as it is not limited in the number of neighbors + */ +template +class RadiusUniqueResultSet : public UniqueResultSet +{ +public: + /** Constructor + * @param radius the maximum distance of a neighbor + */ + RadiusUniqueResultSet(DistanceType radius) : + radius_(radius) + { + is_full_ = true; + } + + /** Add a possible candidate to the best neighbors + * @param dist distance for that neighbor + * @param index index of that neighbor + */ + void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + if (dist <= radius_) dist_indices_.insert(DistIndex(dist, index)); + } + + /** Remove all elements in the set + */ + inline void clear() CV_OVERRIDE + { + dist_indices_.clear(); + } + + + /** Check the status of the set + * @return alwys false + */ + inline bool full() const CV_OVERRIDE + { + return true; + } + + /** The distance of the furthest neighbor + * If we don't have enough neighbors, it returns the max possible value + * @return + */ + inline DistanceType worstDist() const CV_OVERRIDE + { + return radius_; + } +private: + typedef typename UniqueResultSet::DistIndex DistIndex; + using UniqueResultSet::dist_indices_; + using UniqueResultSet::is_full_; + + /** The furthest distance a neighbor can be */ + DistanceType radius_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the k NN neighbors within a radius distance + */ +template +class KNNRadiusUniqueResultSet : public KNNUniqueResultSet +{ +public: + /** Constructor + * @param capacity the number of neighbors to store at max + * @param radius the maximum distance of a neighbor + */ + KNNRadiusUniqueResultSet(unsigned int capacity, DistanceType radius) + { + this->capacity_ = capacity; + this->radius_ = radius; + this->dist_indices_.reserve(capacity_); + this->clear(); + } + + /** Remove all elements in the set + */ + void clear() + { + dist_indices_.clear(); + worst_distance_ = radius_; + is_full_ = false; + } +private: + using KNNUniqueResultSet::dist_indices_; + using KNNUniqueResultSet::is_full_; + using KNNUniqueResultSet::worst_distance_; + + /** The maximum number of neighbors to consider */ + unsigned int capacity_; + + /** The maximum distance of a neighbor */ + DistanceType radius_; +}; +} + +//! @endcond + +#endif //OPENCV_FLANN_RESULTSET_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/sampling.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/sampling.h new file mode 100644 index 0000000..4e452b9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/sampling.h @@ -0,0 +1,84 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_SAMPLING_H_ +#define OPENCV_FLANN_SAMPLING_H_ + +//! @cond IGNORED + +#include "matrix.h" +#include "random.h" + +namespace cvflann +{ + +template +Matrix random_sample(Matrix& srcMatrix, long size, bool remove = false) +{ + Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); + + T* src,* dest; + for (long i=0; i +Matrix random_sample(const Matrix& srcMatrix, size_t size) +{ + UniqueRandom rand((int)srcMatrix.rows); + Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); + + T* src,* dest; + for (size_t i=0; i +#include + +#include "general.h" +#include "nn_index.h" + +#ifdef FLANN_SIGNATURE_ +#undef FLANN_SIGNATURE_ +#endif +#define FLANN_SIGNATURE_ "FLANN_INDEX" + +namespace cvflann +{ + +template +struct Datatype {}; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_INT8; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_INT16; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_INT32; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_UINT8; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_UINT16; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_UINT32; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_FLOAT32; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_FLOAT64; } }; + + +/** + * Structure representing the index header. + */ +struct IndexHeader +{ + char signature[16]; + char version[16]; + flann_datatype_t data_type; + flann_algorithm_t index_type; + size_t rows; + size_t cols; +}; + +/** + * Saves index header to stream + * + * @param stream - Stream to save to + * @param index - The index to save + */ +template +void save_header(FILE* stream, const NNIndex& index) +{ + IndexHeader header; + memset(header.signature, 0, sizeof(header.signature)); + strcpy(header.signature, FLANN_SIGNATURE_); + memset(header.version, 0, sizeof(header.version)); + strcpy(header.version, FLANN_VERSION_); + header.data_type = Datatype::type(); + header.index_type = index.getType(); + header.rows = index.size(); + header.cols = index.veclen(); + + std::fwrite(&header, sizeof(header),1,stream); +} + + +/** + * + * @param stream - Stream to load from + * @return Index header + */ +inline IndexHeader load_header(FILE* stream) +{ + IndexHeader header; + size_t read_size = fread(&header,sizeof(header),1,stream); + + if (read_size!=(size_t)1) { + FLANN_THROW(cv::Error::StsError, "Invalid index file, cannot read"); + } + + if (strcmp(header.signature,FLANN_SIGNATURE_)!=0) { + FLANN_THROW(cv::Error::StsError, "Invalid index file, wrong signature"); + } + + return header; + +} + + +template +void save_value(FILE* stream, const T& value, size_t count = 1) +{ + fwrite(&value, sizeof(value),count, stream); +} + +template +void save_value(FILE* stream, const cvflann::Matrix& value) +{ + fwrite(&value, sizeof(value),1, stream); + fwrite(value.data, sizeof(T),value.rows*value.cols, stream); +} + +template +void save_value(FILE* stream, const std::vector& value) +{ + size_t size = value.size(); + fwrite(&size, sizeof(size_t), 1, stream); + fwrite(&value[0], sizeof(T), size, stream); +} + +template +void load_value(FILE* stream, T& value, size_t count = 1) +{ + size_t read_cnt = fread(&value, sizeof(value), count, stream); + if (read_cnt != count) { + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); + } +} + +template +void load_value(FILE* stream, cvflann::Matrix& value) +{ + size_t read_cnt = fread(&value, sizeof(value), 1, stream); + if (read_cnt != 1) { + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); + } + value.data = new T[value.rows*value.cols]; + read_cnt = fread(value.data, sizeof(T), value.rows*value.cols, stream); + if (read_cnt != (size_t)(value.rows*value.cols)) { + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); + } +} + + +template +void load_value(FILE* stream, std::vector& value) +{ + size_t size; + size_t read_cnt = fread(&size, sizeof(size_t), 1, stream); + if (read_cnt!=1) { + FLANN_THROW(cv::Error::StsError, "Cannot read from file"); + } + value.resize(size); + read_cnt = fread(&value[0], sizeof(T), size, stream); + if (read_cnt != size) { + FLANN_THROW(cv::Error::StsError, "Cannot read from file"); + } +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_SAVING_H_ */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/flann/simplex_downhill.h b/Cigarette/OpenCV455Simple/include/opencv2/flann/simplex_downhill.h new file mode 100644 index 0000000..0297014 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/flann/simplex_downhill.h @@ -0,0 +1,190 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_SIMPLEX_DOWNHILL_H_ +#define OPENCV_FLANN_SIMPLEX_DOWNHILL_H_ + +//! @cond IGNORED + +namespace cvflann +{ + +/** + Adds val to array vals (and point to array points) and keeping the arrays sorted by vals. + */ +template +void addValue(int pos, float val, float* vals, T* point, T* points, int n) +{ + vals[pos] = val; + for (int i=0; i0 && vals[j] +float optimizeSimplexDownhill(T* points, int n, F func, float* vals = NULL ) +{ + const int MAX_ITERATIONS = 10; + + CV_DbgAssert(n>0); + + T* p_o = new T[n]; + T* p_r = new T[n]; + T* p_e = new T[n]; + + int alpha = 1; + + int iterations = 0; + + bool ownVals = false; + if (vals == NULL) { + ownVals = true; + vals = new float[n+1]; + for (int i=0; i MAX_ITERATIONS) break; + + // compute average of simplex points (except the highest point) + for (int j=0; j=vals[0])&&(val_r=vals[n]) { + for (int i=0; i +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" + +namespace cvflann +{ + +/** + * A start-stop timer class. + * + * Can be used to time portions of code. + */ +class StartStopTimer +{ + int64 startTime; + +public: + /** + * Value of the timer. + */ + double value; + + + /** + * Constructor. + */ + StartStopTimer() + : startTime(0) + { + reset(); + } + + /** + * Starts the timer. + */ + void start() + { + startTime = cv::getTickCount(); + } + + /** + * Stops the timer and updates timer value. + */ + void stop() + { + int64 stopTime = cv::getTickCount(); + value += ( (double)stopTime - startTime) / cv::getTickFrequency(); + } + + /** + * Resets the timer value to 0. + */ + void reset() + { + value = 0; + } + +}; + +} + +//! @endcond + +#endif // FLANN_TIMER_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi.hpp new file mode 100644 index 0000000..f10dfd4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi.hpp @@ -0,0 +1,42 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_HPP +#define OPENCV_GAPI_HPP + +#include + +/** \defgroup gapi G-API framework +@{ + @defgroup gapi_main_classes G-API Main Classes + @defgroup gapi_data_objects G-API Data Types + @{ + @defgroup gapi_meta_args G-API Metadata Descriptors + @} + @defgroup gapi_std_backends G-API Standard Backends + @defgroup gapi_compile_args G-API Graph Compilation Arguments + @defgroup gapi_serialization G-API Serialization functionality +@} + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Include these files here to avoid cyclic dependency between +// Desync & GKernel & GComputation & GStreamingCompiled. +#include +#include + +#endif // OPENCV_GAPI_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/core.hpp new file mode 100644 index 0000000..791aa4c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/core.hpp @@ -0,0 +1,1991 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_CORE_HPP +#define OPENCV_GAPI_CORE_HPP + +#include + +#include // std::tuple + +#include + +#include +#include +#include +#include + +/** \defgroup gapi_core G-API Core functionality +@{ + @defgroup gapi_math Graph API: Math operations + @defgroup gapi_pixelwise Graph API: Pixelwise operations + @defgroup gapi_matrixop Graph API: Operations on matrices + @defgroup gapi_transform Graph API: Image and channel composition functions +@} + */ + +namespace cv { namespace gapi { +/** + * @brief This namespace contains G-API Operation Types for OpenCV + * Core module functionality. + */ +namespace core { + using GMat2 = std::tuple; + using GMat3 = std::tuple; // FIXME: how to avoid this? + using GMat4 = std::tuple; + using GMatScalar = std::tuple; + + G_TYPED_KERNEL(GAdd, , "org.opencv.core.math.add") { + static GMatDesc outMeta(GMatDesc a, GMatDesc b, int ddepth) { + if (ddepth == -1) + { + // OpenCV: When the input arrays in add/subtract/multiply/divide + // functions have different depths, the output array depth must be + // explicitly specified! + // See artim_op() @ arithm.cpp + GAPI_Assert(a.chan == b.chan); + GAPI_Assert(a.depth == b.depth); + return a; + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GAddC, , "org.opencv.core.math.addC") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) { + GAPI_Assert(a.chan <= 4); + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSub, , "org.opencv.core.math.sub") { + static GMatDesc outMeta(GMatDesc a, GMatDesc b, int ddepth) { + if (ddepth == -1) + { + // This macro should select a larger data depth from a and b + // considering the number of channels in the same + // FIXME!!! Clarify if it is valid for sub() + GAPI_Assert(a.chan == b.chan); + ddepth = std::max(a.depth, b.depth); + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSubC, , "org.opencv.core.math.subC") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSubRC,, "org.opencv.core.math.subRC") { + static GMatDesc outMeta(GScalarDesc, GMatDesc b, int ddepth) { + return b.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMul, , "org.opencv.core.math.mul") { + static GMatDesc outMeta(GMatDesc a, GMatDesc, double, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMulCOld, , "org.opencv.core.math.mulCOld") { + static GMatDesc outMeta(GMatDesc a, double, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMulC, , "org.opencv.core.math.mulC"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMulS, , "org.opencv.core.math.muls") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; // FIXME: Merge with MulC + + G_TYPED_KERNEL(GDiv, , "org.opencv.core.math.div") { + static GMatDesc outMeta(GMatDesc a, GMatDesc b, double, int ddepth) { + if (ddepth == -1) + { + GAPI_Assert(a.depth == b.depth); + return b; + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GDivC, , "org.opencv.core.math.divC") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc, double, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GDivRC, , "org.opencv.core.math.divRC") { + static GMatDesc outMeta(GScalarDesc, GMatDesc b, double, int ddepth) { + return b.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMean, , "org.opencv.core.math.mean") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL_M(GPolarToCart, , "org.opencv.core.math.polarToCart") { + static std::tuple outMeta(GMatDesc, GMatDesc a, bool) { + return std::make_tuple(a, a); + } + }; + + G_TYPED_KERNEL_M(GCartToPolar, , "org.opencv.core.math.cartToPolar") { + static std::tuple outMeta(GMatDesc x, GMatDesc, bool) { + return std::make_tuple(x, x); + } + }; + + G_TYPED_KERNEL(GPhase, , "org.opencv.core.math.phase") { + static GMatDesc outMeta(const GMatDesc &inx, const GMatDesc &, bool) { + return inx; + } + }; + + G_TYPED_KERNEL(GMask, , "org.opencv.core.pixelwise.mask") { + static GMatDesc outMeta(GMatDesc in, GMatDesc) { + return in; + } + }; + + G_TYPED_KERNEL(GCmpGT, , "org.opencv.core.pixelwise.compare.cmpGT") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpGE, , "org.opencv.core.pixelwise.compare.cmpGE") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLE, , "org.opencv.core.pixelwise.compare.cmpLE") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLT, , "org.opencv.core.pixelwise.compare.cmpLT") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpEQ, , "org.opencv.core.pixelwise.compare.cmpEQ") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpNE, , "org.opencv.core.pixelwise.compare.cmpNE") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpGTScalar, , "org.opencv.core.pixelwise.compare.cmpGTScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpGEScalar, , "org.opencv.core.pixelwise.compare.cmpGEScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLEScalar, , "org.opencv.core.pixelwise.compare.cmpLEScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLTScalar, , "org.opencv.core.pixelwise.compare.cmpLTScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpEQScalar, , "org.opencv.core.pixelwise.compare.cmpEQScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpNEScalar, , "org.opencv.core.pixelwise.compare.cmpNEScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GAnd, , "org.opencv.core.pixelwise.bitwise_and") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GAndS, , "org.opencv.core.pixelwise.bitwise_andS") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GOr, , "org.opencv.core.pixelwise.bitwise_or") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GOrS, , "org.opencv.core.pixelwise.bitwise_orS") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GXor, , "org.opencv.core.pixelwise.bitwise_xor") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GXorS, , "org.opencv.core.pixelwise.bitwise_xorS") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GNot, , "org.opencv.core.pixelwise.bitwise_not") { + static GMatDesc outMeta(GMatDesc a) { + return a; + } + }; + + G_TYPED_KERNEL(GSelect, , "org.opencv.core.pixelwise.select") { + static GMatDesc outMeta(GMatDesc a, GMatDesc, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GMin, , "org.opencv.core.matrixop.min") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GMax, , "org.opencv.core.matrixop.max") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GAbsDiff, , "org.opencv.core.matrixop.absdiff") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GAbsDiffC, , "org.opencv.core.matrixop.absdiffC") { + static GMatDesc outMeta(const GMatDesc& a, const GScalarDesc&) { + return a; + } + }; + + G_TYPED_KERNEL(GSum, , "org.opencv.core.matrixop.sum") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL(GCountNonZero, (GMat)>, "org.opencv.core.matrixop.countNonZero") { + static GOpaqueDesc outMeta(GMatDesc in) { + GAPI_Assert(in.chan == 1); + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GAddW, , "org.opencv.core.matrixop.addweighted") { + static GMatDesc outMeta(GMatDesc a, double, GMatDesc b, double, double, int ddepth) { + if (ddepth == -1) + { + // OpenCV: When the input arrays in add/subtract/multiply/divide + // functions have different depths, the output array depth must be + // explicitly specified! + // See artim_op() @ arithm.cpp + GAPI_Assert(a.chan == b.chan); + GAPI_Assert(a.depth == b.depth); + return a; + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GNormL1, , "org.opencv.core.matrixop.norml1") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL(GNormL2, , "org.opencv.core.matrixop.norml2") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL(GNormInf, , "org.opencv.core.matrixop.norminf") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL_M(GIntegral, , "org.opencv.core.matrixop.integral") { + static std::tuple outMeta(GMatDesc in, int sd, int sqd) { + return std::make_tuple(in.withSizeDelta(1,1).withDepth(sd), + in.withSizeDelta(1,1).withDepth(sqd)); + } + }; + + G_TYPED_KERNEL(GThreshold, , "org.opencv.core.matrixop.threshold") { + static GMatDesc outMeta(GMatDesc in, GScalarDesc, GScalarDesc, int) { + return in; + } + }; + + + G_TYPED_KERNEL_M(GThresholdOT, , "org.opencv.core.matrixop.thresholdOT") { + static std::tuple outMeta(GMatDesc in, GScalarDesc, int) { + return std::make_tuple(in, empty_scalar_desc()); + } + }; + + G_TYPED_KERNEL(GInRange, , "org.opencv.core.matrixop.inrange") { + static GMatDesc outMeta(GMatDesc in, GScalarDesc, GScalarDesc) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL_M(GSplit3, , "org.opencv.core.transform.split3") { + static std::tuple outMeta(GMatDesc in) { + const auto out_depth = in.depth; + const auto out_desc = in.withType(out_depth, 1); + return std::make_tuple(out_desc, out_desc, out_desc); + } + }; + + G_TYPED_KERNEL_M(GSplit4, ,"org.opencv.core.transform.split4") { + static std::tuple outMeta(GMatDesc in) { + const auto out_depth = in.depth; + const auto out_desc = in.withType(out_depth, 1); + return std::make_tuple(out_desc, out_desc, out_desc, out_desc); + } + }; + + G_TYPED_KERNEL(GResize, , "org.opencv.core.transform.resize") { + static GMatDesc outMeta(GMatDesc in, Size sz, double fx, double fy, int /*interp*/) { + if (sz.width != 0 && sz.height != 0) + { + return in.withSize(sz); + } + else + { + int outSz_w = static_cast(round(in.size.width * fx)); + int outSz_h = static_cast(round(in.size.height * fy)); + GAPI_Assert(outSz_w > 0 && outSz_h > 0); + return in.withSize(Size(outSz_w, outSz_h)); + } + } + }; + + G_TYPED_KERNEL(GResizeP, , "org.opencv.core.transform.resizeP") { + static GMatDesc outMeta(GMatDesc in, Size sz, int interp) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + GAPI_Assert(in.planar); + GAPI_Assert(interp == cv::INTER_LINEAR); + return in.withSize(sz); + } + }; + + G_TYPED_KERNEL(GMerge3, , "org.opencv.core.transform.merge3") { + static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc) { + // Preserve depth and add channel component + return in.withType(in.depth, 3); + } + }; + + G_TYPED_KERNEL(GMerge4, , "org.opencv.core.transform.merge4") { + static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc, GMatDesc) { + // Preserve depth and add channel component + return in.withType(in.depth, 4); + } + }; + + G_TYPED_KERNEL(GRemap, , "org.opencv.core.transform.remap") { + static GMatDesc outMeta(GMatDesc in, Mat m1, Mat, int, int, Scalar) { + return in.withSize(m1.size()); + } + }; + + G_TYPED_KERNEL(GFlip, , "org.opencv.core.transform.flip") { + static GMatDesc outMeta(GMatDesc in, int) { + return in; + } + }; + + // TODO: eliminate the need in this kernel (streaming) + G_TYPED_KERNEL(GCrop, , "org.opencv.core.transform.crop") { + static GMatDesc outMeta(GMatDesc in, Rect rc) { + return in.withSize(Size(rc.width, rc.height)); + } + }; + + G_TYPED_KERNEL(GConcatHor, , "org.opencv.imgproc.transform.concatHor") { + static GMatDesc outMeta(GMatDesc l, GMatDesc r) { + return l.withSizeDelta(+r.size.width, 0); + } + }; + + G_TYPED_KERNEL(GConcatVert, , "org.opencv.imgproc.transform.concatVert") { + static GMatDesc outMeta(GMatDesc t, GMatDesc b) { + return t.withSizeDelta(0, +b.size.height); + } + }; + + G_TYPED_KERNEL(GLUT, , "org.opencv.core.transform.LUT") { + static GMatDesc outMeta(GMatDesc in, Mat) { + return in; + } + }; + + G_TYPED_KERNEL(GConvertTo, , "org.opencv.core.transform.convertTo") { + static GMatDesc outMeta(GMatDesc in, int rdepth, double, double) { + return rdepth < 0 ? in : in.withDepth(rdepth); + } + }; + + G_TYPED_KERNEL(GSqrt, , "org.opencv.core.math.sqrt") { + static GMatDesc outMeta(GMatDesc in) { + return in; + } + }; + + G_TYPED_KERNEL(GNormalize, , "org.opencv.core.normalize") { + static GMatDesc outMeta(GMatDesc in, double, double, int, int ddepth) { + // unlike opencv doesn't have a mask as a parameter + return (ddepth < 0 ? in : in.withDepth(ddepth)); + } + }; + + G_TYPED_KERNEL(GWarpPerspective, , "org.opencv.core.warpPerspective") { + static GMatDesc outMeta(GMatDesc in, const Mat&, Size dsize, int, int borderMode, const cv::Scalar&) { + GAPI_Assert((borderMode == cv::BORDER_CONSTANT || borderMode == cv::BORDER_REPLICATE) && + "cv::gapi::warpPerspective supports only cv::BORDER_CONSTANT and cv::BORDER_REPLICATE border modes"); + return in.withType(in.depth, in.chan).withSize(dsize); + } + }; + + G_TYPED_KERNEL(GWarpAffine, , "org.opencv.core.warpAffine") { + static GMatDesc outMeta(GMatDesc in, const Mat&, Size dsize, int, int border_mode, const cv::Scalar&) { + GAPI_Assert(border_mode != cv::BORDER_TRANSPARENT && + "cv::BORDER_TRANSPARENT mode is not supported in cv::gapi::warpAffine"); + return in.withType(in.depth, in.chan).withSize(dsize); + } + }; + + G_TYPED_KERNEL( + GKMeansND, + ,GMat,GMat>(GMat,int,GMat,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeansND") { + + static std::tuple + outMeta(const GMatDesc& in, int K, const GMatDesc& bestLabels, const TermCriteria&, int, + KmeansFlags flags) { + GAPI_Assert(in.depth == CV_32F); + std::vector amount_n_dim = detail::checkVector(in); + int amount = amount_n_dim[0], dim = amount_n_dim[1]; + if (amount == -1) // Mat with height != 1, width != 1, channels != 1 given + { // which means that kmeans will consider the following: + amount = in.size.height; + dim = in.size.width * in.chan; + } + // kmeans sets these labels' sizes when no bestLabels given: + GMatDesc out_labels(CV_32S, 1, Size{1, amount}); + // kmeans always sets these centers' sizes: + GMatDesc centers (CV_32F, 1, Size{dim, K}); + if (flags & KMEANS_USE_INITIAL_LABELS) + { + GAPI_Assert(bestLabels.depth == CV_32S); + int labels_amount = detail::checkVector(bestLabels, 1u); + GAPI_Assert(labels_amount == amount); + out_labels = bestLabels; // kmeans preserves bestLabels' sizes if given + } + return std::make_tuple(empty_gopaque_desc(), out_labels, centers); + } + }; + + G_TYPED_KERNEL( + GKMeansNDNoInit, + ,GMat,GMat>(GMat,int,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeansNDNoInit") { + + static std::tuple + outMeta(const GMatDesc& in, int K, const TermCriteria&, int, KmeansFlags flags) { + GAPI_Assert( !(flags & KMEANS_USE_INITIAL_LABELS) ); + GAPI_Assert(in.depth == CV_32F); + std::vector amount_n_dim = detail::checkVector(in); + int amount = amount_n_dim[0], dim = amount_n_dim[1]; + if (amount == -1) // Mat with height != 1, width != 1, channels != 1 given + { // which means that kmeans will consider the following: + amount = in.size.height; + dim = in.size.width * in.chan; + } + GMatDesc out_labels(CV_32S, 1, Size{1, amount}); + GMatDesc centers (CV_32F, 1, Size{dim, K}); + return std::make_tuple(empty_gopaque_desc(), out_labels, centers); + } + }; + + G_TYPED_KERNEL(GKMeans2D, ,GArray,GArray> + (GArray,int,GArray,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeans2D") { + static std::tuple + outMeta(const GArrayDesc&,int,const GArrayDesc&,const TermCriteria&,int,KmeansFlags) { + return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GKMeans3D, ,GArray,GArray> + (GArray,int,GArray,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeans3D") { + static std::tuple + outMeta(const GArrayDesc&,int,const GArrayDesc&,const TermCriteria&,int,KmeansFlags) { + return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GTranspose, , "org.opencv.core.transpose") { + static GMatDesc outMeta(GMatDesc in) { + return in.withSize({in.size.height, in.size.width}); + } + }; +} // namespace core + +namespace streaming { + +// Operations for Streaming (declared in this header for convenience) +G_TYPED_KERNEL(GSize, (GMat)>, "org.opencv.streaming.size") { + static GOpaqueDesc outMeta(const GMatDesc&) { + return empty_gopaque_desc(); + } +}; + +G_TYPED_KERNEL(GSizeR, (GOpaque)>, "org.opencv.streaming.sizeR") { + static GOpaqueDesc outMeta(const GOpaqueDesc&) { + return empty_gopaque_desc(); + } +}; + +G_TYPED_KERNEL(GSizeMF, (GFrame)>, "org.opencv.streaming.sizeMF") { + static GOpaqueDesc outMeta(const GFrameDesc&) { + return empty_gopaque_desc(); + } +}; +} // namespace streaming + +//! @addtogroup gapi_math +//! @{ + +/** @brief Calculates the per-element sum of two matrices. + +The function add calculates sum of two matrices of the same size and the same number of channels: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f] + +The function can be replaced with matrix expressions: + \f[\texttt{dst} = \texttt{src1} + \texttt{src2}\f] + +The input matrices and the output matrix can all have the same or different depths. For example, you +can add a 16-bit unsigned matrix to a 8-bit signed matrix and store the sum as a 32-bit +floating-point matrix. Depth of the output matrix is determined by the ddepth parameter. +If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have +the same depth as the input matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.add" +@param src1 first input matrix. +@param src2 second input matrix. +@param ddepth optional depth of the output matrix. +@sa sub, addWeighted +*/ +GAPI_EXPORTS_W GMat add(const GMat& src1, const GMat& src2, int ddepth = -1); + +/** @brief Calculates the per-element sum of matrix and given scalar. + +The function addC adds a given scalar value to each element of given matrix. +The function can be replaced with matrix expressions: + + \f[\texttt{dst} = \texttt{src1} + \texttt{c}\f] + +Depth of the output matrix is determined by the ddepth parameter. +If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. +The matrices can be single or multi channel. Output matrix must have the same size and number of channels as the input matrix. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.addC" +@param src1 first input matrix. +@param c scalar value to be added. +@param ddepth optional depth of the output matrix. +@sa sub, addWeighted +*/ +GAPI_EXPORTS_W GMat addC(const GMat& src1, const GScalar& c, int ddepth = -1); +//! @overload +GAPI_EXPORTS GMat addC(const GScalar& c, const GMat& src1, int ddepth = -1); + +/** @brief Calculates the per-element difference between two matrices. + +The function sub calculates difference between two matrices, when both matrices have the same size and the same number of +channels: + \f[\texttt{dst}(I) = \texttt{src1}(I) - \texttt{src2}(I)\f] + +The function can be replaced with matrix expressions: +\f[\texttt{dst} = \texttt{src1} - \texttt{src2}\f] + +The input matrices and the output matrix can all have the same or different depths. For example, you +can subtract two 8-bit unsigned matrices store the result as a 16-bit signed matrix. +Depth of the output matrix is determined by the ddepth parameter. +If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have +the same depth as the input matrices. The matrices can be single or multi channel. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.sub" +@param src1 first input matrix. +@param src2 second input matrix. +@param ddepth optional depth of the output matrix. +@sa add, addC + */ +GAPI_EXPORTS GMat sub(const GMat& src1, const GMat& src2, int ddepth = -1); + +/** @brief Calculates the per-element difference between matrix and given scalar. + +The function can be replaced with matrix expressions: + \f[\texttt{dst} = \texttt{src} - \texttt{c}\f] + +Depth of the output matrix is determined by the ddepth parameter. +If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. +The matrices can be single or multi channel. Output matrix must have the same size as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.subC" +@param src first input matrix. +@param c scalar value to subtracted. +@param ddepth optional depth of the output matrix. +@sa add, addC, subRC + */ +GAPI_EXPORTS GMat subC(const GMat& src, const GScalar& c, int ddepth = -1); + +/** @brief Calculates the per-element difference between given scalar and the matrix. + +The function can be replaced with matrix expressions: + \f[\texttt{dst} = \texttt{c} - \texttt{src}\f] + +Depth of the output matrix is determined by the ddepth parameter. +If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. +The matrices can be single or multi channel. Output matrix must have the same size as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.subRC" +@param c scalar value to subtract from. +@param src input matrix to be subtracted. +@param ddepth optional depth of the output matrix. +@sa add, addC, subC + */ +GAPI_EXPORTS GMat subRC(const GScalar& c, const GMat& src, int ddepth = -1); + +/** @brief Calculates the per-element scaled product of two matrices. + +The function mul calculates the per-element product of two matrices: + +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\f] + +If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have +the same depth as the input matrices. The matrices can be single or multi channel. +Output matrix must have the same size as input matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.mul" +@param src1 first input matrix. +@param src2 second input matrix of the same size and the same depth as src1. +@param scale optional scale factor. +@param ddepth optional depth of the output matrix. +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat mul(const GMat& src1, const GMat& src2, double scale = 1.0, int ddepth = -1); + +/** @brief Multiplies matrix by scalar. + +The function mulC multiplies each element of matrix src by given scalar value: + +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I) \cdot \texttt{multiplier} )\f] + +The matrices can be single or multi channel. Output matrix must have the same size as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.mulC" +@param src input matrix. +@param multiplier factor to be multiplied. +@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth. +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat mulC(const GMat& src, double multiplier, int ddepth = -1); +//! @overload +GAPI_EXPORTS GMat mulC(const GMat& src, const GScalar& multiplier, int ddepth = -1); // FIXME: merge with mulc +//! @overload +GAPI_EXPORTS GMat mulC(const GScalar& multiplier, const GMat& src, int ddepth = -1); // FIXME: merge with mulc + +/** @brief Performs per-element division of two matrices. + +The function divides one matrix by another: +\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f] + +For integer types when src2(I) is zero, dst(I) will also be zero. +Floating point case returns Inf/NaN (according to IEEE). + +Different channels of +multi-channel matrices are processed independently. +The matrices can be single or multi channel. Output matrix must have the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.div" +@param src1 first input matrix. +@param src2 second input matrix of the same size and depth as src1. +@param scale scalar factor. +@param ddepth optional depth of the output matrix; you can only pass -1 when src1.depth() == src2.depth(). +@sa mul, add, sub +*/ +GAPI_EXPORTS GMat div(const GMat& src1, const GMat& src2, double scale, int ddepth = -1); + +/** @brief Divides matrix by scalar. + +The function divC divides each element of matrix src by given scalar value: + +\f[\texttt{dst(I) = saturate(src(I)*scale/divisor)}\f] + +When divisor is zero, dst(I) will also be zero. Different channels of +multi-channel matrices are processed independently. +The matrices can be single or multi channel. Output matrix must have the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.divC" +@param src input matrix. +@param divisor number to be divided by. +@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth. +@param scale scale factor. +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat divC(const GMat& src, const GScalar& divisor, double scale, int ddepth = -1); + +/** @brief Divides scalar by matrix. + +The function divRC divides given scalar by each element of matrix src and keep the division result in new matrix of the same size and type as src: + +\f[\texttt{dst(I) = saturate(divident*scale/src(I))}\f] + +When src(I) is zero, dst(I) will also be zero. Different channels of +multi-channel matrices are processed independently. +The matrices can be single or multi channel. Output matrix must have the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.divRC" +@param src input matrix. +@param divident number to be divided. +@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth. +@param scale scale factor +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat divRC(const GScalar& divident, const GMat& src, double scale, int ddepth = -1); + +/** @brief Applies a mask to a matrix. + +The function mask set value from given matrix if the corresponding pixel value in mask matrix set to true, +and set the matrix value to 0 otherwise. + +Supported src matrix data types are @ref CV_8UC1, @ref CV_16SC1, @ref CV_16UC1. Supported mask data type is @ref CV_8UC1. + +@note Function textual ID is "org.opencv.core.math.mask" +@param src input matrix. +@param mask input mask matrix. +*/ +GAPI_EXPORTS GMat mask(const GMat& src, const GMat& mask); + +/** @brief Calculates an average (mean) of matrix elements. + +The function mean calculates the mean value M of matrix elements, +independently for each channel, and return it. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.mean" +@param src input matrix. +@sa countNonZero, min, max +*/ +GAPI_EXPORTS_W GScalar mean(const GMat& src); + +/** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle. + +The function polarToCart calculates the Cartesian coordinates of each 2D +vector represented by the corresponding elements of magnitude and angle: +\f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f] + +The relative accuracy of the estimated coordinates is about 1e-6. + +First output is a matrix of x-coordinates of 2D vectors. +Second output is a matrix of y-coordinates of 2D vectors. +Both output must have the same size and depth as input matrices. + +@note Function textual ID is "org.opencv.core.math.polarToCart" + +@param magnitude input floating-point @ref CV_32FC1 matrix (1xN) of magnitudes of 2D vectors; +@param angle input floating-point @ref CV_32FC1 matrix (1xN) of angles of 2D vectors. +@param angleInDegrees when true, the input angles are measured in +degrees, otherwise, they are measured in radians. +@sa cartToPolar, exp, log, pow, sqrt +*/ +GAPI_EXPORTS std::tuple polarToCart(const GMat& magnitude, const GMat& angle, + bool angleInDegrees = false); + +/** @brief Calculates the magnitude and angle of 2D vectors. + +The function cartToPolar calculates either the magnitude, angle, or both +for every 2D vector (x(I),y(I)): +\f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f] + +The angles are calculated with accuracy about 0.3 degrees. For the point +(0,0), the angle is set to 0. + +First output is a matrix of magnitudes of the same size and depth as input x. +Second output is a matrix of angles that has the same size and depth as +x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees). + +@note Function textual ID is "org.opencv.core.math.cartToPolar" + +@param x matrix of @ref CV_32FC1 x-coordinates. +@param y array of @ref CV_32FC1 y-coordinates. +@param angleInDegrees a flag, indicating whether the angles are measured +in radians (which is by default), or in degrees. +@sa polarToCart +*/ +GAPI_EXPORTS std::tuple cartToPolar(const GMat& x, const GMat& y, + bool angleInDegrees = false); + +/** @brief Calculates the rotation angle of 2D vectors. + +The function cv::phase calculates the rotation angle of each 2D vector that +is formed from the corresponding elements of x and y : +\f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f] + +The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 , +the corresponding angle(I) is set to 0. +@param x input floating-point array of x-coordinates of 2D vectors. +@param y input array of y-coordinates of 2D vectors; it must have the +same size and the same type as x. +@param angleInDegrees when true, the function calculates the angle in +degrees, otherwise, they are measured in radians. +@return array of vector angles; it has the same size and same type as x. +*/ +GAPI_EXPORTS GMat phase(const GMat& x, const GMat &y, bool angleInDegrees = false); + +/** @brief Calculates a square root of array elements. + +The function cv::gapi::sqrt calculates a square root of each input array element. +In case of multi-channel arrays, each channel is processed +independently. The accuracy is approximately the same as of the built-in +std::sqrt . +@param src input floating-point array. +@return output array of the same size and type as src. +*/ +GAPI_EXPORTS GMat sqrt(const GMat &src); + +//! @} gapi_math +//! +//! @addtogroup gapi_pixelwise +//! @{ + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater compare to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) > \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: +\f[\texttt{dst} = \texttt{src1} > \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices/matrix. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGT" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpLE, cmpGE, cmpLT +*/ +GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGTScalar" +*/ +GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less than elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) < \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} < \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices/matrix. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLT" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpLE, cmpGE, cmpGT +*/ +GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLTScalar" +*/ +GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater or equal compare to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) >= \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} >= \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGE" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpLE, cmpGT, cmpLT +*/ +GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLGEcalar" +*/ +GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less or equal compare to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) <= \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} <= \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLE" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpGT, cmpGE, cmpLT +*/ +GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLEScalar" +*/ +GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are equal to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) == \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} == \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQ" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpNE +*/ +GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQScalar" +*/ +GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are not equal to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) != \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} != \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNE" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpEQ +*/ +GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNEScalar" +*/ +GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GScalar& src2); + +/** @brief computes bitwise conjunction of the two matrixes (src1 & src2) +Calculates the per-element bit-wise logical conjunction of two matrices of the same size. + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_and" + +@param src1 first input matrix. +@param src2 second input matrix. +*/ +GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_andS" +@param src1 first input matrix. +@param src2 scalar, which will be per-lemenetly conjuncted with elements of src1. +*/ +GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GScalar& src2); + +/** @brief computes bitwise disjunction of the two matrixes (src1 | src2) +Calculates the per-element bit-wise logical disjunction of two matrices of the same size. + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_or" + +@param src1 first input matrix. +@param src2 second input matrix. +*/ +GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_orS" +@param src1 first input matrix. +@param src2 scalar, which will be per-lemenetly disjuncted with elements of src1. +*/ +GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GScalar& src2); + + +/** @brief computes bitwise logical "exclusive or" of the two matrixes (src1 ^ src2) +Calculates the per-element bit-wise logical "exclusive or" of two matrices of the same size. + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_xor" + +@param src1 first input matrix. +@param src2 second input matrix. +*/ +GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_xorS" +@param src1 first input matrix. +@param src2 scalar, for which per-lemenet "logical or" operation on elements of src1 will be performed. +*/ +GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GScalar& src2); + + +/** @brief Inverts every bit of an array. + +The function bitwise_not calculates per-element bit-wise inversion of the input +matrix: +\f[\texttt{dst} (I) = \neg \texttt{src} (I)\f] + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrix. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_not" + +@param src input matrix. +*/ +GAPI_EXPORTS GMat bitwise_not(const GMat& src); + +/** @brief Select values from either first or second of input matrices by given mask. +The function set to the output matrix either the value from the first input matrix if corresponding value of mask matrix is 255, + or value from the second input matrix (if value of mask matrix set to 0). + +Input mask matrix must be of @ref CV_8UC1 type, two other inout matrices and output matrix should be of the same type. The size should +be the same for all input and output matrices. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.select" + +@param src1 first input matrix. +@param src2 second input matrix. +@param mask mask input matrix. +*/ +GAPI_EXPORTS GMat select(const GMat& src1, const GMat& src2, const GMat& mask); + +//! @} gapi_pixelwise + + +//! @addtogroup gapi_matrixop +//! @{ +/** @brief Calculates per-element minimum of two matrices. + +The function min calculates the per-element minimum of two matrices of the same size, number of channels and depth: +\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f] + where I is a multi-dimensional index of matrix elements. In case of + multi-channel matrices, each channel is processed independently. +Output matrix must be of the same size and depth as src1. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.min" +@param src1 first input matrix. +@param src2 second input matrix of the same size and depth as src1. +@sa max, cmpEQ, cmpLT, cmpLE +*/ +GAPI_EXPORTS GMat min(const GMat& src1, const GMat& src2); + +/** @brief Calculates per-element maximum of two matrices. + +The function max calculates the per-element maximum of two matrices of the same size, number of channels and depth: +\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f] + where I is a multi-dimensional index of matrix elements. In case of + multi-channel matrices, each channel is processed independently. +Output matrix must be of the same size and depth as src1. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.max" +@param src1 first input matrix. +@param src2 second input matrix of the same size and depth as src1. +@sa min, compare, cmpEQ, cmpGT, cmpGE +*/ +GAPI_EXPORTS GMat max(const GMat& src1, const GMat& src2); + +/** @brief Calculates the per-element absolute difference between two matrices. + +The function absDiff calculates absolute difference between two matrices of the same size and depth: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f] + where I is a multi-dimensional index of matrix elements. In case of + multi-channel matrices, each channel is processed independently. +Output matrix must have the same size and depth as input matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.absdiff" +@param src1 first input matrix. +@param src2 second input matrix. +@sa abs +*/ +GAPI_EXPORTS GMat absDiff(const GMat& src1, const GMat& src2); + +/** @brief Calculates absolute value of matrix elements. + +The function abs calculates absolute difference between matrix elements and given scalar value: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{matC}(I)|)\f] + where matC is constructed from given scalar c and has the same sizes and depth as input matrix src. + +Output matrix must be of the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.absdiffC" +@param src input matrix. +@param c scalar to be subtracted. +@sa min, max +*/ +GAPI_EXPORTS GMat absDiffC(const GMat& src, const GScalar& c); + +/** @brief Calculates sum of all matrix elements. + +The function sum calculates sum of all matrix elements, independently for each channel. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.sum" +@param src input matrix. +@sa countNonZero, mean, min, max +*/ +GAPI_EXPORTS GScalar sum(const GMat& src); + +/** @brief Counts non-zero array elements. + +The function returns the number of non-zero elements in src : +\f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f] + +Supported matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.countNonZero" +@param src input single-channel matrix. +@sa mean, min, max +*/ +GAPI_EXPORTS GOpaque countNonZero(const GMat& src); + +/** @brief Calculates the weighted sum of two matrices. + +The function addWeighted calculates the weighted sum of two matrices as follows: +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] +where I is a multi-dimensional index of array elements. In case of multi-channel matrices, each +channel is processed independently. + +The function can be replaced with a matrix expression: + \f[\texttt{dst}(I) = \texttt{alpha} * \texttt{src1}(I) - \texttt{beta} * \texttt{src2}(I) + \texttt{gamma} \f] + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.addweighted" +@param src1 first input matrix. +@param alpha weight of the first matrix elements. +@param src2 second input matrix of the same size and channel number as src1. +@param beta weight of the second matrix elements. +@param gamma scalar added to each sum. +@param ddepth optional depth of the output matrix. +@sa add, sub +*/ +GAPI_EXPORTS GMat addWeighted(const GMat& src1, double alpha, const GMat& src2, double beta, double gamma, int ddepth = -1); + +/** @brief Calculates the absolute L1 norm of a matrix. + +This version of normL1 calculates the absolute L1 norm of src. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{1} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\ +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\ +\f} + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.norml1" +@param src input matrix. +@sa normL2, normInf +*/ +GAPI_EXPORTS GScalar normL1(const GMat& src); + +/** @brief Calculates the absolute L2 norm of a matrix. + +This version of normL2 calculates the absolute L2 norm of src. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{2} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\ +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\ +\f} + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +@note Function textual ID is "org.opencv.core.matrixop.norml2" +@param src input matrix. +@sa normL1, normInf +*/ +GAPI_EXPORTS GScalar normL2(const GMat& src); + +/** @brief Calculates the absolute infinite norm of a matrix. + +This version of normInf calculates the absolute infinite norm of src. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2 +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5. +\f} + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.norminf" +@param src input matrix. +@sa normL1, normL2 +*/ +GAPI_EXPORTS GScalar normInf(const GMat& src); + +/** @brief Calculates the integral of an image. + +The function calculates one or more integral images for the source image as follows: + +\f[\texttt{sum} (X,Y) = \sum _{x integral(const GMat& src, int sdepth = -1, int sqdepth = -1); + +/** @brief Applies a fixed-level threshold to each matrix element. + +The function applies fixed-level thresholding to a single- or multiple-channel matrix. +The function is typically used to get a bi-level (binary) image out of a grayscale image ( cmp functions could be also used for +this purpose) or for removing a noise, that is, filtering out pixels with too small or too large +values. There are several types of thresholding supported by the function. They are determined by +type parameter. + +Also, the special values cv::THRESH_OTSU or cv::THRESH_TRIANGLE may be combined with one of the +above values. In these cases, the function determines the optimal threshold value using the Otsu's +or Triangle algorithm and uses it instead of the specified thresh . The function returns the +computed threshold value in addititon to thresholded matrix. +The Otsu's and Triangle methods are implemented only for 8-bit matrices. + +Input image should be single channel only in case of cv::THRESH_OTSU or cv::THRESH_TRIANGLE flags. +Output matrix must be of the same size and depth as src. + +@note Function textual ID is "org.opencv.core.matrixop.threshold" + +@param src input matrix (@ref CV_8UC1, @ref CV_8UC3, or @ref CV_32FC1). +@param thresh threshold value. +@param maxval maximum value to use with the cv::THRESH_BINARY and cv::THRESH_BINARY_INV thresholding +types. +@param type thresholding type (see the cv::ThresholdTypes). + +@sa min, max, cmpGT, cmpLE, cmpGE, cmpLT + */ +GAPI_EXPORTS GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type); +/** @overload +This function applicable for all threshold types except CV_THRESH_OTSU and CV_THRESH_TRIANGLE +@note Function textual ID is "org.opencv.core.matrixop.thresholdOT" +*/ +GAPI_EXPORTS_W std::tuple threshold(const GMat& src, const GScalar& maxval, int type); + +/** @brief Applies a range-level threshold to each matrix element. + +The function applies range-level thresholding to a single- or multiple-channel matrix. +It sets output pixel value to OxFF if the corresponding pixel value of input matrix is in specified range,or 0 otherwise. + +Input and output matrices must be CV_8UC1. + +@note Function textual ID is "org.opencv.core.matrixop.inRange" + +@param src input matrix (CV_8UC1). +@param threshLow lower boundary value. +@param threshUp upper boundary value. + +@sa threshold + */ +GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp); + +//! @} gapi_matrixop + +//! @addtogroup gapi_transform +//! @{ +/** @brief Resizes an image. + +The function resizes the image src down to or up to the specified size. + +Output image size will have the size dsize (when dsize is non-zero) or the size computed from +src.size(), fx, and fy; the depth of output is the same as of src. + +If you want to resize src so that it fits the pre-created dst, +you may call the function as follows: +@code + // explicitly specify dsize=dst.size(); fx and fy will be computed from that. + resize(src, dst, dst.size(), 0, 0, interpolation); +@endcode +If you want to decimate the image by factor of 2 in each direction, you can call the function this +way: +@code + // specify fx and fy and let the function compute the destination image size. + resize(src, dst, Size(), 0.5, 0.5, interpolation); +@endcode +To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to +enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR +(faster but still looks OK). + +@note Function textual ID is "org.opencv.core.transform.resize" + +@param src input image. +@param dsize output image size; if it equals zero, it is computed as: + \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f] + Either dsize or both fx and fy must be non-zero. +@param fx scale factor along the horizontal axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.width/src.cols}\f] +@param fy scale factor along the vertical axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.height/src.rows}\f] +@param interpolation interpolation method, see cv::InterpolationFlags + +@sa warpAffine, warpPerspective, remap, resizeP + */ +GAPI_EXPORTS_W GMat resize(const GMat& src, const Size& dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR); + +/** @brief Resizes a planar image. + +The function resizes the image src down to or up to the specified size. +Planar image memory layout is three planes laying in the memory contiguously, +so the image height should be plane_height*plane_number, image type is @ref CV_8UC1. + +Output image size will have the size dsize, the depth of output is the same as of src. + +@note Function textual ID is "org.opencv.core.transform.resizeP" + +@param src input image, must be of @ref CV_8UC1 type; +@param dsize output image size; +@param interpolation interpolation method, only cv::INTER_LINEAR is supported at the moment + +@sa warpAffine, warpPerspective, remap, resize + */ +GAPI_EXPORTS GMatP resizeP(const GMatP& src, const Size& dsize, int interpolation = cv::INTER_LINEAR); + +/** @brief Creates one 4-channel matrix out of 4 single-channel ones. + +The function merges several matrices to make a single multi-channel matrix. That is, each +element of the output matrix will be a concatenation of the elements of the input matrices, where +elements of i-th input matrix are treated as mv[i].channels()-element vectors. +Output matrix must be of @ref CV_8UC4 type. + +The function split4 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.merge4" + +@param src1 first input @ref CV_8UC1 matrix to be merged. +@param src2 second input @ref CV_8UC1 matrix to be merged. +@param src3 third input @ref CV_8UC1 matrix to be merged. +@param src4 fourth input @ref CV_8UC1 matrix to be merged. +@sa merge3, split4, split3 +*/ +GAPI_EXPORTS GMat merge4(const GMat& src1, const GMat& src2, const GMat& src3, const GMat& src4); + +/** @brief Creates one 3-channel matrix out of 3 single-channel ones. + +The function merges several matrices to make a single multi-channel matrix. That is, each +element of the output matrix will be a concatenation of the elements of the input matrices, where +elements of i-th input matrix are treated as mv[i].channels()-element vectors. +Output matrix must be of @ref CV_8UC3 type. + +The function split3 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.merge3" + +@param src1 first input @ref CV_8UC1 matrix to be merged. +@param src2 second input @ref CV_8UC1 matrix to be merged. +@param src3 third input @ref CV_8UC1 matrix to be merged. +@sa merge4, split4, split3 +*/ +GAPI_EXPORTS GMat merge3(const GMat& src1, const GMat& src2, const GMat& src3); + +/** @brief Divides a 4-channel matrix into 4 single-channel matrices. + +The function splits a 4-channel matrix into 4 single-channel matrices: +\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f] + +All output matrices must be of @ref CV_8UC1 type. + +The function merge4 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.split4" + +@param src input @ref CV_8UC4 matrix. +@sa split3, merge3, merge4 +*/ +GAPI_EXPORTS std::tuple split4(const GMat& src); + +/** @brief Divides a 3-channel matrix into 3 single-channel matrices. + +The function splits a 3-channel matrix into 3 single-channel matrices: +\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f] + +All output matrices must be of @ref CV_8UC1 type. + +The function merge3 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.split3" + +@param src input @ref CV_8UC3 matrix. +@sa split4, merge3, merge4 +*/ +GAPI_EXPORTS_W std::tuple split3(const GMat& src); + +/** @brief Applies a generic geometrical transformation to an image. + +The function remap transforms the source image using the specified map: + +\f[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\f] + +where values of pixels with non-integer coordinates are computed using one of available +interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps +in \f$map_1\f$ and \f$map_2\f$ respectively, or interleaved floating-point maps of \f$(x,y)\f$ in +\f$map_1\f$, or fixed-point maps created by using convertMaps. The reason you might want to +convert from floating to fixed-point representations of a map is that they can yield much faster +(\~2x) remapping operations. In the converted case, \f$map_1\f$ contains pairs (cvFloor(x), +cvFloor(y)) and \f$map_2\f$ contains indices in a table of interpolation coefficients. +Output image must be of the same size and depth as input one. + +@note + - Function textual ID is "org.opencv.core.transform.remap" + - Due to current implementation limitations the size of an input and output images should be less than 32767x32767. + +@param src Source image. +@param map1 The first map of either (x,y) points or just x values having the type CV_16SC2, +CV_32FC1, or CV_32FC2. +@param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map +if map1 is (x,y) points), respectively. +@param interpolation Interpolation method (see cv::InterpolationFlags). The methods #INTER_AREA +and #INTER_LINEAR_EXACT are not supported by this function. +@param borderMode Pixel extrapolation method (see cv::BorderTypes). When +borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that +corresponds to the "outliers" in the source image are not modified by the function. +@param borderValue Value used in case of a constant border. By default, it is 0. + */ +GAPI_EXPORTS GMat remap(const GMat& src, const Mat& map1, const Mat& map2, + int interpolation, int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @brief Flips a 2D matrix around vertical, horizontal, or both axes. + +The function flips the matrix in one of three different ways (row +and column indices are 0-based): +\f[\texttt{dst} _{ij} = +\left\{ +\begin{array}{l l} +\texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\ +\texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\ +\texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\ +\end{array} +\right.\f] +The example scenarios of using the function are the following: +* Vertical flipping of the image (flipCode == 0) to switch between + top-left and bottom-left image origin. This is a typical operation + in video processing on Microsoft Windows\* OS. +* Horizontal flipping of the image with the subsequent horizontal + shift and absolute difference calculation to check for a + vertical-axis symmetry (flipCode \> 0). +* Simultaneous horizontal and vertical flipping of the image with + the subsequent shift and absolute difference calculation to check + for a central symmetry (flipCode \< 0). +* Reversing the order of point arrays (flipCode \> 0 or + flipCode == 0). +Output image must be of the same depth as input one, size should be correct for given flipCode. + +@note Function textual ID is "org.opencv.core.transform.flip" + +@param src input matrix. +@param flipCode a flag to specify how to flip the array; 0 means +flipping around the x-axis and positive value (for example, 1) means +flipping around y-axis. Negative value (for example, -1) means flipping +around both axes. +@sa remap +*/ +GAPI_EXPORTS GMat flip(const GMat& src, int flipCode); + +/** @brief Crops a 2D matrix. + +The function crops the matrix by given cv::Rect. + +Output matrix must be of the same depth as input one, size is specified by given rect size. + +@note Function textual ID is "org.opencv.core.transform.crop" + +@param src input matrix. +@param rect a rect to crop a matrix to +@sa resize +*/ +GAPI_EXPORTS GMat crop(const GMat& src, const Rect& rect); + +/** @brief Applies horizontal concatenation to given matrices. + +The function horizontally concatenates two GMat matrices (with the same number of rows). +@code{.cpp} + GMat A = { 1, 4, + 2, 5, + 3, 6 }; + GMat B = { 7, 10, + 8, 11, + 9, 12 }; + + GMat C = gapi::concatHor(A, B); + //C: + //[1, 4, 7, 10; + // 2, 5, 8, 11; + // 3, 6, 9, 12] +@endcode +Output matrix must the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2. +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.imgproc.transform.concatHor" + +@param src1 first input matrix to be considered for horizontal concatenation. +@param src2 second input matrix to be considered for horizontal concatenation. +@sa concatVert +*/ +GAPI_EXPORTS GMat concatHor(const GMat& src1, const GMat& src2); + +/** @overload +The function horizontally concatenates given number of GMat matrices (with the same number of columns). +Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices. + +@param v vector of input matrices to be concatenated horizontally. +*/ +GAPI_EXPORTS GMat concatHor(const std::vector &v); + +/** @brief Applies vertical concatenation to given matrices. + +The function vertically concatenates two GMat matrices (with the same number of cols). + @code{.cpp} + GMat A = { 1, 7, + 2, 8, + 3, 9 }; + GMat B = { 4, 10, + 5, 11, + 6, 12 }; + + GMat C = gapi::concatVert(A, B); + //C: + //[1, 7; + // 2, 8; + // 3, 9; + // 4, 10; + // 5, 11; + // 6, 12] + @endcode + +Output matrix must the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2. +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.imgproc.transform.concatVert" + +@param src1 first input matrix to be considered for vertical concatenation. +@param src2 second input matrix to be considered for vertical concatenation. +@sa concatHor +*/ +GAPI_EXPORTS GMat concatVert(const GMat& src1, const GMat& src2); + +/** @overload +The function vertically concatenates given number of GMat matrices (with the same number of columns). +Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices. + +@param v vector of input matrices to be concatenated vertically. +*/ +GAPI_EXPORTS GMat concatVert(const std::vector &v); + + +/** @brief Performs a look-up table transform of a matrix. + +The function LUT fills the output matrix with values from the look-up table. Indices of the entries +are taken from the input matrix. That is, the function processes each element of src as follows: +\f[\texttt{dst} (I) \leftarrow \texttt{lut(src(I))}\f] + +Supported matrix data types are @ref CV_8UC1. +Output is a matrix of the same size and number of channels as src, and the same depth as lut. + +@note Function textual ID is "org.opencv.core.transform.LUT" + +@param src input matrix of 8-bit elements. +@param lut look-up table of 256 elements; in case of multi-channel input array, the table should +either have a single channel (in this case the same table is used for all channels) or the same +number of channels as in the input matrix. +*/ +GAPI_EXPORTS GMat LUT(const GMat& src, const Mat& lut); + +/** @brief Converts a matrix to another data depth with optional scaling. + +The method converts source pixel values to the target data depth. saturate_cast\<\> is applied at +the end to avoid possible overflows: + +\f[m(x,y) = saturate \_ cast( \alpha (*this)(x,y) + \beta )\f] +Output matrix must be of the same size as input one. + +@note Function textual ID is "org.opencv.core.transform.convertTo" +@param src input matrix to be converted from. +@param rdepth desired output matrix depth or, rather, the depth since the number of channels are the +same as the input has; if rdepth is negative, the output matrix will have the same depth as the input. +@param alpha optional scale factor. +@param beta optional delta added to the scaled values. + */ +GAPI_EXPORTS GMat convertTo(const GMat& src, int rdepth, double alpha=1, double beta=0); + +/** @brief Normalizes the norm or value range of an array. + +The function normalizes scale and shift the input array elements so that +\f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f] +(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that +\f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f] +when normType=NORM_MINMAX (for dense arrays only). + +@note Function textual ID is "org.opencv.core.normalize" + +@param src input array. +@param alpha norm value to normalize to or the lower range boundary in case of the range +normalization. +@param beta upper range boundary in case of the range normalization; it is not used for the norm +normalization. +@param norm_type normalization type (see cv::NormTypes). +@param ddepth when negative, the output array has the same type as src; otherwise, it has the same +number of channels as src and the depth =ddepth. +@sa norm, Mat::convertTo +*/ +GAPI_EXPORTS GMat normalize(const GMat& src, double alpha, double beta, + int norm_type, int ddepth = -1); + +/** @brief Applies a perspective transformation to an image. + +The function warpPerspective transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , + \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert +and then put in the formula above instead of M. The function cannot operate in-place. + +@param src input image. +@param M \f$3\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the +optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). +@param borderValue value used in case of a constant border; by default, it equals 0. + +@sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform + */ +GAPI_EXPORTS GMat warpPerspective(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR, + int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar()); + +/** @brief Applies an affine transformation to an image. + +The function warpAffine transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted +with #invertAffineTransform and then put in the formula above instead of M. The function cannot +operate in-place. + +@param src input image. +@param M \f$2\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (see #InterpolationFlags) and the optional +flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (see #BorderTypes); +borderMode=#BORDER_TRANSPARENT isn't supported +@param borderValue value used in case of a constant border; by default, it is 0. + +@sa warpPerspective, resize, remap, getRectSubPix, transform + */ +GAPI_EXPORTS GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR, + int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar()); +//! @} gapi_transform + +/** @brief Finds centers of clusters and groups input samples around the clusters. + +The function kmeans implements a k-means algorithm that finds the centers of K clusters +and groups the input samples around the clusters. As an output, \f$\texttt{bestLabels}_i\f$ +contains a 0-based cluster index for the \f$i^{th}\f$ sample. + +@note + - Function textual ID is "org.opencv.core.kmeansND" + - In case of an N-dimentional points' set given, input GMat can have the following traits: +2 dimensions, a single row or column if there are N channels, +or N columns if there is a single channel. Mat should have @ref CV_32F depth. + - Although, if GMat with height != 1, width != 1, channels != 1 given as data, n-dimensional +samples are considered given in amount of A, where A = height, n = width * channels. + - In case of GMat given as data: + - the output labels are returned as 1-channel GMat with sizes +width = 1, height = A, where A is samples amount, or width = bestLabels.width, +height = bestLabels.height if bestLabels given; + - the cluster centers are returned as 1-channel GMat with sizes +width = n, height = K, where n is samples' dimentionality and K is clusters' amount. + - As one of possible usages, if you want to control the initial labels for each attempt +by yourself, you can utilize just the core of the function. To do that, set the number +of attempts to 1, initialize labels each time using a custom algorithm, pass them with the +( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best (most-compact) clustering. + +@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed. +Function can take GArray, GArray for 2D and 3D cases or GMat for any +dimentionality and channels. +@param K Number of clusters to split the set by. +@param bestLabels Optional input integer array that can store the supposed initial cluster indices +for every sample. Used when ( flags = #KMEANS_USE_INITIAL_LABELS ) flag is set. +@param criteria The algorithm termination criteria, that is, the maximum number of iterations +and/or the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of +the cluster centers moves by less than criteria.epsilon on some iteration, the algorithm stops. +@param attempts Flag to specify the number of times the algorithm is executed using different +initial labellings. The algorithm returns the labels that yield the best compactness (see the first +function return value). +@param flags Flag that can take values of cv::KmeansFlags . + +@return + - Compactness measure that is computed as +\f[\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\f] +after every attempt. The best (minimum) value is chosen and the corresponding labels and the +compactness value are returned by the function. + - Integer array that stores the cluster indices for every sample. + - Array of the cluster centers. +*/ +GAPI_EXPORTS std::tuple,GMat,GMat> +kmeans(const GMat& data, const int K, const GMat& bestLabels, + const TermCriteria& criteria, const int attempts, const KmeansFlags flags); + +/** @overload +@note + - Function textual ID is "org.opencv.core.kmeansNDNoInit" + - #KMEANS_USE_INITIAL_LABELS flag must not be set while using this overload. + */ +GAPI_EXPORTS_W std::tuple,GMat,GMat> +kmeans(const GMat& data, const int K, const TermCriteria& criteria, const int attempts, + const KmeansFlags flags); + +/** @overload +@note Function textual ID is "org.opencv.core.kmeans2D" + */ +GAPI_EXPORTS_W std::tuple,GArray,GArray> +kmeans(const GArray& data, const int K, const GArray& bestLabels, + const TermCriteria& criteria, const int attempts, const KmeansFlags flags); + +/** @overload +@note Function textual ID is "org.opencv.core.kmeans3D" + */ +GAPI_EXPORTS std::tuple,GArray,GArray> +kmeans(const GArray& data, const int K, const GArray& bestLabels, + const TermCriteria& criteria, const int attempts, const KmeansFlags flags); + + +/** @brief Transposes a matrix. + +The function transposes the matrix: +\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f] + +@note + - Function textual ID is "org.opencv.core.transpose" + - No complex conjugation is done in case of a complex matrix. It should be done separately if needed. + +@param src input array. +*/ +GAPI_EXPORTS GMat transpose(const GMat& src); + + +namespace streaming { +/** @brief Gets dimensions from Mat. + +@note Function textual ID is "org.opencv.streaming.size" + +@param src Input tensor +@return Size (tensor dimensions). +*/ +GAPI_EXPORTS_W GOpaque size(const GMat& src); + +/** @overload +Gets dimensions from rectangle. + +@note Function textual ID is "org.opencv.streaming.sizeR" + +@param r Input rectangle. +@return Size (rectangle dimensions). +*/ +GAPI_EXPORTS_W GOpaque size(const GOpaque& r); + +/** @brief Gets dimensions from MediaFrame. + +@note Function textual ID is "org.opencv.streaming.sizeMF" + +@param src Input frame +@return Size (frame dimensions). +*/ +GAPI_EXPORTS GOpaque size(const GFrame& src); +} //namespace streaming +} //namespace gapi +} //namespace cv + +#endif //OPENCV_GAPI_CORE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/core.hpp new file mode 100644 index 0000000..ac08f91 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/core.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_CPU_CORE_API_HPP +#define OPENCV_GAPI_CPU_CORE_API_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { +namespace gapi { +namespace core { +namespace cpu { + +GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +} // namespace cpu +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_CORE_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/gcpukernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/gcpukernel.hpp new file mode 100644 index 0000000..48909a8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/gcpukernel.hpp @@ -0,0 +1,533 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GCPUKERNEL_HPP +#define OPENCV_GAPI_GCPUKERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include //suppress_unused_warning +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gimpl +{ + // Forward-declare an internal class + class GCPUExecutable; +} // namespace gimpl + +namespace gapi +{ +/** + * @brief This namespace contains G-API CPU backend functions, + * structures, and symbols. + */ +namespace cpu +{ + /** + * \addtogroup gapi_std_backends + * @{ + * + * @brief G-API backends available in this OpenCV version + * + * G-API backends play a corner stone role in G-API execution + * stack. Every backend is hardware-oriented and thus can run its + * kernels efficiently on the target platform. + * + * Backends are usually "black boxes" for G-API users -- on the API + * side, all backends are represented as different objects of the + * same class cv::gapi::GBackend. + * User can manipulate with backends by specifying which kernels to use. + * + * @sa @ref gapi_hld + */ + + /** + * @brief Get a reference to CPU (OpenCV) backend. + * + * This is the default backend in G-API at the moment, providing + * broader functional coverage but losing some graph model + * advantages. Provided mostly for reference and prototyping + * purposes. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ + + class GOCVFunctor; + + //! @cond IGNORED + template + GOCVFunctor ocv_kernel(const Callable& c); + + template + GOCVFunctor ocv_kernel(Callable& c); + //! @endcond + +} // namespace cpu +} // namespace gapi + +// Represents arguments which are passed to a wrapped CPU function +// FIXME: put into detail? +class GAPI_EXPORTS GCPUContext +{ +public: + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const cv::Mat& inMat(int input); + cv::Mat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR() + + const cv::Scalar& inVal(int input); + cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR() + cv::MediaFrame& outFrame(int output); + template std::vector& outVecR(int output) // FIXME: the same issue + { + return outVecRef(output).wref(); + } + template T& outOpaqueR(int output) // FIXME: the same issue + { + return outOpaqueRef(output).wref(); + } + + GArg state() + { + return m_state; + } + +protected: + detail::VectorRef& outVecRef(int output); + detail::OpaqueRef& outOpaqueRef(int output); + + std::vector m_args; + GArg m_state; + + //FIXME: avoid conversion of arguments from internal representation to OpenCV one on each call + //to OCV kernel. (This can be achieved by a two single time conversions in GCPUExecutable::run, + //once on enter for input and output arguments, and once before return for output arguments only + std::unordered_map m_results; + + friend class gimpl::GCPUExecutable; +}; + +class GAPI_EXPORTS GCPUKernel +{ +public: + // This function is a kernel's execution entry point (does the processing work) + using RunF = std::function; + // This function is a stateful kernel's setup routine (configures state) + using SetupF = std::function; + + GCPUKernel(); + GCPUKernel(const RunF& runF, const SetupF& setupF = nullptr); + + RunF m_runF = nullptr; + SetupF m_setupF = nullptr; + + bool m_isStateful = false; +}; + +// FIXME: This is an ugly ad-hoc implementation. TODO: refactor + +namespace detail +{ +template struct get_in; +template<> struct get_in +{ + static cv::Mat get(GCPUContext &ctx, int idx) { return ctx.inMat(idx); } +}; +template<> struct get_in +{ + static cv::Mat get(GCPUContext &ctx, int idx) { return get_in::get(ctx, idx); } +}; +template<> struct get_in +{ + static cv::MediaFrame get(GCPUContext &ctx, int idx) { return ctx.inArg(idx); } +}; +template<> struct get_in +{ + static cv::Scalar get(GCPUContext &ctx, int idx) { return ctx.inVal(idx); } +}; +template struct get_in > +{ + static const std::vector& get(GCPUContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct get_in > +{ + static const U& get(GCPUContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; + +//FIXME(dm): GArray/GArray conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +//FIXME(dm): GArray/GArray conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +// FIXME(dm): GArray>/GArray> conversion should be done more gracefully in the system +template struct get_in> >: public get_in> > +{ +}; + +//FIXME(dm): GOpaque/GOpaque conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +//FIXME(dm): GOpaque/GOpaque conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +template struct get_in +{ + static T get(GCPUContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +struct tracked_cv_mat{ + tracked_cv_mat(cv::Mat& m) : r{m}, original_data{m.data} {} + cv::Mat r; + uchar* original_data; + + operator cv::Mat& (){ return r;} + void validate() const{ + if (r.data != original_data) + { + util::throw_error + (std::logic_error + ("OpenCV kernel output parameter was reallocated. \n" + "Incorrect meta data was provided ?")); + } + } +}; + +template +void postprocess(Outputs&... outs) +{ + struct + { + void operator()(tracked_cv_mat* bm) { bm->validate(); } + void operator()(...) { } + + } validate; + //dummy array to unfold parameter pack + int dummy[] = { 0, (validate(&outs), 0)... }; + cv::util::suppress_unused_warning(dummy); +} + +template struct get_out; +template<> struct get_out +{ + static tracked_cv_mat get(GCPUContext &ctx, int idx) + { + auto& r = ctx.outMatR(idx); + return {r}; + } +}; +template<> struct get_out +{ + static tracked_cv_mat get(GCPUContext &ctx, int idx) + { + return get_out::get(ctx, idx); + } +}; +template<> struct get_out +{ + static cv::Scalar& get(GCPUContext &ctx, int idx) + { + return ctx.outValR(idx); + } +}; +template<> struct get_out +{ + static cv::MediaFrame& get(GCPUContext &ctx, int idx) + { + return ctx.outFrame(idx); + } +}; +template struct get_out> +{ + static std::vector& get(GCPUContext &ctx, int idx) + { + return ctx.outVecR(idx); + } +}; + +//FIXME(dm): GArray/GArray conversion should be done more gracefully in the system +template<> struct get_out >: public get_out > +{ +}; + +// FIXME(dm): GArray>/GArray> conversion should be done more gracefully in the system +template struct get_out> >: public get_out> > +{ +}; + +template struct get_out> +{ + static U& get(GCPUContext &ctx, int idx) + { + return ctx.outOpaqueR(idx); + } +}; + +template +struct OCVSetupHelper; + +template +struct OCVSetupHelper> +{ + // Using 'auto' return type and 'decltype' specifier in both 'setup_impl' versions + // to check existence of required 'Impl::setup' functions. + // While 'decltype' specifier accepts expression we pass expression with 'comma-operator' + // where first operand of comma-operator is call attempt to desired 'Impl::setup' and + // the second operand is 'void()' expression. + // + // SFINAE for 'Impl::setup' which accepts compile arguments. + template + static auto setup_impl(const GMetaArgs &metaArgs, const GArgs &args, + GArg &state, const GCompileArgs &compileArgs, + detail::Seq) -> + decltype(Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., + std::declval + >::type + >(), + compileArgs) + , void()) + { + // TODO: unique_ptr <-> shared_ptr conversion ? + // To check: Conversion is possible only if the state which should be passed to + // 'setup' user callback isn't required to have previous value + std::shared_ptr stPtr; + Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., stPtr, compileArgs); + state = GArg(stPtr); + } + + // SFINAE for 'Impl::setup' which doesn't accept compile arguments. + template + static auto setup_impl(const GMetaArgs &metaArgs, const GArgs &args, + GArg &state, const GCompileArgs &/* compileArgs */, + detail::Seq) -> + decltype(Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., + std::declval + >::type + >() + ) + , void()) + { + // The same comment as in 'setup' above. + std::shared_ptr stPtr; + Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., stPtr); + state = GArg(stPtr); + } + + static void setup(const GMetaArgs &metaArgs, const GArgs &args, + GArg& state, const GCompileArgs &compileArgs) + { + setup_impl(metaArgs, args, state, compileArgs, + typename detail::MkSeq::type()); + } +}; + +// OCVCallHelper is a helper class to call stateless OCV kernels and OCV kernel functors. +template +struct OCVCallHelper; + +// FIXME: probably can be simplified with std::apply or analogue. +template +struct OCVCallHelper, std::tuple> +{ + template + struct call_and_postprocess + { + template + static void call(Inputs&&... ins, Outputs&&... outs) + { + //not using a std::forward on outs is deliberate in order to + //cause compilation error, by trying to bind rvalue references to lvalue references + Impl::run(std::forward(ins)..., outs...); + postprocess(outs...); + } + + template + static void call(Impl& impl, Inputs&&... ins, Outputs&&... outs) + { + impl(std::forward(ins)..., outs...); + } + }; + + template + static void call_impl(GCPUContext &ctx, detail::Seq, detail::Seq) + { + //Make sure that OpenCV kernels do not reallocate memory for output parameters + //by comparing it's state (data ptr) before and after the call. + //This is done by converting each output Mat into tracked_cv_mat object, and binding + //them to parameters of ad-hoc function + call_and_postprocess::get(ctx, IIs))...> + ::call(get_in::get(ctx, IIs)..., get_out::get(ctx, OIs)...); + } + + template + static void call_impl(cv::GCPUContext &ctx, Impl& impl, + detail::Seq, detail::Seq) + { + call_and_postprocess::get(ctx, IIs))...> + ::call(impl, get_in::get(ctx, IIs)..., get_out::get(ctx, OIs)...); + } + + static void call(GCPUContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } + + // NB: Same as call but calling the object + // This necessary for kernel implementations that have a state + // and are represented as an object + static void callFunctor(cv::GCPUContext &ctx, Impl& impl) + { + call_impl(ctx, impl, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +// OCVStCallHelper is a helper class to call stateful OCV kernels. +template +struct OCVStCallHelper; + +template +struct OCVStCallHelper, std::tuple> : + OCVCallHelper, std::tuple> +{ + template + struct call_and_postprocess + { + template + static void call(typename Impl::State& st, Inputs&&... ins, Outputs&&... outs) + { + Impl::run(std::forward(ins)..., outs..., st); + postprocess(outs...); + } + }; + + template + static void call_impl(GCPUContext &ctx, detail::Seq, detail::Seq) + { + auto& st = *ctx.state().get>(); + call_and_postprocess::get(ctx, IIs))...> + ::call(st, get_in::get(ctx, IIs)..., get_out::get(ctx, OIs)...); + } + + static void call(GCPUContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GCPUKernelImpl: public cv::detail::KernelTag +{ + using CallHelper = cv::detail::OCVCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::cpu::backend(); } + static cv::GCPUKernel kernel() { return GCPUKernel(&CallHelper::call); } +}; + +template +class GCPUStKernelImpl: public cv::detail::KernelTag +{ + using StSetupHelper = detail::OCVSetupHelper; + using StCallHelper = detail::OCVStCallHelper; + +public: + using API = K; + using State = S; + + static cv::gapi::GBackend backend() { return cv::gapi::cpu::backend(); } + static cv::GCPUKernel kernel() { return GCPUKernel(&StCallHelper::call, + &StSetupHelper::setup); } +}; + +#define GAPI_OCV_KERNEL(Name, API) struct Name: public cv::GCPUKernelImpl + +// TODO: Reuse Anatoliy's logic for support of types with commas in macro. +// Retrieve the common part from Anatoliy's logic to the separate place. +#define GAPI_OCV_KERNEL_ST(Name, API, State) \ + struct Name: public cv::GCPUStKernelImpl \ + +/// @private +class gapi::cpu::GOCVFunctor : public gapi::GFunctor +{ +public: + using Impl = std::function; + using Meta = cv::GKernel::M; + + GOCVFunctor(const char* id, const Meta &meta, const Impl& impl) + : gapi::GFunctor(id), impl_{GCPUKernel(impl), meta} + { + } + + GKernelImpl impl() const override { return impl_; } + gapi::GBackend backend() const override { return gapi::cpu::backend(); } + +private: + GKernelImpl impl_; +}; + +//! @cond IGNORED +template +gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(Callable& c) +{ + using P = cv::detail::OCVCallHelper; + return GOCVFunctor{ K::id() + , &K::getOutMeta + , std::bind(&P::callFunctor, std::placeholders::_1, std::ref(c)) + }; +} + +template +gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(const Callable& c) +{ + using P = cv::detail::OCVCallHelper; + return GOCVFunctor{ K::id() + , &K::getOutMeta + , std::bind(&P::callFunctor, std::placeholders::_1, c) + }; +} +//! @endcond + +} // namespace cv + +#endif // OPENCV_GAPI_GCPUKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/imgproc.hpp new file mode 100644 index 0000000..0b96db0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/imgproc.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_CPU_IMGPROC_API_HPP +#define OPENCV_GAPI_CPU_IMGPROC_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace imgproc { +namespace cpu { + +GAPI_EXPORTS GKernelPackage kernels(); + +} // namespace cpu +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_IMGPROC_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/stereo.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/stereo.hpp new file mode 100644 index 0000000..e2a2242 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/stereo.hpp @@ -0,0 +1,48 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_CPU_STEREO_API_HPP +#define OPENCV_GAPI_CPU_STEREO_API_HPP + +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace calib3d { +namespace cpu { + +GAPI_EXPORTS GKernelPackage kernels(); + +/** @brief Structure for the Stereo operation initialization parameters.*/ +struct GAPI_EXPORTS StereoInitParam { + StereoInitParam(int nD, int bS, double bL, double f): + numDisparities(nD), blockSize(bS), baseline(bL), focus(f) {} + + StereoInitParam() = default; + + int numDisparities = 0; + int blockSize = 21; + double baseline = 63.5; + double focus = 3.6; +}; + +} // namespace cpu +} // namespace calib3d +} // namespace gapi + +namespace detail { + + template<> struct CompileArgTag { + static const char* tag() { + return "org.opencv.stereoInit"; + } +}; + +} // namespace detail +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_STEREO_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/video.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/video.hpp new file mode 100644 index 0000000..d3c1f2e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/cpu/video.hpp @@ -0,0 +1,25 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_CPU_VIDEO_API_HPP +#define OPENCV_GAPI_CPU_VIDEO_API_HPP + +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace video { +namespace cpu { + +GAPI_EXPORTS GKernelPackage kernels(); + +} // namespace cpu +} // namespace video +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_VIDEO_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/core.hpp new file mode 100644 index 0000000..9eceb82 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/core.hpp @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_CORE_HPP +#define OPENCV_GAPI_FLUID_CORE_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { namespace gapi { namespace core { namespace fluid { + +GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +}}}} + +#endif // OPENCV_GAPI_FLUID_CORE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidbuffer.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidbuffer.hpp new file mode 100644 index 0000000..551f0a3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidbuffer.hpp @@ -0,0 +1,154 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_BUFFER_HPP +#define OPENCV_GAPI_FLUID_BUFFER_HPP + +#include +#include // accumulate +#include // ostream +#include // uint8_t + +#include +#include + +#include + +namespace cv { +namespace gapi { +namespace fluid { + +struct Border +{ + // This constructor is required to support existing kernels which are part of G-API + Border(int _type, cv::Scalar _val) : type(_type), value(_val) {} + + int type; + cv::Scalar value; +}; + +using BorderOpt = util::optional; + +bool operator == (const Border& b1, const Border& b2); + +class GAPI_EXPORTS Buffer; + +class GAPI_EXPORTS View +{ +public: + struct Cache + { + std::vector m_linePtrs; + GMatDesc m_desc; + int m_border_size = 0; + + inline const uint8_t* linePtr(int index) const + { + // "out_of_window" check: + // user must not request the lines which are outside of specified kernel window + GAPI_DbgAssert(index >= -m_border_size + && index < -m_border_size + static_cast(m_linePtrs.size())); + return m_linePtrs[index + m_border_size]; + } + }; + + const inline uint8_t* InLineB(int index) const // -(w-1)/2...0...+(w-1)/2 for Filters + { + return m_cache->linePtr(index); + } + + template const inline T* InLine(int i) const + { + const uint8_t* ptr = this->InLineB(i); + return reinterpret_cast(ptr); + } + + inline operator bool() const { return m_priv != nullptr; } + bool ready() const; + inline int length() const { return m_cache->m_desc.size.width; } + int y() const; + + inline const GMatDesc& meta() const { return m_cache->m_desc; } + + class GAPI_EXPORTS Priv; // internal use only + Priv& priv(); // internal use only + const Priv& priv() const; // internal use only + + View(); + View(std::unique_ptr&& p); + View(View&& v); + View& operator=(View&& v); + ~View(); + +private: + std::unique_ptr m_priv; + const Cache* m_cache = nullptr; +}; + +class GAPI_EXPORTS Buffer +{ +public: + struct Cache + { + std::vector m_linePtrs; + GMatDesc m_desc; + }; + + // Default constructor (executable creation stage, + // all following initialization performed in Priv::init()) + Buffer(); + // Scratch constructor (user kernels) + Buffer(const cv::GMatDesc &desc); + + // Constructor for intermediate buffers (for tests) + Buffer(const cv::GMatDesc &desc, + int max_line_consumption, int border_size, + int skew, + int wlpi, + BorderOpt border); + // Constructor for in/out buffers (for tests) + Buffer(const cv::Mat &data, bool is_input); + ~Buffer(); + Buffer& operator=(Buffer&&); + + inline uint8_t* OutLineB(int index = 0) + { + return m_cache->m_linePtrs[index]; + } + + template inline T* OutLine(int index = 0) + { + uint8_t* ptr = this->OutLineB(index); + return reinterpret_cast(ptr); + } + + int y() const; + + int linesReady() const; + void debug(std::ostream &os) const; + inline int length() const { return m_cache->m_desc.size.width; } + int lpi() const; // LPI for WRITER + + inline const GMatDesc& meta() const { return m_cache->m_desc; } + + View mkView(int borderSize, bool ownStorage); + void addView(const View* v); + + class GAPI_EXPORTS Priv; // internal use only + Priv& priv(); // internal use only + const Priv& priv() const; // internal use only + +private: + std::unique_ptr m_priv; + const Cache* m_cache; +}; + +} // namespace cv::gapi::fluid +} // namespace cv::gapi +} // namespace cv + +#endif // OPENCV_GAPI_FLUID_BUFFER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidkernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidkernel.hpp new file mode 100644 index 0000000..53b68c4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidkernel.hpp @@ -0,0 +1,442 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_KERNEL_HPP +#define OPENCV_GAPI_FLUID_KERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gapi +{ +/** + * @brief This namespace contains G-API Fluid backend functions, structures, and symbols. + */ +namespace fluid +{ + /** + * \addtogroup gapi_std_backends G-API Standard Backends + * @{ + */ + /** + * @brief Get a reference to Fluid backend. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ +} // namespace fluid +} // namespace gapi + + +class GAPI_EXPORTS GFluidKernel +{ +public: + enum class Kind + { + Filter, + Resize, + YUV420toRGB //Color conversion of 4:2:0 chroma sub-sampling formats (NV12, I420 ..etc) to RGB + }; + + // This function is a generic "doWork" callback + using F = std::function &)>; + + // This function is a generic "initScratch" callback + using IS = std::function; + + // This function is a generic "resetScratch" callback + using RS = std::function; + + // This function describes kernel metadata inference rule. + using M = std::function; + + // This function is a generic "getBorder" callback (extracts border-related data from kernel's input parameters) + using B = std::function; + + // This function is a generic "getWindow" callback (extracts window-related data from kernel's input parameters) + using GW = std::function; + + // FIXME: move implementations out of header file + GFluidKernel() {} + GFluidKernel(Kind k, int l, bool scratch, const F& f, const IS &is, const RS &rs, const B& b, const GW& win) + : m_kind(k) + , m_lpi(l) + , m_scratch(scratch) + , m_f(f) + , m_is(is) + , m_rs(rs) + , m_b(b) + , m_gw(win) {} + + Kind m_kind; + const int m_lpi = -1; + const bool m_scratch = false; + + const F m_f; + const IS m_is; + const RS m_rs; + const B m_b; + const GW m_gw; +}; + +// FIXME!!! +// This is the temporary and experimental API +// which should be replaced by runtime roi-based scheduling +/** \addtogroup gapi_compile_args + * @{ + */ +/** + * @brief This structure allows to control the output image region + * which Fluid backend will produce in the graph. + * + * This feature is useful for external tiling and parallelism, but + * will be deprecated in the future releases. + */ +struct GFluidOutputRois +{ + std::vector rois; +}; + +/** + * @brief This structure forces Fluid backend to generate multiple + * parallel output regions in the graph. These regions execute in parallel. + * + * This feature may be deprecated in the future releases. + */ +struct GFluidParallelOutputRois +{ + std::vector parallel_rois; +}; + +/** + * @brief This structure allows to customize the way how Fluid executes + * parallel regions. + * + * For example, user can utilize his own threading runtime via this parameter. + * The `parallel_for` member functor is called by the Fluid runtime with the + * following arguments: + * + * @param size Size of the parallel range to process + * @param f A function which should be called for every integer index + * in this range by the specified parallel_for implementation. + * + * This feature may be deprecated in the future releases. + */ +struct GFluidParallelFor +{ + //this function accepts: + // - size of the "parallel" range as the first argument + // - and a function to be called on the range items, designated by item index + std::function)> parallel_for; +}; +/** @} gapi_compile_args */ + +namespace detail +{ +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.fluid.outputRois"; } +}; + +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.fluid.parallelFor"; } +}; + +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.fluid.parallelOutputRois"; } +}; + +} // namespace detail + +namespace detail +{ +template struct fluid_get_in; +template<> struct fluid_get_in +{ + static const cv::gapi::fluid::View& get(const cv::GArgs &in_args, int idx) + { + return *in_args[idx].unsafe_get(); + } +}; + +template<> struct fluid_get_in +{ + // FIXME: change to return by reference when moved to own::Scalar + static const cv::Scalar get(const cv::GArgs &in_args, int idx) + { + return in_args[idx].unsafe_get(); + } +}; + +template struct fluid_get_in> +{ + static const std::vector& get(const cv::GArgs &in_args, int idx) + { + return in_args.at(idx).unsafe_get().rref(); + } +}; + +template struct fluid_get_in> +{ + static const U& get(const cv::GArgs &in_args, int idx) + { + return in_args.at(idx).unsafe_get().rref(); + } +}; + +template struct fluid_get_in +{ + static const T& get(const cv::GArgs &in_args, int idx) + { + return in_args[idx].unsafe_get(); + } +}; + +template +struct scratch_helper; + +template +struct scratch_helper +{ + // Init + template + static void help_init_impl(const cv::GMetaArgs &metas, + const cv::GArgs &in_args, + gapi::fluid::Buffer &scratch_buf, + detail::Seq) + { + Impl::initScratch(get_in_meta(metas, in_args, IIs)..., scratch_buf); + } + + static void help_init(const cv::GMetaArgs &metas, + const cv::GArgs &in_args, + gapi::fluid::Buffer &b) + { + help_init_impl(metas, in_args, b, typename detail::MkSeq::type()); + } + + // Reset + static void help_reset(gapi::fluid::Buffer &b) + { + Impl::resetScratch(b); + } +}; + +template +struct scratch_helper +{ + static void help_init(const cv::GMetaArgs &, + const cv::GArgs &, + gapi::fluid::Buffer &) + { + GAPI_Assert(false); + } + static void help_reset(gapi::fluid::Buffer &) + { + GAPI_Assert(false); + } +}; + +template struct is_gmat_type +{ + static const constexpr bool value = std::is_same::value; +}; + +template +struct get_border_helper; + +template +struct get_border_helper +{ + template + static gapi::fluid::BorderOpt get_border_impl(const GMetaArgs &metas, + const cv::GArgs &in_args, + cv::detail::Seq) + { + return util::make_optional(Impl::getBorder(cv::detail::get_in_meta(metas, in_args, IIs)...)); + } + + static gapi::fluid::BorderOpt help(const GMetaArgs &metas, + const cv::GArgs &in_args) + { + return get_border_impl(metas, in_args, typename detail::MkSeq::type()); + } +}; + +template +struct get_border_helper +{ + static gapi::fluid::BorderOpt help(const cv::GMetaArgs &, + const cv::GArgs &) + { + return {}; + } +}; + +template +struct get_window_helper; + +template +struct get_window_helper +{ + template + static int get_window_impl(const GMetaArgs &metas, + const cv::GArgs &in_args, + cv::detail::Seq) + { + return Impl::getWindow(cv::detail::get_in_meta(metas, in_args, IIs)...); + } + + static int help(const GMetaArgs &metas, const cv::GArgs &in_args) + { + return get_window_impl(metas, in_args, typename detail::MkSeq::type()); + } +}; + +template +struct get_window_helper +{ + static int help(const cv::GMetaArgs &, + const cv::GArgs &) + { + return Impl::Window; + } +}; + +template +struct has_Window +{ +private: + template + static constexpr auto Check(U*) -> typename std::is_same::type; + + template + static constexpr std::false_type Check(...); + + typedef decltype(Check(0)) Result; + +public: + static constexpr bool value = Result::value; +}; + +template +struct callCustomGetBorder; + +template +struct callCustomGetBorder +{ + static constexpr bool value = (Impl::Window != 1); +}; + +template +struct callCustomGetBorder +{ + static constexpr bool value = true; +}; + +template +struct FluidCallHelper; + +template +struct FluidCallHelper, std::tuple, UseScratch> +{ + static_assert(all_satisfy::value, "return type must be GMat"); + static_assert(contains::value, "input must contain at least one GMat"); + + // Execution dispatcher //////////////////////////////////////////////////// + template + static void call_impl(const cv::GArgs &in_args, + const std::vector &out_bufs, + detail::Seq, + detail::Seq) + { + Impl::run(fluid_get_in::get(in_args, IIs)..., *out_bufs[OIs]...); + } + + static void call(const cv::GArgs &in_args, + const std::vector &out_bufs) + { + constexpr int numOuts = (sizeof...(Outs)) + (UseScratch ? 1 : 0); + call_impl(in_args, out_bufs, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } + + // Scratch buffer initialization dispatcher //////////////////////////////// + static void init_scratch(const GMetaArgs &metas, + const cv::GArgs &in_args, + gapi::fluid::Buffer &b) + { + scratch_helper::help_init(metas, in_args, b); + } + + // Scratch buffer reset dispatcher ///////////////////////////////////////// + static void reset_scratch(gapi::fluid::Buffer &scratch_buf) + { + scratch_helper::help_reset(scratch_buf); + } + + static gapi::fluid::BorderOpt getBorder(const GMetaArgs &metas, const cv::GArgs &in_args) + { + constexpr bool hasWindow = has_Window::value; + + // User must provide "init" callback if Window != 1 + // TODO: move to constexpr if when we enable C++17 + return get_border_helper::value, Impl, Ins...>::help(metas, in_args); + } + + static int getWindow(const GMetaArgs &metas, const cv::GArgs &in_args) + { + constexpr bool callCustomGetWindow = !(has_Window::value); + return get_window_helper::help(metas, in_args); + } +}; +} // namespace detail + + +template +class GFluidKernelImpl : public cv::detail::KernelTag +{ + static const int LPI = 1; + static const auto Kind = GFluidKernel::Kind::Filter; + using P = detail::FluidCallHelper; + +public: + using API = K; + + static GFluidKernel kernel() + { + // FIXME: call() and getOutMeta() needs to be renamed so it is clear these + // functions are internal wrappers, not user API + return GFluidKernel(Impl::Kind, Impl::LPI, + UseScratch, + &P::call, &P::init_scratch, &P::reset_scratch, &P::getBorder, &P::getWindow); + } + + static cv::gapi::GBackend backend() { return cv::gapi::fluid::backend(); } +}; + +#define GAPI_FLUID_KERNEL(Name, API, Scratch) struct Name: public cv::GFluidKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GCPUKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/imgproc.hpp new file mode 100644 index 0000000..dedfa9d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/fluid/imgproc.hpp @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_IMGPROC_HPP +#define OPENCV_GAPI_FLUID_IMGPROC_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { namespace gapi { namespace imgproc { namespace fluid { + +GAPI_EXPORTS GKernelPackage kernels(); + +}}}} + +#endif // OPENCV_GAPI_FLUID_IMGPROC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/garg.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/garg.hpp new file mode 100644 index 0000000..bfe147f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/garg.hpp @@ -0,0 +1,309 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GARG_HPP +#define OPENCV_GAPI_GARG_HPP + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cv { + +class GArg; + +namespace detail { + template + using is_garg = std::is_same::type>; +} + +// Parameter holder class for a node +// Depending on platform capabilities, can either support arbitrary types +// (as `boost::any`) or a limited number of types (as `boot::variant`). +// FIXME: put into "details" as a user shouldn't use it in his code +class GAPI_EXPORTS GArg +{ +public: + GArg() {} + + template::value, int>::type = 0> + explicit GArg(const T &t) + : kind(detail::GTypeTraits::kind) + , opaque_kind(detail::GOpaqueTraits::kind) + , value(detail::wrap_gapi_helper::wrap(t)) + { + } + + template::value, int>::type = 0> + explicit GArg(T &&t) + : kind(detail::GTypeTraits::type>::kind) + , opaque_kind(detail::GOpaqueTraits::type>::kind) + , value(detail::wrap_gapi_helper::wrap(t)) + { + } + + template inline T& get() + { + return util::any_cast::type>(value); + } + + template inline const T& get() const + { + return util::any_cast::type>(value); + } + + template inline T& unsafe_get() + { + return util::unsafe_any_cast::type>(value); + } + + template inline const T& unsafe_get() const + { + return util::unsafe_any_cast::type>(value); + } + + detail::ArgKind kind = detail::ArgKind::OPAQUE_VAL; + detail::OpaqueKind opaque_kind = detail::OpaqueKind::CV_UNKNOWN; + +protected: + util::any value; +}; + +using GArgs = std::vector; + +// FIXME: Express as M::type +// FIXME: Move to a separate file! +using GRunArgBase = util::variant< +#if !defined(GAPI_STANDALONE) + cv::UMat, +#endif // !defined(GAPI_STANDALONE) + cv::RMat, + cv::gapi::wip::IStreamSource::Ptr, + cv::Mat, + cv::Scalar, + cv::detail::VectorRef, + cv::detail::OpaqueRef, + cv::MediaFrame + >; + +namespace detail { +template +struct in_variant; + +template +struct in_variant > + : std::integral_constant::value > { +}; +} // namespace detail + +struct GAPI_EXPORTS GRunArg: public GRunArgBase +{ + // Metadata information here + using Meta = std::unordered_map; + Meta meta; + + // Mimic the old GRunArg semantics here, old of the times when + // GRunArg was an alias to variant<> + GRunArg(); + GRunArg(const cv::GRunArg &arg); + GRunArg(cv::GRunArg &&arg); + + GRunArg& operator= (const GRunArg &arg); + GRunArg& operator= (GRunArg &&arg); + + template + GRunArg(const T &t, + const Meta &m = Meta{}, + typename std::enable_if< detail::in_variant::value, int>::type = 0) + : GRunArgBase(t) + , meta(m) + { + } + template + GRunArg(T &&t, + const Meta &m = Meta{}, + typename std::enable_if< detail::in_variant::value, int>::type = 0) + : GRunArgBase(std::move(t)) + , meta(m) + { + } + template auto operator= (const T &t) + -> typename std::enable_if< detail::in_variant::value, cv::GRunArg>::type& + { + GRunArgBase::operator=(t); + return *this; + } + template auto operator= (T&& t) + -> typename std::enable_if< detail::in_variant::value, cv::GRunArg>::type& + { + GRunArgBase::operator=(std::move(t)); + return *this; + } +}; +using GRunArgs = std::vector; + +// TODO: Think about the addition operator +/** + * @brief This operator allows to complement the input vector at runtime. + * + * It's an ordinary overload of addition assignment operator. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GRunArgs usage + * + */ +inline GRunArgs& operator += (GRunArgs &lhs, const GRunArgs &rhs) +{ + lhs.reserve(lhs.size() + rhs.size()); + lhs.insert(lhs.end(), rhs.begin(), rhs.end()); + return lhs; +} + +namespace gapi +{ +namespace wip +{ +/** + * @brief This aggregate type represents all types which G-API can + * handle (via variant). + * + * It only exists to overcome C++ language limitations (where a + * `using`-defined class can't be forward-declared). + */ +struct GAPI_EXPORTS Data: public GRunArg +{ + using GRunArg::GRunArg; + template + Data& operator= (const T& t) { GRunArg::operator=(t); return *this; } + template + Data& operator= (T&& t) { GRunArg::operator=(std::move(t)); return *this; } +}; +} // namespace wip +} // namespace gapi + +using GRunArgP = util::variant< +#if !defined(GAPI_STANDALONE) + cv::UMat*, +#endif // !defined(GAPI_STANDALONE) + cv::Mat*, + cv::RMat*, + cv::Scalar*, + cv::MediaFrame*, + cv::detail::VectorRef, + cv::detail::OpaqueRef + >; +using GRunArgsP = std::vector; + +// TODO: Think about the addition operator +/** + * @brief This operator allows to complement the output vector at runtime. + * + * It's an ordinary overload of addition assignment operator. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GRunArgsP usage + * + */ +inline GRunArgsP& operator += (GRunArgsP &lhs, const GRunArgsP &rhs) +{ + lhs.reserve(lhs.size() + rhs.size()); + lhs.insert(lhs.end(), rhs.begin(), rhs.end()); + return lhs; +} + +namespace gapi +{ +/** + * \addtogroup gapi_serialization + * @{ + * + * @brief G-API functions and classes for serialization and deserialization. + */ +/** @brief Wraps deserialized output GRunArgs to GRunArgsP which can be used by GCompiled. + * + * Since it's impossible to get modifiable output arguments from deserialization + * it needs to be wrapped by this function. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp bind after deserialization + * + * @param out_args deserialized GRunArgs. + * @return the same GRunArgs wrapped in GRunArgsP. + * @see deserialize + */ +GAPI_EXPORTS cv::GRunArgsP bind(cv::GRunArgs &out_args); +/** @brief Wraps output GRunArgsP available during graph execution to GRunArgs which can be serialized. + * + * GRunArgsP is pointer-to-value, so to be serialized they need to be binded to real values + * which this function does. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp bind before serialization + * + * @param out output GRunArgsP available during graph execution. + * @return the same GRunArgsP wrapped in serializable GRunArgs. + * @see serialize + */ +GAPI_EXPORTS cv::GRunArg bind(cv::GRunArgP &out); // FIXME: think more about it +/** @} */ +} + +template inline GRunArgs gin(const Ts&... args) +{ + return GRunArgs{ GRunArg(detail::wrap_host_helper::wrap_in(args))... }; +} + +template inline GRunArgsP gout(Ts&... args) +{ + return GRunArgsP{ GRunArgP(detail::wrap_host_helper::wrap_out(args))... }; +} + +struct GTypeInfo; +using GTypesInfo = std::vector; + +// FIXME: Needed for python bridge, must be moved to more appropriate header +namespace detail { +struct ExtractArgsCallback +{ + cv::GRunArgs operator()(const cv::GTypesInfo& info) const { return c(info); } + using CallBackT = std::function; + CallBackT c; +}; + +struct ExtractMetaCallback +{ + cv::GMetaArgs operator()(const cv::GTypesInfo& info) const { return c(info); } + using CallBackT = std::function; + CallBackT c; +}; + +void constructGraphOutputs(const cv::GTypesInfo &out_info, + cv::GRunArgs &args, + cv::GRunArgsP &outs); +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_GARG_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/garray.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/garray.hpp new file mode 100644 index 0000000..17b0333 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/garray.hpp @@ -0,0 +1,440 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GARRAY_HPP +#define OPENCV_GAPI_GARRAY_HPP + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include // flatten_g only! +#include // flatten_g only! + +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; +template class GArray; + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GArrayDesc +{ + // FIXME: Body + // FIXME: Also implement proper operator== then + bool operator== (const GArrayDesc&) const { return true; } +}; +template GArrayDesc descr_of(const std::vector &) { return {};} +GAPI_EXPORTS_W inline GArrayDesc empty_array_desc() {return {}; } +/** @} */ + +std::ostream& operator<<(std::ostream& os, const cv::GArrayDesc &desc); + +namespace detail +{ + // ConstructVec is a callback which stores information about T and is used by + // G-API runtime to construct arrays in host memory (T remains opaque for G-API). + // ConstructVec is carried into G-API internals by GArrayU. + // Currently it is suitable for Host (CPU) plugins only, real offload may require + // more information for manual memory allocation on-device. + class VectorRef; + using ConstructVec = std::function; + + // This is the base struct for GArrayU type holder + struct TypeHintBase{virtual ~TypeHintBase() = default;}; + + // This class holds type of initial GArray to be checked from GArrayU + template + struct TypeHint final : public TypeHintBase{}; + + // This class strips type information from GArray and makes it usable + // in the G-API graph compiler (expression unrolling, graph generation, etc). + // Part of GProtoArg. + class GAPI_EXPORTS GArrayU + { + public: + GArrayU(const GNode &n, std::size_t out); // Operation result constructor + + template + bool holds() const; // Check if was created from GArray + + GOrigin& priv(); // Internal use only + const GOrigin& priv() const; // Internal use only + + protected: + GArrayU(); // Default constructor + GArrayU(const detail::VectorRef& vref); // Constant value constructor + template friend class cv::GArray; // (available to GArray only) + + void setConstructFcn(ConstructVec &&cv); // Store T-aware constructor + + template + void specifyType(); // Store type of initial GArray + + template + void storeKind(); + + void setKind(cv::detail::OpaqueKind); + + std::shared_ptr m_priv; + std::shared_ptr m_hint; + }; + + template + bool GArrayU::holds() const{ + GAPI_Assert(m_hint != nullptr); + using U = typename std::decay::type; + return dynamic_cast*>(m_hint.get()) != nullptr; + }; + + template + void GArrayU::specifyType(){ + m_hint.reset(new TypeHint::type>); + }; + + template + void GArrayU::storeKind(){ + setKind(cv::detail::GOpaqueTraits::kind); + }; + + // This class represents a typed STL vector reference. + // Depending on origins, this reference may be either "just a" reference to + // an object created externally, OR actually own the underlying object + // (be value holder). + class BasicVectorRef + { + public: + // These fields are set by the derived class(es) + std::size_t m_elemSize = 0ul; + cv::GArrayDesc m_desc; + virtual ~BasicVectorRef() {} + + virtual void mov(BasicVectorRef &ref) = 0; + virtual const void* ptr() const = 0; + virtual std::size_t size() const = 0; + }; + + template class VectorRefT final: public BasicVectorRef + { + using empty_t = util::monostate; + using ro_ext_t = const std::vector *; + using rw_ext_t = std::vector *; + using rw_own_t = std::vector ; + util::variant m_ref; + + inline bool isEmpty() const { return util::holds_alternative(m_ref); } + inline bool isROExt() const { return util::holds_alternative(m_ref); } + inline bool isRWExt() const { return util::holds_alternative(m_ref); } + inline bool isRWOwn() const { return util::holds_alternative(m_ref); } + + void init(const std::vector* vec = nullptr) + { + m_elemSize = sizeof(T); + if (vec) m_desc = cv::descr_of(*vec); + } + + public: + VectorRefT() { init(); } + virtual ~VectorRefT() {} + + explicit VectorRefT(const std::vector& vec) : m_ref(&vec) { init(&vec); } + explicit VectorRefT(std::vector& vec) : m_ref(&vec) { init(&vec); } + explicit VectorRefT(std::vector&& vec) : m_ref(std::move(vec)) { init(&vec); } + + // Reset a VectorRefT. Called only for objects instantiated + // internally in G-API (e.g. temporary GArray's within a + // computation). Reset here means both initialization + // (creating an object) and reset (discarding its existing + // content before the next execution). Must never be called + // for external VectorRefTs. + void reset() + { + if (isEmpty()) + { + std::vector empty_vector; + m_desc = cv::descr_of(empty_vector); + m_ref = std::move(empty_vector); + GAPI_Assert(isRWOwn()); + } + else if (isRWOwn()) + { + util::get(m_ref).clear(); + } + else GAPI_Assert(false); // shouldn't be called in *EXT modes + } + + // Obtain a WRITE reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + std::vector& wref() + { + GAPI_Assert(isRWExt() || isRWOwn()); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + // Obtain a READ reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + const std::vector& rref() const + { + // ANY vector can be accessed for reading, even if it declared for + // output. Example -- a GComputation from [in] to [out1,out2] + // where [out2] is a result of operation applied to [out1]: + // + // GComputation boundary + // . . . . . . . + // . . + // [in] ----> foo() ----> [out1] + // . . : + // . . . .:. . . + // . V . + // . bar() ---> [out2] + // . . . . . . . . . . . . + // + if (isROExt()) return *util::get(m_ref); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + virtual void mov(BasicVectorRef &v) override { + VectorRefT *tv = dynamic_cast*>(&v); + GAPI_Assert(tv != nullptr); + wref() = std::move(tv->wref()); + } + + virtual const void* ptr() const override { return &rref(); } + virtual std::size_t size() const override { return rref().size(); } + }; + + // This class strips type information from VectorRefT<> and makes it usable + // in the G-API executables (carrying run-time data/information to kernels). + // Part of GRunArg. + // Its methods are typed proxies to VectorRefT. + // VectorRef maintains "reference" semantics so two copies of VectoRef refer + // to the same underlying object. + // FIXME: Put a good explanation on why cv::OutputArray doesn't fit this role + class VectorRef + { + std::shared_ptr m_ref; + cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN; + + template inline void check() const + { + GAPI_DbgAssert(dynamic_cast*>(m_ref.get()) != nullptr); + GAPI_Assert(sizeof(T) == m_ref->m_elemSize); + } + + public: + VectorRef() = default; + template explicit VectorRef(const std::vector& vec) + : m_ref(new VectorRefT(vec)) + , m_kind(GOpaqueTraits::kind) + {} + template explicit VectorRef(std::vector& vec) + : m_ref(new VectorRefT(vec)) + , m_kind(GOpaqueTraits::kind) + {} + template explicit VectorRef(std::vector&& vec) + : m_ref(new VectorRefT(std::move(vec))) + , m_kind(GOpaqueTraits::kind) + {} + + cv::detail::OpaqueKind getKind() const + { + return m_kind; + } + + template void reset() + { + if (!m_ref) m_ref.reset(new VectorRefT()); + check(); + storeKind(); + static_cast&>(*m_ref).reset(); + } + + template + void storeKind() + { + m_kind = cv::detail::GOpaqueTraits::kind; + } + + template std::vector& wref() + { + check(); + return static_cast&>(*m_ref).wref(); + } + + template const std::vector& rref() const + { + check(); + return static_cast&>(*m_ref).rref(); + } + + // Check if was created for/from std::vector + template bool holds() const + { + if (!m_ref) return false; + using U = typename std::decay::type; + return dynamic_cast*>(m_ref.get()) != nullptr; + } + + void mov(VectorRef &v) + { + m_ref->mov(*v.m_ref); + } + + cv::GArrayDesc descr_of() const + { + return m_ref->m_desc; + } + + std::size_t size() const + { + return m_ref->size(); + } + + // May be used to uniquely identify this object internally + const void *ptr() const { return m_ref->ptr(); } + }; + + // Helper (FIXME: work-around?) + // stripping G types to their host types + // like cv::GArray would still map to std::vector + // but not to std::vector +#if defined(GAPI_STANDALONE) +# define FLATTEN_NS cv::gapi::own +#else +# define FLATTEN_NS cv +#endif + template struct flatten_g; + template<> struct flatten_g { using type = FLATTEN_NS::Mat; }; + template<> struct flatten_g { using type = FLATTEN_NS::Scalar; }; + template struct flatten_g> { using type = std::vector; }; + template struct flatten_g { using type = T; }; +#undef FLATTEN_NS + // FIXME: the above mainly duplicates "ProtoToParam" thing from gtyped.hpp + // but I decided not to include gtyped here - probably worth moving that stuff + // to some common place? (DM) +} // namespace detail + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief `cv::GArray` template class represents a list of objects + * of class `T` in the graph. + * + * `cv::GArray` describes a functional relationship between + * operations consuming and producing arrays of objects of class + * `T`. The primary purpose of `cv::GArray` is to represent a + * dynamic list of objects -- where the size of the list is not known + * at the graph construction or compile time. Examples include: corner + * and feature detectors (`cv::GArray`), object detection + * and tracking results (`cv::GArray`). Programmers can use + * their own types with `cv::GArray` in the custom operations. + * + * Similar to `cv::GScalar`, `cv::GArray` may be value-initialized + * -- in this case a graph-constant value is associated with the object. + * + * `GArray` is a virtual counterpart of `std::vector`, which is + * usually used to represent the `GArray` data in G-API during the + * execution. + * + * @sa `cv::GOpaque` + */ +template class GArray +{ +public: + // Host type (or Flat type) - the type this GArray is actually + // specified to. + /// @private + using HT = typename detail::flatten_g::type>::type; + + /** + * @brief Constructs a value-initialized `cv::GArray` + * + * `cv::GArray` objects may have their values + * be associated at graph construction time. It is useful when + * some operation has a `cv::GArray` input which doesn't change during + * the program execution, and is set only once. In this case, + * there is no need to declare such `cv::GArray` as a graph input. + * + * @note The value of `cv::GArray` may be overwritten by assigning some + * other `cv::GArray` to the object using `operator=` -- on the + * assigment, the old association or value is discarded. + * + * @param v a std::vector to associate with this + * `cv::GArray` object. Vector data is copied into the + * `cv::GArray` (no reference to the passed data is held). + */ + explicit GArray(const std::vector& v) // Constant value constructor + : m_ref(detail::GArrayU(detail::VectorRef(v))) { putDetails(); } + + /** + * @overload + * @brief Constructs a value-initialized `cv::GArray` + * + * @param v a std::vector to associate with this + * `cv::GArray` object. Vector data is moved into the `cv::GArray`. + */ + explicit GArray(std::vector&& v) // Move-constructor + : m_ref(detail::GArrayU(detail::VectorRef(std::move(v)))) { putDetails(); } + + /** + * @brief Constructs an empty `cv::GArray` + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty `cv::GArray` is assigned to a result + * of some operation, it obtains a functional link to this + * operation (and is not empty anymore). + */ + GArray() { putDetails(); } // Empty constructor + + /// @private + explicit GArray(detail::GArrayU &&ref) // GArrayU-based constructor + : m_ref(ref) { putDetails(); } // (used by GCall, not for users) + + /// @private + detail::GArrayU strip() const { + return m_ref; + } + /// @private + static void VCtor(detail::VectorRef& vref) { + vref.reset(); + } + +private: + void putDetails() { + m_ref.setConstructFcn(&VCtor); + m_ref.specifyType(); // FIXME: to unify those 2 to avoid excessive dynamic_cast + m_ref.storeKind(); // + } + + detail::GArrayU m_ref; +}; + +/** @} */ + +} // namespace cv + +#endif // OPENCV_GAPI_GARRAY_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gasync_context.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gasync_context.hpp new file mode 100644 index 0000000..f49b598 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gasync_context.hpp @@ -0,0 +1,63 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_GASYNC_CONTEXT_HPP +#define OPENCV_GAPI_GASYNC_CONTEXT_HPP + +#if !defined(GAPI_STANDALONE) +# include +#else // Without OpenCV +# include +#endif // !defined(GAPI_STANDALONE) + +#include + +namespace cv { +namespace gapi{ + +/** + * @brief This namespace contains experimental G-API functionality, + * functions or structures in this namespace are subjects to change or + * removal in the future releases. This namespace also contains + * functions which API is not stabilized yet. + */ +namespace wip { + +/** + * @brief A class to group async requests to cancel them in a single shot. + * + * GAsyncContext is passed as an argument to async() and async_apply() functions + */ + +class GAPI_EXPORTS GAsyncContext{ + std::atomic cancelation_requested = {false}; +public: + /** + * @brief Start cancellation process for an associated request. + * + * User still has to wait for each individual request (either via callback or according std::future object) to make sure it actually canceled. + * + * @return true if it was a first request to cancel the context + */ + bool cancel(); + + /** + * @brief Returns true if cancellation was requested for this context. + * + * @return true if cancellation was requested for this context + */ + bool isCanceled() const; +}; + +class GAPI_EXPORTS GAsyncCanceled : public std::exception { +public: + virtual const char* what() const noexcept CV_OVERRIDE; +}; +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif //OPENCV_GAPI_GASYNC_CONTEXT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcall.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcall.hpp new file mode 100644 index 0000000..8d1b8d6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcall.hpp @@ -0,0 +1,78 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GCALL_HPP +#define OPENCV_GAPI_GCALL_HPP + +#include // GArg +#include // GMat +#include // GScalar +#include // GFrame +#include // GArray +#include // GOpaque + +namespace cv { + +struct GKernel; + +// The whole idea of this class is to represent an operation +// which is applied to arguments. This is part of public API, +// since it is what users should use to define kernel interfaces. + +class GAPI_EXPORTS GCall final +{ +public: + class Priv; + + explicit GCall(const GKernel &k); + ~GCall(); + + template + GCall& pass(Ts&&... args) + { + setArgs({cv::GArg(std::move(args))...}); + return *this; + } + + // A generic yield method - obtain a link to operator's particular GMat output + GMat yield (int output = 0); + GMatP yieldP (int output = 0); + GScalar yieldScalar(int output = 0); + GFrame yieldFrame (int output = 0); + + template GArray yieldArray(int output = 0) + { + return GArray(yieldArray(output)); + } + + template GOpaque yieldOpaque(int output = 0) + { + return GOpaque(yieldOpaque(output)); + } + + // Internal use only + Priv& priv(); + const Priv& priv() const; + + // GKernel and params can be modified, it's needed for infer, + // because information about output shapes doesn't exist in compile time + GKernel& kernel(); + cv::util::any& params(); + + void setArgs(std::vector &&args); + +protected: + std::shared_ptr m_priv; + + // Public versions return a typed array or opaque, those are implementation details + detail::GArrayU yieldArray(int output = 0); + detail::GOpaqueU yieldOpaque(int output = 0); +}; + +} // namespace cv + +#endif // OPENCV_GAPI_GCALL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcommon.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcommon.hpp new file mode 100644 index 0000000..dfbd9e3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcommon.hpp @@ -0,0 +1,287 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMMON_HPP +#define OPENCV_GAPI_GCOMMON_HPP + +#include // std::hash +#include // std::vector +#include // decay + +#include + +#include +#include +#include +#include +#include +#include + +namespace cv { + +class GMat; // FIXME: forward declaration for GOpaqueTraits + +namespace detail +{ + // This is a trait-like structure to mark backend-specific compile arguments + // with tags + template struct CompileArgTag; + + // These structures are tags which separate kernels and transformations + struct KernelTag + {}; + struct TransformTag + {}; + + // This enum is utilized mostly by GArray and GOpaque to store and recognize their internal data + // types (aka Host type). Also it is widely used during serialization routine. + enum class OpaqueKind: int + { + CV_UNKNOWN, // Unknown, generic, opaque-to-GAPI data type unsupported in graph seriallization + CV_BOOL, // bool user G-API data + CV_INT, // int user G-API data + CV_INT64, // int64_t user G-API data + CV_DOUBLE, // double user G-API data + CV_FLOAT, // float user G-API data + CV_UINT64, // uint64_t user G-API data + CV_STRING, // std::string user G-API data + CV_POINT, // cv::Point user G-API data + CV_POINT2F, // cv::Point2f user G-API data + CV_SIZE, // cv::Size user G-API data + CV_RECT, // cv::Rect user G-API data + CV_SCALAR, // cv::Scalar user G-API data + CV_MAT, // cv::Mat user G-API data + CV_DRAW_PRIM, // cv::gapi::wip::draw::Prim user G-API data + }; + + // Type traits helper which simplifies the extraction of kind from type + template struct GOpaqueTraits; + template struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_UNKNOWN; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_INT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_INT64; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_DOUBLE; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_FLOAT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_UINT64; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_BOOL; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_STRING; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_SIZE; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_SCALAR; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT2F; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_RECT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; }; + template<> struct GOpaqueTraits + { static constexpr const OpaqueKind kind = OpaqueKind::CV_DRAW_PRIM; }; + using GOpaqueTraitsArrayTypes = std::tuple; + // GOpaque is not supporting cv::Mat and cv::Scalar since there are GScalar and GMat types + using GOpaqueTraitsOpaqueTypes = std::tuple; +} // namespace detail + +// This definition is here because it is reused by both public(?) and internal +// modules. Keeping it here wouldn't expose public details (e.g., API-level) +// to components which are internal and operate on a lower-level entities +// (e.g., compiler, backends). +// FIXME: merge with ArgKind? +// FIXME: replace with variant[format desc]? +enum class GShape: int +{ + GMAT, + GSCALAR, + GARRAY, + GOPAQUE, + GFRAME, +}; + +namespace gapi { +namespace s11n { +namespace detail { +template struct wrap_serialize; +} // namespace detail +} // namespace s11n +} // namespace gapi + + +struct GCompileArg; + +namespace detail { + template + using is_compile_arg = std::is_same::type>; +} // namespace detail + +// CompileArg is an unified interface over backend-specific compilation +// information +// FIXME: Move to a separate file? +/** \addtogroup gapi_compile_args + * @{ + * + * @brief Compilation arguments: data structures controlling the + * compilation process + * + * G-API comes with a number of graph compilation options which can be + * passed to cv::GComputation::apply() or + * cv::GComputation::compile(). Known compilation options are listed + * in this page, while extra backends may introduce their own + * compilation options (G-API transparently accepts _everything_ which + * can be passed to cv::compile_args(), it depends on underlying + * backends if an option would be interpreted or not). + * + * For example, if an example computation is executed like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_decl_apply + * + * Extra parameter specifying which kernels to compile with can be + * passed like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp apply_with_param + */ + +/** + * @brief Represents an arbitrary compilation argument. + * + * Any value can be wrapped into cv::GCompileArg, but only known ones + * (to G-API or its backends) can be interpreted correctly. + * + * Normally objects of this class shouldn't be created manually, use + * cv::compile_args() function which automatically wraps everything + * passed in (a variadic template parameter pack) into a vector of + * cv::GCompileArg objects. + */ +struct GCompileArg +{ +public: + // NB: Required for pythnon bindings + GCompileArg() = default; + + std::string tag; + + // FIXME: use decay in GArg/other trait-based wrapper before leg is shot! + template::value, int>::type = 0> + explicit GCompileArg(T &&t) + : tag(detail::CompileArgTag::type>::tag()) + , serializeF(cv::gapi::s11n::detail::has_S11N_spec::value ? + &cv::gapi::s11n::detail::wrap_serialize::serialize : + nullptr) + , arg(t) + { + } + + template T& get() + { + return util::any_cast(arg); + } + + template const T& get() const + { + return util::any_cast(arg); + } + + void serialize(cv::gapi::s11n::IOStream& os) const + { + if (serializeF) + { + serializeF(os, *this); + } + } + +private: + std::function serializeF; + util::any arg; +}; + +using GCompileArgs = std::vector; + +inline cv::GCompileArgs& operator += ( cv::GCompileArgs &lhs, + const cv::GCompileArgs &rhs) +{ + lhs.reserve(lhs.size() + rhs.size()); + lhs.insert(lhs.end(), rhs.begin(), rhs.end()); + return lhs; +} + +/** + * @brief Wraps a list of arguments (a parameter pack) into a vector of + * compilation arguments (cv::GCompileArg). + */ +template GCompileArgs compile_args(Ts&&... args) +{ + return GCompileArgs{ GCompileArg(args)... }; +} + +namespace gapi +{ +/** + * @brief Retrieves particular compilation argument by its type from + * cv::GCompileArgs + */ +template +inline cv::util::optional getCompileArg(const cv::GCompileArgs &args) +{ + for (auto &compile_arg : args) + { + if (compile_arg.tag == cv::detail::CompileArgTag::tag()) + { + return cv::util::optional(compile_arg.get()); + } + } + return cv::util::optional(); +} + +namespace s11n { +namespace detail { +template struct wrap_serialize +{ + static void serialize(IOStream& os, const GCompileArg& arg) + { + using DT = typename std::decay::type; + S11N
::serialize(os, arg.get
()); + } +}; +} // namespace detail +} // namespace s11n +} // namespace gapi + +/** + * @brief Ask G-API to dump compiled graph in Graphviz format under + * the given file name. + * + * Specifies a graph dump path (path to .dot file to be generated). + * G-API will dump a .dot file under specified path during a + * compilation process if this flag is passed. + */ +struct graph_dump_path +{ + std::string m_dump_path; +}; +/** @} */ + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.graph_dump_path"; } + }; +} + +} // namespace cv + +// std::hash overload for GShape +namespace std +{ +template<> struct hash +{ + size_t operator() (cv::GShape sh) const + { + return std::hash()(static_cast(sh)); + } +}; +} // namespace std + + +#endif // OPENCV_GAPI_GCOMMON_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompiled.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompiled.hpp new file mode 100644 index 0000000..ac36783 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompiled.hpp @@ -0,0 +1,232 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPILED_HPP +#define OPENCV_GAPI_GCOMPILED_HPP + +#include + +#include +#include +#include + +namespace cv { + +// This class represents a compiled computation. +// In theory (and ideally), it can be used w/o the rest of APIs. +// In theory (and ideally), it can be serialized/deserialized. +// It can enable scenarious like deployment to an autonomous devince, FuSa, etc. +// +// Currently GCompiled assumes all GMats you used to pass data to G-API +// are valid and not destroyed while you use a GCompiled object. +// +// FIXME: In future, there should be a way to name I/O objects and specify it +// to GCompiled externally (for example, when it is loaded on the target system). + +/** + * \addtogroup gapi_main_classes + * @{ + */ +/** + * @brief Represents a compiled computation (graph). Can only be used + * with image / data formats & resolutions it was compiled for, with + * some exceptions. + * + * This class represents a product of graph compilation (calling + * cv::GComputation::compile()). Objects of this class actually do + * data processing, and graph execution is incapsulated into objects + * of this class. Execution model itself depends on kernels and + * backends which were using during the compilation, see @ref + * gapi_compile_args for details. + * + * In a general case, GCompiled objects can be applied to data only in + * that formats/resolutions they were compiled for (see @ref + * gapi_meta_args). However, if the underlying backends allow, a + * compiled object can be _reshaped_ to handle data (images) of + * different resolution, though formats and types must remain the same. + * + * GCompiled is very similar to `std::function<>` in its semantics -- + * running it looks like a function call in the user code. + * + * At the moment, GCompiled objects are not reentrant -- generally, + * the objects are stateful since graph execution itself is a stateful + * process and this state is now maintained in GCompiled's own memory + * (not on the process stack). + * + * At the same time, two different GCompiled objects produced from the + * single cv::GComputation are completely independent and can be used + * concurrently. + * + * @sa GStreamingCompiled + */ +class GAPI_EXPORTS GCompiled +{ +public: + /// @private + class GAPI_EXPORTS Priv; + + /** + * @brief Constructs an empty object + */ + GCompiled(); + + /** + * @brief Run the compiled computation, a generic version. + * + * @param ins vector of inputs to process. + * @param outs vector of outputs to produce. + * + * Input/output vectors must have the same number of elements as + * defined in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::Mat needs to be passed where cv::GMat has been + * declared as input, and so on). Run-time exception is generated + * otherwise. + * + * Objects in output vector may remain empty (like cv::Mat) -- + * G-API will automatically initialize output objects to proper formats. + * + * @note Don't construct GRunArgs/GRunArgsP objects manually, use + * cv::gin()/cv::gout() wrappers instead. + */ + void operator() (GRunArgs &&ins, GRunArgsP &&outs); // Generic arg-to-arg +#if !defined(GAPI_STANDALONE) + + /** + * @brief Execute an unary computation + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Mat for unary computation + * process. + */ + void operator() (cv::Mat in, cv::Mat &out); // Unary overload + + /** + * @brief Execute an unary computation + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Scalar for unary computation + * process. + */ + void operator() (cv::Mat in, cv::Scalar &out); // Unary overload (scalar) + + /** + * @brief Execute a binary computation + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Mat for binary computation + * process. + */ + void operator() (cv::Mat in1, cv::Mat in2, cv::Mat &out); // Binary overload + + /** + * @brief Execute an binary computation + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Scalar for binary computation + * process. + */ + void operator() (cv::Mat in1, cv::Mat in2, cv::Scalar &out); // Binary overload (scalar) + + /** + * @brief Execute a computation with arbitrary number of + * inputs/outputs. + * + * @overload + * @param ins vector of input cv::Mat objects to process by the + * computation. + * @param outs vector of output cv::Mat objects to produce by the + * computation. + * + * Numbers of elements in ins/outs vectors must match numbers of + * inputs/outputs which were used to define the source GComputation. + */ + void operator() (const std::vector &ins, // Compatibility overload + const std::vector &outs); +#endif // !defined(GAPI_STANDALONE) + /// @private + Priv& priv(); + + /** + * @brief Check if compiled object is valid (non-empty) + * + * @return true if the object is runnable (valid), false otherwise + */ + explicit operator bool () const; + + /** + * @brief Vector of metadata this graph was compiled for. + * + * @return Unless _reshape_ is not supported, return value is the + * same vector which was passed to cv::GComputation::compile() to + * produce this compiled object. Otherwise, it is the latest + * metadata vector passed to reshape() (if that call was + * successful). + */ + const GMetaArgs& metas() const; // Meta passed to compile() + + /** + * @brief Vector of metadata descriptions of graph outputs + * + * @return vector with formats/resolutions of graph's output + * objects, auto-inferred from input metadata vector by + * operations which form this computation. + * + * @note GCompiled objects produced from the same + * cv::GComputiation graph with different input metas may return + * different values in this vector. + */ + const GMetaArgs& outMetas() const; + + /** + * @brief Check if the underlying backends support reshape or not. + * + * @return true if supported, false otherwise. + */ + bool canReshape() const; + + /** + * @brief Reshape a compiled graph to support new image + * resolutions. + * + * Throws an exception if an error occurs. + * + * @param inMetas new metadata to reshape on. Vector size and + * metadata shapes must match the computation's protocol. + * @param args compilation arguments to use. + */ + // FIXME: Why it requires compile args? + void reshape(const GMetaArgs& inMetas, const GCompileArgs& args); + + /** + * @brief Prepare inner kernels states for a new video-stream. + * + * GCompiled objects may be used to process video streams frame by frame. + * In this case, a GCompiled is called on every image frame individually. + * Starting OpenCV 4.4, some kernels in the graph may have their internal + * states (see GAPI_OCV_KERNEL_ST for the OpenCV backend). + * In this case, if user starts processing another video stream with + * this GCompiled, this method needs to be called to let kernels re-initialize + * their internal states to a new video stream. + */ + void prepareForNewStream(); + +protected: + /// @private + std::shared_ptr m_priv; +}; +/** @} */ + +} + +#endif // OPENCV_GAPI_GCOMPILED_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompiled_async.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompiled_async.hpp new file mode 100644 index 0000000..a0c2917 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompiled_async.hpp @@ -0,0 +1,73 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPILED_ASYNC_HPP +#define OPENCV_GAPI_GCOMPILED_ASYNC_HPP + +#include //for std::future +#include //for std::exception_ptr +#include //for std::function +#include +#include + +namespace cv { + //fwd declaration + class GCompiled; + +namespace gapi{ +namespace wip { + class GAsyncContext; + /** + These functions asynchronously (i.e. probably on a separate thread of execution) call GCompiled::operator() member function of their first argument with copies of rest of arguments (except callback) passed in. + The difference between the function is the way to get the completion notification (via callback or a waiting on std::future object) + If exception is occurred during execution of apply it is transferred to the callback (via function parameter) or passed to future (and will be thrown on call to std::future::get) + + N.B. : + Input arguments are copied on call to async function (actually on call to cv::gin) and thus do not have to outlive the actual completion of asynchronous activity. + While output arguments are "captured" by reference(pointer) and therefore _must_ outlive the asynchronous activity + (i.e. live at least until callback is called or future is unblocked) + + @param gcmpld Compiled computation (graph) to start asynchronously + @param callback Callback to be called when execution of gcmpld is done + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + */ + GAPI_EXPORTS void async(GCompiled& gcmpld, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs); + + /** @overload + @param gcmpld Compiled computation (graph) to run asynchronously + @param callback Callback to be called when execution of gcmpld is done + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + @param ctx Context this request belongs to + @see async GAsyncContext + */ + GAPI_EXPORTS void async(GCompiled& gcmpld, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx); + + /** @overload + @param gcmpld Compiled computation (graph) to run asynchronously + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + @return std::future object to wait for completion of async operation + @see async + */ + GAPI_EXPORTS std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs); + + /** + @param gcmpld Compiled computation (graph) to run asynchronously + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + @param ctx Context this request belongs to + @return std::future object to wait for completion of async operation + @see async GAsyncContext + */ + GAPI_EXPORTS std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx); +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GCOMPILED_ASYNC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompoundkernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompoundkernel.hpp new file mode 100644 index 0000000..df0ce34 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcompoundkernel.hpp @@ -0,0 +1,139 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPOUNDKERNEL_HPP +#define OPENCV_GAPI_GCOMPOUNDKERNEL_HPP + +#include +#include +#include +#include + +namespace cv { +namespace gapi +{ +namespace compound +{ + // FIXME User does not need to know about this function + // Needs that user may define compound kernels(as cpu kernels) + GAPI_EXPORTS cv::gapi::GBackend backend(); +} // namespace compound +} // namespace gapi + +namespace detail +{ + +struct GCompoundContext +{ + explicit GCompoundContext(const GArgs& in_args); + template + const T& inArg(int input) { return m_args.at(input).get(); } + + GArgs m_args; + GArgs m_results; +}; + +class GAPI_EXPORTS GCompoundKernel +{ +// Compound kernel must use all of it's inputs +public: + using F = std::function; + + explicit GCompoundKernel(const F& f); + void apply(GCompoundContext& ctx); + +protected: + F m_f; +}; + +template struct get_compound_in +{ + static T get(GCompoundContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +template struct get_compound_in> +{ + static cv::GArray get(GCompoundContext &ctx, int idx) + { + auto array = cv::GArray(); + ctx.m_args[idx] = GArg(array); + return array; + } +}; + +template struct get_compound_in> +{ + static cv::GOpaque get(GCompoundContext &ctx, int idx) + { + auto opaq = cv::GOpaque(); + ctx.m_args[idx] = GArg(opaq); + return opaq; + } +}; + +template<> struct get_compound_in +{ + static cv::GMatP get(GCompoundContext &ctx, int idx) + { + auto mat = cv::GMatP(); + ctx.m_args[idx] = GArg(mat); + return mat; + } +}; + +template +struct GCompoundCallHelper; + +template +struct GCompoundCallHelper, std::tuple > +{ + template + static void expand_impl(GCompoundContext &ctx, detail::Seq, detail::Seq) + { + auto result = Impl::expand(get_compound_in::get(ctx, IIs)...); + auto tuple_return = tuple_wrap_helper::get(std::move(result)); + ctx.m_results = { cv::GArg(std::get(tuple_return))... }; + } + + static void expand(GCompoundContext &ctx) + { + expand_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +template +class GCompoundKernelImpl: public cv::detail::GCompoundCallHelper, + public cv::detail::KernelTag +{ + using P = cv::detail::GCompoundCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::compound::backend(); } + static GCompoundKernel kernel() { return GCompoundKernel(&P::expand); } +}; + +} // namespace detail + + +/** + * Declares a new compound kernel. See this + * [documentation chapter](@ref gapi_kernel_compound) + * on compound kernels for more details. + * + * @param Name type name for new kernel + * @param API the interface this kernel implements + */ +#define GAPI_COMPOUND_KERNEL(Name, API) \ + struct Name: public cv::detail::GCompoundKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GCOMPOUNDKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcomputation.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcomputation.hpp new file mode 100644 index 0000000..13944c7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcomputation.hpp @@ -0,0 +1,580 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPUTATION_HPP +#define OPENCV_GAPI_GCOMPUTATION_HPP + +#include + +#include +#include +#include +#include +#include +#include + +namespace cv { + +namespace detail +{ + // FIXME: move to algorithm, cover with separate tests + // FIXME: replace with O(1) version (both memory and compilation time) + template + struct last_type; + + template + struct last_type { using type = T;}; + + template + struct last_type { using type = typename last_type::type; }; + + template + using last_type_t = typename last_type::type; +} + +// Forward-declare the serialization objects +namespace gapi { +namespace s11n { + struct IIStream; + struct IOStream; +} // namespace s11n +} // namespace gapi + +/** + * \addtogroup gapi_main_classes + * @{ + * + * @brief G-API classes for constructed and compiled graphs. + */ +/** + * @brief GComputation class represents a captured computation + * graph. GComputation objects form boundaries for expression code + * user writes with G-API, allowing to compile and execute it. + * + * G-API computations are defined with input/output data + * objects. G-API will track automatically which operations connect + * specified outputs to the inputs, forming up a call graph to be + * executed. The below example expresses calculation of Sobel operator + * for edge detection (\f$G = \sqrt{G_x^2 + G_y^2}\f$): + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_def + * + * Full pipeline can be now captured with this object declaration: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_cap_full + * + * Input/output data objects on which a call graph should be + * reconstructed are passed using special wrappers cv::GIn and + * cv::GOut. G-API will track automatically which operations form a + * path from inputs to outputs and build the execution graph appropriately. + * + * Note that cv::GComputation doesn't take ownership on data objects + * it is defined. Moreover, multiple GComputation objects may be + * defined on the same expressions, e.g. a smaller pipeline which + * expects that image gradients are already pre-calculated may be + * defined like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_cap_sub + * + * The resulting graph would expect two inputs and produce one + * output. In this case, it doesn't matter if gx/gy data objects are + * results of cv::gapi::Sobel operators -- G-API will stop unrolling + * expressions and building the underlying graph one reaching this + * data objects. + * + * The way how GComputation is defined is important as its definition + * specifies graph _protocol_ -- the way how the graph should be + * used. Protocol is defined by number of inputs, number of outputs, + * and shapes of inputs and outputs. + * + * In the above example, sobelEdge expects one Mat on input and + * produces one Mat; while sobelEdgeSub expects two Mats on input and + * produces one Mat. GComputation's protocol defines how other + * computation methods should be used -- cv::GComputation::compile() and + * cv::GComputation::apply(). For example, if a graph is defined on + * two GMat inputs, two cv::Mat objects have to be passed to apply() + * for execution. GComputation checks protocol correctness in runtime + * so passing a different number of objects in apply() or passing + * cv::Scalar instead of cv::Mat there would compile well as a C++ + * source but raise an exception in run-time. G-API also comes with a + * typed wrapper cv::GComputationT<> which introduces this type-checking in + * compile-time. + * + * cv::GComputation itself is a thin object which just captures what + * the graph is. The compiled graph (which actually process data) is + * represented by class GCompiled. Use compile() method to generate a + * compiled graph with given compile options. cv::GComputation can + * also be used to process data with implicit graph compilation + * on-the-fly, see apply() for details. + * + * GComputation is a reference-counted object -- once defined, all its + * copies will refer to the same instance. + * + * @sa GCompiled + */ +class GAPI_EXPORTS_W GComputation +{ +public: + class Priv; + typedef std::function Generator; + + // Various constructors enable different ways to define a computation: ///// + // 1. Generic constructors + /** + * @brief Define a computation using a generator function. + * + * Graph can be defined in-place directly at the moment of its + * construction with a lambda: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_gen + * + * This may be useful since all temporary objects (cv::GMats) and + * namespaces can be localized to scope of lambda, without + * contaminating the parent scope with probably unnecessary objects + * and information. + * + * @param gen generator function which returns a cv::GComputation, + * see Generator. + */ + GComputation(const Generator& gen); // Generator + // overload + + /** + * @brief Generic GComputation constructor. + * + * Constructs a new graph with a given protocol, specified as a + * flow of operations connecting input/output objects. Throws if + * the passed boundaries are invalid, e.g. if there's no + * functional dependency (path) between given outputs and inputs. + * + * @param ins Input data vector. + * @param outs Output data vector. + * + * @note Don't construct GProtoInputArgs/GProtoOutputArgs objects + * directly, use cv::GIn()/cv::GOut() wrapper functions instead. + * + * @sa @ref gapi_data_objects + */ + GAPI_WRAP GComputation(GProtoInputArgs &&ins, + GProtoOutputArgs &&outs); // Arg-to-arg overload + + // 2. Syntax sugar and compatibility overloads + /** + * @brief Defines an unary (one input -- one output) computation + * + * @overload + * @param in input GMat of the defined unary computation + * @param out output GMat of the defined unary computation + */ + GAPI_WRAP GComputation(GMat in, GMat out); // Unary overload + + /** + * @brief Defines an unary (one input -- one output) computation + * + * @overload + * @param in input GMat of the defined unary computation + * @param out output GScalar of the defined unary computation + */ + GAPI_WRAP GComputation(GMat in, GScalar out); // Unary overload (scalar) + + /** + * @brief Defines a binary (two inputs -- one output) computation + * + * @overload + * @param in1 first input GMat of the defined binary computation + * @param in2 second input GMat of the defined binary computation + * @param out output GMat of the defined binary computation + */ + GAPI_WRAP GComputation(GMat in1, GMat in2, GMat out); // Binary overload + + /** + * @brief Defines a binary (two inputs -- one output) computation + * + * @overload + * @param in1 first input GMat of the defined binary computation + * @param in2 second input GMat of the defined binary computation + * @param out output GScalar of the defined binary computation + */ + GComputation(GMat in1, GMat in2, GScalar out); // Binary + // overload + // (scalar) + + /** + * @brief Defines a computation with arbitrary input/output number. + * + * @overload + * @param ins vector of inputs GMats for this computation + * @param outs vector of outputs GMats for this computation + * + * Use this overload for cases when number of computation + * inputs/outputs is not known in compile-time -- e.g. when graph + * is programmatically generated to build an image pyramid with + * the given number of levels, etc. + */ + GComputation(const std::vector &ins, // Compatibility overload + const std::vector &outs); + + // Various versions of apply(): //////////////////////////////////////////// + // 1. Generic apply() + /** + * @brief Compile graph on-the-fly and immediately execute it on + * the inputs data vectors. + * + * Number of input/output data objects must match GComputation's + * protocol, also types of host data objects (cv::Mat, cv::Scalar) + * must match the shapes of data objects from protocol (cv::GMat, + * cv::GScalar). If there's a mismatch, a run-time exception will + * be generated. + * + * Internally, a cv::GCompiled object is created for the given + * input format configuration, which then is executed on the input + * data immediately. cv::GComputation caches compiled objects + * produced within apply() -- if this method would be called next + * time with the same input parameters (image formats, image + * resolution, etc), the underlying compiled graph will be reused + * without recompilation. If new metadata doesn't match the cached + * one, the underlying compiled graph is regenerated. + * + * @note compile() always triggers a compilation process and + * produces a new GCompiled object regardless if a similar one has + * been cached via apply() or not. + * + * @param ins vector of input data to process. Don't create + * GRunArgs object manually, use cv::gin() wrapper instead. + * @param outs vector of output data to fill results in. cv::Mat + * objects may be empty in this vector, G-API will automatically + * initialize it with the required format & dimensions. Don't + * create GRunArgsP object manually, use cv::gout() wrapper instead. + * @param args a list of compilation arguments to pass to the + * underlying compilation process. Don't create GCompileArgs + * object manually, use cv::compile_args() wrapper instead. + * + * @sa @ref gapi_data_objects, @ref gapi_compile_args + */ + void apply(GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); // Arg-to-arg overload + + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP GRunArgs apply(const cv::detail::ExtractArgsCallback &callback, + GCompileArgs &&args = {}); + + /// @private -- Exclude this function from OpenCV documentation + void apply(const std::vector& ins, // Compatibility overload + const std::vector& outs, + GCompileArgs &&args = {}); + + // 2. Syntax sugar and compatibility overloads +#if !defined(GAPI_STANDALONE) + /** + * @brief Execute an unary computation (with compilation on the fly) + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Mat for unary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in, cv::Mat &out, GCompileArgs &&args = {}); // Unary overload + + /** + * @brief Execute an unary computation (with compilation on the fly) + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Scalar for unary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in, cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar) + + /** + * @brief Execute a binary computation (with compilation on the fly) + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Mat for binary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in1, cv::Mat in2, cv::Mat &out, GCompileArgs &&args = {}); // Binary overload + + /** + * @brief Execute an binary computation (with compilation on the fly) + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Scalar for binary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in1, cv::Mat in2, cv::Scalar &out, GCompileArgs &&args = {}); // Binary overload (scalar) + + /** + * @brief Execute a computation with arbitrary number of + * inputs/outputs (with compilation on-the-fly). + * + * @overload + * @param ins vector of input cv::Mat objects to process by the + * computation. + * @param outs vector of output cv::Mat objects to produce by the + * computation. + * @param args compilation arguments for underlying compilation + * process. + * + * Numbers of elements in ins/outs vectors must match numbers of + * inputs/outputs which were used to define this GComputation. + */ + void apply(const std::vector& ins, // Compatibility overload + std::vector& outs, + GCompileArgs &&args = {}); +#endif // !defined(GAPI_STANDALONE) + // Various versions of compile(): ////////////////////////////////////////// + // 1. Generic compile() - requires metas to be passed as vector + /** + * @brief Compile the computation for specific input format(s). + * + * This method triggers compilation process and produces a new + * GCompiled object which then can process data of the given + * format. Passing data with different format to the compiled + * computation will generate a run-time exception. + * + * @param in_metas vector of input metadata configuration. Grab + * metadata from real data objects (like cv::Mat or cv::Scalar) + * using cv::descr_of(), or create it on your own. + * @param args compilation arguments for this compilation + * process. Compilation arguments directly affect what kind of + * executable object would be produced, e.g. which kernels (and + * thus, devices) would be used to execute computation. + * + * @return GCompiled, an executable computation compiled + * specifically for the given input parameters. + * + * @sa @ref gapi_compile_args + */ + GCompiled compile(GMetaArgs &&in_metas, GCompileArgs &&args = {}); + + // 2. Syntax sugar - variadic list of metas, no extra compile args + // FIXME: SFINAE looks ugly in the generated documentation + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced. + * + * @return GCompiled, an executable computation compiled + * specifically for the given input parameters. + */ + template + auto compile(const Ts&... metas) -> + typename std::enable_if::value, GCompiled>::type + { + return compile(GMetaArgs{GMetaArg(metas)...}, GCompileArgs()); + } + + // 3. Syntax sugar - variadic list of metas, extra compile args + // (seems optional parameters don't work well when there's an variadic template + // comes first) + // + // Ideally it should look like: + // + // template + // GCompiled compile(const Ts&... metas, GCompileArgs &&args) + // + // But not all compilers can handle this (and seems they shouldn't be able to). + // FIXME: SFINAE looks ugly in the generated documentation + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced, + * followed by GCompileArgs object representing compilation + * arguments for this process. + * + * @return GCompiled, an executable computation compiled + * specifically for the given input parameters. + */ + template + auto compile(const Ts&... meta_and_compile_args) -> + typename std::enable_if::value + && std::is_same >::value, + GCompiled>::type + { + //FIXME: wrapping meta_and_compile_args into a tuple to unwrap them inside a helper function is the overkill + return compile(std::make_tuple(meta_and_compile_args...), + typename detail::MkSeq::type()); + } + + + // FIXME: Document properly in the Doxygen format + // Video-oriented pipeline compilation: + // 1. A generic version + /** + * @brief Compile the computation for streaming mode. + * + * This method triggers compilation process and produces a new + * GStreamingCompiled object which then can process video stream + * data of the given format. Passing a stream in a different + * format to the compiled computation will generate a run-time + * exception. + * + * @param in_metas vector of input metadata configuration. Grab + * metadata from real data objects (like cv::Mat or cv::Scalar) + * using cv::descr_of(), or create it on your own. + * + * @param args compilation arguments for this compilation + * process. Compilation arguments directly affect what kind of + * executable object would be produced, e.g. which kernels (and + * thus, devices) would be used to execute computation. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled specifically for the given input + * parameters. + * + * @sa @ref gapi_compile_args + */ + GAPI_WRAP GStreamingCompiled compileStreaming(GMetaArgs &&in_metas, GCompileArgs &&args = {}); + + /** + * @brief Compile the computation for streaming mode. + * + * This method triggers compilation process and produces a new + * GStreamingCompiled object which then can process video stream + * data in any format. Underlying mechanisms will be adjusted to + * every new input video stream automatically, but please note that + * _not all_ existing backends support this (see reshape()). + * + * @param args compilation arguments for this compilation + * process. Compilation arguments directly affect what kind of + * executable object would be produced, e.g. which kernels (and + * thus, devices) would be used to execute computation. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled for any input image format. + * + * @sa @ref gapi_compile_args + */ + GAPI_WRAP GStreamingCompiled compileStreaming(GCompileArgs &&args = {}); + + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP GStreamingCompiled compileStreaming(const cv::detail::ExtractMetaCallback &callback, + GCompileArgs &&args = {}); + + // 2. Direct metadata version + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled specifically for the given input + * parameters. + */ + template + auto compileStreaming(const Ts&... metas) -> + typename std::enable_if::value, GStreamingCompiled>::type + { + return compileStreaming(GMetaArgs{GMetaArg(metas)...}, GCompileArgs()); + } + + // 2. Direct metadata + compile arguments version + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced, + * followed by GCompileArgs object representing compilation + * arguments for this process. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled specifically for the given input + * parameters. + */ + template + auto compileStreaming(const Ts&... meta_and_compile_args) -> + typename std::enable_if::value + && std::is_same >::value, + GStreamingCompiled>::type + { + //FIXME: wrapping meta_and_compile_args into a tuple to unwrap them inside a helper function is the overkill + return compileStreaming(std::make_tuple(meta_and_compile_args...), + typename detail::MkSeq::type()); + } + + // Internal use only + /// @private + Priv& priv(); + /// @private + const Priv& priv() const; + /// @private + explicit GComputation(cv::gapi::s11n::IIStream &); + /// @private + void serialize(cv::gapi::s11n::IOStream &) const; + +protected: + + // 4. Helper methods for (3) + /// @private + template + GCompiled compile(const std::tuple &meta_and_compile_args, detail::Seq) + { + GMetaArgs meta_args = {GMetaArg(std::get(meta_and_compile_args))...}; + GCompileArgs comp_args = std::get(meta_and_compile_args); + return compile(std::move(meta_args), std::move(comp_args)); + } + template + GStreamingCompiled compileStreaming(const std::tuple &meta_and_compile_args, detail::Seq) + { + GMetaArgs meta_args = {GMetaArg(std::get(meta_and_compile_args))...}; + GCompileArgs comp_args = std::get(meta_and_compile_args); + return compileStreaming(std::move(meta_args), std::move(comp_args)); + } + void recompile(GMetaArgs&& in_metas, GCompileArgs &&args); + /// @private + std::shared_ptr m_priv; +}; +/** @} */ + +namespace gapi +{ + // FIXME: all these standalone functions need to be added to some + // common documentation section + /** + * @brief Define an tagged island (subgraph) within a computation. + * + * Declare an Island tagged with `name` and defined from `ins` to `outs` + * (exclusively, as ins/outs are data objects, and regioning is done on + * operations level). + * Throws if any operation between `ins` and `outs` are already assigned + * to another island. + * + * Islands allow to partition graph into subgraphs, fine-tuning + * the way it is scheduled by the underlying executor. + * + * @param name name of the Island to create + * @param ins vector of input data objects where the subgraph + * begins + * @param outs vector of output data objects where the subgraph + * ends. + * + * The way how an island is defined is similar to how + * cv::GComputation is defined on input/output data objects. + * Same rules apply here as well -- if there's no functional + * dependency between inputs and outputs or there's not enough + * input data objects were specified to properly calculate all + * outputs, an exception is thrown. + * + * Use cv::GIn() / cv::GOut() to specify input/output vectors. + */ + void GAPI_EXPORTS island(const std::string &name, + GProtoInputArgs &&ins, + GProtoOutputArgs &&outs); +} // namespace gapi + +} // namespace cv +#endif // OPENCV_GAPI_GCOMPUTATION_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcomputation_async.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcomputation_async.hpp new file mode 100644 index 0000000..8af603e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gcomputation_async.hpp @@ -0,0 +1,69 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP +#define OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP + + +#include //for std::future +#include //for std::exception_ptr +#include //for std::function +#include //for GRunArgs, GRunArgsP +#include //for GCompileArgs +#include + + +namespace cv { + //fwd declaration + class GComputation; +namespace gapi { +namespace wip { + class GAsyncContext; + /** In contrast to async() functions, these do call GComputation::apply() member function of the GComputation passed in. + + @param gcomp Computation (graph) to run asynchronously + @param callback Callback to be called when execution of gcomp is done + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @see async + */ + GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); + /** @overload + @param gcomp Computation (graph) to run asynchronously + @param callback Callback to be called when execution of gcomp is done + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @param ctx Context this request belongs to + @see async_apply async GAsyncContext + */ + GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx); + /** @overload + @param gcomp Computation (graph) to run asynchronously + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @return std::future object to wait for completion of async operation + @see async_apply async + */ + GAPI_EXPORTS std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); + /** @overload + @param gcomp Computation (graph) to run asynchronously + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @param ctx Context this request belongs to + @return std::future object to wait for completion of async operation + @see async_apply async GAsyncContext + */ + GAPI_EXPORTS std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx); +} // namespace wip +} // namespace gapi +} // namespace cv + + +#endif //OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gframe.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gframe.hpp new file mode 100644 index 0000000..96913dc --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gframe.hpp @@ -0,0 +1,112 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GFRAME_HPP +#define OPENCV_GAPI_GFRAME_HPP + +#include +#include // std::shared_ptr + +#include +#include // GShape + +#include +#include + +// TODO GAPI_EXPORTS or so +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief GFrame class represents an image or media frame in the graph. + * + * GFrame doesn't store any data itself, instead it describes a + * functional relationship between operations consuming and producing + * GFrame objects. + * + * GFrame is introduced to handle various media formats (e.g., NV12 or + * I420) under the same type. Various image formats may differ in the + * number of planes (e.g. two for NV12, three for I420) and the pixel + * layout inside. GFrame type allows to handle these media formats in + * the graph uniformly -- the graph structure will not change if the + * media format changes, e.g. a different camera or decoder is used + * with the same graph. G-API provides a number of operations which + * operate directly on GFrame, like `infer<>()` or + * renderFrame(); these operations are expected to handle different + * media formats inside. There is also a number of accessor + * operations like BGR(), Y(), UV() -- these operations provide + * access to frame's data in the familiar cv::GMat form, which can be + * used with the majority of the existing G-API operations. These + * accessor functions may perform color space converion on the fly if + * the image format of the GFrame they are applied to differs from the + * operation's semantic (e.g. the BGR() accessor is called on an NV12 + * image frame). + * + * GFrame is a virtual counterpart of cv::MediaFrame. + * + * @sa cv::MediaFrame, cv::GFrameDesc, BGR(), Y(), UV(), infer<>(). + */ +class GAPI_EXPORTS_W_SIMPLE GFrame +{ +public: + /** + * @brief Constructs an empty GFrame + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty GFrame is assigned to a result of some + * operation, it obtains a functional link to this operation (and + * is not empty anymore). + */ + GAPI_WRAP GFrame(); // Empty constructor + + /// @private + GFrame(const GNode &n, std::size_t out); // Operation result constructor + /// @private + GOrigin& priv(); // Internal use only + /// @private + const GOrigin& priv() const; // Internal use only + +private: + std::shared_ptr m_priv; +}; +/** @} */ + +enum class MediaFormat: int +{ + BGR = 0, + NV12, +}; + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS GFrameDesc +{ + MediaFormat fmt; + cv::Size size; + + bool operator== (const GFrameDesc &) const; +}; +static inline GFrameDesc empty_gframe_desc() { return GFrameDesc{}; } +/** @} */ + +class MediaFrame; +GAPI_EXPORTS GFrameDesc descr_of(const MediaFrame &frame); + +GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GFrameDesc &desc); + +} // namespace cv + +#endif // OPENCV_GAPI_GFRAME_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gkernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gkernel.hpp new file mode 100644 index 0000000..4d3fbd8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gkernel.hpp @@ -0,0 +1,749 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GKERNEL_HPP +#define OPENCV_GAPI_GKERNEL_HPP + +#include +#include +#include // string +#include // false_type, true_type +#include // map (for GKernelPackage) +#include // tuple + +#include // CompileArgTag +#include // Seq +#include +#include // GArg +#include // GMetaArg +#include // GTypeTraits +#include //suppress_unused_warning +#include + +namespace cv { + +struct GTypeInfo +{ + GShape shape; + cv::detail::OpaqueKind kind; + detail::HostCtor ctor; +}; + +using GShapes = std::vector; +using GKinds = std::vector; +using GCtors = std::vector; +using GTypesInfo = std::vector; + +// GKernel describes kernel API to the system +// FIXME: add attributes of a kernel, (e.g. number and types +// of inputs, etc) +struct GAPI_EXPORTS GKernel +{ + using M = std::function; + + std::string name; // kernel ID, defined by its API (signature) + std::string tag; // some (implementation-specific) tag + M outMeta; // generic adaptor to API::outMeta(...) + GShapes outShapes; // types (shapes) kernel's outputs + GKinds inKinds; // kinds of kernel's inputs (fixme: below) + GCtors outCtors; // captured constructors for template output types +}; +// TODO: It's questionable if inKinds should really be here. Instead, +// this information could come from meta. + +// GKernelImpl describes particular kernel implementation to the system +struct GAPI_EXPORTS GKernelImpl +{ + util::any opaque; // backend-specific opaque info + GKernel::M outMeta; // for deserialized graphs, the outMeta is taken here +}; + +template class GKernelTypeM; + +namespace detail +{ + //////////////////////////////////////////////////////////////////////////// + // yield() is used in graph construction time as a generic method to obtain + // lazy "return value" of G-API operations + // + template struct Yield; + template<> struct Yield + { + static inline cv::GMat yield(cv::GCall &call, int i) { return call.yield(i); } + }; + template<> struct Yield + { + static inline cv::GMatP yield(cv::GCall &call, int i) { return call.yieldP(i); } + }; + template<> struct Yield + { + static inline cv::GScalar yield(cv::GCall &call, int i) { return call.yieldScalar(i); } + }; + template struct Yield > + { + static inline cv::GArray yield(cv::GCall &call, int i) { return call.yieldArray(i); } + }; + template struct Yield > + { + static inline cv::GOpaque yield(cv::GCall &call, int i) { return call.yieldOpaque(i); } + }; + template<> struct Yield + { + static inline cv::GFrame yield(cv::GCall &call, int i) { return call.yieldFrame(i); } + }; + + //////////////////////////////////////////////////////////////////////////// + // Helper classes which brings outputMeta() marshalling to kernel + // implementations + // + // 1. MetaType establishes G#Type -> G#Meta mapping between G-API dynamic + // types and its metadata descriptor types. + // This mapping is used to transform types to call outMeta() callback. + template struct MetaType; + template<> struct MetaType { using type = GMatDesc; }; + template<> struct MetaType { using type = GMatDesc; }; + template<> struct MetaType { using type = GFrameDesc; }; + template<> struct MetaType { using type = GScalarDesc; }; + template struct MetaType > { using type = GArrayDesc; }; + template struct MetaType > { using type = GOpaqueDesc; }; + template struct MetaType { using type = T; }; // opaque args passed as-is + // FIXME: Move it to type traits? + + // 2. Hacky test based on MetaType to check if we operate on G-* type or not + template using is_nongapi_type = std::is_same::type>; + + // 3. Two ways to transform input arguments to its meta - for G-* and non-G* types: + template + typename std::enable_if::value, typename MetaType::type> + ::type get_in_meta(const GMetaArgs &in_meta, const GArgs &, int idx) + { + return util::get::type>(in_meta.at(idx)); + } + + template + typename std::enable_if::value, T> + ::type get_in_meta(const GMetaArgs &, const GArgs &in_args, int idx) + { + return in_args.at(idx).template get(); + } + + // 4. The MetaHelper itself: an entity which generates outMeta() call + // based on kernel signature, with arguments properly substituted. + // 4.1 - case for multiple return values + // FIXME: probably can be simplified with std::apply or analogue. + template + struct MetaHelper; + + template + struct MetaHelper, std::tuple > + { + template + static GMetaArgs getOutMeta_impl(const GMetaArgs &in_meta, + const GArgs &in_args, + detail::Seq, + detail::Seq) + { + // FIXME: decay? + using R = std::tuple::type...>; + const R r = K::outMeta( get_in_meta(in_meta, in_args, IIs)... ); + return GMetaArgs{ GMetaArg(std::get(r))... }; + } + // FIXME: help users identify how outMeta must look like (via default impl w/static_assert?) + + static GMetaArgs getOutMeta(const GMetaArgs &in_meta, + const GArgs &in_args) + { + return getOutMeta_impl(in_meta, + in_args, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } + }; + + // 4.1 - case for a single return value + // FIXME: How to avoid duplication here? + template + struct MetaHelper, Out > + { + template + static GMetaArgs getOutMeta_impl(const GMetaArgs &in_meta, + const GArgs &in_args, + detail::Seq) + { + // FIXME: decay? + using R = typename MetaType::type; + const R r = K::outMeta( get_in_meta(in_meta, in_args, IIs)... ); + return GMetaArgs{ GMetaArg(r) }; + } + // FIXME: help users identify how outMeta must look like (via default impl w/static_assert?) + + static GMetaArgs getOutMeta(const GMetaArgs &in_meta, + const GArgs &in_args) + { + return getOutMeta_impl(in_meta, + in_args, + typename detail::MkSeq::type()); + } + }; + + //////////////////////////////////////////////////////////////////////////// + // Helper class to introduce tags to calls. By default there's no tag + struct NoTag { + static constexpr const char *tag() { return ""; } + }; + +} // namespace detail + +// GKernelType and GKernelTypeM are base classes which implement typed ::on() +// method based on kernel signature. GKernelTypeM stands for multiple-return-value kernels +// +// G_TYPED_KERNEL and G_TYPED_KERNEL_M macros inherit user classes from GKernelType and +// GKernelTypeM respectively. + +template +class GKernelTypeM(Args...)> > + : public detail::MetaHelper, std::tuple> + , public detail::NoTag +{ + template + static std::tuple yield(cv::GCall &call, detail::Seq) + { + return std::make_tuple(detail::Yield::yield(call, IIs)...); + } + +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + // TODO: Args&&... here? + static std::tuple on(Args... args) + { + cv::GCall call(GKernel{ K::id() + , K::tag() + , &K::getOutMeta + , {detail::GTypeTraits::shape...} + , {detail::GTypeTraits::op_kind...} + , {detail::GObtainCtor::get()...}}); + call.pass(args...); // TODO: std::forward() here? + return yield(call, typename detail::MkSeq::type()); + } +}; + +template class GKernelType; + +template +class GKernelType > + : public detail::MetaHelper, R> + , public detail::NoTag +{ +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + static R on(Args... args) + { + cv::GCall call(GKernel{ K::id() + , K::tag() + , &K::getOutMeta + , {detail::GTypeTraits::shape} + , {detail::GTypeTraits::op_kind...} + , {detail::GObtainCtor::get()}}); + call.pass(args...); + return detail::Yield::yield(call, 0); + } +}; + +namespace detail { +// This tiny class eliminates the semantic difference between +// GKernelType and GKernelTypeM. +template class KernelTypeMedium; + +template +class KernelTypeMedium(Args...)>> : + public cv::GKernelTypeM(Args...)>> {}; + +template +class KernelTypeMedium> : + public cv::GKernelType> {}; +} // namespace detail + +} // namespace cv + + +// FIXME: I don't know a better way so far. Feel free to suggest one +// The problem is that every typed kernel should have ::id() but body +// of the class is defined by user (with outMeta, other stuff) + +//! @cond IGNORED +#define G_ID_HELPER_CLASS(Class) Class##IdHelper + +#define G_ID_HELPER_BODY(Class, Id) \ + struct G_ID_HELPER_CLASS(Class) \ + { \ + static constexpr const char * id() {return Id;} \ + }; \ +//! @endcond + +#define GET_G_TYPED_KERNEL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, NAME, ...) NAME +#define COMBINE_SIGNATURE(...) __VA_ARGS__ +// Ensure correct __VA_ARGS__ expansion on Windows +#define __WRAP_VAARGS(x) x + +/** + * Helper for G_TYPED_KERNEL declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) + * for more details. + * + * @param Class type name for this operation. + * @param API an `std::function<>`-like signature for the operation; + * return type is a single value or a tuple of multiple values. + * @param Id string identifier for the operation. Must be unique. + */ +#define G_TYPED_KERNEL_HELPER(Class, API, Id) \ + G_ID_HELPER_BODY(Class, Id) \ + struct Class final: public cv::detail::KernelTypeMedium, \ + public G_ID_HELPER_CLASS(Class) +// {body} is to be defined by user + +#define G_TYPED_KERNEL_HELPER_2(Class, _1, _2, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2), Id) + +#define G_TYPED_KERNEL_HELPER_3(Class, _1, _2, _3, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3), Id) + +#define G_TYPED_KERNEL_HELPER_4(Class, _1, _2, _3, _4, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4), Id) + +#define G_TYPED_KERNEL_HELPER_5(Class, _1, _2, _3, _4, _5, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5), Id) + +#define G_TYPED_KERNEL_HELPER_6(Class, _1, _2, _3, _4, _5, _6, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6), Id) + +#define G_TYPED_KERNEL_HELPER_7(Class, _1, _2, _3, _4, _5, _6, _7, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7), Id) + +#define G_TYPED_KERNEL_HELPER_8(Class, _1, _2, _3, _4, _5, _6, _7, _8, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8), Id) + +#define G_TYPED_KERNEL_HELPER_9(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9), Id) + +#define G_TYPED_KERNEL_HELPER_10(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Id) + +/** + * Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) + * for more details. + * + * @param Class type name for this operation. + */ +#define G_TYPED_KERNEL(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \ + G_TYPED_KERNEL_HELPER_10, \ + G_TYPED_KERNEL_HELPER_9, \ + G_TYPED_KERNEL_HELPER_8, \ + G_TYPED_KERNEL_HELPER_7, \ + G_TYPED_KERNEL_HELPER_6, \ + G_TYPED_KERNEL_HELPER_5, \ + G_TYPED_KERNEL_HELPER_4, \ + G_TYPED_KERNEL_HELPER_3, \ + G_TYPED_KERNEL_HELPER_2, \ + G_TYPED_KERNEL_HELPER)(Class, __VA_ARGS__)) \ + +/** + * Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) for more details. + * + * @deprecated This macro is deprecated in favor of `G_TYPED_KERNEL` that is used for declaring any + * G-API Operation. + * + * @param Class type name for this operation. + */ +#define G_TYPED_KERNEL_M G_TYPED_KERNEL + +#define G_API_OP G_TYPED_KERNEL +#define G_API_OP_M G_API_OP + +namespace cv +{ +namespace gapi +{ + // Prework: model "Device" API before it gets to G-API headers. + // FIXME: Don't mix with internal Backends class! + /// @private + class GAPI_EXPORTS GBackend + { + public: + class Priv; + + // TODO: make it template (call `new` within??) + GBackend(); + explicit GBackend(std::shared_ptr &&p); + + Priv& priv(); + const Priv& priv() const; + std::size_t hash() const; + + bool operator== (const GBackend &rhs) const; + + private: + std::shared_ptr m_priv; + }; + + inline bool operator != (const GBackend &lhs, const GBackend &rhs) + { + return !(lhs == rhs); + } +} // namespace gapi +} // namespace cv + +namespace std +{ + template<> struct hash + { + std::size_t operator() (const cv::gapi::GBackend &b) const + { + return b.hash(); + } + }; +} // namespace std + + +namespace cv { +namespace gapi { + /// @private + class GFunctor + { + public: + virtual cv::GKernelImpl impl() const = 0; + virtual cv::gapi::GBackend backend() const = 0; + const char* id() const { return m_id; } + + virtual ~GFunctor() = default; + protected: + GFunctor(const char* id) : m_id(id) { }; + private: + const char* m_id; + }; + + /** \addtogroup gapi_compile_args + * @{ + */ + + // FIXME: Hide implementation + /** + * @brief A container class for heterogeneous kernel + * implementation collections and graph transformations. + * + * GKernelPackage is a special container class which stores kernel + * _implementations_ and graph _transformations_. Objects of this class + * are created and passed to cv::GComputation::compile() to specify + * which kernels to use and which transformations to apply in the + * compiled graph. GKernelPackage may contain kernels of + * different backends, e.g. be heterogeneous. + * + * The most easy way to create a kernel package is to use function + * cv::gapi::kernels(). This template functions takes kernel + * implementations in form of type list (variadic template) and + * generates a kernel package atop of that. + * + * Kernel packages can be also generated programmatically, starting + * with an empty package (created with the default constructor) + * and then by populating it with kernels via call to + * GKernelPackage::include(). Note this method is also a template + * one since G-API kernel and transformation implementations are _types_, + * not objects. + * + * Finally, two kernel packages can be combined into a new one + * with function cv::gapi::combine(). + */ + class GAPI_EXPORTS_W_SIMPLE GKernelPackage + { + + /// @private + using M = std::unordered_map>; + + /// @private + M m_id_kernels; + + /// @private + std::vector m_transformations; + + protected: + /// @private + // Remove ALL implementations of the given API (identified by ID) + void removeAPI(const std::string &id); + + /// @private + // Partial include() specialization for kernels + template + typename std::enable_if<(std::is_base_of::value), void>::type + includeHelper() + { + auto backend = KImpl::backend(); + auto kernel_id = KImpl::API::id(); + auto kernel_impl = GKernelImpl{KImpl::kernel(), &KImpl::API::getOutMeta}; + removeAPI(kernel_id); + + m_id_kernels[kernel_id] = std::make_pair(backend, kernel_impl); + } + + /// @private + // Partial include() specialization for transformations + template + typename std::enable_if<(std::is_base_of::value), void>::type + includeHelper() + { + m_transformations.emplace_back(TImpl::transformation()); + } + + public: + void include(const GFunctor& functor) + { + m_id_kernels[functor.id()] = std::make_pair(functor.backend(), functor.impl()); + } + /** + * @brief Returns total number of kernels + * in the package (across all backends included) + * + * @return a number of kernels in the package + */ + std::size_t size() const; + + /** + * @brief Returns vector of transformations included in the package + * + * @return vector of transformations included in the package + */ + const std::vector& get_transformations() const; + + /** + * @brief Returns vector of kernel ids included in the package + * + * @return vector of kernel ids included in the package + */ + std::vector get_kernel_ids() const; + + /** + * @brief Test if a particular kernel _implementation_ KImpl is + * included in this kernel package. + * + * @sa includesAPI() + * + * @note cannot be applied to transformations + * + * @return true if there is such kernel, false otherwise. + */ + template + bool includes() const + { + static_assert(std::is_base_of::value, + "includes() can be applied to kernels only"); + + auto kernel_it = m_id_kernels.find(KImpl::API::id()); + return kernel_it != m_id_kernels.end() && + kernel_it->second.first == KImpl::backend(); + } + + /** + * @brief Remove all kernels associated with the given backend + * from the package. + * + * Does nothing if there's no kernels of this backend in the package. + * + * @param backend backend which kernels to remove + */ + void remove(const GBackend& backend); + + /** + * @brief Remove all kernels implementing the given API from + * the package. + * + * Does nothing if there's no kernels implementing the given interface. + */ + template + void remove() + { + removeAPI(KAPI::id()); + } + + // FIXME: Rename to includes() and distinguish API/impl case by + // statically? + /** + * Check if package contains ANY implementation of a kernel API + * by API type. + */ + template + bool includesAPI() const + { + return includesAPI(KAPI::id()); + } + + /// @private + bool includesAPI(const std::string &id) const; + + // FIXME: The below comment is wrong, and who needs this function? + /** + * @brief Find a kernel (by its API) + * + * Returns implementation corresponding id. + * Throws if nothing found. + * + * @return Backend which hosts matching kernel implementation. + * + */ + template + GBackend lookup() const + { + return lookup(KAPI::id()).first; + } + + /// @private + std::pair + lookup(const std::string &id) const; + + // FIXME: No overwrites allowed? + /** + * @brief Put a new kernel implementation or a new transformation + * KImpl into the package. + */ + template + void include() + { + includeHelper(); + } + + /** + * @brief Adds a new kernel based on it's backend and id into the kernel package + * + * @param backend backend associated with the kernel + * @param kernel_id a name/id of the kernel + */ + void include(const cv::gapi::GBackend& backend, const std::string& kernel_id) + { + removeAPI(kernel_id); + m_id_kernels[kernel_id] = std::make_pair(backend, GKernelImpl{{}, {}}); + } + + /** + * @brief Lists all backends which are included into package + * + * @return vector of backends + */ + std::vector backends() const; + + // TODO: Doxygen bug -- it wants me to place this comment + // here, not below. + /** + * @brief Create a new package based on `lhs` and `rhs`. + * + * @param lhs "Left-hand-side" package in the process + * @param rhs "Right-hand-side" package in the process + * @return a new kernel package. + */ + friend GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs, + const GKernelPackage &rhs); + }; + + /** + * @brief Create a kernel package object containing kernels + * and transformations specified in variadic template argument. + * + * In G-API, kernel implementations and transformations are _types_. + * Every backend has its own kernel API (like GAPI_OCV_KERNEL() and + * GAPI_FLUID_KERNEL()) but all of that APIs define a new type for + * each kernel implementation. + * + * Use this function to pass kernel implementations (defined in + * either way) and transformations to the system. Example: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp kernels_snippet + * + * Note that kernels() itself is a function returning object, not + * a type, so having `()` at the end is important -- it must be a + * function call. + */ + template GKernelPackage kernels() + { + // FIXME: currently there is no check that transformations' signatures are unique + // and won't be any intersection in graph compilation stage + static_assert(cv::detail::all_unique::value, "Kernels API must be unique"); + + GKernelPackage pkg; + + // For those who wonder - below is a trick to call a number of + // methods based on parameter pack (zeroes just help hiding these + // calls into a sequence which helps to expand this parameter pack). + // Just note that `f(),a` always equals to `a` (with f() called!) + // and parentheses are used to hide function call in the expanded sequence. + // Leading 0 helps to handle case when KK is an empty list (kernels<>()). + int unused[] = { 0, (pkg.include(), 0)... }; + cv::util::suppress_unused_warning(unused); + return pkg; + }; + + template + GKernelPackage kernels(FF&... functors) + { + GKernelPackage pkg; + int unused[] = { 0, (pkg.include(functors), 0)... }; + cv::util::suppress_unused_warning(unused); + return pkg; + }; + + /** @} */ + + // FYI - this function is already commented above + GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs, + const GKernelPackage &rhs); + + /** + * @brief Combines multiple G-API kernel packages into one + * + * @overload + * + * This function successively combines the passed kernel packages using a right fold. + * Calling `combine(a, b, c)` is equal to `combine(a, combine(b, c))`. + * + * @return The resulting kernel package + */ + template + GKernelPackage combine(const GKernelPackage &a, const GKernelPackage &b, Ps&&... rest) + { + return combine(a, combine(b, rest...)); + } + + /** \addtogroup gapi_compile_args + * @{ + */ + /** + * @brief cv::gapi::use_only() is a special combinator which hints G-API to use only + * kernels specified in cv::GComputation::compile() (and not to extend kernels available by + * default with that package). + */ + struct GAPI_EXPORTS use_only + { + GKernelPackage pkg; + }; + /** @} */ + +} // namespace gapi + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.kernel_package"; } + }; + + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.use_only"; } + }; +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_GKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gmat.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gmat.hpp new file mode 100644 index 0000000..7bea97b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gmat.hpp @@ -0,0 +1,279 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GMAT_HPP +#define OPENCV_GAPI_GMAT_HPP + +#include +#include // std::shared_ptr + +#include +#include // GShape + +#include + +// TODO GAPI_EXPORTS or so +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; + +/** \addtogroup gapi_data_objects + * @{ + * + * @brief G-API data objects used to build G-API expressions. + * + * These objects do not own any particular data (except compile-time + * associated values like with cv::GScalar or `cv::GArray`) and are + * used only to construct graphs. + * + * Every graph in G-API starts and ends with data objects. + * + * Once constructed and compiled, G-API operates with regular host-side + * data instead. Refer to the below table to find the mapping between + * G-API and regular data types when passing input and output data + * structures to G-API: + * + * G-API data type | I/O data type + * ------------------ | ------------- + * cv::GMat | cv::Mat, cv::UMat, cv::RMat + * cv::GScalar | cv::Scalar + * `cv::GArray` | std::vector + * `cv::GOpaque` | T + * cv::GFrame | cv::MediaFrame + */ +/** + * @brief GMat class represents image or tensor data in the + * graph. + * + * GMat doesn't store any data itself, instead it describes a + * functional relationship between operations consuming and producing + * GMat objects. + * + * GMat is a virtual counterpart of Mat and UMat, but it + * doesn't mean G-API use Mat or UMat objects internally to represent + * GMat objects -- the internal data representation may be + * backend-specific or optimized out at all. + * + * @sa Mat, GMatDesc + */ +class GAPI_EXPORTS_W_SIMPLE GMat +{ +public: + /** + * @brief Constructs an empty GMat + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty GMat is assigned to a result of some + * operation, it obtains a functional link to this operation (and + * is not empty anymore). + */ + GAPI_WRAP GMat(); // Empty constructor + + /// @private + GMat(const GNode &n, std::size_t out); // Operation result constructor + /// @private + GOrigin& priv(); // Internal use only + /// @private + const GOrigin& priv() const; // Internal use only + +private: + std::shared_ptr m_priv; +}; + +class GAPI_EXPORTS GMatP : public GMat +{ +public: + using GMat::GMat; +}; + +class RMat; + +/** @} */ + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GMatDesc +{ + // FIXME: Default initializers in C++14 + GAPI_PROP int depth; + GAPI_PROP int chan; + GAPI_PROP cv::Size size; // NB.: no multi-dimensional cases covered yet + GAPI_PROP bool planar; + GAPI_PROP std::vector dims; // FIXME: Maybe it's real questionable to have it here + + GAPI_WRAP GMatDesc(int d, int c, cv::Size s, bool p = false) + : depth(d), chan(c), size(s), planar(p) {} + + GAPI_WRAP GMatDesc(int d, const std::vector &dd) + : depth(d), chan(-1), size{-1,-1}, planar(false), dims(dd) {} + + GAPI_WRAP GMatDesc(int d, std::vector &&dd) + : depth(d), chan(-1), size{-1,-1}, planar(false), dims(std::move(dd)) {} + + GAPI_WRAP GMatDesc() : GMatDesc(-1, -1, {-1,-1}) {} + + inline bool operator== (const GMatDesc &rhs) const + { + return depth == rhs.depth + && chan == rhs.chan + && size == rhs.size + && planar == rhs.planar + && dims == rhs.dims; + } + + inline bool operator!= (const GMatDesc &rhs) const + { + return !(*this == rhs); + } + + bool isND() const { return !dims.empty(); } + + // Checks if the passed mat can be described by this descriptor + // (it handles the case when + // 1-channel mat can be reinterpreted as is (1-channel mat) + // and as a 3-channel planar mat with height divided by 3) + bool canDescribe(const cv::Mat& mat) const; + + bool canDescribe(const cv::RMat& mat) const; + + // Meta combinator: return a new GMatDesc which differs in size by delta + // (all other fields are taken unchanged from this GMatDesc) + // FIXME: a better name? + GAPI_WRAP GMatDesc withSizeDelta(cv::Size delta) const + { + GMatDesc desc(*this); + desc.size += delta; + return desc; + } + // Meta combinator: return a new GMatDesc which differs in size by delta + // (all other fields are taken unchanged from this GMatDesc) + // + // This is an overload. + GAPI_WRAP GMatDesc withSizeDelta(int dx, int dy) const + { + return withSizeDelta(cv::Size{dx,dy}); + } + + GAPI_WRAP GMatDesc withSize(cv::Size sz) const + { + GMatDesc desc(*this); + desc.size = sz; + return desc; + } + + // Meta combinator: return a new GMatDesc with specified data depth. + // (all other fields are taken unchanged from this GMatDesc) + GAPI_WRAP GMatDesc withDepth(int ddepth) const + { + GAPI_Assert(CV_MAT_CN(ddepth) == 1 || ddepth == -1); + GMatDesc desc(*this); + if (ddepth != -1) desc.depth = ddepth; + return desc; + } + + // Meta combinator: return a new GMatDesc with specified data depth + // and number of channels. + // (all other fields are taken unchanged from this GMatDesc) + GAPI_WRAP GMatDesc withType(int ddepth, int dchan) const + { + GAPI_Assert(CV_MAT_CN(ddepth) == 1 || ddepth == -1); + GMatDesc desc = withDepth(ddepth); + desc.chan = dchan; + return desc; + } + + // Meta combinator: return a new GMatDesc with planar flag set + // (no size changes are performed, only channel interpretation is changed + // (interleaved -> planar) + GAPI_WRAP GMatDesc asPlanar() const + { + GAPI_Assert(planar == false); + GMatDesc desc(*this); + desc.planar = true; + return desc; + } + + // Meta combinator: return a new GMatDesc + // reinterpreting 1-channel input as planar image + // (size height is divided by plane number) + GAPI_WRAP GMatDesc asPlanar(int planes) const + { + GAPI_Assert(planar == false); + GAPI_Assert(chan == 1); + GAPI_Assert(planes > 1); + GAPI_Assert(size.height % planes == 0); + GMatDesc desc(*this); + desc.size.height /= planes; + desc.chan = planes; + return desc.asPlanar(); + } + + // Meta combinator: return a new GMatDesc with planar flag set to false + // (no size changes are performed, only channel interpretation is changed + // (planar -> interleaved) + GAPI_WRAP GMatDesc asInterleaved() const + { + GAPI_Assert(planar == true); + GMatDesc desc(*this); + desc.planar = false; + return desc; + } +}; + +static inline GMatDesc empty_gmat_desc() { return GMatDesc{-1,-1,{-1,-1}}; } + +namespace gapi { namespace detail { +/** Checks GMatDesc fields if the passed matrix is a set of n-dimentional points. +@param in GMatDesc to check. +@param n expected dimensionality. +@return the amount of points. In case input matrix can't be described as vector of points +of expected dimensionality, returns -1. + */ +int checkVector(const GMatDesc& in, const size_t n); + +/** @overload + +Checks GMatDesc fields if the passed matrix can be described as a set of points of any +dimensionality. + +@return array of two elements in form of std::vector: the amount of points +and their calculated dimensionality. In case input matrix can't be described as vector of points, +returns {-1, -1}. + */ +std::vector checkVector(const GMatDesc& in); +}} // namespace gapi::detail + +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS GMatDesc descr_of(const cv::UMat &mat); +#endif // !defined(GAPI_STANDALONE) + +//Fwd declarations +namespace gapi { namespace own { + class Mat; + GAPI_EXPORTS GMatDesc descr_of(const Mat &mat); +}}//gapi::own + +GAPI_EXPORTS GMatDesc descr_of(const RMat &mat); + +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS GMatDesc descr_of(const cv::Mat &mat); +#else +using gapi::own::descr_of; +#endif + +/** @} */ + +GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc); + +} // namespace cv + +#endif // OPENCV_GAPI_GMAT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gmetaarg.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gmetaarg.hpp new file mode 100644 index 0000000..f21182c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gmetaarg.hpp @@ -0,0 +1,80 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GMETAARG_HPP +#define OPENCV_GAPI_GMETAARG_HPP + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +namespace cv +{ +// FIXME: Rename to GMeta? +// FIXME: user shouldn't deal with it - put to detail? +// GMetaArg is an union type over descriptions of G-types which can serve as +// GComputation's in/output slots. +// +// GMetaArg objects are passed as arguments to GComputation::compile() +// to specify which data a compiled computation should be specialized on. +// For manual compile(), user must supply this metadata, in case of apply() +// this metadata is taken from arguments computation should operate on. +// +// The first type (monostate) is equal to "uninitialized"/"unresolved" meta. +using GMetaArg = util::variant + < util::monostate + , GMatDesc + , GScalarDesc + , GArrayDesc + , GOpaqueDesc + , GFrameDesc + >; +GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &); + +using GMetaArgs = std::vector; + +namespace detail +{ + // These traits are used by GComputation::compile() + + // FIXME: is_constructible doesn't work as variant doesn't do any SFINAE + // in its current template constructor + + template struct is_meta_descr : std::false_type {}; + template<> struct is_meta_descr : std::true_type {}; + template<> struct is_meta_descr : std::true_type {}; + template<> struct is_meta_descr : std::true_type {}; + template<> struct is_meta_descr : std::true_type {}; + + template + using are_meta_descrs = all_satisfy; + + template + using are_meta_descrs_but_last = all_satisfy::type>; + +} // namespace detail + +// Note: descr_of(std::vector<..>) returns a GArrayDesc, while +// descrs_of(std::vector<..>) returns an array of Meta args! +class UMat; +GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector &vec); +GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector &vec); +namespace gapi { namespace own { + GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector &vec); +}} // namespace gapi::own + +} // namespace cv + +#endif // OPENCV_GAPI_GMETAARG_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gopaque.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gopaque.hpp new file mode 100644 index 0000000..f77795c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gopaque.hpp @@ -0,0 +1,369 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GOPAQUE_HPP +#define OPENCV_GAPI_GOPAQUE_HPP + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include // OpaqueKind +#include // TypeHintBase + +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; +template class GOpaque; + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GOpaqueDesc +{ + // FIXME: Body + // FIXME: Also implement proper operator== then + bool operator== (const GOpaqueDesc&) const { return true; } +}; +template GOpaqueDesc descr_of(const U &) { return {};} +GAPI_EXPORTS_W inline GOpaqueDesc empty_gopaque_desc() {return {}; } +/** @} */ + +std::ostream& operator<<(std::ostream& os, const cv::GOpaqueDesc &desc); + +namespace detail +{ + // ConstructOpaque is a callback which stores information about T and is used by + // G-API runtime to construct an object in host memory (T remains opaque for G-API). + // ConstructOpaque is carried into G-API internals by GOpaqueU. + // Currently it is suitable for Host (CPU) plugins only, real offload may require + // more information for manual memory allocation on-device. + class OpaqueRef; + using ConstructOpaque = std::function; + + // FIXME: garray.hpp already contains hint classes (for actual T type verification), + // need to think where it can be moved (currently opaque uses it from garray) + + // This class strips type information from GOpaque and makes it usable + // in the G-API graph compiler (expression unrolling, graph generation, etc). + // Part of GProtoArg. + class GAPI_EXPORTS GOpaqueU + { + public: + GOpaqueU(const GNode &n, std::size_t out); // Operation result constructor + + template + bool holds() const; // Check if was created from GOpaque + + GOrigin& priv(); // Internal use only + const GOrigin& priv() const; // Internal use only + + protected: + GOpaqueU(); // Default constructor + template friend class cv::GOpaque; // (available for GOpaque only) + + void setConstructFcn(ConstructOpaque &&cv); // Store T-aware constructor + + template + void specifyType(); // Store type of initial GOpaque + + template + void storeKind(); + + void setKind(cv::detail::OpaqueKind); + + std::shared_ptr m_priv; + std::shared_ptr m_hint; + }; + + template + bool GOpaqueU::holds() const{ + GAPI_Assert(m_hint != nullptr); + using U = util::decay_t; + return dynamic_cast*>(m_hint.get()) != nullptr; + }; + + template + void GOpaqueU::specifyType(){ + m_hint.reset(new TypeHint>); + }; + + template + void GOpaqueU::storeKind(){ + // FIXME: Add assert here on cv::Mat and cv::Scalar? + setKind(cv::detail::GOpaqueTraits::kind); + }; + + // This class represents a typed object reference. + // Depending on origins, this reference may be either "just a" reference to + // an object created externally, OR actually own the underlying object + // (be value holder). + class BasicOpaqueRef + { + public: + cv::GOpaqueDesc m_desc; + virtual ~BasicOpaqueRef() {} + + virtual void mov(BasicOpaqueRef &ref) = 0; + virtual const void* ptr() const = 0; + virtual void set(const cv::util::any &a) = 0; + }; + + template class OpaqueRefT final: public BasicOpaqueRef + { + using empty_t = util::monostate; + using ro_ext_t = const T *; + using rw_ext_t = T *; + using rw_own_t = T ; + util::variant m_ref; + + inline bool isEmpty() const { return util::holds_alternative(m_ref); } + inline bool isROExt() const { return util::holds_alternative(m_ref); } + inline bool isRWExt() const { return util::holds_alternative(m_ref); } + inline bool isRWOwn() const { return util::holds_alternative(m_ref); } + + void init(const T* obj = nullptr) + { + if (obj) m_desc = cv::descr_of(*obj); + } + + public: + OpaqueRefT() { init(); } + virtual ~OpaqueRefT() {} + + explicit OpaqueRefT(const T& obj) : m_ref(&obj) { init(&obj); } + explicit OpaqueRefT( T& obj) : m_ref(&obj) { init(&obj); } + explicit OpaqueRefT( T&& obj) : m_ref(std::move(obj)) { init(&obj); } + + // Reset a OpaqueRefT. Called only for objects instantiated + // internally in G-API (e.g. temporary GOpaque's within a + // computation). Reset here means both initialization + // (creating an object) and reset (discarding its existing + // content before the next execution). Must never be called + // for external OpaqueRefTs. + void reset() + { + if (isEmpty()) + { + T empty_obj{}; + m_desc = cv::descr_of(empty_obj); + m_ref = std::move(empty_obj); + GAPI_Assert(isRWOwn()); + } + else if (isRWOwn()) + { + util::get(m_ref) = {}; + } + else GAPI_Assert(false); // shouldn't be called in *EXT modes + } + + // Obtain a WRITE reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + T& wref() + { + GAPI_Assert(isRWExt() || isRWOwn()); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + // Obtain a READ reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + const T& rref() const + { + // ANY object can be accessed for reading, even if it declared for + // output. Example -- a GComputation from [in] to [out1,out2] + // where [out2] is a result of operation applied to [out1]: + // + // GComputation boundary + // . . . . . . . + // . . + // [in] ----> foo() ----> [out1] + // . . : + // . . . .:. . . + // . V . + // . bar() ---> [out2] + // . . . . . . . . . . . . + // + if (isROExt()) return *util::get(m_ref); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + virtual void mov(BasicOpaqueRef &v) override { + OpaqueRefT *tv = dynamic_cast*>(&v); + GAPI_Assert(tv != nullptr); + wref() = std::move(tv->wref()); + } + + virtual const void* ptr() const override { return &rref(); } + + virtual void set(const cv::util::any &a) override { + wref() = util::any_cast(a); + } + }; + + // This class strips type information from OpaqueRefT<> and makes it usable + // in the G-API executables (carrying run-time data/information to kernels). + // Part of GRunArg. + // Its methods are typed proxies to OpaqueRefT. + // OpaqueRef maintains "reference" semantics so two copies of OpaqueRef refer + // to the same underlying object. + class OpaqueRef + { + std::shared_ptr m_ref; + cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN; + + template inline void check() const + { + GAPI_DbgAssert(dynamic_cast*>(m_ref.get()) != nullptr); + } + + public: + OpaqueRef() = default; + + template< + typename T, + typename = util::are_different_t + > + // FIXME: probably won't work with const object + explicit OpaqueRef(T&& obj) : + m_ref(new OpaqueRefT>(std::forward(obj))), + m_kind(GOpaqueTraits>::kind) {} + + cv::detail::OpaqueKind getKind() const + { + return m_kind; + } + + template void reset() + { + if (!m_ref) m_ref.reset(new OpaqueRefT()); + check(); + storeKind(); + static_cast&>(*m_ref).reset(); + } + + template + void storeKind() + { + m_kind = cv::detail::GOpaqueTraits::kind; + } + + template T& wref() + { + check(); + return static_cast&>(*m_ref).wref(); + } + + template const T& rref() const + { + check(); + return static_cast&>(*m_ref).rref(); + } + + void mov(OpaqueRef &v) + { + m_ref->mov(*v.m_ref); + } + + cv::GOpaqueDesc descr_of() const + { + return m_ref->m_desc; + } + + // May be used to uniquely identify this object internally + const void *ptr() const { return m_ref->ptr(); } + + // Introduced for in-graph meta handling + OpaqueRef& operator= (const cv::util::any &a) + { + m_ref->set(a); + return *this; + } + }; +} // namespace detail + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief `cv::GOpaque` template class represents an object of + * class `T` in the graph. + * + * `cv::GOpaque` describes a functional relationship between operations + * consuming and producing object of class `T`. `cv::GOpaque` is + * designed to extend G-API with user-defined data types, which are + * often required with user-defined operations. G-API can't apply any + * optimizations to user-defined types since these types are opaque to + * the framework. However, there is a number of G-API operations + * declared with `cv::GOpaque` as a return type, + * e.g. cv::gapi::streaming::timestamp() or cv::gapi::streaming::size(). + * + * @sa `cv::GArray` + */ +template class GOpaque +{ +public: + // Host type (or Flat type) - the type this GOpaque is actually + // specified to. + /// @private + using HT = typename detail::flatten_g>::type; + + /** + * @brief Constructs an empty `cv::GOpaque` + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty `cv::GOpaque` is assigned to a result + * of some operation, it obtains a functional link to this + * operation (and is not empty anymore). + */ + GOpaque() { putDetails(); } // Empty constructor + + /// @private + explicit GOpaque(detail::GOpaqueU &&ref) // GOpaqueU-based constructor + : m_ref(ref) { putDetails(); } // (used by GCall, not for users) + + /// @private + detail::GOpaqueU strip() const { + return m_ref; + } + /// @private + static void Ctor(detail::OpaqueRef& ref) { + ref.reset(); + } +private: + void putDetails() { + m_ref.setConstructFcn(&Ctor); + m_ref.specifyType(); + m_ref.storeKind(); + } + + detail::GOpaqueU m_ref; +}; + +/** @} */ + +} // namespace cv + +#endif // OPENCV_GAPI_GOPAQUE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gproto.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gproto.hpp new file mode 100644 index 0000000..a2b5d83 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gproto.hpp @@ -0,0 +1,159 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GPROTO_HPP +#define OPENCV_GAPI_GPROTO_HPP + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace cv { + +// FIXME: user shouldn't deal with it - put to detail? +// GProtoArg is an union type over G-types which can serve as +// GComputation's in/output slots. In other words, GProtoArg +// wraps any type which can serve as G-API exchange type. +// +// In Runtime, GProtoArgs are substituted with appropriate GRunArgs. +// +// GProtoArg objects are constructed in-place when user describes +// (captures) computations, user doesn't interact with these types +// directly. +using GProtoArg = util::variant + < GMat + , GMatP + , GFrame + , GScalar + , detail::GArrayU // instead of GArray + , detail::GOpaqueU // instead of GOpaque + >; + +using GProtoArgs = std::vector; + +namespace detail +{ +template inline GProtoArgs packArgs(Ts... args) +{ + return GProtoArgs{ GProtoArg(wrap_gapi_helper::wrap(args))... }; +} + +} + +template +struct GIOProtoArgs +{ +public: + // NB: Used by python wrapper + GIOProtoArgs() = default; + explicit GIOProtoArgs(const GProtoArgs& args) : m_args(args) {} + explicit GIOProtoArgs(GProtoArgs &&args) : m_args(std::move(args)) {} + + GProtoArgs m_args; + + // TODO: Think about the addition operator + /** + * @brief This operator allows to complement the proto vectors at runtime. + * + * It's an ordinary overload of addition assignment operator. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GIOProtoArgs usage + * + */ + template + friend GIOProtoArgs& operator += (GIOProtoArgs &lhs, const GIOProtoArgs &rhs); +}; + +template +cv::GIOProtoArgs& operator += (cv::GIOProtoArgs &lhs, const cv::GIOProtoArgs &rhs) +{ + lhs.m_args.reserve(lhs.m_args.size() + rhs.m_args.size()); + lhs.m_args.insert(lhs.m_args.end(), rhs.m_args.begin(), rhs.m_args.end()); + return lhs; +} + +struct In_Tag{}; +struct Out_Tag{}; + +using GProtoInputArgs = GIOProtoArgs; +using GProtoOutputArgs = GIOProtoArgs; + +// Perfect forwarding +template inline GProtoInputArgs GIn(Ts&&... ts) +{ + return GProtoInputArgs(detail::packArgs(std::forward(ts)...)); +} + +template inline GProtoOutputArgs GOut(Ts&&... ts) +{ + return GProtoOutputArgs(detail::packArgs(std::forward(ts)...)); +} + +namespace detail +{ + // Extract elements form tuple + // FIXME: Someday utilize a generic tuple_to_vec<> routine + template + static GProtoOutputArgs getGOut_impl(const std::tuple& ts, detail::Seq) + { + return GProtoOutputArgs{ detail::packArgs(std::get(ts)...)}; + } +} + +template inline GProtoOutputArgs GOut(const std::tuple& ts) +{ + // TODO: think of std::forward(ts) + return detail::getGOut_impl(ts, typename detail::MkSeq::type()); +} + +// Takes rvalue as input arg +template inline GProtoOutputArgs GOut(std::tuple&& ts) +{ + // TODO: think of std::forward(ts) + return detail::getGOut_impl(ts, typename detail::MkSeq::type()); +} + +// Extract run-time arguments from node origin +// Can be used to extract constant values associated with G-objects +// (like GScalar) at graph construction time +GRunArg value_of(const GOrigin &origin); + +// Transform run-time computation arguments into a collection of metadata +// extracted from that arguments +GMetaArg GAPI_EXPORTS descr_of(const GRunArg &arg ); +GMetaArgs GAPI_EXPORTS descr_of(const GRunArgs &args); + +// Transform run-time operation result argument into metadata extracted from that argument +// Used to compare the metadata, which generated at compile time with the metadata result operation in run time +GMetaArg GAPI_EXPORTS descr_of(const GRunArgP& argp); + +// Checks if run-time computation argument can be described by metadata +bool GAPI_EXPORTS can_describe(const GMetaArg& meta, const GRunArg& arg); +bool GAPI_EXPORTS can_describe(const GMetaArgs& metas, const GRunArgs& args); + +// Checks if run-time computation result argument can be described by metadata. +// Used to check if the metadata generated at compile time +// coincides with output arguments passed to computation in cpu and ocl backends +bool GAPI_EXPORTS can_describe(const GMetaArg& meta, const GRunArgP& argp); + +// Validates input arguments +void GAPI_EXPORTS validate_input_arg(const GRunArg& arg); +void GAPI_EXPORTS validate_input_args(const GRunArgs& args); + +} // namespace cv + +#endif // OPENCV_GAPI_GPROTO_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/core.hpp new file mode 100644 index 0000000..a7ee595 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/core.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GPU_CORE_API_HPP +#define OPENCV_GAPI_GPU_CORE_API_HPP +/** @file +* @deprecated Use instead. +*/ + +#include + +namespace cv { +namespace gapi { +namespace core { +namespace gpu { + using namespace ocl; +} // namespace gpu +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_GPU_CORE_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/ggpukernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/ggpukernel.hpp new file mode 100644 index 0000000..b52c21d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/ggpukernel.hpp @@ -0,0 +1,18 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GGPUKERNEL_HPP +#define OPENCV_GAPI_GGPUKERNEL_HPP +/** @file +* @deprecated Use instead. +*/ + +#include +#define GAPI_GPU_KERNEL GAPI_OCL_KERNEL + + +#endif // OPENCV_GAPI_GGPUKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/imgproc.hpp new file mode 100644 index 0000000..b0df7ae --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gpu/imgproc.hpp @@ -0,0 +1,28 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GPU_IMGPROC_API_HPP +#define OPENCV_GAPI_GPU_IMGPROC_API_HPP +/** @file +* @deprecated Use instead. +*/ + +#include + + +namespace cv { +namespace gapi { +namespace imgproc { +namespace gpu { + using namespace ocl; +} // namespace gpu +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_GPU_IMGPROC_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gscalar.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gscalar.hpp new file mode 100644 index 0000000..7ebeded --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gscalar.hpp @@ -0,0 +1,140 @@ +// This file is part of OpenCV project. + +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GSCALAR_HPP +#define OPENCV_GAPI_GSCALAR_HPP + +#include + +#include +#include // GShape +#include + +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief GScalar class represents cv::Scalar data in the graph. + * + * GScalar may be associated with a cv::Scalar value, which becomes + * its constant value bound in graph compile time. cv::GScalar describes a + * functional relationship between operations consuming and producing + * GScalar objects. + * + * GScalar is a virtual counterpart of cv::Scalar, which is usually used + * to represent the GScalar data in G-API during the execution. + * + * @sa Scalar + */ +class GAPI_EXPORTS_W_SIMPLE GScalar +{ +public: + /** + * @brief Constructs an empty GScalar + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty GScalar is assigned to a result of some + * operation, it obtains a functional link to this operation (and + * is not empty anymore). + */ + GAPI_WRAP GScalar(); + + /** + * @brief Constructs a value-initialized GScalar + * + * In contrast with GMat (which can be either an explicit graph input + * or a result of some operation), GScalars may have their values + * be associated at graph construction time. It is useful when + * some operation has a GScalar input which doesn't change during + * the program execution, and is set only once. In this case, + * there is no need to declare such GScalar as a graph input. + * + * @note The value of GScalar may be overwritten by assigning some + * other GScalar to the object using `operator=` -- on the + * assigment, the old GScalar value is discarded. + * + * @param s a cv::Scalar value to associate with this GScalar object. + */ + explicit GScalar(const cv::Scalar& s); + + /** + * @overload + * @brief Constructs a value-initialized GScalar + * + * @param s a cv::Scalar value to associate with this GScalar object. + */ + explicit GScalar(cv::Scalar&& s); // Constant value move-constructor from cv::Scalar + + /** + * @overload + * @brief Constructs a value-initialized GScalar + * + * @param v0 A `double` value to associate with this GScalar. Note + * that only the first component of a four-component cv::Scalar is + * set to this value, with others remain zeros. + * + * This constructor overload is not marked `explicit` and can be + * used in G-API expression code like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp gscalar_implicit + * + * Here operator+(GMat,GScalar) is used to wrap cv::gapi::addC() + * and a value-initialized GScalar is created on the fly. + * + * @overload + */ + GScalar(double v0); // Constant value constructor from double + + /// @private + GScalar(const GNode &n, std::size_t out); // Operation result constructor + /// @private + GOrigin& priv(); // Internal use only + /// @private + const GOrigin& priv() const; // Internal use only + +private: + std::shared_ptr m_priv; +}; + +/** @} */ + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GScalarDesc +{ + // NB.: right now it is empty + + inline bool operator== (const GScalarDesc &) const + { + return true; // NB: implement this method if GScalar meta appears + } + + inline bool operator!= (const GScalarDesc &rhs) const + { + return !(*this == rhs); + } +}; + +GAPI_EXPORTS_W inline GScalarDesc empty_scalar_desc() { return GScalarDesc(); } + +GAPI_EXPORTS GScalarDesc descr_of(const cv::Scalar &scalar); + +std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &desc); + +} // namespace cv + +#endif // OPENCV_GAPI_GSCALAR_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gstreaming.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gstreaming.hpp new file mode 100644 index 0000000..890eb58 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gstreaming.hpp @@ -0,0 +1,430 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GSTREAMING_COMPILED_HPP +#define OPENCV_GAPI_GSTREAMING_COMPILED_HPP + +#include +#include + +#include +#include +#include +#include +#include + +namespace cv { + +template using optional = cv::util::optional; + +namespace detail { +template struct wref_spec { + using type = T; +}; +template struct wref_spec > { + using type = T; +}; + +template +struct OptRef { + struct OptHolder { + virtual void mov(RefHolder &h) = 0; + virtual void reset() = 0; + virtual ~OptHolder() = default; + using Ptr = std::shared_ptr; + }; + template struct Holder final: OptHolder { + std::reference_wrapper > m_opt_ref; + + explicit Holder(cv::optional& opt) : m_opt_ref(std::ref(opt)) { + } + virtual void mov(RefHolder &h) override { + using U = typename wref_spec::type; + m_opt_ref.get() = cv::util::make_optional(std::move(h.template wref())); + } + virtual void reset() override { + m_opt_ref.get().reset(); + } + }; + template + explicit OptRef(cv::optional& t) : m_opt{new Holder(t)} {} + void mov(RefHolder &h) { m_opt->mov(h); } + void reset() { m_opt->reset();} +private: + typename OptHolder::Ptr m_opt; +}; +using OptionalVectorRef = OptRef; +using OptionalOpaqueRef = OptRef; +} // namespace detail + +// TODO: Keep it in sync with GRunArgP (derive the type automatically?) +using GOptRunArgP = util::variant< + optional*, + optional*, + optional*, + optional*, + cv::detail::OptionalVectorRef, + cv::detail::OptionalOpaqueRef +>; +using GOptRunArgsP = std::vector; + +using GOptRunArg = util::variant< + optional, + optional, + optional, + optional, + optional, + optional +>; +using GOptRunArgs = std::vector; + +namespace detail { + +template inline GOptRunArgP wrap_opt_arg(optional& arg) { + // By default, T goes to an OpaqueRef. All other types are specialized + return GOptRunArgP{OptionalOpaqueRef(arg)}; +} + +template inline GOptRunArgP wrap_opt_arg(optional >& arg) { + return GOptRunArgP{OptionalVectorRef(arg)}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &m) { + return GOptRunArgP{&m}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &m) { + return GOptRunArgP{&m}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &f) { + return GOptRunArgP{&f}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &s) { + return GOptRunArgP{&s}; +} + +} // namespace detail + +// Now cv::gout() may produce an empty vector (see "dynamic graphs"), so +// there may be a conflict between these two. State here that Opt version +// _must_ have at least one input for this overload +template +inline GOptRunArgsP gout(optional&arg, optional&... args) +{ + return GOptRunArgsP{ detail::wrap_opt_arg(arg), detail::wrap_opt_arg(args)... }; +} + +/** + * \addtogroup gapi_main_classes + * @{ + */ +/** + * @brief Represents a computation (graph) compiled for streaming. + * + * This class represents a product of graph compilation (calling + * cv::GComputation::compileStreaming()). Objects of this class + * actually do stream processing, and the whole pipeline execution + * complexity is incapsulated into objects of this class. Execution + * model has two levels: at the very top, the execution of a + * heterogeneous graph is aggressively pipelined; at the very bottom + * the execution of every internal block is determined by its + * associated backend. Backends are selected based on kernel packages + * passed via compilation arguments ( see @ref gapi_compile_args, + * GNetworkPackage, GKernelPackage for details). + * + * GStreamingCompiled objects have a "player" semantics -- there are + * methods like start() and stop(). GStreamingCompiled has a full + * control over a videostream and so is stateful. You need to specify the + * input stream data using setSource() and then call start() to + * actually start processing. After that, use pull() or try_pull() to + * obtain next processed data frame from the graph in a blocking or + * non-blocking way, respectively. + * + * Currently a single GStreamingCompiled can process only one video + * streat at time. Produce multiple GStreamingCompiled objects to run the + * same graph on multiple video streams. + * + * @sa GCompiled + */ +class GAPI_EXPORTS_W_SIMPLE GStreamingCompiled +{ +public: + class GAPI_EXPORTS Priv; + GAPI_WRAP GStreamingCompiled(); + + // FIXME: More overloads? + /** + * @brief Specify the input data to GStreamingCompiled for + * processing, a generic version. + * + * Use gin() to create an input parameter vector. + * + * Input vectors must have the same number of elements as defined + * in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::Mat needs to be passed where cv::GMat has been + * declared as input, and so on). Run-time exception is generated + * on type mismatch. + * + * In contrast with regular GCompiled, user can also pass an + * object of type GVideoCapture for a GMat parameter of the parent + * GComputation. The compiled pipeline will start fetching data + * from that GVideoCapture and feeding it into the + * pipeline. Pipeline stops when a GVideoCapture marks end of the + * stream (or when stop() is called). + * + * Passing a regular Mat for a GMat parameter makes it "infinite" + * source -- pipeline may run forever feeding with this Mat until + * stopped explicitly. + * + * Currently only a single GVideoCapture is supported as input. If + * the parent GComputation is declared with multiple input GMat's, + * one of those can be specified as GVideoCapture but all others + * must be regular Mat objects. + * + * Throws if pipeline is already running. Use stop() and then + * setSource() to run the graph on a new video stream. + * + * @note This method is not thread-safe (with respect to the user + * side) at the moment. Protect the access if + * start()/stop()/setSource() may be called on the same object in + * multiple threads in your application. + * + * @param ins vector of inputs to process. + * @sa gin + */ + void setSource(GRunArgs &&ins); + + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP void setSource(const cv::detail::ExtractArgsCallback& callback); + + /** + * @brief Specify an input video stream for a single-input + * computation pipeline. + * + * Throws if pipeline is already running. Use stop() and then + * setSource() to run the graph on a new video stream. + * + * @overload + * @param s a shared pointer to IStreamSource representing the + * input video stream. + */ + void setSource(const gapi::wip::IStreamSource::Ptr& s); + + /** + * @brief Constructs and specifies an input video stream for a + * single-input computation pipeline with the given parameters. + * + * Throws if pipeline is already running. Use stop() and then + * setSource() to run the graph on a new video stream. + * + * @overload + * @param args arguments used to contruct and initialize a stream + * source. + */ + template + void setSource(Args&&... args) { + setSource(cv::gapi::wip::make_src(std::forward(args)...)); + } + + /** + * @brief Start the pipeline execution. + * + * Use pull()/try_pull() to obtain data. Throws an exception if + * a video source was not specified. + * + * setSource() must be called first, even if the pipeline has been + * working already and then stopped (explicitly via stop() or due + * stream completion) + * + * @note This method is not thread-safe (with respect to the user + * side) at the moment. Protect the access if + * start()/stop()/setSource() may be called on the same object in + * multiple threads in your application. + */ + GAPI_WRAP void start(); + + /** + * @brief Get the next processed frame from the pipeline. + * + * Use gout() to create an output parameter vector. + * + * Output vectors must have the same number of elements as defined + * in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::Mat needs to be passed where cv::GMat has been + * declared as output, and so on). Run-time exception is generated + * on type mismatch. + * + * This method writes new data into objects passed via output + * vector. If there is no data ready yet, this method blocks. Use + * try_pull() if you need a non-blocking version. + * + * @param outs vector of output parameters to obtain. + * @return true if next result has been obtained, + * false marks end of the stream. + */ + bool pull(cv::GRunArgsP &&outs); + + // NB: Used from python + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP std::tuple> pull(); + + /** + * @brief Get some next available data from the pipeline. + * + * This method takes a vector of cv::optional object. An object is + * assigned to some value if this value is available (ready) at + * the time of the call, and resets the object to empty() if it is + * not. + * + * This is a blocking method which guarantees that some data has + * been written to the output vector on return. + * + * Using this method only makes sense if the graph has + * desynchronized parts (see cv::gapi::desync). If there is no + * desynchronized parts in the graph, the behavior of this + * method is identical to the regular pull() (all data objects are + * produced synchronously in the output vector). + * + * Use gout() to create an output parameter vector. + * + * Output vectors must have the same number of elements as defined + * in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::optional needs to be passed where cv::GMat + * has been declared as output, and so on). Run-time exception is + * generated on type mismatch. + * + * This method writes new data into objects passed via output + * vector. If there is no data ready yet, this method blocks. Use + * try_pull() if you need a non-blocking version. + * + * @param outs vector of output parameters to obtain. + * @return true if next result has been obtained, + * false marks end of the stream. + * + * @sa cv::gapi::desync + */ + bool pull(cv::GOptRunArgsP &&outs); + + /** + * @brief Try to get the next processed frame from the pipeline. + * + * Use gout() to create an output parameter vector. + * + * This method writes new data into objects passed via output + * vector. If there is no data ready yet, the output vector + * remains unchanged and false is returned. + * + * @return true if data has been obtained, and false if it was + * not. Note: false here doesn't mark the end of the stream. + */ + bool try_pull(cv::GRunArgsP &&outs); + + /** + * @brief Stop (abort) processing the pipeline. + * + * Note - it is not pause but a complete stop. Calling start() + * will cause G-API to start processing the stream from the early beginning. + * + * Throws if the pipeline is not running. + */ + GAPI_WRAP void stop(); + + /** + * @brief Test if the pipeline is running. + * + * @note This method is not thread-safe (with respect to the user + * side) at the moment. Protect the access if + * start()/stop()/setSource() may be called on the same object in + * multiple threads in your application. + * + * @return true if the current stream is not over yet. + */ + GAPI_WRAP bool running() const; + + /// @private + Priv& priv(); + + /** + * @brief Check if compiled object is valid (non-empty) + * + * @return true if the object is runnable (valid), false otherwise + */ + explicit operator bool () const; + + /** + * @brief Vector of metadata this graph was compiled for. + * + * @return Unless _reshape_ is not supported, return value is the + * same vector which was passed to cv::GComputation::compile() to + * produce this compiled object. Otherwise, it is the latest + * metadata vector passed to reshape() (if that call was + * successful). + */ + const GMetaArgs& metas() const; // Meta passed to compile() + + /** + * @brief Vector of metadata descriptions of graph outputs + * + * @return vector with formats/resolutions of graph's output + * objects, auto-inferred from input metadata vector by + * operations which form this computation. + * + * @note GCompiled objects produced from the same + * cv::GComputiation graph with different input metas may return + * different values in this vector. + */ + const GMetaArgs& outMetas() const; + +protected: + /// @private + std::shared_ptr m_priv; +}; +/** @} */ + +namespace gapi { + +/** + * @brief This namespace contains G-API functions, structures, and + * symbols related to the Streaming execution mode. + * + * Some of the operations defined in this namespace (e.g. size(), + * BGR(), etc.) can be used in the traditional execution mode too. + */ +namespace streaming { +/** + * @brief Specify queue capacity for streaming execution. + * + * In the streaming mode the pipeline steps are connected with queues + * and this compile argument controls every queue's size. + */ +struct GAPI_EXPORTS_W_SIMPLE queue_capacity +{ + GAPI_WRAP + explicit queue_capacity(size_t cap = 1) : capacity(cap) { }; + GAPI_PROP_RW + size_t capacity; +}; +/** @} */ +} // namespace streaming +} // namespace gapi + +namespace detail +{ +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.queue_capacity"; } +}; +} + +} + +#endif // OPENCV_GAPI_GSTREAMING_COMPILED_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtransform.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtransform.hpp new file mode 100644 index 0000000..109bc87 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtransform.hpp @@ -0,0 +1,103 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_GTRANSFORM_HPP +#define OPENCV_GAPI_GTRANSFORM_HPP + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace cv +{ + +struct GAPI_EXPORTS GTransform +{ + // FIXME: consider another simplified + // class instead of GComputation + using F = std::function; + + std::string description; + F pattern; + F substitute; + + GTransform(const std::string& d, const F &p, const F &s) : description(d), pattern(p), substitute(s) {} +}; + +namespace detail +{ + +template +struct TransHelper; + +template +struct TransHelper, Out> +{ + template + static GComputation invoke(Callable f, Seq, Seq) + { + const std::tuple ins; + const auto r = tuple_wrap_helper::get(f(std::get(ins)...)); + return GComputation(cv::GIn(std::get(ins)...), + cv::GOut(std::get(r)...)); + } + + static GComputation get_pattern() + { + return invoke(K::pattern, typename MkSeq::type(), + typename MkSeq::type>::value>::type()); + } + static GComputation get_substitute() + { + return invoke(K::substitute, typename MkSeq::type(), + typename MkSeq::type>::value>::type()); + } +}; +} // namespace detail + +template +class GTransformImpl; + +template +class GTransformImpl> : public cv::detail::TransHelper, R>, + public cv::detail::TransformTag +{ +public: + // FIXME: currently there is no check that transformations' signatures are unique + // and won't be any intersection in graph compilation stage + using API = K; + + static GTransform transformation() + { + return GTransform(K::descr(), &K::get_pattern, &K::get_substitute); + } +}; +} // namespace cv + +#define G_DESCR_HELPER_CLASS(Class) Class##DescrHelper + +#define G_DESCR_HELPER_BODY(Class, Descr) \ + namespace detail \ + { \ + struct G_DESCR_HELPER_CLASS(Class) \ + { \ + static constexpr const char *descr() { return Descr; }; \ + }; \ + } + +#define GAPI_TRANSFORM(Class, API, Descr) \ + G_DESCR_HELPER_BODY(Class, Descr) \ + struct Class final : public cv::GTransformImpl, \ + public detail::G_DESCR_HELPER_CLASS(Class) + +#endif // OPENCV_GAPI_GTRANSFORM_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtype_traits.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtype_traits.hpp new file mode 100644 index 0000000..2b43421 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtype_traits.hpp @@ -0,0 +1,240 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GTYPE_TRAITS_HPP +#define OPENCV_GAPI_GTYPE_TRAITS_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cv +{ +namespace detail +{ + template + struct contains_shape_field : std::false_type {}; + + template + struct contains_shape_field> : + std::is_same::type, GShape> + {}; + + template + struct has_gshape : contains_shape_field {}; + + // FIXME: These traits and enum and possible numerous switch(kind) + // block may be replaced with a special Handler object or with + // a double dispatch + enum class ArgKind: int + { + OPAQUE_VAL, // Unknown, generic, opaque-to-GAPI data type - STATIC + // Note: OPAQUE is sometimes defined in Win sys headers +#if !defined(OPAQUE) && !defined(CV_DOXYGEN) + OPAQUE = OPAQUE_VAL, // deprecated value used for compatibility, use OPAQUE_VAL instead +#endif + GOBJREF, // reference to object + GMAT, // a cv::GMat + GMATP, // a cv::GMatP + GFRAME, // a cv::GFrame + GSCALAR, // a cv::GScalar + GARRAY, // a cv::GArrayU (note - exactly GArrayU, not GArray!) + GOPAQUE, // a cv::GOpaqueU (note - exactly GOpaqueU, not GOpaque!) + }; + + // Describe G-API types (G-types) with traits. Mostly used by + // cv::GArg to store meta information about types passed into + // operation arguments. Please note that cv::GComputation is + // defined on GProtoArgs, not GArgs! + template struct GTypeTraits; + template struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::OPAQUE_VAL; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GMAT; + static constexpr const GShape shape = GShape::GMAT; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GMATP; + static constexpr const GShape shape = GShape::GMAT; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GFRAME; + static constexpr const GShape shape = GShape::GFRAME; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GSCALAR; + static constexpr const GShape shape = GShape::GSCALAR; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template struct GTypeTraits > + { + static constexpr const ArgKind kind = ArgKind::GARRAY; + static constexpr const GShape shape = GShape::GARRAY; + static constexpr const OpaqueKind op_kind = GOpaqueTraits::kind; + using host_type = std::vector; + using strip_type = cv::detail::VectorRef; + static cv::detail::GArrayU wrap_value(const cv::GArray &t) { return t.strip();} + static cv::detail::VectorRef wrap_in (const std::vector &t) { return detail::VectorRef(t); } + static cv::detail::VectorRef wrap_out ( std::vector &t) { return detail::VectorRef(t); } + }; + template struct GTypeTraits > + { + static constexpr const ArgKind kind = ArgKind::GOPAQUE; + static constexpr const GShape shape = GShape::GOPAQUE; + static constexpr const OpaqueKind op_kind = GOpaqueTraits::kind; + using host_type = T; + using strip_type = cv::detail::OpaqueRef; + static cv::detail::GOpaqueU wrap_value(const cv::GOpaque &t) { return t.strip();} + static cv::detail::OpaqueRef wrap_in (const T &t) { return detail::OpaqueRef(t); } + static cv::detail::OpaqueRef wrap_out ( T &t) { return detail::OpaqueRef(t); } + }; + + // Tests if Trait for type T requires extra marshalling ("custom wrap") or not. + // If Traits has wrap_value() defined, it does. + template struct has_custom_wrap + { + template class check; + template static std::true_type test(check::wrap_value)> *); + template static std::false_type test(...); + using type = decltype(test(nullptr)); + static const constexpr bool value = std::is_same(nullptr))>::value; + }; + + // Resolve a Host type back to its associated G-Type. + // FIXME: Probably it can be avoided + // FIXME: GMatP is not present here. + // (Actually these traits is used only to check + // if associated G-type has custom wrap functions + // and GMat behavior is correct for GMatP) + template struct GTypeOf; +#if !defined(GAPI_STANDALONE) + template<> struct GTypeOf { using type = cv::GMat; }; +#endif // !defined(GAPI_STANDALONE) + template<> struct GTypeOf { using type = cv::GMat; }; + template<> struct GTypeOf { using type = cv::GMat; }; + template<> struct GTypeOf { using type = cv::GScalar; }; + template struct GTypeOf > { using type = cv::GArray; }; + template struct GTypeOf { using type = cv::GOpaque;}; + template<> struct GTypeOf { using type = cv::GFrame; }; + // FIXME: This is not quite correct since IStreamSource may produce not only Mat but also Scalar + // and vector data. TODO: Extend the type dispatching on these types too. + template<> struct GTypeOf { using type = cv::GMat;}; + template using g_type_of_t = typename GTypeOf::type; + + // Marshalling helper for G-types and its Host types. Helps G-API + // to store G types in internal generic containers for further + // processing. Implements the following callbacks: + // + // * wrap() - converts user-facing G-type into an internal one + // for internal storage. + // Used when G-API operation is instantiated (G::on(), + // etc) during expressing a pipeline. Mostly returns input + // value "as is" except the case when G-type is a template. For + // template G-classes, calls custom wrap() from Traits. + // The value returned by wrap() is then wrapped into GArg() and + // stored in G-API metadata. + // + // Example: + // - cv::GMat arguments are passed as-is. + // - integers, pointers, STL containers, user types are passed as-is. + // - cv::GArray is converted to cv::GArrayU. + // + // * wrap_in() / wrap_out() - convert Host type associated with + // G-type to internal representation type. + // + // - For "simple" (non-template) G-types, returns value as-is. + // Example: cv::GMat has host type cv::Mat, when user passes a + // cv::Mat, system stores it internally as cv::Mat. + // + // - For "complex" (template) G-types, utilizes custom + // wrap_in()/wrap_out() as described in Traits. + // Example: cv::GArray has host type std::vector, when + // user passes a std::vector, system stores it + // internally as VectorRef (with stripped away). + template struct WrapValue + { + static auto wrap(const T& t) -> + typename std::remove_reference::type + { + return static_cast::type>(t); + } + + template static U wrap_in (const U &u) { return u; } + template static U* wrap_out(U &u) { return &u; } + }; + template struct WrapValue::value>::type> + { + static auto wrap(const T& t) -> decltype(GTypeTraits::wrap_value(t)) + { + return GTypeTraits::wrap_value(t); + } + template static auto wrap_in (const U &u) -> typename GTypeTraits::strip_type + { + static_assert(!(cv::detail::has_gshape>::value + || cv::detail::contains::type, GAPI_OWN_TYPES_LIST>::value), + "gin/gout must not be used with G* classes or cv::gapi::own::*"); + return GTypeTraits::wrap_in(u); + } + template static auto wrap_out(U &u) -> typename GTypeTraits::strip_type + { + static_assert(!(cv::detail::has_gshape>::value + || cv::detail::contains::type, GAPI_OWN_TYPES_LIST>::value), + "gin/gout must not be used with G* classses or cv::gapi::own::*"); + return GTypeTraits::wrap_out(u); + } + }; + + template using wrap_gapi_helper = WrapValue::type>; + template using wrap_host_helper = WrapValue >::type>; + +// Union type for various user-defined type constructors (GArray, +// GOpaque, etc) +// +// TODO: Replace construct-only API with a more generic one (probably +// with bits of introspection) +// +// Not required for non-user-defined types (GMat, GScalar, etc) +using HostCtor = util::variant + < util::monostate + , detail::ConstructVec + , detail::ConstructOpaque + >; + +template struct GObtainCtor { + static HostCtor get() { return HostCtor{}; } +}; +template struct GObtainCtor > { + static HostCtor get() { return HostCtor{ConstructVec{&GArray::VCtor}}; }; +}; +template struct GObtainCtor > { + static HostCtor get() { return HostCtor{ConstructOpaque{&GOpaque::Ctor}}; }; +}; +} // namespace detail +} // namespace cv + +#endif // OPENCV_GAPI_GTYPE_TRAITS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtyped.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtyped.hpp new file mode 100644 index 0000000..c1c16d1 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/gtyped.hpp @@ -0,0 +1,246 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GTYPED_HPP +#define OPENCV_GAPI_GTYPED_HPP +#if !defined(GAPI_STANDALONE) + +#include + +#include +#include +#include +#include + +namespace cv { + +namespace detail +{ + // FIXME: How to prevent coolhackers from extending it by their own types? + // FIXME: ...Should we care? + template struct ProtoToParam; + template<> struct ProtoToParam { using type = cv::Mat; }; + template<> struct ProtoToParam { using type = cv::Scalar; }; + template struct ProtoToParam > { using type = std::vector; }; + template<> struct ProtoToParam> { using type = std::vector; }; + template struct ProtoToParam > { using type = U; }; + template using ProtoToParamT = typename ProtoToParam::type; + + template struct ProtoToMeta; + template<> struct ProtoToMeta { using type = cv::GMatDesc; }; + template<> struct ProtoToMeta { using type = cv::GScalarDesc; }; + template struct ProtoToMeta > { using type = cv::GArrayDesc; }; + template struct ProtoToMeta > { using type = cv::GOpaqueDesc; }; + template using ProtoToMetaT = typename ProtoToMeta::type; + + //workaround for MSVC 19.0 bug + template + auto make_default()->decltype(T{}) {return {};} +}; // detail + +/** + * @brief This class is a typed wrapper over a regular GComputation. + * + * `std::function<>`-like template parameter specifies the graph + * signature so methods so the object's constructor, methods like + * `apply()` and the derived `GCompiledT::operator()` also become + * typed. + * + * There is no need to use cv::gin() or cv::gout() modifiers with + * objects of this class. Instead, all input arguments are followed + * by all output arguments in the order from the template argument + * signature. + * + * Refer to the following example. Regular (untyped) code is written this way: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp Untyped_Example + * + * Here: + * + * - cv::GComputation object is created with a lambda constructor + * where it is defined as a two-input, one-output graph. + * + * - Its method `apply()` in fact takes arbitrary number of arguments + * (as vectors) so user can pass wrong number of inputs/outputs + * here. C++ compiler wouldn't notice that since the cv::GComputation + * API is polymorphic, and only a run-time error will be generated. + * + * Now the same code written with typed API: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp Typed_Example + * + * The key difference is: + * + * - Now the constructor lambda *must take* parameters and *must + * return* values as defined in the `GComputationT<>` signature. + * - Its method `apply()` does not require any extra specifiers to + * separate input arguments from the output ones + * - A `GCompiledT` (compilation product) takes input/output + * arguments with no extra specifiers as well. + */ +template class GComputationT; + +// Single return value implementation +template class GComputationT +{ +public: + typedef std::function Gen; + + class GCompiledT + { + private: + friend class GComputationT; + + cv::GCompiled m_comp; + + explicit GCompiledT(const cv::GCompiled &comp) : m_comp(comp) {} + + public: + GCompiledT() {} + + void operator()(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT &outArg) + { + m_comp(cv::gin(inArgs...), cv::gout(outArg)); + } + + explicit operator bool() const + { + return static_cast(m_comp); + } + }; + +private: + typedef std::pair Captured; + + Captured capture(const Gen& g, Args... args) + { + return Captured(g(args...), cv::GIn(args...)); + } + + Captured m_capture; + cv::GComputation m_comp; + +public: + GComputationT(const Gen &generator) + : m_capture(capture(generator, detail::make_default()...)) + , m_comp(cv::GProtoInputArgs(std::move(m_capture.second)), + cv::GOut(m_capture.first)) + { + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT &outArg, + GCompileArgs &&args) + { + m_comp.apply(cv::gin(inArgs...), cv::gout(outArg), std::move(args)); + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT &outArg) + { + apply(inArgs..., outArg, GCompileArgs()); + } + + + GCompiledT compile(detail::ProtoToMetaT... inDescs) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), GCompileArgs())); + } + + GCompiledT compile(detail::ProtoToMetaT... inDescs, GCompileArgs &&args) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), std::move(args))); + } +}; + +// Multiple (fixed) return value implementation. FIXME: How to avoid copy-paste? +template class GComputationT(Args...)> +{ +public: + typedef std::function(Args...)> Gen; + + class GCompiledT + { + private: + friend class GComputationT(Args...)>; + + cv::GCompiled m_comp; + explicit GCompiledT(const cv::GCompiled &comp) : m_comp(comp) {} + + public: + GCompiledT() {} + + void operator()(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT&... outArgs) + { + m_comp(cv::gin(inArgs...), cv::gout(outArgs...)); + } + + explicit operator bool() const + { + return static_cast(m_comp); + } + }; + +private: + typedef std::pair Captured; + + template + Captured capture(GProtoArgs &&args, const std::tuple &rr, detail::Seq) + { + return Captured(cv::GOut(std::get(rr)...).m_args, args); + } + + Captured capture(const Gen& g, Args... args) + { + return capture(cv::GIn(args...).m_args, g(args...), typename detail::MkSeq::type()); + } + + Captured m_capture; + cv::GComputation m_comp; + +public: + GComputationT(const Gen &generator) + : m_capture(capture(generator, detail::make_default()...)) + , m_comp(cv::GProtoInputArgs(std::move(m_capture.second)), + cv::GProtoOutputArgs(std::move(m_capture.first))) + { + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT&... outArgs, + GCompileArgs &&args) + { + m_comp.apply(cv::gin(inArgs...), cv::gout(outArgs...), std::move(args)); + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT&... outArgs) + { + apply(inArgs..., outArgs..., GCompileArgs()); + } + + + GCompiledT compile(detail::ProtoToMetaT... inDescs) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), GCompileArgs())); + } + + GCompiledT compile(detail::ProtoToMetaT... inDescs, GCompileArgs &&args) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), std::move(args))); + } +}; + +} // namespace cv +#endif // !defined(GAPI_STANDALONE) +#endif // OPENCV_GAPI_GTYPED_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/imgproc.hpp new file mode 100644 index 0000000..5c4c6f7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/imgproc.hpp @@ -0,0 +1,1682 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_IMGPROC_HPP +#define OPENCV_GAPI_IMGPROC_HPP + +#include + +#include // std::tuple + +#include +#include +#include + + +/** \defgroup gapi_imgproc G-API Image processing functionality +@{ + @defgroup gapi_filters Graph API: Image filters + @defgroup gapi_colorconvert Graph API: Converting image from one color space to another + @defgroup gapi_feature Graph API: Image Feature Detection + @defgroup gapi_shape Graph API: Image Structural Analysis and Shape Descriptors +@} + */ + +namespace { +void validateFindingContoursMeta(const int depth, const int chan, const int mode) +{ + GAPI_Assert(chan == 1); + switch (mode) + { + case cv::RETR_CCOMP: + GAPI_Assert(depth == CV_8U || depth == CV_32S); + break; + case cv::RETR_FLOODFILL: + GAPI_Assert(depth == CV_32S); + break; + default: + GAPI_Assert(depth == CV_8U); + break; + } +} +} // anonymous namespace + +namespace cv { namespace gapi { + +/** + * @brief This namespace contains G-API Operation Types for OpenCV + * ImgProc module functionality. + */ +namespace imgproc { + using GMat2 = std::tuple; + using GMat3 = std::tuple; // FIXME: how to avoid this? + using GFindContoursOutput = std::tuple>,GArray>; + + G_TYPED_KERNEL(GFilter2D, ,"org.opencv.imgproc.filters.filter2D") { + static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Point, Scalar, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSepFilter, , "org.opencv.imgproc.filters.sepfilter") { + static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Mat, Point, Scalar, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GBoxFilter, , "org.opencv.imgproc.filters.boxfilter") { + static GMatDesc outMeta(GMatDesc in, int ddepth, Size, Point, bool, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GBlur, , "org.opencv.imgproc.filters.blur"){ + static GMatDesc outMeta(GMatDesc in, Size, Point, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GGaussBlur, , "org.opencv.imgproc.filters.gaussianBlur") { + static GMatDesc outMeta(GMatDesc in, Size, double, double, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GMedianBlur, , "org.opencv.imgproc.filters.medianBlur") { + static GMatDesc outMeta(GMatDesc in, int) { + return in; + } + }; + + G_TYPED_KERNEL(GErode, , "org.opencv.imgproc.filters.erode") { + static GMatDesc outMeta(GMatDesc in, Mat, Point, int, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GDilate, , "org.opencv.imgproc.filters.dilate") { + static GMatDesc outMeta(GMatDesc in, Mat, Point, int, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GMorphologyEx, , + "org.opencv.imgproc.filters.morphologyEx") { + static GMatDesc outMeta(const GMatDesc &in, MorphTypes, Mat, Point, int, + BorderTypes, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GSobel, , "org.opencv.imgproc.filters.sobel") { + static GMatDesc outMeta(GMatDesc in, int ddepth, int, int, int, double, double, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL_M(GSobelXY, , "org.opencv.imgproc.filters.sobelxy") { + static std::tuple outMeta(GMatDesc in, int ddepth, int, int, double, double, int, Scalar) { + return std::make_tuple(in.withDepth(ddepth), in.withDepth(ddepth)); + } + }; + + G_TYPED_KERNEL(GLaplacian, , + "org.opencv.imgproc.filters.laplacian") { + static GMatDesc outMeta(GMatDesc in, int ddepth, int, double, double, int) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GBilateralFilter, , + "org.opencv.imgproc.filters.bilateralfilter") { + static GMatDesc outMeta(GMatDesc in, int, double, double, int) { + return in; + } + }; + + G_TYPED_KERNEL(GEqHist, , "org.opencv.imgproc.equalizeHist"){ + static GMatDesc outMeta(GMatDesc in) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GCanny, , "org.opencv.imgproc.feature.canny"){ + static GMatDesc outMeta(GMatDesc in, double, double, int, bool) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GGoodFeatures, + (GMat,int,double,double,Mat,int,bool,double)>, + "org.opencv.imgproc.feature.goodFeaturesToTrack") { + static GArrayDesc outMeta(GMatDesc, int, double, double, const Mat&, int, bool, double) { + return empty_array_desc(); + } + }; + + using RetrMode = RetrievalModes; + using ContMethod = ContourApproximationModes; + G_TYPED_KERNEL(GFindContours, >(GMat,RetrMode,ContMethod,GOpaque)>, + "org.opencv.imgproc.shape.findContours") + { + static GArrayDesc outMeta(GMatDesc in, RetrMode mode, ContMethod, GOpaqueDesc) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return empty_array_desc(); + } + }; + + // FIXME oc: make default value offset = Point() + G_TYPED_KERNEL(GFindContoursNoOffset, >(GMat,RetrMode,ContMethod)>, + "org.opencv.imgproc.shape.findContoursNoOffset") + { + static GArrayDesc outMeta(GMatDesc in, RetrMode mode, ContMethod) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return empty_array_desc(); + } + }; + + G_TYPED_KERNEL(GFindContoursH,)>, + "org.opencv.imgproc.shape.findContoursH") + { + static std::tuple + outMeta(GMatDesc in, RetrMode mode, ContMethod, GOpaqueDesc) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + }; + + // FIXME oc: make default value offset = Point() + G_TYPED_KERNEL(GFindContoursHNoOffset,, + "org.opencv.imgproc.shape.findContoursHNoOffset") + { + static std::tuple + outMeta(GMatDesc in, RetrMode mode, ContMethod) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GBoundingRectMat, (GMat)>, + "org.opencv.imgproc.shape.boundingRectMat") { + static GOpaqueDesc outMeta(GMatDesc in) { + if (in.depth == CV_8U) + { + GAPI_Assert(in.chan == 1); + } + else + { + GAPI_Assert (in.depth == CV_32S || in.depth == CV_32F); + int amount = detail::checkVector(in, 2u); + GAPI_Assert(amount != -1 && + "Input Mat can't be described as vector of 2-dimentional points"); + } + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GBoundingRectVector32S, (GArray)>, + "org.opencv.imgproc.shape.boundingRectVector32S") { + static GOpaqueDesc outMeta(GArrayDesc) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GBoundingRectVector32F, (GArray)>, + "org.opencv.imgproc.shape.boundingRectVector32F") { + static GOpaqueDesc outMeta(GArrayDesc) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DMat, (GMat,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DMat") { + static GOpaqueDesc outMeta(GMatDesc in,DistanceTypes,double,double,double) { + int amount = detail::checkVector(in, 2u); + GAPI_Assert(amount != -1 && + "Input Mat can't be described as vector of 2-dimentional points"); + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DVector32S, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DVector32S") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DVector32F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DVector32F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DVector64F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DVector64F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DMat, (GMat,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DMat") { + static GOpaqueDesc outMeta(GMatDesc in,int,double,double,double) { + int amount = detail::checkVector(in, 3u); + GAPI_Assert(amount != -1 && + "Input Mat can't be described as vector of 3-dimentional points"); + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DVector32S, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DVector32S") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DVector32F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DVector32F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DVector64F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DVector64F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GBGR2RGB, , "org.opencv.imgproc.colorconvert.bgr2rgb") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GRGB2YUV, , "org.opencv.imgproc.colorconvert.rgb2yuv") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GYUV2RGB, , "org.opencv.imgproc.colorconvert.yuv2rgb") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GBGR2I420, , "org.opencv.imgproc.colorconvert.bgr2i420") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + GAPI_Assert(in.size.height % 2 == 0); + return in.withType(in.depth, 1).withSize(Size(in.size.width, in.size.height * 3 / 2)); + } + }; + + G_TYPED_KERNEL(GRGB2I420, , "org.opencv.imgproc.colorconvert.rgb2i420") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + GAPI_Assert(in.size.height % 2 == 0); + return in.withType(in.depth, 1).withSize(Size(in.size.width, in.size.height * 3 / 2)); + } + }; + + G_TYPED_KERNEL(GI4202BGR, , "org.opencv.imgproc.colorconvert.i4202bgr") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 1); + GAPI_Assert(in.size.height % 3 == 0); + return in.withType(in.depth, 3).withSize(Size(in.size.width, in.size.height * 2 / 3)); + } + }; + + G_TYPED_KERNEL(GI4202RGB, , "org.opencv.imgproc.colorconvert.i4202rgb") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 1); + GAPI_Assert(in.size.height % 3 == 0); + return in.withType(in.depth, 3).withSize(Size(in.size.width, in.size.height * 2 / 3)); + } + }; + + G_TYPED_KERNEL(GNV12toRGB, , "org.opencv.imgproc.colorconvert.nv12torgb") { + static GMatDesc outMeta(GMatDesc in_y, GMatDesc in_uv) { + GAPI_Assert(in_y.chan == 1); + GAPI_Assert(in_uv.chan == 2); + GAPI_Assert(in_y.depth == CV_8U); + GAPI_Assert(in_uv.depth == CV_8U); + // UV size should be aligned with Y + GAPI_Assert(in_y.size.width == 2 * in_uv.size.width); + GAPI_Assert(in_y.size.height == 2 * in_uv.size.height); + return in_y.withType(CV_8U, 3); // type will be CV_8UC3; + } + }; + + G_TYPED_KERNEL(GNV12toBGR, , "org.opencv.imgproc.colorconvert.nv12tobgr") { + static GMatDesc outMeta(GMatDesc in_y, GMatDesc in_uv) { + GAPI_Assert(in_y.chan == 1); + GAPI_Assert(in_uv.chan == 2); + GAPI_Assert(in_y.depth == CV_8U); + GAPI_Assert(in_uv.depth == CV_8U); + // UV size should be aligned with Y + GAPI_Assert(in_y.size.width == 2 * in_uv.size.width); + GAPI_Assert(in_y.size.height == 2 * in_uv.size.height); + return in_y.withType(CV_8U, 3); // type will be CV_8UC3; + } + }; + + G_TYPED_KERNEL(GRGB2Lab, , "org.opencv.imgproc.colorconvert.rgb2lab") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GBGR2LUV, , "org.opencv.imgproc.colorconvert.bgr2luv") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GLUV2BGR, , "org.opencv.imgproc.colorconvert.luv2bgr") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GYUV2BGR, , "org.opencv.imgproc.colorconvert.yuv2bgr") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GBGR2YUV, , "org.opencv.imgproc.colorconvert.bgr2yuv") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GRGB2Gray, , "org.opencv.imgproc.colorconvert.rgb2gray") { + static GMatDesc outMeta(GMatDesc in) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GRGB2GrayCustom, , "org.opencv.imgproc.colorconvert.rgb2graycustom") { + static GMatDesc outMeta(GMatDesc in, float, float, float) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GBGR2Gray, , "org.opencv.imgproc.colorconvert.bgr2gray") { + static GMatDesc outMeta(GMatDesc in) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GBayerGR2RGB, , "org.opencv.imgproc.colorconvert.bayergr2rgb") { + static cv::GMatDesc outMeta(cv::GMatDesc in) { + return in.withType(CV_8U, 3); + } + }; + + G_TYPED_KERNEL(GRGB2HSV, , "org.opencv.imgproc.colorconvert.rgb2hsv") { + static cv::GMatDesc outMeta(cv::GMatDesc in) { + return in; + } + }; + + G_TYPED_KERNEL(GRGB2YUV422, , "org.opencv.imgproc.colorconvert.rgb2yuv422") { + static cv::GMatDesc outMeta(cv::GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + return in.withType(in.depth, 2); + } + }; + + G_TYPED_KERNEL(GNV12toRGBp, , "org.opencv.imgproc.colorconvert.nv12torgbp") { + static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) { + GAPI_Assert(inY.depth == CV_8U); + GAPI_Assert(inUV.depth == CV_8U); + GAPI_Assert(inY.chan == 1); + GAPI_Assert(inY.planar == false); + GAPI_Assert(inUV.chan == 2); + GAPI_Assert(inUV.planar == false); + GAPI_Assert(inY.size.width == 2 * inUV.size.width); + GAPI_Assert(inY.size.height == 2 * inUV.size.height); + return inY.withType(CV_8U, 3).asPlanar(); + } + }; + + G_TYPED_KERNEL(GNV12toGray, , "org.opencv.imgproc.colorconvert.nv12togray") { + static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) { + GAPI_Assert(inY.depth == CV_8U); + GAPI_Assert(inUV.depth == CV_8U); + GAPI_Assert(inY.chan == 1); + GAPI_Assert(inY.planar == false); + GAPI_Assert(inUV.chan == 2); + GAPI_Assert(inUV.planar == false); + + GAPI_Assert(inY.size.width == 2 * inUV.size.width); + GAPI_Assert(inY.size.height == 2 * inUV.size.height); + return inY.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GNV12toBGRp, , "org.opencv.imgproc.colorconvert.nv12tobgrp") { + static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) { + GAPI_Assert(inY.depth == CV_8U); + GAPI_Assert(inUV.depth == CV_8U); + GAPI_Assert(inY.chan == 1); + GAPI_Assert(inY.planar == false); + GAPI_Assert(inUV.chan == 2); + GAPI_Assert(inUV.planar == false); + GAPI_Assert(inY.size.width == 2 * inUV.size.width); + GAPI_Assert(inY.size.height == 2 * inUV.size.height); + return inY.withType(CV_8U, 3).asPlanar(); + } + }; + +} //namespace imgproc + +//! @addtogroup gapi_filters +//! @{ +/** @brief Applies a separable linear filter to a matrix(image). + +The function applies a separable linear filter to the matrix. That is, first, every row of src is +filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D +kernel kernelY. The final result is returned. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - In case of floating-point computation, rounding to nearest even is procedeed +if hardware supports it (if not - to nearest value). + - Function textual ID is "org.opencv.imgproc.filters.sepfilter" +@param src Source image. +@param ddepth desired depth of the destination image (the following combinations of src.depth() and ddepth are supported: + + src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F + src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F + src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F + src.depth() = CV_64F, ddepth = -1/CV_64F + +when ddepth=-1, the output image will have the same depth as the source) +@param kernelX Coefficients for filtering each row. +@param kernelY Coefficients for filtering each column. +@param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor +is at the kernel center. +@param delta Value added to the filtered results before storing them. +@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa boxFilter, gaussianBlur, medianBlur + */ +GAPI_EXPORTS GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor /*FIXME: = Point(-1,-1)*/, + const Scalar& delta /*FIXME = GScalar(0)*/, int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Convolves an image with the kernel. + +The function applies an arbitrary linear filter to an image. When +the aperture is partially outside the image, the function interpolates outlier pixel values +according to the specified border mode. + +The function does actually compute correlation, not the convolution: + +\f[\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\f] + +That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip +the kernel using flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - +anchor.y - 1)`. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same size and number of channels an input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.filter2D" + +@param src input image. +@param ddepth desired depth of the destination image +@param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point +matrix; if you want to apply different kernels to different channels, split the image into +separate color planes using split and process them individually. +@param anchor anchor of the kernel that indicates the relative position of a filtered point within +the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor +is at the kernel center. +@param delta optional value added to the filtered pixels before storing them in dst. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa sepFilter + */ +GAPI_EXPORTS GMat filter2D(const GMat& src, int ddepth, const Mat& kernel, const Point& anchor = Point(-1,-1), const Scalar& delta = Scalar(0), + int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0)); + + +/** @brief Blurs an image using the box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\f] + +where + +\f[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise} \end{cases}\f] + +Unnormalized box filter is useful for computing various integral characteristics over each pixel +neighborhood, such as covariance matrices of image derivatives (used in dense optical flow +algorithms, and so on). If you need to compute pixel sums over variable-size windows, use cv::integral. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.boxfilter" + +@param src Source image. +@param dtype the output image depth (-1 to set the input image data type). +@param ksize blurring kernel size. +@param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor +is at the kernel center. +@param normalize flag, specifying whether the kernel is normalized by its area or not. +@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa sepFilter, gaussianBlur, medianBlur, integral + */ +GAPI_EXPORTS GMat boxFilter(const GMat& src, int dtype, const Size& ksize, const Point& anchor = Point(-1,-1), + bool normalize = true, int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Blurs an image using the normalized box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\f] + +The call `blur(src, ksize, anchor, borderType)` is equivalent to `boxFilter(src, src.type(), ksize, anchor, +true, borderType)`. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.blur" + +@param src Source image. +@param ksize blurring kernel size. +@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel +center. +@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa boxFilter, bilateralFilter, GaussianBlur, medianBlur + */ +GAPI_EXPORTS GMat blur(const GMat& src, const Size& ksize, const Point& anchor = Point(-1,-1), + int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0)); + + +//GAPI_EXPORTS_W void blur( InputArray src, OutputArray dst, + // Size ksize, Point anchor = Point(-1,-1), + // int borderType = BORDER_DEFAULT ); + + +/** @brief Blurs an image using a Gaussian filter. + +The function filter2Ds the source image with the specified Gaussian kernel. +Output image must have the same type and number of channels an input image. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.gaussianBlur" + +@param src input image; +@param ksize Gaussian kernel size. ksize.width and ksize.height can differ but they both must be +positive and odd. Or, they can be zero's and then they are computed from sigma. +@param sigmaX Gaussian kernel standard deviation in X direction. +@param sigmaY Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be +equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, +respectively (see cv::getGaussianKernel for details); to fully control the result regardless of +possible future modifications of all this semantics, it is recommended to specify all of ksize, +sigmaX, and sigmaY. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa sepFilter, boxFilter, medianBlur + */ +GAPI_EXPORTS GMat gaussianBlur(const GMat& src, const Size& ksize, double sigmaX, double sigmaY = 0, + int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0)); + +/** @brief Blurs an image using the median filter. + +The function smoothes an image using the median filter with the \f$\texttt{ksize} \times +\texttt{ksize}\f$ aperture. Each channel of a multi-channel image is processed independently. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. +The median filter uses cv::BORDER_REPLICATE internally to cope with border pixels, see cv::BorderTypes + - Function textual ID is "org.opencv.imgproc.filters.medianBlur" + +@param src input matrix (image) +@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ... +@sa boxFilter, gaussianBlur + */ +GAPI_EXPORTS_W GMat medianBlur(const GMat& src, int ksize); + +/** @brief Erodes an image by using a specific structuring element. + +The function erodes the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the minimum is taken: + +\f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.erode" + +@param src input image +@param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular +structuring element is used. Kernel can be created using getStructuringElement. +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times erosion is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa dilate, morphologyEx + */ +GAPI_EXPORTS GMat erode(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Erodes an image by using 3 by 3 rectangular structuring element. + +The function erodes the source image using the rectangular structuring element with rectangle center as an anchor. +Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.erode" + +@param src input image +@param iterations number of times erosion is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa erode, dilate3x3 + */ +GAPI_EXPORTS GMat erode3x3(const GMat& src, int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Dilates an image by using a specific structuring element. + +The function dilates the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the maximum is taken: +\f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.dilate" + +@param src input image. +@param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular +structuring element is used. Kernel can be created using getStructuringElement +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times dilation is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa erode, morphologyEx, getStructuringElement + */ +GAPI_EXPORTS GMat dilate(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Dilates an image by using 3 by 3 rectangular structuring element. + +The function dilates the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the maximum is taken: +\f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.dilate" + +@param src input image. +@param iterations number of times dilation is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa dilate, erode3x3 + */ + +GAPI_EXPORTS GMat dilate3x3(const GMat& src, int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Performs advanced morphological transformations. + +The function can perform advanced morphological transformations using an erosion and dilation as +basic operations. + +Any of the operations can be done in-place. In case of multi-channel images, each channel is +processed independently. + +@note + - Function textual ID is "org.opencv.imgproc.filters.morphologyEx" + - The number of iterations is the number of times erosion or dilatation operation will be +applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to +apply successively: erode -> erode -> dilate -> dilate +(and not erode -> dilate -> erode -> dilate). + +@param src Input image. +@param op Type of a morphological operation, see #MorphTypes +@param kernel Structuring element. It can be created using #getStructuringElement. +@param anchor Anchor position within the element. Both negative values mean that the anchor is at +the kernel center. +@param iterations Number of times erosion and dilation are applied. +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@param borderValue Border value in case of a constant border. The default value has a special +meaning. +@sa dilate, erode, getStructuringElement + */ +GAPI_EXPORTS GMat morphologyEx(const GMat &src, const MorphTypes op, const Mat &kernel, + const Point &anchor = Point(-1,-1), + const int iterations = 1, + const BorderTypes borderType = BORDER_CONSTANT, + const Scalar &borderValue = morphologyDefaultBorderValue()); + +/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. + +In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to +calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$ +kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first +or the second x- or y- derivatives. + +There is also the special value `ksize = FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is + +\f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] + +for the x-derivative, or transposed for the y-derivative. + +The function calculates an image derivative by convolving the image with the appropriate kernel: + +\f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f] + +The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less +resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) +or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first +case corresponds to a kernel of: + +\f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f] + +The second case corresponds to a kernel of: + +\f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f] + +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.sobel" + +@param src input image. +@param ddepth output image depth, see @ref filter_depths "combinations"; in the case of + 8-bit input images it will result in truncated derivatives. +@param dx order of the derivative x. +@param dy order of the derivative y. +@param ksize size of the extended Sobel kernel; it must be odd. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see cv::getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa filter2D, gaussianBlur, cartToPolar + */ +GAPI_EXPORTS GMat Sobel(const GMat& src, int ddepth, int dx, int dy, int ksize = 3, + double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. + +In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to +calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$ +kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first +or the second x- or y- derivatives. + +There is also the special value `ksize = FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is + +\f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] + +for the x-derivative, or transposed for the y-derivative. + +The function calculates an image derivative by convolving the image with the appropriate kernel: + +\f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f] + +The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less +resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) +or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first +case corresponds to a kernel of: + +\f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f] + +The second case corresponds to a kernel of: + +\f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f] + +@note + - First returned matrix correspons to dx derivative while the second one to dy. + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.sobelxy" + +@param src input image. +@param ddepth output image depth, see @ref filter_depths "combinations"; in the case of + 8-bit input images it will result in truncated derivatives. +@param order order of the derivatives. +@param ksize size of the extended Sobel kernel; it must be odd. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see cv::getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa filter2D, gaussianBlur, cartToPolar + */ +GAPI_EXPORTS std::tuple SobelXY(const GMat& src, int ddepth, int order, int ksize = 3, + double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Calculates the Laplacian of an image. + +The function calculates the Laplacian of the source image by adding up the second x and y +derivatives calculated using the Sobel operator: + +\f[\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\f] + +This is done when `ksize > 1`. When `ksize == 1`, the Laplacian is computed by filtering the image +with the following \f$3 \times 3\f$ aperture: + +\f[\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\f] + +@note Function textual ID is "org.opencv.imgproc.filters.laplacian" + +@param src Source image. +@param ddepth Desired depth of the destination image. +@param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for +details. The size must be positive and odd. +@param scale Optional scale factor for the computed Laplacian values. By default, no scaling is +applied. See #getDerivKernels for details. +@param delta Optional delta value that is added to the results prior to storing them in dst . +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@return Destination image of the same size and the same number of channels as src. +@sa Sobel, Scharr + */ +GAPI_EXPORTS GMat Laplacian(const GMat& src, int ddepth, int ksize = 1, + double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT); + +/** @brief Applies the bilateral filter to an image. + +The function applies bilateral filtering to the input image, as described in +http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html +bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is +very slow compared to most filters. + +_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\< +10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very +strong effect, making the image look "cartoonish". + +_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time +applications, and perhaps d=9 for offline applications that need heavy noise filtering. + +This filter does not work inplace. + +@note Function textual ID is "org.opencv.imgproc.filters.bilateralfilter" + +@param src Source 8-bit or floating-point, 1-channel or 3-channel image. +@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, +it is computed from sigmaSpace. +@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that +farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting +in larger areas of semi-equal color. +@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that +farther pixels will influence each other as long as their colors are close enough (see sigmaColor +). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is +proportional to sigmaSpace. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes +@return Destination image of the same size and type as src. + */ +GAPI_EXPORTS GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace, + int borderType = BORDER_DEFAULT); + +//! @} gapi_filters + +//! @addtogroup gapi_feature +//! @{ +/** @brief Finds edges in an image using the Canny algorithm. + +The function finds edges in the input image and marks them in the output map edges using the +Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The +largest value is used to find initial segments of strong edges. See + + +@note Function textual ID is "org.opencv.imgproc.feature.canny" + +@param image 8-bit input image. +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param apertureSize aperture size for the Sobel operator. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). + */ +GAPI_EXPORTS GMat Canny(const GMat& image, double threshold1, double threshold2, + int apertureSize = 3, bool L2gradient = false); + +/** @brief Determines strong corners on an image. + +The function finds the most prominent corners in the image or in the specified image region, as +described in @cite Shi94 + +- Function calculates the corner quality measure at every source image pixel using the + #cornerMinEigenVal or #cornerHarris . +- Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are + retained). +- The corners with the minimal eigenvalue less than + \f$\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\f$ are rejected. +- The remaining corners are sorted by the quality measure in the descending order. +- Function throws away each corner for which there is a stronger corner at a distance less than + maxDistance. + +The function can be used to initialize a point-based tracker of an object. + +@note + - If the function is called with different values A and B of the parameter qualityLevel , and +A \> B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector +with qualityLevel=B . + - Function textual ID is "org.opencv.imgproc.feature.goodFeaturesToTrack" + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Optional region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + +@return vector of detected corners. + */ +GAPI_EXPORTS_W GArray goodFeaturesToTrack(const GMat &image, + int maxCorners, + double qualityLevel, + double minDistance, + const Mat &mask = Mat(), + int blockSize = 3, + bool useHarrisDetector = false, + double k = 0.04); + +/** @brief Equalizes the histogram of a grayscale image. + +//! @} gapi_feature + +The function equalizes the histogram of the input image using the following algorithm: + +- Calculate the histogram \f$H\f$ for src . +- Normalize the histogram so that the sum of histogram bins is 255. +- Compute the integral of the histogram: +\f[H'_i = \sum _{0 \le j < i} H(j)\f] +- Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$ + +The algorithm normalizes the brightness and increases the contrast of the image. +@note + - The returned image is of the same size and type as input. + - Function textual ID is "org.opencv.imgproc.equalizeHist" + +@param src Source 8-bit single channel image. + */ +GAPI_EXPORTS GMat equalizeHist(const GMat& src); + +//! @addtogroup gapi_shape +//! @{ +/** @brief Finds contours in a binary image. + +The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . +The contours are a useful tool for shape analysis and object detection and recognition. +See squares.cpp in the OpenCV sample directory. + +@note Function textual ID is "org.opencv.imgproc.shape.findContours" + +@param src Input gray-scale image @ref CV_8UC1. Non-zero pixels are treated as 1's. Zero +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP, the input can also be a 32-bit integer +image of labels ( @ref CV_32SC1 ). If #RETR_FLOODFILL then @ref CV_32SC1 is supported only. +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes +@param offset Optional offset by which every contour point is shifted. This is useful if the +contours are extracted from the image ROI and then they should be analyzed in the whole image +context. + +@return GArray of detected contours. Each contour is stored as a GArray of points. + */ +GAPI_EXPORTS GArray> +findContours(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, + const GOpaque &offset); + +// FIXME oc: make default value offset = Point() +/** @overload +@note Function textual ID is "org.opencv.imgproc.shape.findContoursNoOffset" + */ +GAPI_EXPORTS GArray> +findContours(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method); + +/** @brief Finds contours and their hierarchy in a binary image. + +The function retrieves contours from the binary image using the algorithm @cite Suzuki85 +and calculates their hierarchy. +The contours are a useful tool for shape analysis and object detection and recognition. +See squares.cpp in the OpenCV sample directory. + +@note Function textual ID is "org.opencv.imgproc.shape.findContoursH" + +@param src Input gray-scale image @ref CV_8UC1. Non-zero pixels are treated as 1's. Zero +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP, the input can also be a 32-bit integer +image of labels ( @ref CV_32SC1 ). If #RETR_FLOODFILL -- @ref CV_32SC1 supports only. +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes +@param offset Optional offset by which every contour point is shifted. This is useful if the +contours are extracted from the image ROI and then they should be analyzed in the whole image +context. + +@return + - GArray of detected contours. Each contour is stored as a GArray of points. + - Optional output GArray of cv::Vec4i, containing information about the image topology. +It has as many elements as the number of contours. For each i-th contour contours[i], the elements +hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based +indices in contours of the next and previous contours at the same hierarchical level, the first +child contour and the parent contour, respectively. If for the contour i there are no next, +previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative. + */ +GAPI_EXPORTS std::tuple>,GArray> +findContoursH(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, + const GOpaque &offset); + +// FIXME oc: make default value offset = Point() +/** @overload +@note Function textual ID is "org.opencv.imgproc.shape.findContoursHNoOffset" + */ +GAPI_EXPORTS std::tuple>,GArray> +findContoursH(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method); + +/** @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels +of gray-scale image. + +The function calculates and returns the minimal up-right bounding rectangle for the specified +point set or non-zero pixels of gray-scale image. + +@note + - Function textual ID is "org.opencv.imgproc.shape.boundingRectMat" + - In case of a 2D points' set given, Mat should be 2-dimensional, have a single row or column +if there are 2 channels, or have 2 columns if there is a single channel. Mat should have either +@ref CV_32S or @ref CV_32F depth + +@param src Input gray-scale image @ref CV_8UC1; or input set of @ref CV_32S or @ref CV_32F +2D points stored in Mat. + */ +GAPI_EXPORTS_W GOpaque boundingRect(const GMat& src); + +/** @overload + +Calculates the up-right bounding rectangle of a point set. + +@note Function textual ID is "org.opencv.imgproc.shape.boundingRectVector32S" + +@param src Input 2D point set, stored in std::vector. + */ +GAPI_EXPORTS_W GOpaque boundingRect(const GArray& src); + +/** @overload + +Calculates the up-right bounding rectangle of a point set. + +@note Function textual ID is "org.opencv.imgproc.shape.boundingRectVector32F" + +@param src Input 2D point set, stored in std::vector. + */ +GAPI_EXPORTS GOpaque boundingRect(const GArray& src); + +/** @brief Fits a line to a 2D point set. + +The function fits a line to a 2D point set by minimizing \f$\sum_i \rho(r_i)\f$ where +\f$r_i\f$ is a distance between the \f$i^{th}\f$ point, the line and \f$\rho(r)\f$ is a distance +function, one of the following: +- DIST_L2 +\f[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\f] +- DIST_L1 +\f[\rho (r) = r\f] +- DIST_L12 +\f[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\f] +- DIST_FAIR +\f[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{where} \quad C=1.3998\f] +- DIST_WELSCH +\f[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{where} \quad C=2.9846\f] +- DIST_HUBER +\f[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\f] + +The algorithm is based on the M-estimator ( ) technique +that iteratively fits the line using the weighted least-squares algorithm. After each iteration the +weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . + +@note + - Function textual ID is "org.opencv.imgproc.shape.fitLine2DMat" + - In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row +or column if there are N channels, or have N columns if there is a single channel. + +@param src Input set of 2D points stored in one of possible containers: Mat, +std::vector, std::vector, std::vector. +@param distType Distance used by the M-estimator, see #DistanceTypes. @ref DIST_USER +and @ref DIST_C are not suppored. +@param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value +is chosen. +@param reps Sufficient accuracy for the radius (distance between the coordinate origin and the +line). 1.0 would be a good default value for reps. If it is 0, a default value is chosen. +@param aeps Sufficient accuracy for the angle. 0.01 would be a good default value for aeps. +If it is 0, a default value is chosen. + +@return Output line parameters: a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), +where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line. + */ +GAPI_EXPORTS GOpaque fitLine2D(const GMat& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector32S" + + */ +GAPI_EXPORTS GOpaque fitLine2D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector32F" + + */ +GAPI_EXPORTS GOpaque fitLine2D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector64F" + + */ +GAPI_EXPORTS GOpaque fitLine2D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @brief Fits a line to a 3D point set. + +The function fits a line to a 3D point set by minimizing \f$\sum_i \rho(r_i)\f$ where +\f$r_i\f$ is a distance between the \f$i^{th}\f$ point, the line and \f$\rho(r)\f$ is a distance +function, one of the following: +- DIST_L2 +\f[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\f] +- DIST_L1 +\f[\rho (r) = r\f] +- DIST_L12 +\f[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\f] +- DIST_FAIR +\f[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{where} \quad C=1.3998\f] +- DIST_WELSCH +\f[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{where} \quad C=2.9846\f] +- DIST_HUBER +\f[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\f] + +The algorithm is based on the M-estimator ( ) technique +that iteratively fits the line using the weighted least-squares algorithm. After each iteration the +weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . + +@note + - Function textual ID is "org.opencv.imgproc.shape.fitLine3DMat" + - In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row +or column if there are N channels, or have N columns if there is a single channel. + +@param src Input set of 3D points stored in one of possible containers: Mat, +std::vector, std::vector, std::vector. +@param distType Distance used by the M-estimator, see #DistanceTypes. @ref DIST_USER +and @ref DIST_C are not suppored. +@param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value +is chosen. +@param reps Sufficient accuracy for the radius (distance between the coordinate origin and the +line). 1.0 would be a good default value for reps. If it is 0, a default value is chosen. +@param aeps Sufficient accuracy for the angle. 0.01 would be a good default value for aeps. +If it is 0, a default value is chosen. + +@return Output line parameters: a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), +where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on +the line. + */ +GAPI_EXPORTS GOpaque fitLine3D(const GMat& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector32S" + + */ +GAPI_EXPORTS GOpaque fitLine3D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector32F" + + */ +GAPI_EXPORTS GOpaque fitLine3D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector64F" + + */ +GAPI_EXPORTS GOpaque fitLine3D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +//! @} gapi_shape + +//! @addtogroup gapi_colorconvert +//! @{ +/** @brief Converts an image from BGR color space to RGB color space. + +The function converts an input image from BGR color space to RGB. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image is 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2rgb" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa RGB2BGR +*/ +GAPI_EXPORTS_W GMat BGR2RGB(const GMat& src); + +/** @brief Converts an image from RGB color space to gray-scaled. + +The conventional ranges for R, G, and B channel values are 0 to 255. +Resulting gray color value computed as +\f[\texttt{dst} (I)= \texttt{0.299} * \texttt{src}(I).R + \texttt{0.587} * \texttt{src}(I).G + \texttt{0.114} * \texttt{src}(I).B \f] + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2gray" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@sa RGB2YUV + */ +GAPI_EXPORTS_W GMat RGB2Gray(const GMat& src); + +/** @overload +Resulting gray color value computed as +\f[\texttt{dst} (I)= \texttt{rY} * \texttt{src}(I).R + \texttt{gY} * \texttt{src}(I).G + \texttt{bY} * \texttt{src}(I).B \f] + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2graycustom" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@param rY float multiplier for R channel. +@param gY float multiplier for G channel. +@param bY float multiplier for B channel. +@sa RGB2YUV + */ +GAPI_EXPORTS GMat RGB2Gray(const GMat& src, float rY, float gY, float bY); + +/** @brief Converts an image from BGR color space to gray-scaled. + +The conventional ranges for B, G, and R channel values are 0 to 255. +Resulting gray color value computed as +\f[\texttt{dst} (I)= \texttt{0.114} * \texttt{src}(I).B + \texttt{0.587} * \texttt{src}(I).G + \texttt{0.299} * \texttt{src}(I).R \f] + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2gray" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@sa BGR2LUV + */ +GAPI_EXPORTS GMat BGR2Gray(const GMat& src); + +/** @brief Converts an image from RGB color space to YUV color space. + +The function converts an input image from RGB color space to YUV. +The conventional ranges for R, G, and B channel values are 0 to 255. + +In case of linear transformations, the range does not matter. But in case of a non-linear +transformation, an input RGB image should be normalized to the proper value range to get the correct +results, like here, at RGB \f$\rightarrow\f$ Y\*u\*v\* transformation. +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2yuv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa YUV2RGB, RGB2Lab +*/ +GAPI_EXPORTS GMat RGB2YUV(const GMat& src); + +/** @brief Converts an image from BGR color space to I420 color space. + +The function converts an input image from BGR color space to I420. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 1-channel image. @ref CV_8UC1. +Width of I420 output image must be the same as width of input image. +Height of I420 output image must be equal 3/2 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2i420" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa I4202BGR +*/ +GAPI_EXPORTS GMat BGR2I420(const GMat& src); + +/** @brief Converts an image from RGB color space to I420 color space. + +The function converts an input image from RGB color space to I420. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 1-channel image. @ref CV_8UC1. +Width of I420 output image must be the same as width of input image. +Height of I420 output image must be equal 3/2 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2i420" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa I4202RGB +*/ +GAPI_EXPORTS GMat RGB2I420(const GMat& src); + +/** @brief Converts an image from I420 color space to BGR color space. + +The function converts an input image from I420 color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image. @ref CV_8UC3. +Width of BGR output image must be the same as width of input image. +Height of BGR output image must be equal 2/3 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.i4202bgr" + +@param src input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@sa BGR2I420 +*/ +GAPI_EXPORTS GMat I4202BGR(const GMat& src); + +/** @brief Converts an image from I420 color space to BGR color space. + +The function converts an input image from I420 color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image. @ref CV_8UC3. +Width of RGB output image must be the same as width of input image. +Height of RGB output image must be equal 2/3 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.i4202rgb" + +@param src input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@sa RGB2I420 +*/ +GAPI_EXPORTS GMat I4202RGB(const GMat& src); + +/** @brief Converts an image from BGR color space to LUV color space. + +The function converts an input image from BGR color space to LUV. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2luv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa RGB2Lab, RGB2LUV +*/ +GAPI_EXPORTS GMat BGR2LUV(const GMat& src); + +/** @brief Converts an image from LUV color space to BGR color space. + +The function converts an input image from LUV color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.luv2bgr" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa BGR2LUV +*/ +GAPI_EXPORTS GMat LUV2BGR(const GMat& src); + +/** @brief Converts an image from YUV color space to BGR color space. + +The function converts an input image from YUV color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2bgr" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa BGR2YUV +*/ +GAPI_EXPORTS GMat YUV2BGR(const GMat& src); + +/** @brief Converts an image from BGR color space to YUV color space. + +The function converts an input image from BGR color space to YUV. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2yuv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa YUV2BGR +*/ +GAPI_EXPORTS GMat BGR2YUV(const GMat& src); + +/** @brief Converts an image from RGB color space to Lab color space. + +The function converts an input image from BGR color space to Lab. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2lab" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@sa RGB2YUV, RGB2LUV +*/ +GAPI_EXPORTS GMat RGB2Lab(const GMat& src); + +/** @brief Converts an image from YUV color space to RGB. +The function converts an input image from YUV color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2rgb" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. + +@sa RGB2Lab, RGB2YUV +*/ +GAPI_EXPORTS GMat YUV2RGB(const GMat& src); + +/** @brief Converts an image from NV12 (YUV420p) color space to RGB. +The function converts an input image from NV12 color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12torgb" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toBGR +*/ +GAPI_EXPORTS GMat NV12toRGB(const GMat& src_y, const GMat& src_uv); + +/** @brief Converts an image from NV12 (YUV420p) color space to gray-scaled. +The function converts an input image from NV12 color space to gray-scaled. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 1-channel image @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12togray" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toBGR +*/ +GAPI_EXPORTS GMat NV12toGray(const GMat& src_y, const GMat& src_uv); + +/** @brief Converts an image from NV12 (YUV420p) color space to BGR. +The function converts an input image from NV12 color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12tobgr" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat NV12toBGR(const GMat& src_y, const GMat& src_uv); + +/** @brief Converts an image from BayerGR color space to RGB. +The function converts an input image from BayerGR color space to RGB. +The conventional ranges for G, R, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bayergr2rgb" + +@param src_gr input image: 8-bit unsigned 1-channel image @ref CV_8UC1. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat BayerGR2RGB(const GMat& src_gr); + +/** @brief Converts an image from RGB color space to HSV. +The function converts an input image from RGB color space to HSV. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2hsv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat RGB2HSV(const GMat& src); + +/** @brief Converts an image from RGB color space to YUV422. +The function converts an input image from RGB color space to YUV422. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 2-channel image @ref CV_8UC2. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2yuv422" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat RGB2YUV422(const GMat& src); + +/** @brief Converts an image from NV12 (YUV420p) color space to RGB. +The function converts an input image from NV12 color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned planar 3-channel image @ref CV_8UC1. +Planar image memory layout is three planes laying in the memory contiguously, +so the image height should be plane_height*plane_number, +image type is @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12torgbp" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toBGRp, NV12toRGB +*/ +GAPI_EXPORTS GMatP NV12toRGBp(const GMat &src_y, const GMat &src_uv); + +/** @brief Converts an image from NV12 (YUV420p) color space to BGR. +The function converts an input image from NV12 color space to BGR. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned planar 3-channel image @ref CV_8UC1. +Planar image memory layout is three planes laying in the memory contiguously, +so the image height should be plane_height*plane_number, +image type is @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12torgbp" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toRGBp, NV12toBGR +*/ +GAPI_EXPORTS GMatP NV12toBGRp(const GMat &src_y, const GMat &src_uv); + +//! @} gapi_colorconvert +} //namespace gapi +} //namespace cv + +#endif // OPENCV_GAPI_IMGPROC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer.hpp new file mode 100644 index 0000000..807c82d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer.hpp @@ -0,0 +1,714 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_INFER_HPP +#define OPENCV_GAPI_INFER_HPP + +// FIXME: Inference API is currently only available in full mode +#if !defined(GAPI_STANDALONE) + +#include +#include // string +#include // tuple +#include // is_same, false_type + +#include // all_satisfy +#include // any<> +#include // GKernelType[M], GBackend +#include // GArg +#include // CompileArgTag +#include // GMetaArg + +namespace cv { + +template class GNetworkType; + +namespace detail { + +// Infer /////////////////////////////////////////////////////////////////////// +template +struct accepted_infer_types { + static constexpr const auto value = + std::is_same::type, cv::GMat>::value + || std::is_same::type, cv::GFrame>::value; +}; + +template +using valid_infer_types = all_satisfy; + +// Infer2 ////////////////////////////////////////////////////////////////////// + +template +struct valid_infer2_types; + +// Terminal case 1 (50/50 success) +template +struct valid_infer2_types< std::tuple, std::tuple > { + // By default, Nets are limited to GMat argument types only + // for infer2, every GMat argument may translate to either + // GArray or GArray. GArray<> part is stripped + // already at this point. + static constexpr const auto value = + std::is_same::type, cv::GMat>::value + || std::is_same::type, cv::Rect>::value; +}; + +// Terminal case 2 (100% failure) +template +struct valid_infer2_types< std::tuple<>, std::tuple > + : public std::false_type { +}; + +// Terminal case 3 (100% failure) +template +struct valid_infer2_types< std::tuple, std::tuple<> > + : public std::false_type { +}; + +// Recursion -- generic +template +struct valid_infer2_types< std::tuple, std::tuple > { + static constexpr const auto value = + valid_infer2_types< std::tuple, std::tuple >::value + && valid_infer2_types< std::tuple, std::tuple >::value; +}; + +// Struct stores network input/output names. +// Used by infer +struct InOutInfo +{ + std::vector in_names; + std::vector out_names; +}; + +template +class GInferOutputsTyped +{ +public: + GInferOutputsTyped() = default; + GInferOutputsTyped(std::shared_ptr call) + : m_priv(std::make_shared(std::move(call))) + { + } + + OutT at(const std::string& name) + { + auto it = m_priv->blobs.find(name); + if (it == m_priv->blobs.end()) { + // FIXME: Avoid modifying GKernel + auto shape = cv::detail::GTypeTraits::shape; + m_priv->call->kernel().outShapes.push_back(shape); + m_priv->call->kernel().outCtors.emplace_back(cv::detail::GObtainCtor::get()); + auto out_idx = static_cast(m_priv->blobs.size()); + it = m_priv->blobs.emplace(name, + cv::detail::Yield::yield(*(m_priv->call), out_idx)).first; + m_priv->info->out_names.push_back(name); + } + return it->second; + } +private: + struct Priv + { + Priv(std::shared_ptr c) + : call(std::move(c)), info(cv::util::any_cast(&call->params())) + { + } + + std::shared_ptr call; + InOutInfo* info = nullptr; + std::unordered_map blobs; + }; + + std::shared_ptr m_priv; +}; + +template +class GInferInputsTyped +{ +public: + GInferInputsTyped() + : m_priv(std::make_shared()) + { + } + + template + GInferInputsTyped& setInput(const std::string& name, U in) + { + m_priv->blobs.emplace(std::piecewise_construct, + std::forward_as_tuple(name), + std::forward_as_tuple(in)); + return *this; + } + + using StorageT = cv::util::variant; + StorageT& operator[](const std::string& name) { + return m_priv->blobs[name]; + } + + using Map = std::unordered_map; + const Map& getBlobs() const { + return m_priv->blobs; + } + +private: + struct Priv + { + std::unordered_map blobs; + }; + + std::shared_ptr m_priv; +}; + +template +std::shared_ptr makeCall(const std::string &tag, + std::vector &&args, + std::vector &&names, + cv::GKinds &&kinds) { + auto call = std::make_shared(GKernel{ + InferT::id(), + tag, + InferT::getOutMeta, + {}, // outShape will be filled later + std::move(kinds), + {}, // outCtors will be filled later + }); + + call->setArgs(std::move(args)); + call->params() = cv::detail::InOutInfo{std::move(names), {}}; + + return call; +} + +} // namespace detail + +// TODO: maybe tuple_wrap_helper from util.hpp may help with this. +// Multiple-return-value network definition (specialized base class) +template +class GNetworkType(Args...)> > +{ +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + using Result = OutArgs; + using API = std::function; + + using ResultL = std::tuple< cv::GArray... >; +}; + +// Single-return-value network definition (specialized base class) +template +class GNetworkType > +{ +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + using Result = R; + using API = std::function; + + using ResultL = cv::GArray; +}; + +// InferAPI: Accepts either GMat or GFrame for very individual network's input +template +struct InferAPI { + using type = typename std::enable_if + < detail::valid_infer_types::value + && std::tuple_size::value == sizeof...(Ts) + , std::function + >::type; +}; + +// InferAPIRoi: Accepts a rectangle and either GMat or GFrame +template +struct InferAPIRoi { + using type = typename std::enable_if + < detail::valid_infer_types::value + && std::tuple_size::value == 1u + , std::function, T)> + >::type; +}; + +// InferAPIList: Accepts a list of rectangles and list of GMat/GFrames; +// crops every input. +template +struct InferAPIList { + using type = typename std::enable_if + < detail::valid_infer_types::value + && std::tuple_size::value == sizeof...(Ts) + , std::function, Ts...)> + >::type; +}; + +// APIList2 is also template to allow different calling options +// (GArray vs GArray per input) +template +struct InferAPIList2 { + using type = typename std::enable_if + < detail::valid_infer_types::value && + cv::detail::valid_infer2_types< typename Net::InArgs + , std::tuple >::value, + std::function...)> + >::type; +}; + +// Base "Infer" kernel. Note - for whatever network, kernel ID +// is always the same. Different inference calls are distinguished by +// network _tag_ (an extra field in GCall) +// +// getOutMeta is a stub callback collected by G-API kernel subsystem +// automatically. This is a rare case when this callback is defined by +// a particular backend, not by a network itself. +struct GInferBase { + static constexpr const char * id() { + return "org.opencv.dnn.infer"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// Base "InferROI" kernel. +// All notes from "Infer" kernel apply here as well. +struct GInferROIBase { + static constexpr const char * id() { + return "org.opencv.dnn.infer-roi"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// Base "Infer list" kernel. +// All notes from "Infer" kernel apply here as well. +struct GInferListBase { + static constexpr const char * id() { + return "org.opencv.dnn.infer-roi-list-1"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// Base "Infer list 2" kernel. +// All notes from "Infer" kernel apply here as well. +struct GInferList2Base { + static constexpr const char * id() { + return "org.opencv.dnn.infer-roi-list-2"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// A generic inference kernel. API (::on()) is fully defined by the Net +// template parameter. +// Acts as a regular kernel in graph (via KernelTypeMedium). +template +struct GInfer final + : public GInferBase + , public detail::KernelTypeMedium< GInfer + , typename InferAPI::type > { + using GInferBase::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + +// A specific roi-inference kernel. API (::on()) is fixed here and +// verified against Net. +template +struct GInferROI final + : public GInferROIBase + , public detail::KernelTypeMedium< GInferROI + , typename InferAPIRoi::type > { + using GInferROIBase::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + + +// A generic roi-list inference kernel. API (::on()) is derived from +// the Net template parameter (see more in infer<> overload). +template +struct GInferList final + : public GInferListBase + , public detail::KernelTypeMedium< GInferList + , typename InferAPIList::type > { + using GInferListBase::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + +// An even more generic roi-list inference kernel. API (::on()) is +// derived from the Net template parameter (see more in infer<> +// overload). +// Takes an extra variadic template list to reflect how this network +// was called (with Rects or GMats as array parameters) +template +struct GInferList2 final + : public GInferList2Base + , public detail::KernelTypeMedium< GInferList2 + , typename InferAPIList2::type > { + using GInferList2Base::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + +/** + * @brief G-API object used to collect network inputs + */ +using GInferInputs = cv::detail::GInferInputsTyped; + +/** + * @brief G-API object used to collect the list of network inputs + */ +using GInferListInputs = cv::detail::GInferInputsTyped, cv::GArray>; + +/** + * @brief G-API object used to collect network outputs + */ +using GInferOutputs = cv::detail::GInferOutputsTyped; + +/** + * @brief G-API object used to collect the list of network outputs + */ +using GInferListOutputs = cv::detail::GInferOutputsTyped>; + +namespace detail { +void inline unpackBlobs(const cv::GInferInputs::Map& blobs, + std::vector& args, + std::vector& names, + cv::GKinds& kinds) +{ + for (auto&& p : blobs) { + names.emplace_back(p.first); + switch (p.second.index()) { + case cv::GInferInputs::StorageT::index_of(): + args.emplace_back(cv::util::get(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_MAT); + break; + case cv::GInferInputs::StorageT::index_of(): + args.emplace_back(cv::util::get(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_UNKNOWN); + break; + default: + GAPI_Assert(false); + } + } +} + +template +struct InferROITraits; + +template <> +struct InferROITraits +{ + using outType = cv::GInferOutputs; + using inType = cv::GOpaque; +}; + +template <> +struct InferROITraits +{ + using outType = cv::GInferListOutputs; + using inType = cv::GArray; +}; + +template +typename InferROITraits::outType +inferGenericROI(const std::string& tag, + const typename InferROITraits::inType& in, + const cv::GInferInputs& inputs) +{ + std::vector args; + std::vector names; + cv::GKinds kinds; + + args.emplace_back(in); + kinds.emplace_back(cv::detail::OpaqueKind::CV_RECT); + + unpackBlobs(inputs.getBlobs(), args, names, kinds); + + auto call = cv::detail::makeCall(tag, + std::move(args), + std::move(names), + std::move(kinds)); + + return {std::move(call)}; +} + +} // namespace detail +} // namespace cv + +// FIXME: Probably the signature makes a function/tuple/function round-trip +#define G_API_NET(Class, API, Tag) \ + struct Class final: public cv::GNetworkType { \ + static constexpr const char * tag() { return Tag; } \ + } + +namespace cv { +namespace gapi { + +/** @brief Calculates response for the specified network (template + * parameter) for the specified region in the source image. + * Currently expects a single-input network only. + * + * @tparam A network type defined with G_API_NET() macro. + * @param in input image where to take ROI from. + * @param roi an object describing the region of interest + * in the source image. May be calculated in the same graph dynamically. + * @return an object of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * objects of appropriate type is returned. + * @sa G_API_NET() + */ +template +typename Net::Result infer(cv::GOpaque roi, T in) { + return GInferROI::on(roi, in); +} + +/** @brief Calculates responses for the specified network (template + * parameter) for every region in the source image. + * + * @tparam A network type defined with G_API_NET() macro. + * @param roi a list of rectangles describing regions of interest + * in the source image. Usually an output of object detector or tracker. + * @param args network's input parameters as specified in G_API_NET() macro. + * NOTE: verified to work reliably with 1-input topologies only. + * @return a list of objects of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * GArray<> objects is returned with the appropriate types inside. + * @sa G_API_NET() + */ +template +typename Net::ResultL infer(cv::GArray roi, Args&&... args) { + return GInferList::on(roi, std::forward(args)...); +} + +/** @brief Calculates responses for the specified network (template + * parameter) for every region in the source image, extended version. + * + * @tparam A network type defined with G_API_NET() macro. + * @param image A source image containing regions of interest + * @param args GArray<> objects of cv::Rect or cv::GMat, one per every + * network input: + * - If a cv::GArray is passed, the appropriate + * regions are taken from `image` and preprocessed to this particular + * network input; + * - If a cv::GArray is passed, the underlying data traited + * as tensor (no automatic preprocessing happen). + * @return a list of objects of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * GArray<> objects is returned with the appropriate types inside. + * @sa G_API_NET() + */ + +template +typename Net::ResultL infer2(T image, cv::GArray... args) { + // FIXME: Declared as "2" because in the current form it steals + // overloads from the regular infer + return GInferList2::on(image, args...); +} + +/** + * @brief Calculates response for the specified network (template + * parameter) given the input data. + * + * @tparam A network type defined with G_API_NET() macro. + * @param args network's input parameters as specified in G_API_NET() macro. + * @return an object of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * objects of appropriate type is returned. + * @sa G_API_NET() + */ +template +typename Net::Result infer(Args&&... args) { + return GInfer::on(std::forward(args)...); +} + +/** + * @brief Generic network type: input and output layers are configured dynamically at runtime + * + * Unlike the network types defined with G_API_NET macro, this one + * doesn't fix number of network inputs and outputs at the compilation stage + * thus providing user with an opportunity to program them in runtime. + */ +struct Generic { }; + +/** + * @brief Calculates response for generic network + * + * @param tag a network tag + * @param inputs networks's inputs + * @return a GInferOutputs + */ +template cv::GInferOutputs +infer(const std::string& tag, const cv::GInferInputs& inputs) +{ + std::vector args; + std::vector names; + cv::GKinds kinds; + + cv::detail::unpackBlobs(inputs.getBlobs(), args, names, kinds); + + auto call = cv::detail::makeCall(tag, + std::move(args), + std::move(names), + std::move(kinds)); + + return cv::GInferOutputs{std::move(call)}; +} + +/** @brief Calculates response for the generic network + * for the specified region in the source image. + * Currently expects a single-input network only. + * + * @param tag a network tag + * @param roi a an object describing the region of interest + * in the source image. May be calculated in the same graph dynamically. + * @param inputs networks's inputs + * @return a cv::GInferOutputs + */ +template cv::GInferOutputs +infer(const std::string& tag, const cv::GOpaque& roi, const cv::GInferInputs& inputs) +{ + return cv::detail::inferGenericROI(tag, roi, inputs); +} + +/** @brief Calculates responses for the specified network + * for every region in the source image. + * + * @param tag a network tag + * @param rois a list of rectangles describing regions of interest + * in the source image. Usually an output of object detector or tracker. + * @param inputs networks's inputs + * @return a cv::GInferListOutputs + */ +template cv::GInferListOutputs +infer(const std::string& tag, const cv::GArray& rois, const cv::GInferInputs& inputs) +{ + return cv::detail::inferGenericROI(tag, rois, inputs); +} + +/** @brief Calculates responses for the specified network + * for every region in the source image, extended version. + * + * @param tag a network tag + * @param in a source image containing regions of interest. + * @param inputs networks's inputs + * @return a cv::GInferListOutputs + */ +template +typename std::enable_if::value, cv::GInferListOutputs>::type +infer2(const std::string& tag, + const Input& in, + const cv::GInferListInputs& inputs) +{ + std::vector args; + std::vector names; + cv::GKinds kinds; + + args.emplace_back(in); + auto k = cv::detail::GOpaqueTraits::kind; + kinds.emplace_back(k); + + for (auto&& p : inputs.getBlobs()) { + names.emplace_back(p.first); + switch (p.second.index()) { + case cv::GInferListInputs::StorageT::index_of>(): + args.emplace_back(cv::util::get>(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_MAT); + break; + case cv::GInferListInputs::StorageT::index_of>(): + args.emplace_back(cv::util::get>(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_RECT); + break; + default: + GAPI_Assert(false); + } + } + + auto call = cv::detail::makeCall(tag, + std::move(args), + std::move(names), + std::move(kinds)); + + return cv::GInferListOutputs{std::move(call)}; +} + +} // namespace gapi +} // namespace cv + +#endif // GAPI_STANDALONE + +namespace cv { +namespace gapi { + +// Note: the below code _is_ part of STANDALONE build, +// just to make our compiler code compileable. + +// A type-erased form of network parameters. +// Similar to how a type-erased GKernel is represented and used. +/// @private +struct GAPI_EXPORTS_W_SIMPLE GNetParam { + std::string tag; // FIXME: const? + GBackend backend; // Specifies the execution model + util::any params; // Backend-interpreted parameter structure +}; + +/** \addtogroup gapi_compile_args + * @{ + */ +/** + * @brief A container class for network configurations. Similar to + * GKernelPackage. Use cv::gapi::networks() to construct this object. + * + * @sa cv::gapi::networks + */ +struct GAPI_EXPORTS_W_SIMPLE GNetPackage { + GAPI_WRAP GNetPackage() = default; + GAPI_WRAP explicit GNetPackage(std::vector nets); + explicit GNetPackage(std::initializer_list ii); + std::vector backends() const; + std::vector networks; +}; +/** @} gapi_compile_args */ +} // namespace gapi + +namespace detail { +template +gapi::GNetParam strip(T&& t) { + return gapi::GNetParam { t.tag() + , t.backend() + , t.params() + }; +} + +template<> struct CompileArgTag { + static const char* tag() { return "gapi.net_package"; } +}; + +} // namespace cv::detail + +namespace gapi { +template +cv::gapi::GNetPackage networks(Args&&... args) { + return cv::gapi::GNetPackage({ cv::detail::strip(args)... }); +} + +inline cv::gapi::GNetPackage& operator += ( cv::gapi::GNetPackage& lhs, + const cv::gapi::GNetPackage& rhs) { + lhs.networks.reserve(lhs.networks.size() + rhs.networks.size()); + lhs.networks.insert(lhs.networks.end(), rhs.networks.begin(), rhs.networks.end()); + return lhs; +} + +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/bindings_ie.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/bindings_ie.hpp new file mode 100644 index 0000000..94272de --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/bindings_ie.hpp @@ -0,0 +1,70 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_INFER_BINDINGS_IE_HPP +#define OPENCV_GAPI_INFER_BINDINGS_IE_HPP + +#include +#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS +#include // GKernelPackage +#include // Params + +#include + +namespace cv { +namespace gapi { +namespace ie { + +// NB: Used by python wrapper +// This class can be marked as SIMPLE, because it's implemented as pimpl +class GAPI_EXPORTS_W_SIMPLE PyParams { +public: + GAPI_WRAP + PyParams() = default; + + GAPI_WRAP + PyParams(const std::string &tag, + const std::string &model, + const std::string &weights, + const std::string &device); + + GAPI_WRAP + PyParams(const std::string &tag, + const std::string &model, + const std::string &device); + + GAPI_WRAP + PyParams& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR); + + GAPI_WRAP + PyParams& cfgNumRequests(size_t nireq); + + GAPI_WRAP + PyParams& cfgBatchSize(const size_t size); + + GBackend backend() const; + std::string tag() const; + cv::util::any params() const; + +private: + std::shared_ptr> m_priv; +}; + +GAPI_EXPORTS_W PyParams params(const std::string &tag, + const std::string &model, + const std::string &weights, + const std::string &device); + +GAPI_EXPORTS_W PyParams params(const std::string &tag, + const std::string &model, + const std::string &device); +} // namespace ie +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_BINDINGS_IE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/ie.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/ie.hpp new file mode 100644 index 0000000..e6b7be5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/ie.hpp @@ -0,0 +1,479 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019-2021 Intel Corporation + +#ifndef OPENCV_GAPI_INFER_IE_HPP +#define OPENCV_GAPI_INFER_IE_HPP + +#include +#include +#include +#include +#include // tuple, tuple_size +#include + +#include +#include + +#include // GAPI_EXPORTS +#include // GKernelPackage +#include // Generic + +namespace cv { +namespace gapi { +// FIXME: introduce a new sub-namespace for NN? + +/** + * @brief This namespace contains G-API OpenVINO backend functions, + * structures, and symbols. + */ +namespace ie { + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +/** + * Specifies how G-API and IE should trait input data + * + * In OpenCV, the same cv::Mat is used to represent both + * image and tensor data. Sometimes those are hardly distinguishable, + * so this extra parameter is used to give G-API a hint. + * + * This hint controls how G-API reinterprets the data when converting + * it to IE Blob format (and which layout/etc is assigned to this data). + */ +enum class TraitAs: int +{ + TENSOR, //!< G-API traits an associated cv::Mat as a raw tensor and passes dimensions as-is + IMAGE //!< G-API traits an associated cv::Mat as an image so creates an "image" blob (NCHW/NHWC, etc) +}; + +using IEConfig = std::map; + +namespace detail { +struct ParamDesc { + std::string model_path; + std::string weights_path; + std::string device_id; + + std::vector input_names; + std::vector output_names; + + using ConstInput = std::pair; + std::unordered_map const_inputs; + + std::size_t num_in; + std::size_t num_out; + + enum class Kind {Load, Import}; + Kind kind; + bool is_generic; + IEConfig config; + + std::map> reshape_table; + std::unordered_set layer_names_to_reshape; + + // NB: Number of asyncrhonious infer requests + size_t nireq; + + // NB: An optional config to setup RemoteContext for IE + cv::util::any context_config; + + // NB: batch_size can't be equal to 1 by default, because some of models + // have 2D (Layout::NC) input and if the first dimension not equal to 1 + // net.setBatchSize(1) will overwrite it. + cv::optional batch_size; +}; +} // namespace detail + +// FIXME: this is probably a shared (reusable) thing +template +struct PortCfg { + using In = std::array + < std::string + , std::tuple_size::value >; + using Out = std::array + < std::string + , std::tuple_size::value >; +}; + +/** + * @brief This structure provides functions + * that fill inference parameters for "OpenVINO Toolkit" model. + */ +template class Params { +public: + /** @brief Class constructor. + + Constructs Params based on model information and specifies default values for other + inference description parameters. Model is loaded and compiled using "OpenVINO Toolkit". + + @param model Path to topology IR (.xml file). + @param weights Path to weights (.bin file). + @param device target device to use. + */ + Params(const std::string &model, + const std::string &weights, + const std::string &device) + : desc{ model, weights, device, {}, {}, {} + , std::tuple_size::value // num_in + , std::tuple_size::value // num_out + , detail::ParamDesc::Kind::Load + , false + , {} + , {} + , {} + , 1u + , {} + , {}} { + }; + + /** @overload + Use this constructor to work with pre-compiled network. + Model is imported from a pre-compiled blob. + + @param model Path to model. + @param device target device to use. + */ + Params(const std::string &model, + const std::string &device) + : desc{ model, {}, device, {}, {}, {} + , std::tuple_size::value // num_in + , std::tuple_size::value // num_out + , detail::ParamDesc::Kind::Import + , false + , {} + , {} + , {} + , 1u + , {} + , {}} { + }; + + /** @brief Specifies sequence of network input layers names for inference. + + The function is used to associate cv::gapi::infer<> inputs with the model inputs. + Number of names has to match the number of network inputs as defined in G_API_NET(). + In case a network has only single input layer, there is no need to specify name manually. + + @param layer_names std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains names of input layers. + @return reference to this parameter structure. + */ + Params& cfgInputLayers(const typename PortCfg::In &layer_names) { + desc.input_names.clear(); + desc.input_names.reserve(layer_names.size()); + std::copy(layer_names.begin(), layer_names.end(), + std::back_inserter(desc.input_names)); + return *this; + } + + /** @brief Specifies sequence of network output layers names for inference. + + The function is used to associate cv::gapi::infer<> outputs with the model outputs. + Number of names has to match the number of network outputs as defined in G_API_NET(). + In case a network has only single output layer, there is no need to specify name manually. + + @param layer_names std::array where N is the number of outputs + as defined in the @ref G_API_NET. Contains names of output layers. + @return reference to this parameter structure. + */ + Params& cfgOutputLayers(const typename PortCfg::Out &layer_names) { + desc.output_names.clear(); + desc.output_names.reserve(layer_names.size()); + std::copy(layer_names.begin(), layer_names.end(), + std::back_inserter(desc.output_names)); + return *this; + } + + /** @brief Specifies a constant input. + + The function is used to set a constant input. This input has to be + a preprocessed tensor if its type is TENSOR. Need to provide name of the + network layer which will receive provided data. + + @param layer_name Name of network layer. + @param data cv::Mat that contains data which will be associated with network layer. + @param hint Input type @sa cv::gapi::ie::TraitAs. + @return reference to this parameter structure. + */ + Params& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR) { + desc.const_inputs[layer_name] = {data, hint}; + return *this; + } + + /** @brief Specifies OpenVINO plugin configuration. + + The function is used to set configuration for OpenVINO plugin. Some parameters + can be different for each plugin. Please follow https://docs.openvinotoolkit.org/latest/index.html + to check information about specific plugin. + + @param cfg Map of pairs: (config parameter name, config parameter value). + @return reference to this parameter structure. + */ + Params& pluginConfig(const IEConfig& cfg) { + desc.config = cfg; + return *this; + } + + /** @overload + Function with a rvalue parameter. + + @param cfg rvalue map of pairs: (config parameter name, config parameter value). + @return reference to this parameter structure. + */ + Params& pluginConfig(IEConfig&& cfg) { + desc.config = std::move(cfg); + return *this; + } + + /** @brief Specifies configuration for RemoteContext in InferenceEngine. + + When RemoteContext is configured the backend imports the networks using the context. + It also expects cv::MediaFrames to be actually remote, to operate with blobs via the context. + + @param ctx_cfg cv::util::any value which holds InferenceEngine::ParamMap. + @return reference to this parameter structure. + */ + Params& cfgContextParams(const cv::util::any& ctx_cfg) { + desc.context_config = ctx_cfg; + return *this; + } + + /** @overload + Function with an rvalue parameter. + + @param ctx_cfg cv::util::any value which holds InferenceEngine::ParamMap. + @return reference to this parameter structure. + */ + Params& cfgContextParams(cv::util::any&& ctx_cfg) { + desc.context_config = std::move(ctx_cfg); + return *this; + } + + /** @brief Specifies number of asynchronous inference requests. + + @param nireq Number of inference asynchronous requests. + @return reference to this parameter structure. + */ + Params& cfgNumRequests(size_t nireq) { + GAPI_Assert(nireq > 0 && "Number of infer requests must be greater than zero!"); + desc.nireq = nireq; + return *this; + } + + /** @brief Specifies new input shapes for the network inputs. + + The function is used to specify new input shapes for the network inputs. + Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1networkNetwork.html + for additional information. + + @param reshape_table Map of pairs: name of corresponding data and its dimension. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(const std::map>& reshape_table) { + desc.reshape_table = reshape_table; + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::map>&& reshape_table) { + desc.reshape_table = std::move(reshape_table); + return *this; + } + + /** @overload + + @param layer_name Name of layer. + @param layer_dims New dimensions for this layer. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(const std::string& layer_name, const std::vector& layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::string&& layer_name, std::vector&& layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload + + @param layer_names set of names of network layers that will be used for network reshape. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(const std::unordered_set& layer_names) { + desc.layer_names_to_reshape = layer_names; + return *this; + } + + /** @overload + + @param layer_names rvalue set of the selected layers will be reshaped automatically + its input image size. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(std::unordered_set&& layer_names) { + desc.layer_names_to_reshape = std::move(layer_names); + return *this; + } + + /** @brief Specifies the inference batch size. + + The function is used to specify inference batch size. + Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1CNNNetwork.html#a8e9d19270a48aab50cb5b1c43eecb8e9 for additional information + + @param size batch size which will be used. + @return reference to this parameter structure. + */ + Params& cfgBatchSize(const size_t size) { + desc.batch_size = cv::util::make_optional(size); + return *this; + } + + // BEGIN(G-API's network parametrization API) + GBackend backend() const { return cv::gapi::ie::backend(); } + std::string tag() const { return Net::tag(); } + cv::util::any params() const { return { desc }; } + // END(G-API's network parametrization API) + +protected: + detail::ParamDesc desc; +}; + +/* +* @brief This structure provides functions for generic network type that +* fill inference parameters. +* @see struct Generic +*/ +template<> +class Params { +public: + /** @brief Class constructor. + + Constructs Params based on model information and sets default values for other + inference description parameters. Model is loaded and compiled using OpenVINO Toolkit. + + @param tag string tag of the network for which these parameters are intended. + @param model path to topology IR (.xml file). + @param weights path to weights (.bin file). + @param device target device to use. + */ + Params(const std::string &tag, + const std::string &model, + const std::string &weights, + const std::string &device) + : desc{ model, weights, device, {}, {}, {}, 0u, 0u, + detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u, + {}, {}}, + m_tag(tag) { + }; + + /** @overload + + This constructor for pre-compiled networks. Model is imported from pre-compiled + blob. + + @param tag string tag of the network for which these parameters are intended. + @param model path to model. + @param device target device to use. + */ + Params(const std::string &tag, + const std::string &model, + const std::string &device) + : desc{ model, {}, device, {}, {}, {}, 0u, 0u, + detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u, + {}, {}}, + m_tag(tag) { + }; + + /** @see ie::Params::pluginConfig. */ + Params& pluginConfig(const IEConfig& cfg) { + desc.config = cfg; + return *this; + } + + /** @overload */ + Params& pluginConfig(IEConfig&& cfg) { + desc.config = std::move(cfg); + return *this; + } + + /** @see ie::Params::constInput. */ + Params& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR) { + desc.const_inputs[layer_name] = {data, hint}; + return *this; + } + + /** @see ie::Params::cfgNumRequests. */ + Params& cfgNumRequests(size_t nireq) { + GAPI_Assert(nireq > 0 && "Number of infer requests must be greater than zero!"); + desc.nireq = nireq; + return *this; + } + + /** @see ie::Params::cfgInputReshape */ + Params& cfgInputReshape(const std::map>&reshape_table) { + desc.reshape_table = reshape_table; + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::map> && reshape_table) { + desc.reshape_table = std::move(reshape_table); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::string && layer_name, std::vector && layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(const std::string & layer_name, const std::vector&layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::unordered_set && layer_names) { + desc.layer_names_to_reshape = std::move(layer_names); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(const std::unordered_set&layer_names) { + desc.layer_names_to_reshape = layer_names; + return *this; + } + + /** @see ie::Params::cfgBatchSize */ + Params& cfgBatchSize(const size_t size) { + desc.batch_size = cv::util::make_optional(size); + return *this; + } + + // BEGIN(G-API's network parametrization API) + GBackend backend() const { return cv::gapi::ie::backend(); } + std::string tag() const { return m_tag; } + cv::util::any params() const { return { desc }; } + // END(G-API's network parametrization API) + +protected: + detail::ParamDesc desc; + std::string m_tag; +}; + +} // namespace ie +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_IE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/onnx.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/onnx.hpp new file mode 100644 index 0000000..bb5ef6c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/onnx.hpp @@ -0,0 +1,284 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + +#ifndef OPENCV_GAPI_INFER_ONNX_HPP +#define OPENCV_GAPI_INFER_ONNX_HPP + +#include +#include +#include +#include // tuple, tuple_size + +#include +#include + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { + +/** + * @brief This namespace contains G-API ONNX Runtime backend functions, structures, and symbols. + */ +namespace onnx { + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +enum class TraitAs: int { + TENSOR, //!< G-API traits an associated cv::Mat as a raw tensor + // and passes dimensions as-is + IMAGE //!< G-API traits an associated cv::Mat as an image so + // creates an "image" blob (NCHW/NHWC, etc) +}; + +using PostProc = std::function &, + std::unordered_map &)>; + +namespace detail { +/** +* @brief This structure contains description of inference parameters +* which is specific to ONNX models. +*/ +struct ParamDesc { + std::string model_path; //!< Path to model. + + // NB: nun_* may differ from topology's real input/output port numbers + // (e.g. topology's partial execution) + std::size_t num_in; //!< How many inputs are defined in the operation + std::size_t num_out; //!< How many outputs are defined in the operation + + // NB: Here order follows the `Net` API + std::vector input_names; //!< Names of input network layers. + std::vector output_names; //!< Names of output network layers. + + using ConstInput = std::pair; + std::unordered_map const_inputs; //!< Map with pair of name of network layer and ConstInput which will be associated with this. + + std::vector mean; //!< Mean values for preprocessing. + std::vector stdev; //!< Standard deviation values for preprocessing. + + std::vector out_metas; //!< Out meta information about your output (type, dimension). + PostProc custom_post_proc; //!< Post processing function. + + std::vector normalize; //!< Vector of bool values that enabled or disabled normalize of input data. + + std::vector names_to_remap; //!< Names of output layers that will be processed in PostProc function. +}; +} // namespace detail + +template +struct PortCfg { + using In = std::array + < std::string + , std::tuple_size::value >; + using Out = std::array + < std::string + , std::tuple_size::value >; + using NormCoefs = std::array + < cv::Scalar + , std::tuple_size::value >; + using Normalize = std::array + < bool + , std::tuple_size::value >; +}; + +/** + * Contains description of inference parameters and kit of functions that + * fill this parameters. + */ +template class Params { +public: + /** @brief Class constructor. + + Constructs Params based on model information and sets default values for other + inference description parameters. + + @param model Path to model (.onnx file). + */ + Params(const std::string &model) { + desc.model_path = model; + desc.num_in = std::tuple_size::value; + desc.num_out = std::tuple_size::value; + }; + + /** @brief Specifies sequence of network input layers names for inference. + + The function is used to associate data of graph inputs with input layers of + network topology. Number of names has to match the number of network inputs. If a network + has only one input layer, there is no need to call it as the layer is + associated with input automatically but this doesn't prevent you from + doing it yourself. Count of names has to match to number of network inputs. + + @param layer_names std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains names of input layers. + @return the reference on modified object. + */ + Params& cfgInputLayers(const typename PortCfg::In &layer_names) { + desc.input_names.assign(layer_names.begin(), layer_names.end()); + return *this; + } + + /** @brief Specifies sequence of output layers names for inference. + + The function is used to associate data of graph outputs with output layers of + network topology. If a network has only one output layer, there is no need to call it + as the layer is associated with ouput automatically but this doesn't prevent + you from doing it yourself. Count of names has to match to number of network + outputs or you can set your own output but for this case you have to + additionally use @ref cfgPostProc function. + + @param layer_names std::array where N is the number of outputs + as defined in the @ref G_API_NET. Contains names of output layers. + @return the reference on modified object. + */ + Params& cfgOutputLayers(const typename PortCfg::Out &layer_names) { + desc.output_names.assign(layer_names.begin(), layer_names.end()); + return *this; + } + + /** @brief Sets a constant input. + + The function is used to set constant input. This input has to be + a prepared tensor since preprocessing is disabled for this case. You should + provide name of network layer which will receive provided data. + + @param layer_name Name of network layer. + @param data cv::Mat that contains data which will be associated with network layer. + @param hint Type of input (TENSOR). + @return the reference on modified object. + */ + Params& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR) { + desc.const_inputs[layer_name] = {data, hint}; + return *this; + } + + /** @brief Specifies mean value and standard deviation for preprocessing. + + The function is used to set mean value and standard deviation for preprocessing + of input data. + + @param m std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains mean values. + @param s std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains standard deviation values. + @return the reference on modified object. + */ + Params& cfgMeanStd(const typename PortCfg::NormCoefs &m, + const typename PortCfg::NormCoefs &s) { + desc.mean.assign(m.begin(), m.end()); + desc.stdev.assign(s.begin(), s.end()); + return *this; + } + + /** @brief Configures graph output and provides the post processing function from user. + + The function is used when you work with networks with dynamic outputs. + Since we can't know dimensions of inference result needs provide them for + construction of graph output. This dimensions can differ from inference result. + So you have to provide @ref PostProc function that gets information from inference + result and fill output which is constructed by dimensions from out_metas. + + @param out_metas Out meta information about your output (type, dimension). + @param remap_function Post processing function, which has two parameters. First is onnx + result, second is graph output. Both parameters is std::map that contain pair of + layer's name and cv::Mat. + @return the reference on modified object. + */ + Params& cfgPostProc(const std::vector &out_metas, + const PostProc &remap_function) { + desc.out_metas = out_metas; + desc.custom_post_proc = remap_function; + return *this; + } + + /** @overload + Function with a rvalue parameters. + + @param out_metas rvalue out meta information about your output (type, dimension). + @param remap_function rvalue post processing function, which has two parameters. First is onnx + result, second is graph output. Both parameters is std::map that contain pair of + layer's name and cv::Mat. + @return the reference on modified object. + */ + Params& cfgPostProc(std::vector &&out_metas, + PostProc &&remap_function) { + desc.out_metas = std::move(out_metas); + desc.custom_post_proc = std::move(remap_function); + return *this; + } + + /** @overload + The function has additional parameter names_to_remap. This parameter provides + information about output layers which will be used for inference and post + processing function. + + @param out_metas Out meta information. + @param remap_function Post processing function. + @param names_to_remap Names of output layers. network's inference will + be done on these layers. Inference's result will be processed in post processing + function using these names. + @return the reference on modified object. + */ + Params& cfgPostProc(const std::vector &out_metas, + const PostProc &remap_function, + const std::vector &names_to_remap) { + desc.out_metas = out_metas; + desc.custom_post_proc = remap_function; + desc.names_to_remap = names_to_remap; + return *this; + } + + /** @overload + Function with a rvalue parameters and additional parameter names_to_remap. + + @param out_metas rvalue out meta information. + @param remap_function rvalue post processing function. + @param names_to_remap rvalue names of output layers. network's inference will + be done on these layers. Inference's result will be processed in post processing + function using these names. + @return the reference on modified object. + */ + Params& cfgPostProc(std::vector &&out_metas, + PostProc &&remap_function, + std::vector &&names_to_remap) { + desc.out_metas = std::move(out_metas); + desc.custom_post_proc = std::move(remap_function); + desc.names_to_remap = std::move(names_to_remap); + return *this; + } + + /** @brief Specifies normalize parameter for preprocessing. + + The function is used to set normalize parameter for preprocessing of input data. + + @param normalizations std::array where N is the number of inputs + as defined in the @ref G_API_NET. Сontains bool values that enabled or disabled + normalize of input data. + @return the reference on modified object. + */ + Params& cfgNormalize(const typename PortCfg::Normalize &normalizations) { + desc.normalize.assign(normalizations.begin(), normalizations.end()); + return *this; + } + + // BEGIN(G-API's network parametrization API) + GBackend backend() const { return cv::gapi::onnx::backend(); } + std::string tag() const { return Net::tag(); } + cv::util::any params() const { return { desc }; } + // END(G-API's network parametrization API) + +protected: + detail::ParamDesc desc; +}; + +} // namespace onnx +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/parsers.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/parsers.hpp new file mode 100644 index 0000000..c7308dd --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/infer/parsers.hpp @@ -0,0 +1,138 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_PARSERS_HPP +#define OPENCV_GAPI_PARSERS_HPP + +#include // std::tuple + +#include +#include + +namespace cv { namespace gapi { +namespace nn { +namespace parsers { + using GRects = GArray; + using GDetections = std::tuple, GArray>; + + G_TYPED_KERNEL(GParseSSDBL, , float, int)>, + "org.opencv.nn.parsers.parseSSD_BL") { + static std::tuple outMeta(const GMatDesc&, const GOpaqueDesc&, float, int) { + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GParseSSD, , float, bool, bool)>, + "org.opencv.nn.parsers.parseSSD") { + static GArrayDesc outMeta(const GMatDesc&, const GOpaqueDesc&, float, bool, bool) { + return empty_array_desc(); + } + }; + + G_TYPED_KERNEL(GParseYolo, , float, float, std::vector)>, + "org.opencv.nn.parsers.parseYolo") { + static std::tuple outMeta(const GMatDesc&, const GOpaqueDesc&, + float, float, const std::vector&) { + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + static const std::vector& defaultAnchors() { + static std::vector anchors { + 0.57273f, 0.677385f, 1.87446f, 2.06253f, 3.33843f, 5.47434f, 7.88282f, 3.52778f, 9.77052f, 9.16828f + }; + return anchors; + } + }; +} // namespace parsers +} // namespace nn + +/** @brief Parses output of SSD network. + +Extracts detection information (box, confidence, label) from SSD output and +filters it by given confidence and label. + +@note Function textual ID is "org.opencv.nn.parsers.parseSSD_BL" + +@param in Input CV_32F tensor with {1,1,N,7} dimensions. +@param inSz Size to project detected boxes to (size of the input image). +@param confidenceThreshold If confidence of the +detection is smaller than confidence threshold, detection is rejected. +@param filterLabel If provided (!= -1), only detections with +given label will get to the output. +@return a tuple with a vector of detected boxes and a vector of appropriate labels. +*/ +GAPI_EXPORTS_W std::tuple, GArray> parseSSD(const GMat& in, + const GOpaque& inSz, + const float confidenceThreshold = 0.5f, + const int filterLabel = -1); + +/** @brief Parses output of SSD network. + +Extracts detection information (box, confidence) from SSD output and +filters it by given confidence and by going out of bounds. + +@note Function textual ID is "org.opencv.nn.parsers.parseSSD" + +@param in Input CV_32F tensor with {1,1,N,7} dimensions. +@param inSz Size to project detected boxes to (size of the input image). +@param confidenceThreshold If confidence of the +detection is smaller than confidence threshold, detection is rejected. +@param alignmentToSquare If provided true, bounding boxes are extended to squares. +The center of the rectangle remains unchanged, the side of the square is +the larger side of the rectangle. +@param filterOutOfBounds If provided true, out-of-frame boxes are filtered. +@return a vector of detected bounding boxes. +*/ +GAPI_EXPORTS_W GArray parseSSD(const GMat& in, + const GOpaque& inSz, + const float confidenceThreshold, + const bool alignmentToSquare, + const bool filterOutOfBounds); + +/** @brief Parses output of Yolo network. + +Extracts detection information (box, confidence, label) from Yolo output, +filters it by given confidence and performs non-maximum supression for overlapping boxes. + +@note Function textual ID is "org.opencv.nn.parsers.parseYolo" + +@param in Input CV_32F tensor with {1,13,13,N} dimensions, N should satisfy: +\f[\texttt{N} = (\texttt{num_classes} + \texttt{5}) * \texttt{5},\f] +where num_classes - a number of classes Yolo network was trained with. +@param inSz Size to project detected boxes to (size of the input image). +@param confidenceThreshold If confidence of the +detection is smaller than confidence threshold, detection is rejected. +@param nmsThreshold Non-maximum supression threshold which controls minimum +relative box intersection area required for rejecting the box with a smaller confidence. +If 1.f, nms is not performed and no boxes are rejected. +@param anchors Anchors Yolo network was trained with. +@note The default anchor values are specified for YOLO v2 Tiny as described in Intel Open Model Zoo +documentation. +@return a tuple with a vector of detected boxes and a vector of appropriate labels. +*/ +GAPI_EXPORTS_W std::tuple, GArray> parseYolo(const GMat& in, + const GOpaque& inSz, + const float confidenceThreshold = 0.5f, + const float nmsThreshold = 0.5f, + const std::vector& anchors + = nn::parsers::GParseYolo::defaultAnchors()); + +} // namespace gapi +} // namespace cv + +// Reimport parseSSD & parseYolo under their initial namespace +namespace cv { +namespace gapi { +namespace streaming { + +using cv::gapi::parseSSD; +using cv::gapi::parseYolo; + +} // namespace streaming +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_PARSERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/media.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/media.hpp new file mode 100644 index 0000000..19aaef3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/media.hpp @@ -0,0 +1,257 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_MEDIA_HPP +#define OPENCV_GAPI_MEDIA_HPP + +#include // unique_ptr<>, shared_ptr<> +#include // array<> +#include // function<> +#include // forward<>() + +#include +#include + +// Forward declaration +namespace cv { +namespace gapi { +namespace s11n { +struct IOStream; +struct IIStream; +} // namespace s11n +} // namespace gapi +} // namespace cv + +namespace cv { + +/** \addtogroup gapi_data_structures + * @{ + * + * @brief Extra G-API data structures used to pass input/output data + * to the graph for processing. + */ +/** + * @brief cv::MediaFrame class represents an image/media frame + * obtained from an external source. + * + * cv::MediaFrame represents image data as specified in + * cv::MediaFormat. cv::MediaFrame is designed to be a thin wrapper over some + * external memory of buffer; the class itself provides an uniform + * interface over such types of memory. cv::MediaFrame wraps data from + * a camera driver or from a media codec and provides an abstraction + * layer over this memory to G-API. MediaFrame defines a compact interface + * to access and manage the underlying data; the implementation is + * fully defined by the associated Adapter (which is usually + * user-defined). + * + * @sa cv::RMat + */ +class GAPI_EXPORTS MediaFrame { +public: + /// This enum defines different types of cv::MediaFrame provided + /// access to the underlying data. Note that different flags can't + /// be combined in this version. + enum class Access { + R, ///< Access data for reading + W, ///< Access data for writing + }; + class IAdapter; + class View; + using AdapterPtr = std::unique_ptr; + + /** + * @brief Constructs an empty MediaFrame + * + * The constructed object has no any data associated with it. + */ + MediaFrame(); + + /** + * @brief Constructs a MediaFrame with the given + * Adapter. MediaFrame takes ownership over the passed adapter. + * + * @param p an unique pointer to instance of IAdapter derived class. + */ + explicit MediaFrame(AdapterPtr &&p); + + /** + * @overload + * @brief Constructs a MediaFrame with the given parameters for + * the Adapter. The adapter of type `T` is costructed on the fly. + * + * @param args list of arguments to construct an adapter of type + * `T`. + */ + template static cv::MediaFrame Create(Args&&... args); + + /** + * @brief Obtain access to the underlying data with the given + * mode. + * + * Depending on the associated Adapter and the data wrapped, this + * method may be cheap (e.g., the underlying memory is local) or + * costly (if the underlying memory is external or device + * memory). + * + * @param mode an access mode flag + * @return a MediaFrame::View object. The views should be handled + * carefully, refer to the MediaFrame::View documentation for details. + */ + View access(Access mode) const; + + /** + * @brief Returns a media frame descriptor -- the information + * about the media format, dimensions, etc. + * @return a cv::GFrameDesc + */ + cv::GFrameDesc desc() const; + + // FIXME: design a better solution + // Should be used only if the actual adapter provides implementation + /// @private -- exclude from the OpenCV documentation for now. + cv::util::any blobParams() const; + + /** + * @brief Casts and returns the associated MediaFrame adapter to + * the particular adapter type `T`, returns nullptr if the type is + * different. + * + * This method may be useful if the adapter type is known by the + * caller, and some lower level access to the memory is required. + * Depending on the memory type, it may be more efficient than + * access(). + * + * @return a pointer to the adapter object, nullptr if the adapter + * type is different. + */ + template T* get() const { + static_assert(std::is_base_of::value, + "T is not derived from cv::MediaFrame::IAdapter!"); + auto* adapter = getAdapter(); + GAPI_Assert(adapter != nullptr); + return dynamic_cast(adapter); + } + + /** + * @brief Serialize MediaFrame's data to a byte array. + * + * @note The actual logic is implemented by frame's adapter class. + * Does nothing by default. + * + * @param os Bytestream to store serialized MediaFrame data in. + */ + void serialize(cv::gapi::s11n::IOStream& os) const; + +private: + struct Priv; + std::shared_ptr m; + IAdapter* getAdapter() const; +}; + +template +inline cv::MediaFrame cv::MediaFrame::Create(Args&&... args) { + std::unique_ptr ptr(new T(std::forward(args)...)); + return cv::MediaFrame(std::move(ptr)); +} + +/** + * @brief Provides access to the MediaFrame's underlying data. + * + * This object contains the necessary information to access the pixel + * data of the associated MediaFrame: arrays of pointers and strides + * (distance between every plane row, in bytes) for every image + * plane, as defined in cv::MediaFormat. + * There may be up to four image planes in MediaFrame. + * + * Depending on the MediaFrame::Access flag passed in + * MediaFrame::access(), a MediaFrame::View may be read- or + * write-only. + * + * Depending on the MediaFrame::IAdapter implementation associated + * with the parent MediaFrame, writing to memory with + * MediaFrame::Access::R flag may have no effect or lead to + * undefined behavior. Same applies to reading the memory with + * MediaFrame::Access::W flag -- again, depending on the IAdapter + * implementation, the host-side buffer the view provides access to + * may have no current data stored in (so in-place editing of the + * buffer contents may not be possible). + * + * MediaFrame::View objects must be handled carefully, as an external + * resource associated with MediaFrame may be locked for the time the + * MediaFrame::View object exists. Obtaining MediaFrame::View should + * be seen as "map" and destroying it as "unmap" in the "map/unmap" + * idiom (applicable to OpenCL, device memory, remote + * memory). + * + * When a MediaFrame buffer is accessed for writing, and the memory + * under MediaFrame::View::Ptrs is altered, the data synchronization + * of a host-side and device/remote buffer is not guaranteed until the + * MediaFrame::View is destroyed. In other words, the real data on the + * device or in a remote target may be updated at the MediaFrame::View + * destruction only -- but it depends on the associated + * MediaFrame::IAdapter implementation. + */ +class GAPI_EXPORTS MediaFrame::View final { +public: + static constexpr const size_t MAX_PLANES = 4; + using Ptrs = std::array; + using Strides = std::array; // in bytes + using Callback = std::function; + + /// @private + View(Ptrs&& ptrs, Strides&& strs, Callback &&cb = [](){}); + + /// @private + View(const View&) = delete; + + /// @private + View(View&&) = default; + + /// @private + View& operator = (const View&) = delete; + + ~View(); + + Ptrs ptr; ///< Array of image plane pointers + Strides stride; ///< Array of image plane strides, in bytes. + +private: + Callback m_cb; +}; + +/** + * @brief An interface class for MediaFrame data adapters. + * + * Implement this interface to wrap media data in the MediaFrame. It + * makes sense to implement this class if there is a custom + * cv::gapi::wip::IStreamSource defined -- in this case, a stream + * source can produce MediaFrame objects with this adapter and the + * media data may be passed to graph without any copy. For example, a + * GStreamer-based stream source can implement an adapter over + * `GstBuffer` and G-API will transparently use it in the graph. + */ +class GAPI_EXPORTS MediaFrame::IAdapter { +public: + virtual ~IAdapter() = 0; + virtual cv::GFrameDesc meta() const = 0; + virtual MediaFrame::View access(MediaFrame::Access) = 0; + // FIXME: design a better solution + // The default implementation does nothing + virtual cv::util::any blobParams() const; + virtual void serialize(cv::gapi::s11n::IOStream&) { + GAPI_Assert(false && "Generic serialize method of MediaFrame::IAdapter does nothing by default. " + "Please, implement it in derived class to properly serialize the object."); + } + virtual void deserialize(cv::gapi::s11n::IIStream&) { + GAPI_Assert(false && "Generic deserialize method of MediaFrame::IAdapter does nothing by default. " + "Please, implement it in derived class to properly deserialize the object."); + } +}; +/** @} */ + +} //namespace cv + +#endif // OPENCV_GAPI_MEDIA_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/core.hpp new file mode 100644 index 0000000..6c75870 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/core.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OCL_CORE_API_HPP +#define OPENCV_GAPI_OCL_CORE_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace core { +namespace ocl { + + GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +} // namespace ocl +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_OCL_CORE_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/goclkernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/goclkernel.hpp new file mode 100644 index 0000000..6a2f1df --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/goclkernel.hpp @@ -0,0 +1,249 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GOCLKERNEL_HPP +#define OPENCV_GAPI_GOCLKERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gimpl +{ + // Forward-declare an internal class + class GOCLExecutable; +} // namespace gimpl + +namespace gapi +{ +/** + * @brief This namespace contains G-API OpenCL backend functions, structures, and symbols. + */ +namespace ocl +{ + /** + * \addtogroup gapi_std_backends G-API Standard Backends + * @{ + */ + /** + * @brief Get a reference to OCL backend. + * + * At the moment, the OCL backend is built atop of OpenCV + * "Transparent API" (T-API), see cv::UMat for details. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ +} // namespace ocl +} // namespace gapi + + +// Represents arguments which are passed to a wrapped OCL function +// FIXME: put into detail? +class GAPI_EXPORTS GOCLContext +{ +public: + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const cv::UMat& inMat(int input); + cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR() + + const cv::Scalar& inVal(int input); + cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR() + template std::vector& outVecR(int output) // FIXME: the same issue + { + return outVecRef(output).wref(); + } + template T& outOpaqueR(int output) // FIXME: the same issue + { + return outOpaqueRef(output).wref(); + } + +protected: + detail::VectorRef& outVecRef(int output); + detail::OpaqueRef& outOpaqueRef(int output); + + std::vector m_args; + std::unordered_map m_results; + + + friend class gimpl::GOCLExecutable; +}; + +class GAPI_EXPORTS GOCLKernel +{ +public: + // This function is kernel's execution entry point (does the processing work) + using F = std::function; + + GOCLKernel(); + explicit GOCLKernel(const F& f); + + void apply(GOCLContext &ctx); + +protected: + F m_f; +}; + +// FIXME: This is an ugly ad-hoc implementation. TODO: refactor + +namespace detail +{ +template struct ocl_get_in; +template<> struct ocl_get_in +{ + static cv::UMat get(GOCLContext &ctx, int idx) { return ctx.inMat(idx); } +}; +template<> struct ocl_get_in +{ + static cv::Scalar get(GOCLContext &ctx, int idx) { return ctx.inVal(idx); } +}; +template struct ocl_get_in > +{ + static const std::vector& get(GOCLContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct ocl_get_in > +{ + static const U& get(GOCLContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct ocl_get_in +{ + static T get(GOCLContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +struct tracked_cv_umat{ + //TODO Think if T - API could reallocate UMat to a proper size - how do we handle this ? + //tracked_cv_umat(cv::UMat& m) : r{(m)}, original_data{m.getMat(ACCESS_RW).data} {} + tracked_cv_umat(cv::UMat& m) : r(m), original_data{ nullptr } {} + cv::UMat &r; // FIXME: It was a value (not a reference) before. + // Actually OCL backend should allocate its internal data! + uchar* original_data; + + operator cv::UMat& (){ return r;} + void validate() const{ + //if (r.getMat(ACCESS_RW).data != original_data) + //{ + // util::throw_error + // (std::logic_error + // ("OpenCV kernel output parameter was reallocated. \n" + // "Incorrect meta data was provided ?")); + //} + + } +}; + +template +void postprocess_ocl(Outputs&... outs) +{ + struct + { + void operator()(tracked_cv_umat* bm) { bm->validate(); } + void operator()(...) { } + + } validate; + //dummy array to unfold parameter pack + int dummy[] = { 0, (validate(&outs), 0)... }; + cv::util::suppress_unused_warning(dummy); +} + +template struct ocl_get_out; +template<> struct ocl_get_out +{ + static tracked_cv_umat get(GOCLContext &ctx, int idx) + { + auto& r = ctx.outMatR(idx); + return{ r }; + } +}; +template<> struct ocl_get_out +{ + static cv::Scalar& get(GOCLContext &ctx, int idx) + { + return ctx.outValR(idx); + } +}; +template struct ocl_get_out > +{ + static std::vector& get(GOCLContext &ctx, int idx) { return ctx.outVecR(idx); } +}; +template struct ocl_get_out > +{ + static U& get(GOCLContext &ctx, int idx) { return ctx.outOpaqueR(idx); } +}; + +template +struct OCLCallHelper; + +// FIXME: probably can be simplified with std::apply or analogue. +template +struct OCLCallHelper, std::tuple > +{ + template + struct call_and_postprocess + { + template + static void call(Inputs&&... ins, Outputs&&... outs) + { + //not using a std::forward on outs is deliberate in order to + //cause compilation error, by trying to bind rvalue references to lvalue references + Impl::run(std::forward(ins)..., outs...); + + postprocess_ocl(outs...); + } + }; + + template + static void call_impl(GOCLContext &ctx, detail::Seq, detail::Seq) + { + //TODO: Make sure that OpenCV kernels do not reallocate memory for output parameters + //by comparing it's state (data ptr) before and after the call. + //Convert own::Scalar to cv::Scalar before call kernel and run kernel + //convert cv::Scalar to own::Scalar after call kernel and write back results + call_and_postprocess::get(ctx, IIs))...>::call(ocl_get_in::get(ctx, IIs)..., ocl_get_out::get(ctx, OIs)...); + } + + static void call(GOCLContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GOCLKernelImpl: public cv::detail::OCLCallHelper, + public cv::detail::KernelTag +{ + using P = detail::OCLCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::ocl::backend(); } + static cv::GOCLKernel kernel() { return GOCLKernel(&P::call); } +}; + +#define GAPI_OCL_KERNEL(Name, API) struct Name: public cv::GOCLKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GOCLKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/imgproc.hpp new file mode 100644 index 0000000..1bb5911 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/ocl/imgproc.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OCL_IMGPROC_API_HPP +#define OPENCV_GAPI_OCL_IMGPROC_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace imgproc { +namespace ocl { + + GAPI_EXPORTS GKernelPackage kernels(); + +} // namespace ocl +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_OCL_IMGPROC_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/opencv_includes.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/opencv_includes.hpp new file mode 100644 index 0000000..25a67d6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/opencv_includes.hpp @@ -0,0 +1,41 @@ +// This file is part of OpenCV project. + +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OPENCV_INCLUDES_HPP +#define OPENCV_GAPI_OPENCV_INCLUDES_HPP + +#if !defined(GAPI_STANDALONE) +# include +# include +# include +# include +#define GAPI_OWN_TYPES_LIST cv::gapi::own::Rect, \ + cv::gapi::own::Size, \ + cv::gapi::own::Point, \ + cv::gapi::own::Point2f, \ + cv::gapi::own::Scalar, \ + cv::gapi::own::Mat +#else // Without OpenCV +# include +# include // cv::gapi::own::Rect/Size/Point +# include // cv::gapi::own::Scalar +# include +// replacement of cv's structures: +namespace cv { + using Rect = gapi::own::Rect; + using Size = gapi::own::Size; + using Point = gapi::own::Point; + using Point2f = gapi::own::Point2f; + using Scalar = gapi::own::Scalar; + using Mat = gapi::own::Mat; +} // namespace cv +#define GAPI_OWN_TYPES_LIST cv::gapi::own::VoidType + +#endif // !defined(GAPI_STANDALONE) + +#endif // OPENCV_GAPI_OPENCV_INCLUDES_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/operators.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/operators.hpp new file mode 100644 index 0000000..6794b44 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/operators.hpp @@ -0,0 +1,70 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OPERATORS_HPP +#define OPENCV_GAPI_OPERATORS_HPP + +#include +#include + +namespace cv +{ +GAPI_EXPORTS cv::GMat operator+(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator+(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator+(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator-(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator-(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator-(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator*(const cv::GMat& lhs, float rhs); +GAPI_EXPORTS cv::GMat operator*(float lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator*(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator*(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator/(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator/(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator/(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator&(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator|(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator^(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator~(const cv::GMat& lhs); + +GAPI_EXPORTS cv::GMat operator&(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator|(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator^(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator&(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator|(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator^(const cv::GMat& lhs, const cv::GScalar& rhs); + +GAPI_EXPORTS cv::GMat operator>(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator>=(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<=(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator==(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator!=(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator>(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator>=(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator<(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator<=(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator==(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator!=(const cv::GMat& lhs, const cv::GScalar& rhs); + +GAPI_EXPORTS cv::GMat operator>(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator>=(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<=(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator==(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator!=(const cv::GScalar& lhs, const cv::GMat& rhs); +} // cv + +#endif // OPENCV_GAPI_OPERATORS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/assert.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/assert.hpp new file mode 100644 index 0000000..d50543f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/assert.hpp @@ -0,0 +1,55 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_ASSERT_HPP +#define OPENCV_GAPI_OWN_ASSERT_HPP + +#include + +#define GAPI_DbgAssertNoOp(expr) { \ + constexpr bool _assert_tmp = false && (expr); \ + cv::util::suppress_unused_warning(_assert_tmp); \ +} + +#if !defined(GAPI_STANDALONE) +#include +#define GAPI_Assert CV_Assert + +#if defined _DEBUG || defined CV_STATIC_ANALYSIS +# define GAPI_DbgAssert CV_DbgAssert +#else +# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr) +#endif + +#else +#include +#include +#include + +namespace detail +{ + [[noreturn]] inline void assert_abort(const char* str, int line, const char* file, const char* func) + { + std::stringstream ss; + ss << file << ":" << line << ": Assertion " << str << " in function " << func << " failed\n"; + cv::util::throw_error(std::logic_error(ss.str())); + } +} + +#define GAPI_Assert(expr) \ +{ if (!(expr)) ::detail::assert_abort(#expr, __LINE__, __FILE__, __func__); } + + +#ifdef NDEBUG +# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr) +#else +# define GAPI_DbgAssert(expr) GAPI_Assert(expr) +#endif + +#endif // GAPI_STANDALONE + +#endif // OPENCV_GAPI_OWN_ASSERT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/convert.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/convert.hpp new file mode 100644 index 0000000..1a8ecd8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/convert.hpp @@ -0,0 +1,55 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_CONVERT_HPP +#define OPENCV_GAPI_OWN_CONVERT_HPP + +#if !defined(GAPI_STANDALONE) + +#include +#include + +namespace cv +{ + template + std::vector to_own(const cv::MatSize &sz) { + std::vector result(sz.dims()); + for (int i = 0; i < sz.dims(); i++) { + // Note: cv::MatSize is not iterable + result[i] = static_cast(sz[i]); + } + return result; + } + + cv::gapi::own::Mat to_own(Mat&&) = delete; + + inline cv::gapi::own::Mat to_own(Mat const& m) { + return (m.dims == 2) + ? cv::gapi::own::Mat{m.rows, m.cols, m.type(), m.data, m.step} + : cv::gapi::own::Mat{to_own(m.size), m.type(), m.data}; + }; + +namespace gapi +{ +namespace own +{ + + inline cv::Mat to_ocv(Mat const& m) { + return m.dims.empty() + ? cv::Mat{m.rows, m.cols, m.type(), m.data, m.step} + : cv::Mat{m.dims, m.type(), m.data}; + } + + cv::Mat to_ocv(Mat&&) = delete; + +} // namespace own +} // namespace gapi +} // namespace cv + +#endif // !defined(GAPI_STANDALONE) + +#endif // OPENCV_GAPI_OWN_CONVERT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/cvdefs.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/cvdefs.hpp new file mode 100644 index 0000000..d3bef98 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/cvdefs.hpp @@ -0,0 +1,166 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_CV_DEFS_HPP +#define OPENCV_GAPI_CV_DEFS_HPP + +#if defined(GAPI_STANDALONE) +// Simulate OpenCV definitions taken from various +// OpenCV interface headers if G-API is built in a +// standalone mode. + +// interface.h: + +typedef unsigned char uchar; +typedef char schar; + +typedef unsigned short ushort; + +#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" + +#define CV_CN_MAX 512 +#define CV_CN_SHIFT 3 +#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) + +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 +#define CV_16F 7 + +#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) +#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) + +#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKE_TYPE CV_MAKETYPE + +#define CV_8UC1 CV_MAKETYPE(CV_8U,1) +#define CV_8UC2 CV_MAKETYPE(CV_8U,2) +#define CV_8UC3 CV_MAKETYPE(CV_8U,3) +#define CV_8UC4 CV_MAKETYPE(CV_8U,4) +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) + +#define CV_8SC1 CV_MAKETYPE(CV_8S,1) +#define CV_8SC2 CV_MAKETYPE(CV_8S,2) +#define CV_8SC3 CV_MAKETYPE(CV_8S,3) +#define CV_8SC4 CV_MAKETYPE(CV_8S,4) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) + +#define CV_16UC1 CV_MAKETYPE(CV_16U,1) +#define CV_16UC2 CV_MAKETYPE(CV_16U,2) +#define CV_16UC3 CV_MAKETYPE(CV_16U,3) +#define CV_16UC4 CV_MAKETYPE(CV_16U,4) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) + +#define CV_16SC1 CV_MAKETYPE(CV_16S,1) +#define CV_16SC2 CV_MAKETYPE(CV_16S,2) +#define CV_16SC3 CV_MAKETYPE(CV_16S,3) +#define CV_16SC4 CV_MAKETYPE(CV_16S,4) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_32SC1 CV_MAKETYPE(CV_32S,1) +#define CV_32SC2 CV_MAKETYPE(CV_32S,2) +#define CV_32SC3 CV_MAKETYPE(CV_32S,3) +#define CV_32SC4 CV_MAKETYPE(CV_32S,4) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) + +#define CV_16FC1 CV_MAKETYPE(CV_16F,1) +#define CV_16FC2 CV_MAKETYPE(CV_16F,2) +#define CV_16FC3 CV_MAKETYPE(CV_16F,3) +#define CV_16FC4 CV_MAKETYPE(CV_16F,4) +#define CV_16FC(n) CV_MAKETYPE(CV_16F,(n)) + +#define CV_32FC1 CV_MAKETYPE(CV_32F,1) +#define CV_32FC2 CV_MAKETYPE(CV_32F,2) +#define CV_32FC3 CV_MAKETYPE(CV_32F,3) +#define CV_32FC4 CV_MAKETYPE(CV_32F,4) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) + +#define CV_64FC1 CV_MAKETYPE(CV_64F,1) +#define CV_64FC2 CV_MAKETYPE(CV_64F,2) +#define CV_64FC3 CV_MAKETYPE(CV_64F,3) +#define CV_64FC4 CV_MAKETYPE(CV_64F,4) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + +// cvdef.h: + +#ifndef CV_ALWAYS_INLINE +# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +# define CV_ALWAYS_INLINE inline __attribute__((always_inline)) +# elif defined(_MSC_VER) +# define CV_ALWAYS_INLINE __forceinline +# else +# define CV_ALWAYS_INLINE inline +# endif +#endif + +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_CONT_FLAG_SHIFT 14 +#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) +#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) +#define CV_IS_CONT_MAT CV_IS_MAT_CONT +#define CV_SUBMAT_FLAG_SHIFT 15 +#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT) +#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG) + +//** Size of each channel item, +// 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ +#define CV_ELEM_SIZE1(type) \ + ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15) + +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) + +/** 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */ +#define CV_ELEM_SIZE(type) \ + (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)) + +#ifndef CV_OVERRIDE +# define CV_OVERRIDE override +#endif + +// base.h: +namespace cv +{ +enum BorderTypes { + BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i` + BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh` + BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb` + BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg` + BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba` + BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno` + + BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_ISOLATED = 16 //!< do not look outside of ROI +}; +// imgproc.hpp: +enum InterpolationFlags{ + INTER_NEAREST = 0, + INTER_LINEAR = 1, + INTER_CUBIC = 2, + INTER_AREA = 3, + INTER_LANCZOS4 = 4, + INTER_LINEAR_EXACT = 5, + INTER_MAX = 7, +}; +} // namespace cv + +static inline int cvFloor( double value ) +{ + int i = (int)value; + return i - (i > value); +} + +#endif // defined(GAPI_STANDALONE) + +#endif // OPENCV_GAPI_CV_DEFS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/exports.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/exports.hpp new file mode 100644 index 0000000..c36f400 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/exports.hpp @@ -0,0 +1,42 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_TYPES_HPP +#define OPENCV_GAPI_OWN_TYPES_HPP + +# if defined(__OPENCV_BUILD) +# include +# define GAPI_EXPORTS CV_EXPORTS + /* special informative macros for wrapper generators */ +# define GAPI_PROP CV_PROP +# define GAPI_PROP_RW CV_PROP_RW +# define GAPI_WRAP CV_WRAP +# define GAPI_EXPORTS_W_SIMPLE CV_EXPORTS_W_SIMPLE +# define GAPI_EXPORTS_W CV_EXPORTS_W +# else +# define GAPI_PROP +# define GAPI_PROP_RW +# define GAPI_WRAP +# define GAPI_EXPORTS +# define GAPI_EXPORTS_W_SIMPLE +# define GAPI_EXPORTS_W + +#if 0 // Note: the following version currently is not needed for non-OpenCV build +# if defined _WIN32 +# define GAPI_EXPORTS __declspec(dllexport) +# elif defined __GNUC__ && __GNUC__ >= 4 +# define GAPI_EXPORTS __attribute__ ((visibility ("default"))) +# endif + +# ifndef GAPI_EXPORTS +# define GAPI_EXPORTS +# endif +#endif + +# endif + +#endif // OPENCV_GAPI_OWN_TYPES_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/mat.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/mat.hpp new file mode 100644 index 0000000..ce9c0bf --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/mat.hpp @@ -0,0 +1,354 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_MAT_HPP +#define OPENCV_GAPI_OWN_MAT_HPP + +#include +#include +#include +#include +#include + +#include //std::shared_ptr +#include //std::memcpy +#include //std::accumulate +#include +#include + +namespace cv { namespace gapi { namespace own { + namespace detail { + template + void assign_row(void* ptr, int cols, Scalar const& s) + { + auto p = static_cast(ptr); + for (int c = 0; c < cols; c++) + { + for (int ch = 0; ch < channels; ch++) + { + p[c * channels + ch] = saturate(s[ch], roundd); + } + } + } + + inline size_t default_step(int type, int cols) + { + return CV_ELEM_SIZE(type) * cols; + } + //Matrix header, i.e. fields that are unique to each Mat object. + //Devoted class is needed to implement custom behavior on move (erasing state of moved from object) + struct MatHeader{ + enum { AUTO_STEP = 0}; + enum { TYPE_MASK = 0x00000FFF }; + + MatHeader() = default; + + MatHeader(int _rows, int _cols, int type, void* _data, size_t _step) + : flags((type & TYPE_MASK)), rows(_rows), cols(_cols), data((uchar*)_data), step(_step == AUTO_STEP ? detail::default_step(type, _cols) : _step) + {} + + MatHeader(const std::vector &_dims, int type, void* _data) + : flags((type & TYPE_MASK)), data((uchar*)_data), step(0), dims(_dims) + {} + + MatHeader(const MatHeader& ) = default; + MatHeader(MatHeader&& src) : MatHeader(src) // reuse copy constructor here + { + MatHeader empty; //give it a name to call copy(not move) assignment below + src = empty; + } + MatHeader& operator=(const MatHeader& ) = default; + MatHeader& operator=(MatHeader&& src) + { + *this = src; //calling a copy assignment here, not move one + MatHeader empty; //give it a name to call copy(not move) assignment below + src = empty; + return *this; + } + /*! includes several bit-fields: + - depth + - number of channels + */ + int flags = 0; + + //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + int rows = 0, cols = 0; + //! pointer to the data + uchar* data = nullptr; + size_t step = 0; + //! dimensions (ND-case) + std::vector dims; + }; + } // namespace detail + //concise version of cv::Mat suitable for GAPI needs (used when no dependence on OpenCV is required) + class Mat : public detail::MatHeader{ + public: + + Mat() = default; + + /** @overload + @param _rows Number of rows in a 2D array. + @param _cols Number of columns in a 2D array. + @param _type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param _data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param _step Number of bytes each matrix row occupies. The value should include the padding bytes at + the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + */ + Mat(int _rows, int _cols, int _type, void* _data, size_t _step = AUTO_STEP) + : MatHeader (_rows, _cols, _type, _data, _step) + {} + + Mat(const std::vector &_dims, int _type, void* _data) + : MatHeader (_dims, _type, _data) + {} + + Mat(std::vector &&_dims, int _type, void* _data) + : MatHeader (std::move(_dims), _type, _data) + {} + + Mat(Mat const& src, const Rect& roi ) + : Mat(src) + { + rows = roi.height; + cols = roi.width; + data = ptr(roi.y, roi.x); + } + + Mat(Mat const& ) = default; + Mat(Mat&& ) = default; + + Mat& operator=(Mat const& ) = default; + Mat& operator=(Mat&& ) = default; + + /** @brief Sets all or some of the array elements to the specified value. + @param s Assigned scalar converted to the actual array type. + */ + Mat& operator = (const Scalar& s) + { + constexpr unsigned max_channels = 4; //Scalar can't fit more than 4 + using func_p_t = void (*)(void*, int, Scalar const&); + using detail::assign_row; + #define TABLE_ENTRY(type) {assign_row, assign_row, assign_row, assign_row} + static constexpr func_p_t func_tbl[][max_channels] = { + TABLE_ENTRY(uchar), + TABLE_ENTRY(schar), + TABLE_ENTRY(ushort), + TABLE_ENTRY(short), + TABLE_ENTRY(int), + TABLE_ENTRY(float), + TABLE_ENTRY(double) + }; + #undef TABLE_ENTRY + + static_assert(CV_8U == 0 && CV_8S == 1 && CV_16U == 2 && CV_16S == 3 + && CV_32S == 4 && CV_32F == 5 && CV_64F == 6, + "OCV type ids used as indexes to array, thus exact numbers are important!" + ); + + const auto depth = static_cast(this->depth()); + GAPI_Assert(depth < sizeof(func_tbl)/sizeof(func_tbl[0])); + + if (dims.empty()) + { + const auto channels = static_cast(this->channels()); + GAPI_Assert(channels <= max_channels); + + auto* f = func_tbl[depth][channels - 1]; + for (int r = 0; r < rows; ++r) + { + (*f)(static_cast(ptr(r)), cols, s ); + } + } + else + { + auto* f = func_tbl[depth][0]; + // FIXME: better to refactor assign_row to use std::size_t by default + (*f)(static_cast(data), static_cast(total()), s); + } + return *this; + } + + /** @brief Returns the matrix element size in bytes. + + The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , + the method returns 3\*sizeof(short) or 6. + */ + size_t elemSize() const + { + return CV_ELEM_SIZE(type()); + } + /** @brief Returns the type of a matrix element. + + The method returns a matrix element type. This is an identifier compatible with the CvMat type + system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. + */ + int type() const {return CV_MAT_TYPE(flags);} + + /** @brief Returns the depth of a matrix element. + + The method returns the identifier of the matrix element depth (the type of each individual channel). + For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of + matrix types contains the following values: + - CV_8U - 8-bit unsigned integers ( 0..255 ) + - CV_8S - 8-bit signed integers ( -128..127 ) + - CV_16U - 16-bit unsigned integers ( 0..65535 ) + - CV_16S - 16-bit signed integers ( -32768..32767 ) + - CV_32S - 32-bit signed integers ( -2147483648..2147483647 ) + - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) + - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) + */ + int depth() const {return CV_MAT_DEPTH(flags);} + + /** @brief Returns the number of matrix channels. + + The method returns the number of matrix channels. + If matrix is N-dimensional, -1 is returned. + */ + int channels() const {return dims.empty() ? CV_MAT_CN(flags) : -1;} + + /** + @param _rows New number of rows. + @param _cols New number of columns. + @param _type New matrix type. + */ + void create(int _rows, int _cols, int _type) + { + create(Size{_cols, _rows}, _type); + } + /** @overload + @param _size Alternative new matrix size specification: Size(cols, rows) + @param _type New matrix type. + */ + void create(Size _size, int _type) + { + GAPI_Assert(_size.height >= 0 && _size.width >= 0); + if (_size != Size{cols, rows} ) + { + Mat tmp{_size.height, _size.width, _type, nullptr}; + tmp.memory.reset(new uchar[ tmp.step * tmp.rows], [](uchar * p){delete[] p;}); + tmp.data = tmp.memory.get(); + + *this = std::move(tmp); + } + } + + void create(const std::vector &_dims, int _type) + { + // FIXME: make a proper reallocation-on-demands + // WARNING: no tensor views, so no strides + Mat tmp{_dims, _type, nullptr}; + // FIXME: this accumulate duplicates a lot + const auto sz = std::accumulate(_dims.begin(), _dims.end(), 1, std::multiplies()); + tmp.memory.reset(new uchar[CV_ELEM_SIZE(_type)*sz], [](uchar * p){delete[] p;}); + tmp.data = tmp.memory.get(); + *this = std::move(tmp); + } + + /** @brief Creates a full copy of the matrix and the underlying data. + + The method creates a full copy of the matrix. The original step[] is not taken into account. + So, the copy has a continuous buffer occupying total() * elemSize() bytes. + */ + Mat clone() const + { + Mat m; + copyTo(m); + return m; + } + + /** @brief Copies the matrix to another one. + + The method copies the matrix data to another matrix. Before copying the data, the method invokes : + @code + m.create(this->size(), this->type()); + @endcode + so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the + function does not handle the case of a partial overlap between the source and the destination + matrices. + */ + void copyTo(Mat& dst) const + { + if (dims.empty()) + { + dst.create(rows, cols, type()); + for (int r = 0; r < rows; ++r) + { + std::copy_n(ptr(r), detail::default_step(type(),cols), dst.ptr(r)); + } + } + else + { + dst.create(dims, depth()); + std::copy_n(data, total()*elemSize(), data); + } + } + + /** @brief Returns true if the array has no elements. + + The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and + resize() methods `M.total() == 0` does not imply that `M.data == NULL`. + */ + bool empty() const + { + return data == 0 || total() == 0; + } + + /** @brief Returns the total number of array elements. + + The method returns the number of array elements (a number of pixels if the array represents an + image). + */ + size_t total() const + { + return dims.empty() + ? (static_cast(rows) * cols) + : std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies()); + } + + /** @overload + @param roi Extracted submatrix specified as a rectangle. + */ + Mat operator()( const Rect& roi ) const + { + return Mat{*this, roi}; + } + + + /** @brief Returns a pointer to the specified matrix row. + + The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + Mat::isContinuous to know how to use these methods. + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + uchar* ptr(int row, int col = 0) + { + return const_cast(const_cast(this)->ptr(row,col)); + } + /** @overload */ + const uchar* ptr(int row, int col = 0) const + { + return data + step * row + CV_ELEM_SIZE(type()) * col; + } + + + private: + //actual memory allocated for storage, or nullptr if object is non owning view to over memory + std::shared_ptr memory; + }; + +} //namespace own +} //namespace gapi +} //namespace cv + +#endif /* OPENCV_GAPI_OWN_MAT_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/saturate.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/saturate.hpp new file mode 100644 index 0000000..74eaecf --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/saturate.hpp @@ -0,0 +1,83 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_SATURATE_HPP +#define OPENCV_GAPI_OWN_SATURATE_HPP + +#include + +#include + +#include +#include + +namespace cv { namespace gapi { namespace own { +//----------------------------- +// +// Numeric cast with saturation +// +//----------------------------- + +template::value && + std::is_integral::value && + std::is_integral::value> > +static CV_ALWAYS_INLINE DST saturate(SRC x) +{ + if (sizeof(DST) > sizeof(SRC)) + return static_cast(x); + + // compiler must recognize this saturation, + // so compile saturate(a + b) with adds + // instruction (e.g.: _mm_adds_epi16 if x86) + return x < std::numeric_limits::min()? + std::numeric_limits::min(): + x > std::numeric_limits::max()? + std::numeric_limits::max(): + static_cast(x); +} +template +static CV_ALWAYS_INLINE T saturate(T x) +{ + return x; +} + +template::value, bool> = true > +static CV_ALWAYS_INLINE DST saturate(SRC x, R) +{ + return static_cast(x); +} +template::value && + std::is_integral::value , bool> = true > +static CV_ALWAYS_INLINE DST saturate(SRC x, R) +{ + return saturate(x); +} +// Note, that OpenCV rounds differently: +// - like std::round() for add, subtract +// - like std::rint() for multiply, divide +template::value && + std::is_floating_point::value, bool> = true > +static CV_ALWAYS_INLINE DST saturate(SRC x, R round) +{ + int ix = static_cast(round(x)); + return saturate(ix); +} + +// explicit suffix 'd' for double type +inline double ceild(double x) { return ceil(x); } +inline double floord(double x) { return floor(x); } +inline double roundd(double x) { return round(x); } +inline double rintd(double x) { return rint(x); } + +} //namespace own +} //namespace gapi +} //namespace cv +#endif /* OPENCV_GAPI_OWN_SATURATE_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/scalar.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/scalar.hpp new file mode 100644 index 0000000..bda91c8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/scalar.hpp @@ -0,0 +1,47 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GAPI_OWN_SCALAR_HPP +#define OPENCV_GAPI_GAPI_OWN_SCALAR_HPP + +#include + +namespace cv +{ +namespace gapi +{ +namespace own +{ + +class GAPI_EXPORTS Scalar +{ +public: + Scalar() = default; + explicit Scalar(double v0) { val[0] = v0; }; + Scalar(double v0, double v1, double v2 = 0, double v3 = 0) + : val{v0, v1, v2, v3} + { + } + + const double& operator[](int i) const { return val[i]; } + double& operator[](int i) { return val[i]; } + + static Scalar all(double v0) { return Scalar(v0, v0, v0, v0); } + + double val[4] = {0}; +}; + +inline bool operator==(const Scalar& lhs, const Scalar& rhs) +{ + return std::equal(std::begin(lhs.val), std::end(lhs.val), std::begin(rhs.val)); +} + +} // namespace own +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GAPI_OWN_SCALAR_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/types.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/types.hpp new file mode 100644 index 0000000..3814366 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/own/types.hpp @@ -0,0 +1,151 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_TYPES_HPP +#define OPENCV_GAPI_TYPES_HPP + +#include // std::max, std::min +#include + +namespace cv +{ +namespace gapi +{ + +/** + * @brief This namespace contains G-API own data structures used in + * its standalone mode build. + */ +namespace own +{ + +class Point +{ +public: + Point() = default; + Point(int _x, int _y) : x(_x), y(_y) {} + + int x = 0; + int y = 0; +}; + +class Point2f +{ +public: + Point2f() = default; + Point2f(float _x, float _y) : x(_x), y(_y) {} + + float x = 0.f; + float y = 0.f; +}; + +class Rect +{ +public: + Rect() = default; + Rect(int _x, int _y, int _width, int _height) : x(_x), y(_y), width(_width), height(_height) {} +#if !defined(GAPI_STANDALONE) + Rect(const cv::Rect& other) : x(other.x), y(other.y), width(other.width), height(other.height) {} + inline Rect& operator=(const cv::Rect& other) + { + x = other.x; + y = other.x; + width = other.width; + height = other.height; + return *this; + } +#endif // !defined(GAPI_STANDALONE) + + int x = 0; //!< x coordinate of the top-left corner + int y = 0; //!< y coordinate of the top-left corner + int width = 0; //!< width of the rectangle + int height = 0; //!< height of the rectangle +}; + +inline bool operator==(const Rect& lhs, const Rect& rhs) +{ + return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height; +} + +inline bool operator!=(const Rect& lhs, const Rect& rhs) +{ + return !(lhs == rhs); +} + +inline Rect& operator&=(Rect& lhs, const Rect& rhs) +{ + int x1 = std::max(lhs.x, rhs.x); + int y1 = std::max(lhs.y, rhs.y); + lhs.width = std::min(lhs.x + lhs.width, rhs.x + rhs.width) - x1; + lhs.height = std::min(lhs.y + lhs.height, rhs.y + rhs.height) - y1; + lhs.x = x1; + lhs.y = y1; + if( lhs.width <= 0 || lhs.height <= 0 ) + lhs = Rect(); + return lhs; +} + +inline const Rect operator&(const Rect& lhs, const Rect& rhs) +{ + Rect result = lhs; + return result &= rhs; +} + +inline std::ostream& operator<<(std::ostream& o, const Rect& rect) +{ + return o << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]"; +} + +class Size +{ +public: + Size() = default; + Size(int _width, int _height) : width(_width), height(_height) {} +#if !defined(GAPI_STANDALONE) + Size(const cv::Size& other) : width(other.width), height(other.height) {} + inline Size& operator=(const cv::Size& rhs) + { + width = rhs.width; + height = rhs.height; + return *this; + } +#endif // !defined(GAPI_STANDALONE) + + int width = 0; + int height = 0; +}; + +inline Size& operator+=(Size& lhs, const Size& rhs) +{ + lhs.width += rhs.width; + lhs.height += rhs.height; + return lhs; +} + +inline bool operator==(const Size& lhs, const Size& rhs) +{ + return lhs.width == rhs.width && lhs.height == rhs.height; +} + +inline bool operator!=(const Size& lhs, const Size& rhs) +{ + return !(lhs == rhs); +} + + +inline std::ostream& operator<<(std::ostream& o, const Size& s) +{ + o << "[" << s.width << " x " << s.height << "]"; + return o; +} + +struct VoidType {}; +} // namespace own +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_TYPES_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/core.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/core.hpp new file mode 100644 index 0000000..3c63fed --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/core.hpp @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + + +#ifndef OPENCV_GAPI_PLAIDML_CORE_HPP +#define OPENCV_GAPI_PLAIDML_CORE_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { namespace gapi { namespace core { namespace plaidml { + +GAPI_EXPORTS cv::gapi::GKernelPackage kernels(); + +}}}} + +#endif // OPENCV_GAPI_PLAIDML_CORE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/gplaidmlkernel.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/gplaidmlkernel.hpp new file mode 100644 index 0000000..e22ecc7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/gplaidmlkernel.hpp @@ -0,0 +1,140 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation +// + + +#ifndef OPENCV_GAPI_GPLAIDMLKERNEL_HPP +#define OPENCV_GAPI_GPLAIDMLKERNEL_HPP + +#include +#include + +namespace plaidml +{ +namespace edsl +{ + class Tensor; +} // namespace edsl +} // namespace plaidml + +namespace cv +{ +namespace gapi +{ +namespace plaidml +{ + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +} // namespace plaidml +} // namespace gapi + +struct GPlaidMLContext +{ + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const plaidml::edsl::Tensor& inTensor(int input) + { + return inArg(input); + } + + plaidml::edsl::Tensor& outTensor(int output) + { + return *(m_results.at(output).get()); + } + + std::vector m_args; + std::unordered_map m_results; +}; + +class GAPI_EXPORTS GPlaidMLKernel +{ +public: + using F = std::function; + + GPlaidMLKernel() = default; + explicit GPlaidMLKernel(const F& f) : m_f(f) {} + + void apply(GPlaidMLContext &ctx) const + { + GAPI_Assert(m_f); + m_f(ctx); + } + +protected: + F m_f; +}; + + +namespace detail +{ + +template struct plaidml_get_in; +template<> struct plaidml_get_in +{ + static const plaidml::edsl::Tensor& get(GPlaidMLContext& ctx, int idx) + { + return ctx.inTensor(idx); + } +}; + +template struct plaidml_get_in +{ + static T get(GPlaidMLContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +template struct plaidml_get_out; +template<> struct plaidml_get_out +{ + static plaidml::edsl::Tensor& get(GPlaidMLContext& ctx, int idx) + { + return ctx.outTensor(idx); + } +}; + +template +struct PlaidMLCallHelper; + +template +struct PlaidMLCallHelper, std::tuple > +{ + template + static void call_impl(GPlaidMLContext &ctx, detail::Seq, detail::Seq) + { + Impl::run(plaidml_get_in::get(ctx, IIs)..., plaidml_get_out::get(ctx, OIs)...); + } + + static void call(GPlaidMLContext& ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GPlaidMLKernelImpl: public cv::detail::PlaidMLCallHelper, + public cv::detail::KernelTag +{ + using P = detail::PlaidMLCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::plaidml::backend(); } + static cv::GPlaidMLKernel kernel() { return GPlaidMLKernel(&P::call); } +}; + +#define GAPI_PLAIDML_KERNEL(Name, API) struct Name: public cv::GPlaidMLKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GPLAIDMLKERNEL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/plaidml.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/plaidml.hpp new file mode 100644 index 0000000..3207a8c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/plaidml/plaidml.hpp @@ -0,0 +1,53 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + + +#ifndef OPENCV_GAPI_PLAIDML_PLAIDML_HPP +#define OPENCV_GAPI_PLAIDML_PLAIDML_HPP + +#include +#include // CompileArgTag + +namespace cv +{ +namespace gapi +{ + +/** + * @brief This namespace contains G-API PlaidML backend functions, + * structures, and symbols. + */ +namespace plaidml +{ + +/** \addtogroup gapi_compile_args + * @{ + */ +/** + * @brief This structure represents the basic parameters for the experimental + * PlaidML backend. + */ +struct config +{ + std::string dev_id; //!< Device ID. Refer to PlaidML documentation for details. + std::string trg_id; //!< Target ID. Refer to PlaidML documentation for details. +}; +/** @} gapi_compile_args */ + +} // namespace plaidml +} // namespace gapi + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.plaidml.config"; } + }; +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_PLAIDML_PLAIDML_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/python/python.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/python/python.hpp new file mode 100644 index 0000000..0e20bbb --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/python/python.hpp @@ -0,0 +1,67 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + + +#ifndef OPENCV_GAPI_PYTHON_API_HPP +#define OPENCV_GAPI_PYTHON_API_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { +namespace gapi { + +/** + * @brief This namespace contains G-API Python backend functions, + * structures, and symbols. + * + * This functionality is required to enable G-API custom operations + * and kernels when using G-API from Python, no need to use it in the + * C++ form. + */ +namespace python { + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +struct GPythonContext +{ + const cv::GArgs &ins; + const cv::GMetaArgs &in_metas; + const cv::GTypesInfo &out_info; +}; + +using Impl = std::function; + +class GAPI_EXPORTS GPythonKernel +{ +public: + GPythonKernel() = default; + GPythonKernel(Impl run); + + cv::GRunArgs operator()(const GPythonContext& ctx); +private: + Impl m_run; +}; + +class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor +{ +public: + using Meta = cv::GKernel::M; + + GPythonFunctor(const char* id, const Meta &meta, const Impl& impl); + + GKernelImpl impl() const override; + gapi::GBackend backend() const override; + +private: + GKernelImpl impl_; +}; + +} // namespace python +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_PYTHON_API_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/render.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/render.hpp new file mode 100644 index 0000000..52e55b0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/render.hpp @@ -0,0 +1,14 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_RENDER_ROOT_HPP +#define OPENCV_GAPI_RENDER_ROOT_HPP + +// This file is just a shortcut to render/render.hpp + +#include + +#endif // OPENCV_GAPI_RENDER_ROOT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/render/render.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/render/render.hpp new file mode 100644 index 0000000..5375412 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/render/render.hpp @@ -0,0 +1,196 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_RENDER_HPP +#define OPENCV_GAPI_RENDER_HPP + +#include + +#include + +/** \defgroup gapi_draw G-API Drawing and composition functionality + * @{ + * + * @brief Functions for in-graph drawing. + * + * @note This is a Work in Progress functionality and APIs may + * change in the future releases. + * + * G-API can do some in-graph drawing with a generic operations and a + * set of [rendering primitives](@ref gapi_draw_prims). + * In contrast with traditional OpenCV, in G-API user need to form a + * *rendering list* of primitives to draw. This list can be built + * manually or generated within a graph. This list is passed to + * [special operations or functions](@ref gapi_draw_api) where all + * primitives are interpreted and applied to the image. + * + * For example, in a complex pipeline a list of detected objects + * can be translated in-graph to a list of cv::gapi::wip::draw::Rect + * primitives to highlight those with bounding boxes, or a list of + * detected faces can be translated in-graph to a list of + * cv::gapi::wip::draw::Mosaic primitives to hide sensitive content + * or protect privacy. + * + * Like any other operations, rendering in G-API can be reimplemented + * by different backends. Currently only an OpenCV-based backend is + * available. + * + * In addition to the graph-level operations, there are also regular + * (immediate) OpenCV-like functions are available -- see + * cv::gapi::wip::draw::render(). These functions are just wrappers + * over regular G-API and build the rendering graphs on the fly, so + * take compilation arguments as parameters. + * + * Currently this API is more machine-oriented than human-oriented. + * The main purpose is to translate a set of domain-specific objects + * to a list of primitives to draw. For example, in order to generate + * a picture like this: + * + * ![](modules/gapi/doc/pics/render_example.png) + * + * Rendering list needs to be generated as follows: + * + * @include modules/gapi/samples/draw_example.cpp + * + * @defgroup gapi_draw_prims Drawing primitives + * @defgroup gapi_draw_api Drawing operations and functions + * @} + */ + +namespace cv +{ +namespace gapi +{ +namespace wip +{ +namespace draw +{ + +using GMat2 = std::tuple; +using GMatDesc2 = std::tuple; + +//! @addtogroup gapi_draw_api +//! @{ +/** @brief The function renders on the input image passed drawing primitivies + +@param bgr input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@param prims vector of drawing primitivies +@param args graph compile time parameters +*/ +void GAPI_EXPORTS_W render(cv::Mat& bgr, + const Prims& prims, + cv::GCompileArgs&& args = {}); + +/** @brief The function renders on two NV12 planes passed drawing primitivies + +@param y_plane input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param uv_plane input image: 8-bit unsigned 2-channel image @ref CV_8UC2. +@param prims vector of drawing primitivies +@param args graph compile time parameters +*/ +void GAPI_EXPORTS_W render(cv::Mat& y_plane, + cv::Mat& uv_plane, + const Prims& prims, + cv::GCompileArgs&& args = {}); + +/** @brief The function renders on the input media frame passed drawing primitivies + +@param frame input Media Frame : @ref cv::MediaFrame. +@param prims vector of drawing primitivies +@param args graph compile time parameters +*/ +void GAPI_EXPORTS render(cv::MediaFrame& frame, + const Prims& prims, + cv::GCompileArgs&& args = {}); + + +G_TYPED_KERNEL_M(GRenderNV12, )>, "org.opencv.render.nv12") +{ + static GMatDesc2 outMeta(GMatDesc y_plane, GMatDesc uv_plane, GArrayDesc) + { + return std::make_tuple(y_plane, uv_plane); + } +}; + +G_TYPED_KERNEL(GRenderBGR, )>, "org.opencv.render.bgr") +{ + static GMatDesc outMeta(GMatDesc bgr, GArrayDesc) + { + return bgr; + } +}; + +G_TYPED_KERNEL(GRenderFrame, )>, "org.opencv.render.frame") +{ + static GFrameDesc outMeta(GFrameDesc desc, GArrayDesc) + { + return desc; + } +}; + +/** @brief Renders on 3 channels input + +Output image must be 8-bit unsigned planar 3-channel image + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3 +@param prims draw primitives +*/ +GAPI_EXPORTS_W GMat render3ch(const GMat& src, const GArray& prims); + +/** @brief Renders on two planes + +Output y image must be 8-bit unsigned planar 1-channel image @ref CV_8UC1 +uv image must be 8-bit unsigned planar 2-channel image @ref CV_8UC2 + +@param y input image: 8-bit unsigned 1-channel image @ref CV_8UC1 +@param uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2 +@param prims draw primitives +*/ +GAPI_EXPORTS_W GMat2 renderNV12(const GMat& y, + const GMat& uv, + const GArray& prims); + +/** @brief Renders Media Frame + +Output media frame frame cv::MediaFrame + +@param m_frame input image: cv::MediaFrame @ref cv::MediaFrame +@param prims draw primitives +*/ +GAPI_EXPORTS GFrame renderFrame(const GFrame& m_frame, + const GArray& prims); + +//! @} gapi_draw_api + +} // namespace draw +} // namespace wip + +/** + * @brief This namespace contains G-API CPU rendering backend functions, + * structures, and symbols. See @ref gapi_draw for details. + */ +namespace render +{ +namespace ocv +{ + GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +} // namespace ocv +} // namespace render +} // namespace gapi + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.freetype_font"; } + }; +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_RENDER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/render/render_types.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/render/render_types.hpp new file mode 100644 index 0000000..6d70e3a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/render/render_types.hpp @@ -0,0 +1,359 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_RENDER_TYPES_HPP +#define OPENCV_GAPI_RENDER_TYPES_HPP + +#include +#include + +#include +#include +#include + +namespace cv +{ +namespace gapi +{ +namespace wip +{ +namespace draw +{ + +/** + * @brief This structure specifies which FreeType font to use by FText primitives. + */ +struct freetype_font +{ + /*@{*/ + std::string path; //!< The path to the font file (.ttf) + /*@{*/ +}; + +//! @addtogroup gapi_draw_prims +//! @{ +/** + * @brief This structure represents a text string to draw. + * + * Parameters match cv::putText(). + */ +struct GAPI_EXPORTS_W_SIMPLE Text +{ + /** + * @brief Text constructor + * + * @param text_ The text string to be drawn + * @param org_ The bottom-left corner of the text string in the image + * @param ff_ The font type, see #HersheyFonts + * @param fs_ The font scale factor that is multiplied by the font-specific base size + * @param color_ The text color + * @param thick_ The thickness of the lines used to draw a text + * @param lt_ The line type. See #LineTypes + * @param bottom_left_origin_ When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner + */ + GAPI_WRAP + Text(const std::string& text_, + const cv::Point& org_, + int ff_, + double fs_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + bool bottom_left_origin_ = false) : + text(text_), org(org_), ff(ff_), fs(fs_), + color(color_), thick(thick_), lt(lt_), bottom_left_origin(bottom_left_origin_) + { + } + + GAPI_WRAP + Text() = default; + + /*@{*/ + GAPI_PROP_RW std::string text; //!< The text string to be drawn + GAPI_PROP_RW cv::Point org; //!< The bottom-left corner of the text string in the image + GAPI_PROP_RW int ff; //!< The font type, see #HersheyFonts + GAPI_PROP_RW double fs; //!< The font scale factor that is multiplied by the font-specific base size + GAPI_PROP_RW cv::Scalar color; //!< The text color + GAPI_PROP_RW int thick; //!< The thickness of the lines used to draw a text + GAPI_PROP_RW int lt; //!< The line type. See #LineTypes + GAPI_PROP_RW bool bottom_left_origin; //!< When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner + /*@{*/ +}; + +/** + * @brief This structure represents a text string to draw using + * FreeType renderer. + * + * If OpenCV is built without FreeType support, this primitive will + * fail at the execution stage. + */ +struct FText +{ + /** + * @brief FText constructor + * + * @param text_ The text string to be drawn + * @param org_ The bottom-left corner of the text string in the image + * @param fh_ The height of text + * @param color_ The text color + */ + FText(const std::wstring& text_, + const cv::Point& org_, + int fh_, + const cv::Scalar& color_) : + text(text_), org(org_), fh(fh_), color(color_) + { + } + + FText() = default; + + /*@{*/ + std::wstring text; //!< The text string to be drawn + cv::Point org; //!< The bottom-left corner of the text string in the image + int fh; //!< The height of text + cv::Scalar color; //!< The text color + /*@{*/ +}; + +/** + * @brief This structure represents a rectangle to draw. + * + * Parameters match cv::rectangle(). + */ +struct GAPI_EXPORTS_W_SIMPLE Rect +{ + /** + * @brief Rect constructor + * + * @param rect_ Coordinates of the rectangle + * @param color_ The bottom-left corner of the text string in the image + * @param thick_ The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle + * @param lt_ The type of the line. See #LineTypes + * @param shift_ The number of fractional bits in the point coordinates + */ + Rect(const cv::Rect& rect_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + rect(rect_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Rect() = default; + + /*@{*/ + GAPI_PROP_RW cv::Rect rect; //!< Coordinates of the rectangle + GAPI_PROP_RW cv::Scalar color; //!< The rectangle color or brightness (grayscale image) + GAPI_PROP_RW int thick; //!< The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle + GAPI_PROP_RW int lt; //!< The type of the line. See #LineTypes + GAPI_PROP_RW int shift; //!< The number of fractional bits in the point coordinates + /*@{*/ +}; + +/** + * @brief This structure represents a circle to draw. + * + * Parameters match cv::circle(). + */ +struct GAPI_EXPORTS_W_SIMPLE Circle +{ + /** + * @brief Circle constructor + * + * @param center_ The center of the circle + * @param radius_ The radius of the circle + * @param color_ The color of the circle + * @param thick_ The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn + * @param lt_ The Type of the circle boundary. See #LineTypes + * @param shift_ The Number of fractional bits in the coordinates of the center and in the radius value + */ + GAPI_WRAP + Circle(const cv::Point& center_, + int radius_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + center(center_), radius(radius_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Circle() = default; + + /*@{*/ + GAPI_PROP_RW cv::Point center; //!< The center of the circle + GAPI_PROP_RW int radius; //!< The radius of the circle + GAPI_PROP_RW cv::Scalar color; //!< The color of the circle + GAPI_PROP_RW int thick; //!< The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn + GAPI_PROP_RW int lt; //!< The Type of the circle boundary. See #LineTypes + GAPI_PROP_RW int shift; //!< The Number of fractional bits in the coordinates of the center and in the radius value + /*@{*/ +}; + +/** + * @brief This structure represents a line to draw. + * + * Parameters match cv::line(). + */ +struct GAPI_EXPORTS_W_SIMPLE Line +{ + /** + * @brief Line constructor + * + * @param pt1_ The first point of the line segment + * @param pt2_ The second point of the line segment + * @param color_ The line color + * @param thick_ The thickness of line + * @param lt_ The Type of the line. See #LineTypes + * @param shift_ The number of fractional bits in the point coordinates + */ + GAPI_WRAP + Line(const cv::Point& pt1_, + const cv::Point& pt2_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + pt1(pt1_), pt2(pt2_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Line() = default; + + /*@{*/ + GAPI_PROP_RW cv::Point pt1; //!< The first point of the line segment + GAPI_PROP_RW cv::Point pt2; //!< The second point of the line segment + GAPI_PROP_RW cv::Scalar color; //!< The line color + GAPI_PROP_RW int thick; //!< The thickness of line + GAPI_PROP_RW int lt; //!< The Type of the line. See #LineTypes + GAPI_PROP_RW int shift; //!< The number of fractional bits in the point coordinates + /*@{*/ +}; + +/** + * @brief This structure represents a mosaicing operation. + * + * Mosaicing is a very basic method to obfuscate regions in the image. + */ +struct GAPI_EXPORTS_W_SIMPLE Mosaic +{ + /** + * @brief Mosaic constructor + * + * @param mos_ Coordinates of the mosaic + * @param cellSz_ Cell size (same for X, Y) + * @param decim_ Decimation (0 stands for no decimation) + */ + Mosaic(const cv::Rect& mos_, + int cellSz_, + int decim_) : + mos(mos_), cellSz(cellSz_), decim(decim_) + { + } + + GAPI_WRAP + Mosaic() : cellSz(0), decim(0) {} + + /*@{*/ + GAPI_PROP_RW cv::Rect mos; //!< Coordinates of the mosaic + GAPI_PROP_RW int cellSz; //!< Cell size (same for X, Y) + GAPI_PROP_RW int decim; //!< Decimation (0 stands for no decimation) + /*@{*/ +}; + +/** + * @brief This structure represents an image to draw. + * + * Image is blended on a frame using the specified mask. + */ +struct GAPI_EXPORTS_W_SIMPLE Image +{ + /** + * @brief Mosaic constructor + * + * @param org_ The bottom-left corner of the image + * @param img_ Image to draw + * @param alpha_ Alpha channel for image to draw (same size and number of channels) + */ + GAPI_WRAP + Image(const cv::Point& org_, + const cv::Mat& img_, + const cv::Mat& alpha_) : + org(org_), img(img_), alpha(alpha_) + { + } + + GAPI_WRAP + Image() = default; + + /*@{*/ + GAPI_PROP_RW cv::Point org; //!< The bottom-left corner of the image + GAPI_PROP_RW cv::Mat img; //!< Image to draw + GAPI_PROP_RW cv::Mat alpha; //!< Alpha channel for image to draw (same size and number of channels) + /*@{*/ +}; + +/** + * @brief This structure represents a polygon to draw. + */ +struct GAPI_EXPORTS_W_SIMPLE Poly +{ + /** + * @brief Mosaic constructor + * + * @param points_ Points to connect + * @param color_ The line color + * @param thick_ The thickness of line + * @param lt_ The Type of the line. See #LineTypes + * @param shift_ The number of fractional bits in the point coordinate + */ + GAPI_WRAP + Poly(const std::vector& points_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + points(points_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Poly() = default; + + /*@{*/ + GAPI_PROP_RW std::vector points; //!< Points to connect + GAPI_PROP_RW cv::Scalar color; //!< The line color + GAPI_PROP_RW int thick; //!< The thickness of line + GAPI_PROP_RW int lt; //!< The Type of the line. See #LineTypes + GAPI_PROP_RW int shift; //!< The number of fractional bits in the point coordinate + /*@{*/ +}; + +using Prim = util::variant + < Text + , FText + , Rect + , Circle + , Line + , Mosaic + , Image + , Poly + >; + +using Prims = std::vector; +//! @} gapi_draw_prims + +} // namespace draw +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_RENDER_TYPES_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/rmat.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/rmat.hpp new file mode 100644 index 0000000..38668d6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/rmat.hpp @@ -0,0 +1,160 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_RMAT_HPP +#define OPENCV_GAPI_RMAT_HPP + +#include +#include + +// Forward declaration +namespace cv { +namespace gapi { +namespace s11n { +struct IOStream; +struct IIStream; +} // namespace s11n +} // namespace gapi +} // namespace cv + +namespace cv { + +// "Remote Mat", a general class which provides an abstraction layer over the data +// storage and placement (host, remote device etc) and allows to access this data. +// +// The device specific implementation is hidden in the RMat::IAdapter class +// +// The basic flow is the following: +// * Backend which is aware of the remote device: +// - Implements own AdapterT class which is derived from RMat::IAdapter +// - Wraps device memory into RMat via make_rmat utility function: +// cv::RMat rmat = cv::make_rmat(args); +// +// * End user: +// - Writes the code which works with RMats without any knowledge of the remote device: +// void func(const cv::RMat& in_rmat, cv::RMat& out_rmat) { +// // Fetch input data from the device, get mapped memory for output +// cv::RMat::View in_view = in_rmat.access(Access::R); +// cv::RMat::View out_view = out_rmat.access(Access::W); +// performCalculations(in_view, out_view); +// // data from out_view is transferred to the device when out_view is destroyed +// } +/** \addtogroup gapi_data_structures + * @{ + */ +class GAPI_EXPORTS RMat +{ +public: + // A lightweight wrapper on image data: + // - Doesn't own the memory; + // - Doesn't implement copy semantics (it's assumed that a view is created each time + // wrapped data is being accessed); + // - Has an optional callback which is called when the view is destroyed. + class GAPI_EXPORTS View + { + public: + using DestroyCallback = std::function; + using stepsT = std::vector; + + View() = default; + View(const GMatDesc& desc, uchar* data, const stepsT& steps = {}, DestroyCallback&& cb = nullptr); + View(const GMatDesc& desc, uchar* data, size_t step, DestroyCallback&& cb = nullptr); + + View(const View&) = delete; + View& operator=(const View&) = delete; + View(View&&) = default; + View& operator=(View&& v); + ~View() { if (m_cb) m_cb(); } + + cv::Size size() const { return m_desc.size; } + const std::vector& dims() const { return m_desc.dims; } + int cols() const { return m_desc.size.width; } + int rows() const { return m_desc.size.height; } + int type() const; + int depth() const { return m_desc.depth; } + int chan() const { return m_desc.chan; } + size_t elemSize() const { return CV_ELEM_SIZE(type()); } + + template T* ptr(int y = 0) { + return reinterpret_cast(m_data + step()*y); + } + template const T* ptr(int y = 0) const { + return reinterpret_cast(m_data + step()*y); + } + template T* ptr(int y, int x) { + return reinterpret_cast(m_data + step()*y + step(1)*x); + } + template const T* ptr(int y, int x) const { + return reinterpret_cast(m_data + step()*y + step(1)*x); + } + size_t step(size_t i = 0) const { GAPI_DbgAssert(i; + + RMat() = default; + RMat(AdapterP&& a) : m_adapter(std::move(a)) {} + GMatDesc desc() const { return m_adapter->desc(); } + + // Note: When accessed for write there is no guarantee that returned view + // will contain actual snapshot of the mapped device memory + // (no guarantee that fetch from a device is performed). The only + // guaranty is that when the view is destroyed, its data will be + // transferred to the device + View access(Access a) const { return m_adapter->access(a); } + + // Cast underlying RMat adapter to the particular adapter type, + // return nullptr if underlying type is different + template T* get() const + { + static_assert(std::is_base_of::value, "T is not derived from IAdapter!"); + GAPI_Assert(m_adapter != nullptr); + return dynamic_cast(m_adapter.get()); + } + + void serialize(cv::gapi::s11n::IOStream& os) const { + m_adapter->serialize(os); + } + +private: + AdapterP m_adapter = nullptr; +}; + +template +RMat make_rmat(Ts&&... args) { return { std::make_shared(std::forward(args)...) }; } +/** @} */ + +} //namespace cv + +#endif /* OPENCV_GAPI_RMAT_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/s11n.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/s11n.hpp new file mode 100644 index 0000000..6863a5e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/s11n.hpp @@ -0,0 +1,505 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + +#ifndef OPENCV_GAPI_S11N_HPP +#define OPENCV_GAPI_S11N_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +// FIXME: caused by deserialize_runarg +#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER +#pragma warning(disable: 4702) +#endif + +namespace cv { +namespace gapi { + +/** +* \addtogroup gapi_serialization +* @{ +*/ + +namespace detail { + GAPI_EXPORTS cv::GComputation getGraph(const std::vector &bytes); + + GAPI_EXPORTS cv::GMetaArgs getMetaArgs(const std::vector &bytes); + + GAPI_EXPORTS cv::GRunArgs getRunArgs(const std::vector &bytes); + + GAPI_EXPORTS std::vector getVectorOfStrings(const std::vector &bytes); + + template + cv::GCompileArgs getCompileArgs(const std::vector &bytes); + + template + cv::GRunArgs getRunArgsWithAdapters(const std::vector &bytes); +} // namespace detail + +/** @brief Serialize a graph represented by GComputation into an array of bytes. + * + * Check different overloads for more examples. + * @param c GComputation to serialize. + * @return serialized vector of bytes. + */ +GAPI_EXPORTS std::vector serialize(const cv::GComputation &c); + +/** @overload + * @param ca GCompileArgs to serialize. + */ +GAPI_EXPORTS std::vector serialize(const cv::GCompileArgs& ca); + +/** @overload + * @param ma GMetaArgs to serialize. + */ +GAPI_EXPORTS std::vector serialize(const cv::GMetaArgs& ma); + +/** @overload + * @param ra GRunArgs to serialize. + */ +GAPI_EXPORTS std::vector serialize(const cv::GRunArgs& ra); + +/** @overload + * @param vs std::vector to serialize. + */ +GAPI_EXPORTS std::vector serialize(const std::vector& vs); + +/** + * @private + */ +template static inline +T deserialize(const std::vector &bytes); + +/** @brief Deserialize GComputation from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized GComputation object. + */ +template<> inline +cv::GComputation deserialize(const std::vector &bytes) { + return detail::getGraph(bytes); +} + +/** @brief Deserialize GMetaArgs from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized GMetaArgs object. + */ +template<> inline +cv::GMetaArgs deserialize(const std::vector &bytes) { + return detail::getMetaArgs(bytes); +} + +/** @brief Deserialize GRunArgs from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized GRunArgs object. + */ +template<> inline +cv::GRunArgs deserialize(const std::vector &bytes) { + return detail::getRunArgs(bytes); +} + +/** @brief Deserialize std::vector from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized std::vector object. + */ +template<> inline +std::vector deserialize(const std::vector &bytes) { + return detail::getVectorOfStrings(bytes); +} + +/** + * @brief Deserialize GCompileArgs which types were specified in the template from a byte array. + * + * @note cv::gapi::s11n::detail::S11N template specialization must be provided to make a custom type + * in GCompileArgs deserializable. + * + * @param bytes vector of bytes to deserialize GCompileArgs object from. + * @return GCompileArgs object. + * @see GCompileArgs cv::gapi::s11n::detail::S11N + */ +template inline +typename std::enable_if::value, GCompileArgs>:: +type deserialize(const std::vector &bytes) { + return detail::getCompileArgs(bytes); +} + +/** + * @brief Deserialize GRunArgs including RMat and MediaFrame objects if any from a byte array. + * + * Adapter types are specified in the template. + * @note To be used properly specified adapter types must overload their deserialize() method. + * @param bytes vector of bytes to deserialize GRunArgs object from. + * @return GRunArgs including RMat and MediaFrame objects if any. + * @see RMat MediaFrame + */ +template inline +typename std::enable_if::value, GRunArgs>:: +type deserialize(const std::vector &bytes) { + return detail::getRunArgsWithAdapters(bytes); +} +} // namespace gapi +} // namespace cv + +namespace cv { +namespace gapi { +namespace s11n { + +/** @brief This structure is an interface for serialization routines. + * + * It's main purpose is to provide multiple overloads for operator<<() + * with basic C++ in addition to OpenCV/G-API types. + * + * This sctructure can be inherited and further extended with additional types. + * + * For example, it is utilized in cv::gapi::s11n::detail::S11N as input parameter + * in serialize() method. + */ +struct GAPI_EXPORTS IOStream { + virtual ~IOStream() = default; + // Define the native support for basic C++ types at the API level: + virtual IOStream& operator<< (bool) = 0; + virtual IOStream& operator<< (char) = 0; + virtual IOStream& operator<< (unsigned char) = 0; + virtual IOStream& operator<< (short) = 0; + virtual IOStream& operator<< (unsigned short) = 0; + virtual IOStream& operator<< (int) = 0; + virtual IOStream& operator<< (uint32_t) = 0; + virtual IOStream& operator<< (uint64_t) = 0; + virtual IOStream& operator<< (float) = 0; + virtual IOStream& operator<< (double) = 0; + virtual IOStream& operator<< (const std::string&) = 0; +}; + +/** @brief This structure is an interface for deserialization routines. + * + * It's main purpose is to provide multiple overloads for operator>>() + * with basic C++ in addition to OpenCV/G-API types. + * + * This structure can be inherited and further extended with additional types. + * + * For example, it is utilized in cv::gapi::s11n::detail::S11N as input parameter + * in deserialize() method. + */ +struct GAPI_EXPORTS IIStream { + virtual ~IIStream() = default; + virtual IIStream& operator>> (bool &) = 0; + virtual IIStream& operator>> (std::vector::reference) = 0; + virtual IIStream& operator>> (char &) = 0; + virtual IIStream& operator>> (unsigned char &) = 0; + virtual IIStream& operator>> (short &) = 0; + virtual IIStream& operator>> (unsigned short &) = 0; + virtual IIStream& operator>> (int &) = 0; + virtual IIStream& operator>> (float &) = 0; + virtual IIStream& operator>> (double &) = 0; + virtual IIStream& operator >> (uint32_t &) = 0; + virtual IIStream& operator >> (uint64_t &) = 0; + virtual IIStream& operator>> (std::string &) = 0; +}; + +namespace detail { +GAPI_EXPORTS std::unique_ptr getInStream(const std::vector &bytes); +} // namespace detail + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// S11N operators +// Note: operators for basic types are defined in IIStream/IOStream + +// OpenCV types //////////////////////////////////////////////////////////////// + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point &pt); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point &pt); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point2f &pt); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point2f &pt); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Size &sz); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Size &sz); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Rect &rc); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Rect &rc); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Scalar &s); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Scalar &s); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Mat &m); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Mat &m); + +// FIXME: for GRunArgs serailization +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::UMat & um); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::UMat & um); +#endif // !defined(GAPI_STANDALONE) + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::RMat &r); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::RMat &r); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::gapi::wip::IStreamSource::Ptr &issptr); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::gapi::wip::IStreamSource::Ptr &issptr); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::detail::VectorRef &vr); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::detail::VectorRef &vr); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::detail::OpaqueRef &opr); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::detail::OpaqueRef &opr); + +/// @private -- Exclude this function from OpenCV documentation +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::MediaFrame &mf); +/// @private -- Exclude this function from OpenCV documentation +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::MediaFrame &mf); + +// Generic STL types //////////////////////////////////////////////////////////////// +template +IOStream& operator<< (IOStream& os, const std::map &m) { + const uint32_t sz = static_cast(m.size()); + os << sz; + for (const auto& it : m) os << it.first << it.second; + return os; +} +template +IIStream& operator>> (IIStream& is, std::map &m) { + m.clear(); + uint32_t sz = 0u; + is >> sz; + for (std::size_t i = 0; i < sz; ++i) { + K k{}; + V v{}; + is >> k >> v; + m[k] = v; + } + return is; +} + +template +IOStream& operator<< (IOStream& os, const std::unordered_map &m) { + const uint32_t sz = static_cast(m.size()); + os << sz; + for (auto &&it : m) os << it.first << it.second; + return os; +} +template +IIStream& operator>> (IIStream& is, std::unordered_map &m) { + m.clear(); + uint32_t sz = 0u; + is >> sz; + for (std::size_t i = 0; i < sz; ++i) { + K k{}; + V v{}; + is >> k >> v; + m[k] = v; + } + return is; +} + +template +IOStream& operator<< (IOStream& os, const std::vector &ts) { + const uint32_t sz = static_cast(ts.size()); + os << sz; + for (auto &&v : ts) os << v; + return os; +} +template +IIStream& operator>> (IIStream& is, std::vector &ts) { + uint32_t sz = 0u; + is >> sz; + if (sz == 0u) { + ts.clear(); + } + else { + ts.resize(sz); + for (std::size_t i = 0; i < sz; ++i) is >> ts[i]; + } + return is; +} + +// Generic: variant serialization +namespace detail { +template +IOStream& put_v(IOStream&, const V&, std::size_t) { + GAPI_Assert(false && "variant>>: requested index is invalid"); +}; + +template +IOStream& put_v(IOStream& os, const V& v, std::size_t x) { + return (x == 0u) + ? os << cv::util::get(v) + : put_v(os, v, x-1); +} + +template +IIStream& get_v(IIStream&, V&, std::size_t, std::size_t) { + GAPI_Assert(false && "variant<<: requested index is invalid"); +} + +template +IIStream& get_v(IIStream& is, V& v, std::size_t i, std::size_t gi) { + if (i == gi) { + X x{}; + is >> x; + v = V{std::move(x)}; + return is; + } else return get_v(is, v, i+1, gi); +} +} // namespace detail + +//! @overload +template +IOStream& operator<< (IOStream& os, const cv::util::variant &v) { + os << static_cast(v.index()); + return detail::put_v, Ts...>(os, v, v.index()); +} +//! @overload +template +IIStream& operator>> (IIStream& is, cv::util::variant &v) { + int idx = -1; + is >> idx; + GAPI_Assert(idx >= 0 && idx < (int)sizeof...(Ts)); + return detail::get_v, Ts...>(is, v, 0u, idx); +} + +// FIXME: consider a better solution +/// @private -- Exclude this function from OpenCV documentation +template +void getRunArgByIdx (IIStream& is, cv::util::variant &v, uint32_t idx) { + is = detail::get_v, Ts...>(is, v, 0u, idx); +} +} // namespace s11n + +namespace detail +{ +template struct try_deserialize_comparg; + +template<> struct try_deserialize_comparg> { +static cv::util::optional exec(const std::string&, cv::gapi::s11n::IIStream&) { + return { }; + } +}; + +template +struct try_deserialize_comparg> { +static cv::util::optional exec(const std::string& tag, cv::gapi::s11n::IIStream& is) { + if (tag == cv::detail::CompileArgTag::tag()) { + static_assert(cv::gapi::s11n::detail::has_S11N_spec::value, + "cv::gapi::deserialize expects Types to have S11N " + "specializations with deserialization callbacks!"); + return cv::util::optional( + GCompileArg { cv::gapi::s11n::detail::S11N::deserialize(is) }); + } + return try_deserialize_comparg>::exec(tag, is); +} +}; + +template +struct deserialize_arg_with_adapter; + +template +struct deserialize_arg_with_adapter { +static GRunArg exec(cv::gapi::s11n::IIStream& is) { + std::unique_ptr ptr(new TA); + ptr->deserialize(is); + return GRunArg { RA(std::move(ptr)) }; +} +}; + +template +struct deserialize_arg_with_adapter { +static GRunArg exec(cv::gapi::s11n::IIStream&) { + GAPI_Assert(false && "No suitable adapter class found during RMat/MediaFrame deserialization. " + "Please, make sure you've passed them in cv::gapi::deserialize() template"); + return GRunArg{}; +} +}; + +template +struct deserialize_runarg { +static GRunArg exec(cv::gapi::s11n::IIStream& is, uint32_t idx) { + if (idx == GRunArg::index_of()) { + // Type or void (if not found) + using TA = typename cv::util::find_adapter_impl::type; + return deserialize_arg_with_adapter::exec(is); + } else if (idx == GRunArg::index_of()) { + // Type or void (if not found) + using TA = typename cv::util::find_adapter_impl::type; + return deserialize_arg_with_adapter::exec(is); + } else { // not an adapter holding type runarg - use default deserialization + GRunArg arg; + getRunArgByIdx(is, arg, idx); + return arg; + } +} +}; + +template +inline cv::util::optional tryDeserializeCompArg(const std::string& tag, + const std::vector& sArg) { + std::unique_ptr pArgIs = cv::gapi::s11n::detail::getInStream(sArg); + return try_deserialize_comparg>::exec(tag, *pArgIs); +} + +template +cv::GCompileArgs getCompileArgs(const std::vector &sArgs) { + cv::GCompileArgs args; + + std::unique_ptr pIs = cv::gapi::s11n::detail::getInStream(sArgs); + cv::gapi::s11n::IIStream& is = *pIs; + + uint32_t sz = 0; + is >> sz; + for (uint32_t i = 0; i < sz; ++i) { + std::string tag; + is >> tag; + + std::vector sArg; + is >> sArg; + + cv::util::optional dArg = + cv::gapi::detail::tryDeserializeCompArg(tag, sArg); + + if (dArg.has_value()) + { + args.push_back(dArg.value()); + } + } + + return args; +} + +template +cv::GRunArgs getRunArgsWithAdapters(const std::vector &bytes) { + std::unique_ptr pIs = cv::gapi::s11n::detail::getInStream(bytes); + cv::gapi::s11n::IIStream& is = *pIs; + cv::GRunArgs args; + + uint32_t sz = 0; + is >> sz; + for (uint32_t i = 0; i < sz; ++i) { + uint32_t idx = 0; + is >> idx; + args.push_back(cv::gapi::detail::deserialize_runarg::exec(is, idx)); + } + + return args; +} +} // namespace detail +/** @} */ + +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_S11N_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/s11n/base.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/s11n/base.hpp new file mode 100644 index 0000000..6cea941 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/s11n/base.hpp @@ -0,0 +1,80 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + +#ifndef OPENCV_GAPI_S11N_BASE_HPP +#define OPENCV_GAPI_S11N_BASE_HPP + +#include +#include + +namespace cv { +namespace gapi { + +/** + * @brief This namespace contains G-API serialization and + * deserialization functions and data structures. + */ +namespace s11n { +struct IOStream; +struct IIStream; + +namespace detail { + +//! @addtogroup gapi_serialization +//! @{ + +struct NotImplemented { +}; + +/** @brief This structure allows to implement serialization routines for custom types. + * + * The default S11N for custom types is not implemented. + * + * @note When providing an overloaded implementation for S11N with your type + * don't inherit it from NotImplemented structure. + * + * @note There are lots of overloaded >> and << operators for basic and OpenCV/G-API types + * which can be utilized when serializing a custom type. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp S11N usage + * + */ +template +struct S11N: public NotImplemented { + /** + * @brief This function allows user to serialize their custom type. + * + * @note The default overload throws an exception if called. User need to + * properly overload the function to use it. + */ + static void serialize(IOStream &, const T &) { + GAPI_Assert(false && "No serialization routine is provided!"); + } + /** + * @brief This function allows user to deserialize their custom type. + * + * @note The default overload throws an exception if called. User need to + * properly overload the function to use it. + */ + static T deserialize(IIStream &) { + GAPI_Assert(false && "No deserialization routine is provided!"); + } +}; + +/// @private -- Exclude this struct from OpenCV documentation +template struct has_S11N_spec { + static constexpr bool value = !std::is_base_of::type>>::value; +}; +//! @} gapi_serialization + +} // namespace detail +} // namespace s11n +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_S11N_BASE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/stereo.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/stereo.hpp new file mode 100644 index 0000000..dcf8f4d --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/stereo.hpp @@ -0,0 +1,85 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distereoibution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STEREO_HPP +#define OPENCV_GAPI_STEREO_HPP + +#include +#include +#include + +namespace cv { +namespace gapi { + +/** + * The enum specified format of result that you get from @ref cv::gapi::stereo. + */ +enum class StereoOutputFormat { + DEPTH_FLOAT16, ///< Floating point 16 bit value, CV_16FC1. + ///< This identifier is deprecated, use DEPTH_16F instead. + DEPTH_FLOAT32, ///< Floating point 32 bit value, CV_32FC1 + ///< This identifier is deprecated, use DEPTH_16F instead. + DISPARITY_FIXED16_11_5, ///< 16 bit signed: first bit for sign, + ///< 10 bits for integer part, + ///< 5 bits for fractional part. + ///< This identifier is deprecated, + ///< use DISPARITY_16Q_10_5 instead. + DISPARITY_FIXED16_12_4, ///< 16 bit signed: first bit for sign, + ///< 11 bits for integer part, + ///< 4 bits for fractional part. + ///< This identifier is deprecated, + ///< use DISPARITY_16Q_11_4 instead. + DEPTH_16F = DEPTH_FLOAT16, ///< Same as DEPTH_FLOAT16 + DEPTH_32F = DEPTH_FLOAT32, ///< Same as DEPTH_FLOAT32 + DISPARITY_16Q_10_5 = DISPARITY_FIXED16_11_5, ///< Same as DISPARITY_FIXED16_11_5 + DISPARITY_16Q_11_4 = DISPARITY_FIXED16_12_4 ///< Same as DISPARITY_FIXED16_12_4 +}; + + +/** + * @brief This namespace contains G-API Operation Types for Stereo and + * related functionality. + */ +namespace calib3d { + +G_TYPED_KERNEL(GStereo, , "org.opencv.stereo") { + static GMatDesc outMeta(const GMatDesc &left, const GMatDesc &right, const StereoOutputFormat of) { + GAPI_Assert(left.chan == 1); + GAPI_Assert(left.depth == CV_8U); + + GAPI_Assert(right.chan == 1); + GAPI_Assert(right.depth == CV_8U); + + switch(of) { + case StereoOutputFormat::DEPTH_FLOAT16: + return left.withDepth(CV_16FC1); + case StereoOutputFormat::DEPTH_FLOAT32: + return left.withDepth(CV_32FC1); + case StereoOutputFormat::DISPARITY_FIXED16_11_5: + case StereoOutputFormat::DISPARITY_FIXED16_12_4: + return left.withDepth(CV_16SC1); + default: + GAPI_Assert(false && "Unknown output format!"); + } + } +}; + +} // namespace calib3d + +/** @brief Computes disparity/depth map for the specified stereo-pair. +The function computes disparity or depth map depending on passed StereoOutputFormat argument. + +@param left 8-bit single-channel left image of @ref CV_8UC1 type. +@param right 8-bit single-channel right image of @ref CV_8UC1 type. +@param of enum to specified output kind: depth or disparity and corresponding type +*/ +GAPI_EXPORTS GMat stereo(const GMat& left, + const GMat& right, + const StereoOutputFormat of = StereoOutputFormat::DEPTH_FLOAT32); +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STEREO_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/cap.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/cap.hpp new file mode 100644 index 0000000..aad6af6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/cap.hpp @@ -0,0 +1,126 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_CAP_HPP +#define OPENCV_GAPI_STREAMING_CAP_HPP + +/** + * YOUR ATTENTION PLEASE! + * + * This is a header-only implementation of cv::VideoCapture-based + * Stream source. It is not built by default with G-API as G-API + * doesn't depend on videoio module. + * + * If you want to use it in your application, please make sure + * videioio is available in your OpenCV package and is linked to your + * application. + * + * Note for developers: please don't put videoio dependency in G-API + * because of this file. + */ +#include + +#include +#include +#include + +namespace cv { +namespace gapi { +namespace wip { + +/** + * @brief OpenCV's VideoCapture-based streaming source. + * + * This class implements IStreamSource interface. + * Its constructor takes the same parameters as cv::VideoCapture does. + * + * Please make sure that videoio OpenCV module is available before using + * this in your application (G-API doesn't depend on it directly). + * + * @note stream sources are passed to G-API via shared pointers, so + * please gapi::make_src<> to create objects and ptr() to pass a + * GCaptureSource to cv::gin(). + */ +class GCaptureSource: public IStreamSource +{ +public: + explicit GCaptureSource(int id) : cap(id) { prep(); } + explicit GCaptureSource(const std::string &path) : cap(path) { prep(); } + + // TODO: Add more constructor overloads to make it + // fully compatible with VideoCapture's interface. + +protected: + cv::VideoCapture cap; + cv::Mat first; + bool first_pulled = false; + int64_t counter = 0; + + void prep() + { + // Prepare first frame to report its meta to engine + // when needed + GAPI_Assert(first.empty()); + cv::Mat tmp; + if (!cap.read(tmp)) + { + GAPI_Assert(false && "Couldn't grab the very first frame"); + } + // NOTE: Some decode/media VideoCapture backends continue + // owning the video buffer under cv::Mat so in order to + // process it safely in a highly concurrent pipeline, clone() + // is the only right way. + first = tmp.clone(); + } + + virtual bool pull(cv::gapi::wip::Data &data) override + { + if (!first_pulled) + { + GAPI_Assert(!first.empty()); + first_pulled = true; + data = first; // no need to clone here since it was cloned already + } + else + { + if (!cap.isOpened()) return false; + + cv::Mat frame; + if (!cap.read(frame)) + { + // end-of-stream happened + return false; + } + // Same reason to clone as in prep() + data = frame.clone(); + } + // Tag data with seq_id/ts + const auto now = std::chrono::system_clock::now(); + const auto dur = std::chrono::duration_cast + (now.time_since_epoch()); + data.meta[cv::gapi::streaming::meta_tag::timestamp] = int64_t{dur.count()}; + data.meta[cv::gapi::streaming::meta_tag::seq_id] = int64_t{counter++}; + return true; + } + + virtual GMetaArg descr_of() const override + { + GAPI_Assert(!first.empty()); + return cv::GMetaArg{cv::descr_of(first)}; + } +}; + +// NB: Overload for using from python +GAPI_EXPORTS_W cv::Ptr inline make_capture_src(const std::string& path) +{ + return make_src(path); +} + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_CAP_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/desync.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/desync.hpp new file mode 100644 index 0000000..1ed6e24 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/desync.hpp @@ -0,0 +1,85 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GSTREAMING_DESYNC_HPP +#define OPENCV_GAPI_GSTREAMING_DESYNC_HPP + +#include + +#include +#include +#include +#include +#include + +namespace cv { +namespace gapi { +namespace streaming { + +namespace detail { +struct GDesync { + static const char *id() { + return "org.opencv.streaming.desync"; + } + + // An universal yield for desync. + // Yields output objects according to the input Types... + // Reuses gkernel machinery. + // FIXME: This function can be generic and declared in gkernel.hpp + // (it is there already, but a part of GKernelType[M] + template + static std::tuple yield(cv::GCall &call, cv::detail::Seq) { + return std::make_tuple(cv::detail::Yield::yield(call, IIs)...); + } +}; + +template +G desync(const G &g) { + cv::GKernel k{ + GDesync::id() // kernel id + , "" // kernel tag + , [](const GMetaArgs &a, const GArgs &) {return a;} // outMeta callback + , {cv::detail::GTypeTraits::shape} // output Shape + , {cv::detail::GTypeTraits::op_kind} // input data kinds + , {cv::detail::GObtainCtor::get()} // output template ctors + }; + cv::GCall call(std::move(k)); + call.pass(g); + return std::get<0>(GDesync::yield(call, cv::detail::MkSeq<1>::type())); +} +} // namespace detail + +/** + * @brief Starts a desynchronized branch in the graph. + * + * This operation takes a single G-API data object and returns a + * graph-level "duplicate" of this object. + * + * Operations which use this data object can be desynchronized + * from the rest of the graph. + * + * This operation has no effect when a GComputation is compiled with + * regular cv::GComputation::compile(), since cv::GCompiled objects + * always produce their full output vectors. + * + * This operation only makes sense when a GComputation is compiled in + * straming mode with cv::GComputation::compileStreaming(). If this + * operation is used and there are desynchronized outputs, the user + * should use a special version of cv::GStreamingCompiled::pull() + * which produces an array of cv::util::optional<> objects. + * + * @note This feature is highly experimental now and is currently + * limited to a single GMat/GFrame argument only. + */ +GAPI_EXPORTS GMat desync(const GMat &g); +GAPI_EXPORTS GFrame desync(const GFrame &f); + +} // namespace streaming +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GSTREAMING_DESYNC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/format.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/format.hpp new file mode 100644 index 0000000..f7c3bd4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/format.hpp @@ -0,0 +1,94 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_GSTREAMING_FORMAT_HPP +#define OPENCV_GAPI_GSTREAMING_FORMAT_HPP + +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace streaming { + +GAPI_EXPORTS cv::gapi::GKernelPackage kernels(); + +G_API_OP(GBGR, , "org.opencv.streaming.BGR") +{ + static GMatDesc outMeta(const GFrameDesc& in) { return GMatDesc{CV_8U, 3, in.size}; } +}; + +G_API_OP(GY, , "org.opencv.streaming.Y") { + static GMatDesc outMeta(const GFrameDesc& frameDesc) { + return GMatDesc { CV_8U, 1, frameDesc.size , false }; + } +}; + +G_API_OP(GUV, , "org.opencv.streaming.UV") { + static GMatDesc outMeta(const GFrameDesc& frameDesc) { + return GMatDesc { CV_8U, 2, cv::Size(frameDesc.size.width / 2, frameDesc.size.height / 2), + false }; + } +}; + +/** @brief Gets bgr plane from input frame + +@note Function textual ID is "org.opencv.streaming.BGR" + +@param in Input frame +@return Image in BGR format +*/ +GAPI_EXPORTS cv::GMat BGR(const cv::GFrame& in); + +/** @brief Extracts Y plane from media frame. + +Output image is 8-bit 1-channel image of @ref CV_8UC1. + +@note Function textual ID is "org.opencv.streaming.Y" + +@param frame input media frame. +*/ +GAPI_EXPORTS GMat Y(const cv::GFrame& frame); + +/** @brief Extracts UV plane from media frame. + +Output image is 8-bit 2-channel image of @ref CV_8UC2. + +@note Function textual ID is "org.opencv.streaming.UV" + +@param frame input media frame. +*/ +GAPI_EXPORTS GMat UV(const cv::GFrame& frame); +} // namespace streaming + +//! @addtogroup gapi_transform +//! @{ +/** @brief Makes a copy of the input image. Note that this copy may be not real +(no actual data copied). Use this function to maintain graph contracts, +e.g when graph's input needs to be passed directly to output, like in Streaming mode. + +@note Function textual ID is "org.opencv.streaming.copy" + +@param in Input image +@return Copy of the input +*/ +GAPI_EXPORTS_W GMat copy(const GMat& in); + +/** @brief Makes a copy of the input frame. Note that this copy may be not real +(no actual data copied). Use this function to maintain graph contracts, +e.g when graph's input needs to be passed directly to output, like in Streaming mode. + +@note Function textual ID is "org.opencv.streaming.copy" + +@param in Input frame +@return Copy of the input +*/ +GAPI_EXPORTS GFrame copy(const GFrame& in); +//! @} gapi_transform + +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GSTREAMING_FORMAT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp new file mode 100644 index 0000000..83afc99 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp @@ -0,0 +1,47 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP +#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP + +#include +#include + +#include +#include +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace gst { + +class GAPI_EXPORTS GStreamerPipeline +{ +public: + class Priv; + + explicit GStreamerPipeline(const std::string& pipeline); + IStreamSource::Ptr getStreamingSource(const std::string& appsinkName, + const GStreamerSource::OutputType outputType = + GStreamerSource::OutputType::MAT); + virtual ~GStreamerPipeline(); + +protected: + explicit GStreamerPipeline(std::unique_ptr priv); + + std::unique_ptr m_priv; +}; + +} // namespace gst + +using GStreamerPipeline = gst::GStreamerPipeline; + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamersource.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamersource.hpp new file mode 100644 index 0000000..b81bad3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamersource.hpp @@ -0,0 +1,89 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP +#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP + +#include +#include + +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace gst { + +/** + * @brief OpenCV's GStreamer streaming source. + * Streams cv::Mat-s/cv::MediaFrame from passed GStreamer pipeline. + * + * This class implements IStreamSource interface. + * + * To create GStreamerSource instance you need to pass 'pipeline' and, optionally, 'outputType' + * arguments into constructor. + * 'pipeline' should represent GStreamer pipeline in form of textual description. + * Almost any custom pipeline is supported which can be successfully ran via gst-launch. + * The only two limitations are: + * - there should be __one__ appsink element in the pipeline to pass data to OpenCV app. + * Pipeline can actually contain many sink elements, but it must have one and only one + * appsink among them. + * + * - data passed to appsink should be video-frame in NV12 format. + * + * 'outputType' is used to select type of output data to produce: 'cv::MediaFrame' or 'cv::Mat'. + * To produce 'cv::MediaFrame'-s you need to pass 'GStreamerSource::OutputType::FRAME' and, + * correspondingly, 'GStreamerSource::OutputType::MAT' to produce 'cv::Mat'-s. + * Please note, that in the last case, output 'cv::Mat' will be of BGR format, internal conversion + * from NV12 GStreamer data will happen. + * Default value for 'outputType' is 'GStreamerSource::OutputType::MAT'. + * + * @note Stream sources are passed to G-API via shared pointers, so please use gapi::make_src<> + * to create objects and ptr() to pass a GStreamerSource to cv::gin(). + * + * @note You need to build OpenCV with GStreamer support to use this class. + */ + +class GStreamerPipelineFacade; + +class GAPI_EXPORTS GStreamerSource : public IStreamSource +{ +public: + class Priv; + + // Indicates what type of data should be produced by GStreamerSource: cv::MediaFrame or cv::Mat + enum class OutputType { + FRAME, + MAT + }; + + GStreamerSource(const std::string& pipeline, + const GStreamerSource::OutputType outputType = + GStreamerSource::OutputType::MAT); + GStreamerSource(std::shared_ptr pipeline, + const std::string& appsinkName, + const GStreamerSource::OutputType outputType = + GStreamerSource::OutputType::MAT); + + bool pull(cv::gapi::wip::Data& data) override; + GMetaArg descr_of() const override; + ~GStreamerSource() override; + +protected: + explicit GStreamerSource(std::unique_ptr priv); + + std::unique_ptr m_priv; +}; + +} // namespace gst + +using GStreamerSource = gst::GStreamerSource; + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/meta.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/meta.hpp new file mode 100644 index 0000000..cbcfc3a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/meta.hpp @@ -0,0 +1,79 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GSTREAMING_META_HPP +#define OPENCV_GAPI_GSTREAMING_META_HPP + +#include +#include +#include +#include + +namespace cv { +namespace gapi { +namespace streaming { + +// FIXME: the name is debatable +namespace meta_tag { +static constexpr const char * timestamp = "org.opencv.gapi.meta.timestamp"; +static constexpr const char * seq_id = "org.opencv.gapi.meta.seq_id"; +} // namespace meta_tag + +namespace detail { +struct GMeta { + static const char *id() { + return "org.opencv.streaming.meta"; + } + // A universal yield for meta(), same as in GDesync + template + static std::tuple yield(cv::GCall &call, cv::detail::Seq) { + return std::make_tuple(cv::detail::Yield::yield(call, IIs)...); + } + // Also a universal outMeta stub here + static GMetaArgs getOutMeta(const GMetaArgs &args, const GArgs &) { + return args; + } +}; +} // namespace detail + +template +cv::GOpaque meta(G g, const std::string &tag) { + using O = cv::GOpaque; + cv::GKernel k{ + detail::GMeta::id() // kernel id + , tag // kernel tag. Use meta tag here + , &detail::GMeta::getOutMeta // outMeta callback + , {cv::detail::GTypeTraits::shape} // output Shape + , {cv::detail::GTypeTraits::op_kind} // input data kinds + , {cv::detail::GObtainCtor::get()} // output template ctors + }; + cv::GCall call(std::move(k)); + call.pass(g); + return std::get<0>(detail::GMeta::yield(call, cv::detail::MkSeq<1>::type())); +} + +template +cv::GOpaque timestamp(G g) { + return meta(g, meta_tag::timestamp); +} + +template +cv::GOpaque seq_id(G g) { + return meta(g, meta_tag::seq_id); +} + +template +cv::GOpaque seqNo(G g) { + // Old name, compatibility only + return seq_id(g); +} + +} // namespace streaming +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GSTREAMING_META_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp new file mode 100644 index 0000000..bfd9224 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp @@ -0,0 +1,151 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP +#define OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP + +#include +#include +#include + +#include +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { + +/** + * @brief Public class is using for creation of onevpl::GSource instances. + * + * Class members availaible through methods @ref CfgParam::get_name() and @ref CfgParam::get_value() are used by + * onevpl::GSource inner logic to create or find oneVPL particular implementation + * (software/hardware, specific API version and etc.). + * + * @note Because oneVPL may provide several implementations which are satisfying with multiple (or single one) @ref CfgParam + * criteria therefore it is possible to configure `preferred` parameters. This kind of CfgParams are created + * using `is_major = false` argument in @ref CfgParam::create method and are not used by creating oneVPL particular implementations. + * Instead they fill out a "score table" to select preferrable implementation from available list. Implementation are satisfying + * with most of these optional params would be chosen. + * If no one optional CfgParam params were present then first of available oneVPL implementation would be applied. + * Please get on https://spec.oneapi.io/versions/latest/elements/oneVPL/source/API_ref/VPL_disp_api_func.html?highlight=mfxcreateconfig#mfxsetconfigfilterproperty + * for using OneVPL configuration. In this schema `mfxU8 *name` represents @ref CfgParam::get_name() and + * `mfxVariant value` is @ref CfgParam::get_value() + */ +struct GAPI_EXPORTS CfgParam { + using name_t = std::string; + using value_t = cv::util::variant; + /** + * @brief frames_pool_size_name + * + * Special configuration parameter name for onevp::GSource: + * + * @note frames_pool_size_name allows to allocate surfaces pool appropriate size to keep + * decoded frames in accelerator memory ready before + * they would be consumed by onevp::GSource::pull operation. If you see + * a lot of WARNING about lack of free surface then it's time to increase + * frames_pool_size_name but be aware of accelerator free memory volume. + * If not set then MFX implementation use + * mfxFrameAllocRequest::NumFrameSuggested behavior + * + */ + static constexpr const char *frames_pool_size_name() { return "frames_pool_size"; } + static CfgParam create_frames_pool_size(size_t value); + + /** + * @brief acceleration_mode_name + * + * Special configuration parameter names for onevp::GSource: + * + * @note acceleration_mode_name allows to activate hardware acceleration & + * device memory management. + * Supported values: + * - MFX_ACCEL_MODE_VIA_D3D11 Will activate DX11 acceleration and will produces + * MediaFrames with data allocated in DX11 device memory + * + * If not set then MFX implementation will use default acceleration behavior: + * all decoding operation uses default GPU resources but MediaFrame produces + * data allocated by using host RAM + * + */ + static constexpr const char *acceleration_mode_name() { return "mfxImplDescription.AccelerationMode"; } + static CfgParam create_acceleration_mode(uint32_t value); + static CfgParam create_acceleration_mode(const char* value); + + /** + * @brief decoder_id_name + * + * Special configuration parameter names for onevp::GSource: + * + * @note decoder_id_name allows to specify VPL decoder type which MUST present + * in case of RAW video input data and MUST NOT present as CfgParam if video + * stream incapsulated into container(*.mp4, *.mkv and so on). In latter case + * onevp::GSource will determine it automatically + * Supported values: + * - MFX_CODEC_AVC + * - MFX_CODEC_HEVC + * - MFX_CODEC_MPEG2 + * - MFX_CODEC_VC1 + * - MFX_CODEC_CAPTURE + * - MFX_CODEC_VP9 + * - MFX_CODEC_AV1 + * + */ + static constexpr const char *decoder_id_name() { return "mfxImplDescription.mfxDecoderDescription.decoder.CodecID"; } + static CfgParam create_decoder_id(uint32_t value); + static CfgParam create_decoder_id(const char* value); + + static constexpr const char *implementation_name() { return "mfxImplDescription.Impl"; } + static CfgParam create_implementation(uint32_t value); + static CfgParam create_implementation(const char* value); + + /** + * Create generic onevp::GSource configuration parameter. + * + *@param name name of parameter. + *@param value value of parameter. + *@param is_major TRUE if parameter MUST be provided by OneVPL inner implementation, FALSE for optional (for resolve multiple available implementations). + * + */ + template + static CfgParam create(const std::string& name, ValueType&& value, bool is_major = true) { + CfgParam param(name, CfgParam::value_t(std::forward(value)), is_major); + return param; + } + + struct Priv; + + const name_t& get_name() const; + const value_t& get_value() const; + bool is_major() const; + bool operator==(const CfgParam& rhs) const; + bool operator< (const CfgParam& rhs) const; + bool operator!=(const CfgParam& rhs) const; + + CfgParam& operator=(const CfgParam& src); + CfgParam& operator=(CfgParam&& src); + CfgParam(const CfgParam& src); + CfgParam(CfgParam&& src); + ~CfgParam(); +private: + CfgParam(const std::string& param_name, value_t&& param_value, bool is_major_param); + std::shared_ptr m_priv; +}; + +} //namespace onevpl +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/data_provider_interface.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/data_provider_interface.hpp new file mode 100644 index 0000000..c70e3db --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/data_provider_interface.hpp @@ -0,0 +1,105 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP +#define GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP +#include +#include +#include + +#include // GAPI_EXPORTS +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { + +struct GAPI_EXPORTS DataProviderException : public std::exception { + DataProviderException(const std::string& descr); + DataProviderException(std::string&& descr); + + virtual ~DataProviderException() = default; + virtual const char* what() const noexcept override; +private: + std::string reason; +}; + +struct GAPI_EXPORTS DataProviderSystemErrorException final : public DataProviderException { + DataProviderSystemErrorException(int error_code, const std::string& desription = std::string()); + ~DataProviderSystemErrorException() = default; +}; + +struct GAPI_EXPORTS DataProviderUnsupportedException final : public DataProviderException { + DataProviderUnsupportedException(const std::string& description); + ~DataProviderUnsupportedException() = default; +}; + +struct GAPI_EXPORTS DataProviderImplementationException : public DataProviderException { + DataProviderImplementationException(const std::string& description); + ~DataProviderImplementationException() = default; +}; +/** + * @brief Public interface allows to customize extraction of video stream data + * used by onevpl::GSource instead of reading stream from file (by default). + * + * Interface implementation constructor MUST provide consistency and creates fully operable object. + * If error happened implementation MUST throw `DataProviderException` kind exceptions + * + * @note Interface implementation MUST manage stream and other constructed resources by itself to avoid any kind of leak. + * For simple interface implementation example please see `StreamDataProvider` in `tests/streaming/gapi_streaming_tests.cpp` + */ +struct GAPI_EXPORTS IDataProvider { + using Ptr = std::shared_ptr; + using mfx_codec_id_type = uint32_t; + + /** + * NB: here is supposed to be forward declaration of mfxBitstream + * But according to current oneVPL implementation it is impossible to forward + * declare untagged struct mfxBitstream. + * + * IDataProvider makes sense only for HAVE_VPL is ON and to keep IDataProvider + * interface API/ABI compliant between core library and user application layer + * let's introduce wrapper mfx_bitstream which inherits mfxBitstream in private + * G-API code section and declare forward for wrapper mfx_bitstream here + */ + struct mfx_bitstream; + + virtual ~IDataProvider() = default; + + /** + * The function is used by onevpl::GSource to extract codec id from data + * + */ + virtual mfx_codec_id_type get_mfx_codec_id() const = 0; + + /** + * The function is used by onevpl::GSource to extract binary data stream from @ref IDataProvider + * implementation. + * + * It MUST throw `DataProviderException` kind exceptions in fail cases. + * It MUST return MFX_ERR_MORE_DATA in EOF which considered as not-fail case. + * + * @param in_out_bitsream the input-output reference on MFX bitstream buffer which MUST be empty at the first request + * to allow implementation to allocate it by itself and to return back. Subsequent invocation of `fetch_bitstream_data` + * MUST use the previously used in_out_bitsream to avoid skipping rest of frames which haven't been consumed + * @return true for fetched data, false on EOF and throws exception on error + */ + virtual bool fetch_bitstream_data(std::shared_ptr &in_out_bitsream) = 0; + + /** + * The function is used by onevpl::GSource to check more binary data availability. + * + * It MUST return TRUE in case of EOF and NO_THROW exceptions. + * + * @return boolean value which detects end of stream + */ + virtual bool empty() const = 0; +}; +} // namespace onevpl +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/device_selector_interface.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/device_selector_interface.hpp new file mode 100644 index 0000000..04f8cae --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/device_selector_interface.hpp @@ -0,0 +1,102 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP +#define GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP + +#include +#include +#include +#include + +#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS + +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { + +enum class AccelType: uint8_t { + HOST, + DX11, + + LAST_VALUE = std::numeric_limits::max() +}; + +GAPI_EXPORTS const char* to_cstring(AccelType type); + +struct IDeviceSelector; +struct GAPI_EXPORTS Device { + friend struct IDeviceSelector; + using Ptr = void*; + + ~Device(); + const std::string& get_name() const; + Ptr get_ptr() const; + AccelType get_type() const; +private: + Device(Ptr device_ptr, const std::string& device_name, + AccelType device_type); + + std::string name; + Ptr ptr; + AccelType type; +}; + +struct GAPI_EXPORTS Context { + friend struct IDeviceSelector; + using Ptr = void*; + + ~Context(); + Ptr get_ptr() const; + AccelType get_type() const; +private: + Context(Ptr ctx_ptr, AccelType ctx_type); + Ptr ptr; + AccelType type; +}; + +struct GAPI_EXPORTS IDeviceSelector { + using Ptr = std::shared_ptr; + + struct GAPI_EXPORTS Score { + friend struct IDeviceSelector; + using Type = int16_t; + static constexpr Type MaxActivePriority = std::numeric_limits::max(); + static constexpr Type MinActivePriority = 0; + static constexpr Type MaxPassivePriority = MinActivePriority - 1; + static constexpr Type MinPassivePriority = std::numeric_limits::min(); + + Score(Type val); + ~Score(); + + operator Type () const; + Type get() const; + friend bool operator< (Score lhs, Score rhs) { + return lhs.get() < rhs.get(); + } + private: + Type value; + }; + + using DeviceScoreTable = std::map; + using DeviceContexts = std::vector; + + virtual ~IDeviceSelector(); + virtual DeviceScoreTable select_devices() const = 0; + virtual DeviceContexts select_context() = 0; +protected: + template + static Entity create(Args &&...args) { + return Entity(std::forward(args)...); + } +}; +} // namespace onevpl +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/source.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/source.hpp new file mode 100644 index 0000000..6334480 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/source.hpp @@ -0,0 +1,90 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP +#define OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP + +#include +#include +#include +#include +#include +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { +using CfgParams = std::vector; + +/** + * @brief G-API streaming source based on OneVPL implementation. + * + * This class implements IStreamSource interface. + * Its constructor takes source file path (in usual way) or @ref onevpl::IDataProvider + * interface implementation (for not file-based sources). It also allows to pass-through + * oneVPL configuration parameters by using several @ref onevpl::CfgParam. + * + * @note stream sources are passed to G-API via shared pointers, so + * please gapi::make_onevpl_src<> to create objects and ptr() to pass a + * GSource to cv::gin(). + */ +class GAPI_EXPORTS GSource : public IStreamSource +{ +public: + struct Priv; + + GSource(const std::string& filePath, + const CfgParams& cfg_params = CfgParams{}); + + GSource(const std::string& filePath, + const CfgParams& cfg_params, + const std::string& device_id, + void* accel_device_ptr, + void* accel_ctx_ptr); + + GSource(const std::string& filePath, + const CfgParams& cfg_params, + std::shared_ptr selector); + + + GSource(std::shared_ptr source, + const CfgParams& cfg_params = CfgParams{}); + + GSource(std::shared_ptr source, + const CfgParams& cfg_params, + const std::string& device_id, + void* accel_device_ptr, + void* accel_ctx_ptr); + + GSource(std::shared_ptr source, + const CfgParams& cfg_params, + std::shared_ptr selector); + + ~GSource() override; + + bool pull(cv::gapi::wip::Data& data) override; + GMetaArg descr_of() const override; + +private: + explicit GSource(std::unique_ptr&& impl); + std::unique_ptr m_priv; +}; +} // namespace onevpl + +using GVPLSource = onevpl::GSource; + +template +GAPI_EXPORTS_W cv::Ptr inline make_onevpl_src(Args&&... args) +{ + return make_src(std::forward(args)...); +} + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/source.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/source.hpp new file mode 100644 index 0000000..6597cad --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/source.hpp @@ -0,0 +1,62 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_SOURCE_HPP +#define OPENCV_GAPI_STREAMING_SOURCE_HPP + +#include // shared_ptr +#include // is_base_of + +#include // GMetaArg + + +namespace cv { +namespace gapi { +namespace wip { + struct Data; // "forward-declaration" of GRunArg + +/** + * @brief Abstract streaming pipeline source. + * + * Implement this interface if you want customize the way how data is + * streaming into GStreamingCompiled. + * + * Objects implementing this interface can be passed to + * GStreamingCompiled using setSource() with cv::gin(). Regular + * compiled graphs (GCompiled) don't support input objects of this + * type. + * + * Default cv::VideoCapture-based implementation is available, see + * cv::gapi::wip::GCaptureSource. + * + * @note stream sources are passed to G-API via shared pointers, so + * please use ptr() when passing a IStreamSource implementation to + * cv::gin(). + */ +class IStreamSource: public std::enable_shared_from_this +{ +public: + using Ptr = std::shared_ptr; + Ptr ptr() { return shared_from_this(); } + virtual bool pull(Data &data) = 0; + virtual GMetaArg descr_of() const = 0; + virtual ~IStreamSource() = default; +}; + +template +IStreamSource::Ptr inline make_src(Args&&... args) +{ + static_assert(std::is_base_of::value, + "T must implement the cv::gapi::IStreamSource interface!"); + auto src_ptr = std::make_shared(std::forward(args)...); + return src_ptr->ptr(); +} + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_SOURCE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/sync.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/sync.hpp new file mode 100644 index 0000000..5801e6f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/streaming/sync.hpp @@ -0,0 +1,30 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_SYNC_HPP +#define OPENCV_GAPI_STREAMING_SYNC_HPP + +namespace cv { +namespace gapi { +namespace streaming { + +enum class sync_policy { + dont_sync, + drop +}; + +} // namespace streaming +} // namespace gapi + +namespace detail { + template<> struct CompileArgTag { + static const char* tag() { return "gapi.streaming.sync_policy"; } + }; + +} // namespace detail +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_SYNC_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/any.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/any.hpp new file mode 100644 index 0000000..94451c7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/any.hpp @@ -0,0 +1,190 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_ANY_HPP +#define OPENCV_GAPI_UTIL_ANY_HPP + +#include +#include +#include +#include + +#include + +#if defined(_MSC_VER) + // disable MSVC warning on "multiple copy constructors specified" +# pragma warning(disable: 4521) +#endif + +namespace cv +{ + +namespace internal +{ + template + T down_cast(Source operand) + { +#if defined(__GXX_RTTI) || defined(_CPPRTTI) + return dynamic_cast(operand); +#else +#ifdef __GNUC__ +#warning used static cast instead of dynamic because RTTI is disabled +#else +#pragma message("WARNING: used static cast instead of dynamic because RTTI is disabled") +#endif + return static_cast(operand); +#endif + } +} + +namespace util +{ + class bad_any_cast : public std::bad_cast + { + public: + virtual const char* what() const noexcept override + { + return "Bad any cast"; + } + }; + + //modeled against C++17 std::any + + class any + { + private: + struct holder; + using holder_ptr = std::unique_ptr; + struct holder + { + virtual holder_ptr clone() = 0; + virtual ~holder() = default; + }; + + template + struct holder_impl : holder + { + value_t v; + template + holder_impl(arg_t&& a) : v(std::forward(a)) {} + holder_ptr clone() override { return holder_ptr(new holder_impl (v));} + }; + + holder_ptr hldr; + public: + template + any(value_t&& arg) : hldr(new holder_impl::type>( std::forward(arg))) {} + + any(any const& src) : hldr( src.hldr ? src.hldr->clone() : nullptr) {} + //simple hack in order not to write enable_if for the template constructor + any(any & src) : any (const_cast(src)) {} + + any() = default; + any(any&& ) = default; + + any& operator=(any&&) = default; + + any& operator=(any const& src) + { + any copy(src); + swap(*this, copy); + return *this; + } + + template + friend value_t* any_cast(any* operand); + + template + friend const value_t* any_cast(const any* operand); + + template + friend value_t& unsafe_any_cast(any& operand); + + template + friend const value_t& unsafe_any_cast(const any& operand); + + friend void swap(any & lhs, any& rhs) + { + swap(lhs.hldr, rhs.hldr); + } + + }; + + template + value_t* any_cast(any* operand) + { + auto casted = internal::down_cast::type> *>(operand->hldr.get()); + if (casted){ + return & (casted->v); + } + return nullptr; + } + + template + const value_t* any_cast(const any* operand) + { + auto casted = internal::down_cast::type> *>(operand->hldr.get()); + if (casted){ + return & (casted->v); + } + return nullptr; + } + + template + value_t& any_cast(any& operand) + { + auto ptr = any_cast(&operand); + if (ptr) + { + return *ptr; + } + + throw_error(bad_any_cast()); + } + + + template + const value_t& any_cast(const any& operand) + { + auto ptr = any_cast(&operand); + if (ptr) + { + return *ptr; + } + + throw_error(bad_any_cast()); + } + + template + inline value_t& unsafe_any_cast(any& operand) + { +#ifdef DEBUG + return any_cast(operand); +#else + return static_cast::type> *>(operand.hldr.get())->v; +#endif + } + + template + inline const value_t& unsafe_any_cast(const any& operand) + { +#ifdef DEBUG + return any_cast(operand); +#else + return static_cast::type> *>(operand.hldr.get())->v; +#endif + } + +} // namespace util +} // namespace cv + +#if defined(_MSC_VER) + // Enable "multiple copy constructors specified" back +# pragma warning(default: 4521) +#endif + +#endif // OPENCV_GAPI_UTIL_ANY_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/compiler_hints.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/compiler_hints.hpp new file mode 100644 index 0000000..a41a971 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/compiler_hints.hpp @@ -0,0 +1,19 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + +#ifndef OPENCV_GAPI_UTIL_COMPILER_HINTS_HPP +#define OPENCV_GAPI_UTIL_COMPILER_HINTS_HPP + +namespace cv +{ +namespace util +{ + //! Utility template function to prevent "unused" warnings by various compilers. + template void suppress_unused_warning( const T& ) {} +} // namespace util +} // namespace cv + +#endif /* OPENCV_GAPI_UTIL_COMPILER_HINTS_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/copy_through_move.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/copy_through_move.hpp new file mode 100644 index 0000000..1a1121e --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/copy_through_move.hpp @@ -0,0 +1,34 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_UTIL_COPY_THROUGH_MOVE_HPP +#define OPENCV_GAPI_UTIL_COPY_THROUGH_MOVE_HPP + +#include //decay_t + +namespace cv +{ +namespace util +{ + //This is a tool to move initialize captures of a lambda in C++11 + template + struct copy_through_move_t{ + T value; + const T& get() const {return value;} + T& get() {return value;} + copy_through_move_t(T&& g) : value(std::move(g)) {} + copy_through_move_t(copy_through_move_t&&) = default; + copy_through_move_t(copy_through_move_t const& lhs) : copy_through_move_t(std::move(const_cast(lhs))) {} + }; + + template + copy_through_move_t> copy_through_move(T&& t){ + return std::forward(t); + } +} // namespace util +} // namespace cv + +#endif /* OPENCV_GAPI_UTIL_COPY_THROUGH_MOVE_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/optional.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/optional.hpp new file mode 100644 index 0000000..dca03ca --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/optional.hpp @@ -0,0 +1,178 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_OPTIONAL_HPP +#define OPENCV_GAPI_UTIL_OPTIONAL_HPP + +#include + +// A poor man's `optional` implementation, incompletely modeled against C++17 spec. +namespace cv +{ +namespace util +{ + class bad_optional_access: public std::exception + { + public: + virtual const char *what() const noexcept override + { + return "Bad optional access"; + } + }; + + // TODO: nullopt_t + + // Interface /////////////////////////////////////////////////////////////// + template class optional + { + public: + // Constructors + // NB.: there were issues with Clang 3.8 when =default() was used + // instead {} + optional() {} + optional(const optional&) = default; + explicit optional(T&&) noexcept; + explicit optional(const T&) noexcept; + optional(optional&&) noexcept; + // TODO: optional(nullopt_t) noexcept; + // TODO: optional(const optional &) + // TODO: optional(optional &&) + // TODO: optional(Args&&...) + // TODO: optional(initializer_list) + // TODO: optional(U&& value); + + // Assignment + optional& operator=(const optional&) = default; + optional& operator=(optional&&); + + // Observers + T* operator-> (); + const T* operator-> () const; + T& operator* (); + const T& operator* () const; + // TODO: && versions + + operator bool() const noexcept; + bool has_value() const noexcept; + + T& value(); + const T& value() const; + // TODO: && versions + + template + T value_or(U &&default_value) const; + + void swap(optional &other) noexcept; + void reset() noexcept; + // TODO: emplace + + // TODO: operator==, !=, <, <=, >, >= + + private: + struct nothing {}; + util::variant m_holder; + }; + + template + optional::type> make_optional(T&& value); + + // TODO: Args... and initializer_list versions + + // Implementation ////////////////////////////////////////////////////////// + template optional::optional(T &&v) noexcept + : m_holder(std::move(v)) + { + } + + template optional::optional(const T &v) noexcept + : m_holder(v) + { + } + + template optional::optional(optional&& rhs) noexcept + : m_holder(std::move(rhs.m_holder)) + { + rhs.reset(); + } + + template optional& optional::operator=(optional&& rhs) + { + m_holder = std::move(rhs.m_holder); + rhs.reset(); + return *this; + } + + template T* optional::operator-> () + { + return & *(*this); + } + + template const T* optional::operator-> () const + { + return & *(*this); + } + + template T& optional::operator* () + { + return this->value(); + } + + template const T& optional::operator* () const + { + return this->value(); + } + + template optional::operator bool() const noexcept + { + return this->has_value(); + } + + template bool optional::has_value() const noexcept + { + return util::holds_alternative(m_holder); + } + + template T& optional::value() + { + if (!this->has_value()) + throw_error(bad_optional_access()); + return util::get(m_holder); + } + + template const T& optional::value() const + { + if (!this->has_value()) + throw_error(bad_optional_access()); + return util::get(m_holder); + } + + template + template T optional::value_or(U &&default_value) const + { + return (this->has_value() ? this->value() : T(default_value)); + } + + template void optional::swap(optional &other) noexcept + { + m_holder.swap(other.m_holder); + } + + template void optional::reset() noexcept + { + if (this->has_value()) + m_holder = nothing{}; + } + + template + optional::type> make_optional(T&& value) + { + return optional::type>(std::forward(value)); + } +} // namespace util +} // namespace cv + +#endif // OPENCV_GAPI_UTIL_OPTIONAL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/throw.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/throw.hpp new file mode 100644 index 0000000..689bf58 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/throw.hpp @@ -0,0 +1,36 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_THROW_HPP +#define OPENCV_GAPI_UTIL_THROW_HPP + +#include // std::forward + +#if !defined(__EXCEPTIONS) +#include +#include +#endif + +namespace cv +{ +namespace util +{ +template +[[noreturn]] void throw_error(ExceptionType &&e) +{ +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) + throw std::forward(e); +#else + fprintf(stderr, "An exception thrown! %s\n" , e.what()); + fflush(stderr); + abort(); +#endif +} +} // namespace util +} // namespace cv + +#endif // OPENCV_GAPI_UTIL_THROW_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/type_traits.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/type_traits.hpp new file mode 100644 index 0000000..637f184 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/type_traits.hpp @@ -0,0 +1,31 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_TYPE_TRAITS_HPP +#define OPENCV_GAPI_UTIL_TYPE_TRAITS_HPP + +#include + +namespace cv +{ +namespace util +{ + //these are C++14 parts of type_traits : + template< bool B, class T = void > + using enable_if_t = typename std::enable_if::type; + + template + using decay_t = typename std::decay::type; + + //this is not part of C++14 but still, of pretty common usage + template + using are_different_t = enable_if_t< !std::is_same, decay_t>::value, V>; + +} // namespace cv +} // namespace util + +#endif // OPENCV_GAPI_UTIL_TYPE_TRAITS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/util.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/util.hpp new file mode 100644 index 0000000..3be46d7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/util.hpp @@ -0,0 +1,190 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_HPP +#define OPENCV_GAPI_UTIL_HPP + +#include + +// \cond HIDDEN_SYMBOLS +// This header file contains some generic utility functions which are +// used in other G-API Public API headers. +// +// PLEASE don't put any stuff here if it is NOT used in public API headers! + +namespace cv +{ +namespace detail +{ + // Recursive integer sequence type, useful for enumerating elements of + // template parameter packs. + template struct Seq { using next = Seq; }; + template struct MkSeq { using type = typename MkSeq::type::next; }; + template<> struct MkSeq<0>{ using type = Seq<>; }; + + // Checks if elements of variadic template satisfy the given Predicate. + // Implemented via tuple, with an interface to accept plain type lists + template class, typename, typename...> struct all_satisfy; + + template class F, typename T, typename... Ts> + struct all_satisfy > + { + static const constexpr bool value = F::value + && all_satisfy >::value; + }; + template class F, typename T> + struct all_satisfy > + { + static const constexpr bool value = F::value; + }; + + template class F, typename T, typename... Ts> + struct all_satisfy: public all_satisfy > {}; + + // Permute given tuple type C with given integer sequence II + // Sequence may be less than tuple C size. + template struct permute_tuple; + + template + struct permute_tuple > + { + using type = std::tuple< typename std::tuple_element::type... >; + }; + + // Given T..., generates a type sequence of sizeof...(T)-1 elements + // which is T... without its last element + // Implemented via tuple, with an interface to accept plain type lists + template struct all_but_last; + + template + struct all_but_last > + { + using C = std::tuple; + using S = typename MkSeq::value - 1>::type; + using type = typename permute_tuple::type; + }; + + template + struct all_but_last: public all_but_last > {}; + + template + using all_but_last_t = typename all_but_last::type; + + // NB.: This is here because there's no constexpr std::max in C++11 + template struct max_of_t + { + static constexpr const std::size_t rest = max_of_t::value; + static constexpr const std::size_t value = rest > S0 ? rest : S0; + }; + template struct max_of_t + { + static constexpr const std::size_t value = S; + }; + + template + struct contains : std::false_type{}; + + template + struct contains : std::integral_constant::value || + contains::value> {}; + template + struct contains> : std::integral_constant::value> {}; + + template + struct all_unique : std::true_type{}; + + template + struct all_unique : std::integral_constant::value && + all_unique::value> {}; + + template + struct tuple_wrap_helper; + + template struct tuple_wrap_helper + { + using type = std::tuple; + static type get(T&& obj) { return std::make_tuple(std::move(obj)); } + }; + + template + struct tuple_wrap_helper> + { + using type = std::tuple; + static type get(std::tuple&& objs) { return std::forward>(objs); } + }; + + template + struct make_void { typedef void type;}; + + template + using void_t = typename make_void::type; + +} // namespace detail + +namespace util +{ +template +struct overload_lamba_set; + +template +struct overload_lamba_set : public L1 +{ + overload_lamba_set(L1&& lambda) : L1(std::move(lambda)) {} + overload_lamba_set(const L1& lambda) : L1(lambda) {} + + using L1::operator(); +}; + +template +struct overload_lamba_set : public L1, public overload_lamba_set +{ + using base_type = overload_lamba_set; + overload_lamba_set(L1 &&lambda1, L&& ...lambdas): + L1(std::move(lambda1)), + base_type(std::forward(lambdas)...) {} + + overload_lamba_set(const L1 &lambda1, L&& ...lambdas): + L1(lambda1), + base_type(std::forward(lambdas)...) {} + + using L1::operator(); + using base_type::operator(); +}; + +template +overload_lamba_set overload_lambdas(L&& ...lambdas) +{ + return overload_lamba_set(std::forward(lambdas)...); +} + +template +struct find_adapter_impl; + +template +struct find_adapter_impl +{ + using type = typename std::conditional::value, + T, + void>::type; + static constexpr bool found = std::is_base_of::value; +}; + +template +struct find_adapter_impl +{ + using type = typename std::conditional::value, + T, + typename find_adapter_impl::type>::type; + static constexpr bool found = std::is_base_of::value || + find_adapter_impl::found; +}; +} // namespace util +} // namespace cv + +// \endcond + +#endif // OPENCV_GAPI_UTIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/variant.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/variant.hpp new file mode 100644 index 0000000..f412110 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/util/variant.hpp @@ -0,0 +1,658 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_VARIANT_HPP +#define OPENCV_GAPI_UTIL_VARIANT_HPP + +#include +#include + +#include +#include +#include // max_of_t +#include + +// A poor man's `variant` implementation, incompletely modeled against C++17 spec. +namespace cv +{ +namespace util +{ + namespace detail + { + template + struct type_list_index_helper + { + static const constexpr bool is_same = std::is_same::value; + static const constexpr std::size_t value = + std::conditional, type_list_index_helper>::type::value; + }; + + template + struct type_list_index_helper + { + static_assert(std::is_same::value, "Type not found"); + static const constexpr std::size_t value = I; + }; + } + + template + struct type_list_index + { + static const constexpr std::size_t value = detail::type_list_index_helper<0, Target, Types...>::value; + }; + + template + struct type_list_element + { + using type = typename std::tuple_element >::type; + }; + + class bad_variant_access: public std::exception + { + public: + virtual const char *what() const noexcept override + { + return "Bad variant access"; + } + }; + + // Interface /////////////////////////////////////////////////////////////// + struct monostate {}; + inline bool operator==(const util::monostate&, const util::monostate&) + { + return true; + } + + template // FIXME: no references, arrays, and void + class variant + { + // FIXME: Replace with std::aligned_union after gcc4.8 support is dropped + static constexpr const std::size_t S = cv::detail::max_of_t::value; + static constexpr const std::size_t A = cv::detail::max_of_t::value; + using Memory = typename std::aligned_storage::type[1]; + + template struct cctr_h { + static void help(Memory memory, const Memory from) { + new (memory) T(*reinterpret_cast(from)); + } + }; + + template struct mctr_h { + static void help(Memory memory, void *pval) { + new (memory) T(std::move(*reinterpret_cast(pval))); + } + }; + + //FIXME: unify with cctr_h and mctr_h + template struct cnvrt_ctor_h { + static void help(Memory memory, void* from) { + using util::decay_t; + new (memory) decay_t(std::forward(*reinterpret_cast*>(from))); + } + }; + + template struct copy_h { + static void help(Memory to, const Memory from) { + *reinterpret_cast(to) = *reinterpret_cast(from); + } + }; + + template struct move_h { + static void help(Memory to, Memory from) { + *reinterpret_cast(to) = std::move(*reinterpret_cast(from)); + } + }; + + //FIXME: unify with copy_h and move_h + template struct cnvrt_assign_h { + static void help(Memory to, void* from) { + using util::decay_t; + *reinterpret_cast*>(to) = std::forward(*reinterpret_cast*>(from)); + } + }; + + template struct swap_h { + static void help(Memory to, Memory from) { + std::swap(*reinterpret_cast(to), *reinterpret_cast(from)); + } + }; + + template struct dtor_h { + static void help(Memory memory) { + (void) memory; // MSCV warning + reinterpret_cast(memory)->~T(); + } + }; + + template struct equal_h { + static bool help(const Memory lhs, const Memory rhs) { + const T& t_lhs = *reinterpret_cast(lhs); + const T& t_rhs = *reinterpret_cast(rhs); + return t_lhs == t_rhs; + } + }; + + typedef void (*CCtr) (Memory, const Memory); // Copy c-tor (variant) + typedef void (*MCtr) (Memory, void*); // Generic move c-tor + typedef void (*Copy) (Memory, const Memory); // Copy assignment + typedef void (*Move) (Memory, Memory); // Move assignment + + typedef void (*Swap) (Memory, Memory); // Swap + typedef void (*Dtor) (Memory); // Destructor + + using cnvrt_assgn_t = void (*) (Memory, void*); // Converting assignment (via std::forward) + using cnvrt_ctor_t = void (*) (Memory, void*); // Converting constructor (via std::forward) + + typedef bool (*Equal)(const Memory, const Memory); // Equality test (external) + + static constexpr std::array cctrs(){ return {{(&cctr_h::help)...}};} + static constexpr std::array mctrs(){ return {{(&mctr_h::help)...}};} + static constexpr std::array cpyrs(){ return {{(©_h::help)...}};} + static constexpr std::array mvers(){ return {{(&move_h::help)...}};} + static constexpr std::array swprs(){ return {{(&swap_h::help)...}};} + static constexpr std::array dtors(){ return {{(&dtor_h::help)...}};} + + template + struct conditional_ref : std::conditional::type&, typename std::remove_reference::type > {}; + + template + using conditional_ref_t = typename conditional_ref::type; + + + template + static constexpr std::array cnvrt_assgnrs(){ + return {{(&cnvrt_assign_h>::help)...}}; + } + + template + static constexpr std::array cnvrt_ctors(){ + return {{(&cnvrt_ctor_h>::help)...}}; + } + + std::size_t m_index = 0; + + protected: + template friend T& get(variant &v); + template friend const T& get(const variant &v); + template friend T* get_if(variant *v) noexcept; + template friend const T* get_if(const variant *v) noexcept; + + template friend bool operator==(const variant &lhs, + const variant &rhs); + Memory memory; + + public: + // Constructors + variant() noexcept; + variant(const variant& other); + variant(variant&& other) noexcept; + // are_different_t is a SFINAE trick to avoid variant(T &&t) with T=variant + // for some reason, this version is called instead of variant(variant&& o) when + // variant is used in STL containers (examples: vector assignment). + template< + typename T, + typename = util::are_different_t + > + explicit variant(T&& t); + // template explicit variant(Args&&... args); + // FIXME: other constructors + + // Destructor + ~variant(); + + // Assignment + variant& operator=(const variant& rhs); + variant& operator=(variant &&rhs) noexcept; + + // SFINAE trick to avoid operator=(T&&) with T=variant<>, see comment above + template< + typename T, + typename = util::are_different_t + > + variant& operator=(T&& t) noexcept; + + // Observers + std::size_t index() const noexcept; + // FIXME: valueless_by_exception() + + // Modifiers + // FIXME: emplace() + void swap(variant &rhs) noexcept; + + // Non-C++17x! + template static constexpr std::size_t index_of(); + }; + + // FIMXE: visit + template + T* get_if(util::variant* v) noexcept; + + template + const T* get_if(const util::variant* v) noexcept; + + template + T& get(util::variant &v); + + template + const T& get(const util::variant &v); + + template + typename util::type_list_element::type& get(util::variant &v); + + template + const typename util::type_list_element::type& get(const util::variant &v); + + template + bool holds_alternative(const util::variant &v) noexcept; + + + // Visitor + namespace detail + { + struct visitor_interface {}; + + // Class `visitor_return_type_deduction_helper` + // introduces solution for deduction `return_type` in `visit` function in common way + // for both Lambda and class Visitor and keep one interface invocation point: `visit` only + // his helper class is required to unify return_type deduction mechanism because + // for Lambda it is possible to take type of `decltype(visitor(get<0>(var)))` + // but for class Visitor there is no operator() in base case, + // because it provides `operator() (std::size_t index, ...)` + // So `visitor_return_type_deduction_helper` expose `operator()` + // uses only for class Visitor only for deduction `return type` in visit() + template + struct visitor_return_type_deduction_helper + { + using return_type = R; + + // to be used in Lambda return type deduction context only + template + return_type operator() (T&&); + }; + } + + // Special purpose `static_visitor` can receive additional arguments + template + struct static_visitor : public detail::visitor_interface, + public detail::visitor_return_type_deduction_helper { + + // assign responsibility for return type deduction to helper class + using return_type = typename detail::visitor_return_type_deduction_helper::return_type; + using detail::visitor_return_type_deduction_helper::operator(); + friend Impl; + + template + return_type operator() (std::size_t index, VariantValue&& value, Args&& ...args) + { + suppress_unused_warning(index); + return static_cast(this)-> visit( + std::forward(value), + std::forward(args)...); + } + }; + + // Special purpose `static_indexed_visitor` can receive additional arguments + // And make forwarding current variant index as runtime function argument to its `Impl` + template + struct static_indexed_visitor : public detail::visitor_interface, + public detail::visitor_return_type_deduction_helper { + + // assign responsibility for return type deduction to helper class + using return_type = typename detail::visitor_return_type_deduction_helper::return_type; + using detail::visitor_return_type_deduction_helper::operator(); + friend Impl; + + template + return_type operator() (std::size_t Index, VariantValue&& value, Args&& ...args) + { + return static_cast(this)-> visit(Index, + std::forward(value), + std::forward(args)...); + } + }; + + template + struct variant_size; + + template + struct variant_size> + : std::integral_constant { }; + // FIXME: T&&, const TT&& versions. + + // Implementation ////////////////////////////////////////////////////////// + template + variant::variant() noexcept + { + typedef typename std::tuple_element<0, std::tuple >::type TFirst; + new (memory) TFirst(); + } + + template + variant::variant(const variant &other) + : m_index(other.m_index) + { + (cctrs()[m_index])(memory, other.memory); + } + + template + variant::variant(variant &&other) noexcept + : m_index(other.m_index) + { + (mctrs()[m_index])(memory, other.memory); + } + + template + template + variant::variant(T&& t) + : m_index(util::type_list_index, Ts...>::value) + { + const constexpr bool is_lvalue_arg = std::is_lvalue_reference::value; + (cnvrt_ctors()[m_index])(memory, const_cast *>(&t)); + } + + template + variant::~variant() + { + (dtors()[m_index])(memory); + } + + template + variant& variant::operator=(const variant &rhs) + { + if (m_index != rhs.m_index) + { + (dtors()[ m_index])(memory); + (cctrs()[rhs.m_index])(memory, rhs.memory); + m_index = rhs.m_index; + } + else + { + (cpyrs()[rhs.m_index])(memory, rhs.memory); + } + return *this; + } + + template + variant& variant::operator=(variant &&rhs) noexcept + { + if (m_index != rhs.m_index) + { + (dtors()[ m_index])(memory); + (mctrs()[rhs.m_index])(memory, rhs.memory); + m_index = rhs.m_index; + } + else + { + (mvers()[rhs.m_index])(memory, rhs.memory); + } + return *this; + } + + template + template + variant& variant::operator=(T&& t) noexcept + { + using decayed_t = util::decay_t; + // FIXME: No version with implicit type conversion available! + const constexpr std::size_t t_index = + util::type_list_index::value; + + const constexpr bool is_lvalue_arg = std::is_lvalue_reference::value; + + if (t_index != m_index) + { + (dtors()[m_index])(memory); + (cnvrt_ctors()[t_index])(memory, &t); + m_index = t_index; + } + else + { + (cnvrt_assgnrs()[m_index])(memory, &t); + } + return *this; + + } + + template + std::size_t util::variant::index() const noexcept + { + return m_index; + } + + template + void variant::swap(variant &rhs) noexcept + { + if (m_index == rhs.index()) + { + (swprs()[m_index](memory, rhs.memory)); + } + else + { + variant tmp(std::move(*this)); + *this = std::move(rhs); + rhs = std::move(tmp); + } + } + + template + template + constexpr std::size_t variant::index_of() + { + return util::type_list_index::value; // FIXME: tests! + } + + template + T* get_if(util::variant* v) noexcept + { + const constexpr std::size_t t_index = + util::type_list_index::value; + + if (v && v->index() == t_index) + return (T*)(&v->memory); // workaround for ICC 2019 + // original code: return reinterpret_cast(v.memory); + return nullptr; + } + + template + const T* get_if(const util::variant* v) noexcept + { + const constexpr std::size_t t_index = + util::type_list_index::value; + + if (v && v->index() == t_index) + return (const T*)(&v->memory); // workaround for ICC 2019 + // original code: return reinterpret_cast(v.memory); + return nullptr; + } + + template + T& get(util::variant &v) + { + if (auto* p = get_if(&v)) + return *p; + else + throw_error(bad_variant_access()); + } + + template + const T& get(const util::variant &v) + { + if (auto* p = get_if(&v)) + return *p; + else + throw_error(bad_variant_access()); + } + + template + typename util::type_list_element::type& get(util::variant &v) + { + using ReturnType = typename util::type_list_element::type; + return const_cast(get(static_cast &>(v))); + } + + template + const typename util::type_list_element::type& get(const util::variant &v) + { + static_assert(Index < sizeof...(Types), + "`Index` it out of bound of `util::variant` type list"); + using ReturnType = typename util::type_list_element::type; + return get(v); + } + + template + bool holds_alternative(const util::variant &v) noexcept + { + return v.index() == util::variant::template index_of(); + } + + template bool operator==(const variant &lhs, + const variant &rhs) + { + using V = variant; + + // Instantiate table only here since it requires operator== for + // should have operator== only if this one is used, not in general + static const std::array eqs = { + {(&V::template equal_h::help)...} + }; + if (lhs.index() != rhs.index()) + return false; + return (eqs[lhs.index()])(lhs.memory, rhs.memory); + } + + template bool operator!=(const variant &lhs, + const variant &rhs) + { + return !(lhs == rhs); + } + +namespace detail +{ + // terminate recursion implementation for `non-void` ReturnType + template + ReturnType apply_visitor_impl(Visitor&&, Variant&, + std::true_type, std::false_type, + VisitorArgs&& ...) + { + return {}; + } + + // terminate recursion implementation for `void` ReturnType + template + void apply_visitor_impl(Visitor&&, Variant&, + std::true_type, std::true_type, + VisitorArgs&& ...) + { + } + + // Intermediate resursion processor for Lambda Visitors + template + typename std::enable_if::type>::value, ReturnType>::type + apply_visitor_impl(Visitor&& visitor, Variant&& v, std::false_type not_processed, + std::integral_constant should_no_return, + VisitorArgs&& ...args) + { + static_assert(std::is_same(v)))>::value, + "Different `ReturnType`s detected! All `Visitor::visit` or `overload_lamba_set`" + " must return the same type"); + suppress_unused_warning(not_processed); + if (v.index() == CurIndex) + { + return visitor.operator()(get(v), std::forward(args)... ); + } + + using is_variant_processed_t = std::integral_constant= ElemCount>; + return apply_visitor_impl( + std::forward(visitor), + std::forward(v), + is_variant_processed_t{}, + should_no_return, + std::forward(args)...); + } + + //Visual Studio 2014 compilation fix: cast visitor to base class before invoke operator() + template + typename std::enable_if::type>, + typename std::decay::type>::value, ReturnType>::type + invoke_class_visitor(Visitor& visitor, Value&& v, VisitorArgs&&...args) + { + return static_cast::type>&>(visitor).operator() (CurIndex, std::forward(v), std::forward(args)... ); + } + + //Visual Studio 2014 compilation fix: cast visitor to base class before invoke operator() + template + typename std::enable_if::type>, + typename std::decay::type>::value, ReturnType>::type + invoke_class_visitor(Visitor& visitor, Value&& v, VisitorArgs&&...args) + { + return static_cast::type>&>(visitor).operator() (CurIndex, std::forward(v), std::forward(args)... ); + } + + // Intermediate recursion processor for special case `visitor_interface` derived Visitors + template + typename std::enable_if::type>::value, ReturnType>::type + apply_visitor_impl(Visitor&& visitor, Variant&& v, std::false_type not_processed, + std::integral_constant should_no_return, + VisitorArgs&& ...args) + { + static_assert(std::is_same(v)))>::value, + "Different `ReturnType`s detected! All `Visitor::visit` or `overload_lamba_set`" + " must return the same type"); + suppress_unused_warning(not_processed); + if (v.index() == CurIndex) + { + return invoke_class_visitor(visitor, get(v), std::forward(args)... ); + } + + using is_variant_processed_t = std::integral_constant= ElemCount>; + return apply_visitor_impl( + std::forward(visitor), + std::forward(v), + is_variant_processed_t{}, + should_no_return, + std::forward(args)...); + } +} // namespace detail + + template + auto visit(Visitor &visitor, const Variant& var, VisitorArg &&...args) -> decltype(visitor(get<0>(var))) + { + constexpr std::size_t varsize = util::variant_size::value; + static_assert(varsize != 0, "utils::variant must contains one type at least "); + using is_variant_processed_t = std::false_type; + + using ReturnType = decltype(visitor(get<0>(var))); + using return_t = std::is_same; + return detail::apply_visitor_impl( + std::forward(visitor), + var, is_variant_processed_t{}, + return_t{}, + std::forward(args)...); + } + + template + auto visit(Visitor&& visitor, const Variant& var) -> decltype(visitor(get<0>(var))) + { + constexpr std::size_t varsize = util::variant_size::value; + static_assert(varsize != 0, "utils::variant must contains one type at least "); + using is_variant_processed_t = std::false_type; + + using ReturnType = decltype(visitor(get<0>(var))); + using return_t = std::is_same; + return detail::apply_visitor_impl( + std::forward(visitor), + var, is_variant_processed_t{}, + return_t{}); + } +} // namespace util +} // namespace cv + +#endif // OPENCV_GAPI_UTIL_VARIANT_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/gapi/video.hpp b/Cigarette/OpenCV455Simple/include/opencv2/gapi/video.hpp new file mode 100644 index 0000000..4dcc1d4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/gapi/video.hpp @@ -0,0 +1,364 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_VIDEO_HPP +#define OPENCV_GAPI_VIDEO_HPP + +#include // std::tuple + +#include + + +/** \defgroup gapi_video G-API Video processing functionality + */ + +namespace cv { namespace gapi { + +/** @brief Structure for the Kalman filter's initialization parameters.*/ + +struct GAPI_EXPORTS KalmanParams +{ + // initial state + + //! corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) + Mat state; + //! posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) + Mat errorCov; + + // dynamic system description + + //! state transition matrix (A) + Mat transitionMatrix; + //! measurement matrix (H) + Mat measurementMatrix; + //! process noise covariance matrix (Q) + Mat processNoiseCov; + //! measurement noise covariance matrix (R) + Mat measurementNoiseCov; + //! control matrix (B) (Optional: not used if there's no control) + Mat controlMatrix; +}; + +/** + * @brief This namespace contains G-API Operations and functions for + * video-oriented algorithms, like optical flow and background subtraction. + */ +namespace video +{ +using GBuildPyrOutput = std::tuple, GScalar>; + +using GOptFlowLKOutput = std::tuple, + cv::GArray, + cv::GArray>; + +G_TYPED_KERNEL(GBuildOptFlowPyramid, , + "org.opencv.video.buildOpticalFlowPyramid") +{ + static std::tuple + outMeta(GMatDesc,const Size&,GScalarDesc,bool,int,int,bool) + { + return std::make_tuple(empty_array_desc(), empty_scalar_desc()); + } +}; + +G_TYPED_KERNEL(GCalcOptFlowLK, + ,cv::GArray,Size, + GScalar,TermCriteria,int,double)>, + "org.opencv.video.calcOpticalFlowPyrLK") +{ + static std::tuple outMeta(GMatDesc,GMatDesc,GArrayDesc, + GArrayDesc,const Size&,GScalarDesc, + const TermCriteria&,int,double) + { + return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc()); + } + +}; + +G_TYPED_KERNEL(GCalcOptFlowLKForPyr, + ,cv::GArray, + cv::GArray,cv::GArray,Size,GScalar, + TermCriteria,int,double)>, + "org.opencv.video.calcOpticalFlowPyrLKForPyr") +{ + static std::tuple outMeta(GArrayDesc,GArrayDesc, + GArrayDesc,GArrayDesc, + const Size&,GScalarDesc, + const TermCriteria&,int,double) + { + return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc()); + } +}; + +enum BackgroundSubtractorType +{ + TYPE_BS_MOG2, + TYPE_BS_KNN +}; + +/** @brief Structure for the Background Subtractor operation's initialization parameters.*/ + +struct BackgroundSubtractorParams +{ + //! Type of the Background Subtractor operation. + BackgroundSubtractorType operation = TYPE_BS_MOG2; + + //! Length of the history. + int history = 500; + + //! For MOG2: Threshold on the squared Mahalanobis distance between the pixel + //! and the model to decide whether a pixel is well described by + //! the background model. + //! For KNN: Threshold on the squared distance between the pixel and the sample + //! to decide whether a pixel is close to that sample. + double threshold = 16; + + //! If true, the algorithm will detect shadows and mark them. + bool detectShadows = true; + + //! The value between 0 and 1 that indicates how fast + //! the background model is learnt. + //! Negative parameter value makes the algorithm use some automatically + //! chosen learning rate. + double learningRate = -1; + + //! default constructor + BackgroundSubtractorParams() {} + + /** Full constructor + @param op MOG2/KNN Background Subtractor type. + @param histLength Length of the history. + @param thrshld For MOG2: Threshold on the squared Mahalanobis distance between + the pixel and the model to decide whether a pixel is well described by the background model. + For KNN: Threshold on the squared distance between the pixel and the sample to decide + whether a pixel is close to that sample. + @param detect If true, the algorithm will detect shadows and mark them. It decreases the + speed a bit, so if you do not need this feature, set the parameter to false. + @param lRate The value between 0 and 1 that indicates how fast the background model is learnt. + Negative parameter value makes the algorithm to use some automatically chosen learning rate. + */ + BackgroundSubtractorParams(BackgroundSubtractorType op, int histLength, + double thrshld, bool detect, double lRate) : operation(op), + history(histLength), + threshold(thrshld), + detectShadows(detect), + learningRate(lRate){} +}; + +G_TYPED_KERNEL(GBackgroundSubtractor, , + "org.opencv.video.BackgroundSubtractor") +{ + static GMatDesc outMeta(const GMatDesc& in, const BackgroundSubtractorParams& bsParams) + { + GAPI_Assert(bsParams.history >= 0); + GAPI_Assert(bsParams.learningRate <= 1); + return in.withType(CV_8U, 1); + } +}; + +void checkParams(const cv::gapi::KalmanParams& kfParams, + const cv::GMatDesc& measurement, const cv::GMatDesc& control = {}); + +G_TYPED_KERNEL(GKalmanFilter, , GMat, KalmanParams)>, + "org.opencv.video.KalmanFilter") +{ + static GMatDesc outMeta(const GMatDesc& measurement, const GOpaqueDesc&, + const GMatDesc& control, const KalmanParams& kfParams) + { + checkParams(kfParams, measurement, control); + return measurement.withSize(Size(1, kfParams.transitionMatrix.rows)); + } +}; + +G_TYPED_KERNEL(GKalmanFilterNoControl, , KalmanParams)>, "org.opencv.video.KalmanFilterNoControl") +{ + static GMatDesc outMeta(const GMatDesc& measurement, const GOpaqueDesc&, const KalmanParams& kfParams) + { + checkParams(kfParams, measurement); + return measurement.withSize(Size(1, kfParams.transitionMatrix.rows)); + } +}; +} //namespace video + +//! @addtogroup gapi_video +//! @{ +/** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK. + +@note Function textual ID is "org.opencv.video.buildOpticalFlowPyramid" + +@param img 8-bit input image. +@param winSize window size of optical flow algorithm. Must be not less than winSize + argument of calcOpticalFlowPyrLK. It is needed to calculate required + padding for pyramid levels. +@param maxLevel 0-based maximal pyramid level number. +@param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is + constructed without the gradients then calcOpticalFlowPyrLK will calculate + them internally. +@param pyrBorder the border mode for pyramid layers. +@param derivBorder the border mode for gradients. +@param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false + to force data copying. + +@return + - output pyramid. + - number of levels in constructed pyramid. Can be less than maxLevel. + */ +GAPI_EXPORTS std::tuple, GScalar> +buildOpticalFlowPyramid(const GMat &img, + const Size &winSize, + const GScalar &maxLevel, + bool withDerivatives = true, + int pyrBorder = BORDER_REFLECT_101, + int derivBorder = BORDER_CONSTANT, + bool tryReuseInputImage = true); + +/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade +method with pyramids. + +See @cite Bouguet00 . + +@note Function textual ID is "org.opencv.video.calcOpticalFlowPyrLK" + +@param prevImg first 8-bit input image (GMat) or pyramid (GArray) constructed by +buildOpticalFlowPyramid. +@param nextImg second input image (GMat) or pyramid (GArray) of the same size and the same +type as prevImg. +@param prevPts GArray of 2D points for which the flow needs to be found; point coordinates must be +single-precision floating-point numbers. +@param predPts GArray of 2D points initial for the flow search; make sense only when +OPTFLOW_USE_INITIAL_FLOW flag is passed; in that case the vector must have the same size as in +the input. +@param winSize size of the search window at each pyramid level. +@param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single +level), if set to 1, two levels are used, and so on; if pyramids are passed to input then +algorithm will use as many levels as pyramids have but no more than maxLevel. +@param criteria parameter, specifying the termination criteria of the iterative search algorithm +(after the specified maximum number of iterations criteria.maxCount or when the search window +moves by less than criteria.epsilon). +@param flags operation flags: + - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is + not set, then prevPts is copied to nextPts and is considered the initial estimate. + - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see + minEigThreshold description); if the flag is not set, then L1 distance between patches + around the original and a moved point, divided by number of pixels in a window, is used as a + error measure. +@param minEigThresh the algorithm calculates the minimum eigen value of a 2x2 normal matrix of +optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided +by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding +feature is filtered out and its flow is not processed, so it allows to remove bad points and get a +performance boost. + +@return + - GArray of 2D points (with single-precision floating-point coordinates) +containing the calculated new positions of input features in the second image. + - status GArray (of unsigned chars); each element of the vector is set to 1 if +the flow for the corresponding features has been found, otherwise, it is set to 0. + - GArray of errors (doubles); each element of the vector is set to an error for the +corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't +found then the error is not defined (use the status parameter to find such cases). + */ +GAPI_EXPORTS std::tuple, GArray, GArray> +calcOpticalFlowPyrLK(const GMat &prevImg, + const GMat &nextImg, + const GArray &prevPts, + const GArray &predPts, + const Size &winSize = Size(21, 21), + const GScalar &maxLevel = 3, + const TermCriteria &criteria = TermCriteria(TermCriteria::COUNT | + TermCriteria::EPS, + 30, 0.01), + int flags = 0, + double minEigThresh = 1e-4); + +/** +@overload +@note Function textual ID is "org.opencv.video.calcOpticalFlowPyrLKForPyr" +*/ +GAPI_EXPORTS std::tuple, GArray, GArray> +calcOpticalFlowPyrLK(const GArray &prevPyr, + const GArray &nextPyr, + const GArray &prevPts, + const GArray &predPts, + const Size &winSize = Size(21, 21), + const GScalar &maxLevel = 3, + const TermCriteria &criteria = TermCriteria(TermCriteria::COUNT | + TermCriteria::EPS, + 30, 0.01), + int flags = 0, + double minEigThresh = 1e-4); + +/** @brief Gaussian Mixture-based or K-nearest neighbours-based Background/Foreground Segmentation Algorithm. +The operation generates a foreground mask. + +@return Output image is foreground mask, i.e. 8-bit unsigned 1-channel (binary) matrix @ref CV_8UC1. + +@note Functional textual ID is "org.opencv.video.BackgroundSubtractor" + +@param src input image: Floating point frame is used without scaling and should be in range [0,255]. +@param bsParams Set of initialization parameters for Background Subtractor kernel. +*/ +GAPI_EXPORTS GMat BackgroundSubtractor(const GMat& src, const cv::gapi::video::BackgroundSubtractorParams& bsParams); + +/** @brief Standard Kalman filter algorithm . + +@note Functional textual ID is "org.opencv.video.KalmanFilter" + +@param measurement input matrix: 32-bit or 64-bit float 1-channel matrix containing measurements. +@param haveMeasurement dynamic input flag that indicates whether we get measurements +at a particular iteration . +@param control input matrix: 32-bit or 64-bit float 1-channel matrix contains control data +for changing dynamic system. +@param kfParams Set of initialization parameters for Kalman filter kernel. + +@return Output matrix is predicted or corrected state. They can be 32-bit or 64-bit float +1-channel matrix @ref CV_32FC1 or @ref CV_64FC1. + +@details If measurement matrix is given (haveMeasurements == true), corrected state will +be returned which corresponds to the pipeline +cv::KalmanFilter::predict(control) -> cv::KalmanFilter::correct(measurement). +Otherwise, predicted state will be returned which corresponds to the call of +cv::KalmanFilter::predict(control). +@sa cv::KalmanFilter +*/ +GAPI_EXPORTS GMat KalmanFilter(const GMat& measurement, const GOpaque& haveMeasurement, + const GMat& control, const cv::gapi::KalmanParams& kfParams); + +/** @overload +The case of Standard Kalman filter algorithm when there is no control in a dynamic system. +In this case the controlMatrix is empty and control vector is absent. + +@note Function textual ID is "org.opencv.video.KalmanFilterNoControl" + +@param measurement input matrix: 32-bit or 64-bit float 1-channel matrix containing measurements. +@param haveMeasurement dynamic input flag that indicates whether we get measurements +at a particular iteration. +@param kfParams Set of initialization parameters for Kalman filter kernel. + +@return Output matrix is predicted or corrected state. They can be 32-bit or 64-bit float +1-channel matrix @ref CV_32FC1 or @ref CV_64FC1. + +@sa cv::KalmanFilter + */ +GAPI_EXPORTS GMat KalmanFilter(const GMat& measurement, const GOpaque& haveMeasurement, + const cv::gapi::KalmanParams& kfParams); + +//! @} gapi_video +} //namespace gapi +} //namespace cv + + +namespace cv { namespace detail { +template<> struct CompileArgTag +{ + static const char* tag() + { + return "org.opencv.video.background_substractor_params"; + } +}; +} // namespace detail +} // namespace cv + +#endif // OPENCV_GAPI_VIDEO_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/highgui.hpp b/Cigarette/OpenCV455Simple/include/opencv2/highgui.hpp new file mode 100644 index 0000000..7ae2395 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/highgui.hpp @@ -0,0 +1,868 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HIGHGUI_HPP +#define OPENCV_HIGHGUI_HPP + +#include "opencv2/core.hpp" +#ifdef HAVE_OPENCV_IMGCODECS +#include "opencv2/imgcodecs.hpp" +#endif +#ifdef HAVE_OPENCV_VIDEOIO +#include "opencv2/videoio.hpp" +#endif + +/** +@defgroup highgui High-level GUI + +While OpenCV was designed for use in full-scale applications and can be used within functionally +rich UI frameworks (such as Qt\*, WinForms\*, or Cocoa\*) or without any UI at all, sometimes there +it is required to try functionality quickly and visualize the results. This is what the HighGUI +module has been designed for. + +It provides easy interface to: + +- Create and manipulate windows that can display images and "remember" their content (no need to + handle repaint events from OS). +- Add trackbars to the windows, handle simple mouse events as well as keyboard commands. + +@{ + @defgroup highgui_window_flags Flags related creating and manipulating HighGUI windows and mouse events + @defgroup highgui_opengl OpenGL support + @defgroup highgui_qt Qt New Functions + + ![image](pics/qtgui.png) + + This figure explains new functionality implemented with Qt\* GUI. The new GUI provides a statusbar, + a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it. + If you cannot see the control panel, press Ctrl+P or right-click any Qt window and select **Display + properties window**. + + - To attach a trackbar, the window name parameter must be NULL. + + - To attach a buttonbar, a button must be created. If the last bar attached to the control panel + is a buttonbar, the new button is added to the right of the last button. If the last bar + attached to the control panel is a trackbar, or the control panel is empty, a new buttonbar is + created. Then, a new button is attached to it. + + See below the example used to generate the figure: + @code + int main(int argc, char *argv[]) + { + + int value = 50; + int value2 = 0; + + + namedWindow("main1",WINDOW_NORMAL); + namedWindow("main2",WINDOW_AUTOSIZE | WINDOW_GUI_NORMAL); + createTrackbar( "track1", "main1", &value, 255, NULL); + + String nameb1 = "button1"; + String nameb2 = "button2"; + + createButton(nameb1,callbackButton,&nameb1,QT_CHECKBOX,1); + createButton(nameb2,callbackButton,NULL,QT_CHECKBOX,0); + createTrackbar( "track2", NULL, &value2, 255, NULL); + createButton("button5",callbackButton1,NULL,QT_RADIOBOX,0); + createButton("button6",callbackButton2,NULL,QT_RADIOBOX,1); + + setMouseCallback( "main2",on_mouse,NULL ); + + Mat img1 = imread("files/flower.jpg"); + VideoCapture video; + video.open("files/hockey.avi"); + + Mat img2,img3; + + while( waitKey(33) != 27 ) + { + img1.convertTo(img2,-1,1,value); + video >> img3; + + imshow("main1",img2); + imshow("main2",img3); + } + + destroyAllWindows(); + + return 0; + } + @endcode + + + @defgroup highgui_winrt WinRT support + + This figure explains new functionality implemented with WinRT GUI. The new GUI provides an Image control, + and a slider panel. Slider panel holds trackbars attached to it. + + Sliders are attached below the image control. Every new slider is added below the previous one. + + See below the example used to generate the figure: + @code + void sample_app::MainPage::ShowWindow() + { + static cv::String windowName("sample"); + cv::winrt_initContainer(this->cvContainer); + cv::namedWindow(windowName); // not required + + cv::Mat image = cv::imread("Assets/sample.jpg"); + cv::Mat converted = cv::Mat(image.rows, image.cols, CV_8UC4); + cv::cvtColor(image, converted, COLOR_BGR2BGRA); + cv::imshow(windowName, converted); // this will create window if it hasn't been created before + + int state = 42; + cv::TrackbarCallback callback = [](int pos, void* userdata) + { + if (pos == 0) { + cv::destroyWindow(windowName); + } + }; + cv::TrackbarCallback callbackTwin = [](int pos, void* userdata) + { + if (pos >= 70) { + cv::destroyAllWindows(); + } + }; + cv::createTrackbar("Sample trackbar", windowName, &state, 100, callback); + cv::createTrackbar("Twin brother", windowName, &state, 100, callbackTwin); + } + @endcode + + @defgroup highgui_c C API +@} +*/ + +///////////////////////// graphical user interface ////////////////////////// +namespace cv +{ + +//! @addtogroup highgui +//! @{ + +//! @addtogroup highgui_window_flags +//! @{ + +//! Flags for cv::namedWindow +enum WindowFlags { + WINDOW_NORMAL = 0x00000000, //!< the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size. + WINDOW_AUTOSIZE = 0x00000001, //!< the user cannot resize the window, the size is constrainted by the image displayed. + WINDOW_OPENGL = 0x00001000, //!< window with opengl support. + + WINDOW_FULLSCREEN = 1, //!< change the window to fullscreen. + WINDOW_FREERATIO = 0x00000100, //!< the image expends as much as it can (no ratio constraint). + WINDOW_KEEPRATIO = 0x00000000, //!< the ratio of the image is respected. + WINDOW_GUI_EXPANDED=0x00000000, //!< status bar and tool bar + WINDOW_GUI_NORMAL = 0x00000010, //!< old fashious way + }; + +//! Flags for cv::setWindowProperty / cv::getWindowProperty +enum WindowPropertyFlags { + WND_PROP_FULLSCREEN = 0, //!< fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN). + WND_PROP_AUTOSIZE = 1, //!< autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE). + WND_PROP_ASPECT_RATIO = 2, //!< window's aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO). + WND_PROP_OPENGL = 3, //!< opengl support. + WND_PROP_VISIBLE = 4, //!< checks whether the window exists and is visible + WND_PROP_TOPMOST = 5, //!< property to toggle normal window being topmost or not + WND_PROP_VSYNC = 6 //!< enable or disable VSYNC (in OpenGL mode) + }; + +//! Mouse Events see cv::MouseCallback +enum MouseEventTypes { + EVENT_MOUSEMOVE = 0, //!< indicates that the mouse pointer has moved over the window. + EVENT_LBUTTONDOWN = 1, //!< indicates that the left mouse button is pressed. + EVENT_RBUTTONDOWN = 2, //!< indicates that the right mouse button is pressed. + EVENT_MBUTTONDOWN = 3, //!< indicates that the middle mouse button is pressed. + EVENT_LBUTTONUP = 4, //!< indicates that left mouse button is released. + EVENT_RBUTTONUP = 5, //!< indicates that right mouse button is released. + EVENT_MBUTTONUP = 6, //!< indicates that middle mouse button is released. + EVENT_LBUTTONDBLCLK = 7, //!< indicates that left mouse button is double clicked. + EVENT_RBUTTONDBLCLK = 8, //!< indicates that right mouse button is double clicked. + EVENT_MBUTTONDBLCLK = 9, //!< indicates that middle mouse button is double clicked. + EVENT_MOUSEWHEEL = 10,//!< positive and negative values mean forward and backward scrolling, respectively. + EVENT_MOUSEHWHEEL = 11 //!< positive and negative values mean right and left scrolling, respectively. + }; + +//! Mouse Event Flags see cv::MouseCallback +enum MouseEventFlags { + EVENT_FLAG_LBUTTON = 1, //!< indicates that the left mouse button is down. + EVENT_FLAG_RBUTTON = 2, //!< indicates that the right mouse button is down. + EVENT_FLAG_MBUTTON = 4, //!< indicates that the middle mouse button is down. + EVENT_FLAG_CTRLKEY = 8, //!< indicates that CTRL Key is pressed. + EVENT_FLAG_SHIFTKEY = 16,//!< indicates that SHIFT Key is pressed. + EVENT_FLAG_ALTKEY = 32 //!< indicates that ALT Key is pressed. + }; + +//! @} highgui_window_flags + +//! @addtogroup highgui_qt +//! @{ + +//! Qt font weight +enum QtFontWeights { + QT_FONT_LIGHT = 25, //!< Weight of 25 + QT_FONT_NORMAL = 50, //!< Weight of 50 + QT_FONT_DEMIBOLD = 63, //!< Weight of 63 + QT_FONT_BOLD = 75, //!< Weight of 75 + QT_FONT_BLACK = 87 //!< Weight of 87 + }; + +//! Qt font style +enum QtFontStyles { + QT_STYLE_NORMAL = 0, //!< Normal font. + QT_STYLE_ITALIC = 1, //!< Italic font. + QT_STYLE_OBLIQUE = 2 //!< Oblique font. + }; + +//! Qt "button" type +enum QtButtonTypes { + QT_PUSH_BUTTON = 0, //!< Push button. + QT_CHECKBOX = 1, //!< Checkbox button. + QT_RADIOBOX = 2, //!< Radiobox button. + QT_NEW_BUTTONBAR = 1024 //!< Button should create a new buttonbar + }; + +//! @} highgui_qt + +/** @brief Callback function for mouse events. see cv::setMouseCallback +@param event one of the cv::MouseEventTypes constants. +@param x The x-coordinate of the mouse event. +@param y The y-coordinate of the mouse event. +@param flags one of the cv::MouseEventFlags constants. +@param userdata The optional parameter. + */ +typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata); + +/** @brief Callback function for Trackbar see cv::createTrackbar +@param pos current position of the specified trackbar. +@param userdata The optional parameter. + */ +typedef void (*TrackbarCallback)(int pos, void* userdata); + +/** @brief Callback function defined to be called every frame. See cv::setOpenGlDrawCallback +@param userdata The optional parameter. + */ +typedef void (*OpenGlDrawCallback)(void* userdata); + +/** @brief Callback function for a button created by cv::createButton +@param state current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button. +@param userdata The optional parameter. + */ +typedef void (*ButtonCallback)(int state, void* userdata); + +/** @brief Creates a window. + +The function namedWindow creates a window that can be used as a placeholder for images and +trackbars. Created windows are referred to by their names. + +If a window with the same name already exists, the function does nothing. + +You can call cv::destroyWindow or cv::destroyAllWindows to close the window and de-allocate any associated +memory usage. For a simple program, you do not really have to call these functions because all the +resources and windows of the application are closed automatically by the operating system upon exit. + +@note + +Qt backend supports additional flags: + - **WINDOW_NORMAL or WINDOW_AUTOSIZE:** WINDOW_NORMAL enables you to resize the + window, whereas WINDOW_AUTOSIZE adjusts automatically the window size to fit the + displayed image (see imshow ), and you cannot change the window size manually. + - **WINDOW_FREERATIO or WINDOW_KEEPRATIO:** WINDOW_FREERATIO adjusts the image + with no respect to its ratio, whereas WINDOW_KEEPRATIO keeps the image ratio. + - **WINDOW_GUI_NORMAL or WINDOW_GUI_EXPANDED:** WINDOW_GUI_NORMAL is the old way to draw the window + without statusbar and toolbar, whereas WINDOW_GUI_EXPANDED is a new enhanced GUI. +By default, flags == WINDOW_AUTOSIZE | WINDOW_KEEPRATIO | WINDOW_GUI_EXPANDED + +@param winname Name of the window in the window caption that may be used as a window identifier. +@param flags Flags of the window. The supported flags are: (cv::WindowFlags) + */ +CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE); + +/** @brief Destroys the specified window. + +The function destroyWindow destroys the window with the given name. + +@param winname Name of the window to be destroyed. + */ +CV_EXPORTS_W void destroyWindow(const String& winname); + +/** @brief Destroys all of the HighGUI windows. + +The function destroyAllWindows destroys all of the opened HighGUI windows. + */ +CV_EXPORTS_W void destroyAllWindows(); + +CV_EXPORTS_W int startWindowThread(); + +/** @brief Similar to #waitKey, but returns full key code. + +@note + +Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc + +*/ +CV_EXPORTS_W int waitKeyEx(int delay = 0); + +/** @brief Waits for a pressed key. + +The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay +milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the +function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is +running on your computer at that time. It returns the code of the pressed key or -1 if no key was +pressed before the specified time had elapsed. To check for a key press but not wait for it, use +#pollKey. + +@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle +GUI events, so one of them needs to be called periodically for normal event processing unless +HighGUI is used within an environment that takes care of event processing. + +@note The function only works if there is at least one HighGUI window created and the window is +active. If there are several HighGUI windows, any of them can be active. + +@param delay Delay in milliseconds. 0 is the special value that means "forever". + */ +CV_EXPORTS_W int waitKey(int delay = 0); + +/** @brief Polls for a pressed key. + +The function pollKey polls for a key event without waiting. It returns the code of the pressed key +or -1 if no key was pressed since the last invocation. To wait until a key was pressed, use #waitKey. + +@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle +GUI events, so one of them needs to be called periodically for normal event processing unless +HighGUI is used within an environment that takes care of event processing. + +@note The function only works if there is at least one HighGUI window created and the window is +active. If there are several HighGUI windows, any of them can be active. + */ +CV_EXPORTS_W int pollKey(); + +/** @brief Displays an image in the specified window. + +The function imshow displays an image in the specified window. If the window was created with the +cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution. +Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth: + +- If the image is 8-bit unsigned, it is displayed as is. +- If the image is 16-bit unsigned, the pixels are divided by 256. That is, the + value range [0,255\*256] is mapped to [0,255]. +- If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the + value range [0,1] is mapped to [0,255]. +- 32-bit integer images are not processed anymore due to ambiguouty of required transform. + Convert to 8-bit unsigned matrix using a custom preprocessing specific to image's context. + +If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and +cuda::GpuMat as input. + +If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE. + +If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow. + +@note This function should be followed by a call to cv::waitKey or cv::pollKey to perform GUI +housekeeping tasks that are necessary to actually show the given image and make the window respond +to mouse and keyboard events. Otherwise, it won't display the image and the window might lock up. +For example, **waitKey(0)** will display the window infinitely until any keypress (it is suitable +for image display). **waitKey(25)** will display a frame and wait approximately 25 ms for a key +press (suitable for displaying a video frame-by-frame). To remove the window, use cv::destroyWindow. + +@note + +[__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard. + +[__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image. + +@param winname Name of the window. +@param mat Image to be shown. + */ +CV_EXPORTS_W void imshow(const String& winname, InputArray mat); + +/** @brief Resizes the window to the specified size + +@note + +- The specified window size is for the image area. Toolbars are not counted. +- Only windows created without cv::WINDOW_AUTOSIZE flag can be resized. + +@param winname Window name. +@param width The new window width. +@param height The new window height. + */ +CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height); + +/** @overload +@param winname Window name. +@param size The new window size. +*/ +CV_EXPORTS_W void resizeWindow(const String& winname, const cv::Size& size); + +/** @brief Moves the window to the specified position + +@param winname Name of the window. +@param x The new x-coordinate of the window. +@param y The new y-coordinate of the window. + */ +CV_EXPORTS_W void moveWindow(const String& winname, int x, int y); + +/** @brief Changes parameters of a window dynamically. + +The function setWindowProperty enables changing properties of a window. + +@param winname Name of the window. +@param prop_id Window property to edit. The supported operation flags are: (cv::WindowPropertyFlags) +@param prop_value New value of the window property. The supported flags are: (cv::WindowFlags) + */ +CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value); + +/** @brief Updates window title +@param winname Name of the window. +@param title New title. +*/ +CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title); + +/** @brief Provides parameters of a window. + +The function getWindowProperty returns properties of a window. + +@param winname Name of the window. +@param prop_id Window property to retrieve. The following operation flags are available: (cv::WindowPropertyFlags) + +@sa setWindowProperty + */ +CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id); + +/** @brief Provides rectangle of image in the window. + +The function getWindowImageRect returns the client screen coordinates, width and height of the image rendering area. + +@param winname Name of the window. + +@sa resizeWindow moveWindow + */ +CV_EXPORTS_W Rect getWindowImageRect(const String& winname); + +/** @example samples/cpp/create_mask.cpp +This program demonstrates using mouse events and how to make and use a mask image (black and white) . +*/ +/** @brief Sets mouse handler for the specified window + +@param winname Name of the window. +@param onMouse Callback function for mouse events. See OpenCV samples on how to specify and use the callback. +@param userdata The optional parameter passed to the callback. + */ +CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0); + +/** @brief Gets the mouse-wheel motion delta, when handling mouse-wheel events cv::EVENT_MOUSEWHEEL and +cv::EVENT_MOUSEHWHEEL. + +For regular mice with a scroll-wheel, delta will be a multiple of 120. The value 120 corresponds to +a one notch rotation of the wheel or the threshold for action to be taken and one such action should +occur for each delta. Some high-precision mice with higher-resolution freely-rotating wheels may +generate smaller values. + +For cv::EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling, +respectively. For cv::EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and +left scrolling, respectively. + +@note + +Mouse-wheel events are currently supported only on Windows. + +@param flags The mouse callback flags parameter. + */ +CV_EXPORTS int getMouseWheelDelta(int flags); + +/** @brief Allows users to select a ROI on the given image. + +The function creates a window and allows users to select a ROI using the mouse. +Controls: use `space` or `enter` to finish selection, use key `c` to cancel selection (function will return the zero cv::Rect). + +@param windowName name of the window where selection process will be shown. +@param img image to select a ROI. +@param showCrosshair if true crosshair of selection rectangle will be shown. +@param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of +selection rectangle will correspont to the initial mouse position. +@return selected ROI or empty rect if selection canceled. + +@note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...). +After finish of work an empty callback will be set for the used window. + */ +CV_EXPORTS_W Rect selectROI(const String& windowName, InputArray img, bool showCrosshair = true, bool fromCenter = false); + +/** @overload + */ +CV_EXPORTS_W Rect selectROI(InputArray img, bool showCrosshair = true, bool fromCenter = false); + +/** @brief Allows users to select multiple ROIs on the given image. + +The function creates a window and allows users to select multiple ROIs using the mouse. +Controls: use `space` or `enter` to finish current selection and start a new one, +use `esc` to terminate multiple ROI selection process. + +@param windowName name of the window where selection process will be shown. +@param img image to select a ROI. +@param boundingBoxes selected ROIs. +@param showCrosshair if true crosshair of selection rectangle will be shown. +@param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of +selection rectangle will correspont to the initial mouse position. + +@note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...). +After finish of work an empty callback will be set for the used window. + */ +CV_EXPORTS_W void selectROIs(const String& windowName, InputArray img, + CV_OUT std::vector& boundingBoxes, bool showCrosshair = true, bool fromCenter = false); + +/** @brief Creates a trackbar and attaches it to the specified window. + +The function createTrackbar creates a trackbar (a slider or range control) with the specified name +and range, assigns a variable value to be a position synchronized with the trackbar and specifies +the callback function onChange to be called on the trackbar position change. The created trackbar is +displayed in the specified window winname. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar should be attached to the +control panel. + +Clicking the label of each trackbar enables editing the trackbar values manually. + +@param trackbarname Name of the created trackbar. +@param winname Name of the window that will be used as a parent of the created trackbar. +@param value Optional pointer to an integer variable whose value reflects the position of the +slider. Upon creation, the slider position is defined by this variable. +@param count Maximal position of the slider. The minimal position is always 0. +@param onChange Pointer to the function to be called every time the slider changes position. This +function should be prototyped as void Foo(int,void\*); , where the first parameter is the trackbar +position and the second parameter is the user data (see the next parameter). If the callback is +the NULL pointer, no callbacks are called, but only value is updated. +@param userdata User data that is passed as is to the callback. It can be used to handle trackbar +events without using global variables. + */ +CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname, + int* value, int count, + TrackbarCallback onChange = 0, + void* userdata = 0); + +/** @brief Returns the trackbar position. + +The function returns the current position of the specified trackbar. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of the trackbar. + */ +CV_EXPORTS_W int getTrackbarPos(const String& trackbarname, const String& winname); + +/** @brief Sets the trackbar position. + +The function sets the position of the specified trackbar in the specified window. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of trackbar. +@param pos New position. + */ +CV_EXPORTS_W void setTrackbarPos(const String& trackbarname, const String& winname, int pos); + +/** @brief Sets the trackbar maximum position. + +The function sets the maximum position of the specified trackbar in the specified window. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of trackbar. +@param maxval New maximum position. + */ +CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval); + +/** @brief Sets the trackbar minimum position. + +The function sets the minimum position of the specified trackbar in the specified window. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of trackbar. +@param minval New minimum position. + */ +CV_EXPORTS_W void setTrackbarMin(const String& trackbarname, const String& winname, int minval); + +//! @addtogroup highgui_opengl OpenGL support +//! @{ + +/** @brief Displays OpenGL 2D texture in the specified window. + +@param winname Name of the window. +@param tex OpenGL 2D texture data. + */ +CV_EXPORTS void imshow(const String& winname, const ogl::Texture2D& tex); + +/** @brief Sets a callback function to be called to draw on top of displayed image. + +The function setOpenGlDrawCallback can be used to draw 3D data on the window. See the example of +callback function below: +@code + void on_opengl(void* param) + { + glLoadIdentity(); + + glTranslated(0.0, 0.0, -1.0); + + glRotatef( 55, 1, 0, 0 ); + glRotatef( 45, 0, 1, 0 ); + glRotatef( 0, 0, 0, 1 ); + + static const int coords[6][4][3] = { + { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, + { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } }, + { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } }, + { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } }, + { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } }, + { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } + }; + + for (int i = 0; i < 6; ++i) { + glColor3ub( i*20, 100+i*10, i*42 ); + glBegin(GL_QUADS); + for (int j = 0; j < 4; ++j) { + glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]); + } + glEnd(); + } + } +@endcode + +@param winname Name of the window. +@param onOpenGlDraw Pointer to the function to be called every frame. This function should be +prototyped as void Foo(void\*) . +@param userdata Pointer passed to the callback function.(__Optional__) + */ +CV_EXPORTS void setOpenGlDrawCallback(const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0); + +/** @brief Sets the specified window as current OpenGL context. + +@param winname Name of the window. + */ +CV_EXPORTS void setOpenGlContext(const String& winname); + +/** @brief Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ). + +@param winname Name of the window. + */ +CV_EXPORTS void updateWindow(const String& winname); + +//! @} highgui_opengl + +//! @addtogroup highgui_qt +//! @{ + +/** @brief QtFont available only for Qt. See cv::fontQt + */ +struct QtFont +{ + const char* nameFont; //!< Name of the font + Scalar color; //!< Color of the font. Scalar(blue_component, green_component, red_component[, alpha_component]) + int font_face; //!< See cv::QtFontStyles + const int* ascii; //!< font data and metrics + const int* greek; + const int* cyrillic; + float hscale, vscale; + float shear; //!< slope coefficient: 0 - normal, >0 - italic + int thickness; //!< See cv::QtFontWeights + float dx; //!< horizontal interval between letters + int line_type; //!< PointSize +}; + +/** @brief Creates the font to draw a text on an image. + +The function fontQt creates a cv::QtFont object. This cv::QtFont is not compatible with putText . + +A basic usage of this function is the following: : +@code + QtFont font = fontQt("Times"); + addText( img1, "Hello World !", Point(50,50), font); +@endcode + +@param nameFont Name of the font. The name should match the name of a system font (such as +*Times*). If the font is not found, a default one is used. +@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the +font is set to a system-dependent default value. Generally, this is 12 points. +@param color Color of the font in BGRA where A = 255 is fully transparent. Use the macro CV_RGB +for simplicity. +@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control. +@param style Font style. Available operation flags are : cv::QtFontStyles +@param spacing Spacing between characters. It can be negative or positive. + */ +CV_EXPORTS QtFont fontQt(const String& nameFont, int pointSize = -1, + Scalar color = Scalar::all(0), int weight = QT_FONT_NORMAL, + int style = QT_STYLE_NORMAL, int spacing = 0); + +/** @brief Draws a text on the image. + +The function addText draws *text* on the image *img* using a specific font *font* (see example cv::fontQt +) + +@param img 8-bit 3-channel image where the text should be drawn. +@param text Text to write on an image. +@param org Point(x,y) where the text should start on an image. +@param font Font to use to draw a text. + */ +CV_EXPORTS void addText( const Mat& img, const String& text, Point org, const QtFont& font); + +/** @brief Draws a text on the image. + +@param img 8-bit 3-channel image where the text should be drawn. +@param text Text to write on an image. +@param org Point(x,y) where the text should start on an image. +@param nameFont Name of the font. The name should match the name of a system font (such as +*Times*). If the font is not found, a default one is used. +@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the +font is set to a system-dependent default value. Generally, this is 12 points. +@param color Color of the font in BGRA where A = 255 is fully transparent. +@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control. +@param style Font style. Available operation flags are : cv::QtFontStyles +@param spacing Spacing between characters. It can be negative or positive. + */ +CV_EXPORTS_W void addText(const Mat& img, const String& text, Point org, const String& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), + int weight = QT_FONT_NORMAL, int style = QT_STYLE_NORMAL, int spacing = 0); + +/** @brief Displays a text on a window image as an overlay for a specified duration. + +The function displayOverlay displays useful information/tips on top of the window for a certain +amount of time *delayms*. The function does not modify the image, displayed in the window, that is, +after the specified delay the original content of the window is restored. + +@param winname Name of the window. +@param text Overlay text to write on a window image. +@param delayms The period (in milliseconds), during which the overlay text is displayed. If this +function is called before the previous overlay text timed out, the timer is restarted and the text +is updated. If this value is zero, the text never disappears. + */ +CV_EXPORTS_W void displayOverlay(const String& winname, const String& text, int delayms = 0); + +/** @brief Displays a text on the window statusbar during the specified period of time. + +The function displayStatusBar displays useful information/tips on top of the window for a certain +amount of time *delayms* . This information is displayed on the window statusbar (the window must be +created with the CV_GUI_EXPANDED flags). + +@param winname Name of the window. +@param text Text to write on the window statusbar. +@param delayms Duration (in milliseconds) to display the text. If this function is called before +the previous text timed out, the timer is restarted and the text is updated. If this value is +zero, the text never disappears. + */ +CV_EXPORTS_W void displayStatusBar(const String& winname, const String& text, int delayms = 0); + +/** @brief Saves parameters of the specified window. + +The function saveWindowParameters saves size, location, flags, trackbars value, zoom and panning +location of the window windowName. + +@param windowName Name of the window. + */ +CV_EXPORTS void saveWindowParameters(const String& windowName); + +/** @brief Loads parameters of the specified window. + +The function loadWindowParameters loads size, location, flags, trackbars value, zoom and panning +location of the window windowName. + +@param windowName Name of the window. + */ +CV_EXPORTS void loadWindowParameters(const String& windowName); + +CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]); + +CV_EXPORTS void stopLoop(); + +/** @brief Attaches a button to the control panel. + +The function createButton attaches a button to the control panel. Each button is added to a +buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the +control panel before, or if the last element attached to the control panel was a trackbar or if the +QT_NEW_BUTTONBAR flag is added to the type. + +See below various examples of the cv::createButton function call: : +@code + createButton("",callbackButton);//create a push button "button 0", that will call callbackButton. + createButton("button2",callbackButton,NULL,QT_CHECKBOX,0); + createButton("button3",callbackButton,&value); + createButton("button5",callbackButton1,NULL,QT_RADIOBOX); + createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1); + createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON|QT_NEW_BUTTONBAR);// create a push button in a new row +@endcode + +@param bar_name Name of the button. +@param on_change Pointer to the function to be called every time the button changes its state. +This function should be prototyped as void Foo(int state,\*void); . *state* is the current state +of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button. +@param userdata Pointer passed to the callback function. +@param type Optional type of the button. Available types are: (cv::QtButtonTypes) +@param initial_button_state Default state of the button. Use for checkbox and radiobox. Its +value could be 0 or 1. (__Optional__) +*/ +CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change, + void* userdata = 0, int type = QT_PUSH_BUTTON, + bool initial_button_state = false); + +//! @} highgui_qt + +//! @} highgui + +} // cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/highgui/highgui.hpp b/Cigarette/OpenCV455Simple/include/opencv2/highgui/highgui.hpp new file mode 100644 index 0000000..160c9cf --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/highgui/highgui.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/highgui.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/highgui/highgui_c.h b/Cigarette/OpenCV455Simple/include/opencv2/highgui/highgui_c.h new file mode 100644 index 0000000..e508e14 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/highgui/highgui_c.h @@ -0,0 +1,251 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HIGHGUI_H +#define OPENCV_HIGHGUI_H + +#include "opencv2/core/core_c.h" +#include "opencv2/imgproc/imgproc_c.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** @addtogroup highgui_c + @{ + */ + +/****************************************************************************************\ +* Basic GUI functions * +\****************************************************************************************/ +//YV +//-----------New for Qt +/* For font */ +enum { CV_FONT_LIGHT = 25,//QFont::Light, + CV_FONT_NORMAL = 50,//QFont::Normal, + CV_FONT_DEMIBOLD = 63,//QFont::DemiBold, + CV_FONT_BOLD = 75,//QFont::Bold, + CV_FONT_BLACK = 87 //QFont::Black +}; + +enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal, + CV_STYLE_ITALIC = 1,//QFont::StyleItalic, + CV_STYLE_OBLIQUE = 2 //QFont::StyleOblique +}; +/* ---------*/ + +//for color cvScalar(blue_component, green_component, red_component[, alpha_component]) +//and alpha= 0 <-> 0xFF (not transparent <-> transparent) +CVAPI(CvFont) cvFontQt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0)); + +CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2); + +CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0)); +CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0)); + +CVAPI(void) cvSaveWindowParameters(const char* name); +CVAPI(void) cvLoadWindowParameters(const char* name); +CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]); +CVAPI(void) cvStopLoop( void ); + +typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata); +enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2}; +CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0)); +//---------------------- + + +/* this function is used to set some external parameters in case of X Window */ +CVAPI(int) cvInitSystem( int argc, char** argv ); + +CVAPI(int) cvStartWindowThread( void ); + +// --------- YV --------- +enum +{ + //These 3 flags are used by cvSet/GetWindowProperty + CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property + CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property + CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property + CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support + CV_WND_PROP_VISIBLE = 4, + + //These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty + CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size + CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed + CV_WINDOW_OPENGL = 0x00001000, //window with opengl support + + //Those flags are only for Qt + CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar + CV_GUI_NORMAL = 0x00000010, //old fashious way + + //These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty + CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen + CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint) + CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected. +}; + +/* create window */ +CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) ); + +/* Set and Get Property of the window */ +CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value); +CVAPI(double) cvGetWindowProperty(const char* name, int prop_id); + +/* display image within window (highgui windows remember their content) */ +CVAPI(void) cvShowImage( const char* name, const CvArr* image ); + +/* resize/move window */ +CVAPI(void) cvResizeWindow( const char* name, int width, int height ); +CVAPI(void) cvMoveWindow( const char* name, int x, int y ); + + +/* destroy window and all the trackers associated with it */ +CVAPI(void) cvDestroyWindow( const char* name ); + +CVAPI(void) cvDestroyAllWindows(void); + +/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */ +CVAPI(void*) cvGetWindowHandle( const char* name ); + +/* get name of highgui window given its native handle */ +CVAPI(const char*) cvGetWindowName( void* window_handle ); + + +typedef void (CV_CDECL *CvTrackbarCallback)(int pos); + +/* create trackbar and display it on top of given window, set callback */ +CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name, + int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL)); + +typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata); + +CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name, + int* value, int count, CvTrackbarCallback2 on_change, + void* userdata CV_DEFAULT(0)); + +/* retrieve or set trackbar position */ +CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name ); +CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos ); +CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval); +CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval); + +enum +{ + CV_EVENT_MOUSEMOVE =0, + CV_EVENT_LBUTTONDOWN =1, + CV_EVENT_RBUTTONDOWN =2, + CV_EVENT_MBUTTONDOWN =3, + CV_EVENT_LBUTTONUP =4, + CV_EVENT_RBUTTONUP =5, + CV_EVENT_MBUTTONUP =6, + CV_EVENT_LBUTTONDBLCLK =7, + CV_EVENT_RBUTTONDBLCLK =8, + CV_EVENT_MBUTTONDBLCLK =9, + CV_EVENT_MOUSEWHEEL =10, + CV_EVENT_MOUSEHWHEEL =11 +}; + +enum +{ + CV_EVENT_FLAG_LBUTTON =1, + CV_EVENT_FLAG_RBUTTON =2, + CV_EVENT_FLAG_MBUTTON =4, + CV_EVENT_FLAG_CTRLKEY =8, + CV_EVENT_FLAG_SHIFTKEY =16, + CV_EVENT_FLAG_ALTKEY =32 +}; + + +#define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits + +typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param); + +/* assign callback for mouse events */ +CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, + void* param CV_DEFAULT(NULL)); + +/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */ +CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0)); + +// OpenGL support + +typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata); +CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL)); + +CVAPI(void) cvSetOpenGlContext(const char* window_name); +CVAPI(void) cvUpdateWindow(const char* window_name); + + +/****************************************************************************************\ + +* Obsolete functions/synonyms * +\****************************************************************************************/ + +#define cvAddSearchPath(path) +#define cvvInitSystem cvInitSystem +#define cvvNamedWindow cvNamedWindow +#define cvvShowImage cvShowImage +#define cvvResizeWindow cvResizeWindow +#define cvvDestroyWindow cvDestroyWindow +#define cvvCreateTrackbar cvCreateTrackbar +#define cvvAddSearchPath cvAddSearchPath +#define cvvWaitKey(name) cvWaitKey(0) +#define cvvWaitKeyEx(name,delay) cvWaitKey(delay) +#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE +#define set_preprocess_func cvSetPreprocessFuncWin32 +#define set_postprocess_func cvSetPostprocessFuncWin32 + +#if defined _WIN32 + +CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback); +CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback); +#define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback)) +#define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback)) + +#endif + +/** @} highgui_c */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs.hpp new file mode 100644 index 0000000..d7ff9a1 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs.hpp @@ -0,0 +1,330 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGCODECS_HPP +#define OPENCV_IMGCODECS_HPP + +#include "opencv2/core.hpp" + +/** + @defgroup imgcodecs Image file reading and writing + @{ + @defgroup imgcodecs_c C API + @defgroup imgcodecs_flags Flags used for image file reading and writing + @defgroup imgcodecs_ios iOS glue + @defgroup imgcodecs_macosx MacOS(OSX) glue + @} +*/ + +//////////////////////////////// image codec //////////////////////////////// +namespace cv +{ + +//! @addtogroup imgcodecs +//! @{ + +//! @addtogroup imgcodecs_flags +//! @{ + +//! Imread flags +enum ImreadModes { + IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation. + IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion). + IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image. + IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit. + IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format. + IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image. + IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2. + IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2. + IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4. + IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4. + IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8. + IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8. + IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag. + }; + +//! Imwrite flags +enum ImwriteFlags { + IMWRITE_JPEG_QUALITY = 1, //!< For JPEG, it can be a quality from 0 to 100 (the higher is the better). Default value is 95. + IMWRITE_JPEG_PROGRESSIVE = 2, //!< Enable JPEG features, 0 or 1, default is False. + IMWRITE_JPEG_OPTIMIZE = 3, //!< Enable JPEG features, 0 or 1, default is False. + IMWRITE_JPEG_RST_INTERVAL = 4, //!< JPEG restart interval, 0 - 65535, default is 0 - no restart. + IMWRITE_JPEG_LUMA_QUALITY = 5, //!< Separate luma quality level, 0 - 100, default is 0 - don't use. + IMWRITE_JPEG_CHROMA_QUALITY = 6, //!< Separate chroma quality level, 0 - 100, default is 0 - don't use. + IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting). + IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE. + IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0. + IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1. + IMWRITE_EXR_TYPE = (3 << 4) + 0, /* 48 */ //!< override EXR storage type (FLOAT (FP32) is default) + IMWRITE_EXR_COMPRESSION = (3 << 4) + 1, /* 49 */ //!< override EXR compression type (ZIP_COMPRESSION = 3 is default) + IMWRITE_WEBP_QUALITY = 64, //!< For WEBP, it can be a quality from 1 to 100 (the higher is the better). By default (without any parameter) and for quality above 100 the lossless compression is used. + IMWRITE_PAM_TUPLETYPE = 128,//!< For PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format + IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values + IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI + IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI + IMWRITE_TIFF_COMPRESSION = 259, //!< For TIFF, use to specify the image compression scheme. See libtiff for integer constants corresponding to compression formats. Note, for images whose depth is CV_32F, only libtiff's SGILOG compression scheme is used. For other supported depths, the compression scheme can be specified by this flag; LZW compression is the default. + IMWRITE_JPEG2000_COMPRESSION_X1000 = 272 //!< For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000. + }; + +enum ImwriteEXRTypeFlags { + /*IMWRITE_EXR_TYPE_UNIT = 0, //!< not supported */ + IMWRITE_EXR_TYPE_HALF = 1, //!< store as HALF (FP16) + IMWRITE_EXR_TYPE_FLOAT = 2 //!< store as FP32 (default) + }; + +enum ImwriteEXRCompressionFlags { + IMWRITE_EXR_COMPRESSION_NO = 0, //!< no compression + IMWRITE_EXR_COMPRESSION_RLE = 1, //!< run length encoding + IMWRITE_EXR_COMPRESSION_ZIPS = 2, //!< zlib compression, one scan line at a time + IMWRITE_EXR_COMPRESSION_ZIP = 3, //!< zlib compression, in blocks of 16 scan lines + IMWRITE_EXR_COMPRESSION_PIZ = 4, //!< piz-based wavelet compression + IMWRITE_EXR_COMPRESSION_PXR24 = 5, //!< lossy 24-bit float compression + IMWRITE_EXR_COMPRESSION_B44 = 6, //!< lossy 4-by-4 pixel block compression, fixed compression rate + IMWRITE_EXR_COMPRESSION_B44A = 7, //!< lossy 4-by-4 pixel block compression, flat fields are compressed more + IMWRITE_EXR_COMPRESSION_DWAA = 8, //!< lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access. Supported since OpenEXR 2.2.0. + IMWRITE_EXR_COMPRESSION_DWAB = 9, //!< lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION. Supported since OpenEXR 2.2.0. + }; + +//! Imwrite PNG specific flags used to tune the compression algorithm. +/** These flags will be modify the way of PNG image compression and will be passed to the underlying zlib processing stage. + +- The effect of IMWRITE_PNG_STRATEGY_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between IMWRITE_PNG_STRATEGY_DEFAULT and IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY. +- IMWRITE_PNG_STRATEGY_RLE is designed to be almost as fast as IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, but give better compression for PNG image data. +- The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. +- IMWRITE_PNG_STRATEGY_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. +*/ +enum ImwritePNGFlags { + IMWRITE_PNG_STRATEGY_DEFAULT = 0, //!< Use this value for normal data. + IMWRITE_PNG_STRATEGY_FILTERED = 1, //!< Use this value for data produced by a filter (or predictor).Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. + IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2, //!< Use this value to force Huffman encoding only (no string match). + IMWRITE_PNG_STRATEGY_RLE = 3, //!< Use this value to limit match distances to one (run-length encoding). + IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. + }; + +//! Imwrite PAM specific tupletype flags used to define the 'TUPETYPE' field of a PAM file. +enum ImwritePAMFlags { + IMWRITE_PAM_FORMAT_NULL = 0, + IMWRITE_PAM_FORMAT_BLACKANDWHITE = 1, + IMWRITE_PAM_FORMAT_GRAYSCALE = 2, + IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA = 3, + IMWRITE_PAM_FORMAT_RGB = 4, + IMWRITE_PAM_FORMAT_RGB_ALPHA = 5, + }; + +//! @} imgcodecs_flags + +/** @brief Loads an image from a file. + +@anchor imread + +The function imread loads an image from the specified file and returns it. If the image cannot be +read (because of missing file, improper permissions, unsupported or invalid format), the function +returns an empty matrix ( Mat::data==NULL ). + +Currently, the following file formats are supported: + +- Windows bitmaps - \*.bmp, \*.dib (always supported) +- JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section) +- JPEG 2000 files - \*.jp2 (see the *Note* section) +- Portable Network Graphics - \*.png (see the *Note* section) +- WebP - \*.webp (see the *Note* section) +- Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported) +- PFM files - \*.pfm (see the *Note* section) +- Sun rasters - \*.sr, \*.ras (always supported) +- TIFF files - \*.tiff, \*.tif (see the *Note* section) +- OpenEXR Image files - \*.exr (see the *Note* section) +- Radiance HDR - \*.hdr, \*.pic (always supported) +- Raster and Vector geospatial data supported by GDAL (see the *Note* section) + +@note +- The function determines the type of an image by the content, not by the file extension. +- In the case of color images, the decoded images will have the channels stored in **B G R** order. +- When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available. + Results may differ to the output of cvtColor() +- On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg, + libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, + and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware + that currently these native image loaders give images with different pixel values because of + the color management embedded into MacOSX. +- On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for + codecs supplied with an OS image. Install the relevant packages (do not forget the development + files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn + on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake. +- In the case you set *WITH_GDAL* flag to true in CMake and @ref IMREAD_LOAD_GDAL to load the image, + then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting + the following formats: [Raster](http://www.gdal.org/formats_list.html), + [Vector](http://www.gdal.org/ogr_formats.html). +- If EXIF information is embedded in the image file, the EXIF orientation will be taken into account + and thus the image will be rotated accordingly except if the flags @ref IMREAD_IGNORE_ORIENTATION + or @ref IMREAD_UNCHANGED are passed. +- Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image. +- By default number of pixels must be less than 2^30. Limit can be set using system + variable OPENCV_IO_MAX_IMAGE_PIXELS + +@param filename Name of file to be loaded. +@param flags Flag that can take values of cv::ImreadModes +*/ +CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR ); + +/** @brief Loads a multi-page image from a file. + +The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects. +@param filename Name of file to be loaded. +@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. +@param mats A vector of Mat objects holding each page, if more than one. +@sa cv::imread +*/ +CV_EXPORTS_W bool imreadmulti(const String& filename, CV_OUT std::vector& mats, int flags = IMREAD_ANYCOLOR); + +/** @brief Loads a of images of a multi-page image from a file. + +The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects. +@param filename Name of file to be loaded. +@param start Start index of the image to load +@param count Count number of images to load +@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. +@param mats A vector of Mat objects holding each page, if more than one. +@sa cv::imread +*/ +CV_EXPORTS_W bool imreadmulti(const String& filename, CV_OUT std::vector& mats, int start, int count, int flags = IMREAD_ANYCOLOR); + +/** @brief Returns the number of images inside the give file + +The function imcount will return the number of pages in a multi-page image, or 1 for single-page images +@param filename Name of file to be loaded. +@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. +*/ +CV_EXPORTS_W size_t imcount(const String& filename, int flags = IMREAD_ANYCOLOR); + +/** @brief Saves an image to a specified file. + +The function imwrite saves the image to the specified file. The image format is chosen based on the +filename extension (see cv::imread for the list of extensions). In general, only 8-bit +single-channel or 3-channel (with 'BGR' channel order) images +can be saved using this function, with these exceptions: + +- 16-bit unsigned (CV_16U) images can be saved in the case of PNG, JPEG 2000, and TIFF formats +- 32-bit float (CV_32F) images can be saved in PFM, TIFF, OpenEXR, and Radiance HDR formats; + 3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding + (4 bytes per pixel) +- PNG images with an alpha channel can be saved using this function. To do this, create +8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels +should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below). +- Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below). + +If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way. + +If the format, depth or channel order is different, use +Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O +functions to save the image to XML or YAML format. + +The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file. +It also demonstrates how to save multiple images in a TIFF file: +@include snippets/imgcodecs_imwrite.cpp +@param filename Name of the file. +@param img (Mat or vector of Mat) Image or Images to be saved. +@param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags +*/ +CV_EXPORTS_W bool imwrite( const String& filename, InputArray img, + const std::vector& params = std::vector()); + +/// @overload multi-image overload for bindings +CV_WRAP static inline +bool imwritemulti(const String& filename, InputArrayOfArrays img, + const std::vector& params = std::vector()) +{ + return imwrite(filename, img, params); +} + +/** @brief Reads an image from a buffer in memory. + +The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or +contains invalid data, the function returns an empty matrix ( Mat::data==NULL ). + +See cv::imread for the list of supported formats and flags description. + +@note In the case of color images, the decoded images will have the channels stored in **B G R** order. +@param buf Input array or vector of bytes. +@param flags The same flags as in cv::imread, see cv::ImreadModes. +*/ +CV_EXPORTS_W Mat imdecode( InputArray buf, int flags ); + +/** @overload +@param buf +@param flags +@param dst The optional output placeholder for the decoded matrix. It can save the image +reallocations when the function is called repeatedly for images of the same size. +*/ +CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst); + +/** @brief Encodes an image into a memory buffer. + +The function imencode compresses the image and stores it in the memory buffer that is resized to fit the +result. See cv::imwrite for the list of supported formats and flags description. + +@param ext File extension that defines the output format. +@param img Image to be written. +@param buf Output buffer resized to fit the compressed image. +@param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags. +*/ +CV_EXPORTS_W bool imencode( const String& ext, InputArray img, + CV_OUT std::vector& buf, + const std::vector& params = std::vector()); + +/** @brief Returns true if the specified image can be decoded by OpenCV + +@param filename File name of the image +*/ +CV_EXPORTS_W bool haveImageReader( const String& filename ); + +/** @brief Returns true if an image with the specified filename can be encoded by OpenCV + + @param filename File name of the image + */ +CV_EXPORTS_W bool haveImageWriter( const String& filename ); + + +//! @} imgcodecs + +} // cv + +#endif //OPENCV_IMGCODECS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs.hpp new file mode 100644 index 0000000..a3cd232 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/imgcodecs.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs_c.h b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs_c.h new file mode 100644 index 0000000..c78b3f7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs_c.h @@ -0,0 +1 @@ +#error "This header with legacy C API declarations has been removed from OpenCV. Legacy constants are available from legacy/constants_c.h file." diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/ios.h b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/ios.h new file mode 100644 index 0000000..5f17218 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/ios.h @@ -0,0 +1,59 @@ + +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#import +#import +#import +#import +#include "opencv2/core.hpp" + +//! @addtogroup imgcodecs_ios +//! @{ + +CV_EXPORTS CGImageRef MatToCGImage(const cv::Mat& image) CF_RETURNS_RETAINED; +CV_EXPORTS void CGImageToMat(const CGImageRef image, cv::Mat& m, bool alphaExist = false); +CV_EXPORTS UIImage* MatToUIImage(const cv::Mat& image); +CV_EXPORTS void UIImageToMat(const UIImage* image, + cv::Mat& m, bool alphaExist = false); + +//! @} diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/legacy/constants_c.h b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/legacy/constants_c.h new file mode 100644 index 0000000..de7be4f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/legacy/constants_c.h @@ -0,0 +1,54 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGCODECS_LEGACY_CONSTANTS_H +#define OPENCV_IMGCODECS_LEGACY_CONSTANTS_H + +/* duplicate of "ImreadModes" enumeration for better compatibility with OpenCV 3.x */ +enum +{ +/* 8bit, color or not */ + CV_LOAD_IMAGE_UNCHANGED =-1, +/* 8bit, gray */ + CV_LOAD_IMAGE_GRAYSCALE =0, +/* ?, color */ + CV_LOAD_IMAGE_COLOR =1, +/* any depth, ? */ + CV_LOAD_IMAGE_ANYDEPTH =2, +/* ?, any color */ + CV_LOAD_IMAGE_ANYCOLOR =4, +/* ?, no rotate */ + CV_LOAD_IMAGE_IGNORE_ORIENTATION =128 +}; + +/* duplicate of "ImwriteFlags" enumeration for better compatibility with OpenCV 3.x */ +enum +{ + CV_IMWRITE_JPEG_QUALITY =1, + CV_IMWRITE_JPEG_PROGRESSIVE =2, + CV_IMWRITE_JPEG_OPTIMIZE =3, + CV_IMWRITE_JPEG_RST_INTERVAL =4, + CV_IMWRITE_JPEG_LUMA_QUALITY =5, + CV_IMWRITE_JPEG_CHROMA_QUALITY =6, + CV_IMWRITE_PNG_COMPRESSION =16, + CV_IMWRITE_PNG_STRATEGY =17, + CV_IMWRITE_PNG_BILEVEL =18, + CV_IMWRITE_PNG_STRATEGY_DEFAULT =0, + CV_IMWRITE_PNG_STRATEGY_FILTERED =1, + CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2, + CV_IMWRITE_PNG_STRATEGY_RLE =3, + CV_IMWRITE_PNG_STRATEGY_FIXED =4, + CV_IMWRITE_PXM_BINARY =32, + CV_IMWRITE_EXR_TYPE = 48, + CV_IMWRITE_WEBP_QUALITY =64, + CV_IMWRITE_PAM_TUPLETYPE = 128, + CV_IMWRITE_PAM_FORMAT_NULL = 0, + CV_IMWRITE_PAM_FORMAT_BLACKANDWHITE = 1, + CV_IMWRITE_PAM_FORMAT_GRAYSCALE = 2, + CV_IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA = 3, + CV_IMWRITE_PAM_FORMAT_RGB = 4, + CV_IMWRITE_PAM_FORMAT_RGB_ALPHA = 5, +}; + +#endif // OPENCV_IMGCODECS_LEGACY_CONSTANTS_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/macosx.h b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/macosx.h new file mode 100644 index 0000000..cfb0770 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgcodecs/macosx.h @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#if !defined(__APPLE__) || !defined(__MACH__) +#error This header should be used in macOS ObjC/Swift projects. +#endif + +#import +#include "opencv2/core.hpp" + +//! @addtogroup imgcodecs_macosx +//! @{ + +CV_EXPORTS CGImageRef MatToCGImage(const cv::Mat& image) CF_RETURNS_RETAINED; +CV_EXPORTS void CGImageToMat(const CGImageRef image, cv::Mat& m, bool alphaExist = false); +CV_EXPORTS NSImage* MatToNSImage(const cv::Mat& image); +CV_EXPORTS void NSImageToMat(const NSImage* image, cv::Mat& m, bool alphaExist = false); + +//! @} diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgproc.hpp new file mode 100644 index 0000000..eacec61 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc.hpp @@ -0,0 +1,4994 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_HPP +#define OPENCV_IMGPROC_HPP + +#include "opencv2/core.hpp" + +/** + @defgroup imgproc Image Processing + +This module includes image-processing functions. + + @{ + @defgroup imgproc_filter Image Filtering + +Functions and classes described in this section are used to perform various linear or non-linear +filtering operations on 2D images (represented as Mat's). It means that for each pixel location +\f$(x,y)\f$ in the source image (normally, rectangular), its neighborhood is considered and used to +compute the response. In case of a linear filter, it is a weighted sum of pixel values. In case of +morphological operations, it is the minimum or maximum values, and so on. The computed response is +stored in the destination image at the same location \f$(x,y)\f$. It means that the output image +will be of the same size as the input image. Normally, the functions support multi-channel arrays, +in which case every channel is processed independently. Therefore, the output image will also have +the same number of channels as the input one. + +Another common feature of the functions and classes described in this section is that, unlike +simple arithmetic functions, they need to extrapolate values of some non-existing pixels. For +example, if you want to smooth an image using a Gaussian \f$3 \times 3\f$ filter, then, when +processing the left-most pixels in each row, you need pixels to the left of them, that is, outside +of the image. You can let these pixels be the same as the left-most image pixels ("replicated +border" extrapolation method), or assume that all the non-existing pixels are zeros ("constant +border" extrapolation method), and so on. OpenCV enables you to specify the extrapolation method. +For details, see #BorderTypes + +@anchor filter_depths +### Depth combinations +Input depth (src.depth()) | Output depth (ddepth) +--------------------------|---------------------- +CV_8U | -1/CV_16S/CV_32F/CV_64F +CV_16U/CV_16S | -1/CV_32F/CV_64F +CV_32F | -1/CV_32F/CV_64F +CV_64F | -1/CV_64F + +@note when ddepth=-1, the output image will have the same depth as the source. + + @defgroup imgproc_transform Geometric Image Transformations + +The functions in this section perform various geometrical transformations of 2D images. They do not +change the image content but deform the pixel grid and map this deformed grid to the destination +image. In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from +destination to the source. That is, for each pixel \f$(x, y)\f$ of the destination image, the +functions compute coordinates of the corresponding "donor" pixel in the source image and copy the +pixel value: + +\f[\texttt{dst} (x,y)= \texttt{src} (f_x(x,y), f_y(x,y))\f] + +In case when you specify the forward mapping \f$\left: \texttt{src} \rightarrow +\texttt{dst}\f$, the OpenCV functions first compute the corresponding inverse mapping +\f$\left: \texttt{dst} \rightarrow \texttt{src}\f$ and then use the above formula. + +The actual implementations of the geometrical transformations, from the most generic remap and to +the simplest and the fastest resize, need to solve two main problems with the above formula: + +- Extrapolation of non-existing pixels. Similarly to the filtering functions described in the +previous section, for some \f$(x,y)\f$, either one of \f$f_x(x,y)\f$, or \f$f_y(x,y)\f$, or both +of them may fall outside of the image. In this case, an extrapolation method needs to be used. +OpenCV provides the same selection of extrapolation methods as in the filtering functions. In +addition, it provides the method #BORDER_TRANSPARENT. This means that the corresponding pixels in +the destination image will not be modified at all. + +- Interpolation of pixel values. Usually \f$f_x(x,y)\f$ and \f$f_y(x,y)\f$ are floating-point +numbers. This means that \f$\left\f$ can be either an affine or perspective +transformation, or radial lens distortion correction, and so on. So, a pixel value at fractional +coordinates needs to be retrieved. In the simplest case, the coordinates can be just rounded to the +nearest integer coordinates and the corresponding pixel can be used. This is called a +nearest-neighbor interpolation. However, a better result can be achieved by using more +sophisticated [interpolation methods](http://en.wikipedia.org/wiki/Multivariate_interpolation) , +where a polynomial function is fit into some neighborhood of the computed pixel \f$(f_x(x,y), +f_y(x,y))\f$, and then the value of the polynomial at \f$(f_x(x,y), f_y(x,y))\f$ is taken as the +interpolated pixel value. In OpenCV, you can choose between several interpolation methods. See +resize for details. + +@note The geometrical transformations do not work with `CV_8S` or `CV_32S` images. + + @defgroup imgproc_misc Miscellaneous Image Transformations + @defgroup imgproc_draw Drawing Functions + +Drawing functions work with matrices/images of arbitrary depth. The boundaries of the shapes can be +rendered with antialiasing (implemented only for 8-bit images for now). All the functions include +the parameter color that uses an RGB value (that may be constructed with the Scalar constructor ) +for color images and brightness for grayscale images. For color images, the channel ordering is +normally *Blue, Green, Red*. This is what imshow, imread, and imwrite expect. So, if you form a +color using the Scalar constructor, it should look like: + +\f[\texttt{Scalar} (blue \_ component, green \_ component, red \_ component[, alpha \_ component])\f] + +If you are using your own image rendering and I/O functions, you can use any channel ordering. The +drawing functions process each channel independently and do not depend on the channel order or even +on the used color space. The whole image can be converted from BGR to RGB or to a different color +space using cvtColor . + +If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, +many drawing functions can handle pixel coordinates specified with sub-pixel accuracy. This means +that the coordinates can be passed as fixed-point numbers encoded as integers. The number of +fractional bits is specified by the shift parameter and the real point coordinates are calculated as +\f$\texttt{Point}(x,y)\rightarrow\texttt{Point2f}(x*2^{-shift},y*2^{-shift})\f$ . This feature is +especially effective when rendering antialiased shapes. + +@note The functions do not support alpha-transparency when the target image is 4-channel. In this +case, the color[3] is simply copied to the repainted pixels. Thus, if you want to paint +semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main +image. + + @defgroup imgproc_color_conversions Color Space Conversions + @defgroup imgproc_colormap ColorMaps in OpenCV + +The human perception isn't built for observing fine changes in grayscale images. Human eyes are more +sensitive to observing changes between colors, so you often need to recolor your grayscale images to +get a clue about them. OpenCV now comes with various colormaps to enhance the visualization in your +computer vision application. + +In OpenCV you only need applyColorMap to apply a colormap on a given image. The following sample +code reads the path to an image from command line, applies a Jet colormap on it and shows the +result: + +@include snippets/imgproc_applyColorMap.cpp + +@see #ColormapTypes + + @defgroup imgproc_subdiv2d Planar Subdivision + +The Subdiv2D class described in this section is used to perform various planar subdivision on +a set of 2D points (represented as vector of Point2f). OpenCV subdivides a plane into triangles +using the Delaunay's algorithm, which corresponds to the dual graph of the Voronoi diagram. +In the figure below, the Delaunay's triangulation is marked with black lines and the Voronoi +diagram with red lines. + +![Delaunay triangulation (black) and Voronoi (red)](pics/delaunay_voronoi.png) + +The subdivisions can be used for the 3D piece-wise transformation of a plane, morphing, fast +location of points on the plane, building special graphs (such as NNG,RNG), and so forth. + + @defgroup imgproc_hist Histograms + @defgroup imgproc_shape Structural Analysis and Shape Descriptors + @defgroup imgproc_motion Motion Analysis and Object Tracking + @defgroup imgproc_feature Feature Detection + @defgroup imgproc_object Object Detection + @defgroup imgproc_segmentation Image Segmentation + @defgroup imgproc_c C API + @defgroup imgproc_hal Hardware Acceleration Layer + @{ + @defgroup imgproc_hal_functions Functions + @defgroup imgproc_hal_interface Interface + @} + @} +*/ + +namespace cv +{ + +/** @addtogroup imgproc +@{ +*/ + +//! @addtogroup imgproc_filter +//! @{ + +enum SpecialFilter { + FILTER_SCHARR = -1 +}; + +//! type of morphological operation +enum MorphTypes{ + MORPH_ERODE = 0, //!< see #erode + MORPH_DILATE = 1, //!< see #dilate + MORPH_OPEN = 2, //!< an opening operation + //!< \f[\texttt{dst} = \mathrm{open} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \mathrm{erode} ( \texttt{src} , \texttt{element} ))\f] + MORPH_CLOSE = 3, //!< a closing operation + //!< \f[\texttt{dst} = \mathrm{close} ( \texttt{src} , \texttt{element} )= \mathrm{erode} ( \mathrm{dilate} ( \texttt{src} , \texttt{element} ))\f] + MORPH_GRADIENT = 4, //!< a morphological gradient + //!< \f[\texttt{dst} = \mathrm{morph\_grad} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \texttt{src} , \texttt{element} )- \mathrm{erode} ( \texttt{src} , \texttt{element} )\f] + MORPH_TOPHAT = 5, //!< "top hat" + //!< \f[\texttt{dst} = \mathrm{tophat} ( \texttt{src} , \texttt{element} )= \texttt{src} - \mathrm{open} ( \texttt{src} , \texttt{element} )\f] + MORPH_BLACKHAT = 6, //!< "black hat" + //!< \f[\texttt{dst} = \mathrm{blackhat} ( \texttt{src} , \texttt{element} )= \mathrm{close} ( \texttt{src} , \texttt{element} )- \texttt{src}\f] + MORPH_HITMISS = 7 //!< "hit or miss" + //!< .- Only supported for CV_8UC1 binary images. A tutorial can be found in the documentation +}; + +//! shape of the structuring element +enum MorphShapes { + MORPH_RECT = 0, //!< a rectangular structuring element: \f[E_{ij}=1\f] + MORPH_CROSS = 1, //!< a cross-shaped structuring element: + //!< \f[E_{ij} = \begin{cases} 1 & \texttt{if } {i=\texttt{anchor.y } {or } {j=\texttt{anchor.x}}} \\0 & \texttt{otherwise} \end{cases}\f] + MORPH_ELLIPSE = 2 //!< an elliptic structuring element, that is, a filled ellipse inscribed + //!< into the rectangle Rect(0, 0, esize.width, 0.esize.height) +}; + +//! @} imgproc_filter + +//! @addtogroup imgproc_transform +//! @{ + +//! interpolation algorithm +enum InterpolationFlags{ + /** nearest neighbor interpolation */ + INTER_NEAREST = 0, + /** bilinear interpolation */ + INTER_LINEAR = 1, + /** bicubic interpolation */ + INTER_CUBIC = 2, + /** resampling using pixel area relation. It may be a preferred method for image decimation, as + it gives moire'-free results. But when the image is zoomed, it is similar to the INTER_NEAREST + method. */ + INTER_AREA = 3, + /** Lanczos interpolation over 8x8 neighborhood */ + INTER_LANCZOS4 = 4, + /** Bit exact bilinear interpolation */ + INTER_LINEAR_EXACT = 5, + /** Bit exact nearest neighbor interpolation. This will produce same results as + the nearest neighbor method in PIL, scikit-image or Matlab. */ + INTER_NEAREST_EXACT = 6, + /** mask for interpolation codes */ + INTER_MAX = 7, + /** flag, fills all of the destination image pixels. If some of them correspond to outliers in the + source image, they are set to zero */ + WARP_FILL_OUTLIERS = 8, + /** flag, inverse transformation + + For example, #linearPolar or #logPolar transforms: + - flag is __not__ set: \f$dst( \rho , \phi ) = src(x,y)\f$ + - flag is set: \f$dst(x,y) = src( \rho , \phi )\f$ + */ + WARP_INVERSE_MAP = 16 +}; + +/** \brief Specify the polar mapping mode +@sa warpPolar +*/ +enum WarpPolarMode +{ + WARP_POLAR_LINEAR = 0, ///< Remaps an image to/from polar space. + WARP_POLAR_LOG = 256 ///< Remaps an image to/from semilog-polar space. +}; + +enum InterpolationMasks { + INTER_BITS = 5, + INTER_BITS2 = INTER_BITS * 2, + INTER_TAB_SIZE = 1 << INTER_BITS, + INTER_TAB_SIZE2 = INTER_TAB_SIZE * INTER_TAB_SIZE + }; + +//! @} imgproc_transform + +//! @addtogroup imgproc_misc +//! @{ + +//! Distance types for Distance Transform and M-estimators +//! @see distanceTransform, fitLine +enum DistanceTypes { + DIST_USER = -1, //!< User defined distance + DIST_L1 = 1, //!< distance = |x1-x2| + |y1-y2| + DIST_L2 = 2, //!< the simple euclidean distance + DIST_C = 3, //!< distance = max(|x1-x2|,|y1-y2|) + DIST_L12 = 4, //!< L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) + DIST_FAIR = 5, //!< distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 + DIST_WELSCH = 6, //!< distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 + DIST_HUBER = 7 //!< distance = |x| \texttt{thresh}\)}{0}{otherwise}\f] + THRESH_BINARY_INV = 1, //!< \f[\texttt{dst} (x,y) = \fork{0}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{maxval}}{otherwise}\f] + THRESH_TRUNC = 2, //!< \f[\texttt{dst} (x,y) = \fork{\texttt{threshold}}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{src}(x,y)}{otherwise}\f] + THRESH_TOZERO = 3, //!< \f[\texttt{dst} (x,y) = \fork{\texttt{src}(x,y)}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{0}{otherwise}\f] + THRESH_TOZERO_INV = 4, //!< \f[\texttt{dst} (x,y) = \fork{0}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{src}(x,y)}{otherwise}\f] + THRESH_MASK = 7, + THRESH_OTSU = 8, //!< flag, use Otsu algorithm to choose the optimal threshold value + THRESH_TRIANGLE = 16 //!< flag, use Triangle algorithm to choose the optimal threshold value +}; + +//! adaptive threshold algorithm +//! @see adaptiveThreshold +enum AdaptiveThresholdTypes { + /** the threshold value \f$T(x,y)\f$ is a mean of the \f$\texttt{blockSize} \times + \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$ minus C */ + ADAPTIVE_THRESH_MEAN_C = 0, + /** the threshold value \f$T(x, y)\f$ is a weighted sum (cross-correlation with a Gaussian + window) of the \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$ + minus C . The default sigma (standard deviation) is used for the specified blockSize . See + #getGaussianKernel*/ + ADAPTIVE_THRESH_GAUSSIAN_C = 1 +}; + +//! class of the pixel in GrabCut algorithm +enum GrabCutClasses { + GC_BGD = 0, //!< an obvious background pixels + GC_FGD = 1, //!< an obvious foreground (object) pixel + GC_PR_BGD = 2, //!< a possible background pixel + GC_PR_FGD = 3 //!< a possible foreground pixel +}; + +//! GrabCut algorithm flags +enum GrabCutModes { + /** The function initializes the state and the mask using the provided rectangle. After that it + runs iterCount iterations of the algorithm. */ + GC_INIT_WITH_RECT = 0, + /** The function initializes the state using the provided mask. Note that GC_INIT_WITH_RECT + and GC_INIT_WITH_MASK can be combined. Then, all the pixels outside of the ROI are + automatically initialized with GC_BGD .*/ + GC_INIT_WITH_MASK = 1, + /** The value means that the algorithm should just resume. */ + GC_EVAL = 2, + /** The value means that the algorithm should just run the grabCut algorithm (a single iteration) with the fixed model */ + GC_EVAL_FREEZE_MODEL = 3 +}; + +//! distanceTransform algorithm flags +enum DistanceTransformLabelTypes { + /** each connected component of zeros in src (as well as all the non-zero pixels closest to the + connected component) will be assigned the same label */ + DIST_LABEL_CCOMP = 0, + /** each zero pixel (and all the non-zero pixels closest to it) gets its own label. */ + DIST_LABEL_PIXEL = 1 +}; + +//! floodfill algorithm flags +enum FloodFillFlags { + /** If set, the difference between the current pixel and seed pixel is considered. Otherwise, + the difference between neighbor pixels is considered (that is, the range is floating). */ + FLOODFILL_FIXED_RANGE = 1 << 16, + /** If set, the function does not change the image ( newVal is ignored), and only fills the + mask with the value specified in bits 8-16 of flags as described above. This option only make + sense in function variants that have the mask parameter. */ + FLOODFILL_MASK_ONLY = 1 << 17 +}; + +//! @} imgproc_misc + +//! @addtogroup imgproc_shape +//! @{ + +//! connected components statistics +enum ConnectedComponentsTypes { + CC_STAT_LEFT = 0, //!< The leftmost (x) coordinate which is the inclusive start of the bounding + //!< box in the horizontal direction. + CC_STAT_TOP = 1, //!< The topmost (y) coordinate which is the inclusive start of the bounding + //!< box in the vertical direction. + CC_STAT_WIDTH = 2, //!< The horizontal size of the bounding box + CC_STAT_HEIGHT = 3, //!< The vertical size of the bounding box + CC_STAT_AREA = 4, //!< The total area (in pixels) of the connected component +#ifndef CV_DOXYGEN + CC_STAT_MAX = 5 //!< Max enumeration value. Used internally only for memory allocation +#endif +}; + +//! connected components algorithm +enum ConnectedComponentsAlgorithmsTypes { + CCL_DEFAULT = -1, //!< Spaghetti @cite Bolelli2019 algorithm for 8-way connectivity, Spaghetti4C @cite Bolelli2021 algorithm for 4-way connectivity. + CCL_WU = 0, //!< SAUF @cite Wu2009 algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity. The parallel implementation described in @cite Bolelli2017 is available for SAUF. + CCL_GRANA = 1, //!< BBDT @cite Grana2010 algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity. The parallel implementation described in @cite Bolelli2017 is available for both BBDT and SAUF. + CCL_BOLELLI = 2, //!< Spaghetti @cite Bolelli2019 algorithm for 8-way connectivity, Spaghetti4C @cite Bolelli2021 algorithm for 4-way connectivity. The parallel implementation described in @cite Bolelli2017 is available for both Spaghetti and Spaghetti4C. + CCL_SAUF = 3, //!< Same as CCL_WU. It is preferable to use the flag with the name of the algorithm (CCL_SAUF) rather than the one with the name of the first author (CCL_WU). + CCL_BBDT = 4, //!< Same as CCL_GRANA. It is preferable to use the flag with the name of the algorithm (CCL_BBDT) rather than the one with the name of the first author (CCL_GRANA). + CCL_SPAGHETTI = 5, //!< Same as CCL_BOLELLI. It is preferable to use the flag with the name of the algorithm (CCL_SPAGHETTI) rather than the one with the name of the first author (CCL_BOLELLI). +}; + +//! mode of the contour retrieval algorithm +enum RetrievalModes { + /** retrieves only the extreme outer contours. It sets `hierarchy[i][2]=hierarchy[i][3]=-1` for + all the contours. */ + RETR_EXTERNAL = 0, + /** retrieves all of the contours without establishing any hierarchical relationships. */ + RETR_LIST = 1, + /** retrieves all of the contours and organizes them into a two-level hierarchy. At the top + level, there are external boundaries of the components. At the second level, there are + boundaries of the holes. If there is another contour inside a hole of a connected component, it + is still put at the top level. */ + RETR_CCOMP = 2, + /** retrieves all of the contours and reconstructs a full hierarchy of nested contours.*/ + RETR_TREE = 3, + RETR_FLOODFILL = 4 //!< +}; + +//! the contour approximation algorithm +enum ContourApproximationModes { + /** stores absolutely all the contour points. That is, any 2 subsequent points (x1,y1) and + (x2,y2) of the contour will be either horizontal, vertical or diagonal neighbors, that is, + max(abs(x1-x2),abs(y2-y1))==1. */ + CHAIN_APPROX_NONE = 1, + /** compresses horizontal, vertical, and diagonal segments and leaves only their end points. + For example, an up-right rectangular contour is encoded with 4 points. */ + CHAIN_APPROX_SIMPLE = 2, + /** applies one of the flavors of the Teh-Chin chain approximation algorithm @cite TehChin89 */ + CHAIN_APPROX_TC89_L1 = 3, + /** applies one of the flavors of the Teh-Chin chain approximation algorithm @cite TehChin89 */ + CHAIN_APPROX_TC89_KCOS = 4 +}; + +/** @brief Shape matching methods + +\f$A\f$ denotes object1,\f$B\f$ denotes object2 + +\f$\begin{array}{l} m^A_i = \mathrm{sign} (h^A_i) \cdot \log{h^A_i} \\ m^B_i = \mathrm{sign} (h^B_i) \cdot \log{h^B_i} \end{array}\f$ + +and \f$h^A_i, h^B_i\f$ are the Hu moments of \f$A\f$ and \f$B\f$ , respectively. +*/ +enum ShapeMatchModes { + CONTOURS_MATCH_I1 =1, //!< \f[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\f] + CONTOURS_MATCH_I2 =2, //!< \f[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\f] + CONTOURS_MATCH_I3 =3 //!< \f[I_3(A,B) = \max _{i=1...7} \frac{ \left| m^A_i - m^B_i \right| }{ \left| m^A_i \right| }\f] +}; + +//! @} imgproc_shape + +//! @addtogroup imgproc_feature +//! @{ + +//! Variants of a Hough transform +enum HoughModes { + + /** classical or standard Hough transform. Every line is represented by two floating-point + numbers \f$(\rho, \theta)\f$ , where \f$\rho\f$ is a distance between (0,0) point and the line, + and \f$\theta\f$ is the angle between x-axis and the normal to the line. Thus, the matrix must + be (the created sequence will be) of CV_32FC2 type */ + HOUGH_STANDARD = 0, + /** probabilistic Hough transform (more efficient in case if the picture contains a few long + linear segments). It returns line segments rather than the whole line. Each segment is + represented by starting and ending points, and the matrix must be (the created sequence will + be) of the CV_32SC4 type. */ + HOUGH_PROBABILISTIC = 1, + /** multi-scale variant of the classical Hough transform. The lines are encoded the same way as + HOUGH_STANDARD. */ + HOUGH_MULTI_SCALE = 2, + HOUGH_GRADIENT = 3, //!< basically *21HT*, described in @cite Yuen90 + HOUGH_GRADIENT_ALT = 4, //!< variation of HOUGH_GRADIENT to get better accuracy +}; + +//! Variants of Line Segment %Detector +enum LineSegmentDetectorModes { + LSD_REFINE_NONE = 0, //!< No refinement applied + LSD_REFINE_STD = 1, //!< Standard refinement is applied. E.g. breaking arches into smaller straighter line approximations. + LSD_REFINE_ADV = 2 //!< Advanced refinement. Number of false alarms is calculated, lines are + //!< refined through increase of precision, decrement in size, etc. +}; + +//! @} imgproc_feature + +/** Histogram comparison methods + @ingroup imgproc_hist +*/ +enum HistCompMethods { + /** Correlation + \f[d(H_1,H_2) = \frac{\sum_I (H_1(I) - \bar{H_1}) (H_2(I) - \bar{H_2})}{\sqrt{\sum_I(H_1(I) - \bar{H_1})^2 \sum_I(H_2(I) - \bar{H_2})^2}}\f] + where + \f[\bar{H_k} = \frac{1}{N} \sum _J H_k(J)\f] + and \f$N\f$ is a total number of histogram bins. */ + HISTCMP_CORREL = 0, + /** Chi-Square + \f[d(H_1,H_2) = \sum _I \frac{\left(H_1(I)-H_2(I)\right)^2}{H_1(I)}\f] */ + HISTCMP_CHISQR = 1, + /** Intersection + \f[d(H_1,H_2) = \sum _I \min (H_1(I), H_2(I))\f] */ + HISTCMP_INTERSECT = 2, + /** Bhattacharyya distance + (In fact, OpenCV computes Hellinger distance, which is related to Bhattacharyya coefficient.) + \f[d(H_1,H_2) = \sqrt{1 - \frac{1}{\sqrt{\bar{H_1} \bar{H_2} N^2}} \sum_I \sqrt{H_1(I) \cdot H_2(I)}}\f] */ + HISTCMP_BHATTACHARYYA = 3, + HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA, //!< Synonym for HISTCMP_BHATTACHARYYA + /** Alternative Chi-Square + \f[d(H_1,H_2) = 2 * \sum _I \frac{\left(H_1(I)-H_2(I)\right)^2}{H_1(I)+H_2(I)}\f] + This alternative formula is regularly used for texture comparison. See e.g. @cite Puzicha1997 */ + HISTCMP_CHISQR_ALT = 4, + /** Kullback-Leibler divergence + \f[d(H_1,H_2) = \sum _I H_1(I) \log \left(\frac{H_1(I)}{H_2(I)}\right)\f] */ + HISTCMP_KL_DIV = 5 +}; + +/** the color conversion codes +@see @ref imgproc_color_conversions +@ingroup imgproc_color_conversions + */ +enum ColorConversionCodes { + COLOR_BGR2BGRA = 0, //!< add alpha channel to RGB or BGR image + COLOR_RGB2RGBA = COLOR_BGR2BGRA, + + COLOR_BGRA2BGR = 1, //!< remove alpha channel from RGB or BGR image + COLOR_RGBA2RGB = COLOR_BGRA2BGR, + + COLOR_BGR2RGBA = 2, //!< convert between RGB and BGR color spaces (with or without alpha channel) + COLOR_RGB2BGRA = COLOR_BGR2RGBA, + + COLOR_RGBA2BGR = 3, + COLOR_BGRA2RGB = COLOR_RGBA2BGR, + + COLOR_BGR2RGB = 4, + COLOR_RGB2BGR = COLOR_BGR2RGB, + + COLOR_BGRA2RGBA = 5, + COLOR_RGBA2BGRA = COLOR_BGRA2RGBA, + + COLOR_BGR2GRAY = 6, //!< convert between RGB/BGR and grayscale, @ref color_convert_rgb_gray "color conversions" + COLOR_RGB2GRAY = 7, + COLOR_GRAY2BGR = 8, + COLOR_GRAY2RGB = COLOR_GRAY2BGR, + COLOR_GRAY2BGRA = 9, + COLOR_GRAY2RGBA = COLOR_GRAY2BGRA, + COLOR_BGRA2GRAY = 10, + COLOR_RGBA2GRAY = 11, + + COLOR_BGR2BGR565 = 12, //!< convert between RGB/BGR and BGR565 (16-bit images) + COLOR_RGB2BGR565 = 13, + COLOR_BGR5652BGR = 14, + COLOR_BGR5652RGB = 15, + COLOR_BGRA2BGR565 = 16, + COLOR_RGBA2BGR565 = 17, + COLOR_BGR5652BGRA = 18, + COLOR_BGR5652RGBA = 19, + + COLOR_GRAY2BGR565 = 20, //!< convert between grayscale to BGR565 (16-bit images) + COLOR_BGR5652GRAY = 21, + + COLOR_BGR2BGR555 = 22, //!< convert between RGB/BGR and BGR555 (16-bit images) + COLOR_RGB2BGR555 = 23, + COLOR_BGR5552BGR = 24, + COLOR_BGR5552RGB = 25, + COLOR_BGRA2BGR555 = 26, + COLOR_RGBA2BGR555 = 27, + COLOR_BGR5552BGRA = 28, + COLOR_BGR5552RGBA = 29, + + COLOR_GRAY2BGR555 = 30, //!< convert between grayscale and BGR555 (16-bit images) + COLOR_BGR5552GRAY = 31, + + COLOR_BGR2XYZ = 32, //!< convert RGB/BGR to CIE XYZ, @ref color_convert_rgb_xyz "color conversions" + COLOR_RGB2XYZ = 33, + COLOR_XYZ2BGR = 34, + COLOR_XYZ2RGB = 35, + + COLOR_BGR2YCrCb = 36, //!< convert RGB/BGR to luma-chroma (aka YCC), @ref color_convert_rgb_ycrcb "color conversions" + COLOR_RGB2YCrCb = 37, + COLOR_YCrCb2BGR = 38, + COLOR_YCrCb2RGB = 39, + + COLOR_BGR2HSV = 40, //!< convert RGB/BGR to HSV (hue saturation value) with H range 0..180 if 8 bit image, @ref color_convert_rgb_hsv "color conversions" + COLOR_RGB2HSV = 41, + + COLOR_BGR2Lab = 44, //!< convert RGB/BGR to CIE Lab, @ref color_convert_rgb_lab "color conversions" + COLOR_RGB2Lab = 45, + + COLOR_BGR2Luv = 50, //!< convert RGB/BGR to CIE Luv, @ref color_convert_rgb_luv "color conversions" + COLOR_RGB2Luv = 51, + COLOR_BGR2HLS = 52, //!< convert RGB/BGR to HLS (hue lightness saturation) with H range 0..180 if 8 bit image, @ref color_convert_rgb_hls "color conversions" + COLOR_RGB2HLS = 53, + + COLOR_HSV2BGR = 54, //!< backward conversions HSV to RGB/BGR with H range 0..180 if 8 bit image + COLOR_HSV2RGB = 55, + + COLOR_Lab2BGR = 56, + COLOR_Lab2RGB = 57, + COLOR_Luv2BGR = 58, + COLOR_Luv2RGB = 59, + COLOR_HLS2BGR = 60, //!< backward conversions HLS to RGB/BGR with H range 0..180 if 8 bit image + COLOR_HLS2RGB = 61, + + COLOR_BGR2HSV_FULL = 66, //!< convert RGB/BGR to HSV (hue saturation value) with H range 0..255 if 8 bit image, @ref color_convert_rgb_hsv "color conversions" + COLOR_RGB2HSV_FULL = 67, + COLOR_BGR2HLS_FULL = 68, //!< convert RGB/BGR to HLS (hue lightness saturation) with H range 0..255 if 8 bit image, @ref color_convert_rgb_hls "color conversions" + COLOR_RGB2HLS_FULL = 69, + + COLOR_HSV2BGR_FULL = 70, //!< backward conversions HSV to RGB/BGR with H range 0..255 if 8 bit image + COLOR_HSV2RGB_FULL = 71, + COLOR_HLS2BGR_FULL = 72, //!< backward conversions HLS to RGB/BGR with H range 0..255 if 8 bit image + COLOR_HLS2RGB_FULL = 73, + + COLOR_LBGR2Lab = 74, + COLOR_LRGB2Lab = 75, + COLOR_LBGR2Luv = 76, + COLOR_LRGB2Luv = 77, + + COLOR_Lab2LBGR = 78, + COLOR_Lab2LRGB = 79, + COLOR_Luv2LBGR = 80, + COLOR_Luv2LRGB = 81, + + COLOR_BGR2YUV = 82, //!< convert between RGB/BGR and YUV + COLOR_RGB2YUV = 83, + COLOR_YUV2BGR = 84, + COLOR_YUV2RGB = 85, + + //! YUV 4:2:0 family to RGB + COLOR_YUV2RGB_NV12 = 90, + COLOR_YUV2BGR_NV12 = 91, + COLOR_YUV2RGB_NV21 = 92, + COLOR_YUV2BGR_NV21 = 93, + COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21, + COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21, + + COLOR_YUV2RGBA_NV12 = 94, + COLOR_YUV2BGRA_NV12 = 95, + COLOR_YUV2RGBA_NV21 = 96, + COLOR_YUV2BGRA_NV21 = 97, + COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21, + COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21, + + COLOR_YUV2RGB_YV12 = 98, + COLOR_YUV2BGR_YV12 = 99, + COLOR_YUV2RGB_IYUV = 100, + COLOR_YUV2BGR_IYUV = 101, + COLOR_YUV2RGB_I420 = COLOR_YUV2RGB_IYUV, + COLOR_YUV2BGR_I420 = COLOR_YUV2BGR_IYUV, + COLOR_YUV420p2RGB = COLOR_YUV2RGB_YV12, + COLOR_YUV420p2BGR = COLOR_YUV2BGR_YV12, + + COLOR_YUV2RGBA_YV12 = 102, + COLOR_YUV2BGRA_YV12 = 103, + COLOR_YUV2RGBA_IYUV = 104, + COLOR_YUV2BGRA_IYUV = 105, + COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV, + COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV, + COLOR_YUV420p2RGBA = COLOR_YUV2RGBA_YV12, + COLOR_YUV420p2BGRA = COLOR_YUV2BGRA_YV12, + + COLOR_YUV2GRAY_420 = 106, + COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420, + COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420, + COLOR_YUV420p2GRAY = COLOR_YUV2GRAY_420, + + //! YUV 4:2:2 family to RGB + COLOR_YUV2RGB_UYVY = 107, + COLOR_YUV2BGR_UYVY = 108, + //COLOR_YUV2RGB_VYUY = 109, + //COLOR_YUV2BGR_VYUY = 110, + COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY, + COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY, + COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY, + COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY, + + COLOR_YUV2RGBA_UYVY = 111, + COLOR_YUV2BGRA_UYVY = 112, + //COLOR_YUV2RGBA_VYUY = 113, + //COLOR_YUV2BGRA_VYUY = 114, + COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY, + COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY, + COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY, + COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY, + + COLOR_YUV2RGB_YUY2 = 115, + COLOR_YUV2BGR_YUY2 = 116, + COLOR_YUV2RGB_YVYU = 117, + COLOR_YUV2BGR_YVYU = 118, + COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2, + COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2, + COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2, + COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2, + + COLOR_YUV2RGBA_YUY2 = 119, + COLOR_YUV2BGRA_YUY2 = 120, + COLOR_YUV2RGBA_YVYU = 121, + COLOR_YUV2BGRA_YVYU = 122, + COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2, + COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2, + COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2, + COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2, + + COLOR_YUV2GRAY_UYVY = 123, + COLOR_YUV2GRAY_YUY2 = 124, + //CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY, + COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY, + COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY, + COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2, + COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2, + COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2, + + //! alpha premultiplication + COLOR_RGBA2mRGBA = 125, + COLOR_mRGBA2RGBA = 126, + + //! RGB to YUV 4:2:0 family + COLOR_RGB2YUV_I420 = 127, + COLOR_BGR2YUV_I420 = 128, + COLOR_RGB2YUV_IYUV = COLOR_RGB2YUV_I420, + COLOR_BGR2YUV_IYUV = COLOR_BGR2YUV_I420, + + COLOR_RGBA2YUV_I420 = 129, + COLOR_BGRA2YUV_I420 = 130, + COLOR_RGBA2YUV_IYUV = COLOR_RGBA2YUV_I420, + COLOR_BGRA2YUV_IYUV = COLOR_BGRA2YUV_I420, + COLOR_RGB2YUV_YV12 = 131, + COLOR_BGR2YUV_YV12 = 132, + COLOR_RGBA2YUV_YV12 = 133, + COLOR_BGRA2YUV_YV12 = 134, + + //! Demosaicing, see @ref color_convert_bayer "color conversions" for additional information + COLOR_BayerBG2BGR = 46, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGR = 47, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGR = 48, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGR = 49, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGR = COLOR_BayerBG2BGR, + COLOR_BayerGRBG2BGR = COLOR_BayerGB2BGR, + COLOR_BayerBGGR2BGR = COLOR_BayerRG2BGR, + COLOR_BayerGBRG2BGR = COLOR_BayerGR2BGR, + + COLOR_BayerRGGB2RGB = COLOR_BayerBGGR2BGR, + COLOR_BayerGRBG2RGB = COLOR_BayerGBRG2BGR, + COLOR_BayerBGGR2RGB = COLOR_BayerRGGB2BGR, + COLOR_BayerGBRG2RGB = COLOR_BayerGRBG2BGR, + + COLOR_BayerBG2RGB = COLOR_BayerRG2BGR, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGB = COLOR_BayerGR2BGR, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGB = COLOR_BayerBG2BGR, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGB = COLOR_BayerGB2BGR, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerBG2GRAY = 86, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2GRAY = 87, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2GRAY = 88, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2GRAY = 89, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2GRAY = COLOR_BayerBG2GRAY, + COLOR_BayerGRBG2GRAY = COLOR_BayerGB2GRAY, + COLOR_BayerBGGR2GRAY = COLOR_BayerRG2GRAY, + COLOR_BayerGBRG2GRAY = COLOR_BayerGR2GRAY, + + //! Demosaicing using Variable Number of Gradients + COLOR_BayerBG2BGR_VNG = 62, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGR_VNG = 63, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGR_VNG = 64, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGR_VNG = 65, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGR_VNG = COLOR_BayerBG2BGR_VNG, + COLOR_BayerGRBG2BGR_VNG = COLOR_BayerGB2BGR_VNG, + COLOR_BayerBGGR2BGR_VNG = COLOR_BayerRG2BGR_VNG, + COLOR_BayerGBRG2BGR_VNG = COLOR_BayerGR2BGR_VNG, + + COLOR_BayerRGGB2RGB_VNG = COLOR_BayerBGGR2BGR_VNG, + COLOR_BayerGRBG2RGB_VNG = COLOR_BayerGBRG2BGR_VNG, + COLOR_BayerBGGR2RGB_VNG = COLOR_BayerRGGB2BGR_VNG, + COLOR_BayerGBRG2RGB_VNG = COLOR_BayerGRBG2BGR_VNG, + + COLOR_BayerBG2RGB_VNG = COLOR_BayerRG2BGR_VNG, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGB_VNG = COLOR_BayerGR2BGR_VNG, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGB_VNG = COLOR_BayerBG2BGR_VNG, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGB_VNG = COLOR_BayerGB2BGR_VNG, //!< equivalent to GBRG Bayer pattern + + //! Edge-Aware Demosaicing + COLOR_BayerBG2BGR_EA = 135, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGR_EA = 136, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGR_EA = 137, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGR_EA = 138, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGR_EA = COLOR_BayerBG2BGR_EA, + COLOR_BayerGRBG2BGR_EA = COLOR_BayerGB2BGR_EA, + COLOR_BayerBGGR2BGR_EA = COLOR_BayerRG2BGR_EA, + COLOR_BayerGBRG2BGR_EA = COLOR_BayerGR2BGR_EA, + + COLOR_BayerRGGB2RGB_EA = COLOR_BayerBGGR2BGR_EA, + COLOR_BayerGRBG2RGB_EA = COLOR_BayerGBRG2BGR_EA, + COLOR_BayerBGGR2RGB_EA = COLOR_BayerRGGB2BGR_EA, + COLOR_BayerGBRG2RGB_EA = COLOR_BayerGRBG2BGR_EA, + + COLOR_BayerBG2RGB_EA = COLOR_BayerRG2BGR_EA, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGB_EA = COLOR_BayerGR2BGR_EA, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGB_EA = COLOR_BayerBG2BGR_EA, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGB_EA = COLOR_BayerGB2BGR_EA, //!< equivalent to GBRG Bayer pattern + + //! Demosaicing with alpha channel + COLOR_BayerBG2BGRA = 139, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGRA = 140, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGRA = 141, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGRA = 142, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGRA = COLOR_BayerBG2BGRA, + COLOR_BayerGRBG2BGRA = COLOR_BayerGB2BGRA, + COLOR_BayerBGGR2BGRA = COLOR_BayerRG2BGRA, + COLOR_BayerGBRG2BGRA = COLOR_BayerGR2BGRA, + + COLOR_BayerRGGB2RGBA = COLOR_BayerBGGR2BGRA, + COLOR_BayerGRBG2RGBA = COLOR_BayerGBRG2BGRA, + COLOR_BayerBGGR2RGBA = COLOR_BayerRGGB2BGRA, + COLOR_BayerGBRG2RGBA = COLOR_BayerGRBG2BGRA, + + COLOR_BayerBG2RGBA = COLOR_BayerRG2BGRA, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGBA = COLOR_BayerGR2BGRA, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGBA = COLOR_BayerBG2BGRA, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGBA = COLOR_BayerGB2BGRA, //!< equivalent to GBRG Bayer pattern + + COLOR_COLORCVT_MAX = 143 +}; + +//! @addtogroup imgproc_shape +//! @{ + +//! types of intersection between rectangles +enum RectanglesIntersectTypes { + INTERSECT_NONE = 0, //!< No intersection + INTERSECT_PARTIAL = 1, //!< There is a partial intersection + INTERSECT_FULL = 2 //!< One of the rectangle is fully enclosed in the other +}; + +/** types of line +@ingroup imgproc_draw +*/ +enum LineTypes { + FILLED = -1, + LINE_4 = 4, //!< 4-connected line + LINE_8 = 8, //!< 8-connected line + LINE_AA = 16 //!< antialiased line +}; + +/** Only a subset of Hershey fonts are supported +@ingroup imgproc_draw +*/ +enum HersheyFonts { + FONT_HERSHEY_SIMPLEX = 0, //!< normal size sans-serif font + FONT_HERSHEY_PLAIN = 1, //!< small size sans-serif font + FONT_HERSHEY_DUPLEX = 2, //!< normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX) + FONT_HERSHEY_COMPLEX = 3, //!< normal size serif font + FONT_HERSHEY_TRIPLEX = 4, //!< normal size serif font (more complex than FONT_HERSHEY_COMPLEX) + FONT_HERSHEY_COMPLEX_SMALL = 5, //!< smaller version of FONT_HERSHEY_COMPLEX + FONT_HERSHEY_SCRIPT_SIMPLEX = 6, //!< hand-writing style font + FONT_HERSHEY_SCRIPT_COMPLEX = 7, //!< more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX + FONT_ITALIC = 16 //!< flag for italic font +}; + +/** Possible set of marker types used for the cv::drawMarker function +@ingroup imgproc_draw +*/ +enum MarkerTypes +{ + MARKER_CROSS = 0, //!< A crosshair marker shape + MARKER_TILTED_CROSS = 1, //!< A 45 degree tilted crosshair marker shape + MARKER_STAR = 2, //!< A star marker shape, combination of cross and tilted cross + MARKER_DIAMOND = 3, //!< A diamond marker shape + MARKER_SQUARE = 4, //!< A square marker shape + MARKER_TRIANGLE_UP = 5, //!< An upwards pointing triangle marker shape + MARKER_TRIANGLE_DOWN = 6 //!< A downwards pointing triangle marker shape +}; + +/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform +*/ +class CV_EXPORTS_W GeneralizedHough : public Algorithm +{ +public: + //! set template to search + CV_WRAP virtual void setTemplate(InputArray templ, Point templCenter = Point(-1, -1)) = 0; + CV_WRAP virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0; + + //! find template on image + CV_WRAP virtual void detect(InputArray image, OutputArray positions, OutputArray votes = noArray()) = 0; + CV_WRAP virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions, OutputArray votes = noArray()) = 0; + + //! Canny low threshold. + CV_WRAP virtual void setCannyLowThresh(int cannyLowThresh) = 0; + CV_WRAP virtual int getCannyLowThresh() const = 0; + + //! Canny high threshold. + CV_WRAP virtual void setCannyHighThresh(int cannyHighThresh) = 0; + CV_WRAP virtual int getCannyHighThresh() const = 0; + + //! Minimum distance between the centers of the detected objects. + CV_WRAP virtual void setMinDist(double minDist) = 0; + CV_WRAP virtual double getMinDist() const = 0; + + //! Inverse ratio of the accumulator resolution to the image resolution. + CV_WRAP virtual void setDp(double dp) = 0; + CV_WRAP virtual double getDp() const = 0; + + //! Maximal size of inner buffers. + CV_WRAP virtual void setMaxBufferSize(int maxBufferSize) = 0; + CV_WRAP virtual int getMaxBufferSize() const = 0; +}; + +/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform + +Detects position only without translation and rotation @cite Ballard1981 . +*/ +class CV_EXPORTS_W GeneralizedHoughBallard : public GeneralizedHough +{ +public: + //! R-Table levels. + CV_WRAP virtual void setLevels(int levels) = 0; + CV_WRAP virtual int getLevels() const = 0; + + //! The accumulator threshold for the template centers at the detection stage. The smaller it is, the more false positions may be detected. + CV_WRAP virtual void setVotesThreshold(int votesThreshold) = 0; + CV_WRAP virtual int getVotesThreshold() const = 0; +}; + +/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform + +Detects position, translation and rotation @cite Guil1999 . +*/ +class CV_EXPORTS_W GeneralizedHoughGuil : public GeneralizedHough +{ +public: + //! Angle difference in degrees between two points in feature. + CV_WRAP virtual void setXi(double xi) = 0; + CV_WRAP virtual double getXi() const = 0; + + //! Feature table levels. + CV_WRAP virtual void setLevels(int levels) = 0; + CV_WRAP virtual int getLevels() const = 0; + + //! Maximal difference between angles that treated as equal. + CV_WRAP virtual void setAngleEpsilon(double angleEpsilon) = 0; + CV_WRAP virtual double getAngleEpsilon() const = 0; + + //! Minimal rotation angle to detect in degrees. + CV_WRAP virtual void setMinAngle(double minAngle) = 0; + CV_WRAP virtual double getMinAngle() const = 0; + + //! Maximal rotation angle to detect in degrees. + CV_WRAP virtual void setMaxAngle(double maxAngle) = 0; + CV_WRAP virtual double getMaxAngle() const = 0; + + //! Angle step in degrees. + CV_WRAP virtual void setAngleStep(double angleStep) = 0; + CV_WRAP virtual double getAngleStep() const = 0; + + //! Angle votes threshold. + CV_WRAP virtual void setAngleThresh(int angleThresh) = 0; + CV_WRAP virtual int getAngleThresh() const = 0; + + //! Minimal scale to detect. + CV_WRAP virtual void setMinScale(double minScale) = 0; + CV_WRAP virtual double getMinScale() const = 0; + + //! Maximal scale to detect. + CV_WRAP virtual void setMaxScale(double maxScale) = 0; + CV_WRAP virtual double getMaxScale() const = 0; + + //! Scale step. + CV_WRAP virtual void setScaleStep(double scaleStep) = 0; + CV_WRAP virtual double getScaleStep() const = 0; + + //! Scale votes threshold. + CV_WRAP virtual void setScaleThresh(int scaleThresh) = 0; + CV_WRAP virtual int getScaleThresh() const = 0; + + //! Position votes threshold. + CV_WRAP virtual void setPosThresh(int posThresh) = 0; + CV_WRAP virtual int getPosThresh() const = 0; +}; + +//! @} imgproc_shape + +//! @addtogroup imgproc_hist +//! @{ + +/** @brief Base class for Contrast Limited Adaptive Histogram Equalization. +*/ +class CV_EXPORTS_W CLAHE : public Algorithm +{ +public: + /** @brief Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization. + + @param src Source image of type CV_8UC1 or CV_16UC1. + @param dst Destination image. + */ + CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0; + + /** @brief Sets threshold for contrast limiting. + + @param clipLimit threshold value. + */ + CV_WRAP virtual void setClipLimit(double clipLimit) = 0; + + //! Returns threshold value for contrast limiting. + CV_WRAP virtual double getClipLimit() const = 0; + + /** @brief Sets size of grid for histogram equalization. Input image will be divided into + equally sized rectangular tiles. + + @param tileGridSize defines the number of tiles in row and column. + */ + CV_WRAP virtual void setTilesGridSize(Size tileGridSize) = 0; + + //!@brief Returns Size defines the number of tiles in row and column. + CV_WRAP virtual Size getTilesGridSize() const = 0; + + CV_WRAP virtual void collectGarbage() = 0; +}; + +//! @} imgproc_hist + +//! @addtogroup imgproc_subdiv2d +//! @{ + +class CV_EXPORTS_W Subdiv2D +{ +public: + /** Subdiv2D point location cases */ + enum { PTLOC_ERROR = -2, //!< Point location error + PTLOC_OUTSIDE_RECT = -1, //!< Point outside the subdivision bounding rect + PTLOC_INSIDE = 0, //!< Point inside some facet + PTLOC_VERTEX = 1, //!< Point coincides with one of the subdivision vertices + PTLOC_ON_EDGE = 2 //!< Point on some edge + }; + + /** Subdiv2D edge type navigation (see: getEdge()) */ + enum { NEXT_AROUND_ORG = 0x00, + NEXT_AROUND_DST = 0x22, + PREV_AROUND_ORG = 0x11, + PREV_AROUND_DST = 0x33, + NEXT_AROUND_LEFT = 0x13, + NEXT_AROUND_RIGHT = 0x31, + PREV_AROUND_LEFT = 0x20, + PREV_AROUND_RIGHT = 0x02 + }; + + /** creates an empty Subdiv2D object. + To create a new empty Delaunay subdivision you need to use the #initDelaunay function. + */ + CV_WRAP Subdiv2D(); + + /** @overload + + @param rect Rectangle that includes all of the 2D points that are to be added to the subdivision. + + The function creates an empty Delaunay subdivision where 2D points can be added using the function + insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime + error is raised. + */ + CV_WRAP Subdiv2D(Rect rect); + + /** @brief Creates a new empty Delaunay subdivision + + @param rect Rectangle that includes all of the 2D points that are to be added to the subdivision. + + */ + CV_WRAP void initDelaunay(Rect rect); + + /** @brief Insert a single point into a Delaunay triangulation. + + @param pt Point to insert. + + The function inserts a single point into a subdivision and modifies the subdivision topology + appropriately. If a point with the same coordinates exists already, no new point is added. + @returns the ID of the point. + + @note If the point is outside of the triangulation specified rect a runtime error is raised. + */ + CV_WRAP int insert(Point2f pt); + + /** @brief Insert multiple points into a Delaunay triangulation. + + @param ptvec Points to insert. + + The function inserts a vector of points into a subdivision and modifies the subdivision topology + appropriately. + */ + CV_WRAP void insert(const std::vector& ptvec); + + /** @brief Returns the location of a point within a Delaunay triangulation. + + @param pt Point to locate. + @param edge Output edge that the point belongs to or is located to the right of it. + @param vertex Optional output vertex the input point coincides with. + + The function locates the input point within the subdivision and gives one of the triangle edges + or vertices. + + @returns an integer which specify one of the following five cases for point location: + - The point falls into some facet. The function returns #PTLOC_INSIDE and edge will contain one of + edges of the facet. + - The point falls onto the edge. The function returns #PTLOC_ON_EDGE and edge will contain this edge. + - The point coincides with one of the subdivision vertices. The function returns #PTLOC_VERTEX and + vertex will contain a pointer to the vertex. + - The point is outside the subdivision reference rectangle. The function returns #PTLOC_OUTSIDE_RECT + and no pointers are filled. + - One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error + processing mode is selected, #PTLOC_ERROR is returned. + */ + CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex); + + /** @brief Finds the subdivision vertex closest to the given point. + + @param pt Input point. + @param nearestPt Output subdivision vertex point. + + The function is another function that locates the input point within the subdivision. It finds the + subdivision vertex that is the closest to the input point. It is not necessarily one of vertices + of the facet containing the input point, though the facet (located using locate() ) is used as a + starting point. + + @returns vertex ID. + */ + CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt = 0); + + /** @brief Returns a list of all edges. + + @param edgeList Output vector. + + The function gives each edge as a 4 numbers vector, where each two are one of the edge + vertices. i.e. org_x = v[0], org_y = v[1], dst_x = v[2], dst_y = v[3]. + */ + CV_WRAP void getEdgeList(CV_OUT std::vector& edgeList) const; + + /** @brief Returns a list of the leading edge ID connected to each triangle. + + @param leadingEdgeList Output vector. + + The function gives one edge ID for each triangle. + */ + CV_WRAP void getLeadingEdgeList(CV_OUT std::vector& leadingEdgeList) const; + + /** @brief Returns a list of all triangles. + + @param triangleList Output vector. + + The function gives each triangle as a 6 numbers vector, where each two are one of the triangle + vertices. i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5]. + */ + CV_WRAP void getTriangleList(CV_OUT std::vector& triangleList) const; + + /** @brief Returns a list of all Voronoi facets. + + @param idx Vector of vertices IDs to consider. For all vertices you can pass empty vector. + @param facetList Output vector of the Voronoi facets. + @param facetCenters Output vector of the Voronoi facets center points. + + */ + CV_WRAP void getVoronoiFacetList(const std::vector& idx, CV_OUT std::vector >& facetList, + CV_OUT std::vector& facetCenters); + + /** @brief Returns vertex location from vertex ID. + + @param vertex vertex ID. + @param firstEdge Optional. The first edge ID which is connected to the vertex. + @returns vertex (x,y) + + */ + CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge = 0) const; + + /** @brief Returns one of the edges related to the given edge. + + @param edge Subdivision edge ID. + @param nextEdgeType Parameter specifying which of the related edges to return. + The following values are possible: + - NEXT_AROUND_ORG next around the edge origin ( eOnext on the picture below if e is the input edge) + - NEXT_AROUND_DST next around the edge vertex ( eDnext ) + - PREV_AROUND_ORG previous around the edge origin (reversed eRnext ) + - PREV_AROUND_DST previous around the edge destination (reversed eLnext ) + - NEXT_AROUND_LEFT next around the left facet ( eLnext ) + - NEXT_AROUND_RIGHT next around the right facet ( eRnext ) + - PREV_AROUND_LEFT previous around the left facet (reversed eOnext ) + - PREV_AROUND_RIGHT previous around the right facet (reversed eDnext ) + + ![sample output](pics/quadedge.png) + + @returns edge ID related to the input edge. + */ + CV_WRAP int getEdge( int edge, int nextEdgeType ) const; + + /** @brief Returns next edge around the edge origin. + + @param edge Subdivision edge ID. + + @returns an integer which is next edge ID around the edge origin: eOnext on the + picture above if e is the input edge). + */ + CV_WRAP int nextEdge(int edge) const; + + /** @brief Returns another edge of the same quad-edge. + + @param edge Subdivision edge ID. + @param rotate Parameter specifying which of the edges of the same quad-edge as the input + one to return. The following values are possible: + - 0 - the input edge ( e on the picture below if e is the input edge) + - 1 - the rotated edge ( eRot ) + - 2 - the reversed edge (reversed e (in green)) + - 3 - the reversed rotated edge (reversed eRot (in green)) + + @returns one of the edges ID of the same quad-edge as the input edge. + */ + CV_WRAP int rotateEdge(int edge, int rotate) const; + CV_WRAP int symEdge(int edge) const; + + /** @brief Returns the edge origin. + + @param edge Subdivision edge ID. + @param orgpt Output vertex location. + + @returns vertex ID. + */ + CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt = 0) const; + + /** @brief Returns the edge destination. + + @param edge Subdivision edge ID. + @param dstpt Output vertex location. + + @returns vertex ID. + */ + CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt = 0) const; + +protected: + int newEdge(); + void deleteEdge(int edge); + int newPoint(Point2f pt, bool isvirtual, int firstEdge = 0); + void deletePoint(int vtx); + void setEdgePoints( int edge, int orgPt, int dstPt ); + void splice( int edgeA, int edgeB ); + int connectEdges( int edgeA, int edgeB ); + void swapEdges( int edge ); + int isRightOf(Point2f pt, int edge) const; + void calcVoronoi(); + void clearVoronoi(); + void checkSubdiv() const; + + struct CV_EXPORTS Vertex + { + Vertex(); + Vertex(Point2f pt, bool isvirtual, int firstEdge=0); + bool isvirtual() const; + bool isfree() const; + + int firstEdge; + int type; + Point2f pt; + }; + + struct CV_EXPORTS QuadEdge + { + QuadEdge(); + QuadEdge(int edgeidx); + bool isfree() const; + + int next[4]; + int pt[4]; + }; + + //! All of the vertices + std::vector vtx; + //! All of the edges + std::vector qedges; + int freeQEdge; + int freePoint; + bool validGeometry; + + int recentEdge; + //! Top left corner of the bounding rect + Point2f topLeft; + //! Bottom right corner of the bounding rect + Point2f bottomRight; +}; + +//! @} imgproc_subdiv2d + +//! @addtogroup imgproc_feature +//! @{ + +/** @example samples/cpp/lsd_lines.cpp +An example using the LineSegmentDetector +\image html building_lsd.png "Sample output image" width=434 height=300 +*/ + +/** @brief Line segment detector class + +following the algorithm described at @cite Rafael12 . + +@note Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict. +restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license. +*/ +class CV_EXPORTS_W LineSegmentDetector : public Algorithm +{ +public: + + /** @brief Finds lines in the input image. + + This is the output of the default parameters of the algorithm on the above shown image. + + ![image](pics/building_lsd.png) + + @param image A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use: + `lsd_ptr-\>detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);` + @param lines A vector of Vec4f elements specifying the beginning and ending point of a line. Where + Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly + oriented depending on the gradient. + @param width Vector of widths of the regions, where the lines are found. E.g. Width of line. + @param prec Vector of precisions with which the lines are found. + @param nfa Vector containing number of false alarms in the line region, with precision of 10%. The + bigger the value, logarithmically better the detection. + - -1 corresponds to 10 mean false alarms + - 0 corresponds to 1 mean false alarm + - 1 corresponds to 0.1 mean false alarms + This vector will be calculated only when the objects type is #LSD_REFINE_ADV. + */ + CV_WRAP virtual void detect(InputArray image, OutputArray lines, + OutputArray width = noArray(), OutputArray prec = noArray(), + OutputArray nfa = noArray()) = 0; + + /** @brief Draws the line segments on a given image. + @param image The image, where the lines will be drawn. Should be bigger or equal to the image, + where the lines were found. + @param lines A vector of the lines that needed to be drawn. + */ + CV_WRAP virtual void drawSegments(InputOutputArray image, InputArray lines) = 0; + + /** @brief Draws two groups of lines in blue and red, counting the non overlapping (mismatching) pixels. + + @param size The size of the image, where lines1 and lines2 were found. + @param lines1 The first group of lines that needs to be drawn. It is visualized in blue color. + @param lines2 The second group of lines. They visualized in red color. + @param image Optional image, where the lines will be drawn. The image should be color(3-channel) + in order for lines1 and lines2 to be drawn in the above mentioned colors. + */ + CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray image = noArray()) = 0; + + virtual ~LineSegmentDetector() { } +}; + +/** @brief Creates a smart pointer to a LineSegmentDetector object and initializes it. + +The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want +to edit those, as to tailor it for their own application. + +@param refine The way found lines will be refined, see #LineSegmentDetectorModes +@param scale The scale of the image that will be used to find the lines. Range (0..1]. +@param sigma_scale Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale. +@param quant Bound to the quantization error on the gradient norm. +@param ang_th Gradient angle tolerance in degrees. +@param log_eps Detection threshold: -log10(NFA) \> log_eps. Used only when advance refinement is chosen. +@param density_th Minimal density of aligned region points in the enclosing rectangle. +@param n_bins Number of bins in pseudo-ordering of gradient modulus. + */ +CV_EXPORTS_W Ptr createLineSegmentDetector( + int refine = LSD_REFINE_STD, double scale = 0.8, + double sigma_scale = 0.6, double quant = 2.0, double ang_th = 22.5, + double log_eps = 0, double density_th = 0.7, int n_bins = 1024); + +//! @} imgproc_feature + +//! @addtogroup imgproc_filter +//! @{ + +/** @brief Returns Gaussian filter coefficients. + +The function computes and returns the \f$\texttt{ksize} \times 1\f$ matrix of Gaussian filter +coefficients: + +\f[G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)},\f] + +where \f$i=0..\texttt{ksize}-1\f$ and \f$\alpha\f$ is the scale factor chosen so that \f$\sum_i G_i=1\f$. + +Two of such generated kernels can be passed to sepFilter2D. Those functions automatically recognize +smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly. +You may also use the higher-level GaussianBlur. +@param ksize Aperture size. It should be odd ( \f$\texttt{ksize} \mod 2 = 1\f$ ) and positive. +@param sigma Gaussian standard deviation. If it is non-positive, it is computed from ksize as +`sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8`. +@param ktype Type of filter coefficients. It can be CV_32F or CV_64F . +@sa sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur + */ +CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F ); + +/** @brief Returns filter coefficients for computing spatial image derivatives. + +The function computes and returns the filter coefficients for spatial image derivatives. When +`ksize=FILTER_SCHARR`, the Scharr \f$3 \times 3\f$ kernels are generated (see #Scharr). Otherwise, Sobel +kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to + +@param kx Output matrix of row filter coefficients. It has the type ktype . +@param ky Output matrix of column filter coefficients. It has the type ktype . +@param dx Derivative order in respect of x. +@param dy Derivative order in respect of y. +@param ksize Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7. +@param normalize Flag indicating whether to normalize (scale down) the filter coefficients or not. +Theoretically, the coefficients should have the denominator \f$=2^{ksize*2-dx-dy-2}\f$. If you are +going to filter floating-point images, you are likely to use the normalized kernels. But if you +compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve +all the fractional bits, you may want to set normalize=false . +@param ktype Type of filter coefficients. It can be CV_32f or CV_64F . + */ +CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky, + int dx, int dy, int ksize, + bool normalize = false, int ktype = CV_32F ); + +/** @brief Returns Gabor filter coefficients. + +For more details about gabor filter equations and parameters, see: [Gabor +Filter](http://en.wikipedia.org/wiki/Gabor_filter). + +@param ksize Size of the filter returned. +@param sigma Standard deviation of the gaussian envelope. +@param theta Orientation of the normal to the parallel stripes of a Gabor function. +@param lambd Wavelength of the sinusoidal factor. +@param gamma Spatial aspect ratio. +@param psi Phase offset. +@param ktype Type of filter coefficients. It can be CV_32F or CV_64F . + */ +CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd, + double gamma, double psi = CV_PI*0.5, int ktype = CV_64F ); + +//! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation. +static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); } + +/** @brief Returns a structuring element of the specified size and shape for morphological operations. + +The function constructs and returns the structuring element that can be further passed to #erode, +#dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as +the structuring element. + +@param shape Element shape that could be one of #MorphShapes +@param ksize Size of the structuring element. +@param anchor Anchor position within the element. The default value \f$(-1, -1)\f$ means that the +anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor +position. In other cases the anchor just regulates how much the result of the morphological +operation is shifted. + */ +CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1)); + +/** @example samples/cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp +Sample code for simple filters +![Sample screenshot](Smoothing_Tutorial_Result_Median_Filter.jpg) +Check @ref tutorial_gausian_median_blur_bilateral_filter "the corresponding tutorial" for more details + */ + +/** @brief Blurs an image using the median filter. + +The function smoothes an image using the median filter with the \f$\texttt{ksize} \times +\texttt{ksize}\f$ aperture. Each channel of a multi-channel image is processed independently. +In-place operation is supported. + +@note The median filter uses #BORDER_REPLICATE internally to cope with border pixels, see #BorderTypes + +@param src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be +CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U. +@param dst destination array of the same size and type as src. +@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ... +@sa bilateralFilter, blur, boxFilter, GaussianBlur + */ +CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize ); + +/** @brief Blurs an image using a Gaussian filter. + +The function convolves the source image with the specified Gaussian kernel. In-place filtering is +supported. + +@param src input image; the image can have any number of channels, which are processed +independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param ksize Gaussian kernel size. ksize.width and ksize.height can differ but they both must be +positive and odd. Or, they can be zero's and then they are computed from sigma. +@param sigmaX Gaussian kernel standard deviation in X direction. +@param sigmaY Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be +equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, +respectively (see #getGaussianKernel for details); to fully control the result regardless of +possible future modifications of all this semantics, it is recommended to specify all of ksize, +sigmaX, and sigmaY. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. + +@sa sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur + */ +CV_EXPORTS_W void GaussianBlur( InputArray src, OutputArray dst, Size ksize, + double sigmaX, double sigmaY = 0, + int borderType = BORDER_DEFAULT ); + +/** @brief Applies the bilateral filter to an image. + +The function applies bilateral filtering to the input image, as described in +http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html +bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is +very slow compared to most filters. + +_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\< +10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very +strong effect, making the image look "cartoonish". + +_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time +applications, and perhaps d=9 for offline applications that need heavy noise filtering. + +This filter does not work inplace. +@param src Source 8-bit or floating-point, 1-channel or 3-channel image. +@param dst Destination image of the same size and type as src . +@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, +it is computed from sigmaSpace. +@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that +farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting +in larger areas of semi-equal color. +@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that +farther pixels will influence each other as long as their colors are close enough (see sigmaColor +). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is +proportional to sigmaSpace. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes + */ +CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d, + double sigmaColor, double sigmaSpace, + int borderType = BORDER_DEFAULT ); + +/** @brief Blurs an image using the box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\f] + +where + +\f[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\f] + +Unnormalized box filter is useful for computing various integral characteristics over each pixel +neighborhood, such as covariance matrices of image derivatives (used in dense optical flow +algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral. + +@param src input image. +@param dst output image of the same size and type as src. +@param ddepth the output image depth (-1 to use src.depth()). +@param ksize blurring kernel size. +@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel +center. +@param normalize flag, specifying whether the kernel is normalized by its area or not. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. +@sa blur, bilateralFilter, GaussianBlur, medianBlur, integral + */ +CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth, + Size ksize, Point anchor = Point(-1,-1), + bool normalize = true, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates the normalized sum of squares of the pixel values overlapping the filter. + +For every pixel \f$ (x, y) \f$ in the source image, the function calculates the sum of squares of those neighboring +pixel values which overlap the filter placed over the pixel \f$ (x, y) \f$. + +The unnormalized square box filter can be useful in computing local image statistics such as the the local +variance and standard deviation around the neighborhood of a pixel. + +@param src input image +@param dst output image of the same size and type as src +@param ddepth the output image depth (-1 to use src.depth()) +@param ksize kernel size +@param anchor kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel +center. +@param normalize flag, specifying whether the kernel is to be normalized by it's area or not. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. +@sa boxFilter +*/ +CV_EXPORTS_W void sqrBoxFilter( InputArray src, OutputArray dst, int ddepth, + Size ksize, Point anchor = Point(-1, -1), + bool normalize = true, + int borderType = BORDER_DEFAULT ); + +/** @brief Blurs an image using the normalized box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\f] + +The call `blur(src, dst, ksize, anchor, borderType)` is equivalent to `boxFilter(src, dst, src.type(), ksize, +anchor, true, borderType)`. + +@param src input image; it can have any number of channels, which are processed independently, but +the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param ksize blurring kernel size. +@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel +center. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. +@sa boxFilter, bilateralFilter, GaussianBlur, medianBlur + */ +CV_EXPORTS_W void blur( InputArray src, OutputArray dst, + Size ksize, Point anchor = Point(-1,-1), + int borderType = BORDER_DEFAULT ); + +/** @brief Convolves an image with the kernel. + +The function applies an arbitrary linear filter to an image. In-place operation is supported. When +the aperture is partially outside the image, the function interpolates outlier pixel values +according to the specified border mode. + +The function does actually compute correlation, not the convolution: + +\f[\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\f] + +That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip +the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - +anchor.y - 1)`. + +The function uses the DFT-based algorithm in case of sufficiently large kernels (~`11 x 11` or +larger) and the direct algorithm for small kernels. + +@param src input image. +@param dst output image of the same size and the same number of channels as src. +@param ddepth desired depth of the destination image, see @ref filter_depths "combinations" +@param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point +matrix; if you want to apply different kernels to different channels, split the image into +separate color planes using split and process them individually. +@param anchor anchor of the kernel that indicates the relative position of a filtered point within +the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor +is at the kernel center. +@param delta optional value added to the filtered pixels before storing them in dst. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa sepFilter2D, dft, matchTemplate + */ +CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth, + InputArray kernel, Point anchor = Point(-1,-1), + double delta = 0, int borderType = BORDER_DEFAULT ); + +/** @brief Applies a separable linear filter to an image. + +The function applies a separable linear filter to the image. That is, first, every row of src is +filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D +kernel kernelY. The final result shifted by delta is stored in dst . + +@param src Source image. +@param dst Destination image of the same size and the same number of channels as src . +@param ddepth Destination image depth, see @ref filter_depths "combinations" +@param kernelX Coefficients for filtering each row. +@param kernelY Coefficients for filtering each column. +@param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor +is at the kernel center. +@param delta Value added to the filtered results before storing them. +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa filter2D, Sobel, GaussianBlur, boxFilter, blur + */ +CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth, + InputArray kernelX, InputArray kernelY, + Point anchor = Point(-1,-1), + double delta = 0, int borderType = BORDER_DEFAULT ); + +/** @example samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp +Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector +![Sample screenshot](Sobel_Derivatives_Tutorial_Result.jpg) +Check @ref tutorial_sobel_derivatives "the corresponding tutorial" for more details +*/ + +/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. + +In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to +calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$ +kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first +or the second x- or y- derivatives. + +There is also the special value `ksize = #FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is + +\f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] + +for the x-derivative, or transposed for the y-derivative. + +The function calculates an image derivative by convolving the image with the appropriate kernel: + +\f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f] + +The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less +resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) +or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first +case corresponds to a kernel of: + +\f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f] + +The second case corresponds to a kernel of: + +\f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f] + +@param src input image. +@param dst output image of the same size and the same number of channels as src . +@param ddepth output image depth, see @ref filter_depths "combinations"; in the case of + 8-bit input images it will result in truncated derivatives. +@param dx order of the derivative x. +@param dy order of the derivative y. +@param ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see #getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar + */ +CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth, + int dx, int dy, int ksize = 3, + double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates the first order image derivative in both x and y using a Sobel operator + +Equivalent to calling: + +@code +Sobel( src, dx, CV_16SC1, 1, 0, 3 ); +Sobel( src, dy, CV_16SC1, 0, 1, 3 ); +@endcode + +@param src input image. +@param dx output image with first-order derivative in x. +@param dy output image with first-order derivative in y. +@param ksize size of Sobel kernel. It must be 3. +@param borderType pixel extrapolation method, see #BorderTypes. + Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported. + +@sa Sobel + */ + +CV_EXPORTS_W void spatialGradient( InputArray src, OutputArray dx, + OutputArray dy, int ksize = 3, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates the first x- or y- image derivative using Scharr operator. + +The function computes the first x- or y- spatial image derivative using the Scharr operator. The +call + +\f[\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\f] + +is equivalent to + +\f[\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\f] + +@param src input image. +@param dst output image of the same size and the same number of channels as src. +@param ddepth output image depth, see @ref filter_depths "combinations" +@param dx order of the derivative x. +@param dy order of the derivative y. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see #getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa cartToPolar + */ +CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth, + int dx, int dy, double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT ); + +/** @example samples/cpp/laplace.cpp +An example using Laplace transformations for edge detection +*/ + +/** @brief Calculates the Laplacian of an image. + +The function calculates the Laplacian of the source image by adding up the second x and y +derivatives calculated using the Sobel operator: + +\f[\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\f] + +This is done when `ksize > 1`. When `ksize == 1`, the Laplacian is computed by filtering the image +with the following \f$3 \times 3\f$ aperture: + +\f[\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\f] + +@param src Source image. +@param dst Destination image of the same size and the same number of channels as src . +@param ddepth Desired depth of the destination image. +@param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for +details. The size must be positive and odd. +@param scale Optional scale factor for the computed Laplacian values. By default, no scaling is +applied. See #getDerivKernels for details. +@param delta Optional delta value that is added to the results prior to storing them in dst . +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa Sobel, Scharr + */ +CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth, + int ksize = 1, double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT ); + +//! @} imgproc_filter + +//! @addtogroup imgproc_feature +//! @{ + +/** @example samples/cpp/edge.cpp +This program demonstrates usage of the Canny edge detector + +Check @ref tutorial_canny_detector "the corresponding tutorial" for more details +*/ + +/** @brief Finds edges in an image using the Canny algorithm @cite Canny86 . + +The function finds edges in the input image and marks them in the output map edges using the +Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The +largest value is used to find initial segments of strong edges. See + + +@param image 8-bit input image. +@param edges output edge map; single channels 8-bit image, which has the same size as image . +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param apertureSize aperture size for the Sobel operator. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). + */ +CV_EXPORTS_W void Canny( InputArray image, OutputArray edges, + double threshold1, double threshold2, + int apertureSize = 3, bool L2gradient = false ); + +/** \overload + +Finds edges in an image using the Canny algorithm with custom image gradient. + +@param dx 16-bit x derivative of input image (CV_16SC1 or CV_16SC3). +@param dy 16-bit y derivative of input image (same type as dx). +@param edges output edge map; single channels 8-bit image, which has the same size as image . +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). + */ +CV_EXPORTS_W void Canny( InputArray dx, InputArray dy, + OutputArray edges, + double threshold1, double threshold2, + bool L2gradient = false ); + +/** @brief Calculates the minimal eigenvalue of gradient matrices for corner detection. + +The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal +eigenvalue of the covariance matrix of derivatives, that is, \f$\min(\lambda_1, \lambda_2)\f$ in terms +of the formulae in the cornerEigenValsAndVecs description. + +@param src Input single-channel 8-bit or floating-point image. +@param dst Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as +src . +@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ). +@param ksize Aperture parameter for the Sobel operator. +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + */ +CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst, + int blockSize, int ksize = 3, + int borderType = BORDER_DEFAULT ); + +/** @brief Harris corner detector. + +The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and +cornerEigenValsAndVecs , for each pixel \f$(x, y)\f$ it calculates a \f$2\times2\f$ gradient covariance +matrix \f$M^{(x,y)}\f$ over a \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood. Then, it +computes the following characteristic: + +\f[\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\f] + +Corners in the image can be found as the local maxima of this response map. + +@param src Input single-channel 8-bit or floating-point image. +@param dst Image to store the Harris detector responses. It has the type CV_32FC1 and the same +size as src . +@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ). +@param ksize Aperture parameter for the Sobel operator. +@param k Harris detector free parameter. See the formula above. +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + */ +CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize, + int ksize, double k, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates eigenvalues and eigenvectors of image blocks for corner detection. + +For every pixel \f$p\f$ , the function cornerEigenValsAndVecs considers a blockSize \f$\times\f$ blockSize +neighborhood \f$S(p)\f$ . It calculates the covariation matrix of derivatives over the neighborhood as: + +\f[M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}\f] + +where the derivatives are computed using the Sobel operator. + +After that, it finds eigenvectors and eigenvalues of \f$M\f$ and stores them in the destination image as +\f$(\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\f$ where + +- \f$\lambda_1, \lambda_2\f$ are the non-sorted eigenvalues of \f$M\f$ +- \f$x_1, y_1\f$ are the eigenvectors corresponding to \f$\lambda_1\f$ +- \f$x_2, y_2\f$ are the eigenvectors corresponding to \f$\lambda_2\f$ + +The output of the function can be used for robust edge or corner detection. + +@param src Input single-channel 8-bit or floating-point image. +@param dst Image to store the results. It has the same size as src and the type CV_32FC(6) . +@param blockSize Neighborhood size (see details below). +@param ksize Aperture parameter for the Sobel operator. +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + +@sa cornerMinEigenVal, cornerHarris, preCornerDetect + */ +CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst, + int blockSize, int ksize, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates a feature map for corner detection. + +The function calculates the complex spatial derivative-based function of the source image + +\f[\texttt{dst} = (D_x \texttt{src} )^2 \cdot D_{yy} \texttt{src} + (D_y \texttt{src} )^2 \cdot D_{xx} \texttt{src} - 2 D_x \texttt{src} \cdot D_y \texttt{src} \cdot D_{xy} \texttt{src}\f] + +where \f$D_x\f$,\f$D_y\f$ are the first image derivatives, \f$D_{xx}\f$,\f$D_{yy}\f$ are the second image +derivatives, and \f$D_{xy}\f$ is the mixed derivative. + +The corners can be found as local maximums of the functions, as shown below: +@code + Mat corners, dilated_corners; + preCornerDetect(image, corners, 3); + // dilation with 3x3 rectangular structuring element + dilate(corners, dilated_corners, Mat(), 1); + Mat corner_mask = corners == dilated_corners; +@endcode + +@param src Source single-channel 8-bit of floating-point image. +@param dst Output image that has the type CV_32F and the same size as src . +@param ksize %Aperture size of the Sobel . +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + */ +CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize, + int borderType = BORDER_DEFAULT ); + +/** @brief Refines the corner locations. + +The function iterates to find the sub-pixel accurate location of corners or radial saddle +points as described in @cite forstner1987fast, and as shown on the figure below. + +![image](pics/cornersubpix.png) + +Sub-pixel accurate corner locator is based on the observation that every vector from the center \f$q\f$ +to a point \f$p\f$ located within a neighborhood of \f$q\f$ is orthogonal to the image gradient at \f$p\f$ +subject to image and measurement noise. Consider the expression: + +\f[\epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)\f] + +where \f${DI_{p_i}}\f$ is an image gradient at one of the points \f$p_i\f$ in a neighborhood of \f$q\f$ . The +value of \f$q\f$ is to be found so that \f$\epsilon_i\f$ is minimized. A system of equations may be set up +with \f$\epsilon_i\f$ set to zero: + +\f[\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) \cdot q - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)\f] + +where the gradients are summed within a neighborhood ("search window") of \f$q\f$ . Calling the first +gradient term \f$G\f$ and the second gradient term \f$b\f$ gives: + +\f[q = G^{-1} \cdot b\f] + +The algorithm sets the center of the neighborhood window at this new center \f$q\f$ and then iterates +until the center stays within a set threshold. + +@param image Input single-channel, 8-bit or float image. +@param corners Initial coordinates of the input corners and refined coordinates provided for +output. +@param winSize Half of the side length of the search window. For example, if winSize=Size(5,5) , +then a \f$(5*2+1) \times (5*2+1) = 11 \times 11\f$ search window is used. +@param zeroZone Half of the size of the dead region in the middle of the search zone over which +the summation in the formula below is not done. It is used sometimes to avoid possible +singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such +a size. +@param criteria Criteria for termination of the iterative process of corner refinement. That is, +the process of corner position refinement stops either after criteria.maxCount iterations or when +the corner position moves by less than criteria.epsilon on some iteration. + */ +CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners, + Size winSize, Size zeroZone, + TermCriteria criteria ); + +/** @brief Determines strong corners on an image. + +The function finds the most prominent corners in the image or in the specified image region, as +described in @cite Shi94 + +- Function calculates the corner quality measure at every source image pixel using the + #cornerMinEigenVal or #cornerHarris . +- Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are + retained). +- The corners with the minimal eigenvalue less than + \f$\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\f$ are rejected. +- The remaining corners are sorted by the quality measure in the descending order. +- Function throws away each corner for which there is a stronger corner at a distance less than + maxDistance. + +The function can be used to initialize a point-based tracker of an object. + +@note If the function is called with different values A and B of the parameter qualityLevel , and +A \> B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector +with qualityLevel=B . + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param corners Output vector of detected corners. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Optional region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + +@sa cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform, + */ + +CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask = noArray(), int blockSize = 3, + bool useHarrisDetector = false, double k = 0.04 ); + +CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask, int blockSize, + int gradientSize, bool useHarrisDetector = false, + double k = 0.04 ); + +/** @brief Same as above, but returns also quality measure of the detected corners. + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param corners Output vector of detected corners. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param cornersQuality Output vector of quality measure of the detected corners. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param gradientSize Aperture parameter for the Sobel operator used for derivatives computation. +See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + */ +CV_EXPORTS CV_WRAP_AS(goodFeaturesToTrackWithQuality) void goodFeaturesToTrack( + InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask, OutputArray cornersQuality, int blockSize = 3, + int gradientSize = 3, bool useHarrisDetector = false, double k = 0.04); + +/** @example samples/cpp/tutorial_code/ImgTrans/houghlines.cpp +An example using the Hough line detector +![Sample input image](Hough_Lines_Tutorial_Original_Image.jpg) ![Output image](Hough_Lines_Tutorial_Result.jpg) +*/ + +/** @brief Finds lines in a binary image using the standard Hough transform. + +The function implements the standard or standard multi-scale Hough transform algorithm for line +detection. See for a good explanation of Hough +transform. + +@param image 8-bit, single-channel binary source image. The image may be modified by the function. +@param lines Output vector of lines. Each line is represented by a 2 or 3 element vector +\f$(\rho, \theta)\f$ or \f$(\rho, \theta, \textrm{votes})\f$ . \f$\rho\f$ is the distance from the coordinate origin \f$(0,0)\f$ (top-left corner of +the image). \f$\theta\f$ is the line rotation angle in radians ( +\f$0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\f$ ). +\f$\textrm{votes}\f$ is the value of accumulator. +@param rho Distance resolution of the accumulator in pixels. +@param theta Angle resolution of the accumulator in radians. +@param threshold Accumulator threshold parameter. Only those lines are returned that get enough +votes ( \f$>\texttt{threshold}\f$ ). +@param srn For the multi-scale Hough transform, it is a divisor for the distance resolution rho . +The coarse accumulator distance resolution is rho and the accurate accumulator resolution is +rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these +parameters should be positive. +@param stn For the multi-scale Hough transform, it is a divisor for the distance resolution theta. +@param min_theta For standard and multi-scale Hough transform, minimum angle to check for lines. +Must fall between 0 and max_theta. +@param max_theta For standard and multi-scale Hough transform, maximum angle to check for lines. +Must fall between min_theta and CV_PI. + */ +CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double srn = 0, double stn = 0, + double min_theta = 0, double max_theta = CV_PI ); + +/** @brief Finds line segments in a binary image using the probabilistic Hough transform. + +The function implements the probabilistic Hough transform algorithm for line detection, described +in @cite Matas00 + +See the line detection example below: +@include snippets/imgproc_HoughLinesP.cpp +This is a sample picture the function parameters have been tuned for: + +![image](pics/building.jpg) + +And this is the output of the above program in case of the probabilistic Hough transform: + +![image](pics/houghp.png) + +@param image 8-bit, single-channel binary source image. The image may be modified by the function. +@param lines Output vector of lines. Each line is represented by a 4-element vector +\f$(x_1, y_1, x_2, y_2)\f$ , where \f$(x_1,y_1)\f$ and \f$(x_2, y_2)\f$ are the ending points of each detected +line segment. +@param rho Distance resolution of the accumulator in pixels. +@param theta Angle resolution of the accumulator in radians. +@param threshold Accumulator threshold parameter. Only those lines are returned that get enough +votes ( \f$>\texttt{threshold}\f$ ). +@param minLineLength Minimum line length. Line segments shorter than that are rejected. +@param maxLineGap Maximum allowed gap between points on the same line to link them. + +@sa LineSegmentDetector + */ +CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double minLineLength = 0, double maxLineGap = 0 ); + +/** @brief Finds lines in a set of points using the standard Hough transform. + +The function finds lines in a set of points using a modification of the Hough transform. +@include snippets/imgproc_HoughLinesPointSet.cpp +@param point Input vector of points. Each vector must be encoded as a Point vector \f$(x,y)\f$. Type must be CV_32FC2 or CV_32SC2. +@param lines Output vector of found lines. Each vector is encoded as a vector \f$(votes, rho, theta)\f$. +The larger the value of 'votes', the higher the reliability of the Hough line. +@param lines_max Max count of Hough lines. +@param threshold Accumulator threshold parameter. Only those lines are returned that get enough +votes ( \f$>\texttt{threshold}\f$ ). +@param min_rho Minimum value for \f$\rho\f$ for the accumulator (Note: \f$\rho\f$ can be negative. The absolute value \f$|\rho|\f$ is the distance of a line to the origin.). +@param max_rho Maximum value for \f$\rho\f$ for the accumulator. +@param rho_step Distance resolution of the accumulator. +@param min_theta Minimum angle value of the accumulator in radians. +@param max_theta Maximum angle value of the accumulator in radians. +@param theta_step Angle resolution of the accumulator in radians. + */ +CV_EXPORTS_W void HoughLinesPointSet( InputArray point, OutputArray lines, int lines_max, int threshold, + double min_rho, double max_rho, double rho_step, + double min_theta, double max_theta, double theta_step ); + +/** @example samples/cpp/tutorial_code/ImgTrans/houghcircles.cpp +An example using the Hough circle detector +*/ + +/** @brief Finds circles in a grayscale image using the Hough transform. + +The function finds circles in a grayscale image using a modification of the Hough transform. + +Example: : +@include snippets/imgproc_HoughLinesCircles.cpp + +@note Usually the function detects the centers of circles well. However, it may fail to find correct +radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if +you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number +to return centers only without radius search, and find the correct radius using an additional procedure. + +It also helps to smooth image a bit unless it's already soft. For example, +GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help. + +@param image 8-bit, single-channel, grayscale input image. +@param circles Output vector of found circles. Each vector is encoded as 3 or 4 element +floating-point vector \f$(x, y, radius)\f$ or \f$(x, y, radius, votes)\f$ . +@param method Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT. +@param dp Inverse ratio of the accumulator resolution to the image resolution. For example, if +dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has +half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, +unless some small very circles need to be detected. +@param minDist Minimum distance between the centers of the detected circles. If the parameter is +too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is +too large, some circles may be missed. +@param param1 First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, +it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). +Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value +shough normally be higher, such as 300 or normally exposed and contrasty images. +@param param2 Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the +accumulator threshold for the circle centers at the detection stage. The smaller it is, the more +false circles may be detected. Circles, corresponding to the larger accumulator values, will be +returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. +The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. +If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. +But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles. +@param minRadius Minimum circle radius. +@param maxRadius Maximum circle radius. If <= 0, uses the maximum image dimension. If < 0, #HOUGH_GRADIENT returns +centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. + +@sa fitEllipse, minEnclosingCircle + */ +CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles, + int method, double dp, double minDist, + double param1 = 100, double param2 = 100, + int minRadius = 0, int maxRadius = 0 ); + +//! @} imgproc_feature + +//! @addtogroup imgproc_filter +//! @{ + +/** @example samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp +Advanced morphology Transformations sample code +![Sample screenshot](Morphology_2_Tutorial_Result.jpg) +Check @ref tutorial_opening_closing_hats "the corresponding tutorial" for more details +*/ + +/** @brief Erodes an image by using a specific structuring element. + +The function erodes the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the minimum is taken: + +\f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In +case of multi-channel images, each channel is processed independently. + +@param src input image; the number of channels can be arbitrary, but the depth should be one of +CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular +structuring element is used. Kernel can be created using #getStructuringElement. +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times erosion is applied. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@param borderValue border value in case of a constant border +@sa dilate, morphologyEx, getStructuringElement + */ +CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel, + Point anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue() ); + +/** @example samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp +Erosion and Dilation sample code +![Sample Screenshot-Erosion](Morphology_1_Tutorial_Erosion_Result.jpg)![Sample Screenshot-Dilation](Morphology_1_Tutorial_Dilation_Result.jpg) +Check @ref tutorial_erosion_dilatation "the corresponding tutorial" for more details +*/ + +/** @brief Dilates an image by using a specific structuring element. + +The function dilates the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the maximum is taken: +\f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In +case of multi-channel images, each channel is processed independently. + +@param src input image; the number of channels can be arbitrary, but the depth should be one of +CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular +structuring element is used. Kernel can be created using #getStructuringElement +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times dilation is applied. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported. +@param borderValue border value in case of a constant border +@sa erode, morphologyEx, getStructuringElement + */ +CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel, + Point anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue() ); + +/** @brief Performs advanced morphological transformations. + +The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as +basic operations. + +Any of the operations can be done in-place. In case of multi-channel images, each channel is +processed independently. + +@param src Source image. The number of channels can be arbitrary. The depth should be one of +CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst Destination image of the same size and type as source image. +@param op Type of a morphological operation, see #MorphTypes +@param kernel Structuring element. It can be created using #getStructuringElement. +@param anchor Anchor position with the kernel. Negative values mean that the anchor is at the +kernel center. +@param iterations Number of times erosion and dilation are applied. +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@param borderValue Border value in case of a constant border. The default value has a special +meaning. +@sa dilate, erode, getStructuringElement +@note The number of iterations is the number of times erosion or dilatation operation will be applied. +For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply +successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate). + */ +CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst, + int op, InputArray kernel, + Point anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue() ); + +//! @} imgproc_filter + +//! @addtogroup imgproc_transform +//! @{ + +/** @brief Resizes an image. + +The function resize resizes the image src down to or up to the specified size. Note that the +initial dst type or size are not taken into account. Instead, the size and type are derived from +the `src`,`dsize`,`fx`, and `fy`. If you want to resize src so that it fits the pre-created dst, +you may call the function as follows: +@code + // explicitly specify dsize=dst.size(); fx and fy will be computed from that. + resize(src, dst, dst.size(), 0, 0, interpolation); +@endcode +If you want to decimate the image by factor of 2 in each direction, you can call the function this +way: +@code + // specify fx and fy and let the function compute the destination image size. + resize(src, dst, Size(), 0.5, 0.5, interpolation); +@endcode +To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to +enlarge an image, it will generally look best with c#INTER_CUBIC (slow) or #INTER_LINEAR +(faster but still looks OK). + +@param src input image. +@param dst output image; it has the size dsize (when it is non-zero) or the size computed from +src.size(), fx, and fy; the type of dst is the same as of src. +@param dsize output image size; if it equals zero (`None` in Python), it is computed as: + \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f] + Either dsize or both fx and fy must be non-zero. +@param fx scale factor along the horizontal axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.width/src.cols}\f] +@param fy scale factor along the vertical axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.height/src.rows}\f] +@param interpolation interpolation method, see #InterpolationFlags + +@sa warpAffine, warpPerspective, remap + */ +CV_EXPORTS_W void resize( InputArray src, OutputArray dst, + Size dsize, double fx = 0, double fy = 0, + int interpolation = INTER_LINEAR ); + +/** @brief Applies an affine transformation to an image. + +The function warpAffine transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted +with #invertAffineTransform and then put in the formula above instead of M. The function cannot +operate in-place. + +@param src input image. +@param dst output image that has the size dsize and the same type as src . +@param M \f$2\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (see #InterpolationFlags) and the optional +flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (see #BorderTypes); when +borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to +the "outliers" in the source image are not modified by the function. +@param borderValue value used in case of a constant border; by default, it is 0. + +@sa warpPerspective, resize, remap, getRectSubPix, transform + */ +CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst, + InputArray M, Size dsize, + int flags = INTER_LINEAR, + int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @example samples/cpp/warpPerspective_demo.cpp +An example program shows using cv::getPerspectiveTransform and cv::warpPerspective for image warping +*/ + +/** @brief Applies a perspective transformation to an image. + +The function warpPerspective transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , + \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert +and then put in the formula above instead of M. The function cannot operate in-place. + +@param src input image. +@param dst output image that has the size dsize and the same type as src . +@param M \f$3\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the +optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). +@param borderValue value used in case of a constant border; by default, it equals 0. + +@sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform + */ +CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst, + InputArray M, Size dsize, + int flags = INTER_LINEAR, + int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @brief Applies a generic geometrical transformation to an image. + +The function remap transforms the source image using the specified map: + +\f[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\f] + +where values of pixels with non-integer coordinates are computed using one of available +interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps +in \f$map_1\f$ and \f$map_2\f$ respectively, or interleaved floating-point maps of \f$(x,y)\f$ in +\f$map_1\f$, or fixed-point maps created by using convertMaps. The reason you might want to +convert from floating to fixed-point representations of a map is that they can yield much faster +(\~2x) remapping operations. In the converted case, \f$map_1\f$ contains pairs (cvFloor(x), +cvFloor(y)) and \f$map_2\f$ contains indices in a table of interpolation coefficients. + +This function cannot operate in-place. + +@param src Source image. +@param dst Destination image. It has the same size as map1 and the same type as src . +@param map1 The first map of either (x,y) points or just x values having the type CV_16SC2 , +CV_32FC1, or CV_32FC2. See convertMaps for details on converting a floating point +representation to fixed-point for speed. +@param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map +if map1 is (x,y) points), respectively. +@param interpolation Interpolation method (see #InterpolationFlags). The methods #INTER_AREA +and #INTER_LINEAR_EXACT are not supported by this function. +@param borderMode Pixel extrapolation method (see #BorderTypes). When +borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that +corresponds to the "outliers" in the source image are not modified by the function. +@param borderValue Value used in case of a constant border. By default, it is 0. +@note +Due to current implementation limitations the size of an input and output images should be less than 32767x32767. + */ +CV_EXPORTS_W void remap( InputArray src, OutputArray dst, + InputArray map1, InputArray map2, + int interpolation, int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @brief Converts image transformation maps from one representation to another. + +The function converts a pair of maps for remap from one representation to another. The following +options ( (map1.type(), map2.type()) \f$\rightarrow\f$ (dstmap1.type(), dstmap2.type()) ) are +supported: + +- \f$\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. This is the +most frequently used conversion operation, in which the original floating-point maps (see remap ) +are converted to a more compact and much faster fixed-point representation. The first output array +contains the rounded coordinates and the second array (created only when nninterpolation=false ) +contains indices in the interpolation tables. + +- \f$\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. The same as above but +the original maps are stored in one 2-channel matrix. + +- Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same +as the originals. + +@param map1 The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 . +@param map2 The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), +respectively. +@param dstmap1 The first output map that has the type dstmap1type and the same size as src . +@param dstmap2 The second output map. +@param dstmap1type Type of the first output map that should be CV_16SC2, CV_32FC1, or +CV_32FC2 . +@param nninterpolation Flag indicating whether the fixed-point maps are used for the +nearest-neighbor or for a more complex interpolation. + +@sa remap, undistort, initUndistortRectifyMap + */ +CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2, + OutputArray dstmap1, OutputArray dstmap2, + int dstmap1type, bool nninterpolation = false ); + +/** @brief Calculates an affine matrix of 2D rotation. + +The function calculates the following matrix: + +\f[\begin{bmatrix} \alpha & \beta & (1- \alpha ) \cdot \texttt{center.x} - \beta \cdot \texttt{center.y} \\ - \beta & \alpha & \beta \cdot \texttt{center.x} + (1- \alpha ) \cdot \texttt{center.y} \end{bmatrix}\f] + +where + +\f[\begin{array}{l} \alpha = \texttt{scale} \cdot \cos \texttt{angle} , \\ \beta = \texttt{scale} \cdot \sin \texttt{angle} \end{array}\f] + +The transformation maps the rotation center to itself. If this is not the target, adjust the shift. + +@param center Center of the rotation in the source image. +@param angle Rotation angle in degrees. Positive values mean counter-clockwise rotation (the +coordinate origin is assumed to be the top-left corner). +@param scale Isotropic scale factor. + +@sa getAffineTransform, warpAffine, transform + */ +CV_EXPORTS_W Mat getRotationMatrix2D(Point2f center, double angle, double scale); + +/** @sa getRotationMatrix2D */ +CV_EXPORTS Matx23d getRotationMatrix2D_(Point2f center, double angle, double scale); + +inline +Mat getRotationMatrix2D(Point2f center, double angle, double scale) +{ + return Mat(getRotationMatrix2D_(center, angle, scale), true); +} + +/** @brief Calculates an affine transform from three pairs of the corresponding points. + +The function calculates the \f$2 \times 3\f$ matrix of an affine transform so that: + +\f[\begin{bmatrix} x'_i \\ y'_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\f] + +where + +\f[dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2\f] + +@param src Coordinates of triangle vertices in the source image. +@param dst Coordinates of the corresponding triangle vertices in the destination image. + +@sa warpAffine, transform + */ +CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] ); + +/** @brief Inverts an affine transformation. + +The function computes an inverse affine transformation represented by \f$2 \times 3\f$ matrix M: + +\f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ a_{21} & a_{22} & b_2 \end{bmatrix}\f] + +The result is also a \f$2 \times 3\f$ matrix of the same type as M. + +@param M Original affine transformation. +@param iM Output reverse affine transformation. + */ +CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM ); + +/** @brief Calculates a perspective transform from four pairs of the corresponding points. + +The function calculates the \f$3 \times 3\f$ matrix of a perspective transform so that: + +\f[\begin{bmatrix} t_i x'_i \\ t_i y'_i \\ t_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\f] + +where + +\f[dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2,3\f] + +@param src Coordinates of quadrangle vertices in the source image. +@param dst Coordinates of the corresponding quadrangle vertices in the destination image. +@param solveMethod method passed to cv::solve (#DecompTypes) + +@sa findHomography, warpPerspective, perspectiveTransform + */ +CV_EXPORTS_W Mat getPerspectiveTransform(InputArray src, InputArray dst, int solveMethod = DECOMP_LU); + +/** @overload */ +CV_EXPORTS Mat getPerspectiveTransform(const Point2f src[], const Point2f dst[], int solveMethod = DECOMP_LU); + + +CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst ); + +/** @brief Retrieves a pixel rectangle from an image with sub-pixel accuracy. + +The function getRectSubPix extracts pixels from src: + +\f[patch(x, y) = src(x + \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y + \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\f] + +where the values of the pixels at non-integer coordinates are retrieved using bilinear +interpolation. Every channel of multi-channel images is processed independently. Also +the image should be a single channel or three channel image. While the center of the +rectangle must be inside the image, parts of the rectangle may be outside. + +@param image Source image. +@param patchSize Size of the extracted patch. +@param center Floating point coordinates of the center of the extracted rectangle within the +source image. The center must be inside the image. +@param patch Extracted patch that has the size patchSize and the same number of channels as src . +@param patchType Depth of the extracted pixels. By default, they have the same depth as src . + +@sa warpAffine, warpPerspective + */ +CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize, + Point2f center, OutputArray patch, int patchType = -1 ); + +/** @example samples/cpp/polar_transforms.cpp +An example using the cv::linearPolar and cv::logPolar operations +*/ + +/** @brief Remaps an image to semilog-polar coordinates space. + +@deprecated This function produces same result as cv::warpPolar(src, dst, src.size(), center, maxRadius, flags+WARP_POLAR_LOG); + +@internal +Transform the source image using the following transformation (See @ref polar_remaps_reference_image "Polar remaps reference image d)"): +\f[\begin{array}{l} + dst( \rho , \phi ) = src(x,y) \\ + dst.size() \leftarrow src.size() +\end{array}\f] + +where +\f[\begin{array}{l} + I = (dx,dy) = (x - center.x,y - center.y) \\ + \rho = M \cdot log_e(\texttt{magnitude} (I)) ,\\ + \phi = Kangle \cdot \texttt{angle} (I) \\ +\end{array}\f] + +and +\f[\begin{array}{l} + M = src.cols / log_e(maxRadius) \\ + Kangle = src.rows / 2\Pi \\ +\end{array}\f] + +The function emulates the human "foveal" vision and can be used for fast scale and +rotation-invariant template matching, for object tracking and so forth. +@param src Source image +@param dst Destination image. It will have same size and type as src. +@param center The transformation center; where the output precision is maximal +@param M Magnitude scale parameter. It determines the radius of the bounding circle to transform too. +@param flags A combination of interpolation methods, see #InterpolationFlags + +@note +- The function can not operate in-place. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. + +@sa cv::linearPolar +@endinternal +*/ +CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst, + Point2f center, double M, int flags ); + +/** @brief Remaps an image to polar coordinates space. + +@deprecated This function produces same result as cv::warpPolar(src, dst, src.size(), center, maxRadius, flags) + +@internal +Transform the source image using the following transformation (See @ref polar_remaps_reference_image "Polar remaps reference image c)"): +\f[\begin{array}{l} + dst( \rho , \phi ) = src(x,y) \\ + dst.size() \leftarrow src.size() +\end{array}\f] + +where +\f[\begin{array}{l} + I = (dx,dy) = (x - center.x,y - center.y) \\ + \rho = Kmag \cdot \texttt{magnitude} (I) ,\\ + \phi = angle \cdot \texttt{angle} (I) +\end{array}\f] + +and +\f[\begin{array}{l} + Kx = src.cols / maxRadius \\ + Ky = src.rows / 2\Pi +\end{array}\f] + + +@param src Source image +@param dst Destination image. It will have same size and type as src. +@param center The transformation center; +@param maxRadius The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too. +@param flags A combination of interpolation methods, see #InterpolationFlags + +@note +- The function can not operate in-place. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. + +@sa cv::logPolar +@endinternal +*/ +CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst, + Point2f center, double maxRadius, int flags ); + + +/** \brief Remaps an image to polar or semilog-polar coordinates space + +@anchor polar_remaps_reference_image +![Polar remaps reference](pics/polar_remap_doc.png) + +Transform the source image using the following transformation: +\f[ +dst(\rho , \phi ) = src(x,y) +\f] + +where +\f[ +\begin{array}{l} +\vec{I} = (x - center.x, \;y - center.y) \\ +\phi = Kangle \cdot \texttt{angle} (\vec{I}) \\ +\rho = \left\{\begin{matrix} +Klin \cdot \texttt{magnitude} (\vec{I}) & default \\ +Klog \cdot log_e(\texttt{magnitude} (\vec{I})) & if \; semilog \\ +\end{matrix}\right. +\end{array} +\f] + +and +\f[ +\begin{array}{l} +Kangle = dsize.height / 2\Pi \\ +Klin = dsize.width / maxRadius \\ +Klog = dsize.width / log_e(maxRadius) \\ +\end{array} +\f] + + +\par Linear vs semilog mapping + +Polar mapping can be linear or semi-log. Add one of #WarpPolarMode to `flags` to specify the polar mapping mode. + +Linear is the default mode. + +The semilog mapping emulates the human "foveal" vision that permit very high acuity on the line of sight (central vision) +in contrast to peripheral vision where acuity is minor. + +\par Option on `dsize`: + +- if both values in `dsize <=0 ` (default), +the destination image will have (almost) same area of source bounding circle: +\f[\begin{array}{l} +dsize.area \leftarrow (maxRadius^2 \cdot \Pi) \\ +dsize.width = \texttt{cvRound}(maxRadius) \\ +dsize.height = \texttt{cvRound}(maxRadius \cdot \Pi) \\ +\end{array}\f] + + +- if only `dsize.height <= 0`, +the destination image area will be proportional to the bounding circle area but scaled by `Kx * Kx`: +\f[\begin{array}{l} +dsize.height = \texttt{cvRound}(dsize.width \cdot \Pi) \\ +\end{array} +\f] + +- if both values in `dsize > 0 `, +the destination image will have the given size therefore the area of the bounding circle will be scaled to `dsize`. + + +\par Reverse mapping + +You can get reverse mapping adding #WARP_INVERSE_MAP to `flags` +\snippet polar_transforms.cpp InverseMap + +In addiction, to calculate the original coordinate from a polar mapped coordinate \f$(rho, phi)->(x, y)\f$: +\snippet polar_transforms.cpp InverseCoordinate + +@param src Source image. +@param dst Destination image. It will have same type as src. +@param dsize The destination image size (see description for valid options). +@param center The transformation center. +@param maxRadius The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too. +@param flags A combination of interpolation methods, #InterpolationFlags + #WarpPolarMode. + - Add #WARP_POLAR_LINEAR to select linear polar mapping (default) + - Add #WARP_POLAR_LOG to select semilog polar mapping + - Add #WARP_INVERSE_MAP for reverse mapping. +@note +- The function can not operate in-place. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. +- This function uses #remap. Due to current implementation limitations the size of an input and output images should be less than 32767x32767. + +@sa cv::remap +*/ +CV_EXPORTS_W void warpPolar(InputArray src, OutputArray dst, Size dsize, + Point2f center, double maxRadius, int flags); + + +//! @} imgproc_transform + +//! @addtogroup imgproc_misc +//! @{ + +/** @brief Calculates the integral of an image. + +The function calculates one or more integral images for the source image as follows: + +\f[\texttt{sum} (X,Y) = \sum _{x + +Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed +with getOptimalDFTSize. + +The function performs the following equations: +- First it applies a Hanning window (see ) to each +image to remove possible edge effects. This window is cached until the array size changes to speed +up processing time. +- Next it computes the forward DFTs of each source array: +\f[\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\f] +where \f$\mathcal{F}\f$ is the forward DFT. +- It then computes the cross-power spectrum of each frequency domain array: +\f[R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\f] +- Next the cross-correlation is converted back into the time domain via the inverse DFT: +\f[r = \mathcal{F}^{-1}\{R\}\f] +- Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to +achieve sub-pixel accuracy. +\f[(\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\f] +- If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 +centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single +peak) and will be smaller when there are multiple peaks. + +@param src1 Source floating point array (CV_32FC1 or CV_64FC1) +@param src2 Source floating point array (CV_32FC1 or CV_64FC1) +@param window Floating point array with windowing coefficients to reduce edge effects (optional). +@param response Signal power within the 5x5 centroid around the peak, between 0 and 1 (optional). +@returns detected phase shift (sub-pixel) between the two arrays. + +@sa dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow + */ +CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2, + InputArray window = noArray(), CV_OUT double* response = 0); + +/** @brief This function computes a Hanning window coefficients in two dimensions. + +See (http://en.wikipedia.org/wiki/Hann_function) and (http://en.wikipedia.org/wiki/Window_function) +for more information. + +An example is shown below: +@code + // create hanning window of size 100x100 and type CV_32F + Mat hann; + createHanningWindow(hann, Size(100, 100), CV_32F); +@endcode +@param dst Destination array to place Hann coefficients in +@param winSize The window size specifications (both width and height must be > 1) +@param type Created array type + */ +CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type); + +/** @brief Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum. + +The function cv::divSpectrums performs the per-element division of the first array by the second array. +The arrays are CCS-packed or complex matrices that are results of a real or complex Fourier transform. + +@param a first input array. +@param b second input array of the same size and type as src1 . +@param c output array of the same size and type as src1 . +@param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that +each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a `0` as value. +@param conjB optional flag that conjugates the second input array before the multiplication (true) +or not (false). +*/ +CV_EXPORTS_W void divSpectrums(InputArray a, InputArray b, OutputArray c, + int flags, bool conjB = false); + +//! @} imgproc_motion + +//! @addtogroup imgproc_misc +//! @{ + +/** @brief Applies a fixed-level threshold to each array element. + +The function applies fixed-level thresholding to a multiple-channel array. The function is typically +used to get a bi-level (binary) image out of a grayscale image ( #compare could be also used for +this purpose) or for removing a noise, that is, filtering out pixels with too small or too large +values. There are several types of thresholding supported by the function. They are determined by +type parameter. + +Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with one of the +above values. In these cases, the function determines the optimal threshold value using the Otsu's +or Triangle algorithm and uses it instead of the specified thresh. + +@note Currently, the Otsu's and Triangle methods are implemented only for 8-bit single-channel images. + +@param src input array (multiple-channel, 8-bit or 32-bit floating point). +@param dst output array of the same size and type and the same number of channels as src. +@param thresh threshold value. +@param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding +types. +@param type thresholding type (see #ThresholdTypes). +@return the computed threshold value if Otsu's or Triangle methods used. + +@sa adaptiveThreshold, findContours, compare, min, max + */ +CV_EXPORTS_W double threshold( InputArray src, OutputArray dst, + double thresh, double maxval, int type ); + + +/** @brief Applies an adaptive threshold to an array. + +The function transforms a grayscale image to a binary image according to the formulae: +- **THRESH_BINARY** + \f[dst(x,y) = \fork{\texttt{maxValue}}{if \(src(x,y) > T(x,y)\)}{0}{otherwise}\f] +- **THRESH_BINARY_INV** + \f[dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\f] +where \f$T(x,y)\f$ is a threshold calculated individually for each pixel (see adaptiveMethod parameter). + +The function can process the image in-place. + +@param src Source 8-bit single-channel image. +@param dst Destination image of the same size and the same type as src. +@param maxValue Non-zero value assigned to the pixels for which the condition is satisfied +@param adaptiveMethod Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. +The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries. +@param thresholdType Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, +see #ThresholdTypes. +@param blockSize Size of a pixel neighborhood that is used to calculate a threshold value for the +pixel: 3, 5, 7, and so on. +@param C Constant subtracted from the mean or weighted mean (see the details below). Normally, it +is positive but may be zero or negative as well. + +@sa threshold, blur, GaussianBlur + */ +CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst, + double maxValue, int adaptiveMethod, + int thresholdType, int blockSize, double C ); + +//! @} imgproc_misc + +//! @addtogroup imgproc_filter +//! @{ + +/** @example samples/cpp/tutorial_code/ImgProc/Pyramids/Pyramids.cpp +An example using pyrDown and pyrUp functions +*/ + +/** @brief Blurs an image and downsamples it. + +By default, size of the output image is computed as `Size((src.cols+1)/2, (src.rows+1)/2)`, but in +any case, the following conditions should be satisfied: + +\f[\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\f] + +The function performs the downsampling step of the Gaussian pyramid construction. First, it +convolves the source image with the kernel: + +\f[\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\f] + +Then, it downsamples the image by rejecting even rows and columns. + +@param src input image. +@param dst output image; it has the specified size and the same type as src. +@param dstsize size of the output image. +@param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) + */ +CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst, + const Size& dstsize = Size(), int borderType = BORDER_DEFAULT ); + +/** @brief Upsamples an image and then blurs it. + +By default, size of the output image is computed as `Size(src.cols\*2, (src.rows\*2)`, but in any +case, the following conditions should be satisfied: + +\f[\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\f] + +The function performs the upsampling step of the Gaussian pyramid construction, though it can +actually be used to construct the Laplacian pyramid. First, it upsamples the source image by +injecting even zero rows and columns and then convolves the result with the same kernel as in +pyrDown multiplied by 4. + +@param src input image. +@param dst output image. It has the specified size and the same type as src . +@param dstsize size of the output image. +@param borderType Pixel extrapolation method, see #BorderTypes (only #BORDER_DEFAULT is supported) + */ +CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst, + const Size& dstsize = Size(), int borderType = BORDER_DEFAULT ); + +/** @brief Constructs the Gaussian pyramid for an image. + +The function constructs a vector of images and builds the Gaussian pyramid by recursively applying +pyrDown to the previously built pyramid layers, starting from `dst[0]==src`. + +@param src Source image. Check pyrDown for the list of supported types. +@param dst Destination vector of maxlevel+1 images of the same type as src. dst[0] will be the +same as src. dst[1] is the next pyramid layer, a smoothed and down-sized src, and so on. +@param maxlevel 0-based index of the last (the smallest) pyramid layer. It must be non-negative. +@param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) + */ +CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst, + int maxlevel, int borderType = BORDER_DEFAULT ); + +//! @} imgproc_filter + +//! @addtogroup imgproc_hist +//! @{ + +/** @example samples/cpp/demhist.cpp +An example for creating histograms of an image +*/ + +/** @brief Calculates a histogram of a set of arrays. + +The function cv::calcHist calculates the histogram of one or more arrays. The elements of a tuple used +to increment a histogram bin are taken from the corresponding input arrays at the same location. The +sample below shows how to compute a 2D Hue-Saturation histogram for a color image. : +@include snippets/imgproc_calcHist.cpp + +@param images Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same +size. Each of them can have an arbitrary number of channels. +@param nimages Number of source images. +@param channels List of the dims channels used to compute the histogram. The first array channels +are numerated from 0 to images[0].channels()-1 , the second array channels are counted from +images[0].channels() to images[0].channels() + images[1].channels()-1, and so on. +@param mask Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size +as images[i] . The non-zero mask elements mark the array elements counted in the histogram. +@param hist Output histogram, which is a dense or sparse dims -dimensional array. +@param dims Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS +(equal to 32 in the current OpenCV version). +@param histSize Array of histogram sizes in each dimension. +@param ranges Array of the dims arrays of the histogram bin boundaries in each dimension. When the +histogram is uniform ( uniform =true), then for each dimension i it is enough to specify the lower +(inclusive) boundary \f$L_0\f$ of the 0-th histogram bin and the upper (exclusive) boundary +\f$U_{\texttt{histSize}[i]-1}\f$ for the last histogram bin histSize[i]-1 . That is, in case of a +uniform histogram each of ranges[i] is an array of 2 elements. When the histogram is not uniform ( +uniform=false ), then each of ranges[i] contains histSize[i]+1 elements: +\f$L_0, U_0=L_1, U_1=L_2, ..., U_{\texttt{histSize[i]}-2}=L_{\texttt{histSize[i]}-1}, U_{\texttt{histSize[i]}-1}\f$ +. The array elements, that are not between \f$L_0\f$ and \f$U_{\texttt{histSize[i]}-1}\f$ , are not +counted in the histogram. +@param uniform Flag indicating whether the histogram is uniform or not (see above). +@param accumulate Accumulation flag. If it is set, the histogram is not cleared in the beginning +when it is allocated. This feature enables you to compute a single histogram from several sets of +arrays, or to update the histogram in time. +*/ +CV_EXPORTS void calcHist( const Mat* images, int nimages, + const int* channels, InputArray mask, + OutputArray hist, int dims, const int* histSize, + const float** ranges, bool uniform = true, bool accumulate = false ); + +/** @overload + +this variant uses %SparseMat for output +*/ +CV_EXPORTS void calcHist( const Mat* images, int nimages, + const int* channels, InputArray mask, + SparseMat& hist, int dims, + const int* histSize, const float** ranges, + bool uniform = true, bool accumulate = false ); + +/** @overload */ +CV_EXPORTS_W void calcHist( InputArrayOfArrays images, + const std::vector& channels, + InputArray mask, OutputArray hist, + const std::vector& histSize, + const std::vector& ranges, + bool accumulate = false ); + +/** @brief Calculates the back projection of a histogram. + +The function cv::calcBackProject calculates the back project of the histogram. That is, similarly to +#calcHist , at each location (x, y) the function collects the values from the selected channels +in the input images and finds the corresponding histogram bin. But instead of incrementing it, the +function reads the bin value, scales it by scale , and stores in backProject(x,y) . In terms of +statistics, the function computes probability of each element value in respect with the empirical +probability distribution represented by the histogram. See how, for example, you can find and track +a bright-colored object in a scene: + +- Before tracking, show the object to the camera so that it covers almost the whole frame. +Calculate a hue histogram. The histogram may have strong maximums, corresponding to the dominant +colors in the object. + +- When tracking, calculate a back projection of a hue plane of each input video frame using that +pre-computed histogram. Threshold the back projection to suppress weak colors. It may also make +sense to suppress pixels with non-sufficient color saturation and too dark or too bright pixels. + +- Find connected components in the resulting picture and choose, for example, the largest +component. + +This is an approximate algorithm of the CamShift color object tracker. + +@param images Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same +size. Each of them can have an arbitrary number of channels. +@param nimages Number of source images. +@param channels The list of channels used to compute the back projection. The number of channels +must match the histogram dimensionality. The first array channels are numerated from 0 to +images[0].channels()-1 , the second array channels are counted from images[0].channels() to +images[0].channels() + images[1].channels()-1, and so on. +@param hist Input histogram that can be dense or sparse. +@param backProject Destination back projection array that is a single-channel array of the same +size and depth as images[0] . +@param ranges Array of arrays of the histogram bin boundaries in each dimension. See #calcHist . +@param scale Optional scale factor for the output back projection. +@param uniform Flag indicating whether the histogram is uniform or not (see above). + +@sa calcHist, compareHist + */ +CV_EXPORTS void calcBackProject( const Mat* images, int nimages, + const int* channels, InputArray hist, + OutputArray backProject, const float** ranges, + double scale = 1, bool uniform = true ); + +/** @overload */ +CV_EXPORTS void calcBackProject( const Mat* images, int nimages, + const int* channels, const SparseMat& hist, + OutputArray backProject, const float** ranges, + double scale = 1, bool uniform = true ); + +/** @overload */ +CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const std::vector& channels, + InputArray hist, OutputArray dst, + const std::vector& ranges, + double scale ); + +/** @brief Compares two histograms. + +The function cv::compareHist compares two dense or two sparse histograms using the specified method. + +The function returns \f$d(H_1, H_2)\f$ . + +While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable +for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling +problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms +or more general sparse configurations of weighted points, consider using the #EMD function. + +@param H1 First compared histogram. +@param H2 Second compared histogram of the same size as H1 . +@param method Comparison method, see #HistCompMethods + */ +CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method ); + +/** @overload */ +CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method ); + +/** @brief Equalizes the histogram of a grayscale image. + +The function equalizes the histogram of the input image using the following algorithm: + +- Calculate the histogram \f$H\f$ for src . +- Normalize the histogram so that the sum of histogram bins is 255. +- Compute the integral of the histogram: +\f[H'_i = \sum _{0 \le j < i} H(j)\f] +- Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$ + +The algorithm normalizes the brightness and increases the contrast of the image. + +@param src Source 8-bit single channel image. +@param dst Destination image of the same size and type as src . + */ +CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst ); + +/** @brief Creates a smart pointer to a cv::CLAHE class and initializes it. + +@param clipLimit Threshold for contrast limiting. +@param tileGridSize Size of grid for histogram equalization. Input image will be divided into +equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column. + */ +CV_EXPORTS_W Ptr createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8)); + +/** @brief Computes the "minimal work" distance between two weighted point configurations. + +The function computes the earth mover distance and/or a lower boundary of the distance between the +two weighted point configurations. One of the applications described in @cite RubnerSept98, +@cite Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation +problem that is solved using some modification of a simplex algorithm, thus the complexity is +exponential in the worst case, though, on average it is much faster. In the case of a real metric +the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used +to determine roughly whether the two signatures are far enough so that they cannot relate to the +same object. + +@param signature1 First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ floating-point matrix. +Each row stores the point weight followed by the point coordinates. The matrix is allowed to have +a single column (weights only) if the user-defined cost matrix is used. The weights must be +non-negative and have at least one non-zero value. +@param signature2 Second signature of the same format as signature1 , though the number of rows +may be different. The total weights may be different. In this case an extra "dummy" point is added +to either signature1 or signature2. The weights must be non-negative and have at least one non-zero +value. +@param distType Used metric. See #DistanceTypes. +@param cost User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix +is used, lower boundary lowerBound cannot be calculated because it needs a metric function. +@param lowerBound Optional input/output parameter: lower boundary of a distance between the two +signatures that is a distance between mass centers. The lower boundary may not be calculated if +the user-defined cost matrix is used, the total weights of point configurations are not equal, or +if the signatures consist of weights only (the signature matrices have a single column). You +**must** initialize \*lowerBound . If the calculated distance between mass centers is greater or +equal to \*lowerBound (it means that the signatures are far enough), the function does not +calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on +return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound +should be set to 0. +@param flow Resultant \f$\texttt{size1} \times \texttt{size2}\f$ flow matrix: \f$\texttt{flow}_{i,j}\f$ is +a flow from \f$i\f$ -th point of signature1 to \f$j\f$ -th point of signature2 . + */ +CV_EXPORTS float EMD( InputArray signature1, InputArray signature2, + int distType, InputArray cost=noArray(), + float* lowerBound = 0, OutputArray flow = noArray() ); + +CV_EXPORTS_AS(EMD) float wrapperEMD( InputArray signature1, InputArray signature2, + int distType, InputArray cost=noArray(), + CV_IN_OUT Ptr lowerBound = Ptr(), OutputArray flow = noArray() ); + +//! @} imgproc_hist + +//! @addtogroup imgproc_segmentation +//! @{ + +/** @example samples/cpp/watershed.cpp +An example using the watershed algorithm +*/ + +/** @brief Performs a marker-based image segmentation using the watershed algorithm. + +The function implements one of the variants of watershed, non-parametric marker-based segmentation +algorithm, described in @cite Meyer92 . + +Before passing the image to the function, you have to roughly outline the desired regions in the +image markers with positive (\>0) indices. So, every region is represented as one or more connected +components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary +mask using #findContours and #drawContours (see the watershed.cpp demo). The markers are "seeds" of +the future image regions. All the other pixels in markers , whose relation to the outlined regions +is not known and should be defined by the algorithm, should be set to 0's. In the function output, +each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the +regions. + +@note Any two neighbor connected components are not necessarily separated by a watershed boundary +(-1's pixels); for example, they can touch each other in the initial marker image passed to the +function. + +@param image Input 8-bit 3-channel image. +@param markers Input/output 32-bit single-channel image (map) of markers. It should have the same +size as image . + +@sa findContours + */ +CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers ); + +//! @} imgproc_segmentation + +//! @addtogroup imgproc_filter +//! @{ + +/** @brief Performs initial step of meanshift segmentation of an image. + +The function implements the filtering stage of meanshift segmentation, that is, the output of the +function is the filtered "posterized" image with color gradients and fine-grain texture flattened. +At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes +meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is +considered: + +\f[(x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\f] + +where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively +(though, the algorithm does not depend on the color space used, so any 3-component color space can +be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector +(R',G',B') are found and they act as the neighborhood center on the next iteration: + +\f[(X,Y)~(X',Y'), (R,G,B)~(R',G',B').\f] + +After the iterations over, the color components of the initial pixel (that is, the pixel from where +the iterations started) are set to the final value (average color at the last iteration): + +\f[I(X,Y) <- (R*,G*,B*)\f] + +When maxLevel \> 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is +run on the smallest layer first. After that, the results are propagated to the larger layer and the +iterations are run again only on those pixels where the layer colors differ by more than sr from the +lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the +results will be actually different from the ones obtained by running the meanshift procedure on the +whole original image (i.e. when maxLevel==0). + +@param src The source 8-bit, 3-channel image. +@param dst The destination image of the same format and the same size as the source. +@param sp The spatial window radius. +@param sr The color window radius. +@param maxLevel Maximum level of the pyramid for the segmentation. +@param termcrit Termination criteria: when to stop meanshift iterations. + */ +CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst, + double sp, double sr, int maxLevel = 1, + TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) ); + +//! @} + +//! @addtogroup imgproc_segmentation +//! @{ + +/** @example samples/cpp/grabcut.cpp +An example using the GrabCut algorithm +![Sample Screenshot](grabcut_output1.jpg) +*/ + +/** @brief Runs the GrabCut algorithm. + +The function implements the [GrabCut image segmentation algorithm](http://en.wikipedia.org/wiki/GrabCut). + +@param img Input 8-bit 3-channel image. +@param mask Input/output 8-bit single-channel mask. The mask is initialized by the function when +mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses. +@param rect ROI containing a segmented object. The pixels outside of the ROI are marked as +"obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT . +@param bgdModel Temporary array for the background model. Do not modify it while you are +processing the same image. +@param fgdModel Temporary arrays for the foreground model. Do not modify it while you are +processing the same image. +@param iterCount Number of iterations the algorithm should make before returning the result. Note +that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or +mode==GC_EVAL . +@param mode Operation mode that could be one of the #GrabCutModes + */ +CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect, + InputOutputArray bgdModel, InputOutputArray fgdModel, + int iterCount, int mode = GC_EVAL ); + +//! @} imgproc_segmentation + +//! @addtogroup imgproc_misc +//! @{ + +/** @example samples/cpp/distrans.cpp +An example on using the distance transform +*/ + +/** @brief Calculates the distance to the closest zero pixel for each pixel of the source image. + +The function cv::distanceTransform calculates the approximate or precise distance from every binary +image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero. + +When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the +algorithm described in @cite Felzenszwalb04 . This algorithm is parallelized with the TBB library. + +In other cases, the algorithm @cite Borgefors86 is used. This means that for a pixel the function +finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, +diagonal, or knight's move (the latest is available for a \f$5\times 5\f$ mask). The overall +distance is calculated as a sum of these basic distances. Since the distance function should be +symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all +the diagonal shifts must have the same cost (denoted as `b`), and all knight's moves must have the +same cost (denoted as `c`). For the #DIST_C and #DIST_L1 types, the distance is calculated +precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a +relative error (a \f$5\times 5\f$ mask gives more accurate results). For `a`,`b`, and `c`, OpenCV +uses the values suggested in the original paper: +- DIST_L1: `a = 1, b = 2` +- DIST_L2: + - `3 x 3`: `a=0.955, b=1.3693` + - `5 x 5`: `a=1, b=1.4, c=2.1969` +- DIST_C: `a = 1, b = 1` + +Typically, for a fast, coarse distance estimation #DIST_L2, a \f$3\times 3\f$ mask is used. For a +more accurate distance estimation #DIST_L2, a \f$5\times 5\f$ mask or the precise algorithm is used. +Note that both the precise and the approximate algorithms are linear on the number of pixels. + +This variant of the function does not only compute the minimum distance for each pixel \f$(x, y)\f$ +but also identifies the nearest connected component consisting of zero pixels +(labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the +component/pixel is stored in `labels(x, y)`. When labelType==#DIST_LABEL_CCOMP, the function +automatically finds connected components of zero pixels in the input image and marks them with +distinct labels. When labelType==#DIST_LABEL_PIXEL, the function scans through the input image and +marks all the zero pixels with distinct labels. + +In this mode, the complexity is still linear. That is, the function provides a very fast way to +compute the Voronoi diagram for a binary image. Currently, the second variant can use only the +approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported +yet. + +@param src 8-bit, single-channel (binary) source image. +@param dst Output image with calculated distances. It is a 8-bit or 32-bit floating-point, +single-channel image of the same size as src. +@param labels Output 2D array of labels (the discrete Voronoi diagram). It has the type +CV_32SC1 and the same size as src. +@param distanceType Type of distance, see #DistanceTypes +@param maskSize Size of the distance transform mask, see #DistanceTransformMasks. +#DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type, +the parameter is forced to 3 because a \f$3\times 3\f$ mask gives the same result as \f$5\times +5\f$ or any larger aperture. +@param labelType Type of the label array to build, see #DistanceTransformLabelTypes. + */ +CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst, + OutputArray labels, int distanceType, int maskSize, + int labelType = DIST_LABEL_CCOMP ); + +/** @overload +@param src 8-bit, single-channel (binary) source image. +@param dst Output image with calculated distances. It is a 8-bit or 32-bit floating-point, +single-channel image of the same size as src . +@param distanceType Type of distance, see #DistanceTypes +@param maskSize Size of the distance transform mask, see #DistanceTransformMasks. In case of the +#DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \f$3\times 3\f$ mask gives +the same result as \f$5\times 5\f$ or any larger aperture. +@param dstType Type of output image. It can be CV_8U or CV_32F. Type CV_8U can be used only for +the first variant of the function and distanceType == #DIST_L1. +*/ +CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst, + int distanceType, int maskSize, int dstType=CV_32F); + +/** @brief Fills a connected component with the given color. + +The function cv::floodFill fills a connected component starting from the seed point with the specified +color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The +pixel at \f$(x,y)\f$ is considered to belong to the repainted domain if: + +- in case of a grayscale image and floating range +\f[\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\f] + + +- in case of a grayscale image and fixed range +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\f] + + +- in case of a color image and floating range +\f[\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\f] +\f[\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\f] +and +\f[\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\f] + + +- in case of a color image and fixed range +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\f] +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\f] +and +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\f] + + +where \f$src(x',y')\f$ is the value of one of pixel neighbors that is already known to belong to the +component. That is, to be added to the connected component, a color/brightness of the pixel should +be close enough to: +- Color/brightness of one of its neighbors that already belong to the connected component in case +of a floating range. +- Color/brightness of the seed point in case of a fixed range. + +Use these functions to either mark a connected component with the specified color in-place, or build +a mask and then extract the contour, or copy the region to another image, and so on. + +@param image Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the +function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See +the details below. +@param mask Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels +taller than image. Since this is both an input and output parameter, you must take responsibility +of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, +an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the +mask corresponding to filled pixels in the image are set to 1 or to the a value specified in flags +as described below. Additionally, the function fills the border of the mask with ones to simplify +internal processing. It is therefore possible to use the same mask in multiple calls to the function +to make sure the filled areas do not overlap. +@param seedPoint Starting point. +@param newVal New value of the repainted domain pixels. +@param loDiff Maximal lower brightness/color difference between the currently observed pixel and +one of its neighbors belonging to the component, or a seed pixel being added to the component. +@param upDiff Maximal upper brightness/color difference between the currently observed pixel and +one of its neighbors belonging to the component, or a seed pixel being added to the component. +@param rect Optional output parameter set by the function to the minimum bounding rectangle of the +repainted domain. +@param flags Operation flags. The first 8 bits contain a connectivity value. The default value of +4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A +connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) +will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill +the mask (the default value is 1). For example, 4 | ( 255 \<\< 8 ) will consider 4 nearest +neighbours and fill the mask with a value of 255. The following additional options occupy higher +bits and therefore may be further combined with the connectivity and mask fill values using +bit-wise or (|), see #FloodFillFlags. + +@note Since the mask is larger than the filled image, a pixel \f$(x, y)\f$ in image corresponds to the +pixel \f$(x+1, y+1)\f$ in the mask . + +@sa findContours + */ +CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask, + Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0, + Scalar loDiff = Scalar(), Scalar upDiff = Scalar(), + int flags = 4 ); + +/** @example samples/cpp/ffilldemo.cpp +An example using the FloodFill technique +*/ + +/** @overload + +variant without `mask` parameter +*/ +CV_EXPORTS int floodFill( InputOutputArray image, + Point seedPoint, Scalar newVal, CV_OUT Rect* rect = 0, + Scalar loDiff = Scalar(), Scalar upDiff = Scalar(), + int flags = 4 ); + +//! Performs linear blending of two images: +//! \f[ \texttt{dst}(i,j) = \texttt{weights1}(i,j)*\texttt{src1}(i,j) + \texttt{weights2}(i,j)*\texttt{src2}(i,j) \f] +//! @param src1 It has a type of CV_8UC(n) or CV_32FC(n), where n is a positive integer. +//! @param src2 It has the same type and size as src1. +//! @param weights1 It has a type of CV_32FC1 and the same size with src1. +//! @param weights2 It has a type of CV_32FC1 and the same size with src1. +//! @param dst It is created if it does not have the same size and type with src1. +CV_EXPORTS_W void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst); + +//! @} imgproc_misc + +//! @addtogroup imgproc_color_conversions +//! @{ + +/** @brief Converts an image from one color space to another. + +The function converts an input image from one color space to another. In case of a transformation +to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note +that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the +bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue +component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and +sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on. + +The conventional ranges for R, G, and B channel values are: +- 0 to 255 for CV_8U images +- 0 to 65535 for CV_16U images +- 0 to 1 for CV_32F images + +In case of linear transformations, the range does not matter. But in case of a non-linear +transformation, an input RGB image should be normalized to the proper value range to get the correct +results, for example, for RGB \f$\rightarrow\f$ L\*u\*v\* transformation. For example, if you have a +32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will +have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor , +you need first to scale the image down: +@code + img *= 1./255; + cvtColor(img, img, COLOR_BGR2Luv); +@endcode +If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many +applications, this will not be noticeable but it is recommended to use 32-bit images in applications +that need the full range of colors or that convert an image before an operation and then convert +back. + +If conversion adds the alpha channel, its value will set to the maximum of corresponding channel +range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F. + +@param src input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision +floating-point. +@param dst output image of the same size and depth as src. +@param code color space conversion code (see #ColorConversionCodes). +@param dstCn number of channels in the destination image; if the parameter is 0, the number of the +channels is derived automatically from src and code. + +@see @ref imgproc_color_conversions + */ +CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 ); + +/** @brief Converts an image from one color space to another where the source image is +stored in two planes. + +This function only supports YUV420 to RGB conversion as of now. + +@param src1: 8-bit image (#CV_8U) of the Y plane. +@param src2: image containing interleaved U/V plane. +@param dst: output image. +@param code: Specifies the type of conversion. It can take any of the following values: +- #COLOR_YUV2BGR_NV12 +- #COLOR_YUV2RGB_NV12 +- #COLOR_YUV2BGRA_NV12 +- #COLOR_YUV2RGBA_NV12 +- #COLOR_YUV2BGR_NV21 +- #COLOR_YUV2RGB_NV21 +- #COLOR_YUV2BGRA_NV21 +- #COLOR_YUV2RGBA_NV21 +*/ +CV_EXPORTS_W void cvtColorTwoPlane( InputArray src1, InputArray src2, OutputArray dst, int code ); + +/** @brief main function for all demosaicing processes + +@param src input image: 8-bit unsigned or 16-bit unsigned. +@param dst output image of the same size and depth as src. +@param code Color space conversion code (see the description below). +@param dstCn number of channels in the destination image; if the parameter is 0, the number of the +channels is derived automatically from src and code. + +The function can do the following transformations: + +- Demosaicing using bilinear interpolation + + #COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR + + #COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY + +- Demosaicing using Variable Number of Gradients. + + #COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG + +- Edge-Aware Demosaicing. + + #COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA + +- Demosaicing with alpha channel + + #COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA + +@sa cvtColor +*/ +CV_EXPORTS_W void demosaicing(InputArray src, OutputArray dst, int code, int dstCn = 0); + +//! @} imgproc_color_conversions + +//! @addtogroup imgproc_shape +//! @{ + +/** @brief Calculates all of the moments up to the third order of a polygon or rasterized shape. + +The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The +results are returned in the structure cv::Moments. + +@param array Raster image (single-channel, 8-bit or floating-point 2D array) or an array ( +\f$1 \times N\f$ or \f$N \times 1\f$ ) of 2D points (Point or Point2f ). +@param binaryImage If it is true, all non-zero image pixels are treated as 1's. The parameter is +used for images only. +@returns moments. + +@note Only applicable to contour moments calculations from Python bindings: Note that the numpy +type for the input array should be either np.int32 or np.float32. + +@sa contourArea, arcLength + */ +CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage = false ); + +/** @brief Calculates seven Hu invariants. + +The function calculates seven Hu invariants (introduced in @cite Hu62; see also +) defined as: + +\f[\begin{array}{l} hu[0]= \eta _{20}+ \eta _{02} \\ hu[1]=( \eta _{20}- \eta _{02})^{2}+4 \eta _{11}^{2} \\ hu[2]=( \eta _{30}-3 \eta _{12})^{2}+ (3 \eta _{21}- \eta _{03})^{2} \\ hu[3]=( \eta _{30}+ \eta _{12})^{2}+ ( \eta _{21}+ \eta _{03})^{2} \\ hu[4]=( \eta _{30}-3 \eta _{12})( \eta _{30}+ \eta _{12})[( \eta _{30}+ \eta _{12})^{2}-3( \eta _{21}+ \eta _{03})^{2}]+(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ hu[5]=( \eta _{20}- \eta _{02})[( \eta _{30}+ \eta _{12})^{2}- ( \eta _{21}+ \eta _{03})^{2}]+4 \eta _{11}( \eta _{30}+ \eta _{12})( \eta _{21}+ \eta _{03}) \\ hu[6]=(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}]-( \eta _{30}-3 \eta _{12})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ \end{array}\f] + +where \f$\eta_{ji}\f$ stands for \f$\texttt{Moments::nu}_{ji}\f$ . + +These values are proved to be invariants to the image scale, rotation, and reflection except the +seventh one, whose sign is changed by reflection. This invariance is proved with the assumption of +infinite image resolution. In case of raster images, the computed Hu invariants for the original and +transformed images are a bit different. + +@param moments Input moments computed with moments . +@param hu Output Hu invariants. + +@sa matchShapes + */ +CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] ); + +/** @overload */ +CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu ); + +//! @} imgproc_shape + +//! @addtogroup imgproc_object +//! @{ + +//! type of the template matching operation +enum TemplateMatchModes { + TM_SQDIFF = 0, /*!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f] + with mask: + \f[R(x,y)= \sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot + M(x',y') \right)^2\f] */ + TM_SQDIFF_NORMED = 1, /*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{ + x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f] + with mask: + \f[R(x,y)= \frac{\sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot + M(x',y') \right)^2}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot + M(x',y') \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot + M(x',y') \right)^2}}\f] */ + TM_CCORR = 2, /*!< \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y'))\f] + with mask: + \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot M(x',y') + ^2)\f] */ + TM_CCORR_NORMED = 3, /*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{ + \sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f] + with mask: + \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot + M(x',y')^2)}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot M(x',y') + \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot M(x',y') + \right)^2}}\f] */ + TM_CCOEFF = 4, /*!< \f[R(x,y)= \sum _{x',y'} (T'(x',y') \cdot I'(x+x',y+y'))\f] + where + \f[\begin{array}{l} T'(x',y')=T(x',y') - 1/(w \cdot h) \cdot \sum _{ + x'',y''} T(x'',y'') \\ I'(x+x',y+y')=I(x+x',y+y') - 1/(w \cdot h) + \cdot \sum _{x'',y''} I(x+x'',y+y'') \end{array}\f] + with mask: + \f[\begin{array}{l} T'(x',y')=M(x',y') \cdot \left( T(x',y') - + \frac{1}{\sum _{x'',y''} M(x'',y'')} \cdot \sum _{x'',y''} + (T(x'',y'') \cdot M(x'',y'')) \right) \\ I'(x+x',y+y')=M(x',y') + \cdot \left( I(x+x',y+y') - \frac{1}{\sum _{x'',y''} M(x'',y'')} + \cdot \sum _{x'',y''} (I(x+x'',y+y'') \cdot M(x'',y'')) \right) + \end{array} \f] */ + TM_CCOEFF_NORMED = 5 /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ + \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} + }\f] */ +}; + +/** @example samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp +An example using Template Matching algorithm +*/ + +/** @brief Compares a template against overlapped image regions. + +The function slides through image , compares the overlapped patches of size \f$w \times h\f$ against +templ using the specified method and stores the comparison results in result . #TemplateMatchModes +describes the formulae for the available comparison methods ( \f$I\f$ denotes image, \f$T\f$ +template, \f$R\f$ result, \f$M\f$ the optional mask ). The summation is done over template and/or +the image patch: \f$x' = 0...w-1, y' = 0...h-1\f$ + +After the function finishes the comparison, the best matches can be found as global minimums (when +#TM_SQDIFF was used) or maximums (when #TM_CCORR or #TM_CCOEFF was used) using the +#minMaxLoc function. In case of a color image, template summation in the numerator and each sum in +the denominator is done over all of the channels and separate mean values are used for each channel. +That is, the function can take a color template and a color image. The result will still be a +single-channel image, which is easier to analyze. + +@param image Image where the search is running. It must be 8-bit or 32-bit floating-point. +@param templ Searched template. It must be not greater than the source image and have the same +data type. +@param result Map of comparison results. It must be single-channel 32-bit floating-point. If image +is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ . +@param method Parameter specifying the comparison method, see #TemplateMatchModes +@param mask Optional mask. It must have the same size as templ. It must either have the same number + of channels as template or only one channel, which is then used for all template and + image channels. If the data type is #CV_8U, the mask is interpreted as a binary mask, + meaning only elements where mask is nonzero are used and are kept unchanged independent + of the actual mask value (weight equals 1). For data tpye #CV_32F, the mask values are + used as weights. The exact formulas are documented in #TemplateMatchModes. + */ +CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ, + OutputArray result, int method, InputArray mask = noArray() ); + +//! @} + +//! @addtogroup imgproc_shape +//! @{ + +/** @example samples/cpp/connected_components.cpp +This program demonstrates connected components and use of the trackbar +*/ + +/** @brief computes the connected components labeled image of boolean image + +image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0 +represents the background label. ltype specifies the output label image type, an important +consideration based on the total number of labels or alternatively the total number of pixels in +the source image. ccltype specifies the connected components labeling algorithm to use, currently +Bolelli (Spaghetti) @cite Bolelli2019, Grana (BBDT) @cite Grana2010 and Wu's (SAUF) @cite Wu2009 algorithms +are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces +a row major ordering of labels while Spaghetti and BBDT do not. +This function uses parallel version of the algorithms if at least one allowed +parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs. + +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +@param ccltype connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes). +*/ +CV_EXPORTS_AS(connectedComponentsWithAlgorithm) int connectedComponents(InputArray image, OutputArray labels, + int connectivity, int ltype, int ccltype); + + +/** @overload + +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +*/ +CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels, + int connectivity = 8, int ltype = CV_32S); + + +/** @brief computes the connected components labeled image of boolean image and also produces a statistics output for each label + +image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0 +represents the background label. ltype specifies the output label image type, an important +consideration based on the total number of labels or alternatively the total number of pixels in +the source image. ccltype specifies the connected components labeling algorithm to use, currently +Bolelli (Spaghetti) @cite Bolelli2019, Grana (BBDT) @cite Grana2010 and Wu's (SAUF) @cite Wu2009 algorithms +are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces +a row major ordering of labels while Spaghetti and BBDT do not. +This function uses parallel version of the algorithms (statistics included) if at least one allowed +parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs. + +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param stats statistics output for each label, including the background label. +Statistics are accessed via stats(label, COLUMN) where COLUMN is one of +#ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S. +@param centroids centroid output for each label, including the background label. Centroids are +accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F. +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +@param ccltype connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes). +*/ +CV_EXPORTS_AS(connectedComponentsWithStatsWithAlgorithm) int connectedComponentsWithStats(InputArray image, OutputArray labels, + OutputArray stats, OutputArray centroids, + int connectivity, int ltype, int ccltype); + +/** @overload +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param stats statistics output for each label, including the background label. +Statistics are accessed via stats(label, COLUMN) where COLUMN is one of +#ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S. +@param centroids centroid output for each label, including the background label. Centroids are +accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F. +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +*/ +CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labels, + OutputArray stats, OutputArray centroids, + int connectivity = 8, int ltype = CV_32S); + + +/** @brief Finds contours in a binary image. + +The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . The contours +are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the +OpenCV sample directory. +@note Since opencv 3.2 source image is not modified by this function. + +@param image Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP or #RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1). +@param contours Detected contours. Each contour is stored as a vector of points (e.g. +std::vector >). +@param hierarchy Optional output vector (e.g. std::vector), containing information about the image topology. It has +as many elements as the number of contours. For each i-th contour contours[i], the elements +hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices +in contours of the next and previous contours at the same hierarchical level, the first child +contour and the parent contour, respectively. If for the contour i there are no next, previous, +parent, or nested contours, the corresponding elements of hierarchy[i] will be negative. +@note In Python, hierarchy is nested inside a top level array. Use hierarchy[0][i] to access hierarchical elements of i-th contour. +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes +@param offset Optional offset by which every contour point is shifted. This is useful if the +contours are extracted from the image ROI and then they should be analyzed in the whole image +context. + */ +CV_EXPORTS_W void findContours( InputArray image, OutputArrayOfArrays contours, + OutputArray hierarchy, int mode, + int method, Point offset = Point()); + +/** @overload */ +CV_EXPORTS void findContours( InputArray image, OutputArrayOfArrays contours, + int mode, int method, Point offset = Point()); + +/** @example samples/cpp/squares.cpp +A program using pyramid scaling, Canny, contours and contour simplification to find +squares in a list of images (pic1-6.png). Returns sequence of squares detected on the image. +*/ + +/** @example samples/tapi/squares.cpp +A program using pyramid scaling, Canny, contours and contour simplification to find +squares in the input image. +*/ + +/** @brief Approximates a polygonal curve(s) with the specified precision. + +The function cv::approxPolyDP approximates a curve or a polygon with another curve/polygon with less +vertices so that the distance between them is less or equal to the specified precision. It uses the +Douglas-Peucker algorithm + +@param curve Input vector of a 2D point stored in std::vector or Mat +@param approxCurve Result of the approximation. The type should match the type of the input curve. +@param epsilon Parameter specifying the approximation accuracy. This is the maximum distance +between the original curve and its approximation. +@param closed If true, the approximated curve is closed (its first and last vertices are +connected). Otherwise, it is not closed. + */ +CV_EXPORTS_W void approxPolyDP( InputArray curve, + OutputArray approxCurve, + double epsilon, bool closed ); + +/** @brief Calculates a contour perimeter or a curve length. + +The function computes a curve length or a closed contour perimeter. + +@param curve Input vector of 2D points, stored in std::vector or Mat. +@param closed Flag indicating whether the curve is closed or not. + */ +CV_EXPORTS_W double arcLength( InputArray curve, bool closed ); + +/** @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image. + +The function calculates and returns the minimal up-right bounding rectangle for the specified point set or +non-zero pixels of gray-scale image. + +@param array Input gray-scale image or 2D point set, stored in std::vector or Mat. + */ +CV_EXPORTS_W Rect boundingRect( InputArray array ); + +/** @brief Calculates a contour area. + +The function computes a contour area. Similarly to moments , the area is computed using the Green +formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using +#drawContours or #fillPoly , can be different. Also, the function will most certainly give a wrong +results for contours with self-intersections. + +Example: +@code + vector contour; + contour.push_back(Point2f(0, 0)); + contour.push_back(Point2f(10, 0)); + contour.push_back(Point2f(10, 10)); + contour.push_back(Point2f(5, 4)); + + double area0 = contourArea(contour); + vector approx; + approxPolyDP(contour, approx, 5, true); + double area1 = contourArea(approx); + + cout << "area0 =" << area0 << endl << + "area1 =" << area1 << endl << + "approx poly vertices" << approx.size() << endl; +@endcode +@param contour Input vector of 2D points (contour vertices), stored in std::vector or Mat. +@param oriented Oriented area flag. If it is true, the function returns a signed area value, +depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can +determine orientation of a contour by taking the sign of an area. By default, the parameter is +false, which means that the absolute value is returned. + */ +CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false ); + +/** @brief Finds a rotated rectangle of the minimum area enclosing the input 2D point set. + +The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a +specified point set. Developer should keep in mind that the returned RotatedRect can contain negative +indices when data is close to the containing Mat element boundary. + +@param points Input vector of 2D points, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect minAreaRect( InputArray points ); + +/** @brief Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle. + +The function finds the four vertices of a rotated rectangle. This function is useful to draw the +rectangle. In C++, instead of using this function, you can directly use RotatedRect::points method. Please +visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information. + +@param box The input rotated rectangle. It may be the output of +@param points The output array of four vertices of rectangles. + */ +CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points); + +/** @brief Finds a circle of the minimum area enclosing a 2D point set. + +The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm. + +@param points Input vector of 2D points, stored in std::vector\<\> or Mat +@param center Output center of the circle. +@param radius Output radius of the circle. + */ +CV_EXPORTS_W void minEnclosingCircle( InputArray points, + CV_OUT Point2f& center, CV_OUT float& radius ); + +/** @example samples/cpp/minarea.cpp +*/ + +/** @brief Finds a triangle of minimum area enclosing a 2D point set and returns its area. + +The function finds a triangle of minimum area enclosing the given set of 2D points and returns its +area. The output for a given 2D point set is shown in the image below. 2D points are depicted in +*red* and the enclosing triangle in *yellow*. + +![Sample output of the minimum enclosing triangle function](pics/minenclosingtriangle.png) + +The implementation of the algorithm is based on O'Rourke's @cite ORourke86 and Klee and Laskowski's +@cite KleeLaskowski85 papers. O'Rourke provides a \f$\theta(n)\f$ algorithm for finding the minimal +enclosing triangle of a 2D convex polygon with n vertices. Since the #minEnclosingTriangle function +takes a 2D point set as input an additional preprocessing step of computing the convex hull of the +2D point set is required. The complexity of the #convexHull function is \f$O(n log(n))\f$ which is higher +than \f$\theta(n)\f$. Thus the overall complexity of the function is \f$O(n log(n))\f$. + +@param points Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector\<\> or Mat +@param triangle Output vector of three 2D points defining the vertices of the triangle. The depth +of the OutputArray must be CV_32F. + */ +CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle ); + +/** @brief Compares two shapes. + +The function compares two shapes. All three implemented methods use the Hu invariants (see #HuMoments) + +@param contour1 First contour or grayscale image. +@param contour2 Second contour or grayscale image. +@param method Comparison method, see #ShapeMatchModes +@param parameter Method-specific parameter (not supported now). + */ +CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2, + int method, double parameter ); + +/** @example samples/cpp/convexhull.cpp +An example using the convexHull functionality +*/ + +/** @brief Finds the convex hull of a point set. + +The function cv::convexHull finds the convex hull of a 2D point set using the Sklansky's algorithm @cite Sklansky82 +that has *O(N logN)* complexity in the current implementation. + +@param points Input 2D point set, stored in std::vector or Mat. +@param hull Output convex hull. It is either an integer vector of indices or vector of points. In +the first case, the hull elements are 0-based indices of the convex hull points in the original +array (since the set of convex hull points is a subset of the original point set). In the second +case, hull elements are the convex hull points themselves. +@param clockwise Orientation flag. If it is true, the output convex hull is oriented clockwise. +Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing +to the right, and its Y axis pointing upwards. +@param returnPoints Operation flag. In case of a matrix, when the flag is true, the function +returns convex hull points. Otherwise, it returns indices of the convex hull points. When the +output array is std::vector, the flag is ignored, and the output depends on the type of the +vector: std::vector\ implies returnPoints=false, std::vector\ implies +returnPoints=true. + +@note `points` and `hull` should be different arrays, inplace processing isn't supported. + +Check @ref tutorial_hull "the corresponding tutorial" for more details. + +useful links: + +https://www.learnopencv.com/convex-hull-using-opencv-in-python-and-c/ + */ +CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull, + bool clockwise = false, bool returnPoints = true ); + +/** @brief Finds the convexity defects of a contour. + +The figure below displays convexity defects of a hand contour: + +![image](pics/defects.png) + +@param contour Input contour. +@param convexhull Convex hull obtained using convexHull that should contain indices of the contour +points that make the hull. +@param convexityDefects The output vector of convexity defects. In C++ and the new Python/Java +interface each convexity defect is represented as 4-element integer vector (a.k.a. #Vec4i): +(start_index, end_index, farthest_pt_index, fixpt_depth), where indices are 0-based indices +in the original contour of the convexity defect beginning, end and the farthest point, and +fixpt_depth is fixed-point approximation (with 8 fractional bits) of the distance between the +farthest contour point and the hull. That is, to get the floating-point value of the depth will be +fixpt_depth/256.0. + */ +CV_EXPORTS_W void convexityDefects( InputArray contour, InputArray convexhull, OutputArray convexityDefects ); + +/** @brief Tests a contour convexity. + +The function tests whether the input contour is convex or not. The contour must be simple, that is, +without self-intersections. Otherwise, the function output is undefined. + +@param contour Input vector of 2D points, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W bool isContourConvex( InputArray contour ); + +/** @example samples/cpp/intersectExample.cpp +Examples of how intersectConvexConvex works +*/ + +/** @brief Finds intersection of two convex polygons + +@param p1 First polygon +@param p2 Second polygon +@param p12 Output polygon describing the intersecting area +@param handleNested When true, an intersection is found if one of the polygons is fully enclosed in the other. +When false, no intersection is found. If the polygons share a side or the vertex of one polygon lies on an edge +of the other, they are not considered nested and an intersection will be found regardless of the value of handleNested. + +@returns Absolute value of area of intersecting polygon + +@note intersectConvexConvex doesn't confirm that both polygons are convex and will return invalid results if they aren't. + */ +CV_EXPORTS_W float intersectConvexConvex( InputArray p1, InputArray p2, + OutputArray p12, bool handleNested = true ); + +/** @example samples/cpp/fitellipse.cpp +An example using the fitEllipse technique +*/ + +/** @brief Fits an ellipse around a set of 2D points. + +The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of +all. It returns the rotated rectangle in which the ellipse is inscribed. The first algorithm described by @cite Fitzgibbon95 +is used. Developer should keep in mind that it is possible that the returned +ellipse/rotatedRect data contains negative indices, due to the data points being close to the +border of the containing Mat element. + +@param points Input 2D point set, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect fitEllipse( InputArray points ); + +/** @brief Fits an ellipse around a set of 2D points. + + The function calculates the ellipse that fits a set of 2D points. + It returns the rotated rectangle in which the ellipse is inscribed. + The Approximate Mean Square (AMS) proposed by @cite Taubin1991 is used. + + For an ellipse, this basis set is \f$ \chi= \left(x^2, x y, y^2, x, y, 1\right) \f$, + which is a set of six free coefficients \f$ A^T=\left\{A_{\text{xx}},A_{\text{xy}},A_{\text{yy}},A_x,A_y,A_0\right\} \f$. + However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \f$ (a,b) \f$, + the position \f$ (x_0,y_0) \f$, and the orientation \f$ \theta \f$. This is because the basis set includes lines, + quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits. + If the fit is found to be a parabolic or hyperbolic function then the standard #fitEllipse method is used. + The AMS method restricts the fit to parabolic, hyperbolic and elliptical curves + by imposing the condition that \f$ A^T ( D_x^T D_x + D_y^T D_y) A = 1 \f$ where + the matrices \f$ Dx \f$ and \f$ Dy \f$ are the partial derivatives of the design matrix \f$ D \f$ with + respect to x and y. The matrices are formed row by row applying the following to + each of the points in the set: + \f{align*}{ + D(i,:)&=\left\{x_i^2, x_i y_i, y_i^2, x_i, y_i, 1\right\} & + D_x(i,:)&=\left\{2 x_i,y_i,0,1,0,0\right\} & + D_y(i,:)&=\left\{0,x_i,2 y_i,0,1,0\right\} + \f} + The AMS method minimizes the cost function + \f{equation*}{ + \epsilon ^2=\frac{ A^T D^T D A }{ A^T (D_x^T D_x + D_y^T D_y) A^T } + \f} + + The minimum cost is found by solving the generalized eigenvalue problem. + + \f{equation*}{ + D^T D A = \lambda \left( D_x^T D_x + D_y^T D_y\right) A + \f} + + @param points Input 2D point set, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect fitEllipseAMS( InputArray points ); + + +/** @brief Fits an ellipse around a set of 2D points. + + The function calculates the ellipse that fits a set of 2D points. + It returns the rotated rectangle in which the ellipse is inscribed. + The Direct least square (Direct) method by @cite Fitzgibbon1999 is used. + + For an ellipse, this basis set is \f$ \chi= \left(x^2, x y, y^2, x, y, 1\right) \f$, + which is a set of six free coefficients \f$ A^T=\left\{A_{\text{xx}},A_{\text{xy}},A_{\text{yy}},A_x,A_y,A_0\right\} \f$. + However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \f$ (a,b) \f$, + the position \f$ (x_0,y_0) \f$, and the orientation \f$ \theta \f$. This is because the basis set includes lines, + quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits. + The Direct method confines the fit to ellipses by ensuring that \f$ 4 A_{xx} A_{yy}- A_{xy}^2 > 0 \f$. + The condition imposed is that \f$ 4 A_{xx} A_{yy}- A_{xy}^2=1 \f$ which satisfies the inequality + and as the coefficients can be arbitrarily scaled is not overly restrictive. + + \f{equation*}{ + \epsilon ^2= A^T D^T D A \quad \text{with} \quad A^T C A =1 \quad \text{and} \quad C=\left(\begin{matrix} + 0 & 0 & 2 & 0 & 0 & 0 \\ + 0 & -1 & 0 & 0 & 0 & 0 \\ + 2 & 0 & 0 & 0 & 0 & 0 \\ + 0 & 0 & 0 & 0 & 0 & 0 \\ + 0 & 0 & 0 & 0 & 0 & 0 \\ + 0 & 0 & 0 & 0 & 0 & 0 + \end{matrix} \right) + \f} + + The minimum cost is found by solving the generalized eigenvalue problem. + + \f{equation*}{ + D^T D A = \lambda \left( C\right) A + \f} + + The system produces only one positive eigenvalue \f$ \lambda\f$ which is chosen as the solution + with its eigenvector \f$\mathbf{u}\f$. These are used to find the coefficients + + \f{equation*}{ + A = \sqrt{\frac{1}{\mathbf{u}^T C \mathbf{u}}} \mathbf{u} + \f} + The scaling factor guarantees that \f$A^T C A =1\f$. + + @param points Input 2D point set, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect fitEllipseDirect( InputArray points ); + +/** @brief Fits a line to a 2D or 3D point set. + +The function fitLine fits a line to a 2D or 3D point set by minimizing \f$\sum_i \rho(r_i)\f$ where +\f$r_i\f$ is a distance between the \f$i^{th}\f$ point, the line and \f$\rho(r)\f$ is a distance function, one +of the following: +- DIST_L2 +\f[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\f] +- DIST_L1 +\f[\rho (r) = r\f] +- DIST_L12 +\f[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\f] +- DIST_FAIR +\f[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{where} \quad C=1.3998\f] +- DIST_WELSCH +\f[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{where} \quad C=2.9846\f] +- DIST_HUBER +\f[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\f] + +The algorithm is based on the M-estimator ( ) technique +that iteratively fits the line using the weighted least-squares algorithm. After each iteration the +weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . + +@param points Input vector of 2D or 3D points, stored in std::vector\<\> or Mat. +@param line Output line parameters. In case of 2D fitting, it should be a vector of 4 elements +(like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and +(x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like +Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line +and (x0, y0, z0) is a point on the line. +@param distType Distance used by the M-estimator, see #DistanceTypes +@param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value +is chosen. +@param reps Sufficient accuracy for the radius (distance between the coordinate origin and the line). +@param aeps Sufficient accuracy for the angle. 0.01 would be a good default value for reps and aeps. + */ +CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType, + double param, double reps, double aeps ); + +/** @brief Performs a point-in-contour test. + +The function determines whether the point is inside a contour, outside, or lies on an edge (or +coincides with a vertex). It returns positive (inside), negative (outside), or zero (on an edge) +value, correspondingly. When measureDist=false , the return value is +1, -1, and 0, respectively. +Otherwise, the return value is a signed distance between the point and the nearest contour edge. + +See below a sample output of the function where each image pixel is tested against the contour: + +![sample output](pics/pointpolygon.png) + +@param contour Input contour. +@param pt Point tested against the contour. +@param measureDist If true, the function estimates the signed distance from the point to the +nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not. + */ +CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist ); + +/** @brief Finds out if there is any intersection between two rotated rectangles. + +If there is then the vertices of the intersecting region are returned as well. + +Below are some examples of intersection configurations. The hatched pattern indicates the +intersecting region and the red vertices are returned by the function. + +![intersection examples](pics/intersection.png) + +@param rect1 First rectangle +@param rect2 Second rectangle +@param intersectingRegion The output array of the vertices of the intersecting region. It returns +at most 8 vertices. Stored as std::vector\ or cv::Mat as Mx1 of type CV_32FC2. +@returns One of #RectanglesIntersectTypes + */ +CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion ); + +/** @brief Creates a smart pointer to a cv::GeneralizedHoughBallard class and initializes it. +*/ +CV_EXPORTS_W Ptr createGeneralizedHoughBallard(); + +/** @brief Creates a smart pointer to a cv::GeneralizedHoughGuil class and initializes it. +*/ +CV_EXPORTS_W Ptr createGeneralizedHoughGuil(); + +//! @} imgproc_shape + +//! @addtogroup imgproc_colormap +//! @{ + +//! GNU Octave/MATLAB equivalent colormaps +enum ColormapTypes +{ + COLORMAP_AUTUMN = 0, //!< ![autumn](pics/colormaps/colorscale_autumn.jpg) + COLORMAP_BONE = 1, //!< ![bone](pics/colormaps/colorscale_bone.jpg) + COLORMAP_JET = 2, //!< ![jet](pics/colormaps/colorscale_jet.jpg) + COLORMAP_WINTER = 3, //!< ![winter](pics/colormaps/colorscale_winter.jpg) + COLORMAP_RAINBOW = 4, //!< ![rainbow](pics/colormaps/colorscale_rainbow.jpg) + COLORMAP_OCEAN = 5, //!< ![ocean](pics/colormaps/colorscale_ocean.jpg) + COLORMAP_SUMMER = 6, //!< ![summer](pics/colormaps/colorscale_summer.jpg) + COLORMAP_SPRING = 7, //!< ![spring](pics/colormaps/colorscale_spring.jpg) + COLORMAP_COOL = 8, //!< ![cool](pics/colormaps/colorscale_cool.jpg) + COLORMAP_HSV = 9, //!< ![HSV](pics/colormaps/colorscale_hsv.jpg) + COLORMAP_PINK = 10, //!< ![pink](pics/colormaps/colorscale_pink.jpg) + COLORMAP_HOT = 11, //!< ![hot](pics/colormaps/colorscale_hot.jpg) + COLORMAP_PARULA = 12, //!< ![parula](pics/colormaps/colorscale_parula.jpg) + COLORMAP_MAGMA = 13, //!< ![magma](pics/colormaps/colorscale_magma.jpg) + COLORMAP_INFERNO = 14, //!< ![inferno](pics/colormaps/colorscale_inferno.jpg) + COLORMAP_PLASMA = 15, //!< ![plasma](pics/colormaps/colorscale_plasma.jpg) + COLORMAP_VIRIDIS = 16, //!< ![viridis](pics/colormaps/colorscale_viridis.jpg) + COLORMAP_CIVIDIS = 17, //!< ![cividis](pics/colormaps/colorscale_cividis.jpg) + COLORMAP_TWILIGHT = 18, //!< ![twilight](pics/colormaps/colorscale_twilight.jpg) + COLORMAP_TWILIGHT_SHIFTED = 19, //!< ![twilight shifted](pics/colormaps/colorscale_twilight_shifted.jpg) + COLORMAP_TURBO = 20, //!< ![turbo](pics/colormaps/colorscale_turbo.jpg) + COLORMAP_DEEPGREEN = 21 //!< ![deepgreen](pics/colormaps/colorscale_deepgreen.jpg) +}; + +/** @example samples/cpp/falsecolor.cpp +An example using applyColorMap function +*/ + +/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image. + +@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3. +@param dst The result is the colormapped source image. Note: Mat::create is called on dst. +@param colormap The colormap to apply, see #ColormapTypes +*/ +CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap); + +/** @brief Applies a user colormap on a given image. + +@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3. +@param dst The result is the colormapped source image. Note: Mat::create is called on dst. +@param userColor The colormap to apply of type CV_8UC1 or CV_8UC3 and size 256 +*/ +CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, InputArray userColor); + +//! @} imgproc_colormap + +//! @addtogroup imgproc_draw +//! @{ + + +/** OpenCV color channel order is BGR[A] */ +#define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0) + +/** @brief Draws a line segment connecting two points. + +The function line draws the line segment between pt1 and pt2 points in the image. The line is +clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected +or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings. Antialiased +lines are drawn using Gaussian filtering. + +@param img Image. +@param pt1 First point of the line segment. +@param pt2 Second point of the line segment. +@param color Line color. +@param thickness Line thickness. +@param lineType Type of the line. See #LineTypes. +@param shift Number of fractional bits in the point coordinates. + */ +CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, + int thickness = 1, int lineType = LINE_8, int shift = 0); + +/** @brief Draws an arrow segment pointing from the first point to the second one. + +The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line. + +@param img Image. +@param pt1 The point the arrow starts from. +@param pt2 The point the arrow points to. +@param color Line color. +@param thickness Line thickness. +@param line_type Type of the line. See #LineTypes +@param shift Number of fractional bits in the point coordinates. +@param tipLength The length of the arrow tip in relation to the arrow length + */ +CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, + int thickness=1, int line_type=8, int shift=0, double tipLength=0.1); + +/** @brief Draws a simple, thick, or filled up-right rectangle. + +The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners +are pt1 and pt2. + +@param img Image. +@param pt1 Vertex of the rectangle. +@param pt2 Vertex of the rectangle opposite to pt1 . +@param color Rectangle color or brightness (grayscale image). +@param thickness Thickness of lines that make up the rectangle. Negative values, like #FILLED, +mean that the function has to draw a filled rectangle. +@param lineType Type of the line. See #LineTypes +@param shift Number of fractional bits in the point coordinates. + */ +CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @overload + +use `rec` parameter as alternative specification of the drawn rectangle: `r.tl() and +r.br()-Point(1,1)` are opposite corners +*/ +CV_EXPORTS_W void rectangle(InputOutputArray img, Rect rec, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @example samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp +An example using drawing functions +*/ + +/** @brief Draws a circle. + +The function cv::circle draws a simple or filled circle with a given center and radius. +@param img Image where the circle is drawn. +@param center Center of the circle. +@param radius Radius of the circle. +@param color Circle color. +@param thickness Thickness of the circle outline, if positive. Negative values, like #FILLED, +mean that a filled circle is to be drawn. +@param lineType Type of the circle boundary. See #LineTypes +@param shift Number of fractional bits in the coordinates of the center and in the radius value. + */ +CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @brief Draws a simple or thick elliptic arc or fills an ellipse sector. + +The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic +arc, or a filled ellipse sector. The drawing code uses general parametric form. +A piecewise-linear curve is used to approximate the elliptic arc +boundary. If you need more control of the ellipse rendering, you can retrieve the curve using +#ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first +variant of the function and want to draw the whole ellipse, not an arc, pass `startAngle=0` and +`endAngle=360`. If `startAngle` is greater than `endAngle`, they are swapped. The figure below explains +the meaning of the parameters to draw the blue arc. + +![Parameters of Elliptic Arc](pics/ellipse.svg) + +@param img Image. +@param center Center of the ellipse. +@param axes Half of the size of the ellipse main axes. +@param angle Ellipse rotation angle in degrees. +@param startAngle Starting angle of the elliptic arc in degrees. +@param endAngle Ending angle of the elliptic arc in degrees. +@param color Ellipse color. +@param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that +a filled ellipse sector is to be drawn. +@param lineType Type of the ellipse boundary. See #LineTypes +@param shift Number of fractional bits in the coordinates of the center and values of axes. + */ +CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes, + double angle, double startAngle, double endAngle, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @overload +@param img Image. +@param box Alternative ellipse representation via RotatedRect. This means that the function draws +an ellipse inscribed in the rotated rectangle. +@param color Ellipse color. +@param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that +a filled ellipse sector is to be drawn. +@param lineType Type of the ellipse boundary. See #LineTypes +*/ +CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color, + int thickness = 1, int lineType = LINE_8); + +/* ----------------------------------------------------------------------------------------- */ +/* ADDING A SET OF PREDEFINED MARKERS WHICH COULD BE USED TO HIGHLIGHT POSITIONS IN AN IMAGE */ +/* ----------------------------------------------------------------------------------------- */ + +/** @brief Draws a marker on a predefined position in an image. + +The function cv::drawMarker draws a marker on a given position in the image. For the moment several +marker types are supported, see #MarkerTypes for more information. + +@param img Image. +@param position The point where the crosshair is positioned. +@param color Line color. +@param markerType The specific type of marker you want to use, see #MarkerTypes +@param thickness Line thickness. +@param line_type Type of the line, See #LineTypes +@param markerSize The length of the marker axis [default = 20 pixels] + */ +CV_EXPORTS_W void drawMarker(InputOutputArray img, Point position, const Scalar& color, + int markerType = MARKER_CROSS, int markerSize=20, int thickness=1, + int line_type=8); + +/* ----------------------------------------------------------------------------------------- */ +/* END OF MARKER SECTION */ +/* ----------------------------------------------------------------------------------------- */ + +/** @brief Fills a convex polygon. + +The function cv::fillConvexPoly draws a filled convex polygon. This function is much faster than the +function #fillPoly . It can fill not only convex polygons but any monotonic polygon without +self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line) +twice at the most (though, its top-most and/or the bottom edge could be horizontal). + +@param img Image. +@param points Polygon vertices. +@param color Polygon color. +@param lineType Type of the polygon boundaries. See #LineTypes +@param shift Number of fractional bits in the vertex coordinates. + */ +CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points, + const Scalar& color, int lineType = LINE_8, + int shift = 0); + +/** @overload */ +CV_EXPORTS void fillConvexPoly(InputOutputArray img, const Point* pts, int npts, + const Scalar& color, int lineType = LINE_8, + int shift = 0); + +/** @example samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp +An example using drawing functions +Check @ref tutorial_random_generator_and_text "the corresponding tutorial" for more details +*/ + +/** @brief Fills the area bounded by one or more polygons. + +The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill +complex areas, for example, areas with holes, contours with self-intersections (some of their +parts), and so forth. + +@param img Image. +@param pts Array of polygons where each polygon is represented as an array of points. +@param color Polygon color. +@param lineType Type of the polygon boundaries. See #LineTypes +@param shift Number of fractional bits in the vertex coordinates. +@param offset Optional offset of all points of the contours. + */ +CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts, + const Scalar& color, int lineType = LINE_8, int shift = 0, + Point offset = Point() ); + +/** @overload */ +CV_EXPORTS void fillPoly(InputOutputArray img, const Point** pts, + const int* npts, int ncontours, + const Scalar& color, int lineType = LINE_8, int shift = 0, + Point offset = Point() ); + +/** @brief Draws several polygonal curves. + +@param img Image. +@param pts Array of polygonal curves. +@param isClosed Flag indicating whether the drawn polylines are closed or not. If they are closed, +the function draws a line from the last vertex of each curve to its first vertex. +@param color Polyline color. +@param thickness Thickness of the polyline edges. +@param lineType Type of the line segments. See #LineTypes +@param shift Number of fractional bits in the vertex coordinates. + +The function cv::polylines draws one or more polygonal curves. + */ +CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts, + bool isClosed, const Scalar& color, + int thickness = 1, int lineType = LINE_8, int shift = 0 ); + +/** @overload */ +CV_EXPORTS void polylines(InputOutputArray img, const Point* const* pts, const int* npts, + int ncontours, bool isClosed, const Scalar& color, + int thickness = 1, int lineType = LINE_8, int shift = 0 ); + +/** @example samples/cpp/contours2.cpp +An example program illustrates the use of cv::findContours and cv::drawContours +\image html WindowsQtContoursOutput.png "Screenshot of the program" +*/ + +/** @example samples/cpp/segment_objects.cpp +An example using drawContours to clean up a background segmentation result +*/ + +/** @brief Draws contours outlines or filled contours. + +The function draws contour outlines in the image if \f$\texttt{thickness} \ge 0\f$ or fills the area +bounded by the contours if \f$\texttt{thickness}<0\f$ . The example below shows how to retrieve +connected components from the binary image and label them: : +@include snippets/imgproc_drawContours.cpp + +@param image Destination image. +@param contours All the input contours. Each contour is stored as a point vector. +@param contourIdx Parameter indicating a contour to draw. If it is negative, all the contours are drawn. +@param color Color of the contours. +@param thickness Thickness of lines the contours are drawn with. If it is negative (for example, +thickness=#FILLED ), the contour interiors are drawn. +@param lineType Line connectivity. See #LineTypes +@param hierarchy Optional information about hierarchy. It is only needed if you want to draw only +some of the contours (see maxLevel ). +@param maxLevel Maximal level for drawn contours. If it is 0, only the specified contour is drawn. +If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function +draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This +parameter is only taken into account when there is hierarchy available. +@param offset Optional contour shift parameter. Shift all the drawn contours by the specified +\f$\texttt{offset}=(dx,dy)\f$ . +@note When thickness=#FILLED, the function is designed to handle connected components with holes correctly +even when no hierarchy data is provided. This is done by analyzing all the outlines together +using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved +contours. In order to solve this problem, you need to call #drawContours separately for each sub-group +of contours, or iterate over the collection using contourIdx parameter. + */ +CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours, + int contourIdx, const Scalar& color, + int thickness = 1, int lineType = LINE_8, + InputArray hierarchy = noArray(), + int maxLevel = INT_MAX, Point offset = Point() ); + +/** @brief Clips the line against the image rectangle. + +The function cv::clipLine calculates a part of the line segment that is entirely within the specified +rectangle. It returns false if the line segment is completely outside the rectangle. Otherwise, +it returns true . +@param imgSize Image size. The image rectangle is Rect(0, 0, imgSize.width, imgSize.height) . +@param pt1 First line point. +@param pt2 Second line point. + */ +CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2); + +/** @overload +@param imgSize Image size. The image rectangle is Rect(0, 0, imgSize.width, imgSize.height) . +@param pt1 First line point. +@param pt2 Second line point. +*/ +CV_EXPORTS bool clipLine(Size2l imgSize, CV_IN_OUT Point2l& pt1, CV_IN_OUT Point2l& pt2); + +/** @overload +@param imgRect Image rectangle. +@param pt1 First line point. +@param pt2 Second line point. +*/ +CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_IN_OUT Point& pt2); + +/** @brief Approximates an elliptic arc with a polyline. + +The function ellipse2Poly computes the vertices of a polyline that approximates the specified +elliptic arc. It is used by #ellipse. If `arcStart` is greater than `arcEnd`, they are swapped. + +@param center Center of the arc. +@param axes Half of the size of the ellipse main axes. See #ellipse for details. +@param angle Rotation angle of the ellipse in degrees. See #ellipse for details. +@param arcStart Starting angle of the elliptic arc in degrees. +@param arcEnd Ending angle of the elliptic arc in degrees. +@param delta Angle between the subsequent polyline vertices. It defines the approximation +accuracy. +@param pts Output vector of polyline vertices. + */ +CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle, + int arcStart, int arcEnd, int delta, + CV_OUT std::vector& pts ); + +/** @overload +@param center Center of the arc. +@param axes Half of the size of the ellipse main axes. See #ellipse for details. +@param angle Rotation angle of the ellipse in degrees. See #ellipse for details. +@param arcStart Starting angle of the elliptic arc in degrees. +@param arcEnd Ending angle of the elliptic arc in degrees. +@param delta Angle between the subsequent polyline vertices. It defines the approximation accuracy. +@param pts Output vector of polyline vertices. +*/ +CV_EXPORTS void ellipse2Poly(Point2d center, Size2d axes, int angle, + int arcStart, int arcEnd, int delta, + CV_OUT std::vector& pts); + +/** @brief Draws a text string. + +The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered +using the specified font are replaced by question marks. See #getTextSize for a text rendering code +example. + +@param img Image. +@param text Text string to be drawn. +@param org Bottom-left corner of the text string in the image. +@param fontFace Font type, see #HersheyFonts. +@param fontScale Font scale factor that is multiplied by the font-specific base size. +@param color Text color. +@param thickness Thickness of the lines used to draw a text. +@param lineType Line type. See #LineTypes +@param bottomLeftOrigin When true, the image data origin is at the bottom-left corner. Otherwise, +it is at the top-left corner. + */ +CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org, + int fontFace, double fontScale, Scalar color, + int thickness = 1, int lineType = LINE_8, + bool bottomLeftOrigin = false ); + +/** @brief Calculates the width and height of a text string. + +The function cv::getTextSize calculates and returns the size of a box that contains the specified text. +That is, the following code renders some text, the tight box surrounding it, and the baseline: : +@code + String text = "Funny text inside the box"; + int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX; + double fontScale = 2; + int thickness = 3; + + Mat img(600, 800, CV_8UC3, Scalar::all(0)); + + int baseline=0; + Size textSize = getTextSize(text, fontFace, + fontScale, thickness, &baseline); + baseline += thickness; + + // center the text + Point textOrg((img.cols - textSize.width)/2, + (img.rows + textSize.height)/2); + + // draw the box + rectangle(img, textOrg + Point(0, baseline), + textOrg + Point(textSize.width, -textSize.height), + Scalar(0,0,255)); + // ... and the baseline first + line(img, textOrg + Point(0, thickness), + textOrg + Point(textSize.width, thickness), + Scalar(0, 0, 255)); + + // then put the text itself + putText(img, text, textOrg, fontFace, fontScale, + Scalar::all(255), thickness, 8); +@endcode + +@param text Input text string. +@param fontFace Font to use, see #HersheyFonts. +@param fontScale Font scale factor that is multiplied by the font-specific base size. +@param thickness Thickness of lines used to render the text. See #putText for details. +@param[out] baseLine y-coordinate of the baseline relative to the bottom-most text +point. +@return The size of a box that contains the specified text. + +@see putText + */ +CV_EXPORTS_W Size getTextSize(const String& text, int fontFace, + double fontScale, int thickness, + CV_OUT int* baseLine); + + +/** @brief Calculates the font-specific size to use to achieve a given height in pixels. + +@param fontFace Font to use, see cv::HersheyFonts. +@param pixelHeight Pixel height to compute the fontScale for +@param thickness Thickness of lines used to render the text.See putText for details. +@return The fontSize to use for cv::putText + +@see cv::putText +*/ +CV_EXPORTS_W double getFontScaleFromHeight(const int fontFace, + const int pixelHeight, + const int thickness = 1); + +/** @brief Line iterator + +The class is used to iterate over all the pixels on the raster line +segment connecting two specified points. + +The class LineIterator is used to get each pixel of a raster line. It +can be treated as versatile implementation of the Bresenham algorithm +where you can stop at each pixel and do some extra processing, for +example, grab pixel values along the line or draw a line with an effect +(for example, with XOR operation). + +The number of pixels along the line is stored in LineIterator::count. +The method LineIterator::pos returns the current position in the image: + +@code{.cpp} +// grabs pixels along the line (pt1, pt2) +// from 8-bit 3-channel image to the buffer +LineIterator it(img, pt1, pt2, 8); +LineIterator it2 = it; +vector buf(it.count); + +for(int i = 0; i < it.count; i++, ++it) + buf[i] = *(const Vec3b*)*it; + +// alternative way of iterating through the line +for(int i = 0; i < it2.count; i++, ++it2) +{ + Vec3b val = img.at(it2.pos()); + CV_Assert(buf[i] == val); +} +@endcode +*/ +class CV_EXPORTS LineIterator +{ +public: + /** @brief initializes the iterator + + creates iterators for the line connecting pt1 and pt2 + the line will be clipped on the image boundaries + the line is 8-connected or 4-connected + If leftToRight=true, then the iteration is always done + from the left-most point to the right most, + not to depend on the ordering of pt1 and pt2 parameters; + */ + LineIterator( const Mat& img, Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(&img, Rect(0, 0, img.cols, img.rows), pt1, pt2, connectivity, leftToRight); + ptmode = false; + } + LineIterator( Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(0, Rect(std::min(pt1.x, pt2.x), + std::min(pt1.y, pt2.y), + std::max(pt1.x, pt2.x) - std::min(pt1.x, pt2.x) + 1, + std::max(pt1.y, pt2.y) - std::min(pt1.y, pt2.y) + 1), + pt1, pt2, connectivity, leftToRight); + ptmode = true; + } + LineIterator( Size boundingAreaSize, Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(0, Rect(0, 0, boundingAreaSize.width, boundingAreaSize.height), + pt1, pt2, connectivity, leftToRight); + ptmode = true; + } + LineIterator( Rect boundingAreaRect, Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(0, boundingAreaRect, pt1, pt2, connectivity, leftToRight); + ptmode = true; + } + void init(const Mat* img, Rect boundingAreaRect, Point pt1, Point pt2, int connectivity, bool leftToRight); + + /** @brief returns pointer to the current pixel + */ + uchar* operator *(); + /** @brief prefix increment operator (++it). shifts iterator to the next pixel + */ + LineIterator& operator ++(); + /** @brief postfix increment operator (it++). shifts iterator to the next pixel + */ + LineIterator operator ++(int); + /** @brief returns coordinates of the current pixel + */ + Point pos() const; + + uchar* ptr; + const uchar* ptr0; + int step, elemSize; + int err, count; + int minusDelta, plusDelta; + int minusStep, plusStep; + int minusShift, plusShift; + Point p; + bool ptmode; +}; + +//! @cond IGNORED + +// === LineIterator implementation === + +inline +uchar* LineIterator::operator *() +{ + return ptmode ? 0 : ptr; +} + +inline +LineIterator& LineIterator::operator ++() +{ + int mask = err < 0 ? -1 : 0; + err += minusDelta + (plusDelta & mask); + if(!ptmode) + { + ptr += minusStep + (plusStep & mask); + } + else + { + p.x += minusShift + (plusShift & mask); + p.y += minusStep + (plusStep & mask); + } + return *this; +} + +inline +LineIterator LineIterator::operator ++(int) +{ + LineIterator it = *this; + ++(*this); + return it; +} + +inline +Point LineIterator::pos() const +{ + if(!ptmode) + { + size_t offset = (size_t)(ptr - ptr0); + int y = (int)(offset/step); + int x = (int)((offset - (size_t)y*step)/elemSize); + return Point(x, y); + } + return p; +} + +//! @endcond + +//! @} imgproc_draw + +//! @} imgproc + +} // cv + + +#include "./imgproc/segmentation.hpp" + + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/bindings.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/bindings.hpp new file mode 100644 index 0000000..c69527a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/bindings.hpp @@ -0,0 +1,34 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGPROC_BINDINGS_HPP +#define OPENCV_IMGPROC_BINDINGS_HPP + +// This file contains special overloads for OpenCV bindings +// No need to use these functions in C++ code. + +namespace cv { + +/** @brief Finds lines in a binary image using the standard Hough transform and get accumulator. + * + * @note This function is for bindings use only. Use original function in C++ code + * + * @sa HoughLines + */ +CV_WRAP static inline +void HoughLinesWithAccumulator( + InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double srn = 0, double stn = 0, + double min_theta = 0, double max_theta = CV_PI +) +{ + std::vector lines_acc; + HoughLines(image, lines_acc, rho, theta, threshold, srn, stn, min_theta, max_theta); + Mat(lines_acc).copyTo(lines); +} + +} // namespace + +#endif // OPENCV_IMGPROC_BINDINGS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/detail/gcgraph.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/detail/gcgraph.hpp new file mode 100644 index 0000000..f17c6e7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/detail/gcgraph.hpp @@ -0,0 +1,395 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_DETAIL_GCGRAPH_HPP +#define OPENCV_IMGPROC_DETAIL_GCGRAPH_HPP + +//! @cond IGNORED + +namespace cv { namespace detail { +template class GCGraph +{ +public: + GCGraph(); + GCGraph( unsigned int vtxCount, unsigned int edgeCount ); + ~GCGraph(); + void create( unsigned int vtxCount, unsigned int edgeCount ); + int addVtx(); + void addEdges( int i, int j, TWeight w, TWeight revw ); + void addTermWeights( int i, TWeight sourceW, TWeight sinkW ); + TWeight maxFlow(); + bool inSourceSegment( int i ); +private: + class Vtx + { + public: + Vtx *next; // initialized and used in maxFlow() only + int parent; + int first; + int ts; + int dist; + TWeight weight; + uchar t; + }; + class Edge + { + public: + int dst; + int next; + TWeight weight; + }; + + std::vector vtcs; + std::vector edges; + TWeight flow; +}; + +template +GCGraph::GCGraph() +{ + flow = 0; +} +template +GCGraph::GCGraph( unsigned int vtxCount, unsigned int edgeCount ) +{ + create( vtxCount, edgeCount ); +} +template +GCGraph::~GCGraph() +{ +} +template +void GCGraph::create( unsigned int vtxCount, unsigned int edgeCount ) +{ + vtcs.reserve( vtxCount ); + edges.reserve( edgeCount + 2 ); + flow = 0; +} + +template +int GCGraph::addVtx() +{ + Vtx v; + memset( &v, 0, sizeof(Vtx)); + vtcs.push_back(v); + return (int)vtcs.size() - 1; +} + +template +void GCGraph::addEdges( int i, int j, TWeight w, TWeight revw ) +{ + CV_Assert( i>=0 && i<(int)vtcs.size() ); + CV_Assert( j>=0 && j<(int)vtcs.size() ); + CV_Assert( w>=0 && revw>=0 ); + CV_Assert( i != j ); + + if( !edges.size() ) + edges.resize( 2 ); + + Edge fromI, toI; + fromI.dst = j; + fromI.next = vtcs[i].first; + fromI.weight = w; + vtcs[i].first = (int)edges.size(); + edges.push_back( fromI ); + + toI.dst = i; + toI.next = vtcs[j].first; + toI.weight = revw; + vtcs[j].first = (int)edges.size(); + edges.push_back( toI ); +} + +template +void GCGraph::addTermWeights( int i, TWeight sourceW, TWeight sinkW ) +{ + CV_Assert( i>=0 && i<(int)vtcs.size() ); + + TWeight dw = vtcs[i].weight; + if( dw > 0 ) + sourceW += dw; + else + sinkW -= dw; + flow += (sourceW < sinkW) ? sourceW : sinkW; + vtcs[i].weight = sourceW - sinkW; +} + +template +TWeight GCGraph::maxFlow() +{ + CV_Assert(!vtcs.empty()); + CV_Assert(!edges.empty()); + const int TERMINAL = -1, ORPHAN = -2; + Vtx stub, *nilNode = &stub, *first = nilNode, *last = nilNode; + int curr_ts = 0; + stub.next = nilNode; + Vtx *vtxPtr = &vtcs[0]; + Edge *edgePtr = &edges[0]; + + std::vector orphans; + + // initialize the active queue and the graph vertices + for( int i = 0; i < (int)vtcs.size(); i++ ) + { + Vtx* v = vtxPtr + i; + v->ts = 0; + if( v->weight != 0 ) + { + last = last->next = v; + v->dist = 1; + v->parent = TERMINAL; + v->t = v->weight < 0; + } + else + v->parent = 0; + } + first = first->next; + last->next = nilNode; + nilNode->next = 0; + + // run the search-path -> augment-graph -> restore-trees loop + for(;;) + { + Vtx* v, *u; + int e0 = -1, ei = 0, ej = 0; + TWeight minWeight, weight; + uchar vt; + + // grow S & T search trees, find an edge connecting them + while( first != nilNode ) + { + v = first; + if( v->parent ) + { + vt = v->t; + for( ei = v->first; ei != 0; ei = edgePtr[ei].next ) + { + if( edgePtr[ei^vt].weight == 0 ) + continue; + u = vtxPtr+edgePtr[ei].dst; + if( !u->parent ) + { + u->t = vt; + u->parent = ei ^ 1; + u->ts = v->ts; + u->dist = v->dist + 1; + if( !u->next ) + { + u->next = nilNode; + last = last->next = u; + } + continue; + } + + if( u->t != vt ) + { + e0 = ei ^ vt; + break; + } + + if( u->dist > v->dist+1 && u->ts <= v->ts ) + { + // reassign the parent + u->parent = ei ^ 1; + u->ts = v->ts; + u->dist = v->dist + 1; + } + } + if( e0 > 0 ) + break; + } + // exclude the vertex from the active list + first = first->next; + v->next = 0; + } + + if( e0 <= 0 ) + break; + + // find the minimum edge weight along the path + minWeight = edgePtr[e0].weight; + CV_Assert( minWeight > 0 ); + // k = 1: source tree, k = 0: destination tree + for( int k = 1; k >= 0; k-- ) + { + for( v = vtxPtr+edgePtr[e0^k].dst;; v = vtxPtr+edgePtr[ei].dst ) + { + if( (ei = v->parent) < 0 ) + break; + weight = edgePtr[ei^k].weight; + minWeight = MIN(minWeight, weight); + CV_Assert( minWeight > 0 ); + } + weight = fabs(v->weight); + minWeight = MIN(minWeight, weight); + CV_Assert( minWeight > 0 ); + } + + // modify weights of the edges along the path and collect orphans + edgePtr[e0].weight -= minWeight; + edgePtr[e0^1].weight += minWeight; + flow += minWeight; + + // k = 1: source tree, k = 0: destination tree + for( int k = 1; k >= 0; k-- ) + { + for( v = vtxPtr+edgePtr[e0^k].dst;; v = vtxPtr+edgePtr[ei].dst ) + { + if( (ei = v->parent) < 0 ) + break; + edgePtr[ei^(k^1)].weight += minWeight; + if( (edgePtr[ei^k].weight -= minWeight) == 0 ) + { + orphans.push_back(v); + v->parent = ORPHAN; + } + } + + v->weight = v->weight + minWeight*(1-k*2); + if( v->weight == 0 ) + { + orphans.push_back(v); + v->parent = ORPHAN; + } + } + + // restore the search trees by finding new parents for the orphans + curr_ts++; + while( !orphans.empty() ) + { + Vtx* v2 = orphans.back(); + orphans.pop_back(); + + int d, minDist = INT_MAX; + e0 = 0; + vt = v2->t; + + for( ei = v2->first; ei != 0; ei = edgePtr[ei].next ) + { + if( edgePtr[ei^(vt^1)].weight == 0 ) + continue; + u = vtxPtr+edgePtr[ei].dst; + if( u->t != vt || u->parent == 0 ) + continue; + // compute the distance to the tree root + for( d = 0;; ) + { + if( u->ts == curr_ts ) + { + d += u->dist; + break; + } + ej = u->parent; + d++; + if( ej < 0 ) + { + if( ej == ORPHAN ) + d = INT_MAX-1; + else + { + u->ts = curr_ts; + u->dist = 1; + } + break; + } + u = vtxPtr+edgePtr[ej].dst; + } + + // update the distance + if( ++d < INT_MAX ) + { + if( d < minDist ) + { + minDist = d; + e0 = ei; + } + for( u = vtxPtr+edgePtr[ei].dst; u->ts != curr_ts; u = vtxPtr+edgePtr[u->parent].dst ) + { + u->ts = curr_ts; + u->dist = --d; + } + } + } + + if( (v2->parent = e0) > 0 ) + { + v2->ts = curr_ts; + v2->dist = minDist; + continue; + } + + /* no parent is found */ + v2->ts = 0; + for( ei = v2->first; ei != 0; ei = edgePtr[ei].next ) + { + u = vtxPtr+edgePtr[ei].dst; + ej = u->parent; + if( u->t != vt || !ej ) + continue; + if( edgePtr[ei^(vt^1)].weight && !u->next ) + { + u->next = nilNode; + last = last->next = u; + } + if( ej > 0 && vtxPtr+edgePtr[ej].dst == v2 ) + { + orphans.push_back(u); + u->parent = ORPHAN; + } + } + } + } + return flow; +} + +template +bool GCGraph::inSourceSegment( int i ) +{ + CV_Assert( i>=0 && i<(int)vtcs.size() ); + return vtcs[i].t == 0; +} + +}} // namespace detail, cv + + +//! @endcond + +#endif // OPENCV_IMGPROC_DETAIL_GCGRAPH_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/hal/hal.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/hal/hal.hpp new file mode 100644 index 0000000..f129012 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/hal/hal.hpp @@ -0,0 +1,246 @@ +#ifndef CV_IMGPROC_HAL_HPP +#define CV_IMGPROC_HAL_HPP + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/hal/interface.h" + +namespace cv { namespace hal { + +//! @addtogroup imgproc_hal_functions +//! @{ + +//--------------------------- +//! @cond IGNORED + +struct CV_EXPORTS Filter2D +{ + CV_DEPRECATED static Ptr create(uchar * , size_t , int , + int , int , + int , int , + int , int , + int , double , + int , int , + bool , bool ); + virtual void apply(uchar * , size_t , + uchar * , size_t , + int , int , + int , int , + int , int ) = 0; + virtual ~Filter2D() {} +}; + +struct CV_EXPORTS SepFilter2D +{ + CV_DEPRECATED static Ptr create(int , int , int , + uchar * , int , + uchar * , int , + int , int , + double , int ); + virtual void apply(uchar * , size_t , + uchar * , size_t , + int , int , + int , int , + int , int ) = 0; + virtual ~SepFilter2D() {} +}; + + +struct CV_EXPORTS Morph +{ + CV_DEPRECATED static Ptr create(int , int , int , int , int , + int , uchar * , size_t , + int , int , + int , int , + int , const double *, + int , bool , bool ); + virtual void apply(uchar * , size_t , uchar * , size_t , int , int , + int , int , int , int , + int , int , int , int ) = 0; + virtual ~Morph() {} +}; + +//! @endcond +//--------------------------- + +CV_EXPORTS void filter2D(int stype, int dtype, int kernel_type, + uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int full_width, int full_height, + int offset_x, int offset_y, + uchar * kernel_data, size_t kernel_step, + int kernel_width, int kernel_height, + int anchor_x, int anchor_y, + double delta, int borderType, + bool isSubmatrix); + +CV_EXPORTS void sepFilter2D(int stype, int dtype, int ktype, + uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int full_width, int full_height, + int offset_x, int offset_y, + uchar * kernelx_data, int kernelx_len, + uchar * kernely_data, int kernely_len, + int anchor_x, int anchor_y, + double delta, int borderType); + +CV_EXPORTS void morph(int op, int src_type, int dst_type, + uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int roi_width, int roi_height, int roi_x, int roi_y, + int roi_width2, int roi_height2, int roi_x2, int roi_y2, + int kernel_type, uchar * kernel_data, size_t kernel_step, + int kernel_width, int kernel_height, int anchor_x, int anchor_y, + int borderType, const double borderValue[4], + int iterations, bool isSubmatrix); + + +CV_EXPORTS void resize(int src_type, + const uchar * src_data, size_t src_step, int src_width, int src_height, + uchar * dst_data, size_t dst_step, int dst_width, int dst_height, + double inv_scale_x, double inv_scale_y, int interpolation); + +CV_EXPORTS void warpAffine(int src_type, + const uchar * src_data, size_t src_step, int src_width, int src_height, + uchar * dst_data, size_t dst_step, int dst_width, int dst_height, + const double M[6], int interpolation, int borderType, const double borderValue[4]); + +CV_EXPORTS void warpPerspective(int src_type, + const uchar * src_data, size_t src_step, int src_width, int src_height, + uchar * dst_data, size_t dst_step, int dst_width, int dst_height, + const double M[9], int interpolation, int borderType, const double borderValue[4]); + +CV_EXPORTS void cvtBGRtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, int dcn, bool swapBlue); + +CV_EXPORTS void cvtBGRtoBGR5x5(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int scn, bool swapBlue, int greenBits); + +CV_EXPORTS void cvtBGR5x5toBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int dcn, bool swapBlue, int greenBits); + +CV_EXPORTS void cvtBGRtoGray(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue); + +CV_EXPORTS void cvtGraytoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn); + +CV_EXPORTS void cvtBGR5x5toGray(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int greenBits); + +CV_EXPORTS void cvtGraytoBGR5x5(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int greenBits); +CV_EXPORTS void cvtBGRtoYUV(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue, bool isCbCr); + +CV_EXPORTS void cvtYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue, bool isCbCr); + +CV_EXPORTS void cvtBGRtoXYZ(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue); + +CV_EXPORTS void cvtXYZtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue); + +CV_EXPORTS void cvtBGRtoHSV(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue, bool isFullRange, bool isHSV); + +CV_EXPORTS void cvtHSVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV); + +CV_EXPORTS void cvtBGRtoLab(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue, bool isLab, bool srgb); + +CV_EXPORTS void cvtLabtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue, bool isLab, bool srgb); + +CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +//! Separate Y and UV planes +CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * y_data, const uchar * uv_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * y_data, size_t y_step, const uchar * uv_data, size_t uv_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtThreePlaneYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtBGRtoThreePlaneYUV(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int scn, bool swapBlue, int uIdx); + +//! Separate Y and UV planes +CV_EXPORTS void cvtBGRtoTwoPlaneYUV(const uchar * src_data, size_t src_step, + uchar * y_data, uchar * uv_data, size_t dst_step, + int width, int height, + int scn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtOnePlaneYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int dcn, bool swapBlue, int uIdx, int ycn); + +CV_EXPORTS void cvtRGBAtoMultipliedRGBA(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height); + +CV_EXPORTS void cvtMultipliedRGBAtoRGBA(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height); + +CV_EXPORTS void integral(int depth, int sdepth, int sqdepth, + const uchar* src, size_t srcstep, + uchar* sum, size_t sumstep, + uchar* sqsum, size_t sqsumstep, + uchar* tilted, size_t tstep, + int width, int height, int cn); + +//! @} + +}} + +#endif // CV_IMGPROC_HAL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/hal/interface.h b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/hal/interface.h new file mode 100644 index 0000000..f8dbcfe --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/hal/interface.h @@ -0,0 +1,46 @@ +#ifndef OPENCV_IMGPROC_HAL_INTERFACE_H +#define OPENCV_IMGPROC_HAL_INTERFACE_H + +//! @addtogroup imgproc_hal_interface +//! @{ + +//! @name Interpolation modes +//! @sa cv::InterpolationFlags +//! @{ +#define CV_HAL_INTER_NEAREST 0 +#define CV_HAL_INTER_LINEAR 1 +#define CV_HAL_INTER_CUBIC 2 +#define CV_HAL_INTER_AREA 3 +#define CV_HAL_INTER_LANCZOS4 4 +//! @} + +//! @name Morphology operations +//! @sa cv::MorphTypes +//! @{ +#define CV_HAL_MORPH_ERODE 0 +#define CV_HAL_MORPH_DILATE 1 +//! @} + +//! @name Threshold types +//! @sa cv::ThresholdTypes +//! @{ +#define CV_HAL_THRESH_BINARY 0 +#define CV_HAL_THRESH_BINARY_INV 1 +#define CV_HAL_THRESH_TRUNC 2 +#define CV_HAL_THRESH_TOZERO 3 +#define CV_HAL_THRESH_TOZERO_INV 4 +#define CV_HAL_THRESH_MASK 7 +#define CV_HAL_THRESH_OTSU 8 +#define CV_HAL_THRESH_TRIANGLE 16 +//! @} + +//! @name Adaptive threshold algorithm +//! @sa cv::AdaptiveThresholdTypes +//! @{ +#define CV_HAL_ADAPTIVE_THRESH_MEAN_C 0 +#define CV_HAL_ADAPTIVE_THRESH_GAUSSIAN_C 1 +//! @} + +//! @} + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/imgproc.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/imgproc.hpp new file mode 100644 index 0000000..4175bd0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/imgproc.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/imgproc.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/imgproc_c.h b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/imgproc_c.h new file mode 100644 index 0000000..86dc119 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/imgproc_c.h @@ -0,0 +1,1177 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_IMGPROC_C_H +#define OPENCV_IMGPROC_IMGPROC_C_H + +#include "opencv2/imgproc/types_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup imgproc_c +@{ +*/ + +/*********************** Background statistics accumulation *****************************/ + +/** @brief Adds image to accumulator +@see cv::accumulate +*/ +CVAPI(void) cvAcc( const CvArr* image, CvArr* sum, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Adds squared image to accumulator +@see cv::accumulateSquare +*/ +CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Adds a product of two images to accumulator +@see cv::accumulateProduct +*/ +CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha +@see cv::accumulateWeighted +*/ +CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha, + const CvArr* mask CV_DEFAULT(NULL) ); + +/****************************************************************************************\ +* Image Processing * +\****************************************************************************************/ + +/** Copies source 2D array inside of the larger destination array and + makes a border of the specified type (IPL_BORDER_*) around the copied area. */ +CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset, + int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0))); + +/** @brief Smooths the image in one of several ways. + +@param src The source image +@param dst The destination image +@param smoothtype Type of the smoothing, see SmoothMethod_c +@param size1 The first parameter of the smoothing operation, the aperture width. Must be a +positive odd number (1, 3, 5, ...) +@param size2 The second parameter of the smoothing operation, the aperture height. Ignored by +CV_MEDIAN and CV_BILATERAL methods. In the case of simple scaled/non-scaled and Gaussian blur if +size2 is zero, it is set to size1. Otherwise it must be a positive odd number. +@param sigma1 In the case of a Gaussian parameter this parameter may specify Gaussian \f$\sigma\f$ +(standard deviation). If it is zero, it is calculated from the kernel size: +\f[\sigma = 0.3 (n/2 - 1) + 0.8 \quad \text{where} \quad n= \begin{array}{l l} \mbox{\texttt{size1} for horizontal kernel} \\ \mbox{\texttt{size2} for vertical kernel} \end{array}\f] +Using standard sigma for small kernels ( \f$3\times 3\f$ to \f$7\times 7\f$ ) gives better speed. If +sigma1 is not zero, while size1 and size2 are zeros, the kernel size is calculated from the +sigma (to provide accurate enough operation). +@param sigma2 additional parameter for bilateral filtering + +@see cv::GaussianBlur, cv::blur, cv::medianBlur, cv::bilateralFilter. + */ +CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst, + int smoothtype CV_DEFAULT(CV_GAUSSIAN), + int size1 CV_DEFAULT(3), + int size2 CV_DEFAULT(0), + double sigma1 CV_DEFAULT(0), + double sigma2 CV_DEFAULT(0)); + +/** @brief Convolves an image with the kernel. + +@param src input image. +@param dst output image of the same size and the same number of channels as src. +@param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point +matrix; if you want to apply different kernels to different channels, split the image into +separate color planes using split and process them individually. +@param anchor anchor of the kernel that indicates the relative position of a filtered point within +the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor +is at the kernel center. + +@see cv::filter2D + */ +CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, + CvPoint anchor CV_DEFAULT(cvPoint(-1,-1))); + +/** @brief Finds integral image: SUM(X,Y) = sum(x \texttt{hist1}(I)\)}{\frac{\texttt{hist2}(I) \cdot \texttt{scale}}{\texttt{hist1}(I)}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) \le \texttt{hist1}(I)\)}\f] + +@param hist1 First histogram (the divisor). +@param hist2 Second histogram. +@param dst_hist Destination histogram. +@param scale Scale factor for the destination histogram. + */ +CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2, + CvHistogram* dst_hist, double scale CV_DEFAULT(255) ); + +/** @brief equalizes histogram of 8-bit single-channel image +@see cv::equalizeHist +*/ +CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst ); + + +/** @brief Applies distance transform to binary image +@see cv::distanceTransform +*/ +CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst, + int distance_type CV_DEFAULT(CV_DIST_L2), + int mask_size CV_DEFAULT(3), + const float* mask CV_DEFAULT(NULL), + CvArr* labels CV_DEFAULT(NULL), + int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP)); + + +/** @brief Applies fixed-level threshold to grayscale image. + + This is a basic operation applied before retrieving contours +@see cv::threshold +*/ +CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst, + double threshold, double max_value, + int threshold_type ); + +/** @brief Applies adaptive threshold to grayscale image. + + The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and + CV_ADAPTIVE_THRESH_GAUSSIAN_C are: + neighborhood size (3, 5, 7 etc.), + and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) +@see cv::adaptiveThreshold +*/ +CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value, + int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C), + int threshold_type CV_DEFAULT(CV_THRESH_BINARY), + int block_size CV_DEFAULT(3), + double param1 CV_DEFAULT(5)); + +/** @brief Fills the connected component until the color difference gets large enough +@see cv::floodFill +*/ +CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point, + CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)), + CvScalar up_diff CV_DEFAULT(cvScalarAll(0)), + CvConnectedComp* comp CV_DEFAULT(NULL), + int flags CV_DEFAULT(4), + CvArr* mask CV_DEFAULT(NULL)); + +/****************************************************************************************\ +* Feature detection * +\****************************************************************************************/ + +/** @brief Runs canny edge detector +@see cv::Canny +*/ +CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1, + double threshold2, int aperture_size CV_DEFAULT(3) ); + +/** @brief Calculates constraint image for corner detection + + Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. + Applying threshold to the result gives coordinates of corners +@see cv::preCornerDetect +*/ +CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners, + int aperture_size CV_DEFAULT(3) ); + +/** @brief Calculates eigen values and vectors of 2x2 + gradient covariation matrix at every image pixel +@see cv::cornerEigenValsAndVecs +*/ +CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/** @brief Calculates minimal eigenvalue for 2x2 gradient covariation matrix at + every image pixel +@see cv::cornerMinEigenVal +*/ +CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/** @brief Harris corner detector: + + Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel +@see cv::cornerHarris +*/ +CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_response, + int block_size, int aperture_size CV_DEFAULT(3), + double k CV_DEFAULT(0.04) ); + +/** @brief Adjust corner position using some sort of gradient search +@see cv::cornerSubPix +*/ +CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, + int count, CvSize win, CvSize zero_zone, + CvTermCriteria criteria ); + +/** @brief Finds a sparse set of points within the selected region + that seem to be easy to track +@see cv::goodFeaturesToTrack +*/ +CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, + CvArr* temp_image, CvPoint2D32f* corners, + int* corner_count, double quality_level, + double min_distance, + const CvArr* mask CV_DEFAULT(NULL), + int block_size CV_DEFAULT(3), + int use_harris CV_DEFAULT(0), + double k CV_DEFAULT(0.04) ); + +/** @brief Finds lines on binary image using one of several methods. + + line_storage is either memory storage or 1 x _max number of lines_ CvMat, its + number of columns is changed by the function. + method is one of CV_HOUGH_*; + rho, theta and threshold are used for each of those methods; + param1 ~ line length, param2 ~ line gap - for probabilistic, + param1 ~ srn, param2 ~ stn - for multi-scale +@see cv::HoughLines +*/ +CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method, + double rho, double theta, int threshold, + double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0), + double min_theta CV_DEFAULT(0), double max_theta CV_DEFAULT(CV_PI)); + +/** @brief Finds circles in the image +@see cv::HoughCircles +*/ +CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage, + int method, double dp, double min_dist, + double param1 CV_DEFAULT(100), + double param2 CV_DEFAULT(100), + int min_radius CV_DEFAULT(0), + int max_radius CV_DEFAULT(0)); + +/** @brief Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) +@see cv::fitLine +*/ +CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, + double reps, double aeps, float* line ); + +/****************************************************************************************\ +* Drawing * +\****************************************************************************************/ + +/****************************************************************************************\ +* Drawing functions work with images/matrices of arbitrary type. * +* For color images the channel order is BGR[A] * +* Antialiasing is supported only for 8-bit image now. * +* All the functions include parameter color that means rgb value (that may be * +* constructed with CV_RGB macro) for color images and brightness * +* for grayscale images. * +* If a drawn figure is partially or completely outside of the image, it is clipped.* +\****************************************************************************************/ + +#define CV_FILLED -1 + +#define CV_AA 16 + +/** @brief Draws 4-connected, 8-connected or antialiased line segment connecting two points +@see cv::line +*/ +CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/** @brief Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2) + + if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn +@see cv::rectangle +*/ +CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + int shift CV_DEFAULT(0)); + +/** @brief Draws a rectangle specified by a CvRect structure +@see cv::rectangle +*/ +CVAPI(void) cvRectangleR( CvArr* img, CvRect r, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + int shift CV_DEFAULT(0)); + + +/** @brief Draws a circle with specified center and radius. + + Thickness works in the same way as with cvRectangle +@see cv::circle +*/ +CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/** @brief Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector + + depending on _thickness_, _start_angle_ and _end_angle_ parameters. The resultant figure + is rotated by _angle_. All the angles are in degrees +@see cv::ellipse +*/ +CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, + double angle, double start_angle, double end_angle, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color, + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ) +{ + CvSize axes = cvSize( + cvRound(box.size.width*0.5), + cvRound(box.size.height*0.5) + ); + + cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle, + 0, 360, color, thickness, line_type, shift ); +} + +/** @brief Fills convex or monotonous polygon. +@see cv::fillConvexPoly +*/ +CVAPI(void) cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/** @brief Fills an area bounded by one or more arbitrary polygons +@see cv::fillPoly +*/ +CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, const int* npts, + int contours, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/** @brief Draws one or more polygonal curves +@see cv::polylines +*/ +CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours, + int is_closed, CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +#define cvDrawRect cvRectangle +#define cvDrawLine cvLine +#define cvDrawCircle cvCircle +#define cvDrawEllipse cvEllipse +#define cvDrawPolyLine cvPolyLine + +/** @brief Clips the line segment connecting *pt1 and *pt2 + by the rectangular window + + (0<=xptr will point to pt1 (or pt2, see left_to_right description) location in +the image. Returns the number of pixels on the line between the ending points. +@see cv::LineIterator +*/ +CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2, + CvLineIterator* line_iterator, + int connectivity CV_DEFAULT(8), + int left_to_right CV_DEFAULT(0)); + +#define CV_NEXT_LINE_POINT( line_iterator ) \ +{ \ + int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \ + (line_iterator).err += (line_iterator).minus_delta + \ + ((line_iterator).plus_delta & _line_iterator_mask); \ + (line_iterator).ptr += (line_iterator).minus_step + \ + ((line_iterator).plus_step & _line_iterator_mask); \ +} + + +#define CV_FONT_HERSHEY_SIMPLEX 0 +#define CV_FONT_HERSHEY_PLAIN 1 +#define CV_FONT_HERSHEY_DUPLEX 2 +#define CV_FONT_HERSHEY_COMPLEX 3 +#define CV_FONT_HERSHEY_TRIPLEX 4 +#define CV_FONT_HERSHEY_COMPLEX_SMALL 5 +#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6 +#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7 + +#define CV_FONT_ITALIC 16 + +#define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX + + +/** Font structure */ +typedef struct CvFont +{ + const char* nameFont; //Qt:nameFont + CvScalar color; //Qt:ColorFont -> cvScalar(blue_component, green_component, red_component[, alpha_component]) + int font_face; //Qt: bool italic /** =CV_FONT_* */ + const int* ascii; //!< font data and metrics + const int* greek; + const int* cyrillic; + float hscale, vscale; + float shear; //!< slope coefficient: 0 - normal, >0 - italic + int thickness; //!< Qt: weight /** letters thickness */ + float dx; //!< horizontal interval between letters + int line_type; //!< Qt: PointSize +} +CvFont; + +/** @brief Initializes font structure (OpenCV 1.x API). + +The function initializes the font structure that can be passed to text rendering functions. + +@param font Pointer to the font structure initialized by the function +@param font_face Font name identifier. See cv::HersheyFonts and corresponding old CV_* identifiers. +@param hscale Horizontal scale. If equal to 1.0f , the characters have the original width +depending on the font type. If equal to 0.5f , the characters are of half the original width. +@param vscale Vertical scale. If equal to 1.0f , the characters have the original height depending +on the font type. If equal to 0.5f , the characters are of half the original height. +@param shear Approximate tangent of the character slope relative to the vertical line. A zero +value means a non-italic font, 1.0f means about a 45 degree slope, etc. +@param thickness Thickness of the text strokes +@param line_type Type of the strokes, see line description + +@sa cvPutText + */ +CVAPI(void) cvInitFont( CvFont* font, int font_face, + double hscale, double vscale, + double shear CV_DEFAULT(0), + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8)); + +CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) ) +{ + CvFont font; + cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA ); + return font; +} + +/** @brief Renders text stroke with specified font and color at specified location. + CvFont should be initialized with cvInitFont +@see cvInitFont, cvGetTextSize, cvFont, cv::putText +*/ +CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org, + const CvFont* font, CvScalar color ); + +/** @brief Calculates bounding box of text stroke (useful for alignment) +@see cv::getTextSize +*/ +CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font, + CvSize* text_size, int* baseline ); + +/** @brief Unpacks color value + +if arrtype is CV_8UC?, _color_ is treated as packed color value, otherwise the first channels +(depending on arrtype) of destination scalar are set to the same value = _color_ +*/ +CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype ); + +/** @brief Returns the polygon points which make up the given ellipse. + +The ellipse is define by the box of size 'axes' rotated 'angle' around the 'center'. A partial +sweep of the ellipse arc can be done by specifying arc_start and arc_end to be something other than +0 and 360, respectively. The input array 'pts' must be large enough to hold the result. The total +number of points stored into 'pts' is returned by this function. +@see cv::ellipse2Poly +*/ +CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes, + int angle, int arc_start, int arc_end, CvPoint * pts, int delta ); + +/** @brief Draws contour outlines or filled interiors on the image +@see cv::drawContours +*/ +CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, + CvScalar external_color, CvScalar hole_color, + int max_level, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + CvPoint offset CV_DEFAULT(cvPoint(0,0))); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/segmentation.hpp b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/segmentation.hpp new file mode 100644 index 0000000..26882f4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/segmentation.hpp @@ -0,0 +1,141 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGPROC_SEGMENTATION_HPP +#define OPENCV_IMGPROC_SEGMENTATION_HPP + +#include "opencv2/imgproc.hpp" + +namespace cv { + +namespace segmentation { + +//! @addtogroup imgproc_segmentation +//! @{ + + +/** @brief Intelligent Scissors image segmentation + * + * This class is used to find the path (contour) between two points + * which can be used for image segmentation. + * + * Usage example: + * @snippet snippets/imgproc_segmentation.cpp usage_example_intelligent_scissors + * + * Reference: "Intelligent Scissors for Image Composition" + * algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University + * @cite Mortensen95intelligentscissors + */ +class CV_EXPORTS_W_SIMPLE IntelligentScissorsMB +{ +public: + CV_WRAP + IntelligentScissorsMB(); + + /** @brief Specify weights of feature functions + * + * Consider keeping weights normalized (sum of weights equals to 1.0) + * Discrete dynamic programming (DP) goal is minimization of costs between pixels. + * + * @param weight_non_edge Specify cost of non-edge pixels (default: 0.43f) + * @param weight_gradient_direction Specify cost of gradient direction function (default: 0.43f) + * @param weight_gradient_magnitude Specify cost of gradient magnitude function (default: 0.14f) + */ + CV_WRAP + IntelligentScissorsMB& setWeights(float weight_non_edge, float weight_gradient_direction, float weight_gradient_magnitude); + + /** @brief Specify gradient magnitude max value threshold + * + * Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article). + * Otherwize pixels with `gradient magnitude >= threshold` have zero cost. + * + * @note Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos). + * + * @param gradient_magnitude_threshold_max Specify gradient magnitude max value threshold (default: 0, disabled) + */ + CV_WRAP + IntelligentScissorsMB& setGradientMagnitudeMaxLimit(float gradient_magnitude_threshold_max = 0.0f); + + /** @brief Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters + * + * This feature extractor is used by default according to article. + * + * Implementation has additional filtering for regions with low-amplitude noise. + * This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16). + * + * @note Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first). + * + * @note Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters(). + * + * @param gradient_magnitude_min_value Minimal gradient magnitude value for edge pixels (default: 0, check is disabled) + */ + CV_WRAP + IntelligentScissorsMB& setEdgeFeatureZeroCrossingParameters(float gradient_magnitude_min_value = 0.0f); + + /** @brief Switch edge feature extractor to use Canny edge detector + * + * @note "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) + * + * @sa Canny + */ + CV_WRAP + IntelligentScissorsMB& setEdgeFeatureCannyParameters( + double threshold1, double threshold2, + int apertureSize = 3, bool L2gradient = false + ); + + /** @brief Specify input image and extract image features + * + * @param image input image. Type is #CV_8UC1 / #CV_8UC3 + */ + CV_WRAP + IntelligentScissorsMB& applyImage(InputArray image); + + /** @brief Specify custom features of imput image + * + * Customized advanced variant of applyImage() call. + * + * @param non_edge Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are `{0, 1}`. + * @param gradient_direction Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: `x^2 + y^2 == 1` + * @param gradient_magnitude Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range `[0, 1]`. + * @param image **Optional parameter**. Must be specified if subset of features is specified (non-specified features are calculated internally) + */ + CV_WRAP + IntelligentScissorsMB& applyImageFeatures( + InputArray non_edge, InputArray gradient_direction, InputArray gradient_magnitude, + InputArray image = noArray() + ); + + /** @brief Prepares a map of optimal paths for the given source point on the image + * + * @note applyImage() / applyImageFeatures() must be called before this call + * + * @param sourcePt The source point used to find the paths + */ + CV_WRAP void buildMap(const Point& sourcePt); + + /** @brief Extracts optimal contour for the given target point on the image + * + * @note buildMap() must be called before this call + * + * @param targetPt The target point + * @param[out] contour The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with `std::vector`) + * @param backward Flag to indicate reverse order of retrived pixels (use "true" value to fetch points from the target to the source point) + */ + CV_WRAP void getContour(const Point& targetPt, OutputArray contour, bool backward = false) const; + +#ifndef CV_DOXYGEN + struct Impl; + inline Impl* getImpl() const { return impl.get(); } +protected: + std::shared_ptr impl; +#endif +}; + +//! @} + +} // namespace segmentation +} // namespace cv + +#endif // OPENCV_IMGPROC_SEGMENTATION_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/imgproc/types_c.h b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/types_c.h new file mode 100644 index 0000000..d3e55f5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/imgproc/types_c.h @@ -0,0 +1,659 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_TYPES_C_H +#define OPENCV_IMGPROC_TYPES_C_H + +#include "opencv2/core/core_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup imgproc_c + @{ +*/ + +/** Connected component structure */ +typedef struct CvConnectedComp +{ + double area; /** DBL_EPSILON ? 1./std::sqrt(am00) : 0; + } + operator cv::Moments() const + { + return cv::Moments(m00, m10, m01, m20, m11, m02, m30, m21, m12, m03); + } +#endif +} +CvMoments; + +#ifdef __cplusplus +} // extern "C" + +CV_INLINE CvMoments cvMoments() +{ +#if !defined(CV__ENABLE_C_API_CTORS) + CvMoments self = CV_STRUCT_INITIALIZER; return self; +#else + return CvMoments(); +#endif +} + +CV_INLINE CvMoments cvMoments(const cv::Moments& m) +{ +#if !defined(CV__ENABLE_C_API_CTORS) + double am00 = std::abs(m.m00); + CvMoments self = { + m.m00, m.m10, m.m01, m.m20, m.m11, m.m02, m.m30, m.m21, m.m12, m.m03, + m.mu20, m.mu11, m.mu02, m.mu30, m.mu21, m.mu12, m.mu03, + am00 > DBL_EPSILON ? 1./std::sqrt(am00) : 0 + }; + return self; +#else + return CvMoments(m); +#endif +} + +extern "C" { +#endif // __cplusplus + +/** Hu invariants */ +typedef struct CvHuMoments +{ + double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /**< Hu invariants */ +} +CvHuMoments; + +/** Template matching methods */ +enum +{ + CV_TM_SQDIFF =0, + CV_TM_SQDIFF_NORMED =1, + CV_TM_CCORR =2, + CV_TM_CCORR_NORMED =3, + CV_TM_CCOEFF =4, + CV_TM_CCOEFF_NORMED =5 +}; + +typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param ); + +/** Contour retrieval modes */ +enum +{ + CV_RETR_EXTERNAL=0, + CV_RETR_LIST=1, + CV_RETR_CCOMP=2, + CV_RETR_TREE=3, + CV_RETR_FLOODFILL=4 +}; + +/** Contour approximation methods */ +enum +{ + CV_CHAIN_CODE=0, + CV_CHAIN_APPROX_NONE=1, + CV_CHAIN_APPROX_SIMPLE=2, + CV_CHAIN_APPROX_TC89_L1=3, + CV_CHAIN_APPROX_TC89_KCOS=4, + CV_LINK_RUNS=5 +}; + +/* +Internal structure that is used for sequential retrieving contours from the image. +It supports both hierarchical and plane variants of Suzuki algorithm. +*/ +typedef struct _CvContourScanner* CvContourScanner; + +/** Freeman chain reader state */ +typedef struct CvChainPtReader +{ + CV_SEQ_READER_FIELDS() + char code; + CvPoint pt; + schar deltas[8][2]; +} +CvChainPtReader; + +/** initializes 8-element array for fast access to 3x3 neighborhood of a pixel */ +#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \ + ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ + (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ + (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ + (deltas)[6] = (step), (deltas)[7] = (step) + (nch)) + + +/** Contour approximation algorithms */ +enum +{ + CV_POLY_APPROX_DP = 0 +}; + +/** Shape matching methods */ +enum +{ + CV_CONTOURS_MATCH_I1 =1, //!< \f[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\f] + CV_CONTOURS_MATCH_I2 =2, //!< \f[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\f] + CV_CONTOURS_MATCH_I3 =3 //!< \f[I_3(A,B) = \max _{i=1...7} \frac{ \left| m^A_i - m^B_i \right| }{ \left| m^A_i \right| }\f] +}; + +/** Shape orientation */ +enum +{ + CV_CLOCKWISE =1, + CV_COUNTER_CLOCKWISE =2 +}; + + +/** Convexity defect */ +typedef struct CvConvexityDefect +{ + CvPoint* start; /**< point of the contour where the defect begins */ + CvPoint* end; /**< point of the contour where the defect ends */ + CvPoint* depth_point; /**< the farthest from the convex hull point within the defect */ + float depth; /**< distance between the farthest point and the convex hull */ +} CvConvexityDefect; + + +/** Histogram comparison methods */ +enum +{ + CV_COMP_CORREL =0, + CV_COMP_CHISQR =1, + CV_COMP_INTERSECT =2, + CV_COMP_BHATTACHARYYA =3, + CV_COMP_HELLINGER =CV_COMP_BHATTACHARYYA, + CV_COMP_CHISQR_ALT =4, + CV_COMP_KL_DIV =5 +}; + +/** Mask size for distance transform */ +enum +{ + CV_DIST_MASK_3 =3, + CV_DIST_MASK_5 =5, + CV_DIST_MASK_PRECISE =0 +}; + +/** Content of output label array: connected components or pixels */ +enum +{ + CV_DIST_LABEL_CCOMP = 0, + CV_DIST_LABEL_PIXEL = 1 +}; + +/** Distance types for Distance Transform and M-estimators */ +enum +{ + CV_DIST_USER =-1, /**< User defined distance */ + CV_DIST_L1 =1, /**< distance = |x1-x2| + |y1-y2| */ + CV_DIST_L2 =2, /**< the simple euclidean distance */ + CV_DIST_C =3, /**< distance = max(|x1-x2|,|y1-y2|) */ + CV_DIST_L12 =4, /**< L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */ + CV_DIST_FAIR =5, /**< distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */ + CV_DIST_WELSCH =6, /**< distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */ + CV_DIST_HUBER =7 /**< distance = |x| threshold ? max_value : 0 */ + CV_THRESH_BINARY_INV =1, /**< value = value > threshold ? 0 : max_value */ + CV_THRESH_TRUNC =2, /**< value = value > threshold ? threshold : value */ + CV_THRESH_TOZERO =3, /**< value = value > threshold ? value : 0 */ + CV_THRESH_TOZERO_INV =4, /**< value = value > threshold ? 0 : value */ + CV_THRESH_MASK =7, + CV_THRESH_OTSU =8, /**< use Otsu algorithm to choose the optimal threshold value; + combine the flag with one of the above CV_THRESH_* values */ + CV_THRESH_TRIANGLE =16 /**< use Triangle algorithm to choose the optimal threshold value; + combine the flag with one of the above CV_THRESH_* values, but not + with CV_THRESH_OTSU */ +}; + +/** Adaptive threshold methods */ +enum +{ + CV_ADAPTIVE_THRESH_MEAN_C =0, + CV_ADAPTIVE_THRESH_GAUSSIAN_C =1 +}; + +/** FloodFill flags */ +enum +{ + CV_FLOODFILL_FIXED_RANGE =(1 << 16), + CV_FLOODFILL_MASK_ONLY =(1 << 17) +}; + + +/** Canny edge detector flags */ +enum +{ + CV_CANNY_L2_GRADIENT =(1 << 31) +}; + +/** Variants of a Hough transform */ +enum +{ + CV_HOUGH_STANDARD =0, + CV_HOUGH_PROBABILISTIC =1, + CV_HOUGH_MULTI_SCALE =2, + CV_HOUGH_GRADIENT =3 +}; + + +/* Fast search data structures */ +struct CvFeatureTree; +struct CvLSH; +struct CvLSHOperations; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/ml.hpp b/Cigarette/OpenCV455Simple/include/opencv2/ml.hpp new file mode 100644 index 0000000..d537ab7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/ml.hpp @@ -0,0 +1,1956 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2014, Itseez Inc, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_ML_HPP +#define OPENCV_ML_HPP + +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif + +#ifdef __cplusplus + +#include +#include +#include + +/** + @defgroup ml Machine Learning + + The Machine Learning Library (MLL) is a set of classes and functions for statistical + classification, regression, and clustering of data. + + Most of the classification and regression algorithms are implemented as C++ classes. As the + algorithms have different sets of features (like an ability to handle missing measurements or + categorical input variables), there is a little common ground between the classes. This common + ground is defined by the class cv::ml::StatModel that all the other ML classes are derived from. + + See detailed overview here: @ref ml_intro. + */ + +namespace cv +{ + +namespace ml +{ + +//! @addtogroup ml +//! @{ + +/** @brief Variable types */ +enum VariableTypes +{ + VAR_NUMERICAL =0, //!< same as VAR_ORDERED + VAR_ORDERED =0, //!< ordered variables + VAR_CATEGORICAL =1 //!< categorical variables +}; + +/** @brief %Error types */ +enum ErrorTypes +{ + TEST_ERROR = 0, + TRAIN_ERROR = 1 +}; + +/** @brief Sample types */ +enum SampleTypes +{ + ROW_SAMPLE = 0, //!< each training sample is a row of samples + COL_SAMPLE = 1 //!< each training sample occupies a column of samples +}; + +/** @brief The structure represents the logarithmic grid range of statmodel parameters. + +It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate +being computed by cross-validation. + */ +class CV_EXPORTS_W ParamGrid +{ +public: + /** @brief Default constructor */ + ParamGrid(); + /** @brief Constructor with parameters */ + ParamGrid(double _minVal, double _maxVal, double _logStep); + + CV_PROP_RW double minVal; //!< Minimum value of the statmodel parameter. Default value is 0. + CV_PROP_RW double maxVal; //!< Maximum value of the statmodel parameter. Default value is 0. + /** @brief Logarithmic step for iterating the statmodel parameter. + + The grid determines the following iteration sequence of the statmodel parameter values: + \f[(minVal, minVal*step, minVal*{step}^2, \dots, minVal*{logStep}^n),\f] + where \f$n\f$ is the maximal index satisfying + \f[\texttt{minVal} * \texttt{logStep} ^n < \texttt{maxVal}\f] + The grid is logarithmic, so logStep must always be greater than 1. Default value is 1. + */ + CV_PROP_RW double logStep; + + /** @brief Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method + + @param minVal minimum value of the parameter grid + @param maxVal maximum value of the parameter grid + @param logstep Logarithmic step for iterating the statmodel parameter + */ + CV_WRAP static Ptr create(double minVal=0., double maxVal=0., double logstep=1.); +}; + +/** @brief Class encapsulating training data. + +Please note that the class only specifies the interface of training data, but not implementation. +All the statistical model classes in _ml_ module accepts Ptr\ as parameter. In other +words, you can create your own class derived from TrainData and pass smart pointer to the instance +of this class into StatModel::train. + +@sa @ref ml_intro_data + */ +class CV_EXPORTS_W TrainData +{ +public: + static inline float missingValue() { return FLT_MAX; } + virtual ~TrainData(); + + CV_WRAP virtual int getLayout() const = 0; + CV_WRAP virtual int getNTrainSamples() const = 0; + CV_WRAP virtual int getNTestSamples() const = 0; + CV_WRAP virtual int getNSamples() const = 0; + CV_WRAP virtual int getNVars() const = 0; + CV_WRAP virtual int getNAllVars() const = 0; + + CV_WRAP virtual void getSample(InputArray varIdx, int sidx, float* buf) const = 0; + CV_WRAP virtual Mat getSamples() const = 0; + CV_WRAP virtual Mat getMissing() const = 0; + + /** @brief Returns matrix of train samples + + @param layout The requested layout. If it's different from the initial one, the matrix is + transposed. See ml::SampleTypes. + @param compressSamples if true, the function returns only the training samples (specified by + sampleIdx) + @param compressVars if true, the function returns the shorter training samples, containing only + the active variables. + + In current implementation the function tries to avoid physical data copying and returns the + matrix stored inside TrainData (unless the transposition or compression is needed). + */ + CV_WRAP virtual Mat getTrainSamples(int layout=ROW_SAMPLE, + bool compressSamples=true, + bool compressVars=true) const = 0; + + /** @brief Returns the vector of responses + + The function returns ordered or the original categorical responses. Usually it's used in + regression algorithms. + */ + CV_WRAP virtual Mat getTrainResponses() const = 0; + + /** @brief Returns the vector of normalized categorical responses + + The function returns vector of responses. Each response is integer from `0` to `-1`. The actual label value can be retrieved then from the class label vector, see + TrainData::getClassLabels. + */ + CV_WRAP virtual Mat getTrainNormCatResponses() const = 0; + CV_WRAP virtual Mat getTestResponses() const = 0; + CV_WRAP virtual Mat getTestNormCatResponses() const = 0; + CV_WRAP virtual Mat getResponses() const = 0; + CV_WRAP virtual Mat getNormCatResponses() const = 0; + CV_WRAP virtual Mat getSampleWeights() const = 0; + CV_WRAP virtual Mat getTrainSampleWeights() const = 0; + CV_WRAP virtual Mat getTestSampleWeights() const = 0; + CV_WRAP virtual Mat getVarIdx() const = 0; + CV_WRAP virtual Mat getVarType() const = 0; + CV_WRAP virtual Mat getVarSymbolFlags() const = 0; + CV_WRAP virtual int getResponseType() const = 0; + CV_WRAP virtual Mat getTrainSampleIdx() const = 0; + CV_WRAP virtual Mat getTestSampleIdx() const = 0; + CV_WRAP virtual void getValues(int vi, InputArray sidx, float* values) const = 0; + virtual void getNormCatValues(int vi, InputArray sidx, int* values) const = 0; + CV_WRAP virtual Mat getDefaultSubstValues() const = 0; + + CV_WRAP virtual int getCatCount(int vi) const = 0; + + /** @brief Returns the vector of class labels + + The function returns vector of unique labels occurred in the responses. + */ + CV_WRAP virtual Mat getClassLabels() const = 0; + + CV_WRAP virtual Mat getCatOfs() const = 0; + CV_WRAP virtual Mat getCatMap() const = 0; + + /** @brief Splits the training data into the training and test parts + @sa TrainData::setTrainTestSplitRatio + */ + CV_WRAP virtual void setTrainTestSplit(int count, bool shuffle=true) = 0; + + /** @brief Splits the training data into the training and test parts + + The function selects a subset of specified relative size and then returns it as the training + set. If the function is not called, all the data is used for training. Please, note that for + each of TrainData::getTrain\* there is corresponding TrainData::getTest\*, so that the test + subset can be retrieved and processed as well. + @sa TrainData::setTrainTestSplit + */ + CV_WRAP virtual void setTrainTestSplitRatio(double ratio, bool shuffle=true) = 0; + CV_WRAP virtual void shuffleTrainTest() = 0; + + /** @brief Returns matrix of test samples */ + CV_WRAP virtual Mat getTestSamples() const = 0; + + /** @brief Returns vector of symbolic names captured in loadFromCSV() */ + CV_WRAP virtual void getNames(std::vector& names) const = 0; + + /** @brief Extract from 1D vector elements specified by passed indexes. + @param vec input vector (supported types: CV_32S, CV_32F, CV_64F) + @param idx 1D index vector + */ + static CV_WRAP Mat getSubVector(const Mat& vec, const Mat& idx); + + /** @brief Extract from matrix rows/cols specified by passed indexes. + @param matrix input matrix (supported types: CV_32S, CV_32F, CV_64F) + @param idx 1D index vector + @param layout specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES) + */ + static CV_WRAP Mat getSubMatrix(const Mat& matrix, const Mat& idx, int layout); + + /** @brief Reads the dataset from a .csv file and returns the ready-to-use training data. + + @param filename The input file name + @param headerLineCount The number of lines in the beginning to skip; besides the header, the + function also skips empty lines and lines staring with `#` + @param responseStartIdx Index of the first output variable. If -1, the function considers the + last variable as the response + @param responseEndIdx Index of the last output variable + 1. If -1, then there is single + response variable at responseStartIdx. + @param varTypeSpec The optional text string that specifies the variables' types. It has the + format `ord[n1-n2,n3,n4-n5,...]cat[n6,n7-n8,...]`. That is, variables from `n1 to n2` + (inclusive range), `n3`, `n4 to n5` ... are considered ordered and `n6`, `n7 to n8` ... are + considered as categorical. The range `[n1..n2] + [n3] + [n4..n5] + ... + [n6] + [n7..n8]` + should cover all the variables. If varTypeSpec is not specified, then algorithm uses the + following rules: + - all input variables are considered ordered by default. If some column contains has non- + numerical values, e.g. 'apple', 'pear', 'apple', 'apple', 'mango', the corresponding + variable is considered categorical. + - if there are several output variables, they are all considered as ordered. Error is + reported when non-numerical values are used. + - if there is a single output variable, then if its values are non-numerical or are all + integers, then it's considered categorical. Otherwise, it's considered ordered. + @param delimiter The character used to separate values in each line. + @param missch The character used to specify missing measurements. It should not be a digit. + Although it's a non-numerical value, it surely does not affect the decision of whether the + variable ordered or categorical. + @note If the dataset only contains input variables and no responses, use responseStartIdx = -2 + and responseEndIdx = 0. The output variables vector will just contain zeros. + */ + static Ptr loadFromCSV(const String& filename, + int headerLineCount, + int responseStartIdx=-1, + int responseEndIdx=-1, + const String& varTypeSpec=String(), + char delimiter=',', + char missch='?'); + + /** @brief Creates training data from in-memory arrays. + + @param samples matrix of samples. It should have CV_32F type. + @param layout see ml::SampleTypes. + @param responses matrix of responses. If the responses are scalar, they should be stored as a + single row or as a single column. The matrix should have type CV_32F or CV_32S (in the + former case the responses are considered as ordered by default; in the latter case - as + categorical) + @param varIdx vector specifying which variables to use for training. It can be an integer vector + (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of + active variables. + @param sampleIdx vector specifying which samples to use for training. It can be an integer + vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask + of training samples. + @param sampleWeights optional vector with weights for each sample. It should have CV_32F type. + @param varType optional vector of type CV_8U and size ` + + `, containing types of each input and output variable. See + ml::VariableTypes. + */ + CV_WRAP static Ptr create(InputArray samples, int layout, InputArray responses, + InputArray varIdx=noArray(), InputArray sampleIdx=noArray(), + InputArray sampleWeights=noArray(), InputArray varType=noArray()); +}; + +/** @brief Base class for statistical models in OpenCV ML. + */ +class CV_EXPORTS_W StatModel : public Algorithm +{ +public: + /** Predict options */ + enum Flags { + UPDATE_MODEL = 1, + RAW_OUTPUT=1, //!< makes the method return the raw results (the sum), not the class label + COMPRESSED_INPUT=2, + PREPROCESSED_INPUT=4 + }; + + /** @brief Returns the number of variables in training samples */ + CV_WRAP virtual int getVarCount() const = 0; + + CV_WRAP virtual bool empty() const CV_OVERRIDE; + + /** @brief Returns true if the model is trained */ + CV_WRAP virtual bool isTrained() const = 0; + /** @brief Returns true if the model is classifier */ + CV_WRAP virtual bool isClassifier() const = 0; + + /** @brief Trains the statistical model + + @param trainData training data that can be loaded from file using TrainData::loadFromCSV or + created with TrainData::create. + @param flags optional flags, depending on the model. Some of the models can be updated with the + new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP). + */ + CV_WRAP virtual bool train( const Ptr& trainData, int flags=0 ); + + /** @brief Trains the statistical model + + @param samples training samples + @param layout See ml::SampleTypes. + @param responses vector of responses associated with the training samples. + */ + CV_WRAP virtual bool train( InputArray samples, int layout, InputArray responses ); + + /** @brief Computes error on the training or test dataset + + @param data the training data + @param test if true, the error is computed over the test subset of the data, otherwise it's + computed over the training subset of the data. Please note that if you loaded a completely + different dataset to evaluate already trained classifier, you will probably want not to set + the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so + that the error is computed for the whole new set. Yes, this sounds a bit confusing. + @param resp the optional output responses. + + The method uses StatModel::predict to compute the error. For regression models the error is + computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%). + */ + CV_WRAP virtual float calcError( const Ptr& data, bool test, OutputArray resp ) const; + + /** @brief Predicts response(s) for the provided sample(s) + + @param samples The input samples, floating-point matrix + @param results The optional output matrix of results. + @param flags The optional flags, model-dependent. See cv::ml::StatModel::Flags. + */ + CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const = 0; + + /** @brief Create and train model with default parameters + + The class must implement static `create()` method with no parameters or with all default parameter values + */ + template static Ptr<_Tp> train(const Ptr& data, int flags=0) + { + Ptr<_Tp> model = _Tp::create(); + return !model.empty() && model->train(data, flags) ? model : Ptr<_Tp>(); + } +}; + +/****************************************************************************************\ +* Normal Bayes Classifier * +\****************************************************************************************/ + +/** @brief Bayes classifier for normally distributed data. + +@sa @ref ml_intro_bayes + */ +class CV_EXPORTS_W NormalBayesClassifier : public StatModel +{ +public: + /** @brief Predicts the response for sample(s). + + The method estimates the most probable classes for input vectors. Input vectors (one or more) + are stored as rows of the matrix inputs. In case of multiple input vectors, there should be one + output vector outputs. The predicted class for a single input vector is returned by the method. + The vector outputProbs contains the output probabilities corresponding to each element of + result. + */ + CV_WRAP virtual float predictProb( InputArray inputs, OutputArray outputs, + OutputArray outputProbs, int flags=0 ) const = 0; + + /** Creates empty model + Use StatModel::train to train the model after creation. */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized NormalBayesClassifier from a file + * + * Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. + * Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized NormalBayesClassifier + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* K-Nearest Neighbour Classifier * +\****************************************************************************************/ + +/** @brief The class implements K-Nearest Neighbors model + +@sa @ref ml_intro_knn + */ +class CV_EXPORTS_W KNearest : public StatModel +{ +public: + + /** Default number of neighbors to use in predict method. */ + /** @see setDefaultK */ + CV_WRAP virtual int getDefaultK() const = 0; + /** @copybrief getDefaultK @see getDefaultK */ + CV_WRAP virtual void setDefaultK(int val) = 0; + + /** Whether classification or regression model should be trained. */ + /** @see setIsClassifier */ + CV_WRAP virtual bool getIsClassifier() const = 0; + /** @copybrief getIsClassifier @see getIsClassifier */ + CV_WRAP virtual void setIsClassifier(bool val) = 0; + + /** Parameter for KDTree implementation. */ + /** @see setEmax */ + CV_WRAP virtual int getEmax() const = 0; + /** @copybrief getEmax @see getEmax */ + CV_WRAP virtual void setEmax(int val) = 0; + + /** %Algorithm type, one of KNearest::Types. */ + /** @see setAlgorithmType */ + CV_WRAP virtual int getAlgorithmType() const = 0; + /** @copybrief getAlgorithmType @see getAlgorithmType */ + CV_WRAP virtual void setAlgorithmType(int val) = 0; + + /** @brief Finds the neighbors and predicts responses for input vectors. + + @param samples Input samples stored by rows. It is a single-precision floating-point matrix of + ` * k` size. + @param k Number of used nearest neighbors. Should be greater than 1. + @param results Vector with results of prediction (regression or classification) for each input + sample. It is a single-precision floating-point vector with `` elements. + @param neighborResponses Optional output values for corresponding neighbors. It is a single- + precision floating-point matrix of ` * k` size. + @param dist Optional output distances from the input vectors to the corresponding neighbors. It + is a single-precision floating-point matrix of ` * k` size. + + For each input vector (a row of the matrix samples), the method finds the k nearest neighbors. + In case of regression, the predicted result is a mean value of the particular vector's neighbor + responses. In case of classification, the class is determined by voting. + + For each input vector, the neighbors are sorted by their distances to the vector. + + In case of C++ interface you can use output pointers to empty matrices and the function will + allocate memory itself. + + If only a single input vector is passed, all output matrices are optional and the predicted + value is returned by the method. + + The function is parallelized with the TBB library. + */ + CV_WRAP virtual float findNearest( InputArray samples, int k, + OutputArray results, + OutputArray neighborResponses=noArray(), + OutputArray dist=noArray() ) const = 0; + + /** @brief Implementations of KNearest algorithm + */ + enum Types + { + BRUTE_FORCE=1, + KDTREE=2 + }; + + /** @brief Creates the empty model + + The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method. + */ + CV_WRAP static Ptr create(); + /** @brief Loads and creates a serialized knearest from a file + * + * Use KNearest::save to serialize and store an KNearest to disk. + * Load the KNearest from this file again, by calling this function with the path to the file. + * + * @param filepath path to serialized KNearest + */ + CV_WRAP static Ptr load(const String& filepath); +}; + +/****************************************************************************************\ +* Support Vector Machines * +\****************************************************************************************/ + +/** @brief Support Vector Machines. + +@sa @ref ml_intro_svm + */ +class CV_EXPORTS_W SVM : public StatModel +{ +public: + + class CV_EXPORTS Kernel : public Algorithm + { + public: + virtual int getType() const = 0; + virtual void calc( int vcount, int n, const float* vecs, const float* another, float* results ) = 0; + }; + + /** Type of a %SVM formulation. + See SVM::Types. Default value is SVM::C_SVC. */ + /** @see setType */ + CV_WRAP virtual int getType() const = 0; + /** @copybrief getType @see getType */ + CV_WRAP virtual void setType(int val) = 0; + + /** Parameter \f$\gamma\f$ of a kernel function. + For SVM::POLY, SVM::RBF, SVM::SIGMOID or SVM::CHI2. Default value is 1. */ + /** @see setGamma */ + CV_WRAP virtual double getGamma() const = 0; + /** @copybrief getGamma @see getGamma */ + CV_WRAP virtual void setGamma(double val) = 0; + + /** Parameter _coef0_ of a kernel function. + For SVM::POLY or SVM::SIGMOID. Default value is 0.*/ + /** @see setCoef0 */ + CV_WRAP virtual double getCoef0() const = 0; + /** @copybrief getCoef0 @see getCoef0 */ + CV_WRAP virtual void setCoef0(double val) = 0; + + /** Parameter _degree_ of a kernel function. + For SVM::POLY. Default value is 0. */ + /** @see setDegree */ + CV_WRAP virtual double getDegree() const = 0; + /** @copybrief getDegree @see getDegree */ + CV_WRAP virtual void setDegree(double val) = 0; + + /** Parameter _C_ of a %SVM optimization problem. + For SVM::C_SVC, SVM::EPS_SVR or SVM::NU_SVR. Default value is 0. */ + /** @see setC */ + CV_WRAP virtual double getC() const = 0; + /** @copybrief getC @see getC */ + CV_WRAP virtual void setC(double val) = 0; + + /** Parameter \f$\nu\f$ of a %SVM optimization problem. + For SVM::NU_SVC, SVM::ONE_CLASS or SVM::NU_SVR. Default value is 0. */ + /** @see setNu */ + CV_WRAP virtual double getNu() const = 0; + /** @copybrief getNu @see getNu */ + CV_WRAP virtual void setNu(double val) = 0; + + /** Parameter \f$\epsilon\f$ of a %SVM optimization problem. + For SVM::EPS_SVR. Default value is 0. */ + /** @see setP */ + CV_WRAP virtual double getP() const = 0; + /** @copybrief getP @see getP */ + CV_WRAP virtual void setP(double val) = 0; + + /** Optional weights in the SVM::C_SVC problem, assigned to particular classes. + They are multiplied by _C_ so the parameter _C_ of class _i_ becomes `classWeights(i) * C`. Thus + these weights affect the misclassification penalty for different classes. The larger weight, + the larger penalty on misclassification of data from the corresponding class. Default value is + empty Mat. */ + /** @see setClassWeights */ + CV_WRAP virtual cv::Mat getClassWeights() const = 0; + /** @copybrief getClassWeights @see getClassWeights */ + CV_WRAP virtual void setClassWeights(const cv::Mat &val) = 0; + + /** Termination criteria of the iterative %SVM training procedure which solves a partial + case of constrained quadratic optimization problem. + You can specify tolerance and/or the maximum number of iterations. Default value is + `TermCriteria( TermCriteria::MAX_ITER + TermCriteria::EPS, 1000, FLT_EPSILON )`; */ + /** @see setTermCriteria */ + CV_WRAP virtual cv::TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const cv::TermCriteria &val) = 0; + + /** Type of a %SVM kernel. + See SVM::KernelTypes. Default value is SVM::RBF. */ + CV_WRAP virtual int getKernelType() const = 0; + + /** Initialize with one of predefined kernels. + See SVM::KernelTypes. */ + CV_WRAP virtual void setKernel(int kernelType) = 0; + + /** Initialize with custom kernel. + See SVM::Kernel class for implementation details */ + virtual void setCustomKernel(const Ptr &_kernel) = 0; + + //! %SVM type + enum Types { + /** C-Support Vector Classification. n-class classification (n \f$\geq\f$ 2), allows + imperfect separation of classes with penalty multiplier C for outliers. */ + C_SVC=100, + /** \f$\nu\f$-Support Vector Classification. n-class classification with possible + imperfect separation. Parameter \f$\nu\f$ (in the range 0..1, the larger the value, the smoother + the decision boundary) is used instead of C. */ + NU_SVC=101, + /** Distribution Estimation (One-class %SVM). All the training data are from + the same class, %SVM builds a boundary that separates the class from the rest of the feature + space. */ + ONE_CLASS=102, + /** \f$\epsilon\f$-Support Vector Regression. The distance between feature vectors + from the training set and the fitting hyper-plane must be less than p. For outliers the + penalty multiplier C is used. */ + EPS_SVR=103, + /** \f$\nu\f$-Support Vector Regression. \f$\nu\f$ is used instead of p. + See @cite LibSVM for details. */ + NU_SVR=104 + }; + + /** @brief %SVM kernel type + + A comparison of different kernels on the following 2D test case with four classes. Four + SVM::C_SVC SVMs have been trained (one against rest) with auto_train. Evaluation on three + different kernels (SVM::CHI2, SVM::INTER, SVM::RBF). The color depicts the class with max score. + Bright means max-score \> 0, dark means max-score \< 0. + ![image](pics/SVM_Comparison.png) + */ + enum KernelTypes { + /** Returned by SVM::getKernelType in case when custom kernel has been set */ + CUSTOM=-1, + /** Linear kernel. No mapping is done, linear discrimination (or regression) is + done in the original feature space. It is the fastest option. \f$K(x_i, x_j) = x_i^T x_j\f$. */ + LINEAR=0, + /** Polynomial kernel: + \f$K(x_i, x_j) = (\gamma x_i^T x_j + coef0)^{degree}, \gamma > 0\f$. */ + POLY=1, + /** Radial basis function (RBF), a good choice in most cases. + \f$K(x_i, x_j) = e^{-\gamma ||x_i - x_j||^2}, \gamma > 0\f$. */ + RBF=2, + /** Sigmoid kernel: \f$K(x_i, x_j) = \tanh(\gamma x_i^T x_j + coef0)\f$. */ + SIGMOID=3, + /** Exponential Chi2 kernel, similar to the RBF kernel: + \f$K(x_i, x_j) = e^{-\gamma \chi^2(x_i,x_j)}, \chi^2(x_i,x_j) = (x_i-x_j)^2/(x_i+x_j), \gamma > 0\f$. */ + CHI2=4, + /** Histogram intersection kernel. A fast kernel. \f$K(x_i, x_j) = min(x_i,x_j)\f$. */ + INTER=5 + }; + + //! %SVM params type + enum ParamTypes { + C=0, + GAMMA=1, + P=2, + NU=3, + COEF=4, + DEGREE=5 + }; + + /** @brief Trains an %SVM with optimal parameters. + + @param data the training data that can be constructed using TrainData::create or + TrainData::loadFromCSV. + @param kFold Cross-validation parameter. The training set is divided into kFold subsets. One + subset is used to test the model, the others form the train set. So, the %SVM algorithm is + executed kFold times. + @param Cgrid grid for C + @param gammaGrid grid for gamma + @param pGrid grid for p + @param nuGrid grid for nu + @param coeffGrid grid for coeff + @param degreeGrid grid for degree + @param balanced If true and the problem is 2-class classification then the method creates more + balanced cross-validation subsets that is proportions between classes in subsets are close + to such proportion in the whole train dataset. + + The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p, + nu, coef0, degree. Parameters are considered optimal when the cross-validation + estimate of the test set error is minimal. + + If there is no need to optimize a parameter, the corresponding grid step should be set to any + value less than or equal to 1. For example, to avoid optimization in gamma, set `gammaGrid.step + = 0`, `gammaGrid.minVal`, `gamma_grid.maxVal` as arbitrary numbers. In this case, the value + `Gamma` is taken for gamma. + + And, finally, if the optimization in a parameter is required but the corresponding grid is + unknown, you may call the function SVM::getDefaultGrid. To generate a grid, for example, for + gamma, call `SVM::getDefaultGrid(SVM::GAMMA)`. + + This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the + regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and + the usual %SVM with parameters specified in params is executed. + */ + virtual bool trainAuto( const Ptr& data, int kFold = 10, + ParamGrid Cgrid = getDefaultGrid(C), + ParamGrid gammaGrid = getDefaultGrid(GAMMA), + ParamGrid pGrid = getDefaultGrid(P), + ParamGrid nuGrid = getDefaultGrid(NU), + ParamGrid coeffGrid = getDefaultGrid(COEF), + ParamGrid degreeGrid = getDefaultGrid(DEGREE), + bool balanced=false) = 0; + + /** @brief Trains an %SVM with optimal parameters + + @param samples training samples + @param layout See ml::SampleTypes. + @param responses vector of responses associated with the training samples. + @param kFold Cross-validation parameter. The training set is divided into kFold subsets. One + subset is used to test the model, the others form the train set. So, the %SVM algorithm is + @param Cgrid grid for C + @param gammaGrid grid for gamma + @param pGrid grid for p + @param nuGrid grid for nu + @param coeffGrid grid for coeff + @param degreeGrid grid for degree + @param balanced If true and the problem is 2-class classification then the method creates more + balanced cross-validation subsets that is proportions between classes in subsets are close + to such proportion in the whole train dataset. + + The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p, + nu, coef0, degree. Parameters are considered optimal when the cross-validation + estimate of the test set error is minimal. + + This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only + offers rudimentary parameter options. + + This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the + regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and + the usual %SVM with parameters specified in params is executed. + */ + CV_WRAP virtual bool trainAuto(InputArray samples, + int layout, + InputArray responses, + int kFold = 10, + Ptr Cgrid = SVM::getDefaultGridPtr(SVM::C), + Ptr gammaGrid = SVM::getDefaultGridPtr(SVM::GAMMA), + Ptr pGrid = SVM::getDefaultGridPtr(SVM::P), + Ptr nuGrid = SVM::getDefaultGridPtr(SVM::NU), + Ptr coeffGrid = SVM::getDefaultGridPtr(SVM::COEF), + Ptr degreeGrid = SVM::getDefaultGridPtr(SVM::DEGREE), + bool balanced=false) = 0; + + /** @brief Retrieves all the support vectors + + The method returns all the support vectors as a floating-point matrix, where support vectors are + stored as matrix rows. + */ + CV_WRAP virtual Mat getSupportVectors() const = 0; + + /** @brief Retrieves all the uncompressed support vectors of a linear %SVM + + The method returns all the uncompressed support vectors of a linear %SVM that the compressed + support vector, used for prediction, was derived from. They are returned in a floating-point + matrix, where the support vectors are stored as matrix rows. + */ + CV_WRAP virtual Mat getUncompressedSupportVectors() const = 0; + + /** @brief Retrieves the decision function + + @param i the index of the decision function. If the problem solved is regression, 1-class or + 2-class classification, then there will be just one decision function and the index should + always be 0. Otherwise, in the case of N-class classification, there will be \f$N(N-1)/2\f$ + decision functions. + @param alpha the optional output vector for weights, corresponding to different support vectors. + In the case of linear %SVM all the alpha's will be 1's. + @param svidx the optional output vector of indices of support vectors within the matrix of + support vectors (which can be retrieved by SVM::getSupportVectors). In the case of linear + %SVM each decision function consists of a single "compressed" support vector. + + The method returns rho parameter of the decision function, a scalar subtracted from the weighted + sum of kernel responses. + */ + CV_WRAP virtual double getDecisionFunction(int i, OutputArray alpha, OutputArray svidx) const = 0; + + /** @brief Generates a grid for %SVM parameters. + + @param param_id %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is + generated for the parameter with this ID. + + The function generates a grid for the specified parameter of the %SVM algorithm. The grid may be + passed to the function SVM::trainAuto. + */ + static ParamGrid getDefaultGrid( int param_id ); + + /** @brief Generates a grid for %SVM parameters. + + @param param_id %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is + generated for the parameter with this ID. + + The function generates a grid pointer for the specified parameter of the %SVM algorithm. + The grid may be passed to the function SVM::trainAuto. + */ + CV_WRAP static Ptr getDefaultGridPtr( int param_id ); + + /** Creates empty model. + Use StatModel::train to train the model. Since %SVM has several parameters, you may want to + find the best parameters for your problem, it can be done with SVM::trainAuto. */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized svm from a file + * + * Use SVM::save to serialize and store an SVM to disk. + * Load the SVM from this file again, by calling this function with the path to the file. + * + * @param filepath path to serialized svm + */ + CV_WRAP static Ptr load(const String& filepath); +}; + +/****************************************************************************************\ +* Expectation - Maximization * +\****************************************************************************************/ + +/** @brief The class implements the Expectation Maximization algorithm. + +@sa @ref ml_intro_em + */ +class CV_EXPORTS_W EM : public StatModel +{ +public: + //! Type of covariation matrices + enum Types { + /** A scaled identity matrix \f$\mu_k * I\f$. There is the only + parameter \f$\mu_k\f$ to be estimated for each matrix. The option may be used in special cases, + when the constraint is relevant, or as a first step in the optimization (for example in case + when the data is preprocessed with PCA). The results of such preliminary estimation may be + passed again to the optimization procedure, this time with + covMatType=EM::COV_MAT_DIAGONAL. */ + COV_MAT_SPHERICAL=0, + /** A diagonal matrix with positive diagonal elements. The number of + free parameters is d for each matrix. This is most commonly used option yielding good + estimation results. */ + COV_MAT_DIAGONAL=1, + /** A symmetric positively defined matrix. The number of free + parameters in each matrix is about \f$d^2/2\f$. It is not recommended to use this option, unless + there is pretty accurate initial estimation of the parameters and/or a huge number of + training samples. */ + COV_MAT_GENERIC=2, + COV_MAT_DEFAULT=COV_MAT_DIAGONAL + }; + + //! Default parameters + enum {DEFAULT_NCLUSTERS=5, DEFAULT_MAX_ITERS=100}; + + //! The initial step + enum {START_E_STEP=1, START_M_STEP=2, START_AUTO_STEP=0}; + + /** The number of mixture components in the Gaussian mixture model. + Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could + determine the optimal number of mixtures within a specified value range, but that is not the + case in ML yet. */ + /** @see setClustersNumber */ + CV_WRAP virtual int getClustersNumber() const = 0; + /** @copybrief getClustersNumber @see getClustersNumber */ + CV_WRAP virtual void setClustersNumber(int val) = 0; + + /** Constraint on covariance matrices which defines type of matrices. + See EM::Types. */ + /** @see setCovarianceMatrixType */ + CV_WRAP virtual int getCovarianceMatrixType() const = 0; + /** @copybrief getCovarianceMatrixType @see getCovarianceMatrixType */ + CV_WRAP virtual void setCovarianceMatrixType(int val) = 0; + + /** The termination criteria of the %EM algorithm. + The %EM algorithm can be terminated by the number of iterations termCrit.maxCount (number of + M-steps) or when relative change of likelihood logarithm is less than termCrit.epsilon. Default + maximum number of iterations is EM::DEFAULT_MAX_ITERS=100. */ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const TermCriteria &val) = 0; + + /** @brief Returns weights of the mixtures + + Returns vector with the number of elements equal to the number of mixtures. + */ + CV_WRAP virtual Mat getWeights() const = 0; + /** @brief Returns the cluster centers (means of the Gaussian mixture) + + Returns matrix with the number of rows equal to the number of mixtures and number of columns + equal to the space dimensionality. + */ + CV_WRAP virtual Mat getMeans() const = 0; + /** @brief Returns covariation matrices + + Returns vector of covariation matrices. Number of matrices is the number of gaussian mixtures, + each matrix is a square floating-point matrix NxN, where N is the space dimensionality. + */ + CV_WRAP virtual void getCovs(CV_OUT std::vector& covs) const = 0; + + /** @brief Returns posterior probabilities for the provided samples + + @param samples The input samples, floating-point matrix + @param results The optional output \f$ nSamples \times nClusters\f$ matrix of results. It contains + posterior probabilities for each sample from the input + @param flags This parameter will be ignored + */ + CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const CV_OVERRIDE = 0; + + /** @brief Returns a likelihood logarithm value and an index of the most probable mixture component + for the given sample. + + @param sample A sample for classification. It should be a one-channel matrix of + \f$1 \times dims\f$ or \f$dims \times 1\f$ size. + @param probs Optional output matrix that contains posterior probabilities of each component + given the sample. It has \f$1 \times nclusters\f$ size and CV_64FC1 type. + + The method returns a two-element double vector. Zero element is a likelihood logarithm value for + the sample. First element is an index of the most probable mixture component for the given + sample. + */ + CV_WRAP virtual Vec2d predict2(InputArray sample, OutputArray probs) const = 0; + + /** @brief Estimate the Gaussian mixture parameters from a samples set. + + This variation starts with Expectation step. Initial values of the model parameters will be + estimated by the k-means algorithm. + + Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take + responses (class labels or function values) as input. Instead, it computes the *Maximum + Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the + parameters inside the structure: \f$p_{i,k}\f$ in probs, \f$a_k\f$ in means , \f$S_k\f$ in + covs[k], \f$\pi_k\f$ in weights , and optionally computes the output "class label" for each + sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most + probable mixture component for each sample). + + The trained model can be used further for prediction, just like any other classifier. The + trained model is similar to the NormalBayesClassifier. + + @param samples Samples from which the Gaussian mixture model will be estimated. It should be a + one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type + it will be converted to the inner matrix of such type for the further computing. + @param logLikelihoods The optional output matrix that contains a likelihood logarithm value for + each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type. + @param labels The optional output "class label" for each sample: + \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable + mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type. + @param probs The optional output matrix that contains posterior probabilities of each Gaussian + mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and + CV_64FC1 type. + */ + CV_WRAP virtual bool trainEM(InputArray samples, + OutputArray logLikelihoods=noArray(), + OutputArray labels=noArray(), + OutputArray probs=noArray()) = 0; + + /** @brief Estimate the Gaussian mixture parameters from a samples set. + + This variation starts with Expectation step. You need to provide initial means \f$a_k\f$ of + mixture components. Optionally you can pass initial weights \f$\pi_k\f$ and covariance matrices + \f$S_k\f$ of mixture components. + + @param samples Samples from which the Gaussian mixture model will be estimated. It should be a + one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type + it will be converted to the inner matrix of such type for the further computing. + @param means0 Initial means \f$a_k\f$ of mixture components. It is a one-channel matrix of + \f$nclusters \times dims\f$ size. If the matrix does not have CV_64F type it will be + converted to the inner matrix of such type for the further computing. + @param covs0 The vector of initial covariance matrices \f$S_k\f$ of mixture components. Each of + covariance matrices is a one-channel matrix of \f$dims \times dims\f$ size. If the matrices + do not have CV_64F type they will be converted to the inner matrices of such type for the + further computing. + @param weights0 Initial weights \f$\pi_k\f$ of mixture components. It should be a one-channel + floating-point matrix with \f$1 \times nclusters\f$ or \f$nclusters \times 1\f$ size. + @param logLikelihoods The optional output matrix that contains a likelihood logarithm value for + each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type. + @param labels The optional output "class label" for each sample: + \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable + mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type. + @param probs The optional output matrix that contains posterior probabilities of each Gaussian + mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and + CV_64FC1 type. + */ + CV_WRAP virtual bool trainE(InputArray samples, InputArray means0, + InputArray covs0=noArray(), + InputArray weights0=noArray(), + OutputArray logLikelihoods=noArray(), + OutputArray labels=noArray(), + OutputArray probs=noArray()) = 0; + + /** @brief Estimate the Gaussian mixture parameters from a samples set. + + This variation starts with Maximization step. You need to provide initial probabilities + \f$p_{i,k}\f$ to use this option. + + @param samples Samples from which the Gaussian mixture model will be estimated. It should be a + one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type + it will be converted to the inner matrix of such type for the further computing. + @param probs0 the probabilities + @param logLikelihoods The optional output matrix that contains a likelihood logarithm value for + each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type. + @param labels The optional output "class label" for each sample: + \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable + mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type. + @param probs The optional output matrix that contains posterior probabilities of each Gaussian + mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and + CV_64FC1 type. + */ + CV_WRAP virtual bool trainM(InputArray samples, InputArray probs0, + OutputArray logLikelihoods=noArray(), + OutputArray labels=noArray(), + OutputArray probs=noArray()) = 0; + + /** Creates empty %EM model. + The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you + can use one of the EM::train\* methods or load it from file using Algorithm::load\(filename). + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized EM from a file + * + * Use EM::save to serialize and store an EM to disk. + * Load the EM from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized EM + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Decision Tree * +\****************************************************************************************/ + +/** @brief The class represents a single decision tree or a collection of decision trees. + +The current public interface of the class allows user to train only a single decision tree, however +the class is capable of storing multiple decision trees and using them for prediction (by summing +responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost) +use this capability to implement decision tree ensembles. + +@sa @ref ml_intro_trees +*/ +class CV_EXPORTS_W DTrees : public StatModel +{ +public: + /** Predict options */ + enum Flags { PREDICT_AUTO=0, PREDICT_SUM=(1<<8), PREDICT_MAX_VOTE=(2<<8), PREDICT_MASK=(3<<8) }; + + /** Cluster possible values of a categorical variable into K\<=maxCategories clusters to + find a suboptimal split. + If a discrete variable, on which the training procedure tries to make a split, takes more than + maxCategories values, the precise best subset estimation may take a very long time because the + algorithm is exponential. Instead, many decision trees engines (including our implementation) + try to find sub-optimal split in this case by clustering all the samples into maxCategories + clusters that is some categories are merged together. The clustering is applied only in n \> + 2-class classification problems for categorical variables with N \> max_categories possible + values. In case of regression and 2-class classification the optimal split can be found + efficiently without employing clustering, thus the parameter is not used in these cases. + Default value is 10.*/ + /** @see setMaxCategories */ + CV_WRAP virtual int getMaxCategories() const = 0; + /** @copybrief getMaxCategories @see getMaxCategories */ + CV_WRAP virtual void setMaxCategories(int val) = 0; + + /** The maximum possible depth of the tree. + That is the training algorithms attempts to split a node while its depth is less than maxDepth. + The root node has zero depth. The actual depth may be smaller if the other termination criteria + are met (see the outline of the training procedure @ref ml_intro_trees "here"), and/or if the + tree is pruned. Default value is INT_MAX.*/ + /** @see setMaxDepth */ + CV_WRAP virtual int getMaxDepth() const = 0; + /** @copybrief getMaxDepth @see getMaxDepth */ + CV_WRAP virtual void setMaxDepth(int val) = 0; + + /** If the number of samples in a node is less than this parameter then the node will not be split. + + Default value is 10.*/ + /** @see setMinSampleCount */ + CV_WRAP virtual int getMinSampleCount() const = 0; + /** @copybrief getMinSampleCount @see getMinSampleCount */ + CV_WRAP virtual void setMinSampleCount(int val) = 0; + + /** If CVFolds \> 1 then algorithms prunes the built decision tree using K-fold + cross-validation procedure where K is equal to CVFolds. + Default value is 10.*/ + /** @see setCVFolds */ + CV_WRAP virtual int getCVFolds() const = 0; + /** @copybrief getCVFolds @see getCVFolds */ + CV_WRAP virtual void setCVFolds(int val) = 0; + + /** If true then surrogate splits will be built. + These splits allow to work with missing data and compute variable importance correctly. + Default value is false. + @note currently it's not implemented.*/ + /** @see setUseSurrogates */ + CV_WRAP virtual bool getUseSurrogates() const = 0; + /** @copybrief getUseSurrogates @see getUseSurrogates */ + CV_WRAP virtual void setUseSurrogates(bool val) = 0; + + /** If true then a pruning will be harsher. + This will make a tree more compact and more resistant to the training data noise but a bit less + accurate. Default value is true.*/ + /** @see setUse1SERule */ + CV_WRAP virtual bool getUse1SERule() const = 0; + /** @copybrief getUse1SERule @see getUse1SERule */ + CV_WRAP virtual void setUse1SERule(bool val) = 0; + + /** If true then pruned branches are physically removed from the tree. + Otherwise they are retained and it is possible to get results from the original unpruned (or + pruned less aggressively) tree. Default value is true.*/ + /** @see setTruncatePrunedTree */ + CV_WRAP virtual bool getTruncatePrunedTree() const = 0; + /** @copybrief getTruncatePrunedTree @see getTruncatePrunedTree */ + CV_WRAP virtual void setTruncatePrunedTree(bool val) = 0; + + /** Termination criteria for regression trees. + If all absolute differences between an estimated value in a node and values of train samples + in this node are less than this parameter then the node will not be split further. Default + value is 0.01f*/ + /** @see setRegressionAccuracy */ + CV_WRAP virtual float getRegressionAccuracy() const = 0; + /** @copybrief getRegressionAccuracy @see getRegressionAccuracy */ + CV_WRAP virtual void setRegressionAccuracy(float val) = 0; + + /** @brief The array of a priori class probabilities, sorted by the class label value. + + The parameter can be used to tune the decision tree preferences toward a certain class. For + example, if you want to detect some rare anomaly occurrence, the training base will likely + contain much more normal cases than anomalies, so a very good classification performance + will be achieved just by considering every case as normal. To avoid this, the priors can be + specified, where the anomaly probability is artificially increased (up to 0.5 or even + greater), so the weight of the misclassified anomalies becomes much bigger, and the tree is + adjusted properly. + + You can also think about this parameter as weights of prediction categories which determine + relative weights that you give to misclassification. That is, if the weight of the first + category is 1 and the weight of the second category is 10, then each mistake in predicting + the second category is equivalent to making 10 mistakes in predicting the first category. + Default value is empty Mat.*/ + /** @see setPriors */ + CV_WRAP virtual cv::Mat getPriors() const = 0; + /** @copybrief getPriors @see getPriors */ + CV_WRAP virtual void setPriors(const cv::Mat &val) = 0; + + /** @brief The class represents a decision tree node. + */ + class CV_EXPORTS Node + { + public: + Node(); + double value; //!< Value at the node: a class label in case of classification or estimated + //!< function value in case of regression. + int classIdx; //!< Class index normalized to 0..class_count-1 range and assigned to the + //!< node. It is used internally in classification trees and tree ensembles. + int parent; //!< Index of the parent node + int left; //!< Index of the left child node + int right; //!< Index of right child node + int defaultDir; //!< Default direction where to go (-1: left or +1: right). It helps in the + //!< case of missing values. + int split; //!< Index of the first split + }; + + /** @brief The class represents split in a decision tree. + */ + class CV_EXPORTS Split + { + public: + Split(); + int varIdx; //!< Index of variable on which the split is created. + bool inversed; //!< If true, then the inverse split rule is used (i.e. left and right + //!< branches are exchanged in the rule expressions below). + float quality; //!< The split quality, a positive number. It is used to choose the best split. + int next; //!< Index of the next split in the list of splits for the node + float c; /**< The threshold value in case of split on an ordered variable. + The rule is: + @code{.none} + if var_value < c + then next_node <- left + else next_node <- right + @endcode */ + int subsetOfs; /**< Offset of the bitset used by the split on a categorical variable. + The rule is: + @code{.none} + if bitset[var_value] == 1 + then next_node <- left + else next_node <- right + @endcode */ + }; + + /** @brief Returns indices of root nodes + */ + virtual const std::vector& getRoots() const = 0; + /** @brief Returns all the nodes + + all the node indices are indices in the returned vector + */ + virtual const std::vector& getNodes() const = 0; + /** @brief Returns all the splits + + all the split indices are indices in the returned vector + */ + virtual const std::vector& getSplits() const = 0; + /** @brief Returns all the bitsets for categorical splits + + Split::subsetOfs is an offset in the returned vector + */ + virtual const std::vector& getSubsets() const = 0; + + /** @brief Creates the empty model + + The static method creates empty decision tree with the specified parameters. It should be then + trained using train method (see StatModel::train). Alternatively, you can load the model from + file using Algorithm::load\(filename). + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized DTrees from a file + * + * Use DTree::save to serialize and store an DTree to disk. + * Load the DTree from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized DTree + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Random Trees Classifier * +\****************************************************************************************/ + +/** @brief The class implements the random forest predictor. + +@sa @ref ml_intro_rtrees + */ +class CV_EXPORTS_W RTrees : public DTrees +{ +public: + + /** If true then variable importance will be calculated and then it can be retrieved by RTrees::getVarImportance. + Default value is false.*/ + /** @see setCalculateVarImportance */ + CV_WRAP virtual bool getCalculateVarImportance() const = 0; + /** @copybrief getCalculateVarImportance @see getCalculateVarImportance */ + CV_WRAP virtual void setCalculateVarImportance(bool val) = 0; + + /** The size of the randomly selected subset of features at each tree node and that are used + to find the best split(s). + If you set it to 0 then the size will be set to the square root of the total number of + features. Default value is 0.*/ + /** @see setActiveVarCount */ + CV_WRAP virtual int getActiveVarCount() const = 0; + /** @copybrief getActiveVarCount @see getActiveVarCount */ + CV_WRAP virtual void setActiveVarCount(int val) = 0; + + /** The termination criteria that specifies when the training algorithm stops. + Either when the specified number of trees is trained and added to the ensemble or when + sufficient accuracy (measured as OOB error) is achieved. Typically the more trees you have the + better the accuracy. However, the improvement in accuracy generally diminishes and asymptotes + pass a certain number of trees. Also to keep in mind, the number of tree increases the + prediction time linearly. Default value is TermCriteria(TermCriteria::MAX_ITERS + + TermCriteria::EPS, 50, 0.1)*/ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const TermCriteria &val) = 0; + + /** Returns the variable importance array. + The method returns the variable importance vector, computed at the training stage when + CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is + returned. + */ + CV_WRAP virtual Mat getVarImportance() const = 0; + + /** Returns the result of each individual tree in the forest. + In case the model is a regression problem, the method will return each of the trees' + results for each of the sample cases. If the model is a classifier, it will return + a Mat with samples + 1 rows, where the first row gives the class number and the + following rows return the votes each class had for each sample. + @param samples Array containing the samples for which votes will be calculated. + @param results Array where the result of the calculation will be written. + @param flags Flags for defining the type of RTrees. + */ + CV_WRAP virtual void getVotes(InputArray samples, OutputArray results, int flags) const = 0; + + /** Returns the OOB error value, computed at the training stage when calcOOBError is set to true. + * If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting. + */ +#if CV_VERSION_MAJOR == 4 + CV_WRAP virtual double getOOBError() const { return 0; } +#else + /*CV_WRAP*/ virtual double getOOBError() const = 0; +#endif + + /** Creates the empty model. + Use StatModel::train to train the model, StatModel::train to create and train the model, + Algorithm::load to load the pre-trained model. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized RTree from a file + * + * Use RTree::save to serialize and store an RTree to disk. + * Load the RTree from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized RTree + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Boosted tree classifier * +\****************************************************************************************/ + +/** @brief Boosted tree classifier derived from DTrees + +@sa @ref ml_intro_boost + */ +class CV_EXPORTS_W Boost : public DTrees +{ +public: + /** Type of the boosting algorithm. + See Boost::Types. Default value is Boost::REAL. */ + /** @see setBoostType */ + CV_WRAP virtual int getBoostType() const = 0; + /** @copybrief getBoostType @see getBoostType */ + CV_WRAP virtual void setBoostType(int val) = 0; + + /** The number of weak classifiers. + Default value is 100. */ + /** @see setWeakCount */ + CV_WRAP virtual int getWeakCount() const = 0; + /** @copybrief getWeakCount @see getWeakCount */ + CV_WRAP virtual void setWeakCount(int val) = 0; + + /** A threshold between 0 and 1 used to save computational time. + Samples with summary weight \f$\leq 1 - weight_trim_rate\f$ do not participate in the *next* + iteration of training. Set this parameter to 0 to turn off this functionality. Default value is 0.95.*/ + /** @see setWeightTrimRate */ + CV_WRAP virtual double getWeightTrimRate() const = 0; + /** @copybrief getWeightTrimRate @see getWeightTrimRate */ + CV_WRAP virtual void setWeightTrimRate(double val) = 0; + + /** Boosting type. + Gentle AdaBoost and Real AdaBoost are often the preferable choices. */ + enum Types { + DISCRETE=0, //!< Discrete AdaBoost. + REAL=1, //!< Real AdaBoost. It is a technique that utilizes confidence-rated predictions + //!< and works well with categorical data. + LOGIT=2, //!< LogitBoost. It can produce good regression fits. + GENTLE=3 //!< Gentle AdaBoost. It puts less weight on outlier data points and for that + //!(filename) to load the pre-trained model. */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized Boost from a file + * + * Use Boost::save to serialize and store an RTree to disk. + * Load the Boost from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized Boost + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Gradient Boosted Trees * +\****************************************************************************************/ + +/*class CV_EXPORTS_W GBTrees : public DTrees +{ +public: + struct CV_EXPORTS_W_MAP Params : public DTrees::Params + { + CV_PROP_RW int weakCount; + CV_PROP_RW int lossFunctionType; + CV_PROP_RW float subsamplePortion; + CV_PROP_RW float shrinkage; + + Params(); + Params( int lossFunctionType, int weakCount, float shrinkage, + float subsamplePortion, int maxDepth, bool useSurrogates ); + }; + + enum {SQUARED_LOSS=0, ABSOLUTE_LOSS, HUBER_LOSS=3, DEVIANCE_LOSS}; + + virtual void setK(int k) = 0; + + virtual float predictSerial( InputArray samples, + OutputArray weakResponses, int flags) const = 0; + + static Ptr create(const Params& p); +};*/ + +/****************************************************************************************\ +* Artificial Neural Networks (ANN) * +\****************************************************************************************/ + +/////////////////////////////////// Multi-Layer Perceptrons ////////////////////////////// + +/** @brief Artificial Neural Networks - Multi-Layer Perceptrons. + +Unlike many other models in ML that are constructed and trained at once, in the MLP model these +steps are separated. First, a network with the specified topology is created using the non-default +constructor or the method ANN_MLP::create. All the weights are set to zeros. Then, the network is +trained using a set of input and output vectors. The training procedure can be repeated more than +once, that is, the weights can be adjusted based on the new training data. + +Additional flags for StatModel::train are available: ANN_MLP::TrainFlags. + +@sa @ref ml_intro_ann + */ +class CV_EXPORTS_W ANN_MLP : public StatModel +{ +public: + /** Available training methods */ + enum TrainingMethods { + BACKPROP=0, //!< The back-propagation algorithm. + RPROP = 1, //!< The RPROP algorithm. See @cite RPROP93 for details. + ANNEAL = 2 //!< The simulated annealing algorithm. See @cite Kirkpatrick83 for details. + }; + + /** Sets training method and common parameters. + @param method Default value is ANN_MLP::RPROP. See ANN_MLP::TrainingMethods. + @param param1 passed to setRpropDW0 for ANN_MLP::RPROP and to setBackpropWeightScale for ANN_MLP::BACKPROP and to initialT for ANN_MLP::ANNEAL. + @param param2 passed to setRpropDWMin for ANN_MLP::RPROP and to setBackpropMomentumScale for ANN_MLP::BACKPROP and to finalT for ANN_MLP::ANNEAL. + */ + CV_WRAP virtual void setTrainMethod(int method, double param1 = 0, double param2 = 0) = 0; + + /** Returns current training method */ + CV_WRAP virtual int getTrainMethod() const = 0; + + /** Initialize the activation function for each neuron. + Currently the default and the only fully supported activation function is ANN_MLP::SIGMOID_SYM. + @param type The type of activation function. See ANN_MLP::ActivationFunctions. + @param param1 The first parameter of the activation function, \f$\alpha\f$. Default value is 0. + @param param2 The second parameter of the activation function, \f$\beta\f$. Default value is 0. + */ + CV_WRAP virtual void setActivationFunction(int type, double param1 = 0, double param2 = 0) = 0; + + /** Integer vector specifying the number of neurons in each layer including the input and output layers. + The very first element specifies the number of elements in the input layer. + The last element - number of elements in the output layer. Default value is empty Mat. + @sa getLayerSizes */ + CV_WRAP virtual void setLayerSizes(InputArray _layer_sizes) = 0; + + /** Integer vector specifying the number of neurons in each layer including the input and output layers. + The very first element specifies the number of elements in the input layer. + The last element - number of elements in the output layer. + @sa setLayerSizes */ + CV_WRAP virtual cv::Mat getLayerSizes() const = 0; + + /** Termination criteria of the training algorithm. + You can specify the maximum number of iterations (maxCount) and/or how much the error could + change between the iterations to make the algorithm continue (epsilon). Default value is + TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 1000, 0.01).*/ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(TermCriteria val) = 0; + + /** BPROP: Strength of the weight gradient term. + The recommended value is about 0.1. Default value is 0.1.*/ + /** @see setBackpropWeightScale */ + CV_WRAP virtual double getBackpropWeightScale() const = 0; + /** @copybrief getBackpropWeightScale @see getBackpropWeightScale */ + CV_WRAP virtual void setBackpropWeightScale(double val) = 0; + + /** BPROP: Strength of the momentum term (the difference between weights on the 2 previous iterations). + This parameter provides some inertia to smooth the random fluctuations of the weights. It can + vary from 0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough. + Default value is 0.1.*/ + /** @see setBackpropMomentumScale */ + CV_WRAP virtual double getBackpropMomentumScale() const = 0; + /** @copybrief getBackpropMomentumScale @see getBackpropMomentumScale */ + CV_WRAP virtual void setBackpropMomentumScale(double val) = 0; + + /** RPROP: Initial value \f$\Delta_0\f$ of update-values \f$\Delta_{ij}\f$. + Default value is 0.1.*/ + /** @see setRpropDW0 */ + CV_WRAP virtual double getRpropDW0() const = 0; + /** @copybrief getRpropDW0 @see getRpropDW0 */ + CV_WRAP virtual void setRpropDW0(double val) = 0; + + /** RPROP: Increase factor \f$\eta^+\f$. + It must be \>1. Default value is 1.2.*/ + /** @see setRpropDWPlus */ + CV_WRAP virtual double getRpropDWPlus() const = 0; + /** @copybrief getRpropDWPlus @see getRpropDWPlus */ + CV_WRAP virtual void setRpropDWPlus(double val) = 0; + + /** RPROP: Decrease factor \f$\eta^-\f$. + It must be \<1. Default value is 0.5.*/ + /** @see setRpropDWMinus */ + CV_WRAP virtual double getRpropDWMinus() const = 0; + /** @copybrief getRpropDWMinus @see getRpropDWMinus */ + CV_WRAP virtual void setRpropDWMinus(double val) = 0; + + /** RPROP: Update-values lower limit \f$\Delta_{min}\f$. + It must be positive. Default value is FLT_EPSILON.*/ + /** @see setRpropDWMin */ + CV_WRAP virtual double getRpropDWMin() const = 0; + /** @copybrief getRpropDWMin @see getRpropDWMin */ + CV_WRAP virtual void setRpropDWMin(double val) = 0; + + /** RPROP: Update-values upper limit \f$\Delta_{max}\f$. + It must be \>1. Default value is 50.*/ + /** @see setRpropDWMax */ + CV_WRAP virtual double getRpropDWMax() const = 0; + /** @copybrief getRpropDWMax @see getRpropDWMax */ + CV_WRAP virtual void setRpropDWMax(double val) = 0; + + /** ANNEAL: Update initial temperature. + It must be \>=0. Default value is 10.*/ + /** @see setAnnealInitialT */ + CV_WRAP virtual double getAnnealInitialT() const = 0; + /** @copybrief getAnnealInitialT @see getAnnealInitialT */ + CV_WRAP virtual void setAnnealInitialT(double val) = 0; + + /** ANNEAL: Update final temperature. + It must be \>=0 and less than initialT. Default value is 0.1.*/ + /** @see setAnnealFinalT */ + CV_WRAP virtual double getAnnealFinalT() const = 0; + /** @copybrief getAnnealFinalT @see getAnnealFinalT */ + CV_WRAP virtual void setAnnealFinalT(double val) = 0; + + /** ANNEAL: Update cooling ratio. + It must be \>0 and less than 1. Default value is 0.95.*/ + /** @see setAnnealCoolingRatio */ + CV_WRAP virtual double getAnnealCoolingRatio() const = 0; + /** @copybrief getAnnealCoolingRatio @see getAnnealCoolingRatio */ + CV_WRAP virtual void setAnnealCoolingRatio(double val) = 0; + + /** ANNEAL: Update iteration per step. + It must be \>0 . Default value is 10.*/ + /** @see setAnnealItePerStep */ + CV_WRAP virtual int getAnnealItePerStep() const = 0; + /** @copybrief getAnnealItePerStep @see getAnnealItePerStep */ + CV_WRAP virtual void setAnnealItePerStep(int val) = 0; + + /** @brief Set/initialize anneal RNG */ + virtual void setAnnealEnergyRNG(const RNG& rng) = 0; + + /** possible activation functions */ + enum ActivationFunctions { + /** Identity function: \f$f(x)=x\f$ */ + IDENTITY = 0, + /** Symmetrical sigmoid: \f$f(x)=\beta*(1-e^{-\alpha x})/(1+e^{-\alpha x})\f$ + @note + If you are using the default sigmoid activation function with the default parameter values + fparam1=0 and fparam2=0 then the function used is y = 1.7159\*tanh(2/3 \* x), so the output + will range from [-1.7159, 1.7159], instead of [0,1].*/ + SIGMOID_SYM = 1, + /** Gaussian function: \f$f(x)=\beta e^{-\alpha x*x}\f$ */ + GAUSSIAN = 2, + /** ReLU function: \f$f(x)=max(0,x)\f$ */ + RELU = 3, + /** Leaky ReLU function: for x>0 \f$f(x)=x \f$ and x<=0 \f$f(x)=\alpha x \f$*/ + LEAKYRELU= 4 + }; + + /** Train options */ + enum TrainFlags { + /** Update the network weights, rather than compute them from scratch. In the latter case + the weights are initialized using the Nguyen-Widrow algorithm. */ + UPDATE_WEIGHTS = 1, + /** Do not normalize the input vectors. If this flag is not set, the training algorithm + normalizes each input feature independently, shifting its mean value to 0 and making the + standard deviation equal to 1. If the network is assumed to be updated frequently, the new + training data could be much different from original one. In this case, you should take care + of proper normalization. */ + NO_INPUT_SCALE = 2, + /** Do not normalize the output vectors. If the flag is not set, the training algorithm + normalizes each output feature independently, by transforming it to the certain range + depending on the used activation function. */ + NO_OUTPUT_SCALE = 4 + }; + + CV_WRAP virtual Mat getWeights(int layerIdx) const = 0; + + /** @brief Creates empty model + + Use StatModel::train to train the model, Algorithm::load\(filename) to load the pre-trained model. + Note that the train method has optional flags: ANN_MLP::TrainFlags. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized ANN from a file + * + * Use ANN::save to serialize and store an ANN to disk. + * Load the ANN from this file again, by calling this function with the path to the file. + * + * @param filepath path to serialized ANN + */ + CV_WRAP static Ptr load(const String& filepath); + +}; + +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +typedef ANN_MLP ANN_MLP_ANNEAL; +#endif + +/****************************************************************************************\ +* Logistic Regression * +\****************************************************************************************/ + +/** @brief Implements Logistic Regression classifier. + +@sa @ref ml_intro_lr + */ +class CV_EXPORTS_W LogisticRegression : public StatModel +{ +public: + + /** Learning rate. */ + /** @see setLearningRate */ + CV_WRAP virtual double getLearningRate() const = 0; + /** @copybrief getLearningRate @see getLearningRate */ + CV_WRAP virtual void setLearningRate(double val) = 0; + + /** Number of iterations. */ + /** @see setIterations */ + CV_WRAP virtual int getIterations() const = 0; + /** @copybrief getIterations @see getIterations */ + CV_WRAP virtual void setIterations(int val) = 0; + + /** Kind of regularization to be applied. See LogisticRegression::RegKinds. */ + /** @see setRegularization */ + CV_WRAP virtual int getRegularization() const = 0; + /** @copybrief getRegularization @see getRegularization */ + CV_WRAP virtual void setRegularization(int val) = 0; + + /** Kind of training method used. See LogisticRegression::Methods. */ + /** @see setTrainMethod */ + CV_WRAP virtual int getTrainMethod() const = 0; + /** @copybrief getTrainMethod @see getTrainMethod */ + CV_WRAP virtual void setTrainMethod(int val) = 0; + + /** Specifies the number of training samples taken in each step of Mini-Batch Gradient + Descent. Will only be used if using LogisticRegression::MINI_BATCH training algorithm. It + has to take values less than the total number of training samples. */ + /** @see setMiniBatchSize */ + CV_WRAP virtual int getMiniBatchSize() const = 0; + /** @copybrief getMiniBatchSize @see getMiniBatchSize */ + CV_WRAP virtual void setMiniBatchSize(int val) = 0; + + /** Termination criteria of the algorithm. */ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(TermCriteria val) = 0; + + //! Regularization kinds + enum RegKinds { + REG_DISABLE = -1, //!< Regularization disabled + REG_L1 = 0, //!< %L1 norm + REG_L2 = 1 //!< %L2 norm + }; + + //! Training methods + enum Methods { + BATCH = 0, + MINI_BATCH = 1 //!< Set MiniBatchSize to a positive integer when using this method. + }; + + /** @brief Predicts responses for input samples and returns a float type. + + @param samples The input data for the prediction algorithm. Matrix [m x n], where each row + contains variables (features) of one object being classified. Should have data type CV_32F. + @param results Predicted labels as a column matrix of type CV_32S. + @param flags Not used. + */ + CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const CV_OVERRIDE = 0; + + /** @brief This function returns the trained parameters arranged across rows. + + For a two class classification problem, it returns a row matrix. It returns learnt parameters of + the Logistic Regression as a matrix of type CV_32F. + */ + CV_WRAP virtual Mat get_learnt_thetas() const = 0; + + /** @brief Creates empty model. + + Creates Logistic Regression model with parameters given. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized LogisticRegression from a file + * + * Use LogisticRegression::save to serialize and store an LogisticRegression to disk. + * Load the LogisticRegression from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized LogisticRegression + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + + +/****************************************************************************************\ +* Stochastic Gradient Descent SVM Classifier * +\****************************************************************************************/ + +/*! +@brief Stochastic Gradient Descent SVM classifier + +SVMSGD provides a fast and easy-to-use implementation of the SVM classifier using the Stochastic Gradient Descent approach, +as presented in @cite bottou2010large. + +The classifier has following parameters: +- model type, +- margin type, +- margin regularization (\f$\lambda\f$), +- initial step size (\f$\gamma_0\f$), +- step decreasing power (\f$c\f$), +- and termination criteria. + +The model type may have one of the following values: \ref SGD and \ref ASGD. + +- \ref SGD is the classic version of SVMSGD classifier: every next step is calculated by the formula + \f[w_{t+1} = w_t - \gamma(t) \frac{dQ_i}{dw} |_{w = w_t}\f] + where + - \f$w_t\f$ is the weights vector for decision function at step \f$t\f$, + - \f$\gamma(t)\f$ is the step size of model parameters at the iteration \f$t\f$, it is decreased on each step by the formula + \f$\gamma(t) = \gamma_0 (1 + \lambda \gamma_0 t) ^ {-c}\f$ + - \f$Q_i\f$ is the target functional from SVM task for sample with number \f$i\f$, this sample is chosen stochastically on each step of the algorithm. + +- \ref ASGD is Average Stochastic Gradient Descent SVM Classifier. ASGD classifier averages weights vector on each step of algorithm by the formula +\f$\widehat{w}_{t+1} = \frac{t}{1+t}\widehat{w}_{t} + \frac{1}{1+t}w_{t+1}\f$ + +The recommended model type is ASGD (following @cite bottou2010large). + +The margin type may have one of the following values: \ref SOFT_MARGIN or \ref HARD_MARGIN. + +- You should use \ref HARD_MARGIN type, if you have linearly separable sets. +- You should use \ref SOFT_MARGIN type, if you have non-linearly separable sets or sets with outliers. +- In the general case (if you know nothing about linear separability of your sets), use SOFT_MARGIN. + +The other parameters may be described as follows: +- Margin regularization parameter is responsible for weights decreasing at each step and for the strength of restrictions on outliers + (the less the parameter, the less probability that an outlier will be ignored). + Recommended value for SGD model is 0.0001, for ASGD model is 0.00001. + +- Initial step size parameter is the initial value for the step size \f$\gamma(t)\f$. + You will have to find the best initial step for your problem. + +- Step decreasing power is the power parameter for \f$\gamma(t)\f$ decreasing by the formula, mentioned above. + Recommended value for SGD model is 1, for ASGD model is 0.75. + +- Termination criteria can be TermCriteria::COUNT, TermCriteria::EPS or TermCriteria::COUNT + TermCriteria::EPS. + You will have to find the best termination criteria for your problem. + +Note that the parameters margin regularization, initial step size, and step decreasing power should be positive. + +To use SVMSGD algorithm do as follows: + +- first, create the SVMSGD object. The algorithm will set optimal parameters by default, but you can set your own parameters via functions setSvmsgdType(), + setMarginType(), setMarginRegularization(), setInitialStepSize(), and setStepDecreasingPower(). + +- then the SVM model can be trained using the train features and the correspondent labels by the method train(). + +- after that, the label of a new feature vector can be predicted using the method predict(). + +@code +// Create empty object +cv::Ptr svmsgd = SVMSGD::create(); + +// Train the Stochastic Gradient Descent SVM +svmsgd->train(trainData); + +// Predict labels for the new samples +svmsgd->predict(samples, responses); +@endcode + +*/ + +class CV_EXPORTS_W SVMSGD : public cv::ml::StatModel +{ +public: + + /** SVMSGD type. + ASGD is often the preferable choice. */ + enum SvmsgdType + { + SGD, //!< Stochastic Gradient Descent + ASGD //!< Average Stochastic Gradient Descent + }; + + /** Margin type.*/ + enum MarginType + { + SOFT_MARGIN, //!< General case, suits to the case of non-linearly separable sets, allows outliers. + HARD_MARGIN //!< More accurate for the case of linearly separable sets. + }; + + /** + * @return the weights of the trained model (decision function f(x) = weights * x + shift). + */ + CV_WRAP virtual Mat getWeights() = 0; + + /** + * @return the shift of the trained model (decision function f(x) = weights * x + shift). + */ + CV_WRAP virtual float getShift() = 0; + + /** @brief Creates empty model. + * Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to + * find the best parameters for your problem or use setOptimalParameters() to set some default parameters. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized SVMSGD from a file + * + * Use SVMSGD::save to serialize and store an SVMSGD to disk. + * Load the SVMSGD from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized SVMSGD + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); + + /** @brief Function sets optimal parameters values for chosen SVM SGD model. + * @param svmsgdType is the type of SVMSGD classifier. + * @param marginType is the type of margin constraint. + */ + CV_WRAP virtual void setOptimalParameters(int svmsgdType = SVMSGD::ASGD, int marginType = SVMSGD::SOFT_MARGIN) = 0; + + /** @brief %Algorithm type, one of SVMSGD::SvmsgdType. */ + /** @see setSvmsgdType */ + CV_WRAP virtual int getSvmsgdType() const = 0; + /** @copybrief getSvmsgdType @see getSvmsgdType */ + CV_WRAP virtual void setSvmsgdType(int svmsgdType) = 0; + + /** @brief %Margin type, one of SVMSGD::MarginType. */ + /** @see setMarginType */ + CV_WRAP virtual int getMarginType() const = 0; + /** @copybrief getMarginType @see getMarginType */ + CV_WRAP virtual void setMarginType(int marginType) = 0; + + /** @brief Parameter marginRegularization of a %SVMSGD optimization problem. */ + /** @see setMarginRegularization */ + CV_WRAP virtual float getMarginRegularization() const = 0; + /** @copybrief getMarginRegularization @see getMarginRegularization */ + CV_WRAP virtual void setMarginRegularization(float marginRegularization) = 0; + + /** @brief Parameter initialStepSize of a %SVMSGD optimization problem. */ + /** @see setInitialStepSize */ + CV_WRAP virtual float getInitialStepSize() const = 0; + /** @copybrief getInitialStepSize @see getInitialStepSize */ + CV_WRAP virtual void setInitialStepSize(float InitialStepSize) = 0; + + /** @brief Parameter stepDecreasingPower of a %SVMSGD optimization problem. */ + /** @see setStepDecreasingPower */ + CV_WRAP virtual float getStepDecreasingPower() const = 0; + /** @copybrief getStepDecreasingPower @see getStepDecreasingPower */ + CV_WRAP virtual void setStepDecreasingPower(float stepDecreasingPower) = 0; + + /** @brief Termination criteria of the training algorithm. + You can specify the maximum number of iterations (maxCount) and/or how much the error could + change between the iterations to make the algorithm continue (epsilon).*/ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const cv::TermCriteria &val) = 0; +}; + + +/****************************************************************************************\ +* Auxiliary functions declarations * +\****************************************************************************************/ + +/** @brief Generates _sample_ from multivariate normal distribution + +@param mean an average row vector +@param cov symmetric covariation matrix +@param nsamples returned samples count +@param samples returned samples array +*/ +CV_EXPORTS void randMVNormal( InputArray mean, InputArray cov, int nsamples, OutputArray samples); + +/** @brief Creates test set */ +CV_EXPORTS void createConcentricSpheresTestSet( int nsamples, int nfeatures, int nclasses, + OutputArray samples, OutputArray responses); + + +/****************************************************************************************\ +* Simulated annealing solver * +\****************************************************************************************/ + +#ifdef CV_DOXYGEN +/** @brief This class declares example interface for system state used in simulated annealing optimization algorithm. + +@note This class is not defined in C++ code and can't be use directly - you need your own implementation with the same methods. +*/ +struct SimulatedAnnealingSolverSystem +{ + /** Give energy value for a state of system.*/ + double energy() const; + /** Function which change the state of system (random perturbation).*/ + void changeState(); + /** Function to reverse to the previous state. Can be called once only after changeState(). */ + void reverseState(); +}; +#endif // CV_DOXYGEN + +/** @brief The class implements simulated annealing for optimization. + +@cite Kirkpatrick83 for details + +@param solverSystem optimization system (see SimulatedAnnealingSolverSystem) +@param initialTemperature initial temperature +@param finalTemperature final temperature +@param coolingRatio temperature step multiplies +@param iterationsPerStep number of iterations per temperature changing step +@param lastTemperature optional output for last used temperature +@param rngEnergy specify custom random numbers generator (cv::theRNG() by default) +*/ +template +int simulatedAnnealingSolver(SimulatedAnnealingSolverSystem& solverSystem, + double initialTemperature, double finalTemperature, double coolingRatio, + size_t iterationsPerStep, + CV_OUT double* lastTemperature = NULL, + cv::RNG& rngEnergy = cv::theRNG() +); + +//! @} ml + +} +} + +#include + +#endif // __cplusplus +#endif // OPENCV_ML_HPP + +/* End of file. */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/ml/ml.hpp b/Cigarette/OpenCV455Simple/include/opencv2/ml/ml.hpp new file mode 100644 index 0000000..f6f9cd8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/ml/ml.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/ml.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/ml/ml.inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/ml/ml.inl.hpp new file mode 100644 index 0000000..dc9c783 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/ml/ml.inl.hpp @@ -0,0 +1,60 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_ML_INL_HPP +#define OPENCV_ML_INL_HPP + +namespace cv { namespace ml { + +// declared in ml.hpp +template +int simulatedAnnealingSolver(SimulatedAnnealingSolverSystem& solverSystem, + double initialTemperature, double finalTemperature, double coolingRatio, + size_t iterationsPerStep, + CV_OUT double* lastTemperature, + cv::RNG& rngEnergy +) +{ + CV_Assert(finalTemperature > 0); + CV_Assert(initialTemperature > finalTemperature); + CV_Assert(iterationsPerStep > 0); + CV_Assert(coolingRatio < 1.0f); + double Ti = initialTemperature; + double previousEnergy = solverSystem.energy(); + int exchange = 0; + while (Ti > finalTemperature) + { + for (size_t i = 0; i < iterationsPerStep; i++) + { + solverSystem.changeState(); + double newEnergy = solverSystem.energy(); + if (newEnergy < previousEnergy) + { + previousEnergy = newEnergy; + exchange++; + } + else + { + double r = rngEnergy.uniform(0.0, 1.0); + if (r < std::exp(-(newEnergy - previousEnergy) / Ti)) + { + previousEnergy = newEnergy; + exchange++; + } + else + { + solverSystem.reverseState(); + } + } + } + Ti *= coolingRatio; + } + if (lastTemperature) + *lastTemperature = Ti; + return exchange; +} + +}} //namespace + +#endif // OPENCV_ML_INL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/objdetect.hpp b/Cigarette/OpenCV455Simple/include/opencv2/objdetect.hpp new file mode 100644 index 0000000..3592255 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/objdetect.hpp @@ -0,0 +1,836 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OBJDETECT_HPP +#define OPENCV_OBJDETECT_HPP + +#include "opencv2/core.hpp" + +/** +@defgroup objdetect Object Detection + +Haar Feature-based Cascade Classifier for Object Detection +---------------------------------------------------------- + +The object detector described below has been initially proposed by Paul Viola @cite Viola01 and +improved by Rainer Lienhart @cite Lienhart02 . + +First, a classifier (namely a *cascade of boosted classifiers working with haar-like features*) is +trained with a few hundred sample views of a particular object (i.e., a face or a car), called +positive examples, that are scaled to the same size (say, 20x20), and negative examples - arbitrary +images of the same size. + +After a classifier is trained, it can be applied to a region of interest (of the same size as used +during the training) in an input image. The classifier outputs a "1" if the region is likely to show +the object (i.e., face/car), and "0" otherwise. To search for the object in the whole image one can +move the search window across the image and check every location using the classifier. The +classifier is designed so that it can be easily "resized" in order to be able to find the objects of +interest at different sizes, which is more efficient than resizing the image itself. So, to find an +object of an unknown size in the image the scan procedure should be done several times at different +scales. + +The word "cascade" in the classifier name means that the resultant classifier consists of several +simpler classifiers (*stages*) that are applied subsequently to a region of interest until at some +stage the candidate is rejected or all the stages are passed. The word "boosted" means that the +classifiers at every stage of the cascade are complex themselves and they are built out of basic +classifiers using one of four different boosting techniques (weighted voting). Currently Discrete +Adaboost, Real Adaboost, Gentle Adaboost and Logitboost are supported. The basic classifiers are +decision-tree classifiers with at least 2 leaves. Haar-like features are the input to the basic +classifiers, and are calculated as described below. The current algorithm uses the following +Haar-like features: + +![image](pics/haarfeatures.png) + +The feature used in a particular classifier is specified by its shape (1a, 2b etc.), position within +the region of interest and the scale (this scale is not the same as the scale used at the detection +stage, though these two scales are multiplied). For example, in the case of the third line feature +(2c) the response is calculated as the difference between the sum of image pixels under the +rectangle covering the whole feature (including the two white stripes and the black stripe in the +middle) and the sum of the image pixels under the black stripe multiplied by 3 in order to +compensate for the differences in the size of areas. The sums of pixel values over a rectangular +regions are calculated rapidly using integral images (see below and the integral description). + +To see the object detector at work, have a look at the facedetect demo: + + +The following reference is for the detection part only. There is a separate application called +opencv_traincascade that can train a cascade of boosted classifiers from a set of samples. + +@note In the new C++ interface it is also possible to use LBP (local binary pattern) features in +addition to Haar-like features. .. [Viola01] Paul Viola and Michael J. Jones. Rapid Object Detection +using a Boosted Cascade of Simple Features. IEEE CVPR, 2001. The paper is available online at + + +@{ + @defgroup objdetect_c C API +@} + */ + +typedef struct CvHaarClassifierCascade CvHaarClassifierCascade; + +namespace cv +{ + +//! @addtogroup objdetect +//! @{ + +///////////////////////////// Object Detection //////////////////////////// + +//! class for grouping object candidates, detected by Cascade Classifier, HOG etc. +//! instance of the class is to be passed to cv::partition (see cxoperations.hpp) +class CV_EXPORTS SimilarRects +{ +public: + SimilarRects(double _eps) : eps(_eps) {} + inline bool operator()(const Rect& r1, const Rect& r2) const + { + double delta = eps * ((std::min)(r1.width, r2.width) + (std::min)(r1.height, r2.height)) * 0.5; + return std::abs(r1.x - r2.x) <= delta && + std::abs(r1.y - r2.y) <= delta && + std::abs(r1.x + r1.width - r2.x - r2.width) <= delta && + std::abs(r1.y + r1.height - r2.y - r2.height) <= delta; + } + double eps; +}; + +/** @brief Groups the object candidate rectangles. + +@param rectList Input/output vector of rectangles. Output vector includes retained and grouped +rectangles. (The Python list is not modified in place.) +@param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a +group of rectangles to retain it. +@param eps Relative difference between sides of the rectangles to merge them into a group. + +The function is a wrapper for the generic function partition . It clusters all the input rectangles +using the rectangle equivalence criteria that combines rectangles with similar sizes and similar +locations. The similarity is defined by eps. When eps=0 , no clustering is done at all. If +\f$\texttt{eps}\rightarrow +\inf\f$ , all the rectangles are put in one cluster. Then, the small +clusters containing less than or equal to groupThreshold rectangles are rejected. In each other +cluster, the average rectangle is computed and put into the output rectangle list. + */ +CV_EXPORTS void groupRectangles(std::vector& rectList, int groupThreshold, double eps = 0.2); +/** @overload */ +CV_EXPORTS_W void groupRectangles(CV_IN_OUT std::vector& rectList, CV_OUT std::vector& weights, + int groupThreshold, double eps = 0.2); +/** @overload */ +CV_EXPORTS void groupRectangles(std::vector& rectList, int groupThreshold, + double eps, std::vector* weights, std::vector* levelWeights ); +/** @overload */ +CV_EXPORTS void groupRectangles(std::vector& rectList, std::vector& rejectLevels, + std::vector& levelWeights, int groupThreshold, double eps = 0.2); +/** @overload */ +CV_EXPORTS void groupRectangles_meanshift(std::vector& rectList, std::vector& foundWeights, + std::vector& foundScales, + double detectThreshold = 0.0, Size winDetSize = Size(64, 128)); + +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvHaarClassifierCascade* obj) const; }; + +enum { CASCADE_DO_CANNY_PRUNING = 1, + CASCADE_SCALE_IMAGE = 2, + CASCADE_FIND_BIGGEST_OBJECT = 4, + CASCADE_DO_ROUGH_SEARCH = 8 + }; + +class CV_EXPORTS_W BaseCascadeClassifier : public Algorithm +{ +public: + virtual ~BaseCascadeClassifier(); + virtual bool empty() const CV_OVERRIDE = 0; + virtual bool load( const String& filename ) = 0; + virtual void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + double scaleFactor, + int minNeighbors, int flags, + Size minSize, Size maxSize ) = 0; + + virtual void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& numDetections, + double scaleFactor, + int minNeighbors, int flags, + Size minSize, Size maxSize ) = 0; + + virtual void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& rejectLevels, + CV_OUT std::vector& levelWeights, + double scaleFactor, + int minNeighbors, int flags, + Size minSize, Size maxSize, + bool outputRejectLevels ) = 0; + + virtual bool isOldFormatCascade() const = 0; + virtual Size getOriginalWindowSize() const = 0; + virtual int getFeatureType() const = 0; + virtual void* getOldCascade() = 0; + + class CV_EXPORTS MaskGenerator + { + public: + virtual ~MaskGenerator() {} + virtual Mat generateMask(const Mat& src)=0; + virtual void initializeMask(const Mat& /*src*/) { } + }; + virtual void setMaskGenerator(const Ptr& maskGenerator) = 0; + virtual Ptr getMaskGenerator() = 0; +}; + +/** @example samples/cpp/facedetect.cpp +This program demonstrates usage of the Cascade classifier class +\image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254 +*/ +/** @brief Cascade classifier class for object detection. + */ +class CV_EXPORTS_W CascadeClassifier +{ +public: + CV_WRAP CascadeClassifier(); + /** @brief Loads a classifier from a file. + + @param filename Name of the file from which the classifier is loaded. + */ + CV_WRAP CascadeClassifier(const String& filename); + ~CascadeClassifier(); + /** @brief Checks whether the classifier has been loaded. + */ + CV_WRAP bool empty() const; + /** @brief Loads a classifier from a file. + + @param filename Name of the file from which the classifier is loaded. The file may contain an old + HAAR classifier trained by the haartraining application or a new cascade classifier trained by the + traincascade application. + */ + CV_WRAP bool load( const String& filename ); + /** @brief Reads a classifier from a FileStorage node. + + @note The file may contain a new cascade classifier (trained traincascade application) only. + */ + CV_WRAP bool read( const FileNode& node ); + + /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list + of rectangles. + + @param image Matrix of the type CV_8U containing an image where objects are detected. + @param objects Vector of rectangles where each rectangle contains the detected object, the + rectangles may be partially outside the original image. + @param scaleFactor Parameter specifying how much the image size is reduced at each image scale. + @param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have + to retain it. + @param flags Parameter with the same meaning for an old cascade as in the function + cvHaarDetectObjects. It is not used for a new cascade. + @param minSize Minimum possible object size. Objects smaller than that are ignored. + @param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale. + + The function is parallelized with the TBB library. + + @note + - (Python) A face detection example using cascade classifiers can be found at + opencv_source_code/samples/python/facedetect.py + */ + CV_WRAP void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + double scaleFactor = 1.1, + int minNeighbors = 3, int flags = 0, + Size minSize = Size(), + Size maxSize = Size() ); + + /** @overload + @param image Matrix of the type CV_8U containing an image where objects are detected. + @param objects Vector of rectangles where each rectangle contains the detected object, the + rectangles may be partially outside the original image. + @param numDetections Vector of detection numbers for the corresponding objects. An object's number + of detections is the number of neighboring positively classified rectangles that were joined + together to form the object. + @param scaleFactor Parameter specifying how much the image size is reduced at each image scale. + @param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have + to retain it. + @param flags Parameter with the same meaning for an old cascade as in the function + cvHaarDetectObjects. It is not used for a new cascade. + @param minSize Minimum possible object size. Objects smaller than that are ignored. + @param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale. + */ + CV_WRAP_AS(detectMultiScale2) void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& numDetections, + double scaleFactor=1.1, + int minNeighbors=3, int flags=0, + Size minSize=Size(), + Size maxSize=Size() ); + + /** @overload + This function allows you to retrieve the final stage decision certainty of classification. + For this, one needs to set `outputRejectLevels` on true and provide the `rejectLevels` and `levelWeights` parameter. + For each resulting detection, `levelWeights` will then contain the certainty of classification at the final stage. + This value can then be used to separate strong from weaker classifications. + + A code sample on how to use it efficiently can be found below: + @code + Mat img; + vector weights; + vector levels; + vector detections; + CascadeClassifier model("/path/to/your/model.xml"); + model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); + cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl; + @endcode + */ + CV_WRAP_AS(detectMultiScale3) void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& rejectLevels, + CV_OUT std::vector& levelWeights, + double scaleFactor = 1.1, + int minNeighbors = 3, int flags = 0, + Size minSize = Size(), + Size maxSize = Size(), + bool outputRejectLevels = false ); + + CV_WRAP bool isOldFormatCascade() const; + CV_WRAP Size getOriginalWindowSize() const; + CV_WRAP int getFeatureType() const; + void* getOldCascade(); + + CV_WRAP static bool convert(const String& oldcascade, const String& newcascade); + + void setMaskGenerator(const Ptr& maskGenerator); + Ptr getMaskGenerator(); + + Ptr cc; +}; + +CV_EXPORTS Ptr createFaceDetectionMaskGenerator(); + +//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector ////////////// + +//! struct for detection region of interest (ROI) +struct DetectionROI +{ + //! scale(size) of the bounding box + double scale; + //! set of requested locations to be evaluated + std::vector locations; + //! vector that will contain confidence values for each location + std::vector confidences; +}; + +/**@brief Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. + +the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs @cite Dalal2005 . + +useful links: + +https://hal.inria.fr/inria-00548512/document/ + +https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients + +https://software.intel.com/en-us/ipp-dev-reference-histogram-of-oriented-gradients-hog-descriptor + +http://www.learnopencv.com/histogram-of-oriented-gradients + +http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial + + */ +struct CV_EXPORTS_W HOGDescriptor +{ +public: + enum HistogramNormType { L2Hys = 0 //!< Default histogramNormType + }; + enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value. + }; + enum DescriptorStorageFormat { DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW }; + + /**@brief Creates the HOG descriptor and detector with default params. + + aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) + */ + CV_WRAP HOGDescriptor() : winSize(64,128), blockSize(16,16), blockStride(8,8), + cellSize(8,8), nbins(9), derivAperture(1), winSigma(-1), + histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2), gammaCorrection(true), + free_coef(-1.f), nlevels(HOGDescriptor::DEFAULT_NLEVELS), signedGradient(false) + {} + + /** @overload + @param _winSize sets winSize with given value. + @param _blockSize sets blockSize with given value. + @param _blockStride sets blockStride with given value. + @param _cellSize sets cellSize with given value. + @param _nbins sets nbins with given value. + @param _derivAperture sets derivAperture with given value. + @param _winSigma sets winSigma with given value. + @param _histogramNormType sets histogramNormType with given value. + @param _L2HysThreshold sets L2HysThreshold with given value. + @param _gammaCorrection sets gammaCorrection with given value. + @param _nlevels sets nlevels with given value. + @param _signedGradient sets signedGradient with given value. + */ + CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, + Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1, + HOGDescriptor::HistogramNormType _histogramNormType=HOGDescriptor::L2Hys, + double _L2HysThreshold=0.2, bool _gammaCorrection=false, + int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false) + : winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize), + nbins(_nbins), derivAperture(_derivAperture), winSigma(_winSigma), + histogramNormType(_histogramNormType), L2HysThreshold(_L2HysThreshold), + gammaCorrection(_gammaCorrection), free_coef(-1.f), nlevels(_nlevels), signedGradient(_signedGradient) + {} + + /** @overload + @param filename The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier. + */ + CV_WRAP HOGDescriptor(const String& filename) + { + load(filename); + } + + /** @overload + @param d the HOGDescriptor which cloned to create a new one. + */ + HOGDescriptor(const HOGDescriptor& d) + { + d.copyTo(*this); + } + + /**@brief Default destructor. + */ + virtual ~HOGDescriptor() {} + + /**@brief Returns the number of coefficients required for the classification. + */ + CV_WRAP size_t getDescriptorSize() const; + + /** @brief Checks if detector size equal to descriptor size. + */ + CV_WRAP bool checkDetectorSize() const; + + /** @brief Returns winSigma value + */ + CV_WRAP double getWinSigma() const; + + /**@example samples/cpp/peopledetect.cpp + */ + /**@brief Sets coefficients for the linear SVM classifier. + @param svmdetector coefficients for the linear SVM classifier. + */ + CV_WRAP virtual void setSVMDetector(InputArray svmdetector); + + /** @brief Reads HOGDescriptor parameters from a cv::FileNode. + @param fn File node + */ + virtual bool read(FileNode& fn); + + /** @brief Stores HOGDescriptor parameters in a cv::FileStorage. + @param fs File storage + @param objname Object name + */ + virtual void write(FileStorage& fs, const String& objname) const; + + /** @brief loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. + @param filename Path of the file to read. + @param objname The optional name of the node to read (if empty, the first top-level node will be used). + */ + CV_WRAP virtual bool load(const String& filename, const String& objname = String()); + + /** @brief saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file + @param filename File name + @param objname Object name + */ + CV_WRAP virtual void save(const String& filename, const String& objname = String()) const; + + /** @brief clones the HOGDescriptor + @param c cloned HOGDescriptor + */ + virtual void copyTo(HOGDescriptor& c) const; + + /**@example samples/cpp/train_HOG.cpp + */ + /** @brief Computes HOG descriptors of given image. + @param img Matrix of the type CV_8U containing an image where HOG features will be calculated. + @param descriptors Matrix of the type CV_32F + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param locations Vector of Point + */ + CV_WRAP virtual void compute(InputArray img, + CV_OUT std::vector& descriptors, + Size winStride = Size(), Size padding = Size(), + const std::vector& locations = std::vector()) const; + + /** @brief Performs object detection without a multi-scale window. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries. + @param weights Vector that will contain confidence values for each detected object. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param searchLocations Vector of Point includes set of requested locations to be evaluated. + */ + CV_WRAP virtual void detect(InputArray img, CV_OUT std::vector& foundLocations, + CV_OUT std::vector& weights, + double hitThreshold = 0, Size winStride = Size(), + Size padding = Size(), + const std::vector& searchLocations = std::vector()) const; + + /** @brief Performs object detection without a multi-scale window. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param searchLocations Vector of Point includes locations to search. + */ + virtual void detect(InputArray img, CV_OUT std::vector& foundLocations, + double hitThreshold = 0, Size winStride = Size(), + Size padding = Size(), + const std::vector& searchLocations=std::vector()) const; + + /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list + of rectangles. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of rectangles where each rectangle contains the detected object. + @param foundWeights Vector that will contain confidence values for each detected object. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param scale Coefficient of the detection window increase. + @param finalThreshold Final threshold + @param useMeanshiftGrouping indicates grouping algorithm + */ + CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector& foundLocations, + CV_OUT std::vector& foundWeights, double hitThreshold = 0, + Size winStride = Size(), Size padding = Size(), double scale = 1.05, + double finalThreshold = 2.0,bool useMeanshiftGrouping = false) const; + + /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list + of rectangles. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of rectangles where each rectangle contains the detected object. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param scale Coefficient of the detection window increase. + @param finalThreshold Final threshold + @param useMeanshiftGrouping indicates grouping algorithm + */ + virtual void detectMultiScale(InputArray img, CV_OUT std::vector& foundLocations, + double hitThreshold = 0, Size winStride = Size(), + Size padding = Size(), double scale = 1.05, + double finalThreshold = 2.0, bool useMeanshiftGrouping = false) const; + + /** @brief Computes gradients and quantized gradient orientations. + @param img Matrix contains the image to be computed + @param grad Matrix of type CV_32FC2 contains computed gradients + @param angleOfs Matrix of type CV_8UC2 contains quantized gradient orientations + @param paddingTL Padding from top-left + @param paddingBR Padding from bottom-right + */ + CV_WRAP virtual void computeGradient(InputArray img, InputOutputArray grad, InputOutputArray angleOfs, + Size paddingTL = Size(), Size paddingBR = Size()) const; + + /** @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows). + */ + CV_WRAP static std::vector getDefaultPeopleDetector(); + + /**@example samples/tapi/hog.cpp + */ + /** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows). + */ + CV_WRAP static std::vector getDaimlerPeopleDetector(); + + //! Detection window size. Align to block size and block stride. Default value is Size(64,128). + CV_PROP Size winSize; + + //! Block size in pixels. Align to cell size. Default value is Size(16,16). + CV_PROP Size blockSize; + + //! Block stride. It must be a multiple of cell size. Default value is Size(8,8). + CV_PROP Size blockStride; + + //! Cell size. Default value is Size(8,8). + CV_PROP Size cellSize; + + //! Number of bins used in the calculation of histogram of gradients. Default value is 9. + CV_PROP int nbins; + + //! not documented + CV_PROP int derivAperture; + + //! Gaussian smoothing window parameter. + CV_PROP double winSigma; + + //! histogramNormType + CV_PROP HOGDescriptor::HistogramNormType histogramNormType; + + //! L2-Hys normalization method shrinkage. + CV_PROP double L2HysThreshold; + + //! Flag to specify whether the gamma correction preprocessing is required or not. + CV_PROP bool gammaCorrection; + + //! coefficients for the linear SVM classifier. + CV_PROP std::vector svmDetector; + + //! coefficients for the linear SVM classifier used when OpenCL is enabled + UMat oclSvmDetector; + + //! not documented + float free_coef; + + //! Maximum number of detection window increases. Default value is 64 + CV_PROP int nlevels; + + //! Indicates signed gradient will be used or not + CV_PROP bool signedGradient; + + /** @brief evaluate specified ROI and return confidence value for each location + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param locations Vector of Point + @param foundLocations Vector of Point where each Point is detected object's top-left point. + @param confidences confidences + @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually + it is 0 and should be specified in the detector coefficients (as the last free coefficient). But if + the free coefficient is omitted (which is allowed), you can specify it manually here + @param winStride winStride + @param padding padding + */ + virtual void detectROI(InputArray img, const std::vector &locations, + CV_OUT std::vector& foundLocations, CV_OUT std::vector& confidences, + double hitThreshold = 0, cv::Size winStride = Size(), + cv::Size padding = Size()) const; + + /** @brief evaluate specified ROI and return confidence value for each location in multiple scales + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of rectangles where each rectangle contains the detected object. + @param locations Vector of DetectionROI + @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified + in the detector coefficients (as the last free coefficient). But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. + */ + virtual void detectMultiScaleROI(InputArray img, + CV_OUT std::vector& foundLocations, + std::vector& locations, + double hitThreshold = 0, + int groupThreshold = 0) const; + + /** @brief Groups the object candidate rectangles. + @param rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.) + @param weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.) + @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. + @param eps Relative difference between sides of the rectangles to merge them into a group. + */ + void groupRectangles(std::vector& rectList, std::vector& weights, int groupThreshold, double eps) const; +}; + +class CV_EXPORTS_W QRCodeEncoder { +protected: + QRCodeEncoder(); // use ::create() +public: + virtual ~QRCodeEncoder(); + + enum EncodeMode { + MODE_AUTO = -1, + MODE_NUMERIC = 1, // 0b0001 + MODE_ALPHANUMERIC = 2, // 0b0010 + MODE_BYTE = 4, // 0b0100 + MODE_ECI = 7, // 0b0111 + MODE_KANJI = 8, // 0b1000 + MODE_STRUCTURED_APPEND = 3 // 0b0011 + }; + + enum CorrectionLevel { + CORRECT_LEVEL_L = 0, + CORRECT_LEVEL_M = 1, + CORRECT_LEVEL_Q = 2, + CORRECT_LEVEL_H = 3 + }; + + enum ECIEncodings { + ECI_UTF8 = 26 + }; + + /** @brief QR code encoder parameters. + @param version The optional version of QR code (by default - maximum possible depending on + the length of the string). + @param correction_level The optional level of error correction (by default - the lowest). + @param mode The optional encoding mode - Numeric, Alphanumeric, Byte, Kanji, ECI or Structured Append. + @param structure_number The optional number of QR codes to generate in Structured Append mode. + */ + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW int version; + CV_PROP_RW CorrectionLevel correction_level; + CV_PROP_RW EncodeMode mode; + CV_PROP_RW int structure_number; + }; + + /** @brief Constructor + @param parameters QR code encoder parameters QRCodeEncoder::Params + */ + static CV_WRAP + Ptr create(const QRCodeEncoder::Params& parameters = QRCodeEncoder::Params()); + + /** @brief Generates QR code from input string. + @param encoded_info Input string to encode. + @param qrcode Generated QR code. + */ + CV_WRAP virtual void encode(const String& encoded_info, OutputArray qrcode) = 0; + + /** @brief Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes. + @param encoded_info Input string to encode. + @param qrcodes Vector of generated QR codes. + */ + CV_WRAP virtual void encodeStructuredAppend(const String& encoded_info, OutputArrayOfArrays qrcodes) = 0; + +}; + +class CV_EXPORTS_W QRCodeDetector +{ +public: + CV_WRAP QRCodeDetector(); + ~QRCodeDetector(); + + /** @brief sets the epsilon used during the horizontal scan of QR code stop marker detection. + @param epsX Epsilon neighborhood, which allows you to determine the horizontal pattern + of the scheme 1:1:3:1:1 according to QR code standard. + */ + CV_WRAP void setEpsX(double epsX); + /** @brief sets the epsilon used during the vertical scan of QR code stop marker detection. + @param epsY Epsilon neighborhood, which allows you to determine the vertical pattern + of the scheme 1:1:3:1:1 according to QR code standard. + */ + CV_WRAP void setEpsY(double epsY); + + /** @brief Detects QR code in image and returns the quadrangle containing the code. + @param img grayscale or color (BGR) image containing (or not) QR code. + @param points Output vector of vertices of the minimum-area quadrangle containing the code. + */ + CV_WRAP bool detect(InputArray img, OutputArray points) const; + + /** @brief Decodes QR code in image once it's found by the detect() method. + + Returns UTF8-encoded output string or empty string if the code cannot be decoded. + @param img grayscale or color (BGR) image containing QR code. + @param points Quadrangle vertices found by detect() method (or some other algorithm). + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP std::string decode(InputArray img, InputArray points, OutputArray straight_qrcode = noArray()); + + /** @brief Decodes QR code on a curved surface in image once it's found by the detect() method. + + Returns UTF8-encoded output string or empty string if the code cannot be decoded. + @param img grayscale or color (BGR) image containing QR code. + @param points Quadrangle vertices found by detect() method (or some other algorithm). + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP cv::String decodeCurved(InputArray img, InputArray points, OutputArray straight_qrcode = noArray()); + + /** @brief Both detects and decodes QR code + + @param img grayscale or color (BGR) image containing QR code. + @param points optional output array of vertices of the found QR code quadrangle. Will be empty if not found. + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP std::string detectAndDecode(InputArray img, OutputArray points=noArray(), + OutputArray straight_qrcode = noArray()); + + /** @brief Both detects and decodes QR code on a curved surface + + @param img grayscale or color (BGR) image containing QR code. + @param points optional output array of vertices of the found QR code quadrangle. Will be empty if not found. + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP std::string detectAndDecodeCurved(InputArray img, OutputArray points=noArray(), + OutputArray straight_qrcode = noArray()); + + /** @brief Detects QR codes in image and returns the vector of the quadrangles containing the codes. + @param img grayscale or color (BGR) image containing (or not) QR codes. + @param points Output vector of vector of vertices of the minimum-area quadrangle containing the codes. + */ + CV_WRAP + bool detectMulti(InputArray img, OutputArray points) const; + + /** @brief Decodes QR codes in image once it's found by the detect() method. + @param img grayscale or color (BGR) image containing QR codes. + @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. + @param points vector of Quadrangle vertices found by detect() method (or some other algorithm). + @param straight_qrcode The optional output vector of images containing rectified and binarized QR codes + */ + CV_WRAP + bool decodeMulti( + InputArray img, InputArray points, + CV_OUT std::vector& decoded_info, + OutputArrayOfArrays straight_qrcode = noArray() + ) const; + + /** @brief Both detects and decodes QR codes + @param img grayscale or color (BGR) image containing QR codes. + @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. + @param points optional output vector of vertices of the found QR code quadrangles. Will be empty if not found. + @param straight_qrcode The optional output vector of images containing rectified and binarized QR codes + */ + CV_WRAP + bool detectAndDecodeMulti( + InputArray img, CV_OUT std::vector& decoded_info, + OutputArray points = noArray(), + OutputArrayOfArrays straight_qrcode = noArray() + ) const; + +protected: + struct Impl; + Ptr p; +}; + +//! @} objdetect +} + +#include "opencv2/objdetect/detection_based_tracker.hpp" +#include "opencv2/objdetect/face.hpp" + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/objdetect/detection_based_tracker.hpp b/Cigarette/OpenCV455Simple/include/opencv2/objdetect/detection_based_tracker.hpp new file mode 100644 index 0000000..18cde13 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/objdetect/detection_based_tracker.hpp @@ -0,0 +1,222 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OBJDETECT_DBT_HPP +#define OPENCV_OBJDETECT_DBT_HPP + +#include + +#include + +namespace cv +{ + +//! @addtogroup objdetect +//! @{ + +class CV_EXPORTS DetectionBasedTracker +{ + public: + struct CV_EXPORTS Parameters + { + int maxTrackLifetime; + int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0 + + Parameters(); + }; + + class IDetector + { + public: + IDetector(): + minObjSize(96, 96), + maxObjSize(INT_MAX, INT_MAX), + minNeighbours(2), + scaleFactor(1.1f) + {} + + virtual void detect(const cv::Mat& image, std::vector& objects) = 0; + + void setMinObjectSize(const cv::Size& min) + { + minObjSize = min; + } + void setMaxObjectSize(const cv::Size& max) + { + maxObjSize = max; + } + cv::Size getMinObjectSize() const + { + return minObjSize; + } + cv::Size getMaxObjectSize() const + { + return maxObjSize; + } + float getScaleFactor() + { + return scaleFactor; + } + void setScaleFactor(float value) + { + scaleFactor = value; + } + int getMinNeighbours() + { + return minNeighbours; + } + void setMinNeighbours(int value) + { + minNeighbours = value; + } + virtual ~IDetector() {} + + protected: + cv::Size minObjSize; + cv::Size maxObjSize; + int minNeighbours; + float scaleFactor; + }; + + DetectionBasedTracker(cv::Ptr mainDetector, cv::Ptr trackingDetector, const Parameters& params); + virtual ~DetectionBasedTracker(); + + virtual bool run(); + virtual void stop(); + virtual void resetTracking(); + + virtual void process(const cv::Mat& imageGray); + + bool setParameters(const Parameters& params); + const Parameters& getParameters() const; + + + typedef std::pair Object; + virtual void getObjects(std::vector& result) const; + virtual void getObjects(std::vector& result) const; + + enum ObjectStatus + { + DETECTED_NOT_SHOWN_YET, + DETECTED, + DETECTED_TEMPORARY_LOST, + WRONG_OBJECT + }; + struct ExtObject + { + int id; + cv::Rect location; + ObjectStatus status; + ExtObject(int _id, cv::Rect _location, ObjectStatus _status) + :id(_id), location(_location), status(_status) + { + } + }; + virtual void getObjects(std::vector& result) const; + + + virtual int addObject(const cv::Rect& location); //returns id of the new object + + protected: + class SeparateDetectionWork; + cv::Ptr separateDetectionWork; + friend void* workcycleObjectDetectorFunction(void* p); + + struct InnerParameters + { + int numLastPositionsToTrack; + int numStepsToWaitBeforeFirstShow; + int numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown; + int numStepsToShowWithoutDetecting; + + float coeffTrackingWindowSize; + float coeffObjectSizeToTrack; + float coeffObjectSpeedUsingInPrediction; + + InnerParameters(); + }; + Parameters parameters; + InnerParameters innerParameters; + + struct TrackedObject + { + typedef std::vector PositionsVector; + + PositionsVector lastPositions; + + int numDetectedFrames; + int numFramesNotDetected; + int id; + + TrackedObject(const cv::Rect& rect):numDetectedFrames(1), numFramesNotDetected(0) + { + lastPositions.push_back(rect); + id=getNextId(); + }; + + static int getNextId() + { + static int _id=0; + return _id++; + } + }; + + int numTrackedSteps; + std::vector trackedObjects; + + std::vector weightsPositionsSmoothing; + std::vector weightsSizesSmoothing; + + cv::Ptr cascadeForTracking; + + void updateTrackedObjects(const std::vector& detectedObjects); + cv::Rect calcTrackedObjectPositionToShow(int i) const; + cv::Rect calcTrackedObjectPositionToShow(int i, ObjectStatus& status) const; + void detectInRegion(const cv::Mat& img, const cv::Rect& r, std::vector& detectedObjectsInRegions); +}; + +//! @} objdetect + +} //end of cv namespace + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/objdetect/face.hpp b/Cigarette/OpenCV455Simple/include/opencv2/objdetect/face.hpp new file mode 100644 index 0000000..f2429c5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/objdetect/face.hpp @@ -0,0 +1,125 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_OBJDETECT_FACE_HPP +#define OPENCV_OBJDETECT_FACE_HPP + +#include + +/** @defgroup dnn_face DNN-based face detection and recognition + */ + +namespace cv +{ + +/** @brief DNN-based face detector, model download link: https://github.com/ShiqiYu/libfacedetection.train/tree/master/tasks/task1/onnx. + */ +class CV_EXPORTS_W FaceDetectorYN +{ +public: + virtual ~FaceDetectorYN() {}; + + /** @brief Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model + * + * @param input_size the size of the input image + */ + CV_WRAP virtual void setInputSize(const Size& input_size) = 0; + + CV_WRAP virtual Size getInputSize() = 0; + + /** @brief Set the score threshold to filter out bounding boxes of score less than the given value + * + * @param score_threshold threshold for filtering out bounding boxes + */ + CV_WRAP virtual void setScoreThreshold(float score_threshold) = 0; + + CV_WRAP virtual float getScoreThreshold() = 0; + + /** @brief Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value + * + * @param nms_threshold threshold for NMS operation + */ + CV_WRAP virtual void setNMSThreshold(float nms_threshold) = 0; + + CV_WRAP virtual float getNMSThreshold() = 0; + + /** @brief Set the number of bounding boxes preserved before NMS + * + * @param top_k the number of bounding boxes to preserve from top rank based on score + */ + CV_WRAP virtual void setTopK(int top_k) = 0; + + CV_WRAP virtual int getTopK() = 0; + + /** @brief A simple interface to detect face from given image + * + * @param image an image to detect + * @param faces detection results stored in a cv::Mat + */ + CV_WRAP virtual int detect(InputArray image, OutputArray faces) = 0; + + /** @brief Creates an instance of this class with given parameters + * + * @param model the path to the requested model + * @param config the path to the config file for compability, which is not requested for ONNX models + * @param input_size the size of the input image + * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value + * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value + * @param top_k keep top K bboxes before NMS + * @param backend_id the id of backend + * @param target_id the id of target device + */ + CV_WRAP static Ptr create(const String& model, + const String& config, + const Size& input_size, + float score_threshold = 0.9f, + float nms_threshold = 0.3f, + int top_k = 5000, + int backend_id = 0, + int target_id = 0); +}; + +/** @brief DNN-based face recognizer, model download link: https://drive.google.com/file/d/1ClK9WiB492c5OZFKveF3XiHCejoOxINW/view. + */ +class CV_EXPORTS_W FaceRecognizerSF +{ +public: + virtual ~FaceRecognizerSF() {}; + + /** @brief Definition of distance used for calculating the distance between two face features + */ + enum DisType { FR_COSINE=0, FR_NORM_L2=1 }; + + /** @brief Aligning image to put face on the standard position + * @param src_img input image + * @param face_box the detection result used for indicate face in input image + * @param aligned_img output aligned image + */ + CV_WRAP virtual void alignCrop(InputArray src_img, InputArray face_box, OutputArray aligned_img) const = 0; + + /** @brief Extracting face feature from aligned image + * @param aligned_img input aligned image + * @param face_feature output face feature + */ + CV_WRAP virtual void feature(InputArray aligned_img, OutputArray face_feature) = 0; + + /** @brief Calculating the distance between two face features + * @param _face_feature1 the first input feature + * @param _face_feature2 the second input feature of the same size and the same type as _face_feature1 + * @param dis_type defining the similarity with optional values "FR_OSINE" or "FR_NORM_L2" + */ + CV_WRAP virtual double match(InputArray _face_feature1, InputArray _face_feature2, int dis_type = FaceRecognizerSF::FR_COSINE) const = 0; + + /** @brief Creates an instance of this class with given parameters + * @param model the path of the onnx model used for face recognition + * @param config the path to the config file for compability, which is not requested for ONNX models + * @param backend_id the id of backend + * @param target_id the id of target device + */ + CV_WRAP static Ptr create(const String& model, const String& config, int backend_id = 0, int target_id = 0); +}; + +} // namespace cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/objdetect/objdetect.hpp b/Cigarette/OpenCV455Simple/include/opencv2/objdetect/objdetect.hpp new file mode 100644 index 0000000..3ee284f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/objdetect/objdetect.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/objdetect.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/opencv.hpp b/Cigarette/OpenCV455Simple/include/opencv2/opencv.hpp new file mode 100644 index 0000000..d17b94a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/opencv.hpp @@ -0,0 +1,95 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_ALL_HPP +#define OPENCV_ALL_HPP + +// File that defines what modules where included during the build of OpenCV +// These are purely the defines of the correct HAVE_OPENCV_modulename values +#include "opencv2/opencv_modules.hpp" + +// Then the list of defines is checked to include the correct headers +// Core library is always included --> without no OpenCV functionality available +#include "opencv2/core.hpp" + +// Then the optional modules are checked +#ifdef HAVE_OPENCV_CALIB3D +#include "opencv2/calib3d.hpp" +#endif +#ifdef HAVE_OPENCV_FEATURES2D +#include "opencv2/features2d.hpp" +#endif +#ifdef HAVE_OPENCV_DNN +#include "opencv2/dnn.hpp" +#endif +#ifdef HAVE_OPENCV_FLANN +#include "opencv2/flann.hpp" +#endif +#ifdef HAVE_OPENCV_HIGHGUI +#include "opencv2/highgui.hpp" +#endif +#ifdef HAVE_OPENCV_IMGCODECS +#include "opencv2/imgcodecs.hpp" +#endif +#ifdef HAVE_OPENCV_IMGPROC +#include "opencv2/imgproc.hpp" +#endif +#ifdef HAVE_OPENCV_ML +#include "opencv2/ml.hpp" +#endif +#ifdef HAVE_OPENCV_OBJDETECT +#include "opencv2/objdetect.hpp" +#endif +#ifdef HAVE_OPENCV_PHOTO +#include "opencv2/photo.hpp" +#endif +#ifdef HAVE_OPENCV_STITCHING +#include "opencv2/stitching.hpp" +#endif +#ifdef HAVE_OPENCV_VIDEO +#include "opencv2/video.hpp" +#endif +#ifdef HAVE_OPENCV_VIDEOIO +#include "opencv2/videoio.hpp" +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/opencv_modules.hpp b/Cigarette/OpenCV455Simple/include/opencv2/opencv_modules.hpp new file mode 100644 index 0000000..c9e24d8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/opencv_modules.hpp @@ -0,0 +1,30 @@ +/* + * ** File generated automatically, do not modify ** + * + * This file defines the list of modules available in current build configuration + * + * +*/ + +// This definition means that OpenCV is built with enabled non-free code. +// For example, patented algorithms for non-profit/non-commercial use only. +/* #undef OPENCV_ENABLE_NONFREE */ + +#define HAVE_OPENCV_CALIB3D +#define HAVE_OPENCV_CORE +#define HAVE_OPENCV_DNN +#define HAVE_OPENCV_FEATURES2D +#define HAVE_OPENCV_FLANN +#define HAVE_OPENCV_GAPI +#define HAVE_OPENCV_HIGHGUI +#define HAVE_OPENCV_IMGCODECS +#define HAVE_OPENCV_IMGPROC +#define HAVE_OPENCV_ML +#define HAVE_OPENCV_OBJDETECT +#define HAVE_OPENCV_PHOTO +#define HAVE_OPENCV_STITCHING +#define HAVE_OPENCV_VIDEO +#define HAVE_OPENCV_VIDEOIO +#define HAVE_OPENCV_WORLD + + diff --git a/Cigarette/OpenCV455Simple/include/opencv2/photo.hpp b/Cigarette/OpenCV455Simple/include/opencv2/photo.hpp new file mode 100644 index 0000000..c2e89a3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/photo.hpp @@ -0,0 +1,858 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_PHOTO_HPP +#define OPENCV_PHOTO_HPP + +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" + +/** +@defgroup photo Computational Photography + +This module includes photo processing algorithms +@{ + @defgroup photo_inpaint Inpainting + @defgroup photo_denoise Denoising + @defgroup photo_hdr HDR imaging + +This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment, +camera calibration with multiple exposures and exposure fusion. + + @defgroup photo_decolor Contrast Preserving Decolorization + +Useful links: + +http://www.cse.cuhk.edu.hk/leojia/projects/color2gray/index.html + + @defgroup photo_clone Seamless Cloning + +Useful links: + +https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp + + @defgroup photo_render Non-Photorealistic Rendering + +Useful links: + +http://www.inf.ufrgs.br/~eslgastal/DomainTransform + +https://www.learnopencv.com/non-photorealistic-rendering-using-opencv-python-c/ + + @defgroup photo_c C API +@} + */ + +namespace cv +{ + +//! @addtogroup photo +//! @{ + +//! @addtogroup photo_inpaint +//! @{ +//! the inpainting algorithm +enum +{ + INPAINT_NS = 0, //!< Use Navier-Stokes based method + INPAINT_TELEA = 1 //!< Use the algorithm proposed by Alexandru Telea @cite Telea04 +}; + +/** @brief Restores the selected region in an image using the region neighborhood. + +@param src Input 8-bit, 16-bit unsigned or 32-bit float 1-channel or 8-bit 3-channel image. +@param inpaintMask Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that +needs to be inpainted. +@param dst Output image with the same size and type as src . +@param inpaintRadius Radius of a circular neighborhood of each point inpainted that is considered +by the algorithm. +@param flags Inpainting method that could be cv::INPAINT_NS or cv::INPAINT_TELEA + +The function reconstructs the selected image area from the pixel near the area boundary. The +function may be used to remove dust and scratches from a scanned photo, or to remove undesirable +objects from still images or video. See for more details. + +@note + - An example using the inpainting technique can be found at + opencv_source_code/samples/cpp/inpaint.cpp + - (Python) An example using the inpainting technique can be found at + opencv_source_code/samples/python/inpaint.py + */ +CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask, + OutputArray dst, double inpaintRadius, int flags ); + +//! @} photo_inpaint + +//! @addtogroup photo_denoise +//! @{ + +/** @brief Perform image denoising using Non-local Means Denoising algorithm + with several computational +optimizations. Noise expected to be a gaussian white noise + +@param src Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image. +@param dst Output image with the same size and type as src . +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength. Big h value perfectly removes noise but also +removes image details, smaller h value preserves details but also preserves some noise + +This function expected to be applied to grayscale images. For colored images look at +fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored +image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting +image to CIELAB colorspace and then separately denoise L and AB components with different h +parameter. + */ +CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, float h = 3, + int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Perform image denoising using Non-local Means Denoising algorithm + with several computational +optimizations. Noise expected to be a gaussian white noise + +@param src Input 8-bit or 16-bit (only with NORM_L1) 1-channel, +2-channel, 3-channel or 4-channel image. +@param dst Output image with the same size and type as src . +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Array of parameters regulating filter strength, either one +parameter applied to all channels or one per channel in dst. Big h value +perfectly removes noise but also removes image details, smaller h +value preserves details but also preserves some noise +@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1 + +This function expected to be applied to grayscale images. For colored images look at +fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored +image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting +image to CIELAB colorspace and then separately denoise L and AB components with different h +parameter. + */ +CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, + const std::vector& h, + int templateWindowSize = 7, int searchWindowSize = 21, + int normType = NORM_L2); + +/** @brief Modification of fastNlMeansDenoising function for colored images + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src . +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly +removes noise but also removes image details, smaller h value preserves details but also preserves +some noise +@param hColor The same as h but for color components. For most images value equals 10 +will be enough to remove colored noise and do not distort colors + +The function converts image to CIELAB colorspace and then separately denoise L and AB components +with given h parameters using fastNlMeansDenoising function. + */ +CV_EXPORTS_W void fastNlMeansDenoisingColored( InputArray src, OutputArray dst, + float h = 3, float hColor = 3, + int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Modification of fastNlMeansDenoising function for images sequence where consecutive images have been +captured in small period of time. For example video. This version of the function is for grayscale +images or for manual manipulation with colorspaces. For more details see + + +@param srcImgs Input 8-bit 1-channel, 2-channel, 3-channel or +4-channel images sequence. All images should have the same type and +size. +@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence +@param temporalWindowSize Number of surrounding images to use for target image denoising. Should +be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to +imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise +srcImgs[imgToDenoiseIndex] image. +@param dst Output image with the same size and type as srcImgs images. +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength. Bigger h value +perfectly removes noise but also removes image details, smaller h +value preserves details but also preserves some noise + */ +CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst, + int imgToDenoiseIndex, int temporalWindowSize, + float h = 3, int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Modification of fastNlMeansDenoising function for images sequence where consecutive images have been +captured in small period of time. For example video. This version of the function is for grayscale +images or for manual manipulation with colorspaces. For more details see + + +@param srcImgs Input 8-bit or 16-bit (only with NORM_L1) 1-channel, +2-channel, 3-channel or 4-channel images sequence. All images should +have the same type and size. +@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence +@param temporalWindowSize Number of surrounding images to use for target image denoising. Should +be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to +imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise +srcImgs[imgToDenoiseIndex] image. +@param dst Output image with the same size and type as srcImgs images. +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Array of parameters regulating filter strength, either one +parameter applied to all channels or one per channel in dst. Big h value +perfectly removes noise but also removes image details, smaller h +value preserves details but also preserves some noise +@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1 + */ +CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst, + int imgToDenoiseIndex, int temporalWindowSize, + const std::vector& h, + int templateWindowSize = 7, int searchWindowSize = 21, + int normType = NORM_L2); + +/** @brief Modification of fastNlMeansDenoisingMulti function for colored images sequences + +@param srcImgs Input 8-bit 3-channel images sequence. All images should have the same type and +size. +@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence +@param temporalWindowSize Number of surrounding images to use for target image denoising. Should +be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to +imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise +srcImgs[imgToDenoiseIndex] image. +@param dst Output image with the same size and type as srcImgs images. +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly +removes noise but also removes image details, smaller h value preserves details but also preserves +some noise. +@param hColor The same as h but for color components. + +The function converts images to CIELAB colorspace and then separately denoise L and AB components +with given h parameters using fastNlMeansDenoisingMulti function. + */ +CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs, OutputArray dst, + int imgToDenoiseIndex, int temporalWindowSize, + float h = 3, float hColor = 3, + int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Primal-dual algorithm is an algorithm for solving special types of variational problems (that is, +finding a function to minimize some functional). As the image denoising, in particular, may be seen +as the variational problem, primal-dual algorithm then can be used to perform denoising and this is +exactly what is implemented. + +It should be noted, that this implementation was taken from the July 2013 blog entry +@cite MA13 , which also contained (slightly more general) ready-to-use source code on Python. +Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end +of July 2013 and finally it was slightly adapted by later authors. + +Although the thorough discussion and justification of the algorithm involved may be found in +@cite ChambolleEtAl, it might make sense to skim over it here, following @cite MA13 . To begin +with, we consider the 1-byte gray-level images as the functions from the rectangular domain of +pixels (it may be seen as set +\f$\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\f$ for some +\f$m,\;n\in\mathbb{N}\f$) into \f$\{0,1,\dots,255\}\f$. We shall denote the noised images as \f$f_i\f$ and with +this view, given some image \f$x\f$ of the same size, we may measure how bad it is by the formula + +\f[\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\f] + +\f$\|\|\cdot\|\|\f$ here denotes \f$L_2\f$-norm and as you see, the first addend states that we want our +image to be smooth (ideally, having zero gradient, thus being constant) and the second states that +we want our result to be close to the observations we've got. If we treat \f$x\f$ as a function, this is +exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play. + +@param observations This array should contain one or more noised versions of the image that is to +be restored. +@param result Here the denoised image will be stored. There is no need to do pre-allocation of +storage space, as it will be automatically allocated, if necessary. +@param lambda Corresponds to \f$\lambda\f$ in the formulas above. As it is enlarged, the smooth +(blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly +speaking, as it becomes smaller, the result will be more blur but more sever outliers will be +removed. +@param niters Number of iterations that the algorithm will run. Of course, as more iterations as +better, but it is hard to quantitatively refine this statement, so just use the default and +increase it if the results are poor. + */ +CV_EXPORTS_W void denoise_TVL1(const std::vector& observations,Mat& result, double lambda=1.0, int niters=30); + +//! @} photo_denoise + +//! @addtogroup photo_hdr +//! @{ + +enum { LDR_SIZE = 256 }; + +/** @brief Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range. + */ +class CV_EXPORTS_W Tonemap : public Algorithm +{ +public: + /** @brief Tonemaps image + + @param src source image - CV_32FC3 Mat (float 32 bits 3 channels) + @param dst destination image - CV_32FC3 Mat with values in [0, 1] range + */ + CV_WRAP virtual void process(InputArray src, OutputArray dst) = 0; + + CV_WRAP virtual float getGamma() const = 0; + CV_WRAP virtual void setGamma(float gamma) = 0; +}; + +/** @brief Creates simple linear mapper with gamma correction + +@param gamma positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma +equal to 2.2f is suitable for most displays. +Generally gamma \> 1 brightens the image and gamma \< 1 darkens it. + */ +CV_EXPORTS_W Ptr createTonemap(float gamma = 1.0f); + +/** @brief Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in +logarithmic domain. + +Since it's a global operator the same function is applied to all the pixels, it is controlled by the +bias parameter. + +Optional saturation enhancement is possible as described in @cite FL02 . + +For more information see @cite DM03 . + */ +class CV_EXPORTS_W TonemapDrago : public Tonemap +{ +public: + + CV_WRAP virtual float getSaturation() const = 0; + CV_WRAP virtual void setSaturation(float saturation) = 0; + + CV_WRAP virtual float getBias() const = 0; + CV_WRAP virtual void setBias(float bias) = 0; +}; + +/** @brief Creates TonemapDrago object + +@param gamma gamma value for gamma correction. See createTonemap +@param saturation positive saturation enhancement value. 1.0 preserves saturation, values greater +than 1 increase saturation and values less than 1 decrease it. +@param bias value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best +results, default value is 0.85. + */ +CV_EXPORTS_W Ptr createTonemapDrago(float gamma = 1.0f, float saturation = 1.0f, float bias = 0.85f); + + +/** @brief This is a global tonemapping operator that models human visual system. + +Mapping function is controlled by adaptation parameter, that is computed using light adaptation and +color adaptation. + +For more information see @cite RD05 . + */ +class CV_EXPORTS_W TonemapReinhard : public Tonemap +{ +public: + CV_WRAP virtual float getIntensity() const = 0; + CV_WRAP virtual void setIntensity(float intensity) = 0; + + CV_WRAP virtual float getLightAdaptation() const = 0; + CV_WRAP virtual void setLightAdaptation(float light_adapt) = 0; + + CV_WRAP virtual float getColorAdaptation() const = 0; + CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0; +}; + +/** @brief Creates TonemapReinhard object + +@param gamma gamma value for gamma correction. See createTonemap +@param intensity result intensity in [-8, 8] range. Greater intensity produces brighter results. +@param light_adapt light adaptation in [0, 1] range. If 1 adaptation is based only on pixel +value, if 0 it's global, otherwise it's a weighted mean of this two cases. +@param color_adapt chromatic adaptation in [0, 1] range. If 1 channels are treated independently, +if 0 adaptation level is the same for each channel. + */ +CV_EXPORTS_W Ptr +createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f); + +/** @brief This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid, +transforms contrast values to HVS response and scales the response. After this the image is +reconstructed from new contrast values. + +For more information see @cite MM06 . + */ +class CV_EXPORTS_W TonemapMantiuk : public Tonemap +{ +public: + CV_WRAP virtual float getScale() const = 0; + CV_WRAP virtual void setScale(float scale) = 0; + + CV_WRAP virtual float getSaturation() const = 0; + CV_WRAP virtual void setSaturation(float saturation) = 0; +}; + +/** @brief Creates TonemapMantiuk object + +@param gamma gamma value for gamma correction. See createTonemap +@param scale contrast scale factor. HVS response is multiplied by this parameter, thus compressing +dynamic range. Values from 0.6 to 0.9 produce best results. +@param saturation saturation enhancement value. See createTonemapDrago + */ +CV_EXPORTS_W Ptr +createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f); + +/** @brief The base class for algorithms that align images of the same scene with different exposures + */ +class CV_EXPORTS_W AlignExposures : public Algorithm +{ +public: + /** @brief Aligns images + + @param src vector of input images + @param dst vector of aligned images + @param times vector of exposure time values for each image + @param response 256x1 matrix with inverse camera response function for each pixel value, it should + have the same number of channels as images. + */ + CV_WRAP virtual void process(InputArrayOfArrays src, std::vector& dst, + InputArray times, InputArray response) = 0; +}; + +/** @brief This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median +luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations. + +It is invariant to exposure, so exposure values and camera response are not necessary. + +In this implementation new image regions are filled with zeros. + +For more information see @cite GW03 . + */ +class CV_EXPORTS_W AlignMTB : public AlignExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, std::vector& dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + + /** @brief Short version of process, that doesn't take extra arguments. + + @param src vector of input images + @param dst vector of aligned images + */ + CV_WRAP virtual void process(InputArrayOfArrays src, std::vector& dst) = 0; + + /** @brief Calculates shift between two images, i. e. how to shift the second image to correspond it with the + first. + + @param img0 first image + @param img1 second image + */ + CV_WRAP virtual Point calculateShift(InputArray img0, InputArray img1) = 0; + /** @brief Helper function, that shift Mat filling new regions with zeros. + + @param src input image + @param dst result image + @param shift shift value + */ + CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0; + /** @brief Computes median threshold and exclude bitmaps of given image. + + @param img input image + @param tb median threshold bitmap + @param eb exclude bitmap + */ + CV_WRAP virtual void computeBitmaps(InputArray img, OutputArray tb, OutputArray eb) = 0; + + CV_WRAP virtual int getMaxBits() const = 0; + CV_WRAP virtual void setMaxBits(int max_bits) = 0; + + CV_WRAP virtual int getExcludeRange() const = 0; + CV_WRAP virtual void setExcludeRange(int exclude_range) = 0; + + CV_WRAP virtual bool getCut() const = 0; + CV_WRAP virtual void setCut(bool value) = 0; +}; + +/** @brief Creates AlignMTB object + +@param max_bits logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are +usually good enough (31 and 63 pixels shift respectively). +@param exclude_range range for exclusion bitmap that is constructed to suppress noise around the +median value. +@param cut if true cuts images, otherwise fills the new regions with zeros. + */ +CV_EXPORTS_W Ptr createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true); + +/** @brief The base class for camera response calibration algorithms. + */ +class CV_EXPORTS_W CalibrateCRF : public Algorithm +{ +public: + /** @brief Recovers inverse camera response. + + @param src vector of input images + @param dst 256x1 matrix with inverse camera response function + @param times vector of exposure time values for each image + */ + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0; +}; + +/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective +function as linear system. Objective function is constructed using pixel values on the same position +in all images, extra term is added to make the result smoother. + +For more information see @cite DM97 . + */ +class CV_EXPORTS_W CalibrateDebevec : public CalibrateCRF +{ +public: + CV_WRAP virtual float getLambda() const = 0; + CV_WRAP virtual void setLambda(float lambda) = 0; + + CV_WRAP virtual int getSamples() const = 0; + CV_WRAP virtual void setSamples(int samples) = 0; + + CV_WRAP virtual bool getRandom() const = 0; + CV_WRAP virtual void setRandom(bool random) = 0; +}; + +/** @brief Creates CalibrateDebevec object + +@param samples number of pixel locations to use +@param lambda smoothness term weight. Greater values produce smoother results, but can alter the +response. +@param random if true sample pixel locations are chosen at random, otherwise they form a +rectangular grid. + */ +CV_EXPORTS_W Ptr createCalibrateDebevec(int samples = 70, float lambda = 10.0f, bool random = false); + +/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective +function as linear system. This algorithm uses all image pixels. + +For more information see @cite RB99 . + */ +class CV_EXPORTS_W CalibrateRobertson : public CalibrateCRF +{ +public: + CV_WRAP virtual int getMaxIter() const = 0; + CV_WRAP virtual void setMaxIter(int max_iter) = 0; + + CV_WRAP virtual float getThreshold() const = 0; + CV_WRAP virtual void setThreshold(float threshold) = 0; + + CV_WRAP virtual Mat getRadiance() const = 0; +}; + +/** @brief Creates CalibrateRobertson object + +@param max_iter maximal number of Gauss-Seidel solver iterations. +@param threshold target difference between results of two successive steps of the minimization. + */ +CV_EXPORTS_W Ptr createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f); + +/** @brief The base class algorithms that can merge exposure sequence to a single image. + */ +class CV_EXPORTS_W MergeExposures : public Algorithm +{ +public: + /** @brief Merges images. + + @param src vector of input images + @param dst result image + @param times vector of exposure time values for each image + @param response 256x1 matrix with inverse camera response function for each pixel value, it should + have the same number of channels as images. + */ + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) = 0; +}; + +/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure +values and camera response. + +For more information see @cite DM97 . + */ +class CV_EXPORTS_W MergeDebevec : public MergeExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0; +}; + +/** @brief Creates MergeDebevec object + */ +CV_EXPORTS_W Ptr createMergeDebevec(); + +/** @brief Pixels are weighted using contrast, saturation and well-exposedness measures, than images are +combined using laplacian pyramids. + +The resulting image weight is constructed as weighted average of contrast, saturation and +well-exposedness measures. + +The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying +by 255, but it's recommended to apply gamma correction and/or linear tonemapping. + +For more information see @cite MK07 . + */ +class CV_EXPORTS_W MergeMertens : public MergeExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + /** @brief Short version of process, that doesn't take extra arguments. + + @param src vector of input images + @param dst result image + */ + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0; + + CV_WRAP virtual float getContrastWeight() const = 0; + CV_WRAP virtual void setContrastWeight(float contrast_weiht) = 0; + + CV_WRAP virtual float getSaturationWeight() const = 0; + CV_WRAP virtual void setSaturationWeight(float saturation_weight) = 0; + + CV_WRAP virtual float getExposureWeight() const = 0; + CV_WRAP virtual void setExposureWeight(float exposure_weight) = 0; +}; + +/** @brief Creates MergeMertens object + +@param contrast_weight contrast measure weight. See MergeMertens. +@param saturation_weight saturation measure weight +@param exposure_weight well-exposedness measure weight + */ +CV_EXPORTS_W Ptr +createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f); + +/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure +values and camera response. + +For more information see @cite RB99 . + */ +class CV_EXPORTS_W MergeRobertson : public MergeExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0; +}; + +/** @brief Creates MergeRobertson object + */ +CV_EXPORTS_W Ptr createMergeRobertson(); + +//! @} photo_hdr + +//! @addtogroup photo_decolor +//! @{ + +/** @brief Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized +black-and-white photograph rendering, and in many single channel image processing applications +@cite CL12 . + +@param src Input 8-bit 3-channel image. +@param grayscale Output 8-bit 1-channel image. +@param color_boost Output 8-bit 3-channel image. + +This function is to be applied on color images. + */ +CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray color_boost); + +//! @} photo_decolor + +//! @addtogroup photo_clone +//! @{ + + +//! seamlessClone algorithm flags +enum +{ + /** The power of the method is fully expressed when inserting objects with complex outlines into a new background*/ + NORMAL_CLONE = 1, + /** The classic method, color-based selection and alpha masking might be time consuming and often leaves an undesirable + halo. Seamless cloning, even averaged with the original image, is not effective. Mixed seamless cloning based on a loose selection proves effective.*/ + MIXED_CLONE = 2, + /** Monochrome transfer allows the user to easily replace certain features of one object by alternative features.*/ + MONOCHROME_TRANSFER = 3}; + + +/** @example samples/cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp +An example using seamlessClone function +*/ +/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters, +deformations) or local changes concerned to a selection. Here we are interested in achieving local +changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless +manner. The extent of the changes ranges from slight distortions to complete replacement by novel +content @cite PM03 . + +@param src Input 8-bit 3-channel image. +@param dst Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param p Point in dst image where object is placed. +@param blend Output image with the same size and type as dst. +@param flags Cloning method that could be cv::NORMAL_CLONE, cv::MIXED_CLONE or cv::MONOCHROME_TRANSFER + */ +CV_EXPORTS_W void seamlessClone( InputArray src, InputArray dst, InputArray mask, Point p, + OutputArray blend, int flags); + +/** @brief Given an original color image, two differently colored versions of this image can be mixed +seamlessly. + +@param src Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param dst Output image with the same size and type as src . +@param red_mul R-channel multiply factor. +@param green_mul G-channel multiply factor. +@param blue_mul B-channel multiply factor. + +Multiplication factor is between .5 to 2.5. + */ +CV_EXPORTS_W void colorChange(InputArray src, InputArray mask, OutputArray dst, float red_mul = 1.0f, + float green_mul = 1.0f, float blue_mul = 1.0f); + +/** @brief Applying an appropriate non-linear transformation to the gradient field inside the selection and +then integrating back with a Poisson solver, modifies locally the apparent illumination of an image. + +@param src Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param dst Output image with the same size and type as src. +@param alpha Value ranges between 0-2. +@param beta Value ranges between 0-2. + +This is useful to highlight under-exposed foreground objects or to reduce specular reflections. + */ +CV_EXPORTS_W void illuminationChange(InputArray src, InputArray mask, OutputArray dst, + float alpha = 0.2f, float beta = 0.4f); + +/** @brief By retaining only the gradients at edge locations, before integrating with the Poisson solver, one +washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used. + +@param src Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param dst Output image with the same size and type as src. +@param low_threshold %Range from 0 to 100. +@param high_threshold Value \> 100. +@param kernel_size The size of the Sobel kernel to be used. + +@note +The algorithm assumes that the color of the source image is close to that of the destination. This +assumption means that when the colors don't match, the source image color gets tinted toward the +color of the destination image. + */ +CV_EXPORTS_W void textureFlattening(InputArray src, InputArray mask, OutputArray dst, + float low_threshold = 30, float high_threshold = 45, + int kernel_size = 3); + +//! @} photo_clone + +//! @addtogroup photo_render +//! @{ + +//! Edge preserving filters +enum +{ + RECURS_FILTER = 1, //!< Recursive Filtering + NORMCONV_FILTER = 2 //!< Normalized Convolution Filtering +}; + +/** @brief Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing +filters are used in many different applications @cite EM11 . + +@param src Input 8-bit 3-channel image. +@param dst Output 8-bit 3-channel image. +@param flags Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. + */ +CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flags = 1, + float sigma_s = 60, float sigma_r = 0.4f); + +/** @brief This filter enhances the details of a particular image. + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. + */ +CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10, + float sigma_r = 0.15f); + +/** @example samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp +An example using non-photorealistic line drawing functions +*/ +/** @brief Pencil-like non-photorealistic line drawing + +@param src Input 8-bit 3-channel image. +@param dst1 Output 8-bit 1-channel image. +@param dst2 Output image with the same size and type as src. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. +@param shade_factor %Range between 0 to 0.1. + */ +CV_EXPORTS_W void pencilSketch(InputArray src, OutputArray dst1, OutputArray dst2, + float sigma_s = 60, float sigma_r = 0.07f, float shade_factor = 0.02f); + +/** @brief Stylization aims to produce digital imagery with a wide variety of effects not focused on +photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low +contrast while preserving, or enhancing, high-contrast features. + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. + */ +CV_EXPORTS_W void stylization(InputArray src, OutputArray dst, float sigma_s = 60, + float sigma_r = 0.45f); + +//! @} photo_render + +//! @} photo + +} // cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/photo/cuda.hpp b/Cigarette/OpenCV455Simple/include/opencv2/photo/cuda.hpp new file mode 100644 index 0000000..a2f3816 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/photo/cuda.hpp @@ -0,0 +1,132 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_PHOTO_CUDA_HPP +#define OPENCV_PHOTO_CUDA_HPP + +#include "opencv2/core/cuda.hpp" + +namespace cv { namespace cuda { + +//! @addtogroup photo_denoise +//! @{ + +/** @brief Performs pure non local means denoising without any simplification, and thus it is not fast. + +@param src Source image. Supports only CV_8UC1, CV_8UC2 and CV_8UC3. +@param dst Destination image. +@param h Filter sigma regulating filter strength for color. +@param search_window Size of search window. +@param block_size Size of block used for computing weights. +@param borderMode Border type. See borderInterpolate for details. BORDER_REFLECT101 , +BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now. +@param stream Stream for the asynchronous version. + +@sa + fastNlMeansDenoising + */ +CV_EXPORTS void nonLocalMeans(InputArray src, OutputArray dst, + float h, + int search_window = 21, + int block_size = 7, + int borderMode = BORDER_DEFAULT, + Stream& stream = Stream::Null()); + +/** @brief Perform image denoising using Non-local Means Denoising algorithm + with several computational +optimizations. Noise expected to be a gaussian white noise + +@param src Input 8-bit 1-channel, 2-channel or 3-channel image. +@param dst Output image with the same size and type as src . +@param h Parameter regulating filter strength. Big h value perfectly removes noise but also +removes image details, smaller h value preserves details but also preserves some noise +@param search_window Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater search_window - greater +denoising time. Recommended value 21 pixels +@param block_size Size in pixels of the template patch that is used to compute weights. Should be +odd. Recommended value 7 pixels +@param stream Stream for the asynchronous invocations. + +This function expected to be applied to grayscale images. For colored images look at +FastNonLocalMeansDenoising::labMethod. + +@sa + fastNlMeansDenoising + */ +CV_EXPORTS void fastNlMeansDenoising(InputArray src, OutputArray dst, + float h, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()); + +/** @brief Modification of fastNlMeansDenoising function for colored images + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src . +@param h_luminance Parameter regulating filter strength. Big h value perfectly removes noise but +also removes image details, smaller h value preserves details but also preserves some noise +@param photo_render float The same as h but for color components. For most images value equals 10 will be +enough to remove colored noise and do not distort colors +@param search_window Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater search_window - greater +denoising time. Recommended value 21 pixels +@param block_size Size in pixels of the template patch that is used to compute weights. Should be +odd. Recommended value 7 pixels +@param stream Stream for the asynchronous invocations. + +The function converts image to CIELAB colorspace and then separately denoise L and AB components +with given h parameters using FastNonLocalMeansDenoising::simpleMethod function. + +@sa + fastNlMeansDenoisingColored + */ +CV_EXPORTS void fastNlMeansDenoisingColored(InputArray src, OutputArray dst, + float h_luminance, float photo_render, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()); + +//! @} photo + +}} // namespace cv { namespace cuda { + +#endif /* OPENCV_PHOTO_CUDA_HPP */ diff --git a/Cigarette/OpenCV455Simple/include/opencv2/photo/legacy/constants_c.h b/Cigarette/OpenCV455Simple/include/opencv2/photo/legacy/constants_c.h new file mode 100644 index 0000000..ec1d440 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/photo/legacy/constants_c.h @@ -0,0 +1,14 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_PHOTO_LEGACY_CONSTANTS_H +#define OPENCV_PHOTO_LEGACY_CONSTANTS_H + +enum InpaintingModes +{ + CV_INPAINT_NS =0, + CV_INPAINT_TELEA =1 +}; + +#endif // OPENCV_PHOTO_LEGACY_CONSTANTS_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/photo/photo.hpp b/Cigarette/OpenCV455Simple/include/opencv2/photo/photo.hpp new file mode 100644 index 0000000..8af5e9f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/photo/photo.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/photo.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching.hpp new file mode 100644 index 0000000..fb0ebe9 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching.hpp @@ -0,0 +1,357 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_STITCHER_HPP +#define OPENCV_STITCHING_STITCHER_HPP + +#include "opencv2/core.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/stitching/warpers.hpp" +#include "opencv2/stitching/detail/matchers.hpp" +#include "opencv2/stitching/detail/motion_estimators.hpp" +#include "opencv2/stitching/detail/exposure_compensate.hpp" +#include "opencv2/stitching/detail/seam_finders.hpp" +#include "opencv2/stitching/detail/blenders.hpp" +#include "opencv2/stitching/detail/camera.hpp" + + +#if defined(Status) +# warning Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers. +#endif + + +/** +@defgroup stitching Images stitching + +This figure illustrates the stitching module pipeline implemented in the Stitcher class. Using that +class it's possible to configure/remove some steps, i.e. adjust the stitching pipeline according to +the particular needs. All building blocks from the pipeline are available in the detail namespace, +one can combine and use them separately. + +The implemented stitching pipeline is very similar to the one proposed in @cite BL07 . + +![stitching pipeline](StitchingPipeline.jpg) + +Camera models +------------- + +There are currently 2 camera models implemented in stitching pipeline. + +- _Homography model_ expecting perspective transformations between images + implemented in @ref cv::detail::BestOf2NearestMatcher cv::detail::HomographyBasedEstimator + cv::detail::BundleAdjusterReproj cv::detail::BundleAdjusterRay +- _Affine model_ expecting affine transformation with 6 DOF or 4 DOF implemented in + @ref cv::detail::AffineBestOf2NearestMatcher cv::detail::AffineBasedEstimator + cv::detail::BundleAdjusterAffine cv::detail::BundleAdjusterAffinePartial cv::AffineWarper + +Homography model is useful for creating photo panoramas captured by camera, +while affine-based model can be used to stitch scans and object captured by +specialized devices. Use @ref cv::Stitcher::create to get preconfigured pipeline for one +of those models. + +@note +Certain detailed settings of @ref cv::Stitcher might not make sense. Especially +you should not mix classes implementing affine model and classes implementing +Homography model, as they work with different transformations. + +@{ + @defgroup stitching_match Features Finding and Images Matching + @defgroup stitching_rotation Rotation Estimation + @defgroup stitching_autocalib Autocalibration + @defgroup stitching_warp Images Warping + @defgroup stitching_seam Seam Estimation + @defgroup stitching_exposure Exposure Compensation + @defgroup stitching_blend Image Blenders +@} + */ + +namespace cv { + +//! @addtogroup stitching +//! @{ + +/** @example samples/cpp/stitching.cpp +A basic example on image stitching +*/ + +/** @example samples/python/stitching.py +A basic example on image stitching in Python. +*/ + +/** @example samples/cpp/stitching_detailed.cpp +A detailed example on image stitching +*/ + +/** @brief High level image stitcher. + +It's possible to use this class without being aware of the entire stitching pipeline. However, to +be able to achieve higher stitching stability and quality of the final images at least being +familiar with the theory is recommended. + +@note +- A basic example on image stitching can be found at + opencv_source_code/samples/cpp/stitching.cpp +- A basic example on image stitching in Python can be found at + opencv_source_code/samples/python/stitching.py +- A detailed example on image stitching can be found at + opencv_source_code/samples/cpp/stitching_detailed.cpp + */ +class CV_EXPORTS_W Stitcher +{ +public: + /** + * When setting a resolution for stitching, this values is a placeholder + * for preserving the original resolution. + */ +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) + static constexpr double ORIG_RESOL = -1.0; +#else + // support MSVS 2013 + static const double ORIG_RESOL; // Initialized in stitcher.cpp +#endif + + enum Status + { + OK = 0, + ERR_NEED_MORE_IMGS = 1, + ERR_HOMOGRAPHY_EST_FAIL = 2, + ERR_CAMERA_PARAMS_ADJUST_FAIL = 3 + }; + + enum Mode + { + /** Mode for creating photo panoramas. Expects images under perspective + transformation and projects resulting pano to sphere. + + @sa detail::BestOf2NearestMatcher SphericalWarper + */ + PANORAMA = 0, + /** Mode for composing scans. Expects images under affine transformation does + not compensate exposure by default. + + @sa detail::AffineBestOf2NearestMatcher AffineWarper + */ + SCANS = 1, + + }; + + /** @brief Creates a Stitcher configured in one of the stitching modes. + + @param mode Scenario for stitcher operation. This is usually determined by source of images + to stitch and their transformation. Default parameters will be chosen for operation in given + scenario. + @return Stitcher class instance. + */ + CV_WRAP static Ptr create(Mode mode = Stitcher::PANORAMA); + + CV_WRAP double registrationResol() const { return registr_resol_; } + CV_WRAP void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; } + + CV_WRAP double seamEstimationResol() const { return seam_est_resol_; } + CV_WRAP void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; } + + CV_WRAP double compositingResol() const { return compose_resol_; } + CV_WRAP void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; } + + CV_WRAP double panoConfidenceThresh() const { return conf_thresh_; } + CV_WRAP void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } + + CV_WRAP bool waveCorrection() const { return do_wave_correct_; } + CV_WRAP void setWaveCorrection(bool flag) { do_wave_correct_ = flag; } + + CV_WRAP InterpolationFlags interpolationFlags() const { return interp_flags_; } + CV_WRAP void setInterpolationFlags(InterpolationFlags interp_flags) { interp_flags_ = interp_flags; } + + detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; } + void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; } + + Ptr featuresFinder() { return features_finder_; } + const Ptr featuresFinder() const { return features_finder_; } + void setFeaturesFinder(Ptr features_finder) + { features_finder_ = features_finder; } + + Ptr featuresMatcher() { return features_matcher_; } + const Ptr featuresMatcher() const { return features_matcher_; } + void setFeaturesMatcher(Ptr features_matcher) + { features_matcher_ = features_matcher; } + + const cv::UMat& matchingMask() const { return matching_mask_; } + void setMatchingMask(const cv::UMat &mask) + { + CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows); + matching_mask_ = mask.clone(); + } + + Ptr bundleAdjuster() { return bundle_adjuster_; } + const Ptr bundleAdjuster() const { return bundle_adjuster_; } + void setBundleAdjuster(Ptr bundle_adjuster) + { bundle_adjuster_ = bundle_adjuster; } + + Ptr estimator() { return estimator_; } + const Ptr estimator() const { return estimator_; } + void setEstimator(Ptr estimator) + { estimator_ = estimator; } + + Ptr warper() { return warper_; } + const Ptr warper() const { return warper_; } + void setWarper(Ptr creator) { warper_ = creator; } + + Ptr exposureCompensator() { return exposure_comp_; } + const Ptr exposureCompensator() const { return exposure_comp_; } + void setExposureCompensator(Ptr exposure_comp) + { exposure_comp_ = exposure_comp; } + + Ptr seamFinder() { return seam_finder_; } + const Ptr seamFinder() const { return seam_finder_; } + void setSeamFinder(Ptr seam_finder) { seam_finder_ = seam_finder; } + + Ptr blender() { return blender_; } + const Ptr blender() const { return blender_; } + void setBlender(Ptr b) { blender_ = b; } + + /** @brief These functions try to match the given images and to estimate rotations of each camera. + + @note Use the functions only if you're aware of the stitching pipeline, otherwise use + Stitcher::stitch. + + @param images Input images. + @param masks Masks for each input image specifying where to look for keypoints (optional). + @return Status code. + */ + CV_WRAP Status estimateTransform(InputArrayOfArrays images, InputArrayOfArrays masks = noArray()); + + /** @brief These function restors camera rotation and camera intrinsics of each camera + * that can be got with @ref Stitcher::cameras call + + @param images Input images. + @param cameras Estimated rotation of cameras for each of the input images. + @param component Indices (0-based) of images constituting the final panorama (optional). + @return Status code. + */ + Status setTransform(InputArrayOfArrays images, + const std::vector &cameras, + const std::vector &component); + /** @overload */ + Status setTransform(InputArrayOfArrays images, const std::vector &cameras); + + /** @overload */ + CV_WRAP Status composePanorama(OutputArray pano); + /** @brief These functions try to compose the given images (or images stored internally from the other function + calls) into the final pano under the assumption that the image transformations were estimated + before. + + @note Use the functions only if you're aware of the stitching pipeline, otherwise use + Stitcher::stitch. + + @param images Input images. + @param pano Final pano. + @return Status code. + */ + CV_WRAP Status composePanorama(InputArrayOfArrays images, OutputArray pano); + + /** @overload */ + CV_WRAP Status stitch(InputArrayOfArrays images, OutputArray pano); + /** @brief These functions try to stitch the given images. + + @param images Input images. + @param masks Masks for each input image specifying where to look for keypoints (optional). + @param pano Final pano. + @return Status code. + */ + CV_WRAP Status stitch(InputArrayOfArrays images, InputArrayOfArrays masks, OutputArray pano); + + std::vector component() const { return indices_; } + std::vector cameras() const { return cameras_; } + CV_WRAP double workScale() const { return work_scale_; } + UMat resultMask() const { return result_mask_; } + +private: + Status matchImages(); + Status estimateCameraParams(); + + double registr_resol_; + double seam_est_resol_; + double compose_resol_; + double conf_thresh_; + InterpolationFlags interp_flags_; + Ptr features_finder_; + Ptr features_matcher_; + cv::UMat matching_mask_; + Ptr bundle_adjuster_; + Ptr estimator_; + bool do_wave_correct_; + detail::WaveCorrectKind wave_correct_kind_; + Ptr warper_; + Ptr exposure_comp_; + Ptr seam_finder_; + Ptr blender_; + + std::vector imgs_; + std::vector masks_; + std::vector full_img_sizes_; + std::vector features_; + std::vector pairwise_matches_; + std::vector seam_est_imgs_; + std::vector indices_; + std::vector cameras_; + UMat result_mask_; + double work_scale_; + double seam_scale_; + double seam_work_aspect_; + double warped_image_scale_; +}; + +/** + * @deprecated use Stitcher::create + */ +CV_DEPRECATED Ptr createStitcher(bool try_use_gpu = false); + +/** + * @deprecated use Stitcher::create + */ +CV_DEPRECATED Ptr createStitcherScans(bool try_use_gpu = false); + +//! @} stitching + +} // namespace cv + +#endif // OPENCV_STITCHING_STITCHER_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/autocalib.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/autocalib.hpp new file mode 100644 index 0000000..8eb6212 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/autocalib.hpp @@ -0,0 +1,86 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_AUTOCALIB_HPP +#define OPENCV_STITCHING_AUTOCALIB_HPP + +#include "opencv2/core.hpp" +#include "matchers.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_autocalib +//! @{ + +/** @brief Tries to estimate focal lengths from the given homography under the assumption that the camera +undergoes rotations around its centre only. + +@param H Homography. +@param f0 Estimated focal length along X axis. +@param f1 Estimated focal length along Y axis. +@param f0_ok True, if f0 was estimated successfully, false otherwise. +@param f1_ok True, if f1 was estimated successfully, false otherwise. + +See "Construction of Panoramic Image Mosaics with Global and Local Alignment" +by Heung-Yeung Shum and Richard Szeliski. + */ +void CV_EXPORTS_W focalsFromHomography(const Mat &H, double &f0, double &f1, bool &f0_ok, bool &f1_ok); + +/** @brief Estimates focal lengths for each given camera. + +@param features Features of images. +@param pairwise_matches Matches between all image pairs. +@param focals Estimated focal lengths for each camera. + */ +void CV_EXPORTS estimateFocal(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &focals); + +bool CV_EXPORTS_W calibrateRotatingCamera(const std::vector &Hs,CV_OUT Mat &K); + +//! @} stitching_autocalib + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_AUTOCALIB_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/blenders.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/blenders.hpp new file mode 100644 index 0000000..ec35aa7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/blenders.hpp @@ -0,0 +1,184 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_BLENDERS_HPP +#define OPENCV_STITCHING_BLENDERS_HPP + +#if defined(NO) +# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers. +#endif + +#include "opencv2/core.hpp" +#include "opencv2/core/cuda.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_blend +//! @{ + +/** @brief Base class for all blenders. + +Simple blender which puts one image over another +*/ +class CV_EXPORTS_W Blender +{ +public: + virtual ~Blender() {} + + enum { NO, FEATHER, MULTI_BAND }; + CV_WRAP static Ptr createDefault(int type, bool try_gpu = false); + + /** @brief Prepares the blender for blending. + + @param corners Source images top-left corners + @param sizes Source image sizes + */ + CV_WRAP virtual void prepare(const std::vector &corners, const std::vector &sizes); + /** @overload */ + CV_WRAP virtual void prepare(Rect dst_roi); + /** @brief Processes the image. + + @param img Source image + @param mask Source image mask + @param tl Source image top-left corners + */ + CV_WRAP virtual void feed(InputArray img, InputArray mask, Point tl); + /** @brief Blends and returns the final pano. + + @param dst Final pano + @param dst_mask Final pano mask + */ + CV_WRAP virtual void blend(CV_IN_OUT InputOutputArray dst,CV_IN_OUT InputOutputArray dst_mask); + +protected: + UMat dst_, dst_mask_; + Rect dst_roi_; +}; + +/** @brief Simple blender which mixes images at its borders. + */ +class CV_EXPORTS_W FeatherBlender : public Blender +{ +public: + CV_WRAP FeatherBlender(float sharpness = 0.02f); + + CV_WRAP float sharpness() const { return sharpness_; } + CV_WRAP void setSharpness(float val) { sharpness_ = val; } + + CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE; + CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE; + CV_WRAP void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE; + + //! Creates weight maps for fixed set of source images by their masks and top-left corners. + //! Final image can be obtained by simple weighting of the source images. + CV_WRAP Rect createWeightMaps(const std::vector &masks, const std::vector &corners, + CV_IN_OUT std::vector &weight_maps); + +private: + float sharpness_; + UMat weight_map_; + UMat dst_weight_map_; +}; + +inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); } + +/** @brief Blender which uses multi-band blending algorithm (see @cite BA83). + */ +class CV_EXPORTS_W MultiBandBlender : public Blender +{ +public: + CV_WRAP MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F); + + CV_WRAP int numBands() const { return actual_num_bands_; } + CV_WRAP void setNumBands(int val) { actual_num_bands_ = val; } + + CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE; + CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE; + CV_WRAP void blend(CV_IN_OUT InputOutputArray dst, CV_IN_OUT InputOutputArray dst_mask) CV_OVERRIDE; + +private: + int actual_num_bands_, num_bands_; + std::vector dst_pyr_laplace_; + std::vector dst_band_weights_; + Rect dst_roi_final_; + bool can_use_gpu_; + int weight_type_; //CV_32F or CV_16S +#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING) + std::vector gpu_dst_pyr_laplace_; + std::vector gpu_dst_band_weights_; + std::vector gpu_tl_points_; + std::vector gpu_imgs_with_border_; + std::vector > gpu_weight_pyr_gauss_vec_; + std::vector > gpu_src_pyr_laplace_vec_; + std::vector > gpu_ups_; + cuda::GpuMat gpu_dst_mask_; + cuda::GpuMat gpu_mask_; + cuda::GpuMat gpu_img_; + cuda::GpuMat gpu_weight_map_; + cuda::GpuMat gpu_add_mask_; + int gpu_feed_idx_; + bool gpu_initialized_; +#endif +}; + + +////////////////////////////////////////////////////////////////////////////// +// Auxiliary functions + +void CV_EXPORTS_W normalizeUsingWeightMap(InputArray weight, CV_IN_OUT InputOutputArray src); + +void CV_EXPORTS_W createWeightMap(InputArray mask, float sharpness, CV_IN_OUT InputOutputArray weight); + +void CV_EXPORTS_W createLaplacePyr(InputArray img, int num_levels, CV_IN_OUT std::vector& pyr); +void CV_EXPORTS_W createLaplacePyrGpu(InputArray img, int num_levels, CV_IN_OUT std::vector& pyr); + +// Restores source image +void CV_EXPORTS_W restoreImageFromLaplacePyr(CV_IN_OUT std::vector& pyr); +void CV_EXPORTS_W restoreImageFromLaplacePyrGpu(CV_IN_OUT std::vector& pyr); + +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_BLENDERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/camera.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/camera.hpp new file mode 100644 index 0000000..14ecf60 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/camera.hpp @@ -0,0 +1,78 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_CAMERA_HPP +#define OPENCV_STITCHING_CAMERA_HPP + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching +//! @{ + +/** @brief Describes camera parameters. + +@note Translation is assumed to be zero during the whole stitching pipeline. : + */ +struct CV_EXPORTS_W_SIMPLE CameraParams +{ + CameraParams(); + CameraParams(const CameraParams& other); + CameraParams& operator =(const CameraParams& other); + CV_WRAP Mat K() const; + + CV_PROP_RW double focal; // Focal length + CV_PROP_RW double aspect; // Aspect ratio + CV_PROP_RW double ppx; // Principal point X + CV_PROP_RW double ppy; // Principal point Y + CV_PROP_RW Mat R; // Rotation + CV_PROP_RW Mat t; // Translation +}; + +//! @} + +} // namespace detail +} // namespace cv + +#endif // #ifndef OPENCV_STITCHING_CAMERA_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/exposure_compensate.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/exposure_compensate.hpp new file mode 100644 index 0000000..074c9b6 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/exposure_compensate.hpp @@ -0,0 +1,245 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP +#define OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP + +#if defined(NO) +# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers. +#endif + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_exposure +//! @{ + +/** @brief Base class for all exposure compensators. + */ +class CV_EXPORTS_W ExposureCompensator +{ +public: + ExposureCompensator(): updateGain(true) {} + virtual ~ExposureCompensator() {} + + enum { NO, GAIN, GAIN_BLOCKS, CHANNELS, CHANNELS_BLOCKS }; + CV_WRAP static Ptr createDefault(int type); + + /** + @param corners Source image top-left corners + @param images Source images + @param masks Image masks to update (second value in pair specifies the value which should be used + to detect where image is) + */ + CV_WRAP void feed(const std::vector &corners, const std::vector &images, + const std::vector &masks); + /** @overload */ + virtual void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) = 0; + /** @brief Compensate exposure in the specified image. + + @param index Image index + @param corner Image top-left corner + @param image Image to process + @param mask Image mask + */ + CV_WRAP virtual void apply(int index, Point corner, InputOutputArray image, InputArray mask) = 0; + CV_WRAP virtual void getMatGains(CV_OUT std::vector& ) {CV_Error(Error::StsInternal, "");}; + CV_WRAP virtual void setMatGains(std::vector& ) { CV_Error(Error::StsInternal, ""); }; + CV_WRAP void setUpdateGain(bool b) { updateGain = b; }; + CV_WRAP bool getUpdateGain() { return updateGain; }; +protected : + bool updateGain; +}; + +/** @brief Stub exposure compensator which does nothing. + */ +class CV_EXPORTS_W NoExposureCompensator : public ExposureCompensator +{ +public: + void feed(const std::vector &/*corners*/, const std::vector &/*images*/, + const std::vector > &/*masks*/) CV_OVERRIDE { } + CV_WRAP void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) CV_OVERRIDE { } + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE { umv.clear(); return; }; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE { umv.clear(); return; }; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image +intensities, see @cite BL07 and @cite WJ10 for details. + */ +class CV_EXPORTS_W GainCompensator : public ExposureCompensator +{ +public: + // This Constructor only exists to make source level compatibility detector happy + CV_WRAP GainCompensator() + : GainCompensator(1) {} + CV_WRAP GainCompensator(int nr_feeds) + : nr_feeds_(nr_feeds), similarity_threshold_(1) {} + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; + void singleFeed(const std::vector &corners, const std::vector &images, + const std::vector > &masks); + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE; + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE ; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE ; + CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; } + CV_WRAP int getNrFeeds() { return nr_feeds_; } + CV_WRAP void setSimilarityThreshold(double similarity_threshold) { similarity_threshold_ = similarity_threshold; } + CV_WRAP double getSimilarityThreshold() const { return similarity_threshold_; } + void prepareSimilarityMask(const std::vector &corners, const std::vector &images); + std::vector gains() const; + +private: + UMat buildSimilarityMask(InputArray src_array1, InputArray src_array2); + + Mat_ gains_; + int nr_feeds_; + double similarity_threshold_; + std::vector similarities_; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image +intensities on each channel independently. + */ +class CV_EXPORTS_W ChannelsCompensator : public ExposureCompensator +{ +public: + CV_WRAP ChannelsCompensator(int nr_feeds=1) + : nr_feeds_(nr_feeds), similarity_threshold_(1) {} + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE; + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE; + CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; } + CV_WRAP int getNrFeeds() { return nr_feeds_; } + CV_WRAP void setSimilarityThreshold(double similarity_threshold) { similarity_threshold_ = similarity_threshold; } + CV_WRAP double getSimilarityThreshold() const { return similarity_threshold_; } + std::vector gains() const { return gains_; } + +private: + std::vector gains_; + int nr_feeds_; + double similarity_threshold_; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image blocks. + */ +class CV_EXPORTS_W BlocksCompensator : public ExposureCompensator +{ +public: + BlocksCompensator(int bl_width=32, int bl_height=32, int nr_feeds=1) + : bl_width_(bl_width), bl_height_(bl_height), nr_feeds_(nr_feeds), nr_gain_filtering_iterations_(2), + similarity_threshold_(1) {} + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE; + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE; + CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; } + CV_WRAP int getNrFeeds() { return nr_feeds_; } + CV_WRAP void setSimilarityThreshold(double similarity_threshold) { similarity_threshold_ = similarity_threshold; } + CV_WRAP double getSimilarityThreshold() const { return similarity_threshold_; } + CV_WRAP void setBlockSize(int width, int height) { bl_width_ = width; bl_height_ = height; } + CV_WRAP void setBlockSize(Size size) { setBlockSize(size.width, size.height); } + CV_WRAP Size getBlockSize() const { return Size(bl_width_, bl_height_); } + CV_WRAP void setNrGainsFilteringIterations(int nr_iterations) { nr_gain_filtering_iterations_ = nr_iterations; } + CV_WRAP int getNrGainsFilteringIterations() const { return nr_gain_filtering_iterations_; } + +protected: + template + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks); + +private: + UMat getGainMap(const GainCompensator& compensator, int bl_idx, Size bl_per_img); + UMat getGainMap(const ChannelsCompensator& compensator, int bl_idx, Size bl_per_img); + + int bl_width_, bl_height_; + std::vector gain_maps_; + int nr_feeds_; + int nr_gain_filtering_iterations_; + double similarity_threshold_; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block +intensities, see @cite UES01 for details. + */ +class CV_EXPORTS_W BlocksGainCompensator : public BlocksCompensator +{ +public: + // This Constructor only exists to make source level compatibility detector happy + CV_WRAP BlocksGainCompensator(int bl_width = 32, int bl_height = 32) + : BlocksGainCompensator(bl_width, bl_height, 1) {} + CV_WRAP BlocksGainCompensator(int bl_width, int bl_height, int nr_feeds) + : BlocksCompensator(bl_width, bl_height, nr_feeds) {} + + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; + + // This function only exists to make source level compatibility detector happy + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE { + BlocksCompensator::apply(index, corner, image, mask); } + // This function only exists to make source level compatibility detector happy + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE { BlocksCompensator::getMatGains(umv); } + // This function only exists to make source level compatibility detector happy + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE { BlocksCompensator::setMatGains(umv); } +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block +on each channel. + */ +class CV_EXPORTS_W BlocksChannelsCompensator : public BlocksCompensator +{ +public: + CV_WRAP BlocksChannelsCompensator(int bl_width=32, int bl_height=32, int nr_feeds=1) + : BlocksCompensator(bl_width, bl_height, nr_feeds) {} + + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; +}; +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/matchers.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/matchers.hpp new file mode 100644 index 0000000..cd9749c --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/matchers.hpp @@ -0,0 +1,253 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_MATCHERS_HPP +#define OPENCV_STITCHING_MATCHERS_HPP + +#include "opencv2/core.hpp" +#include "opencv2/features2d.hpp" + +#include "opencv2/opencv_modules.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_match +//! @{ + +/** @brief Structure containing image keypoints and descriptors. */ +struct CV_EXPORTS_W_SIMPLE ImageFeatures +{ + CV_PROP_RW int img_idx; + CV_PROP_RW Size img_size; + CV_PROP_RW std::vector keypoints; + CV_PROP_RW UMat descriptors; + CV_WRAP std::vector getKeypoints() { return keypoints; }; +}; +/** @brief + +@param featuresFinder +@param images +@param features +@param masks +*/ +CV_EXPORTS_W void computeImageFeatures( + const Ptr &featuresFinder, + InputArrayOfArrays images, + CV_OUT std::vector &features, + InputArrayOfArrays masks = noArray()); + +/** @brief + +@param featuresFinder +@param image +@param features +@param mask +*/ +CV_EXPORTS_AS(computeImageFeatures2) void computeImageFeatures( + const Ptr &featuresFinder, + InputArray image, + CV_OUT ImageFeatures &features, + InputArray mask = noArray()); + +/** @brief Structure containing information about matches between two images. + +It's assumed that there is a transformation between those images. Transformation may be +homography or affine transformation based on selected matcher. + +@sa detail::FeaturesMatcher +*/ +struct CV_EXPORTS_W_SIMPLE MatchesInfo +{ + MatchesInfo(); + MatchesInfo(const MatchesInfo &other); + MatchesInfo& operator =(const MatchesInfo &other); + + CV_PROP_RW int src_img_idx; + CV_PROP_RW int dst_img_idx; //!< Images indices (optional) + std::vector matches; + std::vector inliers_mask; //!< Geometrically consistent matches mask + CV_PROP_RW int num_inliers; //!< Number of geometrically consistent matches + CV_PROP_RW Mat H; //!< Estimated transformation + CV_PROP_RW double confidence; //!< Confidence two images are from the same panorama + CV_WRAP std::vector getMatches() { return matches; }; + CV_WRAP std::vector getInliers() { return inliers_mask; }; +}; + +/** @brief Feature matchers base class. */ +class CV_EXPORTS_W FeaturesMatcher +{ +public: + CV_WRAP virtual ~FeaturesMatcher() {} + + /** @overload + @param features1 First image features + @param features2 Second image features + @param matches_info Found matches + */ + CV_WRAP_AS(apply) void operator ()(const ImageFeatures &features1, const ImageFeatures &features2, + CV_OUT MatchesInfo& matches_info) { match(features1, features2, matches_info); } + + /** @brief Performs images matching. + + @param features Features of the source images + @param pairwise_matches Found pairwise matches + @param mask Mask indicating which image pairs must be matched + + The function is parallelized with the TBB library. + + @sa detail::MatchesInfo + */ + CV_WRAP_AS(apply2) void operator ()(const std::vector &features, CV_OUT std::vector &pairwise_matches, + const cv::UMat &mask = cv::UMat()); + + /** @return True, if it's possible to use the same matcher instance in parallel, false otherwise + */ + CV_WRAP bool isThreadSafe() const { return is_thread_safe_; } + + /** @brief Frees unused memory allocated before if there is any. + */ + CV_WRAP virtual void collectGarbage() {} + +protected: + FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {} + + /** @brief This method must implement matching logic in order to make the wrappers + detail::FeaturesMatcher::operator()_ work. + + @param features1 first image features + @param features2 second image features + @param matches_info found matches + */ + virtual void match(const ImageFeatures &features1, const ImageFeatures &features2, + MatchesInfo& matches_info) = 0; + + bool is_thread_safe_; +}; + +/** @brief Features matcher which finds two best matches for each feature and leaves the best one only if the +ratio between descriptor distances is greater than the threshold match_conf + +@sa detail::FeaturesMatcher + */ +class CV_EXPORTS_W BestOf2NearestMatcher : public FeaturesMatcher +{ +public: + /** @brief Constructs a "best of 2 nearest" matcher. + + @param try_use_gpu Should try to use GPU or not + @param match_conf Match distances ration threshold + @param num_matches_thresh1 Minimum number of matches required for the 2D projective transform + estimation used in the inliers classification step + @param num_matches_thresh2 Minimum number of matches required for the 2D projective transform + re-estimation on inliers + */ + CV_WRAP BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6, + int num_matches_thresh2 = 6); + + CV_WRAP void collectGarbage() CV_OVERRIDE; + CV_WRAP static Ptr create(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6, + int num_matches_thresh2 = 6); + +protected: + + void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE; + int num_matches_thresh1_; + int num_matches_thresh2_; + Ptr impl_; +}; + +class CV_EXPORTS_W BestOf2NearestRangeMatcher : public BestOf2NearestMatcher +{ +public: + CV_WRAP BestOf2NearestRangeMatcher(int range_width = 5, bool try_use_gpu = false, float match_conf = 0.3f, + int num_matches_thresh1 = 6, int num_matches_thresh2 = 6); + + void operator ()(const std::vector &features, std::vector &pairwise_matches, + const cv::UMat &mask = cv::UMat()); + + +protected: + int range_width_; +}; + +/** @brief Features matcher similar to cv::detail::BestOf2NearestMatcher which +finds two best matches for each feature and leaves the best one only if the +ratio between descriptor distances is greater than the threshold match_conf. + +Unlike cv::detail::BestOf2NearestMatcher this matcher uses affine +transformation (affine transformation estimate will be placed in matches_info). + +@sa cv::detail::FeaturesMatcher cv::detail::BestOf2NearestMatcher + */ +class CV_EXPORTS_W AffineBestOf2NearestMatcher : public BestOf2NearestMatcher +{ +public: + /** @brief Constructs a "best of 2 nearest" matcher that expects affine transformation + between images + + @param full_affine whether to use full affine transformation with 6 degress of freedom or reduced + transformation with 4 degrees of freedom using only rotation, translation and uniform scaling + @param try_use_gpu Should try to use GPU or not + @param match_conf Match distances ration threshold + @param num_matches_thresh1 Minimum number of matches required for the 2D affine transform + estimation used in the inliers classification step + + @sa cv::estimateAffine2D cv::estimateAffinePartial2D + */ + CV_WRAP AffineBestOf2NearestMatcher(bool full_affine = false, bool try_use_gpu = false, + float match_conf = 0.3f, int num_matches_thresh1 = 6) : + BestOf2NearestMatcher(try_use_gpu, match_conf, num_matches_thresh1, num_matches_thresh1), + full_affine_(full_affine) {} + +protected: + void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE; + + bool full_affine_; +}; + +//! @} stitching_match + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_MATCHERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/motion_estimators.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/motion_estimators.hpp new file mode 100644 index 0000000..ad21ee1 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/motion_estimators.hpp @@ -0,0 +1,373 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_MOTION_ESTIMATORS_HPP +#define OPENCV_STITCHING_MOTION_ESTIMATORS_HPP + +#include "opencv2/core.hpp" +#include "matchers.hpp" +#include "util.hpp" +#include "camera.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_rotation +//! @{ + +/** @brief Rotation estimator base class. + +It takes features of all images, pairwise matches between all images and estimates rotations of all +cameras. + +@note The coordinate system origin is implementation-dependent, but you can always normalize the +rotations in respect to the first camera, for instance. : + */ +class CV_EXPORTS_W Estimator +{ +public: + virtual ~Estimator() {} + + /** @brief Estimates camera parameters. + + @param features Features of images + @param pairwise_matches Pairwise matches of images + @param cameras Estimated camera parameters + @return True in case of success, false otherwise + */ + CV_WRAP_AS(apply) bool operator ()(const std::vector &features, + const std::vector &pairwise_matches, + CV_OUT CV_IN_OUT std::vector &cameras) + { + return estimate(features, pairwise_matches, cameras); + } + +protected: + /** @brief This method must implement camera parameters estimation logic in order to make the wrapper + detail::Estimator::operator()_ work. + + @param features Features of images + @param pairwise_matches Pairwise matches of images + @param cameras Estimated camera parameters + @return True in case of success, false otherwise + */ + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + CV_OUT std::vector &cameras) = 0; +}; + +/** @brief Homography based rotation estimator. + */ +class CV_EXPORTS_W HomographyBasedEstimator : public Estimator +{ +public: + CV_WRAP HomographyBasedEstimator(bool is_focals_estimated = false) + : is_focals_estimated_(is_focals_estimated) {} + +private: + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) CV_OVERRIDE; + + bool is_focals_estimated_; +}; + +/** @brief Affine transformation based estimator. + +This estimator uses pairwise transformations estimated by matcher to estimate +final transformation for each camera. + +@sa cv::detail::HomographyBasedEstimator + */ +class CV_EXPORTS_W AffineBasedEstimator : public Estimator +{ +public: + CV_WRAP AffineBasedEstimator(){} +private: + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) CV_OVERRIDE; +}; + +/** @brief Base class for all camera parameters refinement methods. + */ +class CV_EXPORTS_W BundleAdjusterBase : public Estimator +{ +public: + CV_WRAP const Mat refinementMask() const { return refinement_mask_.clone(); } + CV_WRAP void setRefinementMask(const Mat &mask) + { + CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3)); + refinement_mask_ = mask.clone(); + } + + CV_WRAP double confThresh() const { return conf_thresh_; } + CV_WRAP void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } + + CV_WRAP TermCriteria termCriteria() { return term_criteria_; } + CV_WRAP void setTermCriteria(const TermCriteria& term_criteria) { term_criteria_ = term_criteria; } + +protected: + /** @brief Construct a bundle adjuster base instance. + + @param num_params_per_cam Number of parameters per camera + @param num_errs_per_measurement Number of error terms (components) per match + */ + BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement) + : num_images_(0), total_num_matches_(0), + num_params_per_cam_(num_params_per_cam), + num_errs_per_measurement_(num_errs_per_measurement), + features_(0), pairwise_matches_(0), conf_thresh_(0) + { + setRefinementMask(Mat::ones(3, 3, CV_8U)); + setConfThresh(1.); + setTermCriteria(TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 1000, DBL_EPSILON)); + } + + // Runs bundle adjustment + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) CV_OVERRIDE; + + /** @brief Sets initial camera parameter to refine. + + @param cameras Camera parameters + */ + virtual void setUpInitialCameraParams(const std::vector &cameras) = 0; + /** @brief Gets the refined camera parameters. + + @param cameras Refined camera parameters + */ + virtual void obtainRefinedCameraParams(std::vector &cameras) const = 0; + /** @brief Calculates error vector. + + @param err Error column-vector of length total_num_matches \* num_errs_per_measurement + */ + virtual void calcError(Mat &err) = 0; + /** @brief Calculates the cost function jacobian. + + @param jac Jacobian matrix of dimensions + (total_num_matches \* num_errs_per_measurement) x (num_images \* num_params_per_cam) + */ + virtual void calcJacobian(Mat &jac) = 0; + + // 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine + Mat refinement_mask_; + + int num_images_; + int total_num_matches_; + + int num_params_per_cam_; + int num_errs_per_measurement_; + + const ImageFeatures *features_; + const MatchesInfo *pairwise_matches_; + + // Threshold to filter out poorly matched image pairs + double conf_thresh_; + + //Levenberg-Marquardt algorithm termination criteria + TermCriteria term_criteria_; + + // Camera parameters matrix (CV_64F) + Mat cam_params_; + + // Connected images pairs + std::vector > edges_; +}; + + +/** @brief Stub bundle adjuster that does nothing. + */ +class CV_EXPORTS_W NoBundleAdjuster : public BundleAdjusterBase +{ +public: + CV_WRAP NoBundleAdjuster() : BundleAdjusterBase(0, 0) {} + +private: + bool estimate(const std::vector &, const std::vector &, + std::vector &) CV_OVERRIDE + { + return true; + } + void setUpInitialCameraParams(const std::vector &) CV_OVERRIDE {} + void obtainRefinedCameraParams(std::vector &) const CV_OVERRIDE {} + void calcError(Mat &) CV_OVERRIDE {} + void calcJacobian(Mat &) CV_OVERRIDE {} +}; + + +/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection +error squares + +It can estimate focal length, aspect ratio, principal point. +You can affect only on them via the refinement mask. + */ +class CV_EXPORTS_W BundleAdjusterReproj : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the distances +between the rays passing through the camera center and a feature. : + +It can estimate focal length. It ignores the refinement mask for now. + */ +class CV_EXPORTS_W BundleAdjusterRay : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterRay() : BundleAdjusterBase(4, 3) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +/** @brief Bundle adjuster that expects affine transformation +represented in homogeneous coordinates in R for each camera param. Implements +camera parameters refinement algorithm which minimizes sum of the reprojection +error squares + +It estimates all transformation parameters. Refinement mask is ignored. + +@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial + */ +class CV_EXPORTS_W BundleAdjusterAffine : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterAffine() : BundleAdjusterBase(6, 2) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +/** @brief Bundle adjuster that expects affine transformation with 4 DOF +represented in homogeneous coordinates in R for each camera param. Implements +camera parameters refinement algorithm which minimizes sum of the reprojection +error squares + +It estimates all transformation parameters. Refinement mask is ignored. + +@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine + */ +class CV_EXPORTS_W BundleAdjusterAffinePartial : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterAffinePartial() : BundleAdjusterBase(4, 2) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +enum WaveCorrectKind +{ + WAVE_CORRECT_HORIZ, + WAVE_CORRECT_VERT, + WAVE_CORRECT_AUTO +}; + +/** @brief Tries to detect the wave correction kind depending +on whether a panorama spans horizontally or vertically + +@param rmats Camera rotation matrices. +@return The correction kind to use for this panorama + */ +CV_EXPORTS +WaveCorrectKind autoDetectWaveCorrectKind(const std::vector &rmats); + +/** @brief Tries to make panorama more horizontal (or vertical). + +@param rmats Camera rotation matrices. +@param kind Correction kind, see detail::WaveCorrectKind. + */ +void CV_EXPORTS_W waveCorrect(CV_IN_OUT std::vector &rmats, WaveCorrectKind kind); + + +////////////////////////////////////////////////////////////////////////////// +// Auxiliary functions + +// Returns matches graph representation in DOT language +String CV_EXPORTS_W matchesGraphAsString(std::vector &pathes, std::vector &pairwise_matches, + float conf_threshold); + +CV_EXPORTS_W std::vector leaveBiggestComponent( + std::vector &features, + std::vector &pairwise_matches, + float conf_threshold); + +void CV_EXPORTS findMaxSpanningTree( + int num_images, const std::vector &pairwise_matches, + Graph &span_tree, std::vector ¢ers); + +//! @} stitching_rotation + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_MOTION_ESTIMATORS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/seam_finders.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/seam_finders.hpp new file mode 100644 index 0000000..71dae7f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/seam_finders.hpp @@ -0,0 +1,291 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_SEAM_FINDERS_HPP +#define OPENCV_STITCHING_SEAM_FINDERS_HPP + +#include +#include "opencv2/core.hpp" +#include "opencv2/opencv_modules.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_seam +//! @{ + +/** @brief Base class for a seam estimator. + */ +class CV_EXPORTS_W SeamFinder +{ +public: + CV_WRAP virtual ~SeamFinder() {} + enum { NO, VORONOI_SEAM, DP_SEAM }; + /** @brief Estimates seams. + + @param src Source images + @param corners Source image top-left corners + @param masks Source image masks to update + */ + CV_WRAP virtual void find(const std::vector &src, const std::vector &corners, + CV_IN_OUT std::vector &masks) = 0; + CV_WRAP static Ptr createDefault(int type); +}; + +/** @brief Stub seam estimator which does nothing. + */ +class CV_EXPORTS_W NoSeamFinder : public SeamFinder +{ +public: + CV_WRAP void find(const std::vector&, const std::vector&, CV_IN_OUT std::vector&) CV_OVERRIDE {} +}; + +/** @brief Base class for all pairwise seam estimators. + */ +class CV_EXPORTS_W PairwiseSeamFinder : public SeamFinder +{ +public: + CV_WRAP virtual void find(const std::vector &src, const std::vector &corners, + CV_IN_OUT std::vector &masks) CV_OVERRIDE; + +protected: + void run(); + /** @brief Resolves masks intersection of two specified images in the given ROI. + + @param first First image index + @param second Second image index + @param roi Region of interest + */ + virtual void findInPair(size_t first, size_t second, Rect roi) = 0; + + std::vector images_; + std::vector sizes_; + std::vector corners_; + std::vector masks_; +}; + +/** @brief Voronoi diagram-based seam estimator. + */ +class CV_EXPORTS_W VoronoiSeamFinder : public PairwiseSeamFinder +{ +public: + CV_WRAP virtual void find(const std::vector &src, const std::vector &corners, + CV_IN_OUT std::vector &masks) CV_OVERRIDE; + virtual void find(const std::vector &size, const std::vector &corners, + std::vector &masks); +private: + void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE; +}; + + +class CV_EXPORTS_W DpSeamFinder : public SeamFinder +{ +public: + enum CostFunction { COLOR, COLOR_GRAD }; + + DpSeamFinder(CostFunction costFunc = COLOR); + CV_WRAP DpSeamFinder(String costFunc ); + + CostFunction costFunction() const { return costFunc_; } + void setCostFunction(CostFunction val) { costFunc_ = val; } + CV_WRAP void setCostFunction(String val); + + virtual void find(const std::vector &src, const std::vector &corners, + std::vector &masks) CV_OVERRIDE; + +private: + enum ComponentState + { + FIRST = 1, SECOND = 2, INTERS = 4, + INTERS_FIRST = INTERS | FIRST, + INTERS_SECOND = INTERS | SECOND + }; + + class ImagePairLess + { + public: + ImagePairLess(const std::vector &images, const std::vector &corners) + : src_(&images[0]), corners_(&corners[0]) {} + + bool operator() (const std::pair &l, const std::pair &r) const + { + Point c1 = corners_[l.first] + Point(src_[l.first].cols / 2, src_[l.first].rows / 2); + Point c2 = corners_[l.second] + Point(src_[l.second].cols / 2, src_[l.second].rows / 2); + int d1 = (c1 - c2).dot(c1 - c2); + + c1 = corners_[r.first] + Point(src_[r.first].cols / 2, src_[r.first].rows / 2); + c2 = corners_[r.second] + Point(src_[r.second].cols / 2, src_[r.second].rows / 2); + int d2 = (c1 - c2).dot(c1 - c2); + + return d1 < d2; + } + + private: + const Mat *src_; + const Point *corners_; + }; + + class ClosePoints + { + public: + ClosePoints(int minDist) : minDist_(minDist) {} + + bool operator() (const Point &p1, const Point &p2) const + { + int dist2 = (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y); + return dist2 < minDist_ * minDist_; + } + + private: + int minDist_; + }; + + void process( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); + + void findComponents(); + + void findEdges(); + + void resolveConflicts( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); + + void computeGradients(const Mat &image1, const Mat &image2); + + bool hasOnlyOneNeighbor(int comp); + + bool closeToContour(int y, int x, const Mat_ &contourMask); + + bool getSeamTips(int comp1, int comp2, Point &p1, Point &p2); + + void computeCosts( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, + int comp, Mat_ &costV, Mat_ &costH); + + bool estimateSeam( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, int comp, + Point p1, Point p2, std::vector &seam, bool &isHorizontal); + + void updateLabelsUsingSeam( + int comp1, int comp2, const std::vector &seam, bool isHorizontalSeam); + + CostFunction costFunc_; + + // processing images pair data + Point unionTl_, unionBr_; + Size unionSize_; + Mat_ mask1_, mask2_; + Mat_ contour1mask_, contour2mask_; + Mat_ gradx1_, grady1_; + Mat_ gradx2_, grady2_; + + // components data + int ncomps_; + Mat_ labels_; + std::vector states_; + std::vector tls_, brs_; + std::vector > contours_; + std::set > edges_; +}; + +/** @brief Base class for all minimum graph-cut-based seam estimators. + */ +class CV_EXPORTS GraphCutSeamFinderBase +{ +public: + enum CostType { COST_COLOR, COST_COLOR_GRAD }; +}; + +/** @brief Minimum graph cut-based seam estimator. See details in @cite V03 . + */ +class CV_EXPORTS_W GraphCutSeamFinder : public GraphCutSeamFinderBase, public SeamFinder +{ +public: + GraphCutSeamFinder(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f, + float bad_region_penalty = 1000.f); + CV_WRAP GraphCutSeamFinder(String cost_type,float terminal_cost = 10000.f, + float bad_region_penalty = 1000.f); + + ~GraphCutSeamFinder(); + + CV_WRAP void find(const std::vector &src, const std::vector &corners, + std::vector &masks) CV_OVERRIDE; + +private: + // To avoid GCGraph dependency + class Impl; + Ptr impl_; +}; + + +#ifdef HAVE_OPENCV_CUDALEGACY +class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder +{ +public: + GraphCutSeamFinderGpu(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f, + float bad_region_penalty = 1000.f) + : cost_type_(cost_type), terminal_cost_(terminal_cost), + bad_region_penalty_(bad_region_penalty) {} + + void find(const std::vector &src, const std::vector &corners, + std::vector &masks) CV_OVERRIDE; + void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE; + +private: + void setGraphWeightsColor(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &mask1, const cv::Mat &mask2, + cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom); + void setGraphWeightsColorGrad(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &dx1, const cv::Mat &dx2, + const cv::Mat &dy1, const cv::Mat &dy2, const cv::Mat &mask1, const cv::Mat &mask2, + cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom); + std::vector dx_, dy_; + int cost_type_; + float terminal_cost_; + float bad_region_penalty_; +}; +#endif + +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_SEAM_FINDERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/timelapsers.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/timelapsers.hpp new file mode 100644 index 0000000..f6f3da8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/timelapsers.hpp @@ -0,0 +1,91 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + + +#ifndef OPENCV_STITCHING_TIMELAPSERS_HPP +#define OPENCV_STITCHING_TIMELAPSERS_HPP + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching +//! @{ + +// Base Timelapser class, takes a sequence of images, applies appropriate shift, stores result in dst_. + +class CV_EXPORTS_W Timelapser +{ +public: + + enum {AS_IS, CROP}; + + virtual ~Timelapser() {} + + CV_WRAP static Ptr createDefault(int type); + + CV_WRAP virtual void initialize(const std::vector &corners, const std::vector &sizes); + CV_WRAP virtual void process(InputArray img, InputArray mask, Point tl); + CV_WRAP virtual const UMat& getDst() {return dst_;} + +protected: + + virtual bool test_point(Point pt); + + UMat dst_; + Rect dst_roi_; +}; + + +class CV_EXPORTS_W TimelapserCrop : public Timelapser +{ +public: + virtual void initialize(const std::vector &corners, const std::vector &sizes) CV_OVERRIDE; +}; + +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_TIMELAPSERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/util.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/util.hpp new file mode 100644 index 0000000..bf7a390 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/util.hpp @@ -0,0 +1,121 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_UTIL_HPP +#define OPENCV_STITCHING_UTIL_HPP + +#include +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching +//! @{ + +class CV_EXPORTS DisjointSets +{ +public: + DisjointSets(int elem_count = 0) { createOneElemSets(elem_count); } + + void createOneElemSets(int elem_count); + int findSetByElem(int elem); + int mergeSets(int set1, int set2); + + std::vector parent; + std::vector size; + +private: + std::vector rank_; +}; + + +struct CV_EXPORTS GraphEdge +{ + GraphEdge(int from, int to, float weight); + bool operator <(const GraphEdge& other) const { return weight < other.weight; } + bool operator >(const GraphEdge& other) const { return weight > other.weight; } + + int from, to; + float weight; +}; + +inline GraphEdge::GraphEdge(int _from, int _to, float _weight) : from(_from), to(_to), weight(_weight) {} + + +class CV_EXPORTS Graph +{ +public: + Graph(int num_vertices = 0) { create(num_vertices); } + void create(int num_vertices) { edges_.assign(num_vertices, std::list()); } + int numVertices() const { return static_cast(edges_.size()); } + void addEdge(int from, int to, float weight); + template B forEach(B body) const; + template B walkBreadthFirst(int from, B body) const; + +private: + std::vector< std::list > edges_; +}; + + +////////////////////////////////////////////////////////////////////////////// +// Auxiliary functions + +CV_EXPORTS_W bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi); +CV_EXPORTS_W Rect resultRoi(const std::vector &corners, const std::vector &images); +CV_EXPORTS_W Rect resultRoi(const std::vector &corners, const std::vector &sizes); +CV_EXPORTS_W Rect resultRoiIntersection(const std::vector &corners, const std::vector &sizes); +CV_EXPORTS_W Point resultTl(const std::vector &corners); + +// Returns random 'count' element subset of the {0,1,...,size-1} set +CV_EXPORTS_W void selectRandomSubset(int count, int size, std::vector &subset); + +CV_EXPORTS_W int& stitchingLogLevel(); + +//! @} + +} // namespace detail +} // namespace cv + +#include "util_inl.hpp" + +#endif // OPENCV_STITCHING_UTIL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/util_inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/util_inl.hpp new file mode 100644 index 0000000..dafab8b --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/util_inl.hpp @@ -0,0 +1,131 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_UTIL_INL_HPP +#define OPENCV_STITCHING_UTIL_INL_HPP + +#include +#include "opencv2/core.hpp" +#include "util.hpp" // Make your IDE see declarations + +//! @cond IGNORED + +namespace cv { +namespace detail { + +template +B Graph::forEach(B body) const +{ + for (int i = 0; i < numVertices(); ++i) + { + std::list::const_iterator edge = edges_[i].begin(); + for (; edge != edges_[i].end(); ++edge) + body(*edge); + } + return body; +} + + +template +B Graph::walkBreadthFirst(int from, B body) const +{ + std::vector was(numVertices(), false); + std::queue vertices; + + was[from] = true; + vertices.push(from); + + while (!vertices.empty()) + { + int vertex = vertices.front(); + vertices.pop(); + + std::list::const_iterator edge = edges_[vertex].begin(); + for (; edge != edges_[vertex].end(); ++edge) + { + if (!was[edge->to]) + { + body(*edge); + was[edge->to] = true; + vertices.push(edge->to); + } + } + } + + return body; +} + + +////////////////////////////////////////////////////////////////////////////// +// Some auxiliary math functions + +static inline +float normL2(const Point3f& a) +{ + return a.x * a.x + a.y * a.y + a.z * a.z; +} + + +static inline +float normL2(const Point3f& a, const Point3f& b) +{ + return normL2(a - b); +} + + +static inline +double normL2sq(const Mat &r) +{ + return r.dot(r); +} + + +static inline int sqr(int x) { return x * x; } +static inline float sqr(float x) { return x * x; } +static inline double sqr(double x) { return x * x; } + +} // namespace detail +} // namespace cv + +//! @endcond + +#endif // OPENCV_STITCHING_UTIL_INL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/warpers.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/warpers.hpp new file mode 100644 index 0000000..ff005e8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/warpers.hpp @@ -0,0 +1,682 @@ + /*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_WARPERS_HPP +#define OPENCV_STITCHING_WARPERS_HPP + +#include "opencv2/core.hpp" +#include "opencv2/core/cuda.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/opencv_modules.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_warp +//! @{ + +/** @brief Rotation-only model image warper interface. + */ +class CV_EXPORTS RotationWarper +{ +public: + virtual ~RotationWarper() {} + + /** @brief Projects the image point. + + @param pt Source point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected point + */ + virtual Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) = 0; + + /** @brief Projects the image point backward. + + @param pt Projected point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Backward-projected point + */ +#if CV_VERSION_MAJOR == 4 + virtual Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) + { + CV_UNUSED(pt); CV_UNUSED(K); CV_UNUSED(R); + CV_Error(Error::StsNotImplemented, ""); + } +#else + virtual Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) = 0; +#endif + + /** @brief Builds the projection maps according to the given camera data. + + @param src_size Source image size + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param xmap Projection map for the x axis + @param ymap Projection map for the y axis + @return Projected image minimum bounding box + */ + virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) = 0; + + /** @brief Projects the image. + + @param src Source image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst Projected image + @return Project image top-left corner + */ + virtual Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + CV_OUT OutputArray dst) = 0; + + /** @brief Projects the image backward. + + @param src Projected image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst_size Backward-projected image size + @param dst Backward-projected image + */ + virtual void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, CV_OUT OutputArray dst) = 0; + + /** + @param src_size Source image bounding box + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected image minimum bounding box + */ + virtual Rect warpRoi(Size src_size, InputArray K, InputArray R) = 0; + + virtual float getScale() const { return 1.f; } + virtual void setScale(float) {} +}; + +/** @brief Base class for warping logic implementation. + */ +struct CV_EXPORTS_W_SIMPLE ProjectorBase +{ + void setCameraParams(InputArray K = Mat::eye(3, 3, CV_32F), + InputArray R = Mat::eye(3, 3, CV_32F), + InputArray T = Mat::zeros(3, 1, CV_32F)); + + float scale; + float k[9]; + float rinv[9]; + float r_kinv[9]; + float k_rinv[9]; + float t[3]; +}; + +/** @brief Base class for rotation-based warper using a detail::ProjectorBase_ derived class. + */ +template +class CV_EXPORTS_TEMPLATE RotationWarperBase : public RotationWarper +{ +public: + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE; + + Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE; + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE; + + void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, OutputArray dst) CV_OVERRIDE; + + Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE; + + float getScale() const CV_OVERRIDE{ return projector_.scale; } + void setScale(float val) CV_OVERRIDE { projector_.scale = val; } + +protected: + + // Detects ROI of the destination image. It's correct for any projection. + virtual void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br); + + // Detects ROI of the destination image by walking over image border. + // Correctness for any projection isn't guaranteed. + void detectResultRoiByBorder(Size src_size, Point &dst_tl, Point &dst_br); + + P projector_; +}; + + +struct CV_EXPORTS PlaneProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + +/** @brief Warper that maps an image onto the z = 1 plane. + */ +class CV_EXPORTS PlaneWarper : public RotationWarperBase +{ +public: + /** @brief Construct an instance of the plane warper class. + + @param scale Projected image scale multiplier + */ + PlaneWarper(float scale = 1.f) { projector_.scale = scale; } + + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE; + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R, InputArray T); + + Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) CV_OVERRIDE; + Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R, InputArray T); + + virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, CV_OUT OutputArray xmap, CV_OUT OutputArray ymap); + Rect buildMaps(Size src_size, InputArray K, InputArray R, CV_OUT OutputArray xmap, CV_OUT OutputArray ymap) CV_OVERRIDE; + + Point warp(InputArray src, InputArray K, InputArray R, + int interp_mode, int border_mode, CV_OUT OutputArray dst) CV_OVERRIDE; + virtual Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, + CV_OUT OutputArray dst); + + Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE; + Rect warpRoi(Size src_size, InputArray K, InputArray R, InputArray T); + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE; +}; + + +/** @brief Affine warper that uses rotations and translations + + Uses affine transformation in homogeneous coordinates to represent both rotation and + translation in camera rotation matrix. + */ +class CV_EXPORTS AffineWarper : public PlaneWarper +{ +public: + /** @brief Construct an instance of the affine warper class. + + @param scale Projected image scale multiplier + */ + AffineWarper(float scale = 1.f) : PlaneWarper(scale) {} + + /** @brief Projects the image point. + + @param pt Source point + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @return Projected point + */ + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray H) CV_OVERRIDE; + + /** @brief Projects the image point backward. + + @param pt Projected point + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @return Backward-projected point + */ + Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray H) CV_OVERRIDE; + + /** @brief Builds the projection maps according to the given camera data. + + @param src_size Source image size + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @param xmap Projection map for the x axis + @param ymap Projection map for the y axis + @return Projected image minimum bounding box + */ + Rect buildMaps(Size src_size, InputArray K, InputArray H, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + + /** @brief Projects the image. + + @param src Source image + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst Projected image + @return Project image top-left corner + */ + Point warp(InputArray src, InputArray K, InputArray H, + int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE; + + /** + @param src_size Source image bounding box + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @return Projected image minimum bounding box + */ + Rect warpRoi(Size src_size, InputArray K, InputArray H) CV_OVERRIDE; + +protected: + /** @brief Extracts rotation and translation matrices from matrix H representing + affine transformation in homogeneous coordinates + */ + void getRTfromHomogeneous(InputArray H, Mat &R, Mat &T); +}; + + +struct CV_EXPORTS_W_SIMPLE SphericalProjector : ProjectorBase +{ + CV_WRAP void mapForward(float x, float y, float &u, float &v); + CV_WRAP void mapBackward(float u, float v, float &x, float &y); +}; + + +/** @brief Warper that maps an image onto the unit sphere located at the origin. + + Projects image onto unit sphere with origin at (0, 0, 0) and radius scale, measured in pixels. + A 360 panorama would therefore have a resulting width of 2 * scale * PI pixels. + Poles are located at (0, -1, 0) and (0, 1, 0) points. +*/ +class CV_EXPORTS SphericalWarper : public RotationWarperBase +{ +public: + /** @brief Construct an instance of the spherical warper class. + + @param scale Radius of the projected sphere, in pixels. An image spanning the + whole sphere will have a width of 2 * scale * PI pixels. + */ + SphericalWarper(float scale) { projector_.scale = scale; } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE; +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE; +}; + + +struct CV_EXPORTS CylindricalProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +/** @brief Warper that maps an image onto the x\*x + z\*z = 1 cylinder. + */ +class CV_EXPORTS CylindricalWarper : public RotationWarperBase +{ +public: + /** @brief Construct an instance of the cylindrical warper class. + + @param scale Projected image scale multiplier + */ + CylindricalWarper(float scale) { projector_.scale = scale; } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE; +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE + { + RotationWarperBase::detectResultRoiByBorder(src_size, dst_tl, dst_br); + } +}; + + +struct CV_EXPORTS FisheyeProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS FisheyeWarper : public RotationWarperBase +{ +public: + FisheyeWarper(float scale) { projector_.scale = scale; } +}; + + +struct CV_EXPORTS StereographicProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS StereographicWarper : public RotationWarperBase +{ +public: + StereographicWarper(float scale) { projector_.scale = scale; } +}; + + +struct CV_EXPORTS CompressedRectilinearProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS CompressedRectilinearWarper : public RotationWarperBase +{ +public: + CompressedRectilinearWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } +}; + + +struct CV_EXPORTS CompressedRectilinearPortraitProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS CompressedRectilinearPortraitWarper : public RotationWarperBase +{ +public: + CompressedRectilinearPortraitWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } +}; + + +struct CV_EXPORTS PaniniProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS PaniniWarper : public RotationWarperBase +{ +public: + PaniniWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } +}; + + +struct CV_EXPORTS PaniniPortraitProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS PaniniPortraitWarper : public RotationWarperBase +{ +public: + PaniniPortraitWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } + +}; + + +struct CV_EXPORTS MercatorProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS MercatorWarper : public RotationWarperBase +{ +public: + MercatorWarper(float scale) { projector_.scale = scale; } +}; + + +struct CV_EXPORTS TransverseMercatorProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS TransverseMercatorWarper : public RotationWarperBase +{ +public: + TransverseMercatorWarper(float scale) { projector_.scale = scale; } +}; + + +class CV_EXPORTS PlaneWarperGpu : public PlaneWarper +{ +public: + PlaneWarperGpu(float scale = 1.f) : PlaneWarper(scale) {} + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, T, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, T, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, int interp_mode, int border_mode, + cuda::GpuMat & dst); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, + cuda::GpuMat & dst); + +private: + cuda::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_; +}; + + +class CV_EXPORTS SphericalWarperGpu : public SphericalWarper +{ +public: + SphericalWarperGpu(float scale) : SphericalWarper(scale) {} + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, int interp_mode, int border_mode, + cuda::GpuMat & dst); + +private: + cuda::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_; +}; + + +class CV_EXPORTS CylindricalWarperGpu : public CylindricalWarper +{ +public: + CylindricalWarperGpu(float scale) : CylindricalWarper(scale) {} + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, int interp_mode, int border_mode, + cuda::GpuMat & dst); + +private: + cuda::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_; +}; + + +struct CV_EXPORTS SphericalPortraitProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +// Projects image onto unit sphere with origin at (0, 0, 0). +// Poles are located NOT at (0, -1, 0) and (0, 1, 0) points, BUT at (1, 0, 0) and (-1, 0, 0) points. +class CV_EXPORTS SphericalPortraitWarper : public RotationWarperBase +{ +public: + SphericalPortraitWarper(float scale) { projector_.scale = scale; } + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE; +}; + +struct CV_EXPORTS CylindricalPortraitProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS CylindricalPortraitWarper : public RotationWarperBase +{ +public: + CylindricalPortraitWarper(float scale) { projector_.scale = scale; } + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE + { + RotationWarperBase::detectResultRoiByBorder(src_size, dst_tl, dst_br); + } +}; + +struct CV_EXPORTS PlanePortraitProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS PlanePortraitWarper : public RotationWarperBase +{ +public: + PlanePortraitWarper(float scale) { projector_.scale = scale; } + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE + { + RotationWarperBase::detectResultRoiByBorder(src_size, dst_tl, dst_br); + } +}; + +//! @} stitching_warp + +} // namespace detail +} // namespace cv + +#include "warpers_inl.hpp" + +#endif // OPENCV_STITCHING_WARPERS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/warpers_inl.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/warpers_inl.hpp new file mode 100644 index 0000000..72b5c08 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/detail/warpers_inl.hpp @@ -0,0 +1,782 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_WARPERS_INL_HPP +#define OPENCV_STITCHING_WARPERS_INL_HPP + +#include "opencv2/core.hpp" +#include "warpers.hpp" // Make your IDE see declarations +#include + +//! @cond IGNORED + +namespace cv { +namespace detail { + +template +Point2f RotationWarperBase

::warpPoint(const Point2f &pt, InputArray K, InputArray R) +{ + projector_.setCameraParams(K, R); + Point2f uv; + projector_.mapForward(pt.x, pt.y, uv.x, uv.y); + return uv; +} + +template +Point2f RotationWarperBase

::warpPointBackward(const Point2f& pt, InputArray K, InputArray R) +{ + projector_.setCameraParams(K, R); + Point2f xy; + projector_.mapBackward(pt.x, pt.y, xy.x, xy.y); + return xy; +} + +template +Rect RotationWarperBase

::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray _xmap, OutputArray _ymap) +{ + projector_.setCameraParams(K, R); + + Point dst_tl, dst_br; + detectResultRoi(src_size, dst_tl, dst_br); + + _xmap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); + _ymap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); + + Mat xmap = _xmap.getMat(), ymap = _ymap.getMat(); + + float x, y; + for (int v = dst_tl.y; v <= dst_br.y; ++v) + { + for (int u = dst_tl.x; u <= dst_br.x; ++u) + { + projector_.mapBackward(static_cast(u), static_cast(v), x, y); + xmap.at(v - dst_tl.y, u - dst_tl.x) = x; + ymap.at(v - dst_tl.y, u - dst_tl.x) = y; + } + } + + return Rect(dst_tl, dst_br); +} + + +template +Point RotationWarperBase

::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) +{ + UMat xmap, ymap; + Rect dst_roi = buildMaps(src.size(), K, R, xmap, ymap); + + dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); + remap(src, dst, xmap, ymap, interp_mode, border_mode); + + return dst_roi.tl(); +} + + +template +void RotationWarperBase

::warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, OutputArray dst) +{ + projector_.setCameraParams(K, R); + + Point src_tl, src_br; + detectResultRoi(dst_size, src_tl, src_br); + + Size size = src.size(); + CV_Assert(src_br.x - src_tl.x + 1 == size.width && src_br.y - src_tl.y + 1 == size.height); + + Mat xmap(dst_size, CV_32F); + Mat ymap(dst_size, CV_32F); + + float u, v; + for (int y = 0; y < dst_size.height; ++y) + { + for (int x = 0; x < dst_size.width; ++x) + { + projector_.mapForward(static_cast(x), static_cast(y), u, v); + xmap.at(y, x) = u - src_tl.x; + ymap.at(y, x) = v - src_tl.y; + } + } + + dst.create(dst_size, src.type()); + remap(src, dst, xmap, ymap, interp_mode, border_mode); +} + + +template +Rect RotationWarperBase

::warpRoi(Size src_size, InputArray K, InputArray R) +{ + projector_.setCameraParams(K, R); + + Point dst_tl, dst_br; + detectResultRoi(src_size, dst_tl, dst_br); + + return Rect(dst_tl, Point(dst_br.x + 1, dst_br.y + 1)); +} + + +template +void RotationWarperBase

::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) +{ + float tl_uf = (std::numeric_limits::max)(); + float tl_vf = (std::numeric_limits::max)(); + float br_uf = -(std::numeric_limits::max)(); + float br_vf = -(std::numeric_limits::max)(); + + float u, v; + for (int y = 0; y < src_size.height; ++y) + { + for (int x = 0; x < src_size.width; ++x) + { + projector_.mapForward(static_cast(x), static_cast(y), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + } + } + + dst_tl.x = static_cast(tl_uf); + dst_tl.y = static_cast(tl_vf); + dst_br.x = static_cast(br_uf); + dst_br.y = static_cast(br_vf); +} + + +template +void RotationWarperBase

::detectResultRoiByBorder(Size src_size, Point &dst_tl, Point &dst_br) +{ + float tl_uf = (std::numeric_limits::max)(); + float tl_vf = (std::numeric_limits::max)(); + float br_uf = -(std::numeric_limits::max)(); + float br_vf = -(std::numeric_limits::max)(); + + float u, v; + for (float x = 0; x < src_size.width; ++x) + { + projector_.mapForward(static_cast(x), 0, u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + + projector_.mapForward(static_cast(x), static_cast(src_size.height - 1), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + } + for (int y = 0; y < src_size.height; ++y) + { + projector_.mapForward(0, static_cast(y), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + + projector_.mapForward(static_cast(src_size.width - 1), static_cast(y), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + } + + dst_tl.x = static_cast(tl_uf); + dst_tl.y = static_cast(tl_vf); + dst_br.x = static_cast(br_uf); + dst_br.y = static_cast(br_vf); +} + + +inline +void PlaneProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + x_ = t[0] + x_ / z_ * (1 - t[2]); + y_ = t[1] + y_ / z_ * (1 - t[2]); + + u = scale * x_; + v = scale * y_; +} + + +inline +void PlaneProjector::mapBackward(float u, float v, float &x, float &y) +{ + u = u / scale - t[0]; + v = v / scale - t[1]; + + float z; + x = k_rinv[0] * u + k_rinv[1] * v + k_rinv[2] * (1 - t[2]); + y = k_rinv[3] * u + k_rinv[4] * v + k_rinv[5] * (1 - t[2]); + z = k_rinv[6] * u + k_rinv[7] * v + k_rinv[8] * (1 - t[2]); + + x /= z; + y /= z; +} + + +inline +void SphericalProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + u = scale * atan2f(x_, z_); + float w = y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_); + v = scale * (static_cast(CV_PI) - acosf(w == w ? w : 0)); +} + + +inline +void SphericalProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float sinv = sinf(static_cast(CV_PI) - v); + float x_ = sinv * sinf(u); + float y_ = cosf(static_cast(CV_PI) - v); + float z_ = sinv * cosf(u); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + + +inline +void CylindricalProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + u = scale * atan2f(x_, z_); + v = scale * y_ / sqrtf(x_ * x_ + z_ * z_); +} + + +inline +void CylindricalProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float x_ = sinf(u); + float y_ = v; + float z_ = cosf(u); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void FisheyeProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = scale * v_ * cosf(u_); + v = scale * v_ * sinf(u_); +} + +inline +void FisheyeProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float u_ = atan2f(v, u); + float v_ = sqrtf(u*u + v*v); + + float sinv = sinf((float)CV_PI - v_); + float x_ = sinv * sinf(u_); + float y_ = cosf((float)CV_PI - v_); + float z_ = sinv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void StereographicProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float r = sinf(v_) / (1 - cosf(v_)); + + u = scale * r * std::cos(u_); + v = scale * r * std::sin(u_); +} + +inline +void StereographicProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float u_ = atan2f(v, u); + float r = sqrtf(u*u + v*v); + float v_ = 2 * atanf(1.f / r); + + float sinv = sinf((float)CV_PI - v_); + float x_ = sinv * sinf(u_); + float y_ = cosf((float)CV_PI - v_); + float z_ = sinv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void CompressedRectilinearProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = scale * a * tanf(u_ / a); + v = scale * b * tanf(v_) / cosf(u_); +} + +inline +void CompressedRectilinearProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float aatg = a * atanf(u / a); + float u_ = aatg; + float v_ = atanf(v * cosf(aatg) / b); + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void CompressedRectilinearPortraitProjector::mapForward(float x, float y, float &u, float &v) +{ + float y_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float x_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = - scale * a * tanf(u_ / a); + v = scale * b * tanf(v_) / cosf(u_); +} + +inline +void CompressedRectilinearPortraitProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= - scale; + v /= scale; + + float aatg = a * atanf(u / a); + float u_ = aatg; + float v_ = atanf(v * cosf( aatg ) / b); + + float cosv = cosf(v_); + float y_ = cosv * sinf(u_); + float x_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void PaniniProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float tg = a * tanf(u_ / a); + u = scale * tg; + + float sinu = sinf(u_); + if ( fabs(sinu) < 1E-7 ) + v = scale * b * tanf(v_); + else + v = scale * b * tg * tanf(v_) / sinu; +} + +inline +void PaniniProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float lamda = a * atanf(u / a); + float u_ = lamda; + + float v_; + if ( fabs(lamda) > 1E-7) + v_ = atanf(v * sinf(lamda) / (b * a * tanf(lamda / a))); + else + v_ = atanf(v / b); + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void PaniniPortraitProjector::mapForward(float x, float y, float &u, float &v) +{ + float y_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float x_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float tg = a * tanf(u_ / a); + u = - scale * tg; + + float sinu = sinf( u_ ); + if ( fabs(sinu) < 1E-7 ) + v = scale * b * tanf(v_); + else + v = scale * b * tg * tanf(v_) / sinu; +} + +inline +void PaniniPortraitProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= - scale; + v /= scale; + + float lamda = a * atanf(u / a); + float u_ = lamda; + + float v_; + if ( fabs(lamda) > 1E-7) + v_ = atanf(v * sinf(lamda) / (b * a * tanf(lamda/a))); + else + v_ = atanf(v / b); + + float cosv = cosf(v_); + float y_ = cosv * sinf(u_); + float x_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void MercatorProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = scale * u_; + v = scale * logf( tanf( (float)(CV_PI/4) + v_/2 ) ); +} + +inline +void MercatorProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float v_ = atanf( sinhf(v) ); + float u_ = u; + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void TransverseMercatorProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float B = cosf(v_) * sinf(u_); + + u = scale / 2 * logf( (1+B) / (1-B) ); + v = scale * atan2f(tanf(v_), cosf(u_)); +} + +inline +void TransverseMercatorProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float v_ = asinf( sinf(v) / coshf(u) ); + float u_ = atan2f( sinhf(u), std::cos(v) ); + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void SphericalPortraitProjector::mapForward(float x, float y, float &u0, float &v0) +{ + float x0_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y0_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float x_ = y0_; + float y_ = x0_; + float u, v; + + u = scale * atan2f(x_, z_); + v = scale * (static_cast(CV_PI) - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_))); + + u0 = -u;//v; + v0 = v;//u; +} + + +inline +void SphericalPortraitProjector::mapBackward(float u0, float v0, float &x, float &y) +{ + float u, v; + u = -u0;//v0; + v = v0;//u0; + + u /= scale; + v /= scale; + + float sinv = sinf(static_cast(CV_PI) - v); + float x0_ = sinv * sinf(u); + float y0_ = cosf(static_cast(CV_PI) - v); + float z_ = sinv * cosf(u); + + float x_ = y0_; + float y_ = x0_; + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void CylindricalPortraitProjector::mapForward(float x, float y, float &u0, float &v0) +{ + float x0_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y0_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float x_ = y0_; + float y_ = x0_; + float u, v; + + u = scale * atan2f(x_, z_); + v = scale * y_ / sqrtf(x_ * x_ + z_ * z_); + + u0 = -u;//v; + v0 = v;//u; +} + + +inline +void CylindricalPortraitProjector::mapBackward(float u0, float v0, float &x, float &y) +{ + float u, v; + u = -u0;//v0; + v = v0;//u0; + + u /= scale; + v /= scale; + + float x0_ = sinf(u); + float y0_ = v; + float z_ = cosf(u); + + float x_ = y0_; + float y_ = x0_; + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void PlanePortraitProjector::mapForward(float x, float y, float &u0, float &v0) +{ + float x0_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y0_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float x_ = y0_; + float y_ = x0_; + + x_ = t[0] + x_ / z_ * (1 - t[2]); + y_ = t[1] + y_ / z_ * (1 - t[2]); + + float u,v; + u = scale * x_; + v = scale * y_; + + u0 = -u; + v0 = v; +} + + +inline +void PlanePortraitProjector::mapBackward(float u0, float v0, float &x, float &y) +{ + float u, v; + u = -u0; + v = v0; + + u = u / scale - t[0]; + v = v / scale - t[1]; + + float z; + x = k_rinv[0] * v + k_rinv[1] * u + k_rinv[2] * (1 - t[2]); + y = k_rinv[3] * v + k_rinv[4] * u + k_rinv[5] * (1 - t[2]); + z = k_rinv[6] * v + k_rinv[7] * u + k_rinv[8] * (1 - t[2]); + + x /= z; + y /= z; +} + + +} // namespace detail +} // namespace cv + +//! @endcond + +#endif // OPENCV_STITCHING_WARPERS_INL_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/stitching/warpers.hpp b/Cigarette/OpenCV455Simple/include/opencv2/stitching/warpers.hpp new file mode 100644 index 0000000..aa1ce5a --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/stitching/warpers.hpp @@ -0,0 +1,277 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_WARPER_CREATORS_HPP +#define OPENCV_STITCHING_WARPER_CREATORS_HPP + +#include "opencv2/stitching/detail/warpers.hpp" +#include + +namespace cv { + class CV_EXPORTS_W PyRotationWarper + { + Ptr rw; + + public: + CV_WRAP PyRotationWarper(String type, float scale); + CV_WRAP PyRotationWarper() {}; + ~PyRotationWarper() {} + + /** @brief Projects the image point. + + @param pt Source point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected point + */ + CV_WRAP Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R); + + /** @brief Projects the image point backward. + + @param pt Projected point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Backward-projected point + */ +#if CV_VERSION_MAJOR == 4 + CV_WRAP Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) + { + CV_UNUSED(pt); CV_UNUSED(K); CV_UNUSED(R); + CV_Error(Error::StsNotImplemented, ""); + } +#else + CV_WRAP Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray R); +#endif + /** @brief Builds the projection maps according to the given camera data. + + @param src_size Source image size + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param xmap Projection map for the x axis + @param ymap Projection map for the y axis + @return Projected image minimum bounding box + */ + CV_WRAP Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap); + + /** @brief Projects the image. + + @param src Source image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst Projected image + @return Project image top-left corner + */ + CV_WRAP Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + CV_OUT OutputArray dst); + + /** @brief Projects the image backward. + + @param src Projected image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst_size Backward-projected image size + @param dst Backward-projected image + */ + CV_WRAP void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, CV_OUT OutputArray dst); + + /** + @param src_size Source image bounding box + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected image minimum bounding box + */ + CV_WRAP Rect warpRoi(Size src_size, InputArray K, InputArray R); + + CV_WRAP float getScale() const { return 1.f; } + CV_WRAP void setScale(float) {} + }; + +//! @addtogroup stitching_warp +//! @{ + +/** @brief Image warper factories base class. + */ + +class CV_EXPORTS_W WarperCreator +{ +public: + CV_WRAP virtual ~WarperCreator() {} + virtual Ptr create(float scale) const = 0; +}; + + +/** @brief Plane warper factory class. + @sa detail::PlaneWarper + */ +class CV_EXPORTS PlaneWarper : public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +/** @brief Affine warper factory class. + @sa detail::AffineWarper + */ +class CV_EXPORTS AffineWarper : public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +/** @brief Cylindrical warper factory class. +@sa detail::CylindricalWarper +*/ +class CV_EXPORTS CylindricalWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +/** @brief Spherical warper factory class */ +class CV_EXPORTS SphericalWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS FisheyeWarper : public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS StereographicWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS CompressedRectilinearWarper: public WarperCreator +{ + float a, b; +public: + CompressedRectilinearWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS CompressedRectilinearPortraitWarper: public WarperCreator +{ + float a, b; +public: + CompressedRectilinearPortraitWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS PaniniWarper: public WarperCreator +{ + float a, b; +public: + PaniniWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS PaniniPortraitWarper: public WarperCreator +{ + float a, b; +public: + PaniniPortraitWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS MercatorWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS TransverseMercatorWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + + + +#ifdef HAVE_OPENCV_CUDAWARPING +class PlaneWarperGpu: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + + +class CylindricalWarperGpu: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + + +class SphericalWarperGpu: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; +#endif + +//! @} stitching_warp + +} // namespace cv + +#endif // OPENCV_STITCHING_WARPER_CREATORS_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/video.hpp b/Cigarette/OpenCV455Simple/include/opencv2/video.hpp new file mode 100644 index 0000000..a3dde60 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/video.hpp @@ -0,0 +1,59 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_VIDEO_HPP +#define OPENCV_VIDEO_HPP + +/** + @defgroup video Video Analysis + @{ + @defgroup video_motion Motion Analysis + @defgroup video_track Object Tracking + @defgroup video_c C API + @} +*/ + +#include "opencv2/video/tracking.hpp" +#include "opencv2/video/background_segm.hpp" + +#endif //OPENCV_VIDEO_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/video/background_segm.hpp b/Cigarette/OpenCV455Simple/include/opencv2/video/background_segm.hpp new file mode 100644 index 0000000..e1dfa15 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/video/background_segm.hpp @@ -0,0 +1,317 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_BACKGROUND_SEGM_HPP +#define OPENCV_BACKGROUND_SEGM_HPP + +#include "opencv2/core.hpp" + +namespace cv +{ + +//! @addtogroup video_motion +//! @{ + +/** @brief Base class for background/foreground segmentation. : + +The class is only used to define the common interface for the whole family of background/foreground +segmentation algorithms. + */ +class CV_EXPORTS_W BackgroundSubtractor : public Algorithm +{ +public: + /** @brief Computes a foreground mask. + + @param image Next video frame. + @param fgmask The output foreground mask as an 8-bit binary image. + @param learningRate The value between 0 and 1 that indicates how fast the background model is + learnt. Negative parameter value makes the algorithm to use some automatically chosen learning + rate. 0 means that the background model is not updated at all, 1 means that the background model + is completely reinitialized from the last frame. + */ + CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0; + + /** @brief Computes a background image. + + @param backgroundImage The output background image. + + @note Sometimes the background image can be very blurry, as it contain the average background + statistics. + */ + CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const = 0; +}; + + +/** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm. + +The class implements the Gaussian mixture model background subtraction described in @cite Zivkovic2004 +and @cite Zivkovic2006 . + */ +class CV_EXPORTS_W BackgroundSubtractorMOG2 : public BackgroundSubtractor +{ +public: + /** @brief Returns the number of last frames that affect the background model + */ + CV_WRAP virtual int getHistory() const = 0; + /** @brief Sets the number of last frames that affect the background model + */ + CV_WRAP virtual void setHistory(int history) = 0; + + /** @brief Returns the number of gaussian components in the background model + */ + CV_WRAP virtual int getNMixtures() const = 0; + /** @brief Sets the number of gaussian components in the background model. + + The model needs to be reinitalized to reserve memory. + */ + CV_WRAP virtual void setNMixtures(int nmixtures) = 0;//needs reinitialization! + + /** @brief Returns the "background ratio" parameter of the algorithm + + If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's + considered background and added to the model as a center of a new component. It corresponds to TB + parameter in the paper. + */ + CV_WRAP virtual double getBackgroundRatio() const = 0; + /** @brief Sets the "background ratio" parameter of the algorithm + */ + CV_WRAP virtual void setBackgroundRatio(double ratio) = 0; + + /** @brief Returns the variance threshold for the pixel-model match + + The main threshold on the squared Mahalanobis distance to decide if the sample is well described by + the background model or not. Related to Cthr from the paper. + */ + CV_WRAP virtual double getVarThreshold() const = 0; + /** @brief Sets the variance threshold for the pixel-model match + */ + CV_WRAP virtual void setVarThreshold(double varThreshold) = 0; + + /** @brief Returns the variance threshold for the pixel-model match used for new mixture component generation + + Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the + existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it + is considered foreground or added as a new component. 3 sigma =\> Tg=3\*3=9 is default. A smaller Tg + value generates more components. A higher Tg value may result in a small number of components but + they can grow too large. + */ + CV_WRAP virtual double getVarThresholdGen() const = 0; + /** @brief Sets the variance threshold for the pixel-model match used for new mixture component generation + */ + CV_WRAP virtual void setVarThresholdGen(double varThresholdGen) = 0; + + /** @brief Returns the initial variance of each gaussian component + */ + CV_WRAP virtual double getVarInit() const = 0; + /** @brief Sets the initial variance of each gaussian component + */ + CV_WRAP virtual void setVarInit(double varInit) = 0; + + CV_WRAP virtual double getVarMin() const = 0; + CV_WRAP virtual void setVarMin(double varMin) = 0; + + CV_WRAP virtual double getVarMax() const = 0; + CV_WRAP virtual void setVarMax(double varMax) = 0; + + /** @brief Returns the complexity reduction threshold + + This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 + is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the + standard Stauffer&Grimson algorithm. + */ + CV_WRAP virtual double getComplexityReductionThreshold() const = 0; + /** @brief Sets the complexity reduction threshold + */ + CV_WRAP virtual void setComplexityReductionThreshold(double ct) = 0; + + /** @brief Returns the shadow detection flag + + If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for + details. + */ + CV_WRAP virtual bool getDetectShadows() const = 0; + /** @brief Enables or disables shadow detection + */ + CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0; + + /** @brief Returns the shadow value + + Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 + in the mask always means background, 255 means foreground. + */ + CV_WRAP virtual int getShadowValue() const = 0; + /** @brief Sets the shadow value + */ + CV_WRAP virtual void setShadowValue(int value) = 0; + + /** @brief Returns the shadow threshold + + A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in + the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel + is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara, + *Detecting Moving Shadows...*, IEEE PAMI,2003. + */ + CV_WRAP virtual double getShadowThreshold() const = 0; + /** @brief Sets the shadow threshold + */ + CV_WRAP virtual void setShadowThreshold(double threshold) = 0; + + /** @brief Computes a foreground mask. + + @param image Next video frame. Floating point frame will be used without scaling and should be in range \f$[0,255]\f$. + @param fgmask The output foreground mask as an 8-bit binary image. + @param learningRate The value between 0 and 1 that indicates how fast the background model is + learnt. Negative parameter value makes the algorithm to use some automatically chosen learning + rate. 0 means that the background model is not updated at all, 1 means that the background model + is completely reinitialized from the last frame. + */ + CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0; +}; + +/** @brief Creates MOG2 Background Subtractor + +@param history Length of the history. +@param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model +to decide whether a pixel is well described by the background model. This parameter does not +affect the background update. +@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the +speed a bit, so if you do not need this feature, set the parameter to false. + */ +CV_EXPORTS_W Ptr + createBackgroundSubtractorMOG2(int history=500, double varThreshold=16, + bool detectShadows=true); + +/** @brief K-nearest neighbours - based Background/Foreground Segmentation Algorithm. + +The class implements the K-nearest neighbours background subtraction described in @cite Zivkovic2006 . +Very efficient if number of foreground pixels is low. + */ +class CV_EXPORTS_W BackgroundSubtractorKNN : public BackgroundSubtractor +{ +public: + /** @brief Returns the number of last frames that affect the background model + */ + CV_WRAP virtual int getHistory() const = 0; + /** @brief Sets the number of last frames that affect the background model + */ + CV_WRAP virtual void setHistory(int history) = 0; + + /** @brief Returns the number of data samples in the background model + */ + CV_WRAP virtual int getNSamples() const = 0; + /** @brief Sets the number of data samples in the background model. + + The model needs to be reinitalized to reserve memory. + */ + CV_WRAP virtual void setNSamples(int _nN) = 0;//needs reinitialization! + + /** @brief Returns the threshold on the squared distance between the pixel and the sample + + The threshold on the squared distance between the pixel and the sample to decide whether a pixel is + close to a data sample. + */ + CV_WRAP virtual double getDist2Threshold() const = 0; + /** @brief Sets the threshold on the squared distance + */ + CV_WRAP virtual void setDist2Threshold(double _dist2Threshold) = 0; + + /** @brief Returns the number of neighbours, the k in the kNN. + + K is the number of samples that need to be within dist2Threshold in order to decide that that + pixel is matching the kNN background model. + */ + CV_WRAP virtual int getkNNSamples() const = 0; + /** @brief Sets the k in the kNN. How many nearest neighbours need to match. + */ + CV_WRAP virtual void setkNNSamples(int _nkNN) = 0; + + /** @brief Returns the shadow detection flag + + If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for + details. + */ + CV_WRAP virtual bool getDetectShadows() const = 0; + /** @brief Enables or disables shadow detection + */ + CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0; + + /** @brief Returns the shadow value + + Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 + in the mask always means background, 255 means foreground. + */ + CV_WRAP virtual int getShadowValue() const = 0; + /** @brief Sets the shadow value + */ + CV_WRAP virtual void setShadowValue(int value) = 0; + + /** @brief Returns the shadow threshold + + A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in + the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel + is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara, + *Detecting Moving Shadows...*, IEEE PAMI,2003. + */ + CV_WRAP virtual double getShadowThreshold() const = 0; + /** @brief Sets the shadow threshold + */ + CV_WRAP virtual void setShadowThreshold(double threshold) = 0; +}; + +/** @brief Creates KNN Background Subtractor + +@param history Length of the history. +@param dist2Threshold Threshold on the squared distance between the pixel and the sample to decide +whether a pixel is close to that sample. This parameter does not affect the background update. +@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the +speed a bit, so if you do not need this feature, set the parameter to false. + */ +CV_EXPORTS_W Ptr + createBackgroundSubtractorKNN(int history=500, double dist2Threshold=400.0, + bool detectShadows=true); + +//! @} video_motion + +} // cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/video/detail/tracking.detail.hpp b/Cigarette/OpenCV455Simple/include/opencv2/video/detail/tracking.detail.hpp new file mode 100644 index 0000000..1e61079 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/video/detail/tracking.detail.hpp @@ -0,0 +1,406 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEO_DETAIL_TRACKING_HPP +#define OPENCV_VIDEO_DETAIL_TRACKING_HPP + +/* + * Partially based on: + * ==================================================================================================================== + * - [AAM] S. Salti, A. Cavallaro, L. Di Stefano, Adaptive Appearance Modeling for Video Tracking: Survey and Evaluation + * - [AMVOT] X. Li, W. Hu, C. Shen, Z. Zhang, A. Dick, A. van den Hengel, A Survey of Appearance Models in Visual Object Tracking + * + * This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/doc/uml + * + */ + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { +inline namespace tracking { + +/** @addtogroup tracking_detail +@{ +*/ + +/************************************ TrackerFeature Base Classes ************************************/ + +/** @brief Abstract base class for TrackerFeature that represents the feature. +*/ +class CV_EXPORTS TrackerFeature +{ +public: + virtual ~TrackerFeature(); + + /** @brief Compute the features in the images collection + @param images The images + @param response The output response + */ + void compute(const std::vector& images, Mat& response); + +protected: + virtual bool computeImpl(const std::vector& images, Mat& response) = 0; +}; + +/** @brief Class that manages the extraction and selection of features + +@cite AAM Feature Extraction and Feature Set Refinement (Feature Processing and Feature Selection). +See table I and section III C @cite AMVOT Appearance modelling -\> Visual representation (Table II, +section 3.1 - 3.2) + +TrackerFeatureSet is an aggregation of TrackerFeature + +@sa + TrackerFeature + +*/ +class CV_EXPORTS TrackerFeatureSet +{ +public: + TrackerFeatureSet(); + + ~TrackerFeatureSet(); + + /** @brief Extract features from the images collection + @param images The input images + */ + void extraction(const std::vector& images); + + /** @brief Add TrackerFeature in the collection. Return true if TrackerFeature is added, false otherwise + @param feature The TrackerFeature class + */ + bool addTrackerFeature(const Ptr& feature); + + /** @brief Get the TrackerFeature collection (TrackerFeature name, TrackerFeature pointer) + */ + const std::vector>& getTrackerFeatures() const; + + /** @brief Get the responses + @note Be sure to call extraction before getResponses Example TrackerFeatureSet::getResponses + */ + const std::vector& getResponses() const; + +private: + void clearResponses(); + bool blockAddTrackerFeature; + + std::vector> features; // list of features + std::vector responses; // list of response after compute +}; + +/************************************ TrackerSampler Base Classes ************************************/ + +/** @brief Abstract base class for TrackerSamplerAlgorithm that represents the algorithm for the specific +sampler. +*/ +class CV_EXPORTS TrackerSamplerAlgorithm +{ +public: + virtual ~TrackerSamplerAlgorithm(); + + /** @brief Computes the regions starting from a position in an image. + + Return true if samples are computed, false otherwise + + @param image The current frame + @param boundingBox The bounding box from which regions can be calculated + + @param sample The computed samples @cite AAM Fig. 1 variable Sk + */ + virtual bool sampling(const Mat& image, const Rect& boundingBox, std::vector& sample) = 0; +}; + +/** + * \brief Class that manages the sampler in order to select regions for the update the model of the tracker + * [AAM] Sampling e Labeling. See table I and section III B + */ + +/** @brief Class that manages the sampler in order to select regions for the update the model of the tracker + +@cite AAM Sampling e Labeling. See table I and section III B + +TrackerSampler is an aggregation of TrackerSamplerAlgorithm +@sa + TrackerSamplerAlgorithm + */ +class CV_EXPORTS TrackerSampler +{ +public: + TrackerSampler(); + + ~TrackerSampler(); + + /** @brief Computes the regions starting from a position in an image + @param image The current frame + @param boundingBox The bounding box from which regions can be calculated + */ + void sampling(const Mat& image, Rect boundingBox); + + /** @brief Return the collection of the TrackerSamplerAlgorithm + */ + const std::vector>& getSamplers() const; + + /** @brief Return the samples from all TrackerSamplerAlgorithm, @cite AAM Fig. 1 variable Sk + */ + const std::vector& getSamples() const; + + /** @brief Add TrackerSamplerAlgorithm in the collection. Return true if sampler is added, false otherwise + @param sampler The TrackerSamplerAlgorithm + */ + bool addTrackerSamplerAlgorithm(const Ptr& sampler); + +private: + std::vector> samplers; + std::vector samples; + bool blockAddTrackerSampler; + + void clearSamples(); +}; + +/************************************ TrackerModel Base Classes ************************************/ + +/** @brief Abstract base class for TrackerTargetState that represents a possible state of the target. + +See @cite AAM \f$\hat{x}^{i}_{k}\f$ all the states candidates. + +Inherits this class with your Target state, In own implementation you can add scale variation, +width, height, orientation, etc. +*/ +class CV_EXPORTS TrackerTargetState +{ +public: + virtual ~TrackerTargetState() {}; + /** @brief Get the position + * @return The position + */ + Point2f getTargetPosition() const; + + /** @brief Set the position + * @param position The position + */ + void setTargetPosition(const Point2f& position); + /** @brief Get the width of the target + * @return The width of the target + */ + int getTargetWidth() const; + + /** @brief Set the width of the target + * @param width The width of the target + */ + void setTargetWidth(int width); + /** @brief Get the height of the target + * @return The height of the target + */ + int getTargetHeight() const; + + /** @brief Set the height of the target + * @param height The height of the target + */ + void setTargetHeight(int height); + +protected: + Point2f targetPosition; + int targetWidth; + int targetHeight; +}; + +/** @brief Represents the model of the target at frame \f$k\f$ (all states and scores) + +See @cite AAM The set of the pair \f$\langle \hat{x}^{i}_{k}, C^{i}_{k} \rangle\f$ +@sa TrackerTargetState +*/ +typedef std::vector, float>> ConfidenceMap; + +/** @brief Represents the estimate states for all frames + +@cite AAM \f$x_{k}\f$ is the trajectory of the target up to time \f$k\f$ + +@sa TrackerTargetState +*/ +typedef std::vector> Trajectory; + +/** @brief Abstract base class for TrackerStateEstimator that estimates the most likely target state. + +See @cite AAM State estimator + +See @cite AMVOT Statistical modeling (Fig. 3), Table III (generative) - IV (discriminative) - V (hybrid) +*/ +class CV_EXPORTS TrackerStateEstimator +{ +public: + virtual ~TrackerStateEstimator(); + + /** @brief Estimate the most likely target state, return the estimated state + @param confidenceMaps The overall appearance model as a list of :cConfidenceMap + */ + Ptr estimate(const std::vector& confidenceMaps); + + /** @brief Update the ConfidenceMap with the scores + @param confidenceMaps The overall appearance model as a list of :cConfidenceMap + */ + void update(std::vector& confidenceMaps); + + /** @brief Create TrackerStateEstimator by tracker state estimator type + @param trackeStateEstimatorType The TrackerStateEstimator name + + The modes available now: + + - "BOOSTING" -- Boosting-based discriminative appearance models. See @cite AMVOT section 4.4 + + The modes available soon: + + - "SVM" -- SVM-based discriminative appearance models. See @cite AMVOT section 4.5 + */ + static Ptr create(const String& trackeStateEstimatorType); + + /** @brief Get the name of the specific TrackerStateEstimator + */ + String getClassName() const; + +protected: + virtual Ptr estimateImpl(const std::vector& confidenceMaps) = 0; + virtual void updateImpl(std::vector& confidenceMaps) = 0; + String className; +}; + +/** @brief Abstract class that represents the model of the target. + +It must be instantiated by specialized tracker + +See @cite AAM Ak + +Inherits this with your TrackerModel +*/ +class CV_EXPORTS TrackerModel +{ +public: + TrackerModel(); + + virtual ~TrackerModel(); + + /** @brief Set TrackerEstimator, return true if the tracker state estimator is added, false otherwise + @param trackerStateEstimator The TrackerStateEstimator + @note You can add only one TrackerStateEstimator + */ + bool setTrackerStateEstimator(Ptr trackerStateEstimator); + + /** @brief Estimate the most likely target location + + @cite AAM ME, Model Estimation table I + @param responses Features extracted from TrackerFeatureSet + */ + void modelEstimation(const std::vector& responses); + + /** @brief Update the model + + @cite AAM MU, Model Update table I + */ + void modelUpdate(); + + /** @brief Run the TrackerStateEstimator, return true if is possible to estimate a new state, false otherwise + */ + bool runStateEstimator(); + + /** @brief Set the current TrackerTargetState in the Trajectory + @param lastTargetState The current TrackerTargetState + */ + void setLastTargetState(const Ptr& lastTargetState); + + /** @brief Get the last TrackerTargetState from Trajectory + */ + Ptr getLastTargetState() const; + + /** @brief Get the list of the ConfidenceMap + */ + const std::vector& getConfidenceMaps() const; + + /** @brief Get the last ConfidenceMap for the current frame + */ + const ConfidenceMap& getLastConfidenceMap() const; + + /** @brief Get the TrackerStateEstimator + */ + Ptr getTrackerStateEstimator() const; + +private: + void clearCurrentConfidenceMap(); + +protected: + std::vector confidenceMaps; + Ptr stateEstimator; + ConfidenceMap currentConfidenceMap; + Trajectory trajectory; + int maxCMLength; + + virtual void modelEstimationImpl(const std::vector& responses) = 0; + virtual void modelUpdateImpl() = 0; +}; + +/************************************ Specific TrackerStateEstimator Classes ************************************/ + +// None + +/************************************ Specific TrackerSamplerAlgorithm Classes ************************************/ + +/** @brief TrackerSampler based on CSC (current state centered), used by MIL algorithm TrackerMIL + */ +class CV_EXPORTS TrackerSamplerCSC : public TrackerSamplerAlgorithm +{ +public: + ~TrackerSamplerCSC(); + + enum MODE + { + MODE_INIT_POS = 1, //!< mode for init positive samples + MODE_INIT_NEG = 2, //!< mode for init negative samples + MODE_TRACK_POS = 3, //!< mode for update positive samples + MODE_TRACK_NEG = 4, //!< mode for update negative samples + MODE_DETECT = 5 //!< mode for detect samples + }; + + struct CV_EXPORTS Params + { + Params(); + float initInRad; //!< radius for gathering positive instances during init + float trackInPosRad; //!< radius for gathering positive instances during tracking + float searchWinSize; //!< size of search window + int initMaxNegNum; //!< # negative samples to use during init + int trackMaxPosNum; //!< # positive samples to use during training + int trackMaxNegNum; //!< # negative samples to use during training + }; + + /** @brief Constructor + @param parameters TrackerSamplerCSC parameters TrackerSamplerCSC::Params + */ + TrackerSamplerCSC(const TrackerSamplerCSC::Params& parameters = TrackerSamplerCSC::Params()); + + /** @brief Set the sampling mode of TrackerSamplerCSC + @param samplingMode The sampling mode + + The modes are: + + - "MODE_INIT_POS = 1" -- for the positive sampling in initialization step + - "MODE_INIT_NEG = 2" -- for the negative sampling in initialization step + - "MODE_TRACK_POS = 3" -- for the positive sampling in update step + - "MODE_TRACK_NEG = 4" -- for the negative sampling in update step + - "MODE_DETECT = 5" -- for the sampling in detection step + */ + void setMode(int samplingMode); + + bool sampling(const Mat& image, const Rect& boundingBox, std::vector& sample) CV_OVERRIDE; + +private: + Params params; + int mode; + RNG rng; + + std::vector sampleImage(const Mat& img, int x, int y, int w, int h, float inrad, float outrad = 0, int maxnum = 1000000); +}; + +//! @} + +}}} // namespace cv::detail::tracking + +#endif // OPENCV_VIDEO_DETAIL_TRACKING_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/video/legacy/constants_c.h b/Cigarette/OpenCV455Simple/include/opencv2/video/legacy/constants_c.h new file mode 100644 index 0000000..1a98f52 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/video/legacy/constants_c.h @@ -0,0 +1,16 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEO_LEGACY_CONSTANTS_H +#define OPENCV_VIDEO_LEGACY_CONSTANTS_H + +enum +{ + CV_LKFLOW_PYR_A_READY = 1, + CV_LKFLOW_PYR_B_READY = 2, + CV_LKFLOW_INITIAL_GUESSES = 4, + CV_LKFLOW_GET_MIN_EIGENVALS = 8 +}; + +#endif // OPENCV_VIDEO_LEGACY_CONSTANTS_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/video/tracking.hpp b/Cigarette/OpenCV455Simple/include/opencv2/video/tracking.hpp new file mode 100644 index 0000000..7ec6bc5 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/video/tracking.hpp @@ -0,0 +1,857 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_TRACKING_HPP +#define OPENCV_TRACKING_HPP + +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" + +namespace cv +{ + +//! @addtogroup video_track +//! @{ + +enum { OPTFLOW_USE_INITIAL_FLOW = 4, + OPTFLOW_LK_GET_MIN_EIGENVALS = 8, + OPTFLOW_FARNEBACK_GAUSSIAN = 256 + }; + +/** @brief Finds an object center, size, and orientation. + +@param probImage Back projection of the object histogram. See calcBackProject. +@param window Initial search window. +@param criteria Stop criteria for the underlying meanShift. +returns +(in old interfaces) Number of iterations CAMSHIFT took to converge +The function implements the CAMSHIFT object tracking algorithm @cite Bradski98 . First, it finds an +object center using meanShift and then adjusts the window size and finds the optimal rotation. The +function returns the rotated rectangle structure that includes the object position, size, and +orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() + +See the OpenCV sample camshiftdemo.c that tracks colored objects. + +@note +- (Python) A sample explaining the camshift tracking algorithm can be found at + opencv_source_code/samples/python/camshift.py + */ +CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window, + TermCriteria criteria ); +/** @example samples/cpp/camshiftdemo.cpp +An example using the mean-shift tracking algorithm +*/ + +/** @brief Finds an object on a back projection image. + +@param probImage Back projection of the object histogram. See calcBackProject for details. +@param window Initial search window. +@param criteria Stop criteria for the iterative search algorithm. +returns +: Number of iterations CAMSHIFT took to converge. +The function implements the iterative object search algorithm. It takes the input back projection of +an object and the initial position. The mass center in window of the back projection image is +computed and the search window center shifts to the mass center. The procedure is repeated until the +specified number of iterations criteria.maxCount is done or until the window center shifts by less +than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search +window size or orientation do not change during the search. You can simply pass the output of +calcBackProject to this function. But better results can be obtained if you pre-filter the back +projection and remove the noise. For example, you can do this by retrieving connected components +with findContours , throwing away contours with small area ( contourArea ), and rendering the +remaining contours with drawContours. + + */ +CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria ); + +/** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK. + +@param img 8-bit input image. +@param pyramid output pyramid. +@param winSize window size of optical flow algorithm. Must be not less than winSize argument of +calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels. +@param maxLevel 0-based maximal pyramid level number. +@param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is +constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally. +@param pyrBorder the border mode for pyramid layers. +@param derivBorder the border mode for gradients. +@param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false +to force data copying. +@return number of levels in constructed pyramid. Can be less than maxLevel. + */ +CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays pyramid, + Size winSize, int maxLevel, bool withDerivatives = true, + int pyrBorder = BORDER_REFLECT_101, + int derivBorder = BORDER_CONSTANT, + bool tryReuseInputImage = true ); + +/** @example samples/cpp/lkdemo.cpp +An example using the Lucas-Kanade optical flow algorithm +*/ + +/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with +pyramids. + +@param prevImg first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid. +@param nextImg second input image or pyramid of the same size and the same type as prevImg. +@param prevPts vector of 2D points for which the flow needs to be found; point coordinates must be +single-precision floating-point numbers. +@param nextPts output vector of 2D points (with single-precision floating-point coordinates) +containing the calculated new positions of input features in the second image; when +OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input. +@param status output status vector (of unsigned chars); each element of the vector is set to 1 if +the flow for the corresponding features has been found, otherwise, it is set to 0. +@param err output vector of errors; each element of the vector is set to an error for the +corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't +found then the error is not defined (use the status parameter to find such cases). +@param winSize size of the search window at each pyramid level. +@param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single +level), if set to 1, two levels are used, and so on; if pyramids are passed to input then +algorithm will use as many levels as pyramids have but no more than maxLevel. +@param criteria parameter, specifying the termination criteria of the iterative search algorithm +(after the specified maximum number of iterations criteria.maxCount or when the search window +moves by less than criteria.epsilon. +@param flags operation flags: + - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is + not set, then prevPts is copied to nextPts and is considered the initial estimate. + - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see + minEigThreshold description); if the flag is not set, then L1 distance between patches + around the original and a moved point, divided by number of pixels in a window, is used as a + error measure. +@param minEigThreshold the algorithm calculates the minimum eigen value of a 2x2 normal matrix of +optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided +by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding +feature is filtered out and its flow is not processed, so it allows to remove bad points and get a +performance boost. + +The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See +@cite Bouguet00 . The function is parallelized with the TBB library. + +@note + +- An example using the Lucas-Kanade optical flow algorithm can be found at + opencv_source_code/samples/cpp/lkdemo.cpp +- (Python) An example using the Lucas-Kanade optical flow algorithm can be found at + opencv_source_code/samples/python/lk_track.py +- (Python) An example using the Lucas-Kanade tracker for homography matching can be found at + opencv_source_code/samples/python/lk_homography.py + */ +CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, + InputArray prevPts, InputOutputArray nextPts, + OutputArray status, OutputArray err, + Size winSize = Size(21,21), int maxLevel = 3, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), + int flags = 0, double minEigThreshold = 1e-4 ); + +/** @brief Computes a dense optical flow using the Gunnar Farneback's algorithm. + +@param prev first 8-bit single-channel input image. +@param next second input image of the same size and the same type as prev. +@param flow computed flow image that has the same size as prev and type CV_32FC2. +@param pyr_scale parameter, specifying the image scale (\<1) to build pyramids for each image; +pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous +one. +@param levels number of pyramid layers including the initial image; levels=1 means that no extra +layers are created and only the original images are used. +@param winsize averaging window size; larger values increase the algorithm robustness to image +noise and give more chances for fast motion detection, but yield more blurred motion field. +@param iterations number of iterations the algorithm does at each pyramid level. +@param poly_n size of the pixel neighborhood used to find polynomial expansion in each pixel; +larger values mean that the image will be approximated with smoother surfaces, yielding more +robust algorithm and more blurred motion field, typically poly_n =5 or 7. +@param poly_sigma standard deviation of the Gaussian that is used to smooth derivatives used as a +basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a +good value would be poly_sigma=1.5. +@param flags operation flags that can be a combination of the following: + - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation. + - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian \f$\texttt{winsize}\times\texttt{winsize}\f$ + filter instead of a box filter of the same size for optical flow estimation; usually, this + option gives z more accurate flow than with a box filter, at the cost of lower speed; + normally, winsize for a Gaussian window should be set to a larger value to achieve the same + level of robustness. + +The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that + +\f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f] + +@note + +- An example using the optical flow algorithm described by Gunnar Farneback can be found at + opencv_source_code/samples/cpp/fback.cpp +- (Python) An example using the optical flow algorithm described by Gunnar Farneback can be + found at opencv_source_code/samples/python/opt_flow.py + */ +CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow, + double pyr_scale, int levels, int winsize, + int iterations, int poly_n, double poly_sigma, + int flags ); + +/** @brief Computes an optimal affine transformation between two 2D point sets. + +@param src First input 2D point set stored in std::vector or Mat, or an image stored in Mat. +@param dst Second input 2D point set of the same size and the same type as A, or another image. +@param fullAffine If true, the function finds an optimal affine transformation with no additional +restrictions (6 degrees of freedom). Otherwise, the class of transformations to choose from is +limited to combinations of translation, rotation, and uniform scaling (4 degrees of freedom). + +The function finds an optimal affine transform *[A|b]* (a 2 x 3 floating-point matrix) that +approximates best the affine transformation between: + +* Two point sets +* Two raster images. In this case, the function first finds some features in the src image and + finds the corresponding features in dst image. After that, the problem is reduced to the first + case. +In case of point sets, the problem is formulated as follows: you need to find a 2x2 matrix *A* and +2x1 vector *b* so that: + +\f[[A^*|b^*] = arg \min _{[A|b]} \sum _i \| \texttt{dst}[i] - A { \texttt{src}[i]}^T - b \| ^2\f] +where src[i] and dst[i] are the i-th points in src and dst, respectively +\f$[A|b]\f$ can be either arbitrary (when fullAffine=true ) or have a form of +\f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ -a_{12} & a_{11} & b_2 \end{bmatrix}\f] +when fullAffine=false. + +@deprecated Use cv::estimateAffine2D, cv::estimateAffinePartial2D instead. If you are using this function +with images, extract points using cv::calcOpticalFlowPyrLK and then use the estimation functions. + +@sa +estimateAffine2D, estimateAffinePartial2D, getAffineTransform, getPerspectiveTransform, findHomography + */ +CV_DEPRECATED CV_EXPORTS Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine ); + +enum +{ + MOTION_TRANSLATION = 0, + MOTION_EUCLIDEAN = 1, + MOTION_AFFINE = 2, + MOTION_HOMOGRAPHY = 3 +}; + +/** @brief Computes the Enhanced Correlation Coefficient value between two images @cite EP08 . + +@param templateImage single-channel template image; CV_8U or CV_32F array. +@param inputImage single-channel input image to be warped to provide an image similar to + templateImage, same type as templateImage. +@param inputMask An optional mask to indicate valid values of inputImage. + +@sa +findTransformECC + */ + +CV_EXPORTS_W double computeECC(InputArray templateImage, InputArray inputImage, InputArray inputMask = noArray()); + +/** @example samples/cpp/image_alignment.cpp +An example using the image alignment ECC algorithm +*/ + +/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 . + +@param templateImage single-channel template image; CV_8U or CV_32F array. +@param inputImage single-channel input image which should be warped with the final warpMatrix in +order to provide an image similar to templateImage, same type as templateImage. +@param warpMatrix floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp). +@param motionType parameter, specifying the type of motion: + - **MOTION_TRANSLATION** sets a translational motion model; warpMatrix is \f$2\times 3\f$ with + the first \f$2\times 2\f$ part being the unity matrix and the rest two parameters being + estimated. + - **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three + parameters are estimated; warpMatrix is \f$2\times 3\f$. + - **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated; + warpMatrix is \f$2\times 3\f$. + - **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are + estimated;\`warpMatrix\` is \f$3\times 3\f$. +@param criteria parameter, specifying the termination criteria of the ECC algorithm; +criteria.epsilon defines the threshold of the increment in the correlation coefficient between two +iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion). +Default values are shown in the declaration above. +@param inputMask An optional mask to indicate valid values of inputImage. +@param gaussFiltSize An optional value indicating size of gaussian blur filter; (DEFAULT: 5) + +The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion +(@cite EP08), that is + +\f[\texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\f] + +where + +\f[\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\f] + +(the equation holds with homogeneous coordinates for homography). It returns the final enhanced +correlation coefficient, that is the correlation coefficient between the template image and the +final warped input image. When a \f$3\times 3\f$ matrix is given with motionType =0, 1 or 2, the third +row is ignored. + +Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an +area-based alignment that builds on intensity similarities. In essence, the function updates the +initial transformation that roughly aligns the images. If this information is missing, the identity +warp (unity matrix) is used as an initialization. Note that if images undergo strong +displacements/rotations, an initial transformation that roughly aligns the images is necessary +(e.g., a simple euclidean/similarity transform that allows for the images showing the same image +content approximately). Use inverse warping in the second image to take an image close to the first +one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV +sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws +an exception if algorithm does not converges. + +@sa +computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography + */ +CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray inputImage, + InputOutputArray warpMatrix, int motionType, + TermCriteria criteria, + InputArray inputMask, int gaussFiltSize); + +/** @overload */ +CV_EXPORTS_W +double findTransformECC(InputArray templateImage, InputArray inputImage, + InputOutputArray warpMatrix, int motionType = MOTION_AFFINE, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001), + InputArray inputMask = noArray()); + +/** @example samples/cpp/kalman.cpp +An example using the standard Kalman filter +*/ + +/** @brief Kalman filter class. + +The class implements a standard Kalman filter , +@cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get +an extended Kalman filter functionality. +@note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released +with cvReleaseKalman(&kalmanFilter) + */ +class CV_EXPORTS_W KalmanFilter +{ +public: + CV_WRAP KalmanFilter(); + /** @overload + @param dynamParams Dimensionality of the state. + @param measureParams Dimensionality of the measurement. + @param controlParams Dimensionality of the control vector. + @param type Type of the created matrices that should be CV_32F or CV_64F. + */ + CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); + + /** @brief Re-initializes Kalman filter. The previous content is destroyed. + + @param dynamParams Dimensionality of the state. + @param measureParams Dimensionality of the measurement. + @param controlParams Dimensionality of the control vector. + @param type Type of the created matrices that should be CV_32F or CV_64F. + */ + void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); + + /** @brief Computes a predicted state. + + @param control The optional input control + */ + CV_WRAP const Mat& predict( const Mat& control = Mat() ); + + /** @brief Updates the predicted state from the measurement. + + @param measurement The measured system parameters + */ + CV_WRAP const Mat& correct( const Mat& measurement ); + + CV_PROP_RW Mat statePre; //!< predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k) + CV_PROP_RW Mat statePost; //!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) + CV_PROP_RW Mat transitionMatrix; //!< state transition matrix (A) + CV_PROP_RW Mat controlMatrix; //!< control matrix (B) (not used if there is no control) + CV_PROP_RW Mat measurementMatrix; //!< measurement matrix (H) + CV_PROP_RW Mat processNoiseCov; //!< process noise covariance matrix (Q) + CV_PROP_RW Mat measurementNoiseCov;//!< measurement noise covariance matrix (R) + CV_PROP_RW Mat errorCovPre; //!< priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/ + CV_PROP_RW Mat gain; //!< Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R) + CV_PROP_RW Mat errorCovPost; //!< posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) + + // temporary matrices + Mat temp1; + Mat temp2; + Mat temp3; + Mat temp4; + Mat temp5; +}; + + +/** @brief Read a .flo file + + @param path Path to the file to be loaded + + The function readOpticalFlow loads a flow field from a file and returns it as a single matrix. + Resulting Mat has a type CV_32FC2 - floating-point, 2-channel. First channel corresponds to the + flow in the horizontal direction (u), second - vertical (v). + */ +CV_EXPORTS_W Mat readOpticalFlow( const String& path ); +/** @brief Write a .flo to disk + + @param path Path to the file to be written + @param flow Flow field to be stored + + The function stores a flow field in a file, returns true on success, false otherwise. + The flow field must be a 2-channel, floating-point matrix (CV_32FC2). First channel corresponds + to the flow in the horizontal direction (u), second - vertical (v). + */ +CV_EXPORTS_W bool writeOpticalFlow( const String& path, InputArray flow ); + +/** + Base class for dense optical flow algorithms +*/ +class CV_EXPORTS_W DenseOpticalFlow : public Algorithm +{ +public: + /** @brief Calculates an optical flow. + + @param I0 first 8-bit single-channel input image. + @param I1 second input image of the same size and the same type as prev. + @param flow computed flow image that has the same size as prev and type CV_32FC2. + */ + CV_WRAP virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; + /** @brief Releases all inner buffers. + */ + CV_WRAP virtual void collectGarbage() = 0; +}; + +/** @brief Base interface for sparse optical flow algorithms. + */ +class CV_EXPORTS_W SparseOpticalFlow : public Algorithm +{ +public: + /** @brief Calculates a sparse optical flow. + + @param prevImg First input image. + @param nextImg Second input image of the same size and the same type as prevImg. + @param prevPts Vector of 2D points for which the flow needs to be found. + @param nextPts Output vector of 2D points containing the calculated new positions of input features in the second image. + @param status Output status vector. Each element of the vector is set to 1 if the + flow for the corresponding features has been found. Otherwise, it is set to 0. + @param err Optional output vector that contains error response for each point (inverse confidence). + */ + CV_WRAP virtual void calc(InputArray prevImg, InputArray nextImg, + InputArray prevPts, InputOutputArray nextPts, + OutputArray status, + OutputArray err = cv::noArray()) = 0; +}; + + +/** @brief Class computing a dense optical flow using the Gunnar Farneback's algorithm. + */ +class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow +{ +public: + CV_WRAP virtual int getNumLevels() const = 0; + CV_WRAP virtual void setNumLevels(int numLevels) = 0; + + CV_WRAP virtual double getPyrScale() const = 0; + CV_WRAP virtual void setPyrScale(double pyrScale) = 0; + + CV_WRAP virtual bool getFastPyramids() const = 0; + CV_WRAP virtual void setFastPyramids(bool fastPyramids) = 0; + + CV_WRAP virtual int getWinSize() const = 0; + CV_WRAP virtual void setWinSize(int winSize) = 0; + + CV_WRAP virtual int getNumIters() const = 0; + CV_WRAP virtual void setNumIters(int numIters) = 0; + + CV_WRAP virtual int getPolyN() const = 0; + CV_WRAP virtual void setPolyN(int polyN) = 0; + + CV_WRAP virtual double getPolySigma() const = 0; + CV_WRAP virtual void setPolySigma(double polySigma) = 0; + + CV_WRAP virtual int getFlags() const = 0; + CV_WRAP virtual void setFlags(int flags) = 0; + + CV_WRAP static Ptr create( + int numLevels = 5, + double pyrScale = 0.5, + bool fastPyramids = false, + int winSize = 13, + int numIters = 10, + int polyN = 5, + double polySigma = 1.1, + int flags = 0); +}; + +/** @brief Variational optical flow refinement + +This class implements variational refinement of the input flow field, i.e. +it uses input flow to initialize the minimization of the following functional: +\f$E(U) = \int_{\Omega} \delta \Psi(E_I) + \gamma \Psi(E_G) + \alpha \Psi(E_S) \f$, +where \f$E_I,E_G,E_S\f$ are color constancy, gradient constancy and smoothness terms +respectively. \f$\Psi(s^2)=\sqrt{s^2+\epsilon^2}\f$ is a robust penalizer to limit the +influence of outliers. A complete formulation and a description of the minimization +procedure can be found in @cite Brox2004 +*/ +class CV_EXPORTS_W VariationalRefinement : public DenseOpticalFlow +{ +public: + /** @brief @ref calc function overload to handle separate horizontal (u) and vertical (v) flow components + (to avoid extra splits/merges) */ + CV_WRAP virtual void calcUV(InputArray I0, InputArray I1, InputOutputArray flow_u, InputOutputArray flow_v) = 0; + + /** @brief Number of outer (fixed-point) iterations in the minimization procedure. + @see setFixedPointIterations */ + CV_WRAP virtual int getFixedPointIterations() const = 0; + /** @copybrief getFixedPointIterations @see getFixedPointIterations */ + CV_WRAP virtual void setFixedPointIterations(int val) = 0; + + /** @brief Number of inner successive over-relaxation (SOR) iterations + in the minimization procedure to solve the respective linear system. + @see setSorIterations */ + CV_WRAP virtual int getSorIterations() const = 0; + /** @copybrief getSorIterations @see getSorIterations */ + CV_WRAP virtual void setSorIterations(int val) = 0; + + /** @brief Relaxation factor in SOR + @see setOmega */ + CV_WRAP virtual float getOmega() const = 0; + /** @copybrief getOmega @see getOmega */ + CV_WRAP virtual void setOmega(float val) = 0; + + /** @brief Weight of the smoothness term + @see setAlpha */ + CV_WRAP virtual float getAlpha() const = 0; + /** @copybrief getAlpha @see getAlpha */ + CV_WRAP virtual void setAlpha(float val) = 0; + + /** @brief Weight of the color constancy term + @see setDelta */ + CV_WRAP virtual float getDelta() const = 0; + /** @copybrief getDelta @see getDelta */ + CV_WRAP virtual void setDelta(float val) = 0; + + /** @brief Weight of the gradient constancy term + @see setGamma */ + CV_WRAP virtual float getGamma() const = 0; + /** @copybrief getGamma @see getGamma */ + CV_WRAP virtual void setGamma(float val) = 0; + + /** @brief Creates an instance of VariationalRefinement + */ + CV_WRAP static Ptr create(); +}; + +/** @brief DIS optical flow algorithm. + +This class implements the Dense Inverse Search (DIS) optical flow algorithm. More +details about the algorithm can be found at @cite Kroeger2016 . Includes three presets with preselected +parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is +still relatively fast, use DeepFlow if you need better quality and don't care about speed. + +This implementation includes several additional features compared to the algorithm described in the paper, +including spatial propagation of flow vectors (@ref getUseSpatialPropagation), as well as an option to +utilize an initial flow approximation passed to @ref calc (which is, essentially, temporal propagation, +if the previous frame's flow field is passed). +*/ +class CV_EXPORTS_W DISOpticalFlow : public DenseOpticalFlow +{ +public: + enum + { + PRESET_ULTRAFAST = 0, + PRESET_FAST = 1, + PRESET_MEDIUM = 2 + }; + + /** @brief Finest level of the Gaussian pyramid on which the flow is computed (zero level + corresponds to the original image resolution). The final flow is obtained by bilinear upscaling. + @see setFinestScale */ + CV_WRAP virtual int getFinestScale() const = 0; + /** @copybrief getFinestScale @see getFinestScale */ + CV_WRAP virtual void setFinestScale(int val) = 0; + + /** @brief Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well + enough in most cases. + @see setPatchSize */ + CV_WRAP virtual int getPatchSize() const = 0; + /** @copybrief getPatchSize @see getPatchSize */ + CV_WRAP virtual void setPatchSize(int val) = 0; + + /** @brief Stride between neighbor patches. Must be less than patch size. Lower values correspond + to higher flow quality. + @see setPatchStride */ + CV_WRAP virtual int getPatchStride() const = 0; + /** @copybrief getPatchStride @see getPatchStride */ + CV_WRAP virtual void setPatchStride(int val) = 0; + + /** @brief Maximum number of gradient descent iterations in the patch inverse search stage. Higher values + may improve quality in some cases. + @see setGradientDescentIterations */ + CV_WRAP virtual int getGradientDescentIterations() const = 0; + /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ + CV_WRAP virtual void setGradientDescentIterations(int val) = 0; + + /** @brief Number of fixed point iterations of variational refinement per scale. Set to zero to + disable variational refinement completely. Higher values will typically result in more smooth and + high-quality flow. + @see setGradientDescentIterations */ + CV_WRAP virtual int getVariationalRefinementIterations() const = 0; + /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ + CV_WRAP virtual void setVariationalRefinementIterations(int val) = 0; + + /** @brief Weight of the smoothness term + @see setVariationalRefinementAlpha */ + CV_WRAP virtual float getVariationalRefinementAlpha() const = 0; + /** @copybrief getVariationalRefinementAlpha @see getVariationalRefinementAlpha */ + CV_WRAP virtual void setVariationalRefinementAlpha(float val) = 0; + + /** @brief Weight of the color constancy term + @see setVariationalRefinementDelta */ + CV_WRAP virtual float getVariationalRefinementDelta() const = 0; + /** @copybrief getVariationalRefinementDelta @see getVariationalRefinementDelta */ + CV_WRAP virtual void setVariationalRefinementDelta(float val) = 0; + + /** @brief Weight of the gradient constancy term + @see setVariationalRefinementGamma */ + CV_WRAP virtual float getVariationalRefinementGamma() const = 0; + /** @copybrief getVariationalRefinementGamma @see getVariationalRefinementGamma */ + CV_WRAP virtual void setVariationalRefinementGamma(float val) = 0; + + + /** @brief Whether to use mean-normalization of patches when computing patch distance. It is turned on + by default as it typically provides a noticeable quality boost because of increased robustness to + illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes + in illumination. + @see setUseMeanNormalization */ + CV_WRAP virtual bool getUseMeanNormalization() const = 0; + /** @copybrief getUseMeanNormalization @see getUseMeanNormalization */ + CV_WRAP virtual void setUseMeanNormalization(bool val) = 0; + + /** @brief Whether to use spatial propagation of good optical flow vectors. This option is turned on by + default, as it tends to work better on average and can sometimes help recover from major errors + introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this + option off can make the output flow field a bit smoother, however. + @see setUseSpatialPropagation */ + CV_WRAP virtual bool getUseSpatialPropagation() const = 0; + /** @copybrief getUseSpatialPropagation @see getUseSpatialPropagation */ + CV_WRAP virtual void setUseSpatialPropagation(bool val) = 0; + + /** @brief Creates an instance of DISOpticalFlow + + @param preset one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM + */ + CV_WRAP static Ptr create(int preset = DISOpticalFlow::PRESET_FAST); +}; + +/** @brief Class used for calculating a sparse optical flow. + +The class can calculate an optical flow for a sparse feature set using the +iterative Lucas-Kanade method with pyramids. + +@sa calcOpticalFlowPyrLK + +*/ +class CV_EXPORTS_W SparsePyrLKOpticalFlow : public SparseOpticalFlow +{ +public: + CV_WRAP virtual Size getWinSize() const = 0; + CV_WRAP virtual void setWinSize(Size winSize) = 0; + + CV_WRAP virtual int getMaxLevel() const = 0; + CV_WRAP virtual void setMaxLevel(int maxLevel) = 0; + + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + CV_WRAP virtual void setTermCriteria(TermCriteria& crit) = 0; + + CV_WRAP virtual int getFlags() const = 0; + CV_WRAP virtual void setFlags(int flags) = 0; + + CV_WRAP virtual double getMinEigThreshold() const = 0; + CV_WRAP virtual void setMinEigThreshold(double minEigThreshold) = 0; + + CV_WRAP static Ptr create( + Size winSize = Size(21, 21), + int maxLevel = 3, TermCriteria crit = + TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), + int flags = 0, + double minEigThreshold = 1e-4); +}; + + + + +/** @brief Base abstract class for the long-term tracker + */ +class CV_EXPORTS_W Tracker +{ +protected: + Tracker(); +public: + virtual ~Tracker(); + + /** @brief Initialize the tracker with a known bounding box that surrounded the target + @param image The initial frame + @param boundingBox The initial bounding box + */ + CV_WRAP virtual + void init(InputArray image, const Rect& boundingBox) = 0; + + /** @brief Update the tracker, find the new most likely bounding box for the target + @param image The current frame + @param boundingBox The bounding box that represent the new target location, if true was returned, not + modified otherwise + + @return True means that target was located and false means that tracker cannot locate target in + current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed + missing from the frame (say, out of sight) + */ + CV_WRAP virtual + bool update(InputArray image, CV_OUT Rect& boundingBox) = 0; +}; + + + +/** @brief The MIL algorithm trains a classifier in an online manner to separate the object from the +background. + +Multiple Instance Learning avoids the drift problem for a robust tracking. The implementation is +based on @cite MIL . + +Original code can be found here + */ +class CV_EXPORTS_W TrackerMIL : public Tracker +{ +protected: + TrackerMIL(); // use ::create() +public: + virtual ~TrackerMIL() CV_OVERRIDE; + + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + //parameters for sampler + CV_PROP_RW float samplerInitInRadius; //!< radius for gathering positive instances during init + CV_PROP_RW int samplerInitMaxNegNum; //!< # negative samples to use during init + CV_PROP_RW float samplerSearchWinSize; //!< size of search window + CV_PROP_RW float samplerTrackInRadius; //!< radius for gathering positive instances during tracking + CV_PROP_RW int samplerTrackMaxPosNum; //!< # positive samples to use during tracking + CV_PROP_RW int samplerTrackMaxNegNum; //!< # negative samples to use during tracking + CV_PROP_RW int featureSetNumFeatures; //!< # features + }; + + /** @brief Create MIL tracker instance + * @param parameters MIL parameters TrackerMIL::Params + */ + static CV_WRAP + Ptr create(const TrackerMIL::Params ¶meters = TrackerMIL::Params()); + + //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; + //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; +}; + + + +/** @brief the GOTURN (Generic Object Tracking Using Regression Networks) tracker + * + * GOTURN (@cite GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers, + * GOTURN is much faster due to offline training without online fine-tuning nature. + * GOTURN tracker addresses the problem of single target tracking: given a bounding box label of an object in the first frame of the video, + * we track that object through the rest of the video. NOTE: Current method of GOTURN does not handle occlusions; however, it is fairly + * robust to viewpoint changes, lighting changes, and deformations. + * Inputs of GOTURN are two RGB patches representing Target and Search patches resized to 227x227. + * Outputs of GOTURN are predicted bounding box coordinates, relative to Search patch coordinate system, in format X1,Y1,X2,Y2. + * Original paper is here: + * As long as original authors implementation: + * Implementation of training algorithm is placed in separately here due to 3d-party dependencies: + * + * GOTURN architecture goturn.prototxt and trained model goturn.caffemodel are accessible on opencv_extra GitHub repository. + */ +class CV_EXPORTS_W TrackerGOTURN : public Tracker +{ +protected: + TrackerGOTURN(); // use ::create() +public: + virtual ~TrackerGOTURN() CV_OVERRIDE; + + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW std::string modelTxt; + CV_PROP_RW std::string modelBin; + }; + + /** @brief Constructor + @param parameters GOTURN parameters TrackerGOTURN::Params + */ + static CV_WRAP + Ptr create(const TrackerGOTURN::Params& parameters = TrackerGOTURN::Params()); + + //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; + //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; +}; + +class CV_EXPORTS_W TrackerDaSiamRPN : public Tracker +{ +protected: + TrackerDaSiamRPN(); // use ::create() +public: + virtual ~TrackerDaSiamRPN() CV_OVERRIDE; + + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW std::string model; + CV_PROP_RW std::string kernel_cls1; + CV_PROP_RW std::string kernel_r1; + CV_PROP_RW int backend; + CV_PROP_RW int target; + }; + + /** @brief Constructor + @param parameters DaSiamRPN parameters TrackerDaSiamRPN::Params + */ + static CV_WRAP + Ptr create(const TrackerDaSiamRPN::Params& parameters = TrackerDaSiamRPN::Params()); + + /** @brief Return tracking score + */ + CV_WRAP virtual float getTrackingScore() = 0; + + //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; + //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; +}; + + +//! @} video_track + +} // cv + +#endif diff --git a/Cigarette/OpenCV455Simple/include/opencv2/video/video.hpp b/Cigarette/OpenCV455Simple/include/opencv2/video/video.hpp new file mode 100644 index 0000000..8267b85 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/video/video.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/video.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/videoio.hpp b/Cigarette/OpenCV455Simple/include/opencv2/videoio.hpp new file mode 100644 index 0000000..93ea8cd --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/videoio.hpp @@ -0,0 +1,1129 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_VIDEOIO_HPP +#define OPENCV_VIDEOIO_HPP + +#include "opencv2/core.hpp" + +/** + @defgroup videoio Video I/O + + @brief Read and write video or images sequence with OpenCV + + ### See also: + - @ref videoio_overview + - Tutorials: @ref tutorial_table_of_content_app + @{ + @defgroup videoio_flags_base Flags for video I/O + @defgroup videoio_flags_others Additional flags for video I/O API backends + @defgroup videoio_hwaccel Hardware-accelerated video decoding and encoding + @defgroup videoio_c C API for video I/O + @defgroup videoio_ios iOS glue for video I/O + @defgroup videoio_winrt WinRT glue for video I/O + @defgroup videoio_registry Query I/O API backends registry + @} +*/ + +////////////////////////////////// video io ///////////////////////////////// + +typedef struct CvCapture CvCapture; +typedef struct CvVideoWriter CvVideoWriter; + +namespace cv +{ + +//! @addtogroup videoio +//! @{ + +//! @addtogroup videoio_flags_base +//! @{ + + +/** @brief cv::VideoCapture API backends identifier. + +Select preferred API for a capture object. +To be used in the VideoCapture::VideoCapture() constructor or VideoCapture::open() + +@note Backends are available only if they have been built with your OpenCV binaries. +See @ref videoio_overview for more information. +*/ +enum VideoCaptureAPIs { + CAP_ANY = 0, //!< Auto detect == 0 + CAP_VFW = 200, //!< Video For Windows (obsolete, removed) + CAP_V4L = 200, //!< V4L/V4L2 capturing support + CAP_V4L2 = CAP_V4L, //!< Same as CAP_V4L + CAP_FIREWIRE = 300, //!< IEEE 1394 drivers + CAP_FIREWARE = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_IEEE1394 = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_DC1394 = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_CMU1394 = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_QT = 500, //!< QuickTime (obsolete, removed) + CAP_UNICAP = 600, //!< Unicap drivers (obsolete, removed) + CAP_DSHOW = 700, //!< DirectShow (via videoInput) + CAP_PVAPI = 800, //!< PvAPI, Prosilica GigE SDK + CAP_OPENNI = 900, //!< OpenNI (for Kinect) + CAP_OPENNI_ASUS = 910, //!< OpenNI (for Asus Xtion) + CAP_ANDROID = 1000, //!< Android - not used + CAP_XIAPI = 1100, //!< XIMEA Camera API + CAP_AVFOUNDATION = 1200, //!< AVFoundation framework for iOS (OS X Lion will have the same API) + CAP_GIGANETIX = 1300, //!< Smartek Giganetix GigEVisionSDK + CAP_MSMF = 1400, //!< Microsoft Media Foundation (via videoInput) + CAP_WINRT = 1410, //!< Microsoft Windows Runtime using Media Foundation + CAP_INTELPERC = 1500, //!< RealSense (former Intel Perceptual Computing SDK) + CAP_REALSENSE = 1500, //!< Synonym for CAP_INTELPERC + CAP_OPENNI2 = 1600, //!< OpenNI2 (for Kinect) + CAP_OPENNI2_ASUS = 1610, //!< OpenNI2 (for Asus Xtion and Occipital Structure sensors) + CAP_OPENNI2_ASTRA= 1620, //!< OpenNI2 (for Orbbec Astra) + CAP_GPHOTO2 = 1700, //!< gPhoto2 connection + CAP_GSTREAMER = 1800, //!< GStreamer + CAP_FFMPEG = 1900, //!< Open and record video file or stream using the FFMPEG library + CAP_IMAGES = 2000, //!< OpenCV Image Sequence (e.g. img_%02d.jpg) + CAP_ARAVIS = 2100, //!< Aravis SDK + CAP_OPENCV_MJPEG = 2200, //!< Built-in OpenCV MotionJPEG codec + CAP_INTEL_MFX = 2300, //!< Intel MediaSDK + CAP_XINE = 2400, //!< XINE engine (Linux) + CAP_UEYE = 2500, //!< uEye Camera API + }; + +/** @brief cv::VideoCapture generic properties identifier. + + Reading / writing properties involves many layers. Some unexpected result might happens along this chain. + Effective behaviour depends from device hardware, driver and API Backend. + @sa videoio_flags_others, VideoCapture::get(), VideoCapture::set() +*/ +enum VideoCaptureProperties { + CAP_PROP_POS_MSEC =0, //!< Current position of the video file in milliseconds. + CAP_PROP_POS_FRAMES =1, //!< 0-based index of the frame to be decoded/captured next. + CAP_PROP_POS_AVI_RATIO =2, //!< Relative position of the video file: 0=start of the film, 1=end of the film. + CAP_PROP_FRAME_WIDTH =3, //!< Width of the frames in the video stream. + CAP_PROP_FRAME_HEIGHT =4, //!< Height of the frames in the video stream. + CAP_PROP_FPS =5, //!< Frame rate. + CAP_PROP_FOURCC =6, //!< 4-character code of codec. see VideoWriter::fourcc . + CAP_PROP_FRAME_COUNT =7, //!< Number of frames in the video file. + CAP_PROP_FORMAT =8, //!< Format of the %Mat objects (see Mat::type()) returned by VideoCapture::retrieve(). + //!< Set value -1 to fetch undecoded RAW video streams (as Mat 8UC1). + CAP_PROP_MODE =9, //!< Backend-specific value indicating the current capture mode. + CAP_PROP_BRIGHTNESS =10, //!< Brightness of the image (only for those cameras that support). + CAP_PROP_CONTRAST =11, //!< Contrast of the image (only for cameras). + CAP_PROP_SATURATION =12, //!< Saturation of the image (only for cameras). + CAP_PROP_HUE =13, //!< Hue of the image (only for cameras). + CAP_PROP_GAIN =14, //!< Gain of the image (only for those cameras that support). + CAP_PROP_EXPOSURE =15, //!< Exposure (only for those cameras that support). + CAP_PROP_CONVERT_RGB =16, //!< Boolean flags indicating whether images should be converted to RGB.
+ //!< *GStreamer note*: The flag is ignored in case if custom pipeline is used. It's user responsibility to interpret pipeline output. + CAP_PROP_WHITE_BALANCE_BLUE_U =17, //!< Currently unsupported. + CAP_PROP_RECTIFICATION =18, //!< Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently). + CAP_PROP_MONOCHROME =19, + CAP_PROP_SHARPNESS =20, + CAP_PROP_AUTO_EXPOSURE =21, //!< DC1394: exposure control done by camera, user can adjust reference level using this feature. + CAP_PROP_GAMMA =22, + CAP_PROP_TEMPERATURE =23, + CAP_PROP_TRIGGER =24, + CAP_PROP_TRIGGER_DELAY =25, + CAP_PROP_WHITE_BALANCE_RED_V =26, + CAP_PROP_ZOOM =27, + CAP_PROP_FOCUS =28, + CAP_PROP_GUID =29, + CAP_PROP_ISO_SPEED =30, + CAP_PROP_BACKLIGHT =32, + CAP_PROP_PAN =33, + CAP_PROP_TILT =34, + CAP_PROP_ROLL =35, + CAP_PROP_IRIS =36, + CAP_PROP_SETTINGS =37, //!< Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. The property value is ignored) + CAP_PROP_BUFFERSIZE =38, + CAP_PROP_AUTOFOCUS =39, + CAP_PROP_SAR_NUM =40, //!< Sample aspect ratio: num/den (num) + CAP_PROP_SAR_DEN =41, //!< Sample aspect ratio: num/den (den) + CAP_PROP_BACKEND =42, //!< Current backend (enum VideoCaptureAPIs). Read-only property + CAP_PROP_CHANNEL =43, //!< Video input or Channel Number (only for those cameras that support) + CAP_PROP_AUTO_WB =44, //!< enable/ disable auto white-balance + CAP_PROP_WB_TEMPERATURE=45, //!< white-balance color temperature + CAP_PROP_CODEC_PIXEL_FORMAT =46, //!< (read-only) codec's pixel format. 4-character code - see VideoWriter::fourcc . Subset of [AV_PIX_FMT_*](https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/raw.c) or -1 if unknown + CAP_PROP_BITRATE =47, //!< (read-only) Video bitrate in kbits/s + CAP_PROP_ORIENTATION_META=48, //!< (read-only) Frame rotation defined by stream meta (applicable for FFmpeg back-end only) + CAP_PROP_ORIENTATION_AUTO=49, //!< if true - rotates output frames of CvCapture considering video file's metadata (applicable for FFmpeg back-end only) (https://github.com/opencv/opencv/issues/15499) + CAP_PROP_HW_ACCELERATION=50, //!< (**open-only**) Hardware acceleration type (see #VideoAccelerationType). Setting supported only via `params` parameter in cv::VideoCapture constructor / .open() method. Default value is backend-specific. + CAP_PROP_HW_DEVICE =51, //!< (**open-only**) Hardware device index (select GPU if multiple available). Device enumeration is acceleration type specific. + CAP_PROP_HW_ACCELERATION_USE_OPENCL=52, //!< (**open-only**) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between HW accelerated decoder and cv::UMat. + CAP_PROP_OPEN_TIMEOUT_MSEC=53, //!< (**open-only**) timeout in milliseconds for opening a video capture (applicable for FFmpeg back-end only) + CAP_PROP_READ_TIMEOUT_MSEC=54, //!< (**open-only**) timeout in milliseconds for reading from a video capture (applicable for FFmpeg back-end only) + CAP_PROP_STREAM_OPEN_TIME_USEC =55, //). E.g. When reading from a h264 encoded RTSP stream, the FFmpeg backend could return the SPS and/or PPS if available (if sent in reply to a DESCRIBE request), from calls to cap.retrieve(data, ). +#ifndef CV_DOXYGEN + CV__CAP_PROP_LATEST +#endif + }; + +/** @brief cv::VideoWriter generic properties identifier. + @sa VideoWriter::get(), VideoWriter::set() +*/ +enum VideoWriterProperties { + VIDEOWRITER_PROP_QUALITY = 1, //!< Current quality (0..100%) of the encoded videostream. Can be adjusted dynamically in some codecs. + VIDEOWRITER_PROP_FRAMEBYTES = 2, //!< (Read-only): Size of just encoded video frame. Note that the encoding order may be different from representation order. + VIDEOWRITER_PROP_NSTRIPES = 3, //!< Number of stripes for parallel encoding. -1 for auto detection. + VIDEOWRITER_PROP_IS_COLOR = 4, //!< If it is not zero, the encoder will expect and encode color frames, otherwise it + //!< will work with grayscale frames. + VIDEOWRITER_PROP_DEPTH = 5, //!< Defaults to CV_8U. + VIDEOWRITER_PROP_HW_ACCELERATION = 6, //!< (**open-only**) Hardware acceleration type (see #VideoAccelerationType). Setting supported only via `params` parameter in VideoWriter constructor / .open() method. Default value is backend-specific. + VIDEOWRITER_PROP_HW_DEVICE = 7, //!< (**open-only**) Hardware device index (select GPU if multiple available). Device enumeration is acceleration type specific. + VIDEOWRITER_PROP_HW_ACCELERATION_USE_OPENCL= 8, //!< (**open-only**) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between cv::UMat and HW accelerated encoder. +#ifndef CV_DOXYGEN + CV__VIDEOWRITER_PROP_LATEST +#endif +}; + +//! @} videoio_flags_base + +//! @addtogroup videoio_flags_others +//! @{ + +/** @name Hardware acceleration support + @{ +*/ + +/** @brief Video Acceleration type + * + * Used as value in #CAP_PROP_HW_ACCELERATION and #VIDEOWRITER_PROP_HW_ACCELERATION + * + * @note In case of FFmpeg backend, it translated to enum AVHWDeviceType (https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/hwcontext.h) + */ +enum VideoAccelerationType +{ + VIDEO_ACCELERATION_NONE = 0, //!< Do not require any specific H/W acceleration, prefer software processing. + //!< Reading of this value means that special H/W accelerated handling is not added or not detected by OpenCV. + + VIDEO_ACCELERATION_ANY = 1, //!< Prefer to use H/W acceleration. If no one supported, then fallback to software processing. + //!< @note H/W acceleration may require special configuration of used environment. + //!< @note Results in encoding scenario may differ between software and hardware accelerated encoders. + + VIDEO_ACCELERATION_D3D11 = 2, //!< DirectX 11 + VIDEO_ACCELERATION_VAAPI = 3, //!< VAAPI + VIDEO_ACCELERATION_MFX = 4, //!< libmfx (Intel MediaSDK/oneVPL) +}; + +//! @} Hardware acceleration support + +/** @name IEEE 1394 drivers + @{ +*/ + +/** @brief Modes of the IEEE 1394 controlling registers +(can be: auto, manual, auto single push, absolute Latter allowed with any other mode) +every feature can have only one mode turned on at a time +*/ +enum { CAP_PROP_DC1394_OFF = -4, //!< turn the feature off (not controlled manually nor automatically). + CAP_PROP_DC1394_MODE_MANUAL = -3, //!< set automatically when a value of the feature is set by the user. + CAP_PROP_DC1394_MODE_AUTO = -2, + CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1, + CAP_PROP_DC1394_MAX = 31 + }; + +//! @} IEEE 1394 drivers + +/** @name OpenNI (for Kinect) + @{ +*/ + +//! OpenNI map generators +enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31, + CAP_OPENNI_IMAGE_GENERATOR = 1 << 30, + CAP_OPENNI_IR_GENERATOR = 1 << 29, + CAP_OPENNI_GENERATORS_MASK = CAP_OPENNI_DEPTH_GENERATOR + CAP_OPENNI_IMAGE_GENERATOR + CAP_OPENNI_IR_GENERATOR + }; + +//! Properties of cameras available through OpenNI backend +enum { CAP_PROP_OPENNI_OUTPUT_MODE = 100, + CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, //!< In mm + CAP_PROP_OPENNI_BASELINE = 102, //!< In mm + CAP_PROP_OPENNI_FOCAL_LENGTH = 103, //!< In pixels + CAP_PROP_OPENNI_REGISTRATION = 104, //!< Flag that synchronizes the remapping depth map to image map + //!< by changing depth generator's view point (if the flag is "on") or + //!< sets this view point to its normal one (if the flag is "off"). + CAP_PROP_OPENNI_REGISTRATION_ON = CAP_PROP_OPENNI_REGISTRATION, + CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105, + CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106, + CAP_PROP_OPENNI_CIRCLE_BUFFER = 107, + CAP_PROP_OPENNI_MAX_TIME_DURATION = 108, + CAP_PROP_OPENNI_GENERATOR_PRESENT = 109, + CAP_PROP_OPENNI2_SYNC = 110, + CAP_PROP_OPENNI2_MIRROR = 111 + }; + +//! OpenNI shortcuts +enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, + CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE, + CAP_OPENNI_DEPTH_GENERATOR_PRESENT = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, + CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE, + CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH, + CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION, + CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION, + CAP_OPENNI_IR_GENERATOR_PRESENT = CAP_OPENNI_IR_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, + }; + +//! OpenNI data given from depth generator +enum { CAP_OPENNI_DEPTH_MAP = 0, //!< Depth values in mm (CV_16UC1) + CAP_OPENNI_POINT_CLOUD_MAP = 1, //!< XYZ in meters (CV_32FC3) + CAP_OPENNI_DISPARITY_MAP = 2, //!< Disparity in pixels (CV_8UC1) + CAP_OPENNI_DISPARITY_MAP_32F = 3, //!< Disparity in pixels (CV_32FC1) + CAP_OPENNI_VALID_DEPTH_MASK = 4, //!< CV_8UC1 + + CAP_OPENNI_BGR_IMAGE = 5, //!< Data given from RGB image generator + CAP_OPENNI_GRAY_IMAGE = 6, //!< Data given from RGB image generator + + CAP_OPENNI_IR_IMAGE = 7 //!< Data given from IR image generator + }; + +//! Supported output modes of OpenNI image generator +enum { CAP_OPENNI_VGA_30HZ = 0, + CAP_OPENNI_SXGA_15HZ = 1, + CAP_OPENNI_SXGA_30HZ = 2, + CAP_OPENNI_QVGA_30HZ = 3, + CAP_OPENNI_QVGA_60HZ = 4 + }; + +//! @} OpenNI + +/** @name GStreamer + @{ +*/ + +enum { CAP_PROP_GSTREAMER_QUEUE_LENGTH = 200 //!< Default is 1 + }; + +//! @} GStreamer + +/** @name PvAPI, Prosilica GigE SDK + @{ +*/ + +//! PVAPI +enum { CAP_PROP_PVAPI_MULTICASTIP = 300, //!< IP for enable multicast master mode. 0 for disable multicast. + CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, //!< FrameStartTriggerMode: Determines how a frame is initiated. + CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, //!< Horizontal sub-sampling of the image. + CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, //!< Vertical sub-sampling of the image. + CAP_PROP_PVAPI_BINNINGX = 304, //!< Horizontal binning factor. + CAP_PROP_PVAPI_BINNINGY = 305, //!< Vertical binning factor. + CAP_PROP_PVAPI_PIXELFORMAT = 306 //!< Pixel format. + }; + +//! PVAPI: FrameStartTriggerMode +enum { CAP_PVAPI_FSTRIGMODE_FREERUN = 0, //!< Freerun + CAP_PVAPI_FSTRIGMODE_SYNCIN1 = 1, //!< SyncIn1 + CAP_PVAPI_FSTRIGMODE_SYNCIN2 = 2, //!< SyncIn2 + CAP_PVAPI_FSTRIGMODE_FIXEDRATE = 3, //!< FixedRate + CAP_PVAPI_FSTRIGMODE_SOFTWARE = 4 //!< Software + }; + +//! PVAPI: DecimationHorizontal, DecimationVertical +enum { CAP_PVAPI_DECIMATION_OFF = 1, //!< Off + CAP_PVAPI_DECIMATION_2OUTOF4 = 2, //!< 2 out of 4 decimation + CAP_PVAPI_DECIMATION_2OUTOF8 = 4, //!< 2 out of 8 decimation + CAP_PVAPI_DECIMATION_2OUTOF16 = 8 //!< 2 out of 16 decimation + }; + +//! PVAPI: PixelFormat +enum { CAP_PVAPI_PIXELFORMAT_MONO8 = 1, //!< Mono8 + CAP_PVAPI_PIXELFORMAT_MONO16 = 2, //!< Mono16 + CAP_PVAPI_PIXELFORMAT_BAYER8 = 3, //!< Bayer8 + CAP_PVAPI_PIXELFORMAT_BAYER16 = 4, //!< Bayer16 + CAP_PVAPI_PIXELFORMAT_RGB24 = 5, //!< Rgb24 + CAP_PVAPI_PIXELFORMAT_BGR24 = 6, //!< Bgr24 + CAP_PVAPI_PIXELFORMAT_RGBA32 = 7, //!< Rgba32 + CAP_PVAPI_PIXELFORMAT_BGRA32 = 8, //!< Bgra32 + }; + +//! @} PvAPI + +/** @name XIMEA Camera API + @{ +*/ + +//! Properties of cameras available through XIMEA SDK backend +enum { CAP_PROP_XI_DOWNSAMPLING = 400, //!< Change image resolution by binning or skipping. + CAP_PROP_XI_DATA_FORMAT = 401, //!< Output data format. + CAP_PROP_XI_OFFSET_X = 402, //!< Horizontal offset from the origin to the area of interest (in pixels). + CAP_PROP_XI_OFFSET_Y = 403, //!< Vertical offset from the origin to the area of interest (in pixels). + CAP_PROP_XI_TRG_SOURCE = 404, //!< Defines source of trigger. + CAP_PROP_XI_TRG_SOFTWARE = 405, //!< Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. + CAP_PROP_XI_GPI_SELECTOR = 406, //!< Selects general purpose input. + CAP_PROP_XI_GPI_MODE = 407, //!< Set general purpose input mode. + CAP_PROP_XI_GPI_LEVEL = 408, //!< Get general purpose level. + CAP_PROP_XI_GPO_SELECTOR = 409, //!< Selects general purpose output. + CAP_PROP_XI_GPO_MODE = 410, //!< Set general purpose output mode. + CAP_PROP_XI_LED_SELECTOR = 411, //!< Selects camera signalling LED. + CAP_PROP_XI_LED_MODE = 412, //!< Define camera signalling LED functionality. + CAP_PROP_XI_MANUAL_WB = 413, //!< Calculates White Balance(must be called during acquisition). + CAP_PROP_XI_AUTO_WB = 414, //!< Automatic white balance. + CAP_PROP_XI_AEAG = 415, //!< Automatic exposure/gain. + CAP_PROP_XI_EXP_PRIORITY = 416, //!< Exposure priority (0.5 - exposure 50%, gain 50%). + CAP_PROP_XI_AE_MAX_LIMIT = 417, //!< Maximum limit of exposure in AEAG procedure. + CAP_PROP_XI_AG_MAX_LIMIT = 418, //!< Maximum limit of gain in AEAG procedure. + CAP_PROP_XI_AEAG_LEVEL = 419, //!< Average intensity of output signal AEAG should achieve(in %). + CAP_PROP_XI_TIMEOUT = 420, //!< Image capture timeout in milliseconds. + CAP_PROP_XI_EXPOSURE = 421, //!< Exposure time in microseconds. + CAP_PROP_XI_EXPOSURE_BURST_COUNT = 422, //!< Sets the number of times of exposure in one frame. + CAP_PROP_XI_GAIN_SELECTOR = 423, //!< Gain selector for parameter Gain allows to select different type of gains. + CAP_PROP_XI_GAIN = 424, //!< Gain in dB. + CAP_PROP_XI_DOWNSAMPLING_TYPE = 426, //!< Change image downsampling type. + CAP_PROP_XI_BINNING_SELECTOR = 427, //!< Binning engine selector. + CAP_PROP_XI_BINNING_VERTICAL = 428, //!< Vertical Binning - number of vertical photo-sensitive cells to combine together. + CAP_PROP_XI_BINNING_HORIZONTAL = 429, //!< Horizontal Binning - number of horizontal photo-sensitive cells to combine together. + CAP_PROP_XI_BINNING_PATTERN = 430, //!< Binning pattern type. + CAP_PROP_XI_DECIMATION_SELECTOR = 431, //!< Decimation engine selector. + CAP_PROP_XI_DECIMATION_VERTICAL = 432, //!< Vertical Decimation - vertical sub-sampling of the image - reduces the vertical resolution of the image by the specified vertical decimation factor. + CAP_PROP_XI_DECIMATION_HORIZONTAL = 433, //!< Horizontal Decimation - horizontal sub-sampling of the image - reduces the horizontal resolution of the image by the specified vertical decimation factor. + CAP_PROP_XI_DECIMATION_PATTERN = 434, //!< Decimation pattern type. + CAP_PROP_XI_TEST_PATTERN_GENERATOR_SELECTOR = 587, //!< Selects which test pattern generator is controlled by the TestPattern feature. + CAP_PROP_XI_TEST_PATTERN = 588, //!< Selects which test pattern type is generated by the selected generator. + CAP_PROP_XI_IMAGE_DATA_FORMAT = 435, //!< Output data format. + CAP_PROP_XI_SHUTTER_TYPE = 436, //!< Change sensor shutter type(CMOS sensor). + CAP_PROP_XI_SENSOR_TAPS = 437, //!< Number of taps. + CAP_PROP_XI_AEAG_ROI_OFFSET_X = 439, //!< Automatic exposure/gain ROI offset X. + CAP_PROP_XI_AEAG_ROI_OFFSET_Y = 440, //!< Automatic exposure/gain ROI offset Y. + CAP_PROP_XI_AEAG_ROI_WIDTH = 441, //!< Automatic exposure/gain ROI Width. + CAP_PROP_XI_AEAG_ROI_HEIGHT = 442, //!< Automatic exposure/gain ROI Height. + CAP_PROP_XI_BPC = 445, //!< Correction of bad pixels. + CAP_PROP_XI_WB_KR = 448, //!< White balance red coefficient. + CAP_PROP_XI_WB_KG = 449, //!< White balance green coefficient. + CAP_PROP_XI_WB_KB = 450, //!< White balance blue coefficient. + CAP_PROP_XI_WIDTH = 451, //!< Width of the Image provided by the device (in pixels). + CAP_PROP_XI_HEIGHT = 452, //!< Height of the Image provided by the device (in pixels). + CAP_PROP_XI_REGION_SELECTOR = 589, //!< Selects Region in Multiple ROI which parameters are set by width, height, ... ,region mode. + CAP_PROP_XI_REGION_MODE = 595, //!< Activates/deactivates Region selected by Region Selector. + CAP_PROP_XI_LIMIT_BANDWIDTH = 459, //!< Set/get bandwidth(datarate)(in Megabits). + CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH = 460, //!< Sensor output data bit depth. + CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH = 461, //!< Device output data bit depth. + CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH = 462, //!< bitdepth of data returned by function xiGetImage. + CAP_PROP_XI_OUTPUT_DATA_PACKING = 463, //!< Device output data packing (or grouping) enabled. Packing could be enabled if output_data_bit_depth > 8 and packing capability is available. + CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE = 464, //!< Data packing type. Some cameras supports only specific packing type. + CAP_PROP_XI_IS_COOLED = 465, //!< Returns 1 for cameras that support cooling. + CAP_PROP_XI_COOLING = 466, //!< Start camera cooling. + CAP_PROP_XI_TARGET_TEMP = 467, //!< Set sensor target temperature for cooling. + CAP_PROP_XI_CHIP_TEMP = 468, //!< Camera sensor temperature. + CAP_PROP_XI_HOUS_TEMP = 469, //!< Camera housing temperature. + CAP_PROP_XI_HOUS_BACK_SIDE_TEMP = 590, //!< Camera housing back side temperature. + CAP_PROP_XI_SENSOR_BOARD_TEMP = 596, //!< Camera sensor board temperature. + CAP_PROP_XI_CMS = 470, //!< Mode of color management system. + CAP_PROP_XI_APPLY_CMS = 471, //!< Enable applying of CMS profiles to xiGetImage (see XI_PRM_INPUT_CMS_PROFILE, XI_PRM_OUTPUT_CMS_PROFILE). + CAP_PROP_XI_IMAGE_IS_COLOR = 474, //!< Returns 1 for color cameras. + CAP_PROP_XI_COLOR_FILTER_ARRAY = 475, //!< Returns color filter array type of RAW data. + CAP_PROP_XI_GAMMAY = 476, //!< Luminosity gamma. + CAP_PROP_XI_GAMMAC = 477, //!< Chromaticity gamma. + CAP_PROP_XI_SHARPNESS = 478, //!< Sharpness Strength. + CAP_PROP_XI_CC_MATRIX_00 = 479, //!< Color Correction Matrix element [0][0]. + CAP_PROP_XI_CC_MATRIX_01 = 480, //!< Color Correction Matrix element [0][1]. + CAP_PROP_XI_CC_MATRIX_02 = 481, //!< Color Correction Matrix element [0][2]. + CAP_PROP_XI_CC_MATRIX_03 = 482, //!< Color Correction Matrix element [0][3]. + CAP_PROP_XI_CC_MATRIX_10 = 483, //!< Color Correction Matrix element [1][0]. + CAP_PROP_XI_CC_MATRIX_11 = 484, //!< Color Correction Matrix element [1][1]. + CAP_PROP_XI_CC_MATRIX_12 = 485, //!< Color Correction Matrix element [1][2]. + CAP_PROP_XI_CC_MATRIX_13 = 486, //!< Color Correction Matrix element [1][3]. + CAP_PROP_XI_CC_MATRIX_20 = 487, //!< Color Correction Matrix element [2][0]. + CAP_PROP_XI_CC_MATRIX_21 = 488, //!< Color Correction Matrix element [2][1]. + CAP_PROP_XI_CC_MATRIX_22 = 489, //!< Color Correction Matrix element [2][2]. + CAP_PROP_XI_CC_MATRIX_23 = 490, //!< Color Correction Matrix element [2][3]. + CAP_PROP_XI_CC_MATRIX_30 = 491, //!< Color Correction Matrix element [3][0]. + CAP_PROP_XI_CC_MATRIX_31 = 492, //!< Color Correction Matrix element [3][1]. + CAP_PROP_XI_CC_MATRIX_32 = 493, //!< Color Correction Matrix element [3][2]. + CAP_PROP_XI_CC_MATRIX_33 = 494, //!< Color Correction Matrix element [3][3]. + CAP_PROP_XI_DEFAULT_CC_MATRIX = 495, //!< Set default Color Correction Matrix. + CAP_PROP_XI_TRG_SELECTOR = 498, //!< Selects the type of trigger. + CAP_PROP_XI_ACQ_FRAME_BURST_COUNT = 499, //!< Sets number of frames acquired by burst. This burst is used only if trigger is set to FrameBurstStart. + CAP_PROP_XI_DEBOUNCE_EN = 507, //!< Enable/Disable debounce to selected GPI. + CAP_PROP_XI_DEBOUNCE_T0 = 508, //!< Debounce time (x * 10us). + CAP_PROP_XI_DEBOUNCE_T1 = 509, //!< Debounce time (x * 10us). + CAP_PROP_XI_DEBOUNCE_POL = 510, //!< Debounce polarity (pol = 1 t0 - falling edge, t1 - rising edge). + CAP_PROP_XI_LENS_MODE = 511, //!< Status of lens control interface. This shall be set to XI_ON before any Lens operations. + CAP_PROP_XI_LENS_APERTURE_VALUE = 512, //!< Current lens aperture value in stops. Examples: 2.8, 4, 5.6, 8, 11. + CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE = 513, //!< Lens current focus movement value to be used by XI_PRM_LENS_FOCUS_MOVE in motor steps. + CAP_PROP_XI_LENS_FOCUS_MOVE = 514, //!< Moves lens focus motor by steps set in XI_PRM_LENS_FOCUS_MOVEMENT_VALUE. + CAP_PROP_XI_LENS_FOCUS_DISTANCE = 515, //!< Lens focus distance in cm. + CAP_PROP_XI_LENS_FOCAL_LENGTH = 516, //!< Lens focal distance in mm. + CAP_PROP_XI_LENS_FEATURE_SELECTOR = 517, //!< Selects the current feature which is accessible by XI_PRM_LENS_FEATURE. + CAP_PROP_XI_LENS_FEATURE = 518, //!< Allows access to lens feature value currently selected by XI_PRM_LENS_FEATURE_SELECTOR. + CAP_PROP_XI_DEVICE_MODEL_ID = 521, //!< Returns device model id. + CAP_PROP_XI_DEVICE_SN = 522, //!< Returns device serial number. + CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA = 529, //!< The alpha channel of RGB32 output image format. + CAP_PROP_XI_IMAGE_PAYLOAD_SIZE = 530, //!< Buffer size in bytes sufficient for output image returned by xiGetImage. + CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT = 531, //!< Current format of pixels on transport layer. + CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ = 532, //!< Sensor clock frequency in Hz. + CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX = 533, //!< Sensor clock frequency index. Sensor with selected frequencies have possibility to set the frequency only by this index. + CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT = 534, //!< Number of output channels from sensor used for data transfer. + CAP_PROP_XI_FRAMERATE = 535, //!< Define framerate in Hz. + CAP_PROP_XI_COUNTER_SELECTOR = 536, //!< Select counter. + CAP_PROP_XI_COUNTER_VALUE = 537, //!< Counter status. + CAP_PROP_XI_ACQ_TIMING_MODE = 538, //!< Type of sensor frames timing. + CAP_PROP_XI_AVAILABLE_BANDWIDTH = 539, //!< Calculate and returns available interface bandwidth(int Megabits). + CAP_PROP_XI_BUFFER_POLICY = 540, //!< Data move policy. + CAP_PROP_XI_LUT_EN = 541, //!< Activates LUT. + CAP_PROP_XI_LUT_INDEX = 542, //!< Control the index (offset) of the coefficient to access in the LUT. + CAP_PROP_XI_LUT_VALUE = 543, //!< Value at entry LUTIndex of the LUT. + CAP_PROP_XI_TRG_DELAY = 544, //!< Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + CAP_PROP_XI_TS_RST_MODE = 545, //!< Defines how time stamp reset engine will be armed. + CAP_PROP_XI_TS_RST_SOURCE = 546, //!< Defines which source will be used for timestamp reset. Writing this parameter will trigger settings of engine (arming). + CAP_PROP_XI_IS_DEVICE_EXIST = 547, //!< Returns 1 if camera connected and works properly. + CAP_PROP_XI_ACQ_BUFFER_SIZE = 548, //!< Acquisition buffer size in buffer_size_unit. Default bytes. + CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT = 549, //!< Acquisition buffer size unit in bytes. Default 1. E.g. Value 1024 means that buffer_size is in KiBytes. + CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE = 550, //!< Acquisition transport buffer size in bytes. + CAP_PROP_XI_BUFFERS_QUEUE_SIZE = 551, //!< Queue of field/frame buffers. + CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT = 552, //!< Number of buffers to commit to low level. + CAP_PROP_XI_RECENT_FRAME = 553, //!< GetImage returns most recent frame. + CAP_PROP_XI_DEVICE_RESET = 554, //!< Resets the camera to default state. + CAP_PROP_XI_COLUMN_FPN_CORRECTION = 555, //!< Correction of column FPN. + CAP_PROP_XI_ROW_FPN_CORRECTION = 591, //!< Correction of row FPN. + CAP_PROP_XI_SENSOR_MODE = 558, //!< Current sensor mode. Allows to select sensor mode by one integer. Setting of this parameter affects: image dimensions and downsampling. + CAP_PROP_XI_HDR = 559, //!< Enable High Dynamic Range feature. + CAP_PROP_XI_HDR_KNEEPOINT_COUNT = 560, //!< The number of kneepoints in the PWLR. + CAP_PROP_XI_HDR_T1 = 561, //!< Position of first kneepoint(in % of XI_PRM_EXPOSURE). + CAP_PROP_XI_HDR_T2 = 562, //!< Position of second kneepoint (in % of XI_PRM_EXPOSURE). + CAP_PROP_XI_KNEEPOINT1 = 563, //!< Value of first kneepoint (% of sensor saturation). + CAP_PROP_XI_KNEEPOINT2 = 564, //!< Value of second kneepoint (% of sensor saturation). + CAP_PROP_XI_IMAGE_BLACK_LEVEL = 565, //!< Last image black level counts. Can be used for Offline processing to recall it. + CAP_PROP_XI_HW_REVISION = 571, //!< Returns hardware revision number. + CAP_PROP_XI_DEBUG_LEVEL = 572, //!< Set debug level. + CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION = 573, //!< Automatic bandwidth calculation. + CAP_PROP_XI_FFS_FILE_ID = 594, //!< File number. + CAP_PROP_XI_FFS_FILE_SIZE = 580, //!< Size of file. + CAP_PROP_XI_FREE_FFS_SIZE = 581, //!< Size of free camera FFS. + CAP_PROP_XI_USED_FFS_SIZE = 582, //!< Size of used camera FFS. + CAP_PROP_XI_FFS_ACCESS_KEY = 583, //!< Setting of key enables file operations on some cameras. + CAP_PROP_XI_SENSOR_FEATURE_SELECTOR = 585, //!< Selects the current feature which is accessible by XI_PRM_SENSOR_FEATURE_VALUE. + CAP_PROP_XI_SENSOR_FEATURE_VALUE = 586, //!< Allows access to sensor feature value currently selected by XI_PRM_SENSOR_FEATURE_SELECTOR. + }; + +//! @} XIMEA + + +/** @name ARAVIS Camera API + @{ +*/ + +//! Properties of cameras available through ARAVIS backend +enum { CAP_PROP_ARAVIS_AUTOTRIGGER = 600 //!< Automatically trigger frame capture if camera is configured with software trigger +}; + +//! @} ARAVIS + +/** @name AVFoundation framework for iOS + @{ +*/ + +//! Properties of cameras available through AVFOUNDATION backend +enum { CAP_PROP_IOS_DEVICE_FOCUS = 9001, + CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, + CAP_PROP_IOS_DEVICE_FLASH = 9003, + CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, + CAP_PROP_IOS_DEVICE_TORCH = 9005 + }; + +//! @} AVFoundation framework for iOS + + +/** @name Smartek Giganetix GigEVisionSDK + @{ +*/ + +//! Properties of cameras available through Smartek Giganetix Ethernet Vision backend +/* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */ +enum { CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, + CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, + CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, + CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, + CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, + CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006 + }; + +//! @} Smartek + +/** @name Intel Perceptual Computing SDK + @{ +*/ +enum { CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, + CAP_PROP_INTELPERC_PROFILE_IDX = 11002, + CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, + CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, + CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, + CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, + CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007 + }; + +//! Intel Perceptual Streams +enum { CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, + CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, + CAP_INTELPERC_IR_GENERATOR = 1 << 27, + CAP_INTELPERC_GENERATORS_MASK = CAP_INTELPERC_DEPTH_GENERATOR + CAP_INTELPERC_IMAGE_GENERATOR + CAP_INTELPERC_IR_GENERATOR + }; + +enum { CAP_INTELPERC_DEPTH_MAP = 0, //!< Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. + CAP_INTELPERC_UVDEPTH_MAP = 1, //!< Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. + CAP_INTELPERC_IR_MAP = 2, //!< Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. + CAP_INTELPERC_IMAGE = 3 + }; + +//! @} Intel Perceptual + +/** @name gPhoto2 connection + @{ +*/ + +/** @brief gPhoto2 properties + +If `propertyId` is less than 0 then work on widget with that __additive inversed__ camera setting ID +Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE. +@see CvCaptureCAM_GPHOTO2 for more info +*/ +enum { CAP_PROP_GPHOTO2_PREVIEW = 17001, //!< Capture only preview from liveview mode. + CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, //!< Readonly, returns (const char *). + CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, //!< Trigger, only by set. Reload camera settings. + CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, //!< Reload all settings on set. + CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, //!< Collect messages with details. + CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, //!< Readonly, returns (const char *). + CAP_PROP_SPEED = 17007, //!< Exposure speed. Can be readonly, depends on camera program. + CAP_PROP_APERTURE = 17008, //!< Aperture. Can be readonly, depends on camera program. + CAP_PROP_EXPOSUREPROGRAM = 17009, //!< Camera exposure program. + CAP_PROP_VIEWFINDER = 17010 //!< Enter liveview mode. + }; + +//! @} gPhoto2 + + +/** @name Images backend + @{ +*/ + +/** @brief Images backend properties + +*/ +enum { CAP_PROP_IMAGES_BASE = 18000, + CAP_PROP_IMAGES_LAST = 19000 // excluding + }; + +//! @} Images + +//! @} videoio_flags_others + + +class IVideoCapture; +//! @cond IGNORED +namespace internal { class VideoCapturePrivateAccessor; } +//! @endcond IGNORED + +/** @brief Class for video capturing from video files, image sequences or cameras. + +The class provides C++ API for capturing video from cameras or for reading video files and image sequences. + +Here is how the class can be used: +@include samples/cpp/videocapture_basic.cpp + +@note In @ref videoio_c "C API" the black-box structure `CvCapture` is used instead of %VideoCapture. +@note +- (C++) A basic sample on using the %VideoCapture interface can be found at + `OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp` +- (Python) A basic sample on using the %VideoCapture interface can be found at + `OPENCV_SOURCE_CODE/samples/python/video.py` +- (Python) A multi threaded video processing sample can be found at + `OPENCV_SOURCE_CODE/samples/python/video_threaded.py` +- (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend + `OPENCV_SOURCE_CODE/samples/python/video_v4l2.py` + */ +class CV_EXPORTS_W VideoCapture +{ +public: + /** @brief Default constructor + @note In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with + cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + destructor. + */ + CV_WRAP VideoCapture(); + + /** @overload + @brief Opens a video file or a capturing device or an IP video stream for video capturing with API Preference + + @param filename it can be: + - name of video file (eg. `video.avi`) + - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`) + - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`) + - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend + Note that each video stream or IP camera feed has its own URL scheme. Please refer to the + documentation of source stream to know the right URL. + @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader + implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW. + + @sa cv::VideoCaptureAPIs + */ + CV_WRAP explicit VideoCapture(const String& filename, int apiPreference = CAP_ANY); + + /** @overload + @brief Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + */ + CV_WRAP explicit VideoCapture(const String& filename, int apiPreference, const std::vector& params); + + /** @overload + @brief Opens a camera for video capturing + + @param index id of the video capturing device to open. To open default camera using default backend just pass 0. + (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY) + @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader + implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L. + + @sa cv::VideoCaptureAPIs + */ + CV_WRAP explicit VideoCapture(int index, int apiPreference = CAP_ANY); + + /** @overload + @brief Opens a camera for video capturing with API Preference and parameters + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + */ + CV_WRAP explicit VideoCapture(int index, int apiPreference, const std::vector& params); + + /** @brief Default destructor + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + virtual ~VideoCapture(); + + /** @brief Opens a video file or a capturing device or an IP video stream for video capturing. + + @overload + + Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) + @return `true` if the file has been successfully opened + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(const String& filename, int apiPreference = CAP_ANY); + + /** @brief Opens a camera for video capturing + + @overload + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + + @return `true` if the file has been successfully opened + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(const String& filename, int apiPreference, const std::vector& params); + + /** @brief Opens a camera for video capturing + + @overload + + Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY) + @return `true` if the camera has been successfully opened. + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(int index, int apiPreference = CAP_ANY); + + /** @brief Returns true if video capturing has been initialized already. + + @overload + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + + @return `true` if the camera has been successfully opened. + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(int index, int apiPreference, const std::vector& params); + + /** @brief Returns true if video capturing has been initialized already. + + If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns + true. + */ + CV_WRAP virtual bool isOpened() const; + + /** @brief Closes video file or capturing device. + + The method is automatically called by subsequent VideoCapture::open and by VideoCapture + destructor. + + The C function also deallocates memory and clears \*capture pointer. + */ + CV_WRAP virtual void release(); + + /** @brief Grabs the next frame from video file or capturing device. + + @return `true` (non-zero) in the case of success. + + The method/function grabs the next frame from video file or camera and returns true (non-zero) in + the case of success. + + The primary use of the function is in multi-camera environments, especially when the cameras do not + have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that + call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way + the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames + from different cameras will be closer in time. + + Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the + correct way of retrieving data from it is to call VideoCapture::grab() first and then call + VideoCapture::retrieve() one or more times with different values of the channel parameter. + + @ref tutorial_kinect_openni + */ + CV_WRAP virtual bool grab(); + + /** @brief Decodes and returns the grabbed video frame. + + @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty. + @param flag it could be a frame index or a driver specific flag + @return `false` if no frames has been grabbed + + The method decodes and returns the just grabbed frame. If no frames has been grabbed + (camera has been disconnected, or there are no more frames in video file), the method returns false + and the function returns an empty image (with %cv::Mat, test it with Mat::empty()). + + @sa read() + + @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video + capturing structure. It is not allowed to modify or release the image! You can copy the frame using + cvCloneImage and then do whatever you want with the copy. + */ + CV_WRAP virtual bool retrieve(OutputArray image, int flag = 0); + + /** @brief Stream operator to read the next video frame. + @sa read() + */ + virtual VideoCapture& operator >> (CV_OUT Mat& image); + + /** @overload + @sa read() + */ + virtual VideoCapture& operator >> (CV_OUT UMat& image); + + /** @brief Grabs, decodes and returns the next video frame. + + @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty. + @return `false` if no frames has been grabbed + + The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the + most convenient method for reading video files or capturing data from decode and returns the just + grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more + frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()). + + @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video + capturing structure. It is not allowed to modify or release the image! You can copy the frame using + cvCloneImage and then do whatever you want with the copy. + */ + CV_WRAP virtual bool read(OutputArray image); + + /** @brief Sets a property in the VideoCapture. + + @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) + or one from @ref videoio_flags_others + @param value Value of the property. + @return `true` if the property is supported by backend used by the VideoCapture instance. + @note Even if it returns `true` this doesn't ensure that the property + value has been accepted by the capture device. See note in VideoCapture::get() + */ + CV_WRAP virtual bool set(int propId, double value); + + /** @brief Returns the specified VideoCapture property + + @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) + or one from @ref videoio_flags_others + @return Value for the specified property. Value 0 is returned when querying a property that is + not supported by the backend used by the VideoCapture instance. + + @note Reading / writing properties involves many layers. Some unexpected result might happens + along this chain. + @code{.txt} + VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware + @endcode + The returned value might be different from what really used by the device or it could be encoded + using device dependent rules (eg. steps or percentage). Effective behaviour depends from device + driver and API Backend + + */ + CV_WRAP virtual double get(int propId) const; + + /** @brief Returns used backend API name + + @note Stream should be opened. + */ + CV_WRAP String getBackendName() const; + + /** Switches exceptions mode + * + * methods raise exceptions if not successful instead of returning an error code + */ + CV_WRAP void setExceptionMode(bool enable) { throwOnFail = enable; } + + /// query if exception mode is active + CV_WRAP bool getExceptionMode() { return throwOnFail; } + + + /** @brief Wait for ready frames from VideoCapture. + + @param streams input video streams + @param readyIndex stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame) + @param timeoutNs number of nanoseconds (0 - infinite) + @return `true` if streamReady is not empty + + @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported + + The primary use of the function is in multi-camera environments. + The method fills the ready state vector, grabs video frame, if camera is ready. + + After this call use VideoCapture::retrieve() to decode and fetch frame data. + */ + static /*CV_WRAP*/ + bool waitAny( + const std::vector& streams, + CV_OUT std::vector& readyIndex, + int64 timeoutNs = 0); + +protected: + Ptr cap; + Ptr icap; + bool throwOnFail; + + friend class internal::VideoCapturePrivateAccessor; +}; + +class IVideoWriter; + +/** @example samples/cpp/tutorial_code/videoio/video-write/video-write.cpp +Check @ref tutorial_video_write "the corresponding tutorial" for more details +*/ + +/** @example samples/cpp/videowriter_basic.cpp +An example using VideoCapture and VideoWriter class +*/ + +/** @brief Video writer class. + +The class provides C++ API for writing video files or image sequences. +*/ +class CV_EXPORTS_W VideoWriter +{ +public: + /** @brief Default constructors + + The constructors/functions initialize video writers. + - On Linux FFMPEG is used to write videos; + - On Windows FFMPEG or MSWF or DSHOW is used; + - On MacOSX AVFoundation is used. + */ + CV_WRAP VideoWriter(); + + /** @overload + @param filename Name of the output video file. + @param fourcc 4-character code of codec used to compress the frames. For example, + VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a + motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by + FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses + other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), + so you may receive a warning message from OpenCV about fourcc code conversion. + @param fps Framerate of the created video stream. + @param frameSize Size of the video frames. + @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it + will work with grayscale frames. + + @b Tips: + - With some backends `fourcc=-1` pops up the codec selection dialog from the system. + - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0` + OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames. + - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs + (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) + - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file. + */ + CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation + if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. + */ + CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + * The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) + * see cv::VideoWriterProperties + */ + CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, const Size& frameSize, + const std::vector& params); + + /** @overload + */ + CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps, + const Size& frameSize, const std::vector& params); + + /** @brief Default destructor + + The method first calls VideoWriter::release to close the already opened file. + */ + virtual ~VideoWriter(); + + /** @brief Initializes or reinitializes video writer. + + The method opens video writer. Parameters are the same as in the constructor + VideoWriter::VideoWriter. + @return `true` if video writer has been successfully initialized + + The method first calls VideoWriter::release to close the already opened file. + */ + CV_WRAP virtual bool open(const String& filename, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + */ + CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + */ + CV_WRAP bool open(const String& filename, int fourcc, double fps, const Size& frameSize, + const std::vector& params); + + /** @overload + */ + CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps, + const Size& frameSize, const std::vector& params); + + /** @brief Returns true if video writer has been successfully initialized. + */ + CV_WRAP virtual bool isOpened() const; + + /** @brief Closes the video writer. + + The method is automatically called by subsequent VideoWriter::open and by the VideoWriter + destructor. + */ + CV_WRAP virtual void release(); + + /** @brief Stream operator to write the next video frame. + @sa write + */ + virtual VideoWriter& operator << (const Mat& image); + + /** @overload + @sa write + */ + virtual VideoWriter& operator << (const UMat& image); + + /** @brief Writes the next video frame + + @param image The written frame. In general, color images are expected in BGR format. + + The function/method writes the specified image to video file. It must have the same size as has + been specified when opening the video writer. + */ + CV_WRAP virtual void write(InputArray image); + + /** @brief Sets a property in the VideoWriter. + + @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) + or one of @ref videoio_flags_others + + @param value Value of the property. + @return `true` if the property is supported by the backend used by the VideoWriter instance. + */ + CV_WRAP virtual bool set(int propId, double value); + + /** @brief Returns the specified VideoWriter property + + @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) + or one of @ref videoio_flags_others + + @return Value for the specified property. Value 0 is returned when querying a property that is + not supported by the backend used by the VideoWriter instance. + */ + CV_WRAP virtual double get(int propId) const; + + /** @brief Concatenates 4 chars to a fourcc code + + @return a fourcc code + + This static method constructs the fourcc code of the codec to be used in the constructor + VideoWriter::VideoWriter or VideoWriter::open. + */ + CV_WRAP static int fourcc(char c1, char c2, char c3, char c4); + + /** @brief Returns used backend API name + + @note Stream should be opened. + */ + CV_WRAP String getBackendName() const; + +protected: + Ptr writer; + Ptr iwriter; + + static Ptr create(const String& filename, int fourcc, double fps, + Size frameSize, bool isColor = true); +}; + +//! @cond IGNORED +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvCapture* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvVideoWriter* obj) const; }; +//! @endcond IGNORED + +//! @} videoio + +} // cv + +#endif //OPENCV_VIDEOIO_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/videoio/cap_ios.h b/Cigarette/OpenCV455Simple/include/opencv2/videoio/cap_ios.h new file mode 100644 index 0000000..207ad46 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/videoio/cap_ios.h @@ -0,0 +1,150 @@ +/* For iOS video I/O + * by Eduard Feicho on 29/07/12 + * Copyright 2012. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * 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. + * + */ + +#import +#import +#import +#import +#include "opencv2/core.hpp" + +//! @addtogroup videoio_ios +//! @{ + +/////////////////////////////////////// CvAbstractCamera ///////////////////////////////////// + +@class CvAbstractCamera; + +CV_EXPORTS @interface CvAbstractCamera : NSObject +{ + UIDeviceOrientation currentDeviceOrientation; + + BOOL cameraAvailable; +} + +@property (nonatomic, strong) AVCaptureSession* captureSession; +@property (nonatomic, strong) AVCaptureConnection* videoCaptureConnection; + +@property (nonatomic, readonly) BOOL running; +@property (nonatomic, readonly) BOOL captureSessionLoaded; + +@property (nonatomic, assign) int defaultFPS; +@property (nonatomic, readonly) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer; +@property (nonatomic, assign) AVCaptureDevicePosition defaultAVCaptureDevicePosition; +@property (nonatomic, assign) AVCaptureVideoOrientation defaultAVCaptureVideoOrientation; +@property (nonatomic, assign) BOOL useAVCaptureVideoPreviewLayer; +@property (nonatomic, strong) NSString *const defaultAVCaptureSessionPreset; + +@property (nonatomic, assign) int imageWidth; +@property (nonatomic, assign) int imageHeight; + +@property (nonatomic, strong) UIView* parentView; + +- CV_UNUSED(start); +- CV_UNUSED(stop); +- CV_UNUSED(switchCameras); + +- (id)initWithParentView:(UIView*)parent; + +- CV_UNUSED(createCaptureOutput); +- CV_UNUSED(createVideoPreviewLayer); +- CV_UNUSED(updateOrientation); + +- CV_UNUSED(lockFocus); +- CV_UNUSED(unlockFocus); +- CV_UNUSED(lockExposure); +- CV_UNUSED(unlockExposure); +- CV_UNUSED(lockBalance); +- CV_UNUSED(unlockBalance); + +@end + +///////////////////////////////// CvVideoCamera /////////////////////////////////////////// + +@class CvVideoCamera; + +CV_EXPORTS @protocol CvVideoCameraDelegate + +#ifdef __cplusplus +// delegate method for processing image frames +- (void)processImage:(cv::Mat&)image; +#endif + +@end + +CV_EXPORTS @interface CvVideoCamera : CvAbstractCamera +{ + AVCaptureVideoDataOutput *videoDataOutput; + + dispatch_queue_t videoDataOutputQueue; + CALayer *customPreviewLayer; + + CMTime lastSampleTime; + +} + +@property (nonatomic, weak) id delegate; +@property (nonatomic, assign) BOOL grayscaleMode; + +@property (nonatomic, assign) BOOL recordVideo; +@property (nonatomic, assign) BOOL rotateVideo; +@property (nonatomic, strong) AVAssetWriterInput* recordAssetWriterInput; +@property (nonatomic, strong) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor; +@property (nonatomic, strong) AVAssetWriter* recordAssetWriter; + +- (void)adjustLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; +- CV_UNUSED(layoutPreviewLayer); +- CV_UNUSED(saveVideo); +- (NSURL *)videoFileURL; +- (NSString *)videoFileString; + + +@end + +///////////////////////////////// CvPhotoCamera /////////////////////////////////////////// + +@class CvPhotoCamera; + +CV_EXPORTS @protocol CvPhotoCameraDelegate + +- (void)photoCamera:(CvPhotoCamera*)photoCamera capturedImage:(UIImage *)image; +- (void)photoCameraCancel:(CvPhotoCamera*)photoCamera; + +@end + +CV_EXPORTS @interface CvPhotoCamera : CvAbstractCamera +{ + AVCaptureStillImageOutput *stillImageOutput; +} + +@property (nonatomic, weak) id delegate; + +- CV_UNUSED(takePicture); + +@end + +//! @} videoio_ios diff --git a/Cigarette/OpenCV455Simple/include/opencv2/videoio/legacy/constants_c.h b/Cigarette/OpenCV455Simple/include/opencv2/videoio/legacy/constants_c.h new file mode 100644 index 0000000..91f85f8 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/videoio/legacy/constants_c.h @@ -0,0 +1,434 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEOIO_LEGACY_CONSTANTS_H +#define OPENCV_VIDEOIO_LEGACY_CONSTANTS_H + +enum +{ + CV_CAP_ANY =0, // autodetect + + CV_CAP_MIL =100, // MIL proprietary drivers + + CV_CAP_VFW =200, // platform native + CV_CAP_V4L =200, + CV_CAP_V4L2 =200, + + CV_CAP_FIREWARE =300, // IEEE 1394 drivers + CV_CAP_FIREWIRE =300, + CV_CAP_IEEE1394 =300, + CV_CAP_DC1394 =300, + CV_CAP_CMU1394 =300, + + CV_CAP_STEREO =400, // TYZX proprietary drivers + CV_CAP_TYZX =400, + CV_TYZX_LEFT =400, + CV_TYZX_RIGHT =401, + CV_TYZX_COLOR =402, + CV_TYZX_Z =403, + + CV_CAP_QT =500, // QuickTime + + CV_CAP_UNICAP =600, // Unicap drivers + + CV_CAP_DSHOW =700, // DirectShow (via videoInput) + CV_CAP_MSMF =1400, // Microsoft Media Foundation (via videoInput) + + CV_CAP_PVAPI =800, // PvAPI, Prosilica GigE SDK + + CV_CAP_OPENNI =900, // OpenNI (for Kinect) + CV_CAP_OPENNI_ASUS =910, // OpenNI (for Asus Xtion) + + CV_CAP_ANDROID =1000, // Android - not used + CV_CAP_ANDROID_BACK =CV_CAP_ANDROID+99, // Android back camera - not used + CV_CAP_ANDROID_FRONT =CV_CAP_ANDROID+98, // Android front camera - not used + + CV_CAP_XIAPI =1100, // XIMEA Camera API + + CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API) + + CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK + + CV_CAP_INTELPERC = 1500, // Intel Perceptual Computing + + CV_CAP_OPENNI2 = 1600, // OpenNI2 (for Kinect) + CV_CAP_GPHOTO2 = 1700, + CV_CAP_GSTREAMER = 1800, // GStreamer + CV_CAP_FFMPEG = 1900, // FFMPEG + CV_CAP_IMAGES = 2000, // OpenCV Image Sequence (e.g. img_%02d.jpg) + + CV_CAP_ARAVIS = 2100 // Aravis GigE SDK +}; + +enum +{ + // modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode) + // every feature can have only one mode turned on at a time + CV_CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically) + CV_CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user + CV_CAP_PROP_DC1394_MODE_AUTO = -2, + CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1, + CV_CAP_PROP_POS_MSEC =0, + CV_CAP_PROP_POS_FRAMES =1, + CV_CAP_PROP_POS_AVI_RATIO =2, + CV_CAP_PROP_FRAME_WIDTH =3, + CV_CAP_PROP_FRAME_HEIGHT =4, + CV_CAP_PROP_FPS =5, + CV_CAP_PROP_FOURCC =6, + CV_CAP_PROP_FRAME_COUNT =7, + CV_CAP_PROP_FORMAT =8, + CV_CAP_PROP_MODE =9, + CV_CAP_PROP_BRIGHTNESS =10, + CV_CAP_PROP_CONTRAST =11, + CV_CAP_PROP_SATURATION =12, + CV_CAP_PROP_HUE =13, + CV_CAP_PROP_GAIN =14, + CV_CAP_PROP_EXPOSURE =15, + CV_CAP_PROP_CONVERT_RGB =16, + CV_CAP_PROP_WHITE_BALANCE_BLUE_U =17, + CV_CAP_PROP_RECTIFICATION =18, + CV_CAP_PROP_MONOCHROME =19, + CV_CAP_PROP_SHARPNESS =20, + CV_CAP_PROP_AUTO_EXPOSURE =21, // exposure control done by camera, + // user can adjust reference level + // using this feature + CV_CAP_PROP_GAMMA =22, + CV_CAP_PROP_TEMPERATURE =23, + CV_CAP_PROP_TRIGGER =24, + CV_CAP_PROP_TRIGGER_DELAY =25, + CV_CAP_PROP_WHITE_BALANCE_RED_V =26, + CV_CAP_PROP_ZOOM =27, + CV_CAP_PROP_FOCUS =28, + CV_CAP_PROP_GUID =29, + CV_CAP_PROP_ISO_SPEED =30, + CV_CAP_PROP_MAX_DC1394 =31, + CV_CAP_PROP_BACKLIGHT =32, + CV_CAP_PROP_PAN =33, + CV_CAP_PROP_TILT =34, + CV_CAP_PROP_ROLL =35, + CV_CAP_PROP_IRIS =36, + CV_CAP_PROP_SETTINGS =37, + CV_CAP_PROP_BUFFERSIZE =38, + CV_CAP_PROP_AUTOFOCUS =39, + CV_CAP_PROP_SAR_NUM =40, + CV_CAP_PROP_SAR_DEN =41, + + CV_CAP_PROP_AUTOGRAB =1024, // property for videoio class CvCapture_Android only + CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING=1025, // readonly, tricky property, returns cpnst char* indeed + CV_CAP_PROP_PREVIEW_FORMAT=1026, // readonly, tricky property, returns cpnst char* indeed + + // OpenNI map generators + CV_CAP_OPENNI_DEPTH_GENERATOR = 1 << 31, + CV_CAP_OPENNI_IMAGE_GENERATOR = 1 << 30, + CV_CAP_OPENNI_IR_GENERATOR = 1 << 29, + CV_CAP_OPENNI_GENERATORS_MASK = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_OPENNI_IR_GENERATOR, + + // Properties of cameras available through OpenNI interfaces + CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100, + CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm + CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm + CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels + CV_CAP_PROP_OPENNI_REGISTRATION = 104, // flag + CV_CAP_PROP_OPENNI_REGISTRATION_ON = CV_CAP_PROP_OPENNI_REGISTRATION, // flag that synchronizes the remapping depth map to image map + // by changing depth generator's view point (if the flag is "on") or + // sets this view point to its normal one (if the flag is "off"). + CV_CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105, + CV_CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106, + CV_CAP_PROP_OPENNI_CIRCLE_BUFFER = 107, + CV_CAP_PROP_OPENNI_MAX_TIME_DURATION = 108, + + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT = 109, + CV_CAP_PROP_OPENNI2_SYNC = 110, + CV_CAP_PROP_OPENNI2_MIRROR = 111, + + CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, + CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE, + CV_CAP_OPENNI_DEPTH_GENERATOR_PRESENT = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, + CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE, + CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH, + CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION, + CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION, + CV_CAP_OPENNI_IR_GENERATOR_PRESENT = CV_CAP_OPENNI_IR_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, + + // Properties of cameras available through GStreamer interface + CV_CAP_GSTREAMER_QUEUE_LENGTH = 200, // default is 1 + + // PVAPI + CV_CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast + CV_CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, // FrameStartTriggerMode: Determines how a frame is initiated + CV_CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image + CV_CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image + CV_CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor + CV_CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor + CV_CAP_PROP_PVAPI_PIXELFORMAT = 306, // Pixel format + + // Properties of cameras available through XIMEA SDK interface + CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. + CV_CAP_PROP_XI_DATA_FORMAT = 401, // Output data format. + CV_CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels). + CV_CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels). + CV_CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger. + CV_CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. + CV_CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input + CV_CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode + CV_CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level + CV_CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output + CV_CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode + CV_CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED + CV_CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality + CV_CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition) + CV_CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance + CV_CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain + CV_CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%). + CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure + CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure + CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %) + CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds + CV_CAP_PROP_XI_EXPOSURE = 421, // Exposure time in microseconds + CV_CAP_PROP_XI_EXPOSURE_BURST_COUNT = 422, // Sets the number of times of exposure in one frame. + CV_CAP_PROP_XI_GAIN_SELECTOR = 423, // Gain selector for parameter Gain allows to select different type of gains. + CV_CAP_PROP_XI_GAIN = 424, // Gain in dB + CV_CAP_PROP_XI_DOWNSAMPLING_TYPE = 426, // Change image downsampling type. + CV_CAP_PROP_XI_BINNING_SELECTOR = 427, // Binning engine selector. + CV_CAP_PROP_XI_BINNING_VERTICAL = 428, // Vertical Binning - number of vertical photo-sensitive cells to combine together. + CV_CAP_PROP_XI_BINNING_HORIZONTAL = 429, // Horizontal Binning - number of horizontal photo-sensitive cells to combine together. + CV_CAP_PROP_XI_BINNING_PATTERN = 430, // Binning pattern type. + CV_CAP_PROP_XI_DECIMATION_SELECTOR = 431, // Decimation engine selector. + CV_CAP_PROP_XI_DECIMATION_VERTICAL = 432, // Vertical Decimation - vertical sub-sampling of the image - reduces the vertical resolution of the image by the specified vertical decimation factor. + CV_CAP_PROP_XI_DECIMATION_HORIZONTAL = 433, // Horizontal Decimation - horizontal sub-sampling of the image - reduces the horizontal resolution of the image by the specified vertical decimation factor. + CV_CAP_PROP_XI_DECIMATION_PATTERN = 434, // Decimation pattern type. + CV_CAP_PROP_XI_TEST_PATTERN_GENERATOR_SELECTOR = 587, // Selects which test pattern generator is controlled by the TestPattern feature. + CV_CAP_PROP_XI_TEST_PATTERN = 588, // Selects which test pattern type is generated by the selected generator. + CV_CAP_PROP_XI_IMAGE_DATA_FORMAT = 435, // Output data format. + CV_CAP_PROP_XI_SHUTTER_TYPE = 436, // Change sensor shutter type(CMOS sensor). + CV_CAP_PROP_XI_SENSOR_TAPS = 437, // Number of taps + CV_CAP_PROP_XI_AEAG_ROI_OFFSET_X = 439, // Automatic exposure/gain ROI offset X + CV_CAP_PROP_XI_AEAG_ROI_OFFSET_Y = 440, // Automatic exposure/gain ROI offset Y + CV_CAP_PROP_XI_AEAG_ROI_WIDTH = 441, // Automatic exposure/gain ROI Width + CV_CAP_PROP_XI_AEAG_ROI_HEIGHT = 442, // Automatic exposure/gain ROI Height + CV_CAP_PROP_XI_BPC = 445, // Correction of bad pixels + CV_CAP_PROP_XI_WB_KR = 448, // White balance red coefficient + CV_CAP_PROP_XI_WB_KG = 449, // White balance green coefficient + CV_CAP_PROP_XI_WB_KB = 450, // White balance blue coefficient + CV_CAP_PROP_XI_WIDTH = 451, // Width of the Image provided by the device (in pixels). + CV_CAP_PROP_XI_HEIGHT = 452, // Height of the Image provided by the device (in pixels). + CV_CAP_PROP_XI_REGION_SELECTOR = 589, // Selects Region in Multiple ROI which parameters are set by width, height, ... ,region mode + CV_CAP_PROP_XI_REGION_MODE = 595, // Activates/deactivates Region selected by Region Selector + CV_CAP_PROP_XI_LIMIT_BANDWIDTH = 459, // Set/get bandwidth(datarate)(in Megabits) + CV_CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH = 460, // Sensor output data bit depth. + CV_CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH = 461, // Device output data bit depth. + CV_CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH = 462, // bitdepth of data returned by function xiGetImage + CV_CAP_PROP_XI_OUTPUT_DATA_PACKING = 463, // Device output data packing (or grouping) enabled. Packing could be enabled if output_data_bit_depth > 8 and packing capability is available. + CV_CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE = 464, // Data packing type. Some cameras supports only specific packing type. + CV_CAP_PROP_XI_IS_COOLED = 465, // Returns 1 for cameras that support cooling. + CV_CAP_PROP_XI_COOLING = 466, // Start camera cooling. + CV_CAP_PROP_XI_TARGET_TEMP = 467, // Set sensor target temperature for cooling. + CV_CAP_PROP_XI_CHIP_TEMP = 468, // Camera sensor temperature + CV_CAP_PROP_XI_HOUS_TEMP = 469, // Camera housing temperature + CV_CAP_PROP_XI_HOUS_BACK_SIDE_TEMP = 590, // Camera housing back side temperature + CV_CAP_PROP_XI_SENSOR_BOARD_TEMP = 596, // Camera sensor board temperature + CV_CAP_PROP_XI_CMS = 470, // Mode of color management system. + CV_CAP_PROP_XI_APPLY_CMS = 471, // Enable applying of CMS profiles to xiGetImage (see XI_PRM_INPUT_CMS_PROFILE, XI_PRM_OUTPUT_CMS_PROFILE). + CV_CAP_PROP_XI_IMAGE_IS_COLOR = 474, // Returns 1 for color cameras. + CV_CAP_PROP_XI_COLOR_FILTER_ARRAY = 475, // Returns color filter array type of RAW data. + CV_CAP_PROP_XI_GAMMAY = 476, // Luminosity gamma + CV_CAP_PROP_XI_GAMMAC = 477, // Chromaticity gamma + CV_CAP_PROP_XI_SHARPNESS = 478, // Sharpness Strength + CV_CAP_PROP_XI_CC_MATRIX_00 = 479, // Color Correction Matrix element [0][0] + CV_CAP_PROP_XI_CC_MATRIX_01 = 480, // Color Correction Matrix element [0][1] + CV_CAP_PROP_XI_CC_MATRIX_02 = 481, // Color Correction Matrix element [0][2] + CV_CAP_PROP_XI_CC_MATRIX_03 = 482, // Color Correction Matrix element [0][3] + CV_CAP_PROP_XI_CC_MATRIX_10 = 483, // Color Correction Matrix element [1][0] + CV_CAP_PROP_XI_CC_MATRIX_11 = 484, // Color Correction Matrix element [1][1] + CV_CAP_PROP_XI_CC_MATRIX_12 = 485, // Color Correction Matrix element [1][2] + CV_CAP_PROP_XI_CC_MATRIX_13 = 486, // Color Correction Matrix element [1][3] + CV_CAP_PROP_XI_CC_MATRIX_20 = 487, // Color Correction Matrix element [2][0] + CV_CAP_PROP_XI_CC_MATRIX_21 = 488, // Color Correction Matrix element [2][1] + CV_CAP_PROP_XI_CC_MATRIX_22 = 489, // Color Correction Matrix element [2][2] + CV_CAP_PROP_XI_CC_MATRIX_23 = 490, // Color Correction Matrix element [2][3] + CV_CAP_PROP_XI_CC_MATRIX_30 = 491, // Color Correction Matrix element [3][0] + CV_CAP_PROP_XI_CC_MATRIX_31 = 492, // Color Correction Matrix element [3][1] + CV_CAP_PROP_XI_CC_MATRIX_32 = 493, // Color Correction Matrix element [3][2] + CV_CAP_PROP_XI_CC_MATRIX_33 = 494, // Color Correction Matrix element [3][3] + CV_CAP_PROP_XI_DEFAULT_CC_MATRIX = 495, // Set default Color Correction Matrix + CV_CAP_PROP_XI_TRG_SELECTOR = 498, // Selects the type of trigger. + CV_CAP_PROP_XI_ACQ_FRAME_BURST_COUNT = 499, // Sets number of frames acquired by burst. This burst is used only if trigger is set to FrameBurstStart + CV_CAP_PROP_XI_DEBOUNCE_EN = 507, // Enable/Disable debounce to selected GPI + CV_CAP_PROP_XI_DEBOUNCE_T0 = 508, // Debounce time (x * 10us) + CV_CAP_PROP_XI_DEBOUNCE_T1 = 509, // Debounce time (x * 10us) + CV_CAP_PROP_XI_DEBOUNCE_POL = 510, // Debounce polarity (pol = 1 t0 - falling edge, t1 - rising edge) + CV_CAP_PROP_XI_LENS_MODE = 511, // Status of lens control interface. This shall be set to XI_ON before any Lens operations. + CV_CAP_PROP_XI_LENS_APERTURE_VALUE = 512, // Current lens aperture value in stops. Examples: 2.8, 4, 5.6, 8, 11 + CV_CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE = 513, // Lens current focus movement value to be used by XI_PRM_LENS_FOCUS_MOVE in motor steps. + CV_CAP_PROP_XI_LENS_FOCUS_MOVE = 514, // Moves lens focus motor by steps set in XI_PRM_LENS_FOCUS_MOVEMENT_VALUE. + CV_CAP_PROP_XI_LENS_FOCUS_DISTANCE = 515, // Lens focus distance in cm. + CV_CAP_PROP_XI_LENS_FOCAL_LENGTH = 516, // Lens focal distance in mm. + CV_CAP_PROP_XI_LENS_FEATURE_SELECTOR = 517, // Selects the current feature which is accessible by XI_PRM_LENS_FEATURE. + CV_CAP_PROP_XI_LENS_FEATURE = 518, // Allows access to lens feature value currently selected by XI_PRM_LENS_FEATURE_SELECTOR. + CV_CAP_PROP_XI_DEVICE_MODEL_ID = 521, // Return device model id + CV_CAP_PROP_XI_DEVICE_SN = 522, // Return device serial number + CV_CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA = 529, // The alpha channel of RGB32 output image format. + CV_CAP_PROP_XI_IMAGE_PAYLOAD_SIZE = 530, // Buffer size in bytes sufficient for output image returned by xiGetImage + CV_CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT = 531, // Current format of pixels on transport layer. + CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ = 532, // Sensor clock frequency in Hz. + CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX = 533, // Sensor clock frequency index. Sensor with selected frequencies have possibility to set the frequency only by this index. + CV_CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT = 534, // Number of output channels from sensor used for data transfer. + CV_CAP_PROP_XI_FRAMERATE = 535, // Define framerate in Hz + CV_CAP_PROP_XI_COUNTER_SELECTOR = 536, // Select counter + CV_CAP_PROP_XI_COUNTER_VALUE = 537, // Counter status + CV_CAP_PROP_XI_ACQ_TIMING_MODE = 538, // Type of sensor frames timing. + CV_CAP_PROP_XI_AVAILABLE_BANDWIDTH = 539, // Calculate and return available interface bandwidth(int Megabits) + CV_CAP_PROP_XI_BUFFER_POLICY = 540, // Data move policy + CV_CAP_PROP_XI_LUT_EN = 541, // Activates LUT. + CV_CAP_PROP_XI_LUT_INDEX = 542, // Control the index (offset) of the coefficient to access in the LUT. + CV_CAP_PROP_XI_LUT_VALUE = 543, // Value at entry LUTIndex of the LUT + CV_CAP_PROP_XI_TRG_DELAY = 544, // Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + CV_CAP_PROP_XI_TS_RST_MODE = 545, // Defines how time stamp reset engine will be armed + CV_CAP_PROP_XI_TS_RST_SOURCE = 546, // Defines which source will be used for timestamp reset. Writing this parameter will trigger settings of engine (arming) + CV_CAP_PROP_XI_IS_DEVICE_EXIST = 547, // Returns 1 if camera connected and works properly. + CV_CAP_PROP_XI_ACQ_BUFFER_SIZE = 548, // Acquisition buffer size in buffer_size_unit. Default bytes. + CV_CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT = 549, // Acquisition buffer size unit in bytes. Default 1. E.g. Value 1024 means that buffer_size is in KiBytes + CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE = 550, // Acquisition transport buffer size in bytes + CV_CAP_PROP_XI_BUFFERS_QUEUE_SIZE = 551, // Queue of field/frame buffers + CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT = 552, // Number of buffers to commit to low level + CV_CAP_PROP_XI_RECENT_FRAME = 553, // GetImage returns most recent frame + CV_CAP_PROP_XI_DEVICE_RESET = 554, // Resets the camera to default state. + CV_CAP_PROP_XI_COLUMN_FPN_CORRECTION = 555, // Correction of column FPN + CV_CAP_PROP_XI_ROW_FPN_CORRECTION = 591, // Correction of row FPN + CV_CAP_PROP_XI_SENSOR_MODE = 558, // Current sensor mode. Allows to select sensor mode by one integer. Setting of this parameter affects: image dimensions and downsampling. + CV_CAP_PROP_XI_HDR = 559, // Enable High Dynamic Range feature. + CV_CAP_PROP_XI_HDR_KNEEPOINT_COUNT = 560, // The number of kneepoints in the PWLR. + CV_CAP_PROP_XI_HDR_T1 = 561, // position of first kneepoint(in % of XI_PRM_EXPOSURE) + CV_CAP_PROP_XI_HDR_T2 = 562, // position of second kneepoint (in % of XI_PRM_EXPOSURE) + CV_CAP_PROP_XI_KNEEPOINT1 = 563, // value of first kneepoint (% of sensor saturation) + CV_CAP_PROP_XI_KNEEPOINT2 = 564, // value of second kneepoint (% of sensor saturation) + CV_CAP_PROP_XI_IMAGE_BLACK_LEVEL = 565, // Last image black level counts. Can be used for Offline processing to recall it. + CV_CAP_PROP_XI_HW_REVISION = 571, // Returns hardware revision number. + CV_CAP_PROP_XI_DEBUG_LEVEL = 572, // Set debug level + CV_CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION = 573, // Automatic bandwidth calculation, + CV_CAP_PROP_XI_FFS_FILE_ID = 594, // File number. + CV_CAP_PROP_XI_FFS_FILE_SIZE = 580, // Size of file. + CV_CAP_PROP_XI_FREE_FFS_SIZE = 581, // Size of free camera FFS. + CV_CAP_PROP_XI_USED_FFS_SIZE = 582, // Size of used camera FFS. + CV_CAP_PROP_XI_FFS_ACCESS_KEY = 583, // Setting of key enables file operations on some cameras. + CV_CAP_PROP_XI_SENSOR_FEATURE_SELECTOR = 585, // Selects the current feature which is accessible by XI_PRM_SENSOR_FEATURE_VALUE. + CV_CAP_PROP_XI_SENSOR_FEATURE_VALUE = 586, // Allows access to sensor feature value currently selected by XI_PRM_SENSOR_FEATURE_SELECTOR. + + + // Properties for Android cameras + CV_CAP_PROP_ANDROID_FLASH_MODE = 8001, + CV_CAP_PROP_ANDROID_FOCUS_MODE = 8002, + CV_CAP_PROP_ANDROID_WHITE_BALANCE = 8003, + CV_CAP_PROP_ANDROID_ANTIBANDING = 8004, + CV_CAP_PROP_ANDROID_FOCAL_LENGTH = 8005, + CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006, + CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007, + CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008, + CV_CAP_PROP_ANDROID_EXPOSE_LOCK = 8009, + CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK = 8010, + + // Properties of cameras available through AVFOUNDATION interface + CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001, + CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, + CV_CAP_PROP_IOS_DEVICE_FLASH = 9003, + CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, + CV_CAP_PROP_IOS_DEVICE_TORCH = 9005, + + // Properties of cameras available through Smartek Giganetix Ethernet Vision interface + /* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */ + CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, + CV_CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, + CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, + CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, + CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, + CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006, + + CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, + CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002, + CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, + CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, + CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, + CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, + CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007, + + // Intel PerC streams + CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, + CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, + CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR +}; + +enum +{ + // Data given from depth generator. + CV_CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1) + CV_CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3) + CV_CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1) + CV_CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1) + CV_CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1 + + // Data given from RGB image generator. + CV_CAP_OPENNI_BGR_IMAGE = 5, + CV_CAP_OPENNI_GRAY_IMAGE = 6, + + // Data given from IR image generator. + CV_CAP_OPENNI_IR_IMAGE = 7 +}; + +// Supported output modes of OpenNI image generator +enum +{ + CV_CAP_OPENNI_VGA_30HZ = 0, + CV_CAP_OPENNI_SXGA_15HZ = 1, + CV_CAP_OPENNI_SXGA_30HZ = 2, + CV_CAP_OPENNI_QVGA_30HZ = 3, + CV_CAP_OPENNI_QVGA_60HZ = 4 +}; + +enum +{ + CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. + CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. + CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. + CV_CAP_INTELPERC_IMAGE = 3 +}; + +// gPhoto2 properties, if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID +// Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE. +// @see CvCaptureCAM_GPHOTO2 for more info +enum +{ + CV_CAP_PROP_GPHOTO2_PREVIEW = 17001, // Capture only preview from liveview mode. + CV_CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, // Readonly, returns (const char *). + CV_CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, // Trigger, only by set. Reload camera settings. + CV_CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, // Reload all settings on set. + CV_CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, // Collect messages with details. + CV_CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, // Readonly, returns (const char *). + CV_CAP_PROP_SPEED = 17007, // Exposure speed. Can be readonly, depends on camera program. + CV_CAP_PROP_APERTURE = 17008, // Aperture. Can be readonly, depends on camera program. + CV_CAP_PROP_EXPOSUREPROGRAM = 17009, // Camera exposure program. + CV_CAP_PROP_VIEWFINDER = 17010 // Enter liveview mode. +}; + +//! Macro to construct the fourcc code of the codec. Same as CV_FOURCC() +#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24)) + +/** @brief Constructs the fourcc code of the codec function + +Simply call it with 4 chars fourcc code like `CV_FOURCC('I', 'Y', 'U', 'V')` + +List of codes can be obtained at [Video Codecs by FOURCC](http://www.fourcc.org/codecs.php) page. +FFMPEG backend with MP4 container natively uses other values as fourcc code: +see [ObjectType](http://mp4ra.org/#/codecs). +*/ +CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4) +{ + return CV_FOURCC_MACRO(c1, c2, c3, c4); +} + +//! (Windows only) Open Codec Selection Dialog +#define CV_FOURCC_PROMPT -1 +//! (Linux only) Use default codec for specified filename +#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V') + +#endif // OPENCV_VIDEOIO_LEGACY_CONSTANTS_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/videoio/registry.hpp b/Cigarette/OpenCV455Simple/include/opencv2/videoio/registry.hpp new file mode 100644 index 0000000..cf72247 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/videoio/registry.hpp @@ -0,0 +1,72 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEOIO_REGISTRY_HPP +#define OPENCV_VIDEOIO_REGISTRY_HPP + +#include + +namespace cv { namespace videoio_registry { +/** @addtogroup videoio_registry +This section contains API description how to query/configure available Video I/O backends. + +Runtime configuration options: +- enable debug mode: `OPENCV_VIDEOIO_DEBUG=1` +- change backend priority: `OPENCV_VIDEOIO_PRIORITY_=9999` +- disable backend: `OPENCV_VIDEOIO_PRIORITY_=0` +- specify list of backends with high priority (>100000): `OPENCV_VIDEOIO_PRIORITY_LIST=FFMPEG,GSTREAMER` + +@{ + */ + + +/** @brief Returns backend API name or "UnknownVideoAPI(xxx)" +@param api backend ID (#VideoCaptureAPIs) +*/ +CV_EXPORTS_W cv::String getBackendName(VideoCaptureAPIs api); + +/** @brief Returns list of all available backends */ +CV_EXPORTS_W std::vector getBackends(); + +/** @brief Returns list of available backends which works via `cv::VideoCapture(int index)` */ +CV_EXPORTS_W std::vector getCameraBackends(); + +/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */ +CV_EXPORTS_W std::vector getStreamBackends(); + +/** @brief Returns list of available backends which works via `cv::VideoWriter()` */ +CV_EXPORTS_W std::vector getWriterBackends(); + +/** @brief Returns true if backend is available */ +CV_EXPORTS_W bool hasBackend(VideoCaptureAPIs api); + +/** @brief Returns true if backend is built in (false if backend is used as plugin) */ +CV_EXPORTS_W bool isBackendBuiltIn(VideoCaptureAPIs api); + +/** @brief Returns description and ABI/API version of videoio plugin's camera interface */ +CV_EXPORTS_W std::string getCameraBackendPluginVersion( + VideoCaptureAPIs api, + CV_OUT int& version_ABI, + CV_OUT int& version_API +); + +/** @brief Returns description and ABI/API version of videoio plugin's stream capture interface */ +CV_EXPORTS_W std::string getStreamBackendPluginVersion( + VideoCaptureAPIs api, + CV_OUT int& version_ABI, + CV_OUT int& version_API +); + +/** @brief Returns description and ABI/API version of videoio plugin's writer interface */ +CV_EXPORTS_W std::string getWriterBackendPluginVersion( + VideoCaptureAPIs api, + CV_OUT int& version_ABI, + CV_OUT int& version_API +); + + +//! @} +}} // namespace + +#endif // OPENCV_VIDEOIO_REGISTRY_HPP diff --git a/Cigarette/OpenCV455Simple/include/opencv2/videoio/videoio.hpp b/Cigarette/OpenCV455Simple/include/opencv2/videoio/videoio.hpp new file mode 100644 index 0000000..ec84cf7 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/videoio/videoio.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/videoio.hpp" diff --git a/Cigarette/OpenCV455Simple/include/opencv2/videoio/videoio_c.h b/Cigarette/OpenCV455Simple/include/opencv2/videoio/videoio_c.h new file mode 100644 index 0000000..cf1a6d0 --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/videoio/videoio_c.h @@ -0,0 +1,153 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_VIDEOIO_H +#define OPENCV_VIDEOIO_H + +#include "opencv2/core/core_c.h" + +#include "opencv2/videoio/legacy/constants_c.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + @addtogroup videoio_c + @{ +*/ + +/****************************************************************************************\ +* Working with Video Files and Cameras * +\****************************************************************************************/ + +/** @brief "black box" capture structure + +In C++ use cv::VideoCapture +*/ +typedef struct CvCapture CvCapture; + +/** @brief start capturing frames from video file +*/ +CVAPI(CvCapture*) cvCreateFileCapture( const char* filename ); + +/** @brief start capturing frames from video file. allows specifying a preferred API to use +*/ +CVAPI(CvCapture*) cvCreateFileCaptureWithPreference( const char* filename , int apiPreference); + +/** @brief start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) +*/ +CVAPI(CvCapture*) cvCreateCameraCapture( int index ); + +/** @brief grab a frame, return 1 on success, 0 on fail. + + this function is thought to be fast +*/ +CVAPI(int) cvGrabFrame( CvCapture* capture ); + +/** @brief get the frame grabbed with cvGrabFrame(..) + + This function may apply some frame processing like + frame decompression, flipping etc. + @warning !!!DO NOT RELEASE or MODIFY the retrieved frame!!! +*/ +CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture, int streamIdx CV_DEFAULT(0) ); + +/** @brief Just a combination of cvGrabFrame and cvRetrieveFrame + + @warning !!!DO NOT RELEASE or MODIFY the retrieved frame!!! +*/ +CVAPI(IplImage*) cvQueryFrame( CvCapture* capture ); + +/** @brief stop capturing/reading and free resources +*/ +CVAPI(void) cvReleaseCapture( CvCapture** capture ); + +/** @brief retrieve capture properties +*/ +CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id ); +/** @brief set capture properties +*/ +CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value ); + +/** @brief Return the type of the capturer (eg, ::CV_CAP_VFW, ::CV_CAP_UNICAP) + +It is unknown if created with ::CV_CAP_ANY +*/ +CVAPI(int) cvGetCaptureDomain( CvCapture* capture); + +/** @brief "black box" video file writer structure + +In C++ use cv::VideoWriter +*/ +typedef struct CvVideoWriter CvVideoWriter; + +/** @brief initialize video file writer +*/ +CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc, + double fps, CvSize frame_size, + int is_color CV_DEFAULT(1)); + +/** @brief write frame to video file +*/ +CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image ); + +/** @brief close video file writer +*/ +CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer ); + +// *************************************************************************************** +//! @name Obsolete functions/synonyms +//! @{ +#define cvCaptureFromCAM cvCreateCameraCapture //!< @deprecated use cvCreateCameraCapture() instead +#define cvCaptureFromFile cvCreateFileCapture //!< @deprecated use cvCreateFileCapture() instead +#define cvCaptureFromAVI cvCaptureFromFile //!< @deprecated use cvCreateFileCapture() instead +#define cvCreateAVIWriter cvCreateVideoWriter //!< @deprecated use cvCreateVideoWriter() instead +#define cvWriteToAVI cvWriteFrame //!< @deprecated use cvWriteFrame() instead +//! @} Obsolete... + +//! @} videoio_c + +#ifdef __cplusplus +} +#endif + +#endif //OPENCV_VIDEOIO_H diff --git a/Cigarette/OpenCV455Simple/include/opencv2/world.hpp b/Cigarette/OpenCV455Simple/include/opencv2/world.hpp new file mode 100644 index 0000000..4902c2f --- /dev/null +++ b/Cigarette/OpenCV455Simple/include/opencv2/world.hpp @@ -0,0 +1,58 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_WORLD_HPP +#define OPENCV_WORLD_HPP + +#include "opencv2/core.hpp" + +#ifdef __cplusplus +namespace cv +{ + +CV_EXPORTS_W bool initAll(); + +} + +#endif + +#endif diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVConfig-version.cmake b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVConfig-version.cmake new file mode 100644 index 0000000..435b7ec --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVConfig-version.cmake @@ -0,0 +1,15 @@ +set(OpenCV_VERSION 4.5.5) +set(PACKAGE_VERSION ${OpenCV_VERSION}) + +set(PACKAGE_VERSION_EXACT False) +set(PACKAGE_VERSION_COMPATIBLE False) + +if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT True) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() + +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 4 + AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVConfig.cmake b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVConfig.cmake new file mode 100644 index 0000000..b6bb809 --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVConfig.cmake @@ -0,0 +1,355 @@ +# =================================================================================== +# The OpenCV CMake configuration file +# +# ** File generated automatically, do not modify ** +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(OpenCV REQUIRED) +# include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11 +# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS}) +# +# Or you can search for specific OpenCV modules: +# +# find_package(OpenCV REQUIRED core videoio) +# +# You can also mark OpenCV components as optional: + +# find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz) +# +# If the module is found then OPENCV__FOUND is set to TRUE. +# +# This file will define the following variables: +# - OpenCV_LIBS : The list of all imported targets for OpenCV modules. +# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. +# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability. +# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API. +# - OpenCV_VERSION : The version of this OpenCV build: "4.5.5" +# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "4" +# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_STATUS : Development status of this build: "" +# +# Advanced variables: +# - OpenCV_SHARED : Use OpenCV as shared library +# - OpenCV_INSTALL_PATH : OpenCV location +# - OpenCV_LIB_COMPONENTS : Present OpenCV modules list +# - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag +# +# Deprecated variables: +# - OpenCV_VERSION_TWEAK : Always "0" +# +# =================================================================================== + +# ====================================================== +# Version variables: +# ====================================================== +SET(OpenCV_VERSION 4.5.5) +SET(OpenCV_VERSION_MAJOR 4) +SET(OpenCV_VERSION_MINOR 5) +SET(OpenCV_VERSION_PATCH 5) +SET(OpenCV_VERSION_TWEAK 0) +SET(OpenCV_VERSION_STATUS "") + +include(FindPackageHandleStandardArgs) + +if(NOT CMAKE_VERSION VERSION_LESS 2.8.8 + AND OpenCV_FIND_COMPONENTS # prevent excessive output +) + # HANDLE_COMPONENTS was introduced in CMake 2.8.8 + list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS) + # The missing components will be handled by the FindPackageHandleStandardArgs + # module. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE) +else() + # The missing components will be handled by this config. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE) +endif() + +# Extract directory name from full path of the file currently being processed. +# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it +# for older versions of CMake to support these as well. +if(CMAKE_VERSION VERSION_LESS "2.8.3") + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +endif() + +# Extract the directory where *this* file has been installed (determined at cmake run-time) +# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings +get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}" REALPATH) +get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../../" REALPATH) + +# Search packages for host system instead of packages for target system. +# in case of cross compilation this macro should be defined by toolchain file +if(NOT COMMAND find_host_package) + macro(find_host_package) + find_package(${ARGN}) + endmacro() +endif() +if(NOT COMMAND find_host_program) + macro(find_host_program) + find_program(${ARGN}) + endmacro() +endif() + + + + + + + + +# Some additional settings are required if OpenCV is built as static libs +set(OpenCV_SHARED ON) + +# Enables mangled install paths, that help with side by side installs +set(OpenCV_USE_MANGLED_PATHS FALSE) + +set(OpenCV_LIB_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_world) +set(__OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include") + +set(OpenCV_INCLUDE_DIRS "") +foreach(d ${__OpenCV_INCLUDE_DIRS}) + get_filename_component(__d "${d}" REALPATH) + if(NOT EXISTS "${__d}") + if(NOT OpenCV_FIND_QUIETLY) + message(WARNING "OpenCV: Include directory doesn't exist: '${d}'. OpenCV installation may be broken. Skip...") + endif() + else() + list(APPEND OpenCV_INCLUDE_DIRS "${__d}") + endif() +endforeach() +unset(__d) + + +if(NOT TARGET opencv_core) + include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) +endif() + +if(NOT CMAKE_VERSION VERSION_LESS "2.8.11") + # Target property INTERFACE_INCLUDE_DIRECTORIES available since 2.8.11: + # * http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_tgt:INTERFACE_INCLUDE_DIRECTORIES + foreach(__component ${OpenCV_LIB_COMPONENTS}) + if(TARGET ${__component}) + set_target_properties( + ${__component} + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}" + ) + endif() + endforeach() +endif() + + +if(NOT DEFINED OPENCV_MAP_IMPORTED_CONFIG) + if(CMAKE_GENERATOR MATCHES "Visual Studio" OR MSVC) + # OpenCV supports Debug and Release builds only. + # But MSVS has 'RelWithDebInfo' 'MinSizeRel' configurations for applications. + # By default CMake maps these configuration on the first available (Debug) which is wrong. + # Non-Debug build of Application can't be used with OpenCV Debug build (ABI mismatch problem) + # Add mapping of RelWithDebInfo and MinSizeRel to Release here + set(OPENCV_MAP_IMPORTED_CONFIG "RELWITHDEBINFO=!Release;MINSIZEREL=!Release") + endif() +endif() +set(__remap_warnings "") +macro(ocv_map_imported_config target) + if(DEFINED OPENCV_MAP_IMPORTED_CONFIG) # list, "RELWITHDEBINFO=Release;MINSIZEREL=Release" + get_target_property(__available_configurations ${target} IMPORTED_CONFIGURATIONS) + foreach(remap ${OPENCV_MAP_IMPORTED_CONFIG}) + if(remap MATCHES "^(.+)=(!?)([^!]+)$") + set(__remap_config "${CMAKE_MATCH_1}") + set(__final_config "${CMAKE_MATCH_3}") + set(__force_flag "${CMAKE_MATCH_2}") + string(TOUPPER "${__final_config}" __final_config_upper) + string(TOUPPER "${__remap_config}" __remap_config_upper) + if(";${__available_configurations};" MATCHES ";${__remap_config_upper};" AND NOT "${__force_flag}" STREQUAL "!") + # configuration already exists, skip remap + set(__remap_warnings "${__remap_warnings}... Configuration already exists ${__remap_config} (skip mapping ${__remap_config} => ${__final_config}) (available configurations: ${__available_configurations})\n") + continue() + endif() + if(__available_configurations AND NOT ";${__available_configurations};" MATCHES ";${__final_config_upper};") + # skip, configuration is not available + if(NOT "${__force_flag}" STREQUAL "!") + set(__remap_warnings "${__remap_warnings}... Configuration is not available '${__final_config}' for ${target}, build may fail (available configurations: ${__available_configurations})\n") + endif() + endif() + set_target_properties(${target} PROPERTIES + MAP_IMPORTED_CONFIG_${__remap_config} "${__final_config}" + ) + else() + message(WARNING "Invalid entry of OPENCV_MAP_IMPORTED_CONFIG: '${remap}' (${OPENCV_MAP_IMPORTED_CONFIG})") + endif() + endforeach() + endif() +endmacro() + + +# ============================================================== +# Form list of modules (components) to find +# ============================================================== +if(NOT OpenCV_FIND_COMPONENTS) + set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS}) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java) + if(GTest_FOUND OR GTEST_FOUND) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts) + endif() +endif() + +set(OpenCV_WORLD_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio) + +# expand short module names and see if requested components exist +foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) + # Store the name of the original component so we can set the + # OpenCV__FOUND variable which can be checked by the user. + set (__original_cvcomponent ${__cvcomponent}) + if(NOT __cvcomponent MATCHES "^opencv_") + set(__cvcomponent opencv_${__cvcomponent}) + endif() + list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx) + if(__cvcomponentIdx LESS 0) + if(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + # Either the component is required or the user did not set any components at + # all. In the latter case, the OpenCV_FIND_REQUIRED_ variable + # will not be defined since it is not set by this config. So let's assume + # the implicitly set components are always required. + if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR + OpenCV_FIND_REQUIRED_${__original_cvcomponent}) + message(FATAL_ERROR "${__cvcomponent} is required but was not found") + elseif(NOT OpenCV_FIND_QUIETLY) + # The component was marked as optional using OPTIONAL_COMPONENTS + message(WARNING "Optional component ${__cvcomponent} was not found") + endif() + endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + #indicate that module is NOT found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND") + set(OpenCV_${__original_cvcomponent}_FOUND FALSE) + else() + # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet. + # Also not clearing OpenCV_LIBS anywhere, so that multiple calls + # to find_package(OpenCV) with different component lists add up. + set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}") + #indicate that module is found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND 1) + set(OpenCV_${__original_cvcomponent}_FOUND TRUE) + endif() + if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent}) + get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG) + get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE) + get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG) + get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE) + get_target_property(__include_dir opencv_world INTERFACE_INCLUDE_DIRECTORIES) + add_library(${__cvcomponent} SHARED IMPORTED) + set_target_properties(${__cvcomponent} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${__include_dir}") + if(__location_dbg) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_DEBUG "${__implib_dbg}" + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "" + IMPORTED_LOCATION_DEBUG "${__location_dbg}" + ) + endif() + if(__location_release) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_RELEASE "${__implib_release}" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" + IMPORTED_LOCATION_RELEASE "${__location_release}" + ) + endif() + endif() + if(TARGET ${__cvcomponent}) + ocv_map_imported_config(${__cvcomponent}) + endif() +endforeach() + +if(__remap_warnings AND NOT OpenCV_FIND_QUIETLY) + message("OpenCV: configurations remap warnings:\n${__remap_warnings}OpenCV: Check variable OPENCV_MAP_IMPORTED_CONFIG=${OPENCV_MAP_IMPORTED_CONFIG}") +endif() + +# ============================================================== +# Compatibility stuff +# ============================================================== +set(OpenCV_LIBRARIES ${OpenCV_LIBS}) + +# Require C++11 features for OpenCV modules +if(CMAKE_VERSION VERSION_LESS "3.1") + if(NOT OpenCV_FIND_QUIETLY AND NOT OPENCV_HIDE_WARNING_COMPILE_FEATURES) + message(STATUS "OpenCV: CMake version is low (${CMAKE_VERSION}, required 3.1+). Can't enable C++11 features: https://github.com/opencv/opencv/issues/13000") + endif() +else() + set(__target opencv_core) + if(TARGET opencv_world) + set(__target opencv_world) + endif() + set(__compile_features cxx_std_11) # CMake 3.8+ + if(DEFINED OPENCV_COMPILE_FEATURES) + set(__compile_features ${OPENCV_COMPILE_FEATURES}) # custom override + elseif(CMAKE_VERSION VERSION_LESS "3.8") + set(__compile_features cxx_auto_type cxx_rvalue_references cxx_lambdas) + endif() + if(__compile_features) + # Simulate exported result of target_compile_features(opencv_core PUBLIC ...) + set_target_properties(${__target} PROPERTIES + INTERFACE_COMPILE_FEATURES "${__compile_features}" + ) + endif() + unset(__target) + unset(__compile_features) +endif() + +# +# Some macros for samples +# +macro(ocv_check_dependencies) + set(OCV_DEPENDENCIES_FOUND TRUE) + foreach(d ${ARGN}) + if(NOT TARGET ${d}) + message(WARNING "OpenCV: Can't resolve dependency: ${d}") + set(OCV_DEPENDENCIES_FOUND FALSE) + break() + endif() + endforeach() +endmacro() + +# adds include directories in such way that directories from the OpenCV source tree go first +function(ocv_include_directories) + set(__add_before "") + file(TO_CMAKE_PATH "${OpenCV_INSTALL_PATH}" __baseDir) + foreach(dir ${ARGN}) + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + if("${__abs_dir}" MATCHES "^${__baseDir}") + list(APPEND __add_before "${dir}") + else() + include_directories(AFTER SYSTEM "${dir}") + endif() + endforeach() + include_directories(BEFORE ${__add_before}) +endfunction() + +macro(ocv_include_modules) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_include_modules_recurse) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_target_link_libraries) + target_link_libraries(${ARGN}) +endmacro() + +# remove all matching elements from the list +macro(ocv_list_filterout lst regex) + foreach(item ${${lst}}) + if(item MATCHES "${regex}") + list(REMOVE_ITEM ${lst} "${item}") + endif() + endforeach() +endmacro() + +# We do not actually need REQUIRED_VARS to be checked for. Just use the +# installation directory for the status. +find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH + VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS}) diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules-debug.cmake b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules-debug.cmake new file mode 100644 index 0000000..9635f97 --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules-debug.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Debug". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Debug" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455d.lib" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455d.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455d.lib" "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455d.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules-release.cmake b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules-release.cmake new file mode 100644 index 0000000..fa218f4 --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Release" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455.lib" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455.lib" "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules.cmake b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules.cmake new file mode 100644 index 0000000..9ab8ae3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc14/lib/OpenCVModules.cmake @@ -0,0 +1,90 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget opencv_world) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target opencv_world +add_library(opencv_world SHARED IMPORTED) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/OpenCVModules-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/opencv_world455.lib b/Cigarette/OpenCV455Simple/win64/vc14/lib/opencv_world455.lib new file mode 100644 index 0000000..c35f130 Binary files /dev/null and b/Cigarette/OpenCV455Simple/win64/vc14/lib/opencv_world455.lib differ diff --git a/Cigarette/OpenCV455Simple/win64/vc14/lib/opencv_world455d.lib b/Cigarette/OpenCV455Simple/win64/vc14/lib/opencv_world455d.lib new file mode 100644 index 0000000..f86c437 Binary files /dev/null and b/Cigarette/OpenCV455Simple/win64/vc14/lib/opencv_world455d.lib differ diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVConfig-version.cmake b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVConfig-version.cmake new file mode 100644 index 0000000..435b7ec --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVConfig-version.cmake @@ -0,0 +1,15 @@ +set(OpenCV_VERSION 4.5.5) +set(PACKAGE_VERSION ${OpenCV_VERSION}) + +set(PACKAGE_VERSION_EXACT False) +set(PACKAGE_VERSION_COMPATIBLE False) + +if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT True) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() + +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 4 + AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVConfig.cmake b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVConfig.cmake new file mode 100644 index 0000000..b6bb809 --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVConfig.cmake @@ -0,0 +1,355 @@ +# =================================================================================== +# The OpenCV CMake configuration file +# +# ** File generated automatically, do not modify ** +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(OpenCV REQUIRED) +# include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11 +# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS}) +# +# Or you can search for specific OpenCV modules: +# +# find_package(OpenCV REQUIRED core videoio) +# +# You can also mark OpenCV components as optional: + +# find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz) +# +# If the module is found then OPENCV__FOUND is set to TRUE. +# +# This file will define the following variables: +# - OpenCV_LIBS : The list of all imported targets for OpenCV modules. +# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. +# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability. +# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API. +# - OpenCV_VERSION : The version of this OpenCV build: "4.5.5" +# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "4" +# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_STATUS : Development status of this build: "" +# +# Advanced variables: +# - OpenCV_SHARED : Use OpenCV as shared library +# - OpenCV_INSTALL_PATH : OpenCV location +# - OpenCV_LIB_COMPONENTS : Present OpenCV modules list +# - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag +# +# Deprecated variables: +# - OpenCV_VERSION_TWEAK : Always "0" +# +# =================================================================================== + +# ====================================================== +# Version variables: +# ====================================================== +SET(OpenCV_VERSION 4.5.5) +SET(OpenCV_VERSION_MAJOR 4) +SET(OpenCV_VERSION_MINOR 5) +SET(OpenCV_VERSION_PATCH 5) +SET(OpenCV_VERSION_TWEAK 0) +SET(OpenCV_VERSION_STATUS "") + +include(FindPackageHandleStandardArgs) + +if(NOT CMAKE_VERSION VERSION_LESS 2.8.8 + AND OpenCV_FIND_COMPONENTS # prevent excessive output +) + # HANDLE_COMPONENTS was introduced in CMake 2.8.8 + list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS) + # The missing components will be handled by the FindPackageHandleStandardArgs + # module. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE) +else() + # The missing components will be handled by this config. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE) +endif() + +# Extract directory name from full path of the file currently being processed. +# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it +# for older versions of CMake to support these as well. +if(CMAKE_VERSION VERSION_LESS "2.8.3") + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +endif() + +# Extract the directory where *this* file has been installed (determined at cmake run-time) +# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings +get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}" REALPATH) +get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../../" REALPATH) + +# Search packages for host system instead of packages for target system. +# in case of cross compilation this macro should be defined by toolchain file +if(NOT COMMAND find_host_package) + macro(find_host_package) + find_package(${ARGN}) + endmacro() +endif() +if(NOT COMMAND find_host_program) + macro(find_host_program) + find_program(${ARGN}) + endmacro() +endif() + + + + + + + + +# Some additional settings are required if OpenCV is built as static libs +set(OpenCV_SHARED ON) + +# Enables mangled install paths, that help with side by side installs +set(OpenCV_USE_MANGLED_PATHS FALSE) + +set(OpenCV_LIB_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_world) +set(__OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include") + +set(OpenCV_INCLUDE_DIRS "") +foreach(d ${__OpenCV_INCLUDE_DIRS}) + get_filename_component(__d "${d}" REALPATH) + if(NOT EXISTS "${__d}") + if(NOT OpenCV_FIND_QUIETLY) + message(WARNING "OpenCV: Include directory doesn't exist: '${d}'. OpenCV installation may be broken. Skip...") + endif() + else() + list(APPEND OpenCV_INCLUDE_DIRS "${__d}") + endif() +endforeach() +unset(__d) + + +if(NOT TARGET opencv_core) + include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) +endif() + +if(NOT CMAKE_VERSION VERSION_LESS "2.8.11") + # Target property INTERFACE_INCLUDE_DIRECTORIES available since 2.8.11: + # * http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_tgt:INTERFACE_INCLUDE_DIRECTORIES + foreach(__component ${OpenCV_LIB_COMPONENTS}) + if(TARGET ${__component}) + set_target_properties( + ${__component} + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}" + ) + endif() + endforeach() +endif() + + +if(NOT DEFINED OPENCV_MAP_IMPORTED_CONFIG) + if(CMAKE_GENERATOR MATCHES "Visual Studio" OR MSVC) + # OpenCV supports Debug and Release builds only. + # But MSVS has 'RelWithDebInfo' 'MinSizeRel' configurations for applications. + # By default CMake maps these configuration on the first available (Debug) which is wrong. + # Non-Debug build of Application can't be used with OpenCV Debug build (ABI mismatch problem) + # Add mapping of RelWithDebInfo and MinSizeRel to Release here + set(OPENCV_MAP_IMPORTED_CONFIG "RELWITHDEBINFO=!Release;MINSIZEREL=!Release") + endif() +endif() +set(__remap_warnings "") +macro(ocv_map_imported_config target) + if(DEFINED OPENCV_MAP_IMPORTED_CONFIG) # list, "RELWITHDEBINFO=Release;MINSIZEREL=Release" + get_target_property(__available_configurations ${target} IMPORTED_CONFIGURATIONS) + foreach(remap ${OPENCV_MAP_IMPORTED_CONFIG}) + if(remap MATCHES "^(.+)=(!?)([^!]+)$") + set(__remap_config "${CMAKE_MATCH_1}") + set(__final_config "${CMAKE_MATCH_3}") + set(__force_flag "${CMAKE_MATCH_2}") + string(TOUPPER "${__final_config}" __final_config_upper) + string(TOUPPER "${__remap_config}" __remap_config_upper) + if(";${__available_configurations};" MATCHES ";${__remap_config_upper};" AND NOT "${__force_flag}" STREQUAL "!") + # configuration already exists, skip remap + set(__remap_warnings "${__remap_warnings}... Configuration already exists ${__remap_config} (skip mapping ${__remap_config} => ${__final_config}) (available configurations: ${__available_configurations})\n") + continue() + endif() + if(__available_configurations AND NOT ";${__available_configurations};" MATCHES ";${__final_config_upper};") + # skip, configuration is not available + if(NOT "${__force_flag}" STREQUAL "!") + set(__remap_warnings "${__remap_warnings}... Configuration is not available '${__final_config}' for ${target}, build may fail (available configurations: ${__available_configurations})\n") + endif() + endif() + set_target_properties(${target} PROPERTIES + MAP_IMPORTED_CONFIG_${__remap_config} "${__final_config}" + ) + else() + message(WARNING "Invalid entry of OPENCV_MAP_IMPORTED_CONFIG: '${remap}' (${OPENCV_MAP_IMPORTED_CONFIG})") + endif() + endforeach() + endif() +endmacro() + + +# ============================================================== +# Form list of modules (components) to find +# ============================================================== +if(NOT OpenCV_FIND_COMPONENTS) + set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS}) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java) + if(GTest_FOUND OR GTEST_FOUND) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts) + endif() +endif() + +set(OpenCV_WORLD_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio) + +# expand short module names and see if requested components exist +foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) + # Store the name of the original component so we can set the + # OpenCV__FOUND variable which can be checked by the user. + set (__original_cvcomponent ${__cvcomponent}) + if(NOT __cvcomponent MATCHES "^opencv_") + set(__cvcomponent opencv_${__cvcomponent}) + endif() + list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx) + if(__cvcomponentIdx LESS 0) + if(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + # Either the component is required or the user did not set any components at + # all. In the latter case, the OpenCV_FIND_REQUIRED_ variable + # will not be defined since it is not set by this config. So let's assume + # the implicitly set components are always required. + if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR + OpenCV_FIND_REQUIRED_${__original_cvcomponent}) + message(FATAL_ERROR "${__cvcomponent} is required but was not found") + elseif(NOT OpenCV_FIND_QUIETLY) + # The component was marked as optional using OPTIONAL_COMPONENTS + message(WARNING "Optional component ${__cvcomponent} was not found") + endif() + endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + #indicate that module is NOT found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND") + set(OpenCV_${__original_cvcomponent}_FOUND FALSE) + else() + # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet. + # Also not clearing OpenCV_LIBS anywhere, so that multiple calls + # to find_package(OpenCV) with different component lists add up. + set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}") + #indicate that module is found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND 1) + set(OpenCV_${__original_cvcomponent}_FOUND TRUE) + endif() + if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent}) + get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG) + get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE) + get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG) + get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE) + get_target_property(__include_dir opencv_world INTERFACE_INCLUDE_DIRECTORIES) + add_library(${__cvcomponent} SHARED IMPORTED) + set_target_properties(${__cvcomponent} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${__include_dir}") + if(__location_dbg) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_DEBUG "${__implib_dbg}" + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "" + IMPORTED_LOCATION_DEBUG "${__location_dbg}" + ) + endif() + if(__location_release) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_RELEASE "${__implib_release}" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" + IMPORTED_LOCATION_RELEASE "${__location_release}" + ) + endif() + endif() + if(TARGET ${__cvcomponent}) + ocv_map_imported_config(${__cvcomponent}) + endif() +endforeach() + +if(__remap_warnings AND NOT OpenCV_FIND_QUIETLY) + message("OpenCV: configurations remap warnings:\n${__remap_warnings}OpenCV: Check variable OPENCV_MAP_IMPORTED_CONFIG=${OPENCV_MAP_IMPORTED_CONFIG}") +endif() + +# ============================================================== +# Compatibility stuff +# ============================================================== +set(OpenCV_LIBRARIES ${OpenCV_LIBS}) + +# Require C++11 features for OpenCV modules +if(CMAKE_VERSION VERSION_LESS "3.1") + if(NOT OpenCV_FIND_QUIETLY AND NOT OPENCV_HIDE_WARNING_COMPILE_FEATURES) + message(STATUS "OpenCV: CMake version is low (${CMAKE_VERSION}, required 3.1+). Can't enable C++11 features: https://github.com/opencv/opencv/issues/13000") + endif() +else() + set(__target opencv_core) + if(TARGET opencv_world) + set(__target opencv_world) + endif() + set(__compile_features cxx_std_11) # CMake 3.8+ + if(DEFINED OPENCV_COMPILE_FEATURES) + set(__compile_features ${OPENCV_COMPILE_FEATURES}) # custom override + elseif(CMAKE_VERSION VERSION_LESS "3.8") + set(__compile_features cxx_auto_type cxx_rvalue_references cxx_lambdas) + endif() + if(__compile_features) + # Simulate exported result of target_compile_features(opencv_core PUBLIC ...) + set_target_properties(${__target} PROPERTIES + INTERFACE_COMPILE_FEATURES "${__compile_features}" + ) + endif() + unset(__target) + unset(__compile_features) +endif() + +# +# Some macros for samples +# +macro(ocv_check_dependencies) + set(OCV_DEPENDENCIES_FOUND TRUE) + foreach(d ${ARGN}) + if(NOT TARGET ${d}) + message(WARNING "OpenCV: Can't resolve dependency: ${d}") + set(OCV_DEPENDENCIES_FOUND FALSE) + break() + endif() + endforeach() +endmacro() + +# adds include directories in such way that directories from the OpenCV source tree go first +function(ocv_include_directories) + set(__add_before "") + file(TO_CMAKE_PATH "${OpenCV_INSTALL_PATH}" __baseDir) + foreach(dir ${ARGN}) + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + if("${__abs_dir}" MATCHES "^${__baseDir}") + list(APPEND __add_before "${dir}") + else() + include_directories(AFTER SYSTEM "${dir}") + endif() + endforeach() + include_directories(BEFORE ${__add_before}) +endfunction() + +macro(ocv_include_modules) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_include_modules_recurse) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_target_link_libraries) + target_link_libraries(${ARGN}) +endmacro() + +# remove all matching elements from the list +macro(ocv_list_filterout lst regex) + foreach(item ${${lst}}) + if(item MATCHES "${regex}") + list(REMOVE_ITEM ${lst} "${item}") + endif() + endforeach() +endmacro() + +# We do not actually need REQUIRED_VARS to be checked for. Just use the +# installation directory for the status. +find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH + VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS}) diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules-debug.cmake b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules-debug.cmake new file mode 100644 index 0000000..eb122cc --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules-debug.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Debug". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Debug" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455d.lib" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455d.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455d.lib" "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455d.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules-release.cmake b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules-release.cmake new file mode 100644 index 0000000..38d533a --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Release" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455.lib" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455.lib" "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules.cmake b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules.cmake new file mode 100644 index 0000000..9ab8ae3 --- /dev/null +++ b/Cigarette/OpenCV455Simple/win64/vc15/lib/OpenCVModules.cmake @@ -0,0 +1,90 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget opencv_world) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target opencv_world +add_library(opencv_world SHARED IMPORTED) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/OpenCVModules-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/opencv_world455.lib b/Cigarette/OpenCV455Simple/win64/vc15/lib/opencv_world455.lib new file mode 100644 index 0000000..752add0 Binary files /dev/null and b/Cigarette/OpenCV455Simple/win64/vc15/lib/opencv_world455.lib differ diff --git a/Cigarette/OpenCV455Simple/win64/vc15/lib/opencv_world455d.lib b/Cigarette/OpenCV455Simple/win64/vc15/lib/opencv_world455d.lib new file mode 100644 index 0000000..9fdee19 Binary files /dev/null and b/Cigarette/OpenCV455Simple/win64/vc15/lib/opencv_world455d.lib differ diff --git a/Cigarette/PLC/PLCDevice.cpp b/Cigarette/PLC/PLCDevice.cpp new file mode 100644 index 0000000..6bbe89b --- /dev/null +++ b/Cigarette/PLC/PLCDevice.cpp @@ -0,0 +1,92 @@ +#include "stdio.h" +#include "PLCDevice.h" +#include "modbus.h" +#include + +modbus_t * g_modbus; //Modbus TCP + +bool PLCDevice::init_plc(PLCDevice* PLCptr) +{ + //连接PLC + g_modbus = modbus_new_rtu("COM1", 9600, 'N', 8, 1); + modbus_set_debug(g_modbus, 0); + + modbus_set_response_timeout(g_modbus, 1, 0); + if (g_modbus && modbus_connect(g_modbus) == -1) { + PLCptr->g_plc_ok = false; + } + else { + modbus_set_slave(g_modbus, 1); + PLCptr->g_plc_ok = true; + } + return true; +} +bool PLCDevice::disconnect_plc(void) +{ + modbus_close(g_modbus); + modbus_free(g_modbus); + return true; +} +int PLCDevice::write_bit_2_plc(int addr, int value) +{ + if (g_plc_ok) + { + g_mutex.lock(); + int ret = modbus_write_bit(g_modbus, addr, value); + g_mutex.unlock(); + //printf("modbus_write_bit:addr=%d,value=%d,ret=%d\n", addr, value, ret); + return ret; + } + else { + //std::cout << "PLC no ok" << std::endl; + return false; + } +} + +int PLCDevice::read_bits_from_plc(int addr, int nb,uint8_t* value) +{ + if (g_plc_ok) + { + g_mutex.lock(); + int ret = modbus_read_bits(g_modbus, addr, nb ,value); + g_mutex.unlock(); + //printf("modbus_read_bits:addr=%d,nb=%d,value=%d,ret=%d\n", addr, nb, *value, ret); + return ret; + } + else { + //std::cout << "PLC no ok" << std::endl; + return false; + } +} + +int PLCDevice::write_short_2_plc(int addr, int nb, uint16_t *value) +{ + if (g_plc_ok) + { + g_mutex.lock(); + int ret = modbus_write_registers(g_modbus, addr, nb, value); + g_mutex.unlock(); + //printf("modbus_write_registers:addr=%d,nb=%d,value=%d,ret=%d\n", addr, nb, *value, ret); + return ret; + } + else { + //std::cout << "PLC no ok" << std::endl; + return false; + } +} + +int PLCDevice::read_short_from_plc(int addr, int nb, uint16_t *value) +{ + if (g_plc_ok) + { + g_mutex.lock(); + int ret = modbus_read_registers(g_modbus, addr, nb, value); + g_mutex.unlock(); + //printf("modbus_read_registers:addr=%d,nb=%d,value=%d,ret=%d\n", addr, nb, *value ,ret); + return ret; + } + else { + //std::cout << "PLC no ok" << std::endl; + return false; + } +} \ No newline at end of file diff --git a/Cigarette/PLC/PLCDevice.h b/Cigarette/PLC/PLCDevice.h new file mode 100644 index 0000000..e9bc161 --- /dev/null +++ b/Cigarette/PLC/PLCDevice.h @@ -0,0 +1,20 @@ +#include + +class PLCDevice +{ +public: + QMutex g_mutex; //访问Modbus的互斥锁 + + bool g_plc_ok; + + //[0]:1=连接,0=断开 + uint8_t g_plc_status; + + static bool init_plc(PLCDevice *PLCptr); + + int write_bit_2_plc(int addr, int value); + int read_bits_from_plc(int addr, int nb, uint8_t* value); + int write_short_2_plc(int addr, int nb, uint16_t *value); + int read_short_from_plc(int addr, int nb, uint16_t *value); + bool disconnect_plc(void); +}; diff --git a/Cigarette/Pylon6.2/include/Base/GCArray.h b/Cigarette/Pylon6.2/include/Base/GCArray.h new file mode 100644 index 0000000..1ceaf42 --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCArray.h @@ -0,0 +1,52 @@ +/**************************************************************************** + (c) 2014 by Teledyne DALSA + Section: Digital Imaging + Project: GCBase + Author: Eric Bourbonnais + + + License: This file is published under the license of the EMVA GenICam Standard Group. + A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. + If for some reason you are missing this file please contact the EMVA or visit the website + (http://www.genicam.org) for a full copy. + + THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP + OR CONTRIBUTORS 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 GCBASE_GCARRAY_H +#define GCBASE_GCARRAY_H + +#include +namespace GENICAM_NAMESPACE +{ + template< class T> + class gcarray + { + public: + gcarray( size_t size) : m_p( NULL) + { + if(size) + m_p = new T[size]; + }; + ~gcarray( ){ if(m_p) delete [] m_p;}; + T* get() const {return m_p;} ; + T* operator *() {return m_p;} ; + T operator[](size_t idx) {return m_p[idx];} ; + private: + T* m_p; + }; + +} + +#endif // GCBASE_GCARRAY_H diff --git a/Cigarette/Pylon6.2/include/Base/GCBase.h b/Cigarette/Pylon6.2/include/Base/GCBase.h new file mode 100644 index 0000000..b56020c --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCBase.h @@ -0,0 +1,40 @@ +/**************************************************************************** + (c) 2005 by STEMMER IMAGING + + License: This file is published under the license of the EMVA GenICam Standard Group. + A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. + If for some reason you are missing this file please contact the EMVA or visit the website + (http://www.genicam.org) for a full copy. + + THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP + OR CONTRIBUTORS 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. + +****************************************************************************/ + + /// \file + /// \brief Common GenICam base include file. + /// \version $Revision$ + /// \date $Date$ + /// \ingroup Base_PublicUtilities + + +#ifndef GENICAM_GCBASE_H +#define GENICAM_GCBASE_H + +#include +#include +#include +#include +#include +#include + +#endif // GENICAM_GCBASE_H diff --git a/Cigarette/Pylon6.2/include/Base/GCError.h b/Cigarette/Pylon6.2/include/Base/GCError.h new file mode 100644 index 0000000..509870d --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCError.h @@ -0,0 +1,75 @@ +//*************************************************************************** +// (C) 2005 STEMMER IMAGING +// +/// \file +/// GenICam Common Error Values +/// \author Rupert Stelz (STEMMER IMAGING) +/// \version 0.1 +/// \date 2005 + /// \ingroup Base_PublicUtilities +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//*************************************************************************** + +// TLIClientDummy.dll GenICam TransportLayer Dummy Client + +#ifndef GC_ERROR_DEF_H +#define GC_ERROR_DEF_H + +#include + +namespace GENICAM_NAMESPACE +{ + /// Gen Cam Error + //! \ingroup Base_PublicUtilities + typedef int32_t GC_ERROR; + + //! Define a list which maps error ids to error descriptions + //! The list is filled in the cpp file + //! \ingroup Base_PublicUtilities + enum GCErrorID + { + GC_ERR_SUCCESS = 0, + GC_ERR_INVALID_BUFFER_SIZE = -1, + GC_ERR_INVALID_HANDLE = -2, + GC_ERR_INVALID_ID = -3, + GC_ERR_ACCESS_DENIED = -4, + GC_ERR_NO_DATA = -5, + GC_ERR_ERROR = -6, + GC_ERR_INVALID_PARAMETER = -7, + GC_ERR_TIMEOUT = -8, + GC_ERR_INVALID_FILENAME = -9, + GC_ERR_INVALID_ADDRESS = -10, + GC_ERR_FILE_IO = -11 + }; + + //! Modules were errors can come from + //! \ingroup Base_PublicUtilities + enum GCModuleID { + GC_MOD_SYSTEM = 0x0, + GC_MOD_TLICLIENT = 0x20000000, + GC_MOD_TLISYSTEM = 0x10000000, + GC_MOD_FACTORY = 0x08000000, + GC_MOD_GENAPI = 0x04000000 + + }; + + #define GC_GET_ERROR(ErrorCode) (((ErrorCode ) & 0xFFFF ) | 0xFFFF0000) + #define GC_IS_ERROR(ErrorCode) (((ErrorCode ) & 0x80000000) ? true : false) +} +#endif //GC_ERROR_DEF_H diff --git a/Cigarette/Pylon6.2/include/Base/GCException.h b/Cigarette/Pylon6.2/include/Base/GCException.h new file mode 100644 index 0000000..7ff8274 --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCException.h @@ -0,0 +1,289 @@ +//----------------------------------------------------------------------------- +// (c) 2004 by Basler Vision Technologies +// Section: Vision Components +// Project: GenICam +// Author: Fritz Dierks +// $Header$ +// +// 01.10.2014 Stemmer, SD +// prepared for remove of std::exception base class +// +// 14.03.2005 Stemmer, RS +// changed minor things like namespace +// added a AccessException +// added a TimeoutException +// +// 21.02.2006 Stemmer, SD +// used _vsnprintf_s function for VS8 and higher (compiler fork) +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! + \file + Standard GenICam Exceptions + \ingroup Base_PublicUtilities + */ + +#ifndef GENCAM_EXCEPTION_H_ +#define GENCAM_EXCEPTION_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma pack(push, 8) + +namespace GENICAM_NAMESPACE +{ + /** + \brief GenICam's exception class + \ingroup Base_PublicUtilities + */ + class GCBASE_RTTI_CLASS_API GenericException + { + public: + //! Constructor + GenericException(const char* pDescription, const char *pSourceFileName, unsigned int SourceLine); + + //! Constructor + GenericException(const char* pDescription, const char *pSourceFileName, unsigned int SourceLine, const char* pExceptionType); + + //! Constructor (GenApi specific) + GenericException(const char* pDescription, const char *pSourceFileName, unsigned int SourceLine, const char *pEntryPoint, const char *pErrorNodeName, const char* pExceptionType); + + //! Get error description + virtual const char* GetDescription() const throw(); + + //! Get filename in which the error occurred + virtual const char* GetSourceFileName() const throw(); + + //! Get line number at which the error occurred + virtual unsigned int GetSourceLine() const throw(); + + //! Get error description (overwrite from std:exception) + virtual const char *what() const throw(); + + virtual ~GenericException() throw(); + + private: + + //! Assembles the error message + void AssembleMessage(); + + //! The full error message + GENICAM_NAMESPACE::gcstring m_What; + + //! The full error message + GENICAM_NAMESPACE::gcstring m_ExceptionType; + + //! Line number at which the error occurred + unsigned int m_SourceLine; + + //! Filename in which the error occurred + GENICAM_NAMESPACE::gcstring m_SourceFileName; + + //! Error description + GENICAM_NAMESPACE::gcstring m_Description; + + /* the following members are GenApi specific */ + + //! Node and method where the call stack entered the node map (may be empty) + GENICAM_NAMESPACE::gcstring m_EntryPoint; + + //! Node where the error occurred (may be empty) + GENICAM_NAMESPACE::gcstring m_ErrorNodeName; + }; + + //! Creates an exception with the same functionality as the GenericException but being of different type + //! \ingroup Base_PublicUtilities +#define DECLARE_EXCEPTION( name ) \ + class GCBASE_RTTI_CLASS_API name : public GENICAM_NAMESPACE::GenericException \ + { \ + public: \ + name( const char* pDescription, const char *pSourceFileName, int SourceLine ); \ + name( const char* pDescription, const char *pSourceFileName, int SourceLine, const char* pExceptionType ); \ + name( const char* pDescription, const char *pSourceFileName, int SourceLine, const char *pEntryPoint, const char *pErrorNodeName, const char* pExceptionType ); \ + } + + //! \addtogroup Base_PublicUtilities + + DECLARE_EXCEPTION(BadAllocException); + + //! Exception fired if an argument is invalid + DECLARE_EXCEPTION(InvalidArgumentException); + + //! Exception fired if an argument is out of range + DECLARE_EXCEPTION(OutOfRangeException); + + //! Exception fired if a property access fails + DECLARE_EXCEPTION(PropertyException); + + //! Runtime exception + DECLARE_EXCEPTION(RuntimeException); + + //! Exception to be thrown to indicate logical errors in program flow + DECLARE_EXCEPTION(LogicalErrorException); + + //! Exception to be thrown to indicate an access error + DECLARE_EXCEPTION(AccessException); + + //! Exception to be thrown to indicate an timeout error + DECLARE_EXCEPTION(TimeoutException); + + //! Exception to be thrown to indicate the result of a dynamic cast was zero + DECLARE_EXCEPTION(DynamicCastException); + + //! \} + + /*-----------------------------------------------------------------*/ + // Utilities + /*-----------------------------------------------------------------*/ + + /** + \brief printf like creation of exceptions + \ingroup Base_PublicImpl + */ + template + class ExceptionReporter + { + public: + + ExceptionReporter(const char* pSourceFileName, int SourceLine) + : m_SourceFileName(pSourceFileName) + , m_SourceLine(SourceLine) + { + } + + ExceptionReporter(const char* pSourceFileName, int SourceLine, const char* pExceptionType) + : m_SourceFileName(pSourceFileName) + , m_SourceLine(SourceLine) + , m_ExceptionType(pExceptionType) + { + } + + E Report(const char* pFormat, ...) + { + char pBuffer[256]; + va_list vap; + va_start(vap, pFormat); + +# if defined (_MSC_VER) + vsnprintf_s(pBuffer, sizeof pBuffer, _TRUNCATE, pFormat, vap); +# else + vsnprintf( pBuffer, sizeof pBuffer, pFormat, vap ); +# endif + + va_end(vap); + + return E(pBuffer, m_SourceFileName.c_str(), m_SourceLine, m_ExceptionType.c_str()); + }; + + E Report() + { + return E("", m_SourceFileName.c_str(), m_SourceLine, m_ExceptionType.c_str()); + } + + E Report(const std::string &s) + { + return E(s.c_str(), m_SourceFileName.c_str(), m_SourceLine, m_ExceptionType.c_str()); + } + + E Report(const std::stringstream& str) + { + return E(str.str().c_str(), m_SourceFileName.c_str(), m_SourceLine, m_ExceptionType.c_str()); + } + + protected: + //! the path to the source file where the exception is thrown + GENICAM_NAMESPACE::gcstring m_SourceFileName; + + //! The line within the source file where the exception is thrown + int m_SourceLine; + + //! the type of the exception in string + GENICAM_NAMESPACE::gcstring m_ExceptionType; + }; + + //! \addtogroup Base_PublicImpl + //! \{ + + //! Fires a generic exception, e.g. throw GENERIC_EXCEPTION("%ld too large", Value); + #define GENERIC_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__).Report + + //! Fires a bad alloc exception, e.g. throw BAD_ALLOC_EXCEPTION(); + #define BAD_ALLOC_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "BadAllocException" ).Report + + //! Fires an invalid argument exception, e.g. throw INVALID_ARGUMENT_EXCEPTION("%ld too large", Value); + #define INVALID_ARGUMENT_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "InvalidArgumentException" ).Report + + //! Fires an out of range exception, e.g. throw OUT_OF_RANGE_EXCEPTION("%ld too large", Value); + #define OUT_OF_RANGE_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "OutOfRangeException" ).Report + + //! Fires an property exception, e.g. throw PROPERTY_EXCEPTION("%ld too large", Value); + #define PROPERTY_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "PropertyException" ).Report + + //! Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!") + #define RUNTIME_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "RuntimeException" ).Report + + //! Fires a logical error exception, e.g. throw LOGICAL_ERROR_EXCEPTION("Should never reach this point") + #define LOGICAL_ERROR_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "LogicalErrorException" ).Report + + //! Fires a access exception, e.g. throw ACCESS_EXCEPTION("Not everybody") + #define ACCESS_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "AccessException" ).Report + + //! Fires a timeout error exception, e.g. throw TIMEOUT_EXCEPTION("Not everybody") + #define TIMEOUT_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__,"TimeoutException" ).Report + + //! Fires a dynamic cast exception, e.g. throw DYNAMICCAST_EXCEPTION("Not everybody") + #define DYNAMICCAST_EXCEPTION GENICAM_NAMESPACE::ExceptionReporter(__FILE__, __LINE__, "DynamicCastException" ).Report + + //! Range check for int64 + #define CHECK_RANGE_I64(_Value, _Min, _Max, _Inc) \ + if((int64_t)(_Value) < (int64_t)(_Min)) \ + throw OUT_OF_RANGE_EXCEPTION("Value = %" FMT_I64 "d must be equal or greater than Min = %" FMT_I64 "d", (int64_t)(_Value), (int64_t)(_Min)); \ + else if((int64_t)(_Value) > (int64_t)(_Max)) \ + throw OUT_OF_RANGE_EXCEPTION("Value = %" FMT_I64 "d must be equal or smaller than Max = %" FMT_I64 "d", (int64_t)(_Value), (int64_t)(_Max)); \ + else if ( 0 == _Inc ) \ + throw LOGICAL_ERROR_EXCEPTION("Increment must not equal 0!"); \ + else if( ((int64_t)(_Value) - (int64_t)(_Min)) % (int64_t)(_Inc) != 0) \ + throw OUT_OF_RANGE_EXCEPTION("The difference between Value = %" FMT_I64 "d and Min = %" FMT_I64 "d must be dividable without rest by Inc = %" FMT_I64 "d", (int64_t)(_Value), (int64_t)(_Min), (int64_t)(_Inc)); + + //! Range check for float + #define CHECK_RANGE_FLT(_Value, _Min, _Max) \ + if ((_Value) < (_Min)) \ + throw OUT_OF_RANGE_EXCEPTION( "Value %f must be greater than or equal %f", (_Value), (_Min) ); \ + else if ((_Value) > (_Max)) \ + throw OUT_OF_RANGE_EXCEPTION( "Value %f must be smaller than or equal %f", (_Value), (_Max) ); + + //! Checks if a dynamic_cast is possible + #define CHECK_DYNAMIC_CAST_POINTER( _Pointer )\ + assert( (_Pointer) != NULL ); \ + if (NULL == (_Pointer)) throw LOGICAL_ERROR_EXCEPTION( "Unexpected type in dynamic cast" ) + + //! \} + +} + +#pragma pack(pop) + +#endif // GENCAM_EXCEPTION_H_ diff --git a/Cigarette/Pylon6.2/include/Base/GCLinkage.h b/Cigarette/Pylon6.2/include/Base/GCLinkage.h new file mode 100644 index 0000000..905243b --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCLinkage.h @@ -0,0 +1,183 @@ +//----------------------------------------------------------------------------- +// (c) 2007 by Basler Vision Technologies +// Section: Vision Components +// Project: GenICam +// Author: Fritz Dierks +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! + \file + \brief helpers for pragma linkage + */ + +#ifndef LINKAGE_H +#define LINKAGE_H + +#include + +#if defined (_MSC_VER) + +# if defined (_WIN32) && defined (_MT ) +# if defined(GENICAM_USER_ALWAYS_LINK_RELEASE) +// for the central installation always the Release version is used +# define CONFIGURATION "MD" +# else +# if defined(_DEBUG) || defined(DEBUG) +# define CONFIGURATION "MDd" +# else +# define CONFIGURATION "MD" +# endif +# endif // defined(GENICAM_USER_ALWAYS_LINK_RELEASE) +# else +# error Invalid configuration +# endif + +# if defined(COMPILER) // COMPILER may be force set from outside +# undef GENICAM_COMPILER_STR +# define GENICAM_COMPILER_STR COMPILER +# endif + +// _MSC_VER==1400 : VC80 : Visual C++ 2005 +// _MSC_VER==1500 : VC90 : Visual C++ 2008 +// _MSC_VER==1600 : VC100 : Visual C++ 2010 +// _MSC_VER==1700 : VC110 : Visual C++ 2012 +// _MSC_VER==1800 : VC120 : Visual C++ 2013 +// _MSC_VER==1900 : VC140 : Visual C++ 2015 +# if !( _MSC_VER==1400 || _MSC_VER==1500 || _MSC_VER==1600 || _MSC_VER==1700 || _MSC_VER==1800 || _MSC_VER==1900 ) && ! defined(GENICAM_USER_ACCEPTS_ANY_COMPILER) +# define COMPILER_VERSION_2( s ) #s +# define COMPILER_VERSION_STRING(version) COMPILER_VERSION_2( version ) +# pragma message( "Notice: Using GenICam with untested compiler, version " COMPILER_VERSION_STRING(_MSC_VER) " detected!" ) +# pragma message( "Following versions were tested: 1400, 1500, 1600, 1700, 1800, 1900." ) +# undef COMPILER_VERSION_2 +# undef COMPILER_VERSION_STRING +# endif + +# if defined(GENICAM_COMPANY_SUFFIX) +# define GENICAM_SUFFIX( CONFIGURATION, GENICAM_COMPILER_STR, VERSION_MAJOR, VERSION_MINOR, EXTENSION ) \ + "_" CONFIGURATION "_" GENICAM_COMPILER_STR "_v" VERSION_MAJOR "_" VERSION_MINOR "_" TOSTRING(GENICAM_COMPANY_SUFFIX) "." EXTENSION +# else +# define GENICAM_SUFFIX( CONFIGURATION, GENICAM_COMPILER_STR, VERSION_MAJOR, VERSION_MINOR, EXTENSION ) \ + "_" CONFIGURATION "_" GENICAM_COMPILER_STR "_v" VERSION_MAJOR "_" VERSION_MINOR "." EXTENSION +# endif + // _MDd_VC80_v3_0_Company + // _MD_VC80_v3_0_Company + // _MDd_VC80_v3_0 + // _MD_VC80_v3_0 + +# define LIB_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_COMPILER_STR, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "lib" ) +#if defined(UNDER_RTSS) +# define DLL_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_COMPILER_STR, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "rtdll" ) +#else +# define DLL_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_COMPILER_STR, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "dll" ) +#endif // defined(UNDER_RTSS) +# define EXE_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_COMPILER_STR, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "exe" ) + +# define DLL_PREFIX "" + +#elif defined (__GNUC__) && (defined (__linux__) || defined(__APPLE__) || defined(VXWORKS)) + +# if defined(_DEBUG) || defined(DEBUG) +# define CONFIGURATION "_d" +# else +# define CONFIGURATION "" +# endif + +# if defined(GENICAM_COMPANY_SUFFIX) +# define GENICAM_SUFFIX( CONFIGURATION, VERSION_MAJOR, VERSION_MINOR, EXTENSION ) \ + CONFIGURATION "_" GENICAM_COMPILER_STR "_v" VERSION_MAJOR "_" VERSION_MINOR "_" TOSTRING(GENICAM_COMPANY_SUFFIX) "." EXTENSION +# else +# define GENICAM_SUFFIX( CONFIGURATION, VERSION_MAJOR, VERSION_MINOR, EXTENSION ) \ + CONFIGURATION "_" GENICAM_COMPILER_STR "_v" VERSION_MAJOR "_" VERSION_MINOR "." EXTENSION +# endif + // _d_gcc40_v3_0_Company + // _gcc40_v3_0_Company + // _d_gcc40_v3_0 + // _gcc40_v3_0 + + +# define LIB_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "a" ) + +# if defined(__linux__) +# define DLL_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "so" ) +# elif defined(VXWORKS) +# define DLL_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "out" ) +# else +# define DLL_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "dylib" ) +# endif + +# define EXE_SUFFIX \ + GENICAM_SUFFIX( CONFIGURATION, GENICAM_VERSION_MAJOR_STR, GENICAM_VERSION_MINOR_STR, "" ) + +# if defined(VXWORKS) +# define DLL_PREFIX "" +# else +# define DLL_PREFIX "lib" +# endif + +#else + +# error Unknown shared library support + +#endif + +#define LIB_NAME( MODULE ) \ + MODULE LIB_SUFFIX + +#define DLL_NAME( MODULE ) \ + DLL_PREFIX MODULE DLL_SUFFIX + +#define EXE_NAME( MODULE ) \ + MODULE EXE_SUFFIX + + +// The CameraLink standard defines the names for certain DLLs we build that do not match the GenICam naming scheme +#if defined(_DEBUG) || defined(DEBUG) +# define CAMERALINK_CONFIGURATION "d" +#else +# define CAMERALINK_CONFIGURATION "" +#endif +# +#if defined(_MSC_VER) +# if defined(UNDER_RTSS) +# define CAMERALINK_DLL_SUFFIX ".rtdll" +# else +# define CAMERALINK_DLL_SUFFIX ".dll" +# endif +#elif defined (__GNUC__) && (defined (__linux__) || defined(__APPLE__) || defined(VXWORKS)) +# if defined(__linux__) +# define CAMERALINK_DLL_SUFFIX ".so" +# elif defined(VXWORKS) +# define CAMERALINK_DLL_SUFFIX ".out" +# else +# define CAMERALINK_DLL_SUFFIX ".dylib" +# endif +#endif +# +#define CAMERALINK_DLL_NAME( MODULE) \ + MODULE CAMERALINK_CONFIGURATION CAMERALINK_DLL_SUFFIX + +#endif // LINKAGE_H diff --git a/Cigarette/Pylon6.2/include/Base/GCNamespace.h b/Cigarette/Pylon6.2/include/Base/GCNamespace.h new file mode 100644 index 0000000..74af99f --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCNamespace.h @@ -0,0 +1,53 @@ +/**************************************************************************** +(c) 2004 by Basler Vision Technologies +(c) 2005 STEMMER IMAGING + +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. + + +****************************************************************************/ + +/// \file +/// \brief GenICam versioned namespace. +/// \ingroup Base_PublicUtilities + +#ifndef GENICAM_NAMESPACE_H +#define GENICAM_NAMESPACE_H + +#include + +#if ! defined( GENICAM_NAMESPACE_DEFINED ) +// This is the development namespace for the GenICam libraries +# if defined(GENICAM_COMPANY_SUFFIX) +# define GENICAM_NAMESPACE GENICAM_SEP_UNDERSCORE_COMPANY(GenICam, GENICAM_VERSION_MAJOR, GENICAM_VERSION_MINOR, GENICAM_COMPANY_SUFFIX) +# else +# define GENICAM_NAMESPACE GENICAM_SEP_UNDERSCORE(GenICam, GENICAM_VERSION_MAJOR, GENICAM_VERSION_MINOR) +# endif + +# define GENICAM_NAMESPACE_DEFINED +#endif // GENICAM_NAMESPACE_DEFINED + +namespace GENICAM_NAMESPACE {} + + +#if ! defined( GENICAM_SUPPRESS_NAMESPACE_ALIAS ) + // Public alias + namespace GenICam = GENICAM_NAMESPACE; +#endif // GENICAM_SUPPRESS_NAMESPACE_ALIAS + +#endif // GENICAM_NAMESPACE_H diff --git a/Cigarette/Pylon6.2/include/Base/GCRTSSUtilities.h b/Cigarette/Pylon6.2/include/Base/GCRTSSUtilities.h new file mode 100644 index 0000000..0f2412f --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCRTSSUtilities.h @@ -0,0 +1,257 @@ +//----------------------------------------------------------------------------- +// (c) 2014 by Basler Vision Technologies +// Section: Vision Components +// Project: GenICam +// Author: Maxime Dupont +// $Header$ +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief GenICam RTSS utilities +\ingroup Base_PublicUtilities +*/ + +#ifndef GENAPI_GENAPIRTSSUTILITIES_DEF_H_ +#define GENAPI_GENAPIRTSSUTILITIES_DEF_H_ + +#include "crtdefs.h" +#include +#include +#include +#include "windows.h" + +#if defined(UNDER_RTSS) && defined(GENICAM_BUILD) +#if defined(htons) +#undef htons +#endif // defined(htons) + +#if defined(ntohs) +#undef ntohs +#endif // defined(ntohs) + +#if defined(htonl) +#undef htonl +#endif // defined(htonl) + +#if defined(ntohl) +#undef ntohl +#endif // defined(ntohl) + + +#define HTONS(n) (unsigned short)(((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) +#define NTOHS(n) (unsigned short)(((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8)) + +#define HTONL(n) (unsigned long)(((((unsigned long)(n) & 0xFF)) << 24) | \ + ((((unsigned long)(n) & 0xFF00)) << 8) | \ + ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ + ((((unsigned long)(n) & 0xFF000000)) >> 24)) + +#define NTOHL(n) (unsigned long)(((((unsigned long)(n) & 0xFF)) << 24) | \ + ((((unsigned long)(n) & 0xFF00)) << 8) | \ + ((((unsigned long)(n) & 0xFF0000)) >> 8) | \ + ((((unsigned long)(n) & 0xFF000000)) >> 24)) + +#define htons(n) HTONS(n) +#define ntohs(n) NTOHS(n) + +#define htonl(n) HTONL(n) +#define ntohl(n) NTOHL(n) + +#endif + + +#if defined(UNDER_RTSS) + +#ifdef __cplusplus +extern "C" { +#endif + +WINBASEAPI __out HANDLE WINAPI FindFirstFileExW( + __in LPCWSTR lpFileName, + __in FINDEX_INFO_LEVELS fInfoLevelId, + __out LPVOID lpFindFileData, + __in FINDEX_SEARCH_OPS fSearchOp, + __reserved LPVOID lpSearchFilter, + __in DWORD dwAdditionalFlags + ); + +WINBASEAPI __out HANDLE WINAPI FindFirstFileExA( + __in LPCSTR lpFileName, + __in FINDEX_INFO_LEVELS fInfoLevelId, + __out LPVOID lpFindFileData, + __in FINDEX_SEARCH_OPS fSearchOp, + __reserved LPVOID lpSearchFilter, + __in DWORD dwAdditionalFlags + ); + +WINBASEAPI BOOL WINAPI FindNextFileW( + __in HANDLE hFindFile, + __out LPWIN32_FIND_DATAW lpFindFileData + ); + +WINBASEAPI BOOL WINAPI FindNextFileA( + __in HANDLE hFindFile, + __out LPWIN32_FIND_DATAA lpFindFileData + ); + +WINBASEAPI BOOL WINAPI FindClose( + __inout HANDLE hFindHandle + ); + +WINBASEAPI BOOL WINAPI SystemTimeToTzSpecificLocalTime( + __in_opt CONST TIME_ZONE_INFORMATION * lpTimeZoneInformation, + __in CONST SYSTEMTIME * lpUniversalTime, + __out LPSYSTEMTIME lpLocalTime + ); + +WINBASEAPI UINT WINAPI GetDriveTypeW( + __in_opt LPCWSTR lpRootPathName + ); + +WINBASEAPI UINT WINAPI GetDriveTypeA( + __in_opt LPCSTR lpRootPathName + ); + +WINBASEAPI BOOL WINAPI GetFileInformationByHandle( + __in HANDLE hFile, + __out LPBY_HANDLE_FILE_INFORMATION lpFileInformation + ); + + +WINBASEAPI BOOL WINAPI PeekNamedPipe( + __in HANDLE hNamedPipe, + __out_bcount_part_opt(nBufferSize, *lpBytesRead) LPVOID lpBuffer, + __in DWORD nBufferSize, + __out_opt LPDWORD lpBytesRead, + __out_opt LPDWORD lpTotalBytesAvail, + __out_opt LPDWORD lpBytesLeftThisMessage + ); + +WINBASEAPI DWORD WINAPI GetFullPathNameW( + __in LPCWSTR lpFileName, + __in DWORD nBufferLength, + __out_ecount_part_opt(nBufferLength, return +1) LPWSTR lpBuffer, + __deref_opt_out LPWSTR * lpFilePart + ); + +WINBASEAPI BOOL WINAPI SetCurrentDirectoryW( + __in LPCWSTR lpPathName + ); + +WINBASEAPI DWORD WINAPI GetCurrentDirectoryW( + __in DWORD nBufferLength, + __out_ecount_part_opt(nBufferLength, return +1) LPWSTR lpBuffer + ); + +WINBASEAPI DWORD WINAPI GetFullPathNameA( + __in LPCSTR lpFileName, + __in DWORD nBufferLength, + __out_ecount_part_opt(nBufferLength, return +1) LPSTR lpBuffer, + __deref_opt_out LPSTR * lpFilePart + ); + +WINBASEAPI UINT WINAPI SetErrorMode( + __in UINT uMode + ); + +WINBASEAPI LANGID WINAPI GetUserDefaultLangID(void); + + +WINBASEAPI DWORD WINAPI GetFileAttributesW( + __in LPCWSTR lpFileName + ); + +WINBASEAPI DWORD WINAPI GetFileAttributesA( + __in LPCSTR lpFileName + ); + +WINBASEAPI BOOL WINAPI GetFileAttributesExW( + __in LPCWSTR lpFileName, + __in GET_FILEEX_INFO_LEVELS fInfoLevelId, + __out LPVOID lpFileInformation + ); + +WINBASEAPI BOOL WINAPI GetModuleHandleExA( + __in DWORD dwFlags, + __in_opt LPCSTR lpModuleName, + __out HMODULE * phModule + ); + +WINBASEAPI HLOCAL WINAPI LocalFree( + __deref HLOCAL hMem + ); + +WINBASEAPI BOOL WINAPI CopyFileA( + __in LPCSTR lpExistingFileName, + __in LPCSTR lpNewFileName, + __in BOOL bFailIfExists + ); + +// ************************************************************************ +// ********** GenAPITest section ********** +// ************************************************************************ + +WINBASEAPI UINT WINAPI GetSystemDirectoryA( + __out_ecount_part_opt(uSize, return + 1) LPSTR lpBuffer, + __in UINT uSize + ); + +WINBASEAPI DWORD WINAPI GetTempPathA( + __in DWORD nBufferLength, + __out_ecount_part_opt(nBufferLength, return + 1) LPSTR lpBuffer + ); + +WINBASEAPI BOOL WINAPI GetThreadTimes( + __in HANDLE hThread, + __out LPFILETIME lpCreationTime, + __out LPFILETIME lpExitTime, + __out LPFILETIME lpKernelTime, + __out LPFILETIME lpUserTime + ); + +WINBASEAPI BOOL WINAPI SetConsoleOutputCP( + __in UINT wCodePageID + ); + +WINBASEAPI BOOL WINAPI SetEnvironmentVariableW( + __in LPCWSTR lpName, + __in_opt LPCWSTR lpValue + ); + + +WINBASEAPI __success(return < nSize) __success(return != 0) DWORD WINAPI GetEnvironmentVariableA( + __in_opt LPCSTR lpName, + __out_ecount_part_opt(nSize, return + 1) LPSTR lpBuffer, + __in DWORD nSize + ); + +WINBASEAPI BOOL WINAPI CopyFileW( + __in LPCWSTR lpExistingFileName, + __in LPCWSTR lpNewFileName, + __in BOOL bFailIfExists + ); + +#ifdef __cplusplus +} +#endif + +#endif // defined(UNDER_RTSS) + +#endif // GENAPI_GENAPIRTSSUTILITIES_DEF_H_ + diff --git a/Cigarette/Pylon6.2/include/Base/GCString.h b/Cigarette/Pylon6.2/include/Base/GCString.h new file mode 100644 index 0000000..9607b01 --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCString.h @@ -0,0 +1,258 @@ +/**************************************************************************** +(c) 2005 by STEMMER IMAGING + +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. + + +****************************************************************************/ + +/// \file +/// \brief Portable string implementation +/// \ingroup Base_PublicUtilities + + +#ifndef GENICAM_GCSTRING_H +#define GENICAM_GCSTRING_H + +#include +#include +#include +#include + +#pragma pack(push, 8) + + +/** +\brief Indicates either 'not found' or 'all remaining characters'. +\ingroup GenApi_Implementation +*/ +#define GCSTRING_NPOS size_t(-1) + +namespace GENICAM_NAMESPACE +{ + /** + \brief A string class which is a clone of std::string + \ingroup Base_PublicUtilities + */ + class GCBASE_API gcstring + { +# if defined(_MSC_VER) && !defined(PHARLAP_WIN32) + public: + //! Helper class for storing shared-ownership wchar_t * + class GCBASE_API gcwchar + { + public: + //! Creates a buffer of \a n wchar_ts + explicit gcwchar( size_t n ); + + // copy constructor + gcwchar( const gcwchar &rhs ); + + // assignment operator + gcwchar & operator = (const gcwchar &rhs); + + //! Gets the c-string. + const wchar_t * c_str() const; + + //! Gets the length of the buffer. + size_t length() const; + + //! destructor + ~gcwchar(); + private: + class impl; + impl *m_pimpl; + }; + +# endif + + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + gcstring (); + gcstring ( const char *pc ); + gcstring ( const char *pc, size_t n ); + gcstring ( size_t count, char ch ); + gcstring ( const gcstring &str ); +# if defined(_MSC_VER) && !defined(PHARLAP_WIN32) + explicit gcstring ( const wchar_t *pBufferUTF16 ); + gcstring ( const wchar_t *pBufferUTF16, size_t n ); +# endif + virtual ~gcstring ( void ); + + // Data access + // ------------------------------------------------------------------------- + public: + virtual gcstring & append ( const gcstring &str ); + virtual gcstring & append ( size_t count, char ch ); + virtual gcstring & assign ( const gcstring &str ); + virtual gcstring & assign ( size_t count, char ch ); + virtual gcstring & assign ( const char *pc ); + virtual gcstring & assign ( const char *pc, size_t n ); +# if defined(_MSC_VER) && !defined(PHARLAP_WIN32) + virtual gcstring & assign ( const wchar_t *pStringUTF16 ); + virtual gcstring & assign ( const wchar_t *pStringUTF16, int n ); +# endif + virtual int compare ( const gcstring &str ) const; +# if defined(_MSC_VER) && !defined(PHARLAP_WIN32) + virtual gcwchar w_str ( void ) const; +# endif + virtual const char *c_str ( void ) const; + virtual bool empty ( void ) const; + virtual size_t find ( char ch, size_t offset = 0 ) const; + virtual size_t find ( const gcstring &str, size_t offset = 0 ) const; + virtual size_t find ( const gcstring &str, size_t offset, size_t count ) const; + virtual size_t find ( const char* pc, size_t offset = 0) const; + virtual size_t find ( const char* pc, size_t offset, size_t count ) const; + virtual size_t length ( void ) const; + virtual size_t size ( void ) const; + virtual void resize ( size_t n ); + virtual size_t max_size ( ) const; + virtual gcstring substr ( size_t offset = 0, size_t count = GCSTRING_NPOS ) const; + virtual size_t find_first_of ( const gcstring &str, size_t offset = 0 ) const; + virtual size_t find_first_not_of ( const gcstring &str, size_t offset = 0 ) const; + static size_t _npos ( void ); + virtual void swap ( gcstring &Right ); + + + // Operators + // ------------------------------------------------------------------------- + public: + bool operator != ( const gcstring &str ) const; + bool operator != ( const char *pc ) const; + gcstring & operator += ( const gcstring &str ); + gcstring operator += ( const gcstring &str ) const; + gcstring & operator += ( const char *pc ); + + gcstring & operator += ( char ch ); + gcstring operator += ( char ch ) const; + gcstring & operator = ( const gcstring &str ); +# if defined(_MSC_VER) && !defined(PHARLAP_WIN32) + gcstring & operator = ( const wchar_t *pStringUTF16 ); +# endif + bool operator == ( const gcstring &str ) const; + bool operator == ( const char *pc ) const; + bool operator < ( const gcstring &str ) const; + bool operator > ( const gcstring &str ) const; + operator const char * ( void ) const; + void operator delete ( void *pWhere ); + void operator delete ( void *pWhere, void *pNewWhere ); + void * operator new ( size_t uiSize ); + void * operator new ( size_t uiSize, void *pWhere ); + GCBASE_API + friend gcstring operator + ( const gcstring &left, const gcstring &right ); + GCBASE_API + friend gcstring operator + ( const gcstring &left, const char *right ); + GCBASE_API + friend gcstring operator + ( const char *left, const gcstring &right ); + + // Member + // ------------------------------------------------------------------------- + private: + // redundant pointer to make the possible to see the contents of the string in the debugger + const char* m_psz; + // actual std::string object + uint8_t m_opaqueData[64]; + + // Constants + // ------------------------------------------------------------------------- + public: + // Beware : this static member prevents delay loading + // use _npos() instead + static const size_t npos; + }; +} + +namespace GENICAM_NAMESPACE +{ + // this is necessary due to the circular dependency between string/exception + GCBASE_API void ThrowBadAlloc(const char *source, int line); + + //! STL getline + //! \ingroup Base_PublicUtilities + inline std::istream & getline(std::istream& is, GENICAM_NAMESPACE::gcstring& str) + { + try + { + std::string tmp; + std::getline(is, tmp); + str.assign(tmp.c_str(), tmp.size()); + } + catch(std::bad_alloc &) + { + ThrowBadAlloc(__FILE__, __LINE__); + } + return is; + } + + //! STL getline + //! \ingroup Base_PublicUtilities + inline std::istream & getline(std::istream& is, GENICAM_NAMESPACE::gcstring& str, char delim) + { + try + { + std::string tmp; + std::getline(is, tmp, delim); + str.assign(tmp.c_str(), tmp.size()); + } + catch(std::bad_alloc &) + { + ThrowBadAlloc(__FILE__, __LINE__); + } + return is; + } +} + + + +//! STL operator out +//! \ingroup Base_PublicUtilities +inline std::ostream & operator <<(std::ostream &ostr, const GENICAM_NAMESPACE::gcstring &str) +{ + try + { + // use formatted output operator of std::string + ostr << str.c_str(); + } + catch(std::bad_alloc &) + { + GENICAM_NAMESPACE::ThrowBadAlloc(__FILE__, __LINE__); + } + return ostr; +} + +//! STL operator in +//! \ingroup Base_PublicUtilities +inline std::istream & operator >>(std::istream &istr, GENICAM_NAMESPACE::gcstring &str) +{ + try + { + std::string tmp; + istr >> tmp; + str.assign(tmp.c_str(), tmp.size()); + } + catch(std::bad_alloc &) + { + GENICAM_NAMESPACE::ThrowBadAlloc(__FILE__, __LINE__); + } + return istr; +} + +#pragma pack(pop) + +#endif // GENICAM_GCSTRING_H diff --git a/Cigarette/Pylon6.2/include/Base/GCStringVector.h b/Cigarette/Pylon6.2/include/Base/GCStringVector.h new file mode 100644 index 0000000..9776ff4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCStringVector.h @@ -0,0 +1,185 @@ +/**************************************************************************** + (c) 2005 by STEMMER IMAGING + + // License: This file is published under the license of the EMVA GenICam Standard Group. + // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. + // If for some reason you are missing this file please contact the EMVA or visit the website + // (http://www.genicam.org) for a full copy. + // + // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" + // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP + // OR CONTRIBUTORS 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. + + + ****************************************************************************/ + +/// \file +/// \brief Portable string vector implementation +/// \ingroup Base_PublicUtilities + + + +#ifndef GENICAM_GCSTRINGLIST_H +#define GENICAM_GCSTRINGLIST_H + +#include +#include + +#pragma pack(push, 8) + + +#if defined (_WIN32) || (defined (__GNUC__) && (defined (__linux__) || defined(__APPLE__) || defined(VXWORKS))) + + +namespace GENICAM_NAMESPACE +{ + + /** + \brief A vector of gcstrings which is a clone of std::vector + \ingroup Base_PublicUtilities + */ + class GCBASE_API gcstring_vector + { + // Nested types + // --------------------------------------------------------------------------- + public: + class GCBASE_API const_iterator + { + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + const_iterator(gcstring *pStr = 0); + + // Operators + // ------------------------------------------------------------------------- + public: + const gcstring & operator * (void) const; + const gcstring * operator -> (void) const; + const_iterator & operator ++ (void); + const_iterator operator ++ (int); + const_iterator & operator -- (void); + const_iterator operator -- (int); + const_iterator & operator += (intptr_t iInc); + const_iterator operator + (intptr_t iInc) const; + const_iterator & operator -= (intptr_t iDec); + intptr_t operator - (const const_iterator &iter) const; + const_iterator operator - (intptr_t iDec) const; + const gcstring & operator [] (intptr_t iIndex) const; + bool operator == (const const_iterator &iter) const; + bool operator != (const const_iterator &iter) const; + bool operator < (const const_iterator &iter) const; + bool operator > (const const_iterator &iter) const; + bool operator <= (const const_iterator &iter) const; + bool operator >= (const const_iterator &iter) const; + GCBASE_API + friend const_iterator operator + (intptr_t iInc, const const_iterator &iter); + + // Member + // ------------------------------------------------------------------------- + protected: + gcstring * _ps; + }; + + class GCBASE_API iterator : + public const_iterator + { + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + iterator(gcstring *pStr = 0); + + // Operators + // ------------------------------------------------------------------------- + public: + gcstring & operator * (void) const; + gcstring * operator -> (void) const; + iterator & operator ++ (void); + iterator operator ++ (int); + iterator & operator -- (void); + iterator operator -- (int); + iterator & operator += (intptr_t iInc); + iterator operator + (intptr_t iInc) const; + iterator & operator -= (intptr_t iDec); + intptr_t operator - (const iterator &iter) const; + iterator operator - (intptr_t iDec) const; + gcstring & operator [] (intptr_t iIndex) const; + GCBASE_API + friend iterator operator + (intptr_t iInc, const iterator &iter); + }; + + // Ctor / Dtor + // --------------------------------------------------------------------------- + public: + gcstring_vector(void); + explicit gcstring_vector(size_t uiSize, const gcstring &str = gcstring()); + gcstring_vector(const gcstring_vector &obj); + virtual ~gcstring_vector(void); + + // Element access + // --------------------------------------------------------------------------- + public: + virtual void assign(size_t n, const gcstring &val); + virtual void clear(void); + virtual iterator erase(iterator pos); + virtual gcstring & at(size_t uiIndex); + virtual const gcstring & at(size_t uiIndex) const; + virtual gcstring & back(void); + virtual const gcstring & back(void) const; + virtual iterator begin(void); + virtual const_iterator begin(void) const; + virtual size_t capacity(void) const; + virtual iterator end(void); + virtual const_iterator end(void) const; + virtual gcstring & front(void); + virtual const gcstring & front(void) const; + virtual size_t max_size(void) const; + virtual size_t size(void) const; + virtual iterator insert(iterator pos, const gcstring &str); + virtual bool empty(void) const; + virtual void pop_back(void); + virtual void push_back(const gcstring &str); + virtual void resize(size_t uiSize, const gcstring &str = gcstring()); + virtual void reserve(size_t uiSize); + virtual bool contains(const gcstring &str) const; + + // Do not use the methods below - they only exist for + // backwards compatibility + virtual gcstring_vector & assign(const gcstring_vector &obj); + virtual void erase(size_t uiIndex); + virtual void insert(size_t uiIndex, const gcstring &str); + + + // Operators + // --------------------------------------------------------------------------- + public: + gcstring_vector & operator = (const gcstring_vector &obj); + gcstring & operator [] (size_t uiIndex); + const gcstring & operator [] (size_t uiIndex) const; + void operator delete (void *pWhere); + void * operator new (size_t uiSize); + + // Member + // --------------------------------------------------------------------------- + private: + void * _pv; + }; + +} + + + +#else +# error No known support for shared libraries +#endif + +#pragma pack(pop) + +#endif // GENICAM_GCSTRINGLIST_H diff --git a/Cigarette/Pylon6.2/include/Base/GCSynch.h b/Cigarette/Pylon6.2/include/Base/GCSynch.h new file mode 100644 index 0000000..548044d --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCSynch.h @@ -0,0 +1,324 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Hartmut Nebelung +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of Lock classes +\ingroup Base_PublicUtilities +*/ + +#ifndef GENAPI_GCSYNCH_H +#define GENAPI_GCSYNCH_H + +#include +#include + +#if defined (_WIN32) +# include +# include +#elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) +# include +# include +# include +# include +#elif defined(VXWORKS) + #include + #include +#else +# error No/unknown platform thread support +#endif + +namespace GENICAM_NAMESPACE +{ + + //----------------------------------------------------------------- + // CLock + //----------------------------------------------------------------- + + /** + \brief A lock class + \ingroup Base_PublicUtilities + */ + class GCBASE_API CLock + { + public: + //! Constructor + CLock(); + + //! Destructor + ~CLock(); + + //! tries to enter the critical section; returns true if successful + bool TryLock(); + + //! enters the critical section (may block) + void Lock(); + + //! leaves the critical section + void Unlock(); + + private: + //! no copy constructor + CLock( const CLock& ); + + //! no assignment operator + CLock& operator=( const CLock& ); + + protected: + +#if defined (_WIN32) + //! The critical section object + CRITICAL_SECTION m_csObject; +#elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) + //! the mutex object + pthread_mutex_t m_mtxObject; +#elif defined(VXWORKS) + SEM_ID m_sem; +#else +# error No/unknown platform thread support +#endif + + }; + + + //! This class is for testing purposes only. It should not be used for + //! client code because it exists only for Windows but not for Linux + //! since it uses internal data structures of a Win32 object + class GCBASE_API CLockEx : public CLock + { + public: + +# if defined (_WIN32) + + //! Gives access to internal data member for test and purposes + int64_t GetLockCount(); + + //! Gives access to internal data member for test and purposes + int64_t GetRecursionCount(); + +# elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__) || defined(VXWORKS)) + // nothing implemented for Unix +# else +# error No/unknown platform support +# endif + + private: + //! no copy constructor + CLockEx( const CLockEx& ); + + //! no assignment operator + CLockEx& operator=( const CLockEx& ); + + }; + + + //----------------------------------------------------------------- + // AutoLock + //----------------------------------------------------------------- + class AutoLock + { + CLock& m_Lock; + public: + AutoLock(CLock& lock) + : m_Lock(lock) + { + m_Lock.Lock(); + } + + ~AutoLock() + { + m_Lock.Unlock(); + } + + private: + AutoLock& operator=(const AutoLock&); + AutoLock(const AutoLock&); + }; + + + //----------------------------------------------------------------- + // template LockableObject + //----------------------------------------------------------------- + + /** + \brief Instance-Lock for an object + \ingroup Base_PublicUtilities + */ + template< class Object> + class LockableObject + { + public: + mutable CLock m_Lock; + + class Lock; + friend class Lock; + + /*! A scopelevel Lock class. + * Automatically acquires the lock when created and releases + * it when destroyed. + */ + class Lock + { + /// Reference to outer object + const LockableObject &m_Object; + public: + Lock( const LockableObject& obj) : m_Object(obj) { + m_Object.m_Lock.Lock(); + } + + ~Lock(){ + m_Object.m_Lock.Unlock(); + } + private: + Lock& operator=( const Lock& ); + }; + + /// Get a new lock + Lock GetLock() const + { + return Lock( *this ); + } + }; + + + /** + \brief Named global lock which can be used over process boundaries + \ingroup Base_PublicUtilities + */ + class GCBASE_API CGlobalLock + { + public: + //! Creates a global lock object name pszName. + //! In case an object with the same name already exists + //! a reference to the existing object will be created. + //! If pszName is NULL an unnamed object will be created. + explicit CGlobalLock(const char* pszName); +#if defined(_WIN32) && ! defined(PHARLAP_WIN32) + //! Creates a global lock object name pszName. + //! In case an object with the same name already exists + //! a reference to the existing object will be created. + //! If pszName is NULL an unnamed object will be created. + explicit CGlobalLock(const wchar_t* pszName); +#endif + //! Creates a global lock object name strName. + //! In case an object with the same name already exists + //! a reference to the existing object will be created. + //! If strName is empty an unnamed object will be created. + explicit CGlobalLock(const GENICAM_NAMESPACE::gcstring& strName); + + ~CGlobalLock(); + + public: + //! tests whether the lock is valid + bool IsValid(void) const; + + //! enters the lock (may block) + bool Lock(unsigned int timeout_ms); + + //! tries to enter the lock and returns immediately when not possible + bool TryLock(void); + + //! leaves the lock + void Unlock(void); + +#if defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) + // creates a hashed name instead of the real name + void HashSemName(const GENICAM_NAMESPACE::gcstring& strName); +#endif + + protected: +#if defined(_WIN32) + HANDLE m_handle; +#elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) + GENICAM_NAMESPACE::gcstring m_semName; + sem_t* m_handle; +#elif VXWORKS + // There are no named locks on VxWorks. While we could use a single global lock, we + // will just rely on the caller to add their own locking in +#else +# error No/unknown platform thread support +#endif + + // This is for debugging/assertions only + // the d'tor check whether this is 0 in debug builds + // in release builds this is always 0 + mutable long m_DebugCount; + + private: + // not copyable + CGlobalLock(const CGlobalLock&); + CGlobalLock& operator=(const CGlobalLock&); + }; + + + /** + \brief unlocks the global lock object on destruction + + This is for automatic UNLOCKING only. + We can't do automatic locking here since there is no returnvalue for contructors + + \ingroup Base_PublicUtilities + */ + //----------------------------------------------------------------- + // unlocks the global lock object on destruction + // this is for automatic UNLOCKING only. + // we can't do automatic locking here since we don't get a returnvalue from the c'tor + //----------------------------------------------------------------- + class GCBASE_API CGlobalLockUnlocker + { + protected: + CGlobalLock& m_Lock; + bool m_enabled; + + public: + CGlobalLockUnlocker(CGlobalLock& lock) + : m_Lock(lock) + , m_enabled(true) // this allows the auto unlock to be turned off for messy code structures + { + // explicitly don't lock the object here since we want to do this manually and handle the return value properly + } + + ~CGlobalLockUnlocker() + { + UnlockEarly(); + } + + //! This function allows to unlock the object early before the object is destroyed + void UnlockEarly(void) + { + if (m_enabled) + { + m_enabled = false; + m_Lock.Unlock(); + } + } + + private: + CGlobalLockUnlocker& operator=(const CGlobalLockUnlocker&); + CGlobalLockUnlocker(const CGlobalLockUnlocker&); + }; + +} // namespace GenICam + +#endif // GENAPI_GCSYNCH_H diff --git a/Cigarette/Pylon6.2/include/Base/GCTypes.h b/Cigarette/Pylon6.2/include/Base/GCTypes.h new file mode 100644 index 0000000..1e74162 --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCTypes.h @@ -0,0 +1,287 @@ +/**************************************************************************** +(c) 2004 by Basler Vision Technologies +(c) 2005 STEMMER IMAGING + +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. + + +****************************************************************************/ + +/// \file +/// \brief Platform-dependent type definitions +/// \ingroup Base_PublicUtilities + + +#ifndef GENICAM_TYPES_H +#define GENICAM_TYPES_H + +#include + +// Make sure WIN32 is defined if the toolchain does not already do it. +#if defined (_WIN32) && !defined(WIN32) +# define WIN32 +#endif + +#if !defined (_WIN32) + +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS +# endif + +# ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +# endif + +# include +#ifndef VXWORKS +# include +#endif +# include + +#elif defined (_WIN32) + +//! \addtogroup Base_PublicUtilities +//! \{ + +// tag to perform 64 compatibility warnings checks on a type +# if !defined(GC_W64) +# if defined(_M_IX86) && _MSC_VER >= 1300 +# define GC_W64 __w64 +# else +# define GC_W64 +# endif +# endif + +# if defined(_MSC_VER) && _MSC_VER >= 1600 + // VS2010 provides stdint.h +# include +# else +# ifndef _STDINT // only define if not already done + + //! makes int 8 portable across different platforms + typedef char int8_t; + //! makes unsigned char portable across different platforms + typedef unsigned char uint8_t; + + //! makes short portable across different platforms + typedef short int16_t; + //! makes unsigned short portable across different platforms + typedef unsigned short uint16_t; + + //! makes __int32 portable across different platforms + typedef __int32 int32_t; + //! makes unsigned int32 portable across different platforms + typedef unsigned __int32 uint32_t; + + //! makes int64 portable across different platforms + typedef __int64 int64_t; + //! makes unsigned int64 portable across different platforms + typedef unsigned __int64 uint64_t; + +# endif // _STDINT +# endif // _MSC_VER >= 1600 + + // Deprecated, use int8_t instead + // typedef char char8_t; + + // Deprecated, use uint8_t instead + // typedef unsigned char uchar8_t; + + //! use a universal platform dependent int + typedef __int64 int_t; + //! use a universal platform dependent unsigned int + typedef unsigned __int64 uint_t; + +# ifndef _SIZE_T_DEFINED +# ifdef _WIN64 + //! use a universal platform dependent unsigned int + typedef unsigned __int64 size_t; +# else + //! use a universal platform dependent unsigned int + typedef GC_W64 unsigned int size_t; +# endif +# define _SIZE_T_DEFINED +# endif + +# ifndef _INTPTR_T_DEFINED +# ifdef _WIN64 + //! use a universal platform dependent intptr_t + typedef __int64 intptr_t; +# else + //! use a universal platform dependent intptr_t + typedef GC_W64 int intptr_t; +# endif +# define _INTPTR_T_DEFINED +# endif + +# ifndef _UINTPTR_T_DEFINED +# ifdef _WIN64 + //! use a universal platform dependent uintptr_t + typedef unsigned __int64 uintptr_t; +# else + //! use a universal platform dependent intptr_t + typedef GC_W64 unsigned int uintptr_t; +# endif +# define _UINTPTR_T_DEFINED +# endif + +#else +# error No platform-specific type definitions +#endif /* __unix__ */ + +// \} + + +#ifndef GC_INT64_MAX +#ifdef INT64_MAX +# define GC_INT64_MAX INT64_MAX +#else +# define GC_INT64_MAX static_cast(0x7fffffffffffffffLL) /* maximum signed int64 value */ +#endif +#endif // GC_INT64_MAX + +#ifndef GC_INT64_MIN +#ifdef INT64_MIN +# define GC_INT64_MIN INT64_MIN +#else +# define GC_INT64_MIN static_cast(0x8000000000000000LL) /* minimum signed int64 value */ +#endif +#endif // GC_INT64_MIN + +#ifndef GC_UINT64_MAX +#ifdef UINT64_MAX +# define GC_UINT64_MAX UINT64_MAX +#else +# define GC_UINT64_MAX static_cast(0xffffffffffffffffULL) /* maximum unsigned int64 value */ +#endif +#endif // GC_UINT64_MAX + +#ifndef GC_INT32_MAX +#ifdef INT32_MAX +# define GC_INT32_MAX INT32_MAX +#else +# define GC_INT32_MAX static_cast(0x000000007fffffffLL) /* maximum signed int32 value */ +#endif +#endif // GC_INT32_MAX + +#ifndef GC_INT32_MIN +#ifdef INT32_MIN +# define GC_INT32_MIN INT32_MIN +#else +# define GC_INT32_MIN static_cast(0xffffffff80000000LL) /* minimum signed int32 value */ +#endif +#endif // GC_INT32_MIN + +#ifndef GC_UINT32_MAX +#ifdef UINT32_MAX +# define GC_UINT32_MAX UINT32_MAX +#else +# define GC_UINT32_MAX static_cast(0x00000000ffffffffULL) /* maximum unsigned int32 value */ +#endif +#endif // GC_UINT32_MAX + +#ifndef GC_INT8_MAX +#ifdef INT8_MAX +# define GC_INT8_MAX INT8_MAX +#else +# define GC_INT8_MAX static_cast(0x000000000000007fLL) /* maximum signed int8 value */ +#endif +#endif // GC_INT8_MAX + +#ifndef GC_INT8_MIN +#ifdef INT8_MIN +# define GC_INT8_MIN INT8_MIN +#else +# define GC_INT8_MIN static_cast(0xffffffffffffff80LL) /* minimum signed int8 value */ +#endif +#endif // GC_INT8_MIN + +#ifndef GC_UINT8_MAX +#ifdef UINT8_MAX +# define GC_UINT8_MAX UINT8_MAX +#else +# define GC_UINT8_MAX static_cast(0x00000000000000ffULL) /* maximum unsigned int8 value */ +#endif +#endif // GC_UINT8_MAX + +//! \addtogroup Base_PublicUtilities +//! \{ + +// Utility Types + +// Deprecated, use const uint8_t* instead +// typedef const char * pcchar8_t; + +// Deprecated, use uint8_t* instead +// typedef char * pchar8_t; + +//! 32 bit floating point +typedef float float32_t; + +//! 64 bit floating point +typedef double float64_t; + +//! \} + +// gc base import/export +#if defined(_MSC_VER) +# ifdef GCBASE_EXPORTS +# define GCBASE_API __declspec( dllexport ) +# define GCBASE_RTTI_CLASS_API __declspec( dllexport ) +# else +# define GCBASE_API __declspec( dllimport ) +# define GCBASE_RTTI_CLASS_API __declspec( dllimport ) +# endif +#elif defined (__GNUC__) +# ifdef GCBASE_EXPORTS +# define GCBASE_API __attribute__((visibility("default"))) +# define GCBASE_RTTI_CLASS_API __attribute__((visibility("default"))) +# else +# define GCBASE_API + // Classes that need RTTI info across library boundaries (like Exception classes) + // need to always use default visibility, even when symbols are being imported. +# define GCBASE_RTTI_CLASS_API __attribute__((visibility("default"))) +# endif +#else +# error Unsupported compiler or platform +#endif + +namespace GENICAM_NAMESPACE +{ + //! version + struct GCBASE_API Version_t + { + uint16_t Major; //!> a is incompatible with b if a != b + uint16_t Minor; //!> a is incompatible b a > b + uint16_t SubMinor; //!> a is aways compatible with b + }; +} + +using GENICAM_NAMESPACE::Version_t; + +// mark a variable as unused. This prevents unused parameter/ unused local variable warnings on warning level 4. +#if defined(_MSC_VER) +# define GC_UNUSED(unused_var) (void)(unused_var) +#elif defined(__GNUC__) +# define GC_UNUSED(unused_var) // no changes to unused params with GCC +#else +# error Unsupported compiler or platform +#endif + + +#endif // GENICAM_TYPES_H diff --git a/Cigarette/Pylon6.2/include/Base/GCUtilities.h b/Cigarette/Pylon6.2/include/Base/GCUtilities.h new file mode 100644 index 0000000..01982a1 --- /dev/null +++ b/Cigarette/Pylon6.2/include/Base/GCUtilities.h @@ -0,0 +1,230 @@ +//----------------------------------------------------------------------------- +// (c) 2005 by Basler Vision Technologies +// Section: Vision Components +// Project: GenICam +// Author: Fritz Dierks +// $Header$ +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief GenICam common utilities +\ingroup Base_PublicUtilities +*/ + +#ifndef GENAPI_GENAPIUTILITIES_DEF_H_ +#define GENAPI_GENAPIUTILITIES_DEF_H_ + +#if defined (_WIN32) +# include +#endif + +#include + +#include +#include +#include +#include +#include + +#if defined(UNDER_RTSS) +#include +#endif // defined(UNDER_RTSS) + +#if defined(UNDER_RTSS) +#define USE_TEMP_CACHE_FILE 0 +#else +#define USE_TEMP_CACHE_FILE 1 +#endif // defined(UNDER_RTSS) + +#if defined(UNDER_RTSS) +#define USE_TEMP_CACHE_FILE 0 +#else +#define USE_TEMP_CACHE_FILE 1 +#endif // defined(UNDER_RTSS) + +#if defined (_MSC_VER) +# if defined (_WIN64) +# define PLATFORM_NAME "Win64_x64" +# else +# define PLATFORM_NAME "Win32_i86" +# endif +#elif defined (__GNUC__) +# define GENICAM_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# if defined (__LP64__) +# if defined (__linux__) +# define PLATFORM_NAME "Linux64_x64" +# elif defined (__APPLE__) +# define PLATFORM_NAME "Maci64_x64" +# else +# error Unknown Platform +# endif +# else +# if defined (__linux__) +# define PLATFORM_NAME "Linux32_i86" +# elif defined (__APPLE__) +# error Unsupported Platform +# elif defined (VXWORKS) +# define PLATFORM_NAME "VxWorks_PPC" +# else +# error Unknown Platform +# endif +# endif +#else +# error Unknown Platform +#endif + +#ifndef GC_COUNTOF +# define GC_COUNTOF(arr) (sizeof (arr) / sizeof (arr)[0] ) +#endif + +namespace GENICAM_NAMESPACE +{ + //! This verifies at runtime if there was no loss of data if an type Ts (e.g. int64t) was downcast + //! to type Td (e.g. int32_t) + template + inline Td INTEGRAL_CAST2( Ts s ) + { + const Td d = static_cast( s ); + if ( static_cast( d ) != s ){ + throw RUNTIME_EXCEPTION("INTEGRAL_CAST failed"); + } + return d; + } + + //! This verifies at runtime if there was no loss of data if an int64_t was downcast + //! to type T (e.g. int32_t) + template + inline T INTEGRAL_CAST( int64_t ll ) + { + return INTEGRAL_CAST2( ll ); + } + + //! Returns true if an environment variable exists + GCBASE_API bool DoesEnvironmentVariableExist( const gcstring &VariableName ); + + //! Retrieve the value of an environment variable + //! \throw runtime_exception if not found + GCBASE_API gcstring GetValueOfEnvironmentVariable( const gcstring &VariableName ); + + //! Retrieve the value of an environment variable + //! \return true if environment variable was found, otherwise false + GCBASE_API bool GetValueOfEnvironmentVariable(const gcstring &VariableName, gcstring &VariableContent ); + +#if defined(UNDER_RTSS) + //! Returns true if a file exists + GCBASE_API bool DoesFileExist( const gcstring &FilePath ); +#endif // defined(UNDER_RTSS) + + //! Converts \ to / and replaces all unsafe characters by their %xx equivalent + //! \ingroup Base_PublicUtilities + GCBASE_API gcstring UrlEncode(const GENICAM_NAMESPACE::gcstring& Input); + + //! Replaces %xx escapes by their char equivalent + //! \ingroup Base_PublicUtilities + GCBASE_API GENICAM_NAMESPACE::gcstring UrlDecode(const GENICAM_NAMESPACE::gcstring& Input); + + //! Replaces $(ENVIRONMENT_VARIABLES) in a string and replace ' ' with %20 + //! \ingroup Base_PublicUtilities + GCBASE_API void ReplaceEnvironmentVariables(gcstring &Buffer, bool ReplaceBlankBy20 = false); + + + //! Retrieve the path of the GenICam cache folder + /*! The path to the cache folder can be stored by calling SetGenICamCacheFolder(). + If GetGenICamCacheFolder() is called before SetGenICamCacheFolder(), it will return + the value of environment variable GENICAM_CACHE_Vx_y. If this environment variable does + not exist, an exception will be thrown. + */ + GCBASE_API gcstring GetGenICamCacheFolder(void); + + //! Retrieve the path of the GenICam logging properties file + /*! The path to the logging properties file can be stored by calling SetGenICamLogConfig(). + If GetGenICamLogConfig() is called before SetGenICamLogConfig(), it will return + the value of environment variable GENICAM_LOG_CONFIG_Vx_y. If this environment variable does + not exist, an exception will be thrown. + */ + GCBASE_API gcstring GetGenICamLogConfig(void); + + //! Retrieve the path of the CLProtocol folder + /*! The path to the CLProtocol folder can be stored by calling SetGenICamCLProtocolFolder(). + If GetGenICamCLProtocolFolder() is called before SetGenICamCLProtocolFolder(), it will return + the value of environment variable GENICAM_CLPROTOCOL. If this environment variable does + not exist, an exception will be thrown. + */ + GCBASE_API gcstring GetGenICamCLProtocolFolder(void); + + //! Stores the path of the GenICam cache folder + GCBASE_API void SetGenICamCacheFolder(const gcstring& path); + + //! Stores the path of the GenICam logging properties file + GCBASE_API void SetGenICamLogConfig(const gcstring& path); + + //! Stores the path of the CLProtocol folder + GCBASE_API void SetGenICamCLProtocolFolder(const gcstring& path); + + //! splits str input string into a list of tokens using the delimiter + GCBASE_API void Tokenize( + const gcstring& str, //!< string to be split + gcstring_vector& tokens, //!< result of the splitting operation + const gcstring& delimiters = " " //!< delimiters for the splitting + ); + + //! Gets a list of files or directories matching a given FileTemplate + GCBASE_API void GetFiles( + const gcstring &FileTemplate, //!> The file template. Can contain environment variables. + gcstring_vector &FileNames, //!> A list of files matching the file template + const bool DirectoriesOnly = false ); //!> true = only subdirectories (ex . and ..) are retrieved; false = only files are retrieved + + //! Gets the full path to the module (DLL/SO) containing the given \a pFunction; empty string if not found. + GCBASE_API gcstring GetModulePathFromFunction(void *pFunction); +} + +#define GENICAM_UNUSED(unused_var) ((void)(unused_var)) + +#if !defined(GENICAM_DEPRECATED) +# if defined(__GNUC__) && (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 1) // is at least GCC 3.1 compiler? +# define GENICAM_DEPRECATED(FUNCTION) FUNCTION __attribute__ ((deprecated)) +# elif defined(_MSC_VER) && (_MSC_VER >= 1300) // is at least VC 2003 compiler? +# define GENICAM_DEPRECATED(FUNCTION) __declspec(deprecated) FUNCTION +# else +# define GENICAM_DEPRECATED(FUNCTION) FUNCTION +# endif // compiler check +#endif // #if !defined(GENICAM_DEPRECATED) + + +/////////////////////////////////////////////////////////////////////////////// +// +// Useful to create pragma message output recognized by VisualStudio +// +// Usage: +// #pragma message ( __ERR__ "Invalid DLL ABI" ) +// +/////////////////////////////////////////////////////////////////////////////// +// Message formatter +#define _TO_STRING( __stN ) #__stN +#define EXPAND_TO_STRINGISE( __stN ) _TO_STRING( __stN ) +#define __LINE_STR__ EXPAND_TO_STRINGISE(__LINE__) +#define __LOCATION__ __FILE__ "(" __LINE_STR__ ")" +#define __OUTPUT_FORMATER__(_type) __LOCATION__ " : " _type " : " + +// Message types +#define __WARN__ __OUTPUT_FORMATER__("WARNING") +#define __ERR__ __OUTPUT_FORMATER__("ERROR") +#define __TODO__ __OUTPUT_FORMATER__("TBD") + +#endif // GENAPI_GENAPIUTILITIES_DEF_H_ diff --git a/Cigarette/Pylon6.2/include/GenApi/Autovector.h b/Cigarette/Pylon6.2/include/GenApi/Autovector.h new file mode 100644 index 0000000..c658903 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Autovector.h @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// (c) 2012 by Teledyne DALSA +// Section: Digital Imaging +// Project: GenAPI +// Author: Eric Bourbonnais +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +// +/*! +\file +\brief This file contains the public definition of the autovector classes. +\ingroup GenApi_PublicInterface +*/ + +////////////////////////////////////////////////////////////////////////////// + +#ifndef GENAPI_AUTOVECTOR_H +#define GENAPI_AUTOVECTOR_H + +#include +#include +#include + +#if defined (_WIN32) + typedef long ATOMIC_VARIABLE; +#elif (defined(__GNUC__) && (defined (__linux__)) || defined (__APPLE__)) || defined(VXWORKS) + typedef uint32_t ATOMIC_VARIABLE; +#else +# error Unsupported platform +#endif + +namespace GENAPI_NAMESPACE +{ + /** + \brief Vector of integers with reference counting + \ingroup GenApi_PublicInterface + */ + class GENAPI_DECL int64_autovector_t + { + public: + explicit int64_autovector_t(); + int64_autovector_t( const int64_autovector_t& obj ); + explicit int64_autovector_t( size_t n ); + virtual ~int64_autovector_t( void ); + + int64_autovector_t& operator=( const int64_autovector_t& obj ); + + int64_t& operator[]( size_t uiIndex ); + const int64_t& operator[]( size_t uiIndex ) const; + size_t size( void ) const; + protected: + std::vector* _pv; + ATOMIC_VARIABLE* _pCount; + }; + + /** + \brief Vector of doubles with reference counting + \ingroup GenApi_PublicInterface + */ + class GENAPI_DECL double_autovector_t + { + public: + explicit double_autovector_t(); + double_autovector_t( const double_autovector_t& obj ); + explicit double_autovector_t( size_t n ); + virtual ~double_autovector_t( void ); + + double_autovector_t& operator=( const double_autovector_t& obj ); + + double& operator[]( size_t uiIndex ); + const double& operator[]( size_t uiIndex ) const; + size_t size( void )const; + protected: + std::vector* _pv; + ATOMIC_VARIABLE* _pCount; + }; +} + +#endif // GENAPI_AUTOVECTOR_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ChunkAdapter.h b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapter.h new file mode 100644 index 0000000..5ab7341 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapter.h @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CChunkAdapter class. +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_CHUNKADAPTER_H +#define GENAPI_CHUNKADAPTER_H + +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + + //! Delivers information about the attached chunks and nodes + //! \ingroup GenApi_PublicUtilities + typedef struct AttachStatistics_t + { + int NumChunkPorts; //!< Number of chunk ports found in the node map + int NumChunks; //!< Number of chunks found in the buffer + int NumAttachedChunks; //!< Number of chunks from the buffer attached to a chunk port + } AttachStatistics_t; + + + /** + \brief Connects a chunked buffer to a node map + \ingroup GenApi_PublicUtilities + */ + class GENAPI_DECL CChunkAdapter + { + + public: + //! Destructor + virtual ~CChunkAdapter(); + + //! Attaches to a node map and retrieves the chunk ports + void AttachNodeMap(INodeMap* pNodeMap); + + //! Detaches from the node map + void DetachNodeMap(); + + //! Checks if a buffer contains chunks in a known format + /*! Implement that for a specific buffer layout */ + virtual bool CheckBufferLayout(uint8_t *pBuffer, int64_t BufferLength) = 0; + + //! Attaches a buffer to the matching ChunkPort + /*! Implement that for a specific buffer layout */ + virtual void AttachBuffer(uint8_t *pBuffer, int64_t BufferLength, AttachStatistics_t *pAttachStatistics = NULL) = 0; + + //! Detaches a buffer + void DetachBuffer(); + + //! Updates the base address of the buffer + void UpdateBuffer(uint8_t *pBaseAddress); + + //! Clears the chunk caches + void ClearCaches(); + + protected: + + //! Serves as default constructor + CChunkAdapter(INodeMap* pNodeMap = NULL, int64_t MaxChunkCacheSize = -1); + + //! An array of attached ChunkPorts + /*! Note that this must be a pointer otherwise we'll get into DLL hell (see warning C4251) */ + std::vector *m_ppChunkPorts; + + //! the maximum size of a chunk to be cached + /*! 0 : no caching, -1 : all caching */ + int64_t m_MaxChunkCacheSize; + + }; + +} + +#endif // GENAPI_CHUNKADAPTER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterDcam.h b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterDcam.h new file mode 100644 index 0000000..cb640e5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterDcam.h @@ -0,0 +1,96 @@ +//----------------------------------------------------------------------------- +// (c) 2004 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CChunkAdapterDcam class. +*/ + +#ifndef GENAPI_CHUNKADAPTERDCAM_H +#define GENAPI_CHUNKADAPTERDCAM_H + +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + void GENAPI_DECL SET_GUID(GUID& name, uint32_t l, uint16_t w1, uint16_t w2, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7, uint8_t b8); + + + // make sure everything is properly packed +# pragma pack(push, 1) + + typedef struct DCAM_CHUNK_TRAILER + { + GUID ChunkID ; + uint32_t ChunkLength ; + uint32_t InverseChunkLength ; + } DCAM_CHUNK_TRAILER; + + typedef struct DCAM_CHECKSUM + { + uint32_t CRCChecksum ; + } DCAM_CHECKSUM; + + // restore the previous packing +# pragma pack(pop) + /* ------------------------------------------- */ + + //! Connects a chunked DCAM buffer to a node map + class GENAPI_DECL CChunkAdapterDcam : public CChunkAdapter + { + + public: + //! Constructor + CChunkAdapterDcam(INodeMap* pNodeMap = NULL, int64_t MaxChunkCacheSize = -1); + + //! Destructor + virtual ~CChunkAdapterDcam(); + + //! Checks if a buffer contains chunks in a known format + virtual bool CheckBufferLayout(uint8_t *pBuffer, int64_t BufferLength); + + //! Attaches a buffer to the matching ChunkPort + virtual void AttachBuffer(uint8_t *pBuffer, int64_t BufferLength, AttachStatistics_t *pAttachStatistics = NULL); + + //! Checks if buffer has a CRC attached + bool HasCRC(uint8_t *pBuffer, int64_t BufferLength); + + //! Checks CRC sum of buffer + bool CheckCRC(uint8_t *pBuffer, int64_t BufferLength); + + protected: + //! Checks the CRC of a buffer + uint32_t CRC16(const unsigned char *pData, uint32_t nbyLength ); + + //! Checks the CRC of a buffer + bool CheckBuffer(const unsigned char* pData, uint32_t nbyLength ); + + }; + +} + +#endif // GENAPI_CHUNKADAPTERDCAM_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterGEV.h b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterGEV.h new file mode 100644 index 0000000..1c605db --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterGEV.h @@ -0,0 +1,77 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CChunkAdapterGEV class. +*/ + +#ifndef GENAPI_CHUNKADAPTERGEV_H +#define GENAPI_CHUNKADAPTERGEV_H + +#include + +namespace GENAPI_NAMESPACE +{ + + /* ------------------------------------------- */ + // Declartion of GigE Vision Chunk message trailer + + // make sure everything is properly packed +# pragma pack(push, 1) + + //! header of a GVCP request packet + typedef struct GVCP_CHUNK_TRAILER + { + uint32_t ChunkID; + uint32_t ChunkLength; + } GVCP_CHUNK_TRAILER; + + // restore the previous packing +# pragma pack(pop) + /* ------------------------------------------- */ + + + //! Connects a chunked DCAM buffer to a node map + class GENAPI_DECL CChunkAdapterGEV : public CChunkAdapter + { + + public: + //! Constructor + CChunkAdapterGEV(INodeMap* pNodeMap = NULL, int64_t MaxChunkCacheSize = -1); + + //! Destructor + virtual ~CChunkAdapterGEV(); + + //! Checks if a buffer contains chunks in a known format + virtual bool CheckBufferLayout(uint8_t *pBuffer, int64_t BufferLength); + + //! Attaches a buffer to the matching ChunkPort + virtual void AttachBuffer(uint8_t *pBuffer, int64_t BufferLength, AttachStatistics_t *pAttachStatistics = NULL); + + }; + +} + +#endif // GENAPI_CHUNKADAPTERGEV_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterGeneric.h b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterGeneric.h new file mode 100644 index 0000000..1883fbf --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterGeneric.h @@ -0,0 +1,87 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Leutron Vision +// Project: GenApi +// Author: Jan Becvar +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CChunkAdapterGeneric class. +*/ + +#ifndef GENAPI_CHUNKADAPTERGENERIC_H +#define GENAPI_CHUNKADAPTERGENERIC_H + +#include + +namespace GENAPI_NAMESPACE +{ + /* ------------------------------------------- */ + // Single chunk info + + // make sure everything is properly packed + #pragma pack(push, 1) + + typedef struct SingleChunkData_t + { + uint64_t ChunkID; + ptrdiff_t ChunkOffset; + size_t ChunkLength; + } SingleChunkData_t; + + // the extended version holding ChunkID as string should be used only in special cases + // when the ChunkID does not fit into a 64-bit integer + typedef struct SingleChunkDataStr_t + { + GENICAM_NAMESPACE::gcstring ChunkID; + ptrdiff_t ChunkOffset; + size_t ChunkLength; + } SingleChunkDataStr_t; + + // restore the previous packing + #pragma pack(pop) + /* ------------------------------------------- */ + + + //! Connects a generic chunked buffer to a node map + class GENAPI_DECL CChunkAdapterGeneric : public CChunkAdapter + { + + public: + //! Constructor + CChunkAdapterGeneric(INodeMap* pNodeMap = NULL, int64_t MaxChunkCacheSize = -1); + + //! Destructor + virtual ~CChunkAdapterGeneric(); + + // Does not have implementation, use the version with EventID + virtual bool CheckBufferLayout(uint8_t *pBuffer, int64_t BufferLength); + + // Does not have implementation, use the generic version + virtual void AttachBuffer(uint8_t *pBuffer, int64_t BufferLength, AttachStatistics_t *pAttachStatistics = NULL); + + virtual void AttachBuffer(uint8_t *pBuffer, SingleChunkData_t *ChunkData, int64_t NumChunks, AttachStatistics_t *pAttachStatistics = NULL); + + virtual void AttachBuffer(uint8_t *pBuffer, SingleChunkDataStr_t *ChunkData, int64_t NumChunks, AttachStatistics_t *pAttachStatistics = NULL); + }; + +} + +#endif // GENAPI_CHUNKADAPTERGENERIC_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterU3V.h b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterU3V.h new file mode 100644 index 0000000..f0180d5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ChunkAdapterU3V.h @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// (c) 2013 by Groget +// Project: GenApi +// Author: Jan Becvar +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CChunkAdapterU3V class. +*/ + +#ifndef GENAPI_CHUNKADAPTERU3V_H +#define GENAPI_CHUNKADAPTERU3V_H + +#include + +namespace GENAPI_NAMESPACE +{ + + /* ------------------------------------------- */ + // Declartion of USB3 Vision Chunk trailer + + // make sure everything is properly packed +# pragma pack(push, 1) + + //! header of a GVCP request packet + typedef struct U3V_CHUNK_TRAILER + { + uint32_t ChunkID; + uint32_t ChunkLength; + } U3V_CHUNK_TRAILER; + + // restore the previous packing +# pragma pack(pop) + /* ------------------------------------------- */ + + + //! Connects a chunked U3V buffer to a node map + class GENAPI_DECL CChunkAdapterU3V : public CChunkAdapter + { + + public: + //! Constructor + CChunkAdapterU3V(INodeMap* pNodeMap = NULL, int64_t MaxChunkCacheSize = -1); + + //! Destructor + virtual ~CChunkAdapterU3V(); + + //! Checks if a buffer contains chunks in a known format + virtual bool CheckBufferLayout(uint8_t *pBuffer, int64_t BufferLength); + + //! Attaches a buffer to the matching ChunkPort + virtual void AttachBuffer(uint8_t *pBuffer, int64_t BufferLength, AttachStatistics_t *pAttachStatistics = NULL); + + }; + +} + +#endif // GENAPI_CHUNKADAPTERU3V_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ChunkPort.h b/Cigarette/Pylon6.2/include/GenApi/ChunkPort.h new file mode 100644 index 0000000..201c7b0 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ChunkPort.h @@ -0,0 +1,180 @@ +//----------------------------------------------------------------------------- +// (c) 2006-8 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CChunkPort class. +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_CHUNKPORT_H +#define GENAPI_CHUNKPORT_H + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) // GenApi::CChunkPort::m_ptrPort' : class 'GenApi::CPointer' needs to have dll-interface +#endif + +namespace GENAPI_NAMESPACE +{ + + /** + \brief Port attachable to a chunk in a buffer + \ingroup GenApi_PublicUtilities + */ + class GENAPI_DECL CChunkPort : public IPortConstruct + { + + public: + + //! Constructor; can attach to a port + CChunkPort(IPort* pPort = NULL); + + //! Destructor; detaches from the port + virtual ~CChunkPort(); + + //------------------------------------------------------------- + // IPortConstruct implementation + //------------------------------------------------------------- + + //! Get the access mode of the node + virtual EAccessMode GetAccessMode() const; + + //! Get the type of the main interface of a node + virtual EInterfaceType GetPrincipalInterfaceType() const; + + //! Reads a chunk of bytes from the port + virtual void Read(void *pBuffer, int64_t Address, int64_t Length); + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length); + + //! Called from the port node to give the chunk port a pointer to itself + virtual void SetPortImpl(GENAPI_NAMESPACE::IPort* pPort); + + //! Determines if the port adapter must perform an endianess swap + virtual EYesNo GetSwapEndianess() + { + return No; + } + + //--------------------------------------------------------------- + // Implementation + //--------------------------------------------------------------- + + // Invalidates the chunk port node + void InvalidateNode(); + + //------------------------------------------------------------- + // Initializing + //------------------------------------------------------------- + + //! Attaches the ChunkPort to the Port + bool AttachPort(GENAPI_NAMESPACE::IPort* pPort); + + //! Detaches the ChunkPort to the Port + void DetachPort(); + + //! Attaches the Chunk to the ChunkPort + void AttachChunk(uint8_t *pBaseAddress, int64_t ChunkOffset, int64_t Length, bool Cache); + + //! Detaches the Chunk from the ChunkPort + void DetachChunk(); + + //! Gets the ChunkID length + int GetChunkIDLength() + { + return m_ChunkIDLength; + } + + //! Checks if a ChunkID matches + bool CheckChunkID(uint8_t* pChunkIDBuffer, int ChunkIDLength); + + //! Checks if a ChunkID matches, version using uint64_t ID representation + bool CheckChunkID(uint64_t ChunkID); + + //! Updates the base address of the chunk + void UpdateBuffer(uint8_t *pBaseAddress); + + //! Clears the chunk cache + void ClearCache(); + protected: + + CLock& GetLock() const + { + if (!m_ptrPort.IsValid()) + throw RUNTIME_EXCEPTION("The event port is not attached to a node"); + + return m_ptrPort->GetNodeMap()->GetLock(); + } + + //------------------------------------------------------------- + // Member variables + //------------------------------------------------------------- + + //! Pointer to the begin of the buffer + uint8_t *m_pBaseAddress; + + //! The chunk's offset within the buffer + int64_t m_ChunkOffset; + + //! Length of the chunk + int64_t m_Length; + + //! Space allocated for the chunk + int64_t m_LengthAlloc; + + //! Pointer to the node holding a reference to this implementation + CNodePtr m_ptrPort; + + //! Binary version of the chunk ID + uint8_t *m_pChunkIDBuffer; + + //! Length of the chunk ID buffer + int m_ChunkIDLength; + + //! cache for the chunk data + uint8_t *m_pChunkData; + + //! indicates if the data needs to be cached + bool m_CacheData; + + //! Chunk ID stored as a number (for more straightforward access) + uint64_t m_ChunkIDNumber; + + //! indicates if the m_ChunkIDNumber is valid (could be invalid eg. if the ID does not fit in 64-bit range) + bool m_ChunkIDNumberValid; + }; + +} + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif // GENAPI_CHUNKPORT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Compatibility.h b/Cigarette/Pylon6.2/include/GenApi/Compatibility.h new file mode 100644 index 0000000..5049f8c --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Compatibility.h @@ -0,0 +1,72 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! + \file + \brief Definition of macros for cross-platform compatibility + \ingroup GenApi_Implementation +*/ + +#ifndef GENAPI_COMPATIBILITY_H +#define GENAPI_COMPATIBILITY_H + +#if defined (_MSC_VER) && defined (_WIN32) + +#if ! defined(NOMINMAX) +# define NOMINMAX +#endif + +#elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__) || defined(VXWORKS)) + +# include +/* + * Watch out! + * In order not to break existing code, we have to duplicate the + * broken MS Windows GUID handling. Never mix with code using the + * rfc4122-compliant uuid framework implemented by libuuid! + */ + +typedef struct _GUID { + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[ 8 ]; +} __attribute__ ((packed)) GUID; +#else +# error Unsupported platform +#endif + + + +#if defined (__APPLE__) +# define FMT_I64 "ll" +#else +# if defined (__x86_64) // GNUC && 64 Bit +# define FMT_I64 "l" +# else // all 32 bit and all Windows +# define FMT_I64 "ll" +# endif +#endif + +#endif // ifndef GENAPI_COMPATIBILITY_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Container.h b/Cigarette/Pylon6.2/include/GenApi/Container.h new file mode 100644 index 0000000..c491efd --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Container.h @@ -0,0 +1,380 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Alex Happe +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Portable container classes for INode & IValue pointers. +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENICAM_GENAPI_NODEVECTOR_H +#define GENICAM_GENAPI_NODEVECTOR_H + + +#include +#include + +#include + +#ifndef _WIN32 +# include +#endif + +#if defined ( __GNUC__ ) && !defined (VXWORKS) && !defined ( __APPLE__ ) + using namespace __gnu_cxx; +#endif + +#if defined ( __GNUC__ ) && defined ( __linux__) +# include +#endif + +#if defined (_WIN32) || (defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__) || defined(VXWORKS))) + +// conversion from 'uintptr_t' to 'void *' of greater size +// This is a portability warning +#ifdef _MSC_VER +# pragma warning( disable : 4312 ) +#endif + +namespace GENAPI_NAMESPACE +{ + struct INode; + struct IValue; + + + //************************************************************* + // N O D E _ V E C T O R + //************************************************************* + + /** + \brief A vector of INode pointers + \ingroup GenApi_PublicImpl + */ + class GENAPI_DECL node_vector + { + typedef INode* T; + + // Nested types + // --------------------------------------------------------------------------- + public: + class GENAPI_DECL const_iterator + { + // iterator traits + // ------------------------------------------------------------------------ + public: + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + const_iterator ( T *pPtr = 0 ); + + // Operators + // ------------------------------------------------------------------------- + public: + const T & operator * ( void ) const; + const_iterator & operator ++ ( void ); + const_iterator operator ++ ( int ); + const_iterator & operator -- ( void ); + const_iterator operator -- ( int ); + const_iterator & operator += ( intptr_t iInc ); + const_iterator operator += ( intptr_t iInc ) const; + const_iterator operator + ( intptr_t iInc ) const; + const_iterator & operator -= ( intptr_t iDec ); + const_iterator operator -= ( intptr_t iDec ) const; + intptr_t operator - ( const const_iterator &iter ) const; + const_iterator operator - ( intptr_t iDec ) const; + const T & operator [] ( intptr_t iIndex ) const; + bool operator == ( const const_iterator &iter ) const; + bool operator != ( const const_iterator &iter ) const; + bool operator < ( const const_iterator &iter ) const; + bool operator > ( const const_iterator &iter ) const; + bool operator <= ( const const_iterator &iter ) const; + bool operator >= ( const const_iterator &iter ) const; + GENAPI_DECL + friend const_iterator operator + ( intptr_t iInc, const const_iterator &iter); + + // Member + // ------------------------------------------------------------------------- + protected: + T * _ps; + }; + + class GENAPI_DECL iterator : + public const_iterator + { + public: + // iterator traits + // ------------------------------------------------------------------------- + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef const_iterator::difference_type difference_type; + typedef const_iterator::pointer pointer; + typedef const_iterator::reference reference; + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + iterator ( T *pPtr = 0 ); + + // Operators + // ------------------------------------------------------------------------- + public: + T & operator * ( void ) const; + iterator & operator ++ ( void ); + iterator operator ++ ( int ); + iterator & operator -- ( void ); + iterator operator -- ( int ); + iterator & operator += ( intptr_t iInc ); + iterator operator += ( intptr_t iInc ) const; + iterator operator + ( intptr_t iInc ) const; + iterator & operator -= ( intptr_t iDec ); + iterator operator -= ( intptr_t iDec ) const; + intptr_t operator - ( const iterator &iter ) const; + iterator operator - ( intptr_t iDec ) const; + T & operator [] ( intptr_t iIndex ) const; + GENAPI_DECL + friend iterator operator + ( intptr_t iInc, const iterator &iter); + }; + + // Ctor / Dtor + // --------------------------------------------------------------------------- + public: + node_vector ( void ); + explicit node_vector ( size_t uiSize); + node_vector ( const node_vector &obj); + virtual ~node_vector ( void ); + + // Element access + // --------------------------------------------------------------------------- + public: + virtual void assign ( size_t n, const T &val ); + virtual void clear ( void ); + virtual iterator erase ( iterator pos ); + virtual T & at ( size_t uiIndex ); + virtual const T & at ( size_t uiIndex ) const; + virtual T & back ( void ); + virtual const T & back ( void ) const; + virtual iterator begin ( void ); + virtual const_iterator begin ( void ) const; + virtual size_t capacity ( void ) const; + virtual iterator end ( void ); + virtual const_iterator end ( void ) const; + virtual T & front ( void ); + virtual const T & front ( void ) const; + virtual size_t max_size ( void ) const; + virtual size_t size ( void ) const; + virtual iterator insert ( iterator pos, const T& val) ; + virtual bool empty ( void ) const; + virtual void pop_back ( void ); + virtual void push_back ( const T &val ); + virtual void resize ( size_t uiSize ); + virtual void reserve ( size_t uiSize ); + + // Do not use - only left in for backwards compatibility! + virtual void erase (size_t uiIndex); + virtual void insert (size_t uiIndex, const T &val); + +// Operators + // --------------------------------------------------------------------------- + public: + node_vector & operator = ( const node_vector &obj ); + T & operator [] ( size_t uiIndex ); + const T & operator [] ( size_t uiIndex ) const; + void operator delete ( void *pWhere ); + void * operator new ( size_t uiSize ); + + // Member + // --------------------------------------------------------------------------- + private: + typedef std::vector > vector_t; + vector_t *_pv; + }; + + + + //************************************************************* + // V A L U E _ V E C T O R + //************************************************************* + + /** + \brief A vector of IValue pointers + \ingroup GenApi_PublicImpl + */ + class GENAPI_DECL value_vector + { + typedef IValue* T; + // Nested types + // --------------------------------------------------------------------------- + public: + class GENAPI_DECL const_iterator + { + // iterator traits + // ------------------------------------------------------------------------ + public: + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; + + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + const_iterator ( T *pPtr = 0 ); + + // Operators + // ------------------------------------------------------------------------- + public: + const T & operator * ( void ) const; + const_iterator & operator ++ ( void ); + const_iterator operator ++ ( int ); + const_iterator & operator -- ( void ); + const_iterator operator -- ( int ); + const_iterator & operator += ( intptr_t iInc ); + const_iterator operator += ( intptr_t iInc ) const; + const_iterator operator + ( intptr_t iInc ) const; + const_iterator & operator -= ( intptr_t iDec ); + const_iterator operator -= ( intptr_t iDec ) const; + intptr_t operator - ( const const_iterator &iter ) const; + const_iterator operator - ( intptr_t iDec ) const; + const T & operator [] ( intptr_t iIndex ) const; + bool operator == ( const const_iterator &iter ) const; + bool operator != ( const const_iterator &iter ) const; + bool operator < ( const const_iterator &iter ) const; + bool operator > ( const const_iterator &iter ) const; + bool operator <= ( const const_iterator &iter ) const; + bool operator >= ( const const_iterator &iter ) const; + GENAPI_DECL + friend const_iterator operator + ( intptr_t iInc, const const_iterator &iter); + + // Member + // ------------------------------------------------------------------------- + protected: + T * _ps; + }; + + class GENAPI_DECL iterator : + public const_iterator + { + public: + // iterator traits + // ------------------------------------------------------------------------- + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef const_iterator::difference_type difference_type; + typedef const_iterator::pointer pointer; + typedef const_iterator::reference reference; + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + iterator ( T *pPtr = 0 ); + + // Operators + // ------------------------------------------------------------------------- + public: + T & operator * ( void ) const; + iterator & operator ++ ( void ); + iterator operator ++ ( int ); + iterator & operator -- ( void ); + iterator operator -- ( int ); + iterator & operator += ( intptr_t iInc ); + iterator operator += ( intptr_t iInc ) const; + iterator operator + ( intptr_t iInc ) const; + iterator & operator -= ( intptr_t iDec ); + iterator operator -= ( intptr_t iDec ) const; + intptr_t operator - ( const iterator &iter ) const; + iterator operator - ( intptr_t iDec ) const; + T & operator [] ( intptr_t iIndex ) const; + GENAPI_DECL + friend iterator operator + ( intptr_t iInc, const iterator &iter); + }; + + // Ctor / Dtor + // --------------------------------------------------------------------------- + public: + value_vector ( void ); + explicit value_vector ( size_t uiSize); + value_vector ( const value_vector &obj); + virtual ~value_vector ( void ); + + // Element access + // --------------------------------------------------------------------------- + public: + virtual void assign ( size_t n, const T &obj ); + virtual void clear ( void ); + virtual iterator erase ( iterator pos ); + virtual T & at ( size_t uiIndex ); + virtual const T & at ( size_t uiIndex ) const; + virtual T & back ( void ); + virtual const T & back ( void ) const; + virtual iterator begin ( void ); + virtual const_iterator begin ( void ) const; + virtual size_t capacity ( void ) const; + virtual iterator end ( void ); + virtual const_iterator end ( void ) const; + virtual T & front ( void ); + virtual const T & front ( void ) const; + virtual size_t max_size ( void ) const; + virtual size_t size ( void ) const; + virtual iterator insert ( iterator pos, const T& val) ; + virtual bool empty ( void ) const; + virtual void pop_back ( void ); + virtual void push_back ( const T &val ); + virtual void resize ( size_t uiSize, const T &val ); + virtual void reserve ( size_t uiSize ); + + + // Do not use - only left in for backwards compatibility! + virtual void erase (size_t uiIndex); + virtual void insert (size_t uiIndex, const T &val); + +// Operators + // --------------------------------------------------------------------------- + public: + value_vector & operator = ( const value_vector &obj ); + T & operator [] ( size_t uiIndex ); + const T & operator [] ( size_t uiIndex ) const; + void operator delete ( void *pWhere ); + void * operator new ( size_t uiSize ); + + // Member + // --------------------------------------------------------------------------- + private: + typedef std::vector > vector_t; + vector_t *_pv; + }; + + //! a list of feature references + typedef value_vector FeatureList_t; +} // namespace GenApi; + + +#else +# error Unknown platform +#endif + +#endif // GENICAM_GENAPI_NODEVECTOR_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Counter.h b/Cigarette/Pylon6.2/include/GenApi/Counter.h new file mode 100644 index 0000000..d62bfa5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Counter.h @@ -0,0 +1,84 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Alexander Happe +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of a simple Counter class +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPI_COUNTER_H +#define GENAPI_COUNTER_H + +namespace GENAPI_NAMESPACE { + + class Counter + { + public: + Counter() : m_value(0) + { + } + + unsigned int GetValue() const + { return m_value; } + + unsigned int operator++() // prefix + { + return ++m_value; + } + + unsigned int operator++(int) // postfix + { + return m_value++; + } + + unsigned int operator--(int) // postfix + { + assert( m_value > 0); + return m_value--; + } + + unsigned int operator--() // prefix + { + assert( m_value > 0); + return --m_value; + } + + operator unsigned int() + { + return m_value; + } + + bool IsZero() + { + return m_value == 0; + } + + private: + unsigned int m_value; + }; +} + +#endif // GENAPI_COUNTER_H + diff --git a/Cigarette/Pylon6.2/include/GenApi/DLLLoad.h b/Cigarette/Pylon6.2/include/GenApi/DLLLoad.h new file mode 100644 index 0000000..8280a21 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/DLLLoad.h @@ -0,0 +1,65 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of function for laoding a DLL dynamically +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPI_DLLLOAD_H +#define GENAPI_DLLLOAD_H + +#include +#include + +#if defined (_MSC_VER) +// nothing +#elif defined (__GNUC__) +# if !defined(__x86_64) && !defined(__arm__) && !defined(VXWORKS) +# define __cdecl __attribute__((cdecl)) +# else +# define __cdecl /* use default calling convention */ +# endif +#else +# error Unsupported compiler +#endif + +namespace GENAPI_NAMESPACE +{ + //! Function prototype for the create function implemented by GenApi DLLs + //! \ingroup GenApi_PublicImpl + typedef INodeMap* (__cdecl * Create_f)(const char* pDeviceName); + + //! Function prototype for checking the DLL's GenApi version + //! \ingroup GenApi_PublicImpl + typedef void (__cdecl * GetGenApiVersion_f)(Version_t &Version); + + //! Frees static resources hold by GenApi + /*! Frees all dynamically loaded DLLs held by the DLLManager + */ + GENAPI_DECL void GenApiTerminate(); +} + +#endif // ifndef GENAPI_DLLLOAD_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EnumClasses.h b/Cigarette/Pylon6.2/include/GenApi/EnumClasses.h new file mode 100644 index 0000000..a0874c5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EnumClasses.h @@ -0,0 +1,631 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of enum classes for Sign, Endianess, Access mode and Visibility +*/ + +#ifndef GENAPI_ENUMCLASSES_H +#define GENAPI_ENUMCLASSES_H +#include + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // Build in enummeration classes + //************************************************************* + + //! ESignClass holds conversion methods for the sign enumeration + + class GENAPI_DECL ESignClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ESign *pValue) + { + if (!pValue) return false; + if( ValueStr == "Signed" ) + *pValue = Signed; + else if( ValueStr == "Unsigned" ) + *pValue = Unsigned; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ESign *pValue) + { + + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == Signed ) + ValueStr = "Signed"; + else if( *pValue == Unsigned ) + ValueStr = "Unsigned"; + else + ValueStr = "_UndefinedSign"; + } + + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(ESign Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief EEndianessClass holds conversion methods for the endianess enumeration + */ + class GENAPI_DECL EEndianessClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EEndianess *pValue) + { + if (!pValue) return false; + if( ValueStr == "BigEndian" ) + *pValue = BigEndian; + else if( ValueStr == "LittleEndian" ) + *pValue = LittleEndian; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EEndianess *pValue) + { + + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == BigEndian ) + ValueStr = "BigEndian"; + else if( *pValue == LittleEndian ) + ValueStr = "LittleEndian"; + else + ValueStr = "_UndefinedEndian"; + } + + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EEndianess Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief ERepresentationClass holds conversion methods for the representation enumeration + */ + class GENAPI_DECL ERepresentationClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ERepresentation *pValue) + { + if (!pValue) return false; + if( ValueStr == "Linear" ) + *pValue = Linear; + else if( ValueStr == "Logarithmic" ) + *pValue = Logarithmic; + else if( ValueStr == "Boolean" ) + *pValue = Boolean; + else if( ValueStr == "PureNumber" ) + *pValue = PureNumber; + else if( ValueStr == "HexNumber" ) + *pValue = HexNumber; + else if( ValueStr == "IPV4Address" ) + *pValue = IPV4Address; + else if( ValueStr == "MACAddress" ) + *pValue = MACAddress; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ERepresentation *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == Linear ) + ValueStr = "Linear"; + else if( *pValue == Logarithmic ) + ValueStr = "Logarithmic"; + else if( *pValue == Boolean ) + ValueStr = "Boolean"; + else if( *pValue == PureNumber ) + ValueStr = "PureNumber"; + else if( *pValue == HexNumber ) + ValueStr = "HexNumber"; + else if( *pValue == IPV4Address ) + ValueStr = "IPV4Address"; + else if( *pValue == MACAddress ) + ValueStr = "MACAddress"; + else + ValueStr = "_UndefinedRepresentation"; + } + + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(ERepresentation Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief EVisibilityClass holds conversion methods for the visibility enumeration + */ + class GENAPI_DECL EVisibilityClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EVisibility *pValue) + { + if (!pValue) return false; + if( ValueStr == "Beginner" ) + *pValue = Beginner; + else if( ValueStr == "Expert" ) + *pValue = Expert; + else if( ValueStr == "Guru" ) + *pValue = Guru; + else if( ValueStr == "Invisible" ) + *pValue = Invisible; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EVisibility *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == Beginner ) + ValueStr = "Beginner"; + else if( *pValue == Expert ) + ValueStr = "Expert"; + else if( *pValue == Guru ) + ValueStr = "Guru"; + else if( *pValue == Invisible ) + ValueStr = "Invisible"; + else + ValueStr = "_UndefinedVisibility"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EVisibility Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief EAccessModeClass holds conversion methods for the access mode enumeration + */ + class GENAPI_DECL EAccessModeClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EAccessMode *pValue) + { + + if (!pValue) return false; + if( ValueStr == "RW" ) + *pValue = RW; + else if( ValueStr == "RO" ) + *pValue = RO; + else if( ValueStr == "WO" ) + *pValue = WO; + else if( ValueStr == "NA" ) + *pValue = NA; + else if( ValueStr == "NI" ) + *pValue = NI; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EAccessMode *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == RW ) + ValueStr = "RW"; + else if( *pValue == RO ) + ValueStr = "RO"; + else if( *pValue == WO ) + ValueStr = "WO"; + else if( *pValue == NI ) + ValueStr = "NI"; + else if( *pValue == NA ) + ValueStr = "NA"; + else + ValueStr = "_UndefinedAccessMode"; + } + + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EAccessMode Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief ECachingModeClass holds conversion methods for the caching mode enumeration + */ + class GENAPI_DECL ECachingModeClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ECachingMode *pValue ) + { + if( ! pValue ) return false; + if( ValueStr == "NoCache" ) + *pValue = NoCache; + else if( ValueStr == "WriteThrough" ) + *pValue = WriteThrough; + else if( ValueStr == "WriteAround" ) + *pValue = WriteAround; + else + return false; + return true; + } + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ECachingMode *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == NoCache ) + ValueStr = "NoCache"; + else if( *pValue == WriteThrough ) + ValueStr = "WriteThrough"; + else if( *pValue == WriteAround ) + ValueStr = "WriteAround"; + else + ValueStr = "_UndefinedCachingMode"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(ECachingMode Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + + }; + + /** + \brief Holds conversion methods for the namespace enumeration + */ + class GENAPI_DECL ENameSpaceClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ENameSpace *pValue) + { + if (!pValue) return false; + if( ValueStr == "Custom" ) + *pValue = Custom; + else if( ValueStr == "Standard" ) + *pValue = Standard; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ENameSpace *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == Custom ) + ValueStr = "Custom"; + else if( *pValue == Standard ) + ValueStr = "Standard"; + else + ValueStr = "_UndefinedNameSpace"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(ENameSpace Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief Holds conversion methods for the standard namespace enumeration + */ + class GENAPI_DECL EYesNoClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EYesNo *pValue) + { + if (!pValue) return false; + if( ValueStr == "Yes" ) + *pValue = Yes; + else if( ValueStr == "No" ) + *pValue = No; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EYesNo *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == Yes) + ValueStr = "Yes"; + else if( *pValue == No ) + ValueStr = "No"; + else + ValueStr = "_UndefinedYesNo"; + } + + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EYesNo Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief Holds conversion methods for the standard namespace enumeration + */ + class GENAPI_DECL EStandardNameSpaceClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EStandardNameSpace *pValue) + { + if (!pValue) return false; + if( ValueStr == "None" ) + *pValue = None; + else if( ValueStr == "GEV" ) + *pValue = GEV; + else if( ValueStr == "IIDC" ) + *pValue = IIDC; + else if( ValueStr == "CL" ) + *pValue = CL; + else if( ValueStr == "USB" ) + *pValue = USB; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EStandardNameSpace *pValue) + { + if( ! pValue ) throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + if( *pValue == None ) + ValueStr = "None"; + else if( *pValue == GEV ) + ValueStr = "GEV"; + else if( *pValue == IIDC ) + ValueStr = "IIDC"; + else if( *pValue == CL ) + ValueStr = "CL"; + else if( *pValue == USB ) + ValueStr = "USB"; + else + ValueStr = "_UndefinedStandardNameSpace"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EStandardNameSpace Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief Holds conversion methods for the converter formulas + */ + class GENAPI_DECL ESlopeClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, ESlope *pValue) + { + if (!pValue) + return false; + + if( ValueStr == "Increasing" ) + *pValue = Increasing; + else if( ValueStr == "Decreasing" ) + *pValue = Decreasing; + else if( ValueStr == "Varying" ) + *pValue = Varying; + else if( ValueStr == "Automatic" ) + *pValue = Automatic; + else + return false; + + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, ESlope *pValue) + { + if( ! pValue ) + throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + + if( *pValue == Increasing ) + ValueStr = "Increasing"; + else if( *pValue == Decreasing ) + ValueStr = "Decreasing"; + else if( *pValue == Varying ) + ValueStr = "Varying"; + else if( *pValue == Automatic ) + ValueStr = "Automatic"; + else + ValueStr = "_UndefinedESlope"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(ESlope Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief Holds conversion methods for the notation type of floats + */ + class GENAPI_DECL EDisplayNotationClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EDisplayNotation *pValue) + { + if (!pValue) + return false; + + if( ValueStr == "Automatic" ) + *pValue = fnAutomatic; + else if( ValueStr == "Fixed" ) + *pValue = fnFixed; + else if( ValueStr == "Scientific" ) + *pValue = fnScientific; + else + return false; + + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EDisplayNotation *pValue) + { + if( ! pValue ) + throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + + if( *pValue == fnAutomatic ) + ValueStr = "Automatic"; + else if( *pValue == fnFixed ) + ValueStr = "Fixed"; + else if( *pValue == fnScientific ) + ValueStr = "Scientific"; + else + ValueStr = "_UndefinedEDisplayNotation"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EDisplayNotation Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + /** + \brief Holds conversion methods for the notation type of floats + */ + class GENAPI_DECL EInputDirectionClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EInputDirection *pValue) + { + if (!pValue) + return false; + + if( ValueStr == "From" ) + *pValue = idFrom; + else if( ValueStr == "To" ) + *pValue = idTo; + else if( ValueStr == "None" ) + *pValue = idNone; + else + return false; + + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EInputDirection *pValue) + { + if( ! pValue ) + throw INVALID_ARGUMENT_EXCEPTION( "NULL argument pValue" ); + + if( *pValue == idFrom ) + ValueStr = "From"; + else if( *pValue == idTo ) + ValueStr = "To"; + else if( *pValue == idNone ) + ValueStr = "None"; + else + ValueStr = "_UndefinedEInputDirection"; + } + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EInputDirection Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + //! helper class converting EGenApiSchemaVersion from and to string + class GENAPI_DECL EGenApiSchemaVersionClass + { + public: + //! Converts a string to enum value + static bool FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, EGenApiSchemaVersion *pValue) + { + if (!pValue) return false; + if (ValueStr == "v1_0") + *pValue = v1_0; + else if (ValueStr == "v1_1") + *pValue = v1_1; + else + return false; + return true; + } + //! Converts a string to an int32_t property + static void ToString(GENICAM_NAMESPACE::gcstring &ValueStr, EGenApiSchemaVersion *pValue) + { + + assert(!pValue); + if (*pValue == v1_0) + ValueStr = "v1_0"; + else if (*pValue == v1_1) + ValueStr = "v1_1"; + else + ValueStr = "_Undefined"; + } + + //! Converts a string to an int32_t property + static GENICAM_NAMESPACE::gcstring ToString(EGenApiSchemaVersion Value) + { + GENICAM_NAMESPACE::gcstring Result; + ToString(Result, &Value); + return Result; + } + }; + + +} + +#endif // ifndef GENAPI_ENUMCLASSES_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EventAdapter.h b/Cigarette/Pylon6.2/include/GenApi/EventAdapter.h new file mode 100644 index 0000000..73a69a2 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventAdapter.h @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventAdapter class. +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_EVENTADAPTER_H +#define GENAPI_EVENTADAPTER_H + +#include +#include +#include + +#include + +namespace GENAPI_NAMESPACE +{ + + /** + \brief Delivers Events to ports + \ingroup GenApi_PublicUtilities + */ + class GENAPI_DECL CEventAdapter + { + + public: + //! Constructor + CEventAdapter(INodeMap* pNodeMap = NULL); + + //! Destructor + virtual ~CEventAdapter(); + + //! Attaches to a node map and retrieves the chunk ports + virtual void AttachNodeMap(INodeMap* pNodeMap); + + //! Detaches from the node emap + virtual void DetachNodeMap(); + + //! Deliver message + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ) = 0; + + + protected: + //! An array of attached ChunkPorts + /*! Note that this must be a pointer otherwise we'll get into DLL hell (see warning C4251) */ + std::vector *m_ppEventPorts; + }; + +} + +#endif // GENAPI_EVENTADAPTER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EventAdapter1394.h b/Cigarette/Pylon6.2/include/GenApi/EventAdapter1394.h new file mode 100644 index 0000000..6b551b9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventAdapter1394.h @@ -0,0 +1,64 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Hartmut Nebelung +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventAdapter1394 class. +*/ +#ifndef __EVENTADAPTER1394_H__ +#define __EVENTADAPTER1394_H__ + + +#include + + +namespace GENAPI_NAMESPACE +{ + // the opaque event data on IEEE 1394 + struct EventData1394; + + //! Distribute the events to the node map + class GENAPI_DECL CEventAdapter1394 : public GENAPI_NAMESPACE::CEventAdapter + { + public: + //! constructor + explicit CEventAdapter1394( INodeMap* pNodeMap=NULL ); + //! destructor + ~CEventAdapter1394(); + private: + //! not implemented: copy constructor + CEventAdapter1394( const CEventAdapter1394& ); + //! not implemented: assignment operator + CEventAdapter1394& operator=( const CEventAdapter1394& ); + + public: + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ); + //! distributes events to node map + void DeliverEventMessage( EventData1394& Event, uint32_t numBytes ); + private: + struct EventAdapter1394Impl; + EventAdapter1394Impl* m_pImpl; + }; +} +#endif //__EVENTADAPTER1394_H__ diff --git a/Cigarette/Pylon6.2/include/GenApi/EventAdapterCL.h b/Cigarette/Pylon6.2/include/GenApi/EventAdapterCL.h new file mode 100644 index 0000000..a5ec102 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventAdapterCL.h @@ -0,0 +1,128 @@ +//----------------------------------------------------------------------------- +// (c) 2015 by Baumer +// Project: GenApi +// Author: Thomas Doering +// Adapted from EventAdapterU3V.h +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventAdapterCL class. +*/ + +#ifndef GENAPI_EVENTADAPTERCL_H +#define GENAPI_EVENTADAPTERCL_H + +#include + +namespace GENAPI_NAMESPACE +{ + + /* ------------------------------------------- */ + // Declaration of CL / GenCP Event message structures + + // some useful macros + #if defined( _MSC_VER ) + #define PACK_STRUCT + #elif defined (__GNUC__) + // While gcc-4 understands #pragma pack, + // gcc-3 does not + #define PACK_STRUCT __attribute__((packed)) + #else + # error Unknown platform + #endif + + // make sure everything is properly packed +#pragma pack(push, 1) + + //! CL/GenCP command header + typedef struct PACK_STRUCT CL_COMMAND_HEADER + { + // prefix + uint16_t Preamble; + uint16_t CcdCrc16; + uint16_t ScdCrc16; + uint16_t ChannelId; + + // CCD + uint16_t Flags; + uint16_t CommandId; + uint16_t Length; + uint16_t ReqId; + } CL_COMMAND_HEADER; + + //! CL/GenCP EVENT_CMD specific command data WITHOUT event specific data + typedef struct PACK_STRUCT CL_EVENT_DATA + { + // SCD + uint16_t ReservedOrEventSize; + uint16_t EventId; + uint64_t Timestamp; + } CL_EVENT_DATA; + + //! CL/GenCP EVENT_CMD specific command data WITH event specific data + typedef struct PACK_STRUCT CL_EVENT_DATA1 + { + // SCD + uint16_t ReservedOrEventSize; + uint16_t EventId; + uint64_t Timestamp; + uint8_t Data[1]; + } CL_EVENT_DATA1; + + //! Entire event data message + typedef struct PACK_STRUCT CL_EVENT_MESSAGE + { + CL_COMMAND_HEADER CommandHeader; + union { + CL_EVENT_DATA EventData; +// CL_EVENT_DATA1 EventData1; + }; + } CL_EVENT_MESSAGE; + + const uint16_t CL_EVENT_PREAMBLE = 0x0100; + const uint16_t CL_EVENT_CMD_ID = 0x0C00; + const size_t CL_COMMAND_HEADER_SIZE = sizeof (CL_COMMAND_HEADER); + const size_t CL_EVENT_BASIC_SIZE = sizeof (CL_EVENT_MESSAGE); + + // restore the previous packing +#pragma pack(pop) + /* ------------------------------------------- */ + + + //! Connects a U3V Event to a node map + class GENAPI_DECL CEventAdapterCL : public CEventAdapter + { + public: + //! Constructor + CEventAdapterCL(INodeMap* pNodeMap = NULL); + + //! Destructor + virtual ~CEventAdapterCL(); + + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ); + + //! Delivers the Event + Data listed in the packet + void DeliverEventData(const CL_EVENT_DATA *pEventData, uint16_t length); + + }; +} + +#endif // GENAPI_EVENTADAPTERCL_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EventAdapterGEV.h b/Cigarette/Pylon6.2/include/GenApi/EventAdapterGEV.h new file mode 100644 index 0000000..5726d8b --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventAdapterGEV.h @@ -0,0 +1,178 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventAdapterGEV class. +*/ + +#ifndef GENAPI_EVENTADAPTERGEV_H +#define GENAPI_EVENTADAPTERGEV_H + +#include + +namespace GENAPI_NAMESPACE +{ + + /* ------------------------------------------- */ + // Declaration of GigE Vision Event message structures + + // some useful macros + #if defined( _MSC_VER ) + #define PACK_STRUCT + #elif defined (__GNUC__) + // While gcc-4 understands #pragma pack, + // gcc-3 does not + #define PACK_STRUCT __attribute__((packed)) + #else + # error Unknown platform + #endif + + // make sure everything is properly packed +#pragma pack(push, 1) + + + //! header of a GVCP request packet + typedef struct PACK_STRUCT GVCP_REQUEST_HEADER + { + uint8_t Magic; + uint8_t Flags; + uint16_t Command; + uint16_t Length; + uint16_t ReqId; + } GVCP_REQUEST_HEADER; + + //! layout of a GVCP event item (common to all types) + typedef struct PACK_STRUCT GVCP_EVENT_ITEM_BASIC + { + uint16_t ReservedOrEventSize; + uint16_t EventId; + } GVCP_EVENT_ITEM_BASIC; + + //! layout of a GVCP event item (Extended ID flag not set) + typedef struct PACK_STRUCT GVCP_EVENT_ITEM + { + uint16_t ReservedOrEventSize; + uint16_t EventId; + uint16_t StreamChannelId; + uint16_t BlockId; + uint32_t TimestampHigh; + uint32_t TimestampLow; + } GVCP_EVENT_ITEM; + + //! Layout of a GVCP event request packet (Extended ID flag not set) + typedef struct PACK_STRUCT GVCP_EVENT_REQUEST + { + GVCP_REQUEST_HEADER Header; + GVCP_EVENT_ITEM Items[ 1 ]; + } GVCP_EVENT_REQUEST; + + //! Layout of a GVCP event data request packet (Extended ID flag not set) + typedef struct PACK_STRUCT GVCP_EVENTDATA_REQUEST + { + GVCP_REQUEST_HEADER Header; + GVCP_EVENT_ITEM Event; + uint32_t Data[ 1 ]; + } GVCP_EVENTDATA_REQUEST; + + //! layout of a GVCP event item (Extended ID flag set) + typedef struct PACK_STRUCT GVCP_EVENT_ITEM_EXTENDED_ID + { + uint16_t ReservedOrEventSize; + uint16_t EventId; + uint16_t StreamChannelId; + uint16_t BlockId; + uint32_t BlockId64High; + uint32_t BlockId64Low; + uint32_t TimestampHigh; + uint32_t TimestampLow; + } GVCP_EVENT_ITEM_EXTENDED_ID; + + //! Layout of a GVCP event request packet (Extended ID flag set) + typedef struct PACK_STRUCT GVCP_EVENT_REQUEST_EXTENDED_ID + { + GVCP_REQUEST_HEADER Header; + GVCP_EVENT_ITEM_EXTENDED_ID Items[ 1 ]; + } GVCP_EVENT_REQUEST_EXTENDED_ID; + + //! Layout of a GVCP event data request packet (Extended ID flag set) + typedef struct PACK_STRUCT GVCP_EVENTDATA_REQUEST_EXTENDED_ID + { + GVCP_REQUEST_HEADER Header; + GVCP_EVENT_ITEM_EXTENDED_ID Event; + uint32_t Data[ 1 ]; + } GVCP_EVENTDATA_REQUEST_EXTENDED_ID; + + const uint8_t COMMAND_MAGIC = 0x42; + + typedef enum GVCP_MESSAGE_TAGS + { + TAG_EVENT_CMD = 0xc0, + TAG_EVENTDATA_CMD = 0xc2 + } GVCP_MESSAGE_TAGS; + // restore the previous packing +#pragma pack(pop) + /* ------------------------------------------- */ + + + //! Connects a GigE Event to a node map + class GENAPI_DECL CEventAdapterGEV : public CEventAdapter + { + public: + //! Constructor + CEventAdapterGEV(INodeMap* pNodeMap = NULL); + + //! Destructor + virtual ~CEventAdapterGEV(); + + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ); + + //! Delivers the Events listed in the Event packet (Extended ID flag not set) + void DeliverEventMessage(const GVCP_EVENT_REQUEST *pEvent); + + //! Delivers the Event + Data listed in the EventData packet (Extended ID flag not set) + void DeliverEventMessage(const GVCP_EVENTDATA_REQUEST *pEventData); + + //! Delivers the Events listed in the Event packet (Extended ID flag set) + void DeliverEventMessage(const GVCP_EVENT_REQUEST_EXTENDED_ID *pEvent); + + //! Delivers the Event + Data listed in the EventData packet (Extended ID flag set) + void DeliverEventMessage(const GVCP_EVENTDATA_REQUEST_EXTENDED_ID *pEventData); + + private: + void DeliverEventItem(const GVCP_EVENT_ITEM_BASIC *pItem, unsigned int length); + + /* + The code for handling event messages and attaching event items to the EventPort + is the same for events with and without extended ID. + Only the datatype differs, so we keep the implementation in these templates + */ + template void DeliverEventMessageImpl(const EVT_REQ_TYPE *pEvent); + template void DeliverEventDataMessageImpl(const EVT_REQ_TYPE *pEvent); + void AttachItemToPorts(const uint8_t *pItem, uint16_t event_id, unsigned int length); + + }; +} + +#endif // GENAPI_EVENTADAPTERGEV_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EventAdapterGeneric.h b/Cigarette/Pylon6.2/include/GenApi/EventAdapterGeneric.h new file mode 100644 index 0000000..7812d99 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventAdapterGeneric.h @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Leutron Vision +// Project: GenApi +// Author: Jan Becvar +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventAdapterGEV class. +*/ + +#ifndef GENAPI_EVENTADAPTERGENERIC_H +#define GENAPI_EVENTADAPTERGENERIC_H + +#include + +namespace GENAPI_NAMESPACE +{ + //! Connects a generic event to a node map + class GENAPI_DECL CEventAdapterGeneric : public CEventAdapter + { + public: + //! Constructor + CEventAdapterGeneric(INodeMap* pNodeMap = NULL); + + //! Destructor + virtual ~CEventAdapterGeneric(); + + // Does not have implementation, use the version with EventID + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ); + + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes, const GENICAM_NAMESPACE::gcstring& EventID); + + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes, uint64_t EventID); + private: + //! Binary version of the EventID + uint8_t *m_pEventIDBuffer; + + //! Length of the EventID buffer + int m_AllocEventIDLength; + + }; +} + +#endif // GENAPI_EVENTADAPTERGENERIC_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EventAdapterU3V.h b/Cigarette/Pylon6.2/include/GenApi/EventAdapterU3V.h new file mode 100644 index 0000000..fe6783d --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventAdapterU3V.h @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +// (c) 2013 by Groget +// Project: GenApi +// Author: Jan Becvar +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventAdapterU3V class. +*/ + +#ifndef GENAPI_EVENTADAPTERU3V_H +#define GENAPI_EVENTADAPTERU3V_H + +#include + +namespace GENAPI_NAMESPACE +{ + + /* ------------------------------------------- */ + // Declaration of USB3 Vision / GenCP Event message structures + + // some useful macros + #if defined( _MSC_VER ) + #define PACK_STRUCT + #elif defined (__GNUC__) + // While gcc-4 understands #pragma pack, + // gcc-3 does not + #define PACK_STRUCT __attribute__((packed)) + #else + # error Unknown platform + #endif + + // make sure everything is properly packed +#pragma pack(push, 1) + + //! U3V/GenCP command header + typedef struct PACK_STRUCT U3V_COMMAND_HEADER + { + uint32_t Prefix; + // CCD + uint16_t Flags; + uint16_t CommandId; + uint16_t Length; + uint16_t ReqId; + } U3V_COMMAND_HEADER; + //! U3V/GenCP EVENT_CMD specific command data + typedef struct PACK_STRUCT U3V_EVENT_DATA + { + // SCD + uint16_t Reserved; + uint16_t EventId; + uint64_t Timestamp; + // Deliberately not mentioning the (optional?) variable sized data + } U3V_EVENT_DATA; + //! Entire event data message (without the variable-sized data field) + typedef struct PACK_STRUCT U3V_EVENT_MESSAGE + { + U3V_COMMAND_HEADER CommandHeader; + U3V_EVENT_DATA EventData; + } U3V_EVENT_MESSAGE; + + const uint32_t U3V_EVENT_PREFIX = 0x45563355; + const uint16_t GENCP_EVENT_CMD_ID = 0x0C00; + const size_t GENCP_COMMAND_HEADER_SIZE = sizeof (U3V_COMMAND_HEADER); + const size_t GENCP_EVENT_BASIC_SIZE = sizeof (U3V_EVENT_MESSAGE); + + // restore the previous packing +#pragma pack(pop) + /* ------------------------------------------- */ + + + //! Connects a U3V Event to a node map + class GENAPI_DECL CEventAdapterU3V : public CEventAdapter + { + public: + //! Constructor + CEventAdapterU3V(INodeMap* pNodeMap = NULL); + + //! Destructor + virtual ~CEventAdapterU3V(); + + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ); + + //! Delivers the Event + Data listed in the packet + void DeliverEventMessage(const U3V_EVENT_MESSAGE *pEventMessage); + + }; +} + +#endif // GENAPI_EVENTADAPTERU3V_H diff --git a/Cigarette/Pylon6.2/include/GenApi/EventPort.h b/Cigarette/Pylon6.2/include/GenApi/EventPort.h new file mode 100644 index 0000000..560db6b --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/EventPort.h @@ -0,0 +1,154 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/** +\file +\brief Declaration of the CEventPort class. +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_EVENTPORT_H +#define GENAPI_EVENTPORT_H + +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + /** + \brief Port attachable to an event + \ingroup GenApi_PublicUtilities + */ + class GENAPI_DECL CEventPort : public IPortConstruct + { + + public: + //! Constructor; can attach to a node + CEventPort(INode* pNode = NULL); + + //! Destructor; detaches from the port + ~CEventPort(); + + //------------------------------------------------------------- + // IPortConstruct implementation + //------------------------------------------------------------- + + //! Get the access mode of the node + virtual EAccessMode GetAccessMode() const; + + //! Get the type of the main interface of a node + virtual EInterfaceType GetPrincipalInterfaceType() const; + + //! Reads a chunk of bytes from the port + virtual void Read(void *pBuffer, int64_t Address, int64_t Length); + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length); + + //! Called from the port node to give the chunk port a pointer to itself + virtual void SetPortImpl(GENAPI_NAMESPACE::IPort* pPort); + + //! Determines if the port adapter must perform an endianess swap + virtual EYesNo GetSwapEndianess(); + + //--------------------------------------------------------------- + // Implementation + //--------------------------------------------------------------- + + // Invalidates the chunk port node + void InvalidateNode(); + + //------------------------------------------------------------- + // Initializing + //------------------------------------------------------------- + + //! Attaches to the Node + bool AttachNode(GENAPI_NAMESPACE::INode* pNode); + + //! Detaches from the Node + void DetachNode(); + + //! Gets the EventID length + int GetEventIDLength(); + + //! Checks if a EventID matches + bool CheckEventID(uint8_t* pEventIDBuffer, int EventIDLength) const; + + //! Checks if a EventID matches, version using uint64_t ID representation + bool CheckEventID(uint64_t EventID) const; + + //! Attaches the an Event to the EventPort + void AttachEvent(uint8_t *pBaseAddress, int64_t Length); + + //! Detaches the Event from the EventPort + void DetachEvent(); + + protected: + + CLock& GetLock() const; + private: + void ResetEventDataBuffer(); + + //------------------------------------------------------------- + // Member variables + //------------------------------------------------------------- + + //! Pointer to the begin of the buffer + uint8_t *m_pEventData; + + //! Length of the data + int64_t m_EventDataLength; + + //! Space allocated for the data + int64_t m_EventDataAlloc; +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable: 4251 ) +#endif + //! Pointer to the node holding a reference to this implementation + CNodePtr m_ptrNode; +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + + //! Binary version of the EventID + uint8_t *m_pEventIDBuffer; + + //! Length of the EventID buffer + int m_EventIDLength; + + //! indicates if the object is attached to a port node or another node type + bool m_IsAttachedToPortNode; + + //! Event ID stored as a number (for more straightforward access) + uint64_t m_EventIDNumber; + + //! indicates if the m_EventIDNumber is valid (could be invalid eg. if the ID does not fit in 64-bit range) + bool m_EventIDNumberValid; + }; + +} +#endif // GENAPI_EVENTPORT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Filestream.h b/Cigarette/Pylon6.2/include/GenApi/Filestream.h new file mode 100644 index 0000000..eae5c71 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Filestream.h @@ -0,0 +1,754 @@ +//----------------------------------------------------------------------------- +// (c) 2007 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Thies Moeller +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of ODevFileStream and IDevFileStream +*/ + +#ifndef GENAPI_FILESTREAM_H_ +#define GENAPI_FILESTREAM_H_ + +// #include +// #include +// #include +#include +#include +#include // memcpy +//#include +//#include + +#include + +#include + + +#if (__GNUC__) +# include +#endif + +// We cannot use std::streamsize because in VC90/Win32 this was int but in VC120 it is int64 +// So in order to preserve compiler interoperability we need to use our own declaration +typedef int64_t GenICam_streamsize; + + +// FileProtocolAdapter was a header only class before. +// Since it has been moved to GenApi.dll the user now has to explicitly link against GenApi import library to use it +// To minimize the pain we add the genapi lib using pragmas +#if defined (_MSC_VER) + +# include + +// you can define GENICAM_NO_AUTO_IMPLIB to turn off automatic linkage of genicam libs +// you can define GENICAM_FORCE_AUTO_IMPLIB to enforce automatic linkage of genicam libs +# if defined(GENICAM_FORCE_AUTO_IMPLIB) || (!defined(GENICAM_NO_AUTO_IMPLIB) && !defined(GENAPI_EXPORTS)) +# if defined (_WIN32) && defined (_MT ) +# pragma comment(lib, LIB_NAME( "GenApi" )) +# else +# error Invalid configuration +# endif +# endif + +#endif // _MSC_VER + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning (disable: 4251) // class 'GenApi::CPointer' needs to have dll-interface to be used by clients of class 'GenICam::FileProtocolAdapter' +#endif + +namespace GENAPI_NAMESPACE +{ + /** + \brief Adapter between the std::iostreambuf and the SFNC Features representing the device filesystem + \ingroup GenApi_PublicImpl + */ + interface GENAPI_DECL_ABSTRACT IFileProtocolAdapter + { + virtual bool attach(GENAPI_NAMESPACE::INodeMap * pInterface) = 0; + virtual bool openFile(const char * pFileName, std::ios_base::openmode mode) = 0; + virtual bool closeFile(const char * pFileName) = 0; + virtual GenICam_streamsize write(const char * buf, int64_t offs, int64_t len, const char * pFileName) = 0; + virtual GenICam_streamsize read(char * buf, int64_t offs, GenICam_streamsize len, const char * pFileName) = 0; + virtual int64_t getBufSize(const char * pFileName, std::ios_base::openmode mode) = 0; + virtual bool deleteFile(const char * pFileName) = 0; + + }; + /*! + * @brief + * Adapter between the std::iostreambuf and the SFNC Features representing the device filesystem + * + * The adapter assumes, that the features provide stdio fileaccess + * compatible semantic + * + */ + class GENAPI_DECL FileProtocolAdapter : public IFileProtocolAdapter { + public: + /*! + * @brief + * Constructor + * + */ + FileProtocolAdapter(); + virtual ~FileProtocolAdapter(); + private: + FileProtocolAdapter(const FileProtocolAdapter&); // not implemented + FileProtocolAdapter& operator=(const FileProtocolAdapter&); // not implemented + public: + + /*! + * @brief + * attach file protocol adapter to nodemap + * + * @param pInterface + * NodeMap of the device to which the FileProtocolAdapter is attached + * + * @return true if attach was successful, false if not + * + */ + virtual bool attach(GENAPI_NAMESPACE::INodeMap * pInterface ); + + + /*! + * @brief + * open a file on the device + * + * @param pFileName + * file name of the file to open. The file name must exist in the Enumeration FileSelector + * + * @param mode + * mode to open the file. The mode must exist in the Enumeration FileOpenMode + * + * @returns + * true on success, false on error + * + */ + virtual bool openFile(const char * pFileName, std::ios_base::openmode mode); + + + /*! + * @brief + * close a file on the device + * + * @param pFileName + * file name of the file to open. The file name must exist in the Enumeration FileSelector + * + * @returns + * true on success, false on error + */ + virtual bool closeFile(const char * pFileName); + + + /*! + * @brief + * writes data into a file. + * + * @param buf + * source buffer + * + * @param offs + * offset into the device file + * + * @param len + * count of bytes to write + * + * @param pFileName + * file name of the file to write into The file name must exist in the Enumeration FileSelector + * + * @returns + * count of bytes written + * + */ + virtual GenICam_streamsize write(const char * buf, int64_t offs, int64_t len, const char * pFileName); + + + /*! + * @brief + * read data from the device into a buffer + * + * @param buf + * target buffer + * + * @param offs + * offset in the device file to read from + * + * @param len + * count of bytes to read + * + * @param pFileName + * file name of the file to write into The file name must exist in the Enumeration FileSelector + * + * @returns + * count of bytes successfully read + * + */ + virtual GenICam_streamsize read(char * buf, int64_t offs, GenICam_streamsize len, const char * pFileName); + + + /*! + * @brief + * fetch max FileAccessBuffer length for a file + * + * @param pFileName + * file name of the file to open. The file name must exist in the Enumeration FileSelector + * + * @param mode + * mode to open the file. The mode must exist in the Enumeration FileOpenMode + * + * @returns + * max length of FileAccessBuffer in the given mode on the given file + * + */ + virtual int64_t getBufSize(const char * pFileName, std::ios_base::openmode mode); + + + /*! + * @brief + * Delete the content of the file. + * + * @param pFileName + * file name of the file to open. The file name must exist in the Enumeration FileSelector + * + * @returns + * true on success, false on error + */ + virtual bool deleteFile(const char * pFileName); + + private: + void WaitUntilFileOperationExecuteDone( bool Validate = true ); + + private: + // implementation details + struct FileProtocolAdapterImpl; + FileProtocolAdapterImpl* m_pImpl; + }; + + + template class IDevFileStreamBuf + : public std::basic_streambuf { + + typedef Traits traits_type; + typedef typename Traits::int_type int_type; + typedef typename Traits::char_type char_type; + typedef IDevFileStreamBuf filebuf_type; + + // GET next ptr + using std::basic_streambuf::gptr; + // GET end ptr + using std::basic_streambuf::egptr; + // GET begin ptr + using std::basic_streambuf::eback; + // increment next pointer + using std::basic_streambuf::gbump; + // set buffer info + using std::basic_streambuf::setg; + + public: + IDevFileStreamBuf() + : m_pBuffer(0), m_BufSize(0), m_pAdapter(0), m_fpos(0) { + // This already handled by the base class constructor, right? + // std::basic_streambuf::_Init(); + }; + + + ~IDevFileStreamBuf() + { + // catch and dump all exceptions - we're in a destructor... + try + { + this->close(); + } + catch(...) + {} + } + + filebuf_type *open(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, std::ios_base::openmode mode = std::ios_base::in ) { + // get file protocol adapter + m_pAdapter = new FileProtocolAdapter(); + + // open file via Adapter + if (!m_pAdapter || !m_pAdapter->attach(pInterface)){ + delete m_pAdapter; + m_pAdapter = 0; + return 0; + } + + // open file via Adapter + try + { + if (!(m_pAdapter->openFile(pFileName, mode))){ + delete m_pAdapter; + m_pAdapter = 0; + return 0; + } + } + catch (...) + { + delete m_pAdapter; + m_pAdapter = 0; + throw; + } + + m_file = pFileName; + // allocate buffer according to fileinfo + m_BufSize = (GenICam_streamsize)m_pAdapter->getBufSize(m_file.c_str(), mode); + m_pBuffer = new char_type[(unsigned int)m_BufSize / sizeof(char_type)]; + + // setg(buffer+pbSize, buffer+pbSize, buffer+pbSize); + setg(m_pBuffer, m_pBuffer + m_BufSize,m_pBuffer + m_BufSize); + + #ifdef _MSC_VER + // is this reasonable? + std::basic_streambuf::_Init(); + #endif + + return this; + } + + + + bool + is_open() const + { + return m_pAdapter != 0; + } + + filebuf_type *close() { + filebuf_type * ret = 0; + if (this->is_open()) { + // close file + if(m_pAdapter->closeFile(m_file.c_str())){ + // no error + ret = this; + } + delete m_pAdapter; + m_pAdapter = 0; + // buffer + delete[] m_pBuffer; + m_pBuffer = 0; + } + return ret; + } + + + protected: + int_type underflow() { + if (gptr() < egptr() ) + return traits_type::to_int_type(*gptr()); + + if (buffer_in() < 0) + return traits_type::eof(); + else + return traits_type::to_int_type(*gptr()); + + } + + int_type pbackfail(int_type c) { + if (gptr() != eback() || eback()(traits_type::not_eof(c)); + return traits_type::not_eof(c); + } else + return traits_type::eof(); + } + + private: + char_type * m_pBuffer; + GenICam_streamsize m_BufSize; + + GENICAM_NAMESPACE::gcstring m_file; + FileProtocolAdapter * m_pAdapter; + int64_t m_fpos; + + + + int buffer_in() { + + GenICam_streamsize retval = m_pAdapter->read(m_pBuffer, m_fpos, m_BufSize, m_file.c_str()); + + if (retval <= 0) { + setg(0, 0, 0); + return -1; + } else { + setg(m_pBuffer, m_pBuffer , m_pBuffer + retval); + m_fpos += retval; + return GENICAM_NAMESPACE::INTEGRAL_CAST2(retval); + } + } + + + // prohibit copying and assignment + IDevFileStreamBuf(const IDevFileStreamBuf&); + IDevFileStreamBuf& operator=(const IDevFileStreamBuf&); + }; + + + template class ODevFileStreamBuf + : public std::basic_streambuf { + typedef Traits traits_type; + + typedef typename Traits::int_type int_type; + typedef typename Traits::char_type char_type; + typedef typename Traits::pos_type pos_type; + typedef typename Traits::off_type off_type; + + typedef ODevFileStreamBuf filebuf_type; + + + // PUT begin + using std::basic_streambuf::pbase; + // PUT next + using std::basic_streambuf::pptr; + // PUT end + using std::basic_streambuf::epptr; + // increment next pointer + using std::basic_streambuf::pbump; + + public: + ODevFileStreamBuf() + : m_pBuffer(0), m_file(0), m_pAdapter(0), m_fpos(0) { + } + + ~ODevFileStreamBuf() { + this->close(); + } + + filebuf_type *open(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, std::ios_base::openmode mode) { + + // create Genicam Access + m_pAdapter = new FileProtocolAdapter(); + + // attach to nodemap + if (!m_pAdapter || !m_pAdapter->attach(pInterface)){ + delete m_pAdapter; + m_pAdapter = 0; + return 0; + } + + + // open file via Adapter + try + { + if (!(m_pAdapter->openFile(pFileName, mode))){ + delete m_pAdapter; + m_pAdapter = 0; + return 0; + } + } + catch (...) + { + delete m_pAdapter; + m_pAdapter = 0; + throw; + } + + m_file = pFileName; + // allocate buffer according to fileinfo + const int64_t bufSize = m_pAdapter->getBufSize(m_file,mode); + m_pBuffer = new char_type[GENICAM_NAMESPACE::INTEGRAL_CAST(bufSize) / sizeof(char_type)]; + std::basic_streambuf::setp(m_pBuffer, m_pBuffer + bufSize); + + return this; + } + + bool + is_open() const { + return m_pAdapter != 0; + } + + filebuf_type *close() { + filebuf_type * ret = 0; + bool syncFailed = false; + if (this->is_open()) { + if (sync()){ + syncFailed = true; + }; + // close file + if(m_pAdapter->closeFile(m_file)){ + // no error + if ( syncFailed ){ + ret = 0; + } else { + ret = this; + } + } + delete m_pAdapter; + m_pAdapter = 0; + // buffer + delete[] m_pBuffer; + m_pBuffer = 0; + } + return ret; + } + + protected: + GenICam_streamsize xsputn(const char_type * s, GenICam_streamsize n) { + if (n < epptr() - pptr() ) { + memcpy( pptr(), s, (size_t)(n * sizeof(char_type))); + pbump( GENICAM_NAMESPACE::INTEGRAL_CAST2(n) ); + return n; + } else { + for (GenICam_streamsize i = 0; i::sputc(s[i]), traits_type::eof())) + return i; + } + return n; + } + + } + int_type overflow(int_type c = traits_type::eof()) { + if (buffer_out() < 0) { + return traits_type::eof(); + } else { + if (!traits_type::eq_int_type (c, traits_type::eof() ) ) + return std::basic_streambuf::sputc(static_cast(c)); + else + return traits_type::not_eof(c); + } + + } + int sync() { + return GENICAM_NAMESPACE::INTEGRAL_CAST(buffer_out()); + } + + private: + char_type * m_pBuffer; // buffer[bufSize]; + const char * m_file; + FileProtocolAdapter * m_pAdapter; + int64_t m_fpos; + + int64_t buffer_out() { + int64_t cnt = pptr() - pbase(); + + int64_t retval; + int64_t res = m_pAdapter->write(m_pBuffer, m_fpos, cnt, m_file); + + if (res != cnt) { + retval = -1; + } else { + retval = 0; + } + m_fpos += res; + + pbump(- GENICAM_NAMESPACE::INTEGRAL_CAST(cnt)); + return retval; + } + + // prohibit copying assignment + ODevFileStreamBuf(const ODevFileStreamBuf&); + ODevFileStreamBuf & operator =(const ODevFileStreamBuf&); + }; + + template class ODevFileStreamBase + : public std::basic_ostream { + public: + // Non-standard types: + typedef ODevFileStreamBuf filebuf_type; + typedef std::basic_ios ios_type; + typedef std::basic_ostream ostream_type; + + private: + filebuf_type m_streambuf; + public: + +#if defined (_MSC_VER) + ODevFileStreamBase() + : ostream_type(std::_Noinit), m_streambuf() { + this->init(&m_streambuf); + } + + ODevFileStreamBase(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc) + : ostream_type(std::_Noinit), m_streambuf() { + this->init(&m_streambuf); + this->open(pInterface, pFileName, mode); + } + ; + +#elif defined (__GNUC__) + ODevFileStreamBase() + : ostream_type(), m_streambuf() { + this->init(&m_streambuf); + } + + ODevFileStreamBase(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc) + : ostream_type(), m_streambuf() { + this->init(&m_streambuf); + this->open(pInterface, pFileName, mode); + } + ; + + +#else +# error Unknown C++ library +#endif + + + + filebuf_type *rdbuf() const { + return const_cast(&m_streambuf); + } + + /* bool is_open() { + return m_streambuf.is_open(); + } */ + + bool is_open() const { + return m_streambuf.is_open(); + } + + /** + * @brief + * Open file on device in write mode + * + * @param pInterface NodeMap of the device to which the FileProtocolAdapter is attached + * @param pFileName Name of the file to open + * @param mode open mode + * + */ + void open(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, + std::ios_base::openmode mode = std::ios_base::out | std::ios_base::trunc) { + if (!m_streambuf.open(pInterface,pFileName, mode)){ + this->setstate(std::ios_base::failbit); + } + else{ + this->clear(); + } + } + + /** + * @brief Close the file on device + * + */ + void close() { + if (!m_streambuf.close()) + this->setstate(std::ios_base::failbit); + } + }; + + template class IDevFileStreamBase + : public std::basic_istream { + public: + + // Non-standard types: + typedef IDevFileStreamBuf filebuf_type; + typedef std::basic_ios ios_type; + typedef std::basic_istream istream_type; + + private: + filebuf_type m_streambuf; + public: + +#if defined (_MSC_VER) + IDevFileStreamBase() + : istream_type(std::_Noinit), m_streambuf() { + this->init(&m_streambuf); + } + + IDevFileStreamBase(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, + std::ios_base::openmode mode = std::ios_base::in) + : istream_type(std::_Noinit), m_streambuf() { + this->init(&m_streambuf); + this->open(pInterface, pFileName, mode); + } + ; + +#elif defined (__APPLE__) + IDevFileStreamBase() + : istream_type(0), m_streambuf() { + this->init(&m_streambuf); + } + + IDevFileStreamBase(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, + std::ios_base::openmode mode = std::ios_base::in) + : istream_type(0), m_streambuf() { + this->init(&m_streambuf); + this->open(pInterface, pFileName, mode); + } + ; + +#elif defined (__GNUC__) + IDevFileStreamBase() + : istream_type(), m_streambuf() { + this->init(&m_streambuf); + } + + IDevFileStreamBase(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, + std::ios_base::openmode mode = std::ios_base::in) + : istream_type(), m_streambuf() { + this->init(&m_streambuf); + this->open(pInterface, pFileName, mode); + } + ; + +#else +# error Unknown C++ library +#endif + + + filebuf_type *rdbuf() const { + return const_cast(&m_streambuf); + } + + /* bool is_open() { + return m_streambuf.is_open(); + } */ + + bool is_open() const { + return m_streambuf.is_open(); + } + + /* @brief + * Open file on device in write mode + * + * @param pInterface NodeMap of the device to which the FileProtocolAdapter is attached + * @param pFileName Name of the file to open + * @param mode open mode + */ + void open(GENAPI_NAMESPACE::INodeMap * pInterface, const char * pFileName, + std::ios_base::openmode mode = std::ios_base::in) { + if (!m_streambuf.open(pInterface,pFileName, mode)) + this->setstate(std::ios_base::failbit); + else + this->clear(); + } + + /** + * @brief Close the file on the device + */ + void close() { + if (!m_streambuf.close()) + this->setstate(std::ios_base::failbit); + } + }; + + typedef ODevFileStreamBase > ODevFileStream; + typedef IDevFileStreamBase > IDevFileStream; +} + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + +#endif /*GENAPI_FILESTREAM_H_*/ diff --git a/Cigarette/Pylon6.2/include/GenApi/GenApi.h b/Cigarette/Pylon6.2/include/GenApi/GenApi.h new file mode 100644 index 0000000..84d0521 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/GenApi.h @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Main include file for using GenApi with smart pointers +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_GENAPI_H +#define GENAPI_GENAPI_H + +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined (_MSC_VER) +# include +#endif + +#endif diff --git a/Cigarette/Pylon6.2/include/GenApi/GenApiDll.h b/Cigarette/Pylon6.2/include/GenApi/GenApiDll.h new file mode 100644 index 0000000..2d866d4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/GenApiDll.h @@ -0,0 +1,61 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief declspec's to be used for GenApi Windows dll +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPIDLL_H +#define GENAPIDLL_H + +#include + +#if defined(_MSC_VER) +# pragma once +# define GENAPI_DECL_ABSTRACT /*nothing*/ +# ifdef GENAPI_EXPORTS +# define GENAPI_DECL __declspec(dllexport) +# else +# define GENAPI_DECL __declspec(dllimport) +# define GENAPI_EXPIMP_TEMPL extern +# endif +#elif defined (__GNUC__) && (defined (__linux__) || defined(__APPLE__) || defined(VXWORKS)) +# define GENAPI_DECL __attribute__((visibility("default"))) +# define GENAPI_DECL_ABSTRACT __attribute__((visibility("default"))) +# ifdef GENAPI_EXPORTS + // nothing +# else +# define GENAPI_EXPIMP_TEMPL extern +# endif +#else +# #error Define how to export symbols on your platform! +# define GENAPI_DECL +# ifndef GENAPI_EXPORTS +# define GENAPI_EXPIMP_TEMPL extern +# endif +#endif + +#endif /* GENAPIDLL_H */ diff --git a/Cigarette/Pylon6.2/include/GenApi/GenApiLinkage.h b/Cigarette/Pylon6.2/include/GenApi/GenApiLinkage.h new file mode 100644 index 0000000..d3a8a23 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/GenApiLinkage.h @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------------- +// (c) 2007 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains GenApi's linker directives +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_GENAPILINKAGE_H +#define GENAPI_GENAPILINKAGE_H + +#include + +// you can define GENICAM_NO_AUTO_IMPLIB to turn off automatic linkage of genicam libs +// you can define GENICAM_FORCE_AUTO_IMPLIB to enforce automatic linkage of genicam libs +#if defined(GENICAM_FORCE_AUTO_IMPLIB) || (!defined(GENICAM_NO_AUTO_IMPLIB) && !defined(GCBASE_EXPORTS) && !defined(GENAPI_EXPORTS) && !defined(MATHPARSERDLL_EXPORTS) && !defined(LOG_EXPORTS)) +# if defined (_WIN32) && defined (_MT ) +# pragma comment(lib, LIB_NAME( "GCBase" )) +# pragma comment(lib, LIB_NAME( "GenApi" )) +//# pragma comment(lib, LIB_NAME( "Log" )) +//# pragma comment(lib, LIB_NAME( "Log4cpp" )) +# else +# error Invalid configuration +# endif +#endif + + +#define GENAPI_GENAPILINKAGE_H +#endif // diff --git a/Cigarette/Pylon6.2/include/GenApi/GenApiNamespace.h b/Cigarette/Pylon6.2/include/GenApi/GenApiNamespace.h new file mode 100644 index 0000000..cca40e9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/GenApiNamespace.h @@ -0,0 +1,57 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// (c) 2015 by STEMMER IMAGING GmbH +// +// Project: GenApi +// Author: Sascha Dorenbeck +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file GenApiNamespace.h +\brief GenICam versioned namespace. +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPI_NAMESPACE_H +#define GENAPI_NAMESPACE_H + +#include + +// This is the development namespace for the GenApi library +#if ! defined(GENAPI_NAMESPACE_DEFINED) + +# if defined(GENICAM_COMPANY_SUFFIX) +# define GENAPI_NAMESPACE GENICAM_SEP_UNDERSCORE_COMPANY(GenApi, GENICAM_VERSION_MAJOR, GENICAM_VERSION_MINOR, GENICAM_COMPANY_SUFFIX) +# else +# define GENAPI_NAMESPACE GENICAM_SEP_UNDERSCORE(GenApi, GENICAM_VERSION_MAJOR, GENICAM_VERSION_MINOR) +# endif + +# define GENAPI_NAMESPACE_DEFINED +#endif // GENAPI_NAMESPACE_DEFINED + +// And make it usable nicely by api's clients +namespace GENAPI_NAMESPACE {} +#if ! defined( GENICAM_SUPPRESS_NAMESPACE_ALIAS ) +// Public alias + namespace GenApi = GENAPI_NAMESPACE; +#endif // GENICAM_SUPPRESS_NAMESPACE_ALIAS + +#endif // GENAPI_NAMESPACE_H diff --git a/Cigarette/Pylon6.2/include/GenApi/GenApiVersion.h b/Cigarette/Pylon6.2/include/GenApi/GenApiVersion.h new file mode 100644 index 0000000..3725081 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/GenApiVersion.h @@ -0,0 +1,44 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief central versioning counters +*/ + +#ifndef GENAPI_VERSION_H +#define GENAPI_VERSION_H + +#include + +// CAUTION: the following symbols exist for compatibility reasons only +// For new clde please use the GENICAM_ symbols from GenICamVersion.h only + +#define GENAPI_VERSION_MAJOR GENICAM_VERSION_MAJOR +#define GENAPI_VERSION_MINOR GENICAM_VERSION_MINOR +#define GENAPI_VERSION_SUBMINOR GENICAM_VERSION_SUBMINOR +#define GENAPI_VERSION_BUILD GENICAM_VERSION_BUILD + + +#endif // GENAPI_VERSION_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IBase.h b/Cigarette/Pylon6.2/include/GenApi/IBase.h new file mode 100644 index 0000000..583c8ff --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IBase.h @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IBase +\ingroup GenApi_PublicInterface +*/ + + +#ifndef GENAPI_IBASE_H +#define GENAPI_IBASE_H + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IBase interface + //************************************************************* + + /** + \brief Base interface common to all nodes + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IBase + { + //! Get the access mode of the node + virtual EAccessMode GetAccessMode() const = 0; + + //! Virtual destructor enforcing virtual destructor on all derived classes + virtual ~IBase() = 0; + }; + + // Implementation required for Windows only. + // Note: the C++ standard >= 11 prohibit pure virtual destructors with a function body + // in the declaration. Consequently gcc 4.0 and newer reject an inline implementation + // in the class. + inline IBase::~IBase() + { + // do nothing + } + + //************************************************************* + // CBaseRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IBase pointer + \ingroup GenApi_PublicImpl + */ + template + class CBaseRefT : public CReferenceT + { + typedef CReferenceT ref; + + public: + /*--------------------------------------------------------*/ + // IBase + /*--------------------------------------------------------*/ + + //! Get the access mode of the node + virtual EAccessMode GetAccessMode() const + { + if(ref::m_Ptr) + return ref::m_Ptr->GetAccessMode(); + else + return NI; + } + + }; + + //! Reference to an IBase pointer + //! \ingroup GenApi_PublicImpl + typedef CBaseRefT CBaseRef; + +#endif + +} +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IBASE_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IBoolean.h b/Cigarette/Pylon6.2/include/GenApi/IBoolean.h new file mode 100644 index 0000000..487f4ec --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IBoolean.h @@ -0,0 +1,154 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of IBoolean interface +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IBOOLEAN_H +#define GENAPI_IBOOLEAN_H + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IBoolean interface + //************************************************************* + + /** + \brief Interface for Boolean properties + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IBoolean : virtual public IValue + { + public: + //! Set node value + /*! + \param Value The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void SetValue(bool Value, bool Verify = true) = 0; + + //! Set node value + virtual void operator=(bool Value){ SetValue( Value ); } + + //! Get node value + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual bool GetValue(bool Verify = false, bool IgnoreCache = false) const = 0; + + //! Get node value + virtual bool operator()() const { return GetValue(); } + }; + + + //************************************************************* + // CBooleanRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + /** + \internal + \brief Reference to an IInteger pointer + \ingroup GenApi_PublicImpl + */ + template + class CBooleanRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // IBoolean + /*--------------------------------------------------------*/ + + //! Set node value + virtual void SetValue(bool Value, bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->SetValue(Value, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + + // unused param *JS* (removed warning) + GC_UNUSED(Verify); + } + + //! Set node value + virtual void operator=(bool Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->operator=(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual bool GetValue(bool Verify = false, bool IgnoreCache = false) const + { + if(ref::m_Ptr) + return ref::m_Ptr->GetValue(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual bool operator()() const + { + if(ref::m_Ptr) + return ref::m_Ptr->operator()(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IBoolean pointer + //! \ingroup GenApi_PublicImpl + typedef CBooleanRefT CBooleanRef; + +#endif + + + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IBOOLEAN_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ICategory.h b/Cigarette/Pylon6.2/include/GenApi/ICategory.h new file mode 100644 index 0000000..3b892ff --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ICategory.h @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface ICategory and types FeatureList_t : +\ingroup GenApi_PublicInterface +*/ + + +#ifndef GENAPI_ICATEGORY_H +#define GENAPI_ICATEGORY_H + +#include +#include +#include +#include +#include + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + interface INode; + + + //************************************************************* + // ICategory interface + //************************************************************* + + /** + \brief Gives access to a category node + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT ICategory : virtual public IValue + { + + //! Get all features of the category (including sub-categories) + virtual void GetFeatures(FeatureList_t &Features) const = 0; + + }; + + + //************************************************************* + // CCategoryRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an ICategory pointer + \ingroup GenApi_PublicImpl + */ + template + class CCategoryRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // ICategory + /*--------------------------------------------------------*/ + + //! Get all features of the category (including sub-categories) + virtual void GetFeatures(FeatureList_t &Features) const + { + if(ref::m_Ptr) + return ref::m_Ptr->GetFeatures(Features); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an ICategory pointer + //! \ingroup GenApi_PublicImpl + typedef CCategoryRefT CCategoryRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_ICATEGORY_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IChunkPort.h b/Cigarette/Pylon6.2/include/GenApi/IChunkPort.h new file mode 100644 index 0000000..e8f2cc7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IChunkPort.h @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IChunkPort +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_ICHUNKPORT_H +#define GENAPI_ICHUNKPORT_H + +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IChunkPort interface + //************************************************************* + + //! Address of a int64_t pseudo register containing the base address of the chunk (MAX_INT64) +# define CHUNK_BASE_ADDRESS_REGISTER GC_INT64_MAX + + //! Length of the CHUNK_BASE_ADDRESS_REGISTER pseudo register +# define CHUNK_BASE_ADDRESS_REGISTER_LEN 8 + + //! Address of a int64_t pseudo register containing the length of the chunk +# define CHUNK_LENGTH_REGISTER (GC_INT64_MAX-15) + + //! Length of the CHUNK_LENGTH_REGISTER pseudo register +# define CHUNK_LENGTH_REGISTER_LEN 8 + + /** + \brief Interface for ports attached to a chunk + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IChunkPort : virtual public IPort + { + //! Get the Id of the chunk the port should be attached to + virtual GENICAM_NAMESPACE::gcstring GetChunkID() const = 0; + + //! Indicates if the chunk a adapter must hold a cached version of the chunk data + virtual EYesNo CacheChunkData() const = 0; + }; +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_ICHUNKPORT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ICommand.h b/Cigarette/Pylon6.2/include/GenApi/ICommand.h new file mode 100644 index 0000000..5c31c02 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ICommand.h @@ -0,0 +1,138 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Hartmut Nebelung +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of ICommand interface +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_ICOMMAND_H +#define GENAPI_ICOMMAND_H + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // ICommand interface + //************************************************************* + + //! Interface for command like properties + //! \ingroup GenApi_PublicInterface + interface GENAPI_DECL_ABSTRACT ICommand : virtual public IValue + { + public: + + //! Execute the command + /*! + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void Execute(bool Verify = true) = 0; + + //! Execute the command + virtual void operator()() = 0; + + //! Query whether the command is executed + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \return True if the Execute command has finished; false otherwise + */ + virtual bool IsDone(bool Verify = true) = 0; + + + }; + + + //************************************************************* + // CCommandRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IInteger pointer + \ingroup GenApi_PublicImpl + */ + template + class CCommandRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // ICommand + /*--------------------------------------------------------*/ + + //! Execute the command + virtual void Execute(bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->Execute(Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Execute the command + virtual void operator()() + { + if(ref::m_Ptr) + ref::m_Ptr->operator()(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Query whether the command is executed + virtual bool IsDone(bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->IsDone(Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + + }; + + //! Reference to an ICommand pointer + //! \ingroup GenApi_PublicImpl + typedef CCommandRefT CCommandRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_ICOMMAND_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IDestroy.h b/Cigarette/Pylon6.2/include/GenApi/IDestroy.h new file mode 100644 index 0000000..8201ff7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IDestroy.h @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// (c) 2004 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +//----------------------------------------------------------------------------- +/*! +\file IDestroy.h +\brief Definition of interface IDestroy +*/ + +#ifndef GENAPI_IDESTROY_H +#define GENAPI_IDESTROY_H + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + //************************************************************* + // IDestroy interface + //************************************************************* + /** + * \ingroup internal_itf + * \brief Interface to destroy an object + */ + + interface GENAPI_DECL_ABSTRACT IDestroy + { + //! Makes the object to destro itself + virtual void Destroy() = 0; + + }; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // GENAPI_IDESTROY_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IDeviceInfo.h b/Cigarette/Pylon6.2/include/GenApi/IDeviceInfo.h new file mode 100644 index 0000000..49c7276 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IDeviceInfo.h @@ -0,0 +1,87 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface INodeMap +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_DEVICEINFO_H +#define GENAPI_DEVICEINFO_H + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + //************************************************************* + // IDeviceInfo interface + //************************************************************* + + /** + \brief Interface to get information about the device (= nodemap) + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IDeviceInfo + { + //! Get the model name + virtual GENICAM_NAMESPACE::gcstring GetModelName() = 0; + + //! Get the vendor name + virtual GENICAM_NAMESPACE::gcstring GetVendorName() = 0; + + //! Get tool tip + virtual GENICAM_NAMESPACE::gcstring GetToolTip() = 0; + + //! Get the standard name space + virtual GENICAM_NAMESPACE::gcstring GetStandardNameSpace() = 0; + + //! Get the version of the DLL's GenApi implementation + virtual void GetGenApiVersion(Version_t &Version, uint16_t &Build) = 0; + + //! Get the schema version number + virtual void GetSchemaVersion(Version_t &Version) = 0; + + //! Get the version of the device description file + virtual void GetDeviceVersion(Version_t &Version) = 0; + + //! Get the Guid describing the product + virtual GENICAM_NAMESPACE::gcstring GetProductGuid() = 0; + + //! Get the Guid describing the product version + virtual GENICAM_NAMESPACE::gcstring GetVersionGuid() = 0; + }; +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IDEVICEINFO_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IEnumEntry.h b/Cigarette/Pylon6.2/include/GenApi/IEnumEntry.h new file mode 100644 index 0000000..0572f3f --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IEnumEntry.h @@ -0,0 +1,142 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IENUMENTRY_H +#define GENAPI_IENUMENTRY_H + + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + //************************************************************* + // IEnumEntry interface + //************************************************************* + + /** + \brief Interface of single enum value + \ingroup GenApi_PublicInterface + */ + /*! Maps of Enum Values to symbolic values */ + interface GENAPI_DECL_ABSTRACT IEnumEntry : virtual public IValue + { + + public: + //! Get numeric enum value + virtual int64_t GetValue() = 0; + + //! Get symbolic enum value + virtual GENICAM_NAMESPACE::gcstring GetSymbolic()const = 0; + + //! Get double number associated with the entry + virtual double GetNumericValue() = 0; + + //! Indicates if the corresponding EnumEntry is self clearing + virtual bool IsSelfClearing() = 0; + }; + + //************************************************************* + // CEnumEntryRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IEnumEntry pointer + \ingroup GenApi_PublicImpl + */ + template + class CEnumEntryRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // IEnumEntry + /*--------------------------------------------------------*/ + + //! Get numeric enum value + virtual int64_t GetValue() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetValue(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get symbolic enum value + virtual GENICAM_NAMESPACE::gcstring GetSymbolic()const + { + if(ref::m_Ptr) + return ref::m_Ptr->GetSymbolic(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get numeric enum value + virtual double GetNumericValue() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetNumericValue(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Indicates if the corresponding EnumEntry is self clearing + virtual bool IsSelfClearing() + { + if(ref::m_Ptr) + return ref::m_Ptr->IsSelfClearing(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + }; + + //! Reference to an IEnumEntry pointer + //! \ingroup GenApi_PublicImpl + typedef CEnumEntryRefT CEnumEntryRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IENUMENTRY_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IEnumeration.h b/Cigarette/Pylon6.2/include/GenApi/IEnumeration.h new file mode 100644 index 0000000..e309b2d --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IEnumeration.h @@ -0,0 +1,103 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IEnumeration +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IENUMERATION_H +#define GENAPI_IENUMERATION_H + +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // Enumeration interface + //************************************************************* + + /** + \brief Interface for enumeration properties + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IEnumeration : virtual public IValue + { + + //! Get list of symbolic Values + virtual void GetSymbolics(StringList_t & Symbolics) = 0; + + //! Get list of entry nodes + virtual void GetEntries(NodeList_t & Entries) = 0; + + //! Set string node value + virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr) = 0; + + //! Set integer node value + /*! + \param Value The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void SetIntValue(int64_t Value, bool Verify = true) = 0; + + //! Get string node value + virtual GENICAM_NAMESPACE::gcstring operator*() = 0; + + //! Get integer node value + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false) = 0; + + //! Get an entry node by name + virtual IEnumEntry *GetEntryByName(const GENICAM_NAMESPACE::gcstring& Symbolic) = 0; + + //! Get an entry node by its IntValue + virtual IEnumEntry *GetEntry(const int64_t IntValue) = 0; + + //! Get the current entry + virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false) = 0; + + }; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IENUMERATION_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IEnumerationT.h b/Cigarette/Pylon6.2/include/GenApi/IEnumerationT.h new file mode 100644 index 0000000..5abba58 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IEnumerationT.h @@ -0,0 +1,383 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IEnumerationT +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IENUMERATIONT_H +#define GENAPI_IENUMERATIONT_H + +#include +#include +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // Enumeration template interface + //************************************************************* + + /** + \brief Interface for enumeration properties + \ingroup GenApi_PublicInterface + */ + template< typename EnumT > + interface IEnumerationT : public IEnumeration + { + //! Set node value + /*! + \param Value The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void SetValue(EnumT Value, bool Verify = true) = 0; + + //! Set node value + virtual IEnumeration& operator=(EnumT Value) = 0; + + //! Get node value + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual EnumT GetValue(bool Verify = false, bool IgnoreCache = false) = 0; + + //! Get node value + virtual EnumT operator()() = 0; + + //! Set node value + /*! Note : the operator= is not inherited thus the operator= versions + from IEnumeration must be implemented again */ + virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr) = 0; + + //! returns the EnumEntry object belonging to the Value + virtual IEnumEntry *GetEntry(const EnumT Value) = 0; + + //! Get the current entry + virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false) = 0; + + }; + + //************************************************************* + // CEnumerationTRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IEnumerationT pointer + \ingroup GenApi_PublicImpl + */ + template< class EnumT > + class CEnumerationTRef : public IEnumerationT< EnumT >, public IReference, public IEnumReference + { + public: + // Constructor + CEnumerationTRef() : + m_Ptr(NULL) + {} + + /*--------------------------------------------------------*/ + // IReference + /*--------------------------------------------------------*/ + + //! sets the implementation to the reference + virtual void SetReference( IBase *ptr ) + { + m_Ptr = dynamic_cast< IEnumeration *>( ptr ); + } + + /*--------------------------------------------------------*/ + // IEnumReference + /*--------------------------------------------------------*/ + + //! sets the number of enum values + virtual void SetNumEnums( int NumEnums ) + { + m_EnumExists.resize(NumEnums); + m_EnumValues.resize(NumEnums); + + std::vector::iterator ptr; + for(ptr = m_EnumExists.begin(); ptr != m_EnumExists.end(); ptr++) + *ptr = false; + + } + + //! sets the Enum value corresponding to a value + virtual void SetEnumReference( int Index, GENICAM_NAMESPACE::gcstring Name) + { + if ( m_Ptr ) + { + CEnumEntryPtr ptrEnumEntry = GetEntryByName(Name); + + if( ptrEnumEntry.IsValid() ) + { + m_EnumExists[Index] = true; + m_EnumValues[Index] = ptrEnumEntry->GetValue(); + } + } + } + + + /*--------------------------------------------------------*/ + // IBase + /*--------------------------------------------------------*/ + + //! Get the access mode of the node + virtual EAccessMode GetAccessMode() const + { + if(m_Ptr) + return m_Ptr->GetAccessMode(); + else + return NI; + } + + /*--------------------------------------------------------*/ + // IValue + /*--------------------------------------------------------*/ + + //! Get the INode interface of the node + virtual INode* GetNode() + { + if(m_Ptr) + return m_Ptr->GetNode(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get content of the node as string + virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false) + { + if(m_Ptr) + return m_Ptr->ToString(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set content of the node as string + virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true) + { + if(m_Ptr) + return m_Ptr->FromString(ValueStr, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Checks if the value comes from cache or is requested from another node + bool IsValueCacheValid() const + { + if(m_Ptr) + return m_Ptr->IsValueCacheValid(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + /*--------------------------------------------------------*/ + // IEnumeration + /*--------------------------------------------------------*/ + + //! Get list of symbolic Values + virtual void GetSymbolics(StringList_t & Symbolics) + { + if(m_Ptr) + return m_Ptr->GetSymbolics(Symbolics); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get list of entry nodes + virtual void GetEntries(NodeList_t & Entries) + { + if(m_Ptr) + return m_Ptr->GetEntries(Entries); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr) + { + if(m_Ptr) + return m_Ptr->operator=(ValueStr); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual IEnumeration& operator=(const char *pValueStr) + { + if(m_Ptr) + return m_Ptr->operator=(pValueStr); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual void SetIntValue(int64_t Value, bool Verify = true) + { + if(m_Ptr) + m_Ptr->SetIntValue(Value, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual GENICAM_NAMESPACE::gcstring operator*() + { + if(m_Ptr) + return m_Ptr->operator*(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false) + { + if(m_Ptr) + return m_Ptr->GetIntValue(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get an entry node by name + virtual IEnumEntry *GetEntryByName(const GENICAM_NAMESPACE::gcstring& Symbolic) + { + if(m_Ptr) + return m_Ptr->GetEntryByName(Symbolic); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + + //! Get an entry node by its IntValue + virtual IEnumEntry *GetEntry(const int64_t IntValue) + { + if(m_Ptr) + return m_Ptr->GetEntry(IntValue); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get the current entry + virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false) + { + if(m_Ptr) + return m_Ptr->GetCurrentEntry(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + /*--------------------------------------------------------*/ + // IEnumerationT + /*--------------------------------------------------------*/ + + //! Set node value + virtual void SetValue(EnumT Value, bool Verify = true) + { + if(m_Ptr) + { + if( m_EnumExists[Value] ) + { + int64_t EnumValue = m_EnumValues[Value]; + m_Ptr->SetIntValue(EnumValue, Verify); + } + else + throw ACCESS_EXCEPTION("EnumEntry %d not present", Value); + } + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual IEnumeration& operator=(EnumT Value) + { + SetValue(Value); + return *this; + } + + //! Get node value + virtual EnumT GetValue(bool Verify = false, bool IgnoreCache = false) + { + if(m_Ptr) + { + int64_t IntValue = m_Ptr->GetIntValue(Verify, IgnoreCache); + std::vector::iterator ptr; + for ( unsigned int idx = 0; idx < m_EnumValues.size(); ++idx ) + { + if( m_EnumExists[idx] && m_EnumValues[idx] == IntValue) + return (EnumT) idx; + } + throw ACCESS_EXCEPTION("Unknown IntValue %" FMT_I64 "d", IntValue); + } + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual EnumT operator()() + { + return GetValue(); + } + + //! returns the EnumEntry object belonging to the Value + virtual IEnumEntry *GetEntry(const EnumT Value) + { + if(m_Ptr) + { + if( m_EnumExists[Value] ) + { + int64_t EnumValue = m_EnumValues[Value]; + return m_Ptr->GetEntry(EnumValue); + } + else + return NULL; + } + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + protected: + //! Pointer to the implementation the reference references to + IEnumeration *m_Ptr; + + //! The values for enums with a given index + std::vector m_EnumValues; + + //! Indicates it an enum with a given index exists + std::vector m_EnumExists; + + }; + +#endif + +} + +#endif // ifndef GENAPI_IENUMERATIONT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IFloat.h b/Cigarette/Pylon6.2/include/GenApi/IFloat.h new file mode 100644 index 0000000..bf6d3eb --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IFloat.h @@ -0,0 +1,323 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the IFloat interface +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IFLOAT_H +#define GENAPI_IFLOAT_H + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IFloat interface + //************************************************************* + + /** + \brief Interface for float properties + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IFloat : virtual public IValue + { + //! Set node value + /*! + \param Value The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void SetValue(double Value, bool Verify = true) = 0; + + //! Set node value + virtual IFloat& operator=(double Value) = 0; + + //! Get node value + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual double GetValue(bool Verify = false, bool IgnoreCache = false) = 0; + + //! Get node value + virtual double operator()() = 0; + + //! Get node value + virtual double operator*() = 0; + + //! Get minimum value allowed + virtual double GetMin() = 0; + + //! Get maximum value allowed + virtual double GetMax() = 0; + + //! True if the float has a constant increment + virtual bool HasInc() = 0; + + //! Get increment mode + virtual EIncMode GetIncMode() = 0; + + //! Get the constant increment if there is any + virtual double GetInc() = 0; + + //! Get list of valid value + virtual double_autovector_t GetListOfValidValues( bool bounded = true) = 0; + + //! Get recommended representation + virtual ERepresentation GetRepresentation() = 0; + + //! Get the physical unit name + virtual GENICAM_NAMESPACE::gcstring GetUnit() const = 0; + + //! Get the way the float should be converted to a string + virtual EDisplayNotation GetDisplayNotation() const = 0; + + //! Get the precision to be used when converting the float to a string + virtual int64_t GetDisplayPrecision() const = 0; + + //! Restrict minimum value + virtual void ImposeMin(double Value) = 0; + + //! Restrict maximum value + virtual void ImposeMax(double Value) = 0; + }; + + //************************************************************* + // CFloatRef class + //************************************************************* + + interface IInteger; + interface IEnumeration; + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IEnumEntry pointer + \ingroup GenApi_PublicImpl + */ + template + class CFloatRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // IFloat + /*--------------------------------------------------------*/ + + //! Set node value + virtual void SetValue(double Value, bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->SetValue(Value, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual IFloat& operator=(double Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->operator=(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual double GetValue(bool Verify = false, bool IgnoreCache = false) + { + if(ref::m_Ptr) + return ref::m_Ptr->GetValue(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual double operator()() + { + if(ref::m_Ptr) + return ref::m_Ptr->operator()(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual double operator*() + { + if(ref::m_Ptr) + return ref::m_Ptr->operator*(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get minimum value allowed + virtual double GetMin() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetMin(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get maximum value allowed + virtual double GetMax() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetMax(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! True if the float has a constant increment + virtual bool HasInc() + { + if(ref::m_Ptr) + return ref::m_Ptr->HasInc(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + virtual EIncMode GetIncMode() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetIncMode(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get the constant increment if there is any + virtual double GetInc() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetInc(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get list of valid value + virtual double_autovector_t GetListOfValidValues(bool bounded = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->GetListOfValidValues(bounded); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get recommended representation + virtual ERepresentation GetRepresentation() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetRepresentation(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get unit + virtual GENICAM_NAMESPACE::gcstring GetUnit() const + { + if (ref::m_Ptr) + return ref::m_Ptr->GetUnit(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get the way the float should be converted to a string + virtual EDisplayNotation GetDisplayNotation() const + { + if (ref::m_Ptr) + return ref::m_Ptr->GetDisplayNotation(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get the precision to be used when converting the float to a string + virtual int64_t GetDisplayPrecision() const + { + if (ref::m_Ptr) + return ref::m_Ptr->GetDisplayPrecision(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! gets the interface of an alias node. + IInteger *GetIntAlias() + { + if (ref::m_Ptr) + return dynamic_cast(ref::m_Ptr->GetNode()->GetCastAlias()); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! gets the interface of an alias node. + IEnumeration *GetEnumAlias() + { + if (ref::m_Ptr) + return dynamic_cast(ref::m_Ptr->GetNode()->GetCastAlias()); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Restrict minimum value + virtual void ImposeMin(double Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->ImposeMin(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Restrict maximum value + virtual void ImposeMax(double Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->ImposeMax(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IFloat pointer + //! \ingroup GenApi_PublicImpl + typedef CFloatRefT CFloatRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IFLOAT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IInteger.h b/Cigarette/Pylon6.2/include/GenApi/IInteger.h new file mode 100644 index 0000000..8137f29 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IInteger.h @@ -0,0 +1,285 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the interface IInteger. +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IIINTEGER_H +#define GENAPI_IIINTEGER_H + +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IInteger interface + //************************************************************* + + /** + \brief Interface for integer properties + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IInteger : virtual public IValue + { + //! Set node value + /*! + \param Value The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void SetValue(int64_t Value, bool Verify = true) = 0; + + //! Set node value + virtual IInteger& operator=(int64_t Value) = 0; + + //! Get node value + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual int64_t GetValue(bool Verify = false, bool IgnoreCache = false ) = 0; + + //! Get node value + virtual int64_t operator()() = 0; + + //! Get node value + virtual int64_t operator*() = 0; + + //! Get minimum value allowed + virtual int64_t GetMin() = 0; + + //! Get maximum value allowed + virtual int64_t GetMax() = 0; + + //! Get increment mode + virtual EIncMode GetIncMode() = 0; + + //! Get increment + virtual int64_t GetInc() = 0; + + //! Get list of valid value + virtual int64_autovector_t GetListOfValidValues(bool bounded = true) = 0; + + //! Get recommended representation + virtual ERepresentation GetRepresentation() = 0; + + //! Get the physical unit name + virtual GENICAM_NAMESPACE::gcstring GetUnit() = 0; + + //! Restrict minimum value + virtual void ImposeMin(int64_t Value) = 0; + + //! Restrict maximum value + virtual void ImposeMax(int64_t Value) = 0; + }; + + + //************************************************************* + // CIntegerRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + interface IFloat; + + /** + \internal + \brief Reference to an IInteger pointer + \ingroup GenApi_PublicImpl + */ + template + class CIntegerRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // IInteger + /*--------------------------------------------------------*/ + + //! Set node value + virtual void SetValue(int64_t Value, bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->SetValue(Value, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual IInteger& operator=(int64_t Value) + { + if(ref::m_Ptr) + { + ref::m_Ptr->SetValue(Value); + return *this; + } + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual int64_t GetValue( bool Verify = false, bool IgnoreCache = false ) + { + if(ref::m_Ptr) + return ref::m_Ptr->GetValue( Verify, IgnoreCache ); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual int64_t operator()() + { + if(ref::m_Ptr) + return ref::m_Ptr->operator()(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual int64_t operator*() + { + if(ref::m_Ptr) + return ref::m_Ptr->operator*(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get minimum value allowed + virtual int64_t GetMin() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetMin(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get maximum value allowed + virtual int64_t GetMax() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetMax(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get increment + virtual EIncMode GetIncMode() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetIncMode(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get increment + virtual int64_t GetInc() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetInc(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Implementation of IInteger::GetListOfValidValues + virtual int64_autovector_t GetListOfValidValues(bool bounded = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->GetListOfValidValues( bounded ); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + + } + + //! Get recommended representation + virtual ERepresentation GetRepresentation() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetRepresentation(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get the physical unit name + virtual GENICAM_NAMESPACE::gcstring GetUnit() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetUnit(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! gets the interface of an alias node. + IFloat *GetFloatAlias() + { + if(ref::m_Ptr) + return dynamic_cast(ref::m_Ptr->GetNode()->GetCastAlias()); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Restrict minimum value + virtual void ImposeMin(int64_t Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->ImposeMin(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Restrict maximum value + virtual void ImposeMax(int64_t Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->ImposeMax(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IInteger pointer + //! \ingroup GenApi_PublicImpl + typedef CIntegerRefT CIntegerRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IIINTEGER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/INode.h b/Cigarette/Pylon6.2/include/GenApi/INode.h new file mode 100644 index 0000000..c3d2ab4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/INode.h @@ -0,0 +1,323 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface INode and types NodeList_t and CallbackHandleType: +\ingroup GenApi_PublicInterface +*/ + + +#ifndef GENAPI_INODE_H +#define GENAPI_INODE_H + +#include +#include +#include +#include +#include + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + interface INode; + interface INodeMap; + + //! a list of node references + typedef node_vector NodeList_t; + + //! the callback handle for nodes + typedef intptr_t CallbackHandleType; + + class CNodeCallback; + + //************************************************************* + // INode interface + //************************************************************* + + /** + \brief Interface common to all nodes + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT INode : virtual public IBase + { + //! Get node name + virtual GENICAM_NAMESPACE::gcstring GetName(bool FullQualified=false) const = 0; + + //! Get name space + virtual GENAPI_NAMESPACE::ENameSpace GetNameSpace() const = 0; + + //! Get the recommended visibility of the node + virtual EVisibility GetVisibility() const = 0; + + //! Indicates that the node's value may have changed. + /*! Fires the callback on this and all dependent nodes */ + virtual void InvalidateNode() = 0; + + //! Is the node value cachable + virtual bool IsCachable() const = 0; + + //! True if the AccessMode can be cached + virtual EYesNo IsAccessModeCacheable() const = 0; + + //! Get Caching Mode + virtual ECachingMode GetCachingMode() const = 0; + + //! recommended polling time (for not cachable nodes) + virtual int64_t GetPollingTime() const = 0; + + //! Get a short description of the node + virtual GENICAM_NAMESPACE::gcstring GetToolTip() const = 0; + + //! Get a long description of the node + virtual GENICAM_NAMESPACE::gcstring GetDescription() const = 0; + + //! Get a name string for display + virtual GENICAM_NAMESPACE::gcstring GetDisplayName() const = 0; + + //! Get a name of the device + virtual GENICAM_NAMESPACE::gcstring GetDeviceName() const = 0; + + /*! + \brief Get all nodes this node directly depends on. + \param[out] Children List of children nodes + \param LinkType The link type + */ + virtual void GetChildren(GENAPI_NAMESPACE::NodeList_t &Children, ELinkType LinkType=ctReadingChildren) const = 0; + + /*! + \brief Gets all nodes this node is directly depending on + \param[out] Parents List of parent nodes + */ + virtual void GetParents(GENAPI_NAMESPACE::NodeList_t &Parents) const = 0; + + //! Register change callback + /*! Takes ownership of the CNodeCallback object */ + virtual CallbackHandleType RegisterCallback( CNodeCallback *pCallback ) = 0; + + //! De register change callback + /*! Destroys CNodeCallback object + \return true if the callback handle was valid + */ + virtual bool DeregisterCallback( CallbackHandleType hCallback ) = 0; + + //! Retrieves the central node map + virtual INodeMap* GetNodeMap() const = 0; + + //! Get the EventId of the node + virtual GENICAM_NAMESPACE::gcstring GetEventID() const = 0; + + //! True if the node is streamable + virtual bool IsStreamable() const = 0; + + //! Returns a list of the names all properties set during initialization + virtual void GetPropertyNames(GENICAM_NAMESPACE::gcstring_vector &PropertyNames) const = 0; + + //! Retrieves a property plus an additional attribute by name + /*! If a property has multiple values/attribute they come with Tabs as delimiters */ + virtual bool GetProperty(const GENICAM_NAMESPACE::gcstring& PropertyName, GENICAM_NAMESPACE::gcstring& ValueStr, GENICAM_NAMESPACE::gcstring& AttributeStr) = 0; + + //! Imposes an access mode to the natural access mode of the node + virtual void ImposeAccessMode(EAccessMode ImposedAccessMode) = 0; + + //! Imposes a visibility to the natural visibility of the node + virtual void ImposeVisibility(EVisibility ImposedVisibility) = 0; + + //! Retrieves the a node which describes the same feature in a different way + virtual INode* GetAlias() const = 0; + + //! Retrieves the a node which describes the same feature so that it can be casted + virtual INode* GetCastAlias() const = 0; + + //! Gets a URL pointing to the documentation of that feature + virtual GENICAM_NAMESPACE::gcstring GetDocuURL() const = 0; + + //! True if the node should not be used any more + virtual bool IsDeprecated() const = 0; + + //! Get the type of the main interface of a node + virtual EInterfaceType GetPrincipalInterfaceType() const = 0; + + //! True if the node can be reached via category nodes from a category node named "Root" + virtual bool IsFeature() const = 0; + + }; + + //! \addtogroup GenApi_PublicInterface + //! \{ + + //! Tests if readable + inline bool IsReadable( EAccessMode AccessMode ) + { + return RO == AccessMode || RW == AccessMode; + } + + //! Checks if a node is readable + inline bool IsReadable( const IBase* p) + { + return (p != NULL) && IsReadable( p->GetAccessMode() ); + } + + //! Checks if a node is readable + inline bool IsReadable( const IBase& r) + { + return IsReadable( r.GetAccessMode() ); + } + + //! Tests if writable + inline bool IsWritable( EAccessMode AccessMode ) + { + return WO == AccessMode || RW == AccessMode; + } + + //! Checks if a node is writable + inline bool IsWritable( const IBase* p) + { + return (p != NULL) && IsWritable( p->GetAccessMode() ); + } + + //! Checks if a node is writable + inline bool IsWritable( const IBase& r) + { + return IsWritable( r.GetAccessMode() ); + } + + //! Tests if implemented + inline bool IsImplemented( EAccessMode AccessMode ) + { + return AccessMode != NI; + } + + //! Checks if a node is implemented + inline bool IsImplemented( const IBase* p) + { + return (p != NULL) && IsImplemented(p->GetAccessMode() ); + } + + //! Checks if a node is implemented + inline bool IsImplemented( const IBase& r) + { + return IsImplemented(&r); + } + + //! Tests if available + inline bool IsAvailable( EAccessMode AccessMode ) + { + return ! ( AccessMode == NA || AccessMode == NI ); + } + + //! Checks if a node is available + inline bool IsAvailable( const IBase* p) + { + return (p != NULL) && IsAvailable(p->GetAccessMode() ); + } + + //! Checks if a node is available + inline bool IsAvailable( const IBase& r) + { + return IsAvailable(r.GetAccessMode() ); + } + + //! Computes which access mode the two guards allow together + inline EAccessMode Combine(EAccessMode Peter, EAccessMode Paul) + { + assert( Peter != _UndefinedAccesMode ); + assert( Paul != _UndefinedAccesMode ); + + if( Peter == NI || Paul == NI ) + return NI; + else if( Peter == NA || Paul == NA ) + return NA; + else if( (Peter == RO && Paul == WO) || (Peter == WO && Paul == RO) ) + return NA; + else if( Peter == WO || Paul == WO ) + return WO; + else if( Peter == RO || Paul == RO ) + return RO; + else + return RW; + } + + + //! Tests Visibility + /*! CAVE : this relys on the EVisibility enum's coding */ + inline bool IsVisible( EVisibility Visibility, EVisibility MaxVisiblity ) + { + return (Visibility <= MaxVisiblity); + } + + + //! Computes which visibility the two guards allow together + inline EVisibility Combine(EVisibility Peter, EVisibility Paul) + { + assert( Peter != _UndefinedVisibility ); + assert( Paul != _UndefinedVisibility ); + + if( Peter == Invisible || Paul == Invisible ) + return Invisible; + else if( Peter == Guru || Paul == Guru ) + return Guru; + else if( Peter == Expert || Paul == Expert ) + return Expert; + else + return Beginner; + } + + + //! Tests Cacheability + inline bool IsCacheable( ECachingMode CachingMode ) + { + return (CachingMode != NoCache); + } + + //! Computes which CachingMode results from a combination + inline ECachingMode Combine(ECachingMode Peter, ECachingMode Paul) + { + assert( Peter != _UndefinedCachingMode ); + assert( Paul != _UndefinedCachingMode ); + + if( Peter == NoCache || Paul == NoCache ) + return NoCache; + else if( Peter == WriteAround || Paul == WriteAround ) + return WriteAround; + else + return WriteThrough; + } + + //! \} + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_INODE_H diff --git a/Cigarette/Pylon6.2/include/GenApi/INodeMap.h b/Cigarette/Pylon6.2/include/GenApi/INodeMap.h new file mode 100644 index 0000000..8cfd42f --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/INodeMap.h @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface INodeMap +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_INODEMAP_H +#define GENAPI_INODEMAP_H + +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + //************************************************************* + // INodeMap interface + //************************************************************* + + /** + \brief Interface to access the node map + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT INodeMap + { + //! Retrieves all nodes in the node map + virtual void GetNodes(NodeList_t &Nodes) const = 0; + + //! Retrieves the node from the central map by Name + virtual INode* GetNode( const GENICAM_NAMESPACE::gcstring& Name) const = 0; + + //! Invalidates all nodes + virtual void InvalidateNodes() const = 0; + + //! Connects a port to a port node with given name + virtual bool Connect( IPort* pPort, const GENICAM_NAMESPACE::gcstring& PortName) const = 0; + + //! Connects a port to the standard port "Device" + virtual bool Connect( IPort* pPort) const = 0; + + //! Get device name + /*! The device name identifies a device instance, e.g. for debugging purposes. + The default ist "Device". */ + virtual GENICAM_NAMESPACE::gcstring GetDeviceName() = 0; + + //! Fires nodes which have a polling time + virtual void Poll( int64_t ElapsedTime ) = 0; + + //! Returns the lock which guards the node map + virtual CLock& GetLock() const = 0; + + //! Get the number of nodes in the map + virtual uint64_t GetNumNodes() const = 0; + + //! Parse all Swissknife equations + virtual bool ParseSwissKnifes( GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL ) const = 0; + }; +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_INODEMAP_H diff --git a/Cigarette/Pylon6.2/include/GenApi/INodeMapDyn.h b/Cigarette/Pylon6.2/include/GenApi/INodeMapDyn.h new file mode 100644 index 0000000..9e4d317 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/INodeMapDyn.h @@ -0,0 +1,123 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface INodeMapDyn +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_INODEMAPDYN_H +#define GENAPI_INODEMAPDYN_H + +#include "Base/GCBase.h" +#include "INodeMap.h" + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + //************************************************************* + // INodeMap interface + //************************************************************* + + /** + \brief Interface to access the node map + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT INodeMapDyn : virtual public INodeMap + { + //! Deletes all Nodes from the map + virtual void ClearAllNodes() = 0; + + //! Loads an XML from a file + virtual void LoadXMLFromFile(const GENICAM_NAMESPACE::gcstring& FileName) = 0; + + //! Loads an XML from a file with injection + virtual void LoadXMLFromFileInject(const GENICAM_NAMESPACE::gcstring& TargetFileName, const GENICAM_NAMESPACE::gcstring& InjectFileName) = 0; + + //! Loads an XML from a string + virtual void LoadXMLFromString(const GENICAM_NAMESPACE::gcstring& XMLData) = 0; + + //! Loads an XML from a string with injection + virtual void LoadXMLFromStringInject(const GENICAM_NAMESPACE::gcstring& TargetXMLData, const GENICAM_NAMESPACE::gcstring& InjectXMLData) = 0; + + //! Loads an XML, checks it for correctness, pre-processes it, caches it, and optionally applies a style sheet, and optionally writes it to a file + virtual void PreprocessXMLFromFile( + const GENICAM_NAMESPACE::gcstring& XMLFileName, //!> The name of the XML file to process + const GENICAM_NAMESPACE::gcstring& StyleSheetFileName, //!> Optional name of a style sheet which is applied after the pre-processor (can be empty string) + //!> This has no effect if the OutputFileName is an empty string + const GENICAM_NAMESPACE::gcstring& OutputFileName, //!> Optional name of an output file into which the processed data is written (can be empty string) + const uint32_t XMLValidation = xvDefault //!> Optional bit mask formed from EXMLValidation enumeration indicating which tests should be performed on the XML file + ) = 0; + + //! Injects an XML file into a target file + virtual void MergeXMLFiles( + const GENICAM_NAMESPACE::gcstring& TargetFileName, //!> Name of the target XML file to process + const GENICAM_NAMESPACE::gcstring& InjectedFileName, //!> Name of the Injected XML file to process + const GENICAM_NAMESPACE::gcstring& OutputFileName //!> Name of the oputput file + ) = 0; + + //! Extract independent subtree + virtual void ExtractIndependentSubtree( + const GENICAM_NAMESPACE::gcstring& XMLData, //!> The XML data the subtree is extracted from. + const GENICAM_NAMESPACE::gcstring& InjectXMLData, //!> Optional XML data that is injected before extracting the subtree. No effect if an empty string is passed. + const GENICAM_NAMESPACE::gcstring& SubTreeRootNodeName,//!> The name of the node that represents the root of the subtree that shall be extracted. + GENICAM_NAMESPACE::gcstring& ExtractedSubtree //!> The returned extracted subtree as string. + ) = 0; + + //! Gets a list of supported schema versions + /*! Each list entry is a string with the format "." were and are integers + Example: {"1.1", "1.2"} indicates that the schema v1.1 and v1.2 are supported. + The SubMinor version number is not given since it is for fully compatible bug fixes only + */ + virtual void GetSupportedSchemaVersions( GENICAM_NAMESPACE::gcstring_vector &SchemaVersions ) = 0; + + //! Loads an XML from a ZIP file + virtual void LoadXMLFromZIPFile(const GENICAM_NAMESPACE::gcstring & ZipFileName) = 0; + + //! Loads an XML from a ZIP data buffer + virtual void LoadXMLFromZIPData(const void* zipData, size_t zipSize) = 0; + + //! Loads a Zipped XML, checks it for correctness, pre-processes it, caches it, and optionally applies a style sheet, and optionally writes it to a file + virtual void PreprocessXMLFromZIPFile( + const GENICAM_NAMESPACE::gcstring& XMLFileName, //!> The name of the XML file to process + const GENICAM_NAMESPACE::gcstring& StyleSheetFileName, //!> Optional name of a style sheet which is applied after the pre-processor (can be empty string) + //!> This has no effect if the OutputFileName is an empty string + const GENICAM_NAMESPACE::gcstring& OutputFileName, //!> Optional name of an output file into which the processed data is written (can be empty string) + const uint32_t XMLValidation = xvDefault //!> Optional bit mask formed from EXMLValidation enumeration indicating which tests should be performed on the XML file + ) = 0; + }; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_INODEMAPDYN_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IPort.h b/Cigarette/Pylon6.2/include/GenApi/IPort.h new file mode 100644 index 0000000..eced3a8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IPort.h @@ -0,0 +1,116 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IPort +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IPORT_H +#define GENAPI_IPORT_H + +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IPort interface + //************************************************************* + + /** + \brief Interface for ports + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IPort : virtual public IBase + { + //! Reads a chunk of bytes from the port + virtual void Read(void *pBuffer, int64_t Address, int64_t Length) = 0; + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) = 0; + }; + + //************************************************************* + // CPortRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IPort pointer + \ingroup GenApi_PublicImpl + */ + template + class CPortRefT : public CBaseRefT + { + typedef CBaseRefT ref; + + public: + /*--------------------------------------------------------*/ + // IPort + /*--------------------------------------------------------*/ + + //! Reads a chunk of bytes from the port + virtual void Read(void *pBuffer, int64_t Address, int64_t Length) + { + if(ref::m_Ptr) + return ref::m_Ptr->Read(pBuffer, Address, Length); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) + { + if(ref::m_Ptr) + return ref::m_Ptr->Write(pBuffer, Address, Length); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IEnumEntry pointer + //! \ingroup GenApi_PublicImpl + typedef CPortRefT CPortRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IPORT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IPortConstruct.h b/Cigarette/Pylon6.2/include/GenApi/IPortConstruct.h new file mode 100644 index 0000000..686804c --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IPortConstruct.h @@ -0,0 +1,58 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IPortConstruct +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPI_IPORTCONSTRUCT_H +#define GENAPI_IPORTCONSTRUCT_H + +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IPortContruct interface + //************************************************************* + + /** + \brief Interface for ports + \ingroup GenApi_PublicImpl + */ + interface GENAPI_DECL_ABSTRACT IPortConstruct: virtual public IPort + { + //! Sets pointer the real port implementation; this function may called only once + virtual void SetPortImpl(IPort* pPort) = 0; + + //! Determines if the port adapter must perform an endianess swap + virtual EYesNo GetSwapEndianess() = 0; + }; +} + +#endif // ifndef GENAPI_IPORTCONSTRUCT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IPortRecorder.h b/Cigarette/Pylon6.2/include/GenApi/IPortRecorder.h new file mode 100644 index 0000000..a444ca7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IPortRecorder.h @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +// (c) 2009 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IPort +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IPORTRECORDER_H +#define GENAPI_IPORTRECORDER_H + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + interface GENAPI_DECL_ABSTRACT IPortWriteList + { + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) = 0; + + //! Replays the write command to the given port interface + virtual void Replay(IPort* pPort) = 0; + + //! Sets a cookie in case the port implementation want to cache a command list + // Default = -1 + virtual void SetCookie(const int64_t Value) = 0; + + //! Gets the cookie a port implementation may have set for caching a command list + virtual int64_t GetCookie() = 0; + }; + + /** + \brief Interface for replaying write commands on a port + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IPortReplay : virtual public IPort + { + //! sends the commands to the camera. + /*! the default implementation just walks the list and issues each command + using the WriteRegister method. Depending on the capabilities of + the transport layer the implementation can however use a special command + which sends all register write commands as one package. + */ + virtual void Replay( IPortWriteList *pPortRecorder, bool Invalidate = true ) = 0; + }; + + /** + \brief Interface for recording write commands on a port + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IPortRecorder : public IPortReplay + { + //! starts logging all WriteRegister commands to a list + virtual void StartRecording( IPortWriteList *pPortRecorder ) = 0; + + //! stops recording + virtual void StopRecording() = 0; + }; + + //************************************************************* + // CPortRecorderRef class + //************************************************************* + + /** + \internal + \brief Reference to an IPortRecorder pointer + \ingroup GenApi_PublicImpl + */ + template + class CPortRecorderRefT : public CPortRefT + { + typedef CPortRefT ref; + + public: + /*--------------------------------------------------------*/ + // IPortRecorder + /*--------------------------------------------------------*/ + + //! sends the commands to the camera. + /*! the default implementation just walks the list and issues each command + using the WriteRegister method. Depending on the capabilities of + the transport layer the implementation can however use a special command + which sends all register write commands as one package. + */ + virtual void Replay( IPortWriteList *pPortRecorder, bool Invalidate = true ) + { + if(ref::m_Ptr) + return ref::m_Ptr->Replay(pPortRecorder, Invalidate); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! starts logging all WriteRegister commands to a list + virtual void StartRecording( IPortWriteList *pPortRecorder ) + { + if(ref::m_Ptr) + return ref::m_Ptr->StartRecording(pPortRecorder); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! stops recording + virtual void StopRecording() + { + if(ref::m_Ptr) + return ref::m_Ptr->StopRecording(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IPortRecorder pointer + //! \ingroup GenApi_PublicImpl + typedef CPortRecorderRefT< IPortRecorder > CPortRecorderRef; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IPORTRECORDER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IRegister.h b/Cigarette/Pylon6.2/include/GenApi/IRegister.h new file mode 100644 index 0000000..4cb4962 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IRegister.h @@ -0,0 +1,151 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of RegisterList_t type and the interface IRegister +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IREGISTER_H +#define GENAPI_IREGISTER_H + +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IRegister interface + //************************************************************* + + /** + \brief Interface for registers + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IRegister : virtual public IValue + { + //! Set the register's contents + /*! + \param pBuffer The buffer containing the data to set + \param Length The number of bytes in pBuffer + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void Set(const uint8_t *pBuffer, int64_t Length, bool Verify = true) = 0; + + //! Fills a buffer with the register's contents + /*! + \param pBuffer The buffer receiving the data to read + \param Length The number of bytes to retrieve + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + */ + virtual void Get(uint8_t *pBuffer, int64_t Length, bool Verify = false, bool IgnoreCache = false) = 0; + + //! Retrieves the Length of the register [Bytes] + virtual int64_t GetLength() = 0; + + //! Retrieves the Address of the register + virtual int64_t GetAddress() = 0; + }; + + //************************************************************* + // CRegisterRef class + //************************************************************* + + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IRegister pointer + \ingroup GenApi_PublicImpl + */ + template + class CRegisterRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // IRegister + /*--------------------------------------------------------*/ + + //! Set the register's contents + virtual void Set(const uint8_t *pBuffer, int64_t Length, bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->Set(pBuffer, Length, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Fills a buffer with the register's contents + virtual void Get(uint8_t *pBuffer, int64_t Length, bool Verify = false, bool IgnoreCache = false) + { + if(ref::m_Ptr) + return ref::m_Ptr->Get(pBuffer, Length, Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Retrieves the Length of the register [Bytes] + virtual int64_t GetLength() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetLength(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Retrieves the Address of the register + virtual int64_t GetAddress() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetAddress(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IRegister pointer + //! \ingroup GenApi_PublicImpl + typedef CRegisterRefT CRegisterRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IREGISTER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ISelector.h b/Cigarette/Pylon6.2/include/GenApi/ISelector.h new file mode 100644 index 0000000..df16cde --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ISelector.h @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Hartmut Nebelung +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of ISelector +*/ + +#ifndef GENAPI_ISELECTOR_H +#define GENAPI_ISELECTOR_H + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + /** + \brief Interface for groups of features selected by a single one + \ingroup GenApi_PublicImpl + */ + interface GENAPI_DECL_ABSTRACT ISelector : virtual public IBase + { + //! true iff this feature selects a group of features + virtual bool IsSelector() const = 0; + + //! retrieve the group of selected features + virtual void GetSelectedFeatures( FeatureList_t& ) const = 0; + + //! retrieve the group of features selecting this node + virtual void GetSelectingFeatures( FeatureList_t& ) const = 0; + }; + + //************************************************************* + // CSelectorRef class + //************************************************************* + + /** + \internal + \brief Reference to an ISelector pointer + \ingroup GenApi_PublicImpl + */ + template + class CSelectorRefT : public CBaseRefT + { + typedef CBaseRefT ref; + + public: + /*--------------------------------------------------------*/ + // ISelector + /*--------------------------------------------------------*/ + + //! Get all features of the Selector + virtual void GetSelectedFeatures(FeatureList_t &Features) const + { + if(ref::m_Ptr) + return ref::m_Ptr->GetSelectedFeatures( Features ); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! retrieve the group of features selecting this node + virtual void GetSelectingFeatures( FeatureList_t& Features) const + { + if(ref::m_Ptr) + return ref::m_Ptr->GetSelectingFeatures( Features ); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! true iff this feature selects a group of features + virtual bool IsSelector() const + { + if(ref::m_Ptr) + return ref::m_Ptr->IsSelector(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + }; + + //! Reference to an ISelector pointer + //! \ingroup GenApi_PublicImpl + typedef CSelectorRefT CSelectorRef; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // GENAPI_ISELECTOR_H diff --git a/Cigarette/Pylon6.2/include/GenApi/ISelectorDigit.h b/Cigarette/Pylon6.2/include/GenApi/ISelectorDigit.h new file mode 100644 index 0000000..fec59a9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/ISelectorDigit.h @@ -0,0 +1,79 @@ +//----------------------------------------------------------------------------- +// (c) 2010 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +*/ + +#ifndef GENAPI_ISELECTORDIGIT_H +#define GENAPI_ISELECTORDIGIT_H + +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + //! Interface of a "digit" of the "counter" formed by the selector set + interface GENAPI_DECL_ABSTRACT ISelectorDigit + { + /*! \brief Sets digit to start value + \return true if the resulting value is valid */ + virtual bool SetFirst() = 0; + + /*! \brief Sets digit to next value + \param Tick if false the counter does not tick (but realize it could have) + \return true if the resulting value is valid */ + virtual bool SetNext(bool Tick = true) = 0; + + //! Restores the selectors' values found at creation + virtual void Restore() = 0; + + //! Returns a string representation of the digit + virtual GENICAM_NAMESPACE::gcstring ToString() = 0; + + //! Retrieves an ordered list of selectors + virtual void GetSelectorList( + GENAPI_NAMESPACE::FeatureList_t &SelectorList, //!> List to contain the selector pointer + bool Incremental = false //!> if true only seletor changed since the last GetNext are contained + ) = 0; + + //! Virtual destructor enforcing virtual destructor on all derived classes + virtual ~ISelectorDigit() = 0; + + }; + + // Implementation required for Windows only. + // Note: the C++ standard >= 11 prohibit pure virtual destructors with a function body + // in the declaration. Consequently gcc 4.0 and newer reject an inline implementation + // in the class. + inline ISelectorDigit::~ISelectorDigit() + { + // do nothing + } +} + +#endif + diff --git a/Cigarette/Pylon6.2/include/GenApi/IString.h b/Cigarette/Pylon6.2/include/GenApi/IString.h new file mode 100644 index 0000000..85fe20e --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IString.h @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Margret Albrecht +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IString +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_ISTRING_H +#define GENAPI_ISTRING_H + +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // IString interface + //************************************************************* + + /** + \brief Interface for string properties + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IString : virtual public IValue + { + //! Set node value + /*! + \param Value The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void SetValue(const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true) = 0; + + //! Set node value + virtual IString& operator=(const GENICAM_NAMESPACE::gcstring& Value) = 0; + + //! Get node value + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false) = 0; + + //! Get node value + virtual GENICAM_NAMESPACE::gcstring operator()() = 0; + + //! Get node value + virtual GENICAM_NAMESPACE::gcstring operator*() = 0; + + //! Retrieves the maximum length of the string in bytes + virtual int64_t GetMaxLength() = 0; + + }; + //************************************************************* + // CStringRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IEnumEntry pointer + \ingroup GenApi_PublicImpl + */ + template + class CStringRefT : public CValueRefT + { + typedef CValueRefT ref; + + public: + /*--------------------------------------------------------*/ + // IString + /*--------------------------------------------------------*/ + + //! Set node value + virtual void SetValue(const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->SetValue(Value, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set node value + virtual IString& operator=(const GENICAM_NAMESPACE::gcstring& Value) + { + if(ref::m_Ptr) + return ref::m_Ptr->operator=(Value); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false) + { + if(ref::m_Ptr) + return ref::m_Ptr->GetValue(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual GENICAM_NAMESPACE::gcstring operator()() + { + if(ref::m_Ptr) + return ref::m_Ptr->operator()(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get node value + virtual GENICAM_NAMESPACE::gcstring operator*() + { + if(ref::m_Ptr) + return ref::m_Ptr-> operator*(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get max length of string + virtual int64_t GetMaxLength() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetMaxLength(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + }; + + //! Reference to an IString pointer + //! \ingroup GenApi_PublicImpl + typedef CStringRefT CStringRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_ISTRING_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IUserData.h b/Cigarette/Pylon6.2/include/GenApi/IUserData.h new file mode 100644 index 0000000..73ecb68 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IUserData.h @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------------- +// (c) 2015 by Basler +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +//----------------------------------------------------------------------------- +/*! +\file IUserData.h +\brief Definition of interface IUserData +*/ + +#ifndef GENAPI_IUSERDATA_H +#define GENAPI_IUSERDATA_H + +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + typedef void* UserData_t; + //************************************************************* + // IUserData + //************************************************************* + /** + * \ingroup internal_itf + * \brief Interface to manage user data stored in nodes or nodemaps. + */ + + interface GENAPI_DECL_ABSTRACT IUserData + { + //! Returns the stored user defined data. + virtual UserData_t GetUserData() const = 0; + //! Stores user defined data without taking ownership. Returns the previously stored value. + virtual UserData_t SetUserData( UserData_t userdata ) = 0; + + }; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // GENAPI_IUSERDATA_H diff --git a/Cigarette/Pylon6.2/include/GenApi/IValue.h b/Cigarette/Pylon6.2/include/GenApi/IValue.h new file mode 100644 index 0000000..f5c2b40 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/IValue.h @@ -0,0 +1,153 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the interface IValue. +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_IVALUE_H +#define GENAPI_IVALUE_H + +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + interface INode; + + //************************************************************* + // IValue interface + //************************************************************* + + /** + \brief Interface for value properties + \ingroup GenApi_PublicInterface + */ + interface GENAPI_DECL_ABSTRACT IValue : virtual public IBase + { + //! Get the INode interface of the node + virtual INode* GetNode() { return dynamic_cast(this); } + + //! Get content of the node as string + /*! + \param Verify Enables Range verification (default = false). The AccessMode is always checked + \param IgnoreCache If true the value is read ignoring any caches (default = false) + \return The value read + */ + virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false) = 0; + + //! Set content of the node as string + /*! + \param ValueStr The value to set + \param Verify Enables AccessMode and Range verification (default = true) + */ + virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true) = 0; + + //! Checks if the value comes from cache or is requested from another node + virtual bool IsValueCacheValid() const = 0; + }; + + + //************************************************************* + // CValueRef class + //************************************************************* + +#ifndef DOXYGEN_IGNORE + + /** + \internal + \brief Reference to an IValue pointer + \ingroup GenApi_PublicImpl + */ + template + class CValueRefT : public CBaseRefT + { + typedef CBaseRefT ref; + + public: + /*--------------------------------------------------------*/ + // IValue + /*--------------------------------------------------------*/ + + //! Get the INode interface of the node + virtual INode* GetNode() + { + if(ref::m_Ptr) + return ref::m_Ptr->GetNode(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Get content of the node as string + virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false) + { + if(ref::m_Ptr) + return ref::m_Ptr->ToString(Verify, IgnoreCache); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Set content of the node as string + virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true) + { + if(ref::m_Ptr) + return ref::m_Ptr->FromString(ValueStr, Verify); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + //! Checks if the value comes from cache or is requested from another node + virtual bool IsValueCacheValid() const + { + if(ref::m_Ptr) + return ref::m_Ptr->IsValueCacheValid(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + }; + + //! Reference to an IValue pointer + //! \ingroup GenApi_PublicImpl + typedef CValueRefT CValueRef; + +#endif + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_IVALUE_H diff --git a/Cigarette/Pylon6.2/include/GenApi/NodeCallback.h b/Cigarette/Pylon6.2/include/GenApi/NodeCallback.h new file mode 100644 index 0000000..ace743f --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/NodeCallback.h @@ -0,0 +1,231 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Hartmut Nebelung +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Implementation helpers for CNodeCallback +\ingroup GenApi_PublicImpl + +Defines a bunch of templates for creating callback-functors taking a INode pointer +and returning void. + +\note does not work with all stl containers, i.e. std::map + +*/ + +#ifndef GENAPI_NODECALLBACK_H +#define GENAPI_NODECALLBACK_H +#include + +namespace GENAPI_NAMESPACE +{ + + //! the type of callback + typedef enum _ECallbackType + { + cbPostInsideLock = 1, //!> callback is fired on leaving the tree inside the lock-guarded area + cbPostOutsideLock = 2 //!> callback is fired on leaving the tree outside the lock-guarded area + } ECallbackType; + + /** + \brief callback body instance for INode pointers + \ingroup GenApi_PublicImpl + */ + class CNodeCallback + { + public: + CNodeCallback( INode *pNode, ECallbackType CallbackType ) : + m_pNode(pNode), + m_CallbackType( CallbackType ) + {} + + //! virtual destructor + virtual ~CNodeCallback() + {}; + + //! fires the callback if the type is right + virtual void operator()( ECallbackType CallbackType ) const = 0; + + //! destroys the object + virtual void Destroy() = 0; + + //! returns the node the callback is registered to + INode* GetNode() + { + return m_pNode; + } + + protected: + //! the node were the callback is installed + INode *m_pNode; + + //! the type of the callback + ECallbackType m_CallbackType; + }; + + /***************************************************************************/ + // C Functions as callbacks + /***************************************************************************/ + + /** + \brief Container for a function pointer + \ingroup GenApi_PublicImpl + */ + template + class Function_NodeCallback : public CNodeCallback + { + public: + //! Constructor + Function_NodeCallback( INode *pNode, const Function& function, ECallbackType CallbackType ) : + CNodeCallback( pNode, CallbackType ), + m_pFunction( function ) + {} + + //! execute operation: call the function + virtual void operator()( ECallbackType CallbackType ) const + { + if (m_pFunction && m_CallbackType == CallbackType) + m_pFunction( m_pNode ); + } + + //! destroys the object + virtual void Destroy() + { + delete this; + } + + private: + //! the callback function + const Function m_pFunction; + + //! no assignment operator + Function_NodeCallback& operator=(Function_NodeCallback&); + }; + + /*-----------------------------------------------------------------------------*/ + + /** + \brief make a new callback object for C functions + \ingroup GenApi_PublicImpl + */ + template + CNodeCallback *make_NodeCallback( INode *pNode, Function function, ECallbackType CallbackType ) + { + return static_cast( new Function_NodeCallback(pNode, function, CallbackType) ); + } + + /*-----------------------------------------------------------------------------*/ + + + /** + \brief Register a C-function as a callback + \ingroup GenApi_PublicUtilities + */ + template + intptr_t Register( INode* pNode, Function f, ECallbackType CallbackType = cbPostInsideLock ) + { + CNodeCallback *pCallback(make_NodeCallback(pNode, f, CallbackType)); + return pNode->RegisterCallback(pCallback); + } + + + /***************************************************************************/ + // C++ Member functions as callbacks + /***************************************************************************/ + + /** + \brief Container for a member function pointer + \ingroup GenApi_PublicImpl + */ + template + class Member_NodeCallback : public CNodeCallback + { + public: + //! Member function type + typedef void (Client::*PMEMBERFUNC)(INode*); + + //! Constructor + Member_NodeCallback( INode *pNode, Client& client, Member member, ECallbackType CallbackType ) : + CNodeCallback( pNode, CallbackType ), + m_Client(client), + m_pMemberFunc(member) + {} + + //! execute operation + virtual void operator()( ECallbackType CallbackType ) const + { + if (m_pMemberFunc && m_CallbackType == CallbackType) + (m_Client.*m_pMemberFunc)( m_pNode ); + } + + //! destroys the object + virtual void Destroy() + { + delete this; + } + + private: + //! The object the method function belongs to + Client& m_Client; + + //! The method to call + PMEMBERFUNC m_pMemberFunc; + + //! no assignment operator + Member_NodeCallback& operator=(Member_NodeCallback&); + }; + + /*-----------------------------------------------------------------------------*/ + + /** + \brief make a new callback object for member functions + \ingroup GenApi_PublicImpl + */ + template + CNodeCallback *make_NodeCallback( INode *pNode, Client& client, Member member, ECallbackType CallbackType ) + { + return static_cast( new Member_NodeCallback(pNode, client, member, CallbackType) ); + } + + /*-----------------------------------------------------------------------------*/ + + /** + \brief Register a C++-member function a callback + \ingroup GenApi_PublicUtilities + */ + template + intptr_t Register( INode* pNode, Client &c, Member m, ECallbackType CallbackType = cbPostInsideLock ) + { + CNodeCallback *pCallback(make_NodeCallback(pNode, c, m, CallbackType)); + return pNode->RegisterCallback(pCallback); + } + + + //! Unregistering callback by handle + // definition in Node.cpp + GENAPI_DECL void Deregister (GENAPI_NAMESPACE::CallbackHandleType pCallbackInfo ); + +} + +#endif // GENAPI_NODECALLBACK_H diff --git a/Cigarette/Pylon6.2/include/GenApi/NodeMapFactory.h b/Cigarette/Pylon6.2/include/GenApi/NodeMapFactory.h new file mode 100644 index 0000000..361971c --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/NodeMapFactory.h @@ -0,0 +1,331 @@ +//----------------------------------------------------------------------------- +// (c) 2013 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Andreas Gau +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the node map factory. +\ingroup GenApi_PublicInterface +*/ +#pragma once + +#include +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + class CLock; // forward + class CNodeDataMap; + struct INodeMap; + + /** + \brief Lists the cache usage strategies. The cache stores preprocessed camera description xml files providing faster access or smaller footprint. + \note The environment variable GENICAM_CACHE_VERSION, e.g. GENICAM_CACHE_V3_0, must contain the path to cache directory for using the cache. + \ingroup GenApi_PublicInterface + */ + typedef enum + { + CacheUsage_Automatic, ///< The use of cache files is determined automatically. + CacheUsage_ForceWrite,///< Forces the loading and preprocessing of the camera description xml file. + ///< If a cache directory is available the result of preprocessing is written to the cache. + CacheUsage_ForceRead, ///< Suppresses loading and preprocessing of the camera description xml file and + ///< forces reading a cache file from cache directory. Fails if no matching cache file is available. + CacheUsage_Ignore ///< Forces the loading and preprocessing of the camera description xml file. No cache file is written. + } ECacheUsage_t; + + /** + \brief Lists the processable file types. + \ingroup GenApi_PublicInterface + */ + typedef enum + { + //ContentType_Auto, + ContentType_Xml, ///< XML camera description file text + ContentType_ZippedXml ///< Zipped XML camera description file text + } EContentType_t; + + + + + //************************************************************* + // CNodeMapFactory + //************************************************************* + + /** + \brief The node map factory is used for creating node maps from camera description files. + + \ingroup GenApi_PublicInterface + \par Examples + + \code + // Simple node map creation from buffer, downloaded from a device for instance. + CNodeMapFactory cameraNodeMapFactory( ContentType_ZippedXml, buffer, bufferSize); + + // Create the node map. The node map can be destroyed using the IDestroy interface later. + INodeMap* pNodeMap = cameraNodeMapFactory.CreateNodeMap(); + // The next step is attaching the device port (not shown). + \endcode + + \code + // Node map creation with injecting additional xml fragments. + CNodeMapFactory cameraNodeMapFactory( ContentType_Xml, buffer, bufferSize); + cameraParameters.AddInjectionData( CNodeMapFactory(ContentType_Xml, filename1)); + cameraParameters.AddInjectionData( CNodeMapFactory(ContentType_Xml, filename2)); + + // Create the node map. The node map can be destroyed using the IDestroy interface later. + INodeMap* pNodeMap = cameraNodeMapFactory.CreateNodeMap(); + // The next step is attaching the device port (not shown). + \endcode + + \code + // Node map creation and additional extraction of a category subtree. + CNodeMapFactory cameraNodeMapFactory( ContentType_Xml, buffer, bufferSize); + // Extract a subtree for later chunk parsing. + CNodeMapFactory chunkDataNodeMapFactory = cameraParameters.ExtractSubtree("ChunkData"); + + // Create the node map. The node map can be destroyed using the IDestroy interface later. + INodeMap* pNodeMap = cameraParameters.CreateNodeMap(); + // The next step is attaching the device port (not shown). + \endcode + + \code + // Node map creation with injecting additional xml fragments and additional extraction of a category subtree. + CNodeMapFactory cameraNodeMapFactory( ContentType_Xml, buffer, bufferSize); + cameraParameters.AddInjectionData( CNodeMapFactory(ContentType_Xml, filename1)); + cameraParameters.AddInjectionData( CNodeMapFactory(ContentType_Xml, filename2)); + CNodeMapFactory chunkDataNodeMapFactory = cameraNodeMapFactory.ExtractSubtree("ChunkData"); + + // Create the node map. The node map can be destroyed using the IDestroy interface later. + INodeMap* pNodeMap = cameraNodeMapFactory.CreateNodeMap(); + // The next step is attaching the device port (not shown). + + // A node map factory can create multiple node maps from the provided camera description file(s). + for(int i = 0; i < 20; ++i) + { + INodeMap* pNodeMapChunks = chunkDataNodeMapFactory.CreateNodeMap(); + //... + } + \endcode + + \attention The is CNodeMapFactory not thread-safe. + + \attention You need to take care when camera description file data can be actually be freed, see method documentation of the node map factory for more detail. + */ + class GENAPI_DECL CNodeMapFactory + { + public: + //! Creates an empty node map factory for assigning a non-empty node map factory later. + CNodeMapFactory(); + + //! Destroys the node map factory data if all references to the data have been released. + virtual ~CNodeMapFactory(); + + /** + \brief Creates another reference to the node map factory data. No data is copied. + */ + CNodeMapFactory( const CNodeMapFactory&); + + /** + \brief Creates another reference to the assigned node map factory data. Destroys the "overwritten" node map factory data if all references to the data have been released. + */ + CNodeMapFactory& operator=(const CNodeMapFactory&); + + + //! Creates the node map factory and simply stores the full path to the provided camera description file data. + /*! + \param[in] FileType Defines how the camera description file is stored, e.g. as zipped XML text. + \param[in] FileName The full path of the camera description file to process. + \param[in] CacheUsage Defines if and how to use the cache for preprocessed camera description files. + \param[in] SuppressStringsOnLoad Suppresses loading strings that are not needed for most use cases, e.g. node tooltip or description, for reducing the memory footprint. + + Throws an invalid argument exception if FileName is empty. Throws if environment variables in FileName cannot be resolved. + + \attention The given file must be readable until the camera description file data has been released. The IsCameraDescriptionFileDataReleased() method can be used to check if releasing has been done. + */ + CNodeMapFactory( EContentType_t FileType, const GENICAM_NAMESPACE::gcstring& FileName, ECacheUsage_t CacheUsage = CacheUsage_Automatic, bool SuppressStringsOnLoad = false); + + + //! Creates the node map factory and simply stores the pointer and the size of the provided camera description file data. + /*! + \param[in] ContentType Defines how the camera description file is stored, e.g. as zipped XML text. + \param[in] pData The pointer to the camera description file data. + \param[in] DataSize The size of the camera description file data. + \param[in] CacheUsage Defines if and how to use the cache for preprocessed camera description files. + \param[in] SuppressStringsOnLoad Suppresses loading strings that are not needed for most use cases, e.g. node tooltip or description, for reducing the memory footprint. + + Throws an invalid argument exception if pData is NULL or DataSize is 0. + + \attention The given buffer must not be freed or changed until the camera description file data has been released. The IsCameraDescriptionFileDataReleased() method can be used to check if releasing has been done. + */ + CNodeMapFactory(EContentType_t ContentType, const void* pData, size_t DataSize, ECacheUsage_t CacheUsage = CacheUsage_Automatic, bool SuppressStringsOnLoad = false); + + + //! Creates the node map factory and copies the provided camera description file string. + /*! + \param[in] XmlData The camera description file data as XML text. + The provided text is copied. You can use the overloaded constructor accepting a buffer to avoid that. + \code + gcstring cdfData; + //... fill cdfData ... + CNodeMapFactory factory(ContentType_Xml, cfdData.c_str(), cfdData.size()); + // Create the node map. The node map can be destroyed using the IDestroy interface later. + INodeMap* pNodeMap = factory.CreateNodeMap(); + // The next step is attaching the device port (not shown). + \endcode + \param[in] CacheUsage Defines if and how to use the cache for preprocessed camera description files. + \param[in] SuppressStringsOnLoad Suppresses loading strings that are not needed for most use cases, e.g. node tooltip or description, for reducing the memory footprint. + + Throws an invalid argument exception if XmlData is empty. + */ + CNodeMapFactory(const GENICAM_NAMESPACE::gcstring& XmlData, ECacheUsage_t CacheUsage = CacheUsage_Automatic, bool SuppressStringsOnLoad = false); + + + //! Returns true if nothing is loaded (IsLoaded()) and no source data is available, e.g. when the node map factory has been created with the default constructor. + bool IsEmpty() const; + + + //! Adds a node map factory representing a camera description file to inject. + /*! + \param[in] injectionData A node map factory representing a camera description file to inject. + + The injected files are injected in the order they are added. + InjectionData must not be preprocessed. The IsPreprocessed() method can be used to check if preprocessing has been done before. + The cache usage of injection data is ignored. + */ + void AddInjectionData(CNodeMapFactory& injectionData); + + + //! Advanced: Loads, Parses, and Injects the camera description files recursively. The result is a memory internal representation of the camera description file(s), the CNodeDataMap (not part of the public interface). + /*! + This step is usually done automatically. Prevents cache read if called manually. + */ + void LoadAndInject(); + + + //! Can be used to check whether the LoadAndInject() processing step has been performed. Returns true if IsPreprocessed() returns true (Preprocessed Data has been loaded from cache). + bool IsLoaded() const; + + + //! The name of the node that represents the root of the subtree that shall be extracted. + /*! + \param[in] SubTreeRootNodeName The root of the branch to extract, e.g. "ChunkData". + \param[in] doRenameToRoot Renames the extracted subtree root node SubTreeRootNodeName to "Root", sets the IsFeature property. + Preprocess() is automatically called if needed to create the memory internal representation of the camera description file(s). + The preprocessed result can be read from the cache or written to the cache in this step. This depends on the availability of a cache and the used CacheUsage setting. + */ + CNodeMapFactory ExtractSubtree(const GENICAM_NAMESPACE::gcstring& SubTreeRootNodeName, bool doRenameToRoot = false); + + + //! Advanced: Creates the preprocessed memory internal representation of the camera description file(s), the CNodeDataMap (not part of the public interface). + /*! + This step is usually done automatically. + Preprocessed data can be read from the cache or written to the cache in this step. This depends on the availability of a cache and the used CacheUsage setting. + By calling this method directly direct cache load is suppressed, see CreateNodeMap() for more information. + */ + void Preprocess(); + + + //! Can be used to check whether the Preprocess() processing step has been performed. + bool IsPreprocessed() const; + + + //! Advanced: Releases any in constructors provided camera description file data buffers or files. + /*! + This step is usually done automatically. + All references to added injection data are dropped in this step to free the data. + After this step any in constructors provided buffers can be freed or any in constructors given files can be deleted. + */ + void ReleaseCameraDescriptionFileData(); + + + //! Can be used to check whether the ReleaseCameraDescriptionFileData() processing step has been performed. + bool IsCameraDescriptionFileDataReleased() const; + + + //! Creates a node map from the preprocessed memory internal representation of the camera description file(s). + /*! + Preprocess() is automatically called if needed. The preprocess step can be omitted by the factory depending on the cache mode setting + when a cache file is available, then the cache file is read and converted directly into a node map. + ReleaseCameraDescriptionFileData() is called if DoReleaseCameraDescriptionFileData is true. + This method can be called multiple times to create multiple instances of a node map. + */ + INodeMap* CreateNodeMap(const GENICAM_NAMESPACE::gcstring &DeviceName = "Device", bool DoReleaseCameraDescriptionFileData = true); + + + //! Creates a node map from the preprocessed memory internal representation of the camera description file(s). + /*! + Preprocess() is automatically called if needed. The preprocess step can be omitted by the factory depending on the cache mode setting + when a cache file is available, then the cache file is read and converted directly into a node map. + ReleaseCameraDescriptionFileData() is called if DoReleaseCameraDescriptionFileData is true. + This method can be called multiple times to create multiple instances of a node map. + This method allows to provide an external lock to avoid using too many locks in an application. + \attention The provided lock must not be destroyed before the created node map. + */ + INodeMap* CreateNodeMap(CLock& UserProvidedLock, const GENICAM_NAMESPACE::gcstring &DeviceName = "Device", bool DoReleaseCameraDescriptionFileData = true); + + + //! Creates an empty node map usable as placeholder, e.g. if certain features are not supported by a module. + static INodeMap* CreateEmptyNodeMap(); + + + //! Deletes all preprocessed camera description files from the cache. + static bool ClearCache(); + + + /*! Each list entry is a string with the format "{Major}.{Minor}" were {Major} and {Minor} are integers + Example: {"1.1", "1.2"} indicates that the schema v1.1 and v1.2 are supported. + The SubMinor version number is not given since it is for fully compatible bug fixes only + */ + void GetSupportedSchemaVersions(GENICAM_NAMESPACE::gcstring_vector &SchemaVersions) const; + + //! Outputs the pre-processed node map in string form (for debug purpose) + GENICAM_NAMESPACE::gcstring ToString() const; + + //! Outputs the pre-processed node map in XML form (mainly for debug purpose) + GENICAM_NAMESPACE::gcstring ToXml() const; + + static CNodeDataMap *CreateNodeDataFromNodeMap( INodeMap* pNodeMap ); + + typedef struct + { + uint32_t NumNodes; + uint32_t NumProperties; + uint32_t NumLinks; + uint32_t NumStrings; + } NodeStatistics_t; + + void GetNodeStatistics(NodeStatistics_t &NodeStatistics); + + //! Applies a style sheet to the pre-processed node map. + const GENICAM_NAMESPACE::gcstring ApplyStyleSheet(const GENICAM_NAMESPACE::gcstring& StyleSheetFileName); + + private: + + class CNodeMapFactoryImpl; + + CNodeMapFactoryImpl* m_pImpl; + }; +} diff --git a/Cigarette/Pylon6.2/include/GenApi/NodeMapRef.h b/Cigarette/Pylon6.2/include/GenApi/NodeMapRef.h new file mode 100644 index 0000000..a236cd8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/NodeMapRef.h @@ -0,0 +1,521 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of CNodeMapRef +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_NODEMAPREF_H +#define GENAPI_NODEMAPREF_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace GENAPI_NAMESPACE +{ + +# ifdef _WIN32 + + // see below in the Linux branch + inline IDestroy *CastToIDestroy(INodeMap *pNodeMap) + { + return dynamic_cast(pNodeMap); + } + +# else + //! makes sure the dynamic_cast operator is implemented in the DLL (due to a Linux bug) + GENAPI_DECL IDestroy *CastToIDestroy(INodeMap *pNodeMap); +# endif + + /** + \brief Smartpointer template for NodeMaps with create function + \ingroup GenApi_PublicInterface + \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file) + */ + template + class CNodeMapRefT : public TCameraParams + { + public: + //! Constructor + CNodeMapRefT(const GENICAM_NAMESPACE::gcstring &DeviceName = "Device"); + + //! Constructor + CNodeMapRefT(INodeMap* pNodeMap, const GENICAM_NAMESPACE::gcstring &DeviceName = "Device"); + + //! Copy constructor + CNodeMapRefT(const CNodeMapRefT& Them); + + //! Assignment + CNodeMapRefT& operator=(const CNodeMapRefT& Them); + + //! Assignment of an INodeMap* + CNodeMapRefT& operator=(INodeMap* pNodeMap); + + //! Destructor + virtual ~CNodeMapRefT(); + + //! Destroys the node map + void _Destroy(); + + //! Creates the object from a XML file with given file name + void _LoadXMLFromFile(const GENICAM_NAMESPACE::gcstring &FileName); + + //! Creates the object from a ZIP'd XML file with given file name + void _LoadXMLFromZIPFile(const GENICAM_NAMESPACE::gcstring &ZipFileName); + + //! Creates the object from a ZIP'd XML file given in a string + void _LoadXMLFromZIPData(const void* zipData, size_t zipSize); + + //! Creates the object from a XML target and an inject file with given file name + void _LoadXMLFromFileInject(const GENICAM_NAMESPACE::gcstring &TargetFileName, const GENICAM_NAMESPACE::gcstring &InjectFileName); + + //! Creates the object from XML data given in a string + void _LoadXMLFromString(const GENICAM_NAMESPACE::gcstring& XMLData); + + //! Creates the object from XML data given in a string with injection + void _LoadXMLFromStringInject(const GENICAM_NAMESPACE::gcstring& TargetXMLDataconst, const GENICAM_NAMESPACE::gcstring& InjectXMLData); + + //! Gets a list of supported schema versions + /*! Each list entry is a string with the format "{Major}.{Minor}" were {Major} and {Minor} are integers + Example: {"1.1", "1.2"} indicates that the schema v1.1 and v1.2 are supported. + The SubMinor version number is not given since it is for fully compatible bug fixes only + */ + virtual void _GetSupportedSchemaVersions(GENICAM_NAMESPACE::gcstring_vector &SchemaVersions) const; + + //! Get device name + virtual GENICAM_NAMESPACE::gcstring _GetDeviceName() const; + + //! Fires nodes which have a polling time + virtual void _Poll(int64_t ElapsedTime); + + //! Clears the cache of the camera description files + static bool _ClearXMLCache(); + + //---------------------------------------------------------------- + // INodeMap + //---------------------------------------------------------------- + + //! Retrieves all nodes in the node map + virtual void _GetNodes(NodeList_t &Nodes) const; + + //! Retrieves the node from the central map by name + virtual INode* _GetNode(const GENICAM_NAMESPACE::gcstring& key) const; + + //! Invalidates all nodes + virtual void _InvalidateNodes() const; + + //! Connects a port to a port node with given name + virtual bool _Connect(IPort* pPort, const GENICAM_NAMESPACE::gcstring& PortName) const; + + //! Connects a port to the standard port "Device" + virtual bool _Connect(IPort* pPort) const; + + //! Parse all Swissknife equations + virtual bool _ParseSwissKnifes( GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL ) const; + //! Pointer to the NodeMap + INodeMap *_Ptr; + + private: + //! The name of this device + GENICAM_NAMESPACE::gcstring _DeviceName; + + //ATTENTION: not thread safe + int* _pRefCount; + void Release(); + void Attach(INodeMap *pNodeMap, const GENICAM_NAMESPACE::gcstring &DeviceName, int* pRefCount); + }; + + + + template + inline CNodeMapRefT::CNodeMapRefT(const GENICAM_NAMESPACE::gcstring &DeviceName) + : _Ptr(NULL) + , _DeviceName(DeviceName) + , _pRefCount(NULL) + { + } + + template + inline CNodeMapRefT::CNodeMapRefT(INodeMap *pNodeMap, const GENICAM_NAMESPACE::gcstring &DeviceName) + : _Ptr(NULL) + , _DeviceName(DeviceName) + , _pRefCount(NULL) + { + assert(pNodeMap); + Attach(pNodeMap, DeviceName, pNodeMap ? new int(0) : NULL); + } + + template + GENAPI_NAMESPACE::CNodeMapRefT::CNodeMapRefT(const CNodeMapRefT& Them) + : TCameraParams() + , _Ptr(NULL) + , _DeviceName() + , _pRefCount(NULL) + { + Attach(Them._Ptr, Them._DeviceName, Them._pRefCount); + } + + //ATTENTION: not thread safe + template + void GENAPI_NAMESPACE::CNodeMapRefT::Attach(INodeMap *pNodeMap, const GENICAM_NAMESPACE::gcstring &DeviceName, int* pRefCount) + { + // Must be empty + assert(_Ptr == NULL); + assert(_pRefCount == NULL); + + //always copy device name + if (&_DeviceName != &DeviceName) //if not assigning member itself + { + _DeviceName = DeviceName; + } + + // Attach + if (pNodeMap) + { + assert(pRefCount); + if (pRefCount) + { + ++*pRefCount; + + //assign new node map data + _Ptr = pNodeMap; + _pRefCount = pRefCount; + + // Initialize the references + TCameraParams::_Initialize(_Ptr); + } + } + } + + //ATTENTION: not thread safe + template + void GENAPI_NAMESPACE::CNodeMapRefT::Release() + { + if (_Ptr) + { + // Copy node map data for eventual later destruction + INodeMap* pToDel = _Ptr; + int* pRefCount = _pRefCount; + + // Clear + _pRefCount = NULL; + _Ptr = NULL; + _DeviceName = "Device"; + + assert(pRefCount); + // Check if destruction is required + if (pRefCount) + { + assert(*pRefCount > 0); + --*pRefCount; + if (*pRefCount == 0) + { + // We do not need this anymore, all references are gone + delete pRefCount; + pRefCount = NULL; + + // Destroy the node map finally + GENAPI_NAMESPACE::IDestroy *pDestroy = CastToIDestroy(pToDel); + assert(pDestroy); + pDestroy->Destroy(); //must not throw + } + } + } + else + { + // Must not have a refcount when no node map is there. + assert(_pRefCount == NULL); + } + } + + template + CNodeMapRefT& GENAPI_NAMESPACE::CNodeMapRefT::operator=(INodeMap* pNodeMap) + { + Release(); + assert(pNodeMap); + if (pNodeMap) + { + Attach(pNodeMap, pNodeMap->GetDeviceName(), new int(0)); + } + + return *this; + } + + template + CNodeMapRefT& GENAPI_NAMESPACE::CNodeMapRefT::operator=(const CNodeMapRefT& Them) + { + Release(); + Attach(Them._Ptr, Them._DeviceName, Them._pRefCount); + return *this; + } + + template + inline CNodeMapRefT::~CNodeMapRefT() + { + Release(); + } + + template + inline void CNodeMapRefT::_Destroy() + { + Release(); + } + + + template + inline void CNodeMapRefT::_LoadXMLFromFile(const GENICAM_NAMESPACE::gcstring &FileName) + { + // FileName environment is replaced in CNodeMapFactory ctor + + // Load the DLL + if(_Ptr) + throw RUNTIME_EXCEPTION("Node map already created"); + + // Load the XML file + CNodeMapFactory nodeMapData(ContentType_Xml, FileName); + Attach(nodeMapData.CreateNodeMap(_DeviceName), _DeviceName, new int(0)); + } + + template + inline void CNodeMapRefT::_LoadXMLFromZIPFile(const GENICAM_NAMESPACE::gcstring &ZipFileName) + { + // FileName environment is replaced in CNodeMapFactory ctor + + // Load the DLL + if(_Ptr) + throw RUNTIME_EXCEPTION("Node map already created"); + + // Load the XML file + CNodeMapFactory nodeMapData(ContentType_ZippedXml, ZipFileName); + Attach(nodeMapData.CreateNodeMap(), _DeviceName, new int(0)); + } + + template + inline void CNodeMapRefT::_LoadXMLFromFileInject(const GENICAM_NAMESPACE::gcstring &TargetFileName, const GENICAM_NAMESPACE::gcstring &InjectFileName) + { + // xxxFileName environment is replaced in CNodeMapFactory ctor + + // Load the DLL + if(_Ptr) + throw RUNTIME_EXCEPTION("Node map already created"); + + // Load the XML file + CNodeMapFactory nodeMapData(ContentType_Xml, TargetFileName); + CNodeMapFactory injectNodeMapData(ContentType_Xml, InjectFileName); + nodeMapData.AddInjectionData(injectNodeMapData); + Attach(nodeMapData.CreateNodeMap(), _DeviceName, new int(0)); + } + + template + inline void CNodeMapRefT::_LoadXMLFromString(const GENICAM_NAMESPACE::gcstring& XMLData) + { + // Load the DLL + if(_Ptr) + throw RUNTIME_EXCEPTION("Node map already created"); + + // Load the XML file + CNodeMapFactory nodeMapData(ContentType_Xml, XMLData.c_str(), XMLData.size()); //avoid string copy + Attach(nodeMapData.CreateNodeMap(_DeviceName), _DeviceName, new int(0)); + } + + + template + inline void CNodeMapRefT::_LoadXMLFromZIPData(const void* zipData, size_t zipSize) + { + // Load the DLL + if(_Ptr) + throw RUNTIME_EXCEPTION("Node map already created"); + + // Load the XML file + CNodeMapFactory nodeMapData(ContentType_ZippedXml, zipData, zipSize); + Attach(nodeMapData.CreateNodeMap(), _DeviceName, new int(0)); + } + + template + inline void CNodeMapRefT::_LoadXMLFromStringInject(const GENICAM_NAMESPACE::gcstring& TargetXMLData, const GENICAM_NAMESPACE::gcstring& InjectXMLData) + { + // Load the DLL + if(_Ptr) + throw RUNTIME_EXCEPTION("Node map already created"); + + // Load the XML file + CNodeMapFactory nodeMapData(ContentType_Xml, TargetXMLData.c_str(), TargetXMLData.size()); //avoid string copy + CNodeMapFactory injectNodeMapData(ContentType_Xml, InjectXMLData.c_str(), InjectXMLData.size()); //avoid string copy + nodeMapData.AddInjectionData(injectNodeMapData); + Attach(nodeMapData.CreateNodeMap(), _DeviceName, new int(0)); + } + + template + inline void CNodeMapRefT::_GetSupportedSchemaVersions(GENICAM_NAMESPACE::gcstring_vector &SchemaVersions) const + { + CNodeMapFactory().GetSupportedSchemaVersions(SchemaVersions); + } + + template + inline GENICAM_NAMESPACE::gcstring CNodeMapRefT::_GetDeviceName() const + { + if(_Ptr) + return _Ptr->GetDeviceName(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + template + inline void CNodeMapRefT::_Poll(int64_t ElapsedTime) + { + if(_Ptr) + return _Ptr->Poll(ElapsedTime); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + template + inline void CNodeMapRefT::_GetNodes(NodeList_t &Nodes) const + { + if(_Ptr) + return _Ptr->GetNodes(Nodes); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + template + inline INode* CNodeMapRefT::_GetNode(const GENICAM_NAMESPACE::gcstring& key) const + { + if(_Ptr) + return _Ptr->GetNode(key); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + template + inline void CNodeMapRefT::_InvalidateNodes() const + { + if(_Ptr) + return _Ptr->InvalidateNodes(); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + template + inline bool CNodeMapRefT::_ParseSwissKnifes( GENICAM_NAMESPACE::gcstring_vector *pErrorList ) const + { + bool ret = false; + if (_Ptr) + ret = _Ptr->ParseSwissKnifes(pErrorList); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + return ret; + } + + template + inline bool CNodeMapRefT::_Connect(IPort* pPort, const GENICAM_NAMESPACE::gcstring& PortName) const + { + if(_Ptr) + return _Ptr->Connect(pPort, PortName); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + template + inline bool CNodeMapRefT::_Connect(IPort* pPort) const + { + if(_Ptr) + return _Ptr->Connect(pPort); + else + throw ACCESS_EXCEPTION("Feature not present (reference not valid)"); + } + + + template + inline bool CNodeMapRefT::_ClearXMLCache() + { + return CNodeMapFactory::ClearCache(); + } + + /** + \brief Empty base class used by class CNodeMapRef as generic template argument + \ingroup GenApi_PublicInterface + */ + class CGeneric_XMLLoaderParams + { + protected: + virtual void _Initialize(GENAPI_NAMESPACE::INodeMap*) {} + }; + + + /** + \brief Smartpointer for NodeMaps with create function + \ingroup GenApi_PublicInterface + \note This class is a simple typedef definition. The class syntax is only used, + because Doxygen has to generate a useful documentation. + */ + class CNodeMapRef : public CNodeMapRefT + { + public: + //! Constructor + CNodeMapRef(const GENICAM_NAMESPACE::gcstring &DeviceName = "Device") + : CNodeMapRefT(DeviceName) + { + } + + //! Constructor + CNodeMapRef(INodeMap* pNodeMap, const GENICAM_NAMESPACE::gcstring &DeviceName = "Device") + : CNodeMapRefT(pNodeMap, DeviceName) + { + } + + //! Copy constructor + CNodeMapRef(const CNodeMapRef& Them) + : CNodeMapRefT(Them) + { + } + + //! Assignment + CNodeMapRef& operator=(const CNodeMapRef& Them) + { + CNodeMapRefT::operator=(Them); + return *this; + } + + //! Assignment of an INodeMap* + CNodeMapRef& operator=(INodeMap* pNodeMap) + { + CNodeMapRefT::operator=(pNodeMap); + return *this; + } + }; + +} + +#endif // ifndef GENAPI_NODEMAPPTR_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Persistence.h b/Cigarette/Pylon6.2/include/GenApi/Persistence.h new file mode 100644 index 0000000..4218638 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Persistence.h @@ -0,0 +1,403 @@ +//----------------------------------------------------------------------------- +// (c) 2007 by National Instruments +// Project: GenApi +// Author: Eric Gross +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IPersistScript and class CFeatureBag +\ingroup GenApi_PublicUtilities +*/ + +#ifndef _GENICAM_PERSISTENCE_H +#define _GENICAM_PERSISTENCE_H + +#include +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + //! Basic interface to persist values to + interface GENAPI_DECL_ABSTRACT IPersistScript + { + //! sets information about the node map + virtual void SetInfo(const GENICAM_NAMESPACE::gcstring &Info) = 0; + + //! Stores a feature + virtual void PersistFeature(IValue& item) = 0; + }; + + //! Bag holding streamable features of a nodetree + class GENAPI_DECL CFeatureBag : public IPersistScript + { + public: + //! sets information about the node map + virtual void SetInfo(const GENICAM_NAMESPACE::gcstring &Info); + + //! Stores a feature + virtual void PersistFeature(IValue& item); + + //! Loads the features from the bag to the node tree + //! \param pNodeMap The node map to load into + //! \param Verify If true, all streamable features are read back + //! \param pErrorList If an error occurs during loading the error message is stored in the list and the loading continues + /*! For Verify=true the list of names in the feature bag is replayed again. + If a node is a selector it's value is set to the value from the feature bag + If not the value is read from the camera and compared with the value from the feature bag. + */ + bool LoadFromBag(INodeMap *pNodeMap, bool Verify = true, GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL); + + /*! \brief Stores the streamable nodes to this feature bag + \param pNodeMap The node map to persist + \param MaxNumPersistSkriptEntries The max number of entries in the container; -1 means unlimited + \param pFeatureFilter List of valid feature; all feature if NULL. + \return number of entries in the bag + */ + int64_t StoreToBag(INodeMap *pNodeMap, const int MaxNumPersistSkriptEntries = -1, GENICAM_NAMESPACE::gcstring_vector *pFeatureFilter = NULL); + + //! compares the content of two feature bags + bool operator==(const CFeatureBag &FeatureBag) const; + + GENICAM_NAMESPACE::gcstring ToString(); + + virtual void Destroy(); + + virtual const GENICAM_NAMESPACE::gcstring& GetBagName( void ) const; + virtual void SetBagName(const GENICAM_NAMESPACE::gcstring& bagName); + + //! fills the bag from a stream + friend std::istream& operator >>(std::istream &is, CFeatureBag &FeatureBag); + + //! puts the bag into a stream + friend std::ostream& operator <<(std::ostream &os, const CFeatureBag &FeatureBag); + + private: + //! The name of the feature bag + GENICAM_NAMESPACE::gcstring m_BagName; + GENICAM_NAMESPACE::gcstring_vector m_Names; + GENICAM_NAMESPACE::gcstring_vector m_Values; + + //! String describing the node map + GENICAM_NAMESPACE::gcstring m_Info; + + bool LoadFromBagInternal(INodeMap *pNodeMap, bool Verify /* = true */, GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL); + int64_t StoreToBagInternal(INodeMap *pNodeMap, const int MaxNumPersistSkriptEntries = -1, GENICAM_NAMESPACE::gcstring_vector *pFeatureFilter = NULL); + + friend class CFeatureBagger; + }; + + //! the magic GUID which indicates that the file or buffer is a GenApi stream created by the CFeatureBag class. Must be the first entry of a file or section. + #define GENAPI_PERSISTENCE_MAGIC "{05D8C294-F295-4dfb-9D01-096BD04049F4}" + + //! the magic GUID which indicates that the file is a GenApi stream file created by the CFeatureBagger class. Must be the first entry of a file. + #define GENAPI_PERSISTENCE_MAGIC_FEATUREBAGGER "{4709CB3C-7322-4460-84C3-DA11DDA09939}" + + //! Helper function ignoring lines starting with comment character '#' + // note: this method must be inlined because it uses istream in the parameter list + inline std::istream& EatComments(std::istream &is) + { + if( is.eof() ) + { + return is; + } + + char FirstCharacter = static_cast(is.peek()); + while( FirstCharacter == '#' ) + { + is.ignore(1024, '\n'); + FirstCharacter = static_cast(is.peek()); + } + return is; + } + +#ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT + //! reads in persistent data from a stream + // note: this method must be inlined because it uses istream in the parameter list + // note: May not be used as inline if called against a library where it is already compiled. + inline std::istream& operator >>(std::istream &is, CFeatureBag &FeatureBag) + { + if( is.eof() ) + { + throw RUNTIME_EXCEPTION("The stream is eof"); + } + + FeatureBag.m_Names.clear(); + FeatureBag.m_Values.clear(); + + const int BufferSize = 1024; + char Buffer[BufferSize] = {0}; + + // Check the magic + is.getline(Buffer, BufferSize, '\n'); + GENICAM_NAMESPACE::gcstring FirstLine(Buffer); + GENICAM_NAMESPACE::gcstring MagicGUID(GENAPI_PERSISTENCE_MAGIC); + if( GENICAM_NAMESPACE::gcstring::_npos() == FirstLine.find(MagicGUID) ) + { + MagicGUID = GENICAM_NAMESPACE::gcstring(GENAPI_PERSISTENCE_MAGIC_FEATUREBAGGER); + if( GENICAM_NAMESPACE::gcstring::_npos() == FirstLine.find(MagicGUID) ) + { + throw RUNTIME_EXCEPTION("The stream is not a GenApi feature stream since it is missing the magic GUID in the first line"); + } + throw RUNTIME_EXCEPTION("The stream has been created using the CFeatureBagger class thus must be restored using the CFeatureBagger class as well"); + } + + EatComments( is ); + char Name[BufferSize] = {0}; + GENICAM_NAMESPACE::gcstring Value(""); + while( !is.eof() ) + { + is.getline(Name, BufferSize, '\t'); + if (is.fail()) // if reading from stream failed -> stop reading! + { + break; + } + GENICAM_NAMESPACE::getline(is, Value); + if (is.fail()) // if reading from stream failed -> stop reading! + { + break; + } + FeatureBag.m_Names.push_back(Name); + FeatureBag.m_Values.push_back(Value); + + Name[0] = '\0'; + Value = ""; + EatComments( is ); + } + return is; + } + + //! writes out persistent data to a stream + // note: this method must be inlined because it uses ostream in the parameter list + // note: May not be used as inline if called against a library where it is already compiled. + inline std::ostream& operator <<(std::ostream &os, const CFeatureBag &FeatureBag) + { + os << "# " GENAPI_PERSISTENCE_MAGIC "\n"; + if( !FeatureBag.m_Info.empty() ) + { + os << "# GenApi persistence file (version " << GENAPI_VERSION_MAJOR << "." << GENAPI_VERSION_MINOR << "." << GENAPI_VERSION_SUBMINOR << ")\n"; + os << "# " << FeatureBag.m_Info << "\n"; + } + + // This can actually never happen the way the code is written right now, but... + assert(FeatureBag.m_Names.size() == FeatureBag.m_Values.size()); + + GENICAM_NAMESPACE::gcstring_vector::const_iterator pName = FeatureBag.m_Names.begin(); + GENICAM_NAMESPACE::gcstring_vector::const_iterator pValue = FeatureBag.m_Values.begin(); + const GENICAM_NAMESPACE::gcstring_vector::const_iterator endNames = FeatureBag.m_Names.end(); + for( ; pName != endNames; ++pName, ++pValue ) + { + const GENICAM_NAMESPACE::gcstring Name(*pName); + const GENICAM_NAMESPACE::gcstring Value(*pValue); + os << Name << "\t" << Value << "\n"; + } + + return os; + } +#endif // #ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT + + //! Class use to bag features + class GENAPI_DECL CFeatureBagger + { + public: + class GENAPI_DECL const_iterator + { + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + const_iterator(CFeatureBag **ppBag = NULL); + + // Operators + // ------------------------------------------------------------------------- + public: + const CFeatureBag & operator * (void) const; + const CFeatureBag * operator -> (void) const; + const_iterator & operator ++ (void); + const_iterator operator ++ (int); + const_iterator & operator += (intptr_t iInc); + const_iterator operator + (intptr_t iInc) const; + intptr_t operator - (const const_iterator &iter) const; + bool operator == (const const_iterator &iter) const; + bool operator != (const const_iterator &iter) const; + + // Member + // ------------------------------------------------------------------------- + protected: + CFeatureBag **_ppb; + }; + explicit CFeatureBagger(); + virtual ~CFeatureBagger(); + + /*! \brief Stores the streamable nodes to this feature bags in different device configurations + \param handleDefaultNodeMap Stores the current nodemap if True + \param handleUserSets Store all user sets if True + \param handleSequencerSets Store all sequencer sets if True + \param pNodeMap The node map to persist + \param MaxNumPersistSkriptEntries The max number of entries in the container. -1 means unlimited + \return number of bags + */ + size_t Bag(INodeMap *pNodeMap, bool handleDefaultNodeMap = true, bool handleUserSets = false, bool handleSequencerSets = false, const int MaxNumPersistSkriptEntries = -1); + + //! Loads the features from the bag to the node tree + //! \param Verify If true, all streamable features are read back + //! \param pErrorList If an error occurs during loading the error message is stored in the list and the loading continues + /*! For Verify=true the list of names in the feature bag is replayed again. + If a node is a selector it's value is set to the value from the feature bag + If not the value is read from the camera and compared with the value from the feature bag. + */ + bool UnBag(INodeMap *pNodeMap, bool Verify = true, GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL); + + //! sets information about the node map + virtual void SetInfo(const GENICAM_NAMESPACE::gcstring &Info); + + // Element access + // --------------------------------------------------------------------------- + virtual const_iterator begin(void) const; + virtual const_iterator end(void) const; + virtual const CFeatureBag& at(size_t uiIndex) const; + virtual size_t size(void) const; + + //! puts the bags into a stream + friend std::ostream& operator <<(std::ostream &os, const CFeatureBagger &featureBagger); + + //! reads the bags from a stream + friend std::istream& operator >>(std::istream &is, CFeatureBagger &featureBagger); + + private: + CFeatureBag& AddBag(const GENICAM_NAMESPACE::gcstring &bagName); + void DeleteAllBags( void ); + template + void UnBagCustomAction(INodeMap *pNodeMap, _Ty setNodePtr, const GENICAM_NAMESPACE::gcstring& setNodeValue, CCommandPtr saveNodePtr ); + void *m_pBags; + //! String describing the node map + GENICAM_NAMESPACE::gcstring m_Info; + }; + +#ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT + //! writes out persistent data to a stream + // note: this method must be inlined because it uses ostream in the parameter list + // note: May not be used as inline if called against a library where it is already compiled. + inline std::ostream& operator <<(std::ostream &os, const CFeatureBagger &featureBagger) + { + os << "# " GENAPI_PERSISTENCE_MAGIC_FEATUREBAGGER "\n"; + if( !featureBagger.m_Info.empty() ) + { + os << "# GenApi CFeatureBagger persistence file (version " << GENAPI_VERSION_MAJOR << "." << GENAPI_VERSION_MINOR << "." << GENAPI_VERSION_SUBMINOR << ")\n"; + os << "# " << featureBagger.m_Info << "\n"; + } + + CFeatureBagger::const_iterator it; + for (it = featureBagger.begin(); it != featureBagger.end(); it++) + { + os << "[" << (*it).GetBagName() << "]\n"; + os << (*it); + } + + return os; + } + + //! reads back persistent data from a stream + // note: this method must be inlined because it uses istream in the parameter list + // note: May not be used as inline if called against a library where it is already compiled. + inline std::istream& operator >> (std::istream &is, CFeatureBagger &featureBagger) + { + if (is.eof()) + { + throw RUNTIME_EXCEPTION("The stream is eof"); + } + + // Check the magic + const int BufferSize = 1024; + char Buffer[BufferSize] = { 0 }; + is.getline(Buffer, BufferSize, '\n'); + GENICAM_NAMESPACE::gcstring FirstLine(Buffer); + GENICAM_NAMESPACE::gcstring MagicGUID(GENAPI_PERSISTENCE_MAGIC_FEATUREBAGGER); + bool boCFeatureBagFormatDetected = false; + if( GENICAM_NAMESPACE::gcstring::_npos() == FirstLine.find(MagicGUID) ) + { + MagicGUID = GENICAM_NAMESPACE::gcstring(GENAPI_PERSISTENCE_MAGIC); + if( GENICAM_NAMESPACE::gcstring::_npos() == FirstLine.find(MagicGUID) ) + { + throw RUNTIME_EXCEPTION("The stream is not a GenApi feature stream since it is missing the magic GUID in the first line"); + } + boCFeatureBagFormatDetected = true; + } + + std::stringstream currentBagData; + if (boCFeatureBagFormatDetected) + { + currentBagData << FirstLine; + } + else + { + EatComments( is ); + } + + featureBagger.DeleteAllBags(); + // Allow to digest the 'CFeatureBag' format using the 'CFeatureBagger' class! + CFeatureBag *pBag = boCFeatureBagFormatDetected ? &featureBagger.AddBag("All") : NULL; + + while (!is.eof()) + { + GENICAM_NAMESPACE::gcstring line; + GENICAM_NAMESPACE::getline(is, line); + if (is.fail()) // if reading from stream failed -> stop reading! + { + break; + } + if (!line.empty() && (line[0] == '[')) + { + if (!currentBagData.str().empty()) + { + if (pBag) + { + currentBagData >> (*pBag); + } + currentBagData.str(""); + currentBagData.clear(); + pBag = NULL; + } + // this is the beginning of a new section + const size_t pos = line.find_first_of("]"); + const GENICAM_NAMESPACE::gcstring bagName(line.substr(1, pos - 1)); + if( !bagName.empty() ) + { + pBag = &featureBagger.AddBag(bagName); + } + } + else + { + currentBagData << line << "\n"; + } + } + if (!currentBagData.str().empty() && pBag) + { + currentBagData >> (*pBag); + } + return is; + } +#endif // #ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT +} + +#endif //_GENICAM_PERSISTENCE_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Pointer.h b/Cigarette/Pylon6.2/include/GenApi/Pointer.h new file mode 100644 index 0000000..4da57af --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Pointer.h @@ -0,0 +1,340 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of template CPointer +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_POINTER_H +#define GENAPI_POINTER_H + +#include +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // CPointer class + //************************************************************* + + /** + \brief Encapsulates a GenApi pointer dealing with the dynamic_cast automatically + \ingroup GenApi_PublicUtilities + */ + template + class CPointer + { + + public: + //! Default constructor. + CPointer(void) throw() + : m_pT( NULL ) + { + } + + //! Constructor from INode pointer type. + CPointer( B *pB ) + : m_pT( dynamic_cast(pB) ) + { + } + + virtual ~CPointer(void) + { + } + + //! Assign INode Pointer + void operator=( B *pB ) + { + m_pT = dynamic_cast(pB); + } + + //! Dereferencing + operator T*(void) const + { + if (NULL == m_pT) + throw LOGICAL_ERROR_EXCEPTION( "NULL pointer dereferenced" ); + return m_pT; + } + + //! Dereferencing + T& operator*(void) const + { + if (NULL == m_pT) + throw LOGICAL_ERROR_EXCEPTION( "NULL pointer dereferenced" ); + return *m_pT; + } + + //! Dereferencing + T& operator()(void) const + { + if (NULL == m_pT) + throw LOGICAL_ERROR_EXCEPTION( "NULL pointer dereferenced" ); + return *m_pT; + } + + //! Dereferencing + T* operator->(void) const + { + if (NULL == m_pT) + throw LOGICAL_ERROR_EXCEPTION( "NULL pointer dereferenced" ); + return m_pT; + } + + //! true if the pointer is valid + bool IsValid() const throw() + { + return m_pT != NULL; + } + + //! true if the pointer is valid + operator bool(void) const throw() + { + return m_pT != NULL; + } + + //! pointer equal + bool operator==(T* pT) const + { + return m_pT == pT; + } + + //! pointer equal + bool operator==(const CPointer &rT) const + { + return m_pT == rT.m_pT; + } + + //! pointer equal + bool operator==(int nMustBeNull) const + { + if (0 != nMustBeNull) + throw LOGICAL_ERROR_EXCEPTION( "argument must be NULL" ); + return NULL == m_pT; + } + + + protected: + + //! Underlying raw pointer. + T* m_pT; + }; + + //************************************************************* + // Smartpointer for all interface + //************************************************************* + + //! \addtogroup GenApi_PublicUtilities + //! \{ + + //! SmartPointer for IBase interface pointer + typedef CPointer CBasePtr; + + //! SmartPointer for INode interface pointer + typedef CPointer CNodePtr; + + //! SmartPointer for IValue interface pointer + typedef CPointer CValuePtr; + + //! SmartPointer for ICategory interface pointer + typedef CPointer CCategoryPtr; + + //! SmartPointer for IBoolean interface pointer + typedef CPointer CBooleanPtr; + + //! SmartPointer for IInteger interface pointer + typedef CPointer CIntegerPtr; + + //! SmartPointer for IString interface pointer + typedef CPointer CStringPtr; + + //! SmartPointer for IRegister interface pointer + typedef CPointer CRegisterPtr; + + //! SmartPointer for IEnumeration interface pointer + typedef CPointer CEnumerationPtr; + + //! SmartPointer for IEnumEntry interface pointer + typedef CPointer CEnumEntryPtr; + + //! SmartPointer for IPort interface pointer + typedef CPointer CPortPtr; + + //! SmartPointer for IPortReplay interface pointer + typedef CPointer CPortReplayPtr; + + //! SmartPointer for IPortRecorder interface pointer + typedef CPointer CPortRecorderPtr; + + //! SmartPointer for IPortWriteList interface pointer + typedef CPointer CPortWriteListPtr; + + //! SmartPointer for IChunkPort interface pointer + typedef CPointer CChunkPortPtr; + + //! SmartPointer for INodeMap interface pointer + typedef CPointer CNodeMapPtr; + + //! SmartPointer for IDeviceInfo interface pointer + typedef CPointer CDeviceInfoPtr; + + //! SmartPointer for IUserData interface pointer + typedef CPointer CNodeMapUserDataPtr; + //! SmartPointer for IUserData interface pointer + typedef CPointer CNodeUserDataPtr; + + //! SmartPointer for ISelector interface pointer + typedef CPointer CSelectorPtr; + + //! SmartPointer for ICommand interface pointer + typedef CPointer CCommandPtr; + + //! SmartPointer for IFloat interface pointer + class CFloatPtr : public CPointer + { + public: + //! Default constructor. + CFloatPtr() throw() + : CPointer( ) + { + } + + //! Constructor from IBase pointer type. + CFloatPtr( IBase *pB ) + : CPointer( pB ) + { + } + + //! Assign IBase Pointer + void operator=( IBase *pB ) + { + CPointer::operator =(pB); + } + + //! gets the interface of an integer alias node. + IInteger *GetIntAlias() + { + return dynamic_cast(m_pT->GetNode()->GetCastAlias()); + } + + //! gets the interface of an enum alias node. + IEnumeration *GetEnumAlias() + { + return dynamic_cast(m_pT->GetNode()->GetCastAlias()); + } + }; + + //! \} + + //! \addtogroup GenApi_PublicImpl + //! \{ + + //! SmartPointer for IPortConstruct interface pointer + typedef CPointer CPortConstructPtr; + + + //! Returns the name of the main interface as string + //! DEPRECATED, use IBase::GetPrincipalInterfaceType() instead + inline GENICAM_NAMESPACE::gcstring GetInterfaceName(IBase *pBase) + { +# ifdef _MSC_VER +# pragma warning (push) // icc -W4 complains: controlling expression is constant +# pragma warning (disable : 279) +# endif + assert(pBase && "don't call this with a NULL pointer"); +# ifdef _MSC_VER +# pragma warning (pop) +# endif + CNodePtr ptrNode(pBase); + switch(ptrNode->GetPrincipalInterfaceType()) + { + case intfIValue: + return GENICAM_NAMESPACE::gcstring("IValue"); + case intfIInteger: + return GENICAM_NAMESPACE::gcstring("IInteger"); + case intfIBoolean: + return GENICAM_NAMESPACE::gcstring("IBoolean"); + case intfICommand: + return GENICAM_NAMESPACE::gcstring("ICommand"); + case intfIFloat: + return GENICAM_NAMESPACE::gcstring("IFloat"); + case intfIString: + return GENICAM_NAMESPACE::gcstring("IString"); + case intfIRegister: + return GENICAM_NAMESPACE::gcstring("IRegister"); + case intfICategory: + return GENICAM_NAMESPACE::gcstring("ICategory"); + case intfIEnumeration: + return GENICAM_NAMESPACE::gcstring("IEnumeration"); + case intfIEnumEntry: + return GENICAM_NAMESPACE::gcstring("IEnumEntry"); + case intfIPort: + return GENICAM_NAMESPACE::gcstring("IPort"); +// Do not use this pragma in public header files (warnings in depend projects): #pragma BullseyeCoverage off + case intfIBase: + default: + return GENICAM_NAMESPACE::gcstring("IBase"); +// Do not use this pragma in public header files (warnings in depend projects): #pragma BullseyeCoverage on + } + } + + //! Checks if a node is readable + template + inline bool IsReadable( const CPointer& ptr) + { + return ptr.IsValid() && IsReadable( ptr->GetAccessMode() ); + } + + //! Checks if a node is Writable + template + inline bool IsWritable( const CPointer& ptr) + { + return ptr.IsValid() && IsWritable( ptr->GetAccessMode() ); + } + + //! Checks if a node is Implemented + template + inline bool IsImplemented( const CPointer& ptr) + { + return ptr.IsValid() && IsImplemented( ptr->GetAccessMode() ); + } + + //! Checks if a node is Available + template + inline bool IsAvailable( const CPointer& ptr) + { + return ptr.IsValid() && IsAvailable( ptr->GetAccessMode() ); + } + + + //! \} + + +} + +#endif // ifndef GENAPI_POINTER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/PortImpl.h b/Cigarette/Pylon6.2/include/GenApi/PortImpl.h new file mode 100644 index 0000000..72294c4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/PortImpl.h @@ -0,0 +1,143 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of CPortImpl +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_PORTIMPL_H +#define GENAPI_PORTIMPL_H + +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4251 ) // enApi::CPortImpl::m_ptrPort' : class 'GenApi::CPointer' needs to have dll-interface +# pragma warning( disable : 4275 ) // DLL interface (this is a bug) +# pragma warning( disable : 4068 ) // unknown pragma; refers to BullsEyeCoverage +#endif + +namespace GENAPI_NAMESPACE +{ + //************************************************************* + // CPortImpl class + //************************************************************* + + /** + \brief Standard implementation for a port + //! \ingroup GenApi_PublicUtilities + */ + class CPortImpl : public IPortConstruct, public IPortReplay + { + public: + //! Constructor + CPortImpl() + { + } + + //! Destructor + virtual ~CPortImpl() + { + } + + /*---------------------------------------------------------------*/ + // IBase ==> You need to override this method + /*---------------------------------------------------------------*/ + + //! Get the access mode of the node + /*! Driver closed => NI, Driver open => RW, analysing a struct, RO */ + virtual EAccessMode GetAccessMode() const = 0; + + /*---------------------------------------------------------------*/ + // IPort ==> You need to override these methods + /*---------------------------------------------------------------*/ + + //! Reads a chunk of bytes from the port + virtual void Read(void *pBuffer, int64_t Address, int64_t Length) = 0; + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) = 0; + + /*---------------------------------------------------------------*/ + // IPortConstruct implementation (without IPort & IBase) + /*---------------------------------------------------------------*/ + + //! Sets pointer the real port implementation; this function may called only once + virtual void SetPortImpl(IPort* pPort) + { + m_ptrPort = pPort; + assert(m_ptrPort.IsValid()); + } + + //! Determines if the port adapter must perform an endianess swap + virtual EYesNo GetSwapEndianess() + { + return No; + } + + + //--------------------------------------------------------------- + // IPortReplay implementation + //--------------------------------------------------------------- + + //! sends the commands to the camera. + /*! the default implementation just walks the list and issues each command + using the WriteRegister method. Depending on the capabilities of + the transport layer the implementation can however use a special command + which sends all register write commands as one package. + */ + virtual void Replay( IPortWriteList *pPortRecorder, bool Invalidate = true ) + { + if(pPortRecorder) + pPortRecorder->Replay(this); + + if(Invalidate) + InvalidateNode(); + } + + // Invalidate the node + void InvalidateNode() + { + if(m_ptrPort.IsValid()) + m_ptrPort->InvalidateNode(); + } + + private: + //! Pointer to the node holding a reference to this implementation + CNodePtr m_ptrPort; + + }; +} + +#ifdef _MSC_VER +# pragma warning(pop) +#endif +#endif // ifndef GENAPI_PORTIMPL_H diff --git a/Cigarette/Pylon6.2/include/GenApi/PortWriteList.h b/Cigarette/Pylon6.2/include/GenApi/PortWriteList.h new file mode 100644 index 0000000..0775ada --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/PortWriteList.h @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// (c) 2009 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of interface IPort +\ingroup GenApi_PublicInterface +*/ + +#ifndef GENAPI_PORTWRITELIST_H +#define GENAPI_PORTWRITELIST_H + +#include +#include + +#ifdef _MSC_VER +# pragma warning ( push ) +# pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY +#endif + +namespace GENAPI_NAMESPACE +{ + + //! Container holding a list of port write commands + class GENAPI_DECL CPortWriteList : public IPortWriteList + { + public: + //! Constructor + CPortWriteList(); + + //! Destructor + ~CPortWriteList(); + + /*---------------------------------------------------------------*/ + // IPortWriteList + /*---------------------------------------------------------------*/ + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length); + + //! Replays the write command to the given port interface + virtual void Replay(IPort* pPort); + + //! Sets a cookie in case the port implementation want to cache a command list + // Default = -1 + virtual void SetCookie(const int64_t Value); + + //! Gets the cookie a port implementation may have set for caching a command list + virtual int64_t GetCookie(); + + protected: + //! The data associated with a write command + typedef struct + { + int64_t Address; + int64_t Length; + char *pData; + } WriteCommand_t; + + //! a list holding the write commands + std::list *m_pWriteCommands; + + //! A cookie helper for caching + int64_t m_Cookie; + }; + +} + +#ifdef _MSC_VER +# pragma warning ( pop ) +#endif + +#endif // ifndef GENAPI_PORTWRITELIST_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Reference.h b/Cigarette/Pylon6.2/include/GenApi/Reference.h new file mode 100644 index 0000000..a5fd6de --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Reference.h @@ -0,0 +1,106 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of template CReference +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPI_REFERENCE_H +#define GENAPI_REFERENCE_H + +#include +#include + +namespace GENAPI_NAMESPACE +{ + interface IBase; + + //************************************************************* + // IReference interface + //************************************************************* + + /** + \brief Interface to construct a reference + \ingroup GenApi_PublicImpl + */ + interface GENAPI_DECL_ABSTRACT IReference + { + //! sets the implementation to a reference + virtual void SetReference( GENAPI_NAMESPACE::IBase *pBase ) = 0; + }; + + //************************************************************* + // IEnumReference interface + //************************************************************* + + /** + \brief Interface to construct an enum reference + \ingroup GenApi_PublicImpl + */ + interface GENAPI_DECL_ABSTRACT IEnumReference + { + //! sets the Enum value corresponding to a value + virtual void SetEnumReference( int Index, GENICAM_NAMESPACE::gcstring Name) = 0; + + //! sets the number of enum vallues + virtual void SetNumEnums( int NumEnums ) = 0; + }; + + //************************************************************* + // CReference class + //************************************************************* + + /** + \brief Reference to an IBase derived pointer + \ingroup GenApi_PublicImpl + */ + template + class CReferenceT : public T, public IReference + { + public: + // Constructor + CReferenceT() : + m_Ptr(NULL) + {} + + /*--------------------------------------------------------*/ + // IReference + /*--------------------------------------------------------*/ + + //! sets the implementation to the reference + virtual void SetReference( IBase *ptr ) + { + m_Ptr = dynamic_cast( ptr ); + } + + protected: + //! Pointer to the implementation the reference references to + I *m_Ptr; + }; + +} + +#endif // ifndef GENAPI_REFERENCE_H diff --git a/Cigarette/Pylon6.2/include/GenApi/RegisterSetHelper.h b/Cigarette/Pylon6.2/include/GenApi/RegisterSetHelper.h new file mode 100644 index 0000000..e0f085f --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/RegisterSetHelper.h @@ -0,0 +1,84 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Alexander Happe / Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! + \file + \brief Definition of CRegisterSetHelper + \ingroup GenApi_PublicUtilities +*/ + + +#ifndef REGISTER_SET_HELPER_H +#define REGISTER_SET_HELPER_H + +namespace GENAPI_NAMESPACE +{ + /** + \brief Copies data from buffer to variables in a typesafe manner + \ingroup GenApi_PublicUtilities + */ + class GENAPI_DECL CRegisterSetHelper + { + public: + //! memcpy firing exceptions + static size_t CopyData( void *pvDestination, size_t nbyDestSize, const void *pvSource, size_t nbySourceSize ) + { + if (nbyDestSize != nbySourceSize) + { + throw OUT_OF_RANGE_EXCEPTION("CopyData : Destination size (%ld) does not fit source size (%d)", nbyDestSize, nbySourceSize); + } + +#if defined(_WINDOWS_) + if ( IsBadWritePtr(pvDestination, nbyDestSize) || IsBadReadPtr(pvSource, nbySourceSize) ) + { + throw RUNTIME_EXCEPTION("Invalid user buffer"); + } +#endif + + memcpy( pvDestination, pvSource, nbySourceSize ); + return nbySourceSize; + } + + /** + \brief Typesafe copy from variable to buffer + */ + template + static size_t CopyToBuffer( void *pvDestination, size_t nbyDestSize, T *d ) + { + return CopyData( pvDestination, nbyDestSize, d, sizeof( *d ) ); + } + + /** + \brief Typesafe copy from buffer to variable + */ + template + static size_t CopyFromBuffer( T *d, const void *pvDestination, size_t nbyDestSize) + { + return CopyData( d, sizeof( *d ), pvDestination, nbyDestSize); + } + }; + +} // namespace GenApi + +#endif // ifndef REGISTER_SET_HELPER_H diff --git a/Cigarette/Pylon6.2/include/GenApi/SelectorSet.h b/Cigarette/Pylon6.2/include/GenApi/SelectorSet.h new file mode 100644 index 0000000..5da72a7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/SelectorSet.h @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------------- +// (c) 2010 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +*/ + +#ifndef GENAPI_SELECTORSET_H +#define GENAPI_SELECTORSET_H + +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + //! The set of selectors selecting a given node + class GENAPI_DECL CSelectorSet : public ISelectorDigit + { + public: + //! Constructor + CSelectorSet ( + IBase *pBase //!> Feature selected by the selector set + ); + + //! Destructor + virtual ~CSelectorSet(); + + //! returns true if no selectors are present + bool IsEmpty(); + + + // Implementation of ISelectorDigit + public: + virtual bool SetFirst(); + virtual bool SetNext(bool Tick = true); + virtual void Restore(); + virtual GENICAM_NAMESPACE::gcstring ToString(); + virtual void GetSelectorList( GENAPI_NAMESPACE::FeatureList_t &SelectorList, bool Incremental = false ); + + private: + struct SelectorIteratorList_t; + //! List of selector digits + SelectorIteratorList_t *m_pSelectorIterators; + + //! recursively explores the selectors and sub selectors of a node + void ExploreSelector( + CNodePtr &ptrNode, //!> The node to explore + NodeList_t &SelectorNodes //!> ordered list of elector names (LSB first, MSB last) + ); + + //! Creates the selector counter + void Create( + IBase* pBase //!> the node to create the selector set for + ); + }; + +} +#endif + diff --git a/Cigarette/Pylon6.2/include/GenApi/StructPort.h b/Cigarette/Pylon6.2/include/GenApi/StructPort.h new file mode 100644 index 0000000..6f02345 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/StructPort.h @@ -0,0 +1,140 @@ +//----------------------------------------------------------------------------- +// (c) 2009 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- + +/*! +\file +*/ + + +#ifndef __STRUCTPORT_H +#define __STRUCTPORT_H + +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + //! Implements a register spaces based on a C++ struct + template + class CTestPortStruct : public CDataStruct, public GENAPI_NAMESPACE::CPortImpl + { + public: + CTestPortStruct(int64_t BaseAddress = 0) + : m_BaseAddress(BaseAddress) + { + MemSet(0); + ResetStatistics(); + } + + //------------------------------------------------------------- + // IBase implementation + //------------------------------------------------------------- + + //! Get the access mode of the node + virtual GENAPI_NAMESPACE::EAccessMode GetAccessMode() const + { + return RW; + } + + //! Get the type of the main interface of a node + virtual GENAPI_NAMESPACE::EInterfaceType GetPrincipalInterfaceType() const + { + return intfIPort; + } + + //--------------------------------------------------------------- + // IPort implementation + //--------------------------------------------------------------- + + //! Reads a chunk of bytes from the port + virtual void Read(void *pBuffer, int64_t Address, int64_t Length) + { + int64_t InternalAddress = Address - m_BaseAddress; + + CDataStruct *pDataStruct = static_cast(this); + if( InternalAddress < 0 || Length < 0 || InternalAddress + Length > sizeof(CDataStruct) ) + throw RUNTIME_EXCEPTION("CTestPortStruct::Read - Invalid address and/or length"); + memcpy( pBuffer, (uint8_t*)pDataStruct + InternalAddress, (size_t)Length ); + m_NumReads++; + } + + //! Writes a chunk of bytes to the port + virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) + { + int64_t InternalAddress = Address - m_BaseAddress; + + CDataStruct *pDataStruct = static_cast(this); + if( InternalAddress < 0 || Length < 0 || InternalAddress + Length > sizeof(CDataStruct) ) + throw RUNTIME_EXCEPTION("CTestPortStruct::Write - Invalid address and/or length"); + memcpy( (uint8_t*)pDataStruct + InternalAddress, pBuffer, (size_t)Length ); + m_NumWrites++; + } + + //------------------------------------------------------------- + // Utility functions + //------------------------------------------------------------- + + void MemSet( const char FillValue ) + { + memset( static_cast(this), FillValue, sizeof(CDataStruct) ); + } + + //------------------------------------------------------------- + // Statistics functions + //------------------------------------------------------------- + + //! Resets the read/write statistics + void ResetStatistics() + { + m_NumReads = 0; + m_NumWrites = 0; + } + + //! Returns the number of reads since lastReset Statistics + int64_t GetNumReads() + { + return m_NumReads; + } + + //! Returns the number of writes since lastReset Statistics + int64_t GetNumWrites() + { + return m_NumWrites; + } + + protected: + //! Number of reads since last reset + int64_t m_NumReads; + + //! Number of writes since last reset + int64_t m_NumWrites; + + //! the base address used for the struct + int64_t m_BaseAddress; + }; +} + +#endif // __STRUCTPORT_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Synch.h b/Cigarette/Pylon6.2/include/GenApi/Synch.h new file mode 100644 index 0000000..2f4933f --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Synch.h @@ -0,0 +1,206 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Hartmut Nebelung +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of Lock classes +\ingroup GenApi_PublicImpl +*/ + +#ifndef GENAPI_SYNCH_H +#define GENAPI_SYNCH_H + +#include +#include + +#if defined (_WIN32) +# include +# include +#elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) +# include +# include +# include +#elif defined(VXWORKS) + #include + #include + #include +#else +# error No/unknown platform thread support +#endif + +namespace GENAPI_NAMESPACE +{ + + //----------------------------------------------------------------- + // CLock + //----------------------------------------------------------------- + + /** + \brief A lock class + \ingroup GenApi_PublicImpl + */ + class GENAPI_DECL CLock + { + public: + //! Constructor + CLock(); + + //! Destructor + ~CLock(); + + //! tries to enter the critical section; returns true if successful + bool TryLock(); + + //! enters the critical section (may block) + void Lock(); + + //! leaves the critical section + void Unlock(); + + private: + //! no copy constructor + CLock( const CLock& ); + + //! no assignment operator + CLock& operator=( const CLock& ); + + protected: + +#if defined (_WIN32) + //! The critical section object + CRITICAL_SECTION m_csObject; +#elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) + //! the mutex object + pthread_mutex_t m_mtxObject; +#elif defined(VXWORKS) + SEM_ID m_sem; +#else +# error No/unknown platform thread support +#endif + + }; + + + //! This class is for testing purposes only. It should not be used for + //! client code because it exists only for Windows but not for Linux + //! since it uses internal data structures of a Win32 object + class GENAPI_DECL CLockEx : public CLock + { + public: + +# if defined (_WIN32) + + //! Gives access to internal data member for test and purposes + int64_t GetLockCount(); + + //! Gives access to internal data member for test and purposes + int64_t GetRecursionCount(); + +# elif defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__) || defined(VXWORKS)) + // nothing implemented for Unix +# else +# error No/unknown platform support +# endif + + private: + //! no copy constructor + CLockEx( const CLockEx& ); + + //! no assignment operator + CLockEx& operator=( const CLockEx& ); + + }; + + + //----------------------------------------------------------------- + // AutoLock + //----------------------------------------------------------------- + class AutoLock + { + CLock& m_Lock; + public: + AutoLock(CLock& lock) + : m_Lock(lock) + { + m_Lock.Lock(); + } + + ~AutoLock() + { + m_Lock.Unlock(); + } + + private: + AutoLock& operator=(const AutoLock&); + AutoLock(const AutoLock&); + }; + + + //----------------------------------------------------------------- + // template LockableObject + //----------------------------------------------------------------- + + /** + \brief Instance-Lock for an object + \ingroup GenApi_PublicImpl + */ + template< class Object> + class LockableObject + { + public: + mutable CLock m_Lock; + + class Lock; + friend class Lock; + + /*! A scopelevel Lock class. + * Automatically acquires the lock when created and releases + * it when destroyed. + */ + class Lock + { + /// Reference to outer object + const LockableObject &m_Object; + public: + Lock( const LockableObject& obj) : m_Object(obj) { + m_Object.m_Lock.Lock(); + } + + ~Lock(){ + m_Object.m_Lock.Unlock(); + } + private: + Lock& operator=( const Lock& ); + }; + + /// Get a new lock + Lock GetLock() const + { + return Lock( *this ); + } + }; + +} // namespace GenApi + +#endif // GENAPI_SYNCH_H diff --git a/Cigarette/Pylon6.2/include/GenApi/Types.h b/Cigarette/Pylon6.2/include/GenApi/Types.h new file mode 100644 index 0000000..285d9fe --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenApi/Types.h @@ -0,0 +1,248 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenApi +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief Common types used in the public GenApi interface. +\ingroup GenApi_PublicUtilities +*/ + +#ifndef GENAPI_TYPES_H +#define GENAPI_TYPES_H + +#include +#include +#include +#include +#include + +namespace GENAPI_NAMESPACE +{ + + //! signed or unsigned integers + //! \ingroup GenApi_PublicUtilities + typedef enum _ESign + { + Signed, //!< Integer is signed + Unsigned, //!< Integer is unsigned + _UndefinedSign //!< Object is not yet initialized + } ESign; + + //! access mode of a node + //! \ingroup GenApi_PublicUtilities + typedef enum _EAccessMode + { + NI, //!< Not implemented + NA, //!< Not available + WO, //!< Write Only + RO, //!< Read Only + RW, //!< Read and Write + _UndefinedAccesMode, //!< Object is not yet initialized + _CycleDetectAccesMode //!< used internally for AccessMode cycle detection + + } EAccessMode; + + //! recommended visibility of a node + //! \ingroup GenApi_PublicUtilities + typedef enum _EVisibility + { + Beginner = 0, //!< Always visible + Expert = 1, //!< Visible for experts or Gurus + Guru = 2, //!< Visible for Gurus + Invisible = 3, //!< Not Visible + _UndefinedVisibility = 99 //!< Object is not yet initialized + } EVisibility; + + //! caching mode of a register + //! \ingroup GenApi_PublicUtilities + typedef enum _ECachingMode + { + NoCache, //!< Do not use cache + WriteThrough, //!< Write to cache and register + WriteAround, //!< Write to register, write to cache on read + _UndefinedCachingMode //!< Not yet initialized + } ECachingMode; + + //! recommended representation of a node value + //! \ingroup GenApi_PublicUtilities + typedef enum _ERepresentation + { + Linear, //!< Slider with linear behavior + Logarithmic, //!< Slider with logarithmic behaviour + Boolean, //!< Check box + PureNumber, //!< Decimal number in an edit control + HexNumber, //!< Hex number in an edit control + IPV4Address, //!< IP-Address + MACAddress, //!< MAC-Address + _UndefinedRepresentation + } ERepresentation; + +// this define is required to deal with a spelling error corrected in v1.2 +#ifndef NO_UNDEFINEDED_REPRESENTATION +# define _UndefindedRepresentation _UndefinedRepresentation +#endif + + //! Endianess of a value in a register + //! \ingroup GenApi_PublicUtilities + typedef enum _EEndianess + { + BigEndian, //!< Register is big endian + LittleEndian, //!< Register is little endian + _UndefinedEndian //!< Object is not yet initialized + } EEndianess; + + + //! Defines if a node name is standard or custom + //! \ingroup GenApi_PublicUtilities + typedef enum _ENameSpace + { + Custom, //!< name resides in custom namespace + Standard, //!< name resides in one of the standard namespaces + _UndefinedNameSpace //!< Object is not yet initialized + } ENameSpace; + + + //! Defines from which standard namespace a node name comes from + //! \ingroup GenApi_PublicUtilities + typedef enum _EStandardNameSpace + { + None, //!< name resides in custom namespace + GEV, //!< name resides in GigE Vision namespace + IIDC, //!< name resides in 1394 IIDC namespace + CL, //!< name resides in camera link namespace + USB, //!< name resides in USB namespace + _UndefinedStandardNameSpace //!< Object is not yet initialized + } EStandardNameSpace; + + + //! Defines the choices of a Yes/No alternatives + //! \ingroup GenApi_PublicUtilities + typedef enum _EYesNo + { + Yes = 1, //!< yes + No = 0, //!< no + _UndefinedYesNo = 2 //!< Object is not yet initialized + } EYesNo; + + //! A list of strings + //! \ingroup GenApi_PublicImpl + typedef GENICAM_NAMESPACE::gcstring_vector StringList_t; + + + //! typedef for formula type + //! \ingroup GenApi_PublicImpl + typedef enum _ESlope + { + Increasing, //!< strictly monotonous increasing + Decreasing, //!< strictly monotonous decreasing + Varying, //!< slope changes, e.g. at run-time + Automatic, //!< slope is determined automatically by probing the function + _UndefinedESlope //!< Object is not yet initialized + } ESlope; + + //! typedef describing the different validity checks which can be performed on an XML file + /*! The enum values for a bitfield of length uint32_t */ + //! \ingroup GenApi_PublicImpl + typedef enum _EXMLValidation + { + xvLoad = 0x00000001L, //!< Creates a dummy node map + xvCycles = 0x00000002L, //!< checks for write and dependency cycles (implies xvLoad) + xvSFNC = 0x00000004L, //!< checks for conformance with the standard feature naming convention (SFNC) + xvDefault = 0x00000000L, //!< checks performed if nothing else is said + xvAll = 0xffffffffL, //!< all possible checks + _UndefinedEXMLValidation = 0x8000000L //!< Object is not yet initialized + } EXMLValidation; + + //! typedef for float notation + //! \ingroup GenApi_PublicImpl + typedef enum _EDisplayNotation + { + fnAutomatic, //!< the notation if either scientific or fixed depending on what is shorter + fnFixed, //!< the notation is fixed, e.g. 123.4 + fnScientific, //!< the notation is scientific, e.g. 1.234e2 + _UndefinedEDisplayNotation //!< Object is not yet initialized + } EDisplayNotation; + + //! typedef for interface type + //! \ingroup GenApi_PublicImpl + typedef enum _EInterfaceType + { + intfIValue, //!< IValue interface + intfIBase, //!< IBase interface + intfIInteger, //!< IInteger interface + intfIBoolean, //!< IBoolean interface + intfICommand, //!< ICommand interface + intfIFloat, //!< IFloat interface + intfIString, //!< IString interface + intfIRegister, //!< IRegister interface + intfICategory, //!< ICategory interface + intfIEnumeration, //!< IEnumeration interface + intfIEnumEntry, //!< IEnumEntry interface + intfIPort //!< IPort interface + } EInterfaceType; + + //! typedef for link type + /*! For details see GenICam Wiki : GenApi/SoftwareArchitecture/NodeDependencies + \ingroup GenApi_PublicImpl + */ + typedef enum _ELinkType + { + ctParentNodes, //!< All nodes for which this node is at least an invalidating child + ctReadingChildren, //!< All nodes which can be read from + ctWritingChildren, //!< All nodes which can write a value further down the node stack + ctInvalidatingChildren, //!< All directly connected nodes which invalidate this node + ctDependingNodes, //!< All directly or indirectly connected nodes which are invalidated by this nodes (i.e. which are dependent on this node) + ctTerminalNodes, //!< All indirectly connected terminal nodes + ctValueChangingChildren //!< All child node used to compute the value. + } ELinkType; + + //! typedef for increment mode + //! \ingroup GenApi_PublicImpl + typedef enum _EIncMode + { + noIncrement, // !> The feature has no increment + fixedIncrement, // !> The feature has a fix increment + listIncrement // !> The feature has a list of valid value + } EIncMode; + + //! typedef for link type + //! \ingroup GenApi_PublicImpl + typedef enum _EInputDirection + { + idFrom, //!< Indicates a swiss knife that it is used as worker for a converter computing FROM + idTo, //!< Indicates a swiss knife that it is used as worker for a converter computing TO + idNone //!< SwissKnife is not used within a converter + } EInputDirection; + + //! GenApi schema version + typedef enum _EGenApiSchemaVersion + { + v1_0 = 1, + v1_1 = 2, + _Undefined = -1 + } EGenApiSchemaVersion; + +} + +#endif // ifndef GENAPI_TYPES_H diff --git a/Cigarette/Pylon6.2/include/GenICam.h b/Cigarette/Pylon6.2/include/GenICam.h new file mode 100644 index 0000000..321cd01 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenICam.h @@ -0,0 +1,39 @@ +/**************************************************************************** + (c) 2005 by STEMMER IMAGING + + License: This file is published under the license of the EMVA GenICam Standard Group. + A text file describing the legal terms is included in your installation as 'license.txt'. + If for some reason you are missing this file please contact the EMVA or visit the website + (http://www.genicam.org) for a full copy. + + THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP + OR CONTRIBUTORS 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. + +****************************************************************************/ + + /// \file $Source$ + /// \brief Common GenICam include file. + /// \version $Revision$ + /// \date $Date$ + + +#ifndef GENICAM_OVERALL_H +#define GENICAM_OVERALL_H + +#if defined (_WIN32) || (defined (__GNUC__) && (defined (__linux__) || defined (__APPLE__)) || defined(VXWORKS)) +# include +# include +#else +# error Unknown/unsupported platform +#endif + +#endif // GENICAM_OVERALL_H diff --git a/Cigarette/Pylon6.2/include/GenICamFwd.h b/Cigarette/Pylon6.2/include/GenICamFwd.h new file mode 100644 index 0000000..31fd7c5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenICamFwd.h @@ -0,0 +1,76 @@ +/**************************************************************************** +(c) 2004 by Basler Vision Technologies +(c) 2005 STEMMER IMAGING + +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. + + +****************************************************************************/ + +/// \file GenICamFwd.h +/// \brief Forward declarations for GenICam types. +/// \ingroup Base_PublicUtilities + +#ifndef GENICAM_FWD_H +#define GENICAM_FWD_H + +#ifdef _WIN32 +# include // interface +#else +# define interface struct +#endif +#include +#include + +// GCBase +namespace GENICAM_NAMESPACE +{ + class gcstring; + class gcstring_vector; +} + +// GenApi +namespace GENAPI_NAMESPACE +{ + interface IBase; + interface IBoolean; + interface ICategory; + interface IChunkPort; + interface ICommand; + interface IDeviceInfo; + interface IEnumEntry; + interface IEnumeration; + interface IFloat; + interface IInteger; + interface INode; + interface INodeMap; + interface IPort; + interface IPortConstruct; + interface IPortRecorder; + interface IPortReplay; + interface IPortWriteList; + interface IRegister; + interface ISelector; + interface IString; + interface IUserData; + interface IValue; + + class CLock; +} + +#endif // GENICAM_FWD_H diff --git a/Cigarette/Pylon6.2/include/GenICamVersion.h b/Cigarette/Pylon6.2/include/GenICamVersion.h new file mode 100644 index 0000000..bbe9154 --- /dev/null +++ b/Cigarette/Pylon6.2/include/GenICamVersion.h @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------------- +// (c) 2006 by Basler Vision Technologies +// Section: Vision Components +// Project: GenICam +// Author: Fritz Dierks +// $Header$ +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +/*! +\file +\brief central versioning counters +*/ + +#ifndef GENICAM_VERSION_H +#define GENICAM_VERSION_H + +// The following symbols are defined in a cmake generated include file +//#define GENICAM_VERSION_MAJOR 3 +//#define GENICAM_VERSION_MINOR 0 +//#define GENICAM_VERSION_SUBMINOR 0 +//#define GENICAM_MAIN_COMPILER VC120 / gcc421 +#include <_GenICamVersion.h> + +// The Build is not supported any more +#define GENICAM_VERSION_BUILD 0 + +// Normally GENICAM_COMPILER is fed via cmake; however in pure library mode it is not +#ifndef GENICAM_COMPILER +# define GENICAM_COMPILER GENICAM_MAIN_COMPILER +#endif + +// Don't ask... +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +#define GENICAM_RAW_UNDERSCORE(a, b, c) a ## _ ## b ## _ ## c +#define GENICAM_SEP_UNDERSCORE(a, b, c) GENICAM_RAW_UNDERSCORE(a, b, c) +#define GENICAM_RAW_UNDERSCORE_COMPANY(a, b, c, d) a ## _ ## b ## _ ## c ## _ ## d +#define GENICAM_SEP_UNDERSCORE_COMPANY(a, b, c, d) GENICAM_RAW_UNDERSCORE_COMPANY(a, b, c, d) + +// String versions of the version numbers +#define GENICAM_VERSION_MAJOR_STR TOSTRING( GENICAM_VERSION_MAJOR ) +#define GENICAM_VERSION_MINOR_STR TOSTRING( GENICAM_VERSION_MINOR ) +#define GENICAM_VERSION_SUBMINOR_STR TOSTRING( GENICAM_VERSION_SUBMINOR ) +#define GENICAM_VERSION_BUILD_STR TOSTRING( GENICAM_VERSION_BUILD ) +#define GENICAM_COMPILER_STR TOSTRING( GENICAM_COMPILER ) +#define GENICAM_ROOT "GENICAM_ROOT" +#define GENICAM_CACHE_VERSION "GENICAM_CACHE_V" GENICAM_VERSION_MAJOR_STR "_" GENICAM_VERSION_MINOR_STR +#define GENICAM_LOG_CONFIG_VERSION "GENICAM_LOG_CONFIG_V" GENICAM_VERSION_MAJOR_STR "_" GENICAM_VERSION_MINOR_STR +#define GENICAM_CLPROTOCOL "GENICAM_CLPROTOCOL" + +#endif // GENICAM_VERSION_H diff --git a/Cigarette/Pylon6.2/include/_GenICamVersion.h b/Cigarette/Pylon6.2/include/_GenICamVersion.h new file mode 100644 index 0000000..351e0d4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/_GenICamVersion.h @@ -0,0 +1,9 @@ +// This file is generated automatically. Do not modify! +#define GENICAM_VERSION_MAJOR 3 +#define GENICAM_VERSION_MINOR 1 +#define GENICAM_VERSION_SUBMINOR 0 + +#define GENICAM_MAIN_COMPILER VC141 + +#define GENICAM_COMPANY_SUFFIX Basler_pylon +#define GENICAM_SVN_REVISION 5245 diff --git a/Cigarette/Pylon6.2/include/genapic/GenApiC.h b/Cigarette/Pylon6.2/include/genapic/GenApiC.h new file mode 100644 index 0000000..346a97b --- /dev/null +++ b/Cigarette/Pylon6.2/include/genapic/GenApiC.h @@ -0,0 +1,255 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2009-2021 Basler AG + http://www.baslerweb.com + Author: AH, TK +-----------------------------------------------------------------------------*/ + +/** + \file + \brief GenApi C bindings. +*/ + +#ifndef GENAPI_GENAPIC_H_ +#define GENAPI_GENAPIC_H_ + +#include + +#include + +#pragma pack(push, GENAPIC_PACKING) + +#include +#include +#include + +#define GENAPIC_DECLARE_HANDLE(name) struct name##_; typedef struct name##_ *name + +/** +* \addtogroup genapi GenApi Interface +* @{ +*/ + +/** \brief A value for invalid / uninitialized handles. */ +#ifdef __cplusplus +# define GENAPIC_INVALID_HANDLE ( 0 ) /* C++ won't allow to assign a void* to a typed pointer (HANDLE) */ +#else +# define GENAPIC_INVALID_HANDLE ( (void*)0 ) +#endif + +GENAPIC_DECLARE_HANDLE( NODE_HANDLE ); /**< \brief A handle for a node object. */ +GENAPIC_DECLARE_HANDLE( NODEMAP_HANDLE ); /**< \brief A handle for a node map object. */ +GENAPIC_DECLARE_HANDLE( GENAPI_FILE_HANDLE ); /**< \brief A handle for a GenApi file object. */ +GENAPIC_DECLARE_HANDLE( NODE_CALLBACK_HANDLE ); /**< \brief A handle for a node callback object. */ + +/** +* @} +*/ + + +#ifdef __cplusplus + +// avoid namespace ambiguities between std::_Bool (from yvals.h) and ::_Bool (from GenApiCTypes.h) +#ifdef _MSC_VER +# define _Bool ::_Bool +# define PYLONC_BOOL_DEFINED +#endif + +extern "C" { + +#endif /* __cplusplus */ + + typedef void GENAPIC_CC NodeCallbackFunction_t( NODE_HANDLE h ); + + /* + * ---------------------------------------------------------------------------- + * Error handling + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiGetLastErrorMessage( char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiGetLastErrorDetail( char* pBuf, size_t* pBufLen ); + + + /* + * ---------------------------------------------------------------------------- + * Nodemap + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeMapGetNode( NODEMAP_HANDLE hMap, const char* pName, NODE_HANDLE* phNode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeMapGetNumNodes( NODEMAP_HANDLE hMap, size_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeMapGetNodeByIndex( NODEMAP_HANDLE hMap, size_t index, NODE_HANDLE* phNode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeMapPoll( NODEMAP_HANDLE hMap, int64_t timestamp ); + + + /* + * ---------------------------------------------------------------------------- + * INode Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetAccessMode( NODE_HANDLE hNode, EGenApiAccessMode* pAccessMode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetName( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetNameSpace( NODE_HANDLE hNode, EGenApiNameSpace* pNamespace ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetVisibility( NODE_HANDLE hNode, EGenApiVisibility* pVisibility ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeInvalidateNode( NODE_HANDLE hNode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetCachingMode( NODE_HANDLE hNode, EGenApiCachingMode* pCachingMode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetToolTip( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetDescription( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetDisplayName( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetType( NODE_HANDLE hNode, EGenApiNodeType* pType ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetPollingTime( NODE_HANDLE hNode, int64_t* pPollingTime ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeRegisterCallback( NODE_HANDLE hNode, NodeCallbackFunction_t* pCbFunction, NODE_CALLBACK_HANDLE* phCb ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeDeregisterCallback( NODE_HANDLE hNode, NODE_CALLBACK_HANDLE hCb ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeImposeAccessMode( NODE_HANDLE hNode, EGenApiAccessMode imposedAccessMode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeImposeVisibility( NODE_HANDLE hNode, EGenApiVisibility imposedVisibility ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeIsImplemented( NODE_HANDLE hNode, _Bool* pResult ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeIsReadable( NODE_HANDLE hNode, _Bool* pResult ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeIsWritable( NODE_HANDLE hNode, _Bool* pResult ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeIsAvailable( NODE_HANDLE hNode, _Bool* pResult ); + + + /* + * ---------------------------------------------------------------------------- + * IValue Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeToString( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeToStringEx( NODE_HANDLE hNode, _Bool verify, char* pBuf, size_t* pBufLen ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeFromStringEx( NODE_HANDLE hNode, _Bool verify, const char* pString ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeFromString( NODE_HANDLE hNode, const char* pString ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetAlias( NODE_HANDLE hNode, NODE_HANDLE* phNode ); + + + /* + * ---------------------------------------------------------------------------- + * IInteger Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerSetValue( NODE_HANDLE hNode, int64_t value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerSetValueEx( NODE_HANDLE hNode, _Bool verify, int64_t value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetValue( NODE_HANDLE hNode, int64_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetValueEx( NODE_HANDLE hNode, _Bool verify, int64_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetMin( NODE_HANDLE hNode, int64_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetMax( NODE_HANDLE hNode, int64_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetInc( NODE_HANDLE hNode, int64_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetRepresentation( NODE_HANDLE hNode, EGenApiRepresentation* pValue ); + + + /* + * ---------------------------------------------------------------------------- + * IBoolean Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiBooleanSetValue( NODE_HANDLE hNode, _Bool value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiBooleanGetValue( NODE_HANDLE hNode, _Bool* pValue ); + + + /* + * ---------------------------------------------------------------------------- + * IFloat Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatSetValue( NODE_HANDLE hNode, double value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatSetValueEx( NODE_HANDLE hNode, _Bool verify, double value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatGetValue( NODE_HANDLE hNode, double* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatGetValueEx( NODE_HANDLE hNode, _Bool verify, double* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatGetMin( NODE_HANDLE hNode, double* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatGetMax( NODE_HANDLE hNode, double* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatGetRepresentation( NODE_HANDLE hNode, EGenApiRepresentation* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFloatGetUnit( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + + + /* + * ---------------------------------------------------------------------------- + * ICommand Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiCommandExecute( NODE_HANDLE hNode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiCommandIsDone( NODE_HANDLE hNode, _Bool* pValue ); + + + /* + * ---------------------------------------------------------------------------- + * IEnumeration Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiEnumerationGetNumEntries( NODE_HANDLE hNode, size_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiEnumerationGetEntryByIndex( NODE_HANDLE hNode, size_t index, NODE_HANDLE* pEntry ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiEnumerationGetEntryByName( NODE_HANDLE hNode, const char* pName, NODE_HANDLE* pEntry ); + + + /* + * ---------------------------------------------------------------------------- + * IEnumEntry Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiEnumerationEntryGetValue( NODE_HANDLE hNode, int* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiEnumerationEntryGetSymbolic( NODE_HANDLE hNode, char* pBuf, size_t* pBufLen ); + + + /* + * ---------------------------------------------------------------------------- + * ISelector Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiSelectorGetNumSelectingFeatures( NODE_HANDLE hNode, size_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiSelectorGetSelectingFeatureByIndex( NODE_HANDLE hNode, size_t index, NODE_HANDLE* phNode ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiSelectorGetNumSelectedFeatures( NODE_HANDLE hNode, size_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiSelectorGetSelectedFeatureByIndex( NODE_HANDLE hNode, size_t index, NODE_HANDLE* phNode ); + + + /* + * ---------------------------------------------------------------------------- + * IRegister Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiRegisterGetValue( NODE_HANDLE hNode, void* pBuffer, size_t* pLength ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiRegisterSetValue( NODE_HANDLE hNode, const void* pBuffer, size_t length ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiRegisterGetLength( NODE_HANDLE hNode, size_t* pLength ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiRegisterGetAddress( NODE_HANDLE hNode, int64_t* pAddress ); + + + /* + * ---------------------------------------------------------------------------- + * Category Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiCategoryGetNumFeatures( NODE_HANDLE hNode, size_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiCategoryGetFeatureByIndex( NODE_HANDLE hNode, size_t index, NODE_HANDLE* phEntry ); + + + /* + * ---------------------------------------------------------------------------- + * IPort Nodes + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiPortRead( NODE_HANDLE hNode, void* pBuffer, int64_t Address, size_t Length ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiPortWrite( NODE_HANDLE hNode, const void* pBuffer, int64_t Address, size_t Length ); + + + /* + * ---------------------------------------------------------------------------- + * DeviceFileStream + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFilesAreSupported( NODEMAP_HANDLE hMap, _Bool* pResult ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFileExists( NODEMAP_HANDLE hMap, const char* pFileName, _Bool* pResult ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFileOpen( NODEMAP_HANDLE hMap, const char* pFileName, EGenApiFileAccessMode accessMode, GENAPI_FILE_HANDLE* phFile ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFileRead( GENAPI_FILE_HANDLE hFile, void* pBuffer, size_t* pLength ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFileWrite( GENAPI_FILE_HANDLE hFile, const void* pBuffer, size_t length ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiFileClose( GENAPI_FILE_HANDLE hFile ); + +#ifdef __cplusplus +} /* extern "C" */ + +#ifdef PYLONC_BOOL_DEFINED +# undef _Bool +# undef PYLONC_BOOL_DEFINED +#endif + +#endif /* __cplusplus */ + +#include + +#pragma pack(pop) + +#endif diff --git a/Cigarette/Pylon6.2/include/genapic/GenApiC32BitMethods.h b/Cigarette/Pylon6.2/include/genapic/GenApiC32BitMethods.h new file mode 100644 index 0000000..f690001 --- /dev/null +++ b/Cigarette/Pylon6.2/include/genapic/GenApiC32BitMethods.h @@ -0,0 +1,58 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2012-2021 Basler AG + http://www.baslerweb.com +-----------------------------------------------------------------------------*/ +/** + \file + \brief GenApi C bindings - 32 bit functions. +*/ + +#ifndef GenApiC32BitMethods_h__ +#define GenApiC32BitMethods_h__ + +#include + +#pragma pack(push, GENAPIC_PACKING) + +#include + +#ifdef __cplusplus +// avoid namespace ambiguities between std::_Bool (from yvals.h) and ::_Bool (from GenApiCTypes.h) +# ifdef _MSC_VER +# define _Bool ::_Bool +# define PYLONC_BOOL_DEFINED +# endif + +extern "C" +{ +#endif /* __cplusplus */ + + /* + * ---------------------------------------------------------------------------- + * Functions doing an implicit cast to 32-bit values + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeGetPollingTimeInt32( NODE_HANDLE hNode, int32_t* pollingTime ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerSetValueInt32( NODE_HANDLE hNode, int32_t value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerSetValueExInt32( NODE_HANDLE hNode, _Bool verify, int32_t value ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetValueInt32( NODE_HANDLE hNode, int32_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetValueExInt32( NODE_HANDLE hNode, _Bool verify, int32_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetMinInt32( NODE_HANDLE hNode, int32_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetMaxInt32( NODE_HANDLE hNode, int32_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiIntegerGetIncInt32( NODE_HANDLE hNode, int32_t* pValue ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC GenApiNodeMapPollInt32( NODEMAP_HANDLE hMap, int32_t timestamp ); + +#ifdef __cplusplus +} /* extern "C" */ + +#ifdef PYLONC_BOOL_DEFINED +# undef _Bool +# undef PYLONC_BOOL_DEFINED +#endif + +#endif /* __cplusplus */ + +#pragma pack(pop) + +#endif /* GenApiC32BitMethods_h__ */ diff --git a/Cigarette/Pylon6.2/include/genapic/GenApiCDefines.h b/Cigarette/Pylon6.2/include/genapic/GenApiCDefines.h new file mode 100644 index 0000000..4ceb121 --- /dev/null +++ b/Cigarette/Pylon6.2/include/genapic/GenApiCDefines.h @@ -0,0 +1,46 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2012-2021 Basler AG + http://www.baslerweb.com +-----------------------------------------------------------------------------*/ +/** + \file + \brief Platform-dependent macro definitions. + */ +#ifndef GenApiCDefines_h__ +#define GenApiCDefines_h__ + +#if defined (_MSC_VER) || defined (__BORLANDC__) || defined (__MINGW32__) +# define GENAPIC_WIN_BUILD /**< Will be set when building for windows platforms. */ +#elif (defined(__GNUC__) && (defined(__linux__)) || defined(__APPLE__)) +# define GENAPIC_LINUX_BUILD /**< Will be set when building for linux platforms. */ +#else +# error Unsupported platform +#endif + +#if defined (GENAPIC_WIN_BUILD) +# if defined (GENAPIC_EXPORTS) && defined (__cplusplus) +# define GENAPIC_API __declspec(dllexport) +# else +# define GENAPIC_API __declspec(dllimport) +# endif +# define GENAPIC_CC __stdcall +# define GENAPIC_PACKING 8 +#elif defined (GENAPIC_LINUX_BUILD) +# if defined (GENAPIC_EXPORTS) && defined (__cplusplus) +# define GENAPIC_API __attribute__((visibility("default"))) +# else +# define GENAPIC_API +# endif +# define GENAPIC_CC +# define GENAPIC_PACKING 8 +#else +# error Unsupported platform +#endif + +#ifndef _HRESULT_DEFINED +# define _HRESULT_DEFINED + typedef long HRESULT; +#endif /* !_HRESULT_DEFINED */ + +#endif /* GenApiCDefines_h__ */ diff --git a/Cigarette/Pylon6.2/include/genapic/GenApiCEnums.h b/Cigarette/Pylon6.2/include/genapic/GenApiCEnums.h new file mode 100644 index 0000000..9386969 --- /dev/null +++ b/Cigarette/Pylon6.2/include/genapic/GenApiCEnums.h @@ -0,0 +1,118 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2012-2021 Basler AG + http://www.baslerweb.com +-----------------------------------------------------------------------------*/ +#ifndef GENAPICENUMS_H_INCLUDED +#define GENAPICENUMS_H_INCLUDED + +#include + +/** + * \file + * \brief GenApi enumeration types. + * + * Definitions of enumerated types used by GenApi C functions. + */ + +/** + * \addtogroup genapi GenApi Interface + * @{ + */ + +/** + * \brief Node type. + */ + +typedef enum +{ + IntegerNode, /**< \brief Node represents an integer-valued parameter. */ + BooleanNode, /**< \brief Node represents a boolean (true/false) parameter. */ + FloatNode, /**< \brief Node represents a floating point-valued parameter. */ + CommandNode, /**< \brief Node can trigger a command. */ + StringNode, /**< \brief Node represents a string-valued parameter. */ + EnumerationNode, /**< \brief Node represents an enumeration-valued parameter. */ + EnumEntryNode, /**< \brief Node represents an 'enumeration entry' parameter. */ + Category, /**< \brief Node for grouping parameters in a category. */ + _UnknownNodeType = -1 /**< \brief Node type invalid. */ +} EGenApiNodeType; + +/** + * \brief Access mode of a node. + */ + +typedef enum +{ + NI, /**< \brief Not implemented. */ + NA, /**< \brief Not available. */ + WO, /**< \brief Write Only.*/ + RO, /**< \brief Read Only. */ + RW, /**< \brief Read and Write. */ + _UndefinedAccesMode = -1 /**< \brief Access mode invalid. */ +} EGenApiAccessMode; + +/** + * \brief Node name spaces. + */ + +typedef enum +{ + Custom, /**< \brief Name resides in custom name space. */ + Standard, /**< \brief Name resides in one of the standard name spaces. */ + _UndefinedNameSpace = -1 /**< \brief Name space invalid. */ +} EGenApiNameSpace; + +/** + * \brief Node visibility. + */ + +typedef enum +{ + Beginner = 0, /**< \brief Visible to everyone. */ + Expert = 1, /**< \brief Visible to experts or gurus only. */ + Guru = 2, /**< \brief Visible to gurus only. */ + Invisible = 3, /**< \brief Not visible at all. */ + _UndefinedVisibility = -1 /**< \brief Visibility invalid. */ +} EGenApiVisibility; + +/** + * \brief Node caching modes. + */ + +typedef enum +{ + NoCache, /**< \brief Do not use cache. */ + WriteThrough, /**< \brief Write to cache and register. */ + WriteAround, /**< \brief Write to register, write to cache on read. */ + _UndefinedCachingMode = -1 /**< \brief Caching mode invalid. */ +} EGenApiCachingMode; + +/** + * \brief Node representation. + */ + +typedef enum +{ + Linear, /**< \brief Slider with linear behavior. */ + Logarithmic, /**< \brief Slider with logarithmic behavior. */ + Boolean, /**< \brief Checkbox. */ + PureNumber, /**< \brief Decimal number in an edit control. */ + HexNumber, /**< \brief Hex number in an edit control. */ + _UndefinedRepresentation = -1 /**< \brief Representation invalid. */ +} EGenApiRepresentation; + +/** + * \brief File access modes. + */ + +typedef enum +{ + GenApiFileReadAccess, /**< \brief For specifying file read access on file open. */ + GenApiFileWriteAccess /**< \brief For specifying file write access on file open. */ +} EGenApiFileAccessMode; + +/** + * @} + */ + +#endif diff --git a/Cigarette/Pylon6.2/include/genapic/GenApiCError.h b/Cigarette/Pylon6.2/include/genapic/GenApiCError.h new file mode 100644 index 0000000..b4d672f --- /dev/null +++ b/Cigarette/Pylon6.2/include/genapic/GenApiCError.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2009-2021 Basler AG + http://www.baslerweb.com + Author: AH, TK +-----------------------------------------------------------------------------*/ + +/** + \file + \brief Error codes for GenApi C bindings. +*/ + +#ifndef GENAPICERROR_H_INCLUDED +#define GENAPICERROR_H_INCLUDED + +/* + * TODO: Define a more elaborate numbering scheme + * TODO: Map to HRESULTS when library is built for usage with type library + */ + +#define GENAPIC_RESULT HRESULT + +/** +* \defgroup errorcodes Error Codes +* \brief Error codes returned by any of the \pylon_C API functions. +* +* These error codes can be returned from any of the \pylon_C API functions.\n +* To get a textual representation for the error code you can call GenApiGetLastErrorMessage().\n +* To get a detailed error description you can call GenApiGetLastErrorDetail(). The string returned will contain the specific reason why the call has failed. +* \note If a function returns an error, you must call GenApiGetLastErrorMessage() and/or GenApiGetLastErrorDetail() directly after you received the error. +* Calling other functions will either reset or overwrite the error text. +* +* @{ +*/ + +#define GENAPI_E_OK ((GENAPIC_RESULT) 0) /**< Operation completed successfully. */ +#define GENAPI_E_FAIL ((GENAPIC_RESULT) 0xC2000001) /**< Unspecified error occurred. Call GenApiGetLastErrorDetail() for more information about the error. */ +#define GENAPI_E_INVALID_ARG ((GENAPIC_RESULT) 0xC2000002) /**< Function called with invalid argument. */ +#define GENAPI_E_INSUFFICIENT_BUFFER ((GENAPIC_RESULT) 0xC2000003) /**< Buffer size passed is less than required. */ +#define GENAPI_E_INVALID_NODEMAPHANDLE ((GENAPIC_RESULT) 0xC2000004) /**< An invalid node map handle has been passed. */ +#define GENAPI_E_NODE_NOT_FOUND ((GENAPIC_RESULT) 0xC2000005) /**< Specified node not found in node map. */ +#define GENAPI_E_INVALID_NODEHANDLE ((GENAPIC_RESULT) 0xC2000006) /**< An invalid node handle has been passed. */ +#define GENAPI_E_RESULT_RANGE_EXCEEDED ((GENAPIC_RESULT) 0xC2000007) /**< A 64 bit result will be truncated if returned as a 32 bit value. */ +#define GENAPI_E_LIMITS_EXCEEDED ((GENAPIC_RESULT) 0xC2000008) /**< The value exceeds the valid range. */ +#define GENAPI_E_PROPERTY_ERROR ((GENAPIC_RESULT) 0xC2000009) /**< Generic GenICam property error occurred. Call GenApiGetLastErrorDetail() for more information about the error. */ +#define GENAPI_E_TIMEOUT ((GENAPIC_RESULT) 0xC200000A) /**< Timeout expired. */ +#define GENAPI_E_TYPE_ERROR ((GENAPIC_RESULT) 0xC200000B) /**< Expression has wrong type. */ +#define GENAPI_E_INDEX_ERROR ((GENAPIC_RESULT) 0xC200000C) /**< An index is out of range. */ +/* 0xC200000D left out intentionally */ +#define GENAPI_E_OBJECT_ILLEGAL_STATE ((GENAPIC_RESULT) 0xC200000E) /**< Object state illegal for operation. Call GenApiGetLastErrorDetail() for more information about the error.*/ +#define GENAPI_E_INVALID_NODECALLBACKHANDLE ((GENAPIC_RESULT) 0xC200000F) /**< An invalid callback handle has been passed. */ +#define GENAPI_E_LOGICAL_ERROR ((GENAPIC_RESULT) 0xC2000010) /**< Program logic error. Call GenApiGetLastErrorDetail() for more information about the error. */ +#define GENAPI_E_INVALID_FILEHANDLE ((GENAPIC_RESULT) 0xC2000011) /**< An invalid file handle has been passed. */ +/** +* @} +*/ + + +#endif diff --git a/Cigarette/Pylon6.2/include/genapic/GenApiCTypes.h b/Cigarette/Pylon6.2/include/genapic/GenApiCTypes.h new file mode 100644 index 0000000..360602d --- /dev/null +++ b/Cigarette/Pylon6.2/include/genapic/GenApiCTypes.h @@ -0,0 +1,150 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2009-2021 Basler AG + http://www.baslerweb.com + Author: AH, TK +-----------------------------------------------------------------------------*/ + +/** + * \file + * \brief Platform-dependent type definitions. + * Define a subset of the types and macros that are provided by the + * stdint.h header on systems that comply with the C99 standard. This + * is meant to aid in portability. +**/ + +#ifndef GENAPIC_TYPES_H +#define GENAPIC_TYPES_H + +#if __STDC_VERSION__ >= 199901L + +/* Compiler is c99-compliant. */ +# if !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +# endif +# if !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +# endif +# include +# include + +#elif defined (_WIN32) + +# if defined(_MSC_VER) && _MSC_VER >= 1600 +// VS2010 provides stdint.h +# include +# else +# ifndef _STDINT // only define if not already done + + /*! Portable 8 bit-wide signed integer type. */ +typedef __int8 int8_t; +/*! Portable 8 bit-wide unsigned integer type. */ +typedef unsigned __int8 uint8_t; + +/*! Portable 16 bit-wide signed integer type. */ +typedef __int16 int16_t; +/*! Portable 16 bit-wide unsigned integer type. */ +typedef unsigned __int16 uint16_t; + +/*! Portable 32 bit-wide signed integer type. */ +typedef __int32 int32_t; +/*! Portable 32 bit-wide unsigned integer type. */ +typedef unsigned __int32 uint32_t; + +/*! Portable 64 bit-wide signed integer type. */ +typedef __int64 int64_t; +/*! Portable 64 bit-wide unsigned integer type. */ +typedef unsigned __int64 uint64_t; + +# if defined(_WIN64) + /*! Portable signed integer type capable of holding a pointer. */ +typedef __int64 intptr_t; +/*! Portable unsigned integer type capable of holding a pointer. */ +typedef unsigned __int64 uintptr_t; +# else + /*! Portable signed integer type capable of holding a pointer. */ +typedef __int32 intptr_t; +/*! Portable unsigned integer type capable of holding a pointer. */ +typedef unsigned __int32 uintptr_t; +# endif +# endif // _STDINT +# endif // _MSC_VER >= 1600 + + +/*! Mimic c99 built-in _Bool type. */ +#if defined(__cplusplus) + /* for C++ builds use the same typedef as in */ +typedef bool _Bool; +# if defined(_MSC_VER) +# define _Bool ::_Bool +# define PYLONC_BOOL_DEFINED +# endif +#else + /* for VC Version >= 1800 : _Bool is now a proper type and you can't create identifiers with that name */ + /* for embarcadero C++ Builder >= 2009 : _Bool is now a proper type and you can't create identifiers with that name */ +# if (defined(_MSC_VER) && _MSC_VER <= 1700) || (defined(__BORLANDC__) && __BORLANDC__ < 0x0610 ) +typedef unsigned char _Bool; +# endif +#endif + + +#elif (defined(__GNUC__) && (defined(__linux__)) || defined(__APPLE__)) +# include + + /* Mimic c99 built-in _Bool type. */ +# if defined(__cplusplus) +typedef bool _Bool; +# else + /* gcc has built-in _Bool type for C, even for older standard than c99 */ + /*typedef unsigned char _Bool;*/ +# endif + +#else +# error No platform-specific type definitions +#endif /* __STDC_VERSION__ >= 199901L */ + + + +#ifndef INT64_MAX +# define INT64_MAX 0x7fffffffffffffffLL /* Maximum signed int64 value. */ +#endif + +#ifndef INT64_MIN +# define INT64_MIN 0x8000000000000000LL /* Minimum signed int64 value. */ +#endif + +#ifndef UINT64_MAX +# define UINT64_MAX 0xffffffffffffffffULL /* Maximum unsigned int64 value. */ +#endif + +#ifndef INT32_MAX +# define INT32_MAX 0x000000007fffffffLL /* Maximum signed int32 value. */ +#endif + +#ifndef INT32_MIN +# define INT32_MIN 0xffffffff80000000LL /* Minimum signed int32 value. */ +#endif + +#ifndef UINT32_MAX +# define UINT32_MAX 0x00000000ffffffffULL /* Maximum unsigned int32 value. */ +#endif + +#ifndef INT8_MAX +# define INT8_MAX 0x000000000000007fLL /* Maximum signed int8 value. */ +#endif + +#ifndef INT8_MIN +# define INT8_MIN 0xffffffffffffff80LL /* Minimum signed int8 value. */ +#endif + +#ifndef UINT8_MAX +# define UINT8_MAX 0x00000000000000ffULL /* Maximum unsigned int8 value. */ +#endif + +#ifdef PYLONC_BOOL_DEFINED +# undef _Bool +# undef PYLONC_BOOL_DEFINED +#endif + + +#endif /* GENAPIC_TYPES_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/AcquireContinuousConfiguration.h b/Cigarette/Pylon6.2/include/pylon/AcquireContinuousConfiguration.h new file mode 100644 index 0000000..c703697 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/AcquireContinuousConfiguration.h @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief An instant camera configuration for free-running continuous acquisition. + This instant camera configuration is provided as header-only file. The code + can be copied and modified for creating own configuration classes. +*/ + +#ifndef INCLUDED_ACQUIRECONTINUOUSCONFIGURATION_H_7346765 +#define INCLUDED_ACQUIRECONTINUOUSCONFIGURATION_H_7346765 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CAcquireContinuousConfiguration + \brief Changes the configuration of the camera to free-running continuous acquisition. + + The \c CAcquireContinuousConfiguration is the default configuration of the Instant Camera class. + The CAcquireContinuousConfiguration is automatically registered when an Instant Camera object is created. + + This instant camera configuration is provided as header-only file. The code + can be copied and modified for creating own configuration classes. + */ + class CAcquireContinuousConfiguration : public CConfigurationEventHandler + { + public: + /// Destructor + virtual ~CAcquireContinuousConfiguration() + { + } + + /// Apply acquire continuous configuration. + static void ApplyConfiguration( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + using namespace GENAPI_NAMESPACE; + + //Disable all trigger types. + CConfigurationHelper::DisableAllTriggers( nodemap ); + + //Disable compression mode. + CConfigurationHelper::DisableCompression( nodemap ); + + //Disable GenDC streaming. + CConfigurationHelper::DisableGenDC( nodemap ); + + // Set image component. + CConfigurationHelper::SelectRangeComponent( nodemap ); + + //Set acquisition mode. + CEnumParameter( nodemap, "AcquisitionMode" ).SetValue( "Continuous" ); + } + + + //Set basic camera settings. + virtual void OnOpened( CInstantCamera& camera ) + { + try + { + ApplyConfiguration( camera.GetNodeMap() ); + } + catch (const GenericException& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Pylon::GenericException caught in OnOpened method msg=%hs", e.what() ); + } + catch (const std::exception& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. std::exception caught in OnOpened method msg=%hs", e.what() ); + } + catch (...) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Unknown exception caught in OnOpened method." ); + } + } + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_ACQUIRECONTINUOUSCONFIGURATION_H_7346765 */ diff --git a/Cigarette/Pylon6.2/include/pylon/AcquireSingleFrameConfiguration.h b/Cigarette/Pylon6.2/include/pylon/AcquireSingleFrameConfiguration.h new file mode 100644 index 0000000..ccfc0e1 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/AcquireSingleFrameConfiguration.h @@ -0,0 +1,108 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief An instant camera configuration for single frame acquisition. + Use together with Pylon::CInstantCamera::GrabOne() only. + This instant camera configuration is provided as header-only file. The code + can be copied and modified for creating own configuration classes. +*/ + +#ifndef INCLUDED_ACQUIRESINGLEFRAMECONFIGURATION_H_6529309 +#define INCLUDED_ACQUIRESINGLEFRAMECONFIGURATION_H_6529309 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CAcquireSingleFrameConfiguration + \brief An instant camera configuration for single frame acquisition, Use together with CInstantCamera::GrabOne() only. + + The %CAcquireSingleFrameConfiguration is provided as header-only file. + The code can be copied and modified for creating own configuration classes. + + \note Grabbing single images using Software Trigger (CSoftwareTriggerConfiguration) is recommended if you want to maximize frame rate. + This is because the overhead per grabbed image is reduced compared to Single Frame Acquisition. + The grabbing can be started using CInstantCamera::StartGrabbing(). + Images are grabbed using the CInstantCamera::WaitForFrameTriggerReady(), CInstantCamera::ExecuteSoftwareTrigger() and CInstantCamera::RetrieveResult() methods instead of using CInstantCamera::GrabOne(). + The grab can be stopped using CInstantCamera::StopGrabbing() when done. + + */ + class CAcquireSingleFrameConfiguration : public CConfigurationEventHandler + { + public: + /// Destructor + virtual ~CAcquireSingleFrameConfiguration() + { + } + + /// Apply acquire single frame configuration. + static void ApplyConfiguration( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + using namespace GENAPI_NAMESPACE; + + //Disable all trigger types. + CConfigurationHelper::DisableAllTriggers( nodemap ); + + //Disable compression mode. + CConfigurationHelper::DisableCompression( nodemap ); + + //Disable GenDC streaming. + CConfigurationHelper::DisableGenDC( nodemap ); + + // Set image component. + CConfigurationHelper::SelectRangeComponent( nodemap ); + + //Set acquisition mode. + CEnumParameter( nodemap, "AcquisitionMode" ).SetValue( "SingleFrame" ); + } + + //Set basic camera settings + virtual void OnOpened( CInstantCamera& camera ) + { + try + { + ApplyConfiguration( camera.GetNodeMap() ); + } + catch (const GenericException& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Pylon::GenericException caught in OnOpened method msg=%hs", e.what() ); + } + catch (const std::exception& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. std::exception caught in OnOpened method msg=%hs", e.what() ); + } + catch (...) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Unknown exception caught in OnOpened method." ); + } + } + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_ACQUIRESINGLEFRAMECONFIGURATION_H_6529309 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ArrayParameter.h b/Cigarette/Pylon6.2/include/pylon/ArrayParameter.h new file mode 100644 index 0000000..a841541 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ArrayParameter.h @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CArrayParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H +#define INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /*! + \brief Extends the GenApi::IRegister interface with convenience methods. + */ + interface IRegisterEx : virtual public GENAPI_NAMESPACE::IRegister, virtual public IValueEx + { + using GENAPI_NAMESPACE::IRegister::operator=; + + }; + + + /*! + \brief CArrayParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CArrayParameter : public IRegisterEx, public CParameter + { + public: + /*! + \brief Creates an empty CArrayParameter object. + \error + Does not throw C++ exceptions. + */ + CArrayParameter(); + + + /*! + \brief Creates a CArrayParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CArrayParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CArrayParameter object and attaches it to a node of a matching type. + \param[in] pRegister The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pRegister has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CArrayParameter( GENAPI_NAMESPACE::IRegister* pRegister ); + + + /*! + \brief Creates a CArrayParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CArrayParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CArrayParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CArrayParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CArrayParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CArrayParameter( const CArrayParameter& rhs ); + + + /*! + \brief Destroys the CArrayParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CArrayParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pRegister The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IRegister* pRegister ); + + + /*! + \brief Assigns a CArrayParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CArrayParameter& operator=( const CArrayParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CArrayParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pRegister The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IRegister* pRegister ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::IRegister + virtual void Set( const uint8_t* pBuffer, int64_t length, bool verify = true ); + + // Implements GenApi::IRegister + virtual void Get( uint8_t* pBuffer, int64_t length, bool verify = false, bool ignoreCache = false ); + + // Implements GenApi::IRegister + virtual int64_t GetLength(); + + // Implements GenApi::IRegister + virtual int64_t GetAddress(); + + + + protected: + GENAPI_NAMESPACE::IRegister* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/AviCompressionOptions.h b/Cigarette/Pylon6.2/include/pylon/AviCompressionOptions.h new file mode 100644 index 0000000..4068f17 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/AviCompressionOptions.h @@ -0,0 +1,126 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: AG +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains compression options declaration for the AviWriter class. +*/ +#ifndef INCLUDED_AVICOMPRESSIONOPTIONS_H_6841242 +#define INCLUDED_AVICOMPRESSIONOPTIONS_H_6841242 + +#include +#include + +#ifdef PYLON_WIN_BUILD + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union +#endif +#include +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + ///Wraps the AVI compression options of the Video for Window API + struct SAviCompressionOptions + { + + /*! + \brief Create the compression options structure. + + To use compression set up the AVICOMPRESSOPTIONS structure. + You can use the dialog provided by the Video for Windows API to do this by setting \c optionalShowDialog to true. + Alternatively, fill the AVICOMPRESSOPTIONS structure with the four character code identifying the codec + and the parameter settings of the codec. + For more information, see the MSDN documentation of the Video for Windows API and the documentation of the codec you are using. + + \param[in] optionalShowDialog Optionally show the Compression Options dialog box. + The dialog allows to set the compression parameters. + See the Video for Windows API AviSaveOptions() MSDN documentation. + \param[in] optionalHParentWindow Optional handle to the parent window for the Compression Options dialog box. + See the Video for Windows API AviSaveOptions() MSDN documentation. + */ + SAviCompressionOptions( bool optionalShowDialog = false, HWND optionalHParentWindow = NULL ) + : hParentWindow( optionalHParentWindow ) + , showDialog( optionalShowDialog ) + , userDialogReturnOk( false ) + , autoKeyFrameInsertionRate( 20 ) + { + ::ZeroMemory( &compressionOptions, sizeof( compressionOptions ) ); + } + + /*! + \brief Create the compression options structure. Preset some compression options. + + To use compression set up the AVICOMPRESSOPTIONS structure. + You can use the dialog provided by the Video for Windows API to do this by setting \c optionalShowDialog to true. + Alternatively, fill the AVICOMPRESSOPTIONS structure with the four character code identifying the codec + and the parameter settings of the codec. + For more information, see the MSDN documentation of the Video for Windows API and the documentation of the codec you are using. + + \param[in] fourCharacterCode The four character code identifying the codec to use for compression. + \param[in] optionalShowDialog Optionally show the Compression Options dialog box. + The dialog allows to set the compression parameters. + See the Video for Windows API AviSaveOptions() MSDN documentation. + \param[in] optionalHParentWindow Optional handle to the parent window for the Compression Options dialog box. + See the Video for Windows API AviSaveOptions() MSDN documentation. + */ + SAviCompressionOptions( const char* fourCharacterCode, bool optionalShowDialog = false, HWND optionalHParentWindow = NULL ) + : hParentWindow( optionalHParentWindow ) + , showDialog( optionalShowDialog ) + , userDialogReturnOk( false ) + , autoKeyFrameInsertionRate( 20 ) + { + ::ZeroMemory( &compressionOptions, sizeof( compressionOptions ) ); + + //Set compression. + compressionOptions.dwFlags = AVICOMPRESSF_VALID; + + //Handle the case if the code passes has fewer than four characters. + String_t fourCharacterCodeLocal( fourCharacterCode ); + fourCharacterCodeLocal += " "; + fourCharacterCodeLocal.resize( 4 ); + + //Set four character code. + compressionOptions.fccHandler = mmioFOURCC( fourCharacterCodeLocal[0], fourCharacterCodeLocal[1], fourCharacterCodeLocal[2], fourCharacterCodeLocal[3] ); + } + + HWND hParentWindow; ///< Optional handle to the parent window for the Compression Options dialog box. See the Video for Windows API AviSaveOptions() MSDN documentation. + bool showDialog; ///< Optionally show Compression Options dialog box. See the Video for Windows API AviSaveOptions() MSDN documentation. + bool userDialogReturnOk; ///< Is set to true in the call to the CAviWriter::Open() method if the user pressed OK in the dialog. The compression is not set up if cancel has been pressed. + LONG autoKeyFrameInsertionRate; ///< Indicates to insert a key frame every nth image when KeyFrameSelection_Auto is used. + AVICOMPRESSOPTIONS compressionOptions; ///< The AVICOMPRESSOPTIONS structure needs to be set up with the four character code identifying the codec and the parameter settings of the codec. + ///< For more information, see the MSDN documentation of the Video for Windows API and the documentation of the codec you are using. + }; + + /** + * @} + */ +} + +#else + +//No AVI support for Linux. + +#endif + + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_AVICOMPRESSIONOPTIONS_H_6841242 */ diff --git a/Cigarette/Pylon6.2/include/pylon/AviWriter.h b/Cigarette/Pylon6.2/include/pylon/AviWriter.h new file mode 100644 index 0000000..fe0e69d --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/AviWriter.h @@ -0,0 +1,295 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: AG +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains support for writing files in the Audio Video Interleave (AVI) format. +*/ +#ifndef INCLUDED_AVIWRITER_H_9434931 +#define INCLUDED_AVIWRITER_H_9434931 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + /// Exception thrown if a fatal error occurs (e.g. access violations, ...) when accessing an AVI video file + class AviWriterFatalException : public GenericException + { + public: + /** \brief \copybrief GenericException::GenericException() */ + AviWriterFatalException( const char* pDescription, const char* pSourceFileName, int SourceLine ); + AviWriterFatalException( const char* pDescription, const char* pSourceFileName, int SourceLine, const char* pExceptionType ); + AviWriterFatalException( const char* pDescription, const char* pSourceFileName, int SourceLine, const char* pEntryPoint, const char* pErrorNodeName, const char* pExceptionType ); + }; + + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /// Forward reference for compression options, requires additional include of AviCompressionOptions.h + struct SAviCompressionOptions; + + /// List the possibilities for selecting a key frame when using compression. + enum EKeyFrameSelection + { + KeyFrameSelection_NoKeyFrame, //!< Indicates that an image is not a key frame. + KeyFrameSelection_KeyFrame, //!< Indicates that an image is a key frame. + KeyFrameSelection_Auto //!< Every nth frame is a key frame. The value of n is specified by passing its value in the SAviCompressionOptions in the autoKeyFrameInsertionRate member when opening the AVI Writer. + }; + + /*! + \class CAviWriter + \brief Supports writing AVI files. + */ + class PYLONUTILITY_API CAviWriter + { + public: + /*! + \brief Creates an AVI writer object. + + \error + Does not throw C++ exceptions. + */ + CAviWriter(); + + /*! + \brief Destroys the AVI writer object. + + \error + Does not throw C++ exceptions. + */ + virtual ~CAviWriter(); + + + /*! + \brief Opens an AVI file for writing. + + If a file with the same \c filename already exists, it will be overwritten. + + \param[in] filename Name and path of the image. + \param[in] framesPerSecondPlayback The frame rate of the AVI file when shown in a media player. + \param[in] pixelType The pixel type of the image in the AVI file. + \param[in] width The number of pixels in a row. + \param[in] height The number of rows of the image. + \param[in] orientation The vertical orientation of the image data in the AVI file. + \param[in,out] pCompressionOptions Compression can be enabled by passing compression options. See SAviCompressionOptions. + + \pre +
    +
  • The AVI file is closed. +
  • The pixelType is either PixelType_Mono8, PixelType_BGR8packed or PixelType_BGRA8packed +
  • The \c width value must be > 0 and < _I32_MAX. +
  • The \c height value must be > 0 and < _I32_MAX. +
+ + \error + Throws an exception if the AVI file cannot be opened. + Throws an exception if the preconditions are not met. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Open( + const String_t& filename, + double framesPerSecondPlayback, + EPixelType pixelType, + uint32_t width, uint32_t height, + EImageOrientation orientation = ImageOrientation_BottomUp, + SAviCompressionOptions* pCompressionOptions = NULL + ); + + /*! + \brief Returns the open state of the AVI file. + + \return Returns true if open. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsOpen(); + + + /*! + \brief Closes the AVI file. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Close(); + + + /*! + \brief Adds the image to the AVI file. Converts the image to the correct format if required. + + The image is automatically converted to the format passed when opening the file if needed. + The image is also converted if the stride of the passed image is not aligned to 4 byte. + The image is also converted if the orientation of the passed image does mot match the value passed when opening the AVI file. + + If more control over the conversion is required, the CImageFormatConverter class + can be used to convert other images with a CPylonBitmapImage object as target. + The CPylonBitmapImage object can then be added to the AVI file. + + \param[in] image The image to add, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \param[in] keyFrameSelection Can be used to control key frame selection for compressed images if needed. + + \pre +
    +
  • The file is open. +
  • The image added is valid. +
  • The pixel type of the image to add is a supported input format of the Pylon::CImageFormatConverter. +
  • The width and height of the \c image match the values passed when opening the AVI file. +
  • The total size of the AVI file must not exceed 2 GB. See CAviWriter::GetImageDataBytesWritten(). +
+ + \error + Throws an exception if the image cannot be added. + + \threading + This method is synchronized using the lock provided by GetLock(). + + */ + virtual void Add( const IImage& image, EKeyFrameSelection keyFrameSelection = KeyFrameSelection_Auto ); + + + /*! + \brief Adds the image to the AVI file. Converts the image to the correct format if required. + + See Add( const Image&) for more details. + + \param[in] pBuffer The pointer to the buffer of the image. + \param[in] bufferSize The size of the buffer in byte. + \param[in] pixelType The pixel type of the image to save. + \param[in] width The number of pixels in a row of the image to save. + \param[in] height The number of rows of the image to save. + \param[in] paddingX The number of extra data bytes at the end of each line. + \param[in] orientation The vertical orientation of the image in the image buffer. + \param[in] keyFrameSelection Can be used to control key frame selection for compressed images if needed. + + \pre +
    +
  • The file is open. +
  • The image added is valid. +
  • The pixel type of the image to add is a supported input format of the Pylon::CImageFormatConverter. +
  • The width and height of the \c image match the values passed when opening the AVI file. +
  • The total size of the AVI file must not exceed 2 GB. See CAviWriter::GetImageDataBytesWritten(). +
+ + \error + Throws an exception if the image cannot be added. + + \threading + This method is synchronized using the lock provided by GetLock(). + + */ + virtual void Add( const void* pBuffer, size_t bufferSize, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation, EKeyFrameSelection keyFrameSelection = KeyFrameSelection_Auto ); + + + /*! + \brief Can be used to check whether the given image is added to the AVI file without prior conversion when Add() is called. + + \param[in] pixelType The pixel type of the image to save. + \param[in] width The number of pixels in a row of the image to save. + \param[in] height The number of rows of the image to save. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image data in the AVI file. + + \return Returns true if the image is added to the AVI stream without prior conversion when Add() is called. + Returns false if the image is automatically converted when Add() is called. + Returns false if the image cannot be added at all. See the preconditions of Add() for more information. + + \error + Does not throw C++ exceptions. + */ + virtual bool CanAddWithoutConversion( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation ); + + + /*! + \brief Can be used to check whether the given image is added to the AVI file without prior conversion when Add() is called. + + \param[in] image The image to save, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \return Returns true if the image is added to the AVI stream without prior conversion when Add() is called. + Returns false if the image is automatically converted when Add() is called. + Returns false if the image cannot be added at all. See the preconditions of Add() for more information. + + \error + Does not throw C++ exceptions. + */ + virtual bool CanAddWithoutConversion( const IImage& image ); + + /*! + \brief Provides access to the number of images that have been added to the AVI file. + + \return Returns the number of images that have been added to the AVI file. + Returns 0 if no AVI file has been written yet. + \error + Does not throw C++ exceptions. + */ + virtual size_t GetCountOfAddedImages() const; + + /*! + \brief Provides access to the number of image data bytes written to the AVI file. + + This value is updated with each call to AviWriter::Add(). + + Depending on the used image format and codec, about + 5 KB of header information and padding bytes are written to the AVI file. + Furthermore, 24 additional bytes are needed per image for chunk header and index entry data. + + \return Returns the number of image data bytes that have been written to the AVI file. + Returns 0 if no AVI File has been written yet. + This size does not include the sizes of the AVI file header and AVI file index. + + \error + Does not throw C++ exceptions. + */ + virtual size_t GetImageDataBytesWritten() const; + + protected: + + /*! + \brief Provides access to the lock used for synchronizing the access to the AVI writer. + + \error + Does not throw C++ exceptions. + */ + CLock& GetLock(); + + + private: + // The object can not be copied. + CAviWriter( const CAviWriter& ); + // The object can not be copied. + void operator = ( const CAviWriter& ); + + // Internal use only. + class CAviWriterImpl; + CAviWriterImpl* m_pImpl; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_AVIWRITER_H_9434931 */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalCameraEventHandler.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalCameraEventHandler.h new file mode 100644 index 0000000..6aeed5f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalCameraEventHandler.h @@ -0,0 +1,162 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the camera event handler base class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALCAMERAEVENTHANDLER_H +#define INCLUDED_BASLERUNIVERSALCAMERAEVENTHANDLER_H + +#pragma once + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class CBaslerUniversalInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + /** + \class CBaslerUniversalCameraEventHandler + \brief The camera event handler base class. + */ + class CBaslerUniversalCameraEventHandler + { + public: + + /** + \brief This method is called when a camera event has been received. + + Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the + processing of images. + + \param[in] camera The source of the call. + \param[in] userProvidedId The ID passed when registering for the event. It can be used to distinguish between different events. + \param[in] pNode The node identified by node name when registering. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + \threading + This method is called outside the lock of the camera object, outside the lock of the node map, and inside the lock of the camera event handler registry. + */ + virtual void OnCameraEvent( CBaslerUniversalInstantCamera& camera, intptr_t userProvidedId, GENAPI_NAMESPACE::INode* pNode ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( userProvidedId ); + PYLON_UNUSED( pNode ); + } + + /** + \brief This method is called when the camera event handler has been registered. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerUniversalCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerRegistered( CBaslerUniversalInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( nodeName ); + PYLON_UNUSED( userProvidedId ); + } + + /** + \brief This method is called when the camera event handler has been deregistered. + + The camera event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerUniversalCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerDeregistered( CBaslerUniversalInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( nodeName ); + PYLON_UNUSED( userProvidedId ); + } + + /*! + \brief Destroys the camera event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyCameraEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerUniversalCameraEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerUniversalCameraEventHandler( const CBaslerUniversalCameraEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerUniversalCameraEventHandler& operator=( const CBaslerUniversalCameraEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerUniversalCameraEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUNIVERSALCAMERAEVENTHANDLER_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalConfigurationEventHandler.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalConfigurationEventHandler.h new file mode 100644 index 0000000..be84140 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalConfigurationEventHandler.h @@ -0,0 +1,411 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the configuration event handler base class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALCONFIGURATIONEVENTHANDLERH +#define INCLUDED_BASLERUNIVERSALCONFIGURATIONEVENTHANDLERH + +#pragma once + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + class CBaslerUniversalInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + /** + \class CBaslerUniversalConfigurationEventHandler + \brief The configuration event handler base class. + */ + class CBaslerUniversalConfigurationEventHandler + { + public: + /** + \brief This method is called before a %Pylon Device (Pylon::IPylonDevice) is attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttach( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a %Pylon Device (Pylon::IPylonDevice) has been attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttached( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is detached from the Instant Camera object. + + The camera's Detach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetach( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been detached from the Instant Camera object. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetached( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is destroyed. + + Camera DestroyDevice must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroy( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroyed( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpen( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpened( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is closed. + + Camera Close must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClose( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been closed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClosed( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before a grab session is started. + + Camera StartGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStart( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a grab session has been started. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStarted( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before a grab session is stopped. + + Camera StopGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStop( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a grab session has been stopped. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStopped( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when an exception has been triggered during grabbing. + + An exception has been triggered by a grab thread. The grab will be stopped after this event call. + + \param[in] camera The source of the call. + \param[in] errorMessage The message of the exception that signaled an error during grabbing. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabError( CBaslerUniversalInstantCamera& camera, const char* errorMessage ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( errorMessage ); + } + + /** + \brief This method is called when a camera device removal from the PC has been detected. + + The %Pylon Device attached to the Instant Camera is not operable after this event. + After it is made sure that no access to the %Pylon Device or any of its node maps is made anymore + the %Pylon Device should be destroyed using InstantCamera::DeviceDestroy(). + The access to the %Pylon Device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object from an additional thread. + */ + virtual void OnCameraDeviceRemoved( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + + /** + \brief This method is called when the configuration event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationRegistered( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when the configuration event handler has been deregistered. + + The configuration event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationDeregistered( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /*! + \brief Destroys the configuration event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyConfiguration() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerUniversalConfigurationEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerUniversalConfigurationEventHandler( const CBaslerUniversalConfigurationEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerUniversalConfigurationEventHandler& operator=( const CBaslerUniversalConfigurationEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerUniversalConfigurationEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUNIVERSALCONFIGURATIONEVENTHANDLERH */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalGrabResultData.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalGrabResultData.h new file mode 100644 index 0000000..86a1157 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalGrabResultData.h @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief pylon universal grab result data class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALGRABRESULTDATA_H +#define INCLUDED_BASLERUNIVERSALGRABRESULTDATA_H + +#pragma once + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + /// The Universal grab result data. + class CBaslerUniversalGrabResultData : public CGrabResultData, public Basler_UniversalChunkDataParams::CUniversalChunkDataParams_Params + { + protected: + // Internal use only. The grab result data class should only be created by the instant camera class. + friend class CBaslerUniversalInstantCamera; + CBaslerUniversalGrabResultData() + { + } + + // Internal use only. + virtual void Destroy() + { + delete this; + } + + // Internal use only. + virtual void Initialize() + { + _Initialize( &GetChunkDataNodeMap() ); + } + }; + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERUNIVERSALGRABRESULTDATA_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalGrabResultPtr.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalGrabResultPtr.h new file mode 100644 index 0000000..2cfefc5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalGrabResultPtr.h @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief pylon universal grab result data class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALGRABRESULTPTR_H +#define INCLUDED_BASLERUNIVERSALGRABRESULTPTR_H + +#pragma once + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + /// The Universal grab result smart pointer. + PYLON_DEFINE_DEVICE_SPECIFIC_GRAB_RESULT_PTR( CBaslerUniversalGrabResultPtr, CBaslerUniversalGrabResultData ) + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERUNIVERSALGRABRESULTPTR_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalImageEventHandler.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalImageEventHandler.h new file mode 100644 index 0000000..2286954 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalImageEventHandler.h @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the image event handler base class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALIMAGEEVENTHANDLER_H +#define INCLUDED_BASLERUNIVERSALIMAGEEVENTHANDLER_H + +#pragma once + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class CBaslerUniversalInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + /** + \class CBaslerUniversalImageEventHandler + \brief The image event handler base class. + */ + class CBaslerUniversalImageEventHandler + { + public: + + /** + \brief This method is called when images have been skipped using the GrabStrategy_LatestImageOnly strategy or the GrabStrategy_LatestImages strategy. + + \param[in] camera The source of the call. + \param[in] countOfSkippedImages The number of images skipped. This \c countOfSkippedImages does not include the number of images lost in the case of a buffer under run in the driver. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImagesSkipped( CBaslerUniversalInstantCamera& camera, size_t countOfSkippedImages ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( countOfSkippedImages ); + } + + /** + \brief This method is called when an image has been grabbed. + + The grab result smart pointer passed does always reference a grab result data object. + The status of the grab needs to be checked before accessing the grab result data. + See CGrabResultData::GrabSucceeded(), CGrabResultData::GetErrorCode() and + CGrabResultData::GetErrorDescription() for more information. + + \param[in] camera The source of the call. + \param[in] grabResult The grab result data. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImageGrabbed( CBaslerUniversalInstantCamera& camera, const CBaslerUniversalGrabResultPtr& grabResult ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( grabResult ); + } + + /** + \brief This method is called when the image event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerRegistered( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when the image event handler has been deregistered. + + The image event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerDeregistered( CBaslerUniversalInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /*! + \brief Destroys the image event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyImageEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerUniversalImageEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerUniversalImageEventHandler( const CBaslerUniversalImageEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerUniversalImageEventHandler& operator=( const CBaslerUniversalImageEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerUniversalImageEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUNIVERSALIMAGEEVENTHANDLER_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalInstantCamera.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalInstantCamera.h new file mode 100644 index 0000000..398fe91 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalInstantCamera.h @@ -0,0 +1,212 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief pylon universal instant camera class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H +#define INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + class CBaslerUniversalInstantCamera; + + /// Lists all the types used by the universal instant camera class. + struct CBaslerUniversalInstantCameraTraits + { + /// The type of the final camera class. + typedef CBaslerUniversalInstantCamera InstantCamera_t; + /// \copybrief Basler_UniversalCameraParams::CUniversalCameraParams_Params + typedef Basler_UniversalCameraParams::CUniversalCameraParams_Params CameraParams_t; + /// \copybrief Pylon::IPylonDevice + typedef IPylonDevice IPylonDevice_t; + /// \copybrief Pylon::CDeviceInfo + typedef Pylon::CDeviceInfo DeviceInfo_t; + /// \copybrief Basler_UniversalTLParams::CUniversalTLParams_Params + typedef CNodeMapProxyT TlParams_t; + /// The parameters of the universal stream grabber. + typedef CNodeMapProxyT StreamGrabberParams_t; + /// The parameters of the universal event grabber. + typedef CNodeMapProxyT EventGrabberParams_t; + /// The universal configuration event handler class. + typedef CBaslerUniversalConfigurationEventHandler ConfigurationEventHandler_t; + /// The universal image event handler class. + typedef CBaslerUniversalImageEventHandler ImageEventHandler_t; + /// The universal camera event handler class. + typedef CBaslerUniversalCameraEventHandler CameraEventHandler_t; + /// The universal grab result data. + typedef CBaslerUniversalGrabResultData GrabResultData_t; + /// The universal grab result smart pointer. + typedef CBaslerUniversalGrabResultPtr GrabResultPtr_t; + + //! Can be used to check whether the DeviceClass() can be used for enumeration. + static bool HasSpecificDeviceClass() + { + return false; + } +//! The name of this device class. Use this one for enumeration. + static String_t DeviceClass() + { + throw LOGICAL_ERROR_EXCEPTION( "The CBaslerUniversalInstantCamera has no specific device class. The method DeviceClass() cannot be used." ); + } + + }; + /*! + \class CBaslerUniversalInstantCamera + \brief Extends the CInstantCamera by universal parameter interface classes combining all interface types. + */ + class CBaslerUniversalInstantCamera : public CDeviceSpecificInstantCameraT + { + public: + /*! + \copybrief CInstantCamera::CInstantCamera() + \copydetails CInstantCamera::CInstantCamera + */ + CBaslerUniversalInstantCamera() + { + } + + /*! + \copybrief CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + \copydetails CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + */ + CBaslerUniversalInstantCamera( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ) + : CDeviceSpecificInstantCameraT( pDevice, cleanupProcedure ) + { + } + + /*! + \copybrief CInstantCamera::~CInstantCamera + \copydetails CInstantCamera::~CInstantCamera + */ + ~CBaslerUniversalInstantCamera() + { + Attach( NULL ); + InternalShutdownEventHandlers(); + } + + /*! + \brief Enables/disables use of persistent IP address and DHCP usage of the attached %Pylon Device. + + See Pylon::IPylonGigEDevice::ChangeIpConfiguration() + + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp ) + { + AutoLock lock( CInstantCamera::GetLock() ); + GetGigEDevice()->ChangeIpConfiguration( EnablePersistentIp, EnableDhcp ); + } + + /*! + \brief Reads the persistent IP address from the attached %Pylon Device. + + See Pylon::IPylonGigEDevice::GetPersistentIpAddress() + + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway ) + { + AutoLock lock( CInstantCamera::GetLock() ); + GetGigEDevice()->GetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway ); + } + + /*! + \brief Writes a persistent IP address to the attached %Pylon Device. + + See Pylon::IPylonGigEDevice::SetPersistentIpAddress() + + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + void SetPersistentIpAddress( const String_t& IpAddress, + const String_t& SubnetMask, + const String_t& DefaultGateway ) + + { + AutoLock lock( CInstantCamera::GetLock() ); + GetGigEDevice()->SetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway ); + } + + protected: + //Get the pointer for the Universal device. + virtual IPylonGigEDevice* GetGigEDevice() + { + IPylonDevice* pDevice = CInstantCamera::GetDevice(); + IPylonGigEDevice* pGigEDevice = dynamic_cast(pDevice); + + // Check whether device type matches camera type. + if (!pGigEDevice) + { + throw LOGICAL_ERROR_EXCEPTION( "The attached pylon device type must be a GigE device." ); + } + + return pGigEDevice; + } + + //Create device grab result data. Is subject to change without notice. + virtual CGrabResultData* CreateDeviceSpecificGrabResultData() + { + return new GrabResultData_t(); + } + }; + + /** + * @} + */ + +} // namespace Pylon + +#endif /* INCLUDED_BASLERUNIVERSALINSTANTCAMERA_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/BaslerUniversalInstantCameraArray.h b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalInstantCameraArray.h new file mode 100644 index 0000000..375d52f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BaslerUniversalInstantCameraArray.h @@ -0,0 +1,58 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief pylon universal instant camera array class. +*/ + +#ifndef INCLUDED_BASLERUNIVERSALINSTANTCAMERAARRAY_H +#define INCLUDED_BASLERUNIVERSALINSTANTCAMERAARRAY_H + +#pragma once + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + + /*! + \class CBaslerUniversalInstantCameraArray + \brief Universal instant camera array. + + \threading + The CBaslerUniversalInstantCameraArray class is not thread-safe. + */ + class CBaslerUniversalInstantCameraArray : public CDeviceSpecificInstantCameraArrayT + { + public: + /*! + \copybrief CInstantCameraArray::CInstantCameraArray() + \copydetails CInstantCameraArray::CInstantCameraArray() + */ + CBaslerUniversalInstantCameraArray() + { + } + /*! + \copybrief CInstantCameraArray::CInstantCameraArray( size_t) + \copydetails CInstantCameraArray::CInstantCameraArray( size_t) + */ + CBaslerUniversalInstantCameraArray( size_t numberOfCameras ) : CDeviceSpecificInstantCameraArrayT( numberOfCameras ) + { + } + + }; + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERUNIVERSALINSTANTCAMERAARRAY_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/BooleanParameter.h b/Cigarette/Pylon6.2/include/pylon/BooleanParameter.h new file mode 100644 index 0000000..5eb67c7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BooleanParameter.h @@ -0,0 +1,301 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CBooleanParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CBOOLEANPARAMETER_H +#define INCLUDED_BASLER_PYLON_CBOOLEANPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /*! + \brief Extends the GenApi::IBoolean interface with convenience methods. + */ + interface IBooleanEx : virtual public GENAPI_NAMESPACE::IBoolean, virtual public IValueEx + { + using GENAPI_NAMESPACE::IBoolean::operator=; + + /*! + \brief Sets the Boolean value of the parameter if the parameter is writable. + \return Returns false if the parameter is not writable. + \param[in] value The Boolean value to set. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual bool TrySetValue( bool value ) = 0; + + + /*! + \brief Gets the Boolean value of the parameter if the parameter is readable. + \brief Otherwise returns the default value. + \return Returns the parameter value if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading the value fails. + */ + virtual bool GetValueOrDefault( bool defaultValue ) = 0; + }; + + + /*! + \brief CBooleanParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CBooleanParameter : public IBooleanEx, public CParameter + { + public: + /*! + \brief Creates an empty CBooleanParameter object. + \error + Does not throw C++ exceptions. + */ + CBooleanParameter(); + + + /*! + \brief Creates a CBooleanParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CBooleanParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CBooleanParameter object and attaches it to a node of a matching type. + \param[in] pBoolean The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pBoolean has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CBooleanParameter( GENAPI_NAMESPACE::IBoolean* pBoolean ); + + + /*! + \brief Creates a CBooleanParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CBooleanParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CBooleanParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CBooleanParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CBooleanParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CBooleanParameter( const CBooleanParameter& rhs ); + + + /*! + \brief Destroys the CBooleanParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CBooleanParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pBoolean The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IBoolean* pBoolean ); + + + /*! + \brief Assigns a CBooleanParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CBooleanParameter& operator=( const CBooleanParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CBooleanParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pBoolean The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IBoolean* pBoolean ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::IBoolean + virtual void SetValue( bool value, bool verify = true ); + + // Implements GenApi::IBoolean + virtual void operator=( bool value ); + + // Implements GenApi::IBoolean + virtual bool GetValue( bool verify = false, bool ignoreCache = false ) const; + + // Implements GenApi::IBoolean + virtual bool operator()() const; + + + // Implements IBooleanEx + virtual bool TrySetValue( bool value ); + + // Implements IEnumerationEx + virtual bool GetValueOrDefault( bool defaultValue ); + + protected: + GENAPI_NAMESPACE::IBoolean* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CBOOLEANPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/BufferFactory.h b/Cigarette/Pylon6.2/include/pylon/BufferFactory.h new file mode 100644 index 0000000..3e6c5b8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/BufferFactory.h @@ -0,0 +1,97 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains an interface for a buffer factory. +*/ + +#ifndef INCLUDED_BUFFERFACTORY_H_264599 +#define INCLUDED_BUFFERFACTORY_H_264599 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +namespace Pylon +{ + /*! + \class IBufferFactory + \brief Usable to create a custom buffer factory when needed. + \ingroup Pylon_InstantCameraApiGeneric + */ + interface IBufferFactory + { + public: + /// Ensure proper destruction by using a virtual destructor. + virtual ~IBufferFactory() = 0; + + /*! + \brief Allocates a buffer and provides additional context information. + + + \param[in] bufferSize The size of the buffer that has to be allocated. + \param[out] pCreatedBuffer Return the pointer to the allocated buffer. May return NULL if the allocation fails. + \param[out] bufferContext Context information that belongs to the buffer. + This context information is provided when FreeBuffer() is called. + The value can be left unchanged if not needed. + + \threading + This method can be run by different threads. It is called from threads that + call Pylon::CInstantCamera::StartGrabbing() and it can be called by the internal + grab engine thread. + + \error + May throw an exception if the allocation fails. + */ + virtual void AllocateBuffer( size_t bufferSize, void** pCreatedBuffer, intptr_t& bufferContext ) = 0; + + + /*! + \brief Frees a previously allocated buffer. + + \param[in] pCreatedBuffer The pointer to the allocated buffer. Created by this factory. + \param[in] bufferContext Context information of the buffer returned by AllocateBuffer(). + + \error + Does not throw C++ exceptions. + */ + virtual void FreeBuffer( void* pCreatedBuffer, intptr_t bufferContext ) = 0; + + + /*! + \brief Destroys the buffer factory. + + This method is called when the buffer factory is not needed any longer. + The object implementing IBufferFactory can be deleted by calling: delete this. + + \threading + This method can be run by different threads. It is called from threads that are running the + destructor of a Pylon::CGrabResultPtr or call Pylon::CInstantCamera::StopGrabbing(). + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyBufferFactory() = 0; + }; + + // Implementation required for Windows only. + // Note: the C++ standards >= C11 prohibit pure virtual destructors with a function body + // in the declaration. Consequently GCC 4.0 and newer GCC versions reject an inline implementation + // in the class. + inline IBufferFactory::~IBufferFactory() + { + } +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BUFFERFACTORY_H_264599 */ diff --git a/Cigarette/Pylon6.2/include/pylon/Callback.h b/Cigarette/Pylon6.2/include/pylon/Callback.h new file mode 100644 index 0000000..7abfc7d --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Callback.h @@ -0,0 +1,266 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: HN, AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of callback objects. + +Helper functions used for managing callbacks. Callback objects are used +to encapsulate C-style functions or C++ member functions as +callbacks. + +Based on the ideas of Paul Jakubik. +*/ + +#ifndef __PYLON_CALLBACK_H__ +#define __PYLON_CALLBACK_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include +#include + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + + /* + \brief Abstract callback container. + + This helper class is used to manage device removal callbacks. + + \see RegisterRemovalCallback() + \see IPylonDevice::RegisterRemovalCallback() + */ + template + class Base_Callback1Body + { + public: + //! destructor + virtual ~Base_Callback1Body( void ) + { + }; + + //! do operation with P1 as argument + virtual void operator()( P1 ) const = 0; + + //! deep copy + virtual Base_Callback1Body* clone( void ) const = 0; + }; + + /* + \brief Callback object with one parameter P1 + + This helper class is used to manage device removal callbacks. + + \see RegisterRemovalCallback() + \see IPylonDevice::RegisterRemovalCallback() + */ + template + class Callback1 + { + public: + + //! constructor, taking lifetime control of body + Callback1( Base_Callback1Body* pBody ) : + m_pBody( pBody ) + { + } + + //! copy constructor doing deep copy + Callback1( const Callback1& callback ) : + m_pBody( callback.m_pBody ? callback.m_pBody->clone() : NULL ) + { + } + + //! destructor, destroying body + ~Callback1( void ) + { + delete m_pBody; + m_pBody = NULL; + } + + //! assignment operator + Callback1& operator=( const Callback1& callback ) + { + if (this != &callback) + { + delete m_pBody; + m_pBody = callback.m_pBody ? callback.m_pBody->clone() : NULL; + } + return *this; + } + + //! do operation defined in body + void operator()( P1 p1 ) + { + if (m_pBody) + (*m_pBody)(p1); + else + assert( false && "Callback1:Empty body" ); + } + + private: + Base_Callback1Body* m_pBody; + }; + + + /***************************************************************************/ + // C Functions as callbacks + /***************************************************************************/ + + /* + \brief Container for a function pointer + + This helper class is used to manage device removal callbacks. + + \see RegisterRemovalCallback() + \see IPylonDevice::RegisterRemovalCallback() + */ + template + class Function_CallbackBody : public Base_Callback1Body

+ { + public: + //! Constructor + Function_CallbackBody( const Function& function ) : + m_pFunction( function ) + { + } + + //! execute operation: call the function + void operator()( P p ) const + { + if (m_pFunction) + m_pFunction( p ); + } + + //! virtual copy constructor + Function_CallbackBody* clone( void ) const + { + return new Function_CallbackBody( *this ); + } + private: + //! the callback function + const Function m_pFunction; + + //! no assignment operator + Function_CallbackBody& operator=( Function_CallbackBody& ); + }; + + + /* + \brief Make a new callback object for C functions + + This helper function is used to manage device removal callbacks. + + Use one of the the Pylon::RegisterRemovalCallback() functions to + register a callback that is fired in case of a device removal. + + \see IPylonDevice::RegisterRemovalCallback() + \see RegisterRemovalCallback() + */ + template + Callback make_FunctionCallback( Function function ) + { + return new Function_CallbackBody( function ); + } + + + /*-----------------------------------------------------------------------------*/ + + + /***************************************************************************/ + // C++ Member functions as callbacks + /***************************************************************************/ + + /* + \brief Container for a member function pointer + + This helper class is used to manage device removal callbacks. + + \see RegisterRemovalCallback() + \see IPylonDevice::RegisterRemovalCallback() + */ + template + class Member_CallbackBody : public Base_Callback1Body

+ { + public: + //! Member function type + typedef void (Client::* PMEMBERFUNC)(P); + + //! Constructor + Member_CallbackBody( Client& client, Member member ) : + m_Client( client ), + m_pMemberFunc( member ) + { + } + + //! execute operation + void operator()( P pP ) const + { + if (m_pMemberFunc) + (m_Client.*m_pMemberFunc)(pP); + } + + //! virtual copy constructor + Member_CallbackBody* clone() const + { + return new Member_CallbackBody( m_Client, m_pMemberFunc ); + } + + private: + //! The object the method function belongs to + Client& m_Client; + + //! The method to call + PMEMBERFUNC m_pMemberFunc; + + //! no assignment operator + Member_CallbackBody& operator=( Member_CallbackBody& ); + + //! no copy constructor + Member_CallbackBody( const Member_CallbackBody& ); + }; + + /*-----------------------------------------------------------------------------*/ + + /* + \brief Make a new callback object for member functions + + \brief Make a new callback object for C functions + + This helper function is used to manage device removal callbacks. + + Use one of the the Pylon::RegisterRemovalCallback() functions to + register a callback that is fired in case of a device removal. + + \see RegisterRemovalCallback() + \see IPylonDevice::RegisterRemovalCallback() + */ + + template + Callback make_MemberFunctionCallback( Client& client, Member member ) + { + return Callback( static_cast*>(new Member_CallbackBody( client, member )) ); + } + + + + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/CameraEventHandler.h b/Cigarette/Pylon6.2/include/pylon/CameraEventHandler.h new file mode 100644 index 0000000..f536b22 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/CameraEventHandler.h @@ -0,0 +1,160 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the camera event handler base class. +*/ + +#ifndef INCLUDED_CAMERAEVENTHANDLER_H_3102315 +#define INCLUDED_CAMERAEVENTHANDLER_H_3102315 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class CInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /** + \class CCameraEventHandler + \brief The camera event handler base class. + */ + class CCameraEventHandler + { + public: + + /** + \brief This method is called when a camera event has been received. + + Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the + processing of images. + + \param[in] camera The source of the call. + \param[in] userProvidedId The ID passed when registering for the event. It can be used to distinguish between different events. + \param[in] pNode The node identified by node name when registering. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + \threading + This method is called outside the lock of the camera object, outside the lock of the node map, and inside the lock of the camera event handler registry. + */ + virtual void OnCameraEvent( CInstantCamera& camera, intptr_t userProvidedId, GENAPI_NAMESPACE::INode* pNode ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( userProvidedId ); + PYLON_UNUSED( pNode ); + } + + /** + \brief This method is called when the camera event handler has been registered. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerRegistered( CInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( nodeName ); + PYLON_UNUSED( userProvidedId ); + } + + /** + \brief This method is called when the camera event handler has been deregistered. + + The camera event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerDeregistered( CInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( nodeName ); + PYLON_UNUSED( userProvidedId ); + } + + /*! + \brief Destroys the camera event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyCameraEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CCameraEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CCameraEventHandler( const CCameraEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CCameraEventHandler& operator=( const CCameraEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CCameraEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_CAMERAEVENTHANDLER_H_3102315 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ChunkParser.h b/Cigarette/Pylon6.2/include/pylon/ChunkParser.h new file mode 100644 index 0000000..a15da30 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ChunkParser.h @@ -0,0 +1,201 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Lutz Koschorreck +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Definition of the IChunkParser interface. +*/ + +#pragma once + +#ifndef CHUNKPARSER_H__ +#define CHUNKPARSER_H__ + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +// additional forwards +namespace GENAPI_NAMESPACE +{ + class CChunkAdapter; + struct AttachStatistics_t; +} + +namespace Pylon +{ + /*! \interface IChunkParser + \brief Low Level API: The interface for chunk parsers analyzing a data stream consisting of chunks + + When chunk data is enabled in the camera the stream sends additional data along with + the image. This data needs to be extracted with help of a chunk parser. + These are created using the camera's member function IPylonDevice::CreateChunkParser(). + + When an image buffer containing chunked data is passed to a chunk parser, + the camera's chunk related parameters are updated. After changing the data + layout either by changing the AOI or enabling/disabling chunk features the + parser needs to be reinitialized by calling IChunkParser::AttachBuffer(). + Thereafter buffers with the same layout are processed with the + IChunkParser::UpdateBuffer() method. Chunk related properties remain unchanged + until a new buffer is passed in. + + After usage return the chunk parser with a call of the camera's + IPylonDevice::DestroyChunkParser() member function. + + The code snippet below demonstrates the usage of a chunk parser. A + complete program is found in the sample AcquireSingleFrame_ChunkImage. + + \note Check the payload type of the GrabResult_t before attaching or + updating the buffer. + + \ingroup Pylon_LowLevelApi + + \code + IChunkParser &ChunkParser = *Camera.CreateChunkParser(); + + // enable Frame Counter chunk + Camera.ChunkModeActive.SetValue( true ); + Camera.ChunkSelector.SetValue( ChunkSelector_Framecounter ); + Camera.ChunkEnable.SetValue( true ); + + // retrieve data from the chunk + GrabResult Result; + if (StreamGrabber.RetrieveResult( Result ) && + Result.Succeeded() && + Result.PayloadType() == PayloadType_ChunkData) + { + ChunkParser.AttachBuffer( Result.Buffer(), Result.GetPayloadSize() ); + int64_t frameCounter = Camera.ChunkFramecounter.GetValue(); + } + \endcode + + */ + interface PUBLIC_INTERFACE IChunkParser + { + public: + /// Pass in a buffer and let the chunk parser analyze it. + /*! Corresponding parameters of the camera object reflecting the chunked data + will be updated. + \param pBuffer Pointer to the new buffer + \param BufferLength Size of the new buffer in bytes + \param pAttachStatistics (optional) Pointer to a record taking statistic + data of the analyzed buffer + */ + virtual void AttachBuffer( const void* pBuffer, int64_t BufferLength, GENAPI_NAMESPACE::AttachStatistics_t* pAttachStatistics = NULL ) = 0; + + /// \brief Detaches a buffer from the chunk parser. The buffer will no longer accessed by the chunk parser + /*! + // An attached buffer must be detached before freeing it. When attaching a new buffer, the previous + // one gets detached automatically. + */ + virtual void DetachBuffer() = 0; + + /// \brief Pass in a buffer and let the chunk parser update the camera object's parameters. + /*! + This method can be used when the layout of the chunk data hasn't changed since a previous buffer + has been attached to the chunk parser. In this case UpdateBuffer is slightly faster than AttachBuffer, + because the buffer's layout is reused. + If you call UpdateBuffer without having called AttachBuffer first, a LogicalErrorException is raised. + \param pBaseAddress Pointer to the new buffer + */ + virtual void UpdateBuffer( const void* pBaseAddress ) = 0; + /// Checks if buffer has a CRC attached + /*! + \return true if the buffer contains CRC value. + */ + virtual bool HasCRC() const = 0; + + /// Checks CRC sum of buffer + /*! + \return true if the contained CRC equals the computed value. + */ + virtual bool CheckCRC() const = 0; + }; + + /*! + \interface ISelfReliantChunkParser + \brief Low Level API: Interface for chunk parsers with an own chunk data node map attached. + This type of chunk parser updates the an own node map containing + only the chunk data nodes instead of updating the devices node map. + This is useful for attaching the chunk data to a grab result. + + \ingroup Pylon_LowLevelApi + */ + interface ISelfReliantChunkParser : public IChunkParser + { + /// Provides access to the chunk data node map that the parser updates. + /*! + \return The chunk data node map of the parser + */ + virtual GENAPI_NAMESPACE::INodeMap* GetChunkDataNodeMap() = 0; + + /// Makes the object to destroy itself. + /*! + This is an alternative to destroying it via the IPylonDevice interface. + It is used when the device has been destroyed already. + */ + virtual void Destroy() = 0; + }; + + /// Low Level API: Base class for chunk parsers returned by camera objects + /*! + Part implementation of chunk parser of common functionality. + + \ingroup Pylon_LowLevelApi + */ + class PYLONBASE_API CChunkParser : public ISelfReliantChunkParser + { + public: + // \name IChunkParser implementation + // \{ + void AttachBuffer( const void* pBuffer, int64_t BufferLength, GENAPI_NAMESPACE::AttachStatistics_t* pAttachStatistics = NULL ); + void DetachBuffer(); + void UpdateBuffer( const void* pBaseAddress ); + GENAPI_NAMESPACE::INodeMap* GetChunkDataNodeMap(); + void Destroy(); + // \} + + protected: + /// default constructor - make it protected to prevent this class from instantiation + explicit CChunkParser( GENAPI_NAMESPACE::CChunkAdapter* pParser ); + /// destructor + virtual ~CChunkParser(); + + protected: + /// Pointer to the GenApi workhorse. + GENAPI_NAMESPACE::CChunkAdapter* m_pParser; + + class PYLONBASE_API CBuffer + { + public: + CBuffer( const void* pBuffer, int64_t BufferSize_by ); + ~CBuffer(); + operator bool() const; + int64_t GetSize() const; + const void* operator&() const; + + private: + const void* m_pBuffer; + int64_t m_BufferLength_by; + + } m_AttachedBuffer; + + bool m_IsBufferAttached; + }; + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // __CHUNKPARSER_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/CommandParameter.h b/Cigarette/Pylon6.2/include/pylon/CommandParameter.h new file mode 100644 index 0000000..ffa7112 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/CommandParameter.h @@ -0,0 +1,281 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CCommandParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CCOMMANDPARAMETER_H +#define INCLUDED_BASLER_PYLON_CCOMMANDPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /*! + \brief Extends the GenApi::ICommand interface with convenience methods. + */ + interface ICommandEx : virtual public GENAPI_NAMESPACE::ICommand, virtual public IValueEx + { + using GENAPI_NAMESPACE::ICommand::operator=; + + /*! + \brief Executes the command and returns immediately if the parameter is writable. + \return Returns false if the parameter is not writable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if accessing the camera failed. + */ + virtual bool TryExecute() = 0; + }; + + + /*! + \brief CCommandParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CCommandParameter : public ICommandEx, public CParameter + { + public: + /*! + \brief Creates an empty CCommandParameter object. + \error + Does not throw C++ exceptions. + */ + CCommandParameter(); + + + /*! + \brief Creates a CCommandParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +

    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CCommandParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CCommandParameter object and attaches it to a node of a matching type. + \param[in] pCommand The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pCommand has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CCommandParameter( GENAPI_NAMESPACE::ICommand* pCommand ); + + + /*! + \brief Creates a CCommandParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CCommandParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CCommandParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CCommandParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CCommandParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CCommandParameter( const CCommandParameter& rhs ); + + + /*! + \brief Destroys the CCommandParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CCommandParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pCommand The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::ICommand* pCommand ); + + + /*! + \brief Assigns a CCommandParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CCommandParameter& operator=( const CCommandParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CCommandParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pCommand The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::ICommand* pCommand ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::ICommand + virtual void Execute( bool verify = true ); + + // Implements GenApi::ICommand + virtual void operator()(); + + // Implements GenApi::ICommand + virtual bool IsDone( bool verify = true ); + + + // Implements ICommandEx + virtual bool TryExecute(); + + protected: + GENAPI_NAMESPACE::ICommand* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CCOMMANDPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/ConfigurationEventHandler.h b/Cigarette/Pylon6.2/include/pylon/ConfigurationEventHandler.h new file mode 100644 index 0000000..ae0d6b7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ConfigurationEventHandler.h @@ -0,0 +1,409 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the configuration event handler base class. +*/ + +#ifndef INCLUDED_CONFIGURATIONEVENTHANDLER_H_01627755 +#define INCLUDED_CONFIGURATIONEVENTHANDLER_H_01627755 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + class CInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /** + \class CConfigurationEventHandler + \brief The configuration event handler base class. + */ + class CConfigurationEventHandler + { + public: + /** + \brief This method is called before a %Pylon Device (Pylon::IPylonDevice) is attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttach( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a %Pylon Device (Pylon::IPylonDevice) has been attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttached( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is detached from the Instant Camera object. + + The camera's Detach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetach( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been detached from the Instant Camera object. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetached( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is destroyed. + + Camera DestroyDevice must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroy( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroyed( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpen( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpened( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is closed. + + Camera Close must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClose( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been closed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClosed( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before a grab session is started. + + Camera StartGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStart( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a grab session has been started. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStarted( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before a grab session is stopped. + + Camera StopGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStop( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a grab session has been stopped. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStopped( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when an exception has been triggered during grabbing. + + An exception has been triggered by a grab thread. The grab will be stopped after this event call. + + \param[in] camera The source of the call. + \param[in] errorMessage The message of the exception that signaled an error during grabbing. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabError( CInstantCamera& camera, const char* errorMessage ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( errorMessage ); + } + + /** + \brief This method is called when a camera device removal from the PC has been detected. + + The %Pylon Device attached to the Instant Camera is not operable after this event. + After it is made sure that no access to the %Pylon Device or any of its node maps is made anymore + the %Pylon Device should be destroyed using InstantCamera::DeviceDestroy(). + The access to the %Pylon Device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object from an additional thread. + */ + virtual void OnCameraDeviceRemoved( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + + /** + \brief This method is called when the configuration event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationRegistered( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when the configuration event handler has been deregistered. + + The configuration event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationDeregistered( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /*! + \brief Destroys the configuration event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyConfiguration() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CConfigurationEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CConfigurationEventHandler( const CConfigurationEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CConfigurationEventHandler& operator=( const CConfigurationEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CConfigurationEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_CONFIGURATIONEVENTHANDLER_H_01627755 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ConfigurationHelper.h b/Cigarette/Pylon6.2/include/pylon/ConfigurationHelper.h new file mode 100644 index 0000000..3672a79 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ConfigurationHelper.h @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Arne Wischmann +//----------------------------------------------------------------------------- +/*! +\file +\brief Helper functions for different camera configuration classes. + + These helper functions are provided as a header-only file. + The code can be copied and modified for creating your own configuration classes. +*/ + +#ifndef INCLUDED_CONFIGURATIONHELPER_H_6526739 +#define INCLUDED_CONFIGURATIONHELPER_H_6526739 + + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ +#include + +namespace Pylon +{ + + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CConfigurationHelper + \brief Helper functions for different camera configuration classes. + */ + class CConfigurationHelper + { + public: + + /*! + \brief DisableAllTriggers disables all trigger types that can be + turned off. + */ + static void DisableAllTriggers( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + + //Disable all trigger types. + { + // Get required enumerations. + CEnumParameter triggerSelector( nodemap, "TriggerSelector" ); + CEnumParameter triggerMode( nodemap, "TriggerMode" ); + + if (triggerSelector.IsWritable()) + { + // Get all settable enumeration entries of trigger selector. + GENAPI_NAMESPACE::StringList_t triggerSelectorEntries; + triggerSelector.GetSettableValues( triggerSelectorEntries ); + + const String_t originalSelectorValue = triggerSelector.GetValue(); + + // Turn trigger mode off for all trigger selector entries. + for (GENAPI_NAMESPACE::StringList_t::const_iterator it = triggerSelectorEntries.begin(); it != triggerSelectorEntries.end(); ++it) + { + // Set trigger mode to off if the trigger is available. + triggerSelector.SetValue( *it ); + triggerMode.TrySetValue( "Off" ); + } + + // reset to original value + triggerSelector.SetValue( originalSelectorValue ); + } + } + } + + /*! + \brief DisableCompression disables all compressions modes that can be + turned off. + */ + static void DisableCompression( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + //Disable compression mode (if supported by the camera). + CEnumParameter compressionMode( nodemap, "ImageCompressionMode" ); + + compressionMode.TrySetValue( "Off" ); + } + + /*! + \brief DisableGenDC disables GenDC streaming when available. + */ + static void DisableGenDC( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + CEnumParameter genDCMode( nodemap, "GenDCStreamingMode" ); + + genDCMode.TrySetValue( "Off" ); + } + + /*! + \brief Select the 'Range' component. + + Some cameras, such as Basler blaze, provide multiple components. + Default is component 'Range' with pixel format 'Mono16' respective 'Mono8'. + */ + static void SelectRangeComponent( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + CEnumParameter componentSelector = CEnumParameter( nodemap, "ComponentSelector" ); + CBooleanParameter enableComponent = CBooleanParameter( nodemap, "ComponentEnable" ); + CEnumParameter pixelFormat = CEnumParameter( nodemap, "PixelFormat" ); + + // if multiple components are supported then enable only the 'range' component. + if (componentSelector.IsWritable()) + { + const String_t originalComponentValue = componentSelector.GetValue(); + + GENAPI_NAMESPACE::StringList_t componentSelectorEntries; + componentSelector.GetSettableValues( componentSelectorEntries ); + + for (GENAPI_NAMESPACE::StringList_t::iterator it = componentSelectorEntries.begin(), end = componentSelectorEntries.end(); it != end; ++it) + { + const String_t& entry = *it; + componentSelector.SetValue( entry ); + + // if Range is selected enable it set pixel format to Mono16 of Mono8 + if (entry.compare( "Range" ) == 0) + { + enableComponent.TrySetValue( true ); + if (!pixelFormat.TrySetValue( "Mono16" )) + { + pixelFormat.TrySetValue( "Mono8" ); + } + } + else + { // disable other components + enableComponent.TrySetValue( false ); + } + } + + // reset the component selector + componentSelector.TrySetValue( originalComponentValue ); + + } + } + + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_CONFIGURATIONHELPER_H_6526739 */ diff --git a/Cigarette/Pylon6.2/include/pylon/Container.h b/Cigarette/Pylon6.2/include/pylon/Container.h new file mode 100644 index 0000000..1e557e1 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Container.h @@ -0,0 +1,303 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the DeviceInfoList_t, TLInfoList_t, and InterfaceInfoList_t classes +*/ + +#ifndef __CONTAINER_H__ +#define __CONTAINER_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include + + +namespace Pylon +{ + // --------------------------------------------------------------------------- + /// + /// \brief STL std::vector like container class. + /*! + // Based on the GenICam::gcstring_vector class. + */ + // --------------------------------------------------------------------------- + template + class PYLONBASE_API TList + { + public: + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + + // Nested types + // --------------------------------------------------------------------------- + public: + + // \brief Const iterator for the DeviceInfoList container. + class PYLONBASE_API const_iterator + { + // iterator traits + // ------------------------------------------------------------------------ + public: + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + const_iterator( T* pPtr = 0 ); + + // Operators + // ------------------------------------------------------------------------- + public: + const T& operator * ( void ) const; + const T* operator -> () const; + const_iterator& operator ++ ( void ); + const_iterator operator ++ ( int ); + const_iterator& operator -- ( void ); + const_iterator operator -- ( int ); + const_iterator& operator += ( const intptr_t& iInc ); + const_iterator operator + ( intptr_t iInc ) const; + const_iterator& operator -= ( const intptr_t& iDec ); + intptr_t operator - ( const const_iterator& iter ) const; + const_iterator operator - ( intptr_t iDec ) const; + const T& operator [] ( intptr_t iIndex ) const; + bool operator == ( const const_iterator& iter ) const; + bool operator != ( const const_iterator& iter ) const; + bool operator < ( const const_iterator& iter ) const; + bool operator > ( const const_iterator& iter ) const; + bool operator <= ( const const_iterator& iter ) const; + bool operator >= ( const const_iterator& iter ) const; + template PYLONBASE_API friend typename TList::const_iterator operator +( intptr_t iInc, const typename TList::const_iterator& iter ); + + // Member + // ------------------------------------------------------------------------- + protected: + T* _ps; + }; + + class PYLONBASE_API iterator : + public const_iterator + { + public: + // iterator traits + // ------------------------------------------------------------------------- + typedef std::random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; + // Ctor / Dtor + // ------------------------------------------------------------------------- + public: + iterator( T* pPtr = 0 ); + + // Operators + // ------------------------------------------------------------------------- + public: + T& operator * ( void ) const; + T* operator -> () const; + iterator& operator ++ ( void ); + iterator operator ++ ( int ); + iterator& operator -- ( void ); + iterator operator -- ( int ); + iterator& operator += ( const intptr_t& iInc ); + iterator operator + ( intptr_t iInc ) const; + iterator& operator -= ( const intptr_t& iDec ); + intptr_t operator - ( const iterator& iter ) const; + iterator operator - ( intptr_t iDec ) const; + T& operator [] ( intptr_t iIndex ) const; + template PYLONBASE_API friend typename TList::iterator operator +( intptr_t iInc, const typename TList::iterator& iter ); + }; + + // Ctor / Dtor + // --------------------------------------------------------------------------- + public: + TList( void ); + explicit TList( size_t uiSize ); + TList( const TList& obj ); + virtual ~TList( void ); + + // Element access + // --------------------------------------------------------------------------- + public: + virtual void assign( size_t n, const T& val ); + virtual void clear( void ); + virtual iterator erase( iterator pos ); + virtual T& at( size_t uiIndex ); + virtual const T& at( size_t uiIndex ) const; + virtual T& back( void ); + virtual const T& back( void ) const; + virtual iterator begin( void ); + virtual const_iterator begin( void ) const; + virtual size_t capacity( void ) const; + virtual iterator end( void ); + virtual const_iterator end( void ) const; + virtual T& front( void ); + virtual const T& front( void ) const; + virtual size_t max_size( void ) const; + virtual size_t size( void ) const; + virtual iterator insert( iterator pos, const T& val ); + virtual bool empty( void ) const; + virtual void pop_back( void ); + virtual void push_back( const T& val ); + virtual void resize( size_t uiSize ); + virtual void reserve( size_t uiSize ); + + // Do not use - only left in for backwards compatibility! + virtual void erase( size_t uiIndex ); + virtual void insert( size_t uiIndex, const T& val ); + +// Operators + // --------------------------------------------------------------------------- + public: + TList& operator = ( const TList& obj ); + T& operator [] ( size_t uiIndex ); + const T& operator [] ( size_t uiIndex ) const; + void operator delete (void* pWhere); + void* operator new (size_t uiSize); + + // Member + // --------------------------------------------------------------------------- + private: + typedef std::vector > vector_t; + vector_t* _pv; + }; + + + // --------------------------------------------------------------------------- + /// \brief Gets the sum of the given \a iInc and the given \a iter. + /// + /// \param[in] iInc Increment from which the sum is calculated. + /// \param[in] iter Iterator from which the sum is calculated. + /// \return Sum of iterator. + // --------------------------------------------------------------------------- + template + typename TList::iterator PYLONBASE_API operator +( intptr_t iInc, const typename TList::iterator& iter ); + + +#ifndef PYLONBASE_EXPORT_TEMPLATE +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4231 4910) // Nonstandard extension used : 'extern' before template explicit instantiation +#endif + extern template class PYLONBASE_API TList; +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif + + ///////////////////////////////////////////////////////////////////////////////////////// + // + // DeviceInfoList + // + ///////////////////////////////////////////////////////////////////////////////////////// + + /// + /// \brief STL std::vector like container for Pylon::CDeviceInfo objects. + /*! + // \ingroup Pylon_TransportLayer + */ + // --------------------------------------------------------------------------- + class PYLONBASE_API DeviceInfoList : public TList + { + public: + DeviceInfoList( void ); + explicit DeviceInfoList( size_t uiSize ); + DeviceInfoList( const DeviceInfoList& obj ); + + virtual ~DeviceInfoList( void ); + + }; + + /// \copybrief Pylon::DeviceInfoList + /*! \copydoc Pylon::DeviceInfoList */ + typedef DeviceInfoList DeviceInfoList_t; + + ///////////////////////////////////////////////////////////////////////////////////////// + // + // TlInfoList + // + ///////////////////////////////////////////////////////////////////////////////////////// + + // --------------------------------------------------------------------------- + /*! + // \brief STL std::vector like container for Pylon::CTlInfo objects. + // + // \ingroup Pylon_TransportLayer + */ + // --------------------------------------------------------------------------- + class PYLONBASE_API TlInfoList : public TList + { + public: + TlInfoList( void ); + explicit TlInfoList( size_t uiSize ); + TlInfoList( const TlInfoList& obj ); + + virtual ~TlInfoList( void ); + + }; + + /*! + \copybrief Pylon::TlInfoList + \copydoc Pylon::TlInfoList + */ + typedef TlInfoList TlInfoList_t; + + + ///////////////////////////////////////////////////////////////////////////////////////// + // + // InterfaceInfoList + // + ///////////////////////////////////////////////////////////////////////////////////////// + + // --------------------------------------------------------------------------- + /*! + // \brief STL std::vector like container for Pylon::CInterfaceInfo objects. + // + */ + // --------------------------------------------------------------------------- + class PYLONBASE_API InterfaceInfoList : public TList + { + public: + InterfaceInfoList( void ); + explicit InterfaceInfoList( size_t uiSize ); + InterfaceInfoList( const InterfaceInfoList& obj ); + + virtual ~InterfaceInfoList( void ); + + }; + + /*! + \copybrief Pylon::InterfaceInfoList + \copydoc Pylon::InterfaceInfoList + */ + typedef InterfaceInfoList InterfaceInfoList_t; + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__CONTAINER_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/Device.h b/Cigarette/Pylon6.2/include/pylon/Device.h new file mode 100644 index 0000000..6aa8887 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Device.h @@ -0,0 +1,271 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Definition of IPylonDevice +*/ + +#ifndef __DEVICE_H__ +#define __DEVICE_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include +#include // for backward compatibility reasons +#include +#include +#include +#include + +namespace Pylon +{ + + interface IStreamGrabber; + interface IEventGrabber; + interface IChunkParser; + interface ISelfReliantChunkParser; + interface IPylonDevice; + + /// callback type with a IPylonDevice as parameter + typedef Pylon::Callback1 DeviceCallback; + /// opaque device callback object + typedef void* DeviceCallbackHandle; + + class CDeviceInfo; + // ------------------------------------------------------------------------- + // interface IDevice + // ------------------------------------------------------------------------- + /*! \interface IDevice + \brief Low Level API: The interface implemented by all device objects + \ingroup Pylon_LowLevelApi + */ + interface PUBLIC_INTERFACE IDevice + { + + /// Opens a device + /** + The open method initializes all involved drivers and establishes a connection + to the device. + + A device may support different access modes, e.g. EDeviceAccessMode::Exclusive providing + an exclusive access to the device. + + \param mode The desired device access mode + */ + virtual void Open( AccessModeSet mode = (Stream | Control | Event) ) = 0; + + /// Closes a device + /** + The close method closes all involved drivers and an existing connection to + the device will be released. Other applications now can access the device. + */ + virtual void Close() = 0; + + /// Checks if a device already is opened + /** + \return true, when the device already has been opened by the calling application. + + \note When a device has been opened an application A, IsOpen() will return false + when called by an application B not having called the device's open method. + */ + virtual bool IsOpen() const = 0; + + /// Returns the access mode used to open the device + virtual AccessModeSet AccessMode( void ) const = 0; + + /** \brief Returns the device info object storing information like + the device's name. + + \return A reference to the device info object used to create the device by a device factory + */ + virtual const CDeviceInfo& GetDeviceInfo() const = 0; + }; + + // --------------------------------------------------------------------- + // interface IPylonDevice + // --------------------------------------------------------------------- + /** \interface IPylonDevice + \brief Low Level API: Interface for camera objects + \ingroup Pylon_LowLevelApi + */ + interface PUBLIC_INTERFACE IPylonDevice : public IDevice + { + public: + + /// Returns the number of stream grabbers the camera object provides + virtual uint32_t GetNumStreamGrabberChannels() const = 0; + + /// Returns a pointer to a stream grabber + /** + Stream grabbers (IStreamGrabber) are the objects used to grab images + from a camera device. A camera device might be able to send image data + over more than one logical channel called stream. A stream grabber grabs + data from one single stream. + + \param index The number of the grabber to return + \return A pointer to a stream grabber, NULL if index is out of range + */ + virtual IStreamGrabber* GetStreamGrabber( uint32_t index ) = 0; + + /// Returns a pointer to an event grabber + /** + Event grabbers are used to handle events sent from a camera device. + */ + virtual IEventGrabber* GetEventGrabber() = 0; + + /// Returns the set of camera parameters. + /** + \return Pointer to the GenApi node map holding the parameters + */ + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() = 0; + + /// Returns the set of camera related transport layer parameters. + /** + \return Pointer to the GenApi node holding the transport layer parameter. If + there are no transport layer parameters for the device, NULL is returned. + */ + virtual GENAPI_NAMESPACE::INodeMap* GetTLNodeMap() = 0; + + /** \brief Creates a chunk parser used to update those camera object members + reflecting the content of additional data chunks appended to the image data. + + \return Pointer to the created chunk parser + + \note Don't try to delete a chunk parser pointer by calling free or delete. Instead, + use the DestroyChunkParser() method + */ + virtual Pylon::IChunkParser* CreateChunkParser() = 0; + + /// Deletes a chunk parser + /** + \param pChunkParser Pointer to the chunk parser to be deleted + */ + virtual void DestroyChunkParser( Pylon::IChunkParser* pChunkParser ) = 0; + + /*! + Creates an Event adapter + */ + virtual IEventAdapter* CreateEventAdapter() = 0; + + /*! + Deletes an Event adapter + */ + virtual void DestroyEventAdapter( IEventAdapter* ) = 0; + + /*! + Creates a a self-reliant chunk parser, returns NULL if not supported + */ + virtual ISelfReliantChunkParser* CreateSelfReliantChunkParser() = 0; + + /*! + Deletes a self-reliant chunk parser + */ + virtual void DestroySelfReliantChunkParser( ISelfReliantChunkParser* ) = 0; + + /// Registers a surprise removal callback object + /** + \param d reference to a device callback object + \return A handle which must be used to deregister a callback + It is recommended to use one of the RegisterRemovalCallback() helper functions + to register a callback. + + Example how to register a C function + \code + void MyRemovalCallback( Pylon::IPylonDevice* pDevice) + { + // handle removal + } + + DeviceCallbackHandle h = + Pylon::RegisterRemovalCallback( m_pCamera, &MyRemovalCallback); + \endcode + + Example how to register a class member function + \code + class C + { + void MyRemovalCallback( Pylon::IPylonDevice* pDevice ) + { + // handle removal + } + } c; + + DeviceCallbackHandle h = + Pylon::RegisterRemovalCallback( m_pCamera, c, &C::MyRemovalCallback); + \endcode + */ + virtual DeviceCallbackHandle RegisterRemovalCallback( DeviceCallback& d ) = 0; + + /// Deregisters a surprise removal callback object + /*! + \param h Handle of the callback to be removed + */ + virtual bool DeregisterRemovalCallback( DeviceCallbackHandle h ) = 0; + + }; + + +#ifdef _MSC_VER +#pragma warning ( push ) +#pragma warning( disable : 4239 ) // nonstandard extension used +#endif + /** + \brief Low Level API: Register a C-function as a removal callback + \ingroup Pylon_LowLevelApi + \see Pylon::IPylonDevice::RegisterRemovalCallback() + \param pDevice Pointer to the device that generates callbacks + \param f The function to be called + */ + template + DeviceCallbackHandle RegisterRemovalCallback( IPylonDevice* pDevice, Function f ) + { + if (NULL == pDevice) + throw RUNTIME_EXCEPTION( "Failed to register removal callback, invalid device object." ); + DeviceCallback cb( make_FunctionCallback, IPylonDevice* >( f ) ); + return pDevice->RegisterRemovalCallback( cb ); + } + + /** + \brief Low Level API: Register a C++-member function as removal callback + \ingroup Pylon_LowLevelApi + \see Pylon::IPylonDevice::RegisterRemovalCallback() + \param pDevice Pointer to the device that generates callbacks + \param c The client object + \param m The member function to be called + */ + template + DeviceCallbackHandle RegisterRemovalCallback( IPylonDevice* pDevice, Client& c, Member m ) + { + if (NULL == pDevice) + throw RUNTIME_EXCEPTION( "Failed to register removal callback, invalid device object." ); + DeviceCallback x( make_MemberFunctionCallback( c, m ) ); + return pDevice->RegisterRemovalCallback( x ); + } +#ifdef _MSC_VER +#pragma warning ( pop ) +#endif + + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__DEVICE_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/DeviceAccessMode.h b/Cigarette/Pylon6.2/include/pylon/DeviceAccessMode.h new file mode 100644 index 0000000..06d87d3 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/DeviceAccessMode.h @@ -0,0 +1,212 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of Device Access Mode +*/ + +#ifndef INCLUDED_DEVICEACCESSMODE_H_6600916 +#define INCLUDED_DEVICEACCESSMODE_H_6600916 + +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + // -------------------------------------------------------------------------- + // enum EDeviceAccessMode + // -------------------------------------------------------------------------- + /// The available access modes when opening a camera object + /*! + \ingroup Pylon_TransportLayer + */ + enum EDeviceAccessMode + { + Control = 0x1, //!< access the control and status registers + Stream = 0x3, //!< access a streaming data channel + Event = 0x4, //!< access the event data channel + Exclusive = 0x5, //!< exclusive access to the device + _NumModes + }; + + // -------------------------------------------------------------------------- + // class AccessModeSet + // -------------------------------------------------------------------------- + /// Collection of access mode bits + /*! + Used for defining how a device is accessed. + + \par Low Level API: + This set is used when a device is opened. The combination of + different access modes specifies how the device is opened. + Not all combinations may be allowed because the + device implementations have certain restrictions. + + \code + AccessModeSet a = Exclusive | Stream; + if (a.test( Exclusive )) + { + // Exclusive implies Control access, so set it also + a |= Control; + } + \endcode + \sa The method of IDevice::Open() uses it to define a default value. + \sa The global operator |( EDeviceAccessMode lhs, EDeviceAccessMode rhs ) allows to combine + two modes to a set. + \ingroup Pylon_TransportLayer + */ + class PYLONBASE_API AccessModeSet + { + public: + /// Default constructor creates an empty set. + AccessModeSet( void ); + /// Converts an access mode into a set. + AccessModeSet( EDeviceAccessMode am ); + /// Copy constructor + AccessModeSet( const AccessModeSet& ams ); + /// + explicit AccessModeSet( unsigned long l ); + // Destructor + ~AccessModeSet(); + + /*! + \brief Sets the bit at position pos. + \param pos Order position of the bit whose value is modified. Order positions are counted from the rightmost bit, which is order position 0. + \ingroup Pylon_TransportLayer + \return *this + */ + AccessModeSet& set( size_t pos ); + + + /*! + \brief Resets all bits to zero + \return *this + \ingroup Pylon_TransportLayer + */ + AccessModeSet& reset(); + + /*! + \brief Returns whether any of the bits is set (i.e., whether at least one bit in the AccessModeSet is set to one). + \returns true if any of the bits in the AccessModeSet is set (to one), and false otherwise. + \ingroup Pylon_TransportLayer + */ + bool any() const; + + /*! + \brief Returns whether any of the bits is set (i.e., whether at least one bit in the AccessModeSet is set to one). + \returns true if any of the bits in the AccessModeSet is set (to one), and false otherwise. + \ingroup Pylon_TransportLayer + */ + bool none() const; + + /*! + \brief Returns whether the bit at position pos is set (i.e., whether it is one). + \param pos Order position of the bit whose value is modified. Order positions are counted from the rightmost bit, which is order position 0. + \returns true if the bit at position pos is set, and false if it is not set. + \ingroup Pylon_TransportLayer + */ + bool test( size_t pos ) const; + + /*! + \brief Returns an unsigned long with the integer value that has the same bits set as the AccessModeSet. + \returns Integer value with the same bit representation as the AccessModeSet object. + \ingroup Pylon_TransportLayer + */ + unsigned long to_ulong() const; + + private: + unsigned long mBits; + + + }; + + // ------------------------------------------------------------------------- + // Access mode operators + // ------------------------------------------------------------------------- + + /*! + \brief Creates a set containing lhs and rhs operands + \param lhs left operand + \param rhs right operand + \return returns an AccessModeSet containing both operands + \ingroup Pylon_TransportLayer + */ + AccessModeSet PYLONBASE_API operator+( EDeviceAccessMode lhs, EDeviceAccessMode rhs ); + + /*! + \brief Creates a set containing lhs and rhs operands. + \param lhs left operand + \param rhs right operand + \ingroup Pylon_TransportLayer + */ + AccessModeSet PYLONBASE_API operator|( EDeviceAccessMode lhs, EDeviceAccessMode rhs ); + + /*! + \brief Adds the operand rhs to the set lhs + \param lhs a set of bits. + \param rhs the additional bit + \ingroup Pylon_TransportLayer + */ + AccessModeSet PYLONBASE_API operator+( const AccessModeSet& lhs, EDeviceAccessMode rhs ); + + /*! + \brief Adds the operand rhs to the set lhs + \param lhs a set of bits. + \param rhs the additional bit + \ingroup Pylon_TransportLayer + */ + AccessModeSet PYLONBASE_API operator|( const AccessModeSet& lhs, EDeviceAccessMode rhs ); + + + + /*! + \brief Check if the operand rhs is equal to lhs + \param lhs a set of bits. + \param rhs the additional set of bits. + \ingroup Pylon_TransportLayer + */ + bool PYLONBASE_API operator==( const AccessModeSet& lhs, const AccessModeSet& rhs ); + + /*! + \brief Check if the operand rhs is not equal to lhs + \param lhs a set of bits. + \param rhs the additional set of bits. + \ingroup Pylon_TransportLayer + */ + bool PYLONBASE_API operator!=( const AccessModeSet& lhs, const AccessModeSet& rhs ); + + + // ------------------------------------------------------------------------- + // STL output operators + // ------------------------------------------------------------------------- + + //! STL operator out + //! \ingroup Pylon_TransportLayer + inline std::ostream& operator <<( std::ostream& ostr, const Pylon::AccessModeSet& ams ) + { + // use formatted output operator of std::string + ostr << "0x" + << std::setfill( '0' ) << std::setw( sizeof( unsigned long ) * 2 ) + << std::hex << ams.to_ulong(); + + return ostr; + } + + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ +} + +#endif /* INCLUDED_DEVICEACCESSMODE_H_6600916 */ diff --git a/Cigarette/Pylon6.2/include/pylon/DeviceClass.h b/Cigarette/Pylon6.2/include/pylon/DeviceClass.h new file mode 100644 index 0000000..887e37f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/DeviceClass.h @@ -0,0 +1,44 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: Thomas Koeller +//----------------------------------------------------------------------------- +/*! +\file +\brief Device class definitions +*/ + +#ifndef __DEVICE_CLASS_H__ +#define __DEVICE_CLASS_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + + +namespace Pylon +{ + /** \addtogroup Pylon_TransportLayer + * @{ + */ + // PYLON_WIN_BUILD only controls whether the DeviceClass is listed in the API reference guide + const char* const Basler1394DeviceClass = "Basler1394"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerGigEDeviceClass = "BaslerGigE"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerCamEmuDeviceClass = "BaslerCamEmu"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerIpCamDeviceClass = "BaslerIPCam"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerCameraLinkDeviceClass = "BaslerCameraLink"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerGenTlDeviceClassPrefix = "BaslerGTC"; ///< The actual device class string is made up of this prefix + '/' + [TL Vendor] + '/' + [TL Model]. + const char* const BaslerGenTlGevDeviceClass = "BaslerGTC/Basler/GEV"; + const char* const BaslerGenTlU3vDeviceClass = "BaslerGTC/Basler/U3V"; + const char* const BaslerGenTlCxpDeviceClass = "BaslerGTC/Basler/CXP"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerGenTlBlazeDeviceClass = "BaslerGTC/Basler/GenTL_Producer_for_Basler_blaze_101_cameras"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerUsbDeviceClass = "BaslerUsb"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + const char* const BaslerBconDeviceClass = "BaslerBcon"; ///< This device class can be used to create the corresponding Transport Layer object or when creating Devices with the Transport Layer Factory. + /** + * @} + */ +} +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/DeviceFactory.h b/Cigarette/Pylon6.2/include/pylon/DeviceFactory.h new file mode 100644 index 0000000..e1adac8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/DeviceFactory.h @@ -0,0 +1,169 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the IDeviceFactory interface +*/ + +#ifndef __DEVICEFACTORY_H__ +#define __DEVICEFACTORY_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include + +namespace Pylon +{ + interface IPylonDevice; + + + // -------------------------------------------------------------------------- + // enum EDeviceAccessiblityInfo + // -------------------------------------------------------------------------- + /// Information about the accessibility of a device + /*! + \ingroup Pylon_TransportLayer + */ + enum EDeviceAccessiblityInfo + { + Accessibility_Unknown = 0, //!< The accessibility could not be determined. The state of accessibility is unknown. + Accessibility_Ok = 1, //!< The device could be opened. + Accessibility_Opened = 2, //!< The device is reachable, but can be opened in read only mode only. + Accessibility_OpenedExclusively = 3, //!< The device is reachable, but currently opened exclusively by another application. + Accessibility_NotReachable = 4, //!< The device could not be reached or does not exist. No connection to the device is possible. + }; + + + /*! + \interface IDeviceFactory + \brief Interface to be implemented by device factories used to create devices. + + Each transport layer object is a device factory. These device factories must implement + the IDeviceFactory interface. + + \ingroup Pylon_TransportLayer + */ + + interface PUBLIC_INTERFACE IDeviceFactory + { + /// Retrieves a list of available devices. + /** + The list contains Pylon::CDeviceInfo objects used for the device creation and is ordered by device class and serial number using the operator Pylon::CDeviceInfo::operator<(). + By default, the list will be cleared before the device discovery is started. + + \param list List to be filled with device info objects. + \param addToList If true, the devices found will be appended to the list instead of deleting the list. Only newly discovered devices are sorted and not the entire list. + \return Number of devices found. + */ + virtual int EnumerateDevices( DeviceInfoList_t& list, bool addToList = false ) = 0; + + /// Retrieves a list of available devices filtered by given properties, usable for looking for specific devices. + /** + The list contains Pylon::CDeviceInfo objects used for the device creation and is ordered by device class and serial number using the operator Pylon::CDeviceInfo::operator<(). + By default, the list will be cleared before the device discovery is started. + The filter list can contain a list of device info objects containing properties a device must have, e.g., + the user-provided name or the serial number. A device is returned if it matches the properties of any of the + device info objects on the filter list. + If the device class property is set in the filter device info objects, the search is + limited to the required transport layers. + + \param list List to be filled with device info objects. + \param filter A list of device info objects with user-provided properties that a device can match. + \param addToList If true, the devices found will be appended to the list instead of deleting the list. Only newly discovered devices are sorted and not the entire list. + \return Number of devices found. + */ + virtual int EnumerateDevices( DeviceInfoList_t& list, const DeviceInfoList_t& filter, bool addToList = false ) = 0; + + /// Creates a camera object from a device info object. + /** + This method accepts either a device info object from a device enumeration or a user-provided device info object. + User-provided device info objects can be preset with properties required for a device, e.g. + the user-provided name or the serial number. The implementation tries to find a matching camera by using device + enumeration. + When the device class property is set, the search is limited to the required transport layer. + + If the device creation fails, a GenApi::GenericException will be thrown. + \param di Device info object containing all information needed to identify exactly one device. + */ + virtual IPylonDevice* CreateDevice( const CDeviceInfo& di ) = 0; + + /// If multiple devices match the provided properties, the first device found is created. + /// The order in which the devices are found can vary from call to call. + virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di = CDeviceInfo() ) = 0; + + /// Creates a camera object from a device info object, injecting additional GenICam XML definition strings. + /// Currently only one injected xml string is supported. + virtual IPylonDevice* CreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ) = 0; + + /// Creates the first found camera device matching the provided properties, injecting additional GenICam XML definition strings. + /// Currently only one injected xml string is supported. + virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ) = 0; + + /// This method is deprecated. Use CreateDevice and pass a CDeviceInfo object containing the full name as a property. + /// Example: IPylonDevice* device = TlFactory.CreateDevice( CDeviceInfo().SetFullName( fullname)); + /// creates a device that matches its full name (i.e., as returned by CDeviceInfo::GetFullName). + virtual IPylonDevice* CreateDevice( const String_t& ) = 0; + + /// Destroys a device. + /** \note Never try to delete a pointer to a camera device by calling free or delete. + Always use the DestroyDevice method. + */ + virtual void DestroyDevice( IPylonDevice* ) = 0; + + /*! + \brief This method can be used to check if a camera device can be created and opened. + + This method accepts either a device info object from a device enumeration or a user-provided device info object. + User-provided device info objects can be preset with properties required for a device, e.g. + the user-provided name or the serial number. The implementation tries to find a matching camera by using device + enumeration. When the device class property is set, see \ref DeviceClass.h header file, the search is limited to the required transport layer. + For more information, see \ref UsingEnumeraionWithFilter "Applying a Filter when Enumerating Cameras". + + + \param[in] deviceInfo Properties to find/identify the camera device to check. + \param[in] mode Used for defining how a device is accessed. + The use of the mode information is transport layer-specific. + - For \ref Pylon::BaslerBconDeviceClass "BCON", \ref Pylon::BaslerCameraLinkDeviceClass "CameraLink", + and \ref Pylon::BaslerUsbDeviceClass "USB" devices, the mode information is ignored. + - For \ref Pylon::BaslerGigEDeviceClass "GigE" devices, the \c Exclusive and \c Control flags are used for defining how a device is accessed. Other mode information is ignored. + - For devices of any type that are accessed via the \ref Pylon::BaslerGenTlDeviceClassPrefix "GenICam GenTL" transport layer, the mode is ignored. + \param[out] pAccessibilityInfo Optional parameter that provides more information about whether a device is accessible or not. + \return True if device can be opened with provided access mode. + + \pre The \c deviceInfo object properties specify exactly one device. + This is the case when the device info object has been obtained using device enumeration. + + \error + Throws a C++ exception, if the preconditions are not met. + */ + virtual bool IsDeviceAccessible( const CDeviceInfo& deviceInfo, AccessModeSet mode = Control, EDeviceAccessiblityInfo* pAccessibilityInfo = NULL ) = 0; + }; + + + + + + + +} // namespace PYLON + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/DeviceInfo.h b/Cigarette/Pylon6.2/include/pylon/DeviceInfo.h new file mode 100644 index 0000000..cf85fea --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/DeviceInfo.h @@ -0,0 +1,577 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung, AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of CDeviceInfo class +*/ + +#ifndef __DEVICEINFO_H__ +#define __DEVICEINFO_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + + ///This namespace contains keys for accessing the properties of pylon info objects + namespace Key + { + //General + ///Identifies the serial number if it supported by the underlying implementation + const char* const SerialNumberKey = "SerialNumber"; + ///Identifies the user-defined name if present. + const char* const UserDefinedNameKey = "UserDefinedName"; + ///Identifies the model name of the device. + const char* const ModelNameKey = "ModelName"; + ///Identifies the version string of the device. + const char* const DeviceVersionKey = "DeviceVersion"; + ///Identifies the identifier for the transport layer able to create this device. + const char* const DeviceFactoryKey = "DeviceFactory"; + ///Identifies the source of the XML used to create the node map of this device. + const char* const XMLSourceKey = "XMLSource"; + ///Identifies the manufacturer info. + const char* const ManufacturerInfoKey = "ManufacturerInfo"; + ///Identifies the device ID (e.g., used by Camera Link and GenTL Consumer). + const char* const DeviceIDKey = "DeviceID"; + + //GigE + ///Identifies the IP address of the device IP address in a human-readable representation including the port number. + const char* const AddressKey = "Address"; + ///Identifies the IP address of the device IP address in a human-readable representation. + const char* const IpAddressKey = "IpAddress"; + ///Identifies the default gateway of the device IP address in a human-readable representation. + const char* const DefaultGatewayKey = "DefaultGateway"; + ///Identifies the subnet mask of the device IP address in a human-readable representation. + const char* const SubnetMaskKey = "SubnetMask"; + ///Identifies the subnet address of the device in a human-readable representation. + const char* const SubnetAddressKey = "SubnetAddress"; + ///Identifies the port number used. + const char* const PortNrKey = "PortNr"; + ///Identifies the MAC address of the device of the device IP address in a human-readable representation. + const char* const MacAddressKey = "MacAddress"; + ///Identifies the address of the network interface the device is connected. + const char* const InterfaceKey = "Interface"; + ///Identifies the persistent IP configuration options. + const char* const IpConfigOptionsKey = "IpConfigOptions"; + ///Identifies the current IP configuration of the device. + const char* const IpConfigCurrentKey = "IpConfigCurrent"; + + //USB + const char* const DeviceGUIDKey = "DeviceGUID"; + const char* const VendorIdKey = "VendorId"; + const char* const ProductIdKey = "ProductId"; + const char* const DriverKeyNameKey = "DriverKeyName"; + const char* const UsbDriverTypeKey = "UsbDriverTypeName"; + // Internal use only + const char* const UsbPortVersionBcdKey = "UsbPortVersionBcd"; + // Internal use only + const char* const SpeedSupportBitmaskKey = "SpeedSupportBitmask"; + // Internal use only + const char* const TransferModeKey = "TransferModeKey"; + + //1394 + ///Identifies the name of the device used by the underlying device driver. Internal use only. + const char* const InternalNameKey = "InternalName"; + + //BCON + ///Identifies the name of BCON adapter library including extension without path information. + const char* const BconAdapterLibraryNameKey = "BconAdapterLibraryName"; + ///Identifies the version of the externally provided BCON adapter library. The format is:v{major}.{minor} + const char* const BconAdapterLibraryVersionKey = "BconAdapterLibraryVersion"; + ///Identifies the version of the BCON Adapter API the BCON adapter library has been implemented for. The format is:v{major}.{minor} + const char* const BconAdapterLibraryApiVersionKey = "BconAdapterLibraryApiVersion"; + ///Identifies the version of the BCON Adapter API currently supported by pylon. The format is:v{major}.{minor} + const char* const SupportedBconAdapterApiVersionKey = "SupportedBconAdapterApiVersion"; + + + //CameraLink + ///Identifies the ID of the serial port the device is connected to. + const char* const PortIDKey = "PortID"; + ///Identifies the initial baud rate of the serial port the device is connected to. + const char* const InitialBaudRateKey = "InitialBaudRate"; + ///Identifies the device xml file override used. Internal use only. + const char* const DeviceXMLFileOverrideKey = "DeviceXMLFileOverride"; + ///Identifies the device specific string. Internal use only. + const char* const DeviceSpecificStringKey = "DeviceSpecificString"; + ///Identifies the port specific string of the device. Internal use only. + const char* const PortSpecificStringKey = "PortSpecificString"; + + + // Internal use only + const char* const DeviceIdxKey = "DeviceIdx"; + } + + /// Holds information about an enumerated device. + /*! + The device enumeration process creates a list of CDeviceInfo objects + (Pylon::DeviceInfoList_t). Each CDeviceInfo objects stores information + about a device. The information is retrieved during the device enumeration process (ITransportLayer::EnumerateDevices resp. + CTlFactory::EnumerateDevices) + + \ingroup Pylon_TransportLayer + */ + class PYLONBASE_API CDeviceInfo : public CInfoBase + { + public: + + CDeviceInfo(); + CDeviceInfo( const CDeviceInfo& ); + virtual ~CDeviceInfo() + { + } + + /*! + \brief Compares CDeviceInfo objects by device class and serial number. + \param[in] rhs The right-hand side object of the comparison. + \return Returns true according to this rule: USB < GigE < CameraLink < 1394 < Bcon < Less than compare of device class text < CamEmu. + CDeviceInfo objects of the same transport layer are compared by serial number. Numeric serial numbers are less than alphanumeric + serial numbers. Two alphanumeric serial numbers return the result of a less than text comparison. + \error + Does not throw C++ exceptions. + */ + bool operator<( const CDeviceInfo& rhs ) const; + + /* The underlying implementation does not need to support all the listed properties. + The properties that are not supported always have the value "N/A" which is the value of CInfoBase::PropertyNotAvailable */ + + ///Retrieves the serial number if it supported by the underlying implementation + ///This property is identified by Key::SerialNumberKey. + String_t GetSerialNumber() const; + ///Sets the above property. + CDeviceInfo& SetSerialNumber( const String_t& SerialNumberValue ); + ///Returns true if the above property is available. + bool IsSerialNumberAvailable() const; + + ///Retrieves the user-defined name if present. + ///This property is identified by Key::UserDefinedNameKey. + String_t GetUserDefinedName() const; + ///Sets the above property. + CDeviceInfo& SetUserDefinedName( const String_t& UserDefinedNameValue ); + ///Returns true if the above property is available. + bool IsUserDefinedNameAvailable() const; + + ///Retrieves the model name of the device. + ///This property is identified by Key::ModelNameKey. + String_t GetModelName() const; + ///Sets the above property. + CDeviceInfo& SetModelName( const String_t& ModelNameValue ); + ///Returns true if the above property is available. + bool IsModelNameAvailable() const; + + ///Retrieves the version string of the device. + ///This property is identified by Key::DeviceVersionKey. + String_t GetDeviceVersion() const; + ///Sets the above property. + CDeviceInfo& SetDeviceVersion( const String_t& DeviceVersionValue ); + ///Returns true if the above property is available. + bool IsDeviceVersionAvailable() const; + + ///Retrieves the identifier for the transport layer able to create this device. + ///This property is identified by Key::DeviceFactoryKey. + String_t GetDeviceFactory() const; + ///Sets the above property. + CDeviceInfo& SetDeviceFactory( const String_t& DeviceFactoryValue ); + ///Returns true if the above property is available. + bool IsDeviceFactoryAvailable() const; + + ///Retrieves the location where the XML file was loaded from. + ///This property is identified by Key::XMLSourceKey. + ///You must use the DeviceInfo of an opened IPylonDevice to retrieve this property. + String_t GetXMLSource() const; + ///Sets the above property. + CDeviceInfo& SetXMLSource( const String_t& XMLSource ); + ///Returns true if the above property is available. + bool IsXMLSourceAvailable() const; + + ///Sets the display friendly name of the device. + ///This property is identified by Key::FriendlyNameKey. + ///This method overrides a method of a base class returning a reference to CDeviceInfo + CDeviceInfo& SetFriendlyName( const String_t& FriendlyNameValue ); + + ///Sets the full name identifying the device. + ///This property is identified by Key::FullNameKey. + ///This method overrides a method of a base class returning a reference to CDeviceInfo + CDeviceInfo& SetFullName( const String_t& FullNameValue ); + + ///Sets the vendor name of the device. + ///This property is identified by Key::VendorNameKey. + ///This method overrides a method of a base class returning a reference to CDeviceInfo + CDeviceInfo& SetVendorName( const String_t& VendorNameValue ); + + ///Sets the device class device, e.g. Basler1394. + ///This property is identified by Key::DeviceClassKey. + ///This method overrides a method of a base class returning a reference to CDeviceInfo + CDeviceInfo& SetDeviceClass( const String_t& DeviceClassValue ); + + ///Retrieves the ID of the interface that the device is connected to. + ///This property is identified by Key::InterfaceIDKey. + String_t GetInterfaceID() const; + ///Sets the above property. + CDeviceInfo& SetInterfaceID( const String_t& InterfaceIDValue ); + ///Returns true if the above property is available. + bool IsInterfaceIDAvailable() const; + + + ///Retrieves the IP address the device IP address in a human-readable representation including the port number. + ///This property is identified by Key::AddressKey. + ///Applies to: GigE + String_t GetAddress() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetAddress( const String_t& AddressValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsAddressAvailable() const; + + ///Retrieves the IP address the device IP address in a human-readable representation. + ///This property is identified by Key::IpAddressKey. + ///Applies to: GigE + String_t GetIpAddress() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetIpAddress( const String_t& IpAddressValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsIpAddressAvailable() const; + + ///Retrieves the IP address of the subnet. + /// This property is identified by Key::SubnetAddressKey + ///Applies to: GigE + String_t GetSubnetAddress() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetSubnetAddress( const String_t& SubnetAddressValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsSubnetAddressAvailable() const; + + ///Retrieves the default gateway the device IP address in a human-readable representation. + ///This property is identified by Key::DefaultGatewayKey. + ///Applies to: GigE + String_t GetDefaultGateway() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetDefaultGateway( const String_t& DefaultGatewayValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsDefaultGatewayAvailable() const; + + ///Retrieves the subnet mask the device IP address in a human-readable representation. + ///This property is identified by Key::SubnetMaskKey. + ///Applies to: GigE + String_t GetSubnetMask() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetSubnetMask( const String_t& SubnetMaskValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsSubnetMaskAvailable() const; + + ///Retrieves the port number used. + ///This property is identified by Key::PortNrKey. + ///Applies to: GigE + String_t GetPortNr() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetPortNr( const String_t& PortNrValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsPortNrAvailable() const; + + ///Retrieves the MAC address of the device the device IP address in a human-readable representation. + ///This property is identified by Key::MacAddressKey. + ///Applies to: GigE + String_t GetMacAddress() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetMacAddress( const String_t& MacAddressValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsMacAddressAvailable() const; + + ///Retrieves the address of the network interface the device is connected. + ///This property is identified by Key::InterfaceKey. + ///Applies to: GigE + String_t GetInterface() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetInterface( const String_t& InterfaceValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsInterfaceAvailable() const; + + ///Retrieves the persistent IP configuration options. + ///This property is identified by Key::IpConfigOptionsKey. + ///Applies to: GigE + String_t GetIpConfigOptions() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetIpConfigOptions( const String_t& IpConfigOptionsValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsIpConfigOptionsAvailable() const; + + ///Retrieves the current IP configuration of the device. + ///This property is identified by Key::IpConfigCurrentKey. + ///Applies to: GigE + String_t GetIpConfigCurrent() const; + ///Sets the above property. + ///Applies to: GigE + CDeviceInfo& SetIpConfigCurrent( const String_t& IpConfigCurrentValue ); + ///Returns true if the above property is available. + ///Applies to: GigE + bool IsIpConfigCurrentAvailable() const; + + + ///Retrieves the device GUID. + ///This property is identified by Key::DeviceGUIDKey. + ///Applies to: Usb + String_t GetDeviceGUID() const; + ///Returns true if the above property is available. + ///Applies to: Usb + bool IsDeviceGUIDAvailable() const; + + ///Retrieves the manufacturer info. + ///This property is identified by Key::ManufacturerInfoKey. + ///Applies to: Usb and BCON + String_t GetManufacturerInfo() const; + ///Returns true if the above property is available. + ///Applies to: Usb and BCON + bool IsManufacturerInfoAvailable() const; + + ///Retrieves the device index. For internal use only. + ///This property is identified by Key::DeviceIdxKey. + ///Applies to: Usb and BCON + String_t GetDeviceIdx() const; + ///Returns true if the above property is available. + ///Applies to: Usb and BCON + bool IsDeviceIdxAvailable() const; + + ///Retrieves the product ID. For internal use only. + ///This property is identified by Key::ProductIdKey. + ///Applies to: Usb + String_t GetProductId() const; + ///Returns true if the above property is available. + ///Applies to: Usb + bool IsProductIdAvailable() const; + + ///Retrieves the vendor ID. For internal use only. + ///This property is identified by Key::VendorIdKey. + ///Applies to: Usb + String_t GetVendorId() const; + ///Returns true if the above property is available. + ///Applies to: Usb + bool IsVendorIdAvailable() const; + + ///Retrieves the driver key name. For internal use only. + ///This property is identified by Key::DriverKeyNameKey. + ///Applies to: Usb + String_t GetDriverKeyName() const; + ///Returns true if the above property is available. + ///Applies to: Usb + bool IsDriverKeyNameAvailable() const; + + ///Retrieves the usb driver type. For internal use only. + ///This property is identified by Key::UsbDriverTypeKey. + ///Applies to: Usb + String_t GetUsbDriverType() const; + ///Returns true if the above property is available. + ///Applies to: Usb + bool IsUsbDriverTypeAvailable() const; + + ///Retrieves the transfer mode. For internal use only. + ///This property is identified by Key::TransferModeKey + // Returns either dtx or btx (direct vs. buffered transfer) + ///Applies to: Usb + String_t GetTransferMode() const; + ///Returns true if the above property is available. + ///Applies to: Usb + bool IsTransferModeAvailable() const; + + + ///Retrieves the name of the device used by the underlying device driver. Internal use only. + ///This property is identified by Key::InternalNameKey. + ///Applies to: 1394 + String_t GetInternalName() const; + ///Sets the above property. + ///Applies to: 1394 + CDeviceInfo& SetInternalName( const String_t& InternalNameValue ); + ///Returns true if the above property is available. + ///Applies to: 1394 + bool IsInternalNameAvailable() const; + + + ///Retrieves the name of BCON adapter library including extension without path information. + ///This property is identified by Key::BconAdapterLibraryNameKey. + ///Applies to: BCON + String_t GetBconAdapterLibraryName() const; + ///Sets the above property. + ///Applies to: BCON + CDeviceInfo& SetBconAdapterLibraryName( const String_t& BconAdapterLibraryNameValue ); + ///Returns true if the above property is available. + ///Applies to: BCON + bool IsBconAdapterLibraryNameAvailable() const; + + ///Retrieves the version of the externally provided BCON adapter library. The format is:v{major}.{minor} + ///This property is identified by Key::BconAdapterLibraryVersionKey. + ///Applies to: BCON + String_t GetBconAdapterLibraryVersion() const; + ///Sets the above property. + ///Applies to: BCON + CDeviceInfo& SetBconAdapterLibraryVersion( const String_t& BconAdapterLibraryVersionValue ); + ///Returns true if the above property is available. + ///Applies to: BCON + bool IsBconAdapterLibraryVersionAvailable() const; + + ///Retrieves the version of the BCON Adapter API the BCON adapter library has been implemented for. The format is:v{major}.{minor} + ///This property is identified by Key::BconAdapterLibraryApiVersionKey. + ///Applies to: BCON + String_t GetBconAdapterLibraryApiVersion() const; + ///Sets the above property. + ///Applies to: BCON + CDeviceInfo& SetBconAdapterLibraryApiVersion( const String_t& BconAdapterLibraryApiVersionValue ); + ///Returns true if the above property is available. + ///Applies to: BCON + bool IsBconAdapterLibraryApiVersionAvailable() const; + + ///Retrieves the version of the BCON Adapter API currently supported by pylon. The format is:v{major}.{minor} + ///This property is identified by Key::SupportedBconAdapterApiVersionKey. + ///Applies to: BCON + String_t GetSupportedBconAdapterApiVersion() const; + ///Sets the above property. + ///Applies to: BCON + CDeviceInfo& SetSupportedBconAdapterApiVersion( const String_t& SupportedBconAdapterApiVersionValue ); + ///Returns true if the above property is available. + ///Applies to: BCON + bool IsSupportedBconAdapterApiVersionAvailable() const; + + + ///Retrieves the ID of the serial port the device is connected to. + ///This property is identified by Key::PortIDKey. + ///Applies to: CameraLink + String_t GetPortID() const; + ///Sets the above property. + ///Applies to: CameraLink + CDeviceInfo& SetPortID( const String_t& PortIDValue ); + ///Returns true if the above property is available. + ///Applies to: CameraLink + bool IsPortIDAvailable() const; + + ///Retrieves the device ID. + ///This property is identified by Key::DeviceIDKey. + ///Applies to: CameraLink + String_t GetDeviceID() const; + ///Sets the above property. + ///Applies to: CameraLink + CDeviceInfo& SetDeviceID( const String_t& DeviceIDValue ); + ///Returns true if the above property is available. + ///Applies to: CameraLink + bool IsDeviceIDAvailable() const; + + ///Retrieves the initial baud rate of the serial port the device is connected to. + ///This property is identified by Key::InitialBaudRateKey. + ///Applies to: CameraLink + String_t GetInitialBaudRate() const; + ///Sets the above property. + ///Applies to: CameraLink + CDeviceInfo& SetInitialBaudRate( const String_t& InitialBaudRateValue ); + ///Returns true if the above property is available. + ///Applies to: CameraLink + bool IsInitialBaudRateAvailable() const; + + ///Retrieves the device xml file override used. Internal use only. + ///This property is identified by Key::DeviceXMLFileOverrideKey. + ///Applies to: CameraLink + String_t GetDeviceXMLFileOverride() const; + ///Sets the above property. + ///Applies to: CameraLink + CDeviceInfo& SetDeviceXMLFileOverride( const String_t& DeviceXMLFileOverrideValue ); + ///Returns true if the above property is available. + ///Applies to: CameraLink + bool IsDeviceXMLFileOverrideAvailable() const; + + ///Retrieves the device specific string. Internal use only. + ///This property is identified by Key::DeviceSpecificStringKey. + ///Applies to: CameraLink + String_t GetDeviceSpecificString() const; + ///Sets the above property. + ///Applies to: CameraLink + CDeviceInfo& SetDeviceSpecificString( const String_t& DeviceSpecificStringValue ); + ///Returns true if the above property is available. + ///Applies to: CameraLink + bool IsDeviceSpecificStringAvailable() const; + + ///Retrieves the port specific string of the device. Internal use only. + ///This property is identified by Key::PortSpecificStringKey. + ///Applies to: CameraLink + String_t GetPortSpecificString() const; + ///Sets the above property. + ///Applies to: CameraLink + CDeviceInfo& SetPortSpecificString( const String_t& PortSpecificStringValue ); + ///Returns true if the above property is available. + ///Applies to: CameraLink + bool IsPortSpecificStringAvailable() const; + + /// Modifies a property value + ///This method overrides a method of a base class returning a reference to CDeviceInfo + virtual CDeviceInfo& SetPropertyValue( const String_t& Name, const String_t& Value ) + { + CInfoBase::SetPropertyValue( Name, Value ); + return *this; + } + + public: + //! \brief Returns true when the device is configured for a persistent IP address + bool IsPersistentIpActive( void ) const; + + //! \brief Returns true when the device is configured for using DHCP + bool IsDhcpActive( void ) const; + + //! \brief Returns true when the device is configured for using Auto IP (aka LLA) + bool IsAutoIpActive( void ) const; + + //! \brief Returns true when the device supports configuring a persistent IP address + bool IsPersistentIpSupported( void ) const; + + //! \brief Returns true when the device supports DHCP + bool IsDhcpSupported( void ) const; + + //! \brief Returns true when the device supports Auto IP (aka LLA) + bool IsAutoIpSupported( void ) const; + + //! \brief Returns true when subset, applies special knowledge on how to compare GigE specific values + virtual bool IsSubset( const IProperties& Subset ) const; + + protected: + CDeviceInfo& SetDeviceGUID( const String_t& ); + CDeviceInfo& SetManufacturerInfo( const String_t& ); + CDeviceInfo& SetDeviceIdx( const String_t& ); + CDeviceInfo& SetProductId( const String_t& ); + CDeviceInfo& SetVendorId( const String_t& ); + CDeviceInfo& SetDriverKeyName( const String_t& ); + CDeviceInfo& SetUsbDriverType( const String_t& ); + CDeviceInfo& SetTransferMode( const String_t& ); + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__DEVICEINFO_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/EnumParameter.h b/Cigarette/Pylon6.2/include/pylon/EnumParameter.h new file mode 100644 index 0000000..86b21b6 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/EnumParameter.h @@ -0,0 +1,535 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CEnumParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CENUMPARAMETER_H +#define INCLUDED_BASLER_PYLON_CENUMPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /*! + \brief Extends the GenApi::IEnumeration interface with convenience methods. + */ + interface IEnumerationEx : virtual public GENAPI_NAMESPACE::IEnumeration, virtual public IValueEx + { + using GENAPI_NAMESPACE::IEnumeration::operator=; + + /*! + \brief Gets the value of the parameter if the parameter is readable. Otherwise returns the default value. + \return Returns the parameter value if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading the value fails. + */ + virtual String_t GetValueOrDefault( const String_t& defaultValue ) = 0; + + + /*! + \brief Sets the value of the parameter if the parameter is writable and the value is contained in the set of settable enumeration values. + \return Returns false if the parameter is not writable or the value is not contained in the set of settable enumeration values. + \param[in] value The value to set. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error- + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual bool TrySetValue( const String_t& value ) = 0; + + + /*! + \brief Sets the value of the parameter to the first valid value in a list of values. + Example: + \code + CEnumParameter pixelFormat(nodemap, "PixelFormat"); + const char* list[] = { "BayerGR8", "BayerRG8", "BayerGB8", "BayerBG8", "Mono8", NULL }; + pixelFormat.SetValue(list); + \endcode + \param[in] nullTerminatedList The list of possible values to set. The list is terminated by a NULL value. + \pre +
    +
  • The parameter must be writable. +
  • At least one value within the list passed must be contained in the set of settable enumeration values. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, no value \c nullTerminatedList is settable, or writing the value fails. + */ + virtual void SetValue( const char** nullTerminatedList ) = 0; + + + /*! + \brief If the parameter is writable, sets the value of the parameter to the first valid value in a list of values. + Example: + \code + CEnumParameter pixelFormat(nodemap, "PixelFormat"); + const char* list[] = { "BayerGR8", "BayerRG8", "BayerGB8", "BayerBG8", "Mono8", NULL }; + pixelFormat.TrySetValue(list); + \endcode + \param[in] nullTerminatedList The list of possible values to set. The list is terminated by a NULL value. + \return Returns false if the parameter is not writable. + \pre At least one value within the passed list must be contained in the set of settable enumeration values. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, no value \c nullTerminatedList is settable, or writing the value fails. + */ + virtual bool TrySetValue( const char** nullTerminatedList ) = 0; + + + /*! + \brief Indicates whether the given value can be set. + \return Returns true if the value can be set, otherwise false. + \param[in] value The value to be checked. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Does not throw exceptions. + */ + virtual bool CanSetValue( const String_t& value ) = 0; + + + /*! + \brief Sets the value of the parameter. + Calls FromString(). + \param[in] value The value to set. + \pre The value must be contained in the set of settable enumeration values. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, no value is valid, or writing the value fails. + */ + virtual void SetValue( const String_t& value ) = 0; + + + /*! + \brief Gets the value of the parameter. + \return Returns the current parameter value. + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not readable or if reading the value fails. + */ + virtual String_t GetValue() = 0; + + + /*! + \brief Gets a list of all values of the enumeration that are currently settable. + \param[out] values Returns a list of all values of the enumeration that are currently settable. + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions. + */ + virtual void GetSettableValues( GENAPI_NAMESPACE::StringList_t& values ) = 0; + + + /*! + \brief Gets a list of all values of the enumeration including the values that are currently not settable. + \param[out] values Returns a list of all values of the enumeration including the values that are currently not settable. + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions. + */ + virtual void GetAllValues( GENAPI_NAMESPACE::StringList_t& values ) = 0; + + + /*! + \brief Gets an enumeration entry by its symbolic name. The entry is returned as a CParameter. + This method can be used to access information about the enumeration value represented by the entry using CParameter::GetInfo(). + \param[in] value The symbolic name of the enumeration entry, e.g., "Testimage1". + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions. + */ + virtual CParameter GetEntryByNameAsParameter( const GENICAM_NAMESPACE::gcstring& value ) = 0; + + + /*! + \brief Gets the currently selected entry of an enumeration. The entry is returned as a CParameter. + This method can be used to access information about the enumeration value represented by the entry using CParameter::GetInfo(). + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions. + */ + virtual CParameter GetCurrentEntryAsParameter() = 0; + }; + + + /*! + \brief CEnumParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CEnumParameter : virtual public IEnumerationEx, public CParameter + { + public: + /*! + \brief Creates an empty CEnumParameter object. + \error + Does not throw C++ exceptions. + */ + CEnumParameter(); + + + /*! + \brief Creates a CEnumParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CEnumParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CEnumParameter object and attaches it to a node of a matching type. + \param[in] pEnumeration The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pEnumeration has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CEnumParameter( GENAPI_NAMESPACE::IEnumeration* pEnumeration ); + + + /*! + \brief Creates a CEnumParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CEnumParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CEnumParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CEnumParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CEnumParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CEnumParameter( const CEnumParameter& rhs ); + + + /*! + \brief Destroys the CEnumParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CEnumParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pEnumeration The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IEnumeration* pEnumeration ); + + + /*! + \brief Assigns a CEnumParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CEnumParameter& operator=( const CEnumParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CEnumParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pEnumeration The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IEnumeration* pEnumeration ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::IEnumeration + virtual void GetSymbolics( GENAPI_NAMESPACE::StringList_t& symbolics ); + + // Implements GenApi::IEnumeration + virtual void GetEntries( GENAPI_NAMESPACE::NodeList_t& entries ); + + // Implements GenApi::IEnumeration + virtual GENAPI_NAMESPACE::IEnumeration& operator=( const GENICAM_NAMESPACE::gcstring& valueStr ); + + // Implements GenApi::IEnumeration + virtual void SetIntValue( int64_t value, bool verify = true ); + + // Implements GenApi::IEnumeration + virtual GENICAM_NAMESPACE::gcstring operator*(); + + // Implements GenApi::IEnumeration + virtual int64_t GetIntValue( bool verify = false, bool ignoreCache = false ); + + // Implements GenApi::IEnumeration + virtual GENAPI_NAMESPACE::IEnumEntry* GetEntryByName( const GENICAM_NAMESPACE::gcstring& symbolic ); + + // Implements GenApi::IEnumeration + virtual GENAPI_NAMESPACE::IEnumEntry* GetEntry( const int64_t intValue ); + + // Implements GenApi::IEnumeration + virtual GENAPI_NAMESPACE::IEnumEntry* GetCurrentEntry( bool verify = false, bool ignoreCache = false ); + + + // Implements IEnumerationEx + virtual String_t GetValueOrDefault( const String_t& defaultValue ); + + // Implements IEnumerationEx + virtual bool TrySetValue( const String_t& value ); + + // Implements IEnumerationEx + virtual void SetValue( const char** nullTerminatedList ); + + // Implements IEnumerationEx + virtual bool TrySetValue( const char** nullTerminatedList ); + + // Implements IEnumerationEx + virtual bool CanSetValue( const String_t& value ); + + // Implements IEnumerationEx + virtual void SetValue( const String_t& value ); + + // Implements IEnumerationEx + virtual String_t GetValue(); + + // Implements IEnumerationEx + virtual void GetSettableValues( GENAPI_NAMESPACE::StringList_t& values ); + + // Implements IEnumerationEx + virtual void GetAllValues( GENAPI_NAMESPACE::StringList_t& values ); + + // Implements IEnumerationEx + virtual CParameter GetEntryByNameAsParameter( const GENICAM_NAMESPACE::gcstring& value ); + + // Implements IEnumerationEx + virtual CParameter GetCurrentEntryAsParameter(); + + + public: + // Start - For using C++ enums instead of strings as enumeration values (native parameter access) + class TableItem_t + { + public: + TableItem_t() + : m_szName( "" ) + , m_sizeOfName( 0 ) + { + } + + TableItem_t( const char* name, size_t size ) + : m_szName( name ) + , m_sizeOfName( size ) + { + } + + inline const char* GetName() const + { + return m_szName; + } + + inline size_t GetSizeOfName() const + { + return m_sizeOfName; + } + private: + const char* m_szName; + size_t m_sizeOfName; + }; + class Table_t + { + public: + Table_t() + : m_items( 0 ) + , m_tableSize( 0 ) + { + } + + Table_t( const TableItem_t* items, size_t tableSize ) + : m_items( items ) + , m_tableSize( tableSize ) + { + } + + inline const TableItem_t* GetItems() const + { + return m_items; + } + + inline size_t GetSizeOfTable() const + { + return m_tableSize; + } + private: + const TableItem_t* m_items; + size_t m_tableSize; + }; + protected: + void SetValue( const Table_t& table, size_t index, bool verify ); + size_t /*index*/ GetValue( const Table_t& table, bool verify, bool ignoreCache ); + GENAPI_NAMESPACE::IEnumEntry* GetEntry( const Table_t& table, size_t index ); + bool CanSetValue( const Table_t& table, size_t index ); + // End - For using C++ enums instead of strings as enumeration values (native parameter access) + + protected: + GENAPI_NAMESPACE::IEnumeration* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CENUMPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/EnumParameterT.h b/Cigarette/Pylon6.2/include/pylon/EnumParameterT.h new file mode 100644 index 0000000..1616433 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/EnumParameterT.h @@ -0,0 +1,230 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains a template class that is used to create classes derived from CEnumParameter. +The derived classes use C++ enums instead of strings as enumeration values. They are used for native parameter access. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CENUMPARAMETERT_H +#define INCLUDED_BASLER_PYLON_CENUMPARAMETERT_H + +#pragma once + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +#pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /*! + \brief A template class that is used to create classes derived from CEnumParameter. + The derived classes use C++ enums instead of strings as enumeration values. They are used for native parameter access. + */ + template + interface IEnumParameterT : virtual public IEnumerationEx + { + public: + using IEnumerationEx::SetValue; + using IEnumerationEx::TrySetValue; + using IEnumerationEx::GetValueOrDefault; + using IEnumerationEx::CanSetValue; + using IEnumeration::operator=; + + + /*! + \brief Sets the value passed. + \param[in] value The value to set. + \param[in] verify Enables AccessMode and Range verification (default = true). + \error + Can throw exceptions if the parameter is not writable or if writing the value fails. + */ + virtual void SetValue( EnumT value, bool verify = true ) = 0; + + + /*! + \brief Sets the value passed. + \param[in] value The value to set. + \error + Can throw exceptions if the parameter is not readable or if reading the value fails. + */ + virtual IEnumParameterT& operator=( EnumT value ) = 0; + + + /*! + \brief Gets the current parameter value. + \param verify Enables Range verification (default = false). The AccessMode is always checked. + \param ignoreCache If true, the value is read ignoring any caches (default = false). + \return Returns the current parameter value. + \error + Can throw exceptions if the parameter is not readable or if reading the value fails. + */ + virtual EnumT GetValue( bool verify = false, bool ignoreCache = false ) = 0; + + + /*! + \brief Gets the current parameter value. + \return Returns the current parameter value. + \error + Can throw exceptions if the parameter is not readable or if reading the value fails. + */ + virtual EnumT operator()() = 0; + + + //! Returns the EnumEntry object belonging to the value + virtual GENAPI_NAMESPACE::IEnumEntry* GetEntry( const EnumT value ) = 0; + + + /*! + \brief Gets the parameter value if the parameter is readable. Otherwise returns the default value. + \return Returns the parameter value if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading the value fails. + */ + virtual EnumT GetValueOrDefault( EnumT defaultValue ) = 0; + + + /*! + \brief Sets the value passed if the parameter is writable and the value is contained in the set of settable enumeration values. + \return Returns false if the parameter is not writable or the value is not contained in the set of settable enumeration values. + \param[in] value The value to set. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual bool TrySetValue( EnumT value ) = 0; + + + /*! + \brief Indicates if the value passed can be set. + \return Returns true if the value can be set, otherwise false. + \param[in] value The value to be checked. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Does not throw exceptions. + */ + virtual bool CanSetValue( EnumT value ) = 0; + }; + + + + // A template class that is used to create classes derived from CEnumParameter. + template + class CEnumParameterT : public CEnumParameter, virtual public IEnumParameterT + { + public: + using IEnumeration::operator=; + + CEnumParameterT() + { + } + + CEnumParameterT( GENAPI_NAMESPACE::INode* pNode ) + : CEnumParameter( pNode ) + { + } + + + using CEnumParameter::SetValue; + + // Implements IEnumParameterT + virtual void SetValue( EnumT value, bool verify = true ) + { + SetValue( GetTable(), static_cast(value), verify ); + } + + + // Implements IEnumParameterT + virtual CEnumParameterT& operator=( EnumT value ) + { + SetValue( value ); + return *this; + } + + + // Implements IEnumParameterT + virtual EnumT GetValue( bool verify = false, bool ignoreCache = false ) + { + EnumT result = static_cast(CEnumParameter::GetValue( GetTable(), verify, ignoreCache )); + return result; + } + + + // Implements IEnumParameterT + virtual EnumT operator()() + { + EnumT result = GetValue(); + return result; + } + + + // Implements IEnumParameterT + virtual GENAPI_NAMESPACE::IEnumEntry* GetEntry( const EnumT value ) + { + GENAPI_NAMESPACE::IEnumEntry* result = CEnumParameter::GetEntry( GetTable(), static_cast(value) ); + return result; + } + + + // Implements IEnumParameterT + virtual EnumT GetValueOrDefault( EnumT defaultValue ) + { + if (this->IsReadable()) + { + EnumT result = GetValue(); + return result; + } + return defaultValue; + } + + + // Implements IEnumParameterT + virtual bool TrySetValue( EnumT value ) + { + if (this->IsWritable() && CEnumParameter::CanSetValue( GetTable(), static_cast(value) )) + { + SetValue( value ); + return true; + } + return false; + } + + + // Implements IEnumParameterT + virtual bool CanSetValue( EnumT value ) + { + bool result = CEnumParameter::CanSetValue( GetTable(), static_cast(value) ); + return result; + } + + + protected: + // Must be provided by the specific enum instance class + virtual const Table_t& GetTable() const = 0; + }; +} +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CENUMPARAMETERT_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/EventAdapter.h b/Cigarette/Pylon6.2/include/pylon/EventAdapter.h new file mode 100644 index 0000000..5983f0a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/EventAdapter.h @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: HN +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Definition of the IEventAdapter interface +*/ +#ifndef __PYLON_EVENT_ADAPTER_H__ +#define __PYLON_EVENT_ADAPTER_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include + +namespace Pylon +{ + /*! + \interface IEventAdapter + \brief Low Level API: IEventAdapter delivers event messages to ports + \ingroup Pylon_LowLevelApi + */ + interface PUBLIC_INTERFACE IEventAdapter + { + //! Deliver message + virtual void DeliverMessage( const uint8_t msg[], uint32_t numBytes ) = 0; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__PYLON_EVENT_ADAPTER_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/EventGrabber.h b/Cigarette/Pylon6.2/include/pylon/EventGrabber.h new file mode 100644 index 0000000..7a1bcf8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/EventGrabber.h @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung, AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Definition of IEventGrabber interface +*/ +#ifndef __IEVENTGRABBER_H__ +#define __IEVENTGRABBER_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + + class EventResult; + class WaitObject; + + /*! + \interface IEventGrabber + \ingroup Pylon_LowLevelApi + \brief Low Level API: Interface of an object receiving asynchronous events. + + Asynchronous event messages are received from the camera. Internal Buffers are filled + and stored in an output queue. While the output queue contains data the associated + waitobject is signaled. + + With RetrieveEvent() the first event message is copied into a user buffer. + */ + interface PUBLIC_INTERFACE IEventGrabber + { + /// Open the event grabber + virtual void Open() = 0; + /// Close the event grabber + virtual void Close() = 0; + /// Retrieve whether the event grabber is open + virtual bool IsOpen() const = 0; + /// Retrieve an event message from the output queue + /*! + \return When the event was available true is returned + and the event message is copied into the EventResult. + */ + virtual bool RetrieveEvent( EventResult& ) = 0; + /// Return the event object associated with the grabber + /*! + This object get signaled as soon as a event has occurred. + It will be reset when the output queue is empty. + */ + virtual WaitObject& GetWaitObject() const = 0; + /// Return the associated event grabber parameters + /*! If no parameters are available, NULL is returned. */ + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() = 0; + }; + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__IEVENTGRABBER_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/EventGrabberProxy.h b/Cigarette/Pylon6.2/include/pylon/EventGrabberProxy.h new file mode 100644 index 0000000..c90189c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/EventGrabberProxy.h @@ -0,0 +1,248 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Pylon generic event grabber interface declaration +*/ + + +#ifndef __PYLON_EVENTGRABBERPROXY__H__ +#define __PYLON_EVENTGRABBERPROXY__H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include +#include "EventGrabber.h" +#include "NodeMapProxy.h" + + +//! Low Level API: Macro to define a custom Node map proxy +#define PYLON_DEFINE_EVENTGRABBER(ClassName, BaseClass) \ + class ClassName : public BaseClass \ + { \ + public: \ + /** \name Construction */ \ + /*@{*/ \ + /** \brief \copybrief Pylon::CEventGrabberProxyT::CEventGrabberProxyT() + \copydetails Pylon::CEventGrabberProxyT::CEventGrabberProxyT() + */ \ + ClassName() \ + { \ + } \ + /** \brief \copybrief Pylon::CEventGrabberProxyT::CEventGrabberProxyT(Pylon::IEventGrabber*) + \copydetails Pylon::CEventGrabberProxyT::CEventGrabberProxyT(Pylon::IEventGrabber*) + */ \ + ClassName( Pylon::IEventGrabber* pEventGrabber ) : BaseClass( pEventGrabber ) \ + { \ + } \ + /*@}*/ \ + }; + + + namespace Pylon + { + //************************************************************************************************** + //! Low Level API: The event grabber class with parameter access methods + /** + This is the base class for pylon event grabber providing access to configuration parameters. + \see \ref configuringcameras + + \tparam TParams The specific parameter class (auto generated from the parameter xml file) + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + template + class CEventGrabberProxyT : public CNodeMapProxyT + { + public: + //! \name Construction + // \{ + + //! Creates a CEventGrabberProxyT object that is not attached to a pylon stream grabber. Use the Attach() method to attach the pylon event grabber. + CEventGrabberProxyT(); + + //! Creates a CEventGrabberProxyT object and attaches it to a pylon event grabber. + CEventGrabberProxyT( Pylon::IEventGrabber* ); + + //! Destructor + virtual ~CEventGrabberProxyT(); + + //\} + + private: + //! \name Assignment and copying is not supported + // \{ + CEventGrabberProxyT( const CEventGrabberProxyT& ); + CEventGrabberProxyT& operator=( const CEventGrabberProxyT& ); + // \} + + + public: + //! \name Some smart pointer functionality + // \{ + + //! Attach a pylon event grabber + virtual void Attach( IEventGrabber* ); + + //! Checks if a pylon stream grabber is attached + virtual bool IsAttached() const; + + //! Returns the pylon event grabber interface pointer + virtual IEventGrabber* GetEventGrabber() const; + + // \} + + + public: + //! \name Implementation of the IEventGrabber interface + //! See Pylon::IEventGrabber for more details. + // \{ + + /** \brief \copybrief Pylon::IEventGrabber::Open() + + \copydetails Pylon::IEventGrabber::Open() + */ + void Open() + { + CheckPtr(); + m_pEventGrabber->Open(); + } + + /** \brief \copybrief Pylon::IEventGrabber::Close() + + \copydetails Pylon::IEventGrabber::Close() + */ + void Close() + { + CheckPtr(); + m_pEventGrabber->Close(); + } + + /** \brief \copybrief Pylon::IEventGrabber::IsOpen() + + \copydetails Pylon::IEventGrabber::IsOpen() + */ + bool IsOpen() const + { + CheckPtr(); + return m_pEventGrabber->IsOpen(); + } + + + /** \brief \copybrief Pylon::IEventGrabber::RetrieveEvent() + + \copydetails Pylon::IEventGrabber::RetrieveEvent() + */ + bool RetrieveEvent( EventResult& Result ) + { + CheckPtr(); + return m_pEventGrabber->RetrieveEvent( Result ); + } + + /** \brief \copybrief Pylon::IEventGrabber::GetWaitObject() + + \copydetails Pylon::IEventGrabber::GetWaitObject() + */ + WaitObject& GetWaitObject() const + { + CheckPtr(); + return m_pEventGrabber->GetWaitObject(); + } + + /** \brief \copybrief Pylon::IEventGrabber::GetNodeMap() + + \copydetails Pylon::IEventGrabber::GetNodeMap() + */ + GENAPI_NAMESPACE::INodeMap* GetNodeMap() + { + CheckPtr(); + return m_pEventGrabber->GetNodeMap(); + } + // \} + + + protected: + void CheckPtr() const + { + if (NULL == m_pEventGrabber) + { + throw LOGICAL_ERROR_EXCEPTION( "The stream grabber class is not attached to a pylon event grabber" ); + } + } + + IEventGrabber* m_pEventGrabber; + }; + + + //************************************************************************************************** + // CEventGrabberProxyT implementation + //************************************************************************************************** + + + template + inline CEventGrabberProxyT::CEventGrabberProxyT() + : CNodeMapProxyT(), m_pEventGrabber( NULL ) + { + } + + template + inline CEventGrabberProxyT::CEventGrabberProxyT( IEventGrabber* pEventGrabber ) + : CNodeMapProxyT(), m_pEventGrabber( NULL ) + { + Attach( pEventGrabber ); + } + + template + inline CEventGrabberProxyT::~CEventGrabberProxyT( void ) + { + } + + template + inline void CEventGrabberProxyT::Attach( IEventGrabber* pEventGrabber ) + { + if (IsAttached()) + { + throw LOGICAL_ERROR_EXCEPTION( "Object is already attached to a stream grabber" ); + } + + if (NULL == pEventGrabber) + { + throw LOGICAL_ERROR_EXCEPTION( "Tried to attach a NULL pointer as event grabber" ); + } + + CNodeMapProxyT::Attach( pEventGrabber->GetNodeMap() ); + m_pEventGrabber = pEventGrabber; + } + + template + inline bool CEventGrabberProxyT::IsAttached() const + { + return NULL != m_pEventGrabber; + } + + template + inline IEventGrabber* CEventGrabberProxyT::GetEventGrabber() const + { + return m_pEventGrabber; + } + + } // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/FeaturePersistence.h b/Cigarette/Pylon6.2/include/pylon/FeaturePersistence.h new file mode 100644 index 0000000..ee9b519 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/FeaturePersistence.h @@ -0,0 +1,116 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2009-2021 Basler AG +// http://www.baslerweb.com +// Author: Italo Anzioso +//----------------------------------------------------------------------------- +/*! + \file FeaturePersistence.h + \brief Pylon::CFeaturePersistence class with static helper functions for loading + and saving camera features. + \date 2007-09-11 +*/ + +#ifndef __PYLON_FeaturePersistence_H_090218_090218_IS_INCLUDED__ +#define __PYLON_FeaturePersistence_H_090218_090218_IS_INCLUDED__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include // Pylon::String_t +#include // defines PYLONUTILITY_API + +namespace Pylon +{ + /*! \brief Utility class for saving and restoring camera features to and from a file or string. + + \note When saving features, the behavior of cameras supporting sequencers depends on the + current setting of the "SequenceEnable" (some GigE models) or + "SequencerConfigurationMode" (USB only) features respectively. + + Only if the sequencer is in configuration mode, are the sequence sets exported. + Otherwise, the camera features are exported without sequence sets. + + */ + class PYLONUTILITY_API CFeaturePersistence + { + + public: + + /*! \brief Loads the features from the file to the node map. + + \param[in] FileName Name of the file that contains the node map values. + \param[in] pNodeMap Pointer to the node map + \param[in] validate If validate==true, all node values will be validated. + In case of an error, a GenICam::RuntimeException will be thrown + + \error Throws an exception if loading fails. + */ + static void Load( const String_t& FileName, + GENAPI_NAMESPACE::INodeMap* pNodeMap, + bool validate = true + ); + + /*! \brief Saves the node map to the file. + + Sequence sets of a camera are automatically saved if SequenceEnable or + SequencerConfigurationMode is enabled. + + \param[in] FileName Name of the file that contains the node map values + \param[in] pNodeMap Pointer to the node map + + \error Throws an exception if saving fails. + + */ + static void Save( const String_t& FileName, + GENAPI_NAMESPACE::INodeMap* pNodeMap + ); + /*! + \brief Loads the features from the string to the node map. + + \param[in] Features String containing the node map values. + \param[in] pNodeMap Pointer to the node map. + \param[in] validate If validate==true, all node values will be validated. + In case of an error, a GenICam::RuntimeException will be thrown. + + \error Throws an exception if loading fails. + */ + static void LoadFromString( const String_t& Features, + GENAPI_NAMESPACE::INodeMap* pNodeMap, + bool validate = true + ); + + /*! \brief Saves the node map to the string. + Sequence sets of a camera are automatically saved, if SequenceEnable or + SequencerConfigurationMode is enabled. + + \param[out] Features String containing the node map values + \param[in] pNodeMap Pointer to the node map + + \error Throws an exception if saving fails. + */ + static void SaveToString( String_t& Features, + GENAPI_NAMESPACE::INodeMap* pNodeMap + ); + + private: + CFeaturePersistence( void ); + ~CFeaturePersistence( void ); + + }; + +} // Pylon Namespace + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__PYLON_FeaturePersistence_H_090218_090218_IS_INCLUDED__ diff --git a/Cigarette/Pylon6.2/include/pylon/FloatParameter.h b/Cigarette/Pylon6.2/include/pylon/FloatParameter.h new file mode 100644 index 0000000..331873a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/FloatParameter.h @@ -0,0 +1,527 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CFloatParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CFLOATPARAMETER_H +#define INCLUDED_BASLER_PYLON_CFLOATPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /// Lists possible float value correction strategies. + enum EFloatValueCorrection + { + /// No correction is applied. If the value isn't valid for the parameter, an exception is thrown. + FloatValueCorrection_None = 0, + /// If the value is not in the valid range, the value is corrected to the valid range. + FloatValueCorrection_ClipToRange = 3 + }; + + class CIntegerParameter; + /*! + \brief Extends the GenApi::IFloat interface with convenience methods. + */ + interface IFloatEx : virtual public GENAPI_NAMESPACE::IFloat, virtual public IValueEx + { + using GENAPI_NAMESPACE::IFloat::operator=; + + using GENAPI_NAMESPACE::IFloat::SetValue; + + /*! + \brief Sets the value of the parameter if the parameter is writable. + \brief The value must be in the valid range and the increment must be correct. + \return Returns false if the parameter is not writable. + \param[in] value The value to set. + If the float parameter has an increment, the increment is automatically corrected. + \pre +
    +
  • The passed value must be >= GenApi::IFloat::GetMin(). +
  • The passed value must be <= GenApi::IFloat::GetMax(). +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual bool TrySetValue( double value ) = 0; + + + /*! + \brief Gets the value of the parameter if the parameter is readable. + \brief Otherwise returns the default value. + \return Returns the parameter value if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exception if reading the value fails. + */ + virtual double GetValueOrDefault( double defaultValue ) = 0; + + + /*! + \brief Sets the value of the parameter if the parameter is writable and readable. + \brief The value is automatically corrected if needed. + \return Returns false if the parameter is not readable or not writable. + \param[in] value The value to set. + \param[in] correction The correction method. + \note Calls TrySetValue(GenApi::IFloatParameter, double) if \c correction equals FloatValueCorrection_None. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual bool TrySetValue( double value, EFloatValueCorrection correction ) = 0; + + + /*! + \brief Sets the value of the parameter. The value is automatically corrected if needed. + \param[in] value The value to set. + \param[in] correction The correction method. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \note Calls GenApi::IFloatParameter::SetValue(double) if \c correction equals FloatValueCorrection_None. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual void SetValue( double value, EFloatValueCorrection correction ) = 0; + + + /*! + \brief Gets the value of the parameter in percent of its value range (from minimum to maximum). + \return Returns the parameter value in percent of its value range. Returns 100 if minimum equals maximum. + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual double GetValuePercentOfRange() = 0; + + + /*! + \brief Sets the value of the parameter to a value within its range, using this formula (simplified): ((max - min) * (percentOfRange / 100.0)) + min. + \param[in] percentOfRange The percentage of the range to be used in the calculation. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual void SetValuePercentOfRange( double percentOfRange ) = 0; + + + /*! + \brief If the parameter is writable and readable, sets the value of the parameter to a value within its range, using this formula (simplified): ((max - min) * (percentOfRange / 100.0)) + min. + \return Returns true if the value has been set. + \param[in] percentOfRange The percentage of the range used in the calculation. Valid values are in the range of 0 to 100. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual bool TrySetValuePercentOfRange( double percentOfRange ) = 0; + + + /*! + \brief Sets the parameter value to the maximum possible value. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, not readable, or if reading or writing fails. + */ + virtual void SetToMaximum() = 0; + + + /*! + \brief Sets the parameter value to the minimum possible value. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, not readable, or if reading or writing fails. + */ + virtual void SetToMinimum() = 0; + + + /*! + \brief Sets the parameter value to the maximum possible value if the parameter is readable and writable. + \return Returns true if the maximum value has been set. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading or writing fails. + */ + virtual bool TrySetToMaximum() = 0; + + + /*! + \brief Sets the parameter value to the minimum possible value if the parameter is readable and writable. + \return Returns true if the minimum value has been set. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading or writing fails. + */ + virtual bool TrySetToMinimum() = 0; + + + /*! + \brief Gets the alternative integer representation of the float parameter, if available. + The alternative integer representation is typically used if a parameter is represented as a + float value in the node map, but as an integer register in the camera device. + \param[out] parameter The integer representation returned. The returned value will be empty if no alternative representation is available. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions. + */ + virtual void GetAlternativeIntegerRepresentation( CIntegerParameter& parameter ) = 0; + }; + + + /*! + \brief CFloatParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CFloatParameter : public IFloatEx, public CParameter + { + public: + /*! + \brief Creates an empty CFloatParameter object. + \error + Does not throw C++ exceptions. + */ + CFloatParameter(); + + + /*! + \brief Creates a CFloatParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CFloatParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CFloatParameter object and attaches it to a node of a matching type. + \param[in] pFloat The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pFloat has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CFloatParameter( GENAPI_NAMESPACE::IFloat* pFloat ); + + + /*! + \brief Creates a CFloatParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CFloatParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CFloatParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CFloatParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CFloatParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CFloatParameter( const CFloatParameter& rhs ); + + + /*! + \brief Destroys the CFloatParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CFloatParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pFloat The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IFloat* pFloat ); + + + /*! + \brief Assigns a CFloatParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CFloatParameter& operator=( const CFloatParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CFloatParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pFloat The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IFloat* pFloat ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::IFloat + virtual void SetValue( double value, bool verify = true ); + + // Implements GenApi::IFloat + virtual GENAPI_NAMESPACE::IFloat& operator=( double value ); + + // Implements GenApi::IFloat + virtual double GetValue( bool verify = false, bool ignoreCache = false ); + + // Implements GenApi::IFloat + virtual double operator()(); + + // Implements GenApi::IFloat + virtual double operator*(); + + // Implements GenApi::IFloat + virtual double GetMin(); + + // Implements GenApi::IFloat + virtual double GetMax(); + + // Implements GenApi::IFloat + virtual bool HasInc(); + + // Implements GenApi::IFloat + virtual GENAPI_NAMESPACE::EIncMode GetIncMode(); + + // Implements GenApi::IFloat + virtual double GetInc(); + + // Implements GenApi::IFloat + virtual GENAPI_NAMESPACE::double_autovector_t GetListOfValidValues( bool bounded = true ); + + // Implements GenApi::IFloat + virtual GENAPI_NAMESPACE::ERepresentation GetRepresentation(); + + // Implements GenApi::IFloat + virtual GENICAM_NAMESPACE::gcstring GetUnit() const; + + // Implements GenApi::IFloat + virtual GENAPI_NAMESPACE::EDisplayNotation GetDisplayNotation() const; + + // Implements GenApi::IFloat + virtual int64_t GetDisplayPrecision() const; + + // Implements GenApi::IFloat + virtual void ImposeMin( double value ); + + // Implements GenApi::IFloat + virtual void ImposeMax( double value ); + + + // Implements IFloatEx + virtual bool TrySetValue( double value ); + + // Implements IFloatEx + virtual double GetValueOrDefault( double defaultValue ); + + // Implements IFloatEx + virtual bool TrySetValue( double value, EFloatValueCorrection correction ); + + // Implements IFloatEx + virtual void SetValue( double value, EFloatValueCorrection correction ); + + // Implements IFloatEx + virtual double GetValuePercentOfRange(); + + // Implements IFloatEx + virtual void SetValuePercentOfRange( double percentOfRange ); + + // Implements IFloatEx + virtual bool TrySetValuePercentOfRange( double percentOfRange ); + + // Implements IFloatEx + virtual void SetToMaximum(); + + // Implements IFloatEx + virtual void SetToMinimum(); + + // Implements IFloatEx + virtual bool TrySetToMaximum(); + + // Implements IFloatEx + virtual bool TrySetToMinimum(); + + // Implements IFloatEx + virtual void GetAlternativeIntegerRepresentation( CIntegerParameter& parameter ); + + protected: + GENAPI_NAMESPACE::IFloat* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CFLOATPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/GrabResultData.h b/Cigarette/Pylon6.2/include/pylon/GrabResultData.h new file mode 100644 index 0000000..0f8d4ae --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/GrabResultData.h @@ -0,0 +1,276 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains a class that makes the data for one grabbed buffer available. +*/ + +#ifndef INCLUDED_GRABRESULTDATA_H_1758952 +#define INCLUDED_GRABRESULTDATA_H_1758952 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include // [temporary] namespace alias +#include + +namespace Pylon +{ + // Forward declaration + class CPylonDataContainer; + class CPylonDataComponent; + + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CGrabResultData + \brief Makes the data for one grabbed buffer available. + */ + class PYLONBASE_API CGrabResultData + { + public: + /// Returns true if an image has been grabbed successfully and false in the case of an error. + bool GrabSucceeded() const; + + + /// This method returns a description of the error if GrabSucceeded() returns false due to an error. + String_t GetErrorDescription() const; + + + /// This method returns the error code if GrabSucceeded() returns false due to an error. + uint32_t GetErrorCode() const; + + + /// Get the current payload type. + EPayloadType GetPayloadType() const; + + + /// Get the current pixel type. + EPixelType GetPixelType() const; + + + /// Get the current number of columns. + uint32_t GetWidth() const; + + + /// Get the current number of rows expressed as number of pixels. + uint32_t GetHeight() const; + + + /// Get the current starting column. + uint32_t GetOffsetX() const; + + + /// Get the current starting row. + uint32_t GetOffsetY() const; + + + /// Get the number of extra data at the end of each row in bytes. + uint32_t GetPaddingX() const; + + + /// Get the number of extra data at the end of the image data in bytes. + uint32_t GetPaddingY() const; + + + /// Get the pointer to the buffer. + /*! + If the chunk data feature is activated for the device, chunk data is appended to the image data. + When writing past the image section while performing image processing, the chunk data will be corrupted. + */ + void* GetBuffer() const; + + + /// Get the current payload size in bytes. + size_t GetPayloadSize() const; + + /// Get the size of the buffer returned by GetBuffer() in bytes. + size_t GetBufferSize() const; + + + /// Get the block ID of the grabbed frame (camera device specific). + /*! + \par IEEE 1394 Camera Devices + The value of Block ID is always UINT64_MAX. + + \par GigE Camera Devices + The sequence number starts with 1 and + wraps at 65535. The value 0 has a special meaning and indicates + that this feature is not supported by the camera. + + \par USB Camera Devices + The sequence number starts with 0 and uses the full 64 Bit range. + + \attention A block ID with the value UINT64_MAX indicates that the block ID is invalid and must not be used. + */ + uint64_t GetBlockID() const; + + /// Get the camera specific tick count (camera device specific). + /*! + This describes when the image exposure was started. + Cameras that do not support this feature return zero. If supported, this + can be used to determine which image AOIs were acquired simultaneously. + */ + uint64_t GetTimeStamp() const; + + + /// Get the stride in bytes. + /* + Uses Pylon::ComputeStride to compute the stride from the result data. + + \return The stride in byte. + + \pre The preconditions of Pylon::ComputeStride must be met. + + \error + Throws an exception if the stride value cannot be computed from the result data. + */ + bool GetStride( size_t& strideBytes ) const; + + + /// Get the size of the image in byte. + /* + Uses Pylon::ComputeBufferSize to compute the stride from the result data. + PaddingY is not taken into account. + + \return The buffer size in byte. + + \pre The preconditions of Pylon::ComputeBufferSize must be met. + + \error + Throws an exception if the buffer size cannot be computed from the result data. + */ + size_t GetImageSize() const; + + + /// Get the context value assigned to the camera object. The context is attached to the result when it is retrieved. + intptr_t GetCameraContext() const; + + + /// Get the ID of the grabbed image. + /*! Always returns a number larger than 0. The counting starts with 1 and is never reset during the lifetime of the Instant Camera object. */ + int64_t GetID() const; + + + /// Get the number of the image. This number is incremented when an image is retrieved using CInstantCamera::RetrieveResult(). + /*! Always returns a number larger than 0. The counting starts with 1 and is reset with every call to CInstantCamera::StartGrabbing(). */ + int64_t GetImageNumber() const; + + + /// Get the number of skipped images before this image. + /*! + This value can be larger than 0 if EGrabStrategy_LatestImageOnly grab strategy or GrabStrategy_LatestImages grab strategy is used. + Always returns a number larger than or equal 0. This number does not include the number of images lost in case of a buffer underrun in the driver. + */ + int64_t GetNumberOfSkippedImages() const; + + + /// Returns true if chunk data is available. + /*! + This is the case if the chunk mode is enabled for the camera device. + The parameter CInstantCamera::ChunkNodeMapsEnable of the used Instant Camera object is set to true (default setting). + Chunk data node maps are supported by the Transport Layer of the camera device. + */ + bool IsChunkDataAvailable() const; + + + /// Get the reference to the chunk data node map connected to the result. + /*! An empty node map is returned when the device does not support this feature or when chunks are disabled. */ + GENAPI_NAMESPACE::INodeMap& GetChunkDataNodeMap() const; + + + /// Checks if buffer has a CRC attached. This needs not be activated for the device. See the PayloadCRC16 chunk. + /* The chunk feature must be supported and activated, otherwise false is returned. */ + bool HasCRC() const; + + + /// Checks CRC sum of buffer, returns true if CRC sum is OK. + /* + \error + Throws an exception if GetHasCRC() is false and chunks are activated. + */ + bool CheckCRC() const; + + /// Get the context value assigned to the buffer. The context is set when CInstamtCamera is using a custom buffer factory. + intptr_t GetBufferContext() const; + + /// Returns the grab result as a CPylonDataContainer. + CPylonDataContainer GetDataContainer() const; + + /// \copydoc Pylon::CPylonDataContainer::GetDataComponentCount() + size_t GetDataComponentCount() const; + + /// \copydoc Pylon::CPylonDataContainer::GetDataComponent() + CPylonDataComponent GetDataComponent( size_t index ); + + /// Internal use only. + class CGrabResultDataImpl; + CGrabResultDataImpl* GetGrabResultDataImpl(); + virtual ~CGrabResultData(); + + private: + ///The grab result data object can not be copied. + CGrabResultData( const CGrabResultData& ); + ///The grab result data object can not be copied. + void operator = ( const CGrabResultData& ); + protected: + + /// Internal use only. The grab result data class should only be created by the instant camera class. + friend class CInstantCamera; + CGrabResultData(); + + private: + virtual void Destroy(); + virtual void Initialize(); + + // Internal use only. Subject to change without notice. + friend class CGrabResultDataFactory; + CGrabResultDataImpl* m_pImpl; + + // The grab result data + const void*& m_pBuffer; + size_t& m_bufferSize; + bool& m_grabSucceeded; + EPayloadType& m_payloadType; + EPixelType& m_pixelType; + uint64_t& m_timeStamp; + uint32_t& m_width; + uint32_t& m_height; + uint32_t& m_offsetX; + uint32_t& m_offsetY; + uint32_t& m_paddingX; + uint32_t& m_paddingY; + uint64_t& m_payloadSize; + uint32_t& m_errorCode; + String_t& m_errorDescription; + intptr_t& m_cameraContext; + int64_t& m_ID; + int64_t& m_imageNumber; + int64_t& m_skippedImageCount; + intptr_t& m_bufferContext; + uint64_t& m_blockId; + }; + + /** + * @} + */ + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_GRABRESULTDATA_H_1758952 */ diff --git a/Cigarette/Pylon6.2/include/pylon/GrabResultPtr.h b/Cigarette/Pylon6.2/include/pylon/GrabResultPtr.h new file mode 100644 index 0000000..fdc0821 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/GrabResultPtr.h @@ -0,0 +1,216 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains a smart pointer that holds a reference to grab result data. +*/ + +#ifndef INCLUDED_GRABRESULTPTR_H_4356898 +#define INCLUDED_GRABRESULTPTR_H_4356898 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + namespace PylonPrivate + { + class CGrabResultDataConverter; + } + + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CGrabResultPtr + \brief A smart pointer holding a reference to grab result data. + + This class is used for distributing the grab result data of a camera. It controls + the reuse and lifetime of the referenced buffer. When all smart pointers referencing + a buffer go out of scope the referenced buffer is reused or destroyed. + The data and the held buffer are still valid after the camera object it originated from + has been destroyed. + \attention The grabbing will stop with an input queue underrun, when the grab results are + never released, e.g. when put into a container. + + The CGrabResultPtr class provides a cast operator that allows passing the grab result directly to functions or methods + that take an const IImage& as parameter, e.g. image saving functions or image format converter methods. + + \attention The returned reference to IImage is only valid as long the CGrabResultPtr object it came from is not destroyed. + + \threading Instances of CGrabResultPtr referencing the same grab result can be used from any thread context. + */ + class PYLONBASE_API CGrabResultPtr + { + public: + /*! + \brief Creates a smart pointer. + \post No grab result is referenced. + */ + CGrabResultPtr(); + + + /*! + \brief Creates a copy of a smart pointer. + + \param[in] rhs Another smart pointer, source of the result data to reference. + + The data itself is not copied. + + \post +
    +
  • Another reference to the grab result of the source is held if it references a grab result. +
  • No grab result is referenced if the source does not reference a grab result. +
+ + \error + Still valid after error. + */ + CGrabResultPtr( const CGrabResultPtr& rhs ); + + + /*! + \brief Assignment of a smart pointer. + + \param[in] rhs Another smart pointer, source of the result data to reference. + + The data itself is not copied. + + \post +
    +
  • The currently referenced data is released. +
  • Another reference to the grab result of the source is held if it references a grab result. +
  • No grab result is referenced if the source does not reference a grab result. +
+ + \error + Still valid after error. + */ + CGrabResultPtr& operator = ( const CGrabResultPtr& rhs ); + + + /*! + \brief Destroys the smart pointer. + + \post The currently referenced data is released. + + \error + Does not throw C++ exceptions. + */ + ~CGrabResultPtr(); + + + /*! + \brief Allows accessing the referenced data. + + \return The pointer to the grab result data. + + \pre The pointer must reference a grab result. + IsValid() or the overloaded bool operator can be used to check whether data is referenced. + + \error + Still valid after error. Throws an exception when no data is referenced. + */ + CGrabResultData* operator->() const; + + + /*! + \brief Check whether data is referenced. + + \return True if data is referenced. + + \error + Does not throw C++ exceptions. + */ + bool IsValid() const; + + + /*! + \brief Check whether data is referenced. + + \return IsValid(). + + The overloaded bool operator can be used to check whether data is referenced. + Example: + \code + if ( grabResult) + { + grabResult->GetStatus(); + } + \endcode + + \error + Does not throw C++ exceptions. + */ + operator bool() const; + + + /*! + \brief The currently referenced data is released. + + \post The currently referenced data is released. + + \error + Still valid after error. + */ + void Release(); + + + /*! + \brief Provides an IImage interface to the grab result. + + This cast operator allows passing the grab result to saving functions or image format converter. + The returned image is invalid if the grab was not successful, see CGrabResultData::GrabSucceeded(). + + \attention The returned reference is only valid as long the grab result ptr is not destroyed. + + \error + Still valid after error. + */ + operator IImage& () const; + + + /*! + \brief Indicates that the held grab result data and buffer is only referenced by this grab result. + + \return Returns true if the held grab result data and buffer is only referenced by this grab result. Returns false if the grab result is invalid. + + \error + Does not throw C++ exceptions. + */ + bool IsUnique() const; + + + /// Internal use only. + class CGrabResultPtrImpl; + CGrabResultPtr& operator = ( const CGrabResultPtrImpl& rhs ); + private: + /// Internal use only. + friend class PylonPrivate::CGrabResultDataConverter; + CGrabResultData* GetPtr() const; + mutable CGrabResultPtrImpl* m_pImpl; + CGrabResultData* m_pGrabResultData; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_GRABRESULTPTR_H_4356898 */ diff --git a/Cigarette/Pylon6.2/include/pylon/Image.h b/Cigarette/Pylon6.2/include/pylon/Image.h new file mode 100644 index 0000000..0b4e0cd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Image.h @@ -0,0 +1,193 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains an interface for an image. +*/ + +#ifndef INCLUDED_IMAGE_H_9730799 +#define INCLUDED_IMAGE_H_9730799 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /// Defines the vertical orientation of an image in memory. + enum EImageOrientation + { + ImageOrientation_TopDown, //!< The first row of the image is located at the start of the image buffer. This is the default for images taken by a camera. + ImageOrientation_BottomUp //!< The last row of the image is located at the start of the image buffer. + }; + + /*! + \interface IImage + \brief Usable to access image properties and image buffer. + */ + interface IImage + { + public: + /// Ensure proper destruction by using a virtual destructor. + // Do not add implemenation here in class as older compilers doesn't accept in-class definitions (see definition below) + virtual ~IImage() = 0; + + // + /*! + \brief Can be used to check whether an image is valid. + + \return Returns false if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsValid() const = 0; + + + /*! + \brief Get the current pixel type. + + \return Returns the pixel type or PixelType_Undefined if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual EPixelType GetPixelType() const = 0; + + + /*! + \brief Get the current number of columns in pixels. + + \return Returns the current number of columns in pixels or 0 if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual uint32_t GetWidth() const = 0; + + + /*! + \brief Get the current number of rows. + + \return Returns the current number of rows or 0 if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual uint32_t GetHeight() const = 0; + + + /*! + \brief Get the number of extra data bytes at the end of each row. + + \return Returns the number of extra data bytes at the end of each row or 0 if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual size_t GetPaddingX() const = 0; + + + /*! + \brief Get the vertical orientation of the image in memory. + + \return Returns the orientation of the image or ImageOrientation_TopDown if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual EImageOrientation GetOrientation() const = 0; + + + /*! + \brief Get the pointer to the buffer. + + \return Returns the pointer to the used buffer or NULL if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual void* GetBuffer() = 0; + + + /*! + \brief Get the pointer to the buffer containing the image. + + The buffer is at least as large as the value returned by GetImageSize(). + + \return Returns the pointer to the used buffer or NULL if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual const void* GetBuffer() const = 0; + + + /*! + \brief Get the size of the image in bytes. + + \return Returns the size of the image in bytes or 0 if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual size_t GetImageSize() const = 0; + + + /*! + \brief Indicates that the referenced buffer is only referenced by this image. + + \return Returns true if the referenced buffer is only referenced by this image. Returns false if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsUnique() const = 0; + + + /*! + \brief Get the stride in bytes. + + The stride in bytes can not be computed for packed image format when the stride is not byte aligned. See also Pylon::IsPacked(). + The stride in bytes can not be computed if the image is invalid. + + \param[out] strideBytes The stride in byte if it can be computed. + \return Returns true if the stride can be computed. + + \error + Does not throw C++ exceptions. + */ + virtual bool GetStride( size_t& strideBytes ) const = 0; + }; + + /** + * @} + */ + + // Implementation required for Windows only. + // Note: the C++ standard >= 11 prohibit pure virtual destructors with a function body + // in the declaration. Consequently gcc 4.0 and newer reject an inline implementation + // in the class. + inline IImage::~IImage() + { + } +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_IMAGE_H_9730799 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ImageDecompressor.h b/Cigarette/Pylon6.2/include/pylon/ImageDecompressor.h new file mode 100644 index 0000000..8ea6a8c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ImageDecompressor.h @@ -0,0 +1,630 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +// Author: MP +//----------------------------------------------------------------------------- +/** +* \file +* \brief Declaration of the CImageDecompressor class +*/ +#pragma once + +#ifndef INCLUDED_IMAGEDECOMPRESSOR_H_C5305647 +#define INCLUDED_IMAGEDECOMPRESSOR_H_C5305647 + +#include + +#include +#include +#include +#include +#include +#include + +namespace Pylon +{ + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + /*! + \enum ECompressionStatus + \brief Status of a grab buffer/result with compressed data. + + It is possible that images could not be compressed properly by the camera (if the amount of data required for + compressing an image exceeds the desired compression ratio). If an image was compressed successfully, it will + have the compression status CompressionStatus_Ok. + */ + enum ECompressionStatus + { + CompressionStatus_Ok, //!< Buffer was compressed properly. + CompressionStatus_BufferOverflow, //!< Size of compressed image exceeded desired compression ratio. + CompressionStatus_Error //!< Generic error. + }; + + /*! + \enum EEndianness + \brief Endianness for parsing the grab buffer/result as defined for the camera technology used. + + If not known, Endianness_Auto can be used to detect the endianness automatically. However, this may take longer. + */ + enum EEndianness + { + Endianness_Little, //!< Little endian (e.g., as used in USB3 Vision). + Endianness_Big, //!< Big endian (e.g., as used in GigE Vision). + Endianness_Auto //!< Try to detect endianness automatically. + }; + + /*! + \struct CompressionInfo_t + \brief The struct containing information about a grab buffer/result. + + You can find more information about the usage of this struct in the description of + the CImageDecompressor class. + */ + struct PYLONUTILITY_API CompressionInfo_t + { + bool hasCompressedImage; ///< True if grab buffer/result provided contains a compressed image (otherwise false if buffer/result is already decompressed). + ECompressionStatus compressionStatus; ///< Status of compression (see ECompressionStatus). + bool lossy; ///< True if image was compressed lossily (otherwise false if it was compressed losslessly). + EPixelType pixelType; ///< Pixel type of compressed image. + size_t width; ///< Width (in pixels) of compressed image. + size_t height; ///< Height (in pixels) of compressed image. + size_t offsetX; ///< X offset (in pixels) of compressed image. + size_t offsetY; ///< Y offset (in pixels) of compressed image. + size_t paddingX; ///< X padding (line padding; in bytes) of compressed image. + size_t paddingY; ///< Y padding (image padding; in bytes) of compressed image. + size_t decompressedImageSize; ///< Size (in bytes) required for decompressed image (only valid if hasCompressedImage is true). + size_t decompressedPayloadSize; ///< Size (in bytes; including chunk data) required for decompressed payload (only valid if hasCompressedImage is true). + + /*! + \brief Creates and initializes a compression info struct. + \error + Does not throw C++ exceptions. + */ + CompressionInfo_t(); + }; + + /*! + \enum ECompressionMode + \brief Mode used for transferring images. + + The compression mode can have three states. Either compression is disabled in the camera (CompressionMode_Off) + or the camera compresses the images in one of two ways (CompressionMode_BaslerLossless or CompressionMode_BaslerFixRatio). + */ + enum ECompressionMode + { + CompressionMode_Off, //!< Images are transferred uncompressed. + CompressionMode_BaslerLossless, //!< Images are transferred with Basler lossless compression. + CompressionMode_BaslerFixRatio //!< Images are transferred with Basler fixed ratio compression (which may lead to lossily compressed images). + }; + + /*! + \class CImageDecompressor + \brief Provides convenient access to cameras that support image compression and helps with decompressing these images. + + A decompressor requires a compression descriptor in order to be able to decompress images. You can set + a compression descriptor via the constructor or the SetCompressionDescriptor methods (in both cases, + either using the node map or manually). + + A compression descriptor can be identified via a hash. This hash can be used to identify the matching + compression descriptor for a particular compressed image. It can be computed using the + ComputeCompressionDescriptorHash method or retrieved from the camera, decompressor, or a grab buffer/result + using one of the GetCompressionDescriptorHash methods. + + Grab buffers/results may contain different kinds of data. You can use the + decompressor's GetCompressionInfo methods to distinguish between them. For that to work, a + grab buffer/result must have been received successfully and it must contain the + payload type chunk (for grab results you can get the payload type using the + GetPayloadType method). + + If compression info for the grab buffer/result provided is available, + GetCompressionInfo returns true and you will receive the compression info + via the CompressionInfo_t struct. + If the field hasCompressedImage in the struct is true, the grab buffer/result + contains a compressed image. In this case, you should check the compressionStatus + field in the struct to check whether the camera was able to compress + the image properly. The camera can't compress an image if the amount of + data required for compressing the image exceeds the desired compression ratio. + The image can be decompressed if compressionStatus is CompressionStatus_Ok. + If the field hasCompressedImage in the struct is false, the grab buffer/result + contains an already decompressed image. In this case, the decompressedImageSize + and decompressedPayloadSize fields will not be used. All other fields contain + information about the decompressed data. + */ + class PYLONUTILITY_API CImageDecompressor + { + public: + /*! + \brief Creates an empty decompressor without compression descriptor. + + This constructor does not initialize the decompressor with a compression descriptor. You will have to + initialize the decompressor first by using one of the SetCompressionDescriptor methods in order to be + able to decompress images. You will get an exception if you access methods that require the decompressor + to be initialized (see method descriptions for which methods are affected by that precondition). + \error + Throws an exception if no memory can be allocated. + */ + CImageDecompressor(); + + /*! + \brief Creates a decompressor by copying from another decompressor. + \param[in] imageDecompressor Decompressor to copy from during initialization. + \error + Throws an exception if no memory can be allocated. + */ + explicit CImageDecompressor( const CImageDecompressor& imageDecompressor ); + + /*! + \brief Creates a decompressor and initializes it with the compression descriptor provided. + \param[in] pCompressionDescriptor Pointer to the compression descriptor. This parameter must not be NULL. + \param[in] sizeCompressionDescriptor Size of the data (in bytes) of the compression descriptor. + \error + Throws an exception if no memory can be allocated or the compression descriptor provided is invalid (e.g., because it is corrupt) + or incompatible (e.g., because a compression descriptor of a newer compression implementation is passed). + */ + CImageDecompressor( const void* pCompressionDescriptor, size_t sizeCompressionDescriptor ); + + /*! + \brief Creates a decompressor and initializes it with a compression descriptor that is retrieved from the camera's node map. + \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor. + \error + Throws an exception if no memory can be allocated or no proper compression descriptor can be retrieved from the camera. + */ + explicit CImageDecompressor( GENAPI_NAMESPACE::INodeMap& nodeMap ); + + /*! + \brief Destroys the decompressor instance. + \error + Does not throw C++ exceptions. + \threading + This method is thread-safe. + */ + ~CImageDecompressor(); + + /*! + \brief Determines whether the decompressor already has a compression descriptor. + \return Returns true if the decompressor is already initialized with a compression descriptor or false otherwise. + \error + Does not throw C++ exceptions. + \threading + This method is thread-safe. + */ + bool HasCompressionDescriptor() const; + + /*! + \brief Resets the compression descriptor in the decompressor. + \note After calling this method, no images can be decompressed by the decompressor because it is + back in uninitialized state. + \error + Does not throw C++ exceptions. + \threading + This method is thread-safe. + */ + void ResetCompressionDescriptor(); + + /*! + \brief Initializes a decompressor with the compression descriptor provided. + \param[in] pCompressionDescriptor Pointer to the compression descriptor. This parameter must not be NULL. + \param[in] sizeCompressionDescriptor Size of the data (in bytes) of the compression descriptor. + \error + Throws an exception if no memory can be allocated or the compression descriptor provided is invalid (e.g., because it is corrupt) + or incompatible (e.g., because a compression descriptor of a newer compression implementation is passed). + \threading + This method is thread-safe. + */ + void SetCompressionDescriptor( const void* pCompressionDescriptor, size_t sizeCompressionDescriptor ); + + /*! + \brief Initializes a decompressor with a compression descriptor that is retrieved from the camera's node map. + \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor. + \error + Throws an exception if no memory can be allocated or no proper compression descriptor can be retrieved from the camera. + \threading + This method is thread-safe. + */ + void SetCompressionDescriptor( GENAPI_NAMESPACE::INodeMap& nodeMap ); + + /*! + \brief Retrieves the current compression mode from the camera's node map. + + This indicates which kind of compression is active or whether compression is not enabled (or unavailable). + \param[in] nodeMap Node map of the camera to be used for retrieving the compression mode. + \return Returns the current compression mode of the camera. + \error + Throws an exception if an error is encountered while determining the compression mode. + \threading + This method is thread-safe. + */ + static ECompressionMode GetCompressionMode( GENAPI_NAMESPACE::INodeMap& nodeMap ); + + /*! + \brief Gets the currently set compression descriptor. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + \param[out] pCompressionDescriptor Pointer to the buffer that will receive the compression descriptor or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeCompressionDescriptor On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor (if pCompressionDescriptor is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor. + This parameter must not be NULL. + \error + Throws an exception if the decompressor has no compression descriptor set or the input parameters are + invalid (e.g., if the size provided is not sufficient to hold the compression descriptor). + \threading + This method is thread-safe. + */ + void GetCompressionDescriptor( void* pCompressionDescriptor, size_t* pSizeCompressionDescriptor ) const; + + /*! + \brief Gets the current compression descriptor from the camera's node map. + + This method requires image compression to be enabled in the camera. You can determine this via the + GetCompressionMode method. + \param[out] pCompressionDescriptor Pointer to the buffer that will receive the compression descriptor or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeCompressionDescriptor On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor (if pCompressionDescriptor is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor. + This parameter must not be NULL. + \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor. + \error + Throws an exception if compression is not enabled in the camera (or unavailable) or the input parameters are + invalid (e.g., if the size provided is not sufficient to hold the compression descriptor). + \threading + This method is thread-safe. + */ + static void GetCompressionDescriptor( void* pCompressionDescriptor, size_t* pSizeCompressionDescriptor, GENAPI_NAMESPACE::INodeMap& nodeMap ); + + /*! + \brief Gets compression information about a grab buffer. + \param[out] compressionInfo Reference to the struct that will receive the compression information if the grab buffer contains such information. + \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL. + \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer). + \param[in] endianness Endianness of the grab buffer's content. If not known, auto detection can be used. + \return Returns true if compression information could be extracted from the the grab buffer or false otherwise. + \error + Throws an exception if the input parameters are invalid. + \threading + This method is thread-safe. + */ + static bool GetCompressionInfo( CompressionInfo_t& compressionInfo, const void* pGrabBuffer, size_t payloadSize, EEndianness endianness = Endianness_Auto ); + + /*! + \brief Gets compression information about a grab result. + \param[out] compressionInfo Reference to the struct that will receive the compression information if the grab result contains such information. + \param[in] grabResult Grab result that holds the compressed data. + \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used. + \return Returns true if compression information could be extracted from the the grab result or false otherwise. + \error + Throws an exception if the input parameters are invalid. + \threading + This method is thread-safe. + */ + static bool GetCompressionInfo( CompressionInfo_t& compressionInfo, const Pylon::GrabResult& grabResult, EEndianness endianness = Endianness_Auto ); + + /*! + \brief Gets compression information about a grab result. + \param[out] compressionInfo Reference to the struct that will receive the compression information if the grab result contains such information. + \param[in] grabResultPtr Pointer to grab result that holds the compressed data. + \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used. + \return Returns true if compression information could be extracted from the the grab result or false otherwise. + \error + Throws an exception if the input parameters are invalid. + \threading + This method is thread-safe. + */ + static bool GetCompressionInfo( CompressionInfo_t& compressionInfo, const Pylon::CGrabResultPtr grabResultPtr, EEndianness endianness = Endianness_Auto ); + + /*! + \brief Computes the hash for a given compression descriptor. + \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor hash (if pHash is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor hash. + This parameter must not be NULL. + \param[in] pCompressionDescriptor Pointer to the compression descriptor. This parameter must not be NULL. + \param[in] sizeCompressionDescriptor Size of the data (in bytes) of the compression descriptor. + \error + Throws an exception if the input parameters are invalid (e.g., if the size provided is not sufficient to hold + the compression descriptor hash). + \threading + This method is thread-safe. + */ + static void ComputeCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const void* pCompressionDescriptor, size_t sizeCompressionDescriptor ); + + /*! + \brief Gets the hash of the currently set compression descriptor. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor hash (if pHash is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor hash. + This parameter must not be NULL. + \error + Throws an exception if the decompressor has no compression descriptor set or the input parameters are + invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash). + \threading + This method is thread-safe. + */ + void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash ) const; + + /*! + \brief Gets the hash of the current compression descriptor from the camera's node map. + + This method requires image compression to be enabled in the camera. You can determine this via the + GetCompressionMode method. + \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor hash (if pHash is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor hash. + This parameter must not be NULL. + \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor hash. + \error + Throws an exception if compression is not active in the camera (or unavailable) or the input parameters + are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash). + \threading + This method is thread-safe. + */ + static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, GENAPI_NAMESPACE::INodeMap& nodeMap ); + + /*! + \brief Gets the hash of the compression descriptor that is required for decompressing the grab buffer provided. + \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor hash (if pHash is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor hash. + This parameter must not be NULL. + \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL. + \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer). + \param[in] endianness Endianness of the grab buffer's content. If not known, auto detection can be used. + \error + Throws an exception if the grab buffer does not contain compressed data, the data is corrupt, or the input + parameters are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash). + \threading + This method is thread-safe. + */ + static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const void* pGrabBuffer, size_t payloadSize, EEndianness endianness = Endianness_Auto ); + + /*! + \brief Gets the hash of the compression descriptor that is required for decompressing the grab result provided. + \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor hash (if pHash is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor hash. + This parameter must not be NULL. + \param[in] grabResult Grab result that holds the compressed data. + \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used. + \error + Throws an exception if the grab result does not contain compressed data, the data is corrupt, or the input + parameters are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash). + \threading + This method is thread-safe. + */ + static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const Pylon::GrabResult& grabResult, EEndianness endianness = Endianness_Auto ); + + /*! + \brief Gets the hash of the compression descriptor that is required for decompressing the grab result provided. + \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or + NULL if you only want to get the size of the buffer for buffer allocation. + \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes) + for the compression descriptor hash (if pHash is not NULL). + On output, the variable will receive the actual buffer size required for the current + compression descriptor hash. + This parameter must not be NULL. + \param[in] grabResultPtr Pointer to grab result that holds the compressed data. + \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used. + \error + Throws an exception if the grab result does not contain compressed data, the data is corrupt, or the input + parameters are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash). + \threading + This method is thread-safe. + */ + static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const Pylon::CGrabResultPtr grabResultPtr, EEndianness endianness = Endianness_Auto ); + + /*! + \brief Gets size (in bytes) required for allocating buffers for decompressing the images during streaming. + + This method requires image compression to be enabled in the camera. You can determine this via the + GetCompressionMode method. + \param[in] nodeMap Node map of the camera to be used for retrieving the image size required for decompression. + \return Returns the buffer size (in bytes) required for image decompression. + \error + Throws an exception if an error is encountered while determining the image size required for decompression. + \threading + This method is thread-safe. + */ + static size_t GetImageSizeForDecompression( GENAPI_NAMESPACE::INodeMap& nodeMap ); + + /*! + \brief Decompresses the image of the grab buffer provided. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + + The grab buffer provided must contain a compressed image that has been received without errors. + \param[out] pOutputBuffer Pointer to the buffer that will receive the decompressed image. This parameter must + not be NULL. + \param[in,out] pSizeOutputBuffer On input, the variable specifies the size of the buffer (in bytes) + for the decompressed image (must be larger or equal to the value in the decompressedImageSize + field in the CompressionInfo_t struct received via the GetCompressionInfo methods; + alternatively, the GetImageSizeForDecompression method can be used to get the image + size required for decompression). + On output, the variable will receive the actual buffer size required for the decompressed image. + This parameter must not be NULL. + \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL. + \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer). + \return Returns the struct with the compression information of the compressed image. + \error + Throws an exception if the grab buffer does not contain compressed data, the data is corrupt, the image cannot + be decompressed, or the input parameters are invalid (e.g., if the size provided is not sufficient to hold the + decompressed image). + \threading + This method is thread-safe. + */ + CompressionInfo_t DecompressImage( void* pOutputBuffer, size_t* pSizeOutputBuffer, const void* pGrabBuffer, size_t payloadSize ) const; + + /*! + \brief Decompresses the image of the grab result provided. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + + The grab result provided must contain a compressed image that has been received without errors. + \param[out] pOutputBuffer Pointer to the buffer that will receive the decompressed image. This parameter must + not be NULL. + \param[in,out] pSizeOutputBuffer On input, the variable specifies the size of the buffer (in bytes) + for the decompressed image (must be larger or equal to the value in the decompressedImageSize + field in the CompressionInfo_t struct received via the GetCompressionInfo + methods; alternatively, the GetImageSizeForDecompression method can be used to get the image + size required for decompression). + On output, the variable will receive the actual buffer size required for the decompressed image. + This parameter must not be NULL. + \param[in] grabResult Grab result that holds the compressed data. + \return Returns the struct with the compression information about the compressed image. + \error + Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot + be decompressed or the input parameters are invalid (e.g., if the size provided is not sufficient to hold the + decompressed image). + \threading + This method is thread-safe. + */ + CompressionInfo_t DecompressImage( void* pOutputBuffer, size_t* pSizeOutputBuffer, const Pylon::GrabResult& grabResult ) const; + + /*! + \brief Decompresses the image of the grab result provided. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + + The grab result provided must contain a compressed image that has been received without errors. + \param[out] pOutputBuffer Pointer to the buffer that will receive the decompressed image. This parameter must + not be NULL. + \param[in,out] pSizeOutputBuffer On input, the variable specifies the size of the buffer (in bytes) + for the decompressed image (must be larger or equal to the value in the decompressedImageSize + field in the CompressionInfo_t struct received via the GetCompressionInfo methods; + alternatively, the GetImageSizeForDecompression method can be used to get the image + size required for decompression). + On output, the variable will receive the actual buffer size required for the decompressed image. + This parameter must not be NULL. + \param[in] grabResultPtr Pointer to grab result that holds the compressed data. + \return Returns the struct with the compression information about the compressed image. + \error + Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot + be decompressed or the input parameters are invalid (e.g., if the size provided is not sufficient to hold the + decompressed image). + \threading + This method is thread-safe. + */ + CompressionInfo_t DecompressImage( void* pOutputBuffer, size_t* pSizeOutputBuffer, const Pylon::CGrabResultPtr grabResultPtr ) const; + + /*! + \brief Decompresses the image of the grab buffer provided. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + + The grab buffer provided must contain a compressed image that has been received without errors. + \param[out] destinationImage Image object (e.g., instance of CPylonImage) that will be filled with the decompressed + image (will be resized if required). + \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL. + \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer). + \return Returns the struct with the compression information about the compressed image. + \error + Throws an exception if the grab buffer does not contain compressed data, the data is corrupt, the image cannot + be decompressed or the input parameters are invalid. + \threading + This method is thread-safe. + */ + CompressionInfo_t DecompressImage( IReusableImage& destinationImage, const void* pGrabBuffer, size_t payloadSize ) const; + + /*! + \brief Decompresses the image of the grab result provided. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + + The grab result provided must contain a compressed image that has been received without errors. + \param[out] destinationImage Image object (e.g., instance of CPylonImage) that will be filled with the decompressed + image (will be resized if required). + \param[in] grabResult Grab result that holds the compressed data. + \return Returns the struct with the compression information about the compressed image. + \error + Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot be + decompressed, or the input parameters are invalid. + \threading + This method is thread-safe. + */ + CompressionInfo_t DecompressImage( IReusableImage& destinationImage, const Pylon::GrabResult& grabResult ) const; + + /*! + \brief Decompresses the image of the grab result provided. + + This method requires that a compression descriptor has been set previously via the constructor or + the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method. + + The grab result provided must contain a compressed image that has been received without errors. + \param[out] destinationImage Image object (e.g., instance of CPylonImage) that will be filled with the decompressed + image (will be resized if required). + \param[in] grabResultPtr Pointer to grab result that holds the compressed data. + \return Returns the struct with the compression information about the compressed image. + \error + Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot be + decompressed, or the input parameters are invalid. + \threading + This method is thread-safe. + */ + CompressionInfo_t DecompressImage( IReusableImage& destinationImage, const Pylon::CGrabResultPtr grabResultPtr ) const; + + /*! + \brief Copies the decompressor. + \param[in] imageDecompressor The source decompressor. + \return Returns a reference to the destination decompressor. + \error + Does not throw C++ exceptions. + \threading + This method is thread-safe. + */ + CImageDecompressor& operator = ( const CImageDecompressor& imageDecompressor ); + + /*! + \brief Compares this instance with another decompressor. + \param[in] imageDecompressor The decompressor on the right-hand side of the comparison. + \return True if both decompressors are equal or false otherwise. + \error + Does not throw C++ exceptions. + \threading + This method is thread-safe. + */ + bool operator == ( const CImageDecompressor& imageDecompressor ); + + private: + struct Impl_t; + + Impl_t* m_pImpl; + }; + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +} //namespace Pylon + +#endif // INCLUDED_IMAGEDECOMPRESSOR_H_C5305647 diff --git a/Cigarette/Pylon6.2/include/pylon/ImageEventHandler.h b/Cigarette/Pylon6.2/include/pylon/ImageEventHandler.h new file mode 100644 index 0000000..b18612e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ImageEventHandler.h @@ -0,0 +1,171 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the image event handler base class. +*/ + +#ifndef INCLUDED_IMAGEEVENTHANDLER_H_8866388 +#define INCLUDED_IMAGEEVENTHANDLER_H_8866388 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class CInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /** + \class CImageEventHandler + \brief The image event handler base class. + */ + class CImageEventHandler + { + public: + + /** + \brief This method is called when images have been skipped using the GrabStrategy_LatestImageOnly strategy or the GrabStrategy_LatestImages strategy. + + \param[in] camera The source of the call. + \param[in] countOfSkippedImages The number of images skipped. This \c countOfSkippedImages does not include the number of images lost in the case of a buffer under run in the driver. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImagesSkipped( CInstantCamera& camera, size_t countOfSkippedImages ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( countOfSkippedImages ); + } + + /** + \brief This method is called when an image has been grabbed. + + The grab result smart pointer passed does always reference a grab result data object. + The status of the grab needs to be checked before accessing the grab result data. + See CGrabResultData::GrabSucceeded(), CGrabResultData::GetErrorCode() and + CGrabResultData::GetErrorDescription() for more information. + + \param[in] camera The source of the call. + \param[in] grabResult The grab result data. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImageGrabbed( CInstantCamera& camera, const CGrabResultPtr& grabResult ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( grabResult ); + } + + /** + \brief This method is called when the image event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerRegistered( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when the image event handler has been deregistered. + + The image event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerDeregistered( CInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /*! + \brief Destroys the image event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyImageEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CImageEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CImageEventHandler( const CImageEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CImageEventHandler& operator=( const CImageEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CImageEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_IMAGEEVENTHANDLER_H_8866388 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ImageFormatConverter.h b/Cigarette/Pylon6.2/include/pylon/ImageFormatConverter.h new file mode 100644 index 0000000..786f9fd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ImageFormatConverter.h @@ -0,0 +1,506 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains an image format converter class. +*/ + +#ifndef INCLUDED_IMAGEFORMATCONVERTER_H_1564142 +#define INCLUDED_IMAGEFORMATCONVERTER_H_1564142 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4275 ) // Class must have a dll interface to be used by clients of the class. +#endif + +#include +#include +#include +#include + +namespace Pylon +{ + using namespace Basler_ImageFormatConverterParams; + + + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /*! + \class CImageFormatConverter + \brief Creates new images by converting a source image to another format. + + Supported input image formats defined by the pixel type: + +
    +
  • PixelType_Mono1packed +
  • PixelType_Mono2packed +
  • PixelType_Mono4packed +
  • PixelType_Mono8 +
  • PixelType_Mono10 +
  • PixelType_Mono10packed +
  • PixelType_Mono10p +
  • PixelType_Mono12 +
  • PixelType_Mono12packed +
  • PixelType_Mono12p +
  • PixelType_Mono16 +
+
    +
  • PixelType_BayerGR8 +
  • PixelType_BayerRG8 +
  • PixelType_BayerGB8 +
  • PixelType_BayerBG8 +
  • PixelType_BayerGR10 +
  • PixelType_BayerRG10 +
  • PixelType_BayerGB10 +
  • PixelType_BayerBG10 +
  • PixelType_BayerGR12 +
  • PixelType_BayerRG12 +
  • PixelType_BayerGB12 +
  • PixelType_BayerBG12 +
  • PixelType_BayerGR12Packed +
  • PixelType_BayerRG12Packed +
  • PixelType_BayerGB12Packed +
  • PixelType_BayerBG12Packed +
  • PixelType_BayerGR10p +
  • PixelType_BayerRG10p +
  • PixelType_BayerGB10p +
  • PixelType_BayerBG10p +
  • PixelType_BayerGR12p +
  • PixelType_BayerRG12p +
  • PixelType_BayerGB12p +
  • PixelType_BayerBG12p +
  • PixelType_BayerGR16 +
  • PixelType_BayerRG16 +
  • PixelType_BayerGB16 +
  • PixelType_BayerBG16 +
+
    +
  • PixelType_RGB8packed +
  • PixelType_BGR8packed +
  • PixelType_RGBA8packed +
  • PixelType_BGRA8packed +
  • PixelType_RGB10packed +
  • PixelType_BGR10packed +
  • PixelType_RGB12packed +
  • PixelType_BGR12packed +
  • PixelType_RGB12V1packed +
  • PixelType_RGB16packed +
  • PixelType_RGB8planar +
  • PixelType_RGB16planar +
+
    +
  • PixelType_YUV422packed +
  • PixelType_YUV422_YUYV_Packed +
  • PixelType_YCbCr422_8_YY_CbCr_Semiplanar +
  • PixelType_YCbCr420_8_YY_CbCr_Semiplanar +
+ + Supported output image formats defined by the pixel type: + +
    +
  • PixelType_BGRA8packed - This pixel type can be used in Windows bitmaps. See Pylon::SBGRA8Pixel. +
  • PixelType_BGR8packed - This pixel type can be used in Windows bitmaps. See Pylon::SBGR8Pixel. +
  • PixelType_RGB8packed - See Pylon::SRGB8Pixel. +
  • PixelType_RGB16packed - See Pylon::SRGB16Pixel. +
  • PixelType_RGB8planar +
  • PixelType_RGB16planar +
  • PixelType_Mono8 +
  • PixelType_Mono16 +
  • PixelType_YUV444planar +
  • PixelType_YUV422planar +
  • PixelType_YUV420planar +
+ + + All input image formats can be converted to all output image formats. + + RGB, BGR and Bayer image formats are converted to monochrome formats by using the following formula: + + \code + mono = (0.25 * red) + (0.625 * green) + (0.125 * blue); + \endcode + + YUV formats are converted to 16 bit bit depth in an intermediate conversion step. This is why the output + is always aligned at the most significant bit when converting to 16 bit color output formats like PixelType_RGB16packed. + + \par Limitations: + The last column of a YUV input image with odd width cannot be converted. + The last column and the last row of a Bayer input image cannot be converted. + + The default treatment of rows and columns that cannot be converted due to their location on edges, + can be controlled using the CImageFormatConverter::InconvertibleEdgeHandling parameter. + See also the Convert() method description. + + \threading + The CImageFormatConverter class is not thread-safe. + */ + class PYLONUTILITY_API CImageFormatConverter : public CImageFormatConverterParams_Params + { + public: + + /*! + \brief Creates an image format converter. + + \error + Does not throw C++ exceptions. + */ + CImageFormatConverter(); + + + /*! + \brief Destroys the image format converter. + + \error + Does not throw C++ exceptions. + */ + virtual ~CImageFormatConverter(); + + + /*! + \brief Optionally initializes the image format converter before conversion. + + \param[in] sourcePixelType The pixel type of the source image. + +
    +
  • Depending on parameter settings and the input format, data structures required for conversion are created, e.g. lookup tables. +
  • Initialization is done automatically when calling Convert() if needed. This may add a delay when converting the first image. +
+ + \pre +
    +
  • The converter parameters are set up. +
  • The \c pixelTypeSource must be supported by the converter. +
+ + Lookup tables are created when using monochrome images as input and when + the gamma conversion method is selected + or when the shift conversion method is selected and the value of AdditionalLeftShift is not zero. + The converter can be reinitialized with other settings if required. + + \error + Throws an exception if the passed pixel type does not represent a valid input format. + The converter object is still valid after error and can be initialized again. + */ + virtual void Initialize( EPixelType sourcePixelType ); + + + /*! + \brief Returns information about the converter being initialized. + + \param[in] sourcePixelType The pixel type of the source image. + + The result depends on the converter settings. + + \return True if initialized. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsInitialized( EPixelType sourcePixelType ) const; + + + /*! + \brief Destroys data structures required for conversion. + + This function can be called to free resources held by the format converter. + + \error + Does not throw C++ exceptions. + */ + virtual void Uninitialize(); + + + /*! + \brief Checks to see if a conversion is required or if the source image already has the desired format. + + \param[in] sourceImage The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \return Returns true if the source image already has the desired format. + + A conversion may even be required image format does not change e.g. if the gamma conversion method is selected and the format describes a monochrome image. + + \error + Does not throw C++ exceptions. + */ + virtual bool ImageHasDestinationFormat( const IImage& sourceImage ) const; + + + /*! + \brief Checks to see if a conversion is required or if the source image already has the desired format. + + \param[in] sourcePixelType The pixel type of the source image. + \param[in] sourcePaddingX The number of extra data bytes at the end of each row. The default value is usually 0. + \param[in] sourceOrientation The vertical orientation of the image in the image buffer. The default value is usually ImageOrientation_TopDown. + + \return Returns true if the source image already has the desired format. This is done according to the current converter settings. + + A conversion may even be required image format does not change e.g. if the gamma conversion method is selected and the format describes a monochrome image. + + \error + Does not throw C++ exceptions. + */ + virtual bool ImageHasDestinationFormat( EPixelType sourcePixelType, size_t sourcePaddingX, EImageOrientation sourceOrientation ) const; + + + /*! + \brief Computes the size of the destination image buffer in byte. + + \param[in] sourceImage The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \return The size of the destination image when converting the given source image using current converter settings. + + \error + Throws an exception if the destination image size for the passed input cannot be computed. The converter object is still valid after error. + */ + virtual size_t GetBufferSizeForConversion( const IImage& sourceImage ) const; + + + /*! + \brief Computes the size of the destination image buffer in byte. + + \param[in] sourceWidth The number of pixels in a row in the source image. + \param[in] sourceHeight The number of rows in the source image. + \param[in] sourcePixelType The pixel type of the source image. + \return The size of the destination image when converting the source image using current converter settings. + + \pre +
    +
  • The \c sourceWidth value must be >= 0 and < _I32_MAX. +
  • The \c sourceHeight value must be >= 0 and < _I32_MAX. +
+ + \error + Throws an exception if the destination image size for the passed input cannot be computed. The converter object is still valid after error. + */ + virtual size_t GetBufferSizeForConversion( EPixelType sourcePixelType, uint32_t sourceWidth, uint32_t sourceHeight ) const; + + + /*! + \brief Creates a new image by converting an image to a different format. + + The IReusableImage::Reset() method of the destination image is called to set the destination format. + The image is converted to the destination image according to the current converter settings. + The padding area of a row in the destination image is set to zero. + + The OutputPaddingX setting is ignored for images that do not support user defined padding, e.g. + CPylonBitmapImage. See also IReusableImage::IsAdditionalPaddingSupported(). + + \param[out] destinationImage The destination image, e.g. a CPylonImage or CPylonBitmapImage object. + When passing a CPylonBitmapImage object the target format must be supported by the CPylonBitmapImage class. + \param[in] sourceImage The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + + \pre +
    +
  • The source and destination images must be different images. +
  • The source image must be valid. +
  • The format of the source image must be supported by the converter. +
  • The destination image must support the destination format. +
  • The destination image must be able to provide a large enough buffer to hold the image. +
+ + \error + Throws an exception if the passed parameters are not valid. The converter object is still valid after error. + */ + virtual void Convert( IReusableImage& destinationImage, const IImage& sourceImage ); + + + /*! + \brief Creates a new image by converting an image to a different format. + + The IReusableImage::Reset() method of the destination image is called to set the destination format. + The image is converted to the destination image according to the current converter settings. + The padding area of a row in the destination image is set to zero. + + The OutputPaddingX setting is ignored for images that do not support user defined padding, e.g. + CPylonBitmapImage. See also IReusableImage::IsAdditionalPaddingSupported(). + + \param[out] destinationImage The destination image. + \param[in] pSourceBuffer The pointer to the buffer of the source image. + \param[in] sourceBufferSizeBytes The size of the buffer of the source image. + \param[in] sourcePixelType The pixel type of the source image. + \param[in] sourceWidth The number of pixels in a row in the source image. + \param[in] sourceHeight The number of rows in the source image. + \param[in] sourcePaddingX The number of extra data bytes at the end of each row. The default value is usually 0. + \param[in] sourceOrientation The vertical orientation of the source image in the image buffer. The default value is usually ImageOrientation_TopDown. + + \pre +
    +
  • The pixel type must be valid. +
  • The \c sourceWidth value must be >= 0 and < _I32_MAX. +
  • The \c sourceHeight value must be >= 0 and < _I32_MAX. +
  • The pointer to the source buffer must not be NULL. +
  • The source buffer must be large enough to hold the image described by the parameters. +
  • The format of the input image represented by the given parameter must be supported by the converter. +
  • The destination image must support the destination format. +
  • The destination image must be able to provide a large enough buffer to hold the image. +
  • The source image buffer and the destination image buffer must not be identical. +
+ + \error + Throws an exception if the passed parameters are not valid. The converter object is still valid after error. + */ + virtual void Convert( IReusableImage& destinationImage, + const void* pSourceBuffer, + size_t sourceBufferSizeBytes, + EPixelType sourcePixelType, + uint32_t sourceWidth, + uint32_t sourceHeight, + size_t sourcePaddingX, + EImageOrientation sourceOrientation + ); + + + /*! + \brief Creates a new image by converting an image to a different format. + + The image is converted to the destination image according to the current converter settings. + The padding area of a row in the destination image is set to zero. + + \param[out] pDestinationBuffer The pointer to the buffer of the destination image. + \param[in] destinationBufferSizeBytes The size of the buffer of the destination image. + \param[in] sourceImage The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + + \pre +
    +
  • The format of the source image must be supported by the converter. +
  • The destination image buffer must be large enough to hold the destination image. +
  • The source image buffer and the destination image buffer must not be identical. +
+ + \error + Throws an exception if the passed parameters are not valid. The converter object is still valid after error. + */ + virtual void Convert( void* pDestinationBuffer, size_t destinationBufferSizeBytes, const IImage& sourceImage ); + + + /*! + \brief Creates a new image by converting an image to a different format. + + The image is converted to the destination image according to the current converter settings. + The padding area of a row in the destination image is set to zero. + + \param[out] pDestinationBuffer The pointer to the buffer of the destination image. + \param[in] destinationBufferSizeBytes The size of the buffer of the destination image. + \param[in] pSourceBuffer The pointer to the buffer of the source image. + \param[in] sourceBufferSizeBytes The size of the buffer of the source image. + \param[in] sourcePixelType The pixel type of the source image. + \param[in] sourceWidth The number of pixels in a row in the source image. + \param[in] sourceHeight The number of rows in the source image. + \param[in] sourcePaddingX The number of extra data bytes at the end of each row. The default value is usually 0. + \param[in] sourceOrientation The vertical orientation of the source image in the image buffer. The default value is usually ImageOrientation_TopDown. + + \pre +
    +
  • The parameters regarding the source buffer must describe a valid image. +
  • The format of the input image represented by the given parameter must be supported by the converter. +
  • If the destination image buffer must be large enough to hold the destination image. +
  • The the source buffer can not be equal the destination buffer. +
+ + \error + Throws an exception if the passed parameters are not valid. The converter object is still valid after error. + */ + virtual void Convert( void* pDestinationBuffer, + size_t destinationBufferSizeBytes, + const void* pSourceBuffer, + size_t sourceBufferSizeBytes, + EPixelType sourcePixelType, + uint32_t sourceWidth, + uint32_t sourceHeight, + size_t sourcePaddingX, + EImageOrientation sourceOrientation + ); + + + /*! + \brief Returns true if the image format defined by the given pixel type is a supported input format. + + \param[in] sourcePixelType The pixel type of the source image. + + \error + Does not throw C++ exceptions. + */ + static bool IsSupportedInputFormat( EPixelType sourcePixelType ); + + + /*! + \brief Returns true if the image format defined by the given pixel type is a supported output format. + + \param[in] destinationPixelType The pixel type of the destination image. + + \error + Does not throw C++ exceptions. + */ + static bool IsSupportedOutputFormat( EPixelType destinationPixelType ); + + + /*! + \brief Provides access to the node map of the format converter. + \return Reference to the node map of the format converter. + + \error + Does not throw C++ exceptions. + */ + virtual GENAPI_NAMESPACE::INodeMap& GetNodeMap(); + + private: + // The converter object can not be copied. + CImageFormatConverter( const CImageFormatConverter& src ); + // The converter object can not be copied. + CImageFormatConverter& operator=( const CImageFormatConverter& src ); + + // Internal use only. + class CImageFormatConverterImpl; + CImageFormatConverterImpl* m_pImpl; + + public: + // This class emulates part of the behavior of a GENAPI_NAMESPACE::IEnumerationT interface used for native parameter access. + // This allows using the EPixelType enumeration. + class IOutputPixelFormatEnum + { + public: + virtual void operator=( EPixelType outputPixelType ) = 0; + virtual void SetValue( EPixelType outputPixelType ) = 0; + + virtual EPixelType GetValue() const = 0; + virtual EPixelType operator()() const = 0; + }; + + /*! + \brief The pixel data format of the output image. + + This member can be used to get and set the output pixel format using the EPixelType enumeration. + It emulates the behavior of native parameter access. + + \pre + The pixel format set must be a supported output pixel format. See IsSupportedOutputFormat(). + \error + Throws an exception if the set output pixel format is not supported. + */ + IOutputPixelFormatEnum& OutputPixelFormat; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_IMAGEFORMATCONVERTER_H_1564142 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ImagePersistence.h b/Cigarette/Pylon6.2/include/pylon/ImagePersistence.h new file mode 100644 index 0000000..801c945 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ImagePersistence.h @@ -0,0 +1,254 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains an image loading and saving support class. +*/ +#ifndef INCLUDED_IMAGEPERSISTENCE_H_3336145 +#define INCLUDED_IMAGEPERSISTENCE_H_3336145 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + +#if defined(PYLON_WIN_BUILD) + /// Lists the available file formats + enum EImageFileFormat + { + ImageFileFormat_Bmp = 0, //!< Windows Bitmap, no compression. + ImageFileFormat_Tiff = 1, //!< Tagged Image File Format, no compression, supports mono images with more than 8 bit bit depth. + ImageFileFormat_Jpeg = 2, //!< Joint Photographic Experts Group, lossy data compression. + ImageFileFormat_Png = 3, //!< Portable Network Graphics, lossless data compression. + ImageFileFormat_Raw = 4, //!< Saves the raw image buffer data. Packed image formats are unpacked. See GetPixelTypesForUnpacking() for more information. + //!< In the format used for saving, the data cannot be loaded using CImagePersistence::Load(). + ImageFileFormat_Dng = 5 //!< Saves Bayer pattern images in DNG/TIFF format. Packed image formats are unpacked. See GetPixelTypesForUnpacking() for more information. + //!< In the format used for saving, the data cannot be loaded using CImagePersistence::Load(). + }; +#elif defined(PYLON_UNIX_BUILD) + /// Lists the available file formats + enum EImageFileFormat + { + ImageFileFormat_Tiff = 1, //!< Tagged Image File Format, no compression, supports mono images with more than 8 bit bit depth. + ImageFileFormat_Png = 3, //!< Portable Network Graphics, lossless data compression. + ImageFileFormat_Raw = 4, //!< Saves the raw image buffer data. Packed image formats are unpacked. See GetPixelTypesForUnpacking() for more information. + //!< This format cannot be loaded unsing CImagePersistence::Load(). + ImageFileFormat_Dng = 5 //!< Saves Bayer pattern images in DNG/TIFF format. Packed image formats are unpacked. See GetPixelTypesForUnpacking() for more information. + //!< In the format used for saving, the data cannot be loaded using CImagePersistence::Load(). + }; +#else +# error unsupported platform +#endif + + + /// Used to pass options to CImagePersistence methods. + class CImagePersistenceOptions + { + public: + CImagePersistenceOptions() + : m_quality( 90 ) + { + } + + ~CImagePersistenceOptions() + { + } + + /// Set the image quality options. Valid quality values range from 0 to 100. + void SetQuality( int quality ) + { + m_quality = quality; + } + + /// Returns the set quality level. + int GetQuality() + { + return m_quality; + } + + private: + int m_quality; ///< Can be used to control the quality when saving JPEG images. + }; + + + /*! + \class CImagePersistence + \brief Contains static functions supporting loading and saving of images. + */ + class PYLONUTILITY_API CImagePersistence + { + public: + /*! + \brief Saves the image to disk. Converts the image to a format that can be saved if required. + + If required, the image is automatically converted to a new image and then saved. See + CanSaveWithoutConversion() for more information. + An image with a bit depth higher than 8 bit is stored with 16 bit bit depth + if supported by the image file format. In this case the pixel data is MSB aligned. + + If more control over the conversion is required then the CImageFormatConverter class + can be used to convert the input image before saving it. + + \param[in] imageFileFormat The file format to save the image in. + \param[in] filename Name and path of the image. + \param[in] pBuffer The pointer to the buffer of the image. + \param[in] bufferSize The size of the buffer in byte. + \param[in] pixelType The pixel type of the image to save. + \param[in] width The number of pixels in a row of the image to save. + \param[in] height The number of rows of the image to save. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + \param[in] pOptions Additional options. + + \pre +
    +
  • The pixel type of the image to save must be a supported input format of the Pylon::CImageFormatConverter. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
+ + \error + Throws an exception if saving the image fails. + */ + static void Save( EImageFileFormat imageFileFormat, const String_t& filename, const void* pBuffer, size_t bufferSize, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation, CImagePersistenceOptions* pOptions = NULL ); + + + /*! + \brief Saves the image to disk. Converts the image to a format that can be if required. + + If required, the image is automatically converted to a new image and then saved. See + CanSaveWithoutConversion() for more information. + An image with a bit depth higher than 8 bit is stored with 16 bit bit depth + if supported by the image file format. In this case the pixel data is MSB aligned. + + If more control over the conversion is required then the CImageFormatConverter class + can be used to convert the input image before saving it. + + \param[in] imageFileFormat The target file format for the image to save. + \param[in] filename Name and path of the image. + \param[in] image The image to save, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \param[in] pOptions Additional options. + + \pre + The pixel type of the image to save must be a supported input format of the Pylon::CImageFormatConverter. + + \error + Throws an exception if saving the image fails. + */ + static void Save( EImageFileFormat imageFileFormat, const String_t& filename, const IImage& image, CImagePersistenceOptions* pOptions = NULL ); + + + /*! + \brief Can be used to check whether the given image can be saved without prior conversion. + + See the CImagePersistence::CanSaveWithoutConversion( EImageFileFormat, const IImage&) method documentation for a list of supported pixel formats. + + \param[in] imageFileFormat The target file format for the image to save. + \param[in] pixelType The pixel type of the image to save. + \param[in] width The number of pixels in a row of the image to save. + \param[in] height The number of rows of the image to save. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + \return Returns true if the image can be saved without prior conversion. + + \error + Does not throw C++ exceptions. + */ + static bool CanSaveWithoutConversion( EImageFileFormat imageFileFormat, EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation ); + + + /*! + \brief Can be used to check whether the image can be saved without prior conversion. + + Supported formats for TIFF: +
    +
  • PixelType_Mono8 +
  • PixelType_Mono16 +
  • PixelType_RGB8packed +
  • PixelType_RGB16packed +
+ + Supported formats for BMP, JPEG and PNG: +
    +
  • PixelType_Mono8 +
  • PixelType_BGR8packed +
  • PixelType_BGRA8packed +
+ + Supported formats for DNG: +
    +
  • PixelType_BayerGR* +
  • PixelType_BayerRG* +
  • PixelType_BayerGB* +
  • PixelType_BayerBG* +
+ With *: 8, 10, 12, 16, 10p, 12p, 12packed + + \param[in] imageFileFormat The target file format for the image to save. + \param[in] image The image to save, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \return Returns true if the image can be saved without prior conversion. + + \error + Does not throw C++ exceptions. + */ + static bool CanSaveWithoutConversion( EImageFileFormat imageFileFormat, const IImage& image ); + + + /*! + \brief Loads an image from disk. + + The orientation of loaded images is always ImageOrientation_TopDown. + + \param[in] filename Name and path of the image. + \param[in] image The target image object, e.g. a CPylonImage or CPylonBitmapImage object. + When passing a CPylonBitmapImage object the loaded format must be supported by the CPylonBitmapImage class. + + \error + Throws an exception if the image cannot be loaded. The image buffer content is undefined when the loading of the image fails. + */ + static void Load( const String_t& filename, IReusableImage& image ); + + /*! + \brief Loads an image from memory. + + The orientation of loaded images is always ImageOrientation_TopDown. + Currently BMP, JPEG & PNG images are supported. + + \param[in] pBuffer The pointer to the buffer of the source image. + \param[in] bufferSizeBytes The size of the buffer of the source image. + \param[in] image The target image object, e.g. a CPylonImage or CPylonBitmapImage object. + When passing a CPylonBitmapImage object the loaded format must be supported by the CPylonBitmapImage class. + + \error + Throws an exception if the image cannot be loaded. The image buffer content is undefined when the loading of the image fails. + */ + static void LoadFromMemory( const void* pBuffer, size_t bufferSizeBytes, IReusableImage& image ); + + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_IMAGEPERSISTENCE_H_3336145 */ diff --git a/Cigarette/Pylon6.2/include/pylon/Info.h b/Cigarette/Pylon6.2/include/pylon/Info.h new file mode 100644 index 0000000..d217fc0 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Info.h @@ -0,0 +1,192 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the IProperties interface and the CInfoBase class +*/ + +#ifndef __INFO_H__ +#define __INFO_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /*! + \interface IProperties + \brief interface for a property container + */ + interface PUBLIC_INTERFACE IProperties + { + /// Retrieves a list of property names + virtual int GetPropertyNames( StringList_t& ) const = 0; + /// Returns true if a property with the provided name is available + virtual bool GetPropertyAvailable( const String_t& Name ) const = 0; + /// Retrieves a property value + virtual bool GetPropertyValue( const String_t& Name, String_t& Value ) const = 0; + /// Modifies a property value + virtual IProperties& SetPropertyValue( const String_t& Name, const String_t& Value ) = 0; + /// Returns true if all properties of the subset can be found and the values are equal + /// The implementing container may use special knowledge on how to compare the values + /// For instance for IP adresses, 192.2.3.45 == 192.2.3.0x2D + virtual bool IsSubset( const IProperties& Subset ) const = 0; + + }; + + ///This namespace contains values for the different transport layer types + namespace TLType + { + ///Value for the GigE Vision transport layer + const char* const TLTypeGigE = "GEV"; + ///Value for the USB3 Vision transport layer + const char* const TLTypeUSB = "U3V"; + ///Value for the IIDC 1394 transport layer + const char* const TLType1394 = "IIDC"; + ///Value for the BCON transport layer + const char* const TLTypeBCON = "BCON"; + ///Value for the Camera Link transport layer + const char* const TLTypeCL = "CL"; + ///Value for the camera emulator transport layer + const char* const TLTypeCamEmu = "CamEmu"; + ///Value for the IP camera transport layer + const char* const TLTypeIPCam = "IPCam"; + ///Value for the CoaXPress transport layer + const char* const TLTypeCXP = "CXP"; + ///Value for the "Custom" transport layer + const char* const TLTypeCustom = "Custom"; + } + + ///This namespace contains keys for accessing the properties of pylon info objects + namespace Key + { + ///Identifies the human readable name of the device. + const char* const FriendlyNameKey = "FriendlyName"; + ///Identifies the full name identifying the device. + const char* const FullNameKey = "FullName"; + ///Identifies the vendor name of the device. + const char* const VendorNameKey = "VendorName"; + ///Identifies the device class device, e.g. Basler1394. + const char* const DeviceClassKey = "DeviceClass"; + ///Identifies the transport layer type. + const char* const TLTypeKey = "TLType"; + ///Identifies the interface ID. + const char* const InterfaceIDKey = "InterfaceID"; + } + + class CInfoImpl; + + /*! + \brief Base implementation for PYLON info container. + + Info container allow a generic access to implemented properties. All + Properties and their values can be accessed without knowing them in + advance. It is possible to enumerate all properties available and corresponding + values. Properties and values are represented as String_t. The normal usage + is to have enumerators that create the info objects and clients that read only. + + If the type of the info object is known before client can use specific + accessor function to retrieve the property values + + */ + class PYLONBASE_API CInfoBase : public IProperties + { + public: + static const char* const PropertyNotAvailable; + + CInfoBase& operator=( const CInfoBase& ); + + /// compare two info objects + bool operator==( const CInfoBase& rhs ) const; + + /*! + \brief Compares CInfoBase objects by device class. + \param[in] rhs The right-hand side object of the comparison. + \return Returns true according to this rule: USB < GigE < CameraLink < 1394 < GenTL (incl. CXP) < Bcon < unknown device classes < CamEmu. + \error + Does not throw C++ exceptions. + */ + bool operator < ( const CInfoBase& rhs ) const; + + /* The underlying implementation does not need to support all the listed properties. + The properties that are not supported always have the value "N/A" which is the value of CInfoBase::PropertyNotAvailable */ + + ///Retrieves the human readable name of the device. + ///This property is identified by Key::FriendlyNameKey. + String_t GetFriendlyName() const; + ///Sets the above property. + CInfoBase& SetFriendlyName( const String_t& FriendlyNameValue ); + ///Returns true if the above property is available. + bool IsFriendlyNameAvailable() const; + + ///Retrieves the full name identifying the device. + ///This property is identified by Key::FullNameKey. + String_t GetFullName() const; + ///Sets the above property. + CInfoBase& SetFullName( const String_t& FullNameValue ); + ///Returns true if the above property is available. + bool IsFullNameAvailable() const; + + ///Retrieves the vendor name of the device. + ///This property is identified by Key::VendorNameKey. + String_t GetVendorName() const; + ///Sets the above property. + CInfoBase& SetVendorName( const String_t& VendorNameValue ); + ///Returns true if the above property is available. + bool IsVendorNameAvailable() const; + + ///Retrieves the device class device, e.g. Basler1394. + ///This property is identified by Key::DeviceClassKey. + String_t GetDeviceClass() const; + ///Sets the above property. + CInfoBase& SetDeviceClass( const String_t& DeviceClassValue ); + ///Returns true if the above property is available. + bool IsDeviceClassAvailable() const; + + ///Retrieves the transport layer type. + ///This property is identified by Key::TLTypeKey. + String_t GetTLType() const; + ///Sets the above property. + CInfoBase& SetTLType( const String_t& value ); + ///Returns true if the above property is available. + bool IsTLTypeAvailable() const; + + public: + static const char* GetPropertyNotAvailable(); + virtual int GetPropertyNames( StringList_t& ) const; + virtual bool GetPropertyAvailable( const String_t& Name ) const; + /* Returns the value of the property if this property is supported by the underlying implementation or "N/A". */ + virtual bool GetPropertyValue( const String_t& Name, String_t& Value ) const; + virtual IProperties& SetPropertyValue( const String_t& Name, const String_t& Value ); + virtual bool IsUserProvided() const; + virtual bool IsSubset( const IProperties& Subset ) const; + + protected: + CInfoBase(); + CInfoBase( const CInfoBase& ); + virtual ~CInfoBase(); + + protected: + CInfoImpl* m_pImpl; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/InstantCamera.h b/Cigarette/Pylon6.2/include/pylon/InstantCamera.h new file mode 100644 index 0000000..fd58902 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/InstantCamera.h @@ -0,0 +1,1300 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains a camera class establishing convenient access to a camera device. +*/ + +#ifndef INCLUDED_INSTANTCAMERA_H_08725703 +#define INCLUDED_INSTANTCAMERA_H_08725703 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Pylon +{ + /// Internal use only. + class IInstantCameraExtensions; +} + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +#endif + +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /// Lists the possible grab strategies. + enum EGrabStrategy + { + GrabStrategy_OneByOne, //!< The images are processed in the order of their arrival. This is the default grab strategy. + + GrabStrategy_LatestImageOnly, //!< Only the latest image is kept in the output queue, all other grabbed images are skipped. + //!< If no image is in the output queue when retrieving an image with \c CInstantCamera::RetrieveResult(), + //!< the processing waits for the upcoming image. + + GrabStrategy_LatestImages, //!< This strategy can be used to grab images while keeping only the latest images. If the application does not + //!< retrieve all images in time, all other grabbed images are skipped. The CInstantCamera::OutputQueueSize parameter can be used to + //!< control how many images can be queued in the output queue. When setting the output queue size to 1, this strategy is equivalent to + //!< GrabStrategy_LatestImageOnly grab strategy. When setting the output queue size to CInstantCamera::MaxNumBuffer, + //!< this strategy is equivalent to GrabStrategy_OneByOne. + + GrabStrategy_UpcomingImage //!< The input buffer queue is kept empty. This prevents grabbing. + //!< However, when retrieving an image with a call to the \c CInstantCamera::RetrieveResult() method + //!< a buffer is queued into the input queue and then the call waits for the upcoming image. + //!< The buffer is removed from the queue on timeout. + //!< Hence after the call to the \c CInstantCamera::RetrieveResult() method the input buffer queue is empty again. + //!< The upcoming image grab strategy cannot be used together with USB or GenTL-based camera devices. See the advanced topics section of + //!< the pylon Programmer's Guide for more information. + }; + + /// Defines who deletes a passed object if it is not needed anymore. + enum ECleanup + { + Cleanup_None, //!< The caller is responsible for deleting the passed object. The object needs to be detached or deregistered before deletion. + Cleanup_Delete //!< The passed object is deleted if it is not needed anymore. + }; + + /// Defines the use of an additional grab loop thread. + enum EGrabLoop + { + GrabLoop_ProvidedByInstantCamera, //!< The grab loop thread is provided by the Instant Camera. It calls RetrieveResult() in a loop. Grabbed images are processed by registered image event handlers. The grab loop thread is started when the grab starts. + GrabLoop_ProvidedByUser //!< The user code calls RetrieveResult() in a loop to process grabbed images and camera events. + }; + + /// Defines how to register an item. + enum ERegistrationMode + { + RegistrationMode_Append, //!< The item is appended to the list of registered items. + RegistrationMode_ReplaceAll //!< The item replaces all other registered items. + }; + + /// Defines how to register a camera event handler. + enum ECameraEventAvailability + { + CameraEventAvailability_Mandatory, //!< The camera event must be provided by the camera, otherwise an exception is thrown. + CameraEventAvailability_Optional //!< The camera event handler is not used if the camera does not support the camera event. + }; + + /// Defines how to handle a timeout for a method. + enum ETimeoutHandling + { + TimeoutHandling_Return, //!< The method returns on timeout. What data is returned can be found in the documentation of the method. + TimeoutHandling_ThrowException //!< An exception is thrown on timeout. + }; + + /*! + \class CInstantCamera + \brief Provides convenient access to a camera device. + +
    +
  • Establishes a single access point for accessing camera functionality. +
  • The class can be used off the shelf without any parameters. The camera uses a default configuration for the camera device. This can be overridden. +
  • Handles %Pylon device lifetime. This can be overridden. +
  • Handles opening and closing of a %Pylon device automatically. +
  • Handles chunk data parsing automatically returning the chunk data in the grab result. +
  • Handles event grabbing automatically providing a convenient interface for event callbacks. This can be overridden. +
  • Handles physical camera device removal. +
  • Handles the creation, reuse, and destruction of buffers. +
  • The grabbing can be done in the context of the caller or by using an additional grab loop thread. +
  • The Instant Camera class is extensible using derivation or by registering event handler objects. +
+ */ + class PYLONBASE_API CInstantCamera : public Basler_InstantCameraParams::CInstantCameraParams_Params + { + public: + //Creation and life time------------------------------------------------ + + /*! + \brief Creates an Instant Camera object with no attached %Pylon device. + + \error + Does not throw C++ exceptions. + */ + CInstantCamera(); + + + /*! + \brief Creates an Instant Camera object and calls Attach(). + + See Attach() for more information. + + \param[in] pDevice The %Pylon device to attach. + \param[in] cleanupProcedure If cleanupProcedure equals Cleanup_Delete, the %Pylon device is destroyed when the Instant Camera object is destroyed. + + \error + May throw an exception if the passed %Pylon device is open. + Does not throw C++ exceptions if the passed %Pylon device is closed or NULL. + */ + CInstantCamera( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ); + + + /*! + \brief Destroys an Instant Camera object. + + Calls Attach( NULL) for destroying or removing a %Pylon device depending on the passed cleanup procedure. + + \error + Does not throw C++ exceptions. + */ + virtual ~CInstantCamera(); + + + /*! + \brief Attaches a %Pylon device to the Instant Camera. + + \param[in] pDevice The %Pylon device to attach. + \param[in] cleanupProcedure If cleanupProcedure equals Cleanup_Delete, the %Pylon device is destroyed when the Instant Camera object is destroyed. + +
    +
  • If a %Pylon device is currently attached, it is destroyed (DestroyDevice()) or removed (DetachDevice()) depending on the previously set cleanup procedure value. +
  • If the pDevice parameter is NULL, nothing more is done. +
  • The OnAttach configuration event is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
  • The new %Pylon device is attached. +
  • The instant camera migration mode setting is applied to the %Pylon device transport layer node map. +
  • If the passed %Pylon device is open, callbacks for camera events are registered at the camera node map. (This may fail) +
  • If the passed %Pylon device is open, a device removal call back is registered. (This may fail) +
  • If the passed %Pylon device is open, access modifiers (see IPylonDevice::Open()) are carried over as camera parameters. +
  • The OnAttached configuration event is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
+ + \post +
    +
  • If the passed pointer to the %Pylon device is NULL, the Instant Camera object is in the "no device attached" state. +
  • If the passed pointer to the %Pylon device is not NULL, the passed %Pylon device is attached. +
  • If the set cleanup procedure equals Cleanup_Delete, the %Pylon device is destroyed when the Instant Camera object is destroyed or a new device is attached. +
  • If the passed %Pylon device is open and the registration of callbacks fails, the Instant Camera object is in the "no device attached" state. +
  • The opened-by-user flag is set, preventing closing of the %Pylon device on StopGrabbing() when the attached %Pylon device is already open. +
+ + \error + May throw an exception if the passed %Pylon device is open. + Does not throw C++ exceptions if the passed %Pylon device is closed or NULL. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Attach( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ); + + + /*! + \brief Returns the %Pylon device attached state of the Instant Camera object. + + \return True if a %Pylon device is attached. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsPylonDeviceAttached() const; + + + /*! + \brief Returns the connection state of the camera device. + + \attention Due to technical reasons, the IsCameraDeviceRemoved() property may not be updated immediately after the first error caused by a device removal occurs. + + The device removal is only detected while the Instant Camera and therefore the attached %Pylon device are open. + + The attached %Pylon device is not operable anymore if the camera device has been removed from the PC. + After it is made sure that no access to the %Pylon device or any of its node maps is made anymore + the %Pylon device should be destroyed using CInstantCamera::DeviceDestroy(). + The access to the %Pylon device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \return True if the camera device removal from the PC has been detected. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsCameraDeviceRemoved() const; + + + /*! + \brief Returns the ownership of the attached %Pylon device. + + \return True if a %Pylon device is attached and the Instant Camera object has been given the ownership + by passing the cleanup procedure Cleanup_Delete when calling Attach(). + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool HasOwnership() const; + + + /*! + \brief Destroys the attached %Pylon device. + + \attention The node maps, e.g. the camera node map, of the attached %Pylon device must not be accessed anymore while destroying the %Pylon device. + +
    +
  • If no %Pylon device is attached, nothing is done. +
  • If the %Pylon device is open, it is closed by calling Close(). +
  • The configuration event OnDestroy is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
  • The %Pylon device is destroyed even if the cleanup procedure Cleanup_None has been passed when calling Attach() before. +
  • The configuration event OnDestroyed is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
+ + \post No %Pylon device is attached. + + \error + Does not throw C++ exceptions. Possible C++ exceptions are caught and ignored. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void DestroyDevice(); + + + /*! + \brief Detaches an attached %Pylon device. + +
    +
  • If no %Pylon device is attached, nothing is done. +
  • If a grab is in progress, it is stopped by calling StopGrabbing(). +
  • The configuration event OnDetach is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
  • The %Pylon device is detached. +
  • The configuration event OnDetached is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
+ + \return The attached %Pylon device or NULL if nothing has been attached before. + + \post +
    +
  • No %Pylon device is attached. +
  • The ownership of the %Pylon device goes to the caller who is responsible for destroying the %Pylon device. +
+ + \error + Does not throw C++ exceptions. Possible C++ exceptions are caught and ignored. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual IPylonDevice* DetachDevice(); + + + //Control opening and closing of the device----------------------------- + + /*! + \brief Opens the attached %Pylon device. + +
    +
  • Opened by user flag is set, preventing closing of the device on StopGrabbing(). +
  • If the %Pylon device is already open, nothing more is done. +
  • The OnOpen configuration event is fired. The notification of event handlers stops when an event call triggers an exception. +
  • The %Pylon device is opened and a connection to the camera device is established. +
  • The instant camera migration mode setting is applied to the %Pylon device transport layer node map. +
  • A device removal call back is registered at the %Pylon device. +
  • Callbacks for camera events are registered at the camera node map. +
  • The OnOpened configuration event is fired if the %Pylon device has been opened successfully. The notification of event handlers stops when an event call triggers an exception. +
+ + \pre A %Pylon device is attached. + + \post +
    +
  • The %Pylon device is open and a connection to the camera device has been established. +
  • Opened by user flag is set, preventing closing of the %Pylon device on StopGrabbing(). +
+ + \error + The Instant Camera object is still valid after error. + The %Pylon device open may throw. + Configuration event calls may throw. + Callback registrations may throw. + The %Pylon device is closed with Close() if the OnOpened event call triggers an exception. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Open(); + + + /*! + \brief Returns the open state of the attached %Pylon device object. + \note This method still returns true if the camera device has been physically removed from the PC while the attached %Pylon device object is open. + The %Pylon device object will not automatically close itself on device removal. It must be closed by calling CInstantCamera::Close(). + The IsCameraDeviceRemoved() method can be used to check if the connection to the camera device has been lost while the attached %Pylon device object is open. + \error Does not throw C++ exceptions. + \return Returns true if a %Pylon device is attached and it is open. + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsOpen() const; + + + /*! + \brief Closes the attached %Pylon device. + +
    +
  • If no %Pylon device is attached, nothing is done. +
  • If the %Pylon device is already closed, nothing is done. +
  • If a grab is in progress, it is stopped by calling StopGrabbing(). +
  • The configuration event OnClose is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
  • The connection to the camera device is closed and the %Pylon device is closed. +
  • The configuration event OnClosed is fired if the %Pylon device has been closed successfully. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
+ + \post The connection to the camera device is closed and the %Pylon device is closed. + + \error + Does not throw C++ exceptions. Possible C++ exceptions are caught and ignored. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Close(); + + + //Grab ----------------------------------------------------------------- + + /*! + \brief Starts the grabbing of images. + +
    +
  • If a grab loop thread has been used in the last grab session, the grab loop thread context is joined with the caller's context. +
  • If the %Pylon device is not already open, it is opened by calling Open(). +
  • The configuration event OnGrabStart is fired. The notification of event handlers stops when an event call triggers an exception. +
  • Grab-specific parameters of the camera object are locked, e.g. MaxNumBuffers. +
  • If the camera device parameter ChunkModeActive is enabled, the Instant Camera chunk parsing support is initialized. +
  • If the Instant Camera parameter GrabCameraEvents is enabled, the Instant Camera event grabbing support is initialized. +
  • The grabbing is started. +
  • The AcquisitionStart command of the camera device is executed. +
  • The configuration event OnGrabStarted is fired if the grab has been started successfully. The notification of event handlers stops when an event call triggers an exception. +
  • If grabLoopType equals GrabLoop_ProvidedByInstantCamera, an additional grab loop thread is started calling RetrieveResult( GrabLoopThreadTimeout, grabResult) in a loop. +
+ + \param[in] strategy The grab strategy. See Pylon::EGrabStrategy for more information + \param[in] grabLoopType If grabLoopType equals GrabLoop_ProvidedByInstantCamera, an additional grab loop thread is used to run the grab loop. + + \pre +
    +
  • A %Pylon device is attached. +
  • The stream grabber of the %Pylon device is closed. +
  • The grabbing is stopped. +
  • The attached %Pylon device supports grabbing. +
  • Must not be called while holding the lock provided by GetLock() when using the grab loop thread. +
+ + \post +
    +
  • The grabbing is started. +
  • Grab-specific parameters of the camera object are locked, e.g. MaxNumBuffers. +
  • If grabLoopType equals GrabLoop_ProvidedByInstantCamera, an additional grab loop thread is running that calls RetrieveResult( GrabLoopThreadTimeout, grabResult) in a loop. Images are processed by registered image event handlers. +
  • Operating the stream grabber from outside the camera object will result in undefined behavior. +
+ + \error + The Instant Camera object is still valid after error. Open() may throw. Configuration event calls may throw. The grab implementation may throw. + The grabbing is stopped with StopGrabbing() if the OnGrabStarted event call triggers an exception. Throws a C++ exception, if Upcoming Image grab strategy + is used together with USB camera devices. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void StartGrabbing( EGrabStrategy strategy = GrabStrategy_OneByOne, EGrabLoop grabLoopType = GrabLoop_ProvidedByUser ); + + + /*! + \brief Starts the grabbing for a maximum number of images. + + Extends the StartGrabbing(EStrategy, EGrabLoop) by a number of images to grab. If the passed count of images has been reached, StopGrabbing is called + automatically. The images are counted according to the grab strategy. Skipped images are not taken into account. + + The amount of allocated buffers is reduced to maxImages when grabbing fewer images + than according to the value of the \link Pylon::CInstantCamera::MaxNumBuffer \c MaxNumBuffer \endlink parameter + and the grab strategy is GrabStrategy_OneByOne. + + \param[in] maxImages The count of images to grab. This value must be larger than zero. + \param[in] strategy The grab strategy. See Pylon::InstantCamera::EStrategy for more information. + \param[in] grabLoopType If grabLoopType equals GrabLoop_ProvidedByInstantCamera, an additional grab loop thread is used to run the grab loop. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void StartGrabbing( size_t maxImages, EGrabStrategy strategy = GrabStrategy_OneByOne, EGrabLoop grabLoopType = GrabLoop_ProvidedByUser ); + + + /*! + \brief Retrieves a grab result according to the strategy, waits if it is not yet available + +
    +
  • The content of the passed grab result is released. +
  • If no %Pylon device is attached or the grabbing is not started, the method returns immediately "false". +
  • Wait for a grab result if it is not yet available. The access to the camera is not locked during waiting. Camera events are handled. +
  • Only if camera events are used: Incoming camera events are handled. +
  • One grab result is retrieved per call according to the strategy applied. +
  • Only if chunk mode is used: The chunk data parsing is performed. The grab result data is updated using chunk data. +
  • The image event OnImagesSkipped is fired if grab results have been skipped according to the strategy. The notification of event handlers stops when an event call triggers an exception. +
  • The image event OnImageGrabbed is fired if a grab result becomes available. The notification of event handlers stops when an event call triggers an exception. +
  • Stops the grabbing by calling StopGrabbing() if the maximum number of images has been grabbed. +
+ + It needs to be checked whether the grab represented by the grab result has been successful, see CGrabResultData::GrabSucceeded(). + + \param[in] timeoutMs A timeout value in ms for waiting for a grab result, or the INFINITE value. + \param[out] grabResult Receives the grab result. + \param[in] timeoutHandling If timeoutHandling equals TimeoutHandling_ThrowException, a timeout exception is thrown on timeout. + + \return True if the call successfully retrieved a grab result, false otherwise. + + \pre +
    +
  • There is no other thread waiting for a result. This will be the case when the Instant Camera grab loop thread is used. +
+ + \post +
    +
  • If a grab result has been retrieved, one image is removed from the output queue and is returned in the grabResult parameter. +
  • If no grab result has been retrieved, an empty grab result is returned in the grabResult parameter. +
  • If the maximum number of images has been grabbed, the grabbing is stopped. +
  • If camera event handling is enabled and camera events were received, at least one or more camera event messages have been processed. +
+ + \error + The Instant Camera object is still valid after error. The grabbing is stopped if an exception is thrown. + + \threading + This method is synchronized using the lock provided by GetLock() while not waiting. + */ + virtual bool RetrieveResult( unsigned int timeoutMs, CGrabResultPtr& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ); + + + /*! + \brief Stops the grabbing of images. + +
    +
  • Nothing is done if the Instant Camera is not currently grabbing. +
  • The configuration event OnGrabStop is fired. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
  • The AcquisitionStop command of the camera device is executed. +
  • The grabbing is stopped. +
  • All buffer queues of the Instant Camera are cleared. +
  • The OnGrabStopped configuration event is fired if the grab has been stopped successfully. Possible C++ exceptions from event calls are caught and ignored. All event handlers are notified. +
  • If the Instant Camera has been opened by StartGrabbing, it is closed by calling Close(). +
  • Grab-specific parameters of the camera object are unlocked, e.g. MaxNumBuffers. +
+ + \post +
    +
  • The grabbing is stopped. +
  • If the %Pylon device has been opened by StartGrabbing and no other camera object service requires it to be open, it is closed. +
  • Grab specific parameters of the camera object are unlocked, e.g. MaxNumBuffers. +
+ + \error + Does not throw C++ exceptions. Possible C++ exceptions are caught and ignored. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void StopGrabbing(); + + + /*! + \brief Returns state of grabbing. + + The camera object is grabbing after a successful call to StartGrabbing() until StopGrabbing() is called. + + \return Returns true if still grabbing. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsGrabbing() const; + + + /*! + \brief Grabs one image. + + The following code shows a simplified version of what is done (happy path): + + \code + //grab one image + StartGrabbing( 1, GrabStrategy_OneByOne, GrabLoop_ProvidedByUser); + + //grab is stopped automatically due to maxImages = 1 + return RetrieveResult( timeoutMs, grabResult, timeoutHandling) && grabResult->GrabSucceeded(); + \endcode + + GrabOne() can be used to together with the CAcquireSingleFrameConfiguration. + + \note Using GrabOne is more efficient if the %Pylon device is already open, otherwise the %Pylon device is opened and closed for each call. + + \note Grabbing single images using Software Trigger (CSoftwareTriggerConfiguration) is recommended if you want to maximize frame rate. + This is because the overhead per grabbed image is reduced compared to Single Frame Acquisition. + The grabbing can be started using StartGrabbing(). + Images are grabbed using the WaitForFrameTriggerReady(), ExecuteSoftwareTrigger() and RetrieveResult() methods instead of using GrabOne. + The grab can be stopped using StopGrabbing() when done. + + \param[in] timeoutMs A timeout value in ms for waiting for a grab result, or the INFINITE value. + \param[out] grabResult Receives the grab result. + \param[in] timeoutHandling If timeoutHandling equals TimeoutHandling_ThrowException, a timeout exception is thrown on timeout. + + \return Returns true if the call successfully retrieved a grab result and the grab succeeded (CGrabResultData::GrabSucceeded()). + + \pre Must meet the preconditions of start grabbing. + \post Meets the postconditions of stop grabbing. + + \error + The Instant Camera object is still valid after error. See StartGrabbing(), RetrieveResult(), and StopGrabbing() . + In the case of exceptions after StartGrabbing() the grabbing is stopped using StopGrabbing(). + */ + virtual bool GrabOne( unsigned int timeoutMs, CGrabResultPtr& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ); + + + /*! + \brief Deprecated: This method has been deprecated. Use the NumQueuedBuffers parameter instead. + \return The number of buffers that are queued for grabbing. + */ + virtual size_t GetQueuedBufferCount(); + + + /*! + \brief Provides access to a wait object indicating available grab results. + + \return A wait object indicating available grab results. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual const WaitObject& GetGrabResultWaitObject(); + + + /*! + \brief Provides access to a wait object indicating that the grabbing has stopped. + + \return A wait object indicating that the grabbing has stopped. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual const WaitObject& GetGrabStopWaitObject(); + + + /*! + \brief Provides access to a wait object indicating available camera events. + + This wait object is %Pylon device specific and changes when a new %Pylon device is attached to + the camera. + + \return A wait object indicating available camera events. + + \pre +
    +
  • A %Pylon device is attached. +
  • The %Pylon device is open. +
+ + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + + virtual const WaitObject& GetCameraEventWaitObject(); + + + //Event handling-------------------------------------------------------- + + /*! + \brief Adds a configurator to the list of registered configurator objects. + +
    +
  • If mode equals RegistrationMode_ReplaceAll, the list of registered configurators is cleared. +
  • If pointer \c pConfigurator is not NULL, it is appended to the list of configurators. +
+ + \param[in] pConfigurator The receiver of configuration events. + \param[in] mode Indicates how to register the new configurator. + \param[in] cleanupProcedure If cleanupProcedure equals Cleanup_Delete, the passed event handler is deleted when no longer needed. + + \post The configurator is registered and called on configuration events. + + \error + Does not throw C++ exceptions, except when memory allocation fails. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void RegisterConfiguration( CConfigurationEventHandler* pConfigurator, ERegistrationMode mode, ECleanup cleanupProcedure ); + + + /*! + \brief Removes a configurator from the list of registered configurator objects. + + If the configurator is not found, nothing is done. + + \param[in] configurator The registered receiver of configuration events. + + \return True if successful + + \post +
    +
  • The configurator is deregistered. +
  • If the configuration has been registered by passing a pointer and the cleanup procedure is Cleanup_Delete, the event handler is deleted. +
+ + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool DeregisterConfiguration( CConfigurationEventHandler* configurator ); + + + /*! + \brief Adds an image event handler to the list of registered image event handler objects. + +
    +
  • If mode equals RegistrationMode_ReplaceAll, the list of registered image event handlers is cleared. +
  • If pointer \c pImageEventHandler is not NULL, it is appended to the list of image event handlers. +
+ + \param[in] pImageEventHandler The receiver of image events. + \param[in] mode Indicates how to register the new imageEventHandler. + \param[in] cleanupProcedure If cleanupProcedure equals Cleanup_Delete, the passed event handler is deleted when no longer needed. + + \post The imageEventHandler is registered and called on image related events. + + \error + Does not throw C++ exceptions, except when memory allocation fails. + + \threading + This method is synchronized using the internal image event handler registry lock. + */ + virtual void RegisterImageEventHandler( CImageEventHandler* pImageEventHandler, ERegistrationMode mode, ECleanup cleanupProcedure ); + + + /*! + \brief Removes an image event handler from the list of registered image event handler objects. + + If the image event handler is not found, nothing is done. + + \param[in] imageEventHandler The registered receiver of configuration events. + + \return True if successful + + \post +
    +
  • The imageEventHandler is deregistered. +
  • If the image event handler has been registered by passing a pointer and the cleanup procedure is Cleanup_Delete, the event handler is deleted. +
+ + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the internal image event handler registry lock. + */ + virtual bool DeregisterImageEventHandler( CImageEventHandler* imageEventHandler ); + + + /*! + \brief Adds an camera event handler to the list of registered camera event handler objects. + +
    +
  • If mode equals RegistrationMode_ReplaceAll, the list of registered camera event handlers is cleared. +
  • If the pointer \c pCameraEventHandler is not NULL, it is appended to the list of camera event handlers. +
+ + \param[in] pCameraEventHandler The receiver of camera events. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + It is recommended to create an own application specific enum and use it's values as IDs. + \param[in] mode Indicates how to register the new cameraEventHandler. + \param[in] cleanupProcedure If cleanupProcedure equals Cleanup_Delete, the passed event handler is deleted when no longer needed. + \param[in] availability If availability equals CameraEventAvailability_Mandatory, the camera must support the data node specified by node name. + If not, an exception is thrown when the Instant Camera is open, the Instant Camera is opened, or an open %Pylon device is attached. + + Internally, a GenApi node call back is registered for the node identified by \c nodeName. + This callback triggers a call to the \c CCameraEventHandler::OnCameraEvent() method. + That's why a Camera Event Handler can be registered for any node of the camera node map to get informed about changes. + + \post The cameraEventHandler is registered and called on camera events. + + \error + Throws an exception if the availability is set to CameraEventAvailability_Mandatory and the node with the name \c nodeName is not available in the camera node map (see GetNodeMap()). + Throws an exception fail if the node callback registration fails. + The event handler is not registered when an C++ exception is thrown. + + \threading + This method is synchronized using the camera event handler lock. If the camera is open, the lock provided by GetLock() and the camera + node map lock are also used for synchronization. + */ + + virtual void RegisterCameraEventHandler( + CCameraEventHandler* pCameraEventHandler, + const String_t& nodeName, + intptr_t userProvidedId, + ERegistrationMode mode, + ECleanup cleanupProcedure, + ECameraEventAvailability availability = CameraEventAvailability_Mandatory ); + + + /*! + \brief Removes a camera event handler from the list of registered camera event handler objects. + + If the camera event handler is not found, nothing is done. + + \param[in] cameraEventHandler The registered receiver of camera events. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + + \return True if successful + + \post +
    +
  • The cameraEventHandler is deregistered. +
  • If the camera event handler has been registered by passing a pointer and the cleanup procedure is Cleanup_Delete, the event handler is deleted. +
+ + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the camera event handler lock. If the camera is open, the camera node map lock + is also used for synchronization. + */ + virtual bool DeregisterCameraEventHandler( CCameraEventHandler* cameraEventHandler, const String_t& nodeName ); + + + + //Additional features--------------------------------------------------- + + /*! + \brief Actively waits until the the camera is ready to accept a frame trigger. + + The implementation selects 'FrameTriggerWait' for the 'AcquisitionStatusSelector' + and waits until the 'AcquisitionStatus' is true. + If the above mentioned nodes are not available and the 'SoftwareTrigger' node is readable, + the implementation waits for SoftwareTrigger.IsDone(). + + The WaitForFrameTriggerReady method does not work for A600 Firewire cameras. + + \param[in] timeoutMs The timeout in ms for active waiting. + \param[in] timeoutHandling If timeoutHandling equals TimeoutHandling_ThrowException, a timeout exception is thrown on timeout. + \return True if the camera can execute a frame trigger. + + \pre The 'AcquisitionStatusSelector' node is writable and the 'AcquisitionStatus' node is readable or the 'SoftwareTrigger' node is readable. + This depends on the used camera model. + + \error + Accessing the camera registers may fail. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool WaitForFrameTriggerReady( unsigned int timeoutMs, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ); + + + /*! + \brief Checks to see whether the camera device can be queried whether it is ready to accept the next frame trigger. + + If 'FrameTriggerWait' can be selected for 'AcquisitionStatusSelector' and 'AcquisitionStatus' is readable, the + camera device can be queried whether it is ready to accept the next frame trigger. + + If the nodes mentioned above are not available and the 'SoftwareTrigger' node is readable, the + camera device can be queried whether it is ready to accept the next frame trigger. + + \note If a camera device can't be queried whether it is ready to accept the next frame trigger, the camera device is + ready to accept the next trigger after the last image triggered has been grabbed, e.g. after you have retrieved + the last image triggered using RetrieveResult(). Camera devices that can be queried whether they are ready to accept the + next frame trigger, may not be ready for the next frame trigger after the last image triggered has been grabbed. + + \return Returns true if the camera is open and the camera device can be queried whether it is ready to accept the next frame trigger. + + \post The 'AcquisitionStatusSelector' is set to 'FrameTriggerWait' if writable. + + \error + Accessing the camera registers may fail. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool CanWaitForFrameTriggerReady() const; + + + /*! + \brief Executes the software trigger command. + + The camera needs to be configured for software trigger mode. + Additionally, the camera needs to be ready to accept triggers. + When triggering a frame this can be checked using the WaitForFrameTriggerReady() method; + + \note The application has to make sure that the correct trigger is selected + before calling ExecuteSoftwareTrigger(). + This can be done via the camera's TriggerSelector node. + The \c Pylon::CSoftwareTriggerConfiguration + selects the correct trigger when the Instant Camera is opened. + + \pre +
    +
  • The grabbing is started. +
  • The camera device supports software trigger. +
  • The software trigger is available. This depends on the configuration of the camera device. +
+ + \error + Accessing the camera registers may fail. Throws an exception on timeout if \c timeoutHandling is TimeoutHandling_ThrowException. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void ExecuteSoftwareTrigger(); + + + /*! + \brief Sets a context that is attached to each grab result of the camera object on RetrieveResult(). + This is useful when handling multiple cameras. It has nothing in common with the context passed to the stream grabber when queuing a buffer. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void SetCameraContext( intptr_t context ); + + + /*! + \brief Returns the context that is attached to each grab result of the camera object + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual intptr_t GetCameraContext() const; + + + /*! + \brief Provides access to the device info object of the attached %Pylon device or an empty one. + \return The info object of the attached %Pylon device or an empty one. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual const CDeviceInfo& GetDeviceInfo() const; + + + /*! + \brief Provides access to the node map of the camera device. + + The %Pylon device must be opened before reading ore writing any parameters of the camera device. + This can be done using the Open() method of the Instant Camera class. + + \return Reference to the node map of the camera device. + + \pre A %Pylon device is attached. + + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual GENAPI_NAMESPACE::INodeMap& GetNodeMap(); + + + /*! + \brief Provides access to the transport layer node map of the attached %Pylon device. + \return Reference to the transport layer node map of the attached %Pylon device + or the reference to the empty node map if a transport layer node map is not supported. + The GENAPI_NAMESPACE::INodeMap::GetNumNodes() method can be used to check whether the node map is empty. + + \pre A %Pylon device is attached. + + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual GENAPI_NAMESPACE::INodeMap& GetTLNodeMap(); + + + /*! + \brief Provides access to the stream grabber node map of the attached %Pylon device. + \return Reference to the stream grabber node map of the attached %Pylon device + or the reference to the empty node map if grabbing is not supported. + The GENAPI_NAMESPACE::INodeMap::GetNumNodes() method can be used to check whether the node map is empty. + + \pre +
    +
  • A %Pylon device is attached. +
  • The %Pylon device is open. +
+ + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual GENAPI_NAMESPACE::INodeMap& GetStreamGrabberNodeMap(); + + + /*! + \brief Provides access to the event grabber node map of the attached %Pylon device. + \return Reference to the event grabber node map of the attached %Pylon device + or a reference to the empty node map if event grabbing is not supported. + The GENAPI_NAMESPACE::INodeMap::GetNumNodes() method can be used to check whether the node map is empty. + + \pre +
    +
  • A %Pylon device is attached. +
  • The %Pylon device is open. +
+ + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual GENAPI_NAMESPACE::INodeMap& GetEventGrabberNodeMap(); + + + /*! + \brief Provides access to the node map of the Instant Camera object. + + The node map of the camera device is made available by the GetNodeMap() method. + + \return Reference to the node map of the Instant Camera object. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual GENAPI_NAMESPACE::INodeMap& GetInstantCameraNodeMap(); + + + /*! + \brief Sets an alternative buffer factory that is used for buffer allocation. + + This use of this method is optional and intended for advanced use cases only. + + If NULL is passed as buffer factory then the default buffer factory is used. + Buffers are allocated when StartGrabbing is called. + A buffer factory must not be deleted while it is attached to the camera object + and it must not be deleted until the last buffer is freed. To free all buffers + the grab needs to be stopped and all grab results must be released or destroyed. + + \param[in] pFactory A pointer to a buffer factory. + \param[in] cleanupProcedure If ownership is cleanupProcedure Cleanup_Delete, the passed factory is destroyed when no longer needed. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void SetBufferFactory( IBufferFactory* pFactory, ECleanup cleanupProcedure = Cleanup_Delete ); + + + /*! + \brief Returns true if an IEEE 1394 %Pylon device is attached to the Instant Camera object. + + This method is provided for convenience only. The device type can also be determined as shown in the following example. + + \code + #include + ... + if (camera.GetDeviceInfo().GetDeviceClass() == Basler1394DeviceClass) + { + ... + } + \endcode + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool Is1394() const; + + + /*! + \brief Returns true if a GigE %Pylon device is attached to the Instant Camera object. + + This method is provided for convenience only. The device type can also be determined as shown in the following example. + + \code + #include + ... + if (camera.GetDeviceInfo().GetDeviceClass() == BaslerGigEDeviceClass) + { + ... + } + \endcode + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsGigE() const; + + + /*! + \brief Returns true if a USB %Pylon device is attached to the Instant Camera object. + + This method is provided for convenience only. The device type can also be determined as shown in the following example. + + \code + #include + ... + if (camera.GetDeviceInfo().GetDeviceClass() == BaslerUsbDeviceClass) + { + ... + } + \endcode + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsUsb() const; + + + /*! + \brief Returns true if a Camera Link %Pylon device is attached to the Instant Camera object. + + This method is provided for convenience only. The device type can also be determined as shown in the following example. + + \code + #include + ... + if (camera.GetDeviceInfo().GetDeviceClass() == BaslerCameraLinkDeviceClass) + { + ... + } + \endcode + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsCameraLink() const; + + + /*! + \brief Returns true if a CoaXPress GenTL device is attached to the Instant Camera object. + + This method is provided for convenience only. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsCxp() const; + + + /*! + \brief Returns the SFNC version read from the camera node map. + + The SFNC version is read from the camera node map using the integer nodes + DeviceSFNCVersionMajor, DeviceSFNCVersionMinor, and DeviceSFNCVersionSubMinor. + + \return The SFNC version used by the camera device. The returned SFNC version is 0.0.0 (Pylon::Sfnc_VersionUndefined) + if no SFNC version information is provided by the camera device. + + \pre A %Pylon device is attached. + + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + VersionInfo GetSfncVersion() const; + + + //Types used by camera-------------------------------------------------- + + /// The type of the camera class + typedef CInstantCamera InstantCamera_t; + /// \copybrief Pylon::IPylonDevice + typedef IPylonDevice IPylonDevice_t; + /// \copybrief Pylon::CDeviceInfo + typedef Pylon::CDeviceInfo DeviceInfo_t; + /// The generic configuration event handler class + typedef CConfigurationEventHandler ConfigurationEventHandler_t; + /// The generic image event handler class + typedef CImageEventHandler ImageEventHandler_t; + /// The generic image event handler class + typedef CCameraEventHandler CameraEventHandler_t; + /// The generic grab result data + typedef CGrabResultData GrabResultData_t; + /// The generic grab result smart pointer + typedef CGrabResultPtr GrabResultPtr_t; + + protected: + + /*! + \brief Provides access to the attached %Pylon device. + + \return Pointer to the attached %Pylon device. + + \pre A %Pylon device is attached. + + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual IPylonDevice* GetDevice(); + + + /*! + \brief Provides access to the lock used for synchronizing the access to the camera. + + This lock can be used when extending the Instant Camera class. + + Example: + \code + class CMyInstantCamera : public CInstantCamera + { + // Method extending the Instant Camera class + void Foo() + { + // Scoped Lock. + AutoLock lock( CInstantCamera::GetLock()); + + //... + } + }; + \endcode + + \error + Does not throw C++ exceptions. + */ + CLock& GetLock(); + + + /* + \brief Returns a reference to the empty node map. + + The empty node map can be used by device specific camera classes. + The pointer to the empty node map does not change during the lifetime of the camera object. + + \return Reference to the empty node map. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + GENAPI_NAMESPACE::INodeMap& GetEmptyNodeMap(); + + + // Internal use only. Subject to change without notice. + void InternalRegisterConfiguration( CConfigurationEventHandler*, ERegistrationMode, ECleanup, const long* ); + // Internal use only. Subject to change without notice. + void InternalRegisterImageEventHandler( CImageEventHandler*, ERegistrationMode, ECleanup, const long* ); + // Internal use only. Subject to change without notice. + void InternalRegisterCameraEventHandler( CCameraEventHandler*, const String_t&, intptr_t, ERegistrationMode, ECleanup, ECameraEventAvailability, const long* ); + // Internal use only. Subject to change without notice. + bool InternalDeregisterConfiguration( const long* ); + // Internal use only. Subject to change without notice. + bool InternalDeregisterImageEventHandler( const long* ); + // Internal use only. Subject to change without notice. + bool InternalDeregisterCameraEventHandler( const long*, const String_t& ); + // Internal use only. Subject to change without notice. + void InternalShutdownEventHandlers(); + + public: + // Internal use only. Subject to change without notice. + IInstantCameraExtensions& GetExtensionInterface(); + private: + // The camera object can not be copied. + CInstantCamera( const CInstantCamera& ); + // The camera object can not be copied. + void operator = ( const CInstantCamera& ); + + class CInstantCameraImpl; + CInstantCameraImpl* m_pImpl; + + protected: + // Internal use only. Subject to change without notice. + friend class CGrabResultDataFactory; + // Internal use only. Subject to change without notice. + virtual CGrabResultData* CreateDeviceSpecificGrabResultData(); + private: + // Internal use only. Subject to change without notice. + CGrabResultData* CreateGrabResultData(); + public: + /*! + \brief Returns true if a BCON %Pylon device is attached to the Instant Camera object. + + This method is provided for convenience only. The device type can also be determined as shown in the following example. + + \code + #include + ... + if (camera.GetDeviceInfo().GetDeviceClass() == BaslerBconDeviceClass) + { + ... + } + \endcode + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsBcon() const; + }; + + /** + * @} + */ +} +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_INSTANTCAMERA_H_08725703 */ diff --git a/Cigarette/Pylon6.2/include/pylon/InstantCameraArray.h b/Cigarette/Pylon6.2/include/pylon/InstantCameraArray.h new file mode 100644 index 0000000..8cbc68e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/InstantCameraArray.h @@ -0,0 +1,406 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the instant camera array class which supports grabbing with multiple camera devices. +*/ + +#ifndef INCLUDED_INSTANTCAMERAARRAY_H_3108332 +#define INCLUDED_INSTANTCAMERAARRAY_H_3108332 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CInstantCameraArray + \brief Supports grabbing with multiple camera devices. + + \threading + The CInstantCameraArray class is not thread-safe. + */ + + class PYLONBASE_API CInstantCameraArray + { + public: + //Creation and life time------------------------------------------------ + + /*! + \brief Creates an Instant Camera Array of size 0. + + Initialize() can be used to adjust the size of the array. + + \error + Does not throw C++ exceptions. + */ + CInstantCameraArray(); + + /*! + \brief Creates an Instant Camera Array. + + Calls Initialize() to adjust the size of the array. + + \param[in] numberOfCameras The number of cameras the array shall hold. Can be 0. + + The index operator can be used to access the individual cameras + for attaching a %Pylon Device or for configuration. + + Example: + \code + // Create an array of two devices. + CInstantCamera array(2); + // Attach Pylon Devices. + array[0].Attach( pDevice1); + array[1].Attach( pDevice2); + \endcode + + \error + Does not throw C++ exceptions, except when memory allocation fails. + */ + CInstantCameraArray( size_t numberOfCameras ); + + + /*! + \brief Destroys the Instant Camera Array. + + If a grab is in progress, it is stopped by calling StopGrabbing(). + + \error + Does not throw C++ exceptions. + */ + virtual ~CInstantCameraArray(); + + + /*! + \brief Initializes the array. + +
    +
  • If a grab is in progress, it is stopped by calling StopGrabbing(). +
  • All cameras of the array are destroyed. +
  • A new set of cameras is created. No %Pylon Devices are attached. +
  • The camera context values are set to the index of the camera in the array using CInstantCamera::SetCameraContext. +
+ + The index operator can be used to access the individual cameras + for attaching a %Pylon Device or for configuration. + + \param[in] numberOfCameras The number of cameras the array shall hold. + + \error + Does not throw C++ exceptions, except when memory allocation fails. + */ + virtual void Initialize( size_t numberOfCameras ); + + + /*! + \brief Returns the attachment state of cameras in the array. + + \return True if all cameras in the array have a %Pylon Device attached. False is returned if the size of the array is 0. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsPylonDeviceAttached() const; + + + /*! + \brief Returns the connection state of the camera devices used by the Instant Cameras in the array. + + The device removal is only detected if the Instant Cameras and therefore the attached %Pylon Devices are open. + + The %Pylon Device is not operable after this event. + After it is made sure that no access to the %Pylon Device or any of its node maps is made anymore + the %Pylon Device should be destroyed using InstantCamera::DeviceDestroy(). + The access to the %Pylon Device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \return True if the camera device removal from the PC for any camera in the array has been detected. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsCameraDeviceRemoved() const; + + + /*! + \brief Destroys the %Pylon Devices that are attached to the Instant Cameras in the array. + + \attention The node maps, e.g. the camera node map, of the attached %Pylon Device must not be accessed anymore while destroying the %Pylon Device. + +
    +
  • If a grab is in progress, it is stopped by calling StopGrabbing(). +
  • DestroyDevice is called for all cameras. See CInstantCamera::DestroyDevice() for more information. +
+ + \post + No %Pylon Devices are attached to the cameras in the array. + + \error + Does not throw C++ exceptions. + */ + virtual void DestroyDevice(); + + + /*! + \brief Detaches all %Pylon Devices that are attached to the Instant Cameras in the array. + +
    +
  • If a grab is in progress, it is stopped by calling StopGrabbing(). +
  • DetachDevice is called for all cameras, see CInstantCamera::DetachDevice() for more information. +
+ + \post +
    +
  • No %Pylon Devices are attached to the cameras in the array. +
  • The ownership of the %Pylon Devices goes to the caller who is responsible for destroying the %Pylon Devices. +
+ + \error + Does not throw C++ exceptions. + */ + virtual void DetachDevice(); + + + //Control opening and closing of the device----------------------------- + + /*! + \brief Opens all cameras in the array. + + Open is called for all cameras. See CInstantCamera::Open() for more information. + + \pre +
    +
  • The size of the array is larger than 0. +
  • All devices are attached. +
+ + \post + The cameras are open. + + \error + If one camera throws an exception, all cameras are closed by calling Close(). + */ + virtual void Open(); + + + /*! + \brief Returns the open state of the cameras in the array. + \error Does not throw C++ exceptions. + \return Returns true if all cameras in the array are open. False is returned if the size of the array is 0. + */ + virtual bool IsOpen() const; + + + /*! + \brief Closes all cameras in the array. + +
    +
  • If a grab is in progress, it is stopped by calling StopGrabbing(). +
  • Close is called for all cameras, see CInstantCamera::Close() for more information. +
+ + \post + All cameras in the array are closed. + + \error + Does not throw C++ exceptions. + */ + virtual void Close(); + + + /*! + \brief Returns the size of the array. + + \error + Does not throw C++ exceptions. + */ + virtual size_t GetSize() const; + + + /*! + \brief Retrieve a camera by index + + \pre + The index is smaller than GetSize(); + + \error + Throws an exception if the index is not valid. + */ + virtual CInstantCamera& operator[]( size_t index ); + + + /*! + \brief Retrieve a camera by index + + \pre + The index is smaller than GetSize(); + + \error + Throws an exception if the index is not valid. + */ + virtual const CInstantCamera& operator[]( size_t index ) const; + + //Grab ----------------------------------------------------------------- + + /*! + \brief Starts the grabbing of images for all cameras. + +
    +
  • StartGrabbing is called for all cameras with the provided parameters, see CInstantCamera::StartGrabbing() for more information. +
  • The grabbing is started. +
  • The starting position for retrieving results is set to the first camera. +
+ + \param[in] strategy The grab strategy, see Pylon::InstantCamera::EStrategy for more information. + \param[in] grabLoopType Indicates using the internal grab thread of the camera. + + \pre +
    +
  • The size of the array is larger than 0. +
  • All devices are attached. +
  • The grabbing is stopped. +
  • The preconditions for calling StartGrabbing() are met for every camera in the array. +
+ + \post + The grabbing is started. + + \error + The camera objects may throw an exception. The grabbing is stopped calling StopGrabbing() in this case. + */ + virtual void StartGrabbing( EGrabStrategy strategy = GrabStrategy_OneByOne, EGrabLoop grabLoopType = GrabLoop_ProvidedByUser ); + + + /*! + \brief Retrieves a grab result according to the strategy, waits if it is not yet available + +
    +
  • The content of the passed grab result is released. +
  • If the grabbing is not started, the method returns immediately false. +
  • If GrabStrategy_UpcomingImage strategy: RetrieveResult is called for a camera. Cameras are processed using a round-robin strategy. +
  • If GrabStrategy_OneByOne, GrabStrategy_LatestImageOnly or GrabStrategy_LatestImages strategy: Pending images or camera events are retrieved. Cameras are processed using a round-robin strategy. +
  • If GrabStrategy_OneByOne, GrabStrategy_LatestImageOnly or GrabStrategy_LatestImages strategy: Wait for a grab result if it is not yet available. Camera events are handled. +
+ + The camera array index is assigned to the context value of the instant camera when Initialize() is called. + This context value is attached to the result when the result is retrieved and can be obtained using the grab result method GrabResultData::GetCameraContext(). + The context value can be used to associate the result with the camera from where it originated. + + \param[in] timeoutMs A timeout value in ms for waiting for a grab result, or the INFINITE value. + \param[out] grabResult Receives the grab result. + \param[in] timeoutHandling If timeoutHandling equals TimeoutHandling_ThrowException, a timeout exception is thrown on timeout. + + \return True if the call successfully retrieved a grab result, false otherwise. + + \pre + The preconditions for calling StartGrabbing() are met for every camera in the array. + + \post +
    +
  • If successful, one image is removed from the output queue of a camera and is returned in the grabResult parameter. +
  • If not successful, an empty grab result is returned in the grabResult parameter. +
+ + \error + The Instant Camera Array object is still valid after error. The grabbing is stopped by calling StopGrabbing() if an exception is thrown. + */ + virtual bool RetrieveResult( unsigned int timeoutMs, CGrabResultPtr& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ); + + + /*! + \brief Stops the grabbing of images. + + The grabbing is stopped. + StopGrabbing is called for all cameras. See CInstantCamera::StopGrabbing() for more information. + + \post + The grabbing is stopped. + + \error + Does not throw C++ exceptions. + + \threading + Can be called while one other thread is polling RetrieveResult() in a IsGrabbing()/RetrieveResult() loop + to stop grabbing. + */ + virtual void StopGrabbing(); + + + /*! + \brief Returns state of grabbing. + + The camera array is grabbing after a successful call to StartGrabbing() until StopGrabbing() has been called. + + \return Returns true if still grabbing. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsGrabbing() const; + + public: + /// The type of the camera class in the array. + typedef CInstantCamera InstantCamera_t; + + protected: + //Functionality that can be provided by specializing class-------------- + + /* + \brief Creates an instance of an instant camera class. + + The method is called from Initialize() method. + + \return Returns pointer to the created class. + + \error + Does not throw C++ exceptions, except when memory allocation fails. + */ + virtual CInstantCamera* CreateInstantCamera(); + + + /* + \brief Destroys an instance of an instant camera class. + + The method is called from Initialize() method. + Cameras are destroyed in the reverse order they are created. + + \param[in] pCamera Camera instance to destroy. + + \error + Does not throw C++ exceptions. + */ + virtual void DestroyInstantCamera( CInstantCamera* pCamera ); + + private: + // The camera array object can not be copied. + CInstantCameraArray( const CInstantCameraArray& ); + // The camera array object can not be copied. + void operator = ( const CInstantCameraArray& ); + + class CInstantCameraArrayImpl; + CInstantCameraArrayImpl* m_pImpl; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_INSTANTCAMERAARRAY_H_3108332 */ diff --git a/Cigarette/Pylon6.2/include/pylon/InstantInterface.h b/Cigarette/Pylon6.2/include/pylon/InstantInterface.h new file mode 100644 index 0000000..14ecd94 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/InstantInterface.h @@ -0,0 +1,331 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +// Author: DV +//------------------------------------------------------------------------------ + +#pragma once + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include +#include +#include + + +namespace Pylon +{ + /*! + \class CInstantInterface + \brief Provides convenient access to an interface. An interface is used to represent a frame grabber board, a network card, etc. + +
    +
  • Establishes a single access point for accessing interface functionality. +
  • Handles %Pylon interface lifetime. +
  • Handles opening and closing of a %Pylon interface automatically. +
+ + \note Currently, this object type is mainly used for the pylon GenTL Consumer Transport Layer, e.g., for CoaXPress. + All other pylon transport layers currently return one default interface. + */ + template + class CInstantInterface : public T, public IInterface + { + public: + /*! + \brief Constructor. Creates a CInstantInterface object from a CDeviceInfo or CInterfaceInfo object. + + The following steps are taken: +
    +
  • The DeviceClass property is used to create the transport layer. +
  • If the DeviceClass property is not available, the TlType property is used to create the first matching transport layer. +
  • If the DeviceClass and TlType properties are not be available, an error will be thrown. +
  • If the provided argument is of CInterfaceInfo type, this is used to create the interface. +
  • If the provided argument is of CDeviceInfo type, use the InterfaceID property to create the interface. +
  • If the above steps fail, the first interface is created. +
+ + \error + May throw an exception if the passed argument cannot be used to create an interface object. + */ + CInstantInterface( const Pylon::CInfoBase& info ) : T() + , m_pTransportLayer( NULL ) + , m_pInterface( NULL ) + { + if (info.IsDeviceClassAvailable()) + { + // find transport layer by DeviceClass + CTlFactory& theFactory = CTlFactory::GetInstance(); + m_pTransportLayer = theFactory.CreateTl( info.GetDeviceClass() ); + } + else if (info.IsTLTypeAvailable()) + { + // find transport layer by TlType (choose first) + TlInfoList_t tlList; + CTlFactory& theFactory = Pylon::CTlFactory::GetInstance(); + theFactory.EnumerateTls( tlList ); + for (TlInfoList_t::const_iterator it = tlList.begin(); it != tlList.end(); ++it) + { + const CTlInfo& tinfo = *it; + if (tinfo.GetTLType() == info.GetTLType()) + { + m_pTransportLayer = theFactory.CreateTl( tinfo.GetDeviceClass() ); + break; + } + } + } + else + { + throw RUNTIME_EXCEPTION( "Not enough information to create the desired transport layer." ); + } + + if (m_pTransportLayer == NULL) + { + throw RUNTIME_EXCEPTION( "Cannot create transport layer." ); + } + + const CInterfaceInfo* pInterfaceInfo = dynamic_cast(&info); + const CDeviceInfo* pDeviceInfo = dynamic_cast(&info); + if (pInterfaceInfo != NULL) + { + // parameter might be CInterfaceInfo + m_pInterface = m_pTransportLayer->CreateInterface( *pInterfaceInfo ); + } + else if ((pDeviceInfo != NULL) && (pDeviceInfo->IsInterfaceIDAvailable())) + { + // parameter might be CDeviceInfo + CInterfaceInfo ii; + ii.SetDeviceClass( info.GetDeviceClass() ); + ii.SetInterfaceID( pDeviceInfo->GetInterfaceID() ); + m_pInterface = m_pTransportLayer->CreateInterface( ii ); + } + else + { + // open first interface + InterfaceInfoList infoList; + m_pTransportLayer->EnumerateInterfaces( infoList ); + m_pInterface = m_pTransportLayer->CreateInterface( infoList.at( 0 ) ); + } + + if (m_pInterface == NULL) + { + throw RUNTIME_EXCEPTION( "Cannot create interface." ); + } + } + + /*! + \brief Destructor. All created objects are destroyed correctly. + */ + ~CInstantInterface() + { + if (m_pInterface != NULL) + { + if (IsOpen()) + { + Close(); + } + + m_pTransportLayer->DestroyInterface( m_pInterface ); + } + + if (m_pTransportLayer != NULL) + { + CTlFactory& theFactory = CTlFactory::GetInstance(); + theFactory.ReleaseTl( m_pTransportLayer ); + } + } + + // IInterface + + /*! + \brief Opens the attached %Pylon interface. + + This call is neccessary to work with all parameters. + + \post +
    +
  • The interface is opened. +
  • The nodemap and parameters are available and accessable. +
+ + \error + May throw C++ exceptions. + */ + virtual void Open() + { + m_pInterface->Open(); + this->_Initialize( m_pInterface->GetNodeMap() ); + } + + /*! + \brief Checks if the interface is open. + + \note The 'open' status of an interface instance won't change even if an attached camera is used, e.g., opened or closed. + + \return Returns true if the interface is open. + + \error + May throw C++ exceptions. + */ + virtual bool IsOpen() const + { + bool isOpen = false; + if (m_pInterface != NULL) + { + isOpen = m_pInterface->IsOpen(); + } + return isOpen; + } + + /*! + \brief Closes an interface. + + \post +
    +
  • The interface is closed. +
  • Any previously acquired objects and references have been deleted and must not be used any longer. +
+ + \error + May throw C++ exceptions. + */ + virtual void Close() + { + if (m_pInterface != NULL) + { + m_pInterface->Close(); + } + this->_Initialize( NULL ); + } + + /*! + \brief Returns the interface info object storing information like the Interface ID property. + + This information is available at all times regardless of whether the interface is open or closed. + + \return A reference to the interface info object. + + \error + May throw C++ exceptions. + */ + virtual const CInterfaceInfo& GetInterfaceInfo() const + { + return m_pInterface->GetInterfaceInfo(); + } + + /*! + \brief Returns the GenApi node map used for accessing parameters provided by the interface. + + \note The default interface object does not provide a node map. + + \note Interfaces will only provide a nodemap after calling Open(). + + \return Returns the GenApi node map used for accessing parameters provided by the interface. + If no parameters are available, NULL is returned. + + \error + May throw C++ exceptions. + */ + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() + { + return m_pInterface->GetNodeMap(); + } + + // IDeviceFactory + + /// @copydoc IDeviceFactory::EnumerateDevices(DeviceInfoList_t&,bool) + /// \error + /// May throw C++ exceptions. + virtual int EnumerateDevices( DeviceInfoList_t& list, bool addToList = false ) + { + return m_pInterface->EnumerateDevices( list, addToList ); + } + + /// @copydoc IDeviceFactory::EnumerateDevices(DeviceInfoList_t&,const DeviceInfoList_t&,bool) + /// \error + /// May throw C++ exceptions. + virtual int EnumerateDevices( DeviceInfoList_t& list, const DeviceInfoList_t& filter, bool addToList = false ) + { + return m_pInterface->EnumerateDevices( list, filter, addToList ); + } + + /// @copydoc IDeviceFactory::CreateDevice(const CDeviceInfo&) + /// \error + /// May throw C++ exceptions. + virtual IPylonDevice* CreateDevice( const CDeviceInfo& di ) + { + return m_pInterface->CreateDevice( di ); + } + + /// @copydoc IDeviceFactory::CreateFirstDevice(const CDeviceInfo&) + /// \error + /// May throw C++ exceptions. + virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di = CDeviceInfo() ) + { + return m_pInterface->CreateFirstDevice( di ); + } + + /// @copydoc IDeviceFactory::CreateDevice(const CDeviceInfo&,const StringList_t&) + /// \error + /// May throw C++ exceptions. + virtual IPylonDevice* CreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ) + { + return m_pInterface->CreateDevice( di, InjectedXmlStrings ); + } + + /// @copydoc IDeviceFactory::CreateFirstDevice(const CDeviceInfo&,const StringList_t&) + /// \error + /// May throw C++ exceptions. + virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ) + { + return m_pInterface->CreateFirstDevice( di, InjectedXmlStrings ); + } + + /// @copydoc IDeviceFactory::CreateDevice(const String_t&) + /// \error + /// May throw C++ exceptions. + virtual IPylonDevice* CreateDevice( const String_t& s ) + { + return m_pInterface->CreateDevice( s ); + } + + /// @copydoc IDeviceFactory::DestroyDevice(IPylonDevice*) + /// \error + /// May throw C++ exceptions. + virtual void DestroyDevice( IPylonDevice* pDevice ) + { + return m_pInterface->DestroyDevice( pDevice ); + } + + /// @copydoc IDeviceFactory::IsDeviceAccessible(const CDeviceInfo&,AccessModeSet,EDeviceAccessiblityInfo*) + /// \error + /// May throw C++ exceptions. + virtual bool IsDeviceAccessible( const CDeviceInfo& deviceInfo, AccessModeSet mode = Control, EDeviceAccessiblityInfo* pAccessibilityInfo = NULL ) + { + return m_pInterface->IsDeviceAccessible( deviceInfo, mode, pAccessibilityInfo ); + } + + private: + // Do not use + CInstantInterface(); + + ITransportLayer* m_pTransportLayer; + IInterface* m_pInterface; + }; + + typedef CInstantInterface CUniversalInstantInterface; + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ diff --git a/Cigarette/Pylon6.2/include/pylon/IntegerParameter.h b/Cigarette/Pylon6.2/include/pylon/IntegerParameter.h new file mode 100644 index 0000000..956f0b3 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/IntegerParameter.h @@ -0,0 +1,515 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CIntegerParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CINTEGERPARAMETER_H +#define INCLUDED_BASLER_PYLON_CINTEGERPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /// Lists possible integer value corrections. + enum EIntegerValueCorrection + { + /// No correction is applied. If the value isn't valid for the parameter, an exception is thrown. + IntegerValueCorrection_None = 0, + /// The value is corrected by rounding up to the nearest valid value. + /// If the value is lower/higher than the minimum/maximum in the range of valid values, the value is corrected to the minimum/maximum. + IntegerValueCorrection_Up = 1, + /// The value is corrected by rounding down to the nearest valid value. + /// If the value is lower/higher than the minimum/maximum in the range of valid values, the value is corrected to the minimum/maximum. + IntegerValueCorrection_Down = 2, + /// The value is corrected by rounding up or down to the nearest valid value. + /// If the correction in each direction is equal, the value is corrected by rounding up to the nearest valid value. + /// If the value is lower/higher than the minimum/maximum in the range of valid values, the value is corrected to the minimum/maximum. + IntegerValueCorrection_Nearest = 3 + }; + + + /*! + \brief Extends the GenApi::IInteger interface with convenience methods. + */ + interface IIntegerEx : virtual public GENAPI_NAMESPACE::IInteger, virtual public IValueEx + { + using GENAPI_NAMESPACE::IInteger::operator=; + + using GENAPI_NAMESPACE::IInteger::SetValue; + + /*! + \brief Sets the value of the parameter if the parameter is writable. + \brief The value must be in the valid range and the increment must be correct. + \return Returns false if the parameter is not writable. + \param[in] value The value to set. + \pre +
    +
  • The passed value must be >= GenApi::IInteger::GetMin(). +
  • The passed value must be <= GenApi::IInteger::GetMax(). +
  • The passed value must be aligned to the increment returned by GenApi::IInteger::GetInc(). +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual bool TrySetValue( int64_t value ) = 0; + + + /*! + \brief Gets the value of the parameter if the parameter is readable. + \brief Otherwise returns the default value. + \return Returns the parameter value if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exception if reading the value fails. + */ + virtual int64_t GetValueOrDefault( int64_t defaultValue ) = 0; + + + /*! + \brief Sets the value of the parameter if the parameter is writable and readable. + \brief The value is automatically corrected if needed. + \return Returns false if the parameter is not readable or not writable. + \param[in] value The value to set. + \param[in] correction The correction method. + \note Calls TrySetValue(GenApi::IInteger*, int64_t) if \c correction equals IntegerValueCorrection_None. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual bool TrySetValue( int64_t value, EIntegerValueCorrection correction ) = 0; + + + /*! + \brief Sets the value of the parameter. The value is automatically corrected if needed. + \param[in] value The value to set. + \param[in] correction The correction method. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \note Calls GenApi::IInteger::SetValue(int64_t) if \c correction equals IntegerValueCorrection_None. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual void SetValue( int64_t value, EIntegerValueCorrection correction ) = 0; + + + /*! + \brief Gets the value of the parameter in percent of its value range (from minimum to maximum). + \return Returns the parameter value in percent of its value range. Returns 100 if minimum equals maximum. + \pre The parameter must be readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual double GetValuePercentOfRange() = 0; + + + /*! + \brief Sets the value of the parameter to a value within its range, using this formula (simplified): ((max - min) * (percentOfRange / 100.0)) + min. + \brief The value is always corrected to the nearest valid value. + \param[in] percentOfRange The percentage of the range to be used in the calculation. + The parameter must be writable. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual void SetValuePercentOfRange( double percentOfRange ) = 0; + + + /*! + \brief If the parameter is writable and readable, sets the value of the parameter to a value within its range, using this formula (simplified): ((max - min) * (percentOfRange / 100.0)) + min. + \brief The value is always corrected to the nearest valid value. + \return Returns true if the a value has been set. + \param[in] percentOfRange The percentage of the range to be used in the calculation. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if writing the value fails. + */ + virtual bool TrySetValuePercentOfRange( double percentOfRange ) = 0; + + + /*! + \brief Sets the value of the parameter to the maximum possible value. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, not readable, or if reading or writing fails. + */ + virtual void SetToMaximum() = 0; + + + /*! + \brief Sets the value of the parameter to the minimum possible value. + \pre +
    +
  • The parameter must be writable. +
  • The parameter must be readable. +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the parameter is not writable, not readable, or if reading or writing fails. + */ + virtual void SetToMinimum() = 0; + + + /*! + \brief Sets the value of the parameter to the maximum possible value if the parameter is readable and writable. + \return Returns true if the maximum value has been set. + + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading or writing fails. + */ + virtual bool TrySetToMaximum() = 0; + + + /*! + \brief Sets the value of the parameter to the minimum possible value if the parameter is readable and writable. + \return Returns true if the minimum value has been set. + + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading or writing fails. + */ + virtual bool TrySetToMinimum() = 0; + }; + + + /*! + \brief CIntegerParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CIntegerParameter : public IIntegerEx, public CParameter + { + public: + /*! + \brief Creates an empty CIntegerParameter object. + \error + Does not throw C++ exceptions. + */ + CIntegerParameter(); + + + /*! + \brief Creates a CIntegerParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CIntegerParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CIntegerParameter object and attaches it to a node of a matching type. + \param[in] pInteger The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pInteger has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CIntegerParameter( GENAPI_NAMESPACE::IInteger* pInteger ); + + + /*! + \brief Creates a CIntegerParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CIntegerParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CIntegerParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CIntegerParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CIntegerParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CIntegerParameter( const CIntegerParameter& rhs ); + + + /*! + \brief Destroys the CIntegerParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CIntegerParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pInteger The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IInteger* pInteger ); + + + /*! + \brief Assigns a CIntegerParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CIntegerParameter& operator=( const CIntegerParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CIntegerParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pInteger The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IInteger* pInteger ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::IInteger + virtual void SetValue( int64_t value, bool verify = true ); + + // Implements GenApi::IInteger + virtual GENAPI_NAMESPACE::IInteger& operator=( int64_t value ); + + // Implements GenApi::IInteger + virtual int64_t GetValue( bool verify = false, bool ignoreCache = false ); + + // Implements GenApi::IInteger + virtual int64_t operator()(); + + // Implements GenApi::IInteger + virtual int64_t operator*(); + + // Implements GenApi::IInteger + virtual int64_t GetMin(); + + // Implements GenApi::IInteger + virtual int64_t GetMax(); + + // Implements GenApi::IInteger + virtual GENAPI_NAMESPACE::EIncMode GetIncMode(); + + // Implements GenApi::IInteger + virtual int64_t GetInc(); + + // Implements GenApi::IInteger + virtual GENAPI_NAMESPACE::int64_autovector_t GetListOfValidValues( bool bounded = true ); + + // Implements GenApi::IInteger + virtual GENAPI_NAMESPACE::ERepresentation GetRepresentation(); + + // Implements GenApi::IInteger + virtual GENICAM_NAMESPACE::gcstring GetUnit(); + + // Implements GenApi::IInteger + virtual void ImposeMin( int64_t value ); + + // Implements GenApi::IInteger + virtual void ImposeMax( int64_t value ); + + + // Implements IIntegerEx + virtual bool TrySetValue( int64_t value ); + + // Implements IIntegerEx + virtual int64_t GetValueOrDefault( int64_t defaultValue ); + + // Implements IIntegerEx + virtual bool TrySetValue( int64_t value, EIntegerValueCorrection correction ); + + // Implements IIntegerEx + virtual void SetValue( int64_t value, EIntegerValueCorrection correction ); + + // Implements IIntegerEx + virtual double GetValuePercentOfRange(); + + // Implements IIntegerEx + virtual void SetValuePercentOfRange( double percentOfRange ); + + // Implements IIntegerEx + virtual bool TrySetValuePercentOfRange( double percentOfRange ); + + // Implements IIntegerEx + virtual void SetToMaximum(); + + // Implements IIntegerEx + virtual void SetToMinimum(); + + // Implements IIntegerEx + virtual bool TrySetToMaximum(); + + // Implements IIntegerEx + virtual bool TrySetToMinimum(); + + protected: + GENAPI_NAMESPACE::IInteger* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CINTEGERPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/Interface.h b/Cigarette/Pylon6.2/include/pylon/Interface.h new file mode 100644 index 0000000..adce4db --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Interface.h @@ -0,0 +1,145 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +// Author: DV +//----------------------------------------------------------------------------- +/*! +\file +\brief Definiton of Interface interface +*/ + +#ifndef PYLON_INTERFACE_H__ +#define PYLON_INTERFACE_H__ + +#pragma once + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include + + +namespace Pylon +{ + /*! + \ingroup Pylon_TransportLayer + \interface IInterface + \brief An interface is used to represent a frame grabber board, a network card, etc. + + Currently, this object type is mainly used for the pylon GenTL Consumer Transport Layer, e.g., for CoaXPress. + All other pylon transport layers currently return one default interface. + + The 'open' status of an interface instance won't change even if an attached camera is used, e.g., opened or closed. + */ + interface PUBLIC_INTERFACE IInterface : public IDeviceFactory + { + /*! + \brief Opens an interface to be able access it's parameters via GetNodeMap(). + + \note You can use the methods provided by IDeviceFactory regardless of whether the interface is opened or closed. + + \post +
    +
  • The interface is open. +
  • The node map can be accessed via GetNodeMap(). +
+ + + \threading + This method is thread-safe. + + \error + Throws a C++ exception if opening the interface fails. + */ + virtual void Open() = 0; + + + /*! + \brief Closes an interface. + + \threading + This method is thread-safe. + + \post +
    +
  • The interface is closed. +
  • Any previously acquired node map using GetNodeMap() has been deleted and must not be used any longer. +
+ + \error + Does not throw C++ exceptions. + */ + virtual void Close() = 0; + + + /*! + \brief Checks if the interface is open. + + \note The 'open' status of an interface instance won't change even if an attached camera is used, e.g., opened or closed. + + \return Returns true if when the interface is open. + + \threading + This method is thread-safe. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsOpen() const = 0; + + + /*! \brief Returns the interface info object storing information like the Interface ID property. + + This information is available at all times regardless of whether the interface is open or closed. + + \return A reference to the interface info object. + + \threading + This method is thread-safe. + + \error + Does not throw C++ exceptions. + */ + virtual const CInterfaceInfo& GetInterfaceInfo() const = 0; + + + /*! + \brief Returns the GenApi node map used for accessing parameters provided by the interface. + + \note The default interface object does not provide a node map. + + \return Returns the GenApi node map used for accessing parameters provided by the interface. + If no parameters are available, NULL is returned. + + \threading + This method is thread-safe. + + \error + Can throw C++ exceptions. + */ + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() = 0; + + protected: + virtual ~IInterface() = 0; + }; + + // Note: the C++ standard >= 11 prohibit pure virtual destructors with a function body + // in the declaration. Consequently gcc 4.0 and newer reject an inline implementation + // in the class. + inline IInterface::~IInterface() + { + } +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* PYLON_INTERFACE_H__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/InterfaceInfo.h b/Cigarette/Pylon6.2/include/pylon/InterfaceInfo.h new file mode 100644 index 0000000..14e9232 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/InterfaceInfo.h @@ -0,0 +1,58 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Declaration of the interface information class. +*/ + +#ifndef __INTERFACE_INFO_H__ +#define __INTERFACE_INFO_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include +#include + +namespace Pylon +{ + + /** + \ingroup PYLON_PUBLIC + + \brief Class used for storing information about an interface object provided by a transport layer. + + Enumerating the available Transport Layer Interface objects returns a list of + CInterface objects (Pylon::InterfaceInfoList_t). A CInterfaceInfo object holds information + about the enumerated interface. + */ + class PYLONBASE_API CInterfaceInfo : public CInfoBase + { + public: + /*! + \brief Compares CInterfaceInfo objects by device class and interface ID. + \param[in] rhs The right-hand side object of the comparison. + \return Returns true according to this rule: USB < GigE < CameraLink < 1394 < Bcon < Less than compare of device class text < CamEmu. + CInterfaceInfo objects of the same transport layer are compared by interface ID using less than text comparison. + \error + Does not throw C++ exceptions. + */ + bool operator<( const CInterfaceInfo& rhs ) const; + + ///Retrieves the interface ID identifying the interface. + ///This property is identified by Key::InterfaceIDKey. + String_t GetInterfaceID() const; + ///Sets the above property. + CInterfaceInfo& SetInterfaceID( const String_t& InterfaceIDValue ); + ///Returns true if the above property is available. + bool IsInterfaceIDAvailable() const; + }; + +} + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/NodeMapProxy.h b/Cigarette/Pylon6.2/include/pylon/NodeMapProxy.h new file mode 100644 index 0000000..72fa5c1 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/NodeMapProxy.h @@ -0,0 +1,227 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Pylon generic node map interface declaration + +\ingroup PYLON_INTERNAL +*/ + + +#ifndef __PYLON_NODEMAPROXY__H__ +#define __PYLON_NODEMAPROXY__H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +//! Macro to define a custom Node map proxy +#define PYLON_DEFINE_NODEMAP(ClassName, BaseClass) \ + class ClassName : public BaseClass \ + { \ + public: \ + /** \name Construction */ \ + /*@{*/ \ + /** \brief \copybrief Pylon::CNodeMapProxyT::CNodeMapProxyT() + \copydetails Pylon::CNodeMapProxyT::CNodeMapProxyT() + */ \ + ClassName() \ + { \ + } \ + /** \brief \copybrief Pylon::CNodeMapProxyT::CNodeMapProxyT(GenApi::INodeMap*) + \copydetails Pylon::CNodeMapProxyT::CNodeMapProxyT(GenApi::INodeMap*) + */ \ + ClassName( GENAPI_NAMESPACE::INodeMap* pNodeMap ) : BaseClass( pNodeMap ) \ + { \ + } \ + /*@}*/ \ + }; + + + namespace Pylon + { + //************************************************************************************************** + //! Implementation Detail: This class wraps programming interfaces that are generated from %GenICam parameter description files to provide native parameter access. + /** + \see \ref configuringcameras + + \tparam TParams The specific parameter class (auto generated from the parameter xml file) + \ingroup PYLON_INTERNAL + */ + //************************************************************************************************** + template + class CNodeMapProxyT : public TParams + { + public: + //! \name Construction + // \{ + + //! Creates a CNodeMapProxyT object that is not attached to a node map. Use the Attach() method to attach the pylon node map. + CNodeMapProxyT(); + + //! Creates a CNodeMapProxyT object and attaches it to a pylon node map. + CNodeMapProxyT( GENAPI_NAMESPACE::INodeMap* ); + + //! Destructor + virtual ~CNodeMapProxyT(); + + //\} + + + private: + //! \name Assignment and copying is not supported + // \{ + CNodeMapProxyT( const CNodeMapProxyT& ); + CNodeMapProxyT& operator=( const CNodeMapProxyT& ); + // \} + + + public: + //! \name Some smart pointer functionality + // \{ + + //! Attach a pylon node map + virtual void Attach( GENAPI_NAMESPACE::INodeMap*, bool replace = false ); + + //! Checks if a pylon node map is attached + virtual bool IsAttached() const; + + //! Returns the pylon node map interface pointer + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() const; + + // \} + + + public: + //! \name Partial implementation of the INodeMap interface + //! See GENAPI_NAMESPACE::INodeMap for more details + // \{ + /** \brief \copybrief GenApi::INodeMap::GetNodes() + + \copydetails GenApi::INodeMap::GetNodes() + */ + void GetNodes( GENAPI_NAMESPACE::NodeList_t& Nodes ) const + { + CheckNodeMapPtr(); + return m_pNodeMap->GetNodes( Nodes ); + } + + /** \brief \copybrief GenApi::INodeMap::GetNode() + + \copydetails GenApi::INodeMap::GetNode() + */ + GENAPI_NAMESPACE::INode* GetNode( const GENICAM_NAMESPACE::gcstring& Name ) const + { + CheckNodeMapPtr(); + return m_pNodeMap->GetNode( Name ); + } + + /** \brief \copybrief GenApi::INodeMap::InvalidateNodes() + + \copydetails GenApi::INodeMap::InvalidateNodes() + */ + void InvalidateNodes() const + { + CheckNodeMapPtr(); + m_pNodeMap->InvalidateNodes(); + } + + /** \brief \copybrief GenApi::INodeMap::Poll() + + \copydetails GenApi::INodeMap::Poll() + */ + void Poll( int64_t ElapsedTime ) + { + CheckNodeMapPtr(); + m_pNodeMap->Poll( ElapsedTime ); + } + + // \} + + + protected: + void CheckNodeMapPtr() const + { + if (NULL == m_pNodeMap) + { + throw LOGICAL_ERROR_EXCEPTION( "The object is not attached to a NodeMap" ); + } + } + + GENAPI_NAMESPACE::INodeMap* m_pNodeMap; + }; + + + //************************************************************************************************** + // CPylonDeviceProxyT implementation + //************************************************************************************************** + + + template + inline CNodeMapProxyT::CNodeMapProxyT() + : m_pNodeMap( NULL ) + { + } + + template + inline CNodeMapProxyT::CNodeMapProxyT( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + : m_pNodeMap( NULL ) + { + Attach( pNodeMap ); + } + + template + inline CNodeMapProxyT::~CNodeMapProxyT( void ) + { + } + + template + inline void CNodeMapProxyT::Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, bool replace ) + { + if (IsAttached() && !replace) + { + throw LOGICAL_ERROR_EXCEPTION( "Object is already attached to a node map" ); + } + + if (NULL == pNodeMap) + { + throw LOGICAL_ERROR_EXCEPTION( "Tried to attach a NULL pointer as node map" ); + } + + TParams::_Initialize( pNodeMap ); + m_pNodeMap = pNodeMap; + } + + template + inline bool CNodeMapProxyT::IsAttached() const + { + return NULL != m_pNodeMap; + } + + template + inline GENAPI_NAMESPACE::INodeMap* CNodeMapProxyT::GetNodeMap() const + { + return m_pNodeMap; + } + } + + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // __PYLON_NODEMAPROXY__H__ diff --git a/Cigarette/Pylon6.2/include/pylon/Parameter.h b/Cigarette/Pylon6.2/include/pylon/Parameter.h new file mode 100644 index 0000000..2f35a69 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Parameter.h @@ -0,0 +1,371 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CPARAMETER_H +#define INCLUDED_BASLER_PYLON_CPARAMETER_H + +#pragma once + +#include +#include + + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /// Lists possible parameter info values. + enum EParameterInfo + { + /// The identifier of a parameter. It can be used to access the node via a node map using GenApi::INodeMap::GetNode() + /// or to access the value of an enumeration parameter using CEnumParameter::GetEntryByNameAsParameter(). + ParameterInfo_Name, + /// The name of a parameter or an enumeration value that can be used for display in a user interface. + ParameterInfo_DisplayName, + /// The short description of a parameter or an enumeration value. + ParameterInfo_ToolTip, + /// The long description of a parameter or an enumeration value. + ParameterInfo_Description + }; + + + /*! + \brief Extends the GenApi::IValue interface with convenience methods. + */ + interface IValueEx : virtual public GENAPI_NAMESPACE::IValue + { + /*! + \brief Indicates whether the parameter is readable. + \error + Does not throw C++ exceptions. + \return Returns true if the parameter is readable. + */ + virtual bool IsReadable() const = 0; + + + /*! + \brief Indicates whether the parameter is writable. + \error + Does not throw C++ exceptions. + \return Returns true if the parameter is writable. + */ + virtual bool IsWritable() const = 0; + + + /*! + \brief Indicates whether a node is attached. + \return Returns true if a node is attached. + \error + Does not throw C++ exceptions. + */ + virtual bool IsValid() const = 0; + + + /*! + \brief Gets the parameter information. + \param[in] info The type information to return. + \return Returns the parameter information. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Throws an exception if no node is attached. + Can throw exceptions if the retrieval of the information fails. + */ + virtual String_t GetInfo( EParameterInfo info ) = 0; + + + /*! + \brief Gets the parameter information if the parameter is attached to a node. See IsValid(). + \param[in] info The type information to return. + \brief Otherwise returns the default information. + This method is useful if you want to display parameter information and handle the case that some parameters are not available for a device. + \return Returns the parameter information if the parameter is attached to a node. Otherwise returns the default information. + \param[in] defaultInfo The default information returned if the parameter is not attached to a node. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the retrieval of the information fails. + */ + virtual String_t GetInfoOrDefault( EParameterInfo info, const String_t defaultInfo ) = 0; + + + /*! + \brief Gets the parameter value as string if the parameter is readable. + \brief Otherwise returns the default value. + \return Returns the parameter value if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading the value fails. + */ + virtual String_t ToStringOrDefault( const String_t& defaultValue ) = 0; + }; + + + /*! + \brief CParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CParameter : virtual public IValueEx + { + public: + /*! + \brief Creates an empty CParameter object. + \error + Does not throw C++ exceptions. + */ + CParameter(); + + + /*! + \brief Creates a CParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CParameter object and attaches it to a node of a matching type. + \param[in] pValue The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pValue has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CParameter( GENAPI_NAMESPACE::IValue* pValue ); + + + /*! + \brief Creates a CParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CParameter( const CParameter& rhs ); + + + /*! + \brief Destroys the CParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pValue The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IValue* pValue ); + + + /*! + \brief Assigns a CParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CParameter& operator=( const CParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pValue The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IValue* pValue ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + + + + // Implements GenApi::IBase + virtual GENAPI_NAMESPACE::EAccessMode GetAccessMode() const; + + // Implements GenApi::IValue + virtual GENAPI_NAMESPACE::INode* GetNode(); + + // Implements GenApi::IValue + virtual GENICAM_NAMESPACE::gcstring ToString( bool verify = false, bool ignoreCache = false ); + + // Implements GenApi::IValue + virtual void FromString( const GENICAM_NAMESPACE::gcstring& valueStr, bool verify = true ); + + // Implements GenApi::IValue + virtual bool IsValueCacheValid() const; + + + // Implements IValueEx + virtual bool IsReadable() const; + + // Implements IValueEx + virtual bool IsWritable() const; + + // Implements IValueEx + virtual bool IsValid() const; + + // Implements IValueEx + virtual String_t GetInfo( EParameterInfo info ); + + // Implements IValueEx + virtual String_t GetInfoOrDefault( EParameterInfo info, const String_t defaultInfo ); + + // Implements IValueEx + virtual String_t ToStringOrDefault( const String_t& defaultValue ); + + protected: + GENAPI_NAMESPACE::IValue* m_pValue; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/ParameterIncludes.h b/Cigarette/Pylon6.2/include/pylon/ParameterIncludes.h new file mode 100644 index 0000000..cc60f9c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ParameterIncludes.h @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief This file can be used to include all parameter classes for Generic API use. +*/ + +#ifndef INCLUDED_BASLER_PYLON_PARAMETERINCLUDES_H +#define INCLUDED_BASLER_PYLON_PARAMETERINCLUDES_H + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#endif /* INCLUDED_BASLER_PYLON_PARAMETERINCLUDES_H */ diff --git a/Cigarette/Pylon6.2/include/pylon/PayloadType.h b/Cigarette/Pylon6.2/include/pylon/PayloadType.h new file mode 100644 index 0000000..1b1a5c2 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PayloadType.h @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! + \file + \brief Contains possible payload type values. +*/ + +#ifndef INCLUDED_PAYLOADTYPE_H_835705 +#define INCLUDED_PAYLOADTYPE_H_835705 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + // ------------------------------------------------------------------------- + // enum EPayloadType + // ------------------------------------------------------------------------- + /*! + \brief Possible payload type values + \ingroup Pylon_InstantCameraApiGeneric + */ + enum EPayloadType + { + PayloadType_Undefined = -1, //!< Undefined payload + PayloadType_Image, //!< The buffer contains image data. + PayloadType_RawData, //!< The buffer contains raw data. + PayloadType_File, //!< The buffer contains file data. + PayloadType_ChunkData, //!< The buffer contains chunk data. + PayloadType_GenDC, //!< The buffer contains GenDC container. + PayloadType_DeviceSpecific = 0x8000 //!< The buffer contains device specific data. + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PAYLOADTYPE_H_835705 */ diff --git a/Cigarette/Pylon6.2/include/pylon/Pixel.h b/Cigarette/Pylon6.2/include/pylon/Pixel.h new file mode 100644 index 0000000..5e8e7b2 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Pixel.h @@ -0,0 +1,101 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! + \file + \brief Contains structs describing pixel layouts. +*/ + +#ifndef INCLUDED_PIXEL_H_9632837 +#define INCLUDED_PIXEL_H_9632837 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ +#pragma pack(push, 1) + + //----------------------------------------------------------------------- + // Structs needed for BGR and RGB formats + //----------------------------------------------------------------------- + + /// Describes the memory layout of a BGRA8 pixel. This pixel is used in Windows bitmaps. + struct SBGRA8Pixel + { + uint8_t B; ///< Blue + uint8_t G; ///< Green + uint8_t R; ///< Red + uint8_t A; ///< Transparency + }; + + /// Describes the memory layout of a BGR8 pixel. This pixel is used in Windows bitmaps. + struct SBGR8Pixel + { + uint8_t B; ///< Blue + uint8_t G; ///< Green + uint8_t R; ///< Red + }; + + /// Describes the memory layout of a RGB8 pixel. + struct SRGB8Pixel + { + uint8_t R; ///< Red + uint8_t G; ///< Green + uint8_t B; ///< Blue + }; + + /// Describes the memory layout of a RGB16 pixel. + struct SRGB16Pixel + { + uint16_t R; ///< Red + uint16_t G; ///< Green + uint16_t B; ///< Blue + }; + + //----------------------------------------------------------------------- + // Structs needed for variants of YUV422 formats + //----------------------------------------------------------------------- + + /// Describes the memory layout of a YUV422_UYVY pixel with information about brightness and chroma for two pixels. + struct SYUV422_UYVY // DCAM Variant + { + uint8_t U; ///< chroma U (both pixels) + uint8_t Y1; ///< brightness Pixel 1 + uint8_t V; ///< chroma V (both pixels) + uint8_t Y2; ///< brightness Pixel 2 + typedef uint8_t value_type; + }; + + /// Describes the memory layout of a YUV422_YUYV pixel with information about brightness and chroma for two pixels. + struct SYUV422_YUYV // Microsoft preferred variant + { + uint8_t Y1; ///< brightness Pixel 1 + uint8_t U; ///< chroma U (both pixels) + uint8_t Y2; ///< brightness Pixel 2 + uint8_t V; ///< chroma V (both pixels) + typedef uint8_t value_type; + }; + +#pragma pack(pop) + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PIXEL_H_9632837 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PixelData.h b/Cigarette/Pylon6.2/include/pylon/PixelData.h new file mode 100644 index 0000000..67485a5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PixelData.h @@ -0,0 +1,146 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2012-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains a data structure describing the data of one pixel. +*/ + +#ifndef INCLUDED_PIXELDATA_H_9714014 +#define INCLUDED_PIXELDATA_H_9714014 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /*! + \class SPixelData + \brief Describes the data of one pixel. + */ + struct SPixelData + { + /// Construct and clear. + SPixelData() + : PixelDataType( PixelDataType_Unknown ) + , BitDepth( 0 ) + { + Data.RGBA.R = + Data.RGBA.G = + Data.RGBA.B = + Data.RGBA.A = 0; + } + ~SPixelData() + { + + } + + /// Lists the possible pixel data types. + /// Do not confound this enumeration with the Pylon::PixelType enumeration that lists all pixel formats. + enum EPixelDataType + { + PixelDataType_Unknown,//!< Will be returned, if the pixel data cannot be determined. + PixelDataType_Mono, //!< Pixel data of monochrome images. + PixelDataType_YUV, //!< Pixel data of YUV images. + PixelDataType_RGB, //!< Pixel data of RGB or BGR images. + PixelDataType_RGBA, //!< Pixel data of RGB or BGR images with alpha channel. + PixelDataType_BayerR, //!< Pixel data of a red pixel of bayer images. + PixelDataType_BayerG, //!< Pixel data of a green pixel of bayer images. + PixelDataType_BayerB //!< Pixel data of a blue pixel of bayer images. + }; + + EPixelDataType PixelDataType; ///< The type of pixel data held. + uint32_t BitDepth; ///< The bit depth of the data held. + + union + { + int Mono; ///< Pixel data of monochrome images. + int BayerR; ///< Pixel data of a red pixel of bayer images. + int BayerG; ///< Pixel data of a green pixel of bayer images. + int BayerB; ///< Pixel data of a blue pixel of bayer images. + + struct + { + int Y; ///< Brightness. + int U; ///< Chroma U. + int V; ///< Chroma V. + } + YUV; ///< Pixel data of YUV images. + + struct + { + int R; ///< Red. + int G; ///< Green. + int B; ///< Blue. + } + RGB; ///< Pixel data of RGB or BGR images. + + struct + { + int R; ///< Red. + int G; ///< Green. + int B; ///< Blue. + int A; ///< Transparency. + } + RGBA; ///< Pixel data of RGB or BGR images with an alpha channel. + } + Data; ///< Holds all types of pixel data. + + /// Compares pixel data. + bool operator==( const SPixelData& rhs ) + { + if (PixelDataType != rhs.PixelDataType) return false; + if (BitDepth != rhs.BitDepth) return false; + switch (PixelDataType) + { + case PixelDataType_Unknown: + return true; + case PixelDataType_Mono: + return Data.Mono == rhs.Data.Mono; + case PixelDataType_YUV: + return Data.YUV.Y == rhs.Data.YUV.Y && Data.YUV.U == rhs.Data.YUV.U && Data.YUV.V == rhs.Data.YUV.V; + case PixelDataType_RGB: + return Data.RGB.R == rhs.Data.RGB.R && Data.RGB.G == rhs.Data.RGB.G && Data.RGB.B == rhs.Data.RGB.B; + case PixelDataType_RGBA: + return Data.RGB.R == rhs.Data.RGBA.R && Data.RGBA.G == rhs.Data.RGBA.G && Data.RGBA.B == rhs.Data.RGBA.B && Data.RGBA.A == rhs.Data.RGBA.A; + case PixelDataType_BayerR: + return Data.BayerR == rhs.Data.BayerR; + case PixelDataType_BayerG: + return Data.BayerG == rhs.Data.BayerG; + case PixelDataType_BayerB: + return Data.BayerB == rhs.Data.BayerB; + default: + PYLON_ASSERT2( false, "Cannot compare SPixelDataStructure. It contains unexpected data." ); + } + return false; + } + + /// Compares pixel data. + bool operator!=( const SPixelData& rhs ) + { + return !((*this) == rhs); + } + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PIXELDATA_H_9714014 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PixelType.h b/Cigarette/Pylon6.2/include/pylon/PixelType.h new file mode 100644 index 0000000..b062c1f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PixelType.h @@ -0,0 +1,746 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung, Edgar Katzer, AG +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of types of helper functions concerning image format and pixel type. +\ingroup PYLON_PUBLIC +*/ + +#ifndef INCLUDED_PIXELTYPE_H_1534845 +#define INCLUDED_PIXELTYPE_H_1534845 + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + // Bitmask value of the monochrome type. Internal use only. +#define PIXEL_MONO (0x01000000) + // Bitmask value of the color pixel type. Internal use only. +#define PIXEL_COLOR (0x02000000) + // Pixel type is not standard +#define PIXEL_CUSTOMTYPE (0x80000000) + // Sets the bit count of pixel type. Internal use only. +#define PIXEL_BIT_COUNT(n) ((n) << 16) + + /*! + \brief Lists the available pixel types. + + These pixel types are returned by a grab result and are used by the Image Handling Support classes. + + The camera parameter interface classes define additional pixel format enumerations. These pixel format enumerations + are different from the enumeration EPixelType pylon uses, e.g. the pylon pixel type PixelType_Mono1packed + corresponds to PixelFormat_Mono1packed or PixelFormat_Mono1p. See + the documentation of the parameter interface classes for more information. + + The camera User's Manual provides more information on pixel formats and the memory layout of the image data. + */ + enum EPixelType + { + PixelType_Undefined = -1, //!< Undefined pixel type. + PixelType_Mono1packed = PIXEL_CUSTOMTYPE | PIXEL_MONO | PIXEL_BIT_COUNT( 1 ) | 0x000c, //!< alias PixelFormat_Mono1Packed or PixelFormat_Mono1p + PixelType_Mono2packed = PIXEL_CUSTOMTYPE | PIXEL_MONO | PIXEL_BIT_COUNT( 2 ) | 0x000d, //!< alias PixelFormat_Mono2Packed or PixelFormat_Mono2p + PixelType_Mono4packed = PIXEL_CUSTOMTYPE | PIXEL_MONO | PIXEL_BIT_COUNT( 4 ) | 0x000e, //!< alias PixelFormat_Mono4Packed or PixelFormat_Mono4p + + PixelType_Mono8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0001, //!< alias PixelFormat_Mono8 + PixelType_Mono8signed = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0002, //!< alias PixelFormat_Mono8signed or PixelFormat_Mono8s + PixelType_Mono10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0003, //!< alias PixelFormat_Mono10 + PixelType_Mono10packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0004, //!< alias PixelFormat_Mono10Packed. The memory layouts of PixelType_Mono10packed and PixelType_Mono10p are different. + PixelType_Mono10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0046, //!< alias PixelFormat_Mono10p. The memory layouts of PixelType_Mono10packed and PixelType_Mono10p are different. + PixelType_Mono12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0005, //!< alias PixelFormat_Mono12 + PixelType_Mono12packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0006, //!< alias PixelFormat_Mono12Packed. The memory layouts of PixelType_Mono12packed and PixelType_Mono12p are different. + PixelType_Mono12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0047, //!< alias PixelFormat_Mono12p. The memory layouts of PixelType_Mono12packed and PixelType_Mono12p are different. + PixelType_Mono16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0007, //!< alias PixelFormat_Mono16 + + PixelType_BayerGR8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0008, //!< alias PixelFormat_BayerGR8 + PixelType_BayerRG8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0009, //!< alias PixelFormat_BayerRG8 + PixelType_BayerGB8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x000a, //!< alias PixelFormat_BayerGB8 + PixelType_BayerBG8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x000b, //!< alias PixelFormat_BayerBG8 + + PixelType_BayerGR10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000c, //!< alias PixelFormat_BayerGR10 + PixelType_BayerRG10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000d, //!< alias PixelFormat_BayerRG10 + PixelType_BayerGB10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000e, //!< alias PixelFormat_BayerGB10 + PixelType_BayerBG10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000f, //!< alias PixelFormat_BayerBG10 + + PixelType_BayerGR12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0010, //!< alias PixelFormat_BayerGR12 + PixelType_BayerRG12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0011, //!< alias PixelFormat_BayerRG12 + PixelType_BayerGB12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0012, //!< alias PixelFormat_BayerGB12 + PixelType_BayerBG12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0013, //!< alias PixelFormat_BayerBG12 + + PixelType_RGB8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0014, //!< alias PixelFormat_RGB8Packed or PixelFormat_RGB8 + PixelType_BGR8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0015, //!< alias PixelFormat_BGR8Packed or PixelFormat_BGR8 + + PixelType_RGBA8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x0016, //!< alias PixelFormat_RGBA8Packed or PixelFormat_RGBa8 + PixelType_BGRA8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x0017, //!< alias PixelFormat_BGRA8Packed or PixelFormat_BGRa8 + + PixelType_RGB10packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0018, //!< alias PixelFormat_RGB10Packed or PixelFormat_RGB10 + PixelType_BGR10packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0019, //!< alias PixelFormat_BGR10Packed or PixelFormat_BGR10 + + PixelType_RGB12packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x001a, //!< alias PixelFormat_RGB12Packed or PixelFormat_RGB12 + PixelType_BGR12packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x001b, //!< alias PixelFormat_BGR12Packed or PixelFormat_BGR12 + + PixelType_RGB16packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0033, //!< alias PixelFormat_RGB16Packed or PixelFormat_RGB16 + + PixelType_BGR10V1packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x001c, //!< alias PixelFormat_BGR10V1Packed + PixelType_BGR10V2packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x001d, //!< alias PixelFormat_BGR10V2Packed + + PixelType_YUV411packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 12 ) | 0x001e, //!< alias PixelFormat_YUV411Packed or PixelFormat_YCbCr411_8 + PixelType_YUV422packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x001f, //!< alias PixelFormat_YUV422Packed + PixelType_YUV444packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0020, //!< alias PixelFormat_YUV444Packed or PixelFormat_YCbCr8 + + PixelType_RGB8planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0021, //!< alias PixelFormat_RGB8Planar or PixelFormat_RGB8_Planar + PixelType_RGB10planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0022, //!< alias PixelFormat_RGB10Planar or PixelFormat_RGB10_Planar + PixelType_RGB12planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0023, //!< alias PixelFormat_RGB12Planar or PixelFormat_RGB12_Planar + PixelType_RGB16planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0024, //!< alias PixelFormat_RGB16Planar or PixelFormat_RGB16_Planar + + PixelType_YUV422_YUYV_Packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x0032, //!< alias PixelFormat_YUV422_YUYV_Packed or PixelFormat_YCbCr422_8 + PixelType_YUV444planar = PIXEL_CUSTOMTYPE | PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0044, //!< 8 bit / channel YUV 444 planar YY YY UU UU VV VV + PixelType_YUV422planar = PIXEL_CUSTOMTYPE | PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x0042, //!< 8 bit / channel YUV 422 planar YY YY U U V V + PixelType_YUV420planar = PIXEL_CUSTOMTYPE | PIXEL_COLOR | PIXEL_BIT_COUNT( 12 ) | 0x0040, //!< 8 bit / channel YUV 420 planar YY YY U V + + PixelType_YCbCr422_8_YY_CbCr_Semiplanar = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x0113, //!< 8 bit / channel YUV 422 semiplanar YY YY UV UV also known as PixelType_YUV422_NV16 4:2:2 image with a plane of 8 bit Y samples followed by an interleaved U/V plane + PixelType_YCbCr420_8_YY_CbCr_Semiplanar = PIXEL_COLOR | PIXEL_BIT_COUNT( 12 ) | 0x0112, //!< 8 bit / channel YUV 420 semiplanar YY YY UV also known as PixelType_YUV420_NV12 4:2:0 image with a plane of 8 bit Y samples followed by an interleaved U/V plane + + PixelType_BayerGR12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002A, //!< alias PixelFormat_BayerGR12Packed. The memory layouts of PixelType_BayerGR12Packed and PixelType_BayerGR12p are different. + PixelType_BayerRG12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002B, //!< alias PixelFormat_BayerRG12Packed. The memory layouts of PixelType_BayerRG12Packed and PixelType_BayerRG12p are different. + PixelType_BayerGB12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002C, //!< alias PixelFormat_BayerGB12Packed. The memory layouts of PixelType_BayerGB12Packed and PixelType_BayerGB12p are different. + PixelType_BayerBG12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002D, //!< alias PixelFormat_BayerBG12Packed. The memory layouts of PixelType_BayerBG12Packed and PixelType_BayerBG12p are different. + + PixelType_BayerGR10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0056, //!< alias PixelFormat_BayerGR10p. + PixelType_BayerRG10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0058, //!< alias PixelFormat_BayerRG10p. + PixelType_BayerGB10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0054, //!< alias PixelFormat_BayerGB10p. + PixelType_BayerBG10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0052, //!< alias PixelFormat_BayerBG10p. + + PixelType_BayerGR12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0057, //!< alias PixelFormat_BayerGR12p. The memory layouts of PixelType_BayerGR12Packed and PixelType_BayerGR12p are different. + PixelType_BayerRG12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0059, //!< alias PixelFormat_BayerRG12p. The memory layouts of PixelType_BayerRG12Packed and PixelType_BayerRG12p are different. + PixelType_BayerGB12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0055, //!< alias PixelFormat_BayerGB12p. The memory layouts of PixelType_BayerGB12Packed and PixelType_BayerGB12p are different. + PixelType_BayerBG12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0053, //!< alias PixelFormat_BayerBG12p. The memory layouts of PixelType_BayerBG12Packed and PixelType_BayerBG12p are different. + + PixelType_BayerGR16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x002E, //!< alias PixelFormat_BayerGR16 + PixelType_BayerRG16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x002F, //!< alias PixelFormat_BayerRG16 + PixelType_BayerGB16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0030, //!< alias PixelFormat_BayerGB16 + PixelType_BayerBG16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0031, //!< alias PixelFormat_BayerBG16 + + PixelType_RGB12V1packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 36 ) | 0x0034, //!< alias PixelFormat_RGB12V1Packed + + PixelType_Double = PIXEL_CUSTOMTYPE | PIXEL_MONO | PIXEL_BIT_COUNT( 64 ) | 0x100, //!< alias PixelFormat_Double + + // For ToF + PixelType_Confidence8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x00C6, //!< Confidence 8-bit + PixelType_Confidence16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x00C7, //!< Confidence 16-bit + PixelType_Coord3D_C8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x00B1, //!< 3D coordinate C 8-bit + PixelType_Coord3D_C16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x00B8, //!< 3D coordinate C 16-bit + PixelType_Coord3D_ABC32f = PIXEL_COLOR | PIXEL_BIT_COUNT( 96 ) | 0x00C0, //!< 3D coordinate A-B-C 32-bit floating point + + // Floating point + PixelType_Data32f = PIXEL_MONO | PIXEL_BIT_COUNT( 32 ) | 0x011C, //!< 32 bit IEC 60559:1989 conform little endian floating point data + }; + + /// Returns true if the pixel type is Mono and the pixel values are not byte aligned. + inline bool IsMonoPacked( EPixelType pixelType ) + { + if (PixelType_Mono1packed == pixelType) return true; + if (PixelType_Mono2packed == pixelType) return true; + if (PixelType_Mono4packed == pixelType) return true; + if (PixelType_Mono10packed == pixelType) return true; + if (PixelType_Mono10p == pixelType) return true; + if (PixelType_Mono12packed == pixelType) return true; + if (PixelType_Mono12p == pixelType) return true; + + return false; + } + + /// Returns true if the pixel type is Bayer and the pixel values are not byte aligned. + inline bool IsBayerPacked( EPixelType pixelType ) + { + if (PixelType_BayerGB12Packed == pixelType) return true; + if (PixelType_BayerGR12Packed == pixelType) return true; + if (PixelType_BayerRG12Packed == pixelType) return true; + if (PixelType_BayerBG12Packed == pixelType) return true; + if (PixelType_BayerGB10p == pixelType) return true; + if (PixelType_BayerGR10p == pixelType) return true; + if (PixelType_BayerRG10p == pixelType) return true; + if (PixelType_BayerBG10p == pixelType) return true; + if (PixelType_BayerGB12p == pixelType) return true; + if (PixelType_BayerGR12p == pixelType) return true; + if (PixelType_BayerRG12p == pixelType) return true; + if (PixelType_BayerBG12p == pixelType) return true; + + return false; + } + + /// Returns true if the pixel type is RGB and the pixel values are not byte aligned. + inline bool IsRGBPacked( EPixelType pixelType ) + { + if (PixelType_RGB12V1packed == pixelType) return true; + + return false; + } + + /// Returns true if the pixel type is BGR and the pixel values are not byte aligned. + inline bool IsBGRPacked( EPixelType pixelType ) + { + if (PixelType_BGR10V1packed == pixelType) return true; + if (PixelType_BGR10V2packed == pixelType) return true; + + return false; + } + + /// Returns true if the pixels of the given pixel type are not byte aligned. + inline bool IsPacked( EPixelType pixelType ) + { + return (IsMonoPacked( pixelType ) || IsBayerPacked( pixelType ) || IsRGBPacked( pixelType ) || IsBGRPacked( pixelType )); + } + + /// Returns true if the pixel type is packed in lsb packed format. + /// For lsb packed format, the data is filled lsb first in the lowest address byte (byte 0) starting with the first pixel + /// and continued in the lsb of byte 1 (and so on). + /// See the camera User's Manual or the Pixel Format Naming Convention (PFNC) of the GenICam standard group for more information. + inline bool IsPackedInLsbFormat( EPixelType pixelType ) + { + if (PixelType_Mono1packed == pixelType) return true; + if (PixelType_Mono2packed == pixelType) return true; + if (PixelType_Mono4packed == pixelType) return true; + if (PixelType_Mono10p == pixelType) return true; + if (PixelType_BayerGB10p == pixelType) return true; + if (PixelType_BayerGR10p == pixelType) return true; + if (PixelType_BayerRG10p == pixelType) return true; + if (PixelType_BayerBG10p == pixelType) return true; + if (PixelType_BayerGB12p == pixelType) return true; + if (PixelType_BayerGR12p == pixelType) return true; + if (PixelType_BayerRG12p == pixelType) return true; + if (PixelType_BayerBG12p == pixelType) return true; + if (PixelType_Mono12p == pixelType) return true; + + return false; + } + + /// Returns number of planes in the image composed of the pixel type. + inline uint32_t PlaneCount( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_RGB8planar: + case PixelType_RGB10planar: + case PixelType_RGB12planar: + case PixelType_RGB16planar: + case PixelType_YUV444planar: + case PixelType_YUV422planar: + case PixelType_YUV420planar: + return 3; + default: + return 1; + } + } + + /// Returns the pixel type of a plane. + inline EPixelType GetPlanePixelType( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_RGB8planar: + case PixelType_YUV444planar: + case PixelType_YUV422planar: + case PixelType_YUV420planar: + return PixelType_Mono8; + case PixelType_RGB10planar: + return PixelType_Mono10; + case PixelType_RGB12planar: + return PixelType_Mono12; + case PixelType_RGB16planar: + return PixelType_Mono16; + default: + return pixelType; + } + } + + /// Returns true if images of the pixel type are divided into multiple planes. + inline bool IsPlanar( EPixelType pixelType ) + { + return PlaneCount( pixelType ) > 1; + } + + /// Lists the Bayer color filter types. + enum EPixelColorFilter + { + PCF_BayerRG, //!< red green + PCF_BayerGB, //!< green blue + PCF_BayerGR, //!< green red + PCF_BayerBG, //!< blue green + PCF_Undefined //!< undefined color filter or not applicable + }; + + /// Returns the Bayer color filter type. + inline EPixelColorFilter GetPixelColorFilter( EPixelType pixelType ) + { + if (PixelType_BayerGR8 == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG8 == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB8 == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG8 == pixelType) return PCF_BayerBG; + + if (PixelType_BayerGR10 == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG10 == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB10 == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG10 == pixelType) return PCF_BayerBG; + + if (PixelType_BayerGR12 == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG12 == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB12 == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG12 == pixelType) return PCF_BayerBG; + + if (PixelType_BayerGR12Packed == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG12Packed == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB12Packed == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG12Packed == pixelType) return PCF_BayerBG; + + if (PixelType_BayerGR10p == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG10p == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB10p == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG10p == pixelType) return PCF_BayerBG; + + if (PixelType_BayerGR12p == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG12p == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB12p == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG12p == pixelType) return PCF_BayerBG; + + if (PixelType_BayerGR16 == pixelType) return PCF_BayerGR; + if (PixelType_BayerRG16 == pixelType) return PCF_BayerRG; + if (PixelType_BayerGB16 == pixelType) return PCF_BayerGB; + if (PixelType_BayerBG16 == pixelType) return PCF_BayerBG; + + return PCF_Undefined; + } + + /*! + \brief Returns the bits needed to store a pixel. + + BitPerPixel(PixelType_Mono12) returns 16 and BitPerPixel(PixelType_Mono12packed) + returns 12 for example. + + \param[in] pixelType The pixel type. + \pre The pixel type must be defined. + + \error + Throws an exception when the pixel type is undefined. + */ + PYLONBASE_API uint32_t BitPerPixel( EPixelType pixelType ); + + /*! + \brief Returns the number of measured values per pixel. + + SamplesPerPixel(PixelType_Mono8) returns 1 and SamplesPerPixel(PixelType_RGB8packed) + returns 3 for example. + + \param[in] pixelType The pixel type. + \pre The pixel type must be defined. The pixel type is not PixelType_YUV411packed. + + \error + Throws an exception when the pixel type is undefined. + */ + PYLONBASE_API uint32_t SamplesPerPixel( EPixelType pixelType ); + + /// Returns true when the pixel type represents a YUV format. + inline bool IsYUV( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_YUV411packed: + case PixelType_YUV422_YUYV_Packed: + case PixelType_YUV422packed: + case PixelType_YUV444packed: + case PixelType_YUV444planar: + case PixelType_YUV422planar: + case PixelType_YUV420planar: + return true; + default: + return false; + } + } + + /// Returns true when the pixel type represents an RGBA format. + inline bool IsRGBA( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_RGBA8packed: + return true; + default: + return false; + } + } + + /// Returns true when the pixel type represents an RGB or RGBA format. + inline bool IsRGB( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_RGB8packed: + case PixelType_RGB10packed: + case PixelType_RGB12packed: + case PixelType_RGB16packed: + case PixelType_RGB8planar: + case PixelType_RGB10planar: + case PixelType_RGB12planar: + case PixelType_RGB16planar: + case PixelType_RGB12V1packed: + return true; + default: + return IsRGBA( pixelType ); + } + } + + /// Returns true when the pixel type represents a BGRA format. + inline bool IsBGRA( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_BGRA8packed: + return true; + default: + return false; + } + + } + + /// Returns true when the pixel type represents a BGR or BGRA format. + inline bool IsBGR( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_BGR8packed: + case PixelType_BGR10packed: + case PixelType_BGR12packed: + case PixelType_BGR10V1packed: + case PixelType_BGR10V2packed: + return true; + default: + return IsBGRA( pixelType ); + } + } + + /// Returns true when the pixel type represents a Bayer format. + inline bool IsBayer( EPixelType pixelType ) + { + return GetPixelColorFilter( pixelType ) != PCF_Undefined; + } + + /// Returns true when a given pixel is monochrome, e.g. PixelType_Mono8 or PixelType_BayerGR8. + inline bool IsMono( EPixelType pixelType ) + { + return (pixelType != PixelType_Undefined) && (PIXEL_MONO == (pixelType & PIXEL_MONO)); + } + + /// Returns true when an image using the given pixel type is monochrome, e.g. PixelType_Mono8. + inline bool IsMonoImage( EPixelType pixelType ) + { + return IsMono( pixelType ) && !IsBayer( pixelType ); + } + + /// Returns true when an image using the given pixel type is a color image (RGB/BGR/RGBA/BGRA/ etc or Bayer. + inline bool IsColorImage( EPixelType pixelType ) + { + bool res = (pixelType != PixelType_Undefined) && (IsBayer( pixelType ) || ((pixelType & PIXEL_COLOR) != 0)); + return res; + } + + /// Returns true when an the image using the given pixel type has an alpha channel. + inline bool HasAlpha( EPixelType pixelType ) + { + switch (pixelType) + { + case PixelType_RGBA8packed: + case PixelType_BGRA8packed: + return true; + default: + return false; + } + } + + /// Returns true if a given pixel type represents a floating point number. + inline bool IsFloatingPoint( EPixelType pixelType ) + { + bool res = (pixelType == PixelType_Double) || (pixelType == PixelType_Coord3D_ABC32f) || (pixelType == PixelType_Data32f); + return res; + } + + /// Returns the minimum step size expressed in pixels for extracting an AOI. + inline uint32_t GetPixelIncrementX( EPixelType pixelType ) + { + if (IsBayer( pixelType )) + { + return 2; + } + + switch (pixelType) + { + case PixelType_YUV422packed: + return 2; + case PixelType_YUV422_YUYV_Packed: + return 2; + case PixelType_YUV411packed: + return 4; + default: + return 1; + } + } + + /// Returns the minimum step size expressed in pixels for extracting an AOI. + inline uint32_t GetPixelIncrementY( EPixelType pixelType ) + { + if (IsBayer( pixelType )) + { + return 2; + } + return 1; + } + + /*! + \brief Returns the bit depth of a value of the pixel in bits. + + This may be less than the size needed to store the pixel. + BitDepth(PixelType_Mono12) returns 12, BitDepth(PixelType_Mono12packed) + returns 12, and BitDepth(PixelType_RGB8packed) returns 8 for example. + + \param[in] pixelType The pixel type. + + \pre The pixel type must be valid. + + \error + Throws an exception when the pixel type is undefined. + */ + PYLONBASE_API uint32_t BitDepth( EPixelType pixelType ); + + /*! + \brief Computes the stride in byte. + + The stride indicates the number of bytes between the beginning of one row + in an image and the beginning of the next row. + For planar pixel types the returned value represents the stride of a plane. + + The stride in bytes cannot be computed for packed image format when the stride is not byte aligned and paddingX == 0. + If paddingX is larger than zero and the stride without padding is not byte aligned then the rest of the partially + filled byte is considered as padding, e.g. pixelType = PixelType_Mono12packed, width = 5, paddingX = 10 results + in a stride of 18 Bytes (stride without padding is 5 * BitPerPixel( PixelType_Mono12packed) = 5 * 12 = 60 Bits = 7.5 Bytes). + + The stride can also be not computed for planar YUV422 and YUV420 image formats. + + See also Pylon::IsPacked(). + + \param[out] strideBytes The stride in byte if it can be computed. + \param[in] pixelType The pixel type. + \param[in] width The number of pixels in a row. + \param[in] paddingX The number of additional bytes at the end of a row (byte aligned). + + \return Returns true if the stride can be computed. + + \pre + The \c width value must be >= 0 and <= _I32_MAX. + + \error + Throws an exception when the preconditions are not met. + */ + PYLONBASE_API bool ComputeStride( size_t& strideBytes, EPixelType pixelType, uint32_t width, size_t paddingX = 0 ); + + /*! + \brief Computes the padding value from row stride in byte. + + \param[out] strideBytes The stride in byte. + \param[in] pixelType The pixel type. + \param[in] width The number of pixels in a row. + + \return Returns the paddingX value for the given stride value (byte aligned). + + \pre +
    +
  • The value of \c strideBytes must be large enough to contain a line described by \c pixelType and \c width. +
  • The pixel type must be valid. +
  • The \c width value must be >= 0 and <= _I32_MAX. +
+ + \error + Throws an exception when the preconditions are not met. + */ + PYLONBASE_API size_t ComputePaddingX( size_t strideBytes, EPixelType pixelType, uint32_t width ); + + /*! + \brief Computes the buffer size in byte. + + \param[in] pixelType The pixel type. + \param[in] width The number of pixels in a row. + \param[in] height The number of rows in an image. + \param[in] paddingX The number of extra data bytes at the end of each row (byte aligned). + \return The buffer size in byte. + + \pre +
    +
  • The pixel type must be valid. +
  • The \c width value must be >= 0 and <= _I32_MAX. +
  • The \c height value must be >= 0 and <= _I32_MAX. +
+ + \error + Throws an exception when the preconditions are not met. + */ + PYLONBASE_API size_t ComputeBufferSize( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX = 0 ); + + /*! + \brief Returns the pixel types needed for conversion from packed to unpacked image formats using the CImageFormatConverter class. + + The following pixel types are supported: +
    +
  • source: PixelType_Mono1packed target: PixelType_Mono8 +
  • source: PixelType_Mono2packed target: PixelType_Mono8 +
  • source: PixelType_Mono4packed target: PixelType_Mono8 +
  • source: PixelType_Mono10packed target: PixelType_Mono16 +
  • source: PixelType_Mono10p target: PixelType_Mono16 +
  • source: PixelType_Mono12packed target: PixelType_Mono16 +
  • source: PixelType_Mono12p target: PixelType_Mono16 +
  • source: PixelType_BayerGB12Packed imposed: PixelType_Mono12packed target: PixelType_Mono16 +
  • source: PixelType_BayerGR12Packed imposed: PixelType_Mono12packed target: PixelType_Mono16 +
  • source: PixelType_BayerRG12Packed imposed: PixelType_Mono12packed target: PixelType_Mono16 +
  • source: PixelType_BayerBG12Packed imposed: PixelType_Mono12packed target: PixelType_Mono16 +
  • source: PixelType_BayerGB10p imposed: PixelType_Mono10p target: PixelType_Mono16 +
  • source: PixelType_BayerGR10p imposed: PixelType_Mono10p target: PixelType_Mono16 +
  • source: PixelType_BayerRG10p imposed: PixelType_Mono10p target: PixelType_Mono16 +
  • source: PixelType_BayerBG10p imposed: PixelType_Mono10p target: PixelType_Mono16 +
  • source: PixelType_BayerGB12p imposed: PixelType_Mono12p target: PixelType_Mono16 +
  • source: PixelType_BayerGR12p imposed: PixelType_Mono12p target: PixelType_Mono16 +
  • source: PixelType_BayerRG12p imposed: PixelType_Mono12p target: PixelType_Mono16 +
  • source: PixelType_BayerBG12p imposed: PixelType_Mono12p target: PixelType_Mono16 +
+ + \param[in] pixelTypeSource The source pixel type. + \param[out] pixelTypeToImpose The pixel type that is used for conversion instead of the source pixel type. + Returns \c pixelTypeSource if changing the source pixel type is not needed. + Returns PixelType_Undefined if no unpacking is needed. + \param[out] pixelTypeTarget The pixel type to which the image pixel data are converted. + Returns PixelType_Undefined if no unpacking is needed. + + \return Returns true if the source \c pixelTypeSource is in packed image format and a conversion is possible. + */ + inline bool GetPixelTypesForUnpacking( EPixelType pixelTypeSource, EPixelType& pixelTypeToImpose, EPixelType& pixelTypeTarget ) + { + pixelTypeToImpose = pixelTypeSource; + pixelTypeTarget = PixelType_Undefined; + + if (PixelType_Mono1packed == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono8; + } + else if (PixelType_Mono2packed == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono8; + } + else if (PixelType_Mono4packed == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono8; + } + else if (PixelType_Mono10packed == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_Mono10p == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_Mono12packed == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_Mono12p == pixelTypeSource) + { + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerGB12Packed == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12packed; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerGR12Packed == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12packed; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerRG12Packed == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12packed; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerBG12Packed == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12packed; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerGB10p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono10p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerGR10p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono10p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerRG10p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono10p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerBG10p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono10p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerGB12p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerGR12p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerRG12p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12p; + pixelTypeTarget = PixelType_Mono16; + } + else if (PixelType_BayerBG12p == pixelTypeSource) + { + pixelTypeToImpose = PixelType_Mono12p; + pixelTypeTarget = PixelType_Mono16; + } + + return pixelTypeTarget != PixelType_Undefined; + } + + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PIXELTYPE_H_1534845 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PixelTypeMapper.h b/Cigarette/Pylon6.2/include/pylon/PixelTypeMapper.h new file mode 100644 index 0000000..500cf43 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PixelTypeMapper.h @@ -0,0 +1,261 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Pixeltypemapper for mapping GenICam pixel format enumerations to pylon pixel type enumeration +\ingroup PYLON_PUBLIC +*/ + +#ifndef PYLON_PIXEL_TYPE_MAPPER_H_INCLUDED_ +#define PYLON_PIXEL_TYPE_MAPPER_H_INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + class CPixelTypeMapperImpl; + + /// Specifies the SFNC version. + enum SFNCVersion + { + SFNCVersion_Invalid = 0, //!< Invalid or unknown SFNC version + SFNCVersion_pre2_0 = 1, //!< SFNC version prior to 2.0 + SFNCVersion_2_0 = 200 //!< SFNC version 2.0 + // if you ad entries here you must change GetStartIndexForSFNC accordingly + }; + + // ------------------------------------------------------------------------- + // class CPixelTypeMapper + // ------------------------------------------------------------------------- + /*! + \brief A simple pixeltypemapper (maps device specific pixelformats read from device-node map to pylon pixeltypes by their name). + + \ingroup PYLON_PUBLIC + + Use this mapper to convert a device specifc Pylon::PixelFormat value to a Pylon::EPixelType used for PixelFormatConverters. + When passing the symbolic name of the pixeltype you can use the static function CPixelTypeMapper::GetPylonPixelTypeByName(). + If you want to convert a nodeValue you must first create a CPixelTypeMapper instance and pass the constructor a pointer the PixelFormat node of the device + you want the node value to be converted. Then call CPixelTypeMapper::GetPylonPixelTypeFromNodeValue() to get the corresponding Pylon::EPixelType. + */ + class PYLONBASE_API CPixelTypeMapper + { + public: + /// Create an empty mapper. + /// Before calling any non-static function you must call SetPixelFormatEnumNode to initialize the mapper. + CPixelTypeMapper( void ); + + /// create and initialize a mapper by using the enum node passed. + explicit CPixelTypeMapper( GENAPI_NAMESPACE::IEnumeration* pEnum ); + + /// default d'tor + virtual ~CPixelTypeMapper( void ); + + public: + + /*! \brief Checks the objects validity + \return Returns true if the object is initialized properly. + + Essentially this function checks whether you've called SetPixelFormatEnumNode. + */ + bool IsValid() const; + + /*! \brief Lazy initialization of the object. + \param pEnum Pointer to the enumeration node containing the PixelFormats. + + Call this function initialize the mapper when using the default c'tor. + */ + void SetPixelFormatEnumNode( GENAPI_NAMESPACE::IEnumeration* pEnum ); + + public: + /*! \brief Converts an enumeration node value to a Pylon::EPixelType enum + + \param nodeValue node value to convert. You can obtain this value by calling GENAPI_NAMESPACE::IEnumeration::GetIntValue. + \return Returns the Pylon::EPixelType for a given pixelformat enum value defined in the Enum passed in c'tor + + Converts a enumeration node value to a Pylon::EPixelType enum. + You must have initialized the mapper before you can call this function. + */ + EPixelType GetPylonPixelTypeFromNodeValue( int64_t nodeValue ) const; + + public: + /*! \brief Returns a Pylon::EPixelType for a given symbolic name. + \param pszSymbolicName pointer to the symbolic name. Note: Symbolic names are case sensitive. You can obtain the symbolic name by calling GENAPI_NAMESPACE::IEnumEntry::GetSymbolic() + \return Returns the Pylon_PixelType for a given symbolic name. + + Static version which does the lookup soley by symbolic string comparison. + Passing "Mono16" will return Pylon::PixelType_Mono16. If the name is not found Pylon::PixelType_Undefined will be returned. + */ + static EPixelType GetPylonPixelTypeByName( const char* pszSymbolicName ); + + /*! \brief Returns a Pylon::EPixelType for a given symbolic name. + \param symbolicName The symbolic name. Note: Symbolic names are case sensitive. You can obtain the symbolic name by calling GENAPI_NAMESPACE::IEnumEntry::GetSymbolic() + \return Returns the Pylon_PixelType for a given symbolic name. + + Static version which does the lookup solely by symbolic string comparison. + Passing "Mono16" will return Pylon::PixelType_Mono16. If the name is not found Pylon::PixelType_Undefined will be returned. + */ + static EPixelType GetPylonPixelTypeByName( const String_t& symbolicName ) + { + return GetPylonPixelTypeByName( symbolicName.c_str() ); + } + + /*! \brief Static function that returns a string representation of the given EPixelType. + \param pixelType The pixel type to return the name for. + \param sfncVer SFNC Version to use when doing the mapping. Some names have been changed in SFNC 2.0 + \return Returns the pointer to a null terminated string representing the symbolic name of the pixel type. + + Passing Pylon::PixelType_Mono16 will return "Mono16" will be returned. If the pixel type is not known an empty string is returned. + + \note The returned name cannot be used to parameterize the pixel format of a camera device, because the camera's pixel format name can be + different. The camera's pixel format name depends on the used standard feature naming convention (SFNC). + */ + static const char* GetNameByPixelType( EPixelType pixelType, SFNCVersion sfncVer = SFNCVersion_pre2_0 ); + + private: + CPixelTypeMapperImpl* m_pImpl; + }; + + + // ------------------------------------------------------------------------- + // class CCameraPixelTypeMapperT + // ------------------------------------------------------------------------- + /*! + \brief A camera specific pixeltypemapper (maps device specific pixelformats contained in the generated camera classes to pylon pixeltypes by their name). + + \ingroup PYLON_PUBLIC + + Use this mapper to convert a PixelTypeEnums or ChunkPixelFormatEnums enum values to a Pylon_PixelType used for PixelTypeConverter creation. + When passing the symbolic name of the pixeltype you can use the static version GetPylonPixelTypeByName. This function will do the lookup everytime you call it. + The non-static member function GetPylonPixelTypeFromPixelFormatEnum uses caching to speed up subsequent calls. + + The template parameter EnumT is the enumeration type from the camera class (typically Basler_GigECamera::PixelFormatEnums for GigE cameras or Basler_IIDC1394CameraParams::PixelFormatEnums for 1394 cameras) + */ + template + class CCameraPixelTypeMapperT : protected CPixelTypeMapper + { + public: + /// Create an empty mapper. Before calling any non-static function + CCameraPixelTypeMapperT( void ) + : m_pEnumT( NULL ) + { + } + + /// create a mapper by using the enum node passed. + explicit CCameraPixelTypeMapperT( GENAPI_NAMESPACE::IEnumerationT* pEnumT ) + : m_pEnumT( NULL ) + { + SetPixelFormatEnumNode( pEnumT ); + } + + virtual ~CCameraPixelTypeMapperT( void ) + { + m_pEnumT = NULL; + } + + public: + + /*! \brief Checks the objects validity + \return Returns true if the object is initialized properly. + + Essentially this function checks whether you've called SetPixelFormatEnumNode. + */ + bool IsValid() const + { + return m_pEnumT != NULL && CPixelTypeMapper::IsValid(); + } + + + /*! \brief Lazy initialization of the object. + \param pEnumT Pointer to the enumeration node containing the PixelFormats. + + Call this function initialize the mapper when using the default c'tor. + */ + void SetPixelFormatEnumNode( GENAPI_NAMESPACE::IEnumerationT* pEnumT ) + { + // remember a reference to the EnumerationT node. Needed for enum->nodeValue lookup + m_pEnumT = pEnumT; + + if (pEnumT != NULL) + { + CPixelTypeMapper::SetPixelFormatEnumNode( pEnumT ); + } + else + { + CPixelTypeMapper::SetPixelFormatEnumNode( NULL ); + } + } + + + public: + /*! \brief Converts a enumeration node value to a Pylon::EPixelType enum + + \param pixelFormatEnumValue enumeration value to convert. You obtain this value by calling GENAPI_NAMESPACE::IEnumerationT::GetValue. + \return Returns the Pylon::EPixelType for a given pixelformat enum value defined in the enum node passed in c'tor + + Converts a enumeration node value to a Pylon::EPixelType enum. + You must have initialized the mapper before you can call this function. + */ + EPixelType GetPylonPixelTypeFromPixelFormatEnum( EnumT pixelFormatEnumValue ) const + { + if (!IsValid()) + { + throw RUNTIME_EXCEPTION( "SetPixelFormatEnumNode not called." ); + } + + EPixelType pt = PixelType_Undefined; + GENAPI_NAMESPACE::IEnumEntry* pE = m_pEnumT->GetEntry( pixelFormatEnumValue ); + if (pE != NULL) + { + pt = CPixelTypeMapper::GetPylonPixelTypeFromNodeValue( pE->GetValue() ); + } + return pt; + } + + public: + /*! \copydoc CPixelTypeMapper::GetPylonPixelTypeByName(const char*) + */ + static EPixelType GetPylonPixelTypeByName( const char* pszSymbolicName ) + { + return CPixelTypeMapper::GetPylonPixelTypeByName( pszSymbolicName ); + } + + /*! \copydoc CPixelTypeMapper::GetPylonPixelTypeByName(const String_t&) + */ + static EPixelType GetPylonPixelTypeByName( const String_t& symbolicName ) + { + return CPixelTypeMapper::GetPylonPixelTypeByName( symbolicName.c_str() ); + } + + /*! \copydoc CPixelTypeMapper::GetNameByPixelType(EPixelType, SFNCVersion sfncVer = SFNCVersion_pre2_0) + */ + static const char* GetNameByPixelType( EPixelType pixelType, SFNCVersion sfncVer = SFNCVersion_pre2_0 ) + { + return CPixelTypeMapper::GetNameByPixelType( pixelType, sfncVer ); + } + + private: + GENAPI_NAMESPACE::IEnumerationT* m_pEnumT; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // #ifndef PYLON_PIXEL_TYPE_MAPPER_H_INCLUDED_ diff --git a/Cigarette/Pylon6.2/include/pylon/Platform.h b/Cigarette/Pylon6.2/include/pylon/Platform.h new file mode 100644 index 0000000..3458b3f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Platform.h @@ -0,0 +1,162 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: Thomas Koeller +//----------------------------------------------------------------------------- +/** \file +\brief Provides platform-specific defines +*/ + + +#if !defined(PYLON_PLATFORM_H) +#define PYLON_PLATFORM_H + +#if defined (_MSC_VER) && defined (_WIN32) +// Platform Microsoft windows, Microsoft tool chain + + + +/** \brief Is defined, when using the pylon for Windows API */ +# define PYLON_WIN_BUILD // we are building for windows + +# define PYLON_HAS_AVI_SUPPORT +# define PYLON_HAS_MALLOC_H + +// define PYLON_XX_BUILD to distinguish between 32 & 64 bit builds +# if defined(_WIN32) && !defined(_WIN64) +# define PYLON_32_BUILD +# elif defined(_WIN32) && defined(_WIN64) +# define PYLON_64_BUILD +# else +# error unsupported wordsize (32/64 platform) +# endif + + + +# if defined(PYLON_STATIC) +# define APIEXPORT +# define APIIMPORT +# define PUBLIC_INTERFACE +# else +# define APIEXPORT __declspec(dllexport) +# define APIIMPORT __declspec(dllimport) +# define PUBLIC_INTERFACE +# endif + +# if !defined(CDECL) +# define CDECL +# endif + +# if defined PYLON_NO_DEPRECATE +# define PYLON_DEPRECATED(x) +# else +# if _MSC_VER >= 1400 +# define PYLON_DEPRECATED(x) __declspec(deprecated(x)) +# else +# define PYLON_DEPRECATED(x) __declspec(deprecated) +# endif +# endif + +// packing used for pylon structs/classes +# define PYLON_PACKING 8 + +#elif (defined(__GNUC__) && defined(__linux__)) || defined(__APPLE__) +// Platform Linux, gcc or Darwin, llvm toolchain + +#ifdef __APPLE__ + // Platform Darwin / OS X +# define PYLON_OSX_BUILD +# define PYLON_HAS_BYTEORDER + +#else +# define PYLON_LINUX_BUILD + // Platform Linux + +# define PYLON_HAS_MALLOC_H +# define PYLON_HAS_BYTESWAP +# define PYLON_HAS_THREADCAP +#endif + +/** \brief Is defined when using the pylon for Unix API (Linux & Darwin / OS X */ +# define PYLON_UNIX_BUILD +# define PYLON_HAS_POSIX_THREADS + +//TODO this works only on a C99 compiler. We must ensure, that things like SIZE_MAX UINTPTR_MAX are always defined +#if !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +#endif +#if !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +#endif +#if !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS // for PRI* in inttypes.h +#endif + +# include +# include + +// gnu compiler needs explicit visibility of interfaces, so dynamic_cast works +# define PUBLIC_INTERFACE APIEXPORT + +// define PYLON_XX_BUILD to distinguish between 32 & 64 bit builds +// __WORDSIZE is not always defined and sometimes set to 32 on 64 bit platforms. So we prefer other sources. +# if __GNUC__ +# if __x86_64__ || __ppc64__ || __powerpc64__ || __aarch64__ +# define PYLON_64_BUILD +# else +# define PYLON_32_BUILD +# endif +# else + // Fallback to the unsafe wordsize method +# if __WORDSIZE == 32 +# define PYLON_32_BUILD +# elif __WORDSIZE == 64 +# define PYLON_64_BUILD +# else +# error unsupported wordsize (32/64 platform) +# endif +# endif + +// packing used for pylon structs/classes +# define PYLON_PACKING 8 + +#else + +# error Unsupported platform + +#endif + +// Architecture +#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(_M_ARMT) || defined(__arm) || defined(__aarch64__) || defined(_M_ARM64) +# define PYLON_ARM_BUILD +#endif + +#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_I86) || defined(_M_IX86) || defined(_X86_) || defined(__X86__) || defined(__I86__) || defined(_M_AMD64) || defined(_M_X64) +# define PYLON_INTEL_BUILD +#endif + + +// The GENICAM_BUILD define has been removed in GenICam 3.0. +#if defined(GENICAM_BUILD) && defined(PYLON_WIN_BUILD) +#pragma message("The GENICAM_BUILD define has been deprecated and can therefore be removed.") +#endif + +// Check whether the GenICam header (GCLinkage.h) has been included before this one as this leads to wrong DLL suffixes in debug builds. +#if defined(LINKAGE_H) && defined(PYLON_WIN_BUILD) && !defined(GENICAM_NO_AUTO_IMPLIB) && !defined(GENICAM_USER_ALWAYS_LINK_RELEASE) && (defined(_DEBUG) || defined(DEBUG)) && !defined(PYLON_BUILD_DEBUG) +#error You must include pylon/Platform.h (or at least define GENICAM_USER_ALWAYS_LINK_RELEASE) before including any GenICam headers. Note: If you include only pylon/PylonIncludes.h this will be done automatically. +#endif + +// Turn off GenICam compiler warning about untested compiler. +#if !defined(GENICAM_USER_ACCEPTS_ANY_COMPILER) +# define GENICAM_USER_ACCEPTS_ANY_COMPILER +#endif + +// Macro for deprecated classes in pylon 6.0 +#if defined(PYLON_6_0_NO_DEPRECATE) || defined(PYLON_UNIX_BUILD) +# define PYLON_6_0_DEPRECATED(message) +#else +# define PYLON_6_0_DEPRECATED(message) PYLON_DEPRECATED(message) +#endif + +#endif /* !defined(PYLON_PLATFORM_H) */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonBase.h b/Cigarette/Pylon6.2/include/pylon/PylonBase.h new file mode 100644 index 0000000..fa06a58 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonBase.h @@ -0,0 +1,190 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Function and classes for initializing the pylon runtime. +*/ +#pragma once + +#ifndef PYLONBASE_H__ +#define PYLONBASE_H__ + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +#ifdef PYLONBASE_EXPORTS +# define PYLONBASE_API APIEXPORT +#else +# define PYLONBASE_API APIIMPORT +#endif + +#if defined(PYLON_BASE_3_0_NO_DEPRECATE) +# define PYLON_BASE_3_0_DEPRECATED(message) +#else +# define PYLON_BASE_3_0_DEPRECATED(message) PYLON_DEPRECATED(message) +#endif + +namespace Pylon +{ +/** + \brief Initializes the pylon runtime system. + + You must call PylonInitialize before calling any other pylon functions. + When finished you must call PylonTerminate to free up all resources used by pylon. + + You can use the helperclass PylonAutoInitTerm to let the compiler call + PylonInitialze and PylonTerminate. + + Just create a local object on the stack in your main function and + the constructor and destructor will call the functions. + See PylonAutoInitTerm for a sample. + + PylonInitialize/PylonTerminate is reference counted. For every call of PylonInitialize, a call to PylonTerminate is required. + The last call to PylonTerminate will free up all resources. + + \if windows + For MFC applications we recommend to call PylonInitialize and PylonTerminate in the + application's InitInstance() and ExitInstance() methods. + This prevents the MFC runtime from reporting a huge number of pretended memory leaks. + This does not apply to DLLs using MFC (see below)! + + \note + Due to the limitations of functions allowed during DLLMain, it is not allowed to call PylonIntialize from DLLMain. + For further information see the official documentation of DLLMain in the Windows documentation. + \endif + + */ + PYLONBASE_API void CDECL PylonInitialize( void ); + + /** + \brief Frees up resources allocated by the pylon runtime system. + + Call this function before terminating the application. Don't use any pylon methods or pylon objects after + having called PylonTerminate(). + + PylonInitialize/PylonTerminate is reference counted. For every call of PylonInitialize, a call to PylonTerminate is required. + The last call to PylonTerminate will free up all resources. + + \if windows + \note + Due to the limitations of functions allowed during DLLMain, it is not allowed to call PylonTerminate from DLLMain. + For further information see the official documentation of DLLMain in the Windows documentation. + \endif + */ + PYLONBASE_API void CDECL PylonTerminate( bool ShutDownLogging = true ); + + /** + \brief Returns the version number of pylon + + It is possible to pass a NULL pointer for a version number category if the value is not of interest. + */ + extern "C" PYLONBASE_API void CDECL GetPylonVersion( unsigned int* major, unsigned int* minor, unsigned int* subminor, unsigned int* build ); + + /** + \brief Returns the version number of pylon as string. + */ + extern "C" PYLONBASE_API const char* CDECL GetPylonVersionString(); + + + /** + \brief Set the value of a property. + + \param propertyId Identifies the property. + \param pData A pointer to the buffer containing the data. + \param size Size of the buffer in bytes. + + Call this function to set the value of a property. + + You must have called PylonInitialize() before you can call this function. + */ + PYLONBASE_API void CDECL SetProperty( int propertyId, const void* pData, size_t size ); + + + /** + \brief Get the value of a property. + + \param propertyId Identifies the property. + \param pData A pointer to the buffer containing the data. + \param pSize Size of the buffer in bytes when calling. Holds the resulting size on return. + + Call this function to get the value of a property. + + You must have called PylonInitialize() before you can call this function. + */ + PYLONBASE_API void CDECL GetProperty( int propertyId, void* pData, size_t* pSize ); + + + /** + \brief Helper class to automagically call PylonInitialize and PylonTerminate in constructor and destructor + + \code + + #include + + // ... + + using namespace Pylon; + + int main(int argc, char* argv[]) + { + + PylonAutoInitTerm autoInitTerm; + + // Get the transport layer factory + CTlFactory& TlFactory = CTlFactory::GetInstance(); + + // Get all attached cameras and exit application if no camera is found + DeviceInfoList_t devices; + if ( 0 == TlFactory.EnumerateDevices( devices ) ) + { + cerr << "No camera present!" << endl; + return 1; + } + else + { + // do something with devices ... + //... + } + + + return 0; + + } // When leaving the main function, the destructor of the PylonAutoInitTerm object will be called + // and it will in turn call PylonTerminate. + \endcode + */ + class PylonAutoInitTerm + { + public: + PYLONBASE_API PylonAutoInitTerm( void ) + { + PylonInitialize(); + } + + PYLONBASE_API ~PylonAutoInitTerm( void ) + { + PylonTerminate(); + } + private: + // unimplemented new operator to prevent creation on the heap which is a bad idea. + // This object must be created in the local stack frame (see sample above) + void* operator new(size_t); + void* operator new[]( size_t ); + }; + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* PYLONBASE_H__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonBitmapImage.h b/Cigarette/Pylon6.2/include/pylon/PylonBitmapImage.h new file mode 100644 index 0000000..07cfc27 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonBitmapImage.h @@ -0,0 +1,323 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains a bitmap image class for displaying images. +*/ + +#ifndef INCLUDED_PYLONBITMAPIMAGE_H_7767407 +#define INCLUDED_PYLONBITMAPIMAGE_H_7767407 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /*! + \class CPylonBitmapImage + \brief This class can be used to easily create Windows bitmaps for displaying images. + +
    +
  • Automatically handles the bitmap creation and lifetime. +
  • Provides methods for loading and saving an image in different file formats. +
  • Serves as target format for the \c CImageFormatConverter image format converter. +
+ + \par Buffer Handling: + The bitmap buffer that is automatically created by the CPylonBitmapImage class. + The Release() method can be used to release a bitmap. + + \threading + The CPylonBitmapImage class is not thread-safe. + */ + class PYLONUTILITY_API CPylonBitmapImage : public CPylonImageBase + { + public: + + /*! + \brief Creates an invalid image. + + See Pylon::IImage on how the properties of an invalid image are returned. + + \error + Does not throw C++ exceptions. + */ + CPylonBitmapImage(); + + + /*! + \brief Copies the image properties and creates a reference to the bitmap of the source image. + + \param[in] source The source image. + + \post +
    +
  • Another reference to the source bitmap is created. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Does not throw C++ exceptions. + */ + CPylonBitmapImage( const CPylonBitmapImage& source ); + + + /*! + \brief Destroys a pylon image object. + + \attention The bitmap handle must not be currently selected into a DC. Otherwise the bitmap is not freed. + + \error + Does not throw C++ exceptions. + */ + virtual ~CPylonBitmapImage(); + + + /*! + \brief Copies the image properties and creates a reference to the bitmap of the source image. + + \param[in] source The source image. + + \post +
    +
  • Another reference to the source bitmap is created. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Does not throw C++ exceptions. + */ + virtual CPylonBitmapImage& operator= ( const CPylonBitmapImage& source ); + + + /*! + \brief Creates an image and a Windows bitmap for it. + + \param[in] pixelType The pixel type of the new image. + \param[in] width The number of pixels in a row in the new image. + \param[in] height The number of rows in the new image. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The pixel type must be supported, see IsSupportedPixelType(). +
  • The \c width value must be > 0 and < _I32_MAX. +
  • The \c height value must be > 0 and < _I32_MAX. +
+ + \error + Throws an exception when the parameters are invalid. + Throws an exception when the bitmap could not be created. + */ + static CPylonBitmapImage Create( EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation = ImageOrientation_BottomUp ); + + + /*! + \brief Copies the image data from a different image. + + The input image is automatically converted if needed to PixelType_Mono8 + if Pylon::IsMonoImage( pixelTypeSource) is true, + otherwise it is converted to PixelType_BGR8packed. + The orientation of the image is changed to bottom up. + + If more control over the conversion is required, the CImageFormatConverter class + can be used to convert other images with a CPylonBitmapImage object as target. + + \param[in] image The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + + \pre + The preconditions of the Reset() method must be met. + + + \post +
    +
  • The source image is automatically converted. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Throws an exception when the bitmap could not be created. + Throws an exception when the preconditions of the Reset() method are not met. + */ + virtual void CopyImage( const IImage& image ); + + /*! + \brief Sets an image from a user buffer. + + \param[in] pBuffer The pointer to the buffer of the source image. + \param[in] bufferSizeBytes The size of the buffer of the source image. + \param[in] pixelType The pixel type of the source image. + \param[in] width The number of pixels in a row in the source image. + \param[in] height The number of rows in the source image. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The pixel type must be valid. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
  • The pointer to the source buffer must not be NULL. +
  • The source buffer must be large enough to hold the image described by the parameters. +
  • The preconditions of the Reset() method must be met. +
+ + \post + The source image is automatically converted. See CopyImage(). + + \error + Throws an exception when when the bitmap could not be created. + Throws an exception when the preconditions of the Reset() method are not met. + */ + virtual void CopyImage( + const void* pBuffer, + size_t bufferSizeBytes, + EPixelType pixelType, + uint32_t width, + uint32_t height, + size_t paddingX, + EImageOrientation orientation ); + + + // Implements Pylon::IImage. + virtual bool IsValid() const; + + // Implements Pylon::IImage. + virtual EPixelType GetPixelType() const; + + // Implements Pylon::IImage. + virtual uint32_t GetWidth() const; + + // Implements Pylon::IImage. + virtual uint32_t GetHeight() const; + + // Implements Pylon::IImage. + virtual size_t GetPaddingX() const; + + // Implements Pylon::IImage. + virtual EImageOrientation GetOrientation() const; + + // Implements Pylon::IImage. + virtual void* GetBuffer(); + + // Implements Pylon::IImage. + virtual const void* GetBuffer() const; + + // Implements Pylon::IImage. + virtual size_t GetImageSize() const; + + // Implements Pylon::IImage. + virtual bool IsUnique() const; + + // Implements Pylon::IImage. + virtual bool GetStride( size_t& strideBytes ) const; + + // Implements Pylon::IReusableImage. + virtual bool IsSupportedPixelType( EPixelType pixelType ) const; + + // Implements Pylon::IReusableImage, always returns true. + virtual bool IsAdditionalPaddingSupported() const; + + + //Implements Pylon::IReusableImage + /*! + \brief Resets the image properties and creates a new Windows bitmap if required. + + \param[in] pixelType The pixel type of the new image. + \param[in] width The number of pixels in a row in the new image. + \param[in] height The number of rows in the new image. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The \c width value must be > 0 and < _I32_MAX. +
  • The \c height value must be > 0 and < _I32_MAX. +
+ + \post +
    +
  • If the previously referenced bitmap is also referenced by another pylon bitmap image, a new Windows bitmap is created. +
  • If the previously referenced bitmap is able to hold an image with the given properties, a new Windows bitmap is created. +
  • If no bitmap has been created before, a new Windows bitmap is created. +
+ + \error + Throws an exception when the preconditions are not met. + Throws an exception when no buffer with the required size could be allocated. + */ + virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation = ImageOrientation_BottomUp ); + + + // Implements Pylon::IReusableImage. + // attention: The bitmap handle must not be currently selected into a DC. Otherwise, the bitmap is not freed. + virtual void Release(); + + + /*! + \brief Get the handle of the windows bitmap. + + \attention The handle must not be freed using DeleteObject(). + The handle is invalid after calling Release(). + The handle may be invalid after calling Reset(). + + \return Returns the handle of the windows bitmap or NULL if the image is invalid. + + \error + Does not throw C++ exceptions. + */ + virtual operator HBITMAP() const; + + + /*! + \brief Detach the windows bitmap. + + \return Returns the handle of the windows bitmap or NULL if the image is invalid. + + \pre + IsUnique() must return true. No other image must reference the bitmap. + + \post +
    +
  • The image is invalid. +
  • The ownership of the bitmap goes to the caller who is responsible for deleting it. +
+ + \error + Does not throw C++ exceptions. + */ + virtual HBITMAP Detach(); + + private: + /// Not supported. + virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation ); + + // Internal use only. + class CPylonBitmapImageImpl; + CPylonBitmapImageImpl* m_pImpl; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PYLONBITMAPIMAGE_H_7767407 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonDataComponent.h b/Cigarette/Pylon6.2/include/pylon/PylonDataComponent.h new file mode 100644 index 0000000..d41ef57 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonDataComponent.h @@ -0,0 +1,352 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2020-2021 Basler AG +// http://www.baslerweb.com +// Author: DV, JS +//----------------------------------------------------------------------------- +/** +\file +\brief Contains a class to access one component of a multi-component grab result. +*/ + +#ifndef INCLUDED_PYLONDATACOMPONENT_H +#define INCLUDED_PYLONDATACOMPONENT_H + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include + + +namespace Pylon +{ + // Forward declaration + class CGrabResultPtr; + class GrabResult; + + /** + * \brief Lists the possible component types. + * + * Use this value to determine what kind of data is stored in a component. + * You can call Pylon::CPylonDataComponent::GetComponentType(). + */ + enum EComponentType + { + ComponentType_Undefined = 0x00, //!< The component type is not known or hasn't been set. + ComponentType_Intensity = 0x01, //!< Component contains intensity values + ComponentType_Range = 0x04, //!< Component contains range values + ComponentType_Confidence = 0x06 //!< Component contains confidence value + }; + + + /** + * \class CPylonDataComponent + * \brief Provides methods for accessing a single component of CPylonDataContainer. + * + * \copydetails Pylon::CPylonDataContainer + */ + class PYLONBASE_API CPylonDataComponent + { + public: + /*! + * \brief Creates an empty component. + * + * The default constructor will create an empty component. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + CPylonDataComponent(); + + /*! + * \brief Creates a copy of an existing component. + * + * \param rhs Source component to copy. + * + * When creating a copy of a component, only the reference to the data in the container is copied. + * The actual data pointed to by Pylon::CPylonDataComponent::GetData() will not be copied. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + CPylonDataComponent( const CPylonDataComponent& rhs ); + + /*! + * \brief Destroys a pylon data component object. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + ~CPylonDataComponent( ); + + /*! + * \brief Assigns the data of another component to this component by copying. + * + * \param rhs Source component to copy. + * + * When assigning a copy of a component, only the metadata is copied. + * The actual data pointed to by Pylon::CPylonDataComponent::GetData() will not be copied. + * + * \post + *
    + *
  • Any container previously referenced is released. + *
  • The container of the component passed is referenced. + *
  • No container is referenced if the component passed is invalid. + *
+ * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + CPylonDataComponent& operator=( const CPylonDataComponent& rhs ); + + /** + * \brief Provides a Pylon::IImage interface to the component. + * + * This cast operator allows passing the component to image format converters, + * save functions, or any other functions that require an IImage object. + * The returned image is invalid if the component is invalid or cannot be converted to an image. + * + * \attention The returned reference is only valid as long as the component is not destroyed. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + operator const Pylon::IImage& () const; + + /** + * \brief Can be used to check whether the component is valid. + * + * \return Returns false if the component does not contain valid data or hasn't been initialized yet. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + bool IsValid() const; + + + /** + * \brief Get the type of data this component contains. + * + * \return Returns the type of data in this component. See \c Pylon::EComponentType for values. + * + * Use this function to distinguish between different component types like + * intensity values or range values. See Pylon::EComponentType for values. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + EComponentType GetComponentType() const; + + + /** + * \brief Get the type of pixels this component contains. + * + * \return Returns an enumeration value describing the pixels in the component. See \c Pylon::EPixelType for values. + * If the component does not contain valid data or contains a unknown pixel format, \c PixelType_Unknown is returned. + * + * Use this function to determine how to interpret the data returned by \c Pylon::CPylonDataComponent::GetData(). + * \note Not all components contain pixel data. Only components of type + * ComponentType_Intensity, ComponentType_Range, and ComponentType_Confidence return a valid pixel type. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + EPixelType GetPixelType() const; + + + /** + * \brief Get the current number of columns. + * + * \return Returns the current number of columns or 0 if the component is invalid. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + uint32_t GetWidth() const; + + + /** + * \brief Get the current number of rows. + * + * \return Returns the current number of rows or 0 if the component is invalid. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + uint32_t GetHeight() const; + + + /** + * \brief Get the starting column. + * + * \return Returns the starting column. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + uint32_t GetOffsetX() const; + + + /** + * \brief Get the starting row. + * + * \return Returns the starting row. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + uint32_t GetOffsetY() const; + + + /** + * \brief Get the number of extra bytes at the end of each row. + * + * \return Returns the number of extra bytes at the end of each row. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + size_t GetPaddingX() const; + + + /** + * \brief Get the pointer to the data contained in the component. + * + * \return Returns a pointer to the data contained in the component. + * + * Use this pointer to access the data in this component. + * The size in bytes of the buffer can be obtained by calling Pylon::CPylonDataComponent::GetDataSize(). + * Call Pylon::CPylonDataComponent::GetPixelFormat() and other methods to determine how to interpret the data. + * + * \error + * Does not throw C++ exceptions. + */ + const void* GetData() const; + + + /** + * \brief Get the size of the buffer returned by Pylon::CPylonDataComponent::GetData(). + * + * \return Returns the size in bytes of the buffer returned by Pylon::CPylonDataComponent::GetData(). + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + size_t GetDataSize() const; + + + /** + * \brief Get the camera-specific time the data was created on the camera. + * + * \return Returns the camera-specific time the data was created on the camera + * or 0 if the time is not available. + * + * \note Timestamp generation is available only on some camera models. + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + uint64_t GetTimeStamp() const; + + + /** + * \brief Get the stride in bytes for the component. + * + * \param[out] strideBytes On successful return, the stride value can be read from this output parameter. + * + * \return Returns true if the stride could be computed successfully and is returned in the output parameter. + * Returns false if the preconditions are not met or the component doesn't contain valid data. + * If the function returns false, the value of strideBytes is undefined. + * + * This method uses \c Pylon::ComputeStride() to compute the component's stride value. + * The stride describes the amount of bytes to advance from one row to the next. + * + * \pre + *
    + *
  • The component type must be Pylon::ComponentType_Intensity, Pylon::ComponentType_Range, or Pylon::ComponentType_Confidence. + *
  • The preconditions of \c ComputeStride() must be met. + *
+ * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + bool GetStride( size_t& strideBytes ) const; + + protected: + class CPylonDataComponentImpl; + CPylonDataComponentImpl* m_pImpl; + }; + +} // namespace Pylon + +#endif // INCLUDED_PYLONDATACOMPONENT_H diff --git a/Cigarette/Pylon6.2/include/pylon/PylonDataContainer.h b/Cigarette/Pylon6.2/include/pylon/PylonDataContainer.h new file mode 100644 index 0000000..e2bee4a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonDataContainer.h @@ -0,0 +1,268 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2020-2021 Basler AG +// http://www.baslerweb.com +// Author: DV, JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains a class to access multi-component grab results +*/ + +#ifndef INCLUDED_PYLONDATACONTAINER_H +#define INCLUDED_PYLONDATACONTAINER_H + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + + + +namespace Pylon +{ + // Forward declaration + class CGrabResultPtr; + class GrabResult; + class CPylonDataComponent; + + /** + * \class CPylonDataContainer + * \brief Provides methods for accessing grab results consisting of multiple components. + * + * Some cameras can return complex grab results consisting of multiple components. + * For example, Basler blaze cameras return a data stream that is composed of range, intensity, + * and confidence components. + * To access the individual components, you can use the \c CPylonDataContainer class. + * + * A \c CPylonDataContainer can hold one or more components. + * You can obtain a container by calling \c Pylon::CGrabResultData::GetDataContainer(). + * You can then use the container to query for the number of components by calling \c Pylon::CGrabResultData::GetDataComponentCount(). + * To retrieve a specific component, you can call \c Pylon::CGrabResultData::GetDataComponent(). + * Each component in the container can be used to access the actual data, e.g., the range values, and its metadata. + * + * \attention Any \c CPylonDataContainer or \c CPylonDataComponent will hold a reference to the \c CGrabResultData + * from which it has been created. To allow the instant camera to reuse the \c CGrabResultData + * and prevent buffer underruns, you must destroy the \c CPylonDataContainer and all its \c CPylonDataComponent objects. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + class PYLONBASE_API CPylonDataContainer + { + public: + /** + * \brief Creates a \c CPylonDataContainer from a given \c CGrabResultPtr. + * \param ptrGrabResult The grab result to create a container from. + * + * Creates a \c CPylonDataContainer from a given \c CGrabResultPtr. + * The \c CPylonDataContainer instance created will hold a reference to the \c CGrabResultData from which it has been created. + * To allow the instant camera to reuse the grab result and prevent buffer underruns, + * you must destroy the \c CPylonDataContainer. + * + * \post + *
    + *
  • A new reference to the grab result passed in ptrGrabResult has been set. + *
+ * + * \error + * Does not throw an exception if the \c CGrabResultPtr was invalid or points to an invalid/unsuccessful result. + * Instead, an empty container is returned. + * Can throw exceptions if the data in the result is invalid or malformed. + * Can throw exceptions in low-memory conditions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + explicit CPylonDataContainer( const CGrabResultPtr& ptrGrabResult ); + + + /** + * \brief Creates a \c CPylonDataContainer from a given \c GrabResult. + * \param grabResult The grab result to create a container from. + * + * Creates a \c CPylonDataContainer from a given \c GrabResult. + * The \c CPylonDataContainer instance created is only valid as long as the associated buffer + * is not queued or deregistered and deleted. + * + * \error + * Does not throw an exception if the GrabResult contains an unsuccessful result. + * Instead, an empty container is returned. + * Can throw exceptions if the data in the buffer of the GrabResult is invalid or malformed. + * Can throw exceptions in low-memory conditions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + explicit CPylonDataContainer( const GrabResult& grabResult ); + + + /** + * \brief Creates a \c CPylonDataContainer by loading the data from the file passed. + * + * \copydetails Pylon::CPylonDataContainer::Load() + * + */ + explicit CPylonDataContainer( const Pylon::String_t& filename ); + + + /** + * \brief Creates an empty \c CPylonDataContainer. + * + * Creates an empty \c CPylonDataContainer. + * The \c CPylonDataContainer instance created will not be valid. + * + * \error + * Can throw exceptions in low-memory conditions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + CPylonDataContainer(); + + + /** + * \brief Creates a shallow copy of an existing \c CPylonDataContainer. + * \param rhs Container to copy from. + * + * \post + *
    + *
  • A new reference to the grab result or buffer of the container passed in rhs has been set. + *
+ * + * \error + * Can throw exceptions in low-memory conditions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + CPylonDataContainer( const CPylonDataContainer& rhs ); + + + /** + * \brief Destroys the \c CPylonDataContainer instance. If the instance has been created through a GrabResultPtr, + * the reference to that \c CGrabResultData will be released. + * + * \post + *
    + *
  • The reference to a grab result or buffer has been released. + *
+ * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + ~CPylonDataContainer(); + + + /** + * \brief Assigns a shallow copy of the \c CPylonDataContainer to this instance. + * \param rhs CPylonDataContainer to copy data from. + * \return Returns a reference to the current instance. + * + * \post + *
    + *
  • The reference to a previous grab result or buffer has been released. + *
  • A new reference to the grab result or buffer of the container passed in rhs has been set. + *
+ * + * \error + * Can throw exceptions in low-memory conditions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + CPylonDataContainer& operator=( const CPylonDataContainer& rhs ); + + + /** + * \brief Returns the number of components contained in the container. + * \return Returns the number of components contained in the container. + * + * You can use the return value to iterate over the existing components by calling \c Pylon::CPylonDataContainer::GetDataComponent(). + * + * \error + * Does not throw C++ exceptions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + size_t GetDataComponentCount() const; + + + /** + * \brief Returns a specific component from the container. + * \param index Index of the component to return. The index must be less than the value returned by \c Pylon::CPylonDataContainer::GetComponentCount(). + * \return Returns the component specified by the index parameter. + * + * \error + * Throws an exception if the index parameter is out of range. + * Can throw exceptions in low-memory conditions. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + const CPylonDataComponent GetDataComponent( const size_t index ) const; + + + /** + * \brief Saves the container to disk. + * \param filename Name and path of the file to save the container to. + * + * \pre + * The container must contain at least one component. + * + * \error + * Throws an exception if the container cannot be saved. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + void Save( const Pylon::String_t& filename ) const; + + /** + * \brief Loads a container from a file. + * \param filename Name and path of the file to load. + * + * Loads a container and all its components from a file on disk. + * + * \post + *
    + *
  • The reference to a previous grab result or buffer has been released. + *
  • A new buffer has been allocated to hold the data loaded. + *
+ * + * \error + * Throws an exception if the container cannot be read. + * Throws an exception if the contents of the file does not contain a valid container. + * + * \threading + * This class is not thread-safe. + * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly. + */ + void Load( const Pylon::String_t& filename ); + + private: + class CPylonDataContainerImpl; + CPylonDataContainerImpl* m_pImpl; + }; +} + +#endif // INCLUDED_PYLONDATACONTAINER_H diff --git a/Cigarette/Pylon6.2/include/pylon/PylonDeviceProxy.h b/Cigarette/Pylon6.2/include/pylon/PylonDeviceProxy.h new file mode 100644 index 0000000..cc9b87b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonDeviceProxy.h @@ -0,0 +1,407 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Pylon generic device interface declaration +*/ + + +#ifndef __PYLON_PYLONDEVICEPROXY__H__ +#define __PYLON_PYLONDEVICEPROXY__H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include "Device.h" +#include "TlFactory.h" + + +//! Macro to define a custom camera class +#define PYLON_DEFINE_CAMERA(ClassName, BaseClass) \ + PYLON_6_0_DEPRECATED("Use CBaslerUniversalInstantCamera") \ + class ClassName : public BaseClass \ + { \ + public: \ + /** \name Construction */ \ + /*@{*/ \ + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + */ \ + ClassName() \ + { \ + } \ + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + */ \ + ClassName( IPylonDevice* pDevice, bool takeOwnership = true ) : BaseClass( pDevice, takeOwnership ) \ + { \ + } \ + /** \brief \copybrief Pylon::CPylonDeviceProxyT::~CPylonDeviceProxyT() + \copydetails Pylon::CPylonDeviceProxyT::~CPylonDeviceProxyT() + */ \ + virtual ~ClassName() \ + { \ + } \ + /*@}*/ \ + }; + + + namespace Pylon + { + //************************************************************************************************** + //! Low Level API: The camera class for generic camera devices + /** + This is the base class for pylon camera classes providing access to camera parameters. + \see \ref configuringcameras + + \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file) + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + template + class CPylonDeviceProxyT : public TCameraParams + { + public: + //! \name Construction + // \{ + + //! Creates a camera object that is not attached to an pylon device. Use the Attach() method to attach the device + CPylonDeviceProxyT(); + + /** \brief Creates a camera object and attaches a camera object to a pylon device that takes the ownership over an pylon device. + + When having the ownership, the destructor of this camera object destroys the pylon device + the camera object is attached to. Otherwise, the pylon device object remains valid when the camera + object has been destroyed. + */ + CPylonDeviceProxyT( IPylonDevice*, bool takeOwnership = true ); + + //! Destructor + virtual ~CPylonDeviceProxyT(); + + //\} + + + private: + //! \name Assignment and copying is not supported + // \{ + CPylonDeviceProxyT( const CPylonDeviceProxyT& ); + CPylonDeviceProxyT& operator=( const CPylonDeviceProxyT& ); + // \} + + + public: + //! \name Some smart pointer functionality + // \{ + + /** \brief Attach the camera object to a pylon device + + It is not allowed to call Attach when the camera object is already attached! + + When having the ownership, the destructor of this camera object destroys the pylon device + the camera object is attached to. Otherwise, the pylon device object remains valid when the camera + object has been destroyed. + */ + virtual void Attach( IPylonDevice*, bool takeOwnership = true ); + + //! Checks if a pylon device is attached to the camera object + virtual bool IsAttached() const; + + //! Checks if the camera object has the ownership of the pylon device + virtual bool HasOwnership() const; + + //! Returns the pylon device interface pointer + virtual IPylonDevice* GetDevice() const; + + // \} + + + public: + //! \name Implementation of the IPylonDevice interface. + //! See Pylon::IPylonDevice for more details. + // \{ + + /** \brief \copybrief Pylon::IPylonDevice::Open() + + \copydetails Pylon::IPylonDevice::Open() + */ + void Open( AccessModeSet mode = (Stream | Control | Event) ) + { + CheckDevicePtr(); + m_pDevice->Open( mode ); + } + + /** \brief \copybrief Pylon::IPylonDevice::Close() + + \copydetails Pylon::IPylonDevice::Close() + */ + void Close( void ) + { + CheckDevicePtr(); + m_pDevice->Close(); + } + + /** \brief \copybrief Pylon::IPylonDevice::IsOpen() + + \copydetails Pylon::IPylonDevice::IsOpen() + */ + bool IsOpen( void ) const + { + CheckDevicePtr(); + return m_pDevice->IsOpen(); + } + + /** \brief \copybrief Pylon::IPylonDevice::AccessMode() + + \copydetails Pylon::IPylonDevice::AccessMode() + */ + AccessModeSet AccessMode( void ) const + { + CheckDevicePtr(); + return m_pDevice->AccessMode(); + } + + /** \brief \copybrief Pylon::IPylonDevice::GetDeviceInfo() + + \copydetails Pylon::IPylonDevice::GetDeviceInfo() + */ + const CDeviceInfo& GetDeviceInfo( void ) const + { + CheckDevicePtr(); + return m_pDevice->GetDeviceInfo(); + } + + + /** \brief \copybrief Pylon::IPylonDevice::GetNumStreamGrabberChannels() + + \copydetails Pylon::IPylonDevice::GetNumStreamGrabberChannels() + */ + uint32_t GetNumStreamGrabberChannels( void ) const + { + CheckDevicePtr(); + return m_pDevice->GetNumStreamGrabberChannels(); + } + + /** \brief \copybrief Pylon::IPylonDevice::GetStreamGrabber() + + \copydetails Pylon::IPylonDevice::GetStreamGrabber() + */ + IStreamGrabber* GetStreamGrabber( uint32_t index ) + { + CheckDevicePtr(); + return m_pDevice->GetStreamGrabber( index ); + } + + /** \brief \copybrief Pylon::IPylonDevice::GetEventGrabber() + + \copydetails Pylon::IPylonDevice::GetEventGrabber() + */ + IEventGrabber* GetEventGrabber( void ) + { + CheckDevicePtr(); + return m_pDevice->GetEventGrabber(); + } + + /** \brief \copybrief Pylon::IPylonDevice::GetNodeMap() + + \copydetails Pylon::IPylonDevice::GetNodeMap() + */ + GENAPI_NAMESPACE::INodeMap* GetNodeMap( void ) + { + CheckDevicePtr(); + return m_pDevice->GetNodeMap(); + } + + /** \brief \copybrief Pylon::IPylonDevice::GetTLNodeMap() + + \copydetails Pylon::IPylonDevice::GetTLNodeMap() + */ + GENAPI_NAMESPACE::INodeMap* GetTLNodeMap( void ) + { + CheckDevicePtr(); + return m_pDevice->GetTLNodeMap(); + } + + /** \brief \copybrief Pylon::IPylonDevice::CreateChunkParser() + + \copydetails Pylon::IPylonDevice::CreateChunkParser() + */ + Pylon::IChunkParser* CreateChunkParser( void ) + { + CheckDevicePtr(); + return m_pDevice->CreateChunkParser(); + } + + /** \brief \copybrief Pylon::IPylonDevice::DestroyChunkParser() + + \copydetails Pylon::IPylonDevice::DestroyChunkParser() + */ + void DestroyChunkParser( Pylon::IChunkParser* pChunkParser ) + { + CheckDevicePtr(); + m_pDevice->DestroyChunkParser( pChunkParser ); + } + + + /** \brief \copybrief Pylon::IPylonDevice::CreateEventAdapter() + + \copydetails Pylon::IPylonDevice::CreateEventAdapter() + */ + IEventAdapter* CreateEventAdapter( void ) + { + CheckDevicePtr(); + return m_pDevice->CreateEventAdapter(); + } + + /** \brief \copybrief Pylon::IPylonDevice::DestroyEventAdapter() + + \copydetails Pylon::IPylonDevice::DestroyEventAdapter() + */ + void DestroyEventAdapter( IEventAdapter* pAdapter ) + { + CheckDevicePtr(); + m_pDevice->DestroyEventAdapter( pAdapter ); + } + + /** \brief \copybrief Pylon::IPylonDevice::CreateSelfReliantChunkParser() + + \copydetails Pylon::IPylonDevice::CreateSelfReliantChunkParser() + */ + virtual ISelfReliantChunkParser* CreateSelfReliantChunkParser() + { + CheckDevicePtr(); + return m_pDevice->CreateSelfReliantChunkParser(); + } + + /** \brief \copybrief Pylon::IPylonDevice::DestroySelfReliantChunkParser() + + \copydetails Pylon::IPylonDevice::DestroySelfReliantChunkParser() + */ + virtual void DestroySelfReliantChunkParser( ISelfReliantChunkParser* pChunkParser ) + { + CheckDevicePtr(); + m_pDevice->DestroySelfReliantChunkParser( pChunkParser ); + } + + /** \brief \copybrief Pylon::IPylonDevice::RegisterRemovalCallback() + + \copydetails Pylon::IPylonDevice::RegisterRemovalCallback() + */ + DeviceCallbackHandle RegisterRemovalCallback( DeviceCallback& d ) + { + CheckDevicePtr(); + return m_pDevice->RegisterRemovalCallback( d ); + } + + /** \brief \copybrief Pylon::IPylonDevice::DeregisterRemovalCallback() + + \copydetails Pylon::IPylonDevice::DeregisterRemovalCallback() + */ + bool DeregisterRemovalCallback( DeviceCallbackHandle h ) + { + CheckDevicePtr(); + return m_pDevice->DeregisterRemovalCallback( h ); + } + + // \} + + + protected: + void CheckDevicePtr() const + { + if (NULL == m_pDevice) + { + throw LOGICAL_ERROR_EXCEPTION( "The camera class is not attached to a IPylonDevice" ); + } + } + + IPylonDevice* m_pDevice; + bool m_hasOwnership; + }; + + + //************************************************************************************************** + // CPylonDeviceProxyT implementation + //************************************************************************************************** + + template + inline CPylonDeviceProxyT::CPylonDeviceProxyT( void ) + : m_pDevice( NULL ) + , m_hasOwnership( false ) + { + } + + template + inline CPylonDeviceProxyT::CPylonDeviceProxyT( IPylonDevice* pDevice, bool takeOwnership ) + : m_pDevice( NULL ) + , m_hasOwnership( false ) + { + Attach( pDevice, takeOwnership ); + } + + template + inline CPylonDeviceProxyT::~CPylonDeviceProxyT( void ) + { + if (HasOwnership() && IsAttached()) + { + CTlFactory::GetInstance().DestroyDevice( m_pDevice ); + } + } + + template + inline void CPylonDeviceProxyT::Attach( IPylonDevice* pDevice, bool takeOwnership ) + { + if (IsAttached()) + { + throw LOGICAL_ERROR_EXCEPTION( "Object is already attached to a pylon device" ); + } + + if (NULL == pDevice) + { + throw LOGICAL_ERROR_EXCEPTION( "Tried to attach a NULL pointer as device" ); + } + + TCameraParams::_Initialize( pDevice->GetNodeMap() ); + + m_pDevice = pDevice; + m_hasOwnership = takeOwnership; + } + + template + inline bool CPylonDeviceProxyT::IsAttached() const + { + return NULL != m_pDevice; + } + + template + inline bool CPylonDeviceProxyT::HasOwnership() const + { + return m_hasOwnership; + } + + template + inline IPylonDevice* CPylonDeviceProxyT::GetDevice() const + { + return m_pDevice; + } + + + } // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/PylonGUI.h b/Cigarette/Pylon6.2/include/pylon/PylonGUI.h new file mode 100644 index 0000000..4caf47c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonGUI.h @@ -0,0 +1,385 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: NN +//----------------------------------------------------------------------------- +/*! +\file +\brief Implements a simple window to show a pylon Image. + +To use the pylon GUI classes and functions you should not include this file directly. +Instead, you should include \c pylon/PylonGUIIncludes.h. +*/ + +#ifndef PYLON_GUI_H_INCLUDED__ +#define PYLON_GUI_H_INCLUDED__ + +#include + +#pragma pack(push, PYLON_PACKING) + +#include + +#ifdef PYLONGUI_EXPORTS +# define PYLONGUI_API APIEXPORT +#else +# define PYLONGUI_API APIIMPORT + +# ifndef PYLON_NO_AUTO_IMPLIB +# pragma comment(lib, PYLON_LIB_NAME( "PylonGUI" )) +# endif +#endif + + +#if defined(__cplusplus) + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + // forwards + interface IImage; + + /////////////////////////////////////////////////////////////////////// + // convenience function to show an image in one row + + /*! + \brief Convenience function to display an image on screen with one function call. + + \param[in] winIndex The window used for displaying the image. Valid window indexes range from 0 to 31. + \param[in] image The image to display in the window, specified in winIndex. + You can also pass a CGrabResultPtr. + + This convenience function displays the image or grab result passed in the \a image parameter in a window on the screen. + Using this function is the easiest way to display an image on the screen. + + You can pass any IImage based object or a GrabResultPtr. If the window hasn't been created before, it will be created with default positions and the image will be shown. + When the function returns, you can free/delete the image. + If you need more control over the window creation (e.g. to specify the position or size of the window), you can use the CPylonImageWindow class. + + When you pass an empty/invalid (e.g. image.IsValid() returns false) image, the window will be cleared. + + \code + // This smart pointer will receive the grab result data. + CGrabResultPtr ptrGrabResult; + // Open the first device. + CInstantCamera Camera( CTlFactory::GetInstance().CreateFirstDevice()); + // Grab one image. + Camera.GrabOne( 1000, ptrGrabResult); + // Display the image on the screen. If the grab result is invalid, the image window will be empty. + Pylon::DisplayImage(1, ptrGrabResult); + \endcode + + \post +
    +
  • The window specified by \a winIndex will be created and shown on the screen. +
  • If the passed image is valid, it is shown in the window specified by \a winIndex. +
  • If the passed image is invalid, the window specified by \a winIndex will be cleared. +
+ + \remark + To use this function, you must explicitly include \c pylon/PylonGUIIncludes.h in your code. + Unlike other pylon headers, the GUI headers will not be included automatically when you include \c pylon/PylonIncludes.h. + + \error + Can throw an exception if the passed winIndex is invalid or the window could not be created. + + \threading + This function is thread-safe. + */ + PYLONGUI_API void DisplayImage( size_t winIndex, const Pylon::IImage& image ); + + + + /*! + \class CPylonImageWindow + \brief Class to manage a pylon image window. + + Use this class to manage a pylon image window. + + To diplay an image, you need to create and show it first. You can the call SetImage() to let the window display any %Pylon image. The following snippet shows how to do this: + + \code + CPylonImageWindow win; + // Create the window with winIndex = 1 using default position and size. + // The window will not be visible until Show() has been called. + win.Create(1); + // Set the contents of the window. + win.SetImage(myImage); + // Make the window visible on the screen. + win.Show(); + \endcode + + If the user closes the window, it will only be hidden and not truly closed. You can call Show() to make it visible again. + The window will be closed (destroyed) when you call Close(). + The destructor automatically closes (i.e destroys) the window. To prevent this, you can call Detach() before the object is destroyed. + All windows will be closed when PylonTerminate() is called. + + \remark The easiest way to display an image on screen is to use the DisplayImage() global function. + + \remark + To use this class, you must explicitly include \c pylon/PylonGUIIncludes.h in your code. + Unlike other pylon headers, the GUI headers will not be included automatically when you include \c pylon/PylonIncludes.h. + + */ + class PYLONGUI_API CPylonImageWindow + { + public: + /////////////////////////////////////////////////////////////////////// + /*! + \brief Creates an empty CPylonImageWindow object. To actuall create the window, you must call Create() + + \error + Does not throw C++ exceptions. + */ + CPylonImageWindow( void ); + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Destroys a CPylonImageWindow object. If the window hasn't been closed, it will be closed. + + \error + Does not throw C++ exceptions. + + \threading + This function is thread-safe. + */ + ~CPylonImageWindow( void ); + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Returns the window handle (HWND) for the image window. + + Returns the native window handle of the image window. + The handle will become invalid after Close() has been called. + + \return Returns the native window handle (HWND) for the image window. + + \error + Throws an exception if the window hasn't been created yet or the window has been already closed. + + \threading + This function is thread-safe. + */ + HWND GetWindowHandle() const; + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Returns the window index handled by this object. + + The index will become valid if you call Create() or Attach(). + The index will become invalid when you call Close() or Detach(). + Valid window indexes range from 0 to 31. + + \return Returns the window index stored in this object. + + \error + Does not throw C++ exceptions. + + \threading + This function is thread-safe. + + \sa IsValid() + */ + size_t GetWindowIndex( void ) const + { + return m_winIndex; + } + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Returns true if the object holds a valid window index. + + Returns true if the object holds a valid window index + + \return Returns \a true if the objects holds a valid window index. Otherwise, \a false is returned. + + \error + Does not throw C++ exceptions. + + \threading + This function is thread-safe. + */ + bool IsValid( void ) const; + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Attaches the window index passed in \a winIndex to this object. + + \param[in] winIndex The new window index to attach to this object. Valid window indexes range from 0 to 31. + + \error + Throws an exception if the object already holds a valid window index. If you want to reuse an existing object, you should call Detach() or Close() to clear the object. + + \threading + This function is thread-safe. + */ + void Attach( size_t winIndex ); + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Detaches the window index from this object and returns the window index previously stored in the object. + + Detaches the window index from this object and returns the window index previously stored in the object. + After this function returns the state of the object will be invalid. + + You can call this function to prevent the window being closed when the CPylonImageWindow is destroyed. + If you don't close a CPylonImageWindow, it will be closed automatically when PylonTerminate() is called. + + \return Returns the current window index. If no window index is stored, invalidWinIndex will be returned. + + \error + Does not throw C++ exceptions. + + \threading + This function is thread-safe. + */ + size_t Detach( void ); + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Creates a window for index passed in \a winIndex. + + Creates a window for the index passed in \a winIndex. If there is already an existing window with \a winIndex, an exception will be thrown. + + When you pass the \a CPylonImageWindow::useDefault for the \a x parameter, the window will be shown at the same position and with the same size as the previous one before it was closed. + Otherwise, the position and size parameters are passed directly to the CreateWindow() function of the Windows API. + + When the function returns successfully, the window has been created but is not visible. You must call Show() to make the window visible. + + \param[in] winIndex The window used for displaying the image. Valid window indexes range from 0 to 31. + \param[in] x The x-coordinate of the upper-left corner of the window in screen coordinates. + You can pass the CPylonImageWindow::useDefault value to create the window at the same position as the previous one before it was closed. The other position parameters will be ignored. + If the window is shown the very first time the system select a default position and size for the window. + \param[in] y The y-coordinate of the upper-left corner of the window in screen-coordinates. + \param[in] nWidth The width of the window in screen coordinates. + \param[in] nHeight The height of the window in screen coordinates. + + \error +
    +
  • Will throw an exception if an invalid \a winIndex is passed. +
  • Will throw an exception if the a window with the specified window index already exists. +
+ + \threading + This function is thread-safe. + */ + void Create( size_t winIndex, int x = useDefault, int y = useDefault, int nWidth = useDefault, int nHeight = useDefault ); + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Shows or hides the image window. + + This function calls ShowWindow from the Windows API. + You can pass the same values for the \a nShow parameter as described in the official documentation for ShowWindow() + The default value \a nShowDefault (which equals SW_SHOW) will show the window in its current state and position. + + When the user closes the window it will be hidden, but not destroyed. You can call Show() to make it visible again. + + \remark After you create a window using Create() it will be invisible. You must call Show() to make the window visible. + + \error + Throws an exception if the window hasn't been created yet and the object doesn't hold a valid window index. + + \threading + This function is thread-safe. + */ + void Show( int nShow = showDefault ) const; + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Hides the image window. + + This is a convenience function to hide the window. It will call Show(SW_HIDE) + + \error + Throws an exception if the window hasn't been created yet and the object doesn't hold a valid window index. + + \threading + This function is thread-safe. + + \sa Show() + */ + void Hide( void ) const; + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Closes and destroys the window. + + Closes and destroys the window. + When the function returns successfully, the object will be invalid and the stored window index will be set to invalid. + + If you don't close a CPylonImageWindow, it will be closed automatically when PylonTerminate() is called. + + \remark If you just want to hide the window from the user you should call Hide() instead. + + \error + Does not throw C++ exceptions. + + \threading + This function is thread-safe. + */ + bool Close( void ); + + + /////////////////////////////////////////////////////////////////////// + /*! + \brief Sets the contents of the image window. + + Use this function to set the image shown in the window. + You can pass any IImage based object (like CPylonImage or CPylonBitmapImage). + You can also pass a GrabResultPtr object as it will convert its contents automatically to an IImage. + + If you pass an empty or invalid image the contents of the image window will be cleared. + + \param[in] image The image to display in the window. + + \error + Throws an exception if the window hasn't been created yet and the object doesn't hold a valid window index. + + \threading + This function is thread-safe. + */ + void SetImage( const Pylon::IImage& image ); //accepts also CGrabResultPtr + + public: + /// Default value for window position/size when calling Create() + static const int useDefault = static_cast(0x80000000); // CW_USEDEFAULT + /// Default value for window position/size when calling Show() + static const int showDefault = 5; // SW_SHOW + + protected: + /// Invalid window index. + static const size_t invalidWinIndex = static_cast(-1); + + /// The window index managed by this object. Valid window indexes range from 0 to 31. If no window is currently managed, invalidWinIndex will be stored. + size_t m_winIndex; + + protected: + // no copy + CPylonImageWindow( const CPylonImageWindow& ); + CPylonImageWindow& operator=( const CPylonImageWindow& ); + }; + +/** + * @} + */ +} + +#endif /* __cplusplus */ + +#pragma pack(pop) + +#endif /* PYLON_GUI_H_INCLUDED__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonGUIIncludes.h b/Cigarette/Pylon6.2/include/pylon/PylonGUIIncludes.h new file mode 100644 index 0000000..2a42580 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonGUIIncludes.h @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: NN +//----------------------------------------------------------------------------- +/*! +\file +\brief Master include for Pylon GUI. +If you intend to use the GUI classes and functions you must include this file explicitly. +This file will \e not be included automatically when you include pylon/PylonIncludes.h. + +\sa \link Pylon::CPylonImageWindow CPylonImageWindow \endlink +\sa \link Pylon::DisplayImage DisplayImage \endlink +*/ + +#ifndef PYLON_GUI_INCLUDEDS_H_INCLUDED__ +#define PYLON_GUI_INCLUDEDS_H_INCLUDED__ + +#include +#include + +#include + +// Add the lib to the linkers input libraries. +#if defined(_MSC_VER) && defined(PYLON_WIN_BUILD) +# ifndef PYLON_NO_AUTO_IMPLIB +# pragma comment(lib, PYLON_LIB_NAME( "PylonGUI" )) +# endif +#endif + +#endif // PYLON_GUI_INCLUDEDS_H_INCLUDED__ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonImage.h b/Cigarette/Pylon6.2/include/pylon/PylonImage.h new file mode 100644 index 0000000..3c8543c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonImage.h @@ -0,0 +1,551 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains an image class. +*/ + +#ifndef INCLUDED_PYLONIMAGE_H_6241114 +#define INCLUDED_PYLONIMAGE_H_6241114 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include + +namespace Pylon +{ + // Forward references. + class CGrabResultPtr; + + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /*! + \class CPylonImage + \brief Describes an image. + +
    +
  • Automatically handles size and lifetime of the image buffer. +
  • Allows to take over a buffer of grab result which is preventing its reuse as long as required. +
  • Allows to connect user buffers or buffers provided by third party software packages. +
  • Provides methods for loading and saving an image in different file formats. +
  • Serves as the main target format for the image format converter \c CImageFormatConverter. +
  • Eases working with planar images. +
  • Eases extraction of AOIs, e.g. for thumbnail images of defects. +
+ + \par Buffer Handling: + The buffer that is automatically created by the CPylonImage class or a hosted grab result buffer are replaced by a larger buffer if required. + The size of the allocated buffer is never decreased. + Referenced user buffers are never automatically replaced by a larger buffer. + Referenced grab result buffers are never reused. See the Reset() method for more details. + The Release() method can be used to detach a user buffer, release a hosted grab result buffer or to free an allocated buffer. + + \threading + The CPylonImage class is not thread-safe. + */ + class PYLONUTILITY_API CPylonImage : public CPylonImageBase + { + public: + typedef void (*DeleteNotifyFunction_t) (void*); + + public: + + /*! + \brief Creates an invalid image. + + See Pylon::IImage on how the properties of an invalid image are returned. + + \error + Does not throw C++ exceptions. + */ + CPylonImage(); + + + /*! + \brief Copies the image properties and creates a reference to the buffer of the source image. + + \param[in] source The source image. + + \post +
    +
  • Another reference to the source image buffer is created. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Does not throw C++ exceptions. + */ + CPylonImage( const CPylonImage& source ); + + + /*! + \brief Destroys a pylon image object. + + \error + Does not throw C++ exceptions. + */ + virtual ~CPylonImage(); + + + /*! + \brief Copies the image properties and creates a reference to the buffer of the source image. + + \param[in] source The source image. + + \post +
    +
  • Another reference to the source image buffer is created. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Does not throw C++ exceptions. + */ + virtual CPylonImage& operator= ( const CPylonImage& source ); + + + /*! + \brief Creates an image and allocates a buffer for it. + + \param[in] pixelType The pixel type of the new image. + \param[in] width The number of pixels in a row in the new image. + \param[in] height The number of rows in the new image. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The pixel type must be valid. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
+ + \error + Throws an exception when the parameters are invalid. + Throws an exception when no buffer with the required size could be allocated. + */ + static CPylonImage Create( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX = 0, EImageOrientation orientation = ImageOrientation_TopDown ); + + + /*! + \brief Copies the image data from a different image. + + This method is used for making a full copy of an image. + Calls the Reset() method to set the same image properties as the source image and + copies the image data. + + \param[in] image The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + + \pre + The preconditions of the Reset() method must be met. + + + \post +
    +
  • The image contains a copy of the image data contained by the source image. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Throws an exception when no buffer with the required size could be allocated. + Throws an exception when the preconditions of the Reset() method are not met. + */ + virtual void CopyImage( const IImage& image ); + + + /*! + \brief Copies the image data from a different image and changes the padding while copying. + + This method is used for making a full copy of an image except for changing the padding. + Calls the Reset() method to set the same image properties as the source image and + copies the image data. + This method is useful in combination with the GetAoi() method. + + \param[in] image The source image, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \param[in] newPaddingX The number of extra data bytes at the end of each row. + + \pre +
    +
  • The preconditions of the Reset() method must be met. +
  • The rows of the source image must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked(). +
  • The rows of the newly created image must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked(). +
+ + \post +
    +
  • The image contains a copy of the image data contained by the source image. +
  • The line padding is adjusted. +
  • The byte aligned row padding area is set to zero. +
  • Creates an invalid image if the source image is invalid. +
+ + \error + Throws an exception when no buffer with the required size could be allocated. + Throws an exception when the preconditions of the Reset() method are not met. + */ + virtual void CopyImage( const IImage& image, size_t newPaddingX ); + + + /*! + \brief Copies the image data from a provided buffer. + + This method is used for making a full copy of an image. + Calls the Reset() method to set the same image properties as the source image and + copies the image data. + + \param[in] pBuffer The pointer to the buffer of the source image. + \param[in] bufferSizeBytes The size of the buffer of the source image. + \param[in] pixelType The pixel type of the source image. + \param[in] width The number of pixels in a row in the source image. + \param[in] height The number of rows in the source image. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The pixel type must be valid. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
  • The pointer to the source buffer must not be NULL. +
  • The source buffer must be large enough to hold the image described by the parameters. +
  • The preconditions of the Reset() method must be met. +
+ + \post A copy of the image contained by the source image buffer is made. + + \error + Throws an exception when no buffer with the required size could be allocated. + Throws an exception when the preconditions of the Reset() method are not met. + */ + virtual void CopyImage( + void* pBuffer, + size_t bufferSizeBytes, + EPixelType pixelType, + uint32_t width, + uint32_t height, + size_t paddingX, + EImageOrientation orientation = ImageOrientation_TopDown ); + + /*! + \brief Attaches a grab result buffer using additional hints. + + This allows to display grabbed data in a user-defined way. + + \param[in] grabResult The source buffer. + \param[in] pixelType The pixel type of the source image. + \param[in] width The number of pixels in a row in the source image. + \param[in] height The number of rows in the source image. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The \c grabResult must be valid. +
  • The \c pixelType must be valid. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
+ + \post +
    +
  • The image properties are taken from the \c width, \c height, \c pixelType, \c paddingX and \c orientation parameters. +
  • The grab result buffer is used by the image class. +
  • Another reference to the grab result buffer is created. This prevents the buffer's reuse for grabbing. +
+ + \error + Throws an exception if the preconditions are not met. + Throws an exception if the buffer size of the grabresult is too small for an image with the given parameters. + */ + virtual void AttachGrabResultBufferWithUserHints( + const CGrabResultPtr& grabResult, + EPixelType pixelType, + uint32_t width, + uint32_t height, + size_t paddingX, + EImageOrientation orientation = ImageOrientation_TopDown ); + + /*! + \brief Attaches a grab result buffer. + + \param[in] grabResult The source image represented by a grab result. + + \post +
    +
  • The image properties are taken from the grab result. +
  • The grab result buffer is used by the image class. +
  • Another reference to the grab result buffer is created. This prevents the buffer's reuse for grabbing. +
  • Creates an invalid image if the \c grabResult is invalid. +
  • Creates an invalid image if the grab was not successful. See CGrabResultData::GrabSucceeded(). +
+ + \error + Throws an exception when no buffer with the required size could be allocated. + Throws an exception when the preconditions of the Reset() method are not met. + */ + virtual void AttachGrabResultBuffer( const CGrabResultPtr& grabResult ); + + + /*! + \brief Attaches a user buffer. + + \param[in] pBuffer The pointer to the buffer of the source image. CPylonImage will never free any user buffers. + \param[in] bufferSizeBytes The size of the buffer of the source image. + \param[in] pixelType The pixel type of the source image. + \param[in] width The number of pixels in a row in the source image. + \param[in] height The number of rows in the source image. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + \param[in] pEventHandler A pointer to an optional CPylonImageUserBufferEventHandler-derived object + called when the user-supplied buffer is not used anymore. + You can use this to free the user-supplied buffer. + In case the function throws an exception, the handler will not be called. + + When attaching a user buffer and passing a pEventHandler, the user is responsible for ensuring the object is valid + until CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() has been called. + The user is also responsible to free the handler object after CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() + has been called. After the function has returned, CPylonImage won't access the object anymore. + See \c CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() for a sample. + + \pre +
    +
  • The pixel type must be valid. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
  • The pointer to the source buffer must not be NULL. +
  • The source buffer must be large enough to hold the image described by the parameters. +
  • The buffer passed in \c pBuffer must not be currently attached. +
+ + \post +
    +
  • The image properties are taken from the parameters passed. +
  • The user buffer is used by the image class. +
  • The user buffer must not be freed while being attached. +
+ + \error + Throws an exception if the preconditions are not met. In this case the an optional handler passed in \ pEventHandler will not be called. + */ + virtual void AttachUserBuffer( + void* pBuffer, + size_t bufferSizeBytes, + EPixelType pixelType, + uint32_t width, + uint32_t height, + size_t paddingX, + EImageOrientation orientation = ImageOrientation_TopDown, + CPylonImageUserBufferEventHandler* pEventHandler = NULL); + + + // Implements Pylon::IImage. + virtual bool IsValid() const; + + // Implements Pylon::IImage. + virtual EPixelType GetPixelType() const; + + // Implements Pylon::IImage. + virtual uint32_t GetWidth() const; + + // Implements Pylon::IImage. + virtual uint32_t GetHeight() const; + + // Implements Pylon::IImage. + virtual size_t GetPaddingX() const; + + // Implements Pylon::IImage. + virtual EImageOrientation GetOrientation() const; + + // Implements Pylon::IImage. + virtual void* GetBuffer(); + + // Implements Pylon::IImage. + virtual const void* GetBuffer() const; + + // Implements Pylon::IImage. + virtual size_t GetImageSize() const; + + // Implements Pylon::IImage. + virtual bool IsUnique() const; + + // Implements Pylon::IImage. + virtual bool GetStride( size_t& strideBytes ) const; + + // Implements Pylon::IReusableImage. + virtual bool IsSupportedPixelType( EPixelType pixelType ) const; + + // Implements Pylon::IReusableImage, always returns true. + virtual bool IsAdditionalPaddingSupported() const; + + + //Implements Pylon::IReusableImage + /*! + \brief Resets the image properties and allocates a new buffer if required. + + \param[in] pixelType The pixel type of the new image. + \param[in] width The number of pixels in a row in the new image. + \param[in] height The number of rows in the new image. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
  • If a user buffer is referenced then this buffer must not be referenced by another pylon image. See the IsUnique() and IsUserBufferAttached() methods. +
  • If a user buffer is referenced then this buffer must be large enough to hold the destination image. See the GetAllocatedBufferSize() and IsUserBufferAttached() methods. +
+ + \post +
    +
  • If the previously referenced buffer is a grab result buffer, a new buffer has been allocated. +
  • If the previously referenced buffer is also referenced by another pylon image, a new buffer has been allocated. +
  • If the previously referenced buffer is not large enough to hold an image with the given properties, a new buffer has been allocated. +
  • If no buffer has been allocated before, a buffer has been allocated. +
+ + \error + Throws an exception when the preconditions are not met. + Throws an exception when no buffer with the required size could be allocated. + */ + virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation = ImageOrientation_TopDown ); + + + // Implements Pylon::IReusableImage, user defined padding is always supported. + /*! + \brief Extends the Reset( EPixelType, uint32_t, uint32_t, EImageOrientation) method by settable paddingX. + \copydetails Reset( EPixelType, uint32_t, uint32_t, EImageOrientation) + \param[in] paddingX The number of extra data bytes at the end of each row. + */ + virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation = ImageOrientation_TopDown ); + + // Implements Pylon::IReusableImage. + virtual void Release(); + + /// Returns true if the referenced buffer has been provided by the user. + virtual bool IsUserBufferAttached() const; + + /// Returns true if the referenced buffer has been provided by a grab result. + virtual bool IsGrabResultBufferAttached() const; + + /*! + \brief Returns the size of the used buffer. + + This method is useful when working with so-called user buffers. + + \error + Does not throw C++ exceptions. + */ + virtual size_t GetAllocatedBufferSize() const; + + /*! + \brief Changes the pixel type of the image. + + \param[in] pixelType The new pixel type. + + \pre +
    +
  • Pylon::SamplesPerPixel( oldPixelType) == Pylon::SamplesPerPixel( newPixelType) +
  • Pylon::BitPerPixel( oldPixelType) == Pylon::BitPerPixel( newPixelType) +
+ + \error + Throws an exception when the new pixel type properties do not match the existing ones. + */ + virtual void ChangePixelType( EPixelType pixelType ); + + + /*! + \brief Creates a new pylon image for a plane of the image. No image data is copied. + + Use CopyImage( const IImage& image) to create a full copy. + + \code + copiedPlane.CopyImage( planarImage.GetPlane( 2)); + \endcode + + \param[in] planeIndex The zero based index of the plane. + \return A pylon image referencing a plane of the image. + + \pre + The value of planeIndex < Pylon::PlaneCount( GetPixelType()). + + \post +
    +
  • A reference to the same buffer is created. No image data is copied. +
  • The returned image has the Pylon::GetPlanePixelType( GetPixelType()) pixel type. +
  • If the image is not planar only index 0 is allowed. A call passing index 0 returns a copy of the image. No image data is copied. +
+ + \error + Throws an exception when the plane index is out of range. + */ + virtual CPylonImage GetPlane( size_t planeIndex ) const; + + + /*! + \brief Creates a new pylon image for an image area of interest (Image AOI) derived from the image. No image data is copied. + + Use CopyImage( const IImage& image, size_t newPaddingX) to create a full copy and to remove the additional padding. + + \code + copiedAoi.CopyImage( image.GetAoi( 80, 90, 100, 100), 0); + \endcode + + \param[in] topLeftX The x-coordinate of the top left corner of the image AOI in pixels. + \param[in] topLeftY The y-coordinate of the top left corner of the image AOI in pixels. + \param[in] width The width of the image AOI in pixels. + \param[in] height The height of the image AOI in pixels. + + \return A pylon image referencing an image AOI of the image. + + \pre +
    +
  • The image must be valid. +
  • The image AOI is located inside the image. +
  • The image is not in a planar format, see Pylon::IsPlanar(). Use GetPlane() first in this case. +
  • The rows of the image must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked(). +
  • The x-coordinate must be byte aligned. This may not be the case for packed pixel types. See Pylon::IsPacked(). +
  • The \c topLeftX parameter must be divisible by the return value of Pylon::GetPixelIncrementX() for the image's pixel type. +
  • The \c topLeftY parameter must be divisible by the return value of Pylon::GetPixelIncrementY() for the image's pixel type. +
+ + \post +
    +
  • A reference to the same buffer is created. The image data is not copied. +
  • The returned image uses the paddingX property to skip over image content outside of the image AOI. +
+ + \error + Throws an exception when the preconditions are not met. + */ + virtual CPylonImage GetAoi( uint32_t topLeftX, uint32_t topLeftY, uint32_t width, uint32_t height ) const; + + private: + // Internal use only. + class CPylonImageImpl; + CPylonImageImpl* m_pImpl; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PYLONIMAGE_H_6241114 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonImageBase.h b/Cigarette/Pylon6.2/include/pylon/PylonImageBase.h new file mode 100644 index 0000000..32139d5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonImageBase.h @@ -0,0 +1,193 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains the pylon image base class. +*/ + +#ifndef INCLUDED_PYLONIMAGEBASE_H_6835095 +#define INCLUDED_PYLONIMAGEBASE_H_6835095 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /*! + \class CPylonImageBase + \brief Provides basic functionality for pylon image classes. + */ + class PYLONUTILITY_API CPylonImageBase : public IReusableImage + { + public: + + /*! + \brief Saves the image to disk. Converts the image to a format that can be saved if required. + + This is a convenience method that calls CImagePersistence::Save(). + + If required, the image is automatically converted into a new image and saved afterwards. See + CImagePersistence::CanSaveWithoutConversion() for more information. + An image with a bit depth higher than 8 bit is stored with 16 bit bit depth, + if supported by the image file format. In this case the pixel data is MSB aligned. + + If more control over the conversion is required, the CImageFormatConverter class + can be used to convert the input image before saving it. + + \param[in] imageFileFormat File format to save the image in. + \param[in] filename Name and path of the image. + \param[in] pOptions Additional options. + + \pre + The pixel type of the image to be saved must be a supported input format of the Pylon::CImageFormatConverter. + + \error + Throws an exception if the saving of the image fails. + */ + virtual void Save( EImageFileFormat imageFileFormat, const String_t& filename, CImagePersistenceOptions* pOptions = NULL ) const; + + + /*! + \brief Loads an image from a disk. + + This is a convenience method that calls CImagePersistence::Load() + + \param[in] filename Name and path of the image. + + \pre + The image object must be able to hold the image format of the loaded image. + + \error + Throws an exception if the image cannot be loaded. The image buffer content is undefined when the loading of the image fails. + */ + virtual void Load( const String_t& filename ); + + + /*! + \brief Can be used to check whether the image can be saved without prior conversion. + + This is a convenience method that calls CImagePersistence::CanSaveWithoutConversion(). + + \param[in] imageFileFormat Target file format for the image to be saved. + \return Returns true, if the image can be saved without prior conversion. + + \error + Does not throw C++ exceptions. + */ + virtual bool CanSaveWithoutConversion( EImageFileFormat imageFileFormat ) const; + + /*! + \brief Retrieves the data of a pixel. + + \note This method is relativly slow. Do not use it for image processing tasks. + + \param[in] posX Horizontal position of the pixel. The first column has position 0. + \param[in] posY Vertical position of the pixel. The first row has position 0. + \return Returns the data of a pixel for supported pixel types. For unsupported pixel types pixel data of the SPixelData::PixelDataType_Unknown type is returned. + + \pre +
    +
  • The image must be valid. +
  • The pixel position defined by \c posX and \c posY must be located inside the image area. +
+ + Supported pixel types: +
    +
  • PixelType_Mono1packed +
  • PixelType_Mono2packed +
  • PixelType_Mono4packed +
  • PixelType_Mono8 +
  • PixelType_Mono8signed +
  • PixelType_Mono10 +
  • PixelType_Mono10packed +
  • PixelType_Mono10p +
  • PixelType_Mono12 +
  • PixelType_Mono12packed +
  • PixelType_Mono12p +
  • PixelType_Mono16 +
+
    +
  • PixelType_BayerGR8 +
  • PixelType_BayerRG8 +
  • PixelType_BayerGB8 +
  • PixelType_BayerBG8 +
  • PixelType_BayerGR10 +
  • PixelType_BayerRG10 +
  • PixelType_BayerGB10 +
  • PixelType_BayerBG10 +
  • PixelType_BayerGR12 +
  • PixelType_BayerRG12 +
  • PixelType_BayerGB12 +
  • PixelType_BayerBG12 +
  • PixelType_BayerGR12Packed +
  • PixelType_BayerRG12Packed +
  • PixelType_BayerGB12Packed +
  • PixelType_BayerBG12Packed +
  • PixelType_BayerGR10p +
  • PixelType_BayerRG10p +
  • PixelType_BayerGB10p +
  • PixelType_BayerBG10p +
  • PixelType_BayerGR12p +
  • PixelType_BayerRG12p +
  • PixelType_BayerGB12p +
  • PixelType_BayerBG12p +
  • PixelType_BayerGR16 +
  • PixelType_BayerRG16 +
  • PixelType_BayerGB16 +
  • PixelType_BayerBG16 +
+
    +
  • PixelType_RGB8packed +
  • PixelType_BGR8packed +
  • PixelType_RGBA8packed +
  • PixelType_BGRA8packed +
  • PixelType_RGB10packed +
  • PixelType_BGR10packed +
  • PixelType_RGB12packed +
  • PixelType_BGR12packed +
  • PixelType_RGB12V1packed +
  • PixelType_RGB16packed +
  • PixelType_RGB8planar +
  • PixelType_RGB10planar +
  • PixelType_RGB12planar +
  • PixelType_RGB16planar +
+
    +
  • PixelType_YUV422packed +
  • PixelType_YUV422_YUYV_Packed +
+ + \error + Throws an exception, if the preconditions are not met. + */ + virtual SPixelData GetPixelData( uint32_t posX, uint32_t posY ) const; + + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PYLONIMAGEBASE_H_6835095 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonImageUserBufferEventHandler.h b/Cigarette/Pylon6.2/include/pylon/PylonImageUserBufferEventHandler.h new file mode 100644 index 0000000..8fae38a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonImageUserBufferEventHandler.h @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2021-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the pylon image event handler base class. +*/ + +#pragma once + +#ifndef INCLUDED_PYLONIMAGEUSERBUFFEREVENTHANDLER_H_ +#define INCLUDED_PYLONIMAGEUSERBUFFEREVENTHANDLER_H_ + +#include + +#pragma pack(push, PYLON_PACKING) + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /** + \class CPylonImageUserBufferEventHandler + \brief The CPylonImage user buffer event handler base class. + + You can optionally pass an object derived from this class when calling CPylonImage::AttachUserBuffer(). + When the CPylonImage doesn't need the user buffer anymore, it will call the CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() + method. You can override this function to execute your custom code when the user buffer has been detached implicitly. + + The user is responsible for ensuring the object is valid until CPylonImageUserBufferEventHandler::OnPylonImageUserBufferDetached() has been called. + */ + class CPylonImageUserBufferEventHandler + { + public: + + /** + \brief This method is called after the image class has released its user buffer. + + This method is called after the image class releases its image buffer. + In case a user buffer has been attached using CPylonImage::AttachUserBuffer() you can use this to free + your user buffer. + + In case you created the event handler on the heap using \c new, you can call delete this at the end of the function. + + \code{.cpp} + // Sample handler to show how to delete the handler when allocating the handler on the heap. + class MyHandler : public CPylonImageUserBufferEventHandler { + OnPylonImageUserBufferDetached( void* pUserBuffer, size_t bufferSizeBytes ) override { + // Use our custom memory allocator to free the user buffer. + MyCustomFreeMemory( pUserBuffer ); + + // Delete the handler. + delete this; + } + }; + + // Use our custom memory allocator for pixel data. + void* pUserBuffer = MyCustomAllocateMemory( 640 * 480 ); + + // Attach user buffer using a heap-allocated event handler. + CPylonImage image; + image.AttachUserBuffer(pUserBuffer, (640 * 480), PixelType_Mono8, 640, 480, 0, ImageOrientation_TopDown, new MyHandler() ); + \endcode + + The default implementation does nothing. You can override this function to execute custom code. + + \param[in] pUserBuffer Pointer to the user buffer passed when the user buffer was attached using CPylonImage::AttachUserBuffer(). + \param[in] bufferSizeBytes Size of the user buffer passed when the user buffer was attached using CPylonImage::AttachUserBuffer(). + + \error + This function must not throw any exceptions. + */ + virtual void OnPylonImageUserBufferDetached( void* pUserBuffer, size_t bufferSizeBytes ) + { + PYLON_UNUSED( pUserBuffer ); + PYLON_UNUSED( bufferSizeBytes ); + } + }; + + /** + * @} + */ +} + +#pragma pack(pop) + +#endif /* INCLUDED_PYLONIMAGEUSERBUFFEREVENTHANDLER_H_ */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonIncludes.h b/Cigarette/Pylon6.2/include/pylon/PylonIncludes.h new file mode 100644 index 0000000..da22f08 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonIncludes.h @@ -0,0 +1,154 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Master include for Pylon +*/ + +#ifndef PYLONINCLUDES_H_INCLUDED__ +#define PYLONINCLUDES_H_INCLUDED__ + + +// PylonPlatform.h must be included before including any GenICam/GenApi header files, +// to ensure that the GENICAM_COMPILER_STR macro used by GenICam/GenApi is set properly +#include + +#include + +// basic types (from GenICam) +#include +#include +#include + +// GenICam stuff + +#if defined( PYLON_NO_AUTO_IMPLIB ) +# define GENICAM_NO_AUTO_IMPLIB +# define HAS_DEFINED_GENICAM_NO_AUTO_IMPLIB +#endif + +#ifdef PYLON_LINUX_BUILD +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wunknown-pragmas" +# pragma GCC diagnostic ignored "-Wpragmas" // gcc < 4.6 doesn't know the following pragma +# pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + +#if defined (PYLON_OSX_BUILD) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-variable" +# pragma clang diagnostic ignored "-Wunknown-pragmas" +#endif + +#include + +#if defined (PYLON_OSX_BUILD) +# pragma clang diagnostic pop +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wunknown-pragmas" +# pragma GCC diagnostic warning "-Wunused-but-set-variable" +# pragma GCC diagnostic warning "-Wpragmas" // gcc < 4.6 doesn't know the pragma +# endif +#endif + +#if defined( HAS_DEFINED_GENICAM_NO_AUTO_IMPLIB ) +# undef GENICAM_NO_AUTO_IMPLIB +# undef HAS_DEFINED_GENICAM_NO_AUTO_IMPLIB +#endif + + + +// basic macros +#include + + +// init functions +#include +#include + + +#include // IProperties interface and CInfoBase class +#include // CTlInfo +#include // DeviceClass definitions +#include // CDeviceInfo +#include // DeviceInfoList, TlInfoList +#include // IDeviceFactory +#include // ITransportLayer, CTransportLayerBase +#include // TlFactory + +#include // IEventAdapter +#include // Base_Callback1Body, Callback1, Function_CallbackBody, Member_CallbackBody, make_MemberFunctionCallback +#include // EDeviceAccessMode, AccessModeSet, IDevice, IPylonDevice, RegisterRemovalCallback + +#include // IStreamGrabber + +#include // EPixelType, EPixelColorFilter, several helper function for EPixelType +#include // Structs that describe the memory layout of pixel. +#include // CPixelTypeMapper, CCameraPixelTypeMapperT template maps device specific pixel formats to pylon pixel types. +#include // EGrabStatus, EPayloadType, GrabResult, EventResult +#include // PylonDataComponent to access for multi-component grab results +#include // PylonDataContainer to + + +#include // IChunkParser, CChunkParser + +#include // IEventGrabber +#include // CEventGrabberProxy + +#include // CNodeMapProxy + +#include +#include + +#include // CAcquireSingleFrameConfiguration +#include // CInstantCameraArray, includes CInstantCamera +#include // CAcquireContinuousConfiguration +#include // CSoftwareTriggerConfiguration + +#include // CInstantInterface, IInterface + +#include // Parameter classes + +////////////////////////////////////////////////////////////////////////////// +// add the PylonUntility headers +#ifndef PYLON_NO_UTILITY_INCLUDES +# include +#endif + + + +////////////////////////////////////////////////////////////////////////////// +// add the pylon libs +#if defined(PYLON_WIN_BUILD) +# ifndef PYLON_NO_AUTO_IMPLIB +# pragma comment(lib, PYLON_LIB_NAME( "PylonBase" )) +# endif + +#endif + +#include + +#endif //PYLONINCLUDES_H_INCLUDED__ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonLinkage.h b/Cigarette/Pylon6.2/include/pylon/PylonLinkage.h new file mode 100644 index 0000000..78b8959 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonLinkage.h @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file PylonLinkage.h +\brief Adds the pylon (and GenICam) libs to the linker comment record in the object file +*/ + +#ifndef PYLON_LINKAGE_H_INCLUDED_ +#define PYLON_LINKAGE_H_INCLUDED_ + +#pragma once + +// needed for COMPILER/COMPILER_STR +#include + +#if defined(PYLON_WIN_BUILD) + +#define PYLON_VERSION_SUFFIX "_v6_2" + +#if !defined(PYLON_BUILD_DEBUG) +# if !defined(GENICAM_USER_ALWAYS_LINK_RELEASE) +# define GENICAM_USER_ALWAYS_LINK_RELEASE +# endif +#endif + +// should be already included (needed for CONFIGURATION, GENICAM_COMPILER_STR) +#include +#include + + +////////////////////////////////////////////////////////////////////////////// +// create the Pylon suffix + +// The name consists of the following parts +// PylonBased.lib +// [ 1 ] [ 2 ] [ 3 ] +// [module ] [ suffix ] +// [ lib name ] +// 1 = module name +// 2 = configuration +// 3 = extension +#define PYLON_SUFFIX( config, extension ) config "." extension + +#if (defined(_DEBUG) || defined(DEBUG)) && defined(PYLON_BUILD_DEBUG) +# define PYLON_CONFIGURATION "d" +#else +# define PYLON_CONFIGURATION "" +#endif + +// generic +#define PYLON_LIB_SUFFIX PYLON_SUFFIX( PYLON_VERSION_SUFFIX PYLON_CONFIGURATION, "lib" ) +#define PYLON_DLL_SUFFIX PYLON_SUFFIX( PYLON_VERSION_SUFFIX PYLON_CONFIGURATION, "dll" ) + +// names for Transport Layer +#define PYLON_TL_LIB_SUFFIX PYLON_SUFFIX( PYLON_VERSION_SUFFIX PYLON_CONFIGURATION "_TL", "lib" ) +#define PYLON_TL_DLL_SUFFIX PYLON_SUFFIX( PYLON_VERSION_SUFFIX PYLON_CONFIGURATION "_TL", "dll" ) + + +////////////////////////////////////////////////////////////////////////////// +// +#define PYLON_LIB_NAME_NAKED( module ) module PYLON_SUFFIX( PYLON_CONFIGURATION, "lib" ) +#define PYLON_DLL_NAME_NAKED( module ) module PYLON_SUFFIX( PYLON_CONFIGURATION, "dll" ) + +#define PYLON_LIB_NAME( module ) module PYLON_SUFFIX( PYLON_VERSION_SUFFIX PYLON_CONFIGURATION, "lib" ) +#define PYLON_DLL_NAME( module ) module PYLON_SUFFIX( PYLON_VERSION_SUFFIX PYLON_CONFIGURATION, "dll" ) + +#define PYLON_TL_LIB_NAME( module ) module PYLON_TL_LIB_SUFFIX +#define PYLON_TL_DLL_NAME( module ) module PYLON_TL_DLL_SUFFIX + +#endif + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/PylonUtility.h b/Cigarette/Pylon6.2/include/pylon/PylonUtility.h new file mode 100644 index 0000000..74c2ab5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonUtility.h @@ -0,0 +1,44 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/* AH: intentionally omitted for doxygen documentation +\file +\brief Defines for the pylon utility library. +*/ +#ifndef PYLONUTILITY_H +#define PYLONUTILITY_H + + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + + +#ifdef PYLONUTILITY_EXPORTS +# define PYLONUTILITY_API APIEXPORT +#else +# define PYLONUTILITY_API APIIMPORT +#endif + +#if defined(PYLON_UTILITY_3_0_NO_DEPRECATE) +# define PYLON_UTILITY_3_0_DEPRECATED(message) +#else +# define PYLON_UTILITY_3_0_DEPRECATED(message) PYLON_DEPRECATED(message) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif + diff --git a/Cigarette/Pylon6.2/include/pylon/PylonUtilityIncludes.h b/Cigarette/Pylon6.2/include/pylon/PylonUtilityIncludes.h new file mode 100644 index 0000000..d6616fd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonUtilityIncludes.h @@ -0,0 +1,34 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Master include for the PylonUtility library +*/ + +#ifndef PYLONUTILITIESINCLUDES_H_INCLUDED__ +#define PYLONUTILITIESINCLUDES_H_INCLUDED__ + +#include +#include +#include +#include +#include +#include +#include +#if defined(PYLON_WIN_BUILD) +// windows only headers +# include +# include +#endif +#include + +#if defined (PYLON_WIN_BUILD) && !defined (PYLON_NO_AUTO_IMPLIB) +# include +# pragma comment(lib, PYLON_LIB_NAME( "PylonUtility" )) +#endif + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/PylonVersion.h b/Cigarette/Pylon6.2/include/pylon/PylonVersion.h new file mode 100644 index 0000000..33c83a8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonVersion.h @@ -0,0 +1,116 @@ +#pragma once + +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/** + * \file PylonVersion.h + * \ingroup Miscellaneous Files + * + * \brief Definition of the version info resource for the pylon project + * + */ +//----------------------------------------------------------------------------- + +// Set to 1/0 the following lines as appropriate. +#define PYLON_VERSION_PRERELEASE 0 +#define PYLON_VERSION_PRIVATEBUILD 0 + +/* Nothing below this point has to be modified to adjust version data. + *-------------------------------------------------------------------*/ + +#include + +#ifdef _DEBUG +#define PYLON_DEBUGSTRING " (debug)" +#else +#define PYLON_DEBUGSTRING "" +#endif + +#ifndef PYLON_FILE_DESCRIPTION +#if defined(PYLON_DRV) +#define PYLON_FILE_DESCRIPTION(name) #name " Device Driver\0" +#elif defined(PYLON_CPL) +#define PYLON_FILE_DESCRIPTION(name) #name " Control Panel\0" +#elif defined(PYLON_EXE) +#define PYLON_FILE_DESCRIPTION(name) #name " Application\0" +#else +#define PYLON_FILE_DESCRIPTION(name) #name " Module\0" +#endif +#endif + +#if PYLON_VERSION_PRIVATEBUILD +#define PYLON_FILE_FLAGS2 VS_FF_PRIVATEBUILD +#else +#define PYLON_FILE_FLAGS2 0 +#endif + +#ifdef _DEBUG +#define PYLON_FILE_FLAGS PYLON_FILE_FLAGS2|VS_FF_DEBUG +#elif PYLON_VERSION_PRERELEASE +#define PYLON_FILE_FLAGS PYLON_FILE_FLAGS2|VS_FF_PRERELEASE +#else +#define PYLON_FILE_FLAGS 0 +#endif + + +#if defined(PYLON_DRV) +#define PYLON_FILETYPE VFT_DRV +#define PYLON_FILESUBTYPE VFT2_DRV_INSTALLABLE +#define PYLON_ORIGINAL_FILENAME(name) #name ".sys\0" +#elif defined(PYLON_CPL) +#define PYLON_FILETYPE VFT_DLL +#define PYLON_FILESUBTYPE VFT2_UNKNOWN +#define PYLON_ORIGINAL_FILENAME(name) #name ".cpl\0" +#elif defined(PYLON_EXE) +#define PYLON_FILETYPE VFT_APP +#define PYLON_FILESUBTYPE VFT2_UNKNOWN +#define PYLON_ORIGINAL_FILENAME(name) #name ".exe\0" +#else +#define PYLON_FILETYPE VFT_DLL +#define PYLON_FILESUBTYPE VFT2_UNKNOWN +#define PYLON_ORIGINAL_FILENAME(name) #name ".dll\0" +#endif + +#ifndef PYLON_VERSIONSTRING_COMMENT +#define PYLON_VERSIONSTRING_COMMENT "" +#endif + + +#define PYLON_VERSION(name, priv) \ + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL \ + VS_VERSION_INFO VERSIONINFO \ + FILEVERSION PYLON_VERSION_MAJOR, PYLON_VERSION_MINOR, PYLON_VERSION_SUBMINOR, PYLON_VERSION_BUILD \ + PRODUCTVERSION PYLON_VERSION_MAJOR, PYLON_VERSION_MINOR, PYLON_VERSION_SUBMINOR, PYLON_VERSION_BUILD \ + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK \ + FILEFLAGS PYLON_FILE_FLAGS \ + FILEOS VOS_NT_WINDOWS32 \ + FILETYPE PYLON_FILETYPE \ + FILESUBTYPE PYLON_FILESUBTYPE \ + BEGIN \ + BLOCK "StringFileInfo" \ + BEGIN \ + BLOCK "000004b0" \ + BEGIN \ + VALUE "Comments", PYLON_VERSIONSTRING_COMMENT "\0" \ + VALUE "CompanyName", "Basler\0" \ + VALUE "FileDescription", PYLON_FILE_DESCRIPTION(name) "\0" \ + VALUE "FileVersion", PYLON_VERSIONSTRING_MAJOR "." PYLON_VERSIONSTRING_MINOR "." PYLON_VERSIONSTRING_SUBMINOR "." PYLON_VERSIONSTRING_BUILD PYLON_DEBUGSTRING "\0" \ + VALUE "InternalName", #name "\0" \ + VALUE "LegalCopyright", "Copyright (c) 2006-2021 Basler AG\0" \ + VALUE "LegalTrademarks", "\0" \ + VALUE "OLESelfRegister", "\0" \ + VALUE "OriginalFilename", PYLON_ORIGINAL_FILENAME(name) \ + VALUE "PrivateBuild", "\0" \ + VALUE "ProductName", "Basler pylon\0" \ + VALUE "ProductVersion", PYLON_VERSIONSTRING_MAJOR "." PYLON_VERSIONSTRING_MINOR "." PYLON_VERSIONSTRING_SUBMINOR "." PYLON_VERSIONSTRING_BUILD " " PYLON_VERSIONSTRING_EXTENSION PYLON_DEBUGSTRING "\0" \ + VALUE "SpecialBuild", #priv \ + END \ + END \ + BLOCK "VarFileInfo" \ + BEGIN \ + VALUE "Translation", 0x0000, 0x04b0 \ + END \ + END diff --git a/Cigarette/Pylon6.2/include/pylon/PylonVersionInfo.h b/Cigarette/Pylon6.2/include/pylon/PylonVersionInfo.h new file mode 100644 index 0000000..5974256 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonVersionInfo.h @@ -0,0 +1,193 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2009-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains the VersionInfo class, which is a utility for comparing version numbers. +*/ + +#ifndef INCLUDED_PYLONVERSIONINFO_H_3453485 +#define INCLUDED_PYLONVERSIONINFO_H_3453485 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + + /** + \class VersionInfo + \brief Holds a four-part version number consisting of major.minor.subminor.build + + This class stores a four-part version number and provides comparison operators. + If you use the constructor with one parameter, the version info object will be + initialized with pylon base version numbers. + + You can also call the static getVersionString() method to retrieve + a string containing the complete version separated by dots. + */ + class VersionInfo + { + public: + /// Constructs a version info object using pylon base version numbers. + /// If checkBuild is set to false, the build number will not be used in comparison operators. + explicit VersionInfo( bool checkBuild = false ) + : m_major( 0 ) + , m_minor( 0 ) + , m_subminor( 0 ) + , m_build( 0 ) + , m_checkBuild( checkBuild ) + { + Pylon::GetPylonVersion( &m_major, &m_minor, &m_subminor, &m_build ); + } + + + /// Constructs a version info object using the version number parts passed. + VersionInfo( unsigned int major, + unsigned int minor, + unsigned int subminor ) + : m_major( major ) + , m_minor( minor ) + , m_subminor( subminor ) + , m_build( 0 ) + , m_checkBuild( false ) + { + } + + + /// Constructs a version info object using the version number parts passed. + VersionInfo( unsigned int major, + unsigned int minor, + unsigned int subminor, + unsigned int build ) + : m_major( major ) + , m_minor( minor ) + , m_subminor( subminor ) + , m_build( build ) + , m_checkBuild( true ) + { + } + + + /// The VersionInfo destructor. + ~VersionInfo( void ) + { + } + + public: + /// Returns the complete version number as a string. + static const char* getVersionString() + { + return Pylon::GetPylonVersionString(); + } + + + /// Returns the major version number. + /// For version 2.1.3.1234 the value 2 would be returned. + unsigned int getMajor() const + { + return m_major; + } + + + /// Returns the minor version number. + /// For version 2.1.3.1234 the value 1 would be returned. + unsigned int getMinor() const + { + return m_minor; + } + + + /// Returns the subminor version number. + /// For version 2.1.3.1234 the value 3 would be returned. + unsigned int getSubminor() const + { + return m_subminor; + } + + + /// Returns the build number. + /// For version 2.1.3.1234 the value 1234 would be returned. + unsigned int getBuild() const + { + return m_build; + } + + public: + /// Compares two version info objects. + bool operator > ( const VersionInfo& rhs ) const + { + bool res = (m_major > rhs.m_major) + || (m_major == rhs.m_major && m_minor > rhs.m_minor) + || (m_major == rhs.m_major && m_minor == rhs.m_minor && m_subminor > rhs.m_subminor) + || (m_major == rhs.m_major && m_minor == rhs.m_minor && m_subminor == rhs.m_subminor && m_checkBuild && m_build > rhs.m_build); + + return res; + } + + + /// Compares two version info objects. + bool operator == ( const VersionInfo& rhs ) const + { + // use the reverse order to save some executiontime ;-) + bool res( (m_checkBuild ? (m_build == rhs.m_build) : true) + && (m_subminor == rhs.m_subminor) + && (m_minor == rhs.m_minor) + && (m_major == rhs.m_major) ); + return res; + } + + + /// Compares two version info objects. + bool operator >= ( const VersionInfo& rhs ) const + { + bool res = (*this > rhs) || (*this == rhs); + return res; + } + + + /// Compares two version info objects. + bool operator < ( const VersionInfo& rhs ) const + { + bool res = !(*this >= rhs); + return res; + } + + + /// Compares two version info objects. + bool operator != ( const VersionInfo& rhs ) const + { + bool res = !(*this == rhs); + return res; + } + + + /// compares two version info objects. + bool operator <= ( const VersionInfo& rhs ) const + { + bool res = !(*this > rhs); + return res; + } + + protected: + unsigned int m_major; + unsigned int m_minor; + unsigned int m_subminor; + unsigned int m_build; + bool m_checkBuild; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_PYLONVERSIONINFO_H_3453485 */ diff --git a/Cigarette/Pylon6.2/include/pylon/PylonVersionNumber.h b/Cigarette/Pylon6.2/include/pylon/PylonVersionNumber.h new file mode 100644 index 0000000..c8bb329 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/PylonVersionNumber.h @@ -0,0 +1,13 @@ +// This file has been generated automatically using: +// "d:\jenkinscore\workspace\pylon-release_release_6.2.0@2\build\filetemplates\pylonversionnumber.template.h" +// DO NOT EDIT! + +#define PYLON_VERSION_MAJOR 6 +#define PYLON_VERSION_MINOR 2 +#define PYLON_VERSION_SUBMINOR 0 +#define PYLON_VERSION_BUILD 18677 +#define PYLON_VERSIONSTRING_MAJOR "6" +#define PYLON_VERSIONSTRING_MINOR "2" +#define PYLON_VERSIONSTRING_SUBMINOR "0" +#define PYLON_VERSIONSTRING_BUILD "18677" +#define PYLON_VERSIONSTRING_EXTENSION "" diff --git a/Cigarette/Pylon6.2/include/pylon/Result.h b/Cigarette/Pylon6.2/include/pylon/Result.h new file mode 100644 index 0000000..328293a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/Result.h @@ -0,0 +1,417 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Definition of classes that contain grabbed data. +*/ +#pragma once + +#ifndef RESULT_H__ +#define RESULT_H__ + + +#include +#include // for memset +#include +#include + +#include +#include +#include +#include +#include + +#pragma pack(push, PYLON_PACKING) + +// Microsoft Visual Studio defines SIZE_MAX (see limits.h) +// But VS 2003 does not define SIZE_MAX. In this case, we have to define SIZE_MAX +// Because of this, the following lines must be AFTER #include limits.h +#ifndef SIZE_MAX +#define SIZE_MAX UINT_MAX +#endif + +namespace Pylon +{ + // Forward declaration + class CPylonDataContainer; + class CPylonDataComponent; + class GrabResult; + typedef CGrabResultImageT CGrabResultImageRef; + + /////////////////////////////////////////////////////////////////////// + /// \brief Low Level API: Possible grab status values + /// + /// \ingroup Pylon_LowLevelApi + enum EGrabStatus + { + GrabStatus_Undefined = -1, + _UndefinedGrabStatus = GrabStatus_Undefined, // Consider using GrabStatus_Undefined instead. + + GrabStatus_Idle, //!< Currently not used. + Idle = GrabStatus_Idle, //!< Currently not used. For backward compatibility only. + + GrabStatus_Queued, //!< Grab request is in the input queue. + Queued = GrabStatus_Queued, //!< Grab request is in the input queue. For backward compatibility only. Consider using GrabStatus_Queued instead. + + GrabStatus_Grabbed, //!< Grab request terminated successfully. Buffer is filled with data. + Grabbed = GrabStatus_Grabbed, //!< Grab request terminated successfully. Buffer is filled with data. For backward compatibility only. Consider using GrabStatus_Grabbed instead. + + GrabStatus_Canceled, //!< Grab request was canceled. Buffer doesn't contain valid data. + Canceled = GrabStatus_Canceled, //!< Grab request was canceled. Buffer doesn't contain valid data. For backward compatibility only. Consider using GrabStatus_Canceled instead. + + GrabStatus_Failed, //!< Grab request failed. Buffer doesn't contain valid data. + Failed = GrabStatus_Failed //!< Grab request failed. Buffer doesn't contain valid data. For backward compatibility only. Consider using GrabStatus_Queued instead. + }; + + /// Retrieve the number of bits per pixel for a given pixel type +#define BIT_PER_PIXEL( pixelType ) ( ( (pixelType) >> 16 ) & 0xff ) + + + /////////////////////////////////////////////////////////////////////// + /// \brief Low Level API: A grab result that combines the used image buffer and status information. + /// + /// Note that depending on the used interface technology, the specific camera and + /// the situation some of the attributes are not meaningful, e. g. timestamp in case + /// of an canceled grab. + /// + /// \ingroup Pylon_LowLevelApi + class PYLONBASE_API GrabResult + { + public: + /////////////////////////////////////////////////////////////////////// + // + GrabResult() + : m_pContext( NULL ) + , m_hBuffer( NULL ) + , m_pBuffer( NULL ) + , m_BufferSize( 0 ) + , m_Status( GrabStatus_Undefined ) + , m_PayloadType( PayloadType_Undefined ) + , m_PixelType( PixelType_Undefined ) + , m_TimeStamp( 0 ) + , m_SizeX( -1 ) + , m_SizeY( -1 ) + , m_OffsetX( -1 ) + , m_OffsetY( -1 ) + , m_PaddingX( -1 ) + , m_PaddingY( -1 ) + , m_PayloadSize( (uint64_t) -1 ) + , m_ErrorCode( 0 ) + , m_ErrorDescription( "" ) + , m_BlockID( GC_UINT64_MAX ) + { + } + + + /////////////////////////////////////////////////////////////////////// + // + ~GrabResult() + { + } + + + /////////////////////////////////////////////////////////////////////// + /// True if status is grabbed. + bool Succeeded() const + { + return m_Status == GrabStatus_Grabbed; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the buffer handle. + StreamBufferHandle Handle() const + { + return m_hBuffer; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the pointer to the buffer. + void* Buffer() const + { + return const_cast(m_pBuffer); + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the grab status. + EGrabStatus Status() const + { + return m_Status; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the pointer the user provided context. + const void* Context() const + { + return m_pContext; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the actual payload type. + EPayloadType GetPayloadType() const + { + return m_PayloadType; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the actual pixel type. This is only defined in case of image data. + EPixelType GetPixelType() const + { + return m_PixelType; + } + + + /////////////////////////////////////////////////////////////////////// + /// \brief Get the camera specific tick count. + /// + /// In case of GigE-Vision this describes when the image exposure was started. + /// Cameras that do not support this feature return zero. If supported this + /// may be used to determine which ROIs were acquired simultaneously. + uint64_t GetTimeStamp() const + { + return m_TimeStamp; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the actual number of columns in pixel. This is only defined in case of image data. + int32_t GetSizeX() const + { + return m_SizeX; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the actual number of rows in pixel. This is only defined in case of image data. + int32_t GetSizeY() const + { + return m_SizeY; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the actual starting column. This is only defined in case of image data. + int32_t GetOffsetX() const + { + return m_OffsetX; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the actual starting row. This is only defined in case of image data. + int32_t GetOffsetY() const + { + return m_OffsetY; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the number of extra data at the end of each row in bytes. This is only defined in case of image data. + int32_t GetPaddingX() const + { + return m_PaddingX; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the number of extra data at the end of the image data in bytes. This is only defined in case of image data. + int32_t GetPaddingY() const + { + return m_PaddingY; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the number of valid bytes in the buffer returned by Buffer(). + int64_t GetPayloadSize() const + { + return m_PayloadSize; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the number of valid bytes in the buffer returned by Buffer() as size_t. + size_t GetPayloadSize_t() const + { +#if SIZE_MAX >= 0xffffffffffffffffULL + return static_cast(GetPayloadSize()); +#else + if (m_PayloadSize > SIZE_MAX) + { + throw OUT_OF_RANGE_EXCEPTION( "PayloadSize too big" ); + } + return static_cast(m_PayloadSize & SIZE_MAX); +#endif + } + + + /////////////////////////////////////////////////////////////////////// + /// Get a description of the current error. + String_t GetErrorDescription() const + { + return m_ErrorDescription; + } + + + /////////////////////////////////////////////////////////////////////// + /// Get the current error code. + uint32_t GetErrorCode() const + { + return m_ErrorCode; + } + + + /////////////////////////////////////////////////////////////////////// + /// \brief Provides an adapter from the grab result to Pylon::IImage interface. + /// + /// This returned adapter allows passing the grab result to saving functions or image format converter. + /// + /// \attention The returned reference is only valid as long the grab result is not destroyed. + CGrabResultImageRef GetImage() const + { + return CGrabResultImageRef( *this, false ); + } + + + /////////////////////////////////////////////////////////////////////// + /// \brief Get the block ID of the grabbed frame (camera device specific). + /// + /// \par IEEE 1394 Camera Devices + /// The value of block ID is always UINT64_MAX. + /// + /// \par GigE Camera Devices + /// The sequence number starts with 1 and + /// wraps at 65535. The value 0 has a special meaning and indicates + /// that this feature is not supported by the camera. + /// + /// \par USB Camera Devices + /// The sequence number starts with 0 and uses the full 64 Bit range. + /// + /// \attention A block ID of value UINT64_MAX indicates that the Block ID is invalid and must not be used. + uint64_t GetBlockID() const + { + return m_BlockID; + } + + + /////////////////////////////////////////////////////////////////////////////// + /// \copydoc Pylon::CGrabResultData::GetDataContainer() + CPylonDataContainer GetDataContainer() const; + + + /////////////////////////////////////////////////////////////////////////////// + /// \copydoc Pylon::CPylonDataContainer::GetDataComponentCount() + size_t GetDataComponentCount() const; + + + /////////////////////////////////////////////////////////////////////////////// + /// \copydoc Pylon::CPylonDataContainer::GetDataComponent() + CPylonDataComponent GetDataComponent( size_t index ); + + + /////////////////////////////////////////////////////////////////////// + /// Get the size of the buffer returned by Buffer(). + size_t GetBufferSize() const + { + return m_BufferSize; + } + + protected: + const void* m_pContext; + StreamBufferHandle m_hBuffer; + const void* m_pBuffer; + size_t m_BufferSize; + + EGrabStatus m_Status; + EPayloadType m_PayloadType; + EPixelType m_PixelType; + uint64_t m_TimeStamp; + int32_t m_SizeX; + int32_t m_SizeY; + int32_t m_OffsetX; + int32_t m_OffsetY; + int32_t m_PaddingX; + int32_t m_PaddingY; + uint64_t m_PayloadSize; + uint32_t m_ErrorCode; + String_t m_ErrorDescription; + uint64_t m_BlockID; + }; + + + /////////////////////////////////////////////////////////////////////// + /// \brief Low Level API: An event result + /// \ingroup Pylon_LowLevelApi + class EventResult + { + public: + /////////////////////////////////////////////////////////////////////// + // + EventResult() + : m_ReturnCode( 0 ) + , m_Message() + { + // prevent uninitialized member warning + memset( Buffer, 0, sizeof( Buffer ) ); + } + + + /////////////////////////////////////////////////////////////////////// + // + ~EventResult() + { + } + + + /////////////////////////////////////////////////////////////////////// + // + bool Succeeded() const + { + return 0 == m_ReturnCode; + } + + + /////////////////////////////////////////////////////////////////////// + // + String_t ErrorDescription() const + { + return m_Message; + } + + + /////////////////////////////////////////////////////////////////////// + // + unsigned long ErrorCode() const + { + return m_ReturnCode; + } + + protected: + unsigned long m_ReturnCode; + String_t m_Message; + + public: + unsigned char Buffer[576]; + }; + + /////////////////////////////////////////////////////////////////////// + /// \brief Low Level API: Adapts a copy of a grab result to pylon image. + /// + /// \attention The referenced grab result must not be destroyed and the result's buffer must not be queued for grabbing again during the lifetime of this object. + /// + /// \ingroup Pylon_LowLevelApi + typedef CGrabResultImageT CGrabResultImage; +} + +#pragma pack(pop) + +#endif // RESULT_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/ResultImage.h b/Cigarette/Pylon6.2/include/pylon/ResultImage.h new file mode 100644 index 0000000..f4d4884 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ResultImage.h @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Contains an adapter adapting a grab result to Pylon::IImage. +*/ + +#pragma once + +#ifndef INCLUDED_RESULTIMAGE_H_0326044 +#define INCLUDED_RESULTIMAGE_H_0326044 + +#include + +namespace Pylon +{ + /*! + \brief Low Level API: Adapts grab result to Pylon::IImage. + + \ingroup Pylon_LowLevelApi + */ + template + class CGrabResultImageT : public IImage + { + public: + /*! + \brief Creates a grab result image object. + + \param[in] grabResult A grab result. + \param[in] isUnique User provided info whether the buffer is referenced only by this grab result. + + \error + Does not throw C++ exceptions. + */ + CGrabResultImageT( GrabResultT grabResult, bool isUnique ) + : m_grabResult( grabResult ) + , m_isUnique( isUnique ) + { + } + + /// Destroys a grab result image object. + virtual ~CGrabResultImageT() + { + } + + // Implements Pylon::IImage. + virtual bool IsValid() const + { + return IsValidImpl(); + } + + // Implements Pylon::IImage. + virtual EPixelType GetPixelType() const + { + return IsValidImpl() ? m_grabResult.GetPixelType() : PixelType_Undefined; + } + + // Implements Pylon::IImage. + virtual uint32_t GetWidth() const + { + return IsValidImpl() ? static_cast(m_grabResult.GetSizeX()) : 0; + } + + // Implements Pylon::IImage. + virtual uint32_t GetHeight() const + { + return IsValidImpl() ? static_cast(m_grabResult.GetSizeY()) : 0; + } + + // Implements Pylon::IImage. + virtual size_t GetPaddingX() const + { + return IsValidImpl() ? m_grabResult.GetPaddingX() : 0; + } + + // Implements Pylon::IImage. + virtual EImageOrientation GetOrientation() const + { + return ImageOrientation_TopDown; + } + + // Implements Pylon::IImage. + virtual void* GetBuffer() + { + return IsValidImpl() ? m_grabResult.Buffer() : NULL; + } + + // Implements Pylon::IImage. + virtual const void* GetBuffer() const + { + return IsValidImpl() ? m_grabResult.Buffer() : NULL; + } + + // Implements Pylon::IImage. + virtual size_t GetImageSize() const + { + return IsValidImpl() ? ComputeBufferSize( m_grabResult.GetPixelType(), static_cast(m_grabResult.GetSizeX()), static_cast(m_grabResult.GetSizeY()), m_grabResult.GetPaddingX() ) : 0; + } + + // Implements Pylon::IImage. + virtual bool IsUnique() const + { + return m_isUnique; + } + + // Implements Pylon::IImage. + virtual bool GetStride( size_t& strideBytes ) const + { + return IsValidImpl() ? ComputeStride( strideBytes, m_grabResult.GetPixelType(), static_cast(m_grabResult.GetSizeX()), m_grabResult.GetPaddingX() ) : false; + } + + protected: + // Check whether the grab result is valid. + bool IsValidImpl() const + { + return + m_grabResult.Succeeded() + && m_grabResult.GetPixelType() != PixelType_Undefined + && m_grabResult.GetSizeX() >= 0 + && m_grabResult.GetSizeY() >= 0 + && m_grabResult.GetPaddingX() >= 0; + } + + GrabResultT m_grabResult; ///< The grab result that is adapted to IImage. + bool m_isUnique; ///< User provided info whether the buffer is referenced only by this adapter. + }; +} // namespace Pylon + +#endif /* INCLUDED_RESULTIMAGE_H_0326044 */ diff --git a/Cigarette/Pylon6.2/include/pylon/ReusableImage.h b/Cigarette/Pylon6.2/include/pylon/ReusableImage.h new file mode 100644 index 0000000..f202283 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ReusableImage.h @@ -0,0 +1,146 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//------------------------------------------------------------------------------ +/*! + \file + \brief Contains an interface for a reusable image. +*/ + +#ifndef INCLUDED_REUSABLEIMAGE_H_1558802 +#define INCLUDED_REUSABLEIMAGE_H_1558802 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_ImageHandlingSupport + * @{ + */ + + /*! + \interface IReusableImage + \brief Extends the IImage interface to be able to reuse the image's resources to represent a different image. + */ + interface IReusableImage : public IImage + { + public: + /// Ensure proper destruction by using a virtual destructor. + // implementation must be out of class or older compilers will throw an error (see below) + virtual ~IReusableImage() = 0; + + + /*! + \brief Can be used to check whether the pixel type is supported. + + \return Returns true if the pixel type is supported. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsSupportedPixelType( EPixelType pixelType ) const = 0; + + + /*! + \brief Can be used to check whether the value of PaddingX can be defined by the user. + + \return Returns true if the value of PaddingX can be defined by the user. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsAdditionalPaddingSupported() const = 0; + + + /*! + \brief Resets the image properties and provides a buffer to hold the image. + + \param[in] pixelType The pixel type of the new image. + \param[in] width The number of pixels in a row in the new image. + \param[in] height The number of rows in the new image. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The IsSupportedPixelType() method returns true. +
  • The \c width value must be >= 0 and < _I32_MAX. +
  • The \c height value must be >= 0 and < _I32_MAX. +
+ + \post +
    +
  • The properties of the image are changed. +
  • A buffer large enough to hold the image is provided. +
+ + \error + Throws an exception when the preconditions are not met. + Throws an exception when no buffer with the required size can be provided, e.g. by allocation. + The original representation is preserved on error. + */ + virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, EImageOrientation orientation = ImageOrientation_TopDown ) = 0; + + + /*! + \brief Resets the image properties including user defined PaddingX and provides a buffer to hold the image. + + Extends the Reset(EPixelType, uint32_t, uint32_t) method with user provided padding. + + \param[in] pixelType The pixel type of the new image. + \param[in] width The number of pixels in a row in the new image. + \param[in] height The number of rows in the new image. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The preconditions of the Reset() method without paddingX parameter apply. +
  • The IsAdditionalPaddingSupported() method returns true. +
+ */ + virtual void Reset( EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EImageOrientation orientation = ImageOrientation_TopDown ) = 0; + + + /*! + \brief Releases the image buffer and resets to an invalid image. + + \post +
    +
  • PixelType = PixelType_Undefined. +
  • Width = 0. +
  • Height = 0. +
  • PaddingX = 0. +
  • No buffer is allocated. +
+ + \error + Does not throw C++ exceptions. + */ + virtual void Release() = 0; + }; + + /** + * @} + */ + + // implementation for d'tor must be out of class + inline IReusableImage::~IReusableImage() + { + } + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_REUSABLEIMAGE_H_1558802 */ diff --git a/Cigarette/Pylon6.2/include/pylon/SfncVersion.h b/Cigarette/Pylon6.2/include/pylon/SfncVersion.h new file mode 100644 index 0000000..4095f03 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/SfncVersion.h @@ -0,0 +1,129 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2009-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains the support for SFNC version handling. +*/ + +#ifndef INCLUDED_SFNCVERSION_H_3193628 +#define INCLUDED_SFNCVERSION_H_3193628 + +#include +#include + +#ifdef PYLON_LINUX_BUILD +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#if defined (PYLON_OSX_BUILD) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-variable" +# pragma clang diagnostic ignored "-Wunknown-pragmas" +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wunknown-pragmas" +# pragma GCC diagnostic ignored "-Wpragmas" // gcc < 4.6 doesn't know the following pragma +# pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + +#include + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wunknown-pragmas" +# pragma GCC diagnostic warning "-Wunused-but-set-variable" +# pragma GCC diagnostic warning "-Wpragmas" // gcc < 4.6 doesn't know the pragma +# endif +#endif + +#include +#include + +#if defined (PYLON_OSX_BUILD) +# pragma clang diagnostic pop +#endif + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + /// Constant for undefined SFNC version. + static const VersionInfo Sfnc_VersionUndefined( 0, 0, 0 ); + /// Constant for SFNC version 1.2.1. + static const VersionInfo Sfnc_1_2_1( 1, 2, 1 ); + /// Constant for SFNC version 1.3.0. + static const VersionInfo Sfnc_1_3_0( 1, 3, 0 ); + /// Constant for SFNC version 1.4.0. + static const VersionInfo Sfnc_1_4_0( 1, 4, 0 ); + /// Constant for SFNC version 1.5.0. + static const VersionInfo Sfnc_1_5_0( 1, 5, 0 ); + /// Constant for SFNC version 1.5.1. + static const VersionInfo Sfnc_1_5_1( 1, 5, 1 ); + /// Constant for SFNC version 2.0.0. This version or a later version is used by USB camera devices. + static const VersionInfo Sfnc_2_0_0( 2, 0, 0 ); + /// Constant for SFNC version 2.1.0 + static const VersionInfo Sfnc_2_1_0( 2, 1, 0 ); + /// Constant for SFNC version 2.2.0 + static const VersionInfo Sfnc_2_2_0( 2, 2, 0 ); + /// Constant for SFNC version 2.3.0 + static const VersionInfo Sfnc_2_3_0( 2, 3, 0 ); + /// Constant for SFNC version 2.4.0 + static const VersionInfo Sfnc_2_4_0( 2, 4, 0 ); + /// Constant for SFNC version 2.5.0 + static const VersionInfo Sfnc_2_5_0( 2, 5, 0 ); + + + /** + * @} + */ + + /// Helper function for getting the SFNC version from the camera device node map. + inline VersionInfo GetSfncVersion( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + // If pNodeMap is a valid node map. + if (pNodeMap) + { + // Check to see whether node for major version exists. + GENAPI_NAMESPACE::CIntegerPtr major = pNodeMap->GetNode( "DeviceSFNCVersionMajor" ); + if (major) + { + // Get further version Info. + GENAPI_NAMESPACE::CIntegerPtr minor = pNodeMap->GetNode( "DeviceSFNCVersionMinor" ); + GENAPI_NAMESPACE::CIntegerPtr subminor = pNodeMap->GetNode( "DeviceSFNCVersionSubMinor" ); + + if (!IsReadable( major ) || !IsReadable( minor ) || !IsReadable( subminor )) + { + throw RUNTIME_EXCEPTION( "Failed to read SFNC version from camera device node map." ); + } + + VersionInfo v( static_cast(major->GetValue()), + static_cast(minor->GetValue()), + static_cast(subminor->GetValue()) ); + return v; + } + } + + return Sfnc_VersionUndefined; + } +} + +#endif /* INCLUDED_SFNCVERSION_H_3193628 */ diff --git a/Cigarette/Pylon6.2/include/pylon/SoftwareTriggerConfiguration.h b/Cigarette/Pylon6.2/include/pylon/SoftwareTriggerConfiguration.h new file mode 100644 index 0000000..41cc708 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/SoftwareTriggerConfiguration.h @@ -0,0 +1,158 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief An instant camera configuration for software trigger, + Use together with Pylon::CInstantCamera::WaitForFrameTriggerReady() and Pylon::CInstantCamera::ExecuteSoftwareTrigger(). + This instant camera configuration is provided as header-only file. The code + can be copied and modified for creating own configuration classes. +*/ + +#ifndef INCLUDED_SOFTWARETRIGGERCONFIGURATION_H_4655834 +#define INCLUDED_SOFTWARETRIGGERCONFIGURATION_H_4655834 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGeneric + * @{ + */ + + /*! + \class CSoftwareTriggerConfiguration + \brief Changes the configuration of the camera so that the acquisition of frames is triggered by software trigger. + Use together with CInstantCamera::WaitForFrameTriggerReady() and CInstantCamera::ExecuteSoftwareTrigger(). + + The %CSoftwareTriggerConfiguration is provided as header-only file. + The code can be copied and modified for creating own configuration classes. + */ + class CSoftwareTriggerConfiguration : public CConfigurationEventHandler + { + public: + /// Apply software trigger configuration. + static void ApplyConfiguration( GENAPI_NAMESPACE::INodeMap& nodemap ) + { + using namespace GENAPI_NAMESPACE; + + //Disable compression mode. + CConfigurationHelper::DisableCompression( nodemap ); + + //Disable GenDC streaming. + CConfigurationHelper::DisableGenDC( nodemap ); + + //Select image component. + CConfigurationHelper::SelectRangeComponent( nodemap ); + + // Disable all trigger types except the trigger type used for triggering the acquisition of + // frames. + { + // Get required enumerations. + CEnumParameter triggerSelector( nodemap, "TriggerSelector" ); + CEnumParameter triggerMode( nodemap, "TriggerMode" ); + + // Check the available camera trigger mode(s) to select the appropriate one: acquisition start trigger mode + // (used by older cameras, i.e. for cameras supporting only the legacy image acquisition control mode; + // do not confuse with acquisition start command) or frame start trigger mode + // (used by newer cameras, i.e. for cameras using the standard image acquisition control mode; + // equivalent to the acquisition start trigger mode in the legacy image acquisition control mode). + String_t triggerName( "FrameStart" ); + if (!triggerSelector.CanSetValue( triggerName )) + { + triggerName = "AcquisitionStart"; + if (!triggerSelector.CanSetValue( triggerName )) + { + throw RUNTIME_EXCEPTION( "Could not select trigger. Neither FrameStart nor AcquisitionStart is available." ); + } + } + + // Get all enumeration entries of trigger selector. + StringList_t triggerSelectorEntries; + triggerSelector.GetSettableValues( triggerSelectorEntries ); + + // Turn trigger mode off for all trigger selector entries except for the frame trigger given by triggerName. + for (StringList_t::const_iterator it = triggerSelectorEntries.begin(); it != triggerSelectorEntries.end(); ++it) + { + // Set trigger mode to off. + triggerSelector.SetValue( *it ); + if (triggerName == *it) + { + // Activate trigger. + triggerMode.SetValue( "On" ); + + // The trigger source must be set to 'Software'. + CEnumParameter( nodemap, "TriggerSource" ).SetValue( "Software" ); + + //// Alternative hardware trigger configuration: + //// This configuration can be copied and modified to create a hardware trigger configuration. + //// Remove setting the 'TriggerSource' to 'Software' (see above) and + //// use the commented lines as a starting point. + //// The camera user's manual contains more information about available configurations. + //// The Basler pylon Viewer tool can be used to test the selected settings first. + + //// The trigger source must be set to the trigger input, e.g. 'Line1'. + //CEnumParameter(nodemap, "TriggerSource").SetValue("Line1"); + + ////The trigger activation must be set to e.g. 'RisingEdge'. + //CEnumParameter(nodemap, "TriggerActivation").SetValue("RisingEdge"); + } + else + { + triggerMode.TrySetValue( "Off" ); + } + } + // Finally select the frame trigger type (resp. acquisition start type + // for older cameras). Issuing a software trigger will now trigger + // the acquisition of a frame. + triggerSelector.SetValue( triggerName ); + } + + + //Set acquisition mode to "continuous" + CEnumParameter( nodemap, "AcquisitionMode" ).SetValue( "Continuous" ); + } + + //Set basic camera settings. + virtual void OnOpened( CInstantCamera& camera ) + { + try + { + ApplyConfiguration( camera.GetNodeMap() ); + } + catch (const GenericException& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Pylon::GenericException caught in OnOpened method msg=%hs", e.what() ); + } + catch (const std::exception& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. std::exception caught in OnOpened method msg=%hs", e.what() ); + } + catch (...) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Unknown exception caught in OnOpened method." ); + } + } + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_SOFTWARETRIGGERCONFIGURATION_H_4655834 */ diff --git a/Cigarette/Pylon6.2/include/pylon/StreamGrabber.h b/Cigarette/Pylon6.2/include/pylon/StreamGrabber.h new file mode 100644 index 0000000..001f48e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/StreamGrabber.h @@ -0,0 +1,517 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Definition of IStreamGrabber interface + +\attention +The Low Level API has been deprecated in pylon 6.0. It is recommended +to use the Instant Camera classes instead. +*/ +#ifndef __ISTREAMGRABBER_H__ +#define __ISTREAMGRABBER_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /*! + \ingroup Pylon_LowLevelApi + \brief Used to configure how starting and stopping of streaming are handled. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + */ + + class GrabResult; + class WaitObject; + /// This opaque type represents a registered buffer. + typedef void* StreamBufferHandle; + + // ------------------------------------------------------------------------- + // interface IStreamGrabber + // ------------------------------------------------------------------------- + /*! + \ingroup Pylon_LowLevelApi + \interface IStreamGrabber + \brief Low Level API: Interface to an (input) data stream + + \attention + The Low Level API has been deprecated in pylon 6.0. It is recommended + to use the Instant Camera classes instead. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + */ + interface IStreamGrabber + { + /*! + \brief Opens the stream grabber. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \pre +
    +
  • The corresponding device is open. +
  • The stream grabber is closed. +
+ + \post +
    +
  • The stream grabber is open. +
  • If the device is closed while the stream grabber is open, the stream grabber is closed automatically. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber is already open or prepared. The stream grabber remains in the same state after raising the exception in this case. +
  • Throws an exception if the stream grabber is closed and opening the stream grabber fails. The stream grabber remains closed after raising the exception. +
+ */ + virtual void Open() = 0; + + + /*! + \brief Closes the stream grabber. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + This method calls FinishGrab() automatically if needed. + + \post +
    +
  • Any running grab has been stopped by calling FinishGrab(). +
  • The stream grabber is closed. +
  • All results waiting in the output queue are discarded. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error + Does not throw C++ exceptions. + */ + virtual void Close() = 0; + + + /*! + \brief Retrieve whether the stream grabber is open. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \return Returns true if the stream grabber is open. + + \threading + This method can be synchronized using an internal stream grabber lock. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsOpen() const = 0; + + + /*! + \brief Registers a buffer for subsequent use. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \param[in] pBuffer The pointer of the buffer that is to be used for grabbing e.g., for grabbing images. + \param[in] bufferSize The size of the provided buffer in bytes. + \return Returns a handle for the registered buffer that can be used in subsequent calls. + + \pre +
    +
  • pBuffer must not be NULL. +
  • The buffer size must not exceed the value of the node map integer parameter MaxBufferSize specified when PrepareGrab was called. +
  • Less buffers are already registered than value of the node map integer parameter MaxNumBuffer specified when PrepareGrab was called. +
  • The stream grabber is prepared, see PrepareGrab(). +
  • The buffer has not been registered already. +
+ + \post +
    +
  • The buffer is registered. +
  • Transport Layer specific preparations have been executed e.g., locking the memory pages of the buffer. +
  • The buffer must not be freed while being registered. +
  • If the stream grabber requires the additional streaming state, streaming must not be started, see IsStartAndStopStreamingMandatory() and StartStreamingIfMandatory(). +
+ + \threading + This method can be synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if registering the buffer fails. The buffer is not registered after raising an exception. +
+ */ + virtual StreamBufferHandle RegisterBuffer( void* pBuffer, size_t bufferSize ) = 0; + + + /*! + \brief Deregisters the buffer. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \param[in] hStreamBuffer The handle of a buffer that has been provided by RegisterBuffer() + \return Returns the pointer of the corresponding buffer. + + \pre +
    +
  • The buffer is registered. +
  • The buffer is not queued. Either it has not been queued yet, see QueueBuffer(), or it has been retrieved after grabbing using RetrieveResult(). +
  • FinishGrab() or Close() have not been called for the grab session yet. +
  • If the stream grabber requires the additional streaming state, streaming must not be started, see IsStartAndStopStreamingMandatory() and StartStreamingIfMandatory(). +
+ + \post +
    +
  • Transport layer-specific preparations have been reversed. +
  • The buffer is deregistered. +
  • The buffer can be freed if needed e.g., by calling delete. +
+ + \error + Throws an exception if deregistering the buffer fails. + */ + virtual const void* DeregisterBuffer( StreamBufferHandle hStreamBuffer ) = 0; + + + /*! + \brief Prepares grabbing + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \note pylon uses a pool of buffers with a fixed amount of buffers to grab images. This is required because certain + preparations e.g., locking the buffer's memory pages, must be made by the driver to be able to grab images into a buffer. + Thus, using a pool of buffers is much more efficient than allocating a new buffer for every grabbed image. + + The node map integer parameters MaxBufferSize and MaxNumBuffer need to be set before calling PrepareGrab(). + + MaxNumBuffer should be set to the number of buffers you plan to use for grabbing. + \note There can be limitations depending on the transport layer technology used when using a large amount of buffers. + + MaxBufferSize needs to be set according to the PayloadSize parameter of the camera device or the stream grabber. + If the stream grabber provides a PayloadSize parameter, the MaxBufferSize must be at least the size reported + by the stream grabber payload size. This is the case if for instance a frame grabber or additional preprocessing + is used. + If the stream grabber does not provide a PayloadSize parameter, the MaxBufferSize must be at least the size reported + by the camera device PayloadSize parameter. + + \pre +
    +
  • The node map integer parameter MaxBufferSize is set, see GetNodeNap(). +
  • The node map integer parameter MaxNumBuffer is set, see GetNodeNap(). +
  • The stream grabber is open. +
  • No grab session is currently in progress. +
+ + \post +
    +
  • Resources required for grabbing are allocated. +
  • The camera is set up for grabbing. +
  • Critical camera parameters, provided by IPylonDevice::GetNodeMap(), are locked. +
  • The stream grabber is prepared. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if preparing the stream grabber fails. The stream grabber is not prepared after raising the exception. +
+ */ + virtual void PrepareGrab() = 0; + + + /*! + \brief Returns true if the Stream Grabber requires calling StartStreamingIfMandatory() for operation. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \threading + This method is synchronized using an internal stream grabber lock. + + \error + Does not throw C++ exceptions. + */ + virtual bool IsStartAndStopStreamingMandatory() = 0; + + + /*! + \brief Starts streaming for the stream grabber if this is mandatory for operation. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + Some stream grabbers e.g., some stream grabbers based on GenTL, have limitations on when buffers can + be registered. For these stream grabbers it is mandatory to register all buffers first and + call StartStreamingIfMandatory() aftwards. + Between the StartStreamingIfMandatory() and StopStreamingIfMandatory() calls no buffers can be + registered or deregistered if such a limitation exists. + + \note This method has been added in pylon 6.0 for supporting CoaXPress. Prior implementations + of pylon stream grabbers did not require calling start and stop streaming. + The IsStartAndStopStreamingMandatory(), StartStreamingIfMandatory(), and StopStreamingIfMandatory() + methods allow backward-compatible operation. + + \pre +
    +
  • The stream grabber is prepared. +
+ + \post +
    +
  • If the stream grabber does not require StartStreamingIfMandatory(), nothing is done. +
  • Streaming is started. For GenTL-based stream grabbers DSStartAcquistion is called +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if start streaming fails. The stream grabber is not streaming after raising the exception. +
+ */ + virtual void StartStreamingIfMandatory() = 0; + + + /*! + \brief Stops streaming for the stream grabber if this is mandatory for operation. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + Some stream grabbers e.g., some stream grabbers based on GenTL, have limitations on when buffers can + be registered. For these stream grabbers it is mandatory to call StopStreamingIfMandatory to be able to deregister buffer afterwards. + + \pre +
    +
  • The stream grabber is in streaming mode if start and stop streaming is mandatory. +
+ + \post +
    +
  • If the stream grabber does not require StopStreamingIfMandatory(), nothing is done. +
  • Streaming is stopped. For GenTL-based stream grabbers DSStopAcquistion is called. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if stop streaming fails. The stream grabber is not streaming after raising the exception. +
+ */ + virtual void StopStreamingIfMandatory() = 0; + + + /*! + \brief Stops grabbing finally + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + This method calls FlushBuffersToOutput() automatically if needed. + + \pre +
    +
  • The stream grabber is prepared. +
+ + \post +
    +
  • Resources required for grabbing are freed. +
  • The camera is not set up for grabbing anymore +
  • Critical camera parameters, provided by IPylonDevice::GetNodeMap(), are unlocked. +
  • The stream grabber is open. +
  • Queued buffers are available in the output queue of the stream grabber and can be retrieved calling RetrieveResult(). +
  • All buffers are deregistered. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if finishing the grab fails. The stream grabber is in open state after raising the exception. +
+ */ + virtual void FinishGrab() = 0; + + + /*! + \brief Enqueues a buffer in the input queue. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \param[in] hStreamBuffer The handle of a buffer that has been provided by RegisterBuffer(). + \param[in] pContext A user-provided pointer passed along with buffer in the internal input and output queues. + + \pre +
    +
  • The buffer is registered, see RegisterBuffer(). +
  • The stream grabber is prepared. +
  • The buffer has not been queued for grabbing yet. +
  • The buffer is not waiting in the output queue of the stream grabber. The buffer can be queued again after it has been retrieved using RetrieveResult(). +
+ + \post +
    +
  • The buffer is queued to input queue of the stream grabber. +
  • The buffer cannot be deregistered until it has been retrieved using RetrieveResult(). +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if queuing the buffer fails. +
+ */ + virtual void QueueBuffer( StreamBufferHandle hStreamBuffer, const void* pContext = NULL ) = 0; + + + /*! + \brief Cancels grabbing the current buffer and flushes all buffers to the output queue. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \pre +
    +
  • The stream grabber is prepared. +
+ + \post +
    +
  • All queued buffers are placed in the output queue of the stream grabber and can be retrieved using RetrieveResult(). +
  • Buffers that have not been grabbed completely before calling FlushBuffersToOutput are marked with the EGrabStatus Canceled. +
  • The stream grabber is prepared. +
  • Buffers can be queued again to continue grabbing. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if canceling the grab fails. +
+ */ + virtual void FlushBuffersToOutput() = 0; + ///This method has been renamed to FlushBuffersToOutput(). Calling CancelGrab calls FlushBuffersToOutput(); + virtual void CancelGrab() = 0; + + + /*! + \brief Retrieves one grab result from the output queue. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + param[out] grabResult The object the grab result data is returned in if true is returned. The \c grabResult remains unchanged if false is returned. + \return Returns true when result was available. + + \pre +
    +
  • The stream grabber is open. +
+ + \post +
    +
  • If a grab result was available, it has been removed from the ouput queue. +
  • The corresponding buffer can be queued again for grabbing. +
+ + \threading + This method is synchronized using an internal stream grabber lock. + + \error +
    +
  • Throws a LogicalErrorException if the stream grabber state does not match the preconditions. +
  • Throws an exception if retrieving the result fails. This does not change the stream grabber state. +
+ */ + virtual bool RetrieveResult( GrabResult& grabResult ) = 0; + + + /*! + \brief Returns the result event object of the stream grabber. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + This object is associated with the output queue of the stream grabber. + The event is signaled when output queue is non-empty. + + \return Returns the result event object of the stream grabber. + + \threading + This method can be synchronized using an internal stream grabber lock. + + \error + Does not throw C++ exceptions. + */ + + virtual WaitObject& GetWaitObject() const = 0; + + + /*! + \brief Returns the associated stream grabber parameters. + + \note Basler recommends using one of the Instant Camera classes CBaslerUniversalInstantCamera or CInstantCamera for new projects. + If you want to control which buffers are used for grabbing, you can use the Pylon::IBufferFactory. + + \return Returns the associated stream grabber parameters. The returned pointer is never NULL. + + \threading + This method can be synchronized using an internal stream grabber lock. + + \error + Does not throw C++ exceptions. + */ + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() = 0; + }; + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__ISTREAMGRABBER_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/StreamGrabberProxy.h b/Cigarette/Pylon6.2/include/pylon/StreamGrabberProxy.h new file mode 100644 index 0000000..de72e5b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/StreamGrabberProxy.h @@ -0,0 +1,344 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Pylon generic stream grabber interface declaration +*/ + + +#ifndef __PYLON_STREAMGRABBERPROXY__H__ +#define __PYLON_STREAMGRABBERPROXY__H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include "NodeMapProxy.h" + + +//! Macro to define a custom Node map proxy +#define PYLON_DEFINE_STREAMGRABBER(ClassName, BaseClass) \ + class ClassName : public BaseClass \ + { \ + public: \ + /** \name Construction */ \ + /*@{*/ \ + /** \brief \copybrief Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT() + \copydetails Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT() + */ \ + ClassName() \ + { \ + } \ + /** \brief \copybrief Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT(Pylon::IStreamGrabber*) + \copydetails Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT(Pylon::IStreamGrabber*) + */ \ + ClassName( IStreamGrabber* pStreamGrabber ) : BaseClass( pStreamGrabber ) \ + { \ + } \ + /*@}*/ \ + }; + + + namespace Pylon + { + //************************************************************************************************** + //! Low Level API: The stream grabber class with parameter access methods + /** + This is the base class for pylon stream grabber providing access to configuration parameters. + \see \ref configuringcameras + + \tparam TParams The specific parameter class (auto generated from the parameter xml file) + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + template + class CStreamGrabberProxyT : public CNodeMapProxyT + { + public: + //! \name Construction + // \{ + + //! Creates a CStreamGrabberProxyT object that is not attached to a pylon stream grabber. Use the Attach() method to attach the pylon stream grabber. + CStreamGrabberProxyT(); + + //! Creates a CStreamGrabberProxyT object and attaches it to a pylon stream grabber. + CStreamGrabberProxyT( Pylon::IStreamGrabber* ); + + //! Destructor + virtual ~CStreamGrabberProxyT(); + + //\} + + + private: + //! \name Assignment and copying is not supported + // \{ + CStreamGrabberProxyT( const CStreamGrabberProxyT& ); + CStreamGrabberProxyT& operator=( const CStreamGrabberProxyT& ); + // \} + + + public: + //! \name Some smart pointer functionality + // \{ + + //! Attach a pylon stream grabber + virtual void Attach( IStreamGrabber* ); + + //! Checks if a pylon stream grabber is attached + virtual bool IsAttached() const; + + //! Returns the pylon stream grabber interface pointer + virtual IStreamGrabber* GetStreamGrabber() const; + + // \} + + + public: + //! \name Implementation of the IStreamGrabber interface + //! See Pylon::IStreamGrabber for more details. + // \{ + + /** \brief \copybrief Pylon::IStreamGrabber::Open() + + \copydetails Pylon::IStreamGrabber::Open() + */ + void Open() + { + CheckPtr(); + m_pStreamGrabber->Open(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::Close() + + \copydetails Pylon::IStreamGrabber::Close() + */ + void Close() + { + CheckPtr(); + m_pStreamGrabber->Close(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::IsOpen() + + \copydetails Pylon::IStreamGrabber::IsOpen() + */ + bool IsOpen() const + { + CheckPtr(); + return m_pStreamGrabber->IsOpen(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::RegisterBuffer() + + \copydetails Pylon::IStreamGrabber::RegisterBuffer() + */ + StreamBufferHandle RegisterBuffer( void* pBuffer, size_t bufferSize ) + { + CheckPtr(); + return m_pStreamGrabber->RegisterBuffer( pBuffer, bufferSize ); + } + + /** \brief \copybrief Pylon::IStreamGrabber::DeregisterBuffer() + + \copydetails Pylon::IStreamGrabber::DeregisterBuffer() + */ + const void* DeregisterBuffer( StreamBufferHandle hStreamBuffer ) + { + CheckPtr(); + return m_pStreamGrabber->DeregisterBuffer( hStreamBuffer ); + } + + /** \brief \copybrief Pylon::IStreamGrabber::PrepareGrab() + + \copydetails Pylon::IStreamGrabber::PrepareGrab() + */ + void PrepareGrab() + { + CheckPtr(); + m_pStreamGrabber->PrepareGrab(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::IsStartAndStopStreamingMandatory() + + \copydetails Pylon::IStreamGrabber::IsStartAndStopStreamingMandatory() + */ + bool IsStartAndStopStreamingMandatory() + { + CheckPtr(); + return m_pStreamGrabber->IsStartAndStopStreamingMandatory(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::StartStreamingIfMandatory() + + \copydetails Pylon::IStreamGrabber::StartStreamingIfMandatory() + */ + void StartStreamingIfMandatory() + { + CheckPtr(); + m_pStreamGrabber->StartStreamingIfMandatory(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::StopStreamingIfMandatory() + + \copydetails Pylon::IStreamGrabber::StopStreamingIfMandatory() + */ + void StopStreamingIfMandatory() + { + CheckPtr(); + m_pStreamGrabber->StopStreamingIfMandatory(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::FinishGrab() + + \copydetails Pylon::IStreamGrabber::FinishGrab() + */ + void FinishGrab() + { + CheckPtr(); + m_pStreamGrabber->FinishGrab(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::QueueBuffer() + + \copydetails Pylon::IStreamGrabber::QueueBuffer() + */ + void QueueBuffer( StreamBufferHandle hStreamBuffer, const void* pContext = NULL ) + { + CheckPtr(); + m_pStreamGrabber->QueueBuffer( hStreamBuffer, pContext ); + } + + /** \brief \copybrief Pylon::IStreamGrabber::FlushBuffersToOutput() + + \copydetails Pylon::IStreamGrabber::FlushBuffersToOutput() + */ + void FlushBuffersToOutput() + { + CheckPtr(); + m_pStreamGrabber->FlushBuffersToOutput(); + } + + // undocumented, deprecated + void CancelGrab() + { + CheckPtr(); + m_pStreamGrabber->FlushBuffersToOutput(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::RetrieveResult() + + \copydetails Pylon::IStreamGrabber::RetrieveResult() + */ + bool RetrieveResult( GrabResult& Result ) + { + CheckPtr(); + return m_pStreamGrabber->RetrieveResult( Result ); + } + + /** \brief \copybrief Pylon::IStreamGrabber::GetWaitObject() + + \copydetails Pylon::IStreamGrabber::GetWaitObject() + */ + WaitObject& GetWaitObject() const + { + CheckPtr(); + return m_pStreamGrabber->GetWaitObject(); + } + + /** \brief \copybrief Pylon::IStreamGrabber::GetNodeMap() + + \copydetails Pylon::IStreamGrabber::GetNodeMap() + */ + GENAPI_NAMESPACE::INodeMap* GetNodeMap() + { + CheckPtr(); + return m_pStreamGrabber->GetNodeMap(); + } + + // \} + + + protected: + void CheckPtr() const + { + if (NULL == m_pStreamGrabber) + { + throw LOGICAL_ERROR_EXCEPTION( "The stream grabber class is not attached to a pylon stream grabber" ); + } + } + + IStreamGrabber* m_pStreamGrabber; + }; + + + //************************************************************************************************** + // CStreamGrabberProxyT implementation + //************************************************************************************************** + + template + inline CStreamGrabberProxyT::CStreamGrabberProxyT() + : CNodeMapProxyT(), m_pStreamGrabber( NULL ) + { + } + + template + inline CStreamGrabberProxyT::CStreamGrabberProxyT( IStreamGrabber* pStreamGrabber ) + : CNodeMapProxyT(), m_pStreamGrabber( NULL ) + { + Attach( pStreamGrabber ); + } + + template + inline CStreamGrabberProxyT::~CStreamGrabberProxyT( void ) + { + } + + template + inline void CStreamGrabberProxyT::Attach( IStreamGrabber* pStreamGrabber ) + { + if (IsAttached()) + { + throw LOGICAL_ERROR_EXCEPTION( "Object is already attached to a stream grabber" ); + } + + if (NULL == pStreamGrabber) + { + throw LOGICAL_ERROR_EXCEPTION( "Tried to attach a NULL pointer as stream grabber" ); + } + + CNodeMapProxyT::Attach( pStreamGrabber->GetNodeMap() ); + m_pStreamGrabber = pStreamGrabber; + } + + template + inline bool CStreamGrabberProxyT::IsAttached() const + { + return NULL != m_pStreamGrabber; + } + + template + inline IStreamGrabber* CStreamGrabberProxyT::GetStreamGrabber() const + { + return m_pStreamGrabber; + } + + } // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/StringParameter.h b/Cigarette/Pylon6.2/include/pylon/StringParameter.h new file mode 100644 index 0000000..bf7460a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/StringParameter.h @@ -0,0 +1,310 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains the class CStringParameter used to simplify access to %GenApi parameters. +*/ + +#ifndef INCLUDED_BASLER_PYLON_CSTRINGPARAMETER_H +#define INCLUDED_BASLER_PYLON_CSTRINGPARAMETER_H + +#pragma once + +#include +#include +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class. +# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance +#endif + +namespace Pylon +{ + /*! + \brief Extends the GenApi::IString interface with convenience methods. + */ + interface IStringEx : virtual public GENAPI_NAMESPACE::IString, virtual public IValueEx + { + using GENAPI_NAMESPACE::IString::operator=; + + /*! + \brief Sets the value of the parameter if the parameter is writable. + \return Returns false if the parameter is not writable. + \param[in] value The string value to set. + \pre +
    +
  • The length of the string must be less than GenApi::IString::GetMaxLength(). +
+ \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if the preconditions are not met or if writing the value fails. + */ + virtual bool TrySetValue( const String_t& value ) = 0; + + + /*! + \brief Gets the value of the parameter if the parameter is readable. Otherwise returns the default value. + \return Returns the value of the parameter if the parameter is readable. Otherwise returns the default value. + \param[in] defaultValue The default value returned if the parameter is not readable. + \threading + The method accesses the parameter multiple times. These accesses are not synchronized by a lock. + \error + Can throw exceptions if reading the value fails. + */ + virtual String_t GetValueOrDefault( const String_t& defaultValue ) = 0; + }; + + + /*! + \brief CStringParameter class used to simplify access to %GenApi parameters. + */ + class PYLONBASE_API CStringParameter : public IStringEx, public CParameter + { + public: + /*! + \brief Creates an empty CStringParameter object. + \error + Does not throw C++ exceptions. + */ + CStringParameter(); + + + /*! + \brief Creates a CStringParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to attach. + \post +
    +
  • If the passed node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + explicit CStringParameter( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Creates a CStringParameter object and attaches it to a node of a matching type. + \param[in] pString The node to attach. + \post + The parameter object must not be used to access the node's functionality if the source of the attached \c pString has been destroyed. In this case, call Release() or attach a new node. + \error + Does not throw C++ exceptions. + */ + explicit CStringParameter( GENAPI_NAMESPACE::IString* pString ); + + + /*! + \brief Creates a CStringParameter object and attaches it to a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CStringParameter( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Creates a CStringParameter object and attaches it to a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \post +
    +
  • If \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + CStringParameter( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Copies a CStringParameter object. + \param[in] rhs The object to copy. + \error + Does not throw C++ exceptions. + */ + CStringParameter( const CStringParameter& rhs ); + + + /*! + \brief Destroys the CStringParameter object. + Does not access the attached node. + \error + Does not throw C++ exceptions. + */ + virtual ~CStringParameter(); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] pNodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap* pNodeMap, const char* pName ); + + + /*! + \brief Attaches a node retrieved from the provided node map. + \param[in] nodeMap The node map. The source of the parameter. + \param[in] pName The name of the parameter to attach. + \return Returns true if the node has been attached. + \post +
    +
  • If \c name is NULL the parameter will be empty, see IsValid(). +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node. +
+ \error + The call to GenApi::INodeMap::GetNode can throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INodeMap& nodeMap, const char* pName ); + + + /*! + \brief Attaches a node, typically retrieved for a nodemap calling GetNode(). + \param[in] pNode The node to assign. + \return Returns true if the node has been attached. + \post +
    +
  • If the node does not match the parameter type, the parameter will be empty, see IsValid(). +
  • If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality. +
  • The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node. +
+ \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::INode* pNode ); + + + /*! + \brief Assigns a node of the same type to the parameter object. + \param[in] pString The node to assign. + \return Returns true if the node has been attached. + \error + Does not throw C++ exceptions. + */ + virtual bool Attach( GENAPI_NAMESPACE::IString* pString ); + + + /*! + \brief Assigns a CStringParameter object. + \param[in] rhs The object to assign. + \error + Does not throw C++ exceptions. + */ + CStringParameter& operator=( const CStringParameter& rhs ); + + + /*! + \brief Returns true if the same nodes are attached or both parameters are empty. + \param[in] rhs The object to compare to. + \return Returns true if the same nodes are attached or both parameters are empty. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const CStringParameter& rhs ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pNode The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::INode* pNode ) const; + + + /*! + \brief Returns true if the attached node pointer is equal. + \param[in] pString The node to compare to. + \return Returns true if the attached node pointer is equal. + \error + Does not throw C++ exceptions. + */ + virtual bool Equals( const GENAPI_NAMESPACE::IString* pString ) const; + + + /*! + \brief Releases the attached node. + \error + Does not throw C++ exceptions. + */ + virtual void Release(); + + + // Implements IValueEx + virtual bool IsValid() const; + + + // Implements GenApi::IString + virtual void SetValue( const GENICAM_NAMESPACE::gcstring& value, bool verify = true ); + + // Implements GenApi::IString + virtual GENAPI_NAMESPACE::IString& operator=( const GENICAM_NAMESPACE::gcstring& value ); + + // Implements GenApi::IString + virtual GENICAM_NAMESPACE::gcstring GetValue( bool verify = false, bool ignoreCache = false ); + + // Implements GenApi::IString + virtual GENICAM_NAMESPACE::gcstring operator()(); + + // Implements GenApi::IString + virtual GENICAM_NAMESPACE::gcstring operator*(); + + // Implements GenApi::IString + virtual int64_t GetMaxLength(); + + + // Implements IStringEx + virtual bool TrySetValue( const String_t& value ); + + // Implements IStringEx + virtual String_t GetValueOrDefault( const String_t& defaultValue ); + + protected: + GENAPI_NAMESPACE::IString* m_pFeature; + }; +} +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLER_PYLON_CSTRINGPARAMETER_H */ \ No newline at end of file diff --git a/Cigarette/Pylon6.2/include/pylon/ThreadPriority.h b/Cigarette/Pylon6.2/include/pylon/ThreadPriority.h new file mode 100644 index 0000000..96d133d --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/ThreadPriority.h @@ -0,0 +1,140 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Declaration of methods to control the thread priority +*/ +#ifndef __THREADPRIORITY_H__ +#define __THREADPRIORITY_H__ + + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include "PylonBase.h" + + +namespace Pylon +{ + +#if defined(PYLON_WIN_BUILD) + /** \brief Typedef for a Win32 thread handle + \ingroup PYLON_PUBLIC */ + typedef HANDLE THREADHANDLE; +#elif defined(PYLON_HAS_POSIX_THREADS) + /** \brief Typedef for a pthreads thread handle */ + typedef pthread_t THREADHANDLE; +#else +# error Platform not supported. +#endif + + /** + \brief Queries the range of allowed thread priorities + \ingroup PYLON_PUBLIC + */ + void PYLONBASE_API GetRTThreadPriorityCapabilities( int& prioMin, int& prioMax ); + /** + \brief Indicates the current thread priority of a thread + \ingroup PYLON_PUBLIC + */ + int PYLONBASE_API GetRTThreadPriority( THREADHANDLE thread ); + + /** + \brief Allows to set the realtime thread priority of a thread + \ingroup PYLON_PUBLIC + + \if windows + This method allows to raise a thread's priority into the range + of "realtime" thread priorities. The methods can control each thread + independently. This means that it it not necessary to raise the process to the + "realtime" priority class, which would affect all thread of the process. + + If the process is not in the realtime priority class and if the process has the + SE_INC_BASE_PRIORITY_NAME privilege, values from 15 to 31 can be set. If the + privilege is not granted, only 15 can be set. + + If the process is in the realtime priority class, + values from 16 to 31 can be set. No special permissions are required. + + To grant the privilege, use the Windows policy editor to enable the + SE_INC_BASE_PRIORITY_NAME right (User Rights Assignment / Increase scheduling policy). + Typically, all members of the Administrators group have the privilege enabled. + + Caution: Do not change the process priority class after setting the realtime thread priority. + \endif + + \if linux + Values greater than 0 set the thread's static priority and imply realtime scheduling + (SCHED_RR scheduling policy). When setting the value 0, non-realtime scheduling is used. + The thread's dynamic priority depends on the process' dynamic priority (nice scheduling). + + Setting realtime priorities requires certain permissions. The pylon install guide described + how to grant an application the permissions to set realtime thread priorities. + + \endif + + \if osx + Values greater than 0 set the thread's static priority and imply realtime scheduling + (THREAD_TIME_CONSTRAINT_POLICY scheduling policy). When setting the value 0, non-realtime + scheduling is used and the thread's static priority is set to the highest possible depends + on the process dynamic priority (nice scheduling). + + \endif + + Typically a thread that receives image data should be set to realtime thread priorities + to reduce jitter and delays. Be aware that such a realtime thread shouldn't perform time + consuming tasks (like image processing). A realtime thread that is continuously working can + cause the whole operating system to be blocked! + */ + void PYLONBASE_API SetRTThreadPriority( THREADHANDLE thread, int priority ); + + /** + \brief Get current running thread handle. + + This wrapper method return the handle of the current running thread. + */ + inline THREADHANDLE GetCurrentThreadHandle() + { +#if defined(PYLON_WIN_BUILD) + return ::GetCurrentThread(); +#elif defined(PYLON_HAS_POSIX_THREADS) + return pthread_self(); +#else +# error Platform not supported. +#endif + } + + /** + \brief Get current running thread id. + + This wrapper method return the id of the current running thread. + */ + inline int GetCurrentThreadIdentifier() + { +#if defined(PYLON_WIN_BUILD) + return static_cast(::GetCurrentThreadId()); +#elif defined(PYLON_LINUX_BUILD) + return static_cast(pthread_self()); +#elif defined(PYLON_HAS_POSIX_THREADS) + return reinterpret_cast(pthread_self()); +#else +# error Platform not supported. +#endif + } +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__THREADPRIORITY_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/TlFactory.h b/Cigarette/Pylon6.2/include/pylon/TlFactory.h new file mode 100644 index 0000000..b201990 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/TlFactory.h @@ -0,0 +1,165 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of CTlFactory class +*/ + +#ifndef __TLFACTORY_H__ +#define __TLFACTORY_H__ + +#if _MSC_VER>1000 +#pragma once +#endif // _MSC_VER>1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include + + +namespace Pylon +{ + // forwards + class CSimpleMutex; + class CTlInfo; + interface ITransportLayer; + interface IDeviceFactory; + class TlMap; + class ImplicitTlRefs; + + //------------------------------------------------------------------------ + // class CTlFactory + //------------------------------------------------------------------------ + /*! + \ingroup Pylon_TransportLayer + \brief the Transport Layer Factory + + Creates, Destroys and Enumerates transport layers as well as + their devices. + */ + class PYLONBASE_API CTlFactory : public IDeviceFactory + { + public: + /////////////////////////////////////////////////////////////////////// + /// Retrieve the transport layer factory singleton. + /// Throws an exception when Pylon::PylonInitialize() has not been called before. + static CTlFactory& GetInstance(); + + /** + \brief Retrieves a list of available transport layers. + + The list contains Pylon::CTlInfo objects used for transport layer creation. + + \param list List to be filled with transport layer info objects. + \return Number of transport layers found. + */ + int EnumerateTls( TlInfoList_t& list ); + + /** + \brief Creates a transport layer object from a transport layer info object. + + This method accepts a transport layer info object which can be obtained by calling EnumerateTls. + For each successfully returned transport layer object, you must call ReleaseTl to free the transport layer object. + + If the creation fails, a GenApi::GenericException will be thrown. + + \param ti Transport layer info object specifying which transport layer to create. + \return Pointer to the transport layer object created. If no matching transport layer could be found, NULL will be returned. + */ + ITransportLayer* CreateTl( const CTlInfo& ti ); + + /** + \brief Creates a transport layer object from a device class string. + + This method accepts a device class string. You can see a list of available device classes in the DeviceClass.h file. + For each successfully returned transport layer object, you must call ReleaseTl to free the transport layer object. + + If the creation fails, a GenApi::GenericException will be thrown. + + \param deviceClass Transport layer info object specifying which transport layer to create. + \return Pointer to the transport layer object created. If no matching transport layer could be found, NULL will be returned. + */ + ITransportLayer* CreateTl( const String_t& deviceClass ); + + /** + \brief Releases a transport layer object created by a call to CreateTl(). + + For each successfully returned transport layer object from any CreateTl() function, + you must call this function to free the transport layer object. + + \param pTl Pointer to the transport layer object to be released. + */ + void ReleaseTl( const ITransportLayer* pTl ); + + // returns a list of available devices, see IDeviceFactory for more information + virtual int EnumerateDevices( DeviceInfoList_t&, bool addToList = false ); + + // returns a list of available devices that match the filter, see IDeviceFactory for more information + virtual int EnumerateDevices( DeviceInfoList_t& list, const DeviceInfoList_t& filter, bool addToList = false ); + + // creates a device from a device info object, see IDeviceFactory for more information + virtual IPylonDevice* CreateDevice( const CDeviceInfo& di ); + + // creates first found device from a device info object, see IDeviceFactory for more information + virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di = CDeviceInfo() ); + + // creates a device from a device info object, injecting additional GenICam XML definition strings + virtual IPylonDevice* CreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ); + + // creates first found device from a device info object, injecting additional GenICam XML definition strings + virtual IPylonDevice* CreateFirstDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings ); + + // Use CreateDevice and pass a CDeviceInfo object containing the full name as a property. + // example: IPylonDevice* device = TlFactory.CreateDevice(CDeviceInfo().SetFullName(fullname)); + // creates a device that matches its full name (i.e., as returned by CDeviceInfo::GetFullName). + virtual IPylonDevice* CreateDevice( const String_t& ); + + // destroys a device + virtual void DestroyDevice( IPylonDevice* ); + + // implements IDeviceFactory::IsDeviceAccessible + virtual bool IsDeviceAccessible( const CDeviceInfo& deviceInfo, AccessModeSet mode = Control, EDeviceAccessiblityInfo* pAccessibilityInfo = NULL ); + + protected: + void InternalEnumerateTls( TlInfoList_t& ); + virtual IPylonDevice* InternalCreateDevice( const CDeviceInfo& di, const StringList_t& InjectedXmlStrings, bool allowAnyFirstFound ); + + TlMap* m_pTls; + ImplicitTlRefs* m_pImplicitlyCreatedTls; + CSimpleMutex* m_pMemberLock; + + private: + void Terminate( void ); + void checkInitialized( void ); // fires an exception when Terminate() already has been called + + CTlFactory( void ); + CTlFactory& operator=( const CTlFactory& ); + CTlFactory( const CTlFactory& ); + + virtual ~CTlFactory( void ); + + friend void Pylon::PylonInitialize(); + friend void Pylon::PylonTerminate( bool ); + friend void Pylon::SetProperty( int propertyId, const void* pData, size_t size ); + friend void Pylon::GetProperty( int propertyId, void* pData, size_t* pSize ); + }; + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* __TLFACTORY_H__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/TlInfo.h b/Cigarette/Pylon6.2/include/pylon/TlInfo.h new file mode 100644 index 0000000..bf12515 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/TlInfo.h @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of Transport layer information object +*/ + +#ifndef __TLINFO_H__ +#define __TLINFO_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + namespace Key + { + ///Identifies the filename of the GenTL producer [GenTL consumer only]. + const char* const FileNameKey = "FileName"; + ///Identifies the InfoID of the GenTL producer [GenTL consumer only]. + const char* const InfoIDKey = "InfoID"; + ///Identifies the filename of the GenTL producer. + const char* const VersionKey = "Version"; + } // namespace Key + + /** + \ingroup Pylon_TransportLayer + \brief Class used for storing the result of the transport + layer enumeration process. + + Enumerating the available Transport Layer objects returns a list of + CTlInfo objects (Pylon::TlInfoList_t). A CTlInfo object holds information + about the enumerated transport layer. + */ + class PYLONBASE_API CTlInfo : public CInfoBase + { + public: + ///Retrieves the filename of the GenTL producer [GenTL consumer only]. + ///This property is identified by Key::FileNameKey. + String_t GetFileName() const; + ///Sets the above property. + CTlInfo& SetFileName( const String_t& value ); + ///Returns true if the above property is available. + bool IsFileNameAvailable() const; + + ///Retrieves the InfoID of the GenTL producer [GenTL consumer only]. + ///This property is identified by Key::VendorNameKey. + String_t GetInfoID() const; + ///Sets the above property. + CTlInfo& SetInfoID( const String_t& value ); + ///Returns true if the above property is available. + bool IsInfoIDAvailable() const; + + ///Retrieves the model name of the data producer + ///This property is identified by Key::ModelNameKey. + String_t GetModelName() const; + ///Sets the above property. + CTlInfo& SetModelName( const String_t& value ); + ///Returns true if the above property is available. + bool IsModelNameAvailable() const; + + ///Retrieves the version of the transport layer. + ///This property is identified by Key::VersionKey. + String_t GetVersion() const; + ///Sets the above property. + CTlInfo& SetVersion( const String_t& value ); + ///Returns true if the above property is available. + bool IsVersionAvailable() const; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* __TLINFO_H__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/TransportLayer.h b/Cigarette/Pylon6.2/include/pylon/TransportLayer.h new file mode 100644 index 0000000..722926f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/TransportLayer.h @@ -0,0 +1,140 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definiton of Transportlayer interface and the common Transportlayer base class +*/ + +#ifndef __TRANSPORTLAYER__ +#define __TRANSPORTLAYER__ + +#if _MSC_VER>1000 +#pragma once +#endif // _MSC_VER>1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include +#include +#include +#include + + +namespace Pylon +{ + + + /*! + \ingroup Pylon_TransportLayer + \interface ITransportLayer + \brief The interface of Transport Layer objects + + Transport Layer objects are used for enumerating and creating devices accessible + by a specific transport layer (like the Pylon1394 or the PylonGigE transport layer). + */ + interface PUBLIC_INTERFACE ITransportLayer : public IDeviceFactory + { + /*! + \brief Returns a CTlInfo object holding information about the transport layer. + + \return Returns a CTlInfo object holding information about the transport layer. + */ + virtual CTlInfo GetTlInfo() const = 0; + + + /*! + \brief Creates and returns an 'empty' Device Info object appropriate for the transport layer. + + Device Info objects returned by the CreateDeviceInfo() method are used to create + devices from device info objects that are not the result of a device enumeration process but are + provided by the user. The user is responsible for + filling in the fields of the Device Info object that are needed to identify and create a device. + + Example: To open a GigE device for which the IP address is known, the user lets the Transport Layer object + create a Device Info object, specifies the IP address and passes the device info object to the + CreateDevice() method. + */ + virtual CDeviceInfo CreateDeviceInfo() = 0; + + + /*! \brief Returns the GenApi node map used for accessing parameters provided by the transport layer. + + \return NULL, if the transport layer doesn't provide parameters, a pointer to the parameter node map otherwise. + */ + virtual GENAPI_NAMESPACE::INodeMap* GetNodeMap() = 0; + + + /*! \brief Retrieves a list of available interfaces. An interface may represent a frame grabber board, a network card, etc. + + \note Currently, this method is used mainly for the pylon GenTL Consumer transport layer, which is used for CoaXPress, for example. + All other pylon transport layers return one default interface. The default interface will forward + all IDeviceFactory methods to the transport layer that created the interface object. The default interface does not provide a node map. + + \param[out] list The list to be filled with interface info objects. The list contains Pylon::CInterfaceInfo objects used for the interface + creation. It is ordered by device class and interface ID using the operator Pylon::CInterfaceInfo::operator<(). + \param[in] addToList If true, devices found will be added to the list instead of clearing the list. + By default, the list passed in will be cleared. + \return Number of interfaces provided by the transport layer. + + \threading + This method is thread-safe. + + \error + Can throw C++ exceptions. + */ + virtual int EnumerateInterfaces( InterfaceInfoList_t& list, bool addToList = false ) = 0; + + + /*! \brief Creates an interface object from an interface info object. + + + \param[in] interfaceInfo The Interface info object. You can pass an interface info object returned by EnumerateInterfaces() + or a user-provided interface info object. + User-provided interface info objects can be preset with properties required for an interface, e.g. + the interface ID. The implementation tries to find a matching interface. + \return Returns the pointer to the interface created. + + \post The interface created must be freed by calling DestroyInterface(). The transport layer is not destroyed as long as the interface is not destroyed. + Never try to delete a pointer to an interface object by calling free or delete. Always use the DestroyInterface() method. + + \error + Throws an exception if creating the interface fails. + + \threading + This method is thread-safe. + */ + virtual IInterface* CreateInterface( const CInterfaceInfo& interfaceInfo ) = 0; + + + /*! \brief Destroys an interface. + + \param[in] pInterface The pointer to an interface created by this transport layer. + + \pre The interface has been created by this transport layer using CreateInterface() and has not been destroyed using DestroyInterface() yet. + \post The interface is deleted and must not be used any longer. + + \error + Throws a C++ exception if the preconditions are not met. + + \threading + This method is thread-safe. + */ + virtual void DestroyInterface( IInterface* pInterface ) = 0; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* __TRANSPORTLAYER__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/TypeMappings.h b/Cigarette/Pylon6.2/include/pylon/TypeMappings.h new file mode 100644 index 0000000..8cb0870 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/TypeMappings.h @@ -0,0 +1,163 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/** \file +\brief Maps GenICam/GenApi types to pylon namespace +*/ + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include + +#include // for PYLON_PACKING + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + /// Pylon's string definition + typedef GENICAM_NAMESPACE::gcstring String_t; + + /// Pylon's string list definition + typedef GENICAM_NAMESPACE::gcstring_vector StringList_t; + + // pull genicam exceptions into the pylon namespace + // we provide mappings so the user can use the Pylon namespace and don't have to think about + // whether to use GenApi or GENICAM_NAMESPACE namespace + + using GENICAM_NAMESPACE::GenericException; + using GENICAM_NAMESPACE::BadAllocException; + using GENICAM_NAMESPACE::InvalidArgumentException; + using GENICAM_NAMESPACE::OutOfRangeException; + using GENICAM_NAMESPACE::PropertyException; + using GENICAM_NAMESPACE::RuntimeException; + using GENICAM_NAMESPACE::LogicalErrorException; + using GENICAM_NAMESPACE::AccessException; + using GENICAM_NAMESPACE::TimeoutException; + using GENICAM_NAMESPACE::DynamicCastException; + + // locks + using GENAPI_NAMESPACE::CLock; + using GENAPI_NAMESPACE::AutoLock; + + // INodeMap, INode etc. are not mapped + + +// this is only used for documentation purpose +#ifdef DOXYGEN_INVOKED + /** + \brief pylon exception class + + This is pylons exception class. It is also used as a base class for all other pylon exceptions. + To catch all pylon and genicam exceptions it is sufficient to catch GenericException. + */ + class GenericException + { + public: + /// Constructs an exception + GenericException( const char* pDescription, const char* pSourceFileName, unsigned int SourceLine ); + /// Returns error description + virtual const char* GetDescription() const throw(); + /// Returns the filename of the file where the exception was thrown + virtual const char* GetSourceFileName() const throw(); + /// Returns the line number of the file where the exception was thrown + virtual unsigned int GetSourceLine() const throw(); + /// Returns a descriptive text of the exception + virtual const char* what() const throw(); + }; + + /// Exception thrown if memory could not be allocated + DECLARE_PYLON_EXCEPTION( BadAllocException ); + + /// Exception thrown if an argument passed is invalid + DECLARE_PYLON_EXCEPTION( InvalidArgumentException ); + + /// Exception thrown if an argument is out of range + DECLARE_PYLON_EXCEPTION( OutOfRangeException ); + + /// Exception thrown if a property access fails + DECLARE_PYLON_EXCEPTION( PropertyException ); + + /// Exception thrown if a runtime error occurs + DECLARE_PYLON_EXCEPTION( RuntimeException ); + + /// Exception thrown to indicate logical errors in program flow + DECLARE_PYLON_EXCEPTION( LogicalErrorException ); + + /// Exception thrown to indicate an access error. (i.E. A when trying to set a read-only value) + DECLARE_PYLON_EXCEPTION( AccessException ); + + /// Exception thrown when a timeout has elapsed. + DECLARE_PYLON_EXCEPTION( TimeoutException ); + + /// Exception thrown to indicate a dynamic cast has failed. Usually this means a value is not of expected type. + DECLARE_PYLON_EXCEPTION( DynamicCastException ); + + /** + \brief A simple recursive lock class. + \sa AutoLock + */ + class CLock + { + public: + /// Constructs a lock object. The lock is not initially locked. + CLock(); + ~CLock(); + + /// Tries to acquire the lock. If the lock currently locked by another thread the function returns immediately and returns false. + bool TryLock(); + + /// Acquires the lock. If the lock is currently held by another thread the function waits until the other thread releases the lock. + void Lock(); + + /// Releases the lock. + void Unlock(); + }; + + /** + \brief A scoped lock class to acquire and release a CLock upon creation and destruction + + Use this class to created scoped lock. + To acquire the lock just create a CAutoLock object. When the object will be destroyed it will automatically release the lock. + \code +int SampleFunction(Pylon::CLock & lock) +{ + // acquire lock + Pylon::AutoLock scopedLock(lock); + + // perform operation requiring lock to be held here + + return 1; + + // lock will be released automatically when scopedLock goes out of scope and is destroyed +} + \endcode + \sa CLock + */ + class AutoLock + { + /// Locks the CLock object passed in the parameter lock + AutoLock( CLock& lock ); + /// Releases the CLock object passed in the constructor + ~AutoLock(); + }; + +#endif + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ diff --git a/Cigarette/Pylon6.2/include/pylon/VideoWriter.h b/Cigarette/Pylon6.2/include/pylon/VideoWriter.h new file mode 100644 index 0000000..fe253c8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/VideoWriter.h @@ -0,0 +1,266 @@ +//------------------------------------------------------------------------------ +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +// Author: DV +//------------------------------------------------------------------------------ +/*! +\file +\brief Contains support for writing video files in MP4 format, provided by a supplementary software package. +*/ +#ifndef INCLUDED_VIDEOWRITER_H_3842348390 +#define INCLUDED_VIDEOWRITER_H_3842348390 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4275 ) // Class must have a dll interface to be used by clients of the class. +#endif + +#include +#include +#include +#include +#include + + + + +namespace Pylon +{ + class CVideoWriterImpl; + using namespace Basler_VideoWriterParams; + + /*! + \class CVideoWriter + \brief Supports writing video files. + \note Note that a supplementary software package containing additional libraries has to be installed for this. + */ + class PYLONUTILITY_API CVideoWriter : public Basler_VideoWriterParams::CVideoWriterParams_Params + { + public: + /*! + \brief Creates a video writer object. + + \error + Throws a RuntimeException when no memory can be allocated. + */ + CVideoWriter(); + + /*! + \brief Destroys the video writer object. + + \error + Does not throw C++ exceptions. + */ + virtual ~CVideoWriter(); + + /*! + \brief Checks if video writing is supported. + + Checks if all necessary dynamic libraries of the supplementary software package are installed and can be loaded. + This does not check if the codec for the video can be used. This is checked in Open(). + + \return Returns true if video writing is supported. + + \error + Does not throw C++ exceptions. + */ + static bool IsSupported(); + + /*! + \brief Easy way to set parameters required for video recording. + + This is a convenient way to set all required parameters in a single function call. + The parameters \c width, \c height, \c framesPerSecondPlaybackSpeed and \c quality are set in the nodemap. + The parameter \c inputPixelType is checked for its convertibility to YUV420p or whether it is already YUV420p. + Advanced parameters can be accessed using the nodemap provided by GetNodeMap(). + + \param[in] width The number of pixels in a row of the video file to save. + \param[in] height The number of rows of the video file to save. + \param[in] inputPixelType The pixel type of the images that will be added to the video writer. This input is used to derive the video format. Currently the output is always YUV420p. + \param[in] framesPerSecondPlaybackSpeed The playback speed in frames per second. + \param[in] quality The quality setting, valid range is 1 ... 100. + + \pre The VideoWriter ist closed. + + \error + Throws a C++ exception when a parameter is out of range, set to an invalid value or parameters cannot be changed (e.g., after calling Open()). + */ + virtual void SetParameter( + uint32_t width, uint32_t height, + EPixelType inputPixelType, + double framesPerSecondPlaybackSpeed, + uint32_t quality + ); + + /*! + \brief Opens a video file for writing. + + If a file with the same \c filename already exists, it will be overwritten. + + \param[in] filename Name and path of the video file. + + \pre +
    +
  • The VideoWriter ist closed. +
  • The width and height parameters are larger than 1. +
+ + \error + Throws an exception if the video file cannot be opened. + Throws an exception if the current parameters do not meet codec requirements. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Open( const Pylon::String_t& filename ); + + /*! + \brief Returns the open state of the video file. + + \return Returns true if open. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual bool IsOpen() const; + + /*! + \brief Closes the video file. + + \error + Does not throw C++ exceptions. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Close(); + + /*! + \brief Adds the image to the video file. Converts the image to the correct format if required. + + The image is automatically converted to YUV420p unless the input \c pixelType is already YUV420p. + The orientation of the image is always converted to \c ImageOrientation_TopDown unless the input\c pixelType is + YUV420p. In that case, the \c orientation of the image must already be \c ImageOrientation_TopDown. See preconditions. + + \param[in] pBuffer The pointer to the buffer of the image. + \param[in] bufferSize The size of the buffer in byte. + \param[in] pixelType The pixel type of the image to save. + \param[in] width The number of pixels in a row of the image to save. + \param[in] height The number of rows of the image to save. + \param[in] paddingX The number of extra data bytes at the end of each line. + \param[in] orientation The vertical orientation of the image in the image buffer. + + \pre +
    +
  • The file is open. +
  • The image added is valid. +
  • The \c pixelType of the image to add is a supported input format of the Pylon::CImageFormatConverter or YUV420p. +
  • If the pixelType is YUV420p the \c orientation has to be \c ImageOrientation_TopDown. +
  • The width and height of the image match the values passed when opening the video file. +
+ + \error + Throws an exception if the image cannot be added. + + \threading + This method is synchronized using the lock provided by GetLock(). + + */ + virtual void Add( const void* pBuffer, size_t bufferSize, Pylon::EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, Pylon::EImageOrientation orientation ); + + /*! + \brief Adds the image to the video file. Converts the image to the correct format if required. + + The image is automatically converted to YUV420p unless the input \c pixelType is already YUV420p. + The orientation of the image is always converted to \c ImageOrientation_TopDown unless the input \c pixelType is + YUV420p. In that case, the \c orientation of the image must already be \c ImageOrientation_TopDown. See preconditions. + + \param[in] image The image to add, e.g., a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + + \pre +
    +
  • The file is open. +
  • The image added is valid. +
  • The \c pixelType of the image to add is a supported input format of the Pylon::CImageFormatConverter or YUV420p. +
  • If the pixelType is YUV420p the \c orientation has to be \c ImageOrientation_TopDown. +
  • The width and height of the image match the values passed when opening the video file. +
+ + \error + Throws an exception if the image cannot be added. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual void Add( const Pylon::IImage& image ); + + /*! + \brief Can be used to check whether the given image is added to the video file without prior conversion when Add() is called. + + \param[in] pixelType The pixel type of the image to save. + \param[in] width The number of pixels in a row of the image to save. + \param[in] height The number of rows of the image to save. + \param[in] paddingX The number of extra data bytes at the end of each row. + \param[in] orientation The vertical orientation of the image data in the video file. + + \return Returns true if the image is added to the video stream without prior conversion when Add() is called. + Returns false if the image is automatically converted when Add() is called. + Returns false if the image cannot be added at all. See the preconditions of Add() for more information. + + \error + Does not throw C++ exceptions. + */ + virtual bool CanAddWithoutConversion( Pylon::EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, Pylon::EImageOrientation orientation ); + + /*! + \brief Can be used to check whether the given image is added to the video file without prior conversion when Add() is called. + + \param[in] image The image to save, e.g. a CPylonImage, CPylonBitmapImage, or Grab Result Smart Pointer object. + \return Returns true if the image is added to the video stream without prior conversion when Add() is called. + Returns false if the image is automatically converted when Add() is called. + Returns false if the image cannot be added at all. See the preconditions of Add() for more information. + + \error + Does not throw C++ exceptions. + */ + virtual bool CanAddWithoutConversion( const Pylon::IImage& image ); + + /*! + \brief Provides access to all parameters via a nodemap. + \error + Does not throw C++ exceptions. + */ + virtual GENAPI_NAMESPACE::INodeMap& GetNodeMap(); + + protected: + /*! + \brief Provides access to the lock used for synchronizing the access to the video writer. + \error + Does not throw C++ exceptions. + */ + CLock& GetLock(); + + private: + CVideoWriterImpl* m_pImpl; + }; +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // INCLUDED_VIDEOWRITER_H_3842348390 diff --git a/Cigarette/Pylon6.2/include/pylon/WaitObject.h b/Cigarette/Pylon6.2/include/pylon/WaitObject.h new file mode 100644 index 0000000..c9be012 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/WaitObject.h @@ -0,0 +1,282 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Urs Helmig +//----------------------------------------------------------------------------- +/*! +\file +\brief Declaration of WaitObject classes +*/ +#ifndef __WAITOBJECT_H__ +#define __WAITOBJECT_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include +#include + + +#if defined (PYLON_UNIX_BUILD) +struct _WaitObjectPosix_t; +#endif + + +namespace Pylon +{ + // ------------------------------------------------------------------------- + // enum EWaitExResult + // ---------------------------------------------------------------------- + /*! + \brief The return value of the Pylon::WaitObject::WaitEx() and Pylon::WaitObjectEx::WaitEx() methods + \ingroup PYLON_PUBLIC + */ + // ---------------------------------------------------------------------- + enum EWaitExResult + { + waitex_timeout = 0, //!< The time-out interval elapsed + waitex_signaled = 1, //!< The wait operation completed successfully + waitex_abandoned = 2, //!< Windows only (see MSDN for more information) + waitex_alerted = -1 //!< The wait was interrupted (Windows: queued APC or I/O completion routine; UNIX: signal) + }; + +#if defined(PYLON_WIN_BUILD) + typedef HANDLE WaitObject_t; +#elif defined(PYLON_UNIX_BUILD) + typedef struct _WaitObjectPosix_t* WaitObject_t; +#endif + + +#if defined (PYLON_UNIX_BUILD) + + // ------------------------------------------------------------------------- + // enum ready_mask_t + // ---------------------------------------------------------------------- + /*! + \brief File descriptor ready mask + + Return value of the Pylon::WaitObject::GetReadyMask() method. Indicates to which type of file descriptor set a wait object's file descriptor + is to be added when using the file descriptor as input for the select() or poll() function. + + Example: When the ready_read bit of a wait object's GetReadyMask() value is set, add the wait object's file descriptor to the read file descriptor set. + + + \ingroup PYLON_PUBLIC + */ + // ---------------------------------------------------------------------- + enum ready_mask_t + { + ready_none = 0x00, //!< The file descriptor is not valid + ready_read = 0x01, //!< The file desriptor is to be added to a read file descriptor set + ready_write = 0x02, //!< The file descriptor is to be added to a write file descriptor set + ready_except = 0x04 //!< The file descriptor is to be added to a exception file descriptor set + }; +#endif + + // ---------------------------------------------------------------------- + const unsigned int waitForever = 0xFFFFFFFF; + +#if defined (PYLON_UNIX_BUILD) +# ifndef INFINITE +# define INFINITE waitForever +# endif +#endif + + // ---------------------------------------------------------------------- + /*! + \brief A platform independent wait object. + + Wait objects are used by the Pylon::IStreamGrabber and Pylon::IEventGrabber interfaces to provide a platform independent mechanism for + allowing an application to wait for data buffers to be filled. + + For the Windows version of pylon, WaitObjects are wrappers for Win32 objects that can be used with \c WaitForSingleObject() and \c WaitForMultipleObjects(). + + For the Linux version of pylon, WaitObjects are implemented based on file descriptors. The wait operation is implemented using the \c poll() function. + + Although the class provides a default constructor, the default constructor doesn't create a "usable" wait objects wrapping a handle resp. file descriptor. + Valid instances of Pylon::WaitObject cannot be created by the application, instead the pylon libraries return fully created wait objects. + The Pylon::WaitObjectEx class can be used to create wait objects that can be controlled by the application. + + The Pylon::WaitObject class provides access to the wrapped handle resp. file descriptor. This allows to use to allow use pylon wait objects as input for + "native" APIs like \c WaitForMultipleObjects() (Windows), and \c poll() (Linux). + + Multiple Pylon::WaitObjects can be put in the Pylon::WaitObjects container class allowing to wait "simultaneously" for multiple events. + + + \ingroup PYLON_PUBLIC + */ + // ---------------------------------------------------------------------- + class PYLONBASE_API WaitObject + { + // ------------------------------- + // Platform independent + // ------------------------------- + public: + /// Constructs an "empty" wait object, i.e., the wait object is not attached to a platform dependent wait object (IsValid() == false) + /** The Pylon::WaitObjectEx class can be used to create wait objects controllable by an application. */ + WaitObject(); + /// Destructor + virtual ~WaitObject(); + /// Copy constructor (duplicates the wrapped handle/file descriptor) + WaitObject( const WaitObject& ); + /// Assignment operator (duplicates the wrapped handle/file descriptor) + WaitObject& operator=( const WaitObject& ); + + /// Suspend calling thread for specified time. + /** + \param ms wait time in ms + */ + static void Sleep( unsigned long ms ); + + public: + /// Checks if the wait object is valid. + /** + Don't call the Wait methods() for an invalid wait object. Wait objects returned by the pylon libraries are valid. + \return true if the object contains a valid handle/file descriptor + */ + bool IsValid() const; + + public: + /// Wait for the object to be signaled + /** + \param timeout timeout in ms + \return false when the timeout has been expired, true when the waiting was successful before + the timeout has been expired. + */ + bool Wait( unsigned int timeout ) const; + + /// Wait for the object to be signaled (interruptible) + /** + + \param timeout timeout in ms + \param bAlertable When the bAlertable parameter is set to true, the function waits until either the timeout elapses, the object enters + the signaled state, or the wait operation has been interrupted. + For Windows, the wait operation is interrupted by queued APCs or I/O completion routines. + For Linux, the wait operation can be interrupted by signals. + + \return The returned Pylon::EWaitExResult value indicates the result of the wait operation. + + */ + EWaitExResult WaitEx( unsigned int timeout, bool bAlertable ) const; + + + // ------------------------------- + // Windows-specific stuff + // ------------------------------- + public: + /// Constructor taking existing handle (duplicate=false -> take ownership like std:auto_ptr) + /** This method allows to wrap an existing windows handle that can be used with the \c WaitForSingleObject() and + \c WaitForMultipleObjects methods. */ + WaitObject( WaitObject_t h, bool duplicate = true ); + + +#if defined(PYLON_WIN_BUILD) + /// conversion operator + /** \return the native Win32 handle wrapped by the WaitObject. (Not supported by pylon4Linux) */ + operator WaitObject_t() const; + + protected: + WaitObject_t Duplicate( WaitObject_t h ) const; + + protected: + WaitObject_t m_Native; +#endif + + +#if defined (PYLON_UNIX_BUILD) + + /// Invalidates the internal wait object. + void Destroy(); + + protected: + + WaitObject_t m_pWaitObjectPosix; + + // ------------------------------- + // Linux specific stuff + // ------------------------------- + public: + + /// Getter for file descriptor + /** \return the file descriptor wrapped by the WaitObject. When the file descriptor is added to the file descriptor set indicated by the + GetReadyMask() method, the \c select() or poll() function can be used to wait for pylon and non-pylon events simultaneously. + */ + int GetFd( void ) const; + + /// Indicates to what kind of file descriptor set the wrapped file descriptor must be put for usage with the \c select() or poll() function. + ready_mask_t GetReadyMask() const; + + /// conversion operator + /** \return the internal wait object handle. (Not supported by pylon4Windows) */ + operator struct _WaitObjectPosix_t* () const; + + /// Accessor to internal wait object (not supported by pylon for Windows) + WaitObject_t& GetWaitObject(); +#endif + + }; + + + // ---------------------------------------------------------------------- + /*! + \brief A wait object that the user may signal + \ingroup PYLON_PUBLIC + */ + // ---------------------------------------------------------------------- + class PYLONBASE_API WaitObjectEx : public WaitObject + { + // ------------------------------- + // Platform independent + // ------------------------------- + public: + /// Creates an event object (manual reset event) + static WaitObjectEx Create( bool initiallySignalled = false ); + + + /// Constructs an "empty" wait object, i.e., the wait object is not attached to a platform dependent wait object (IsValid() == false) + /** Use the static WaitObjectEx::Create() method to create instances of the WaitObjectEx class instead. */ + WaitObjectEx(); + + /// Destroys the waitobject + virtual ~WaitObjectEx() + { + } + public: + /// Set the object to signaled state + void Signal(); + /// Reset the object to unsignaled state + void Reset(); + + public: + // ------------------------------- + // Windows and OSX specific stuff + // ------------------------------- +#if defined(PYLON_WIN_BUILD) || defined(PYLON_OSX_BUILD) + /// Constructor using an existing windows handle (duplicate=false -> take ownership like std:auto_ptr) + explicit WaitObjectEx( WaitObject_t h, bool duplicate = true ); +#endif + + // ------------------------------- + // Linux specific stuff + // ------------------------------- +#if defined(PYLON_UNIX_BUILD) + /// Constructor using an existing Linux file descriptor + explicit WaitObjectEx( int fd ); +#endif + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__WAITOBJECT_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/WaitObjects.h b/Cigarette/Pylon6.2/include/pylon/WaitObjects.h new file mode 100644 index 0000000..49f437b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/WaitObjects.h @@ -0,0 +1,110 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Urs Helmig +//----------------------------------------------------------------------------- +/*! +\file +\brief Declaration of WaitObjects class +*/ +#ifndef __WAITOBJECTS_H__ +#define __WAITOBJECTS_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class WaitObject; + enum EWaitExResult; + namespace PylonPrivate + { + struct WaitObjectsImpl; + } + + // ------------------------------------------------------------------------- + // class WaitObjects + // ---------------------------------------------------------------------- + /*! + \brief A set of wait objects + \ingroup PYLON_PUBLIC + */ + // ---------------------------------------------------------------------- + class PYLONBASE_API WaitObjects + { + public: + /// Creates an empty wait object set + WaitObjects(); + /// destructor + ~WaitObjects(); + /// copy constructor + WaitObjects( const WaitObjects& ); + /// assignment operator + WaitObjects& operator=( const WaitObjects& ); + + public: + /// Add an object to wait on and return the index of the added object + /*! + Calling Add from another thread during wait operations will cause undefined behaviour. + */ + unsigned Add( const WaitObject& o ); + + /// Removes all added wait objects + /*! + Calling RemoveAll from another thread during wait operations will cause undefined behaviour. + */ + void RemoveAll( void ); + + /// Wait for all objects to get signaled + /*! + \param timeout maximum wait period in milliseconds + \return true if all objects were signaled + */ + bool WaitForAll( unsigned timeout ) const; + + /// Wait for any one object to get signaled + /*! + \param timeout maximum wait period in milliseconds + \param *pIndex (optional) pointer to buffer taking the index of + the signaled object + \return true if any object was signaled. + */ + bool WaitForAny( unsigned timeout, unsigned* pIndex = NULL ) const; + + /// Wait for all objects to get signaled + /*! + \param bAlertable If true, the wait operation can be interrupted (Windows: APC; UNIX: signal) + \param timeout maximum wait period in milliseconds + */ + EWaitExResult WaitForAllEx( unsigned timeout, bool bAlertable ) const; + + + /// Wait for any one object to get signaled + /*! + \param timeout maximum wait period in milliseconds + \param bAlertable If true, the wait operation can be interrupted (Windows: APC; UNIX: signal) + \param *pIndex (optional) pointer to buffer taking the index of + the signaled object + */ + EWaitExResult WaitForAnyEx( unsigned timeout, bool bAlertable, unsigned* pIndex = NULL ) const; + + private: + PylonPrivate::WaitObjectsImpl* m_pImpl; + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__WAITOBJECTS_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/XmlFileProvider.h b/Cigarette/Pylon6.2/include/pylon/XmlFileProvider.h new file mode 100644 index 0000000..569a9fd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/XmlFileProvider.h @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\internal +\brief Declaration of the IXmlFileProvider interface +*/ + +#ifndef __PYLONXMLFILEPROVIDER_H__ +#define __PYLONXMLFILEPROVIDER_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + + +namespace Pylon +{ + class CDeviceInfo; + + /** + \internal + */ + interface PUBLIC_INTERFACE IXmlFileProvider + { + virtual bool CanProvideXmlFile( const CDeviceInfo& ) = 0; + virtual void ProvideXmlFile( + const CDeviceInfo& di, + String_t& RecommendedFileName, + String_t& XmlString + ) = 0; + }; + +} + + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* __PYLONXMLFILEPROVIDER_H__ */ + diff --git a/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalCameraParams.h b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalCameraParams.h new file mode 100644 index 0000000..22d66d1 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalCameraParams.h @@ -0,0 +1,16251 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for Basler camera devices + +The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. +The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_UNIVERSALCAMERAPARAMS_H +#define BASLER_PYLON_UNIVERSALCAMERAPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_UniversalCameraParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for AcquisitionFrameRateEnum + enum AcquisitionFrameRateEnumEnums + { + AcquisitionFrameRateEnum_FrameRate24, //!< Applies to: CameraLink + AcquisitionFrameRateEnum_FrameRate25, //!< Applies to: CameraLink + AcquisitionFrameRateEnum_FrameRate30, //!< Applies to: CameraLink + AcquisitionFrameRateEnum_FrameRate50, //!< Applies to: CameraLink + AcquisitionFrameRateEnum_FrameRate60 //!< Applies to: CameraLink + }; + + //! Valid values for AcquisitionMode + enum AcquisitionModeEnums + { + AcquisitionMode_Continuous, //!< The acquisition mode is set to Continuous - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + AcquisitionMode_MultiFrame, //!< The acquisition mode is set to Multi Frame - Applies to: CameraLink and GigE + AcquisitionMode_SingleFrame //!< The acquisition mode is set to Single Frame - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for AcquisitionStatusSelector + enum AcquisitionStatusSelectorEnums + { + AcquisitionStatusSelector_AcquisitionActive, //!< A check determines whether the camera is currently acquiring one or multiple frames - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + AcquisitionStatusSelector_AcquisitionIdle, //!< A check determines whether the camera is currently idle - Applies to: GigE + AcquisitionStatusSelector_AcquisitionTransfer, //!< A check determines whether the camera is currently transferring an acquisition of one or multiple frames - Applies to: CameraLink and GigE + AcquisitionStatusSelector_AcquisitionTriggerWait, //!< A check determines whether the camera is currently waiting for a trigger to acquire one or multiple frames - Applies to: CameraLink and GigE + AcquisitionStatusSelector_ExposureActive, //!< A check determines whether the camera is currently exposing a frame - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + AcquisitionStatusSelector_ExposureTriggerWait, //!< A check determines whether the camera is currently waiting for an Exposure Start trigger signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + AcquisitionStatusSelector_FrameActive, //!< A check determines whether the camera is currently capturing a frame - Applies to: CameraLink, GigE and ace USB + AcquisitionStatusSelector_FrameBurstActive, //!< A check determines whether the camera is currently doing a frame burst of one or many frames - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + AcquisitionStatusSelector_FrameBurstTriggerActive, //!< A check can be performed if the device is currently doing a frame burst of one or many frames - Applies to: ace USB + AcquisitionStatusSelector_FrameBurstTriggerTransfer, //!< A check can be performed if the device is currently transferring a frame burst of one or many frames - Applies to: ace USB + AcquisitionStatusSelector_FrameBurstTriggerWait, //!< A check determines whether the camera is currently waiting for a frame burst trigger - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + AcquisitionStatusSelector_FrameTransfer, //!< A check determines whether the camera is currently transferring a frame - Applies to: CameraLink, GigE and ace USB + AcquisitionStatusSelector_FrameTriggerWait, //!< A check determines whether the camera is currently waiting for a frame trigger - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + AcquisitionStatusSelector_LineTriggerWait //!< A check determines whether the camera is currently waiting for a line trigger - Applies to: CameraLink and GigE + }; + + //! Valid values for AutoFunctionAOISelector + enum AutoFunctionAOISelectorEnums + { + AutoFunctionAOISelector_AOI1, //!< Auto function AOI 1 can be configured - Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI2, //!< Auto function AOI 2 can be configured - Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI3, //!< Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI4, //!< Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI5, //!< Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI6, //!< Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI7, //!< Applies to: CameraLink and GigE + AutoFunctionAOISelector_AOI8 //!< Applies to: CameraLink and GigE + }; + + //! Valid values for AutoFunctionProfile + enum AutoFunctionProfileEnums + { + AutoFunctionProfile_AntiFlicker50Hz, //!< Gain and exposure time are optimized to reduce flickering in an environment where the lighting flickers at a 50-Hz rate (e g , Europe) - Applies to: dart BCON, dart USB and pulse USB + AutoFunctionProfile_AntiFlicker60Hz, //!< Gain and exposure time are optimized to reduce flickering in an environment where the lighting flickers at a 60-Hz rate (e g , North America) - Applies to: dart BCON, dart USB and pulse USB + AutoFunctionProfile_ExposureMinimum, //!< Exposure time is kept as low as possible - Applies to: CameraLink and GigE + AutoFunctionProfile_ExposureMinimumQuick, //!< Exposure time is kept as low as possible and is adjusted quickly - Applies to: GigE + AutoFunctionProfile_GainMinimum, //!< Gain is kept as low as possible - Applies to: CameraLink and GigE + AutoFunctionProfile_GainMinimumQuick, //!< Gain time is kept as low as possible and is adjusted quickly - Applies to: GigE + AutoFunctionProfile_MinimizeExposureTime, //!< Exposure time is kept as low as possible - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + AutoFunctionProfile_MinimizeExposureTimeQuick, //!< Exposure time is kept as low as possible and is adjusted quickly - Applies to: ace USB + AutoFunctionProfile_MinimizeGain, //!< Gain is kept as low as possible - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + AutoFunctionProfile_MinimizeGainQuick, //!< Gain is kept as low as possible and is adjusted quickly - Applies to: ace USB + AutoFunctionProfile_Smart //!< Gain is kept as low as possible and the frame rate is kept as high as possible during automatic adjustments - Applies to: dart BCON, dart USB and pulse USB + }; + + //! Valid values for AutoFunctionROISelector + enum AutoFunctionROISelectorEnums + { + AutoFunctionROISelector_ROI1, //!< Auto function ROI 1 can be configured - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + AutoFunctionROISelector_ROI2 //!< Auto function ROI 2 can be configured - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for AutoTonalRangeAdjustmentSelector + enum AutoTonalRangeAdjustmentSelectorEnums + { + AutoTonalRangeAdjustmentSelector_Bright, //!< Only the bright end of the tonal range can be adjusted - Applies to: GigE and ace USB + AutoTonalRangeAdjustmentSelector_Dark, //!< Only the dark end of the tonal range can be adjusted - Applies to: GigE and ace USB + AutoTonalRangeAdjustmentSelector_DarkAndBright //!< The dark and bright end of the tonal range can be adjusted - Applies to: GigE and ace USB + }; + + //! Valid values for AutoTonalRangeModeSelector + enum AutoTonalRangeModeSelectorEnums + { + AutoTonalRangeModeSelector_Color, //!< Only color is adjusted - Applies to: GigE and ace USB + AutoTonalRangeModeSelector_ColorAndContrast, //!< Color and contrast are adjusted - Applies to: GigE and ace USB + AutoTonalRangeModeSelector_Contrast //!< Only contrast is adjusted - Applies to: GigE and ace USB + }; + + //! Valid values for BLCSerialPortBaudRate + enum BLCSerialPortBaudRateEnums + { + BLCSerialPortBaudRate_Baud115200 //!< The baud rate is 115200 Bd - Applies to: GigE and ace USB + }; + + //! Valid values for BLCSerialPortParity + enum BLCSerialPortParityEnums + { + BLCSerialPortParity_Even, //!< The serial communication module uses an even parity bit - Applies to: GigE and ace USB + BLCSerialPortParity_Odd, //!< The serial communication module uses an odd parity bit - Applies to: GigE and ace USB + BLCSerialPortParity_Off //!< The serial communication module does not use a parity bit - Applies to: GigE and ace USB + }; + + //! Valid values for BLCSerialPortSource + enum BLCSerialPortSourceEnums + { + BLCSerialPortSource_Line3, //!< The signal source for the serial communication module is set to line 3 - Applies to: GigE and ace USB + BLCSerialPortSource_Line4, //!< The signal source for the serial communication module is set to line 4 - Applies to: GigE and ace USB + BLCSerialPortSource_Off //!< The signal source for the serial communication module is disabled - Applies to: GigE and ace USB + }; + + //! Valid values for BLCSerialPortStopBits + enum BLCSerialPortStopBitsEnums + { + BLCSerialPortStopBits_StopBits0, //!< The serial communication module does not use a stop bit - Applies to: GigE and ace USB + BLCSerialPortStopBits_StopBits1 //!< The serial communication module does uses 1 stop bit - Applies to: GigE and ace USB + }; + + //! Valid values for BLCSerialReceiveQueueStatus + enum BLCSerialReceiveQueueStatusEnums + { + BLCSerialReceiveQueueStatus_Empty, //!< The receive queue is empty - Applies to: GigE and ace USB + BLCSerialReceiveQueueStatus_Filled, //!< The receive queue contains at least one value - Applies to: GigE and ace USB + BLCSerialReceiveQueueStatus_Full //!< The receive queue is full - Applies to: GigE and ace USB + }; + + //! Valid values for BLCSerialTransmitQueueStatus + enum BLCSerialTransmitQueueStatusEnums + { + BLCSerialTransmitQueueStatus_Empty, //!< The transmit queue is empty - Applies to: GigE and ace USB + BLCSerialTransmitQueueStatus_Filled, //!< The transmit queue contains at least one value - Applies to: GigE and ace USB + BLCSerialTransmitQueueStatus_Full //!< The transmit queue is full - Applies to: GigE and ace USB + }; + + //! Valid values for BalanceRatioSelector + enum BalanceRatioSelectorEnums + { + BalanceRatioSelector_Blue, //!< Balance ratio is applied to the blue channel - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BalanceRatioSelector_Green, //!< Balance ratio is applied to the green channel - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BalanceRatioSelector_Red //!< Balance ratio is applied to the red channel - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for BalanceWhiteAuto + enum BalanceWhiteAutoEnums + { + BalanceWhiteAuto_Continuous, //!< White balance is adjusted continuously while images are being acquired - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BalanceWhiteAuto_Off, //!< The Balance White Auto auto function is disabled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BalanceWhiteAuto_Once //!< White balance is adjusted automatically to reach the specified target value - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for BandwidthReserveMode + enum BandwidthReserveModeEnums + { + BandwidthReserveMode_Manual, //!< The bandwidth reserve can be configured manually - Applies to: ace 2 GigE + BandwidthReserveMode_Performance, //!< The bandwidth reserve is set to 5 % - Applies to: ace 2 GigE + BandwidthReserveMode_Standard //!< The bandwidth reserve is set to 10 % - Applies to: ace 2 GigE + }; + + //! Valid values for BconClockFrequency + enum BconClockFrequencyEnums + { + BconClockFrequency_MHz_12, //!< The BCON clock frequency is set to 12 MHz - Applies to: dart BCON + BconClockFrequency_MHz_20, //!< The BCON clock frequency is set to 20 MHz - Applies to: dart BCON + BconClockFrequency_MHz_28, //!< The BCON clock frequency is set to 28 MHz - Applies to: dart BCON + BconClockFrequency_MHz_36, //!< The BCON clock frequency is set to 36 MHz - Applies to: dart BCON + BconClockFrequency_MHz_44, //!< The BCON clock frequency is set to 44 MHz - Applies to: dart BCON + BconClockFrequency_MHz_52, //!< The BCON clock frequency is set to 52 MHz - Applies to: dart BCON + BconClockFrequency_MHz_60, //!< The BCON clock frequency is set to 60 MHz - Applies to: dart BCON + BconClockFrequency_MHz_68, //!< The BCON clock frequency is set to 68 MHz - Applies to: dart BCON + BconClockFrequency_MHz_76, //!< The BCON clock frequency is set to 76 MHz - Applies to: dart BCON + BconClockFrequency_MHz_84 //!< The BCON clock frequency is set to 84 MHz - Applies to: dart BCON + }; + + //! Valid values for BconPixelsPerClockCycle + enum BconPixelsPerClockCycleEnums + { + BconPixelsPerClockCycle_One, //!< During each clock cycle, data for one pixel is transmitted via the BCON interface - Applies to: dart BCON + BconPixelsPerClockCycle_Two //!< During each clock cycle, data for two pixels is transmitted via the BCON interface - Applies to: dart BCON + }; + + //! Valid values for BinningHorizontalMode + enum BinningHorizontalModeEnums + { + BinningHorizontalMode_Average, //!< The values of the binned pixels are averaged - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BinningHorizontalMode_Sum //!< The values of the binned pixels are summed - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for BinningModeHorizontal + enum BinningModeHorizontalEnums + { + BinningModeHorizontal_Averaging, //!< The values of the binned pixels are averaged - Applies to: CameraLink + BinningModeHorizontal_Summing //!< The values of the binned pixels are summed - Applies to: CameraLink + }; + + //! Valid values for BinningModeVertical + enum BinningModeVerticalEnums + { + BinningModeVertical_Averaging, //!< The values of the binned pixels are averaged - Applies to: CameraLink + BinningModeVertical_Summing //!< The values of the binned pixels are summed - Applies to: CameraLink + }; + + //! Valid values for BinningVerticalMode + enum BinningVerticalModeEnums + { + BinningVerticalMode_Average, //!< The values of the binned pixels are averaged - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BinningVerticalMode_Sum //!< The values of the binned pixels are summed - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for BlackLevelSelector + enum BlackLevelSelectorEnums + { + BlackLevelSelector_All, //!< The black level value is applied to all sensor taps - Applies to: CameraLink, GigE, ace USB, dart BCON, dart USB and pulse USB + BlackLevelSelector_AnalogAll, //!< Selects all analog black level controls for adjustment - Applies to: CameraLink and GigE + BlackLevelSelector_Blue, //!< Selects the blue black level control for adjustment - Applies to: CameraLink and GigE + BlackLevelSelector_DigitalAll, //!< Selects all digital black level controls for adjustment - Applies to: CameraLink and GigE + BlackLevelSelector_Green, //!< Selects the green black level control for adjustment - Applies to: CameraLink and GigE + BlackLevelSelector_Red, //!< Selects the red black level control for adjustment - Applies to: CameraLink and GigE + BlackLevelSelector_Tap1, //!< The black level value is applied to sensor tap 1 - Applies to: CameraLink and GigE + BlackLevelSelector_Tap2, //!< The black level value is applied to sensor tap 2 - Applies to: CameraLink and GigE + BlackLevelSelector_Tap3, //!< The black level value is applied to sensor tap 3 - Applies to: CameraLink and GigE + BlackLevelSelector_Tap4 //!< The black level value is applied to sensor tap 4 - Applies to: CameraLink and GigE + }; + + //! Valid values for BslAcquisitionBurstMode + enum BslAcquisitionBurstModeEnums + { + BslAcquisitionBurstMode_HighSpeed, //!< The High Speed burst mode is enabled - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslAcquisitionBurstMode_Standard //!< The Standard burst mode is enabled - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslAcquisitionStopMode + enum BslAcquisitionStopModeEnums + { + BslAcquisitionStopMode_AbortExposure, //!< Acquisition Stop commands abort exposure - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslAcquisitionStopMode_CompleteExposure //!< Acquisition Stop commands allow the exposure to be completed - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslChunkAutoBrightnessStatus + enum BslChunkAutoBrightnessStatusEnums + { + BslChunkAutoBrightnessStatus_Disabled, //!< Target brightness adjustments are disabled, i e , Gain Auto and Exposure Auto are set to Off - Applies to: ace 2 GigE and ace 2 USB + BslChunkAutoBrightnessStatus_TargetNotReached, //!< Target brightness adjustments are enabled, but the target brightness value has not been reached - Applies to: ace 2 GigE and ace 2 USB + BslChunkAutoBrightnessStatus_TargetReached //!< Target brightness adjustments are enabled, and the target brightness value has been reached - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for BslChunkTimestampSelector + enum BslChunkTimestampSelectorEnums + { + BslChunkTimestampSelector_ExposureEnd, //!< The Chunk Timestamp Value parameter indicates when exposure of the current image ended - Applies to: ace 2 GigE and ace 2 USB + BslChunkTimestampSelector_ExposureStart, //!< The Chunk Timestamp Value parameter indicates when exposure of the current image started - Applies to: ace 2 GigE and ace 2 USB + BslChunkTimestampSelector_FrameStart //!< The Chunk Timestamp Value parameter indicates when acquisition of the current image started - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for BslColorAdjustmentSelector + enum BslColorAdjustmentSelectorEnums + { + BslColorAdjustmentSelector_Blue, //!< Colors with a predominant blue component can be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslColorAdjustmentSelector_Cyan, //!< Colors with a predominant cyan component can be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslColorAdjustmentSelector_Green, //!< Colors with a predominant green component can be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslColorAdjustmentSelector_Magenta, //!< Colors with a predominant magenta component can be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslColorAdjustmentSelector_Red, //!< Colors with a predominant red component can be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslColorAdjustmentSelector_Yellow //!< Colors with a predominant yellow component can be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslColorSpace + enum BslColorSpaceEnums + { + BslColorSpace_Off, //!< No additional gamma correction value is applied - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslColorSpace_sRgb //!< The color space is set to sRGB - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslColorSpaceMode + enum BslColorSpaceModeEnums + { + BslColorSpaceMode_RGB, //!< The color space is set to RGB - Applies to: dart BCON, dart USB and pulse USB + BslColorSpaceMode_sRGB //!< The color space is set to sRGB - Applies to: dart BCON, dart USB and pulse USB + }; + + //! Valid values for BslContrastMode + enum BslContrastModeEnums + { + BslContrastMode_Linear, //!< The camera uses a linear function to adjust the contrast - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + BslContrastMode_SCurve //!< The camera uses an S-curve function to adjust the contrast - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for BslDefectPixelCorrectionMode + enum BslDefectPixelCorrectionModeEnums + { + BslDefectPixelCorrectionMode_Off, //!< Defect pixel correction is disabled - Applies to: dart 2 USB + BslDefectPixelCorrectionMode_On, //!< Defect pixel correction is enabled - Applies to: dart 2 USB + BslDefectPixelCorrectionMode_StaticOnly //!< Only static defect pixel correction is enabled - Applies to: dart 2 USB + }; + + //! Valid values for BslExposureTimeMode + enum BslExposureTimeModeEnums + { + BslExposureTimeMode_Standard, //!< The exposure time mode is set to Standard - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslExposureTimeMode_UltraShort //!< The exposure time mode is set to Ultra Short - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslImmediateTriggerMode + enum BslImmediateTriggerModeEnums + { + BslImmediateTriggerMode_Off, //!< The Immediate Trigger mode is disabled - Applies to: dart BCON, dart USB and pulse USB + BslImmediateTriggerMode_On //!< The Immediate Trigger mode is enabled - Applies to: dart BCON, dart USB and pulse USB + }; + + //! Valid values for BslLightControlErrorStatus + enum BslLightControlErrorStatusEnums + { + BslLightControlErrorStatus_Device1, //!< Light device 1 is experiencing problems - Applies to: GigE and ace USB + BslLightControlErrorStatus_Device2, //!< Light device 2 is experiencing problems - Applies to: GigE and ace USB + BslLightControlErrorStatus_Device3, //!< Light device 3 is experiencing problems - Applies to: GigE and ace USB + BslLightControlErrorStatus_Device4, //!< Light device 4 is experiencing problems - Applies to: GigE and ace USB + BslLightControlErrorStatus_MultipleDevices, //!< Multiple light devices are experiencing problems - Applies to: GigE and ace USB + BslLightControlErrorStatus_NoError //!< No error was detected - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightControlMode + enum BslLightControlModeEnums + { + BslLightControlMode_Off, //!< The light control features are disabled - Applies to: GigE and ace USB + BslLightControlMode_On //!< The light control features are enabled - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightControlSource + enum BslLightControlSourceEnums + { + BslLightControlSource_Line3, //!< Line 3 is used to control the light features - Applies to: GigE and ace USB + BslLightControlSource_Line4, //!< Line 4 is used to control the light features - Applies to: GigE and ace USB + BslLightControlSource_Off //!< No line is used to control the light features - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightControlStatus + enum BslLightControlStatusEnums + { + BslLightControlStatus_Idle, //!< No light device has been detected - Applies to: GigE and ace USB + BslLightControlStatus_Off, //!< The light control mode is disabled - Applies to: GigE and ace USB + BslLightControlStatus_Ready, //!< The light device is ready for use - Applies to: GigE and ace USB + BslLightControlStatus_Searching, //!< The controller ist searching for light devices connected to your camera - Applies to: GigE and ace USB + BslLightControlStatus_Updating //!< Parameters are being updated - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightDeviceChangeID + enum BslLightDeviceChangeIDEnums + { + BslLightDeviceChangeID_Device1, //!< The ID of the currently selected light device is changed to Device 1 - Applies to: GigE and ace USB + BslLightDeviceChangeID_Device2, //!< The ID of the currently selected light device is changed to Device 2 - Applies to: GigE and ace USB + BslLightDeviceChangeID_Device3, //!< The ID of the currently selected light device is changed to Device 3 - Applies to: GigE and ace USB + BslLightDeviceChangeID_Device4 //!< The ID of the currently selected light device is changed to Device 4 - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightDeviceLastError + enum BslLightDeviceLastErrorEnums + { + BslLightDeviceLastError_Communication, //!< The data transmission between the camera and the light device is disrupted - Applies to: GigE and ace USB + BslLightDeviceLastError_Connection, //!< The connection between the camera and the light device is broken - Applies to: GigE and ace USB + BslLightDeviceLastError_Hardware, //!< The light device is experiencing a technical fault - Applies to: GigE and ace USB + BslLightDeviceLastError_InsufficientCurrent, //!< The light controller is unable to supply the requested current - Applies to: GigE and ace USB + BslLightDeviceLastError_NoError, //!< No error was detected - Applies to: GigE and ace USB + BslLightDeviceLastError_ShortCircuit //!< There is a short circuit at the Lighting connector of the light controller - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightDeviceOperationMode + enum BslLightDeviceOperationModeEnums + { + BslLightDeviceOperationMode_Off, //!< The currently selected light device is switched off - Applies to: GigE and ace USB + BslLightDeviceOperationMode_On, //!< The currently selected light device is switched on - Applies to: GigE and ace USB + BslLightDeviceOperationMode_Strobe //!< The currently selected light device is set to strobe mode - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightDeviceSelector + enum BslLightDeviceSelectorEnums + { + BslLightDeviceSelector_Device1, //!< Light device 1 can be configured - Applies to: GigE and ace USB + BslLightDeviceSelector_Device2, //!< Light device 2 can be configured - Applies to: GigE and ace USB + BslLightDeviceSelector_Device3, //!< Light device 3 can be configured - Applies to: GigE and ace USB + BslLightDeviceSelector_Device4 //!< Light device 4 can be configured - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightDeviceStrobeMode + enum BslLightDeviceStrobeModeEnums + { + BslLightDeviceStrobeMode_Automatic, //!< The timing of the individual strobe pulses is determined by the Exposure Active signal - Applies to: GigE and ace USB + BslLightDeviceStrobeMode_Manual //!< The timing of the individual strobe pulses can be specified manually - Applies to: GigE and ace USB + }; + + //! Valid values for BslLightSourcePreset + enum BslLightSourcePresetEnums + { + BslLightSourcePreset_Daylight5000K, //!< The light source preset for image acquisitions with daylight of 5000 K is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslLightSourcePreset_Daylight6500K, //!< The light source preset for image acquisitions with daylight of 6500 K is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslLightSourcePreset_FactoryLED6000K, //!< The light source preset for image acquisitions with LED light is selected - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslLightSourcePreset_Off, //!< No light source preset is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslLightSourcePreset_Tungsten //!< The light source preset for image acquisitions with tungsten incandescent light is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslLightSourcePresetFeatureSelector + enum BslLightSourcePresetFeatureSelectorEnums + { + BslLightSourcePresetFeatureSelector_ColorAdjustment, //!< Adjustment of the Color Adjustment feature can be enabled or disabled - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslLightSourcePresetFeatureSelector_ColorTransformation, //!< Adjustment of the Color Transformation feature can be enabled or disabled - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslLightSourcePresetFeatureSelector_WhiteBalance //!< Adjustment of the Balance White feature can be enabled or disabled - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslMultipleROIColumnSelector + enum BslMultipleROIColumnSelectorEnums + { + BslMultipleROIColumnSelector_Column1, //!< Column 1 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column2, //!< Column 2 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column3, //!< Column 3 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column4, //!< Column 4 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column5, //!< Column 5 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column6, //!< Column 6 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column7, //!< Column 7 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIColumnSelector_Column8 //!< Column 8 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslMultipleROIRowSelector + enum BslMultipleROIRowSelectorEnums + { + BslMultipleROIRowSelector_Row1, //!< Row 1 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row2, //!< Row 2 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row3, //!< Row 3 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row4, //!< Row 4 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row5, //!< Row 5 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row6, //!< Row 6 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row7, //!< Row 7 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslMultipleROIRowSelector_Row8 //!< Row 8 can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslPeriodicSignalSelector + enum BslPeriodicSignalSelectorEnums + { + BslPeriodicSignalSelector_PeriodicSignal1 //!< Periodic Signal 1 can be configured - Applies to: ace 2 GigE + }; + + //! Valid values for BslPeriodicSignalSource + enum BslPeriodicSignalSourceEnums + { + BslPeriodicSignalSource_DeviceClock, //!< The camera is not synchronized via Precision Time Protocol (PTP) - Applies to: ace 2 GigE + BslPeriodicSignalSource_PtpClock //!< The camera is synchronized via Precision Time Protocol (PTP) - Applies to: ace 2 GigE + }; + + //! Valid values for BslPtpDelayMechanism + enum BslPtpDelayMechanismEnums + { + BslPtpDelayMechanism_E2E, //!< The port is configured to use the delay request-response mechanism - Applies to: ace 2 GigE + BslPtpDelayMechanism_P2P //!< The port is configured to use the peer delay mechanism - Applies to: ace 2 GigE + }; + + //! Valid values for BslPtpNetworkMode + enum BslPtpNetworkModeEnums + { + BslPtpNetworkMode_Hybrid, //!< Hybrid network communication is enabled - Applies to: ace 2 GigE + BslPtpNetworkMode_Multicast, //!< Multicast network communication is enabled - Applies to: ace 2 GigE + BslPtpNetworkMode_Unicast //!< Unicast network communication is enabled - Applies to: ace 2 GigE + }; + + //! Valid values for BslPtpProfile + enum BslPtpProfileEnums + { + BslPtpProfile_DelayRequestResponseDefaultProfile, //!< The default PTP profile is set to Delay Request-Response - Applies to: ace 2 GigE + BslPtpProfile_PeerToPeerDefaultProfile //!< The default PTP profile is set to Peer-to-Peer - Applies to: ace 2 GigE + }; + + //! Valid values for BslSensorBitDepth + enum BslSensorBitDepthEnums + { + BslSensorBitDepth_Bpp10, //!< The sensor bit depth is set to 10 bits per pixel - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslSensorBitDepth_Bpp12, //!< The sensor bit depth is set to 12 bits per pixel - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslSensorBitDepth_Bpp8 //!< The sensor bit depth is set to 8 bits per pixel - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslSensorBitDepthMode + enum BslSensorBitDepthModeEnums + { + BslSensorBitDepthMode_Auto, //!< The sensor bit depth mode is set to Auto - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + BslSensorBitDepthMode_Manual //!< The sensor bit depth mode is set to Manual - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for BslSerialBaudRate + enum BslSerialBaudRateEnums + { + BslSerialBaudRate_Baud115200, //!< A symbol rate of 115200 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud1200, //!< A symbol rate of 1200 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud19200, //!< A symbol rate of 19200 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud2400, //!< A symbol rate of 2400 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud38400, //!< A symbol rate of 38400 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud4800, //!< A symbol rate of 4800 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud57600, //!< A symbol rate of 57600 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialBaudRate_Baud9600 //!< A symbol rate of 9600 baud is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslSerialNumberOfDataBits + enum BslSerialNumberOfDataBitsEnums + { + BslSerialNumberOfDataBits_Bits7, //!< Seven data bits per frame are used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialNumberOfDataBits_Bits8 //!< Eight data bits per frame are used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslSerialNumberOfStopBits + enum BslSerialNumberOfStopBitsEnums + { + BslSerialNumberOfStopBits_Bits1, //!< One stop bit is used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialNumberOfStopBits_Bits2 //!< Two stop bits are used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslSerialParity + enum BslSerialParityEnums + { + BslSerialParity_Even, //!< An even parity check is performed - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialParity_None, //!< No parity check is performed - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialParity_Odd //!< An odd parity check is performed - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslSerialRxSource + enum BslSerialRxSourceEnums + { + BslSerialRxSource_Line1, //!< The source of the Rx serial input is set to Line 1 - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialRxSource_Line2, //!< The source of the Rx serial input is set to Line 2 - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialRxSource_Line3, //!< The source of the Rx serial input is set to Line 3 - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialRxSource_Off, //!< Rx input is muted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + BslSerialRxSource_SerialTx //!< The source of the Rx serial input is set to Serial Tx - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for BslTemperatureStatus + enum BslTemperatureStatusEnums + { + BslTemperatureStatus_Critical, //!< The temperature is close to or at the allowed maximum Provide cooling - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + BslTemperatureStatus_Error, //!< The temperature is above the allowed maximum Provide cooling immediately - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + BslTemperatureStatus_Ok //!< The temperature is within the normal operating temperature range - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + }; + + //! Valid values for BslUSBSpeedMode + enum BslUSBSpeedModeEnums + { + BslUSBSpeedMode_FullSpeed, //!< The USB port is operating at Full Speed - Applies to: ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + BslUSBSpeedMode_HighSpeed, //!< The USB port is operating at High Speed - Applies to: ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + BslUSBSpeedMode_LowSpeed, //!< The USB port is operating at Low Speed - Applies to: ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + BslUSBSpeedMode_SuperSpeed //!< The USB port is operating at SuperSpeed - Applies to: ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + }; + + //! Valid values for BslVignettingCorrectionMode + enum BslVignettingCorrectionModeEnums + { + BslVignettingCorrectionMode_Off, //!< The vignetting correction is disabled - Applies to: boost CoaXPress + BslVignettingCorrectionMode_On //!< The vignetting correction is enabled - Applies to: boost CoaXPress + }; + + //! Valid values for CameraOperationMode + enum CameraOperationModeEnums + { + CameraOperationMode_LongExposure, //!< The camera operation mode is set to Long Exposure - Applies to: ace USB + CameraOperationMode_Standard //!< The camera operation mode is set to Standard - Applies to: ace USB + }; + + //! Valid values for ChunkCounterSelector + enum ChunkCounterSelectorEnums + { + ChunkCounterSelector_Counter1, //!< Chunk data can be retrieved from counter 1 - Applies to: ace 2 GigE, ace 2 USB and ace USB + ChunkCounterSelector_Counter2 //!< Chunk data can be retrieved from counter 2 - Applies to: ace 2 GigE, ace 2 USB and ace USB + }; + + //! Valid values for ChunkGainSelector + enum ChunkGainSelectorEnums + { + ChunkGainSelector_All //!< Chunk data can be retrieved from all gain channels - Applies to: ace USB + }; + + //! Valid values for ChunkPixelFormat + enum ChunkPixelFormatEnums + { + ChunkPixelFormat_BGR10Packed, //!< The pixel data in the acquired image is in the BGR 10 Packed format - Applies to: GigE + ChunkPixelFormat_BGR12Packed, //!< The pixel data in the acquired image is in the BGR 12 Packed format - Applies to: GigE + ChunkPixelFormat_BGR8Packed, //!< The pixel data in the acquired image is in the BGR 8 Packed format - Applies to: GigE + ChunkPixelFormat_BGRA8Packed, //!< The pixel data in the acquired image is in the BGRA 8 Packed format - Applies to: GigE + ChunkPixelFormat_BayerBG10, //!< The pixel data in the acquired image is in the Bayer BG 10 format - Applies to: GigE + ChunkPixelFormat_BayerBG10p, //!< The pixel data in the acquired image is in the Bayer BG 10p format - Applies to: GigE + ChunkPixelFormat_BayerBG12, //!< The pixel data in the acquired image is in the Bayer BG 12 format - Applies to: GigE + ChunkPixelFormat_BayerBG12Packed, //!< The pixel data in the acquired image is in the Bayer BG 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerBG16, //!< The pixel data in the acquired image is in the Bayer BG 16 format - Applies to: GigE + ChunkPixelFormat_BayerBG8, //!< The pixel data in the acquired image is in the Bayer BG 8 format - Applies to: GigE + ChunkPixelFormat_BayerGB10, //!< The pixel data in the acquired image is in the Bayer GB 10 format - Applies to: GigE + ChunkPixelFormat_BayerGB10p, //!< The pixel data in the acquired image is in the Bayer GB 10p format - Applies to: GigE + ChunkPixelFormat_BayerGB12, //!< The pixel data in the acquired image is in the Bayer GB 12 format - Applies to: GigE + ChunkPixelFormat_BayerGB12Packed, //!< The pixel data in the acquired image is in the Bayer GB 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerGB16, //!< The pixel data in the acquired image is in the Bayer GB 16 format - Applies to: GigE + ChunkPixelFormat_BayerGB8, //!< The pixel data in the acquired image is in the Bayer GB 8 format - Applies to: GigE + ChunkPixelFormat_BayerGR10, //!< The pixel data in the acquired image is in the Bayer GR 10 format - Applies to: GigE + ChunkPixelFormat_BayerGR10p, //!< The pixel data in the acquired image is in the Bayer GR 10p format - Applies to: GigE + ChunkPixelFormat_BayerGR12, //!< The pixel data in the acquired image is in the Bayer GR 12 format - Applies to: GigE + ChunkPixelFormat_BayerGR12Packed, //!< The pixel data in the acquired image is in the Bayer GR 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerGR16, //!< The pixel data in the acquired image is in the Bayer GR 16 format - Applies to: GigE + ChunkPixelFormat_BayerGR8, //!< The pixel data in the acquired image is in the Bayer GR 8 format - Applies to: GigE + ChunkPixelFormat_BayerRG10, //!< The pixel data in the acquired image is in the Bayer RG 10 format - Applies to: GigE + ChunkPixelFormat_BayerRG10p, //!< The pixel data in the acquired image is in the Bayer RG 10p format - Applies to: GigE + ChunkPixelFormat_BayerRG12, //!< The pixel data in the acquired image is in the Bayer RG 12 format - Applies to: GigE + ChunkPixelFormat_BayerRG12Packed, //!< The pixel data in the acquired image is in the Bayer RG 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerRG16, //!< The pixel data in the acquired image is in the Bayer RG 16 format - Applies to: GigE + ChunkPixelFormat_BayerRG8, //!< The pixel data in the acquired image is in the Bayer RG 8 format - Applies to: GigE + ChunkPixelFormat_Mono10, //!< The pixel data in the acquired image is in the Mono 10 format - Applies to: GigE + ChunkPixelFormat_Mono10Packed, //!< The pixel data in the acquired image is in the Mono 10 Packed format - Applies to: GigE + ChunkPixelFormat_Mono10p, //!< The pixel data in the acquired image is in the Mono 10p format - Applies to: GigE + ChunkPixelFormat_Mono12, //!< The pixel data in the acquired image is in the Mono 12 format - Applies to: GigE + ChunkPixelFormat_Mono12Packed, //!< The pixel data in the acquired image is in the Mono 12 Packed format - Applies to: GigE + ChunkPixelFormat_Mono16, //!< The pixel data in the acquired image is in the Mono 16 format - Applies to: GigE + ChunkPixelFormat_Mono8, //!< The pixel data in the acquired image is in the Mono 8 format - Applies to: GigE + ChunkPixelFormat_Mono8Signed, //!< The pixel data in the acquired image is in the Mono 8 Signed format - Applies to: GigE + ChunkPixelFormat_RGB10Packed, //!< The pixel data in the acquired image is in the RGB 10 Packed format - Applies to: GigE + ChunkPixelFormat_RGB10Planar, //!< The pixel data in the acquired image is in the RGB 10 Planar format - Applies to: GigE + ChunkPixelFormat_RGB10V1Packed, //!< The pixel data in the acquired image is in the RGB 10V1 Packed format - Applies to: GigE + ChunkPixelFormat_RGB10V2Packed, //!< The pixel data in the acquired image is in the RGB 10V2 Packed format - Applies to: GigE + ChunkPixelFormat_RGB12Packed, //!< The pixel data in the acquired image is in the RGB 12 Packed format - Applies to: GigE + ChunkPixelFormat_RGB12Planar, //!< The pixel data in the acquired image is in the RGB 12 Planar format - Applies to: GigE + ChunkPixelFormat_RGB12V1Packed, //!< The pixel data in the acquired image is in RGB 12 V1 Packed format - Applies to: GigE + ChunkPixelFormat_RGB16Planar, //!< The pixel data in the acquired image is in the RGB 16 Planar format - Applies to: GigE + ChunkPixelFormat_RGB8Packed, //!< The pixel data in the acquired image is in the RGB 8 Packed format - Applies to: GigE + ChunkPixelFormat_RGB8Planar, //!< The pixel data in the acquired image is in the RGB 8 Planar format - Applies to: GigE + ChunkPixelFormat_RGBA8Packed, //!< The pixel data in the acquired image is in the RGBA 8 Packed format - Applies to: GigE + ChunkPixelFormat_YUV411Packed, //!< The pixel data in the acquired image is in the YUV 411 Packed format - Applies to: GigE + ChunkPixelFormat_YUV422Packed, //!< The pixel data in the acquired image is in the YUV 422 Packed format - Applies to: GigE + ChunkPixelFormat_YUV422_YUYV_Packed, //!< The pixel data in the acquired image is in the YUV 422 (YUYV) Packed format - Applies to: GigE + ChunkPixelFormat_YUV444Packed //!< The pixel data in the acquired image is in the YUV 444 Packed format - Applies to: GigE + }; + + //! Valid values for ChunkSelector + enum ChunkSelectorEnums + { + ChunkSelector_AutoBrightnessStatus, //!< The Auto Brightness Status chunk can be enabled - Applies to: ace 2 GigE and ace 2 USB + ChunkSelector_BrightPixel, //!< Applies to: GigE + ChunkSelector_CounterValue, //!< The Counter Value chunk can be enabled - Applies to: ace 2 GigE, ace 2 USB and ace USB + ChunkSelector_DynamicRangeMax, //!< The Dynamic Range Max chunk can be enabled - Applies to: GigE + ChunkSelector_DynamicRangeMin, //!< The Dynamic Range Min chunk can be enabled - Applies to: GigE + ChunkSelector_ExposureTime, //!< The Exposure Time chunk can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + ChunkSelector_FrameID, //!< The Frame ID chunk can be enabled - Applies to: ace 2 GigE and ace 2 USB + ChunkSelector_FrameTriggerCounter, //!< The Frame Trigger Counter chunk can be enabled - Applies to: GigE + ChunkSelector_FrameTriggerIgnoredCounter, //!< The Frame Trigger Ignored Counter chunk can be enabled - Applies to: GigE + ChunkSelector_Framecounter, //!< The Frame Counter chunk can be enabled - Applies to: GigE + ChunkSelector_FramesPerTriggerCounter, //!< The Frames Per Trigger Counter chunk can be enabled - Applies to: GigE + ChunkSelector_Gain, //!< The Gain chunk can be enabled - Applies to: ace 2 GigE, ace 2 USB and ace USB + ChunkSelector_GainAll, //!< The Gain All chunk can be enabled - Applies to: GigE + ChunkSelector_Height, //!< The Height chunk can be enabled - Applies to: GigE + ChunkSelector_Image, //!< The Image chunk can be enabled - Applies to: GigE and ace USB + ChunkSelector_InputStatusAtLineTrigger, //!< The Input Status At Line Trigger chunk can be enabled - Applies to: GigE + ChunkSelector_LineStatusAll, //!< The Line Status All chunk can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + ChunkSelector_LineTriggerCounter, //!< The Line Trigger Counter chunk can be enabled - Applies to: GigE + ChunkSelector_LineTriggerEndToEndCounter, //!< The Line Trigger End To End Counter chunk can be enabled - Applies to: GigE + ChunkSelector_LineTriggerIgnoredCounter, //!< The Line Trigger Ignored Counter chunk can be enabled - Applies to: GigE + ChunkSelector_OffsetX, //!< The X Offset chunk can be enabled - Applies to: GigE + ChunkSelector_OffsetY, //!< The Y Offset chunk can be enabled - Applies to: GigE + ChunkSelector_PayloadCRC16, //!< The CRC Checksum chunk can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + ChunkSelector_PixelFormat, //!< The Pixel Format chunk can be enabled - Applies to: GigE + ChunkSelector_SequenceSetIndex, //!< The Sequence Set Index chunk can be enabled - Applies to: GigE + ChunkSelector_SequencerSetActive, //!< The Sequencer Set Active chunk can be enabled - Applies to: ace USB + ChunkSelector_ShaftEncoderCounter, //!< The Shaft Encoder Counter chunk can be enabled - Applies to: GigE + ChunkSelector_Stride, //!< The Stride chunk can be enabled - Applies to: GigE + ChunkSelector_Timestamp, //!< The Timestamp chunk can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + ChunkSelector_Triggerinputcounter, //!< The Trigger Input Counter chunk can be enabled - Applies to: GigE + ChunkSelector_VirtLineStatusAll, //!< Selects the virtual line status all chunk for enabling - Applies to: GigE + ChunkSelector_Width //!< The Width chunk can be enabled - Applies to: GigE + }; + + //! Valid values for ClConfiguration + enum ClConfigurationEnums + { + ClConfiguration_Base, //!< The Base configuration is selected - Applies to: CameraLink + ClConfiguration_Deca, //!< The Deca configuration is selected - Applies to: CameraLink + ClConfiguration_DualBase, //!< The DualBase configuration is selected - Applies to: CameraLink + ClConfiguration_Full, //!< The Full configuration is selected - Applies to: CameraLink + ClConfiguration_Medium //!< The Medium configuration is selected - Applies to: CameraLink + }; + + //! Valid values for ClPixelClock + enum ClPixelClockEnums + { + ClPixelClock_PixelClock20, //!< The pixel clock speed is set to 20 MHz - Applies to: CameraLink + ClPixelClock_PixelClock32_5, //!< The pixel clock speed is set to 32 5 MHz - Applies to: CameraLink + ClPixelClock_PixelClock40, //!< The pixel clock speed is set to 40 MHz - Applies to: CameraLink + ClPixelClock_PixelClock48, //!< The pixel clock speed is set to 48 MHz - Applies to: CameraLink + ClPixelClock_PixelClock65, //!< The pixel clock speed is set to 65 MHz - Applies to: CameraLink + ClPixelClock_PixelClock82, //!< The pixel clock speed is set to 82 MHz - Applies to: CameraLink + ClPixelClock_PixelClock82_5, //!< The pixel clock speed is set to 82 5 MHz - Applies to: CameraLink + ClPixelClock_PixelClock83, //!< The pixel clock speed is set to 83 MHz - Applies to: CameraLink + ClPixelClock_PixelClock83_5 //!< The pixel clock speed is set to 83 5 MHz - Applies to: CameraLink + }; + + //! Valid values for ClSerialPortBaudRate + enum ClSerialPortBaudRateEnums + { + ClSerialPortBaudRate_Baud115200, //!< The baud rate is set to 115200 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud19200, //!< The baud rate is set to 19200 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud230400, //!< The baud rate is set to 230400 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud38400, //!< The baud rate is set to 38400 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud460800, //!< The baud rate is set to 460800 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud57600, //!< The baud rate is set to 57600 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud921600, //!< The baud rate is set to 921600 baud - Applies to: CameraLink + ClSerialPortBaudRate_Baud9600 //!< The baud rate is set to 9600 baud - Applies to: CameraLink + }; + + //! Valid values for ClTapGeometry + enum ClTapGeometryEnums + { + ClTapGeometry_Geometry1X, //!< The tap geometry is set to 1 zone in horizontal direction with one tap - Applies to: CameraLink + ClTapGeometry_Geometry1X10, //!< The tap geometry is set to 1 zone in horizontal direction with ten taps - Applies to: CameraLink + ClTapGeometry_Geometry1X10_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with ten taps and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X2, //!< The tap geometry is set to 1 zone in horizontal direction with two taps - Applies to: CameraLink + ClTapGeometry_Geometry1X2_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with two taps and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X3, //!< The tap geometry is set to 1 zone in horizontal direction with three taps - Applies to: CameraLink + ClTapGeometry_Geometry1X3_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with three taps and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X4, //!< The tap geometry is set to 1 zone in horizontal direction with four taps - Applies to: CameraLink + ClTapGeometry_Geometry1X4_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with four taps and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X6, //!< The tap geometry is set to 1 zone in horizontal direction with six taps - Applies to: CameraLink + ClTapGeometry_Geometry1X6_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with six taps and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X8, //!< The tap geometry is set to 1 zone in horizontal direction with eight taps - Applies to: CameraLink + ClTapGeometry_Geometry1X8_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with eight taps and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X_1Y, //!< The tap geometry is set to 1 zone in horizontal direction with one tap and 1 zone in vertical direction with 1 tap - Applies to: CameraLink + ClTapGeometry_Geometry1X_2YE //!< The tap geometry is set to 1 zone in horizontal direction with one tap and 2 zones in vertical direction with 1 tap with end extraction - Applies to: CameraLink + }; + + //! Valid values for ClTimeSlots + enum ClTimeSlotsEnums + { + ClTimeSlots_TimeSlots1 //!< The time slot is set to one time slot - Applies to: CameraLink + }; + + //! Valid values for ColorAdjustmentSelector + enum ColorAdjustmentSelectorEnums + { + ColorAdjustmentSelector_Blue, //!< Colors with a predominant blue component can be adjusted - Applies to: CameraLink, GigE and ace USB + ColorAdjustmentSelector_Cyan, //!< Colors with a predominant cyan component can be adjusted - Applies to: CameraLink, GigE and ace USB + ColorAdjustmentSelector_Green, //!< Colors with a predominant green component can be adjusted - Applies to: CameraLink, GigE and ace USB + ColorAdjustmentSelector_Magenta, //!< Colors with a predominant magenta component can be adjusted - Applies to: CameraLink, GigE and ace USB + ColorAdjustmentSelector_Red, //!< Colors with a predominant red component can be adjusted - Applies to: CameraLink, GigE and ace USB + ColorAdjustmentSelector_Yellow //!< Colors with a predominant yellow component can be adjusted - Applies to: CameraLink, GigE and ace USB + }; + + //! Valid values for ColorOverexposureCompensationAOISelector + enum ColorOverexposureCompensationAOISelectorEnums + { + ColorOverexposureCompensationAOISelector_AOI1 //!< Selects Color Overexposure Compensation AOI 1 - Applies to: CameraLink and GigE + }; + + //! Valid values for ColorSpace + enum ColorSpaceEnums + { + ColorSpace_RGB, //!< The color space is set to RGB - Applies to: ace USB + ColorSpace_sRGB //!< The color space is set to sRGB - Applies to: ace USB + }; + + //! Valid values for ColorTransformationSelector + enum ColorTransformationSelectorEnums + { + ColorTransformationSelector_RGBtoRGB, //!< Color transformation from RGB to RGB will be performed - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationSelector_RGBtoYUV, //!< Color transformation from RGB to YUV will be performed - Applies to: CameraLink, GigE and ace USB + ColorTransformationSelector_YUVtoRGB //!< Color transformation from YUV to RGB will be performed - Applies to: CameraLink, GigE and ace USB + }; + + //! Valid values for ColorTransformationValueSelector + enum ColorTransformationValueSelectorEnums + { + ColorTransformationValueSelector_Gain00, //!< The desired color transformation value can be entered at the position row 0 and column 0 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain01, //!< The desired color transformation value can be entered at the position row 0 and column 1 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain02, //!< The desired color transformation value can be entered at the position row 0 and column 2 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain10, //!< The desired color transformation value can be entered at the position row 1 and column 0 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain11, //!< The desired color transformation value can be entered at the position row 1 and column 1 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain12, //!< The desired color transformation value can be entered at the position row 1 and column 2 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain20, //!< The desired color transformation value can be entered at the position row 2 and column 0 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain21, //!< The desired color transformation value can be entered at the position row 2 and column 1 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Gain22, //!< The desired color transformation value can be entered at the position row 2 and column 2 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + ColorTransformationValueSelector_Offset0, //!< The desired color transformation value can be entered in row 0 of the offset matrix - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + ColorTransformationValueSelector_Offset1, //!< The desired color transformation value can be entered in row 1 of the offset matrix - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + ColorTransformationValueSelector_Offset2 //!< The desired color transformation value can be entered in row 2 of the offset matrix - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + }; + + //! Valid values for ComponentSelector + enum ComponentSelectorEnums + { + ComponentSelector_Confidence, //!< The acquisition of confidence map of the acquired image is controlled - Applies to: blaze + ComponentSelector_Intensity, //!< The acquisition of intensity (monochrome or color) of the visible reflected light is controlled - Applies to: blaze + ComponentSelector_Range //!< The acquisition of range (distance) data is controlled - Applies to: blaze + }; + + //! Valid values for CounterEventActivation + enum CounterEventActivationEnums + { + CounterEventActivation_AnyEdge, //!< Trigger on the rising or falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventActivation_FallingEdge, //!< Trigger on the falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventActivation_LevelHigh, //!< Trigger is active as long as the selected source signal is on a logic high level - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventActivation_LevelLow, //!< Trigger is active as long as the selected source signal is on a logic low level - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventActivation_RisingEdge //!< Trigger on the rising edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for CounterEventSource + enum CounterEventSourceEnums + { + CounterEventSource_AcquisitionActive, //!< The selected counter counts the number of Acquisition Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_AcquisitionEnd, //!< Counts the number of Acquisition End - Applies to: CameraLink and GigE + CounterEventSource_AcquisitionStart, //!< Counts the number of Acquisition Start - Applies to: CameraLink and GigE + CounterEventSource_AcquisitionTrigger, //!< Counts the number of Acquisition Trigger - Applies to: CameraLink and GigE + CounterEventSource_Action1, //!< The selected counter counts the number of action commands received for action signal 1 - Applies to: ace 2 GigE + CounterEventSource_Action2, //!< The selected counter counts the number of action commands received for action signal 2 - Applies to: ace 2 GigE + CounterEventSource_Counter1Active, //!< The selected counter counts the number of Counter 1 Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Counter1End, //!< The selected counter counts the number of Counter 1 End signals - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterEventSource_Counter1Start, //!< The selected counter counts the number of Counter 1 Start signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Counter2Active, //!< The selected counter counts the number of Counter 2 Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Counter2End, //!< The selected counter counts the number of Counter 2 End signals - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterEventSource_Counter2Start, //!< The selected counter counts the number of Counter 2 Start signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Counter3End, //!< The selected counter counts the number of counter 3 end events - Applies to: ace USB + CounterEventSource_CxpTrigger0, //!< The selected counter counts the number of CXP Trigger 0 signals - Applies to: boost CoaXPress + CounterEventSource_CxpTrigger1, //!< The selected counter counts the number of CXP Trigger 1 signals - Applies to: boost CoaXPress + CounterEventSource_ExposureActive, //!< The selected counter counts the number of Exposure Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_ExposureEnd, //!< Counts the number of Exposure End - Applies to: CameraLink and GigE + CounterEventSource_ExposureStart, //!< Counts the number of Exposure Start - Applies to: CameraLink and GigE + CounterEventSource_ExposureTriggerWait, //!< The selected counter counts the number of Exposure Trigger Wait signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_FrameBurstActive, //!< The selected counter counts the number of Frame Burst Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_FrameBurstTriggerWait, //!< The selected counter counts the number of Frame Burst Trigger Wait signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_FrameEnd, //!< Counts the number of Frame End - Applies to: CameraLink and GigE + CounterEventSource_FrameStart, //!< The selected counter counts the number of Frame Start events - Applies to: CameraLink, GigE and ace USB + CounterEventSource_FrameTrigger, //!< The selected counter counts the number of Frame Trigger events - Applies to: CameraLink, GigE and ace USB + CounterEventSource_FrameTriggerWait, //!< The selected counter counts the number of Frame Trigger Wait signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Line1, //!< The selected counter counts the number of Line 1 signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Line2, //!< The selected counter counts the number of Line 2 signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Line3, //!< The selected counter counts the number of Line 3 signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Line4, //!< The selected counter counts the number of Line 4 signals - Applies to: dart 2 USB + CounterEventSource_LineEnd, //!< Counts the number of Line End - Applies to: CameraLink and GigE + CounterEventSource_LineStart, //!< Counts the number of Line Start - Applies to: CameraLink and GigE + CounterEventSource_LineTrigger, //!< The selected counter counts the number of Line Trigger events - Applies to: CameraLink and GigE + CounterEventSource_Off, //!< The selected counter is disabled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_PeriodicSignal1, //!< The selected counter counts the number of Periodic Signal 1 signals - Applies to: ace 2 GigE + CounterEventSource_SoftwareSignal1, //!< The selected counter counts the number of Software Signal 1 signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_SoftwareSignal2, //!< The selected counter counts the number of Software Signal 2 signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_SoftwareSignal3, //!< The selected counter counts the number of Software Signal 3 signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Timer1Active, //!< The selected counter counts the number of Timer 1 Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Timer1End, //!< The selected counter counts the number of Timer 1 End signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Timer2Active, //!< The selected counter counts the number of Timer 2 Active signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterEventSource_Timer2End //!< The selected counter counts the number of Timer 2 End signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for CounterResetActivation + enum CounterResetActivationEnums + { + CounterResetActivation_AnyEdge, //!< Trigger on the rising or falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetActivation_FallingEdge, //!< Trigger on the falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetActivation_LevelHigh, //!< Trigger is active as long as the selected source signal is on a logic high level - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetActivation_LevelLow, //!< Trigger is active as long as the selected source signal is on a logic low level - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetActivation_RisingEdge //!< The counter is reset on the rising edge of the signal - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for CounterResetSource + enum CounterResetSourceEnums + { + CounterResetSource_AcquisitionActive, //!< The selected counter can be reset by an Acquisition Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Action1, //!< The selected counter can be reset by an action command that is defined by action signal 1 - Applies to: ace 2 GigE + CounterResetSource_Action2, //!< The selected counter can be reset by an action command that is defined by action signal 2 - Applies to: ace 2 GigE + CounterResetSource_CC1, //!< The selected counter can be reset by a CC1 signal - Applies to: CameraLink and GigE + CounterResetSource_CC2, //!< The selected counter can be reset by a CC2 signal - Applies to: CameraLink and GigE + CounterResetSource_CC3, //!< The selected counter can be reset by a CC3 signal - Applies to: CameraLink and GigE + CounterResetSource_CC4, //!< The selected counter can be reset by a CC4 signal - Applies to: CameraLink and GigE + CounterResetSource_Counter1Active, //!< The selected counter can be reset by a Counter 1 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Counter1End, //!< The selected counter can be reset by a Counter End 1 signal - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetSource_Counter1Start, //!< The selected counter can be reset by a Counter 1 Start signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Counter2Active, //!< The selected counter can be reset by a Counter 2 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Counter2End, //!< The selected counter can be reset by a Counter 1 Start event - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetSource_Counter2Start, //!< The selected counter can be reset by a Counter 2 Start signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Counter3End, //!< The selected counter can be reset by a counter end 3 signal - Applies to: ace USB + CounterResetSource_Counter4End, //!< The selected counter can be reset by a counter end 4 signal - Applies to: ace USB + CounterResetSource_CxpTrigger0, //!< The selected counter can be reset by a CXP Trigger 0 signal - Applies to: boost CoaXPress + CounterResetSource_CxpTrigger1, //!< The selected counter can be reset by a CXP Trigger 1 signal - Applies to: boost CoaXPress + CounterResetSource_ExposureActive, //!< The selected counter can be reset by an Exposure Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_ExposureTriggerWait, //!< The selected counter can be reset by an Exposure Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_FrameBurstActive, //!< The selected counter can be reset by a Frame Burst Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_FrameBurstTriggerWait, //!< The selected counter can be reset by a Frame Burst Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_FrameTriggerWait, //!< The selected counter can be reset by a Frame Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Line1, //!< The selected counter can be reset by a signal applied to Line 1 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetSource_Line2, //!< The selected counter can be reset by a signal applied to Line 2 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetSource_Line3, //!< The selected counter can be reset by a signal applied to Line 3 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetSource_Line4, //!< The selected counter can be reset by a signal applied to Line 4 - Applies to: CameraLink, GigE, ace USB and dart 2 USB + CounterResetSource_Line5, //!< The selected counter can be reset by a signal applied to Line 5 - Applies to: CameraLink and GigE + CounterResetSource_Line6, //!< The selected counter can be reset by a signal applied to Line 6 - Applies to: CameraLink and GigE + CounterResetSource_Line7, //!< The selected counter can be reset by a signal applied to Line 7 - Applies to: CameraLink and GigE + CounterResetSource_Line8, //!< The selected counter can be reset by a signal applied to Line 8 - Applies to: CameraLink and GigE + CounterResetSource_Off, //!< The counter reset is disabled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterResetSource_PeriodicSignal1, //!< The selected counter can be reset by a Periodic Signal 1 signal - Applies to: ace 2 GigE + CounterResetSource_Software, //!< The selected counter can be reset by a software command - Applies to: CameraLink, GigE and ace USB + CounterResetSource_SoftwareSignal1, //!< The selected counter can be reset by a Software Signal 1 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_SoftwareSignal2, //!< The selected counter can be reset by a Software Signal 2 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_SoftwareSignal3, //!< The selected counter can be reset by a Software Signal 3 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Timer1Active, //!< The selected counter can be reset by a Timer 1 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Timer1End, //!< The selected counter can be reset by a Timer 1 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Timer2Active, //!< The selected counter can be reset by a Timer 2 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_Timer2End, //!< The selected counter can be reset by a Timer 2 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterResetSource_VInput1, //!< Selects Virtual Input 1 as the source for counter reset - Applies to: CameraLink and GigE + CounterResetSource_VInput2, //!< Selects Virtual Input 2 as the source for counter reset - Applies to: CameraLink and GigE + CounterResetSource_VInput3, //!< Selects Virtual Input 3 as the source for counter reset - Applies to: CameraLink and GigE + CounterResetSource_VInput4, //!< Selects Virtual Input 4 as the source for counter reset - Applies to: CameraLink and GigE + CounterResetSource_VInputDecActive //!< Selects Virtual Input Decoder Active as the source for counter reset - Applies to: CameraLink and GigE + }; + + //! Valid values for CounterSelector + enum CounterSelectorEnums + { + CounterSelector_Counter1, //!< Counter 1 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterSelector_Counter2, //!< Counter 2 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + CounterSelector_Counter3, //!< Counter 3 can be configured - Applies to: CameraLink and GigE + CounterSelector_Counter4 //!< Selects counter 4 for configuration - Applies to: CameraLink and GigE + }; + + //! Valid values for CounterStatus + enum CounterStatusEnums + { + CounterStatus_CounterActive, //!< The counter is waiting to be increased by the selected event source or is currently counting - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterStatus_CounterCompleted, //!< The counter has reached its maximum value defined by the Counter Duration parameter - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterStatus_CounterTriggerWait //!< The counter is waiting to be started - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for CounterTriggerActivation + enum CounterTriggerActivationEnums + { + CounterTriggerActivation_AnyEdge, //!< Trigger on the rising or falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerActivation_FallingEdge, //!< Trigger on the falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerActivation_LevelHigh, //!< Trigger is active as long as the selected source signal is on a logic high level - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerActivation_LevelLow, //!< Trigger is active as long as the selected source signal is on a logic low level - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerActivation_RisingEdge //!< Trigger on the rising edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for CounterTriggerSource + enum CounterTriggerSourceEnums + { + CounterTriggerSource_AcquisitionActive, //!< The selected counter can be started by an Acquisition Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Action1, //!< The selected counter can be started by an action command that is defined by action signal 1 - Applies to: ace 2 GigE + CounterTriggerSource_Action2, //!< The selected counter can be started by an action command that is defined by action signal 2 - Applies to: ace 2 GigE + CounterTriggerSource_Counter1Active, //!< The selected counter can be started by a Counter 1 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Counter1End, //!< The selected counter can be started by a Counter 1 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Counter1Start, //!< The selected counter can be started by a Counter 1 Start signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Counter2Active, //!< The selected counter can be started by a Counter 2 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Counter2End, //!< The selected counter can be started by a Counter 2 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Counter2Start, //!< The selected counter can be started by a Counter 2 Start signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_CxpTrigger0, //!< The selected counter can be started by a CXP Trigger 0 signal - Applies to: boost CoaXPress + CounterTriggerSource_CxpTrigger1, //!< The selected counter can be started by a CXP Trigger 1 signal - Applies to: boost CoaXPress + CounterTriggerSource_ExposureActive, //!< The selected counter can be started by an Exposure Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_ExposureTriggerWait, //!< The selected counter can be started by an Exposure Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_FrameBurstActive, //!< The selected counter can be started by a Frame Burst Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_FrameBurstTriggerWait, //!< The selected counter can be started by a Frame Burst Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_FrameTriggerWait, //!< The selected counter can be started by a Frame Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Line1, //!< The selected counter can be started by a Line 1 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Line2, //!< The selected counter can be started by a Line 2 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Line3, //!< The selected counter can be started by a Line 3 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Line4, //!< The selected counter can be started by a Line 4 signal - Applies to: dart 2 USB + CounterTriggerSource_Off, //!< The selected counter is disabled and can't be started - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_PeriodicSignal1, //!< The selected counter can be started by a Periodic Signal 1 signal - Applies to: ace 2 GigE + CounterTriggerSource_SoftwareSignal1, //!< The selected counter can be started by a Software Signal 1 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_SoftwareSignal2, //!< The selected counter can be started by a Software Signal 2 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_SoftwareSignal3, //!< The selected counter can be started by a Software Signal 3 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Timer1Active, //!< The selected counter can be started by a Timer 1 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Timer1End, //!< The selected counter can be started by a Timer 1 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Timer2Active, //!< The selected counter can be started by a Timer 2 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + CounterTriggerSource_Timer2End //!< The selected counter can be started by a Timer 2 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for CxpConnectionTestMode + enum CxpConnectionTestModeEnums + { + CxpConnectionTestMode_Mode1, //!< Test mode is enabled - Applies to: boost CoaXPress + CxpConnectionTestMode_Off //!< Test mode is disabled - Applies to: boost CoaXPress + }; + + //! Valid values for CxpErrorCounterSelector + enum CxpErrorCounterSelectorEnums + { + CxpErrorCounterSelector_ConnectionLockLoss, //!< The Connection Lock Loss error counter can be read or reset - Applies to: boost CoaXPress + CxpErrorCounterSelector_ControlPacketCrc, //!< The Control Packet CRC error counter can be read or reset - Applies to: boost CoaXPress + CxpErrorCounterSelector_DuplicatedCharactersUncorrected //!< The Duplicated Characters Uncorrected error counter can be read or reset - Applies to: boost CoaXPress + }; + + //! Valid values for CxpErrorCounterStatus + enum CxpErrorCounterStatusEnums + { + CxpErrorCounterStatus_CounterActive //!< The counter is actively counting errors - Applies to: boost CoaXPress + }; + + //! Valid values for CxpLinkConfiguration + enum CxpLinkConfigurationEnums + { + CxpLinkConfiguration_Auto, //!< The link configuration is set to automatic discovery - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP10_X1, //!< The link configuration is set to 1 connection operating at CXP-10 speed (10 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP10_X2, //!< The link configuration is set to 2 connections operating at CXP-10 speed (10 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP12_X1, //!< The link configuration is set to 1 connection operating at CXP-12 speed (12 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP12_X2, //!< The link configuration is set to 2 connections operating at CXP-12 speed (12 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP2_X1, //!< The link configuration is set to 1 connection operating at CXP-2 speed (2 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP2_X2, //!< The link configuration is set to 2 connections operating at CXP-2 speed (2 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP3_X1, //!< The link configuration is set to 1 connection operating at CXP-3 speed (3 125 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP3_X2, //!< The link configuration is set to 2 connections operating at CXP-3 speed (3 125 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP5_X1, //!< The link configuration is set to 1 connection operating at CXP-5 speed (5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP5_X2, //!< The link configuration is set to 2 connections operating at CXP-5 speed (5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP6_X1, //!< The link configuration is set to 1 connection operating at CXP-6 speed (6 25 Gbps) - Applies to: boost CoaXPress + CxpLinkConfiguration_CXP6_X2 //!< The link configuration is set to 2 connections operating at CXP-6 speed (6 25 Gbps) - Applies to: boost CoaXPress + }; + + //! Valid values for CxpLinkConfigurationPreferred + enum CxpLinkConfigurationPreferredEnums + { + CxpLinkConfigurationPreferred_Auto, //!< The link configuration is set to automatic discovery - Applies to: boost CoaXPress + CxpLinkConfigurationPreferred_CXP10_X1, //!< The link configuration is set to 1 connection operating at CXP-10 speed (10 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationPreferred_CXP12_X1, //!< The link configuration is set to 1 connection operating at CXP-12 speed (12 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationPreferred_CXP2_X1, //!< The link configuration is set to 1 connection operating at CXP-2 speed (2 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationPreferred_CXP3_X1, //!< The link configuration is set to 1 connection operating at CXP-3 speed (3 125 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationPreferred_CXP5_X1, //!< The link configuration is set to 1 connection operating at CXP-5 speed (5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationPreferred_CXP6_X1 //!< The link configuration is set to 1 connection operating at CXP-6 speed (6 25 Gbps) - Applies to: boost CoaXPress + }; + + //! Valid values for CxpLinkConfigurationStatus + enum CxpLinkConfigurationStatusEnums + { + CxpLinkConfigurationStatus_Auto, //!< The link configuration is set to automatic discovery - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP10_X1, //!< The link configuration is set to 1 connection operating at CXP-10 speed (10 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP10_X2, //!< The link configuration is set to 2 connections operating at CXP-10 speed (10 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP12_X1, //!< The link configuration is set to 1 connection operating at CXP-12 speed (12 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP12_X2, //!< The link configuration is set to 2 connections operating at CXP-12 speed (12 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP2_X1, //!< The link configuration is set to 1 connection operating at CXP-2 speed (2 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP2_X2, //!< The link configuration is set to 2 connections operating at CXP-2 speed (2 5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP3_X1, //!< The link configuration is set to 1 connection operating at CXP-3 speed (3 125 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP3_X2, //!< The link configuration is set to 2 connections operating at CXP-3 speed (3 125 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP5_X1, //!< The link configuration is set to 1 connection operating at CXP-5 speed (5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP5_X2, //!< The link configuration is set to 2 connections operating at CXP-5 speed (5 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP6_X1, //!< The link configuration is set to 1 connection operating at CXP-6 speed (6 25 Gbps) - Applies to: boost CoaXPress + CxpLinkConfigurationStatus_CXP6_X2 //!< The link configuration is set to 2 connections operating at CXP-6 speed (6 25 Gbps) - Applies to: boost CoaXPress + }; + + //! Valid values for CxpSendReceiveSelector + enum CxpSendReceiveSelectorEnums + { + CxpSendReceiveSelector_Receive, //!< The receive features can be configured - Applies to: boost CoaXPress + CxpSendReceiveSelector_Send //!< The send features can be configured - Applies to: boost CoaXPress + }; + + //! Valid values for DefectPixelCorrectionMode + enum DefectPixelCorrectionModeEnums + { + DefectPixelCorrectionMode_Off, //!< Defect pixel correction is disabled - Applies to: dart BCON, dart USB and pulse USB + DefectPixelCorrectionMode_On, //!< Defect pixel correction is enabled - Applies to: dart BCON, dart USB and pulse USB + DefectPixelCorrectionMode_StaticOnly //!< Only static defect pixel correction is enabled - Applies to: dart BCON, dart USB and pulse USB + }; + + //! Valid values for DemosaicingMode + enum DemosaicingModeEnums + { + DemosaicingMode_BaslerPGI, //!< Demosaicing is performed using the Basler PGI algorithm - Applies to: GigE and ace USB + DemosaicingMode_Simple //!< Demosaicing is performed using a simple demosaicing algorithm - Applies to: GigE and ace USB + }; + + //! Valid values for DeviceCharacterSet + enum DeviceCharacterSetEnums + { + DeviceCharacterSet_UTF8 //!< The strings of the device's bootstrap registers use the UTF-8 character set - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for DeviceClockSelector + enum DeviceClockSelectorEnums + { + DeviceClockSelector_Bcon //!< The BCON camera clock is selected - Applies to: dart BCON + }; + + //! Valid values for DeviceIndicatorMode + enum DeviceIndicatorModeEnums + { + DeviceIndicatorMode_Active, //!< The status LED of the camera is turned on - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + DeviceIndicatorMode_ErrorStatus, //!< The camera's status LED is inactive unless an error occurs - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + DeviceIndicatorMode_Inactive //!< The status LED of the camera is turned off - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + }; + + //! Valid values for DeviceLinkThroughputLimitMode + enum DeviceLinkThroughputLimitModeEnums + { + DeviceLinkThroughputLimitMode_Off, //!< The Device Link Throughput Limit parameter is disabled - Applies to: ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + DeviceLinkThroughputLimitMode_On //!< The Device Link Throughput Limit parameter is enabled - Applies to: ace 2 GigE, ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + }; + + //! Valid values for DeviceRegistersEndianness + enum DeviceRegistersEndiannessEnums + { + DeviceRegistersEndianness_Big, //!< The endianness of the device's registers is big-endian - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + DeviceRegistersEndianness_Little //!< The endianness of the device's registers is little-endian - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for DeviceScanType + enum DeviceScanTypeEnums + { + DeviceScanType_Areascan, //!< The camera has an area scan sensor - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + DeviceScanType_Areascan3D, //!< Device outputs 2D range image - Applies to: blaze + DeviceScanType_Linescan, //!< The camera has a line scan sensor - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress and dart 2 USB + DeviceScanType_Linescan3D //!< Device outputs 1D range image - Applies to: blaze + }; + + //! Valid values for DeviceTLType + enum DeviceTLTypeEnums + { + DeviceTLType_CoaXPress, //!< The device provides a CoaXPress transport layer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + DeviceTLType_GigEVision, //!< The device provides a GigE Vision transport layer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + DeviceTLType_USB3Vision //!< The device provides a USB3 Vision transport layer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for DeviceTapGeometry + enum DeviceTapGeometryEnums + { + DeviceTapGeometry_Geometry_1X_1Y //!< The tap geometry is set to 1 zone in horizontal direction with one tap and 1 zone in vertical direction with 1 tap - Applies to: boost CoaXPress + }; + + //! Valid values for DeviceTemperatureSelector + enum DeviceTemperatureSelectorEnums + { + DeviceTemperatureSelector_CPU, //!< Temperature of the device's CPU - Applies to: blaze + DeviceTemperatureSelector_Camera, //!< The temperature is measured on the camera housing - Applies to: boost CoaXPress + DeviceTemperatureSelector_Coreboard, //!< The temperature is measured on the core board - Applies to: ace 2 GigE, ace 2 USB and ace USB + DeviceTemperatureSelector_FpgaCore, //!< The temperature is measured on the FPGA board - Applies to: boost CoaXPress and dart 2 USB + DeviceTemperatureSelector_Framegrabberboard, //!< The temperature is measured on the frame grabber board - Applies to: ace USB + DeviceTemperatureSelector_Illumination, //!< Temperature of the device's illumination board - Applies to: blaze + DeviceTemperatureSelector_Sensor, //!< The temperature is measured on the image sensor - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + DeviceTemperatureSelector_Sensorboard //!< The temperature is measured on the sensor board - Applies to: ace USB and blaze + }; + + //! Valid values for DeviceType + enum DeviceTypeEnums + { + DeviceType_Peripheral, //!< Controllable device (with no data stream handling) - Applies to: blaze + DeviceType_Receiver, //!< Data stream receiver device - Applies to: blaze + DeviceType_Transceiver, //!< Data stream receiver and transmitter device - Applies to: blaze + DeviceType_Transmitter //!< Data stream transmitter device - Applies to: blaze + }; + + //! Valid values for EventNotification + enum EventNotificationEnums + { + EventNotification_GenICamEvent, //!< Event notifications are enabled and the notification type is set to GenICam - Applies to: GigE + EventNotification_Off, //!< Event notifications are disabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + EventNotification_On, //!< Event notifications are enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + EventNotification_Once //!< Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for EventSelector + enum EventSelectorEnums + { + EventSelector_AcquisitionStart, //!< Event notifications for the Acquisition Start event can be enabled - Applies to: GigE + EventSelector_AcquisitionStartOvertrigger, //!< Event notifications for the Acquisition Start Overtrigger event can be enabled - Applies to: GigE + EventSelector_AcquisitionStartWait, //!< Event notifications for the Acquisition Start Wait event can be enabled - Applies to: GigE + EventSelector_AcquisitionWait, //!< Event notifications for the Acquisition Wait event can be enabled - Applies to: GigE + EventSelector_ActionLate, //!< Event notifications for the Action Late event can be enabled - Applies to: GigE and ace 2 GigE + EventSelector_CriticalTemperature, //!< Event notifications for the Critical Temperature event can be enabled - Applies to: GigE and ace USB + EventSelector_EventOverrun, //!< Event notifications for the Event Overrun event can be enabled - Applies to: GigE + EventSelector_ExposureEnd, //!< Event notifications for the Exposure End event can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + EventSelector_FrameBufferOverrun, //!< Event notifications for the Frame Buffer Overrun event can be enabled - Applies to: ace 2 GigE and ace 2 USB + EventSelector_FrameBurstStart, //!< Event notifications for the Frame Burst Start event can be enabled - Applies to: ace USB + EventSelector_FrameBurstStartOvertrigger, //!< Event notifications for the Frame Burst Start Overtrigger event can be enabled - Applies to: ace USB + EventSelector_FrameBurstStartWait, //!< Event notifications for the Frame Burst Start Wait event can be enabled - Applies to: ace USB + EventSelector_FrameStart, //!< Event notifications for the Frame Start event can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + EventSelector_FrameStartOvertrigger, //!< Event notifications for the Frame Start Overtrigger event can be enabled - Applies to: GigE and ace USB + EventSelector_FrameStartWait, //!< Event notifications for the Frame Start Wait event can be enabled - Applies to: GigE and ace USB + EventSelector_FrameTimeout, //!< Event notifications for the Frame Timeout event can be enabled - Applies to: GigE + EventSelector_FrameTriggerMissed, //!< Event notifications for the Frame Trigger Missed event can be enabled - Applies to: ace 2 GigE and ace 2 USB + EventSelector_FrameWait, //!< Event notifications for the Frame Wait event can be enabled - Applies to: GigE + EventSelector_Line1RisingEdge, //!< Applies to: GigE + EventSelector_Line2RisingEdge, //!< Applies to: GigE + EventSelector_Line3RisingEdge, //!< Applies to: GigE + EventSelector_Line4RisingEdge, //!< Applies to: GigE + EventSelector_LineStartOvertrigger, //!< Event notifications for the Line Start Overtrigger event can be enabled - Applies to: GigE + EventSelector_OverTemperature, //!< Event notifications for the Over Temperature event can be enabled - Applies to: GigE and ace USB + EventSelector_Overrun, //!< Event notifications for the Overrun event can be enabled - Applies to: ace 2 GigE and ace 2 USB + EventSelector_TemperatureStatusChanged, //!< Event notifications for the Temperature Status Changed event can be enabled - Applies to: ace 2 GigE and ace 2 USB + EventSelector_Test, //!< Event notifications for the Test event can be enabled - Applies to: ace 2 GigE and ace 2 USB + EventSelector_VirtualLine1RisingEdge, //!< Applies to: GigE + EventSelector_VirtualLine2RisingEdge, //!< Applies to: GigE + EventSelector_VirtualLine3RisingEdge, //!< Applies to: GigE + EventSelector_VirtualLine4RisingEdge //!< Applies to: GigE + }; + + //! Valid values for EventTemperatureStatusChangedStatus + enum EventTemperatureStatusChangedStatusEnums + { + EventTemperatureStatusChangedStatus_Critical, //!< The temperature status changed to Critical - Applies to: ace 2 GigE and ace 2 USB + EventTemperatureStatusChangedStatus_Error, //!< The temperature status changed to Error - Applies to: ace 2 GigE and ace 2 USB + EventTemperatureStatusChangedStatus_Ok //!< The temperature status changed to Ok - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for ExpertFeatureAccessSelector + enum ExpertFeatureAccessSelectorEnums + { + ExpertFeatureAccessSelector_ExpertFeature1, //!< Expert Feature 1 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature10, //!< Expert Feature 10 can be configured - Applies to: GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature11, //!< Expert feature 11 can be configured - Applies to: GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature1_Legacy, //!< Expert Feature 1 (Legacy) can be configured - Applies to: CameraLink and GigE + ExpertFeatureAccessSelector_ExpertFeature2, //!< Expert Feature 2 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature3, //!< Expert Feature 3 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature4, //!< Expert Feature 4 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature5, //!< Expert Feature 5 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature6, //!< Expert Feature 6 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature7, //!< Expert Feature 7 can be configured - Applies to: CameraLink, GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature8, //!< Expert Feature 8 can be configured - Applies to: GigE and ace USB + ExpertFeatureAccessSelector_ExpertFeature9 //!< Expert Feature 9 can be configured - Applies to: GigE and ace USB + }; + + //! Valid values for ExposureAuto + enum ExposureAutoEnums + { + ExposureAuto_Continuous, //!< The exposure time is adjusted continuously while images are being acquired - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + ExposureAuto_Off, //!< Automatic exposure time adjustment is disabled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + ExposureAuto_Once //!< The exposure time is adjusted automatically to reach the specified target value - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for ExposureMode + enum ExposureModeEnums + { + ExposureMode_Off, //!< Sets the exposure mode to off - Applies to: CameraLink and GigE + ExposureMode_Timed, //!< The exposure mode is set to Timed - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + ExposureMode_TriggerControlled, //!< The exposure mode is set to Trigger Controlled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + ExposureMode_TriggerWidth //!< The exposure mode is set to Trigger Width - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + }; + + //! Valid values for ExposureOverlapTimeMode + enum ExposureOverlapTimeModeEnums + { + ExposureOverlapTimeMode_Automatic, //!< The camera automatically uses the optimum overlap time for each acquisition - Applies to: GigE and ace USB + ExposureOverlapTimeMode_Manual //!< The user can manually set the overlap time for each acquisition - Applies to: GigE and ace USB + }; + + //! Valid values for ExposureTimeMode + enum ExposureTimeModeEnums + { + ExposureTimeMode_Standard, //!< The exposure time mode is set to Standard - Applies to: GigE and ace USB + ExposureTimeMode_UltraShort //!< The exposure time mode is set to Ultra Short - Applies to: GigE and ace USB + }; + + //! Valid values for FeatureSet + enum FeatureSetEnums + { + FeatureSet_Basic, //!< The basic feature set is made available - Applies to: CameraLink and GigE + FeatureSet_Full //!< The full feature set is made available - Applies to: CameraLink and GigE + }; + + //! Valid values for FieldOutputMode + enum FieldOutputModeEnums + { + FieldOutputMode_ConcatenatedNewFields, //!< Sets the mode to output a frame consisting of field 0 in the upper half and field 1 in the lower half of the frame - Applies to: CameraLink and GigE + FieldOutputMode_DeinterlacedNewFields, //!< Sets the mode to output a frame generated by deinterlacing field 0 and field 1 using the deinterlacer selected by feature Deinterlacer - Applies to: CameraLink and GigE + FieldOutputMode_Field0, //!< Sets the mode to only output field 0 - Applies to: CameraLink and GigE + FieldOutputMode_Field0First, //!< Sets the mode to only output field 0 and field 1 in single frames Starting with field 0 - Applies to: CameraLink and GigE + FieldOutputMode_Field1 //!< Sets the mode to only output field 1 - Applies to: CameraLink and GigE + }; + + //! Valid values for FileOpenMode + enum FileOpenModeEnums + { + FileOpenMode_Read, //!< Files are opened in read-only mode - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + FileOpenMode_Write //!< Files are opened in write-only mode - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for FileOperationSelector + enum FileOperationSelectorEnums + { + FileOperationSelector_Close, //!< The currently selected file can be closed - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + FileOperationSelector_Open, //!< The currently selected file can be opened - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + FileOperationSelector_Read, //!< The currently selected file can be read - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + FileOperationSelector_Write //!< The currently selected file can be written to - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for FileOperationStatus + enum FileOperationStatusEnums + { + FileOperationStatus_Failure, //!< The file operation has failed - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + FileOperationStatus_Success //!< The file operation was successful - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for FileSelector + enum FileSelectorEnums + { + FileSelector_BootUpdate, //!< The Boot Firmware Update file is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + FileSelector_BootUpdatePackage, //!< The Boot Firmware Update Package file is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + FileSelector_ExpertFeature7File, //!< The Expert Feature 7 File file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_FirmwareUpdate, //!< The Firmware Update file is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + FileSelector_FirmwareUpdatePackage, //!< The Firmware Update Package file is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + FileSelector_None, //!< No file is selected - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + FileSelector_UserData, //!< The User Data file is selected - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + FileSelector_UserGainShading1, //!< The User Gain Shading 1 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_UserGainShading2, //!< The User Gain Shading 2 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_UserOffsetShading1, //!< The User Offset Shading 1 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_UserOffsetShading2, //!< The User Offset Shading 2 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_UserSet1, //!< The User Set 1 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_UserSet2, //!< The User Set 2 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_UserSet3, //!< The User Set 3 file is selected - Applies to: CameraLink, GigE and ace USB + FileSelector_VignettingCorrection //!< The Vignetting Correction file is selected - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for FrequencyConverterInputSource + enum FrequencyConverterInputSourceEnums + { + FrequencyConverterInputSource_CC1, //!< CC1 is selected as the source signal for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_CC2, //!< CC2 is selected as the source signal for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_CC3, //!< CC3 is selected as the source signal for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_CC4, //!< CC4 is selected as the source signal for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line1, //!< Line 1 is selected as the input source for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line2, //!< Line 2 is selected as the input source for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line3, //!< Line 3 is selected as the input source for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line4, //!< Line 4 is selected as the input source for the frequency converter module - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line5, //!< Selects line 5 as the input source - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line6, //!< Selects line 6 as the input source - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line7, //!< Selects line 7 as the input source - Applies to: CameraLink and GigE + FrequencyConverterInputSource_Line8, //!< Selects line 8 as the input source - Applies to: CameraLink and GigE + FrequencyConverterInputSource_ShaftEncoderModuleOut //!< The output of the shaft encoder module is selected as the input source for the frequency converter module - Applies to: CameraLink and GigE + }; + + //! Valid values for FrequencyConverterSignalAlignment + enum FrequencyConverterSignalAlignmentEnums + { + FrequencyConverterSignalAlignment_FallingEdge, //!< For the falling edge of each received signal, a falling edge of a generated signal is provided - Applies to: CameraLink and GigE + FrequencyConverterSignalAlignment_RisingEdge //!< For the rising edge of each received signal, a rising edge of a generated signal is provided - Applies to: CameraLink and GigE + }; + + //! Valid values for GainAuto + enum GainAutoEnums + { + GainAuto_Continuous, //!< The gain is adjusted continuously while images are being acquired - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + GainAuto_Off, //!< Automatic gain adjustment is disabled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + GainAuto_Once //!< The gain is adjusted automatically to reach the specifed target value - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for GainSelector + enum GainSelectorEnums + { + GainSelector_All, //!< Changes to the gain will be applied universally - Applies to: CameraLink, GigE, ace USB, dart BCON, dart USB and pulse USB + GainSelector_AnalogAll, //!< Changes to the gain will be applied to all analog gain parameters - Applies to: CameraLink, GigE and ace USB + GainSelector_Blue, //!< Selects the blue gain control for adjustment - Applies to: CameraLink and GigE + GainSelector_DigitalAll, //!< Changes to the gain will be applied to all digital gain parameters - Applies to: CameraLink, GigE and ace USB + GainSelector_Green, //!< Selects the green gain control for adjustment - Applies to: CameraLink and GigE + GainSelector_Red, //!< Selects the red gain control for adjustment - Applies to: CameraLink and GigE + GainSelector_Tap1, //!< Changes to the gain will be applied to tap 1 - Applies to: CameraLink and GigE + GainSelector_Tap2, //!< Changes to the gain will be applied to tap 2 - Applies to: CameraLink and GigE + GainSelector_Tap3, //!< Changes to the gain will be applied to tap 3 - Applies to: CameraLink and GigE + GainSelector_Tap4 //!< Changes to the gain will be applied to tap 4 - Applies to: CameraLink and GigE + }; + + //! Valid values for GammaSelector + enum GammaSelectorEnums + { + GammaSelector_User, //!< The gamma curve can be configured by the user - Applies to: CameraLink and GigE + GammaSelector_sRGB //!< The gamma curve is set to a fixed sRGB curve - Applies to: CameraLink and GigE + }; + + //! Valid values for GenDCStreamingMode + enum GenDCStreamingModeEnums + { + GenDCStreamingMode_Automatic, //!< The device will automatically choose in which format it streams its data - Applies to: blaze + GenDCStreamingMode_Off, //!< The device will only stream data in its native format - Applies to: blaze + GenDCStreamingMode_On //!< The device will stream all its data in the generic GenDC format - Applies to: blaze + }; + + //! Valid values for GenDCStreamingStatus + enum GenDCStreamingStatusEnums + { + GenDCStreamingStatus_Off, //!< The device will only stream data in its native format - Applies to: blaze + GenDCStreamingStatus_On //!< The device will stream all its data in the generic GenDC format - Applies to: blaze + }; + + //! Valid values for GevCCP + enum GevCCPEnums + { + GevCCP_Control, //!< The control channel privilege is set to Control - Applies to: GigE + GevCCP_Exclusive, //!< The control channel privilege is set to Exclusive - Applies to: GigE + GevCCP_ExclusiveControl //!< The control channel privilege is set to Exclusive Control - Applies to: GigE + }; + + //! Valid values for GevGVSPExtendedIDMode + enum GevGVSPExtendedIDModeEnums + { + GevGVSPExtendedIDMode_Off, //!< The Extended ID mode is switched off - Applies to: GigE + GevGVSPExtendedIDMode_On //!< The Extended ID mode is switched on - Applies to: GigE + }; + + //! Valid values for GevIEEE1588Status + enum GevIEEE1588StatusEnums + { + GevIEEE1588Status_Disabled, //!< The port is in the Disabled state - Applies to: GigE + GevIEEE1588Status_Faulty, //!< The port is in the Faulty state - Applies to: GigE + GevIEEE1588Status_Initializing, //!< The port is in the Initializing state - Applies to: GigE + GevIEEE1588Status_Listening, //!< The port is in the Listening state - Applies to: GigE + GevIEEE1588Status_Master, //!< The port is in the Master state - Applies to: GigE + GevIEEE1588Status_Passive, //!< The port is in the Passive state - Applies to: GigE + GevIEEE1588Status_PreMaster, //!< The port is in the PreMaster state - Applies to: GigE + GevIEEE1588Status_Slave, //!< The port is in the Slave state - Applies to: GigE + GevIEEE1588Status_Uncalibrated, //!< The port is in the Uncalibrated state - Applies to: GigE + GevIEEE1588Status_Undefined //!< The port is in an undefined state - Applies to: GigE + }; + + //! Valid values for GevIEEE1588StatusLatched + enum GevIEEE1588StatusLatchedEnums + { + GevIEEE1588StatusLatched_Disabled, //!< The port is in the Disabled state - Applies to: GigE + GevIEEE1588StatusLatched_Faulty, //!< The port is in the Faulty state - Applies to: GigE + GevIEEE1588StatusLatched_Initializing, //!< The port is in the Initializing state - Applies to: GigE + GevIEEE1588StatusLatched_Listening, //!< The port is in the Listening state - Applies to: GigE + GevIEEE1588StatusLatched_Master, //!< The port is in the Master state - Applies to: GigE + GevIEEE1588StatusLatched_Passive, //!< The port is in the Passive state - Applies to: GigE + GevIEEE1588StatusLatched_PreMaster, //!< The port is in the PreMaster state - Applies to: GigE + GevIEEE1588StatusLatched_Slave, //!< The port is in the Slave state - Applies to: GigE + GevIEEE1588StatusLatched_Uncalibrated, //!< The port is in the Uncalibrated state - Applies to: GigE + GevIEEE1588StatusLatched_Undefined //!< The port is in an undefined state - Applies to: GigE + }; + + //! Valid values for GevInterfaceSelector + enum GevInterfaceSelectorEnums + { + GevInterfaceSelector_NetworkInterface0 //!< Network interface 0 can be configured - Applies to: GigE + }; + + //! Valid values for GevStreamChannelSelector + enum GevStreamChannelSelectorEnums + { + GevStreamChannelSelector_StreamChannel0 //!< Stream channel 0 can be configured - Applies to: GigE + }; + + //! Valid values for ImageCompressionMode + enum ImageCompressionModeEnums + { + ImageCompressionMode_BaslerCompressionBeyond, //!< Images are compressed using the Compression Beyond feature - Applies to: ace 2 GigE and ace 2 USB + ImageCompressionMode_Off //!< Image compression is disabled - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for ImageCompressionRateOption + enum ImageCompressionRateOptionEnums + { + ImageCompressionRateOption_FixRatio, //!< The camera compresses acquired images If lossless compression can't be achieved, image quality is reduced - Applies to: ace 2 GigE and ace 2 USB + ImageCompressionRateOption_Lossless //!< The camera uses lossless compression - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for ImageFileMode + enum ImageFileModeEnums + { + ImageFileMode_Off, //!< Sets the mode to off - Applies to: CamEmu + ImageFileMode_On //!< Sets the mode to on - Applies to: CamEmu + }; + + //! Valid values for IntensityCalculation + enum IntensityCalculationEnums + { + IntensityCalculation_Method1, //!< Method 1 is used to calculate the intensity image - Applies to: blaze + IntensityCalculation_Method2 //!< Method 2 is used to calculate the intensity image - Applies to: blaze + }; + + //! Valid values for InterlacedIntegrationMode + enum InterlacedIntegrationModeEnums + { + InterlacedIntegrationMode_FieldIntegration, //!< Sets the integration mode to field integration - Applies to: CameraLink and GigE + InterlacedIntegrationMode_FrameIntegration //!< Sets the integration mode to frame integration - Applies to: CameraLink and GigE + }; + + //! Valid values for LUTSelector + enum LUTSelectorEnums + { + LUTSelector_Luminance //!< The luminance lookup table can be configured - Applies to: CameraLink, GigE and ace USB + }; + + //! Valid values for LastError + enum LastErrorEnums + { + LastError_Illumination, //!< Indicates a problem with the VCSELs - Applies to: blaze + LastError_InsufficientTriggerWidth, //!< The trigger width was too short - Applies to: CameraLink and GigE + LastError_InvalidParameter, //!< A parameter was set to an invalid value - Applies to: CameraLink and GigE + LastError_NoError, //!< No error was detected - Applies to: CameraLink, GigE and blaze + LastError_OverTemperature, //!< An over temperature state has been detected - Applies to: CameraLink, GigE and blaze + LastError_Overtrigger, //!< The camera was overtriggered - Applies to: CameraLink and GigE + LastError_PowerFailure, //!< The power supply is not sufficient - Applies to: CameraLink and GigE + LastError_UserDefPixFailure, //!< An error was detected while loading user defect pixel data - Applies to: CameraLink and GigE + LastError_Userset //!< An error was detected while loading a user set - Applies to: CameraLink and GigE + }; + + //! Valid values for LegacyBinningVertical + enum LegacyBinningVerticalEnums + { + LegacyBinningVertical_Off, //!< Vertical binning is disabled - Applies to: CameraLink and GigE + LegacyBinningVertical_Two_Rows //!< Vertical binning is set to 2 rows - Applies to: CameraLink and GigE + }; + + //! Valid values for LightSourcePreset + enum LightSourcePresetEnums + { + LightSourcePreset_Daylight5000K, //!< The light source preset for image acquisitions with daylight of 5000 K is selected - Applies to: ace USB, dart BCON, dart USB and pulse USB + LightSourcePreset_Daylight6500K, //!< The light source preset for image acquisitions with daylight of 6500 K is selected - Applies to: ace USB, dart BCON, dart USB and pulse USB + LightSourcePreset_MicroscopeLED4500K, //!< The light source preset for image acquisitions with microscope LED illumination of 4500 K is set - Applies to: ace USB + LightSourcePreset_MicroscopeLED5500K, //!< The light source preset for image acquisitions with microscope LED illumination of 5500 K is set - Applies to: ace USB + LightSourcePreset_MicroscopeLED6000K, //!< The light source preset for image acquisitions with microscope LED illumination of 6000 K is set - Applies to: ace USB + LightSourcePreset_Off, //!< No light source preset is selected - Applies to: ace USB, dart BCON, dart USB and pulse USB + LightSourcePreset_Tungsten2800K //!< The light source preset for image acquisitions with tungsten incandescent light (2800 K) is selected - Applies to: ace USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for LightSourceSelector + enum LightSourceSelectorEnums + { + LightSourceSelector_Custom, //!< The color transformation matrix can be customized - Applies to: CameraLink and GigE + LightSourceSelector_Daylight, //!< The color transformation matrix is optimized for image acquisitions with daylight of 5000 K - Applies to: CameraLink and GigE + LightSourceSelector_Daylight6500K, //!< The color transformation matrix is optimized for image acquisitions with daylight of 6500 K - Applies to: CameraLink and GigE + LightSourceSelector_LightSource0, //!< The color transformation matrix is optimized for image acquisitions with a custom light source 0 - Applies to: CameraLink and GigE + LightSourceSelector_LightSource1, //!< The color transformation matrix is optimized for image acquisitions with a custom light source 1 - Applies to: CameraLink and GigE + LightSourceSelector_MicroscopeLED4500K, //!< The light source preset for image acquisitions with microscope LED illumination of 4500 K is set - Applies to: GigE + LightSourceSelector_MicroscopeLED5500K, //!< The light source preset for image acquisitions with microscope LED illumination of 5500 K is set - Applies to: GigE + LightSourceSelector_MicroscopeLED6000K, //!< The light source preset for image acquisitions with microscope LED illumination of 6000 K is set - Applies to: GigE + LightSourceSelector_Off, //!< No color transformation for a specific light source is performed - Applies to: CameraLink and GigE + LightSourceSelector_Tungsten //!< The color transformation matrix is optimized for image acquisition with tungsten incandescent light (3100 K) - Applies to: CameraLink and GigE + }; + + //! Valid values for LineFormat + enum LineFormatEnums + { + LineFormat_LVDS, //!< The line is currently accepting or sending LVDS level signals - Applies to: CameraLink, GigE, ace USB and dart BCON + LineFormat_LVTTL, //!< The line is currently accepting or sending LVTTL level signals - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB and dart USB + LineFormat_NoConnect, //!< The line is not connected - Applies to: CameraLink, GigE and ace USB + LineFormat_OpenDrain, //!< The output of the line is "open drain"/"open collector" - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineFormat_OptoCoupled, //!< The line is opto-coupled - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + LineFormat_RS422, //!< The line is currently accepting or sending RS-422 level signals - Applies to: CameraLink, GigE and ace USB + LineFormat_TTL, //!< The line is currently accepting or sending TTL level signals - Applies to: CameraLink, GigE and ace USB + LineFormat_TriState //!< The line is currently in tri-state mode (not driven) - Applies to: CameraLink, GigE and ace USB + }; + + //! Valid values for LineLogic + enum LineLogicEnums + { + LineLogic_Negative, //!< The line logic of the currently selected line is negative - Applies to: CameraLink, GigE and ace USB + LineLogic_Positive //!< The line logic of the currently selected line is positive - Applies to: CameraLink, GigE and ace USB + }; + + //! Valid values for LineMode + enum LineModeEnums + { + LineMode_Input, //!< The selected physical line can be used to input an electrical signal - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineMode_Output //!< The selected physical line can be used to output an electrical signal - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + }; + + //! Valid values for LineSelector + enum LineSelectorEnums + { + LineSelector_CC1, //!< CC1 can be configured - Applies to: CameraLink + LineSelector_CC2, //!< CC2 can be configured - Applies to: CameraLink + LineSelector_CC3, //!< CC3 can be configured - Applies to: CameraLink + LineSelector_CC4, //!< CC4 can be configured - Applies to: CameraLink + LineSelector_ClSpare, //!< The CL Spare line can be configured - Applies to: CameraLink + LineSelector_In1, //!< Selects input line 1 for configuration - Applies to: CameraLink + LineSelector_In2, //!< Selects input line 2 for configuration - Applies to: CameraLink + LineSelector_In3, //!< Selects input line 3 for configuration - Applies to: CameraLink + LineSelector_In4, //!< Selects input line 4 for configuration - Applies to: CameraLink + LineSelector_Line1, //!< Line 1 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineSelector_Line2, //!< Line 2 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineSelector_Line3, //!< Line 3 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB and dart BCON + LineSelector_Line4, //!< Line 4 can be configured - Applies to: CameraLink, GigE, ace USB and dart 2 USB + LineSelector_Line5, //!< Selects line 5 for configuration - Applies to: CameraLink + LineSelector_Line6, //!< Selects line 6 for configuration - Applies to: CameraLink + LineSelector_Line7, //!< Selects line 7 for configuration - Applies to: CameraLink + LineSelector_Line8, //!< Selects line 8 for configuration - Applies to: CameraLink + LineSelector_Out1, //!< Output Line 1 can be configured - Applies to: CameraLink and GigE + LineSelector_Out2, //!< Output Line 2 can be configured - Applies to: CameraLink and GigE + LineSelector_Out3, //!< Output Line 3 can be configured - Applies to: CameraLink and GigE + LineSelector_Out4 //!< Output Line 4 can be configured - Applies to: CameraLink and GigE + }; + + //! Valid values for LineSource + enum LineSourceEnums + { + LineSource_AcquisitionActive, //!< The source signal for the currently selected line is set to Acquisition Active - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineSource_AcquisitionTriggerReady, //!< The source signal for the currently selected line is set to Acquisition Trigger Ready - Applies to: CameraLink and GigE + LineSource_AcquisitionTriggerWait, //!< The source signal for the currently selected line is set to Acquisition Trigger Wait - Applies to: CameraLink and GigE + LineSource_BslLightControl, //!< The source signal for the currently selected line is set to Light Control - Applies to: GigE and ace USB + LineSource_Counter1Active, //!< The source signal for the currently selected line is set to Counter 1 Active - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineSource_Counter2Active, //!< The source signal for the currently selected line is set to Counter 2 Active - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineSource_ExposureActive, //!< The source signal for the currently selected line is set to Exposure Active - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineSource_ExposureTriggerWait, //!< The source signal for the currently selected line is set to Exposure Trigger Wait - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineSource_FlashWindow, //!< The source signal for the currently selected line is set to Flash Window - Applies to: CameraLink, GigE, ace USB, dart BCON and dart USB + LineSource_FrameBurstActive, //!< The source signal for the currently selected line is set to Frame Burst Active - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineSource_FrameBurstTriggerWait, //!< The source signal for the currently selected line is set to Frame Burst Trigger Wait - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + LineSource_FrameCycle, //!< The signal for the currently selected line is rising with Frame Trigger Wait and falling with Exposure Active - Applies to: CameraLink and GigE + LineSource_FrameTriggerWait, //!< The source signal for the currently selected line is set to Frame Trigger Wait - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + LineSource_FrequencyConverter, //!< The signal for the currently selected line is associated with the output of the frequency converter module - Applies to: CameraLink and GigE + LineSource_LineTriggerWait, //!< The source signal for the currently selected line is set to Line Trigger Wait - Applies to: CameraLink and GigE + LineSource_Off, //!< No source signal is set for the currently selected line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + LineSource_PatternGenerator1, //!< Applies to: CameraLink and GigE + LineSource_PatternGenerator2, //!< Applies to: CameraLink and GigE + LineSource_PatternGenerator3, //!< Applies to: CameraLink and GigE + LineSource_PatternGenerator4, //!< Applies to: CameraLink and GigE + LineSource_SerialTx, //!< The source signal for the currently selected line is set to Serial Tx - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB and boost CoaXPress + LineSource_ShaftEncoderModuleOut, //!< The signal for the currently selected line is associated with the output of the shaft encoder module - Applies to: CameraLink and GigE + LineSource_SyncUserOutput, //!< The source signal for the currently selected line is set to Sync User Output - Applies to: CameraLink and GigE + LineSource_SyncUserOutput0, //!< The source signal for the currently selected line is set to Sync User Output 0 - Applies to: GigE + LineSource_SyncUserOutput1, //!< The source signal for the currently selected line is set to Sync User Output 1 - Applies to: GigE + LineSource_SyncUserOutput2, //!< The source signal for the currently selected line is set to Sync User Output 2 - Applies to: GigE + LineSource_SyncUserOutput3, //!< The source signal for the currently selected line is set to Sync User Output 3 - Applies to: GigE + LineSource_Timer1Active, //!< The source signal for the currently selected line is set to Timer 1 Active - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + LineSource_Timer2Active, //!< The source signal for the currently selected line is set to Timer 2 Active - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + LineSource_Timer3Active, //!< Sets the source signal for the selected output line to timer 3 active - Applies to: CameraLink and GigE + LineSource_Timer4Active, //!< Sets the source signal for the selected output line to timer 4 active - Applies to: CameraLink and GigE + LineSource_TimerActive, //!< The source signal for the currently selected line is set to Timer Active - Applies to: CameraLink and GigE + LineSource_TriggerReady, //!< The source signal for the currently selected line is set to Trigger Ready - Applies to: CameraLink and GigE + LineSource_UserOutput, //!< The source signal for the currently selected line is set to User Output - Applies to: CameraLink and GigE + LineSource_UserOutput0, //!< The source signal for the currently selected line is set to User Output 0 - Applies to: GigE and ace USB + LineSource_UserOutput1, //!< The source signal for the currently selected line is set to User Output 1 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineSource_UserOutput2, //!< The source signal for the currently selected line is set to User Output 2 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineSource_UserOutput3, //!< The source signal for the currently selected line is set to User Output 3 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + LineSource_UserOutput4 //!< The source signal for the currently selected line is set to User Output 4 - Applies to: CameraLink, GigE, dart 2 USB, dart BCON and dart USB + }; + + //! Valid values for OperatingMode + enum OperatingModeEnums + { + OperatingMode_LongRange, //!< The operating mode is set to Long Range - Applies to: blaze + OperatingMode_ShortRange //!< The operating mode is set to Short Range - Applies to: blaze + }; + + //! Valid values for OverlapMode + enum OverlapModeEnums + { + OverlapMode_Off, //!< Overlapping image acquisition is disabled - Applies to: dart BCON, dart USB and pulse USB + OverlapMode_On //!< Overlapping image acquisition is enabled - Applies to: dart BCON, dart USB and pulse USB + }; + + //! Valid values for ParameterSelector + enum ParameterSelectorEnums + { + ParameterSelector_AutoTargetValue, //!< The factory limits of the Auto Target Value parameter can be removed - Applies to: CameraLink and GigE + ParameterSelector_BlackLevel, //!< The factory limits of the Black Level parameter can be removed - Applies to: CameraLink and GigE + ParameterSelector_Brightness, //!< The factory limits of the Brightness parameter can be removed - Applies to: CameraLink and GigE + ParameterSelector_ExposureOverhead, //!< The factory limits of the Exposure Overhead parameter can be removed - Applies to: CameraLink and GigE + ParameterSelector_ExposureOverlapMax, //!< The factory limits of the Exposure Overlap Time Max parameter can be removed - Applies to: GigE + ParameterSelector_ExposureTime, //!< The factory limits of the Exposure Time parameter can be removed - Applies to: CameraLink and GigE + ParameterSelector_Framerate, //!< The factory limits of the Framerate parameter can be removed - Applies to: CameraLink and GigE + ParameterSelector_Gain //!< The factory limits of the Gain parameter can be removed - Applies to: CameraLink and GigE + }; + + //! Valid values for PgiMode + enum PgiModeEnums + { + PgiMode_Off, //!< Basler PGI image optimizations are disabled - Applies to: GigE and ace USB + PgiMode_On //!< Basler PGI image optimizations are enabled - Applies to: GigE and ace USB + }; + + //! Valid values for PixelCoding + enum PixelCodingEnums + { + PixelCoding_BGR16, //!< Applies to: CameraLink and GigE + PixelCoding_BGR8, //!< Applies to: CameraLink and GigE + PixelCoding_BGRA8, //!< Applies to: CameraLink and GigE + PixelCoding_BayerBG10p, //!< Sets the pixel format to Bayer BG 10p - Applies to: GigE + PixelCoding_BayerGB10p, //!< Sets the pixel format to Bayer GB 10p - Applies to: GigE + PixelCoding_BayerGR10p, //!< Sets the pixel format to Bayer GR 10p - Applies to: GigE + PixelCoding_BayerRG10p, //!< Sets the pixel format to Bayer RG 10p - Applies to: GigE + PixelCoding_Mono10Packed, //!< Applies to: CameraLink and GigE + PixelCoding_Mono12Packed, //!< Applies to: CameraLink and GigE + PixelCoding_Mono16, //!< Applies to: CameraLink and GigE + PixelCoding_Mono8, //!< Applies to: CameraLink and GigE + PixelCoding_Mono8Signed, //!< Applies to: CameraLink and GigE + PixelCoding_RGB10V1Packed, //!< Applies to: CameraLink and GigE + PixelCoding_RGB10V2Packed, //!< Applies to: CameraLink and GigE + PixelCoding_RGB16, //!< Applies to: CameraLink and GigE + PixelCoding_RGB16Planar, //!< Applies to: CameraLink and GigE + PixelCoding_RGB8, //!< Applies to: CameraLink and GigE + PixelCoding_RGB8Planar, //!< Applies to: CameraLink and GigE + PixelCoding_RGBA8, //!< Applies to: CameraLink and GigE + PixelCoding_Raw16, //!< Applies to: CameraLink and GigE + PixelCoding_Raw8, //!< Applies to: CameraLink and GigE + PixelCoding_YUV411, //!< Applies to: CameraLink and GigE + PixelCoding_YUV422, //!< Applies to: CameraLink and GigE + PixelCoding_YUV444 //!< Applies to: CameraLink and GigE + }; + + //! Valid values for PixelColorFilter + enum PixelColorFilterEnums + { + PixelColorFilter_BayerBG, //!< The Bayer filter has a BG/GR alignment to the pixels in the acquired images - Applies to: ace USB, dart BCON, dart USB and pulse USB + PixelColorFilter_BayerGB, //!< The Bayer filter has a GB/RG alignment to the pixels in the acquired images - Applies to: ace USB, dart BCON, dart USB and pulse USB + PixelColorFilter_BayerGR, //!< The Bayer filter has a GR/BG alignment to the pixels in the acquired images - Applies to: ace USB, dart BCON, dart USB and pulse USB + PixelColorFilter_BayerRG, //!< The Bayer filter has an RG/GB alignment to the pixels in the acquired images - Applies to: ace USB, dart BCON, dart USB and pulse USB + PixelColorFilter_Bayer_BG, //!< The Bayer filter has a BG/GR alignment to the pixels in the acquired images - Applies to: CameraLink and GigE + PixelColorFilter_Bayer_GB, //!< The Bayer filter has a GB/RG alignment to the pixels in the acquired images - Applies to: CameraLink and GigE + PixelColorFilter_Bayer_GR, //!< The Bayer filter has a GR/BG alignment to the pixels in the acquired images - Applies to: CameraLink and GigE + PixelColorFilter_Bayer_RG, //!< The Bayer filter has an RG/GB alignment to the pixels in the acquired images - Applies to: CameraLink and GigE + PixelColorFilter_None //!< The camera doesn't have a Bayer filter - Applies to: CameraLink, GigE, ace USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for PixelFormat + enum PixelFormatEnums + { + PixelFormat_BGR10Packed, //!< The pixel format is set to BGR 10 Packed - Applies to: CameraLink and GigE + PixelFormat_BGR12Packed, //!< The pixel format is set to BGR 12 Packed - Applies to: CameraLink and GigE + PixelFormat_BGR8, //!< The pixel format is set to BGR 8 - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BGR8Packed, //!< The pixel format is set to BGR 8 Packed - Applies to: CamEmu, CameraLink and GigE + PixelFormat_BGRA8Packed, //!< The pixel format is set to BGRA 8 Packed - Applies to: CamEmu, CameraLink and GigE + PixelFormat_BayerBG10, //!< The pixel format is set to Bayer BG 10 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerBG10p, //!< The pixel format is set to Bayer BG 10p - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerBG12, //!< The pixel format is set to Bayer BG 12 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerBG12Packed, //!< The pixel format is set to Bayer BG 12 Packed - Applies to: CameraLink and GigE + PixelFormat_BayerBG12p, //!< The pixel format is set to Bayer BG 12p - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerBG16, //!< The pixel format is set to Bayer BG 16 - Applies to: CameraLink and GigE + PixelFormat_BayerBG8, //!< The pixel format is set to Bayer BG 8 - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerGB10, //!< The pixel format is set to Bayer GB 10 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerGB10p, //!< The pixel format is set to Bayer GB 10p - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerGB12, //!< The pixel format is set to Bayer GB 12 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerGB12Packed, //!< The pixel format is set to Bayer GB 12 Packed - Applies to: CameraLink and GigE + PixelFormat_BayerGB12p, //!< The pixel format is set to Bayer GB 12p - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerGB16, //!< The pixel format is set to Bayer GB 16 - Applies to: CameraLink and GigE + PixelFormat_BayerGB8, //!< The pixel format is set to Bayer GB 8 - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerGR10, //!< The pixel format is set to Bayer GR 10 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerGR10p, //!< The pixel format is set to Bayer GR 10p - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerGR12, //!< The pixel format is set to Bayer GR 12 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerGR12Packed, //!< The pixel format is set to Bayer GR 12 Packed - Applies to: CameraLink and GigE + PixelFormat_BayerGR12p, //!< The pixel format is set to Bayer GR 12p - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerGR16, //!< The pixel format is set to Bayer GR 16 - Applies to: CameraLink and GigE + PixelFormat_BayerGR8, //!< The pixel format is set to Bayer GR 8 - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerRG10, //!< The pixel format is set to Bayer RG 10 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerRG10p, //!< The pixel format is set to Bayer RG 10p - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerRG12, //!< The pixel format is set to Bayer RG 12 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_BayerRG12Packed, //!< The pixel format is set to Bayer RG 12 Packed - Applies to: CameraLink and GigE + PixelFormat_BayerRG12p, //!< The pixel format is set to Bayer RG 12p - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_BayerRG16, //!< The pixel format is set to Bayer RG 16 - Applies to: CameraLink and GigE + PixelFormat_BayerRG8, //!< The pixel format is set to Bayer RG 8 - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_Confidence16, //!< Confidence 16-bit - Applies to: blaze + PixelFormat_Confidence8, //!< Confidence 8-bit - Applies to: blaze + PixelFormat_Coord3D_ABC32f, //!< 3D coordinate A-B-C 32-bit floating point - Applies to: blaze + PixelFormat_Coord3D_C16, //!< 3D coordinate C 16-bit - Applies to: blaze + PixelFormat_Mono10, //!< The pixel format is set to Mono 10 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_Mono10Packed, //!< Sets the pixel format to Mono 10 Packed - Applies to: CameraLink and GigE + PixelFormat_Mono10p, //!< The pixel format is set to Mono 10p - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_Mono12, //!< The pixel format is set to Mono 12 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_Mono12Packed, //!< The pixel format is set to Mono 12 Packed - Applies to: CameraLink and GigE + PixelFormat_Mono12p, //!< The pixel format is set to Mono 12p - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelFormat_Mono16, //!< The pixel format is set to Mono 16 - Applies to: CamEmu, CameraLink, GigE and blaze + PixelFormat_Mono8, //!< The pixel format is set to Mono 8 - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_Mono8Signed, //!< Sets the pixel format to Mono 8 Signed - Applies to: CameraLink and GigE + PixelFormat_RGB10Packed, //!< The pixel format is set to RGB 10 Packed - Applies to: CameraLink and GigE + PixelFormat_RGB10Planar, //!< The pixel format is set to RGB 10 Planar - Applies to: CameraLink and GigE + PixelFormat_RGB10V1Packed, //!< The pixel format is set to RGB 10V1 Packed - Applies to: CameraLink and GigE + PixelFormat_RGB10V2Packed, //!< The pixel format is set to RGB 10V2 Packed - Applies to: CameraLink and GigE + PixelFormat_RGB12Packed, //!< The pixel format is set to RGB 12 Packed - Applies to: CameraLink and GigE + PixelFormat_RGB12Planar, //!< The pixel format is set to RGB 12 Planar - Applies to: CameraLink and GigE + PixelFormat_RGB12V1Packed, //!< The pixel format is set to RGB 12 V1 Packed - Applies to: CameraLink and GigE + PixelFormat_RGB16Packed, //!< Sets the pixel format to RGB 16 Packed - Applies to: CamEmu + PixelFormat_RGB16Planar, //!< The pixel format is set to RGB 16 Planar - Applies to: CameraLink and GigE + PixelFormat_RGB8, //!< The pixel format is set to RGB 8 - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_RGB8Packed, //!< The pixel format is set to RGB 8 Packed - Applies to: CamEmu, CameraLink and GigE + PixelFormat_RGB8Planar, //!< The pixel format is set to RGB 8 Planar - Applies to: CameraLink and GigE + PixelFormat_RGBA8Packed, //!< The pixel format is set to RGBA 8 Packed - Applies to: CameraLink and GigE + PixelFormat_YCbCr422_8, //!< The pixel format is set to YCbCr 422 - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + PixelFormat_YUV411Packed, //!< Sets the pixel format to YUV 411 Packed - Applies to: CameraLink and GigE + PixelFormat_YUV422Packed, //!< The pixel format is set to YUV 422 Packed - Applies to: CameraLink and GigE + PixelFormat_YUV422_8, //!< The pixel format is set to YUV 4:2:2 8 bit packed - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + PixelFormat_YUV422_YUYV_Packed, //!< The pixel format is set to YUV 422 (YUYV) Packed - Applies to: CameraLink and GigE + PixelFormat_YUV444Packed //!< Sets the pixel format to YUV 444 Packed - Applies to: CameraLink and GigE + }; + + //! Valid values for PixelSize + enum PixelSizeEnums + { + PixelSize_Bpp1, //!< The pixel depth in the acquired images is 1 bit per pixel - Applies to: CameraLink, GigE and ace USB + PixelSize_Bpp10, //!< The pixel depth in the acquired images is 10 bits per pixel - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelSize_Bpp12, //!< The pixel depth in the acquired images is 12 bits per pixel - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + PixelSize_Bpp14, //!< The pixel depth in the acquired images is 14 bits per pixel - Applies to: CameraLink and GigE + PixelSize_Bpp16, //!< The pixel depth in the acquired images is 16 bits per pixel - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart USB and pulse USB + PixelSize_Bpp2, //!< The pixel depth in the acquired images is 2 bits per pixel - Applies to: CameraLink, GigE and ace USB + PixelSize_Bpp24, //!< The pixel depth in the acquired images is 24 bits per pixel - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart USB and pulse USB + PixelSize_Bpp32, //!< The pixel depth in the acquired images is 32 bits per pixel - Applies to: CamEmu, CameraLink and GigE + PixelSize_Bpp36, //!< The pixel depth in the acquired images is 36 bits per pixel - Applies to: CameraLink and GigE + PixelSize_Bpp4, //!< The pixel depth in the acquired images is 4 bits per pixel - Applies to: CameraLink, GigE and ace USB + PixelSize_Bpp48, //!< The pixel depth in the acquired images is 48 bits per pixel - Applies to: CamEmu, CameraLink and GigE + PixelSize_Bpp64, //!< The pixel depth in the acquired images is 64 bits per pixel - Applies to: CameraLink and GigE + PixelSize_Bpp8 //!< The pixel depth in the acquired images is 8 bits per pixel - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart USB and pulse USB + }; + + //! Valid values for PtpClockAccuracy + enum PtpClockAccuracyEnums + { + PtpClockAccuracy_GreaterThan10s, //!< The expected accuracy of the PTP device clock is greater than 10 seconds - Applies to: ace 2 GigE + PtpClockAccuracy_Unknown, //!< The expected accuracy of the PTP device clock is unknown - Applies to: ace 2 GigE + PtpClockAccuracy_Within100ms, //!< The expected accuracy of the PTP device clock is within 100 milliseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within100ns, //!< The expected accuracy of the PTP device clock is within 100 nanoseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within100us, //!< The expected accuracy of the PTP device clock is within 100 microseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within10ms, //!< The expected accuracy of the PTP device clock is within 10 milliseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within10s, //!< The expected accuracy of the PTP device clock is within 10 seconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within10us, //!< The expected accuracy of the PTP device clock is within 10 microseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within1ms, //!< The expected accuracy of the PTP device clock is within 1 millisecond - Applies to: ace 2 GigE + PtpClockAccuracy_Within1s, //!< The expected accuracy of the PTP device clock is within 1 second - Applies to: ace 2 GigE + PtpClockAccuracy_Within1us, //!< The expected accuracy of the PTP device clock is within 1 microsecond - Applies to: ace 2 GigE + PtpClockAccuracy_Within250ms, //!< The expected accuracy of the PTP device clock is within 250 milliseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within250ns, //!< The expected accuracy of the PTP device clock is within 250 nanoseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within250us, //!< The expected accuracy of the PTP device clock is within 250 microseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within25ms, //!< The expected accuracy of the PTP device clock is within 25 milliseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within25ns, //!< The expected accuracy of the PTP device clock is within 25 nanoseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within25us, //!< The expected accuracy of the PTP device clock is within 25 microseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within2p5ms, //!< The expected accuracy of the PTP device clock is within 2 5 milliseconds - Applies to: ace 2 GigE + PtpClockAccuracy_Within2p5us //!< The expected accuracy of the PTP device clock is within 2 5 microseconds - Applies to: ace 2 GigE + }; + + //! Valid values for PtpServoStatus + enum PtpServoStatusEnums + { + PtpServoStatus_Locked, //!< The clock servo is locked - Applies to: ace 2 GigE + PtpServoStatus_Unknown //!< The status of the clock servo is unknown - Applies to: ace 2 GigE + }; + + //! Valid values for PtpStatus + enum PtpStatusEnums + { + PtpStatus_Disabled, //!< The port is in the Disabled state - Applies to: ace 2 GigE and blaze + PtpStatus_Faulty, //!< The port is in the Faulty state - Applies to: ace 2 GigE and blaze + PtpStatus_Initializing, //!< The port is in the Initializing state - Applies to: ace 2 GigE and blaze + PtpStatus_Listening, //!< The port is in the Listening state - Applies to: ace 2 GigE and blaze + PtpStatus_Master, //!< The port is in the Master state - Applies to: ace 2 GigE and blaze + PtpStatus_Passive, //!< The port is in the Passive state - Applies to: ace 2 GigE and blaze + PtpStatus_PreMaster, //!< The port is in the PreMaster state - Applies to: ace 2 GigE and blaze + PtpStatus_Slave, //!< The port is in the Slave state - Applies to: ace 2 GigE and blaze + PtpStatus_Uncalibrated //!< The port is in the Uncalibrated state - Applies to: ace 2 GigE and blaze + }; + + //! Valid values for ROIZoneMode + enum ROIZoneModeEnums + { + ROIZoneMode_Off, //!< The currently selected ROI zone is disabled - Applies to: GigE and ace USB + ROIZoneMode_On //!< The currently selected ROI zone is enabled - Applies to: GigE and ace USB + }; + + //! Valid values for ROIZoneSelector + enum ROIZoneSelectorEnums + { + ROIZoneSelector_Zone0, //!< ROI zone 0 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone1, //!< ROI zone 1 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone2, //!< ROI zone 2 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone3, //!< ROI zone 3 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone4, //!< ROI zone 4 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone5, //!< ROI zone 5 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone6, //!< ROI zone 6 can be configured - Applies to: GigE and ace USB + ROIZoneSelector_Zone7 //!< ROI zone 7 can be configured - Applies to: GigE and ace USB + }; + + //! Valid values for RemoveParameterLimitSelector + enum RemoveParameterLimitSelectorEnums + { + RemoveParameterLimitSelector_AutoTargetValue, //!< The factory limits of the AutoTargetValue parameter can be removed - Applies to: ace USB + RemoveParameterLimitSelector_BlackLevel, //!< The factory limits of the BlackLevel parameter can be removed - Applies to: ace USB + RemoveParameterLimitSelector_ExposureOverhead, //!< The factory limits of the ExposureOverhead parameter can be removed - Applies to: ace USB + RemoveParameterLimitSelector_ExposureTime, //!< The factory limits of the Exposure Time parameter can be removed - Applies to: ace USB + RemoveParameterLimitSelector_Gain //!< The factory limits of the Gain parameter can be removed - Applies to: ace USB + }; + + //! Valid values for Scan3dCoordinateSelector + enum Scan3dCoordinateSelectorEnums + { + Scan3dCoordinateSelector_CoordinateA, //!< The first (X or Theta) coordinate - Applies to: blaze + Scan3dCoordinateSelector_CoordinateB, //!< The second (Y or Phi) coordinate - Applies to: blaze + Scan3dCoordinateSelector_CoordinateC //!< The third (Z or Rho) coordinate - Applies to: blaze + }; + + //! Valid values for Scan3dCoordinateSystem + enum Scan3dCoordinateSystemEnums + { + Scan3dCoordinateSystem_Cartesian //!< Default value - Applies to: blaze + }; + + //! Valid values for Scan3dCoordinateSystemReference + enum Scan3dCoordinateSystemReferenceEnums + { + Scan3dCoordinateSystemReference_Anchor //!< Default value - Applies to: blaze + }; + + //! Valid values for Scan3dDistanceUnit + enum Scan3dDistanceUnitEnums + { + Scan3dDistanceUnit_DeviceSpecific, //!< Distance values are in device-specific units - Applies to: blaze + Scan3dDistanceUnit_Millimeter //!< Distance values are in millimeter units (default) - Applies to: blaze + }; + + //! Valid values for Scan3dOutputMode + enum Scan3dOutputModeEnums + { + Scan3dOutputMode_CalibratedABC_Grid, //!< 3 Coordinates in grid organization - Applies to: blaze + Scan3dOutputMode_CalibratedC, //!< Calibrated 2 5D Depth map - Applies to: blaze + Scan3dOutputMode_UncalibratedC //!< Uncalibrated 2 5D Depth map - Applies to: blaze + }; + + //! Valid values for SensorBitDepth + enum SensorBitDepthEnums + { + SensorBitDepth_BitDepth10, //!< The sensor delivers 10-bit pixels - Applies to: CameraLink and GigE + SensorBitDepth_BitDepth12, //!< The sensor delivers 12-bit pixels - Applies to: CameraLink and GigE + SensorBitDepth_BitDepth14, //!< The sensor delivers 14-bit pixels - Applies to: CameraLink and GigE + SensorBitDepth_BitDepth16, //!< The sensor delivers 16-bit pixels - Applies to: CameraLink and GigE + SensorBitDepth_BitDepth8 //!< The sensor delivers 8-bit pixels - Applies to: CameraLink and GigE + }; + + //! Valid values for SensorDigitizationTaps + enum SensorDigitizationTapsEnums + { + SensorDigitizationTaps_Four, //!< Applies to: CameraLink and GigE + SensorDigitizationTaps_One, //!< Applies to: CameraLink and GigE + SensorDigitizationTaps_Three, //!< Applies to: CameraLink and GigE + SensorDigitizationTaps_Two //!< Applies to: CameraLink and GigE + }; + + //! Valid values for SensorReadoutMode + enum SensorReadoutModeEnums + { + SensorReadoutMode_Fast, //!< The camera operates in fast readout mode - Applies to: GigE and ace USB + SensorReadoutMode_Normal //!< The camera operates in normal readout mode - Applies to: GigE and ace USB + }; + + //! Valid values for SensorShutterMode + enum SensorShutterModeEnums + { + SensorShutterMode_Global, //!< The shutter opens and closes at the same time for all pixels - Applies to: dart BCON, dart USB and pulse USB + SensorShutterMode_GlobalReset, //!< The shutter opens at the same time for all rows but closes in a sequential manner - Applies to: dart BCON and dart USB + SensorShutterMode_Rolling //!< The shutter opens and closes sequentially for groups of rows - Applies to: ace 2 GigE, ace 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for SequenceAddressBitSelector + enum SequenceAddressBitSelectorEnums + { + SequenceAddressBitSelector_Bit0, //!< Bit 0 of the sequence set address can be controlled using an input line - Applies to: CameraLink and GigE + SequenceAddressBitSelector_Bit1, //!< Bit 1 of the sequence set address can be controlled using an input line - Applies to: CameraLink and GigE + SequenceAddressBitSelector_Bit2, //!< Bit 2 of the sequence set address can be controlled using an input line - Applies to: CameraLink and GigE + SequenceAddressBitSelector_Bit3 //!< Bit 3 of the sequence set address can be controlled using an input line - Applies to: CameraLink and GigE + }; + + //! Valid values for SequenceAddressBitSource + enum SequenceAddressBitSourceEnums + { + SequenceAddressBitSource_CC1, //!< The selected bit of the sequence set address can be set using the CC1 signal - Applies to: CameraLink and GigE + SequenceAddressBitSource_CC2, //!< The selected bit of the sequence set address can be set using the CC2 signal - Applies to: CameraLink and GigE + SequenceAddressBitSource_CC3, //!< The selected bit of the sequence set address can be set using the CC3 signal - Applies to: CameraLink and GigE + SequenceAddressBitSource_CC4, //!< The selected bit of the sequence set address can be set using the CC4 signal - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line1, //!< The selected bit of the sequence set address can be set using Line 1 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line2, //!< The selected bit of the sequence set address can be set using Line 2 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line3, //!< The selected bit of the sequence set address can be set using Line 3 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line4, //!< The selected bit of the sequence set address can be set using Line 4 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line5, //!< The selected bit of the sequence set address can be set using Line 5 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line6, //!< The selected bit of the sequence set address can be set using Line 6 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line7, //!< The selected bit of the sequence set address can be set using Line 7 - Applies to: CameraLink and GigE + SequenceAddressBitSource_Line8, //!< The selected bit of the sequence set address can be set using Line 8 - Applies to: CameraLink and GigE + SequenceAddressBitSource_VInput1, //!< Selects Virtual Input 1 as the source for the selected bit of the sequence set address - Applies to: CameraLink and GigE + SequenceAddressBitSource_VInput2, //!< Selects Virtual Input 2 as the source for the selected bit of the sequence set address - Applies to: CameraLink and GigE + SequenceAddressBitSource_VInput3, //!< Selects Virtual Input 3 as the source for the selected bit of the sequence set address - Applies to: CameraLink and GigE + SequenceAddressBitSource_VInput4, //!< Selects Virtual Input 4 as the source for the selected bit of the sequence set address - Applies to: CameraLink and GigE + SequenceAddressBitSource_VInputDecActive //!< Selects Virtual Input Decoder Active as the source for the selected bit of the sequence set address - Applies to: CameraLink and GigE + }; + + //! Valid values for SequenceAdvanceMode + enum SequenceAdvanceModeEnums + { + SequenceAdvanceMode_Auto, //!< The Auto sequence advance mode is selected - Applies to: CameraLink and GigE + SequenceAdvanceMode_Controlled, //!< The Controlled sequence advance mode is selected - Applies to: CameraLink and GigE + SequenceAdvanceMode_FreeSelection //!< The Free Selection sequence advance mode is selected - Applies to: CameraLink and GigE + }; + + //! Valid values for SequenceConfigurationMode + enum SequenceConfigurationModeEnums + { + SequenceConfigurationMode_Off, //!< The sequencer can't be configured - Applies to: GigE + SequenceConfigurationMode_On //!< The sequencer can be configured - Applies to: GigE + }; + + //! Valid values for SequenceControlSelector + enum SequenceControlSelectorEnums + { + SequenceControlSelector_Advance, //!< The sequence set advance can be configured - Applies to: CameraLink and GigE + SequenceControlSelector_Restart //!< The sequence set restart can be configured - Applies to: CameraLink and GigE + }; + + //! Valid values for SequenceControlSource + enum SequenceControlSourceEnums + { + SequenceControlSource_AlwaysActive, //!< Sequence set advance is automatic The sequence repeat starts with sequence set index number 1 - Applies to: CameraLink and GigE + SequenceControlSource_CC1, //!< Sequence restart or sequence set advance are controlled using the CC1 signal - Applies to: CameraLink and GigE + SequenceControlSource_CC2, //!< Sequence restart or sequence set advance are controlled using the CC2 signal - Applies to: CameraLink and GigE + SequenceControlSource_CC3, //!< Sequence restart or sequence set advance are controlled using the CC3 signal - Applies to: CameraLink and GigE + SequenceControlSource_CC4, //!< Sequence restart or sequence set advance are controlled using the CC4 signal - Applies to: CameraLink and GigE + SequenceControlSource_Disabled, //!< Sequence set advance will be controlled using the Async Advance command - Applies to: CameraLink and GigE + SequenceControlSource_Line1, //!< Sequence restart or sequence set advance are controlled using Line 1 - Applies to: CameraLink and GigE + SequenceControlSource_Line2, //!< Sequence restart or sequence set advance are controlled using Line 2 - Applies to: CameraLink and GigE + SequenceControlSource_Line3, //!< Sequence restart or sequence set advance are controlled using Line 3 - Applies to: CameraLink and GigE + SequenceControlSource_Line4, //!< Sequence restart or sequence set advance are controlled using Line 4 - Applies to: CameraLink and GigE + SequenceControlSource_Line5, //!< Sequence restart or sequence set advance are controlled using Line 5 - Applies to: CameraLink and GigE + SequenceControlSource_Line6, //!< Sequence restart or sequence set advance are controlled using Line 6 - Applies to: CameraLink and GigE + SequenceControlSource_Line7, //!< Sequence restart or sequence set advance are controlled using Line 7 - Applies to: CameraLink and GigE + SequenceControlSource_Line8, //!< Sequence restart or sequence set advance are controlled using Line 8 - Applies to: CameraLink and GigE + SequenceControlSource_VInput1, //!< The source for sequence restart or sequence set advance is Virtual Input 1 - Applies to: CameraLink and GigE + SequenceControlSource_VInput2, //!< The source for sequence restart or sequence set advance is Virtual Input 2 - Applies to: CameraLink and GigE + SequenceControlSource_VInput3, //!< The source for sequence restart or sequence set advance is Virtual Input 3 - Applies to: CameraLink and GigE + SequenceControlSource_VInput4, //!< The source for sequence restart or sequence set advance is Virtual Input 4 - Applies to: CameraLink and GigE + SequenceControlSource_VInputDecActive //!< The source for sequence restart or sequence set advance is Virtual Input Decoder Active - Applies to: CameraLink and GigE + }; + + //! Valid values for SequencerConfigurationMode + enum SequencerConfigurationModeEnums + { + SequencerConfigurationMode_Off, //!< The sequencer can't be configured - Applies to: ace USB + SequencerConfigurationMode_On //!< The sequencer can be configured - Applies to: ace USB + }; + + //! Valid values for SequencerMode + enum SequencerModeEnums + { + SequencerMode_Off, //!< Image acquisitions can't be controlled by the sequencer - Applies to: ace USB + SequencerMode_On //!< Image acquisitions will be controlled by the sequencer - Applies to: ace USB + }; + + //! Valid values for SequencerTriggerActivation + enum SequencerTriggerActivationEnums + { + SequencerTriggerActivation_AnyEdge, //!< The sequence set will advance on the falling or rising edge of the source signal - Applies to: ace USB + SequencerTriggerActivation_FallingEdge, //!< The sequence set will advance on the falling edge of the source signal - Applies to: ace USB + SequencerTriggerActivation_LevelHigh, //!< The sequence set will advance when the source signal is high - Applies to: ace USB + SequencerTriggerActivation_LevelLow, //!< The sequence set will advance when the source signal is low - Applies to: ace USB + SequencerTriggerActivation_RisingEdge //!< The sequence set will advance on the rising edge of the source signal - Applies to: ace USB + }; + + //! Valid values for SequencerTriggerSource + enum SequencerTriggerSourceEnums + { + SequencerTriggerSource_Counter1End, //!< Counter 1 End is selected as the trigger source for sequencer set advance - Applies to: ace USB + SequencerTriggerSource_Counter2End, //!< Sequencer set advance is controlled using Counter 2 End - Applies to: ace USB + SequencerTriggerSource_Counter3End, //!< Counter 3 End is selected as the trigger source for sequencer set advance - Applies to: ace USB + SequencerTriggerSource_FrameEnd, //!< Frame End is selected as the trigger source for sequencer set advance - Applies to: ace USB + SequencerTriggerSource_FrameStart, //!< Sequencer set advance is controlled using Frame Start signals - Applies to: ace USB + SequencerTriggerSource_Line1, //!< Sequencer set advance is controlled using Line 1 - Applies to: ace USB + SequencerTriggerSource_Line2, //!< Line 2 is selected as the trigger source for sequencer set advance - Applies to: ace USB + SequencerTriggerSource_Line3, //!< Sequencer set advance is controlled using Line 3 - Applies to: ace USB + SequencerTriggerSource_Line4, //!< Sequencer set advance is controlled using Line 4 - Applies to: ace USB + SequencerTriggerSource_SoftwareSignal1, //!< Sequencer set advance is controlled using software signal 1 - Applies to: ace USB + SequencerTriggerSource_SoftwareSignal2, //!< Sequencer set advance is controlled using software signal 2 - Applies to: ace USB + SequencerTriggerSource_SoftwareSignal3 //!< Sequencer set advance is controlled using software signal 3 - Applies to: ace USB + }; + + //! Valid values for ShadingSelector + enum ShadingSelectorEnums + { + ShadingSelector_GainShading, //!< Gain Shading correction is selected - Applies to: CameraLink and GigE + ShadingSelector_OffsetShading //!< Offset Shading correction is selected - Applies to: CameraLink and GigE + }; + + //! Valid values for ShadingSetCreate + enum ShadingSetCreateEnums + { + ShadingSetCreate_Off, //!< Applies to: CameraLink and GigE + ShadingSetCreate_Once //!< Applies to: CameraLink and GigE + }; + + //! Valid values for ShadingSetDefaultSelector + enum ShadingSetDefaultSelectorEnums + { + ShadingSetDefaultSelector_DefaultShadingSet, //!< The default shading set is selected as the bootup shading set - Applies to: CameraLink and GigE + ShadingSetDefaultSelector_UserShadingSet1, //!< User Shading Set 1 is selected as the bootup shading set - Applies to: CameraLink and GigE + ShadingSetDefaultSelector_UserShadingSet2 //!< User Shading Set 2 is selected as the bootup shading set - Applies to: CameraLink and GigE + }; + + //! Valid values for ShadingSetSelector + enum ShadingSetSelectorEnums + { + ShadingSetSelector_DefaultShadingSet, //!< The default shading set can be loaded using the Activate command - Applies to: CameraLink and GigE + ShadingSetSelector_UserShadingSet1, //!< User Shading Set 1 can be loaded using the Activate command - Applies to: CameraLink and GigE + ShadingSetSelector_UserShadingSet2 //!< User Shading Set 2 can be loaded using the Activate command - Applies to: CameraLink and GigE + }; + + //! Valid values for ShadingStatus + enum ShadingStatusEnums + { + ShadingStatus_ActivateError, //!< The selected shading set could not be loaded - Applies to: CameraLink and GigE + ShadingStatus_CreateError, //!< A problem occurred while creating a shading set - Applies to: CameraLink and GigE + ShadingStatus_NoError, //!< The last operation related to shading correction was successful - Applies to: CameraLink and GigE + ShadingStatus_StartupSetError //!< A problem with the startup shading set occurred - Applies to: CameraLink and GigE + }; + + //! Valid values for ShaftEncoderModuleCounterMode + enum ShaftEncoderModuleCounterModeEnums + { + ShaftEncoderModuleCounterMode_FollowDirection, //!< The tick counter increases for forward ticks and decreases for reverse ticks - Applies to: CameraLink and GigE + ShaftEncoderModuleCounterMode_IgnoreDirection //!< The tick counter increases for forward ticks and for reverse ticks - Applies to: CameraLink and GigE + }; + + //! Valid values for ShaftEncoderModuleLineSelector + enum ShaftEncoderModuleLineSelectorEnums + { + ShaftEncoderModuleLineSelector_PhaseA, //!< Phase A of the shaft encoder is selected as input for the shaft encoder module - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSelector_PhaseB //!< Phase B of the shaft encoder is selected as input for the shaft encoder module - Applies to: CameraLink and GigE + }; + + //! Valid values for ShaftEncoderModuleLineSource + enum ShaftEncoderModuleLineSourceEnums + { + ShaftEncoderModuleLineSource_CC1, //!< The source signal for the shaft encoder module is set to CC1 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_CC2, //!< The source signal for the shaft encoder module is set to CC2 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_CC3, //!< The source signal for the shaft encoder module is set to CC3 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_CC4, //!< The source signal for the shaft encoder module is set to CC4 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line1, //!< The source signal for the shaft encoder module is set to input line 1 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line2, //!< The source signal for the shaft encoder module is set to input line 2 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line3, //!< The source signal for the shaft encoder module is set to input line 3 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line4, //!< The source signal for the shaft encoder module is set to input line 4 - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line5, //!< Selects input line 5 as signal source for the shaft encoder module - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line6, //!< Selects input line 6 as signal source for the shaft encoder module - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line7, //!< Selects input line 7 as signal source for the shaft encoder module - Applies to: CameraLink and GigE + ShaftEncoderModuleLineSource_Line8 //!< Selects input line 8 as signal source for the shaft encoder module - Applies to: CameraLink and GigE + }; + + //! Valid values for ShaftEncoderModuleMode + enum ShaftEncoderModuleModeEnums + { + ShaftEncoderModuleMode_AnyDirection, //!< The shaft encoder module outputs trigger signals for forward and reverse ticks, provided the reverse counter is neither increasing nor decreasing - Applies to: CameraLink and GigE + ShaftEncoderModuleMode_ForwardOnly //!< The shaft encoder module outputs trigger signals for forward ticks only, provided the reverse counter is neither increasing nor decreasing - Applies to: CameraLink and GigE + }; + + //! Valid values for ShutterMode + enum ShutterModeEnums + { + ShutterMode_Global, //!< The shutter opens and closes at the same time for all pixels - Applies to: CameraLink, GigE and ace USB + ShutterMode_GlobalResetRelease, //!< The shutter opens at the same time for all rows but closes in a sequential manner - Applies to: CameraLink, GigE and ace USB + ShutterMode_Rolling //!< The shutter opens and closes sequentially for groups of rows - Applies to: CameraLink, GigE and ace USB + }; + + //! Valid values for SoftwareSignalSelector + enum SoftwareSignalSelectorEnums + { + SoftwareSignalSelector_SoftwareSignal1, //!< Software signal 1 can be executed - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + SoftwareSignalSelector_SoftwareSignal2, //!< Software signal 2 can be executed - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + SoftwareSignalSelector_SoftwareSignal3, //!< Software signal 3 can be executed - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + SoftwareSignalSelector_SoftwareSignal4 //!< Software signal 4 can be controlled - Applies to: ace USB + }; + + //! Valid values for SyncUserOutputSelector + enum SyncUserOutputSelectorEnums + { + SyncUserOutputSelector_SyncUserOutput0, //!< User-settable synchronous output signal 0 can be configured - Applies to: GigE + SyncUserOutputSelector_SyncUserOutput1, //!< User-settable synchronous output signal 1 can be configured - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput2, //!< User-settable synchronous output signal 2 can be configured - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput3, //!< User-settable synchronous output signal 3 can be configured - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput4, //!< User-settable synchronous output signal 4 can be configured - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput5, //!< Selects user settable synchronous output signal 5 for configuration - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput6, //!< Selects user settable synchronous output signal 6 for configuration - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput7, //!< Selects user settable synchronous output signal 7 for configuration - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutput8, //!< Selects user settable synchronous output signal 8 for configuration - Applies to: CameraLink and GigE + SyncUserOutputSelector_SyncUserOutputCC1, //!< Selects user settable synchronous output signal CC1 for configuration - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputCC2, //!< Selects user settable synchronous output signal CC2 for configuration - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputCC3, //!< Selects user settable synchronous output signal CC3 for configuration - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputCC4, //!< Selects user settable synchronous output signal CC4 for configuration - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputClSpare, //!< User-settable synchronous output signal CL Spare can be configured - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputLine1, //!< User-settable synchronous output signal Line 1 can be configured - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputLine2, //!< User-settable synchronous output signal Line 2 can be configured - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputLine3, //!< User-settable synchronous output signal Line 3 can be configured - Applies to: CameraLink + SyncUserOutputSelector_SyncUserOutputLine4 //!< User-settable synchronous output signal Line 4 can be configured - Applies to: CameraLink + }; + + //! Valid values for TemperatureSelector + enum TemperatureSelectorEnums + { + TemperatureSelector_Case, //!< The temperature is measured on the case - Applies to: CameraLink and GigE + TemperatureSelector_Coreboard, //!< The temperature is measured on the core board - Applies to: CameraLink and GigE + TemperatureSelector_Framegrabberboard, //!< The temperature is measured on the frame grabber board - Applies to: CameraLink and GigE + TemperatureSelector_Sensorboard //!< The temperature is measured on the sensor board - Applies to: CameraLink and GigE + }; + + //! Valid values for TemperatureState + enum TemperatureStateEnums + { + TemperatureState_Critical, //!< The temperature is close to or at the allowed maximum Provide cooling - Applies to: CameraLink, GigE, ace USB and blaze + TemperatureState_Error, //!< The temperature is above the allowed maximum Provide cooling immediately - Applies to: CameraLink, GigE, ace USB and blaze + TemperatureState_Ok //!< The temperature is within the normal operating temperature range - Applies to: CameraLink, GigE, ace USB and blaze + }; + + //! Valid values for TestImageSelector + enum TestImageSelectorEnums + { + TestImageSelector_Black, //!< Sets the camera to generate and transmit black test images - Applies to: CameraLink and GigE + TestImageSelector_ColorBar, //!< Sets the camera to generate and transmit test images with a color bar pattern - Applies to: CameraLink and GigE + TestImageSelector_DeviceSpecific, //!< Sets the camera to generate and transmit test images with a camera specific pattern - Applies to: CameraLink and GigE + TestImageSelector_FixedDiagonalGrayGradient_8Bit, //!< Sets the camera to generate and transmit test images with an 8 bit fixed diagonal gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_FrameCounter, //!< Sets the camera to generate and transmit test images with a frame counter pattern - Applies to: CameraLink and GigE + TestImageSelector_GreyHorizontalRamp, //!< Sets the camera to generate and transmit test images with a fixed horizontal gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_GreyHorizontalRampMoving, //!< Sets the camera to generate and transmit test images with a moving horizontal gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_GreyVerticalRamp, //!< Sets the camera to generate and transmit test images with a fixed vertical gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_GreyVerticalRampMoving, //!< Sets the camera to generate and transmit test images with a moving vertical gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_HorzontalLineMoving, //!< Sets the camera to generate and transmit test images with a moving horizontal line pattern - Applies to: CameraLink and GigE + TestImageSelector_MovingDiagonalColorGradient, //!< Sets the camera to generate and transmit test images with a moving diagonal color gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_MovingDiagonalGrayGradientFeatureTest_12Bit, //!< Sets the camera to generate and transmit test images with a 12 bit moving diagonal gray gradient feature test pattern - Applies to: CameraLink and GigE + TestImageSelector_MovingDiagonalGrayGradientFeatureTest_8Bit, //!< Sets the camera to generate and transmit test images with an 8 bit moving diagonal gray gradient feature test pattern - Applies to: CameraLink and GigE + TestImageSelector_MovingDiagonalGrayGradient_12Bit, //!< Sets the camera to generate and transmit test images with a 12 bit moving diagonal gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_MovingDiagonalGrayGradient_8Bit, //!< Sets the camera to generate and transmit test images with an 8 bit moving diagonal gray gradient pattern - Applies to: CameraLink and GigE + TestImageSelector_Off, //!< The camera doesn't display a test image - Applies to: CamEmu, CameraLink, GigE and ace USB + TestImageSelector_Testimage1, //!< The camera generates a test image with the test image 1 pattern - Applies to: CamEmu, CameraLink, GigE and ace USB + TestImageSelector_Testimage2, //!< The camera generates a test image with the test image 2 pattern - Applies to: CamEmu, CameraLink, GigE and ace USB + TestImageSelector_Testimage3, //!< The camera generates a test image with the test image 3 pattern - Applies to: CameraLink, GigE and ace USB + TestImageSelector_Testimage4, //!< The camera generates a test image with the test image 4 pattern - Applies to: CameraLink, GigE and ace USB + TestImageSelector_Testimage5, //!< The camera generates a test image with the test image 5 pattern - Applies to: CameraLink, GigE and ace USB + TestImageSelector_Testimage6, //!< The camera generates a test image with the test image 6 pattern - Applies to: CameraLink, GigE and ace USB + TestImageSelector_Testimage7, //!< The camera generates a test image with the test image 7 pattern - Applies to: CameraLink and GigE + TestImageSelector_VerticalLineMoving, //!< Sets the camera to generate and transmit test images with a moving vertical line pattern - Applies to: CameraLink and GigE + TestImageSelector_White //!< Sets the camera to generate and transmit white test images - Applies to: CameraLink and GigE + }; + + //! Valid values for TestPattern + enum TestPatternEnums + { + TestPattern_Black, //!< The camera generates a black test pattern - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TestPattern_ColorDiagonalSawtooth8, //!< The camera generates a test image with a color diagonal sawtooth pattern - Applies to: dart BCON, dart USB and pulse USB + TestPattern_GreyDiagonalSawtooth8, //!< The camera generates a test image with a gray diagonal sawtooth pattern - Applies to: dart BCON, dart USB and pulse USB + TestPattern_Off, //!< No test pattern is generated - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + TestPattern_Testimage1, //!< The camera generates a test image with the test image 1 pattern - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TestPattern_Testimage2, //!< The camera generates a test image with the test image 2 pattern - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TestPattern_Testimage3, //!< The camera generates a test image with the test image 3 pattern - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TestPattern_Testimage6, //!< The camera generates a test image with the test image 6 pattern - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TestPattern_White //!< The camera generates a white test pattern - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for TimerSelector + enum TimerSelectorEnums + { + TimerSelector_Timer1, //!< Timer 1 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TimerSelector_Timer2, //!< Timer 2 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerSelector_Timer3, //!< Timer 3 can be configured - Applies to: CameraLink and GigE + TimerSelector_Timer4 //!< Timer 4 can be configured - Applies to: CameraLink and GigE + }; + + //! Valid values for TimerSequenceEntrySelector + enum TimerSequenceEntrySelectorEnums + { + TimerSequenceEntrySelector_Entry1, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry10, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry11, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry12, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry13, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry14, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry15, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry16, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry2, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry3, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry4, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry5, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry6, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry7, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry8, //!< Applies to: CameraLink and GigE + TimerSequenceEntrySelector_Entry9 //!< Applies to: CameraLink and GigE + }; + + //! Valid values for TimerSequenceTimerSelector + enum TimerSequenceTimerSelectorEnums + { + TimerSequenceTimerSelector_Timer1, //!< Applies to: CameraLink and GigE + TimerSequenceTimerSelector_Timer2, //!< Applies to: CameraLink and GigE + TimerSequenceTimerSelector_Timer3, //!< Applies to: CameraLink and GigE + TimerSequenceTimerSelector_Timer4 //!< Applies to: CameraLink and GigE + }; + + //! Valid values for TimerStatus + enum TimerStatusEnums + { + TimerStatus_TimerActive, //!< The timer has been started - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerStatus_TimerIdle, //!< The timer is idle - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerStatus_TimerTriggerWait //!< The timer is waiting to be started - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for TimerTriggerActivation + enum TimerTriggerActivationEnums + { + TimerTriggerActivation_AnyEdge, //!< Trigger on the rising or falling edge of the selected source - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerActivation_FallingEdge, //!< The timer will start at a falling edge signal change - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerActivation_LevelHigh, //!< Trigger is active as long as the selected source signal is on a logic high level - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerActivation_LevelLow, //!< Trigger is active as long as the selected source signal is on a logic low level - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerActivation_RisingEdge //!< The timer will start at a rising edge signal change - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for TimerTriggerSource + enum TimerTriggerSourceEnums + { + TimerTriggerSource_AcquisitionActive, //!< The selected timer can be started by an Acquisition Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Action1, //!< The selected timer can be started by an action signal that is defined by action signal 1 - Applies to: ace 2 GigE + TimerTriggerSource_Action2, //!< The selected timer can be started by an action signal that is defined by action signal 2 - Applies to: ace 2 GigE + TimerTriggerSource_Counter1Active, //!< The selected timer can be started by a Counter 1 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Counter1End, //!< The selected timer can be started by a Counter 1 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Counter1Start, //!< The selected timer can be started by a Counter 1 Start signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Counter2Active, //!< The selected timer can be started by a Counter 2 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Counter2End, //!< The selected timer can be started by a Counter 2 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Counter2Start, //!< The selected timer can be started by a Counter 2 Start signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_CxpTrigger0, //!< The selected timer can be started by a CXP Trigger 0 signal - Applies to: boost CoaXPress + TimerTriggerSource_CxpTrigger1, //!< The selected timer can be started by a CXP Trigger 1 signal - Applies to: boost CoaXPress + TimerTriggerSource_ExposureActive, //!< The selected timer can be started by an Exposure Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_ExposureStart, //!< The selected timer can be started by an Exposure Start signal - Applies to: CameraLink, GigE and ace USB + TimerTriggerSource_ExposureTriggerWait, //!< The selected timer can be started by an Exposure Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_FlashWindowStart, //!< The selected timer can be started by a Flash Window Start signal - Applies to: GigE and ace USB + TimerTriggerSource_FrameBurstActive, //!< The selected timer can be started by a Frame Burst Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_FrameBurstTriggerWait, //!< The selected timer can be started by a Frame Burst Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_FrameTriggerWait, //!< The selected timer can be started by a Frame Trigger Wait signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Line1, //!< The selected timer can be started by a Line 1 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Line2, //!< The selected timer can be started by a Line 2 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Line3, //!< The selected timer can be started by a Line 3 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Line4, //!< The selected timer can be started by a Line 4 signal - Applies to: dart 2 USB + TimerTriggerSource_Off, //!< The selected timer is disabled and can't be started - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_PeriodicSignal1, //!< The selected timer can be started by a Periodic Signal 1 signal - Applies to: ace 2 GigE + TimerTriggerSource_SoftwareSignal1, //!< The selected timer can be started by a Software Signal 1 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_SoftwareSignal2, //!< The selected timer can be started by a Software Signal 2 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_SoftwareSignal3, //!< The selected timer can be started by a Software Signal 3 signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Timer1Active, //!< The selected timer can be started by a Timer 1 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Timer1End, //!< The selected timer can be started by a Timer 1 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Timer2Active, //!< The selected timer can be started by a Timer 2 Active signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TimerTriggerSource_Timer2End //!< The selected timer can be started by a Timer 2 End signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for TonalRangeAuto + enum TonalRangeAutoEnums + { + TonalRangeAuto_Off, //!< Automatic tonal range adjustment is disabled - Applies to: GigE and ace USB + TonalRangeAuto_Once //!< Automatic tonal range adjustment is enabled - Applies to: GigE and ace USB + }; + + //! Valid values for TonalRangeEnable + enum TonalRangeEnableEnums + { + TonalRangeEnable_Off, //!< Tonal range adjustment is disabled - Applies to: GigE and ace USB + TonalRangeEnable_On //!< Tonal range adjustment is enabled - Applies to: GigE and ace USB + }; + + //! Valid values for TonalRangeSelector + enum TonalRangeSelectorEnums + { + TonalRangeSelector_Blue, //!< Only the blue pixel values are used for tonal range adjustments - Applies to: GigE and ace USB + TonalRangeSelector_Green, //!< Only the green pixel values are used for tonal range adjustments - Applies to: GigE and ace USB + TonalRangeSelector_Red, //!< Only the red pixel values are used for tonal range adjustments - Applies to: GigE and ace USB + TonalRangeSelector_Sum //!< The summed RGB pixel values are used for tonal range adjustments - Applies to: GigE and ace USB + }; + + //! Valid values for TriggerActivation + enum TriggerActivationEnums + { + TriggerActivation_AnyEdge, //!< The selected trigger is activated by the falling or rising edge of the source signal - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerActivation_FallingEdge, //!< The selected trigger is activated by the falling edge of the source signal - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + TriggerActivation_LevelHigh, //!< The selected trigger is activated when the source signal is high - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerActivation_LevelLow, //!< The selected trigger is activated when the source signal is low - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerActivation_RisingEdge //!< The selected trigger is activated by the rising edge of the source signal - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for TriggerControlImplementation + enum TriggerControlImplementationEnums + { + TriggerControlImplementation_Legacy, //!< The image acquisition control mode is set to Legacy - Applies to: CameraLink and GigE + TriggerControlImplementation_Standard //!< The image acquisition control mode is set to Standard - Applies to: CameraLink and GigE + }; + + //! Valid values for TriggerDelaySource + enum TriggerDelaySourceEnums + { + TriggerDelaySource_LineTrigger, //!< The trigger delay is expressed as a number of line triggers - Applies to: CameraLink and GigE + TriggerDelaySource_Time_us //!< The trigger delay is expressed as a time interval in microseconds - Applies to: CameraLink and GigE + }; + + //! Valid values for TriggerMode + enum TriggerModeEnums + { + TriggerMode_Off, //!< The currently selected trigger is turned off - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + TriggerMode_On //!< The currently selected trigger is turned on - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for TriggerSelector + enum TriggerSelectorEnums + { + TriggerSelector_AcquisitionActive, //!< Selects the acquisition active trigger for configuration - Applies to: CameraLink and GigE + TriggerSelector_AcquisitionEnd, //!< Selects the acquisition end trigger for configuration - Applies to: CameraLink and GigE + TriggerSelector_AcquisitionStart, //!< The Acquisition Start trigger can be configured - Applies to: CamEmu, CameraLink and GigE + TriggerSelector_ExposureActive, //!< The Exposure Active trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_ExposureEnd, //!< The Exposure End trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_ExposureStart, //!< The Exposure Start trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_FrameActive, //!< The Frame Active trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_FrameBurstActive, //!< The Frame Burst Active trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_FrameBurstEnd, //!< The Frame Burst End trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_FrameBurstStart, //!< The Frame Burst Start trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerSelector_FrameEnd, //!< The Frame End trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSelector_FrameStart, //!< The Frame Start trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + TriggerSelector_LineStart //!< The Line Start trigger can be configured - Applies to: CameraLink and GigE + }; + + //! Valid values for TriggerSource + enum TriggerSourceEnums + { + TriggerSource_Action1, //!< The source signal for the selected trigger is set to action command signal 1 - Applies to: CameraLink, GigE and ace 2 GigE + TriggerSource_Action2, //!< The source signal for the selected trigger is set to action command signal 2 - Applies to: CameraLink, GigE and ace 2 GigE + TriggerSource_Action3, //!< The source signal for the selected trigger is set to action command signal 3 - Applies to: CameraLink and GigE + TriggerSource_Action4, //!< The source signal for the selected trigger is set to action command signal 4 - Applies to: CameraLink and GigE + TriggerSource_CC1, //!< The source signal for the selected trigger is set to CC1 - Applies to: CameraLink and GigE + TriggerSource_CC2, //!< The source signal for the selected trigger is set to CC2 - Applies to: CameraLink and GigE + TriggerSource_CC3, //!< The source signal for the selected trigger is set to CC3 - Applies to: CameraLink and GigE + TriggerSource_CC4, //!< The source signal for the selected trigger is set to CC4 - Applies to: CameraLink and GigE + TriggerSource_Counter1Active, //!< The Counter 1 Active trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Counter1End, //!< The Counter 1 End trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Counter1Start, //!< The Counter 1 Start trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Counter2Active, //!< The Counter 2 Active trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Counter2End, //!< The Counter 2 End trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Counter2Start, //!< The Counter 2 Start trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_CxpTrigger0, //!< The CXP Trigger 0 trigger can be configured - Applies to: boost CoaXPress + TriggerSource_CxpTrigger1, //!< The CXP Trigger 1 trigger can be configured - Applies to: boost CoaXPress + TriggerSource_FrequencyConverter, //!< The source signal for the selected trigger is set to the frequency converter module - Applies to: CameraLink and GigE + TriggerSource_Line1, //!< The source signal for the selected trigger is set to Line 1 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + TriggerSource_Line2, //!< The source signal for the selected trigger is set to Line 2 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB and dart USB + TriggerSource_Line3, //!< The source signal for the selected trigger is set to Line 3 - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB and dart BCON + TriggerSource_Line4, //!< The source signal for the selected trigger is set to Line 4 - Applies to: CameraLink, GigE, ace USB and dart 2 USB + TriggerSource_Line5, //!< The source signal for the selected trigger is set to Line 5 - Applies to: CameraLink and GigE + TriggerSource_Line6, //!< The source signal for the selected trigger is set to Line 6 - Applies to: CameraLink and GigE + TriggerSource_Line7, //!< The source signal for the selected trigger is set to Line 7 - Applies to: CameraLink and GigE + TriggerSource_Line8, //!< The source signal for the selected trigger is set to Line 8 - Applies to: CameraLink and GigE + TriggerSource_PeriodicSignal1, //!< The source signal for the selected trigger is set to Periodic Signal 1 - Applies to: ace 2 GigE + TriggerSource_ShaftEncoderModuleOut, //!< The source signal for the selected trigger is set to the shaft encoder module - Applies to: CameraLink and GigE + TriggerSource_Software, //!< The source signal for the selected trigger is set to software triggering - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + TriggerSource_SoftwareSignal1, //!< The source signal for the selected trigger is set to software signal 1 - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerSource_SoftwareSignal2, //!< The source signal for the selected trigger is set to software signal 2 - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerSource_SoftwareSignal3, //!< The source signal for the selected trigger is set to software signal 3 - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + TriggerSource_Timer1Active, //!< The Timer 1 Active trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Timer1End, //!< The Timer 1 End trigger can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Timer1Start, //!< Sets the signal source for the selected trigger to timer 1 start - Applies to: CameraLink and GigE + TriggerSource_Timer2Active, //!< The Timer 2 Active trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_Timer2End, //!< The Timer 2 End trigger can be configured - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + TriggerSource_UserOutput1, //!< Sets the signal source for the selected trigger to user output 1 - Applies to: CameraLink and GigE + TriggerSource_UserOutput2, //!< Sets the signal source for the selected trigger to user output 2 - Applies to: CameraLink and GigE + TriggerSource_VInput1, //!< Sets the signal source for the selected trigger to Virtual Input 1 - Applies to: CameraLink and GigE + TriggerSource_VInput2, //!< Sets the signal source for the selected trigger to Virtual Input 2 - Applies to: CameraLink and GigE + TriggerSource_VInput3, //!< Sets the signal source for the selected trigger to Virtual Input 3 - Applies to: CameraLink and GigE + TriggerSource_VInput4, //!< Sets the signal source for the selected trigger to Virtual Input 4 - Applies to: CameraLink and GigE + TriggerSource_VInputDecActive //!< Sets the signal source for the selected trigger to Virtual Input Decoder Active - Applies to: CameraLink and GigE + }; + + //! Valid values for UserDefinedValueSelector + enum UserDefinedValueSelectorEnums + { + UserDefinedValueSelector_Value1, //!< The user-defined value 1 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + UserDefinedValueSelector_Value2, //!< The user-defined value 2 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + UserDefinedValueSelector_Value3, //!< The user-defined value 3 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + UserDefinedValueSelector_Value4, //!< The user-defined value 4 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + UserDefinedValueSelector_Value5 //!< The user-defined value 5 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + }; + + //! Valid values for UserOutputSelector + enum UserOutputSelectorEnums + { + UserOutputSelector_UserOutput0, //!< The user-settable output signal 0 can be configured - Applies to: GigE and ace USB + UserOutputSelector_UserOutput1, //!< The user-settable output signal 1 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + UserOutputSelector_UserOutput2, //!< The user-settable output signal 2 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + UserOutputSelector_UserOutput3, //!< The user-settable output signal 3 can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + UserOutputSelector_UserOutput4, //!< The user-settable output signal 4 can be configured - Applies to: CameraLink, GigE and dart 2 USB + UserOutputSelector_UserOutput5, //!< Selects user settable output signal 5 for configuration - Applies to: CameraLink and GigE + UserOutputSelector_UserOutput6, //!< Selects user settable output signal 6 for configuration - Applies to: CameraLink and GigE + UserOutputSelector_UserOutput7, //!< Selects user settable output signal 7 for configuration - Applies to: CameraLink and GigE + UserOutputSelector_UserOutput8, //!< Selects user settable output signal 8 for configuration - Applies to: CameraLink and GigE + UserOutputSelector_UserOutputCC1, //!< Selects user settable output signal CC1 for configuration - Applies to: CameraLink + UserOutputSelector_UserOutputCC2, //!< Selects user settable output signal CC2 for configuration - Applies to: CameraLink + UserOutputSelector_UserOutputCC3, //!< Selects user settable output signal CC3 for configuration - Applies to: CameraLink + UserOutputSelector_UserOutputCC4, //!< Selects user settable output signal CC4 for configuration - Applies to: CameraLink + UserOutputSelector_UserOutputClSpare, //!< The user-settable output signal CL Spare can be configured - Applies to: CameraLink + UserOutputSelector_UserOutputLine1, //!< User-settable output signal Line 1 can be configured - Applies to: CameraLink + UserOutputSelector_UserOutputLine2, //!< User-settable output signal Line 2 can be configured - Applies to: CameraLink + UserOutputSelector_UserOutputLine3, //!< User-settable output signal Line 3 can be configured - Applies to: CameraLink + UserOutputSelector_UserOutputLine4 //!< User-settable output signal Line 4 can be configured - Applies to: CameraLink + }; + + //! Valid values for UserSetDefault + enum UserSetDefaultEnums + { + UserSetDefault_AutoFunctions, //!< The Auto Functions factory set is set as the default startup set - Applies to: ace USB + UserSetDefault_Color, //!< The factory set enabling color adjustments is set as the startup set - Applies to: ace USB + UserSetDefault_ColorRaw, //!< The Color Raw factory set is set as the default startup set - Applies to: ace USB + UserSetDefault_Default, //!< The Default User Set factory set is set as the default startup set - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + UserSetDefault_HighGain, //!< The High Gain factory set is set as the default startup set - Applies to: ace USB + UserSetDefault_LightMicroscopy, //!< The Light Microscopy factory set is set as the default startup set - Applies to: ace USB + UserSetDefault_UserSet1, //!< User set 1 is set as the default startup set - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + UserSetDefault_UserSet2, //!< User set 2 is set as the default startup set - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + UserSetDefault_UserSet3 //!< User set 3 is set as the default startup set - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for UserSetDefaultSelector + enum UserSetDefaultSelectorEnums + { + UserSetDefaultSelector_AutoFunctions, //!< The Auto Functions factory set is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_Color, //!< The Color factory set is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_ColorRaw, //!< The Color Raw factory set is set as the default startup set - Applies to: GigE + UserSetDefaultSelector_Custom0, //!< Custom 0 factory set is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_Custom1, //!< Custom 1 factory set is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_Default, //!< The Default User Set factory set is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_HighGain, //!< The High Gain factory set is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_LightMicroscopy, //!< The Light Microscopy factory set is set as the default startup set - Applies to: GigE + UserSetDefaultSelector_UserSet1, //!< User set 1 is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_UserSet2, //!< User set 2 is set as the default startup set - Applies to: CameraLink and GigE + UserSetDefaultSelector_UserSet3 //!< User set 3 is set as the default startup set - Applies to: CameraLink and GigE + }; + + //! Valid values for UserSetSelector + enum UserSetSelectorEnums + { + UserSetSelector_AutoFunctions, //!< The Auto Functions factory set can be loaded - Applies to: CameraLink, GigE and ace USB + UserSetSelector_Color, //!< The Color factory set can be loaded - Applies to: CameraLink, GigE and ace USB + UserSetSelector_ColorRaw, //!< The Color Raw factory set can be loaded - Applies to: GigE and ace USB + UserSetSelector_Custom0, //!< The Custom 0 factory set can be loaded - Applies to: CameraLink and GigE + UserSetSelector_Custom1, //!< The Custom 1 factory set can be loaded - Applies to: CameraLink and GigE + UserSetSelector_Default, //!< The Default User Set factory set can be loaded - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + UserSetSelector_HighGain, //!< The High Gain factory set can be loaded - Applies to: CameraLink, GigE and ace USB + UserSetSelector_LightMicroscopy, //!< The Light Microscopy factory set can be loaded - Applies to: GigE and ace USB + UserSetSelector_UserSet1, //!< User set 1 can be saved, loaded, or configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + UserSetSelector_UserSet2, //!< User set 2 can be saved, loaded, or configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + UserSetSelector_UserSet3 //!< User set 3 can be saved, loaded, or configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + }; + + //! Valid values for VInpSignalReadoutActivation + enum VInpSignalReadoutActivationEnums + { + VInpSignalReadoutActivation_FallingEdge, //!< Sets the type of signal change necessary to start the signal evaluation - Applies to: CameraLink and GigE + VInpSignalReadoutActivation_RisingEdge //!< Sets the type of signal change necessary to start the signal evaluation - Applies to: CameraLink and GigE + }; + + //! Valid values for VInpSignalSource + enum VInpSignalSourceEnums + { + VInpSignalSource_CC1, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_CC2, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_CC3, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_CC4, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line1, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line2, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line3, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line4, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line5, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line6, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line7, //!< TODO - Applies to: CameraLink and GigE + VInpSignalSource_Line8 //!< TODO - Applies to: CameraLink and GigE + }; + + //! Valid values for VignettingCorrectionMode + enum VignettingCorrectionModeEnums + { + VignettingCorrectionMode_Off, //!< The vignetting correction is disabled - Applies to: GigE and ace USB + VignettingCorrectionMode_On //!< The vignetting correction is enabled - Applies to: GigE and ace USB + }; + + + + + //************************************************************************************************** + // Parameter class CUniversalCameraParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for Basler camera devices + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class PYLONBASE_API CUniversalCameraParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalCameraParams_Params_v6_2_0( void ); + + //! Destructor + ~CUniversalCameraParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CUniversalCameraParams_Params_v6_2_0_Data; + CUniversalCameraParams_Params_v6_2_0_Data* m_pCUniversalCameraParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Aborts the acquisition of images - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Aborts the acquisition of images. If the camera is currently exposing a frame, the camera stops exposing immediately. The readout process, if already started, is aborted. The current frame will be incomplete. Afterwards, image acquisition is switched off. + + Visibility: Beginner + + Selected by: AcquisitionMode + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& AcquisitionAbort; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Number of frames to acquire for each Frame Burst Start trigger - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionBurstFrameCount; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Number of frames to acquire for each Acquisition Start trigger - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionFrameCount; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Acquisition frame rate of the camera in frames per second - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AcquisitionFrameRate; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Acquisition frame rate of the camera in frames per second - Applies to: CamEmu, CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AcquisitionFrameRateAbs; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Enables setting the camera's acquisition frame rate to a specified value - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AcquisitionFrameRateEnable; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AcquisitionFrameRateEnum; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief A check determines whether the camera is currently idle - Applies to: GigE and ace USB + + A check determines whether the camera is currently idle, i.e., not acquiring images. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AcquisitionIdle; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Acquisition line rate of the camera in lines per second - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AcquisitionLineRateAbs; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the image acquisition mode - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selecting Parameters: AcquisitionAbort, AcquisitionStart and AcquisitionStop + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AcquisitionMode; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Starts the acquisition of images - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Starts the acquisition of images. If the camera is configured for single frame acquisition, it will start the acquisition of one frame. If the camera is configured for continuous frame acquisition, it will start the continuous acquisition of frames. + + Visibility: Beginner + + Selected by: AcquisitionMode + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& AcquisitionStart; + + //@} + + + //! \name Categories: AcquisitionStartEventData + //@{ + /*! + \brief Stream channel index of the Acquisition Start event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionStartEventStreamChannelIndex; + + //@} + + + //! \name Categories: AcquisitionStartEventData + //@{ + /*! + \brief Timestamp of the Acquisition Start event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionStartEventTimestamp; + + //@} + + + //! \name Categories: AcquisitionStartOvertriggerEventData + //@{ + /*! + \brief Stream channel index of the Acquisition Start Overtrigger event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionStartOvertriggerEventStreamChannelIndex; + + //@} + + + //! \name Categories: AcquisitionStartOvertriggerEventData + //@{ + /*! + \brief Timestamp of the Acquisition Start Overtrigger event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionStartOvertriggerEventTimestamp; + + //@} + + + //! \name Categories: AcquisitionStartWaitEventData + //@{ + /*! + \brief Stream channel index of the Acquisition Start Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionStartWaitEventStreamChannelIndex; + + //@} + + + //! \name Categories: AcquisitionStartWaitEventData + //@{ + /*! + \brief Timestamp of the Acquisition Start Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionStartWaitEventTimestamp; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Indicates whether the camera is waiting for trigger signals - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Indicates whether the camera is waiting for trigger signals. You should only use this feature if the camera is configured for software triggering. If the camera is configured for hardware triggering, monitor the camera's Trigger Wait signals instead. + + Visibility: Expert + + Selected by: AcquisitionStatusSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AcquisitionStatus; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the signal whose status you want to check - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Sets the signal whose status you want to check. Its status can be checked by reading the Acquisition Status parameter value. + + Visibility: Expert + + Selecting Parameters: AcquisitionStatus + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AcquisitionStatusSelector; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Stops the acquisition of images - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Stops the acquisition of images if a continuous image acquisition is in progress. + + Visibility: Beginner + + Selected by: AcquisitionMode + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& AcquisitionStop; + + //@} + + + //! \name Categories: AcquisitionWaitEventData + //@{ + /*! + \brief Stream channel index of the Acquisition Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionWaitEventStreamChannelIndex; + + //@} + + + //! \name Categories: AcquisitionWaitEventData + //@{ + /*! + \brief Timestamp of an Acquisition Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AcquisitionWaitEventTimestamp; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Number of separate action signals supported by the camera - Applies to: GigE + + Number of separate action signals supported by the camera. Determines how many action signals the camera can handle in parallel, i.e., how many different action commands can be configured on the camera. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionCommandCount; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Device key used for action commands - Applies to: GigE and ace 2 GigE + + Device key used to authorize the execution of an action command. If the action device key in the camera and the action device key in the protocol message are identical, the camera will execute the corresponding action. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionDeviceKey; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Group key used for action commands - Applies to: GigE and ace 2 GigE + + Group key used to define a group of cameras on which action commands can be executed. + + Visibility: Beginner + + Selected by: ActionSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionGroupKey; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Group mask used for action commands - Applies to: GigE and ace 2 GigE + + Group mask used to filter out a sub-group of cameras belonging to a group of cameras. The cameras belonging to a sub-group execute an action at the same time. The filtering is done using a logical bitwise AND operation on the group mask number of the action command and the group mask number of a camera. If both binary numbers have at least one common bit set to 1 (i.e., the result of the AND operation is non-zero), the corresponding camera belongs to the sub-group. + + Visibility: Beginner + + Selected by: ActionSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionGroupMask; + + //@} + + + //! \name Categories: ActionLateEventData + //@{ + /*! + \brief Stream channel index of the Action Late event - Applies to: GigE + + Stream channel index of the Action Late event. An Action Late event is raised when a scheduled action command with a timestamp in the past is received. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionLateEventStreamChannelIndex; + + //@} + + + //! \name Categories: ActionLateEventData + //@{ + /*! + \brief Timestamp of the Action Late event - Applies to: GigE + + Timestamp of the Action Late event. An Action Late event is raised when a scheduled action command with a timestamp in the past is received. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionLateEventTimestamp; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Number of action commands that can be queued by the camera - Applies to: ace 2 GigE + + Number of action commands that can be queued by the camera. The camera will execute them in ascending order of action time. If the queue is full, additional commands will be ignored. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionQueueSize; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Action command to be configured - Applies to: GigE and ace 2 GigE + + + Visibility: Beginner + + Selecting Parameters: ActionGroupKey and ActionGroupMask + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ActionSelector; + + //@} + + + //! \name Categories: AutoFunctionControl + //@{ + /*! + \brief Backlight compensation to be applied - Applies to: dart BCON, dart USB and pulse USB + + Backlight compensation factor that allows the camera to compensate for underexposure. This is done by excluding a certain percentage of the brightest pixels in the image from the target average gray value calculations. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoBacklightCompensation; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Lower limit of the Exposure Time parameter when the Exposure Auto auto function is active - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoExposureTimeAbsLowerLimit; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Upper limit of the Exposure Time parameter when the Exposure Auto auto function is active - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoExposureTimeAbsUpperLimit; + + //@} + + + //! \name Categories: AcquisitionControl and AutoFunctionControl + //@{ + /*! + \brief Lower limit of the Exposure Time parameter when the Exposure Auto auto function is active - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoExposureTimeLowerLimit; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Lower limit of the Exposure Time parameter when the Exposure Auto auto function is active (raw value) - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoExposureTimeLowerLimitRaw; + + //@} + + + //! \name Categories: AcquisitionControl and AutoFunctionControl + //@{ + /*! + \brief Upper limit of the Exposure Time parameter when the Exposure Auto auto function is active - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoExposureTimeUpperLimit; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Upper limit of the Exposure Time parameter when the Exposure Auto auto function is active (raw value) - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoExposureTimeUpperLimitRaw; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Height of the auto function AOI (in pixels) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionAOIHeight; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Horizontal offset of the auto function AOI from the left side of the sensor (in pixels) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionAOIOffsetX; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Vertical offset from the top of the sensor to the auto function AOI (in pixels) - Applies to: CameraLink and GigE + + Vertical offset of the auto function AOI from the top of the sensor (in pixels). + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionAOIOffsetY; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Sets which auto function AOI can be configured - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selecting Parameters: AutoFunctionAOIHeight, AutoFunctionAOIOffsetX, AutoFunctionAOIOffsetY, AutoFunctionAOIUsageIntensity, AutoFunctionAOIUsageRedLightCorrection, AutoFunctionAOIUsageWhiteBalance and AutoFunctionAOIWidth + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AutoFunctionAOISelector; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Assigns the Gain Auto and the Exposure Auto auto functions to the currently selected auto function AOI - Applies to: CameraLink and GigE + + Assigns the Gain Auto and the Exposure Auto auto functions to the currently selected auto function AOI. For this parameter, Gain Auto and Exposure Auto are considered as a single auto function named 'Intensity'. + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionAOIUsageIntensity; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Assigns the Red Light Correction auto function to the currently selected auto function AOI - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionAOIUsageRedLightCorrection; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Assigns the Tonal Range Auto auto function to the currently selected auto function AOI - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionAOIUsageTonalRange; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Assigns the Balance White Auto auto function to the currently selected auto function AOI - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionAOIUsageWhiteBalance; + + //@} + + + //! \name Categories: AutoFunctionAOIControl + //@{ + /*! + \brief Assigns the Gain Auto and the Exposure Auto auto functions to the currently selected auto function AOI - Applies to: ace USB + + Assigns the Gain Auto and the Exposure Auto auto functions to the currently selected auto function AOI. For this parameter, Gain Auto and Exposure Auto are considered as a single auto function named 'Brightness'. + + Visibility: Invisible + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionAOIUseBrightness; + + //@} + + + //! \name Categories: AutoFunctionAOIControl + //@{ + /*! + \brief Assigns the Balance White auto function to the currently selected auto function AOI - Applies to: ace USB + + + Visibility: Invisible + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionAOIUseWhiteBalance; + + //@} + + + //! \name Categories: AutoFunctionAOIs + //@{ + /*! + \brief Width of the auto function AOI (in pixels) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: AutoFunctionAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionAOIWidth; + + //@} + + + //! \name Categories: AutoFunctionControl and AutoFunctions + //@{ + /*! + \brief Sets how gain and exposure time will be balanced when the camera is making automatic adjustments - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AutoFunctionProfile; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Height of the auto function ROI (in pixels) - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionROIHeight; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Highlights the current auto function ROI in the image window - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Highlights the current auto function ROI in the image window. Areas that do not belong to the current ROI appear darker. + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionROIHighlight; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Horizontal offset of the auto function ROI from the left side of the sensor (in pixels) - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionROIOffsetX; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Vertical offset from the top of the sensor to the auto function ROI (in pixels) - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Vertical offset of the auto function ROI from the top of the sensor (in pixels). + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionROIOffsetY; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Sets which auto function ROI can be configured - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selecting Parameters: AutoFunctionROIHeight, AutoFunctionROIHighlight, AutoFunctionROIOffsetX, AutoFunctionROIOffsetY, AutoFunctionROIUseBrightness, AutoFunctionROIUseTonalRange, AutoFunctionROIUseWhiteBalance and AutoFunctionROIWidth + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AutoFunctionROISelector; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Assigns the Gain Auto and the Exposure Auto auto functions to the currently selected auto function ROI - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Assigns the Gain Auto and the Exposure Auto auto functions to the currently selected auto function ROI. For this parameter, Gain Auto and Exposure Auto are considered as a single auto function named 'Brightness'. + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionROIUseBrightness; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Assigns the Tonal Range Auto auto function to the currently selected auto function ROI - Applies to: ace USB + + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionROIUseTonalRange; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Assigns the Balance White Auto auto function to the currently selected auto function ROI - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoFunctionROIUseWhiteBalance; + + //@} + + + //! \name Categories: AutoFunctionROIControl + //@{ + /*! + \brief Width of the auto function ROI (in pixels) - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: AutoFunctionROISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoFunctionROIWidth; + + //@} + + + //! \name Categories: AnalogControl and AutoFunctionControl + //@{ + /*! + \brief Lower limit of the Gain parameter when the Gain Auto auto function is active - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: GainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoGainLowerLimit; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Lower limit of the Gain parameter when the Gain Auto auto function is active (raw value) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoGainRawLowerLimit; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Upper limit of the Gain parameter when the Gain Auto auto function is active (raw value) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoGainRawUpperLimit; + + //@} + + + //! \name Categories: AnalogControl and AutoFunctionControl + //@{ + /*! + \brief Upper limit of the Gain parameter when the Gain Auto auto function is active - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: GainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoGainUpperLimit; + + //@} + + + //! \name Categories: AutoFunctionControl + //@{ + /*! + \brief Target brightness for the Gain Auto and the Exposure Auto auto functions - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoTargetBrightness; + + //@} + + + //! \name Categories: AutoFunctionControl + //@{ + /*! + \brief Brightness adjustment damping factor to be applied - Applies to: dart BCON, dart USB and pulse USB + + Brightness adjustment damping factor to be applied. This controls the speed with which pixel gray values are changed when Exposure Auto, Gain Auto, or both are enabled. The lower the damping factor, the faster the target brightness value is reached. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoTargetBrightnessDamping; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Target brightness for the Gain Auto and the Exposure Auto auto functions - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoTargetValue; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Sets which parts of the tonal range can be adjusted - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AutoTonalRangeAdjustmentSelector; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Sets the kind of tonal range auto adjustment - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AutoTonalRangeModeSelector; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Bright target value to be used during automatic tonal range adjustments - Applies to: GigE and ace USB + + Bright target value to be used during automatic tonal range adjustments. When you enable the Tonal Range Auto auto function, the camera sets the Tonal Range Target Bright parameter to this value. Not available if the Auto Tonal Range Mode parameter is set to Color. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoTonalRangeTargetBright; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Dark target value to be used during automatic tonal range adjustments - Applies to: GigE and ace USB + + Dark target value to be used during automatic tonal range adjustments. When you enable the Tonal Range Auto auto function, the camera sets the Tonal Range Target Dark parameter to this value. Not available if the Auto Tonal Range Mode parameter is set to Color. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoTonalRangeTargetDark; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Threshold value from which the Tonal Range Source Bright parameter value is calculated during automatic tonal range adjustments - Applies to: GigE and ace USB + + Threshold value from which the Tonal Range Source Bright parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned auto function ROI. Example: Assume you set the Auto Tonal Range Threshold Bright parameter to 0.1 and enable the Tonal Range Auto auto function. Now assume that 0.1 % of the pixels in the assigned auto function ROI have a pixel value greater than or equal to 240. The camera automatically detects this, sets the Tonal Range Source Bright parameter to 240, and starts tonal range adjustments. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoTonalRangeThresholdBright; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Threshold value from which the Tonal Range Source Bright parameter value is calculated during automatic tonal range adjustments (raw value) - Applies to: GigE + + Threshold value from which the Tonal Range Source Bright parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned auto function ROI. Example: Assume you set the Auto Tonal Range Threshold Bright parameter to 0.1 and enable the Tonal Range Auto auto function. Now assume that 0.1 % of the pixels in the assigned auto function ROI have a pixel value greater than or equal to 240. The camera automatically detects this, sets the Tonal Range Source Bright parameter to 240, and starts tonal range adjustments. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoTonalRangeThresholdBrightRaw; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Threshold value from which the Tonal Range Source Dark parameter value is calculated during automatic tonal range adjustments - Applies to: GigE and ace USB + + Threshold value from which the Tonal Range Source Dark parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned auto function ROI. Example: Assume you set the Auto Tonal Range Threshold Dark parameter to 0.2 and enable the Tonal Range Auto auto function. Now assume that 0.2 % of the pixels in the assigned auto function ROI have a pixel value lower than or equal to 30. The camera automatically detects this, sets the Tonal Range Source Dark parameter to 30, and starts tonal range adjustments. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AutoTonalRangeThresholdDark; + + //@} + + + //! \name Categories: AutoTonalRangeControl + //@{ + /*! + \brief Threshold value from which the Tonal Range Source Dark parameter value is calculated during automatic tonal range adjustments (raw value) - Applies to: GigE + + Threshold value from which the Tonal Range Source Dark parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned auto function ROI. Example: Assume you set the Auto Tonal Range Threshold Dark parameter to 0.2 and enable the Tonal Range Auto auto function. Now assume that 0.2 % of the pixels in the assigned auto function ROI have a pixel value lower than or equal to 30. The camera automatically detects this, sets the Tonal Range Source Dark parameter to 30, and starts tonal range adjustments. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& AutoTonalRangeThresholdDarkRaw; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief A serial framing error occurred on reception - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BLCSerialFramingError; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief A serial parity error occurred on reception - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BLCSerialParityError; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Reports the baud rate of the serial communication module - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BLCSerialPortBaudRate; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Clears the error flags of the serial communication module - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BLCSerialPortClearErrors; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Reports the parity bit configuration of the serial communication module - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BLCSerialPortParity; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Reads and removes the front byte value from the serial communication receive queue - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BLCSerialPortReceiveCmd; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Last byte value read from the serial communication receive queue - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BLCSerialPortReceiveValue; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Sets the signal source for the serial communication module - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BLCSerialPortSource; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Reports the number of stop bits used by the serial communication module - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BLCSerialPortStopBits; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Writes the current byte value to the transmit queue - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BLCSerialPortTransmitCmd; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Byte value to be written to the transmit queue - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BLCSerialPortTransmitValue; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Reports the status of the serial communication receive queue - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BLCSerialReceiveQueueStatus; + + //@} + + + //! \name Categories: BLCSerialPortControl + //@{ + /*! + \brief Reports the status of the serial communication transmit queue - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BLCSerialTransmitQueueStatus; + + //@} + + + //! \name Categories: ImageQualityControl and WhiteBalanceControl + //@{ + /*! + \brief Balance Ratio value to be applied to the currently selected channel - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: BalanceRatioSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BalanceRatio; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Balance Ratio value to be applied to the currently selected channel - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: BalanceRatioSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BalanceRatioAbs; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Balance Ratio value to be applied to the currently selected channel (raw value) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: BalanceRatioSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BalanceRatioRaw; + + //@} + + + //! \name Categories: ColorImprovementsControl, ImageQualityControl and WhiteBalanceControl + //@{ + /*! + \brief Sets which color channel can be adjusted when performing manual white balance - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Sets which color channel can be adjusted when performing manual white balance. All changes to the Balance Ratio parameter will be applied to the selected color channel. + + Visibility: Beginner + + Selecting Parameters: BalanceRatio, BalanceRatioAbs and BalanceRatioRaw + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BalanceRatioSelector; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Balance White adjustment damping factor to be applied - Applies to: CameraLink and GigE + + Balance White adjustment damping factor to be applied. This controls the speed with which the camera adjusts colors when the Balance White Auto auto function is enabled. This can be useful, for example, when objects move into the camera's field of view and the light conditions are changing gradually due to the moving objects. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BalanceWhiteAdjustmentDampingAbs; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Balance White adjustment damping factor to be applied (raw value) - Applies to: CameraLink and GigE + + Balance White adjustment damping factor to be applied (raw value). This controls the speed with which the camera adjusts colors when the Balance White Auto auto function is enabled. This can be useful, for example, when objects move into the camera's field of view and the light conditions are changing gradually due to the moving objects. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BalanceWhiteAdjustmentDampingRaw; + + //@} + + + //! \name Categories: ColorImprovementsControl, ImageQualityControl and WhiteBalanceControl + //@{ + /*! + \brief Sets the operation mode of the Balance White Auto auto function - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BalanceWhiteAuto; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Resets all white balance adjustments - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BalanceWhiteReset; + + //@} + + + //! \name Categories: GigEVision + //@{ + /*! + \brief Sets a predefined bandwidth reserve or enables manual configuration of the bandwidth reserve - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BandwidthReserveMode; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Sets the clock frequency for the BCON transport layer - Applies to: dart BCON + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BconClockFrequency; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Sets the number of pixels transmitted per clock cycle via the BCON interface - Applies to: dart BCON + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BconPixelsPerClockCycle; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Number of adjacent horizontal pixels to be summed - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Number of adjacent horizontal pixels to be summed. Their charges will be summed and reported out of the camera as a single pixel. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BinningHorizontal; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Sets the binning mode for horizontal binning - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BinningHorizontalMode; + + //@} + + + //! \name Categories: AOI + //@{ + /*! + \brief Sets the binning mode for horizontal binning - Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BinningModeHorizontal; + + //@} + + + //! \name Categories: AOI + //@{ + /*! + \brief Sets the binning mode for vertical binning - Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BinningModeVertical; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Number of adjacent vertical pixels to be summed - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Number of adjacent vertical pixels to be summed. Their charges will be summed and reported out of the camera as a single pixel. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BinningVertical; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Sets the binning mode for vertical binning - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BinningVerticalMode; + + //@} + + + //! \name Categories: AnalogControl + //@{ + /*! + \brief Black level value to be applied to the currently selected sensor tap - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: BlackLevelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BlackLevel; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief Sets the value of the selected black level control as a float - Applies to: CameraLink and GigE + + This value sets the selected black level control as a float value. + + Visibility: Beginner + + Selected by: BlackLevelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BlackLevelAbs; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief Black level value to be applied to the currently selected sensor tap (raw value) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: BlackLevelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BlackLevelRaw; + + //@} + + + //! \name Categories: AnalogControl and AnalogControls + //@{ + /*! + \brief Sets which sensor tap can be configured - Applies to: CameraLink, GigE, ace USB, dart BCON, dart USB and pulse USB + + Sets which sensor tap can be configured. All changes to the Black Level parameter will be applied to the selected sensor tap. + + Visibility: Beginner + + Selecting Parameters: BlackLevel, BlackLevelAbs and BlackLevelRaw + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BlackLevelSelector; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sets the burst mode - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslAcquisitionBurstMode; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sets whether Acquisition Stop commands abort exposure - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslAcquisitionStopMode; + + //@} + + + //! \name Categories: ImageProcessingControl and ImageQualityControl + //@{ + /*! + \brief Brightness value to be applied - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Adjusting the brightness lightens or darkens the entire image. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslBrightness; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Brightness value to be applied (raw value) - Applies to: GigE + + Adjusting the brightness lightens or darkens the entire image. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslBrightnessRaw; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Centers the image horizontally - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslCenterX; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Centers the image vertically - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslCenterY; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Indicates the status of the target brightness adjustments performed by the Exposure Auto and Gain Auto auto functions - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslChunkAutoBrightnessStatus; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Sets which information should be included in the Chunk Timestamp Value chunk - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + Selecting Parameters: BslChunkTimestampValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslChunkTimestampSelector; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Value of the timestamp when the image was acquired - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + Selected by: BslChunkTimestampSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslChunkTimestampValue; + + //@} + + + //! \name Categories: ColorAdjustmentControl + //@{ + /*! + \brief Enables color adjustment - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslColorAdjustmentEnable; + + //@} + + + //! \name Categories: ColorAdjustmentControl + //@{ + /*! + \brief Hue adjustment value to be applied to the currently selected color channel - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: BslColorAdjustmentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslColorAdjustmentHue; + + //@} + + + //! \name Categories: ColorAdjustmentControl + //@{ + /*! + \brief Saturation adjustment value to be applied to the currently selected color channel - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: BslColorAdjustmentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslColorAdjustmentSaturation; + + //@} + + + //! \name Categories: ColorAdjustmentControl + //@{ + /*! + \brief Sets which color in your images will be adjusted - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selecting Parameters: BslColorAdjustmentHue and BslColorAdjustmentSaturation + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslColorAdjustmentSelector; + + //@} + + + //! \name Categories: AnalogControl and ImageProcessingControl + //@{ + /*! + \brief Sets the color space for image acquisitions - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Sets the color space for image acquisitions. Note that the gamma correction value also influences the perception of brightness in the resulting images. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslColorSpace; + + //@} + + + //! \name Categories: AnalogControl + //@{ + /*! + \brief Sets the color space for image acquisitions - Applies to: dart BCON, dart USB and pulse USB + + Sets the color space for image acquisitions. Note that the gamma correction value also influences the perception of brightness in the resulting images. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslColorSpaceMode; + + //@} + + + //! \name Categories: ImageProcessingControl and ImageQualityControl + //@{ + /*! + \brief Contrast value to be applied - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Adjusting the contrast increases the difference between light and dark areas in the image. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslContrast; + + //@} + + + //! \name Categories: ImageProcessingControl and ImageQualityControl + //@{ + /*! + \brief Sets the contrast mode - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslContrastMode; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Contrast value to be applied (raw value) - Applies to: GigE + + Adjusting the contrast increases the difference between light and dark areas in the image. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslContrastRaw; + + //@} + + + //! \name Categories: ImageProcessingControl + //@{ + /*! + \brief Identifies outlier pixels and adjusts their intensity value - Applies to: dart 2 USB + + Pixels that have a significantly higher or lower intensity value than the neighboring pixels are called outlier pixels. This feature identifies them and adjusts their intensity value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslDefectPixelCorrectionMode; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Actual bandwidth the camera will use - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data with the current camera settings. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslDeviceLinkCurrentThroughput; + + //@} + + + //! \name Categories: ErrorReportControl + //@{ + /*! + \brief Indicates whether an internal error occured on the device - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Indicates whether an internal error occured on the device. If an error occured, you can use the Error Report Next command to determine the error code. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslErrorPresent; + + //@} + + + //! \name Categories: ErrorReportControl + //@{ + /*! + \brief Retrieves the next error code from the device - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Retrieves the next error code from the device. To check the error code, get the value of the Error Report Value parameter. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslErrorReportNext; + + //@} + + + //! \name Categories: ErrorReportControl + //@{ + /*! + \brief Error code indicating the cause of the internal error - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Error code indicating the cause of the internal error. If there are multiple errors, execute the Error Report Next command to retrieve the next error code. A parameter value of 0 means that there are no more error codes to retrieve. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslErrorReportValue; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sets the exposure time mode - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslExposureTimeMode; + + //@} + + + //! \name Categories: ImageProcessingControl and ImageQualityControl + //@{ + /*! + \brief Hue shift value to be applied - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Adjusting the hue shifts the colors of the image. This can be useful, e.g., to correct minor color shifts or to create false-color images. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslHue; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Hue shift value to be applied (raw value) - Applies to: GigE + + Adjusting the hue shifts the colors of the image. This can be useful, e.g., to correct minor color shifts or to create false-color images. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslHueRaw; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Hue shift value to be applied - Applies to: dart BCON, dart USB and pulse USB + + Adjusting the hue shifts the colors of the image. This can be useful, e.g., to correct minor color shifts or to create false-color images. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslHueValue; + + //@} + + + //! \name Categories: ImageCompression + //@{ + /*! + \brief Ratio between the compressed payload size and the uncompressed payload size of the last acquired image - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslImageCompressionLastRatio; + + //@} + + + //! \name Categories: ImageCompression + //@{ + /*! + \brief Compressed payload size of the last acquired image in bytes - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslImageCompressionLastSize; + + //@} + + + //! \name Categories: ImageCompression + //@{ + /*! + \brief Maximum ratio between the payload size of compressed and uncompressed images - Applies to: ace 2 GigE and ace 2 USB + + Maximum ratio between the payload size of compressed and uncompressed images. For example, if you set this parameter to 70, the camera will try to compress the payload of images to 70 % or less of the original size. Note that if the camera can't achieve compression with the specified Image Compression Ratio and Image Compression Rate Option settings, frames will be skipped. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslImageCompressionRatio; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Enables the Immediate Trigger mode - Applies to: dart BCON, dart USB and pulse USB + + Enables the Immediate Trigger mode. If this mode is enabled, exposure starts immediately after triggering, but changes to image parameters become effective with a short delay, i.e., after one or more images have been acquired. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslImmediateTriggerMode; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Time period in which the camera evaluates all changes and durations of logical states of the input signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Time period in which the camera evaluates all changes and durations of logical states of the input signal. During evaluation, the camera calculates the mean value over time and applies a threshold function to the result to reconstruct the digital signal. This removes noise, interference, etc. as well as signal pulses shorter than the filter time. + + Visibility: Expert + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslInputFilterTime; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Time period in which the camera doesn't accept any further trigger signals or signal changes after receiving an input trigger signal - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Time period in which the camera doesn't accept any further trigger signals or signal changes after receiving an input trigger signal. This is useful if you want to avoid false triggering caused by multiple trigger signals arriving in quick succession (contact bounce). + + Visibility: Expert + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslInputHoldOffTime; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Searches for light devices connected to your camera - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslLightControlEnumerateDevices; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Indicates whether any of the light devices are currently experiencing problems - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightControlErrorStatus; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Enables/disables the light control features - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightControlMode; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Sets which line is used to control the light features - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightControlSource; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Indicates the current state of the light control mode - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightControlStatus; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Brightness of the light in percent of total brightness available - Applies to: GigE and ace USB + + Brightness of the light in percent of total brightness available. Setting this parameter to 100 % means that the light device draws the maximum current as specified by the Light Device Max Current parameter. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslLightDeviceBrightness; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Brightness of the light in percent of total brightness available (raw value) - Applies to: GigE + + Brightness of the light in percent of total brightness available (raw value). Setting this parameter to 100 % means that the light device draws the maximum current as specified by the the Light Device Max Current parameter. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslLightDeviceBrightnessRaw; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Changes the ID of the currently selected light device - Applies to: GigE and ace USB + + Changes the ID of the currently selected light device. The new ID will be assigned immediately. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightDeviceChangeID; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Clears the last light device error - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslLightDeviceClearLastError; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Version of the light device's firmware - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& BslLightDeviceFirmwareVersion; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Indicates the last light device error - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightDeviceLastError; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Maximum current that the light device is going to use - Applies to: GigE and ace USB + + Maximum current that the light device is going to use. The value should not exceed the power rating of the device. To change the setting, the Light Device Operation Mode parameter must be set to Off. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslLightDeviceMaxCurrent; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Maximum current that the light device is going to use (raw value) - Applies to: GigE + + Maximum current that the light device is going to use (raw value). The value should not exceed the power rating of the device. To change the setting, the Light Device Operation Mode parameter must be set to Off. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslLightDeviceMaxCurrentRaw; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Sets the operation mode of the light device - Applies to: GigE and ace USB + + Sets the operation mode of the light device. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightDeviceOperationMode; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Sets which light device can be configured - Applies to: GigE and ace USB + + Sets which light device can be configured. To populate the list, use the Light Control Enumerate Devices command first. All subsequent parameter changes in this category will be applied to the device selected here. + + Visibility: Expert + + Selecting Parameters: BslLightDeviceBrightness, BslLightDeviceBrightnessRaw, BslLightDeviceChangeID, BslLightDeviceClearLastError, BslLightDeviceFirmwareVersion, BslLightDeviceLastError, BslLightDeviceMaxCurrent, BslLightDeviceMaxCurrentRaw, BslLightDeviceOperationMode, BslLightDeviceStrobeDuration, BslLightDeviceStrobeDurationRaw and BslLightDeviceStrobeMode + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightDeviceSelector; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Duration of the individual strobe pulses - Applies to: GigE and ace USB + + Duration of the individual strobe pulses. The maximum value is 655 350 microseconds. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslLightDeviceStrobeDuration; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Duration of the individual strobe pulses (raw value) - Applies to: GigE + + Duration of the individual strobe pulses (raw value). The maximum value is 655 350 microseconds. + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslLightDeviceStrobeDurationRaw; + + //@} + + + //! \name Categories: BslLightControl + //@{ + /*! + \brief Sets the strobe mode of the light device - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: BslLightDeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightDeviceStrobeMode; + + //@} + + + //! \name Categories: ImageProcessingControl + //@{ + /*! + \brief Sets the light source preset - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Sets the light source preset. The colors in the image will be corrected so that they are appropriate for the selected light source. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightSourcePreset; + + //@} + + + //! \name Categories: ImageProcessingControl + //@{ + /*! + \brief Enables adjustment of the selected feature - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Enables adjustment of the feature specified by the Light Source Preset Feature Selector parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslLightSourcePresetFeatureEnable; + + //@} + + + //! \name Categories: ImageProcessingControl + //@{ + /*! + \brief Sets which features the camera adjusts when you select a light source preset - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Sets which features the camera adjusts when you select a light source preset. By default, the camera adjust all features. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslLightSourcePresetFeatureSelector; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Indicates whether a GPIO line is overloaded, i e , not powered correctly - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Indicates whether a GPIO line is overloaded, i.e., not powered correctly. A value of true (1) means that the GPIO line is overloaded. + + Visibility: Expert + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslLineOverloadStatus; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Horizontal offset of the currently selected column - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: BslMultipleROIColumnSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslMultipleROIColumnOffset; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Sets which column can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selecting Parameters: BslMultipleROIColumnOffset and BslMultipleROIColumnSize + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslMultipleROIColumnSelector; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Width of the currently selected column - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: BslMultipleROIColumnSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslMultipleROIColumnSize; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Enables or disables the ability to define multiple regions in horizontal direction - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Enables or disables the ability to define multiple regions in horizontal direction. When disabled, the width and horizontal offset of all regions is defined by the Width and OffsetX parameters, and the BslMultipleROIColumnOffset and BslMultipleROIColumnSize parameter values are ignored. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslMultipleROIColumnsEnable; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Vertical offset of the currently selected row - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: BslMultipleROIRowSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslMultipleROIRowOffset; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Sets which row can be configured - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selecting Parameters: BslMultipleROIRowOffset and BslMultipleROIRowSize + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslMultipleROIRowSelector; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Height of the currently selected row - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: BslMultipleROIRowSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslMultipleROIRowSize; + + //@} + + + //! \name Categories: MultipleROI + //@{ + /*! + \brief Enables or disables the ability to define multiple regions in vertical direction - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Enables or disables the ability to define multiple regions in vertical direction. When disabled, the height and vertical offset of all regions is defined by the Height and OffsetY parameters, and the BslMultipleROIRowOffset and BslMultipleROIRowSize parameter values are ignored. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslMultipleROIRowsEnable; + + //@} + + + //! \name Categories: BslPGIControl and PGIControl + //@{ + /*! + \brief Amount of noise reduction to be applied - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + + Amount of noise reduction to be applied. The higher the value, the less chroma noise will be visible in your images. However, very high values may result in image information loss. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslNoiseReduction; + + //@} + + + //! \name Categories: BslPeriodicSignalControl + //@{ + /*! + \brief Delay to be applied to the periodic signal in microseconds - Applies to: ace 2 GigE + + + Visibility: Expert + + Selected by: BslPeriodicSignalSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslPeriodicSignalDelay; + + //@} + + + //! \name Categories: BslPeriodicSignalControl + //@{ + /*! + \brief Length of the periodic signal in microseconds - Applies to: ace 2 GigE + + + Visibility: Expert + + Selected by: BslPeriodicSignalSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslPeriodicSignalPeriod; + + //@} + + + //! \name Categories: BslPeriodicSignalControl + //@{ + /*! + \brief Sets the periodic signal channel to be configured - Applies to: ace 2 GigE + + + Visibility: Expert + + Selecting Parameters: BslPeriodicSignalDelay, BslPeriodicSignalPeriod and BslPeriodicSignalSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslPeriodicSignalSelector; + + //@} + + + //! \name Categories: BslPeriodicSignalControl + //@{ + /*! + \brief Indicates whether the camera is synchronized via Precision Time Protocol (PTP) - Applies to: ace 2 GigE + + + Visibility: Expert + + Selected by: BslPeriodicSignalSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslPeriodicSignalSource; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Indicates the PTP delay mechanism - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslPtpDelayMechanism; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Enables PTP management - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslPtpManagementEnable; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Sets the mode for PTP network communication - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslPtpNetworkMode; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Value indicating the priority of the device when determining the master clock - Applies to: ace 2 GigE + + Value indicating the priority of the device when determining the master clock. The network device with the lowest Priority 1 setting is the master clock. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslPtpPriority1; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Sets the default PTP profile - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslPtpProfile; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Configures a two-step clock if enabled or a one-step clock if disabled - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslPtpTwoStep; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Unicast port address - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslPtpUcPortAddr; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Unicast port address index - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslPtpUcPortAddrIndex; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Maximum number of frames that can be acquired per second with current camera settings - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Maximum number of frames that can be acquired per second with current camera settings. In High Speed burst mode, this value is usually higher than the Resulting Transfer Frame Rate parameter value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslResultingAcquisitionFrameRate; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Maximum number of bursts per second with current camera settings - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslResultingFrameBurstRate; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Maximum number of frames that can be transferred per second with current camera settings - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Maximum number of frames that can be transferred per second with current camera settings. This value indicates the peak frame rate to be expected at the camera's output. In High Speed burst mode, this value is usually lower than the Resulting Acquisition Frame Rate parameter value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslResultingTransferFrameRate; + + //@} + + + //! \name Categories: ImageProcessingControl and ImageQualityControl + //@{ + /*! + \brief Saturation value to be applied - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Adjusting the saturation changes the colorfulness (intensity) of the colors. A higher saturation, for example, makes colors easier to distinguish. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslSaturation; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Saturation value to be applied (raw value) - Applies to: GigE + + Adjusting the saturation changes the colorfulness (intensity) of the colors. A higher saturation, for example, makes colors easier to distinguish. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslSaturationRaw; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Saturation value to be applied - Applies to: dart BCON, dart USB and pulse USB + + Adjusting the saturation changes the colorfulness (intensity) of the colors. A higher saturation, for example, makes colors easier to distinguish. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslSaturationValue; + + //@} + + + //! \name Categories: ImageProcessingControl + //@{ + /*! + \brief Scaling factor to be applied to all images - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + + Scaling factor to be applied to all images. Scaling is performed using the Pixel Beyond feature. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslScalingFactor; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sets the bit depth of the image sensor's data output - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Sets the bit depth of the image sensor's data output. You can set the sensor bit depth independently of the pixel format used if the Sensor Bit Depth Mode parameter is set to Manual. If that parameter is set to Auto, the sensor bit depth is adjusted automatically depending on the pixel format used. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSensorBitDepth; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sets the sensor bit depth mode - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSensorBitDepthMode; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Sets the baud rate used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSerialBaudRate; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Sets the number of data bits used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSerialNumberOfDataBits; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Sets the number of stop bits used in serial communication - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSerialNumberOfStopBits; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Sets which kind of parity check is performed - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSerialParity; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Initiates a receiving transaction from the serial input buffer - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Initiates a receiving transaction from the serial input buffer. When the transaction has been completed, the Serial Transfer Length parameter indicates the number of valid data units received. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslSerialReceive; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Indicates the incoming break signal status - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialRxBreak; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Resets the incoming break status - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslSerialRxBreakReset; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Indicates the overflow status of the receiving FIFO - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialRxFifoOverflow; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Indicates the parity error status of the receiving FIFO - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialRxParityError; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Sets the source of the Rx serial input - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslSerialRxSource; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Indicates the stop bit error status of the receiving FIFO - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialRxStopBitError; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Buffer that holds Rx or Tx transfer data in the controller domain - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Buffer that holds Rx or Tx transfer data in the controller domain. Data is displayed in hexadecimal notation. Transfer starts with the leftmost data. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IRegisterEx& BslSerialTransferBuffer; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Effective number of serial frames in a Rx or Tx data transfer - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Effective number of serial frames in a Rx or Tx data transfer. The maximum number of data frames is 16. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslSerialTransferLength; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Initiates a transmitting transaction to the serial output buffer - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Initiates a transmitting transaction to the serial output buffer. Set the correct transfer length before you issue a transmit command. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslSerialTransmit; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Signals a break to a receiver connected to the camera, or terminates the break - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + Signals a break to a receiver connected to the camera, or terminates the break. If this parameter is set to true, a serial break is signaled by setting the serial output to low level (space). If this parameter is set to false, the serial output is reset to high (mark). + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialTxBreak; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Indicates the empty status of the transmitting FIFO - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialTxFifoEmpty; + + //@} + + + //! \name Categories: SerialCommunicationControl + //@{ + /*! + \brief Indicates the overflow status of the transmitting FIFO - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& BslSerialTxFifoOverflow; + + //@} + + + //! \name Categories: BslPGIControl and PGIControl + //@{ + /*! + \brief Sharpening value to be applied - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + + Sharpening value to be applied. The higher the sharpness, the more distinct the image subject's contours will be. However, very high values may result in image information loss. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslSharpnessEnhancement; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates the maximum temperature the camera reached during operation - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& BslTemperatureMax; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates the temperature state - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslTemperatureStatus; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates how often the temperature state changed to Error - Applies to: ace 2 GigE, ace 2 USB and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& BslTemperatureStatusErrorCount; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Indicates the speed mode of the USB port - Applies to: ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslUSBSpeedMode; + + //@} + + + //! \name Categories: VignettingCorrection + //@{ + /*! + \brief Loads the vignetting correction data from the camera's file system - Applies to: boost CoaXPress + + Loads the vignetting correction data from the camera's file system and applies them to the camera. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& BslVignettingCorrectionLoad; + + //@} + + + //! \name Categories: VignettingCorrection + //@{ + /*! + \brief Enables the vignetting correction - Applies to: boost CoaXPress + + Enables the vignetting correction. This feature allows you to remove vignetting artifacts from your images. To do this, you first have to create vignetting correction data. For more information, see the Basler Product Documentation. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BslVignettingCorrectionMode; + + //@} + + + //! \name Categories: CameraOperationControl + //@{ + /*! + \brief Sets the camera operation mode - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CameraOperationMode; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Centers the image horizontally - Applies to: CameraLink, GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& CenterX; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Centers the image vertically - Applies to: CameraLink, GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& CenterY; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Sets which counter to retrieve chunk data from - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Expert + + Selecting Parameters: ChunkCounterValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ChunkCounterSelector; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Value of the selected chunk counter - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + Selected by: ChunkCounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkCounterValue; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Maximum possible pixel value in the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkDynamicRangeMax; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Minimum possible pixel value in the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkDynamicRangeMin; + + //@} + + + //! \name Categories: ChunkDataControl and ChunkDataStreams + //@{ + /*! + \brief Includes the currently selected chunk in the payload data - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + Selected by: ChunkSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ChunkEnable; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Exposure time used to acquire the image - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ChunkExposureTime; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Unique identifier of the current frame - Applies to: ace 2 GigE and ace 2 USB + + Unique identifier of the current frame. The frame ID starts at 0 and keeps incrementing by 1 for each exposed image until the camera is powered off. The maximum value is 2^48. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkFrameID; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Frame Trigger counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkFrameTriggerCounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Frame Trigger Ignored counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkFrameTriggerIgnoredCounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Frame counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkFramecounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Frames per Trigger counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkFramesPerTriggerCounter; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Gain used during image acquisition - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + Selected by: ChunkGainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ChunkGain; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Gain All value of the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkGainAll; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Sets which gain channel to retrieve chunk data from - Applies to: ace USB + + + Visibility: Expert + + Selecting Parameters: ChunkGain + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ChunkGainSelector; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief AOI height of the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkHeight; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Number of bits per line used for the Input Status At Line Trigger parameter - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkInputStatusAtLineTriggerBitsPerLine; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Index number used for the Input Status At Line Trigger parameter - Applies to: GigE + + Index number used for the Input Status At Line Trigger parameter. The index number can be used to get the state of the camera's input lines when a specific line was acquired. For example, if you want to know the state of the camera's input lines when line 30 was acquired, set the index to 30, then retrieve the value of Status Index parameter. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkInputStatusAtLineTriggerIndex; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value indicating the status of the camera's input lines when a specific line was acquired - Applies to: GigE + + Value indicating the status of the camera's input lines when a specific line was acquired. The information is stored in a 4-bit value (bit 0 = input line 1 state, bit 1 = input line 2 state etc.). For more information, see the Status Index parameter documentation. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkInputStatusAtLineTriggerValue; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Bit field that indicates the status of all of the camera's input and output lines when the image was acquired - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkLineStatusAll; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Line Trigger counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkLineTriggerCounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Line Trigger End to End counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkLineTriggerEndToEndCounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Line Trigger Ignored counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkLineTriggerIgnoredCounter; + + //@} + + + //! \name Categories: ChunkDataControl and ChunkDataStreams + //@{ + /*! + \brief Enables the chunk mode - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ChunkModeActive; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief X offset of the AOI of the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkOffsetX; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Y offset of the AOI of the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkOffsetY; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief CRC checksum of the acquired image - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + CRC checksum of the acquired image. The checksum is calculated using all of the image data and all of the appended chunks except for the checksum itself. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkPayloadCRC16; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Indicates the pixel format of the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ChunkPixelFormat; + + //@} + + + //! \name Categories: ChunkDataControl and ChunkDataStreams + //@{ + /*! + \brief Sets which chunk can be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + Sets which chunk can be enabled. The chunk can be enabled using the Chunk Enable parameter. + + Visibility: Beginner + + Selecting Parameters: ChunkEnable + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ChunkSelector; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Sequence set index number related to the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkSequenceSetIndex; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Index of the active sequencer set - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkSequencerSetActive; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Shaft Encoder counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkShaftEncoderCounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Number of bytes of data between the beginning of one line in the acquired image and the beginning of the next line in the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkStride; + + //@} + + + //! \name Categories: ChunkData and ChunkDataControl + //@{ + /*! + \brief Value of the timestamp when the image was acquired - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkTimestamp; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Value of the Trigger Input counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkTriggerinputcounter; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Status of all of the camera's virtual input and output lines when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkVirtLineStatusAll; + + //@} + + + //! \name Categories: ChunkData + //@{ + /*! + \brief Width of the AOI of the acquired image - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ChunkWidth; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the configuration type - Applies to: CameraLink + + Sets the configuration type. The configuration type determines the amount of data that can be transmitted. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ClConfiguration; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Delay between end of transmission and start of transmission of consecutive lines - Applies to: CameraLink + + Delay (in microseconds) between the end of transmission of one line and the start of transmission of the next line. This value will be adjusted automatically to the nearest multiple of the currently selected pixel clock. The line valid signal (LVAL) remains low while the delay is in force. The default value of the parameter is the minimum inter-line delay. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ClInterLineDelayAbs; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Delay between end of transmission and start of transmission of consecutive lines (raw value) - Applies to: CameraLink + + Delay between the end of transmission of one line and the start of transmission of the next line (raw value). This value will be adjusted automatically to the nearest multiple of the currently selected pixel clock. The line valid signal (LVAL) remains low while the delay is in force. The default value of the parameter is the minimum inter-line delay. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ClInterLineDelayRaw; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the pixel clock used in the communication with the frame grabber - Applies to: CameraLink + + Sets the pixel clock used in the communication with the frame grabber. The pixel clock speed determines the rate at which pixel data will be transmitted from the camera to the frame grabber. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ClPixelClock; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Pixel clock used in the communication with the frame grabber in Hz - Applies to: CameraLink + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ClPixelClockAbs; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the serial port baud rate - Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ClSerialPortBaudRate; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the tap geometry - Applies to: CameraLink + + Sets the tap geometry. The tap geometry uniquely describes the geometrical properties characterizing the different taps of a multi-tap camera. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ClTapGeometry; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the number of time slots - Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ClTimeSlots; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Clears the last error - Applies to: CameraLink, GigE and blaze + + Clears the last error. If a previous error exists, the previous error can still be retrieved. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& ClearLastError; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Enables color adjustment - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ColorAdjustmentEnable; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Hue adjustment value to be applied to the currently selected color channel - Applies to: CameraLink, GigE and ace USB + + + Visibility: Expert + + Selected by: ColorAdjustmentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ColorAdjustmentHue; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Hue adjustment value to be applied to the currently selected color channel (raw value) - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selected by: ColorAdjustmentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorAdjustmentHueRaw; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Allows you to restore previous color adjustment settings - Applies to: CameraLink and GigE + + Allows you to restore the color adjustment settings that were in force before the settings were last changed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& ColorAdjustmentReset; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Saturation adjustment value to be applied to the currently selected color channel - Applies to: CameraLink, GigE and ace USB + + Saturation adjustment value to be applied to the currently selected color channel. + + Visibility: Expert + + Selected by: ColorAdjustmentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ColorAdjustmentSaturation; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Saturation adjustment value to be applied to the currently selected color channel (raw value) - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selected by: ColorAdjustmentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorAdjustmentSaturationRaw; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Sets which color in your images will be adjusted - Applies to: CameraLink, GigE and ace USB + + + Visibility: Expert + + Selecting Parameters: ColorAdjustmentHue, ColorAdjustmentHueRaw, ColorAdjustmentSaturation and ColorAdjustmentSaturationRaw + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ColorAdjustmentSelector; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Enables color overexposure compensation - Applies to: CameraLink and GigE + + Enables color overexposure compensation. + + Visibility: Beginner + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ColorOverexposureCompensationAOIEnable; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Sets the color overexposure compensation factor for the selected C O C AOI - Applies to: CameraLink and GigE + + Sets the color overexposure compensation factor controlling the extent of compensation for the selected C.O.C. AOI. + + Visibility: Guru + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ColorOverexposureCompensationAOIFactor; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Sets the raw value for the color overexposure compensation factor - Applies to: CameraLink and GigE + + Sets the raw value for the color overexposure compensation factor. + + Visibility: Guru + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorOverexposureCompensationAOIFactorRaw; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Sets the height for the selected C O C AOI - Applies to: CameraLink and GigE + + Sets the height for the selected Color Overexposure Compensation AOI. + + Visibility: Guru + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorOverexposureCompensationAOIHeight; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Sets the X offset for the selected C O C AOI - Applies to: CameraLink and GigE + + Sets the horizontal offset for the selected Color Overexposure Compensation AOI. + + Visibility: Guru + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorOverexposureCompensationAOIOffsetX; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Sets the Y offset for the selected C O C AOI - Applies to: CameraLink and GigE + + Sets the vertical offset for the selected Color Overexposure Compensation AOI. + + Visibility: Guru + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorOverexposureCompensationAOIOffsetY; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Selcts the AOI for color overexposure compensation - Applies to: CameraLink and GigE + + Selcts the area of interest where color overexposure compensation will be performed. + + Visibility: Guru + + Selecting Parameters: ColorOverexposureCompensationAOIEnable, ColorOverexposureCompensationAOIFactor, ColorOverexposureCompensationAOIFactorRaw, ColorOverexposureCompensationAOIHeight, ColorOverexposureCompensationAOIOffsetX, ColorOverexposureCompensationAOIOffsetY and ColorOverexposureCompensationAOIWidth + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ColorOverexposureCompensationAOISelector; + + //@} + + + //! \name Categories: ColorOverexposureCompensation + //@{ + /*! + \brief Sets the width for the selected C O C AOI - Applies to: CameraLink and GigE + + Sets the width for the selected Color Overexposure Compensation AOI. + + Visibility: Guru + + Selected by: ColorOverexposureCompensationAOISelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorOverexposureCompensationAOIWidth; + + //@} + + + //! \name Categories: AnalogControl and ImageQualityControl + //@{ + /*! + \brief Sets the color space for image acquisitions - Applies to: ace USB + + Sets the color space for image acquisitions. Note that the gamma correction value also influences the perception of brightness in the resulting images. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ColorSpace; + + //@} + + + //! \name Categories: ColorTransformationControl + //@{ + /*! + \brief Enables color transformation - Applies to: ace 2 GigE, ace 2 USB and boost CoaXPress + + + Visibility: Expert + + Selected by: ColorTransformationSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ColorTransformationEnable; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Extent to which the color matrix influences the color values - Applies to: CameraLink and GigE + + Extent to which the color matrix influences the color values. If set to 0, the matrix is effectively disabled. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ColorTransformationMatrixFactor; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Extent to which the color matrix influences the color values (raw value) - Applies to: CameraLink and GigE + + Extent to which the color matrix influences the color values (raw value). If set to 0, the matrix is effectively disabled. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorTransformationMatrixFactorRaw; + + //@} + + + //! \name Categories: ColorImprovementsControl, ColorTransformationControl and ImageQualityControl + //@{ + /*! + \brief Sets which type of color transformation will be performed - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + + Visibility: Expert + + Selecting Parameters: ColorTransformationEnable, ColorTransformationValue, ColorTransformationValueSelector and LightSourceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ColorTransformationSelector; + + //@} + + + //! \name Categories: ColorImprovementsControl, ColorTransformationControl and ImageQualityControl + //@{ + /*! + \brief Transformation value for the selected element in the color transformation matrix - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + + Visibility: Expert + + Selected by: ColorTransformationSelector and ColorTransformationValueSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ColorTransformationValue; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Transformation value for the selected element in the color transformation matrix (raw value) - Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: ColorTransformationValueSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ColorTransformationValueRaw; + + //@} + + + //! \name Categories: ColorImprovementsControl, ColorTransformationControl and ImageQualityControl + //@{ + /*! + \brief Sets which element will be entered in the color transformation matrix - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + Sets which element will be entered in the color transformation matrix. Depending on the camera model, some elements in the color transformation matrix may be preset and can't be changed. + + Visibility: Expert + + Selected by: ColorTransformationSelector + + Selecting Parameters: ColorTransformationValue and ColorTransformationValueRaw + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ColorTransformationValueSelector; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Controls if the selected component streaming is active - Applies to: blaze + + + Visibility: Beginner + + Selected by: ComponentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ComponentEnable; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Selects a component to activate/deactivate its data streaming - Applies to: blaze + + + Visibility: Beginner + + Selecting Parameters: ComponentEnable and PixelFormat + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ComponentSelector; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Confidence threshold for pixels - Applies to: blaze + + Pixels have to exceed the confidence value specified here in order to be taken into account for the distance measurement. The threshold value is based on the gray values of the confidence map. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ConfidenceThreshold; + + //@} + + + //! \name Categories: CounterAndTimerControl and CounterControl + //@{ + /*! + \brief Number of times a sequencer set is used before the Counter End event is generated - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CounterDuration; + + //@} + + + //! \name Categories: CounterControl + //@{ + /*! + \brief Sets the type of signal transition that the counter will count - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterEventActivation; + + //@} + + + //! \name Categories: CounterAndTimerControl, CounterControl and TimerControls + //@{ + /*! + \brief Sets which event increases the currently selected counter - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterEventSource; + + //@} + + + //! \name Categories: CounterAndTimerControl, CounterControl and TimerControls + //@{ + /*! + \brief Immediately resets the selected counter - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Immediately resets the selected counter. The counter starts counting again immediately after the reset. + + Visibility: Beginner + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& CounterReset; + + //@} + + + //! \name Categories: CounterAndTimerControl and CounterControl + //@{ + /*! + \brief Sets which type of signal transition will reset the counter - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterResetActivation; + + //@} + + + //! \name Categories: CounterAndTimerControl, CounterControl and TimerControls + //@{ + /*! + \brief Sets which source signal will reset the currently selected counter - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterResetSource; + + //@} + + + //! \name Categories: CounterAndTimerControl, CounterControl and TimerControls + //@{ + /*! + \brief Sets which counter can be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Sets which counter can be configured. All changes to the counter settings will be applied to the selected counter. + + Visibility: Beginner + + Selecting Parameters: CounterDuration, CounterEventActivation, CounterEventSource, CounterReset, CounterResetActivation, CounterResetSource, CounterStatus, CounterTriggerActivation, CounterTriggerSource and CounterValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterSelector; + + //@} + + + //! \name Categories: CounterControl + //@{ + /*! + \brief Returns the current status of the counter - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterStatus; + + //@} + + + //! \name Categories: CounterControl + //@{ + /*! + \brief Sets the type of signal transition that will start the counter - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterTriggerActivation; + + //@} + + + //! \name Categories: CounterControl + //@{ + /*! + \brief Sets the signal used to start the selected counter - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Sets the signal used to start the selected counter. If you start a counter, it will not necessarily start counting. If and when the counter counts, depends on the Counter Event Source parameter value. + + Visibility: Expert + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CounterTriggerSource; + + //@} + + + //! \name Categories: CounterControl + //@{ + /*! + \brief Current value of the counter - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: CounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CounterValue; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Indicates whether the critical temperature has been reached - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& CriticalTemperature; + + //@} + + + //! \name Categories: CriticalTemperatureEventData + //@{ + /*! + \brief Stream channel index of the Critical Temperature event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CriticalTemperatureEventStreamChannelIndex; + + //@} + + + //! \name Categories: CriticalTemperatureEventData + //@{ + /*! + \brief Timestamp of the Critical Temperature event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CriticalTemperatureEventTimestamp; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets the CoaXPress physical connection to control - Applies to: boost CoaXPress + + + Visibility: Expert + + Selecting Parameters: CxpConnectionTestErrorCount, CxpConnectionTestMode, CxpErrorCounterSelector and CxpSendReceiveSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CxpConnectionSelector; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Number of test packet connection errors received by the device on the connection selected by the Connection Selector parameter - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpConnectionSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CxpConnectionTestErrorCount; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets the test mode for an individual physical connection of the device - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpConnectionSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpConnectionTestMode; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Number of test packets received by the device on the connection selected by the Cxp Connection Selector parameter - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpSendReceiveSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CxpConnectionTestPacketCount; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Resets the selected CoaXPress error counter - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpErrorCounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& CxpErrorCounterReset; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets which CoaXPress error counter to read or reset - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpConnectionSelector + + Selecting Parameters: CxpErrorCounterReset, CxpErrorCounterStatus and CxpErrorCounterValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpErrorCounterSelector; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Indicates the current status of the selected CoaXPress error counter - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpErrorCounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpErrorCounterStatus; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Current value of the selected CoaXPress error counter - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpErrorCounterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CxpErrorCounterValue; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets the link configuration - Applies to: boost CoaXPress + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpLinkConfiguration; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets the link configuration that allows the device to operate in its default mode - Applies to: boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpLinkConfigurationPreferred; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Indicates the link configuration used by the device - Applies to: boost CoaXPress + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpLinkConfigurationStatus; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets whether the send or the receive features can be configured - Applies to: boost CoaXPress + + + Visibility: Expert + + Selected by: CxpConnectionSelector + + Selecting Parameters: CxpConnectionTestPacketCount + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpSendReceiveSelector; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Horizontal decimation factor - Applies to: CameraLink, GigE and ace USB + + Horizontal decimation factor. This specifies the extent of horizontal sub-sampling of the acquired frame, i.e., it defines how many pixel columns are left out of transmission. This has the net effect of reducing the horizontal resolution (width) of the image by the specified decimation factor. A value of 1 means that the camera performs no horizontal decimation. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DecimationHorizontal; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Vertical decimation factor - Applies to: CameraLink, GigE and ace USB + + Vertical decimation factor. This specifies the extent of vertical sub-sampling of the acquired frame, i.e., it defines how many rows are left out of transmission. This has the net effect of reducing the vertical resolution (height) of the image by the specified decimation factor. A value of 1 means that the camera performs no vertical decimation. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DecimationVertical; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Identifies outlier pixels and adjusts their intensity value - Applies to: dart BCON, dart USB and pulse USB + + Pixels that have a significantly higher or lower intensity value than the neighboring pixels are called outlier pixels. This feature identifies them and adjusts their intensity value. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DefectPixelCorrectionMode; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Sets the demosaicing mode - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DemosaicingMode; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief End of the three-dimensional ROI - Applies to: blaze + + The Minimum Depth and the Maximum Depth parameters together define the desired three-dimensional ROI. In the point cloud display, points outside the ROI will be ignored. When using the Mono16 or RGB8 pixel formats, points in front of the ROI receive the minimum distance value, while points beyond the ROI receive the maximum distance value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DepthMax; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Start of the three-dimensional ROI - Applies to: blaze + + The Minimum Depth and the Maximum Depth parameters together define the desired three-dimensional ROI. In the point cloud display, points outside the ROI will be ignored. When using the Mono16 or RGB8 pixel formats, points in front of the ROI receive the minimum distance value, while points beyond the ROI receive the maximum distance value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DepthMin; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates the character set used by the strings of the device's bootstrap registers - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceCharacterSet; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Clock frequency used - Applies to: dart BCON + + + Visibility: Expert + + Selected by: DeviceClockSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& DeviceClockFrequency; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Sets the clock of the camera - Applies to: dart BCON + + Sets the clock of the camera. When a clock has been set, the clock frequency can be read using the Device Clock Frequency parameter. + + Visibility: Expert + + Selecting Parameters: DeviceClockFrequency + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceClockSelector; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Version of the color modifications applied to images - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceColorPipelineVersion; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates the number of event channels supported by the device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceEventChannelCount; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Identifier of the product family of the device - Applies to: ace 2 GigE, ace 2 USB, blaze, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceFamilyName; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Disables feature streaming on the device - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Disables feature streaming on the device. Feature streaming allows you to save camera settings outside of the device. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& DeviceFeaturePersistenceEnd; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Enables feature streaming on the device - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Enables feature streaming on the device. Feature streaming allows you to save camera settings outside of the device. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& DeviceFeaturePersistenceStart; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Version of the camera's firmware - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceFirmwareVersion; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Major version of the GenCP protocol supported by the device - Applies to: ace 2 USB and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceGenCPVersionMajor; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Minor version of the GenCP protocol supported by the device - Applies to: ace 2 USB and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceGenCPVersionMinor; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief ID of the camera - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceID; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Sets the behavior of the camera's status LED - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceIndicatorMode; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Returns the number of physical connection of the device used by a particular Link - Applies to: blaze + + + Visibility: Beginner + + Selected by: DeviceLinkSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceLinkConnectionCount; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Actual bandwidth the camera will use - Applies to: ace USB + + Actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data with the current camera settings. + + Visibility: Expert + + Selected by: DeviceLinkSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceLinkCurrentThroughput; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Device link to be configured - Applies to: ace USB, blaze, dart USB and pulse USB + + + Visibility: Beginner + + Selecting Parameters: DeviceLinkConnectionCount, DeviceLinkCurrentThroughput, DeviceLinkSpeed, DeviceLinkThroughputLimit and DeviceLinkThroughputLimitMode + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceLinkSelector; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Speed of transmission negotiated on the selected link - Applies to: ace USB, dart USB and pulse USB + + + Visibility: Expert + + Selected by: DeviceLinkSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceLinkSpeed; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Bandwidth limit for data transmission (in bytes per second) - Applies to: ace 2 GigE, ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: DeviceLinkSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceLinkThroughputLimit; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Enables/disables the device link throughput limit - Applies to: ace 2 GigE, ace 2 USB, ace USB, dart 2 USB, dart USB and pulse USB + + Enables/disables the device link throughput limit. If disabled, the bandwidth used is determined by the settings of various other parameters, e.g., exposure time or frame rate. + + Visibility: Beginner + + Selected by: DeviceLinkSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceLinkThroughputLimitMode; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief First URL to the GenICam XML device description file of the selected manifest entry - Applies to: ace 2 GigE and boost CoaXPress + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceManifestPrimaryURL; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Major version number of the schema file of the selected manifest entry - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceManifestSchemaMajorVersion; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Minor version number of the schema file of the selected manifest entry - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceManifestSchemaMinorVersion; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Major version number of the GenICam XML file of the selected manifest entry - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceManifestXMLMajorVersion; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Minor version number of the GenICam XML file of the selected manifest entry - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceManifestXMLMinorVersion; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Subminor version number of the GenICam XML file of the selected manifest entry - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceManifestXMLSubMinorVersion; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Additional information from the vendor about the camera - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Endianness of the registers of the device. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceManufacturerInfo; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Name of the camera model - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceModelName; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Endianness of the registers of the device - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceRegistersEndianness; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Announces the end of feature streaming - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& DeviceRegistersStreamingEnd; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Prepares the camera for feature streaming - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& DeviceRegistersStreamingStart; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Immediately resets and restarts the camera - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& DeviceReset; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Major version number of the SFNC specification that the camera is compatible with - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Major version number of the Standard Features Naming Convention (SFNC) specification that the camera is compatible with. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceSFNCVersionMajor; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Minor version number of the SFNC specification that the camera is compatible with - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Minor version number of the Standard Features Naming Convention (SFNC) specification that the camera is compatible with. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceSFNCVersionMinor; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Subminor version number of the SFNC specification that the camera is compatible with - Applies to: GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Subminor version number of the Standard Features Naming Convention (SFNC) specification that the camera is compatible with. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceSFNCVersionSubMinor; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Indicates the scan type of the camera's sensor (area or line scan) - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceScanType; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Serial number of the camera - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceSerialNumber; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates the number of streaming channels supported by the device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceStreamChannelCount; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Indicates the type of the device's transport layer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceTLType; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Major version number of the device's transport layer - Applies to: ace 2 GigE, ace 2 USB, blaze, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceTLVersionMajor; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Minor version number of the device's transport layer - Applies to: ace 2 GigE, ace 2 USB, blaze, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceTLVersionMinor; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Subminor version number of the device's transport layer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceTLVersionSubMinor; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Sets the tap geometry - Applies to: boost CoaXPress + + Sets the tap geometry. The tap geometry uniquely describes the geometrical properties characterizing the different taps of a multi-tap camera. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceTapGeometry; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Temperature at the selected location in the camera (in degrees centigrade) - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress and dart 2 USB + + Temperature at the selected location in the camera (in degrees centigrade). The temperature is measured at the location specified by the Device Temperature Selector parameter. + + Visibility: Expert + + Selected by: DeviceTemperatureSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& DeviceTemperature; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Sets the location in the camera where the temperature will be measured - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress and dart 2 USB + + Sets the location in the camera where the temperature will be measured. The temperature can be retrieved using the Device Temperature parameter. + + Visibility: Expert + + Selecting Parameters: DeviceTemperature + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceTemperatureSelector; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Returns the device type - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceType; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief User-settable ID of the camera - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceUserID; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Name of the camera vendor - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceVendorName; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Version of the camera - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceVersion; + + //@} + + + //! \name Categories: AnalogControl and AnalogControls + //@{ + /*! + \brief Digital shift to be applied - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + Digital shift allows you to multiply the pixel values in an image. This increases the brightness of the image. If the parameter is set to zero, digital shift is disabled. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DigitalShift; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Enables Burst Acquisition - Applies to: CameraLink and GigE + + Enables Burst Acquisition. If enabled, the maximum frame rate only depends on the sensor timing and the timing of the trigger sequence. The image transfer rate out of the camera has no influence on the frame rate. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& EnableBurstAcquisition; + + //@} + + + //! \name Categories: EventActionLateData + //@{ + /*! + \brief Unique identifier of the Action Late event - Applies to: ace 2 GigE + + Unique identifier of the Action Late event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventActionLate; + + //@} + + + //! \name Categories: EventActionLateData + //@{ + /*! + \brief Timestamp of the Action Late event - Applies to: ace 2 GigE + + Timestamp of the Action Late event. An Action Late event is raised when a scheduled action command with a timestamp in the past is received. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventActionLateTimestamp; + + //@} + + + //! \name Categories: EventCriticalTemperatureData + //@{ + /*! + \brief Unique identifier of the Critical Temperature event - Applies to: ace USB + + Unique identifier of the Critical Temperature event. Use this parameter to get notified when the event occurs. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventCriticalTemperature; + + //@} + + + //! \name Categories: EventCriticalTemperatureData + //@{ + /*! + \brief Timestamp of the Critical Temperature event - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventCriticalTemperatureTimestamp; + + //@} + + + //! \name Categories: EventExposureEndData + //@{ + /*! + \brief Unique identifier of the Exposure End event - Applies to: ace 2 GigE, ace 2 USB and ace USB + + Unique identifier of the Exposure End event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventExposureEnd; + + //@} + + + //! \name Categories: EventExposureEndData + //@{ + /*! + \brief Frame ID of the Exposure End event - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventExposureEndFrameID; + + //@} + + + //! \name Categories: EventExposureEndData + //@{ + /*! + \brief Timestamp of the Exposure End event - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventExposureEndTimestamp; + + //@} + + + //! \name Categories: EventFrameBufferOverrunData + //@{ + /*! + \brief Unique identifier of the Frame Buffer Overrun event - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBufferOverrun; + + //@} + + + //! \name Categories: EventFrameBufferOverrunData + //@{ + /*! + \brief Timestamp of the Frame Buffer Overrun event - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBufferOverrunTimestamp; + + //@} + + + //! \name Categories: EventFrameBurstStartData + //@{ + /*! + \brief Unique identifier of the Frame Burst Start event - Applies to: ace USB + + Unique identifier of the Frame Burst Start event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStart; + + //@} + + + //! \name Categories: EventFrameBurstStartData + //@{ + /*! + \brief Frame ID of the Frame Burst Start event - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartFrameID; + + //@} + + + //! \name Categories: EventFrameBurstStartOvertriggerData + //@{ + /*! + \brief Unique identifier of the Frame Burst Start Overtrigger event - Applies to: ace USB + + Unique identifier of the Frame Burst Start Overtrigger event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartOvertrigger; + + //@} + + + //! \name Categories: EventFrameBurstStartOvertriggerData + //@{ + /*! + \brief Frame ID of the Frame Burst Start Overtrigger event - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartOvertriggerFrameID; + + //@} + + + //! \name Categories: EventFrameBurstStartOvertriggerData + //@{ + /*! + \brief Timestamp of the Frame Burst Start Overtrigger event - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartOvertriggerTimestamp; + + //@} + + + //! \name Categories: EventFrameBurstStartData + //@{ + /*! + \brief Timestamp of the Frame Burst Start event - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartTimestamp; + + //@} + + + //! \name Categories: EventFrameBurstStartWaitData + //@{ + /*! + \brief Unique identifier of the Frame Burst Start Wait event - Applies to: ace USB + + Unique identifier of the Frame Burst Start Wait event. Use this parameter to get notified when the event occurs. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartWait; + + //@} + + + //! \name Categories: EventFrameBurstStartWaitData + //@{ + /*! + \brief Timestamp of the Frame Burst Start Wait event - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameBurstStartWaitTimestamp; + + //@} + + + //! \name Categories: EventFrameStartData + //@{ + /*! + \brief Unique identifier of the Frame Start event - Applies to: ace 2 GigE, ace 2 USB and ace USB + + Unique identifier of the Frame Start event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStart; + + //@} + + + //! \name Categories: EventFrameStartData + //@{ + /*! + \brief Frame ID of the Frame Start event - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartFrameID; + + //@} + + + //! \name Categories: EventFrameStartOvertriggerData + //@{ + /*! + \brief Unique identifier of the Frame Start Overtrigger event - Applies to: ace USB + + Unique identifier of the Frame Start Overtrigger event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartOvertrigger; + + //@} + + + //! \name Categories: EventFrameStartOvertriggerData + //@{ + /*! + \brief Frame ID of the Frame Start Overtrigger event - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartOvertriggerFrameID; + + //@} + + + //! \name Categories: EventFrameStartOvertriggerData + //@{ + /*! + \brief Timestamp of the Frame Start Overtrigger event - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartOvertriggerTimestamp; + + //@} + + + //! \name Categories: EventFrameStartData + //@{ + /*! + \brief Timestamp of the Frame Start event - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartTimestamp; + + //@} + + + //! \name Categories: EventFrameStartWaitData + //@{ + /*! + \brief Unique identifier of the Frame Start Wait event - Applies to: ace USB + + Unique identifier of the Frame Start Wait event. Use this parameter to get notified when the event occurs. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartWait; + + //@} + + + //! \name Categories: EventFrameStartWaitData + //@{ + /*! + \brief Timestamp of the Frame Start Wait event - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameStartWaitTimestamp; + + //@} + + + //! \name Categories: EventFrameTriggerMissedData + //@{ + /*! + \brief Unique identifier of the Frame Trigger Missed event - Applies to: ace 2 GigE and ace 2 USB + + Unique identifier of the Frame Trigger Missed event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameTriggerMissed; + + //@} + + + //! \name Categories: EventFrameTriggerMissedData + //@{ + /*! + \brief Timestamp of the Frame Trigger Missed event - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventFrameTriggerMissedTimestamp; + + //@} + + + //! \name Categories: EventControl and EventsGeneration + //@{ + /*! + \brief Enables event notifications for the currently selected event - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + Enables event notifications for the currently selected event. The event can selected using the Event Selector parameter. + + Visibility: Beginner + + Selected by: EventSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& EventNotification; + + //@} + + + //! \name Categories: EventOverTemperatureData + //@{ + /*! + \brief Unique identifier of the Over Temperature event - Applies to: ace USB + + Unique identifier of the Over Temperature event. Use this parameter to get notified when the event occurs. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverTemperature; + + //@} + + + //! \name Categories: EventOverTemperatureData + //@{ + /*! + \brief Timestamp of the Over Temperature event - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverTemperatureTimestamp; + + //@} + + + //! \name Categories: EventOverrunData + //@{ + /*! + \brief Unique identifier of the Overrun event Use this parameter to get notified when the event occurs - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverrun; + + //@} + + + //! \name Categories: EventOverrunEventData + //@{ + /*! + \brief Frame ID of the Event Overrun event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverrunEventFrameID; + + //@} + + + //! \name Categories: EventOverrunEventData + //@{ + /*! + \brief Stream channel index of the Event Overrun event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverrunEventStreamChannelIndex; + + //@} + + + //! \name Categories: EventOverrunEventData + //@{ + /*! + \brief Timestamp of the Event Overrun event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverrunEventTimestamp; + + //@} + + + //! \name Categories: EventOverrunData + //@{ + /*! + \brief Timestamp of the Event Overrun event - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventOverrunTimestamp; + + //@} + + + //! \name Categories: EventControl and EventsGeneration + //@{ + /*! + \brief Sets the event notification to be enabled - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + Sets the event notification to be enabled. The notification can be enabled using the Event Notification parameter. + + Visibility: Beginner + + Selecting Parameters: EventNotification + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& EventSelector; + + //@} + + + //! \name Categories: EventTemperatureStatusChangedData + //@{ + /*! + \brief Unique identifier of the Temperature Status Changed event - Applies to: ace 2 GigE and ace 2 USB + + Unique identifier of the Temperature Status Changed event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventTemperatureStatusChanged; + + //@} + + + //! \name Categories: EventTemperatureStatusChangedData + //@{ + /*! + \brief New temperature status that applies after the Temperature Status Changed event was raised - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& EventTemperatureStatusChangedStatus; + + //@} + + + //! \name Categories: EventTemperatureStatusChangedData + //@{ + /*! + \brief Timestamp of the Temperature Status Changed event - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventTemperatureStatusChangedTimestamp; + + //@} + + + //! \name Categories: EventTestData + //@{ + /*! + \brief Unique identifier of the Test event - Applies to: ace 2 GigE and ace 2 USB + + Unique identifier of the Test event. Use this parameter to get notified when the event occurs. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventTest; + + //@} + + + //! \name Categories: EventTestData + //@{ + /*! + \brief Timestamp of the test event - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventTestTimestamp; + + //@} + + + //! \name Categories: ExpertFeatureAccess + //@{ + /*! + \brief Key for making the selected expert feature available - Applies to: CameraLink, GigE and ace USB + + + Visibility: Guru + + Selected by: ExpertFeatureAccessSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExpertFeatureAccessKey; + + //@} + + + //! \name Categories: ExpertFeatureAccess + //@{ + /*! + \brief Sets the expert feature to be made available - Applies to: CameraLink, GigE and ace USB + + Sets the expert feature to be made available. All changes will be applied to the selected feature. + + Visibility: Guru + + Selecting Parameters: ExpertFeatureAccessKey and ExpertFeatureEnable + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ExpertFeatureAccessSelector; + + //@} + + + //! \name Categories: ExpertFeatureAccess + //@{ + /*! + \brief Enables the currently selected expert feature - Applies to: CameraLink, GigE and ace USB + + + Visibility: Guru + + Selected by: ExpertFeatureAccessSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ExpertFeatureEnable; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the operation mode of the Exposure Auto auto function - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Sets the operation mode of the Exposure Auto auto function. The Exposure Auto auto function automatically adjusts the exposure time within set limits until a target brightness value has been reached. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ExposureAuto; + + //@} + + + //! \name Categories: ExposureEndEventData + //@{ + /*! + \brief Frame ID of the Exposure End event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExposureEndEventFrameID; + + //@} + + + //! \name Categories: ExposureEndEventData + //@{ + /*! + \brief Stream channel index of the Exposure End event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExposureEndEventStreamChannelIndex; + + //@} + + + //! \name Categories: ExposureEndEventData + //@{ + /*! + \brief Timestamp of the Exposure End event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExposureEndEventTimestamp; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the exposure mode - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ExposureMode; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Maximum overlap of the sensor exposure with sensor readout in Trigger Width exposure mode (in microseconds) - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ExposureOverlapTimeMax; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Maximum overlap of the sensor exposure with sensor readout in Trigger Width exposure mode (in microseconds) - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ExposureOverlapTimeMaxAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Maximum overlap of the sensor exposure with sensor readout in Trigger Width exposure mode (raw value) - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExposureOverlapTimeMaxRaw; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the exposure overlap time mode - Applies to: GigE and ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ExposureOverlapTimeMode; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ExposureStartDelayAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExposureStartDelayRaw; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Exposure time of the camera in microseconds - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ExposureTime; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Exposure time of the camera in microseconds - Applies to: CamEmu, CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ExposureTimeAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Timebase (in microseconds) that the camera uses when the exposure time is specified using the Exposure Time (Raw) parameter - Applies to: CamEmu, CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ExposureTimeBaseAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Enables the use of the exposure timebase - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ExposureTimeBaseAbsEnable; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the exposure time mode - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ExposureTimeMode; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Exposure time of the camera (raw value) - Applies to: CamEmu, CameraLink and GigE + + Exposure time of the camera (raw value). The actual exposure time equals the current Exposure Time (Raw) value multiplied with the current Exposure Timebase value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ExposureTimeRaw; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Enables the fast mode - Applies to: blaze + + The fast mode can be used to achieve the maximum frame rate, but this reduces image quality and measurement accuracy. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& FastMode; + + //@} + + + //! \name Categories: FeatureSets + //@{ + /*! + \brief Sets the default GenICam XML file - Applies to: CameraLink and GigE + + Sets the default GenICam XML file. If the camera has multiple GenICam XML files, this parameter determines which of them is accessible to non-manifest-aware software. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FeatureSet; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Selects the mode to output the fields - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FieldOutputMode; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Access buffer for file operations - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IRegisterEx& FileAccessBuffer; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Number of bytes read from the file into the file access buffer or written to the file from the file access buffer - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileOperationSelector and FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FileAccessLength; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Number of bytes after which FileAccessLength bytes are read from the file into the file access buffer or are written to the file from the file access buffer - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileOperationSelector and FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FileAccessOffset; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Sets the access mode in which a file is opened in the camera - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Beginner + + Selected by: FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FileOpenMode; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Executes the operation selected by File Operation Selector parameter - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileOperationSelector and FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& FileOperationExecute; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief File operation result - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileOperationSelector and FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FileOperationResult; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Sets the target operation for the currently selected file - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileSelector + + Selecting Parameters: FileAccessLength, FileAccessOffset, FileOperationExecute, FileOperationResult and FileOperationStatus + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FileOperationSelector; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Indicates the file operation execution status - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileOperationSelector and FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FileOperationStatus; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Sets the target file in the camera - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selecting Parameters: FileAccessBuffer, FileAccessLength, FileAccessOffset, FileOpenMode, FileOperationExecute, FileOperationResult, FileOperationSelector, FileOperationStatus and FileSize + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FileSelector; + + //@} + + + //! \name Categories: FileAccessControl + //@{ + /*! + \brief Size of the currently selected file in bytes - Applies to: CameraLink, GigE and ace USB + + Basler advises against using this parameter. Use the appropriate feature for file access operations instead. + + Visibility: Guru + + Selected by: FileSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FileSize; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Enables the spatial noise filter - Applies to: blaze + + The spatial noise filter uses the values of neighboring pixels to filter out noise in an image. It is based on the raw data of the image. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& FilterSpatial; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Strength of the temporal filter - Applies to: blaze + + Strength of the temporal filter. The higher the value, the further back the memory of the filter reaches. High values can cause motion artifacts, while low values reduce the efficacy of the filter. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FilterStrength; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Enables the temporal noise filter - Applies to: blaze + + The temporal noise filter uses the values of the same pixel at different points in time to filter out noise in an image. It is based on the depth data of the image. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& FilterTemporal; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Marks the next buffer as failed - Applies to: CamEmu + + Marks the next buffer as a failed buffer. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& ForceFailedBuffer; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Number of failed buffers to generate - Applies to: CamEmu + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ForceFailedBufferCount; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Total time required for exposing and reading out all subframes from the sensor - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameDuration; + + //@} + + + //! \name Categories: FrameStartEventData + //@{ + /*! + \brief Stream channel index of the Frame Start event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameStartEventStreamChannelIndex; + + //@} + + + //! \name Categories: FrameStartEventData + //@{ + /*! + \brief Timestamp of the Frame Start event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameStartEventTimestamp; + + //@} + + + //! \name Categories: FrameStartOvertriggerEventData + //@{ + /*! + \brief Stream channel index of the Frame Start Overtrigger event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameStartOvertriggerEventStreamChannelIndex; + + //@} + + + //! \name Categories: FrameStartOvertriggerEventData + //@{ + /*! + \brief Timestamp of the Frame Start Overtrigger event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameStartOvertriggerEventTimestamp; + + //@} + + + //! \name Categories: FrameStartWaitEventData + //@{ + /*! + \brief Stream channel index of the Frame Start Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameStartWaitEventStreamChannelIndex; + + //@} + + + //! \name Categories: FrameStartWaitEventData + //@{ + /*! + \brief Timestamp of the Frame Start Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameStartWaitEventTimestamp; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Frame timeout in microseconds - Applies to: CameraLink and GigE + + Frame timeout in microseconds. If the timeout expires before a frame acquisition is complete, a partial frame will be delivered. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& FrameTimeoutAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Enables the frame timeout - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& FrameTimeoutEnable; + + //@} + + + //! \name Categories: FrameTimeoutEventData + //@{ + /*! + \brief Stream channel index of the Frame Timeout event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameTimeoutEventStreamChannelIndex; + + //@} + + + //! \name Categories: FrameTimeoutEventData + //@{ + /*! + \brief Timestamp of the Frame Timeout event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameTimeoutEventTimestamp; + + //@} + + + //! \name Categories: FrameWaitEventData + //@{ + /*! + \brief Stream channel index of the Frame Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameWaitEventStreamChannelIndex; + + //@} + + + //! \name Categories: FrameWaitEventData + //@{ + /*! + \brief Timestamp of the Frame Wait event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameWaitEventTimestamp; + + //@} + + + //! \name Categories: FrequencyConverter + //@{ + /*! + \brief Sets the input source - Applies to: CameraLink and GigE + + Sets the input source for the frequency converter module. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FrequencyConverterInputSource; + + //@} + + + //! \name Categories: FrequencyConverter + //@{ + /*! + \brief Multiplication factor to be applied to the input signal frequency - Applies to: CameraLink and GigE + + Multiplication factor to be applied to the input signal frequency. The multiplication factor allows the generation of signals at higher frequencies. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrequencyConverterMultiplier; + + //@} + + + //! \name Categories: FrequencyConverter + //@{ + /*! + \brief Post-divider value to decrease input signal frequency - Applies to: CameraLink and GigE + + Post-divider value to decrease input signal frequency. Determines the frequency with which input signals received from the multiplier sub-module are passed on. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrequencyConverterPostDivider; + + //@} + + + //! \name Categories: FrequencyConverter + //@{ + /*! + \brief Pre-divider value to decrease signal frequency - Applies to: CameraLink and GigE + + Pre-divider value to decrease signal frequency. Determines the frequency with which input signals are passed to the multiplier sub-module. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrequencyConverterPreDivider; + + //@} + + + //! \name Categories: FrequencyConverter + //@{ + /*! + \brief Enables overtriggering protection - Applies to: CameraLink and GigE + + Enables overtriggering protection. This ensures that the multiplier sub-module doesn't generate too many signals within a certain amount of time. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& FrequencyConverterPreventOvertrigger; + + //@} + + + //! \name Categories: FrequencyConverter + //@{ + /*! + \brief Sets the signal transition relationships between received and generated signals - Applies to: CameraLink and GigE + + Sets the signal transition relationships between the signals received from the pre-divider sub-module and the signals generated by the multiplier sub-module. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& FrequencyConverterSignalAlignment; + + //@} + + + //! \name Categories: AnalogControl + //@{ + /*! + \brief Value of the currently selected gain in dB - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: GainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Gain; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief This is a float value that sets the selected gain control in dB - Applies to: CameraLink and GigE + + Sets the 'absolute' value of the selected gain control. The 'absolute' value is a float value that sets the selected gain control in dB. + + Visibility: Beginner + + Selected by: GainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& GainAbs; + + //@} + + + //! \name Categories: AnalogControl and AnalogControls + //@{ + /*! + \brief Sets the operation mode of the Gain Auto auto function - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Sets the operation mode of the Gain Auto auto function. The Gain Auto auto function automatically adjusts the gain within set limits until a target brightness value has been reached. + + Visibility: Beginner + + Selected by: GainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GainAuto; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief Value of the currently selected gain (raw value) - Applies to: CamEmu, CameraLink and GigE + + + Visibility: Beginner + + Selected by: GainSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GainRaw; + + //@} + + + //! \name Categories: AnalogControl and AnalogControls + //@{ + /*! + \brief Sets the gain type to be adjusted - Applies to: CameraLink, GigE, ace USB, dart BCON, dart USB and pulse USB + + Sets the gain type to be adjusted. All changes to the Gain parameter will be applied to the selected gain type. + + Visibility: Beginner + + Selecting Parameters: AutoGainLowerLimit, AutoGainUpperLimit, Gain, GainAbs, GainAuto and GainRaw + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GainSelector; + + //@} + + + //! \name Categories: AnalogControl and AnalogControls + //@{ + /*! + \brief Gamma correction to be applied - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Gamma correction to be applied. Gamma correction allows you to optimize the brightness of acquired images for display on a monitor. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Gamma; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Enables gamma correction on the intensity image - Applies to: blaze + + A nonlinear operation to lighten the dark regions of the image. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GammaCorrection; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief Enables gamma correction - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GammaEnable; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief Sets the type of gamma to be applied - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GammaSelector; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Controls the device's streaming format - Applies to: blaze + + + Visibility: Invisible + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GenDCStreamingMode; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Returns whether the current device data streaming format is GenDC - Applies to: blaze + + Returns whether the current device data streaming format is GenDC. This value is conditioned by the GenDCStreamingMode. + + Visibility: Invisible + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GenDCStreamingStatus; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the control channel privilege - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GevCCP; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Current default gateway of the selected network interface - Applies to: GigE and blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevCurrentDefaultGateway; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Current IP address of the selected network interface - Applies to: GigE and blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevCurrentIPAddress; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Current IP configuration of the selected network interface - Applies to: GigE + + Current IP configuration of the selected network interface, e.g., fixed IP, DHCP, or auto IP. + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevCurrentIPConfiguration; + + //@} + + + //! \name Categories: GigEVision + //@{ + /*! + \brief Controls whether the DHCP IP configuration scheme is activated on the given logical link - Applies to: blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevCurrentIPConfigurationDHCP; + + //@} + + + //! \name Categories: GigEVision + //@{ + /*! + \brief Controls whether the Link Local Address IP configuration scheme is activated on the given logical link - Applies to: blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevCurrentIPConfigurationLLA; + + //@} + + + //! \name Categories: GigEVision + //@{ + /*! + \brief Controls whether the PersistentIP configuration scheme is activated on the given logical link - Applies to: blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevCurrentIPConfigurationPersistentIP; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Current subnet mask of the selected network interface - Applies to: GigE and blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevCurrentSubnetMask; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Character set used by all strings of the bootstrap registers - Applies to: GigE + + Character set used by all strings of the bootstrap registers (1 = UTF8). + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceModeCharacterSet; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the bootstrap register is in big-endian format - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevDeviceModeIsBigEndian; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief First URL reference to the GenICam XML file - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& GevFirstURL; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the Extended ID mode for GVSP - Applies to: GigE + + Sets the Extended ID mode for GVSP (64-bit block ID, 32-bit packet ID). This bit can't be reset if the stream channels do not support the standard ID mode. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GevGVSPExtendedIDMode; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Heartbeat timeout in milliseconds - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevHeartbeatTimeout; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Enables the IEEE 1588 V2 Precision Time Protocol for the timestamp register - Applies to: GigE + + Enables the IEEE 1588 V2 Precision Time Protocol for the timestamp register. Only available if the IEEE1588_support bit of the GVCP Capability register is set. When PTP is enabled, the Timestamp Control register can't be used to reset the timestamp. When PTP is enabled or disabled, the value of Timestamp Tick Frequency and Timestamp Value registers may change to reflect the new time domain. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevIEEE1588; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Latched IEEE 1588 clock ID of the camera - Applies to: GigE + + Latched IEEE 1588 clock ID of the camera. (The clock ID must first be latched using the IEEE 1588 Latch command.) The clock ID is an array of eight octets which is displayed as a hexadecimal number. Leading zeros are omitted. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevIEEE1588ClockId; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Latches the current IEEE 1588-related values of the camera - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& GevIEEE1588DataSetLatch; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Latched offset from the IEEE 1588 master clock in nanoseconds - Applies to: GigE + + Latched offset from the IEEE 1588 master clock in nanoseconds. (The offset must first be latched using the IEEE 1588 Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevIEEE1588OffsetFromMaster; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Latched IEEE 1588 parent clock ID of the camera - Applies to: GigE + + Latched IEEE 1588 parent clock ID of the camera. (The parent clock ID must first be latched using the IEEE 1588 Latch command.) The parent clock ID is the clock ID of the current master clock. A clock ID is an array of eight octets which is displayed as a hexadecimal number. Leading zeros are omitted. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevIEEE1588ParentClockId; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates the state of the IEEE 1588 clock - Applies to: GigE + + Indicates the state of the IEEE 1588 clock. Values of this field must match the IEEE 1588 PTP port state enumeration (INITIALIZING, FAULTY, DISABLED, LISTENING, PRE_MASTER, MASTER, PASSIVE, UNCALIBRATED, SLAVE). + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GevIEEE1588Status; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates the latched state of the IEEE 1588 clock - Applies to: GigE + + Indicates the latched state of the IEEE 1588 clock. (The state must first be latched using the IEEE 1588 Latch command.) The state is indicated by values 1 to 9, corresponding to the states INITIALIZING, FAULTY, DISABLED, LISTENING, PRE_MASTER, MASTER, PASSIVE, UNCALIBRATED, and SLAVE. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GevIEEE1588StatusLatched; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the physical network interface to be configured - Applies to: GigE + + Sets the physical network interface to be configured. All changes to the network interface settings will be applied to the selected interface. + + Visibility: Guru + + Selecting Parameters: GevCurrentDefaultGateway, GevCurrentIPAddress, GevCurrentIPConfiguration, GevCurrentSubnetMask, GevLinkCrossover, GevLinkFullDuplex, GevLinkMaster, GevLinkSpeed, GevMACAddress, GevPersistentDefaultGateway, GevPersistentIPAddress, GevPersistentSubnetMask, GevSupportedIPConfigurationDHCP, GevSupportedIPConfigurationLLA, GevSupportedIPConfigurationPersistentIP and GevSupportedOptionalLegacy16BitBlockID + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GevInterfaceSelector; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates the state of medium-dependent interface crossover (MDIX) for the selected network interface - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevLinkCrossover; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the selected network interface operates in full-duplex mode - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevLinkFullDuplex; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the selected network interface is the clock master - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevLinkMaster; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Connection speed in Mbps of the selected network interface - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevLinkSpeed; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief MAC address of the selected network interface - Applies to: GigE and blaze + + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevMACAddress; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Number of message channels supported by the camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevMessageChannelCount; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Number of network interfaces of the camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevNumberOfInterfaces; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Applies to: GigE + + This is a read only element. Maximum number of elements in RX event message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPTPDiagnosticsQueueRxEvntMaxNumElements; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Applies to: GigE + + This is a read only element. Number of push failures in RX event message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPTPDiagnosticsQueueRxEvntPushNumFailure; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Applies to: GigE + + This is a read only element. Maximum number of elements in RX general message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPTPDiagnosticsQueueRxGnrlMaxNumElements; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Applies to: GigE + + This is a read only element. Number of push failures in RX general message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPTPDiagnosticsQueueRxGnrlPushNumFailure; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Applies to: GigE + + This is a read only element. Number of send failures. (The value must first be latched using the IEEE 1588 Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPTPDiagnosticsQueueSendNumFailure; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Fixed default gateway of the selected network interface - Applies to: GigE and blaze + + Fixed default gateway of the selected network interface (if fixed IP addressing is supported by the camera and enabled). + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPersistentDefaultGateway; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Fixed IP address of the selected network interface - Applies to: GigE and blaze + + Fixed IP address of the selected network interface (if fixed IP addressing is supported by the camera and enabled). + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPersistentIPAddress; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Fixed subnet mask of the selected network interface - Applies to: GigE and blaze + + Fixed subnet mask of the selected network interface (if fixed IP addressing is supported by the camera and enabled). + + Visibility: Beginner + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevPersistentSubnetMask; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Base bandwidth in bytes per second that will be used by the camera to transmit image and chunk feature data and to handle resends and control data transmissions - Applies to: GigE + + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCBWA; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Percentage of the Ethernet bandwidth assigned to the camera to be held in reserve - Applies to: GigE and ace 2 GigE + + Percentage of the Ethernet bandwidth assigned to the camera to be held in reserve for packet resends and for the transmission of control data between the camera and the host computer. The setting is expressed as a percentage of the Bandwidth Assigned parameter. For example, if the Bandwidth Assigned parameter indicates that 30 MBytes/s have been assigned to the camera and the Bandwidth Reserve parameter is set to 5 %, the bandwidth reserve will be 1.5 MBytes/s. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCBWR; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Multiplier for the Bandwidth Reserve parameter - Applies to: GigE and ace 2 GigE + + Multiplier for the Bandwidth Reserve parameter. The multiplier is used to establish an extra pool of reserved bandwidth that can be used if an unusually large burst of packet resends is needed. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCBWRA; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Destination address of the selected stream channel - Applies to: GigE + + Destination address of the selected stream channel. The destination can be a unicast or a multicast address. + + Visibility: Guru + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCDA; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data - Applies to: GigE + + Actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data with the current settings for AOI, chunk features, and pixel format. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCDCT; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Maximum amount of data (in bytes per second) that the camera can generate - Applies to: GigE + + Maximum amount of data (in bytes per second) that the camera can generate with its current settings under ideal conditions, i.e., unlimited bandwidth and no packet resends. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCDMT; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Maximum amount of time (in ticks) that the next frame transmission could be delayed due to a burst of resends - Applies to: GigE + + Maximum amount of time (in ticks) that the next frame transmission could be delayed due to a burst of resends. If the Bandwidth Reserve Accumulation parameter is set to a high value, the camera can experience periods where there is a large burst of data resends. This burst of resends will delay the start of transmission of the next acquired image. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCFJM; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Frame transmission delay on the selected stream channel - Applies to: GigE and ace 2 GigE + + Frame transmission delay on the selected stream channel (in ticks). This value sets a delay before transmitting the acquired image. + + Visibility: Expert + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCFTD; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Delay between the transmission of each packet on the selected stream channel - Applies to: GigE and ace 2 GigE + + Delay between the transmission of each packet on the selected stream channel. The delay is measured in ticks. + + Visibility: Beginner + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCPD; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Destination port of the selected stream channel - Applies to: GigE + + + Visibility: Guru + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCPHostPort; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Index of the network interface to be used - Applies to: GigE + + + Visibility: Guru + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCPInterfaceIndex; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates the endianness of multi-byte pixel data for this stream - Applies to: GigE + + Indicates the endianness of multi-byte pixel data for this stream. True equals big-endian. + + Visibility: Guru + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSCPSBigEndian; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Disables IP fragmentation of packets on the stream channel - Applies to: GigE + + Disables IP fragmentation of packets on the stream channel. This bit is copied into the 'do not fragment' bit of the IP header of each stream packet. + + Visibility: Guru + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSCPSDoNotFragment; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sends a GigE Vision streaming test packet - Applies to: GigE + + Sends a GigE Vision streaming test packet. If this bit is set and the stream channel is a transmitter, the transmitter will send one test packet of the size specified by the Packet Size parameter. The 'do not fragment' bit of the IP header must be set for this test packet (see the SCPS Do Not Fragment parameter documentation). + + Visibility: Guru + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& GevSCPSFireTestPacket; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Packet size in bytes on the selected stream channel Excludes data leader and data trailer - Applies to: GigE, ace 2 GigE and blaze + + Packet size in bytes on the selected stream channel. Excludes data leader and data trailer. (The last packet may be smaller because the packet size is not necessarily a multiple of the block size of the stream channel.) + + Visibility: Beginner + + Selected by: GevStreamChannelSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevSCPSPacketSize; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Second URL reference to the GenICam XML file - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& GevSecondURL; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Number of stream channels supported by the camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevStreamChannelCount; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Sets the stream channel to be configured - Applies to: GigE + + Sets the stream channels to be configured. All changes to the stream channel settings will be applied to the selected stream channel. + + Visibility: Guru + + Selecting Parameters: GevGVSPExtendedIDMode, GevSCBWA, GevSCBWR, GevSCBWRA, GevSCDA, GevSCDCT, GevSCDMT, GevSCFJM, GevSCFTD, GevSCPD, GevSCPHostPort, GevSCPInterfaceIndex, GevSCPSBigEndian, GevSCPSDoNotFragment, GevSCPSFireTestPacket and GevSCPSPacketSize + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& GevStreamChannelSelector; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the IEEE 1588 V2 Precision Time Protocol (PTP) is supported - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedIEEE1588; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the selected network interface supports DHCP IP addressing - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedIPConfigurationDHCP; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the selected network interface supports auto IP addressing (also known as LLA) - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedIPConfigurationLLA; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether the selected network interface supports fixed IP addressing (also known as persistent IP addressing) - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedIPConfigurationPersistentIP; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether multiple operations in a single message are supported - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedOptionalCommandsConcatenation; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether EVENT_CMD and EVENT_ACK are supported - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedOptionalCommandsEVENT; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether EVENTDATA_CMD and EVENTDATA_ACK are supported - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedOptionalCommandsEVENTDATA; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether PACKETRESEND_CMD is supported - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedOptionalCommandsPACKETRESEND; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether WRITEMEM_CMD and WRITEMEM_ACK are supported - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedOptionalCommandsWRITEMEM; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Indicates whether this GVSP transmitter or receiver can support a 16-bit block ID - Applies to: GigE + + + Visibility: Guru + + Selected by: GevInterfaceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& GevSupportedOptionalLegacy16BitBlockID; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Latches the current timestamp value of the camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& GevTimestampControlLatch; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Resets the timestamp control latch - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& GevTimestampControlLatchReset; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Resets the timestamp value of the camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& GevTimestampControlReset; + + //@} + + + //! \name Categories: GigEVision and TransportLayer + //@{ + /*! + \brief Number of timestamp clock ticks in 1 second - Applies to: GigE, ace 2 GigE and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevTimestampTickFrequency; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Latched value of the timestamp - Applies to: GigE + + Latched value of the timestamp. (The timestamp must first be latched using the Timestamp Control Latch command.) + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevTimestampValue; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Major version number of the GigE Vision specification supported by this camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevVersionMajor; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Minor version number of the GigE Vision specification supported by this camera - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevVersionMinor; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Gray value adjustment damping factor to be applied - Applies to: CameraLink and GigE + + Gray value adjustment damping factor to be applied. This controls the speed with which pixel gray values are changed when Exposure Auto, Gain Auto, or both are enabled. This can be useful, for example, when objects move into the camera's field of view and the light conditions are changing gradually due to the moving objects. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& GrayValueAdjustmentDampingAbs; + + //@} + + + //! \name Categories: AutoFunctions + //@{ + /*! + \brief Gray value adjustment damping factor (raw value) to be applied - Applies to: CameraLink and GigE + + Gray value adjustment damping factor (raw value) to be applied. This controls the speed with which pixel gray values are changed when Exposure Auto, Gain Auto, or both are enabled. This can be useful, for example, when objects move into the camera's field of view and the light conditions are changing gradually due to the moving objects. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GrayValueAdjustmentDampingRaw; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Height of the camera's region of interest (area of interest) in pixels - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Height of the camera's region of interest (area of interest) in pixels. Depending on the camera model, the parameter can be set in different increments. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Height; + + //@} + + + //! \name Categories: AOI, DeviceInformation and ImageFormatControl + //@{ + /*! + \brief Maximum height of the region of interest (area of interest) in pixels - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Maximum height of the region of interest (area of interest) in pixels. The value takes into account any features that may limit the maximum height, e.g., binning. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& HeightMax; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Stream ID of the first image stream - Applies to: boost CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Image1StreamID; + + //@} + + + //! \name Categories: ImageCompression + //@{ + /*! + \brief Sets the compression mode of the camera - Applies to: ace 2 GigE and ace 2 USB + + Sets the image compression mode of the camera. The available image compression modes depend on the selected pixel format. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ImageCompressionMode; + + //@} + + + //! \name Categories: ImageCompression + //@{ + /*! + \brief Configures the selected compression mechanism - Applies to: ace 2 GigE and ace 2 USB + + Configures the selected compression mechanism. The available options depend on the selected pixel format and the image compression mode. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ImageCompressionRateOption; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Enables loading files from disk for image acquisition - Applies to: CamEmu + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ImageFileMode; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Enter the name of an image filename or a path to a directory containing image files - Applies to: CamEmu + + Enter the name of an image filename in a format supported by pylon or the path to a directory containing image files. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& ImageFilename; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Sets the method for calculating the intensity data - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& IntensityCalculation; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Selects the Interlaced Integration Mode - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& InterlacedIntegrationMode; + + //@} + + + //! \name Categories: LUTControl and LUTControls + //@{ + /*! + \brief Enables the selected lookup table (LUT) - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + + Visibility: Beginner + + Selected by: LUTSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& LUTEnable; + + //@} + + + //! \name Categories: LUTControl and LUTControls + //@{ + /*! + \brief Pixel value to be replaced with the LUT Value pixel value - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + + Visibility: Beginner + + Selected by: LUTSelector + + Selecting Parameters: LUTValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LUTIndex; + + //@} + + + //! \name Categories: LUTControl and LUTControls + //@{ + /*! + \brief Sets the lookup table (LUT) to be configured - Applies to: CameraLink, GigE and ace USB + + Sets the lookup table (LUT) to be configured. All changes to the LUT settings will be applied to the selected LUT. + + Visibility: Beginner + + Selecting Parameters: LUTEnable, LUTIndex, LUTValue and LUTValueAll + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LUTSelector; + + //@} + + + //! \name Categories: LUTControl and LUTControls + //@{ + /*! + \brief New pixel value to replace the LUT Index pixel value - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + + Visibility: Beginner + + Selected by: LUTIndex and LUTSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LUTValue; + + //@} + + + //! \name Categories: LUTControl and LUTControls + //@{ + /*! + \brief A single register that lets you access all LUT entries - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB and boost CoaXPress + + A single register that lets you access all LUT entries. In many cases, this is faster than repeatedly changing individual entries in the LUT. + + Visibility: Beginner + + Selected by: LUTSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IRegisterEx& LUTValueAll; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Indicates the last error code in the memory - Applies to: CameraLink, GigE and blaze + + Indicates the last error code in the memory. To delete the last error code from the list of error codes, use the Clear Last Error command. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LastError; + + //@} + + + //! \name Categories: LateActionEventData + //@{ + /*! + \brief Stream channel index of the Action Late event - Applies to: GigE + + Stream channel index of the Action Late event. An Action Late event is raised when a scheduled action command with a timestamp in the past is received. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LateActionEventStreamChannelIndex; + + //@} + + + //! \name Categories: LateActionEventData + //@{ + /*! + \brief Timestamp of the Action Late event - Applies to: GigE + + Timestamp of the Action Late event. An Action Late event is raised when a scheduled action command with a timestamp in the past is received. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LateActionEventTimestamp; + + //@} + + + //! \name Categories: AOI + //@{ + /*! + \brief Sets whether vertical binning is used - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LegacyBinningVertical; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Sets the light source preset - Applies to: ace USB, dart BCON, dart USB and pulse USB + + Sets the light source preset. The colors in the image will be corrected so that they are appropriate for the selected light source. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LightSourcePreset; + + //@} + + + //! \name Categories: ColorImprovementsControl and ImageQualityControl + //@{ + /*! + \brief Sets the type of light source for which color transformation will be performed - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selected by: ColorTransformationSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LightSourceSelector; + + //@} + + + //! \name Categories: Line1RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Line 1 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line1RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: Line1RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Line 1 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line1RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: Line2RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Line 2 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line2RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: Line2RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Line 2 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line2RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: Line3RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Line 3 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line3RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: Line3RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Line 3 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line3RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: Line4RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Line 4 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line4RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: Line4RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Line 4 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Line4RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Line debouncer time in microseconds - Applies to: ace USB, dart BCON and dart USB + + Line debouncer time in microseconds. The Line Debouncer allows you to filter out invalid hardware signals by specifying a minimum signal length. + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& LineDebouncerTime; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Line debouncer time in microseconds - Applies to: CameraLink and GigE + + Line debouncer time in microseconds. The Line Debouncer allows you to filter out invalid hardware signals by specifying a minimum signal length. + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& LineDebouncerTimeAbs; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Indicates the electrical configuration of the currently selected line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LineFormat; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Enables the signal inverter function for the currently selected input or output line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& LineInverter; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Indicates the line logic of the currently selected line - Applies to: CameraLink, GigE and ace USB + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LineLogic; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Minimum signal width of an output signal (in microseconds) - Applies to: ace USB + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& LineMinimumOutputPulseWidth; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Sets the mode for the selected line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + Sets the mode for the selected line. This controls whether the physical line is used to input or output a signal. + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LineMode; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Resets the overload status of the selected line - Applies to: ace USB + + This command resets the overload status of the selected line. If the overload condition is still fulfilled, the overload status will be set again immediately. + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& LineOverloadReset; + + //@} + + + //! \name Categories: DigitalIOControl + //@{ + /*! + \brief Indicates whether an overload condition has been detected on the selected line - Applies to: ace USB + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& LineOverloadStatus; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Number of bytes separating the starting pixels of two consecutive lines - Applies to: ace USB + + Number of bytes separating the starting pixels of two consecutive lines. This feature is useful if you want to align your image data to fixed-size groups of digits, e.g., to 4-byte (32-bit) or 8-byte (64-bit) words. Data alignment can improve performance. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LinePitch; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Enables the alignment of output image data to multiples of 4 bytes - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& LinePitchEnable; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Sets the I/O line to be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + Sets the I/O line to be configured. All changes to the line settings will be applied to the selected line. + + Visibility: Beginner + + Selecting Parameters: BslInputFilterTime, BslInputHoldOffTime, BslLineOverloadStatus, LineDebouncerTime, LineDebouncerTimeAbs, LineFormat, LineInverter, LineLogic, LineMinimumOutputPulseWidth, LineMode, LineOverloadReset, LineOverloadStatus, LineSource, LineStatus, LineTermination and MinOutPulseWidthAbs + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LineSelector; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Sets the source signal for the currently selected line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + Sets the source signal for the currently selected line. The currently selected line must be an output line. + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& LineSource; + + //@} + + + //! \name Categories: LineStartOvertriggerEventData + //@{ + /*! + \brief Stream channel index of the Line Start Overtrigger event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LineStartOvertriggerEventStreamChannelIndex; + + //@} + + + //! \name Categories: LineStartOvertriggerEventData + //@{ + /*! + \brief Timestamp of the Line Start Overtrigger event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LineStartOvertriggerEventTimestamp; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Indicates the current logical state of the selected line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& LineStatus; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Single bit field indicating the current logical state of all available line signals at time of polling - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LineStatusAll; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Enables the termination resistor of the selected input line - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& LineTermination; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Minimum signal width of an output signal (in microseconds) - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: LineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& MinOutPulseWidthAbs; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Operating channel of the camera - Applies to: blaze + + Operating channel of the camera. In multi-camera setups, use a different channel on each camera. This ensures that the cameras are operating at different frequencies and their light sources will not interfere with the other cameras' light sources. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MultiCameraChannel; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Amount of noise reduction to be applied - Applies to: ace USB + + Amount of noise reduction to be applied. The higher the value, the less chroma noise will be visible in your images. However, excessively high values may result in image information loss. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& NoiseReduction; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Amount of noise reduction to be applied - Applies to: GigE + + Amount of noise reduction to be applied. The higher the value, the less chroma noise will be visible in your images. However, excessively high values may result in image information loss. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& NoiseReductionAbs; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Amount of noise reduction to be applied (raw value) - Applies to: GigE + + Amount of noise reduction to be applied (raw value). The higher the value, the less chroma noise will be visible in your images. However, excessively high values may result in image information loss. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& NoiseReductionRaw; + + //@} + + + //! \name Categories: ActionControl + //@{ + /*! + \brief Number of separate action signals supported by the camera - Applies to: GigE + + Number of separate action signals supported by the camera. Determines how many action signals the camera can handle in parallel, i.e., how many different action commands can be configured on the camera. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& NumberOfActionSignals; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Horizontal offset of the region of interest (area of interest) from the left side of the sensor (in pixels) - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Horizontal offset from the left side of the sensor to the region of interest (area of interest) (in pixels). + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& OffsetX; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Vertical offset of the region of interest (area of interest) from the top of the sensor (in pixels) - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Vertical offset from the top of the sensor to the region of interest (area of interest) (in pixels). + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& OffsetY; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Sets the operating mode of the camera - Applies to: blaze + + Sets the operating mode of the camera. The choice you make here, affects the working range of the camera, i.e., the Minimum Working Range and Maximum Working Range parameters. If the operating mode is changed, the exposure time is set to the recommended default value. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& OperatingMode; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Enables the outlier removal - Applies to: blaze + + Removes pixels that differ significantly from their local environment. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& OutlierRemoval; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Indicates whether an over temperature state has been detected - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& OverTemperature; + + //@} + + + //! \name Categories: OverTemperatureEventData + //@{ + /*! + \brief Stream channel index of the Over Temperature event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& OverTemperatureEventStreamChannelIndex; + + //@} + + + //! \name Categories: OverTemperatureEventData + //@{ + /*! + \brief Timestamp of the Over Temperature event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& OverTemperatureEventTimestamp; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Configures overlapping exposure and image readout - Applies to: dart BCON, dart USB and pulse USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& OverlapMode; + + //@} + + + //! \name Categories: RemoveParamLimits + //@{ + /*! + \brief Sets the parameter whose factory limits can be removed - Applies to: CameraLink and GigE + + Sets the parameter whose factory limits can be removed. The factory limits can be removed using the Remove Limits parameter. + + Visibility: Guru + + Selecting Parameters: RemoveLimits + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ParameterSelector; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: dart USB and pulse USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadFinalTransfer1Size; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: dart USB and pulse USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadFinalTransfer2Size; + + //@} + + + //! \name Categories: TransportLayer and TransportLayerControl + //@{ + /*! + \brief Size of the payload in bytes - Applies to: CamEmu, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart USB and pulse USB + + Size of the payload in bytes. This is the total number of bytes sent in the payload. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadSize; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief This parameter is required when using the sequencer - Applies to: ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadTransferBlockDelay; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: dart USB and pulse USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadTransferCount; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: dart USB and pulse USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadTransferSize; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Enables Basler PGI image optimizations - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PgiMode; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Sets the color coding of the pixels in the acquired images - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PixelCoding; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Indicates the alignment of the camera's Bayer filter to the pixels in the acquired images - Applies to: CameraLink, GigE, ace USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PixelColorFilter; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Maximum possible pixel value that can be transferred from the camera - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PixelDynamicRangeMax; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Minimum possible pixel value that can be transferred from the camera - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PixelDynamicRangeMin; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Sets the format of the pixel data transmitted by the camera - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Sets the format of the pixel data transmitted by the camera. The available pixel formats depend on the camera model and whether the camera is monochrome or color. + + Visibility: Beginner + + Selected by: ComponentSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PixelFormat; + + //@} + + + //! \name Categories: TransportLayer + //@{ + /*! + \brief Enables legacy pixel format encoding - Applies to: GigE + + Enables legacy GVSP pixel format encoding to ensure compatibility with older camera models. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& PixelFormatLegacy; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Indicates the depth of the pixel values in the image (in bits per pixel) - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart USB and pulse USB + + Indicates the depth of the pixel values in the image (in bits per pixel). The potential values depend on the pixel format setting. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PixelSize; + + //@} + + + //! \name Categories: RemoveParamLimits + //@{ + /*! + \brief Sets the number of prelines - Applies to: CameraLink and GigE + + This value sets the number of prelines. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Prelines; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Enables the output of color-improved raw image data - Applies to: CameraLink and GigE + + Enables the output of color-improved raw image data. If enabled, color transformation and color adjustment will be applied to Bayer pixel formats. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ProcessedRawEnable; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Indicates the expected accuracy of the PTP device clock when it is or becomes the grandmaster - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PtpClockAccuracy; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Returns the latched clock ID of the PTP device - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PtpClockID; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Latches the current values from the device's PTP clock data set - Applies to: ace 2 GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& PtpDataSetLatch; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Enables the Precision Time Protocol (PTP) - Applies to: ace 2 GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& PtpEnable; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Returns the latched grandmaster clock ID of the PTP device - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PtpGrandmasterClockID; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Returns the latched offset from the PTP master clock in nanoseconds - Applies to: ace 2 GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PtpOffsetFromMaster; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Returns the latched parent clock ID of the PTP device - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PtpParentClockID; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Returns the latched state of the clock servo - Applies to: ace 2 GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PtpServoStatus; + + //@} + + + //! \name Categories: PtpControl + //@{ + /*! + \brief Returns the latched state of the PTP clock - Applies to: ace 2 GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PtpStatus; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Enables or disables the currently selected ROI zone - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: ROIZoneSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ROIZoneMode; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Vertical offset of the currently selected ROI zone - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: ROIZoneSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ROIZoneOffset; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Sets the ROI zone that can be configured - Applies to: GigE and ace USB + + + Visibility: Expert + + Selecting Parameters: ROIZoneMode, ROIZoneOffset and ROIZoneSize + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ROIZoneSelector; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Height of the currently selected ROI zone - Applies to: GigE and ace USB + + + Visibility: Expert + + Selected by: ROIZoneSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ROIZoneSize; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Time required for reading out each subframe from the sensor - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ReadoutTime; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Sensor readout time with current settings - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ReadoutTimeAbs; + + //@} + + + //! \name Categories: RemoveParamLimits + //@{ + /*! + \brief Removes the factory-set limit of the selected parameter - Applies to: CameraLink and GigE + + Removes the factory-set limit of the selected parameter. If the factory limits are removed, a wider range of parameter values is available and only subect to technical restrictions. Choosing parameter values outside of the factory limits may affect image quality. + + Visibility: Guru + + Selected by: ParameterSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& RemoveLimits; + + //@} + + + //! \name Categories: RemoveParameterLimitControl + //@{ + /*! + \brief Removes the factory-set limit of the selected parameter - Applies to: ace USB + + Removes the factory-set limit of the selected parameter. If the factory limits are removed, a wider range of parameter values is available and only subect to technical restrictions. Choosing parameter values outside of the factory limits may affect image quality. + + Visibility: Guru + + Selected by: RemoveParameterLimitSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& RemoveParameterLimit; + + //@} + + + //! \name Categories: RemoveParameterLimitControl + //@{ + /*! + \brief Sets the parameter whose factory limits can be removed - Applies to: ace USB + + Sets the parameter whose factory limits can be removed. The factory limits can be removed using the Remove Limits parameter. + + Visibility: Guru + + Selecting Parameters: RemoveParameterLimit + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& RemoveParameterLimitSelector; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Time during which the sensor is reset before the next subframe is acquired - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ResetTime; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Maximum frame acquisition period with current camera settings - Applies to: CameraLink and GigE + + Maximum frame acquisition period with current camera settings (in microseconds). + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ResultingFramePeriodAbs; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Maximum frame acquisition rate with current camera settings - Applies to: ace USB, boost CoaXPress, dart BCON, dart USB and pulse USB + + Maximum frame acquisition rate with current camera settings (in frames per second). + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ResultingFrameRate; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Maximum frame acquisition rate with current camera settings - Applies to: CamEmu, CameraLink and GigE + + Maximum frame acquisition rate with current camera settings (in frames per second). + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ResultingFrameRateAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Maximum line acquisition period with current camera settings - Applies to: CameraLink and GigE + + Maximum line acquisition period with current camera settings (in microseconds). + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ResultingLinePeriodAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Maximum line acquisition rate with current camera settings - Applies to: CameraLink and GigE + + Maximum line acquisition rate with current camera settings (in frames per second). + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ResultingLineRateAbs; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Enables horizontal mirroring of the image - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Enables horizontal mirroring of the image. The pixel values of every line in a captured image will be swapped along the line's center. You can use the ROI feature when using the Reverse X feature. The position of the ROI relative to the sensor remains the same. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ReverseX; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Enables vertical mirroring of the image - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Enables vertical mirroring of the image. The pixel values of every column in a captured image will be swapped along the column's center. You can use the ROI feature when using the Reverse Y feature. The position of the ROI relative to the sensor remains the same. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ReverseY; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: ace 2 USB, ace USB and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SIPayloadFinalTransfer1Size; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: ace 2 USB, ace USB and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SIPayloadFinalTransfer2Size; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: ace 2 USB, ace USB and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SIPayloadTransferCount; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief For information only May be required when contacting Basler support - Applies to: ace 2 USB, ace USB and dart 2 USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SIPayloadTransferSize; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Horizontal scaling factor - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ScalingHorizontal; + + //@} + + + //! \name Categories: AOI + //@{ + /*! + \brief Horizontal scaling factor - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ScalingHorizontalAbs; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Vertical scaling factor - Applies to: ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ScalingVertical; + + //@} + + + //! \name Categories: AOI + //@{ + /*! + \brief Vertical scaling factor - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ScalingVerticalAbs; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Maximum valid transmitted coordinate value of the selected Axis - Applies to: blaze + + + Visibility: Expert + + Selected by: Scan3dCoordinateSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dAxisMax; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Minimum valid transmitted coordinate value of the selected Axis - Applies to: blaze + + + Visibility: Expert + + Selected by: Scan3dCoordinateSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dAxisMin; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Adds an offset to the measured distance - Applies to: blaze + + This parameter allows you to adjust + the internal camera calibration. + The offset specified by Scan3dCalibrationOffset is added to the radial + distances the camera measures. + The camera transforms the radial distances into x, y, z coordinates in a + Cartesian coordinate system whose origin lies in the camera's optical center. + The Scan3dCalibrationOffset parameter can be used to manually correct a + temperature-dependent drift. + Note: Since Scan3dCalibrationOffset is added to the radial distances, it can't + be used to translate the origin of the coordinate system, i.e., it can't be + used to add a constant offset to the z coordinate. + Specifically, you should not use it in an attempt to shift the origin of the + camera's coordinate system from the optical center to + the front of the camera housing. Trying to do so will result in measurement + errors causing planar surfaces to appear curved. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dCalibrationOffset; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Offset when transforming a pixel from relative coordinates to world coordinates - Applies to: blaze + + + Visibility: Expert + + Selected by: Scan3dCoordinateSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dCoordinateOffset; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Scale factor when transforming a pixel from relative coordinates to world coordinates - Applies to: blaze + + + Visibility: Expert + + Selected by: Scan3dCoordinateSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dCoordinateScale; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Selects the individual coordinates in the vectors for 3D information/transformation - Applies to: blaze + + + Visibility: Expert + + Selecting Parameters: Scan3dAxisMax, Scan3dAxisMin, Scan3dCoordinateOffset, Scan3dCoordinateScale, Scan3dInvalidDataFlag and Scan3dInvalidDataValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Scan3dCoordinateSelector; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Specifies the Coordinate system to use for the device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Scan3dCoordinateSystem; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Defines coordinate system reference location - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Scan3dCoordinateSystemReference; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Specifies the unit used when delivering (calibrated) distance data - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Scan3dDistanceUnit; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Returns the focal length of the camera in pixel - Applies to: blaze + + Returns the focal length of the camera in pixel. The focal length depends on the selected region. The value of this feature takes into account horizontal binning, decimation, or any other function changing the image resolution. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dFocalLength; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Enables the definition of a non-valid flag value in the data stream - Applies to: blaze + + Enables the definition of a non-valid flag value in the data stream. Note that the confidence output is an alternate recommended way to identify non-valid pixels. Using an Scan3dInvalidDataValue may give processing penalties due to special handling. + + Visibility: Expert + + Selected by: Scan3dCoordinateSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& Scan3dInvalidDataFlag; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Value which identifies a non-valid pixel if Scan3dInvalidDataFlag is enabled - Applies to: blaze + + + Visibility: Expert + + Selected by: Scan3dCoordinateSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dInvalidDataValue; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Controls the Calibration and data organization of the device and the coordinates transmitted - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Scan3dOutputMode; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Returns the value of the horizontal position of the principal point, relative to the region origin, i e - Applies to: blaze + + Returns the value of the horizontal position of the principal point, relative to the region origin, i.e. OffsetX. The value of this feature takes into account horizontal binning, decimation, or any other function changing the image resolution. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dPrincipalPointU; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Returns the value of the vertical position of the principal point, relative to the region origin, i e - Applies to: blaze + + Returns the value of the vertical position of the principal point, relative to the region origin, i.e. OffsetY. The value of this feature takes into account vertical binning, decimation, or any other function changing the image resolution. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& Scan3dPrincipalPointV; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Amount of data bits the sensor produces for one sample - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SensorBitDepth; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief This feature represents the number of digitized samples outputted simultaneously by the camera A/D conversion stage - Applies to: CameraLink and GigE + + This feature represents the number of digitized samples output simultaneously by the camera A/D conversion stage. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SensorDigitizationTaps; + + //@} + + + //! \name Categories: AOI, DeviceInformation and ImageFormatControl + //@{ + /*! + \brief Height of the camera's sensor in pixels - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SensorHeight; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Physical size (pitch) in the y direction of a photo sensitive pixel unit - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SensorPixelHeight; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Physical size (pitch) in the x direction of a photo sensitive pixel unit - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SensorPixelWidth; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Distance between the sensor plane and the front of the housing - Applies to: blaze + + Distance between the sensor plane and the front of the housing. This value can be used to calculate the distance between the optical center and the front of the housing. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SensorPosition; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the sensor readout mode - Applies to: GigE and ace USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SensorReadoutMode; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sensor readout time with current settings - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SensorReadoutTime; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Sets the shutter mode of the camera - Applies to: ace 2 GigE, ace 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SensorShutterMode; + + //@} + + + //! \name Categories: AOI, DeviceInformation and ImageFormatControl + //@{ + /*! + \brief Width of the camera's sensor in pixels - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SensorWidth; + + //@} + + + //! \name Categories: SequenceControlConfiguration + //@{ + /*! + \brief Sets which bit of the sequence set address can be assigned to an input line - Applies to: CameraLink and GigE + + Sets which bit of the sequence set address can be assigned to an input line. An input line can be set as the control source for this bit using the Address Bit Source parameter. + + Visibility: Guru + + Selecting Parameters: SequenceAddressBitSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequenceAddressBitSelector; + + //@} + + + //! \name Categories: SequenceControlConfiguration + //@{ + /*! + \brief Sets an input line as the control source for the currently selected sequence set address bit - Applies to: CameraLink and GigE + + Sets an input line as the control source for the currently selected sequence set address bit. The bit can be selected using the Address Bit Selector parameter. + + Visibility: Guru + + Selected by: SequenceAddressBitSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequenceAddressBitSource; + + //@} + + + //! \name Categories: SequenceControlConfiguration + //@{ + /*! + \brief Sets the sequence set advance mode - Applies to: CameraLink and GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequenceAdvanceMode; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Enables asynchronous advance from one sequence set to the next - Applies to: CameraLink and GigE + + Enables asynchronous advance from one sequence set to the next. The advance is asynchronous to the camera's frame trigger. Only available in Controlled sequence advance mode. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SequenceAsyncAdvance; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Enables asynchronous restart of the sequence set sequence - Applies to: CameraLink and GigE + + Enables asynchronous restart of the sequence set sequence, starting with the sequence set that has the lowest index number. The restart is asynchronous to the camera's frame trigger. Only available in Auto and Controlled sequence advance mode. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SequenceAsyncRestart; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Sets whether the sequencer can be configured - Applies to: GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequenceConfigurationMode; + + //@} + + + //! \name Categories: SequenceControlConfiguration + //@{ + /*! + \brief Sets whether sequence advance or sequence restart can be configured - Applies to: CameraLink and GigE + + Sets whether sequence advance or sequence restart can be configured. A control source must be chosen using the Sequence Control Source parameter. + + Visibility: Guru + + Selecting Parameters: SequenceControlSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequenceControlSelector; + + //@} + + + //! \name Categories: SequenceControlConfiguration + //@{ + /*! + \brief Sets the source for sequence control - Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: SequenceControlSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequenceControlSource; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Current sequence set - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequenceCurrentSet; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Enables the sequencer - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& SequenceEnable; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Number of sequence set executions - Applies to: CameraLink and GigE + + Number of consecutive executions per sequence cycle of the selected sequence set. Only available in Auto sequence advance mode. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequenceSetExecutions; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Index number of a sequence set - Applies to: CameraLink and GigE + + This number uniquely identifies a sequence set. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequenceSetIndex; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Loads a sequence set - Applies to: CameraLink and GigE + + Loads an existing sequence set to make it the current sequence set. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SequenceSetLoad; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Stores the current sequence set - Applies to: CameraLink and GigE + + Stores the current sequence set. Storing the current sequence set will overwrite any existing sequence set with the same index number. The sequence set is stored in the volatile memory and will therefore be lost if the camera is reset or if power is switched off. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SequenceSetStore; + + //@} + + + //! \name Categories: SequenceControl + //@{ + /*! + \brief Total number of sequence sets in the sequence - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequenceSetTotalNumber; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sets whether the sequencer can be configured - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequencerConfigurationMode; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sets whether the sequencer can be used for image acquisition - Applies to: ace USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequencerMode; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sequencer path to be used - Applies to: ace USB + + + Visibility: Expert + + Selected by: SequencerSetSelector + + Selecting Parameters: SequencerSetNext, SequencerTriggerActivation and SequencerTriggerSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequencerPathSelector; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Index number of the currently active sequencer set - Applies to: ace USB + + Index number of the current sequencer set, i.e., of the sequencer set whose parameter values are currently in the active set. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequencerSetActive; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Loads the parameter values of a sequencer set into the active set - Applies to: ace USB + + Loads the parameter values of a sequencer set into the active set. The sequencer set will then be the current set. + + Visibility: Expert + + Selected by: SequencerSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SequencerSetLoad; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sequencer set that follows the current sequence set - Applies to: ace USB + + + Visibility: Expert + + Selected by: SequencerPathSelector and SequencerSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequencerSetNext; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Saves the sequencer parameter values that are currently in the active set - Applies to: ace USB + + Saves the sequencer parameter values that are currently in the active set. The values will be saved in the sequencer set whose sequencer set index number is currently selected. + + Visibility: Expert + + Selected by: SequencerSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SequencerSetSave; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief The sequencer set to be configured - Applies to: ace USB + + The sequencer set to be configured. Sequencer sets are identified by their sequencer set index numbers. + + Visibility: Expert + + Selecting Parameters: SequencerPathSelector, SequencerSetLoad, SequencerSetNext, SequencerSetSave, SequencerTriggerActivation and SequencerTriggerSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequencerSetSelector; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sequencer set that will be used with the first Frame Start trigger after the Sequencer Mode parameter was set to On - Applies to: ace USB + + Sequencer set that will be used with the first Frame Start trigger after the Sequencer Mode parameter was set to On. Only sequencer set 0 is available. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SequencerSetStart; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sets the logical state that makes the sequencer advance to the next - Applies to: ace USB + + Sets the logical state that makes the sequencer advance to the next. Currently, only High is available. + + Visibility: Expert + + Selected by: SequencerPathSelector and SequencerSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequencerTriggerActivation; + + //@} + + + //! \name Categories: SequencerControl + //@{ + /*! + \brief Sets the trigger source for sequencer set advance - Applies to: ace USB + + Sets the trigger source for sequencer set advance with the currently selected path. + + Visibility: Expert + + Selected by: SequencerPathSelector and SequencerSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SequencerTriggerSource; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Enables the selected shading correction type - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: ShadingSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ShadingEnable; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Sets the kind of shading correction - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selecting Parameters: ShadingEnable, ShadingSetDefaultSelector and ShadingSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShadingSelector; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Loads the selected shading set - Applies to: CameraLink and GigE + + This command copies the selected shading set from the camera's non-volatile memory into the volatile memory. If shading correction is enabled, it will be performed using the shading set in the volatile memory. + + Visibility: Expert + + Selected by: ShadingSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& ShadingSetActivate; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Enables/disables shading set creation - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selected by: ShadingSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShadingSetCreate; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Sets the bootup shading set - Applies to: CameraLink and GigE + + Sets the shading set that will be loaded into the volatile memory during camera start. + + Visibility: Expert + + Selected by: ShadingSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShadingSetDefaultSelector; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Sets which shading set can be enabled or created - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selected by: ShadingSelector + + Selecting Parameters: ShadingSetActivate and ShadingSetCreate + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShadingSetSelector; + + //@} + + + //! \name Categories: Shading + //@{ + /*! + \brief Indicates error statuses related to shading correction - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShadingStatus; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Current value of the tick counter - Applies to: CameraLink and GigE + + Current value of the tick counter of the shaft encoder module. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ShaftEncoderModuleCounter; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Maximum value of the tick counter - Applies to: CameraLink and GigE + + Maximum value of the tick counter of the shaft encoder module. If the tick counter is incrementing and reaches the maximum, it will roll over to 0. If the tick counter is decrementing and reaches 0, it will roll back to the specified maximum value. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ShaftEncoderModuleCounterMax; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Sets the counting mode of the tick counter - Applies to: CameraLink and GigE + + Sets the counting mode of the tick counter of the shaft encoder module. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShaftEncoderModuleCounterMode; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Resets the tick counter to 0 - Applies to: CameraLink and GigE + + Resets the tick counter of the shaft encoder module to 0. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& ShaftEncoderModuleCounterReset; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Sets the phase of the shaft encoder - Applies to: CameraLink and GigE + + Sets the phase of the shaft encoder as input for the shaft encoder module. + + Visibility: Expert + + Selecting Parameters: ShaftEncoderModuleLineSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShaftEncoderModuleLineSelector; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Sets the line source for the shaft encoder module - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selected by: ShaftEncoderModuleLineSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShaftEncoderModuleLineSource; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Sets how the shaft encoder module outputs trigger signals - Applies to: CameraLink and GigE + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShaftEncoderModuleMode; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Maximum value of the reverse counter - Applies to: CameraLink and GigE + + Maximum value of the reverse counter of the shaft encoder module (range: 0 to 32767). + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ShaftEncoderModuleReverseCounterMax; + + //@} + + + //! \name Categories: ShaftEncoderModule + //@{ + /*! + \brief Resets the reverse counter of the shaft encoder module - Applies to: CameraLink and GigE + + Resets the reverse counter of the shaft encoder module to 0 and informs the module that the current direction of conveyor movement is forward. Reset must be carried out before the first conveyor movement in the forward direction. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& ShaftEncoderModuleReverseCounterReset; + + //@} + + + //! \name Categories: ImageQualityControl and PGIControl + //@{ + /*! + \brief Sharpening value to be applied - Applies to: ace USB, dart BCON, dart USB and pulse USB + + Sharpening value to be applied. The higher the sharpness, the more distinct the image subject's contours will be. However, excessively high values may result in image information loss. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SharpnessEnhancement; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Sharpening value to be applied - Applies to: GigE + + Sharpening value to be applied. The higher the sharpness, the more distinct the image subject's contours will be. However, excessively high values may result in image information loss. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SharpnessEnhancementAbs; + + //@} + + + //! \name Categories: PGIControl + //@{ + /*! + \brief Sharpening value to be applied (raw value) - Applies to: GigE + + Sharpening value to be applied (raw value). The higher the sharpness, the more distinct the image subject's contours will be. However, excessively high values may result in image information loss. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SharpnessEnhancementRaw; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the shutter mode of the camera - Applies to: CameraLink, GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& ShutterMode; + + //@} + + + //! \name Categories: SoftwareSignalControl + //@{ + /*! + \brief Executes the selected software signal - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: SoftwareSignalSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SoftwareSignalPulse; + + //@} + + + //! \name Categories: SoftwareSignalControl + //@{ + /*! + \brief Sets the software signal to be executed - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selecting Parameters: SoftwareSignalPulse + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SoftwareSignalSelector; + + //@} + + + //! \name Categories: ImageFormat + //@{ + /*! + \brief Correction factor to account for the gaps between the sensor's lines - Applies to: CameraLink and GigE + + Correction factor to account for the gaps between the sensor's lines. Related line captures will be combined. Positive values: The object will pass the top sensor line first. Negative values: The object will pass the bottom sensor line first. In color cameras, the top sensor line is the green line, and the bottom sensor line is the blue line. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SpatialCorrection; + + //@} + + + //! \name Categories: StackedZoneImaging + //@{ + /*! + \brief Enables the Stacked Zone Imaging feature - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& StackedZoneImagingEnable; + + //@} + + + //! \name Categories: StackedZoneImaging + //@{ + /*! + \brief Index number of the zone to configure - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selecting Parameters: StackedZoneImagingZoneEnable, StackedZoneImagingZoneHeight and StackedZoneImagingZoneOffsetY + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StackedZoneImagingIndex; + + //@} + + + //! \name Categories: StackedZoneImaging + //@{ + /*! + \brief Enables the selected zone - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: StackedZoneImagingIndex + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& StackedZoneImagingZoneEnable; + + //@} + + + //! \name Categories: StackedZoneImaging + //@{ + /*! + \brief Height of the selected zone - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: StackedZoneImagingIndex + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StackedZoneImagingZoneHeight; + + //@} + + + //! \name Categories: StackedZoneImaging + //@{ + /*! + \brief Vertical offset (top offset) of the selected zone - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: StackedZoneImagingIndex + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StackedZoneImagingZoneOffsetY; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Time that passes between triggering the camera and exposure starting - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StartupTime; + + //@} + + + //! \name Categories: AnalogControls + //@{ + /*! + \brief Substrate voltage - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SubstrateVoltage; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Enables the synchronous free run mode - Applies to: GigE and blaze + + Enables the synchronous free run mode. If enabled, the camera will generate all required frame start or line start trigger signals internally. You don't need to apply frame start or line start trigger signals to the camera. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& SyncFreeRunTimerEnable; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief High 32 bits of the synchronous free run trigger start time - Applies to: GigE and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SyncFreeRunTimerStartTimeHigh; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Low 32 bits of the synchronous free run trigger start time - Applies to: GigE and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SyncFreeRunTimerStartTimeLow; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Synchronous free run trigger rate - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SyncFreeRunTimerTriggerRateAbs; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Updates synchronous free run settings - Applies to: GigE and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SyncFreeRunTimerUpdate; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Sets the user-settable synchronous output signal to be configured - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selecting Parameters: SyncUserOutputValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SyncUserOutputSelector; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Enables the selected user-settable synchronous output line - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: SyncUserOutputSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& SyncUserOutputValue; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Single bit field that sets the state of all user-settable synchronous output signals in one access - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SyncUserOutputValueAll; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Temperature at the selected location in the camera (in degrees centigrade) - Applies to: CameraLink and GigE + + Temperature at the selected location in the camera (in degrees centigrade). The temperature is measured at the location specified by the Temperature Selector parameter. + + Visibility: Expert + + Selected by: TemperatureSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TemperatureAbs; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Sets the location in the camera where the temperature will be measured - Applies to: CameraLink and GigE + + + Visibility: Expert + + Selecting Parameters: TemperatureAbs + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TemperatureSelector; + + //@} + + + //! \name Categories: DeviceControl and DeviceInformation + //@{ + /*! + \brief Indicates the temperature state - Applies to: CameraLink, GigE, ace USB and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TemperatureState; + + //@} + + + //! \name Categories: TestControl + //@{ + /*! + \brief Generates a Test event that can be used for testing event notification - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& TestEventGenerate; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Allows you to turn a moving test image into a fixed one - Applies to: GigE and ace USB + + Allows you to turn a moving test image into a fixed one. The test image will be displayed at its starting position and will stay fixed. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& TestImageResetAndHold; + + //@} + + + //! \name Categories: ImageFormat and ImageFormatControl + //@{ + /*! + \brief Sets the test image to display - Applies to: CamEmu, CameraLink, GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TestImageSelector; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Sets the test pattern to display - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TestPattern; + + //@} + + + //! \name Categories: TestControl + //@{ + /*! + \brief Test pending acknowledge time in milliseconds - Applies to: ace 2 GigE, ace 2 USB, dart 2 USB, dart BCON, dart USB and pulse USB + + Test pending acknowledge time in milliseconds. On write, the camera waits for this time period before acknowledging the write. If the time period is longer than the value in the Maximum Device Response Time register, the camera must use PENDING_ACK during the completion of this request. On reads, the camera returns the current value without any additional wait time. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TestPendingAck; + + //@} + + + //! \name Categories: ImageQualityControl + //@{ + /*! + \brief Enables the thermal drift correction - Applies to: blaze + + Activates the correction of the thermal drift. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ThermalDriftCorrection; + + //@} + + + //! \name Categories: CounterAndTimerControl and TimerControl + //@{ + /*! + \brief Delay of the currently selected timer in microseconds - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerDelay; + + //@} + + + //! \name Categories: TimerControls + //@{ + /*! + \brief Delay of the currently selected timer in microseconds - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerDelayAbs; + + //@} + + + //! \name Categories: TimerControls + //@{ + /*! + \brief Delay of the selected timer (raw value) - Applies to: CameraLink and GigE + + Delay of the selected timer (raw value). This value will be used as a multiplier for the timer delay timebase. The actual delay time equals the current Timer Delay Raw value multiplied with the current Timer Delay Timebase value. + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimerDelayRaw; + + //@} + + + //! \name Categories: TimerControls + //@{ + /*! + \brief Timebase (in microseconds) that is used when a timer delay is specified using the Timer Delay Raw parameter - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerDelayTimebaseAbs; + + //@} + + + //! \name Categories: CounterAndTimerControl and TimerControl + //@{ + /*! + \brief Duration of the currently selected timer in microseconds - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerDuration; + + //@} + + + //! \name Categories: TimerControls + //@{ + /*! + \brief Duration of the currently selected timer in microseconds - Applies to: CameraLink and GigE + + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerDurationAbs; + + //@} + + + //! \name Categories: TimerControls + //@{ + /*! + \brief Duration of the selected timer (raw value) - Applies to: CameraLink and GigE + + Duration of the selected timer (raw value). This value will be used as a multiplier for the timer duration timebase. The actual duration time equals the current Timer Duration Raw value multiplied with the current Timer Duration Timebase value. + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimerDurationRaw; + + //@} + + + //! \name Categories: TimerControls + //@{ + /*! + \brief Timebase (in microseconds) that is used when a timer duration is specified using the Timer Duration Raw parameter - Applies to: CameraLink and GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerDurationTimebaseAbs; + + //@} + + + //! \name Categories: TimerControl + //@{ + /*! + \brief Resets the selected timer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& TimerReset; + + //@} + + + //! \name Categories: CounterAndTimerControl, TimerControl and TimerControls + //@{ + /*! + \brief Sets the timer to be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selecting Parameters: TimerDelay, TimerDelayAbs, TimerDelayRaw, TimerDuration, TimerDurationAbs, TimerDurationRaw, TimerReset, TimerStatus, TimerTriggerActivation, TimerTriggerArmDelay and TimerTriggerSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TimerSelector; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimerSequenceCurrentEntryIndex; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& TimerSequenceEnable; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + Selecting Parameters: TimerSequenceTimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TimerSequenceEntrySelector; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimerSequenceLastEntryIndex; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: TimerSequenceTimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimerSequenceTimerDelayRaw; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: TimerSequenceTimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimerSequenceTimerDurationRaw; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: TimerSequenceTimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& TimerSequenceTimerEnable; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: TimerSequenceTimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& TimerSequenceTimerInverter; + + //@} + + + //! \name Categories: TimerSequence + //@{ + /*! + \brief Applies to: CameraLink and GigE + + + Visibility: Guru + + Selected by: TimerSequenceEntrySelector + + Selecting Parameters: TimerSequenceTimerDelayRaw, TimerSequenceTimerDurationRaw, TimerSequenceTimerEnable and TimerSequenceTimerInverter + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TimerSequenceTimerSelector; + + //@} + + + //! \name Categories: TimerControl + //@{ + /*! + \brief Indicates the status of the currently selected timer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Expert + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TimerStatus; + + //@} + + + //! \name Categories: TimerControl and TimerControls + //@{ + /*! + \brief Sets the type of signal transition that will start the timer - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TimerTriggerActivation; + + //@} + + + //! \name Categories: TimerControl + //@{ + /*! + \brief Arm delay of the currently selected timer - Applies to: ace 2 GigE, ace 2 USB, boost CoaXPress and dart 2 USB + + Arm delay of the currently selected timer. If an arm delay is set and the timer is triggered, the camera accepts the trigger signal and stops accepting any further timer trigger signals until the arm delay has elapsed. + + Visibility: Expert + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TimerTriggerArmDelay; + + //@} + + + //! \name Categories: CounterAndTimerControl, TimerControl and TimerControls + //@{ + /*! + \brief Sets the internal camera signal used to trigger the selected timer - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + Selected by: TimerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TimerTriggerSource; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Latches the current timestamp counter and stores its value in TimestampLatchValue - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze and dart 2 USB + + Latches the current timestamp counter and stores its value in the Timestamp Latch Value parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& TimestampLatch; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Latched value of the timestamp counter - Applies to: ace 2 GigE, ace 2 USB, ace USB, blaze and dart 2 USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TimestampLatchValue; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Resets the current timestamp counter - Applies to: ace 2 GigE + + Resets the current timestamp counter. After executing this command, the counter restarts automatically. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& TimestampReset; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Sets the operation mode of the Tonal Range Auto auto function - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TonalRangeAuto; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Sets whether tonal range adjustment is used - Applies to: GigE and ace USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TonalRangeEnable; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Sets which pixel values are used for tonal range adjustments - Applies to: GigE and ace USB + + + Visibility: Expert + + Selecting Parameters: TonalRangeSourceBright, TonalRangeSourceDark, TonalRangeTargetBright and TonalRangeTargetDark + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TonalRangeSelector; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Source value for tonal range adjustments at the bright end of the tonal range - Applies to: GigE and ace USB + + Source value for tonal range adjustments at the bright end of the tonal range. When tonal range adjustments are enabled, the source and target values are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + Visibility: Expert + + Selected by: TonalRangeSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TonalRangeSourceBright; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Source value for tonal range adjustments at the dark end of the tonal range - Applies to: GigE and ace USB + + Source value for tonal range adjustments at the dark end of the tonal range. When tonal range adjustments are enabled, the source and target values are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + Visibility: Expert + + Selected by: TonalRangeSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TonalRangeSourceDark; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Target value at the bright end of the tonal range to which pixel values should be mapped during tonal range adjustments - Applies to: GigE and ace USB + + Target value at the bright end of the tonal range to which pixel values should be mapped during tonal range adjustments. When tonal range adjustments are enabled, the source and target values at the bright end are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + Visibility: Expert + + Selected by: TonalRangeSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TonalRangeTargetBright; + + //@} + + + //! \name Categories: TonalRangeControl + //@{ + /*! + \brief Target value at the dark end of the tonal range to which pixel values should be mapped during tonal range adjustments - Applies to: GigE and ace USB + + Target value at the dark end of the tonal range to which pixel values should be mapped during tonal range adjustments. When tonal range adjustments are enabled, the source and target values at the dark end are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + Visibility: Expert + + Selected by: TonalRangeSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TonalRangeTargetDark; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the type of signal transition that will activate the selected trigger - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerActivation; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Sets the image acquisition control mode - Applies to: CameraLink and GigE + + Sets the image acquisition control mode. For more information, see your camera's product documentation. + + Visibility: Expert + + Selecting Parameters: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerControlImplementation; + + //@} + + + //! \name Categories: AcquisitionControl + //@{ + /*! + \brief Trigger delay time in microseconds - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + Trigger delay time in microseconds. The delay is applied after the trigger has been received and before effectively activating the trigger. + + Visibility: Expert + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerDelay; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Trigger delay time in microseconds - Applies to: CameraLink and GigE + + Trigger delay time in microseconds. The delay is applied after the trigger has been received and before effectively activating the trigger. + + Visibility: Expert + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerDelayAbs; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Trigger delay as number of line triggers - Applies to: CameraLink and GigE + + Trigger delay as a number of consecutive line triggers that are allowed between trigger having been received and before effectively activating the trigger. + + Visibility: Expert + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerDelayLineTriggerCount; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Sets the kind of trigger delay - Applies to: CameraLink and GigE + + Sets whether trigger delay is defined as a time interval or as a number of consecutive line triggers. + + Visibility: Expert + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerDelaySource; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the mode for the currently selected trigger - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerMode; + + //@} + + + //! \name Categories: AcquisitionTrigger + //@{ + /*! + \brief Determines whether a partial or a complete frame is transmitted when the Frame Start trigger signal transitions prematurely - Applies to: CameraLink and GigE + + Determines whether a partial or a complete frame is transmitted when the Frame Start trigger is used with High or Low states and the trigger signal transitions prematurely. + + Visibility: Expert + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& TriggerPartialClosingFrame; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the trigger type to be configured - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Sets the trigger type to be configured. All changes to the trigger settings will be applied to the selected trigger. + + Visibility: Beginner + + Selected by: TriggerControlImplementation + + Selecting Parameters: TriggerActivation, TriggerDelay, TriggerDelayAbs, TriggerDelayLineTriggerCount, TriggerDelaySource, TriggerMode, TriggerPartialClosingFrame, TriggerSoftware and TriggerSource + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerSelector; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Generates a software trigger signal - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Generates a software trigger signal. The software trigger signal will be used if the Trigger Source parameter is set to Trigger Software. + + Visibility: Beginner + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& TriggerSoftware; + + //@} + + + //! \name Categories: AcquisitionControl and AcquisitionTrigger + //@{ + /*! + \brief Sets the source signal for the selected trigger - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: TriggerSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerSource; + + //@} + + + //! \name Categories: UserDefinedValueControl and UserDefinedValues + //@{ + /*! + \brief User-defined value - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + User-defined value. The value can serve as storage location for the camera user. It has no impact on the operation of the camera. + + Visibility: Guru + + Selected by: UserDefinedValueSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& UserDefinedValue; + + //@} + + + //! \name Categories: UserDefinedValueControl and UserDefinedValues + //@{ + /*! + \brief Sets the user-defined value to set or read - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Guru + + Selecting Parameters: UserDefinedValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& UserDefinedValueSelector; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Sets the user-settable output signal to be configured - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + Sets the user-settable output signal to be configured. All changes to the user-settable output signal settings will be applied to the selected user-settable output signal. + + Visibility: Beginner + + Selecting Parameters: UserOutputValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& UserOutputSelector; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Enables the selected user-settable output line - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON and dart USB + + + Visibility: Beginner + + Selected by: UserOutputSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& UserOutputValue; + + //@} + + + //! \name Categories: DigitalIO and DigitalIOControl + //@{ + /*! + \brief Single bit field that sets the state of all user-settable output signals in one access - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress and dart 2 USB + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& UserOutputValueAll; + + //@} + + + //! \name Categories: DigitalIO + //@{ + /*! + \brief Defines a mask that is used when the User Output Value All setting is used to set all of the user settable output signals in one access - Applies to: CameraLink and GigE + + This integer value defines a mask that is used when the User Output Value All setting is used to set all of the user settable output signals in one access. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& UserOutputValueAllMask; + + //@} + + + //! \name Categories: UserSetControl + //@{ + /*! + \brief Sets the user set or the factory set to be used as the startup set - Applies to: ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Sets the user set or the factory set to be used as the startup set. The startup set will be loaded as the active set whenever the camera is powered on or reset. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& UserSetDefault; + + //@} + + + //! \name Categories: UserSets + //@{ + /*! + \brief Sets the user set or the factory set to be used as the startup set - Applies to: CameraLink and GigE + + Sets the user set or the factory set to be used as the startup set. The default startup set will be loaded as the active set whenever the camera is powered on or reset. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& UserSetDefaultSelector; + + //@} + + + //! \name Categories: UserSetControl and UserSets + //@{ + /*! + \brief Loads the selected set into the camera's volatile memory and makes it the active configuration set - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Loads the selected set into the camera's volatile memory and makes it the active configuration set. After the selected set has been loaded, the parameters in that set will control the camera. + + Visibility: Beginner + + Selected by: UserSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& UserSetLoad; + + //@} + + + //! \name Categories: UserSetControl and UserSets + //@{ + /*! + \brief Saves the current active set as the selected user set - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selected by: UserSetSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& UserSetSave; + + //@} + + + //! \name Categories: UserSetControl and UserSets + //@{ + /*! + \brief Sets the user set or the factory set to load, save, or configure - Applies to: CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + + Visibility: Beginner + + Selecting Parameters: UserSetLoad and UserSetSave + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& UserSetSelector; + + //@} + + + //! \name Categories: VirtualInput + //@{ + /*! + \brief Sets the length of the input bit - Applies to: CameraLink and GigE + + This integer value sets the length of the input bit in microseconds. It applies to all bits in the signal. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VInpBitLength; + + //@} + + + //! \name Categories: VirtualInput + //@{ + /*! + \brief Time span between the beginning of the input bit and the time when the high/low status is evaluated - Applies to: CameraLink and GigE + + This integer value sets the time in microseconds that elapses between the beginning of the input bit and the time when the high/low status of the bit is evaluated. It applies to all bits. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VInpSamplingPoint; + + //@} + + + //! \name Categories: VirtualInput + //@{ + /*! + \brief Selects when to start the signal evaluation - Applies to: CameraLink and GigE + + This enumeration selects when to start the signal evaluation. The camera waits for a rising/falling edge on the input line. When the appropriate signal has been received, the camera starts evaluating the incoming bit patterns. When one bit pattern is finished, the camera waits for the next rising/falling edge to read out the next incoming bit pattern. The camera stops listening once three bits have been received. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& VInpSignalReadoutActivation; + + //@} + + + //! \name Categories: VirtualInput + //@{ + /*! + \brief Sets the I/O line on which the camera receives the virtual input signal - Applies to: CameraLink and GigE + + This enumeration selects the I/O line on which the camera receives the virtual input signal. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& VInpSignalSource; + + //@} + + + //! \name Categories: VignettingCorrectionControl + //@{ + /*! + \brief Loads the vignetting correction data - Applies to: GigE and ace USB + + Loads the vignetting correction data into the camera. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& VignettingCorrectionLoad; + + //@} + + + //! \name Categories: VignettingCorrectionControl + //@{ + /*! + \brief Enables/disables the vignetting correction - Applies to: GigE and ace USB + + The Vignetting Correction feature allows you to remove vignetting artifacts from your images. To do this, you first have to create vignetting correction data. For more information, see the Basler Product Documentation. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& VignettingCorrectionMode; + + //@} + + + //! \name Categories: VirtualLine1RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Virtual Line 1 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine1RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: VirtualLine1RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Virtual Line 1 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine1RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: VirtualLine2RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Virtual Line 2 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine2RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: VirtualLine2RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Virtual Line 2 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine2RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: VirtualLine3RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Virtual Line 3 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine3RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: VirtualLine3RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Virtual Line 3 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine3RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: VirtualLine4RisingEdgeEventData + //@{ + /*! + \brief Stream channel index of the Virtual Line 4 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine4RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Categories: VirtualLine4RisingEdgeEventData + //@{ + /*! + \brief Timestamp of the Virtual Line 4 Rising Edge event - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VirtualLine4RisingEdgeEventTimestamp; + + //@} + + + //! \name Categories: VolatileRowColumnOffset + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& VolatileColumnOffsetEnable; + + //@} + + + //! \name Categories: VolatileRowColumnOffset + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + Selecting Parameters: VolatileColumnOffsetValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VolatileColumnOffsetIndex; + + //@} + + + //! \name Categories: VolatileRowColumnOffset + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + Selected by: VolatileColumnOffsetIndex + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VolatileColumnOffsetValue; + + //@} + + + //! \name Categories: VolatileRowColumnOffset + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& VolatileRowOffsetEnable; + + //@} + + + //! \name Categories: VolatileRowColumnOffset + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + Selecting Parameters: VolatileRowOffsetValue + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VolatileRowOffsetIndex; + + //@} + + + //! \name Categories: VolatileRowColumnOffset + //@{ + /*! + \brief Applies to: CameraLink + + + Visibility: Beginner + + Selected by: VolatileRowOffsetIndex + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& VolatileRowOffsetValue; + + //@} + + + //! \name Categories: AOI and ImageFormatControl + //@{ + /*! + \brief Width of the camera's region of interest (area of interest) in pixels - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Width of the camera's region of interest (area of interest) in pixels. Depending on the camera model, the parameter can be set in different increments. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Width; + + //@} + + + //! \name Categories: AOI, DeviceInformation and ImageFormatControl + //@{ + /*! + \brief Maximum width of the region of interest (area of interest) in pixels - Applies to: CamEmu, CameraLink, GigE, ace 2 GigE, ace 2 USB, ace USB, blaze, boost CoaXPress, dart 2 USB, dart BCON, dart USB and pulse USB + + Maximum width of the region of interest (area of interest) in pixels. The value takes into account any function that may limit the maximum width. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& WidthMax; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Maximum working range of the camera - Applies to: blaze + + Maximum working range of the camera. Beyond this, results will be ambguous. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& WorkingRangeMax; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Minimum working range of the camera - Applies to: blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& WorkingRangeMin; + + //@} + + + //! \name Categories: Scan3dControl + //@{ + /*! + \brief Distance between the origin of the z axis to the front of the camera housing - Applies to: blaze + + Distance between the origin of the z axis to the front of the camera housing. Due to mechanical tolerances, this offset is device-specific and needs to be taken into account when measuring absolute distances. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& ZOffsetOriginToCameraFront; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUniversalCameraParams_Params_v6_2_0(CUniversalCameraParams_Params_v6_2_0&); + + //! not implemented assignment operator + CUniversalCameraParams_Params_v6_2_0& operator=(CUniversalCameraParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for Basler camera devices + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class CUniversalCameraParams_Params : public CUniversalCameraParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalCameraParams_Params( void ) + { + } + + //! Destructor + ~CUniversalCameraParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CUniversalCameraParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_UniversalCameraParams + +#endif // BASLER_PYLON_UNIVERSALCAMERAPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalChunkDataParams.h b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalChunkDataParams.h new file mode 100644 index 0000000..ade13f4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalChunkDataParams.h @@ -0,0 +1,731 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for chunk data of Basler camera devices + +The parameter class is used by the \link Pylon::CBaslerUniversalGrabResultPtr \c CBaslerUniversalGrabResultPtr \endlink class. +More information can be found in the code of the \ref sample_Grab_ChunkImage sample. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_UNIVERSALCHUNKDATAPARAMS_H +#define BASLER_PYLON_UNIVERSALCHUNKDATAPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_UniversalChunkDataParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for BslChunkAutoBrightnessStatus + enum BslChunkAutoBrightnessStatusEnums + { + BslChunkAutoBrightnessStatus_Disabled, //!< Target brightness adjustments are disabled, i e , Gain Auto and Exposure Auto are set to Off - Applies to: ace 2 GigE and ace 2 USB + BslChunkAutoBrightnessStatus_TargetNotReached, //!< Target brightness adjustments are enabled, but the target brightness value has not been reached - Applies to: ace 2 GigE and ace 2 USB + BslChunkAutoBrightnessStatus_TargetReached //!< Target brightness adjustments are enabled, and the target brightness value has been reached - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for BslChunkTimestampSelector + enum BslChunkTimestampSelectorEnums + { + BslChunkTimestampSelector_ExposureEnd, //!< The Chunk Timestamp Value parameter indicates when exposure of the current image ended - Applies to: ace 2 GigE and ace 2 USB + BslChunkTimestampSelector_ExposureStart, //!< The Chunk Timestamp Value parameter indicates when exposure of the current image started - Applies to: ace 2 GigE and ace 2 USB + BslChunkTimestampSelector_FrameStart //!< The Chunk Timestamp Value parameter indicates when acquisition of the current image started - Applies to: ace 2 GigE and ace 2 USB + }; + + //! Valid values for ChunkCounterSelector + enum ChunkCounterSelectorEnums + { + ChunkCounterSelector_Counter1, //!< Chunk data can be retrieved from counter 1 - Applies to: ace 2 GigE, ace 2 USB and ace USB + ChunkCounterSelector_Counter2 //!< Chunk data can be retrieved from counter 2 - Applies to: ace 2 GigE, ace 2 USB and ace USB + }; + + //! Valid values for ChunkGainSelector + enum ChunkGainSelectorEnums + { + ChunkGainSelector_All //!< Chunk data can be retrieved from all gain channels - Applies to: ace USB + }; + + //! Valid values for ChunkPixelFormat + enum ChunkPixelFormatEnums + { + ChunkPixelFormat_BGR10Packed, //!< The pixel data in the acquired image is in the BGR 10 Packed format - Applies to: GigE + ChunkPixelFormat_BGR12Packed, //!< The pixel data in the acquired image is in the BGR 12 Packed format - Applies to: GigE + ChunkPixelFormat_BGR8Packed, //!< The pixel data in the acquired image is in the BGR 8 Packed format - Applies to: GigE + ChunkPixelFormat_BGRA8Packed, //!< The pixel data in the acquired image is in the BGRA 8 Packed format - Applies to: GigE + ChunkPixelFormat_BayerBG10, //!< The pixel data in the acquired image is in the Bayer BG 10 format - Applies to: GigE + ChunkPixelFormat_BayerBG10p, //!< The pixel data in the acquired image is in the Bayer BG 10p format - Applies to: GigE + ChunkPixelFormat_BayerBG12, //!< The pixel data in the acquired image is in the Bayer BG 12 format - Applies to: GigE + ChunkPixelFormat_BayerBG12Packed, //!< The pixel data in the acquired image is in the Bayer BG 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerBG16, //!< The pixel data in the acquired image is in the Bayer BG 16 format - Applies to: GigE + ChunkPixelFormat_BayerBG8, //!< The pixel data in the acquired image is in the Bayer BG 8 format - Applies to: GigE + ChunkPixelFormat_BayerGB10, //!< The pixel data in the acquired image is in the Bayer GB 10 format - Applies to: GigE + ChunkPixelFormat_BayerGB10p, //!< The pixel data in the acquired image is in the Bayer GB 10p format - Applies to: GigE + ChunkPixelFormat_BayerGB12, //!< The pixel data in the acquired image is in the Bayer GB 12 format - Applies to: GigE + ChunkPixelFormat_BayerGB12Packed, //!< The pixel data in the acquired image is in the Bayer GB 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerGB16, //!< The pixel data in the acquired image is in the Bayer GB 16 format - Applies to: GigE + ChunkPixelFormat_BayerGB8, //!< The pixel data in the acquired image is in the Bayer GB 8 format - Applies to: GigE + ChunkPixelFormat_BayerGR10, //!< The pixel data in the acquired image is in the Bayer GR 10 format - Applies to: GigE + ChunkPixelFormat_BayerGR10p, //!< The pixel data in the acquired image is in the Bayer GR 10p format - Applies to: GigE + ChunkPixelFormat_BayerGR12, //!< The pixel data in the acquired image is in the Bayer GR 12 format - Applies to: GigE + ChunkPixelFormat_BayerGR12Packed, //!< The pixel data in the acquired image is in the Bayer GR 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerGR16, //!< The pixel data in the acquired image is in the Bayer GR 16 format - Applies to: GigE + ChunkPixelFormat_BayerGR8, //!< The pixel data in the acquired image is in the Bayer GR 8 format - Applies to: GigE + ChunkPixelFormat_BayerRG10, //!< The pixel data in the acquired image is in the Bayer RG 10 format - Applies to: GigE + ChunkPixelFormat_BayerRG10p, //!< The pixel data in the acquired image is in the Bayer RG 10p format - Applies to: GigE + ChunkPixelFormat_BayerRG12, //!< The pixel data in the acquired image is in the Bayer RG 12 format - Applies to: GigE + ChunkPixelFormat_BayerRG12Packed, //!< The pixel data in the acquired image is in the Bayer RG 12 Packed format - Applies to: GigE + ChunkPixelFormat_BayerRG16, //!< The pixel data in the acquired image is in the Bayer RG 16 format - Applies to: GigE + ChunkPixelFormat_BayerRG8, //!< The pixel data in the acquired image is in the Bayer RG 8 format - Applies to: GigE + ChunkPixelFormat_Mono10, //!< The pixel data in the acquired image is in the Mono 10 format - Applies to: GigE + ChunkPixelFormat_Mono10Packed, //!< The pixel data in the acquired image is in the Mono 10 Packed format - Applies to: GigE + ChunkPixelFormat_Mono10p, //!< The pixel data in the acquired image is in the Mono 10p format - Applies to: GigE + ChunkPixelFormat_Mono12, //!< The pixel data in the acquired image is in the Mono 12 format - Applies to: GigE + ChunkPixelFormat_Mono12Packed, //!< The pixel data in the acquired image is in the Mono 12 Packed format - Applies to: GigE + ChunkPixelFormat_Mono16, //!< The pixel data in the acquired image is in the Mono 16 format - Applies to: GigE + ChunkPixelFormat_Mono8, //!< The pixel data in the acquired image is in the Mono 8 format - Applies to: GigE + ChunkPixelFormat_Mono8Signed, //!< The pixel data in the acquired image is in the Mono 8 Signed format - Applies to: GigE + ChunkPixelFormat_RGB10Packed, //!< The pixel data in the acquired image is in the RGB 10 Packed format - Applies to: GigE + ChunkPixelFormat_RGB10Planar, //!< The pixel data in the acquired image is in the RGB 10 Planar format - Applies to: GigE + ChunkPixelFormat_RGB10V1Packed, //!< The pixel data in the acquired image is in the RGB 10V1 Packed format - Applies to: GigE + ChunkPixelFormat_RGB10V2Packed, //!< The pixel data in the acquired image is in the RGB 10V2 Packed format - Applies to: GigE + ChunkPixelFormat_RGB12Packed, //!< The pixel data in the acquired image is in the RGB 12 Packed format - Applies to: GigE + ChunkPixelFormat_RGB12Planar, //!< The pixel data in the acquired image is in the RGB 12 Planar format - Applies to: GigE + ChunkPixelFormat_RGB12V1Packed, //!< The pixel data in the acquired image is in RGB 12 V1 Packed format - Applies to: GigE + ChunkPixelFormat_RGB16Planar, //!< The pixel data in the acquired image is in the RGB 16 Planar format - Applies to: GigE + ChunkPixelFormat_RGB8Packed, //!< The pixel data in the acquired image is in the RGB 8 Packed format - Applies to: GigE + ChunkPixelFormat_RGB8Planar, //!< The pixel data in the acquired image is in the RGB 8 Planar format - Applies to: GigE + ChunkPixelFormat_RGBA8Packed, //!< The pixel data in the acquired image is in the RGBA 8 Packed format - Applies to: GigE + ChunkPixelFormat_YUV411Packed, //!< The pixel data in the acquired image is in the YUV 411 Packed format - Applies to: GigE + ChunkPixelFormat_YUV422Packed, //!< The pixel data in the acquired image is in the YUV 422 Packed format - Applies to: GigE + ChunkPixelFormat_YUV422_YUYV_Packed, //!< The pixel data in the acquired image is in the YUV 422 (YUYV) Packed format - Applies to: GigE + ChunkPixelFormat_YUV444Packed //!< The pixel data in the acquired image is in the YUV 444 Packed format - Applies to: GigE + }; + + + + + //************************************************************************************************** + // Parameter class CUniversalChunkDataParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for chunk data of Basler camera devices + + The parameter class is used by the \link Pylon::CBaslerUniversalGrabResultPtr \c CBaslerUniversalGrabResultPtr \endlink class. + More information can be found in the code of the \ref sample_Grab_ChunkImage sample. + */ + class PYLONBASE_API CUniversalChunkDataParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalChunkDataParams_Params_v6_2_0( void ); + + //! Destructor + ~CUniversalChunkDataParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CUniversalChunkDataParams_Params_v6_2_0_Data; + CUniversalChunkDataParams_Params_v6_2_0_Data* m_pCUniversalChunkDataParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: Root + //@{ + /*! + \brief Indicates the status of the target brightness adjustments performed by the Exposure Auto and Gain Auto auto functions - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + */ + Pylon::IEnumParameterT& BslChunkAutoBrightnessStatus; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sets which information should be included in the Chunk Timestamp Value chunk - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + Selecting Parameters: BslChunkTimestampValue + + */ + Pylon::IEnumParameterT& BslChunkTimestampSelector; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the timestamp when the image was acquired - Applies to: ace 2 GigE and ace 2 USB + + + Visibility: Expert + + Selected by: BslChunkTimestampSelector + + */ + Pylon::IIntegerEx& BslChunkTimestampValue; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sets which counter to retrieve chunk data from - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Expert + + Selecting Parameters: ChunkCounterValue + + */ + Pylon::IEnumParameterT& ChunkCounterSelector; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the selected chunk counter - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + Selected by: ChunkCounterSelector + + */ + Pylon::IIntegerEx& ChunkCounterValue; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum possible pixel value in the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkDynamicRangeMax; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Minimum possible pixel value in the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkDynamicRangeMin; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Exposure time used to acquire the image - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + */ + Pylon::IFloatEx& ChunkExposureTime; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Unique identifier of the current frame - Applies to: ace 2 GigE and ace 2 USB + + Unique identifier of the current frame. The frame ID starts at 0 and keeps incrementing by 1 for each exposed image until the camera is powered off. The maximum value is 2^48. + + Visibility: Expert + + */ + Pylon::IIntegerEx& ChunkFrameID; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Frame Trigger counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkFrameTriggerCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Frame Trigger Ignored counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkFrameTriggerIgnoredCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Frame counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkFramecounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Frames per Trigger counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkFramesPerTriggerCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Gain used during image acquisition - Applies to: ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + Selected by: ChunkGainSelector + + */ + Pylon::IFloatEx& ChunkGain; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Gain All value of the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkGainAll; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sets which gain channel to retrieve chunk data from - Applies to: ace USB + + + Visibility: Expert + + Selecting Parameters: ChunkGain + + */ + Pylon::IEnumParameterT& ChunkGainSelector; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief AOI height of the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkHeight; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Number of bits per line used for the Input Status At Line Trigger parameter - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkInputStatusAtLineTriggerBitsPerLine; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Index number used for the Input Status At Line Trigger parameter - Applies to: GigE + + Index number used for the Input Status At Line Trigger parameter. The index number can be used to get the state of the camera's input lines when a specific line was acquired. For example, if you want to know the state of the camera's input lines when line 30 was acquired, set the index to 30, then retrieve the value of Status Index parameter. + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkInputStatusAtLineTriggerIndex; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value indicating the status of the camera's input lines when a specific line was acquired - Applies to: GigE + + Value indicating the status of the camera's input lines when a specific line was acquired. The information is stored in a 4-bit value (bit 0 = input line 1 state, bit 1 = input line 2 state etc.). For more information, see the Status Index parameter documentation. + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkInputStatusAtLineTriggerValue; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Bit field that indicates the status of all of the camera's input and output lines when the image was acquired - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkLineStatusAll; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Line Trigger counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkLineTriggerCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Line Trigger End to End counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkLineTriggerEndToEndCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Line Trigger Ignored counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkLineTriggerIgnoredCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief X offset of the AOI of the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkOffsetX; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Y offset of the AOI of the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkOffsetY; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief CRC checksum of the acquired image - Applies to: GigE, ace 2 GigE, ace 2 USB and ace USB + + CRC checksum of the acquired image. The checksum is calculated using all of the image data and all of the appended chunks except for the checksum itself. + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkPayloadCRC16; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Indicates the pixel format of the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IEnumParameterT& ChunkPixelFormat; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sequence set index number related to the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkSequenceSetIndex; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Index of the active sequencer set - Applies to: ace USB + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkSequencerSetActive; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Shaft Encoder counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkShaftEncoderCounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Number of bytes of data between the beginning of one line in the acquired image and the beginning of the next line in the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkStride; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the timestamp when the image was acquired - Applies to: GigE and ace USB + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkTimestamp; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Value of the Trigger Input counter when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkTriggerinputcounter; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Status of all of the camera's virtual input and output lines when the image was acquired - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkVirtLineStatusAll; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Width of the AOI of the acquired image - Applies to: GigE + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& ChunkWidth; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUniversalChunkDataParams_Params_v6_2_0(CUniversalChunkDataParams_Params_v6_2_0&); + + //! not implemented assignment operator + CUniversalChunkDataParams_Params_v6_2_0& operator=(CUniversalChunkDataParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for chunk data of Basler camera devices + + The parameter class is used by the \link Pylon::CBaslerUniversalGrabResultPtr \c CBaslerUniversalGrabResultPtr \endlink class. + More information can be found in the code of the \ref sample_Grab_ChunkImage sample. + */ + class CUniversalChunkDataParams_Params : public CUniversalChunkDataParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalChunkDataParams_Params( void ) + { + } + + //! Destructor + ~CUniversalChunkDataParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CUniversalChunkDataParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_UniversalChunkDataParams + +#endif // BASLER_PYLON_UNIVERSALCHUNKDATAPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalEventParams.h b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalEventParams.h new file mode 100644 index 0000000..9a4c30e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalEventParams.h @@ -0,0 +1,262 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for pylon event grabbers + +The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. +The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_UNIVERSALEVENTPARAMS_H +#define BASLER_PYLON_UNIVERSALEVENTPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_UniversalEventParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for Status + enum StatusEnums + { + Status_Closed, //!< The low level event grabber is closed - Applies to: GigE + Status_Open //!< The low level event grabber is open - Applies to: GigE + }; + + + + + //************************************************************************************************** + // Parameter class CUniversalEventParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for pylon event grabbers + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class PYLONBASE_API CUniversalEventParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalEventParams_Params_v6_2_0( void ); + + //! Destructor + ~CUniversalEventParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CUniversalEventParams_Params_v6_2_0_Data; + CUniversalEventParams_Params_v6_2_0_Data* m_pCUniversalEventParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: Root + //@{ + /*! + \brief Number of buffers to be used - Applies to: GigE and USB + + Number of Buffers that are going to be used receiving events. . + + Visibility: Expert + + */ + Pylon::IIntegerEx& NumBuffer; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum number of USB request blocks (URBs) to be enqueued simultaneously - Applies to: USB + + + Visibility: Guru + + */ + Pylon::IIntegerEx& NumMaxQueuedUrbs; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum number of retries - Applies to: GigE + + Number retry attempts by the camera to get an acknowledge for a sent event message. + + Visibility: Expert + + */ + Pylon::IIntegerEx& RetryCount; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Count of processed events with an error status - Applies to: USB + + + Visibility: Expert + + */ + Pylon::IIntegerEx& Statistic_Failed_Event_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Status code of the last failed event buffer - Applies to: USB + + + Visibility: Expert + + */ + Pylon::IIntegerEx& Statistic_Last_Failed_Event_Buffer_Status; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Total count of processed events - Applies to: USB + + + Visibility: Expert + + */ + Pylon::IIntegerEx& Statistic_Total_Event_Count; + + //@} + + + //! \name Categories: Debug + //@{ + /*! + \brief For internal use only - Applies to: GigE + + + Visibility: Guru + + */ + Pylon::IEnumParameterT& Status; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Acknowledge timeout in milliseconds - Applies to: GigE + + Time to wait by the camera if an acknowledge request is configured (RetryCount != 0) to wait until the acknowledge arrives before resending the event message on its own. + + Visibility: Expert + + */ + Pylon::IIntegerEx& Timeout; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Priority of the thread that handles USB requests from the stream interface - Applies to: USB + + + Visibility: Guru + + */ + Pylon::IIntegerEx& TransferLoopThreadPriority; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUniversalEventParams_Params_v6_2_0(CUniversalEventParams_Params_v6_2_0&); + + //! not implemented assignment operator + CUniversalEventParams_Params_v6_2_0& operator=(CUniversalEventParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for pylon event grabbers + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class CUniversalEventParams_Params : public CUniversalEventParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalEventParams_Params( void ) + { + } + + //! Destructor + ~CUniversalEventParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CUniversalEventParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_UniversalEventParams + +#endif // BASLER_PYLON_UNIVERSALEVENTPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalInterfaceParams.h b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalInterfaceParams.h new file mode 100644 index 0000000..2e37461 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalInterfaceParams.h @@ -0,0 +1,799 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for pylon interfaces +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_UNIVERSALINTERFACEPARAMS_H +#define BASLER_PYLON_UNIVERSALINTERFACEPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_UniversalInterfaceParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for CxpLinkConfiguration + enum CxpLinkConfigurationEnums + { + CxpLinkConfiguration_Auto, //!< Link speed is controlled automatically + CxpLinkConfiguration_CXP10_X1, //!< Connection is operating at CXP-10 speed (10 0 Gbps) + CxpLinkConfiguration_CXP12_X1, //!< Connection is operating at CXP-12 speed (12 50 Gbps) + CxpLinkConfiguration_CXP1_X1, //!< Connection is operating at CXP-1 speed (1 25 Gbps) + CxpLinkConfiguration_CXP2_X1, //!< Connection is operating at CXP-2 speed (2 50 Gbps) + CxpLinkConfiguration_CXP3_X1, //!< Connection is operating at CXP-3 speed (3 125 Gbps) + CxpLinkConfiguration_CXP5_X1, //!< Connection is operating at CXP-5 speed (5 00 Gbps) + CxpLinkConfiguration_CXP6_X1 //!< Connection is operating at CXP-6 speed (6 25 Gbps) + }; + + //! Valid values for CxpPoCxpStatus + enum CxpPoCxpStatusEnums + { + CxpPoCxpStatus_Auto, //!< PoCXP operation is set to automatic + CxpPoCxpStatus_Off, //!< PoCXP is forced off + CxpPoCxpStatus_Tripped //!< The link has shut down because of an over-current trip + }; + + //! Valid values for CxpPort0PowerState + enum CxpPort0PowerStateEnums + { + CxpPort0PowerState_AdcFault, //!< The PoCXP state can't be determined because of an A/D converter fault + CxpPort0PowerState_Disabled, //!< PoCXP is disabled + CxpPort0PowerState_HighCurrent, //!< PoCXP is off because of an over current trip + CxpPort0PowerState_HighVoltage, //!< PoCXP is off because the voltage is too high + CxpPort0PowerState_Initializing, //!< The PoCXP state machine is looking for devices + CxpPort0PowerState_InvalidValue, //!< The PoCXP state can't be determined + CxpPort0PowerState_LowVoltage, //!< PoCXP is off because the voltage is too low + CxpPort0PowerState_On //!< PoCXP is active + }; + + //! Valid values for DeviceAccessStatus + enum DeviceAccessStatusEnums + { + DeviceAccessStatus_Busy, //!< The device is already opened by another entity + DeviceAccessStatus_NoAccess, //!< You can't connect to the device + DeviceAccessStatus_OpenReadOnly, //!< The device is opened in Read-only mode by this GenTL host + DeviceAccessStatus_OpenReadWrite, //!< The device is opened in Read/Write mode by this GenTL host + DeviceAccessStatus_ReadOnly, //!< The device offers read-only access + DeviceAccessStatus_ReadWrite, //!< The device offers read/write access + DeviceAccessStatus_Unknown //!< The status is unknown + }; + + //! Valid values for InterfaceApplet + enum InterfaceAppletEnums + { + InterfaceApplet_Acq_SingleCXP12x1Area, //!< The Acq_SingleCXP12x1Area applet is used to initialize the interface + InterfaceApplet_Acq_SingleCXP12x1Area_01, //!< The Acq_SingleCXP12x1Area_01 applet is used to initialize the interface + InterfaceApplet_Acq_SingleCXP12x1Area_02 //!< The Acq_SingleCXP12x1Area_02 applet is used to initialize the interface + }; + + //! Valid values for InterfaceType + enum InterfaceTypeEnums + { + InterfaceType_CL, //!< The interface uses the Camera Link transport layer + InterfaceType_CLHS, //!< The interface uses the Camera Link HS transport layer + InterfaceType_CXP, //!< The interface uses the CoaXPress transport layer + InterfaceType_Custom, //!< The interface uses a custom transport layer + InterfaceType_GEV, //!< The interface uses the GigE Vision transport layer + InterfaceType_Mixed, //!< Different interface modules of the GenTL Producer are of different types + InterfaceType_U3V //!< The interface uses the USB3 Vision transport layer + }; + + + + + //************************************************************************************************** + // Parameter class CUniversalInterfaceParams_Params_v6_2_0 + //************************************************************************************************** + + + //! A parameter class containing all parameters as members that are available for pylon interfaces + class PYLONBASE_API CUniversalInterfaceParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalInterfaceParams_Params_v6_2_0( void ); + + //! Destructor + ~CUniversalInterfaceParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CUniversalInterfaceParams_Params_v6_2_0_Data; + CUniversalInterfaceParams_Params_v6_2_0_Data* m_pCUniversalInterfaceParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: BoardSensors + //@{ + /*! + \brief Ambient temperature at the board + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& AmbientTemperature; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Sets the link configuration for the communication between the receiver and transmitter device + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpLinkConfiguration; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Enables automatic control of Power over CoaXPress (PoCXP) for the port + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& CxpPoCxpAuto; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Returns the Power over CoaXPress (PoCXP) status of the device + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpPoCxpStatus; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Resets Power over CoaXPress (PoCXP) link after an over-current trip on the device connection(s) + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& CxpPoCxpTripReset; + + //@} + + + //! \name Categories: TransportLayerControl + //@{ + /*! + \brief Disables Power over CoaXPress (PoCXP) for the port + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& CxpPoCxpTurnOff; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief CXP port 0 current + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& CxpPort0Current; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief Number of CXP port 0 disparity errors + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CxpPort0DisparityErrorCount; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief Link speed of CXP port 0 + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& CxpPort0LinkSpeed; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief Number of CXP port 0 not-in-table errors + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CxpPort0NotInTableErrorCount; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief CXP port 0 power + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& CxpPort0Power; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief Returns the PoCXP (Power over CXP) state of CXP port 0 + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& CxpPort0PowerState; + + //@} + + + //! \name Categories: Port0Status + //@{ + /*! + \brief CXP port 0 voltage + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& CxpPort0Voltage; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Returns the device's access status at the moment when the Device Update List command was last executed + + Returns the device's access status at the moment when the Device Update List command was last executed. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceAccessStatus; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Interface-wide unique ID of the selected device + + Interface-wide unique ID of the selected device. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceID; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Name of the device model + + Name of the device model. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceModelName; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Device selected in this interface + + Device selected in this interface. This value only changes when the Device Update List command is executed. The parameter is 0-based in order to match the index of the C interface. + + Visibility: Expert + + Selecting Parameters: DeviceAccessStatus, DeviceID, DeviceModelName, DeviceSerialNumber, DeviceTLVersionMajor, DeviceTLVersionMinor, DeviceVendorName, GevDeviceIPAddress, GevDeviceMACAddress and GevDeviceSubnetMask + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceSelector; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Serial number of the remote device + + Serial number of the remote device. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceSerialNumber; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Major version number of the transport layer specification that the remote device complies with + + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceTLVersionMajor; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Minor version number of the transport layer specification that the remote device complies with + + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceTLVersionMinor; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Updates the internal device list + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& DeviceUpdateList; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Timeout for the Device Update List command + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DeviceUpdateTimeout; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief User-settable ID of the remote device + + User-settable ID of the remote device. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceUserID; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Name of the device vendor + + Name of the device vendor. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceVendorName; + + //@} + + + //! \name Categories: BoardSensors + //@{ + /*! + \brief Indicates whether an external power source has been detected + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ExternalPowerPresent; + + //@} + + + //! \name Categories: BoardSensors + //@{ + /*! + \brief FPGA aux voltage + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& FpgaAuxVoltage; + + //@} + + + //! \name Categories: BoardSensors + //@{ + /*! + \brief FPGA BRAM voltage + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& FpgaBRamVoltage; + + //@} + + + //! \name Categories: BoardSensors + //@{ + /*! + \brief FPGA core temperature + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& FpgaCoreTemperature; + + //@} + + + //! \name Categories: BoardSensors + //@{ + /*! + \brief FPGA core voltage + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& FpgaCoreVoltage; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Current IP address of the GVCP interface of the selected remote device + + Current IP address of the GVCP interface of the selected remote device. This value only changes on execution of the DeviceUpdateList command. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceIPAddress; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief 48-bit MAC address of the GVCP interface of the selected remote device + + 48-bit MAC address of the GVCP interface of the selected remote device. This value only changes when the DeviceUpdateList command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceMACAddress; + + //@} + + + //! \name Categories: DeviceEnumeration + //@{ + /*! + \brief Current subnet mask of the GVCP interface of the selected remote device + + Current subnet mask of the GVCP interface of the selected remote device. This value only changes on execution of the DeviceUpdateList command. This value only changes when the DeviceUpdateList command is executed. + + Visibility: Expert + + Selected by: DeviceSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceSubnetMask; + + //@} + + + //! \name Categories: InterfaceApplets + //@{ + /*! + \brief Sets the applet with which to initialize the interface + + Sets the applet with which to initialize the interface. Applets are specific DLLs used to initialize the frame grabber. Each applet has different characteristics and functionalities. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& InterfaceApplet; + + //@} + + + //! \name Categories: InterfaceInformation + //@{ + /*! + \brief User-friendly name of the interface + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& InterfaceDisplayName; + + //@} + + + //! \name Categories: InterfaceInformation + //@{ + /*! + \brief GenTL Producer-wide unique ID of the selected interface + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& InterfaceID; + + //@} + + + //! \name Categories: InterfaceInformation + //@{ + /*! + \brief Major version number of the transport layer specification that the GenTL Producer interface complies with + + Major version number of the transport layer specification that the GenTL Producer interface complies with. The transport layer version of the interface should match the transport layer version of the device to assure compatibility. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& InterfaceTLVersionMajor; + + //@} + + + //! \name Categories: InterfaceInformation + //@{ + /*! + \brief Minor version number of the transport layer specification that the GenTL Producer interface complies with + + Minor version number of the transport layer specification that the GenTL Producer interface complies with. The transport layer version of the interface should match the transport layer version of the device to assure compatibility. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& InterfaceTLVersionMinor; + + //@} + + + //! \name Categories: InterfaceInformation + //@{ + /*! + \brief Sets the transport layer of the interface + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& InterfaceType; + + //@} + + + //! \name Categories: BoardSensors + //@{ + /*! + \brief Temperature of the board power supply + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& PowerSupplyTemperature; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUniversalInterfaceParams_Params_v6_2_0(CUniversalInterfaceParams_Params_v6_2_0&); + + //! not implemented assignment operator + CUniversalInterfaceParams_Params_v6_2_0& operator=(CUniversalInterfaceParams_Params_v6_2_0&); + + //! \endcond + }; + + + //! A parameter class containing all parameters as members that are available for pylon interfaces + class CUniversalInterfaceParams_Params : public CUniversalInterfaceParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalInterfaceParams_Params( void ) + { + } + + //! Destructor + ~CUniversalInterfaceParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CUniversalInterfaceParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_UniversalInterfaceParams + +#endif // BASLER_PYLON_UNIVERSALINTERFACEPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalStreamParams.h b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalStreamParams.h new file mode 100644 index 0000000..d12c6b4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalStreamParams.h @@ -0,0 +1,1113 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for pylon stream grabbers + +The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. +The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_UNIVERSALSTREAMPARAMS_H +#define BASLER_PYLON_UNIVERSALSTREAMPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_UniversalStreamParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for AccessMode + enum AccessModeEnums + { + AccessMode_Control, //!< The application has control access to the device - Applies to: GigE and blaze + AccessMode_Exclusive, //!< The application has exclusive access to the device - Applies to: GigE and blaze + AccessMode_Monitor, //!< The application has monitoring, i e , read-only, access to the device - Applies to: GigE and blaze + AccessMode_NotInitialized //!< Access to the device has not been initialized - Applies to: GigE and blaze + }; + + //! Valid values for PixelPerClockCycle + enum PixelPerClockCycleEnums + { + PixelPerClockCycle_One, //!< During each clock cycle, the device transmits data for one pixel - Applies to: BCON + PixelPerClockCycle_Two //!< During each clock cycle, the device transmits data for two pixels - Applies to: BCON + }; + + //! Valid values for Status + enum StatusEnums + { + Status_Closed, //!< The stream grabber is closed - Applies to: GigE + Status_Locked, //!< The stream grabber is locked - Applies to: GigE + Status_NotInitialized, //!< The stream grabber is not initialized - Applies to: GigE + Status_Open //!< The stream grabber is open - Applies to: GigE + }; + + //! Valid values for StreamBufferHandlingMode + enum StreamBufferHandlingModeEnums + { + StreamBufferHandlingMode_NewestOnly, //!< The application always gets the latest completed buffer (i e , the newest) - Applies to: CoaXPress and blaze + StreamBufferHandlingMode_OldestFirst, //!< The application always gets the buffer from the head of the output buffer queue (i e , the oldest available) - Applies to: CoaXPress and blaze + StreamBufferHandlingMode_OldestFirstOverwrite //!< The application always gets the buffer from the head of the output buffer queue (i e , the oldest available) - Applies to: CoaXPress and blaze + }; + + //! Valid values for StreamType + enum StreamTypeEnums + { + StreamType_CL, //!< The data stream uses the Camera Link transport layer - Applies to: CoaXPress + StreamType_CLHS, //!< The data stream uses the Camera Link HS transport layer - Applies to: CoaXPress + StreamType_CXP, //!< The data stream uses the CoaXPress transport layer - Applies to: CoaXPress + StreamType_Custom, //!< The data stream uses a custom transport layer - Applies to: CoaXPress + StreamType_GEV, //!< The data stream uses the GigE Vision transport layer - Applies to: CoaXPress + StreamType_Mixed, //!< Different interface modules of the GenTL Producer are of different types - Applies to: CoaXPress + StreamType_U3V //!< The data stream uses the USB3 Vision transport layer - Applies to: CoaXPress + }; + + //! Valid values for TransmissionType + enum TransmissionTypeEnums + { + TransmissionType_LimitedBroadcast, //!< The stream data is sent to all devices in the local area network (255 255 255 255) - Applies to: GigE + TransmissionType_Multicast, //!< The stream data is sent to selected devices in the local network - Applies to: GigE + TransmissionType_SubnetDirectedBroadcast, //!< The stream data is sent to all devices in the same subnet as the camera - Applies to: GigE + TransmissionType_Unicast, //!< The stream data is sent to a single device in the local network - Applies to: GigE and blaze + TransmissionType_UseCameraConfig //!< The stream transmission configuration is read from the camera - Applies to: GigE and blaze + }; + + //! Valid values for Type + enum TypeEnums + { + Type_NoDriverAvailable, //!< No suitable driver is installed - Applies to: GigE and blaze + Type_SocketDriver, //!< The socket driver is used - Applies to: GigE and blaze + Type_WindowsFilterDriver, //!< The pylon GigE Vision Filter Driver is used - Applies to: GigE and blaze + Type_WindowsIntelPerformanceDriver //!< The pylon GigE Vision Performance Driver is used - Applies to: GigE and blaze + }; + + + + + //************************************************************************************************** + // Parameter class CUniversalStreamParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for pylon stream grabbers + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class PYLONBASE_API CUniversalStreamParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalStreamParams_Params_v6_2_0( void ); + + //! Destructor + ~CUniversalStreamParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CUniversalStreamParams_Params_v6_2_0_Data; + CUniversalStreamParams_Params_v6_2_0_Data* m_pCUniversalStreamParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: Debug + //@{ + /*! + \brief Indicates the mode of access the current application has to the device - Applies to: GigE and blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AccessMode; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Enables negotiation of the packet size to find the largest possible packet size - Applies to: GigE + + Enables negotiation of the packet size to find the largest possible packet size. Using large packets reduces the overhead for transferring images. The maximum packet size depends on the network hardware and its configuration. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutoPacketSize; + + //@} + + + //! \name Categories: GrabberSettings + //@{ + /*! + \brief Clock frequency on the host side in Hertz - Applies to: BCON + + Clock frequency on the host side in Hertz. This parameter is linked with the BconClockFrequency camera parameter. If the camera parameter changes, the host parameter changes accordingly, but not vice versa. The host parameter should not be set to a value different from the camera parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ClockFrequency; + + //@} + + + //! \name Categories: IPConfig + //@{ + /*! + \brief IP address to which the stream grabber sends all stream data - Applies to: GigE and blaze + + + Visibility: Expert + + Selected by: TransmissionType + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DestinationAddr; + + //@} + + + //! \name Categories: IPConfig + //@{ + /*! + \brief Port to which the stream grabber sends all stream data - Applies to: GigE and blaze + + Port to which the stream grabber sends all stream data. If the parameter is set to zero, pylon automatically selects an unused port. + + Visibility: Expert + + Selected by: TransmissionType + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& DestinationPort; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Enables the packet resend mechanism - Applies to: GigE and blaze + + Enables the packet resend mechanism. The pylon GigE Vision Filter Driver and the GigE Vision Performance Driver use different packet resend mechanisms. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& EnableResend; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Maximum time in milliseconds to receive all packets of a frame - Applies to: GigE and blaze + + Maximum time in milliseconds to receive all packets of a frame. The timer starts when the first packet has been received. If the transmission is not completed within the given time, the corresponding frame is delivered with the status 'Failed'. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrameRetention; + + //@} + + + //! \name Categories: GrabberSettings + //@{ + /*! + \brief Height of the image ROI on the host side - Applies to: BCON + + Height of the image ROI on the host side. This parameter is linked with the Height camera parameter. If the camera parameter changes, the host parameter changes accordingly, but not vice versa. The host parameter should not be set to a value different from the camera parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Height; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Maximum size (in bytes) of a buffer used for grabbing images - Applies to: BCON, GigE, USB and blaze + + Maximum size (in bytes) of a buffer used for grabbing images. A grab application must set this parameter before grabbing starts. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MaxBufferSize; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Maximum number of buffers that can be used simultaneously for grabbing images - Applies to: BCON, GigE, USB and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MaxNumBuffer; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum USB data transfer size in bytes - Applies to: USB + + Maximum USB data transfer size in bytes. The default value is appropriate for most applications. Decreasing the value may increase the CPU load. USB host adapter drivers may require decreasing the value if the application fails to receive the image stream. The maximum value also depends on the operating system. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MaxTransferSize; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Maximum number of resend requests per missing packet - Applies to: GigE and blaze + + Maximum number of resend requests per missing packet. Only available if the pylon GigE Vision Performance Driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MaximumNumberResendRequests; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum number of USB request blocks (URBs) to be enqueued simultaneously - Applies to: USB + + Maximum number of USB request blocks (URBs) to be enqueued simultaneously. Increasing this value may improve stability and reduce jitter, but requires more resources on the host computer. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& NumMaxQueuedUrbs; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Timeout period in milliseconds between two packets within one frame - Applies to: GigE and blaze + + Timeout period in milliseconds between two packets within one frame. The timeout is reset each time a packet is received. If the timeout expires, e.g., no packet was received during the given period, the packet resend mechanism takes effect. For more information, see the Enable Resends parameter. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PacketTimeout; + + //@} + + + //! \name Categories: BufferHandlingControl and GrabberSettings + //@{ + /*! + \brief Size of the payload in bytes - Applies to: BCON and CoaXPress + + Size of the payload in bytes. This is the total number of bytes of the image data payload produced by the frame grabber. This value is computed by the frame grabber implementation. The pylon stream grabber needs to be open to be able to compute the payload size. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PayloadSize; + + //@} + + + //! \name Categories: GrabberSettings + //@{ + /*! + \brief Pixel format on the host side - Applies to: BCON + + Pixel format on the host side. This parameter is linked with the Pixel Format camera parameter. If the camera parameter changes, the host parameter changes accordingly, but not vice versa. The host parameter should not be set to a value different from the camera parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PixelFormatValue; + + //@} + + + //! \name Categories: GrabberSettings + //@{ + /*! + \brief Sets the number of pixels per clock cycle on the host side - Applies to: BCON + + Sets the number of pixels per clock cycle on the host side. This parameter is linked with the Pixels per Clock Cycle camera parameter. If the camera parameter changes, the host parameter changes accordingly, but not vice versa. The host parameter should not be set to a value different from the camera parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PixelPerClockCycle; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Thread priority of the receive thread - Applies to: GigE + + Thread priority of the receive thread. Only available if the socket driver is used. To assign the priority, the Receive Thread Priority Override parameter must be set to true. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ReceiveThreadPriority; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Enables assigning a custom priority to the thread which receives incoming stream packets - Applies to: GigE + + Enables assigning a custom priority to the thread which receives incoming stream packets. Only available if the socket driver is used. To assign the priority, use the Receive Thread Priority parameter. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& ReceiveThreadPriorityOverride; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Size (in frames) of the receive window in which the stream grabber looks for missing packets - Applies to: GigE and blaze + + Size (in frames) of the receive window in which the stream grabber looks for missing packets. Only available if the pylon GigE Vision Performance Driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ReceiveWindowSize; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Amount of packet resend requests to be batched, i e , sent together - Applies to: GigE and blaze + + Amount of packet resend requests to be batched, i.e., sent together. The parameter value is set in percent of the amount of frames between the resend request threshold and the start of the receive window. Only available if the pylon GigE Vision Performance Driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ResendRequestBatching; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Time to wait (in milliseconds) between sending a resend request and considering the request as lost - Applies to: GigE and blaze + + Time to wait (in milliseconds) between sending a resend request and considering the request as lost. Only available if the pylon GigE Vision Performance Driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ResendRequestResponseTimeout; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Threshold after which resend requests are initiated - Applies to: GigE and blaze + + Threshold after which resend requests are initiated. The parameter value is set in percent of the receive window size (Receive Window Size parameter). Only available if the pylon GigE Vision Performance Driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ResendRequestThreshold; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Time to wait (in milliseconds) between detecting a missing packet and sending a resend request - Applies to: GigE and blaze + + Time to wait (in milliseconds) between detecting a missing packet and sending a resend request. Only available if the pylon GigE Vision Performance Driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ResendTimeout; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Socket buffer size in kilobytes - Applies to: GigE and blaze + + Socket buffer size in kilobytes. Only available if the socket driver is used. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SocketBufferSize; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of frames lost because there were no buffers in the queue - Applies to: GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Buffer_Underrun_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief GigE cameras: Number of buffers with at least one failed packet A packet is considered failed if its status is not 'success' Other cameras: Number of buffers that returned with an error status - Applies to: BCON, GigE, USB and blaze + + GigE cameras: Number of buffers with at least one failed packet. A packet is considered failed if its status is not 'success'. Other cameras: Number of buffers that returned an error. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Failed_Buffer_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of failed packets - Applies to: GigE and blaze + + Number of failed packets, i.e., the number of packets whose status is not 'success'. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Failed_Packet_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Last grabbed block ID - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Last_Block_Id; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Status code of the last failed buffer - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Last_Failed_Buffer_Status; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Status code of the last failed buffer - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& Statistic_Last_Failed_Buffer_Status_Text; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of corrupt or lost frames between successfully grabbed images - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Missed_Frame_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of out-of-memory errors - Applies to: USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Out_Of_Memory_Error_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of packets requested by packet resend commands - Applies to: GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Resend_Packet_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of emitted packet resend commands sent - Applies to: GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Resend_Request_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of stream resynchronizations - Applies to: USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Resynchronization_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief GigE cameras: Number of frames received Other cameras: Number of buffers processed - Applies to: BCON, GigE, USB and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Total_Buffer_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of packets received - Applies to: GigE and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Total_Packet_Count; + + //@} + + + //! \name Categories: Debug + //@{ + /*! + \brief Indicates the current status of the stream grabber - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Status; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Minimum number of buffers to announce to enable selected buffer handling mode - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamAnnounceBufferMinimum; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Number of announced (known) buffers on this stream - Applies to: CoaXPress and blaze + + Number of announced (known) buffers on this stream. This value is volatile. It may change if additional buffers are announced and/or buffers are revoked by the GenTL Consumer. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamAnnouncedBufferCount; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Alignment size in bytes of the buffers passed to DSAnnounceBuffer - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamBufferAlignment; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Sets the buffer handling mode of this data stream - Applies to: CoaXPress and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& StreamBufferHandlingMode; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Maximum number of chunks to be expected in a buffer - Applies to: CoaXPress + + Maximum number of chunks to be expected in a buffer (can be used to allocate the array for the DSGetBufferChunkData function). + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamChunkCountMaximum; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Number of delivered frames since last acquisition start - Applies to: CoaXPress and blaze + + Number of delivered frames since last acquisition start. It isn't reset until the stream is closed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamDeliveredFrameCount; + + //@} + + + //! \name Categories: StreamInformation + //@{ + /*! + \brief Device-wide unique ID of the data stream - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& StreamID; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Number of buffers in the input buffer pool plus the buffers currently being filled - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamInputBufferCount; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Indicates whether the acquisition engine is started or not - Applies to: CoaXPress and blaze + + Indicates whether the acquisition engine is started or not. This is independent of the acquisition status of the remote device. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& StreamIsGrabbing; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Number of lost frames due to queue underrun - Applies to: CoaXPress and blaze + + Number of lost frames due to queue underrun. This number is initialized with zero at the time the stream is opened and incremented every time data couldn't be acquired because there was no buffer in the input buffer pool. It isn't reset until the stream is closed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamLostFrameCount; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Number of buffers in the output buffer queue - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamOutputBufferCount; + + //@} + + + //! \name Categories: BufferHandlingControl + //@{ + /*! + \brief Number of frames started in the acquisition engine - Applies to: CoaXPress and blaze + + Number of frames started in the acquisition engine. This number is incremented every time a new buffer is started and then filled regardless of whether the buffer is later delivered to the user or discarded for any reason. This number is initialized with 0 at at the time the stream is opened. It isn't reset until the stream is closed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamStartedFrameCount; + + //@} + + + //! \name Categories: StreamInformation + //@{ + /*! + \brief Sets the transport layer of the data stream - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& StreamType; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Priority of the thread that handles USB requests from the stream interface - Applies to: USB + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TransferLoopThreadPriority; + + //@} + + + //! \name Categories: IPConfig + //@{ + /*! + \brief Sets how stream data is transferred within the network - Applies to: GigE and blaze + + Sets how stream data is transferred within the network. The stream grabber can send the stream data to one specific device or to multiple devices in the network. + + Visibility: Expert + + Selecting Parameters: DestinationAddr and DestinationPort + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TransmissionType; + + //@} + + + //! \name Categories: ExtendedStreamControl and Root + //@{ + /*! + \brief Sets the driver type to be used by the stream grabber - Applies to: GigE and blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Type; + + //@} + + + //! \name Categories: Debug + //@{ + /*! + \brief Indicates whether the socket driver is currently available - Applies to: GigE and blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TypeIsSocketDriverAvailable; + + //@} + + + //! \name Categories: Debug + //@{ + /*! + \brief Indicates whether the pylon GigE Vision Filter Driver is currently available - Applies to: GigE and blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TypeIsWindowsFilterDriverAvailable; + + //@} + + + //! \name Categories: Debug + //@{ + /*! + \brief Indicates whether the pylon GigE Vision Performance Driver is currently available - Applies to: GigE and blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TypeIsWindowsIntelPerformanceDriverAvailable; + + //@} + + + //! \name Categories: GrabberSettings + //@{ + /*! + \brief Width of the image ROI on the host side - Applies to: BCON + + Width of the image ROI on the host side. This parameter is linked with the Width camera parameter. If the camera parameter changes, the host parameter changes accordingly, but not vice versa. The host parameter should not be set to a value different from the camera parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Width; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUniversalStreamParams_Params_v6_2_0(CUniversalStreamParams_Params_v6_2_0&); + + //! not implemented assignment operator + CUniversalStreamParams_Params_v6_2_0& operator=(CUniversalStreamParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for pylon stream grabbers + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class CUniversalStreamParams_Params : public CUniversalStreamParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalStreamParams_Params( void ) + { + } + + //! Destructor + ~CUniversalStreamParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CUniversalStreamParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_UniversalStreamParams + +#endif // BASLER_PYLON_UNIVERSALSTREAMPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalTLParams.h b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalTLParams.h new file mode 100644 index 0000000..a4300a0 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_BaslerUniversalTLParams.h @@ -0,0 +1,1953 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2019-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for pylon device transport layers + +The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. +The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_UNIVERSALTLPARAMS_H +#define BASLER_PYLON_UNIVERSALTLPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_UniversalTLParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for AreaTriggerMode + enum AreaTriggerModeEnums + { + AreaTriggerMode_External, //!< The trigger mode is set to External - Applies to: CoaXPress + AreaTriggerMode_Generator, //!< The trigger mode is set to Generator - Applies to: CoaXPress + AreaTriggerMode_Software //!< The trigger mode is set to Software - Applies to: CoaXPress + }; + + //! Valid values for BitAlignment + enum BitAlignmentEnums + { + BitAlignment_CustomBitShift, //!< The bits are shifted by a user-defined value - Applies to: CoaXPress + BitAlignment_LeftAligned, //!< The bits left-aligned - Applies to: CoaXPress + BitAlignment_RightAligned //!< The bits right-aligned - Applies to: CoaXPress + }; + + //! Valid values for DeviceAccessStatus + enum DeviceAccessStatusEnums + { + DeviceAccessStatus_Busy, //!< The device is already opened by another entity - Applies to: CoaXPress and blaze + DeviceAccessStatus_NoAccess, //!< You can't connect to the device - Applies to: CoaXPress and blaze + DeviceAccessStatus_OpenReadOnly, //!< The device is opened in Read-only mode by this GenTL host - Applies to: CoaXPress and blaze + DeviceAccessStatus_OpenReadWrite, //!< The device is opened in Read/Write mode by this GenTL host - Applies to: CoaXPress and blaze + DeviceAccessStatus_ReadOnly, //!< The device offers read-only access - Applies to: CoaXPress and blaze + DeviceAccessStatus_ReadWrite, //!< The device offers read/write access - Applies to: CoaXPress and blaze + DeviceAccessStatus_Unknown //!< The status is unknown - Applies to: CoaXPress and blaze + }; + + //! Valid values for DeviceEndianessMechanism + enum DeviceEndianessMechanismEnums + { + DeviceEndianessMechanism_Legacy, //!< The device endianness is handled according to GenICam Schema 1 0 - Applies to: blaze + DeviceEndianessMechanism_Standard //!< The device endianness is handled according to GenICam Schema 1 1 and later - Applies to: blaze + }; + + //! Valid values for DeviceType + enum DeviceTypeEnums + { + DeviceType_CL, //!< The device uses the Camera Link transport layer - Applies to: CoaXPress + DeviceType_CLHS, //!< The device uses the Camera Link HS transport layer - Applies to: CoaXPress + DeviceType_CXP, //!< The device uses the CoaXPress transport layer - Applies to: CoaXPress + DeviceType_Custom, //!< The device uses a custom transport layer - Applies to: CoaXPress + DeviceType_GEV, //!< The device uses the GigE Vision transport layer - Applies to: CoaXPress + DeviceType_Mixed, //!< Different interface modules of the GenTL Producer are of different types - Applies to: CoaXPress + DeviceType_U3V //!< The device uses the USB3 Vision transport layer - Applies to: CoaXPress + }; + + //! Valid values for EventNotification + enum EventNotificationEnums + { + EventNotification_Off, //!< The selected Event notification is disabled - Applies to: CoaXPress and blaze + EventNotification_On, //!< The selected Event notification is enabled - Applies to: CoaXPress and blaze + EventNotification_Once //!< The selected Event notification is enabled for one event then return to Off state - Applies to: CoaXPress and blaze + }; + + //! Valid values for EventSelector + enum EventSelectorEnums + { + EventSelector_DeviceLost //!< Selects the Device Lost Event - Applies to: CoaXPress and blaze + }; + + //! Valid values for Format + enum FormatEnums + { + Format_BGR10p, //!< The pixel output format is set to BGR10p - Applies to: CoaXPress + Format_BGR12p, //!< The pixel output format is set to BGR12p - Applies to: CoaXPress + Format_BGR16, //!< The pixel output format is set to BGR16 - Applies to: CoaXPress + Format_BGR8, //!< The pixel output format is set to BGR8 - Applies to: CoaXPress + Format_BayerBG10p, //!< The pixel output format is set to BayerBG10p - Applies to: CoaXPress + Format_BayerBG12p, //!< The pixel output format is set to BayerBG12p - Applies to: CoaXPress + Format_BayerBG16, //!< The pixel output format is set to BayerBG16 - Applies to: CoaXPress + Format_BayerBG8, //!< The pixel output format is set to BayerBG8 - Applies to: CoaXPress + Format_BayerGB10p, //!< The pixel output format is set to BayerGB10p - Applies to: CoaXPress + Format_BayerGB12p, //!< The pixel output format is set to BayerGB12p - Applies to: CoaXPress + Format_BayerGB16, //!< The pixel output format is set to BayerGB16 - Applies to: CoaXPress + Format_BayerGB8, //!< The pixel output format is set to BayerGB8 - Applies to: CoaXPress + Format_BayerGR10p, //!< The pixel output format is set to BayerGR10p - Applies to: CoaXPress + Format_BayerGR12p, //!< The pixel output format is set to BayerGR12p - Applies to: CoaXPress + Format_BayerGR16, //!< The pixel output format is set to BayerGR16 - Applies to: CoaXPress + Format_BayerGR8, //!< The pixel output format is set to BayerGR8 - Applies to: CoaXPress + Format_BayerRG10p, //!< The pixel output format is set to BayerRG10p - Applies to: CoaXPress + Format_BayerRG12p, //!< The pixel output format is set to BayerRG12p - Applies to: CoaXPress + Format_BayerRG16, //!< The pixel output format is set to BayerRG16 - Applies to: CoaXPress + Format_BayerRG8, //!< The pixel output format is set to BayerRG8 - Applies to: CoaXPress + Format_Mono10p, //!< The pixel output format is set to Mono10p - Applies to: CoaXPress + Format_Mono12p, //!< The pixel output format is set to Mono12p - Applies to: CoaXPress + Format_Mono16, //!< The pixel output format is set to Mono16 - Applies to: CoaXPress + Format_Mono8, //!< The pixel output format is set to Mono8 - Applies to: CoaXPress + Format_YCbCr422_8 //!< The pixel output format is set to YCbCr422_8 - Applies to: CoaXPress + }; + + //! Valid values for PixelFormat + enum PixelFormatEnums + { + PixelFormat_BayerBG10p, //!< The pixel format is set to BayerBG10 - Applies to: CoaXPress + PixelFormat_BayerBG12p, //!< The pixel format is set to BayerBG12 - Applies to: CoaXPress + PixelFormat_BayerBG8, //!< The pixel format is set to BayerBG8 - Applies to: CoaXPress + PixelFormat_BayerGB10p, //!< The pixel format is set to BayerGB10 - Applies to: CoaXPress + PixelFormat_BayerGB12p, //!< The pixel format is set to BayerGB12 - Applies to: CoaXPress + PixelFormat_BayerGB8, //!< The pixel format is set to BayerGB8 - Applies to: CoaXPress + PixelFormat_BayerGR10p, //!< The pixel format is set to BayerGR10 - Applies to: CoaXPress + PixelFormat_BayerGR12p, //!< The pixel format is set to BayerGR12 - Applies to: CoaXPress + PixelFormat_BayerGR8, //!< The pixel format is set to BayerGR8 - Applies to: CoaXPress + PixelFormat_BayerRG10p, //!< The pixel format is set to BayerRG10 - Applies to: CoaXPress + PixelFormat_BayerRG12p, //!< The pixel format is set to BayerRG12 - Applies to: CoaXPress + PixelFormat_BayerRG8, //!< The pixel format is set to BayerRG8 - Applies to: CoaXPress + PixelFormat_Mono10, //!< The pixel format is set to Mono10 - Applies to: CoaXPress + PixelFormat_Mono12, //!< The pixel format is set to Mono12 - Applies to: CoaXPress + PixelFormat_Mono8, //!< The pixel format is set to Mono8 - Applies to: CoaXPress + PixelFormat_RGB10p, //!< The pixel format is set to RGB10 - Applies to: CoaXPress + PixelFormat_RGB12p, //!< The pixel format is set to RGB12 - Applies to: CoaXPress + PixelFormat_RGB8, //!< The pixel format is set to RGB8 - Applies to: CoaXPress + PixelFormat_YCbCr422_8 //!< The pixel format is set to YCbCr422_8 - Applies to: CoaXPress + }; + + //! Valid values for SoftwareTriggerIsBusy + enum SoftwareTriggerIsBusyEnums + { + SoftwareTriggerIsBusy_Busy, //!< The software trigger is busy - Applies to: CoaXPress + SoftwareTriggerIsBusy_NotBusy //!< The software trigger is not busy - Applies to: CoaXPress + }; + + //! Valid values for SystemmonitorByteAlignment8b10bLocked + enum SystemmonitorByteAlignment8b10bLockedEnums + { + SystemmonitorByteAlignment8b10bLocked_No, //!< No - Applies to: CoaXPress + SystemmonitorByteAlignment8b10bLocked_Yes //!< Yes - Applies to: CoaXPress + }; + + //! Valid values for SystemmonitorExternalPower + enum SystemmonitorExternalPowerEnums + { + SystemmonitorExternalPower_NoPower, //!< No power - Applies to: CoaXPress + SystemmonitorExternalPower_PowerGood //!< Power is ok - Applies to: CoaXPress + }; + + //! Valid values for SystemmonitorPowerOverCxpState + enum SystemmonitorPowerOverCxpStateEnums + { + SystemmonitorPowerOverCxpState_PoCXPADCChipError, //!< ADC Chip Error - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPBooting, //!< Booting, not initalized - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPDisabled, //!< No Power over CXP - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPLowVolt, //!< Low voltage - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPMaxCurrent, //!< Maximum current - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPMinCurrent, //!< Minimum current - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPNotConnected, //!< No cable connected - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPOK, //!< Power over CXP OK - Applies to: CoaXPress + SystemmonitorPowerOverCxpState_PoCXPOverVolt //!< Over voltage - Applies to: CoaXPress + }; + + //! Valid values for TriggerCameraOutSelect + enum TriggerCameraOutSelectEnums + { + TriggerCameraOutSelect_BypassFrontGPI0, //!< The output source is set to BypassFrontGPI0 - Applies to: CoaXPress + TriggerCameraOutSelect_BypassFrontGPI1, //!< The output source is set to BypassFrontGPI1 - Applies to: CoaXPress + TriggerCameraOutSelect_BypassFrontGPI2, //!< The output source is set to BypassFrontGPI2 - Applies to: CoaXPress + TriggerCameraOutSelect_BypassFrontGPI3, //!< The output source is set to BypassFrontGPI3 - Applies to: CoaXPress + TriggerCameraOutSelect_CamAPulseGenerator0, //!< The output source is set to CamAPulseGenerator0 - Applies to: CoaXPress + TriggerCameraOutSelect_CamAPulseGenerator1, //!< The output source is set to CamAPulseGenerator1 - Applies to: CoaXPress + TriggerCameraOutSelect_CamAPulseGenerator2, //!< The output source is set to CamAPulseGenerator2 - Applies to: CoaXPress + TriggerCameraOutSelect_CamAPulseGenerator3, //!< The output source is set to CamAPulseGenerator3 - Applies to: CoaXPress + TriggerCameraOutSelect_GND, //!< The output source is set to GND - Applies to: CoaXPress + TriggerCameraOutSelect_NotBypassFronGPI0, //!< The output source is set to NotBypassFrontGPI0 - Applies to: CoaXPress + TriggerCameraOutSelect_NotBypassFronGPI1, //!< The output source is set to NotBypassFrontGPI1 - Applies to: CoaXPress + TriggerCameraOutSelect_NotBypassFronGPI2, //!< The output source is set to NotBypassFrontGPI2 - Applies to: CoaXPress + TriggerCameraOutSelect_NotBypassFronGPI3, //!< The output source is set to NotBypassFrontGPI3 - Applies to: CoaXPress + TriggerCameraOutSelect_NotCamAPulseGenerator0, //!< The output source is set to NotCamAPulseGenerator0 - Applies to: CoaXPress + TriggerCameraOutSelect_NotCamAPulseGenerator1, //!< The output source is set to NotCamAPulseGenerator1 - Applies to: CoaXPress + TriggerCameraOutSelect_NotCamAPulseGenerator2, //!< The output source is set to NotCamAPulseGenerator2 - Applies to: CoaXPress + TriggerCameraOutSelect_NotCamAPulseGenerator3, //!< The output source is set to NotCamAPulseGenerator3 - Applies to: CoaXPress + TriggerCameraOutSelect_NotPulseGenerator0, //!< The output source is set to NotPulseGenerator0 - Applies to: CoaXPress + TriggerCameraOutSelect_NotPulseGenerator1, //!< The output source is set to NotPulseGenerator1 - Applies to: CoaXPress + TriggerCameraOutSelect_NotPulseGenerator2, //!< The output source is set to NotPulseGenerator2 - Applies to: CoaXPress + TriggerCameraOutSelect_NotPulseGenerator3, //!< The output source is set to NotPulseGenerator3 - Applies to: CoaXPress + TriggerCameraOutSelect_PulseGenerator0, //!< The output source is set to PulseGenerator0 - Applies to: CoaXPress + TriggerCameraOutSelect_PulseGenerator1, //!< The output source is set to PulseGenerator1 - Applies to: CoaXPress + TriggerCameraOutSelect_PulseGenerator2, //!< The output source is set to PulseGenerator2 - Applies to: CoaXPress + TriggerCameraOutSelect_PulseGenerator3, //!< The output source is set to PulseGenerator3 - Applies to: CoaXPress + TriggerCameraOutSelect_VCC //!< The output source is set to VCC - Applies to: CoaXPress + }; + + //! Valid values for TriggerInPolarity + enum TriggerInPolarityEnums + { + TriggerInPolarity_HighActive, //!< The polarity is set to HighActive - Applies to: CoaXPress + TriggerInPolarity_LowActive //!< The polarity is set to LowActive - Applies to: CoaXPress + }; + + //! Valid values for TriggerInSource + enum TriggerInSourceEnums + { + TriggerInSource_TriggerInSourceFrontGPI0, //!< The trigger input source is set to TriggerInSourceFrontGPI0 - Applies to: CoaXPress + TriggerInSource_TriggerInSourceFrontGPI1, //!< The trigger input source is set to TriggerInSourceFrontGPI1 - Applies to: CoaXPress + TriggerInSource_TriggerInSourceFrontGPI2, //!< The trigger input source is set to TriggerInSourceFrontGPI2 - Applies to: CoaXPress + TriggerInSource_TriggerInSourceFrontGPI3 //!< The trigger input source is set to TriggerInSourceFrontGPI3 - Applies to: CoaXPress + }; + + //! Valid values for TriggerOutSelectFrontGPO0 + enum TriggerOutSelectFrontGPO0Enums + { + TriggerOutSelectFrontGPO0_BypassFrontGPI0, //!< The output source is set to BypassFrontGPI0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_BypassFrontGPI1, //!< The output source is set to BypassFrontGPI1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_BypassFrontGPI2, //!< The output source is set to BypassFrontGPI2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_BypassFrontGPI3, //!< The output source is set to BypassFrontGPI3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_CamAPulseGenerator0, //!< The output source is set to CamAPulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_CamAPulseGenerator1, //!< The output source is set to CamAPulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_CamAPulseGenerator2, //!< The output source is set to CamAPulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_CamAPulseGenerator3, //!< The output source is set to CamAPulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_GND, //!< The output source is set to GND - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotBypassFronGPI0, //!< The output source is set to NotBypassFrontGPI0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotBypassFronGPI1, //!< The output source is set to NotBypassFrontGPI1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotBypassFronGPI2, //!< The output source is set to NotBypassFrontGPI2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotBypassFronGPI3, //!< The output source is set to NotBypassFrontGPI3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotCamAPulseGenerator0, //!< The output source is set to NotCamAPulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotCamAPulseGenerator1, //!< The output source is set to NotCamAPulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotCamAPulseGenerator2, //!< The output source is set to NotCamAPulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotCamAPulseGenerator3, //!< The output source is set to NotCamAPulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotPulseGenerator0, //!< The output source is set to NotPulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotPulseGenerator1, //!< The output source is set to NotPulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotPulseGenerator2, //!< The output source is set to NotPulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_NotPulseGenerator3, //!< The output source is set to NotPulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_PulseGenerator0, //!< The output source is set to PulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_PulseGenerator1, //!< The output source is set to PulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_PulseGenerator2, //!< The output source is set to PulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_PulseGenerator3, //!< The output source is set to PulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO0_VCC //!< The output source is set to VCC - Applies to: CoaXPress + }; + + //! Valid values for TriggerOutSelectFrontGPO1 + enum TriggerOutSelectFrontGPO1Enums + { + TriggerOutSelectFrontGPO1_BypassFrontGPI0, //!< The output source is set to BypassFrontGPI0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_BypassFrontGPI1, //!< The output source is set to BypassFrontGPI1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_BypassFrontGPI2, //!< The output source is set to BypassFrontGPI2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_BypassFrontGPI3, //!< The output source is set to BypassFrontGPI3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_CamAPulseGenerator0, //!< The output source is set to CamAPulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_CamAPulseGenerator1, //!< The output source is set to CamAPulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_CamAPulseGenerator2, //!< The output source is set to CamAPulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_CamAPulseGenerator3, //!< The output source is set to CamAPulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_GND, //!< The output source is set to GND - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotBypassFronGPI0, //!< The output source is set to NotBypassFrontGPI0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotBypassFronGPI1, //!< The output source is set to NotBypassFrontGPI1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotBypassFronGPI2, //!< The output source is set to NotBypassFrontGPI2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotBypassFronGPI3, //!< The output source is set to NotBypassFrontGPI3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotCamAPulseGenerator0, //!< The output source is set to NotCamAPulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotCamAPulseGenerator1, //!< The output source is set to NotCamAPulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotCamAPulseGenerator2, //!< The output source is set to NotCamAPulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotCamAPulseGenerator3, //!< The output source is set to NotCamAPulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotPulseGenerator0, //!< The output source is set to NotPulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotPulseGenerator1, //!< The output source is set to NotPulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotPulseGenerator2, //!< The output source is set to NotPulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_NotPulseGenerator3, //!< The output source is set to NotPulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_PulseGenerator0, //!< The output source is set to PulseGenerator0 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_PulseGenerator1, //!< The output source is set to PulseGenerator1 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_PulseGenerator2, //!< The output source is set to PulseGenerator2 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_PulseGenerator3, //!< The output source is set to PulseGenerator3 - Applies to: CoaXPress + TriggerOutSelectFrontGPO1_VCC //!< The output source is set to VCC - Applies to: CoaXPress + }; + + //! Valid values for TriggerQueueMode + enum TriggerQueueModeEnums + { + TriggerQueueMode_Off, //!< The trigger queue mode is disabled - Applies to: CoaXPress + TriggerQueueMode_On //!< The trigger queue mode is enabled - Applies to: CoaXPress + }; + + //! Valid values for TriggerState + enum TriggerStateEnums + { + TriggerState_Active, //!< The trigger state is set to Active - Applies to: CoaXPress + TriggerState_AsyncStop, //!< The trigger state is set to AsyncStop - Applies to: CoaXPress + TriggerState_SyncStop //!< The trigger state is set to SyncStop - Applies to: CoaXPress + }; + + + + + //************************************************************************************************** + // Parameter class CUniversalTLParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for pylon device transport layers + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class PYLONBASE_API CUniversalTLParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalTLParams_Params_v6_2_0( void ); + + //! Destructor + ~CUniversalTLParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CUniversalTLParams_Params_v6_2_0_Data; + CUniversalTLParams_Params_v6_2_0_Data* m_pCUniversalTLParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: Trigger + //@{ + /*! + \brief Sets the trigger mode of the area trigger signal - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& AreaTriggerMode; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Enables/disables automatic control of the pixel format in the device - Applies to: CoaXPress + + Enables/disables automatic control of the pixel format in the device. If enabled, the frame grabber's pixel format and its dependencies are automatically updated to match the camera's pixel format setting. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& AutomaticFormatControl; + + //@} + + + //! \name Categories: OutputFormat + //@{ + /*! + \brief Sets the alignment of the bits in the output format - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& BitAlignment; + + //@} + + + //! \name Categories: ExtendedDeviceControl and Root + //@{ + /*! + \brief Enables sending all commands and receiving all acknowledges twice - Applies to: GigE and blaze + + Enables sending all commands and receiving all acknowledges twice. This option should only be enabled in case of network problems. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& CommandDuplicationEnable; + + //@} + + + //! \name Categories: OutputFormat + //@{ + /*! + \brief User-defined bit shift to the right - Applies to: CoaXPress + + User-defined bit shift to the right. This allows you to shift the pixel data in the output format to the right by a value of your choice. The Alignment parameter has to be set to CustomBitShift for this. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& CustomBitShiftRight; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Returns the device's access status at the moment when the Device Update List command was last executed - Applies to: CoaXPress and blaze + + Returns the device's access status at the moment when the Device Update List command was last executed. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceAccessStatus; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief User-friendly name of the device - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceDisplayName; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Sets the endianness handling mode - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceEndianessMechanism; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Interface-wide unique ID of the selected device - Applies to: CoaXPress and blaze + + Interface-wide unique ID of the selected device. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceID; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Additional information about the manufacturer of the device - Applies to: blaze + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceManufacturerInfo; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Name of the device model - Applies to: CoaXPress and blaze + + Name of the device model. This value only changes when the Device Update List command is executed. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceModelName; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Serial number of the remote device - Applies to: blaze + + Serial number of the remote device. This value only changes when the Device Update List command is executed. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceSerialNumber; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Returns the transport layer of the device - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& DeviceType; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Name of the device vendor - Applies to: CoaXPress and blaze + + Name of the device vendor. This value only changes when the Device Update List command is executed. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& DeviceVendorName; + + //@} + + + //! \name Categories: EventDeviceLostData + //@{ + /*! + \brief Returns the unique Identifier of the Device Lost type of Event - Applies to: CoaXPress and blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& EventDeviceLost; + + //@} + + + //! \name Categories: EventControl + //@{ + /*! + \brief Activate or deactivate the notification to the host application of the occurrence of the selected Event - Applies to: CoaXPress and blaze + + + Visibility: Expert + + Selected by: EventSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& EventNotification; + + //@} + + + //! \name Categories: EventControl + //@{ + /*! + \brief Selects which Event to signal to the host application - Applies to: CoaXPress and blaze + + + Visibility: Expert + + Selecting Parameters: EventNotification + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& EventSelector; + + //@} + + + //! \name Categories: BufferStatus + //@{ + /*! + \brief Current buffer fill level - Applies to: CoaXPress + + Current buffer fill level. This value allows you to check whether the average input bandwidth of the camera is too high to be processed by the applet. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FillLevel; + + //@} + + + //! \name Categories: OutputFormat + //@{ + /*! + \brief Sets the pixel format of the image that is output to the computer - Applies to: CoaXPress + + Sets the pixel format of the image that is output to the computer. The data is converted from the internal bit width and color format to the output format selected. This setting is not related to the pixel format input from the camera sensor. For more information, see the Pixel Format parameter documentation. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& Format; + + //@} + + + //! \name Categories: External + //@{ + /*! + \brief Current input signal levels of all front GPI inputs (bit mask) - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& FrontGPI; + + //@} + + + //! \name Categories: Gentl + //@{ + /*! + \brief Applies to: CoaXPress + + Ignore the FG output format and manage it internally in the GenTL producer + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& GentlInfoIgnorefgformat; + + //@} + + + //! \name Categories: Gentl + //@{ + /*! + \brief Applies to: CoaXPress + + Version of the GenTL description Interface in the applet. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& GentlInfoVersion; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Current gateway IP address of the GVCP interface of the remote device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceGateway; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Current IP address of the GVCP interface of the remote device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceIPAddress; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief 48-bit MAC address of the GVCP interface of the remote device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceMACAddress; + + //@} + + + //! \name Categories: DeviceInformation + //@{ + /*! + \brief Current subnet mask of the GVCP interface of the remote device - Applies to: blaze + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& GevDeviceSubnetMask; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Heartbeat timeout value on the host side in milliseconds - Applies to: GigE + + Heartbeat timeout value on the host side in milliseconds. This parameter is linked with the Heartbeat Timeout camera parameter. If the camera parameter changes, the host parameter changes accordingly, and vice versa. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& HeartbeatTimeout; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Specifies maximum number of tries before failing the control channel commands - Applies to: blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& LinkCommandRetryCount; + + //@} + + + //! \name Categories: DeviceControl + //@{ + /*! + \brief Specifies application timeout for the control channel communication - Applies to: blaze + + Specifies application timeout for the control channel communication. Up to DeviceLinkCommandRetryCount attempts with this timeout are made before a command fails with a timeout error. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& LinkCommandTimeout; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum number of retries for read operations after a read operation has timed out - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MaxRetryCountRead; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Maximum number of retries for write operations after a write operation has timed out - Applies to: GigE + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& MaxRetryCountWrite; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Enables mapping of certain SFNC 1 x node names to SFNC 2 x node names - Applies to: GigE and USB + + Enables mapping of certain SFNC 1.x node names to SFNC 2.x node names. This allows you to write code for camera devices that are compatible with different SFNC (Standard Features Naming Convention) versions. Available for USB camera devices only. + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& MigrationModeEnable; + + //@} + + + //! \name Categories: ImageFormatControl + //@{ + /*! + \brief Automatically outputs packed formats instead of unpacked ones - Applies to: CoaXPress + + Automatically outputs packed formats instead of unpacked ones. This parameter is only available if the Automatic Format Control parameter is enabled. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IBooleanEx& OutputPackedFormats; + + //@} + + + //! \name Categories: BufferStatus + //@{ + /*! + \brief Indicates whether the image buffer is currently in overflow state - Applies to: CoaXPress + + Indicates whether if the image buffer is currently in overflow state. An overflow results in the loss of images. The parameter is reset at each readout cycle. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Overflow; + + //@} + + + //! \name Categories: OutputFormat + //@{ + /*! + \brief Applet-internal processing bit depth - Applies to: CoaXPress + + Applet-internal processing bit depth. This is the maximum bit depth at which pixels are processed. If you select a highter output and input bit depth, data may be truncated. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& PixelDepth; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Sets the format of the pixel data transmitted by the camera - Applies to: CoaXPress + + Sets the format of the pixel data transmitted by the camera. This setting has to match the pixel format set in the camera. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& PixelFormat; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Read access timeout value in milliseconds - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& ReadTimeout; + + //@} + + + //! \name Categories: SoftwareTrigger + //@{ + /*! + \brief Sends a software trigger pulse - Applies to: CoaXPress + + Sends a software trigger pulse or adds pulses to the trigger queue if it is enabled. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::ICommandEx& SendSoftwareTrigger; + + //@} + + + //! \name Categories: SoftwareTrigger + //@{ + /*! + \brief Indicates whether the software trigger is busy - Applies to: CoaXPress + + Indicates whether the software trigger is busy. This allows you to find out whether the trigger system is still processing software trigger pulses. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SoftwareTriggerIsBusy; + + //@} + + + //! \name Categories: SoftwareTrigger + //@{ + /*! + \brief Number of pulses in queue to be processed - Applies to: CoaXPress + + Number of pulses in queue to be processed. The Queue parameter needs to be enabled for this. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SoftwareTriggerQueueFillLevel; + + //@} + + + //! \name Categories: ExtendedDeviceControl and Root + //@{ + /*! + \brief Number of timeouts during read and write operations when waiting for a response from the device - Applies to: GigE and blaze + + + Visibility: Guru + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StatisticReadWriteTimeoutCount; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Last error status of a read or write operation - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Last_Error_Status; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Last error status of a read or write operation - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& Statistic_Last_Error_Status_Text; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of failed read operations - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Read_Operations_Failed_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of read pipe resets - Applies to: USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Read_Pipe_Reset_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of failed write operations - Applies to: BCON and USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Write_Operations_Failed_Count; + + //@} + + + //! \name Categories: Statistic + //@{ + /*! + \brief Number of write pipe resets - Applies to: USB + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& Statistic_Write_Pipe_Reset_Count; + + //@} + + + //! \name Categories: StreamEnumeration + //@{ + /*! + \brief User-friendly name of the selected stream - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& StreamDisplayName; + + //@} + + + //! \name Categories: StreamEnumeration + //@{ + /*! + \brief Device-wide unique ID of the data stream - Applies to: CoaXPress and blaze + + + Visibility: Beginner + + Selected by: StreamSelector + + The Basler Product Documentation may provide more information. + */ + Pylon::IStringEx& StreamID; + + //@} + + + //! \name Categories: StreamEnumeration + //@{ + /*! + \brief Sets the stream channel - Applies to: CoaXPress and blaze + + Sets the stream channel. The selector is 0-based in order to match the index of the C interface. + + Visibility: Beginner + + Selecting Parameters: StreamID + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& StreamSelector; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Byte Alignment 8b10b locked + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SystemmonitorByteAlignment8b10bLocked; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the Channel Current. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorChannelCurrent; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SystemmonitorChannelCurrentSelector; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the Channel Voltage. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorChannelVoltage; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SystemmonitorChannelVoltageSelector; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the current PCIe link speed in Gibibyte (2^30 byte). + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorCurrentLinkSpeed; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Disparity 8b 10b errors + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SystemmonitorDisparity8b10bError; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Shows the external power state of the board. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SystemmonitorExternalPower; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the current FPGA die temperature. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorFpgaTemperature; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the current FPGA auxiliary Vcc. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorFpgaVccAux; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the current FPGA BRAM Vcc. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorFpgaVccBram; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the current FPGA internal Vcc. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorFpgaVccInt; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Not in table 8b 10b errors + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SystemmonitorNotInTable8b10bError; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the PCIe trained payload size. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SystemmonitorPcieTrainedPayloadSize; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the PCIe trained request size. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& SystemmonitorPcieTrainedRequestSize; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Returns the port bit rate + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& SystemmonitorPortBitRate; + + //@} + + + //! \name Categories: Miscellaneous + //@{ + /*! + \brief Applies to: CoaXPress + + Shows the current power over CXP state. + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& SystemmonitorPowerOverCxpState; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Number of trigger acknowledgement packets sent by the camera have been received by the frame grabber - Applies to: CoaXPress + + Number of trigger acknowledgement packets sent by the camera (in response to trigger edge packets sent before) have been received by the frame grabber. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerAcknowledgementCount; + + //@} + + + //! \name Categories: CameraOutSignalMapping + //@{ + /*! + \brief Sets the output source to be connected to a camera signal channel - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerCameraOutSelect; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Number of trigger events sent to the camera - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerEventCount; + + //@} + + + //! \name Categories: External + //@{ + /*! + \brief Input debounce time for trigger input signals (in microseconds) - Applies to: CoaXPress + + Input debounce time for trigger input signals (in microseconds). This parameter allows you to filter out invalid signals by specifying a minimum signal length. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerInDebounce; + + //@} + + + //! \name Categories: External + //@{ + /*! + \brief Factor by which the trigger input signal is downscaled - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerInDownscale; + + //@} + + + //! \name Categories: External + //@{ + /*! + \brief Phase for selecting the desired pulse in the sequence - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerInDownscalePhase; + + //@} + + + //! \name Categories: External + //@{ + /*! + \brief Sets the polarity of the trigger input signal - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerInPolarity; + + //@} + + + //! \name Categories: External + //@{ + /*! + \brief Sets the trigger input source - Applies to: CoaXPress + + Sets the trigger input source for external trigger mode. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerInSource; + + //@} + + + //! \name Categories: Sequencer + //@{ + /*! + \brief Upscales, i e , duplicates, the number of trigger pulses generated externally or via software with the period specified by the Trigger Output Frequency parameter - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerMultiplyPulses; + + //@} + + + //! \name Categories: DigitalOutput + //@{ + /*! + \brief Sets the output source of Front GPO 0 - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerOutSelectFrontGPO0; + + //@} + + + //! \name Categories: DigitalOutput + //@{ + /*! + \brief Sets the output source of front GPO 1 - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerOutSelectFrontGPO1; + + //@} + + + //! \name Categories: Trigger + //@{ + /*! + \brief Maximum trigger output frequency - Applies to: CoaXPress + + Maximum trigger output frequency. If the internal generator is used, it will use the frequency specified there. If an external source is used, this value determines the maximum allowed value. External trigger signals exceeding this value will be discarded. For more information, see the applet documentation. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerOutputFrequency; + + //@} + + + //! \name Categories: PulseFormGenerator0 + //@{ + /*! + \brief Delay between the input and the output of the pulse form generator - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator0Delay; + + //@} + + + //! \name Categories: PulseFormGenerator0 + //@{ + /*! + \brief Downscale factor at the pulse form generator input - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator0Downscale; + + //@} + + + //! \name Categories: PulseFormGenerator0 + //@{ + /*! + \brief Phase for selecting the desired pulse in the sequence - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator0DownscalePhase; + + //@} + + + //! \name Categories: PulseFormGenerator0 + //@{ + /*! + \brief Width of the output signal - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator0Width; + + //@} + + + //! \name Categories: PulseFormGenerator1 + //@{ + /*! + \brief Delay between the input and the output of the pulse form generator - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator1Delay; + + //@} + + + //! \name Categories: PulseFormGenerator1 + //@{ + /*! + \brief Downscale factor at the pulse form generator input - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator1Downscale; + + //@} + + + //! \name Categories: PulseFormGenerator1 + //@{ + /*! + \brief Phase for selecting the desired pulse in the sequence - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator1DownscalePhase; + + //@} + + + //! \name Categories: PulseFormGenerator1 + //@{ + /*! + \brief Width of the output signal - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator1Width; + + //@} + + + //! \name Categories: PulseFormGenerator2 + //@{ + /*! + \brief Delay between the input and the output of the pulse form generator - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator2Delay; + + //@} + + + //! \name Categories: PulseFormGenerator2 + //@{ + /*! + \brief Downscale factor at the pulse form generator input - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator2Downscale; + + //@} + + + //! \name Categories: PulseFormGenerator2 + //@{ + /*! + \brief Phase for selecting the desired pulse in the sequence - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator2DownscalePhase; + + //@} + + + //! \name Categories: PulseFormGenerator2 + //@{ + /*! + \brief Width of the output signal - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator2Width; + + //@} + + + //! \name Categories: PulseFormGenerator3 + //@{ + /*! + \brief Delay between the input and the output of the pulse form generator - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator3Delay; + + //@} + + + //! \name Categories: PulseFormGenerator3 + //@{ + /*! + \brief Downscale factor at the pulse form generator input - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator3Downscale; + + //@} + + + //! \name Categories: PulseFormGenerator3 + //@{ + /*! + \brief Phase for selecting the desired pulse in the sequence - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerPulseFormGenerator3DownscalePhase; + + //@} + + + //! \name Categories: PulseFormGenerator3 + //@{ + /*! + \brief Width of the output signal - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IFloatEx& TriggerPulseFormGenerator3Width; + + //@} + + + //! \name Categories: Queue + //@{ + /*! + \brief Fill level of the trigger queue - Applies to: CoaXPress + + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerQueueFillLevel; + + //@} + + + //! \name Categories: Queue + //@{ + /*! + \brief Enables/disable the trigger queue mode - Applies to: CoaXPress + + Enables/disable the trigger queue mode. The maximum output frequenc is specified by the Trigger Output Frequency parameter. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerQueueMode; + + //@} + + + //! \name Categories: Trigger + //@{ + /*! + \brief Sets the state of the trigger system - Applies to: CoaXPress + + Sets the state of the trigger system. The state of the trigger system is related to the trigger mode. This parameter enables or disables the trigger processing. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IEnumParameterT& TriggerState; + + //@} + + + //! \name Categories: CoaXPress + //@{ + /*! + \brief Indicates a trigger frequency violation - Applies to: CoaXPress + + Indicates a distance of two trigger edges violating the minimum edge frequency. + + Visibility: Expert + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& TriggerWaveViolation; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Write access timeout in milliseconds - Applies to: GigE + + + Visibility: Beginner + + The Basler Product Documentation may provide more information. + */ + Pylon::IIntegerEx& WriteTimeout; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUniversalTLParams_Params_v6_2_0(CUniversalTLParams_Params_v6_2_0&); + + //! not implemented assignment operator + CUniversalTLParams_Params_v6_2_0& operator=(CUniversalTLParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for pylon device transport layers + + The parameter class is used by the \c Pylon::CBaslerUniversalInstantCamera class. + The \ref sample_ParametrizeCamera_NativeParameterAccess code sample shows how to access camera parameters via the \c Pylon::CBaslerUniversalInstantCamera class. + */ + class CUniversalTLParams_Params : public CUniversalTLParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUniversalTLParams_Params( void ) + { + } + + //! Destructor + ~CUniversalTLParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CUniversalTLParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_UniversalTLParams + +#endif // BASLER_PYLON_UNIVERSALTLPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_ImageFormatConverterParams.h b/Cigarette/Pylon6.2/include/pylon/_ImageFormatConverterParams.h new file mode 100644 index 0000000..5f859e9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_ImageFormatConverterParams.h @@ -0,0 +1,264 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for Image Format Converter + +The parameter class is used by the \c Pylon::CImageFormatConverter class. +The \c Pylon::CImageFormatConverter creates new images by converting a source image to a different format. +Once the format converter is configured it can convert almost all image formats supported by Basler camera devices. +The \ref sample_Utility_ImageFormatConverter code sample shows the use of the Image Format Converter class. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_IMAGEFORMATCONVERTERPARAMS_H +#define BASLER_PYLON_IMAGEFORMATCONVERTERPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_ImageFormatConverterParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for InconvertibleEdgeHandling + enum InconvertibleEdgeHandlingEnums + { + InconvertibleEdgeHandling_Clip, //!< Rows and columns that can't be converted are removed from the output image - Applies to: ImageFormatConverter + InconvertibleEdgeHandling_Extend, //!< Rows and columns that can't be converted are filled by extrapolating image data from neighboring rows and columns - Applies to: ImageFormatConverter + InconvertibleEdgeHandling_SetZero //!< Rows and columns that can't be converted are set to zero - Applies to: ImageFormatConverter + }; + + //! Valid values for MonoConversionMethod + enum MonoConversionMethodEnums + { + MonoConversionMethod_Gamma, //!< When converting images, Gamma conversion is used - Applies to: ImageFormatConverter + MonoConversionMethod_Truncate //!< When converting images, image data is shifted - Applies to: ImageFormatConverter + }; + + //! Valid values for OutputBitAlignment + enum OutputBitAlignmentEnums + { + OutputBitAlignment_LsbAligned, //!< Image data is aligned with the least significant bit - Applies to: ImageFormatConverter + OutputBitAlignment_MsbAligned //!< The data is aligned at the most significant bit - Applies to: ImageFormatConverter + }; + + //! Valid values for OutputOrientation + enum OutputOrientationEnums + { + OutputOrientation_BottomUp, //!< The last row of the image is located at the start of the image buffer - Applies to: ImageFormatConverter + OutputOrientation_TopDown, //!< The first row of the image is located at the start of the image buffer - Applies to: ImageFormatConverter + OutputOrientation_Unchanged //!< The orientation of the image remains the same - Applies to: ImageFormatConverter + }; + + + + + //************************************************************************************************** + // Parameter class CImageFormatConverterParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for Image Format Converter + + The parameter class is used by the \c Pylon::CImageFormatConverter class. + The \c Pylon::CImageFormatConverter creates new images by converting a source image to a different format. + Once the format converter is configured it can convert almost all image formats supported by Basler camera devices. + The \ref sample_Utility_ImageFormatConverter code sample shows the use of the Image Format Converter class. + */ + class PYLONBASE_API CImageFormatConverterParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CImageFormatConverterParams_Params_v6_2_0( void ); + + //! Destructor + ~CImageFormatConverterParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CImageFormatConverterParams_Params_v6_2_0_Data; + CImageFormatConverterParams_Params_v6_2_0_Data* m_pCImageFormatConverterParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: MonoConversion + //@{ + /*! + \brief Additional shifting value used for converting monochrome images - Applies to: ImageFormatConverter + + Additional shifting value used for converting monochrome images. Only effective if the Mono Conversion Method parameter is set to Truncate. If the parameter value isn't zero, the image data is converted using a lookup table. Shifted values exceeding the maximum output value boundary are set to the maximum allowed value. Negative values are treated as right-shifted values. + + Visibility: Beginner + + */ + Pylon::IIntegerEx& AdditionalLeftShift; + + //@} + + + //! \name Categories: MonoConversion + //@{ + /*! + \brief Gamma value for converting monochrome images - Applies to: ImageFormatConverter + + Gamma value for converting monochrome images. The image data is converted using a lookup table. + + Visibility: Beginner + + */ + Pylon::IFloatEx& Gamma; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sets how to handle rows and columns that can't be converted - Applies to: ImageFormatConverter + + + Visibility: Beginner + + */ + Pylon::IEnumParameterT& InconvertibleEdgeHandling; + + //@} + + + //! \name Categories: MonoConversion + //@{ + /*! + \brief Sets the conversion method for monochrome images - Applies to: ImageFormatConverter + + + Visibility: Beginner + + */ + Pylon::IEnumParameterT& MonoConversionMethod; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sets the alignment of the bits in the target pixel type - Applies to: ImageFormatConverter + + Sets the alignment of the bits in the target pixel type if the target bit depth is greater than the source bit depth, e.g., if you are converting from a 10-bit to a 16-bit format. + + Visibility: Beginner + + */ + Pylon::IEnumParameterT& OutputBitAlignment; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Sets the vertical orientation of the output image in the buffer - Applies to: ImageFormatConverter + + + Visibility: Beginner + + */ + Pylon::IEnumParameterT& OutputOrientation; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Number of additional data bytes at the end of each line - Applies to: ImageFormatConverter + + Number of additional data bytes at the end of each line. These bytes are set to zero during the conversion. + + Visibility: Beginner + + */ + Pylon::IIntegerEx& OutputPaddingX; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CImageFormatConverterParams_Params_v6_2_0(CImageFormatConverterParams_Params_v6_2_0&); + + //! not implemented assignment operator + CImageFormatConverterParams_Params_v6_2_0& operator=(CImageFormatConverterParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for Image Format Converter + + The parameter class is used by the \c Pylon::CImageFormatConverter class. + The \c Pylon::CImageFormatConverter creates new images by converting a source image to a different format. + Once the format converter is configured it can convert almost all image formats supported by Basler camera devices. + The \ref sample_Utility_ImageFormatConverter code sample shows the use of the Image Format Converter class. + */ + class CImageFormatConverterParams_Params : public CImageFormatConverterParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CImageFormatConverterParams_Params( void ) + { + } + + //! Destructor + ~CImageFormatConverterParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CImageFormatConverterParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_ImageFormatConverterParams + +#endif // BASLER_PYLON_IMAGEFORMATCONVERTERPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_InstantCameraParams.h b/Cigarette/Pylon6.2/include/pylon/_InstantCameraParams.h new file mode 100644 index 0000000..c9d6a7b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_InstantCameraParams.h @@ -0,0 +1,420 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for Instant Camera + +The parameter class is used by the \c Pylon::CInstantCamera class. +The code sample \ref sample_Grab shows the usage by setting the MaxNumBuffer parameter. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_INSTANTCAMERAPARAMS_H +#define BASLER_PYLON_INSTANTCAMERAPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_InstantCameraParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + + + //************************************************************************************************** + // Parameter class CInstantCameraParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for Instant Camera + + The parameter class is used by the \c Pylon::CInstantCamera class. + The code sample \ref sample_Grab shows the usage by setting the MaxNumBuffer parameter. + */ + class PYLONBASE_API CInstantCameraParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CInstantCameraParams_Params_v6_2_0( void ); + + //! Destructor + ~CInstantCameraParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CInstantCameraParams_Params_v6_2_0_Data; + CInstantCameraParams_Params_v6_2_0_Data* m_pCInstantCameraParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: Root + //@{ + /*! + \brief If set, this will automatically execute AcquisitionStart when calling StartGrabbing and AcquisitionStop when calling StopGrabbing This option is enabled by default - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& AcquisitionStartStopExecutionEnable; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Enables/disables the use of a chunk node map for each grab result Grab result chunk node maps can be disabled to save resources - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& ChunkNodeMapsEnable; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief If set, all buffers will be cleared (set to 0) before grabbing an image Note that this requires additional processing time per frame - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& ClearBufferModeEnable; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief Enables/disables the grabbing of camera events while images are grabbed Is writable when the camera object is closed - Applies to: InstantCamera + + + Visibility: Expert + + */ + Pylon::IBooleanEx& GrabCameraEvents; + + //@} + + + //! \name Categories: GrabLoopThread + //@{ + /*! + \brief The grab loop thread priority - Applies to: InstantCamera + + This value sets the absolute thread priority for the grab loop thread. + + Visibility: Guru + + */ + Pylon::IIntegerEx& GrabLoopThreadPriority; + + //@} + + + //! \name Categories: GrabLoopThread + //@{ + /*! + \brief If enabled, the user can set a custom priority for the grab loop thread Otherwise, the priority of the newly created thread is not changed - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& GrabLoopThreadPriorityOverride; + + //@} + + + //! \name Categories: GrabLoopThread + //@{ + /*! + \brief A custom timeout for the grab loop thread's call to RetrieveResult RetrieveResult is configured to throw an exception on timeout, which will stop the grab session - Applies to: InstantCamera + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& GrabLoopThreadTimeout; + + //@} + + + //! \name Categories: GrabLoopThread + //@{ + /*! + \brief If enabled, the user can set a custom timeout for the grab loop thread's call to RetrieveResult RetrieveResult is configured to throw an exception on timeout, which will stop the grab session - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& GrabLoopThreadUseTimeout; + + //@} + + + //! \name Categories: InternalGrabEngineThread + //@{ + /*! + \brief The internal grab engine thread priority - Applies to: InstantCamera + + This value sets the absolute thread priority for the internal grab engine thread operating the stream grabber. + + Visibility: Guru + + */ + Pylon::IIntegerEx& InternalGrabEngineThreadPriority; + + //@} + + + //! \name Categories: InternalGrabEngineThread + //@{ + /*! + \brief If enabled, the user can set a custom priority for the internal grab engine thread operating the stream grabber Otherwise the priority defaults to 25 - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& InternalGrabEngineThreadPriorityOverride; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The maximum number of buffers that are allocated and used for grabbing - Applies to: InstantCamera + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& MaxNumBuffer; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The maximum number of grab results available at any time during a grab session This value can be limited to save resources Furthermore, it can be used to check that the grab results are returned correctly - Applies to: InstantCamera + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& MaxNumGrabResults; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The maximum number of buffers that are queued in the stream grabber input queue - Applies to: InstantCamera + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& MaxNumQueuedBuffer; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The migration mode is set up according to this setting at defined points e g , when the camera is opened - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& MigrationModeActive; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The camera object is set to monitor mode when enabled, e g when using the GigE multicast feature Is writable when the camera object is closed - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IBooleanEx& MonitorModeActive; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The number of empty buffers that are not used for grabbing yet - Applies to: InstantCamera + + + Visibility: Expert + + */ + Pylon::IIntegerEx& NumEmptyBuffers; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The number of buffers queued at Low Level API stream grabber - Applies to: InstantCamera + + + + This is the number of buffers that are queued for grabbing in the stream grabber. + The number is influenced by the number of available free buffers and the + maximum number of buffers that can be queued. + See also the MaxNumBuffer and MaxNumQueuedBuffer parameters. + + This parameter can be used to check whether the number of buffers ready for grabbing + is stable, which means that the image processing is fast enough to keep up with the + rate of incoming images when using the GrabStrategy_OneByOne grab strategy. + + + + Visibility: Expert + + */ + Pylon::IIntegerEx& NumQueuedBuffers; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The number of grab result buffers in the output queue that are ready for retrieval - Applies to: InstantCamera + + + Visibility: Expert + + */ + Pylon::IIntegerEx& NumReadyBuffers; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief The size of the grab result buffer output queue - Applies to: InstantCamera + + + Visibility: Expert + + */ + Pylon::IIntegerEx& OutputQueueSize; + + //@} + + + //! \name Categories: Root + //@{ + /*! + \brief If larger than 0, a static chunk node map pool is used instead of dynamic chunk node map creation - Applies to: InstantCamera + + + Visibility: Guru + + */ + Pylon::IIntegerEx& StaticChunkNodeMapPoolSize; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CInstantCameraParams_Params_v6_2_0(CInstantCameraParams_Params_v6_2_0&); + + //! not implemented assignment operator + CInstantCameraParams_Params_v6_2_0& operator=(CInstantCameraParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for Instant Camera + + The parameter class is used by the \c Pylon::CInstantCamera class. + The code sample \ref sample_Grab shows the usage by setting the MaxNumBuffer parameter. + */ + class CInstantCameraParams_Params : public CInstantCameraParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CInstantCameraParams_Params( void ) + { + } + + //! Destructor + ~CInstantCameraParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CInstantCameraParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_InstantCameraParams + +#endif // BASLER_PYLON_INSTANTCAMERAPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/_VideoWriterParams.h b/Cigarette/Pylon6.2/include/pylon/_VideoWriterParams.h new file mode 100644 index 0000000..54b6a58 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/_VideoWriterParams.h @@ -0,0 +1,261 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2018-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- + +/*! +\file +\brief A parameter class containing all parameters as members that are available for Video Writer + +The parameter class is used by the \c Pylon::CVideoWriter class. +The \c Pylon::CVideoWriter can be used to create video files in the MP4 format. The \ref sample_Utility_GrabVideo code sample shows the use of the Video Writer class. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + +#ifndef BASLER_PYLON_VIDEOWRITERPARAMS_H +#define BASLER_PYLON_VIDEOWRITERPARAMS_H + +#pragma once + +// common parameter types +#include +#include + +namespace Basler_VideoWriterParams +{ + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + //! Valid values for CompressionMode + enum CompressionModeEnums + { + CompressionMode_Bitrate, //!< The resulting stream has a constant bit rate + CompressionMode_Quality //!< The resulting stream has a constant quality + }; + + + + + //************************************************************************************************** + // Parameter class CVideoWriterParams_Params_v6_2_0 + //************************************************************************************************** + + + /*! + \brief A parameter class containing all parameters as members that are available for Video Writer + + The parameter class is used by the \c Pylon::CVideoWriter class. + The \c Pylon::CVideoWriter can be used to create video files in the MP4 format. The \ref sample_Utility_GrabVideo code sample shows the use of the Video Writer class. + */ + class PYLONBASE_API CVideoWriterParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CVideoWriterParams_Params_v6_2_0( void ); + + //! Destructor + ~CVideoWriterParams_Params_v6_2_0( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! \endcond + + private: + class CVideoWriterParams_Params_v6_2_0_Data; + CVideoWriterParams_Params_v6_2_0_Data* m_pCVideoWriterParams_Params_v6_2_0_Data; + + + //---------------------------------------------------------------------------------------------------------------- + // References to features + //---------------------------------------------------------------------------------------------------------------- + public: + //! \name Categories: RecordingOptions + //@{ + /*! + \brief Bit rate of the resulting compressed stream + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& Bitrate; + + //@} + + + //! \name Categories: Statistics + //@{ + /*! + \brief Bytes written to file since starting the recording + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& BytesWritten; + + //@} + + + //! \name Categories: RecordingOptions + //@{ + /*! + \brief Sets the compression mode + + Sets the compression mode. You can choose whether to keep the bit rate or the quality of the resulting video stream constant. + + Visibility: Beginner + + */ + Pylon::IEnumParameterT& CompressionMode; + + //@} + + + //! \name Categories: Statistics + //@{ + /*! + \brief Number of frames written since starting the recording + + + Visibility: Beginner + + */ + Pylon::IIntegerEx& FrameCount; + + //@} + + + //! \name Categories: ImageParameters + //@{ + /*! + \brief Height of the image (in pixels) + + + Visibility: Invisible + + */ + Pylon::IIntegerEx& Height; + + //@} + + + //! \name Categories: RecordingOptions + //@{ + /*! + \brief Frame rate (in Hertz) of the video to be recorded + + + Visibility: Beginner + + */ + Pylon::IFloatEx& PlaybackFrameRate; + + //@} + + + //! \name Categories: RecordingOptions + //@{ + /*! + \brief Quality of the resulting compressed stream + + Quality of the resulting compressed stream. The quality has a direct influence on the resulting bit rate. The optimal bit rate is calculated based on the input values height, width, and playback frame rate (WIDTH * HEIGHT * PLAYBACKFRAMERATE * 0.25). This is then normalized to the quality value range 1-100, where 100 corresponds to the optimum bit rate and 1 to the lowest bit rate. + + Visibility: Beginner + + */ + Pylon::IFloatEx& Quality; + + //@} + + + //! \name Categories: RecordingOptions + //@{ + /*! + \brief Number of threads used for recording the video + + + Visibility: Expert + + */ + Pylon::IIntegerEx& ThreadCount; + + //@} + + + //! \name Categories: ImageParameters + //@{ + /*! + \brief Width of the image (in pixels) + + + Visibility: Invisible + + */ + Pylon::IIntegerEx& Width; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CVideoWriterParams_Params_v6_2_0(CVideoWriterParams_Params_v6_2_0&); + + //! not implemented assignment operator + CVideoWriterParams_Params_v6_2_0& operator=(CVideoWriterParams_Params_v6_2_0&); + + //! \endcond + }; + + + /*! + \brief A parameter class containing all parameters as members that are available for Video Writer + + The parameter class is used by the \c Pylon::CVideoWriter class. + The \c Pylon::CVideoWriter can be used to create video files in the MP4 format. The \ref sample_Utility_GrabVideo code sample shows the use of the Video Writer class. + */ + class CVideoWriterParams_Params : public CVideoWriterParams_Params_v6_2_0 + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CVideoWriterParams_Params( void ) + { + } + + //! Destructor + ~CVideoWriterParams_Params( void ) + { + } + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* pNodeMap ) + { + CVideoWriterParams_Params_v6_2_0::_Initialize( pNodeMap ); + } + //! \endcond + }; +} // namespace Basler_VideoWriterParams + +#endif // BASLER_PYLON_VIDEOWRITERPARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkCamera.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkCamera.h new file mode 100644 index 0000000..999a8ae --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkCamera.h @@ -0,0 +1,52 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Pylon CameraLink camera interface for Basler CameraLink cameras +*/ + +#ifndef BASLER_CAMERALINK_CAMERA_H +#define BASLER_CAMERALINK_CAMERA_H + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include "PylonCameraLinkCamera.h" + +#include "_BaslerCameraLinkCameraParams.h" +namespace Basler_CameraLinkParams = Basler_CLCameraParams; // Pylon 2.0 compatibility + + +namespace Pylon +{ + //************************************************************************************************** + //! Low Level API: The camera class for Basler CameraLink camera devices + /** + Class for Basler CameraLink cameras providing access to camera parameters. + \see \ref configuringcameras + + \ingroup Pylon_LowLevelApi + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + //************************************************************************************************** + PYLON_DEFINE_CAMERA( CBaslerCameraLinkCamera, Pylon::CPylonCameraLinkCameraT ); + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // BASLER_CAMERALINK_CAMERA_H diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkCameraEventHandler.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkCameraEventHandler.h new file mode 100644 index 0000000..3c207d1 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkCameraEventHandler.h @@ -0,0 +1,161 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the camera event handler base class. +*/ + +#ifndef INCLUDED_BASLERCAMERALINKCAMERAEVENTHANDLER_H_3102315 +#define INCLUDED_BASLERCAMERALINKCAMERAEVENTHANDLER_H_3102315 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#if _MSC_VER +# pragma warning( push) +# pragma warning( disable : 4100) //warning C4100: 'identifier' : unreferenced formal parameter +#endif + +#include + + +namespace Pylon +{ + class CBaslerCameraLinkInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + + /** + \class CBaslerCameraLinkCameraEventHandler + \brief The camera event handler base class. + */ + class CBaslerCameraLinkCameraEventHandler + { + public: + + /** + \brief This method is called when a camera event has been received. + + Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the + processing of images. + + \param[in] camera The source of the call. + \param[in] userProvidedId The ID passed when registering for the event. It can be used to distinguish between different events. + \param[in] pNode The node identified by node name when registering. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + \threading + This method is called outside the lock of the camera object, outside the lock of the node map, and inside the lock of the camera event handler registry. + */ + virtual void OnCameraEvent( CBaslerCameraLinkInstantCamera& camera, intptr_t userProvidedId, GENAPI_NAMESPACE::INode* pNode ) + { + } + + /** + \brief This method is called when the camera event handler has been registered. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerCameraLinkCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerRegistered( CBaslerCameraLinkInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + } + + /** + \brief This method is called when the camera event handler has been deregistered. + + The camera event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerCameraLinkCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerDeregistered( CBaslerCameraLinkInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + } + + /*! + \brief Destroys the camera event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyCameraEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerCameraLinkCameraEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerCameraLinkCameraEventHandler( const CBaslerCameraLinkCameraEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerCameraLinkCameraEventHandler& operator=( const CBaslerCameraLinkCameraEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerCameraLinkCameraEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#if _MSC_VER +# pragma warning( pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERCAMERALINKCAMERAEVENTHANDLER_H_3102315 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkConfigurationEventHandler.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkConfigurationEventHandler.h new file mode 100644 index 0000000..a447505 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkConfigurationEventHandler.h @@ -0,0 +1,399 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the configuration event handler base class. +*/ + +#ifndef INCLUDED_BASLERCAMERALINKCONFIGURATIONEVENTHANDLER_H_01627755 +#define INCLUDED_BASLERCAMERALINKCONFIGURATIONEVENTHANDLER_H_01627755 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#if _MSC_VER +# pragma warning( push) +# pragma warning( disable : 4100) //warning C4100: 'identifier' : unreferenced formal parameter +#endif + +namespace Pylon +{ + class CBaslerCameraLinkInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + + /** + \class CBaslerCameraLinkConfigurationEventHandler + \brief The configuration event handler base class. + */ + class CBaslerCameraLinkConfigurationEventHandler + { + public: + /** + \brief This method is called before a %Pylon Device (Pylon::IPylonDevice) is attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttach( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after a %Pylon Device (Pylon::IPylonDevice) has been attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttached( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is detached from the Instant Camera object. + + The camera's Detach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetach( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been detached from the Instant Camera object. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetached( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is destroyed. + + Camera DestroyDevice must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroy( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroyed( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpen( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpened( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is closed. + + Camera Close must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClose( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been closed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClosed( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called before a grab session is started. + + Camera StartGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStart( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after a grab session has been started. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStarted( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called before a grab session is stopped. + + Camera StopGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStop( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called after a grab session has been stopped. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStopped( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called when an exception has been triggered during grabbing. + + An exception has been triggered by a grab thread. The grab will be stopped after this event call. + + \param[in] camera The source of the call. + \param[in] errorMessage The message of the exception that signaled an error during grabbing. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabError( CBaslerCameraLinkInstantCamera& camera, const char* errorMessage ) + { + } + + /** + \brief This method is called when a camera device removal from the PC has been detected. + + The %Pylon Device attached to the Instant Camera is not operable after this event. + After it is made sure that no access to the %Pylon Device or any of its node maps is made anymore + the %Pylon Device should be destroyed using InstantCamera::DeviceDestroy(). + The access to the %Pylon Device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object from an additional thread. + */ + virtual void OnCameraDeviceRemoved( CBaslerCameraLinkInstantCamera& camera ) + { + } + + + /** + \brief This method is called when the configuration event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationRegistered( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called when the configuration event handler has been deregistered. + + The configuration event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationDeregistered( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /*! + \brief Destroys the configuration event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyConfiguration() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerCameraLinkConfigurationEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerCameraLinkConfigurationEventHandler( const CBaslerCameraLinkConfigurationEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerCameraLinkConfigurationEventHandler& operator=( const CBaslerCameraLinkConfigurationEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerCameraLinkConfigurationEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#if _MSC_VER +# pragma warning( pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERCAMERALINKCONFIGURATIONEVENTHANDLER_H_01627755 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkDeviceInfo.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkDeviceInfo.h new file mode 100644 index 0000000..c1d15b6 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkDeviceInfo.h @@ -0,0 +1,52 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of CPylonPylonCLSerDeviceInfo +*/ + + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#ifndef PYLONCLSERDEVICEINFO_H__ +#define PYLONCLSERDEVICEINFO_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /*! + \brief PylonCLSer specific Device Info object. + \ingroup Pylon_TransportLayer + */ + class PYLONBASE_API CBaslerCameraLinkDeviceInfo : public Pylon::CDeviceInfo + { + public: + CBaslerCameraLinkDeviceInfo(); + CBaslerCameraLinkDeviceInfo( const CDeviceInfo& di ); + virtual ~CBaslerCameraLinkDeviceInfo(); + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // PYLONCLSERDEVICEINFO_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkGrabResultData.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkGrabResultData.h new file mode 100644 index 0000000..47fd4b6 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkGrabResultData.h @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Camera Link specific grab result data class. +*/ +#ifndef INCLUDED_BASLERCAMERALINKGRABRESULTDATA_H_7474481 +#define INCLUDED_BASLERCAMERALINKGRABRESULTDATA_H_7474481 + +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + // This dummy implementation is used by the Device Specific Instant Camera for Camera Link + // because the Camera Link Transport Layer does not support some features. + class CCameraLinkDummyChunkData_Params + { + public: + void _Initialize( GENAPI_NAMESPACE::INodeMap* ) + { + } + }; + + /// The Camera Link specific grab result data class. + class CBaslerCameraLinkGrabResultData : public CGrabResultData, public CCameraLinkDummyChunkData_Params + { + protected: + // Internal use only. The grab result data class should only be created by the Instant Camera class. + friend class CBaslerCameraLinkInstantCamera; + CBaslerCameraLinkGrabResultData() + { + } + + // Internal use only. + virtual void Destroy() + { + delete this; + } + + // Internal use only. + virtual void Initialize() + { + _Initialize( &GetChunkDataNodeMap() ); + } + }; + + /** + * @} + */ +} + +#endif /* INCLUDED_BASLERCAMERALINKGRABRESULTDATA_H_7474481 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkGrabResultPtr.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkGrabResultPtr.h new file mode 100644 index 0000000..762000c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkGrabResultPtr.h @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains the Camera Link specific grab result ptr class. +*/ + +#ifndef INCLUDED_BASLERCAMERALINKGRABRESULTPTR_H_03519839 +#define INCLUDED_BASLERCAMERALINKGRABRESULTPTR_H_03519839 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + + /// The Camera Link specific grab result smart pointer. + PYLON_DEFINE_DEVICE_SPECIFIC_GRAB_RESULT_PTR( CBaslerCameraLinkGrabResultPtr, CBaslerCameraLinkGrabResultData ) + + /** + * @} + */ +} + +#endif /* INCLUDED_BASLERCAMERALINKGRABRESULTPTR_H_03519839 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkImageEventHandler.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkImageEventHandler.h new file mode 100644 index 0000000..b00d1c7 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkImageEventHandler.h @@ -0,0 +1,174 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the image event handler base class. +*/ + +#ifndef INCLUDED_BASLERCAMERALINKIMAGEEVENTHANDLER_H_8866388 +#define INCLUDED_BASLERCAMERALINKIMAGEEVENTHANDLER_H_8866388 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +#if _MSC_VER +# pragma warning( push) +# pragma warning( disable : 4100) //warning C4100: 'identifier' : unreferenced formal parameter +#endif + +namespace Pylon +{ + class CBaslerCameraLinkInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + + /** + \class CBaslerCameraLinkImageEventHandler + \brief The image event handler base class. + */ + class CBaslerCameraLinkImageEventHandler + { + public: + + /** + \brief This method is called when images have been skipped using the GrabStrategy_LatestImageOnly strategy or the GrabStrategy_LatestImages strategy. + + \param[in] camera The source of the call. + \param[in] countOfSkippedImages The number of images skipped. This \c countOfSkippedImages does not include the number of images lost in the case of a buffer under run in the driver. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImagesSkipped( CBaslerCameraLinkInstantCamera& camera, size_t countOfSkippedImages ) + { + } + + /** + \brief This method is called when an image has been grabbed. + + The grab result smart pointer passed does always reference a grab result data object. + The status of the grab needs to be checked before accessing the grab result data. + See CGrabResultData::GrabSucceeded(), CGrabResultData::GetErrorCode() and + CGrabResultData::GetErrorDescription() for more information. + + \param[in] camera The source of the call. + \param[in] grabResult The grab result data. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImageGrabbed( CBaslerCameraLinkInstantCamera& camera, const CBaslerCameraLinkGrabResultPtr& grabResult ) + { + } + + /** + \brief This method is called when the image event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerRegistered( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /** + \brief This method is called when the image event handler has been deregistered. + + The image event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerDeregistered( CBaslerCameraLinkInstantCamera& camera ) + { + } + + /*! + \brief Destroys the image event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyImageEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerCameraLinkImageEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerCameraLinkImageEventHandler( const CBaslerCameraLinkImageEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerCameraLinkImageEventHandler& operator=( const CBaslerCameraLinkImageEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerCameraLinkImageEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#if _MSC_VER +# pragma warning( pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERCAMERALINKIMAGEEVENTHANDLER_H_8866388 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkInstantCamera.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkInstantCamera.h new file mode 100644 index 0000000..79ad95a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkInstantCamera.h @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Camera Link Specific Instant Camera class for Basler Camera Link devices. +*/ + +#ifndef INCLUDED_BASLERCAMERALINKINSTANTCAMERA_H_6872827 +#define INCLUDED_BASLERCAMERALINKINSTANTCAMERA_H_6872827 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + + // This dummy implementation is used by the Device Specific Instant Camera for Camera Link + // because the Camera Link Transport Layer does not support some features. + class CCameraLinkDummyParams_Params + { + public: + void _Initialize( GENAPI_NAMESPACE::INodeMap* ) + { + } + }; + + class CBaslerCameraLinkInstantCamera; + + /// Lists all the types used by the Device Specific Instant Camera class for Camera Link. + struct CBaslerCameraLinkInstantCameraTraits + { + /// The type of the final camera class. + typedef CBaslerCameraLinkInstantCamera InstantCamera_t; + /// \copybrief Basler_CLCameraParams::CCLCameraParams_Params + typedef Basler_CLCameraParams::CCLCameraParams_Params CameraParams_t; + /// \copybrief Pylon::IPylonDevice + typedef IPylonDevice IPylonDevice_t; + /// \copybrief Pylon::CBaslerCameraLinkDeviceInfo + typedef Pylon::CBaslerCameraLinkDeviceInfo DeviceInfo_t; + /// Not supported by Camera Link transport layer. + typedef CNodeMapProxyT TlParams_t; + /// Not supported by Camera Link transport layer. + typedef CNodeMapProxyT StreamGrabberParams_t; + /// Not supported by Camera Link transport layer. + typedef CNodeMapProxyT EventGrabberParams_t; + /// The Camera Link specific configuration event handler class. + typedef CBaslerCameraLinkConfigurationEventHandler ConfigurationEventHandler_t; + /// The Camera Link specific image event handler class. + typedef CBaslerCameraLinkImageEventHandler ImageEventHandler_t; + /// The Camera Link specific camera event handler class. + typedef CBaslerCameraLinkCameraEventHandler CameraEventHandler_t; + /// The Camera Link specific grab result data. + typedef CBaslerCameraLinkGrabResultData GrabResultData_t; + /// The Camera Link specific grab result smart pointer. + typedef CBaslerCameraLinkGrabResultPtr GrabResultPtr_t; + + //! Can be used to check whether the DeviceClass() can be used for enumeration. + static bool HasSpecificDeviceClass() + { + return true; + } + //! The name of this device class. Use this one for enumeration. + static String_t DeviceClass() + { + return BaslerCameraLinkDeviceClass; + } + }; + + + /*! + \class CBaslerCameraLinkInstantCamera + \brief Extends the CInstantCamera by Camera Link specific parameter interface classes. + */ + PYLON_DEFINE_INSTANT_CAMERA( CBaslerCameraLinkInstantCamera, CDeviceSpecificInstantCameraT ) + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERCAMERALINKINSTANTCAMERA_H_6872827 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkInstantCameraArray.h b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkInstantCameraArray.h new file mode 100644 index 0000000..1d7ed89 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/BaslerCameraLinkInstantCameraArray.h @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Camera Link specific instant camera array class. +*/ +#ifndef INCLUDED_BASLERCAMERALINKINSTANTCAMERAARRAY_H_5817072 +#define INCLUDED_BASLERCAMERALINKINSTANTCAMERAARRAY_H_5817072 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiCameraLink + * @{ + */ + + /*! + \class CBaslerCameraLinkInstantCameraArray + \brief Camera Link specific instant camera array + + \threading + The CBaslerCameraLinkInstantCameraArray class is not thread-safe. + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCameraArray instead. + */ + PYLON_6_0_DEPRECATED( "Use CBaslerUniversalInstantCameraArray" ) + class CBaslerCameraLinkInstantCameraArray : public CDeviceSpecificInstantCameraArrayT + { + public: + /*! + \copybrief CInstantCameraArray::CInstantCameraArray() + \copydetails CInstantCameraArray::CInstantCameraArray() + */ + CBaslerCameraLinkInstantCameraArray() + { + } + /*! + \copybrief CInstantCameraArray::CInstantCameraArray( size_t) + \copydetails CInstantCameraArray::CInstantCameraArray( size_t) + */ + CBaslerCameraLinkInstantCameraArray( size_t numberOfCameras ) : CDeviceSpecificInstantCameraArrayT( numberOfCameras ) + { + } + + /*! + \copybrief CInstantCameraArray::~CInstantCameraArray() + \copydetails CInstantCameraArray::~CInstantCameraArray() + */ + virtual ~CBaslerCameraLinkInstantCameraArray() + { + } + + }; + + /** + * @} + */ +} + +#endif /* INCLUDED_BASLERCAMERALINKINSTANTCAMERAARRAY_H_5817072 */ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerDefs.h b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerDefs.h new file mode 100644 index 0000000..ffd1229 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerDefs.h @@ -0,0 +1,25 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Defines for IPTrans. + +*/ + +#ifndef PYLONCLSER_DEFS_H_INCLUDED +#define PYLONCLSER_DEFS_H_INCLUDED + +#include + +// PYLONCLSER_API +#ifdef PYLONCLSER_EXPORTS +# define PYLONCLSER_API APIEXPORT +#else +# define PYLONCLSER_API APIIMPORT +#endif + +#endif // PYLONCLSER_DEFS_H_INCLUDED diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerDeviceInfo.h b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerDeviceInfo.h new file mode 100644 index 0000000..6cb6317 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerDeviceInfo.h @@ -0,0 +1,18 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief This header is for backward compatibility. Please use BaslerCameraLinkDeviceInfo.h instead +*/ +#pragma once + +#include "BaslerCameraLinkDeviceInfo.h" + +namespace Pylon +{ + // aliases until classes are renamed properly + typedef CBaslerCameraLinkDeviceInfo CPylonCLSerDeviceInfo; +} diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerIncludes.h b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerIncludes.h new file mode 100644 index 0000000..800adeb --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCLSerIncludes.h @@ -0,0 +1,19 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief Includes used by CLSer camera classes +*/ + +#ifndef PYLON_CLSER_INCLUDED_INCLUDED__ +#define PYLON_CLSER_INCLUDED_INCLUDED__ + +#pragma message ("Warning: Please do not include this file. Use 'PylonCameraLinkIncludes.h' instead. This is for backward compatibility only.") + +#include + +#endif // PYLON_CLSER_INCLUDED_INCLUDED__ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCameraLinkCamera.h b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCameraLinkCamera.h new file mode 100644 index 0000000..660f5b3 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCameraLinkCamera.h @@ -0,0 +1,133 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Generic pylon CameraLink camera interface +*/ + +#ifndef PYLON_CAMERALINK_CAMERA_H +#define PYLON_CAMERALINK_CAMERA_H + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include "../DeviceClass.h" +#include "../NodeMapProxy.h" +#include "../StreamGrabberProxy.h" +#include "../EventGrabberProxy.h" + +#include "../PylonDeviceProxy.h" + + +namespace Pylon +{ + //************************************************************************************************** + //! Low Level API: pylon CameraLink cameras doesn't support TL Params. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + //PYLON_DEFINE_NODEMAP(CPylonCameraLinkTLParams, CNodeMapProxyT<>); + typedef void CPylonCameraLinkTLParams; + + + //************************************************************************************************** + //! Low Level API: pylon CameraLink cameras doesn't support stream grabber related methods and parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + //PYLON_DEFINE_STREAMGRABBER(CPylonCameraLinkStreamGrabber, CStreamGrabberProxyT<>); + typedef void CPylonCameraLinkStreamGrabber; + + + //************************************************************************************************** + //! Low Level API: pylon CameraLink cameras doesn't support event grabber related methods and parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + //PYLON_DEFINE_EVENTGRABBER(CPylonCameraLinkEventGrabber, CEventGrabberProxyT<>); + typedef void CPylonCameraLinkEventGrabber; + + + //************************************************************************************************** + //! Low Level API: The camera class for pylon CameraLink camera devices + /** + This is the base class for pylon CameraLink cameras providing access to camera parameters. + \see \ref configuringcameras + + \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file) + \ingroup Pylon_LowLevelApi + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + //************************************************************************************************** + template + class CPylonCameraLinkCameraT : public CPylonDeviceProxyT + { + public: + typedef void DeviceInfo_t; + typedef Pylon::CPylonCameraLinkTLParams TlParams_t; //!< \copybrief Pylon::CPylonCameraLinkTLParams + typedef Pylon::CPylonCameraLinkStreamGrabber StreamGrabber_t; //!< \copybrief Pylon::CPylonCameraLinkStreamGrabber + typedef Pylon::CPylonCameraLinkEventGrabber EventGrabber_t; //!< \copybrief Pylon::CPylonCameraLinkEventGrabber + + //! The name of this device class, use this for enumeration + static String_t DeviceClass() + { + return BaslerCameraLinkDeviceClass; + } + + public: + //! \name Construction + // \{ + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + */ + CPylonCameraLinkCameraT() + { + }; + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + */ + CPylonCameraLinkCameraT( IPylonDevice* pDevice, bool takeOwnership = true ) + : CPylonDeviceProxyT( pDevice, takeOwnership ) + { + } + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::~CPylonDeviceProxyT() + + \copydetails Pylon::CPylonDeviceProxyT::~CPylonDeviceProxyT() + */ + virtual ~CPylonCameraLinkCameraT() + { + } + + //\} + }; + + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // PYLON_CAMERALINK_CAMERA_H diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCameraLinkIncludes.h b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCameraLinkIncludes.h new file mode 100644 index 0000000..801b2cb --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/PylonCameraLinkIncludes.h @@ -0,0 +1,37 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: JS +//----------------------------------------------------------------------------- +/*! +\file +\brief includes specific for the Camera Link transport layer +*/ + +#ifndef PYLON_CAMERALINK_INCLUDED_INCLUDED__ +#define PYLON_CAMERALINK_INCLUDED_INCLUDED__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include +#include +#include +#include +#include // for backward compatibility +#include + +namespace Pylon +{ + const char* const CLSerTransportLayer( "Camera Link" ); + + // just use forwards to make generated header PylonCLSerIncludes compilable + class CBaslerCameraLinkDeviceInfo; + class CPylonCLSerDevice; + + typedef void CPylonCLSerEventGrabber; +} + +#endif // PYLON_CAMERALINK_INCLUDED_INCLUDED__ diff --git a/Cigarette/Pylon6.2/include/pylon/cameralink/_BaslerCameraLinkCameraParams.h b/Cigarette/Pylon6.2/include/pylon/cameralink/_BaslerCameraLinkCameraParams.h new file mode 100644 index 0000000..70f2e50 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/cameralink/_BaslerCameraLinkCameraParams.h @@ -0,0 +1,7448 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Basler Cameralink camera interface +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_CLCameraParams_PARAMS_H +#define Basler_CLCameraParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_CLCameraParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for SequenceAdvanceMode + enum SequenceAdvanceModeEnums + { + SequenceAdvanceMode_Auto, //!& SequenceAdvanceMode; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects between sequence restart or sequence set advance + + Selects between controls for sequence restart or sequence set advance. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceControlSelector; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects the source for sequence control + + Selects the source for sequence control. Possible values: Disabled - advance via asynchronous advance. Always Active - automatic sequence set advance. The sequence repeat starts with sequence set index number 1. Line N - the source for sequence restart or sequence set advance is line N. CCN - the source for sequence restart or sequence set advance is CCN. + + \b Visibility = Guru + + \b Selected by : SequenceControlSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceControlSource; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects a bit of the sequence set address + + Selects a bit of the sequence set address. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceAddressBitSelector; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects the source for the selected bit of the sequence set address + + Selects the source for setting the selected bit of the sequence set address. + + \b Visibility = Guru + + \b Selected by : SequenceAddressBitSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceAddressBitSource; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Gain Auto is the 'automatic' counterpart of the manual gain feature. + + The gain auto function automatically adjusts the Auto Gain Raw parameter value within set limits, until a target average gray value for the pixel data from Auto Function AOI1 is reached. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GainAuto; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Selects the gain control to configure. Once a gain control has been selected, all changes to the gain settings will be applied to the selected control. + + This enumeration selects the gain control to configure. Once a gain control has been selected, all changes to the gain settings will be applied to the selected control. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GainSelector; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief This is an integer value that sets the selected gain control in device specific units + + Sets the 'raw' value of the selected gain control. The 'raw' value is an integer value that sets the selected gain control in units specific to the camera. + + \b Visibility = Beginner + + + \b Selected by : GainSelector + + */ + GENAPI_NAMESPACE::IInteger& GainRaw; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief This is a float value that sets the selected gain control in dB + + Sets the 'absolute' value of the selected gain control. The 'absolute' value is a float value that sets the selected gain control in dB. + + \b Visibility = Beginner + + + \b Selected by : GainSelector + + */ + GENAPI_NAMESPACE::IFloat& GainAbs; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Selcts a black level control to configure. Once a black level control has been selected, all changes to the black level settings will be applied to the selected control. + + This enumeration selects the black level control to configure. Once a black level control has been selected, all changes to the black level settings will be applied to the selected control. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BlackLevelSelector; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the value of the selected black level control as an integer + + This value sets the selected black level control as an integer. + + \b Visibility = Beginner + + + \b Selected by : BlackLevelSelector + + */ + GENAPI_NAMESPACE::IInteger& BlackLevelRaw; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the value of the selected black level control as a float + + This value sets the selected black level control as a float value. + + \b Visibility = Beginner + + + \b Selected by : BlackLevelSelector + + */ + GENAPI_NAMESPACE::IFloat& BlackLevelAbs; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Enables the gamma correction + + This boolean value enables the gamma correction. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& GammaEnable; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief + + This enumeration selects the type of gamma to apply. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GammaSelector; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief This feature is used to perform gamma correction of pixel intensity. + + This feature is used to perform gamma correction of pixel intensity. This is typically used to compensate for non-linearity of the display system (such as CRT). + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& Gamma; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the value of the selected digital shift control + + This value sets the selected digital shift control + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DigitalShift; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the substrate voltage + + This value sets the substrate voltage + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SubstrateVoltage; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief This feature selects the amount of data bits the sensor produces for one sample. + + This feature selects the amount of data bits the sensor produces for one sample. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorBitDepth; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief This feature represents the number of digitized samples outputted simultaneously by the camera A/D conversion stage. + + This feature represents the number of digitized samples output simultaneously by the camera A/D conversion stage. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorDigitizationTaps; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Sets the format of the pixel data transmitted for acquired images + + This enumeration sets the format of the pixel data transmitted for acquired images. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelFormat; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Sets the color coding of the pixels in the acquired images + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelCoding; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the depth of the pixel values in the image in bits per pixel + + This is a read only feature. This enumeration provides a list of values that indicate the depth of the pixel values in the acquired images in bits per pixel. This value will always be coherent with the pixel format setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelSize; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the alignment of the camera's Bayer filter to the pixels in the acquired images + + This is a read only feature. This enumeration provides a list of values that indicate the alignment of the camera's Bayer filter to the pixels in the acquired images. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelColorFilter; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Enables color improved RGB raw output + + Enables color improvement of RGB data and provides for their output as RGB raw data. Only available for cameras with an RGB Bayer filter. + Note: Make sure to also select a suitable raw pixel data output format. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& ProcessedRawEnable; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the minimum possible pixel value that could be transferred from the camera + + This a read only feature. It indicates the minimum possible pixel value that could be transferred from the camera. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& PixelDynamicRangeMin; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the maximum possible pixel value that could be transferred from the camera + + This a read only feature. It indicates the maximum possible pixel value that could be transferred from the camera. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& PixelDynamicRangeMax; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Specifies the direction of imaging and the separation (consecutive numbers) of related line captures. + + Specifies the direction of imaging and the separation (consecutive numbers) of related line captures. Related line captures will be combined. + + Positive integer: The object will pass the top sensor line first. + + Negative integer: The object will pass the bottom sensor line first. + + In color cameras, the top sensor line is the green line, and the bottom sensor line is the blue line. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SpatialCorrection; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& SpatialCorrectionAmount; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IEnumerationT& SpatialCorrectionStartingLine; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Enables the horizontal flipping of the image. + + This feature is used to flip horizontally the image sent by the device. The AOI is applied after the flipping. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ReverseX; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Enables the vertical flipping of the image. + + This feature is used to flip vertically the image sent by the device. The AOI is applied after the flipping. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ReverseY; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Selects the mode to output the fields. + + Selects the mode to output the fields. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& FieldOutputMode; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Selecting a test image from the list will enable the test image + + This enumeration provides a list of the available test images. Selecting a test image from the list will enable the test image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TestImageSelector; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the width of the camera's sensor in pixels + + This is a read only element. It is an integer that indicates the actual width of the camera's sensor in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SensorWidth; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the height of the camera's sensor in pixels. + + This is a read only element. It is an integer that indicates the actual height of the camera's sensor in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SensorHeight; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the maximum allowed width of the image in pixels + + This is a read only element. It is an integer that indicates maximum allowed width of the image in pixels taking into account any function that may limit the allowed width. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& WidthMax; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the maximum allowed height of the image in pixels + + This is a read only element. It is an integer that indicates maximum allowed height of the image in pixels taking into account any function that may limit the allowed height. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& HeightMax; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Selects the type of light source to be considered for matrix color transformation + + Selects the color transformation mode to select the type of light source to be considered for matrix color transformation. + + \b Visibility = Expert + + \b Selected by : ColorTransformationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LightSourceSelector; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Allows returning to previous settings + + Allows returning to the color adjustment settings extant before the latest changes of the settings. + This allows you undoing the latest unwanted changes of the color adjustment settings and returning to the preceding settings. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& BalanceWhiteReset; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Balance White Auto is the 'automatic' counterpart of the manual white balance feature. + + The automatic white balance is a two-step process: First, the Balance Ratio Abs parameter values for red, green, and blue are each set to 1.5. Then, assuming a 'grey world' model, the Balance Ratio Abs parameter values are adjusted such that the average gray values for the 'red' and 'blue' pixels match the average gray value for the 'green' pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BalanceWhiteAuto; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Selects a balance ratio to configure. Once a balance ratio control has been selected, all changes to the balance ratio settings will be applied to the selected control. + + This enumeration selects a balance ratio control to configuration. Once a balance ratio control has been selected, all changes to the balance ratio settings will be applied to the selected control. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BalanceRatioSelector; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Sets the value of the selected balance ratio control as a float + + This value sets the selected balance ratio control as a float value. + + \b Visibility = Beginner + + + \b Selected by : BalanceRatioSelector + + */ + GENAPI_NAMESPACE::IFloat& BalanceRatioAbs; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Sets the value of the selected balance ratio control as an integer + + This value sets the selected balance ratio control as an integer. + + \b Visibility = Beginner + + + \b Selected by : BalanceRatioSelector + + */ + GENAPI_NAMESPACE::IInteger& BalanceRatioRaw; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Selects the matrix color transformation between color spaces + + Selects the matrix color transformation between color spaces. + Generally, the related color spaces are used for internal processing: The color signals provided by the sensor are transformed to the RGB color space to allow further transformations (to account for the type of light source, for color adjustment, for white balance, etc.). + The color transformation selected here does not refer to the color space selected for the transmission of image data out of the camera. + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorTransformationSelector; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Selects the element to be entered in the color transformation matrix. + + Selects the element to be entered in the 3 x 3 color transformation matrix for custom matrix color transformation. + Note: Depending on the camera model, some elements in the color transformation matrix may be preset and can not be changed. + + + \b Visibility = Guru + + \b Selected by : ColorTransformationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorTransformationValueSelector; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Sets a floating point value for the selected element in the color transformation matrix + + Sets a floating point value for the selected element in the color transformation matrix. + + \b Visibility = Guru + + \b Selected by : ColorTransformationSelector, ColorTransformationValueSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorTransformationValue; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Sets an integer value for the selected element in the color transformation matrix + + Sets an integer value for the selected element in the color transformation matrix. + + \b Visibility = Guru + + \b Selected by : ColorTransformationValueSelector + + */ + GENAPI_NAMESPACE::IInteger& ColorTransformationValueRaw; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Defines the extent to which the selected light source will be considered (float) + + Sets a floating point value to define the extent to which the selected light source will be considered in color matrix transformation. + If the value is set to 1 the selected light source will be fully considered. If the value is set to 0 the selected light source will not be considered. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ColorTransformationMatrixFactor; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Defines the extent to which the selected light source will be considered (integer) + + Sets an integer value to define the extent to which the selected light source will be considered in color matrix transformation. If the value is set to 65536 the selected light source will be fully considered. If the value is set to 0 the selected light source will not be considered. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ColorTransformationMatrixFactorRaw; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Enables color adjustment + + Enables color adjustment. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& ColorAdjustmentEnable; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Allows returning to previous settings + + Allows returning to the color adjustment settings extant before the latest changes of the settings. + This allows you undoing the latest unwanted changes of the color adjustment settings and returning to the preceding settings. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ColorAdjustmentReset; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Selects the color for color adjustment + + Selects the color for color adjustment. + Those colors in the image will be adjusted where the selected color predominates. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorAdjustmentSelector; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Adjustment of hue of the selected color (float) + + Sets a floating point value for the adjustment of hue of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorAdjustmentHue; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Adjustment of hue of the selected color (integer) + + Sets an integer value for the adjustment of hue of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IInteger& ColorAdjustmentHueRaw; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Adjustment of saturation of the selected color (float) + + Sets a floating point value for the adjustment of saturation of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorAdjustmentSaturation; + + //@} + + + //! \name ColorImprovementsControl - This category includes items that control color improvement + //@{ + /*! + \brief Adjustment of saturation of the selected color (integer) + + Sets an integer value for the adjustment of saturation of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IInteger& ColorAdjustmentSaturationRaw; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the width of the area of interest in pixels + + This value sets the width of the area of interest in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Width; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the height of the area of interest in pixels + + This value sets the height of the area of interest in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Height; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the X offset (left offset) of the area of interest in pixels + + This value sets the X offset (left offset) for the area of interest in pixels, i.e., the distance in pixels between the left side of the sensor and the left side of the image area. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& OffsetX; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the Y offset (top offset) for the area of interest in pixels + + This value sets the Y offset (top offset) for the area of interest, i.e., the distance in pixels between the top of the sensor and the top of the image area. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& OffsetY; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Enables the horizontal centering of the image. + + This feature is used to center the image horizontally. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& CenterX; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Enables the vertical centering of the image. + + This feature is used to center the image vertically. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& CenterY; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the vertical binning feature + + This enumeration sets the vertical binning feature. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LegacyBinningVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the horizontal binning mode + + This enumeration sets the horizontal binning mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningModeHorizontal; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the number of adjacent horizontal pixes to be summed + + Sets the number of binned adjacent horizontal pixels. Their charges will be summed and reported out of the camera as a single pixel. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& BinningHorizontal; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the vertical binning mode + + This enumeration sets the vertical binning mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningModeVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the number of adjacent vertical pixes to be summed + + Sets the number of binned adjacent vertical pixels. Their charges will be summed and reported out of the camera as a single pixel. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& BinningVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets horizontal sub-sampling + + Horizontal sub-sampling of the image. This has the net effect of reducing the horizontal resolution (width) of the image by the specified horizontal decimation factor. A value of 1 indicates that the camera performs no horizontal decimation. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DecimationHorizontal; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets vertical sub-sampling + + Vertical sub-sampling of the image. This has the net effect of reducing the vertical resolution (height) of the image by the specified vertical decimation factor. A value of 1 indicates that the camera performs no vertical decimation. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DecimationVertical; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Enables the stacked zone imaging feature. + + Enables the stacked zone imaging feature. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& StackedZoneImagingEnable; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief This value sets the zone to access. + + This value sets the zone to access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& StackedZoneImagingIndex; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Enables the selected zone. + + Enables the selected zone. + + \b Visibility = Beginner + + + \b Selected by : StackedZoneImagingIndex + + */ + GENAPI_NAMESPACE::IBoolean& StackedZoneImagingZoneEnable; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Sets the Y offset (top offset) for the selected zone. + + Sets the Y offset (top offset) for the selected zone. + + \b Visibility = Beginner + + + \b Selected by : StackedZoneImagingIndex + + */ + GENAPI_NAMESPACE::IInteger& StackedZoneImagingZoneOffsetY; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Sets the height for the selected zone. + + Sets the height for the selected zone. + + \b Visibility = Beginner + + + \b Selected by : StackedZoneImagingIndex + + */ + GENAPI_NAMESPACE::IInteger& StackedZoneImagingZoneHeight; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief When enabled, the maximum frame rate does not depend on the image transfer rate out of the camera. + + When enabled, the maximum frame rate onyl depends on sensor timing and timing of the trigger sequence, and not on the image transfer rate out of the camera. + + Note: The maximum number of triggers within a burst sequence is limited. If the maximum number is exceeded, images may be damaged or lost. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& EnableBurstAcquisition; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the image acquisition mode + + This enumeration sets the image acquisition mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Starts the acquisition of images + + This command starts the acquisition of images. If the camera is set for single frame acquisition, it will start acquisition of one frame. If the camera is set for continuous frame acquisition, it will start continuous acquisition of frames. + + \b Visibility = Beginner + + + \b Selected by : AcquisitionMode + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionStart; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Stops the acquisition of images + + If the camera is set for continuous image acquisition and acquisition has been started, this command stops the acquisition of images. + + \b Visibility = Beginner + + + \b Selected by : AcquisitionMode + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionStop; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Immediately aborts the acquisition of images + + This command will immediately abort any image acquisition process that is currently in progress. + + \b Visibility = Beginner + + + \b Selected by : AcquisitionMode + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionAbort; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the number of frames acquired in the multiframe acquisition mode + + This value sets the number of frames acquired in the multiframe acquisition mode + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionFrameCount; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerControlImplementation; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the trigger type to configure. Once a trigger type has been selected, all changes to the trigger settings will be applied to the selected trigger. + + This enumeration selects the trigger type to configure. Once a trigger type has been selected, all changes to the trigger settings will be applied to the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerControlImplementation + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerSelector; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the mode for the selected trigger + + This enumeration sets the trigger mode for the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Generates a software trigger signal that is used when the trigger source is set to 'software' + + This command generates a software trigger signal. The software trigger signal will be used if the trigger source is set to 'software'. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::ICommand& TriggerSoftware; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the signal source for the selected trigger + + This enumeration sets the signal source for the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerSource; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the signal transition needed to activate the selected trigger + + This enumeration sets the signal transition needed to activate the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerActivation; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Determines whether a partial or complete frame is transmitted when the frame start trigger prematurely transitions. + + This feature determines whether a partial or a complete frame is transmitted when the frame start trigger is used with Level High or Level Low and when the frame start trigger signal transitions while the frame is still being acquired. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IBoolean& TriggerPartialClosingFrame; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the kind of trigger delay. + + Selects wheter trigger delay is defined as a time interval or as a number of consecutive line triggers. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerDelaySource; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the trigger delay time in microseconds. + + This float value sets the absolute trigger delay in microseconds to apply after the trigger reception before effectively activating it. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IFloat& TriggerDelayAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the trigger delay expressed as number of line triggers. + + This integer value sets the trigger delay expressed as a number of consecutive line triggers to apply after the trigger reception before effectively activating it. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IInteger& TriggerDelayLineTriggerCount; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureStartDelayAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureStartDelayRaw; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the exposure mode + + This enumeration sets the exposure mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the Interlaced Integration Mode. + + Selects the Interlaced Integration Mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& InterlacedIntegrationMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Exposure Auto is the 'automatic' counterpart to manually setting an 'absolute' exposure time. + + The exposure auto function automatically adjusts the Auto Exposure Time Abs parameter value within set limits, until a target average gray value for the pixel data of the related Auto Function AOI is reached. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureAuto; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Directly sets the camera's exposure time in microseconds + + This float value sets the camera's exposure time in microseconds. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureTimeAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the time base (in microseconds) that is used when the exposure time is set with the 'exposure time raw' setting + + This float value sets the time base (in microseconds) that is used when the exposure time is set with the 'raw' setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureTimeBaseAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables the use of the exposure time base + + This value enables the use of the exposure time base. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ExposureTimeBaseAbsEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the 'raw' exposure time. Actual exposure time = raw exposure setting x exposure time base abs setting + + This value sets an integer that will be used as a multiplier for the exposure timebase. The actual exposure time equals the current exposure time raw setting times the current exposure time base abs setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureTimeRaw; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the sensor readout time given the current settings. + + Indicates the sensor readout time given the current settings. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& ReadoutTimeAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the maximum overlap of the sensor exposure with sensor readout in TriggerWidth exposure mode in microseconds + + This float value sets the maximum overlap time (in microseconds) of the sensor exposure with sensor readout in TriggerWidth exposure mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ExposureOverlapTimeMaxAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the maximum overlap of the sensor exposure with the sensor readout in TriggerWidth exposure mode in raw units. + + This integer value sets the maximum overlap time (in raw units) of the sensor exposure with sensor readout in TriggerWidth exposure mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ExposureOverlapTimeMaxRaw; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enable the Global Reset Release Mode + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IBoolean& GlobalResetReleaseModeEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the shutter mode + + This enumeration sets the shutter mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShutterMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the camera's acquisition line rate in lines per second + + Sets the 'absolute' value of the acquisition line rate. The 'absolute' value is a float value that sets the acquisition line rate in lines per second. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AcquisitionLineRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the minimum allowed line acquisition period (in microseconds) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the minimum allowed acquisition line period. The 'absolute' value is a float value that indicates the minimum allowed acquisition line period in microseconds given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ResultingLinePeriodAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the maximum allowed line acquisition rate (in lines per second) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the maximum allowed acquisition line rate. The 'absolute' value is a float value that indicates the maximum allowed acquisition line rate in lines per second given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ResultingLineRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables setting the camera's acquisition frame rate to a specified value + + This boolean value enables setting the camera's acquisition frame rate to a specified value. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& AcquisitionFrameRateEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief If the acquisition frame rate feature is enabled, this value sets the camera's acquisition frame rate in frames per second + + Sets the 'absolute' value of the acquisition frame rate. The 'absolute' value is a float value that sets the acquisition frame rate in frames per second. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AcquisitionFrameRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionFrameRateEnum; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the minimum allowed frame acquisition period (in microseconds) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the minimum allowed acquisition frame period. The 'absolute' value is a float value that indicates the minimum allowed acquisition frame period in microseconds given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ResultingFramePeriodAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the maximum allowed frame acquisition rate (in frames per second) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the maximum allowed acquisition frame rate. The 'absolute' value is a float value that indicates the maximum allowed acquisition frame rate in frames per second given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ResultingFrameRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief This enumeration is used to select which internal acquisition signal to read using AcquisitionStatus. + + This enumeration is used to select which internal acquisition signal to read using AcquisitionStatus. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionStatusSelector; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Reads the selected acquisition status + + This feature is used to read the state (True or False) of the internal acquisition signal selected using AcquisitionStatusSelector. + + \b Visibility = Expert + + \b Selected by : AcquisitionStatusSelector + + */ + GENAPI_NAMESPACE::IBoolean& AcquisitionStatus; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables the frame timeout + + This boolean value enables the frame timeout. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& FrameTimeoutEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the frame timeout in microseconds. + + Sets the frame timeout in microseconds. When the timeout expires before a frame acquisition is complete, a partial frame will be delivered. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& FrameTimeoutAbs; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Selects the I/O line to configure. Once a line has been selected, all changes to the line settings will be applied to the selected line. + + This enumeration selects the I/O line to configure. Once a line has been selected, all changes to the line settings will be applied to the selected line. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LineSelector; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the mode for the selected line + + This feature controls whether the physical Line is used to Input or Output a signal. When a Line supports input and output mode, the default state is Input to avoid possible electrical contention. Line Mode can take any of the following values: Input: The selected physical line is used to input an electrical signal. Output: The selected physical line is used to output an electrical signal. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineMode; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LineLogic; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the electrical configuration of the selected line + + This feature controls the current electrical format of the selected physical input or output Line. Line Format can take any of the following values: No Connect: The Line is not connected. Tri-state: The Line is currently in Tri-state mode (Not driven). TTL: The Line is currently accepting or sending TTL level signals. LVDS: The Line is currently accepting or sending LVDS level signals. RS-422: The Line is currently accepting or sending RS-422 level signals. Opto-coupled: The Line is Opto-coupled. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineFormat; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the source signal for the selected line (if the selected line is an output) + + This enumeration selects the internally generated camera signal (source signal) for the selected line when the selected line is an output. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineSource; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Enables the signal inverter function for the selected input or output line. + + This boolean value enables the signal inverter function for the selected input or output line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineInverter; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Enables the termination resistor for the selected input line. + + This boolean value enables the termination resistor for the selected input line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineTermination; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the absolute value of the selected line debouncer time in microseconds + + Sets the absolute value of the selected line debouncer time in microseconds + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IFloat& LineDebouncerTimeAbs; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the raw value of the selected line debouncer time + + Sets the raw value of the selected line debouncer time + + \b Visibility = Invisible + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IInteger& LineDebouncerTimeRaw; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the raw value for the minimum signal width of an output signal. + + This integer value sets the raw value for the minimum signal width of a signal that is received from the frequency converter or from the shaft encoder module and that is associated with a digital output line. + + \b Visibility = Invisible + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IInteger& MinOutPulseWidthRaw; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the absolute value (in microseconds) for the minimum signal width of an output signal. + + This float value sets the absolute value (in microseconds) for the minimum signal width of a signal that is received from the frequency converter or from the shaft encoder module and that is associated with a digital output line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IFloat& MinOutPulseWidthAbs; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Indicates the current logical state for the selected line + + This boolean value indicates the current logical state for the selected line at the time of polling. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineStatus; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief A single bitfield indicating the current logical state of all available line signals at time of polling + + This integer value is a single bitfield that indicates the current logical state of all available lines at time of polling. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LineStatusAll; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Selects the user settable output signal to configure. Once a user settable output signal has been selected, all changes to the user settable output signal settings will be applied to the selected user settable output signal. + + This enumeration selects the user settable output signal to configure. Once a user settable output signal has been selected, all changes to the user settable output signal settings will be applied to the selected user settable output signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserOutputSelector; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the state of the selected user settable output signal + + This boolean value sets the state of the selected user settable output signal. + + \b Visibility = Beginner + + + \b Selected by : UserOutputSelector + + */ + GENAPI_NAMESPACE::IBoolean& UserOutputValue; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief A single bitfield that sets the state of all user settable output signals in one access + + This integer value is a single bitfield that sets the state of all user settable output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& UserOutputValueAll; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Defines a mask that is used when the User Output Value All setting is used to set all of the user settable output signals in one access + + This integer value defines a mask that is used when the User Output Value All setting is used to set all of the user settable output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& UserOutputValueAllMask; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& SyncUserOutputSelector; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the state of the selected user settable synchronous output signal + + This boolean value sets the state of the selected user settable synchronous output signal. + + \b Visibility = Beginner + + + \b Selected by : SyncUserOutputSelector + + */ + GENAPI_NAMESPACE::IBoolean& SyncUserOutputValue; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief A single bitfield that sets the state of all user settable synchronous output signals in one access + + This integer value is a single bitfield that sets the state of all user settable synchronous output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SyncUserOutputValueAll; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Sets the I/O line on which the camera receives the virtual input signal + + This enumeration selects the I/O line on which the camera receives the virtual input signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& VInpSignalSource; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Sets the length of the input bit + + This integer value sets the length of the input bit in microseconds. It applies to all bits in the signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VInpBitLength; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Time span between the beginning of the input bit and the time when the high/low status is evaluated + + This integer value sets the time in microseconds that elapses between the beginning of the input bit and the time when the high/low status of the bit is evaluated. It applies to all bits. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VInpSamplingPoint; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Selects when to start the signal evaluation + + This enumeration selects when to start the signal evaluation. The camera waits for a rising/falling edge on the input line. When the appropriate signal has been received, the camera starts evaluating the incoming bit patterns. When one bit pattern is finished, the camera waits for the next rising/falling edge to read out the next incoming bit pattern. The camera stops listening once three bits have been received. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& VInpSignalReadoutActivation; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the phase of the shaft encoder. + + Selects the phase of the shaft encoder as input for the shaft encoder module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleLineSelector; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the input line as signal source for the shaft encoder module. + + Selects the input line as signal source for the shaft encoder module. + + \b Visibility = Expert + + \b Selected by : ShaftEncoderModuleLineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleLineSource; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the circumstances for the shaft encoder module to output trigger signals. + + This enumeration value selects the circumstances for the shaft encoder module to output trigger signals. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleMode; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the counting mode of the tick counter. + + Selects the counting mode of the tick counter of the shaft encoder module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleCounterMode; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Indicates the current value of the tick counter. + + This integer value (read only) indicates the current value of the tick counter of the shaft encoder module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& ShaftEncoderModuleCounter; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Sets the maximum value for the tick counter. + + This integer value sets the maximum value for the tick counter of the shaft encoder module (range: 0 to 32767). If the tick counter is incrementing and it reaches the set maximum, it willl roll over to 0. If the tick counter is decrementing and it reaches 0, it willl roll back to the set maximum. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& ShaftEncoderModuleCounterMax; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Resets the tick counter to 0. + + This command resets the tick counter count of the shaft encoder module to 0. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ShaftEncoderModuleCounterReset; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Sets the maximum value for the reverse counter. + + This integer value sets the maximum value for the reverse counter of the shaft encoder module (range: 0 to 32767). + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& ShaftEncoderModuleReverseCounterMax; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Resets the reverse counter to 0. + + This command resets the reverse counter of the shaft encoder module to 0 and informs the module that the current direction of conveyor movement is forward. Reset must be carried out before the first conveyor movement in the forward direction. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ShaftEncoderModuleReverseCounterReset; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Selects the input source. + + Selects the input source for the frequency converter module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& FrequencyConverterInputSource; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Selects the signal transition relationships between received and generated signals. + + Selects the signal transition relationships between the signals received from the pre-divider sub-module and the signals generated by the multiplier sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& FrequencyConverterSignalAlignment; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Sets the pre-divider value for the pre-divider sub-module. + + Sets an integer value as the pre-divider for the pre-divider sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& FrequencyConverterPreDivider; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Sets the multiplier value for the multiplier sub-module. + + Sets an integer value as the multiplier for the multiplier sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& FrequencyConverterMultiplier; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Sets the post-divider value for the post-divider sub-module. + + Sets an integer value as the post-divider for the post-divider sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& FrequencyConverterPostDivider; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Enables overtriggering protection. + + This feature ensures that the multiplier sub-module does not provide a generated signal at a too high frequency that would cause camera overtriggering. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& FrequencyConverterPreventOvertrigger; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the time base (in microseconds) that is used when a timer delay is set with the 'timer delay raw' setting + + This float value sets the time base (in microseconds) that is used when a timer delay is set with the 'raw' setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& TimerDelayTimebaseAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the time base (in microseconds) that is used when a timer duration is set with the 'timer duration raw' setting + + This float value sets the time base (in microseconds) that is used when a timer duration is set with the 'raw' setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& TimerDurationTimebaseAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the timer to configure. Once a timer has been selected, all changes to the timer settings will be applied to the selected timer. + + This enumeration selects the timer to configure. . Once a timer has been selected, all changes to the timer settings will be applied to the selected timer. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSelector; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Directly sets the delay for the selected timer in microseconds + + This float value sets the delay for the selected timer in microseconds. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IFloat& TimerDelayAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the 'raw' delay for the selected timer. Actual delay = raw timer delay setting x timer delay time base abs setting + + This value sets an integer that will be used as a multiplier for the timer delay timebase. The actual delay time equals the current timer delay raw setting times the current timer delay time base abs setting. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerDelayRaw; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Directly sets the duration for the selected timer in microseconds + + This float value sets the duration for the selected timer in microseconds. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IFloat& TimerDurationAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the 'raw' duration for the selected timer. Actual duration = raw timer duration setting x timer duration time base abs setting + + This value sets an integer that will be used as a multiplier for the timer duration timebase. The actual duration time equals the current timer duration raw setting times the current timer duration time base abs setting. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerDurationRaw; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the internal camera signal used to trigger the selected timer + + This enumeration sets the internal camera signal used to trigger the selected timer. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerTriggerSource; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the type of signal transistion that will start the timer + + This enumeration sets the type of signal transistion that will start the timer. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerTriggerActivation; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the counter to configure. Once a counter has been selected, all changes to the counter settings will be applied to the selected counter. + + This enumeration selects the counter to configure. Once a counter has been selected, all changes to the counter settings will be applied to the selected counter. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterSelector; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the event that will be the source to increment the counter + + This enumeration selects the event that will be the source to increment the counter. + + \b Visibility = Expert + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterEventSource; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the source of the reset for the selected counter. + + This enumeration selects the source of the reset for the selected counter. + + \b Visibility = Expert + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterResetSource; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Immediately resets the selected counter + + This command will immediately reset the selected counter. Note that the counter starts counting immediately after the reset. + + \b Visibility = Expert + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::ICommand& CounterReset; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& TimerSequenceEnable; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceLastEntryIndex; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceCurrentEntryIndex; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSequenceEntrySelector; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceEntrySelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSequenceTimerSelector; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IBoolean& TimerSequenceTimerEnable; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IBoolean& TimerSequenceTimerInverter; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceTimerDelayRaw; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceTimerDurationRaw; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Selects the lookup table (LUT) to configure. Once a LUT has been selected, all changes to the LUT settings will be applied to the selected LUT. + + This enumeration the lookup table (LUT) to configure. Once a LUT has been selected, all changes to the LUT settings will be applied to the selected LUT. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LUTSelector; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Enables the selected LUT + + This boolean value enables the selected LUT. + + \b Visibility = Beginner + + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IBoolean& LUTEnable; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Sets the LUT element to access + + This value sets the LUT element to access. This value is used to index into a LUT array. + + \b Visibility = Beginner + + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IInteger& LUTIndex; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Sets the value of the LUT element at the LUT index + + This value sets the value of the LUT element at the LUT index. + + \b Visibility = Beginner + + + \b Selected by : LUTSelector, LUTIndex + + */ + GENAPI_NAMESPACE::IInteger& LUTValue; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Accesses the entire content of the selected LUT in one chunk access + + + + \b Visibility = Beginner + + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IRegister& LUTValueAll; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief + + The tap geometry uniquely describes with a standardized name, the geometrical properties characterizing the different taps of a multitap camera + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ClTapGeometry; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ClConfiguration; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ClTimeSlots; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ClSerialPortBaudRate; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief + + The pixel clock used in the communication with the grabber + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ClPixelClock; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief The pixel clock used in the communication with the grabber in Hz + + The pixel clock used in the communication with the grabber in Hz + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ClPixelClockAbs; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief Sets the delay between end of transmission and start of transmission of consecutive lines + + The Inter-line Delay Raw parameter sets the delay between the end of transmission of a line and the start of transmission of the next line. + The parameter sets an integer value to express the delay as a number pixel clock cycles. The line valid signal (LVAL) remains low during the set number of pixel clock cycles. + The default value of the parameter is the minimum allowed number of inter-line clock cycles. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ClInterLineDelayRaw; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief Sets the delay between end of transmission and start of transmission of consecutive lines + + The Inter-line Delay Abs parameter sets the delay between the end of transmission of a line and the start of transmission of the next line. + The parameter sets a floating point value to express the delay in microseconds. The set value will be automatically adjusted to the nearest value that can be expressed as a multiple of the period of the currently selected pixel clock. The line valid signal (LVAL) remains low during the set delay. + The default value of the parameter is the minimum allowed inter-line delay. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ClInterLineDelayAbs; + + //@} + + + //! \name TransportLayer - This category includes items related to the Cameralink transport layer + //@{ + /*! + \brief Indicates whether a live grab is under way + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& TLParamsLocked; + + //@} + + + //! \name DeviceControl - + //@{ + /*! + \brief Prepare the device for registers streaming + + StartFeatureStreaming + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceRegistersStreamingStart; + + //@} + + + //! \name DeviceControl - + //@{ + /*! + \brief Announce the end of registers streaming + + StopFeatureStreaming + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceRegistersStreamingEnd; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Selects the configuration set to load, save, or configure. Once a configuration set has been selected, all changes to the configuration set settings will be applied to the selected configuration set. + + This enumeration selects the configuration set to load, save or configure. Possible values for the User Set Selector are: Default: Selects a configuration set that contains factory settings. User Set 1: Selects the first user set. When the Default configuration set is selected and loaded using User Set Load, the device must be in default factory settings state and must make sure the mandatory continuous acquisition use case works directly. Default User Set is read-only and cannot be modified. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserSetSelector; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Loads the selected configuration into the camera's volatile memory and makes it the active configuration set. Once the selected set is loaded, the parameters in the selected set will control the camera. + + This command loads the selected configuration set from the non-volatile memory in the camera to the volatile memory and makes the selected set the active configuration set. Once the selected set is loaded, the parameters in the selected set will control the camera. + + \b Visibility = Beginner + + + \b Selected by : UserSetSelector + + */ + GENAPI_NAMESPACE::ICommand& UserSetLoad; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Saves the current active configuration set into the selected user set. + + This command copies the parameters in the current active configuration set into the selected user set in the camera's non-volatile memory. + + \b Visibility = Beginner + + + \b Selected by : UserSetSelector + + */ + GENAPI_NAMESPACE::ICommand& UserSetSave; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Sets the configuration set to be used as the default startup set. The configuration set that has been selected as the default startup set will be loaded as the active set whenever the camera is powered on or reset. + + This enumeration sets the configuration set to be used as the default startup set. The configuration set that has been selected as the default startup set will be loaded as the active set whenever the camera is powered on or reset. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserSetDefaultSelector; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Selects the which factory setting will be used as default set. + + Selects the which factory setting will be used as default set. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IEnumerationT& DefaultSetSelector; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Target average grey value for Gain Auto and Exposure Auto + + The target average grey value may range from nearly black to nearly white. Note that this range of gray values applies to 8 bit and to 16 bit (12 bit effective) output modes. Accordingly, also for 16 bit output modes, black is represented by 0 and white by 255. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoTargetValue; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Gray value adjustment damping for Gain Auto and Exposure Auto + + The gray value adjustment damping parameter controls the rate by which pixel gray values are changed when Exposure Auto and/or Gain Auto are enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& GrayValueAdjustmentDampingAbs; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Gray value adjustment damping for Gain Auto and Exposure Auto + + The gray value adjustment damping parameter controls the rate by which pixel gray values are changed when Exposure Auto and/or Gain Auto are enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& GrayValueAdjustmentDampingRaw; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Balance White adjustment damping for Balance White Auto + + The Balance White adjustment damping parameter controls the rate by which the color components are changed when Balance White Auto is enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& BalanceWhiteAdjustmentDampingAbs; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Balance White adjustment damping for Balance White Auto + + The Balance White adjustment damping parameter controls the rate by which the color components are changed when Balance White Auto is enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& BalanceWhiteAdjustmentDampingRaw; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Lower limit of the Auto Gain (Raw) parameter + + Lower limit of the Auto Gain (Raw) parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoGainRawLowerLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Upper limit of the Auto Gain (Raw) parameter + + Upper limit of the Auto Gain (Raw) parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoGainRawUpperLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Lower limit of the Auto Exposure Time (Abs) [us] parameter + + Lower limit of the Auto Exposure Time (Abs) [us] parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoExposureTimeAbsLowerLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Upper limit of the Auto Exposure Time (Abs) [us] parameter + + Upper limit of the Auto Exposure Time (Abs) [us] parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoExposureTimeAbsUpperLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Selects the strategy for controlling gain and shutter simultaneously. + + Selects the profile for controlling gain and shutter simultaneously. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionProfile; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Selects the Auto Function AOI. + + Selects the Auto Function AOI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionAOISelector; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the width of the auto function area of interest in pixels + + This value sets the width of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIWidth; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the height of the auto function area of interest in pixels + + This value sets the height of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIHeight; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the starting column of the auto function area of interest in pixels + + This value sets the starting column of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIOffsetX; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the starting line of the auto function area of interest in pixels + + This value sets the starting line of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIOffsetY; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageIntensity; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageWhiteBalance; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageRedLightCorrection; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Selcts the AOI for color overexposure compensation + + Selcts the area of interest where color overexposure compensation will be performed. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorOverexposureCompensationAOISelector; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Enables color overexposure compensation + + Enables color overexposure compensation. + + \b Visibility = Beginner + + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& ColorOverexposureCompensationAOIEnable; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the color overexposure compensation factor for the selected C.O.C. AOI + + Sets the color overexposure compensation factor controlling the extent of compensation for the selected C.O.C. AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IFloat& ColorOverexposureCompensationAOIFactor; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the raw value for the color overexposure compensation factor + + Sets the raw value for the color overexposure compensation factor. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIFactorRaw; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the width for the selected C.O.C. AOI + + Sets the width for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIWidth; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the height for the selected C.O.C. AOI + + Sets the height for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIHeight; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the X offset for the selected C.O.C. AOI + + Sets the horizontal offset for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIOffsetX; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the Y offset for the selected C.O.C. AOI + + Sets the vertical offset for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIOffsetY; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Selects the kind of shading correction. + + This enumeration selects the kind of shading correction. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSelector; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Enables the selected kind of shading correction. + + This boolean value enables the selected kind of shading correction. + + \b Visibility = Beginner + + + \b Selected by : ShadingSelector + + */ + GENAPI_NAMESPACE::IBoolean& ShadingEnable; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Indicates error statuses related to shading correction. + + This enumeratuion indicates error statuses related to shading correction. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingStatus; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Selects the bootup shading set. + + This enumeration selects the shading set that will be loaded into the volatile memory during camera bootup. + + \b Visibility = Expert + + \b Selected by : ShadingSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSetDefaultSelector; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Selects the shading set to which the activate command will be applied. + + This enumeration selects the shading set to which the activate command will be applied. + + \b Visibility = Expert + + \b Selected by : ShadingSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSetSelector; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Activates the selected shading set. + + This command copies the selected shading set from the camera's non-volatile memory into the volatile memory. Shading correction is performed using the shading set in the volatile memory. + + \b Visibility = Expert + + \b Selected by : ShadingSetSelector + + */ + GENAPI_NAMESPACE::ICommand& ShadingSetActivate; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Creates a shading set. + + ShadingSetCreate + + \b Visibility = Expert + + \b Selected by : ShadingSetSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSetCreate; + + //@} + + + //! \name UserDefinedValues - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& UserDefinedValueSelector; + + //@} + + + //! \name UserDefinedValues - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : UserDefinedValueSelector + + */ + GENAPI_NAMESPACE::IInteger& UserDefinedValue; + + //@} + + + //! \name FeatureSets - + //@{ + /*! + \brief Select default genicam XML file + + If the camera contains multiple GenICam XML files, this parameter determines which of them is accessible to non-manifest-aware software accessing register address 0x0200 (first url). + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& GenicamXmlFileDefault; + + //@} + + + //! \name FeatureSets - + //@{ + /*! + \brief Select a camera description file + + Selects a feature set description file. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& FeatureSet; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the name of the device's vendor + + This is a read only element. It is a text description that indicates the name of the device's vendor. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceVendorName; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the model name of the device + + This is a read only element. It is a text description that indicates the model name of the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceModelName; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Provides additional information from the vendor about the device + + This is a read only element. It is a string that provides additional information from the vendor about the camera. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceManufacturerInfo; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the version of the device + + This is a read only element. It is a string that indicates the version of the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceVersion; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the device's serial number + + This is a read only element. It is a string that indicates the device's serial number. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IString& DeviceID; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief user-programmable identifier + + This feature stores a user-programmable identifier. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceUserID; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the version of the device's firmware and software + + This is a read only element. It is a string that indicates the version of the device's firmware and software. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceFirmwareVersion; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the scan type of the device's sensor + + This enumeration lists the possible scan types for the sensor in the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& DeviceScanType; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Immediately resets and reboots the device + + This is a command that immediately resets and reboots the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::ICommand& DeviceReset; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Lists the temperature sources available for readout + + Lists the temperature sources available for readout + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TemperatureSelector; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Shows the current temperature of the selected target in degrees centigrade + + Shows the current temperature of the selected target in degrees centigrade + + \b Visibility = Expert + + \b Selected by : TemperatureSelector + + */ + GENAPI_NAMESPACE::IFloat& TemperatureAbs; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Temperature State + + Temperature State + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TemperatureState; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Shows the over temperature state of the selected target + + Shows the over temperature state of the selected target + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& CriticalTemperature; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Shows the over temperature state of the selected target + + Shows the over temperature state of the selected target + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& OverTemperature; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the error that was detected last + + Indicates the error that was detected last. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& LastError; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Erases the last error and possibly reveals a previous error + + Erases the last error and possibly reveals a previous error. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ClearLastError; + + //@} + + + //! \name RemoveParamLimits - This category includes items that allow removing the limits of camera parameters + //@{ + /*! + \brief Selects the parameter to configure. Once a parameter has been selected, all changes made using the Remove Limits feature will be applied to the selected parameter + + This enumeration selects the parameter to configure. Selects the parameter to configure. Once a parameter has been selected, all changes made using the Remove Limits feature will be applied to the selected parameter + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ParameterSelector; + + //@} + + + //! \name RemoveParamLimits - This category includes items that allow removing the limits of camera parameters + //@{ + /*! + \brief Removes the factory-set limits of the selected parameter. + + Removes the factory-set limits of the selected parameter. Having removed the factory-set limits you may set the parameter within extended limits. These are only defined by technical restrictions. Note: Inferior image quality may result. + + \b Visibility = Guru + + \b Selected by : ParameterSelector + + */ + GENAPI_NAMESPACE::IBoolean& RemoveLimits; + + //@} + + + //! \name RemoveParamLimits - This category includes items that allow removing the limits of camera parameters + //@{ + /*! + \brief Sets the number of prelines + + This value sets the number of prelines. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& Prelines; + + //@} + + + //! \name ExpertFeatureAccess - + //@{ + /*! + \brief Selects the feature to configure. Once a feature has been selected, all changes made using the feature enable feature will be applied to the selected feature + + Selects the feature to configure. Once a feature has been selected, all changes made using the feature enable feature will be applied to the selected feature + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ExpertFeatureAccessSelector; + + //@} + + + //! \name ExpertFeatureAccess - + //@{ + /*! + \brief Sets the key to access the selected feature + + Sets the key to access the selected feature + + \b Visibility = Guru + + \b Selected by : ExpertFeatureAccessSelector + + */ + GENAPI_NAMESPACE::IInteger& ExpertFeatureAccessKey; + + //@} + + + //! \name ExpertFeatureAccess - + //@{ + /*! + \brief Enable the selected Feature + + Enable the selected Feature + + \b Visibility = Guru + + \b Selected by : ExpertFeatureAccessSelector + + */ + GENAPI_NAMESPACE::IBoolean& ExpertFeatureEnable; + + //@} + + + //! \name N61 - This category includes items available for an frame start event + //@{ + /*! + \brief Indicates the stream channel index for an frame start event + + This enumeration Indicates the stream channel index for an frame start event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N62; + + //@} + + + //! \name N61 - This category includes items available for an frame start event + //@{ + /*! + \brief Indicates the time stamp for an frame start event + + This enumeration value indicates the time stamp for an frame start event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N63; + + //@} + + + //! \name N66 - This category includes items available for an acquisition start event + //@{ + /*! + \brief Indicates the stream channel index for an acquisition start event + + This enumeration Indicates the stream channel index for an acquisition start event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N67; + + //@} + + + //! \name N66 - This category includes items available for an acquisition start event + //@{ + /*! + \brief Indicates the time stamp for an acquisition start event + + This enumeration value indicates the time stamp for an acquisition start event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N68; + + //@} + + + //! \name N71 - This category includes items available for a critical temperature event + //@{ + /*! + \brief Indicates the stream channel index for a critical temperature event + + This enumeration Indicates the stream channel index for a critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N72; + + //@} + + + //! \name N71 - This category includes items available for a critical temperature event + //@{ + /*! + \brief Indicates the time stamp for a critical temperature event + + This enumeration value indicates the time stamp for a critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N73; + + //@} + + + //! \name N76 - This category includes items available for an over temperature event + //@{ + /*! + \brief Indicates the stream channel index for an over temperature event + + This enumeration Indicates the stream channel index for an over temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N77; + + //@} + + + //! \name N76 - This category includes items available for an over temperature event + //@{ + /*! + \brief Indicates the time stamp for an over temperature event + + This enumeration value indicates the time stamp for an over temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N78; + + //@} + + + //! \name N81 - This category includes items available for an io line 1 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 1 rising edge event + + This enumeration Indicates the stream channel index for an io line 1 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N82; + + //@} + + + //! \name N81 - This category includes items available for an io line 1 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 1 rising edge event + + This enumeration value indicates the time stamp for an io line 1 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N83; + + //@} + + + //! \name N86 - This category includes items available for an io line 2 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 2 rising edge event + + This enumeration Indicates the stream channel index for an io line 2 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N87; + + //@} + + + //! \name N86 - This category includes items available for an io line 2 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 2 rising edge event + + This enumeration value indicates the time stamp for an io line 2 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N88; + + //@} + + + //! \name N91 - This category includes items available for an io line 3 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 3 rising edge event + + This enumeration Indicates the stream channel index for an io line 3 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N92; + + //@} + + + //! \name N91 - This category includes items available for an io line 3 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 3 rising edge event + + This enumeration value indicates the time stamp for an io line 3 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N93; + + //@} + + + //! \name N96 - This category includes items available for an io line 4 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 4 rising edge event + + This enumeration Indicates the stream channel index for an io line 4 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N97; + + //@} + + + //! \name N96 - This category includes items available for an io line 4 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 4 rising edge event + + This enumeration value indicates the time stamp for an io line 4 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N98; + + //@} + + + //! \name N101 - This category includes items available for an io virtual line 1 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 1 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 1 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N102; + + //@} + + + //! \name N101 - This category includes items available for an io virtual line 1 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 1 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 1 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N103; + + //@} + + + //! \name N106 - This category includes items available for an io virtual line 2 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 2 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 2 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N107; + + //@} + + + //! \name N106 - This category includes items available for an io virtual line 2 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 2 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 2 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N108; + + //@} + + + //! \name N111 - This category includes items available for an io virtual line 3 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 3 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 3 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N112; + + //@} + + + //! \name N111 - This category includes items available for an io virtual line 3 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 3 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 3 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N113; + + //@} + + + //! \name N116 - This category includes items available for an io virtual line 4 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 4 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 4 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N117; + + //@} + + + //! \name N116 - This category includes items available for an io virtual line 4 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 4 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 4 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& N118; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief This feature selects the target file in the device + + The File Selector feature selects the target file in the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& FileSelector; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Selects the target operation for the selected file + + The File Operation Selector feature selects the target operation for the selected file in the device. This Operation is executed when the FileOperationExecute feature is called. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOperationSelector; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Selects the access mode in which a file is opened + + The File Open Mode feature selects the access mode in which a file is opened in the device. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOpenMode; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Defines the intermediate access buffer + + The File Access Buffer feature defines the intermediate access buffer that allows the exchange of data between the device file storage and the application. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IRegister& FileAccessBuffer; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Controls the mapping between the device file storage and the FileAccessBuffer + + This feature controls the mapping between the device file storage and the FileAccessBuffer. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileAccessOffset; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Controls the mapping between the device file storage and the FileAccessBuffer + + This feature controls the mapping between the device file storage and the FileAccessBuffer. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileAccessLength; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Represents the file operation execution status + + The File Operation Status feature represents the file operation execution status. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOperationStatus; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Represents the file operation result + + The File Operation Result feature represents the file operation result. For Read or Write operations, the number of successfully read/written bytes is returned. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileOperationResult; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Represents the size of the selected file + + The File Size feature represents the size of the selected file in bytes. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IInteger& FileSize; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Executes the selected operation + + The File Operation Execute feature is the command that executes the operation selected by FileOperationSelector on the selected file. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::ICommand& FileOperationExecute; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& VolatileRowOffsetEnable; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VolatileRowOffsetIndex; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : VolatileRowOffsetIndex + + */ + GENAPI_NAMESPACE::IInteger& VolatileRowOffsetValue; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IRegister& VolatileRowOffsetValueAll; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& VolatileColumnOffsetEnable; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VolatileColumnOffsetIndex; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : VolatileColumnOffsetIndex + + */ + GENAPI_NAMESPACE::IInteger& VolatileColumnOffsetValue; + + //@} + + + //! \name VolatileRowColumnOffset - + //@{ + /*! + \brief + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IRegister& VolatileColumnOffsetValueAll; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CCLCameraParams_Params( CCLCameraParams_Params& ); + + //! not implemented assignment operator + CCLCameraParams_Params& operator=( CCLCameraParams_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CCLCameraParams_Params::CCLCameraParams_Params( void ) + : SequenceEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SequenceCurrentSet( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceAsyncRestart( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceAsyncAdvance( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceSetTotalNumber( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceSetIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceSetStore( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceSetLoad( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceSetExecutions( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceAdvanceMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceControlSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceControlSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceAddressBitSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceAddressBitSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GainAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , BlackLevelSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BlackLevelRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BlackLevelAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , GammaEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GammaSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , Gamma( *new GENAPI_NAMESPACE::CFloatRef() ) + , DigitalShift( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SubstrateVoltage( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SensorBitDepth( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SensorDigitizationTaps( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelCoding( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelSize( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelColorFilter( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ProcessedRawEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , PixelDynamicRangeMin( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PixelDynamicRangeMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SpatialCorrection( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SpatialCorrectionAmount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SpatialCorrectionStartingLine( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ReverseX( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ReverseY( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FieldOutputMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TestImageSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SensorWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SensorHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , WidthMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , HeightMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LightSourceSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceWhiteReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , BalanceWhiteAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceRatioSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceRatioAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , BalanceRatioRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorTransformationSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorTransformationValueSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorTransformationValue( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorTransformationValueRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorTransformationMatrixFactor( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorTransformationMatrixFactorRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorAdjustmentEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ColorAdjustmentReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , ColorAdjustmentSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorAdjustmentHue( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorAdjustmentHueRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorAdjustmentSaturation( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorAdjustmentSaturationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Width( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Height( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , CenterX( *new GENAPI_NAMESPACE::CBooleanRef() ) + , CenterY( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LegacyBinningVertical( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningModeHorizontal( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningHorizontal( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BinningModeVertical( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningVertical( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DecimationHorizontal( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DecimationVertical( *new GENAPI_NAMESPACE::CIntegerRef() ) + , StackedZoneImagingEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , StackedZoneImagingIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , StackedZoneImagingZoneEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , StackedZoneImagingZoneOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , StackedZoneImagingZoneHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EnableBurstAcquisition( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AcquisitionMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionStart( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionStop( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionAbort( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionFrameCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TriggerControlImplementation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerSoftware( *new GENAPI_NAMESPACE::CCommandRef() ) + , TriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerPartialClosingFrame( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TriggerDelaySource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TriggerDelayLineTriggerCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExposureStartDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureStartDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExposureMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , InterlacedIntegrationMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureTimeAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureTimeBaseAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureTimeBaseAbsEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ExposureTimeRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ReadoutTimeAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureOverlapTimeMaxAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureOverlapTimeMaxRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GlobalResetReleaseModeEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ShutterMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionLineRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingLinePeriodAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingLineRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionFrameRateEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AcquisitionFrameRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionFrameRateEnum( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ResultingFramePeriodAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingFrameRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionStatusSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FrameTimeoutEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FrameTimeoutAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineLogic( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineInverter( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineTermination( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineDebouncerTimeAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineDebouncerTimeRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MinOutPulseWidthRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MinOutPulseWidthAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserOutputSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserOutputValue( *new GENAPI_NAMESPACE::CBooleanRef() ) + , UserOutputValueAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserOutputValueAllMask( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SyncUserOutputSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SyncUserOutputValue( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SyncUserOutputValueAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VInpSignalSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , VInpBitLength( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VInpSamplingPoint( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VInpSignalReadoutActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleLineSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleLineSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleCounterMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShaftEncoderModuleCounterMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShaftEncoderModuleCounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , ShaftEncoderModuleReverseCounterMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShaftEncoderModuleReverseCounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , FrequencyConverterInputSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FrequencyConverterSignalAlignment( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FrequencyConverterPreDivider( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrequencyConverterMultiplier( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrequencyConverterPostDivider( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrequencyConverterPreventOvertrigger( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerDelayTimebaseAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDurationTimebaseAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerDurationAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDurationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerTriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerTriggerActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterEventSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterResetSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , TimerSequenceEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerSequenceLastEntryIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerSequenceCurrentEntryIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerSequenceEntrySelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerSequenceTimerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerSequenceTimerEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerSequenceTimerInverter( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerSequenceTimerDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerSequenceTimerDurationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LUTEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LUTIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTValueAll( *new GENAPI_NAMESPACE::CRegisterRef() ) + , ClTapGeometry( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClConfiguration( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClTimeSlots( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClSerialPortBaudRate( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClPixelClock( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClPixelClockAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ClInterLineDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ClInterLineDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TLParamsLocked( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceRegistersStreamingStart( *new GENAPI_NAMESPACE::CCommandRef() ) + , DeviceRegistersStreamingEnd( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserSetLoad( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetSave( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetDefaultSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DefaultSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTargetValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GrayValueAdjustmentDampingAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , GrayValueAdjustmentDampingRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BalanceWhiteAdjustmentDampingAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , BalanceWhiteAdjustmentDampingRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoGainRawLowerLimit( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoGainRawUpperLimit( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoExposureTimeAbsLowerLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoExposureTimeAbsUpperLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoFunctionProfile( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoFunctionAOISelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoFunctionAOIWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIUsageIntensity( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionAOIUsageWhiteBalance( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionAOIUsageRedLightCorrection( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ColorOverexposureCompensationAOISelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorOverexposureCompensationAOIEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ColorOverexposureCompensationAOIFactor( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorOverexposureCompensationAOIFactorRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShadingSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ShadingStatus( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingSetDefaultSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingSetActivate( *new GENAPI_NAMESPACE::CCommandRef() ) + , ShadingSetCreate( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserDefinedValueSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserDefinedValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GenicamXmlFileDefault( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FeatureSet( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceVendorName( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceModelName( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceManufacturerInfo( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceVersion( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceID( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceUserID( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceFirmwareVersion( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceScanType( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , TemperatureSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TemperatureAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TemperatureState( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CriticalTemperature( *new GENAPI_NAMESPACE::CBooleanRef() ) + , OverTemperature( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LastError( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClearLastError( *new GENAPI_NAMESPACE::CCommandRef() ) + , ParameterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , RemoveLimits( *new GENAPI_NAMESPACE::CBooleanRef() ) + , Prelines( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExpertFeatureAccessSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExpertFeatureAccessKey( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExpertFeatureEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , N62( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N63( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N67( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N68( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N72( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N73( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N77( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N78( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N82( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N83( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N87( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N88( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N92( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N93( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N97( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N98( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N102( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N103( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N107( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N108( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N112( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N113( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N117( *new GENAPI_NAMESPACE::CIntegerRef() ) + , N118( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOperationSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOpenMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileAccessBuffer( *new GENAPI_NAMESPACE::CRegisterRef() ) + , FileAccessOffset( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileAccessLength( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileOperationStatus( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOperationResult( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileOperationExecute( *new GENAPI_NAMESPACE::CCommandRef() ) + , VolatileRowOffsetEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , VolatileRowOffsetIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VolatileRowOffsetValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VolatileRowOffsetValueAll( *new GENAPI_NAMESPACE::CRegisterRef() ) + , VolatileColumnOffsetEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , VolatileColumnOffsetIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VolatileColumnOffsetValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VolatileColumnOffsetValueAll( *new GENAPI_NAMESPACE::CRegisterRef() ) + + { + } + + inline CCLCameraParams_Params::~CCLCameraParams_Params( void ) + { + delete static_cast (&SequenceEnable); + delete static_cast (&SequenceCurrentSet); + delete static_cast (&SequenceAsyncRestart); + delete static_cast (&SequenceAsyncAdvance); + delete static_cast (&SequenceSetTotalNumber); + delete static_cast (&SequenceSetIndex); + delete static_cast (&SequenceSetStore); + delete static_cast (&SequenceSetLoad); + delete static_cast (&SequenceSetExecutions); + delete static_cast *> (&SequenceAdvanceMode); + delete static_cast *> (&SequenceControlSelector); + delete static_cast *> (&SequenceControlSource); + delete static_cast *> (&SequenceAddressBitSelector); + delete static_cast *> (&SequenceAddressBitSource); + delete static_cast *> (&GainAuto); + delete static_cast *> (&GainSelector); + delete static_cast (&GainRaw); + delete static_cast (&GainAbs); + delete static_cast *> (&BlackLevelSelector); + delete static_cast (&BlackLevelRaw); + delete static_cast (&BlackLevelAbs); + delete static_cast (&GammaEnable); + delete static_cast *> (&GammaSelector); + delete static_cast (&Gamma); + delete static_cast (&DigitalShift); + delete static_cast (&SubstrateVoltage); + delete static_cast *> (&SensorBitDepth); + delete static_cast *> (&SensorDigitizationTaps); + delete static_cast *> (&PixelFormat); + delete static_cast *> (&PixelCoding); + delete static_cast *> (&PixelSize); + delete static_cast *> (&PixelColorFilter); + delete static_cast (&ProcessedRawEnable); + delete static_cast (&PixelDynamicRangeMin); + delete static_cast (&PixelDynamicRangeMax); + delete static_cast (&SpatialCorrection); + delete static_cast (&SpatialCorrectionAmount); + delete static_cast *> (&SpatialCorrectionStartingLine); + delete static_cast (&ReverseX); + delete static_cast (&ReverseY); + delete static_cast *> (&FieldOutputMode); + delete static_cast *> (&TestImageSelector); + delete static_cast (&SensorWidth); + delete static_cast (&SensorHeight); + delete static_cast (&WidthMax); + delete static_cast (&HeightMax); + delete static_cast *> (&LightSourceSelector); + delete static_cast (&BalanceWhiteReset); + delete static_cast *> (&BalanceWhiteAuto); + delete static_cast *> (&BalanceRatioSelector); + delete static_cast (&BalanceRatioAbs); + delete static_cast (&BalanceRatioRaw); + delete static_cast *> (&ColorTransformationSelector); + delete static_cast *> (&ColorTransformationValueSelector); + delete static_cast (&ColorTransformationValue); + delete static_cast (&ColorTransformationValueRaw); + delete static_cast (&ColorTransformationMatrixFactor); + delete static_cast (&ColorTransformationMatrixFactorRaw); + delete static_cast (&ColorAdjustmentEnable); + delete static_cast (&ColorAdjustmentReset); + delete static_cast *> (&ColorAdjustmentSelector); + delete static_cast (&ColorAdjustmentHue); + delete static_cast (&ColorAdjustmentHueRaw); + delete static_cast (&ColorAdjustmentSaturation); + delete static_cast (&ColorAdjustmentSaturationRaw); + delete static_cast (&Width); + delete static_cast (&Height); + delete static_cast (&OffsetX); + delete static_cast (&OffsetY); + delete static_cast (&CenterX); + delete static_cast (&CenterY); + delete static_cast *> (&LegacyBinningVertical); + delete static_cast *> (&BinningModeHorizontal); + delete static_cast (&BinningHorizontal); + delete static_cast *> (&BinningModeVertical); + delete static_cast (&BinningVertical); + delete static_cast (&DecimationHorizontal); + delete static_cast (&DecimationVertical); + delete static_cast (&StackedZoneImagingEnable); + delete static_cast (&StackedZoneImagingIndex); + delete static_cast (&StackedZoneImagingZoneEnable); + delete static_cast (&StackedZoneImagingZoneOffsetY); + delete static_cast (&StackedZoneImagingZoneHeight); + delete static_cast (&EnableBurstAcquisition); + delete static_cast *> (&AcquisitionMode); + delete static_cast (&AcquisitionStart); + delete static_cast (&AcquisitionStop); + delete static_cast (&AcquisitionAbort); + delete static_cast (&AcquisitionFrameCount); + delete static_cast *> (&TriggerControlImplementation); + delete static_cast *> (&TriggerSelector); + delete static_cast *> (&TriggerMode); + delete static_cast (&TriggerSoftware); + delete static_cast *> (&TriggerSource); + delete static_cast *> (&TriggerActivation); + delete static_cast (&TriggerPartialClosingFrame); + delete static_cast *> (&TriggerDelaySource); + delete static_cast (&TriggerDelayAbs); + delete static_cast (&TriggerDelayLineTriggerCount); + delete static_cast (&ExposureStartDelayAbs); + delete static_cast (&ExposureStartDelayRaw); + delete static_cast *> (&ExposureMode); + delete static_cast *> (&InterlacedIntegrationMode); + delete static_cast *> (&ExposureAuto); + delete static_cast (&ExposureTimeAbs); + delete static_cast (&ExposureTimeBaseAbs); + delete static_cast (&ExposureTimeBaseAbsEnable); + delete static_cast (&ExposureTimeRaw); + delete static_cast (&ReadoutTimeAbs); + delete static_cast (&ExposureOverlapTimeMaxAbs); + delete static_cast (&ExposureOverlapTimeMaxRaw); + delete static_cast (&GlobalResetReleaseModeEnable); + delete static_cast *> (&ShutterMode); + delete static_cast (&AcquisitionLineRateAbs); + delete static_cast (&ResultingLinePeriodAbs); + delete static_cast (&ResultingLineRateAbs); + delete static_cast (&AcquisitionFrameRateEnable); + delete static_cast (&AcquisitionFrameRateAbs); + delete static_cast *> (&AcquisitionFrameRateEnum); + delete static_cast (&ResultingFramePeriodAbs); + delete static_cast (&ResultingFrameRateAbs); + delete static_cast *> (&AcquisitionStatusSelector); + delete static_cast (&AcquisitionStatus); + delete static_cast (&FrameTimeoutEnable); + delete static_cast (&FrameTimeoutAbs); + delete static_cast *> (&LineSelector); + delete static_cast *> (&LineMode); + delete static_cast *> (&LineLogic); + delete static_cast *> (&LineFormat); + delete static_cast *> (&LineSource); + delete static_cast (&LineInverter); + delete static_cast (&LineTermination); + delete static_cast (&LineDebouncerTimeAbs); + delete static_cast (&LineDebouncerTimeRaw); + delete static_cast (&MinOutPulseWidthRaw); + delete static_cast (&MinOutPulseWidthAbs); + delete static_cast (&LineStatus); + delete static_cast (&LineStatusAll); + delete static_cast *> (&UserOutputSelector); + delete static_cast (&UserOutputValue); + delete static_cast (&UserOutputValueAll); + delete static_cast (&UserOutputValueAllMask); + delete static_cast *> (&SyncUserOutputSelector); + delete static_cast (&SyncUserOutputValue); + delete static_cast (&SyncUserOutputValueAll); + delete static_cast *> (&VInpSignalSource); + delete static_cast (&VInpBitLength); + delete static_cast (&VInpSamplingPoint); + delete static_cast *> (&VInpSignalReadoutActivation); + delete static_cast *> (&ShaftEncoderModuleLineSelector); + delete static_cast *> (&ShaftEncoderModuleLineSource); + delete static_cast *> (&ShaftEncoderModuleMode); + delete static_cast *> (&ShaftEncoderModuleCounterMode); + delete static_cast (&ShaftEncoderModuleCounter); + delete static_cast (&ShaftEncoderModuleCounterMax); + delete static_cast (&ShaftEncoderModuleCounterReset); + delete static_cast (&ShaftEncoderModuleReverseCounterMax); + delete static_cast (&ShaftEncoderModuleReverseCounterReset); + delete static_cast *> (&FrequencyConverterInputSource); + delete static_cast *> (&FrequencyConverterSignalAlignment); + delete static_cast (&FrequencyConverterPreDivider); + delete static_cast (&FrequencyConverterMultiplier); + delete static_cast (&FrequencyConverterPostDivider); + delete static_cast (&FrequencyConverterPreventOvertrigger); + delete static_cast (&TimerDelayTimebaseAbs); + delete static_cast (&TimerDurationTimebaseAbs); + delete static_cast *> (&TimerSelector); + delete static_cast (&TimerDelayAbs); + delete static_cast (&TimerDelayRaw); + delete static_cast (&TimerDurationAbs); + delete static_cast (&TimerDurationRaw); + delete static_cast *> (&TimerTriggerSource); + delete static_cast *> (&TimerTriggerActivation); + delete static_cast *> (&CounterSelector); + delete static_cast *> (&CounterEventSource); + delete static_cast *> (&CounterResetSource); + delete static_cast (&CounterReset); + delete static_cast (&TimerSequenceEnable); + delete static_cast (&TimerSequenceLastEntryIndex); + delete static_cast (&TimerSequenceCurrentEntryIndex); + delete static_cast *> (&TimerSequenceEntrySelector); + delete static_cast *> (&TimerSequenceTimerSelector); + delete static_cast (&TimerSequenceTimerEnable); + delete static_cast (&TimerSequenceTimerInverter); + delete static_cast (&TimerSequenceTimerDelayRaw); + delete static_cast (&TimerSequenceTimerDurationRaw); + delete static_cast *> (&LUTSelector); + delete static_cast (&LUTEnable); + delete static_cast (&LUTIndex); + delete static_cast (&LUTValue); + delete static_cast (&LUTValueAll); + delete static_cast *> (&ClTapGeometry); + delete static_cast *> (&ClConfiguration); + delete static_cast *> (&ClTimeSlots); + delete static_cast *> (&ClSerialPortBaudRate); + delete static_cast *> (&ClPixelClock); + delete static_cast (&ClPixelClockAbs); + delete static_cast (&ClInterLineDelayRaw); + delete static_cast (&ClInterLineDelayAbs); + delete static_cast (&TLParamsLocked); + delete static_cast (&DeviceRegistersStreamingStart); + delete static_cast (&DeviceRegistersStreamingEnd); + delete static_cast *> (&UserSetSelector); + delete static_cast (&UserSetLoad); + delete static_cast (&UserSetSave); + delete static_cast *> (&UserSetDefaultSelector); + delete static_cast *> (&DefaultSetSelector); + delete static_cast (&AutoTargetValue); + delete static_cast (&GrayValueAdjustmentDampingAbs); + delete static_cast (&GrayValueAdjustmentDampingRaw); + delete static_cast (&BalanceWhiteAdjustmentDampingAbs); + delete static_cast (&BalanceWhiteAdjustmentDampingRaw); + delete static_cast (&AutoGainRawLowerLimit); + delete static_cast (&AutoGainRawUpperLimit); + delete static_cast (&AutoExposureTimeAbsLowerLimit); + delete static_cast (&AutoExposureTimeAbsUpperLimit); + delete static_cast *> (&AutoFunctionProfile); + delete static_cast *> (&AutoFunctionAOISelector); + delete static_cast (&AutoFunctionAOIWidth); + delete static_cast (&AutoFunctionAOIHeight); + delete static_cast (&AutoFunctionAOIOffsetX); + delete static_cast (&AutoFunctionAOIOffsetY); + delete static_cast (&AutoFunctionAOIUsageIntensity); + delete static_cast (&AutoFunctionAOIUsageWhiteBalance); + delete static_cast (&AutoFunctionAOIUsageRedLightCorrection); + delete static_cast *> (&ColorOverexposureCompensationAOISelector); + delete static_cast (&ColorOverexposureCompensationAOIEnable); + delete static_cast (&ColorOverexposureCompensationAOIFactor); + delete static_cast (&ColorOverexposureCompensationAOIFactorRaw); + delete static_cast (&ColorOverexposureCompensationAOIWidth); + delete static_cast (&ColorOverexposureCompensationAOIHeight); + delete static_cast (&ColorOverexposureCompensationAOIOffsetX); + delete static_cast (&ColorOverexposureCompensationAOIOffsetY); + delete static_cast *> (&ShadingSelector); + delete static_cast (&ShadingEnable); + delete static_cast *> (&ShadingStatus); + delete static_cast *> (&ShadingSetDefaultSelector); + delete static_cast *> (&ShadingSetSelector); + delete static_cast (&ShadingSetActivate); + delete static_cast *> (&ShadingSetCreate); + delete static_cast *> (&UserDefinedValueSelector); + delete static_cast (&UserDefinedValue); + delete static_cast (&GenicamXmlFileDefault); + delete static_cast *> (&FeatureSet); + delete static_cast (&DeviceVendorName); + delete static_cast (&DeviceModelName); + delete static_cast (&DeviceManufacturerInfo); + delete static_cast (&DeviceVersion); + delete static_cast (&DeviceID); + delete static_cast (&DeviceUserID); + delete static_cast (&DeviceFirmwareVersion); + delete static_cast *> (&DeviceScanType); + delete static_cast (&DeviceReset); + delete static_cast *> (&TemperatureSelector); + delete static_cast (&TemperatureAbs); + delete static_cast *> (&TemperatureState); + delete static_cast (&CriticalTemperature); + delete static_cast (&OverTemperature); + delete static_cast *> (&LastError); + delete static_cast (&ClearLastError); + delete static_cast *> (&ParameterSelector); + delete static_cast (&RemoveLimits); + delete static_cast (&Prelines); + delete static_cast *> (&ExpertFeatureAccessSelector); + delete static_cast (&ExpertFeatureAccessKey); + delete static_cast (&ExpertFeatureEnable); + delete static_cast (&N62); + delete static_cast (&N63); + delete static_cast (&N67); + delete static_cast (&N68); + delete static_cast (&N72); + delete static_cast (&N73); + delete static_cast (&N77); + delete static_cast (&N78); + delete static_cast (&N82); + delete static_cast (&N83); + delete static_cast (&N87); + delete static_cast (&N88); + delete static_cast (&N92); + delete static_cast (&N93); + delete static_cast (&N97); + delete static_cast (&N98); + delete static_cast (&N102); + delete static_cast (&N103); + delete static_cast (&N107); + delete static_cast (&N108); + delete static_cast (&N112); + delete static_cast (&N113); + delete static_cast (&N117); + delete static_cast (&N118); + delete static_cast *> (&FileSelector); + delete static_cast *> (&FileOperationSelector); + delete static_cast *> (&FileOpenMode); + delete static_cast (&FileAccessBuffer); + delete static_cast (&FileAccessOffset); + delete static_cast (&FileAccessLength); + delete static_cast *> (&FileOperationStatus); + delete static_cast (&FileOperationResult); + delete static_cast (&FileSize); + delete static_cast (&FileOperationExecute); + delete static_cast (&VolatileRowOffsetEnable); + delete static_cast (&VolatileRowOffsetIndex); + delete static_cast (&VolatileRowOffsetValue); + delete static_cast (&VolatileRowOffsetValueAll); + delete static_cast (&VolatileColumnOffsetEnable); + delete static_cast (&VolatileColumnOffsetIndex); + delete static_cast (&VolatileColumnOffsetValue); + delete static_cast (&VolatileColumnOffsetValueAll); + + } + + inline void CCLCameraParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&SequenceEnable)->SetReference( _Ptr->GetNode( "SequenceEnable" ) ); + static_cast (&SequenceCurrentSet)->SetReference( _Ptr->GetNode( "SequenceCurrentSet" ) ); + static_cast (&SequenceAsyncRestart)->SetReference( _Ptr->GetNode( "SequenceAsyncRestart" ) ); + static_cast (&SequenceAsyncAdvance)->SetReference( _Ptr->GetNode( "SequenceAsyncAdvance" ) ); + static_cast (&SequenceSetTotalNumber)->SetReference( _Ptr->GetNode( "SequenceSetTotalNumber" ) ); + static_cast (&SequenceSetIndex)->SetReference( _Ptr->GetNode( "SequenceSetIndex" ) ); + static_cast (&SequenceSetStore)->SetReference( _Ptr->GetNode( "SequenceSetStore" ) ); + static_cast (&SequenceSetLoad)->SetReference( _Ptr->GetNode( "SequenceSetLoad" ) ); + static_cast (&SequenceSetExecutions)->SetReference( _Ptr->GetNode( "SequenceSetExecutions" ) ); + static_cast*> (&SequenceAdvanceMode)->SetReference( _Ptr->GetNode( "SequenceAdvanceMode" ) ); + static_cast*> (&SequenceAdvanceMode)->SetNumEnums( 3 ); + static_cast*> (&SequenceAdvanceMode)->SetEnumReference( SequenceAdvanceMode_Auto, "Auto" ); static_cast*> (&SequenceAdvanceMode)->SetEnumReference( SequenceAdvanceMode_Controlled, "Controlled" ); static_cast*> (&SequenceAdvanceMode)->SetEnumReference( SequenceAdvanceMode_FreeSelection, "FreeSelection" ); static_cast*> (&SequenceControlSelector)->SetReference( _Ptr->GetNode( "SequenceControlSelector" ) ); + static_cast*> (&SequenceControlSelector)->SetNumEnums( 2 ); + static_cast*> (&SequenceControlSelector)->SetEnumReference( SequenceControlSelector_Restart, "Restart" ); static_cast*> (&SequenceControlSelector)->SetEnumReference( SequenceControlSelector_Advance, "Advance" ); static_cast*> (&SequenceControlSource)->SetReference( _Ptr->GetNode( "SequenceControlSource" ) ); + static_cast*> (&SequenceControlSource)->SetNumEnums( 19 ); + static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Disabled, "Disabled" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_AlwaysActive, "AlwaysActive" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line1, "Line1" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line2, "Line2" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line3, "Line3" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line4, "Line4" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line5, "Line5" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line6, "Line6" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line7, "Line7" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line8, "Line8" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC1, "CC1" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC2, "CC2" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC3, "CC3" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC4, "CC4" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput1, "VInput1" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput2, "VInput2" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput3, "VInput3" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput4, "VInput4" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInputDecActive, "VInputDecActive" ); static_cast*> (&SequenceAddressBitSelector)->SetReference( _Ptr->GetNode( "SequenceAddressBitSelector" ) ); + static_cast*> (&SequenceAddressBitSelector)->SetNumEnums( 4 ); + static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit0, "Bit0" ); static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit1, "Bit1" ); static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit2, "Bit2" ); static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit3, "Bit3" ); static_cast*> (&SequenceAddressBitSource)->SetReference( _Ptr->GetNode( "SequenceAddressBitSource" ) ); + static_cast*> (&SequenceAddressBitSource)->SetNumEnums( 17 ); + static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line1, "Line1" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line2, "Line2" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line3, "Line3" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line4, "Line4" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line5, "Line5" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line6, "Line6" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line7, "Line7" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line8, "Line8" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC1, "CC1" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC2, "CC2" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC3, "CC3" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC4, "CC4" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput1, "VInput1" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput2, "VInput2" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput3, "VInput3" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput4, "VInput4" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInputDecActive, "VInputDecActive" ); static_cast*> (&GainAuto)->SetReference( _Ptr->GetNode( "GainAuto" ) ); + static_cast*> (&GainAuto)->SetNumEnums( 3 ); + static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Off, "Off" ); static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Once, "Once" ); static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Continuous, "Continuous" ); static_cast*> (&GainSelector)->SetReference( _Ptr->GetNode( "GainSelector" ) ); + static_cast*> (&GainSelector)->SetNumEnums( 10 ); + static_cast*> (&GainSelector)->SetEnumReference( GainSelector_All, "All" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_AnalogAll, "AnalogAll" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_DigitalAll, "DigitalAll" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap1, "Tap1" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap2, "Tap2" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap3, "Tap3" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap4, "Tap4" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Red, "Red" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Green, "Green" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Blue, "Blue" ); static_cast (&GainRaw)->SetReference( _Ptr->GetNode( "GainRaw" ) ); + static_cast (&GainAbs)->SetReference( _Ptr->GetNode( "GainAbs" ) ); + static_cast*> (&BlackLevelSelector)->SetReference( _Ptr->GetNode( "BlackLevelSelector" ) ); + static_cast*> (&BlackLevelSelector)->SetNumEnums( 10 ); + static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_All, "All" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_AnalogAll, "AnalogAll" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_DigitalAll, "DigitalAll" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap1, "Tap1" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap2, "Tap2" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap3, "Tap3" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap4, "Tap4" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Red, "Red" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Green, "Green" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Blue, "Blue" ); static_cast (&BlackLevelRaw)->SetReference( _Ptr->GetNode( "BlackLevelRaw" ) ); + static_cast (&BlackLevelAbs)->SetReference( _Ptr->GetNode( "BlackLevelAbs" ) ); + static_cast (&GammaEnable)->SetReference( _Ptr->GetNode( "GammaEnable" ) ); + static_cast*> (&GammaSelector)->SetReference( _Ptr->GetNode( "GammaSelector" ) ); + static_cast*> (&GammaSelector)->SetNumEnums( 2 ); + static_cast*> (&GammaSelector)->SetEnumReference( GammaSelector_User, "User" ); static_cast*> (&GammaSelector)->SetEnumReference( GammaSelector_sRGB, "sRGB" ); static_cast (&Gamma)->SetReference( _Ptr->GetNode( "Gamma" ) ); + static_cast (&DigitalShift)->SetReference( _Ptr->GetNode( "DigitalShift" ) ); + static_cast (&SubstrateVoltage)->SetReference( _Ptr->GetNode( "SubstrateVoltage" ) ); + static_cast*> (&SensorBitDepth)->SetReference( _Ptr->GetNode( "SensorBitDepth" ) ); + static_cast*> (&SensorBitDepth)->SetNumEnums( 5 ); + static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth8, "BitDepth8" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth10, "BitDepth10" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth12, "BitDepth12" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth14, "BitDepth14" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth16, "BitDepth16" ); static_cast*> (&SensorDigitizationTaps)->SetReference( _Ptr->GetNode( "SensorDigitizationTaps" ) ); + static_cast*> (&SensorDigitizationTaps)->SetNumEnums( 4 ); + static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_One, "One" ); static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_Two, "Two" ); static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_Three, "Three" ); static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_Four, "Four" ); static_cast*> (&PixelFormat)->SetReference( _Ptr->GetNode( "PixelFormat" ) ); + static_cast*> (&PixelFormat)->SetNumEnums( 46 ); + static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono8, "Mono8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10, "Mono10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10Packed, "Mono10Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono12, "Mono12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono12Packed, "Mono12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono16, "Mono16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR8, "BayerGR8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG8, "BayerRG8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB8, "BayerGB8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG8, "BayerBG8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR10, "BayerGR10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG10, "BayerRG10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB10, "BayerGB10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG10, "BayerBG10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR12, "BayerGR12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG12, "BayerRG12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB12, "BayerGB12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG12, "BayerBG12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB8Packed, "RGB8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR8Packed, "BGR8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGBA8Packed, "RGBA8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGRA8Packed, "BGRA8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10Packed, "RGB10Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR10Packed, "BGR10Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB12Packed, "RGB12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR12Packed, "BGR12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10V1Packed, "RGB10V1Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10V2Packed, "RGB10V2Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV411Packed, "YUV411Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV422Packed, "YUV422Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV444Packed, "YUV444Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB8Planar, "RGB8Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10Planar, "RGB10Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB12Planar, "RGB12Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB16Planar, "RGB16Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV422_YUYV_Packed, "YUV422_YUYV_Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB12Packed, "BayerGB12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR12Packed, "BayerGR12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG12Packed, "BayerRG12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG12Packed, "BayerBG12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR16, "BayerGR16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG16, "BayerRG16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB16, "BayerGB16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG16, "BayerBG16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB12V1Packed, "RGB12V1Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono8Signed, "Mono8Signed" ); static_cast*> (&PixelCoding)->SetReference( _Ptr->GetNode( "PixelCoding" ) ); + static_cast*> (&PixelCoding)->SetNumEnums( 20 ); + static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono8, "Mono8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono8Signed, "Mono8Signed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono16, "Mono16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono10Packed, "Mono10Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono12Packed, "Mono12Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Raw8, "Raw8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Raw16, "Raw16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB8, "RGB8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BGR8, "BGR8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGBA8, "RGBA8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BGRA8, "BGRA8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB16, "RGB16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BGR16, "BGR16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB10V1Packed, "RGB10V1Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB10V2Packed, "RGB10V2Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_YUV411, "YUV411" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_YUV422, "YUV422" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_YUV444, "YUV444" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB8Planar, "RGB8Planar" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB16Planar, "RGB16Planar" ); static_cast*> (&PixelSize)->SetReference( _Ptr->GetNode( "PixelSize" ) ); + static_cast*> (&PixelSize)->SetNumEnums( 13 ); + static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp1, "Bpp1" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp2, "Bpp2" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp4, "Bpp4" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp8, "Bpp8" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp10, "Bpp10" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp12, "Bpp12" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp14, "Bpp14" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp16, "Bpp16" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp24, "Bpp24" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp32, "Bpp32" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp36, "Bpp36" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp48, "Bpp48" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp64, "Bpp64" ); static_cast*> (&PixelColorFilter)->SetReference( _Ptr->GetNode( "PixelColorFilter" ) ); + static_cast*> (&PixelColorFilter)->SetNumEnums( 5 ); + static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_RG, "Bayer_RG" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_GB, "Bayer_GB" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_GR, "Bayer_GR" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_BG, "Bayer_BG" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_None, "None" ); static_cast (&ProcessedRawEnable)->SetReference( _Ptr->GetNode( "ProcessedRawEnable" ) ); + static_cast (&PixelDynamicRangeMin)->SetReference( _Ptr->GetNode( "PixelDynamicRangeMin" ) ); + static_cast (&PixelDynamicRangeMax)->SetReference( _Ptr->GetNode( "PixelDynamicRangeMax" ) ); + static_cast (&SpatialCorrection)->SetReference( _Ptr->GetNode( "SpatialCorrection" ) ); + static_cast (&SpatialCorrectionAmount)->SetReference( _Ptr->GetNode( "SpatialCorrectionAmount" ) ); + static_cast*> (&SpatialCorrectionStartingLine)->SetReference( _Ptr->GetNode( "SpatialCorrectionStartingLine" ) ); + static_cast*> (&SpatialCorrectionStartingLine)->SetNumEnums( 3 ); + static_cast*> (&SpatialCorrectionStartingLine)->SetEnumReference( SpatialCorrectionStartingLine_LineRed, "LineRed" ); static_cast*> (&SpatialCorrectionStartingLine)->SetEnumReference( SpatialCorrectionStartingLine_LineGreen, "LineGreen" ); static_cast*> (&SpatialCorrectionStartingLine)->SetEnumReference( SpatialCorrectionStartingLine_LineBlue, "LineBlue" ); static_cast (&ReverseX)->SetReference( _Ptr->GetNode( "ReverseX" ) ); + static_cast (&ReverseY)->SetReference( _Ptr->GetNode( "ReverseY" ) ); + static_cast*> (&FieldOutputMode)->SetReference( _Ptr->GetNode( "FieldOutputMode" ) ); + static_cast*> (&FieldOutputMode)->SetNumEnums( 5 ); + static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_Field0, "Field0" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_Field1, "Field1" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_Field0First, "Field0First" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_ConcatenatedNewFields, "ConcatenatedNewFields" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_DeinterlacedNewFields, "DeinterlacedNewFields" ); static_cast*> (&TestImageSelector)->SetReference( _Ptr->GetNode( "TestImageSelector" ) ); + static_cast*> (&TestImageSelector)->SetNumEnums( 25 ); + static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Off, "Off" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Black, "Black" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_White, "White" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyHorizontalRamp, "GreyHorizontalRamp" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyVerticalRamp, "GreyVerticalRamp" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyHorizontalRampMoving, "GreyHorizontalRampMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyVerticalRampMoving, "GreyVerticalRampMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_HorzontalLineMoving, "HorzontalLineMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_VerticalLineMoving, "VerticalLineMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_ColorBar, "ColorBar" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_FrameCounter, "FrameCounter" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_DeviceSpecific, "DeviceSpecific" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_FixedDiagonalGrayGradient_8Bit, "FixedDiagonalGrayGradient_8Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradient_8Bit, "MovingDiagonalGrayGradient_8Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradient_12Bit, "MovingDiagonalGrayGradient_12Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradientFeatureTest_8Bit, "MovingDiagonalGrayGradientFeatureTest_8Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradientFeatureTest_12Bit, "MovingDiagonalGrayGradientFeatureTest_12Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalColorGradient, "MovingDiagonalColorGradient" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage1, "Testimage1" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage2, "Testimage2" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage3, "Testimage3" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage4, "Testimage4" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage5, "Testimage5" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage6, "Testimage6" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage7, "Testimage7" ); static_cast (&SensorWidth)->SetReference( _Ptr->GetNode( "SensorWidth" ) ); + static_cast (&SensorHeight)->SetReference( _Ptr->GetNode( "SensorHeight" ) ); + static_cast (&WidthMax)->SetReference( _Ptr->GetNode( "WidthMax" ) ); + static_cast (&HeightMax)->SetReference( _Ptr->GetNode( "HeightMax" ) ); + static_cast*> (&LightSourceSelector)->SetReference( _Ptr->GetNode( "LightSourceSelector" ) ); + static_cast*> (&LightSourceSelector)->SetNumEnums( 7 ); + static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Off, "Off" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Custom, "Custom" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Daylight, "Daylight" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Tungsten, "Tungsten" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Daylight6500K, "Daylight6500K" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_LightSource0, "LightSource0" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_LightSource1, "LightSource1" ); static_cast (&BalanceWhiteReset)->SetReference( _Ptr->GetNode( "BalanceWhiteReset" ) ); + static_cast*> (&BalanceWhiteAuto)->SetReference( _Ptr->GetNode( "BalanceWhiteAuto" ) ); + static_cast*> (&BalanceWhiteAuto)->SetNumEnums( 3 ); + static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Off, "Off" ); static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Once, "Once" ); static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Continuous, "Continuous" ); static_cast*> (&BalanceRatioSelector)->SetReference( _Ptr->GetNode( "BalanceRatioSelector" ) ); + static_cast*> (&BalanceRatioSelector)->SetNumEnums( 3 ); + static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Red, "Red" ); static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Green, "Green" ); static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Blue, "Blue" ); static_cast (&BalanceRatioAbs)->SetReference( _Ptr->GetNode( "BalanceRatioAbs" ) ); + static_cast (&BalanceRatioRaw)->SetReference( _Ptr->GetNode( "BalanceRatioRaw" ) ); + static_cast*> (&ColorTransformationSelector)->SetReference( _Ptr->GetNode( "ColorTransformationSelector" ) ); + static_cast*> (&ColorTransformationSelector)->SetNumEnums( 3 ); + static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_RGBtoRGB, "RGBtoRGB" ); static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_RGBtoYUV, "RGBtoYUV" ); static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_YUVtoRGB, "YUVtoRGB" ); static_cast*> (&ColorTransformationValueSelector)->SetReference( _Ptr->GetNode( "ColorTransformationValueSelector" ) ); + static_cast*> (&ColorTransformationValueSelector)->SetNumEnums( 9 ); + static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain00, "Gain00" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain01, "Gain01" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain02, "Gain02" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain10, "Gain10" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain11, "Gain11" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain12, "Gain12" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain20, "Gain20" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain21, "Gain21" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain22, "Gain22" ); static_cast (&ColorTransformationValue)->SetReference( _Ptr->GetNode( "ColorTransformationValue" ) ); + static_cast (&ColorTransformationValueRaw)->SetReference( _Ptr->GetNode( "ColorTransformationValueRaw" ) ); + static_cast (&ColorTransformationMatrixFactor)->SetReference( _Ptr->GetNode( "ColorTransformationMatrixFactor" ) ); + static_cast (&ColorTransformationMatrixFactorRaw)->SetReference( _Ptr->GetNode( "ColorTransformationMatrixFactorRaw" ) ); + static_cast (&ColorAdjustmentEnable)->SetReference( _Ptr->GetNode( "ColorAdjustmentEnable" ) ); + static_cast (&ColorAdjustmentReset)->SetReference( _Ptr->GetNode( "ColorAdjustmentReset" ) ); + static_cast*> (&ColorAdjustmentSelector)->SetReference( _Ptr->GetNode( "ColorAdjustmentSelector" ) ); + static_cast*> (&ColorAdjustmentSelector)->SetNumEnums( 6 ); + static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Red, "Red" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Yellow, "Yellow" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Green, "Green" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Cyan, "Cyan" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Blue, "Blue" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Magenta, "Magenta" ); static_cast (&ColorAdjustmentHue)->SetReference( _Ptr->GetNode( "ColorAdjustmentHue" ) ); + static_cast (&ColorAdjustmentHueRaw)->SetReference( _Ptr->GetNode( "ColorAdjustmentHueRaw" ) ); + static_cast (&ColorAdjustmentSaturation)->SetReference( _Ptr->GetNode( "ColorAdjustmentSaturation" ) ); + static_cast (&ColorAdjustmentSaturationRaw)->SetReference( _Ptr->GetNode( "ColorAdjustmentSaturationRaw" ) ); + static_cast (&Width)->SetReference( _Ptr->GetNode( "Width" ) ); + static_cast (&Height)->SetReference( _Ptr->GetNode( "Height" ) ); + static_cast (&OffsetX)->SetReference( _Ptr->GetNode( "OffsetX" ) ); + static_cast (&OffsetY)->SetReference( _Ptr->GetNode( "OffsetY" ) ); + static_cast (&CenterX)->SetReference( _Ptr->GetNode( "CenterX" ) ); + static_cast (&CenterY)->SetReference( _Ptr->GetNode( "CenterY" ) ); + static_cast*> (&LegacyBinningVertical)->SetReference( _Ptr->GetNode( "LegacyBinningVertical" ) ); + static_cast*> (&LegacyBinningVertical)->SetNumEnums( 2 ); + static_cast*> (&LegacyBinningVertical)->SetEnumReference( LegacyBinningVertical_Off, "Off" ); static_cast*> (&LegacyBinningVertical)->SetEnumReference( LegacyBinningVertical_Two_Rows, "Two_Rows" ); static_cast*> (&BinningModeHorizontal)->SetReference( _Ptr->GetNode( "BinningModeHorizontal" ) ); + static_cast*> (&BinningModeHorizontal)->SetNumEnums( 2 ); + static_cast*> (&BinningModeHorizontal)->SetEnumReference( BinningModeHorizontal_Summing, "Summing" ); static_cast*> (&BinningModeHorizontal)->SetEnumReference( BinningModeHorizontal_Averaging, "Averaging" ); static_cast (&BinningHorizontal)->SetReference( _Ptr->GetNode( "BinningHorizontal" ) ); + static_cast*> (&BinningModeVertical)->SetReference( _Ptr->GetNode( "BinningModeVertical" ) ); + static_cast*> (&BinningModeVertical)->SetNumEnums( 2 ); + static_cast*> (&BinningModeVertical)->SetEnumReference( BinningModeVertical_Summing, "Summing" ); static_cast*> (&BinningModeVertical)->SetEnumReference( BinningModeVertical_Averaging, "Averaging" ); static_cast (&BinningVertical)->SetReference( _Ptr->GetNode( "BinningVertical" ) ); + static_cast (&DecimationHorizontal)->SetReference( _Ptr->GetNode( "DecimationHorizontal" ) ); + static_cast (&DecimationVertical)->SetReference( _Ptr->GetNode( "DecimationVertical" ) ); + static_cast (&StackedZoneImagingEnable)->SetReference( _Ptr->GetNode( "StackedZoneImagingEnable" ) ); + static_cast (&StackedZoneImagingIndex)->SetReference( _Ptr->GetNode( "StackedZoneImagingIndex" ) ); + static_cast (&StackedZoneImagingZoneEnable)->SetReference( _Ptr->GetNode( "StackedZoneImagingZoneEnable" ) ); + static_cast (&StackedZoneImagingZoneOffsetY)->SetReference( _Ptr->GetNode( "StackedZoneImagingZoneOffsetY" ) ); + static_cast (&StackedZoneImagingZoneHeight)->SetReference( _Ptr->GetNode( "StackedZoneImagingZoneHeight" ) ); + static_cast (&EnableBurstAcquisition)->SetReference( _Ptr->GetNode( "EnableBurstAcquisition" ) ); + static_cast*> (&AcquisitionMode)->SetReference( _Ptr->GetNode( "AcquisitionMode" ) ); + static_cast*> (&AcquisitionMode)->SetNumEnums( 3 ); + static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_SingleFrame, "SingleFrame" ); static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_MultiFrame, "MultiFrame" ); static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_Continuous, "Continuous" ); static_cast (&AcquisitionStart)->SetReference( _Ptr->GetNode( "AcquisitionStart" ) ); + static_cast (&AcquisitionStop)->SetReference( _Ptr->GetNode( "AcquisitionStop" ) ); + static_cast (&AcquisitionAbort)->SetReference( _Ptr->GetNode( "AcquisitionAbort" ) ); + static_cast (&AcquisitionFrameCount)->SetReference( _Ptr->GetNode( "AcquisitionFrameCount" ) ); + static_cast*> (&TriggerControlImplementation)->SetReference( _Ptr->GetNode( "TriggerControlImplementation" ) ); + static_cast*> (&TriggerControlImplementation)->SetNumEnums( 2 ); + static_cast*> (&TriggerControlImplementation)->SetEnumReference( TriggerControlImplementation_Legacy, "Legacy" ); static_cast*> (&TriggerControlImplementation)->SetEnumReference( TriggerControlImplementation_Standard, "Standard" ); static_cast*> (&TriggerSelector)->SetReference( _Ptr->GetNode( "TriggerSelector" ) ); + static_cast*> (&TriggerSelector)->SetNumEnums( 10 ); + static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_AcquisitionStart, "AcquisitionStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_AcquisitionEnd, "AcquisitionEnd" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_AcquisitionActive, "AcquisitionActive" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameStart, "FrameStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameEnd, "FrameEnd" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameActive, "FrameActive" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_LineStart, "LineStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_ExposureStart, "ExposureStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_ExposureEnd, "ExposureEnd" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_ExposureActive, "ExposureActive" ); static_cast*> (&TriggerMode)->SetReference( _Ptr->GetNode( "TriggerMode" ) ); + static_cast*> (&TriggerMode)->SetNumEnums( 2 ); + static_cast*> (&TriggerMode)->SetEnumReference( TriggerMode_Off, "Off" ); static_cast*> (&TriggerMode)->SetEnumReference( TriggerMode_On, "On" ); static_cast (&TriggerSoftware)->SetReference( _Ptr->GetNode( "TriggerSoftware" ) ); + static_cast*> (&TriggerSource)->SetReference( _Ptr->GetNode( "TriggerSource" ) ); + static_cast*> (&TriggerSource)->SetNumEnums( 30 ); + static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Software, "Software" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line1, "Line1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line2, "Line2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line3, "Line3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line4, "Line4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line5, "Line5" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line6, "Line6" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line7, "Line7" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line8, "Line8" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC1, "CC1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC2, "CC2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC3, "CC3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC4, "CC4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_ShaftEncoderModuleOut, "ShaftEncoderModuleOut" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_FrequencyConverter, "FrequencyConverter" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Timer1Start, "Timer1Start" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Timer1End, "Timer1End" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Counter1Start, "Counter1Start" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Counter1End, "Counter1End" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_UserOutput1, "UserOutput1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_UserOutput2, "UserOutput2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action1, "Action1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action2, "Action2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action3, "Action3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action4, "Action4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput1, "VInput1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput2, "VInput2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput3, "VInput3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput4, "VInput4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInputDecActive, "VInputDecActive" ); static_cast*> (&TriggerActivation)->SetReference( _Ptr->GetNode( "TriggerActivation" ) ); + static_cast*> (&TriggerActivation)->SetNumEnums( 5 ); + static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_RisingEdge, "RisingEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_FallingEdge, "FallingEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_AnyEdge, "AnyEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_LevelHigh, "LevelHigh" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_LevelLow, "LevelLow" ); static_cast (&TriggerPartialClosingFrame)->SetReference( _Ptr->GetNode( "TriggerPartialClosingFrame" ) ); + static_cast*> (&TriggerDelaySource)->SetReference( _Ptr->GetNode( "TriggerDelaySource" ) ); + static_cast*> (&TriggerDelaySource)->SetNumEnums( 2 ); + static_cast*> (&TriggerDelaySource)->SetEnumReference( TriggerDelaySource_Time_us, "Time_us" ); static_cast*> (&TriggerDelaySource)->SetEnumReference( TriggerDelaySource_LineTrigger, "LineTrigger" ); static_cast (&TriggerDelayAbs)->SetReference( _Ptr->GetNode( "TriggerDelayAbs" ) ); + static_cast (&TriggerDelayLineTriggerCount)->SetReference( _Ptr->GetNode( "TriggerDelayLineTriggerCount" ) ); + static_cast (&ExposureStartDelayAbs)->SetReference( _Ptr->GetNode( "ExposureStartDelayAbs" ) ); + static_cast (&ExposureStartDelayRaw)->SetReference( _Ptr->GetNode( "ExposureStartDelayRaw" ) ); + static_cast*> (&ExposureMode)->SetReference( _Ptr->GetNode( "ExposureMode" ) ); + static_cast*> (&ExposureMode)->SetNumEnums( 4 ); + static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_Off, "Off" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_Timed, "Timed" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_TriggerWidth, "TriggerWidth" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_TriggerControlled, "TriggerControlled" ); static_cast*> (&InterlacedIntegrationMode)->SetReference( _Ptr->GetNode( "InterlacedIntegrationMode" ) ); + static_cast*> (&InterlacedIntegrationMode)->SetNumEnums( 2 ); + static_cast*> (&InterlacedIntegrationMode)->SetEnumReference( InterlacedIntegrationMode_FieldIntegration, "FieldIntegration" ); static_cast*> (&InterlacedIntegrationMode)->SetEnumReference( InterlacedIntegrationMode_FrameIntegration, "FrameIntegration" ); static_cast*> (&ExposureAuto)->SetReference( _Ptr->GetNode( "ExposureAuto" ) ); + static_cast*> (&ExposureAuto)->SetNumEnums( 3 ); + static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Off, "Off" ); static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Once, "Once" ); static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Continuous, "Continuous" ); static_cast (&ExposureTimeAbs)->SetReference( _Ptr->GetNode( "ExposureTimeAbs" ) ); + static_cast (&ExposureTimeBaseAbs)->SetReference( _Ptr->GetNode( "ExposureTimeBaseAbs" ) ); + static_cast (&ExposureTimeBaseAbsEnable)->SetReference( _Ptr->GetNode( "ExposureTimeBaseAbsEnable" ) ); + static_cast (&ExposureTimeRaw)->SetReference( _Ptr->GetNode( "ExposureTimeRaw" ) ); + static_cast (&ReadoutTimeAbs)->SetReference( _Ptr->GetNode( "ReadoutTimeAbs" ) ); + static_cast (&ExposureOverlapTimeMaxAbs)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMaxAbs" ) ); + static_cast (&ExposureOverlapTimeMaxRaw)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMaxRaw" ) ); + static_cast (&GlobalResetReleaseModeEnable)->SetReference( _Ptr->GetNode( "GlobalResetReleaseModeEnable" ) ); + static_cast*> (&ShutterMode)->SetReference( _Ptr->GetNode( "ShutterMode" ) ); + static_cast*> (&ShutterMode)->SetNumEnums( 3 ); + static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_Global, "Global" ); static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_Rolling, "Rolling" ); static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_GlobalResetRelease, "GlobalResetRelease" ); static_cast (&AcquisitionLineRateAbs)->SetReference( _Ptr->GetNode( "AcquisitionLineRateAbs" ) ); + static_cast (&ResultingLinePeriodAbs)->SetReference( _Ptr->GetNode( "ResultingLinePeriodAbs" ) ); + static_cast (&ResultingLineRateAbs)->SetReference( _Ptr->GetNode( "ResultingLineRateAbs" ) ); + static_cast (&AcquisitionFrameRateEnable)->SetReference( _Ptr->GetNode( "AcquisitionFrameRateEnable" ) ); + static_cast (&AcquisitionFrameRateAbs)->SetReference( _Ptr->GetNode( "AcquisitionFrameRateAbs" ) ); + static_cast*> (&AcquisitionFrameRateEnum)->SetReference( _Ptr->GetNode( "AcquisitionFrameRateEnum" ) ); + static_cast*> (&AcquisitionFrameRateEnum)->SetNumEnums( 5 ); + static_cast*> (&AcquisitionFrameRateEnum)->SetEnumReference( AcquisitionFrameRateEnum_FrameRate24, "FrameRate24" ); static_cast*> (&AcquisitionFrameRateEnum)->SetEnumReference( AcquisitionFrameRateEnum_FrameRate25, "FrameRate25" ); static_cast*> (&AcquisitionFrameRateEnum)->SetEnumReference( AcquisitionFrameRateEnum_FrameRate30, "FrameRate30" ); static_cast*> (&AcquisitionFrameRateEnum)->SetEnumReference( AcquisitionFrameRateEnum_FrameRate50, "FrameRate50" ); static_cast*> (&AcquisitionFrameRateEnum)->SetEnumReference( AcquisitionFrameRateEnum_FrameRate60, "FrameRate60" ); static_cast (&ResultingFramePeriodAbs)->SetReference( _Ptr->GetNode( "ResultingFramePeriodAbs" ) ); + static_cast (&ResultingFrameRateAbs)->SetReference( _Ptr->GetNode( "ResultingFrameRateAbs" ) ); + static_cast*> (&AcquisitionStatusSelector)->SetReference( _Ptr->GetNode( "AcquisitionStatusSelector" ) ); + static_cast*> (&AcquisitionStatusSelector)->SetNumEnums( 8 ); + static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionTriggerWait, "AcquisitionTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionActive, "AcquisitionActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionTransfer, "AcquisitionTransfer" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameTriggerWait, "FrameTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameActive, "FrameActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameTransfer, "FrameTransfer" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_ExposureActive, "ExposureActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_LineTriggerWait, "LineTriggerWait" ); static_cast (&AcquisitionStatus)->SetReference( _Ptr->GetNode( "AcquisitionStatus" ) ); + static_cast (&FrameTimeoutEnable)->SetReference( _Ptr->GetNode( "FrameTimeoutEnable" ) ); + static_cast (&FrameTimeoutAbs)->SetReference( _Ptr->GetNode( "FrameTimeoutAbs" ) ); + static_cast*> (&LineSelector)->SetReference( _Ptr->GetNode( "LineSelector" ) ); + static_cast*> (&LineSelector)->SetNumEnums( 21 ); + static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line1, "Line1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line2, "Line2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line3, "Line3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line4, "Line4" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line5, "Line5" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line6, "Line6" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line7, "Line7" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line8, "Line8" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_CC1, "CC1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_CC2, "CC2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_CC3, "CC3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_CC4, "CC4" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_ClSpare, "ClSpare" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_In1, "In1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_In2, "In2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_In3, "In3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_In4, "In4" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out1, "Out1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out2, "Out2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out3, "Out3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out4, "Out4" ); static_cast*> (&LineMode)->SetReference( _Ptr->GetNode( "LineMode" ) ); + static_cast*> (&LineMode)->SetNumEnums( 2 ); + static_cast*> (&LineMode)->SetEnumReference( LineMode_Input, "Input" ); static_cast*> (&LineMode)->SetEnumReference( LineMode_Output, "Output" ); static_cast*> (&LineLogic)->SetReference( _Ptr->GetNode( "LineLogic" ) ); + static_cast*> (&LineLogic)->SetNumEnums( 2 ); + static_cast*> (&LineLogic)->SetEnumReference( LineLogic_Positive, "Positive" ); static_cast*> (&LineLogic)->SetEnumReference( LineLogic_Negative, "Negative" ); static_cast*> (&LineFormat)->SetReference( _Ptr->GetNode( "LineFormat" ) ); + static_cast*> (&LineFormat)->SetNumEnums( 6 ); + static_cast*> (&LineFormat)->SetEnumReference( LineFormat_NoConnect, "NoConnect" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_TriState, "TriState" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_TTL, "TTL" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_LVDS, "LVDS" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_RS422, "RS422" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_OptoCoupled, "OptoCoupled" ); static_cast*> (&LineSource)->SetReference( _Ptr->GetNode( "LineSource" ) ); + static_cast*> (&LineSource)->SetNumEnums( 27 ); + static_cast*> (&LineSource)->SetEnumReference( LineSource_Off, "Off" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_ExposureActive, "ExposureActive" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrameTriggerWait, "FrameTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_LineTriggerWait, "LineTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer1Active, "Timer1Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer2Active, "Timer2Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer3Active, "Timer3Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer4Active, "Timer4Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_TimerActive, "TimerActive" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput1, "UserOutput1" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput2, "UserOutput2" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput3, "UserOutput3" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput4, "UserOutput4" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput, "UserOutput" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_TriggerReady, "TriggerReady" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SerialTx, "SerialTx" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_AcquisitionTriggerWait, "AcquisitionTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_ShaftEncoderModuleOut, "ShaftEncoderModuleOut" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrequencyConverter, "FrequencyConverter" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator1, "PatternGenerator1" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator2, "PatternGenerator2" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator3, "PatternGenerator3" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator4, "PatternGenerator4" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_AcquisitionTriggerReady, "AcquisitionTriggerReady" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FlashWindow, "FlashWindow" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrameCycle, "FrameCycle" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SyncUserOutput, "SyncUserOutput" ); static_cast (&LineInverter)->SetReference( _Ptr->GetNode( "LineInverter" ) ); + static_cast (&LineTermination)->SetReference( _Ptr->GetNode( "LineTermination" ) ); + static_cast (&LineDebouncerTimeAbs)->SetReference( _Ptr->GetNode( "LineDebouncerTimeAbs" ) ); + static_cast (&LineDebouncerTimeRaw)->SetReference( _Ptr->GetNode( "LineDebouncerTimeRaw" ) ); + static_cast (&MinOutPulseWidthRaw)->SetReference( _Ptr->GetNode( "MinOutPulseWidthRaw" ) ); + static_cast (&MinOutPulseWidthAbs)->SetReference( _Ptr->GetNode( "MinOutPulseWidthAbs" ) ); + static_cast (&LineStatus)->SetReference( _Ptr->GetNode( "LineStatus" ) ); + static_cast (&LineStatusAll)->SetReference( _Ptr->GetNode( "LineStatusAll" ) ); + static_cast*> (&UserOutputSelector)->SetReference( _Ptr->GetNode( "UserOutputSelector" ) ); + static_cast*> (&UserOutputSelector)->SetNumEnums( 17 ); + static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput1, "UserOutput1" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput2, "UserOutput2" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput3, "UserOutput3" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput4, "UserOutput4" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput5, "UserOutput5" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput6, "UserOutput6" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput7, "UserOutput7" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput8, "UserOutput8" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputCC1, "UserOutputCC1" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputCC2, "UserOutputCC2" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputCC3, "UserOutputCC3" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputCC4, "UserOutputCC4" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputLine1, "UserOutputLine1" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputLine2, "UserOutputLine2" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputLine3, "UserOutputLine3" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputLine4, "UserOutputLine4" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutputClSpare, "UserOutputClSpare" ); static_cast (&UserOutputValue)->SetReference( _Ptr->GetNode( "UserOutputValue" ) ); + static_cast (&UserOutputValueAll)->SetReference( _Ptr->GetNode( "UserOutputValueAll" ) ); + static_cast (&UserOutputValueAllMask)->SetReference( _Ptr->GetNode( "UserOutputValueAllMask" ) ); + static_cast*> (&SyncUserOutputSelector)->SetReference( _Ptr->GetNode( "SyncUserOutputSelector" ) ); + static_cast*> (&SyncUserOutputSelector)->SetNumEnums( 17 ); + static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput1, "SyncUserOutput1" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput2, "SyncUserOutput2" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput3, "SyncUserOutput3" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput4, "SyncUserOutput4" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput5, "SyncUserOutput5" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput6, "SyncUserOutput6" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput7, "SyncUserOutput7" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput8, "SyncUserOutput8" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputCC1, "SyncUserOutputCC1" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputCC2, "SyncUserOutputCC2" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputCC3, "SyncUserOutputCC3" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputCC4, "SyncUserOutputCC4" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputLine1, "SyncUserOutputLine1" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputLine2, "SyncUserOutputLine2" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputLine3, "SyncUserOutputLine3" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputLine4, "SyncUserOutputLine4" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutputClSpare, "SyncUserOutputClSpare" ); static_cast (&SyncUserOutputValue)->SetReference( _Ptr->GetNode( "SyncUserOutputValue" ) ); + static_cast (&SyncUserOutputValueAll)->SetReference( _Ptr->GetNode( "SyncUserOutputValueAll" ) ); + static_cast*> (&VInpSignalSource)->SetReference( _Ptr->GetNode( "VInpSignalSource" ) ); + static_cast*> (&VInpSignalSource)->SetNumEnums( 12 ); + static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line1, "Line1" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line2, "Line2" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line3, "Line3" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line4, "Line4" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line5, "Line5" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line6, "Line6" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line7, "Line7" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line8, "Line8" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC1, "CC1" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC2, "CC2" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC3, "CC3" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC4, "CC4" ); static_cast (&VInpBitLength)->SetReference( _Ptr->GetNode( "VInpBitLength" ) ); + static_cast (&VInpSamplingPoint)->SetReference( _Ptr->GetNode( "VInpSamplingPoint" ) ); + static_cast*> (&VInpSignalReadoutActivation)->SetReference( _Ptr->GetNode( "VInpSignalReadoutActivation" ) ); + static_cast*> (&VInpSignalReadoutActivation)->SetNumEnums( 2 ); + static_cast*> (&VInpSignalReadoutActivation)->SetEnumReference( VInpSignalReadoutActivation_RisingEdge, "RisingEdge" ); static_cast*> (&VInpSignalReadoutActivation)->SetEnumReference( VInpSignalReadoutActivation_FallingEdge, "FallingEdge" ); static_cast*> (&ShaftEncoderModuleLineSelector)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleLineSelector" ) ); + static_cast*> (&ShaftEncoderModuleLineSelector)->SetNumEnums( 2 ); + static_cast*> (&ShaftEncoderModuleLineSelector)->SetEnumReference( ShaftEncoderModuleLineSelector_PhaseA, "PhaseA" ); static_cast*> (&ShaftEncoderModuleLineSelector)->SetEnumReference( ShaftEncoderModuleLineSelector_PhaseB, "PhaseB" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleLineSource" ) ); + static_cast*> (&ShaftEncoderModuleLineSource)->SetNumEnums( 12 ); + static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line1, "Line1" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line2, "Line2" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line3, "Line3" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line4, "Line4" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line5, "Line5" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line6, "Line6" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line7, "Line7" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line8, "Line8" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC1, "CC1" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC2, "CC2" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC3, "CC3" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC4, "CC4" ); static_cast*> (&ShaftEncoderModuleMode)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleMode" ) ); + static_cast*> (&ShaftEncoderModuleMode)->SetNumEnums( 2 ); + static_cast*> (&ShaftEncoderModuleMode)->SetEnumReference( ShaftEncoderModuleMode_AnyDirection, "AnyDirection" ); static_cast*> (&ShaftEncoderModuleMode)->SetEnumReference( ShaftEncoderModuleMode_ForwardOnly, "ForwardOnly" ); static_cast*> (&ShaftEncoderModuleCounterMode)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounterMode" ) ); + static_cast*> (&ShaftEncoderModuleCounterMode)->SetNumEnums( 2 ); + static_cast*> (&ShaftEncoderModuleCounterMode)->SetEnumReference( ShaftEncoderModuleCounterMode_FollowDirection, "FollowDirection" ); static_cast*> (&ShaftEncoderModuleCounterMode)->SetEnumReference( ShaftEncoderModuleCounterMode_IgnoreDirection, "IgnoreDirection" ); static_cast (&ShaftEncoderModuleCounter)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounter" ) ); + static_cast (&ShaftEncoderModuleCounterMax)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounterMax" ) ); + static_cast (&ShaftEncoderModuleCounterReset)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounterReset" ) ); + static_cast (&ShaftEncoderModuleReverseCounterMax)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleReverseCounterMax" ) ); + static_cast (&ShaftEncoderModuleReverseCounterReset)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleReverseCounterReset" ) ); + static_cast*> (&FrequencyConverterInputSource)->SetReference( _Ptr->GetNode( "FrequencyConverterInputSource" ) ); + static_cast*> (&FrequencyConverterInputSource)->SetNumEnums( 13 ); + static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line1, "Line1" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line2, "Line2" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line3, "Line3" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line4, "Line4" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line5, "Line5" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line6, "Line6" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line7, "Line7" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line8, "Line8" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC1, "CC1" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC2, "CC2" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC3, "CC3" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC4, "CC4" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_ShaftEncoderModuleOut, "ShaftEncoderModuleOut" ); static_cast*> (&FrequencyConverterSignalAlignment)->SetReference( _Ptr->GetNode( "FrequencyConverterSignalAlignment" ) ); + static_cast*> (&FrequencyConverterSignalAlignment)->SetNumEnums( 2 ); + static_cast*> (&FrequencyConverterSignalAlignment)->SetEnumReference( FrequencyConverterSignalAlignment_RisingEdge, "RisingEdge" ); static_cast*> (&FrequencyConverterSignalAlignment)->SetEnumReference( FrequencyConverterSignalAlignment_FallingEdge, "FallingEdge" ); static_cast (&FrequencyConverterPreDivider)->SetReference( _Ptr->GetNode( "FrequencyConverterPreDivider" ) ); + static_cast (&FrequencyConverterMultiplier)->SetReference( _Ptr->GetNode( "FrequencyConverterMultiplier" ) ); + static_cast (&FrequencyConverterPostDivider)->SetReference( _Ptr->GetNode( "FrequencyConverterPostDivider" ) ); + static_cast (&FrequencyConverterPreventOvertrigger)->SetReference( _Ptr->GetNode( "FrequencyConverterPreventOvertrigger" ) ); + static_cast (&TimerDelayTimebaseAbs)->SetReference( _Ptr->GetNode( "TimerDelayTimebaseAbs" ) ); + static_cast (&TimerDurationTimebaseAbs)->SetReference( _Ptr->GetNode( "TimerDurationTimebaseAbs" ) ); + static_cast*> (&TimerSelector)->SetReference( _Ptr->GetNode( "TimerSelector" ) ); + static_cast*> (&TimerSelector)->SetNumEnums( 4 ); + static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer1, "Timer1" ); static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer2, "Timer2" ); static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer3, "Timer3" ); static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer4, "Timer4" ); static_cast (&TimerDelayAbs)->SetReference( _Ptr->GetNode( "TimerDelayAbs" ) ); + static_cast (&TimerDelayRaw)->SetReference( _Ptr->GetNode( "TimerDelayRaw" ) ); + static_cast (&TimerDurationAbs)->SetReference( _Ptr->GetNode( "TimerDurationAbs" ) ); + static_cast (&TimerDurationRaw)->SetReference( _Ptr->GetNode( "TimerDurationRaw" ) ); + static_cast*> (&TimerTriggerSource)->SetReference( _Ptr->GetNode( "TimerTriggerSource" ) ); + static_cast*> (&TimerTriggerSource)->SetNumEnums( 2 ); + static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_Off, "Off" ); static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_ExposureStart, "ExposureStart" ); static_cast*> (&TimerTriggerActivation)->SetReference( _Ptr->GetNode( "TimerTriggerActivation" ) ); + static_cast*> (&TimerTriggerActivation)->SetNumEnums( 4 ); + static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_RisingEdge, "RisingEdge" ); static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_FallingEdge, "FallingEdge" ); static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_LevelHigh, "LevelHigh" ); static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_LevelLow, "LevelLow" ); static_cast*> (&CounterSelector)->SetReference( _Ptr->GetNode( "CounterSelector" ) ); + static_cast*> (&CounterSelector)->SetNumEnums( 4 ); + static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter1, "Counter1" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter2, "Counter2" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter3, "Counter3" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter4, "Counter4" ); static_cast*> (&CounterEventSource)->SetReference( _Ptr->GetNode( "CounterEventSource" ) ); + static_cast*> (&CounterEventSource)->SetNumEnums( 12 ); + static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_Off, "Off" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_AcquisitionTrigger, "AcquisitionTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_AcquisitionStart, "AcquisitionStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_AcquisitionEnd, "AcquisitionEnd" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameTrigger, "FrameTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameStart, "FrameStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameEnd, "FrameEnd" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_LineTrigger, "LineTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_LineStart, "LineStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_LineEnd, "LineEnd" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_ExposureStart, "ExposureStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_ExposureEnd, "ExposureEnd" ); static_cast*> (&CounterResetSource)->SetReference( _Ptr->GetNode( "CounterResetSource" ) ); + static_cast*> (&CounterResetSource)->SetNumEnums( 19 ); + static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Off, "Off" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Software, "Software" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line1, "Line1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line2, "Line2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line3, "Line3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line4, "Line4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line5, "Line5" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line6, "Line6" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line7, "Line7" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line8, "Line8" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC1, "CC1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC2, "CC2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC3, "CC3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC4, "CC4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput1, "VInput1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput2, "VInput2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput3, "VInput3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput4, "VInput4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInputDecActive, "VInputDecActive" ); static_cast (&CounterReset)->SetReference( _Ptr->GetNode( "CounterReset" ) ); + static_cast (&TimerSequenceEnable)->SetReference( _Ptr->GetNode( "TimerSequenceEnable" ) ); + static_cast (&TimerSequenceLastEntryIndex)->SetReference( _Ptr->GetNode( "TimerSequenceLastEntryIndex" ) ); + static_cast (&TimerSequenceCurrentEntryIndex)->SetReference( _Ptr->GetNode( "TimerSequenceCurrentEntryIndex" ) ); + static_cast*> (&TimerSequenceEntrySelector)->SetReference( _Ptr->GetNode( "TimerSequenceEntrySelector" ) ); + static_cast*> (&TimerSequenceEntrySelector)->SetNumEnums( 16 ); + static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry1, "Entry1" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry2, "Entry2" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry3, "Entry3" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry4, "Entry4" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry5, "Entry5" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry6, "Entry6" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry7, "Entry7" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry8, "Entry8" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry9, "Entry9" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry10, "Entry10" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry11, "Entry11" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry12, "Entry12" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry13, "Entry13" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry14, "Entry14" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry15, "Entry15" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry16, "Entry16" ); static_cast*> (&TimerSequenceTimerSelector)->SetReference( _Ptr->GetNode( "TimerSequenceTimerSelector" ) ); + static_cast*> (&TimerSequenceTimerSelector)->SetNumEnums( 4 ); + static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer1, "Timer1" ); static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer2, "Timer2" ); static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer3, "Timer3" ); static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer4, "Timer4" ); static_cast (&TimerSequenceTimerEnable)->SetReference( _Ptr->GetNode( "TimerSequenceTimerEnable" ) ); + static_cast (&TimerSequenceTimerInverter)->SetReference( _Ptr->GetNode( "TimerSequenceTimerInverter" ) ); + static_cast (&TimerSequenceTimerDelayRaw)->SetReference( _Ptr->GetNode( "TimerSequenceTimerDelayRaw" ) ); + static_cast (&TimerSequenceTimerDurationRaw)->SetReference( _Ptr->GetNode( "TimerSequenceTimerDurationRaw" ) ); + static_cast*> (&LUTSelector)->SetReference( _Ptr->GetNode( "LUTSelector" ) ); + static_cast*> (&LUTSelector)->SetNumEnums( 1 ); + static_cast*> (&LUTSelector)->SetEnumReference( LUTSelector_Luminance, "Luminance" ); static_cast (&LUTEnable)->SetReference( _Ptr->GetNode( "LUTEnable" ) ); + static_cast (&LUTIndex)->SetReference( _Ptr->GetNode( "LUTIndex" ) ); + static_cast (&LUTValue)->SetReference( _Ptr->GetNode( "LUTValue" ) ); + static_cast (&LUTValueAll)->SetReference( _Ptr->GetNode( "LUTValueAll" ) ); + static_cast*> (&ClTapGeometry)->SetReference( _Ptr->GetNode( "ClTapGeometry" ) ); + static_cast*> (&ClTapGeometry)->SetNumEnums( 15 ); + static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X_1Y, "Geometry1X_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X2_1Y, "Geometry1X2_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X_2YE, "Geometry1X_2YE" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X3_1Y, "Geometry1X3_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X4_1Y, "Geometry1X4_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X6_1Y, "Geometry1X6_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X8_1Y, "Geometry1X8_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X10_1Y, "Geometry1X10_1Y" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X, "Geometry1X" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X2, "Geometry1X2" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X3, "Geometry1X3" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X4, "Geometry1X4" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X6, "Geometry1X6" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X8, "Geometry1X8" ); static_cast*> (&ClTapGeometry)->SetEnumReference( ClTapGeometry_Geometry1X10, "Geometry1X10" ); static_cast*> (&ClConfiguration)->SetReference( _Ptr->GetNode( "ClConfiguration" ) ); + static_cast*> (&ClConfiguration)->SetNumEnums( 5 ); + static_cast*> (&ClConfiguration)->SetEnumReference( ClConfiguration_Base, "Base" ); static_cast*> (&ClConfiguration)->SetEnumReference( ClConfiguration_Medium, "Medium" ); static_cast*> (&ClConfiguration)->SetEnumReference( ClConfiguration_Full, "Full" ); static_cast*> (&ClConfiguration)->SetEnumReference( ClConfiguration_DualBase, "DualBase" ); static_cast*> (&ClConfiguration)->SetEnumReference( ClConfiguration_Deca, "Deca" ); static_cast*> (&ClTimeSlots)->SetReference( _Ptr->GetNode( "ClTimeSlots" ) ); + static_cast*> (&ClTimeSlots)->SetNumEnums( 1 ); + static_cast*> (&ClTimeSlots)->SetEnumReference( ClTimeSlots_TimeSlots1, "TimeSlots1" ); static_cast*> (&ClSerialPortBaudRate)->SetReference( _Ptr->GetNode( "ClSerialPortBaudRate" ) ); + static_cast*> (&ClSerialPortBaudRate)->SetNumEnums( 8 ); + static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud9600, "Baud9600" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud19200, "Baud19200" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud38400, "Baud38400" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud57600, "Baud57600" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud115200, "Baud115200" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud230400, "Baud230400" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud460800, "Baud460800" ); static_cast*> (&ClSerialPortBaudRate)->SetEnumReference( ClSerialPortBaudRate_Baud921600, "Baud921600" ); static_cast*> (&ClPixelClock)->SetReference( _Ptr->GetNode( "ClPixelClock" ) ); + static_cast*> (&ClPixelClock)->SetNumEnums( 9 ); + static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock20, "PixelClock20" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock32_5, "PixelClock32_5" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock40, "PixelClock40" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock48, "PixelClock48" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock65, "PixelClock65" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock82, "PixelClock82" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock82_5, "PixelClock82_5" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock83, "PixelClock83" ); static_cast*> (&ClPixelClock)->SetEnumReference( ClPixelClock_PixelClock83_5, "PixelClock83_5" ); static_cast (&ClPixelClockAbs)->SetReference( _Ptr->GetNode( "ClPixelClockAbs" ) ); + static_cast (&ClInterLineDelayRaw)->SetReference( _Ptr->GetNode( "ClInterLineDelayRaw" ) ); + static_cast (&ClInterLineDelayAbs)->SetReference( _Ptr->GetNode( "ClInterLineDelayAbs" ) ); + static_cast (&TLParamsLocked)->SetReference( _Ptr->GetNode( "TLParamsLocked" ) ); + static_cast (&DeviceRegistersStreamingStart)->SetReference( _Ptr->GetNode( "DeviceRegistersStreamingStart" ) ); + static_cast (&DeviceRegistersStreamingEnd)->SetReference( _Ptr->GetNode( "DeviceRegistersStreamingEnd" ) ); + static_cast*> (&UserSetSelector)->SetReference( _Ptr->GetNode( "UserSetSelector" ) ); + static_cast*> (&UserSetSelector)->SetNumEnums( 9 ); + static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Default, "Default" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_HighGain, "HighGain" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Color, "Color" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Custom0, "Custom0" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Custom1, "Custom1" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet1, "UserSet1" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet2, "UserSet2" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet3, "UserSet3" ); static_cast (&UserSetLoad)->SetReference( _Ptr->GetNode( "UserSetLoad" ) ); + static_cast (&UserSetSave)->SetReference( _Ptr->GetNode( "UserSetSave" ) ); + static_cast*> (&UserSetDefaultSelector)->SetReference( _Ptr->GetNode( "UserSetDefaultSelector" ) ); + static_cast*> (&UserSetDefaultSelector)->SetNumEnums( 9 ); + static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Default, "Default" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_HighGain, "HighGain" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Color, "Color" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Custom0, "Custom0" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Custom1, "Custom1" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_UserSet1, "UserSet1" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_UserSet2, "UserSet2" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_UserSet3, "UserSet3" ); static_cast*> (&DefaultSetSelector)->SetReference( _Ptr->GetNode( "DefaultSetSelector" ) ); + static_cast*> (&DefaultSetSelector)->SetNumEnums( 6 ); + static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Standard, "Standard" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_HighGain, "HighGain" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Color, "Color" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Custom0, "Custom0" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Custom1, "Custom1" ); static_cast (&AutoTargetValue)->SetReference( _Ptr->GetNode( "AutoTargetValue" ) ); + static_cast (&GrayValueAdjustmentDampingAbs)->SetReference( _Ptr->GetNode( "GrayValueAdjustmentDampingAbs" ) ); + static_cast (&GrayValueAdjustmentDampingRaw)->SetReference( _Ptr->GetNode( "GrayValueAdjustmentDampingRaw" ) ); + static_cast (&BalanceWhiteAdjustmentDampingAbs)->SetReference( _Ptr->GetNode( "BalanceWhiteAdjustmentDampingAbs" ) ); + static_cast (&BalanceWhiteAdjustmentDampingRaw)->SetReference( _Ptr->GetNode( "BalanceWhiteAdjustmentDampingRaw" ) ); + static_cast (&AutoGainRawLowerLimit)->SetReference( _Ptr->GetNode( "AutoGainRawLowerLimit" ) ); + static_cast (&AutoGainRawUpperLimit)->SetReference( _Ptr->GetNode( "AutoGainRawUpperLimit" ) ); + static_cast (&AutoExposureTimeAbsLowerLimit)->SetReference( _Ptr->GetNode( "AutoExposureTimeAbsLowerLimit" ) ); + static_cast (&AutoExposureTimeAbsUpperLimit)->SetReference( _Ptr->GetNode( "AutoExposureTimeAbsUpperLimit" ) ); + static_cast*> (&AutoFunctionProfile)->SetReference( _Ptr->GetNode( "AutoFunctionProfile" ) ); + static_cast*> (&AutoFunctionProfile)->SetNumEnums( 2 ); + static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_GainMinimum, "GainMinimum" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_ExposureMinimum, "ExposureMinimum" ); static_cast*> (&AutoFunctionAOISelector)->SetReference( _Ptr->GetNode( "AutoFunctionAOISelector" ) ); + static_cast*> (&AutoFunctionAOISelector)->SetNumEnums( 8 ); + static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI1, "AOI1" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI2, "AOI2" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI3, "AOI3" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI4, "AOI4" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI5, "AOI5" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI6, "AOI6" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI7, "AOI7" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI8, "AOI8" ); static_cast (&AutoFunctionAOIWidth)->SetReference( _Ptr->GetNode( "AutoFunctionAOIWidth" ) ); + static_cast (&AutoFunctionAOIHeight)->SetReference( _Ptr->GetNode( "AutoFunctionAOIHeight" ) ); + static_cast (&AutoFunctionAOIOffsetX)->SetReference( _Ptr->GetNode( "AutoFunctionAOIOffsetX" ) ); + static_cast (&AutoFunctionAOIOffsetY)->SetReference( _Ptr->GetNode( "AutoFunctionAOIOffsetY" ) ); + static_cast (&AutoFunctionAOIUsageIntensity)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageIntensity" ) ); + static_cast (&AutoFunctionAOIUsageWhiteBalance)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageWhiteBalance" ) ); + static_cast (&AutoFunctionAOIUsageRedLightCorrection)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageRedLightCorrection" ) ); + static_cast*> (&ColorOverexposureCompensationAOISelector)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOISelector" ) ); + static_cast*> (&ColorOverexposureCompensationAOISelector)->SetNumEnums( 1 ); + static_cast*> (&ColorOverexposureCompensationAOISelector)->SetEnumReference( ColorOverexposureCompensationAOISelector_AOI1, "AOI1" ); static_cast (&ColorOverexposureCompensationAOIEnable)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIEnable" ) ); + static_cast (&ColorOverexposureCompensationAOIFactor)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIFactor" ) ); + static_cast (&ColorOverexposureCompensationAOIFactorRaw)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIFactorRaw" ) ); + static_cast (&ColorOverexposureCompensationAOIWidth)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIWidth" ) ); + static_cast (&ColorOverexposureCompensationAOIHeight)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIHeight" ) ); + static_cast (&ColorOverexposureCompensationAOIOffsetX)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIOffsetX" ) ); + static_cast (&ColorOverexposureCompensationAOIOffsetY)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIOffsetY" ) ); + static_cast*> (&ShadingSelector)->SetReference( _Ptr->GetNode( "ShadingSelector" ) ); + static_cast*> (&ShadingSelector)->SetNumEnums( 2 ); + static_cast*> (&ShadingSelector)->SetEnumReference( ShadingSelector_OffsetShading, "OffsetShading" ); static_cast*> (&ShadingSelector)->SetEnumReference( ShadingSelector_GainShading, "GainShading" ); static_cast (&ShadingEnable)->SetReference( _Ptr->GetNode( "ShadingEnable" ) ); + static_cast*> (&ShadingStatus)->SetReference( _Ptr->GetNode( "ShadingStatus" ) ); + static_cast*> (&ShadingStatus)->SetNumEnums( 4 ); + static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_NoError, "NoError" ); static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_StartupSetError, "StartupSetError" ); static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_ActivateError, "ActivateError" ); static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_CreateError, "CreateError" ); static_cast*> (&ShadingSetDefaultSelector)->SetReference( _Ptr->GetNode( "ShadingSetDefaultSelector" ) ); + static_cast*> (&ShadingSetDefaultSelector)->SetNumEnums( 3 ); + static_cast*> (&ShadingSetDefaultSelector)->SetEnumReference( ShadingSetDefaultSelector_DefaultShadingSet, "DefaultShadingSet" ); static_cast*> (&ShadingSetDefaultSelector)->SetEnumReference( ShadingSetDefaultSelector_UserShadingSet1, "UserShadingSet1" ); static_cast*> (&ShadingSetDefaultSelector)->SetEnumReference( ShadingSetDefaultSelector_UserShadingSet2, "UserShadingSet2" ); static_cast*> (&ShadingSetSelector)->SetReference( _Ptr->GetNode( "ShadingSetSelector" ) ); + static_cast*> (&ShadingSetSelector)->SetNumEnums( 3 ); + static_cast*> (&ShadingSetSelector)->SetEnumReference( ShadingSetSelector_DefaultShadingSet, "DefaultShadingSet" ); static_cast*> (&ShadingSetSelector)->SetEnumReference( ShadingSetSelector_UserShadingSet1, "UserShadingSet1" ); static_cast*> (&ShadingSetSelector)->SetEnumReference( ShadingSetSelector_UserShadingSet2, "UserShadingSet2" ); static_cast (&ShadingSetActivate)->SetReference( _Ptr->GetNode( "ShadingSetActivate" ) ); + static_cast*> (&ShadingSetCreate)->SetReference( _Ptr->GetNode( "ShadingSetCreate" ) ); + static_cast*> (&ShadingSetCreate)->SetNumEnums( 2 ); + static_cast*> (&ShadingSetCreate)->SetEnumReference( ShadingSetCreate_Off, "Off" ); static_cast*> (&ShadingSetCreate)->SetEnumReference( ShadingSetCreate_Once, "Once" ); static_cast*> (&UserDefinedValueSelector)->SetReference( _Ptr->GetNode( "UserDefinedValueSelector" ) ); + static_cast*> (&UserDefinedValueSelector)->SetNumEnums( 5 ); + static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value1, "Value1" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value2, "Value2" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value3, "Value3" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value4, "Value4" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value5, "Value5" ); static_cast (&UserDefinedValue)->SetReference( _Ptr->GetNode( "UserDefinedValue" ) ); + static_cast (&GenicamXmlFileDefault)->SetReference( _Ptr->GetNode( "GenicamXmlFileDefault" ) ); + static_cast*> (&FeatureSet)->SetReference( _Ptr->GetNode( "FeatureSet" ) ); + static_cast*> (&FeatureSet)->SetNumEnums( 2 ); + static_cast*> (&FeatureSet)->SetEnumReference( FeatureSet_Full, "Full" ); static_cast*> (&FeatureSet)->SetEnumReference( FeatureSet_Basic, "Basic" ); static_cast (&DeviceVendorName)->SetReference( _Ptr->GetNode( "DeviceVendorName" ) ); + static_cast (&DeviceModelName)->SetReference( _Ptr->GetNode( "DeviceModelName" ) ); + static_cast (&DeviceManufacturerInfo)->SetReference( _Ptr->GetNode( "DeviceManufacturerInfo" ) ); + static_cast (&DeviceVersion)->SetReference( _Ptr->GetNode( "DeviceVersion" ) ); + static_cast (&DeviceID)->SetReference( _Ptr->GetNode( "DeviceID" ) ); + static_cast (&DeviceUserID)->SetReference( _Ptr->GetNode( "DeviceUserID" ) ); + static_cast (&DeviceFirmwareVersion)->SetReference( _Ptr->GetNode( "DeviceFirmwareVersion" ) ); + static_cast*> (&DeviceScanType)->SetReference( _Ptr->GetNode( "DeviceScanType" ) ); + static_cast*> (&DeviceScanType)->SetNumEnums( 2 ); + static_cast*> (&DeviceScanType)->SetEnumReference( DeviceScanType_Areascan, "Areascan" ); static_cast*> (&DeviceScanType)->SetEnumReference( DeviceScanType_Linescan, "Linescan" ); static_cast (&DeviceReset)->SetReference( _Ptr->GetNode( "DeviceReset" ) ); + static_cast*> (&TemperatureSelector)->SetReference( _Ptr->GetNode( "TemperatureSelector" ) ); + static_cast*> (&TemperatureSelector)->SetNumEnums( 4 ); + static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Sensorboard, "Sensorboard" ); static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Coreboard, "Coreboard" ); static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Framegrabberboard, "Framegrabberboard" ); static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Case, "Case" ); static_cast (&TemperatureAbs)->SetReference( _Ptr->GetNode( "TemperatureAbs" ) ); + static_cast*> (&TemperatureState)->SetReference( _Ptr->GetNode( "TemperatureState" ) ); + static_cast*> (&TemperatureState)->SetNumEnums( 3 ); + static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Ok, "Ok" ); static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Critical, "Critical" ); static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Error, "Error" ); static_cast (&CriticalTemperature)->SetReference( _Ptr->GetNode( "CriticalTemperature" ) ); + static_cast (&OverTemperature)->SetReference( _Ptr->GetNode( "OverTemperature" ) ); + static_cast*> (&LastError)->SetReference( _Ptr->GetNode( "LastError" ) ); + static_cast*> (&LastError)->SetNumEnums( 8 ); + static_cast*> (&LastError)->SetEnumReference( LastError_NoError, "NoError" ); static_cast*> (&LastError)->SetEnumReference( LastError_Overtrigger, "Overtrigger" ); static_cast*> (&LastError)->SetEnumReference( LastError_Userset, "Userset" ); static_cast*> (&LastError)->SetEnumReference( LastError_InvalidParameter, "InvalidParameter" ); static_cast*> (&LastError)->SetEnumReference( LastError_OverTemperature, "OverTemperature" ); static_cast*> (&LastError)->SetEnumReference( LastError_PowerFailure, "PowerFailure" ); static_cast*> (&LastError)->SetEnumReference( LastError_InsufficientTriggerWidth, "InsufficientTriggerWidth" ); static_cast*> (&LastError)->SetEnumReference( LastError_UserDefPixFailure, "UserDefPixFailure" ); static_cast (&ClearLastError)->SetReference( _Ptr->GetNode( "ClearLastError" ) ); + static_cast*> (&ParameterSelector)->SetReference( _Ptr->GetNode( "ParameterSelector" ) ); + static_cast*> (&ParameterSelector)->SetNumEnums( 7 ); + static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_Gain, "Gain" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_Brightness, "Brightness" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_BlackLevel, "BlackLevel" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_ExposureTime, "ExposureTime" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_Framerate, "Framerate" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_AutoTargetValue, "AutoTargetValue" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_ExposureOverhead, "ExposureOverhead" ); static_cast (&RemoveLimits)->SetReference( _Ptr->GetNode( "RemoveLimits" ) ); + static_cast (&Prelines)->SetReference( _Ptr->GetNode( "Prelines" ) ); + static_cast*> (&ExpertFeatureAccessSelector)->SetReference( _Ptr->GetNode( "ExpertFeatureAccessSelector" ) ); + static_cast*> (&ExpertFeatureAccessSelector)->SetNumEnums( 8 ); + static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature1_Legacy, "ExpertFeature1_Legacy" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature1, "ExpertFeature1" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature2, "ExpertFeature2" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature3, "ExpertFeature3" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature4, "ExpertFeature4" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature5, "ExpertFeature5" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature6, "ExpertFeature6" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature7, "ExpertFeature7" ); static_cast (&ExpertFeatureAccessKey)->SetReference( _Ptr->GetNode( "ExpertFeatureAccessKey" ) ); + static_cast (&ExpertFeatureEnable)->SetReference( _Ptr->GetNode( "ExpertFeatureEnable" ) ); + static_cast (&N62)->SetReference( _Ptr->GetNode( "N62" ) ); + static_cast (&N63)->SetReference( _Ptr->GetNode( "N63" ) ); + static_cast (&N67)->SetReference( _Ptr->GetNode( "N67" ) ); + static_cast (&N68)->SetReference( _Ptr->GetNode( "N68" ) ); + static_cast (&N72)->SetReference( _Ptr->GetNode( "N72" ) ); + static_cast (&N73)->SetReference( _Ptr->GetNode( "N73" ) ); + static_cast (&N77)->SetReference( _Ptr->GetNode( "N77" ) ); + static_cast (&N78)->SetReference( _Ptr->GetNode( "N78" ) ); + static_cast (&N82)->SetReference( _Ptr->GetNode( "N82" ) ); + static_cast (&N83)->SetReference( _Ptr->GetNode( "N83" ) ); + static_cast (&N87)->SetReference( _Ptr->GetNode( "N87" ) ); + static_cast (&N88)->SetReference( _Ptr->GetNode( "N88" ) ); + static_cast (&N92)->SetReference( _Ptr->GetNode( "N92" ) ); + static_cast (&N93)->SetReference( _Ptr->GetNode( "N93" ) ); + static_cast (&N97)->SetReference( _Ptr->GetNode( "N97" ) ); + static_cast (&N98)->SetReference( _Ptr->GetNode( "N98" ) ); + static_cast (&N102)->SetReference( _Ptr->GetNode( "N102" ) ); + static_cast (&N103)->SetReference( _Ptr->GetNode( "N103" ) ); + static_cast (&N107)->SetReference( _Ptr->GetNode( "N107" ) ); + static_cast (&N108)->SetReference( _Ptr->GetNode( "N108" ) ); + static_cast (&N112)->SetReference( _Ptr->GetNode( "N112" ) ); + static_cast (&N113)->SetReference( _Ptr->GetNode( "N113" ) ); + static_cast (&N117)->SetReference( _Ptr->GetNode( "N117" ) ); + static_cast (&N118)->SetReference( _Ptr->GetNode( "N118" ) ); + static_cast*> (&FileSelector)->SetReference( _Ptr->GetNode( "FileSelector" ) ); + static_cast*> (&FileSelector)->SetNumEnums( 9 ); + static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserData, "UserData" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet1, "UserSet1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet2, "UserSet2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet3, "UserSet3" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserGainShading1, "UserGainShading1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserGainShading2, "UserGainShading2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserOffsetShading1, "UserOffsetShading1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserOffsetShading2, "UserOffsetShading2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_ExpertFeature7File, "ExpertFeature7File" ); static_cast*> (&FileOperationSelector)->SetReference( _Ptr->GetNode( "FileOperationSelector" ) ); + static_cast*> (&FileOperationSelector)->SetNumEnums( 4 ); + static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Open, "Open" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Close, "Close" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Read, "Read" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Write, "Write" ); static_cast*> (&FileOpenMode)->SetReference( _Ptr->GetNode( "FileOpenMode" ) ); + static_cast*> (&FileOpenMode)->SetNumEnums( 2 ); + static_cast*> (&FileOpenMode)->SetEnumReference( FileOpenMode_Read, "Read" ); static_cast*> (&FileOpenMode)->SetEnumReference( FileOpenMode_Write, "Write" ); static_cast (&FileAccessBuffer)->SetReference( _Ptr->GetNode( "FileAccessBuffer" ) ); + static_cast (&FileAccessOffset)->SetReference( _Ptr->GetNode( "FileAccessOffset" ) ); + static_cast (&FileAccessLength)->SetReference( _Ptr->GetNode( "FileAccessLength" ) ); + static_cast*> (&FileOperationStatus)->SetReference( _Ptr->GetNode( "FileOperationStatus" ) ); + static_cast*> (&FileOperationStatus)->SetNumEnums( 2 ); + static_cast*> (&FileOperationStatus)->SetEnumReference( FileOperationStatus_Success, "Success" ); static_cast*> (&FileOperationStatus)->SetEnumReference( FileOperationStatus_Failure, "Failure" ); static_cast (&FileOperationResult)->SetReference( _Ptr->GetNode( "FileOperationResult" ) ); + static_cast (&FileSize)->SetReference( _Ptr->GetNode( "FileSize" ) ); + static_cast (&FileOperationExecute)->SetReference( _Ptr->GetNode( "FileOperationExecute" ) ); + static_cast (&VolatileRowOffsetEnable)->SetReference( _Ptr->GetNode( "VolatileRowOffsetEnable" ) ); + static_cast (&VolatileRowOffsetIndex)->SetReference( _Ptr->GetNode( "VolatileRowOffsetIndex" ) ); + static_cast (&VolatileRowOffsetValue)->SetReference( _Ptr->GetNode( "VolatileRowOffsetValue" ) ); + static_cast (&VolatileRowOffsetValueAll)->SetReference( _Ptr->GetNode( "VolatileRowOffsetValueAll" ) ); + static_cast (&VolatileColumnOffsetEnable)->SetReference( _Ptr->GetNode( "VolatileColumnOffsetEnable" ) ); + static_cast (&VolatileColumnOffsetIndex)->SetReference( _Ptr->GetNode( "VolatileColumnOffsetIndex" ) ); + static_cast (&VolatileColumnOffsetValue)->SetReference( _Ptr->GetNode( "VolatileColumnOffsetValue" ) ); + static_cast (&VolatileColumnOffsetValueAll)->SetReference( _Ptr->GetNode( "VolatileColumnOffsetValueAll" ) ); + + } + + inline const char* CCLCameraParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CCLCameraParams_Params::_GetModelName( void ) + { + return "CLCameraParams"; + } + + //! \endcond + +} // namespace Basler_CLCameraParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_CLCameraParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/ActionTriggerConfiguration.h b/Cigarette/Pylon6.2/include/pylon/gige/ActionTriggerConfiguration.h new file mode 100644 index 0000000..4a4363e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/ActionTriggerConfiguration.h @@ -0,0 +1,247 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief An instant camera configuration for triggering via GigE Vision action commands. + This instant camera configuration is provided as header-only file. The code + can be copied and modified for creating own configuration classes. +*/ + +#ifndef INCLUDED_ACTIONTRIGGERCONFIGURATION_H_4655834 +#define INCLUDED_ACTIONTRIGGERCONFIGURATION_H_4655834 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUniversal + * @{ + */ + // Arbitrarily chosen constants for camera selection. For an explanation and + // tips see the "Multi-Camera Applications and GigE Vision 2.0" White paper + const uint32_t AllGroupMask( 0xffffffff ); // camera will respond to any mask other than 0 + + /*! + \class CActionTriggerConfiguration + \brief Changes the configuration of the camera so that it is triggered by the first + available action command. + + This configuration enables the frame start trigger and disables all other trigger + types. As trigger source the first available action command is selected, i.e., the + camera will be triggered by action commands issued by the application. + + In contrast to using the software trigger triggering with action commands allows + to trigger multiple cameras simultaneously. + + Either register this configuration as an Instant Camera's event handler or apply + the configuration to the node map of an opened pylon device using one of the + ApplyConfiguration methods. + + The %CActionTriggerConfiguration is provided as header-only file. + The code can be copied and modified for creating own configuration classes. + */ + class CActionTriggerConfiguration : public CConfigurationEventHandler + { + public: + struct ActionParameter + { + uint32_t DeviceKey; + uint32_t GroupKey; + uint32_t GroupMask; + + ActionParameter() + : DeviceKey( 0 ), GroupKey( 0 ), GroupMask( AllGroupMask ) + { + } + ActionParameter( uint32_t DeviceKey_, uint32_t GroupKey_, uint32_t GroupMask_ = AllGroupMask ) + : DeviceKey( DeviceKey_ ), GroupKey( GroupKey_ ), GroupMask( GroupMask_ ) + { + } + }; + + // constructors and assignment + CActionTriggerConfiguration( uint32_t DeviceKey, uint32_t GroupKey, uint32_t GroupMask = AllGroupMask ) : + m_Parameter( DeviceKey, GroupKey, GroupMask ) + { + } + CActionTriggerConfiguration( const ActionParameter& p ) + : m_Parameter( p ) + { + } + CActionTriggerConfiguration( const CActionTriggerConfiguration& other ) : CConfigurationEventHandler( other ) + { + m_Parameter = other.m_Parameter; + } + CActionTriggerConfiguration& operator=( const CActionTriggerConfiguration& rhs ) + { + m_Parameter = rhs.m_Parameter; + return *this; + } + // destructor + virtual ~CActionTriggerConfiguration() + { + } + + /// Apply action trigger configuration to a given camera device node map. + static void ApplyConfiguration( GENAPI_NAMESPACE::INodeMap& deviceNodeMap, const ActionParameter& p ) + { + ApplyConfiguration( deviceNodeMap, p.DeviceKey, p.GroupKey, p.GroupMask ); + } + + /// Apply action trigger configuration to a given camera device node map. + static void ApplyConfiguration( GENAPI_NAMESPACE::INodeMap& deviceNodeMap, uint32_t DeviceKey, uint32_t GroupKey, uint32_t GroupMask = AllGroupMask ) + { + using namespace GenApi; + + //Disable compression mode. + CConfigurationHelper::DisableCompression( deviceNodeMap ); + + //Disable GenDC streaming. + CConfigurationHelper::DisableGenDC( deviceNodeMap ); + + //Select image component. + CConfigurationHelper::SelectRangeComponent( deviceNodeMap ); + + ////////////////////////////////////////////////////////////////// + // get the nodes we need and do a check before we start changing the camera configuration + + CIntegerParameter actionDeviceKey( deviceNodeMap, "ActionDeviceKey" ); + CIntegerParameter actionGroupKey( deviceNodeMap, "ActionGroupKey" ); + CIntegerParameter actionGroupMask( deviceNodeMap, "ActionGroupMask" ); + CIntegerParameter actionSelector( deviceNodeMap, "ActionSelector" ); + + if (!actionDeviceKey.IsWritable() || + !actionGroupKey.IsWritable() || + !actionGroupMask.IsWritable() || + !actionSelector.IsWritable()) + { + throw RUNTIME_EXCEPTION( "Device doesn't support action commands. The ActionCommand features are not writable." ); + } + + // Get required enumerations to configure triggering on action commands + CEnumParameter triggerSelector( deviceNodeMap, "TriggerSelector" ); + CEnumParameter triggerSource( deviceNodeMap, "TriggerSource" ); + CEnumParameter triggerMode( deviceNodeMap, "TriggerMode" ); + + // to use triggering we need to switch Continuous Grab + CEnumParameter acquisitionMode( deviceNodeMap, "AcquisitionMode" ); + + if (!triggerSelector.IsWritable() || + !triggerSource.IsWritable() || + !triggerMode.IsWritable()) + { + throw RUNTIME_EXCEPTION( "Trigger nodes not writable" ); + } + + // Check the available camera trigger mode(s) + const String_t triggerName( "FrameStart" ); + if (!triggerSelector.CanSetValue( triggerName )) + { + throw RUNTIME_EXCEPTION( "Device does not support \"FrameStart\"" ); + } + + + if (!acquisitionMode.IsWritable()) + { + throw RUNTIME_EXCEPTION( "Acquisition mode not writable" ); + } + + + ////////////////////////////////////////////////////////////////// + // start changing the camera configuration + + // Select the first action (usually "Action 1") + actionSelector.SetToMinimum(); + String_t selectedAction = GenICam::gcstring( "Action" ) += actionSelector.ToString(); + + + actionDeviceKey.SetValue( DeviceKey ); + actionGroupKey.SetValue( GroupKey ); + actionGroupMask.SetValue( GroupMask ); + + // The goal is to issue a trigger for each single frame. Configure the + // corresponding trigger mode, disable all other trigger types. + { + + // Get all settable enumeration entries of Trigger Selector. + StringList_t triggerSelectorEntries; + triggerSelector.GetSettableValues( triggerSelectorEntries ); + + const String_t originalSelectorValue = triggerSelector.GetValue(); + + // Iterate through all available trigger modes, configure the frame start + // trigger, disable all other trigger types. + for (StringList_t::const_iterator it = triggerSelectorEntries.begin(); it != triggerSelectorEntries.end(); ++it) + { + // Set Trigger Mode to off if the trigger is available. + triggerSelector.SetValue( *it ); + if (triggerName == *it) + { + // Activate trigger. + triggerMode.SetValue( "On" ); + + // Set the trigger source to the selected action. + triggerSource.SetValue( selectedAction ); + } + else + { + triggerMode.TrySetValue( "Off" ); + } + } + + // reset to old value + triggerSelector.SetValue( originalSelectorValue ); + } + + // Set acquisition mode. + acquisitionMode.SetValue( "Continuous" ); + } + + private: + // Apply settings when the camera is opened. + /* virtual */ void OnOpened( CInstantCamera& camera ) + { + try + { + ApplyConfiguration( camera.GetNodeMap(), m_Parameter ); + } + catch (const GenericException& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Pylon::GenericException caught in OnOpened method msg=%hs", e.what() ); + } + catch (const std::exception& e) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. std::exception caught in OnOpened method msg=%hs", e.what() ); + } + catch (...) + { + throw RUNTIME_EXCEPTION( "Could not apply configuration. Unknown exception caught in OnOpened method." ); + } + } + + private: + ActionParameter m_Parameter; + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_ACTIONTRIGGERCONFIGURATION_H_4655834 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigECamera.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigECamera.h new file mode 100644 index 0000000..704ad1e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigECamera.h @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Pylon GigE Vision camera interface for Basler GigE Vision cameras +*/ + +#ifndef BASLER_GIGE_CAMERA_H +#define BASLER_GIGE_CAMERA_H + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include "PylonGigECamera.h" + +#include "_BaslerGigECameraParams.h" +namespace Basler_GigECameraParams = Basler_GigECamera; + + +namespace Pylon +{ + //************************************************************************************************** + //! Low Level API: The camera class for Basler GigE Vision camera devices + /** + Class for Basler GigE Vision cameras providing access to camera parameters. + \see \ref configuringcameras + + \ingroup Pylon_LowLevelApi + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + //************************************************************************************************** + PYLON_DEFINE_CAMERA( CBaslerGigECamera, Pylon::CPylonGigECameraT ); + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // BASLER_GIGE_CAMERA_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigECameraEventHandler.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigECameraEventHandler.h new file mode 100644 index 0000000..3bb1e9f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigECameraEventHandler.h @@ -0,0 +1,160 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the camera event handler base class. +*/ + +#ifndef INCLUDED_BASLERGIGECAMERAEVENTHANDLER_H_3102315 +#define INCLUDED_BASLERGIGECAMERAEVENTHANDLER_H_3102315 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class CBaslerGigEInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + /** + \class CBaslerGigECameraEventHandler + \brief The camera event handler base class. + */ + class CBaslerGigECameraEventHandler + { + public: + + /** + \brief This method is called when a camera event has been received. + + Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the + processing of images. + + \param[in] camera The source of the call. + \param[in] userProvidedId The ID passed when registering for the event. It can be used to distinguish between different events. + \param[in] pNode The node identified by node name when registering. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + \threading + This method is called outside the lock of the camera object, outside the lock of the node map, and inside the lock of the camera event handler registry. + */ + virtual void OnCameraEvent( CBaslerGigEInstantCamera& camera, intptr_t userProvidedId, GENAPI_NAMESPACE::INode* pNode ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( userProvidedId ); + PYLON_UNUSED( pNode ); + } + + /** + \brief This method is called when the camera event handler has been registered. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerGigECameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerRegistered( CBaslerGigEInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( nodeName ); + PYLON_UNUSED( userProvidedId ); + } + + /** + \brief This method is called when the camera event handler has been deregistered. + + The camera event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerGigECameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerDeregistered( CBaslerGigEInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( nodeName ); + PYLON_UNUSED( userProvidedId ); + } + + /*! + \brief Destroys the camera event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyCameraEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerGigECameraEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerGigECameraEventHandler( const CBaslerGigECameraEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerGigECameraEventHandler& operator=( const CBaslerGigECameraEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerGigECameraEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERGIGECAMERAEVENTHANDLER_H_3102315 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEConfigurationEventHandler.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEConfigurationEventHandler.h new file mode 100644 index 0000000..e5aa185 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEConfigurationEventHandler.h @@ -0,0 +1,409 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the configuration event handler base class. +*/ + +#ifndef INCLUDED_BASLERGIGECONFIGURATIONEVENTHANDLERH_01627755 +#define INCLUDED_BASLERGIGECONFIGURATIONEVENTHANDLERH_01627755 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +namespace Pylon +{ + class CBaslerGigEInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + /** + \class CBaslerGigEConfigurationEventHandler + \brief The configuration event handler base class. + */ + class CBaslerGigEConfigurationEventHandler + { + public: + /** + \brief This method is called before a %Pylon Device (Pylon::IPylonDevice) is attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttach( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a %Pylon Device (Pylon::IPylonDevice) has been attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttached( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is detached from the Instant Camera object. + + The camera's Detach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetach( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been detached from the Instant Camera object. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetached( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is destroyed. + + Camera DestroyDevice must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroy( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroyed( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpen( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpened( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before the attached %Pylon Device is closed. + + Camera Close must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClose( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after the attached %Pylon Device has been closed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClosed( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before a grab session is started. + + Camera StartGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStart( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a grab session has been started. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStarted( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called before a grab session is stopped. + + Camera StopGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStop( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called after a grab session has been stopped. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStopped( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when an exception has been triggered during grabbing. + + An exception has been triggered by a grab thread. The grab will be stopped after this event call. + + \param[in] camera The source of the call. + \param[in] errorMessage The message of the exception that signaled an error during grabbing. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabError( CBaslerGigEInstantCamera& camera, const char* errorMessage ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( errorMessage ); + } + + /** + \brief This method is called when a camera device removal from the PC has been detected. + + The %Pylon Device attached to the Instant Camera is not operable after this event. + After it is made sure that no access to the %Pylon Device or any of its node maps is made anymore + the %Pylon Device should be destroyed using InstantCamera::DeviceDestroy(). + The access to the %Pylon Device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object from an additional thread. + */ + virtual void OnCameraDeviceRemoved( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + + /** + \brief This method is called when the configuration event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationRegistered( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when the configuration event handler has been deregistered. + + The configuration event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationDeregistered( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /*! + \brief Destroys the configuration event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyConfiguration() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerGigEConfigurationEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerGigEConfigurationEventHandler( const CBaslerGigEConfigurationEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerGigEConfigurationEventHandler& operator=( const CBaslerGigEConfigurationEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerGigEConfigurationEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERGIGECONFIGURATIONEVENTHANDLERH_01627755 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEDeviceInfo.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEDeviceInfo.h new file mode 100644 index 0000000..96294af --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEDeviceInfo.h @@ -0,0 +1,54 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung, AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of CGigEDeviceInfo class + +This file contains the CBaslerGigEDeviceInfo class and additional key values +that are used in the CBaslerGigEDeviceInfo class. +*/ + + +#ifndef __BASLERGIGEDEVICEINFO_H__ +#define __BASLERGIGEDEVICEINFO_H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /*! + \ingroup Pylon_TransportLayer + \class CBaslerGigEDeviceInfo + \brief Implementation of the GiGE specific device info object + */ + class PYLONBASE_API CBaslerGigEDeviceInfo : public CDeviceInfo + { + public: + + CBaslerGigEDeviceInfo(); + CBaslerGigEDeviceInfo( const CDeviceInfo& ); + virtual ~CBaslerGigEDeviceInfo(); + }; + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* __BASLERGIGEDEVICEINFO_H__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEGrabResultData.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEGrabResultData.h new file mode 100644 index 0000000..493065c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEGrabResultData.h @@ -0,0 +1,52 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Pylon GigE specific grab result data class. +*/ + +#ifndef INCLUDED_BASLERGIGEGRABRESULTDATA_H_4046292 +#define INCLUDED_BASLERGIGEGRABRESULTDATA_H_4046292 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + /// The GigE specific grab result data. + class CBaslerGigEGrabResultData : public CGrabResultData, public Basler_GigEChunkData::CGigEChunkData_Params + { + protected: + // Internal use only. The grab result data class should only be created by the instant camera class. + friend class CBaslerGigEInstantCamera; + CBaslerGigEGrabResultData() + { + } + + // Internal use only. + virtual void Destroy() + { + delete this; + } + + // Internal use only. + virtual void Initialize() + { + _Initialize( &GetChunkDataNodeMap() ); + } + }; + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERGIGEGRABRESULTDATA_H_4046292 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEGrabResultPtr.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEGrabResultPtr.h new file mode 100644 index 0000000..059a6f9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEGrabResultPtr.h @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Pylon GigE specific grab result data class. +*/ + +#ifndef INCLUDED_BASLERGIGEGRABRESULTPTR_H_4564157 +#define INCLUDED_BASLERGIGEGRABRESULTPTR_H_4564157 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + /// The GigE specific grab result smart pointer. + PYLON_DEFINE_DEVICE_SPECIFIC_GRAB_RESULT_PTR( CBaslerGigEGrabResultPtr, CBaslerGigEGrabResultData ) + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERGIGEGRABRESULTPTR_H_4564157 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEImageEventHandler.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEImageEventHandler.h new file mode 100644 index 0000000..e7c5687 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEImageEventHandler.h @@ -0,0 +1,171 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the image event handler base class. +*/ + +#ifndef INCLUDED_BASLERGIGEIMAGEEVENTHANDLER_H_8866388 +#define INCLUDED_BASLERGIGEIMAGEEVENTHANDLER_H_8866388 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +namespace Pylon +{ + class CBaslerGigEInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + /** + \class CBaslerGigEImageEventHandler + \brief The image event handler base class. + */ + class CBaslerGigEImageEventHandler + { + public: + + /** + \brief This method is called when images have been skipped using the GrabStrategy_LatestImageOnly strategy or the GrabStrategy_LatestImages strategy. + + \param[in] camera The source of the call. + \param[in] countOfSkippedImages The number of images skipped. This \c countOfSkippedImages does not include the number of images lost in the case of a buffer under run in the driver. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImagesSkipped( CBaslerGigEInstantCamera& camera, size_t countOfSkippedImages ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( countOfSkippedImages ); + } + + /** + \brief This method is called when an image has been grabbed. + + The grab result smart pointer passed does always reference a grab result data object. + The status of the grab needs to be checked before accessing the grab result data. + See CGrabResultData::GrabSucceeded(), CGrabResultData::GetErrorCode() and + CGrabResultData::GetErrorDescription() for more information. + + \param[in] camera The source of the call. + \param[in] grabResult The grab result data. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImageGrabbed( CBaslerGigEInstantCamera& camera, const CBaslerGigEGrabResultPtr& grabResult ) + { + PYLON_UNUSED( &camera ); + PYLON_UNUSED( grabResult ); + } + + /** + \brief This method is called when the image event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerRegistered( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /** + \brief This method is called when the image event handler has been deregistered. + + The image event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerDeregistered( CBaslerGigEInstantCamera& camera ) + { + PYLON_UNUSED( &camera ); + } + + /*! + \brief Destroys the image event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyImageEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerGigEImageEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerGigEImageEventHandler( const CBaslerGigEImageEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerGigEImageEventHandler& operator=( const CBaslerGigEImageEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerGigEImageEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERGIGEIMAGEEVENTHANDLER_H_8866388 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEInstantCamera.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEInstantCamera.h new file mode 100644 index 0000000..38a566a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEInstantCamera.h @@ -0,0 +1,212 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Pylon GigE specific instant camera class. +*/ + +#ifndef INCLUDED_BASLERGIGEINSTANTCAMERA_H_7164973 +#define INCLUDED_BASLERGIGEINSTANTCAMERA_H_7164973 + +#include +namespace Basler_GigECameraParams = Basler_GigECamera; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + class CBaslerGigEInstantCamera; + + /// Lists all the types used by the GigE device specific instant camera class. + struct CBaslerGigEInstantCameraTraits + { + /// The type of the final camera class. + typedef CBaslerGigEInstantCamera InstantCamera_t; + /// \copybrief Basler_GigECamera::CGigECamera_Params + typedef Basler_GigECamera::CGigECamera_Params CameraParams_t; + /// \copybrief Pylon::IPylonGigEDevice + typedef IPylonGigEDevice IPylonDevice_t; + /// \copybrief Pylon::CBaslerGigEDeviceInfo + typedef Pylon::CBaslerGigEDeviceInfo DeviceInfo_t; + /// \copybrief Pylon::CPylonGigETLParams + typedef CNodeMapProxyT TlParams_t; + /// The parameters of the GigE streamgrabber. + typedef CNodeMapProxyT StreamGrabberParams_t; + /// The parameters of the GigE eventgrabber. + typedef CNodeMapProxyT EventGrabberParams_t; + /// The GigE specific configuration event handler class. + typedef CBaslerGigEConfigurationEventHandler ConfigurationEventHandler_t; + /// The GigE specific image event handler class. + typedef CBaslerGigEImageEventHandler ImageEventHandler_t; + /// The GigE specific camera event handler class. + typedef CBaslerGigECameraEventHandler CameraEventHandler_t; + /// The GigE specific grab result data. + typedef CBaslerGigEGrabResultData GrabResultData_t; + /// The GigE specific grab result smart pointer. + typedef CBaslerGigEGrabResultPtr GrabResultPtr_t; + + //! Can be used to check whether the DeviceClass() can be used for enumeration. + static bool HasSpecificDeviceClass() + { + return true; + } + //! The name of this device class. Use this one for enumeration. + static String_t DeviceClass() + { + return BaslerGigEDeviceClass; + } + }; + /*! + \class CBaslerGigEInstantCamera + \brief Extends the CInstantCamera by GigE specific parameter interface classes and GigE specific methods. + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + PYLON_6_0_DEPRECATED( "Use CBaslerUniversalInstantCamera" ) + class CBaslerGigEInstantCamera : public CDeviceSpecificInstantCameraT + { + public: + /*! + \copybrief CInstantCamera::CInstantCamera() + \copydetails CInstantCamera::CInstantCamera + */ + CBaslerGigEInstantCamera() + { + } + + /*! + \copybrief CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + \copydetails CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + */ + CBaslerGigEInstantCamera( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ) + : CDeviceSpecificInstantCameraT( pDevice, cleanupProcedure ) + { + } + + /*! + \copybrief CInstantCamera::~CInstantCamera + \copydetails CInstantCamera::~CInstantCamera + */ + ~CBaslerGigEInstantCamera() + { + Attach( NULL ); + InternalShutdownEventHandlers(); + } + + /*! + \brief Enables/disables use of persistent IP address and DHCP usage of the attached %Pylon Device. + + See Pylon::IPylonGigEDevice::ChangeIpConfiguration() + + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ + \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp ) + { + AutoLock lock( CInstantCamera::GetLock() ); + GetDevice()->ChangeIpConfiguration( EnablePersistentIp, EnableDhcp ); + } + + /*! + \brief Reads the persistent IP address from the attached %Pylon Device. + + See Pylon::IPylonGigEDevice::GetPersistentIpAddress() + + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway ) + { + AutoLock lock( CInstantCamera::GetLock() ); + GetDevice()->GetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway ); + } + + /*! + \brief Writes a persistent IP address to the attached %Pylon Device. + + See Pylon::IPylonGigEDevice::SetPersistentIpAddress() + + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ \error + The Instant Camera object is still valid after error. + + \threading + This method is synchronized using the lock provided by GetLock(). + */ + void SetPersistentIpAddress( const String_t& IpAddress, + const String_t& SubnetMask, + const String_t& DefaultGateway ) + + { + AutoLock lock( CInstantCamera::GetLock() ); + GetDevice()->SetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway ); + } + + protected: + //Get the pointer for the GigE device. + virtual IPylonGigEDevice* GetDevice() + { + IPylonDevice* pDevice = CInstantCamera::GetDevice(); + IPylonGigEDevice* pGigEDevice = dynamic_cast(pDevice); + + // Check whether device type matches camera type. + if (!pGigEDevice) + { + throw LOGICAL_ERROR_EXCEPTION( "The attached pylon device type must be a GigE device." ); + } + + return pGigEDevice; + } + + //Create device specific grab result data. Is subject to change without notice. + virtual CGrabResultData* CreateDeviceSpecificGrabResultData() + { + return new GrabResultData_t(); + } + }; + + /** + * @} + */ + +} // namespace Pylon + +#endif /* INCLUDED_BASLERGIGEINSTANTCAMERA_H_7164973 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEInstantCameraArray.h b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEInstantCameraArray.h new file mode 100644 index 0000000..49e8c9c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/BaslerGigEInstantCameraArray.h @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Pylon GigE specific instant camera array class. +*/ + +#ifndef INCLUDED_BASLERGIGEINSTANTCAMERAARRAY_H_6278605 +#define INCLUDED_BASLERGIGEINSTANTCAMERAARRAY_H_6278605 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiGigE + * @{ + */ + + /*! + \class CBaslerGigEInstantCameraArray + \brief GigE specific instant camera array. + + \threading + The CBaslerGigEInstantCameraArray class is not thread-safe. + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCameraArray instead. + */ + PYLON_6_0_DEPRECATED( "Use CBaslerUniversalInstantCameraArray" ) + class CBaslerGigEInstantCameraArray : public CDeviceSpecificInstantCameraArrayT + { + public: + /*! + \copybrief CInstantCameraArray::CInstantCameraArray() + \copydetails CInstantCameraArray::CInstantCameraArray() + */ + CBaslerGigEInstantCameraArray() + { + } + /*! + \copybrief CInstantCameraArray::CInstantCameraArray( size_t) + \copydetails CInstantCameraArray::CInstantCameraArray( size_t) + */ + CBaslerGigEInstantCameraArray( size_t numberOfCameras ) : CDeviceSpecificInstantCameraArrayT( numberOfCameras ) + { + } + /*! + \copybrief CInstantCameraArray::~CInstantCameraArray() + \copydetails CInstantCameraArray::~CInstantCameraArray() + */ + virtual ~CBaslerGigEInstantCameraArray() + { + } + + }; + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERGIGEINSTANTCAMERAARRAY_H_6278605 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/GigETransportLayer.h b/Cigarette/Pylon6.2/include/pylon/gige/GigETransportLayer.h new file mode 100644 index 0000000..076195a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/GigETransportLayer.h @@ -0,0 +1,259 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2008-2021 Basler AG +// http://www.baslerweb.com +// Author: Thomas Koeller, Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the GigE-specific transport layer interface extension +*/ + +#ifndef TRANSPORTLAYER_GIGE_H +#define TRANSPORTLAYER_GIGE_H + +#if _MSC_VER>1000 +#pragma once +#endif // _MSC_VER>1000 + +#include +#include "PylonGigE.h" + +namespace Pylon +{ + /*! + \ingroup Pylon_TransportLayer + \brief Lists possible status codes returned by IGigETransportLayer::IssueActionCommand or IGigETransportLayer::IssueScheduledActionCommand. + */ + enum EGigEActionCommandStatus + { + /** + \brief The device acknowledged the command. + */ + GigEActionCommandStatus_Ok = 0, + + /** + \brief The device is not synchronized to a master clock to be used as time reference. + Typically used when scheduled action commands cannot be scheduled for + a future time since the reference time coming from IEEE 1588 is not locked. + The action command has been ignored by the device. + */ + GigEActionCommandStatus_NoRefTime = 0xE1018013, + + /** + \brief Returned when the scheduled action commands queue is full and the device cannot accept the additional request. + The action command has been discarded by the device. + */ + GigEActionCommandStatus_Overflow = 0xE1018015, + + /** + \brief The requested scheduled action command was requested at a point in time that is in the past. + If the time tag of the scheduled action command is in the past (relative to the device timestamp), and if it is a valid action + command, then the device will execute this action command immediately and return \c GigEActionCommandStatus_ActionLate. + This status code is used as an indicator to the application requesting the action command that a mis-synchronization might have + occurred. + */ + GigEActionCommandStatus_ActionLate = 0xE1018016 + }; + + + /*! + \ingroup Pylon_TransportLayer + \brief Optional result structure of IGigETransportLayer::IssueActionCommand and IGigETransportLayer::IssueScheduledActionCommand. + */ + struct GigEActionCommandResult + { + /// IP address of the device. + char DeviceAddress[12 + 3 + 1]; + + /// GigE Vision status code returned by the device. See Pylon::EGigEActionCommandStatus for more information. + int32_t Status; + }; + + + /*! + \ingroup Pylon_TransportLayer + \interface IGigETransportLayer + \brief Extends the ITransportLayer interface by GigE Vision specific + functionality. + */ + interface PUBLIC_INTERFACE IGigETransportLayer : public ITransportLayer + { + //! \brief Enumerates all available Basler GigE Vision devices + /*! + In contrast to the ITransportLayer::EnumerateDevices method, + devices having a subnet configured that is different from the subnet of the + application will be listed. + + All Basler GigE Vision devices will be listed, including the Basler blaze, + which is usually not considered by the GigE transport layer. + */ + virtual int EnumerateAllDevices( DeviceInfoList_t&, bool addToList = false ) = 0; + + //! \brief "Force" a static IP address configuration in a device identified by its MAC Address + /** + This applies to all Basler GigE Vision devices, including the Basler blaze, which isn't + usually considered by the GigE transport layer. + + \note When calling this function, there must be no opened camera object for + the device to be reconfigured! + + \param MacAddress MAC address as a string, no delimiters are used. e.g., 003053061a58 + \param IpAddress Temporary IP address, "dot notation", e.g., 192.168.1.2 + \param SubnetMask Temporary SubnetMask, "dot notation", e.g. 255.255.255.0 + \param DefaultGateway Temporary DefaultGateway, "dot notation", e.g., 192.168.1.1 + */ + virtual void ForceIp( const String_t& MacAddress, + const String_t& IpAddress, + const String_t& SubnetMask, + const String_t& DefaultGateway ) = 0; + + //! \brief Let a device restart the IP configuration cycle + /** + \note This function fails when the device is open, i.e., a control channel is established + \param MacAddress MAC address as a string, no delimiters are used, e.g., 003053061a58 + */ + virtual void RestartIpConfiguration( const String_t& MacAddress ) = 0; + + //! \brief Announce that a remote device is going to be used + /*! + This applies to all Basler GigE Vision devices, including the Basler blaze, which isn't + usually considered by the GigE transport layer. + + \note This device must be reachable, a route is configured. + \param IpAddress address of device in "dot notation" + \param pInfo This optional parameter holds the full device info if found + */ + virtual bool AnnounceRemoteDevice( const String_t& IpAddress, CDeviceInfo* pInfo = NULL ) = 0; + //! \brief Stop using remote device. + /*! \param IpAddress address of device in "dot notation" */ + virtual bool RenounceRemoteDevice( const String_t& IpAddress ) = 0; + + //! \brief Broadcast a new IP configuration + /** + All Basler GigE Vision devices can be configured, including the Basler blaze, which + isn't usually considered by the GigE transport layer. + When configuring a blaze camera, some options may not be supported. Please check + the camera documentation for more information. + + \param MacAddress MAC address as a string, no delimiters are used. e.g., 003053061a58 + \param EnablePersistentIp If true, a persistent Ip address will be set + \param EnableDhcp If true, DHCP is enabled + \param IpAddress Device's new IP address, "dot notation", e.g., 192.168.1.2 + \param SubnetMask Device's new SubnetMask, "dot notation", e.g. 255.255.255.0 + \param DefaultGateway Device's new DefaultGateway, "dot notation", e.g., 192.168.1.1 + \param UserdefinedName Device's new UserdefinedName, maximal 16 character + \return true if configuration was successfully written + */ + virtual bool BroadcastIpConfiguration( const String_t& MacAddress, + bool EnablePersistentIp, + bool EnableDhcp, + const String_t& IpAddress, + const String_t& SubnetMask, + const String_t& DefaultGateway, + const String_t& UserdefinedName ) = 0; + + + //! \brief Issue a broadcast action command. + /** + \param[in] deviceKey The device key addresses devices managed by an application. + The device key is only known to the application controlling its camera devices + and it ensures that only this application can trigger the camera devices. + Therefore the device key cannot be read from a device. + An exact match of the send \c deviceKey and the device key stored in a device + is required for executing an action. + + \param[in] groupKey The group key is used to create groups of devices or actions. + An exact match of the send \c groupKey and the group key stored in a device + for an action is required for executing an action. + + \param[in] groupMask The groupMask is a bit mask that allows to send an action to a subgroup + of the devices addressed by the \c deviceKey \c groupKey pair. + The result of a bitwise AND operation of \c groupMask and the group mask + stored in a device for an action must be non-zero for executing an action. + + \param[in] broadcastAddress BroadcastAddress in dot notation where the command will be broadcast to, + e.g. 255.255.255.255 (all adapters, default), + 192.168.1.255 (all devices in a single subnet 192.168.1.xxx), + 192.168.1.38 (single device). + See the note below. + + \param[in] timeoutMs Optional: Time in milliseconds the call is waiting for acknowledges of the addressed devices. + Waiting for acknowledges is stopped if \c pNumResults have been received. + This parameter can be 0 if a check of action command results is not required. + + \param[in,out] pNumResults Optional: The number of results in the \c results array. + The value passed should be equal to the expected number of devices that acknowledge the command. + Returns the number of received results. + This parameter is ignored if \c timeoutMs is 0. + Thus this parameter can be NULL if \c timeoutMs is 0. + + \param[out] results Optional: An Array with \c *pNumResults elements to hold the action command result status. + The buffer is filled beginning from the start. Remaining results are + not changed if less results are received than result items available. + This parameter is ignored if \c timeoutMs is 0. + Thus this parameter can be NULL if \c timeoutMs is 0. + + + \return Returns true if *pNumResults have been received and the \c Status of all results is \c GigEActionCommandStatus_Ok. + Returns true if no results have been requested. + + The action command feature lets you trigger actions in multiple devices (e.g. cameras) at roughly + the same time or at a defined point in time (scheduled action command) by using a single broadcast protocol message (without extra cabling). Action + commands are used in cameras in the same way as for example the digital input lines. + + \note The request is sent via all existing network adapters. If a network adapter has more than one IP address, the request is sent separately for each address. + This is not executed simultaneously but consecutively, IP address by IP address. That's why additional latency is added to the execution time. + Directed broadcasts (192.168.1.255) or unicasts (192.168.1.38) are only sent if the request subnet matches the subnet of the IP address, i.e., if no gateway or routing are required. + + See \ref sample_Grab_UsingActionCommand and Pylon::CActionTriggerConfiguration for more information. + + \pre +
    +
  • IP4 addresses must be used. +
  • \c groupMask must not be 0. +
  • \c pNumResult, \c *pNumResult and \c results must not be 0 if a \c timeoutMs value other than 0 is passed. +
+ + \error + Throws an exception if the preconditions are not met. Throws C++ exceptions. + + \threading + The method is thread-safe. + */ + virtual bool IssueActionCommand( uint32_t deviceKey, + uint32_t groupKey, + uint32_t groupMask, + const String_t &broadcastAddress = "255.255.255.255", + uint32_t timeoutMs = 0, + uint32_t *pNumResults = 0, + GigEActionCommandResult results[] = NULL ) = 0; + + + //! \brief Issue a scheduled action command via broadcast. + /** + \copydetails IGigETransportLayer::IssueActionCommand + + \param[in] actionTimeNs Time in nanoseconds when the action is to be executed. + The actual value depends on the used master clock. + A master clock value can be obtained for instance for a set of + synchronized camera devices by reading the timestamp value + (GevTimestampValue) after latching the timestamp value + (GevTimestampControlLatch) from one camera device of the set + + \pre \c actionTimeNs must be smaller than or equal INT64_MAX. + */ + virtual bool IssueScheduledActionCommand( uint32_t deviceKey, + uint32_t groupKey, + uint32_t groupMask, + uint64_t actionTimeNs, + const String_t &broadcastAddress = "255.255.255.255", + uint32_t timeoutMs = 0, + uint32_t *pNumResults = 0, + GigEActionCommandResult results[] = NULL + ) = 0; + + }; +} // namespace Pylon + +#endif // TRANSPORTLAYER_GIGE_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/PylonGigE.h b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigE.h new file mode 100644 index 0000000..fcc4316 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigE.h @@ -0,0 +1,28 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of macros for import/export decorations for PylonGigE library +*/ + +#ifndef __PYLONGIGE_H__ +#define __PYLONGIGE_H__ + +#if defined _MSC_VER && (_MSC_VER > 1000) +# pragma once +#endif // _MSC_VER > 1000 + +#include + +#ifdef PYLONGIGE_EXPORTS +# define PYLONGIGE_API APIEXPORT +#else +# define PYLONGIGE_API APIIMPORT +#endif + + +#endif // __PYLONGIGE_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/PylonGigECamera.h b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigECamera.h new file mode 100644 index 0000000..c3c5b85 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigECamera.h @@ -0,0 +1,134 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Generic pylon GigE Vision camera interface +*/ + +#ifndef PYLON_GIGE_CAMERA_H +#define PYLON_GIGE_CAMERA_H + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include "../DeviceClass.h" +#include "../NodeMapProxy.h" +#include "../StreamGrabberProxy.h" +#include "../EventGrabberProxy.h" + +#include "BaslerGigEDeviceInfo.h" +#include "PylonGigEDeviceProxy.h" + +#include "_GigETLParams.h" +#include "_GigEStreamParams.h" +#include "_GigEEventParams.h" + + +namespace Pylon +{ + //************************************************************************************************** + //! Low Level API: Class for pylon GigE Vision cameras providing access to transport layer related parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + PYLON_DEFINE_NODEMAP( CPylonGigETLParams, CNodeMapProxyT ); + + + //************************************************************************************************** + //! Low Level API: Class for pylon GigE Vision cameras providing access to stream grabber related methods and parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + PYLON_DEFINE_STREAMGRABBER( CPylonGigEStreamGrabber, CStreamGrabberProxyT ); + + + //************************************************************************************************** + //! Low Level API: Class for pylon GigE Vision cameras providing access to event grabber related methods and parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + PYLON_DEFINE_EVENTGRABBER( CPylonGigEEventGrabber, CEventGrabberProxyT ); + + + //************************************************************************************************** + //! Low Level API: The camera class for pylon GigE Vision camera devices + /** + This is the base class for pylon GigE Vision cameras providing access to camera parameters. + \see \ref configuringcameras + + \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file) + \ingroup Pylon_LowLevelApi + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + //************************************************************************************************** + template + class CPylonGigECameraT : public CPylonGigEDeviceProxyT + { + public: + typedef Pylon::CBaslerGigEDeviceInfo DeviceInfo_t; //!< \copybrief Pylon::CBaslerGigEDeviceInfo + typedef Pylon::CPylonGigETLParams TlParams_t; //!< \copybrief Pylon::CPylonGigETLParams + typedef Pylon::CPylonGigEStreamGrabber StreamGrabber_t; //!< \copybrief Pylon::CPylonGigEStreamGrabber + typedef Pylon::CPylonGigEEventGrabber EventGrabber_t; //!< \copybrief Pylon::CPylonGigEEventGrabber + + //! The name of this device class, use this for enumeration + static String_t DeviceClass() + { + return BaslerGigEDeviceClass; + } + + public: + //! \name Construction + // \{ + + /** \brief \copybrief Pylon::CPylonGigEDeviceProxyT::CPylonGigEDeviceProxyT() + + \copydetails Pylon::CPylonGigEDeviceProxyT::CPylonGigEDeviceProxyT() + */ + CPylonGigECameraT() + { + }; + + /** \brief \copybrief Pylon::CPylonGigEDeviceProxyT::CPylonGigEDeviceProxyT(IPylonDevice*,bool) + + \copydetails Pylon::CPylonGigEDeviceProxyT::CPylonGigEDeviceProxyT(IPylonDevice*,bool) + */ + CPylonGigECameraT( IPylonDevice* pDevice, bool takeOwnership = true ) + : CPylonGigEDeviceProxyT( pDevice, takeOwnership ) + { + } + + /** \brief \copybrief Pylon::CPylonGigEDeviceProxyT::~CPylonGigEDeviceProxyT() + + \copydetails Pylon::CPylonGigEDeviceProxyT::~CPylonGigEDeviceProxyT() + */ + virtual ~CPylonGigECameraT() + { + } + //\} + }; + + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // PYLON_GIGE_CAMERA_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEDevice.h b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEDevice.h new file mode 100644 index 0000000..831cd4c --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEDevice.h @@ -0,0 +1,68 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: The IPylonGigEDevice interface +*/ + +#include "PylonGigE.h" + + +#ifndef __PYLON_PYLONGIGEDEVICE__H__ +#define __PYLON_PYLONGIGEDEVICE__H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include "PylonGigE.h" + +namespace Pylon +{ + + /** + \ingroup Pylon_LowLevelApi + \interface IPylonGigEDevice + \brief Low Level API: The interface for Basler GigE camera devices + + This interface extends the IPylonDevice interface. + */ + + + interface PUBLIC_INTERFACE IPylonGigEDevice : public IPylonDevice + { + //! Enables/disables use of persistent IP address and DHCP usage + virtual void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp ) = 0; + + //! Reads the persistent IP address from the device + virtual void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway ) = 0; + + //! Writes a persistent IP address to the device. + /** Writing the persistent IP address does not change the IP configuration. + Use the ChangeIpConfiguration() method to enable the usage of persistent IP addresses. + */ + virtual void SetPersistentIpAddress( const String_t& IpAddress, + const String_t& SubnetMask, + const String_t& DefaultGateway ) = 0; + + }; + + +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* __PYLON_PYLONGIGEDEVICE__H__ */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEDeviceProxy.h b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEDeviceProxy.h new file mode 100644 index 0000000..a1ae6b9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEDeviceProxy.h @@ -0,0 +1,193 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Pylon generic GigEVision device interface declaration +*/ + +#ifndef __PYLON_PYLONGIGEDEVICEPROXY__H__ +#define __PYLON_PYLONGIGEDEVICEPROXY__H__ + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include "PylonGigEDevice.h" +#include "../PylonDeviceProxy.h" + + +namespace Pylon +{ + //************************************************************************************************** + /// Low Level API: The camera class for GigE Vision camera devices + /** + \ingroup Pylon_LowLevelApi + + Extends the Pylon::CPylonDeviceProxyT class by GigE Vision specific functionality. + + \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file) + */ + //************************************************************************************************** + template + class CPylonGigEDeviceProxyT : public CPylonDeviceProxyT + { + public: + //! \name Construction + // \{ + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + */ + CPylonGigEDeviceProxyT(); + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + */ + CPylonGigEDeviceProxyT( IPylonDevice*, bool takeOwnership = true ); + + //! Destructor + virtual ~CPylonGigEDeviceProxyT(); + + //\} + + + private: + //! \name Assignment and copying is not supported + // \{ + CPylonGigEDeviceProxyT( const CPylonGigEDeviceProxyT& ); + CPylonGigEDeviceProxyT& operator=( const CPylonGigEDeviceProxyT& ); + // \} + + + public: + //! \name Some smart pointer functionality + // \{ + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::Attach() + + \copydetails Pylon::CPylonDeviceProxyT::Attach() + */ + virtual void Attach( IPylonDevice*, bool takeOwnership = true ); + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::IsAttached() + + \copydetails Pylon::CPylonDeviceProxyT::IsAttached() + */ + virtual bool IsAttached() const; + + // \} + + public: + //! \name Implementation of the IPylonGigEDevice interface. + //! See Pylon::IPylonGigEDevice for more details. + // \{ + + /** \brief \copybrief Pylon::IPylonGigEDevice::ChangeIpConfiguration() + + \copydetails Pylon::IPylonGigEDevice::ChangeIpConfiguration() + */ + void ChangeIpConfiguration( bool EnablePersistentIp, bool EnableDhcp ) + { + CheckGigEDevicePtr(); + m_pGigEDevice->ChangeIpConfiguration( EnablePersistentIp, EnableDhcp ); + } + + /** \brief \copybrief Pylon::IPylonGigEDevice::GetPersistentIpAddress() + + \copydetails Pylon::IPylonGigEDevice::GetPersistentIpAddress() + */ + void GetPersistentIpAddress( String_t& IpAddress, String_t& SubnetMask, String_t& DefaultGateway ) + { + CheckGigEDevicePtr(); + m_pGigEDevice->GetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway ); + } + + /** \brief \copybrief Pylon::IPylonGigEDevice::SetPersistentIpAddress() + + \copydetails Pylon::IPylonGigEDevice::SetPersistentIpAddress() + */ + void SetPersistentIpAddress( const String_t& IpAddress, + const String_t& SubnetMask, + const String_t& DefaultGateway ) + + { + CheckGigEDevicePtr(); + m_pGigEDevice->SetPersistentIpAddress( IpAddress, SubnetMask, DefaultGateway ); + } + + // \} + + protected: + void CheckGigEDevicePtr() const + { + if (NULL == m_pGigEDevice) + { + throw LOGICAL_ERROR_EXCEPTION( "The camera class is not attached to an IPylonGigEDevice" ); + } + } + + IPylonGigEDevice* m_pGigEDevice; + }; + + + //************************************************************************************************** + // CPylonGigEDeviceProxyT implementation + //************************************************************************************************** + + template + inline CPylonGigEDeviceProxyT::CPylonGigEDeviceProxyT() + : CPylonDeviceProxyT() + , m_pGigEDevice( NULL ) + { + } + + template + inline CPylonGigEDeviceProxyT::CPylonGigEDeviceProxyT( IPylonDevice* pDevice, bool takeOwnership ) + : CPylonDeviceProxyT() + , m_pGigEDevice( NULL ) + { + Attach( pDevice, takeOwnership ); + } + + template + inline CPylonGigEDeviceProxyT::~CPylonGigEDeviceProxyT() + { + } + + template + inline void CPylonGigEDeviceProxyT::Attach( IPylonDevice* pDevice, bool takeOwnership ) + { + IPylonGigEDevice* pGigEDevice = dynamic_cast(pDevice); + if (!pGigEDevice) + { + throw LOGICAL_ERROR_EXCEPTION( "The attached Pylon Device is not of type IPylonGigEDevice!" ); + } + + CPylonDeviceProxyT::Attach( pDevice, takeOwnership ); + m_pGigEDevice = pGigEDevice; + } + + template + inline bool CPylonGigEDeviceProxyT::IsAttached() const + { + return NULL != m_pGigEDevice; + } + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif diff --git a/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEIncludes.h b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEIncludes.h new file mode 100644 index 0000000..61cd3dd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/PylonGigEIncludes.h @@ -0,0 +1,25 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Includes specific for the the GigE transport layer +*/ + +#ifndef INCLUDED_PYLONGIGEINCLUDES_H_08834475 +#define INCLUDED_PYLONGIGEINCLUDES_H_08834475 + +#if _MSC_VER > 1000 +#pragma once +#endif //_MSC_VER > 1000 + +#include +#include +#include +#include //includes also CBaslerGigEInstantCamera +#include + +#endif /* INCLUDED_PYLONGIGEINCLUDES_H_08834475 */ diff --git a/Cigarette/Pylon6.2/include/pylon/gige/_BaslerGigECameraParams.h b/Cigarette/Pylon6.2/include/pylon/gige/_BaslerGigECameraParams.h new file mode 100644 index 0000000..b3061dd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/_BaslerGigECameraParams.h @@ -0,0 +1,10949 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Basler generic GigEVision camera interface +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_GigECamera_PARAMS_H +#define Basler_GigECamera_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_GigECamera +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for SequenceConfigurationMode + enum SequenceConfigurationModeEnums + { + SequenceConfigurationMode_Off, //!& SequenceConfigurationMode; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Allows asynchronous restart of the sequence of sequence sets + + Allows to restart the sequence of sequence sets to image acquisition, starting with the sequence set of lowest index number. The restart is asynchronous to the cameras's frame trigger. Only available in Auto and Controlled sequence advance mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& SequenceAsyncRestart; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Allows asynchronous advance from one sequence set to the next + + Allows to advance from the current sequence set to the next one. The advance is asynchronous to the cameras's frame trigger. Only available in Controlled sequence advance mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& SequenceAsyncAdvance; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Total number of sequence sets + + Sets the total number of sequence sets in the sequence. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SequenceSetTotalNumber; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Selects the index number of a sequence set + + Selects the index number of a sequence set. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SequenceSetIndex; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Stores the current sequence set + + Stores the current sequence set as one of the sequence sets of the sequence. Note: Storing the current sequence set will overwrite any already existing sequence set bearing the same index number. Note: The sequence set is stored in the volatile memory and will therefore be lost if the camera is reset or if power is switched off. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& SequenceSetStore; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Loads a sequence set + + Loads an existing sequence set to make it the current sequence set. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& SequenceSetLoad; + + //@} + + + //! \name SequenceControl - This category includes items that control the sequencer feature + //@{ + /*! + \brief Sets the number of sequence set executions + + Sets the number of consecutive executions per sequence cycle for the selected sequence set. Only available in Auto sequence advance mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& SequenceSetExecutions; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects the sequence set advance mode + + Selects the sequence set advance mode. Possible values: Auto - automatic sequence set advance as images are acquired. Controlled - sequence set advance controlled by settable source. Free selection - the sequence sets are selected according to the states of the input lines. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceAdvanceMode; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects between sequence restart or sequence set advance + + Selects between controls for sequence restart or sequence set advance. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceControlSelector; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects the source for sequence control + + Selects the source for sequence control. Possible values: Disabled - advance via asynchronous advance. Always Active - automatic sequence set advance. The sequence repeat starts with sequence set index number 1. Line N - the source for sequence restart or sequence set advance is line N. CCN - the source for sequence restart or sequence set advance is CCN. + + \b Visibility = Guru + + \b Selected by : SequenceControlSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceControlSource; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects a bit of the sequence set address + + Selects a bit of the sequence set address. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceAddressBitSelector; + + //@} + + + //! \name SequenceControlConfiguration - This category includes items that control the sequence set advance + //@{ + /*! + \brief Selects the source for the selected bit of the sequence set address + + Selects the source for setting the selected bit of the sequence set address. + + \b Visibility = Guru + + \b Selected by : SequenceAddressBitSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& SequenceAddressBitSource; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Gain Auto is the 'automatic' counterpart of the manual gain feature. + + The gain auto function automatically adjusts the Auto Gain Raw parameter value within set limits, until a target average gray value for the pixel data from Auto Function AOI1 is reached. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GainAuto; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Selects the gain control to configure. Once a gain control has been selected, all changes to the gain settings will be applied to the selected control. + + This enumeration selects the gain control to configure. Once a gain control has been selected, all changes to the gain settings will be applied to the selected control. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GainSelector; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief This is an integer value that sets the selected gain control in device specific units + + Sets the 'raw' value of the selected gain control. The 'raw' value is an integer value that sets the selected gain control in units specific to the camera. + + \b Visibility = Beginner + + + \b Selected by : GainSelector + + */ + GENAPI_NAMESPACE::IInteger& GainRaw; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief This is a float value that sets the selected gain control in dB + + Sets the 'absolute' value of the selected gain control. The 'absolute' value is a float value that sets the selected gain control in dB. + + \b Visibility = Beginner + + + \b Selected by : GainSelector + + */ + GENAPI_NAMESPACE::IFloat& GainAbs; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Selcts a black level control to configure. Once a black level control has been selected, all changes to the black level settings will be applied to the selected control. + + This enumeration selects the black level control to configure. Once a black level control has been selected, all changes to the black level settings will be applied to the selected control. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BlackLevelSelector; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the value of the selected black level control as an integer + + This value sets the selected black level control as an integer. + + \b Visibility = Beginner + + + \b Selected by : BlackLevelSelector + + */ + GENAPI_NAMESPACE::IInteger& BlackLevelRaw; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the value of the selected black level control as a float + + This value sets the selected black level control as a float value. + + \b Visibility = Beginner + + + \b Selected by : BlackLevelSelector + + */ + GENAPI_NAMESPACE::IFloat& BlackLevelAbs; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Enables the gamma correction + + This boolean value enables the gamma correction. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& GammaEnable; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief + + This enumeration selects the type of gamma to apply. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GammaSelector; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief This feature is used to perform gamma correction of pixel intensity. + + This feature is used to perform gamma correction of pixel intensity. This is typically used to compensate for non-linearity of the display system (such as CRT). + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& Gamma; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the value of the selected digital shift control + + This value sets the selected digital shift control + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DigitalShift; + + //@} + + + //! \name AnalogControls - This category includes items that control the analog characteristics of the video signal + //@{ + /*! + \brief Sets the substrate voltage + + This value sets the substrate voltage + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SubstrateVoltage; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief This feature selects the amount of data bits the sensor produces for one sample. + + This feature selects the amount of data bits the sensor produces for one sample. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorBitDepth; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief This feature represents the number of digitized samples outputted simultaneously by the camera A/D conversion stage. + + This feature represents the number of digitized samples output simultaneously by the camera A/D conversion stage. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorDigitizationTaps; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Sets the format of the pixel data transmitted for acquired images + + This enumeration sets the format of the pixel data transmitted for acquired images. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelFormat; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Sets the color coding of the pixels in the acquired images + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelCoding; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the depth of the pixel values in the image in bits per pixel + + This is a read only feature. This enumeration provides a list of values that indicate the depth of the pixel values in the acquired images in bits per pixel. This value will always be coherent with the pixel format setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelSize; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the alignment of the camera's Bayer filter to the pixels in the acquired images + + This is a read only feature. This enumeration provides a list of values that indicate the alignment of the camera's Bayer filter to the pixels in the acquired images. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelColorFilter; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Enables color improved RGB raw output + + Enables color improvement of RGB data and provides for their output as RGB raw data. Only available for cameras with an RGB Bayer filter. + Note: Make sure to also select a suitable raw pixel data output format. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& ProcessedRawEnable; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the minimum possible pixel value that could be transferred from the camera + + This a read only feature. It indicates the minimum possible pixel value that could be transferred from the camera. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& PixelDynamicRangeMin; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Indicates the maximum possible pixel value that could be transferred from the camera + + This a read only feature. It indicates the maximum possible pixel value that could be transferred from the camera. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& PixelDynamicRangeMax; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Specifies the direction of imaging and the separation (consecutive numbers) of related line captures. + + Specifies the direction of imaging and the separation (consecutive numbers) of related line captures. Related line captures will be combined. + + Positive integer: The object will pass the top sensor line first. + + Negative integer: The object will pass the bottom sensor line first. + + In color cameras, the top sensor line is the green line, and the bottom sensor line is the blue line. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SpatialCorrection; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& SpatialCorrectionAmount; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IEnumerationT& SpatialCorrectionStartingLine; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Enables the horizontal flipping of the image. + + This feature is used to flip horizontally the image sent by the device. The AOI is applied after the flipping. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ReverseX; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Enables the vertical flipping of the image. + + This feature is used to flip vertically the image sent by the device. The AOI is applied after the flipping. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ReverseY; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Selects the mode to output the fields. + + Selects the mode to output the fields. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& FieldOutputMode; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Selecting a test image from the list will enable the test image + + This enumeration provides a list of the available test images. Selecting a test image from the list will enable the test image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TestImageSelector; + + //@} + + + //! \name ImageFormat - This category includes items that control the size of the acquired image and the format of the transferred pixel data + //@{ + /*! + \brief Holds all moving test images at their starting position. + + Holds all moving test images at their starting position. All test images will be displayed at their starting positions and will stay fixed. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& TestImageResetAndHold; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the width of the camera's sensor in pixels + + This is a read only element. It is an integer that indicates the actual width of the camera's sensor in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SensorWidth; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the height of the camera's sensor in pixels. + + This is a read only element. It is an integer that indicates the actual height of the camera's sensor in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SensorHeight; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the maximum allowed width of the image in pixels + + This is a read only element. It is an integer that indicates maximum allowed width of the image in pixels taking into account any function that may limit the allowed width. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& WidthMax; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the maximum allowed height of the image in pixels + + This is a read only element. It is an integer that indicates maximum allowed height of the image in pixels taking into account any function that may limit the allowed height. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& HeightMax; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Selects the type of light source to be considered for matrix color transformation + + Selects the color transformation mode to select the type of light source to be considered for matrix color transformation. + + \b Visibility = Expert + + \b Selected by : ColorTransformationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LightSourceSelector; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Allows returning to previous settings + + Allows returning to the color adjustment settings extant before the latest changes of the settings. + This allows you undoing the latest unwanted changes of the color adjustment settings and returning to the preceding settings. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& BalanceWhiteReset; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Balance White Auto is the 'automatic' counterpart of the manual white balance feature. + + The automatic white balance is a two-step process: First, the Balance Ratio Abs parameter values for red, green, and blue are each set to 1.5. Then, assuming a 'grey world' model, the Balance Ratio Abs parameter values are adjusted such that the average gray values for the 'red' and 'blue' pixels match the average gray value for the 'green' pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BalanceWhiteAuto; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Selects a balance ratio to configure. Once a balance ratio control has been selected, all changes to the balance ratio settings will be applied to the selected control. + + This enumeration selects a balance ratio control to configuration. Once a balance ratio control has been selected, all changes to the balance ratio settings will be applied to the selected control. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BalanceRatioSelector; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Sets the value of the selected balance ratio control as a float + + This value sets the selected balance ratio control as a float value. + + \b Visibility = Beginner + + + \b Selected by : BalanceRatioSelector + + */ + GENAPI_NAMESPACE::IFloat& BalanceRatioAbs; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Sets the value of the selected balance ratio control as an integer + + This value sets the selected balance ratio control as an integer. + + \b Visibility = Beginner + + + \b Selected by : BalanceRatioSelector + + */ + GENAPI_NAMESPACE::IInteger& BalanceRatioRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Selects the matrix color transformation between color spaces + + Selects the matrix color transformation between color spaces. + Generally, the related color spaces are used for internal processing: The color signals provided by the sensor are transformed to the RGB color space to allow further transformations (to account for the type of light source, for color adjustment, for white balance, etc.). + The color transformation selected here does not refer to the color space selected for the transmission of image data out of the camera. + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorTransformationSelector; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Selects the element to be entered in the color transformation matrix. + + Selects the element to be entered in the 3 x 3 color transformation matrix for custom matrix color transformation. + Note: Depending on the camera model, some elements in the color transformation matrix may be preset and can not be changed. + + + \b Visibility = Guru + + \b Selected by : ColorTransformationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorTransformationValueSelector; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Sets a floating point value for the selected element in the color transformation matrix + + Sets a floating point value for the selected element in the color transformation matrix. + + \b Visibility = Guru + + \b Selected by : ColorTransformationSelector, ColorTransformationValueSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorTransformationValue; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Sets an integer value for the selected element in the color transformation matrix + + Sets an integer value for the selected element in the color transformation matrix. + + \b Visibility = Guru + + \b Selected by : ColorTransformationValueSelector + + */ + GENAPI_NAMESPACE::IInteger& ColorTransformationValueRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Defines the extent to which the selected light source will be considered (float) + + Sets a floating point value to define the extent to which the selected light source will be considered in color matrix transformation. + If the value is set to 1 the selected light source will be fully considered. If the value is set to 0 the selected light source will not be considered. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ColorTransformationMatrixFactor; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Defines the extent to which the selected light source will be considered (integer) + + Sets an integer value to define the extent to which the selected light source will be considered in color matrix transformation. If the value is set to 65536 the selected light source will be fully considered. If the value is set to 0 the selected light source will not be considered. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ColorTransformationMatrixFactorRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Enables color adjustment + + Enables color adjustment. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& ColorAdjustmentEnable; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Allows returning to previous settings + + Allows returning to the color adjustment settings extant before the latest changes of the settings. + This allows you undoing the latest unwanted changes of the color adjustment settings and returning to the preceding settings. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ColorAdjustmentReset; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Selects the color for color adjustment + + Selects the color for color adjustment. + Those colors in the image will be adjusted where the selected color predominates. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorAdjustmentSelector; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Adjustment of hue of the selected color (float) + + Sets a floating point value for the adjustment of hue of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorAdjustmentHue; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Adjustment of hue of the selected color (integer) + + Sets an integer value for the adjustment of hue of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IInteger& ColorAdjustmentHueRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Adjustment of saturation of the selected color (float) + + Sets a floating point value for the adjustment of saturation of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorAdjustmentSaturation; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Adjustment of saturation of the selected color (integer) + + Sets an integer value for the adjustment of saturation of the selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IInteger& ColorAdjustmentSaturationRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Hue shift to be applied. + + Adjusting the hue shifts the colors of the image. This can be useful, e.g., for correcting minor color shifts or creating false-color images. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslHue; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Hue shift to be applied. + + Adjusting the hue shifts the colors of the image. This can be useful, e.g., for correcting minor color shifts or creating false-color images. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BslHueRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Saturation to be applied. + + Adjusting the saturation changes the intensity of the colors. A higher saturation, for example, makes colors easier to distinguish. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslSaturation; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Saturation to be applied. + + Adjusting the saturation changes the intensity of the colors. A higher saturation, for example, makes colors easier to distinguish. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BslSaturationRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Brightness to be applied. + + Adjusting the brightness lightens or darkens the entire image. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslBrightness; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Brightness to be applied. + + Adjusting the brightness lightens or darkens the entire image. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BslBrightnessRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Contrast to be applied. + + Adjusting the contrast increases the difference between light and dark areas in the image. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslContrast; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Contrast to be applied. + + Adjusting the contrast increases the difference between light and dark areas in the image. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BslContrastRaw; + + //@} + + + //! \name ImageQualityControl - This category includes items that control image quality. + //@{ + /*! + \brief Sets the Contrast Mode. + + Sets the Contrast Mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BslContrastMode; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. + //@{ + /*! + \brief Sets the demosaicing mode. + + Sets the demosaicing mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& DemosaicingMode; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. + //@{ + /*! + \brief Enables Basler PGI image optimizations. + + Enables Basler PGI image optimizations. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PgiMode; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. + //@{ + /*! + \brief Amount of noise reduction to apply. + + Amount of noise reduction to apply. The higher the value, the less chroma noise will be visible in your images. However, too high values may result in image information loss. To enable this feature, the DemosaicingMode parameter must be set to BaslerPGI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& NoiseReductionAbs; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. + //@{ + /*! + \brief Amount of noise reduction to apply. + + Amount of noise reduction to apply. The higher the value, the less chroma noise will be visible in your images. However, too high values may result in image information loss. To enable this feature, the DemosaicingMode parameter must be set to BaslerPGI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& NoiseReductionRaw; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. + //@{ + /*! + \brief Amount of sharpening to apply. + + Amount of sharpening to apply. The higher the sharpness, the more distinct the image subject's contours will be. However, too high values may result in image information loss. To enable this feature, the DemosaicingMode parameter must be set to BaslerPGI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& SharpnessEnhancementAbs; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. + //@{ + /*! + \brief Amount of sharpening to apply. + + Amount of sharpening to apply. The higher the sharpness, the more distinct the image subject's contours will be. However, too high values may result in image information loss. To enable this feature, the DemosaicingMode parameter must be set to BaslerPGI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SharpnessEnhancementRaw; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Sets whether tonal range adjustment is used. + + Sets whether tonal range adjustment is used. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TonalRangeEnable; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Sets the operation mode of the Tonal Range Auto auto function. + + Sets the operation mode of the Tonal Range Auto auto function. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TonalRangeAuto; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Sets which pixel values are used for tonal range adjustments. + + Sets which pixel values are used for tonal range adjustments. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TonalRangeSelector; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Source value for tonal range adjustments at the bright end of the tonal range. + + Source value for tonal range adjustments at the bright end of the tonal range. When tonal range adjustments are enabled, the source and target values are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeSourceBright; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Source value for tonal range adjustments at the dark end of the tonal range. + + Source value for tonal range adjustments at the dark end of the tonal range. When tonal range adjustments are enabled, the source and target values are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeSourceDark; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Target value at the dark end of the tonal range to which pixel values should be mapped during tonal range adjustments. + + Target value at the dark end of the tonal range to which pixel values should be mapped during tonal range adjustments. When tonal range adjuments are enabled, the source and target values at the bright end are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeTargetBright; + + //@} + + + //! \name TonalRangeControl - Contains parameters for tonal range adjustments. + //@{ + /*! + \brief Target value at the bright end of the tonal range to which pixel values should be mapped during tonal range adjustments. + + Target value at the bright end of the tonal range to which pixel values should be mapped during tonal range adjustments. When tonal range adjustments are enabled, the source and target values at the dark end are compared and the tonal range is adjusted accordingly. The kind of adjustment depends on whether you want to adjust color or contrast or both, whether you want to adjust all pixel values or, e.g., only the red pixel values, and so on. + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeTargetDark; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the width of the area of interest in pixels + + This value sets the width of the area of interest in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Width; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the height of the area of interest in pixels + + This value sets the height of the area of interest in pixels. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Height; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the X offset (left offset) of the area of interest in pixels + + This value sets the X offset (left offset) for the area of interest in pixels, i.e., the distance in pixels between the left side of the sensor and the left side of the image area. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& OffsetX; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the Y offset (top offset) for the area of interest in pixels + + This value sets the Y offset (top offset) for the area of interest, i.e., the distance in pixels between the top of the sensor and the top of the image area. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& OffsetY; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Enables the horizontal centering of the image. + + This feature is used to center the image horizontally. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& CenterX; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Enables the vertical centering of the image. + + This feature is used to center the image vertically. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& CenterY; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the vertical binning feature + + This enumeration sets the vertical binning feature. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LegacyBinningVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the horizontal binning mode. + + This enumeration sets the horizontal binning mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningHorizontalMode; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the horizontal binning mode + + This enumeration sets the horizontal binning mode. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningModeHorizontal; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the number of adjacent horizontal pixes to be summed + + Sets the number of binned adjacent horizontal pixels. Their charges will be summed and reported out of the camera as a single pixel. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& BinningHorizontal; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the vertical binning mode. + + This enumeration sets the vertical binning mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningVerticalMode; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the vertical binning mode + + This enumeration sets the vertical binning mode. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningModeVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets the number of adjacent vertical pixes to be summed + + Sets the number of binned adjacent vertical pixels. Their charges will be summed and reported out of the camera as a single pixel. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& BinningVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets horizontal sub-sampling + + Horizontal sub-sampling of the image. This has the net effect of reducing the horizontal resolution (width) of the image by the specified horizontal decimation factor. A value of 1 indicates that the camera performs no horizontal decimation. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DecimationHorizontal; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets vertical sub-sampling + + Vertical sub-sampling of the image. This has the net effect of reducing the vertical resolution (height) of the image by the specified vertical decimation factor. A value of 1 indicates that the camera performs no vertical decimation. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DecimationVertical; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets vertical scaling factor + + This is a float value that sets the vertical scaling factor of the image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ScalingHorizontalAbs; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets vertical scaling factor + + This is a float value that sets the vertical scaling factor of the image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ScalingVerticalAbs; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets a ROI zone + + Sets a ROI zone to be enabled, configured, and assembled with other ROI zones. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ROIZoneSelector; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Provides for enabling/disabling a ROI zone. + + Provides for enabling/disabling the previously set ROI zone. + + \b Visibility = Expert + + \b Selected by : ROIZoneSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ROIZoneMode; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets a ROI zone size + + Sets the ROI zone 'thickness' (pixels, in direction of assembly) for the previously enabled ROI zone. Equivalent to Height for vertical zones. + + \b Visibility = Expert + + \b Selected by : ROIZoneSelector + + */ + GENAPI_NAMESPACE::IInteger& ROIZoneSize; + + //@} + + + //! \name AOI - This category includes items used to set the size and position of the area of interest + //@{ + /*! + \brief Sets a ROI zone offset + + Sets the ROI zone offset (pixels, in direction of assembly) for the previously enabled ROI zone. Equivalent to OffsetY for vertical zones. + + \b Visibility = Expert + + \b Selected by : ROIZoneSelector + + */ + GENAPI_NAMESPACE::IInteger& ROIZoneOffset; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Enables the stacked zone imaging feature. + + Enables the stacked zone imaging feature. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& StackedZoneImagingEnable; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief This value sets the zone to access. + + This value sets the zone to access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& StackedZoneImagingIndex; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Enables the selected zone. + + Enables the selected zone. + + \b Visibility = Beginner + + + \b Selected by : StackedZoneImagingIndex + + */ + GENAPI_NAMESPACE::IBoolean& StackedZoneImagingZoneEnable; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Sets the Y offset (top offset) for the selected zone. + + Sets the Y offset (top offset) for the selected zone. + + \b Visibility = Beginner + + + \b Selected by : StackedZoneImagingIndex + + */ + GENAPI_NAMESPACE::IInteger& StackedZoneImagingZoneOffsetY; + + //@} + + + //! \name StackedZoneImaging - + //@{ + /*! + \brief Sets the height for the selected zone. + + Sets the height for the selected zone. + + \b Visibility = Beginner + + + \b Selected by : StackedZoneImagingIndex + + */ + GENAPI_NAMESPACE::IInteger& StackedZoneImagingZoneHeight; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief When enabled, the maximum frame rate does not depend on the image transfer rate out of the camera. + + When enabled, the maximum frame rate onyl depends on sensor timing and timing of the trigger sequence, and not on the image transfer rate out of the camera. + + Note: The maximum number of triggers within a burst sequence is limited. If the maximum number is exceeded, images may be damaged or lost. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& EnableBurstAcquisition; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the image acquisition mode + + This enumeration sets the image acquisition mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Starts the acquisition of images + + This command starts the acquisition of images. If the camera is set for single frame acquisition, it will start acquisition of one frame. If the camera is set for continuous frame acquisition, it will start continuous acquisition of frames. + + \b Visibility = Beginner + + + \b Selected by : AcquisitionMode + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionStart; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Stops the acquisition of images + + If the camera is set for continuous image acquisition and acquisition has been started, this command stops the acquisition of images. + + \b Visibility = Beginner + + + \b Selected by : AcquisitionMode + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionStop; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Immediately aborts the acquisition of images + + This command will immediately abort any image acquisition process that is currently in progress. + + \b Visibility = Beginner + + + \b Selected by : AcquisitionMode + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionAbort; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the number of frames acquired in the multiframe acquisition mode + + This value sets the number of frames acquired in the multiframe acquisition mode + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionFrameCount; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerControlImplementation; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the trigger type to configure. Once a trigger type has been selected, all changes to the trigger settings will be applied to the selected trigger. + + This enumeration selects the trigger type to configure. Once a trigger type has been selected, all changes to the trigger settings will be applied to the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerControlImplementation + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerSelector; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the mode for the selected trigger + + This enumeration sets the trigger mode for the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Generates a software trigger signal that is used when the trigger source is set to 'software' + + This command generates a software trigger signal. The software trigger signal will be used if the trigger source is set to 'software'. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::ICommand& TriggerSoftware; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the signal source for the selected trigger + + This enumeration sets the signal source for the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerSource; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the signal transition needed to activate the selected trigger + + This enumeration sets the signal transition needed to activate the selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerActivation; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Determines whether a partial or complete frame is transmitted when the frame start trigger prematurely transitions. + + This feature determines whether a partial or a complete frame is transmitted when the frame start trigger is used with Level High or Level Low and when the frame start trigger signal transitions while the frame is still being acquired. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IBoolean& TriggerPartialClosingFrame; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the kind of trigger delay. + + Selects wheter trigger delay is defined as a time interval or as a number of consecutive line triggers. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerDelaySource; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the trigger delay time in microseconds. + + This float value sets the absolute trigger delay in microseconds to apply after the trigger reception before effectively activating it. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IFloat& TriggerDelayAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the trigger delay expressed as number of line triggers. + + This integer value sets the trigger delay expressed as a number of consecutive line triggers to apply after the trigger reception before effectively activating it. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IInteger& TriggerDelayLineTriggerCount; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureStartDelayAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureStartDelayRaw; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the exposure mode + + This enumeration sets the exposure mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the Interlaced Integration Mode. + + Selects the Interlaced Integration Mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& InterlacedIntegrationMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Exposure Auto is the 'automatic' counterpart to manually setting an 'absolute' exposure time. + + The exposure auto function automatically adjusts the Auto Exposure Time Abs parameter value within set limits, until a target average gray value for the pixel data of the related Auto Function AOI is reached. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureAuto; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the exposure time mode. + + Sets the exposure time mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureTimeMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Directly sets the camera's exposure time in microseconds + + This float value sets the camera's exposure time in microseconds. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureTimeAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the time base (in microseconds) that is used when the exposure time is set with the 'exposure time raw' setting + + This float value sets the time base (in microseconds) that is used when the exposure time is set with the 'raw' setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureTimeBaseAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables the use of the exposure time base + + This value enables the use of the exposure time base. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ExposureTimeBaseAbsEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the 'raw' exposure time. Actual exposure time = raw exposure setting x exposure time base abs setting + + This value sets an integer that will be used as a multiplier for the exposure timebase. The actual exposure time equals the current exposure time raw setting times the current exposure time base abs setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureTimeRaw; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the sensor readout time given the current settings. + + Indicates the sensor readout time given the current settings. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& ReadoutTimeAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Selects the Exposure Overlap Time Mode. + + Selects the manual or automatic control of the maximum overlap between immediately succeeding image acquisitions. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureOverlapTimeMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the maximum overlap of the sensor exposure with sensor readout in TriggerWidth exposure mode in microseconds + + This float value sets the maximum overlap time (in microseconds) of the sensor exposure with sensor readout in TriggerWidth exposure mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ExposureOverlapTimeMaxAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the maximum overlap of the sensor exposure with the sensor readout in TriggerWidth exposure mode in raw units. + + This integer value sets the maximum overlap time (in raw units) of the sensor exposure with sensor readout in TriggerWidth exposure mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ExposureOverlapTimeMaxRaw; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enable the Global Reset Release Mode + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IBoolean& GlobalResetReleaseModeEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the shutter mode + + This enumeration sets the shutter mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShutterMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the readout mode of the device + + Sets the readout mode of the device + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorReadoutMode; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the camera's acquisition line rate in lines per second + + Sets the 'absolute' value of the acquisition line rate. The 'absolute' value is a float value that sets the acquisition line rate in lines per second. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AcquisitionLineRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the minimum allowed line acquisition period (in microseconds) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the minimum allowed acquisition line period. The 'absolute' value is a float value that indicates the minimum allowed acquisition line period in microseconds given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ResultingLinePeriodAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the maximum allowed line acquisition rate (in lines per second) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the maximum allowed acquisition line rate. The 'absolute' value is a float value that indicates the maximum allowed acquisition line rate in lines per second given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ResultingLineRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables setting the camera's acquisition frame rate to a specified value + + This boolean value enables setting the camera's acquisition frame rate to a specified value. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& AcquisitionFrameRateEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief If the acquisition frame rate feature is enabled, this value sets the camera's acquisition frame rate in frames per second + + Sets the 'absolute' value of the acquisition frame rate. The 'absolute' value is a float value that sets the acquisition frame rate in frames per second. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AcquisitionFrameRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the minimum allowed frame acquisition period (in microseconds) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the minimum allowed acquisition frame period. The 'absolute' value is a float value that indicates the minimum allowed acquisition frame period in microseconds given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& ResultingFramePeriodAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Indicates the maximum allowed frame acquisition rate (in frames per second) given the current settings for the area of interest, exposure time, and bandwidth + + Indicates the 'absolute' value of the maximum allowed acquisition frame rate. The 'absolute' value is a float value that indicates the maximum allowed acquisition frame rate in frames per second given the current settings for the area of interest, exposure time, and bandwidth. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ResultingFrameRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief This enumeration is used to select which internal acquisition signal to read using AcquisitionStatus. + + This enumeration is used to select which internal acquisition signal to read using AcquisitionStatus. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionStatusSelector; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Reads the selected acquisition status + + This feature is used to read the state (True or False) of the internal acquisition signal selected using AcquisitionStatusSelector. + + \b Visibility = Expert + + \b Selected by : AcquisitionStatusSelector + + */ + GENAPI_NAMESPACE::IBoolean& AcquisitionStatus; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables the frame timeout + + This boolean value enables the frame timeout. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& FrameTimeoutEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Sets the frame timeout in microseconds. + + Sets the frame timeout in microseconds. When the timeout expires before a frame acquisition is complete, a partial frame will be delivered. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& FrameTimeoutAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Enables the synchronous free run mode + + When enabled the camera triggers with the specified frame rate derived from the synchronized clock. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& SyncFreeRunTimerEnable; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Synchronous free run trigger start time (low 32 bits) + + Low 32 bits of the synchronous free run trigger start time. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SyncFreeRunTimerStartTimeLow; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Synchronous free run trigger start time (high 32 bits) + + High 32 bits of the synchronous free run trigger start time. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SyncFreeRunTimerStartTimeHigh; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Synchronous free run trigger rate + + Trigger rate for the clock synchronous trigger. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& SyncFreeRunTimerTriggerRateAbs; + + //@} + + + //! \name AcquisitionTrigger - This category includes items used to set the image acquisition parameters and to start and stop acquisition + //@{ + /*! + \brief Activates the synchronous free run trigger settings + + Activates changed settings for the synchronous free run. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::ICommand& SyncFreeRunTimerUpdate; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Selects the I/O line to configure. Once a line has been selected, all changes to the line settings will be applied to the selected line. + + This enumeration selects the I/O line to configure. Once a line has been selected, all changes to the line settings will be applied to the selected line. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LineSelector; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the mode for the selected line + + This feature controls whether the physical Line is used to Input or Output a signal. When a Line supports input and output mode, the default state is Input to avoid possible electrical contention. Line Mode can take any of the following values: Input: The selected physical line is used to input an electrical signal. Output: The selected physical line is used to output an electrical signal. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineMode; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LineLogic; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the electrical configuration of the selected line + + This feature controls the current electrical format of the selected physical input or output Line. Line Format can take any of the following values: No Connect: The Line is not connected. Tri-state: The Line is currently in Tri-state mode (Not driven). TTL: The Line is currently accepting or sending TTL level signals. LVDS: The Line is currently accepting or sending LVDS level signals. RS-422: The Line is currently accepting or sending RS-422 level signals. Opto-coupled: The Line is Opto-coupled. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineFormat; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the source signal for the selected line (if the selected line is an output) + + This enumeration selects the internally generated camera signal (source signal) for the selected line when the selected line is an output. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineSource; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Enables the signal inverter function for the selected input or output line. + + This boolean value enables the signal inverter function for the selected input or output line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineInverter; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Enables the termination resistor for the selected input line. + + This boolean value enables the termination resistor for the selected input line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineTermination; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the absolute value of the selected line debouncer time in microseconds + + Sets the absolute value of the selected line debouncer time in microseconds + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IFloat& LineDebouncerTimeAbs; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the raw value of the selected line debouncer time + + Sets the raw value of the selected line debouncer time + + \b Visibility = Invisible + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IInteger& LineDebouncerTimeRaw; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the raw value for the minimum signal width of an output signal. + + This integer value sets the raw value for the minimum signal width of a signal that is received from the frequency converter or from the shaft encoder module and that is associated with a digital output line. + + \b Visibility = Invisible + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IInteger& MinOutPulseWidthRaw; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the absolute value (in microseconds) for the minimum signal width of an output signal. + + This float value sets the absolute value (in microseconds) for the minimum signal width of a signal that is received from the frequency converter or from the shaft encoder module and that is associated with a digital output line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IFloat& MinOutPulseWidthAbs; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Indicates the current logical state for the selected line + + This boolean value indicates the current logical state for the selected line at the time of polling. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineStatus; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief A single bitfield indicating the current logical state of all available line signals at time of polling + + This integer value is a single bitfield that indicates the current logical state of all available lines at time of polling. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LineStatusAll; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Selects the user settable output signal to configure. Once a user settable output signal has been selected, all changes to the user settable output signal settings will be applied to the selected user settable output signal. + + This enumeration selects the user settable output signal to configure. Once a user settable output signal has been selected, all changes to the user settable output signal settings will be applied to the selected user settable output signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserOutputSelector; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the state of the selected user settable output signal + + This boolean value sets the state of the selected user settable output signal. + + \b Visibility = Beginner + + + \b Selected by : UserOutputSelector + + */ + GENAPI_NAMESPACE::IBoolean& UserOutputValue; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief A single bitfield that sets the state of all user settable output signals in one access + + This integer value is a single bitfield that sets the state of all user settable output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& UserOutputValueAll; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Defines a mask that is used when the User Output Value All setting is used to set all of the user settable output signals in one access + + This integer value defines a mask that is used when the User Output Value All setting is used to set all of the user settable output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& UserOutputValueAllMask; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& SyncUserOutputSelector; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief Sets the state of the selected user settable synchronous output signal + + This boolean value sets the state of the selected user settable synchronous output signal. + + \b Visibility = Beginner + + + \b Selected by : SyncUserOutputSelector + + */ + GENAPI_NAMESPACE::IBoolean& SyncUserOutputValue; + + //@} + + + //! \name DigitalIO - This category includes items used to control the operation of the camera's digital I/O lines + //@{ + /*! + \brief A single bitfield that sets the state of all user settable synchronous output signals in one access + + This integer value is a single bitfield that sets the state of all user settable synchronous output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& SyncUserOutputValueAll; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Sets the I/O line on which the camera receives the virtual input signal + + This enumeration selects the I/O line on which the camera receives the virtual input signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& VInpSignalSource; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Sets the length of the input bit + + This integer value sets the length of the input bit in microseconds. It applies to all bits in the signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VInpBitLength; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Time span between the beginning of the input bit and the time when the high/low status is evaluated + + This integer value sets the time in microseconds that elapses between the beginning of the input bit and the time when the high/low status of the bit is evaluated. It applies to all bits. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VInpSamplingPoint; + + //@} + + + //! \name VirtualInput - This category includes items used to control the operation of the camera's virtual input I/O lines + //@{ + /*! + \brief Selects when to start the signal evaluation + + This enumeration selects when to start the signal evaluation. The camera waits for a rising/falling edge on the input line. When the appropriate signal has been received, the camera starts evaluating the incoming bit patterns. When one bit pattern is finished, the camera waits for the next rising/falling edge to read out the next incoming bit pattern. The camera stops listening once three bits have been received. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& VInpSignalReadoutActivation; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the phase of the shaft encoder. + + Selects the phase of the shaft encoder as input for the shaft encoder module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleLineSelector; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the input line as signal source for the shaft encoder module. + + Selects the input line as signal source for the shaft encoder module. + + \b Visibility = Expert + + \b Selected by : ShaftEncoderModuleLineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleLineSource; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the circumstances for the shaft encoder module to output trigger signals. + + This enumeration value selects the circumstances for the shaft encoder module to output trigger signals. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleMode; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Selects the counting mode of the tick counter. + + Selects the counting mode of the tick counter of the shaft encoder module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShaftEncoderModuleCounterMode; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Indicates the current value of the tick counter. + + This integer value (read only) indicates the current value of the tick counter of the shaft encoder module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& ShaftEncoderModuleCounter; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Sets the maximum value for the tick counter. + + This integer value sets the maximum value for the tick counter of the shaft encoder module (range: 0 to 32767). If the tick counter is incrementing and it reaches the set maximum, it willl roll over to 0. If the tick counter is decrementing and it reaches 0, it willl roll back to the set maximum. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& ShaftEncoderModuleCounterMax; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Resets the tick counter to 0. + + This command resets the tick counter count of the shaft encoder module to 0. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ShaftEncoderModuleCounterReset; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Sets the maximum value for the reverse counter. + + This integer value sets the maximum value for the reverse counter of the shaft encoder module (range: 0 to 32767). + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& ShaftEncoderModuleReverseCounterMax; + + //@} + + + //! \name ShaftEncoderModule - This category provides controls for operating the camera's shaft encoder module. + //@{ + /*! + \brief Resets the reverse counter to 0. + + This command resets the reverse counter of the shaft encoder module to 0 and informs the module that the current direction of conveyor movement is forward. Reset must be carried out before the first conveyor movement in the forward direction. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ShaftEncoderModuleReverseCounterReset; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Selects the input source. + + Selects the input source for the frequency converter module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& FrequencyConverterInputSource; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Selects the signal transition relationships between received and generated signals. + + Selects the signal transition relationships between the signals received from the pre-divider sub-module and the signals generated by the multiplier sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& FrequencyConverterSignalAlignment; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Sets the pre-divider value for the pre-divider sub-module. + + Sets an integer value as the pre-divider for the pre-divider sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& FrequencyConverterPreDivider; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Sets the multiplier value for the multiplier sub-module. + + Sets an integer value as the multiplier for the multiplier sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& FrequencyConverterMultiplier; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Sets the post-divider value for the post-divider sub-module. + + Sets an integer value as the post-divider for the post-divider sub-module. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& FrequencyConverterPostDivider; + + //@} + + + //! \name FrequencyConverter - This category includes items used to control the operation of the camera's frequency converter module + //@{ + /*! + \brief Enables overtriggering protection. + + This feature ensures that the multiplier sub-module does not provide a generated signal at a too high frequency that would cause camera overtriggering. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& FrequencyConverterPreventOvertrigger; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the time base (in microseconds) that is used when a timer delay is set with the 'timer delay raw' setting + + This float value sets the time base (in microseconds) that is used when a timer delay is set with the 'raw' setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& TimerDelayTimebaseAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the time base (in microseconds) that is used when a timer duration is set with the 'timer duration raw' setting + + This float value sets the time base (in microseconds) that is used when a timer duration is set with the 'raw' setting. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& TimerDurationTimebaseAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the timer to configure. Once a timer has been selected, all changes to the timer settings will be applied to the selected timer. + + This enumeration selects the timer to configure. . Once a timer has been selected, all changes to the timer settings will be applied to the selected timer. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSelector; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Directly sets the delay for the selected timer in microseconds + + This float value sets the delay for the selected timer in microseconds. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IFloat& TimerDelayAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the 'raw' delay for the selected timer. Actual delay = raw timer delay setting x timer delay time base abs setting + + This value sets an integer that will be used as a multiplier for the timer delay timebase. The actual delay time equals the current timer delay raw setting times the current timer delay time base abs setting. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerDelayRaw; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Directly sets the duration for the selected timer in microseconds + + This float value sets the duration for the selected timer in microseconds. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IFloat& TimerDurationAbs; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the 'raw' duration for the selected timer. Actual duration = raw timer duration setting x timer duration time base abs setting + + This value sets an integer that will be used as a multiplier for the timer duration timebase. The actual duration time equals the current timer duration raw setting times the current timer duration time base abs setting. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerDurationRaw; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the internal camera signal used to trigger the selected timer + + This enumeration sets the internal camera signal used to trigger the selected timer. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerTriggerSource; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Sets the type of signal transistion that will start the timer + + This enumeration sets the type of signal transistion that will start the timer. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerTriggerActivation; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the counter to configure. Once a counter has been selected, all changes to the counter settings will be applied to the selected counter. + + This enumeration selects the counter to configure. Once a counter has been selected, all changes to the counter settings will be applied to the selected counter. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterSelector; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the event that will be the source to increment the counter + + This enumeration selects the event that will be the source to increment the counter. + + \b Visibility = Expert + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterEventSource; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Selects the source of the reset for the selected counter. + + This enumeration selects the source of the reset for the selected counter. + + \b Visibility = Expert + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterResetSource; + + //@} + + + //! \name TimerControls - This category includes items used to control the operation of the camera's timers + //@{ + /*! + \brief Immediately resets the selected counter + + This command will immediately reset the selected counter. Note that the counter starts counting immediately after the reset. + + \b Visibility = Expert + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::ICommand& CounterReset; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& TimerSequenceEnable; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceLastEntryIndex; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceCurrentEntryIndex; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSequenceEntrySelector; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceEntrySelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSequenceTimerSelector; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IBoolean& TimerSequenceTimerEnable; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IBoolean& TimerSequenceTimerInverter; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceTimerDelayRaw; + + //@} + + + //! \name TimerSequence - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : TimerSequenceTimerSelector + + */ + GENAPI_NAMESPACE::IInteger& TimerSequenceTimerDurationRaw; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Selects the lookup table (LUT) to configure. Once a LUT has been selected, all changes to the LUT settings will be applied to the selected LUT. + + This enumeration the lookup table (LUT) to configure. Once a LUT has been selected, all changes to the LUT settings will be applied to the selected LUT. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LUTSelector; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Enables the selected LUT + + This boolean value enables the selected LUT. + + \b Visibility = Beginner + + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IBoolean& LUTEnable; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Sets the LUT element to access + + This value sets the LUT element to access. This value is used to index into a LUT array. + + \b Visibility = Beginner + + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IInteger& LUTIndex; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Sets the value of the LUT element at the LUT index + + This value sets the value of the LUT element at the LUT index. + + \b Visibility = Beginner + + + \b Selected by : LUTSelector, LUTIndex + + */ + GENAPI_NAMESPACE::IInteger& LUTValue; + + //@} + + + //! \name LUTControls - This category includes items used to control the operation of the camera's lookup table (LUT) + //@{ + /*! + \brief Accesses the entire content of the selected LUT in one chunk access + + + + \b Visibility = Beginner + + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IRegister& LUTValueAll; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Size of the payload in bytes + + Size of the payload in bytes. This is the total number of bytes sent in the payload. Image data + chunk data if present. No packet headers. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& PayloadSize; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the packet size in bytes for the selected stream channel + + This value sets the packet size in bytes for the selected stream channel. Excludes data leader and data trailer. (The last packet may be smaller because the packet size is not necessarily a multiple of the block size for the stream channel.) + + \b Visibility = Beginner + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCPSPacketSize; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the inter-packet delay (in ticks) for the selected stream channel + + This value sets a delay between the transmission of each packet for the selected stream channel. The delay is measured in ticks. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCPD; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the frame transfer start delay (in ticks) for the selected stream channel + + This value sets the frame transfer delay for the selected stream channel. This value sets a delay betweem when the camera would normally begin transmitted an acquired image (frame) and when it actually begins transmitting the acquired image. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCFTD; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets a percentage of the Ethernet bandwidth assigned to the camera to be held in reserve. The reserve is used for packet resends and control data transmissions. + + This value reserves a portion of Ethernet bandwidth assigned to the camera for packet resends and for the transmission of control data between the camera and the host PC. The setting is expressed as a percentage of the bandwidth assigned parameter. For example, if the Bandwidth Assigned parameter indicates that 30 MBytes/s have been assigned to the camera and the Bandwidth Reserve parameter is set to 5%, then the bandwidth reserve will be 1.5 MBytes/s. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCBWR; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets a multiplier for the Bandwidth Reserve parameter. The multiplier is used to establish an extra pool of reserved bandwidth that can be used if an unusually large burst of packet resends is needed. + + This value sets a multiplier for the Bandwidth Reserve parameter. The multiplier is used to establish an extra pool of reserved bandwidth that can be used if an unusually large burst of packet resends is needed. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCBWRA; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the bandwidth (in bytes per second) that will be used by the camera to transmit image and chunk feature data and to handle resends and control data transmissions. + + This value indicates the base bandwidth in bytes per second that will be used by the camera to transmit image and chunk feature data and to handle resends and control data transmissions. This parameter represents a combination of the packet size and the inter-packet delay. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCBWA; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the maximum amount of data (in bytes per second) that the camera could generate given its current settings and ideal conditions, i.e., unlimited bandwidth and no packet resends + + This value indicates the maximum amount of data (in bytes per second) that the camera could generate given its current settings and ideal conditions, i.e., unlimited bandwidth and no packet resends. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCDMT; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data given the current AOI settings, chunk feature settings, and the pixel format setting + + This value indicates the actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data given the current AOI settings, chunk feature settings, and the pixel format setting. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCDCT; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the maximum time (in ticks) that the next frame transmission could be delayed due to a burst of resends + + If the Bandwidth Reserve Accumulation parameter is set to a high value, the camera can experience periods where there is a large burst of data resends. This burst of resends will delay the start of transmission of the next acquired image. The Frame Max Jitter parameter indicates the maximum time in ticks that the next frame transmission could be delayed due to a burst of resends. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCFJM; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the major version number of the GigE Vision specification supported by this device. + + This is a read only element. It indicates the major version number of the GigE Vision specification supported by this device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevVersionMajor; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the minor version number of the GigE Vision specification supported by this device. + + This is a read only element. It indicates the minor version number of the GigE Vision specification supported by this device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevVersionMinor; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the endianess of the bootstrap registers. + + This is a read only element. It indicates the endianess of the bootstrap registers. True = big endian. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevDeviceModeIsBigEndian; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indictes the character set. + + This is a read only element. Its value indicates the character set. 1 = UTF8 + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevDeviceModeCharacterSet; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Selects the physical network interface to configure. Once a network interface has been selected, all changes to the network interface settings will be applied to the selected interface. + + This selects the physical network interface to configure. Once a network interface has been selected, all changes to the network interface settings will be applied to the selected interface. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& GevInterfaceSelector; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the MAC address for the selected network interface + + This is a read only element. It indicates the MAC address for the selected network interface. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevMACAddress; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Enable the extended ID mode for GVSP + + Enable extended ID mode for GVSP (64 bit block_id64, 32 bit packet_id32). This bit cannot be reset if the stream channels do not support the standard ID mode. + + \b Visibility = Expert + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& GevGVSPExtendedIDMode; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether the selected network interface supports auto IP addressing (also known as LLA) + + This is a read only element. It indicates whether the selected network interface supports auto IP addressing (also known as LLA). + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedIPConfigurationLLA; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether the selected network interface supports DHCP IP addressing + + This is a read only element. It indicates whether the selected network interface supports DHCP IP addressing. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedIPConfigurationDHCP; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether the selected network interface supports fixed IP addressing (also known as persistent IP addressing) + + This is a read only element. It indicates whether the selected network interface supports fixed IP addressing (also known as persistent IP addressing). + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedIPConfigurationPersistentIP; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the current IP configuration of the selected network interface + + This value sets the IP configuration of the selected network interface, i.e., fixed IP, DHCP, auto IP. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevCurrentIPConfiguration; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the current IP address for the selected network interface + + This is a read only element. It indicates the current IP address for the selected network interface. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevCurrentIPAddress; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the current subnet mask for the selected network interface + + This is a read only element. It indicates the current subnet mask for the selected network interface. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevCurrentSubnetMask; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the current default gateway for the selected network interface + + This is a read only element. It indicates the current default gateway for the selected network interface. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevCurrentDefaultGateway; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief If fixed (persistent) IP addressing is supported by the device and enabled, sets the fixed IP address for the selected network interface + + This value sets the fixed IP address for the selected network interface (if fixed IP addressing is supported by the device and enabled). + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevPersistentIPAddress; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief If fixed (persistent) IP addressing is supported by the device and enabled, sets the fixed subnet mask for the selected network interface + + This value sets the fixed subnet mask for the selected network interface (if fixed IP addressing is supported by the device and enabled). + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevPersistentSubnetMask; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief If fixed (persistent) IP addressing is supported by the device and enabled, sets the fixed default gateway for the selected network interface + + This value sets the fixed default gateway for the selected network interface (if fixed IP addressing is supported by the device and enabled). + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevPersistentDefaultGateway; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the connection speed in Mbps for the selected network interface + + This is a read only element. It indicates the connection speed in Mbps for the selected network interface. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IInteger& GevLinkSpeed; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether the selected network interface is the clock master. + + This is a read only element. It indicates whether the selected network interface is the clock master. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevLinkMaster; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether the selected network interface operates in full-duplex mode. + + This is a read only element. It indicates whether the selected network interface operates in full-duplex mode. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevLinkFullDuplex; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the state of medium-dependent interface crossover (MDIX) for the selected network interface. + + This is a read only element. It indicates the state of medium-dependent interface crossover (MDIX) for the selected network interface. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevLinkCrossover; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the first URL to the XML device description file + + This is a read only element. It indicates the first URL to the XML device description file. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IString& GevFirstURL; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the second URL to the XML device description file + + This is a read only element. It indicates the second URL to the XML device description file. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IString& GevSecondURL; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the number of network interfaces on the device + + This is a read only element. It indicates the number of network interfaces on the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevNumberOfInterfaces; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the number of message channels supported by the device + + This is a read only element. It indicates the number of message channels supported by the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevMessageChannelCount; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the number of stream channels supported by the device + + This is a read only element. It indicates the number of stream channels supported by the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevStreamChannelCount; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether this GVSP transmitter or receiver can support 16-bit block_id + + This is a read only element. It indicates whether this GVSP transmitter or rceiver can support 16-bit block_id. + + \b Visibility = Guru + + \b Selected by : GevInterfaceSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedOptionalLegacy16BitBlockID; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether IEEE 1588 (PTP) is supported + + This is a read only element. It indicates whether whether IEEE 1588 (PTP) is supported. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedIEEE1588; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether EVENTDATA_CMD and EVENTDATA_ACK are supported + + This is a read only element. It indicates whether EVENTDATA_CMD and EVENTDATA_ACK are supported. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedOptionalCommandsEVENTDATA; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether EVENT_CMD and EVENT_ACK are supported + + This is a read only element. It indicates whether EVENT_CMD and EVENT_ACK are supported. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedOptionalCommandsEVENT; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether PACKETRESEND_CMD is supported + + This is a read only element. It indicates whether PACKETRESEND_CMD is supported. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedOptionalCommandsPACKETRESEND; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether WRITEMEM_CMD and WRITEMEM_ACK are supported + + This is a read only element. It indicates whether WRITEMEM_CMD and WRITEMEM_ACK are supported + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedOptionalCommandsWRITEMEM; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether multiple operations in a single message are supported + + This is a read only element. It indicates whether multiple operations in a single message are supported. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& GevSupportedOptionalCommandsConcatenation; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the heartbeat timeout in milliseconds + + This value sets the heartbeat timeout in milliseconds. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevHeartbeatTimeout; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the number of timestamp clock ticks in 1 second + + This is a read only element. It indicates the number of timestamp clock ticks in 1 second. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevTimestampTickFrequency; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Latches the current timestamp value of the device + + This command latches the current timestamp value of the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& GevTimestampControlLatch; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Resets the timestamp value for the device + + This command resets the timestamp value for the device + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& GevTimestampControlReset; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Resets the timestamp control latch + + This command resets the timestamp control latch. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& GevTimestampControlLatchReset; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the latched value of the timestamp. (The timestamp must first be latched using the Timestamp Control Latch command.) + + This is a read only element. It indicates the latched value of the timestamp. (The timestamp must first be latched using the Timestamp Control Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevTimestampValue; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the control channel privilege feature + + This enumeration sets the control channel privilege feature. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& GevCCP; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Selects the stream channel to configure. Once a stream channel has been selected, all changes to the stream channel settings will be applied to the selected stream channel. + + This enumeration selects the stream channels to configure. Once a stream channel has been selected, all changes to the stream channel settings will be applied to the selected stream channel. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& GevStreamChannelSelector; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the index of the network interface to use + + This value sets the index of the network interface to use. + + \b Visibility = Guru + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCPInterfaceIndex; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the stream channel destination IPv4 address for the selected stream channel + + This value sets the stream channel destination IPv4 address for the selected stream channel. The destination can be a unicast or a multicast. + + \b Visibility = Guru + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCDA; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Sets the port to which the device must send data streams + + This value sets the port to which the device must send data streams. + + \b Visibility = Guru + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IInteger& GevSCPHostPort; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::ICommand& GevSCPSFireTestPacket; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevSCPSDoNotFragment; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : GevStreamChannelSelector + + */ + GENAPI_NAMESPACE::IBoolean& GevSCPSBigEndian; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates whether a live grab is under way + + + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& TLParamsLocked; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Select legacy pixel format encoding + + This switch selects a legacy GVSP pixel format encoding, for compatibility with older camera models. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& PixelFormatLegacy; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Enable usage of the IEEE 1588 V2 Precision Time Protocol to source the timestamp register. Only available when the IEEE1588_support bit of the GVCP Capability register is set. When PTP is enabled, the Timestamp Control register cannot be used to reset the timestamp. Factory default is devicespecific. When PTP is enabled or disabled, the value of Timestamp Tick Frequency and Timestamp Value registers might change to reflect the new time domain. + + This value indicates whether IEEE 1588 V2 (PTP) is enabled. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& GevIEEE1588; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Provides the state of the IEEE 1588 clock + + Provides the state of the IEEE 1588 clock. Values of this field must match the IEEE 1588 PTP port state enumeration (INITIALIZING, FAULTY, DISABLED, LISTENING, PRE_MASTER, MASTER, PASSIVE, UNCALIBRATED, SLAVE). Please refer to IEEE 1588 for additional information. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& GevIEEE1588Status; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Latches the current IEEE 1588 related values of the device + + This command latches the current IEEE 1588 related values of the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::ICommand& GevIEEE1588DataSetLatch; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the latched state of the IEEE 1588 clock + + This is a read only element. It indicates the latched state of the IEEE 1588 clock. (The state must first be latched using the IEEE 1588 Latch command.) The state is indicated by values 1 to 9, corresponding to the states INITIALIZING, FAULTY, DISABLED, LISTENING, PRE_MASTER, MASTER, PASSIVE, UNCALIBRATED, and SLAVE. Refer to the IEEE 1588 specification for additional information. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& GevIEEE1588StatusLatched; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. It indicates the latched offset from the IEEE 1588 master clock in nanoseconds. (The offset must first be latched using the IEEE 1588 Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588OffsetFromMaster; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. It is the low part of the 1588 clock ID + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588ClockIdLow; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. It is the high part of the 1588 clock ID + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588ClockIdHigh; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the latched clock ID of the IEEE 1588 device. + + This is a read only element. It indicates the latched clock ID of the IEEE 1588 device. (The clock ID must first be latched using the IEEE 1588 Latch command.) The clock ID is an array of eight octets which is displayed as hexadecimal number. Leading zeros are omitted. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588ClockId; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. It is the low part of the 1588 parent clock ID + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588ParentClockIdLow; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. It is the high part of the 1588 parent clock ID + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588ParentClockIdHigh; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief Indicates the latched parent clock ID of the IEEE 1588 device. + + This is a read only element. It indicates the latched parent clock ID of the IEEE 1588 device. (The parent clock ID must first be latched using the IEEE 1588 Latch command.) The parent clock ID is the clock ID of the current master clock. A clock ID is an array of eight octets which is displayed as hexadecimal number. Leading zeros are omitted. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevIEEE1588ParentClockId; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. Maximum number of elements in RX event message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevPTPDiagnosticsQueueRxEvntMaxNumElements; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. Maximum number of elements in RX general message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevPTPDiagnosticsQueueRxGnrlMaxNumElements; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. Number of push failures in RX event message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevPTPDiagnosticsQueueRxEvntPushNumFailure; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. Number of push failures in RX general message queue. (The value must first be latched using the IEEE 1588 Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevPTPDiagnosticsQueueRxGnrlPushNumFailure; + + //@} + + + //! \name TransportLayer - This category includes items related to the GigE Vision transport layer + //@{ + /*! + \brief + + This is a read only element. Number of send failures. (The value must first be latched using the IEEE 1588 Latch command.) + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& GevPTPDiagnosticsQueueSendNumFailure; + + //@} + + + //! \name ActionControl - This category includes items that control the action control feature + //@{ + /*! + \brief Number of separate action signals supported by the device. + + Number of separate action signals supported by the device. Determines how many action signals the device can handle in parallel, i.e. how many different action commands can be set up for the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& NumberOfActionSignals; + + //@} + + + //! \name ActionControl - This category includes items that control the action control feature + //@{ + /*! + \brief Number of action command interfaces + + Available number of action command interfaces on the camera device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ActionCommandCount; + + //@} + + + //! \name ActionControl - This category includes items that control the action control feature + //@{ + /*! + \brief Authorization key + + Key to authorize the action for the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ActionDeviceKey; + + //@} + + + //! \name ActionControl - This category includes items that control the action control feature + //@{ + /*! + \brief Selects the action command to configure. Once an action command has been selected, all changes to the action command settings will be applied to the selected action command. + + This enumeration selects the action command to configure. Once an action command has been selected, all changes to the action command settings will be applied to the selected action command. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ActionSelector; + + //@} + + + //! \name ActionControl - This category includes items that control the action control feature + //@{ + /*! + \brief Defines a group of devices + + Used to define a group of devices on which actions can be executed. + + \b Visibility = Guru + + \b Selected by : ActionSelector + + */ + GENAPI_NAMESPACE::IInteger& ActionGroupKey; + + //@} + + + //! \name ActionControl - This category includes items that control the action control feature + //@{ + /*! + \brief Filters out particular devices from its group + + Used to filter out some particular devices from the group of devices defined by the action group key. + + \b Visibility = Guru + + \b Selected by : ActionSelector + + */ + GENAPI_NAMESPACE::IInteger& ActionGroupMask; + + //@} + + + //! \name DeviceControl - + //@{ + /*! + \brief Prepare the device for registers streaming + + StartFeatureStreaming + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceRegistersStreamingStart; + + //@} + + + //! \name DeviceControl - + //@{ + /*! + \brief Announce the end of registers streaming + + StopFeatureStreaming + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceRegistersStreamingEnd; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Selects the configuration set to load, save, or configure. Once a configuration set has been selected, all changes to the configuration set settings will be applied to the selected configuration set. + + This enumeration selects the configuration set to load, save or configure. Possible values for the User Set Selector are: Default: Selects a configuration set that contains factory settings. User Set 1: Selects the first user set. When the Default configuration set is selected and loaded using User Set Load, the device must be in default factory settings state and must make sure the mandatory continuous acquisition use case works directly. Default User Set is read-only and cannot be modified. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserSetSelector; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Loads the selected configuration into the camera's volatile memory and makes it the active configuration set. Once the selected set is loaded, the parameters in the selected set will control the camera. + + This command loads the selected configuration set from the non-volatile memory in the camera to the volatile memory and makes the selected set the active configuration set. Once the selected set is loaded, the parameters in the selected set will control the camera. + + \b Visibility = Beginner + + + \b Selected by : UserSetSelector + + */ + GENAPI_NAMESPACE::ICommand& UserSetLoad; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Saves the current active configuration set into the selected user set. + + This command copies the parameters in the current active configuration set into the selected user set in the camera's non-volatile memory. + + \b Visibility = Beginner + + + \b Selected by : UserSetSelector + + */ + GENAPI_NAMESPACE::ICommand& UserSetSave; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Sets the configuration set to be used as the default startup set. The configuration set that has been selected as the default startup set will be loaded as the active set whenever the camera is powered on or reset. + + This enumeration sets the configuration set to be used as the default startup set. The configuration set that has been selected as the default startup set will be loaded as the active set whenever the camera is powered on or reset. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserSetDefaultSelector; + + //@} + + + //! \name UserSets - This category includes items that control the configuration sets feature that is used to save sets of parameters in the camera + //@{ + /*! + \brief Selects the which factory setting will be used as default set. + + Selects the which factory setting will be used as default set. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IEnumerationT& DefaultSetSelector; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Target average grey value for Gain Auto and Exposure Auto + + The target average grey value may range from nearly black to nearly white. Note that this range of gray values applies to 8 bit and to 16 bit (12 bit effective) output modes. Accordingly, also for 16 bit output modes, black is represented by 0 and white by 255. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoTargetValue; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Gray value adjustment damping for Gain Auto and Exposure Auto + + The gray value adjustment damping parameter controls the rate by which pixel gray values are changed when Exposure Auto and/or Gain Auto are enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& GrayValueAdjustmentDampingAbs; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Gray value adjustment damping for Gain Auto and Exposure Auto + + The gray value adjustment damping parameter controls the rate by which pixel gray values are changed when Exposure Auto and/or Gain Auto are enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& GrayValueAdjustmentDampingRaw; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Balance White adjustment damping for Balance White Auto + + The Balance White adjustment damping parameter controls the rate by which the color components are changed when Balance White Auto is enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& BalanceWhiteAdjustmentDampingAbs; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Balance White adjustment damping for Balance White Auto + + The Balance White adjustment damping parameter controls the rate by which the color components are changed when Balance White Auto is enabled. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& BalanceWhiteAdjustmentDampingRaw; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Lower limit of the Auto Gain (Raw) parameter + + Lower limit of the Auto Gain (Raw) parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoGainRawLowerLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Upper limit of the Auto Gain (Raw) parameter + + Upper limit of the Auto Gain (Raw) parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoGainRawUpperLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Lower limit of the Auto Exposure Time (Abs) [us] parameter + + Lower limit of the Auto Exposure Time (Abs) [us] parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoExposureTimeAbsLowerLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Upper limit of the Auto Exposure Time (Abs) [us] parameter + + Upper limit of the Auto Exposure Time (Abs) [us] parameter + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoExposureTimeAbsUpperLimit; + + //@} + + + //! \name AutoFunctions - This category includes items that parameterize the Auto Functions + //@{ + /*! + \brief Selects the strategy for controlling gain and shutter simultaneously. + + Selects the profile for controlling gain and shutter simultaneously. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionProfile; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Selects the Auto Function AOI. + + Selects the Auto Function AOI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionAOISelector; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the width of the auto function area of interest in pixels + + This value sets the width of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIWidth; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the height of the auto function area of interest in pixels + + This value sets the height of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIHeight; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the starting column of the auto function area of interest in pixels + + This value sets the starting column of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIOffsetX; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Sets the starting line of the auto function area of interest in pixels + + This value sets the starting line of the auto function area of interest in pixels. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIOffsetY; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageIntensity; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageWhiteBalance; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageRedLightCorrection; + + //@} + + + //! \name AutoFunctionAOIs - Portion of the sensor array used for auto function control + //@{ + /*! + \brief Assigns the Tonal Range Auto auto function to the currently selected auto function AOI. + + Assigns the Tonal Range Auto auto function to the currently selected auto function AOI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUsageTonalRange; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Sets the kind of tonal range auto adjustment. + + Sets the kind of tonal range auto adjustment. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoTonalRangeModeSelector; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Sets which parts of the tonal range can be adjusted. + + Sets which parts of the tonal range can be adjusted. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoTonalRangeAdjustmentSelector; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Threshold value from which the TonalRangeSourceDark parameter value is calculated during automatic tonal range adjustments. + + Threshold value from which the TonalRangeSourceDark parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned Auto Function ROI. Example: Assume you set the AutoTonalRangeThresholdDark parameter to 0.2 and enable the Tonal Range Auto auto function. Now assume that 0.2 % of the pixels in the assigned Auto Function ROI have a pixel value lower than or equal to 30. The camera automatically detects this, sets the TonalRangeSourceDark parameter to 30, and starts tonal range adjustments. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoTonalRangeThresholdDark; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Threshold value from which the TonalRangeSourceDark parameter value is calculated during automatic tonal range adjustments (raw value). + + Threshold value from which the TonalRangeSourceDark parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned Auto Function ROI. Example: Assume you set the AutoTonalRangeThresholdDark parameter to 0.2 and enable the Tonal Range Auto auto function. Now assume that 0.2 % of the pixels in the assigned Auto Function ROI have a pixel value lower than or equal to 30. The camera automatically detects this, sets the TonalRangeSourceDark parameter to 30, and starts tonal range adjustments. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoTonalRangeThresholdDarkRaw; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Threshold value from which the TonalRangeSourceBright parameter value is calculated during automatic tonal range adjustments. + + Threshold value from which the TonalRangeSourceBright parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned Auto Function ROI. Example: Assume you set the AutoTonalRangeThresholdBright parameter to 0.1 and enable the Tonal Range Auto auto function. Now assume that 0.1 % of the pixels in the assigned Auto Function ROI have a pixel value greater than or equal to 240. The camera automatically detects this, sets the TonalRangeSourceBright parameter to 240, and starts tonal range adjustments. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoTonalRangeThresholdBright; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Threshold value from which the TonalRangeSourceBright parameter value is calculated during automatic tonal range adjustments (raw value). + + Threshold value from which the TonalRangeSourceBright parameter value is calculated during automatic tonal range adjustments. The parameter is expressed as a percentage of all pixels in the assigned Auto Function ROI. Example: Assume you set the AutoTonalRangeThresholdBright parameter to 0.1 and enable the Tonal Range Auto auto function. Now assume that 0.1 % of the pixels in the assigned Auto Function ROI have a pixel value greater than or equal to 240. The camera automatically detects this, sets the TonalRangeSourceBright parameter to 240, and starts tonal range adjustments. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AutoTonalRangeThresholdBrightRaw; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Dark target value to be used during automatic tonal range adjustments. + + Dark target value to be used during automatic tonal range adjustments. When you enable the Tonal Range Auto auto function, the camera sets the TonalRangeTargetDark parameter to this value. Not available if the AutoTonalRangeModeSelector parameter is set to Color. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& AutoTonalRangeTargetDark; + + //@} + + + //! \name AutoTonalRangeControl - Contains parameters for configuring the Tonal Range Auto auto function. + //@{ + /*! + \brief Bright target value to be used during automatic tonal range adjustments. + + Bright target value to be used during automatic tonal range adjustments. When you enable the Tonal Range Auto auto function, the camera sets the TonalRangeTargetBright parameter to this value. Not available if the AutoTonalRangeModeSelector parameter is set to Color. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& AutoTonalRangeTargetBright; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Selcts the AOI for color overexposure compensation + + Selcts the area of interest where color overexposure compensation will be performed. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorOverexposureCompensationAOISelector; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Enables color overexposure compensation + + Enables color overexposure compensation. + + \b Visibility = Beginner + + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IBoolean& ColorOverexposureCompensationAOIEnable; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the color overexposure compensation factor for the selected C.O.C. AOI + + Sets the color overexposure compensation factor controlling the extent of compensation for the selected C.O.C. AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IFloat& ColorOverexposureCompensationAOIFactor; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the raw value for the color overexposure compensation factor + + Sets the raw value for the color overexposure compensation factor. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIFactorRaw; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the width for the selected C.O.C. AOI + + Sets the width for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIWidth; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the height for the selected C.O.C. AOI + + Sets the height for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIHeight; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the X offset for the selected C.O.C. AOI + + Sets the horizontal offset for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIOffsetX; + + //@} + + + //! \name ColorOverexposureCompensation - Compensates for deviations of hue resulting from overexposure + //@{ + /*! + \brief Sets the Y offset for the selected C.O.C. AOI + + Sets the vertical offset for the selected Color Overexposure Compensation AOI. + + \b Visibility = Guru + + \b Selected by : ColorOverexposureCompensationAOISelector + + */ + GENAPI_NAMESPACE::IInteger& ColorOverexposureCompensationAOIOffsetY; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Selects the kind of shading correction. + + This enumeration selects the kind of shading correction. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSelector; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Enables the selected kind of shading correction. + + This boolean value enables the selected kind of shading correction. + + \b Visibility = Beginner + + + \b Selected by : ShadingSelector + + */ + GENAPI_NAMESPACE::IBoolean& ShadingEnable; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Indicates error statuses related to shading correction. + + This enumeratuion indicates error statuses related to shading correction. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingStatus; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Selects the bootup shading set. + + This enumeration selects the shading set that will be loaded into the volatile memory during camera bootup. + + \b Visibility = Expert + + \b Selected by : ShadingSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSetDefaultSelector; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Selects the shading set to which the activate command will be applied. + + This enumeration selects the shading set to which the activate command will be applied. + + \b Visibility = Expert + + \b Selected by : ShadingSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSetSelector; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Activates the selected shading set. + + This command copies the selected shading set from the camera's non-volatile memory into the volatile memory. Shading correction is performed using the shading set in the volatile memory. + + \b Visibility = Expert + + \b Selected by : ShadingSetSelector + + */ + GENAPI_NAMESPACE::ICommand& ShadingSetActivate; + + //@} + + + //! \name Shading - Includes items used to control the operation of the camera's shading correction. + //@{ + /*! + \brief Creates a shading set. + + ShadingSetCreate + + \b Visibility = Expert + + \b Selected by : ShadingSetSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ShadingSetCreate; + + //@} + + + //! \name UserDefinedValues - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& UserDefinedValueSelector; + + //@} + + + //! \name UserDefinedValues - + //@{ + /*! + \brief + + + + \b Visibility = Guru + + \b Selected by : UserDefinedValueSelector + + */ + GENAPI_NAMESPACE::IInteger& UserDefinedValue; + + //@} + + + //! \name FeatureSets - + //@{ + /*! + \brief Select default genicam XML file + + If the camera contains multiple GenICam XML files, this parameter determines which of them is accessible to non-manifest-aware software accessing register address 0x0200 (first url). + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& GenicamXmlFileDefault; + + //@} + + + //! \name FeatureSets - + //@{ + /*! + \brief Select a camera description file + + Selects a feature set description file. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& FeatureSet; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the name of the device's vendor + + This is a read only element. It is a text description that indicates the name of the device's vendor. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceVendorName; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the model name of the device + + This is a read only element. It is a text description that indicates the model name of the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceModelName; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Provides additional information from the vendor about the device + + This is a read only element. It is a string that provides additional information from the vendor about the camera. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceManufacturerInfo; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the version of the device + + This is a read only element. It is a string that indicates the version of the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceVersion; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the version of the device's firmware and software + + This is a read only element. It is a string that indicates the version of the device's firmware and software. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceFirmwareVersion; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief A unique identifier for the device such as a serial number or a GUID + + This is a read only element. It is a string that provides a unique identifier for the device such as a serial number or a GUID. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceID; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief A device ID that is user programmable + + This is a read/write element. It is a user programmable string. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IString& DeviceUserID; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the scan type of the device's sensor + + This enumeration lists the possible scan types for the sensor in the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& DeviceScanType; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Immediately resets and reboots the device + + This is a command that immediately resets and reboots the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::ICommand& DeviceReset; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Lists the temperature sources available for readout + + Lists the temperature sources available for readout + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TemperatureSelector; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Shows the current temperature of the selected target in degrees centigrade + + Shows the current temperature of the selected target in degrees centigrade + + \b Visibility = Expert + + \b Selected by : TemperatureSelector + + */ + GENAPI_NAMESPACE::IFloat& TemperatureAbs; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Temperature State + + Temperature State + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TemperatureState; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Shows the over temperature state of the selected target + + Shows the over temperature state of the selected target + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& CriticalTemperature; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Shows the over temperature state of the selected target + + Shows the over temperature state of the selected target + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& OverTemperature; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Indicates the error that was detected last + + Indicates the error that was detected last. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& LastError; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Erases the last error and possibly reveals a previous error + + Erases the last error and possibly reveals a previous error. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& ClearLastError; + + //@} + + + //! \name DeviceInformation - This category includes items that describe the device and its sensor + //@{ + /*! + \brief Version of the color modifications applied to images. + + Version of the color modifications applied to images. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DeviceColorPipelineVersion; + + //@} + + + //! \name RemoveParamLimits - This category includes items that allow removing the limits of camera parameters + //@{ + /*! + \brief Selects the parameter to configure. Once a parameter has been selected, all changes made using the Remove Limits feature will be applied to the selected parameter + + This enumeration selects the parameter to configure. Selects the parameter to configure. Once a parameter has been selected, all changes made using the Remove Limits feature will be applied to the selected parameter + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ParameterSelector; + + //@} + + + //! \name RemoveParamLimits - This category includes items that allow removing the limits of camera parameters + //@{ + /*! + \brief Removes the factory-set limits of the selected parameter. + + Removes the factory-set limits of the selected parameter. Having removed the factory-set limits you may set the parameter within extended limits. These are only defined by technical restrictions. Note: Inferior image quality may result. + + \b Visibility = Guru + + \b Selected by : ParameterSelector + + */ + GENAPI_NAMESPACE::IBoolean& RemoveLimits; + + //@} + + + //! \name RemoveParamLimits - This category includes items that allow removing the limits of camera parameters + //@{ + /*! + \brief Sets the number of prelines + + This value sets the number of prelines. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& Prelines; + + //@} + + + //! \name ExpertFeatureAccess - + //@{ + /*! + \brief Selects the feature to configure. Once a feature has been selected, all changes made using the feature enable feature will be applied to the selected feature + + Selects the feature to configure. Once a feature has been selected, all changes made using the feature enable feature will be applied to the selected feature + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ExpertFeatureAccessSelector; + + //@} + + + //! \name ExpertFeatureAccess - + //@{ + /*! + \brief Sets the key to access the selected feature + + Sets the key to access the selected feature + + \b Visibility = Guru + + \b Selected by : ExpertFeatureAccessSelector + + */ + GENAPI_NAMESPACE::IInteger& ExpertFeatureAccessKey; + + //@} + + + //! \name ExpertFeatureAccess - + //@{ + /*! + \brief Enable the selected Feature + + Enable the selected Feature + + \b Visibility = Guru + + \b Selected by : ExpertFeatureAccessSelector + + */ + GENAPI_NAMESPACE::IBoolean& ExpertFeatureEnable; + + //@} + + + //! \name ChunkDataStreams - This category includes items that control the chunk features available on the camera. + //@{ + /*! + \brief Enables the chunk mode + + This boolean value enables the camera's chunk mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ChunkModeActive; + + //@} + + + //! \name ChunkDataStreams - This category includes items that control the chunk features available on the camera. + //@{ + /*! + \brief Selects chunks for enabling. + + This enumeration selects chunks for enabling. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ChunkSelector; + + //@} + + + //! \name ChunkDataStreams - This category includes items that control the chunk features available on the camera. + //@{ + /*! + \brief Enables the inclusion of the selected chunk in the payload data + + This boolean value enables the inclusion of the selected chunk in the payload data. + + \b Visibility = Beginner + + + \b Selected by : ChunkSelector + + */ + GENAPI_NAMESPACE::IBoolean& ChunkEnable; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the number of bytes of data between the beginning of one line in the acquired image and the beginning of the next line in the acquired image + + This value indicates the number of bytes of data between the beginning of one line in the acquired image and the beginning of the next line in the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkStride; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the sequence set index number related to the acquired image + + This value indicates the sequence set index number related to the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkSequenceSetIndex; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the X offset of the area of interest represented in the acquired image + + This value Indicates the X offset of the area of interest represented in the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkOffsetX; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the Y offset of the area of interest represented in the acquired image + + This value Indicates the Y offset of the area of interest represented in the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkOffsetY; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the widtth of the area of interest represented in the acquired image. + + This value Indicates the width of the area of interest represented in the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkWidth; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the height of the area of interest represented in the acquired image. + + This value Indicates the height of the area of interest represented in the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkHeight; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the minimum possible pixel value in the acquired image + + This value indicates the minimum possible pixel value in the acquired image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkDynamicRangeMin; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the maximum possible pixel value in the acquired image + + This value indicates indicates the maximum possible pixel value acquired in the image + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkDynamicRangeMax; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the format of the pixel data in the acquired image + + This enumeration lists the pixel formats that can be indicated by the pixel format chunk. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ChunkPixelFormat; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of the timestamp when the image was acquired + + This integer indicates the value of the timestamp when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkTimestamp; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of the frame counter when the image was acquired + + This integer indicates the value of the frame counter when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFramecounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief A bit field that indicates the status of all of the camera's input and output lines when the image was acquired + + This value is a bit field that indicates the status of all of the camera's input and output lines when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineStatusAll; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief A bit field that indicates the status of all of the camera's virtual input and output lines when the image was acquired + + This value is a bit field that indicates the status of all of the camera's virtual input and output lines when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkVirtLineStatusAll; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of the trigger input counter when the image was acquired + + This integer indicates the value of the trigger input counter when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkTriggerinputcounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineTriggerIgnoredCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFrameTriggerIgnoredCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFrameTriggerCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFramesPerTriggerCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineTriggerEndToEndCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Number of bits per status + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkInputStatusAtLineTriggerBitsPerLine; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Used to select a certain status + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkInputStatusAtLineTriggerIndex; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Value of the status selected by 'Index' + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkInputStatusAtLineTriggerValue; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Shaft encoder counter at frame trigger + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkShaftEncoderCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ChunkExposureTime; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of CRC checksum + + This integer indicates the value of CRC checksum. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkPayloadCRC16; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkGainAll; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineTriggerCounter; + + //@} + + + //! \name EventsGeneration - This category includes items that control event generation by the camera. + //@{ + /*! + \brief Selects the type of event for enabling. + + This enumeration selects the type of event for enabling. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& EventSelector; + + //@} + + + //! \name EventsGeneration - This category includes items that control event generation by the camera. + //@{ + /*! + \brief Sets the notification type that will be sent to the host application for the selected event + + This enumeration sets the notification type that will be sent to the host application for the selected event. + + \b Visibility = Beginner + + + \b Selected by : EventSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& EventNotification; + + //@} + + + //! \name ExposureEndEventData - This category includes items available for an exposure end event + //@{ + /*! + \brief Indicates the stream channel index for an exposure end event + + This enumeration value indicates the stream channel index for an exposure end event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureEndEventStreamChannelIndex; + + //@} + + + //! \name ExposureEndEventData - This category includes items available for an exposure end event + //@{ + /*! + \brief Indicates the frame ID for an exposure end event + + This enumeration value indicates the frame ID for an exposure end event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureEndEventFrameID; + + //@} + + + //! \name ExposureEndEventData - This category includes items available for an exposure end event + //@{ + /*! + \brief Indicates the time stamp for an exposure end event + + This enumeration value indicates the time stamp for an exposure end event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ExposureEndEventTimestamp; + + //@} + + + //! \name LineStartOvertriggerEventData - This category includes items available for an line start overtrigger event + //@{ + /*! + \brief Indicates the stream channel index for an line start overtrigger event + + This enumeration Indicates the stream channel index for an line start overtrigger event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LineStartOvertriggerEventStreamChannelIndex; + + //@} + + + //! \name LineStartOvertriggerEventData - This category includes items available for an line start overtrigger event + //@{ + /*! + \brief Indicates the time stamp for an line start overtrigger event + + This enumeration value indicates the time stamp for an line start overtrigger event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LineStartOvertriggerEventTimestamp; + + //@} + + + //! \name FrameStartOvertriggerEventData - This category includes items available for an frame start overtrigger event + //@{ + /*! + \brief Indicates the stream channel index for an frame start overtrigger event + + This enumeration Indicates the stream channel index for an frame start overtrigger event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameStartOvertriggerEventStreamChannelIndex; + + //@} + + + //! \name FrameStartOvertriggerEventData - This category includes items available for an frame start overtrigger event + //@{ + /*! + \brief Indicates the time stamp for an frame start overtrigger event + + This enumeration value indicates the time stamp for an frame start overtrigger event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameStartOvertriggerEventTimestamp; + + //@} + + + //! \name FrameStartEventData - This category includes items available for an frame start event + //@{ + /*! + \brief Indicates the stream channel index for an frame start event + + This enumeration Indicates the stream channel index for an frame start event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameStartEventStreamChannelIndex; + + //@} + + + //! \name FrameStartEventData - This category includes items available for an frame start event + //@{ + /*! + \brief Indicates the time stamp for an frame start event + + This enumeration value indicates the time stamp for an frame start event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameStartEventTimestamp; + + //@} + + + //! \name AcquisitionStartEventData - This category includes items available for an acquisition start event + //@{ + /*! + \brief Indicates the stream channel index for an acquisition start event + + This enumeration Indicates the stream channel index for an acquisition start event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionStartEventStreamChannelIndex; + + //@} + + + //! \name AcquisitionStartEventData - This category includes items available for an acquisition start event + //@{ + /*! + \brief Indicates the time stamp for an acquisition start event + + This enumeration value indicates the time stamp for an acquisition start event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionStartEventTimestamp; + + //@} + + + //! \name AcquisitionStartOvertriggerEventData - This category includes items available for an acquisition start overtrigger event + //@{ + /*! + \brief Indicates the stream channel index for an acquisition start overtrigger event + + This enumeration Indicates the stream channel index for an acquisition start overtrigger event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionStartOvertriggerEventStreamChannelIndex; + + //@} + + + //! \name AcquisitionStartOvertriggerEventData - This category includes items available for an acquisition start overtrigger event + //@{ + /*! + \brief Indicates the time stamp for an Acquisition start overtrigger event + + This enumeration value indicates the time stamp for an Acquisition start overtrigger event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionStartOvertriggerEventTimestamp; + + //@} + + + //! \name FrameTimeoutEventData - This category includes items available for an frame timeout event + //@{ + /*! + \brief Indicates the stream channel index for an frame timeout event + + This enumeration Indicates the stream channel index for an frame timeout event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameTimeoutEventStreamChannelIndex; + + //@} + + + //! \name FrameTimeoutEventData - This category includes items available for an frame timeout event + //@{ + /*! + \brief Indicates the time stamp for an frame timeout event + + This enumeration value indicates the time stamp for an frame timeout event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameTimeoutEventTimestamp; + + //@} + + + //! \name EventOverrunEventData - This category includes items available for an event overrun event + //@{ + /*! + \brief Indicates the stream channel index for an event overrun event + + This enumeration value indicates the stream channel index for an event overrun event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventOverrunEventStreamChannelIndex; + + //@} + + + //! \name EventOverrunEventData - This category includes items available for an event overrun event + //@{ + /*! + \brief Indicates the frame ID for an event overrun event + + This enumeration value indicates the frame ID for an event overrun event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventOverrunEventFrameID; + + //@} + + + //! \name EventOverrunEventData - This category includes items available for an event overrun event + //@{ + /*! + \brief Indicates the time stamp for an event overrun event + + This enumeration value indicates the time stamp for an event overrun event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventOverrunEventTimestamp; + + //@} + + + //! \name CriticalTemperatureEventData - This category includes items available for a critical temperature event + //@{ + /*! + \brief Indicates the stream channel index for a critical temperature event + + This enumeration Indicates the stream channel index for a critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& CriticalTemperatureEventStreamChannelIndex; + + //@} + + + //! \name CriticalTemperatureEventData - This category includes items available for a critical temperature event + //@{ + /*! + \brief Indicates the time stamp for a critical temperature event + + This enumeration value indicates the time stamp for a critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& CriticalTemperatureEventTimestamp; + + //@} + + + //! \name OverTemperatureEventData - This category includes items available for an over temperature event + //@{ + /*! + \brief Indicates the stream channel index for an over temperature event + + This enumeration Indicates the stream channel index for an over temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& OverTemperatureEventStreamChannelIndex; + + //@} + + + //! \name OverTemperatureEventData - This category includes items available for an over temperature event + //@{ + /*! + \brief Indicates the time stamp for an over temperature event + + This enumeration value indicates the time stamp for an over temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& OverTemperatureEventTimestamp; + + //@} + + + //! \name ActionLateEventData - Contains parameters available for a action late event. + //@{ + /*! + \brief Stream channel index of the action late event. + + Stream channel index of the action late event. A action late event is raised when a scheduled action command with a timestamp in the past is received. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ActionLateEventStreamChannelIndex; + + //@} + + + //! \name ActionLateEventData - Contains parameters available for a action late event. + //@{ + /*! + \brief Time stamp of the action late event. + + Time stamp of the action late event. A action late event is raised when a scheduled action command with a timestamp in the past is received. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ActionLateEventTimestamp; + + //@} + + + //! \name LateActionEventData - TODO + //@{ + /*! + \brief Indicates the stream channel index for a critical temperature event + + This enumeration Indicates the stream channel index for a critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LateActionEventStreamChannelIndex; + + //@} + + + //! \name LateActionEventData - TODO + //@{ + /*! + \brief Indicates the time stamp for a critical temperature event + + This enumeration value indicates the time stamp for a critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LateActionEventTimestamp; + + //@} + + + //! \name Line1RisingEdgeEventData - This category includes items available for an io line 1 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 1 rising edge event + + This enumeration Indicates the stream channel index for an io line 1 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line1RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Line1RisingEdgeEventData - This category includes items available for an io line 1 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 1 rising edge event + + This enumeration value indicates the time stamp for an io line 1 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line1RisingEdgeEventTimestamp; + + //@} + + + //! \name Line2RisingEdgeEventData - This category includes items available for an io line 2 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 2 rising edge event + + This enumeration Indicates the stream channel index for an io line 2 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line2RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Line2RisingEdgeEventData - This category includes items available for an io line 2 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 2 rising edge event + + This enumeration value indicates the time stamp for an io line 2 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line2RisingEdgeEventTimestamp; + + //@} + + + //! \name Line3RisingEdgeEventData - This category includes items available for an io line 3 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 3 rising edge event + + This enumeration Indicates the stream channel index for an io line 3 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line3RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Line3RisingEdgeEventData - This category includes items available for an io line 3 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 3 rising edge event + + This enumeration value indicates the time stamp for an io line 3 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line3RisingEdgeEventTimestamp; + + //@} + + + //! \name Line4RisingEdgeEventData - This category includes items available for an io line 4 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io line 4 rising edge event + + This enumeration Indicates the stream channel index for an io line 4 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line4RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name Line4RisingEdgeEventData - This category includes items available for an io line 4 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a line 4 rising edge event + + This enumeration value indicates the time stamp for an io line 4 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& Line4RisingEdgeEventTimestamp; + + //@} + + + //! \name VirtualLine1RisingEdgeEventData - This category includes items available for an io virtual line 1 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 1 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 1 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine1RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name VirtualLine1RisingEdgeEventData - This category includes items available for an io virtual line 1 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 1 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 1 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine1RisingEdgeEventTimestamp; + + //@} + + + //! \name VirtualLine2RisingEdgeEventData - This category includes items available for an io virtual line 2 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 2 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 2 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine2RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name VirtualLine2RisingEdgeEventData - This category includes items available for an io virtual line 2 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 2 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 2 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine2RisingEdgeEventTimestamp; + + //@} + + + //! \name VirtualLine3RisingEdgeEventData - This category includes items available for an io virtual line 3 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 3 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 3 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine3RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name VirtualLine3RisingEdgeEventData - This category includes items available for an io virtual line 3 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 3 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 3 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine3RisingEdgeEventTimestamp; + + //@} + + + //! \name VirtualLine4RisingEdgeEventData - This category includes items available for an io virtual line 4 rising edge event + //@{ + /*! + \brief Indicates the stream channel index for an io virtual line 4 rising edge event + + This enumeration Indicates the stream channel index for an io virtual line 4 rising edge event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine4RisingEdgeEventStreamChannelIndex; + + //@} + + + //! \name VirtualLine4RisingEdgeEventData - This category includes items available for an io virtual line 4 rising edge event + //@{ + /*! + \brief Indicates the time stamp for a virtual line 4 rising edge event + + This enumeration value indicates the time stamp for an io virtual line 4 rising edge event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& VirtualLine4RisingEdgeEventTimestamp; + + //@} + + + //! \name FrameWaitEventData - This category includes items available for an frame wait event + //@{ + /*! + \brief Indicates the stream channel index for an frame wait event + + This enumeration Indicates the stream channel index for an frame wait event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameWaitEventStreamChannelIndex; + + //@} + + + //! \name FrameWaitEventData - This category includes items available for an frame wait event + //@{ + /*! + \brief Indicates the time stamp for an frame wait event + + This enumeration value indicates the time stamp for an frame wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameWaitEventTimestamp; + + //@} + + + //! \name AcquisitionWaitEventData - This category includes items available for an acquisition wait event + //@{ + /*! + \brief Indicates the stream channel index for an acquisition wait event + + This enumeration Indicates the stream channel index for an acquisition wait event + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionWaitEventStreamChannelIndex; + + //@} + + + //! \name AcquisitionWaitEventData - This category includes items available for an acquisition wait event + //@{ + /*! + \brief Indicates the time stamp for an acquisition wait event + + This enumeration value indicates the time stamp for an acquisition wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionWaitEventTimestamp; + + //@} + + + //! \name FrameStartWaitEventData - Contains parameters available for a frame start wait event. + //@{ + /*! + \brief Stream channel index of the frame start wait event. + + Stream channel index of the frame start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameStartWaitEventStreamChannelIndex; + + //@} + + + //! \name FrameStartWaitEventData - Contains parameters available for a frame start wait event. + //@{ + /*! + \brief Time stamp of the frame start wait event. + + Time stamp of the frame start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& FrameStartWaitEventTimestamp; + + //@} + + + //! \name AcquisitionStartWaitEventData - Contains parameters available for an acquisition start wait event. + //@{ + /*! + \brief Stream channel index of the acquisition start wait event. + + Stream channel index of the acquisition start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionStartWaitEventStreamChannelIndex; + + //@} + + + //! \name AcquisitionStartWaitEventData - Contains parameters available for an acquisition start wait event. + //@{ + /*! + \brief Time stamp of the acquisition start wait event. + + Time stamp of the acquisition start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionStartWaitEventTimestamp; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief This feature selects the target file in the device + + The File Selector feature selects the target file in the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& FileSelector; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Selects the target operation for the selected file + + The File Operation Selector feature selects the target operation for the selected file in the device. This Operation is executed when the FileOperationExecute feature is called. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOperationSelector; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Selects the access mode in which a file is opened + + The File Open Mode feature selects the access mode in which a file is opened in the device. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOpenMode; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Defines the intermediate access buffer + + The File Access Buffer feature defines the intermediate access buffer that allows the exchange of data between the device file storage and the application. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IRegister& FileAccessBuffer; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Controls the mapping between the device file storage and the FileAccessBuffer + + This feature controls the mapping between the device file storage and the FileAccessBuffer. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileAccessOffset; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Controls the mapping between the device file storage and the FileAccessBuffer + + This feature controls the mapping between the device file storage and the FileAccessBuffer. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileAccessLength; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Represents the file operation execution status + + The File Operation Status feature represents the file operation execution status. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOperationStatus; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Represents the file operation result + + The File Operation Result feature represents the file operation result. For Read or Write operations, the number of successfully read/written bytes is returned. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileOperationResult; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Represents the size of the selected file + + The File Size feature represents the size of the selected file in bytes. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IInteger& FileSize; + + //@} + + + //! \name FileAccessControl - This category includes items used to conduct file operations + //@{ + /*! + \brief Executes the selected operation + + The File Operation Execute feature is the command that executes the operation selected by FileOperationSelector on the selected file. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::ICommand& FileOperationExecute; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CGigECamera_Params( CGigECamera_Params& ); + + //! not implemented assignment operator + CGigECamera_Params& operator=( CGigECamera_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CGigECamera_Params::CGigECamera_Params( void ) + : SequenceEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SequenceCurrentSet( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceConfigurationMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceAsyncRestart( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceAsyncAdvance( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceSetTotalNumber( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceSetIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceSetStore( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceSetLoad( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequenceSetExecutions( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequenceAdvanceMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceControlSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceControlSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceAddressBitSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequenceAddressBitSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GainAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , BlackLevelSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BlackLevelRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BlackLevelAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , GammaEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GammaSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , Gamma( *new GENAPI_NAMESPACE::CFloatRef() ) + , DigitalShift( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SubstrateVoltage( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SensorBitDepth( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SensorDigitizationTaps( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelCoding( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelSize( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelColorFilter( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ProcessedRawEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , PixelDynamicRangeMin( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PixelDynamicRangeMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SpatialCorrection( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SpatialCorrectionAmount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SpatialCorrectionStartingLine( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ReverseX( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ReverseY( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FieldOutputMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TestImageSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TestImageResetAndHold( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SensorWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SensorHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , WidthMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , HeightMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LightSourceSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceWhiteReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , BalanceWhiteAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceRatioSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceRatioAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , BalanceRatioRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorTransformationSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorTransformationValueSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorTransformationValue( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorTransformationValueRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorTransformationMatrixFactor( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorTransformationMatrixFactorRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorAdjustmentEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ColorAdjustmentReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , ColorAdjustmentSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorAdjustmentHue( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorAdjustmentHueRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorAdjustmentSaturation( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorAdjustmentSaturationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslHue( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslHueRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslSaturation( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslSaturationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslBrightness( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslBrightnessRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslContrast( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslContrastRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslContrastMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DemosaicingMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PgiMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , NoiseReductionAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , NoiseReductionRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SharpnessEnhancementAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , SharpnessEnhancementRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeEnable( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TonalRangeAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TonalRangeSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TonalRangeSourceBright( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeSourceDark( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeTargetBright( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeTargetDark( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Width( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Height( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , CenterX( *new GENAPI_NAMESPACE::CBooleanRef() ) + , CenterY( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LegacyBinningVertical( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningHorizontalMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningModeHorizontal( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningHorizontal( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BinningVerticalMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningModeVertical( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningVertical( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DecimationHorizontal( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DecimationVertical( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ScalingHorizontalAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ScalingVerticalAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ROIZoneSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ROIZoneMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ROIZoneSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ROIZoneOffset( *new GENAPI_NAMESPACE::CIntegerRef() ) + , StackedZoneImagingEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , StackedZoneImagingIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , StackedZoneImagingZoneEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , StackedZoneImagingZoneOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , StackedZoneImagingZoneHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EnableBurstAcquisition( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AcquisitionMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionStart( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionStop( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionAbort( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionFrameCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TriggerControlImplementation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerSoftware( *new GENAPI_NAMESPACE::CCommandRef() ) + , TriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerPartialClosingFrame( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TriggerDelaySource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TriggerDelayLineTriggerCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExposureStartDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureStartDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExposureMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , InterlacedIntegrationMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureTimeMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureTimeAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureTimeBaseAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureTimeBaseAbsEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ExposureTimeRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ReadoutTimeAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureOverlapTimeMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureOverlapTimeMaxAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureOverlapTimeMaxRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GlobalResetReleaseModeEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ShutterMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SensorReadoutMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionLineRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingLinePeriodAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingLineRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionFrameRateEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AcquisitionFrameRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingFramePeriodAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingFrameRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionStatusSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FrameTimeoutEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FrameTimeoutAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , SyncFreeRunTimerEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SyncFreeRunTimerStartTimeLow( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SyncFreeRunTimerStartTimeHigh( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SyncFreeRunTimerTriggerRateAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , SyncFreeRunTimerUpdate( *new GENAPI_NAMESPACE::CCommandRef() ) + , LineSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineLogic( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineInverter( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineTermination( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineDebouncerTimeAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineDebouncerTimeRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MinOutPulseWidthRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MinOutPulseWidthAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserOutputSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserOutputValue( *new GENAPI_NAMESPACE::CBooleanRef() ) + , UserOutputValueAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserOutputValueAllMask( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SyncUserOutputSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SyncUserOutputValue( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SyncUserOutputValueAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VInpSignalSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , VInpBitLength( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VInpSamplingPoint( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VInpSignalReadoutActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleLineSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleLineSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleCounterMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShaftEncoderModuleCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShaftEncoderModuleCounterMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShaftEncoderModuleCounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , ShaftEncoderModuleReverseCounterMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShaftEncoderModuleReverseCounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , FrequencyConverterInputSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FrequencyConverterSignalAlignment( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FrequencyConverterPreDivider( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrequencyConverterMultiplier( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrequencyConverterPostDivider( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrequencyConverterPreventOvertrigger( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerDelayTimebaseAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDurationTimebaseAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerDelayAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerDurationAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDurationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerTriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerTriggerActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterEventSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterResetSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , TimerSequenceEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerSequenceLastEntryIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerSequenceCurrentEntryIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerSequenceEntrySelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerSequenceTimerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerSequenceTimerEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerSequenceTimerInverter( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TimerSequenceTimerDelayRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TimerSequenceTimerDurationRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LUTEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LUTIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTValueAll( *new GENAPI_NAMESPACE::CRegisterRef() ) + , PayloadSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCPSPacketSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCPD( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCFTD( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCBWR( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCBWRA( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCBWA( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCDMT( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCDCT( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCFJM( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevVersionMajor( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevVersionMinor( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevDeviceModeIsBigEndian( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevDeviceModeCharacterSet( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevInterfaceSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GevMACAddress( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevGVSPExtendedIDMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GevSupportedIPConfigurationLLA( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedIPConfigurationDHCP( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedIPConfigurationPersistentIP( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevCurrentIPConfiguration( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevCurrentIPAddress( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevCurrentSubnetMask( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevCurrentDefaultGateway( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPersistentIPAddress( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPersistentSubnetMask( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPersistentDefaultGateway( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevLinkSpeed( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevLinkMaster( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevLinkFullDuplex( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevLinkCrossover( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevFirstURL( *new GENAPI_NAMESPACE::CStringRef() ) + , GevSecondURL( *new GENAPI_NAMESPACE::CStringRef() ) + , GevNumberOfInterfaces( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevMessageChannelCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevStreamChannelCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSupportedOptionalLegacy16BitBlockID( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedIEEE1588( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedOptionalCommandsEVENTDATA( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedOptionalCommandsEVENT( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedOptionalCommandsPACKETRESEND( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedOptionalCommandsWRITEMEM( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSupportedOptionalCommandsConcatenation( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevHeartbeatTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevTimestampTickFrequency( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevTimestampControlLatch( *new GENAPI_NAMESPACE::CCommandRef() ) + , GevTimestampControlReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , GevTimestampControlLatchReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , GevTimestampValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevCCP( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GevStreamChannelSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GevSCPInterfaceIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCDA( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCPHostPort( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevSCPSFireTestPacket( *new GENAPI_NAMESPACE::CCommandRef() ) + , GevSCPSDoNotFragment( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevSCPSBigEndian( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TLParamsLocked( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PixelFormatLegacy( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevIEEE1588( *new GENAPI_NAMESPACE::CBooleanRef() ) + , GevIEEE1588Status( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GevIEEE1588DataSetLatch( *new GENAPI_NAMESPACE::CCommandRef() ) + , GevIEEE1588StatusLatched( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GevIEEE1588OffsetFromMaster( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevIEEE1588ClockIdLow( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevIEEE1588ClockIdHigh( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevIEEE1588ClockId( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevIEEE1588ParentClockIdLow( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevIEEE1588ParentClockIdHigh( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevIEEE1588ParentClockId( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPTPDiagnosticsQueueRxEvntMaxNumElements( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPTPDiagnosticsQueueRxGnrlMaxNumElements( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPTPDiagnosticsQueueRxEvntPushNumFailure( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPTPDiagnosticsQueueRxGnrlPushNumFailure( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GevPTPDiagnosticsQueueSendNumFailure( *new GENAPI_NAMESPACE::CIntegerRef() ) + , NumberOfActionSignals( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionCommandCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionDeviceKey( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionSelector( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionGroupKey( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionGroupMask( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceRegistersStreamingStart( *new GENAPI_NAMESPACE::CCommandRef() ) + , DeviceRegistersStreamingEnd( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserSetLoad( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetSave( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetDefaultSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DefaultSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTargetValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GrayValueAdjustmentDampingAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , GrayValueAdjustmentDampingRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BalanceWhiteAdjustmentDampingAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , BalanceWhiteAdjustmentDampingRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoGainRawLowerLimit( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoGainRawUpperLimit( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoExposureTimeAbsLowerLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoExposureTimeAbsUpperLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoFunctionProfile( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoFunctionAOISelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoFunctionAOIWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionAOIUsageIntensity( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionAOIUsageWhiteBalance( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionAOIUsageRedLightCorrection( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionAOIUsageTonalRange( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoTonalRangeModeSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTonalRangeAdjustmentSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTonalRangeThresholdDark( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoTonalRangeThresholdDarkRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoTonalRangeThresholdBright( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoTonalRangeThresholdBrightRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoTonalRangeTargetDark( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoTonalRangeTargetBright( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOISelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorOverexposureCompensationAOIEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ColorOverexposureCompensationAOIFactor( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorOverexposureCompensationAOIFactorRaw( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ColorOverexposureCompensationAOIOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ShadingSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ShadingStatus( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingSetDefaultSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ShadingSetActivate( *new GENAPI_NAMESPACE::CCommandRef() ) + , ShadingSetCreate( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserDefinedValueSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserDefinedValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GenicamXmlFileDefault( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FeatureSet( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceVendorName( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceModelName( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceManufacturerInfo( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceVersion( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceFirmwareVersion( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceID( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceUserID( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceScanType( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , TemperatureSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TemperatureAbs( *new GENAPI_NAMESPACE::CFloatRef() ) + , TemperatureState( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CriticalTemperature( *new GENAPI_NAMESPACE::CBooleanRef() ) + , OverTemperature( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LastError( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ClearLastError( *new GENAPI_NAMESPACE::CCommandRef() ) + , DeviceColorPipelineVersion( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ParameterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , RemoveLimits( *new GENAPI_NAMESPACE::CBooleanRef() ) + , Prelines( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExpertFeatureAccessSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExpertFeatureAccessKey( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExpertFeatureEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ChunkModeActive( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ChunkSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ChunkStride( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkSequenceSetIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkDynamicRangeMin( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkDynamicRangeMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkPixelFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFramecounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkVirtLineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkTriggerinputcounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineTriggerIgnoredCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFrameTriggerIgnoredCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFrameTriggerCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFramesPerTriggerCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineTriggerEndToEndCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkInputStatusAtLineTriggerBitsPerLine( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkInputStatusAtLineTriggerIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkInputStatusAtLineTriggerValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkShaftEncoderCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkExposureTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , ChunkPayloadCRC16( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkGainAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineTriggerCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , EventNotification( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureEndEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExposureEndEventFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExposureEndEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LineStartOvertriggerEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LineStartOvertriggerEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameStartOvertriggerEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameStartOvertriggerEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameStartEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameStartEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionStartEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionStartEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionStartOvertriggerEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionStartOvertriggerEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameTimeoutEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameTimeoutEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventOverrunEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventOverrunEventFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventOverrunEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , CriticalTemperatureEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , CriticalTemperatureEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OverTemperatureEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OverTemperatureEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionLateEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ActionLateEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LateActionEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LateActionEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line1RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line1RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line2RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line2RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line3RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line3RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line4RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Line4RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine1RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine1RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine2RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine2RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine3RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine3RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine4RisingEdgeEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , VirtualLine4RisingEdgeEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameWaitEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameWaitEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionWaitEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionWaitEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameStartWaitEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameStartWaitEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionStartWaitEventStreamChannelIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AcquisitionStartWaitEventTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOperationSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOpenMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileAccessBuffer( *new GENAPI_NAMESPACE::CRegisterRef() ) + , FileAccessOffset( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileAccessLength( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileOperationStatus( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOperationResult( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileOperationExecute( *new GENAPI_NAMESPACE::CCommandRef() ) + + { + } + + inline CGigECamera_Params::~CGigECamera_Params( void ) + { + delete static_cast (&SequenceEnable); + delete static_cast (&SequenceCurrentSet); + delete static_cast *> (&SequenceConfigurationMode); + delete static_cast (&SequenceAsyncRestart); + delete static_cast (&SequenceAsyncAdvance); + delete static_cast (&SequenceSetTotalNumber); + delete static_cast (&SequenceSetIndex); + delete static_cast (&SequenceSetStore); + delete static_cast (&SequenceSetLoad); + delete static_cast (&SequenceSetExecutions); + delete static_cast *> (&SequenceAdvanceMode); + delete static_cast *> (&SequenceControlSelector); + delete static_cast *> (&SequenceControlSource); + delete static_cast *> (&SequenceAddressBitSelector); + delete static_cast *> (&SequenceAddressBitSource); + delete static_cast *> (&GainAuto); + delete static_cast *> (&GainSelector); + delete static_cast (&GainRaw); + delete static_cast (&GainAbs); + delete static_cast *> (&BlackLevelSelector); + delete static_cast (&BlackLevelRaw); + delete static_cast (&BlackLevelAbs); + delete static_cast (&GammaEnable); + delete static_cast *> (&GammaSelector); + delete static_cast (&Gamma); + delete static_cast (&DigitalShift); + delete static_cast (&SubstrateVoltage); + delete static_cast *> (&SensorBitDepth); + delete static_cast *> (&SensorDigitizationTaps); + delete static_cast *> (&PixelFormat); + delete static_cast *> (&PixelCoding); + delete static_cast *> (&PixelSize); + delete static_cast *> (&PixelColorFilter); + delete static_cast (&ProcessedRawEnable); + delete static_cast (&PixelDynamicRangeMin); + delete static_cast (&PixelDynamicRangeMax); + delete static_cast (&SpatialCorrection); + delete static_cast (&SpatialCorrectionAmount); + delete static_cast *> (&SpatialCorrectionStartingLine); + delete static_cast (&ReverseX); + delete static_cast (&ReverseY); + delete static_cast *> (&FieldOutputMode); + delete static_cast *> (&TestImageSelector); + delete static_cast (&TestImageResetAndHold); + delete static_cast (&SensorWidth); + delete static_cast (&SensorHeight); + delete static_cast (&WidthMax); + delete static_cast (&HeightMax); + delete static_cast *> (&LightSourceSelector); + delete static_cast (&BalanceWhiteReset); + delete static_cast *> (&BalanceWhiteAuto); + delete static_cast *> (&BalanceRatioSelector); + delete static_cast (&BalanceRatioAbs); + delete static_cast (&BalanceRatioRaw); + delete static_cast *> (&ColorTransformationSelector); + delete static_cast *> (&ColorTransformationValueSelector); + delete static_cast (&ColorTransformationValue); + delete static_cast (&ColorTransformationValueRaw); + delete static_cast (&ColorTransformationMatrixFactor); + delete static_cast (&ColorTransformationMatrixFactorRaw); + delete static_cast (&ColorAdjustmentEnable); + delete static_cast (&ColorAdjustmentReset); + delete static_cast *> (&ColorAdjustmentSelector); + delete static_cast (&ColorAdjustmentHue); + delete static_cast (&ColorAdjustmentHueRaw); + delete static_cast (&ColorAdjustmentSaturation); + delete static_cast (&ColorAdjustmentSaturationRaw); + delete static_cast (&BslHue); + delete static_cast (&BslHueRaw); + delete static_cast (&BslSaturation); + delete static_cast (&BslSaturationRaw); + delete static_cast (&BslBrightness); + delete static_cast (&BslBrightnessRaw); + delete static_cast (&BslContrast); + delete static_cast (&BslContrastRaw); + delete static_cast *> (&BslContrastMode); + delete static_cast *> (&DemosaicingMode); + delete static_cast *> (&PgiMode); + delete static_cast (&NoiseReductionAbs); + delete static_cast (&NoiseReductionRaw); + delete static_cast (&SharpnessEnhancementAbs); + delete static_cast (&SharpnessEnhancementRaw); + delete static_cast *> (&TonalRangeEnable); + delete static_cast *> (&TonalRangeAuto); + delete static_cast *> (&TonalRangeSelector); + delete static_cast (&TonalRangeSourceBright); + delete static_cast (&TonalRangeSourceDark); + delete static_cast (&TonalRangeTargetBright); + delete static_cast (&TonalRangeTargetDark); + delete static_cast (&Width); + delete static_cast (&Height); + delete static_cast (&OffsetX); + delete static_cast (&OffsetY); + delete static_cast (&CenterX); + delete static_cast (&CenterY); + delete static_cast *> (&LegacyBinningVertical); + delete static_cast *> (&BinningHorizontalMode); + delete static_cast *> (&BinningModeHorizontal); + delete static_cast (&BinningHorizontal); + delete static_cast *> (&BinningVerticalMode); + delete static_cast *> (&BinningModeVertical); + delete static_cast (&BinningVertical); + delete static_cast (&DecimationHorizontal); + delete static_cast (&DecimationVertical); + delete static_cast (&ScalingHorizontalAbs); + delete static_cast (&ScalingVerticalAbs); + delete static_cast *> (&ROIZoneSelector); + delete static_cast *> (&ROIZoneMode); + delete static_cast (&ROIZoneSize); + delete static_cast (&ROIZoneOffset); + delete static_cast (&StackedZoneImagingEnable); + delete static_cast (&StackedZoneImagingIndex); + delete static_cast (&StackedZoneImagingZoneEnable); + delete static_cast (&StackedZoneImagingZoneOffsetY); + delete static_cast (&StackedZoneImagingZoneHeight); + delete static_cast (&EnableBurstAcquisition); + delete static_cast *> (&AcquisitionMode); + delete static_cast (&AcquisitionStart); + delete static_cast (&AcquisitionStop); + delete static_cast (&AcquisitionAbort); + delete static_cast (&AcquisitionFrameCount); + delete static_cast *> (&TriggerControlImplementation); + delete static_cast *> (&TriggerSelector); + delete static_cast *> (&TriggerMode); + delete static_cast (&TriggerSoftware); + delete static_cast *> (&TriggerSource); + delete static_cast *> (&TriggerActivation); + delete static_cast (&TriggerPartialClosingFrame); + delete static_cast *> (&TriggerDelaySource); + delete static_cast (&TriggerDelayAbs); + delete static_cast (&TriggerDelayLineTriggerCount); + delete static_cast (&ExposureStartDelayAbs); + delete static_cast (&ExposureStartDelayRaw); + delete static_cast *> (&ExposureMode); + delete static_cast *> (&InterlacedIntegrationMode); + delete static_cast *> (&ExposureAuto); + delete static_cast *> (&ExposureTimeMode); + delete static_cast (&ExposureTimeAbs); + delete static_cast (&ExposureTimeBaseAbs); + delete static_cast (&ExposureTimeBaseAbsEnable); + delete static_cast (&ExposureTimeRaw); + delete static_cast (&ReadoutTimeAbs); + delete static_cast *> (&ExposureOverlapTimeMode); + delete static_cast (&ExposureOverlapTimeMaxAbs); + delete static_cast (&ExposureOverlapTimeMaxRaw); + delete static_cast (&GlobalResetReleaseModeEnable); + delete static_cast *> (&ShutterMode); + delete static_cast *> (&SensorReadoutMode); + delete static_cast (&AcquisitionLineRateAbs); + delete static_cast (&ResultingLinePeriodAbs); + delete static_cast (&ResultingLineRateAbs); + delete static_cast (&AcquisitionFrameRateEnable); + delete static_cast (&AcquisitionFrameRateAbs); + delete static_cast (&ResultingFramePeriodAbs); + delete static_cast (&ResultingFrameRateAbs); + delete static_cast *> (&AcquisitionStatusSelector); + delete static_cast (&AcquisitionStatus); + delete static_cast (&FrameTimeoutEnable); + delete static_cast (&FrameTimeoutAbs); + delete static_cast (&SyncFreeRunTimerEnable); + delete static_cast (&SyncFreeRunTimerStartTimeLow); + delete static_cast (&SyncFreeRunTimerStartTimeHigh); + delete static_cast (&SyncFreeRunTimerTriggerRateAbs); + delete static_cast (&SyncFreeRunTimerUpdate); + delete static_cast *> (&LineSelector); + delete static_cast *> (&LineMode); + delete static_cast *> (&LineLogic); + delete static_cast *> (&LineFormat); + delete static_cast *> (&LineSource); + delete static_cast (&LineInverter); + delete static_cast (&LineTermination); + delete static_cast (&LineDebouncerTimeAbs); + delete static_cast (&LineDebouncerTimeRaw); + delete static_cast (&MinOutPulseWidthRaw); + delete static_cast (&MinOutPulseWidthAbs); + delete static_cast (&LineStatus); + delete static_cast (&LineStatusAll); + delete static_cast *> (&UserOutputSelector); + delete static_cast (&UserOutputValue); + delete static_cast (&UserOutputValueAll); + delete static_cast (&UserOutputValueAllMask); + delete static_cast *> (&SyncUserOutputSelector); + delete static_cast (&SyncUserOutputValue); + delete static_cast (&SyncUserOutputValueAll); + delete static_cast *> (&VInpSignalSource); + delete static_cast (&VInpBitLength); + delete static_cast (&VInpSamplingPoint); + delete static_cast *> (&VInpSignalReadoutActivation); + delete static_cast *> (&ShaftEncoderModuleLineSelector); + delete static_cast *> (&ShaftEncoderModuleLineSource); + delete static_cast *> (&ShaftEncoderModuleMode); + delete static_cast *> (&ShaftEncoderModuleCounterMode); + delete static_cast (&ShaftEncoderModuleCounter); + delete static_cast (&ShaftEncoderModuleCounterMax); + delete static_cast (&ShaftEncoderModuleCounterReset); + delete static_cast (&ShaftEncoderModuleReverseCounterMax); + delete static_cast (&ShaftEncoderModuleReverseCounterReset); + delete static_cast *> (&FrequencyConverterInputSource); + delete static_cast *> (&FrequencyConverterSignalAlignment); + delete static_cast (&FrequencyConverterPreDivider); + delete static_cast (&FrequencyConverterMultiplier); + delete static_cast (&FrequencyConverterPostDivider); + delete static_cast (&FrequencyConverterPreventOvertrigger); + delete static_cast (&TimerDelayTimebaseAbs); + delete static_cast (&TimerDurationTimebaseAbs); + delete static_cast *> (&TimerSelector); + delete static_cast (&TimerDelayAbs); + delete static_cast (&TimerDelayRaw); + delete static_cast (&TimerDurationAbs); + delete static_cast (&TimerDurationRaw); + delete static_cast *> (&TimerTriggerSource); + delete static_cast *> (&TimerTriggerActivation); + delete static_cast *> (&CounterSelector); + delete static_cast *> (&CounterEventSource); + delete static_cast *> (&CounterResetSource); + delete static_cast (&CounterReset); + delete static_cast (&TimerSequenceEnable); + delete static_cast (&TimerSequenceLastEntryIndex); + delete static_cast (&TimerSequenceCurrentEntryIndex); + delete static_cast *> (&TimerSequenceEntrySelector); + delete static_cast *> (&TimerSequenceTimerSelector); + delete static_cast (&TimerSequenceTimerEnable); + delete static_cast (&TimerSequenceTimerInverter); + delete static_cast (&TimerSequenceTimerDelayRaw); + delete static_cast (&TimerSequenceTimerDurationRaw); + delete static_cast *> (&LUTSelector); + delete static_cast (&LUTEnable); + delete static_cast (&LUTIndex); + delete static_cast (&LUTValue); + delete static_cast (&LUTValueAll); + delete static_cast (&PayloadSize); + delete static_cast (&GevSCPSPacketSize); + delete static_cast (&GevSCPD); + delete static_cast (&GevSCFTD); + delete static_cast (&GevSCBWR); + delete static_cast (&GevSCBWRA); + delete static_cast (&GevSCBWA); + delete static_cast (&GevSCDMT); + delete static_cast (&GevSCDCT); + delete static_cast (&GevSCFJM); + delete static_cast (&GevVersionMajor); + delete static_cast (&GevVersionMinor); + delete static_cast (&GevDeviceModeIsBigEndian); + delete static_cast (&GevDeviceModeCharacterSet); + delete static_cast *> (&GevInterfaceSelector); + delete static_cast (&GevMACAddress); + delete static_cast *> (&GevGVSPExtendedIDMode); + delete static_cast (&GevSupportedIPConfigurationLLA); + delete static_cast (&GevSupportedIPConfigurationDHCP); + delete static_cast (&GevSupportedIPConfigurationPersistentIP); + delete static_cast (&GevCurrentIPConfiguration); + delete static_cast (&GevCurrentIPAddress); + delete static_cast (&GevCurrentSubnetMask); + delete static_cast (&GevCurrentDefaultGateway); + delete static_cast (&GevPersistentIPAddress); + delete static_cast (&GevPersistentSubnetMask); + delete static_cast (&GevPersistentDefaultGateway); + delete static_cast (&GevLinkSpeed); + delete static_cast (&GevLinkMaster); + delete static_cast (&GevLinkFullDuplex); + delete static_cast (&GevLinkCrossover); + delete static_cast (&GevFirstURL); + delete static_cast (&GevSecondURL); + delete static_cast (&GevNumberOfInterfaces); + delete static_cast (&GevMessageChannelCount); + delete static_cast (&GevStreamChannelCount); + delete static_cast (&GevSupportedOptionalLegacy16BitBlockID); + delete static_cast (&GevSupportedIEEE1588); + delete static_cast (&GevSupportedOptionalCommandsEVENTDATA); + delete static_cast (&GevSupportedOptionalCommandsEVENT); + delete static_cast (&GevSupportedOptionalCommandsPACKETRESEND); + delete static_cast (&GevSupportedOptionalCommandsWRITEMEM); + delete static_cast (&GevSupportedOptionalCommandsConcatenation); + delete static_cast (&GevHeartbeatTimeout); + delete static_cast (&GevTimestampTickFrequency); + delete static_cast (&GevTimestampControlLatch); + delete static_cast (&GevTimestampControlReset); + delete static_cast (&GevTimestampControlLatchReset); + delete static_cast (&GevTimestampValue); + delete static_cast *> (&GevCCP); + delete static_cast *> (&GevStreamChannelSelector); + delete static_cast (&GevSCPInterfaceIndex); + delete static_cast (&GevSCDA); + delete static_cast (&GevSCPHostPort); + delete static_cast (&GevSCPSFireTestPacket); + delete static_cast (&GevSCPSDoNotFragment); + delete static_cast (&GevSCPSBigEndian); + delete static_cast (&TLParamsLocked); + delete static_cast (&PixelFormatLegacy); + delete static_cast (&GevIEEE1588); + delete static_cast *> (&GevIEEE1588Status); + delete static_cast (&GevIEEE1588DataSetLatch); + delete static_cast *> (&GevIEEE1588StatusLatched); + delete static_cast (&GevIEEE1588OffsetFromMaster); + delete static_cast (&GevIEEE1588ClockIdLow); + delete static_cast (&GevIEEE1588ClockIdHigh); + delete static_cast (&GevIEEE1588ClockId); + delete static_cast (&GevIEEE1588ParentClockIdLow); + delete static_cast (&GevIEEE1588ParentClockIdHigh); + delete static_cast (&GevIEEE1588ParentClockId); + delete static_cast (&GevPTPDiagnosticsQueueRxEvntMaxNumElements); + delete static_cast (&GevPTPDiagnosticsQueueRxGnrlMaxNumElements); + delete static_cast (&GevPTPDiagnosticsQueueRxEvntPushNumFailure); + delete static_cast (&GevPTPDiagnosticsQueueRxGnrlPushNumFailure); + delete static_cast (&GevPTPDiagnosticsQueueSendNumFailure); + delete static_cast (&NumberOfActionSignals); + delete static_cast (&ActionCommandCount); + delete static_cast (&ActionDeviceKey); + delete static_cast (&ActionSelector); + delete static_cast (&ActionGroupKey); + delete static_cast (&ActionGroupMask); + delete static_cast (&DeviceRegistersStreamingStart); + delete static_cast (&DeviceRegistersStreamingEnd); + delete static_cast *> (&UserSetSelector); + delete static_cast (&UserSetLoad); + delete static_cast (&UserSetSave); + delete static_cast *> (&UserSetDefaultSelector); + delete static_cast *> (&DefaultSetSelector); + delete static_cast (&AutoTargetValue); + delete static_cast (&GrayValueAdjustmentDampingAbs); + delete static_cast (&GrayValueAdjustmentDampingRaw); + delete static_cast (&BalanceWhiteAdjustmentDampingAbs); + delete static_cast (&BalanceWhiteAdjustmentDampingRaw); + delete static_cast (&AutoGainRawLowerLimit); + delete static_cast (&AutoGainRawUpperLimit); + delete static_cast (&AutoExposureTimeAbsLowerLimit); + delete static_cast (&AutoExposureTimeAbsUpperLimit); + delete static_cast *> (&AutoFunctionProfile); + delete static_cast *> (&AutoFunctionAOISelector); + delete static_cast (&AutoFunctionAOIWidth); + delete static_cast (&AutoFunctionAOIHeight); + delete static_cast (&AutoFunctionAOIOffsetX); + delete static_cast (&AutoFunctionAOIOffsetY); + delete static_cast (&AutoFunctionAOIUsageIntensity); + delete static_cast (&AutoFunctionAOIUsageWhiteBalance); + delete static_cast (&AutoFunctionAOIUsageRedLightCorrection); + delete static_cast (&AutoFunctionAOIUsageTonalRange); + delete static_cast *> (&AutoTonalRangeModeSelector); + delete static_cast *> (&AutoTonalRangeAdjustmentSelector); + delete static_cast (&AutoTonalRangeThresholdDark); + delete static_cast (&AutoTonalRangeThresholdDarkRaw); + delete static_cast (&AutoTonalRangeThresholdBright); + delete static_cast (&AutoTonalRangeThresholdBrightRaw); + delete static_cast (&AutoTonalRangeTargetDark); + delete static_cast (&AutoTonalRangeTargetBright); + delete static_cast *> (&ColorOverexposureCompensationAOISelector); + delete static_cast (&ColorOverexposureCompensationAOIEnable); + delete static_cast (&ColorOverexposureCompensationAOIFactor); + delete static_cast (&ColorOverexposureCompensationAOIFactorRaw); + delete static_cast (&ColorOverexposureCompensationAOIWidth); + delete static_cast (&ColorOverexposureCompensationAOIHeight); + delete static_cast (&ColorOverexposureCompensationAOIOffsetX); + delete static_cast (&ColorOverexposureCompensationAOIOffsetY); + delete static_cast *> (&ShadingSelector); + delete static_cast (&ShadingEnable); + delete static_cast *> (&ShadingStatus); + delete static_cast *> (&ShadingSetDefaultSelector); + delete static_cast *> (&ShadingSetSelector); + delete static_cast (&ShadingSetActivate); + delete static_cast *> (&ShadingSetCreate); + delete static_cast *> (&UserDefinedValueSelector); + delete static_cast (&UserDefinedValue); + delete static_cast (&GenicamXmlFileDefault); + delete static_cast *> (&FeatureSet); + delete static_cast (&DeviceVendorName); + delete static_cast (&DeviceModelName); + delete static_cast (&DeviceManufacturerInfo); + delete static_cast (&DeviceVersion); + delete static_cast (&DeviceFirmwareVersion); + delete static_cast (&DeviceID); + delete static_cast (&DeviceUserID); + delete static_cast *> (&DeviceScanType); + delete static_cast (&DeviceReset); + delete static_cast *> (&TemperatureSelector); + delete static_cast (&TemperatureAbs); + delete static_cast *> (&TemperatureState); + delete static_cast (&CriticalTemperature); + delete static_cast (&OverTemperature); + delete static_cast *> (&LastError); + delete static_cast (&ClearLastError); + delete static_cast (&DeviceColorPipelineVersion); + delete static_cast *> (&ParameterSelector); + delete static_cast (&RemoveLimits); + delete static_cast (&Prelines); + delete static_cast *> (&ExpertFeatureAccessSelector); + delete static_cast (&ExpertFeatureAccessKey); + delete static_cast (&ExpertFeatureEnable); + delete static_cast (&ChunkModeActive); + delete static_cast *> (&ChunkSelector); + delete static_cast (&ChunkEnable); + delete static_cast (&ChunkStride); + delete static_cast (&ChunkSequenceSetIndex); + delete static_cast (&ChunkOffsetX); + delete static_cast (&ChunkOffsetY); + delete static_cast (&ChunkWidth); + delete static_cast (&ChunkHeight); + delete static_cast (&ChunkDynamicRangeMin); + delete static_cast (&ChunkDynamicRangeMax); + delete static_cast *> (&ChunkPixelFormat); + delete static_cast (&ChunkTimestamp); + delete static_cast (&ChunkFramecounter); + delete static_cast (&ChunkLineStatusAll); + delete static_cast (&ChunkVirtLineStatusAll); + delete static_cast (&ChunkTriggerinputcounter); + delete static_cast (&ChunkLineTriggerIgnoredCounter); + delete static_cast (&ChunkFrameTriggerIgnoredCounter); + delete static_cast (&ChunkFrameTriggerCounter); + delete static_cast (&ChunkFramesPerTriggerCounter); + delete static_cast (&ChunkLineTriggerEndToEndCounter); + delete static_cast (&ChunkInputStatusAtLineTriggerBitsPerLine); + delete static_cast (&ChunkInputStatusAtLineTriggerIndex); + delete static_cast (&ChunkInputStatusAtLineTriggerValue); + delete static_cast (&ChunkShaftEncoderCounter); + delete static_cast (&ChunkExposureTime); + delete static_cast (&ChunkPayloadCRC16); + delete static_cast (&ChunkGainAll); + delete static_cast (&ChunkLineTriggerCounter); + delete static_cast *> (&EventSelector); + delete static_cast *> (&EventNotification); + delete static_cast (&ExposureEndEventStreamChannelIndex); + delete static_cast (&ExposureEndEventFrameID); + delete static_cast (&ExposureEndEventTimestamp); + delete static_cast (&LineStartOvertriggerEventStreamChannelIndex); + delete static_cast (&LineStartOvertriggerEventTimestamp); + delete static_cast (&FrameStartOvertriggerEventStreamChannelIndex); + delete static_cast (&FrameStartOvertriggerEventTimestamp); + delete static_cast (&FrameStartEventStreamChannelIndex); + delete static_cast (&FrameStartEventTimestamp); + delete static_cast (&AcquisitionStartEventStreamChannelIndex); + delete static_cast (&AcquisitionStartEventTimestamp); + delete static_cast (&AcquisitionStartOvertriggerEventStreamChannelIndex); + delete static_cast (&AcquisitionStartOvertriggerEventTimestamp); + delete static_cast (&FrameTimeoutEventStreamChannelIndex); + delete static_cast (&FrameTimeoutEventTimestamp); + delete static_cast (&EventOverrunEventStreamChannelIndex); + delete static_cast (&EventOverrunEventFrameID); + delete static_cast (&EventOverrunEventTimestamp); + delete static_cast (&CriticalTemperatureEventStreamChannelIndex); + delete static_cast (&CriticalTemperatureEventTimestamp); + delete static_cast (&OverTemperatureEventStreamChannelIndex); + delete static_cast (&OverTemperatureEventTimestamp); + delete static_cast (&ActionLateEventStreamChannelIndex); + delete static_cast (&ActionLateEventTimestamp); + delete static_cast (&LateActionEventStreamChannelIndex); + delete static_cast (&LateActionEventTimestamp); + delete static_cast (&Line1RisingEdgeEventStreamChannelIndex); + delete static_cast (&Line1RisingEdgeEventTimestamp); + delete static_cast (&Line2RisingEdgeEventStreamChannelIndex); + delete static_cast (&Line2RisingEdgeEventTimestamp); + delete static_cast (&Line3RisingEdgeEventStreamChannelIndex); + delete static_cast (&Line3RisingEdgeEventTimestamp); + delete static_cast (&Line4RisingEdgeEventStreamChannelIndex); + delete static_cast (&Line4RisingEdgeEventTimestamp); + delete static_cast (&VirtualLine1RisingEdgeEventStreamChannelIndex); + delete static_cast (&VirtualLine1RisingEdgeEventTimestamp); + delete static_cast (&VirtualLine2RisingEdgeEventStreamChannelIndex); + delete static_cast (&VirtualLine2RisingEdgeEventTimestamp); + delete static_cast (&VirtualLine3RisingEdgeEventStreamChannelIndex); + delete static_cast (&VirtualLine3RisingEdgeEventTimestamp); + delete static_cast (&VirtualLine4RisingEdgeEventStreamChannelIndex); + delete static_cast (&VirtualLine4RisingEdgeEventTimestamp); + delete static_cast (&FrameWaitEventStreamChannelIndex); + delete static_cast (&FrameWaitEventTimestamp); + delete static_cast (&AcquisitionWaitEventStreamChannelIndex); + delete static_cast (&AcquisitionWaitEventTimestamp); + delete static_cast (&FrameStartWaitEventStreamChannelIndex); + delete static_cast (&FrameStartWaitEventTimestamp); + delete static_cast (&AcquisitionStartWaitEventStreamChannelIndex); + delete static_cast (&AcquisitionStartWaitEventTimestamp); + delete static_cast *> (&FileSelector); + delete static_cast *> (&FileOperationSelector); + delete static_cast *> (&FileOpenMode); + delete static_cast (&FileAccessBuffer); + delete static_cast (&FileAccessOffset); + delete static_cast (&FileAccessLength); + delete static_cast *> (&FileOperationStatus); + delete static_cast (&FileOperationResult); + delete static_cast (&FileSize); + delete static_cast (&FileOperationExecute); + + } + + inline void CGigECamera_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&SequenceEnable)->SetReference( _Ptr->GetNode( "SequenceEnable" ) ); + static_cast (&SequenceCurrentSet)->SetReference( _Ptr->GetNode( "SequenceCurrentSet" ) ); + static_cast*> (&SequenceConfigurationMode)->SetReference( _Ptr->GetNode( "SequenceConfigurationMode" ) ); + static_cast*> (&SequenceConfigurationMode)->SetNumEnums( 2 ); + static_cast*> (&SequenceConfigurationMode)->SetEnumReference( SequenceConfigurationMode_Off, "Off" ); static_cast*> (&SequenceConfigurationMode)->SetEnumReference( SequenceConfigurationMode_On, "On" ); static_cast (&SequenceAsyncRestart)->SetReference( _Ptr->GetNode( "SequenceAsyncRestart" ) ); + static_cast (&SequenceAsyncAdvance)->SetReference( _Ptr->GetNode( "SequenceAsyncAdvance" ) ); + static_cast (&SequenceSetTotalNumber)->SetReference( _Ptr->GetNode( "SequenceSetTotalNumber" ) ); + static_cast (&SequenceSetIndex)->SetReference( _Ptr->GetNode( "SequenceSetIndex" ) ); + static_cast (&SequenceSetStore)->SetReference( _Ptr->GetNode( "SequenceSetStore" ) ); + static_cast (&SequenceSetLoad)->SetReference( _Ptr->GetNode( "SequenceSetLoad" ) ); + static_cast (&SequenceSetExecutions)->SetReference( _Ptr->GetNode( "SequenceSetExecutions" ) ); + static_cast*> (&SequenceAdvanceMode)->SetReference( _Ptr->GetNode( "SequenceAdvanceMode" ) ); + static_cast*> (&SequenceAdvanceMode)->SetNumEnums( 3 ); + static_cast*> (&SequenceAdvanceMode)->SetEnumReference( SequenceAdvanceMode_Auto, "Auto" ); static_cast*> (&SequenceAdvanceMode)->SetEnumReference( SequenceAdvanceMode_Controlled, "Controlled" ); static_cast*> (&SequenceAdvanceMode)->SetEnumReference( SequenceAdvanceMode_FreeSelection, "FreeSelection" ); static_cast*> (&SequenceControlSelector)->SetReference( _Ptr->GetNode( "SequenceControlSelector" ) ); + static_cast*> (&SequenceControlSelector)->SetNumEnums( 2 ); + static_cast*> (&SequenceControlSelector)->SetEnumReference( SequenceControlSelector_Restart, "Restart" ); static_cast*> (&SequenceControlSelector)->SetEnumReference( SequenceControlSelector_Advance, "Advance" ); static_cast*> (&SequenceControlSource)->SetReference( _Ptr->GetNode( "SequenceControlSource" ) ); + static_cast*> (&SequenceControlSource)->SetNumEnums( 19 ); + static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Disabled, "Disabled" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_AlwaysActive, "AlwaysActive" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line1, "Line1" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line2, "Line2" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line3, "Line3" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line4, "Line4" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line5, "Line5" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line6, "Line6" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line7, "Line7" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_Line8, "Line8" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC1, "CC1" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC2, "CC2" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC3, "CC3" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_CC4, "CC4" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput1, "VInput1" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput2, "VInput2" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput3, "VInput3" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInput4, "VInput4" ); static_cast*> (&SequenceControlSource)->SetEnumReference( SequenceControlSource_VInputDecActive, "VInputDecActive" ); static_cast*> (&SequenceAddressBitSelector)->SetReference( _Ptr->GetNode( "SequenceAddressBitSelector" ) ); + static_cast*> (&SequenceAddressBitSelector)->SetNumEnums( 4 ); + static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit0, "Bit0" ); static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit1, "Bit1" ); static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit2, "Bit2" ); static_cast*> (&SequenceAddressBitSelector)->SetEnumReference( SequenceAddressBitSelector_Bit3, "Bit3" ); static_cast*> (&SequenceAddressBitSource)->SetReference( _Ptr->GetNode( "SequenceAddressBitSource" ) ); + static_cast*> (&SequenceAddressBitSource)->SetNumEnums( 17 ); + static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line1, "Line1" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line2, "Line2" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line3, "Line3" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line4, "Line4" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line5, "Line5" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line6, "Line6" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line7, "Line7" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_Line8, "Line8" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC1, "CC1" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC2, "CC2" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC3, "CC3" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_CC4, "CC4" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput1, "VInput1" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput2, "VInput2" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput3, "VInput3" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInput4, "VInput4" ); static_cast*> (&SequenceAddressBitSource)->SetEnumReference( SequenceAddressBitSource_VInputDecActive, "VInputDecActive" ); static_cast*> (&GainAuto)->SetReference( _Ptr->GetNode( "GainAuto" ) ); + static_cast*> (&GainAuto)->SetNumEnums( 3 ); + static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Off, "Off" ); static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Once, "Once" ); static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Continuous, "Continuous" ); static_cast*> (&GainSelector)->SetReference( _Ptr->GetNode( "GainSelector" ) ); + static_cast*> (&GainSelector)->SetNumEnums( 10 ); + static_cast*> (&GainSelector)->SetEnumReference( GainSelector_All, "All" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_AnalogAll, "AnalogAll" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_DigitalAll, "DigitalAll" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap1, "Tap1" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap2, "Tap2" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap3, "Tap3" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Tap4, "Tap4" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Red, "Red" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Green, "Green" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_Blue, "Blue" ); static_cast (&GainRaw)->SetReference( _Ptr->GetNode( "GainRaw" ) ); + static_cast (&GainAbs)->SetReference( _Ptr->GetNode( "GainAbs" ) ); + static_cast*> (&BlackLevelSelector)->SetReference( _Ptr->GetNode( "BlackLevelSelector" ) ); + static_cast*> (&BlackLevelSelector)->SetNumEnums( 10 ); + static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_All, "All" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_AnalogAll, "AnalogAll" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_DigitalAll, "DigitalAll" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap1, "Tap1" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap2, "Tap2" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap3, "Tap3" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Tap4, "Tap4" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Red, "Red" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Green, "Green" ); static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_Blue, "Blue" ); static_cast (&BlackLevelRaw)->SetReference( _Ptr->GetNode( "BlackLevelRaw" ) ); + static_cast (&BlackLevelAbs)->SetReference( _Ptr->GetNode( "BlackLevelAbs" ) ); + static_cast (&GammaEnable)->SetReference( _Ptr->GetNode( "GammaEnable" ) ); + static_cast*> (&GammaSelector)->SetReference( _Ptr->GetNode( "GammaSelector" ) ); + static_cast*> (&GammaSelector)->SetNumEnums( 2 ); + static_cast*> (&GammaSelector)->SetEnumReference( GammaSelector_User, "User" ); static_cast*> (&GammaSelector)->SetEnumReference( GammaSelector_sRGB, "sRGB" ); static_cast (&Gamma)->SetReference( _Ptr->GetNode( "Gamma" ) ); + static_cast (&DigitalShift)->SetReference( _Ptr->GetNode( "DigitalShift" ) ); + static_cast (&SubstrateVoltage)->SetReference( _Ptr->GetNode( "SubstrateVoltage" ) ); + static_cast*> (&SensorBitDepth)->SetReference( _Ptr->GetNode( "SensorBitDepth" ) ); + static_cast*> (&SensorBitDepth)->SetNumEnums( 5 ); + static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth8, "BitDepth8" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth10, "BitDepth10" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth12, "BitDepth12" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth14, "BitDepth14" ); static_cast*> (&SensorBitDepth)->SetEnumReference( SensorBitDepth_BitDepth16, "BitDepth16" ); static_cast*> (&SensorDigitizationTaps)->SetReference( _Ptr->GetNode( "SensorDigitizationTaps" ) ); + static_cast*> (&SensorDigitizationTaps)->SetNumEnums( 4 ); + static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_One, "One" ); static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_Two, "Two" ); static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_Three, "Three" ); static_cast*> (&SensorDigitizationTaps)->SetEnumReference( SensorDigitizationTaps_Four, "Four" ); static_cast*> (&PixelFormat)->SetReference( _Ptr->GetNode( "PixelFormat" ) ); + static_cast*> (&PixelFormat)->SetNumEnums( 51 ); + static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono8, "Mono8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10, "Mono10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10Packed, "Mono10Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10p, "Mono10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono12, "Mono12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono12Packed, "Mono12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono16, "Mono16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR8, "BayerGR8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG8, "BayerRG8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB8, "BayerGB8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG8, "BayerBG8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR10, "BayerGR10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG10, "BayerRG10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB10, "BayerGB10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG10, "BayerBG10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR12, "BayerGR12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG12, "BayerRG12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB12, "BayerGB12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG12, "BayerBG12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB8Packed, "RGB8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR8Packed, "BGR8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGBA8Packed, "RGBA8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGRA8Packed, "BGRA8Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10Packed, "RGB10Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR10Packed, "BGR10Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB12Packed, "RGB12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR12Packed, "BGR12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10V1Packed, "RGB10V1Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10V2Packed, "RGB10V2Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV411Packed, "YUV411Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV422Packed, "YUV422Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV444Packed, "YUV444Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB8Planar, "RGB8Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB10Planar, "RGB10Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB12Planar, "RGB12Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB16Planar, "RGB16Planar" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YUV422_YUYV_Packed, "YUV422_YUYV_Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB12Packed, "BayerGB12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR12Packed, "BayerGR12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG12Packed, "BayerRG12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG12Packed, "BayerBG12Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR16, "BayerGR16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG16, "BayerRG16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB16, "BayerGB16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG16, "BayerBG16" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB12V1Packed, "RGB12V1Packed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono8Signed, "Mono8Signed" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR10p, "BayerGR10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG10p, "BayerRG10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB10p, "BayerGB10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG10p, "BayerBG10p" ); static_cast*> (&PixelCoding)->SetReference( _Ptr->GetNode( "PixelCoding" ) ); + static_cast*> (&PixelCoding)->SetNumEnums( 24 ); + static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono8, "Mono8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono8Signed, "Mono8Signed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono16, "Mono16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono10Packed, "Mono10Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Mono12Packed, "Mono12Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Raw8, "Raw8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_Raw16, "Raw16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB8, "RGB8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BGR8, "BGR8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGBA8, "RGBA8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BGRA8, "BGRA8" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB16, "RGB16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BGR16, "BGR16" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB10V1Packed, "RGB10V1Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB10V2Packed, "RGB10V2Packed" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_YUV411, "YUV411" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_YUV422, "YUV422" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_YUV444, "YUV444" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB8Planar, "RGB8Planar" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_RGB16Planar, "RGB16Planar" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BayerGR10p, "BayerGR10p" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BayerRG10p, "BayerRG10p" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BayerGB10p, "BayerGB10p" ); static_cast*> (&PixelCoding)->SetEnumReference( PixelCoding_BayerBG10p, "BayerBG10p" ); static_cast*> (&PixelSize)->SetReference( _Ptr->GetNode( "PixelSize" ) ); + static_cast*> (&PixelSize)->SetNumEnums( 13 ); + static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp1, "Bpp1" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp2, "Bpp2" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp4, "Bpp4" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp8, "Bpp8" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp10, "Bpp10" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp12, "Bpp12" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp14, "Bpp14" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp16, "Bpp16" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp24, "Bpp24" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp32, "Bpp32" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp36, "Bpp36" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp48, "Bpp48" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp64, "Bpp64" ); static_cast*> (&PixelColorFilter)->SetReference( _Ptr->GetNode( "PixelColorFilter" ) ); + static_cast*> (&PixelColorFilter)->SetNumEnums( 5 ); + static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_RG, "Bayer_RG" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_GB, "Bayer_GB" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_GR, "Bayer_GR" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_Bayer_BG, "Bayer_BG" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_None, "None" ); static_cast (&ProcessedRawEnable)->SetReference( _Ptr->GetNode( "ProcessedRawEnable" ) ); + static_cast (&PixelDynamicRangeMin)->SetReference( _Ptr->GetNode( "PixelDynamicRangeMin" ) ); + static_cast (&PixelDynamicRangeMax)->SetReference( _Ptr->GetNode( "PixelDynamicRangeMax" ) ); + static_cast (&SpatialCorrection)->SetReference( _Ptr->GetNode( "SpatialCorrection" ) ); + static_cast (&SpatialCorrectionAmount)->SetReference( _Ptr->GetNode( "SpatialCorrectionAmount" ) ); + static_cast*> (&SpatialCorrectionStartingLine)->SetReference( _Ptr->GetNode( "SpatialCorrectionStartingLine" ) ); + static_cast*> (&SpatialCorrectionStartingLine)->SetNumEnums( 3 ); + static_cast*> (&SpatialCorrectionStartingLine)->SetEnumReference( SpatialCorrectionStartingLine_LineRed, "LineRed" ); static_cast*> (&SpatialCorrectionStartingLine)->SetEnumReference( SpatialCorrectionStartingLine_LineGreen, "LineGreen" ); static_cast*> (&SpatialCorrectionStartingLine)->SetEnumReference( SpatialCorrectionStartingLine_LineBlue, "LineBlue" ); static_cast (&ReverseX)->SetReference( _Ptr->GetNode( "ReverseX" ) ); + static_cast (&ReverseY)->SetReference( _Ptr->GetNode( "ReverseY" ) ); + static_cast*> (&FieldOutputMode)->SetReference( _Ptr->GetNode( "FieldOutputMode" ) ); + static_cast*> (&FieldOutputMode)->SetNumEnums( 5 ); + static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_Field0, "Field0" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_Field1, "Field1" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_Field0First, "Field0First" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_ConcatenatedNewFields, "ConcatenatedNewFields" ); static_cast*> (&FieldOutputMode)->SetEnumReference( FieldOutputMode_DeinterlacedNewFields, "DeinterlacedNewFields" ); static_cast*> (&TestImageSelector)->SetReference( _Ptr->GetNode( "TestImageSelector" ) ); + static_cast*> (&TestImageSelector)->SetNumEnums( 25 ); + static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Off, "Off" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Black, "Black" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_White, "White" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyHorizontalRamp, "GreyHorizontalRamp" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyVerticalRamp, "GreyVerticalRamp" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyHorizontalRampMoving, "GreyHorizontalRampMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_GreyVerticalRampMoving, "GreyVerticalRampMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_HorzontalLineMoving, "HorzontalLineMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_VerticalLineMoving, "VerticalLineMoving" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_ColorBar, "ColorBar" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_FrameCounter, "FrameCounter" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_DeviceSpecific, "DeviceSpecific" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_FixedDiagonalGrayGradient_8Bit, "FixedDiagonalGrayGradient_8Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradient_8Bit, "MovingDiagonalGrayGradient_8Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradient_12Bit, "MovingDiagonalGrayGradient_12Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradientFeatureTest_8Bit, "MovingDiagonalGrayGradientFeatureTest_8Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalGrayGradientFeatureTest_12Bit, "MovingDiagonalGrayGradientFeatureTest_12Bit" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_MovingDiagonalColorGradient, "MovingDiagonalColorGradient" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage1, "Testimage1" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage2, "Testimage2" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage3, "Testimage3" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage4, "Testimage4" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage5, "Testimage5" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage6, "Testimage6" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage7, "Testimage7" ); static_cast (&TestImageResetAndHold)->SetReference( _Ptr->GetNode( "TestImageResetAndHold" ) ); + static_cast (&SensorWidth)->SetReference( _Ptr->GetNode( "SensorWidth" ) ); + static_cast (&SensorHeight)->SetReference( _Ptr->GetNode( "SensorHeight" ) ); + static_cast (&WidthMax)->SetReference( _Ptr->GetNode( "WidthMax" ) ); + static_cast (&HeightMax)->SetReference( _Ptr->GetNode( "HeightMax" ) ); + static_cast*> (&LightSourceSelector)->SetReference( _Ptr->GetNode( "LightSourceSelector" ) ); + static_cast*> (&LightSourceSelector)->SetNumEnums( 10 ); + static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Off, "Off" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Custom, "Custom" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Daylight, "Daylight" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Tungsten, "Tungsten" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_MicroscopeLED4500K, "MicroscopeLED4500K" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_MicroscopeLED5500K, "MicroscopeLED5500K" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_MicroscopeLED6000K, "MicroscopeLED6000K" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_Daylight6500K, "Daylight6500K" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_LightSource0, "LightSource0" ); static_cast*> (&LightSourceSelector)->SetEnumReference( LightSourceSelector_LightSource1, "LightSource1" ); static_cast (&BalanceWhiteReset)->SetReference( _Ptr->GetNode( "BalanceWhiteReset" ) ); + static_cast*> (&BalanceWhiteAuto)->SetReference( _Ptr->GetNode( "BalanceWhiteAuto" ) ); + static_cast*> (&BalanceWhiteAuto)->SetNumEnums( 3 ); + static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Off, "Off" ); static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Once, "Once" ); static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Continuous, "Continuous" ); static_cast*> (&BalanceRatioSelector)->SetReference( _Ptr->GetNode( "BalanceRatioSelector" ) ); + static_cast*> (&BalanceRatioSelector)->SetNumEnums( 3 ); + static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Red, "Red" ); static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Green, "Green" ); static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Blue, "Blue" ); static_cast (&BalanceRatioAbs)->SetReference( _Ptr->GetNode( "BalanceRatioAbs" ) ); + static_cast (&BalanceRatioRaw)->SetReference( _Ptr->GetNode( "BalanceRatioRaw" ) ); + static_cast*> (&ColorTransformationSelector)->SetReference( _Ptr->GetNode( "ColorTransformationSelector" ) ); + static_cast*> (&ColorTransformationSelector)->SetNumEnums( 3 ); + static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_RGBtoRGB, "RGBtoRGB" ); static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_RGBtoYUV, "RGBtoYUV" ); static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_YUVtoRGB, "YUVtoRGB" ); static_cast*> (&ColorTransformationValueSelector)->SetReference( _Ptr->GetNode( "ColorTransformationValueSelector" ) ); + static_cast*> (&ColorTransformationValueSelector)->SetNumEnums( 9 ); + static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain00, "Gain00" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain01, "Gain01" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain02, "Gain02" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain10, "Gain10" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain11, "Gain11" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain12, "Gain12" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain20, "Gain20" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain21, "Gain21" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain22, "Gain22" ); static_cast (&ColorTransformationValue)->SetReference( _Ptr->GetNode( "ColorTransformationValue" ) ); + static_cast (&ColorTransformationValueRaw)->SetReference( _Ptr->GetNode( "ColorTransformationValueRaw" ) ); + static_cast (&ColorTransformationMatrixFactor)->SetReference( _Ptr->GetNode( "ColorTransformationMatrixFactor" ) ); + static_cast (&ColorTransformationMatrixFactorRaw)->SetReference( _Ptr->GetNode( "ColorTransformationMatrixFactorRaw" ) ); + static_cast (&ColorAdjustmentEnable)->SetReference( _Ptr->GetNode( "ColorAdjustmentEnable" ) ); + static_cast (&ColorAdjustmentReset)->SetReference( _Ptr->GetNode( "ColorAdjustmentReset" ) ); + static_cast*> (&ColorAdjustmentSelector)->SetReference( _Ptr->GetNode( "ColorAdjustmentSelector" ) ); + static_cast*> (&ColorAdjustmentSelector)->SetNumEnums( 6 ); + static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Red, "Red" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Yellow, "Yellow" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Green, "Green" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Cyan, "Cyan" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Blue, "Blue" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Magenta, "Magenta" ); static_cast (&ColorAdjustmentHue)->SetReference( _Ptr->GetNode( "ColorAdjustmentHue" ) ); + static_cast (&ColorAdjustmentHueRaw)->SetReference( _Ptr->GetNode( "ColorAdjustmentHueRaw" ) ); + static_cast (&ColorAdjustmentSaturation)->SetReference( _Ptr->GetNode( "ColorAdjustmentSaturation" ) ); + static_cast (&ColorAdjustmentSaturationRaw)->SetReference( _Ptr->GetNode( "ColorAdjustmentSaturationRaw" ) ); + static_cast (&BslHue)->SetReference( _Ptr->GetNode( "BslHue" ) ); + static_cast (&BslHueRaw)->SetReference( _Ptr->GetNode( "BslHueRaw" ) ); + static_cast (&BslSaturation)->SetReference( _Ptr->GetNode( "BslSaturation" ) ); + static_cast (&BslSaturationRaw)->SetReference( _Ptr->GetNode( "BslSaturationRaw" ) ); + static_cast (&BslBrightness)->SetReference( _Ptr->GetNode( "BslBrightness" ) ); + static_cast (&BslBrightnessRaw)->SetReference( _Ptr->GetNode( "BslBrightnessRaw" ) ); + static_cast (&BslContrast)->SetReference( _Ptr->GetNode( "BslContrast" ) ); + static_cast (&BslContrastRaw)->SetReference( _Ptr->GetNode( "BslContrastRaw" ) ); + static_cast*> (&BslContrastMode)->SetReference( _Ptr->GetNode( "BslContrastMode" ) ); + static_cast*> (&BslContrastMode)->SetNumEnums( 2 ); + static_cast*> (&BslContrastMode)->SetEnumReference( BslContrastMode_Linear, "Linear" ); static_cast*> (&BslContrastMode)->SetEnumReference( BslContrastMode_SCurve, "SCurve" ); static_cast*> (&DemosaicingMode)->SetReference( _Ptr->GetNode( "DemosaicingMode" ) ); + static_cast*> (&DemosaicingMode)->SetNumEnums( 2 ); + static_cast*> (&DemosaicingMode)->SetEnumReference( DemosaicingMode_Simple, "Simple" ); static_cast*> (&DemosaicingMode)->SetEnumReference( DemosaicingMode_BaslerPGI, "BaslerPGI" ); static_cast*> (&PgiMode)->SetReference( _Ptr->GetNode( "PgiMode" ) ); + static_cast*> (&PgiMode)->SetNumEnums( 2 ); + static_cast*> (&PgiMode)->SetEnumReference( PgiMode_Off, "Off" ); static_cast*> (&PgiMode)->SetEnumReference( PgiMode_On, "On" ); static_cast (&NoiseReductionAbs)->SetReference( _Ptr->GetNode( "NoiseReductionAbs" ) ); + static_cast (&NoiseReductionRaw)->SetReference( _Ptr->GetNode( "NoiseReductionRaw" ) ); + static_cast (&SharpnessEnhancementAbs)->SetReference( _Ptr->GetNode( "SharpnessEnhancementAbs" ) ); + static_cast (&SharpnessEnhancementRaw)->SetReference( _Ptr->GetNode( "SharpnessEnhancementRaw" ) ); + static_cast*> (&TonalRangeEnable)->SetReference( _Ptr->GetNode( "TonalRangeEnable" ) ); + static_cast*> (&TonalRangeEnable)->SetNumEnums( 2 ); + static_cast*> (&TonalRangeEnable)->SetEnumReference( TonalRangeEnable_Off, "Off" ); static_cast*> (&TonalRangeEnable)->SetEnumReference( TonalRangeEnable_On, "On" ); static_cast*> (&TonalRangeAuto)->SetReference( _Ptr->GetNode( "TonalRangeAuto" ) ); + static_cast*> (&TonalRangeAuto)->SetNumEnums( 2 ); + static_cast*> (&TonalRangeAuto)->SetEnumReference( TonalRangeAuto_Off, "Off" ); static_cast*> (&TonalRangeAuto)->SetEnumReference( TonalRangeAuto_Once, "Once" ); static_cast*> (&TonalRangeSelector)->SetReference( _Ptr->GetNode( "TonalRangeSelector" ) ); + static_cast*> (&TonalRangeSelector)->SetNumEnums( 4 ); + static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Sum, "Sum" ); static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Red, "Red" ); static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Green, "Green" ); static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Blue, "Blue" ); static_cast (&TonalRangeSourceBright)->SetReference( _Ptr->GetNode( "TonalRangeSourceBright" ) ); + static_cast (&TonalRangeSourceDark)->SetReference( _Ptr->GetNode( "TonalRangeSourceDark" ) ); + static_cast (&TonalRangeTargetBright)->SetReference( _Ptr->GetNode( "TonalRangeTargetBright" ) ); + static_cast (&TonalRangeTargetDark)->SetReference( _Ptr->GetNode( "TonalRangeTargetDark" ) ); + static_cast (&Width)->SetReference( _Ptr->GetNode( "Width" ) ); + static_cast (&Height)->SetReference( _Ptr->GetNode( "Height" ) ); + static_cast (&OffsetX)->SetReference( _Ptr->GetNode( "OffsetX" ) ); + static_cast (&OffsetY)->SetReference( _Ptr->GetNode( "OffsetY" ) ); + static_cast (&CenterX)->SetReference( _Ptr->GetNode( "CenterX" ) ); + static_cast (&CenterY)->SetReference( _Ptr->GetNode( "CenterY" ) ); + static_cast*> (&LegacyBinningVertical)->SetReference( _Ptr->GetNode( "LegacyBinningVertical" ) ); + static_cast*> (&LegacyBinningVertical)->SetNumEnums( 2 ); + static_cast*> (&LegacyBinningVertical)->SetEnumReference( LegacyBinningVertical_Off, "Off" ); static_cast*> (&LegacyBinningVertical)->SetEnumReference( LegacyBinningVertical_Two_Rows, "Two_Rows" ); static_cast*> (&BinningHorizontalMode)->SetReference( _Ptr->GetNode( "BinningHorizontalMode" ) ); + static_cast*> (&BinningHorizontalMode)->SetNumEnums( 2 ); + static_cast*> (&BinningHorizontalMode)->SetEnumReference( BinningHorizontalMode_Sum, "Sum" ); static_cast*> (&BinningHorizontalMode)->SetEnumReference( BinningHorizontalMode_Average, "Average" ); static_cast*> (&BinningModeHorizontal)->SetReference( _Ptr->GetNode( "BinningModeHorizontal" ) ); + static_cast*> (&BinningModeHorizontal)->SetNumEnums( 2 ); + static_cast*> (&BinningModeHorizontal)->SetEnumReference( BinningModeHorizontal_Summing, "Summing" ); static_cast*> (&BinningModeHorizontal)->SetEnumReference( BinningModeHorizontal_Averaging, "Averaging" ); static_cast (&BinningHorizontal)->SetReference( _Ptr->GetNode( "BinningHorizontal" ) ); + static_cast*> (&BinningVerticalMode)->SetReference( _Ptr->GetNode( "BinningVerticalMode" ) ); + static_cast*> (&BinningVerticalMode)->SetNumEnums( 2 ); + static_cast*> (&BinningVerticalMode)->SetEnumReference( BinningVerticalMode_Sum, "Sum" ); static_cast*> (&BinningVerticalMode)->SetEnumReference( BinningVerticalMode_Average, "Average" ); static_cast*> (&BinningModeVertical)->SetReference( _Ptr->GetNode( "BinningModeVertical" ) ); + static_cast*> (&BinningModeVertical)->SetNumEnums( 2 ); + static_cast*> (&BinningModeVertical)->SetEnumReference( BinningModeVertical_Summing, "Summing" ); static_cast*> (&BinningModeVertical)->SetEnumReference( BinningModeVertical_Averaging, "Averaging" ); static_cast (&BinningVertical)->SetReference( _Ptr->GetNode( "BinningVertical" ) ); + static_cast (&DecimationHorizontal)->SetReference( _Ptr->GetNode( "DecimationHorizontal" ) ); + static_cast (&DecimationVertical)->SetReference( _Ptr->GetNode( "DecimationVertical" ) ); + static_cast (&ScalingHorizontalAbs)->SetReference( _Ptr->GetNode( "ScalingHorizontalAbs" ) ); + static_cast (&ScalingVerticalAbs)->SetReference( _Ptr->GetNode( "ScalingVerticalAbs" ) ); + static_cast*> (&ROIZoneSelector)->SetReference( _Ptr->GetNode( "ROIZoneSelector" ) ); + static_cast*> (&ROIZoneSelector)->SetNumEnums( 8 ); + static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone0, "Zone0" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone1, "Zone1" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone2, "Zone2" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone3, "Zone3" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone4, "Zone4" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone5, "Zone5" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone6, "Zone6" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone7, "Zone7" ); static_cast*> (&ROIZoneMode)->SetReference( _Ptr->GetNode( "ROIZoneMode" ) ); + static_cast*> (&ROIZoneMode)->SetNumEnums( 2 ); + static_cast*> (&ROIZoneMode)->SetEnumReference( ROIZoneMode_Off, "Off" ); static_cast*> (&ROIZoneMode)->SetEnumReference( ROIZoneMode_On, "On" ); static_cast (&ROIZoneSize)->SetReference( _Ptr->GetNode( "ROIZoneSize" ) ); + static_cast (&ROIZoneOffset)->SetReference( _Ptr->GetNode( "ROIZoneOffset" ) ); + static_cast (&StackedZoneImagingEnable)->SetReference( _Ptr->GetNode( "StackedZoneImagingEnable" ) ); + static_cast (&StackedZoneImagingIndex)->SetReference( _Ptr->GetNode( "StackedZoneImagingIndex" ) ); + static_cast (&StackedZoneImagingZoneEnable)->SetReference( _Ptr->GetNode( "StackedZoneImagingZoneEnable" ) ); + static_cast (&StackedZoneImagingZoneOffsetY)->SetReference( _Ptr->GetNode( "StackedZoneImagingZoneOffsetY" ) ); + static_cast (&StackedZoneImagingZoneHeight)->SetReference( _Ptr->GetNode( "StackedZoneImagingZoneHeight" ) ); + static_cast (&EnableBurstAcquisition)->SetReference( _Ptr->GetNode( "EnableBurstAcquisition" ) ); + static_cast*> (&AcquisitionMode)->SetReference( _Ptr->GetNode( "AcquisitionMode" ) ); + static_cast*> (&AcquisitionMode)->SetNumEnums( 3 ); + static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_SingleFrame, "SingleFrame" ); static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_MultiFrame, "MultiFrame" ); static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_Continuous, "Continuous" ); static_cast (&AcquisitionStart)->SetReference( _Ptr->GetNode( "AcquisitionStart" ) ); + static_cast (&AcquisitionStop)->SetReference( _Ptr->GetNode( "AcquisitionStop" ) ); + static_cast (&AcquisitionAbort)->SetReference( _Ptr->GetNode( "AcquisitionAbort" ) ); + static_cast (&AcquisitionFrameCount)->SetReference( _Ptr->GetNode( "AcquisitionFrameCount" ) ); + static_cast*> (&TriggerControlImplementation)->SetReference( _Ptr->GetNode( "TriggerControlImplementation" ) ); + static_cast*> (&TriggerControlImplementation)->SetNumEnums( 2 ); + static_cast*> (&TriggerControlImplementation)->SetEnumReference( TriggerControlImplementation_Legacy, "Legacy" ); static_cast*> (&TriggerControlImplementation)->SetEnumReference( TriggerControlImplementation_Standard, "Standard" ); static_cast*> (&TriggerSelector)->SetReference( _Ptr->GetNode( "TriggerSelector" ) ); + static_cast*> (&TriggerSelector)->SetNumEnums( 10 ); + static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_AcquisitionStart, "AcquisitionStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_AcquisitionEnd, "AcquisitionEnd" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_AcquisitionActive, "AcquisitionActive" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameStart, "FrameStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameEnd, "FrameEnd" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameActive, "FrameActive" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_LineStart, "LineStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_ExposureStart, "ExposureStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_ExposureEnd, "ExposureEnd" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_ExposureActive, "ExposureActive" ); static_cast*> (&TriggerMode)->SetReference( _Ptr->GetNode( "TriggerMode" ) ); + static_cast*> (&TriggerMode)->SetNumEnums( 2 ); + static_cast*> (&TriggerMode)->SetEnumReference( TriggerMode_Off, "Off" ); static_cast*> (&TriggerMode)->SetEnumReference( TriggerMode_On, "On" ); static_cast (&TriggerSoftware)->SetReference( _Ptr->GetNode( "TriggerSoftware" ) ); + static_cast*> (&TriggerSource)->SetReference( _Ptr->GetNode( "TriggerSource" ) ); + static_cast*> (&TriggerSource)->SetNumEnums( 30 ); + static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Software, "Software" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line1, "Line1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line2, "Line2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line3, "Line3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line4, "Line4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line5, "Line5" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line6, "Line6" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line7, "Line7" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line8, "Line8" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC1, "CC1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC2, "CC2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC3, "CC3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_CC4, "CC4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_ShaftEncoderModuleOut, "ShaftEncoderModuleOut" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_FrequencyConverter, "FrequencyConverter" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Timer1Start, "Timer1Start" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Timer1End, "Timer1End" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Counter1Start, "Counter1Start" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Counter1End, "Counter1End" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_UserOutput1, "UserOutput1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_UserOutput2, "UserOutput2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action1, "Action1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action2, "Action2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action3, "Action3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Action4, "Action4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput1, "VInput1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput2, "VInput2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput3, "VInput3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInput4, "VInput4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_VInputDecActive, "VInputDecActive" ); static_cast*> (&TriggerActivation)->SetReference( _Ptr->GetNode( "TriggerActivation" ) ); + static_cast*> (&TriggerActivation)->SetNumEnums( 5 ); + static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_RisingEdge, "RisingEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_FallingEdge, "FallingEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_AnyEdge, "AnyEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_LevelHigh, "LevelHigh" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_LevelLow, "LevelLow" ); static_cast (&TriggerPartialClosingFrame)->SetReference( _Ptr->GetNode( "TriggerPartialClosingFrame" ) ); + static_cast*> (&TriggerDelaySource)->SetReference( _Ptr->GetNode( "TriggerDelaySource" ) ); + static_cast*> (&TriggerDelaySource)->SetNumEnums( 2 ); + static_cast*> (&TriggerDelaySource)->SetEnumReference( TriggerDelaySource_Time_us, "Time_us" ); static_cast*> (&TriggerDelaySource)->SetEnumReference( TriggerDelaySource_LineTrigger, "LineTrigger" ); static_cast (&TriggerDelayAbs)->SetReference( _Ptr->GetNode( "TriggerDelayAbs" ) ); + static_cast (&TriggerDelayLineTriggerCount)->SetReference( _Ptr->GetNode( "TriggerDelayLineTriggerCount" ) ); + static_cast (&ExposureStartDelayAbs)->SetReference( _Ptr->GetNode( "ExposureStartDelayAbs" ) ); + static_cast (&ExposureStartDelayRaw)->SetReference( _Ptr->GetNode( "ExposureStartDelayRaw" ) ); + static_cast*> (&ExposureMode)->SetReference( _Ptr->GetNode( "ExposureMode" ) ); + static_cast*> (&ExposureMode)->SetNumEnums( 4 ); + static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_Off, "Off" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_Timed, "Timed" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_TriggerWidth, "TriggerWidth" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_TriggerControlled, "TriggerControlled" ); static_cast*> (&InterlacedIntegrationMode)->SetReference( _Ptr->GetNode( "InterlacedIntegrationMode" ) ); + static_cast*> (&InterlacedIntegrationMode)->SetNumEnums( 2 ); + static_cast*> (&InterlacedIntegrationMode)->SetEnumReference( InterlacedIntegrationMode_FieldIntegration, "FieldIntegration" ); static_cast*> (&InterlacedIntegrationMode)->SetEnumReference( InterlacedIntegrationMode_FrameIntegration, "FrameIntegration" ); static_cast*> (&ExposureAuto)->SetReference( _Ptr->GetNode( "ExposureAuto" ) ); + static_cast*> (&ExposureAuto)->SetNumEnums( 3 ); + static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Off, "Off" ); static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Once, "Once" ); static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Continuous, "Continuous" ); static_cast*> (&ExposureTimeMode)->SetReference( _Ptr->GetNode( "ExposureTimeMode" ) ); + static_cast*> (&ExposureTimeMode)->SetNumEnums( 2 ); + static_cast*> (&ExposureTimeMode)->SetEnumReference( ExposureTimeMode_Standard, "Standard" ); static_cast*> (&ExposureTimeMode)->SetEnumReference( ExposureTimeMode_UltraShort, "UltraShort" ); static_cast (&ExposureTimeAbs)->SetReference( _Ptr->GetNode( "ExposureTimeAbs" ) ); + static_cast (&ExposureTimeBaseAbs)->SetReference( _Ptr->GetNode( "ExposureTimeBaseAbs" ) ); + static_cast (&ExposureTimeBaseAbsEnable)->SetReference( _Ptr->GetNode( "ExposureTimeBaseAbsEnable" ) ); + static_cast (&ExposureTimeRaw)->SetReference( _Ptr->GetNode( "ExposureTimeRaw" ) ); + static_cast (&ReadoutTimeAbs)->SetReference( _Ptr->GetNode( "ReadoutTimeAbs" ) ); + static_cast*> (&ExposureOverlapTimeMode)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMode" ) ); + static_cast*> (&ExposureOverlapTimeMode)->SetNumEnums( 2 ); + static_cast*> (&ExposureOverlapTimeMode)->SetEnumReference( ExposureOverlapTimeMode_Manual, "Manual" ); static_cast*> (&ExposureOverlapTimeMode)->SetEnumReference( ExposureOverlapTimeMode_Automatic, "Automatic" ); static_cast (&ExposureOverlapTimeMaxAbs)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMaxAbs" ) ); + static_cast (&ExposureOverlapTimeMaxRaw)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMaxRaw" ) ); + static_cast (&GlobalResetReleaseModeEnable)->SetReference( _Ptr->GetNode( "GlobalResetReleaseModeEnable" ) ); + static_cast*> (&ShutterMode)->SetReference( _Ptr->GetNode( "ShutterMode" ) ); + static_cast*> (&ShutterMode)->SetNumEnums( 3 ); + static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_Global, "Global" ); static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_Rolling, "Rolling" ); static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_GlobalResetRelease, "GlobalResetRelease" ); static_cast*> (&SensorReadoutMode)->SetReference( _Ptr->GetNode( "SensorReadoutMode" ) ); + static_cast*> (&SensorReadoutMode)->SetNumEnums( 2 ); + static_cast*> (&SensorReadoutMode)->SetEnumReference( SensorReadoutMode_Normal, "Normal" ); static_cast*> (&SensorReadoutMode)->SetEnumReference( SensorReadoutMode_Fast, "Fast" ); static_cast (&AcquisitionLineRateAbs)->SetReference( _Ptr->GetNode( "AcquisitionLineRateAbs" ) ); + static_cast (&ResultingLinePeriodAbs)->SetReference( _Ptr->GetNode( "ResultingLinePeriodAbs" ) ); + static_cast (&ResultingLineRateAbs)->SetReference( _Ptr->GetNode( "ResultingLineRateAbs" ) ); + static_cast (&AcquisitionFrameRateEnable)->SetReference( _Ptr->GetNode( "AcquisitionFrameRateEnable" ) ); + static_cast (&AcquisitionFrameRateAbs)->SetReference( _Ptr->GetNode( "AcquisitionFrameRateAbs" ) ); + static_cast (&ResultingFramePeriodAbs)->SetReference( _Ptr->GetNode( "ResultingFramePeriodAbs" ) ); + static_cast (&ResultingFrameRateAbs)->SetReference( _Ptr->GetNode( "ResultingFrameRateAbs" ) ); + static_cast*> (&AcquisitionStatusSelector)->SetReference( _Ptr->GetNode( "AcquisitionStatusSelector" ) ); + static_cast*> (&AcquisitionStatusSelector)->SetNumEnums( 9 ); + static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionTriggerWait, "AcquisitionTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionActive, "AcquisitionActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionTransfer, "AcquisitionTransfer" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameTriggerWait, "FrameTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameActive, "FrameActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameTransfer, "FrameTransfer" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_ExposureActive, "ExposureActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_LineTriggerWait, "LineTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionIdle, "AcquisitionIdle" ); static_cast (&AcquisitionStatus)->SetReference( _Ptr->GetNode( "AcquisitionStatus" ) ); + static_cast (&FrameTimeoutEnable)->SetReference( _Ptr->GetNode( "FrameTimeoutEnable" ) ); + static_cast (&FrameTimeoutAbs)->SetReference( _Ptr->GetNode( "FrameTimeoutAbs" ) ); + static_cast (&SyncFreeRunTimerEnable)->SetReference( _Ptr->GetNode( "SyncFreeRunTimerEnable" ) ); + static_cast (&SyncFreeRunTimerStartTimeLow)->SetReference( _Ptr->GetNode( "SyncFreeRunTimerStartTimeLow" ) ); + static_cast (&SyncFreeRunTimerStartTimeHigh)->SetReference( _Ptr->GetNode( "SyncFreeRunTimerStartTimeHigh" ) ); + static_cast (&SyncFreeRunTimerTriggerRateAbs)->SetReference( _Ptr->GetNode( "SyncFreeRunTimerTriggerRateAbs" ) ); + static_cast (&SyncFreeRunTimerUpdate)->SetReference( _Ptr->GetNode( "SyncFreeRunTimerUpdate" ) ); + static_cast*> (&LineSelector)->SetReference( _Ptr->GetNode( "LineSelector" ) ); + static_cast*> (&LineSelector)->SetNumEnums( 8 ); + static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line1, "Line1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line2, "Line2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line3, "Line3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line4, "Line4" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out1, "Out1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out2, "Out2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out3, "Out3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Out4, "Out4" ); static_cast*> (&LineMode)->SetReference( _Ptr->GetNode( "LineMode" ) ); + static_cast*> (&LineMode)->SetNumEnums( 2 ); + static_cast*> (&LineMode)->SetEnumReference( LineMode_Input, "Input" ); static_cast*> (&LineMode)->SetEnumReference( LineMode_Output, "Output" ); static_cast*> (&LineLogic)->SetReference( _Ptr->GetNode( "LineLogic" ) ); + static_cast*> (&LineLogic)->SetNumEnums( 2 ); + static_cast*> (&LineLogic)->SetEnumReference( LineLogic_Positive, "Positive" ); static_cast*> (&LineLogic)->SetEnumReference( LineLogic_Negative, "Negative" ); static_cast*> (&LineFormat)->SetReference( _Ptr->GetNode( "LineFormat" ) ); + static_cast*> (&LineFormat)->SetNumEnums( 6 ); + static_cast*> (&LineFormat)->SetEnumReference( LineFormat_NoConnect, "NoConnect" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_TriState, "TriState" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_TTL, "TTL" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_LVDS, "LVDS" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_RS422, "RS422" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_OptoCoupled, "OptoCoupled" ); static_cast*> (&LineSource)->SetReference( _Ptr->GetNode( "LineSource" ) ); + static_cast*> (&LineSource)->SetNumEnums( 32 ); + static_cast*> (&LineSource)->SetEnumReference( LineSource_Off, "Off" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_ExposureActive, "ExposureActive" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrameTriggerWait, "FrameTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_LineTriggerWait, "LineTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer1Active, "Timer1Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer2Active, "Timer2Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer3Active, "Timer3Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer4Active, "Timer4Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_TimerActive, "TimerActive" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput1, "UserOutput1" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput2, "UserOutput2" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput3, "UserOutput3" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput4, "UserOutput4" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput, "UserOutput" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_TriggerReady, "TriggerReady" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SerialTx, "SerialTx" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_AcquisitionTriggerWait, "AcquisitionTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_ShaftEncoderModuleOut, "ShaftEncoderModuleOut" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrequencyConverter, "FrequencyConverter" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator1, "PatternGenerator1" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator2, "PatternGenerator2" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator3, "PatternGenerator3" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_PatternGenerator4, "PatternGenerator4" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_AcquisitionTriggerReady, "AcquisitionTriggerReady" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FlashWindow, "FlashWindow" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrameCycle, "FrameCycle" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SyncUserOutput, "SyncUserOutput" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput0, "UserOutput0" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SyncUserOutput0, "SyncUserOutput0" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SyncUserOutput1, "SyncUserOutput1" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SyncUserOutput2, "SyncUserOutput2" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_SyncUserOutput3, "SyncUserOutput3" ); static_cast (&LineInverter)->SetReference( _Ptr->GetNode( "LineInverter" ) ); + static_cast (&LineTermination)->SetReference( _Ptr->GetNode( "LineTermination" ) ); + static_cast (&LineDebouncerTimeAbs)->SetReference( _Ptr->GetNode( "LineDebouncerTimeAbs" ) ); + static_cast (&LineDebouncerTimeRaw)->SetReference( _Ptr->GetNode( "LineDebouncerTimeRaw" ) ); + static_cast (&MinOutPulseWidthRaw)->SetReference( _Ptr->GetNode( "MinOutPulseWidthRaw" ) ); + static_cast (&MinOutPulseWidthAbs)->SetReference( _Ptr->GetNode( "MinOutPulseWidthAbs" ) ); + static_cast (&LineStatus)->SetReference( _Ptr->GetNode( "LineStatus" ) ); + static_cast (&LineStatusAll)->SetReference( _Ptr->GetNode( "LineStatusAll" ) ); + static_cast*> (&UserOutputSelector)->SetReference( _Ptr->GetNode( "UserOutputSelector" ) ); + static_cast*> (&UserOutputSelector)->SetNumEnums( 8 ); + static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput1, "UserOutput1" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput2, "UserOutput2" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput3, "UserOutput3" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput4, "UserOutput4" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput5, "UserOutput5" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput6, "UserOutput6" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput7, "UserOutput7" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput8, "UserOutput8" ); static_cast (&UserOutputValue)->SetReference( _Ptr->GetNode( "UserOutputValue" ) ); + static_cast (&UserOutputValueAll)->SetReference( _Ptr->GetNode( "UserOutputValueAll" ) ); + static_cast (&UserOutputValueAllMask)->SetReference( _Ptr->GetNode( "UserOutputValueAllMask" ) ); + static_cast*> (&SyncUserOutputSelector)->SetReference( _Ptr->GetNode( "SyncUserOutputSelector" ) ); + static_cast*> (&SyncUserOutputSelector)->SetNumEnums( 8 ); + static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput1, "SyncUserOutput1" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput2, "SyncUserOutput2" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput3, "SyncUserOutput3" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput4, "SyncUserOutput4" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput5, "SyncUserOutput5" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput6, "SyncUserOutput6" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput7, "SyncUserOutput7" ); static_cast*> (&SyncUserOutputSelector)->SetEnumReference( SyncUserOutputSelector_SyncUserOutput8, "SyncUserOutput8" ); static_cast (&SyncUserOutputValue)->SetReference( _Ptr->GetNode( "SyncUserOutputValue" ) ); + static_cast (&SyncUserOutputValueAll)->SetReference( _Ptr->GetNode( "SyncUserOutputValueAll" ) ); + static_cast*> (&VInpSignalSource)->SetReference( _Ptr->GetNode( "VInpSignalSource" ) ); + static_cast*> (&VInpSignalSource)->SetNumEnums( 12 ); + static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line1, "Line1" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line2, "Line2" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line3, "Line3" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line4, "Line4" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line5, "Line5" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line6, "Line6" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line7, "Line7" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_Line8, "Line8" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC1, "CC1" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC2, "CC2" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC3, "CC3" ); static_cast*> (&VInpSignalSource)->SetEnumReference( VInpSignalSource_CC4, "CC4" ); static_cast (&VInpBitLength)->SetReference( _Ptr->GetNode( "VInpBitLength" ) ); + static_cast (&VInpSamplingPoint)->SetReference( _Ptr->GetNode( "VInpSamplingPoint" ) ); + static_cast*> (&VInpSignalReadoutActivation)->SetReference( _Ptr->GetNode( "VInpSignalReadoutActivation" ) ); + static_cast*> (&VInpSignalReadoutActivation)->SetNumEnums( 2 ); + static_cast*> (&VInpSignalReadoutActivation)->SetEnumReference( VInpSignalReadoutActivation_RisingEdge, "RisingEdge" ); static_cast*> (&VInpSignalReadoutActivation)->SetEnumReference( VInpSignalReadoutActivation_FallingEdge, "FallingEdge" ); static_cast*> (&ShaftEncoderModuleLineSelector)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleLineSelector" ) ); + static_cast*> (&ShaftEncoderModuleLineSelector)->SetNumEnums( 2 ); + static_cast*> (&ShaftEncoderModuleLineSelector)->SetEnumReference( ShaftEncoderModuleLineSelector_PhaseA, "PhaseA" ); static_cast*> (&ShaftEncoderModuleLineSelector)->SetEnumReference( ShaftEncoderModuleLineSelector_PhaseB, "PhaseB" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleLineSource" ) ); + static_cast*> (&ShaftEncoderModuleLineSource)->SetNumEnums( 12 ); + static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line1, "Line1" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line2, "Line2" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line3, "Line3" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line4, "Line4" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line5, "Line5" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line6, "Line6" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line7, "Line7" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_Line8, "Line8" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC1, "CC1" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC2, "CC2" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC3, "CC3" ); static_cast*> (&ShaftEncoderModuleLineSource)->SetEnumReference( ShaftEncoderModuleLineSource_CC4, "CC4" ); static_cast*> (&ShaftEncoderModuleMode)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleMode" ) ); + static_cast*> (&ShaftEncoderModuleMode)->SetNumEnums( 2 ); + static_cast*> (&ShaftEncoderModuleMode)->SetEnumReference( ShaftEncoderModuleMode_AnyDirection, "AnyDirection" ); static_cast*> (&ShaftEncoderModuleMode)->SetEnumReference( ShaftEncoderModuleMode_ForwardOnly, "ForwardOnly" ); static_cast*> (&ShaftEncoderModuleCounterMode)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounterMode" ) ); + static_cast*> (&ShaftEncoderModuleCounterMode)->SetNumEnums( 2 ); + static_cast*> (&ShaftEncoderModuleCounterMode)->SetEnumReference( ShaftEncoderModuleCounterMode_FollowDirection, "FollowDirection" ); static_cast*> (&ShaftEncoderModuleCounterMode)->SetEnumReference( ShaftEncoderModuleCounterMode_IgnoreDirection, "IgnoreDirection" ); static_cast (&ShaftEncoderModuleCounter)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounter" ) ); + static_cast (&ShaftEncoderModuleCounterMax)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounterMax" ) ); + static_cast (&ShaftEncoderModuleCounterReset)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleCounterReset" ) ); + static_cast (&ShaftEncoderModuleReverseCounterMax)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleReverseCounterMax" ) ); + static_cast (&ShaftEncoderModuleReverseCounterReset)->SetReference( _Ptr->GetNode( "ShaftEncoderModuleReverseCounterReset" ) ); + static_cast*> (&FrequencyConverterInputSource)->SetReference( _Ptr->GetNode( "FrequencyConverterInputSource" ) ); + static_cast*> (&FrequencyConverterInputSource)->SetNumEnums( 13 ); + static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line1, "Line1" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line2, "Line2" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line3, "Line3" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line4, "Line4" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line5, "Line5" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line6, "Line6" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line7, "Line7" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_Line8, "Line8" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC1, "CC1" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC2, "CC2" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC3, "CC3" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_CC4, "CC4" ); static_cast*> (&FrequencyConverterInputSource)->SetEnumReference( FrequencyConverterInputSource_ShaftEncoderModuleOut, "ShaftEncoderModuleOut" ); static_cast*> (&FrequencyConverterSignalAlignment)->SetReference( _Ptr->GetNode( "FrequencyConverterSignalAlignment" ) ); + static_cast*> (&FrequencyConverterSignalAlignment)->SetNumEnums( 2 ); + static_cast*> (&FrequencyConverterSignalAlignment)->SetEnumReference( FrequencyConverterSignalAlignment_RisingEdge, "RisingEdge" ); static_cast*> (&FrequencyConverterSignalAlignment)->SetEnumReference( FrequencyConverterSignalAlignment_FallingEdge, "FallingEdge" ); static_cast (&FrequencyConverterPreDivider)->SetReference( _Ptr->GetNode( "FrequencyConverterPreDivider" ) ); + static_cast (&FrequencyConverterMultiplier)->SetReference( _Ptr->GetNode( "FrequencyConverterMultiplier" ) ); + static_cast (&FrequencyConverterPostDivider)->SetReference( _Ptr->GetNode( "FrequencyConverterPostDivider" ) ); + static_cast (&FrequencyConverterPreventOvertrigger)->SetReference( _Ptr->GetNode( "FrequencyConverterPreventOvertrigger" ) ); + static_cast (&TimerDelayTimebaseAbs)->SetReference( _Ptr->GetNode( "TimerDelayTimebaseAbs" ) ); + static_cast (&TimerDurationTimebaseAbs)->SetReference( _Ptr->GetNode( "TimerDurationTimebaseAbs" ) ); + static_cast*> (&TimerSelector)->SetReference( _Ptr->GetNode( "TimerSelector" ) ); + static_cast*> (&TimerSelector)->SetNumEnums( 4 ); + static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer1, "Timer1" ); static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer2, "Timer2" ); static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer3, "Timer3" ); static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer4, "Timer4" ); static_cast (&TimerDelayAbs)->SetReference( _Ptr->GetNode( "TimerDelayAbs" ) ); + static_cast (&TimerDelayRaw)->SetReference( _Ptr->GetNode( "TimerDelayRaw" ) ); + static_cast (&TimerDurationAbs)->SetReference( _Ptr->GetNode( "TimerDurationAbs" ) ); + static_cast (&TimerDurationRaw)->SetReference( _Ptr->GetNode( "TimerDurationRaw" ) ); + static_cast*> (&TimerTriggerSource)->SetReference( _Ptr->GetNode( "TimerTriggerSource" ) ); + static_cast*> (&TimerTriggerSource)->SetNumEnums( 3 ); + static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_Off, "Off" ); static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_ExposureStart, "ExposureStart" ); static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_FlashWindowStart, "FlashWindowStart" ); static_cast*> (&TimerTriggerActivation)->SetReference( _Ptr->GetNode( "TimerTriggerActivation" ) ); + static_cast*> (&TimerTriggerActivation)->SetNumEnums( 4 ); + static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_RisingEdge, "RisingEdge" ); static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_FallingEdge, "FallingEdge" ); static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_LevelHigh, "LevelHigh" ); static_cast*> (&TimerTriggerActivation)->SetEnumReference( TimerTriggerActivation_LevelLow, "LevelLow" ); static_cast*> (&CounterSelector)->SetReference( _Ptr->GetNode( "CounterSelector" ) ); + static_cast*> (&CounterSelector)->SetNumEnums( 4 ); + static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter1, "Counter1" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter2, "Counter2" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter3, "Counter3" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter4, "Counter4" ); static_cast*> (&CounterEventSource)->SetReference( _Ptr->GetNode( "CounterEventSource" ) ); + static_cast*> (&CounterEventSource)->SetNumEnums( 12 ); + static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_Off, "Off" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_AcquisitionTrigger, "AcquisitionTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_AcquisitionStart, "AcquisitionStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_AcquisitionEnd, "AcquisitionEnd" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameTrigger, "FrameTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameStart, "FrameStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameEnd, "FrameEnd" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_LineTrigger, "LineTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_LineStart, "LineStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_LineEnd, "LineEnd" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_ExposureStart, "ExposureStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_ExposureEnd, "ExposureEnd" ); static_cast*> (&CounterResetSource)->SetReference( _Ptr->GetNode( "CounterResetSource" ) ); + static_cast*> (&CounterResetSource)->SetNumEnums( 19 ); + static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Off, "Off" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Software, "Software" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line1, "Line1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line2, "Line2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line3, "Line3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line4, "Line4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line5, "Line5" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line6, "Line6" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line7, "Line7" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line8, "Line8" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC1, "CC1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC2, "CC2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC3, "CC3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_CC4, "CC4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput1, "VInput1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput2, "VInput2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput3, "VInput3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInput4, "VInput4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_VInputDecActive, "VInputDecActive" ); static_cast (&CounterReset)->SetReference( _Ptr->GetNode( "CounterReset" ) ); + static_cast (&TimerSequenceEnable)->SetReference( _Ptr->GetNode( "TimerSequenceEnable" ) ); + static_cast (&TimerSequenceLastEntryIndex)->SetReference( _Ptr->GetNode( "TimerSequenceLastEntryIndex" ) ); + static_cast (&TimerSequenceCurrentEntryIndex)->SetReference( _Ptr->GetNode( "TimerSequenceCurrentEntryIndex" ) ); + static_cast*> (&TimerSequenceEntrySelector)->SetReference( _Ptr->GetNode( "TimerSequenceEntrySelector" ) ); + static_cast*> (&TimerSequenceEntrySelector)->SetNumEnums( 16 ); + static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry1, "Entry1" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry2, "Entry2" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry3, "Entry3" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry4, "Entry4" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry5, "Entry5" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry6, "Entry6" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry7, "Entry7" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry8, "Entry8" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry9, "Entry9" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry10, "Entry10" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry11, "Entry11" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry12, "Entry12" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry13, "Entry13" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry14, "Entry14" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry15, "Entry15" ); static_cast*> (&TimerSequenceEntrySelector)->SetEnumReference( TimerSequenceEntrySelector_Entry16, "Entry16" ); static_cast*> (&TimerSequenceTimerSelector)->SetReference( _Ptr->GetNode( "TimerSequenceTimerSelector" ) ); + static_cast*> (&TimerSequenceTimerSelector)->SetNumEnums( 4 ); + static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer1, "Timer1" ); static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer2, "Timer2" ); static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer3, "Timer3" ); static_cast*> (&TimerSequenceTimerSelector)->SetEnumReference( TimerSequenceTimerSelector_Timer4, "Timer4" ); static_cast (&TimerSequenceTimerEnable)->SetReference( _Ptr->GetNode( "TimerSequenceTimerEnable" ) ); + static_cast (&TimerSequenceTimerInverter)->SetReference( _Ptr->GetNode( "TimerSequenceTimerInverter" ) ); + static_cast (&TimerSequenceTimerDelayRaw)->SetReference( _Ptr->GetNode( "TimerSequenceTimerDelayRaw" ) ); + static_cast (&TimerSequenceTimerDurationRaw)->SetReference( _Ptr->GetNode( "TimerSequenceTimerDurationRaw" ) ); + static_cast*> (&LUTSelector)->SetReference( _Ptr->GetNode( "LUTSelector" ) ); + static_cast*> (&LUTSelector)->SetNumEnums( 1 ); + static_cast*> (&LUTSelector)->SetEnumReference( LUTSelector_Luminance, "Luminance" ); static_cast (&LUTEnable)->SetReference( _Ptr->GetNode( "LUTEnable" ) ); + static_cast (&LUTIndex)->SetReference( _Ptr->GetNode( "LUTIndex" ) ); + static_cast (&LUTValue)->SetReference( _Ptr->GetNode( "LUTValue" ) ); + static_cast (&LUTValueAll)->SetReference( _Ptr->GetNode( "LUTValueAll" ) ); + static_cast (&PayloadSize)->SetReference( _Ptr->GetNode( "PayloadSize" ) ); + static_cast (&GevSCPSPacketSize)->SetReference( _Ptr->GetNode( "GevSCPSPacketSize" ) ); + static_cast (&GevSCPD)->SetReference( _Ptr->GetNode( "GevSCPD" ) ); + static_cast (&GevSCFTD)->SetReference( _Ptr->GetNode( "GevSCFTD" ) ); + static_cast (&GevSCBWR)->SetReference( _Ptr->GetNode( "GevSCBWR" ) ); + static_cast (&GevSCBWRA)->SetReference( _Ptr->GetNode( "GevSCBWRA" ) ); + static_cast (&GevSCBWA)->SetReference( _Ptr->GetNode( "GevSCBWA" ) ); + static_cast (&GevSCDMT)->SetReference( _Ptr->GetNode( "GevSCDMT" ) ); + static_cast (&GevSCDCT)->SetReference( _Ptr->GetNode( "GevSCDCT" ) ); + static_cast (&GevSCFJM)->SetReference( _Ptr->GetNode( "GevSCFJM" ) ); + static_cast (&GevVersionMajor)->SetReference( _Ptr->GetNode( "GevVersionMajor" ) ); + static_cast (&GevVersionMinor)->SetReference( _Ptr->GetNode( "GevVersionMinor" ) ); + static_cast (&GevDeviceModeIsBigEndian)->SetReference( _Ptr->GetNode( "GevDeviceModeIsBigEndian" ) ); + static_cast (&GevDeviceModeCharacterSet)->SetReference( _Ptr->GetNode( "GevDeviceModeCharacterSet" ) ); + static_cast*> (&GevInterfaceSelector)->SetReference( _Ptr->GetNode( "GevInterfaceSelector" ) ); + static_cast*> (&GevInterfaceSelector)->SetNumEnums( 1 ); + static_cast*> (&GevInterfaceSelector)->SetEnumReference( GevInterfaceSelector_NetworkInterface0, "NetworkInterface0" ); static_cast (&GevMACAddress)->SetReference( _Ptr->GetNode( "GevMACAddress" ) ); + static_cast*> (&GevGVSPExtendedIDMode)->SetReference( _Ptr->GetNode( "GevGVSPExtendedIDMode" ) ); + static_cast*> (&GevGVSPExtendedIDMode)->SetNumEnums( 2 ); + static_cast*> (&GevGVSPExtendedIDMode)->SetEnumReference( GevGVSPExtendedIDMode_Off, "Off" ); static_cast*> (&GevGVSPExtendedIDMode)->SetEnumReference( GevGVSPExtendedIDMode_On, "On" ); static_cast (&GevSupportedIPConfigurationLLA)->SetReference( _Ptr->GetNode( "GevSupportedIPConfigurationLLA" ) ); + static_cast (&GevSupportedIPConfigurationDHCP)->SetReference( _Ptr->GetNode( "GevSupportedIPConfigurationDHCP" ) ); + static_cast (&GevSupportedIPConfigurationPersistentIP)->SetReference( _Ptr->GetNode( "GevSupportedIPConfigurationPersistentIP" ) ); + static_cast (&GevCurrentIPConfiguration)->SetReference( _Ptr->GetNode( "GevCurrentIPConfiguration" ) ); + static_cast (&GevCurrentIPAddress)->SetReference( _Ptr->GetNode( "GevCurrentIPAddress" ) ); + static_cast (&GevCurrentSubnetMask)->SetReference( _Ptr->GetNode( "GevCurrentSubnetMask" ) ); + static_cast (&GevCurrentDefaultGateway)->SetReference( _Ptr->GetNode( "GevCurrentDefaultGateway" ) ); + static_cast (&GevPersistentIPAddress)->SetReference( _Ptr->GetNode( "GevPersistentIPAddress" ) ); + static_cast (&GevPersistentSubnetMask)->SetReference( _Ptr->GetNode( "GevPersistentSubnetMask" ) ); + static_cast (&GevPersistentDefaultGateway)->SetReference( _Ptr->GetNode( "GevPersistentDefaultGateway" ) ); + static_cast (&GevLinkSpeed)->SetReference( _Ptr->GetNode( "GevLinkSpeed" ) ); + static_cast (&GevLinkMaster)->SetReference( _Ptr->GetNode( "GevLinkMaster" ) ); + static_cast (&GevLinkFullDuplex)->SetReference( _Ptr->GetNode( "GevLinkFullDuplex" ) ); + static_cast (&GevLinkCrossover)->SetReference( _Ptr->GetNode( "GevLinkCrossover" ) ); + static_cast (&GevFirstURL)->SetReference( _Ptr->GetNode( "GevFirstURL" ) ); + static_cast (&GevSecondURL)->SetReference( _Ptr->GetNode( "GevSecondURL" ) ); + static_cast (&GevNumberOfInterfaces)->SetReference( _Ptr->GetNode( "GevNumberOfInterfaces" ) ); + static_cast (&GevMessageChannelCount)->SetReference( _Ptr->GetNode( "GevMessageChannelCount" ) ); + static_cast (&GevStreamChannelCount)->SetReference( _Ptr->GetNode( "GevStreamChannelCount" ) ); + static_cast (&GevSupportedOptionalLegacy16BitBlockID)->SetReference( _Ptr->GetNode( "GevSupportedOptionalLegacy16BitBlockID" ) ); + static_cast (&GevSupportedIEEE1588)->SetReference( _Ptr->GetNode( "GevSupportedIEEE1588" ) ); + static_cast (&GevSupportedOptionalCommandsEVENTDATA)->SetReference( _Ptr->GetNode( "GevSupportedOptionalCommandsEVENTDATA" ) ); + static_cast (&GevSupportedOptionalCommandsEVENT)->SetReference( _Ptr->GetNode( "GevSupportedOptionalCommandsEVENT" ) ); + static_cast (&GevSupportedOptionalCommandsPACKETRESEND)->SetReference( _Ptr->GetNode( "GevSupportedOptionalCommandsPACKETRESEND" ) ); + static_cast (&GevSupportedOptionalCommandsWRITEMEM)->SetReference( _Ptr->GetNode( "GevSupportedOptionalCommandsWRITEMEM" ) ); + static_cast (&GevSupportedOptionalCommandsConcatenation)->SetReference( _Ptr->GetNode( "GevSupportedOptionalCommandsConcatenation" ) ); + static_cast (&GevHeartbeatTimeout)->SetReference( _Ptr->GetNode( "GevHeartbeatTimeout" ) ); + static_cast (&GevTimestampTickFrequency)->SetReference( _Ptr->GetNode( "GevTimestampTickFrequency" ) ); + static_cast (&GevTimestampControlLatch)->SetReference( _Ptr->GetNode( "GevTimestampControlLatch" ) ); + static_cast (&GevTimestampControlReset)->SetReference( _Ptr->GetNode( "GevTimestampControlReset" ) ); + static_cast (&GevTimestampControlLatchReset)->SetReference( _Ptr->GetNode( "GevTimestampControlLatchReset" ) ); + static_cast (&GevTimestampValue)->SetReference( _Ptr->GetNode( "GevTimestampValue" ) ); + static_cast*> (&GevCCP)->SetReference( _Ptr->GetNode( "GevCCP" ) ); + static_cast*> (&GevCCP)->SetNumEnums( 3 ); + static_cast*> (&GevCCP)->SetEnumReference( GevCCP_Exclusive, "Exclusive" ); static_cast*> (&GevCCP)->SetEnumReference( GevCCP_Control, "Control" ); static_cast*> (&GevCCP)->SetEnumReference( GevCCP_ExclusiveControl, "ExclusiveControl" ); static_cast*> (&GevStreamChannelSelector)->SetReference( _Ptr->GetNode( "GevStreamChannelSelector" ) ); + static_cast*> (&GevStreamChannelSelector)->SetNumEnums( 1 ); + static_cast*> (&GevStreamChannelSelector)->SetEnumReference( GevStreamChannelSelector_StreamChannel0, "StreamChannel0" ); static_cast (&GevSCPInterfaceIndex)->SetReference( _Ptr->GetNode( "GevSCPInterfaceIndex" ) ); + static_cast (&GevSCDA)->SetReference( _Ptr->GetNode( "GevSCDA" ) ); + static_cast (&GevSCPHostPort)->SetReference( _Ptr->GetNode( "GevSCPHostPort" ) ); + static_cast (&GevSCPSFireTestPacket)->SetReference( _Ptr->GetNode( "GevSCPSFireTestPacket" ) ); + static_cast (&GevSCPSDoNotFragment)->SetReference( _Ptr->GetNode( "GevSCPSDoNotFragment" ) ); + static_cast (&GevSCPSBigEndian)->SetReference( _Ptr->GetNode( "GevSCPSBigEndian" ) ); + static_cast (&TLParamsLocked)->SetReference( _Ptr->GetNode( "TLParamsLocked" ) ); + static_cast (&PixelFormatLegacy)->SetReference( _Ptr->GetNode( "PixelFormatLegacy" ) ); + static_cast (&GevIEEE1588)->SetReference( _Ptr->GetNode( "GevIEEE1588" ) ); + static_cast*> (&GevIEEE1588Status)->SetReference( _Ptr->GetNode( "GevIEEE1588Status" ) ); + static_cast*> (&GevIEEE1588Status)->SetNumEnums( 10 ); + static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Undefined, "Undefined" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Initializing, "Initializing" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Faulty, "Faulty" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Disabled, "Disabled" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Listening, "Listening" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_PreMaster, "PreMaster" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Master, "Master" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Passive, "Passive" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Uncalibrated, "Uncalibrated" ); static_cast*> (&GevIEEE1588Status)->SetEnumReference( GevIEEE1588Status_Slave, "Slave" ); static_cast (&GevIEEE1588DataSetLatch)->SetReference( _Ptr->GetNode( "GevIEEE1588DataSetLatch" ) ); + static_cast*> (&GevIEEE1588StatusLatched)->SetReference( _Ptr->GetNode( "GevIEEE1588StatusLatched" ) ); + static_cast*> (&GevIEEE1588StatusLatched)->SetNumEnums( 10 ); + static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Undefined, "Undefined" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Initializing, "Initializing" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Faulty, "Faulty" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Disabled, "Disabled" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Listening, "Listening" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_PreMaster, "PreMaster" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Master, "Master" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Passive, "Passive" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Uncalibrated, "Uncalibrated" ); static_cast*> (&GevIEEE1588StatusLatched)->SetEnumReference( GevIEEE1588StatusLatched_Slave, "Slave" ); static_cast (&GevIEEE1588OffsetFromMaster)->SetReference( _Ptr->GetNode( "GevIEEE1588OffsetFromMaster" ) ); + static_cast (&GevIEEE1588ClockIdLow)->SetReference( _Ptr->GetNode( "GevIEEE1588ClockIdLow" ) ); + static_cast (&GevIEEE1588ClockIdHigh)->SetReference( _Ptr->GetNode( "GevIEEE1588ClockIdHigh" ) ); + static_cast (&GevIEEE1588ClockId)->SetReference( _Ptr->GetNode( "GevIEEE1588ClockId" ) ); + static_cast (&GevIEEE1588ParentClockIdLow)->SetReference( _Ptr->GetNode( "GevIEEE1588ParentClockIdLow" ) ); + static_cast (&GevIEEE1588ParentClockIdHigh)->SetReference( _Ptr->GetNode( "GevIEEE1588ParentClockIdHigh" ) ); + static_cast (&GevIEEE1588ParentClockId)->SetReference( _Ptr->GetNode( "GevIEEE1588ParentClockId" ) ); + static_cast (&GevPTPDiagnosticsQueueRxEvntMaxNumElements)->SetReference( _Ptr->GetNode( "GevPTPDiagnosticsQueueRxEvntMaxNumElements" ) ); + static_cast (&GevPTPDiagnosticsQueueRxGnrlMaxNumElements)->SetReference( _Ptr->GetNode( "GevPTPDiagnosticsQueueRxGnrlMaxNumElements" ) ); + static_cast (&GevPTPDiagnosticsQueueRxEvntPushNumFailure)->SetReference( _Ptr->GetNode( "GevPTPDiagnosticsQueueRxEvntPushNumFailure" ) ); + static_cast (&GevPTPDiagnosticsQueueRxGnrlPushNumFailure)->SetReference( _Ptr->GetNode( "GevPTPDiagnosticsQueueRxGnrlPushNumFailure" ) ); + static_cast (&GevPTPDiagnosticsQueueSendNumFailure)->SetReference( _Ptr->GetNode( "GevPTPDiagnosticsQueueSendNumFailure" ) ); + static_cast (&NumberOfActionSignals)->SetReference( _Ptr->GetNode( "NumberOfActionSignals" ) ); + static_cast (&ActionCommandCount)->SetReference( _Ptr->GetNode( "ActionCommandCount" ) ); + static_cast (&ActionDeviceKey)->SetReference( _Ptr->GetNode( "ActionDeviceKey" ) ); + static_cast (&ActionSelector)->SetReference( _Ptr->GetNode( "ActionSelector" ) ); + static_cast (&ActionGroupKey)->SetReference( _Ptr->GetNode( "ActionGroupKey" ) ); + static_cast (&ActionGroupMask)->SetReference( _Ptr->GetNode( "ActionGroupMask" ) ); + static_cast (&DeviceRegistersStreamingStart)->SetReference( _Ptr->GetNode( "DeviceRegistersStreamingStart" ) ); + static_cast (&DeviceRegistersStreamingEnd)->SetReference( _Ptr->GetNode( "DeviceRegistersStreamingEnd" ) ); + static_cast*> (&UserSetSelector)->SetReference( _Ptr->GetNode( "UserSetSelector" ) ); + static_cast*> (&UserSetSelector)->SetNumEnums( 11 ); + static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Default, "Default" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_HighGain, "HighGain" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Color, "Color" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_ColorRaw, "ColorRaw" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Custom0, "Custom0" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Custom1, "Custom1" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet1, "UserSet1" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet2, "UserSet2" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet3, "UserSet3" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_LightMicroscopy, "LightMicroscopy" ); static_cast (&UserSetLoad)->SetReference( _Ptr->GetNode( "UserSetLoad" ) ); + static_cast (&UserSetSave)->SetReference( _Ptr->GetNode( "UserSetSave" ) ); + static_cast*> (&UserSetDefaultSelector)->SetReference( _Ptr->GetNode( "UserSetDefaultSelector" ) ); + static_cast*> (&UserSetDefaultSelector)->SetNumEnums( 11 ); + static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Default, "Default" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_HighGain, "HighGain" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Color, "Color" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_ColorRaw, "ColorRaw" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Custom0, "Custom0" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_Custom1, "Custom1" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_UserSet1, "UserSet1" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_UserSet2, "UserSet2" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_UserSet3, "UserSet3" ); static_cast*> (&UserSetDefaultSelector)->SetEnumReference( UserSetDefaultSelector_LightMicroscopy, "LightMicroscopy" ); static_cast*> (&DefaultSetSelector)->SetReference( _Ptr->GetNode( "DefaultSetSelector" ) ); + static_cast*> (&DefaultSetSelector)->SetNumEnums( 8 ); + static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Standard, "Standard" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_HighGain, "HighGain" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Color, "Color" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_ColorRaw, "ColorRaw" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Custom0, "Custom0" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_Custom1, "Custom1" ); static_cast*> (&DefaultSetSelector)->SetEnumReference( DefaultSetSelector_LightMicroscopy, "LightMicroscopy" ); static_cast (&AutoTargetValue)->SetReference( _Ptr->GetNode( "AutoTargetValue" ) ); + static_cast (&GrayValueAdjustmentDampingAbs)->SetReference( _Ptr->GetNode( "GrayValueAdjustmentDampingAbs" ) ); + static_cast (&GrayValueAdjustmentDampingRaw)->SetReference( _Ptr->GetNode( "GrayValueAdjustmentDampingRaw" ) ); + static_cast (&BalanceWhiteAdjustmentDampingAbs)->SetReference( _Ptr->GetNode( "BalanceWhiteAdjustmentDampingAbs" ) ); + static_cast (&BalanceWhiteAdjustmentDampingRaw)->SetReference( _Ptr->GetNode( "BalanceWhiteAdjustmentDampingRaw" ) ); + static_cast (&AutoGainRawLowerLimit)->SetReference( _Ptr->GetNode( "AutoGainRawLowerLimit" ) ); + static_cast (&AutoGainRawUpperLimit)->SetReference( _Ptr->GetNode( "AutoGainRawUpperLimit" ) ); + static_cast (&AutoExposureTimeAbsLowerLimit)->SetReference( _Ptr->GetNode( "AutoExposureTimeAbsLowerLimit" ) ); + static_cast (&AutoExposureTimeAbsUpperLimit)->SetReference( _Ptr->GetNode( "AutoExposureTimeAbsUpperLimit" ) ); + static_cast*> (&AutoFunctionProfile)->SetReference( _Ptr->GetNode( "AutoFunctionProfile" ) ); + static_cast*> (&AutoFunctionProfile)->SetNumEnums( 4 ); + static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_GainMinimum, "GainMinimum" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_ExposureMinimum, "ExposureMinimum" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_GainMinimumQuick, "GainMinimumQuick" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_ExposureMinimumQuick, "ExposureMinimumQuick" ); static_cast*> (&AutoFunctionAOISelector)->SetReference( _Ptr->GetNode( "AutoFunctionAOISelector" ) ); + static_cast*> (&AutoFunctionAOISelector)->SetNumEnums( 8 ); + static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI1, "AOI1" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI2, "AOI2" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI3, "AOI3" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI4, "AOI4" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI5, "AOI5" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI6, "AOI6" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI7, "AOI7" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI8, "AOI8" ); static_cast (&AutoFunctionAOIWidth)->SetReference( _Ptr->GetNode( "AutoFunctionAOIWidth" ) ); + static_cast (&AutoFunctionAOIHeight)->SetReference( _Ptr->GetNode( "AutoFunctionAOIHeight" ) ); + static_cast (&AutoFunctionAOIOffsetX)->SetReference( _Ptr->GetNode( "AutoFunctionAOIOffsetX" ) ); + static_cast (&AutoFunctionAOIOffsetY)->SetReference( _Ptr->GetNode( "AutoFunctionAOIOffsetY" ) ); + static_cast (&AutoFunctionAOIUsageIntensity)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageIntensity" ) ); + static_cast (&AutoFunctionAOIUsageWhiteBalance)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageWhiteBalance" ) ); + static_cast (&AutoFunctionAOIUsageRedLightCorrection)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageRedLightCorrection" ) ); + static_cast (&AutoFunctionAOIUsageTonalRange)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUsageTonalRange" ) ); + static_cast*> (&AutoTonalRangeModeSelector)->SetReference( _Ptr->GetNode( "AutoTonalRangeModeSelector" ) ); + static_cast*> (&AutoTonalRangeModeSelector)->SetNumEnums( 3 ); + static_cast*> (&AutoTonalRangeModeSelector)->SetEnumReference( AutoTonalRangeModeSelector_ColorAndContrast, "ColorAndContrast" ); static_cast*> (&AutoTonalRangeModeSelector)->SetEnumReference( AutoTonalRangeModeSelector_Color, "Color" ); static_cast*> (&AutoTonalRangeModeSelector)->SetEnumReference( AutoTonalRangeModeSelector_Contrast, "Contrast" ); static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetReference( _Ptr->GetNode( "AutoTonalRangeAdjustmentSelector" ) ); + static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetNumEnums( 3 ); + static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetEnumReference( AutoTonalRangeAdjustmentSelector_DarkAndBright, "DarkAndBright" ); static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetEnumReference( AutoTonalRangeAdjustmentSelector_Bright, "Bright" ); static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetEnumReference( AutoTonalRangeAdjustmentSelector_Dark, "Dark" ); static_cast (&AutoTonalRangeThresholdDark)->SetReference( _Ptr->GetNode( "AutoTonalRangeThresholdDark" ) ); + static_cast (&AutoTonalRangeThresholdDarkRaw)->SetReference( _Ptr->GetNode( "AutoTonalRangeThresholdDarkRaw" ) ); + static_cast (&AutoTonalRangeThresholdBright)->SetReference( _Ptr->GetNode( "AutoTonalRangeThresholdBright" ) ); + static_cast (&AutoTonalRangeThresholdBrightRaw)->SetReference( _Ptr->GetNode( "AutoTonalRangeThresholdBrightRaw" ) ); + static_cast (&AutoTonalRangeTargetDark)->SetReference( _Ptr->GetNode( "AutoTonalRangeTargetDark" ) ); + static_cast (&AutoTonalRangeTargetBright)->SetReference( _Ptr->GetNode( "AutoTonalRangeTargetBright" ) ); + static_cast*> (&ColorOverexposureCompensationAOISelector)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOISelector" ) ); + static_cast*> (&ColorOverexposureCompensationAOISelector)->SetNumEnums( 1 ); + static_cast*> (&ColorOverexposureCompensationAOISelector)->SetEnumReference( ColorOverexposureCompensationAOISelector_AOI1, "AOI1" ); static_cast (&ColorOverexposureCompensationAOIEnable)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIEnable" ) ); + static_cast (&ColorOverexposureCompensationAOIFactor)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIFactor" ) ); + static_cast (&ColorOverexposureCompensationAOIFactorRaw)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIFactorRaw" ) ); + static_cast (&ColorOverexposureCompensationAOIWidth)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIWidth" ) ); + static_cast (&ColorOverexposureCompensationAOIHeight)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIHeight" ) ); + static_cast (&ColorOverexposureCompensationAOIOffsetX)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIOffsetX" ) ); + static_cast (&ColorOverexposureCompensationAOIOffsetY)->SetReference( _Ptr->GetNode( "ColorOverexposureCompensationAOIOffsetY" ) ); + static_cast*> (&ShadingSelector)->SetReference( _Ptr->GetNode( "ShadingSelector" ) ); + static_cast*> (&ShadingSelector)->SetNumEnums( 2 ); + static_cast*> (&ShadingSelector)->SetEnumReference( ShadingSelector_OffsetShading, "OffsetShading" ); static_cast*> (&ShadingSelector)->SetEnumReference( ShadingSelector_GainShading, "GainShading" ); static_cast (&ShadingEnable)->SetReference( _Ptr->GetNode( "ShadingEnable" ) ); + static_cast*> (&ShadingStatus)->SetReference( _Ptr->GetNode( "ShadingStatus" ) ); + static_cast*> (&ShadingStatus)->SetNumEnums( 4 ); + static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_NoError, "NoError" ); static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_StartupSetError, "StartupSetError" ); static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_ActivateError, "ActivateError" ); static_cast*> (&ShadingStatus)->SetEnumReference( ShadingStatus_CreateError, "CreateError" ); static_cast*> (&ShadingSetDefaultSelector)->SetReference( _Ptr->GetNode( "ShadingSetDefaultSelector" ) ); + static_cast*> (&ShadingSetDefaultSelector)->SetNumEnums( 3 ); + static_cast*> (&ShadingSetDefaultSelector)->SetEnumReference( ShadingSetDefaultSelector_DefaultShadingSet, "DefaultShadingSet" ); static_cast*> (&ShadingSetDefaultSelector)->SetEnumReference( ShadingSetDefaultSelector_UserShadingSet1, "UserShadingSet1" ); static_cast*> (&ShadingSetDefaultSelector)->SetEnumReference( ShadingSetDefaultSelector_UserShadingSet2, "UserShadingSet2" ); static_cast*> (&ShadingSetSelector)->SetReference( _Ptr->GetNode( "ShadingSetSelector" ) ); + static_cast*> (&ShadingSetSelector)->SetNumEnums( 3 ); + static_cast*> (&ShadingSetSelector)->SetEnumReference( ShadingSetSelector_DefaultShadingSet, "DefaultShadingSet" ); static_cast*> (&ShadingSetSelector)->SetEnumReference( ShadingSetSelector_UserShadingSet1, "UserShadingSet1" ); static_cast*> (&ShadingSetSelector)->SetEnumReference( ShadingSetSelector_UserShadingSet2, "UserShadingSet2" ); static_cast (&ShadingSetActivate)->SetReference( _Ptr->GetNode( "ShadingSetActivate" ) ); + static_cast*> (&ShadingSetCreate)->SetReference( _Ptr->GetNode( "ShadingSetCreate" ) ); + static_cast*> (&ShadingSetCreate)->SetNumEnums( 2 ); + static_cast*> (&ShadingSetCreate)->SetEnumReference( ShadingSetCreate_Off, "Off" ); static_cast*> (&ShadingSetCreate)->SetEnumReference( ShadingSetCreate_Once, "Once" ); static_cast*> (&UserDefinedValueSelector)->SetReference( _Ptr->GetNode( "UserDefinedValueSelector" ) ); + static_cast*> (&UserDefinedValueSelector)->SetNumEnums( 5 ); + static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value1, "Value1" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value2, "Value2" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value3, "Value3" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value4, "Value4" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value5, "Value5" ); static_cast (&UserDefinedValue)->SetReference( _Ptr->GetNode( "UserDefinedValue" ) ); + static_cast (&GenicamXmlFileDefault)->SetReference( _Ptr->GetNode( "GenicamXmlFileDefault" ) ); + static_cast*> (&FeatureSet)->SetReference( _Ptr->GetNode( "FeatureSet" ) ); + static_cast*> (&FeatureSet)->SetNumEnums( 2 ); + static_cast*> (&FeatureSet)->SetEnumReference( FeatureSet_Full, "Full" ); static_cast*> (&FeatureSet)->SetEnumReference( FeatureSet_Basic, "Basic" ); static_cast (&DeviceVendorName)->SetReference( _Ptr->GetNode( "DeviceVendorName" ) ); + static_cast (&DeviceModelName)->SetReference( _Ptr->GetNode( "DeviceModelName" ) ); + static_cast (&DeviceManufacturerInfo)->SetReference( _Ptr->GetNode( "DeviceManufacturerInfo" ) ); + static_cast (&DeviceVersion)->SetReference( _Ptr->GetNode( "DeviceVersion" ) ); + static_cast (&DeviceFirmwareVersion)->SetReference( _Ptr->GetNode( "DeviceFirmwareVersion" ) ); + static_cast (&DeviceID)->SetReference( _Ptr->GetNode( "DeviceID" ) ); + static_cast (&DeviceUserID)->SetReference( _Ptr->GetNode( "DeviceUserID" ) ); + static_cast*> (&DeviceScanType)->SetReference( _Ptr->GetNode( "DeviceScanType" ) ); + static_cast*> (&DeviceScanType)->SetNumEnums( 2 ); + static_cast*> (&DeviceScanType)->SetEnumReference( DeviceScanType_Areascan, "Areascan" ); static_cast*> (&DeviceScanType)->SetEnumReference( DeviceScanType_Linescan, "Linescan" ); static_cast (&DeviceReset)->SetReference( _Ptr->GetNode( "DeviceReset" ) ); + static_cast*> (&TemperatureSelector)->SetReference( _Ptr->GetNode( "TemperatureSelector" ) ); + static_cast*> (&TemperatureSelector)->SetNumEnums( 4 ); + static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Sensorboard, "Sensorboard" ); static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Coreboard, "Coreboard" ); static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Framegrabberboard, "Framegrabberboard" ); static_cast*> (&TemperatureSelector)->SetEnumReference( TemperatureSelector_Case, "Case" ); static_cast (&TemperatureAbs)->SetReference( _Ptr->GetNode( "TemperatureAbs" ) ); + static_cast*> (&TemperatureState)->SetReference( _Ptr->GetNode( "TemperatureState" ) ); + static_cast*> (&TemperatureState)->SetNumEnums( 3 ); + static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Ok, "Ok" ); static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Critical, "Critical" ); static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Error, "Error" ); static_cast (&CriticalTemperature)->SetReference( _Ptr->GetNode( "CriticalTemperature" ) ); + static_cast (&OverTemperature)->SetReference( _Ptr->GetNode( "OverTemperature" ) ); + static_cast*> (&LastError)->SetReference( _Ptr->GetNode( "LastError" ) ); + static_cast*> (&LastError)->SetNumEnums( 8 ); + static_cast*> (&LastError)->SetEnumReference( LastError_NoError, "NoError" ); static_cast*> (&LastError)->SetEnumReference( LastError_Overtrigger, "Overtrigger" ); static_cast*> (&LastError)->SetEnumReference( LastError_Userset, "Userset" ); static_cast*> (&LastError)->SetEnumReference( LastError_InvalidParameter, "InvalidParameter" ); static_cast*> (&LastError)->SetEnumReference( LastError_OverTemperature, "OverTemperature" ); static_cast*> (&LastError)->SetEnumReference( LastError_PowerFailure, "PowerFailure" ); static_cast*> (&LastError)->SetEnumReference( LastError_InsufficientTriggerWidth, "InsufficientTriggerWidth" ); static_cast*> (&LastError)->SetEnumReference( LastError_UserDefPixFailure, "UserDefPixFailure" ); static_cast (&ClearLastError)->SetReference( _Ptr->GetNode( "ClearLastError" ) ); + static_cast (&DeviceColorPipelineVersion)->SetReference( _Ptr->GetNode( "DeviceColorPipelineVersion" ) ); + static_cast*> (&ParameterSelector)->SetReference( _Ptr->GetNode( "ParameterSelector" ) ); + static_cast*> (&ParameterSelector)->SetNumEnums( 8 ); + static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_Gain, "Gain" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_Brightness, "Brightness" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_BlackLevel, "BlackLevel" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_ExposureTime, "ExposureTime" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_Framerate, "Framerate" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_AutoTargetValue, "AutoTargetValue" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_ExposureOverhead, "ExposureOverhead" ); static_cast*> (&ParameterSelector)->SetEnumReference( ParameterSelector_ExposureOverlapMax, "ExposureOverlapMax" ); static_cast (&RemoveLimits)->SetReference( _Ptr->GetNode( "RemoveLimits" ) ); + static_cast (&Prelines)->SetReference( _Ptr->GetNode( "Prelines" ) ); + static_cast*> (&ExpertFeatureAccessSelector)->SetReference( _Ptr->GetNode( "ExpertFeatureAccessSelector" ) ); + static_cast*> (&ExpertFeatureAccessSelector)->SetNumEnums( 11 ); + static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature1_Legacy, "ExpertFeature1_Legacy" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature1, "ExpertFeature1" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature2, "ExpertFeature2" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature3, "ExpertFeature3" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature4, "ExpertFeature4" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature5, "ExpertFeature5" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature6, "ExpertFeature6" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature7, "ExpertFeature7" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature8, "ExpertFeature8" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature9, "ExpertFeature9" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature10, "ExpertFeature10" ); static_cast (&ExpertFeatureAccessKey)->SetReference( _Ptr->GetNode( "ExpertFeatureAccessKey" ) ); + static_cast (&ExpertFeatureEnable)->SetReference( _Ptr->GetNode( "ExpertFeatureEnable" ) ); + static_cast (&ChunkModeActive)->SetReference( _Ptr->GetNode( "ChunkModeActive" ) ); + static_cast*> (&ChunkSelector)->SetReference( _Ptr->GetNode( "ChunkSelector" ) ); + static_cast*> (&ChunkSelector)->SetNumEnums( 27 ); + static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Image, "Image" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_OffsetX, "OffsetX" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_OffsetY, "OffsetY" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Width, "Width" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Height, "Height" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_PixelFormat, "PixelFormat" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_DynamicRangeMax, "DynamicRangeMax" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_DynamicRangeMin, "DynamicRangeMin" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Timestamp, "Timestamp" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_LineStatusAll, "LineStatusAll" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Framecounter, "Framecounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Triggerinputcounter, "Triggerinputcounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_LineTriggerIgnoredCounter, "LineTriggerIgnoredCounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_FrameTriggerIgnoredCounter, "FrameTriggerIgnoredCounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_LineTriggerEndToEndCounter, "LineTriggerEndToEndCounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_FrameTriggerCounter, "FrameTriggerCounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_FramesPerTriggerCounter, "FramesPerTriggerCounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_InputStatusAtLineTrigger, "InputStatusAtLineTrigger" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_ShaftEncoderCounter, "ShaftEncoderCounter" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_PayloadCRC16, "PayloadCRC16" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Stride, "Stride" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_SequenceSetIndex, "SequenceSetIndex" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_ExposureTime, "ExposureTime" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_GainAll, "GainAll" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_BrightPixel, "BrightPixel" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_VirtLineStatusAll, "VirtLineStatusAll" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_LineTriggerCounter, "LineTriggerCounter" ); static_cast (&ChunkEnable)->SetReference( _Ptr->GetNode( "ChunkEnable" ) ); + static_cast (&ChunkStride)->SetReference( _Ptr->GetNode( "ChunkStride" ) ); + static_cast (&ChunkSequenceSetIndex)->SetReference( _Ptr->GetNode( "ChunkSequenceSetIndex" ) ); + static_cast (&ChunkOffsetX)->SetReference( _Ptr->GetNode( "ChunkOffsetX" ) ); + static_cast (&ChunkOffsetY)->SetReference( _Ptr->GetNode( "ChunkOffsetY" ) ); + static_cast (&ChunkWidth)->SetReference( _Ptr->GetNode( "ChunkWidth" ) ); + static_cast (&ChunkHeight)->SetReference( _Ptr->GetNode( "ChunkHeight" ) ); + static_cast (&ChunkDynamicRangeMin)->SetReference( _Ptr->GetNode( "ChunkDynamicRangeMin" ) ); + static_cast (&ChunkDynamicRangeMax)->SetReference( _Ptr->GetNode( "ChunkDynamicRangeMax" ) ); + static_cast*> (&ChunkPixelFormat)->SetReference( _Ptr->GetNode( "ChunkPixelFormat" ) ); + static_cast*> (&ChunkPixelFormat)->SetNumEnums( 51 ); + static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono8, "Mono8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono8Signed, "Mono8Signed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono10, "Mono10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono10Packed, "Mono10Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono10p, "Mono10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono12, "Mono12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono12Packed, "Mono12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono16, "Mono16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR8, "BayerGR8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG8, "BayerRG8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB8, "BayerGB8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG8, "BayerBG8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR10, "BayerGR10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG10, "BayerRG10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB10, "BayerGB10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG10, "BayerBG10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR12, "BayerGR12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG12, "BayerRG12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB12, "BayerGB12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG12, "BayerBG12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR16, "BayerGR16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG16, "BayerRG16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB16, "BayerGB16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG16, "BayerBG16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB8Packed, "RGB8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGR8Packed, "BGR8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGBA8Packed, "RGBA8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGRA8Packed, "BGRA8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10Packed, "RGB10Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGR10Packed, "BGR10Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB12Packed, "RGB12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGR12Packed, "BGR12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10V1Packed, "RGB10V1Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10V2Packed, "RGB10V2Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV411Packed, "YUV411Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV422Packed, "YUV422Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV444Packed, "YUV444Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB8Planar, "RGB8Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10Planar, "RGB10Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB12Planar, "RGB12Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB16Planar, "RGB16Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV422_YUYV_Packed, "YUV422_YUYV_Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB12Packed, "BayerGB12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR12Packed, "BayerGR12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG12Packed, "BayerRG12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG12Packed, "BayerBG12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB12V1Packed, "RGB12V1Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB10p, "BayerGB10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR10p, "BayerGR10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG10p, "BayerRG10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG10p, "BayerBG10p" ); static_cast (&ChunkTimestamp)->SetReference( _Ptr->GetNode( "ChunkTimestamp" ) ); + static_cast (&ChunkFramecounter)->SetReference( _Ptr->GetNode( "ChunkFramecounter" ) ); + static_cast (&ChunkLineStatusAll)->SetReference( _Ptr->GetNode( "ChunkLineStatusAll" ) ); + static_cast (&ChunkVirtLineStatusAll)->SetReference( _Ptr->GetNode( "ChunkVirtLineStatusAll" ) ); + static_cast (&ChunkTriggerinputcounter)->SetReference( _Ptr->GetNode( "ChunkTriggerinputcounter" ) ); + static_cast (&ChunkLineTriggerIgnoredCounter)->SetReference( _Ptr->GetNode( "ChunkLineTriggerIgnoredCounter" ) ); + static_cast (&ChunkFrameTriggerIgnoredCounter)->SetReference( _Ptr->GetNode( "ChunkFrameTriggerIgnoredCounter" ) ); + static_cast (&ChunkFrameTriggerCounter)->SetReference( _Ptr->GetNode( "ChunkFrameTriggerCounter" ) ); + static_cast (&ChunkFramesPerTriggerCounter)->SetReference( _Ptr->GetNode( "ChunkFramesPerTriggerCounter" ) ); + static_cast (&ChunkLineTriggerEndToEndCounter)->SetReference( _Ptr->GetNode( "ChunkLineTriggerEndToEndCounter" ) ); + static_cast (&ChunkInputStatusAtLineTriggerBitsPerLine)->SetReference( _Ptr->GetNode( "ChunkInputStatusAtLineTriggerBitsPerLine" ) ); + static_cast (&ChunkInputStatusAtLineTriggerIndex)->SetReference( _Ptr->GetNode( "ChunkInputStatusAtLineTriggerIndex" ) ); + static_cast (&ChunkInputStatusAtLineTriggerValue)->SetReference( _Ptr->GetNode( "ChunkInputStatusAtLineTriggerValue" ) ); + static_cast (&ChunkShaftEncoderCounter)->SetReference( _Ptr->GetNode( "ChunkShaftEncoderCounter" ) ); + static_cast (&ChunkExposureTime)->SetReference( _Ptr->GetNode( "ChunkExposureTime" ) ); + static_cast (&ChunkPayloadCRC16)->SetReference( _Ptr->GetNode( "ChunkPayloadCRC16" ) ); + static_cast (&ChunkGainAll)->SetReference( _Ptr->GetNode( "ChunkGainAll" ) ); + static_cast (&ChunkLineTriggerCounter)->SetReference( _Ptr->GetNode( "ChunkLineTriggerCounter" ) ); + static_cast*> (&EventSelector)->SetReference( _Ptr->GetNode( "EventSelector" ) ); + static_cast*> (&EventSelector)->SetNumEnums( 23 ); + static_cast*> (&EventSelector)->SetEnumReference( EventSelector_ExposureEnd, "ExposureEnd" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_LineStartOvertrigger, "LineStartOvertrigger" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameStartOvertrigger, "FrameStartOvertrigger" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_AcquisitionStartOvertrigger, "AcquisitionStartOvertrigger" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameTimeout, "FrameTimeout" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameStart, "FrameStart" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_AcquisitionStart, "AcquisitionStart" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_CriticalTemperature, "CriticalTemperature" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_OverTemperature, "OverTemperature" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_ActionLate, "ActionLate" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_Line1RisingEdge, "Line1RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_Line2RisingEdge, "Line2RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_Line3RisingEdge, "Line3RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_Line4RisingEdge, "Line4RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_VirtualLine1RisingEdge, "VirtualLine1RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_VirtualLine2RisingEdge, "VirtualLine2RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_VirtualLine3RisingEdge, "VirtualLine3RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_VirtualLine4RisingEdge, "VirtualLine4RisingEdge" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameWait, "FrameWait" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_AcquisitionWait, "AcquisitionWait" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameStartWait, "FrameStartWait" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_AcquisitionStartWait, "AcquisitionStartWait" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_EventOverrun, "EventOverrun" ); static_cast*> (&EventNotification)->SetReference( _Ptr->GetNode( "EventNotification" ) ); + static_cast*> (&EventNotification)->SetNumEnums( 3 ); + static_cast*> (&EventNotification)->SetEnumReference( EventNotification_Off, "Off" ); static_cast*> (&EventNotification)->SetEnumReference( EventNotification_GenICamEvent, "GenICamEvent" ); static_cast*> (&EventNotification)->SetEnumReference( EventNotification_On, "On" ); static_cast (&ExposureEndEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "ExposureEndEventStreamChannelIndex" ) ); + static_cast (&ExposureEndEventFrameID)->SetReference( _Ptr->GetNode( "ExposureEndEventFrameID" ) ); + static_cast (&ExposureEndEventTimestamp)->SetReference( _Ptr->GetNode( "ExposureEndEventTimestamp" ) ); + static_cast (&LineStartOvertriggerEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "LineStartOvertriggerEventStreamChannelIndex" ) ); + static_cast (&LineStartOvertriggerEventTimestamp)->SetReference( _Ptr->GetNode( "LineStartOvertriggerEventTimestamp" ) ); + static_cast (&FrameStartOvertriggerEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "FrameStartOvertriggerEventStreamChannelIndex" ) ); + static_cast (&FrameStartOvertriggerEventTimestamp)->SetReference( _Ptr->GetNode( "FrameStartOvertriggerEventTimestamp" ) ); + static_cast (&FrameStartEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "FrameStartEventStreamChannelIndex" ) ); + static_cast (&FrameStartEventTimestamp)->SetReference( _Ptr->GetNode( "FrameStartEventTimestamp" ) ); + static_cast (&AcquisitionStartEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "AcquisitionStartEventStreamChannelIndex" ) ); + static_cast (&AcquisitionStartEventTimestamp)->SetReference( _Ptr->GetNode( "AcquisitionStartEventTimestamp" ) ); + static_cast (&AcquisitionStartOvertriggerEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "AcquisitionStartOvertriggerEventStreamChannelIndex" ) ); + static_cast (&AcquisitionStartOvertriggerEventTimestamp)->SetReference( _Ptr->GetNode( "AcquisitionStartOvertriggerEventTimestamp" ) ); + static_cast (&FrameTimeoutEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "FrameTimeoutEventStreamChannelIndex" ) ); + static_cast (&FrameTimeoutEventTimestamp)->SetReference( _Ptr->GetNode( "FrameTimeoutEventTimestamp" ) ); + static_cast (&EventOverrunEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "EventOverrunEventStreamChannelIndex" ) ); + static_cast (&EventOverrunEventFrameID)->SetReference( _Ptr->GetNode( "EventOverrunEventFrameID" ) ); + static_cast (&EventOverrunEventTimestamp)->SetReference( _Ptr->GetNode( "EventOverrunEventTimestamp" ) ); + static_cast (&CriticalTemperatureEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "CriticalTemperatureEventStreamChannelIndex" ) ); + static_cast (&CriticalTemperatureEventTimestamp)->SetReference( _Ptr->GetNode( "CriticalTemperatureEventTimestamp" ) ); + static_cast (&OverTemperatureEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "OverTemperatureEventStreamChannelIndex" ) ); + static_cast (&OverTemperatureEventTimestamp)->SetReference( _Ptr->GetNode( "OverTemperatureEventTimestamp" ) ); + static_cast (&ActionLateEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "ActionLateEventStreamChannelIndex" ) ); + static_cast (&ActionLateEventTimestamp)->SetReference( _Ptr->GetNode( "ActionLateEventTimestamp" ) ); + static_cast (&LateActionEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "LateActionEventStreamChannelIndex" ) ); + static_cast (&LateActionEventTimestamp)->SetReference( _Ptr->GetNode( "LateActionEventTimestamp" ) ); + static_cast (&Line1RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "Line1RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&Line1RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "Line1RisingEdgeEventTimestamp" ) ); + static_cast (&Line2RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "Line2RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&Line2RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "Line2RisingEdgeEventTimestamp" ) ); + static_cast (&Line3RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "Line3RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&Line3RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "Line3RisingEdgeEventTimestamp" ) ); + static_cast (&Line4RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "Line4RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&Line4RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "Line4RisingEdgeEventTimestamp" ) ); + static_cast (&VirtualLine1RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "VirtualLine1RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&VirtualLine1RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "VirtualLine1RisingEdgeEventTimestamp" ) ); + static_cast (&VirtualLine2RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "VirtualLine2RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&VirtualLine2RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "VirtualLine2RisingEdgeEventTimestamp" ) ); + static_cast (&VirtualLine3RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "VirtualLine3RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&VirtualLine3RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "VirtualLine3RisingEdgeEventTimestamp" ) ); + static_cast (&VirtualLine4RisingEdgeEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "VirtualLine4RisingEdgeEventStreamChannelIndex" ) ); + static_cast (&VirtualLine4RisingEdgeEventTimestamp)->SetReference( _Ptr->GetNode( "VirtualLine4RisingEdgeEventTimestamp" ) ); + static_cast (&FrameWaitEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "FrameWaitEventStreamChannelIndex" ) ); + static_cast (&FrameWaitEventTimestamp)->SetReference( _Ptr->GetNode( "FrameWaitEventTimestamp" ) ); + static_cast (&AcquisitionWaitEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "AcquisitionWaitEventStreamChannelIndex" ) ); + static_cast (&AcquisitionWaitEventTimestamp)->SetReference( _Ptr->GetNode( "AcquisitionWaitEventTimestamp" ) ); + static_cast (&FrameStartWaitEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "FrameStartWaitEventStreamChannelIndex" ) ); + static_cast (&FrameStartWaitEventTimestamp)->SetReference( _Ptr->GetNode( "FrameStartWaitEventTimestamp" ) ); + static_cast (&AcquisitionStartWaitEventStreamChannelIndex)->SetReference( _Ptr->GetNode( "AcquisitionStartWaitEventStreamChannelIndex" ) ); + static_cast (&AcquisitionStartWaitEventTimestamp)->SetReference( _Ptr->GetNode( "AcquisitionStartWaitEventTimestamp" ) ); + static_cast*> (&FileSelector)->SetReference( _Ptr->GetNode( "FileSelector" ) ); + static_cast*> (&FileSelector)->SetNumEnums( 9 ); + static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserData, "UserData" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet1, "UserSet1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet2, "UserSet2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet3, "UserSet3" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserGainShading1, "UserGainShading1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserGainShading2, "UserGainShading2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserOffsetShading1, "UserOffsetShading1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserOffsetShading2, "UserOffsetShading2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_ExpertFeature7File, "ExpertFeature7File" ); static_cast*> (&FileOperationSelector)->SetReference( _Ptr->GetNode( "FileOperationSelector" ) ); + static_cast*> (&FileOperationSelector)->SetNumEnums( 4 ); + static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Open, "Open" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Close, "Close" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Read, "Read" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Write, "Write" ); static_cast*> (&FileOpenMode)->SetReference( _Ptr->GetNode( "FileOpenMode" ) ); + static_cast*> (&FileOpenMode)->SetNumEnums( 2 ); + static_cast*> (&FileOpenMode)->SetEnumReference( FileOpenMode_Read, "Read" ); static_cast*> (&FileOpenMode)->SetEnumReference( FileOpenMode_Write, "Write" ); static_cast (&FileAccessBuffer)->SetReference( _Ptr->GetNode( "FileAccessBuffer" ) ); + static_cast (&FileAccessOffset)->SetReference( _Ptr->GetNode( "FileAccessOffset" ) ); + static_cast (&FileAccessLength)->SetReference( _Ptr->GetNode( "FileAccessLength" ) ); + static_cast*> (&FileOperationStatus)->SetReference( _Ptr->GetNode( "FileOperationStatus" ) ); + static_cast*> (&FileOperationStatus)->SetNumEnums( 2 ); + static_cast*> (&FileOperationStatus)->SetEnumReference( FileOperationStatus_Success, "Success" ); static_cast*> (&FileOperationStatus)->SetEnumReference( FileOperationStatus_Failure, "Failure" ); static_cast (&FileOperationResult)->SetReference( _Ptr->GetNode( "FileOperationResult" ) ); + static_cast (&FileSize)->SetReference( _Ptr->GetNode( "FileSize" ) ); + static_cast (&FileOperationExecute)->SetReference( _Ptr->GetNode( "FileOperationExecute" ) ); + + } + + inline const char* CGigECamera_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CGigECamera_Params::_GetModelName( void ) + { + return "GigECamera"; + } + + //! \endcond + +} // namespace Basler_GigECamera + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_GigECamera_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/_GigEChunkData.h b/Cigarette/Pylon6.2/include/pylon/gige/_GigEChunkData.h new file mode 100644 index 0000000..1ab6e70 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/_GigEChunkData.h @@ -0,0 +1,748 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Basler generic GigEVision camera interface +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_GigEChunkData_PARAMS_H +#define Basler_GigEChunkData_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_GigEChunkData +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for ChunkPixelFormat + enum ChunkPixelFormatEnums + { + ChunkPixelFormat_Mono8, //!& ChunkPixelFormat; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of the timestamp when the image was acquired + + This integer indicates the value of the timestamp when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkTimestamp; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of the frame counter when the image was acquired + + This integer indicates the value of the frame counter when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFramecounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief A bit field that indicates the status of all of the camera's input and output lines when the image was acquired + + This value is a bit field that indicates the status of all of the camera's input and output lines when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineStatusAll; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief A bit field that indicates the status of all of the camera's virtual input and output lines when the image was acquired + + This value is a bit field that indicates the status of all of the camera's virtual input and output lines when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkVirtLineStatusAll; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of the trigger input counter when the image was acquired + + This integer indicates the value of the trigger input counter when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkTriggerinputcounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineTriggerIgnoredCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFrameTriggerIgnoredCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFrameTriggerCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkFramesPerTriggerCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineTriggerEndToEndCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Number of bits per status + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkInputStatusAtLineTriggerBitsPerLine; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Used to select a certain status + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkInputStatusAtLineTriggerIndex; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Value of the status selected by 'Index' + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkInputStatusAtLineTriggerValue; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Shaft encoder counter at frame trigger + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkShaftEncoderCounter; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ChunkExposureTime; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief Indicates the value of CRC checksum + + This integer indicates the value of CRC checksum. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkPayloadCRC16; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkGainAll; + + //@} + + + //! \name ChunkData - This category includes items related to the chunk data that can be appended to the image data + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineTriggerCounter; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CGigEChunkData_Params( CGigEChunkData_Params& ); + + //! not implemented assignment operator + CGigEChunkData_Params& operator=( CGigEChunkData_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CGigEChunkData_Params::CGigEChunkData_Params( void ) + : ChunkStride( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkSequenceSetIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkDynamicRangeMin( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkDynamicRangeMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkPixelFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFramecounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkVirtLineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkTriggerinputcounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineTriggerIgnoredCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFrameTriggerIgnoredCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFrameTriggerCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkFramesPerTriggerCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineTriggerEndToEndCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkInputStatusAtLineTriggerBitsPerLine( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkInputStatusAtLineTriggerIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkInputStatusAtLineTriggerValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkShaftEncoderCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkExposureTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , ChunkPayloadCRC16( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkGainAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineTriggerCounter( *new GENAPI_NAMESPACE::CIntegerRef() ) + + { + } + + inline CGigEChunkData_Params::~CGigEChunkData_Params( void ) + { + delete static_cast (&ChunkStride); + delete static_cast (&ChunkSequenceSetIndex); + delete static_cast (&ChunkOffsetX); + delete static_cast (&ChunkOffsetY); + delete static_cast (&ChunkWidth); + delete static_cast (&ChunkHeight); + delete static_cast (&ChunkDynamicRangeMin); + delete static_cast (&ChunkDynamicRangeMax); + delete static_cast *> (&ChunkPixelFormat); + delete static_cast (&ChunkTimestamp); + delete static_cast (&ChunkFramecounter); + delete static_cast (&ChunkLineStatusAll); + delete static_cast (&ChunkVirtLineStatusAll); + delete static_cast (&ChunkTriggerinputcounter); + delete static_cast (&ChunkLineTriggerIgnoredCounter); + delete static_cast (&ChunkFrameTriggerIgnoredCounter); + delete static_cast (&ChunkFrameTriggerCounter); + delete static_cast (&ChunkFramesPerTriggerCounter); + delete static_cast (&ChunkLineTriggerEndToEndCounter); + delete static_cast (&ChunkInputStatusAtLineTriggerBitsPerLine); + delete static_cast (&ChunkInputStatusAtLineTriggerIndex); + delete static_cast (&ChunkInputStatusAtLineTriggerValue); + delete static_cast (&ChunkShaftEncoderCounter); + delete static_cast (&ChunkExposureTime); + delete static_cast (&ChunkPayloadCRC16); + delete static_cast (&ChunkGainAll); + delete static_cast (&ChunkLineTriggerCounter); + + } + + inline void CGigEChunkData_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&ChunkStride)->SetReference( _Ptr->GetNode( "ChunkStride" ) ); + static_cast (&ChunkSequenceSetIndex)->SetReference( _Ptr->GetNode( "ChunkSequenceSetIndex" ) ); + static_cast (&ChunkOffsetX)->SetReference( _Ptr->GetNode( "ChunkOffsetX" ) ); + static_cast (&ChunkOffsetY)->SetReference( _Ptr->GetNode( "ChunkOffsetY" ) ); + static_cast (&ChunkWidth)->SetReference( _Ptr->GetNode( "ChunkWidth" ) ); + static_cast (&ChunkHeight)->SetReference( _Ptr->GetNode( "ChunkHeight" ) ); + static_cast (&ChunkDynamicRangeMin)->SetReference( _Ptr->GetNode( "ChunkDynamicRangeMin" ) ); + static_cast (&ChunkDynamicRangeMax)->SetReference( _Ptr->GetNode( "ChunkDynamicRangeMax" ) ); + static_cast*> (&ChunkPixelFormat)->SetReference( _Ptr->GetNode( "ChunkPixelFormat" ) ); + static_cast*> (&ChunkPixelFormat)->SetNumEnums( 51 ); + static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono8, "Mono8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono8Signed, "Mono8Signed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono10, "Mono10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono10Packed, "Mono10Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono10p, "Mono10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono12, "Mono12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono12Packed, "Mono12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_Mono16, "Mono16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR8, "BayerGR8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG8, "BayerRG8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB8, "BayerGB8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG8, "BayerBG8" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR10, "BayerGR10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG10, "BayerRG10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB10, "BayerGB10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG10, "BayerBG10" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR12, "BayerGR12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG12, "BayerRG12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB12, "BayerGB12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG12, "BayerBG12" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR16, "BayerGR16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG16, "BayerRG16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB16, "BayerGB16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG16, "BayerBG16" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB8Packed, "RGB8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGR8Packed, "BGR8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGBA8Packed, "RGBA8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGRA8Packed, "BGRA8Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10Packed, "RGB10Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGR10Packed, "BGR10Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB12Packed, "RGB12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BGR12Packed, "BGR12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10V1Packed, "RGB10V1Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10V2Packed, "RGB10V2Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV411Packed, "YUV411Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV422Packed, "YUV422Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV444Packed, "YUV444Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB8Planar, "RGB8Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB10Planar, "RGB10Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB12Planar, "RGB12Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB16Planar, "RGB16Planar" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_YUV422_YUYV_Packed, "YUV422_YUYV_Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB12Packed, "BayerGB12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR12Packed, "BayerGR12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG12Packed, "BayerRG12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG12Packed, "BayerBG12Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_RGB12V1Packed, "RGB12V1Packed" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGB10p, "BayerGB10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerGR10p, "BayerGR10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerRG10p, "BayerRG10p" ); static_cast*> (&ChunkPixelFormat)->SetEnumReference( ChunkPixelFormat_BayerBG10p, "BayerBG10p" ); static_cast (&ChunkTimestamp)->SetReference( _Ptr->GetNode( "ChunkTimestamp" ) ); + static_cast (&ChunkFramecounter)->SetReference( _Ptr->GetNode( "ChunkFramecounter" ) ); + static_cast (&ChunkLineStatusAll)->SetReference( _Ptr->GetNode( "ChunkLineStatusAll" ) ); + static_cast (&ChunkVirtLineStatusAll)->SetReference( _Ptr->GetNode( "ChunkVirtLineStatusAll" ) ); + static_cast (&ChunkTriggerinputcounter)->SetReference( _Ptr->GetNode( "ChunkTriggerinputcounter" ) ); + static_cast (&ChunkLineTriggerIgnoredCounter)->SetReference( _Ptr->GetNode( "ChunkLineTriggerIgnoredCounter" ) ); + static_cast (&ChunkFrameTriggerIgnoredCounter)->SetReference( _Ptr->GetNode( "ChunkFrameTriggerIgnoredCounter" ) ); + static_cast (&ChunkFrameTriggerCounter)->SetReference( _Ptr->GetNode( "ChunkFrameTriggerCounter" ) ); + static_cast (&ChunkFramesPerTriggerCounter)->SetReference( _Ptr->GetNode( "ChunkFramesPerTriggerCounter" ) ); + static_cast (&ChunkLineTriggerEndToEndCounter)->SetReference( _Ptr->GetNode( "ChunkLineTriggerEndToEndCounter" ) ); + static_cast (&ChunkInputStatusAtLineTriggerBitsPerLine)->SetReference( _Ptr->GetNode( "ChunkInputStatusAtLineTriggerBitsPerLine" ) ); + static_cast (&ChunkInputStatusAtLineTriggerIndex)->SetReference( _Ptr->GetNode( "ChunkInputStatusAtLineTriggerIndex" ) ); + static_cast (&ChunkInputStatusAtLineTriggerValue)->SetReference( _Ptr->GetNode( "ChunkInputStatusAtLineTriggerValue" ) ); + static_cast (&ChunkShaftEncoderCounter)->SetReference( _Ptr->GetNode( "ChunkShaftEncoderCounter" ) ); + static_cast (&ChunkExposureTime)->SetReference( _Ptr->GetNode( "ChunkExposureTime" ) ); + static_cast (&ChunkPayloadCRC16)->SetReference( _Ptr->GetNode( "ChunkPayloadCRC16" ) ); + static_cast (&ChunkGainAll)->SetReference( _Ptr->GetNode( "ChunkGainAll" ) ); + static_cast (&ChunkLineTriggerCounter)->SetReference( _Ptr->GetNode( "ChunkLineTriggerCounter" ) ); + + } + + inline const char* CGigEChunkData_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CGigEChunkData_Params::_GetModelName( void ) + { + return "GigEChunkData"; + } + + //! \endcond + +} // namespace Basler_GigEChunkData + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_GigEChunkData_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/_GigEEventParams.h b/Cigarette/Pylon6.2/include/pylon/gige/_GigEEventParams.h new file mode 100644 index 0000000..996064a --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/_GigEEventParams.h @@ -0,0 +1,258 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Interface to the PylonGigE Event Grabber parameters +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_GigEEventParams_PARAMS_H +#define Basler_GigEEventParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_GigEEventParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for Status + enum StatusEnums + { + Status_Closed, //!& Status; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CGigEEventParams_Params( CGigEEventParams_Params& ); + + //! not implemented assignment operator + CGigEEventParams_Params& operator=( CGigEEventParams_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CGigEEventParams_Params::CGigEEventParams_Params( void ) + : NumBuffer( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Timeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , RetryCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Status( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + + { + } + + inline CGigEEventParams_Params::~CGigEEventParams_Params( void ) + { + delete static_cast (&NumBuffer); + delete static_cast (&Timeout); + delete static_cast (&RetryCount); + delete static_cast *> (&Status); + + } + + inline void CGigEEventParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&NumBuffer)->SetReference( _Ptr->GetNode( "NumBuffer" ) ); + static_cast (&Timeout)->SetReference( _Ptr->GetNode( "Timeout" ) ); + static_cast (&RetryCount)->SetReference( _Ptr->GetNode( "RetryCount" ) ); + static_cast*> (&Status)->SetReference( _Ptr->GetNode( "Status" ) ); + static_cast*> (&Status)->SetNumEnums( 2 ); + static_cast*> (&Status)->SetEnumReference( Status_Closed, "Closed" ); static_cast*> (&Status)->SetEnumReference( Status_Open, "Open" ); + } + + inline const char* CGigEEventParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CGigEEventParams_Params::_GetModelName( void ) + { + return "GigEEventParams"; + } + + //! \endcond + +} // namespace Basler_GigEEventParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_GigEEventParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/_GigEStreamParams.h b/Cigarette/Pylon6.2/include/pylon/gige/_GigEStreamParams.h new file mode 100644 index 0000000..0b200ac --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/_GigEStreamParams.h @@ -0,0 +1,922 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Interface to the PylonGigE Stream Grabber parameters +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_GigEStreamParams_PARAMS_H +#define Basler_GigEStreamParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_GigEStreamParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for Type + enum TypeEnums + { + Type_WindowsFilterDriver, //!& Type; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Maximum number of buffers that can be used simultaneously for grabbing images. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& MaxNumBuffer; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Maximum size (in bytes) of a buffer used for grabbing images. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& MaxBufferSize; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Enables the packet resend mechanism. + + + + An image frame consists of n numbers of packets. Each packet has a header consisting of a 24-bit packet ID. + This packet ID increases with each packet sent, and makes it possible for the receiving end to know if a + particular packet has been lost during the transfer. If 'ResendPacketMechanism' is enabled, and the receiving + end notices a lost packet, it will request the other side (e.g. the camera) to send the lost packet again. + If enabled, the 'ResendPacketMechanism' can cause delays in the timing because the sending end will resend + the lost packet. If disabled, image data packet(s) can get lost which results in an incomplete received frame. + You have to weigh the disadvantages and advantages for your special application to decide whether to enable + or disable this command.

+ + Default setting: Enabled + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& EnableResend; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Timeout period in milliseconds between two packets within one frame. + + + + An image frame consists of n numbers of packets. The packet timeout counting is (re)started + each time a packet is received. If the timeout expires (e.g. no packet was received + during the last 'PacketTimeout' period), the 'Resend Packet Mechanism' is started. + For information, see the 'EnableResend' feature. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& PacketTimeout; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Enables negotiation of the packet size to find the largest possible packet size. + + + + Enables or disables probing of a working large packet size before grabbing. + Using large packets reduces the overhead for transferring images but + whether a large packet can be transported depends on the used network hardware + and its configuration. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& AutoPacketSize; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Size (in frames) of the receive window in which the stream grabber looks for missing packets. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ReceiveWindowSize; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Threshold after which resend requests are initiated. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ResendRequestThreshold; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Amount of packet resend requests to be batched, i.e., sent together. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ResendRequestBatching; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Time to wait (in milliseconds) between detecting a missing packet and sending a resend request. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ResendTimeout; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Time to wait (in milliseconds) between sending a resend request and considering the request as lost. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ResendRequestResponseTimeout; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Maximum number of resend requests per missing packet. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& MaximumNumberResendRequests; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Maximum time in milliseconds to receive all packets of a frame. + + + + An image frame consists of n numbers of packets. The 'FrameRetention' always starts from the + point in time the receiving end notices that a packet has been received for a particular frame. + If the transmission of packets of a frame is not completed within the 'FrameRetention' time, + the corresponding frame is delivered with status 'Failed'. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& FrameRetention; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Enables assigning a custom priority to the thread which receives incoming stream packets. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& ReceiveThreadPriorityOverride; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Thread priority of the receive thread. + + Thread priority of the receive thread. Only available if the socket driver is used. To assign the priority, the Receive Thread Priority Override parameter must be set to true. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& ReceiveThreadPriority; + + //@} + + + //! \name Root - Interface to the GigE specific stream parameters. + //@{ + /*! + \brief Socket buffer size in kilobytes. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& SocketBufferSize; + + //@} + + + //! \name Debug - Contains parameters for debugging purposes. + //@{ + /*! + \brief Indicates the current status of the stream grabber. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& Status; + + //@} + + + //! \name Debug - Contains parameters for debugging purposes. + //@{ + /*! + \brief Indicates the mode of access the current application has to the device. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& AccessMode; + + //@} + + + //! \name Debug - Contains parameters for debugging purposes. + //@{ + /*! + \brief Indicates whether the pylon GigE Vision Performance Driver is currently available. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TypeIsWindowsIntelPerformanceDriverAvailable; + + //@} + + + //! \name Debug - Contains parameters for debugging purposes. + //@{ + /*! + \brief Indicates whether the pylon GigE Vision Filter Driver is currently available. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TypeIsWindowsFilterDriverAvailable; + + //@} + + + //! \name Debug - Contains parameters for debugging purposes. + //@{ + /*! + \brief Indicates whether the socket driver is currently available. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& TypeIsSocketDriverAvailable; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief GigE cameras: Number of frames received. Other cameras: Number of buffers processed. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Total_Buffer_Count; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief GigE cameras: Number of buffers with at least one failed packet. A packet is considered failed if its status is not 'success'. Other cameras: Number of buffers that returned with an error status. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Failed_Buffer_Count; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief Number of frames lost because there were no buffers in the queue. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Buffer_Underrun_Count; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief Number of packets received. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Total_Packet_Count; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief Number of failed packets. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Failed_Packet_Count; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief Number of emitted packet resend commands sent. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Resend_Request_Count; + + //@} + + + //! \name Statistic - Contains parameters for displaying statistical data. + //@{ + /*! + \brief Number of packets requested by packet resend commands. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Resend_Packet_Count; + + //@} + + + //! \name IPConfig - Contains parameters for configuring the stream destination. + //@{ + /*! + \brief Sets how stream data is transferred within the network. + + + +
    +
  • + Default (Unicast)
    + The camera sends stream data to a single controlling application. Other devices cannot + receive the stream data. +
  • +
    +
  • + Broadcast
    + The camera sends the stream data to all devices on the network. The application which + starts/stops the acquisition is called the controlling application. Other applications + can receive the stream data. These applications are called monitor applications, because + they open the camera in read-only mode. This implies that monitor applications cannot + change the camera configuration and they cannot start/stop the image acquisition. + However, monitor applications can request resend requests for lost stream data packets. +

    + Attention: Broadcasting the stream data packets uses a high amount of network bandwidth + because the stream data packets are forwarded to all devices attached to the + network, even if they are not interested in receiving stream data. +
  • +
    +
  • + Multicast
    + Multicasting is very similar to broadcasting. The main advantage of multicasting is that + multicasting saves network bandwidth, because the image data stream is only sent to those + devices that are interested in receiving the data. To achieve this, the camera sends image + data streams to members of a multicast group only. A multicast group is defined by an IP + address taken from the multicast address range (224.0.0.0 to 239.255.255.255). +

    + Every device that wants to receive a multicast data stream has to be a member of a multicast + group. A member of a specific multicast group only receives data destinated for this group. + Data for other groups is not received. Usually network adapters and switches are able to filter + the data efficently on hardware level (layer-2 packet filtering). +

    + When multicasting is enabled for pylon, pylon automatically takes care of joining and leaving + the multicast groups defined by the destination IP address. Keep in mind that some addresses + from the multicast address range are reserved for general purposes. The address range from + 239.255.0.0 to 239.255.255.255 is assigned by RFC 2365 as a locally administered address space. + Use one of these addresses if you are not sure. +

    + On protocol level multicasting involves a so-called IGMP message (IGMP = Internet Group Management Protocol). + To benefit from multicasting, managed network switches should be used. These managed network + switches support the IGMP protocol. Managed network switches supporting the IGMP protocol + will forward multicast packets only if there is a connected device that has joined the + corresponding multicast group. If the switch does not support the IGMP protocol, multicast + is equivalent to broadcasting. +

    + Recommendation:
    +
      +
    • + Each camera should stream to a different multicast group. +
    • +
    • + Streaming to different multicast groups reduces the CPU load and saves network bandwidth + if the network switches supports the IGMP protocol. +
    • +
    +
  • +
    +
  • + Use camera configuration
    + This setting is only available if the application has opened the device in monitor mode. If + the controlling application has already configured the camera stream channel and has possibly + started the acquisition, the monitor application can read all required configuration data + from the camera. Additional configuration is not required. This setting can only be used if + the controlling application has established the stream channel (by opening a pylon stream + grabber object), and the monitor application is started afterwards. +

    + Note, when using broadcast and multicast configurations: When there is more than one camera + device reachable by one network interface, make sure that for each camera a different port + number must be assigned. For assigning port numbers, see the 'DestinationPort' feature. +
  • +
+ + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TransmissionType; + + //@} + + + //! \name IPConfig - Contains parameters for configuring the stream destination. + //@{ + /*! + \brief IP address to which the stream grabber sends all stream data. + + IP address to which the stream grabber sends all stream data. + + \b Visibility = Expert + + \b Selected by : TransmissionType + + */ + GENAPI_NAMESPACE::IString& DestinationAddr; + + //@} + + + //! \name IPConfig - Contains parameters for configuring the stream destination. + //@{ + /*! + \brief Port to which the stream grabber sends all stream data. + + + + The camera will send all stream data to this port. If you manually enter a port + number, it is highly recommended not to choose a port from the ephemeral port + range of the operating system (https://en.wikipedia.org/wiki/Ephemeral_port) + in order to avoid port collisions. + + Port configuration: +
    +
  1. + Unicast
    + The port is determined automatically. + Manually choosing a port number might be useful for certain firewall configurations. +
  2. +
    +
  3. + Broadcast & Multicast
    + For each device reachable by a specific network interface, a unique, unused port number + must be assigned. Be aware that the suggested default value might be already in use. + Choose an unused port or 0=autoselect in that case. The controlling application and all + monitor applications must use the same port number. There is no autoselect feature + availbale for monitor applications, i.e., monitor applications must not use the 0 value. + For monitor applications it is convenient to use the 'UseCameraConfig' value for the + 'TransmissionType' feature instead. For more details see the 'TransmissionType' feature. +
  4. +
+ + + + \b Visibility = Expert + + \b Selected by : TransmissionType + + */ + GENAPI_NAMESPACE::IInteger& DestinationPort; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CGigEStreamParams_Params( CGigEStreamParams_Params& ); + + //! not implemented assignment operator + CGigEStreamParams_Params& operator=( CGigEStreamParams_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CGigEStreamParams_Params::CGigEStreamParams_Params( void ) + : Type( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , MaxNumBuffer( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MaxBufferSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EnableResend( *new GENAPI_NAMESPACE::CBooleanRef() ) + , PacketTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoPacketSize( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ReceiveWindowSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ResendRequestThreshold( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ResendRequestBatching( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ResendTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ResendRequestResponseTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MaximumNumberResendRequests( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FrameRetention( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ReceiveThreadPriorityOverride( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ReceiveThreadPriority( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SocketBufferSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Status( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AccessMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TypeIsWindowsIntelPerformanceDriverAvailable( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TypeIsWindowsFilterDriverAvailable( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TypeIsSocketDriverAvailable( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Total_Buffer_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Failed_Buffer_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Buffer_Underrun_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Total_Packet_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Failed_Packet_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Resend_Request_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Resend_Packet_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TransmissionType( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DestinationAddr( *new GENAPI_NAMESPACE::CStringRef() ) + , DestinationPort( *new GENAPI_NAMESPACE::CIntegerRef() ) + + { + } + + inline CGigEStreamParams_Params::~CGigEStreamParams_Params( void ) + { + delete static_cast *> (&Type); + delete static_cast (&MaxNumBuffer); + delete static_cast (&MaxBufferSize); + delete static_cast (&EnableResend); + delete static_cast (&PacketTimeout); + delete static_cast (&AutoPacketSize); + delete static_cast (&ReceiveWindowSize); + delete static_cast (&ResendRequestThreshold); + delete static_cast (&ResendRequestBatching); + delete static_cast (&ResendTimeout); + delete static_cast (&ResendRequestResponseTimeout); + delete static_cast (&MaximumNumberResendRequests); + delete static_cast (&FrameRetention); + delete static_cast (&ReceiveThreadPriorityOverride); + delete static_cast (&ReceiveThreadPriority); + delete static_cast (&SocketBufferSize); + delete static_cast *> (&Status); + delete static_cast *> (&AccessMode); + delete static_cast (&TypeIsWindowsIntelPerformanceDriverAvailable); + delete static_cast (&TypeIsWindowsFilterDriverAvailable); + delete static_cast (&TypeIsSocketDriverAvailable); + delete static_cast (&Statistic_Total_Buffer_Count); + delete static_cast (&Statistic_Failed_Buffer_Count); + delete static_cast (&Statistic_Buffer_Underrun_Count); + delete static_cast (&Statistic_Total_Packet_Count); + delete static_cast (&Statistic_Failed_Packet_Count); + delete static_cast (&Statistic_Resend_Request_Count); + delete static_cast (&Statistic_Resend_Packet_Count); + delete static_cast *> (&TransmissionType); + delete static_cast (&DestinationAddr); + delete static_cast (&DestinationPort); + + } + + inline void CGigEStreamParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast*> (&Type)->SetReference( _Ptr->GetNode( "Type" ) ); + static_cast*> (&Type)->SetNumEnums( 4 ); + static_cast*> (&Type)->SetEnumReference( Type_WindowsFilterDriver, "WindowsFilterDriver" ); static_cast*> (&Type)->SetEnumReference( Type_WindowsIntelPerformanceDriver, "WindowsIntelPerformanceDriver" ); static_cast*> (&Type)->SetEnumReference( Type_SocketDriver, "SocketDriver" ); static_cast*> (&Type)->SetEnumReference( Type_NoDriverAvailable, "NoDriverAvailable" ); static_cast (&MaxNumBuffer)->SetReference( _Ptr->GetNode( "MaxNumBuffer" ) ); + static_cast (&MaxBufferSize)->SetReference( _Ptr->GetNode( "MaxBufferSize" ) ); + static_cast (&EnableResend)->SetReference( _Ptr->GetNode( "EnableResend" ) ); + static_cast (&PacketTimeout)->SetReference( _Ptr->GetNode( "PacketTimeout" ) ); + static_cast (&AutoPacketSize)->SetReference( _Ptr->GetNode( "AutoPacketSize" ) ); + static_cast (&ReceiveWindowSize)->SetReference( _Ptr->GetNode( "ReceiveWindowSize" ) ); + static_cast (&ResendRequestThreshold)->SetReference( _Ptr->GetNode( "ResendRequestThreshold" ) ); + static_cast (&ResendRequestBatching)->SetReference( _Ptr->GetNode( "ResendRequestBatching" ) ); + static_cast (&ResendTimeout)->SetReference( _Ptr->GetNode( "ResendTimeout" ) ); + static_cast (&ResendRequestResponseTimeout)->SetReference( _Ptr->GetNode( "ResendRequestResponseTimeout" ) ); + static_cast (&MaximumNumberResendRequests)->SetReference( _Ptr->GetNode( "MaximumNumberResendRequests" ) ); + static_cast (&FrameRetention)->SetReference( _Ptr->GetNode( "FrameRetention" ) ); + static_cast (&ReceiveThreadPriorityOverride)->SetReference( _Ptr->GetNode( "ReceiveThreadPriorityOverride" ) ); + static_cast (&ReceiveThreadPriority)->SetReference( _Ptr->GetNode( "ReceiveThreadPriority" ) ); + static_cast (&SocketBufferSize)->SetReference( _Ptr->GetNode( "SocketBufferSize" ) ); + static_cast*> (&Status)->SetReference( _Ptr->GetNode( "Status" ) ); + static_cast*> (&Status)->SetNumEnums( 4 ); + static_cast*> (&Status)->SetEnumReference( Status_NotInitialized, "NotInitialized" ); static_cast*> (&Status)->SetEnumReference( Status_Closed, "Closed" ); static_cast*> (&Status)->SetEnumReference( Status_Open, "Open" ); static_cast*> (&Status)->SetEnumReference( Status_Locked, "Locked" ); static_cast*> (&AccessMode)->SetReference( _Ptr->GetNode( "AccessMode" ) ); + static_cast*> (&AccessMode)->SetNumEnums( 4 ); + static_cast*> (&AccessMode)->SetEnumReference( AccessMode_NotInitialized, "NotInitialized" ); static_cast*> (&AccessMode)->SetEnumReference( AccessMode_Monitor, "Monitor" ); static_cast*> (&AccessMode)->SetEnumReference( AccessMode_Control, "Control" ); static_cast*> (&AccessMode)->SetEnumReference( AccessMode_Exclusive, "Exclusive" ); static_cast (&TypeIsWindowsIntelPerformanceDriverAvailable)->SetReference( _Ptr->GetNode( "TypeIsWindowsIntelPerformanceDriverAvailable" ) ); + static_cast (&TypeIsWindowsFilterDriverAvailable)->SetReference( _Ptr->GetNode( "TypeIsWindowsFilterDriverAvailable" ) ); + static_cast (&TypeIsSocketDriverAvailable)->SetReference( _Ptr->GetNode( "TypeIsSocketDriverAvailable" ) ); + static_cast (&Statistic_Total_Buffer_Count)->SetReference( _Ptr->GetNode( "Statistic_Total_Buffer_Count" ) ); + static_cast (&Statistic_Failed_Buffer_Count)->SetReference( _Ptr->GetNode( "Statistic_Failed_Buffer_Count" ) ); + static_cast (&Statistic_Buffer_Underrun_Count)->SetReference( _Ptr->GetNode( "Statistic_Buffer_Underrun_Count" ) ); + static_cast (&Statistic_Total_Packet_Count)->SetReference( _Ptr->GetNode( "Statistic_Total_Packet_Count" ) ); + static_cast (&Statistic_Failed_Packet_Count)->SetReference( _Ptr->GetNode( "Statistic_Failed_Packet_Count" ) ); + static_cast (&Statistic_Resend_Request_Count)->SetReference( _Ptr->GetNode( "Statistic_Resend_Request_Count" ) ); + static_cast (&Statistic_Resend_Packet_Count)->SetReference( _Ptr->GetNode( "Statistic_Resend_Packet_Count" ) ); + static_cast*> (&TransmissionType)->SetReference( _Ptr->GetNode( "TransmissionType" ) ); + static_cast*> (&TransmissionType)->SetNumEnums( 5 ); + static_cast*> (&TransmissionType)->SetEnumReference( TransmissionType_UseCameraConfig, "UseCameraConfig" ); static_cast*> (&TransmissionType)->SetEnumReference( TransmissionType_Unicast, "Unicast" ); static_cast*> (&TransmissionType)->SetEnumReference( TransmissionType_Multicast, "Multicast" ); static_cast*> (&TransmissionType)->SetEnumReference( TransmissionType_LimitedBroadcast, "LimitedBroadcast" ); static_cast*> (&TransmissionType)->SetEnumReference( TransmissionType_SubnetDirectedBroadcast, "SubnetDirectedBroadcast" ); static_cast (&DestinationAddr)->SetReference( _Ptr->GetNode( "DestinationAddr" ) ); + static_cast (&DestinationPort)->SetReference( _Ptr->GetNode( "DestinationPort" ) ); + + } + + inline const char* CGigEStreamParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CGigEStreamParams_Params::_GetModelName( void ) + { + return "GigEStreamParams"; + } + + //! \endcond + +} // namespace Basler_GigEStreamParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_GigEStreamParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/gige/_GigETLParams.h b/Cigarette/Pylon6.2/include/pylon/gige/_GigETLParams.h new file mode 100644 index 0000000..aa13452 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/gige/_GigETLParams.h @@ -0,0 +1,321 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Interface to the GigE transport layer specific parameters +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_GigETLParams_PARAMS_H +#define Basler_GigETLParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_GigETLParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + + //************************************************************************************************** + // Parameter class + //************************************************************************************************** + + + //! Interface to the GigE transport layer specific parameters + class CGigETLParams_Params + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CGigETLParams_Params( void ); + + //! Destructor + ~CGigETLParams_Params( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! Return the vendor of the camera + const char* _GetVendorName( void ); + + //! Returns the camera model name + const char* _GetModelName( void ); + + //! \endcond + +//---------------------------------------------------------------------------------------------------------------- +// References to features +//---------------------------------------------------------------------------------------------------------------- + public: + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Read access timeout value in milliseconds. + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ReadTimeout; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Write access timeout in milliseconds. + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& WriteTimeout; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Maximum number of retries for read operations after a read operation has timed out. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& MaxRetryCountRead; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Maximum number of retries for write operations after a write operation has timed out. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& MaxRetryCountWrite; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Heartbeat timeout value on the host side in milliseconds. + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& HeartbeatTimeout; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Enables sending all commands and receiving all acknowledges twice. + + Enables sending all commands and receiving all acknowledges twice. This option should only be enabled in case of network problems. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& CommandDuplicationEnable; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Number of timeouts during read and write operations when waiting for a response from the device. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& StatisticReadWriteTimeoutCount; + + //@} + + + //! \name Root - Transport layer-specific parameter + //@{ + /*! + \brief Migration Mode Enable + + Enables mapping of certain SFNC 1.x node names to SFNC 2.x node names + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& MigrationModeEnable; + + //@} + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CGigETLParams_Params( CGigETLParams_Params& ); + + //! not implemented assignment operator + CGigETLParams_Params& operator=( CGigETLParams_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CGigETLParams_Params::CGigETLParams_Params( void ) + : ReadTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , WriteTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MaxRetryCountRead( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MaxRetryCountWrite( *new GENAPI_NAMESPACE::CIntegerRef() ) + , HeartbeatTimeout( *new GENAPI_NAMESPACE::CIntegerRef() ) + , CommandDuplicationEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , StatisticReadWriteTimeoutCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , MigrationModeEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + + { + } + + inline CGigETLParams_Params::~CGigETLParams_Params( void ) + { + delete static_cast (&ReadTimeout); + delete static_cast (&WriteTimeout); + delete static_cast (&MaxRetryCountRead); + delete static_cast (&MaxRetryCountWrite); + delete static_cast (&HeartbeatTimeout); + delete static_cast (&CommandDuplicationEnable); + delete static_cast (&StatisticReadWriteTimeoutCount); + delete static_cast (&MigrationModeEnable); + } + + inline void CGigETLParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&ReadTimeout)->SetReference( _Ptr->GetNode( "ReadTimeout" ) ); + static_cast (&WriteTimeout)->SetReference( _Ptr->GetNode( "WriteTimeout" ) ); + static_cast (&MaxRetryCountRead)->SetReference( _Ptr->GetNode( "MaxRetryCountRead" ) ); + static_cast (&MaxRetryCountWrite)->SetReference( _Ptr->GetNode( "MaxRetryCountWrite" ) ); + static_cast (&HeartbeatTimeout)->SetReference( _Ptr->GetNode( "HeartbeatTimeout" ) ); + static_cast (&CommandDuplicationEnable)->SetReference( _Ptr->GetNode( "CommandDuplicationEnable" ) ); + static_cast (&StatisticReadWriteTimeoutCount)->SetReference( _Ptr->GetNode( "StatisticReadWriteTimeoutCount" ) ); + static_cast (&MigrationModeEnable)->SetReference( _Ptr->GetNode( "MigrationModeEnable" ) ); + } + + inline const char* CGigETLParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CGigETLParams_Params::_GetModelName( void ) + { + return "GigETLParams"; + } + + //! \endcond + +} // namespace Basler_GigETLParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_GigETLParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificCameraEventHandlerTie.h b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificCameraEventHandlerTie.h new file mode 100644 index 0000000..ca9699e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificCameraEventHandlerTie.h @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains an adapter class for device specific camera event handlers. +*/ + +#ifndef INCLUDED_DEVICESPECIFICCAMERAEVENTHANDLERTIE_H_4759899 +#define INCLUDED_DEVICESPECIFICCAMERAEVENTHANDLERTIE_H_4759899 + +#include +#include + +namespace Pylon +{ + /*! + \class CDeviceSpecificCameraEventHandlerTie + \brief Implementation Detail: Adapter for device specific camera event handlers. + */ + template + class CDeviceSpecificCameraEventHandlerTie : public CCameraEventHandler + { + public: + CDeviceSpecificCameraEventHandlerTie( InterfaceT* ptr, bool isCleanupDelete ) + : m_ptr( ptr ) + , m_isCleanupDelete( isCleanupDelete ) + { + } + + ~CDeviceSpecificCameraEventHandlerTie() + { + } + + virtual void OnCameraEvent( CInstantCamera& camera, intptr_t userProvidedId, GENAPI_NAMESPACE::INode* pNode ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnCameraEvent( static_cast(camera), userProvidedId, pNode ); + } + + virtual void OnCameraEventHandlerRegistered( CInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnCameraEventHandlerRegistered( static_cast(camera), nodeName, userProvidedId ); + } + + virtual void OnCameraEventHandlerDeregistered( CInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + m_ptr->OnCameraEventHandlerDeregistered( static_cast(camera), nodeName, userProvidedId ); + } + + virtual void DestroyCameraEventHandler() + { + try + { + // destroy only when demanded + if (m_isCleanupDelete) + { + m_ptr->DestroyCameraEventHandler(); + } + m_ptr = NULL; + } + catch (...) + { + delete this; + m_ptr = NULL; + throw; + } + delete this; + } + + private: + InterfaceT* m_ptr; + bool m_isCleanupDelete; + }; +} + +#endif /* INCLUDED_DEVICESPECIFICCAMERAEVENTHANDLERTIE_H_4759899 */ diff --git a/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificConfigurationEventHandlerTie.h b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificConfigurationEventHandlerTie.h new file mode 100644 index 0000000..03ebc6e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificConfigurationEventHandlerTie.h @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains an adapter class for device specific configuration event handlers. +*/ + +#ifndef INCLUDED_DEVICESPECIFICCONFIGURATIONEVENTHANDLERTIE_H_5249532 +#define INCLUDED_DEVICESPECIFICCONFIGURATIONEVENTHANDLERTIE_H_5249532 + +#include +#include + +namespace Pylon +{ + /*! + \class CDeviceSpecificConfigurationEventHandlerTie + \brief Implementation Detail: Adapter for device specific configuration event handlers. + */ + template + class CDeviceSpecificConfigurationEventHandlerTie : public CConfigurationEventHandler + { + public: + CDeviceSpecificConfigurationEventHandlerTie( InterfaceT* ptr, bool isCleanupDelete ) + : m_ptr( ptr ) + , m_isCleanupDelete( isCleanupDelete ) + { + } + + ~CDeviceSpecificConfigurationEventHandlerTie() + { + } + + + void OnAttach( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnAttach( dynamic_cast(camera) ); + } + + void OnAttached( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnAttached( dynamic_cast(camera) ); + } + + void OnOpen( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnOpen( dynamic_cast(camera) ); + } + + void OnOpened( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnOpened( dynamic_cast(camera) ); + } + + void OnGrabStart( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnGrabStart( dynamic_cast(camera) ); + } + + void OnGrabStarted( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnGrabStarted( dynamic_cast(camera) ); + } + + void OnGrabStop( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnGrabStop( dynamic_cast(camera) ); + } + + void OnGrabStopped( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnGrabStopped( dynamic_cast(camera) ); + } + + void OnClose( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnClose( dynamic_cast(camera) ); + } + + void OnClosed( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnClosed( dynamic_cast(camera) ); + } + + void OnDestroy( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnDestroy( dynamic_cast(camera) ); + } + + void OnDestroyed( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnDestroyed( dynamic_cast(camera) ); + } + + void OnDetach( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnDetach( dynamic_cast(camera) ); + } + + void OnDetached( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnDetached( dynamic_cast(camera) ); + } + + void OnGrabError( CInstantCamera& camera, const char* errorMessage ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnGrabError( dynamic_cast(camera), errorMessage ); + } + + void OnCameraDeviceRemoved( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnCameraDeviceRemoved( dynamic_cast(camera) ); + } + + virtual void OnConfigurationRegistered( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnConfigurationRegistered( static_cast(camera) ); + } + + virtual void OnConfigurationDeregistered( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnConfigurationDeregistered( static_cast(camera) ); + } + + virtual void DestroyConfiguration() + { + try + { + // destroy only when demanded + if (m_isCleanupDelete) + { + m_ptr->DestroyConfiguration(); + } + m_ptr = NULL; + } + catch (...) + { + delete this; + m_ptr = NULL; + throw; + } + delete this; + } + + private: + InterfaceT* m_ptr; + bool m_isCleanupDelete; + }; +} + +#endif /* INCLUDED_DEVICESPECIFICCONFIGURATIONEVENTHANDLERTIE_H_5249532 */ diff --git a/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificGrabResultPtr.h b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificGrabResultPtr.h new file mode 100644 index 0000000..52f9262 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificGrabResultPtr.h @@ -0,0 +1,331 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains a smart pointer that holds a reference to device specific grab result data. +*/ + +#ifndef INCLUDED_DEVICESPECIFICGRABRESULTPTR_H_9329951 +#define INCLUDED_DEVICESPECIFICGRABRESULTPTR_H_9329951 + +#include + +#define PYLON_DEFINE_DEVICE_SPECIFIC_GRAB_RESULT_PTR(ClassName, ResultDataName) \ + class ClassName : public CDeviceSpecificGrabResultPtr \ + { \ + public: \ + /*! + \copybrief Pylon::CGrabResultPtr::CGrabResultPtr() + \copydetails Pylon::CGrabResultPtr::CGrabResultPtr() + */ \ + ClassName() \ + { \ + } \ + /*! + \copybrief Pylon::CGrabResultPtr::CGrabResultPtr( const CGrabResultPtr& rhs) + \copydetails Pylon::CGrabResultPtr::CGrabResultPtr( const CGrabResultPtr& rhs) + */ \ + ClassName( const CGrabResultPtr& rhs ) \ + : CDeviceSpecificGrabResultPtr( rhs ) \ + { \ + } \ + /*! + \copybrief Pylon::CGrabResultPtr::CGrabResultPtr( const CGrabResultPtr& rhs) + \copydetails Pylon::CGrabResultPtr::CGrabResultPtr( const CGrabResultPtr& rhs) + */ \ + ClassName( const ClassName& rhs ) \ + : CDeviceSpecificGrabResultPtr( rhs ) \ + { \ + } \ + /*! + \copybrief Pylon::CGrabResultPtr::~CGrabResultPtr + \copydetails Pylon::CGrabResultPtr::~CGrabResultPtr + */ \ + virtual ~ClassName() \ + { \ + } \ + }; + + + namespace Pylon + { + + namespace PylonPrivate + { + // Internal use only. This is subject to change without notice. + class CGrabResultDataConverter + { + public: + // Internal use only. This is subject to change without notice. + template + static void Convert( GrabResultDataT*& ptr, CGrabResultPtr& target, const CGrabResultPtr& source ) + { + ptr = dynamic_cast(source.GetPtr()); + if (ptr) + { + target = source; + } + } + }; + } + + /*! + \brief Implementation Detail: Header only implementation class for creating device specific grab result ptrs. + \copydetails Pylon::CGrabResultPtr + */ + template + class CDeviceSpecificGrabResultPtr + { + public: + /*! + \copybrief Pylon::CGrabResultPtr::CGrabResultPtr + \copydetails Pylon::CGrabResultPtr::CGrabResultPtr + */ + CDeviceSpecificGrabResultPtr(); + + + /*! + \brief Creates a copy of a smart pointer. + + \param[in] rhs Another smart pointer, source of the result data to reference. + The data itself is not copied. + + \post +
    +
  • Another reference to the grab result of the source is held if it references a grab result. +
  • No grab result is referenced if the source does not reference a grab result or if the result data is not convertible. +
+ + \error + Still valid after error. + */ + CDeviceSpecificGrabResultPtr( const CGrabResultPtr& rhs ); + + + /*! + \brief Assignment of a smart pointer. + + \param[in] rhs Another smart pointer, source of the result data to reference. + + The data itself is not copied. + + \post +
    +
  • The currently referenced data is released. +
  • Another reference to the grab result of the source is held if it references a grab result. +
  • No grab result is referenced if the source does not reference a grab result or if the result data is not convertible. +
+ + \error + Still valid after error. + */ + CDeviceSpecificGrabResultPtr& operator = ( const CGrabResultPtr& rhs ); + + + /*! + \copybrief Pylon::CGrabResultPtr::CGrabResultPtr( const CGrabResultPtr& rhs) + \copydetails Pylon::CGrabResultPtr::CGrabResultPtr( const CGrabResultPtr& rhs) + */ + CDeviceSpecificGrabResultPtr( const CDeviceSpecificGrabResultPtr& rhs ); + + + /*! + \copybrief Pylon::CGrabResultPtr::operator=( const CGrabResultPtr& rhs) + \copydetails Pylon::CGrabResultPtr::operator=( const CGrabResultPtr& rhs) + */ + CDeviceSpecificGrabResultPtr& operator = ( const CDeviceSpecificGrabResultPtr& rhs ); + + + /*! + \copybrief Pylon::CGrabResultPtr::~CGrabResultPtr + \copydetails Pylon::CGrabResultPtr::~CGrabResultPtr + */ + virtual ~CDeviceSpecificGrabResultPtr(); + + + /*! + \copybrief Pylon::CGrabResultPtr::operator->() + \copydetails Pylon::CGrabResultPtr::operator->() + */ + GrabResultDataT* operator->() const; + + + /*! + \copybrief Pylon::CGrabResultPtr::IsValid + \copydetails Pylon::CGrabResultPtr::IsValid + */ + bool IsValid() const; + + + /*! + \brief Check whether data is referenced. + + \return IsValid(). + + The overloaded bool operator can be used to check whether data is referenced. + Example: + \code + if ( grabResult) + { + grabResult->GetStatus(); + } + \endcode + + \error + Does not throw C++ exceptions. + */ + operator bool() const; + + + /*! + */ + operator CGrabResultPtr() const; + + + /*! + \brief Provides an IImage interface to the grab result. + + This cast operator allows passing the grab result to saving functions or image format converter. + The returned image is invalid if the grab was not successful. See CGrabResultData::GrabSucceeded(). + + \attention The returned reference is only valid as long the grab result ptr is not destroyed. + + \error + Still valid after error. + */ + operator IImage& () const; + + + /*! + \brief Indicates that the held grab result data and buffer are only referenced by this grab result. + + \return Returns true if the held grab result data and buffer are only referenced by this grab result. Returns false if the grab result is invalid. + + \error + Does not throw C++ exceptions. + */ + bool IsUnique() const; + + + /*! + \copybrief Pylon::CGrabResultPtr::Release + \copydetails Pylon::CGrabResultPtr::Release + */ + void Release(); + + private: + GrabResultDataT* m_pGrabResultData; + CGrabResultPtr m_gptr; + }; + + + + + + + // Implementation ---------------------------------------------------------- + + template + CDeviceSpecificGrabResultPtr::CDeviceSpecificGrabResultPtr() + : m_pGrabResultData( 0 ) + { + } + + + template + CDeviceSpecificGrabResultPtr::CDeviceSpecificGrabResultPtr( const CGrabResultPtr& rhs ) + { + PylonPrivate::CGrabResultDataConverter::Convert( m_pGrabResultData, m_gptr, rhs ); + } + + + template + CDeviceSpecificGrabResultPtr& CDeviceSpecificGrabResultPtr::operator = ( const CGrabResultPtr& rhs ) + { + PylonPrivate::CGrabResultDataConverter::Convert( m_pGrabResultData, m_gptr, rhs ); + return *this; + } + + + template + CDeviceSpecificGrabResultPtr::CDeviceSpecificGrabResultPtr( const CDeviceSpecificGrabResultPtr& rhs ) + : m_pGrabResultData( rhs.m_pGrabResultData ) + , m_gptr( rhs.m_gptr ) + { + } + + + template + CDeviceSpecificGrabResultPtr& CDeviceSpecificGrabResultPtr::operator = ( const CDeviceSpecificGrabResultPtr& rhs ) + { + if (this != &rhs) // self-assignment check + { + m_pGrabResultData = rhs.m_pGrabResultData; + m_gptr = rhs.m_gptr; + } + return *this; + } + + + template + CDeviceSpecificGrabResultPtr::~CDeviceSpecificGrabResultPtr() + { + } + + + template + GrabResultDataT* CDeviceSpecificGrabResultPtr::operator->() const + { + if (!IsValid()) + { + throw RUNTIME_EXCEPTION( "No grab result data is referenced. Cannot access NULL pointer." ); + } + return m_pGrabResultData; + } + + + template + bool CDeviceSpecificGrabResultPtr::IsValid() const + { + return m_pGrabResultData != NULL; + } + + + template + CDeviceSpecificGrabResultPtr::operator bool() const + { + return IsValid(); + } + + + template + CDeviceSpecificGrabResultPtr::operator CGrabResultPtr() const + { + return m_gptr; + } + + template + CDeviceSpecificGrabResultPtr::operator IImage& () const + { + return m_gptr; + } + + template + bool CDeviceSpecificGrabResultPtr::IsUnique() const + { + return m_gptr.IsUnique(); + } + + template + void CDeviceSpecificGrabResultPtr::Release() + { + m_pGrabResultData = NULL; + m_gptr.Release(); + } + } + +#endif /* INCLUDED_DEVICESPECIFICGRABRESULTPTR_H_9329951 */ diff --git a/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificImageEventHandlerTie.h b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificImageEventHandlerTie.h new file mode 100644 index 0000000..2af0c6e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificImageEventHandlerTie.h @@ -0,0 +1,90 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains an adapter class for device specific image event handlers. +*/ + +#ifndef INCLUDED_DEVICESPECIFICIMAGEEVENTHANDLERTIE_H_009136379 +#define INCLUDED_DEVICESPECIFICIMAGEEVENTHANDLERTIE_H_009136379 + +#include +#include + +namespace Pylon +{ + /*! + \class CDeviceSpecificImageEventHandlerTie + \brief Implementation Detail: Adapter for device specific image event handlers. + */ + template + class CDeviceSpecificImageEventHandlerTie : public CImageEventHandler + { + public: + CDeviceSpecificImageEventHandlerTie( InterfaceT* ptr, bool isCleanupDelete ) + : m_ptr( ptr ) + , m_isCleanupDelete( isCleanupDelete ) + { + } + + ~CDeviceSpecificImageEventHandlerTie() + { + } + + virtual void OnImagesSkipped( CInstantCamera& camera, size_t countOfSkippedImages ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnImagesSkipped( static_cast(camera), countOfSkippedImages ); + } + + virtual void OnImageGrabbed( CInstantCamera& camera, const CGrabResultPtr& grabResult ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + typename DeviceSpecificCameraT::GrabResultPtr_t grabResultLocal = grabResult; + PYLON_ASSERT2( grabResultLocal.IsValid(), "Unexpected condition that result is not convertible." ); + m_ptr->OnImageGrabbed( static_cast(camera), grabResultLocal ); + } + + virtual void OnImageEventHandlerRegistered( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnImageEventHandlerRegistered( static_cast(camera) ); + } + + virtual void OnImageEventHandlerDeregistered( CInstantCamera& camera ) + { + PYLON_ASSERT2( dynamic_cast(&camera) != NULL, "Unexpected camera type passed." ); + m_ptr->OnImageEventHandlerDeregistered( static_cast(camera) ); + } + + virtual void DestroyImageEventHandler() + { + try + { + // destroy only when demanded + if (m_isCleanupDelete) + { + m_ptr->DestroyImageEventHandler(); + } + m_ptr = NULL; + } + catch (...) + { + delete this; + m_ptr = NULL; + throw; + } + delete this; + } + + private: + InterfaceT* m_ptr; + bool m_isCleanupDelete; + }; +} + +#endif /* INCLUDED_DEVICESPECIFICIMAGEEVENTHANDLERTIE_H_009136379 */ diff --git a/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificInstantCamera.h b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificInstantCamera.h new file mode 100644 index 0000000..d51b003 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificInstantCamera.h @@ -0,0 +1,530 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Template for device specific instant camera class. +*/ + +#ifndef INCLUDED_DEVICESPECIFICINSTANTCAMERA_H_4510266 +#define INCLUDED_DEVICESPECIFICINSTANTCAMERA_H_4510266 + +#include +#include +#include +#include +#include +#include + + +//! Macro for defining a custom instant camera class. +#define PYLON_DEFINE_INSTANT_CAMERA(ClassName, BaseClass) \ + PYLON_6_0_DEPRECATED("Use CBaslerUniversalInstantCamera") \ + class ClassName : public BaseClass \ + { \ + public: \ + /*! \copybrief CInstantCamera::CInstantCamera() + \copydetails CInstantCamera::CInstantCamera() + */ \ + ClassName() \ + { \ + } \ + /*! \copybrief CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + \copydetails CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + */ \ + ClassName( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ) : BaseClass( pDevice, cleanupProcedure ) \ + { \ + } \ + /*! \copybrief CInstantCamera::~CInstantCamera + \copydetails CInstantCamera::~CInstantCamera + */ \ + ~ClassName() \ + { \ + Attach( NULL ); \ + InternalShutdownEventHandlers(); \ + } \ + protected: \ + /* Create device specific grab result data. This is subject to change without notice */ \ + virtual CGrabResultData* CreateDeviceSpecificGrabResultData() \ + { \ + return new GrabResultData_t(); \ + } \ + }; + + namespace Pylon + { + /*! + \class CDeviceSpecificInstantCameraT + \brief Implementation Detail: Header only implementation class for creating device specific Instant Camera classes. + */ + + template + class CDeviceSpecificInstantCameraT : public CInstantCamera, public CameraTraitsT::CameraParams_t, public CameraTraitsT + { + public: + /*! + \copybrief Pylon::CInstantCamera::CInstantCamera() + \copydetails Pylon::CInstantCamera::CInstantCamera() + */ + CDeviceSpecificInstantCameraT(); + + /*! + \copybrief Pylon::CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + \copydetails Pylon::CInstantCamera::CInstantCamera( IPylonDevice* , ECleanup ) + */ + CDeviceSpecificInstantCameraT( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ); + + /*! + \copybrief Pylon::CInstantCamera::~CInstantCamera() + \copydetails Pylon::CInstantCamera::~CInstantCamera() + */ + virtual ~CDeviceSpecificInstantCameraT(); + + /* + \copybrief Pylon::CInstantCamera::Attach + \copydetails Pylon::CInstantCamera::Attach + */ + virtual void Attach( IPylonDevice* pDevice, ECleanup cleanupProcedure = Cleanup_Delete ); + + /* + \copybrief Pylon::CInstantCamera::DestroyDevice + \copydetails Pylon::CInstantCamera::DestroyDevice + */ + virtual void DestroyDevice(); + + /* + \copybrief Pylon::CInstantCamera::DetachDevice + \copydetails Pylon::CInstantCamera::DetachDevice + */ + virtual IPylonDevice* DetachDevice(); + + + + /* + \copybrief Pylon::CInstantCamera::Open + \copydetails Pylon::CInstantCamera::Open + */ + virtual void Open(); + + /* + \copybrief Pylon::CInstantCamera::Close + \copydetails Pylon::CInstantCamera::Close + */ + virtual void Close(); + + + + /*! + \copybrief Pylon::CInstantCamera::RetrieveResult + \copydetails Pylon::CInstantCamera::RetrieveResult + */ + virtual bool RetrieveResult( unsigned int timeoutMs, typename CameraTraitsT::GrabResultPtr_t& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ); + + // Also available + using CInstantCamera::RetrieveResult; + + /*! + \copybrief Pylon::CInstantCamera::GrabOne + \copydetails Pylon::CInstantCamera::GrabOne + */ + virtual bool GrabOne( unsigned int timeoutMs, typename CameraTraitsT::GrabResultPtr_t& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ); + + // Also available + using CInstantCamera::GrabOne; + + + + /*! + \copybrief Pylon::CInstantCamera::RegisterConfiguration( CConfigurationEventHandler*, ERegistrationMode, ECleanup) + \copydetails Pylon::CInstantCamera::RegisterConfiguration( CConfigurationEventHandler*, ERegistrationMode, ECleanup) + */ + virtual void RegisterConfiguration( typename CameraTraitsT::ConfigurationEventHandler_t* pConfigurator, ERegistrationMode mode, ECleanup cleanupProcedure ); + + // Also available + using CInstantCamera::RegisterConfiguration; + + /*! + \copybrief Pylon::CInstantCamera::DeregisterConfiguration( CConfigurationEventHandler*) + \copydetails Pylon::CInstantCamera::DeregisterConfiguration( CConfigurationEventHandler*) + */ + virtual bool DeregisterConfiguration( typename CameraTraitsT::ConfigurationEventHandler_t* configurator ); + + // Also available + using CInstantCamera::DeregisterConfiguration; + + + + /*! + \copybrief Pylon::CInstantCamera::RegisterImageEventHandler( CImageEventHandler*, ERegistrationMode, ECleanup) + \copydetails Pylon::CInstantCamera::RegisterImageEventHandler( CImageEventHandler*, ERegistrationMode, ECleanup) + */ + virtual void RegisterImageEventHandler( typename CameraTraitsT::ImageEventHandler_t* pImageEventHandler, ERegistrationMode mode, ECleanup cleanupProcedure ); + + // Also available + using CInstantCamera::RegisterImageEventHandler; + + /*! + \copybrief Pylon::CInstantCamera::DeregisterImageEventHandler( CImageEventHandler*) + \copydetails Pylon::CInstantCamera::DeregisterImageEventHandler( CImageEventHandler*) + */ + virtual bool DeregisterImageEventHandler( typename CameraTraitsT::ImageEventHandler_t* imageEventHandler ); + + // Also available + using CInstantCamera::DeregisterImageEventHandler; + + + + /*! + \copybrief Pylon::CInstantCamera::RegisterCameraEventHandler( CCameraEventHandler*, const String_t&, intptr_t, ERegistrationMode, ECleanup, ECameraEventAvailability) + \copydetails Pylon::CInstantCamera::RegisterCameraEventHandler( CCameraEventHandler*, const String_t&, intptr_t, ERegistrationMode, ECleanup, ECameraEventAvailability) + */ + virtual void RegisterCameraEventHandler( typename CameraTraitsT::CameraEventHandler_t* pCameraEventHandler, const String_t& nodeName, intptr_t userProvidedId, ERegistrationMode mode, ECleanup cleanupProcedure, ECameraEventAvailability availability = CameraEventAvailability_Mandatory ); + + // Also available + using CInstantCamera::RegisterCameraEventHandler; + + /*! + \copybrief Pylon::CInstantCamera::DeregisterCameraEventHandler( CCameraEventHandler*, const String_t&) + \copydetails Pylon::CInstantCamera::DeregisterCameraEventHandler( CCameraEventHandler*, const String_t&) + */ + virtual bool DeregisterCameraEventHandler( typename CameraTraitsT::CameraEventHandler_t* cameraEventHandler, const String_t& nodeName ); + + // Also available + using CInstantCamera::DeregisterCameraEventHandler; + + + + /*! + \copybrief Pylon::CInstantCamera::GetDeviceInfo + \copydetails Pylon::CInstantCamera::GetDeviceInfo + */ + virtual const typename CameraTraitsT::DeviceInfo_t& GetDeviceInfo() const; + + + /*! + \brief Provides access to the transport layer parameters of the attached %Pylon Device. + \return Reference to the transport layer parameters. + \pre A %Pylon Device is attached. + \error + The Instant Camera object is still valid after error. + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual typename CameraTraitsT::TlParams_t& GetTLParams(); + + + /*! + \brief Provides access to the stream grabber parameters of the attached %Pylon Device. + \return Reference to the stream grabber parameters. + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ \error + The Instant Camera object is still valid after error. + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual typename CameraTraitsT::StreamGrabberParams_t& GetStreamGrabberParams(); + + + /*! + \brief Provides access to the event grabber parameters of the attached %Pylon Device. + \return Reference to the event grabber parameters. + \pre +
    +
  • A %Pylon Device is attached. +
  • The %Pylon Device is open. +
+ \error + The Instant Camera object is still valid after error. + \threading + This method is synchronized using the lock provided by GetLock(). + */ + virtual typename CameraTraitsT::EventGrabberParams_t& GetEventGrabberParams(); + + // Types used by camera-------------------------------------------------- + + // Overload CInstantCamera type definitions + typedef typename CameraTraitsT::InstantCamera_t InstantCamera_t; + typedef typename CameraTraitsT::IPylonDevice_t IPylonDevice_t; + typedef typename CameraTraitsT::DeviceInfo_t DeviceInfo_t; + typedef typename CameraTraitsT::ConfigurationEventHandler_t ConfigurationEventHandler_t; + typedef typename CameraTraitsT::ImageEventHandler_t ImageEventHandler_t; + typedef typename CameraTraitsT::CameraEventHandler_t CameraEventHandler_t; + typedef typename CameraTraitsT::GrabResultData_t GrabResultData_t; + typedef typename CameraTraitsT::GrabResultPtr_t GrabResultPtr_t; + + protected: + typename CameraTraitsT::TlParams_t* m_pTlParams; + typename CameraTraitsT::StreamGrabberParams_t* m_pStreamGrabberParams; + typename CameraTraitsT::EventGrabberParams_t* m_pEventGrabberParams; + }; + + + + + + + // Implementation ---------------------------------------------------------- + + template + CDeviceSpecificInstantCameraT::CDeviceSpecificInstantCameraT() + : m_pTlParams( new typename CameraTraitsT::TlParams_t() ) + , m_pStreamGrabberParams( new typename CameraTraitsT::StreamGrabberParams_t() ) + , m_pEventGrabberParams( new typename CameraTraitsT::EventGrabberParams_t() ) + { + } + + + template + CDeviceSpecificInstantCameraT::CDeviceSpecificInstantCameraT( IPylonDevice* pDevice, ECleanup cleanupProcedure ) + : m_pTlParams( new typename CameraTraitsT::TlParams_t() ) + , m_pStreamGrabberParams( new typename CameraTraitsT::StreamGrabberParams_t() ) + , m_pEventGrabberParams( new typename CameraTraitsT::EventGrabberParams_t() ) + { + this->Attach( pDevice, cleanupProcedure ); + } + + template + CDeviceSpecificInstantCameraT::~CDeviceSpecificInstantCameraT() + { + delete m_pTlParams; + m_pTlParams = NULL; + delete m_pStreamGrabberParams; + m_pStreamGrabberParams = NULL; + delete m_pEventGrabberParams; + m_pEventGrabberParams = NULL; + } + + template + void CDeviceSpecificInstantCameraT::Attach( IPylonDevice* pDevice, ECleanup cleanupProcedure ) + { + // Check whether device type matches camera type. + if (pDevice) + { + if ( (dynamic_cast(pDevice) == NULL) + || (this->HasSpecificDeviceClass() && (pDevice->GetDeviceInfo().GetDeviceClass() != this->DeviceClass())) + ) + { + throw LOGICAL_ERROR_EXCEPTION( "The attached pylon device type cannot be used with this type of camera class." ); + } + } + + AutoLock lock( CInstantCamera::GetLock() ); + // Attach the device. + CInstantCamera::Attach( pDevice, cleanupProcedure ); + + // Update camera parameters. + if (CInstantCamera::IsPylonDeviceAttached()) + { + // Set camera parameters. + CameraTraitsT::CameraParams_t::_Initialize( pDevice->GetNodeMap() ); + // Set TL parameters. + m_pTlParams->Attach( &CInstantCamera::GetTLNodeMap(), true ); + } + else + { + // Reset camera parameters. + CameraTraitsT::CameraParams_t::_Initialize( &CInstantCamera::GetEmptyNodeMap() ); + // Reset TL parameters. + m_pTlParams->Attach( &CInstantCamera::GetEmptyNodeMap(), true ); + } + } + + template + void CDeviceSpecificInstantCameraT::DestroyDevice() + { + AutoLock lock( CInstantCamera::GetLock() ); + + // If a device is attached + if (CInstantCamera::IsPylonDeviceAttached()) + { + // Reset camera parameters. + CameraTraitsT::CameraParams_t::_Initialize( &CInstantCamera::GetEmptyNodeMap() ); + // Reset TL parameters. + m_pTlParams->Attach( &CInstantCamera::GetEmptyNodeMap(), true ); + // Perform destroy operation. + CInstantCamera::DestroyDevice(); + } + } + + template + IPylonDevice* CDeviceSpecificInstantCameraT::DetachDevice() + { + AutoLock lock( CInstantCamera::GetLock() ); + IPylonDevice* pDevice = NULL; + + // If a device is attached + if (CInstantCamera::IsPylonDeviceAttached()) + { + // Reset camera parameters. + CameraTraitsT::CameraParams_t::_Initialize( &CInstantCamera::GetEmptyNodeMap() ); + // Reset TL parameters. + m_pTlParams->Attach( &CInstantCamera::GetEmptyNodeMap(), true ); + // Perform detach operation. + pDevice = CInstantCamera::DetachDevice(); + } + return pDevice; + } + + template + void CDeviceSpecificInstantCameraT::Open() + { + AutoLock lock( CInstantCamera::GetLock() ); + // Perform open operation. + CInstantCamera::Open(); + // Set stream grabber parameters. + m_pStreamGrabberParams->Attach( &CInstantCamera::GetStreamGrabberNodeMap(), true ); + // Set event grabber parameters. + m_pEventGrabberParams->Attach( &CInstantCamera::GetEventGrabberNodeMap(), true ); + } + + template + void CDeviceSpecificInstantCameraT::Close() + { + AutoLock lock( CInstantCamera::GetLock() ); + // Reset stream grabber parameters. + m_pStreamGrabberParams->Attach( &CInstantCamera::GetEmptyNodeMap(), true ); + // Reset event grabber parameters. + m_pEventGrabberParams->Attach( &CInstantCamera::GetEmptyNodeMap(), true ); + // Perform close operation. + CInstantCamera::Close(); + } + + + + template + bool CDeviceSpecificInstantCameraT::RetrieveResult( unsigned int timeoutMs, typename CameraTraitsT::GrabResultPtr_t& grabResult, ETimeoutHandling timeoutHandling ) + { + //Release the grab result + grabResult.Release(); + // Use basic grab result. + CGrabResultPtr grabResultLocal; + // Call basic RetrieveResult. + CInstantCamera::RetrieveResult( timeoutMs, grabResultLocal, timeoutHandling ); + // Convert. + grabResult = grabResultLocal; + // Returns true if grabResultLocal is valid and the conversion to the device specific grab result type has been successful. + return grabResult.IsValid(); + } + + + template + bool CDeviceSpecificInstantCameraT::GrabOne( unsigned int timeoutMs, typename CameraTraitsT::GrabResultPtr_t& grabResult, ETimeoutHandling timeoutHandling ) + { + //Release the grab result + grabResult.Release(); + // Use basic grab result. + CGrabResultPtr grabResultLocal; + // Call basic GrabOne. + CInstantCamera::GrabOne( timeoutMs, grabResultLocal, timeoutHandling ); + // Convert. + grabResult = grabResultLocal; + // Returns true if grabResultLocal is valid and the conversion to the device specific grab result type has been successful. + return grabResult.IsValid(); + } + + + + template + void CDeviceSpecificInstantCameraT::RegisterConfiguration( typename CameraTraitsT::ConfigurationEventHandler_t* pConfigurator, ERegistrationMode mode, ECleanup cleanupProcedure ) + { + typedef CDeviceSpecificConfigurationEventHandlerTie< typename CameraTraitsT::InstantCamera_t, typename CameraTraitsT::ConfigurationEventHandler_t> TieT; + InternalRegisterConfiguration( + pConfigurator ? new TieT( pConfigurator, cleanupProcedure == Cleanup_Delete ) : NULL, + mode, + Cleanup_Delete, // demand deletion of TieT + pConfigurator ? &pConfigurator->DebugGetEventHandlerRegistrationCount() : NULL ); + } + + template + bool CDeviceSpecificInstantCameraT::DeregisterConfiguration( typename CameraTraitsT::ConfigurationEventHandler_t* pConfigurator ) + { + return InternalDeregisterConfiguration( pConfigurator ? &pConfigurator->DebugGetEventHandlerRegistrationCount() : NULL ); + } + + + template + void CDeviceSpecificInstantCameraT::RegisterImageEventHandler( typename CameraTraitsT::ImageEventHandler_t* pImageEventHandler, ERegistrationMode mode, ECleanup cleanupProcedure ) + { + typedef CDeviceSpecificImageEventHandlerTie< typename CameraTraitsT::InstantCamera_t, typename CameraTraitsT::ImageEventHandler_t> TieT; + InternalRegisterImageEventHandler( + pImageEventHandler ? new TieT( pImageEventHandler, cleanupProcedure == Cleanup_Delete ) : NULL, + mode, + Cleanup_Delete, // demand deletion of TieT + pImageEventHandler ? &pImageEventHandler->DebugGetEventHandlerRegistrationCount() : NULL ); + } + + template + bool CDeviceSpecificInstantCameraT::DeregisterImageEventHandler( typename CameraTraitsT::ImageEventHandler_t* pImageEventHandler ) + { + return InternalDeregisterImageEventHandler( pImageEventHandler ? &pImageEventHandler->DebugGetEventHandlerRegistrationCount() : NULL ); + } + + + template + void CDeviceSpecificInstantCameraT::RegisterCameraEventHandler( + typename CameraTraitsT::CameraEventHandler_t* pCameraEventHandler, + const String_t& nodeName, + intptr_t userProvidedId, + ERegistrationMode mode, + ECleanup cleanupProcedure, + ECameraEventAvailability availability ) + { + typedef CDeviceSpecificCameraEventHandlerTie< typename CameraTraitsT::InstantCamera_t, typename CameraTraitsT::CameraEventHandler_t> TieT; + InternalRegisterCameraEventHandler( + pCameraEventHandler ? new TieT( pCameraEventHandler, cleanupProcedure == Cleanup_Delete ) : NULL, + nodeName, userProvidedId, mode, + Cleanup_Delete, // demand deletion of TieT + availability, + pCameraEventHandler ? &pCameraEventHandler->DebugGetEventHandlerRegistrationCount() : NULL ); + } + + template + bool CDeviceSpecificInstantCameraT::DeregisterCameraEventHandler( typename CameraTraitsT::CameraEventHandler_t* pCameraEventHandler, const String_t& nodeName ) + { + return InternalDeregisterCameraEventHandler( pCameraEventHandler ? &pCameraEventHandler->DebugGetEventHandlerRegistrationCount() : NULL, nodeName ); + } + + + template + const typename CameraTraitsT::DeviceInfo_t& CDeviceSpecificInstantCameraT::GetDeviceInfo() const + { + return static_cast(CInstantCamera::GetDeviceInfo()); + } + + template + typename CameraTraitsT::TlParams_t& CDeviceSpecificInstantCameraT::GetTLParams() + { + AutoLock lock( CInstantCamera::GetLock() ); + // Enforce preconditions. + CInstantCamera::GetTLNodeMap(); + return *m_pTlParams; + } + + template + typename CameraTraitsT::StreamGrabberParams_t& CDeviceSpecificInstantCameraT::GetStreamGrabberParams() + { + AutoLock lock( CInstantCamera::GetLock() ); + // Enforce preconditions. + CInstantCamera::GetStreamGrabberNodeMap(); + return *m_pStreamGrabberParams; + } + + template + typename CameraTraitsT::EventGrabberParams_t& CDeviceSpecificInstantCameraT::GetEventGrabberParams() + { + AutoLock lock( CInstantCamera::GetLock() ); + // Enforce preconditions. + CInstantCamera::GetEventGrabberNodeMap(); + return *m_pEventGrabberParams; + } + + } // namespace Pylon + +#endif /* INCLUDED_DEVICESPECIFICINSTANTCAMERA_H_4510266 */ diff --git a/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificInstantCameraArray.h b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificInstantCameraArray.h new file mode 100644 index 0000000..3154903 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/private/DeviceSpecificInstantCameraArray.h @@ -0,0 +1,113 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Template for device specific instant camera array class. +*/ + +#ifndef INCLUDED_DEVICESPECIFICINSTANTCAMERAARRAY_H_4299977 +#define INCLUDED_DEVICESPECIFICINSTANTCAMERAARRAY_H_4299977 + +#include + +namespace Pylon +{ + /*! + \class CDeviceSpecificInstantCameraArrayT + \brief Implementation Detail: Header only implementation class for creating device specific Instant Camera Array classes. + */ + template + class CDeviceSpecificInstantCameraArrayT : public CInstantCameraArray + { + public: + + /*! + \copybrief CInstantCameraArray::CInstantCameraArray() + \copydetails CInstantCameraArray::CInstantCameraArray() + */ + CDeviceSpecificInstantCameraArrayT() + { + } + + /*! + \copybrief CInstantCameraArray::CInstantCameraArray( size_t) + \copydetails CInstantCameraArray::CInstantCameraArray( size_t) + */ + CDeviceSpecificInstantCameraArrayT( size_t numberOfCameras ) + { + CInstantCameraArray::Initialize( numberOfCameras ); + } + + /*! + \copybrief CInstantCameraArray::~CInstantCameraArray() + \copydetails CInstantCameraArray::~CInstantCameraArray() + */ + virtual ~CDeviceSpecificInstantCameraArrayT() + { + // Stop grabbing and free all cameras. + Initialize( 0 ); + } + + /*! + \copybrief Pylon::CInstantCameraArray::operator[]( size_t) + \copydetails Pylon::CInstantCameraArray::operator[]( size_t) + */ + virtual CameraT& operator[]( size_t index ) + { + //Cast camera at the index to the device specific camera type and return the result of the cast. + return dynamic_cast(CInstantCameraArray::operator[]( index )); + } + + /*! + \copybrief Pylon::CInstantCameraArray::operator[]( size_t) + \copydetails Pylon::CInstantCameraArray::operator[]( size_t) + */ + virtual const CameraT& operator[]( size_t index ) const + { + //Cast to the specific camera type and return it. + return dynamic_cast(CInstantCameraArray::operator[]( index )); + } + + /*! + \copybrief Pylon::CInstantCameraArray::RetrieveResult + \copydetails Pylon::CInstantCameraArray::RetrieveResult + */ + virtual bool RetrieveResult( unsigned int timeoutMs, typename CameraT::GrabResultPtr_t& grabResult, ETimeoutHandling timeoutHandling = TimeoutHandling_ThrowException ) + { + //Release the grab result. + grabResult.Release(); + // Use basic grab result. + CGrabResultPtr grabResultLocal; + // Call basic RetrieveResult. + CInstantCameraArray::RetrieveResult( timeoutMs, grabResultLocal, timeoutHandling ); + // Convert. + grabResult = grabResultLocal; + // Returns true if grabResultLocal is valid and the conversion to the device specific grab result type has been successful. + return grabResult.IsValid(); + } + + // Also available. + using CInstantCameraArray::RetrieveResult; + public: + /// The type of the camera class in the array. + typedef CameraT InstantCamera_t; + protected: + //Create a specific camera object. + virtual CInstantCamera* CreateInstantCamera() + { + return new CameraT; + } + + //Destroy a specific camera object. + virtual void DestroyInstantCamera( CInstantCamera* pCamera ) + { + delete pCamera; + } + }; +} + +#endif /* INCLUDED_DEVICESPECIFICINSTANTCAMERAARRAY_H_4299977 */ diff --git a/Cigarette/Pylon6.2/include/pylon/stdinclude.h b/Cigarette/Pylon6.2/include/pylon/stdinclude.h new file mode 100644 index 0000000..dff3f18 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/stdinclude.h @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2006-2021 Basler AG +// http://www.baslerweb.com +// Author: Hartmut Nebelung +//----------------------------------------------------------------------------- +/*! +\file +\brief standard definitions +*/ +#ifndef __STDINCLUDE_H__ +#define __STDINCLUDE_H__ + +#include + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#ifdef PYLON_WIN_BUILD +# include // for definition of type 'interface' +#endif + + +/////////////////////////////////////////////////////////////////////////////// +// Note: +/////////////////////////////////////////////////////////////////////////////// +// The PY_ macros are only for backward compatibility +// please use the PYLON_ macros instead. Thank you! +/////////////////////////////////////////////////////////////////////////////// + +// mark a variable as unused. This prevents unused parameter / unused local variable warnings on warning level 4. +#define PYLON_UNUSED(unused_var) ((void)(unused_var)) +#define PY_UNUSED(unused_var) PYLON_UNUSED(unused_var) + +// returns the number of elements in an array +#define PYLON_COUNTOF(arr) (sizeof(arr)/sizeof(*arr)) +#define PY_COUNTOF(arr) PYLON_COUNTOF(arr) + +// PY_ASSERT works like normal assertion +#define PYLON_ASSERT(cond) assert(cond) +#define PY_ASSERT(cond) PYLON_ASSERT(cond) +// PY_ASSERT2 works like a normal assertion but can be passed a descriptive text string +#define PYLON_ASSERT2(cond, tx) assert((cond) && tx) +#define PY_ASSERT2(cond, tx) PYLON_ASSERT2(cond, tx) + +// verify macro +#ifndef NDEBUG +// assert in debug builds but do not remove in release builds +# define PYLON_VERIFY(cond) PYLON_ASSERT(cond) +# define PY_VERIFY(cond) PYLON_ASSERT(cond) +// assert in debug builds but do not remove in release builds but can be passed a descriptive text string +# define PYLON_VERIFY2(cond, tx) PYLON_ASSERT2(cond, tx) +# define PY_VERIFY2(cond, tx) PYLON_ASSERT2(cond, tx) +#else +# define PYLON_VERIFY(cond) ((void)(cond)) +# define PY_VERIFY(cond) ((void)(cond)) +# define PYLON_VERIFY2(cond, tx) PYLON_VERIFY(cond) +# define PY_VERIFY2(cond, tx) PYLON_VERIFY(cond) +#endif + +#if defined(PYLON_WIN_BUILD) +# if defined(PYLON_32_BUILD) +# define PYLON_UNALIGNED +# elif defined(PYLON_64_BUILD) +# define PYLON_UNALIGNED __unaligned +# endif +#elif defined(PYLON_UNIX_BUILD) +# define PYLON_UNALIGNED +#else +# error Invalid platform +#endif + +// Attention in MSVC this is a string literal +// but under gnuc this is a local variable! +#if defined(_MSC_VER) && _MSC_VER >= 1300 + // Attention this does not behave like a string literal! Use it as a variable of type const char[] +# define PYLON_FUNC __FUNCTION__ +#elif defined(__GNUC__) + // Attention this does not behave like a string literal! Use it as a variable of type const char[] +# define PYLON_FUNC __func__ +#else + // Attention this does not behave like a string literal! Use it as a variable of type const char[] +# define PYLON_FUNC "sorry_funcname_na" +#endif + + +// namespace aliases +#include +#include + +#include // for String_t, StringList_t + +namespace Pylon +{ + /// Pylon's string definition + typedef GENICAM_NAMESPACE::gcstring String_t; + /// Pylon's string list definition + typedef GENICAM_NAMESPACE::gcstring_vector StringList_t; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif //__STDINCLUDE_H__ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbCamera.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbCamera.h new file mode 100644 index 0000000..2476a2e --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbCamera.h @@ -0,0 +1,47 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Generic pylon USB3 Vision camera interface +*/ + +#ifndef BASLER_USB3VISION_CAMERA_H +#define BASLER_USB3VISION_CAMERA_H + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + + +#include "PylonUsbCamera.h" + +#include "_BaslerUsbCameraParams.h" + + +namespace Pylon +{ + //************************************************************************************************** + //! Low Level API: The camera class for Basler USB3 Vision camera devices + /** + Class for Basler USB3 Vision cameras providing access to camera parameters. + \see \ref configuringcameras + + \ingroup Pylon_LowLevelApi + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + //************************************************************************************************** + PYLON_DEFINE_CAMERA( CBaslerUsbCamera, Pylon::CPylonUsbCameraT ); + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // BASLER_USB3VISION_CAMERA_H diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbCameraEventHandler.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbCameraEventHandler.h new file mode 100644 index 0000000..710ea15 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbCameraEventHandler.h @@ -0,0 +1,160 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the camera event handler base class. +*/ + +#ifndef INCLUDED_BASLERUSBCAMERAEVENTHANDLER_H_3102315 +#define INCLUDED_BASLERUSBCAMERAEVENTHANDLER_H_3102315 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +#if _MSC_VER +# pragma warning( push) +# pragma warning( disable : 4100) //warning C4100: 'identifier' : unreferenced formal parameter +#endif + +namespace Pylon +{ + class CBaslerUsbInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + /** + \class CBaslerUsbCameraEventHandler + \brief The camera event handler base class. + */ + class CBaslerUsbCameraEventHandler + { + public: + + /** + \brief This method is called when a camera event has been received. + + Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the + processing of images. + + \param[in] camera The source of the call. + \param[in] userProvidedId The ID passed when registering for the event. It can be used to distinguish between different events. + \param[in] pNode The node identified by node name when registering. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + \threading + This method is called outside the lock of the camera object, outside the lock of the node map, and inside the lock of the camera event handler registry. + */ + virtual void OnCameraEvent( CBaslerUsbInstantCamera& camera, intptr_t userProvidedId, GENAPI_NAMESPACE::INode* pNode ) + { + } + + /** + \brief This method is called when the camera event handler has been registered. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerUsbCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerRegistered( CBaslerUsbInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + } + + /** + \brief This method is called when the camera event handler has been deregistered. + + The camera event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event. + \param[in] userProvidedId This ID is passed as a parameter in CBaslerUsbCameraEventHandler::OnCameraEvent and can be used to distinguish between different events. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera event handler registry. + */ + virtual void OnCameraEventHandlerDeregistered( CBaslerUsbInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId ) + { + } + + /*! + \brief Destroys the camera event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyCameraEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerUsbCameraEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerUsbCameraEventHandler( const CBaslerUsbCameraEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerUsbCameraEventHandler& operator=( const CBaslerUsbCameraEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerUsbCameraEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#if _MSC_VER +# pragma warning( pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUSBCAMERAEVENTHANDLER_H_3102315 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbConfigurationEventHandler.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbConfigurationEventHandler.h new file mode 100644 index 0000000..51fa210 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbConfigurationEventHandler.h @@ -0,0 +1,399 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the configuration event handler base class. +*/ + +#ifndef INCLUDED_BASLERUSBCONFIGURATIONEVENTHANDLERH_01627755 +#define INCLUDED_BASLERUSBCONFIGURATIONEVENTHANDLERH_01627755 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#if _MSC_VER +# pragma warning( push) +# pragma warning( disable : 4100) //warning C4100: 'identifier' : unreferenced formal parameter +#endif + +namespace Pylon +{ + class CBaslerUsbInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + /** + \class CBaslerUsbConfigurationEventHandler + \brief The configuration event handler base class. + */ + class CBaslerUsbConfigurationEventHandler + { + public: + /** + \brief This method is called before a %Pylon Device (Pylon::IPylonDevice) is attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttach( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after a %Pylon Device (Pylon::IPylonDevice) has been attached by calling the Instant Camera object's Attach() method. + + This method can not be used for detecting that a camera device has been attached to the PC. + The camera's Attach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnAttached( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is detached from the Instant Camera object. + + The camera's Detach() method must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetach( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been detached from the Instant Camera object. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDetached( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is destroyed. + + Camera DestroyDevice must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroy( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnDestroyed( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpen( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been opened. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnOpened( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called before the attached %Pylon Device is closed. + + Camera Close must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClose( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after the attached %Pylon Device has been closed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnClosed( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called before a grab session is started. + + Camera StartGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStart( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after a grab session has been started. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStarted( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called before a grab session is stopped. + + Camera StopGrabbing must not be called from here or from subsequent calls to avoid infinite recursion. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStop( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called after a grab session has been stopped. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabStopped( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called when an exception has been triggered during grabbing. + + An exception has been triggered by a grab thread. The grab will be stopped after this event call. + + \param[in] camera The source of the call. + \param[in] errorMessage The message of the exception that signaled an error during grabbing. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnGrabError( CBaslerUsbInstantCamera& camera, const char* errorMessage ) + { + } + + /** + \brief This method is called when a camera device removal from the PC has been detected. + + The %Pylon Device attached to the Instant Camera is not operable after this event. + After it is made sure that no access to the %Pylon Device or any of its node maps is made anymore + the %Pylon Device should be destroyed using InstantCamera::DeviceDestroy(). + The access to the %Pylon Device can be protected using the lock provided by GetLock(), e.g. when accessing parameters. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. All event handlers are notified. + + \threading + This method is called inside the lock of the camera object from an additional thread. + */ + virtual void OnCameraDeviceRemoved( CBaslerUsbInstantCamera& camera ) + { + } + + + /** + \brief This method is called when the configuration event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationRegistered( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called when the configuration event handler has been deregistered. + + The configuration event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the camera object. + */ + virtual void OnConfigurationDeregistered( CBaslerUsbInstantCamera& camera ) + { + } + + /*! + \brief Destroys the configuration event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyConfiguration() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerUsbConfigurationEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerUsbConfigurationEventHandler( const CBaslerUsbConfigurationEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerUsbConfigurationEventHandler& operator=( const CBaslerUsbConfigurationEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerUsbConfigurationEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#if _MSC_VER +# pragma warning( pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUSBCONFIGURATIONEVENTHANDLERH_01627755 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbDeviceInfo.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbDeviceInfo.h new file mode 100644 index 0000000..119dbb4 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbDeviceInfo.h @@ -0,0 +1,44 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Definition of the CBaslerUsbDeviceInfo class +*/ + +#ifndef INCLUDED_BASLERUSBDEVICEINFO_H_8532831 +#define INCLUDED_BASLERUSBDEVICEINFO_H_8532831 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include +#include + +namespace Pylon +{ + /*! + \ingroup Pylon_TransportLayer + \class CBaslerUsbDeviceInfo + \brief PylonUsb specific Device Info object. + */ + class PYLONBASE_API CBaslerUsbDeviceInfo : public Pylon::CDeviceInfo + { + public: + CBaslerUsbDeviceInfo(); + CBaslerUsbDeviceInfo( const CDeviceInfo& di ); + virtual ~CBaslerUsbDeviceInfo(); + }; +} + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUSBDEVICEINFO_H_8532831 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbGrabResultData.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbGrabResultData.h new file mode 100644 index 0000000..30c7deb --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbGrabResultData.h @@ -0,0 +1,51 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2012-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief USB specific grab result data class. +*/ +#ifndef INCLUDED_BASLERUSBGRABRESULTDATA_H_7474481 +#define INCLUDED_BASLERUSBGRABRESULTDATA_H_7474481 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + /// The USB specific grab result data class. + class CBaslerUsbGrabResultData : public CGrabResultData, public Basler_UsbChunkData::CUsbChunkData_Params + { + protected: + // Internal use only. The grab result data class should only be created by the Instant Camera class. + friend class CBaslerUsbInstantCamera; + CBaslerUsbGrabResultData() + { + } + + // Internal use only. + virtual void Destroy() + { + delete this; + } + + // Internal use only. + virtual void Initialize() + { + _Initialize( &GetChunkDataNodeMap() ); + } + }; + + /** + * @} + */ +} + +#endif /* INCLUDED_BASLERUSBGRABRESULTDATA_H_7474481 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbGrabResultPtr.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbGrabResultPtr.h new file mode 100644 index 0000000..40f6b72 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbGrabResultPtr.h @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2012-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief Contains the USB specific grab result ptr class. +*/ + +#ifndef INCLUDED_BASLERUSBGRABRESULTPTR_H_03519839 +#define INCLUDED_BASLERUSBGRABRESULTPTR_H_03519839 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + /// The USB specific grab result smart pointer. + PYLON_DEFINE_DEVICE_SPECIFIC_GRAB_RESULT_PTR( CBaslerUsbGrabResultPtr, CBaslerUsbGrabResultData ) + + /** + * @} + */ +} + +#endif /* INCLUDED_BASLERUSBGRABRESULTPTR_H_03519839 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbImageEventHandler.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbImageEventHandler.h new file mode 100644 index 0000000..8bf19c8 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbImageEventHandler.h @@ -0,0 +1,174 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2010-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/** +\file +\brief Contains the image event handler base class. +*/ + +#ifndef INCLUDED_BASLERUSBIMAGEEVENTHANDLER_H_8866388 +#define INCLUDED_BASLERUSBIMAGEEVENTHANDLER_H_8866388 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include + +#if _MSC_VER +# pragma warning( push) +# pragma warning( disable : 4100) //warning C4100: 'identifier' : unreferenced formal parameter +#endif + +namespace Pylon +{ + class CBaslerUsbInstantCamera; + + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + /** + \class CBaslerUsbImageEventHandler + \brief The image event handler base class. + */ + class CBaslerUsbImageEventHandler + { + public: + + /** + \brief This method is called when images have been skipped using the GrabStrategy_LatestImageOnly strategy or the GrabStrategy_LatestImages strategy. + + \param[in] camera The source of the call. + \param[in] countOfSkippedImages The number of images skipped. This \c countOfSkippedImages does not include the number of images lost in the case of a buffer under run in the driver. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImagesSkipped( CBaslerUsbInstantCamera& camera, size_t countOfSkippedImages ) + { + } + + /** + \brief This method is called when an image has been grabbed. + + The grab result smart pointer passed does always reference a grab result data object. + The status of the grab needs to be checked before accessing the grab result data. + See CGrabResultData::GrabSucceeded(), CGrabResultData::GetErrorCode() and + CGrabResultData::GetErrorDescription() for more information. + + \param[in] camera The source of the call. + \param[in] grabResult The grab result data. + + \error + Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered. + + \threading + This method is called outside the lock of the camera object but inside the lock of the image event handler registry. + */ + virtual void OnImageGrabbed( CBaslerUsbInstantCamera& camera, const CBaslerUsbGrabResultPtr& grabResult ) + { + } + + /** + \brief This method is called when the image event handler has been registered. + + \param[in] camera The source of the call. + + \error + Exceptions from this call will propagate through. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerRegistered( CBaslerUsbInstantCamera& camera ) + { + } + + /** + \brief This method is called when the image event handler has been deregistered. + + The image event handler is automatically deregistered when the Instant Camera object + is destroyed. + + \param[in] camera The source of the call. + + \error + C++ exceptions from this call will be caught and ignored. + \threading + This method is called inside the lock of the image event handler registry. + */ + virtual void OnImageEventHandlerDeregistered( CBaslerUsbInstantCamera& camera ) + { + } + + /*! + \brief Destroys the image event handler. + + \error + C++ exceptions from this call will be caught and ignored. + */ + virtual void DestroyImageEventHandler() + { + //If runtime errors occur here during delete, check the following: + //Check that the cleanup procedure is correctly set when registering. + //Ensure that the registered object has been allocated on the heap using new. + //Ensure that the registered object has not already been deleted. + delete this; + } + + /// Create. + CBaslerUsbImageEventHandler() + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Copy. + CBaslerUsbImageEventHandler( const CBaslerUsbImageEventHandler& ) + : m_eventHandlerRegistrationCount( 0 ) + { + } + + /// Assign. + CBaslerUsbImageEventHandler& operator=( const CBaslerUsbImageEventHandler& ) + { + return *this; + } + + /// Destruct. + virtual ~CBaslerUsbImageEventHandler() + { + PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." ); + } + + // Internal use only. Subject to change without notice. + const long& DebugGetEventHandlerRegistrationCount() + { + return m_eventHandlerRegistrationCount; + } + + private: + long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered. + }; + + /** + * @} + */ +} + +#if _MSC_VER +# pragma warning( pop) +#endif + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif /* INCLUDED_BASLERUSBIMAGEEVENTHANDLER_H_8866388 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbInstantCamera.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbInstantCamera.h new file mode 100644 index 0000000..06063bd --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbInstantCamera.h @@ -0,0 +1,88 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2012-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief USB Specific Instant Camera class for Basler USB devices. +*/ + +#ifndef INCLUDED_BASLERUSBINSTANTCAMERA_H_6872827 +#define INCLUDED_BASLERUSBINSTANTCAMERA_H_6872827 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + class CBaslerUsbInstantCamera; + + /// Lists all the types used by the Device Specific Instant Camera class for USB. + struct CBaslerUsbInstantCameraTraits + { + /// The type of the final camera class. + typedef CBaslerUsbInstantCamera InstantCamera_t; + /// \copybrief Basler_UsbCameraParams::CUsbCameraParams_Params + typedef Basler_UsbCameraParams::CUsbCameraParams_Params CameraParams_t; + /// \copybrief Pylon::IPylonDevice + typedef IPylonDevice IPylonDevice_t; + /// \copybrief Pylon::CBaslerUsbDeviceInfo + typedef Pylon::CBaslerUsbDeviceInfo DeviceInfo_t; + /// The parameters of the USB transport layer. + typedef CNodeMapProxyT TlParams_t; + /// The parameters of the USB stream grabber. + typedef CNodeMapProxyT StreamGrabberParams_t; + /// The parameters of the USB event grabber. + typedef CNodeMapProxyT EventGrabberParams_t; + /// The USB specific configuration event handler class. + typedef CBaslerUsbConfigurationEventHandler ConfigurationEventHandler_t; + /// The USB specific image event handler class. + typedef CBaslerUsbImageEventHandler ImageEventHandler_t; + /// The USB specific camera event handler class. + typedef CBaslerUsbCameraEventHandler CameraEventHandler_t; + /// The USB specific grab result data. + typedef CBaslerUsbGrabResultData GrabResultData_t; + /// The USB specific grab result smart pointer. + typedef CBaslerUsbGrabResultPtr GrabResultPtr_t; + + //! Can be used to check whether the DeviceClass() can be used for enumeration. + static bool HasSpecificDeviceClass() + { + return true; + } + //! The name of this device class. Use this one for enumeration. + static String_t DeviceClass() + { + return BaslerUsbDeviceClass; + } + }; + + + /*! + \class CBaslerUsbInstantCamera + \brief Extends the CInstantCamera by USB specific parameter interface classes. + */ + PYLON_DEFINE_INSTANT_CAMERA( CBaslerUsbInstantCamera, CDeviceSpecificInstantCameraT ) + + /** + * @} + */ +} // namespace Pylon + +#endif /* INCLUDED_BASLERUSBINSTANTCAMERA_H_6872827 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbInstantCameraArray.h b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbInstantCameraArray.h new file mode 100644 index 0000000..b1d876b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/BaslerUsbInstantCameraArray.h @@ -0,0 +1,64 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2012-2021 Basler AG +// http://www.baslerweb.com +// Author: Andreas Gau +//----------------------------------------------------------------------------- +/*! +\file +\brief USB specific instant camera array class. +*/ +#ifndef INCLUDED_BASLERUSBINSTANTCAMERAARRAY_H_5817072 +#define INCLUDED_BASLERUSBINSTANTCAMERAARRAY_H_5817072 + +#include +#include + +namespace Pylon +{ + /** \addtogroup Pylon_InstantCameraApiUsb + * @{ + */ + + /*! + \class CBaslerUsbInstantCameraArray + \brief USB specific instant camera array + + \threading + The CBaslerUsbInstantCameraArray class is not thread-safe. + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCameraArray instead. + */ + PYLON_6_0_DEPRECATED( "Use CBaslerUniversalInstantCameraArray" ) + class CBaslerUsbInstantCameraArray : public CDeviceSpecificInstantCameraArrayT + { + public: + /*! + \copybrief CInstantCameraArray::CInstantCameraArray() + \copydetails CInstantCameraArray::CInstantCameraArray() + */ + CBaslerUsbInstantCameraArray() + { + } + /*! + \copybrief CInstantCameraArray::CInstantCameraArray( size_t) + \copydetails CInstantCameraArray::CInstantCameraArray( size_t) + */ + CBaslerUsbInstantCameraArray( size_t numberOfCameras ) : CDeviceSpecificInstantCameraArrayT( numberOfCameras ) + { + } + /*! + \copybrief CInstantCameraArray::~CInstantCameraArray() + \copydetails CInstantCameraArray::~CInstantCameraArray() + */ + virtual ~CBaslerUsbInstantCameraArray() + { + } + }; + + /** + * @} + */ +} + +#endif /* INCLUDED_BASLERUSBINSTANTCAMERAARRAY_H_5817072 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbCamera.h b/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbCamera.h new file mode 100644 index 0000000..4a95f34 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbCamera.h @@ -0,0 +1,135 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2007-2021 Basler AG +// http://www.baslerweb.com +//----------------------------------------------------------------------------- +/*! +\file +\brief Low Level API: Generic pylon USB3 Vision camera interface +*/ + +#ifndef PYLON_USB3VISION_CAMERA_H +#define PYLON_USB3VISION_CAMERA_H + +#if _MSC_VER > 1000 +# pragma once +#endif //_MSC_VER > 1000 + +#include + +#ifdef _MSC_VER +# pragma pack(push, PYLON_PACKING) +#endif /* _MSC_VER */ + +#include "../DeviceClass.h" +#include "../NodeMapProxy.h" +#include "../StreamGrabberProxy.h" +#include "../EventGrabberProxy.h" + +#include "BaslerUsbDeviceInfo.h" +#include "../PylonDeviceProxy.h" + +#include "_UsbStreamParams.h" +#include "_UsbEventParams.h" +#include "_UsbTLParams.h" + + +namespace Pylon +{ + //************************************************************************************************** + //! Low Level API: Class for pylon USB3 Vision cameras providing access to transport layer related parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + PYLON_DEFINE_NODEMAP( CPylonUsbTLParams, CNodeMapProxyT ); + + + //************************************************************************************************** + //! Low Level API: Class for pylon USB3 Vision cameras providing access to stream grabber related methods and parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + PYLON_DEFINE_STREAMGRABBER( CPylonUsbStreamGrabber, CStreamGrabberProxyT ); + + + //************************************************************************************************** + //! Low Level API: Class for pylon USB3 Vision cameras providing access to event grabber related methods and parameters. + /** + \see \ref configuringcameras + \ingroup Pylon_LowLevelApi + */ + //************************************************************************************************** + PYLON_DEFINE_EVENTGRABBER( CPylonUsbEventGrabber, CEventGrabberProxyT ); + + + //************************************************************************************************** + //! Low Level API: The camera class for pylon USB3 Vision camera devices + /** + This is the base class for pylon USB3 Vision cameras providing access to camera parameters. + \see \ref configuringcameras + + \tparam TCameraParams The camera specific parameter class (auto generated from camera xml file) + \ingroup Pylon_LowLevelApi + + \deprecated This class is deprecated in pylon 6.0. Please consider using CBaslerUniversalInstantCamera instead. + */ + //************************************************************************************************** + template + class CPylonUsbCameraT : public CPylonDeviceProxyT + { + public: + typedef Pylon::CBaslerUsbDeviceInfo DeviceInfo_t; //!< \copybrief Pylon::CBaslerUsbDeviceInfo + typedef Pylon::CPylonUsbTLParams TlParams_t; //!< \copybrief Pylon::CPylonUsbTLParams + typedef Pylon::CPylonUsbStreamGrabber StreamGrabber_t; //!< \copybrief Pylon::CPylonUsbStreamGrabber + typedef Pylon::CPylonUsbEventGrabber EventGrabber_t; //!< \copybrief Pylon::CPylonUsbEventGrabber + + /// The name of this device class, use this for enumeration + static String_t DeviceClass() + { + return BaslerUsbDeviceClass; + } + + public: + //! \name Construction + // \{ + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT() + */ + CPylonUsbCameraT() + { + }; + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + + \copydetails Pylon::CPylonDeviceProxyT::CPylonDeviceProxyT(IPylonDevice*,bool) + */ + CPylonUsbCameraT( IPylonDevice* pDevice, bool takeOwnership = true ) + : CPylonDeviceProxyT( pDevice, takeOwnership ) + { + } + + /** \brief \copybrief Pylon::CPylonDeviceProxyT::~CPylonDeviceProxyT() + + \copydetails Pylon::CPylonDeviceProxyT::~CPylonDeviceProxyT() + */ + virtual ~CPylonUsbCameraT() + { + }; + + //\} + }; + + +} // namespace Pylon + +#ifdef _MSC_VER +# pragma pack(pop) +#endif /* _MSC_VER */ + +#endif // PYLON_USB3VISION_CAMERA_H diff --git a/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbDefs.h b/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbDefs.h new file mode 100644 index 0000000..f86dca5 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbDefs.h @@ -0,0 +1,25 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2011-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Defines for pylonUSB +*/ + + +#ifndef INCLUDED_PYLONUSBDEFS_H_7217327 +#define INCLUDED_PYLONUSBDEFS_H_7217327 + +#include + +#ifdef PYLONUSB_EXPORTS +# define PYLONUSB_API APIEXPORT +#else +# define PYLONUSB_API APIIMPORT +#endif + + +#endif /* INCLUDED_PYLONUSBDEFS_H_7217327 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbIncludes.h b/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbIncludes.h new file mode 100644 index 0000000..cc3d6c0 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/PylonUsbIncludes.h @@ -0,0 +1,18 @@ +//----------------------------------------------------------------------------- +// Basler pylon SDK +// Copyright (c) 2012-2021 Basler AG +// http://www.baslerweb.com +// Author: AH +//----------------------------------------------------------------------------- +/*! +\file +\brief Includes for pylonUSB +*/ +#ifndef INCLUDED_PYLONUSBINCLUDES_H_3519251 +#define INCLUDED_PYLONUSBINCLUDES_H_3519251 + +#include +#include +#include //includes also CBaslerUsbInstantCamera + +#endif /* INCLUDED_PYLONUSBINCLUDES_H_3519251 */ diff --git a/Cigarette/Pylon6.2/include/pylon/usb/_BaslerUsbCameraParams.h b/Cigarette/Pylon6.2/include/pylon/usb/_BaslerUsbCameraParams.h new file mode 100644 index 0000000..4d6e91f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/_BaslerUsbCameraParams.h @@ -0,0 +1,6540 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Basler USB3Vision camera interface +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_UsbCameraParams_PARAMS_H +#define Basler_UsbCameraParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_UsbCameraParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for CameraOperationMode + enum CameraOperationModeEnums + { + CameraOperationMode_Standard, //!< + CameraOperationMode_LongExposure //!< + + }; + + //! Valid values for SequencerMode + enum SequencerModeEnums + { + SequencerMode_Off, //!& CameraOperationMode; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sets whether the sequencer can be used for image acquisition. Applies to: ace + + Sets whether the sequencer can be used for image acquisition. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& SequencerMode; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Index number of the currently active sequencer set. Applies to: ace + + Index number of the current sequencer set, i.e. of the sequencer set whose parameter values are currently present in the active set. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SequencerSetActive; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sets whether the sequencer can be configured. Applies to: ace + + Sets whether the sequencer can be configured. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& SequencerConfigurationMode; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sequencer set that will be used with the first frame start trigger after SequencerMode was set to On. Applies to: ace + + Sequencer set that will be used with the first frame start trigger after SequencerMode was set to On. Only sequencer set 0 is available. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SequencerSetStart; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sets a sequencer set by its index number. Applies to: ace + + Sets a sequencer set by its index number. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SequencerSetSelector; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Loads the parameter values of a sequencer set into the active set. Applies to: ace + + Loads the parameter values of a sequencer set into the active set. The sequencer set will then be the current set. + + \b Visibility = Expert + + \b Selected by : SequencerSetSelector + + */ + GENAPI_NAMESPACE::ICommand& SequencerSetLoad; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Saves the sequencer parameter values that are currently in the active set. Applies to: ace + + Saves the sequencer parameter values that are currently in the active set. The values will be saved for the sequencer set whose sequencer set index number is currently selected. + + \b Visibility = Expert + + \b Selected by : SequencerSetSelector + + */ + GENAPI_NAMESPACE::ICommand& SequencerSetSave; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sets the sequencer path. Applies to: ace + + Sets the sequencer path. + + \b Visibility = Expert + + \b Selected by : SequencerSetSelector + + */ + GENAPI_NAMESPACE::IInteger& SequencerPathSelector; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Next sequencer set to follow after the current one. Applies to: ace + + Next sequencer set to follow after the current one. + + \b Visibility = Expert + + \b Selected by : SequencerSetSelector, SequencerPathSelector + + */ + GENAPI_NAMESPACE::IInteger& SequencerSetNext; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sets the trigger source for sequencer set advance. Applies to: ace + + Sets the trigger source for sequencer set advance with the currently selected path. + + \b Visibility = Expert + + \b Selected by : SequencerSetSelector, SequencerPathSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& SequencerTriggerSource; + + //@} + + + //! \name SequencerControl - Contains parameters to control the sequencer. Applies to: ace + //@{ + /*! + \brief Sets the effective logical level for sequencer set advance. Applies to: ace + + Sets the effective logical level for sequencer set advance. Currently, only LevelHigh is available. + + \b Visibility = Expert + + \b Selected by : SequencerSetSelector, SequencerPathSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& SequencerTriggerActivation; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Width of the camera's sensor in pixels. Applies to: ace, dart, pulse + + Width of the camera's sensor in pixels. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SensorWidth; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Height of the camera's sensor in pixels. Applies to: ace, dart, pulse + + Height of the camera's sensor in pixels. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& SensorHeight; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Maximum allowed width of the region of interest in pixels. Applies to: ace, dart, pulse + + Maximum allowed width of the region of interest in pixels. value takes into account any function that may limit the maximum width. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& WidthMax; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Maximum allowed height of the region of interest in pixels. Applies to: ace, dart, pulse + + Maximum allowed height of the region of interest in pixels. value takes into account any function that may limit the maximum height. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& HeightMax; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Width of the camera's region of interest in pixels. Applies to: ace, dart, pulse + + Width of the camera's region of interest in pixels. Depending on the camera model, the parameter can be set in different increments. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& Width; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Height of the camera's region of interest in pixels. Applies to: ace, dart, pulse + + Height of the camera's region of interest in pixels. Depending on the camera model, the parameter can be set in different increments. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& Height; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Horizontal offset from the left side of the sensor to the region of interest (in pixels). Applies to: ace, dart, pulse + + Horizontal offset from the left side of the sensor to the region of interest (in pixels). + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& OffsetX; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Vertical offset from the top of the sensor to the region of interest (in pixels). Applies to: ace, dart, pulse + + Vertical offset from the top of the sensor to the region of interest (in pixels). + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& OffsetY; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Enables the line pitch feature. Applies to: ace + + Enables the line pitch feature which aligns output image data to multiples of 4 bytes. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& LinePitchEnable; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Number of bytes separating the starting pixels of two consecutive lines. Applies to: ace + + Number of bytes separating the starting pixels of two consecutive lines. This feature is used to facilitate alignment of image data. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& LinePitch; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Enables horizontal centering of the image. Applies to: ace + + Enables horizontal centering of the image. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IBoolean& CenterX; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Enables vertical centering of the image. Applies to: ace + + Enables vertical centering of the image. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IBoolean& CenterY; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the binning horizontal mode. Applies to: ace, dart, pulse + + Sets the binning horizontal mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningHorizontalMode; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Number of adjacent horizontal pixels to be summed. Applies to: ace, dart, pulse + + Number of adjacent horizontal pixels to be summed. Their charges will be summed and reported out of the camera as a single pixel. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BinningHorizontal; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the binning vertical mode. Applies to: ace, dart, pulse + + Sets the binning vertical mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& BinningVerticalMode; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Number of adjacent vertical pixels to be summed. Applies to: ace, dart, pulse + + Number of adjacent vertical pixels to be summed. Their charges will be summed and reported out of the camera as a single pixel. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BinningVertical; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Horizontal decimation factor. Applies to: ace + + Horizontal decimation factor. It specifies the extent of horizontal sub-sampling of the acquired frame, i.e. it defines how many pixel columns are left out of transmission. This has the net effect of reducing the horizontal resolution (width) of the image by the specified decimation factor. A value of 1 indicates that the camera performs no horizontal decimation. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& DecimationHorizontal; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Vertical decimation factor. Applies to: ace + + Vertical decimation factor. It specifies the extent of vertical sub-sampling of the acquired frame, i.e. it defines how many rows are left out of transmission. This has the net effect of reducing the vertical resolution (height) of the image by the specified decimation factor. A value of 1 indicates that the camera performs no vertical decimation. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& DecimationVertical; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Horizontal scaling factor. Applies to: ace + + Horizontal scaling factor. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ScalingHorizontal; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Vertical scaling factor. Applies to: ace + + Vertical scaling factor. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ScalingVertical; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Enables horizontal mirroring of the image. Applies to: ace, dart, pulse + + Enables horizontal mirroring of the image. The pixel values for each line in a captured image will be swapped end-for-end about the line's center. You can use the ROI feature when using the reverse X feature. Note that the position of the ROI relative to the sensor remains the same. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& ReverseX; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Enables vertical mirroring of the image. Applies to: ace, dart, pulse + + Enables vertical mirroring of the image. The pixel values for each row in a captured image will be swapped end-for-end about the row's center. You can use the ROI feature when using the reverse Y feature. Note that the position of the ROI relative to the sensor remains the same. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IBoolean& ReverseY; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the format of the pixel data transmitted by the camera. Applies to: ace, dart, pulse + + Sets the format of the pixel data transmitted by the camera. The available pixel formats depend on the camera model and whether the camera is monochrome or color. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelFormat; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Returns the depth of the pixel values in the image (in bits per pixel). Applies to: ace, dart, pulse + + Returns the depth of the pixel values in the image (in bits per pixel). The value will always be coherent with the pixel format setting. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelSize; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Returns the alignment of the camera's Bayer filter to the pixels in the acquired images. Applies to: ace, dart, pulse + + Returns the alignment of the camera's Bayer filter to the pixels in the acquired images. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& PixelColorFilter; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Minimum possible pixel value that could be transferred from the camera. Applies to: ace, dart, pulse + + Minimum possible pixel value that could be transferred from the camera. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& PixelDynamicRangeMin; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Maximum possible pixel value that could be transferred from the camera. Applies to: ace, dart, pulse + + Maximum possible pixel value that could be transferred from the camera. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& PixelDynamicRangeMax; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the test image to display. Applies to: ace + + Sets the test image to display. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TestImageSelector; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Holds all moving test images at their starting position. Applies to: ace + + Holds all moving test images at their starting position. All test images will be displayed at their starting positions and will stay fixed. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IBoolean& TestImageResetAndHold; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Selects the type of image test pattern that is generated by the device. Applies to: dart, pulse + + Selects the type of image test pattern that is generated by the device. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TestPattern; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets a ROI zone + + Sets a ROI zone to be enabled, configured, and assembled with other ROI zones. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ROIZoneSelector; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Provides for enabling/disabling a ROI zone. + + Provides for enabling/disabling the previously set ROI zone. + + \b Visibility = Expert + + \b Selected by : ROIZoneSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ROIZoneMode; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets a ROI zone size + + Sets the ROI zone 'thickness' (pixels, in direction of assembly) for the previously enabled ROI zone. Equivalent to Height for vertical zones. + + \b Visibility = Expert + + \b Selected by : ROIZoneSelector + + */ + GENAPI_NAMESPACE::IInteger& ROIZoneSize; + + //@} + + + //! \name ImageFormatControl - Contains parameters to control the size of the acquired image and the format of the transferred pixel data. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets a ROI zone offset + + Sets the ROI zone offset [pixels, in direction of assembly] for the previously enabled ROI zone. Equivalent to OffsetY for vertical zones. + + \b Visibility = Expert + + \b Selected by : ROIZoneSelector + + */ + GENAPI_NAMESPACE::IInteger& ROIZoneOffset; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the operation mode of the gain auto function. Applies to: ace, dart, pulse + + Sets the operation mode of the gain auto function. The gain auto function automatically adjusts the gain within set limits until a target brightness value is reached. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GainAuto; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the gain channel or tap to be adjusted. Applies to: ace, dart, pulse + + Sets the gain channel or tap to be adjusted. Once a gain channel or tap has been selected, all changes to the Gain parameter will be applied to the selected channel or tap. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& GainSelector; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Value of the currently selected gain control in dB. Applies to: ace, dart, pulse + + Value of the currently selected gain control in dB. + + \b Visibility = Beginner + + + \b Selected by : GainSelector + + */ + GENAPI_NAMESPACE::IFloat& Gain; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the black level channel or tap to be adjusted. Applies to: ace, dart, pulse + + Sets the black level channel or tap to be adjusted. Once a black level channel or tap has been selected, all changes to the BlackLevel parameter will be applied to the selected channel or tap. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BlackLevelSelector; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Value of the currently selected black level channel or tap. Applies to: ace, dart, pulse + + Value of the currently selected black level channel or tap. + + \b Visibility = Beginner + + + \b Selected by : BlackLevelSelector + + */ + GENAPI_NAMESPACE::IFloat& BlackLevel; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Gamma correction value. Applies to: ace, dart, pulse + + Gamma correction value. Gamma correction lets you modify the brightness of the pixel values to account for a non-linearity in the human perception of brightness. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& Gamma; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Returns the color space set for image acquisitions. Applies to: ace + + Returns the color space set for image acquisitions. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorSpace; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Value set for digital shift. Applies to: ace + + Value set for digital shift. When the parameter is set to zero, digital shift will be disabled. When the parameter is set to 1, 2, 3, or 4, digital shift will be set to shift by 1, shift by 2, shift by 3, or shift by 4 respectively. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& DigitalShift; + + //@} + + + //! \name AnalogControl - Contains parameters to control the analog characteristics of the video signal. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the color space for image acquisition. Applies to: dart, pulse + + Sets the color space for image acquisition. Note that perception of brightness also depends on the gamma correction value set. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BslColorSpaceMode; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the light source preset. Applies to: ace, dart, pulse + + Sets the light source preset. The colors in the image will be corrected so that they are appropriate for the selected light source. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IEnumerationT& LightSourcePreset; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the operation mode of the balance white auto function. Applies to: ace, dart, pulse + + Sets the operation mode of the balance white auto function. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BalanceWhiteAuto; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the color channel to be adjusted for manual white balance. Applies to: ace, dart, pulse + + Sets the color channel to be adjusted for manual white balance. Once a color intensity has been selected, all changes to the balance ratio parameter will be applied to the selected color intensity. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BalanceRatioSelector; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Value of the currently selected balance ratio channel or tap. Applies to: ace, dart, pulse + + Value of the currently selected balance ratio channel or tap. + + \b Visibility = Beginner + + + \b Selected by : BalanceRatioSelector + + */ + GENAPI_NAMESPACE::IFloat& BalanceRatio; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the color for color adjustment. Applies to: ace + + Sets the color for color adjustment. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorAdjustmentSelector; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Hue adjustment value for the currently selected color. Applies to: ace + + Hue adjustment value for the currently selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorAdjustmentHue; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Saturation adjustment value for the currently selected color. Applies to: ace + + Saturation adjustment value for the currently selected color. + + \b Visibility = Expert + + \b Selected by : ColorAdjustmentSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorAdjustmentSaturation; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the type of color transformation that will be performed. Applies to: ace + + Sets the type of color transformation that will be performed. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorTransformationSelector; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the element to be entered in the color transformation matrix. Applies to: ace + + Sets the element to be entered in the color transformation matrix for custom color transformation. Note: Depending on the camera model, some elements in the color transformation matrix may be preset and can not be changed. + + \b Visibility = Guru + + \b Selected by : ColorTransformationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& ColorTransformationValueSelector; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Transformation value for the selected element in the color transformation matrix. Applies to: ace + + Transformation value for the selected element in the color transformation matrix. + + \b Visibility = Guru + + \b Selected by : ColorTransformationSelector, ColorTransformationValueSelector + + */ + GENAPI_NAMESPACE::IFloat& ColorTransformationValue; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the contrast mode. Applies to: dart, pulse + + Sets the contrast mode. This specifies which type of contrast enhancement is used to adjust the contrast. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& BslContrastMode; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Amount of brightness to be applied. Applies to: dart, pulse + + Amount of brightness to be applied. This allows you to lighten or darken the entire image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& BslBrightness; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Amount of contrast to be applied. Applies to: dart, pulse + + Amount of contrast to be applied. The more contrast you apply, the more defined the difference between light and dark areas in the image will be. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& BslContrast; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Identifies outlier pixels and adjusts their intensity value. Applies to: dart, pulse + + Identifies pixels that have a significantly greater or lesser intensity value than its neighboring pixels (outlier pixels) and adjusts their intensity value. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& DefectPixelCorrectionMode; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Hue shift to be applied. + + Adjusting the hue shifts the colors of the image. This can be useful, e.g., for correcting minor color shifts or creating false-color images. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslHue; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Hue shift to be applied. Applies to: dart, pulse + + Hue shift to be applied. Adjusting the hue shifts the colors of the image. This can be useful, e.g., for correcting minor color shifts or creating false-color images. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& BslHueValue; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Saturation to be applied. + + Adjusting the saturation changes the intensity of the colors. A higher saturation, for example, makes colors easier to distinguish. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslSaturation; + + //@} + + + //! \name ImageQualityControl - Contains parameters to optimize the image quality. Applies to: ace, dart, pulse + //@{ + /*! + \brief Amount of saturation to be applied. Applies to: dart, pulse + + Amount of saturation to be applied. Adjusting the saturation changes the colorfulness (intensity) of the colors. A higher saturation, for example, will make colors easier to distinguish. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& BslSaturationValue; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. Applies to: ace + //@{ + /*! + \brief Sets the demosaicing mode. Applies to: ace + + Sets the demosaicing mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& DemosaicingMode; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. Applies to: ace + //@{ + /*! + \brief Enables Basler PGI image optimizations. + + Enables Basler PGI image optimizations. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& PgiMode; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. Applies to: ace + //@{ + /*! + \brief Amount of noise reduction to apply. Applies to: ace + + Amount of noise reduction to apply. The higher the value, the less chroma noise will be visible in your images. However, too high values may result in image information loss. To enable this feature, the DemosaicingMode parameter must be set to BaslerPGI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& NoiseReduction; + + //@} + + + //! \name PGIControl - Contains parameters related to the Basler PGI image optimization algorithm. Applies to: ace + //@{ + /*! + \brief Amount of sharpening to apply. Applies to: ace, dart, pulse + + Amount of sharpening to apply. The higher the sharpness, the more distinct the image subject's contours will be. However, too high values may result in image information loss. To enable this feature, the DemosaicingMode parameter must be set to BaslerPGI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& SharpnessEnhancement; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the image acquisition mode. Applies to: ace, dart, pulse + + Sets the image acquisition mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Starts the acquisition of images. Applies to: ace, dart, pulse + + Starts the acquisition of images. If the camera is set for single frame acquisition, it will start acquisition of one frame. If the camera is set for continuous frame acquisition, it will start continuous acquisition of frames. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionStart; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Stops the acquisition of images. Applies to: ace, dart, pulse + + Stops the acquisition of images if the camera is set for continuous image acquisition and acquisition has been started. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::ICommand& AcquisitionStop; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the shutter mode. Applies to: ace + + Sets the shutter mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ShutterMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the operation mode of the exposure auto function. Applies to: ace, dart, pulse + + Sets the operation mode of the exposure auto function. The exposure auto function automatically adjusts the exposure time within set limits until a target brightness value is reached. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureAuto; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureTimeMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the exposure mode. Applies to: ace, dart, pulse + + Sets the exposure mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Exposure time of the camera in microseconds. Applies to: ace, dart, pulse + + Exposure time of the camera in microseconds. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ExposureTime; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the exposure overlap time mode. Applies to: ace + + Sets the exposure overlap time mode. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ExposureOverlapTimeMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Maximum overlap of the sensor exposure with sensor readout in TriggerWidth exposure mode (in microseconds). Applies to: ace + + Maximum overlap of the sensor exposure with sensor readout in TriggerWidth exposure mode (in microseconds). + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& ExposureOverlapTimeMax; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the sensor readout mode. Applies to: ace + + Sets the sensor readout mode. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorReadoutMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Number of frames to acquire for each FrameBurstStart trigger. Applies to: ace + + Number of frames to acquire for each FrameBurstStart trigger. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& AcquisitionBurstFrameCount; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the trigger type to be configured. Applies to: ace, dart, pulse + + Sets the trigger type to be configured. Once a trigger type has been set, all changes to the trigger settings will be applied to the selected trigger. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerSelector; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the mode for the currently selected trigger. Applies to: ace, dart, pulse + + Sets the mode for the currently selected trigger. + + \b Visibility = Beginner + + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Generates a software trigger signal. Applies to: ace, dart, pulse + + Generates a software trigger signal. The software trigger signal will be used if the TriggerSource parameter is set to Software. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::ICommand& TriggerSoftware; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the signal source for the selected trigger. Applies to: ace, dart, pulse + + Sets the signal source for the selected trigger. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerSource; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the signal transition that activates the selected trigger. Applies to: ace, dart, pulse + + Sets the signal transition that activates the selected trigger. + + \b Visibility = Expert + + \b Selected by : TriggerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TriggerActivation; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Trigger delay time in microseconds. Applies to: ace + + Trigger delay time in microseconds. The delay is applied after the trigger reception and before effectively activating the trigger. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& TriggerDelay; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Enables setting the camera's acquisition frame rate to a specified value. Applies to: ace + + Enables setting the camera's acquisition frame rate to a specified value. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IBoolean& AcquisitionFrameRateEnable; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Acquisition frame rate of the camera in frames per second. Applies to: ace, dart, pulse + + Acquisition frame rate of the camera in frames per second. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IFloat& AcquisitionFrameRate; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Maximum allowed frame acquisition rate. Applies to: ace, dart, pulse + + Maximum allowed frame acquisition rate given the current camera settings (in frames per second). + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ResultingFrameRate; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sensor readout time given the current settings. Applies to: ace + + Sensor readout time given the current settings. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IFloat& SensorReadoutTime; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the acquisition status to be checked. Applies to: ace + + Sets the acquisition status to be checked. Once a status has been set, the status can be checked by reading the AcquisitionStatus parameter value. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& AcquisitionStatusSelector; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Indicates the status (true or false) of the currently selected acquisition signal. Applies to: ace + + Indicates the status (true or false) of the currently selected acquisition signal. acquisition signal can be selected using AcquisitionStatusSelector. + + \b Visibility = Expert + + \b Selected by : AcquisitionStatusSelector + + */ + GENAPI_NAMESPACE::IBoolean& AcquisitionStatus; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the shutter mode of the device. Applies to: dart, pulse + + Sets the shutter mode of the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& SensorShutterMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Configures overlapping exposure and image readout. Applies to: dart, pulse + + Configures overlapping exposure and image readout. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& OverlapMode; + + //@} + + + //! \name AcquisitionControl - Contains parameters to control image acquisition and triggering. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the immediate trigger mode. Applies to: dart, pulse + + Sets the immediate trigger mode. If this mode is enabled, exposure starts immediately after triggering, but changes to image parameters become effective with a short delay, i.e., after one or more images have been acquired. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& BslImmediateTriggerMode; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Target average brightness for the gain auto function and the exposure auto function. Applies to: ace, dart, pulse + + Target average brightness for the gain auto function and the exposure auto function. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoTargetBrightness; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets how gain and exposure time will be balanced when the device is making automatic adjustments. Applies to: ace, dart, pulse + + Sets how gain and exposure time will be balanced when the device is making automatic adjustments. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionProfile; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Lower limit for the Gain parameter when the gain auto function is active. Applies to: ace, dart, pulse + + Lower limit for the Gain parameter when the gain auto function is active. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoGainLowerLimit; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Upper limit for the Gain parameter when the gain auto function is active. Applies to: ace, dart, pulse + + Upper limit for the Gain parameter when the gain auto function is active. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoGainUpperLimit; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Lower limit for the ExposureTime parameter when the exposure auto function is active. Applies to: ace, dart, pulse + + Lower limit for the ExposureTime parameter when the exposure auto function is active. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoExposureTimeLowerLimit; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Upper limit for the ExposureTime parameter when the exposure auto function is active. Applies to: ace, dart, pulse + + Upper limit for the ExposureTime parameter when the exposure auto function is active. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoExposureTimeUpperLimit; + + //@} + + + //! \name AutoFunctionControl - Contains parameters to configure the auto functions. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the backlight compensation. Applies to: dart, pulse + + Sets the backlight compensation that allows the camera to compensate for underexposure. This is done by excluding a given percentage of the brightest pixels in the image from the target average gray value calculations. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IFloat& AutoBacklightCompensation; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets which auto function ROI can be adjusted. Applies to: ace, dart, pulse + + Sets which auto function ROI can be adjusted. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionROISelector; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Width of the auto function ROI (in pixels). Applies to: ace, dart, pulse + + Width of the auto function ROI (in pixels). + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionROISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionROIWidth; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Height of the auto function ROI (in pixels). Applies to: ace, dart, pulse + + Height of the auto function ROI (in pixels). + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionROISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionROIHeight; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Horizontal offset from the left side of the sensor to the auto function ROI (in pixels). Applies to: ace, dart, pulse + + Horizontal offset from the left side of the sensor to the auto function ROI (in pixels). + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionROISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionROIOffsetX; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Vertical offset from the top of the sensor to the auto function ROI (in pixels). Applies to: ace, dart, pulse + + Vertical offset from the top of the sensor to the auto function ROI (in pixels). + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionROISelector + + */ + GENAPI_NAMESPACE::IInteger& AutoFunctionROIOffsetY; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Assigns the Gain Auto and the Exposure Auto functions to the currently selected auto function ROI. Applies to: ace, dart, pulse + + Assigns the Gain Auto and the Exposure Auto functions to the currently selected auto function ROI. For this parameter, Gain Auto and the Exposure Auto are considered as a single "brightness" auto function. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionROISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionROIUseBrightness; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Assigns the Balance White auto function to the currently selected auto function ROI. Applies to: ace, dart, pulse + + Assigns the Balance White auto function to the currently selected auto function ROI. + + \b Visibility = Beginner + + + \b Selected by : AutoFunctionROISelector + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionROIUseWhiteBalance; + + //@} + + + //! \name AutoFunctionROIControl - Contains parameters to configure the auto function ROIs. Applies to: ace, dart, pulse + //@{ + /*! + \brief Assigns the Tonal Range Auto auto function to the currently selected auto function ROI. + + Assigns the Tonal Range Auto auto function to the currently selected auto function ROI. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& AutoFunctionROIUseTonalRange; + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Sets which auto function AOI can be adjusted. + + Sets which auto function AOI can be adjusted. + + \b Visibility = Invisible + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IEnumerationT& AutoFunctionAOISelector; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Width of the auto function AOI (in pixels). + + Width of the auto function AOI (in pixels). + + \b Visibility = Invisible + + \b Selected by : AutoFunctionAOISelector + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIWidth; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Height of the auto function AOI (in pixels). + + Height of the auto function AOI (in pixels). + + \b Visibility = Invisible + + \b Selected by : AutoFunctionAOISelector + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIHeight; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Horizontal offset from the left side of the sensor to the auto function AOI (in pixels). + + Horizontal offset from the left side of the sensor to the auto function AOI (in pixels). + + \b Visibility = Invisible + + \b Selected by : AutoFunctionAOISelector + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIOffsetX; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Vertical offset from the top of the sensor to the auto function AOI (in pixels). + + Vertical offset from the top of the sensor to the auto function AOI (in pixels). + + \b Visibility = Invisible + + \b Selected by : AutoFunctionAOISelector + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IInteger& AutoFunctionAOIOffsetY; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Assigns the Gain Auto and the Exposure Auto functions to the currently selected auto function AOI. + + Assigns the Gain Auto and the Exposure Auto functions to the currently selected auto function AOI. For this parameter, Gain Auto and the Exposure Auto are considered as a single "brightness" auto function. + + \b Visibility = Invisible + + \b Selected by : AutoFunctionAOISelector + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUseBrightness; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoFunctionAOIControl - Contains parameters to configure the auto function AOIs. + //@{ + /*! + \brief This feature has been \b deprecated. Assigns the Balance White auto function to the currently selected auto function AOI. + + Assigns the Balance White auto function to the currently selected auto function AOI. + + \b Visibility = Invisible + + \b Selected by : AutoFunctionAOISelector + + */ + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + + GENAPI_DEPRECATED_FEATURE + GENAPI_NAMESPACE::IBoolean& AutoFunctionAOIUseWhiteBalance; + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + + //@} + + + //! \name AutoTonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoTonalRangeModeSelector; + + //@} + + + //! \name AutoTonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& AutoTonalRangeAdjustmentSelector; + + //@} + + + //! \name AutoTonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoTonalRangeThresholdBright; + + //@} + + + //! \name AutoTonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& AutoTonalRangeThresholdDark; + + //@} + + + //! \name AutoTonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& AutoTonalRangeTargetBright; + + //@} + + + //! \name AutoTonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& AutoTonalRangeTargetDark; + + //@} + + + //! \name LUTControl - Contains parameters to control the operation of the camera's lookup table (LUT). Applies to: ace + //@{ + /*! + \brief Sets the lookup table (LUT) to be configured. Applies to: ace + + Sets the lookup table (LUT) to be configured. Once a LUT has been selected, all changes to the LUT settings will be applied to the selected LUT. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& LUTSelector; + + //@} + + + //! \name LUTControl - Contains parameters to control the operation of the camera's lookup table (LUT). Applies to: ace + //@{ + /*! + \brief Enables the selected lookup table (LUT). Applies to: ace + + Enables the selected lookup table (LUT). + + \b Visibility = Expert + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IBoolean& LUTEnable; + + //@} + + + //! \name LUTControl - Contains parameters to control the operation of the camera's lookup table (LUT). Applies to: ace + //@{ + /*! + \brief Index of the LUT element to access. Applies to: ace + + Index of the LUT element to access. + + \b Visibility = Guru + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IInteger& LUTIndex; + + //@} + + + //! \name LUTControl - Contains parameters to control the operation of the camera's lookup table (LUT). Applies to: ace + //@{ + /*! + \brief Value of the LUT element at the LUT index position. Applies to: ace + + Value of the LUT element at the LUT index position. + + \b Visibility = Guru + + \b Selected by : LUTSelector, LUTIndex + + */ + GENAPI_NAMESPACE::IInteger& LUTValue; + + //@} + + + //! \name LUTControl - Contains parameters to control the operation of the camera's lookup table (LUT). Applies to: ace + //@{ + /*! + \brief A single register that lets you access all LUT coefficients. Applies to: ace + + A single register that lets you access all LUT coefficients without the need to repeatedly use the LUTIndex parameter. + + \b Visibility = Guru + + \b Selected by : LUTSelector + + */ + GENAPI_NAMESPACE::IRegister& LUTValueAll; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Sets the I/O line to be configured. Applies to: ace, dart + + Sets the I/O line to be configured. Once a line has been set, all changes to the line settings will be applied to the selected line. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& LineSelector; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Sets the mode for the selected line. Applies to: ace, dart + + Sets the mode for the selected line. This controls whether the physical line is used to input or output a signal. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineMode; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Returns the electrical configuration of the currently selected line. Applies to: ace, dart + + Returns the electrical configuration of the currently selected line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineFormat; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Returns the line logic of the currently selected line. Applies to: ace + + Returns the line logic of the currently selected line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineLogic; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Sets the source signal for the currently selected line. Applies to: ace, dart + + Sets the source signal for the currently selected line. The currently selected line must be an output line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& LineSource; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Enables the signal inverter function for the currently selected input or output line. Applies to: ace, dart + + Enables the signal inverter function for the currently selected input or output line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineInverter; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Value of the selected line debouncer time in microseconds. Applies to: ace, dart + + Value of the selected line debouncer time in microseconds. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IFloat& LineDebouncerTime; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Value for the minimum signal width of an output signal (in microseconds) . Applies to: ace + + Value for the minimum signal width of an output signal (in microseconds) . + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IFloat& LineMinimumOutputPulseWidth; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Indicates whether an overload condition was detected on the selected line. Applies to: ace + + Indicates whether an overload condition was detected on the selected line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineOverloadStatus; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Resets the overload status of the selected line. Applies to: ace + + This command resets the overload status of the selected line. If the overload condition is still fulfilled, the overload status will be set again immediately. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::ICommand& LineOverloadReset; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Indicates the current logical state of the selected line. Applies to: ace, dart + + Indicates the current logical state of the selected line. + + \b Visibility = Beginner + + + \b Selected by : LineSelector + + */ + GENAPI_NAMESPACE::IBoolean& LineStatus; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief A single bit field indicating the current logical state of all available line signals at time of polling. Applies to: ace, dart + + This integer value is a single bit field that indicates the current logical state of all available lines at time of polling. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& LineStatusAll; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Sets the user settable output signal to be configured. Applies to: ace, dart + + Sets the user settable output signal to be configured. Once a user settable output signal has been set, all changes to the user settable output signal settings will be applied to the selected user settable output signal. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserOutputSelector; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief Enables the selected user settable output line. Applies to: ace, dart + + Enables the selected user settable output line. + + \b Visibility = Beginner + + + \b Selected by : UserOutputSelector + + */ + GENAPI_NAMESPACE::IBoolean& UserOutputValue; + + //@} + + + //! \name DigitalIOControl - Contains parameters to control the operation of the camera's digital I/O lines. Applies to: ace, dart + //@{ + /*! + \brief A single bit field that sets the state of all user settable output signals in one access. Applies to: ace + + A single bit field that sets the state of all user settable output signals in one access. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& UserOutputValueAll; + + //@} + + + //! \name SoftwareSignalControl - Contains parameters to control the software signal that can be used as a trigger signal. Applies to: ace + //@{ + /*! + \brief Sets the software signal to control. Applies to: ace + + Sets the software signal to control. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IEnumerationT& SoftwareSignalSelector; + + //@} + + + //! \name SoftwareSignalControl - Contains parameters to control the software signal that can be used as a trigger signal. Applies to: ace + //@{ + /*! + \brief Generates a signal that can be used as a software trigger. Applies to: ace + + Generates a signal that can be used as a software trigger. + + \b Visibility = Beginner + + \b Selected by : SoftwareSignalSelector + + */ + GENAPI_NAMESPACE::ICommand& SoftwareSignalPulse; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Sets the timer to be configured. Applies to: ace + + Sets the timer to be configured. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerSelector; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Duration of the currently selected timer in microseconds. Applies to: ace + + Duration of the currently selected timer in microseconds. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IFloat& TimerDuration; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Delay of the currently selected timer in microseconds. Applies to: ace + + Delay of the currently selected timer in microseconds. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IFloat& TimerDelay; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Sets the internal camera signal used to trigger the selected timer. Applies to: ace + + Sets the internal camera signal used to trigger the selected timer. + + \b Visibility = Beginner + + + \b Selected by : TimerSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& TimerTriggerSource; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Sets the counter to be configured. Applies to: ace + + Sets the counter to be configured. Once a counter has been set, all changes to the counter settings will be applied to this counter. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterSelector; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Sets the event that increments the currently selected counter. Applies to: ace + + Sets the event that increments the currently selected counter. + + \b Visibility = Beginner + + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterEventSource; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Sets the source signal that can reset the currently selected counter. Applies to: ace + + Sets the source signal that can reset the currently selected counter. + + \b Visibility = Beginner + + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterResetSource; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Sets the signal on which the counter will be reset. Applies to: ace + + Sets the signal on which the counter will be reset. + + \b Visibility = Beginner + + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& CounterResetActivation; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Immediately resets the selected counter. Applies to: ace + + Immediately resets the selected counter. The counter starts counting immediately after the reset. + + \b Visibility = Beginner + + + \b Selected by : CounterSelector + + */ + GENAPI_NAMESPACE::ICommand& CounterReset; + + //@} + + + //! \name CounterAndTimerControl - Contains parameters to control the counters and timers. Applies to: ace + //@{ + /*! + \brief Duration (or number of events) before the CounterEnd event is generated. Applies to: ace + + Duration (or number of events) before the CounterEnd event is generated. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& CounterDuration; + + //@} + + + //! \name UserSetControl - Contains parameters to set up user sets, also known as configuration sets. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the user set or the factory set to load, save or configure. Applies to: ace, dart, pulse + + Sets the user set or the factory set to load, save or configure. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserSetSelector; + + //@} + + + //! \name UserSetControl - Contains parameters to set up user sets, also known as configuration sets. Applies to: ace, dart, pulse + //@{ + /*! + \brief Loads the selected set into the camera's volatile memory and makes it the active configuration set. Applies to: ace, dart, pulse + + Loads the selected set into the camera's volatile memory and makes it the active configuration set. Once the selected set is loaded, the parameters in the selected set will control the camera. + + \b Visibility = Beginner + + + \b Selected by : UserSetSelector + + */ + GENAPI_NAMESPACE::ICommand& UserSetLoad; + + //@} + + + //! \name UserSetControl - Contains parameters to set up user sets, also known as configuration sets. Applies to: ace, dart, pulse + //@{ + /*! + \brief Saves the current active set into the selected user set. Applies to: ace, dart, pulse + + Saves the current active set into the selected user set. + + \b Visibility = Beginner + + + \b Selected by : UserSetSelector + + */ + GENAPI_NAMESPACE::ICommand& UserSetSave; + + //@} + + + //! \name UserSetControl - Contains parameters to set up user sets, also known as configuration sets. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the user set or the factory set to be used as the startup set. Applies to: ace, dart, pulse + + Sets the user set or the factory set to be used as the startup set. The startup set will be loaded as the active set whenever the camera is powered on or reset. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& UserSetDefault; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Enables the chunk mode. Applies to: ace + + Enables the chunk mode. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IBoolean& ChunkModeActive; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Sets the chunk to be enabled. Applies to: ace + + Sets the chunk to be enabled. Once a chunk has been set, the chunk can be enabled using the ChunkEnable parameter. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& ChunkSelector; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Enables the inclusion of the currently selected chunk in the payload data. Applies to: ace + + Enables the inclusion of the currently selected chunk in the payload data. + + \b Visibility = Beginner + + + \b Selected by : ChunkSelector + + */ + GENAPI_NAMESPACE::IBoolean& ChunkEnable; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Sets which gain channel to retrieve chunk data from. Applies to: ace + + Sets which gain channel to retrieve chunk data from. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ChunkGainSelector; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Gain used to acquire the image. Applies to: ace + + Gain used to acquire the image. + + \b Visibility = Beginner + + + \b Selected by : ChunkGainSelector + + */ + GENAPI_NAMESPACE::IFloat& ChunkGain; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Exposure time used to acquire the image. Applies to: ace + + Exposure time used to acquire the image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ChunkExposureTime; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Value of the timestamp when the image was acquired. Applies to: ace + + Value of the timestamp when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkTimestamp; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief A bit field that indicates the status of all of the camera's input and output lines when the image was acquired. Applies to: ace + + A bit field that indicates the status of all of the camera's input and output lines when the image was acquired + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineStatusAll; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Sets which counter to retrieve chunk data from. Applies to: ace + + Sets which counter to retrieve chunk data from. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ChunkCounterSelector; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Value of the selected chunk counter. Applies to: ace + + Value of the selected chunk counter. + + \b Visibility = Beginner + + + \b Selected by : ChunkCounterSelector + + */ + GENAPI_NAMESPACE::IInteger& ChunkCounterValue; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief Index of the active sequencer set. Applies to: ace + + Index of the active sequencer set. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkSequencerSetActive; + + //@} + + + //! \name ChunkDataControl - Contains parameters to configure chunk data that is appended to the image data. Applies to: ace + //@{ + /*! + \brief CRC checksum of the acquired image. Applies to: ace + + CRC checksum of the acquired image. The checksum is calculated using all of the image data and all of the appended chunks except for the checksum itself. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkPayloadCRC16; + + //@} + + + //! \name EventControl - Contains parameters to control events generated by the camera. Applies to: ace + //@{ + /*! + \brief Sets the event notification to be enabled. Applies to: ace + + Sets the event notification to be enabled. Once an event notification has been set, the notification can be enabled using the EventNotification parameter. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& EventSelector; + + //@} + + + //! \name EventControl - Contains parameters to control events generated by the camera. Applies to: ace + //@{ + /*! + \brief Enables event notifications for the currently selected event. Applies to: ace + + Enables event notifications for the currently selected event. The event can selected using the EventSelector parameter. + + \b Visibility = Expert + + \b Selected by : EventSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& EventNotification; + + //@} + + + //! \name EventControl - Contains parameters to control events generated by the camera. Applies to: ace + //@{ + /*! + \brief Generates an event test signal. + + Generates an event test signal. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::ICommand& TriggerEventTest; + + //@} + + + //! \name EventExposureEndData - Contains parameters available for an exposure end event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the exposure end event. Applies to: ace + + Unique identifier of the exposure end event. This parameter can be used to register a callback function to be notified of the event occurrence. Its value uniquely identifies the type of event that will be received. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventExposureEnd; + + //@} + + + //! \name EventExposureEndData - Contains parameters available for an exposure end event. Applies to: ace + //@{ + /*! + \brief Time stamp of the exposure end event. Applies to: ace + + Time stamp of the exposure end event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventExposureEndTimestamp; + + //@} + + + //! \name EventExposureEndData - Contains parameters available for an exposure end event. Applies to: ace + //@{ + /*! + \brief Frame ID of the exposure end event. Applies to: ace + + Frame ID of the exposure end event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventExposureEndFrameID; + + //@} + + + //! \name EventFrameStartData - Contains parameters available for a frame start event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the frame start event. Applies to: ace + + Unique identifier of the frame start event. This feature can be used to register a callback function to be notified of the event occurrence. Its value uniquely identifies the type of event that will be received. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStart; + + //@} + + + //! \name EventFrameStartData - Contains parameters available for a frame start event. Applies to: ace + //@{ + /*! + \brief Time stamp of the frame start event. Applies to: ace + + Time stamp of the frame start event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartTimestamp; + + //@} + + + //! \name EventFrameStartData - Contains parameters available for a frame start event. Applies to: ace + //@{ + /*! + \brief Frame ID of the frame start event. Applies to: ace + + Frame ID of the frame start event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartFrameID; + + //@} + + + //! \name EventFrameBurstStartData - Contains parameters available for a frame burst start event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the frame burst start event. Applies to: ace + + Unique identifier of the frame burst start event. This feature can be used to register a callback function to be notified of the event occurrence. Its value uniquely identifies the type of event that will be received. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStart; + + //@} + + + //! \name EventFrameBurstStartData - Contains parameters available for a frame burst start event. Applies to: ace + //@{ + /*! + \brief Time stamp of the frame burst start event. Applies to: ace + + Time stamp of the frame burst start event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartTimestamp; + + //@} + + + //! \name EventFrameBurstStartData - Contains parameters available for a frame burst start event. Applies to: ace + //@{ + /*! + \brief Frame ID of the frame burst start event. Applies to: ace + + Frame ID of the frame burst start event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartFrameID; + + //@} + + + //! \name EventFrameStartOvertriggerData - Contains parameters available for a frame start overtrigger event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the frame start overtrigger event. Applies to: ace + + Unique identifier of the frame start overtrigger event. This feature can be used to register a callback function to be notified of the event occurrence. Its value uniquely identifies the type of event that will be received. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartOvertrigger; + + //@} + + + //! \name EventFrameStartOvertriggerData - Contains parameters available for a frame start overtrigger event. Applies to: ace + //@{ + /*! + \brief Time stamp of the frame start overtrigger event. Applies to: ace + + Time stamp of the frame start overtrigger event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartOvertriggerTimestamp; + + //@} + + + //! \name EventFrameStartOvertriggerData - Contains parameters available for a frame start overtrigger event. Applies to: ace + //@{ + /*! + \brief Frame ID of the frame start overtrigger event. Applies to: ace + + Frame ID of the frame start overtrigger event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartOvertriggerFrameID; + + //@} + + + //! \name EventFrameBurstStartOvertriggerData - Contains parameters available for a frame burst start overtrigger event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the frame burst start overtrigger event. Applies to: ace + + Unique identifier of the frame burst start overtrigger event. This feature can be used to register a callback function to be notified of the event occurrence. Its value uniquely identifies the type of event that will be received. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartOvertrigger; + + //@} + + + //! \name EventFrameBurstStartOvertriggerData - Contains parameters available for a frame burst start overtrigger event. Applies to: ace + //@{ + /*! + \brief Time stamp of the frame burst start overtrigger event. Applies to: ace + + Time stamp of the frame burst start overtrigger event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartOvertriggerTimestamp; + + //@} + + + //! \name EventFrameBurstStartOvertriggerData - Contains parameters available for a frame burst start overtrigger event. Applies to: ace + //@{ + /*! + \brief Frame ID of the frame burst start overtrigger event. Applies to: ace + + Frame ID of the frame burst start overtrigger event. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartOvertriggerFrameID; + + //@} + + + //! \name EventTestData - Contains parameters available for a test event. + //@{ + /*! + \brief Unique identifier of the test event. + + Unique identifier of the test event. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& EventTest; + + //@} + + + //! \name EventTestData - Contains parameters available for a test event. + //@{ + /*! + \brief Time stamp of the test event. + + Time stamp of the test event. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& EventTestTimestamp; + + //@} + + + //! \name EventCriticalTemperatureData - Contains parameters available for a critical temperature event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the critical temperature event. Applies to: ace + + Unique identifier of the critical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventCriticalTemperature; + + //@} + + + //! \name EventCriticalTemperatureData - Contains parameters available for a critical temperature event. Applies to: ace + //@{ + /*! + \brief Time stamp of the crititical temperature event. Applies to: ace + + Time stamp of the crititical temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventCriticalTemperatureTimestamp; + + //@} + + + //! \name EventOverTemperatureData - Contains parameters available for an over temperature event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the over temperature event. Applies to: ace + + Unique identifier of the over temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventOverTemperature; + + //@} + + + //! \name EventOverTemperatureData - Contains parameters available for an over temperature event. Applies to: ace + //@{ + /*! + \brief Time stamp of the over temperature event. Applies to: ace + + Time stamp of the over temperature event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventOverTemperatureTimestamp; + + //@} + + + //! \name EventFrameStartWaitData - Contains parameters available for a frame start event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the frame start wait event. Applies to: ace + + Unique identifier of the frame start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartWait; + + //@} + + + //! \name EventFrameStartWaitData - Contains parameters available for a frame start event. Applies to: ace + //@{ + /*! + \brief Time stamp of the frame start wait event. Applies to: ace + + Time stamp of the frame start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventFrameStartWaitTimestamp; + + //@} + + + //! \name EventFrameBurstStartWaitData - Contains parameters available for a frame burst start wait event. Applies to: ace + //@{ + /*! + \brief Unique identifier of the frame burst start wait event. Applies to: ace + + Unique identifier of the frame burst start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartWait; + + //@} + + + //! \name EventFrameBurstStartWaitData - Contains parameters available for a frame burst start wait event. Applies to: ace + //@{ + /*! + \brief Time stamp of the frame brust start wait event. Applies to: ace + + Time stamp of the frame brust start wait event. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& EventFrameBurstStartWaitTimestamp; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Size of the payload in bytes. Applies to: ace, dart, pulse + + Size of the payload in bytes. This is the total number of bytes sent in the payload. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& PayloadSize; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Returns the speed mode of the USB port. Applies to: ace, dart, pulse + + Returns the speed mode of the USB port. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IEnumerationT& BslUSBSpeedMode; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Expected size of a single payload transfer. Applies to: ace + + Expected size of a single payload transfer. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& SIPayloadTransferSize; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Expected number of payload transfers. Applies to: ace + + Expected number of payload transfers. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& SIPayloadTransferCount; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Size of the first final payload transfer. Applies to: ace + + Size of the first final payload transfer. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& SIPayloadFinalTransfer1Size; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Size of the second final payload transfer. Applies to: ace + + Size of the second final payload transfer. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& SIPayloadFinalTransfer2Size; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Test pending acknowledging time in milliseconds. Applies to: dart, pulse + + Test pending acknowledging time in milliseconds. On write, the device waits for this time period before acknowledging the write. If the time period is longer than the value in the Maximum Device Response Time register, the device must use PENDING_ACK during the completion of this request. On reads, the device returns the current value without any additional wait time. + + \b Visibility = Invisible + + */ + GENAPI_NAMESPACE::IInteger& TestPendingAck; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief + + This parameter takes effect only when the sequencer mode is set to On. The parameter can only be set when the sequencer configuration mode is set to On. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& PayloadTransferBlockDelay; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Payload Transfer Size. Applies to: dart, pulse + + Payload Transfer Size + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& PayloadTransferSize; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Payload Transfer Count. Applies to: dart, pulse + + Payload Transfer Count + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& PayloadTransferCount; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Payload Final Transfer 1 Size. Applies to: dart, pulse + + Payload Final Transfer 1 Size + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& PayloadFinalTransfer1Size; + + //@} + + + //! \name TransportLayerControl - Contains parameters related to the USB3 Vision transport layer. Applies to: ace, dart, pulse + //@{ + /*! + \brief Payload Final Transfer 2 Size. Applies to: dart, pulse + + Payload Final Transfer 2 Size + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IInteger& PayloadFinalTransfer2Size; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Name of the device's vendor. Applies to: ace, dart, pulse + + Name of the device's vendor. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IString& DeviceVendorName; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Model name of the device. Applies to: ace, dart, pulse + + Model name of the device. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IString& DeviceModelName; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Additional information from the vendor about the camera. Applies to: ace, dart, pulse + + Additional information from the vendor about the camera. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IString& DeviceManufacturerInfo; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Version of the device. Applies to: ace, dart, pulse + + Version of the device. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IString& DeviceVersion; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Version of the device's firmware. Applies to: ace, dart, pulse + + Version of the device's firmware. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IString& DeviceFirmwareVersion; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Serial number of the device. Applies to: ace, dart, pulse + + Serial number of the device. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IString& DeviceSerialNumber; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief User-settable ID of the device. Applies to: ace, dart, pulse + + User-settable ID of the device. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IString& DeviceUserID; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Returns the scan type of the device's sensor (area or line scan). Applies to: ace, dart, pulse + + Returns the scan type of the device's sensor (area or line scan). + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IEnumerationT& DeviceScanType; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Latches the current timestamp counter and stores its value in TimestampLatchValue. Applies to: ace + + Latches the current timestamp counter and stores its value in TimestampLatchValue. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::ICommand& TimestampLatch; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Latched value of the timestamp counter. Applies to: ace + + Latched value of the timestamp counter. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& TimestampLatchValue; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets which link of the device to control. Applies to: ace, dart, pulse + + Sets which link of the device to control. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& DeviceLinkSelector; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Speed of transmission negotiated on the selected link. Applies to: ace, dart, pulse + + Speed of transmission negotiated on the selected link. + + \b Visibility = Expert + + \b Selected by : DeviceLinkSelector + + */ + GENAPI_NAMESPACE::IInteger& DeviceLinkSpeed; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Controls if the device link throughput limit is active. Applies to: ace, dart, pulse + + Controls if the device link throughput limit is active. When disabled, lower level throughput limit specific features are expected to control the throughput. When enabled, the device link throughput limit controls the overall throughput. + + \b Visibility = Beginner + + + \b Selected by : DeviceLinkSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& DeviceLinkThroughputLimitMode; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Value set to limit the maximum bandwidth of the data that will be streamed out by the device (in bytes per second). Applies to: ace, dart, pulse + + Value set to limit the maximum bandwidth of the data that will be streamed out by the device on the currently selected link (in bytes per second). + + \b Visibility = Beginner + + \b Selected by : DeviceLinkSelector + + */ + GENAPI_NAMESPACE::IInteger& DeviceLinkThroughputLimit; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Actual bandwidth the camera will use. Applies to: ace + + Actual bandwidth (in bytes per second) that the camera will use to transmit image data and chunk data given the current camera settings. + + \b Visibility = Expert + + \b Selected by : DeviceLinkSelector + + */ + GENAPI_NAMESPACE::IInteger& DeviceLinkCurrentThroughput; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Sets the location within the device where the temperature will be measured. Applies to: ace + + Sets the location within the device where the temperature will be measured. Once a location has been set, the temperature can be retrieved using the DeviceTemperature parameter. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& DeviceTemperatureSelector; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Temperature of the selected location within the device (in degrees centigrade). Applies to: ace + + Temperature of the selected location within the device (in degrees centigrade). The temperature is measured at the location set by DeviceTemperatureSelector. + + \b Visibility = Expert + + \b Selected by : DeviceTemperatureSelector + + */ + GENAPI_NAMESPACE::IFloat& DeviceTemperature; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Returns the temperature state. Applies to: ace + + Returns the temperature state. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TemperatureState; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Immediately resets and reboots the device. Applies to: ace, dart, pulse + + Immediately resets and reboots the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceReset; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Major version number of the SFNC specification that the device is compatible with. Applies to: ace, dart, pulse + + Major version number of the Standard Features Naming Convention (SFNC) specification that the device is compatible with. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& DeviceSFNCVersionMajor; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Minor version number of the SFNC specification that the device is compatible with. Applies to: ace, dart, pulse + + Minor version number of the Standard Features Naming Convention (SFNC) specification that the device is compatible with. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& DeviceSFNCVersionMinor; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Subminor version number of the SFNC specification that the device is compatible with. Applies to: ace, dart, pulse + + Subminor version number of the Standard Features Naming Convention (SFNC) specification that the device is compatible with. + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& DeviceSFNCVersionSubMinor; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Controls the behavior of the indicators (such as LEDs) showing the status of the device. Applies to: dart + + Controls the behavior of the indicators (such as LEDs) showing the status of the device. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& DeviceIndicatorMode; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Prepare the device for registers streaming without checking for consistency. Applies to: dart, pulse + + Prepare the device for registers streaming without checking for consistency. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceRegistersStreamingStart; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief Announce the end of registers streaming. Applies to: dart, pulse + + Announce the end of registers streaming. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::ICommand& DeviceRegistersStreamingEnd; + + //@} + + + //! \name DeviceControl - Contains parameters to retrieve information about the current device or to configure the current device. Applies to: ace, dart, pulse + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + */ + GENAPI_NAMESPACE::IInteger& DeviceColorPipelineVersion; + + //@} + + + //! \name UserDefinedValueControl - Contains parameters to set and get user defined values. Applies to: ace + //@{ + /*! + \brief Sets the user-defined value to set or read. Applies to: ace + + Sets the user-defined value to set or read. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& UserDefinedValueSelector; + + //@} + + + //! \name UserDefinedValueControl - Contains parameters to set and get user defined values. Applies to: ace + //@{ + /*! + \brief A user defined value. Applies to: ace + + A user defined value. value can serve as storage location for the camera user. It has no impact on the operation of the camera. + + \b Visibility = Guru + + \b Selected by : UserDefinedValueSelector + + */ + GENAPI_NAMESPACE::IInteger& UserDefinedValue; + + //@} + + + //! \name RemoveParameterLimitControl - Contains parameters to remove the limits of camera parameters. Applies to: ace + //@{ + /*! + \brief Sets the parameter whose factory limits should be removed. Applies to: ace + + Sets the parameter whose factory limits should be removed. Once a parameter has been set, the factory limits can be removed using RemoveLimits. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& RemoveParameterLimitSelector; + + //@} + + + //! \name RemoveParameterLimitControl - Contains parameters to remove the limits of camera parameters. Applies to: ace + //@{ + /*! + \brief Removes the factory limit of the selected parameter. Applies to: ace + + Removes the factory limit of the selected parameter. When the factory limit is removed, the parameter can be set within extended limits. range of the extended limit is only dictated by the physical restrictions of the camera, such as the absolute limits of the camera's variable gain control. + + \b Visibility = Guru + + \b Selected by : RemoveParameterLimitSelector + + */ + GENAPI_NAMESPACE::IBoolean& RemoveParameterLimit; + + //@} + + + //! \name ExpertFeatureAccess - Contains parameters that allow access to expert features. Applies to: ace + //@{ + /*! + \brief Sets the expert feature to be configured. Applies to: ace + + Sets the expert feature to be configured. Once a feature has been set, all changes made using the feature enable feature will be applied to this feature. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& ExpertFeatureAccessSelector; + + //@} + + + //! \name ExpertFeatureAccess - Contains parameters that allow access to expert features. Applies to: ace + //@{ + /*! + \brief Key to access the selected expert feature. Applies to: ace + + Key to access the selected expert feature. + + \b Visibility = Guru + + \b Selected by : ExpertFeatureAccessSelector + + */ + GENAPI_NAMESPACE::IInteger& ExpertFeatureAccessKey; + + //@} + + + //! \name ExpertFeatureAccess - Contains parameters that allow access to expert features. Applies to: ace + //@{ + /*! + \brief Enables the currently selected expert feature. Applies to: ace + + Enables the currently selected expert feature. + + \b Visibility = Guru + + \b Selected by : ExpertFeatureAccessSelector + + */ + GENAPI_NAMESPACE::IBoolean& ExpertFeatureEnable; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Sets the target file in the device. Applies to: ace + + Sets the target file in the device. + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IEnumerationT& FileSelector; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Sets the target operation for the currently selected file. Applies to: ace + + Sets the target operation for the currently selected file. After an operation has been selected, the operation can be executed using the FileOperationExecute command. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOperationSelector; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Sets the access mode in which a file is opened in the device. Applies to: ace + + Sets the access mode in which a file is opened in the device. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOpenMode; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Access buffer for file operations. Applies to: ace + + Access buffer for file operations. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IRegister& FileAccessBuffer; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief File access offset. Applies to: ace + + File access offset. Controls the mapping between the device file storage and the FileAccessBuffer. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileAccessOffset; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief File access length. Applies to: ace + + File access length. Controls the mapping between the device file storage and the FileAccessBuffer. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileAccessLength; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Returns the file operation execution status. Applies to: ace + + Returns the file operation execution status. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IEnumerationT& FileOperationStatus; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief File operation result. Applies to: ace + + File operation result. For read or write operations, the number of successfully read/written bytes is returned. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::IInteger& FileOperationResult; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Size of the currently selected file in bytes. Applies to: ace + + Size of the currently selected file in bytes. + + \b Visibility = Guru + + \b Selected by : FileSelector + + */ + GENAPI_NAMESPACE::IInteger& FileSize; + + //@} + + + //! \name FileAccessControl - Contains parameters to perform file operations. Applies to: ace + //@{ + /*! + \brief Executes the operation selected by FileOperationSelector. Applies to: ace + + Executes the operation selected by FileOperationSelector on the selected file. + + \b Visibility = Guru + + \b Selected by : FileSelector, FileOperationSelector + + */ + GENAPI_NAMESPACE::ICommand& FileOperationExecute; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TonalRangeEnable; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IEnumerationT& TonalRangeAuto; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& TonalRangeSelector; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeSourceBright; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeSourceDark; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeTargetBright; + + //@} + + + //! \name TonalRangeControl - + //@{ + /*! + \brief + + + + \b Visibility = Expert + + \b Selected by : TonalRangeSelector + + */ + GENAPI_NAMESPACE::IInteger& TonalRangeTargetDark; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUsbCameraParams_Params( CUsbCameraParams_Params& ); + + //! not implemented assignment operator + CUsbCameraParams_Params& operator=( CUsbCameraParams_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CUsbCameraParams_Params::CUsbCameraParams_Params( void ) + : CameraOperationMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequencerMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequencerSetActive( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequencerConfigurationMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequencerSetStart( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequencerSetSelector( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequencerSetLoad( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequencerSetSave( *new GENAPI_NAMESPACE::CCommandRef() ) + , SequencerPathSelector( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequencerSetNext( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SequencerTriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SequencerTriggerActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SensorWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SensorHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , WidthMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , HeightMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Width( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Height( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , OffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LinePitchEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LinePitch( *new GENAPI_NAMESPACE::CIntegerRef() ) + , CenterX( *new GENAPI_NAMESPACE::CBooleanRef() ) + , CenterY( *new GENAPI_NAMESPACE::CBooleanRef() ) + , BinningHorizontalMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningHorizontal( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BinningVerticalMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BinningVertical( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DecimationHorizontal( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DecimationVertical( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ScalingHorizontal( *new GENAPI_NAMESPACE::CFloatRef() ) + , ScalingVertical( *new GENAPI_NAMESPACE::CFloatRef() ) + , ReverseX( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ReverseY( *new GENAPI_NAMESPACE::CBooleanRef() ) + , PixelFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelSize( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelColorFilter( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PixelDynamicRangeMin( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PixelDynamicRangeMax( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TestImageSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TestImageResetAndHold( *new GENAPI_NAMESPACE::CBooleanRef() ) + , TestPattern( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ROIZoneSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ROIZoneMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ROIZoneSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ROIZoneOffset( *new GENAPI_NAMESPACE::CIntegerRef() ) + , GainAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , GainSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , Gain( *new GENAPI_NAMESPACE::CFloatRef() ) + , BlackLevelSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BlackLevel( *new GENAPI_NAMESPACE::CFloatRef() ) + , Gamma( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorSpace( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DigitalShift( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslColorSpaceMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LightSourcePreset( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceWhiteAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceRatioSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BalanceRatio( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorAdjustmentSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorAdjustmentHue( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorAdjustmentSaturation( *new GENAPI_NAMESPACE::CFloatRef() ) + , ColorTransformationSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorTransformationValueSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ColorTransformationValue( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslContrastMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BslBrightness( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslContrast( *new GENAPI_NAMESPACE::CFloatRef() ) + , DefectPixelCorrectionMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BslHue( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslHueValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslSaturation( *new GENAPI_NAMESPACE::CFloatRef() ) + , BslSaturationValue( *new GENAPI_NAMESPACE::CFloatRef() ) + , DemosaicingMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , PgiMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , NoiseReduction( *new GENAPI_NAMESPACE::CFloatRef() ) + , SharpnessEnhancement( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionStart( *new GENAPI_NAMESPACE::CCommandRef() ) + , AcquisitionStop( *new GENAPI_NAMESPACE::CCommandRef() ) + , ShutterMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureTimeMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , ExposureOverlapTimeMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExposureOverlapTimeMax( *new GENAPI_NAMESPACE::CFloatRef() ) + , SensorReadoutMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionBurstFrameCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TriggerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerSoftware( *new GENAPI_NAMESPACE::CCommandRef() ) + , TriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerDelay( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionFrameRateEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AcquisitionFrameRate( *new GENAPI_NAMESPACE::CFloatRef() ) + , ResultingFrameRate( *new GENAPI_NAMESPACE::CFloatRef() ) + , SensorReadoutTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , AcquisitionStatusSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AcquisitionStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , SensorShutterMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , OverlapMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , BslImmediateTriggerMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTargetBrightness( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoFunctionProfile( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoGainLowerLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoGainUpperLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoExposureTimeLowerLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoExposureTimeUpperLimit( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoBacklightCompensation( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoFunctionROISelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoFunctionROIWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionROIHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionROIOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionROIOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoFunctionROIUseBrightness( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionROIUseWhiteBalance( *new GENAPI_NAMESPACE::CBooleanRef() ) + , AutoFunctionROIUseTonalRange( *new GENAPI_NAMESPACE::CBooleanRef() ) + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOISelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOIWidth( *new GENAPI_NAMESPACE::CIntegerRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOIHeight( *new GENAPI_NAMESPACE::CIntegerRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOIOffsetX( *new GENAPI_NAMESPACE::CIntegerRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOIOffsetY( *new GENAPI_NAMESPACE::CIntegerRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOIUseBrightness( *new GENAPI_NAMESPACE::CBooleanRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + , AutoFunctionAOIUseWhiteBalance( *new GENAPI_NAMESPACE::CBooleanRef() ) + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + , AutoTonalRangeModeSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTonalRangeAdjustmentSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , AutoTonalRangeThresholdBright( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoTonalRangeThresholdDark( *new GENAPI_NAMESPACE::CFloatRef() ) + , AutoTonalRangeTargetBright( *new GENAPI_NAMESPACE::CIntegerRef() ) + , AutoTonalRangeTargetDark( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LUTEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LUTIndex( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , LUTValueAll( *new GENAPI_NAMESPACE::CRegisterRef() ) + , LineSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineFormat( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineLogic( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , LineInverter( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineDebouncerTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineMinimumOutputPulseWidth( *new GENAPI_NAMESPACE::CFloatRef() ) + , LineOverloadStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineOverloadReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , LineStatus( *new GENAPI_NAMESPACE::CBooleanRef() ) + , LineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserOutputSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserOutputValue( *new GENAPI_NAMESPACE::CBooleanRef() ) + , UserOutputValueAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SoftwareSignalSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SoftwareSignalPulse( *new GENAPI_NAMESPACE::CCommandRef() ) + , TimerSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimerDuration( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerDelay( *new GENAPI_NAMESPACE::CFloatRef() ) + , TimerTriggerSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterEventSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterResetSource( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterResetActivation( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , CounterReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , CounterDuration( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserSetSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserSetLoad( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetSave( *new GENAPI_NAMESPACE::CCommandRef() ) + , UserSetDefault( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkModeActive( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ChunkSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ChunkGainSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkGain( *new GENAPI_NAMESPACE::CFloatRef() ) + , ChunkExposureTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , ChunkTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkCounterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkCounterValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkSequencerSetActive( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkPayloadCRC16( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , EventNotification( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TriggerEventTest( *new GENAPI_NAMESPACE::CCommandRef() ) + , EventExposureEnd( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventExposureEndTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventExposureEndFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStart( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStart( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartOvertrigger( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartOvertriggerTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartOvertriggerFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartOvertrigger( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartOvertriggerTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartOvertriggerFrameID( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventTest( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventTestTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventCriticalTemperature( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventCriticalTemperatureTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventOverTemperature( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventOverTemperatureTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartWait( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameStartWaitTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartWait( *new GENAPI_NAMESPACE::CIntegerRef() ) + , EventFrameBurstStartWaitTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PayloadSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , BslUSBSpeedMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , SIPayloadTransferSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SIPayloadTransferCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SIPayloadFinalTransfer1Size( *new GENAPI_NAMESPACE::CIntegerRef() ) + , SIPayloadFinalTransfer2Size( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TestPendingAck( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PayloadTransferBlockDelay( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PayloadTransferSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PayloadTransferCount( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PayloadFinalTransfer1Size( *new GENAPI_NAMESPACE::CIntegerRef() ) + , PayloadFinalTransfer2Size( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceVendorName( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceModelName( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceManufacturerInfo( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceVersion( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceFirmwareVersion( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceSerialNumber( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceUserID( *new GENAPI_NAMESPACE::CStringRef() ) + , DeviceScanType( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TimestampLatch( *new GENAPI_NAMESPACE::CCommandRef() ) + , TimestampLatchValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceLinkSelector( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceLinkSpeed( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceLinkThroughputLimitMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceLinkThroughputLimit( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceLinkCurrentThroughput( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceTemperatureSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceTemperature( *new GENAPI_NAMESPACE::CFloatRef() ) + , TemperatureState( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceReset( *new GENAPI_NAMESPACE::CCommandRef() ) + , DeviceSFNCVersionMajor( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceSFNCVersionMinor( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceSFNCVersionSubMinor( *new GENAPI_NAMESPACE::CIntegerRef() ) + , DeviceIndicatorMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , DeviceRegistersStreamingStart( *new GENAPI_NAMESPACE::CCommandRef() ) + , DeviceRegistersStreamingEnd( *new GENAPI_NAMESPACE::CCommandRef() ) + , DeviceColorPipelineVersion( *new GENAPI_NAMESPACE::CIntegerRef() ) + , UserDefinedValueSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , UserDefinedValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , RemoveParameterLimitSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , RemoveParameterLimit( *new GENAPI_NAMESPACE::CBooleanRef() ) + , ExpertFeatureAccessSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ExpertFeatureAccessKey( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ExpertFeatureEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , FileSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOperationSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOpenMode( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileAccessBuffer( *new GENAPI_NAMESPACE::CRegisterRef() ) + , FileAccessOffset( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileAccessLength( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileOperationStatus( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , FileOperationResult( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileSize( *new GENAPI_NAMESPACE::CIntegerRef() ) + , FileOperationExecute( *new GENAPI_NAMESPACE::CCommandRef() ) + , TonalRangeEnable( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TonalRangeAuto( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TonalRangeSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , TonalRangeSourceBright( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeSourceDark( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeTargetBright( *new GENAPI_NAMESPACE::CIntegerRef() ) + , TonalRangeTargetDark( *new GENAPI_NAMESPACE::CIntegerRef() ) + + { + } + + inline CUsbCameraParams_Params::~CUsbCameraParams_Params( void ) + { + delete static_cast *> (&CameraOperationMode); + delete static_cast *> (&SequencerMode); + delete static_cast (&SequencerSetActive); + delete static_cast *> (&SequencerConfigurationMode); + delete static_cast (&SequencerSetStart); + delete static_cast (&SequencerSetSelector); + delete static_cast (&SequencerSetLoad); + delete static_cast (&SequencerSetSave); + delete static_cast (&SequencerPathSelector); + delete static_cast (&SequencerSetNext); + delete static_cast *> (&SequencerTriggerSource); + delete static_cast *> (&SequencerTriggerActivation); + delete static_cast (&SensorWidth); + delete static_cast (&SensorHeight); + delete static_cast (&WidthMax); + delete static_cast (&HeightMax); + delete static_cast (&Width); + delete static_cast (&Height); + delete static_cast (&OffsetX); + delete static_cast (&OffsetY); + delete static_cast (&LinePitchEnable); + delete static_cast (&LinePitch); + delete static_cast (&CenterX); + delete static_cast (&CenterY); + delete static_cast *> (&BinningHorizontalMode); + delete static_cast (&BinningHorizontal); + delete static_cast *> (&BinningVerticalMode); + delete static_cast (&BinningVertical); + delete static_cast (&DecimationHorizontal); + delete static_cast (&DecimationVertical); + delete static_cast (&ScalingHorizontal); + delete static_cast (&ScalingVertical); + delete static_cast (&ReverseX); + delete static_cast (&ReverseY); + delete static_cast *> (&PixelFormat); + delete static_cast *> (&PixelSize); + delete static_cast *> (&PixelColorFilter); + delete static_cast (&PixelDynamicRangeMin); + delete static_cast (&PixelDynamicRangeMax); + delete static_cast *> (&TestImageSelector); + delete static_cast (&TestImageResetAndHold); + delete static_cast *> (&TestPattern); + delete static_cast *> (&ROIZoneSelector); + delete static_cast *> (&ROIZoneMode); + delete static_cast (&ROIZoneSize); + delete static_cast (&ROIZoneOffset); + delete static_cast *> (&GainAuto); + delete static_cast *> (&GainSelector); + delete static_cast (&Gain); + delete static_cast *> (&BlackLevelSelector); + delete static_cast (&BlackLevel); + delete static_cast (&Gamma); + delete static_cast *> (&ColorSpace); + delete static_cast (&DigitalShift); + delete static_cast *> (&BslColorSpaceMode); + delete static_cast *> (&LightSourcePreset); + delete static_cast *> (&BalanceWhiteAuto); + delete static_cast *> (&BalanceRatioSelector); + delete static_cast (&BalanceRatio); + delete static_cast *> (&ColorAdjustmentSelector); + delete static_cast (&ColorAdjustmentHue); + delete static_cast (&ColorAdjustmentSaturation); + delete static_cast *> (&ColorTransformationSelector); + delete static_cast *> (&ColorTransformationValueSelector); + delete static_cast (&ColorTransformationValue); + delete static_cast *> (&BslContrastMode); + delete static_cast (&BslBrightness); + delete static_cast (&BslContrast); + delete static_cast *> (&DefectPixelCorrectionMode); + delete static_cast (&BslHue); + delete static_cast (&BslHueValue); + delete static_cast (&BslSaturation); + delete static_cast (&BslSaturationValue); + delete static_cast *> (&DemosaicingMode); + delete static_cast *> (&PgiMode); + delete static_cast (&NoiseReduction); + delete static_cast (&SharpnessEnhancement); + delete static_cast *> (&AcquisitionMode); + delete static_cast (&AcquisitionStart); + delete static_cast (&AcquisitionStop); + delete static_cast *> (&ShutterMode); + delete static_cast *> (&ExposureAuto); + delete static_cast *> (&ExposureTimeMode); + delete static_cast *> (&ExposureMode); + delete static_cast (&ExposureTime); + delete static_cast *> (&ExposureOverlapTimeMode); + delete static_cast (&ExposureOverlapTimeMax); + delete static_cast *> (&SensorReadoutMode); + delete static_cast (&AcquisitionBurstFrameCount); + delete static_cast *> (&TriggerSelector); + delete static_cast *> (&TriggerMode); + delete static_cast (&TriggerSoftware); + delete static_cast *> (&TriggerSource); + delete static_cast *> (&TriggerActivation); + delete static_cast (&TriggerDelay); + delete static_cast (&AcquisitionFrameRateEnable); + delete static_cast (&AcquisitionFrameRate); + delete static_cast (&ResultingFrameRate); + delete static_cast (&SensorReadoutTime); + delete static_cast *> (&AcquisitionStatusSelector); + delete static_cast (&AcquisitionStatus); + delete static_cast *> (&SensorShutterMode); + delete static_cast *> (&OverlapMode); + delete static_cast *> (&BslImmediateTriggerMode); + delete static_cast (&AutoTargetBrightness); + delete static_cast *> (&AutoFunctionProfile); + delete static_cast (&AutoGainLowerLimit); + delete static_cast (&AutoGainUpperLimit); + delete static_cast (&AutoExposureTimeLowerLimit); + delete static_cast (&AutoExposureTimeUpperLimit); + delete static_cast (&AutoBacklightCompensation); + delete static_cast *> (&AutoFunctionROISelector); + delete static_cast (&AutoFunctionROIWidth); + delete static_cast (&AutoFunctionROIHeight); + delete static_cast (&AutoFunctionROIOffsetX); + delete static_cast (&AutoFunctionROIOffsetY); + delete static_cast (&AutoFunctionROIUseBrightness); + delete static_cast (&AutoFunctionROIUseWhiteBalance); + delete static_cast (&AutoFunctionROIUseTonalRange); + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast *> (&AutoFunctionAOISelector); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast (&AutoFunctionAOIWidth); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast (&AutoFunctionAOIHeight); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast (&AutoFunctionAOIOffsetX); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast (&AutoFunctionAOIOffsetY); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast (&AutoFunctionAOIUseBrightness); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + delete static_cast (&AutoFunctionAOIUseWhiteBalance); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + delete static_cast *> (&AutoTonalRangeModeSelector); + delete static_cast *> (&AutoTonalRangeAdjustmentSelector); + delete static_cast (&AutoTonalRangeThresholdBright); + delete static_cast (&AutoTonalRangeThresholdDark); + delete static_cast (&AutoTonalRangeTargetBright); + delete static_cast (&AutoTonalRangeTargetDark); + delete static_cast *> (&LUTSelector); + delete static_cast (&LUTEnable); + delete static_cast (&LUTIndex); + delete static_cast (&LUTValue); + delete static_cast (&LUTValueAll); + delete static_cast *> (&LineSelector); + delete static_cast *> (&LineMode); + delete static_cast *> (&LineFormat); + delete static_cast *> (&LineLogic); + delete static_cast *> (&LineSource); + delete static_cast (&LineInverter); + delete static_cast (&LineDebouncerTime); + delete static_cast (&LineMinimumOutputPulseWidth); + delete static_cast (&LineOverloadStatus); + delete static_cast (&LineOverloadReset); + delete static_cast (&LineStatus); + delete static_cast (&LineStatusAll); + delete static_cast *> (&UserOutputSelector); + delete static_cast (&UserOutputValue); + delete static_cast (&UserOutputValueAll); + delete static_cast *> (&SoftwareSignalSelector); + delete static_cast (&SoftwareSignalPulse); + delete static_cast *> (&TimerSelector); + delete static_cast (&TimerDuration); + delete static_cast (&TimerDelay); + delete static_cast *> (&TimerTriggerSource); + delete static_cast *> (&CounterSelector); + delete static_cast *> (&CounterEventSource); + delete static_cast *> (&CounterResetSource); + delete static_cast *> (&CounterResetActivation); + delete static_cast (&CounterReset); + delete static_cast (&CounterDuration); + delete static_cast *> (&UserSetSelector); + delete static_cast (&UserSetLoad); + delete static_cast (&UserSetSave); + delete static_cast *> (&UserSetDefault); + delete static_cast (&ChunkModeActive); + delete static_cast *> (&ChunkSelector); + delete static_cast (&ChunkEnable); + delete static_cast *> (&ChunkGainSelector); + delete static_cast (&ChunkGain); + delete static_cast (&ChunkExposureTime); + delete static_cast (&ChunkTimestamp); + delete static_cast (&ChunkLineStatusAll); + delete static_cast *> (&ChunkCounterSelector); + delete static_cast (&ChunkCounterValue); + delete static_cast (&ChunkSequencerSetActive); + delete static_cast (&ChunkPayloadCRC16); + delete static_cast *> (&EventSelector); + delete static_cast *> (&EventNotification); + delete static_cast (&TriggerEventTest); + delete static_cast (&EventExposureEnd); + delete static_cast (&EventExposureEndTimestamp); + delete static_cast (&EventExposureEndFrameID); + delete static_cast (&EventFrameStart); + delete static_cast (&EventFrameStartTimestamp); + delete static_cast (&EventFrameStartFrameID); + delete static_cast (&EventFrameBurstStart); + delete static_cast (&EventFrameBurstStartTimestamp); + delete static_cast (&EventFrameBurstStartFrameID); + delete static_cast (&EventFrameStartOvertrigger); + delete static_cast (&EventFrameStartOvertriggerTimestamp); + delete static_cast (&EventFrameStartOvertriggerFrameID); + delete static_cast (&EventFrameBurstStartOvertrigger); + delete static_cast (&EventFrameBurstStartOvertriggerTimestamp); + delete static_cast (&EventFrameBurstStartOvertriggerFrameID); + delete static_cast (&EventTest); + delete static_cast (&EventTestTimestamp); + delete static_cast (&EventCriticalTemperature); + delete static_cast (&EventCriticalTemperatureTimestamp); + delete static_cast (&EventOverTemperature); + delete static_cast (&EventOverTemperatureTimestamp); + delete static_cast (&EventFrameStartWait); + delete static_cast (&EventFrameStartWaitTimestamp); + delete static_cast (&EventFrameBurstStartWait); + delete static_cast (&EventFrameBurstStartWaitTimestamp); + delete static_cast (&PayloadSize); + delete static_cast *> (&BslUSBSpeedMode); + delete static_cast (&SIPayloadTransferSize); + delete static_cast (&SIPayloadTransferCount); + delete static_cast (&SIPayloadFinalTransfer1Size); + delete static_cast (&SIPayloadFinalTransfer2Size); + delete static_cast (&TestPendingAck); + delete static_cast (&PayloadTransferBlockDelay); + delete static_cast (&PayloadTransferSize); + delete static_cast (&PayloadTransferCount); + delete static_cast (&PayloadFinalTransfer1Size); + delete static_cast (&PayloadFinalTransfer2Size); + delete static_cast (&DeviceVendorName); + delete static_cast (&DeviceModelName); + delete static_cast (&DeviceManufacturerInfo); + delete static_cast (&DeviceVersion); + delete static_cast (&DeviceFirmwareVersion); + delete static_cast (&DeviceSerialNumber); + delete static_cast (&DeviceUserID); + delete static_cast *> (&DeviceScanType); + delete static_cast (&TimestampLatch); + delete static_cast (&TimestampLatchValue); + delete static_cast (&DeviceLinkSelector); + delete static_cast (&DeviceLinkSpeed); + delete static_cast *> (&DeviceLinkThroughputLimitMode); + delete static_cast (&DeviceLinkThroughputLimit); + delete static_cast (&DeviceLinkCurrentThroughput); + delete static_cast *> (&DeviceTemperatureSelector); + delete static_cast (&DeviceTemperature); + delete static_cast *> (&TemperatureState); + delete static_cast (&DeviceReset); + delete static_cast (&DeviceSFNCVersionMajor); + delete static_cast (&DeviceSFNCVersionMinor); + delete static_cast (&DeviceSFNCVersionSubMinor); + delete static_cast *> (&DeviceIndicatorMode); + delete static_cast (&DeviceRegistersStreamingStart); + delete static_cast (&DeviceRegistersStreamingEnd); + delete static_cast (&DeviceColorPipelineVersion); + delete static_cast *> (&UserDefinedValueSelector); + delete static_cast (&UserDefinedValue); + delete static_cast *> (&RemoveParameterLimitSelector); + delete static_cast (&RemoveParameterLimit); + delete static_cast *> (&ExpertFeatureAccessSelector); + delete static_cast (&ExpertFeatureAccessKey); + delete static_cast (&ExpertFeatureEnable); + delete static_cast *> (&FileSelector); + delete static_cast *> (&FileOperationSelector); + delete static_cast *> (&FileOpenMode); + delete static_cast (&FileAccessBuffer); + delete static_cast (&FileAccessOffset); + delete static_cast (&FileAccessLength); + delete static_cast *> (&FileOperationStatus); + delete static_cast (&FileOperationResult); + delete static_cast (&FileSize); + delete static_cast (&FileOperationExecute); + delete static_cast *> (&TonalRangeEnable); + delete static_cast *> (&TonalRangeAuto); + delete static_cast *> (&TonalRangeSelector); + delete static_cast (&TonalRangeSourceBright); + delete static_cast (&TonalRangeSourceDark); + delete static_cast (&TonalRangeTargetBright); + delete static_cast (&TonalRangeTargetDark); + + } + + inline void CUsbCameraParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast*> (&CameraOperationMode)->SetReference( _Ptr->GetNode( "CameraOperationMode" ) ); + static_cast*> (&CameraOperationMode)->SetNumEnums( 2 ); + static_cast*> (&CameraOperationMode)->SetEnumReference( CameraOperationMode_Standard, "Standard" ); static_cast*> (&CameraOperationMode)->SetEnumReference( CameraOperationMode_LongExposure, "LongExposure" ); static_cast*> (&SequencerMode)->SetReference( _Ptr->GetNode( "SequencerMode" ) ); + static_cast*> (&SequencerMode)->SetNumEnums( 2 ); + static_cast*> (&SequencerMode)->SetEnumReference( SequencerMode_Off, "Off" ); static_cast*> (&SequencerMode)->SetEnumReference( SequencerMode_On, "On" ); static_cast (&SequencerSetActive)->SetReference( _Ptr->GetNode( "SequencerSetActive" ) ); + static_cast*> (&SequencerConfigurationMode)->SetReference( _Ptr->GetNode( "SequencerConfigurationMode" ) ); + static_cast*> (&SequencerConfigurationMode)->SetNumEnums( 2 ); + static_cast*> (&SequencerConfigurationMode)->SetEnumReference( SequencerConfigurationMode_Off, "Off" ); static_cast*> (&SequencerConfigurationMode)->SetEnumReference( SequencerConfigurationMode_On, "On" ); static_cast (&SequencerSetStart)->SetReference( _Ptr->GetNode( "SequencerSetStart" ) ); + static_cast (&SequencerSetSelector)->SetReference( _Ptr->GetNode( "SequencerSetSelector" ) ); + static_cast (&SequencerSetLoad)->SetReference( _Ptr->GetNode( "SequencerSetLoad" ) ); + static_cast (&SequencerSetSave)->SetReference( _Ptr->GetNode( "SequencerSetSave" ) ); + static_cast (&SequencerPathSelector)->SetReference( _Ptr->GetNode( "SequencerPathSelector" ) ); + static_cast (&SequencerSetNext)->SetReference( _Ptr->GetNode( "SequencerSetNext" ) ); + static_cast*> (&SequencerTriggerSource)->SetReference( _Ptr->GetNode( "SequencerTriggerSource" ) ); + static_cast*> (&SequencerTriggerSource)->SetNumEnums( 12 ); + static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Line1, "Line1" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Line2, "Line2" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Line3, "Line3" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Line4, "Line4" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_SoftwareSignal1, "SoftwareSignal1" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_SoftwareSignal2, "SoftwareSignal2" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_SoftwareSignal3, "SoftwareSignal3" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Counter1End, "Counter1End" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Counter2End, "Counter2End" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_Counter3End, "Counter3End" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_FrameStart, "FrameStart" ); static_cast*> (&SequencerTriggerSource)->SetEnumReference( SequencerTriggerSource_FrameEnd, "FrameEnd" ); static_cast*> (&SequencerTriggerActivation)->SetReference( _Ptr->GetNode( "SequencerTriggerActivation" ) ); + static_cast*> (&SequencerTriggerActivation)->SetNumEnums( 5 ); + static_cast*> (&SequencerTriggerActivation)->SetEnumReference( SequencerTriggerActivation_RisingEdge, "RisingEdge" ); static_cast*> (&SequencerTriggerActivation)->SetEnumReference( SequencerTriggerActivation_FallingEdge, "FallingEdge" ); static_cast*> (&SequencerTriggerActivation)->SetEnumReference( SequencerTriggerActivation_AnyEdge, "AnyEdge" ); static_cast*> (&SequencerTriggerActivation)->SetEnumReference( SequencerTriggerActivation_LevelHigh, "LevelHigh" ); static_cast*> (&SequencerTriggerActivation)->SetEnumReference( SequencerTriggerActivation_LevelLow, "LevelLow" ); static_cast (&SensorWidth)->SetReference( _Ptr->GetNode( "SensorWidth" ) ); + static_cast (&SensorHeight)->SetReference( _Ptr->GetNode( "SensorHeight" ) ); + static_cast (&WidthMax)->SetReference( _Ptr->GetNode( "WidthMax" ) ); + static_cast (&HeightMax)->SetReference( _Ptr->GetNode( "HeightMax" ) ); + static_cast (&Width)->SetReference( _Ptr->GetNode( "Width" ) ); + static_cast (&Height)->SetReference( _Ptr->GetNode( "Height" ) ); + static_cast (&OffsetX)->SetReference( _Ptr->GetNode( "OffsetX" ) ); + static_cast (&OffsetY)->SetReference( _Ptr->GetNode( "OffsetY" ) ); + static_cast (&LinePitchEnable)->SetReference( _Ptr->GetNode( "LinePitchEnable" ) ); + static_cast (&LinePitch)->SetReference( _Ptr->GetNode( "LinePitch" ) ); + static_cast (&CenterX)->SetReference( _Ptr->GetNode( "CenterX" ) ); + static_cast (&CenterY)->SetReference( _Ptr->GetNode( "CenterY" ) ); + static_cast*> (&BinningHorizontalMode)->SetReference( _Ptr->GetNode( "BinningHorizontalMode" ) ); + static_cast*> (&BinningHorizontalMode)->SetNumEnums( 2 ); + static_cast*> (&BinningHorizontalMode)->SetEnumReference( BinningHorizontalMode_Sum, "Sum" ); static_cast*> (&BinningHorizontalMode)->SetEnumReference( BinningHorizontalMode_Average, "Average" ); static_cast (&BinningHorizontal)->SetReference( _Ptr->GetNode( "BinningHorizontal" ) ); + static_cast*> (&BinningVerticalMode)->SetReference( _Ptr->GetNode( "BinningVerticalMode" ) ); + static_cast*> (&BinningVerticalMode)->SetNumEnums( 2 ); + static_cast*> (&BinningVerticalMode)->SetEnumReference( BinningVerticalMode_Sum, "Sum" ); static_cast*> (&BinningVerticalMode)->SetEnumReference( BinningVerticalMode_Average, "Average" ); static_cast (&BinningVertical)->SetReference( _Ptr->GetNode( "BinningVertical" ) ); + static_cast (&DecimationHorizontal)->SetReference( _Ptr->GetNode( "DecimationHorizontal" ) ); + static_cast (&DecimationVertical)->SetReference( _Ptr->GetNode( "DecimationVertical" ) ); + static_cast (&ScalingHorizontal)->SetReference( _Ptr->GetNode( "ScalingHorizontal" ) ); + static_cast (&ScalingVertical)->SetReference( _Ptr->GetNode( "ScalingVertical" ) ); + static_cast (&ReverseX)->SetReference( _Ptr->GetNode( "ReverseX" ) ); + static_cast (&ReverseY)->SetReference( _Ptr->GetNode( "ReverseY" ) ); + static_cast*> (&PixelFormat)->SetReference( _Ptr->GetNode( "PixelFormat" ) ); + static_cast*> (&PixelFormat)->SetNumEnums( 28 ); + static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono8, "Mono8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10, "Mono10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono10p, "Mono10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono12, "Mono12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_Mono12p, "Mono12p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR8, "BayerGR8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG8, "BayerRG8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB8, "BayerGB8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG8, "BayerBG8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR10, "BayerGR10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR10p, "BayerGR10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG10, "BayerRG10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG10p, "BayerRG10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB10, "BayerGB10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB10p, "BayerGB10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG10, "BayerBG10" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG10p, "BayerBG10p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR12, "BayerGR12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGR12p, "BayerGR12p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG12, "BayerRG12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerRG12p, "BayerRG12p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB12, "BayerGB12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerGB12p, "BayerGB12p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG12, "BayerBG12" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BayerBG12p, "BayerBG12p" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_RGB8, "RGB8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_BGR8, "BGR8" ); static_cast*> (&PixelFormat)->SetEnumReference( PixelFormat_YCbCr422_8, "YCbCr422_8" ); static_cast*> (&PixelSize)->SetReference( _Ptr->GetNode( "PixelSize" ) ); + static_cast*> (&PixelSize)->SetNumEnums( 8 ); + static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp1, "Bpp1" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp2, "Bpp2" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp4, "Bpp4" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp8, "Bpp8" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp10, "Bpp10" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp12, "Bpp12" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp16, "Bpp16" ); static_cast*> (&PixelSize)->SetEnumReference( PixelSize_Bpp24, "Bpp24" ); static_cast*> (&PixelColorFilter)->SetReference( _Ptr->GetNode( "PixelColorFilter" ) ); + static_cast*> (&PixelColorFilter)->SetNumEnums( 5 ); + static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_None, "None" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_BayerRG, "BayerRG" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_BayerGB, "BayerGB" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_BayerGR, "BayerGR" ); static_cast*> (&PixelColorFilter)->SetEnumReference( PixelColorFilter_BayerBG, "BayerBG" ); static_cast (&PixelDynamicRangeMin)->SetReference( _Ptr->GetNode( "PixelDynamicRangeMin" ) ); + static_cast (&PixelDynamicRangeMax)->SetReference( _Ptr->GetNode( "PixelDynamicRangeMax" ) ); + static_cast*> (&TestImageSelector)->SetReference( _Ptr->GetNode( "TestImageSelector" ) ); + static_cast*> (&TestImageSelector)->SetNumEnums( 7 ); + static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Off, "Off" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage1, "Testimage1" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage2, "Testimage2" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage3, "Testimage3" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage4, "Testimage4" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage5, "Testimage5" ); static_cast*> (&TestImageSelector)->SetEnumReference( TestImageSelector_Testimage6, "Testimage6" ); static_cast (&TestImageResetAndHold)->SetReference( _Ptr->GetNode( "TestImageResetAndHold" ) ); + static_cast*> (&TestPattern)->SetReference( _Ptr->GetNode( "TestPattern" ) ); + static_cast*> (&TestPattern)->SetNumEnums( 3 ); + static_cast*> (&TestPattern)->SetEnumReference( TestPattern_Off, "Off" ); static_cast*> (&TestPattern)->SetEnumReference( TestPattern_GreyDiagonalSawtooth8, "GreyDiagonalSawtooth8" ); static_cast*> (&TestPattern)->SetEnumReference( TestPattern_ColorDiagonalSawtooth8, "ColorDiagonalSawtooth8" ); static_cast*> (&ROIZoneSelector)->SetReference( _Ptr->GetNode( "ROIZoneSelector" ) ); + static_cast*> (&ROIZoneSelector)->SetNumEnums( 8 ); + static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone0, "Zone0" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone1, "Zone1" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone2, "Zone2" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone3, "Zone3" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone4, "Zone4" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone5, "Zone5" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone6, "Zone6" ); static_cast*> (&ROIZoneSelector)->SetEnumReference( ROIZoneSelector_Zone7, "Zone7" ); static_cast*> (&ROIZoneMode)->SetReference( _Ptr->GetNode( "ROIZoneMode" ) ); + static_cast*> (&ROIZoneMode)->SetNumEnums( 2 ); + static_cast*> (&ROIZoneMode)->SetEnumReference( ROIZoneMode_Off, "Off" ); static_cast*> (&ROIZoneMode)->SetEnumReference( ROIZoneMode_On, "On" ); static_cast (&ROIZoneSize)->SetReference( _Ptr->GetNode( "ROIZoneSize" ) ); + static_cast (&ROIZoneOffset)->SetReference( _Ptr->GetNode( "ROIZoneOffset" ) ); + static_cast*> (&GainAuto)->SetReference( _Ptr->GetNode( "GainAuto" ) ); + static_cast*> (&GainAuto)->SetNumEnums( 3 ); + static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Off, "Off" ); static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Once, "Once" ); static_cast*> (&GainAuto)->SetEnumReference( GainAuto_Continuous, "Continuous" ); static_cast*> (&GainSelector)->SetReference( _Ptr->GetNode( "GainSelector" ) ); + static_cast*> (&GainSelector)->SetNumEnums( 3 ); + static_cast*> (&GainSelector)->SetEnumReference( GainSelector_All, "All" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_DigitalAll, "DigitalAll" ); static_cast*> (&GainSelector)->SetEnumReference( GainSelector_AnalogAll, "AnalogAll" ); static_cast (&Gain)->SetReference( _Ptr->GetNode( "Gain" ) ); + static_cast*> (&BlackLevelSelector)->SetReference( _Ptr->GetNode( "BlackLevelSelector" ) ); + static_cast*> (&BlackLevelSelector)->SetNumEnums( 1 ); + static_cast*> (&BlackLevelSelector)->SetEnumReference( BlackLevelSelector_All, "All" ); static_cast (&BlackLevel)->SetReference( _Ptr->GetNode( "BlackLevel" ) ); + static_cast (&Gamma)->SetReference( _Ptr->GetNode( "Gamma" ) ); + static_cast*> (&ColorSpace)->SetReference( _Ptr->GetNode( "ColorSpace" ) ); + static_cast*> (&ColorSpace)->SetNumEnums( 2 ); + static_cast*> (&ColorSpace)->SetEnumReference( ColorSpace_RGB, "RGB" ); static_cast*> (&ColorSpace)->SetEnumReference( ColorSpace_sRGB, "sRGB" ); static_cast (&DigitalShift)->SetReference( _Ptr->GetNode( "DigitalShift" ) ); + static_cast*> (&BslColorSpaceMode)->SetReference( _Ptr->GetNode( "BslColorSpaceMode" ) ); + static_cast*> (&BslColorSpaceMode)->SetNumEnums( 2 ); + static_cast*> (&BslColorSpaceMode)->SetEnumReference( BslColorSpaceMode_RGB, "RGB" ); static_cast*> (&BslColorSpaceMode)->SetEnumReference( BslColorSpaceMode_sRGB, "sRGB" ); static_cast*> (&LightSourcePreset)->SetReference( _Ptr->GetNode( "LightSourcePreset" ) ); + static_cast*> (&LightSourcePreset)->SetNumEnums( 7 ); + static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_Off, "Off" ); static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_Daylight5000K, "Daylight5000K" ); static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_Daylight6500K, "Daylight6500K" ); static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_Tungsten2800K, "Tungsten2800K" ); static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_MicroscopeLED4500K, "MicroscopeLED4500K" ); static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_MicroscopeLED5500K, "MicroscopeLED5500K" ); static_cast*> (&LightSourcePreset)->SetEnumReference( LightSourcePreset_MicroscopeLED6000K, "MicroscopeLED6000K" ); static_cast*> (&BalanceWhiteAuto)->SetReference( _Ptr->GetNode( "BalanceWhiteAuto" ) ); + static_cast*> (&BalanceWhiteAuto)->SetNumEnums( 3 ); + static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Off, "Off" ); static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Once, "Once" ); static_cast*> (&BalanceWhiteAuto)->SetEnumReference( BalanceWhiteAuto_Continuous, "Continuous" ); static_cast*> (&BalanceRatioSelector)->SetReference( _Ptr->GetNode( "BalanceRatioSelector" ) ); + static_cast*> (&BalanceRatioSelector)->SetNumEnums( 3 ); + static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Red, "Red" ); static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Green, "Green" ); static_cast*> (&BalanceRatioSelector)->SetEnumReference( BalanceRatioSelector_Blue, "Blue" ); static_cast (&BalanceRatio)->SetReference( _Ptr->GetNode( "BalanceRatio" ) ); + static_cast*> (&ColorAdjustmentSelector)->SetReference( _Ptr->GetNode( "ColorAdjustmentSelector" ) ); + static_cast*> (&ColorAdjustmentSelector)->SetNumEnums( 6 ); + static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Red, "Red" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Yellow, "Yellow" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Green, "Green" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Cyan, "Cyan" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Blue, "Blue" ); static_cast*> (&ColorAdjustmentSelector)->SetEnumReference( ColorAdjustmentSelector_Magenta, "Magenta" ); static_cast (&ColorAdjustmentHue)->SetReference( _Ptr->GetNode( "ColorAdjustmentHue" ) ); + static_cast (&ColorAdjustmentSaturation)->SetReference( _Ptr->GetNode( "ColorAdjustmentSaturation" ) ); + static_cast*> (&ColorTransformationSelector)->SetReference( _Ptr->GetNode( "ColorTransformationSelector" ) ); + static_cast*> (&ColorTransformationSelector)->SetNumEnums( 3 ); + static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_RGBtoRGB, "RGBtoRGB" ); static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_RGBtoYUV, "RGBtoYUV" ); static_cast*> (&ColorTransformationSelector)->SetEnumReference( ColorTransformationSelector_YUVtoRGB, "YUVtoRGB" ); static_cast*> (&ColorTransformationValueSelector)->SetReference( _Ptr->GetNode( "ColorTransformationValueSelector" ) ); + static_cast*> (&ColorTransformationValueSelector)->SetNumEnums( 9 ); + static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain00, "Gain00" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain01, "Gain01" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain02, "Gain02" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain10, "Gain10" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain11, "Gain11" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain12, "Gain12" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain20, "Gain20" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain21, "Gain21" ); static_cast*> (&ColorTransformationValueSelector)->SetEnumReference( ColorTransformationValueSelector_Gain22, "Gain22" ); static_cast (&ColorTransformationValue)->SetReference( _Ptr->GetNode( "ColorTransformationValue" ) ); + static_cast*> (&BslContrastMode)->SetReference( _Ptr->GetNode( "BslContrastMode" ) ); + static_cast*> (&BslContrastMode)->SetNumEnums( 2 ); + static_cast*> (&BslContrastMode)->SetEnumReference( BslContrastMode_Linear, "Linear" ); static_cast*> (&BslContrastMode)->SetEnumReference( BslContrastMode_SCurve, "SCurve" ); static_cast (&BslBrightness)->SetReference( _Ptr->GetNode( "BslBrightness" ) ); + static_cast (&BslContrast)->SetReference( _Ptr->GetNode( "BslContrast" ) ); + static_cast*> (&DefectPixelCorrectionMode)->SetReference( _Ptr->GetNode( "DefectPixelCorrectionMode" ) ); + static_cast*> (&DefectPixelCorrectionMode)->SetNumEnums( 3 ); + static_cast*> (&DefectPixelCorrectionMode)->SetEnumReference( DefectPixelCorrectionMode_Off, "Off" ); static_cast*> (&DefectPixelCorrectionMode)->SetEnumReference( DefectPixelCorrectionMode_On, "On" ); static_cast*> (&DefectPixelCorrectionMode)->SetEnumReference( DefectPixelCorrectionMode_StaticOnly, "StaticOnly" ); static_cast (&BslHue)->SetReference( _Ptr->GetNode( "BslHue" ) ); + static_cast (&BslHueValue)->SetReference( _Ptr->GetNode( "BslHueValue" ) ); + static_cast (&BslSaturation)->SetReference( _Ptr->GetNode( "BslSaturation" ) ); + static_cast (&BslSaturationValue)->SetReference( _Ptr->GetNode( "BslSaturationValue" ) ); + static_cast*> (&DemosaicingMode)->SetReference( _Ptr->GetNode( "DemosaicingMode" ) ); + static_cast*> (&DemosaicingMode)->SetNumEnums( 2 ); + static_cast*> (&DemosaicingMode)->SetEnumReference( DemosaicingMode_Simple, "Simple" ); static_cast*> (&DemosaicingMode)->SetEnumReference( DemosaicingMode_BaslerPGI, "BaslerPGI" ); static_cast*> (&PgiMode)->SetReference( _Ptr->GetNode( "PgiMode" ) ); + static_cast*> (&PgiMode)->SetNumEnums( 2 ); + static_cast*> (&PgiMode)->SetEnumReference( PgiMode_Off, "Off" ); static_cast*> (&PgiMode)->SetEnumReference( PgiMode_On, "On" ); static_cast (&NoiseReduction)->SetReference( _Ptr->GetNode( "NoiseReduction" ) ); + static_cast (&SharpnessEnhancement)->SetReference( _Ptr->GetNode( "SharpnessEnhancement" ) ); + static_cast*> (&AcquisitionMode)->SetReference( _Ptr->GetNode( "AcquisitionMode" ) ); + static_cast*> (&AcquisitionMode)->SetNumEnums( 2 ); + static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_SingleFrame, "SingleFrame" ); static_cast*> (&AcquisitionMode)->SetEnumReference( AcquisitionMode_Continuous, "Continuous" ); static_cast (&AcquisitionStart)->SetReference( _Ptr->GetNode( "AcquisitionStart" ) ); + static_cast (&AcquisitionStop)->SetReference( _Ptr->GetNode( "AcquisitionStop" ) ); + static_cast*> (&ShutterMode)->SetReference( _Ptr->GetNode( "ShutterMode" ) ); + static_cast*> (&ShutterMode)->SetNumEnums( 3 ); + static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_Global, "Global" ); static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_Rolling, "Rolling" ); static_cast*> (&ShutterMode)->SetEnumReference( ShutterMode_GlobalResetRelease, "GlobalResetRelease" ); static_cast*> (&ExposureAuto)->SetReference( _Ptr->GetNode( "ExposureAuto" ) ); + static_cast*> (&ExposureAuto)->SetNumEnums( 3 ); + static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Off, "Off" ); static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Once, "Once" ); static_cast*> (&ExposureAuto)->SetEnumReference( ExposureAuto_Continuous, "Continuous" ); static_cast*> (&ExposureTimeMode)->SetReference( _Ptr->GetNode( "ExposureTimeMode" ) ); + static_cast*> (&ExposureTimeMode)->SetNumEnums( 2 ); + static_cast*> (&ExposureTimeMode)->SetEnumReference( ExposureTimeMode_Standard, "Standard" ); static_cast*> (&ExposureTimeMode)->SetEnumReference( ExposureTimeMode_UltraShort, "UltraShort" ); static_cast*> (&ExposureMode)->SetReference( _Ptr->GetNode( "ExposureMode" ) ); + static_cast*> (&ExposureMode)->SetNumEnums( 2 ); + static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_Timed, "Timed" ); static_cast*> (&ExposureMode)->SetEnumReference( ExposureMode_TriggerWidth, "TriggerWidth" ); static_cast (&ExposureTime)->SetReference( _Ptr->GetNode( "ExposureTime" ) ); + static_cast*> (&ExposureOverlapTimeMode)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMode" ) ); + static_cast*> (&ExposureOverlapTimeMode)->SetNumEnums( 2 ); + static_cast*> (&ExposureOverlapTimeMode)->SetEnumReference( ExposureOverlapTimeMode_Manual, "Manual" ); static_cast*> (&ExposureOverlapTimeMode)->SetEnumReference( ExposureOverlapTimeMode_Automatic, "Automatic" ); static_cast (&ExposureOverlapTimeMax)->SetReference( _Ptr->GetNode( "ExposureOverlapTimeMax" ) ); + static_cast*> (&SensorReadoutMode)->SetReference( _Ptr->GetNode( "SensorReadoutMode" ) ); + static_cast*> (&SensorReadoutMode)->SetNumEnums( 2 ); + static_cast*> (&SensorReadoutMode)->SetEnumReference( SensorReadoutMode_Normal, "Normal" ); static_cast*> (&SensorReadoutMode)->SetEnumReference( SensorReadoutMode_Fast, "Fast" ); static_cast (&AcquisitionBurstFrameCount)->SetReference( _Ptr->GetNode( "AcquisitionBurstFrameCount" ) ); + static_cast*> (&TriggerSelector)->SetReference( _Ptr->GetNode( "TriggerSelector" ) ); + static_cast*> (&TriggerSelector)->SetNumEnums( 2 ); + static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameBurstStart, "FrameBurstStart" ); static_cast*> (&TriggerSelector)->SetEnumReference( TriggerSelector_FrameStart, "FrameStart" ); static_cast*> (&TriggerMode)->SetReference( _Ptr->GetNode( "TriggerMode" ) ); + static_cast*> (&TriggerMode)->SetNumEnums( 2 ); + static_cast*> (&TriggerMode)->SetEnumReference( TriggerMode_Off, "Off" ); static_cast*> (&TriggerMode)->SetEnumReference( TriggerMode_On, "On" ); static_cast (&TriggerSoftware)->SetReference( _Ptr->GetNode( "TriggerSoftware" ) ); + static_cast*> (&TriggerSource)->SetReference( _Ptr->GetNode( "TriggerSource" ) ); + static_cast*> (&TriggerSource)->SetNumEnums( 8 ); + static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Software, "Software" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line1, "Line1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line2, "Line2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line3, "Line3" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_Line4, "Line4" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_SoftwareSignal1, "SoftwareSignal1" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_SoftwareSignal2, "SoftwareSignal2" ); static_cast*> (&TriggerSource)->SetEnumReference( TriggerSource_SoftwareSignal3, "SoftwareSignal3" ); static_cast*> (&TriggerActivation)->SetReference( _Ptr->GetNode( "TriggerActivation" ) ); + static_cast*> (&TriggerActivation)->SetNumEnums( 5 ); + static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_RisingEdge, "RisingEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_FallingEdge, "FallingEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_AnyEdge, "AnyEdge" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_LevelHigh, "LevelHigh" ); static_cast*> (&TriggerActivation)->SetEnumReference( TriggerActivation_LevelLow, "LevelLow" ); static_cast (&TriggerDelay)->SetReference( _Ptr->GetNode( "TriggerDelay" ) ); + static_cast (&AcquisitionFrameRateEnable)->SetReference( _Ptr->GetNode( "AcquisitionFrameRateEnable" ) ); + static_cast (&AcquisitionFrameRate)->SetReference( _Ptr->GetNode( "AcquisitionFrameRate" ) ); + static_cast (&ResultingFrameRate)->SetReference( _Ptr->GetNode( "ResultingFrameRate" ) ); + static_cast (&SensorReadoutTime)->SetReference( _Ptr->GetNode( "SensorReadoutTime" ) ); + static_cast*> (&AcquisitionStatusSelector)->SetReference( _Ptr->GetNode( "AcquisitionStatusSelector" ) ); + static_cast*> (&AcquisitionStatusSelector)->SetNumEnums( 8 ); + static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameBurstTriggerWait, "FrameBurstTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameBurstTriggerActive, "FrameBurstTriggerActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameBurstTriggerTransfer, "FrameBurstTriggerTransfer" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameTriggerWait, "FrameTriggerWait" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameActive, "FrameActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_FrameTransfer, "FrameTransfer" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_ExposureActive, "ExposureActive" ); static_cast*> (&AcquisitionStatusSelector)->SetEnumReference( AcquisitionStatusSelector_AcquisitionIdle, "AcquisitionIdle" ); static_cast (&AcquisitionStatus)->SetReference( _Ptr->GetNode( "AcquisitionStatus" ) ); + static_cast*> (&SensorShutterMode)->SetReference( _Ptr->GetNode( "SensorShutterMode" ) ); + static_cast*> (&SensorShutterMode)->SetNumEnums( 3 ); + static_cast*> (&SensorShutterMode)->SetEnumReference( SensorShutterMode_Global, "Global" ); static_cast*> (&SensorShutterMode)->SetEnumReference( SensorShutterMode_Rolling, "Rolling" ); static_cast*> (&SensorShutterMode)->SetEnumReference( SensorShutterMode_GlobalReset, "GlobalReset" ); static_cast*> (&OverlapMode)->SetReference( _Ptr->GetNode( "OverlapMode" ) ); + static_cast*> (&OverlapMode)->SetNumEnums( 2 ); + static_cast*> (&OverlapMode)->SetEnumReference( OverlapMode_On, "On" ); static_cast*> (&OverlapMode)->SetEnumReference( OverlapMode_Off, "Off" ); static_cast*> (&BslImmediateTriggerMode)->SetReference( _Ptr->GetNode( "BslImmediateTriggerMode" ) ); + static_cast*> (&BslImmediateTriggerMode)->SetNumEnums( 2 ); + static_cast*> (&BslImmediateTriggerMode)->SetEnumReference( BslImmediateTriggerMode_On, "On" ); static_cast*> (&BslImmediateTriggerMode)->SetEnumReference( BslImmediateTriggerMode_Off, "Off" ); static_cast (&AutoTargetBrightness)->SetReference( _Ptr->GetNode( "AutoTargetBrightness" ) ); + static_cast*> (&AutoFunctionProfile)->SetReference( _Ptr->GetNode( "AutoFunctionProfile" ) ); + static_cast*> (&AutoFunctionProfile)->SetNumEnums( 7 ); + static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_MinimizeGain, "MinimizeGain" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_MinimizeExposureTime, "MinimizeExposureTime" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_Smart, "Smart" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_AntiFlicker50Hz, "AntiFlicker50Hz" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_AntiFlicker60Hz, "AntiFlicker60Hz" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_MinimizeGainQuick, "MinimizeGainQuick" ); static_cast*> (&AutoFunctionProfile)->SetEnumReference( AutoFunctionProfile_MinimizeExposureTimeQuick, "MinimizeExposureTimeQuick" ); static_cast (&AutoGainLowerLimit)->SetReference( _Ptr->GetNode( "AutoGainLowerLimit" ) ); + static_cast (&AutoGainUpperLimit)->SetReference( _Ptr->GetNode( "AutoGainUpperLimit" ) ); + static_cast (&AutoExposureTimeLowerLimit)->SetReference( _Ptr->GetNode( "AutoExposureTimeLowerLimit" ) ); + static_cast (&AutoExposureTimeUpperLimit)->SetReference( _Ptr->GetNode( "AutoExposureTimeUpperLimit" ) ); + static_cast (&AutoBacklightCompensation)->SetReference( _Ptr->GetNode( "AutoBacklightCompensation" ) ); + static_cast*> (&AutoFunctionROISelector)->SetReference( _Ptr->GetNode( "AutoFunctionROISelector" ) ); + static_cast*> (&AutoFunctionROISelector)->SetNumEnums( 2 ); + static_cast*> (&AutoFunctionROISelector)->SetEnumReference( AutoFunctionROISelector_ROI1, "ROI1" ); static_cast*> (&AutoFunctionROISelector)->SetEnumReference( AutoFunctionROISelector_ROI2, "ROI2" ); static_cast (&AutoFunctionROIWidth)->SetReference( _Ptr->GetNode( "AutoFunctionROIWidth" ) ); + static_cast (&AutoFunctionROIHeight)->SetReference( _Ptr->GetNode( "AutoFunctionROIHeight" ) ); + static_cast (&AutoFunctionROIOffsetX)->SetReference( _Ptr->GetNode( "AutoFunctionROIOffsetX" ) ); + static_cast (&AutoFunctionROIOffsetY)->SetReference( _Ptr->GetNode( "AutoFunctionROIOffsetY" ) ); + static_cast (&AutoFunctionROIUseBrightness)->SetReference( _Ptr->GetNode( "AutoFunctionROIUseBrightness" ) ); + static_cast (&AutoFunctionROIUseWhiteBalance)->SetReference( _Ptr->GetNode( "AutoFunctionROIUseWhiteBalance" ) ); + static_cast (&AutoFunctionROIUseTonalRange)->SetReference( _Ptr->GetNode( "AutoFunctionROIUseTonalRange" ) ); + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast*> (&AutoFunctionAOISelector)->SetReference( _Ptr->GetNode( "AutoFunctionAOISelector" ) ); + static_cast*> (&AutoFunctionAOISelector)->SetNumEnums( 2 ); + static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI1, "AOI1" ); static_cast*> (&AutoFunctionAOISelector)->SetEnumReference( AutoFunctionAOISelector_AOI2, "AOI2" ); +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast (&AutoFunctionAOIWidth)->SetReference( _Ptr->GetNode( "AutoFunctionAOIWidth" ) ); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast (&AutoFunctionAOIHeight)->SetReference( _Ptr->GetNode( "AutoFunctionAOIHeight" ) ); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast (&AutoFunctionAOIOffsetX)->SetReference( _Ptr->GetNode( "AutoFunctionAOIOffsetX" ) ); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast (&AutoFunctionAOIOffsetY)->SetReference( _Ptr->GetNode( "AutoFunctionAOIOffsetY" ) ); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast (&AutoFunctionAOIUseBrightness)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUseBrightness" ) ); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4996) // name has been marked as deprecated +#endif + static_cast (&AutoFunctionAOIUseWhiteBalance)->SetReference( _Ptr->GetNode( "AutoFunctionAOIUseWhiteBalance" ) ); + +#if defined (_MSC_VER) +# pragma warning(pop) +#endif + static_cast*> (&AutoTonalRangeModeSelector)->SetReference( _Ptr->GetNode( "AutoTonalRangeModeSelector" ) ); + static_cast*> (&AutoTonalRangeModeSelector)->SetNumEnums( 3 ); + static_cast*> (&AutoTonalRangeModeSelector)->SetEnumReference( AutoTonalRangeModeSelector_ColorAndContrast, "ColorAndContrast" ); static_cast*> (&AutoTonalRangeModeSelector)->SetEnumReference( AutoTonalRangeModeSelector_Color, "Color" ); static_cast*> (&AutoTonalRangeModeSelector)->SetEnumReference( AutoTonalRangeModeSelector_Contrast, "Contrast" ); static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetReference( _Ptr->GetNode( "AutoTonalRangeAdjustmentSelector" ) ); + static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetNumEnums( 3 ); + static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetEnumReference( AutoTonalRangeAdjustmentSelector_DarkAndBright, "DarkAndBright" ); static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetEnumReference( AutoTonalRangeAdjustmentSelector_Bright, "Bright" ); static_cast*> (&AutoTonalRangeAdjustmentSelector)->SetEnumReference( AutoTonalRangeAdjustmentSelector_Dark, "Dark" ); static_cast (&AutoTonalRangeThresholdBright)->SetReference( _Ptr->GetNode( "AutoTonalRangeThresholdBright" ) ); + static_cast (&AutoTonalRangeThresholdDark)->SetReference( _Ptr->GetNode( "AutoTonalRangeThresholdDark" ) ); + static_cast (&AutoTonalRangeTargetBright)->SetReference( _Ptr->GetNode( "AutoTonalRangeTargetBright" ) ); + static_cast (&AutoTonalRangeTargetDark)->SetReference( _Ptr->GetNode( "AutoTonalRangeTargetDark" ) ); + static_cast*> (&LUTSelector)->SetReference( _Ptr->GetNode( "LUTSelector" ) ); + static_cast*> (&LUTSelector)->SetNumEnums( 1 ); + static_cast*> (&LUTSelector)->SetEnumReference( LUTSelector_Luminance, "Luminance" ); static_cast (&LUTEnable)->SetReference( _Ptr->GetNode( "LUTEnable" ) ); + static_cast (&LUTIndex)->SetReference( _Ptr->GetNode( "LUTIndex" ) ); + static_cast (&LUTValue)->SetReference( _Ptr->GetNode( "LUTValue" ) ); + static_cast (&LUTValueAll)->SetReference( _Ptr->GetNode( "LUTValueAll" ) ); + static_cast*> (&LineSelector)->SetReference( _Ptr->GetNode( "LineSelector" ) ); + static_cast*> (&LineSelector)->SetNumEnums( 4 ); + static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line1, "Line1" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line2, "Line2" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line3, "Line3" ); static_cast*> (&LineSelector)->SetEnumReference( LineSelector_Line4, "Line4" ); static_cast*> (&LineMode)->SetReference( _Ptr->GetNode( "LineMode" ) ); + static_cast*> (&LineMode)->SetNumEnums( 2 ); + static_cast*> (&LineMode)->SetEnumReference( LineMode_Input, "Input" ); static_cast*> (&LineMode)->SetEnumReference( LineMode_Output, "Output" ); static_cast*> (&LineFormat)->SetReference( _Ptr->GetNode( "LineFormat" ) ); + static_cast*> (&LineFormat)->SetNumEnums( 7 ); + static_cast*> (&LineFormat)->SetEnumReference( LineFormat_NoConnect, "NoConnect" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_TriState, "TriState" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_TTL, "TTL" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_LVDS, "LVDS" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_RS422, "RS422" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_OptoCoupled, "OptoCoupled" ); static_cast*> (&LineFormat)->SetEnumReference( LineFormat_LVTTL, "LVTTL" ); static_cast*> (&LineLogic)->SetReference( _Ptr->GetNode( "LineLogic" ) ); + static_cast*> (&LineLogic)->SetNumEnums( 2 ); + static_cast*> (&LineLogic)->SetEnumReference( LineLogic_Positive, "Positive" ); static_cast*> (&LineLogic)->SetEnumReference( LineLogic_Negative, "Negative" ); static_cast*> (&LineSource)->SetReference( _Ptr->GetNode( "LineSource" ) ); + static_cast*> (&LineSource)->SetNumEnums( 11 ); + static_cast*> (&LineSource)->SetEnumReference( LineSource_Off, "Off" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_ExposureActive, "ExposureActive" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrameTriggerWait, "FrameTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FrameBurstTriggerWait, "FrameBurstTriggerWait" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_Timer1Active, "Timer1Active" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput0, "UserOutput0" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput1, "UserOutput1" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput2, "UserOutput2" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput3, "UserOutput3" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_FlashWindow, "FlashWindow" ); static_cast*> (&LineSource)->SetEnumReference( LineSource_UserOutput4, "UserOutput4" ); static_cast (&LineInverter)->SetReference( _Ptr->GetNode( "LineInverter" ) ); + static_cast (&LineDebouncerTime)->SetReference( _Ptr->GetNode( "LineDebouncerTime" ) ); + static_cast (&LineMinimumOutputPulseWidth)->SetReference( _Ptr->GetNode( "LineMinimumOutputPulseWidth" ) ); + static_cast (&LineOverloadStatus)->SetReference( _Ptr->GetNode( "LineOverloadStatus" ) ); + static_cast (&LineOverloadReset)->SetReference( _Ptr->GetNode( "LineOverloadReset" ) ); + static_cast (&LineStatus)->SetReference( _Ptr->GetNode( "LineStatus" ) ); + static_cast (&LineStatusAll)->SetReference( _Ptr->GetNode( "LineStatusAll" ) ); + static_cast*> (&UserOutputSelector)->SetReference( _Ptr->GetNode( "UserOutputSelector" ) ); + static_cast*> (&UserOutputSelector)->SetNumEnums( 4 ); + static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput0, "UserOutput0" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput1, "UserOutput1" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput2, "UserOutput2" ); static_cast*> (&UserOutputSelector)->SetEnumReference( UserOutputSelector_UserOutput3, "UserOutput3" ); static_cast (&UserOutputValue)->SetReference( _Ptr->GetNode( "UserOutputValue" ) ); + static_cast (&UserOutputValueAll)->SetReference( _Ptr->GetNode( "UserOutputValueAll" ) ); + static_cast*> (&SoftwareSignalSelector)->SetReference( _Ptr->GetNode( "SoftwareSignalSelector" ) ); + static_cast*> (&SoftwareSignalSelector)->SetNumEnums( 4 ); + static_cast*> (&SoftwareSignalSelector)->SetEnumReference( SoftwareSignalSelector_SoftwareSignal1, "SoftwareSignal1" ); static_cast*> (&SoftwareSignalSelector)->SetEnumReference( SoftwareSignalSelector_SoftwareSignal2, "SoftwareSignal2" ); static_cast*> (&SoftwareSignalSelector)->SetEnumReference( SoftwareSignalSelector_SoftwareSignal3, "SoftwareSignal3" ); static_cast*> (&SoftwareSignalSelector)->SetEnumReference( SoftwareSignalSelector_SoftwareSignal4, "SoftwareSignal4" ); static_cast (&SoftwareSignalPulse)->SetReference( _Ptr->GetNode( "SoftwareSignalPulse" ) ); + static_cast*> (&TimerSelector)->SetReference( _Ptr->GetNode( "TimerSelector" ) ); + static_cast*> (&TimerSelector)->SetNumEnums( 1 ); + static_cast*> (&TimerSelector)->SetEnumReference( TimerSelector_Timer1, "Timer1" ); static_cast (&TimerDuration)->SetReference( _Ptr->GetNode( "TimerDuration" ) ); + static_cast (&TimerDelay)->SetReference( _Ptr->GetNode( "TimerDelay" ) ); + static_cast*> (&TimerTriggerSource)->SetReference( _Ptr->GetNode( "TimerTriggerSource" ) ); + static_cast*> (&TimerTriggerSource)->SetNumEnums( 2 ); + static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_ExposureStart, "ExposureStart" ); static_cast*> (&TimerTriggerSource)->SetEnumReference( TimerTriggerSource_FlashWindowStart, "FlashWindowStart" ); static_cast*> (&CounterSelector)->SetReference( _Ptr->GetNode( "CounterSelector" ) ); + static_cast*> (&CounterSelector)->SetNumEnums( 2 ); + static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter1, "Counter1" ); static_cast*> (&CounterSelector)->SetEnumReference( CounterSelector_Counter2, "Counter2" ); static_cast*> (&CounterEventSource)->SetReference( _Ptr->GetNode( "CounterEventSource" ) ); + static_cast*> (&CounterEventSource)->SetNumEnums( 5 ); + static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameTrigger, "FrameTrigger" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_FrameStart, "FrameStart" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_Counter1End, "Counter1End" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_Counter2End, "Counter2End" ); static_cast*> (&CounterEventSource)->SetEnumReference( CounterEventSource_Counter3End, "Counter3End" ); static_cast*> (&CounterResetSource)->SetReference( _Ptr->GetNode( "CounterResetSource" ) ); + static_cast*> (&CounterResetSource)->SetNumEnums( 10 ); + static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Off, "Off" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Software, "Software" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line1, "Line1" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line2, "Line2" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line3, "Line3" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Line4, "Line4" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Counter1End, "Counter1End" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Counter2End, "Counter2End" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Counter3End, "Counter3End" ); static_cast*> (&CounterResetSource)->SetEnumReference( CounterResetSource_Counter4End, "Counter4End" ); static_cast*> (&CounterResetActivation)->SetReference( _Ptr->GetNode( "CounterResetActivation" ) ); + static_cast*> (&CounterResetActivation)->SetNumEnums( 5 ); + static_cast*> (&CounterResetActivation)->SetEnumReference( CounterResetActivation_RisingEdge, "RisingEdge" ); static_cast*> (&CounterResetActivation)->SetEnumReference( CounterResetActivation_FallingEdge, "FallingEdge" ); static_cast*> (&CounterResetActivation)->SetEnumReference( CounterResetActivation_AnyEdge, "AnyEdge" ); static_cast*> (&CounterResetActivation)->SetEnumReference( CounterResetActivation_LevelHigh, "LevelHigh" ); static_cast*> (&CounterResetActivation)->SetEnumReference( CounterResetActivation_LevelLow, "LevelLow" ); static_cast (&CounterReset)->SetReference( _Ptr->GetNode( "CounterReset" ) ); + static_cast (&CounterDuration)->SetReference( _Ptr->GetNode( "CounterDuration" ) ); + static_cast*> (&UserSetSelector)->SetReference( _Ptr->GetNode( "UserSetSelector" ) ); + static_cast*> (&UserSetSelector)->SetNumEnums( 9 ); + static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Default, "Default" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_HighGain, "HighGain" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_AutoFunctions, "AutoFunctions" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_Color, "Color" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_ColorRaw, "ColorRaw" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet1, "UserSet1" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet2, "UserSet2" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_UserSet3, "UserSet3" ); static_cast*> (&UserSetSelector)->SetEnumReference( UserSetSelector_LightMicroscopy, "LightMicroscopy" ); static_cast (&UserSetLoad)->SetReference( _Ptr->GetNode( "UserSetLoad" ) ); + static_cast (&UserSetSave)->SetReference( _Ptr->GetNode( "UserSetSave" ) ); + static_cast*> (&UserSetDefault)->SetReference( _Ptr->GetNode( "UserSetDefault" ) ); + static_cast*> (&UserSetDefault)->SetNumEnums( 9 ); + static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_Default, "Default" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_HighGain, "HighGain" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_AutoFunctions, "AutoFunctions" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_Color, "Color" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_ColorRaw, "ColorRaw" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_UserSet1, "UserSet1" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_UserSet2, "UserSet2" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_UserSet3, "UserSet3" ); static_cast*> (&UserSetDefault)->SetEnumReference( UserSetDefault_LightMicroscopy, "LightMicroscopy" ); static_cast (&ChunkModeActive)->SetReference( _Ptr->GetNode( "ChunkModeActive" ) ); + static_cast*> (&ChunkSelector)->SetReference( _Ptr->GetNode( "ChunkSelector" ) ); + static_cast*> (&ChunkSelector)->SetNumEnums( 8 ); + static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Image, "Image" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Gain, "Gain" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_ExposureTime, "ExposureTime" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_Timestamp, "Timestamp" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_LineStatusAll, "LineStatusAll" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_CounterValue, "CounterValue" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_SequencerSetActive, "SequencerSetActive" ); static_cast*> (&ChunkSelector)->SetEnumReference( ChunkSelector_PayloadCRC16, "PayloadCRC16" ); static_cast (&ChunkEnable)->SetReference( _Ptr->GetNode( "ChunkEnable" ) ); + static_cast*> (&ChunkGainSelector)->SetReference( _Ptr->GetNode( "ChunkGainSelector" ) ); + static_cast*> (&ChunkGainSelector)->SetNumEnums( 1 ); + static_cast*> (&ChunkGainSelector)->SetEnumReference( ChunkGainSelector_All, "All" ); static_cast (&ChunkGain)->SetReference( _Ptr->GetNode( "ChunkGain" ) ); + static_cast (&ChunkExposureTime)->SetReference( _Ptr->GetNode( "ChunkExposureTime" ) ); + static_cast (&ChunkTimestamp)->SetReference( _Ptr->GetNode( "ChunkTimestamp" ) ); + static_cast (&ChunkLineStatusAll)->SetReference( _Ptr->GetNode( "ChunkLineStatusAll" ) ); + static_cast*> (&ChunkCounterSelector)->SetReference( _Ptr->GetNode( "ChunkCounterSelector" ) ); + static_cast*> (&ChunkCounterSelector)->SetNumEnums( 2 ); + static_cast*> (&ChunkCounterSelector)->SetEnumReference( ChunkCounterSelector_Counter1, "Counter1" ); static_cast*> (&ChunkCounterSelector)->SetEnumReference( ChunkCounterSelector_Counter2, "Counter2" ); static_cast (&ChunkCounterValue)->SetReference( _Ptr->GetNode( "ChunkCounterValue" ) ); + static_cast (&ChunkSequencerSetActive)->SetReference( _Ptr->GetNode( "ChunkSequencerSetActive" ) ); + static_cast (&ChunkPayloadCRC16)->SetReference( _Ptr->GetNode( "ChunkPayloadCRC16" ) ); + static_cast*> (&EventSelector)->SetReference( _Ptr->GetNode( "EventSelector" ) ); + static_cast*> (&EventSelector)->SetNumEnums( 9 ); + static_cast*> (&EventSelector)->SetEnumReference( EventSelector_ExposureEnd, "ExposureEnd" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameStart, "FrameStart" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameBurstStart, "FrameBurstStart" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameStartOvertrigger, "FrameStartOvertrigger" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameBurstStartOvertrigger, "FrameBurstStartOvertrigger" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_CriticalTemperature, "CriticalTemperature" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_OverTemperature, "OverTemperature" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameStartWait, "FrameStartWait" ); static_cast*> (&EventSelector)->SetEnumReference( EventSelector_FrameBurstStartWait, "FrameBurstStartWait" ); static_cast*> (&EventNotification)->SetReference( _Ptr->GetNode( "EventNotification" ) ); + static_cast*> (&EventNotification)->SetNumEnums( 2 ); + static_cast*> (&EventNotification)->SetEnumReference( EventNotification_Off, "Off" ); static_cast*> (&EventNotification)->SetEnumReference( EventNotification_On, "On" ); static_cast (&TriggerEventTest)->SetReference( _Ptr->GetNode( "TriggerEventTest" ) ); + static_cast (&EventExposureEnd)->SetReference( _Ptr->GetNode( "EventExposureEnd" ) ); + static_cast (&EventExposureEndTimestamp)->SetReference( _Ptr->GetNode( "EventExposureEndTimestamp" ) ); + static_cast (&EventExposureEndFrameID)->SetReference( _Ptr->GetNode( "EventExposureEndFrameID" ) ); + static_cast (&EventFrameStart)->SetReference( _Ptr->GetNode( "EventFrameStart" ) ); + static_cast (&EventFrameStartTimestamp)->SetReference( _Ptr->GetNode( "EventFrameStartTimestamp" ) ); + static_cast (&EventFrameStartFrameID)->SetReference( _Ptr->GetNode( "EventFrameStartFrameID" ) ); + static_cast (&EventFrameBurstStart)->SetReference( _Ptr->GetNode( "EventFrameBurstStart" ) ); + static_cast (&EventFrameBurstStartTimestamp)->SetReference( _Ptr->GetNode( "EventFrameBurstStartTimestamp" ) ); + static_cast (&EventFrameBurstStartFrameID)->SetReference( _Ptr->GetNode( "EventFrameBurstStartFrameID" ) ); + static_cast (&EventFrameStartOvertrigger)->SetReference( _Ptr->GetNode( "EventFrameStartOvertrigger" ) ); + static_cast (&EventFrameStartOvertriggerTimestamp)->SetReference( _Ptr->GetNode( "EventFrameStartOvertriggerTimestamp" ) ); + static_cast (&EventFrameStartOvertriggerFrameID)->SetReference( _Ptr->GetNode( "EventFrameStartOvertriggerFrameID" ) ); + static_cast (&EventFrameBurstStartOvertrigger)->SetReference( _Ptr->GetNode( "EventFrameBurstStartOvertrigger" ) ); + static_cast (&EventFrameBurstStartOvertriggerTimestamp)->SetReference( _Ptr->GetNode( "EventFrameBurstStartOvertriggerTimestamp" ) ); + static_cast (&EventFrameBurstStartOvertriggerFrameID)->SetReference( _Ptr->GetNode( "EventFrameBurstStartOvertriggerFrameID" ) ); + static_cast (&EventTest)->SetReference( _Ptr->GetNode( "EventTest" ) ); + static_cast (&EventTestTimestamp)->SetReference( _Ptr->GetNode( "EventTestTimestamp" ) ); + static_cast (&EventCriticalTemperature)->SetReference( _Ptr->GetNode( "EventCriticalTemperature" ) ); + static_cast (&EventCriticalTemperatureTimestamp)->SetReference( _Ptr->GetNode( "EventCriticalTemperatureTimestamp" ) ); + static_cast (&EventOverTemperature)->SetReference( _Ptr->GetNode( "EventOverTemperature" ) ); + static_cast (&EventOverTemperatureTimestamp)->SetReference( _Ptr->GetNode( "EventOverTemperatureTimestamp" ) ); + static_cast (&EventFrameStartWait)->SetReference( _Ptr->GetNode( "EventFrameStartWait" ) ); + static_cast (&EventFrameStartWaitTimestamp)->SetReference( _Ptr->GetNode( "EventFrameStartWaitTimestamp" ) ); + static_cast (&EventFrameBurstStartWait)->SetReference( _Ptr->GetNode( "EventFrameBurstStartWait" ) ); + static_cast (&EventFrameBurstStartWaitTimestamp)->SetReference( _Ptr->GetNode( "EventFrameBurstStartWaitTimestamp" ) ); + static_cast (&PayloadSize)->SetReference( _Ptr->GetNode( "PayloadSize" ) ); + static_cast*> (&BslUSBSpeedMode)->SetReference( _Ptr->GetNode( "BslUSBSpeedMode" ) ); + static_cast*> (&BslUSBSpeedMode)->SetNumEnums( 4 ); + static_cast*> (&BslUSBSpeedMode)->SetEnumReference( BslUSBSpeedMode_LowSpeed, "LowSpeed" ); static_cast*> (&BslUSBSpeedMode)->SetEnumReference( BslUSBSpeedMode_FullSpeed, "FullSpeed" ); static_cast*> (&BslUSBSpeedMode)->SetEnumReference( BslUSBSpeedMode_HighSpeed, "HighSpeed" ); static_cast*> (&BslUSBSpeedMode)->SetEnumReference( BslUSBSpeedMode_SuperSpeed, "SuperSpeed" ); static_cast (&SIPayloadTransferSize)->SetReference( _Ptr->GetNode( "SIPayloadTransferSize" ) ); + static_cast (&SIPayloadTransferCount)->SetReference( _Ptr->GetNode( "SIPayloadTransferCount" ) ); + static_cast (&SIPayloadFinalTransfer1Size)->SetReference( _Ptr->GetNode( "SIPayloadFinalTransfer1Size" ) ); + static_cast (&SIPayloadFinalTransfer2Size)->SetReference( _Ptr->GetNode( "SIPayloadFinalTransfer2Size" ) ); + static_cast (&TestPendingAck)->SetReference( _Ptr->GetNode( "TestPendingAck" ) ); + static_cast (&PayloadTransferBlockDelay)->SetReference( _Ptr->GetNode( "PayloadTransferBlockDelay" ) ); + static_cast (&PayloadTransferSize)->SetReference( _Ptr->GetNode( "PayloadTransferSize" ) ); + static_cast (&PayloadTransferCount)->SetReference( _Ptr->GetNode( "PayloadTransferCount" ) ); + static_cast (&PayloadFinalTransfer1Size)->SetReference( _Ptr->GetNode( "PayloadFinalTransfer1Size" ) ); + static_cast (&PayloadFinalTransfer2Size)->SetReference( _Ptr->GetNode( "PayloadFinalTransfer2Size" ) ); + static_cast (&DeviceVendorName)->SetReference( _Ptr->GetNode( "DeviceVendorName" ) ); + static_cast (&DeviceModelName)->SetReference( _Ptr->GetNode( "DeviceModelName" ) ); + static_cast (&DeviceManufacturerInfo)->SetReference( _Ptr->GetNode( "DeviceManufacturerInfo" ) ); + static_cast (&DeviceVersion)->SetReference( _Ptr->GetNode( "DeviceVersion" ) ); + static_cast (&DeviceFirmwareVersion)->SetReference( _Ptr->GetNode( "DeviceFirmwareVersion" ) ); + static_cast (&DeviceSerialNumber)->SetReference( _Ptr->GetNode( "DeviceSerialNumber" ) ); + static_cast (&DeviceUserID)->SetReference( _Ptr->GetNode( "DeviceUserID" ) ); + static_cast*> (&DeviceScanType)->SetReference( _Ptr->GetNode( "DeviceScanType" ) ); + static_cast*> (&DeviceScanType)->SetNumEnums( 2 ); + static_cast*> (&DeviceScanType)->SetEnumReference( DeviceScanType_Areascan, "Areascan" ); static_cast*> (&DeviceScanType)->SetEnumReference( DeviceScanType_Linescan, "Linescan" ); static_cast (&TimestampLatch)->SetReference( _Ptr->GetNode( "TimestampLatch" ) ); + static_cast (&TimestampLatchValue)->SetReference( _Ptr->GetNode( "TimestampLatchValue" ) ); + static_cast (&DeviceLinkSelector)->SetReference( _Ptr->GetNode( "DeviceLinkSelector" ) ); + static_cast (&DeviceLinkSpeed)->SetReference( _Ptr->GetNode( "DeviceLinkSpeed" ) ); + static_cast*> (&DeviceLinkThroughputLimitMode)->SetReference( _Ptr->GetNode( "DeviceLinkThroughputLimitMode" ) ); + static_cast*> (&DeviceLinkThroughputLimitMode)->SetNumEnums( 2 ); + static_cast*> (&DeviceLinkThroughputLimitMode)->SetEnumReference( DeviceLinkThroughputLimitMode_Off, "Off" ); static_cast*> (&DeviceLinkThroughputLimitMode)->SetEnumReference( DeviceLinkThroughputLimitMode_On, "On" ); static_cast (&DeviceLinkThroughputLimit)->SetReference( _Ptr->GetNode( "DeviceLinkThroughputLimit" ) ); + static_cast (&DeviceLinkCurrentThroughput)->SetReference( _Ptr->GetNode( "DeviceLinkCurrentThroughput" ) ); + static_cast*> (&DeviceTemperatureSelector)->SetReference( _Ptr->GetNode( "DeviceTemperatureSelector" ) ); + static_cast*> (&DeviceTemperatureSelector)->SetNumEnums( 3 ); + static_cast*> (&DeviceTemperatureSelector)->SetEnumReference( DeviceTemperatureSelector_Coreboard, "Coreboard" ); static_cast*> (&DeviceTemperatureSelector)->SetEnumReference( DeviceTemperatureSelector_Sensorboard, "Sensorboard" ); static_cast*> (&DeviceTemperatureSelector)->SetEnumReference( DeviceTemperatureSelector_Framegrabberboard, "Framegrabberboard" ); static_cast (&DeviceTemperature)->SetReference( _Ptr->GetNode( "DeviceTemperature" ) ); + static_cast*> (&TemperatureState)->SetReference( _Ptr->GetNode( "TemperatureState" ) ); + static_cast*> (&TemperatureState)->SetNumEnums( 3 ); + static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Ok, "Ok" ); static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Critical, "Critical" ); static_cast*> (&TemperatureState)->SetEnumReference( TemperatureState_Error, "Error" ); static_cast (&DeviceReset)->SetReference( _Ptr->GetNode( "DeviceReset" ) ); + static_cast (&DeviceSFNCVersionMajor)->SetReference( _Ptr->GetNode( "DeviceSFNCVersionMajor" ) ); + static_cast (&DeviceSFNCVersionMinor)->SetReference( _Ptr->GetNode( "DeviceSFNCVersionMinor" ) ); + static_cast (&DeviceSFNCVersionSubMinor)->SetReference( _Ptr->GetNode( "DeviceSFNCVersionSubMinor" ) ); + static_cast*> (&DeviceIndicatorMode)->SetReference( _Ptr->GetNode( "DeviceIndicatorMode" ) ); + static_cast*> (&DeviceIndicatorMode)->SetNumEnums( 2 ); + static_cast*> (&DeviceIndicatorMode)->SetEnumReference( DeviceIndicatorMode_Inactive, "Inactive" ); static_cast*> (&DeviceIndicatorMode)->SetEnumReference( DeviceIndicatorMode_Active, "Active" ); static_cast (&DeviceRegistersStreamingStart)->SetReference( _Ptr->GetNode( "DeviceRegistersStreamingStart" ) ); + static_cast (&DeviceRegistersStreamingEnd)->SetReference( _Ptr->GetNode( "DeviceRegistersStreamingEnd" ) ); + static_cast (&DeviceColorPipelineVersion)->SetReference( _Ptr->GetNode( "DeviceColorPipelineVersion" ) ); + static_cast*> (&UserDefinedValueSelector)->SetReference( _Ptr->GetNode( "UserDefinedValueSelector" ) ); + static_cast*> (&UserDefinedValueSelector)->SetNumEnums( 5 ); + static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value1, "Value1" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value2, "Value2" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value3, "Value3" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value4, "Value4" ); static_cast*> (&UserDefinedValueSelector)->SetEnumReference( UserDefinedValueSelector_Value5, "Value5" ); static_cast (&UserDefinedValue)->SetReference( _Ptr->GetNode( "UserDefinedValue" ) ); + static_cast*> (&RemoveParameterLimitSelector)->SetReference( _Ptr->GetNode( "RemoveParameterLimitSelector" ) ); + static_cast*> (&RemoveParameterLimitSelector)->SetNumEnums( 5 ); + static_cast*> (&RemoveParameterLimitSelector)->SetEnumReference( RemoveParameterLimitSelector_Gain, "Gain" ); static_cast*> (&RemoveParameterLimitSelector)->SetEnumReference( RemoveParameterLimitSelector_BlackLevel, "BlackLevel" ); static_cast*> (&RemoveParameterLimitSelector)->SetEnumReference( RemoveParameterLimitSelector_ExposureTime, "ExposureTime" ); static_cast*> (&RemoveParameterLimitSelector)->SetEnumReference( RemoveParameterLimitSelector_AutoTargetValue, "AutoTargetValue" ); static_cast*> (&RemoveParameterLimitSelector)->SetEnumReference( RemoveParameterLimitSelector_ExposureOverhead, "ExposureOverhead" ); static_cast (&RemoveParameterLimit)->SetReference( _Ptr->GetNode( "RemoveParameterLimit" ) ); + static_cast*> (&ExpertFeatureAccessSelector)->SetReference( _Ptr->GetNode( "ExpertFeatureAccessSelector" ) ); + static_cast*> (&ExpertFeatureAccessSelector)->SetNumEnums( 10 ); + static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature1, "ExpertFeature1" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature2, "ExpertFeature2" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature3, "ExpertFeature3" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature4, "ExpertFeature4" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature5, "ExpertFeature5" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature6, "ExpertFeature6" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature7, "ExpertFeature7" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature8, "ExpertFeature8" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature9, "ExpertFeature9" ); static_cast*> (&ExpertFeatureAccessSelector)->SetEnumReference( ExpertFeatureAccessSelector_ExpertFeature10, "ExpertFeature10" ); static_cast (&ExpertFeatureAccessKey)->SetReference( _Ptr->GetNode( "ExpertFeatureAccessKey" ) ); + static_cast (&ExpertFeatureEnable)->SetReference( _Ptr->GetNode( "ExpertFeatureEnable" ) ); + static_cast*> (&FileSelector)->SetReference( _Ptr->GetNode( "FileSelector" ) ); + static_cast*> (&FileSelector)->SetNumEnums( 9 ); + static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserData, "UserData" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet1, "UserSet1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet2, "UserSet2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserSet3, "UserSet3" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserGainShading1, "UserGainShading1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserGainShading2, "UserGainShading2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserOffsetShading1, "UserOffsetShading1" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_UserOffsetShading2, "UserOffsetShading2" ); static_cast*> (&FileSelector)->SetEnumReference( FileSelector_ExpertFeature7File, "ExpertFeature7File" ); static_cast*> (&FileOperationSelector)->SetReference( _Ptr->GetNode( "FileOperationSelector" ) ); + static_cast*> (&FileOperationSelector)->SetNumEnums( 4 ); + static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Open, "Open" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Close, "Close" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Read, "Read" ); static_cast*> (&FileOperationSelector)->SetEnumReference( FileOperationSelector_Write, "Write" ); static_cast*> (&FileOpenMode)->SetReference( _Ptr->GetNode( "FileOpenMode" ) ); + static_cast*> (&FileOpenMode)->SetNumEnums( 2 ); + static_cast*> (&FileOpenMode)->SetEnumReference( FileOpenMode_Read, "Read" ); static_cast*> (&FileOpenMode)->SetEnumReference( FileOpenMode_Write, "Write" ); static_cast (&FileAccessBuffer)->SetReference( _Ptr->GetNode( "FileAccessBuffer" ) ); + static_cast (&FileAccessOffset)->SetReference( _Ptr->GetNode( "FileAccessOffset" ) ); + static_cast (&FileAccessLength)->SetReference( _Ptr->GetNode( "FileAccessLength" ) ); + static_cast*> (&FileOperationStatus)->SetReference( _Ptr->GetNode( "FileOperationStatus" ) ); + static_cast*> (&FileOperationStatus)->SetNumEnums( 2 ); + static_cast*> (&FileOperationStatus)->SetEnumReference( FileOperationStatus_Success, "Success" ); static_cast*> (&FileOperationStatus)->SetEnumReference( FileOperationStatus_Failure, "Failure" ); static_cast (&FileOperationResult)->SetReference( _Ptr->GetNode( "FileOperationResult" ) ); + static_cast (&FileSize)->SetReference( _Ptr->GetNode( "FileSize" ) ); + static_cast (&FileOperationExecute)->SetReference( _Ptr->GetNode( "FileOperationExecute" ) ); + static_cast*> (&TonalRangeEnable)->SetReference( _Ptr->GetNode( "TonalRangeEnable" ) ); + static_cast*> (&TonalRangeEnable)->SetNumEnums( 2 ); + static_cast*> (&TonalRangeEnable)->SetEnumReference( TonalRangeEnable_Off, "Off" ); static_cast*> (&TonalRangeEnable)->SetEnumReference( TonalRangeEnable_On, "On" ); static_cast*> (&TonalRangeAuto)->SetReference( _Ptr->GetNode( "TonalRangeAuto" ) ); + static_cast*> (&TonalRangeAuto)->SetNumEnums( 2 ); + static_cast*> (&TonalRangeAuto)->SetEnumReference( TonalRangeAuto_Off, "Off" ); static_cast*> (&TonalRangeAuto)->SetEnumReference( TonalRangeAuto_Once, "Once" ); static_cast*> (&TonalRangeSelector)->SetReference( _Ptr->GetNode( "TonalRangeSelector" ) ); + static_cast*> (&TonalRangeSelector)->SetNumEnums( 4 ); + static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Sum, "Sum" ); static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Red, "Red" ); static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Green, "Green" ); static_cast*> (&TonalRangeSelector)->SetEnumReference( TonalRangeSelector_Blue, "Blue" ); static_cast (&TonalRangeSourceBright)->SetReference( _Ptr->GetNode( "TonalRangeSourceBright" ) ); + static_cast (&TonalRangeSourceDark)->SetReference( _Ptr->GetNode( "TonalRangeSourceDark" ) ); + static_cast (&TonalRangeTargetBright)->SetReference( _Ptr->GetNode( "TonalRangeTargetBright" ) ); + static_cast (&TonalRangeTargetDark)->SetReference( _Ptr->GetNode( "TonalRangeTargetDark" ) ); + + } + + inline const char* CUsbCameraParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CUsbCameraParams_Params::_GetModelName( void ) + { + return "UsbCameraParams"; + } + + //! \endcond + +} // namespace Basler_UsbCameraParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_UsbCameraParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/usb/_UsbChunkData.h b/Cigarette/Pylon6.2/include/pylon/usb/_UsbChunkData.h new file mode 100644 index 0000000..2546c6b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/_UsbChunkData.h @@ -0,0 +1,367 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Basler USB3Vision camera interface +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_UsbChunkData_PARAMS_H +#define Basler_UsbChunkData_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_UsbChunkData +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for ChunkGainSelector + enum ChunkGainSelectorEnums + { + ChunkGainSelector_All //!& ChunkGainSelector; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief Gain used to acquire the image. Applies to: ace + + Gain used to acquire the image. + + \b Visibility = Beginner + + + \b Selected by : ChunkGainSelector + + */ + GENAPI_NAMESPACE::IFloat& ChunkGain; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief Exposure time used to acquire the image. Applies to: ace + + Exposure time used to acquire the image. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IFloat& ChunkExposureTime; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief Value of the timestamp when the image was acquired. Applies to: ace + + Value of the timestamp when the image was acquired. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkTimestamp; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief A bit field that indicates the status of all of the camera's input and output lines when the image was acquired. Applies to: ace + + A bit field that indicates the status of all of the camera's input and output lines when the image was acquired + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkLineStatusAll; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief Sets which counter to retrieve chunk data from. Applies to: ace + + Sets which counter to retrieve chunk data from. + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IEnumerationT& ChunkCounterSelector; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief Value of the selected chunk counter. Applies to: ace + + Value of the selected chunk counter. + + \b Visibility = Beginner + + + \b Selected by : ChunkCounterSelector + + */ + GENAPI_NAMESPACE::IInteger& ChunkCounterValue; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief Index of the active sequencer set. Applies to: ace + + Index of the active sequencer set. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkSequencerSetActive; + + //@} + + + //! \name ChunkData - Contains parameters to append chunk data to the image data. + //@{ + /*! + \brief CRC checksum of the acquired image. Applies to: ace + + CRC checksum of the acquired image. The checksum is calculated using all of the image data and all of the appended chunks except for the checksum itself. + + \b Visibility = Beginner + + + */ + GENAPI_NAMESPACE::IInteger& ChunkPayloadCRC16; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUsbChunkData_Params( CUsbChunkData_Params& ); + + //! not implemented assignment operator + CUsbChunkData_Params& operator=( CUsbChunkData_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CUsbChunkData_Params::CUsbChunkData_Params( void ) + : ChunkGainSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkGain( *new GENAPI_NAMESPACE::CFloatRef() ) + , ChunkExposureTime( *new GENAPI_NAMESPACE::CFloatRef() ) + , ChunkTimestamp( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkLineStatusAll( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkCounterSelector( *new GENAPI_NAMESPACE::CEnumerationTRef() ) + , ChunkCounterValue( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkSequencerSetActive( *new GENAPI_NAMESPACE::CIntegerRef() ) + , ChunkPayloadCRC16( *new GENAPI_NAMESPACE::CIntegerRef() ) + + { + } + + inline CUsbChunkData_Params::~CUsbChunkData_Params( void ) + { + delete static_cast *> (&ChunkGainSelector); + delete static_cast (&ChunkGain); + delete static_cast (&ChunkExposureTime); + delete static_cast (&ChunkTimestamp); + delete static_cast (&ChunkLineStatusAll); + delete static_cast *> (&ChunkCounterSelector); + delete static_cast (&ChunkCounterValue); + delete static_cast (&ChunkSequencerSetActive); + delete static_cast (&ChunkPayloadCRC16); + + } + + inline void CUsbChunkData_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast*> (&ChunkGainSelector)->SetReference( _Ptr->GetNode( "ChunkGainSelector" ) ); + static_cast*> (&ChunkGainSelector)->SetNumEnums( 1 ); + static_cast*> (&ChunkGainSelector)->SetEnumReference( ChunkGainSelector_All, "All" ); static_cast (&ChunkGain)->SetReference( _Ptr->GetNode( "ChunkGain" ) ); + static_cast (&ChunkExposureTime)->SetReference( _Ptr->GetNode( "ChunkExposureTime" ) ); + static_cast (&ChunkTimestamp)->SetReference( _Ptr->GetNode( "ChunkTimestamp" ) ); + static_cast (&ChunkLineStatusAll)->SetReference( _Ptr->GetNode( "ChunkLineStatusAll" ) ); + static_cast*> (&ChunkCounterSelector)->SetReference( _Ptr->GetNode( "ChunkCounterSelector" ) ); + static_cast*> (&ChunkCounterSelector)->SetNumEnums( 2 ); + static_cast*> (&ChunkCounterSelector)->SetEnumReference( ChunkCounterSelector_Counter1, "Counter1" ); static_cast*> (&ChunkCounterSelector)->SetEnumReference( ChunkCounterSelector_Counter2, "Counter2" ); static_cast (&ChunkCounterValue)->SetReference( _Ptr->GetNode( "ChunkCounterValue" ) ); + static_cast (&ChunkSequencerSetActive)->SetReference( _Ptr->GetNode( "ChunkSequencerSetActive" ) ); + static_cast (&ChunkPayloadCRC16)->SetReference( _Ptr->GetNode( "ChunkPayloadCRC16" ) ); + + } + + inline const char* CUsbChunkData_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CUsbChunkData_Params::_GetModelName( void ) + { + return "UsbChunkData"; + } + + //! \endcond + +} // namespace Basler_UsbChunkData + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_UsbChunkData_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/usb/_UsbEventParams.h b/Cigarette/Pylon6.2/include/pylon/usb/_UsbEventParams.h new file mode 100644 index 0000000..35742ec --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/_UsbEventParams.h @@ -0,0 +1,293 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Interface to the PylonUsb Event Grabber parameters +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_UsbEventParams_PARAMS_H +#define Basler_UsbEventParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_UsbEventParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for Status + enum StatusEnums + { + Status_Closed, //! (&NumBuffer); + delete static_cast (&NumMaxQueuedUrbs); + delete static_cast (&TransferLoopThreadPriority); + delete static_cast (&Statistic_Total_Event_Count); + delete static_cast (&Statistic_Failed_Event_Count); + delete static_cast (&Statistic_Last_Failed_Event_Buffer_Status); + + } + + inline void CUsbEventParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&NumBuffer)->SetReference( _Ptr->GetNode( "NumBuffer" ) ); + static_cast (&NumMaxQueuedUrbs)->SetReference( _Ptr->GetNode( "NumMaxQueuedUrbs" ) ); + static_cast (&TransferLoopThreadPriority)->SetReference( _Ptr->GetNode( "TransferLoopThreadPriority" ) ); + static_cast (&Statistic_Total_Event_Count)->SetReference( _Ptr->GetNode( "Statistic_Total_Event_Count" ) ); + static_cast (&Statistic_Failed_Event_Count)->SetReference( _Ptr->GetNode( "Statistic_Failed_Event_Count" ) ); + static_cast (&Statistic_Last_Failed_Event_Buffer_Status)->SetReference( _Ptr->GetNode( "Statistic_Last_Failed_Event_Buffer_Status" ) ); + + } + + inline const char* CUsbEventParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CUsbEventParams_Params::_GetModelName( void ) + { + return "UsbEventParams"; + } + + //! \endcond + +} // namespace Basler_UsbEventParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_UsbEventParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/usb/_UsbStreamParams.h b/Cigarette/Pylon6.2/include/pylon/usb/_UsbStreamParams.h new file mode 100644 index 0000000..ea61e5b --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/_UsbStreamParams.h @@ -0,0 +1,427 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Interface to the PylonUsb Stream Grabber parameters +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_UsbStreamParams_PARAMS_H +#define Basler_UsbStreamParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_UsbStreamParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + //! Valid values for Status + enum StatusEnums + { + Status_Closed, //! (&MaxNumBuffer); + delete static_cast (&MaxBufferSize); + delete static_cast (&MaxTransferSize); + delete static_cast (&NumMaxQueuedUrbs); + delete static_cast (&TransferLoopThreadPriority); + delete static_cast (&TransferTimeout); + delete static_cast (&Statistic_Total_Buffer_Count); + delete static_cast (&Statistic_Failed_Buffer_Count); + delete static_cast (&Statistic_Last_Failed_Buffer_Status); + delete static_cast (&Statistic_Last_Failed_Buffer_Status_Text); + delete static_cast (&Statistic_Missed_Frame_Count); + delete static_cast (&Statistic_Resynchronization_Count); + delete static_cast (&Statistic_Last_Block_Id); + + } + + inline void CUsbStreamParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&MaxNumBuffer)->SetReference( _Ptr->GetNode( "MaxNumBuffer" ) ); + static_cast (&MaxBufferSize)->SetReference( _Ptr->GetNode( "MaxBufferSize" ) ); + static_cast (&MaxTransferSize)->SetReference( _Ptr->GetNode( "MaxTransferSize" ) ); + static_cast (&NumMaxQueuedUrbs)->SetReference( _Ptr->GetNode( "NumMaxQueuedUrbs" ) ); + static_cast (&TransferLoopThreadPriority)->SetReference( _Ptr->GetNode( "TransferLoopThreadPriority" ) ); + static_cast (&TransferTimeout)->SetReference( _Ptr->GetNode( "TransferTimeout" ) ); + static_cast (&Statistic_Total_Buffer_Count)->SetReference( _Ptr->GetNode( "Statistic_Total_Buffer_Count" ) ); + static_cast (&Statistic_Failed_Buffer_Count)->SetReference( _Ptr->GetNode( "Statistic_Failed_Buffer_Count" ) ); + static_cast (&Statistic_Last_Failed_Buffer_Status)->SetReference( _Ptr->GetNode( "Statistic_Last_Failed_Buffer_Status" ) ); + static_cast (&Statistic_Last_Failed_Buffer_Status_Text)->SetReference( _Ptr->GetNode( "Statistic_Last_Failed_Buffer_Status_Text" ) ); + static_cast (&Statistic_Missed_Frame_Count)->SetReference( _Ptr->GetNode( "Statistic_Missed_Frame_Count" ) ); + static_cast (&Statistic_Resynchronization_Count)->SetReference( _Ptr->GetNode( "Statistic_Resynchronization_Count" ) ); + static_cast (&Statistic_Last_Block_Id)->SetReference( _Ptr->GetNode( "Statistic_Last_Block_Id" ) ); + + } + + inline const char* CUsbStreamParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CUsbStreamParams_Params::_GetModelName( void ) + { + return "UsbStreamParams"; + } + + //! \endcond + +} // namespace Basler_UsbStreamParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_UsbStreamParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylon/usb/_UsbTLParams.h b/Cigarette/Pylon6.2/include/pylon/usb/_UsbTLParams.h new file mode 100644 index 0000000..78b6e00 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylon/usb/_UsbTLParams.h @@ -0,0 +1,303 @@ + + +//----------------------------------------------------------------------------- +// Copyright (c) 2004-2021 Basler AG +// Section: Vision Components +// Project: GenApi +//----------------------------------------------------------------------------- +/*! +\file +\brief Interface to the USB transport layer specific parameters. +*/ + +//----------------------------------------------------------------------------- +// This file is generated automatically +// Do not modify! +//----------------------------------------------------------------------------- + + + +#ifndef Basler_UsbTLParams_PARAMS_H +#define Basler_UsbTLParams_PARAMS_H + +#include +#include +#include + +// common node types +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# undef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE (GCC_VERSION >= 40200) +# undef GCC_DIAGNOSTIC_PUSH_POP_AWARE +# define GCC_DIAGNOSTIC_PUSH_POP_AWARE (GCC_VERSION >= 40600) +#else +# undef GCC_DIAGNOSTIC_AWARE +# define GCC_DIAGNOSTIC_AWARE 0 +#endif + +#ifdef __GNUC__ + // GCC_DIAGNOSTIC_AWARE ensures that the internal deprecated warnings can be ignored by gcc. + // As a result older gcc will not generate warnings about really used deprecated features. +# if GCC_DIAGNOSTIC_AWARE +# define GENAPI_DEPRECATED_FEATURE __attribute__((deprecated)) +# else +# define GENAPI_DEPRECATED_FEATURE +# endif +#elif defined(_MSC_VER) +# define GENAPI_DEPRECATED_FEATURE __declspec(deprecated) +#else +# define GENAPI_DEPRECATED_FEATURE +#endif + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic push +# endif +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + + +//! The namespace containing the device's control interface and related enumeration types +namespace Basler_UsbTLParams +{ + + //************************************************************************************************** + // Enumerations + //************************************************************************************************** + + + //************************************************************************************************** + // Parameter class + //************************************************************************************************** + + + //! Interface to the USB transport layer specific parameters. + class CUsbTLParams_Params + { + //---------------------------------------------------------------------------------------------------------------- + // Implementation + //---------------------------------------------------------------------------------------------------------------- + protected: + // If you want to show the following methods in the help file + // add the string HIDE_CLASS_METHODS to the ENABLED_SECTIONS tag in the doxygen file + //! \cond HIDE_CLASS_METHODS + + //! Constructor + CUsbTLParams_Params( void ); + + //! Destructor + ~CUsbTLParams_Params( void ); + + //! Initializes the references + void _Initialize( GENAPI_NAMESPACE::INodeMap* ); + + //! Return the vendor of the camera + const char* _GetVendorName( void ); + + //! Returns the camera model name + const char* _GetModelName( void ); + + //! \endcond + +//---------------------------------------------------------------------------------------------------------------- +// References to features +//---------------------------------------------------------------------------------------------------------------- + public: + + //! \name Root - Transport layer-specific parameters. + //@{ + /*! + \brief Enables mapping of certain SFNC 1.x node names to SFNC 2.x node names. + + + + \b Visibility = Guru + + */ + GENAPI_NAMESPACE::IBoolean& MigrationModeEnable; + + //@} + + + //! \name Statistic - Statistical data. + //@{ + /*! + \brief Number of read pipe resets. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Read_Pipe_Reset_Count; + + //@} + + + //! \name Statistic - Statistical data. + //@{ + /*! + \brief Number of write pipe resets. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Write_Pipe_Reset_Count; + + //@} + + + //! \name Statistic - Statistical data. + //@{ + /*! + \brief Number of failed read operations. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Read_Operations_Failed_Count; + + //@} + + + //! \name Statistic - Statistical data. + //@{ + /*! + \brief Number of failed write operations. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Write_Operations_Failed_Count; + + //@} + + + //! \name Statistic - Statistical data. + //@{ + /*! + \brief Last error status of a read or write operation. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IInteger& Statistic_Last_Error_Status; + + //@} + + + //! \name Statistic - Statistical data. + //@{ + /*! + \brief Last error status of a read or write operation. + + + + \b Visibility = Expert + + */ + GENAPI_NAMESPACE::IString& Statistic_Last_Error_Status_Text; + + //@} + + + + private: + //! \cond HIDE_CLASS_METHODS + + //! not implemented copy constructor + CUsbTLParams_Params( CUsbTLParams_Params& ); + + //! not implemented assignment operator + CUsbTLParams_Params& operator=( CUsbTLParams_Params& ); + + //! \endcond + }; + + + //************************************************************************************************** + // Parameter class implementation + //************************************************************************************************** + + //! \cond HIDE_CLASS_METHODS + + inline CUsbTLParams_Params::CUsbTLParams_Params( void ) + : MigrationModeEnable( *new GENAPI_NAMESPACE::CBooleanRef() ) + , Statistic_Read_Pipe_Reset_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Write_Pipe_Reset_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Read_Operations_Failed_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Write_Operations_Failed_Count( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Last_Error_Status( *new GENAPI_NAMESPACE::CIntegerRef() ) + , Statistic_Last_Error_Status_Text( *new GENAPI_NAMESPACE::CStringRef() ) + + { + } + + inline CUsbTLParams_Params::~CUsbTLParams_Params( void ) + { + delete static_cast (&MigrationModeEnable); + delete static_cast (&Statistic_Read_Pipe_Reset_Count); + delete static_cast (&Statistic_Write_Pipe_Reset_Count); + delete static_cast (&Statistic_Read_Operations_Failed_Count); + delete static_cast (&Statistic_Write_Operations_Failed_Count); + delete static_cast (&Statistic_Last_Error_Status); + delete static_cast (&Statistic_Last_Error_Status_Text); + + } + + inline void CUsbTLParams_Params::_Initialize( GENAPI_NAMESPACE::INodeMap* _Ptr ) + { + static_cast (&MigrationModeEnable)->SetReference( _Ptr->GetNode( "MigrationModeEnable" ) ); + static_cast (&Statistic_Read_Pipe_Reset_Count)->SetReference( _Ptr->GetNode( "Statistic_Read_Pipe_Reset_Count" ) ); + static_cast (&Statistic_Write_Pipe_Reset_Count)->SetReference( _Ptr->GetNode( "Statistic_Write_Pipe_Reset_Count" ) ); + static_cast (&Statistic_Read_Operations_Failed_Count)->SetReference( _Ptr->GetNode( "Statistic_Read_Operations_Failed_Count" ) ); + static_cast (&Statistic_Write_Operations_Failed_Count)->SetReference( _Ptr->GetNode( "Statistic_Write_Operations_Failed_Count" ) ); + static_cast (&Statistic_Last_Error_Status)->SetReference( _Ptr->GetNode( "Statistic_Last_Error_Status" ) ); + static_cast (&Statistic_Last_Error_Status_Text)->SetReference( _Ptr->GetNode( "Statistic_Last_Error_Status_Text" ) ); + + } + + inline const char* CUsbTLParams_Params::_GetVendorName( void ) + { + return "Basler"; + } + + inline const char* CUsbTLParams_Params::_GetModelName( void ) + { + return "UsbTLParams"; + } + + //! \endcond + +} // namespace Basler_UsbTLParams + +#if GCC_DIAGNOSTIC_AWARE +# if GCC_DIAGNOSTIC_PUSH_POP_AWARE +# pragma GCC diagnostic pop +# else +# pragma GCC diagnostic warning "-Wdeprecated-declarations" +# endif +#endif + +#undef GENAPI_DEPRECATED_FEATURE +#endif // Basler_UsbTLParams_PARAMS_H diff --git a/Cigarette/Pylon6.2/include/pylonc/GenDC.h b/Cigarette/Pylon6.2/include/pylonc/GenDC.h new file mode 100644 index 0000000..8b72626 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/GenDC.h @@ -0,0 +1,576 @@ + +// ******************************************************************************* +// GenDC.h +// GenDC structures and defines header. +// Version 1.1.0.00 +// +//----------------------------------------------------------------------------- +// Copyright (c) 2018 by Matrox Electronic Systems Ltd. +// Section: GenDC +// Project: GenICam +// Author: Stephane Maurice +// $Header$ GenDC.H +// +// License: This file is published under the license of the EMVA GenICam Standard Group. +// A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. +// If for some reason you are missing this file please contact the EMVA or visit the website +// (http://www.genicam.org) for a full copy. +// +// THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP +// OR CONTRIBUTORS 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. +//----------------------------------------------------------------------------- +#pragma once +// Prevent multiple GenDC.H inclusion. +#ifndef GenDCH +#define GenDCH + +// Headers: +#ifndef _STDINT +#include +#endif +#ifndef PFNC_H +#include "PFNC.h" +#endif +#include // size_t + +// GenDC standard values: +// ----------------------------------- +// ----------------------------------- +#define GDC_SIGNATURE 0x43444E47 // "GNDC" Signature (not null terminated) +#define GDC_VERSION_MAJOR 0x01 +#define GDC_VERSION_MINOR 0x00 +#define GDC_VERSION_SUBMINOR 0x00 + +// Header Types +#define GDC_HEADER_TYPE_MASK 0xF000 +#define GDC_GENERIC_HEADER 0x0000 +#define GDC_CONTAINER_HEADER 0x1000 +#define GDC_COMPONENT_HEADER 0x2000 +#define GDC_PART_HEADER 0x4000 // 0x4000-0x4FFF reserved for sub Part Headers type. +#define GDC_FLOW_TABLE_HEADER 0x7000 + +// Component Types (from SFNC) +#define GDC_UNDEFINED_COMPONENT 0x00 +#define GDC_INTENSITY 0x01 +#define GDC_INFRARED 0x02 +#define GDC_ULTRAVIOLET 0x03 +#define GDC_RANGE 0x04 +#define GDC_REFLECTANCE 0x05 +#define GDC_CONFIDENCE 0x06 +#define GDC_DISPARITY 0x07 +#define GDC_SCATTER 0x08 +#define GDC_MULTISPECTRAL 0x09 +#define GDC_EXTENDED_COMPONENT 0x8000 +#define GDC_METADATA GDC_EXTENDED_COMPONENT+0x0001 +#define GDC_CUSTOM_COMPONENT GDC_EXTENDED_COMPONENT+0x7F00 // + 0x0-0xFE valid +#define GDC_RESERVED_COMPONENT GDC_EXTENDED_COMPONENT+0x7FFF + +// Part types +#define GDC_GENERIC_PART_TYPE_MASK GDC_PART_HEADER+0x0F00 +#define GDC_GENERIC_PART_METADATA GDC_PART_HEADER+0x0000 +#define GDC_GENERIC_PART_1D GDC_PART_HEADER+0x0100 +#define GDC_GENERIC_PART_2D GDC_PART_HEADER+0x0200 +#define GDC_GENERIC_PART_CUSTOM GDC_PART_HEADER+0x0F00 + +#define GDC_METADATA_GENICAM_CHUNK GDC_GENERIC_PART_METADATA+0 +#define GDC_METADATA_GENICAM_XML GDC_GENERIC_PART_METADATA+1 +#define GDC_METADATA_CUSTOM(x) GDC_GENERIC_PART_METADATA+0xF0+x // + 0x0-0xF valid +#define GDC_1D GDC_GENERIC_PART_1D+0x00 +#define GDC_1D_CUSTOM(x) GDC_GENERIC_PART_1D+0xF0+x // + 0x0-0xF valid +#define GDC_2D GDC_GENERIC_PART_2D+0x00 +#define GDC_2D_JPEG GDC_GENERIC_PART_2D+0x01 +#define GDC_2D_JPEG2000 GDC_GENERIC_PART_2D+0x02 +#define GDC_2D_H264 GDC_GENERIC_PART_2D+0x03 +#define GDC_2D_CUSTOM(x) GDC_GENERIC_PART_2D+0xF0+x // + 0x0-0xF valid +#define GDC_CUSTOM(x) GDC_GENERIC_PART_CUSTOM+x // + 0x0-0xFE valid + + +// GenDC objects forward declarations: +// ----------------------------------- +// ----------------------------------- +struct GenDCContainerHeader; +struct GenDCComponentHeader; +struct GenDCPartHeader; + +// GenDC types definitions. +// ------------------------ +// ------------------------ +// Pack all the structures. +#pragma pack(push, 1) + +// GenDC Container typedef and enumerations. +enum GenDCSignature : uint32_t { Signature_GNDC = GDC_SIGNATURE }; +typedef uint8_t GenDCVersionField; +enum GenDCVersionValue : GenDCVersionField { VersionMajorCurrent = GDC_VERSION_MAJOR, + VersionMinorCurrent = GDC_VERSION_MINOR, + VersionSubMinorCurrent = GDC_VERSION_SUBMINOR + }; // Ex: Version 01.01.00 +enum GenDCReservedValue { ReservedDefaultValue = 0x00 }; +typedef uint16_t GenDCHeaderTypeShared; +enum GenDCHeaderType : GenDCHeaderTypeShared { TypeHeaderMask = GDC_HEADER_TYPE_MASK, + TypeGeneric = GDC_GENERIC_HEADER, + TypeContainer = GDC_CONTAINER_HEADER, + TypeComponent = GDC_COMPONENT_HEADER, + TypePart = GDC_PART_HEADER, + TypeFlowTable = GDC_FLOW_TABLE_HEADER + }; +typedef uint32_t GenDCHeaderSize; +typedef uint16_t GenDCHeaderFlags; +union GenDCContainerFlagsGroup; +typedef uint64_t GenDCContainerId; +typedef uint64_t GenDCDataSize; +typedef int64_t GenDCOffset; +typedef uint32_t GenDCDescriptorSize; +typedef GenDCContainerHeader GenDCDescriptor; +typedef uint32_t GenDCContainerSectionFlag; +typedef uint32_t GenDCComponentCount; +typedef uint8_t GenDCContainerBuffer; +typedef uint64_t GenDCContainerBufferSize; + +typedef uint8_t GenDCData; +typedef uint8_t GenDCDataU8; +typedef uint16_t GenDCDataU16; +typedef uint32_t GenDCDataU32; +typedef uint64_t GenDCDataU64; +typedef void GenDCDataVoid; +typedef struct uint24_t /* 3 bytes pixel. Ex: RGB8. */ +{ + // Storage for the RGB or BGR 8 bit values + uint8_t PixelValue[3]; + + // Default copy constructor. + uint24_t(const uint24_t &GenDCDataU24Source) + { + for (int j = 0; j < 3; j++) + PixelValue[j] = GenDCDataU24Source.PixelValue[j]; + }; + + // Default conversion. + operator uint32_t() const + { + uint32_t PixelValue32; + for (int j = 0; j < 3; j++) + ((uint8_t*)(&PixelValue32))[j] = PixelValue[j]; + return (PixelValue32); + }; +} uint24_t; +typedef uint24_t GenDCDataU24; + +// GenDC Component typedef and enumerations. +typedef uint16_t GenDCGroupId; +typedef uint16_t GenDCSourceId; +typedef uint16_t GenDCRegionId; +typedef uint32_t GenDCRegionOffset; +typedef int64_t GenDCTimestamp; +typedef uint64_t GenDCComponentTypeId; +typedef PfncFormat GenDCFormat; +typedef uint16_t GenDCPartCount; +enum GenDCComponentType : GenDCComponentTypeId +{ + TypeUndefined = GDC_UNDEFINED_COMPONENT, TypeIntensity = GDC_INTENSITY, + TypeInfrared = GDC_INFRARED, TypeUltraviolet = GDC_ULTRAVIOLET, + TypeRange = GDC_RANGE, TypeReflectance = GDC_REFLECTANCE, + TypeConfidence = GDC_CONFIDENCE, TypeDisparity = GDC_DISPARITY, + TypeScatter = GDC_SCATTER, TypeMultispectral = GDC_MULTISPECTRAL, + TypeExtended = GDC_EXTENDED_COMPONENT, TypeMetadata = GDC_METADATA, + TypeCustomComponent = GDC_CUSTOM_COMPONENT, TypeReservedComponent = GDC_RESERVED_COMPONENT +}; + +// GenDC Part typedef and enumerations. +typedef uint64_t GenDCSize1D; +typedef int64_t GenDCSize1DSigned; +typedef uint32_t GenDCSize2D; +typedef GenDCSize1D GenDCSize; +typedef uint16_t GenDCPadding; +typedef uint64_t GenDCDataSize; +typedef uint16_t GenDCFlowId; +typedef uint32_t GenDCFlowCount; +typedef GenDCOffset GenDCFlowOffset; +enum GenDCGenericPartType : GenDCHeaderTypeShared +{ + TypeGenericPart = GDC_PART_HEADER, TypeGenericMetadata = GDC_GENERIC_PART_METADATA, + TypeGenericPart1D = GDC_GENERIC_PART_1D, TypeGenericPart2D = GDC_GENERIC_PART_2D, + TypeGenericCustom = GDC_GENERIC_PART_CUSTOM, TypeGenericPartMask = GDC_GENERIC_PART_TYPE_MASK, +}; +enum GenDCPartType : GenDCHeaderTypeShared +{ + TypeMetadataGenICamChunk = GDC_METADATA_GENICAM_CHUNK, TypeMetadataGenICamXML = GDC_METADATA_GENICAM_XML, + TypeMetadataCustom = GDC_METADATA_CUSTOM(0), Type1D = GDC_1D, + Type1DCustom = GDC_1D_CUSTOM(0), Type2D = GDC_2D, + TypeJPEG = GDC_2D_JPEG, TypeJPEG2000 = GDC_2D_JPEG2000, + TypeH264 = GDC_2D_H264, + Type2DCustom = GDC_2D_CUSTOM(0) +}; + +// General utility types and enumerations. +typedef uint8_t GenDCReserved8; +typedef uint16_t GenDCReserved16; +typedef uint32_t GenDCReserved32; +typedef uint64_t GenDCReserved64; +typedef const char* GenDCErrorMessage; +enum GenDCPredefinedValue32 : GenDCComponentCount { GenDCAllComponents = 0xFFFFFFFF, GenDCAllFlows = 0xFFFFFFFF }; +enum GenDCPredefinedValue16 : GenDCPartCount { GenDCAllParts = 0xFFFF }; +enum GenDCPredefinedValue64 : uint64_t { GenDCAllData = 0x8FFFFFFFFFFFFFFF, GenDCCenter = 0x8FFFFFFFFFFFFFFE }; +enum GenDCPredefinedComponentValue : GenDCComponentCount { GenDCInvalidComponentIndex = 0xFFFFFFFF }; +enum GenDCPredefinedPartValue : GenDCPartCount { GenDCInvalidPartIndex = 0xFFFF }; + +// Typedef to avoid warning for 32 or 64 bit compilation. +#ifndef WIN32 +typedef GenDCDataSize GenDCAllocationDataSize; +#else +typedef unsigned GenDCAllocationDataSize; +#endif + + +//GenDC headers structures: +//----------------------------------------- +//----------------------------------------- + +// Container's Flags bit fields structure. +// --------------------------------------- +union GenDCContainerFlagsGroup // Container's Flags. +{ + GenDCHeaderFlags Value; + struct + { + GenDCHeaderFlags TimestampPTP : 1; + GenDCHeaderFlags ComponentInvalid : 1; + GenDCHeaderFlags Reserved : 14; + } Field; +}; + +// Container's VariableFields flags bit fields structure. +// ------------------------------------------------------ +union GenDCContainerVariableFieldsGroup // Container's Flags. +{ + GenDCHeaderFlags Value; + struct + { + GenDCHeaderFlags DataSize : 1; + GenDCHeaderFlags SizeX : 1; + GenDCHeaderFlags SizeY : 1; + GenDCHeaderFlags RegionOffset : 1; + GenDCHeaderFlags Format : 1; + GenDCHeaderFlags Timestamp : 1; + GenDCHeaderFlags ComponentCount : 1; + GenDCHeaderFlags ComponentInvalid: 1; + GenDCHeaderFlags Reserved : 8; + } Field; +}; + + +// GenDC Container header base. +//----------------------------- +struct GenDCContainerHeaderBase +{ + GenDCSignature Signature; + GenDCVersionField VersionMajor; + GenDCVersionField VersionMinor; + GenDCVersionField VersionSubMinor; + GenDCReserved8 Reserved; + GenDCHeaderType HeaderType; + GenDCContainerFlagsGroup Flags; + GenDCHeaderSize HeaderSize; + GenDCContainerId Id; + GenDCContainerVariableFieldsGroup VariableFields; + GenDCReserved16 Reserved16; + GenDCReserved32 Reserved32; + GenDCDataSize DataSize; + GenDCOffset DataOffset; + GenDCDescriptorSize DescriptorSize; + GenDCComponentCount ComponentCount; + // GenDCOffset ComponentOffsets[ComponentCount]; field not included in base class. +}; + +// GenDC Container header (including a Component PartOffset array member). +//------------------------------------------------------------------------ +#define GDC_CONTAINER_COMPONENT_COUNT_MIN 1 +struct GenDCContainerHeader : GenDCContainerHeaderBase +{ + // GenDCOffset ComponentOffsets[ComponentCount]; minimal Component Offset(s) included. + // This allow to use Container.ComponentOffsets[ComponentIndex]. + // Note: sizeof(GenDCContainerHeader) must not be used if ComponentCount > 1. + // Note: Only GenDCContaineHeader reference (GenDCContainerHeader &) can be used as destination to operator = + // since the default copy constructor will not copy all the ComponentOffset members; + // Use only GenDCContaineHeader &Container = AnotherGenDCContaineHeader. + GenDCOffset ComponentOffsets[GDC_CONTAINER_COMPONENT_COUNT_MIN]; + + // Default constructor for "ContainerHeader &". + // GenDCContainerHeader() {;}; + + // Deleted default copy constructor since it will not copy all the ComponentOffsets[] members. + // It would also not point to the real Container header memory Offset. + // Use a reference instead (Ex: GenDCContainerHeader& MyContainer = ...;) or a pointer. + // GenDCContainerHeader(GenDCContainerHeader &) = delete; +}; + + +// Component's Flags bit fields structure. +// --------------------------------------- +union GenDCComponentFlagsGroup // Component's Flags. +{ + GenDCHeaderFlags Value; + struct + { + GenDCHeaderFlags Invalid : 1; + GenDCHeaderFlags Unallocated : 15; + } Field; +}; + + +// GenDC Component header base. +// ---------------------------- +struct GenDCComponentHeaderBase +{ + GenDCHeaderType HeaderType; + GenDCComponentFlagsGroup Flags; + GenDCHeaderSize HeaderSize; + GenDCReserved16 Reserved; + GenDCGroupId GroupId; + GenDCSourceId SourceId; + GenDCRegionId RegionId; + GenDCRegionOffset RegionOffsetX; + GenDCRegionOffset RegionOffsetY; + GenDCTimestamp Timestamp; + GenDCComponentTypeId TypeId; + GenDCFormat Format; + GenDCReserved16 Reserved2; + GenDCPartCount PartCount; + // GenDCOffset PartOffsets[PartCount]; // This field is not included in base class. +}; + +// GenDC Component header (including a PartOffset[] array member). +//----------------------------------------------------------------- +#define GDC_COMPONENT_PART_COUNT_MIN 1 +struct GenDCComponentHeader : GenDCComponentHeaderBase +{ + // GenDCOffset PartOffsets[PartCount]; minimal Component Offset(s) included. + // This allow to use Component.PartOffsets[ComponentIndex]. + // Note: sizeof(GenDCComponent Header) must not be used if ComponentCount > 1. + // Note: Only GenDCComponent header reference (GenDCPart Header &) can be used as destination to operator = + // since the default copy constructor will not copy all the PartOffsets members; + // Use only GenDCComponentHeader &Component = AnotherGenDCComponentHeader. + GenDCOffset PartOffsets[GDC_COMPONENT_PART_COUNT_MIN]; + + // Default constructor for "ComponentHeader &". + GenDCComponentHeader() { ; }; + + // Deleted default copy constructor since it will not copy all the Parts header members. + // It would also not point to the real Component header memory Offset. + // Use a reference instead (Ex: GenDCCoponenHeader& MyComponent = ...;) or a pointer. + GenDCComponentHeader(GenDCComponentHeader &) = delete; +}; + +// Part's Flags bit fields structure. +// --------------------------------------- +union GenDCPartFlagsGroup // Part's Flags. +{ + GenDCHeaderFlags Value; + struct + { + GenDCHeaderFlags Unallocated : 16; + } Field; +}; + +// GenDC Part header common fields. +// -------------------------------- +struct GenDCPartHeaderBase +{ + GenDCPartType HeaderType; + GenDCPartFlagsGroup Flags; + GenDCHeaderSize HeaderSize; + GenDCFormat Format; + GenDCReserved16 Reserved; + GenDCFlowId FlowId; + GenDCFlowOffset FlowOffset; + GenDCDataSize DataSize; + GenDCOffset DataOffset; +}; + +// GenDC generic standard Part header. +//------------------------------------ +struct GenDCPartHeader : public GenDCPartHeaderBase // Add no field compared to base class. +{ + // Default constructor for "PartHeader &". + GenDCPartHeader() { ; }; + + // Deleted default copy constructor since it will not copy all Part type specific members. + // It would also not point to the real Part header memory Offset. + // Use a reference instead (Ex: GenDCPartHeader& MyPart = ...;) or a pointer. + GenDCPartHeader(GenDCPartHeader &) = delete; +}; + +// GenDC 2D Part header base +//--------------------------- +struct GenDCPartHeader2DBase : public GenDCPartHeader +{ + GenDCSize2D SizeX; + GenDCSize2D SizeY; + GenDCPadding PaddingX; + GenDCPadding PaddingY; + GenDCReserved32 InfoReserved; +}; + +// GenDC 2D uncompressed Part header +//----------------------------------- +#define GDC_1D_2D_IMAGE_INFO_RESERVED_COUNT 1 +struct GenDCPartHeader2D : public GenDCPartHeader2DBase +{ +}; + +// GenDC 2D JPEG and JPEG200 standard Type specific info. +//------------------------------------------------------- +struct GenDCInfoTypeSpecificJPEG +{ +}; + +// GenDC 2D JPEG standard Part header. +//------------------------------------ +struct GenDCPartHeaderJPEG : public GenDCPartHeader2DBase +{ +}; + +// GenDC 2D JPEG2000 standard Part header. +//---------------------------------------- +struct GenDCPartHeaderJPEG2000 : public GenDCPartHeader2DBase +{ +}; + +// Part Info field interpretation structure for H.264. +struct GenDCInfoTypeSpecificH264 +{ + uint8_t Reserved; + uint8_t ProfileIDC; + union H264Flags + { + uint8_t CS_set0_flag : 1; + uint8_t CS_set1_flag : 1; + uint8_t CS_set2_flag : 1; + uint8_t CS_set3_flag : 1; + uint8_t PM : 2; + uint8_t RF : 2; + } Flags; + uint8_t LevelIDC; + uint16_t SpropInterleavingDepth; + uint16_t SpropMaxDonDiff; + uint32_t SpropDeintBufReq; + uint32_t SpropInitBufTime; +}; + +// GenDC 2D H.264 compressed Part header. +// -------------------------------------- +struct GenDCPartHeaderH264 : public GenDCPartHeader2DBase +{ + GenDCInfoTypeSpecificH264 InfoTypeSpecific; +}; + +// GenDC 1D uncompressed Part header. +// ---------------------------------- +struct GenDCPartHeader1DBase : GenDCPartHeader +{ + GenDCSize1D SizeX; + GenDCPadding PaddingX; + GenDCReserved16 PaddingReserved; + GenDCReserved32 InfoReserved; + uint64_t InfoTypeSpecific; +}; + +// GenDC 1D uncompressed Part header. +// ---------------------------------- +struct GenDCPartHeader1D : GenDCPartHeader1DBase +{ +}; + +// GenDC GenICam Chunk Metadata Part header. +// ----------------------------------------- +struct GenDCPartHeaderGenICamChunk : GenDCPartHeader1DBase +{ +// For GenICam Chunk metadata Part, InfoTypeSpecific[] should contain the GenICam chunk_layout_id. +}; + +// GenDC GenICam XML Metadata Part header. +// --------------------------------------- +struct GenDCPartHeaderGenICamXML: GenDCPartHeader1DBase +{ + // For GenICam XML metadata Part, InfoTypeSpecific[] should contain the GenICam XML_layout_id. +}; + +// GenDC Container Descriptor Template declaration. +// Assuming that all the Components and their 2D Parts are all symmetrical. +template +struct ContainerDescriptorTemplate2D : GenDCContainerHeaderBase +{ + // Container header base fields followed by the ComponentOffset. + GenDCOffset ComponentOffsets[_ComponentCount]; + + // Including a Component header base followed by the PartOffset. + struct : GenDCComponentHeaderBase + { + GenDCOffset PartOffsets[_PartCount]; + + // Including Part headers. + struct : GenDCPartHeader2D + { + } Parts[_PartCount]; + } Components[_ComponentCount]; +}; + +// GenDC Container Descriptor for a single 2D Component declaration. +// Assuming 1 Components and 1 2D Part. +struct ContainerDescriptorSingleComponent2D : GenDCContainerHeaderBase +{ + // Container header base fields followed by a single ComponentOffset. + GenDCOffset ComponentOffsets[1]; + // Including a Component header base followed by a single PartOffset. + struct : GenDCComponentHeaderBase + { + GenDCOffset PartOffsets[1]; + + // Including a Part header. + struct : GenDCPartHeader2D + { + } Part; + } Component; +}; + +// Flow table base header. +// ------------------------- +struct GenDCFlowTableHeader +{ + GenDCHeaderType HeaderType; + GenDCHeaderFlags Flags; + GenDCHeaderSize HeaderSize; + GenDCVersionField VersionMajor; + GenDCVersionField VersionMinor; + GenDCReserved16 Reserved; + GenDCFlowCount FlowCount; +}; + +// Flow table with one entry (Note: sizeof(GenDCFlowTable) invalid). +// ------------------------- +struct GenDCFlowTable : GenDCFlowTableHeader +{ + uint64_t FlowSize[1]; // Stub array field for easy access using FlowTable.FlowSize[n]. +}; + +// Flow table template. +// ------------------------- +template +struct GenDCFlowTableTemplate : GenDCFlowTableHeader +{ + uint64_t FlowSize[_FlowCount]; +}; + +// Restore packing. +#pragma pack(pop) + +#endif // #ifndef GenDCH diff --git a/Cigarette/Pylon6.2/include/pylonc/PFNC.h b/Cigarette/Pylon6.2/include/pylonc/PFNC.h new file mode 100644 index 0000000..4072c08 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PFNC.h @@ -0,0 +1,1177 @@ +/************************************************************************************************************** + * This file was automatically generated by tools designed and maintained by Leutron Vision, Matrox, Groget, MVTec Software. + * Copyright (C) 2007-2018 Leutron Vision, Matrox, Groget, MVTec Software. + * You can freely use and modify the file without restrictions. + * The file is provided as is, without any warranty. Bug reports and other feedback is appreciated. + ************************************************************************************************************** + * + ************************************************************************************************************** + * Version and date information: + * PFNC value list release date: 2019-02-19 + * Header generator version: 3.4 + * Header generation date: 2019-02-19 + **************************************************************************************************************/ + +#ifndef PFNC_H +#define PFNC_H + +#define PFNC_Mono1p 0x01010037 /* Monochrome 1-bit packed */ +#define PFNC_Mono2p 0x01020038 /* Monochrome 2-bit packed */ +#define PFNC_Mono4p 0x01040039 /* Monochrome 4-bit packed */ +#define PFNC_Mono8 0x01080001 /* Monochrome 8-bit */ +#define PFNC_Mono8s 0x01080002 /* Monochrome 8-bit signed */ +#define PFNC_Mono10 0x01100003 /* Monochrome 10-bit unpacked */ +#define PFNC_Mono10p 0x010A0046 /* Monochrome 10-bit packed */ +#define PFNC_Mono12 0x01100005 /* Monochrome 12-bit unpacked */ +#define PFNC_Mono12p 0x010C0047 /* Monochrome 12-bit packed */ +#define PFNC_Mono14 0x01100025 /* Monochrome 14-bit unpacked */ +#define PFNC_Mono14p 0x010E0104 /* Monochrome 14-bit packed */ +#define PFNC_Mono16 0x01100007 /* Monochrome 16-bit */ +#define PFNC_Mono32 0x01200111 /* Monochrome 32-bit */ +#define PFNC_BayerBG4p 0x01040110 /* Bayer Blue-Green 4-bit packed */ +#define PFNC_BayerBG8 0x0108000B /* Bayer Blue-Green 8-bit */ +#define PFNC_BayerBG10 0x0110000F /* Bayer Blue-Green 10-bit unpacked */ +#define PFNC_BayerBG10p 0x010A0052 /* Bayer Blue-Green 10-bit packed */ +#define PFNC_BayerBG12 0x01100013 /* Bayer Blue-Green 12-bit unpacked */ +#define PFNC_BayerBG12p 0x010C0053 /* Bayer Blue-Green 12-bit packed */ +#define PFNC_BayerBG14 0x0110010C /* Bayer Blue-Green 14-bit */ +#define PFNC_BayerBG14p 0x010E0108 /* Bayer Blue-Green 14-bit packed */ +#define PFNC_BayerBG16 0x01100031 /* Bayer Blue-Green 16-bit */ +#define PFNC_BayerGB4p 0x0104010F /* Bayer Green-Blue 4-bit packed */ +#define PFNC_BayerGB8 0x0108000A /* Bayer Green-Blue 8-bit */ +#define PFNC_BayerGB10 0x0110000E /* Bayer Green-Blue 10-bit unpacked */ +#define PFNC_BayerGB10p 0x010A0054 /* Bayer Green-Blue 10-bit packed */ +#define PFNC_BayerGB12 0x01100012 /* Bayer Green-Blue 12-bit unpacked */ +#define PFNC_BayerGB12p 0x010C0055 /* Bayer Green-Blue 12-bit packed */ +#define PFNC_BayerGB14 0x0110010B /* Bayer Green-Blue 14-bit */ +#define PFNC_BayerGB14p 0x010E0107 /* Bayer Green-Blue 14-bit packed */ +#define PFNC_BayerGB16 0x01100030 /* Bayer Green-Blue 16-bit */ +#define PFNC_BayerGR4p 0x0104010D /* Bayer Green-Red 4-bit packed */ +#define PFNC_BayerGR8 0x01080008 /* Bayer Green-Red 8-bit */ +#define PFNC_BayerGR10 0x0110000C /* Bayer Green-Red 10-bit unpacked */ +#define PFNC_BayerGR10p 0x010A0056 /* Bayer Green-Red 10-bit packed */ +#define PFNC_BayerGR12 0x01100010 /* Bayer Green-Red 12-bit unpacked */ +#define PFNC_BayerGR12p 0x010C0057 /* Bayer Green-Red 12-bit packed */ +#define PFNC_BayerGR14 0x01100109 /* Bayer Green-Red 14-bit */ +#define PFNC_BayerGR14p 0x010E0105 /* Bayer Green-Red 14-bit packed */ +#define PFNC_BayerGR16 0x0110002E /* Bayer Green-Red 16-bit */ +#define PFNC_BayerRG4p 0x0104010E /* Bayer Red-Green 4-bit packed */ +#define PFNC_BayerRG8 0x01080009 /* Bayer Red-Green 8-bit */ +#define PFNC_BayerRG10 0x0110000D /* Bayer Red-Green 10-bit unpacked */ +#define PFNC_BayerRG10p 0x010A0058 /* Bayer Red-Green 10-bit packed */ +#define PFNC_BayerRG12 0x01100011 /* Bayer Red-Green 12-bit unpacked */ +#define PFNC_BayerRG12p 0x010C0059 /* Bayer Red-Green 12-bit packed */ +#define PFNC_BayerRG14 0x0110010A /* Bayer Red-Green 14-bit */ +#define PFNC_BayerRG14p 0x010E0106 /* Bayer Red-Green 14-bit packed */ +#define PFNC_BayerRG16 0x0110002F /* Bayer Red-Green 16-bit */ +#define PFNC_RGBa8 0x02200016 /* Red-Green-Blue-alpha 8-bit */ +#define PFNC_RGBa10 0x0240005F /* Red-Green-Blue-alpha 10-bit unpacked */ +#define PFNC_RGBa10p 0x02280060 /* Red-Green-Blue-alpha 10-bit packed */ +#define PFNC_RGBa12 0x02400061 /* Red-Green-Blue-alpha 12-bit unpacked */ +#define PFNC_RGBa12p 0x02300062 /* Red-Green-Blue-alpha 12-bit packed */ +#define PFNC_RGBa14 0x02400063 /* Red-Green-Blue-alpha 14-bit unpacked */ +#define PFNC_RGBa16 0x02400064 /* Red-Green-Blue-alpha 16-bit */ +#define PFNC_RGB8 0x02180014 /* Red-Green-Blue 8-bit */ +#define PFNC_RGB8_Planar 0x02180021 /* Red-Green-Blue 8-bit planar */ +#define PFNC_RGB10 0x02300018 /* Red-Green-Blue 10-bit unpacked */ +#define PFNC_RGB10_Planar 0x02300022 /* Red-Green-Blue 10-bit unpacked planar */ +#define PFNC_RGB10p 0x021E005C /* Red-Green-Blue 10-bit packed */ +#define PFNC_RGB10p32 0x0220001D /* Red-Green-Blue 10-bit packed into 32-bit */ +#define PFNC_RGB12 0x0230001A /* Red-Green-Blue 12-bit unpacked */ +#define PFNC_RGB12_Planar 0x02300023 /* Red-Green-Blue 12-bit unpacked planar */ +#define PFNC_RGB12p 0x0224005D /* Red-Green-Blue 12-bit packed */ +#define PFNC_RGB14 0x0230005E /* Red-Green-Blue 14-bit unpacked */ +#define PFNC_RGB16 0x02300033 /* Red-Green-Blue 16-bit */ +#define PFNC_RGB16_Planar 0x02300024 /* Red-Green-Blue 16-bit planar */ +#define PFNC_RGB565p 0x02100035 /* Red-Green-Blue 5/6/5-bit packed */ +#define PFNC_BGRa8 0x02200017 /* Blue-Green-Red-alpha 8-bit */ +#define PFNC_BGRa10 0x0240004C /* Blue-Green-Red-alpha 10-bit unpacked */ +#define PFNC_BGRa10p 0x0228004D /* Blue-Green-Red-alpha 10-bit packed */ +#define PFNC_BGRa12 0x0240004E /* Blue-Green-Red-alpha 12-bit unpacked */ +#define PFNC_BGRa12p 0x0230004F /* Blue-Green-Red-alpha 12-bit packed */ +#define PFNC_BGRa14 0x02400050 /* Blue-Green-Red-alpha 14-bit unpacked */ +#define PFNC_BGRa16 0x02400051 /* Blue-Green-Red-alpha 16-bit */ +#define PFNC_BGR8 0x02180015 /* Blue-Green-Red 8-bit */ +#define PFNC_BGR10 0x02300019 /* Blue-Green-Red 10-bit unpacked */ +#define PFNC_BGR10p 0x021E0048 /* Blue-Green-Red 10-bit packed */ +#define PFNC_BGR12 0x0230001B /* Blue-Green-Red 12-bit unpacked */ +#define PFNC_BGR12p 0x02240049 /* Blue-Green-Red 12-bit packed */ +#define PFNC_BGR14 0x0230004A /* Blue-Green-Red 14-bit unpacked */ +#define PFNC_BGR16 0x0230004B /* Blue-Green-Red 16-bit */ +#define PFNC_BGR565p 0x02100036 /* Blue-Green-Red 5/6/5-bit packed */ +#define PFNC_R8 0x010800C9 /* Red 8-bit */ +#define PFNC_R10 0x010A00CA /* Red 10-bit */ +#define PFNC_R12 0x010C00CB /* Red 12-bit */ +#define PFNC_R16 0x011000CC /* Red 16-bit */ +#define PFNC_G8 0x010800CD /* Green 8-bit */ +#define PFNC_G10 0x010A00CE /* Green 10-bit */ +#define PFNC_G12 0x010C00CF /* Green 12-bit */ +#define PFNC_G16 0x011000D0 /* Green 16-bit */ +#define PFNC_B8 0x010800D1 /* Blue 8-bit */ +#define PFNC_B10 0x010A00D2 /* Blue 10-bit */ +#define PFNC_B12 0x010C00D3 /* Blue 12-bit */ +#define PFNC_B16 0x011000D4 /* Blue 16-bit */ +#define PFNC_Coord3D_ABC8 0x021800B2 /* 3D coordinate A-B-C 8-bit */ +#define PFNC_Coord3D_ABC8_Planar 0x021800B3 /* 3D coordinate A-B-C 8-bit planar */ +#define PFNC_Coord3D_ABC10p 0x021E00DB /* 3D coordinate A-B-C 10-bit packed */ +#define PFNC_Coord3D_ABC10p_Planar 0x021E00DC /* 3D coordinate A-B-C 10-bit packed planar */ +#define PFNC_Coord3D_ABC12p 0x022400DE /* 3D coordinate A-B-C 12-bit packed */ +#define PFNC_Coord3D_ABC12p_Planar 0x022400DF /* 3D coordinate A-B-C 12-bit packed planar */ +#define PFNC_Coord3D_ABC16 0x023000B9 /* 3D coordinate A-B-C 16-bit */ +#define PFNC_Coord3D_ABC16_Planar 0x023000BA /* 3D coordinate A-B-C 16-bit planar */ +#define PFNC_Coord3D_ABC32f 0x026000C0 /* 3D coordinate A-B-C 32-bit floating point */ +#define PFNC_Coord3D_ABC32f_Planar 0x026000C1 /* 3D coordinate A-B-C 32-bit floating point planar */ +#define PFNC_Coord3D_AC8 0x021000B4 /* 3D coordinate A-C 8-bit */ +#define PFNC_Coord3D_AC8_Planar 0x021000B5 /* 3D coordinate A-C 8-bit planar */ +#define PFNC_Coord3D_AC10p 0x021400F0 /* 3D coordinate A-C 10-bit packed */ +#define PFNC_Coord3D_AC10p_Planar 0x021400F1 /* 3D coordinate A-C 10-bit packed planar */ +#define PFNC_Coord3D_AC12p 0x021800F2 /* 3D coordinate A-C 12-bit packed */ +#define PFNC_Coord3D_AC12p_Planar 0x021800F3 /* 3D coordinate A-C 12-bit packed planar */ +#define PFNC_Coord3D_AC16 0x022000BB /* 3D coordinate A-C 16-bit */ +#define PFNC_Coord3D_AC16_Planar 0x022000BC /* 3D coordinate A-C 16-bit planar */ +#define PFNC_Coord3D_AC32f 0x024000C2 /* 3D coordinate A-C 32-bit floating point */ +#define PFNC_Coord3D_AC32f_Planar 0x024000C3 /* 3D coordinate A-C 32-bit floating point planar */ +#define PFNC_Coord3D_A8 0x010800AF /* 3D coordinate A 8-bit */ +#define PFNC_Coord3D_A10p 0x010A00D5 /* 3D coordinate A 10-bit packed */ +#define PFNC_Coord3D_A12p 0x010C00D8 /* 3D coordinate A 12-bit packed */ +#define PFNC_Coord3D_A16 0x011000B6 /* 3D coordinate A 16-bit */ +#define PFNC_Coord3D_A32f 0x012000BD /* 3D coordinate A 32-bit floating point */ +#define PFNC_Coord3D_B8 0x010800B0 /* 3D coordinate B 8-bit */ +#define PFNC_Coord3D_B10p 0x010A00D6 /* 3D coordinate B 10-bit packed */ +#define PFNC_Coord3D_B12p 0x010C00D9 /* 3D coordinate B 12-bit packed */ +#define PFNC_Coord3D_B16 0x011000B7 /* 3D coordinate B 16-bit */ +#define PFNC_Coord3D_B32f 0x012000BE /* 3D coordinate B 32-bit floating point */ +#define PFNC_Coord3D_C8 0x010800B1 /* 3D coordinate C 8-bit */ +#define PFNC_Coord3D_C10p 0x010A00D7 /* 3D coordinate C 10-bit packed */ +#define PFNC_Coord3D_C12p 0x010C00DA /* 3D coordinate C 12-bit packed */ +#define PFNC_Coord3D_C16 0x011000B8 /* 3D coordinate C 16-bit */ +#define PFNC_Coord3D_C32f 0x012000BF /* 3D coordinate C 32-bit floating point */ +#define PFNC_Confidence1 0x010800C4 /* Confidence 1-bit unpacked */ +#define PFNC_Confidence1p 0x010100C5 /* Confidence 1-bit packed */ +#define PFNC_Confidence8 0x010800C6 /* Confidence 8-bit */ +#define PFNC_Confidence16 0x011000C7 /* Confidence 16-bit */ +#define PFNC_Confidence32f 0x012000C8 /* Confidence 32-bit floating point */ +#define PFNC_BiColorBGRG8 0x021000A6 /* Bi-color Blue/Green - Red/Green 8-bit */ +#define PFNC_BiColorBGRG10 0x022000A9 /* Bi-color Blue/Green - Red/Green 10-bit unpacked */ +#define PFNC_BiColorBGRG10p 0x021400AA /* Bi-color Blue/Green - Red/Green 10-bit packed */ +#define PFNC_BiColorBGRG12 0x022000AD /* Bi-color Blue/Green - Red/Green 12-bit unpacked */ +#define PFNC_BiColorBGRG12p 0x021800AE /* Bi-color Blue/Green - Red/Green 12-bit packed */ +#define PFNC_BiColorRGBG8 0x021000A5 /* Bi-color Red/Green - Blue/Green 8-bit */ +#define PFNC_BiColorRGBG10 0x022000A7 /* Bi-color Red/Green - Blue/Green 10-bit unpacked */ +#define PFNC_BiColorRGBG10p 0x021400A8 /* Bi-color Red/Green - Blue/Green 10-bit packed */ +#define PFNC_BiColorRGBG12 0x022000AB /* Bi-color Red/Green - Blue/Green 12-bit unpacked */ +#define PFNC_BiColorRGBG12p 0x021800AC /* Bi-color Red/Green - Blue/Green 12-bit packed */ +#define PFNC_Data8 0x01080116 /* Data 8-bit */ +#define PFNC_Data8s 0x01080117 /* Data 8-bit signed */ +#define PFNC_Data16 0x01100118 /* Data 16-bit */ +#define PFNC_Data16s 0x01100119 /* Data 16-bit signed */ +#define PFNC_Data32 0x0120011A /* Data 32-bit */ +#define PFNC_Data32f 0x0120011C /* Data 32-bit floating point */ +#define PFNC_Data32s 0x0120011B /* Data 32-bit signed */ +#define PFNC_Data64 0x0140011D /* Data 64-bit */ +#define PFNC_Data64f 0x0140011F /* Data 64-bit floating point */ +#define PFNC_Data64s 0x0140011E /* Data 64-bit signed */ +#define PFNC_SCF1WBWG8 0x01080067 /* Sparse Color Filter #1 White-Blue-White-Green 8-bit */ +#define PFNC_SCF1WBWG10 0x01100068 /* Sparse Color Filter #1 White-Blue-White-Green 10-bit unpacked */ +#define PFNC_SCF1WBWG10p 0x010A0069 /* Sparse Color Filter #1 White-Blue-White-Green 10-bit packed */ +#define PFNC_SCF1WBWG12 0x0110006A /* Sparse Color Filter #1 White-Blue-White-Green 12-bit unpacked */ +#define PFNC_SCF1WBWG12p 0x010C006B /* Sparse Color Filter #1 White-Blue-White-Green 12-bit packed */ +#define PFNC_SCF1WBWG14 0x0110006C /* Sparse Color Filter #1 White-Blue-White-Green 14-bit unpacked */ +#define PFNC_SCF1WBWG16 0x0110006D /* Sparse Color Filter #1 White-Blue-White-Green 16-bit unpacked */ +#define PFNC_SCF1WGWB8 0x0108006E /* Sparse Color Filter #1 White-Green-White-Blue 8-bit */ +#define PFNC_SCF1WGWB10 0x0110006F /* Sparse Color Filter #1 White-Green-White-Blue 10-bit unpacked */ +#define PFNC_SCF1WGWB10p 0x010A0070 /* Sparse Color Filter #1 White-Green-White-Blue 10-bit packed */ +#define PFNC_SCF1WGWB12 0x01100071 /* Sparse Color Filter #1 White-Green-White-Blue 12-bit unpacked */ +#define PFNC_SCF1WGWB12p 0x010C0072 /* Sparse Color Filter #1 White-Green-White-Blue 12-bit packed */ +#define PFNC_SCF1WGWB14 0x01100073 /* Sparse Color Filter #1 White-Green-White-Blue 14-bit unpacked */ +#define PFNC_SCF1WGWB16 0x01100074 /* Sparse Color Filter #1 White-Green-White-Blue 16-bit */ +#define PFNC_SCF1WGWR8 0x01080075 /* Sparse Color Filter #1 White-Green-White-Red 8-bit */ +#define PFNC_SCF1WGWR10 0x01100076 /* Sparse Color Filter #1 White-Green-White-Red 10-bit unpacked */ +#define PFNC_SCF1WGWR10p 0x010A0077 /* Sparse Color Filter #1 White-Green-White-Red 10-bit packed */ +#define PFNC_SCF1WGWR12 0x01100078 /* Sparse Color Filter #1 White-Green-White-Red 12-bit unpacked */ +#define PFNC_SCF1WGWR12p 0x010C0079 /* Sparse Color Filter #1 White-Green-White-Red 12-bit packed */ +#define PFNC_SCF1WGWR14 0x0110007A /* Sparse Color Filter #1 White-Green-White-Red 14-bit unpacked */ +#define PFNC_SCF1WGWR16 0x0110007B /* Sparse Color Filter #1 White-Green-White-Red 16-bit */ +#define PFNC_SCF1WRWG8 0x0108007C /* Sparse Color Filter #1 White-Red-White-Green 8-bit */ +#define PFNC_SCF1WRWG10 0x0110007D /* Sparse Color Filter #1 White-Red-White-Green 10-bit unpacked */ +#define PFNC_SCF1WRWG10p 0x010A007E /* Sparse Color Filter #1 White-Red-White-Green 10-bit packed */ +#define PFNC_SCF1WRWG12 0x0110007F /* Sparse Color Filter #1 White-Red-White-Green 12-bit unpacked */ +#define PFNC_SCF1WRWG12p 0x010C0080 /* Sparse Color Filter #1 White-Red-White-Green 12-bit packed */ +#define PFNC_SCF1WRWG14 0x01100081 /* Sparse Color Filter #1 White-Red-White-Green 14-bit unpacked */ +#define PFNC_SCF1WRWG16 0x01100082 /* Sparse Color Filter #1 White-Red-White-Green 16-bit */ +#define PFNC_YCbCr8 0x0218005B /* YCbCr 4:4:4 8-bit */ +#define PFNC_YCbCr8_CbYCr 0x0218003A /* YCbCr 4:4:4 8-bit */ +#define PFNC_YCbCr10_CbYCr 0x02300083 /* YCbCr 4:4:4 10-bit unpacked */ +#define PFNC_YCbCr10p_CbYCr 0x021E0084 /* YCbCr 4:4:4 10-bit packed */ +#define PFNC_YCbCr12_CbYCr 0x02300085 /* YCbCr 4:4:4 12-bit unpacked */ +#define PFNC_YCbCr12p_CbYCr 0x02240086 /* YCbCr 4:4:4 12-bit packed */ +#define PFNC_YCbCr411_8 0x020C005A /* YCbCr 4:1:1 8-bit */ +#define PFNC_YCbCr411_8_CbYYCrYY 0x020C003C /* YCbCr 4:1:1 8-bit */ +#define PFNC_YCbCr420_8_YY_CbCr_Semiplanar 0x020C0112 /* YCbCr 4:2:0 8-bit YY/CbCr Semiplanar */ +#define PFNC_YCbCr420_8_YY_CrCb_Semiplanar 0x020C0114 /* YCbCr 4:2:0 8-bit YY/CrCb Semiplanar */ +#define PFNC_YCbCr422_8 0x0210003B /* YCbCr 4:2:2 8-bit */ +#define PFNC_YCbCr422_8_CbYCrY 0x02100043 /* YCbCr 4:2:2 8-bit */ +#define PFNC_YCbCr422_8_YY_CbCr_Semiplanar 0x02100113 /* YCbCr 4:2:2 8-bit YY/CbCr Semiplanar */ +#define PFNC_YCbCr422_8_YY_CrCb_Semiplanar 0x02100115 /* YCbCr 4:2:2 8-bit YY/CrCb Semiplanar */ +#define PFNC_YCbCr422_10 0x02200065 /* YCbCr 4:2:2 10-bit unpacked */ +#define PFNC_YCbCr422_10_CbYCrY 0x02200099 /* YCbCr 4:2:2 10-bit unpacked */ +#define PFNC_YCbCr422_10p 0x02140087 /* YCbCr 4:2:2 10-bit packed */ +#define PFNC_YCbCr422_10p_CbYCrY 0x0214009A /* YCbCr 4:2:2 10-bit packed */ +#define PFNC_YCbCr422_12 0x02200066 /* YCbCr 4:2:2 12-bit unpacked */ +#define PFNC_YCbCr422_12_CbYCrY 0x0220009B /* YCbCr 4:2:2 12-bit unpacked */ +#define PFNC_YCbCr422_12p 0x02180088 /* YCbCr 4:2:2 12-bit packed */ +#define PFNC_YCbCr422_12p_CbYCrY 0x0218009C /* YCbCr 4:2:2 12-bit packed */ +#define PFNC_YCbCr601_8_CbYCr 0x0218003D /* YCbCr 4:4:4 8-bit BT.601 */ +#define PFNC_YCbCr601_10_CbYCr 0x02300089 /* YCbCr 4:4:4 10-bit unpacked BT.601 */ +#define PFNC_YCbCr601_10p_CbYCr 0x021E008A /* YCbCr 4:4:4 10-bit packed BT.601 */ +#define PFNC_YCbCr601_12_CbYCr 0x0230008B /* YCbCr 4:4:4 12-bit unpacked BT.601 */ +#define PFNC_YCbCr601_12p_CbYCr 0x0224008C /* YCbCr 4:4:4 12-bit packed BT.601 */ +#define PFNC_YCbCr601_411_8_CbYYCrYY 0x020C003F /* YCbCr 4:1:1 8-bit BT.601 */ +#define PFNC_YCbCr601_422_8 0x0210003E /* YCbCr 4:2:2 8-bit BT.601 */ +#define PFNC_YCbCr601_422_8_CbYCrY 0x02100044 /* YCbCr 4:2:2 8-bit BT.601 */ +#define PFNC_YCbCr601_422_10 0x0220008D /* YCbCr 4:2:2 10-bit unpacked BT.601 */ +#define PFNC_YCbCr601_422_10_CbYCrY 0x0220009D /* YCbCr 4:2:2 10-bit unpacked BT.601 */ +#define PFNC_YCbCr601_422_10p 0x0214008E /* YCbCr 4:2:2 10-bit packed BT.601 */ +#define PFNC_YCbCr601_422_10p_CbYCrY 0x0214009E /* YCbCr 4:2:2 10-bit packed BT.601 */ +#define PFNC_YCbCr601_422_12 0x0220008F /* YCbCr 4:2:2 12-bit unpacked BT.601 */ +#define PFNC_YCbCr601_422_12_CbYCrY 0x0220009F /* YCbCr 4:2:2 12-bit unpacked BT.601 */ +#define PFNC_YCbCr601_422_12p 0x02180090 /* YCbCr 4:2:2 12-bit packed BT.601 */ +#define PFNC_YCbCr601_422_12p_CbYCrY 0x021800A0 /* YCbCr 4:2:2 12-bit packed BT.601 */ +#define PFNC_YCbCr709_8_CbYCr 0x02180040 /* YCbCr 4:4:4 8-bit BT.709 */ +#define PFNC_YCbCr709_10_CbYCr 0x02300091 /* YCbCr 4:4:4 10-bit unpacked BT.709 */ +#define PFNC_YCbCr709_10p_CbYCr 0x021E0092 /* YCbCr 4:4:4 10-bit packed BT.709 */ +#define PFNC_YCbCr709_12_CbYCr 0x02300093 /* YCbCr 4:4:4 12-bit unpacked BT.709 */ +#define PFNC_YCbCr709_12p_CbYCr 0x02240094 /* YCbCr 4:4:4 12-bit packed BT.709 */ +#define PFNC_YCbCr709_411_8_CbYYCrYY 0x020C0042 /* YCbCr 4:1:1 8-bit BT.709 */ +#define PFNC_YCbCr709_422_8 0x02100041 /* YCbCr 4:2:2 8-bit BT.709 */ +#define PFNC_YCbCr709_422_8_CbYCrY 0x02100045 /* YCbCr 4:2:2 8-bit BT.709 */ +#define PFNC_YCbCr709_422_10 0x02200095 /* YCbCr 4:2:2 10-bit unpacked BT.709 */ +#define PFNC_YCbCr709_422_10_CbYCrY 0x022000A1 /* YCbCr 4:2:2 10-bit unpacked BT.709 */ +#define PFNC_YCbCr709_422_10p 0x02140096 /* YCbCr 4:2:2 10-bit packed BT.709 */ +#define PFNC_YCbCr709_422_10p_CbYCrY 0x021400A2 /* YCbCr 4:2:2 10-bit packed BT.709 */ +#define PFNC_YCbCr709_422_12 0x02200097 /* YCbCr 4:2:2 12-bit unpacked BT.709 */ +#define PFNC_YCbCr709_422_12_CbYCrY 0x022000A3 /* YCbCr 4:2:2 12-bit unpacked BT.709 */ +#define PFNC_YCbCr709_422_12p 0x02180098 /* YCbCr 4:2:2 12-bit packed BT.709 */ +#define PFNC_YCbCr709_422_12p_CbYCrY 0x021800A4 /* YCbCr 4:2:2 12-bit packed BT.709 */ +#define PFNC_YCbCr2020_8_CbYCr 0x021800F4 /* YCbCr 4:4:4 8-bit BT.2020 */ +#define PFNC_YCbCr2020_10_CbYCr 0x023000F5 /* YCbCr 4:4:4 10-bit unpacked BT.2020 */ +#define PFNC_YCbCr2020_10p_CbYCr 0x021E00F6 /* YCbCr 4:4:4 10-bit packed BT.2020 */ +#define PFNC_YCbCr2020_12_CbYCr 0x023000F7 /* YCbCr 4:4:4 12-bit unpacked BT.2020 */ +#define PFNC_YCbCr2020_12p_CbYCr 0x022400F8 /* YCbCr 4:4:4 12-bit packed BT.2020 */ +#define PFNC_YCbCr2020_411_8_CbYYCrYY 0x020C00F9 /* YCbCr 4:1:1 8-bit BT.2020 */ +#define PFNC_YCbCr2020_422_8 0x021000FA /* YCbCr 4:2:2 8-bit BT.2020 */ +#define PFNC_YCbCr2020_422_8_CbYCrY 0x021000FB /* YCbCr 4:2:2 8-bit BT.2020 */ +#define PFNC_YCbCr2020_422_10 0x022000FC /* YCbCr 4:2:2 10-bit unpacked BT.2020 */ +#define PFNC_YCbCr2020_422_10_CbYCrY 0x022000FD /* YCbCr 4:2:2 10-bit unpacked BT.2020 */ +#define PFNC_YCbCr2020_422_10p 0x021400FE /* YCbCr 4:2:2 10-bit packed BT.2020 */ +#define PFNC_YCbCr2020_422_10p_CbYCrY 0x021400FF /* YCbCr 4:2:2 10-bit packed BT.2020 */ +#define PFNC_YCbCr2020_422_12 0x02200100 /* YCbCr 4:2:2 12-bit unpacked BT.2020 */ +#define PFNC_YCbCr2020_422_12_CbYCrY 0x02200101 /* YCbCr 4:2:2 12-bit unpacked BT.2020 */ +#define PFNC_YCbCr2020_422_12p 0x02180102 /* YCbCr 4:2:2 12-bit packed BT.2020 */ +#define PFNC_YCbCr2020_422_12p_CbYCrY 0x02180103 /* YCbCr 4:2:2 12-bit packed BT.2020 */ +#define PFNC_YUV8_UYV 0x02180020 /* YUV 4:4:4 8-bit */ +#define PFNC_YUV411_8_UYYVYY 0x020C001E /* YUV 4:1:1 8-bit */ +#define PFNC_YUV422_8 0x02100032 /* YUV 4:2:2 8-bit */ +#define PFNC_YUV422_8_UYVY 0x0210001F /* YUV 4:2:2 8-bit */ + +/* Following formats are not PFNC compliant, but are still kept in the list for legacy purposes. */ + +#define GVSP_Mono10Packed 0x010C0004 /* GigE Vision specific format, Monochrome 10-bit packed */ +#define GVSP_Mono12Packed 0x010C0006 /* GigE Vision specific format, Monochrome 12-bit packed */ +#define GVSP_BayerBG10Packed 0x010C0029 /* GigE Vision specific format, Bayer Blue-Green 10-bit packed */ +#define GVSP_BayerBG12Packed 0x010C002D /* GigE Vision specific format, Bayer Blue-Green 12-bit packed */ +#define GVSP_BayerGB10Packed 0x010C0028 /* GigE Vision specific format, Bayer Green-Blue 10-bit packed */ +#define GVSP_BayerGB12Packed 0x010C002C /* GigE Vision specific format, Bayer Green-Blue 12-bit packed */ +#define GVSP_BayerGR10Packed 0x010C0026 /* GigE Vision specific format, Bayer Green-Red 10-bit packed */ +#define GVSP_BayerGR12Packed 0x010C002A /* GigE Vision specific format, Bayer Green-Red 12-bit packed */ +#define GVSP_BayerRG10Packed 0x010C0027 /* GigE Vision specific format, Bayer Red-Green 10-bit packed */ +#define GVSP_BayerRG12Packed 0x010C002B /* GigE Vision specific format, Bayer Red-Green 12-bit packed */ +#define GVSP_RGB10V1Packed 0x0220001C /* GigE Vision specific format, Red-Green-Blue 10-bit packed - variant 1 */ +#define GVSP_RGB12V1Packed 0x02240034 /* GigE Vision specific format, Red-Green-Blue 12-bit packed - variant 1 */ + + +/* Identical set of formats in the form of an enum */ + +typedef enum PfncFormat_ +{ + Mono1p = 0x01010037, /* Monochrome 1-bit packed */ + Mono2p = 0x01020038, /* Monochrome 2-bit packed */ + Mono4p = 0x01040039, /* Monochrome 4-bit packed */ + Mono8 = 0x01080001, /* Monochrome 8-bit */ + Mono8s = 0x01080002, /* Monochrome 8-bit signed */ + Mono10 = 0x01100003, /* Monochrome 10-bit unpacked */ + Mono10p = 0x010A0046, /* Monochrome 10-bit packed */ + Mono12 = 0x01100005, /* Monochrome 12-bit unpacked */ + Mono12p = 0x010C0047, /* Monochrome 12-bit packed */ + Mono14 = 0x01100025, /* Monochrome 14-bit unpacked */ + Mono14p = 0x010E0104, /* Monochrome 14-bit packed */ + Mono16 = 0x01100007, /* Monochrome 16-bit */ + Mono32 = 0x01200111, /* Monochrome 32-bit */ + BayerBG4p = 0x01040110, /* Bayer Blue-Green 4-bit packed */ + BayerBG8 = 0x0108000B, /* Bayer Blue-Green 8-bit */ + BayerBG10 = 0x0110000F, /* Bayer Blue-Green 10-bit unpacked */ + BayerBG10p = 0x010A0052, /* Bayer Blue-Green 10-bit packed */ + BayerBG12 = 0x01100013, /* Bayer Blue-Green 12-bit unpacked */ + BayerBG12p = 0x010C0053, /* Bayer Blue-Green 12-bit packed */ + BayerBG14 = 0x0110010C, /* Bayer Blue-Green 14-bit */ + BayerBG14p = 0x010E0108, /* Bayer Blue-Green 14-bit packed */ + BayerBG16 = 0x01100031, /* Bayer Blue-Green 16-bit */ + BayerGB4p = 0x0104010F, /* Bayer Green-Blue 4-bit packed */ + BayerGB8 = 0x0108000A, /* Bayer Green-Blue 8-bit */ + BayerGB10 = 0x0110000E, /* Bayer Green-Blue 10-bit unpacked */ + BayerGB10p = 0x010A0054, /* Bayer Green-Blue 10-bit packed */ + BayerGB12 = 0x01100012, /* Bayer Green-Blue 12-bit unpacked */ + BayerGB12p = 0x010C0055, /* Bayer Green-Blue 12-bit packed */ + BayerGB14 = 0x0110010B, /* Bayer Green-Blue 14-bit */ + BayerGB14p = 0x010E0107, /* Bayer Green-Blue 14-bit packed */ + BayerGB16 = 0x01100030, /* Bayer Green-Blue 16-bit */ + BayerGR4p = 0x0104010D, /* Bayer Green-Red 4-bit packed */ + BayerGR8 = 0x01080008, /* Bayer Green-Red 8-bit */ + BayerGR10 = 0x0110000C, /* Bayer Green-Red 10-bit unpacked */ + BayerGR10p = 0x010A0056, /* Bayer Green-Red 10-bit packed */ + BayerGR12 = 0x01100010, /* Bayer Green-Red 12-bit unpacked */ + BayerGR12p = 0x010C0057, /* Bayer Green-Red 12-bit packed */ + BayerGR14 = 0x01100109, /* Bayer Green-Red 14-bit */ + BayerGR14p = 0x010E0105, /* Bayer Green-Red 14-bit packed */ + BayerGR16 = 0x0110002E, /* Bayer Green-Red 16-bit */ + BayerRG4p = 0x0104010E, /* Bayer Red-Green 4-bit packed */ + BayerRG8 = 0x01080009, /* Bayer Red-Green 8-bit */ + BayerRG10 = 0x0110000D, /* Bayer Red-Green 10-bit unpacked */ + BayerRG10p = 0x010A0058, /* Bayer Red-Green 10-bit packed */ + BayerRG12 = 0x01100011, /* Bayer Red-Green 12-bit unpacked */ + BayerRG12p = 0x010C0059, /* Bayer Red-Green 12-bit packed */ + BayerRG14 = 0x0110010A, /* Bayer Red-Green 14-bit */ + BayerRG14p = 0x010E0106, /* Bayer Red-Green 14-bit packed */ + BayerRG16 = 0x0110002F, /* Bayer Red-Green 16-bit */ + RGBa8 = 0x02200016, /* Red-Green-Blue-alpha 8-bit */ + RGBa10 = 0x0240005F, /* Red-Green-Blue-alpha 10-bit unpacked */ + RGBa10p = 0x02280060, /* Red-Green-Blue-alpha 10-bit packed */ + RGBa12 = 0x02400061, /* Red-Green-Blue-alpha 12-bit unpacked */ + RGBa12p = 0x02300062, /* Red-Green-Blue-alpha 12-bit packed */ + RGBa14 = 0x02400063, /* Red-Green-Blue-alpha 14-bit unpacked */ + RGBa16 = 0x02400064, /* Red-Green-Blue-alpha 16-bit */ + RGB8 = 0x02180014, /* Red-Green-Blue 8-bit */ + RGB8_Planar = 0x02180021, /* Red-Green-Blue 8-bit planar */ + RGB10 = 0x02300018, /* Red-Green-Blue 10-bit unpacked */ + RGB10_Planar = 0x02300022, /* Red-Green-Blue 10-bit unpacked planar */ + RGB10p = 0x021E005C, /* Red-Green-Blue 10-bit packed */ + RGB10p32 = 0x0220001D, /* Red-Green-Blue 10-bit packed into 32-bit */ + RGB12 = 0x0230001A, /* Red-Green-Blue 12-bit unpacked */ + RGB12_Planar = 0x02300023, /* Red-Green-Blue 12-bit unpacked planar */ + RGB12p = 0x0224005D, /* Red-Green-Blue 12-bit packed */ + RGB14 = 0x0230005E, /* Red-Green-Blue 14-bit unpacked */ + RGB16 = 0x02300033, /* Red-Green-Blue 16-bit */ + RGB16_Planar = 0x02300024, /* Red-Green-Blue 16-bit planar */ + RGB565p = 0x02100035, /* Red-Green-Blue 5/6/5-bit packed */ + BGRa8 = 0x02200017, /* Blue-Green-Red-alpha 8-bit */ + BGRa10 = 0x0240004C, /* Blue-Green-Red-alpha 10-bit unpacked */ + BGRa10p = 0x0228004D, /* Blue-Green-Red-alpha 10-bit packed */ + BGRa12 = 0x0240004E, /* Blue-Green-Red-alpha 12-bit unpacked */ + BGRa12p = 0x0230004F, /* Blue-Green-Red-alpha 12-bit packed */ + BGRa14 = 0x02400050, /* Blue-Green-Red-alpha 14-bit unpacked */ + BGRa16 = 0x02400051, /* Blue-Green-Red-alpha 16-bit */ + BGR8 = 0x02180015, /* Blue-Green-Red 8-bit */ + BGR10 = 0x02300019, /* Blue-Green-Red 10-bit unpacked */ + BGR10p = 0x021E0048, /* Blue-Green-Red 10-bit packed */ + BGR12 = 0x0230001B, /* Blue-Green-Red 12-bit unpacked */ + BGR12p = 0x02240049, /* Blue-Green-Red 12-bit packed */ + BGR14 = 0x0230004A, /* Blue-Green-Red 14-bit unpacked */ + BGR16 = 0x0230004B, /* Blue-Green-Red 16-bit */ + BGR565p = 0x02100036, /* Blue-Green-Red 5/6/5-bit packed */ + R8 = 0x010800C9, /* Red 8-bit */ + R10 = 0x010A00CA, /* Red 10-bit */ + R12 = 0x010C00CB, /* Red 12-bit */ + R16 = 0x011000CC, /* Red 16-bit */ + G8 = 0x010800CD, /* Green 8-bit */ + G10 = 0x010A00CE, /* Green 10-bit */ + G12 = 0x010C00CF, /* Green 12-bit */ + G16 = 0x011000D0, /* Green 16-bit */ + B8 = 0x010800D1, /* Blue 8-bit */ + B10 = 0x010A00D2, /* Blue 10-bit */ + B12 = 0x010C00D3, /* Blue 12-bit */ + B16 = 0x011000D4, /* Blue 16-bit */ + Coord3D_ABC8 = 0x021800B2, /* 3D coordinate A-B-C 8-bit */ + Coord3D_ABC8_Planar = 0x021800B3, /* 3D coordinate A-B-C 8-bit planar */ + Coord3D_ABC10p = 0x021E00DB, /* 3D coordinate A-B-C 10-bit packed */ + Coord3D_ABC10p_Planar = 0x021E00DC, /* 3D coordinate A-B-C 10-bit packed planar */ + Coord3D_ABC12p = 0x022400DE, /* 3D coordinate A-B-C 12-bit packed */ + Coord3D_ABC12p_Planar = 0x022400DF, /* 3D coordinate A-B-C 12-bit packed planar */ + Coord3D_ABC16 = 0x023000B9, /* 3D coordinate A-B-C 16-bit */ + Coord3D_ABC16_Planar = 0x023000BA, /* 3D coordinate A-B-C 16-bit planar */ + Coord3D_ABC32f = 0x026000C0, /* 3D coordinate A-B-C 32-bit floating point */ + Coord3D_ABC32f_Planar = 0x026000C1, /* 3D coordinate A-B-C 32-bit floating point planar */ + Coord3D_AC8 = 0x021000B4, /* 3D coordinate A-C 8-bit */ + Coord3D_AC8_Planar = 0x021000B5, /* 3D coordinate A-C 8-bit planar */ + Coord3D_AC10p = 0x021400F0, /* 3D coordinate A-C 10-bit packed */ + Coord3D_AC10p_Planar = 0x021400F1, /* 3D coordinate A-C 10-bit packed planar */ + Coord3D_AC12p = 0x021800F2, /* 3D coordinate A-C 12-bit packed */ + Coord3D_AC12p_Planar = 0x021800F3, /* 3D coordinate A-C 12-bit packed planar */ + Coord3D_AC16 = 0x022000BB, /* 3D coordinate A-C 16-bit */ + Coord3D_AC16_Planar = 0x022000BC, /* 3D coordinate A-C 16-bit planar */ + Coord3D_AC32f = 0x024000C2, /* 3D coordinate A-C 32-bit floating point */ + Coord3D_AC32f_Planar = 0x024000C3, /* 3D coordinate A-C 32-bit floating point planar */ + Coord3D_A8 = 0x010800AF, /* 3D coordinate A 8-bit */ + Coord3D_A10p = 0x010A00D5, /* 3D coordinate A 10-bit packed */ + Coord3D_A12p = 0x010C00D8, /* 3D coordinate A 12-bit packed */ + Coord3D_A16 = 0x011000B6, /* 3D coordinate A 16-bit */ + Coord3D_A32f = 0x012000BD, /* 3D coordinate A 32-bit floating point */ + Coord3D_B8 = 0x010800B0, /* 3D coordinate B 8-bit */ + Coord3D_B10p = 0x010A00D6, /* 3D coordinate B 10-bit packed */ + Coord3D_B12p = 0x010C00D9, /* 3D coordinate B 12-bit packed */ + Coord3D_B16 = 0x011000B7, /* 3D coordinate B 16-bit */ + Coord3D_B32f = 0x012000BE, /* 3D coordinate B 32-bit floating point */ + Coord3D_C8 = 0x010800B1, /* 3D coordinate C 8-bit */ + Coord3D_C10p = 0x010A00D7, /* 3D coordinate C 10-bit packed */ + Coord3D_C12p = 0x010C00DA, /* 3D coordinate C 12-bit packed */ + Coord3D_C16 = 0x011000B8, /* 3D coordinate C 16-bit */ + Coord3D_C32f = 0x012000BF, /* 3D coordinate C 32-bit floating point */ + Confidence1 = 0x010800C4, /* Confidence 1-bit unpacked */ + Confidence1p = 0x010100C5, /* Confidence 1-bit packed */ + Confidence8 = 0x010800C6, /* Confidence 8-bit */ + Confidence16 = 0x011000C7, /* Confidence 16-bit */ + Confidence32f = 0x012000C8, /* Confidence 32-bit floating point */ + BiColorBGRG8 = 0x021000A6, /* Bi-color Blue/Green - Red/Green 8-bit */ + BiColorBGRG10 = 0x022000A9, /* Bi-color Blue/Green - Red/Green 10-bit unpacked */ + BiColorBGRG10p = 0x021400AA, /* Bi-color Blue/Green - Red/Green 10-bit packed */ + BiColorBGRG12 = 0x022000AD, /* Bi-color Blue/Green - Red/Green 12-bit unpacked */ + BiColorBGRG12p = 0x021800AE, /* Bi-color Blue/Green - Red/Green 12-bit packed */ + BiColorRGBG8 = 0x021000A5, /* Bi-color Red/Green - Blue/Green 8-bit */ + BiColorRGBG10 = 0x022000A7, /* Bi-color Red/Green - Blue/Green 10-bit unpacked */ + BiColorRGBG10p = 0x021400A8, /* Bi-color Red/Green - Blue/Green 10-bit packed */ + BiColorRGBG12 = 0x022000AB, /* Bi-color Red/Green - Blue/Green 12-bit unpacked */ + BiColorRGBG12p = 0x021800AC, /* Bi-color Red/Green - Blue/Green 12-bit packed */ + Data8 = 0x01080116, /* Data 8-bit */ + Data8s = 0x01080117, /* Data 8-bit signed */ + Data16 = 0x01100118, /* Data 16-bit */ + Data16s = 0x01100119, /* Data 16-bit signed */ + Data32 = 0x0120011A, /* Data 32-bit */ + Data32f = 0x0120011C, /* Data 32-bit floating point */ + Data32s = 0x0120011B, /* Data 32-bit signed */ + Data64 = 0x0140011D, /* Data 64-bit */ + Data64f = 0x0140011F, /* Data 64-bit floating point */ + Data64s = 0x0140011E, /* Data 64-bit signed */ + SCF1WBWG8 = 0x01080067, /* Sparse Color Filter #1 White-Blue-White-Green 8-bit */ + SCF1WBWG10 = 0x01100068, /* Sparse Color Filter #1 White-Blue-White-Green 10-bit unpacked */ + SCF1WBWG10p = 0x010A0069, /* Sparse Color Filter #1 White-Blue-White-Green 10-bit packed */ + SCF1WBWG12 = 0x0110006A, /* Sparse Color Filter #1 White-Blue-White-Green 12-bit unpacked */ + SCF1WBWG12p = 0x010C006B, /* Sparse Color Filter #1 White-Blue-White-Green 12-bit packed */ + SCF1WBWG14 = 0x0110006C, /* Sparse Color Filter #1 White-Blue-White-Green 14-bit unpacked */ + SCF1WBWG16 = 0x0110006D, /* Sparse Color Filter #1 White-Blue-White-Green 16-bit unpacked */ + SCF1WGWB8 = 0x0108006E, /* Sparse Color Filter #1 White-Green-White-Blue 8-bit */ + SCF1WGWB10 = 0x0110006F, /* Sparse Color Filter #1 White-Green-White-Blue 10-bit unpacked */ + SCF1WGWB10p = 0x010A0070, /* Sparse Color Filter #1 White-Green-White-Blue 10-bit packed */ + SCF1WGWB12 = 0x01100071, /* Sparse Color Filter #1 White-Green-White-Blue 12-bit unpacked */ + SCF1WGWB12p = 0x010C0072, /* Sparse Color Filter #1 White-Green-White-Blue 12-bit packed */ + SCF1WGWB14 = 0x01100073, /* Sparse Color Filter #1 White-Green-White-Blue 14-bit unpacked */ + SCF1WGWB16 = 0x01100074, /* Sparse Color Filter #1 White-Green-White-Blue 16-bit */ + SCF1WGWR8 = 0x01080075, /* Sparse Color Filter #1 White-Green-White-Red 8-bit */ + SCF1WGWR10 = 0x01100076, /* Sparse Color Filter #1 White-Green-White-Red 10-bit unpacked */ + SCF1WGWR10p = 0x010A0077, /* Sparse Color Filter #1 White-Green-White-Red 10-bit packed */ + SCF1WGWR12 = 0x01100078, /* Sparse Color Filter #1 White-Green-White-Red 12-bit unpacked */ + SCF1WGWR12p = 0x010C0079, /* Sparse Color Filter #1 White-Green-White-Red 12-bit packed */ + SCF1WGWR14 = 0x0110007A, /* Sparse Color Filter #1 White-Green-White-Red 14-bit unpacked */ + SCF1WGWR16 = 0x0110007B, /* Sparse Color Filter #1 White-Green-White-Red 16-bit */ + SCF1WRWG8 = 0x0108007C, /* Sparse Color Filter #1 White-Red-White-Green 8-bit */ + SCF1WRWG10 = 0x0110007D, /* Sparse Color Filter #1 White-Red-White-Green 10-bit unpacked */ + SCF1WRWG10p = 0x010A007E, /* Sparse Color Filter #1 White-Red-White-Green 10-bit packed */ + SCF1WRWG12 = 0x0110007F, /* Sparse Color Filter #1 White-Red-White-Green 12-bit unpacked */ + SCF1WRWG12p = 0x010C0080, /* Sparse Color Filter #1 White-Red-White-Green 12-bit packed */ + SCF1WRWG14 = 0x01100081, /* Sparse Color Filter #1 White-Red-White-Green 14-bit unpacked */ + SCF1WRWG16 = 0x01100082, /* Sparse Color Filter #1 White-Red-White-Green 16-bit */ + YCbCr8 = 0x0218005B, /* YCbCr 4:4:4 8-bit */ + YCbCr8_CbYCr = 0x0218003A, /* YCbCr 4:4:4 8-bit */ + YCbCr10_CbYCr = 0x02300083, /* YCbCr 4:4:4 10-bit unpacked */ + YCbCr10p_CbYCr = 0x021E0084, /* YCbCr 4:4:4 10-bit packed */ + YCbCr12_CbYCr = 0x02300085, /* YCbCr 4:4:4 12-bit unpacked */ + YCbCr12p_CbYCr = 0x02240086, /* YCbCr 4:4:4 12-bit packed */ + YCbCr411_8 = 0x020C005A, /* YCbCr 4:1:1 8-bit */ + YCbCr411_8_CbYYCrYY = 0x020C003C, /* YCbCr 4:1:1 8-bit */ + YCbCr420_8_YY_CbCr_Semiplanar = 0x020C0112, /* YCbCr 4:2:0 8-bit YY/CbCr Semiplanar */ + YCbCr420_8_YY_CrCb_Semiplanar = 0x020C0114, /* YCbCr 4:2:0 8-bit YY/CrCb Semiplanar */ + YCbCr422_8 = 0x0210003B, /* YCbCr 4:2:2 8-bit */ + YCbCr422_8_CbYCrY = 0x02100043, /* YCbCr 4:2:2 8-bit */ + YCbCr422_8_YY_CbCr_Semiplanar = 0x02100113, /* YCbCr 4:2:2 8-bit YY/CbCr Semiplanar */ + YCbCr422_8_YY_CrCb_Semiplanar = 0x02100115, /* YCbCr 4:2:2 8-bit YY/CrCb Semiplanar */ + YCbCr422_10 = 0x02200065, /* YCbCr 4:2:2 10-bit unpacked */ + YCbCr422_10_CbYCrY = 0x02200099, /* YCbCr 4:2:2 10-bit unpacked */ + YCbCr422_10p = 0x02140087, /* YCbCr 4:2:2 10-bit packed */ + YCbCr422_10p_CbYCrY = 0x0214009A, /* YCbCr 4:2:2 10-bit packed */ + YCbCr422_12 = 0x02200066, /* YCbCr 4:2:2 12-bit unpacked */ + YCbCr422_12_CbYCrY = 0x0220009B, /* YCbCr 4:2:2 12-bit unpacked */ + YCbCr422_12p = 0x02180088, /* YCbCr 4:2:2 12-bit packed */ + YCbCr422_12p_CbYCrY = 0x0218009C, /* YCbCr 4:2:2 12-bit packed */ + YCbCr601_8_CbYCr = 0x0218003D, /* YCbCr 4:4:4 8-bit BT.601 */ + YCbCr601_10_CbYCr = 0x02300089, /* YCbCr 4:4:4 10-bit unpacked BT.601 */ + YCbCr601_10p_CbYCr = 0x021E008A, /* YCbCr 4:4:4 10-bit packed BT.601 */ + YCbCr601_12_CbYCr = 0x0230008B, /* YCbCr 4:4:4 12-bit unpacked BT.601 */ + YCbCr601_12p_CbYCr = 0x0224008C, /* YCbCr 4:4:4 12-bit packed BT.601 */ + YCbCr601_411_8_CbYYCrYY = 0x020C003F, /* YCbCr 4:1:1 8-bit BT.601 */ + YCbCr601_422_8 = 0x0210003E, /* YCbCr 4:2:2 8-bit BT.601 */ + YCbCr601_422_8_CbYCrY = 0x02100044, /* YCbCr 4:2:2 8-bit BT.601 */ + YCbCr601_422_10 = 0x0220008D, /* YCbCr 4:2:2 10-bit unpacked BT.601 */ + YCbCr601_422_10_CbYCrY = 0x0220009D, /* YCbCr 4:2:2 10-bit unpacked BT.601 */ + YCbCr601_422_10p = 0x0214008E, /* YCbCr 4:2:2 10-bit packed BT.601 */ + YCbCr601_422_10p_CbYCrY = 0x0214009E, /* YCbCr 4:2:2 10-bit packed BT.601 */ + YCbCr601_422_12 = 0x0220008F, /* YCbCr 4:2:2 12-bit unpacked BT.601 */ + YCbCr601_422_12_CbYCrY = 0x0220009F, /* YCbCr 4:2:2 12-bit unpacked BT.601 */ + YCbCr601_422_12p = 0x02180090, /* YCbCr 4:2:2 12-bit packed BT.601 */ + YCbCr601_422_12p_CbYCrY = 0x021800A0, /* YCbCr 4:2:2 12-bit packed BT.601 */ + YCbCr709_8_CbYCr = 0x02180040, /* YCbCr 4:4:4 8-bit BT.709 */ + YCbCr709_10_CbYCr = 0x02300091, /* YCbCr 4:4:4 10-bit unpacked BT.709 */ + YCbCr709_10p_CbYCr = 0x021E0092, /* YCbCr 4:4:4 10-bit packed BT.709 */ + YCbCr709_12_CbYCr = 0x02300093, /* YCbCr 4:4:4 12-bit unpacked BT.709 */ + YCbCr709_12p_CbYCr = 0x02240094, /* YCbCr 4:4:4 12-bit packed BT.709 */ + YCbCr709_411_8_CbYYCrYY = 0x020C0042, /* YCbCr 4:1:1 8-bit BT.709 */ + YCbCr709_422_8 = 0x02100041, /* YCbCr 4:2:2 8-bit BT.709 */ + YCbCr709_422_8_CbYCrY = 0x02100045, /* YCbCr 4:2:2 8-bit BT.709 */ + YCbCr709_422_10 = 0x02200095, /* YCbCr 4:2:2 10-bit unpacked BT.709 */ + YCbCr709_422_10_CbYCrY = 0x022000A1, /* YCbCr 4:2:2 10-bit unpacked BT.709 */ + YCbCr709_422_10p = 0x02140096, /* YCbCr 4:2:2 10-bit packed BT.709 */ + YCbCr709_422_10p_CbYCrY = 0x021400A2, /* YCbCr 4:2:2 10-bit packed BT.709 */ + YCbCr709_422_12 = 0x02200097, /* YCbCr 4:2:2 12-bit unpacked BT.709 */ + YCbCr709_422_12_CbYCrY = 0x022000A3, /* YCbCr 4:2:2 12-bit unpacked BT.709 */ + YCbCr709_422_12p = 0x02180098, /* YCbCr 4:2:2 12-bit packed BT.709 */ + YCbCr709_422_12p_CbYCrY = 0x021800A4, /* YCbCr 4:2:2 12-bit packed BT.709 */ + YCbCr2020_8_CbYCr = 0x021800F4, /* YCbCr 4:4:4 8-bit BT.2020 */ + YCbCr2020_10_CbYCr = 0x023000F5, /* YCbCr 4:4:4 10-bit unpacked BT.2020 */ + YCbCr2020_10p_CbYCr = 0x021E00F6, /* YCbCr 4:4:4 10-bit packed BT.2020 */ + YCbCr2020_12_CbYCr = 0x023000F7, /* YCbCr 4:4:4 12-bit unpacked BT.2020 */ + YCbCr2020_12p_CbYCr = 0x022400F8, /* YCbCr 4:4:4 12-bit packed BT.2020 */ + YCbCr2020_411_8_CbYYCrYY = 0x020C00F9, /* YCbCr 4:1:1 8-bit BT.2020 */ + YCbCr2020_422_8 = 0x021000FA, /* YCbCr 4:2:2 8-bit BT.2020 */ + YCbCr2020_422_8_CbYCrY = 0x021000FB, /* YCbCr 4:2:2 8-bit BT.2020 */ + YCbCr2020_422_10 = 0x022000FC, /* YCbCr 4:2:2 10-bit unpacked BT.2020 */ + YCbCr2020_422_10_CbYCrY = 0x022000FD, /* YCbCr 4:2:2 10-bit unpacked BT.2020 */ + YCbCr2020_422_10p = 0x021400FE, /* YCbCr 4:2:2 10-bit packed BT.2020 */ + YCbCr2020_422_10p_CbYCrY = 0x021400FF, /* YCbCr 4:2:2 10-bit packed BT.2020 */ + YCbCr2020_422_12 = 0x02200100, /* YCbCr 4:2:2 12-bit unpacked BT.2020 */ + YCbCr2020_422_12_CbYCrY = 0x02200101, /* YCbCr 4:2:2 12-bit unpacked BT.2020 */ + YCbCr2020_422_12p = 0x02180102, /* YCbCr 4:2:2 12-bit packed BT.2020 */ + YCbCr2020_422_12p_CbYCrY = 0x02180103, /* YCbCr 4:2:2 12-bit packed BT.2020 */ + YUV8_UYV = 0x02180020, /* YUV 4:4:4 8-bit */ + YUV411_8_UYYVYY = 0x020C001E, /* YUV 4:1:1 8-bit */ + YUV422_8 = 0x02100032, /* YUV 4:2:2 8-bit */ + YUV422_8_UYVY = 0x0210001F, /* YUV 4:2:2 8-bit */ + Mono10Packed = 0x010C0004, /* GigE Vision specific format, Monochrome 10-bit packed */ + Mono12Packed = 0x010C0006, /* GigE Vision specific format, Monochrome 12-bit packed */ + BayerBG10Packed = 0x010C0029, /* GigE Vision specific format, Bayer Blue-Green 10-bit packed */ + BayerBG12Packed = 0x010C002D, /* GigE Vision specific format, Bayer Blue-Green 12-bit packed */ + BayerGB10Packed = 0x010C0028, /* GigE Vision specific format, Bayer Green-Blue 10-bit packed */ + BayerGB12Packed = 0x010C002C, /* GigE Vision specific format, Bayer Green-Blue 12-bit packed */ + BayerGR10Packed = 0x010C0026, /* GigE Vision specific format, Bayer Green-Red 10-bit packed */ + BayerGR12Packed = 0x010C002A, /* GigE Vision specific format, Bayer Green-Red 12-bit packed */ + BayerRG10Packed = 0x010C0027, /* GigE Vision specific format, Bayer Red-Green 10-bit packed */ + BayerRG12Packed = 0x010C002B, /* GigE Vision specific format, Bayer Red-Green 12-bit packed */ + RGB10V1Packed = 0x0220001C, /* GigE Vision specific format, Red-Green-Blue 10-bit packed - variant 1 */ + RGB12V1Packed = 0x02240034, /* GigE Vision specific format, Red-Green-Blue 12-bit packed - variant 1 */ + InvalidPixelFormat = 0 +} PfncFormat; + +/* 32-bit value layout */ +/* |31 24|23 16|15 08|07 00| */ +/* | C| Comp. Layout| Effective Size | Pixel ID | */ + +/* Custom flag */ +#define PFNC_CUSTOM 0x80000000 +/* Component layout */ +#define PFNC_SINGLE_COMPONENT 0x01000000 +#define PFNC_MULTIPLE_COMPONENT 0x02000000 +#define PFNC_COMPONENT_MASK 0x7F000000 +/* Effective size */ +#define PFNC_OCCUPY1BIT 0x00010000 +#define PFNC_OCCUPY2BIT 0x00020000 +#define PFNC_OCCUPY4BIT 0x00040000 +#define PFNC_OCCUPY8BIT 0x00080000 +#define PFNC_OCCUPY10BIT 0x000A0000 +#define PFNC_OCCUPY12BIT 0x000C0000 +#define PFNC_OCCUPY16BIT 0x00100000 +#define PFNC_OCCUPY24BIT 0x00180000 +#define PFNC_OCCUPY30BIT 0x001E0000 +#define PFNC_OCCUPY32BIT 0x00200000 +#define PFNC_OCCUPY36BIT 0x00240000 +#define PFNC_OCCUPY40BIT 0x00280000 +#define PFNC_OCCUPY48BIT 0x00300000 +#define PFNC_OCCUPY64BIT 0x00400000 +#define PFNC_PIXEL_SIZE_MASK 0x00FF0000 +#define PFNC_PIXEL_SIZE_SHIFT 16 +/* Pixel ID */ +#define PFNC_PIXEL_ID_MASK 0x0000FFFF +/* Pixel format value dissection helpers */ +#define PFNC_PIXEL_SIZE(X) ((X & PFNC_PIXEL_SIZE_MASK) >> PFNC_PIXEL_SIZE_SHIFT) +#define PFNC_IS_PIXEL_SINGLE_COMPONENT(X) ((X & PFNC_COMPONENT_MASK) == PFNC_SINGLE_COMPONENT) +#define PFNC_IS_PIXEL_MULTIPLE_COMPONENT(X) ((X & PFNC_COMPONENT_MASK) == PFNC_MULTIPLE_COMPONENT) +#define PFNC_IS_PIXEL_CUSTOM(X) ((X & PFNC_CUSTOM) == PFNC_CUSTOM) +#define PFNC_PIXEL_ID(X) (X & PFNC_PIXEL_ID_MASK) + + +/* Additional helpers */ +#ifdef PFNC_INCLUDE_HELPERS +#ifdef _MSC_VER +# define PFNC_INLINE __inline +#else +# define PFNC_INLINE inline +#endif +static PFNC_INLINE const char* GetPixelFormatName (PfncFormat format) +{ + switch (format) + { + case Mono1p: return "Mono1p"; + case Mono2p: return "Mono2p"; + case Mono4p: return "Mono4p"; + case Mono8: return "Mono8"; + case Mono8s: return "Mono8s"; + case Mono10: return "Mono10"; + case Mono10p: return "Mono10p"; + case Mono12: return "Mono12"; + case Mono12p: return "Mono12p"; + case Mono14: return "Mono14"; + case Mono14p: return "Mono14p"; + case Mono16: return "Mono16"; + case Mono32: return "Mono32"; + case BayerBG4p: return "BayerBG4p"; + case BayerBG8: return "BayerBG8"; + case BayerBG10: return "BayerBG10"; + case BayerBG10p: return "BayerBG10p"; + case BayerBG12: return "BayerBG12"; + case BayerBG12p: return "BayerBG12p"; + case BayerBG14: return "BayerBG14"; + case BayerBG14p: return "BayerBG14p"; + case BayerBG16: return "BayerBG16"; + case BayerGB4p: return "BayerGB4p"; + case BayerGB8: return "BayerGB8"; + case BayerGB10: return "BayerGB10"; + case BayerGB10p: return "BayerGB10p"; + case BayerGB12: return "BayerGB12"; + case BayerGB12p: return "BayerGB12p"; + case BayerGB14: return "BayerGB14"; + case BayerGB14p: return "BayerGB14p"; + case BayerGB16: return "BayerGB16"; + case BayerGR4p: return "BayerGR4p"; + case BayerGR8: return "BayerGR8"; + case BayerGR10: return "BayerGR10"; + case BayerGR10p: return "BayerGR10p"; + case BayerGR12: return "BayerGR12"; + case BayerGR12p: return "BayerGR12p"; + case BayerGR14: return "BayerGR14"; + case BayerGR14p: return "BayerGR14p"; + case BayerGR16: return "BayerGR16"; + case BayerRG4p: return "BayerRG4p"; + case BayerRG8: return "BayerRG8"; + case BayerRG10: return "BayerRG10"; + case BayerRG10p: return "BayerRG10p"; + case BayerRG12: return "BayerRG12"; + case BayerRG12p: return "BayerRG12p"; + case BayerRG14: return "BayerRG14"; + case BayerRG14p: return "BayerRG14p"; + case BayerRG16: return "BayerRG16"; + case RGBa8: return "RGBa8"; + case RGBa10: return "RGBa10"; + case RGBa10p: return "RGBa10p"; + case RGBa12: return "RGBa12"; + case RGBa12p: return "RGBa12p"; + case RGBa14: return "RGBa14"; + case RGBa16: return "RGBa16"; + case RGB8: return "RGB8"; + case RGB8_Planar: return "RGB8_Planar"; + case RGB10: return "RGB10"; + case RGB10_Planar: return "RGB10_Planar"; + case RGB10p: return "RGB10p"; + case RGB10p32: return "RGB10p32"; + case RGB12: return "RGB12"; + case RGB12_Planar: return "RGB12_Planar"; + case RGB12p: return "RGB12p"; + case RGB14: return "RGB14"; + case RGB16: return "RGB16"; + case RGB16_Planar: return "RGB16_Planar"; + case RGB565p: return "RGB565p"; + case BGRa8: return "BGRa8"; + case BGRa10: return "BGRa10"; + case BGRa10p: return "BGRa10p"; + case BGRa12: return "BGRa12"; + case BGRa12p: return "BGRa12p"; + case BGRa14: return "BGRa14"; + case BGRa16: return "BGRa16"; + case BGR8: return "BGR8"; + case BGR10: return "BGR10"; + case BGR10p: return "BGR10p"; + case BGR12: return "BGR12"; + case BGR12p: return "BGR12p"; + case BGR14: return "BGR14"; + case BGR16: return "BGR16"; + case BGR565p: return "BGR565p"; + case R8: return "R8"; + case R10: return "R10"; + case R12: return "R12"; + case R16: return "R16"; + case G8: return "G8"; + case G10: return "G10"; + case G12: return "G12"; + case G16: return "G16"; + case B8: return "B8"; + case B10: return "B10"; + case B12: return "B12"; + case B16: return "B16"; + case Coord3D_ABC8: return "Coord3D_ABC8"; + case Coord3D_ABC8_Planar: return "Coord3D_ABC8_Planar"; + case Coord3D_ABC10p: return "Coord3D_ABC10p"; + case Coord3D_ABC10p_Planar: return "Coord3D_ABC10p_Planar"; + case Coord3D_ABC12p: return "Coord3D_ABC12p"; + case Coord3D_ABC12p_Planar: return "Coord3D_ABC12p_Planar"; + case Coord3D_ABC16: return "Coord3D_ABC16"; + case Coord3D_ABC16_Planar: return "Coord3D_ABC16_Planar"; + case Coord3D_ABC32f: return "Coord3D_ABC32f"; + case Coord3D_ABC32f_Planar: return "Coord3D_ABC32f_Planar"; + case Coord3D_AC8: return "Coord3D_AC8"; + case Coord3D_AC8_Planar: return "Coord3D_AC8_Planar"; + case Coord3D_AC10p: return "Coord3D_AC10p"; + case Coord3D_AC10p_Planar: return "Coord3D_AC10p_Planar"; + case Coord3D_AC12p: return "Coord3D_AC12p"; + case Coord3D_AC12p_Planar: return "Coord3D_AC12p_Planar"; + case Coord3D_AC16: return "Coord3D_AC16"; + case Coord3D_AC16_Planar: return "Coord3D_AC16_Planar"; + case Coord3D_AC32f: return "Coord3D_AC32f"; + case Coord3D_AC32f_Planar: return "Coord3D_AC32f_Planar"; + case Coord3D_A8: return "Coord3D_A8"; + case Coord3D_A10p: return "Coord3D_A10p"; + case Coord3D_A12p: return "Coord3D_A12p"; + case Coord3D_A16: return "Coord3D_A16"; + case Coord3D_A32f: return "Coord3D_A32f"; + case Coord3D_B8: return "Coord3D_B8"; + case Coord3D_B10p: return "Coord3D_B10p"; + case Coord3D_B12p: return "Coord3D_B12p"; + case Coord3D_B16: return "Coord3D_B16"; + case Coord3D_B32f: return "Coord3D_B32f"; + case Coord3D_C8: return "Coord3D_C8"; + case Coord3D_C10p: return "Coord3D_C10p"; + case Coord3D_C12p: return "Coord3D_C12p"; + case Coord3D_C16: return "Coord3D_C16"; + case Coord3D_C32f: return "Coord3D_C32f"; + case Confidence1: return "Confidence1"; + case Confidence1p: return "Confidence1p"; + case Confidence8: return "Confidence8"; + case Confidence16: return "Confidence16"; + case Confidence32f: return "Confidence32f"; + case BiColorBGRG8: return "BiColorBGRG8"; + case BiColorBGRG10: return "BiColorBGRG10"; + case BiColorBGRG10p: return "BiColorBGRG10p"; + case BiColorBGRG12: return "BiColorBGRG12"; + case BiColorBGRG12p: return "BiColorBGRG12p"; + case BiColorRGBG8: return "BiColorRGBG8"; + case BiColorRGBG10: return "BiColorRGBG10"; + case BiColorRGBG10p: return "BiColorRGBG10p"; + case BiColorRGBG12: return "BiColorRGBG12"; + case BiColorRGBG12p: return "BiColorRGBG12p"; + case Data8: return "Data8"; + case Data8s: return "Data8s"; + case Data16: return "Data16"; + case Data16s: return "Data16s"; + case Data32: return "Data32"; + case Data32f: return "Data32f"; + case Data32s: return "Data32s"; + case Data64: return "Data64"; + case Data64f: return "Data64f"; + case Data64s: return "Data64s"; + case SCF1WBWG8: return "SCF1WBWG8"; + case SCF1WBWG10: return "SCF1WBWG10"; + case SCF1WBWG10p: return "SCF1WBWG10p"; + case SCF1WBWG12: return "SCF1WBWG12"; + case SCF1WBWG12p: return "SCF1WBWG12p"; + case SCF1WBWG14: return "SCF1WBWG14"; + case SCF1WBWG16: return "SCF1WBWG16"; + case SCF1WGWB8: return "SCF1WGWB8"; + case SCF1WGWB10: return "SCF1WGWB10"; + case SCF1WGWB10p: return "SCF1WGWB10p"; + case SCF1WGWB12: return "SCF1WGWB12"; + case SCF1WGWB12p: return "SCF1WGWB12p"; + case SCF1WGWB14: return "SCF1WGWB14"; + case SCF1WGWB16: return "SCF1WGWB16"; + case SCF1WGWR8: return "SCF1WGWR8"; + case SCF1WGWR10: return "SCF1WGWR10"; + case SCF1WGWR10p: return "SCF1WGWR10p"; + case SCF1WGWR12: return "SCF1WGWR12"; + case SCF1WGWR12p: return "SCF1WGWR12p"; + case SCF1WGWR14: return "SCF1WGWR14"; + case SCF1WGWR16: return "SCF1WGWR16"; + case SCF1WRWG8: return "SCF1WRWG8"; + case SCF1WRWG10: return "SCF1WRWG10"; + case SCF1WRWG10p: return "SCF1WRWG10p"; + case SCF1WRWG12: return "SCF1WRWG12"; + case SCF1WRWG12p: return "SCF1WRWG12p"; + case SCF1WRWG14: return "SCF1WRWG14"; + case SCF1WRWG16: return "SCF1WRWG16"; + case YCbCr8: return "YCbCr8"; + case YCbCr8_CbYCr: return "YCbCr8_CbYCr"; + case YCbCr10_CbYCr: return "YCbCr10_CbYCr"; + case YCbCr10p_CbYCr: return "YCbCr10p_CbYCr"; + case YCbCr12_CbYCr: return "YCbCr12_CbYCr"; + case YCbCr12p_CbYCr: return "YCbCr12p_CbYCr"; + case YCbCr411_8: return "YCbCr411_8"; + case YCbCr411_8_CbYYCrYY: return "YCbCr411_8_CbYYCrYY"; + case YCbCr420_8_YY_CbCr_Semiplanar: return "YCbCr420_8_YY_CbCr_Semiplanar"; + case YCbCr420_8_YY_CrCb_Semiplanar: return "YCbCr420_8_YY_CrCb_Semiplanar"; + case YCbCr422_8: return "YCbCr422_8"; + case YCbCr422_8_CbYCrY: return "YCbCr422_8_CbYCrY"; + case YCbCr422_8_YY_CbCr_Semiplanar: return "YCbCr422_8_YY_CbCr_Semiplanar"; + case YCbCr422_8_YY_CrCb_Semiplanar: return "YCbCr422_8_YY_CrCb_Semiplanar"; + case YCbCr422_10: return "YCbCr422_10"; + case YCbCr422_10_CbYCrY: return "YCbCr422_10_CbYCrY"; + case YCbCr422_10p: return "YCbCr422_10p"; + case YCbCr422_10p_CbYCrY: return "YCbCr422_10p_CbYCrY"; + case YCbCr422_12: return "YCbCr422_12"; + case YCbCr422_12_CbYCrY: return "YCbCr422_12_CbYCrY"; + case YCbCr422_12p: return "YCbCr422_12p"; + case YCbCr422_12p_CbYCrY: return "YCbCr422_12p_CbYCrY"; + case YCbCr601_8_CbYCr: return "YCbCr601_8_CbYCr"; + case YCbCr601_10_CbYCr: return "YCbCr601_10_CbYCr"; + case YCbCr601_10p_CbYCr: return "YCbCr601_10p_CbYCr"; + case YCbCr601_12_CbYCr: return "YCbCr601_12_CbYCr"; + case YCbCr601_12p_CbYCr: return "YCbCr601_12p_CbYCr"; + case YCbCr601_411_8_CbYYCrYY: return "YCbCr601_411_8_CbYYCrYY"; + case YCbCr601_422_8: return "YCbCr601_422_8"; + case YCbCr601_422_8_CbYCrY: return "YCbCr601_422_8_CbYCrY"; + case YCbCr601_422_10: return "YCbCr601_422_10"; + case YCbCr601_422_10_CbYCrY: return "YCbCr601_422_10_CbYCrY"; + case YCbCr601_422_10p: return "YCbCr601_422_10p"; + case YCbCr601_422_10p_CbYCrY: return "YCbCr601_422_10p_CbYCrY"; + case YCbCr601_422_12: return "YCbCr601_422_12"; + case YCbCr601_422_12_CbYCrY: return "YCbCr601_422_12_CbYCrY"; + case YCbCr601_422_12p: return "YCbCr601_422_12p"; + case YCbCr601_422_12p_CbYCrY: return "YCbCr601_422_12p_CbYCrY"; + case YCbCr709_8_CbYCr: return "YCbCr709_8_CbYCr"; + case YCbCr709_10_CbYCr: return "YCbCr709_10_CbYCr"; + case YCbCr709_10p_CbYCr: return "YCbCr709_10p_CbYCr"; + case YCbCr709_12_CbYCr: return "YCbCr709_12_CbYCr"; + case YCbCr709_12p_CbYCr: return "YCbCr709_12p_CbYCr"; + case YCbCr709_411_8_CbYYCrYY: return "YCbCr709_411_8_CbYYCrYY"; + case YCbCr709_422_8: return "YCbCr709_422_8"; + case YCbCr709_422_8_CbYCrY: return "YCbCr709_422_8_CbYCrY"; + case YCbCr709_422_10: return "YCbCr709_422_10"; + case YCbCr709_422_10_CbYCrY: return "YCbCr709_422_10_CbYCrY"; + case YCbCr709_422_10p: return "YCbCr709_422_10p"; + case YCbCr709_422_10p_CbYCrY: return "YCbCr709_422_10p_CbYCrY"; + case YCbCr709_422_12: return "YCbCr709_422_12"; + case YCbCr709_422_12_CbYCrY: return "YCbCr709_422_12_CbYCrY"; + case YCbCr709_422_12p: return "YCbCr709_422_12p"; + case YCbCr709_422_12p_CbYCrY: return "YCbCr709_422_12p_CbYCrY"; + case YCbCr2020_8_CbYCr: return "YCbCr2020_8_CbYCr"; + case YCbCr2020_10_CbYCr: return "YCbCr2020_10_CbYCr"; + case YCbCr2020_10p_CbYCr: return "YCbCr2020_10p_CbYCr"; + case YCbCr2020_12_CbYCr: return "YCbCr2020_12_CbYCr"; + case YCbCr2020_12p_CbYCr: return "YCbCr2020_12p_CbYCr"; + case YCbCr2020_411_8_CbYYCrYY: return "YCbCr2020_411_8_CbYYCrYY"; + case YCbCr2020_422_8: return "YCbCr2020_422_8"; + case YCbCr2020_422_8_CbYCrY: return "YCbCr2020_422_8_CbYCrY"; + case YCbCr2020_422_10: return "YCbCr2020_422_10"; + case YCbCr2020_422_10_CbYCrY: return "YCbCr2020_422_10_CbYCrY"; + case YCbCr2020_422_10p: return "YCbCr2020_422_10p"; + case YCbCr2020_422_10p_CbYCrY: return "YCbCr2020_422_10p_CbYCrY"; + case YCbCr2020_422_12: return "YCbCr2020_422_12"; + case YCbCr2020_422_12_CbYCrY: return "YCbCr2020_422_12_CbYCrY"; + case YCbCr2020_422_12p: return "YCbCr2020_422_12p"; + case YCbCr2020_422_12p_CbYCrY: return "YCbCr2020_422_12p_CbYCrY"; + case YUV8_UYV: return "YUV8_UYV"; + case YUV411_8_UYYVYY: return "YUV411_8_UYYVYY"; + case YUV422_8: return "YUV422_8"; + case YUV422_8_UYVY: return "YUV422_8_UYVY"; + case Mono10Packed: return "Mono10Packed"; + case Mono12Packed: return "Mono12Packed"; + case BayerBG10Packed: return "BayerBG10Packed"; + case BayerBG12Packed: return "BayerBG12Packed"; + case BayerGB10Packed: return "BayerGB10Packed"; + case BayerGB12Packed: return "BayerGB12Packed"; + case BayerGR10Packed: return "BayerGR10Packed"; + case BayerGR12Packed: return "BayerGR12Packed"; + case BayerRG10Packed: return "BayerRG10Packed"; + case BayerRG12Packed: return "BayerRG12Packed"; + case RGB10V1Packed: return "RGB10V1Packed"; + case RGB12V1Packed: return "RGB12V1Packed"; + + case InvalidPixelFormat: return "InvalidPixelFormat"; + + default: return "UnknownPixelFormat"; + } +} +static PFNC_INLINE const char* GetPixelFormatDescription (PfncFormat format) +{ + switch (format) + { + case Mono1p: return "Monochrome 1-bit packed"; + case Mono2p: return "Monochrome 2-bit packed"; + case Mono4p: return "Monochrome 4-bit packed"; + case Mono8: return "Monochrome 8-bit"; + case Mono8s: return "Monochrome 8-bit signed"; + case Mono10: return "Monochrome 10-bit unpacked"; + case Mono10p: return "Monochrome 10-bit packed"; + case Mono12: return "Monochrome 12-bit unpacked"; + case Mono12p: return "Monochrome 12-bit packed"; + case Mono14: return "Monochrome 14-bit unpacked"; + case Mono14p: return "Monochrome 14-bit packed"; + case Mono16: return "Monochrome 16-bit"; + case Mono32: return "Monochrome 32-bit"; + case BayerBG4p: return "Bayer Blue-Green 4-bit packed"; + case BayerBG8: return "Bayer Blue-Green 8-bit"; + case BayerBG10: return "Bayer Blue-Green 10-bit unpacked"; + case BayerBG10p: return "Bayer Blue-Green 10-bit packed"; + case BayerBG12: return "Bayer Blue-Green 12-bit unpacked"; + case BayerBG12p: return "Bayer Blue-Green 12-bit packed"; + case BayerBG14: return "Bayer Blue-Green 14-bit"; + case BayerBG14p: return "Bayer Blue-Green 14-bit packed"; + case BayerBG16: return "Bayer Blue-Green 16-bit"; + case BayerGB4p: return "Bayer Green-Blue 4-bit packed"; + case BayerGB8: return "Bayer Green-Blue 8-bit"; + case BayerGB10: return "Bayer Green-Blue 10-bit unpacked"; + case BayerGB10p: return "Bayer Green-Blue 10-bit packed"; + case BayerGB12: return "Bayer Green-Blue 12-bit unpacked"; + case BayerGB12p: return "Bayer Green-Blue 12-bit packed"; + case BayerGB14: return "Bayer Green-Blue 14-bit"; + case BayerGB14p: return "Bayer Green-Blue 14-bit packed"; + case BayerGB16: return "Bayer Green-Blue 16-bit"; + case BayerGR4p: return "Bayer Green-Red 4-bit packed"; + case BayerGR8: return "Bayer Green-Red 8-bit"; + case BayerGR10: return "Bayer Green-Red 10-bit unpacked"; + case BayerGR10p: return "Bayer Green-Red 10-bit packed"; + case BayerGR12: return "Bayer Green-Red 12-bit unpacked"; + case BayerGR12p: return "Bayer Green-Red 12-bit packed"; + case BayerGR14: return "Bayer Green-Red 14-bit"; + case BayerGR14p: return "Bayer Green-Red 14-bit packed"; + case BayerGR16: return "Bayer Green-Red 16-bit"; + case BayerRG4p: return "Bayer Red-Green 4-bit packed"; + case BayerRG8: return "Bayer Red-Green 8-bit"; + case BayerRG10: return "Bayer Red-Green 10-bit unpacked"; + case BayerRG10p: return "Bayer Red-Green 10-bit packed"; + case BayerRG12: return "Bayer Red-Green 12-bit unpacked"; + case BayerRG12p: return "Bayer Red-Green 12-bit packed"; + case BayerRG14: return "Bayer Red-Green 14-bit"; + case BayerRG14p: return "Bayer Red-Green 14-bit packed"; + case BayerRG16: return "Bayer Red-Green 16-bit"; + case RGBa8: return "Red-Green-Blue-alpha 8-bit"; + case RGBa10: return "Red-Green-Blue-alpha 10-bit unpacked"; + case RGBa10p: return "Red-Green-Blue-alpha 10-bit packed"; + case RGBa12: return "Red-Green-Blue-alpha 12-bit unpacked"; + case RGBa12p: return "Red-Green-Blue-alpha 12-bit packed"; + case RGBa14: return "Red-Green-Blue-alpha 14-bit unpacked"; + case RGBa16: return "Red-Green-Blue-alpha 16-bit"; + case RGB8: return "Red-Green-Blue 8-bit"; + case RGB8_Planar: return "Red-Green-Blue 8-bit planar"; + case RGB10: return "Red-Green-Blue 10-bit unpacked"; + case RGB10_Planar: return "Red-Green-Blue 10-bit unpacked planar"; + case RGB10p: return "Red-Green-Blue 10-bit packed"; + case RGB10p32: return "Red-Green-Blue 10-bit packed into 32-bit"; + case RGB12: return "Red-Green-Blue 12-bit unpacked"; + case RGB12_Planar: return "Red-Green-Blue 12-bit unpacked planar"; + case RGB12p: return "Red-Green-Blue 12-bit packed"; + case RGB14: return "Red-Green-Blue 14-bit unpacked"; + case RGB16: return "Red-Green-Blue 16-bit"; + case RGB16_Planar: return "Red-Green-Blue 16-bit planar"; + case RGB565p: return "Red-Green-Blue 5/6/5-bit packed"; + case BGRa8: return "Blue-Green-Red-alpha 8-bit"; + case BGRa10: return "Blue-Green-Red-alpha 10-bit unpacked"; + case BGRa10p: return "Blue-Green-Red-alpha 10-bit packed"; + case BGRa12: return "Blue-Green-Red-alpha 12-bit unpacked"; + case BGRa12p: return "Blue-Green-Red-alpha 12-bit packed"; + case BGRa14: return "Blue-Green-Red-alpha 14-bit unpacked"; + case BGRa16: return "Blue-Green-Red-alpha 16-bit"; + case BGR8: return "Blue-Green-Red 8-bit"; + case BGR10: return "Blue-Green-Red 10-bit unpacked"; + case BGR10p: return "Blue-Green-Red 10-bit packed"; + case BGR12: return "Blue-Green-Red 12-bit unpacked"; + case BGR12p: return "Blue-Green-Red 12-bit packed"; + case BGR14: return "Blue-Green-Red 14-bit unpacked"; + case BGR16: return "Blue-Green-Red 16-bit"; + case BGR565p: return "Blue-Green-Red 5/6/5-bit packed"; + case R8: return "Red 8-bit"; + case R10: return "Red 10-bit"; + case R12: return "Red 12-bit"; + case R16: return "Red 16-bit"; + case G8: return "Green 8-bit"; + case G10: return "Green 10-bit"; + case G12: return "Green 12-bit"; + case G16: return "Green 16-bit"; + case B8: return "Blue 8-bit"; + case B10: return "Blue 10-bit"; + case B12: return "Blue 12-bit"; + case B16: return "Blue 16-bit"; + case Coord3D_ABC8: return "3D coordinate A-B-C 8-bit"; + case Coord3D_ABC8_Planar: return "3D coordinate A-B-C 8-bit planar"; + case Coord3D_ABC10p: return "3D coordinate A-B-C 10-bit packed"; + case Coord3D_ABC10p_Planar: return "3D coordinate A-B-C 10-bit packed planar"; + case Coord3D_ABC12p: return "3D coordinate A-B-C 12-bit packed"; + case Coord3D_ABC12p_Planar: return "3D coordinate A-B-C 12-bit packed planar"; + case Coord3D_ABC16: return "3D coordinate A-B-C 16-bit"; + case Coord3D_ABC16_Planar: return "3D coordinate A-B-C 16-bit planar"; + case Coord3D_ABC32f: return "3D coordinate A-B-C 32-bit floating point"; + case Coord3D_ABC32f_Planar: return "3D coordinate A-B-C 32-bit floating point planar"; + case Coord3D_AC8: return "3D coordinate A-C 8-bit"; + case Coord3D_AC8_Planar: return "3D coordinate A-C 8-bit planar"; + case Coord3D_AC10p: return "3D coordinate A-C 10-bit packed"; + case Coord3D_AC10p_Planar: return "3D coordinate A-C 10-bit packed planar"; + case Coord3D_AC12p: return "3D coordinate A-C 12-bit packed"; + case Coord3D_AC12p_Planar: return "3D coordinate A-C 12-bit packed planar"; + case Coord3D_AC16: return "3D coordinate A-C 16-bit"; + case Coord3D_AC16_Planar: return "3D coordinate A-C 16-bit planar"; + case Coord3D_AC32f: return "3D coordinate A-C 32-bit floating point"; + case Coord3D_AC32f_Planar: return "3D coordinate A-C 32-bit floating point planar"; + case Coord3D_A8: return "3D coordinate A 8-bit"; + case Coord3D_A10p: return "3D coordinate A 10-bit packed"; + case Coord3D_A12p: return "3D coordinate A 12-bit packed"; + case Coord3D_A16: return "3D coordinate A 16-bit"; + case Coord3D_A32f: return "3D coordinate A 32-bit floating point"; + case Coord3D_B8: return "3D coordinate B 8-bit"; + case Coord3D_B10p: return "3D coordinate B 10-bit packed"; + case Coord3D_B12p: return "3D coordinate B 12-bit packed"; + case Coord3D_B16: return "3D coordinate B 16-bit"; + case Coord3D_B32f: return "3D coordinate B 32-bit floating point"; + case Coord3D_C8: return "3D coordinate C 8-bit"; + case Coord3D_C10p: return "3D coordinate C 10-bit packed"; + case Coord3D_C12p: return "3D coordinate C 12-bit packed"; + case Coord3D_C16: return "3D coordinate C 16-bit"; + case Coord3D_C32f: return "3D coordinate C 32-bit floating point"; + case Confidence1: return "Confidence 1-bit unpacked"; + case Confidence1p: return "Confidence 1-bit packed"; + case Confidence8: return "Confidence 8-bit"; + case Confidence16: return "Confidence 16-bit"; + case Confidence32f: return "Confidence 32-bit floating point"; + case BiColorBGRG8: return "Bi-color Blue/Green - Red/Green 8-bit"; + case BiColorBGRG10: return "Bi-color Blue/Green - Red/Green 10-bit unpacked"; + case BiColorBGRG10p: return "Bi-color Blue/Green - Red/Green 10-bit packed"; + case BiColorBGRG12: return "Bi-color Blue/Green - Red/Green 12-bit unpacked"; + case BiColorBGRG12p: return "Bi-color Blue/Green - Red/Green 12-bit packed"; + case BiColorRGBG8: return "Bi-color Red/Green - Blue/Green 8-bit"; + case BiColorRGBG10: return "Bi-color Red/Green - Blue/Green 10-bit unpacked"; + case BiColorRGBG10p: return "Bi-color Red/Green - Blue/Green 10-bit packed"; + case BiColorRGBG12: return "Bi-color Red/Green - Blue/Green 12-bit unpacked"; + case BiColorRGBG12p: return "Bi-color Red/Green - Blue/Green 12-bit packed"; + case Data8: return "Data 8-bit"; + case Data8s: return "Data 8-bit signed"; + case Data16: return "Data 16-bit"; + case Data16s: return "Data 16-bit signed"; + case Data32: return "Data 32-bit"; + case Data32f: return "Data 32-bit floating point"; + case Data32s: return "Data 32-bit signed"; + case Data64: return "Data 64-bit"; + case Data64f: return "Data 64-bit floating point"; + case Data64s: return "Data 64-bit signed"; + case SCF1WBWG8: return "Sparse Color Filter #1 White-Blue-White-Green 8-bit"; + case SCF1WBWG10: return "Sparse Color Filter #1 White-Blue-White-Green 10-bit unpacked"; + case SCF1WBWG10p: return "Sparse Color Filter #1 White-Blue-White-Green 10-bit packed"; + case SCF1WBWG12: return "Sparse Color Filter #1 White-Blue-White-Green 12-bit unpacked"; + case SCF1WBWG12p: return "Sparse Color Filter #1 White-Blue-White-Green 12-bit packed"; + case SCF1WBWG14: return "Sparse Color Filter #1 White-Blue-White-Green 14-bit unpacked"; + case SCF1WBWG16: return "Sparse Color Filter #1 White-Blue-White-Green 16-bit unpacked"; + case SCF1WGWB8: return "Sparse Color Filter #1 White-Green-White-Blue 8-bit"; + case SCF1WGWB10: return "Sparse Color Filter #1 White-Green-White-Blue 10-bit unpacked"; + case SCF1WGWB10p: return "Sparse Color Filter #1 White-Green-White-Blue 10-bit packed"; + case SCF1WGWB12: return "Sparse Color Filter #1 White-Green-White-Blue 12-bit unpacked"; + case SCF1WGWB12p: return "Sparse Color Filter #1 White-Green-White-Blue 12-bit packed"; + case SCF1WGWB14: return "Sparse Color Filter #1 White-Green-White-Blue 14-bit unpacked"; + case SCF1WGWB16: return "Sparse Color Filter #1 White-Green-White-Blue 16-bit"; + case SCF1WGWR8: return "Sparse Color Filter #1 White-Green-White-Red 8-bit"; + case SCF1WGWR10: return "Sparse Color Filter #1 White-Green-White-Red 10-bit unpacked"; + case SCF1WGWR10p: return "Sparse Color Filter #1 White-Green-White-Red 10-bit packed"; + case SCF1WGWR12: return "Sparse Color Filter #1 White-Green-White-Red 12-bit unpacked"; + case SCF1WGWR12p: return "Sparse Color Filter #1 White-Green-White-Red 12-bit packed"; + case SCF1WGWR14: return "Sparse Color Filter #1 White-Green-White-Red 14-bit unpacked"; + case SCF1WGWR16: return "Sparse Color Filter #1 White-Green-White-Red 16-bit"; + case SCF1WRWG8: return "Sparse Color Filter #1 White-Red-White-Green 8-bit"; + case SCF1WRWG10: return "Sparse Color Filter #1 White-Red-White-Green 10-bit unpacked"; + case SCF1WRWG10p: return "Sparse Color Filter #1 White-Red-White-Green 10-bit packed"; + case SCF1WRWG12: return "Sparse Color Filter #1 White-Red-White-Green 12-bit unpacked"; + case SCF1WRWG12p: return "Sparse Color Filter #1 White-Red-White-Green 12-bit packed"; + case SCF1WRWG14: return "Sparse Color Filter #1 White-Red-White-Green 14-bit unpacked"; + case SCF1WRWG16: return "Sparse Color Filter #1 White-Red-White-Green 16-bit"; + case YCbCr8: return "YCbCr 4:4:4 8-bit"; + case YCbCr8_CbYCr: return "YCbCr 4:4:4 8-bit"; + case YCbCr10_CbYCr: return "YCbCr 4:4:4 10-bit unpacked"; + case YCbCr10p_CbYCr: return "YCbCr 4:4:4 10-bit packed"; + case YCbCr12_CbYCr: return "YCbCr 4:4:4 12-bit unpacked"; + case YCbCr12p_CbYCr: return "YCbCr 4:4:4 12-bit packed"; + case YCbCr411_8: return "YCbCr 4:1:1 8-bit"; + case YCbCr411_8_CbYYCrYY: return "YCbCr 4:1:1 8-bit"; + case YCbCr420_8_YY_CbCr_Semiplanar: return "YCbCr 4:2:0 8-bit YY/CbCr Semiplanar"; + case YCbCr420_8_YY_CrCb_Semiplanar: return "YCbCr 4:2:0 8-bit YY/CrCb Semiplanar"; + case YCbCr422_8: return "YCbCr 4:2:2 8-bit"; + case YCbCr422_8_CbYCrY: return "YCbCr 4:2:2 8-bit"; + case YCbCr422_8_YY_CbCr_Semiplanar: return "YCbCr 4:2:2 8-bit YY/CbCr Semiplanar"; + case YCbCr422_8_YY_CrCb_Semiplanar: return "YCbCr 4:2:2 8-bit YY/CrCb Semiplanar"; + case YCbCr422_10: return "YCbCr 4:2:2 10-bit unpacked"; + case YCbCr422_10_CbYCrY: return "YCbCr 4:2:2 10-bit unpacked"; + case YCbCr422_10p: return "YCbCr 4:2:2 10-bit packed"; + case YCbCr422_10p_CbYCrY: return "YCbCr 4:2:2 10-bit packed"; + case YCbCr422_12: return "YCbCr 4:2:2 12-bit unpacked"; + case YCbCr422_12_CbYCrY: return "YCbCr 4:2:2 12-bit unpacked"; + case YCbCr422_12p: return "YCbCr 4:2:2 12-bit packed"; + case YCbCr422_12p_CbYCrY: return "YCbCr 4:2:2 12-bit packed"; + case YCbCr601_8_CbYCr: return "YCbCr 4:4:4 8-bit BT.601"; + case YCbCr601_10_CbYCr: return "YCbCr 4:4:4 10-bit unpacked BT.601"; + case YCbCr601_10p_CbYCr: return "YCbCr 4:4:4 10-bit packed BT.601"; + case YCbCr601_12_CbYCr: return "YCbCr 4:4:4 12-bit unpacked BT.601"; + case YCbCr601_12p_CbYCr: return "YCbCr 4:4:4 12-bit packed BT.601"; + case YCbCr601_411_8_CbYYCrYY: return "YCbCr 4:1:1 8-bit BT.601"; + case YCbCr601_422_8: return "YCbCr 4:2:2 8-bit BT.601"; + case YCbCr601_422_8_CbYCrY: return "YCbCr 4:2:2 8-bit BT.601"; + case YCbCr601_422_10: return "YCbCr 4:2:2 10-bit unpacked BT.601"; + case YCbCr601_422_10_CbYCrY: return "YCbCr 4:2:2 10-bit unpacked BT.601"; + case YCbCr601_422_10p: return "YCbCr 4:2:2 10-bit packed BT.601"; + case YCbCr601_422_10p_CbYCrY: return "YCbCr 4:2:2 10-bit packed BT.601"; + case YCbCr601_422_12: return "YCbCr 4:2:2 12-bit unpacked BT.601"; + case YCbCr601_422_12_CbYCrY: return "YCbCr 4:2:2 12-bit unpacked BT.601"; + case YCbCr601_422_12p: return "YCbCr 4:2:2 12-bit packed BT.601"; + case YCbCr601_422_12p_CbYCrY: return "YCbCr 4:2:2 12-bit packed BT.601"; + case YCbCr709_8_CbYCr: return "YCbCr 4:4:4 8-bit BT.709"; + case YCbCr709_10_CbYCr: return "YCbCr 4:4:4 10-bit unpacked BT.709"; + case YCbCr709_10p_CbYCr: return "YCbCr 4:4:4 10-bit packed BT.709"; + case YCbCr709_12_CbYCr: return "YCbCr 4:4:4 12-bit unpacked BT.709"; + case YCbCr709_12p_CbYCr: return "YCbCr 4:4:4 12-bit packed BT.709"; + case YCbCr709_411_8_CbYYCrYY: return "YCbCr 4:1:1 8-bit BT.709"; + case YCbCr709_422_8: return "YCbCr 4:2:2 8-bit BT.709"; + case YCbCr709_422_8_CbYCrY: return "YCbCr 4:2:2 8-bit BT.709"; + case YCbCr709_422_10: return "YCbCr 4:2:2 10-bit unpacked BT.709"; + case YCbCr709_422_10_CbYCrY: return "YCbCr 4:2:2 10-bit unpacked BT.709"; + case YCbCr709_422_10p: return "YCbCr 4:2:2 10-bit packed BT.709"; + case YCbCr709_422_10p_CbYCrY: return "YCbCr 4:2:2 10-bit packed BT.709"; + case YCbCr709_422_12: return "YCbCr 4:2:2 12-bit unpacked BT.709"; + case YCbCr709_422_12_CbYCrY: return "YCbCr 4:2:2 12-bit unpacked BT.709"; + case YCbCr709_422_12p: return "YCbCr 4:2:2 12-bit packed BT.709"; + case YCbCr709_422_12p_CbYCrY: return "YCbCr 4:2:2 12-bit packed BT.709"; + case YCbCr2020_8_CbYCr: return "YCbCr 4:4:4 8-bit BT.2020"; + case YCbCr2020_10_CbYCr: return "YCbCr 4:4:4 10-bit unpacked BT.2020"; + case YCbCr2020_10p_CbYCr: return "YCbCr 4:4:4 10-bit packed BT.2020"; + case YCbCr2020_12_CbYCr: return "YCbCr 4:4:4 12-bit unpacked BT.2020"; + case YCbCr2020_12p_CbYCr: return "YCbCr 4:4:4 12-bit packed BT.2020"; + case YCbCr2020_411_8_CbYYCrYY: return "YCbCr 4:1:1 8-bit BT.2020"; + case YCbCr2020_422_8: return "YCbCr 4:2:2 8-bit BT.2020"; + case YCbCr2020_422_8_CbYCrY: return "YCbCr 4:2:2 8-bit BT.2020"; + case YCbCr2020_422_10: return "YCbCr 4:2:2 10-bit unpacked BT.2020"; + case YCbCr2020_422_10_CbYCrY: return "YCbCr 4:2:2 10-bit unpacked BT.2020"; + case YCbCr2020_422_10p: return "YCbCr 4:2:2 10-bit packed BT.2020"; + case YCbCr2020_422_10p_CbYCrY: return "YCbCr 4:2:2 10-bit packed BT.2020"; + case YCbCr2020_422_12: return "YCbCr 4:2:2 12-bit unpacked BT.2020"; + case YCbCr2020_422_12_CbYCrY: return "YCbCr 4:2:2 12-bit unpacked BT.2020"; + case YCbCr2020_422_12p: return "YCbCr 4:2:2 12-bit packed BT.2020"; + case YCbCr2020_422_12p_CbYCrY: return "YCbCr 4:2:2 12-bit packed BT.2020"; + case YUV8_UYV: return "YUV 4:4:4 8-bit"; + case YUV411_8_UYYVYY: return "YUV 4:1:1 8-bit"; + case YUV422_8: return "YUV 4:2:2 8-bit"; + case YUV422_8_UYVY: return "YUV 4:2:2 8-bit"; + case Mono10Packed: return "Monochrome 10-bit packed"; + case Mono12Packed: return "Monochrome 12-bit packed"; + case BayerBG10Packed: return "Bayer Blue-Green 10-bit packed"; + case BayerBG12Packed: return "Bayer Blue-Green 12-bit packed"; + case BayerGB10Packed: return "Bayer Green-Blue 10-bit packed"; + case BayerGB12Packed: return "Bayer Green-Blue 12-bit packed"; + case BayerGR10Packed: return "Bayer Green-Red 10-bit packed"; + case BayerGR12Packed: return "Bayer Green-Red 12-bit packed"; + case BayerRG10Packed: return "Bayer Red-Green 10-bit packed"; + case BayerRG12Packed: return "Bayer Red-Green 12-bit packed"; + case RGB10V1Packed: return "Red-Green-Blue 10-bit packed - variant 1"; + case RGB12V1Packed: return "Red-Green-Blue 12-bit packed - variant 1"; + + case InvalidPixelFormat: return "Invalid pixel format value"; + + default: return "Unknown pixel format value"; + } +} +#endif /* PFNC_INCLUDE_HELPERS */ + + +#endif /* PFNC_H */ diff --git a/Cigarette/Pylon6.2/include/pylonc/PylonAviCompressionOptions.h b/Cigarette/Pylon6.2/include/pylonc/PylonAviCompressionOptions.h new file mode 100644 index 0000000..536b5d2 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PylonAviCompressionOptions.h @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2012-2021 Basler AG + http://www.baslerweb.com +-----------------------------------------------------------------------------*/ +/*! + \file + \brief Contains PylonAviCompressionOptions_t definition. +*/ +#ifndef INCLUDED_PYLONAVICOMPRESSIONOPTIONS_H_6841242 +#define INCLUDED_PYLONAVICOMPRESSIONOPTIONS_H_6841242 + +#ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union +#endif + +#include + +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + +#include + +#pragma pack(push, PYLONC_PACKING) + +/** \addtogroup pylon pylon Interface +* @{ +*/ + +/** \brief Wraps the AVI compression options of the Video for Window API. File PylonAviCompressionOptions.h has to be included. +*/ +typedef struct tag_PylonAviCompressionOptions_t +{ + HWND hParentWindow; /*!< \brief Optional handle to the parent window for the Compression Options dialog box. See the Video for Windows API AviSaveOptions() MSDN documentation. */ + _Bool showDialog; /*!< \brief Optionally show Compression Options dialog box. See the Video for Windows API AviSaveOptions() MSDN documentation. */ + _Bool userDialogReturnOk; /*!< \brief Is set to true in the call to the CAviWriter::Open() method if the user pressed OK in the dialog. The compression is not set up if cancel has been pressed. */ + LONG autoKeyFrameInsertionRate; /*!< \brief Indicates to insert a key frame every nth image when KeyFrameSelection_Auto is used. */ + AVICOMPRESSOPTIONS compressionOptions; /*!< \brief The AVICOMPRESSOPTIONS structure needs to be set up with the four character code identifying the codec and the parameter settings of the codec. + For more information, see the MSDN documentation of the Video for Windows API and the documentation of the codec you are using. */ +} PylonAviCompressionOptions_t; + +/** +* @} +*/ + +#pragma pack(pop, PYLONC_PACKING) + +#endif /* INCLUDED_PYLONAVICOMPRESSIONOPTIONS_H_6841242 */ diff --git a/Cigarette/Pylon6.2/include/pylonc/PylonC.h b/Cigarette/Pylon6.2/include/pylonc/PylonC.h new file mode 100644 index 0000000..074bf87 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PylonC.h @@ -0,0 +1,615 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2009-2021 Basler AG + http://www.baslerweb.com + Author: AH, TK +-----------------------------------------------------------------------------*/ + +#ifndef PYLONC_PYLONC_H_ +#define PYLONC_PYLONC_H_ + +/** + \file + \brief pylon C bindings +*/ + + +#include /* for FILENAME_MAX */ +#include + +#ifdef GENAPIC_WIN_BUILD +# ifndef RPC_NO_WINDOWS_H +# define RPC_NO_WINDOWS_H // otherwise generates warnings on VC6 +# define RPC_NO_WINDOWS_H_DEFINED_BY_PYLONC +# endif +# include /* thread api needs windows headers */ +#endif +#include + +#include +#pragma pack(push, PYLONC_PACKING) + +#include +#include + + +#ifdef __cplusplus +// avoid namespace ambiguities between std::_Bool (from yvals.h) and ::_Bool (from GenApiCTypes.h) +# ifdef _MSC_VER +# define _Bool ::_Bool +# define PYLONC_BOOL_DEFINED +# endif + +extern "C" { +#endif /* __cplusplus */ + + /** \addtogroup pylon pylon Interface + * @{ + */ + + /* pylon invalid handle type */ +#define PYLONC_INVALID_HANDLE GENAPIC_INVALID_HANDLE + +/* pylon device access modes */ +#define PYLONC_ACCESS_MODE_MONITOR (0) +#define PYLONC_ACCESS_MODE_CONTROL (1 << 0) +#define PYLONC_ACCESS_MODE_STREAM (1 << 1) +#define PYLONC_ACCESS_MODE_EVENT (1 << 2) +#define PYLONC_ACCESS_MODE_EXCLUSIVE (1 << 3) + + /* pylon handle types */ + GENAPIC_DECLARE_HANDLE( PYLON_DEVICE_HANDLE ); /**< \brief A handle for a device object */ + GENAPIC_DECLARE_HANDLE( PYLON_DEVICE_INFO_HANDLE ); /**< \brief A handle for a device info object */ + GENAPIC_DECLARE_HANDLE( PYLON_INTERFACE_HANDLE ); /**< \brief A handle for an interface object */ + GENAPIC_DECLARE_HANDLE( PYLON_INTERFACE_INFO_HANDLE ); /**< \brief A handle for an interface info object */ + GENAPIC_DECLARE_HANDLE( PYLON_STREAMGRABBER_HANDLE ); /**< \brief A handle for a stream grabber object */ + GENAPIC_DECLARE_HANDLE( PYLON_EVENTGRABBER_HANDLE ); /**< \brief A handle for an event grabber object */ + GENAPIC_DECLARE_HANDLE( PYLON_CHUNKPARSER_HANDLE ); /**< \brief A handle for a chunk parser object */ + GENAPIC_DECLARE_HANDLE( PYLON_EVENTADAPTER_HANDLE ); /**< \brief A handle for an event adapter object */ + GENAPIC_DECLARE_HANDLE( PYLON_WAITOBJECT_HANDLE ); /**< \brief A handle for a wait object */ + GENAPIC_DECLARE_HANDLE( PYLON_WAITOBJECTS_HANDLE ); /**< \brief A handle for a node object set */ + GENAPIC_DECLARE_HANDLE( PYLON_STREAMBUFFER_HANDLE ); /**< \brief A handle for a stream buffer object */ + GENAPIC_DECLARE_HANDLE( PYLON_DEVICECALLBACK_HANDLE ); /**< \brief A handle for a device callback object */ + GENAPIC_DECLARE_HANDLE( PYLON_FORMAT_CONVERTER_HANDLE ); /**< \brief A handle for a pixel format converter object */ + GENAPIC_DECLARE_HANDLE( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE ); /**< \brief A handle for a pixel format converter object */ +#if defined(GENAPIC_WIN_BUILD) + GENAPIC_DECLARE_HANDLE( PYLON_AVI_WRITER_HANDLE ); /**< \brief A handle for an AVI writer */ +#endif + GENAPIC_DECLARE_HANDLE( PYLON_IMAGE_DECOMPRESSOR_HANDLE ); /**< \brief A handle for an image decompressor object */ + + /** \brief pylon device removal callback handler type. */ + typedef void PYLONC_CC PylonDeviceRemCb_t( PYLON_DEVICE_HANDLE h ); + + + /** \brief Result data struct for PylonStreamGrabberRetrieveResult(). + * This data describes grab results (typically image data) retrieved from the device. + * Some items are optional (marked as "optional") and are only filled in if they are supported by the device. + **/ + typedef struct tag_PylonGrabResult_t + { + const void* Context; /**< Application specific context specified when calling PylonStreamGrabberRegisterBuffer() */ + PYLON_STREAMBUFFER_HANDLE hBuffer; /**< Data buffer handle returned when calling PylonStreamGrabberRegisterBuffer() */ + const void* pBuffer; /**< Pointer to the raw data */ + EPylonGrabStatus Status; /**< Result status. check this to check whether the result contains valid data. */ + EPylonPayloadType PayloadType; /**< Type of data contained in buffer */ + EPylonPixelType PixelType; /**< Pixel type (if the result contains pixel data) */ + uint64_t TimeStamp; /**< Time stamp generated by the device when filling the result (optional)*/ + int SizeX; /**< Number of columns, in pixels (only if payload is image data) */ + int SizeY; /**< Number of rows, in pixels (only if payload is image data) */ + int OffsetX; /**< Starting column, in pixels (only if payload is image data) */ + int OffsetY; /**< Starting row, in pixels (only if payload is image data) */ + int PaddingX; /**< Number of extra data bytes at end of row (only if payload is image data) */ + int PaddingY; /**< Number of extra data bytes at end of image (only if payload is image data) */ + uint64_t PayloadSize; /**< Total payload size, in bytes, pointed to by pBuffer */ + unsigned int ErrorCode; /**< Additional error code in case Status is gst_Failed (optional) */ + uint64_t BlockID; /**< The block ID of the grabbed frame (camera device specific). + \par IEEE 1394 Camera Devices + The value of block ID is always UINT64_MAX. + + \par GigE Camera Devices + The sequence number starts with 1 and + wraps at 65535. The value 0 has a special meaning and indicates + that this feature is not supported by the camera. + + \par USB Camera Devices + The sequence number starts with 0 and uses the full 64 Bit range. + + \attention A block ID of value UINT64_MAX indicates that the Block ID is invalid and must not be used. */ + } PylonGrabResult_t; + + /** \brief Result data struct for PylonEventGrabberRetrieveEvent(). */ + typedef struct tag_PylonEventResult_t + { + unsigned char Buffer[576]; /**< Raw chunk data which can be passed to PylonChunkParserAttachBuffer() */ + unsigned int ErrorCode; /**< Error code if there was an error retrieving the event data */ + } PylonEventResult_t; + + struct tag_PylonAviCompressionOptions_t; + typedef struct tag_PylonAviCompressionOptions_t PylonAviCompressionOptions_t; + + /** \brief Holds the image persistence options. */ + typedef struct tag_PylonImagePersistenceOptions_t + { + int quality; /**< Can be used to control the quality when saving JPEG images. Valid quality values range from 0 to 100. */ + } PylonImagePersistenceOptions_t; + + /** \brief Optional result structure of PylonGigEIssueActionCommand() and PylonGigEIssueScheduledActionCommand(). */ + typedef struct tag_PylonGigEActionCommandResult_t + { + char DeviceAddress[12 + 3 + 1]; /**< IP address of the device. */ + int32_t Status; /**< GigE Vision status code returned by the device. See Pylon::EGigEActionCommandStatus for more information. */ + } PylonGigEActionCommandResult_t; + + /** + * @} + */ + + + /* + * ---------------------------------------------------------------------------- + * Initialization/Deinitialization/Misc functions + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonInitialize( void ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonTerminate( void ); + + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonSetProperty( int propertyId, const void* pData, size_t size ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGetProperty( int propertyId, void* pData, size_t* pSize ); + + + /* + * ---------------------------------------------------------------------------- + * Device factory: device enumeration, device creation + * ---------------------------------------------------------------------------- + */ + + /** \addtogroup pylon pylon Interface + * @{ + */ + + /** \brief Fixed string size for PylonDeviceInfo_t members. */ +#define PYLON_MAX_DEVICEINFO_ENTRY_LENGTH 64 + + /** \brief Device info struct. + * + * This struct provides general information about the device gathered during enumeration. + **/ + typedef struct tag_PylonDeviceInfo_t + { + char FullName[FILENAME_MAX]; /**< Full unique device name for identification */ + char FriendlyName[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< User friendly device name for display purpose */ + char VendorName[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< Manufacturer of the device*/ + char ModelName[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< Model name of the device*/ + char SerialNumber[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< Serial number of the device */ + char DeviceClass[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< The device class (transport layer) used by the device */ + char DeviceVersion[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< The device version as reported by the device */ + char UserDefinedName[PYLON_MAX_DEVICEINFO_ENTRY_LENGTH]; /**< User defined name, if present, as reported by the device */ + } PylonDeviceInfo_t; + + + /** \brief Fixed string size for PylonInterfaceInfo_t members. */ +#define PYLON_MAX_INTERFACEINFO_ENTRY_LENGTH 64 + + /** \brief Interface info struct. + * + * This struct provides general information about the interface gathered during enumeration. + **/ + typedef struct tag_PylonInterfaceInfo_t + { + char InterfaceID[PYLON_MAX_INTERFACEINFO_ENTRY_LENGTH]; /**< Interface ID for identification */ + char DeviceClass[PYLON_MAX_INTERFACEINFO_ENTRY_LENGTH]; /**< The device class (transport layer) used by the interface */ + char FriendlyName[PYLON_MAX_INTERFACEINFO_ENTRY_LENGTH]; /**< User friendly interface name for display purpose */ + char TlType[PYLON_MAX_INTERFACEINFO_ENTRY_LENGTH]; /**< Type of transport layer */ + } PylonInterfaceInfo_t; + + /** + * @} + */ + + /* + * ---------------------------------------------------------------------------- + * Interface functions + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEnumerateInterfaces( size_t* numInterfaces ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEnumerateInterfacesByDeviceClass( const char* pDeviceClass, size_t* numInterfaces ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGetInterfaceInfo( size_t index, PylonInterfaceInfo_t* pIfInfo ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonCreateInterfaceByIndex( size_t index, PYLON_INTERFACE_HANDLE* phIf ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDestroyInterface( PYLON_INTERFACE_HANDLE hIf ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonInterfaceOpen( PYLON_INTERFACE_HANDLE hIf ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonInterfaceClose( PYLON_INTERFACE_HANDLE hIf ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonInterfaceIsOpen( PYLON_INTERFACE_HANDLE hIf, _Bool* pOpen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonInterfaceGetInterfaceInfo( PYLON_INTERFACE_HANDLE hIf, PylonInterfaceInfo_t* pIfInfo ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonInterfaceGetNodeMap( PYLON_INTERFACE_HANDLE hIf, NODEMAP_HANDLE* phMap ); + + + /* + * ---------------------------------------------------------------------------- + * Device enumeration + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEnumerateDevices( size_t* numDevices ); + + + /* + * ---------------------------------------------------------------------------- + * GigE Device specific enumeration / creation + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEEnumerateAllDevices( size_t* numDevices ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEForceIp( const char* pMacAddress, const char* pIpAddress, const char* pSubnetMask, const char* pDefaultGateway ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigERestartIpConfiguration( const char* pMacAddress ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEChangeIpConfiguration( PYLON_DEVICE_HANDLE hDev, _Bool EnablePersistentIp, _Bool EnableDhcp ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigESetPersistentIpAddress( PYLON_DEVICE_HANDLE hDev, const char* pIpAddress, const char* pSubnetMask, const char* pDefaultGateway ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEAnnounceRemoteDevice( const char* pIpAddress ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigERenounceRemoteDevice( const char* pIpAddress, _Bool* pFound ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEGetPersistentIpAddress( PYLON_DEVICE_HANDLE hDev, char* pIpAddress, size_t* pIpAddressLen, char* pSubnetMask, size_t* pSubnetMaskLen, char* pDefaultGateway, size_t* pDefaultGatewayLen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEBroadcastIpConfiguration( const char* pMacAddress, _Bool EnablePersistentIp, _Bool EnableDHCP, const char* pIpAddress, const char* pSubnetMask, const char* pDefaultGateway, const char* pUserdefinedName, _Bool* pRetval ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEIssueActionCommand( uint32_t deviceKey, uint32_t groupKey, uint32_t groupMask, const char* pBroadcastAddress, uint32_t timeoutMs, uint32_t* pNumResults, PylonGigEActionCommandResult_t* pResults ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGigEIssueScheduledActionCommand( uint32_t deviceKey, uint32_t groupKey, uint32_t groupMask, uint64_t actiontimeNs, const char* pBroadcastAddress, uint32_t timeoutMs, uint32_t* pNumResults, PylonGigEActionCommandResult_t* pResults ); + + + /* + * ---------------------------------------------------------------------------- + * DeviceInfo + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGetDeviceInfo( size_t index, PylonDeviceInfo_t* pDi ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonGetDeviceInfoHandle( size_t index, PYLON_DEVICE_INFO_HANDLE* phDi ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceInfoGetNumProperties( PYLON_DEVICE_INFO_HANDLE hDi, size_t* numProperties ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceInfoGetPropertyValueByName( PYLON_DEVICE_INFO_HANDLE hDi, const char* pName, char* pValue, size_t* pBufLen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceInfoGetPropertyValueByIndex( PYLON_DEVICE_INFO_HANDLE hDi, size_t index, char* pBuf, size_t* pBufLen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceInfoGetPropertyName( PYLON_DEVICE_INFO_HANDLE hDi, size_t index, char* pName, size_t* pBufLen ); + + + /* + * ---------------------------------------------------------------------------- + * Device creation / destruction + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonCreateDeviceByIndex( size_t index, PYLON_DEVICE_HANDLE* phDev ); +#if defined(GENAPIC_WIN_BUILD) + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonCreateDeviceFromDirectShowID( int id, PYLON_DEVICE_HANDLE* phDev ); +#endif + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDestroyDevice( PYLON_DEVICE_HANDLE hDev ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonIsDeviceAccessible( size_t index, int accessMode, _Bool* pIsAccessible ); + + + /* + * ---------------------------------------------------------------------------- + * Device operations + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceOpen( PYLON_DEVICE_HANDLE hDev, int accessMode ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceClose( PYLON_DEVICE_HANDLE hDev ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceIsOpen( PYLON_DEVICE_HANDLE hDev, _Bool* pOpen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceAccessMode( PYLON_DEVICE_HANDLE hDev, int* pAccessMode ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetDeviceInfo( PYLON_DEVICE_HANDLE hDev, /* */ PylonDeviceInfo_t* pDeviceInfo ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetDeviceInfoHandle( PYLON_DEVICE_HANDLE hDev, PYLON_DEVICE_INFO_HANDLE* phDi ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetNumStreamGrabberChannels( PYLON_DEVICE_HANDLE hDev, size_t* pNumChannels ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetStreamGrabber( PYLON_DEVICE_HANDLE hDev, size_t index, PYLON_STREAMGRABBER_HANDLE* phStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetEventGrabber( PYLON_DEVICE_HANDLE hDev, PYLON_EVENTGRABBER_HANDLE* phEvg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetNodeMap( PYLON_DEVICE_HANDLE hDev, NODEMAP_HANDLE* phMap ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetTLNodeMap( PYLON_DEVICE_HANDLE hDev, NODEMAP_HANDLE* phMap ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceCreateChunkParser( PYLON_DEVICE_HANDLE hDev, PYLON_CHUNKPARSER_HANDLE* phChp ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceDestroyChunkParser( PYLON_DEVICE_HANDLE hDev, PYLON_CHUNKPARSER_HANDLE hChp ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceCreateEventAdapter( PYLON_DEVICE_HANDLE hDev, PYLON_EVENTADAPTER_HANDLE* phEva ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceDestroyEventAdapter( PYLON_DEVICE_HANDLE hDev, PYLON_EVENTADAPTER_HANDLE hEva ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceRegisterRemovalCallback( PYLON_DEVICE_HANDLE hDev, PylonDeviceRemCb_t* pCbFunction, PYLON_DEVICECALLBACK_HANDLE* phCb ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceDeregisterRemovalCallback( PYLON_DEVICE_HANDLE hDev, PYLON_DEVICECALLBACK_HANDLE hCb ); + + + /* + * ---------------------------------------------------------------------------- + * Device convenience methods to access the device node map + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceSetIntegerFeature( PYLON_DEVICE_HANDLE hDev, const char* pName, int64_t value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeature( PYLON_DEVICE_HANDLE hDev, const char* pName, int64_t* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureMin( PYLON_DEVICE_HANDLE hDev, const char* pName, int64_t* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureMax( PYLON_DEVICE_HANDLE hDev, const char* pName, int64_t* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureInc( PYLON_DEVICE_HANDLE hDev, const char* pName, int64_t* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGrabSingleFrame( PYLON_DEVICE_HANDLE hDev, size_t channel, void* pBuffer, size_t bufferSize, PylonGrabResult_t* pGrabResult, _Bool* pReady, uint32_t timeout ); + + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceSetFloatFeature( PYLON_DEVICE_HANDLE hDev, const char* pName, double value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetFloatFeature( PYLON_DEVICE_HANDLE hDev, const char* pName, double* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetFloatFeatureMin( PYLON_DEVICE_HANDLE hDev, const char* pName, double* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetFloatFeatureMax( PYLON_DEVICE_HANDLE hDev, const char* pName, double* pValue ); + + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceSetBooleanFeature( PYLON_DEVICE_HANDLE hDev, const char* pName, _Bool value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetBooleanFeature( PYLON_DEVICE_HANDLE hDev, const char* pName, _Bool* pValue ); + + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceExecuteCommandFeature( PYLON_DEVICE_HANDLE hDev, const char* pName ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceIsCommandDone( PYLON_DEVICE_HANDLE hDev, const char* pName, _Bool* pResult ); + + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceFeatureFromString( PYLON_DEVICE_HANDLE hDev, const char* pName, const char* pValue ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceFeatureToString( PYLON_DEVICE_HANDLE hDev, const char* pName, char* pBuf, size_t* pBufLen ); + + PYLONC_API _Bool PYLONC_CC PylonDeviceFeatureIsImplemented( PYLON_DEVICE_HANDLE hDev, const char* pName ); + PYLONC_API _Bool PYLONC_CC PylonDeviceFeatureIsAvailable( PYLON_DEVICE_HANDLE hDev, const char* pName ); + PYLONC_API _Bool PYLONC_CC PylonDeviceFeatureIsReadable( PYLON_DEVICE_HANDLE hDev, const char* pName ); + PYLONC_API _Bool PYLONC_CC PylonDeviceFeatureIsWritable( PYLON_DEVICE_HANDLE hDev, const char* pName ); + PYLONC_API GENAPIC_RESULT GENAPIC_CC PylonDeviceFeatureGetAccessMode( PYLON_DEVICE_HANDLE hDev, const char* pName, EGenApiAccessMode* pResult ); + + + /* + * ---------------------------------------------------------------------------- + * Stream grabber operations + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberOpen( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberClose( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberIsOpen( PYLON_STREAMGRABBER_HANDLE hStg, _Bool* pOpen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberGetWaitObject( PYLON_STREAMGRABBER_HANDLE hStg, PYLON_WAITOBJECT_HANDLE* phWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberSetMaxNumBuffer( PYLON_STREAMGRABBER_HANDLE hStg, size_t numBuffers ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberGetMaxNumBuffer( PYLON_STREAMGRABBER_HANDLE hStg, size_t* pNumBuffers ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberSetMaxBufferSize( PYLON_STREAMGRABBER_HANDLE hStg, size_t maxSize ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberGetMaxBufferSize( PYLON_STREAMGRABBER_HANDLE hStg, size_t* pMaxSize ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberGetPayloadSize( PYLON_DEVICE_HANDLE hDev, PYLON_STREAMGRABBER_HANDLE hStg, size_t* payloadsize ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberRegisterBuffer( PYLON_STREAMGRABBER_HANDLE hStg, void* pBuffer, size_t BufLen, PYLON_STREAMBUFFER_HANDLE* phBuf ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberDeregisterBuffer( PYLON_STREAMGRABBER_HANDLE hStg, PYLON_STREAMBUFFER_HANDLE hBuf ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberPrepareGrab( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberIsStartAndStopStreamingMandatory( PYLON_STREAMGRABBER_HANDLE hStg, _Bool* pMandatory ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberStartStreamingIfMandatory( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberStopStreamingIfMandatory( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberFinishGrab( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberFlushBuffersToOutput( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberCancelGrab( PYLON_STREAMGRABBER_HANDLE hStg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberRetrieveResult( PYLON_STREAMGRABBER_HANDLE hStg, PylonGrabResult_t* pGrabResult, _Bool* pReady ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberQueueBuffer( PYLON_STREAMGRABBER_HANDLE hStg, PYLON_STREAMBUFFER_HANDLE hBuf, const void* pContext ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonStreamGrabberGetNodeMap( PYLON_STREAMGRABBER_HANDLE hStg, NODEMAP_HANDLE* phMap ); + + + /* + * ---------------------------------------------------------------------------- + * Wait object + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectIsValid( PYLON_WAITOBJECT_HANDLE hWobj, _Bool* pValid ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectWait( PYLON_WAITOBJECT_HANDLE hWobj, uint32_t timeout, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectWaitEx( PYLON_WAITOBJECT_HANDLE hWobj, uint32_t timeout, _Bool alertable, EPylonWaitExResult* pWaitResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectCreate( PYLON_WAITOBJECT_HANDLE* phWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectDestroy( PYLON_WAITOBJECT_HANDLE hWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectSignal( PYLON_WAITOBJECT_HANDLE hWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectReset( PYLON_WAITOBJECT_HANDLE hWobj ); + +#if defined(GENAPIC_LINUX_BUILD) + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectFromFd( int fd, PYLON_WAITOBJECT_HANDLE* phWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectGetFd( PYLON_WAITOBJECT_HANDLE hWobj, int* pFd ); +#elif defined(GENAPIC_WIN_BUILD) + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectFromW32( HANDLE hW32, _Bool duplicate, PYLON_WAITOBJECT_HANDLE* phWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectGetW32Handle( PYLON_WAITOBJECT_HANDLE hWobj, PHANDLE phW32 ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonRTThreadGetPriorityCapabilities( int32_t* pPriorityMin, int32_t* pPriorityMax ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonRTThreadSetPriority( HANDLE hThread, int32_t priority ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonRTThreadGetPriority( HANDLE hThread, int32_t* pPriority ); +#endif /* GENAPIC_WIN_BUILD */ + + /* + * ---------------------------------------------------------------------------- + * Wait objects + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsCreate( PYLON_WAITOBJECTS_HANDLE* phWos ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsDestroy( PYLON_WAITOBJECTS_HANDLE hWos ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsAdd( PYLON_WAITOBJECTS_HANDLE hWos, PYLON_WAITOBJECT_HANDLE hWobj, size_t* pIndex ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsAddMany( PYLON_WAITOBJECTS_HANDLE hWos, size_t numWaitObjects, ... ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsRemoveAll( PYLON_WAITOBJECTS_HANDLE hWos ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsWaitForAll( PYLON_WAITOBJECTS_HANDLE hWos, uint32_t timeout, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsWaitForAny( PYLON_WAITOBJECTS_HANDLE hWos, uint32_t timeout, size_t* pIndex, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsWaitForAny( PYLON_WAITOBJECTS_HANDLE hWos, uint32_t timeout, size_t* pIndex, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsWaitForAllEx( PYLON_WAITOBJECTS_HANDLE hWos, uint32_t timeout, _Bool alertable, EPylonWaitExResult* pWaitResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonWaitObjectsWaitForAnyEx( PYLON_WAITOBJECTS_HANDLE hWos, uint32_t timeout, size_t* pIndex, _Bool alertable, EPylonWaitExResult* pWaitResult ); + + + /* + * ---------------------------------------------------------------------------- + * Event grabber + * ---------------------------------------------------------------------------- + */ + extern PYLONC_API const size_t PylonEventGrabberBufferSize; + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberOpen( PYLON_EVENTGRABBER_HANDLE hEvg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberClose( PYLON_EVENTGRABBER_HANDLE hEvg ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberIsOpen( PYLON_EVENTGRABBER_HANDLE hEvg, _Bool* pOpen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberRetrieveEvent( PYLON_EVENTGRABBER_HANDLE hEvg, PylonEventResult_t* pEventResult, _Bool* pReady ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberGetWaitObject( PYLON_EVENTGRABBER_HANDLE hEvg, PYLON_WAITOBJECT_HANDLE* phWobj ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberGetNodeMap( PYLON_EVENTGRABBER_HANDLE hEvg, NODEMAP_HANDLE* phMap ); + + + /* + * ---------------------------------------------------------------------------- + * Event grabber convenience methods + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberGetNumBuffers( PYLON_EVENTGRABBER_HANDLE hEvg, size_t* pNumBuffers ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventGrabberSetNumBuffers( PYLON_EVENTGRABBER_HANDLE hEvg, size_t numBuffers ); + + + /* + * ---------------------------------------------------------------------------- + * Event adapter + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonEventAdapterDeliverMessage( PYLON_EVENTADAPTER_HANDLE hEva, const PylonEventResult_t* pEventResult ); + + + /* + * ---------------------------------------------------------------------------- + * Chunk parser + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonChunkParserAttachBuffer( PYLON_CHUNKPARSER_HANDLE hChp, const void* pBuffer, size_t BufLen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonChunkParserDetachBuffer( PYLON_CHUNKPARSER_HANDLE hChp ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonChunkParserUpdateBuffer( PYLON_CHUNKPARSER_HANDLE hChp, const void* pBuffer ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonChunkParserHasCRC( PYLON_CHUNKPARSER_HANDLE hChp, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonChunkParserCheckCRC( PYLON_CHUNKPARSER_HANDLE hChp, _Bool* pResult ); + + + /* + * ---------------------------------------------------------------------------- + * Deprecated PixelFormat functions. Use ImageFormat functions instead. + * ---------------------------------------------------------------------------- + */ + /* Deprecated: PylonPixelFormatConverterCreate has been deprecated. Use PylonImageFormatConverterCreate instead. */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonPixelFormatConverterCreate( PYLON_DEVICE_HANDLE hDev, int outAlign, PYLON_FORMAT_CONVERTER_HANDLE* phConv ); + /* Deprecated: PylonPixelFormatConverterConvert has been deprecated. Use PylonImageFormatConverterConvert instead. */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonPixelFormatConverterConvert( PYLON_FORMAT_CONVERTER_HANDLE hConv, void* targetBuffer, size_t targetBufferSize, const void* sourceBuffer, size_t sourceBufferSize ); + /* Deprecated: PylonPixelFormatConverterGetOutputBufferSize has been deprecated. Use PylonImageFormatConverterGetBufferSizeForConversion instead. */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonPixelFormatConverterGetOutputBufferSize( PYLON_FORMAT_CONVERTER_HANDLE hConv, size_t* pBufSiz ); + /* Deprecated: PylonPixelFormatConverterDestroy has been deprecated. Use PylonImageFormatConverterDestroy instead. */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonPixelFormatConverterDestroy( PYLON_FORMAT_CONVERTER_HANDLE hConv ); + + + /* + * ---------------------------------------------------------------------------- + * Pixel Type operations + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonBitsPerPixel( EPylonPixelType pixelType, int* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonIsMono( EPylonPixelType pixelType, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonIsBayer( EPylonPixelType pixelType, _Bool* pResult ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonPixelTypeFromString( const char* pString, EPylonPixelType* pPixelType ); + + + + /* + * ---------------------------------------------------------------------------- + * Port read and write operations + * ---------------------------------------------------------------------------- + */ + GENAPIC_API GENAPIC_RESULT GENAPIC_CC PylonDevicePortRead( PYLON_DEVICE_HANDLE hDev, void* pBuffer, int64_t Address, size_t Length ); + GENAPIC_API GENAPIC_RESULT GENAPIC_CC PylonDevicePortWrite( PYLON_DEVICE_HANDLE hDev, const void* pBuffer, int64_t Address, size_t Length ); + + + /* + * ---------------------------------------------------------------------------- + * Feature Persistence + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonFeaturePersistenceSave( NODEMAP_HANDLE hMap, const char* pFileName ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonFeaturePersistenceLoad( NODEMAP_HANDLE hMap, const char* pFileName, _Bool verify ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonFeaturePersistenceSaveToString( NODEMAP_HANDLE hMap, char* pFeatures, size_t* pFeaturesLen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonFeaturePersistenceLoadFromString( NODEMAP_HANDLE hMap, const char* pFeatures, _Bool verify ); + + + /* + * ---------------------------------------------------------------------------- + * Image Persistence + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImagePersistenceSave( EPylonImageFileFormat imageFileFormat, const char* pFilename, const void* pBuffer, size_t bufferSize, EPylonPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EPylonImageOrientation orientation, PylonImagePersistenceOptions_t* pOptions ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImagePersistenceLoad( const char* pFilename, void* pBuffer, size_t* pBufferSize, EPylonPixelType* pPixelType, uint32_t* pWidth, uint32_t* pHeight, size_t* pPaddingX, EPylonImageOrientation* pOrientation ); + + + /* + * ---------------------------------------------------------------------------- + * Image Format Converter + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterCreate( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE* phConv ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterGetNodeMap( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, NODEMAP_HANDLE* phMap ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterSetOutputPixelFormat( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, EPylonPixelType pixelType ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterGetOutputPixelFormat( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, EPylonPixelType* pPixelType ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterSetOutputPaddingX( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, size_t paddingX ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterGetOutputPaddingX( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, size_t* pPaddingX ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterConvert( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, void* targetBuffer, size_t targetBufferSize, const void* sourceBuffer, size_t sourceBufferSize, EPylonPixelType sourcePixelType, uint32_t sourceWidth, uint32_t sourceHeight, size_t sourcePaddingX, EPylonImageOrientation sourceOrientation ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterGetBufferSizeForConversion( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv, EPylonPixelType sourcePixelType, uint32_t sourceWidth, uint32_t sourceHeight, size_t* pBufSize ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageFormatConverterDestroy( PYLON_IMAGE_FORMAT_CONVERTER_HANDLE hConv ); + + + /* + * ---------------------------------------------------------------------------- + * Avi Writer + * ---------------------------------------------------------------------------- + */ +#if defined(GENAPIC_WIN_BUILD) + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterCreate( PYLON_AVI_WRITER_HANDLE* phWriter ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterDestroy( PYLON_AVI_WRITER_HANDLE hWriter ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterOpen( PYLON_AVI_WRITER_HANDLE hWriter, const char* pFilename, double framesPerSecondPlayback, EPylonPixelType pixelType, uint32_t width, uint32_t height, EPylonImageOrientation orientation, PylonAviCompressionOptions_t* pCompressionOptions ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterClose( PYLON_AVI_WRITER_HANDLE hWriter ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterIsOpen( PYLON_AVI_WRITER_HANDLE hWriter, _Bool* pIsOpen ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterAdd( PYLON_AVI_WRITER_HANDLE hWriter, const void* pBuffer, size_t bufferSize, EPylonPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EPylonImageOrientation orientation, EPylonKeyFrameSelection keyFrameSelection ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterCanAddWithoutConversion( PYLON_AVI_WRITER_HANDLE hWriter, EPylonPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EPylonImageOrientation orientation, _Bool* pCanAddWithoutConversion ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterGetImageDataBytesWritten( PYLON_AVI_WRITER_HANDLE hWriter, size_t* pImageDataBytesWritten ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonAviWriterGetCountOfAddedImages( PYLON_AVI_WRITER_HANDLE hWriter, size_t* pCountOfAddedImages ); +#endif + + + /* + * ---------------------------------------------------------------------------- + * Image Window + * ---------------------------------------------------------------------------- + */ + /* */ +#if defined(GENAPIC_WIN_BUILD) + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowCreate( size_t winIndex, int x, int y, int nWidth, int nHeight ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowShow( size_t winIndex, int nShow ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowHide( size_t winIndex ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowClose( size_t winIndex ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowGetWindowHandle( size_t winIndex, HWND* phWindow ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowSetImage( size_t winIndex, const void* buffer, size_t bufferSize, EPylonPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EPylonImageOrientation orientation ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowDisplayImage( size_t winIndex, const void* buffer, size_t bufferSize, EPylonPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, EPylonImageOrientation orientation ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageWindowDisplayImageGrabResult( size_t winIndex, PylonGrabResult_t* grabResult ); +#endif + + + /* + * ---------------------------------------------------------------------------- + * Image Decompressor + * ---------------------------------------------------------------------------- + */ + + /** \brief The struct containing information about a grab buffer/result. + + If the hasCompressedImage field in the struct is true, the grab buffer/result + contains a compressed image. In this case, you should check the compressionStatus + field in the struct to check whether the camera was able to compress + the image properly. The camera can't compress an image if the amount of + data required for compressing the image exceeds the desired compression ratio. + The image can be decompressed if compressionStatus is CompressionStatus_Ok. + If the hasCompressedImage field in the struct is false, the grab buffer/result + already contains a decompressed image. In this case, the decompressedImageSize + and decompressedPayloadSize fields will not be used. All other fields contain + information about the decompressed data. + **/ + typedef struct tag_PylonCompressionInfo_t + { + _Bool HasCompressedImage; /**< True if grab buffer/result provided contains a compressed image (otherwise false if buffer/result is already decompressed). */ + EPylonCompressionStatus CompressionStatus; /**< Status of compression (see EPylonCompressionStatus). */ + _Bool Lossy; /**< True if image was compressed lossily (otherwise false if it was compressed losslessly). */ + EPylonPixelType PixelType; /**< Pixel type of compressed image. */ + int SizeX; /**< Width (in pixels) of compressed image. */ + int SizeY; /**< Height (in pixels) of compressed image. */ + int OffsetX; /**< X offset (in pixels) of compressed image. */ + int OffsetY; /**< Y offset (in pixels) of compressed image. */ + int PaddingX; /**< X padding (line padding; in bytes) of compressed image. */ + int PaddingY; /**< Y padding (image padding; in bytes) of compressed image. */ + size_t DecompressedImageSize; /**< Size (in bytes) required for the decompressed image (only valid if hasCompressedImage is true). */ + size_t DecompressedPayloadSize; /**< Size (in bytes; including chunk data) required for the decompressed payload (only valid if hasCompressedImage is true). */ + } PylonCompressionInfo_t; + + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageDecompressorCreate( PYLON_IMAGE_DECOMPRESSOR_HANDLE* phDecompressor ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageDecompressorDestroy( PYLON_IMAGE_DECOMPRESSOR_HANDLE hDecompressor ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageDecompressorSetCompressionDescriptor( PYLON_IMAGE_DECOMPRESSOR_HANDLE hDecompressor, const void* pCompressionDescriptor, size_t sizeCompressionDescriptor ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageDecompressorGetCompressionInfo( const void* pPayload, size_t payloadSize, PylonCompressionInfo_t* pCompressionInfo ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonImageDecompressorDecompressImage( PYLON_IMAGE_DECOMPRESSOR_HANDLE hDecompressor, void* pOutputBuffer, size_t* pOutputBufferSize, const void* pPayload, size_t payloadSize, PylonCompressionInfo_t* pCompressionInfo ); + + +#ifdef __cplusplus +} /* extern "C" */ +# ifdef PYLONC_BOOL_DEFINED +# undef _Bool +# undef PYLONC_BOOL_DEFINED +# endif +#endif /* __cplusplus */ + +#include + +/* undefine macros defined by this header */ +#if defined(RPC_NO_WINDOWS_H_DEFINED_BY_PYLONC) +# undef RPC_NO_WINDOWS_H_DEFINED_BY_PYLONC +# undef RPC_NO_WINDOWS_H +#endif + +#pragma pack(pop) + +#endif /* PYLONC_PYLONC_H_ */ diff --git a/Cigarette/Pylon6.2/include/pylonc/PylonC32BitMethods.h b/Cigarette/Pylon6.2/include/pylonc/PylonC32BitMethods.h new file mode 100644 index 0000000..c7558ec --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PylonC32BitMethods.h @@ -0,0 +1,47 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2009-2021 Basler AG + http://www.baslerweb.com + Author: AH, TK +-----------------------------------------------------------------------------*/ + +#ifndef PylonC32BitMethods_h__ +#define PylonC32BitMethods_h__ + +#include +#include + +#include +#pragma pack(push, PYLONC_PACKING) + +#include + +/** + \file + \brief pylon C bindings - 32 bit functions. +*/ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* + * ---------------------------------------------------------------------------- + * Functions doing an implicit cast to 32-bit values + * ---------------------------------------------------------------------------- + */ + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceSetIntegerFeatureInt32( PYLON_DEVICE_HANDLE dev, const char* name, int32_t value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureInt32( PYLON_DEVICE_HANDLE dev, const char* name, int32_t* value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureMinInt32( PYLON_DEVICE_HANDLE dev, const char* name, int32_t* value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureMaxInt32( PYLON_DEVICE_HANDLE dev, const char* name, int32_t* value ); + PYLONC_API GENAPIC_RESULT PYLONC_CC PylonDeviceGetIntegerFeatureIncInt32( PYLON_DEVICE_HANDLE dev, const char* name, int32_t* value ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#pragma pack(pop) + +#endif /* PylonC32BitMethods_h__ */ diff --git a/Cigarette/Pylon6.2/include/pylonc/PylonCDefines.h b/Cigarette/Pylon6.2/include/pylonc/PylonCDefines.h new file mode 100644 index 0000000..67fb57f --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PylonCDefines.h @@ -0,0 +1,66 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2012-2021 Basler AG + http://www.baslerweb.com + ------------------------------------------------------------------------------*/ +#ifndef PylonCDefines_h__ +#define PylonCDefines_h__ + +/** + \file + \brief pylon C bindings - macro definitions. +*/ + + +#include + +#ifdef GENAPIC_WIN_BUILD +# ifdef PYLONC_EXPORTS +# define PYLONC_API __declspec(dllexport) +# else +# define PYLONC_API __declspec(dllimport) +# endif +# define PYLONC_CC _stdcall +# define PYLONC_PACKING 8 +#elif defined GENAPIC_LINUX_BUILD +# ifdef PYLONC_EXPORTS +# define PYLONC_API __attribute__((visibility("default"))) +# else +# define PYLONC_API +# endif +# define PYLONC_CC +# define PYLONC_PACKING 8 +#else +# error Unsupported platform +#endif + +#define PYLON_DEVINFO_FULL_NAME_KEY "FullName" //!< The full name identifying the device. +#define PYLON_DEVINFO_FRIENDLY_NAME_KEY "FriendlyName" //!< The human readable name of the device. +#define PYLON_DEVINFO_VENDOR_NAME_KEY "VendorName" //!< The vendor name of the device. +#define PYLON_DEVINFO_DEVICE_CLASS_KEY "DeviceClass" //!< The device class device, e.g. Basler1394. +#define PYLON_DEVINFO_SERIAL_NUMBER_KEY "SerialNumber" //!< The serial number if it supported by the underlying implementation +#define PYLON_DEVINFO_USER_DEFINED_NAME_KEY "UserDefinedName" //!< The user-defined name if present. +#define PYLON_DEVINFO_MODEL_NAME_KEY "ModelName" //!< The model name of the device. +#define PYLON_DEVINFO_DEVICE_FACTORY_KEY "DeviceFactory" //!< The identifier for the transport layer able to create this device. +#define PYLON_DEVINFO_DEVICE_VERSION_KEY "DeviceVersion" //!< The version string of the device. +#define PYLON_DEVINFO_TL_TYPE_KEY "TLType" //!< The transport layer type of the device. +#define PYLON_DEVINFO_INTERFACE_ID_KEY "InterfaceID" //!< The ID of the interface that the device is connected to. +#define PYLON_DEVINFO_DEVICE_ID_KEY "DeviceID" //!< The device ID (e.g., used by Camera Link and GenTL Consumer). +#define PYLON_DEVINFO_ADDRESS_KEY "Address" //!< GigE Device: The IP address of the device IP address in a human-readable representation including the port number. +#define PYLON_DEVINFO_IP_ADDRESS_KEY "IpAddress" //!< GigE Device: The IP address of the device IP address in a human-readable representation. +#define PYLON_DEVINFO_DEFAULT_GATEWAY_KEY "DefaultGateway" //!< GigE Device: The default gateway of the device IP address in a human-readable representation. +#define PYLON_DEVINFO_SUBNET_MASK_KEY "SubnetMask" //!< GigE Device: The subnet mask of the device IP address in a human-readable representation. +#define PYLON_DEVINFO_PORT_NR_KEY "PortNr" //!< GigE Device: The port number used. +#define PYLON_DEVINFO_MAC_ADDRESS_KEY "MacAddress" //!< GigE Device: The MAC address of the device of the device IP address in a human-readable representation. +#define PYLON_DEVINFO_INTERFACE_KEY "Interface" //!< GigE Device: The address of the network interface the device is connected to. +#define PYLON_DEVINFO_IP_CONFIG_OPTIONS_KEY "IpConfigOptions" //!< GigE Device: The persistent IP configuration options. +#define PYLON_DEVINFO_IP_CONFIG_CURRENT_KEY "IpConfigCurrent" //!< GigE Device: The current IP configuration of the device. +#define PYLON_DEVINFO_SUBNET_ADDRESS_KEY "SubnetAddress" //!< GigE Device: The IP address of the subnet the device belongs to. +#define PYLON_DEVINFO_PORT_ID_KEY "PortID" //!< Camera Link Device: The ID of the serial port the device is connected to. +#define PYLON_DEVINFO_INITIAL_BAUD_RATE_KEY "InitialBaudRate" //!< Camera Link Device: The initial baud rate of the serial port the device is connected to. +#define PYLON_DEVINFO_DEVICE_GUID_KEY "DeviceGUID" //!< USB Device: The device GUID. +#define PYLON_DEVINFO_MANUFACTURER_INFO_KEY "ManufacturerInfo"//!< USB Device: The manufacturer info. + +#define PYLON_IMAGE_WINDOW_USEDEFAULT 0x80000000 + +#endif /* PylonCDefines_h__ */ diff --git a/Cigarette/Pylon6.2/include/pylonc/PylonCEnums.h b/Cigarette/Pylon6.2/include/pylonc/PylonCEnums.h new file mode 100644 index 0000000..3f67f32 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PylonCEnums.h @@ -0,0 +1,280 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2012-2021 Basler AG + http://www.baslerweb.com +-----------------------------------------------------------------------------*/ +#ifndef PYLON_ENUMS_H +#define PYLON_ENUMS_H + +#include + +/** + * \file + * \brief pylon enumeration types. + * + * Definitions of enumerated types used by pylon C functions. + */ + +/** + * \addtogroup pylon pylon Interface + * @{ + */ + +/** + * \brief The reason why a wait operation terminated. + */ +typedef enum +{ + waitex_timeout = 0, /*!< \brief The time-out interval elapsed */ + waitex_signaled = 1, /*!< \brief The wait operation completed successfully */ + waitex_abandoned = 2, /*!< \brief Windows only (see MSDN for more information) */ + waitex_alerted = -1 /*!< \brief The wait was interrupted (Windows: queued APC or I/O completion routine; UNIX: signal) */ +} EPylonWaitExResult; + +/** + * \brief The grab status. + */ +typedef enum +{ + UndefinedGrabStatus = -1, /*!< \brief status not defined */ + Idle, /*!< \brief currently not used */ + Queued, /*!< \brief in the input queue */ + Grabbed, /*!< \brief filled with data */ + Canceled, /*!< \brief request was canceled */ + Failed /*!< \brief request failed */ +} EPylonGrabStatus; + +/** + * \brief PayloadType for PylonGrabResult_t + */ +typedef enum +{ + PayloadType_Undefined = -1, /*!< \brief The buffer content is undefined. */ + PayloadType_Image, /*!< \brief The buffer contains image data. */ + PayloadType_RawData, /*!< \brief The buffer contains raw data. */ + PayloadType_File, /*!< \brief The buffer contains file data. */ + PayloadType_ChunkData, /*!< \brief The buffer contains chunk data. */ + PayloadType_GenDC, /*!< \brief The buffer contains GenDC container. */ + PayloadType_DeviceSpecific = 0x8000 /*!< \brief The buffer contains device specific data. */ +} EPylonPayloadType; + +#define PIXEL_MONO (0x01000000) +#define PIXEL_COLOR (0x02000000) +#define PIXEL_CUSTOMTYPE (0x80000000) +#define PIXEL_BIT_COUNT(n) ((n) << 16) + +/*! \brief List all possible pixel formats. See the camera User's Manual for a detailed description of the available pixel formats. */ +typedef enum +{ + PixelType_Undefined = -1, /*!< \brief Indicates that the pixel format is undefined or not valid. */ + PixelType_Mono8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0001, /*!< \brief Indicates the Mono 8 pixel format. */ + PixelType_Mono8signed = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0002, /*!< \brief Indicates the Mono 8 Signed pixel format. */ + PixelType_Mono10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0003, /*!< \brief Indicates the Mono 10 pixel format. */ + PixelType_Mono10packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0004, /*!< \brief Indicates the Mono 10 Packed pixel format. The memory layout of PixelType_Mono10packed and PixelType_Mono10p is different*/ + PixelType_Mono10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0046, /*!< \brief Indicates the Mono10p pixel format. The memory layout of PixelType_Mono10packed and PixelType_Mono10p is different*/ + PixelType_Mono12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0005, /*!< \brief Indicates the Mono 12 pixel format. */ + PixelType_Mono12packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0006, /*!< \brief Indicates the Mono 12 Packed pixel format. The memory layout of PixelType_Mono12packed and PixelType_Mono12p is different.*/ + PixelType_Mono12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0047, /*!< \brief Indicates the Mono12p pixel format. The memory layout of PixelType_Mono12packed and PixelType_Mono12p is different.*/ + PixelType_Mono16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0007, /*!< \brief Indicates the Mono 16 pixel format. */ + + PixelType_BayerGR8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0008, /*!< \brief Indicates the Bayer GR 8 pixel format. */ + PixelType_BayerRG8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x0009, /*!< \brief Indicates the Bayer RG 8 pixel format. */ + PixelType_BayerGB8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x000a, /*!< \brief Indicates the Bayer GB 8 pixel format. */ + PixelType_BayerBG8 = PIXEL_MONO | PIXEL_BIT_COUNT( 8 ) | 0x000b, /*!< \brief Indicates the Bayer BG 8 pixel format. */ + + PixelType_BayerGR10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000c, /*!< \brief Indicates the Bayer GR 10 pixel format. */ + PixelType_BayerRG10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000d, /*!< \brief Indicates the Bayer RG 10 pixel format. */ + PixelType_BayerGB10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000e, /*!< \brief Indicates the Bayer GB 10 pixel format. */ + PixelType_BayerBG10 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x000f, /*!< \brief Indicates the Bayer BG 10 pixel format. */ + + PixelType_BayerGR12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0010, /*!< \brief Indicates the Bayer GR 12 pixel format. */ + PixelType_BayerRG12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0011, /*!< \brief Indicates the Bayer RG 12 pixel format. */ + PixelType_BayerGB12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0012, /*!< \brief Indicates the Bayer GB 12 pixel format. */ + PixelType_BayerBG12 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0013, /*!< \brief Indicates the Bayer BG 12 pixel format. */ + + PixelType_RGB8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0014, /*!< \brief Indicates the RGB 8 Packed pixel format. */ + PixelType_BGR8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0015, /*!< \brief Indicates the BGR 8 Packed pixel format. */ + + PixelType_RGBA8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x0016, /*!< \brief Indicates the RGBA 8 Packed pixel format. */ + PixelType_BGRA8packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x0017, /*!< \brief Indicates the BGRA 8 Packed pixel format. */ + + PixelType_RGB10packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0018, /*!< \brief Indicates the RGB 10 Packed pixel format. */ + PixelType_BGR10packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0019, /*!< \brief Indicates the BGR 10 Packed pixel format. */ + + PixelType_RGB12packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x001a, /*!< \brief Indicates the RGB 12 Packed pixel format. */ + PixelType_BGR12packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x001b, /*!< \brief Indicates the BGR 12 Packed pixel format. */ + + PixelType_RGB16packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0033, /*!< \brief Indicates the RGB 16 Packed pixel format. */ + + PixelType_BGR10V1packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x001c, /*!< \brief Indicates the BGR 10 V1 Packed pixel format. */ + PixelType_BGR10V2packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 32 ) | 0x001d, /*!< \brief Indicates the BGR 10 V2 Packed pixel format. */ + + PixelType_YUV411packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 12 ) | 0x001e, /*!< \brief Indicates the YUV 411 Packed pixel format. */ + PixelType_YUV422packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x001f, /*!< \brief Indicates the YUV 422 Packed pixel format. */ + PixelType_YUV444packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0020, /*!< \brief Indicates the YUV 444 Packed pixel format. */ + + PixelType_RGB8planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0021, /*!< \brief Indicates the RGB 8 Planar pixel format. */ + PixelType_RGB10planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0022, /*!< \brief Indicates the RGB 10 Planar pixel format. */ + PixelType_RGB12planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0023, /*!< \brief Indicates the RGB 12 Planar pixel format. */ + PixelType_RGB16planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 48 ) | 0x0024, /*!< \brief Indicates the RGB 16 Planar pixel format. */ + + PixelType_YUV422_YUYV_Packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x0032, /*!< \brief Indicates the YUV 422 (YUYV) Packed pixel format. */ + PixelType_YUV444planar = PIXEL_CUSTOMTYPE | PIXEL_COLOR | PIXEL_BIT_COUNT( 24 ) | 0x0044, /*!< \brief Indicates the 8 bit / channel YUV 444 planar YY YY UU UU VV VV pixel format. */ + + PixelType_YUV422planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x0042, /*!< \brief Indicates the 8 bit / channel YUV 422 planar YY YY U U V V pixel format. */ + PixelType_YUV420planar = PIXEL_COLOR | PIXEL_BIT_COUNT( 12 ) | 0x0040, /*!< \brief Indicates the 8 bit / channel YUV 420 planar YY YY U V pixel format. */ + + PixelType_YCbCr422_8_YY_CbCr_Semiplanar = PIXEL_COLOR | PIXEL_BIT_COUNT( 16 ) | 0x0113, /*!< \brief Indicates the 8 bit / channel YUV 422 semiplanar YY YY UV UV pixel format previously known as PixelType_YCbCr422_8_YY_CbCr_Semiplanar 4:2:2 image with a plane of 8 bit Y samples followed by an interleaved U/V plane. */ + PixelType_YCbCr420_8_YY_CbCr_Semiplanar = PIXEL_COLOR | PIXEL_BIT_COUNT( 12 ) | 0x0112, /*!< \brief Indicates the 8 bit / channel YUV 420 semiplanar YY YY UV pixel format. */ + + PixelType_BayerGR12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002A, /*!< \brief Indicates the Bayer GR 12 Packed pixel format. The memory layout of PixelType_BayerGR12Packed and PixelType_BayerGR12p is different.*/ + PixelType_BayerRG12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002B, /*!< \brief Indicates the Bayer RG 12 Packed pixel format. The memory layout of PixelType_BayerRG12Packed and PixelType_BayerRG12p is different.*/ + PixelType_BayerGB12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002C, /*!< \brief Indicates the Bayer GB 12 Packed pixel format. The memory layout of PixelType_BayerGB12Packed and PixelType_BayerGB12p is different.*/ + PixelType_BayerBG12Packed = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x002D, /*!< \brief Indicates the Bayer BG 12 Packed pixel format. The memory layout of PixelType_BayerBG12Packed and PixelType_BayerBG12p is different.*/ + + PixelType_BayerGR10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0056, /*!< \brief Indicates the BayerGR10p pixel format. */ + PixelType_BayerRG10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0058, /*!< \brief Indicates the BayerRG10p pixel format. */ + PixelType_BayerGB10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0054, /*!< \brief Indicates the BayerGB10p pixel format. */ + PixelType_BayerBG10p = PIXEL_MONO | PIXEL_BIT_COUNT( 10 ) | 0x0052, /*!< \brief Indicates the BayerBG10p pixel format. */ + + PixelType_BayerGR12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0057, /*!< \brief Indicates the BayerGR12p pixel format. The memory layout of PixelType_BayerGR12Packed and PixelType_BayerGR12p is different.*/ + PixelType_BayerRG12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0059, /*!< \brief Indicates the BayerRG12p pixel format. The memory layout of PixelType_BayerRG12Packed and PixelType_BayerRG12p is different.*/ + PixelType_BayerGB12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0055, /*!< \brief Indicates the BayerGB12p pixel format. The memory layout of PixelType_BayerGB12Packed and PixelType_BayerGB12p is different.*/ + PixelType_BayerBG12p = PIXEL_MONO | PIXEL_BIT_COUNT( 12 ) | 0x0053, /*!< \brief Indicates the BayerBG12p pixel format. The memory layout of PixelType_BayerBG12Packed and PixelType_BayerBG12p is different.*/ + + PixelType_BayerGR16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x002E, /*!< \brief Indicates the Bayer GR 16 pixel format. */ + PixelType_BayerRG16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x002F, /*!< \brief Indicates the Bayer RG 16 pixel format. */ + PixelType_BayerGB16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0030, /*!< \brief Indicates the Bayer GB 16 pixel format. */ + PixelType_BayerBG16 = PIXEL_MONO | PIXEL_BIT_COUNT( 16 ) | 0x0031, /*!< \brief Indicates the Bayer BG 16 pixel format. */ + + PixelType_RGB12V1packed = PIXEL_COLOR | PIXEL_BIT_COUNT( 36 ) | 0X0034, /*!< \brief Indicates the RGB 12 V1 packed pixel format. */ + + /* floating point*/ + PixelType_Data32f = PIXEL_MONO | PIXEL_BIT_COUNT( 32 ) | 0x011C, /*!< \brief Indicates the 32 bit floating point pixel format. */ + + /* custom codes */ + PixelType_Double = PIXEL_CUSTOMTYPE | PIXEL_MONO | PIXEL_BIT_COUNT( 64 ) | 0x100 /*!< \brief Indicates the Double pixel format. */ + +} EPylonPixelType; + + +/*! \brief Lists the available file formats */ +#if defined(GENAPIC_WIN_BUILD) +typedef enum +{ + ImageFileFormat_Bmp = 0, /*!< \brief Windows Bitmap, no compression. */ + ImageFileFormat_Tiff = 1, /*!< \brief Tagged Image File Format, no compression, supports mono images with more than 8 bit bit depth. */ + ImageFileFormat_Jpeg = 2, /*!< \brief Joint Photographic Experts Group, lossy data compression. */ + ImageFileFormat_Png = 3, /*!< \brief Portable Network Graphics, lossless data compression. */ + ImageFileFormat_Raw = 4 /*!< \brief Saves the raw image buffer data. Packed image formats are unpacked. In the format used for saving, the data cannot be loaded using PylonImagePersistenceLoad. */ + ///< The data cannot be loaded in this format. + +} EPylonImageFileFormat; +#elif defined(GENAPIC_LINUX_BUILD) +typedef enum +{ + ImageFileFormat_Tiff = 1, /*!< \brief Tagged Image File Format, no compression, supports mono images with more than 8 bit bit depth. */ + ImageFileFormat_Png = 3, /*!< \brief Portable Network Graphics, lossless data compression. */ + ImageFileFormat_Raw = 4 /*!< \brief Saves the raw image buffer data. Packed image formats are unpacked. This format cannot be loaded using PylonImagePersistenceLoad.*/ +} EPylonImageFileFormat; +#else +# error unsupported platform +#endif + +/*! \brief Defines the vertical orientation of an image in memory. */ +typedef enum +{ + ImageOrientation_TopDown, /*!< \brief The first row of the image is located at the start of the image buffer. This is the default for images taken by a camera. */ + ImageOrientation_BottomUp /*!< \brief The last row of the image is located at the start of the image buffer. */ +} EPylonImageOrientation; + +#if defined(GENAPIC_WIN_BUILD) +/*! \brief Lists the possibilities for selecting a key frame when using compression. */ +typedef enum +{ + KeyFrameSelection_NoKeyFrame, /*!< \brief Indicates that an image is not a key frame. */ + KeyFrameSelection_KeyFrame, /*!< \brief Indicates that an image is a key frame. */ + KeyFrameSelection_Auto /*!< \brief Every nth frame is a key frame. The value of n is specified by passing its value in the SAviCompressionOptions in the autoKeyFrameInsertionRate member when opening the AVI Writer. */ +} EPylonKeyFrameSelection; + +/*! \brief Lists the possibilities for selecting a show window command. */ +typedef enum +{ + EPylonShowWindow_SW_HIDE = 0, /*!< \brief Same as SW_HIDE in WinUser.h */ + EPylonShowWindow_SW_SHOWNORMAL = 1, /*!< \brief Same as SW_SHOWNORMAL and SW_NORMAL in WinUser.h */ + EPylonShowWindow_SW_SHOWMINIMIZED = 2, /*!< \brief Same as SW_SHOWMINIMIZED in WinUser.h */ + EPylonShowWindow_SW_SHOWMAXIMIZED = 3, /*!< \brief Same as SW_SHOWMAXIMIZED and SW_MAXIMIZE in WinUser.h */ + EPylonShowWindow_SW_SHOWNOACTIVATE = 4, /*!< \brief Same as SW_SHOWNOACTIVATE in WinUser.h */ + EPylonShowWindow_SW_SHOW = 5, /*!< \brief Same as SW_SHOWNOACTIVATE in WinUser.h */ + EPylonShowWindow_SW_MINIMIZE = 6, /*!< \brief Same as SW_MINIMIZE in WinUser.h */ + EPylonShowWindow_SW_SHOWMINNOACTIVE = 7, /*!< \brief Same as SW_SHOWMINNOACTIVE in WinUser.h */ + EPylonShowWindow_SW_SHOWNA = 8, /*!< \brief Same as SW_SHOWNA in WinUser.h */ + EPylonShowWindow_SW_RESTORE = 9, /*!< \brief Same as SW_RESTORE in WinUser.h */ + EPylonShowWindow_SW_SHOWDEFAULT = 10, /*!< \brief Same as SW_SHOWDEFAULT in WinUser.h */ + EPylonShowWindow_SW_FORCEMINIMIZE = 11 /*!< \brief Same as SW_FORCEMINIMIZE in WinUser.h */ +} EPylonShowWindow; +#endif + +/*! + \brief Lists possible status codes returned by PylonGigEIssueActionCommand() or PylonGigEIssueScheduledActionCommand(). +*/ +typedef enum +{ + /** + \brief The device acknowledged the command. + */ + PylonGigEActionCommandStatus_Ok = 0, + + /** + \brief The device is not synchronized to a master clock to be used as time reference. + Typically used when scheduled action commands cannot be scheduled for + a future time since the reference time coming from IEEE 1588 is not locked. + The action command has been ignored by the device. + */ + PylonGigEActionCommandStatus_NoRefTime = -519995373, + + /** + \brief Returned when the scheduled action commands queue is full and the device cannot accept the additional request. + The action command has been discarded by the device. + */ + PylonGigEActionCommandStatus_Overflow = -519995371, + + /** + \brief The requested scheduled action command was requested at a point in time that is in the past. + If the time tag of the scheduled action command is in the past (relative to the device timestamp), and if it is a valid action + command, then the device will execute this action command immediately and return \c PylonGigEActionCommandStatus_ActionLate. + This status code is used as an indicator to the application requesting the action command that a mis-synchronization might have + occurred. + */ + PylonGigEActionCommandStatus_ActionLate = -519995370 +} EPylonGigEActionCommandStatus; + + +/*! + \brief Status of a compressed grab buffer/result in PylonCompressionInfo_t. +*/ +typedef enum +{ + CompressionStatus_Ok, /*!< Buffer was compressed properly. */ + CompressionStatus_BufferOverflow, /*!< Size of compressed image exceeded desired compression ratio. */ + CompressionStatus_Error /*!< Generic error. */ +} EPylonCompressionStatus; + +/*! + \brief Mode used for transferring images. + + The compression mode can have three states. Either compression is disabled in the camera (CompressionMode_Off) + or the camera compresses the images in one of two ways (CompressionMode_BaslerLossless or CompressionMode_BaslerFixRatio). +*/ +typedef enum tag_EPylonCompressionMode + { + CompressionMode_Off, /*!< Images are transferred uncompressed. */ + CompressionMode_BaslerLossless, /*!< Images are transferred with Basler lossless compression. */ + CompressionMode_BaslerFixRatio /*!< Images are transferred with Basler fixed ratio compression (which may lead to lossily compressed images). */ + } EPylonCompressionMode; + +/** + * @} + */ + +#endif /* PYLON_ENUMS_H */ diff --git a/Cigarette/Pylon6.2/include/pylonc/PylonCError.h b/Cigarette/Pylon6.2/include/pylonc/PylonCError.h new file mode 100644 index 0000000..d506aa9 --- /dev/null +++ b/Cigarette/Pylon6.2/include/pylonc/PylonCError.h @@ -0,0 +1,44 @@ +/*----------------------------------------------------------------------------- + Basler pylon C SDK + Copyright (c) 2009-2021 Basler AG + http://www.baslerweb.com + Author: AH, TK +-----------------------------------------------------------------------------*/ + +/** + \file + \brief Error codes for pylon C bindings. +*/ + +#ifndef PylonCError_h__ +#define PylonCError_h__ + +#include + +/** +* \addtogroup errorcodes Error Codes +* @{ +*/ + +#define PYLON_E_INVALID_DEVICEHANDLE ((GENAPIC_RESULT) 0xC3000001) /**< An invalid Device handle has been passed. */ +#define PYLON_E_INVALID_DEVICEINFOHANDLE ((GENAPIC_RESULT) 0xC3000002) /**< An invalid DeviceInfo handle has been passed. */ +#define PYLON_E_INVALID_DEVICEINFO_PROPERTY ((GENAPIC_RESULT) 0xC3000003) /**< An invalid DeviceInfoProperty handle has been passed. */ +#define PYLON_E_INVALID_STREAMGRABBERHANDLE ((GENAPIC_RESULT) 0xC3000004) /**< An invalid StreamGrabber handle has been passed. */ +#define PYLON_E_INVALID_CHUNKPARSERHANDLE ((GENAPIC_RESULT) 0xC3000005) /**< An invalid ChunkParser handle has been passed. */ +#define PYLON_E_INVALID_WAITOBJECTHANDLE ((GENAPIC_RESULT) 0xC3000006) /**< An invalid WaitObject handle has been passed. */ +#define PYLON_E_INVALID_EVENTGRABBERHANDLE ((GENAPIC_RESULT) 0xC3000007) /**< An invalid EventGrabber handle has been passed. */ +#define PYLON_E_INVALID_EVENTADAPTERHANDLE ((GENAPIC_RESULT) 0xC3000008) /**< An invalid EventAdapter handle has been passed. */ +#define PYLON_E_INVALID_CONVERTERHANDLE ((GENAPIC_RESULT) 0xC3000009) /**< An invalid Converter handle has been passed. */ +#define PYLON_E_INVALID_WAITOBJECTSHANDLE ((GENAPIC_RESULT) 0xC300000A) /**< An invalid WaitObjects handle has been passed. */ +#if defined(GENAPIC_WIN_BUILD) +#define PYLON_E_INVALID_AVIWRITERHANDLE ((GENAPIC_RESULT) 0xC300000B) /**< An invalid AVI writer handle has been passed. */ +#endif +#define PYLON_E_INVALID_INTERFACEHANDLE ((GENAPIC_RESULT) 0xC300000C) /**< An invalid Interface handle has been passed. */ +#define PYLON_E_INVALID_INTERFACEINFOHANDLE ((GENAPIC_RESULT) 0xC300000D) /**< An invalid InterfaceInfo handle has been passed. */ +#define PYLON_E_INVALID_DECOMPRESSORHANDLE ((GENAPIC_RESULT) 0xC300000E) /**< An invalid decompressor handle has been passed. */ + +/** +* @} +*/ + +#endif /* PylonCError_h__ */ diff --git a/Cigarette/Pylon6.2/lib/Win32/GCBase_MD_VC141_v3_1_Basler_pylon.lib b/Cigarette/Pylon6.2/lib/Win32/GCBase_MD_VC141_v3_1_Basler_pylon.lib new file mode 100644 index 0000000..7a99483 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/GCBase_MD_VC141_v3_1_Basler_pylon.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win32/GenApi_MD_VC141_v3_1_Basler_pylon.lib b/Cigarette/Pylon6.2/lib/Win32/GenApi_MD_VC141_v3_1_Basler_pylon.lib new file mode 100644 index 0000000..005d1f8 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/GenApi_MD_VC141_v3_1_Basler_pylon.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win32/PylonBase_v6_2.lib b/Cigarette/Pylon6.2/lib/Win32/PylonBase_v6_2.lib new file mode 100644 index 0000000..7cc82fb Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/PylonBase_v6_2.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win32/PylonC.lib b/Cigarette/Pylon6.2/lib/Win32/PylonC.lib new file mode 100644 index 0000000..2a01db9 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/PylonC.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win32/PylonC_BCC55.lib b/Cigarette/Pylon6.2/lib/Win32/PylonC_BCC55.lib new file mode 100644 index 0000000..7c7dede Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/PylonC_BCC55.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win32/PylonGUI_v6_2.lib b/Cigarette/Pylon6.2/lib/Win32/PylonGUI_v6_2.lib new file mode 100644 index 0000000..7b68830 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/PylonGUI_v6_2.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win32/PylonUtility_v6_2.lib b/Cigarette/Pylon6.2/lib/Win32/PylonUtility_v6_2.lib new file mode 100644 index 0000000..7cac4f8 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win32/PylonUtility_v6_2.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win64/GCBase_MD_VC141_v3_1_Basler_pylon.lib b/Cigarette/Pylon6.2/lib/Win64/GCBase_MD_VC141_v3_1_Basler_pylon.lib new file mode 100644 index 0000000..7643bda Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win64/GCBase_MD_VC141_v3_1_Basler_pylon.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win64/GenApi_MD_VC141_v3_1_Basler_pylon.lib b/Cigarette/Pylon6.2/lib/Win64/GenApi_MD_VC141_v3_1_Basler_pylon.lib new file mode 100644 index 0000000..101c132 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win64/GenApi_MD_VC141_v3_1_Basler_pylon.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win64/PylonBase_v6_2.lib b/Cigarette/Pylon6.2/lib/Win64/PylonBase_v6_2.lib new file mode 100644 index 0000000..bc64cd8 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win64/PylonBase_v6_2.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win64/PylonC.lib b/Cigarette/Pylon6.2/lib/Win64/PylonC.lib new file mode 100644 index 0000000..31c95f3 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win64/PylonC.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win64/PylonGUI_v6_2.lib b/Cigarette/Pylon6.2/lib/Win64/PylonGUI_v6_2.lib new file mode 100644 index 0000000..a88a9a7 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win64/PylonGUI_v6_2.lib differ diff --git a/Cigarette/Pylon6.2/lib/Win64/PylonUtility_v6_2.lib b/Cigarette/Pylon6.2/lib/Win64/PylonUtility_v6_2.lib new file mode 100644 index 0000000..65f4f38 Binary files /dev/null and b/Cigarette/Pylon6.2/lib/Win64/PylonUtility_v6_2.lib differ diff --git a/Cigarette/Resources/alarm.png b/Cigarette/Resources/alarm.png new file mode 100644 index 0000000..a90260e Binary files /dev/null and b/Cigarette/Resources/alarm.png differ diff --git a/Cigarette/Resources/cam1.png b/Cigarette/Resources/cam1.png new file mode 100644 index 0000000..b58f399 Binary files /dev/null and b/Cigarette/Resources/cam1.png differ diff --git a/Cigarette/Resources/cam1_no.png b/Cigarette/Resources/cam1_no.png new file mode 100644 index 0000000..df64b79 Binary files /dev/null and b/Cigarette/Resources/cam1_no.png differ diff --git a/Cigarette/Resources/cam1_yes.png b/Cigarette/Resources/cam1_yes.png new file mode 100644 index 0000000..cc5cdf5 Binary files /dev/null and b/Cigarette/Resources/cam1_yes.png differ diff --git a/Cigarette/Resources/cam2.png b/Cigarette/Resources/cam2.png new file mode 100644 index 0000000..5bc7613 Binary files /dev/null and b/Cigarette/Resources/cam2.png differ diff --git a/Cigarette/Resources/cam2_no.png b/Cigarette/Resources/cam2_no.png new file mode 100644 index 0000000..9b1c83b Binary files /dev/null and b/Cigarette/Resources/cam2_no.png differ diff --git a/Cigarette/Resources/cam2_yes.png b/Cigarette/Resources/cam2_yes.png new file mode 100644 index 0000000..51f30c9 Binary files /dev/null and b/Cigarette/Resources/cam2_yes.png differ diff --git a/Cigarette/Resources/cam3.png b/Cigarette/Resources/cam3.png new file mode 100644 index 0000000..a132efe Binary files /dev/null and b/Cigarette/Resources/cam3.png differ diff --git a/Cigarette/Resources/cam3_no.png b/Cigarette/Resources/cam3_no.png new file mode 100644 index 0000000..a4bb3eb Binary files /dev/null and b/Cigarette/Resources/cam3_no.png differ diff --git a/Cigarette/Resources/cam3_yes.png b/Cigarette/Resources/cam3_yes.png new file mode 100644 index 0000000..5d523bf Binary files /dev/null and b/Cigarette/Resources/cam3_yes.png differ diff --git a/Cigarette/Resources/cam4.png b/Cigarette/Resources/cam4.png new file mode 100644 index 0000000..28c08de Binary files /dev/null and b/Cigarette/Resources/cam4.png differ diff --git a/Cigarette/Resources/cam4_no.png b/Cigarette/Resources/cam4_no.png new file mode 100644 index 0000000..a3b3f8a Binary files /dev/null and b/Cigarette/Resources/cam4_no.png differ diff --git a/Cigarette/Resources/cam4_yes.png b/Cigarette/Resources/cam4_yes.png new file mode 100644 index 0000000..7a2aa1d Binary files /dev/null and b/Cigarette/Resources/cam4_yes.png differ diff --git a/Cigarette/Resources/cam5.png b/Cigarette/Resources/cam5.png new file mode 100644 index 0000000..3c740ad Binary files /dev/null and b/Cigarette/Resources/cam5.png differ diff --git a/Cigarette/Resources/cam5_no.png b/Cigarette/Resources/cam5_no.png new file mode 100644 index 0000000..5e7660c Binary files /dev/null and b/Cigarette/Resources/cam5_no.png differ diff --git a/Cigarette/Resources/cam5_yes.png b/Cigarette/Resources/cam5_yes.png new file mode 100644 index 0000000..47aad92 Binary files /dev/null and b/Cigarette/Resources/cam5_yes.png differ diff --git a/Cigarette/Resources/cam6.png b/Cigarette/Resources/cam6.png new file mode 100644 index 0000000..a21dbc7 Binary files /dev/null and b/Cigarette/Resources/cam6.png differ diff --git a/Cigarette/Resources/cam6_no.png b/Cigarette/Resources/cam6_no.png new file mode 100644 index 0000000..b4d1cb6 Binary files /dev/null and b/Cigarette/Resources/cam6_no.png differ diff --git a/Cigarette/Resources/cam6_yes.png b/Cigarette/Resources/cam6_yes.png new file mode 100644 index 0000000..44438c1 Binary files /dev/null and b/Cigarette/Resources/cam6_yes.png differ diff --git a/Cigarette/Resources/cam7.png b/Cigarette/Resources/cam7.png new file mode 100644 index 0000000..c19fe63 Binary files /dev/null and b/Cigarette/Resources/cam7.png differ diff --git a/Cigarette/Resources/cam7_no.png b/Cigarette/Resources/cam7_no.png new file mode 100644 index 0000000..c7c18c8 Binary files /dev/null and b/Cigarette/Resources/cam7_no.png differ diff --git a/Cigarette/Resources/cam7_yes.png b/Cigarette/Resources/cam7_yes.png new file mode 100644 index 0000000..4f2924a Binary files /dev/null and b/Cigarette/Resources/cam7_yes.png differ diff --git a/Cigarette/Resources/cam8.png b/Cigarette/Resources/cam8.png new file mode 100644 index 0000000..b2e6489 Binary files /dev/null and b/Cigarette/Resources/cam8.png differ diff --git a/Cigarette/Resources/cam8_no.png b/Cigarette/Resources/cam8_no.png new file mode 100644 index 0000000..775e21f Binary files /dev/null and b/Cigarette/Resources/cam8_no.png differ diff --git a/Cigarette/Resources/cam8_yes.png b/Cigarette/Resources/cam8_yes.png new file mode 100644 index 0000000..0d7ba2f Binary files /dev/null and b/Cigarette/Resources/cam8_yes.png differ diff --git a/Cigarette/Resources/exit.png b/Cigarette/Resources/exit.png new file mode 100644 index 0000000..ffd4acb Binary files /dev/null and b/Cigarette/Resources/exit.png differ diff --git a/Cigarette/Resources/keyboard.png b/Cigarette/Resources/keyboard.png new file mode 100644 index 0000000..bebfa28 Binary files /dev/null and b/Cigarette/Resources/keyboard.png differ diff --git a/Cigarette/Resources/lock.png b/Cigarette/Resources/lock.png new file mode 100644 index 0000000..7651853 Binary files /dev/null and b/Cigarette/Resources/lock.png differ diff --git a/Cigarette/Resources/logo.png b/Cigarette/Resources/logo.png new file mode 100644 index 0000000..15fe2a2 Binary files /dev/null and b/Cigarette/Resources/logo.png differ diff --git a/Cigarette/Resources/pause.png b/Cigarette/Resources/pause.png new file mode 100644 index 0000000..2d359a6 Binary files /dev/null and b/Cigarette/Resources/pause.png differ diff --git a/Cigarette/Resources/plc.png b/Cigarette/Resources/plc.png new file mode 100644 index 0000000..1504bdc Binary files /dev/null and b/Cigarette/Resources/plc.png differ diff --git a/Cigarette/Resources/rotate.png b/Cigarette/Resources/rotate.png new file mode 100644 index 0000000..41449a8 Binary files /dev/null and b/Cigarette/Resources/rotate.png differ diff --git a/Cigarette/Resources/setup.png b/Cigarette/Resources/setup.png new file mode 100644 index 0000000..59db0d0 Binary files /dev/null and b/Cigarette/Resources/setup.png differ diff --git a/Cigarette/Resources/start.png b/Cigarette/Resources/start.png new file mode 100644 index 0000000..da3be3d Binary files /dev/null and b/Cigarette/Resources/start.png differ diff --git a/Cigarette/Resources/unlock.png b/Cigarette/Resources/unlock.png new file mode 100644 index 0000000..88bf476 Binary files /dev/null and b/Cigarette/Resources/unlock.png differ diff --git a/Cigarette/SyncQueue.cpp b/Cigarette/SyncQueue.cpp new file mode 100644 index 0000000..707b702 --- /dev/null +++ b/Cigarette/SyncQueue.cpp @@ -0,0 +1,3 @@ +#include "SyncQueue.h" + + diff --git a/Cigarette/SyncQueue.h b/Cigarette/SyncQueue.h new file mode 100644 index 0000000..bb9a09f --- /dev/null +++ b/Cigarette/SyncQueue.h @@ -0,0 +1,95 @@ +#pragma once +#include +#include +#include +#include + +using namespace std; + +template class SyncQueue +{ +public: + SyncQueue(int max_size); + ~SyncQueue(); + void put(const T& val); + void take(T& val); + void clear(); + bool isEmpty(); + bool isFull(); + int count(); +public: + string name; +private: + mutex lock; + condition_variable_any cv_full, cv_empty; + list q; + int size; + int max_size; +}; + +using namespace std; + +template +SyncQueue::SyncQueue(int max_size) :max_size(max_size) +{ +} + +template +SyncQueue::~SyncQueue() +{ +} + +template +void SyncQueue::put(const T& val) +{ + lock_guard locker(lock); + while (isFull()) + { + //cout << "\nQueue " << name << " is full now, wait a minute!" << endl; + cv_full.wait(lock); + } + q.emplace_back(val); + cv_empty.notify_one(); + //cout << " Put image success " << endl; +} + +template +void SyncQueue::take(T& val) +{ + lock_guard locker(lock); + while (isEmpty()) + { + //cout << "\nQueue "<< name << " is empty now, wait a minute!" << endl; + cv_empty.wait(lock); + } + val = q.front(); + q.pop_front(); + cv_full.notify_one(); + //cout << " Take image success "<< endl; +} + +template +void SyncQueue::clear() +{ + lock_guard locker(lock); + q.clear(); +} + +template +bool SyncQueue::isEmpty() +{ + return q.size() == 0; +} + +template +bool SyncQueue::isFull() +{ + return q.size() == max_size; +} + +template +int SyncQueue::count() +{ + lock_guard locker(lock); + return q.size(); +} \ No newline at end of file diff --git a/Cigarette/alarmdialog.cpp b/Cigarette/alarmdialog.cpp new file mode 100644 index 0000000..56566cb --- /dev/null +++ b/Cigarette/alarmdialog.cpp @@ -0,0 +1,45 @@ +#include "alarmdialog.hpp" +#include "AlarmInfo.h" + +extern std::vector g_vec_alarm; + +AlarmDialog::AlarmDialog(QWidget * parent) : QDialog(parent) { + ui.setupUi(this); + this->setWindowFlags(Qt::FramelessWindowHint); + ui.tableWidget->setColumnCount(4); + ui.tableWidget->setRowCount(g_vec_alarm.size()); + QStringList header_list; + header_list << QStringLiteral("报警开始时间") << QStringLiteral("报警处理时间") + << QStringLiteral("报警信息") << QStringLiteral("报警代码"); + ui.tableWidget->setHorizontalHeaderLabels(header_list); + ui.tableWidget->setColumnWidth(0, 140); + ui.tableWidget->setColumnWidth(1, 140); + ui.tableWidget->setColumnWidth(2, 380); + ui.tableWidget->setColumnWidth(3, 120); + for (int i = 0; i < g_vec_alarm.size(); i++) + { + ui.tableWidget->setItem(i, 0, new QTableWidgetItem(QString(g_vec_alarm[i].alarm_start.c_str()))); + ui.tableWidget->setItem(i, 1, new QTableWidgetItem(QString(g_vec_alarm[i].alarm_handle.c_str()))); + ui.tableWidget->setItem(i, 2, new QTableWidgetItem(QString(g_vec_alarm[i].alarm_msg.c_str()))); + ui.tableWidget->setItem(i, 3, new QTableWidgetItem(QString::number(g_vec_alarm[i].alarm_code))); + } +} + +AlarmDialog::~AlarmDialog() { + +} + +void AlarmDialog::on_pushButton_close_released() +{ + this->close(); +} + +void AlarmDialog::on_pushButton_clear_released() +{ + int rowNum = ui.tableWidget->rowCount(); + for (int i = rowNum - 1; i >= 0; i--) + { + ui.tableWidget->removeRow(i); + } + g_vec_alarm.clear(); +} diff --git a/Cigarette/alarmdialog.hpp b/Cigarette/alarmdialog.hpp new file mode 100644 index 0000000..d27bdf3 --- /dev/null +++ b/Cigarette/alarmdialog.hpp @@ -0,0 +1,18 @@ +#pragma once +#include +#include "ui_alarmdialog.h" + +class AlarmDialog : public QDialog { + Q_OBJECT + +public: + AlarmDialog(QWidget * parent = Q_NULLPTR); + ~AlarmDialog(); + +private slots: + void on_pushButton_close_released(); + void on_pushButton_clear_released(); + +private: + Ui::AlarmDialog ui; +}; diff --git a/Cigarette/alarmdialog.ui b/Cigarette/alarmdialog.ui new file mode 100644 index 0000000..0ae882f --- /dev/null +++ b/Cigarette/alarmdialog.ui @@ -0,0 +1,96 @@ + + + AlarmDialog + + + + 0 + 0 + 800 + 600 + + + + 报警历史 + + + background-color: rgb(240, 240, 240); + + + + + 10 + 60 + 781 + 531 + + + + + + + 40 + 10 + 101 + 41 + + + + + 微软雅黑 + 14 + 75 + true + + + + 报警历史: + + + + + + 640 + 10 + 111 + 41 + + + + + 微软雅黑 + 12 + 75 + true + + + + 关闭窗口 + + + + + + 500 + 10 + 111 + 41 + + + + + 微软雅黑 + 12 + 75 + true + + + + 清空报警 + + + + + + + diff --git a/Cigarette/alg_jd.bak.jpg b/Cigarette/alg_jd.bak.jpg new file mode 100644 index 0000000..32cc04e Binary files /dev/null and b/Cigarette/alg_jd.bak.jpg differ diff --git a/Cigarette/alg_jd.cpp b/Cigarette/alg_jd.cpp new file mode 100644 index 0000000..b5f553f --- /dev/null +++ b/Cigarette/alg_jd.cpp @@ -0,0 +1,369 @@ +#include "alg_jd.h" +#include "common.h" +// Remove the bounding boxes with low confidence using non-maxima suppression +static void post_process(cv::Mat& frame, std::vector& outs, std::vector > &results); + +static void post_process_batch(std::vector& vec_frame, std::vector& outs, std::vector > > &vec_results); + +// Get the names of the output layers +static std::vector getOutputsNames(const cv::dnn::Net& net); + +// Draw the predicted bounding box +static void drawPred(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame); + +// Initialize the parameters +static float confThreshold = 0.1; // Confidence threshold +static float nmsThreshold = 0.4; // Non-maximum suppression threshold +static int inpWidth = 416; // Width of network's input image +static int inpHeight = 416; // Height of network's input image + +static std::vector classes; + +bool AlgJd::init() +{ + QString model_path; + std::fstream cfg_file; + cfg_file.open("../conf/conf.txt"); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file " << "../conf/conf.txt" << std::endl; + return false; + } + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + std::string line(tmp); + if (line.length() > 0) + { + size_t pos = line.find('='); + std::string tmp_key = line.substr(0, pos); + if (tmp_key == "MODELPATH") + { + model_path = line.substr(pos + 1).c_str(); + } + } + } + cfg_file.close(); + + //std::cout << "MODEL PATH IS " << model_path.toStdString().c_str() << std::endl; + + // Load names of classes + std::string classesFile = "../model/jd.names"; + + // Give the configuration and weight files for the model + cv::String modelConfiguration = "../model/jd.cfg"; + cv::String modelWeights; + + if (model_path.length() > 0) { + modelWeights = model_path.toStdString(); + } + else { + modelWeights = "../model/jd.weights"; + } + + std::ifstream classNamesFile(classesFile.c_str()); + if (classNamesFile.is_open()) + { + std::string className = ""; + while (std::getline(classNamesFile, className)) + classes.push_back(className); + } + else{ + return false; + } + + // Load the network + net = cv::dnn::readNetFromDarknet(modelConfiguration, modelWeights); + + net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); + net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); + + cv::Mat image = cv::imread("alg_jd.jpg"); + //ʶһͼģǷȷGPUݼ + if (!image.data) return false; //жϲͼƬǷȡ + std::vector > results; + detect(image, image, results); + if (results.size() > 0) + return true; //⵽Ŀ꣬ʼɹ + else + return false; //ʼʧ +} + +bool AlgJd::test_detect() +{ + cv::Mat m1; + m1 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + std::vector > results; + double t = (double)cv::getTickCount(); + detect(m1, m1, results); + t = ((double)cv::getTickCount() - t) / cv::getTickFrequency(); + DEBUG(" test_detect time process:%f\n", t); + return true; +} + +bool AlgJd::test_detect_batcht(int shoot) +{ + std::vector vec_in; + std::vector vec_out; + std::vector > > vec_results; + cv::Mat m1, m2, m3; + m1 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + m2 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + m3 = cv::Mat(544, 728, CV_8UC3, cv::Scalar(0, 0, 0)); + + double t = (double)cv::getTickCount(); + switch(shoot){ + case 1:{ + std::vector > results; + detect(m1, m1, results); + break; + } + case 3:vec_in.push_back(m3); + case 2:vec_in.push_back(m2); + default:{ + vec_in.push_back(m1); + detect_batch(vec_in, vec_out, vec_results); + } + } + t = ((double)cv::getTickCount() - t) / cv::getTickFrequency(); + DEBUG(" test_detect_batcht time process:%f\n", t); + return true; +} + +int AlgJd::detect(cv::Mat& _frame, cv::Mat &out, std::vector > &results) +{ + cv::Mat frame = _frame.clone(); + cv::Mat image_clone=frame.clone(); + // Process frames. + // Create a 4D blob from a frame. + cv::Mat blob; + cv::dnn::blobFromImage(frame, blob, 1/255.0, cv::Size(inpWidth, inpHeight), cv::Scalar(0,0,0), true, false); + + //Sets the input to the network + net.setInput(blob); + + + // Runs the forward pass to get output of the output layers + std::vector outs; + net.forward(outs, getOutputsNames(net)); + + + // Remove the bounding boxes with low confidence + post_process(frame, outs, results); + + + // Write the frame with the detection boxes + cv::Mat detectedFrame; + frame.convertTo(detectedFrame, CV_8U); + //show detectedFrame + out=detectedFrame.clone(); + return results.size(); +} + +// Get the names of the output layers +static std::vector getOutputsNames(const cv::dnn::Net& net) +{ + static std::vector names; + if (names.empty()) + { + //Get the indices of the output layers, i.e. the layers with unconnected outputs + std::vector outLayers = net.getUnconnectedOutLayers(); + + //get the names of all the layers in the network + std::vector layersNames = net.getLayerNames(); + + // Get the names of the output layers in names + names.resize(outLayers.size()); + for (size_t i = 0; i < outLayers.size(); ++i) + names[i] = layersNames[outLayers[i] - 1]; + } + return names; +} + +static void post_process(cv::Mat& frame, std::vector& outs, std::vector > &results) +{ + std::vector classIds; + std::vector confidences; + std::vector boxes; + + for (size_t i = 0; i < outs.size(); ++i) + { + // Scan through all the bounding boxes output from the network and keep only the + // ones with high confidence scores. Assign the box's class label as the class + // with the highest score for the box. + float* data = (float*)outs[i].data; + for (int j = 0; j < outs[i].rows; ++j, data += outs[i].cols) + { + cv::Mat scores = outs[i].row(j).colRange(5, outs[i].cols); + cv::Point classIdPoint; + double confidence; + // Get the value and location of the maximum score + cv::minMaxLoc(scores, 0, &confidence, 0, &classIdPoint); + + if (confidence > confThreshold) + { + int centerX = (int)(data[0] * frame.cols); + int centerY = (int)(data[1] * frame.rows); + int width = (int)(data[2] * frame.cols); + int height = (int)(data[3] * frame.rows); + int left = centerX - width / 2; + int top = centerY - height / 2; + + classIds.push_back(classIdPoint.x); + confidences.push_back((float)confidence); + boxes.push_back(cv::Rect(left, top, width, height)); + } + } + } + + + // Perform non maximum suppression to eliminate redundant overlapping boxes with + // lower confidences + std::vector indices; + cv::dnn::NMSBoxes(boxes, confidences, confThreshold, nmsThreshold, indices); + + for (size_t i = 0; i < indices.size(); ++i) + { + int idx = indices[i]; + cv::Rect box = boxes[idx]; + drawPred(classIds[idx], confidences[idx], box.x, box.y, + box.x + box.width, box.y + box.height, frame); + results.push_back(std::make_pair(classIds[idx], box)); + } +} + +// Draw the predicted bounding box +static void drawPred(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame) +{ + cv::Scalar color; + if(classId==0) + color = cv::Scalar(0,255,0); + else if(classId == 1) + color = cv::Scalar(255,0,0); + else + color = cv::Scalar(0, 255, 0); + //Draw a rectangle displaying the bounding box + cv::rectangle(frame, cv::Point(left, top), cv::Point(right, bottom), color, 4); + + //Get the label for the class name and its confidence + std::string label = cv::format("%.2f%%", (conf*100)); + if (!classes.empty()) + { + CV_Assert(classId < (int)classes.size()); + label = classes[classId] + ": " + label; + } + else + { + std::cout<<"classes is empty..."<& vec_in, std::vector &vec_out, std::vector > > &vec_results) +{ + cv::Mat blobs; + std::vector image; + + cv::dnn::blobFromImages(vec_in, blobs, 1 / 255.0, cv::Size(inpWidth, inpHeight), cv::Scalar(0, 0, 0), true, false); + + //Sets the input to the network + net.setInput(blobs); + + // Runs the forward pass to get output of the output layers + std::vector outs; + net.forward(outs, getOutputsNames(net)); + + for (int i = 0; i < vec_in.size(); i++) + { + image.push_back(vec_in[i].clone()); + } + + // Remove the bounding boxes with low confidence + post_process_batch(image, outs, vec_results); + + + // Write the frame with the detection boxes + for (int i = 0; i < vec_in.size(); i++) + { + cv::Mat detectedFrame, out; + image[i].convertTo(detectedFrame, CV_8U); + out = detectedFrame.clone(); + vec_out.push_back(out); + } +} + +static void post_process_batch(std::vector& vec_frame, std::vector& outs, std::vector > > &vec_results) +{ + int batch = vec_frame.size(); + for (int k = 0; k < batch; k++) + { + std::vector classIds; + std::vector confidences; + std::vector boxes; + //std::cout << "outs.size()\t" << outs.size() << std::endl; + //std::cout << "Type\t" << outs[0].type() << std::endl; + + for (size_t i = 0; i < outs.size(); ++i) + { + //std::cout << "outs.dims\t" << outs[i].dims << std::endl; + //std::cout << "outs[" << i << "].rows\t" << outs[i].size[0] << std::endl; + //std::cout << "outs[" << i << "].cols\t" << outs[i].size[1] << std::endl; + //std::cout << "outs[" << i << "].cols\t" << outs[i].size[2] << std::endl; + // Scan through all the bounding boxes output from the network and keep only the + // ones with high confidence scores. Assign the box's class label as the class + // + cv::Mat m0(outs[i].size[1], outs[i].size[2], CV_32F, outs[i].data + outs[i].step[0] * k); + // with the highest score for the box. + float* data = (float*)m0.data; + for (int j = 0; j < m0.rows; ++j, data += m0.cols) + { + cv::Mat scores = m0.row(j).colRange(5, m0.cols); + cv::Point classIdPoint; + double confidence; + // Get the value and location of the maximum score + cv::minMaxLoc(scores, 0, &confidence, 0, &classIdPoint); + + if (confidence > confThreshold) + { + int centerX = (int)(data[0] * vec_frame[k].cols); + int centerY = (int)(data[1] * vec_frame[k].rows); + int width = (int)(data[2] * vec_frame[k].cols); + int height = (int)(data[3] * vec_frame[k].rows); + int left = centerX - width / 2; + int top = centerY - height / 2; + + classIds.push_back(classIdPoint.x); + confidences.push_back((float)confidence); + boxes.push_back(cv::Rect(left, top, width, height)); + } + } + } + + // Perform non maximum suppression to eliminate redundant overlapping boxes with + // lower confidences + std::vector indices; + cv::dnn::NMSBoxes(boxes, confidences, confThreshold, nmsThreshold, indices); + + std::vector > results; + for (size_t i = 0; i < indices.size(); ++i) + { + int idx = indices[i]; + cv::Rect box = boxes[idx]; + //ʶȴ15ʾʶСΪ޽㣬NG + if (box.width > 15) + { + drawPred(classIds[idx], confidences[idx], box.x, box.y, + box.x + box.width, box.y + box.height, vec_frame[k]); + results.push_back(std::make_pair(classIds[idx], box)); + } + + } + vec_results.push_back(results); + } +} diff --git a/Cigarette/alg_jd.h b/Cigarette/alg_jd.h new file mode 100644 index 0000000..ac12df2 --- /dev/null +++ b/Cigarette/alg_jd.h @@ -0,0 +1,24 @@ +#ifndef _CIGARETTE_JD +#define _CIGARETTE_JD + +#include +#include +#include +#include +#include +#include +#include + +class AlgJd +{ + public: + bool init(); + bool test_detect(); + bool test_detect_batcht(int shoot); + int detect(cv::Mat& in, cv::Mat &out, std::vector > &results); + void detect_batch(std::vector& vec_in, std::vector &vec_out, std::vector > > &vec_results); + private: + cv::dnn::Net net; +}; + +#endif //end of _CIGARETTE_JD diff --git a/Cigarette/alg_jd.jpg b/Cigarette/alg_jd.jpg new file mode 100644 index 0000000..5e4a89d Binary files /dev/null and b/Cigarette/alg_jd.jpg differ diff --git a/Cigarette/balluffcamera.cpp b/Cigarette/balluffcamera.cpp new file mode 100644 index 0000000..4eddee4 --- /dev/null +++ b/Cigarette/balluffcamera.cpp @@ -0,0 +1,22 @@ +#include "balluffcamera.h" +#include // for std::find_if +#include +#include + +mvIMPACT::acquire::DeviceManager BalluffCamera:: devMgr; +bool BalluffCamera::license_pass = false; +BalluffCamera::BalluffCamera() +{ + +} + + +BalluffCamera::~BalluffCamera() +{ + +} + +int BalluffCamera::Enumerate() +{ + return devMgr.deviceCount(); +} \ No newline at end of file diff --git a/Cigarette/balluffcamera.h b/Cigarette/balluffcamera.h new file mode 100644 index 0000000..9d58e03 --- /dev/null +++ b/Cigarette/balluffcamera.h @@ -0,0 +1,20 @@ +#pragma once +#include "SyncQueue.h" +#include "basecamera.h" +//#include +#include + +#define BalluffClassID 0x01 + +class BalluffCamera: public BaseCamera +{ +public: + BalluffCamera(); + ~BalluffCamera(); + + static int Enumerate(); + +public: + static mvIMPACT::acquire::DeviceManager devMgr; + static bool license_pass; +}; \ No newline at end of file diff --git a/Cigarette/basecamera.cpp b/Cigarette/basecamera.cpp new file mode 100644 index 0000000..1e3d873 --- /dev/null +++ b/Cigarette/basecamera.cpp @@ -0,0 +1,13 @@ +#include "basecamera.h" + +SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras] = { 0 }; + +BaseCamera::BaseCamera() +{ + +} + + +BaseCamera::~BaseCamera() +{ +} diff --git a/Cigarette/basecamera.h b/Cigarette/basecamera.h new file mode 100644 index 0000000..df90994 --- /dev/null +++ b/Cigarette/basecamera.h @@ -0,0 +1,27 @@ +#pragma once + +#include + +#define NumberOfSupportedCameras 8 + +#define EdgeEvent 1 +#define ImageCap 2 + +typedef struct _SingleCamInfoStruct { + int unfiltered_num; + int filtered_num; + int CamClass; + int UserID; + bool Detect; + bool IsOpen; + bool OffLine; +}SingleCamInfoStruct; + +class BaseCamera +{ +public: + BaseCamera(); + ~BaseCamera(); +public: +}; + diff --git a/Cigarette/baslercamera.cpp b/Cigarette/baslercamera.cpp new file mode 100644 index 0000000..38715fb --- /dev/null +++ b/Cigarette/baslercamera.cpp @@ -0,0 +1,45 @@ +#include "baslercamera.h" +#include // for std::find_if +#include +#include + +Pylon::DeviceInfoList_t BaslerCamera::devices; + +BaslerCamera::BaslerCamera() +{ + +} + + +BaslerCamera::~BaslerCamera() +{ + Pylon::PylonTerminate(); +} + + +int BaslerCamera::Enumerate() +{ + int n_basler_cam = 0; + + // Before using any pylon methods, the pylon runtime must be initialized. + Pylon::PylonInitialize(); + try + { + // Get the transport layer factory. + Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance(); + + // Get all attached devices and exit application if no device is found. + if (tlFactory.EnumerateDevices(devices) == 0) + { + return 0; + } + n_basler_cam = min(devices.size(), c_maxCamerasToUse); + } + catch (const Pylon::GenericException& e) + { + // Error handling + cerr << "An exception occurred." << endl + << e.GetDescription() << endl; + } + return n_basler_cam; +} \ No newline at end of file diff --git a/Cigarette/baslercamera.h b/Cigarette/baslercamera.h new file mode 100644 index 0000000..43fa4c2 --- /dev/null +++ b/Cigarette/baslercamera.h @@ -0,0 +1,25 @@ +#pragma once +#include "SyncQueue.h" +#include "basecamera.h" +#include +#include +#include +#include +#include +#include +#include + +#define BaslerClassID 0x02 +#define c_maxCamerasToUse (size_t)2 + +class BaslerCamera: public BaseCamera +{ +public: + BaslerCamera(); + ~BaslerCamera(); + + static int Enumerate(); + +public: + static Pylon::DeviceInfoList_t devices; +}; diff --git a/Cigarette/camera_glue.cpp b/Cigarette/camera_glue.cpp new file mode 100644 index 0000000..6fd0349 --- /dev/null +++ b/Cigarette/camera_glue.cpp @@ -0,0 +1,59 @@ +#include "camera_glue.h" + +#define camera_glue_init(a,b)\ + spinBox[a][0] = ui.spinBox_##b##1;\ + spinBox[a][1] = ui.spinBox_##b##2;\ + spinBox[a][2] = ui.spinBox_##b##3; + +camera_glue::camera_glue(QDialog *parent) + : QDialog(parent) +{ + ui.setupUi(this); + this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint); +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + camera_glue_init(0,1) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + camera_glue_init(1,2) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + camera_glue_init(2,3) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + camera_glue_init(3,4) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + camera_glue_init(4,5) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + camera_glue_init(5,6) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + camera_glue_init(6,7) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + camera_glue_init(7,8) +#endif +} + +camera_glue::~camera_glue() +{ + +} + +void camera_glue::recMsgFromDialogSetup(int ptr[][3]) +{ + for(int i=0;isetValue(ptr[i][j]); +} + +void camera_glue::on_pushButton_take_released(void) +{ + int mat[NumberOfSupportedCameras][3]; + for(int i=0;ivalue(); + emit sendMsgToDialogSetup(mat); + this->close(); +} \ No newline at end of file diff --git a/Cigarette/camera_glue.h b/Cigarette/camera_glue.h new file mode 100644 index 0000000..d0b500b --- /dev/null +++ b/Cigarette/camera_glue.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include "ui_camera_glue.h" +#include "basecamera.h" +#include "common.h" +class camera_glue : public QDialog +{ + Q_OBJECT + +public: + camera_glue(QDialog *parent = Q_NULLPTR); + ~camera_glue(); +signals: + void sendMsgToDialogSetup(int ptr[][3]); + +public slots: + void recMsgFromDialogSetup(int ptr[][3]); + void on_pushButton_take_released(void); + +private: + Ui::camera_glue ui; + QSpinBox *spinBox[NumberOfSupportedCameras][3]; + SysConf local_SysConf; +}; diff --git a/Cigarette/camera_glue.ui b/Cigarette/camera_glue.ui new file mode 100644 index 0000000..ce30ba1 --- /dev/null +++ b/Cigarette/camera_glue.ui @@ -0,0 +1,867 @@ + + + camera_glue + + + + 0 + 0 + 878 + 226 + + + + 配方设置 + + + + + 190 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 290 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 390 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 290 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 190 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 390 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 290 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 190 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 390 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 90 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 90 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 90 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 10 + 53 + 61 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 第一张 + + + + + + 10 + 105 + 61 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 第二张 + + + + + + 10 + 155 + 61 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 第三张 + + + + + + 90 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 1号相机 + + + + + + 190 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 2号相机 + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 3号相机 + + + + + + 390 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 4号相机 + + + + + + 550 + 190 + 285 + 25 + + + + + 微软雅黑 + 10 + + + + 若要保存参数请返回上一级点击保存 + + + + + + 360 + 190 + 141 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 应用 + + + + + + 490 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 490 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 5号相机 + + + + + + 490 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 490 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 590 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 590 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 6号相机 + + + + + + 590 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 590 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 690 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 690 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 7号相机 + + + + + + 690 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 690 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 790 + 150 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 790 + 20 + 70 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + 8号相机 + + + + + + 790 + 100 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + 790 + 50 + 70 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + true + + + 10 + + + + + + + diff --git a/Cigarette/change_shift.cpp b/Cigarette/change_shift.cpp new file mode 100644 index 0000000..68c177f --- /dev/null +++ b/Cigarette/change_shift.cpp @@ -0,0 +1,72 @@ +#include "change_shift.h" +#include +#include + +extern SysConf g_sys_conf; +change_shift::change_shift(QDialog *parent) + : QDialog(parent) +{ + ui.setupUi(this); + this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint); + + if (g_sys_conf.auto_shift == 1) { + ui.radioButton_auto->setChecked(true); + } + else { + ui.radioButton_auto->setChecked(false); + } + if (g_sys_conf.timing_shift == 1) { + ui.radioButton_time->setChecked(true); + } + else { + ui.radioButton_time->setChecked(false); + } +} + +change_shift::~change_shift() +{ +} + +void change_shift::on_pushButton_apply_released() +{ + QTime timeA; + QTime timeB; + QTime timeC; + if (ui.radioButton_auto->isChecked()) { + g_sys_conf.auto_shift = 1; + g_sys_conf.timing_shift = 0; + + timeA.setHMS(ui.A_hour->minimum(), ui.A_minute->minimum(), 0); + timeB.setHMS(ui.B_hour->minimum(), ui.B_minute->minimum(), 0); + timeC.setHMS(ui.C_hour->minimum(), ui.C_minute->minimum(), 0); + //emit sendMsgToDialogSetup(timeA, timeB, timeC); + //this->close(); + } + else if(ui.radioButton_time->isChecked()) { + g_sys_conf.auto_shift = 0; + g_sys_conf.timing_shift = 1; + + timeA.setHMS(ui.A_hour->text().toInt(), ui.A_minute->text().toInt(), 0); + timeB.setHMS(ui.B_hour->text().toInt(), ui.B_minute->text().toInt(), 0); + timeC.setHMS(ui.C_hour->text().toInt(), ui.C_minute->text().toInt(), 0); + //emit sendMsgToDialogSetup(timeA, timeB, timeC); + //this->close(); + } + emit sendMsgToDialogSetup(timeA, timeB, timeC); + this->close(); + DialogSetup::write_config(); +} + +void change_shift::recMsgFromDialogSetup(QTime timeA, QTime timeB, QTime timeC) +{ + ui.A_hour->setValue(timeA.hour()); + ui.A_minute->setValue(timeA.minute()); + + ui.B_hour->setValue(timeB.hour()); + ui.B_minute->setValue(timeB.minute()); + + ui.C_hour->setValue(timeC.hour()); + ui.C_minute->setValue(timeC.minute()); + + this->show(); +} \ No newline at end of file diff --git a/Cigarette/change_shift.h b/Cigarette/change_shift.h new file mode 100644 index 0000000..00c6451 --- /dev/null +++ b/Cigarette/change_shift.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "ui_change_shift.h" +#include "QtCore/qdatetime.h" + +class change_shift : public QDialog +{ + Q_OBJECT + +public: + change_shift(QDialog *parent = Q_NULLPTR); + ~change_shift(); + +private: + Ui::change_shift ui; + +private slots: + void on_pushButton_apply_released(); + +public slots: + void recMsgFromDialogSetup(QTime timeA, QTime timeB, QTime timeC); + +signals: + void sendMsgToDialogSetup(QTime timeA, QTime timeB, QTime timeC); + +}; diff --git a/Cigarette/change_shift.ui b/Cigarette/change_shift.ui new file mode 100644 index 0000000..b691429 --- /dev/null +++ b/Cigarette/change_shift.ui @@ -0,0 +1,383 @@ + + + change_shift + + + + 0 + 0 + 457 + 350 + + + + 换班设置 + + + + + 170 + 250 + 110 + 30 + + + + + 微软雅黑 + 10 + 75 + true + + + + 应用 + + + + + + 70 + 300 + 331 + 30 + + + + + 微软雅黑 + 12 + + + + 若要保存参数请返回上一级点击保存 + + + + + + 40 + 60 + 140 + 30 + + + + + 微软雅黑 + 16 + + + + 自动换班 + + + + + + 250 + 200 + 60 + 30 + + + + + 微软雅黑 + 12 + + + + 59 + + + + + + 220 + 120 + 20 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + 310 + 200 + 20 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + 160 + 120 + 60 + 30 + + + + + 微软雅黑 + 12 + + + + 23 + + + + + + 110 + 160 + 50 + 30 + + + + + 微软雅黑 + 12 + + + + B班 + + + + + + 110 + 200 + 50 + 30 + + + + + 微软雅黑 + 12 + + + + C班 + + + + + + 110 + 120 + 50 + 30 + + + + + 微软雅黑 + 12 + + + + A班 + + + + + + 250 + 120 + 60 + 30 + + + + + 微软雅黑 + 12 + + + + 59 + + + + + + 310 + 120 + 20 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + 160 + 200 + 60 + 30 + + + + + 微软雅黑 + 12 + + + + 23 + + + + + + 280 + 60 + 140 + 30 + + + + + 微软雅黑 + 16 + + + + 定时换班 + + + + + + 250 + 160 + 60 + 30 + + + + + 微软雅黑 + 12 + + + + 59 + + + + + + 310 + 160 + 20 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + 220 + 200 + 20 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + 160 + 160 + 60 + 30 + + + + + 微软雅黑 + 12 + + + + 23 + + + + + + 220 + 160 + 20 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp new file mode 100644 index 0000000..31412c4 --- /dev/null +++ b/Cigarette/cigarette.cpp @@ -0,0 +1,3990 @@ +#include "cigarette.h" +#include +#include +#include +#include +#include +#include +#include + +// ļ +#define CONFIGURE_FILE "../conf/conf.txt" +// תǶļ +#define ROTATE_FILE "../conf/rotate.txt" +#define MODBUS_CONFIGURE_FILE "../conf/modbus.txt" +#define PLC_CONFIG_FILE "../conf/plc.txt" +#define SELECT_RECTS_FILE "../conf/SelectRects%d%d.txt" +#define STATISTIC_FILE "../conf/camera%d_statistic.txt" +#define ALARM_RECORD_FILE "alarm.txt" + +#define OUTPUT_HIGH_WIDTH 20000 //źŵȣ΢ + +#define OP_TIME 300 //OPȨʱĬ300룩 + +#define ADMIN_TIME 600 //ADMINȨʱĬ300룩 + +#define STOP_SECONDS 3 //ٴβ䴥Զ + +int g_op_time; //OPȨʱĬ300룩 + +int g_admin_time; //ADMINOPȨʱĬ300룩 + +int rotationAngle[NumberOfSupportedCameras]; //ͼƬתǶ +bool isNeddRotate[NumberOfSupportedCameras]; + +SysConf g_sys_conf; //ϵͳò +ModbusConf g_modbus_conf; //modbusַ +DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; +PLCDevice * m_PLCDevice; +QDateTime g_ts_start; + +extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; + +AlgJd alg_jd[NumberOfSupportedCameras]; //⽺AI㷨 + +QThread* pThread[NumberOfSupportedCameras]; + +//³ +CaptureThread* pCaptureThread[NumberOfSupportedCameras]; +FunctionInterface* pFI[NumberOfSupportedCameras]; +mvIMPACT::acquire::GenICam::AcquisitionControl* pAC[NumberOfSupportedCameras]; + +//˹ +CaptureThreadBasler* pBaslerCaptureThread[NumberOfSupportedCameras]; +Pylon::CBaslerUniversalInstantCamera* BaslerCamHandle[NumberOfSupportedCameras]; + +// +void *HIKCamHandle[NumberOfSupportedCameras]; +CaptureThreadHIK* pHIKCaptureThread[NumberOfSupportedCameras]; + +SyncQueue > *g_save_queue; //ͼƬ +SyncQueue > *g_image_queue[NumberOfSupportedCameras]; //intʾһĿ˼ +ASyncQueue *g_shooted_queue[NumberOfSupportedCameras]; // +ASyncQueue *g_result_wait_queue[NumberOfSupportedCameras]; // +ASyncQueue *g_double_queue[NumberOfSupportedCameras]; // +ASyncQueue *g_result_queue[NumberOfSupportedCameras]; // +bool g_debug_mode; //ģʽģʽͣ״̬ܴ +SyncQueue *g_debug_queue[NumberOfSupportedCameras]; //ģʽͼ +SyncQueue<_UDPSendInfo> *UDP_Info_queue; + +bool g_admin_mode; //ǷԱģʽ + +QString g_admin_pswd; //Ա + +bool g_op_mode; //ǷԱģʽ + +QString g_op_pswd; //Ա + +bool g_plc_dialog_open; //ǷplcöԻ + +bool g_working; //true ʼ״̬ false ͣ״̬ + +int last_shift; //¼һΰ + +QStringList g_alarm_msg; + +std::vector g_vec_alarm; + +int g_last_alarm_code; + +int g_lst_quantiy; //һIJ +int quantity_stop_count; // +int g_seconds; +int CurOpLabel; + +VOID BeforeWork(int shoot[]) +{ +#ifdef AI_WARM_UP + for (int j = 0;j<10;j++) + { + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if (SingleCamInfo[i].Detect && SingleCamInfo[i].IsOpen) { + alg_jd[i].test_detect_batcht(shoot[i]); + } + } + } +#endif +} + +Cigarette::Cigarette(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + InitPtrMat(); + bool update_rotate = false; + if (!read_rotate_message()) { + update_rotate = true; + } + + QThread* hThread = new QThread(); + CLog* clogWorkThread = new CLog(); + clogWorkThread->moveToThread(hThread); + connect(this, &Cigarette::destroyed, hThread, &QThread::quit); + connect(hThread, &QThread::finished, clogWorkThread, &CLog::deleteLater); + connect(this, &Cigarette::sengMsgToClog, clogWorkThread, &CLog::recMegFromCigarette); + hThread->start(); + + emit sengMsgToClog("Application Start."); + + g_save_queue = new SyncQueue >(Queue_Size); + g_save_queue->name = "save queue"; + UDP_Info_queue = new SyncQueue<_UDPSendInfo>(Queue_Size); + UDP_Info_queue->name = "UDP Info queue"; + last_shift = 256; + + for(int i=0;i >(Queue_Size); + g_image_queue[i]->name = format("image_%d", i); + g_result_queue[i] = new ASyncQueue(Queue_Size); + g_result_queue[i]->name = format("result_%d", i); + g_result_wait_queue[i] = new ASyncQueue(Queue_Size); + g_result_wait_queue[i]->name = format("result_wait%d", i); + g_double_queue[i] = new ASyncQueue(Queue_Size); + g_double_queue[i]->name = format("double_wait%d", i); + g_shooted_queue[i] = new ASyncQueue(Queue_Size); + g_shooted_queue[i]->name = format("shooted_%d", i); + g_debug_queue[i] = new SyncQueue(Queue_Size); + g_debug_queue[i]->name = format("debug_%d", i); + if (update_rotate) { + rotationAngle[i] = cv::ROTATE_90_COUNTERCLOCKWISE + 1; + isNeddRotate[i] = false; + } + } + if (update_rotate) { + if (save_rotate_message()) { + printf("\nFail to write message to file.");; + } + } + g_debug_mode = false; + + g_admin_mode = false; + g_admin_time = ADMIN_TIME; + + g_admin_pswd = read_pswd(); + + g_op_mode = false; + g_op_time = OP_TIME; + g_op_pswd = read_op_pswd(); + + g_working = false; + + g_alarm_msg << QStringLiteral("ޱ") /// 0 + << QStringLiteral("1#") /// 1 + << QStringLiteral("2#") /// 2 + << QStringLiteral("1#޳") /// 3 + << QStringLiteral("2#޳") /// 4 + << QStringLiteral("1#ͨѶ") /// 5 + << QStringLiteral("2#ͨѶ") /// 6 + << QStringLiteral("3#ͨѶ") /// 7 + << QStringLiteral("4#ͨѶ") /// 8 + << QStringLiteral("5#ͨѶ") /// 9 + << QStringLiteral("6#ͨѶ") /// 10 + << QStringLiteral("7#ͨѶ") /// 11 + << QStringLiteral("8#ͨѶ"); /// 12 + + g_last_alarm_code = 0; + + + g_ts_start = QDateTime::currentDateTime(); + + for(int i=0;idisplay(production_number[i]); + ok[i] = 0; + ng[i] = 0; + g_display_label_conf[i].g_last_mat[0] = cv::Mat::zeros(20, 20, CV_8UC3); + g_display_label_conf[i].g_last_mat[1] = cv::Mat::zeros(20, 20, CV_8UC3); + } + ui.lcdNumber_total_no->display(0); + ui.lcdNumber_total_no_last->display(0); + + g_plc_dialog_open = false; + + g_lst_quantiy = 0; + quantity_stop_count = 0; + g_seconds = 0; + + read_sys_config(g_sys_conf); //ʼϵͳ + + g_modbus_conf.kick1 = 0; + g_modbus_conf.kick2 = 0; + g_modbus_conf.kick3 = 0; + g_modbus_conf.kick4 = 0; + g_modbus_conf.kick5 = 0; + g_modbus_conf.kick6 = 0; + g_modbus_conf.kick7 = 0; + g_modbus_conf.kick8 = 0; + g_modbus_conf.quantity = 0; + g_modbus_conf.shift = 0; + g_modbus_conf.work = 0; + g_modbus_conf.no_kick = 0; + g_modbus_conf.debug = 0; + g_modbus_conf.reset = 0; + g_modbus_conf.alarm = 0; + read_modbus_config(g_modbus_conf); //ʼmodbusַ + + //ͼƬ߳ + saveThread.init(); + saveThread.start_work(); +#ifdef __UDPSend + sThread.init(UDP_Info_queue,g_sys_conf.MonitorIP ,g_sys_conf.MonitorPort); + sThread.start_work(); + + rThread = new threadReceive(); + rThread->init(g_sys_conf.MonitorIP ,g_sys_conf.MonitorPort); + connect(rThread, &threadReceive::sendMsgToCigratte, this, &Cigarette::recMsgFromUdp); + rThread->start_work(); + + sThread.sendData("ReStartOk", g_sys_conf.FeedbackPort); + sThread.sendData("DebugDis", g_sys_conf.FeedbackPort); + sThread.sendData("LockOk", g_sys_conf.FeedbackPort); + +#endif + + m_PLCDevice = new PLCDevice; + PLCDevice::init_plc(m_PLCDevice); + + if(m_PLCDevice->g_plc_ok) + { + printf("Connected to dev!\n"); + ui.label_plc->setText(QStringLiteral("PLC")); + ui.label_plc->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + m_PLCDevice->g_plc_status|=(0x01); + uint8_t Data8; + m_PLCDevice->read_bits_from_plc( g_modbus_conf.no_kick, 1 ,&Data8); + ui.checkBox_unkick->setChecked(Data8); +#ifdef __UDPSend + if(Data8)sThread.sendData("UnKickOk", g_sys_conf.FeedbackPort); + else sThread.sendData("UnKickFail", g_sys_conf.FeedbackPort); +#endif + //ʼPLCļĴֵ + read_plc_items(); + init_plc_value(); + } + else + { + printf("\nSorry,fail to connect ttyS0,please check your device's state.\n"); + ui.label_plc->setText(QStringLiteral("PLCϿ")); + ui.label_plc->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + m_PLCDevice->g_plc_status&=~(0x01); + } + std::cout << " Enumerate Cameras..."<< std::endl; + + EnumerateCameras((SingleCamInfoStruct*)&SingleCamInfo,true,g_sys_conf); + + /*if (!license_pass) Ȩʧ + { + QMessageBox::information(NULL, QStringLiteral("Ȩʧ"), QStringLiteral("ȨʧܣϵϵͳӦ̣"), QMessageBox::Ok); + exit(0); + }*/ + + // ޳ֵ0 + int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.shift, 1);//PLCͻϢ + + //߳ + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if(SingleCamInfo[i].Detect){ + cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + if (!alg_jd[i].init()) + { + QMessageBox::information(NULL, QStringLiteral("ϵͳԼʧ"), QStringLiteral("AIģ1ʼʧܣ"), QMessageBox::Ok); + exit(-1); + } + CreatWorkThread(SingleCamInfo[i].CamClass, i, this); + } + } + + //Զ + if (g_sys_conf.auto_open == 1) + { + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if(SingleCamInfo[i].Detect){ + if(ControlCamOpenOrClose(i,OPEN)) + { + cam_work_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + QString str = QString("border-image: url(:/Cigarette/Resources/cam%1_yes.png);").arg(i+1); + QByteArray ba = str.toLatin1(); + cam_toolButton_mat[i]->setStyleSheet(tr(ba.data())); + } + } + } + } + + DisableDebugMode(); + + m_pTimer = new QTimer(this); + connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout())); + m_pTimer->start(1000); + + m_delay = new QTimer(this);// + connect(m_delay, SIGNAL(timeout()), this, SLOT(enable_shift())); + + m_op_delay = new QTimer(this); + connect(m_op_delay, SIGNAL(timeout()), this, SLOT(op_timeout())); + + m_admin_delay = new QTimer(this); + connect(m_admin_delay, SIGNAL(timeout()), this, SLOT(admin_timeout())); + + clean_pTimer = new QTimer(this); + connect(clean_pTimer,SIGNAL(timeout()), this, SLOT(CleanThreadStartAuto())); + clean_pTimer->start(86400000); + + connect(ui.label_alarm, SIGNAL(QlabelDoubleClick()), this, SLOT(OnCancelAlarm()));//ǩ˫ + + image_lable_DBsignalMapper0 = new QSignalMapper(this); + image_lable_DBsignalMapper1 = new QSignalMapper(this); + image_lable_TPsignalMapper0 = new QSignalMapper(this); + image_lable_TPsignalMapper1 = new QSignalMapper(this); + label_ng_signalMapper = new QSignalMapper(this); + pTimer_Cam_signalMapper = new QSignalMapper(this); + toolButton_cam_signalMapper = new QSignalMapper(this); + RotateReleased_signalMapper = new QSignalMapper(this); + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + m_pTimer_Cam_mat[i] = new QTimer(this); + connect(m_pTimer_Cam_mat[i], SIGNAL(timeout()), pTimer_Cam_signalMapper, SLOT(map())); + pTimer_Cam_signalMapper->setMapping(m_pTimer_Cam_mat[i], i); + + connect(display_lable_mat[i][0], SIGNAL(QlabelDoubleClick()), image_lable_DBsignalMapper0, SLOT(map())); + image_lable_DBsignalMapper0->setMapping(display_lable_mat[i][0], i << 4 | 0); + + connect(display_lable_mat[i][1], SIGNAL(QlabelDoubleClick()), image_lable_DBsignalMapper1, SLOT(map())); + image_lable_DBsignalMapper1->setMapping(display_lable_mat[i][1], i << 4 | 1); + + connect(display_lable_mat[i][0], SIGNAL(QlabelTripleClick()), image_lable_TPsignalMapper0, SLOT(map())); + image_lable_TPsignalMapper0->setMapping(display_lable_mat[i][0], i << 4 | 0); + + connect(display_lable_mat[i][1], SIGNAL(QlabelTripleClick()), image_lable_TPsignalMapper1, SLOT(map())); + image_lable_TPsignalMapper1->setMapping(display_lable_mat[i][1], i << 4 | 1); + + connect(label_ng_mat[i], SIGNAL(QlabelDoubleClick()), label_ng_signalMapper, SLOT(map())); + label_ng_signalMapper->setMapping(label_ng_mat[i], i); + + connect(cam_toolButton_mat[i], SIGNAL(released()), toolButton_cam_signalMapper, SLOT(map())); + toolButton_cam_signalMapper->setMapping(cam_toolButton_mat[i], i); + + connect(rotate_mat[i], SIGNAL(released()), RotateReleased_signalMapper, SLOT(map())); + RotateReleased_signalMapper->setMapping(rotate_mat[i], i); + + } + connect(toolButton_cam_signalMapper, SIGNAL(mapped(int)), this, SLOT(OnToolButtonCamReleasedHub(int))); + connect(pTimer_Cam_signalMapper, SIGNAL(mapped(int)), this, SLOT(OpenCamTimeoutHub(int))); + connect(image_lable_DBsignalMapper0, SIGNAL(mapped(int)), this, SLOT(OnDBClickHub(int))); + connect(image_lable_DBsignalMapper1, SIGNAL(mapped(int)), this, SLOT(OnDBClickHub(int))); + connect(image_lable_TPsignalMapper0, SIGNAL(mapped(int)), this, SLOT(OnTPClickHub(int))); + connect(image_lable_TPsignalMapper1, SIGNAL(mapped(int)), this, SLOT(OnTPClickHub(int))); + connect(label_ng_signalMapper, SIGNAL(mapped(int)), this, SLOT(OnDBClickNGHub(int))); + connect(RotateReleased_signalMapper, SIGNAL(mapped(int)), this, SLOT(OnRotateReleasedHub(int))); + + //õ԰ť + ui.checkBox_debug->setEnabled(false); + //OK/NGť + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + label_reslut_mat[i]->setVisible(false); + } + ui.label_role->setText(QStringLiteral("δ¼")); + + //Զʼ + if (g_sys_conf.auto_work == 1) + { + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if(SingleCamInfo[i].Detect && SingleCamInfo[i].IsOpen){ + if(SingleCamInfo[i].CamClass == BalluffClassID){ + if(pCaptureThread[i]) + while(!pCaptureThread[i]->Ready)Sleep(10); + }else if(SingleCamInfo[i].CamClass == BaslerClassID){ + if(pBaslerCaptureThread[i]) + while(!pBaslerCaptureThread[i]->Ready)Sleep(10); + }else if(SingleCamInfo[i].CamClass == HIKClassID){ + if(pHIKCaptureThread[i]) + while(!pHIKCaptureThread[i]->Ready)Sleep(10); + } + } + } + + if (m_PLCDevice->g_plc_ok) { + BeforeWork(g_sys_conf.shoot); + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.work, 1); + ui.label_title->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); +#ifdef __UDPSend + sThread.sendData("Work", g_sys_conf.FeedbackPort); +#endif + g_working = true; + ui.checkBox_debug->setChecked(false); //Բ + ui.checkBox_debug->setEnabled(false); //Բ + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + //ʾOK/NGť + label_reslut_mat[i]->setVisible(true); + } + } + } +} + +Cigarette::~Cigarette() +{ + emit sengMsgToClog("Application exited."); +} + +void Cigarette::start_work() +{ + //ɼʱл + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if(SingleCamInfo[i].Detect && SingleCamInfo[i].IsOpen){ + if(SingleCamInfo[i].CamClass == BalluffClassID){ + if(pCaptureThread[i]) + { + pCaptureThread[i]->p_result_queue->clear(); + pCaptureThread[i]->p_unit_queue->clear(); + pCaptureThread[i]->p_result_wait_queue->clear(); + pCaptureThread[i]->p_shooted_queue->clear(); + } + } + else if (SingleCamInfo[i].CamClass == BaslerClassID) { + if(pBaslerCaptureThread[i]) + { + pBaslerCaptureThread[i]->p_result_queue->clear(); + pBaslerCaptureThread[i]->p_unit_queue->clear(); + pBaslerCaptureThread[i]->p_result_wait_queue->clear(); + pBaslerCaptureThread[i]->p_shooted_queue->clear(); + } + } + else if (SingleCamInfo[i].CamClass == HIKClassID) { + if(pHIKCaptureThread[i]) + { + pHIKCaptureThread[i]->p_result_queue->clear(); + pHIKCaptureThread[i]->p_unit_queue->clear(); + pHIKCaptureThread[i]->p_result_wait_queue->clear(); + pHIKCaptureThread[i]->p_shooted_queue->clear(); + } + } + } + } + + BeforeWork(g_sys_conf.shoot); + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.work, 1); + /*::Sleep(5000); + ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.work, 0); + ::Sleep(5000); + ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.work, 1);*/ + //printf("write:\t%d\n", ret); + ui.label_title->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); +#ifdef __UDPSend + sThread.sendData("Work", g_sys_conf.FeedbackPort); +#endif + g_working = true; + ui.checkBox_debug->setChecked(false); //ȡģʽ + ui.checkBox_debug->setEnabled(false); //Բ + //ʾOK/NGť + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + //ʾOK/NGť + label_reslut_mat[i]->setVisible(true); + } +} +//ʼť +void Cigarette::on_btn_start_released() +{ + emit sengMsgToClog("Start to work."); + if (!g_admin_mode) + { + if (!g_op_mode) + { + emit sengMsgToClog("Start to login in."); + dialogin = new Dialogin(this); + connect(dialogin, SIGNAL(enter_op()), this, SLOT(OnOp())); + dialogin->setModal(true); + dialogin->show(); + dialogin->move((this->width() - dialogin->width()) / 2, (this->height() - dialogin->height()) / 2); + return; + } + } + if (m_PLCDevice->g_plc_ok) { + if (g_debug_mode) + { + QMessageBox::information(NULL, QStringLiteral("˳"), QStringLiteral("ȵģʽѡȡģʽſԿʼ"), QMessageBox::Ok); + return; + } + if (!g_working) + { + start_work(); + } + } + g_op_time = OP_TIME; +} + +void Cigarette::pause_work() +{ + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.work, 0 ); + //printf("write:\t%d\n", ret); + ui.label_title->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); +#ifdef __UDPSend + sThread.sendData("NoWork", g_sys_conf.FeedbackPort); +#endif + g_working = false; + ui.checkBox_debug->setEnabled(true); //ʹcheckBox + //OK/NGť + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + //ʾOK/NGť + label_reslut_mat[i]->setVisible(false); + } +} +//ͣť +void Cigarette::on_btn_pause_released() +{ + emit sengMsgToClog("Pause the application."); + if (!g_admin_mode) + { + if (!g_op_mode) + { + emit sengMsgToClog("Start to login in."); + dialogin = new Dialogin(this); + connect(dialogin, SIGNAL(enter_op()), this, SLOT(OnOp())); + dialogin->setModal(true); + dialogin->show(); + dialogin->move((this->width() - dialogin->width()) / 2, (this->height() - dialogin->height()) / 2); + return; + } + } + if (m_PLCDevice->g_plc_ok) { + if (g_working){ + pause_work(); + } + } + g_op_time = OP_TIME; +} +///ť +void Cigarette::on_btn_lock_released() +{ + if (!g_admin_mode) + { + emit sengMsgToClog("Unlock the application."); + dialog_setup_passwd = new DialogSetupPasswd(this); + connect(dialog_setup_passwd, SIGNAL(enter_admin()), this, SLOT(OnAdmin())); + dialog_setup_passwd->setModal(true); + dialog_setup_passwd->show(); + dialog_setup_passwd->move((this->width() - dialog_setup_passwd->width()) / 2, (this->height() - dialog_setup_passwd->height()) / 2); + } + else + { + emit sengMsgToClog("Lock the application."); + g_admin_mode = false; + g_op_mode = false; + ui.label_12->setText(QStringLiteral("¼û")); + ui.label_role->setText(QStringLiteral("δ¼")); + ui.btn_lock->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/unlock.png);")); + ui.checkBox_debug->setEnabled(false); + if (m_op_delay->isActive()) + { + m_op_delay->stop(); + } + if (m_admin_delay->isActive()) + { + m_admin_delay->stop(); + } +#ifdef __UDPSend + sThread.sendData("LockOk", g_sys_conf.FeedbackPort); +#endif + } +} +//ðť +void Cigarette::on_btn_setup_released() +{ + emit sengMsgToClog("Start to set the application."); + if (g_admin_mode) + { + dialog_setup = new DialogSetup(this); + connect(dialog_setup, SIGNAL(system_exit()), this, SLOT(OnExit())); + dialog_setup->setModal(true); + dialog_setup->show(); + dialog_setup->move((this->width() - dialog_setup->width()) / 2, (this->height() - dialog_setup->height()) / 2); + } + else { + QMessageBox::information(NULL, QStringLiteral("Ȩ޼"), QStringLiteral("ȵťԱģʽ"), QMessageBox::Ok); + } +} + +//Ա½ +void Cigarette::OnAdmin() +{ + emit sengMsgToClog("Administrator is login in."); + g_admin_mode = true; + ui.label_12->setText(QStringLiteral("¼û")); + ui.label_role->setText(QStringLiteral("Ա")); + ui.btn_lock->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/lock.png);")); + ui.checkBox_debug->setEnabled(true); + g_admin_time = ADMIN_TIME; + m_admin_delay->start(1000); + if (m_op_delay->isActive()) + { + m_op_delay->stop(); + } +#ifdef __UDPSend + sThread.sendData("UnlockOk", g_sys_conf.FeedbackPort); +#endif +} +//Ա½ +void Cigarette::OnOp() +{ + emit sengMsgToClog("Operator is login in."); + g_op_mode = true; + g_op_time = OP_TIME; + ui.label_role->setText(QStringLiteral("Ա")); + m_op_delay->start(1000); +} +//˳ǰִ +void Cigarette::OnExit() +{ + //emit sengMsgToClog("Close the Application."); + this->on_btn_pause_released(); + for(int i=0;isetStyleSheet(tr("background-color: rgb(255, 255, 0);")); + } + } + work_thread[i].stop(); + debug_thread[i].stop(); + delete g_image_queue[i]; + delete g_result_queue[i]; + delete g_result_wait_queue[i]; + delete g_double_queue[i]; + delete g_shooted_queue[i]; + delete g_debug_queue[i]; + qDebug() << "Close capture thread " << i; + } + saveThread.stop(); + delete g_save_queue; +#ifdef __UDPSend + sThread.stop(); + rThread->stop(); + delete rThread; +#endif + qDebug() << "Close thread ";; + + if(m_PLCDevice) { + m_PLCDevice->disconnect_plc(); + delete m_PLCDevice; + } + qApp->quit(); + this->close(); + + Pylon::PylonTerminate(); + exit(1);/// +} + +void Cigarette::OnRestart() +{ + this->on_btn_pause_released(); + Pylon::PylonTerminate(); + delete g_save_queue; + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if (SingleCamInfo[i].Detect) { + if (ControlCamOpenOrClose(i, CLOSE)) + { + qDebug() << "Close device " << i; + cam_work_mat[i]->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + } + } + delete g_image_queue[i]; + delete g_result_queue[i]; + delete g_result_wait_queue[i]; + delete g_double_queue[i]; + delete g_shooted_queue[i]; + delete g_debug_queue[i]; + work_thread[i].stop(); + debug_thread[i].stop(); + } + + saveThread.stop(); +#ifdef __UDPSend + sThread.stop(); + rThread->stop(); + delete rThread; +#endif + + if(m_PLCDevice) { + m_PLCDevice->disconnect_plc(); + delete m_PLCDevice; + } + + this->close(); + qApp->quit(); + QProcess::startDetached(qApp->applicationFilePath(), QStringList()); +} +// +void Cigarette::enable_shift() +{ + ui.pushButton_clear->setEnabled(true); +} + +void Cigarette::OnRotateReleasedHub(int Num) +{ + QString str = "Start to rotate picture " + QString::number(90 * ((rotationAngle[Num] + 1) % 4)) + " degrees of camera " + QString::number(Num) + "."; + emit sengMsgToClog(str); + if(isNeddRotate[Num] == true) + { + rotationAngle[Num] = (rotationAngle[Num] + 1) % 4; + save_rotate_message(); + } + +} + +///ر +void Cigarette::OnToolButtonCamReleasedHub(int Num) +{ + if (g_admin_mode) + { + if(SingleCamInfo[Num].Detect) + { + if (!SingleCamInfo[Num].IsOpen) + { + emit sengMsgToClog("Start open camera " + QString::number(Num) + "."); + if(ControlCamOpenOrClose(Num,OPEN)) + { + cam_work_mat[Num]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + QString str = QString("border-image: url(:/Cigarette/Resources/cam%1_yes.png);").arg(Num+1); + QByteArray ba = str.toLatin1(); + cam_toolButton_mat[Num]->setStyleSheet(tr(ba.data())); + } + } + else + { + emit sengMsgToClog("Start close camera " + QString::number(Num) + "."); + if(ControlCamOpenOrClose(Num,CLOSE)) + { + cam_work_mat[Num]->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + QString str = QString("border-image: url(:/Cigarette/Resources/cam%1_no.png);").arg(Num+1); + QByteArray ba = str.toLatin1(); + cam_toolButton_mat[Num]->setStyleSheet(tr(ba.data())); + } + } + } + else + { + emit sengMsgToClog("Close or open camera " + QString::number(Num) + " fail, there is no camera in potision 0."); + QMessageBox::information(NULL, QStringLiteral("ʧ"), QStringLiteral("ûλûм⵽"), QMessageBox::Ok); + } + } + else { + emit sengMsgToClog("Close or open camera " + QString::number(Num) + " fail, because of authorization check fail."); + QMessageBox::information(NULL, QStringLiteral("Ȩ޼"), QStringLiteral("ȵťԱģʽ"), QMessageBox::Ok); + } +} + +void Cigarette::ReconnectCamHub(int Num) +{ + //close + if(SingleCamInfo[Num].Detect) + { + if(ControlCamOpenOrClose(Num,CLOSE)) + { + m_pTimer_Cam_mat[Num]->setSingleShot(true); + m_pTimer_Cam_mat[Num]->start(2000); + } + } +} + +void Cigarette::OpenCamTimeoutHub(int Num) //´ +{ + //open + if(ControlCamOpenOrClose(Num,OPEN)) + { + cam_work_mat[Num]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + cam_toolButton_mat[Num]->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam1_yes.png);")); + } +} + +void Cigarette::OnKey(QKeyEvent* event) +{ + int Num = CurOpLabel >> 4; + int Cnt = CurOpLabel & 0x0f; + + std::lock_guard locker(g_display_label_conf[Num].lock); + if (event->key() == Qt::Key_Escape && event->isAutoRepeat()==false) + { + if (g_display_label_conf[Num].RectVet[Cnt].size()) + { + g_display_label_conf[Num].RectVet[Cnt].pop_back(); + } + } + else if (event->key() == Qt::Key_Return && event->isAutoRepeat()==false) + { + std::fstream cfg_file; + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, SELECT_RECTS_FILE, Num,Cnt); + cfg_file.open(buf, ios::trunc | ofstream::out); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file SelectRects.txt" << std::endl; + return; + } + for (int i = 0; i < g_display_label_conf[Num].RectVet[Cnt].size(); i++) + { + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, + "%03f,%03f,%03f,%03f\n", + g_display_label_conf[Num].RectVet[Cnt][i].TL.x, + g_display_label_conf[Num].RectVet[Cnt][i].TL.y, + g_display_label_conf[Num].RectVet[Cnt][i].BR.x, + g_display_label_conf[Num].RectVet[Cnt][i].BR.y + ); + cfg_file.write(buf, strlen(buf)); + } + } +} +//ص +void Cigarette::OnMouse(QMouseEvent* event) +{ + int Num = CurOpLabel>>4; + int Cnt = CurOpLabel&0x0f; + + int CurWidgetWidth = display_lable_mat[Num][Cnt]->width(); + int CurWidgetHeight = display_lable_mat[Num][Cnt]->height(); + + std::lock_guard locker(g_display_label_conf[Num].lock); + if (event->type() == QEvent::MouseButtonPress) + { + g_display_label_conf[Num].leftButtonDownFlag = true; //־λ + g_display_label_conf[Num].originalPoint = cv::Point2f( + event->x() * 1.0 / CurWidgetWidth, + event->y() * 1.0 / CurWidgetHeight + ); //µľ + g_display_label_conf[Num].processPoint = g_display_label_conf[Num].originalPoint; + } + if (event->type() == QEvent::MouseMove && g_display_label_conf[Num].leftButtonDownFlag) + { + g_display_label_conf[Num].processPoint = cv::Point2f( + event->x() * 1.0 / CurWidgetWidth, + event->y() * 1.0 / CurWidgetHeight + ); + } + if (event->type() == QEvent::MouseButtonRelease) + { + g_display_label_conf[Num].leftButtonDownFlag = false; + RectRatio m_RectRatio = RectRatio( + cv::Point2f(g_display_label_conf[Num].originalPoint.x * 1.0, + g_display_label_conf[Num].originalPoint.y * 1.0 + ), + cv::Point2f(event->x() * 1.0 / CurWidgetWidth, + event->y() * 1.0 / CurWidgetHeight + ) + ); + float tempx = abs((m_RectRatio.TL - m_RectRatio.BR).x); + float tempy = abs((m_RectRatio.TL - m_RectRatio.BR).y); + if(tempx >0.05) + g_display_label_conf[Num].RectVet[Cnt].push_back(m_RectRatio); + } +} + +//˫ͼ1 +void Cigarette::OnDBClickHub(int Num_Cnt) +{ + int Num = Num_Cnt>>4; + int Cnt = Num_Cnt&0x0f; + + CurOpLabel = Num_Cnt; + std::lock_guard locker(g_display_label_conf[Num].lock); + if (g_display_label_conf[Num].g_max[Cnt]) + { /// ȫ״̬ ˫ȡȫ + emit sengMsgToClog("Cancel the picture of camera " + QString::number(Num) + " to full screen."); + g_display_label_conf[Num].g_max[Cnt] = false; + display_lable_mat[Num][Cnt]->setGeometry( + display_lable_info[Num][Cnt].x, + display_lable_info[Num][Cnt].y, + display_lable_info[Num][Cnt].width, + display_lable_info[Num][Cnt].height + ); + rotate_mat[Num]->setGeometry( + rotate_info[Num].x, + rotate_info[Num].y, + rotate_info[Num].width, + rotate_info[Num].height + ); + if(g_display_label_conf[Num].Flag[Cnt] & DisplayLabel_Type_Bit) + { + g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Conf_Bit; + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalmousePressEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalmouseMoveEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalmouseReleaseEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalkeyReleaseEvent(QKeyEvent*)), this, SLOT(OnKey(QKeyEvent*))); + } + } + else + { // ˫ȫ + emit sengMsgToClog("Set the picture of camera " + QString::number(Num) + " to full screen."); + g_display_label_conf[Num].g_max[Cnt] = true; + display_lable_mat[Num][Cnt]->setGeometry(0, 0, 1280, 800); + + //rotate_mat[Num]->setGeometry(1230, 10, 40, 40); + + if (g_debug_mode)//ǷΪģʽ + { + rotate_mat[Num]->setGeometry(1230, 10, 40, 40); + } + else + { + rotate_mat[Num]->setGeometry(1230, 10, 0, 0); + } + + display_lable_mat[Num][Cnt]->raise(); + rotate_mat[Num]->raise(); + + if(g_display_label_conf[Num].Flag[Cnt] & DisplayLabel_Type_Bit) + { + g_display_label_conf[Num].Flag[Cnt] |= DisplayLabel_Conf_Bit; + connect(display_lable_mat[Num][Cnt], SIGNAL(SignalmousePressEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + connect(display_lable_mat[Num][Cnt], SIGNAL(SignalmouseMoveEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + connect(display_lable_mat[Num][Cnt], SIGNAL(SignalmouseReleaseEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + connect(display_lable_mat[Num][Cnt], SIGNAL(SignalkeyReleaseEvent(QKeyEvent*)), this, SLOT(OnKey(QKeyEvent*))); + } + } + OnNotifyHub(Num,Cnt,g_display_label_conf[Num].g_last_mat[Cnt]); +} +void Cigarette::OnTPClickHub(int Num_Cnt) +{ + int Num = Num_Cnt >> 4; + int Cnt = Num_Cnt & 0x0f; + + std::lock_guard locker(g_display_label_conf[Num].lock); + if (g_display_label_conf[Num].Flag[Cnt] & DisplayLabel_Type_Bit) + { + g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Type_Bit; + g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Conf_Bit; + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalmousePressEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalmouseMoveEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalmouseReleaseEvent(QMouseEvent*)), this, SLOT(OnMouse(QMouseEvent*))); + disconnect(display_lable_mat[Num][Cnt], SIGNAL(SignalkeyReleaseEvent(QKeyEvent*)), this, SLOT(OnKey(QKeyEvent*))); + } + else + { + g_display_label_conf[Num].Flag[Cnt] |= DisplayLabel_Type_Bit; + std::fstream cfg_file; + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, SELECT_RECTS_FILE, Num, Cnt); + cfg_file.open(buf); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file SelectRects.txt" << std::endl; + return; + } + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + QString line = QString::fromStdString(std::string(tmp)); + QStringList dataList = line.split(','); + if (dataList.length() == 4) + { + RectRatio m_RectRatio = RectRatio( + cv::Point2f(dataList[0].toFloat(),dataList[1].toFloat()), + cv::Point2f(dataList[2].toFloat(),dataList[3].toFloat()) + ); + g_display_label_conf[Num].RectVet[Cnt].push_back(m_RectRatio); + } + } + } +} +//˫NG +void Cigarette::OnDBClickNGHub(int Num) +{ + emit sengMsgToClog("Double click NG."); + QDateTime now_ts = QDateTime::currentDateTime(); + std::ostringstream ostr; + ostr << "explorer D:\\image\\" << (now_ts.toString("yyyy-MM-dd")).toStdString()<< "\\" << Num+1 << "\\ng_result"; + std::string str = ostr.str(); + system(str.c_str()); +} + +void Cigarette::OnNotifyHub(int Num, int Cnt,cv::Mat m) +{ + //ͼСΪʾڴС + cv::Size display_size = cv::Size(display_lable_mat[Num][Cnt]->width(), display_lable_mat[Num][Cnt]->height()); + cv::resize(m, m, display_size); + + QImage tempImage = Cigarette::cvMatToQImage(m); + display_lable_mat[Num][Cnt]->setPixmap(QPixmap::fromImage(tempImage)); + g_display_label_conf[Num].g_last_mat[Cnt] = m; + + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = image_frame; + UDPSendInfo.index = Num; + UDPSendInfo.cnt = Cnt; + UDPSendInfo.image = m.clone(); +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif +} + +void Cigarette::OnDisplayTimeCostHub(int Num, int ms) +{ + label_timecost_mat[Num]->setText(QString::number(ms) + "ms"); +} + +void Cigarette::OnDisplayCheckNumberHub(int Num, long no) +{ + production_number[Num]++; + lcdNumber_total_mat[Num]->display(production_number[Num]); + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = total_frame; + UDPSendInfo.index = Num; + UDPSendInfo.Total = production_number[Num]; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif +} + +void Cigarette::OnDisplayJdNoHub(int Num, QString jd_no) +{ + label_jd_no_mat[Num]->setText(jd_no); +} + +void Cigarette::OnOKHub(int Num) +{ + ok[Num]++; + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = ok_frame; + UDPSendInfo.index = Num; + UDPSendInfo.ok = ok[Num]; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + lcdNumber_ok_mat[Num]->display(ok[Num]); + label_reslut_mat[Num]->setText("OK"); + label_reslut_mat[Num]->setStyleSheet(tr("background-color: rgb(0, 255, 0);")); +} + +void Cigarette::OnNGHub(int Num) +{ + ng[Num]++; + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = ng_frame; + UDPSendInfo.index = Num; + UDPSendInfo.ng = ng[Num]; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + lcdNumber_ng_mat[Num]->display(ng[Num]); + label_reslut_mat[Num]->setText("NG"); + label_reslut_mat[Num]->setStyleSheet(tr("background-color: rgb(255, 0, 0);")); +} + +void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num) +{ + label_cap_speed_mat[Num]->setText(statisticalData + QStringLiteral("/")); + + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = speed_frame; + UDPSendInfo.index = Num; + UDPSendInfo.speed = statisticalData; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif +} + +//޳ģʽ +void Cigarette::on_checkBox_unkick_clicked(bool checked) +{ + if (!g_admin_mode) + { + if (!g_op_mode) + { + emit sengMsgToClog("Start to login in."); + dialogin = new Dialogin(this); + connect(dialogin, SIGNAL(enter_op()), this, SLOT(OnOp())); + dialogin->setModal(true); + dialogin->show(); + dialogin->move((this->width() - dialogin->width()) / 2, (this->height() - dialogin->height()) / 2); + ui.checkBox_unkick->setChecked(false); + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.no_kick, 0); +#ifdef __UDPSend + sThread.sendData("UnKickOk", g_sys_conf.FeedbackPort); +#endif + return; + } + ui.checkBox_unkick->setChecked(false); + } + if (m_PLCDevice->g_plc_ok) { + if (checked) + { + emit sengMsgToClog("Enter unkick mode."); + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.no_kick, 1); +#ifdef __UDPSend + sThread.sendData("UnKickOk", g_sys_conf.FeedbackPort); +#endif + } + else + { + emit sengMsgToClog("Exit unkick mode."); + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.no_kick, 0); +#ifdef __UDPSend + sThread.sendData("KickOk", g_sys_conf.FeedbackPort); +#endif + } + ui.checkBox_unkick->setChecked(checked); + } + else { + ui.checkBox_unkick->setChecked(false); + emit sengMsgToClog("Enter or exit unkick mode fail."); +#ifdef __UDPSend + sThread.sendData("UnKickFail", g_sys_conf.FeedbackPort); +#endif + } +} +//ģʽ +void Cigarette::on_checkBox_debug_clicked(bool checked) +{ + if (!g_admin_mode) + { + QMessageBox::information(NULL, QStringLiteral("Ȩ޼ "), QStringLiteral("ȵťԱģʽ"), QMessageBox::Ok); + ui.checkBox_debug->setChecked(false); + return; + } + if (checked) //ģʽ + { + if (g_working) + { + QMessageBox::information(NULL, QStringLiteral("˳ "), QStringLiteral("ȵͣťܽģʽ"), QMessageBox::Ok); + ui.checkBox_debug->setChecked(false); + } + else + { + emit sengMsgToClog("Enter debug mode."); + EnableDebugMode(); + ui.checkBox_debug->setChecked(true); +#ifdef __UDPSend + sThread.sendData("DebugEn", g_sys_conf.FeedbackPort); +#endif + } + } + else //ر + { + emit sengMsgToClog("Exit debug mode."); + DisableDebugMode(); + ui.checkBox_debug->setChecked(false); +#ifdef __UDPSend + sThread.sendData("DebugDis", g_sys_conf.FeedbackPort); +#endif + } +} +//PLCöԻ +void Cigarette::on_toolButton_plc_released() +{ + emit sengMsgToClog("Open PLC setting."); + if (m_PLCDevice->g_plc_ok) + { + if (g_admin_mode) + { + g_plc_dialog_open = true; + dialog_plc_setup = new PlcSetup(this); + dialog_plc_setup->setModal(true); + dialog_plc_setup->show(); + dialog_plc_setup->move((this->width() - dialog_plc_setup->width()) / 2, (this->height() - dialog_plc_setup->height()) / 2); + } + else { + QMessageBox::information(NULL, QStringLiteral("Ȩ޼"), QStringLiteral("ȵťԱģʽ"), QMessageBox::Ok); + } + } + else { + QMessageBox::information(NULL, QStringLiteral("Ӳ"), QStringLiteral("ȷPLCӳɹٽPLC"), QMessageBox::Ok); + } +} + +void Cigarette::on_toolButton_version_released() { + emit sengMsgToClog("Open Version infomation."); + std::fstream cfg_file; + QString loc; + cfg_file.open(CONFIGURE_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file " << CONFIGURE_FILE << std::endl; + } + + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + std::string line(tmp); + if (line.length() > 0) + { + /// atoiֵsubstrӴc_str()ַָ׵ַ + size_t pos = line.find('='); + std::string tmp_key = line.substr(0, pos); + + if (tmp_key == "LOCATION") + { /// ͼã0棻1NG2ȫ + loc = line.substr(pos + 1).c_str(); + } + } + } + + //std::cout << loc.toStdString().c_str() << std::endl; + QMessageBox::information(NULL, QStringLiteral("汾Ϣ"), QStringLiteral("ڵأ%1").arg(loc.toStdString().c_str()), QMessageBox::Ok); +} + + +//ԱȨʣʱ +void Cigarette::op_timeout() +{ + g_op_time--; + ui.label_12->setText(QString::number(g_op_time)); + if (0 == g_op_time) + { + g_op_mode = false; + ui.label_12->setText(QStringLiteral("¼û")); + ui.label_role->setText(QStringLiteral("δ¼")); + m_op_delay->stop(); + } +} + +//ԱȨʣʱ +void Cigarette::admin_timeout() +{ + g_admin_time--; + ui.label_12->setText(QString::number(g_admin_time)); + if (0 == g_admin_time) + { + on_btn_lock_released(); + } +} + +void Cigarette::handleTimeout() +{ + QDateTime ts_start = QDateTime::currentDateTime(); + QTime time = QTime::currentTime(); + QDateTime local(ts_start); + QString localTime = local.toString("yyyy-MM-dd hh:mm:ss"); + ui.label_cur_time->setText(localTime); + + qint64 intervalTime = g_ts_start.secsTo(ts_start); + int days = (intervalTime) / (24 * 3600); + int hours = (intervalTime) % (24 * 3600) / 3600; + int minutes = (intervalTime) % 3600 / 60; + int second = (intervalTime) % 60; + + QString run_stat = QString(QStringLiteral("%1%2ʱ%3%4")) + .arg(days).arg(hours).arg(minutes).arg(second); + ui.label_run_stat->setText(run_stat); + + //õPLCַжȡ + if (m_PLCDevice->g_plc_ok) + { + if (!g_plc_dialog_open) //PLCöԻûд + { + if (g_modbus_conf.quantity > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16); + if (ret == 2) + { + int cur_quantity = dest16[0] + (dest16[1] << 16); + ui.lcdNumber_total_no->display(cur_quantity); +#ifdef __UDPSend + sThread.sendData("total_" + QString::number(cur_quantity), g_sys_conf.FeedbackPort); + sThread.sendData("totallast_" + QString::number(ui.lcdNumber_total_no_last->intValue()), g_sys_conf.FeedbackPort); +#endif + ui.label_plc->setText(QStringLiteral("PLC")); + ui.label_plc->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + if(!(m_PLCDevice->g_plc_status&0x01)) + { + init_plc_value(); + if(g_working) + { + if (g_debug_mode) + { + QMessageBox::information(NULL, QStringLiteral("˳"), QStringLiteral("ȵģʽѡȡģʽſԿʼ"), QMessageBox::Ok); + return; + } + start_work(); + } + else if (!g_working) + { + pause_work(); + } + m_PLCDevice->g_plc_status|=(0x01); + } + //Զ + if (g_sys_conf.auto_shift&&g_working) + { + g_seconds++; + if (g_seconds % 10 == 0) + { + if (cur_quantity == g_lst_quantiy) + { + quantity_stop_count++; + } + else { + quantity_stop_count = 0; + } + if (quantity_stop_count == STOP_SECONDS) //һλ + { + g_op_mode = true; //Աģʽ + on_btn_pause_released(); //ͣ + on_pushButton_clear_released(); // + on_btn_start_released(); //ʼ + g_op_mode = false; //˳Աģʽ + } + g_lst_quantiy = cur_quantity; + } + } + else if (g_sys_conf.timing_shift && g_working) + { + qint64 secA = time.secsTo(g_sys_conf.shiftA); + qint64 secB = time.secsTo(g_sys_conf.shiftB); + qint64 secC = time.secsTo(g_sys_conf.shiftC); + if (secA == 0) + { + g_op_mode = true; //Աģʽ + on_btn_pause_released(); //ͣ + record_output_statistic(cur_quantity, 0); + on_pushButton_clear_released(); // + on_btn_start_released(); //ʼ + g_op_mode = false; //˳Աģʽ + } + else if (secB == 0) + { + g_op_mode = true; //Աģʽ + on_btn_pause_released(); //ͣ + record_output_statistic(cur_quantity, 1); + on_pushButton_clear_released(); // + on_btn_start_released(); //ʼ + g_op_mode = false; //˳Աģʽ + } + else if (secC == 0) + { + g_op_mode = true; //Աģʽ + on_btn_pause_released(); //ͣ + record_output_statistic(cur_quantity, 2); + on_pushButton_clear_released(); // + on_btn_start_released(); //ʼ + g_op_mode = false; //˳Աģʽ + } + } + } + else + { + ui.label_plc->setText(QStringLiteral("PLCϿ")); + ui.label_plc->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + m_PLCDevice->g_plc_status&=~(0x01); + } + } + } + } + //޳ + if (m_PLCDevice->g_plc_ok) + { + if (!g_plc_dialog_open) //PLCöԻûд + { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + if (g_modbus_conf.kick1 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick1, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 0; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + if (g_modbus_conf.kick2 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick2, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 1; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + if (g_modbus_conf.kick3 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 2; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + if (g_modbus_conf.kick4 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 3; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + if (g_modbus_conf.kick5 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 4; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + if (g_modbus_conf.kick6 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 5; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + if (g_modbus_conf.kick7 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 6; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + if (g_modbus_conf.kick8 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16); + if (ret == 2) + { + ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16)); +#ifdef __UDPSend + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 7; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } +#endif + } + } + //߼ + if (SingleCamInfo[0].OffLine) //1# + { + //SingleCamInfo[0] = false; + ui.cam_status_1->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_1->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_1->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam1_no.png);")); + ui.label_reslut_1->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = {5,0}; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[0].OffLine = false; + } + } + if (SingleCamInfo[1].OffLine) //2# + { + //SingleCamInfo[1] = false; + ui.cam_status_2->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_2->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_2->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam2_no.png);")); + ui.label_reslut_2->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = {6,0}; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if(ret > 0) SingleCamInfo[1].OffLine = false; + } + } + if (SingleCamInfo[2].OffLine) //3# + { + //SingleCamInfo[2] = false; + ui.cam_status_3->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_3->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_3->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam3_no.png);")); + ui.label_reslut_3->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = { 7,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[2].OffLine = false; + } + } + + if (SingleCamInfo[3].OffLine) //4# + { + //SingleCamInfo[3] = false; + ui.cam_status_4->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_4->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_4->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam4_no.png);")); + ui.label_reslut_4->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = { 8,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[3].OffLine = false; + } + } + if (SingleCamInfo[4].OffLine) //5# + { + //SingleCamInfo[4] = false; + ui.cam_status_5->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_5->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_5->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam5_no.png);")); + ui.label_reslut_5->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = { 9,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[4].OffLine = false; + } + } + if (SingleCamInfo[5].OffLine) //6# + { + //SingleCamInfo[5] = false; + ui.cam_status_6->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_6->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_6->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam6_no.png);")); + ui.label_reslut_6->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = { 10,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[5].OffLine = false; + } + } + if (SingleCamInfo[6].OffLine) //7# + { + //SingleCamInfo[6] = false; + ui.cam_status_7->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_7->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_7->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam7_no.png);")); + ui.label_reslut_7->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = { 11,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[6].OffLine = false; + } + } + if (SingleCamInfo[7].OffLine) //8# + { + //SingleCamInfo[7] = false; + ui.cam_status_8->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.cam_work_8->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); + ui.toolButton_cam_8->setStyleSheet(tr("border-image: url(:/Cigarette/Resources/cam8_no.png);")); + ui.label_reslut_8->setVisible(true); + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = { 12,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) SingleCamInfo[7].OffLine = false; + } + } + + //ȡϢ + if (m_PLCDevice->g_plc_ok) + { + if (!g_plc_dialog_open) //PLCöԻûд + { + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.alarm, 2, dest16); + if (ret>0) + { + AlarmInfo alarm_info; + alarm_info.alarm_code = dest16[0]; + if ((alarm_info.alarm_code > 0) && (alarm_info.alarm_code <= 12)) + { + alarm_info.alarm_msg = (g_alarm_msg[alarm_info.alarm_code]).toStdString(); + alarm_info.alarm_start = localTime.toStdString(); + ui.label_alarm->setText(g_alarm_msg[alarm_info.alarm_code]); + ui.label_alarm->setStyleSheet(tr("background-color: rgb(255, 0, 0);")); + if (g_last_alarm_code != alarm_info.alarm_code) + { + g_vec_alarm.push_back(alarm_info); + g_last_alarm_code = alarm_info.alarm_code; + + } + } + else if (alarm_info.alarm_code == 0) { + ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + ui.label_alarm->setText(QStringLiteral("ޱ")); + } + if (alarm_info.alarm_code == 7) { + ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + ui.label_alarm->setText(QStringLiteral("1#")); + //1# + ReconnectCamHub(0); + //־ + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = {0,0}; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + } + } + if (alarm_info.alarm_code == 8) { + ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + ui.label_alarm->setText(QStringLiteral("2#")); + //2# + ReconnectCamHub(1); + //־ + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = {0,0}; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + } + } +#ifdef __UDPSend + QString str; + str = QString("alarm") + '_' + QString::number(alarm_info.alarm_code); + sThread.sendData(str, g_sys_conf.FeedbackPort); +#endif + } + } + } + } +} +void Cigarette::on_pushButton_reset_released()///λť +{ + int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 1); + Sleep(1000); + if(g_modbus_conf.reset>0) + int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 0); +} +void Cigarette::OnCancelAlarm() //˫ +{ + emit sengMsgToClog("Cancel alarm mode."); + if (!g_admin_mode) + { + if (!g_op_mode) + { + dialogin = new Dialogin(this); + connect(dialogin, SIGNAL(enter_op()), this, SLOT(OnOp())); + dialogin->setModal(true); + dialogin->show(); + dialogin->move((this->width() - dialogin->width()) / 2, (this->height() - dialogin->height()) / 2); + return; + } + } + if (g_modbus_conf.alarm > 0) + { + uint16_t dest16[2] = {0,0}; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + if (ret > 0) + { + ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); + ui.label_alarm->setText(QStringLiteral("ޱ")); + QDateTime ts_start = QDateTime::currentDateTime(); + QDateTime local(ts_start); + QString localTime = local.toString("yyyy-MM-dd hh:mm:ss"); + int n = g_vec_alarm.size(); + if (n>0) + { + g_vec_alarm[n - 1].alarm_handle = localTime.toStdString(); + } +#ifdef __UDPSend + QString str; + str = QString("alarm") + '_' + QString::number(0); + sThread.sendData(str, g_sys_conf.FeedbackPort); +#endif + } + } + g_op_time = OP_TIME; +} +void Cigarette::on_toolButton_alarm_released() +{ + emit sengMsgToClog("Open alarm dialog."); + if (!g_admin_mode) + { + if (!g_op_mode) + { + emit sengMsgToClog("Start to login in."); + dialogin = new Dialogin(this); + connect(dialogin, SIGNAL(enter_op()), this, SLOT(OnOp())); + dialogin->setModal(true); + dialogin->show(); + dialogin->move((this->width() - dialogin->width()) / 2, (this->height() - dialogin->height()) / 2); + return; + } + } + AlarmDialog *alarm_dialog = new AlarmDialog(this); + alarm_dialog->setModal(true); + alarm_dialog->show(); + alarm_dialog->move((this->width() - alarm_dialog->width()) / 2, (this->height() - alarm_dialog->height()) / 2); + g_op_time = OP_TIME; +} +void Cigarette::on_pushButton_clear_released()// +{ + emit sengMsgToClog("Change shift."); + if (!g_admin_mode) + { + if (!g_op_mode) + { + dialogin = new Dialogin(this); + connect(dialogin, SIGNAL(enter_op()), this, SLOT(OnOp())); + dialogin->setModal(true); + dialogin->show(); + dialogin->move((this->width() - dialogin->width()) / 2, (this->height() - dialogin->height()) / 2); + return; + } + } + if(g_working) + { + QMessageBox::information(NULL, QStringLiteral("״̬"), QStringLiteral("ȵͣťͣģʽſԽл"), QMessageBox::Ok); + return; + } + ui.pushButton_clear->setEnabled(false); + m_delay->setSingleShot(true); + m_delay->start(5000); + Sleep(500); + for(int i=0;idisplay(production_number[i]); + ok[i] = 0; + lcdNumber_ok_mat[i]->display(ok[i]); + ng[i] = 0; + lcdNumber_ng_mat[i]->display(ng[i]); + + _UDPSendInfo UDPSendInfo; + UDPSendInfo.index = i; + + UDPSendInfo.FrameID = ok_frame; + UDPSendInfo.ok = ok[i]; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + UDPSendInfo.FrameID = ng_frame; + UDPSendInfo.ok = ng[i]; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + UDPSendInfo.FrameID = info_frame; + UDPSendInfo.timecost = QString::number(0); + UDPSendInfo.JD = QString("0,0,0"); +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + UDPSendInfo.FrameID = total_frame; + UDPSendInfo.Total = 0; +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + } + ui.lcdNumber_total_no->display(0); +#ifdef __UDPSend + sThread.sendData("total_" + QString::number(0), g_sys_conf.FeedbackPort); +#endif + //ͨPLCȡʾϰ + if (m_PLCDevice->g_plc_ok) + { + if (!g_plc_dialog_open) //PLCöԻûд + { + if (g_modbus_conf.quantity > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16); + std::cout << ret << std::endl; + if (ret > 0) + { + int cur_quantity = dest16[0] + (dest16[1] << 16); + ui.lcdNumber_total_no_last->display(cur_quantity); +#ifdef __UDPSend + sThread.sendData("totallast_" + QString::number(cur_quantity), g_sys_conf.FeedbackPort); +#endif + } + } + //ͻϢPLC + if (g_modbus_conf.shift > 0) + { + int ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.shift, 1); + if (g_modbus_conf.alarm >0)///ַalarmӦPLCַ + { + uint16_t dest16[2] = { 0,0 }; + int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); + } + } + } + } + g_op_time = OP_TIME; +} + +void Cigarette::on_pushButton_Clear_Pic_released() +{ + emit sengMsgToClog("Clean images."); + CleanThreadStart(); +} + +void Cigarette::FindFileForDelete(const QString& path) +{ + QDir dir(path); + QFileInfoList list; + QFileInfo curFile; + if (!dir.exists()) { return; }//ļ棬򷵻false + dir.setFilter(QDir::Dirs | QDir::Files); + list = dir.entryInfoList(QDir::Dirs | QDir::Files + | QDir::Readable | QDir::Writable + | QDir::Hidden | QDir::NoDotAndDotDot + , QDir::Time); + if (list.isEmpty()) { return; }//ļΪգ򷵻false + int i = list.size() - 1; + QDateTime delDateTime; + QDate delDate; + do { + QFileInfo fileInfo = list.at(i); + while (fileInfo.fileName() == "." || fileInfo.fileName() == ".." && i >= 0) + { + i--; + } + if (i < 0) { + break; + } + bool bisDir = fileInfo.isDir(); + if (bisDir) + { + QRegExp rx("\\d{4}-\\d{2}-\\d{2}"); + QRegExpValidator v(rx, 0); + int pos = 0; + int match; + match = v.validate(fileInfo.fileName(), pos); + if (match == 2) + { + QString qstrSubFilePath = fileInfo.absoluteFilePath(); + QDir qdrSubPath(qstrSubFilePath); + qdrSubPath.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden); + QFileInfoList qlstFileInfo = qdrSubPath.entryInfoList(); + if (qlstFileInfo.count() <= 0) + { + qdrSubPath.rmdir(qstrSubFilePath); + i--; + list = dir.entryInfoList(QDir::Dirs | QDir::Files + | QDir::Readable | QDir::Writable + | QDir::Hidden | QDir::NoDotAndDotDot + , QDir::Time); + if (list.isEmpty()) { return; }//ļΪգ򷵻false + int i = list.size() - 1; + continue; + } + if (i == (list.size() - 1)) { + delDate = QDate::currentDate().addDays(-60); + } + + // QDate delDate = QDate::currentDate().addDays(-60); + QDate dirDate; + dirDate = QDate::fromString(fileInfo.fileName(), "yyyy-MM-dd"); + qint64 nDays = delDate.daysTo(dirDate); + if (nDays <= 0) + { + qdrSubPath.removeRecursively(); + i--; + list = dir.entryInfoList(QDir::Dirs | QDir::Files + | QDir::Readable | QDir::Writable + | QDir::Hidden | QDir::NoDotAndDotDot + , QDir::Time); + if (list.isEmpty()) { return; }//ļΪգ򷵻false + int i = list.size() - 1; + continue; + } + i--; + continue; + } + FindFileForDelete(fileInfo.filePath()); + i--; + } + else { + if (2) //g_sys_conf.save == + { + // ļжļ ĿǰĬ60졣 + if (i == (list.size() - 1)) { + delDateTime = fileInfo.birthTime().addDays(60); + } + qint64 nDays = delDateTime.daysTo(fileInfo.birthTime()); + nDays = fileInfo.birthTime().daysTo(delDateTime); + if (nDays <= 0) + { + // ɾ60ļ + fileInfo.dir().remove(fileInfo.fileName()); + } + } + i--; + } + } while (i >= 0); +} + +void Cigarette::autoCleanImage() +{ + int64 size; + QString iDriver = "D:/"; + LPCWSTR strDriver = (LPCWSTR)iDriver.utf16(); + ULARGE_INTEGER freeDiskSpaceAvailable, totalDiskSpace, totalFreeDiskSpace; + int64 gb = (1024 * 1024 * 1024); + + //úȡ̲(λΪֽByte),תΪGBҪ(1024*1024*1024) + GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace); + size = (quint64)totalFreeDiskSpace.QuadPart / gb; + + if (size < 10) { //ʣռС10g + QString dir("D:/image/"); + FindFileForDelete(dir); + } + +} + +//ȡϵͳԱ +QString Cigarette::read_pswd() +{ + std::fstream cfg_file; + cfg_file.open("pswd.txt"); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file pswd.txt"<< std::endl; + return "81dc9bdb52d04dc20036dbd8313ed055"; + } + if (!cfg_file.eof()) + { + char tmp[256]; + memset(tmp, 0, 256); + cfg_file.getline(tmp, 256); + QString pswd = QString(QLatin1String(tmp)); + if (pswd.length() > 0) + { + return pswd; + } + else + { + return "81dc9bdb52d04dc20036dbd8313ed055"; + } + } + else + { + return "81dc9bdb52d04dc20036dbd8313ed055"; + } + cfg_file.close(); +} + +//ȡϵͳԱ +QString Cigarette::read_op_pswd() +{ + std::fstream cfg_file; + cfg_file.open("pswd_op.txt"); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file pswd_op.txt" << std::endl; + return "81dc9bdb52d04dc20036dbd8313ed055"; + } + if (!cfg_file.eof()) + { + char tmp[256]; + memset(tmp, 0, 256); + cfg_file.getline(tmp, 256); + QString pswd = QString(QLatin1String(tmp)); + if (pswd.length() > 0) + { + return pswd; + } + else + { + return "81dc9bdb52d04dc20036dbd8313ed055"; + } + } + else + { + return "81dc9bdb52d04dc20036dbd8313ed055"; + } + cfg_file.close(); +} + +bool Cigarette::read_sys_config(SysConf &conf) +{ + std::fstream cfg_file; + cfg_file.open(CONFIGURE_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file " << CONFIGURE_FILE << std::endl; + return false; + } + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + std::string line(tmp); + if (line.length() > 0) + { + /// atoiֵsubstrӴc_str()ַָ׵ַ + size_t pos = line.find('='); + std::string tmp_key = line.substr(0, pos); + + if (tmp_key == "SAVE") + { /// ͼã0棻1NG2ȫ + conf.save = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "MISMATCHACT") + { /// λΪ1NG0OK + conf.MisMatchAct = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "SAVE_DAYS") + { /// Ƭ + conf.save_days = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FREESIZE") { + /// ͼƬ趨Сռֵ + conf.freesize = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "AUTO_OPEN") + { /// ǷԶ01 + conf.auto_open = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "AUTO_WORK") + { /// ǷԶʼ01 + conf.auto_work = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "AUTO_SHIFT") + { /// ǷԶࣺ01 + conf.auto_shift = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "TIMING_SHIFT") + { /// Ƿʱࣺ01 + conf.timing_shift = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "SHIFT_A") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 2) + { + conf.shiftA.setHMS(atoi(vec_info[0].c_str())%24, atoi(vec_info[1].c_str()), 0);/// + } + } + else if (tmp_key == "SHIFT_B") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 2) + { + conf.shiftB.setHMS(atoi(vec_info[0].c_str())%24, atoi(vec_info[1].c_str()), 0);/// + } + } + else if (tmp_key == "SHIFT_C") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 2) + { + conf.shiftC.setHMS(atoi(vec_info[0].c_str())%24, atoi(vec_info[1].c_str()), 0);/// + } + } + else if (tmp_key == "LOCATION") + { + conf.location = line.substr(pos + 1).c_str(); + } + else if (tmp_key == "MODELPATH") + { + conf.path = line.substr(pos + 1).c_str(); + } +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + else if (tmp_key == "EXPO1") + { + conf.expo[0] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN1") + { + conf.gain[0] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER1") + { + conf.filter[0] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID1") + { + conf.UserID[0] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO1") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 3) + { + conf.no[0][0] = atoi(vec_info[0].c_str()); + conf.no[0][1] = atoi(vec_info[1].c_str()); + conf.no[0][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT1") + { + conf.shoot[0] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + else if (tmp_key == "EXPO2") + { + conf.expo[1] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN2") + { + conf.gain[1] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER2") + { + conf.filter[1] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID2") + { + conf.UserID[1] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO2") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 3) + { + conf.no[1][0] = atoi(vec_info[0].c_str()); + conf.no[1][1] = atoi(vec_info[1].c_str()); + conf.no[1][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT2") + { + conf.shoot[1] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + else if (tmp_key == "EXPO3") + { + conf.expo[2] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN3") + { + conf.gain[2] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER3") + { + conf.filter[2] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID3") + { + conf.UserID[2] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO3") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 3) + { + conf.no[2][0] = atoi(vec_info[0].c_str()); + conf.no[2][1] = atoi(vec_info[1].c_str()); + conf.no[2][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT3") + { + conf.shoot[2] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + else if (tmp_key == "EXPO4") + { + conf.expo[3] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN4") + { + conf.gain[3] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER4") + { + conf.filter[3] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID4") + { + conf.UserID[3] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO4") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|",vec_info); + if (vec_info.size() == 3) + { + conf.no[3][0] = atoi(vec_info[0].c_str()); + conf.no[3][1] = atoi(vec_info[1].c_str()); + conf.no[3][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT4") + { + conf.shoot[3] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + else if (tmp_key == "EXPO5") + { + conf.expo[4] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN5") + { + conf.gain[4] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER5") + { + conf.filter[4] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID5") + { + conf.UserID[4] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO5") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|", vec_info); + if (vec_info.size() == 3) + { + conf.no[4][0] = atoi(vec_info[0].c_str()); + conf.no[4][1] = atoi(vec_info[1].c_str()); + conf.no[4][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT5") + { + conf.shoot[4] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + else if (tmp_key == "EXPO6") + { + conf.expo[5] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN6") + { + conf.gain[5] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER6") + { + conf.filter[5] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID6") + { + conf.UserID[5] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO6") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|", vec_info); + if (vec_info.size() == 3) + { + conf.no[5][0] = atoi(vec_info[0].c_str()); + conf.no[5][1] = atoi(vec_info[1].c_str()); + conf.no[5][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT6") + { + conf.shoot[5] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + else if (tmp_key == "EXPO7") + { + conf.expo[6] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN7") + { + conf.gain[6] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER7") + { + conf.filter[6] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID7") + { + conf.UserID[6] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO7") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|", vec_info); + if (vec_info.size() == 3) + { + conf.no[6][0] = atoi(vec_info[0].c_str()); + conf.no[6][1] = atoi(vec_info[1].c_str()); + conf.no[6][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT7") + { + conf.shoot[6] = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + else if (tmp_key == "EXPO8") + { + conf.expo[7] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "GAIN8") + { + conf.gain[7] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "FILTER8") + { + conf.filter[7] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "USERID8") + { + conf.UserID[7] = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO8") + { + std::vector vec_info; + string_split(line.substr(pos + 1), "|", vec_info); + if (vec_info.size() == 3) + { + conf.no[7][0] = atoi(vec_info[0].c_str()); + conf.no[7][1] = atoi(vec_info[1].c_str()); + conf.no[7][2] = atoi(vec_info[2].c_str()); + } + } + else if (tmp_key == "SHOOT8") + { + conf.shoot[7] = atoi(line.substr(pos + 1).c_str()); + } +#endif + else if (tmp_key == "MonitorIP") + { + conf.MonitorIP = line.substr(pos + 1); + } + else if (tmp_key == "MonitorPort") + { + conf.MonitorPort = atoi(line.substr(pos + 1).c_str()); + conf.FeedbackPort = conf.MonitorPort + NumberOfSupportedCameras*2; + conf.FilePort = conf.MonitorPort + NumberOfSupportedCameras*2+2; + } + } + } + cfg_file.close(); + return true; +} + +bool Cigarette::read_modbus_config(ModbusConf &conf) +{ + std::fstream cfg_file; + cfg_file.open(MODBUS_CONFIGURE_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file " << MODBUS_CONFIGURE_FILE << std::endl; + return false; + } + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + std::string line(tmp); + if (line.length() > 0) + { + size_t pos = line.find('='); + std::string tmp_key = line.substr(0, pos); + if (tmp_key == "QUANTITY") + { + conf.quantity = atoi(line.substr(pos + 1).c_str()); + } +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + else if (tmp_key == "KICK1") + { + conf.kick1 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + else if (tmp_key == "KICK2") + { + conf.kick2 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + else if (tmp_key == "KICK3") + { + conf.kick3 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + else if (tmp_key == "KICK4") + { + conf.kick4 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + else if (tmp_key == "KICK5") + { + conf.kick5 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + else if (tmp_key == "KICK6") + { + conf.kick6 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + else if (tmp_key == "KICK7") + { + conf.kick7 = atoi(line.substr(pos + 1).c_str()); + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + else if (tmp_key == "KICK8") + { + conf.kick8 = atoi(line.substr(pos + 1).c_str()); + } +#endif + else if (tmp_key == "QUANTITY") + { + conf.quantity = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "SHIFT") + { + conf.shift = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "WORK") + { + conf.work = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "NO_KICK") + { + conf.no_kick = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "DEBUG") + { + conf.debug = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "RESET") + { + conf.reset = atoi(line.substr(pos + 1).c_str()); + } + else if (tmp_key == "ALARM") + { + conf.alarm = atoi(line.substr(pos + 1).c_str()); + } + } + } + cfg_file.close(); + return true; +} + +//ȡͼת +bool Cigarette::read_rotate_message() +{ + std::fstream cfg_file; + cfg_file.open(ROTATE_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file rotate.txt" << std::endl; + return false; + } + if (!cfg_file.eof()) + { + char tmp[256]; + memset(tmp, 0, 256); + cfg_file.getline(tmp, 256); + QStringList rotate_message = QString(QLatin1String(tmp)).split(","); + if (rotate_message.length() > NumberOfSupportedCameras*2) + { + for (int i = 0; i < NumberOfSupportedCameras; i++) { + isNeddRotate[i] = rotate_message[i * 2].toInt(); + rotationAngle[i] = rotate_message[i * 2 + 1].toInt(); + } + } + else + { + return false; + } + } + else + { + return false; + } + cfg_file.close(); + return true; +} + +//ͼת +bool Cigarette::save_rotate_message() +{ + std::fstream cfg_file; + cfg_file.open(ROTATE_FILE, ios::trunc | ofstream::out); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file rotate.txt" << std::endl; + return false; + } + for (int i = 0; i < NumberOfSupportedCameras; i++) { + char tmp[8]; + memset(tmp, 0, 8); + itoa(isNeddRotate[i], tmp, 10); + cfg_file.write(tmp, 1); + cfg_file.write(",", 1); + memset(tmp, 0, 8); + itoa(rotationAngle[i], tmp, 10); + cfg_file.write(tmp, 1); + cfg_file.write(",", 1); + } + cfg_file.close(); + return true; +} + +//汨Ϣ +bool Cigarette::save_alarm_message(std::vector &AlarmInfo_vect) +{ + std::fstream cfg_file; + cfg_file.open(ALARM_RECORD_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file alarm.txt" << std::endl; + return false; + } + + for (int i = 0; i < AlarmInfo_vect.size(); i++) { + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, "%s_%s_%s_%d\n", AlarmInfo_vect[i].alarm_start, AlarmInfo_vect[i].alarm_handle, AlarmInfo_vect[i].alarm_msg, AlarmInfo_vect[i].alarm_code); + cfg_file.write(buf, strlen(buf)); + } + cfg_file.close(); + return true; +} + +QImage Cigarette::cvMatToQImage(const cv::Mat& mat) +{ + const unsigned char* data = mat.data; + int width = mat.cols; + int height = mat.rows; + int bytesPerLine = static_cast(mat.step); + switch (mat.type()) + { + // 8bit, ARGB + case CV_8UC4: + { + QImage image(data, width, height, bytesPerLine, + QImage::Format_ARGB32); + return image; + } + // 8bit, BGR + case CV_8UC3: + { + QImage image(data, width, height, bytesPerLine, + QImage::Format_RGB888); + //swap blue and red channel + return image.rgbSwapped(); + } + // 8bit, Grayshale + case CV_8UC1: + { + QImage image(data, width, height, bytesPerLine, + QImage::Format_Grayscale8); + return image; + } + default: + { + return QImage(); + } + } +} + +void Cigarette::read_plc_items() +{ + std::fstream cfg_file; + cfg_file.open(PLC_CONFIG_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open production file " << PLC_CONFIG_FILE << std::endl; + return; + } + while (!cfg_file.eof()) + { + char tmp[1024] = ""; + cfg_file.getline(tmp, 1024); + std::string line(tmp); + //std::cout << line << std::endl; + if (line.length() > 0) + { + std::vector vec_info; + string_split(line, "|",vec_info); + if (vec_info.size() == 4) + { + PlcItem plc_item; + plc_item.func_desc = vec_info[0]; + plc_item.address = atoi(vec_info[1].c_str()); + plc_item.value = atoi(vec_info[2].c_str()); + plc_item.memo = vec_info[3]; + m_plc_items.push_back(plc_item); + } + } + } + cfg_file.close(); +} + +void Cigarette::init_plc_value() +{ + for (int i = 0; i < m_plc_items.size(); i++) + { + int addr = m_plc_items[i].address; + int data = m_plc_items[i].value; + if (addr > 0) + { + uint8_t dest[4]; + uint16_t * dest16 = (uint16_t *)dest; + memset(dest, 0, 4); + if (addr > 0) + { + if (addr < 40000) //дȦֵ bit + { + if (data != 0) data = 1; + m_PLCDevice->write_bit_2_plc( addr, data); + } + else { //дDWORDֵ4ֽ + dest16[0] = (data & 0xffff); + dest16[1] = (data >> 16); + m_PLCDevice->write_short_2_plc(addr, 2, dest16); + } + } + } + } +} + +void Cigarette::CreatWorkThread(int classid,int Num,Cigarette* classptr) +{ + work_thread[Num].init(g_image_queue[Num],g_result_queue[Num],classid,Num); + connect(&work_thread[Num], SIGNAL(notify(int,int,cv::Mat)), classptr, SLOT(OnNotifyHub(int,int,cv::Mat))); + connect(&work_thread[Num], SIGNAL(display_timecost(int,int)), classptr, SLOT(OnDisplayTimeCostHub(int,int))); + connect(&work_thread[Num], SIGNAL(display_check_total(int,long)), classptr, SLOT(OnDisplayCheckNumberHub(int,long))); + connect(&work_thread[Num], SIGNAL(display_jd_no(int,QString)), classptr, SLOT(OnDisplayJdNoHub(int,QString))); + connect(&work_thread[Num], SIGNAL(event_ok(int)), classptr, SLOT(OnOKHub(int))); + connect(&work_thread[Num], SIGNAL(event_ng(int)), classptr, SLOT(OnNGHub(int))); + work_thread[Num].start_work(); + debug_thread[Num].init(g_debug_queue[Num],Num); + connect(&debug_thread[Num], SIGNAL(notify(int,int,cv::Mat)), classptr, SLOT(OnNotifyHub(int,int,cv::Mat))); + debug_thread[Num].start_work(); +} + +#define InitPtrMat_init(a,b)\ +cam_status_mat[a]=ui.cam_status_##b;\ +cam_work_mat[a]=ui.cam_work_##b;\ +cam_toolButton_mat[a]=ui.toolButton_cam_##b;\ +label_cap_speed_mat[a]=ui.label_cap_speed_##b;\ +display_lable_mat[a][0]=ui.image_label_##b##1;\ +display_lable_mat[a][1]=ui.image_label_##b##2;\ +label_timecost_mat[a]=ui.label_timecost_##b;\ +lcdNumber_total_mat[a]=ui.lcdNumber_total_##b;\ +label_jd_no_mat[a]=ui.label_jd_no_##b;\ +lcdNumber_ok_mat[a]=ui.lcdNumber_ok_##b;\ +lcdNumber_ng_mat[a]=ui.lcdNumber_ng_##b;\ +label_reslut_mat[a]=ui.label_reslut_##b;\ +rotate_mat[a]=ui.rotate_##b;\ +label_ng_mat[a]=ui.label_ng_##b; +void Cigarette::InitPtrMat() +{ +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + InitPtrMat_init(0,1) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + InitPtrMat_init(1,2) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + InitPtrMat_init(2,3) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + InitPtrMat_init(3,4) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + InitPtrMat_init(4,5) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + InitPtrMat_init(5,6) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + InitPtrMat_init(6,7) +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + InitPtrMat_init(7,8) +#endif + for(int i=0;igeometry().x(); + display_lable_info[i][j].y = display_lable_mat[i][j]->geometry().y(); + display_lable_info[i][j].width = display_lable_mat[i][j]->geometry().width(); + display_lable_info[i][j].height = display_lable_mat[i][j]->geometry().height(); + } + rotate_info[i].x = rotate_mat[i]->geometry().x(); + rotate_info[i].y = rotate_mat[i]->geometry().y(); + rotate_info[i].width = rotate_mat[i]->geometry().width(); + rotate_info[i].height = rotate_mat[i]->geometry().height(); + } + +} + +bool Cigarette::ControlCamOpenOrClose(int Num,bool OpenOrClose) +{ + if(OpenOrClose == OPEN && !SingleCamInfo[Num].IsOpen) + { + if (SingleCamInfo[Num].CamClass == BalluffClassID) + { + qDebug() << "open for balluff"; + try + { + Device* pDev = BalluffCamera::devMgr[SingleCamInfo[Num].unfiltered_num]; + conditionalSetProperty(pDev->interfaceLayout, dilGenICam); + pDev->open(); + // Configure timer1 + mvIMPACT::acquire::GenICam::CounterAndTimerControl mvCATC(pDev); + mvCATC.timerSelector.writeS("Timer1"); + mvCATC.timerTriggerSource.writeS("UserOutput0"); + mvCATC.timerDuration.write(StrobeLineTime); + mvCATC.timerTriggerActivation.writeS("AnyEdge"); + // Configure timer2 + mvCATC.timerSelector.writeS("Timer2"); + mvCATC.timerTriggerSource.writeS("UserOutput1"); + mvCATC.timerDuration.write(StrobeLineTime); + mvCATC.timerTriggerActivation.writeS("AnyEdge"); + + //Configure output1 + mvIMPACT::acquire::GenICam::DigitalIOControl mvDIOC(pDev); + mvDIOC.lineSelector.writeS("Line0"); + mvDIOC.lineSource.writeS("Timer1Active"); + //Configure output2 + mvDIOC.lineSelector.writeS("Line1"); + mvDIOC.lineSource.writeS("Timer2Active"); + + //˲ + mvDIOC.lineSelector.writeS("Line4"); + mvDIOC.mvLineDebounceTimeRisingEdge.write(g_sys_conf.filter[Num]); + //˲ + mvDIOC.lineSelector.writeS("Line5"); + mvDIOC.mvLineDebounceTimeRisingEdge.write(g_sys_conf.filter[Num]); + //binning + mvIMPACT::acquire::GenICam::ImageFormatControl ifc = mvIMPACT::acquire::GenICam::ImageFormatControl(pDev); + ifc.binningHorizontalMode.writeS("Sum"); + ifc.binningHorizontal.write(2); + ifc.binningVerticalMode.writeS("Sum"); + ifc.binningVertical.write(2); + + pFI[Num] = new FunctionInterface(pDev); + if (pDev->interfaceLayout.isValid() && (pDev->interfaceLayout.read() == dilGenICam)) + { + pAC[Num] = new mvIMPACT::acquire::GenICam::AcquisitionControl(pDev); + //ⴥ + pAC[Num]->triggerMode.writeS("On"); + pAC[Num]->triggerSource.writeS("Line4"); + pAC[Num]->triggerActivation.writeS("RisingEdge"); + //عʱ + pAC[Num]->exposureTime.writeS(QString::number(g_sys_conf.expo[Num]).toStdString()); + // + mvIMPACT::acquire::GenICam::AnalogControl *pac = new mvIMPACT::acquire::GenICam::AnalogControl(pDev); + pac->gain.write(g_sys_conf.gain[Num]); + } + pCaptureThread[Num] = new CaptureThread(BalluffCamera::devMgr[SingleCamInfo[Num].unfiltered_num], false, pFI[Num],Num); + + pCaptureThread[Num]->p_image_queue = g_image_queue[Num]; + pCaptureThread[Num]->p_result_queue = g_result_queue[Num]; + pCaptureThread[Num]->p_result_wait_queue = g_result_wait_queue[Num]; + pCaptureThread[Num]->p_double_queue = g_double_queue[Num]; + pCaptureThread[Num]->p_shooted_queue = g_shooted_queue[Num]; + + pCaptureThread[Num]->p_debug_queue = g_debug_queue[Num]; + + pThread[Num] = new QThread; + pCaptureThread[Num]->moveToThread(pThread[Num]); + + // Signal emitted in case of acquisition errors + connect(pThread[Num], SIGNAL(started()), pCaptureThread[Num], SLOT(process())); + //connect(pCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString))); + connect(pCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit())); + connect(pCaptureThread[Num], SIGNAL(finished()), pCaptureThread[Num], SLOT(deleteLater())); + connect(pCaptureThread[Num], SIGNAL(updateStatistics(const QString&,int)), this, SLOT(updateStatisticsHub(const QString&,int))); + + pThread[Num]->start(); + if (pThread[Num]->isRunning()) + { + qDebug() << "balluff pThread OK"; + SingleCamInfo[Num].IsOpen =true; + return true; + } + } + catch (const ImpactAcquireException& e) + { + QString msg; + QTextStream(&msg) << "Error while opening device! Error message: " << QString::fromStdString(e.getErrorCodeAsString()) << "\nError Code: " << e.getErrorCode(); + QMessageBox::warning(this, "Error", msg, QMessageBox::Ok, QMessageBox::Ok); + } + return false; + } + else if (SingleCamInfo[Num].CamClass == BaslerClassID) + { + qDebug() << "open for basler"; + try + { + Pylon::CBaslerUniversalInstantCamera *baslerCamera = new Pylon::CBaslerUniversalInstantCamera(Pylon::CTlFactory::GetInstance().CreateDevice(BaslerCamera::devices[SingleCamInfo[Num].filtered_num])); + BaslerCamHandle[Num]=baslerCamera; + + // Camera event processing must be activated first, the default is off. + baslerCamera->GrabCameraEvents = true; + + baslerCamera->Open(); + baslerCamera->LineSelector.SetValue(Basler_UniversalCameraParams::LineSelector_Line1); + if (!baslerCamera->LineDebouncerTime.TrySetValue(g_sys_conf.filter[Num]/1.0)) + { + std::cout << "can not set LineDebouncerTime" << std::endl; + if(!baslerCamera->BslInputFilterTime.TrySetValue(g_sys_conf.filter[Num]/1.0)) + std::cout << "can not set BslInputFilterTime" << std::endl; + } + baslerCamera->LineSelector.SetValue(Basler_UniversalCameraParams::LineSelector_Line3); + baslerCamera->LineMode.SetValue(Basler_UniversalCameraParams::LineMode_Input); + if (!baslerCamera->LineDebouncerTime.TrySetValue(g_sys_conf.filter[Num]/1.0)) + { + std::cout << "can not set LineDebouncerTime" << std::endl; + if (!baslerCamera->BslInputFilterTime.TrySetValue(g_sys_conf.filter[Num]/1.0)) + std::cout << "can not set BslInputFilterTime" << std::endl; + } + if (baslerCamera->LineSelector.TrySetValue(Basler_UniversalCameraParams::LineSelector_Line4)) + { + baslerCamera->LineMode.SetValue(Basler_UniversalCameraParams::LineMode_Output); +#ifdef USB_BASLER_NEW_FW + GENAPI_NAMESPACE::INodeMap& nodemap = baslerCamera->GetNodeMap(); + Pylon::CFloatParameter(nodemap, "UserOutputDuration").SetValue(StrobeLineTime); +#endif + if (baslerCamera->LineSource.TrySetValue(Basler_UniversalCameraParams::LineSource_UserOutput3)) + { + baslerCamera->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput3); + baslerCamera->UserOutputValue.SetValue(false); + } + else + { + std::cout << "can not set LineSource_UserOutput3" << std::endl; + } + } + else + { + std::cout << "can not set LineSelector_Line4" << std::endl; + } + + baslerCamera->LineSelector.SetValue(Basler_UniversalCameraParams::LineSelector_Line2); +#ifdef USB_BASLER_NEW_FW + GENAPI_NAMESPACE::INodeMap& nodemap = baslerCamera->GetNodeMap(); + Pylon::CFloatParameter(nodemap, "UserOutputDuration").SetValue(StrobeLineTime); +#endif + if (baslerCamera->LineSource.TrySetValue(Basler_UniversalCameraParams::LineSource_UserOutput1)) + { + baslerCamera->UserOutputSelector.SetValue(Basler_UniversalCameraParams::UserOutputSelector_UserOutput1); + baslerCamera->UserOutputValue.SetValue(false); + } + else + { + std::cout << "can not set LineSource_UserOutput1" << std::endl; + } + + baslerCamera->ExposureAuto.SetValue(Basler_UniversalCameraParams::ExposureAuto_Off); + baslerCamera->ExposureMode.SetValue(Basler_UniversalCameraParams::ExposureMode_Timed); + baslerCamera->ExposureTime.SetValue(g_sys_conf.expo[Num]); + + baslerCamera->GainSelector.SetValue(Basler_UniversalCameraParams::GainSelector_All); + baslerCamera->GainAuto.SetValue(Basler_UniversalCameraParams::GainAuto_Off); + baslerCamera->Gain.SetValue(g_sys_conf.gain[Num]); + + baslerCamera->TriggerSelector.SetValue(Basler_UniversalCameraParams::TriggerSelector_FrameStart); + baslerCamera->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_On); + baslerCamera->TriggerSource.SetValue(Basler_UniversalCameraParams::TriggerSource_Line3); + baslerCamera->TriggerActivation.SetValue(Basler_UniversalCameraParams::TriggerActivation_RisingEdge); + + baslerCamera->BinningHorizontal.SetValue(2); + baslerCamera->BinningVertical.SetValue(2); + + pBaslerCaptureThread[Num] = new CaptureThreadBasler(baslerCamera, false, Num,g_sys_conf.shoot[Num]); + + pBaslerCaptureThread[Num]->p_image_queue = g_image_queue[Num]; + pBaslerCaptureThread[Num]->p_result_queue = g_result_queue[Num]; + pBaslerCaptureThread[Num]->p_result_wait_queue = g_result_wait_queue[Num]; + pBaslerCaptureThread[Num]->p_double_queue = g_double_queue[Num]; + pBaslerCaptureThread[Num]->p_shooted_queue = g_shooted_queue[Num]; + + pBaslerCaptureThread[Num]->p_debug_queue = g_debug_queue[Num]; + + pThread[Num] = new QThread; + pBaslerCaptureThread[Num]->moveToThread(pThread[Num]); + + // Signal emitted in case of acquisition errors + connect(pThread[Num], SIGNAL(started()), pBaslerCaptureThread[Num], SLOT(process())); + //connect(pBaslerCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString))); + connect(pBaslerCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit())); + connect(pBaslerCaptureThread[Num], SIGNAL(finished()), pBaslerCaptureThread[Num], SLOT(deleteLater())); + connect(pBaslerCaptureThread[Num], SIGNAL(updateStatistics(const QString&, int)), this, SLOT(updateStatisticsHub(const QString&, int))); + + pThread[Num]->start(); + if (pThread[Num]->isRunning()) + { + qDebug() << "basler pThread OK"; + SingleCamInfo[Num].IsOpen = true; + return true; + } + } + catch (const Pylon::GenericException& e) + { + QString msg; + QTextStream(&msg) << "Error while opening device! Error message: " << QString::fromStdString(e.GetDescription()) << "\nError" ; + QMessageBox::warning(this, "Error", msg, QMessageBox::Ok, QMessageBox::Ok); + } + return false; + } + else if (SingleCamInfo[Num].CamClass == HIKClassID) + { + qDebug() << "open for hik"; + int nRet = MV_OK; + void *camhandle; + nRet = MV_CC_CreateHandle(&camhandle, HIKCamera::stDeviceList.pDeviceInfo[SingleCamInfo[Num].unfiltered_num]); + HIKCamHandle[Num]=camhandle; + nRet = MV_CC_OpenDevice(camhandle); + if (nRet) + { + MV_CC_CloseDevice(camhandle); + if (MV_CC_OpenDevice(camhandle)) + { + qDebug() << "Failed to open camera"; + return false; + } + } + if (HIKCamera::stDeviceList.pDeviceInfo[SingleCamInfo[Num].unfiltered_num]->nTLayerType == MV_GIGE_DEVICE) + { + int nPacketSize = MV_CC_GetOptimalPacketSize(camhandle); + if (nPacketSize > 0) + { + int nRet = MV_CC_SetIntValue(camhandle, "GevSCPSPacketSize", nPacketSize); + if (nRet != MV_OK) + { + //printf("Warning: Set Packet Size fail nRet [0x%x]!", nRet); + } + } + } + int nnRet = MV_OK; + nRet = MV_CC_SetEnumValue(camhandle, "LineSelector", 1); //0:Line0 1:Line1 2:Line2 + if (nRet) { std::cout << "can not set LineSelector" << std::endl; nnRet = nRet;} + + nRet = MV_CC_SetEnumValue(camhandle, "LineMode", 8); //0:Input 1:Output 2:Trigger 8:Strobe + if (nRet) { std::cout << "can not set LineMode" << std::endl; nnRet = nRet; } + + //0:ExposureStartActive 5:SoftTriggerActive 6:HardTriggerActive + nRet = MV_CC_SetEnumValue(camhandle, "LineSource", 5); + if (nRet) { std::cout << "can not set LineSource" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetBoolValue(camhandle, "StrobeEnable",TRUE); + if (nRet) { std::cout << "can not set StrobeEnable" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetIntValueEx(camhandle, "StrobeLineDuration", StrobeLineTime); + if (nRet) { std::cout << "can not set StrobeLineDuration" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "LineSelector", 0); + if (nRet) { std::cout << "can not set LineSelector" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetIntValueEx(camhandle, "LineDebouncerTime", g_sys_conf.filter[Num]); + if (nRet) { std::cout << "can not set LineDebouncerTime" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "LineSelector", 2); + if (nRet) { std::cout << "can not set LineSelector" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetIntValueEx(camhandle, "LineDebouncerTime", g_sys_conf.filter[Num]); + if (nRet) { std::cout << "can not set LineDebouncerTime" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "TriggerMode", MV_TRIGGER_MODE_ON); + if (nRet) { std::cout << "can not set TriggerMode" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "TriggerSource", MV_TRIGGER_SOURCE_LINE2); + if (nRet) { std::cout << "can not set TriggerSource" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "TriggerActivation", 1);//1ʾ½ + if (nRet) { std::cout << "can not set TriggerActivation" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "BinningHorizontal", 2);//binning + if (nRet) { std::cout << "can not set BinningHorizontal" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "BinningVertical", 2);//binning + if (nRet) { std::cout << "can not set BinningVertical" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "ExposureAuto", FALSE); + if (nRet) { std::cout << "can not set ExposureAuto" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "ExposureMode", 0);//timed + if (nRet) { std::cout << "can not set ExposureMode" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetFloatValue(camhandle, "ExposureTime", g_sys_conf.expo[Num]); + if (nRet) { std::cout << "can not set ExposureTime" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(camhandle, "GainAuto", FALSE); + if (nRet) { std::cout << "can not set GainAuto" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetFloatValue(camhandle, "Gain", g_sys_conf.gain[Num]); + if (nRet) { std::cout << "can not set Gain" << std::endl; nnRet = nRet; } + + pHIKCaptureThread[Num] = new CaptureThreadHIK(camhandle, false,Num); + + pHIKCaptureThread[Num]->p_image_queue = g_image_queue[Num]; + pHIKCaptureThread[Num]->p_result_queue = g_result_queue[Num]; + pHIKCaptureThread[Num]->p_debug_queue = g_debug_queue[Num]; + pHIKCaptureThread[Num]->p_result_wait_queue = g_result_wait_queue[Num]; + pHIKCaptureThread[Num]->p_double_queue = g_double_queue[Num]; + pHIKCaptureThread[Num]->p_shooted_queue = g_shooted_queue[Num]; + + pThread[Num] = new QThread; + pHIKCaptureThread[Num]->moveToThread(pThread[Num]); + + // Signal emitted in case of acquisition errors + connect(pThread[Num], SIGNAL(started()), pHIKCaptureThread[Num], SLOT(process())); + //connect(pHIKCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString))); + connect(pHIKCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit())); + connect(pHIKCaptureThread[Num], SIGNAL(finished()), pHIKCaptureThread[Num], SLOT(deleteLater())); + connect(pHIKCaptureThread[Num], SIGNAL(updateStatistics(const QString&,int)), this, SLOT(updateStatisticsHub(const QString&,int))); + pThread[Num]->start(); + if (pThread[Num]->isRunning()) + { + qDebug() << "hik pThread OK"; + SingleCamInfo[Num].IsOpen =true; + return true; + } + return false; + } + } + else if(OpenOrClose == CLOSE && SingleCamInfo[Num].IsOpen) + { + if (SingleCamInfo[Num].CamClass == BalluffClassID) + { + qDebug() << "close for balluff"; + disconnect(pThread[Num], SIGNAL(started()), pCaptureThread[Num], SLOT(process())); + //disconnect(pCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString))); + disconnect(pCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit())); + disconnect(pCaptureThread[Num], SIGNAL(finished()), pCaptureThread[Num], SLOT(deleteLater())); + disconnect(pCaptureThread[Num], SIGNAL(updateStatistics(const QString&,int)), this, SLOT(updateStatisticsHub(const QString&,int))); + if (pCaptureThread[Num]) + { + pCaptureThread[Num]->terminate(); + if (pThread[Num]) + { + pThread[Num]->quit(); + pThread[Num]->wait(); + } + } + Device* pDev = BalluffCamera::devMgr[SingleCamInfo[Num].unfiltered_num]; + if (pDev && pDev->isOpen()) + { + pDev->close(); + } + DeleteElement(pCaptureThread[Num]); + DeleteElement(pThread[Num]); + DeleteElement(pFI[Num]); + DeleteElement(pAC[Num]); + SingleCamInfo[Num].IsOpen = false; + return true; + } + else if (SingleCamInfo[Num].CamClass == BaslerClassID) + { + qDebug() << "close for basler"; + disconnect(pThread[Num], SIGNAL(started()), pBaslerCaptureThread[Num], SLOT(process())); + //disconnect(pBaslerCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString))); + disconnect(pBaslerCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit())); + disconnect(pBaslerCaptureThread[Num], SIGNAL(finished()), pBaslerCaptureThread[Num], SLOT(deleteLater())); + disconnect(pBaslerCaptureThread[Num], SIGNAL(updateStatistics(const QString&, int)), this, SLOT(updateStatisticsHub(const QString&, int))); + if (pBaslerCaptureThread[Num]) + { + pBaslerCaptureThread[Num]->terminate(); + if (pThread[Num]) + { + pThread[Num]->quit(); + pThread[Num]->wait(); + } + } + Pylon::CBaslerUniversalInstantCamera* baslerCamera = BaslerCamHandle[Num]; + if(baslerCamera && baslerCamera->IsOpen()) + { + baslerCamera->Close(); + baslerCamera->GrabCameraEvents = false; + } + DeleteElement(pBaslerCaptureThread[Num]); + DeleteElement(pThread[Num]); + SingleCamInfo[Num].IsOpen = false; + return true; + } + else if (SingleCamInfo[Num].CamClass == HIKClassID) + { + qDebug() << "close for hik"; + void* camhandle; + camhandle = pHIKCaptureThread[Num]->CamHandle; + disconnect(pThread[Num], SIGNAL(started()), pHIKCaptureThread[Num], SLOT(process())); + //disconnect(pCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString))); + disconnect(pHIKCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit())); + disconnect(pHIKCaptureThread[Num], SIGNAL(finished()), pHIKCaptureThread[Num], SLOT(deleteLater())); + disconnect(pHIKCaptureThread[Num], SIGNAL(updateStatistics(const QString&, int)), this, SLOT(updateStatisticsHub(const QString&, int))); + if (pHIKCaptureThread[Num]) + { + pHIKCaptureThread[Num]->terminate(); + if (pThread[Num]) + { + pThread[Num]->quit(); + pThread[Num]->wait(); + } + } + if (camhandle) + { + MV_CC_CloseDevice(camhandle); + MV_CC_DestroyHandle(camhandle); + } + DeleteElement(pHIKCaptureThread[Num]); + DeleteElement(pThread[Num]); + SingleCamInfo[Num].IsOpen = false; + return true; + } + } + return false; +} + +void Cigarette::EnumerateCameras(SingleCamInfoStruct *TempSingleCamInfoStruct,bool showinfo,SysConf &conf) +{ + std::vector TempSingleCamInfo; + //Щöʱ˱ijö + int basler_cnt = 0; + int filtered = 0; + filtered = BaslerCamera::Enumerate(); + Pylon::CInstantCameraArray cameras(filtered); + Pylon::CTlFactory& tlFactory = Pylon::CTlFactory::GetInstance(); + for (int i = 0; i < min(filtered, NumberOfSupportedCameras); i++) + { + SingleCamInfoStruct CamInfo; + //cameras[i].Attach(tlFactory.CreateDevice(BaslerCamera::devices[i])); + //Pylon::String_t selectedAction = ::GenICam::gcstring("Action"); + //std::string manufacture = cameras[i].GetDeviceInfo().GetVendorId(); + //if (!manufacture.compare(0, 6, "BASLER")) + //{ + // Print the UserDefined name of the camera. + //std::string UserID = cameras[i].GetDeviceInfo().GetUserDefinedName(); + Pylon::CBaslerUniversalInstantCamera* baslerCamera = new Pylon::CBaslerUniversalInstantCamera(tlFactory.CreateDevice(BaslerCamera::devices[i])); + baslerCamera->Open(); + std::string UserID = baslerCamera->DeviceUserID(); + baslerCamera->Close(); + delete baslerCamera; + if(showinfo)std::cout << "Basler user ID = " << UserID << std::endl; + CamInfo.UserID = atoi(UserID.c_str()); + CamInfo.CamClass = BaslerClassID; + CamInfo.filtered_num = i; + CamInfo.Detect = false; + CamInfo.IsOpen = false; + CamInfo.OffLine = false; + TempSingleCamInfo.push_back(CamInfo); + basler_cnt++; + //} + } + + //ЩԻö٣EnumerateҪִʼһЩȫϢ + int hik_cnt = 0; + int unfiltered = 0; + unfiltered = HIKCamera::Enumerate(); + for (int i = 0; i < min(unfiltered, NumberOfSupportedCameras); i++) + { + MV_CC_DEVICE_INFO* pDeviceInfo = HIKCamera::stDeviceList.pDeviceInfo[i]; + std::string manufacture; + char chManufacturer[32]; + if (pDeviceInfo->nTLayerType == MV_GIGE_DEVICE) + { + MV_GIGE_DEVICE_INFO* TempPtr = &(pDeviceInfo->SpecialInfo.stGigEInfo); + memcpy(chManufacturer, TempPtr->chManufacturerName, 32); + manufacture = chManufacturer; + } + else if (pDeviceInfo->nTLayerType == MV_USB_DEVICE) + { + MV_USB3_DEVICE_INFO* TempPtr = &(pDeviceInfo->SpecialInfo.stUsb3VInfo); + memcpy(chManufacturer, TempPtr->chManufacturerName, 32); + manufacture = chManufacturer; + } + else + { + continue; + } + + if(showinfo)std::cout << "Camera:" << i << ",vendor = " << manufacture << std::endl; + transform(manufacture.begin(), manufacture.end(), manufacture.begin(), ::toupper); + SingleCamInfoStruct CamInfo; + if ((!manufacture.compare(0, 3, "HIK")) || (!manufacture.compare(0, 3, "U3V"))) + { + void* camhandle; + MVCC_STRINGVALUE UserID; + MV_CC_CreateHandle(&camhandle, HIKCamera::stDeviceList.pDeviceInfo[i]); + if (!MV_CC_OpenDevice(camhandle)) + { + MV_CC_GetDeviceUserID(camhandle, &UserID); + if(showinfo)std::cout << "Hikrobot user ID = " << UserID.chCurValue << std::endl; + MV_CC_CloseDevice(camhandle); + } + MV_CC_DestroyHandle(camhandle); + CamInfo.UserID = atoi(UserID.chCurValue); + CamInfo.CamClass = HIKClassID; + CamInfo.unfiltered_num = i; + CamInfo.Detect = false; + CamInfo.IsOpen = false; + CamInfo.OffLine = false; + TempSingleCamInfo.push_back(CamInfo); + hik_cnt++; + } + } + + int balluff_cnt = 0; + unfiltered = BalluffCamera::Enumerate(); + for (int i = 0; i < min(unfiltered, NumberOfSupportedCameras); i++) + { + Device* pDev = BalluffCamera::devMgr[i]; + std::string manufacture = pDev->manufacturer.read(); + if(showinfo)std::cout << "Camera:" << i << ",vendor = " << manufacture << std::endl; + transform(manufacture.begin(), manufacture.end(), manufacture.begin(), ::toupper); + SingleCamInfoStruct CamInfo; + if (!manufacture.compare(0, 7, "BALLUFF")) + { + mvIMPACT::acquire::GenICam::DeviceControl dc(pDev); + std::string UserID = dc.deviceUserID.read(); + pDev->close(); + if(showinfo)std::cout << "Balluff user ID = " << UserID << std::endl; + CamInfo.UserID = atoi(UserID.c_str()); + CamInfo.CamClass = BalluffClassID; + CamInfo.unfiltered_num = i; + CamInfo.Detect = false; + CamInfo.IsOpen = false; + CamInfo.OffLine = false; + TempSingleCamInfo.push_back(CamInfo); + balluff_cnt++; + } + } + + if (showinfo) { + std::cout << "Camera Count:\t" << TempSingleCamInfo.size() << std::endl; + if (balluff_cnt)std::cout << "Balluff Count:\t" << balluff_cnt << std::endl; + if (hik_cnt)std::cout << "Hikvision Count:\t" << hik_cnt << std::endl; + if (basler_cnt)std::cout << "Basler Count:\t" << basler_cnt << std::endl; + } + + //userid򿪵߼----start + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + for (int j = 0; j < TempSingleCamInfo.size(); j++) + { + if ((TempSingleCamInfo[j].UserID == conf.UserID[i]) && (TempSingleCamInfo[j].Detect!= true)) + { + TempSingleCamInfo[j].Detect = true; + TempSingleCamInfoStruct[i].unfiltered_num = TempSingleCamInfo[j].unfiltered_num; + TempSingleCamInfoStruct[i].filtered_num = TempSingleCamInfo[j].filtered_num; + TempSingleCamInfoStruct[i].CamClass = TempSingleCamInfo[j].CamClass; + TempSingleCamInfoStruct[i].UserID = TempSingleCamInfo[j].UserID; + TempSingleCamInfoStruct[i].Detect = TempSingleCamInfo[j].Detect; + TempSingleCamInfoStruct[i].IsOpen = TempSingleCamInfo[j].IsOpen; + TempSingleCamInfoStruct[i].OffLine = TempSingleCamInfo[j].OffLine; + break; + } + } + } + //userid򿪵߼----end +} + +void Cigarette::EnableDebugMode() +{ + for(int i=0;iacquisitionFrameRateEnable.write(bTrue); + pAC[i]->acquisitionFrameRate.write(10.0); + //رⴥ + pAC[i]->triggerMode.writeS("Off"); + } + else if(SingleCamInfo[i].CamClass == HIKClassID) + { + int nRet = MV_OK; + + MV_CC_SetFrameRate(HIKCamHandle[i], 10.0); + nRet = MV_CC_SetBoolValue(HIKCamHandle[i], "AcquisitionFrameRateEnable",true); + if (nRet) { std::cout << "can not set AcquisitionFrameRateEnable" << std::endl;} + + nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerMode", MV_TRIGGER_MODE_OFF); + if (nRet) { std::cout << "can not set TriggerMode" << std::endl;} + } + else if(SingleCamInfo[i].CamClass == BaslerClassID) + { + bool nRet = false; +#ifndef USB_BASLER_NEW_FW + BaslerCamHandle[i]->TriggerSelector.SetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart); + if (!nRet) { std::cout << "can not set TriggerSelector_FrameBurstStart" << std::endl;} + BaslerCamHandle[i]->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off); + if (!nRet) { std::cout << "can not set TriggerMode_Off" << std::endl;} +#endif + BaslerCamHandle[i]->TriggerSelector.SetValue(Basler_UniversalCameraParams::TriggerSelector_FrameStart); + if (!nRet) { std::cout << "can not set TriggerSelector_FrameStart" << std::endl;} + BaslerCamHandle[i]->TriggerMode.SetValue(Basler_UniversalCameraParams::TriggerMode_Off); + if (!nRet) { std::cout << "can not set TriggerMode_Off" << std::endl;} + BaslerCamHandle[i]->AcquisitionFrameRateEnable.SetValue(true); + if (!nRet) { std::cout << "can not set AcquisitionFrameRateEnable" << std::endl;} + BaslerCamHandle[i]->AcquisitionFrameRate.SetValue(10); + if (!nRet) { std::cout << "can not set AcquisitionFrameRate" << std::endl;} + } + } + } + g_debug_mode = true; +} +void Cigarette::DisableDebugMode() +{ + for(int i=0;iacquisitionFrameRateEnable.write(bFalse); + pAC[i]->triggerMode.writeS("On"); + pAC[i]->triggerSource.writeS("Line4"); + pAC[i]->triggerActivation.writeS("RisingEdge"); + } + else if(SingleCamInfo[i].CamClass == HIKClassID) + { + int nRet = MV_OK; + nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerMode", MV_TRIGGER_MODE_ON); + if (nRet) { std::cout << "can not set TriggerMode" << std::endl;} + + nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerSource", MV_TRIGGER_SOURCE_LINE2); + if (nRet) { std::cout << "can not set TriggerSource" << std::endl;} + + nRet = MV_CC_SetEnumValue(HIKCamHandle[i], "TriggerActivation", 1);//1ʾ½ + if (nRet) { std::cout << "can not set TriggerActivation" << std::endl;} + + nRet = MV_CC_SetFrameRate(HIKCamHandle[i], 1000.0); + if (nRet) { std::cout << "can not set FrameInfo" << std::endl;} + nRet = MV_CC_SetBoolValue(HIKCamHandle[i], "AcquisitionFrameRateEnable",false); + if (nRet) { std::cout << "can not set AcquisitionFrameRateEnable" << std::endl;} + } + else if(SingleCamInfo[i].CamClass == BaslerClassID) + { + bool nRet = false; +#ifndef USB_BASLER_NEW_FW + nRet = BaslerCamHandle[i]->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameBurstStart); + if (!nRet) { std::cout << "can not set TriggerSelector_FrameBurstStart" << std::endl;} + nRet = BaslerCamHandle[i]->TriggerMode.TrySetValue(Basler_UniversalCameraParams::TriggerMode_On); +#endif + if (!nRet) { std::cout << "can not set TriggerMode_On" << std::endl;} + nRet = BaslerCamHandle[i]->TriggerSelector.TrySetValue(Basler_UniversalCameraParams::TriggerSelector_FrameStart); + if (!nRet) { std::cout << "can not set TriggerSelector_FrameStart" << std::endl;} + nRet = BaslerCamHandle[i]->TriggerMode.TrySetValue(Basler_UniversalCameraParams::TriggerMode_On); + if (!nRet) { std::cout << "can not set TriggerMode_On" << std::endl;} + nRet = BaslerCamHandle[i]->AcquisitionFrameRateEnable.TrySetValue(false); + if (!nRet) { std::cout << "can not set AcquisitionFrameRateEnable" << std::endl;} + } + } + } + g_debug_mode = false; +} + +void Cigarette::CleanThreadStart() +{ + QThread* handleThread = new QThread(); + CleanWorkThread* cleanWorkThread = new CleanWorkThread(); + + cleanWorkThread->moveToThread(handleThread); + + connect(handleThread, &QThread::started, cleanWorkThread, &CleanWorkThread::startWork); + connect(cleanWorkThread, &CleanWorkThread::workStart, cleanWorkThread, &CleanWorkThread::setSel); + connect(cleanWorkThread, &CleanWorkThread::workFinished, cleanWorkThread, &CleanWorkThread::deleteLater); + connect(cleanWorkThread, &CleanWorkThread::destroyed, handleThread, &QThread::quit); + connect(handleThread, &QThread::finished, handleThread, &QThread::deleteLater); + handleThread->start(); +} +void Cigarette::CleanThreadStartAuto() +{ + QThread* handleThread = new QThread(); + CleanWorkThread* cleanWorkThread = new CleanWorkThread(); + + cleanWorkThread->moveToThread(handleThread); + + connect(handleThread, &QThread::started, cleanWorkThread, &CleanWorkThread::startWorkAuto); + connect(cleanWorkThread, &CleanWorkThread::workStart, cleanWorkThread, &CleanWorkThread::setSelAuto); + connect(cleanWorkThread, &CleanWorkThread::workFinished, cleanWorkThread, &CleanWorkThread::deleteLater); + connect(cleanWorkThread, &CleanWorkThread::destroyed, handleThread, &QThread::quit); + connect(handleThread, &QThread::finished, handleThread, &QThread::deleteLater); + handleThread->start(); +} + +void Cigarette::record_output_statistic(qint64 quantity, int shift) +{ + float Kick[NumberOfSupportedCameras] = {0}; + if (m_PLCDevice->g_plc_ok) + { + if (!g_plc_dialog_open) //PLCöԻûд + { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + if (g_modbus_conf.kick1 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick1, 2, dest16); + if (ret == 2) + { + Kick[0] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + if (g_modbus_conf.kick2 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick2, 2, dest16); + if (ret == 2) + { + Kick[1] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + if (g_modbus_conf.kick3 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16); + if (ret == 2) + { + Kick[2] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + if (g_modbus_conf.kick4 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16); + if (ret == 2) + { + Kick[3] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + if (g_modbus_conf.kick5 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16); + if (ret == 2) + { + Kick[4] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + if (g_modbus_conf.kick6 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16); + if (ret == 2) + { + Kick[5] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + if (g_modbus_conf.kick7 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16); + if (ret == 2) + { + Kick[6] = dest16[0] + (dest16[1] << 16); + } + } +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + if (g_modbus_conf.kick8 > 0) + { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16); + if (ret == 2) + { + Kick[7] = dest16[0] + (dest16[1] << 16); + } + } +#endif + } + } + + for (int i = 0; i < NumberOfSupportedCameras; i++) + { + if (SingleCamInfo[i].IsOpen && quantity > 0) { + std::fstream cfg_file; + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, STATISTIC_FILE, i); + cfg_file.open(buf, std::ios::app); + if (cfg_file.good()) + { + if (last_shift == 2 || last_shift == 256) { + memset(buf, 0, 256); + sprintf(buf, "\n\n**************************************************************************************\n"); + cfg_file.write(buf, strlen(buf)); + QDate date = QDate::currentDate(); + memset(buf, 0, 256); + sprintf(buf, "%s:\n", date.toString("yyyy-MM-dd ").toStdString().c_str()); + cfg_file.write(buf, strlen(buf)); + } + memset(buf, 0, 256); + sprintf(buf, "%c ܲ:%010I64d ޳:%02.5f%% ϸ:%02.5f%% \n", (shift == 0) ? 'A' : ((shift == 1) ? 'B' : 'C'), quantity, (Kick[i] / quantity) * 100, (1.0 - (Kick[i] / quantity)) * 100); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + + } + cfg_file.close(); + } + } + last_shift = shift; +} + +void Cigarette::recMsgFromUdp(QString data) +{ +#ifdef __UDPSend + if (data == "START") + { + if (!g_admin_mode) + { + if (!g_op_mode) + { + sThread.sendData("OpNoLogin", g_sys_conf.FeedbackPort); + return; + } + } + if (m_PLCDevice->g_plc_ok) { + if (g_debug_mode) + { + sThread.sendData("StillDebug", g_sys_conf.FeedbackPort); + } + else + { + on_btn_start_released(); + } + } + } + else if (data == "END") + { + if (!g_admin_mode) + { + if (!g_op_mode) + { + sThread.sendData("OpNoLogin", g_sys_conf.FeedbackPort); + return; + } + } + on_btn_pause_released(); + } + else if (data == "LOCK") + { + if (!g_admin_mode) + { + sThread.sendData("AdminNoLogin", g_sys_conf.FeedbackPort); + return; + } + on_btn_lock_released(); + } + else if (data == "CHANGESHIFT") + { + if (!g_admin_mode) + { + if (!g_op_mode) + { + sThread.sendData("OpNoLogin", g_sys_conf.FeedbackPort); + return; + } + } + if (g_working) + { + sThread.sendData("CheckWorkState", g_sys_conf.FeedbackPort); + } + else + { + on_pushButton_clear_released(); + } + } + else if (data == "CLEARNIMAGE") + { + on_pushButton_Clear_Pic_released(); + //DialogSetup d; + //d.on_pushButton_ClearImage_released(); + + } + else if (data == "DEBUGEN") + { + if (!g_admin_mode) + { + sThread.sendData("Need_Login", g_sys_conf.FeedbackPort); + sThread.sendData("DebugEnFail", g_sys_conf.FeedbackPort); + return; + } + if (g_working) + { + if (g_debug_mode) + { + sThread.sendData("DebugEnStillWork", g_sys_conf.FeedbackPort); + } + else + { + sThread.sendData("DebugDisStillWork", g_sys_conf.FeedbackPort); + } + } + else + { + on_checkBox_debug_clicked(true); + } + } + else if (data == "DEBUGDIS") + { + if (!g_admin_mode) + { + sThread.sendData("Need_Login", g_sys_conf.FeedbackPort); + sThread.sendData("DebugDisFail", g_sys_conf.FeedbackPort); + return; + } + on_checkBox_debug_clicked(false); + } + else if (data == "KICK") + { + if (!g_admin_mode) + { + if (!g_op_mode) + { + sThread.sendData("OpNoLogin", g_sys_conf.FeedbackPort); + sThread.sendData("KickFail", g_sys_conf.FeedbackPort); + return; + } + } + on_checkBox_unkick_clicked(false); + } + else if (data == "UNKICK") + { + if (!g_admin_mode) + { + if (!g_op_mode) + { + sThread.sendData("OpNoLogin", g_sys_conf.FeedbackPort); + sThread.sendData("UnKickFail", g_sys_conf.FeedbackPort); + return; + } + } + if (m_PLCDevice->g_plc_ok) + { + on_checkBox_unkick_clicked(true); + ui.checkBox_unkick->setChecked(true); + } + else + { + sThread.sendData("UnKickFail", g_sys_conf.FeedbackPort); + } + } + else if (data == "GETCONF") + { + sThread.sendFile(CONFIGURE_FILE,g_sys_conf.FilePort); + for(int i=0;iisChecked()) + { + msg += "UnKickOk"; + } + else + { + msg += "KickOk"; + } + sThread.sendData(msg, g_sys_conf.FeedbackPort); + } + else if (dataList[0] == "GETSETTINGPRO") + { + if (!g_admin_mode) + { + if (!g_op_mode) + { + sThread.sendData("OpNoLogin", g_sys_conf.FeedbackPort); + return; + } + } + int camcnt = dataList[1].toInt(); + QString str; + str = QString("getsetting") + '_' + \ + QString::number(g_sys_conf.auto_open) + '_' +\ + QString::number(g_sys_conf.auto_work) + '_' +\ + QString::number(g_sys_conf.save) + '_'; + for(int i = 0;i +#include +#include + +#include "CaptureThread.h" +#include "CaptureThreadBasler.h" +#include "CaptureThreadHIK.h" +#include "debugthread.h" +#include "savethread.h" +#include "Logthread.h" +#include "threadSend.h" +#include "threadReceive.h" +#include "Cleanthread.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + + +class QTimer; +#define OPEN true +#define CLOSE false +class Cigarette : public QMainWindow +{ + Q_OBJECT + +public: + Cigarette(QWidget *parent = 0); + ~Cigarette(); + + static QImage cvMatToQImage(const cv::Mat& mat); + + QString read_pswd(); + QString read_op_pswd(); + + bool read_sys_config(SysConf &conf); + bool read_modbus_config(ModbusConf &conf); + void read_plc_items(); + bool save_rotate_message(); + bool read_rotate_message(); + bool save_alarm_message(std::vector &AlarmInfo_vect); + void init_plc_value(); + void CreatWorkThread(int classid,int Num,Cigarette* classptr); + void InitPtrMat(); + bool ControlCamOpenOrClose(int Num,bool OpenOrClose); + void EnumerateCameras(SingleCamInfoStruct *TempSingleCamInfo,bool showinfo,SysConf &conf); + void start_work(); + void pause_work(); +private slots : + void on_btn_start_released(); + void on_btn_pause_released(); + void on_btn_lock_released(); + void on_btn_setup_released(); + void on_checkBox_debug_clicked(bool checked); + void on_checkBox_unkick_clicked(bool checked); + void on_toolButton_plc_released(); + void on_toolButton_version_released(); + void on_toolButton_alarm_released(); + void on_pushButton_clear_released(); + void on_pushButton_Clear_Pic_released(); + void enable_shift(); + void OnNotifyHub(int Num, int Cnt, cv::Mat m); + void OnDisplayTimeCostHub(int Num, int ms); + void OnDisplayCheckNumberHub(int Num, long no); + void OnDisplayJdNoHub(int Num, QString jd_no); + void OnOKHub(int Num); + void OnNGHub(int Num); + void updateStatisticsHub(const QString& statisticalData, int Num); + void OnRotateReleasedHub(int Num); + void OnToolButtonCamReleasedHub(int Num); + void OpenCamTimeoutHub(int Num); + void OnDBClickHub(int Num_Cnt); + void OnTPClickHub(int Num_Cnt); + void OnDBClickNGHub(int Num); + void ReconnectCamHub(int Num); + void OnMouse(QMouseEvent* event); + void OnKey(QKeyEvent* event); + void handleTimeout(); //ʱÿһ + void op_timeout(); //Աʣʱ + void admin_timeout(); //ԱȨʣʱ + void FindFileForDelete(const QString& path); + void autoCleanImage(); + void EnableDebugMode(); + void DisableDebugMode(); + + void OnCancelAlarm(); //˫ + void on_pushButton_reset_released();//λ + + void OnOp(); + void OnExit(); + void OnRestart(); + + void OnAdmin(); +private: + Ui::CigaretteClass ui; + DialogSetupPasswd *dialog_setup_passwd; + Dialogin *dialogin; + DialogSetup *dialog_setup; + PlcSetup * dialog_plc_setup; + std::vector m_plc_items; +public: + QTimer *m_pTimer_Cam_mat[NumberOfSupportedCameras]; //ʱ + QLabel *label_cap_speed_mat[NumberOfSupportedCameras]; + QLabel *cam_status_mat[NumberOfSupportedCameras]; + QLabel *cam_work_mat[NumberOfSupportedCameras]; + QToolButton *cam_toolButton_mat[NumberOfSupportedCameras]; + db_label * display_lable_mat[NumberOfSupportedCameras][2]; + QLabel *label_timecost_mat[NumberOfSupportedCameras]; + QLCDNumber *lcdNumber_total_mat[NumberOfSupportedCameras]; + QLabel *label_jd_no_mat[NumberOfSupportedCameras]; + QLCDNumber *lcdNumber_ok_mat[NumberOfSupportedCameras]; + QLCDNumber *lcdNumber_ng_mat[NumberOfSupportedCameras]; + QLabel *label_reslut_mat[NumberOfSupportedCameras]; + QToolButton *rotate_mat[NumberOfSupportedCameras]; + QLabel *label_ng_mat[NumberOfSupportedCameras]; + + struct widget_info + { + UINT32 x; + UINT32 y; + UINT32 width; + UINT32 height; + }; + widget_info display_lable_info[NumberOfSupportedCameras][2]; + widget_info rotate_info[NumberOfSupportedCameras]; + + WorkThread work_thread[NumberOfSupportedCameras]; + + DebugThread debug_thread[NumberOfSupportedCameras]; + + SaveThread saveThread; + void record_output_statistic(qint64 cur_quantity, int shift); + + QTimer *m_pTimer; + QTimer *m_delay; //ֹ + QTimer *m_op_delay; //ԱȨʣʱ + QTimer *m_admin_delay; //ԱȨʣʱ + QTimer *clean_pTimer; //ʱ + + QSignalMapper *image_lable_DBsignalMapper0; + QSignalMapper *image_lable_DBsignalMapper1; + QSignalMapper *image_lable_TPsignalMapper0; + QSignalMapper *image_lable_TPsignalMapper1; + QSignalMapper *label_ng_signalMapper; + QSignalMapper *pTimer_Cam_signalMapper; + QSignalMapper *toolButton_cam_signalMapper; + QSignalMapper *RotateReleased_signalMapper; + int total_production_number; + int production_number[NumberOfSupportedCameras]; + int OpenWithUserID[NumberOfSupportedCameras]; + int ok[NumberOfSupportedCameras], ng[NumberOfSupportedCameras]; +#ifdef __UDPSend + private: + threadSend sThread; + threadReceive *rThread; +#endif +public slots: + void CleanThreadStart(); + void CleanThreadStartAuto(); + void recMsgFromUdp(QString data); + //void ClogThreadStart(); + +signals: + void sengMsgToClog(QString); +}; + +#endif // CIGARETTE_H diff --git a/Cigarette/cigarette.qrc b/Cigarette/cigarette.qrc new file mode 100644 index 0000000..b0f1e75 --- /dev/null +++ b/Cigarette/cigarette.qrc @@ -0,0 +1,39 @@ + + + Resources/rotate.png + Resources/exit.png + Resources/setup.png + Resources/alarm.png + Resources/plc.png + Resources/start.png + Resources/cam1.png + Resources/cam2.png + Resources/cam3.png + Resources/cam4.png + Resources/keyboard.png + Resources/cam1_no.png + Resources/cam1_yes.png + Resources/cam2_no.png + Resources/cam2_yes.png + Resources/cam3_no.png + Resources/cam3_yes.png + Resources/cam4_no.png + Resources/cam4_yes.png + Resources/lock.png + Resources/unlock.png + Resources/pause.png + Resources/cam5.png + Resources/cam5_no.png + Resources/cam5_yes.png + Resources/cam6.png + Resources/cam6_no.png + Resources/cam6_yes.png + Resources/cam7.png + Resources/cam7_no.png + Resources/cam7_yes.png + Resources/cam8.png + Resources/cam8_no.png + Resources/cam8_yes.png + Resources/logo.png + + diff --git a/Cigarette/cigarette.ui b/Cigarette/cigarette.ui new file mode 100644 index 0000000..1dd2607 --- /dev/null +++ b/Cigarette/cigarette.ui @@ -0,0 +1,4560 @@ + + + CigaretteClass + + + + 0 + 0 + 1280 + 800 + + + + Cigarette + + + background-color: rgb(55, 55, 55); + + + + + + 380 + 10 + 411 + 41 + + + + + 微软雅黑 + 24 + + + + background-color: rgb(255, 255, 0); + + + 装封箱胶点检测系统 + + + Qt::AlignCenter + + + + + + 10 + 60 + 161 + 221 + + + + + 微软雅黑 + 14 + 75 + true + + + + color:white + + + 操作区 + + + + + 5 + 30 + 70 + 90 + + + + + 微软雅黑 + + + + border-image: url(:/Cigarette/Resources/start.png); + + + + + + false + + + + + + 80 + 28 + 70 + 90 + + + + + 微软雅黑 + + + + border-image: url(:/Cigarette/Resources/pause.png); + + + + + + + false + + + + + + 5 + 120 + 70 + 90 + + + + + 微软雅黑 + + + + border-image: url(:/Cigarette/Resources/unlock.png); + + + + + + false + + + + + + 80 + 120 + 71 + 91 + + + + + 微软雅黑 + + + + border-image: url(:/Cigarette/Resources/setup.png); + + + + + + + false + + + + + + + 10 + 290 + 161 + 441 + + + + + 微软雅黑 + 14 + 75 + true + + + + color:white + + + 设备区 + + + + + 20 + 30 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam1_no.png); + + + + + + + + + 20 + 120 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam2_no.png); + + + + + + + + + 10 + 170 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 10 + 190 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 10 + 100 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 40 + 390 + 91 + 21 + + + + + 微软雅黑 + 10 + 50 + false + + + + color:white + + + 调试模式 + + + + + + 40 + 410 + 81 + 21 + + + + + 微软雅黑 + 10 + 50 + false + + + + color:white + + + 不剔除 + + + + + + 10 + 370 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 20 + 300 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam4_no.png); + + + + + + + + + 100 + 120 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam6_no.png); + + + + + + + + + 100 + 300 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam8_no.png); + + + + + + + + + 90 + 350 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 90 + 370 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 20 + 210 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam3_no.png); + + + + + + + + + 100 + 30 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam5_no.png); + + + + + + + + + 100 + 210 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/cam7_no.png); + + + + + + + + + 90 + 80 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 10 + 260 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 90 + 260 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 90 + 170 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 10 + 350 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 10 + 280 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 90 + 100 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 90 + 190 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 90 + 280 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 10 + 80 + 61 + 16 + + + + + 微软雅黑 + 10 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + + 10 + 740 + 1264 + 53 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + + + 919 + 10 + 71 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + color:white + + + 无报警 + + + Qt::AlignCenter + + + + + + 410 + 10 + 41 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + color:white + + + 当班 + + + + + + 740 + 10 + 81 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + color:white + + + PLC正常 + + + Qt::AlignCenter + + + + + + 450 + 5 + 171 + 41 + + + + color:white + + + 8 + + + + + + 880 + 5 + 41 + 41 + + + + border-image: url(:/Cigarette/Resources/alarm.png); + + + + + + + + + 690 + 5 + 51 + 41 + + + + border-image: url(:/Cigarette/Resources/plc.png); + + + + + + + + + 630 + 5 + 51 + 41 + + + + + 微软雅黑 + 12 + + + + color:white + + + 换班 + + + + + + 1000 + 16 + 250 + 20 + + + + + 微软雅黑 + 12 + 75 + true + + + + color:white + + + 运行1年10月25天9时15分 + + + Qt::AlignCenter + + + + + + 10 + 10 + 101 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + color:white + + + 登陆用户: + + + Qt::AlignCenter + + + + + + 110 + 10 + 71 + 31 + + + + + 微软雅黑 + 12 + 50 + false + + + + color:white + + + 操作员 + + + + + + 190 + 10 + 41 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + color:white + + + 上班 + + + + + + 230 + 5 + 171 + 41 + + + + color:white + + + 8 + + + + + + 825 + 5 + 51 + 41 + + + + + 微软雅黑 + 12 + + + + color:white + + + 复位 + + + + + + + 185 + 65 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 185 + 175 + 510 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 1#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 610 + 95 + 90 + 20 + + + + color:white + + + 10 + + + + + + 515 + 65 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 1#检测个数 + + + + + + 515 + 95 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 1#OK次数 + + + + + + 610 + 65 + 90 + 20 + + + + color:white + + + 10 + + + + + + 610 + 125 + 90 + 20 + + + + color:white + + + 10 + + + + + + 515 + 125 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 1#NG次数 + + + + + + 515 + 155 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 1#剔除次数 + + + + + + 610 + 155 + 90 + 20 + + + + color:white + + + 10 + + + + + + 484 + 65 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + :/Cigarette/Resources/rotate.png:/Cigarette/Resources/rotate.png + + + + 40 + 40 + + + + + + + 80 + 40 + 301 + 16 + + + + + 微软雅黑 + 8 + + + + color:white + + + SHANGHAI TOBACCO MACHINERY CO.,LTD + + + Qt::AlignCenter + + + + + + 90 + 7 + 271 + 31 + + + + + 微软雅黑 + 13 + + + + color:white + + + 上海烟草机械有限责任公司 + + + Qt::AlignCenter + + + + + + 10 + 10 + 70 + 50 + + + + border-image: url(:/Cigarette/Resources/logo.png); + + + + + + + + + + 880 + 10 + 191 + 21 + + + + + 微软雅黑 + 12 + 50 + false + + + + color:white + + + Tel:87907256(0532) + + + + + + 1080 + 10 + 81 + 21 + + + + + 微软雅黑 + 12 + 50 + false + + + + color:white + + + 青岛维克 + + + + + + 920 + 30 + 211 + 31 + + + + + 微软雅黑 + 12 + 50 + false + + + + color:white + + + 2020-10-10 13:15:39 + + + Qt::AlignCenter + + + + + + 10 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 170 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 484 + 230 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + Resources/rotate.pngResources/rotate.png + + + + 40 + 40 + + + + + + + 185 + 230 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 610 + 595 + 90 + 20 + + + + color:white + + + 10 + + + + + + 490 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 610 + 625 + 90 + 20 + + + + color:white + + + 10 + + + + + + 610 + 565 + 90 + 20 + + + + color:white + + + 10 + + + + + + 484 + 565 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + :/Cigarette/Resources/rotate.png:/Cigarette/Resources/rotate.png + + + + 40 + 40 + + + + + + + 515 + 565 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 4#检测个数 + + + + + + 515 + 595 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 4#OK次数 + + + + + + 515 + 655 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 4#剔除次数 + + + + + + 185 + 675 + 511 + 51 + + + + + 微软雅黑 + 10 + + + + color:white + + + 4#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 185 + 565 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 610 + 655 + 90 + 20 + + + + color:white + + + 10 + + + + + + 515 + 625 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 4#NG次数 + + + + + + 515 + 320 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 2#剔除次数 + + + + + + 610 + 320 + 90 + 20 + + + + color:white + + + 10 + + + + + + 515 + 260 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 2#OK次数 + + + + + + 610 + 260 + 90 + 20 + + + + color:white + + + 10 + + + + + + 610 + 230 + 90 + 20 + + + + color:white + + + 10 + + + + + + 515 + 230 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 2#检测个数 + + + + + + 515 + 290 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 2#NG次数 + + + + + + 610 + 290 + 90 + 20 + + + + color:white + + + 10 + + + + + + 185 + 345 + 510 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 2#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 610 + 460 + 90 + 20 + + + + color:white + + + 10 + + + + + + 515 + 490 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 3#剔除次数 + + + + + + 515 + 400 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 3#检测个数 + + + + + + 610 + 490 + 90 + 20 + + + + color:white + + + 10 + + + + + + 484 + 400 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + Resources/rotate.pngResources/rotate.png + + + + 40 + 40 + + + + + + + 185 + 510 + 510 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 3#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 515 + 460 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 3#NG次数 + + + + + + 185 + 400 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 515 + 430 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 3#OK次数 + + + + + + 610 + 430 + 90 + 20 + + + + color:white + + + 10 + + + + + + 610 + 400 + 90 + 20 + + + + color:white + + + 10 + + + + + + 330 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1175 + 230 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1175 + 125 + 90 + 20 + + + + color:white + + + 10 + + + + + + 750 + 230 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1080 + 320 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 6#剔除次数 + + + + + + 1080 + 65 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 5#检测个数 + + + + + + 1080 + 565 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 8#检测个数 + + + + + + 1034 + 65 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + :/Cigarette/Resources/rotate.png:/Cigarette/Resources/rotate.png + + + + 40 + 40 + + + + + + + 1080 + 655 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 8#剔除次数 + + + + + + 1080 + 400 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 7#检测个数 + + + + + + 1080 + 290 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 6#NG次数 + + + + + + 1034 + 230 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + :/Cigarette/Resources/rotate.png:/Cigarette/Resources/rotate.png + + + + 40 + 40 + + + + + + + 1080 + 125 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 5#NG次数 + + + + + + 1175 + 460 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1080 + 430 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 7#OK次数 + + + + + + 970 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 750 + 345 + 510 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 6#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 1175 + 290 + 90 + 20 + + + + color:white + + + 10 + + + + + + 750 + 565 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1175 + 565 + 90 + 20 + + + + color:white + + + 10 + + + + + + 750 + 675 + 511 + 51 + + + + + 微软雅黑 + 10 + + + + color:white + + + 8#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 750 + 510 + 510 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 7#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 1080 + 155 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 5#剔除次数 + + + + + + 1175 + 625 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1175 + 155 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1080 + 490 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 7#剔除次数 + + + + + + 1175 + 260 + 90 + 20 + + + + color:white + + + 10 + + + + + + 750 + 175 + 510 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 5#相机分析结果 + + + + + 10 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 采集速度: + + + + + + 80 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 150 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 胶点个数: + + + + + + 290 + 20 + 70 + 20 + + + + + 微软雅黑 + 10 + + + + 识别时间: + + + + + + 360 + 20 + 50 + 20 + + + + + 微软雅黑 + 11 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 430 + 20 + 60 + 25 + + + + + SimSun + 18 + 75 + true + + + + background-color: rgb(0, 255, 0); + + + OK + + + Qt::AlignCenter + + + + + + + 1175 + 490 + 90 + 20 + + + + color:white + + + 10 + + + + + + 750 + 65 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1080 + 95 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 5#OK次数 + + + + + + 1080 + 230 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 6#检测个数 + + + + + + 1080 + 595 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 8#OK次数 + + + + + + 1175 + 595 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1175 + 95 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1080 + 625 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 8#NG次数 + + + + + + 1175 + 400 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1175 + 320 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1080 + 460 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 7#NG次数 + + + + + + 1175 + 65 + 90 + 20 + + + + color:white + + + 10 + + + + + + 650 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1130 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1175 + 430 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1080 + 260 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + color:white + + + 6#OK次数 + + + + + + 810 + 1380 + 160 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1175 + 655 + 90 + 20 + + + + color:white + + + 10 + + + + + + 1034 + 565 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + :/Cigarette/Resources/rotate.png:/Cigarette/Resources/rotate.png + + + + 40 + 40 + + + + + + + 1034 + 400 + 0 + 0 + + + + Qt::ClickFocus + + + false + + + ... + + + + Resources/rotate.pngResources/rotate.png + + + + 40 + 40 + + + + + + + 750 + 400 + 320 + 110 + + + + background-color: rgb(0, 0, 0); + + + + + + + + + 1190 + 10 + 70 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 版本信息 + + + + + + 800 + 10 + 70 + 50 + + + + + 微软雅黑 + 10 + + + + color:white + + + 清理图片 + + + rotate_1 + groupBox_status + label_title + groupBox_op + groupBox_dev + image_label_11 + groupBox_a_1 + lcdNumber_ok_1 + label_check_1 + label_ok_1 + lcdNumber_total_1 + lcdNumber_ng_1 + label_ng_1 + label_kick_1 + lcdNumber_kick_1 + label_title_7 + label_title_6 + toolButton_4 + label_17 + label_18 + label_cur_time + rotate_2 + image_label_21 + lcdNumber_ok_4 + lcdNumber_ng_4 + lcdNumber_total_4 + rotate_4 + label_check_4 + label_ok_4 + label_kick_4 + groupBox_a_4 + image_label_41 + lcdNumber_kick_4 + label_ng_4 + label_kick_2 + lcdNumber_kick_2 + label_ok_2 + lcdNumber_ok_2 + lcdNumber_total_2 + label_check_2 + label_ng_2 + lcdNumber_ng_2 + groupBox_a_2 + lcdNumber_ng_3 + label_kick_3 + label_check_3 + lcdNumber_kick_3 + groupBox_a_3 + label_ng_3 + image_label_31 + label_ok_3 + lcdNumber_ok_3 + lcdNumber_total_3 + rotate_3 + lcdNumber_total_6 + lcdNumber_ng_5 + image_label_61 + label_kick_6 + label_check_5 + label_check_8 + rotate_5 + label_kick_8 + label_check_7 + label_ng_6 + rotate_6 + label_ng_5 + lcdNumber_ng_7 + label_ok_7 + groupBox_a_6 + lcdNumber_ng_6 + image_label_81 + lcdNumber_total_8 + groupBox_a_8 + groupBox_a_7 + label_kick_5 + lcdNumber_ng_8 + lcdNumber_kick_5 + label_kick_7 + lcdNumber_ok_6 + groupBox_a_5 + lcdNumber_kick_7 + image_label_51 + label_ok_5 + label_check_6 + label_ok_8 + lcdNumber_ok_8 + lcdNumber_ok_5 + label_ng_8 + lcdNumber_total_7 + lcdNumber_kick_6 + label_ng_7 + lcdNumber_total_5 + lcdNumber_ok_7 + label_ok_6 + lcdNumber_kick_8 + rotate_8 + rotate_7 + image_label_71 + toolButton_version + image_label_22 + image_label_32 + image_label_42 + image_label_52 + image_label_62 + image_label_72 + image_label_82 + image_label_12 + toolButton_Clear_Pic + + + + + + db_label + QLabel +
db_label.h
+
+
+ + + + +
diff --git a/Cigarette/common.cpp b/Cigarette/common.cpp new file mode 100644 index 0000000..4dbcdf9 --- /dev/null +++ b/Cigarette/common.cpp @@ -0,0 +1,105 @@ +#include "common.h" +#include +#include "stdarg.h" +int string_split(std::string str, std::string pattern,std::vector &out) +{ + std::string::size_type pos; + int cnt = 0; + str += pattern; + int size = str.size(); + + for (int i = 0; i chars(nLength); + _vsnprintf(chars.data(), nLength, pszFmt, args); + str.assign(chars.data()); + } + va_end(args); + return str; +} + +void DrawSelectRects(cv::Mat input,DisplayLabelConf &t_DisplayLabelConf,int Cnt) +{ + if (t_DisplayLabelConf.Flag[Cnt] & DisplayLabel_Type_Bit) { + if (t_DisplayLabelConf.leftButtonDownFlag) { + cv::rectangle( + input, + cv::Point( + t_DisplayLabelConf.originalPoint.x * input.cols, + t_DisplayLabelConf.originalPoint.y * input.rows), + cv::Point( + t_DisplayLabelConf.processPoint.x * input.cols, + t_DisplayLabelConf.processPoint.y * input.rows), + cv::Scalar(0, 0, 255), + 4); + } + for (int i = 0; i < t_DisplayLabelConf.RectVet[Cnt].size(); i++) { + cv::rectangle( + input, + cv::Point( + t_DisplayLabelConf.RectVet[Cnt][i].TL.x * input.cols, + t_DisplayLabelConf.RectVet[Cnt][i].TL.y * input.rows), + cv::Point( + t_DisplayLabelConf.RectVet[Cnt][i].BR.x * input.cols, + t_DisplayLabelConf.RectVet[Cnt][i].BR.y * input.rows), + cv::Scalar(0, 0, 255), + 4); + } + } +} + +bool CheckSelectRects( + cv::Mat input, + std::vector > > &VecRects, + int VecCnt, + DisplayLabelConf &t_DisplayLabelConf, + int LabelCnt +) +{ + if (VecCnt < VecRects.size()) + { + for (int i = 0; i < VecRects[VecCnt].size(); i++) + { + for(int j = 0; j < t_DisplayLabelConf.RectVet[LabelCnt].size(); j++) + { + cv::Rect LocalRect = VecRects[VecCnt][i].second; + cv::Rect CheckRect = cv::Rect( + cv::Point( + t_DisplayLabelConf.RectVet[LabelCnt][j].TL.x* input.cols, + t_DisplayLabelConf.RectVet[LabelCnt][j].TL.y* input.rows + ), + cv::Point( + t_DisplayLabelConf.RectVet[LabelCnt][j].BR.x* input.cols, + t_DisplayLabelConf.RectVet[LabelCnt][j].BR.y* input.rows + ) + ); + + if(LocalRect != (LocalRect & CheckRect)) + { + return true; + } + } + } + } + return false; +} \ No newline at end of file diff --git a/Cigarette/common.h b/Cigarette/common.h new file mode 100644 index 0000000..fbec365 --- /dev/null +++ b/Cigarette/common.h @@ -0,0 +1,194 @@ +#pragma once + +#include +#include +#include "basecamera.h" +#include +#include "QtCore\qdatetime.h" + +//#define __DEBUG //debugϢ +#define __UDPSend //緢͹ +#define USB_BASLER_NEW_FW //ʹbaslerƹ̼ +//#define IMM_PROCESS //պУź +//#define IMM_FEED_BACK //Уź +#define ONE_TIME_SHIFT //һķͷ(Ĭϴ) +#define AI_WARM_UP //AIʶʼǰ +//#define LICENSE_VERIFY //licenseļУ +//CAP_FEED_BACKDOUBLE_FEED_BACKҪһ +#if defined (ONE_TIME_SHIFT) + //#define CAP_FEED_BACK //ʱҲûвԽеĻͷ + //#define DOUBLE_FEED_BACK //һngηngź +#endif + +#define Queue_Size 15 +#define Unit_Queue_Size Queue_Size*3 +#define StrobeLineTime 10000 + +#ifdef __DEBUG +#define DEBUG(format, ...) printf (format, ##__VA_ARGS__) +#else +#define DEBUG(format, ...) +#endif + +int string_split(std::string str, std::string pattern,std::vector &out); +std::string format(const char *pszFmt, ...); +class SysConf +{ +public: + std::mutex lock; + int save; //ͼƬǷ񱣴棬0棬1NG, 2ȫ + int MisMatchAct; //λΪ1NG,0ok + int save_days; ///Ƭ + int freesize; /// 趨ͼƬСռ + int auto_open; //ǷԶ01 + int auto_work; //ǷԶʼ01 + int auto_shift; //ǷԶ࣬01 + QTime shiftA; //Aʱ + QTime shiftB; //Bʱ + QTime shiftC; //Cʱ + QString location; // ڵ + QString path; // ģ· + int timing_shift; //Ƿʱ࣬01 + int expo[NumberOfSupportedCameras]; //عʱ䣬λ΢ + int gain[NumberOfSupportedCameras]; //ģ棬Χ0~64 + int filter[NumberOfSupportedCameras];//˲ʱ + int UserID[NumberOfSupportedCameras]; + int no[NumberOfSupportedCameras][3];//ͼƬٺϸ񽺵 + int shoot[NumberOfSupportedCameras];// + std::string MonitorIP; //Զ̼ض˵IP + int MonitorPort; + int FeedbackPort; + int FilePort; + //MonitorPortΪݶ˿ + //MonitorPort+NumberOfSupportedCamerasΪͼ˿ + //MonitorPort+NumberOfSupportedCameras*2Ϊ˿,ҲFeedbackPort + //MonitorPort+NumberOfSupportedCameras*2+1Ϊ˿ + + SysConf() + { + save=0; //ͼƬǷ񱣴棬0棬1NG, 2ȫ + MisMatchAct=1; //λΪ1NG,0ok + save_days = 1; ///Ƭ + freesize = 10; + auto_open=1; //ǷԶ01 + auto_work=1; //ǷԶʼ01 + auto_shift=1; //ǷԶ࣬01 + timing_shift=0; //Ƿʱ࣬01 + location = ""; + path = ""; + shiftA.setHMS(0, 0, 0); + shiftB.setHMS(0, 0, 0); + shiftC.setHMS(0, 0, 0); + for(int i=0;i0) + int kick1; //1#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + int kick2; //2#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + int kick3; //3#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + int kick4; //4#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + int kick5; //5#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + int kick6; //6#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + int kick7; //7#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + int kick8; //8#ͨ޳ַ +#endif + int quantity; //ַ + int shift; //ַ + int work; //ʼ/ͣ + int no_kick; //ֻղ޳ģʽ + int debug; //ģʽPLCģline4ź + int reset; //λ + int alarm; // + + ModbusConf() + { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + kick1=0; //1#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + kick2=0; //2#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + kick3=0; //3#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + kick4=0; //4#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + kick5=0; //1#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + kick6=0; //2#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + kick7=0; //3#ͨ޳ַ +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + kick8=0; //4#ͨ޳ַ +#endif + quantity=0; //ַ + shift=0; //ַ + work=0; //ʼ/ͣ + no_kick=0; //ֻղ޳ģʽ + debug=0; //ģʽPLCģline4ź + reset=0; //λ + alarm=0; // + } +}; + +#define DisplayLabel_Type_Bit 0x01 //1:򿪷Χʶܣ0:رշΧʶ +#define DisplayLabel_Conf_Bit 0x02 //1:Իƾο0:ܻƾο +class RectRatio +{ +public: + RectRatio(cv::Point2f tl, cv::Point2f br) :TL(tl), BR(br) {}; + cv::Point2f TL; + cv::Point2f BR; +}; + +class DisplayLabelConf +{ +public: + std::mutex lock; + bool leftButtonDownFlag = false; //Ƶͣŵı־λ + cv::Point2f originalPoint; //ο + cv::Point2f processPoint; //οյ + + cv::Mat g_last_mat[2]; + bool g_max[2] = {false}; //ͼǷ + uint8_t Flag[2] = {0}; + std::vector RectVet[2]; +}; +void DrawSelectRects(cv::Mat input, DisplayLabelConf &t_DisplayLabelConf, int Cnt); +bool CheckSelectRects(cv::Mat input, std::vector > > &VecRects,int VecCnt, DisplayLabelConf &t_DisplayLabelConf, int LabelCnt); \ No newline at end of file diff --git a/Cigarette/db_label.cpp b/Cigarette/db_label.cpp new file mode 100644 index 0000000..d6eaad2 --- /dev/null +++ b/Cigarette/db_label.cpp @@ -0,0 +1,46 @@ +//qlabel_doubleclick.cpp +#include "db_label.h" +#include +db_label::db_label(QWidget *parent) : QLabel(parent){ + setFocusPolicy(Qt::StrongFocus); + connect(&timer, SIGNAL(timeout()), this, SLOT(TimeOutNotify())); +} + +db_label::~db_label(){} + +void db_label::mouseDoubleClickEvent(QMouseEvent* event) { + emit SignalmouseDoubleClickEvent(event); +} + +void db_label::mouseReleaseEvent(QMouseEvent* event) { + emit SignalmouseReleaseEvent(event); + cnt++; + timer.setSingleShot(true); + timer.start(300); +} + +void db_label::mousePressEvent(QMouseEvent* event) { + emit SignalmousePressEvent(event); +} + +void db_label::mouseMoveEvent(QMouseEvent* event) { + emit SignalmouseMoveEvent(event); +} + +void db_label::keyReleaseEvent(QKeyEvent* event) +{ + emit SignalkeyReleaseEvent(event); +} + +void db_label::TimeOutNotify(void) { + timer.stop(); + switch(cnt) { + case 1:emit QlabelClick(); break; + case 2:emit QlabelDoubleClick(); break; + case 3:emit QlabelTripleClick(); break; + default:break; + } + cnt = 0; +} + + diff --git a/Cigarette/db_label.h b/Cigarette/db_label.h new file mode 100644 index 0000000..db3d348 --- /dev/null +++ b/Cigarette/db_label.h @@ -0,0 +1,38 @@ +//qlabel_doubleclick.h +#ifndef QLABEL_DOUBLECLICK_H_ +#define QLABEL_DOUBLECLICK_H_ + +#include +#include +#include +#include + +class db_label : public QLabel +{ + Q_OBJECT + +public: + db_label(QWidget *parent = 0); + ~db_label(); + + void mouseDoubleClickEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void keyReleaseEvent(QKeyEvent* event); + QTimer timer; + int cnt = 0; +signals: + void QlabelClick(); + void QlabelDoubleClick(); + void QlabelTripleClick(); + void SignalmouseDoubleClickEvent(QMouseEvent* event); + void SignalmousePressEvent(QMouseEvent* event); + void SignalmouseReleaseEvent(QMouseEvent* event); + void SignalmouseMoveEvent(QMouseEvent* event); + void SignalkeyReleaseEvent(QKeyEvent* event); +private slots: + void TimeOutNotify(); +}; + +#endif // QLABEL_DOUBLECLICK_H_ \ No newline at end of file diff --git a/Cigarette/debugthread.cpp b/Cigarette/debugthread.cpp new file mode 100644 index 0000000..e731fa2 --- /dev/null +++ b/Cigarette/debugthread.cpp @@ -0,0 +1,2 @@ +#include "debugthread.h" + diff --git a/Cigarette/debugthread.h b/Cigarette/debugthread.h new file mode 100644 index 0000000..74098f6 --- /dev/null +++ b/Cigarette/debugthread.h @@ -0,0 +1,72 @@ +#ifndef _DEBUGTHREAD_H +#define _DEBUGTHREAD_H +#include +#include +#include +#include +#include +#include "SyncQueue.h" +#include "basecamera.h" +#include "common.h" +extern SyncQueue *g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列 + +extern int rotationAngle[NumberOfSupportedCameras]; //图片旋转角度 +extern bool isNeddRotate[NumberOfSupportedCameras]; +class DebugThread : public QThread +{ + Q_OBJECT +signals: + void notify(int Num,int Cnt,cv::Mat); +public: + DebugThread(QObject *parent = 0): QThread(parent) + { + + } + ~DebugThread() + { + stop(); + p_debug_queue->put(cv::Mat()); + quit(); + wait(); + } + void init(SyncQueue *ptr,int Num) + { + local_camera_number = Num; + b_quit = false; + p_debug_queue = ptr; + } + void start_work() + { + start(HighestPriority); + } + void stop() + { + b_quit = true; + } +protected: + void run() + { + while (!b_quit) { + cv::Mat image; + p_debug_queue->take(image); + if (image.data) + { + cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像 + if (isNeddRotate[local_camera_number]) { + if(rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1)) + { + cv::rotate(image, image, rotationAngle[local_camera_number]); + } + } + emit notify(local_camera_number,0,image); + } + } + } +public: + int local_camera_number; + int local_classid; + bool b_quit; + SyncQueue *p_debug_queue; + +}; +#endif //end of _DEBUGTHREAD_H diff --git a/Cigarette/dialogin.cpp b/Cigarette/dialogin.cpp new file mode 100644 index 0000000..da8adf4 --- /dev/null +++ b/Cigarette/dialogin.cpp @@ -0,0 +1,99 @@ +#include "dialogin.hpp" + +#include + +#include + +#include + +extern bool g_op_mode; //是否操作员模式 + +extern QString g_op_pswd; //操作员密码 + +Dialogin::Dialogin(QWidget * parent) : QDialog(parent) { + ui.setupUi(this); + m_pswd = ""; + this->setWindowFlags(Qt::FramelessWindowHint); +} + +Dialogin::~Dialogin() { + +} + +void Dialogin::on_pushButton_close_released() +{ + this->close(); +} +void Dialogin::on_pushButton_clr_released() +{ + m_pswd = ""; + ui.lineEdit->setText(""); +} +void Dialogin::on_pushButton_ok_released() +{ + QString md5Str = QCryptographicHash::hash(m_pswd.toLatin1(), QCryptographicHash::Md5).toHex(); + qDebug() << "m_pswd_op:" << m_pswd; + qDebug() << "m_pswd_op md5:" << md5Str; + qDebug() << "g_admin_pswd_op md5:" << g_op_pswd; + if (md5Str.compare(g_op_pswd, Qt::CaseInsensitive) == 0) + { + g_op_mode = true; + //QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("验证通过,进入管理员模式"), QMessageBox::Ok); + emit enter_op(); + this->close(); + } + else { + QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("密码错误,请重新输入"), QMessageBox::Ok); + on_pushButton_clr_released(); + } +} +void Dialogin::on_pushButton_0_released() +{ + m_pswd += "0"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_1_released() +{ + m_pswd += "1"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_2_released() +{ + m_pswd += "2"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_3_released() +{ + m_pswd += "3"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_4_released() +{ + m_pswd += "4"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_5_released() +{ + m_pswd += "5"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_6_released() +{ + m_pswd += "6"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_7_released() +{ + m_pswd += "7"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_8_released() +{ + m_pswd += "8"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void Dialogin::on_pushButton_9_released() +{ + m_pswd += "9"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} diff --git a/Cigarette/dialogin.hpp b/Cigarette/dialogin.hpp new file mode 100644 index 0000000..5317898 --- /dev/null +++ b/Cigarette/dialogin.hpp @@ -0,0 +1,34 @@ +#pragma once +#include +#include "ui_dialogin.h" + +class Dialogin : public QDialog { + Q_OBJECT +signals : + void enter_op(); + +public: + Dialogin(QWidget * parent = Q_NULLPTR); + ~Dialogin(); + +private slots : + void on_pushButton_close_released(); + void on_pushButton_clr_released(); + void on_pushButton_ok_released(); + void on_pushButton_0_released(); + void on_pushButton_1_released(); + void on_pushButton_2_released(); + void on_pushButton_3_released(); + void on_pushButton_4_released(); + void on_pushButton_5_released(); + void on_pushButton_6_released(); + void on_pushButton_7_released(); + void on_pushButton_8_released(); + void on_pushButton_9_released(); + +public: + QString m_pswd; + +private: + Ui::Dialogin ui; +}; diff --git a/Cigarette/dialogin.ui b/Cigarette/dialogin.ui new file mode 100644 index 0000000..01941bd --- /dev/null +++ b/Cigarette/dialogin.ui @@ -0,0 +1,338 @@ + + + Dialogin + + + + 0 + 0 + 520 + 708 + + + + Dialogin + + + background-color: rgb(220, 220, 220); + + + + + 360 + 20 + 121 + 61 + + + + + 微软雅黑 + 28 + 75 + true + + + + 关闭 + + + + + + 220 + 440 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 2 + + + + + + 50 + 90 + 441 + 61 + + + + + 微软雅黑 + 48 + 50 + false + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 70 + 180 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 7 + + + + + + 370 + 180 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 9 + + + + + + 220 + 310 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 5 + + + + + + 70 + 310 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 4 + + + + + + 70 + 440 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 1 + + + + + + 70 + 570 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + CLR + + + + + + 370 + 440 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 3 + + + + + + 370 + 570 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + OK + + + + + + 220 + 570 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 0 + + + + + + 370 + 310 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 6 + + + + + + 220 + 180 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 8 + + + + + + 70 + 30 + 261 + 41 + + + + + 微软雅黑 + 20 + 75 + true + + + + 请输入操作员密码: + + + + + + + diff --git a/Cigarette/dialogsetup.cpp b/Cigarette/dialogsetup.cpp new file mode 100644 index 0000000..56bf516 --- /dev/null +++ b/Cigarette/dialogsetup.cpp @@ -0,0 +1,582 @@ +#include "dialogsetup.hpp" +#include +#include +#include +#include +#include +#include "common.h" +#include +#include +#include +#include +#include "basecamera.h" +#include //用于显示桌面 +#include //用于显示桌面 + +extern SysConf g_sys_conf; //系统配置参数 +extern QString g_admin_pswd; //管理员密码 +extern QString g_op_pswd; //操作员密码 + +void task_osk() +{ + system("start /b C:\\Windows\\system32\\osk.exe"); +} + +DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) { + ui.setupUi(this); + InitPtrMat(); + this->setWindowFlags(Qt::FramelessWindowHint); + + for(int i=0;isetValidator(new QIntValidator(0, 1000000, this)); + lineEdit_expo_mat[i]->setText(QString::number(g_sys_conf.expo[i])); + lineEdit_gain_mat[i]->setValidator(new QIntValidator(0, 64, this)); + lineEdit_gain_mat[i]->setText(QString::number(g_sys_conf.gain[i])); + lineEdit_filter_mat[i]->setValidator(new QIntValidator(0, 1000000, this)); + lineEdit_filter_mat[i]->setText(QString::number(g_sys_conf.filter[i])); + } + + if (g_sys_conf.auto_open == 1) + { + ui.checkBox_auto_open->setChecked(true); + } + else { + ui.checkBox_auto_open->setChecked(false); + } + if (g_sys_conf.auto_work == 1) + { + ui.checkBox_auto_work->setChecked(true); + } + else { + ui.checkBox_auto_work->setChecked(false); + } + // + switch (g_sys_conf.save) + { + case 0: + ui.radioButton_none->setChecked(true); + break; + case 1: + ui.radioButton_ng->setChecked(true); + break; + case 2: + ui.radioButton_all->setChecked(true); + break; + default: + break; + } + // +} + +DialogSetup::~DialogSetup() { + +} + +void DialogSetup::on_toolButton_keyboard_released() +{ + std::thread osk_thread = std::thread(task_osk); + osk_thread.detach(); +} +void DialogSetup::on_pushButton_exit_released() +{ + if (QMessageBox::Yes == QMessageBox::critical(NULL, QStringLiteral("退出系统"), QStringLiteral("确定退出系统?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) + { + emit system_exit(); + this->close(); + } +} + +void DialogSetup::on_pushButton_desktop_released() +{ + CoInitialize(0); + IShellDispatch4 * pdisp = NULL; + CoCreateInstance(CLSID_Shell, NULL, CLSCTX_ALL, __uuidof(IShellDispatch4), (void **)&pdisp); + pdisp->ToggleDesktop(); // 这句是用来切换桌面的 + pdisp->Release(); + CoUninitialize(); +} + +void DialogSetup::on_pushButton_expo_released() +{ + for(int i=0;itext()).toInt(); + g_sys_conf.gain[i] = (lineEdit_gain_mat[i]->text()).toInt(); + } + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("设置成功"), QMessageBox::Ok); +} + +void DialogSetup::on_checkBox_auto_open_clicked(bool checked) +{ + if (checked) + { + g_sys_conf.auto_open = 1; + } + else + { + g_sys_conf.auto_open = 0; + } +} + +void DialogSetup::on_checkBox_auto_work_clicked(bool checked) +{ + if (checked) + { + g_sys_conf.auto_work = 1; + } + else + { + g_sys_conf.auto_work = 0; + } +} + +void DialogSetup::on_pushButton_filter_released() +{ + for(int i=0;itext()).toInt(); + } + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("设置成功"), QMessageBox::Ok); +} + +void DialogSetup::on_pushButton_image_released() +{ + if (ui.radioButton_none->isChecked()) + { + g_sys_conf.save = 0; + } + if (ui.radioButton_ng->isChecked()) + { + g_sys_conf.save = 1; + } + if (ui.radioButton_all->isChecked()) + { + g_sys_conf.save = 2; + } + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("设置成功"), QMessageBox::Ok); +} + +void DialogSetup::on_pushButton_pswd_released() +{ + QString md5Str = QCryptographicHash::hash((ui.lineEdit_old->text()).toLatin1(), QCryptographicHash::Md5).toHex(); + if (md5Str.compare(g_admin_pswd, Qt::CaseInsensitive) == 0) + { + QString pswd_new = ui.lineEdit_new->text(); + QString pswd_confirm = ui.lineEdit_confirm->text(); + if (pswd_new.compare(pswd_confirm, Qt::CaseInsensitive) == 0) + { + g_admin_pswd = QCryptographicHash::hash(pswd_new.toLatin1(), QCryptographicHash::Md5).toHex(); + write_pswd(); + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("管理员密码修改成功"), QMessageBox::Ok); + } + else { + QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("新密码两次输入不一致,请重新输入"), QMessageBox::Ok); + } + } + else { + QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("原密码错误,请重新输入"), QMessageBox::Ok); + } +} +void DialogSetup::on_pushButton_pswd_op_released() +{ + QString md5Str = QCryptographicHash::hash((ui.lineEdit_old_op->text()).toLatin1(), QCryptographicHash::Md5).toHex(); + if (md5Str.compare(g_op_pswd, Qt::CaseInsensitive) == 0) + { + QString pswd_new = ui.lineEdit_new_op->text(); + QString pswd_confirm = ui.lineEdit_confirm_op->text(); + if (pswd_new.compare(pswd_confirm, Qt::CaseInsensitive) == 0) + { + g_op_pswd = QCryptographicHash::hash(pswd_new.toLatin1(), QCryptographicHash::Md5).toHex(); + write_pswd_op(); + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("操作员密码修改成功"), QMessageBox::Ok); + } + else { + QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("新密码两次输入不一致,请重新输入"), QMessageBox::Ok); + } + } + else { + QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("原密码错误,请重新输入"), QMessageBox::Ok); + } +} +void DialogSetup::on_pushButton_save_released() +{ + //存图设置 + if (ui.radioButton_none->isChecked()) + { + g_sys_conf.save = 0; + } + if (ui.radioButton_ng->isChecked()) + { + g_sys_conf.save = 1; + } + if (ui.radioButton_all->isChecked()) + { + g_sys_conf.save = 2; + } + for(int i=0;itext()).toInt(); + g_sys_conf.gain[i] = (lineEdit_gain_mat[i]->text()).toInt(); + g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt(); + } + write_config(); + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok); +} +void DialogSetup::on_pushButton_close_released() +{ + this->close(); +} + +void DialogSetup::on_toolButton_choose_path_released() { + //QString srcDirPath = QFileDialog::getExistingDirectory(this, "choose src Directory", "./"); + QString WeightsPath = QFileDialog::getOpenFileName(this, "选择weights文件", "/", "Weights files(*.weights)"); + if (WeightsPath.isEmpty()) { + return; + } + else { + if (ui.comboBox->findText(WeightsPath) == -1) { + ui.comboBox->addItem(WeightsPath); // 在comboBox中显示文件路径 + g_sys_conf.path = WeightsPath; // 将选择的路径写入conf配置文件中 + } + } +} + + +void DialogSetup::write_pswd() +{ + std::fstream cfg_file; + cfg_file.open("pswd.txt", std::ios::out | std::ios::trunc); + if (cfg_file.good()) + { + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, "%s", g_admin_pswd.toStdString().c_str()); + cfg_file.write(buf, strlen(buf)); + } + cfg_file.close(); +} +void DialogSetup::write_pswd_op() +{ + std::fstream cfg_file; + cfg_file.open("pswd_op.txt", std::ios::out | std::ios::trunc); + if (cfg_file.good()) + { + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, "%s", g_op_pswd.toStdString().c_str()); + cfg_file.write(buf, strlen(buf)); + } + cfg_file.close(); +} +void DialogSetup::write_config() +{ + std::fstream cfg_file; + cfg_file.open("../conf/conf.txt", std::ios::out | std::ios::trunc); + if (cfg_file.good()) + { + char buf[256]; + memset(buf, 0, 256); + sprintf(buf, "SAVE=%d\n", g_sys_conf.save); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "MISMATCHACT=%d\n", g_sys_conf.MisMatchAct); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256);/// + sprintf(buf, "SAVE_DAYS=%d\n", g_sys_conf.save_days); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256);/// + sprintf(buf, "FREESIZE=%d\n", g_sys_conf.freesize); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "AUTO_OPEN=%d\n", g_sys_conf.auto_open); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "AUTO_WORK=%d\n", g_sys_conf.auto_work); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "AUTO_SHIFT=%d\n", g_sys_conf.auto_shift); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "TIMING_SHIFT=%d\n", g_sys_conf.timing_shift); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHIFT_A=%d|%d\n", g_sys_conf.shiftA.hour(), g_sys_conf.shiftA.minute()); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHIFT_B=%d|%d\n", g_sys_conf.shiftB.hour(), g_sys_conf.shiftB.minute()); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHIFT_C=%d|%d\n", g_sys_conf.shiftC.hour(), g_sys_conf.shiftC.minute()); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "LOCATION=%s\n", g_sys_conf.location.toStdString().c_str()); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "MODELPATH=%s\n", g_sys_conf.path.toStdString().c_str()); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + memset(buf, 0, 256); + sprintf(buf, "EXPO1=%d\n", g_sys_conf.expo[0]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN1=%d\n", g_sys_conf.gain[0]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "FILTER1=%d\n", g_sys_conf.filter[0]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "USERID1=%d\n", g_sys_conf.UserID[0]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO1=%d|%d|%d\n", g_sys_conf.no[0][0],g_sys_conf.no[0][1],g_sys_conf.no[0][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT1=%d\n", g_sys_conf.shoot[0]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + memset(buf, 0, 256); + sprintf(buf, "EXPO2=%d\n", g_sys_conf.expo[1]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN2=%d\n", g_sys_conf.gain[1]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "FILTER2=%d\n", g_sys_conf.filter[1]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "USERID2=%d\n", g_sys_conf.UserID[1]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO2=%d|%d|%d\n", g_sys_conf.no[1][0],g_sys_conf.no[1][1],g_sys_conf.no[1][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT2=%d\n", g_sys_conf.shoot[1]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + memset(buf, 0, 256); + sprintf(buf, "EXPO3=%d\n", g_sys_conf.expo[2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN3=%d\n", g_sys_conf.gain[2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "FILTER3=%d\n", g_sys_conf.filter[2]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "USERID3=%d\n", g_sys_conf.UserID[2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO3=%d|%d|%d\n", g_sys_conf.no[2][0],g_sys_conf.no[2][1],g_sys_conf.no[2][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT3=%d\n", g_sys_conf.shoot[2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + memset(buf, 0, 256); + sprintf(buf, "EXPO4=%d\n", g_sys_conf.expo[3]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN4=%d\n", g_sys_conf.gain[3]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "FILTER4=%d\n", g_sys_conf.filter[3]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "USERID4=%d\n", g_sys_conf.UserID[3]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO4=%d|%d|%d\n", g_sys_conf.no[3][0],g_sys_conf.no[3][1],g_sys_conf.no[3][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT4=%d\n", g_sys_conf.shoot[3]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + memset(buf, 0, 256); + sprintf(buf, "EXPO5=%d\n", g_sys_conf.expo[4]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN5=%d\n", g_sys_conf.gain[4]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "FILTER5=%d\n", g_sys_conf.filter[4]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "USERID5=%d\n", g_sys_conf.UserID[4]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO5=%d|%d|%d\n", g_sys_conf.no[4][0],g_sys_conf.no[4][1],g_sys_conf.no[4][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT5=%d\n", g_sys_conf.shoot[4]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + memset(buf, 0, 256); + sprintf(buf, "EXPO6=%d\n", g_sys_conf.expo[5]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN6=%d\n", g_sys_conf.gain[5]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "FILTER6=%d\n", g_sys_conf.filter[5]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "USERID6=%d\n", g_sys_conf.UserID[5]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO6=%d|%d|%d\n", g_sys_conf.no[5][0],g_sys_conf.no[5][1],g_sys_conf.no[5][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT6=%d\n", g_sys_conf.shoot[5]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + memset(buf, 0, 256); + sprintf(buf, "EXPO7=%d\n", g_sys_conf.expo[6]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN7=%d\n", g_sys_conf.gain[6]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "FILTER7=%d\n", g_sys_conf.filter[6]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "USERID7=%d\n", g_sys_conf.UserID[6]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO7=%d|%d|%d\n", g_sys_conf.no[6][0],g_sys_conf.no[6][1],g_sys_conf.no[6][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT7=%d\n", g_sys_conf.shoot[6]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + memset(buf, 0, 256); + sprintf(buf, "EXPO8=%d\n", g_sys_conf.expo[7]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "GAIN8=%d\n", g_sys_conf.gain[7]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "FILTER8=%d\n", g_sys_conf.filter[7]); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "USERID8=%d\n", g_sys_conf.UserID[7]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "NO8=%d|%d|%d\n", g_sys_conf.no[7][0],g_sys_conf.no[7][1],g_sys_conf.no[7][2]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "SHOOT8=%d\n", g_sys_conf.shoot[7]); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256); + sprintf(buf, "*****************************************\n"); + cfg_file.write(buf, strlen(buf)); +#endif + memset(buf, 0, 256); + sprintf(buf, "MonitorIP=%s\n", g_sys_conf.MonitorIP.c_str()); + cfg_file.write(buf, strlen(buf)); + + memset(buf, 0, 256); + cfg_file.write(buf, strlen(buf)); + sprintf(buf, "MonitorPort=%d\n", g_sys_conf.MonitorPort); + cfg_file.write(buf, strlen(buf)); + } + cfg_file.close(); +} + +#define InitPtrMatDef(a,b)\ + lineEdit_expo_mat[a]=ui.lineEdit_expo_##b; \ + lineEdit_gain_mat[a]=ui.lineEdit_gain_##b; \ + lineEdit_filter_mat[a]=ui.lineEdit_filter_##b; +void DialogSetup::InitPtrMat() +{ +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) + InitPtrMatDef(0, 1); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) + InitPtrMatDef(1, 2); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) + InitPtrMatDef(2, 3); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) + InitPtrMatDef(3, 4); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) + InitPtrMatDef(4, 5); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) + InitPtrMatDef(5, 6); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) + InitPtrMatDef(6, 7); +#endif +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) + InitPtrMatDef(7, 8); +#endif +} + +void DialogSetup::on_pushButton_config_released() +{ + if (m_camera_glue)delete m_camera_glue; + m_camera_glue = new camera_glue(this); + connect(m_camera_glue, &camera_glue::sendMsgToDialogSetup,this, &DialogSetup::recMsgFromDialogConfig); + connect(this, &DialogSetup::sendMsgToConfig,m_camera_glue, &camera_glue::recMsgFromDialogSetup); + m_camera_glue->show(); + m_camera_glue->move(this->geometry().center() - m_camera_glue->rect().center());//移动父窗口中心位置 + emit sendMsgToConfig(g_sys_conf.no); +} +void DialogSetup::recMsgFromDialogConfig(int ptr[][3]) +{ + for(int i=0;ishow(); + m_change_shift->move(this->geometry().center() - m_change_shift->rect().center()); + emit sendMsgToShift(g_sys_conf.shiftA, g_sys_conf.shiftB, g_sys_conf.shiftC); +} +void DialogSetup::on_pushButton_statistic_released() +{ + if (m_output_statistic)delete m_output_statistic; + m_output_statistic = new output_statistic(this); + connect(this, &DialogSetup::sendMsgToOutput, m_output_statistic, &output_statistic::recMsgFromDialogSetup); + m_output_statistic->show(); + m_output_statistic->move(this->geometry().center() - m_output_statistic->rect().center()); + emit sendMsgToOutput(); +} +void DialogSetup::recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC) +{ + g_sys_conf.shiftA.setHMS(timeA.hour(), timeA.minute(), 0); + g_sys_conf.shiftB.setHMS(timeB.hour(), timeB.minute(), 0); + g_sys_conf.shiftC.setHMS(timeC.hour(), timeC.minute(), 0); +} + diff --git a/Cigarette/dialogsetup.hpp b/Cigarette/dialogsetup.hpp new file mode 100644 index 0000000..64f4484 --- /dev/null +++ b/Cigarette/dialogsetup.hpp @@ -0,0 +1,57 @@ +#pragma once +#include +#include "ui_dialogsetup.h" +#include "basecamera.h" + +#include +#include +#include + +class DialogSetup : public QDialog { + Q_OBJECT +signals : + void system_exit(); + void sendMsgToShift(QTime timeA, QTime timeB, QTime timeC); + void sendMsgToOutput(); + void sendMsgToConfig(int ptr[][3]); + +private slots : + void on_toolButton_keyboard_released(); + void on_pushButton_exit_released(); + void on_pushButton_save_released(); + void on_pushButton_close_released(); + void on_toolButton_choose_path_released(); + void on_pushButton_desktop_released(); + void on_pushButton_image_released(); + void on_pushButton_pswd_released(); + void on_pushButton_pswd_op_released(); + void on_pushButton_expo_released(); + void on_pushButton_filter_released(); + + void on_pushButton_config_released(); + void on_pushButton_change_released(); + void on_pushButton_statistic_released(); + + void on_checkBox_auto_open_clicked(bool checked); + void on_checkBox_auto_work_clicked(bool checked); + + void recMsgFromDialogConfig(int ptr[][3]); + void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC); +public: + DialogSetup(QWidget * parent = Q_NULLPTR); + ~DialogSetup(); + QLineEdit *lineEdit_expo_mat[NumberOfSupportedCameras]; + QLineEdit *lineEdit_gain_mat[NumberOfSupportedCameras]; + QLineEdit *lineEdit_filter_mat[NumberOfSupportedCameras]; + void InitPtrMat(); + static void write_pswd(); + static void write_pswd_op(); + static void write_config(); + +public: + camera_glue *m_camera_glue=NULL; + change_shift *m_change_shift=NULL; + output_statistic *m_output_statistic=NULL; +private: + Ui::DialogSetup ui; +}; diff --git a/Cigarette/dialogsetup.ui b/Cigarette/dialogsetup.ui new file mode 100644 index 0000000..f07eaa2 --- /dev/null +++ b/Cigarette/dialogsetup.ui @@ -0,0 +1,1927 @@ + + + DialogSetup + + + + 0 + 0 + 719 + 819 + + + + + 微软雅黑 + 14 + 75 + true + + + + DialogSetup + + + background-color: rgb(240, 240, 240); + + + + + 0 + 10 + 716 + 819 + + + + + 0 + 0 + + + + true + + + + + 0 + 0 + 693 + 900 + + + + + 670 + 900 + + + + + + 10 + 60 + 641 + 61 + + + + + 微软雅黑 + 12 + 75 + true + + + + 启动设置 + + + + + 30 + 30 + 220 + 22 + + + + + 微软雅黑 + 12 + 75 + true + + + + 自动打开所有相机 + + + + + + 380 + 30 + 261 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 程序启动后自动开始工作 + + + + + + + 10 + 510 + 641 + 91 + + + + + 微软雅黑 + 12 + 75 + true + + + + 管理员密码修改 + + + + + 540 + 30 + 91 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确定 + + + + + + 190 + 40 + 61 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 新密码: + + + + + + 440 + 42 + 91 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 250 + 40 + 101 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 360 + 40 + 81 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确认密码: + + + + + + 90 + 40 + 91 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 20 + 40 + 61 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 原密码: + + + + + + + 10 + 180 + 640 + 278 + + + + + 微软雅黑 + 12 + 75 + true + + + + 相机参数 + + + + + 20 + 40 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 1#相机曝光时间(微秒): + + + + + + 210 + 40 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 210 + 70 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 20 + 70 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 2#相机曝光时间(微秒): + + + + + + 510 + 70 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 320 + 40 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 1#相机模拟增益(0~64): + + + + + + 320 + 70 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 2#相机模拟增益(0~64): + + + + + + 510 + 40 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 210 + 100 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 20 + 130 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 4#相机曝光时间(微秒): + + + + + + 210 + 130 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 20 + 100 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 3#相机曝光时间(微秒): + + + + + + 510 + 130 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 320 + 100 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 3#相机模拟增益(0~64): + + + + + + 320 + 130 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 4#相机模拟增益(0~64): + + + + + + 510 + 100 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 680 + 90 + 91 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确定 + + + + + + 20 + 160 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 5#相机曝光时间(微秒): + + + + + + 20 + 190 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 6#相机曝光时间(微秒): + + + + + + 20 + 220 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 7#相机曝光时间(微秒): + + + + + + 210 + 160 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 210 + 190 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 210 + 220 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 320 + 160 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 5#相机模拟增益(0~64): + + + + + + 320 + 190 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 6#相机模拟增益(0~64): + + + + + + 320 + 220 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 7#相机模拟增益(0~64): + + + + + + 510 + 160 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 510 + 190 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 510 + 220 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 20 + 250 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 8#相机曝光时间(微秒): + + + + + + 210 + 250 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 320 + 250 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 8#相机模拟增益(0~64): + + + + + + 510 + 250 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + + 10 + 690 + 641 + 148 + + + + + 微软雅黑 + 12 + 75 + true + + + + 滤波设置 + + + + + 20 + 30 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 1#相机滤波时间(微秒): + + + + + + 210 + 30 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 510 + 30 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 320 + 30 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 2#相机滤波时间(微秒): + + + + + + 510 + 60 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 20 + 60 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 3#相机滤波时间(微秒): + + + + + + 210 + 60 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 320 + 60 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 4#相机滤波时间(微秒): + + + + + + 680 + 50 + 91 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确定 + + + + + + 20 + 90 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 5#相机滤波时间(微秒): + + + + + + 320 + 90 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 6#相机滤波时间(微秒): + + + + + + 20 + 120 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 7#相机滤波时间(微秒): + + + + + + 320 + 120 + 180 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + 8#相机滤波时间(微秒): + + + + + + 210 + 90 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 210 + 120 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 510 + 90 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + 510 + 120 + 90 + 20 + + + + + 微软雅黑 + 10 + 75 + true + + + + + + + + + + + 10 + 120 + 641 + 61 + + + + + 微软雅黑 + 12 + 75 + true + + + + 存图设置 + + + + + 30 + 30 + 90 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 不存 + + + + + + 230 + 30 + 90 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 存NG + + + + + + 440 + 30 + 90 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 全存 + + + + + + 570 + 25 + 50 + 30 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确定 + + + + + + + 120 + 840 + 131 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 保存参数 + + + + + + 520 + 10 + 130 + 50 + + + + + 微软雅黑 + 12 + 75 + true + + + + 退出系统 + + + + + + 10 + 600 + 641 + 91 + + + + + 微软雅黑 + 12 + 75 + true + + + + 操作员密码修改 + + + + + 190 + 40 + 61 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 新密码: + + + + + + 440 + 42 + 91 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 250 + 40 + 101 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 360 + 40 + 81 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确认密码: + + + + + + 90 + 40 + 91 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + QLineEdit::Password + + + + + + 20 + 40 + 61 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + 原密码: + + + + + + 540 + 30 + 91 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 确定 + + + + + + + 380 + 840 + 131 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 关闭窗口 + + + + + + 220 + 10 + 130 + 50 + + + + + 微软雅黑 + 12 + 75 + true + + + + 显示桌面 + + + + + + 110 + 10 + 91 + 41 + + + + + 微软雅黑 + 12 + 75 + true + + + + border-image: url(:/Cigarette/Resources/keyboard.png); + + + + + + + + + 20 + 20 + 81 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + 系统设置 + + + + + + 10 + 465 + 101 + 41 + + + + + 微软雅黑 + 12 + 75 + true + + + + 配方设置 + + + + + + 120 + 465 + 111 + 41 + + + + + 微软雅黑 + 12 + 75 + true + + + + 换班设置 + + + + + + 240 + 465 + 91 + 41 + + + + + 微软雅黑 + 12 + 75 + true + + + + 产量统计 + + + + + + 620 + 472 + 27 + 26 + + + + + 微软雅黑 + + + + ... + + + + + + 340 + 475 + 91 + 21 + + + + + 微软雅黑 + 75 + true + + + + 模型存储路径 + + + + + + 440 + 472 + 171 + 25 + + + + + 微软雅黑 + + + + + + + + + + + + diff --git a/Cigarette/dialogsetuppasswd.cpp b/Cigarette/dialogsetuppasswd.cpp new file mode 100644 index 0000000..fa06833 --- /dev/null +++ b/Cigarette/dialogsetuppasswd.cpp @@ -0,0 +1,98 @@ +#include "dialogsetuppasswd.hpp" + +#include + +#include + +#include + +extern bool g_admin_mode; //是否管理员模式 +extern QString g_admin_pswd; //管理员密码 + +DialogSetupPasswd::DialogSetupPasswd(QWidget * parent) : QDialog(parent) { + ui.setupUi(this); + m_pswd = ""; + this->setWindowFlags(Qt::FramelessWindowHint); +} + +DialogSetupPasswd::~DialogSetupPasswd() { + +} + +void DialogSetupPasswd::on_pushButton_close_released() +{ + this->close(); +} +void DialogSetupPasswd::on_pushButton_clr_released() +{ + m_pswd = ""; + ui.lineEdit->setText(""); +} +void DialogSetupPasswd::on_pushButton_ok_released() +{ + QString md5Str = QCryptographicHash::hash(m_pswd.toLatin1(), QCryptographicHash::Md5).toHex(); + qDebug() << "m_pswd:" << m_pswd; + qDebug() << "m_pswd md5:" << md5Str; + qDebug() << "g_admin_pswd md5:" << g_admin_pswd; + if (md5Str.compare(g_admin_pswd, Qt::CaseInsensitive) == 0) + { + g_admin_mode = true; + //QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("验证通过,进入管理员模式"), QMessageBox::Ok); + emit enter_admin(); + this->close(); + } + else { + QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("密码错误,请重新输入"), QMessageBox::Ok); + on_pushButton_clr_released(); + } +} +void DialogSetupPasswd::on_pushButton_0_released() +{ + m_pswd += "0"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_1_released() +{ + m_pswd += "1"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_2_released() +{ + m_pswd += "2"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_3_released() +{ + m_pswd += "3"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_4_released() +{ + m_pswd += "4"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_5_released() +{ + m_pswd += "5"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_6_released() +{ + m_pswd += "6"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_7_released() +{ + m_pswd += "7"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_8_released() +{ + m_pswd += "8"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} +void DialogSetupPasswd::on_pushButton_9_released() +{ + m_pswd += "9"; + ui.lineEdit->setText(ui.lineEdit->text() + "*"); +} diff --git a/Cigarette/dialogsetuppasswd.hpp b/Cigarette/dialogsetuppasswd.hpp new file mode 100644 index 0000000..9ca27aa --- /dev/null +++ b/Cigarette/dialogsetuppasswd.hpp @@ -0,0 +1,35 @@ +#pragma once +#include +#include "ui_dialogsetuppasswd.h" + +class DialogSetupPasswd : public QDialog { + Q_OBJECT +signals : + void enter_admin(); + +public: + DialogSetupPasswd(QWidget * parent = Q_NULLPTR); + ~DialogSetupPasswd(); + +private slots : + void on_pushButton_close_released(); + void on_pushButton_clr_released(); + void on_pushButton_ok_released(); + void on_pushButton_0_released(); + void on_pushButton_1_released(); + void on_pushButton_2_released(); + void on_pushButton_3_released(); + void on_pushButton_4_released(); + void on_pushButton_5_released(); + void on_pushButton_6_released(); + void on_pushButton_7_released(); + void on_pushButton_8_released(); + void on_pushButton_9_released(); + + +public: + QString m_pswd; + +private: + Ui::DialogSetupPasswd ui; +}; diff --git a/Cigarette/dialogsetuppasswd.ui b/Cigarette/dialogsetuppasswd.ui new file mode 100644 index 0000000..2fee6aa --- /dev/null +++ b/Cigarette/dialogsetuppasswd.ui @@ -0,0 +1,338 @@ + + + DialogSetupPasswd + + + + 0 + 0 + 520 + 708 + + + + DialogSetupPasswd + + + background-color: rgb(220, 220, 220); + + + + + 210 + 310 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 5 + + + + + + 60 + 440 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 1 + + + + + + 60 + 570 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + CLR + + + + + + 360 + 570 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + OK + + + + + + 60 + 180 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 7 + + + + + + 210 + 570 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 0 + + + + + + 210 + 440 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 2 + + + + + + 40 + 90 + 441 + 61 + + + + + 微软雅黑 + 48 + 50 + false + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 60 + 310 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 4 + + + + + + 360 + 310 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 6 + + + + + + 210 + 180 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 8 + + + + + + 360 + 440 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 3 + + + + + + 360 + 180 + 100 + 100 + + + + + 微软雅黑 + 36 + 75 + true + + + + 9 + + + + + + 60 + 30 + 261 + 41 + + + + + 微软雅黑 + 20 + 75 + true + + + + 请输入管理员密码: + + + + + + 350 + 20 + 121 + 61 + + + + + 微软雅黑 + 28 + 75 + true + + + + 关闭 + + + + + + + diff --git a/Cigarette/hikcamera.cpp b/Cigarette/hikcamera.cpp new file mode 100644 index 0000000..1405ba5 --- /dev/null +++ b/Cigarette/hikcamera.cpp @@ -0,0 +1,38 @@ +#include "hikcamera.h" +#include +#include +#include + +MV_CC_DEVICE_INFO_LIST HIKCamera::stDeviceList; + +HIKCamera::HIKCamera(int DeviceNum) +{ + +} + + +HIKCamera::~HIKCamera() +{ + +} + +int HIKCamera::Enumerate() +{ + int status = 0; + + // ch:枚举设备 | Enum device + + memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST)); + + status = MV_CC_EnumDevices(MV_GIGE_DEVICE| MV_USB_DEVICE, &stDeviceList); + + if (MV_OK == status) + { + return stDeviceList.nDeviceNum; + } + else + { + return 0; + } + +} diff --git a/Cigarette/hikcamera.h b/Cigarette/hikcamera.h new file mode 100644 index 0000000..de998ad --- /dev/null +++ b/Cigarette/hikcamera.h @@ -0,0 +1,20 @@ +#pragma once +#include "SyncQueue.h" +#include "basecamera.h" +#include "MvCameraControl.h" +#include "CameraParams.h" + +#define HIKClassID 0x03 + +class HIKCamera: public BaseCamera +{ +public: + HIKCamera(int DeviceNum); + ~HIKCamera(); + + static int Enumerate(); + +public: + static MV_CC_DEVICE_INFO_LIST stDeviceList; + +}; diff --git a/Cigarette/main.cpp b/Cigarette/main.cpp new file mode 100644 index 0000000..e4b551d --- /dev/null +++ b/Cigarette/main.cpp @@ -0,0 +1,28 @@ +#include "cigarette.h" +#include +#include +#include +#if defined LICENSE_VERIFY +#pragma comment(lib,"CryptoToolLib.lib") +#include "CryptoToolLib.h" +#endif +int main(int argc, char *argv[]) +{ +#if defined LICENSE_VERIFY + if(!VerifyLicense(addtime)) + { + exit(0); + } +#endif + qRegisterMetaType("cv::Mat"); + QApplication a(argc, argv); + QPixmap pixmap("splash.jpg"); + QSplashScreen splash(pixmap); + splash.show(); + a.processEvents(); + Cigarette w; + //w.show(); + w.showFullScreen(); + splash.finish(&w); + return a.exec(); +} diff --git a/Cigarette/modbus/modbus-private.h b/Cigarette/modbus/modbus-private.h new file mode 100644 index 0000000..198baef --- /dev/null +++ b/Cigarette/modbus/modbus-private.h @@ -0,0 +1,116 @@ +/* + * Copyright © 2010-2012 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_PRIVATE_H +#define MODBUS_PRIVATE_H + +#ifndef _MSC_VER +# include +# include +#else +# include "stdint.h" +# include +typedef int ssize_t; +#endif +#include +#include + +#include "modbus.h" + +MODBUS_BEGIN_DECLS + +/* It's not really the minimal length (the real one is report slave ID + * in RTU (4 bytes)) but it's a convenient size to use in RTU or TCP + * communications to read many values or write a single one. + * Maximum between : + * - HEADER_LENGTH_TCP (7) + function (1) + address (2) + number (2) + * - HEADER_LENGTH_RTU (1) + function (1) + address (2) + number (2) + CRC (2) + */ +#define _MIN_REQ_LENGTH 12 + +#define _REPORT_SLAVE_ID 180 + +#define _MODBUS_EXCEPTION_RSP_LENGTH 5 + +/* Timeouts in microsecond (0.5 s) */ +#define _RESPONSE_TIMEOUT 500000 +#define _BYTE_TIMEOUT 500000 + +typedef enum { + _MODBUS_BACKEND_TYPE_RTU=0, + _MODBUS_BACKEND_TYPE_TCP +} modbus_backend_type_t; + +/* + * ---------- Request Indication ---------- + * | Client | ---------------------->| Server | + * ---------- Confirmation Response ---------- + */ +typedef enum { + /* Request message on the server side */ + MSG_INDICATION, + /* Request message on the client side */ + MSG_CONFIRMATION +} msg_type_t; + +/* This structure reduces the number of params in functions and so + * optimizes the speed of execution (~ 37%). */ +typedef struct _sft { + int slave; + int function; + int t_id; +} sft_t; + +typedef struct _modbus_backend { + unsigned int backend_type; + unsigned int header_length; + unsigned int checksum_length; + unsigned int max_adu_length; + int (*set_slave) (modbus_t *ctx, int slave); + int (*build_request_basis) (modbus_t *ctx, int function, int addr, + int nb, uint8_t *req); + int (*build_response_basis) (sft_t *sft, uint8_t *rsp); + int (*prepare_response_tid) (const uint8_t *req, int *req_length); + int (*send_msg_pre) (uint8_t *req, int req_length); + ssize_t (*send) (modbus_t *ctx, const uint8_t *req, int req_length); + int (*receive) (modbus_t *ctx, uint8_t *req); + ssize_t (*recv) (modbus_t *ctx, uint8_t *rsp, int rsp_length); + int (*check_integrity) (modbus_t *ctx, uint8_t *msg, + const int msg_length); + int (*pre_check_confirmation) (modbus_t *ctx, const uint8_t *req, + const uint8_t *rsp, int rsp_length); + int (*connect) (modbus_t *ctx); + void (*close) (modbus_t *ctx); + int (*flush) (modbus_t *ctx); + int (*select) (modbus_t *ctx, fd_set *rset, struct timeval *tv, int msg_length); + void (*free) (modbus_t *ctx); +} modbus_backend_t; + +struct _modbus { + /* Slave address */ + int slave; + /* Socket or file descriptor */ + int s; + int debug; + int error_recovery; + struct timeval response_timeout; + struct timeval byte_timeout; + struct timeval indication_timeout; + const modbus_backend_t *backend; + void *backend_data; +}; + +void _modbus_init_common(modbus_t *ctx); +void _error_print(modbus_t *ctx, const char *context); +int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type); + +#ifndef HAVE_STRLCPY +size_t strlcpy(char *dest, const char *src, size_t dest_size); +#endif + +MODBUS_END_DECLS + +#endif /* MODBUS_PRIVATE_H */ diff --git a/Cigarette/modbus/modbus-rtu-private.h b/Cigarette/modbus/modbus-rtu-private.h new file mode 100644 index 0000000..1c7d478 --- /dev/null +++ b/Cigarette/modbus/modbus-rtu-private.h @@ -0,0 +1,76 @@ +/* + * Copyright © 2001-2011 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_RTU_PRIVATE_H +#define MODBUS_RTU_PRIVATE_H + +#ifndef _MSC_VER +#include +#else +#include "stdint.h" +#endif + +#if defined(_WIN32) +#include +#else +#include +#endif + +#define _MODBUS_RTU_HEADER_LENGTH 1 +#define _MODBUS_RTU_PRESET_REQ_LENGTH 6 +#define _MODBUS_RTU_PRESET_RSP_LENGTH 2 + +#define _MODBUS_RTU_CHECKSUM_LENGTH 2 + +#if defined(_WIN32) +#if !defined(ENOTSUP) +#define ENOTSUP WSAEOPNOTSUPP +#endif + +/* WIN32: struct containing serial handle and a receive buffer */ +#define PY_BUF_SIZE 512 +struct win32_ser { + /* File handle */ + HANDLE fd; + /* Receive buffer */ + uint8_t buf[PY_BUF_SIZE]; + /* Received chars */ + DWORD n_bytes; +}; +#endif /* _WIN32 */ + +typedef struct _modbus_rtu { + /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*" on Mac OS X. */ + char *device; + /* Bauds: 9600, 19200, 57600, 115200, etc */ + int baud; + /* Data bit */ + uint8_t data_bit; + /* Stop bit */ + uint8_t stop_bit; + /* Parity: 'N', 'O', 'E' */ + char parity; +#if defined(_WIN32) + struct win32_ser w_ser; + DCB old_dcb; +#else + /* Save old termios settings */ + struct termios old_tios; +#endif +#if HAVE_DECL_TIOCSRS485 + int serial_mode; +#endif +#if HAVE_DECL_TIOCM_RTS + int rts; + int rts_delay; + int onebyte_time; + void (*set_rts) (modbus_t *ctx, int on); +#endif + /* To handle many slaves on the same link */ + int confirmation_to_ignore; +} modbus_rtu_t; + +#endif /* MODBUS_RTU_PRIVATE_H */ diff --git a/Cigarette/modbus/modbus-rtu.h b/Cigarette/modbus/modbus-rtu.h new file mode 100644 index 0000000..fa37655 --- /dev/null +++ b/Cigarette/modbus/modbus-rtu.h @@ -0,0 +1,42 @@ +/* + * Copyright © 2001-2011 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_RTU_H +#define MODBUS_RTU_H + +#include "modbus.h" + +MODBUS_BEGIN_DECLS + +/* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 + * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes + */ +#define MODBUS_RTU_MAX_ADU_LENGTH 256 + +MODBUS_API modbus_t* modbus_new_rtu(const char *device, int baud, char parity, + int data_bit, int stop_bit); + +#define MODBUS_RTU_RS232 0 +#define MODBUS_RTU_RS485 1 + +MODBUS_API int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode); +MODBUS_API int modbus_rtu_get_serial_mode(modbus_t *ctx); + +#define MODBUS_RTU_RTS_NONE 0 +#define MODBUS_RTU_RTS_UP 1 +#define MODBUS_RTU_RTS_DOWN 2 + +MODBUS_API int modbus_rtu_set_rts(modbus_t *ctx, int mode); +MODBUS_API int modbus_rtu_get_rts(modbus_t *ctx); + +MODBUS_API int modbus_rtu_set_custom_rts(modbus_t *ctx, void (*set_rts) (modbus_t *ctx, int on)); + +MODBUS_API int modbus_rtu_set_rts_delay(modbus_t *ctx, int us); +MODBUS_API int modbus_rtu_get_rts_delay(modbus_t *ctx); + +MODBUS_END_DECLS + +#endif /* MODBUS_RTU_H */ diff --git a/Cigarette/modbus/modbus-tcp-private.h b/Cigarette/modbus/modbus-tcp-private.h new file mode 100644 index 0000000..780587c --- /dev/null +++ b/Cigarette/modbus/modbus-tcp-private.h @@ -0,0 +1,44 @@ +/* + * Copyright © 2001-2011 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_TCP_PRIVATE_H +#define MODBUS_TCP_PRIVATE_H + +#define _MODBUS_TCP_HEADER_LENGTH 7 +#define _MODBUS_TCP_PRESET_REQ_LENGTH 12 +#define _MODBUS_TCP_PRESET_RSP_LENGTH 8 + +#define _MODBUS_TCP_CHECKSUM_LENGTH 0 + +/* In both structures, the transaction ID must be placed on first position + to have a quick access not dependant of the TCP backend */ +typedef struct _modbus_tcp { + /* Extract from MODBUS Messaging on TCP/IP Implementation Guide V1.0b + (page 23/46): + The transaction identifier is used to associate the future response + with the request. This identifier is unique on each TCP connection. */ + uint16_t t_id; + /* TCP port */ + int port; + /* IP address */ + char ip[16]; +} modbus_tcp_t; + +#define _MODBUS_TCP_PI_NODE_LENGTH 1025 +#define _MODBUS_TCP_PI_SERVICE_LENGTH 32 + +typedef struct _modbus_tcp_pi { + /* Transaction ID */ + uint16_t t_id; + /* TCP port */ + int port; + /* Node */ + char node[_MODBUS_TCP_PI_NODE_LENGTH]; + /* Service */ + char service[_MODBUS_TCP_PI_SERVICE_LENGTH]; +} modbus_tcp_pi_t; + +#endif /* MODBUS_TCP_PRIVATE_H */ diff --git a/Cigarette/modbus/modbus-tcp.h b/Cigarette/modbus/modbus-tcp.h new file mode 100644 index 0000000..d67c239 --- /dev/null +++ b/Cigarette/modbus/modbus-tcp.h @@ -0,0 +1,52 @@ +/* + * Copyright © 2001-2010 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_TCP_H +#define MODBUS_TCP_H + +#include "modbus.h" + +MODBUS_BEGIN_DECLS + +#if defined(_WIN32) && !defined(__CYGWIN__) +/* Win32 with MinGW, supplement to */ +#include +#if !defined(ECONNRESET) +#define ECONNRESET WSAECONNRESET +#endif +#if !defined(ECONNREFUSED) +#define ECONNREFUSED WSAECONNREFUSED +#endif +#if !defined(ETIMEDOUT) +#define ETIMEDOUT WSAETIMEDOUT +#endif +#if !defined(ENOPROTOOPT) +#define ENOPROTOOPT WSAENOPROTOOPT +#endif +#if !defined(EINPROGRESS) +#define EINPROGRESS WSAEINPROGRESS +#endif +#endif + +#define MODBUS_TCP_DEFAULT_PORT 502 +#define MODBUS_TCP_SLAVE 0xFF + +/* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 + * TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes + */ +#define MODBUS_TCP_MAX_ADU_LENGTH 260 + +MODBUS_API modbus_t* modbus_new_tcp(const char *ip_address, int port); +MODBUS_API int modbus_tcp_listen(modbus_t *ctx, int nb_connection); +MODBUS_API int modbus_tcp_accept(modbus_t *ctx, int *s); + +MODBUS_API modbus_t* modbus_new_tcp_pi(const char *node, const char *service); +MODBUS_API int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection); +MODBUS_API int modbus_tcp_pi_accept(modbus_t *ctx, int *s); + +MODBUS_END_DECLS + +#endif /* MODBUS_TCP_H */ diff --git a/Cigarette/modbus/modbus-version.h b/Cigarette/modbus/modbus-version.h new file mode 100644 index 0000000..0218973 --- /dev/null +++ b/Cigarette/modbus/modbus-version.h @@ -0,0 +1,53 @@ +/* + * Copyright © 2010-2014 Stéphane Raimbault + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MODBUS_VERSION_H +#define MODBUS_VERSION_H + +/* The major version, (1, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MAJOR (3) + +/* The minor version (2, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MINOR (1) + +/* The micro version (3, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MICRO (6) + +/* The full version, like 1.2.3 */ +#define LIBMODBUS_VERSION 3.1.6 + +/* The full version, in string form (suited for string concatenation) + */ +#define LIBMODBUS_VERSION_STRING "3.1.6" + +/* Numerically encoded version, eg. v1.2.3 is 0x010203 */ +#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_VERSION_MAJOR << 16) | \ + (LIBMODBUS_VERSION_MINOR << 8) | \ + (LIBMODBUS_VERSION_MICRO << 0)) + +/* Evaluates to True if the version is greater than @major, @minor and @micro + */ +#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \ + (LIBMODBUS_VERSION_MAJOR > (major) || \ + (LIBMODBUS_VERSION_MAJOR == (major) && \ + LIBMODBUS_VERSION_MINOR > (minor)) || \ + (LIBMODBUS_VERSION_MAJOR == (major) && \ + LIBMODBUS_VERSION_MINOR == (minor) && \ + LIBMODBUS_VERSION_MICRO >= (micro))) + +#endif /* MODBUS_VERSION_H */ diff --git a/Cigarette/modbus/modbus.h b/Cigarette/modbus/modbus.h new file mode 100644 index 0000000..24808ea --- /dev/null +++ b/Cigarette/modbus/modbus.h @@ -0,0 +1,297 @@ +/* + * Copyright © 2001-2013 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_H +#define MODBUS_H + +/* Add this for macros that defined unix flavor */ +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include +#endif + +#ifndef _MSC_VER +#include +#else +#include "stdint.h" +#endif + +#include "modbus-version.h" + +#if defined(_MSC_VER) +# if defined(DLLBUILD) +/* define DLLBUILD when building the DLL */ +# define MODBUS_API __declspec(dllexport) +# else +# define MODBUS_API __declspec(dllimport) +# endif +#else +# define MODBUS_API +#endif + +#ifdef __cplusplus +# define MODBUS_BEGIN_DECLS extern "C" { +# define MODBUS_END_DECLS } +#else +# define MODBUS_BEGIN_DECLS +# define MODBUS_END_DECLS +#endif + +MODBUS_BEGIN_DECLS + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef OFF +#define OFF 0 +#endif + +#ifndef ON +#define ON 1 +#endif + +/* Modbus function codes */ +#define MODBUS_FC_READ_COILS 0x01 +#define MODBUS_FC_READ_DISCRETE_INPUTS 0x02 +#define MODBUS_FC_READ_HOLDING_REGISTERS 0x03 +#define MODBUS_FC_READ_INPUT_REGISTERS 0x04 +#define MODBUS_FC_WRITE_SINGLE_COIL 0x05 +#define MODBUS_FC_WRITE_SINGLE_REGISTER 0x06 +#define MODBUS_FC_READ_EXCEPTION_STATUS 0x07 +#define MODBUS_FC_WRITE_MULTIPLE_COILS 0x0F +#define MODBUS_FC_WRITE_MULTIPLE_REGISTERS 0x10 +#define MODBUS_FC_REPORT_SLAVE_ID 0x11 +#define MODBUS_FC_MASK_WRITE_REGISTER 0x16 +#define MODBUS_FC_WRITE_AND_READ_REGISTERS 0x17 + +#define MODBUS_BROADCAST_ADDRESS 0 + +/* Modbus_Application_Protocol_V1_1b.pdf (chapter 6 section 1 page 12) + * Quantity of Coils to read (2 bytes): 1 to 2000 (0x7D0) + * (chapter 6 section 11 page 29) + * Quantity of Coils to write (2 bytes): 1 to 1968 (0x7B0) + */ +#define MODBUS_MAX_READ_BITS 2000 +#define MODBUS_MAX_WRITE_BITS 1968 + +/* Modbus_Application_Protocol_V1_1b.pdf (chapter 6 section 3 page 15) + * Quantity of Registers to read (2 bytes): 1 to 125 (0x7D) + * (chapter 6 section 12 page 31) + * Quantity of Registers to write (2 bytes) 1 to 123 (0x7B) + * (chapter 6 section 17 page 38) + * Quantity of Registers to write in R/W registers (2 bytes) 1 to 121 (0x79) + */ +#define MODBUS_MAX_READ_REGISTERS 125 +#define MODBUS_MAX_WRITE_REGISTERS 123 +#define MODBUS_MAX_WR_WRITE_REGISTERS 121 +#define MODBUS_MAX_WR_READ_REGISTERS 125 + +/* The size of the MODBUS PDU is limited by the size constraint inherited from + * the first MODBUS implementation on Serial Line network (max. RS485 ADU = 256 + * bytes). Therefore, MODBUS PDU for serial line communication = 256 - Server + * address (1 byte) - CRC (2 bytes) = 253 bytes. + */ +#define MODBUS_MAX_PDU_LENGTH 253 + +/* Consequently: + * - RTU MODBUS ADU = 253 bytes + Server address (1 byte) + CRC (2 bytes) = 256 + * bytes. + * - TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes. + * so the maximum of both backend in 260 bytes. This size can used to allocate + * an array of bytes to store responses and it will be compatible with the two + * backends. + */ +#define MODBUS_MAX_ADU_LENGTH 260 + +/* Random number to avoid errno conflicts */ +#define MODBUS_ENOBASE 112345678 + +/* Protocol exceptions */ +enum { + MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 0x01, + MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, + MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, + MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE, + MODBUS_EXCEPTION_ACKNOWLEDGE, + MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY, + MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE, + MODBUS_EXCEPTION_MEMORY_PARITY, + MODBUS_EXCEPTION_NOT_DEFINED, + MODBUS_EXCEPTION_GATEWAY_PATH, + MODBUS_EXCEPTION_GATEWAY_TARGET, + MODBUS_EXCEPTION_MAX +}; + +#define EMBXILFUN (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_FUNCTION) +#define EMBXILADD (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS) +#define EMBXILVAL (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE) +#define EMBXSFAIL (MODBUS_ENOBASE + MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE) +#define EMBXACK (MODBUS_ENOBASE + MODBUS_EXCEPTION_ACKNOWLEDGE) +#define EMBXSBUSY (MODBUS_ENOBASE + MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY) +#define EMBXNACK (MODBUS_ENOBASE + MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE) +#define EMBXMEMPAR (MODBUS_ENOBASE + MODBUS_EXCEPTION_MEMORY_PARITY) +#define EMBXGPATH (MODBUS_ENOBASE + MODBUS_EXCEPTION_GATEWAY_PATH) +#define EMBXGTAR (MODBUS_ENOBASE + MODBUS_EXCEPTION_GATEWAY_TARGET) + +/* Native libmodbus error codes */ +#define EMBBADCRC (EMBXGTAR + 1) +#define EMBBADDATA (EMBXGTAR + 2) +#define EMBBADEXC (EMBXGTAR + 3) +#define EMBUNKEXC (EMBXGTAR + 4) +#define EMBMDATA (EMBXGTAR + 5) +#define EMBBADSLAVE (EMBXGTAR + 6) + +extern const unsigned int libmodbus_version_major; +extern const unsigned int libmodbus_version_minor; +extern const unsigned int libmodbus_version_micro; + +typedef struct _modbus modbus_t; + +typedef struct _modbus_mapping_t { + int nb_bits; + int start_bits; + int nb_input_bits; + int start_input_bits; + int nb_input_registers; + int start_input_registers; + int nb_registers; + int start_registers; + uint8_t *tab_bits; + uint8_t *tab_input_bits; + uint16_t *tab_input_registers; + uint16_t *tab_registers; +} modbus_mapping_t; + +typedef enum +{ + MODBUS_ERROR_RECOVERY_NONE = 0, + MODBUS_ERROR_RECOVERY_LINK = (1<<1), + MODBUS_ERROR_RECOVERY_PROTOCOL = (1<<2) +} modbus_error_recovery_mode; + +MODBUS_API int modbus_set_slave(modbus_t* ctx, int slave); +MODBUS_API int modbus_get_slave(modbus_t* ctx); +MODBUS_API int modbus_set_error_recovery(modbus_t *ctx, modbus_error_recovery_mode error_recovery); +MODBUS_API int modbus_set_socket(modbus_t *ctx, int s); +MODBUS_API int modbus_get_socket(modbus_t *ctx); + +MODBUS_API int modbus_get_response_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); +MODBUS_API int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); + +MODBUS_API int modbus_get_byte_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); +MODBUS_API int modbus_set_byte_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); + +MODBUS_API int modbus_get_indication_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); +MODBUS_API int modbus_set_indication_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); + +MODBUS_API int modbus_get_header_length(modbus_t *ctx); + +MODBUS_API int modbus_connect(modbus_t *ctx); +MODBUS_API void modbus_close(modbus_t *ctx); + +MODBUS_API void modbus_free(modbus_t *ctx); + +MODBUS_API int modbus_flush(modbus_t *ctx); +MODBUS_API int modbus_set_debug(modbus_t *ctx, int flag); + +MODBUS_API const char *modbus_strerror(int errnum); + +MODBUS_API int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest); +MODBUS_API int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest); +MODBUS_API int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest); +MODBUS_API int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest); +MODBUS_API int modbus_write_bit(modbus_t *ctx, int coil_addr, int status); +MODBUS_API int modbus_write_register(modbus_t *ctx, int reg_addr, const uint16_t value); +MODBUS_API int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data); +MODBUS_API int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *data); +MODBUS_API int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and_mask, uint16_t or_mask); +MODBUS_API int modbus_write_and_read_registers(modbus_t *ctx, int write_addr, int write_nb, + const uint16_t *src, int read_addr, int read_nb, + uint16_t *dest); +MODBUS_API int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest); + +MODBUS_API modbus_mapping_t* modbus_mapping_new_start_address( + unsigned int start_bits, unsigned int nb_bits, + unsigned int start_input_bits, unsigned int nb_input_bits, + unsigned int start_registers, unsigned int nb_registers, + unsigned int start_input_registers, unsigned int nb_input_registers); + +MODBUS_API modbus_mapping_t* modbus_mapping_new(int nb_bits, int nb_input_bits, + int nb_registers, int nb_input_registers); +MODBUS_API void modbus_mapping_free(modbus_mapping_t *mb_mapping); + +MODBUS_API int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length); + +MODBUS_API int modbus_receive(modbus_t *ctx, uint8_t *req); + +MODBUS_API int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp); + +MODBUS_API int modbus_reply(modbus_t *ctx, const uint8_t *req, + int req_length, modbus_mapping_t *mb_mapping); +MODBUS_API int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, + unsigned int exception_code); + +/** + * UTILS FUNCTIONS + **/ + +#define MODBUS_GET_HIGH_BYTE(data) (((data) >> 8) & 0xFF) +#define MODBUS_GET_LOW_BYTE(data) ((data) & 0xFF) +#define MODBUS_GET_INT64_FROM_INT16(tab_int16, index) \ + (((int64_t)tab_int16[(index) ] << 48) | \ + ((int64_t)tab_int16[(index) + 1] << 32) | \ + ((int64_t)tab_int16[(index) + 2] << 16) | \ + (int64_t)tab_int16[(index) + 3]) +#define MODBUS_GET_INT32_FROM_INT16(tab_int16, index) \ + (((int32_t)tab_int16[(index) ] << 16) | \ + (int32_t)tab_int16[(index) + 1]) +#define MODBUS_GET_INT16_FROM_INT8(tab_int8, index) \ + (((int16_t)tab_int8[(index) ] << 8) | \ + (int16_t)tab_int8[(index) + 1]) +#define MODBUS_SET_INT16_TO_INT8(tab_int8, index, value) \ + do { \ + ((int8_t*)(tab_int8))[(index) ] = (int8_t)((value) >> 8); \ + ((int8_t*)(tab_int8))[(index) + 1] = (int8_t)(value); \ + } while (0) +#define MODBUS_SET_INT32_TO_INT16(tab_int16, index, value) \ + do { \ + ((int16_t*)(tab_int16))[(index) ] = (int16_t)((value) >> 16); \ + ((int16_t*)(tab_int16))[(index) + 1] = (int16_t)(value); \ + } while (0) +#define MODBUS_SET_INT64_TO_INT16(tab_int16, index, value) \ + do { \ + ((int16_t*)(tab_int16))[(index) ] = (int16_t)((value) >> 48); \ + ((int16_t*)(tab_int16))[(index) + 1] = (int16_t)((value) >> 32); \ + ((int16_t*)(tab_int16))[(index) + 2] = (int16_t)((value) >> 16); \ + ((int16_t*)(tab_int16))[(index) + 3] = (int16_t)(value); \ + } while (0) + +MODBUS_API void modbus_set_bits_from_byte(uint8_t *dest, int idx, const uint8_t value); +MODBUS_API void modbus_set_bits_from_bytes(uint8_t *dest, int idx, unsigned int nb_bits, + const uint8_t *tab_byte); +MODBUS_API uint8_t modbus_get_byte_from_bits(const uint8_t *src, int idx, unsigned int nb_bits); +MODBUS_API float modbus_get_float(const uint16_t *src); +MODBUS_API float modbus_get_float_abcd(const uint16_t *src); +MODBUS_API float modbus_get_float_dcba(const uint16_t *src); +MODBUS_API float modbus_get_float_badc(const uint16_t *src); +MODBUS_API float modbus_get_float_cdab(const uint16_t *src); + +MODBUS_API void modbus_set_float(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_abcd(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_dcba(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_badc(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_cdab(float f, uint16_t *dest); + +#include "modbus-tcp.h" +#include "modbus-rtu.h" + +MODBUS_END_DECLS + +#endif /* MODBUS_H */ diff --git a/Cigarette/modbus/modbus.lib b/Cigarette/modbus/modbus.lib new file mode 100644 index 0000000..1ac2089 Binary files /dev/null and b/Cigarette/modbus/modbus.lib differ diff --git a/Cigarette/output_statistic.cpp b/Cigarette/output_statistic.cpp new file mode 100644 index 0000000..8797015 --- /dev/null +++ b/Cigarette/output_statistic.cpp @@ -0,0 +1,75 @@ +#include "output_statistic.h" +#include "QtCore\qfile.h" +#include "QtCore\qtextstream.h" + +output_statistic::output_statistic(QDialog *parent) + : QDialog(parent) +{ + ui.setupUi(this); + this->setWindowFlags(windowFlags()&~Qt::WindowContextHelpButtonHint); +} + +output_statistic::~output_statistic() +{ +} + +void output_statistic::recMsgFromDialogSetup() +{ + QFile file("../conf/camera0_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_1->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera1_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_2->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera2_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_3->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera3_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_4->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera4_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_5->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera5_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_6->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera6_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_7->setText(in.readAll()); + } + file.close(); + file.setFileName("../conf/camera7_statistic.txt"); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + ui.textBrowser_8->setText(in.readAll()); + } + file.close(); + this->show(); +} diff --git a/Cigarette/output_statistic.h b/Cigarette/output_statistic.h new file mode 100644 index 0000000..c13bafa --- /dev/null +++ b/Cigarette/output_statistic.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "ui_output_statistic.h" + +class output_statistic : public QDialog +{ + Q_OBJECT + +public: + output_statistic(QDialog *parent = Q_NULLPTR); + ~output_statistic(); + +private: + Ui::output_statistic ui; + +public slots: + void recMsgFromDialogSetup(); +}; diff --git a/Cigarette/output_statistic.ui b/Cigarette/output_statistic.ui new file mode 100644 index 0000000..5e6a323 --- /dev/null +++ b/Cigarette/output_statistic.ui @@ -0,0 +1,126 @@ + + + output_statistic + + + + 0 + 0 + 810 + 390 + + + + 产量统计 + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 微软雅黑 + + + + 3 + + + + Camera1 + + + + + + + + + + Camera2 + + + + + + + + + + Camera3 + + + + + + + + + + Camera4 + + + + + + + + + + Camera5 + + + + + + + + + + Camera6 + + + + + + + + + + Camera7 + + + + + + + + + + Camera8 + + + + + + + + + + + + + + + + + + diff --git a/Cigarette/plc_item.cpp b/Cigarette/plc_item.cpp new file mode 100644 index 0000000..8edfe14 --- /dev/null +++ b/Cigarette/plc_item.cpp @@ -0,0 +1,12 @@ +#include "plc_item.h" + + + +PlcItem::PlcItem() +{ +} + + +PlcItem::~PlcItem() +{ +} diff --git a/Cigarette/plc_item.h b/Cigarette/plc_item.h new file mode 100644 index 0000000..163b594 --- /dev/null +++ b/Cigarette/plc_item.h @@ -0,0 +1,15 @@ +#pragma once +#include + +class PlcItem +{ +public: + PlcItem(); + ~PlcItem(); +public: + std::string func_desc; // + int address; //modbusַ + std::string memo; //ע + int value; //ʼֵ +}; + diff --git a/Cigarette/plcsetup.cpp b/Cigarette/plcsetup.cpp new file mode 100644 index 0000000..67c73d3 --- /dev/null +++ b/Cigarette/plcsetup.cpp @@ -0,0 +1,293 @@ +#include "plcsetup.hpp" +#include "common.h" +#include +#include +#include +#include +#include +#include +#include +#include "PLCDevice.h" +#define PLC_ITEM_FILE "../conf/plc.txt" + +extern PLCDevice * m_PLCDevice; + +extern bool g_plc_dialog_open; //是否打开plc配置对话框 + +void task_osk_() +{ + system("start /b C:\\Windows\\system32\\osk.exe"); +} + +PlcSetup::PlcSetup(QWidget * parent) : QDialog(parent) { + ui.setupUi(this); + this->setWindowFlags(Qt::FramelessWindowHint); + read_plc_items(); + ui.tableWidget->setColumnCount(7); + ui.tableWidget->setRowCount(m_plc_items.size()); + QStringList header_list; + header_list << QStringLiteral("功能描述") << QStringLiteral("读数值") + << QStringLiteral("读操作") << QStringLiteral("写数值") << QStringLiteral("写操作") << QStringLiteral("保存") << QStringLiteral("备注") ; + ui.tableWidget->setHorizontalHeaderLabels(header_list); + ui.tableWidget->setColumnWidth(0, 200); + ui.tableWidget->setColumnWidth(1, 100); + ui.tableWidget->setColumnWidth(2, 50); + ui.tableWidget->setColumnWidth(3, 100); + ui.tableWidget->setColumnWidth(4, 50); + ui.tableWidget->setColumnWidth(5, 50); + ui.tableWidget->setColumnWidth(6, 390); + ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); //禁止编辑 + for (int i = 0; i < m_plc_items.size(); i++) + { + ui.tableWidget->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit(m_plc_items[i].func_desc.c_str()))); + //ui.tableWidget->setItem(i, 1, new QTableWidgetItem(QString::number(m_plc_items[i].address))); + QPushButton * pBtnR = new QPushButton(); + pBtnR->setText(QStringLiteral("读")); + connect(pBtnR, SIGNAL(clicked(bool)), this, SLOT(click_read())); + ui.tableWidget->setCellWidget(i, 2, pBtnR); + + QLineEdit *edit = new QLineEdit(); + edit->setValidator(new QIntValidator(0, 100000, this)); + ui.tableWidget->setCellWidget(i, 3, edit); + + QPushButton * pBtnW = new QPushButton(); + pBtnW->setText(QStringLiteral("写")); + connect(pBtnW, SIGNAL(clicked(bool)), this, SLOT(click_write())); + ui.tableWidget->setCellWidget(i, 4, pBtnW); + + QPushButton * pBtnS = new QPushButton(); + pBtnS->setText(QStringLiteral("保存")); + connect(pBtnS, SIGNAL(clicked(bool)), this, SLOT(click_save())); + ui.tableWidget->setCellWidget(i, 5, pBtnS); + + ui.tableWidget->setItem(i, 6, new QTableWidgetItem(QString::fromLocal8Bit(m_plc_items[i].memo.c_str()))); + } + m_pTimer = new QTimer(this); + connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout())); + m_pTimer->setSingleShot(true); + m_pTimer->start(1000); +} + +PlcSetup::~PlcSetup() { + +} + +void PlcSetup::click_read() +{ + QPushButton *pushButton_ = dynamic_cast(this->sender()); + if (NULL == pushButton_) + { + return; + } + int x = pushButton_->frameGeometry().x(); + int y = pushButton_->frameGeometry().y(); + QModelIndex index = ui.tableWidget->indexAt(QPoint(x, y)); + int row = index.row(); + int column = index.column(); + + int addr = m_plc_items[row].address; + + uint8_t dest[4]; + uint16_t * dest16 = (uint16_t *)dest; + memset(dest, 0, 4); + if (addr > 0) + { + if (addr < 40000) //读取线圈值 bit + { + int ret = m_PLCDevice->read_bits_from_plc(addr, 1, dest); + ui.tableWidget->setItem(row, 1, new QTableWidgetItem(QString::number(dest[0]))); + } + else { //读取DWORD值,4字节 + int ret = m_PLCDevice->read_short_from_plc( addr, 2, dest16); + //printf("%x ", dest16[0]); + //printf("%x \n", dest16[1]); + //printf("%d \n", dest16[0] + (dest16[1] << 16)); + ui.tableWidget->setItem(row, 1, new QTableWidgetItem(QString::number(dest16[0] + (dest16[1] << 16)))); + } + } +} + +void PlcSetup::click_write() +{ + QPushButton *pushButton_ = dynamic_cast(this->sender()); + if (NULL == pushButton_) + { + return; + } + int x = pushButton_->frameGeometry().x(); + int y = pushButton_->frameGeometry().y(); + QModelIndex index = ui.tableWidget->indexAt(QPoint(x, y)); + int row = index.row(); + int column = index.column(); + //std::cout << "row:" << row << "\tcol:" << column << std::endl; + + int addr = m_plc_items[row].address; + QWidget *widget=ui.tableWidget->cellWidget(row,3); + QLineEdit *edit=(QLineEdit*)widget; + QString d = edit->text(); + uint8_t dest[4]; + uint16_t * dest16 = (uint16_t *)dest; + memset(dest, 0, 4); + if (d.length() > 0) + { + int data = d.toInt(); + if (addr > 0) + { + if (addr < 40000) //写入线圈值 bit + { + if (data != 0) data = 1; + int ret = m_PLCDevice->write_bit_2_plc( addr, data); + } + else { //写入DWORD值,4字节 + dest16[0] = (data & 0xffff); + dest16[1] = (data>>16); + int ret = m_PLCDevice->write_short_2_plc(addr, 2, dest16); + } + } + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("写入成功"), QMessageBox::Ok); + } +} + +void PlcSetup::click_save() +{ + QPushButton *pushButton_ = dynamic_cast(this->sender()); + if (NULL == pushButton_) + { + return; + } + int x = pushButton_->frameGeometry().x(); + int y = pushButton_->frameGeometry().y(); + QModelIndex index = ui.tableWidget->indexAt(QPoint(x, y)); + int row = index.row(); + int column = index.column(); + //std::cout << "row:" << row << "\tcol:" << column << std::endl; + + int addr = m_plc_items[row].address; + QWidget *widget = ui.tableWidget->cellWidget(row, 3); + QLineEdit *edit = (QLineEdit*)widget; + QString d = edit->text(); + uint8_t dest[4]; + uint16_t * dest16 = (uint16_t *)dest; + memset(dest, 0, 4); + if (d.length() > 0) + { + int data = d.toInt(); + if (addr > 0) + { + if (addr < 40000) //写入线圈值 bit + { + if (data != 0) data = 1; + int ret = m_PLCDevice->write_bit_2_plc( addr, data); + } + else { //写入DWORD值,4字节 + dest16[0] = (data & 0xffff); + dest16[1] = (data >> 16); + int ret = m_PLCDevice->write_short_2_plc(addr, 2, dest16); + } + } + //int data = d.toInt(); + for (int i = 0; i < m_plc_items.size(); i++) + { + //std::cout << m_plc_items[i].address << std::endl; + if (m_plc_items[i].address == addr) + { + //std::cout << "Hit" << addr << std::endl; + m_plc_items[i].value = data; + //std::cout << "SAVE start" << std::endl; + save_plc_items(); + //std::cout << "SAVE END" << std::endl; + QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("写入并且保存成功"), QMessageBox::Ok); + break; + } + } + } +} + +void PlcSetup::on_toolButton_batch_read_released() +{ + for (int i = 0; i < m_plc_items.size(); i++) + { + int addr = m_plc_items[i].address; + uint8_t dest[4]; + uint16_t * dest16 = (uint16_t *)dest; + memset(dest, 0, 4); + if (addr > 0) + { + if (addr < 40000) //读取线圈值 bit + { + int ret = m_PLCDevice->read_bits_from_plc(addr, 1, dest); + ui.tableWidget->setItem(i, 1, new QTableWidgetItem(QString::number(dest[0]))); + } + else { //读取DWORD值,4字节 + int ret = m_PLCDevice->read_short_from_plc( addr, 2, dest16); + ui.tableWidget->setItem(i, 1, new QTableWidgetItem(QString::number(dest16[0] + (dest16[1] << 16)))); + } + } + } +} +void PlcSetup::on_toolButton_keyboard_released() +{ + std::thread osk_thread = std::thread(task_osk_); + osk_thread.detach(); +} +void PlcSetup::on_toolButton_close_released() +{ + g_plc_dialog_open = false; + this->close(); +} + +void PlcSetup::handleTimeout() +{ + on_toolButton_batch_read_released(); +} + +void PlcSetup::read_plc_items() +{ + std::fstream cfg_file; + cfg_file.open(PLC_ITEM_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open production file " << PLC_ITEM_FILE << std::endl; + return; + } + while (!cfg_file.eof()) + { + char tmp[1024] = ""; + cfg_file.getline(tmp, 1024); + std::string line(tmp); + std::cout << line << std::endl; + if (line.length() > 0) + { + std::vector vec_info; + string_split(line, "|", vec_info); + if (vec_info.size() == 4) + { + PlcItem plc_item; + plc_item.func_desc = vec_info[0]; + plc_item.address = atoi(vec_info[1].c_str()); + plc_item.value = atoi(vec_info[2].c_str()); + plc_item.memo = vec_info[3]; + m_plc_items.push_back(plc_item); + } + } + } + cfg_file.close(); +} + +void PlcSetup::save_plc_items() +{ + std::fstream cfg_file; + cfg_file.open(PLC_ITEM_FILE, std::ios::out | std::ios::trunc); + if (cfg_file.good()) + { + for (int i = 0; i < m_plc_items.size(); i++) + { + char buf[512]; + memset(buf, 0, 512); + sprintf(buf, "%s|%d|%d|%s\n", m_plc_items[i].func_desc.c_str(), + m_plc_items[i].address, m_plc_items[i].value, m_plc_items[i].memo.c_str()); + cfg_file.write(buf, strlen(buf)); + } + cfg_file.close(); + } +} diff --git a/Cigarette/plcsetup.hpp b/Cigarette/plcsetup.hpp new file mode 100644 index 0000000..530d370 --- /dev/null +++ b/Cigarette/plcsetup.hpp @@ -0,0 +1,39 @@ +#pragma once +#include +#include +#include "ui_plcsetup.h" +#include "plc_item.h" +#include +#include +#include +#include "modbus.h" + +class QTimer; + +class PlcSetup : public QDialog { + Q_OBJECT + +public: + PlcSetup(QWidget * parent = Q_NULLPTR); + ~PlcSetup(); + + QTimer *m_pTimer; + + void read_plc_items(); + void save_plc_items(); +private slots: + void click_read(); + void click_write(); + void click_save(); + + void on_toolButton_batch_read_released(); + void on_toolButton_keyboard_released(); + void on_toolButton_close_released(); + + void handleTimeout(); //窗口加载时执行一次,批处理读取所有地址 + +private: + Ui::PlcSetup ui; + + std::vector m_plc_items; +}; diff --git a/Cigarette/plcsetup.ui b/Cigarette/plcsetup.ui new file mode 100644 index 0000000..1ff2921 --- /dev/null +++ b/Cigarette/plcsetup.ui @@ -0,0 +1,128 @@ + + + PlcSetup + + + + 0 + 0 + 1000 + 700 + + + + + 微软雅黑 + 12 + + + + PLC设置 + + + background-color: rgb(220, 220, 220); + + + + + 30 + 80 + 940 + 590 + + + + + + + 40 + 30 + 101 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + PLC寄存器 + + + + + + 180 + 20 + 101 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 批量读取 + + + + + + 840 + 20 + 101 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + 关闭窗口 + + + + + + 520 + 20 + 91 + 51 + + + + + 微软雅黑 + 12 + 75 + true + + + + border-image: url(:/Cigarette/Resources/keyboard.png); + + + + + + + + + + + + diff --git a/Cigarette/pswd.txt b/Cigarette/pswd.txt new file mode 100644 index 0000000..e781305 --- /dev/null +++ b/Cigarette/pswd.txt @@ -0,0 +1 @@ +d41d8cd98f00b204e9800998ecf8427e \ No newline at end of file diff --git a/Cigarette/pswd_op.txt b/Cigarette/pswd_op.txt new file mode 100644 index 0000000..e781305 --- /dev/null +++ b/Cigarette/pswd_op.txt @@ -0,0 +1 @@ +d41d8cd98f00b204e9800998ecf8427e \ No newline at end of file diff --git a/Cigarette/savethread.h b/Cigarette/savethread.h new file mode 100644 index 0000000..1775e25 --- /dev/null +++ b/Cigarette/savethread.h @@ -0,0 +1,94 @@ +#ifndef SAVE_THREAD_H +#define SAVE_THREAD_H +#include +#include +#include +#include "SyncQueue.h" +#include "common.h" +#include +#include +#include + +#include + +#include +#include + +extern SyncQueue > *g_save_queue; //ͼ񱣴 + +class SaveThread : public QThread +{ + Q_OBJECT +signals: + + +public: + SaveThread(QObject *parent = 0): QThread(parent) + { + + } + ~SaveThread() + { + stop(); + g_save_queue->put(std::make_pair("", cv::Mat())); + quit(); + wait(); + } + + void init() + { + b_quit = false; + } + void start_work() + { + start(HighestPriority); + } + void stop() + { + b_quit = true; + } +protected: + void run() + { + while (!b_quit) { + cv::Mat image; + std::pair element; + g_save_queue->take(element); + std::string file_name = element.first; + //std::cout << file_name << std::endl; + image = element.second; + if (image.data) + { + std::size_t found = file_name.find_last_of("/\\"); + std::string dir_path = file_name.substr(0, found); + check_save_dir(dir_path); + bool b_save = cv::imwrite(file_name, image); + } + } + } + void check_save_dir(std::string dir_path) + { + bool b_find = false; + for (int i = 0; i < vec_save_dirs.size(); i++) + { + if (dir_path == vec_save_dirs[i]) + { + b_find = true; + } + } + if (!b_find) + { + QString dir_str = QString::fromStdString(dir_path); + QDir dir; + if (!dir.exists(dir_str)) + { + dir.mkpath(dir_str); + } + vec_save_dirs.push_back(dir_path); + } + } +public: + bool b_quit; + std::vector vec_save_dirs; +}; +#endif diff --git a/Cigarette/splash.jpg b/Cigarette/splash.jpg new file mode 100644 index 0000000..4c3d9ed Binary files /dev/null and b/Cigarette/splash.jpg differ diff --git a/Cigarette/threadReceive.cpp b/Cigarette/threadReceive.cpp new file mode 100644 index 0000000..767cb58 --- /dev/null +++ b/Cigarette/threadReceive.cpp @@ -0,0 +1,89 @@ +#include "threadReceive.h" +#include "cigarette.h" +#include "basecamera.h" +void threadReceive::start_work() +{ + //start(HighestPriority); + start(); +} + +void threadReceive::stop() +{ + isLoop = false; + BOOL bDontLinger = FALSE; + mSocket->abort(); + filemSocket->abort(); + // wait(); +} + +void threadReceive::init(std::string IP,int port) +{ + ip = QString::fromStdString(IP); + + mSocket = new QUdpSocket(this); + mSocket->bind(port + NumberOfSupportedCameras*2+1, QUdpSocket::ShareAddress); + connect(mSocket, &QUdpSocket::readyRead, this, &threadReceive::processPendingDatagram); + + filemSocket = new QUdpSocket(this); + filemSocket->bind(port + NumberOfSupportedCameras*2+2, QUdpSocket::ShareAddress); + connect(filemSocket, &QUdpSocket::readyRead, this, &threadReceive::fileprocessPendingDatagram); +} + +void threadReceive::processPendingDatagram() +{ + // ӵеȴݱ + while (mSocket->hasPendingDatagrams()) + { + QByteArray datagram; + + // datagramĴСΪȴݱĴСܽյ + datagram.resize(mSocket->pendingDatagramSize()); + + // ݱŵdatagram + mSocket->readDatagram(datagram.data(), datagram.size()); + QString data = datagram; + + emit sendMsgToCigratte(data); + } +} + +void threadReceive::fileprocessPendingDatagram() +{ + QString filename; + std::fstream file; + // ӵеȴݱ + while (filemSocket->hasPendingDatagrams()) + { + QByteArray datagram; + // datagramĴСΪȴݱĴСܽյ + datagram.resize(filemSocket->pendingDatagramSize()); + + // ݱŵdatagram + filemSocket->readDatagram(datagram.data(), datagram.size()); + QString data = datagram; + + QString str = data.mid(0, 4); + if (str == "SYNC") + { + str = data.mid(4, 3); + if (str == "str") + { + filename = data.mid(7, data.length() - 7); + file.open(("../conf/" + filename.toStdString()).c_str(), std::ios::out | std::ios::trunc | ios::binary); + } + else if (str == "con") + { + str = data.mid(7, data.length() - 7); + if (file.is_open()) + { + file.write(str.toStdString().c_str(), str.toStdString().size()); + } + } + else if (str == "end") + { + str = data.mid(7, data.length() - 7); + file.close(); + } + } + } +} \ No newline at end of file diff --git a/Cigarette/threadReceive.h b/Cigarette/threadReceive.h new file mode 100644 index 0000000..15173be --- /dev/null +++ b/Cigarette/threadReceive.h @@ -0,0 +1,45 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "SyncQueue.h" + +#include + +class threadReceive : public QThread +{ + Q_OBJECT +public: + QString ip; + threadReceive(QObject* o = nullptr) :QThread(o) + { + isLoop = true; + } + + ~threadReceive() + { + stop(); + quit(); + wait(); + } + void stop(); + void init(std::string IP,int port); + void start_work(); + +private slots: + void processPendingDatagram(); + void fileprocessPendingDatagram(); + +signals: + void sendMsgToCigratte(QString data); + +public: + std::atomic_bool isLoop = { 0 }; + QUdpSocket *mSocket; + QUdpSocket *filemSocket; +}; diff --git a/Cigarette/threadSend.cpp b/Cigarette/threadSend.cpp new file mode 100644 index 0000000..0fb1144 --- /dev/null +++ b/Cigarette/threadSend.cpp @@ -0,0 +1,174 @@ +#include "threadSend.h" +#include +#include "basecamera.h" +#include +#include +void threadSend::init(SyncQueue<_UDPSendInfo> *p_UDP_Info_queue,std::string IP,int port) +{ + ip = QString::fromStdString(IP); + dataport = port; + imageport = port+NumberOfSupportedCameras; + Local_UDP_Info_queue = p_UDP_Info_queue; + qDebug() << "MonitorIP ip:"<take(UDPSendInfo); + switch(UDPSendInfo.FrameID){ + case info_frame:{ + sendData(&UDPSendInfo, dataport); + break; + } + case speed_frame:{ + sendSpeed(&UDPSendInfo, dataport); + break; + } + case kick_frame:{ + sendKick(&UDPSendInfo, dataport); + break; + } + case ok_frame:{ + sendOK(&UDPSendInfo, dataport); + break; + } + case ng_frame:{ + sendNG(&UDPSendInfo, dataport); + break; + } + case total_frame:{ + sendTotal(&UDPSendInfo, dataport); + break; + } + case image_frame:{ + sendImage(&UDPSendInfo,imageport); + break; + } + } + } +} + +void threadSend::sendData(_UDPSendInfo *UDPSendInfo,int port) +{ + + QString res = QString("%1_%2_%3") + .arg(QString::number(UDPSendInfo->FrameID)) + .arg(UDPSendInfo->JD) + .arg(UDPSendInfo->timecost); + mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); +} + +void threadSend::sendData(QString data, int port) +{ + mSocket.writeDatagram(data.toUtf8(), QHostAddress(ip), port); +} + +void threadSend::sendImage(_UDPSendInfo *UDPSendInfo,int port) +{ + cv::Mat mat = UDPSendInfo->image; + char cnt = UDPSendInfo->cnt; + + cv::resize(mat, mat, cv::Size(image_width, image_heigh)); + int length = image_width * image_heigh * 3; + + char* data = (char*)malloc(sizeof(char) * length + 1); + if (data) + { + memcpy(data, &cnt, 1); + memcpy(data+1, mat.data, length); + int ret=mSocket.writeDatagram((char*)data, length+1, QHostAddress(ip), port + UDPSendInfo->index); + free(data); + } +} + +void threadSend::sendSpeed(_UDPSendInfo *UDPSendInfo,int port) +{ + QString res = QString("%1_%2") + .arg(QString::number(UDPSendInfo->FrameID)) + .arg(UDPSendInfo->speed); + mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); +} + +void threadSend::sendKick(_UDPSendInfo *UDPSendInfo,int port) +{ + QString res = QString("%1_%2") + .arg(QString::number(UDPSendInfo->FrameID)) + .arg(QString::number(UDPSendInfo->Kick[UDPSendInfo->index])); + mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); +} + +void threadSend::sendOK(_UDPSendInfo *UDPSendInfo,int port) +{ + QString res = QString("%1_%2") + .arg(QString::number(UDPSendInfo->FrameID)) + .arg(QString::number(UDPSendInfo->ok)); + mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); +} + +void threadSend::sendNG(_UDPSendInfo *UDPSendInfo,int port) +{ + QString res = QString("%1_%2") + .arg(QString::number(UDPSendInfo->FrameID)) + .arg(QString::number(UDPSendInfo->ng)); + mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); +} + +void threadSend::sendTotal(_UDPSendInfo *UDPSendInfo,int port) +{ + QString res = QString("%1_%2") + .arg(QString::number(UDPSendInfo->FrameID)) + .arg(QString::number(UDPSendInfo->Total)); + mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index); +} + +void threadSend::sendFile(QString FilePath, int port) +{ + QFileInfo info(FilePath); + QString filename = info.fileName(); + QFile file(FilePath); + if (file.size() > 0) { + bool isOk = file.open(QIODevice::ReadOnly); + if (false == isOk) { + return ; + } + } + else { + return ; + } + QString sync("SYNC"); + if (!file.atEnd()) { + QString FileStartFrame(sync); + FileStartFrame.append("str"); + FileStartFrame.append(filename); + mSocket.writeDatagram(FileStartFrame.toLatin1(), QHostAddress(ip), port); + } + + msleep(10); + while (!file.atEnd()) {//文件指针 + QString FileFrame(sync); + FileFrame.append("con"); + QByteArray line = FileFrame.toLatin1() + file.read(1000); + mSocket.writeDatagram(line, QHostAddress(ip), port); + msleep(10); + } + + QString FileEndFrame(sync); + FileEndFrame.append("end");//结尾标志 + FileEndFrame.append(QString::number(file.size()));//文件大小 + mSocket.writeDatagram(FileEndFrame.toLatin1(), QHostAddress(ip), port); + file.close(); +} \ No newline at end of file diff --git a/Cigarette/threadSend.h b/Cigarette/threadSend.h new file mode 100644 index 0000000..b7c8924 --- /dev/null +++ b/Cigarette/threadSend.h @@ -0,0 +1,96 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "SyncQueue.h" + +#include + +#define image_width 80 +#define image_heigh 60 + +#define info_frame 1 +#define speed_frame 2 +#define kick_frame 3 +#define ok_frame 4 +#define ng_frame 5 +#define image_frame 6 +#define total_frame 7 + +class _UDPSendInfo +{ +public: + int FrameID; + int index; + cv::Mat image; + int cnt; + long Total; + QString JD; + QString timecost; + int ok; + int ng; + QString speed; + int Kick[NumberOfSupportedCameras]; + + _UDPSendInfo() + { + FrameID = 0; + index = 0; + image = cv::Mat(image_width, image_heigh, CV_8UC3, cv::Scalar(0,0,0)); + Total = 0; + JD = QString("0,0,0"); + timecost = QString("0ms");; + ok = false; + ng = false; + speed = QString(" "); + for(int i=0;iput(UDPSendInfo); + quit(); + wait(); + } + void stop(); + +protected: + void run(); + +public: + void init(SyncQueue<_UDPSendInfo> *p_UDP_Info_queue,std::string IP,int port); + void start_work(); + + void sendData(_UDPSendInfo *UDPSendInfo,int port); + void sendData(QString data, int port); + void sendImage(_UDPSendInfo *UDPSendInfo,int port); + void sendSpeed(_UDPSendInfo *UDPSendInfo,int port); + void sendKick(_UDPSendInfo *UDPSendInfo,int port); + void sendOK(_UDPSendInfo *UDPSendInfo,int port); + void sendNG(_UDPSendInfo *UDPSendInfo,int port); + void sendTotal(_UDPSendInfo *UDPSendInfo,int port); + void sendFile(QString FilePath, int port); +public: + SyncQueue<_UDPSendInfo> *Local_UDP_Info_queue; + std::atomic_bool isLoop = { 0 }; + QUdpSocket mSocket; +}; diff --git a/Cigarette/three test.jpg b/Cigarette/three test.jpg new file mode 100644 index 0000000..d1d32c2 Binary files /dev/null and b/Cigarette/three test.jpg differ diff --git a/Cigarette/workthread.cpp b/Cigarette/workthread.cpp new file mode 100644 index 0000000..835212e --- /dev/null +++ b/Cigarette/workthread.cpp @@ -0,0 +1,224 @@ +#include "workthread.h" +#include "alg_jd.h" +#include "common.h" +#include "balluffcamera.h" +#include "baslercamera.h" +#include "threadSend.h" +#include +extern AlgJd alg_jd[NumberOfSupportedCameras]; //⽺AI㷨 + +extern SysConf g_sys_conf; //ϵͳò +extern DisplayLabelConf g_display_label_conf[NumberOfSupportedCameras]; + +extern int rotationAngle[NumberOfSupportedCameras]; //ͼƬתǶ +extern bool isNeddRotate[NumberOfSupportedCameras]; + +extern SyncQueue >* g_save_queue; //ͼƬ +extern SyncQueue >* g_image_queue[NumberOfSupportedCameras]; //intʾһĿ˼ +extern SyncQueue<_UDPSendInfo> *UDP_Info_queue; +extern PLCDevice* m_PLCDevice; +WorkThread::~WorkThread() +{ + stop(); + local_g_image_queue->put(std::make_pair(0, cv::Mat())); + quit(); + wait(); +} + +void WorkThread::init(SyncQueue>* image_ptr, ASyncQueue* result_ptr, int classid, int Num) +{ + local_camera_number = Num; + local_classid = classid; + local_g_image_queue = image_ptr; + local_g_result_queue = result_ptr; + b_quit = false; + frame_total = 0; +} +void WorkThread::start_work() +{ + start(HighestPriority); +} +void WorkThread::stop() +{ + b_quit = true; +} + +void WorkThread::run() +{ + try{ + uint32_t result_index = 0; + while (!b_quit) { + {//Ҫɾţ + std::lock_guard locker(g_sys_conf.lock); + local_SysConf.save = g_sys_conf.save; + local_SysConf.shoot[local_camera_number] = g_sys_conf.shoot[local_camera_number]; + local_SysConf.MisMatchAct = g_sys_conf.MisMatchAct; + for (int i = 0; i < 3; i++)local_SysConf.no[local_camera_number][i] = g_sys_conf.no[local_camera_number][i]; + + std::lock_guard locker2(g_display_label_conf[local_camera_number].lock); + local_DisplayLabelConf.leftButtonDownFlag = g_display_label_conf[local_camera_number].leftButtonDownFlag; + local_DisplayLabelConf.Flag[0] = g_display_label_conf[local_camera_number].Flag[0]; + local_DisplayLabelConf.Flag[1] = g_display_label_conf[local_camera_number].Flag[1]; + local_DisplayLabelConf.originalPoint = g_display_label_conf[local_camera_number].originalPoint; + local_DisplayLabelConf.processPoint = g_display_label_conf[local_camera_number].processPoint; + local_DisplayLabelConf.RectVet[0] = g_display_label_conf[local_camera_number].RectVet[0]; + local_DisplayLabelConf.RectVet[1] = g_display_label_conf[local_camera_number].RectVet[1]; + } + QDateTime now_ts = QDateTime::currentDateTime(); + std::pair element; + local_g_image_queue->take(element); + int unit_count = element.first; + cv::Mat image = element.second; + + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = info_frame; + UDPSendInfo.index = local_camera_number; + if (!image.data) + { + continue; //ͼΪգ + } + if (image.channels() == 1) + { + cv::cvtColor(image, image, CV_BGR2RGB); //ҶͼתΪɫͼ + } + if (local_SysConf.shoot[local_camera_number] == unit_count) + { + std::vector vec_in; + int w = image.cols; + int h = image.rows / unit_count; + for(int index=0;index vec_out; + std::vector > > vec_results; + QDateTime ts_start = QDateTime::currentDateTime(); + if(unit_count == 1){ + std::vector > results; + cv::Mat imagein,imageout; + imagein = vec_in[0]; + alg_jd[local_camera_number].detect(imagein, imageout, results); + vec_out.push_back(imageout.clone()); + vec_results.push_back(results); + }else{ + alg_jd[local_camera_number].detect_batch(vec_in, vec_out, vec_results); + } + QDateTime ts_jd = QDateTime::currentDateTime(); + int time_process = ts_start.msecsTo(ts_jd); + emit display_timecost(local_camera_number, time_process); + UDPSendInfo.timecost = QString::number(time_process); + + cv::Mat image1; + cv::Mat image2; + + QString jd_no; + for(int index=0;indexput(std::make_pair(file_name.toStdString(), m)); + } + } + + if (unit_count >= 2){ + image1 = vec_out[(result_index) % 2].clone(); + IsNG|=CheckSelectRects(image1,vec_results,(result_index) % 2,local_DisplayLabelConf,0); + }else { + image1 = vec_out[0].clone(); + IsNG|=CheckSelectRects(image1,vec_results,0,local_DisplayLabelConf,0); + } + DrawSelectRects(image1, local_DisplayLabelConf, 0); + + if (unit_count >= 3) { + image2 = vec_out[2].clone(); + DrawSelectRects(image2, local_DisplayLabelConf, 1); + IsNG|=CheckSelectRects(image1,vec_results,2,local_DisplayLabelConf,1); + } + result_index++; + + if (!IsNG) + { + emit event_ok(local_camera_number); + local_g_result_queue->put(true); + } + else + { + emit event_ng(local_camera_number); + local_g_result_queue->put(false); + if ((local_SysConf.save == 2) || (local_SysConf.save == 1)) + { + for(int index=0;indexput(std::make_pair(file_name.toStdString(), m)); + + m = vec_out[index].clone(); + file_name = "D:/image/" + + now_ts.toString("yyyy-MM-dd") + + "/" + QString::number(local_camera_number + 1) + + "/ng_result/" + QString::number(index)+ "/" + + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".jpg"; + g_save_queue->put(std::make_pair(file_name.toStdString(), m)); + } + } + } + } + + emit display_check_total(local_camera_number, ++frame_total); + + emit notify(local_camera_number, 0,image1); + if(unit_count>=3) + emit notify(local_camera_number, 1,image2); + } + else { //֤λ + if(local_SysConf.MisMatchAct == 1)//as ng + emit event_ng(local_camera_number); + else if(local_SysConf.MisMatchAct == 0)//as ok + emit event_ok(local_camera_number); + emit display_check_total(local_camera_number, ++frame_total); + qDebug() << local_camera_number<< "#camera# " << now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") <<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " << unit_count; + } +#ifdef __UDPSend + UDP_Info_queue->put(UDPSendInfo); +#endif + } + } + catch (cv::Exception& e) + { + const char* err_msg = e.what(); + std::cout << "exception caught: " << err_msg << std::endl; + } +} \ No newline at end of file diff --git a/Cigarette/workthread.h b/Cigarette/workthread.h new file mode 100644 index 0000000..2ad278b --- /dev/null +++ b/Cigarette/workthread.h @@ -0,0 +1,44 @@ +#pragma once +#include +#include +#include +#include +#include +#include "SyncQueue.h" +#include "ASyncQueue.h" +#include "common.h" + +class WorkThread : public QThread +{ + Q_OBJECT +signals: + void notify(int Num,int Cnt,cv::Mat); + void display_timecost(int Num,int ms); + void display_check_total(int Num,long no); + void display_jd_no(int Num,QString jd_no); + + void event_ok(int Num); + void event_ng(int Num); + +public: + WorkThread(QObject *parent = 0): QThread(parent) + { + + } + ~WorkThread(); + + void init(SyncQueue>* image_ptr,ASyncQueue *result_ptr, int classid, int Num); + void start_work(); + void stop(); +protected: + void run(); +public: + int local_camera_number; + int local_classid; + SyncQueue > *local_g_image_queue; + ASyncQueue *local_g_result_queue; + bool b_quit; + long frame_total; + SysConf local_SysConf; + DisplayLabelConf local_DisplayLabelConf; +}; diff --git a/CigaretteSingle/AlgCommon.cpp b/CigaretteSingle/AlgCommon.cpp new file mode 100644 index 0000000..5c09187 --- /dev/null +++ b/CigaretteSingle/AlgCommon.cpp @@ -0,0 +1,312 @@ +#include "AlgCommon.h" + +//保护rect边界,防止越界访问造成程序崩溃 +bool protectRect(cv::Rect& rect, int width, int height) +{ + if (width == 0 || height == 0) + { + return false; + } + rect.x = std::max(rect.x, 0); + rect.x = std::min(rect.x, width - 1); + rect.y = std::max(rect.y, 0); + rect.y = std::min(rect.y, height - 1); + int right = rect.x + rect.width; + int bottom = rect.y + rect.height; + right = std::max(right, 0); + right = std::min(right, width - 1); + bottom = std::max(bottom, 0); + bottom = std::min(bottom, height - 1); + rect.width = std::max(right - rect.x, 0); + rect.height = std::max(bottom - rect.y, 0); + if (rect.width == 0 || rect.height == 0) + return false; + return true; +} + +void GetStringSize(HDC hDC, const char* str, int* w, int* h) +{ + SIZE size; + GetTextExtentPoint32A(hDC, str, strlen(str), &size); + if (w != 0) *w = size.cx; + if (h != 0) *h = size.cy; +} + +void putTextZH(cv::Mat& dst, const char* str, cv::Point org, cv::Scalar color, int fontSize, const char* fn, bool italic, bool underline) +{ + CV_Assert(dst.data != 0 && (dst.channels() == 1 || dst.channels() == 3)); + + int x, y, r, b; + if (org.x > dst.cols || org.y > dst.rows) return; + x = org.x < 0 ? -org.x : 0; + y = org.y < 0 ? -org.y : 0; + + LOGFONTA lf; + lf.lfHeight = -fontSize; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = 5; + lf.lfItalic = italic; //斜体 + lf.lfUnderline = underline; //下划线 + lf.lfStrikeOut = 0; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = 0; + lf.lfClipPrecision = 0; + lf.lfQuality = PROOF_QUALITY; + lf.lfPitchAndFamily = 0; + strcpy_s(lf.lfFaceName, fn); + + HFONT hf = CreateFontIndirectA(&lf); + HDC hDC = CreateCompatibleDC(0); + HFONT hOldFont = (HFONT)SelectObject(hDC, hf); + + int strBaseW = 0, strBaseH = 0; + int singleRow = 0; + char buf[1 << 12]; + strcpy_s(buf, str); + char* bufT[1 << 12]; // 这个用于分隔字符串后剩余的字符,可能会超出。 + //处理多行 + { + int nnh = 0; + int cw, ch; + + const char* ln = strtok_s(buf, "\n", bufT); + while (ln != 0) + { + GetStringSize(hDC, ln, &cw, &ch); + strBaseW = std::max(strBaseW, cw); + strBaseH = std::max(strBaseH, ch); + + ln = strtok_s(0, "\n", bufT); + nnh++; + } + singleRow = strBaseH; + strBaseH *= nnh; + } + + if (org.x + strBaseW < 0 || org.y + strBaseH < 0) + { + SelectObject(hDC, hOldFont); + DeleteObject(hf); + DeleteObject(hDC); + return; + } + + r = org.x + strBaseW > dst.cols ? dst.cols - org.x - 1 : strBaseW - 1; + b = org.y + strBaseH > dst.rows ? dst.rows - org.y - 1 : strBaseH - 1; + org.x = org.x < 0 ? 0 : org.x; + org.y = org.y < 0 ? 0 : org.y; + + BITMAPINFO bmp = { 0 }; + BITMAPINFOHEADER& bih = bmp.bmiHeader; + int strDrawLineStep = strBaseW * 3 % 4 == 0 ? strBaseW * 3 : (strBaseW * 3 + 4 - ((strBaseW * 3) % 4)); + + bih.biSize = sizeof(BITMAPINFOHEADER); + bih.biWidth = strBaseW; + bih.biHeight = strBaseH; + bih.biPlanes = 1; + bih.biBitCount = 24; + bih.biCompression = BI_RGB; + bih.biSizeImage = strBaseH * strDrawLineStep; + bih.biClrUsed = 0; + bih.biClrImportant = 0; + + void* pDibData = 0; + HBITMAP hBmp = CreateDIBSection(hDC, &bmp, DIB_RGB_COLORS, &pDibData, 0, 0); + + CV_Assert(pDibData != 0); + HBITMAP hOldBmp = (HBITMAP)SelectObject(hDC, hBmp); + + //color.val[2], color.val[1], color.val[0] + SetTextColor(hDC, RGB(255, 255, 255)); + SetBkColor(hDC, 0); + //SetStretchBltMode(hDC, COLORONCOLOR); + + strcpy_s(buf, str); + const char* ln = strtok_s(buf, "\n", bufT); + int outTextY = 0; + while (ln != 0) + { + TextOutA(hDC, 0, outTextY, ln, strlen(ln)); + outTextY += singleRow; + ln = strtok_s(0, "\n", bufT); + } + uchar* dstData = (uchar*)dst.data; + int dstStep = dst.step / sizeof(dstData[0]); + unsigned char* pImg = (unsigned char*)dst.data + org.x * dst.channels() + org.y * dstStep; + unsigned char* pStr = (unsigned char*)pDibData + x * 3; + for (int tty = y; tty <= b; ++tty) + { + unsigned char* subImg = pImg + (tty - y) * dstStep; + unsigned char* subStr = pStr + (strBaseH - tty - 1) * strDrawLineStep; + for (int ttx = x; ttx <= r; ++ttx) + { + for (int n = 0; n < dst.channels(); ++n) { + double vtxt = subStr[n] / 255.0; + int cvv = vtxt * color.val[n] + (1 - vtxt) * subImg[n]; + subImg[n] = cvv > 255 ? 255 : (cvv < 0 ? 0 : cvv); + } + + subStr += 3; + subImg += dst.channels(); + } + } + + SelectObject(hDC, hOldBmp); + SelectObject(hDC, hOldFont); + DeleteObject(hf); + DeleteObject(hBmp); + DeleteDC(hDC); +} + +void putTextCorner(cv::Mat& image, std::string text, cv::Scalar color, int where) +{ + //设置绘制文本的相关参数 + int x_margin = 25; + int y_margin = 25; + int font_face = cv::FONT_HERSHEY_COMPLEX; + double font_scale = 1.5; + int thickness = 2; + int baseline; + //获取文本框的长宽 + cv::Size text_size = cv::getTextSize(text, font_face, font_scale, thickness, &baseline); + + //将文本框居中绘制 + cv::Point origin; + switch (where) + { + case 1: //左上 + origin.x = x_margin; + origin.y = y_margin; + break; + case 2: //右上 + origin.x = image.cols - x_margin - text_size.width; + origin.y = y_margin; + break; + case 3: //左下 + origin.x = x_margin; + origin.y = image.rows - y_margin; + break; + case 4: //右下 + origin.x = image.cols - x_margin - text_size.width; + origin.y = image.rows - y_margin; + break; + default: + origin.x = image.cols / 2 - text_size.width / 2; + origin.y = image.rows / 2 + text_size.height / 2; + break; + } + cv::putText(image, text, origin, font_face, font_scale, color, thickness, 8, false); +} + +void fistEROthenDIL(cv::Mat& input,uint8_t EROsize,uint8_t DILsize) +{ + cv::Mat element_erode, element_dilate; + if (EROsize) + { + element_erode = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(EROsize, EROsize)); + cv::erode(input, input, element_erode); + } + if (DILsize) + { + element_dilate = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(DILsize, DILsize)); + cv::dilate(input, input, element_dilate); + } +} +void fistDILthenERO(cv::Mat& input, uint8_t DILsize, uint8_t EROsize) +{ + cv::Mat element_erode, element_dilate; + if (DILsize) + { + element_dilate = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(DILsize, DILsize)); + cv::dilate(input, input, element_dilate); + } + if (EROsize) + { + element_erode = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(EROsize, EROsize)); + cv::erode(input, input, element_erode); + } +} + +bool isInside(cv::Rect rect1, cv::Rect rect2) +{ + return (rect1 == (rect1&rect2)); +} + +cv::Point getCenterPoint(cv::Rect rect) +{ + cv::Point cpt; + cpt.x = rect.x + cvRound(rect.width / 2.0); + cpt.y = rect.y + cvRound(rect.height / 2.0); + return cpt; +} + +cv::Rect rectCenterScale(cv::Rect rect, cv::Size size) +{ + rect = rect + size; + cv::Point pt; + pt.x = cvRound(size.width / 2.0); + pt.y = cvRound(size.height / 2.0); + return (rect - pt); +} +uchar minimum(uchar a, uchar b) +{ + return a <= b ? a : b; +} + +cv::Mat rgb2cmyk(cv::Mat& rgb) +{ + cv::Mat cmyk = cv::Mat::zeros(rgb.rows, rgb.cols, CV_8UC4); + + int pixel_num = rgb.rows * rgb.cols; + + for (int i = 0; i < pixel_num; i++) + { + uchar c = 255 - rgb.data[3 * i + 0]; + uchar m = 255 - rgb.data[3 * i + 1]; + uchar y = 255 - rgb.data[3 * i + 2]; + + uchar K = minimum(minimum(c, m), y); + + uchar C = 0; + uchar M = 0; + uchar Y = 0; + + if (K == 255) + { + C = 0; + M = 0; + Y = 0; + } + else + { + C = (uchar)((c - K)*255.0 / (255 - K)); + M = (uchar)((m - K)*255.0 / (255 - K)); + Y = (uchar)((y - K)*255.0 / (255 - K)); + } + + cmyk.data[4 * i + 0] = C; + cmyk.data[4 * i + 1] = M; + cmyk.data[4 * i + 2] = Y; + cmyk.data[4 * i + 3] = K; + } + return cmyk; +} + +bool sort_rect_by_x_center(cv::Rect r1, cv::Rect r2) +{ + return (r1.x + r1.width / 2) < (r2.x + r2.width / 2); +} +bool sort_rect_by_y_center(cv::Rect r1, cv::Rect r2) +{ + return (r1.y + r1.height / 2) < (r2.y + r2.height / 2); +} +bool sort_rect_by_height(cv::Rect r1, cv::Rect r2) +{ + return (r1.height) < (r2.height); +} +bool sort_rect_by_width(cv::Rect r1, cv::Rect r2) +{ + return (r1.width) < (r2.width); +} \ No newline at end of file diff --git a/CigaretteSingle/AlgCommon.h b/CigaretteSingle/AlgCommon.h new file mode 100644 index 0000000..5926452 --- /dev/null +++ b/CigaretteSingle/AlgCommon.h @@ -0,0 +1,32 @@ +#pragma once +#include +#include +#define NOMINMAX +#include +#include + +//rect߽磬ֹԽɳ +bool protectRect(cv::Rect& rect, int width, int height); + +//ʾ +void GetStringSize(HDC hDC, const char* str, int* w, int* h); +void putTextZH(cv::Mat& dst, const char* str, cv::Point org, cv::Scalar color, int fontSize, + const char* fn = "Arial", bool italic = false, bool underline = false); +//ʾӢıij +void putTextCorner(cv::Mat& image, std::string text, cv::Scalar color, int where); +//ȸʴ +void fistEROthenDIL(cv::Mat& input, uint8_t EROsize,uint8_t DILsize); +//ͺʴ +void fistDILthenERO(cv::Mat& input, uint8_t DILsize, uint8_t EROsize); +//жϾ1Ƿھ2 +bool isInside(cv::Rect rect1, cv::Rect rect2); +//þе +cv::Point getCenterPoint(cv::Rect rect); +//ηΧ +cv::Rect rectCenterScale(cv::Rect rect, cv::Size size); +//rgb2cmyk +cv::Mat rgb2cmyk(cv::Mat& rgb); +bool sort_rect_by_x_center(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_height(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_y_center(cv::Rect r1, cv::Rect r2); +bool sort_rect_by_width(cv::Rect r1, cv::Rect r2); \ No newline at end of file diff --git a/CigaretteSingle/Camera/hikcamera.cpp b/CigaretteSingle/Camera/hikcamera.cpp new file mode 100644 index 0000000..710429a --- /dev/null +++ b/CigaretteSingle/Camera/hikcamera.cpp @@ -0,0 +1,235 @@ +#include "hikcamera.h" +#include +#include +#include + + +MV_CC_DEVICE_INFO_LIST HIKCamera::stDeviceList; +HIKCamera* HIKCamera::HikController = nullptr; +std::vector HIKCamera::CameraHandle; + +void __stdcall ImageCallBackEx1(unsigned char* pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser) +{ + HIKCamera* HIKCTRL = (HIKCamera*)pUser; + if (pFrameInfo) + { + memcpy(HIKCTRL->p_pImage_buf, pData, pFrameInfo->nFrameLen); + cv::Mat image = cv::Mat(pFrameInfo->nHeight, pFrameInfo->nWidth, CV_8UC3, HIKCTRL->p_pImage_buf); + cv::Mat image_clone = image.clone(); + if (image_clone.data) + { + HIKCTRL->p_image_queue->put(image_clone); + } + } +} + +void __stdcall LossCallBack(unsigned int pData, void* pUser) +{ + +} +void __stdcall FallingGpioEvent(MV_EVENT_OUT_INFO* pEventInfo, void* pUser) +{ + + +} +void __stdcall RisingGpioEvent(MV_EVENT_OUT_INFO* pEventInfo, void* pUser) +{ + +} + +HIKCamera::HIKCamera(int DeviceNum):CamSelect(DeviceNum) +{ + p_pImage_buf = (unsigned char*)malloc(5000 * 5000 * 3); +} + +HIKCamera::~HIKCamera() +{ + delete p_pImage_buf; +} + +HIKCamera* HIKCamera::InitHIKController(int DeviceNum) +{ + if (HIKCamera::HikController == nullptr) + { + HIKCamera::HikController = new HIKCamera(DeviceNum); + } + return HIKCamera::HikController; +} + +int HIKCamera::Enumerate() +{ + int status = 0; + int hik_cnt = 0; + memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST)); + + status = MV_CC_EnumDevices(MV_GIGE_DEVICE| MV_USB_DEVICE, &stDeviceList); + if (MV_OK == status) + { + for (int i = 0; i < stDeviceList.nDeviceNum; i++) + { + MV_CC_DEVICE_INFO* pDeviceInfo = HIKCamera::stDeviceList.pDeviceInfo[i]; + std::string manufacture; + char chManufacturer[32]; + if (pDeviceInfo->nTLayerType == MV_GIGE_DEVICE) + { + MV_GIGE_DEVICE_INFO* TempPtr = &(pDeviceInfo->SpecialInfo.stGigEInfo); + memcpy(chManufacturer, TempPtr->chManufacturerName, 32); + manufacture = chManufacturer; + } + else if (pDeviceInfo->nTLayerType == MV_USB_DEVICE) + { + MV_USB3_DEVICE_INFO* TempPtr = &(pDeviceInfo->SpecialInfo.stUsb3VInfo); + memcpy(chManufacturer, TempPtr->chManufacturerName, 32); + manufacture = chManufacturer; + } + else + { + continue; + } + + std::cout << "Camera:" << i << ",vendor = " << manufacture << std::endl; + transform(manufacture.begin(), manufacture.end(), manufacture.begin(), ::toupper); + if ((!manufacture.compare(0, 3, "HIK")) || (!manufacture.compare(0, 3, "U3V"))) + { + void* camhandle; + MV_CC_CreateHandle(&camhandle, HIKCamera::stDeviceList.pDeviceInfo[i]); + hik_cnt++; + HIKCamera::CameraHandle.push_back(camhandle); + } + } + return hik_cnt; + } + else + { + return 0; + } +} + +int HIKCamera::OpenCamera() +{ + int nRet = MV_OK; + int nnRet = MV_OK; + void* handle = HIKCamera::CameraHandle[CamSelect]; + nRet = MV_CC_OpenDevice(handle); + // nRet = MV_CC_SetEnumValue(handle, "LineSelector", 1); //0:Line0 1:Line1 2:Line2 + // if (nRet) { std::cout << "can not set LineSelector" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValue(handle, "LineMode", 8); //0:Input 1:Output 2:Trigger 8:Strobe + // if (nRet) { std::cout << "can not set LineMode" << std::endl; nnRet = nRet; } + + //0:ExposureStartActive 5:SoftTriggerActive 6:HardTriggerActive + // nRet = MV_CC_SetEnumValue(handle, "LineSource", 5); + // if (nRet) { std::cout << "can not set LineSource" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetBoolValue(handle, "StrobeEnable", TRUE); + // if (nRet) { std::cout << "can not set StrobeEnable" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetIntValueEx(handle, "StrobeLineDuration", 2000); + // if (nRet) { std::cout << "can not set StrobeLineDuration" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValue(handle, "LineSelector", 0); + // if (nRet) { std::cout << "can not set LineSelector" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetIntValueEx(handle, "LineDebouncerTime", 2000); + // if (nRet) { std::cout << "can not set LineDebouncerTime" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValue(handle, "LineSelector", 2); + // if (nRet) { std::cout << "can not set LineSelector" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetIntValueEx(handle, "LineDebouncerTime", 2000); + // if (nRet) { std::cout << "can not set LineDebouncerTime" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(handle, "TriggerMode", MV_TRIGGER_MODE_OFF); + if (nRet) { std::cout << "can not set TriggerMode" << std::endl; nnRet = nRet; } + + nRet = MV_CC_SetEnumValue(handle, "TriggerSource", MV_TRIGGER_SOURCE_SOFTWARE); + if (nRet) { std::cout << "can not set TriggerSource" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValue(handle, "TriggerActivation", 1);//1表示下降沿 + // if (nRet) { std::cout << "can not set TriggerActivation" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValue(handle, "BinningHorizontal", 2);//设置binning + // if (nRet) { std::cout << "can not set BinningHorizontal" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValue(handle, "BinningVertical", 2);//设置binning + // if (nRet) { std::cout << "can not set BinningVertical" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValueByString(handle, "EventSelector", "Line0FallingEdge"); + // if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValueByString(handle, "EventNotification", "On"); + // if (nRet) { std::cout << "can not set EventNotification" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValueByString(handle, "EventSelector", "Line0RisingEdge"); + // if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_SetEnumValueByString(handle, "EventNotification", "On"); + // if (nRet) { std::cout << "can not set EventNotification" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_RegisterExceptionCallBack(handle, LossCallBack, this); + // if (nRet) { std::cout << "can not register loss callback" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_RegisterEventCallBackEx(handle, "Line0FallingEdge", FallingGpioEvent, this); + // if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; } + + // nRet = MV_CC_RegisterEventCallBackEx(handle, "Line0RisingEdge", RisingGpioEvent, this); + // if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; } + + if (HIKCamera::stDeviceList.pDeviceInfo[CamSelect]->nTLayerType == MV_GIGE_DEVICE) + { + int nPacketSize = MV_CC_GetOptimalPacketSize(handle); + if (nPacketSize > 0) + { + nRet = MV_CC_SetIntValue(handle, "GevSCPSPacketSize", nPacketSize); + if (nRet != MV_OK) + { + //printf("Warning: Set Packet Size fail nRet [0x%x]!", nRet); + } + } + else + { + //printf("Warning: Get Packet Size fail nRet [0x%x]!", nPacketSize); + } + } + MV_CC_RegisterImageCallBackForRGB(handle, ImageCallBackEx1, this); + nRet = MV_CC_StartGrabbing(handle); + return nnRet; +} + +int HIKCamera::CloseCamera() +{ + int nRet = MV_OK; + void* handle = HIKCamera::CameraHandle[CamSelect]; + nRet = MV_CC_StopGrabbing(handle); + nRet = MV_CC_CloseDevice(handle); + return nRet; +} + +void HIKCamera::SetTriggerMode(MV_CAM_TRIGGER_MODE mode) +{ + int nRet = MV_OK; + int nnRet = MV_OK; + void* handle = HIKCamera::CameraHandle[CamSelect]; + + nRet = MV_CC_SetEnumValue(handle, "TriggerMode", mode); + if (nRet) { std::cout << "can not set TriggerMode" << std::endl; nnRet = nRet; } +} + +cv::Mat HIKCamera::SoftWareTrigger() +{ + int nRet = MV_OK; + int nnRet = MV_OK; + void* handle = HIKCamera::CameraHandle[CamSelect]; + + image = cv::Mat(); + nRet = MV_CC_SetCommandValue(handle, "TriggerSoftware"); + if (nRet) { std::cout << "can not send TriggerSoftware" << std::endl; nnRet = nRet; } + int cnt = 10; + while(cnt) + { + if(image.data)break; + Sleep(200); + cnt--; + } + return image.clone(); +} diff --git a/CigaretteSingle/Camera/hikcamera.h b/CigaretteSingle/Camera/hikcamera.h new file mode 100644 index 0000000..8a52341 --- /dev/null +++ b/CigaretteSingle/Camera/hikcamera.h @@ -0,0 +1,41 @@ +#pragma once +#include "ASyncQueue.h" +#include "SyncQueue.h" +#include "MvCameraControl.h" +#include "CameraParams.h" +#include +#include +#include "common.h" + +#define HIK2D 1 + +class HIKCamera +{ +private: + HIKCamera(int DeviceNums); + HIKCamera(const HIKCamera& tmpobj) {} + HIKCamera operator=(const HIKCamera& tmpobj) {} + ~HIKCamera(); + +private: + int CamSelect = 0; + +public: + static int HIKCamera::Enumerate(); + static HIKCamera* InitHIKController(int DeviceNum); + void SetTriggerMode(MV_CAM_TRIGGER_MODE mode); + cv::Mat SoftWareTrigger(); + + int OpenCamera(); + int CloseCamera(); + +public: + static MV_CC_DEVICE_INFO_LIST stDeviceList; + static HIKCamera* HikController; + static std::vector CameraHandle; + + void* p_pImage_buf = nullptr; + SyncQueue *p_image_queue; + ASyncQueue *p_result_queue; + cv::Mat image; +}; diff --git a/CigaretteSingle/CigaretteSingle.cpp b/CigaretteSingle/CigaretteSingle.cpp new file mode 100644 index 0000000..6620271 --- /dev/null +++ b/CigaretteSingle/CigaretteSingle.cpp @@ -0,0 +1,218 @@ +#include "CigaretteSingle.h" +#include +#include +#include + +SyncQueue >* g_save_queue; +SyncQueue* g_image_queue; +ASyncQueue* g_result_queue; + +CigaretteSingle::CigaretteSingle(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::CigaretteSingleClass()) +{ + ui->setupUi(this); + ui->centralWidget->setStyleSheet("background-color : #1F2026;"); + QFile qrcfile; + //õ¼ںӴڵʽ + qrcfile.setFileName(":/CigaretteSingle/darkblack.css"); + qrcfile.open(QIODevice::ReadOnly); + QString strQss = qrcfile.readAll(); + this->setStyleSheet(strQss); + + + g_save_queue = new SyncQueue >(Queue_Size); + g_save_queue->name = "save queue"; + g_image_queue = new SyncQueue(Queue_Size); + g_image_queue->name = format("image"); + g_result_queue = new ASyncQueue(Queue_Size); + g_result_queue->name = format("result"); + + saveThread.init(g_save_queue); + saveThread.start_work(); + + g_ts_start = QDateTime::currentDateTime(); //ϵͳʱ + //ÿʱ + m_pTimer = new QTimer(this); + connect(m_pTimer, SIGNAL(timeout()), this, SLOT(event_per_second())); + m_pTimer->start(1000); + + connect(ui->textBrowser, SIGNAL(cursorPositionChanged()), this, SLOT(autoScroll())); + + m_alg_ptr = new Alg; + /*int hik_cnt = 0; + hik_cnt = HIKCamera::Enumerate(); + if (hik_cnt) + { + HIKCamera::HikController = HIKCamera::InitHIKController(0); + HikControllerPtr = HIKCamera::HikController; + HikControllerPtr->p_image_queue = g_image_queue; + HikControllerPtr->p_result_queue = g_result_queue; + HikControllerPtr->OpenCamera(); + }*/ + + work_thread.p_image_queue = g_image_queue; + work_thread.p_result_queue = g_result_queue; + work_thread.p_save_queue = g_save_queue; + work_thread.m_alg_ptr = m_alg_ptr; + work_thread.init(); + + connect(&work_thread, SIGNAL(display_image(cv::Mat)), this, SLOT(DisplayImage(cv::Mat))); + work_thread.start_work(); +} + +CigaretteSingle::~CigaretteSingle() +{ + delete g_save_queue; + delete g_image_queue; + delete g_result_queue; + delete ui; +} + +void CigaretteSingle::DisplayImage(cv::Mat m) +{ + // //ͼСΪʾڴС + cv::Size display_size = cv::Size(ui->image_label->width(), ui->image_label->height()); + cv::resize(m, m, display_size); + QImage tempImage = cvMatToQImage(m); + ui->image_label->setPixmap(QPixmap::fromImage(tempImage)); + +} + +//ʱÿһ +void CigaretteSingle::event_per_second() +{ + static int weight_per_minute_mat[10] = {0}; + static INT16 last_weight = 0; + QDateTime ts_start = QDateTime::currentDateTime(); + QDateTime local(ts_start); + QString localTime = local.toString("yyyy-MM-dd hh:mm:ss"); + //ui->label_cur_time_val->setText(localTime); + + qint64 intervalTime = g_ts_start.secsTo(ts_start); + int days = (intervalTime) / (24 * 3600); + int hours = (intervalTime) % (24 * 3600) / 3600; + int minutes = (intervalTime) % 3600 / 60; + int second = (intervalTime) % 60; + + QString run_stat = SecondToQStrTime(intervalTime); + ui->label_run_time_val->setText(run_stat); +} + +void CigaretteSingle::on_pushButton_mtest_released() +{ + QString srcDirPath = QFileDialog::getExistingDirectory(this, "choose src Directory", "./"); + + if (srcDirPath.isEmpty()) + { + return; + } + + vector files; + qDebug() << "srcDirPath=" << srcDirPath; + srcDirPath += "/"; + //ȡ·µļ + getFiles(srcDirPath.toStdString() + "*.jpg", files); + for (int i = 0; i < files.size(); i++) + { + //ͼ + std::cout << "open file------ " << files[i] << std::endl; + cv::Mat imagein = cv::imread(srcDirPath.toStdString() + files[i], cv::IMREAD_COLOR); + if (imagein.data) + { + cv::cvtColor(imagein, imagein, cv::COLOR_BGR2GRAY); + g_image_queue->put(imagein.clone()); + Sleep(500); + } + } +} + + +//cv::Mat image; +//cv::Mat imageCopy; //ƾοʱԭͼͼ +bool leftButtonDownFlag = false; //Ƶͣŵı־λ +cv::Point originalPoint; //ο +cv::Point processPoint; //οյ +std::vector RectVet; +void onMouse(int event, int x, int y, int flags, void* ustc); //ص + +void CigaretteSingle::on_pushButton_selectregion_released() +{ + QString srcDirPath = QString::fromStdString(SelectDirIFD()); + Alg m_alg; + vector files; + qDebug() << "srcDirPath=" << srcDirPath; + srcDirPath += "/"; + //ȡ·µļ + getFiles(srcDirPath.toStdString() + "*.jpg", files); + if (files.size() == 0) + { + QMessageBox::StandardButton result = QMessageBox::information(NULL, QStringLiteral("ʾ"), QStringLiteral("ûҵͼƬ")); + return; + } + + cv::namedWindow("Image"); + cv::setMouseCallback("Image", onMouse); + for (int index = 0; index < files.size(); index++) + { + //ͼ + //std::cout << "open file------ " << files[index] << std::endl; + cv::Mat imagein = cv::imread(srcDirPath.toStdString() + files[index], cv::IMREAD_COLOR); + cv::cvtColor(imagein, imagein, cv::COLOR_BGR2GRAY); + if (!imagein.data) + { + break; + } + //1. յ + //2. δ̧ + if ((originalPoint != processPoint) && (leftButtonDownFlag == true)) + { + rectangle(imagein, originalPoint, processPoint, cv::Scalar(255, 0, 0), 2); + } + if (RectVet.size()) + { + for (int i = 0; i < RectVet.size(); i++) + { + cv::Mat input = imagein(RectVet[i]).clone(); + cv::Mat output; + m_alg.process_bool(input, output); + cv::putText(imagein, to_string (i), RectVet[i].tl(),CV_FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255)); + rectangle(imagein, RectVet[i], cv::Scalar(0, 0, 255), 2); + } + } + imshow("Image", imagein); + //cv::cvtColor(imagein, imagein, cv::COLOR_BGR2GRAY); + //g_image_queue->put(imagein.clone()); + //Sleep(500); + int k = cv::waitKeyEx(1); + if (k == 27)break;//ESC + else if ((k == 3014656) && (RectVet.size() != 0))RectVet.pop_back();//DELETE + + if (index == files.size() - 1)index = 0; + QCoreApplication::processEvents(); + } + cv::imshow("Image", cv::Mat::zeros(cv::Size(1, 1), CV_8UC1)); + cv::destroyWindow("Image"); +} + +//ص +void onMouse(int event, int x, int y, int flags, void* ustc) +{ + if (event == CV_EVENT_LBUTTONDOWN) + { + leftButtonDownFlag = true; //־λ + originalPoint = cv::Point(x, y); //µľ + processPoint = originalPoint; + } + if (event == CV_EVENT_MOUSEMOVE && leftButtonDownFlag) + { + processPoint = cv::Point(x, y); + } + if (event == CV_EVENT_LBUTTONUP) + { + leftButtonDownFlag = false; + RectVet.push_back(cv::Rect(originalPoint, processPoint)); + //cv::Mat rectImage = image(cv::Rect(originalPoint, processPoint)); //ͼʾ + //cv::imshow("Sub Image", rectImage); + } +} \ No newline at end of file diff --git a/CigaretteSingle/CigaretteSingle.h b/CigaretteSingle/CigaretteSingle.h new file mode 100644 index 0000000..ceb5407 --- /dev/null +++ b/CigaretteSingle/CigaretteSingle.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include "ui_CigaretteSingle.h" + +#include "workthread.h" +#include "savethread.h" +#include "common.h" +#include + +#include +#include +#include +#include + +#include +#include "alg.h" + +QT_BEGIN_NAMESPACE +namespace Ui { class CigaretteSingleClass; }; +QT_END_NAMESPACE + +class CigaretteSingle : public QMainWindow +{ + Q_OBJECT + +private slots: + void DisplayImage(cv::Mat m); + void event_per_second(); + void on_pushButton_mtest_released(); + void on_pushButton_selectregion_released(); +public: + CigaretteSingle(QWidget *parent = nullptr); + ~CigaretteSingle(); + +public: + SaveThread saveThread; + WorkThread work_thread; + +public: + QDateTime g_ts_start; //ϵͳʱ + //ʱб + QTimer* m_pTimer; //ÿʱ + + Alg* m_alg_ptr; + + HIKCamera* HikControllerPtr = nullptr; + +private: + Ui::CigaretteSingleClass *ui; +}; diff --git a/CigaretteSingle/CigaretteSingle.qrc b/CigaretteSingle/CigaretteSingle.qrc new file mode 100644 index 0000000..a9e04e9 --- /dev/null +++ b/CigaretteSingle/CigaretteSingle.qrc @@ -0,0 +1,37 @@ + + + darkblack.css + Resources/alarm.png + Resources/cam1.png + Resources/cam1_no.png + Resources/cam1_yes.png + Resources/cam2.png + Resources/cam2_no.png + Resources/cam2_yes.png + Resources/cam3.png + Resources/cam3_no.png + Resources/cam3_yes.png + Resources/cam4.png + Resources/cam4_no.png + Resources/cam4_yes.png + Resources/cam5_no.png + Resources/cam5_yes.png + Resources/cam6_no.png + Resources/cam6_yes.png + Resources/cam7_no.png + Resources/cam7_yes.png + Resources/cam8_no.png + Resources/cam8_yes.png + Resources/exit.png + Resources/keyboard.png + Resources/lock.png + Resources/logo.png + Resources/pause.png + Resources/plc.png + Resources/rotate.png + Resources/setup.png + Resources/start.png + Resources/unlock.png + lightblack.css + + diff --git a/CigaretteSingle/CigaretteSingle.ui b/CigaretteSingle/CigaretteSingle.ui new file mode 100644 index 0000000..a125760 --- /dev/null +++ b/CigaretteSingle/CigaretteSingle.ui @@ -0,0 +1,872 @@ + + + CigaretteSingleClass + + + + 0 + 0 + 1276 + 788 + + + + CigaretteSingle + + + + + + + + + + + + 1100 + 10 + 171 + 23 + + + + 手动测试 + + + + + + 180 + 9 + 650 + 641 + + + + + + + + + + 830 + 10 + 261 + 641 + + + + + + + 10 + 680 + 1264 + 71 + + + + + 微软雅黑 + 12 + 75 + true + + + + 状态区 + + + + + 919 + 24 + 71 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + 无报警 + + + Qt::AlignCenter + + + + + + 410 + 24 + 41 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + 当班 + + + + + + 740 + 24 + 81 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + PLC正常 + + + Qt::AlignCenter + + + + + + 450 + 19 + 171 + 41 + + + + color:white + + + 8 + + + + + + 880 + 19 + 41 + 41 + + + + border-image: url(:/CigaretteSingle/Resources/alarm.png); + + + + + + + + + 690 + 19 + 51 + 41 + + + + border-image: url(:/CigaretteSingle/Resources/plc.png); + + + + + + + + + 630 + 19 + 51 + 41 + + + + + 微软雅黑 + 12 + 50 + false + + + + + + + 换班 + + + + + + 1000 + 30 + 250 + 20 + + + + + 微软雅黑 + 14 + 50 + false + + + + + + + 运行1年10月25天9时15分 + + + Qt::AlignCenter + + + + + + 10 + 24 + 81 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + 登陆用户: + + + Qt::AlignCenter + + + + + + 100 + 24 + 71 + 31 + + + + + 微软雅黑 + 12 + 50 + false + + + + + + + 操作员 + + + + + + 190 + 24 + 41 + 31 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + 上班 + + + + + + 230 + 19 + 171 + 41 + + + + color:white + + + 8 + + + + + + 825 + 19 + 51 + 41 + + + + + 微软雅黑 + 12 + 50 + false + + + + + + + 复位 + + + + + + + 10 + 240 + 171 + 431 + + + + + 微软雅黑 + 14 + 75 + true + + + + + + + 设备区 + + + + + 10 + 130 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 10 + 40 + 71 + 71 + + + + border-image: url(:/CigaretteSingle/Resources/cam1_no.png); + + + + + + + + + 95 + 40 + 71 + 71 + + + + border-image: url(:/CigaretteSingle/Resources/cam2_no.png); + + + + + + + + + 95 + 130 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 95 + 165 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 10 + 165 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 10 + 370 + 82 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + 调试模式 + + + + + + 10 + 400 + 71 + 21 + + + + + 微软雅黑 + 12 + 75 + true + + + + + + + 不剔除 + + + + + + 10 + 330 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 90 + 295 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + 10 + 205 + 72 + 72 + + + + border-image: url(:/CigaretteSingle/Resources/cam3_no.png); + + + + + + + + + 90 + 330 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 工作 + + + Qt::AlignCenter + + + + + + 90 + 205 + 72 + 72 + + + + border-image: url(:/CigaretteSingle/Resources/cam4_no.png); + + + + + + + + + 10 + 295 + 71 + 31 + + + + + 微软雅黑 + 18 + 75 + true + + + + background-color: rgb(255, 255, 0); + + + 联机 + + + Qt::AlignCenter + + + + + + + 10 + 0 + 171 + 231 + + + + + 微软雅黑 + 14 + 75 + true + + + + + + + 操作区 + + + + + 10 + 30 + 72 + 96 + + + + border-image: url(:/CigaretteSingle/Resources/start.png); + + + + + + false + + + + + + 90 + 30 + 72 + 96 + + + + border-image: url(:/CigaretteSingle/Resources/pause.png); + + + + + + + false + + + + + + 10 + 126 + 72 + 96 + + + + border-image: url(:/CigaretteSingle/Resources/unlock.png); + + + + + + false + + + + + + 90 + 126 + 72 + 96 + + + + border-image: url(:/CigaretteSingle/Resources/setup.png); + + + + + + + false + + + + + + + 1100 + 40 + 171 + 23 + + + + 保存图片 + + + + + + 1100 + 70 + 171 + 23 + + + + 选择区域 + + + + + + 1100 + 100 + 171 + 23 + + + + PushButton + + + + + + + + + + diff --git a/CigaretteSingle/CigaretteSingle.vcxproj b/CigaretteSingle/CigaretteSingle.vcxproj new file mode 100644 index 0000000..284d5af --- /dev/null +++ b/CigaretteSingle/CigaretteSingle.vcxproj @@ -0,0 +1,128 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {795A8611-044A-46D3-8DD9-13A338925BC4} + QtVS_v304 + 10.0 + 10.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + Application + v143 + + + Application + v143 + + + + + + + QT5.15 + core;gui;widgets + debug + + + QT5.15 + core;gui;widgets + release + + + + + + + + + + + + + + + + + + + + + + $(ProjectDir)MVS3.2.1\Include;$(ProjectDir)OpenCV455Simple\include;$(ProjectDir)Queue;$(ProjectDir)Camera;$(ProjectDir)WorkThread;$(ProjectDir)modbus;$(ProjectDir);%(AdditionalIncludeDirectories) + WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) + + + $(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)OpenCV455Simple\win64\vc14\lib;$(ProjectDir)modbus;%(AdditionalLibraryDirectories) + MvCameraControl.lib;opencv_world455.lib;modbus.lib;%(AdditionalDependencies) + + + + + true + true + ProgramDatabase + Disabled + MultiThreadedDebugDLL + + + Windows + true + + + + + true + true + ProgramDatabase + Disabled + MultiThreadedDLL + + + Console + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CigaretteSingle/CigaretteSingle.vcxproj.filters b/CigaretteSingle/CigaretteSingle.vcxproj.filters new file mode 100644 index 0000000..ae3ed6e --- /dev/null +++ b/CigaretteSingle/CigaretteSingle.vcxproj.filters @@ -0,0 +1,114 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + {8f8ed37d-ae28-428a-a0ca-cfda2fce7ac4} + + + {2206bbf9-8d5a-4486-af69-506ad0ed7a7f} + + + {ac84abf0-23f4-42bf-9b40-b86c251bcc97} + + + {c5b10d28-9db0-4275-9494-e6865f7419f6} + + + {bce9097d-9cf0-4fe7-b084-8326e253f667} + + + {0ae64424-8243-46e0-ab7d-767859274568} + + + + + Resource Files + + + Form Files + + + Header Files + + + Source Files + + + + + Source Files + + + Source Files\Camera + + + Source Files\Queue + + + Source Files\Queue + + + Source Files\WorkThread + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files\Camera + + + Header Files\Queue + + + Header Files\Queue + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Header Files\WorkThread + + + Header Files\WorkThread + + + \ No newline at end of file diff --git a/CigaretteSingle/MVS3.2.1/Include/CameraParams.h b/CigaretteSingle/MVS3.2.1/Include/CameraParams.h new file mode 100644 index 0000000..8cd0a39 --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/CameraParams.h @@ -0,0 +1,917 @@ + +#ifndef _MV_CAMERA_PARAMS_H_ +#define _MV_CAMERA_PARAMS_H_ + +#include "PixelType.h" + +#ifndef __cplusplus +typedef char bool; +#define true 1 +#define false 0 +#endif + +/// \~chinese 豸Ͷ \~english Device Type Definition +#define MV_UNKNOW_DEVICE 0x00000000 ///< \~chinese δ֪豸ͣ \~english Unknown Device Type, Reserved +#define MV_GIGE_DEVICE 0x00000001 ///< \~chinese GigE豸 \~english GigE Device +#define MV_1394_DEVICE 0x00000002 ///< \~chinese 1394-a/b 豸 \~english 1394-a/b Device +#define MV_USB_DEVICE 0x00000004 ///< \~chinese USB 豸 \~english USB Device +#define MV_CAMERALINK_DEVICE 0x00000008 ///< \~chinese CameraLink豸 \~english CameraLink Device + +/// \~chinese GigE豸Ϣ \~english GigE device info +typedef struct _MV_GIGE_DEVICE_INFO_ +{ + unsigned int nIpCfgOption; ///< [OUT] \~chinese IPѡ \~english IP Configuration Options + unsigned int nIpCfgCurrent; ///< [OUT] \~chinese ǰIP \~english IP Configuration:bit31-static bit30-dhcp bit29-lla + unsigned int nCurrentIp; ///< [OUT] \~chinese ǰIPַ \~english Current Ip + unsigned int nCurrentSubNetMask; ///< [OUT] \~chinese ǰ \~english Curtent Subnet Mask + unsigned int nDefultGateWay; ///< [OUT] \~chinese ǰ \~english Current Gateway + unsigned char chManufacturerName[32]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chModelName[32]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chDeviceVersion[32]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerSpecificInfo[48];///< [OUT] \~chinese ̵ľϢ \~english Manufacturer Specific Information + unsigned char chSerialNumber[16]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chUserDefinedName[16]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned int nNetExport; ///< [OUT] \~chinese IPַ \~english NetWork IP Address + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MV_GIGE_DEVICE_INFO; + +#define INFO_MAX_BUFFER_SIZE 64 ///< \~chinese ϢС \~english Maximum data information size + +/// \~chinese USB豸Ϣ \~english USB device info +typedef struct _MV_USB3_DEVICE_INFO_ +{ + unsigned char CrtlInEndPoint; ///< [OUT] \~chinese ˵ \~english Control input endpoint + unsigned char CrtlOutEndPoint; ///< [OUT] \~chinese ˵ \~english Control output endpoint + unsigned char StreamEndPoint; ///< [OUT] \~chinese ˵ \~english Flow endpoint + unsigned char EventEndPoint; ///< [OUT] \~chinese ¼˵ \~english Event endpoint + unsigned short idVendor; ///< [OUT] \~chinese ӦID \~english Vendor ID Number + unsigned short idProduct; ///< [OUT] \~chinese ƷID \~english Device ID Number + unsigned int nDeviceNumber; ///< [OUT] \~chinese 豸к \~english Device Serial Number + unsigned char chDeviceGUID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸GUID \~english Device GUID Number + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Ӧ \~english Vendor Name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Family Name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned int nbcdUSB; ///< [OUT] \~chinese ֵ֧USBЭ \~english Support USB Protocol + unsigned int nDeviceAddress; ///< [OUT] \~chinese 豸ַ \~english Device Address + + unsigned int nReserved[2]; ///< \~chinese Ԥ \~english Reserved +}MV_USB3_DEVICE_INFO; + +/// \~chinese CameraLink豸Ϣ \~english CameraLink device info +typedef struct _MV_CamL_DEV_INFO_ +{ + unsigned char chPortID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ˿ں \~english Port ID + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chFamilyName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Family Name + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned char chManufacturerName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english Manufacturer Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + + unsigned int nReserved[38]; ///< \~chinese Ԥ \~english Reserved +}MV_CamL_DEV_INFO; + +/// \~chinese 豸Ϣ \~english Device info +typedef struct _MV_CC_DEVICE_INFO_ +{ + unsigned short nMajorVer; ///< [OUT] \~chinese Ҫ汾 \~english Major Version + unsigned short nMinorVer; ///< [OUT] \~chinese Ҫ汾 \~english Minor Version + unsigned int nMacAddrHigh; ///< [OUT] \~chinese MACַ \~english High MAC Address + unsigned int nMacAddrLow; ///< [OUT] \~chinese MACַ \~english Low MAC Address + + unsigned int nTLayerType; ///< [OUT] \~chinese 豸Эͣe.g. MV_GIGE_DEVICE \~english Device Transport Layer Protocol Type, e.g. MV_GIGE_DEVICE + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved + + union + { + MV_GIGE_DEVICE_INFO stGigEInfo; ///< [OUT] \~chinese GigE豸Ϣ \~english GigE Device Info + MV_USB3_DEVICE_INFO stUsb3VInfo; ///< [OUT] \~chinese USB豸Ϣ \~english USB Device Info + MV_CamL_DEV_INFO stCamLInfo; ///< [OUT] \~chinese CameraLink豸Ϣ \~english CameraLink Device Info + // more ... + }SpecialInfo; + +}MV_CC_DEVICE_INFO; + +#define MV_MAX_TLS_NUM 8 ///< \~chinese ֵ֧Ĵʵ \~english The maximum number of supported transport layer instances +#define MV_MAX_DEVICE_NUM 256 ///< \~chinese ֵ֧豸 \~english The maximum number of supported devices + +/// \~chinese 豸Ϣб \~english Device Information List +typedef struct _MV_CC_DEVICE_INFO_LIST_ +{ + unsigned int nDeviceNum; ///< [OUT] \~chinese 豸 \~english Online Device Number + MV_CC_DEVICE_INFO* pDeviceInfo[MV_MAX_DEVICE_NUM]; ///< [OUT] \~chinese ֧256豸 \~english Support up to 256 devices + +}MV_CC_DEVICE_INFO_LIST; + +/// \~chinese ͨGenTLöٵInterfaceϢ \~english Interface Information with GenTL +typedef struct _MV_GENTL_IF_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese GenTLӿID \~english Interface ID + unsigned char chTLType[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english GenTL Type + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Interfaceʾ \~english Display Name + unsigned int nCtiIndex; ///< [OUT] \~chinese GenTLctiļ \~english The Index of Cti Files + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved +}MV_GENTL_IF_INFO; + +#define MV_MAX_GENTL_IF_NUM 256 ///< \~chinese ֵ֧GenTLӿ \~english The maximum number of GenTL interface supported +/// \~chinese ͨGenTLöٵĽӿϢб \~english Inferface Information List with GenTL +typedef struct _MV_GENTL_IF_INFO_LIST_ +{ + unsigned int nInterfaceNum; ///< [OUT] \~chinese ߽ӿ \~english Online Inferface Number + MV_GENTL_IF_INFO* pIFInfo[MV_MAX_GENTL_IF_NUM]; ///< [OUT] \~chinese ֧256ӿ \~english Support up to 256 inferfaces + +}MV_GENTL_IF_INFO_LIST; + +/// \~chinese ͨGenTLöٵ豸Ϣ \~english Device Information with GenTL +typedef struct _MV_GENTL_DEV_INFO_ +{ + unsigned char chInterfaceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese GenTLӿID \~english Interface ID + unsigned char chDeviceID[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸ID \~english Device ID + unsigned char chVendorName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese Ӧ \~english Vendor Name + unsigned char chModelName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese ͺ \~english Model Name + unsigned char chTLType[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese \~english GenTL Type + unsigned char chDisplayName[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸ʾ \~english Display Name + unsigned char chUserDefinedName[INFO_MAX_BUFFER_SIZE];///< [OUT] \~chinese ûԶ \~english User Defined Name + unsigned char chSerialNumber[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese к \~english Serial Number + unsigned char chDeviceVersion[INFO_MAX_BUFFER_SIZE]; ///< [OUT] \~chinese 豸汾 \~english Device Version + unsigned int nCtiIndex; ///< [OUT] \~chinese GenTLctiļ \~english The Index of Cti Files + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved +}MV_GENTL_DEV_INFO; + +#define MV_MAX_GENTL_DEV_NUM 256 ///< \~chinese ֵ֧GenTL豸 \~english The maximum number of GenTL devices supported +/// \~chinese ͨGenTLöٵ豸Ϣб \~english Device Information List with GenTL +typedef struct _MV_GENTL_DEV_INFO_LIST_ +{ + unsigned int nDeviceNum; ///< [OUT] \~chinese 豸 \~english Online Device Number + MV_GENTL_DEV_INFO* pDeviceInfo[MV_MAX_GENTL_DEV_NUM]; ///< [OUT] \~chinese ֧256豸 \~english Support up to 256 devices + +}MV_GENTL_DEV_INFO_LIST; + +/// \~chinese 豸ķģʽ \~english Device Access Mode +/// \~chinese ռȨޣAPPֻCCPĴ \~english Exclusive authority, other APP is only allowed to read the CCP register +#define MV_ACCESS_Exclusive 1 +/// \~chinese Դ5ģʽռȨޣȻԶռȨ޴ \~english You can seize the authority from the 5 mode, and then open with exclusive authority +#define MV_ACCESS_ExclusiveWithSwitch 2 +/// \~chinese ȨޣAPPмĴ \~english Control authority, allows other APP reading all registers +#define MV_ACCESS_Control 3 +/// \~chinese Դ5ģʽռȨޣȻԿȨ޴ \~english You can seize the authority from the 5 mode, and then open with control authority +#define MV_ACCESS_ControlWithSwitch 4 +/// \~chinese ԿɱռĿȨ޴ \~english Open with seized control authority +#define MV_ACCESS_ControlSwitchEnable 5 +/// \~chinese Դ5ģʽռȨޣȻԿɱռĿȨ޴ \~english You can seize the authority from the 5 mode, and then open with seized control authority +#define MV_ACCESS_ControlSwitchEnableWithKey 6 +/// \~chinese ģʽ豸ڿȨ \~english Open with read mode and is available under control authority +#define MV_ACCESS_Monitor 7 + +/// \~chinese Chunk \~english The content of ChunkData +typedef struct _MV_CHUNK_DATA_CONTENT_ +{ + unsigned char* pChunkData; ///< [OUT] \~chinese Chunk \~english Chunk Data + unsigned int nChunkID; ///< [OUT] \~chinese Chunk ID \~english Chunk ID + unsigned int nChunkLen; ///< [OUT] \~chinese Chunkij \~english Chunk Length + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CHUNK_DATA_CONTENT; + +/// \~chinese ֡Ϣ \~english Output Frame Information +typedef struct _MV_FRAME_OUT_INFO_EX_ +{ + unsigned short nWidth; ///< [OUT] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [OUT] \~chinese ͼ \~english Image Height + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel Type + + unsigned int nFrameNum; ///< [OUT] \~chinese ֡ \~english Frame Number + unsigned int nDevTimeStampHigh; ///< [OUT] \~chinese ʱ32λ \~english Timestamp high 32 bits + unsigned int nDevTimeStampLow; ///< [OUT] \~chinese ʱ32λ \~english Timestamp low 32 bits + unsigned int nReserved0; ///< [OUT] \~chinese 8ֽڶ \~english Reserved, 8-byte aligned + int64_t nHostTimeStamp; ///< [OUT] \~chinese ɵʱ \~english Host-generated timestamp + + unsigned int nFrameLen; ///< [OUT] \~chinese ֡ij \~english The Length of Frame + + /// \~chinese 豸ˮӡʱ \~english Device frame-specific time scale + unsigned int nSecondCount; ///< [OUT] \~chinese \~english The Seconds + unsigned int nCycleCount; ///< [OUT] \~chinese \~english The Count of Cycle + unsigned int nCycleOffset; ///< [OUT] \~chinese ƫ \~english The Offset of Cycle + + float fGain; ///< [OUT] \~chinese \~english Gain + float fExposureTime; ///< [OUT] \~chinese عʱ \~english Exposure Time + unsigned int nAverageBrightness; ///< [OUT] \~chinese ƽ \~english Average brightness + + /// \~chinese ƽ \~english White balance + unsigned int nRed; ///< [OUT] \~chinese ɫ \~english Red + unsigned int nGreen; ///< [OUT] \~chinese ɫ \~english Green + unsigned int nBlue; ///< [OUT] \~chinese ɫ \~english Blue + + unsigned int nFrameCounter; ///< [OUT] \~chinese ֡ \~english Frame Counter + unsigned int nTriggerIndex; ///< [OUT] \~chinese \~english Trigger Counting + + unsigned int nInput; ///< [OUT] \~chinese \~english Input + unsigned int nOutput; ///< [OUT] \~chinese \~english Output + + /// \~chinese ROI \~english ROI Region + unsigned short nOffsetX; ///< [OUT] \~chinese ˮƽƫ \~english OffsetX + unsigned short nOffsetY; ///< [OUT] \~chinese ֱƫ \~english OffsetY + unsigned short nChunkWidth; ///< [OUT] \~chinese Chunk \~english The Width of Chunk + unsigned short nChunkHeight; ///< [OUT] \~chinese Chunk \~english The Height of Chunk + + unsigned int nLostPacket; ///< [OUT] \~chinese ֡ \~english Lost Packet Number In This Frame + + unsigned int nUnparsedChunkNum; ///< [OUT] \~chinese δChunkdata \~english Unparsed Chunk Number + union + { + MV_CHUNK_DATA_CONTENT* pUnparsedChunkContent;///< [OUT] \~chinese δChunk \~english Unparsed Chunk Content + int64_t nAligning; ///< [OUT] \~chinese У׼ \~english Aligning + }UnparsedChunkList; + + unsigned int nReserved[36]; ///< \~chinese Ԥ \~english Reserved +}MV_FRAME_OUT_INFO_EX; + +/// \~chinese ͼṹ壬ͼַָͼϢ \~english Image Struct, output the pointer of Image and the information of the specific image +typedef struct _MV_FRAME_OUT_ +{ + unsigned char* pBufAddr; ///< [OUT] \~chinese ͼַָ \~english pointer of image + MV_FRAME_OUT_INFO_EX stFrameInfo; ///< [OUT] \~chinese ͼϢ \~english information of the specific image + + unsigned int nRes[16]; ///< \~chinese Ԥ \~english Reserved +}MV_FRAME_OUT; + +/// \~chinese ȡ \~english The strategy of Grabbing +typedef enum _MV_GRAB_STRATEGY_ +{ + MV_GrabStrategy_OneByOne = 0, ///< \~chinese Ӿɵһ֡һ֡ĻȡͼĬΪòԣ \~english Grab One By One + MV_GrabStrategy_LatestImagesOnly = 1, ///< \~chinese ȡбµһ֡ͼͬʱбеͼ \~english Grab The Latest Image + MV_GrabStrategy_LatestImages = 2, ///< \~chinese ȡбµͼ񣬸OutputQueueSizeΧΪ1-ImageNodeNumó1ͬLatestImagesOnly,óImageNodeNumͬOneByOne \~english Grab The Latest Images + MV_GrabStrategy_UpcomingImage = 3, ///< \~chinese ȴһ֡ͼ \~english Grab The Upcoming Image + +}MV_GRAB_STRATEGY; + +/// \~chinese 紫Ϣ \~english Network transmission information +typedef struct _MV_NETTRANS_INFO_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [ͳStartGrabbingStopGrabbing֮] \~english Received Data Size [Calculate the Data Size between StartGrabbing and StopGrabbing] + int nThrowFrameCount; ///< [OUT] \~chinese ֡ \~english Throw frame number + unsigned int nNetRecvFrameCount; ///< [OUT] \~chinese ѽյ֡ \~english Received Frame Count + int64_t nRequestResendPacketCount; ///< [OUT] \~chinese ط \~english Request Resend Packet Count + int64_t nResendPacketCount; ///< [OUT] \~chinese ط \~english Resend Packet Count + +}MV_NETTRANS_INFO; + +/// \~chinese Ϣ \~english Information Type +#define MV_MATCH_TYPE_NET_DETECT 0x00000001 ///< \~chinese ͶϢ \~english Network traffic and packet loss information +#define MV_MATCH_TYPE_USB_DETECT 0x00000002 ///< \~chinese hostյU3V豸ֽ \~english The total number of bytes host received from U3V device + +/// \~chinese ȫƥһϢṹ \~english A fully matched information structure +typedef struct _MV_ALL_MATCH_INFO_ +{ + unsigned int nType; ///< [IN] \~chinese ҪϢͣe.g. MV_MATCH_TYPE_NET_DETECT \~english Information type need to output ,e.g. MV_MATCH_TYPE_NET_DETECT + void* pInfo; ///< [OUT] \~chinese Ϣ棬ɵ߷ \~english Output information cache, which is allocated by the caller + unsigned int nInfoSize; ///< [IN] \~chinese ϢĴС \ ~english Information cache size + +}MV_ALL_MATCH_INFO; + +/// \~chinese ͶϢṹ壬ӦΪ MV_MATCH_TYPE_NET_DETECT \~english Network traffic and packet loss feedback structure, the corresponding type is MV_MATCH_TYPE_NET_DETECT +typedef struct _MV_MATCH_INFO_NET_DETECT_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [ͳStartGrabbingStopGrabbing֮] \~english Received data size + int64_t nLostPacketCount; ///< [OUT] \~chinese ʧİ \~english Number of packets lost + unsigned int nLostFrameCount; ///< [OUT] \~chinese ֡ \~english Number of frames lost + unsigned int nNetRecvFrameCount; ///< [OUT] \~chinese \~english Received Frame Count + int64_t nRequestResendPacketCount; ///< [OUT] \~chinese ط \~english Request Resend Packet Count + int64_t nResendPacketCount; ///< [OUT] \~chinese ط \~english Resend Packet Count +}MV_MATCH_INFO_NET_DETECT; + +/// \~chinese hostյu3v豸˵ֽӦΪ MV_MATCH_TYPE_USB_DETECT \~english The total number of bytes host received from the u3v device side, the corresponding type is MV_MATCH_TYPE_USB_DETECT +typedef struct _MV_MATCH_INFO_USB_DETECT_ +{ + int64_t nReceiveDataSize; ///< [OUT] \~chinese ѽݴС [ͳOpenDevicceCloseDevice֮] \~english Received data size + unsigned int nReceivedFrameCount; ///< [OUT] \~chinese յ֡ \~english Number of frames received + unsigned int nErrorFrameCount; ///< [OUT] \~chinese ֡ \~english Number of error frames + unsigned int nReserved[2]; ///< \~chinese \~english Reserved +}MV_MATCH_INFO_USB_DETECT; + +/// \~chinese ʾ֡Ϣ \~english Display frame information +typedef struct _MV_DISPLAY_FRAME_INFO_ +{ + void* hWnd; ///< [IN] \~chinese ھ \~english HWND + unsigned char* pData; ///< [IN] \~chinese ʾ \~english Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݳ \~english Data Size + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + unsigned int nRes[4]; ///< \~chinese \~english Reserved + +}MV_DISPLAY_FRAME_INFO; + +/// \~chinese 3Dݸʽ \~english The saved format for 3D data +enum MV_SAVE_POINT_CLOUD_FILE_TYPE +{ + MV_PointCloudFile_Undefined = 0, ///< \~chinese δĵƸʽ \~english Undefined point cloud format + MV_PointCloudFile_PLY = 1, ///< \~chinese PLYƸʽ \~english The point cloud format named PLY + MV_PointCloudFile_CSV = 2, ///< \~chinese CSVƸʽ \~english The point cloud format named CSV + MV_PointCloudFile_OBJ = 3, ///< \~chinese OBJƸʽ \~english The point cloud format named OBJ +}; + +/// \~chinese 3Dݵ \~english Save 3D data to buffer +typedef struct _MV_SAVE_POINT_CLOUD_PARAM_ +{ + unsigned int nLinePntNum; ///< [IN] \~chineseÿһеͼ \~english The number of points in each row,which is the width of the image + unsigned int nLineNum; ///< [IN] \~chineseͼ \~english The number of rows,which is the height of the image + + MvGvspPixelType enSrcPixelType; ///< [IN] \~chineseݵظʽ \~english The pixel format of the input data + unsigned char* pSrcData; ///< [IN] \~chineseݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chineseݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chineseݻ \~english Output pixel data buffer + unsigned int nDstBufSize; ///< [IN] \~chineseṩС(nLinePntNum * nLineNum * (16*3 + 4) + 2048) \~english Output buffer size provided(nLinePntNum * nLineNum * (16*3 + 4) + 2048) + unsigned int nDstBufLen; ///< [OUT] \~chineseݻ泤 \~english Output pixel data buffer size + MV_SAVE_POINT_CLOUD_FILE_TYPE enPointCloudFileType; ///< [IN] \~chineseṩĵļ \~english Output point data file type provided + + unsigned int nReserved[8]; ///< \~chinese ֶ \~english Reserved Field + +}MV_SAVE_POINT_CLOUD_PARAM; + +/// \~chinese ͼƬʽ \~english Save image type +enum MV_SAVE_IAMGE_TYPE +{ + MV_Image_Undefined = 0, ///< \~chinese δͼʽ \~english Undefined Image Type + MV_Image_Bmp = 1, ///< \~chinese BMPͼʽ \~english BMP Image Type + MV_Image_Jpeg = 2, ///< \~chinese JPEGͼʽ \~english Jpeg Image Type + MV_Image_Png = 3, ///< \~chinese PNGͼʽ \~english Png Image Type + MV_Image_Tif = 4, ///< \~chinese TIFFͼʽ \~english TIFF Image Type +}; + +/// \~chinese ͼƬ \~english Save Image Parameters +typedef struct _MV_SAVE_IMAGE_PARAM_T_EX_ +{ + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Input Data Pixel Format + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬС \~english Output Image Size + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + unsigned int nJpgQuality; ///< [IN] \~chinese JPG(50-99]ʽЧ \~english Encoding quality(50-99]Other formats are invalid + + ///< [IN] \~chinese BayerIJֵ 0- 1- 2-ţֵĬΪţ + ///< [IN] \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + unsigned int iMethodValue; ///< [IN] \~chinese ֵ \~english Method Value + unsigned int nReserved[3]; ///< \~chinese Ԥ \~english Reserved + +}MV_SAVE_IMAGE_PARAM_EX; + +/// \~chinese BMPJPEGPNGTIFFͼƬļIJ \~english Save BMPJPEGPNGTIFF image file parameters +typedef struct _MV_SAVE_IMG_TO_FILE_PARAM_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chineseݵظʽ \~english The pixel format of the input data + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Input Image Format + unsigned int nQuality; ///< [IN] \~chinese JPG(50-99]PNG[0-9]ʽЧ \~english JPG Encoding quality(50-99],PNG Encoding quality[0-9]Other formats are invalid + char pImagePath[256]; ///< [IN] \~chinese ļ· \~english Input file path + + ///< [IN] \~chinese BayerIJֵ 0- 1- 2-ţֵĬΪţ + ///< [IN] \~english Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + int iMethodValue; ///< [IN] \~chinese ֵ \~english Method Value + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_SAVE_IMG_TO_FILE_PARAM; + +/// \~chinese תǶ \~english Rotation angle +typedef enum _MV_IMG_ROTATION_ANGLE_ +{ + MV_IMAGE_ROTATE_90 = 1, + MV_IMAGE_ROTATE_180 = 2, + MV_IMAGE_ROTATE_270 = 3, + +}MV_IMG_ROTATION_ANGLE; + +/// \~chinese ͼתṹ \~english Rotate image structure +typedef struct _MV_CC_ROTATE_IMAGE_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ(֧Mono8/RGB24/BGR24) \~english Pixel format(Only support Mono8/RGB24/BGR24) + unsigned int nWidth; ///< [IN][OUT] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN][OUT] \~chinese ͼ \~english Height + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + + MV_IMG_ROTATION_ANGLE enRotationAngle; ///< [IN] \~chinese תǶ \~english Rotation angle + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_ROTATE_IMAGE_PARAM; + +/// \~chinese ת \~english Flip type +typedef enum _MV_IMG_FLIP_TYPE_ +{ + MV_FLIP_VERTICAL = 1, + MV_FLIP_HORIZONTAL = 2, + +}MV_IMG_FLIP_TYPE; + +/// \~chinese ͼתṹ \~english Flip image structure +typedef struct _MV_CC_FLIP_IMAGE_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ(֧Mono8/RGB24/BGR24) \~english Pixel format(Only support Mono8/RGB24/BGR24) + unsigned int nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ \~english Height + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + + MV_IMG_FLIP_TYPE enFlipType; ///< [IN] \~chinese ת \~english Flip type + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FLIP_IMAGE_PARAM; + +/// \~chinese ͼתṹ \~english Pixel convert structure +typedef struct _MV_PIXEL_CONVERT_PARAM_T_ +{ + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Height + + enum MvGvspPixelType enSrcPixelType; ///< [IN] \~chinese Դظʽ \~english Source pixel format + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + enum MvGvspPixelType enDstPixelType; ///< [IN] \~chinese Ŀظʽ \~english Destination pixel format + unsigned char* pDstBuffer; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstLen; ///< [OUT] \~chinese ݴС \~english Output data size + unsigned int nDstBufferSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + + unsigned int nRes[4]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_PIXEL_CONVERT_PARAM; + +/// \~chinese ɫʽ \~english Color correction param +typedef struct _MV_CC_CCM_PARAM_T_ +{ + bool bCCMEnable; ///< [IN] \~chinese ɫУʹ \~english Color correction enable + int nCCMat[9]; ///< [IN] \~chinese ɫʽ(-8192~8192) \~english Color correction matrix + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_CCM_PARAM; + +/// \~chinese \~english Noise feature type +typedef enum _MV_CC_BAYER_NOISE_FEATURE_TYPE +{ + MV_CC_BAYER_NOISE_FEATURE_TYPE_INVALID = 0, ///< \~chinese Чֵ \~english Invalid + MV_CC_BAYER_NOISE_FEATURE_TYPE_PROFILE = 1, ///< \~chinese \~english Noise curve + MV_CC_BAYER_NOISE_FEATURE_TYPE_LEVEL = 2, ///< \~chinese ˮƽ \~english Noise level + MV_CC_BAYER_NOISE_FEATURE_TYPE_DEFAULT = 1, ///< \~chinese Ĭֵ \~english Default + +}MV_CC_BAYER_NOISE_FEATURE_TYPE; + +/// \~chinese BayerʽϢ \~english Denoise profile info +typedef struct _MV_CC_BAYER_NOISE_PROFILE_INFO_T_ +{ + unsigned int nVersion; ///< \~chinese 汾 \~english version + MV_CC_BAYER_NOISE_FEATURE_TYPE enNoiseFeatureType; ///< \~chinese \~english noise feature type + enum MvGvspPixelType enPixelType; ///< \~chinese ͼʽ \~english image format + int nNoiseLevel; ///< \~chinese ƽˮƽ \~english noise level + unsigned int nCurvePointNum; ///< \~chinese ߵ \~english curve point number + int* nNoiseCurve; ///< \~chinese \~english noise curve + int* nLumCurve; ///< \~chinese \~english luminance curve + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_NOISE_PROFILE_INFO; + +/// \~chinese BayerʽƲ \~english Bayer noise estimate param +typedef struct _MV_CC_BAYER_NOISE_ESTIMATE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(ڵ8) \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ(ڵ8) \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned int nNoiseThreshold; ///< [IN] \~chinese ֵ(0-4095) \~english Noise Threshold + + unsigned char* pCurveBuf; ///< [IN] \~chinese ڴ洢ߺߣҪⲿ䣬С4096 * sizeof(int) * 2 \~english Buffer used to store noise and brightness curves, size:4096 * sizeof(int) * 2) + MV_CC_BAYER_NOISE_PROFILE_INFO stNoiseProfile; ///< [OUT] \~chinese Ϣ \~english Denoise profile + + unsigned int nThreadNum; ///< [IN] \~chinese ߳0ʾ㷨ӲӦ1ʾ̣߳Ĭϣ1ʾ߳Ŀ \~english Thread number, 0 means that the library is adaptive to the hardware, 1 means single thread(Default value), Greater than 1 indicates the number of threads + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_NOISE_ESTIMATE_PARAM; + +/// \~chinese Bayerʽ \~english Bayer spatial Denoise param +typedef struct _MV_CC_BAYER_SPATIAL_DENOISE_PARAM_T_ +{ + unsigned int nWidth; ///< [IN] \~chinese ͼ(ڵ8) \~english Width + unsigned int nHeight; ///< [IN] \~chinese ͼ(ڵ8) \~english Height + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Pixel format + + unsigned char* pSrcData; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcDataLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned char* pDstBuf; ///< [OUT] \~chinese \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided outbut buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݳ \~english Output data length + + MV_CC_BAYER_NOISE_PROFILE_INFO stNoiseProfile; ///< [IN] \~chinese Ϣ(Դ) \~english Denoise profile + unsigned int nDenoiseStrength; ///< [IN] \~chinese ǿ(0-100) \~english nDenoise Strength + unsigned int nSharpenStrength; ///< [IN] \~chinese ǿ(0-32) \~english Sharpen Strength + unsigned int nNoiseCorrect; ///< [IN] \~chinese Уϵ(0-1280) \~english Noise Correct + + unsigned int nThreadNum; ///< [IN] \~chinese ߳0ʾ㷨ӲӦ1ʾ̣߳Ĭϣ1ʾ߳Ŀ \~english Thread number, 0 means that the library is adaptive to the hardware, 1 means single thread(Default value), Greater than 1 indicates the number of threads + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_BAYER_SPATIAL_DENOISE_PARAM; + +/// \~chinese ˮӡϢ \~english Frame-specific information +typedef struct _MV_CC_FRAME_SPEC_INFO_ +{ + /// \~chinese 豸ˮӡʱ \~english Device frame-specific time scale + unsigned int nSecondCount; ///< [OUT] \~chinese \~english The Seconds + unsigned int nCycleCount; ///< [OUT] \~chinese \~english The Count of Cycle + unsigned int nCycleOffset; ///< [OUT] \~chinese ƫ \~english The Offset of Cycle + + float fGain; ///< [OUT] \~chinese \~english Gain + float fExposureTime; ///< [OUT] \~chinese عʱ \~english Exposure Time + unsigned int nAverageBrightness; ///< [OUT] \~chinese ƽ \~english Average brightness + + /// \~chinese ƽ \~english White balance + unsigned int nRed; ///< [OUT] \~chinese ɫ \~english Red + unsigned int nGreen; ///< [OUT] \~chinese ɫ \~english Green + unsigned int nBlue; ///< [OUT] \~chinese ɫ \~english Blue + + unsigned int nFrameCounter; ///< [OUT] \~chinese ֡ \~english Frame Counter + unsigned int nTriggerIndex; ///< [OUT] \~chinese \~english Trigger Counting + + unsigned int nInput; ///< [OUT] \~chinese \~english Input + unsigned int nOutput; ///< [OUT] \~chinese \~english Output + + /// \~chinese ROI \~english ROI Region + unsigned short nOffsetX; ///< [OUT] \~chinese ˮƽƫ \~english OffsetX + unsigned short nOffsetY; ///< [OUT] \~chinese ֱƫ \~english OffsetY + unsigned short nFrameWidth; ///< [OUT] \~chinese ˮӡ \~english The Width of Chunk + unsigned short nFrameHeight; ///< [OUT] \~chinese ˮӡ \~english The Height of Chunk + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FRAME_SPEC_INFO; + +/// \~chinese \~english High Bandwidth decode structure +typedef struct _MV_CC_HB_DECODE_PARAM_T_ +{ + unsigned char* pSrcBuf; ///< [IN] \~chinese ݻ \~english Input data buffer + unsigned int nSrcLen; ///< [IN] \~chinese ݴС \~english Input data size + + unsigned int nWidth; ///< [OUT] \~chinese ͼ \~english Width + unsigned int nHeight; ///< [OUT] \~chinese ͼ \~english Height + unsigned char* pDstBuf; ///< [OUT] \~chinese ݻ \~english Output data buffer + unsigned int nDstBufSize; ///< [IN] \~chinese ṩС \~english Provided output buffer size + unsigned int nDstBufLen; ///< [OUT] \~chinese ݴС \~english Output data size + MvGvspPixelType enDstPixelType; ///< [OUT] \~chinese ظʽ \~english Output pixel format + + MV_CC_FRAME_SPEC_INFO stFrameSpecInfo; ///< [OUT] \~chinese ˮӡϢ \~english Frame Spec Info + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_HB_DECODE_PARAM; + +/// \~chinese ¼ʽ \~english Record Format Type +typedef enum _MV_RECORD_FORMAT_TYPE_ +{ + MV_FormatType_Undefined = 0, ///< \~chinese δ¼ʽ \~english Undefined Recode Format Type + MV_FormatType_AVI = 1, ///< \~chinese AVI¼ʽ \~english AVI Recode Format Type + +}MV_RECORD_FORMAT_TYPE; + +/// \~chinese ¼ \~english Record Parameters +typedef struct _MV_CC_RECORD_PARAM_T_ +{ + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ݵظʽ \~english Pixel Type + + unsigned short nWidth; ///< [IN] \~chinese ͼ(ָĿʱΪ2ı) \~english Width + unsigned short nHeight; ///< [IN] \~chinese ͼ(ָĿʱΪ2ı) \~english Height + + float fFrameRate; ///< [IN] \~chinese ֡fps(1/16) \~english The Rate of Frame + unsigned int nBitRate; ///< [IN] \~chinese kbps(128kbps-16Mbps) \~english The Rate of Bitrate + + MV_RECORD_FORMAT_TYPE enRecordFmtType; ///< [IN] \~chinese ¼ʽ \~english Recode Format Type + + char* strFilePath; ///< [IN] \~chinese ¼ļ·(·дģתutf-8) \~english File Path + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_RECORD_PARAM; + +/// \~chinese ͼ \~english Input Data +typedef struct _MV_CC_INPUT_FRAME_INFO_T_ +{ + unsigned char* pData; ///< [IN] \~chinese ͼָ \~english Record Data + unsigned int nDataLen; ///< [IN] \~chinese ͼС \~english The Length of Record Data + + unsigned int nRes[8]; ///< \~chinese Ԥ \~english Reserved + +}MV_CC_INPUT_FRAME_INFO; + +/// \~chinese ɼģʽ \~english Acquisition mode +typedef enum _MV_CAM_ACQUISITION_MODE_ +{ + MV_ACQ_MODE_SINGLE = 0, ///< \~chinese ֡ģʽ \~english Single Mode + MV_ACQ_MODE_MUTLI = 1, ///< \~chinese ֡ģʽ \~english Multi Mode + MV_ACQ_MODE_CONTINUOUS = 2, ///< \~chinese ɼģʽ \~english Continuous Mode + +}MV_CAM_ACQUISITION_MODE; + +/// \~chinese ģʽ \~english Gain Mode +typedef enum _MV_CAM_GAIN_MODE_ +{ + MV_GAIN_MODE_OFF = 0, ///< \~chinese ر \~english Single Mode + MV_GAIN_MODE_ONCE = 1, ///< \~chinese һ \~english Multi Mode + MV_GAIN_MODE_CONTINUOUS = 2, ///< \~chinese \~english Continuous Mode + +}MV_CAM_GAIN_MODE; + +/// \~chinese عģʽ \~english Exposure Mode +typedef enum _MV_CAM_EXPOSURE_MODE_ +{ + MV_EXPOSURE_MODE_TIMED = 0, ///< \~chinese ʱ \~english Timed + MV_EXPOSURE_MODE_TRIGGER_WIDTH = 1, ///< \~chinese \~english TriggerWidth +}MV_CAM_EXPOSURE_MODE; + +/// \~chinese Զعģʽ \~english Auto Exposure Mode +typedef enum _MV_CAM_EXPOSURE_AUTO_MODE_ +{ + MV_EXPOSURE_AUTO_MODE_OFF = 0, ///< \~chinese ر \~english Off + MV_EXPOSURE_AUTO_MODE_ONCE = 1, ///< \~chinese һ \~english Once + MV_EXPOSURE_AUTO_MODE_CONTINUOUS = 2, ///< \~chinese \~english Continuous + +}MV_CAM_EXPOSURE_AUTO_MODE; + +/// \~chinese ģʽ \~english Trigger Mode +typedef enum _MV_CAM_TRIGGER_MODE_ +{ + MV_TRIGGER_MODE_OFF = 0, ///< \~chinese ر \~english Off + MV_TRIGGER_MODE_ON = 1, ///< \~chinese \~english ON + +}MV_CAM_TRIGGER_MODE; + +/// \~chinese Gammaѡ \~english Gamma Selector +typedef enum _MV_CAM_GAMMA_SELECTOR_ +{ + MV_GAMMA_SELECTOR_USER = 1, ///< \~chinese û \~english Gamma Selector User + MV_GAMMA_SELECTOR_SRGB = 2, ///< \~chinese sRGB \~english Gamma Selector sRGB + +}MV_CAM_GAMMA_SELECTOR; + +/// \~chinese ƽ \~english White Balance +typedef enum _MV_CAM_BALANCEWHITE_AUTO_ +{ + MV_BALANCEWHITE_AUTO_OFF = 0, ///< \~chinese ر \~english Off + MV_BALANCEWHITE_AUTO_ONCE = 2, ///< \~chinese һ \~english Once + MV_BALANCEWHITE_AUTO_CONTINUOUS = 1, ///< \~chinese \~english Continuous + +}MV_CAM_BALANCEWHITE_AUTO; + +/// \~chinese Դ \~english Trigger Source +typedef enum _MV_CAM_TRIGGER_SOURCE_ +{ + MV_TRIGGER_SOURCE_LINE0 = 0, ///< \~chinese Line0 \~english Line0 + MV_TRIGGER_SOURCE_LINE1 = 1, ///< \~chinese Line1 \~english Line0 + MV_TRIGGER_SOURCE_LINE2 = 2, ///< \~chinese Line2 \~english Line0 + MV_TRIGGER_SOURCE_LINE3 = 3, ///< \~chinese Line3 \~english Line3 + MV_TRIGGER_SOURCE_COUNTER0 = 4, ///< \~chinese Conuter0 \~english Conuter0 + + MV_TRIGGER_SOURCE_SOFTWARE = 7, ///< \~chinese \~english Software + MV_TRIGGER_SOURCE_FrequencyConverter= 8, ///< \~chinese Ƶ \~english Frequency Converter + +}MV_CAM_TRIGGER_SOURCE; + +/// \~chinese GigEVision IP \~english GigEVision IP Configuration +#define MV_IP_CFG_STATIC 0x05000000 ///< \~chinese ̬ \~english Static +#define MV_IP_CFG_DHCP 0x06000000 ///< \~chinese DHCP \~english DHCP +#define MV_IP_CFG_LLA 0x04000000 ///< \~chinese LLA \~english LLA + +/// \~chinese GigEVision紫ģʽ \~english GigEVision Net Transfer Mode +#define MV_NET_TRANS_DRIVER 0x00000001 ///< \~chinese \~english Driver +#define MV_NET_TRANS_SOCKET 0x00000002 ///< \~chinese Socket \~english Socket + +/// \~chinese CameraLink \~english CameraLink Baud Rates (CLUINT32) +#define MV_CAML_BAUDRATE_9600 0x00000001 ///< \~chinese 9600 \~english 9600 +#define MV_CAML_BAUDRATE_19200 0x00000002 ///< \~chinese 19200 \~english 19200 +#define MV_CAML_BAUDRATE_38400 0x00000004 ///< \~chinese 38400 \~english 38400 +#define MV_CAML_BAUDRATE_57600 0x00000008 ///< \~chinese 57600 \~english 57600 +#define MV_CAML_BAUDRATE_115200 0x00000010 ///< \~chinese 115200 \~english 115200 +#define MV_CAML_BAUDRATE_230400 0x00000020 ///< \~chinese 230400 \~english 230400 +#define MV_CAML_BAUDRATE_460800 0x00000040 ///< \~chinese 460800 \~english 460800 +#define MV_CAML_BAUDRATE_921600 0x00000080 ///< \~chinese 921600 \~english 921600 +#define MV_CAML_BAUDRATE_AUTOMAX 0x40000000 ///< \~chinese ֵ \~english Auto Max + +/// \~chinese 쳣Ϣ \~english Exception message type +#define MV_EXCEPTION_DEV_DISCONNECT 0x00008001 ///< \~chinese 豸Ͽ \~english The device is disconnected +#define MV_EXCEPTION_VERSION_CHECK 0x00008002 ///< \~chinese SDK汾ƥ \~english SDK does not match the driver version + +/// \~chinese Event¼صϢ\ \~english Event callback infomation +#define MAX_EVENT_NAME_SIZE 128 ///< \~chinese 豸Event¼󳤶 \~english Max length of event name +typedef struct _MV_EVENT_OUT_INFO_ +{ + char EventName[MAX_EVENT_NAME_SIZE]; ///< [OUT] \~chinese Event \~english Event name + + unsigned short nEventID; ///< [OUT] \~chinese Event \~english Event ID + unsigned short nStreamChannel; ///< [OUT] \~chinese ͨ \~english Circulation number + + unsigned int nBlockIdHigh; ///< [OUT] \~chinese ֡Ÿλ \~english BlockId high + unsigned int nBlockIdLow; ///< [OUT] \~chinese ֡ŵλ \~english BlockId low + + unsigned int nTimestampHigh; ///< [OUT] \~chinese ʱλ \~english Timestramp high + unsigned int nTimestampLow; ///< [OUT] \~chinese ʱλ \~english Timestramp low + + void* pEventData; ///< [OUT] \~chinese Event \~english Event data + unsigned int nEventDataSize; ///< [OUT] \~chinese Eventݳ \~english Event data len + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved +}MV_EVENT_OUT_INFO; + +/// \~chinese ļȡ \~english File Access +typedef struct _MV_CC_FILE_ACCESS_T +{ + const char* pUserFileName; ///< [IN] \~chinese ûļ \~english User file name + const char* pDevFileName; ///< [IN] \~chinese 豸ļ \~english Device file name + + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FILE_ACCESS; + +/// \~chinese ļȡ \~english File Access Progress +typedef struct _MV_CC_FILE_ACCESS_PROGRESS_T +{ + int64_t nCompleted; ///< [OUT] \~chinese ɵij \~english Completed Length + int64_t nTotal; ///< [OUT] \~chinese ܳ \~english Total Length + + unsigned int nReserved[8]; ///< \~chinese Ԥ \~english Reserved +}MV_CC_FILE_ACCESS_PROGRESS; + +/// \~chinese GigeĴ \~english The transmission type of Gige +typedef enum _MV_GIGE_TRANSMISSION_TYPE_ +{ + MV_GIGE_TRANSTYPE_UNICAST = 0x0, ///< \~chinese ʾ(Ĭ) \~english Unicast mode + MV_GIGE_TRANSTYPE_MULTICAST = 0x1, ///< \~chinese ʾ鲥 \~english Multicast mode + MV_GIGE_TRANSTYPE_LIMITEDBROADCAST = 0x2, ///< \~chinese ʾڹ㲥ݲ֧ \~english Limited broadcast mode,not support + MV_GIGE_TRANSTYPE_SUBNETBROADCAST = 0x3, ///< \~chinese ʾڹ㲥ݲ֧ \~english Subnet broadcast mode,not support + MV_GIGE_TRANSTYPE_CAMERADEFINED = 0x4, ///< \~chinese ʾ豸ȡݲ֧ \~english Transtype from camera,not support + MV_GIGE_TRANSTYPE_UNICAST_DEFINED_PORT = 0x5, ///< \~chinese ʾûԶӦö˽ͼPort \~english User Defined Receive Data Port + MV_GIGE_TRANSTYPE_UNICAST_WITHOUT_RECV = 0x00010000, ///< \~chinese ʾ˵ʵͼ \~english Unicast without receive data + MV_GIGE_TRANSTYPE_MULTICAST_WITHOUT_RECV = 0x00010001, ///< \~chinese ʾ鲥ģʽʵͼ \~english Multicast without receive data +}MV_GIGE_TRANSMISSION_TYPE; + +/// \~chinese ģʽΪģʽ鲥ģʽ \~english Transmission type +typedef struct _MV_TRANSMISSION_TYPE_T +{ + MV_GIGE_TRANSMISSION_TYPE enTransmissionType; ///< [IN] \~chinese ģʽ \~english Transmission type + unsigned int nDestIp; ///< [IN] \~chinese ĿIP鲥ģʽ \~english Destination IP + unsigned short nDestPort; ///< [IN] \~chinese ĿPort鲥ģʽ \~english Destination port + + unsigned int nReserved[32]; ///< \~chinese Ԥ \~english Reserved +}MV_TRANSMISSION_TYPE; + +/// \~chinese Ϣ \~english Action Command +typedef struct _MV_ACTION_CMD_INFO_T +{ + unsigned int nDeviceKey; ///< [IN] \~chinese 豸Կ \~english Device Key; + unsigned int nGroupKey; ///< [IN] \~chinese \~english Group Key + unsigned int nGroupMask; ///< [IN] \~chinese \~english Group Mask + + unsigned int bActionTimeEnable; ///< [IN] \~chinese ֻó1ʱAction TimeЧ1ʱЧ \~english Action Time Enable + int64_t nActionTime; ///< [IN] \~chinese Ԥʱ䣬Ƶй \~english Action Time + + const char* pBroadcastAddress; ///< [IN] \~chinese 㲥ַ \~english Broadcast Address + unsigned int nTimeOut; ///< [IN] \~chinese ȴACKijʱʱ䣬Ϊ0ʾҪACK \~english TimeOut + + unsigned int bSpecialNetEnable; ///< [IN] \~chinese ֻó1ʱָIPЧ1ʱЧ \~english Special IP Enable + unsigned int nSpecialNetIP; ///< [IN] \~chinese ָIP \~english Special Net IP address + + unsigned int nReserved[14]; ///< \~chinese Ԥ \~english Reserved + +}MV_ACTION_CMD_INFO; + +/// \~chinese Ϣ \~english Action Command Result +typedef struct _MV_ACTION_CMD_RESULT_T +{ + unsigned char strDeviceAddress[12 + 3 + 1]; ///< [OUT] \~chinese 豸IP \~english IP address of the device + + int nStatus; ///< [OUT] \~chinese ״̬ \~english status code returned by the device + //1.0x0000:success. + //2.0x8001:Command is not supported by the device. + //3.0x8013:The device is not synchronized to a master clock to be used as time reference. + //4.0x8015:A device queue or packet data has overflowed. + //5.0x8016:The requested scheduled action command was requested at a time that is already past. + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved + +}MV_ACTION_CMD_RESULT; + +/// \~chinese Ϣб \~english Action Command Result List +typedef struct _MV_ACTION_CMD_RESULT_LIST_T +{ + unsigned int nNumResults; ///< [OUT] \~chinese ֵ \~english Number of returned values + MV_ACTION_CMD_RESULT* pResults; ///< [OUT] \~chinese \~english Reslut of action command + +}MV_ACTION_CMD_RESULT_LIST; + +/// \~chinese ÿڵӦĽӿ \~english Interface type corresponds to each node +enum MV_XML_InterfaceType +{ + IFT_IValue, ///< \~chinese Value \~english IValue interface + IFT_IBase, ///< \~chinese Base \~english IBase interface + IFT_IInteger, ///< \~chinese Integer \~english IInteger interface + IFT_IBoolean, ///< \~chinese Boolean \~english IBoolean interface + IFT_ICommand, ///< \~chinese Command \~english ICommand interface + IFT_IFloat, ///< \~chinese Float \~english IFloat interface + IFT_IString, ///< \~chinese String \~english IString interface + IFT_IRegister, ///< \~chinese Register \~english IRegister interface + IFT_ICategory, ///< \~chinese Category \~english ICategory interface + IFT_IEnumeration, ///< \~chinese Enumeration \~english IEnumeration interface + IFT_IEnumEntry, ///< \~chinese EnumEntry \~english IEnumEntry interface + IFT_IPort, ///< \~chinese Port \~english IPort interface +}; + +/// \~chinese ڵķģʽ \~english Node Access Mode +enum MV_XML_AccessMode +{ + AM_NI, ///< \~chinese ʵ \~english Not implemented + AM_NA, ///< \~chinese \~english Not available + AM_WO, ///< \~chinese ֻд \~english Write Only + AM_RO, ///< \~chinese ֻ \~english Read Only + AM_RW, ///< \~chinese д \~english Read and Write + AM_Undefined, ///< \~chinese δ \~english Object is not yet initialized + AM_CycleDetect, ///< \~chinese ڲAccessModeѭ \~english used internally for AccessMode cycle detection +}; + +#define MV_MAX_XML_SYMBOLIC_NUM 64 /// \~chinese XML \~english Max XML Symbolic Number +/// \~chinese öֵ \~english Enumeration Value +typedef struct _MVCC_ENUMVALUE_T +{ + unsigned int nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + unsigned int nSupportedNum; ///< [OUT] \~chinese ݵЧݸ \~english Number of valid data + unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; ///< [OUT] \~chinese ֵ֧öֵ \~english Support Value + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MVCC_ENUMVALUE; + +/// \~chinese Intֵ \~english Int Value +typedef struct _MVCC_INTVALUE_T +{ + unsigned int nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + unsigned int nMax; ///< [OUT] \~chinese ֵ \~english Max + unsigned int nMin; ///< [OUT] \~chinese Сֵ \~english Min + unsigned int nInc; ///< [OUT] \~chinese \~english Inc + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MVCC_INTVALUE; + +/// \~chinese IntֵEx \~english Int Value Ex +typedef struct _MVCC_INTVALUE_EX_T +{ + int64_t nCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + int64_t nMax; ///< [OUT] \~chinese ֵ \~english Max + int64_t nMin; ///< [OUT] \~chinese Сֵ \~english Min + int64_t nInc; ///< [OUT] \~chinese Inc \~english Inc + + unsigned int nReserved[16]; ///< \~chinese Ԥ \~english Reserved +}MVCC_INTVALUE_EX; + +/// \~chinese Floatֵ \~english Float Value +typedef struct _MVCC_FLOATVALUE_T +{ + float fCurValue; ///< [OUT] \~chinese ǰֵ \~english Current Value + float fMax; ///< [OUT] \~chinese ֵ \~english Max + float fMin; ///< [OUT] \~chinese Сֵ \~english Min + + unsigned int nReserved[4]; ///< \~chinese Ԥ \~english Reserved +}MVCC_FLOATVALUE; + +/// \~chinese Stringֵ \~english String Value +typedef struct _MVCC_STRINGVALUE_T +{ + char chCurValue[256]; ///< [OUT] \~chinese ǰֵ \~english Current Value + + int64_t nMaxLength; ///< [OUT] \~chinese 󳤶 \~english MaxLength + unsigned int nReserved[2]; ///< \~chinese Ԥ \~english Reserved +}MVCC_STRINGVALUE; + +#endif /* _MV_CAMERA_PARAMS_H_ */ diff --git a/CigaretteSingle/MVS3.2.1/Include/MvCameraControl.h b/CigaretteSingle/MVS3.2.1/Include/MvCameraControl.h new file mode 100644 index 0000000..f5e33d8 --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/MvCameraControl.h @@ -0,0 +1,2007 @@ + +#ifndef _MV_CAMERA_CTRL_H_ +#define _MV_CAMERA_CTRL_H_ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "MvObsoleteInterfaces.h" + +/************************************************************************/ +/* ̬⵼뵼 */ +/* Import and export definition of the dynamic library */ +/************************************************************************/ +#ifndef MV_CAMCTRL_API + + #if (defined (_WIN32) || defined(WIN64)) + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __declspec(dllexport) + #else + #define MV_CAMCTRL_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MV_CAMCTRL_API + #define MV_CAMCTRL_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* 豸ĻָͲ */ +/* Camera basic instructions and operations */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡSDK汾 + * @return 4ֽڰ汾 + | | | | | + 8bits 8bits 8bits 8bits + * @remarks 緵ֵΪ0x01000001SDK汾ΪV1.0.0.1 + + * @~english + * @brief Get SDK Version + * @return Always return 4 Bytes of version number + |Main |Sub |Rev | Test| + 8bits 8bits 8bits 8bits + * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. + ************************************************************************/ +MV_CAMCTRL_API unsigned int __stdcall MV_CC_GetSDKVersion(); + +/********************************************************************//** + * @~chinese + * @brief ȡֵ֧Ĵ + * @return ֵ֧Ĵ + + * @~english + * @brief Get supported Transport Layer + * @return Supported Transport Layer number + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumerateTls(); + +/********************************************************************//** + * @~chinese + * @brief ö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Device + * @param nTLayerType [IN] Enumerate TLs + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevices(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ݳö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @param strManufacturerName [IN] + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate device according to manufacture name + * @param nTLayerType [IN] Transmission layer of enumeration + * @param pstDevList [OUT] Device list + * @param strManufacturerName [IN] Manufacture Name + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName); + +/********************************************************************//** + * @~chinese + * @brief 豸Ƿɴ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param nAccessMode [IN] Ȩ + * @return ɴtrueɴfalse + * @remarks ȡ豸CCPĴֵжϵǰ״̬ǷijַȨޡ \n + 豸֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableWithKeyģʽӿڷfalseĿǰ豸֧3ռģʽij̵豸Ҳݲ֧3ģʽ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Is the device accessible + * @param pstDevInfo [IN] Device Information Structure + * @param nAccessMode [IN] Access Right + * @return Access, return true. Not access, return false + * @remarks Read device CCP register value and determine current access permission.\n + Return false if the device does not support the modes MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode); + +/********************************************************************//** + * @~chinese + * @brief SDK־· + * @param strSDKLogPath [IN] SDK־· + * @return ɹMV_OK󣬷ش + * @remarks ·֮󣬿ָ·־\n + v2.4.1汾־񣬿֮ýӿЧĬ־Ϊ״̬ + + * @~english + * @brief Set SDK log path + * @param strSDKLogPath [IN] SDK log path + * @return Access, return true. Not access, return false + * @remarks For version V2.4.1, added log service, this API is invalid when the service is enabled.And The logging service is enabled by default\n + This API is used to set the log file storing path. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSDKLogPath(IN const char * strSDKLogPath); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandleWithoutLog + + * @~english + * @brief Create Device Handle + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will be created by default. Creating handle through MV_CC_CreateHandleWithoutLog will not generate log files. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandle(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸־ + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandle־ļԶɡ + + * @~english + * @brief Create Device Handle without log + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleWithoutLog(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Destroy Device Handle + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DestroyHandle(IN void * handle); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nAccessMode [IN] Ȩ + * @param nSwitchoverKey [IN] лȨʱԿ + * @return ɹMV_OK󣬷ش + * @remarks õ豸ҵӦ豸豸\n + ýӿʱɲnAccessModenSwitchoverKeyʱĬ豸ģʽΪռȨޡĿǰ豸ݲ֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableMV_ACCESS_ControlSwitchEnableWithKeyռģʽ\n + U3V豸nAccessModenSwitchoverKeyЧ + + * @~english + * @brief Open Device + * @param handle [IN] Device handle + * @param nAccessMode [IN] Access Right + * @param nSwitchoverKey [IN] Switch key of access right + * @return Success, return MV_OK. Failure, return error code + * @remarks Find specific device and connect according to set device parameters. \n + When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access mode is exclusive. Currently the device does not support the following preemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.\n + For USB3Vision device, nAccessMode, nSwitchoverKey are invalid. + ************************************************************************/ +#ifndef __cplusplus +MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey); +#else +MV_CAMCTRL_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode = MV_ACCESS_Exclusive, IN unsigned short nSwitchoverKey = 0); +#endif + +/********************************************************************//** + * @~chinese + * @brief ر豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ͨMV_CC_OpenDevice豸󣬿ͨýӿڶϿ豸ӣͷԴ + + * @~english + * @brief Close Device + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CloseDevice(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ж豸Ƿ״̬ + * @param handle [IN] 豸 + * @return 豸״̬trueûӻʧȥӣfalse + + * @~english + * @brief Is The Device Connected + * @param handle [IN] Device handle + * @return Connected, return true. Not Connected or DIsconnected, return false + ***********************************************************************/ +MV_CAMCTRL_API bool __stdcall MV_CC_IsDeviceConnected(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief עͼݻص + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackExͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetOneFrameTimeoutȡָظʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register the image callback function + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.\n + There are two available image data acquisition modes, and cannot be used together: \n + Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackEx(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصRGB + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForRGBRGB24ʽͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForRGBȡRGB24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, RGB + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB repeatedly in application layer to get frame data with RGB24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForRGB(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصBGR + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá\n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForBGRBGR24ͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForBGRȡBGR24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, BGR + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.\n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBackForBGR(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief ʼȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Start Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StartGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ֹͣȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Stop Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StopGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡RGBݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתRGB24ʽأû򷵻ش롣ΪͼתRGB24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡\n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of RGB data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Each time the API is called, the internal cache is checked for data. If there is data, it will be transformed as RGB24 format for return, if there is no data, return error code. As time-consuming exists when transform the image to RGB24 format, this API may cause frame loss when the data frame rate is too high. \n + Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡BGRݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתBGR24ʽأû򷵻ش롣ΪͼתBGR24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡ \n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of BGR data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ʹڲȡһ֡ͼƬMV_CC_Displayͬʱʹã + * @param handle [IN] 豸 + * @param pstFrame [OUT] ͼݺͼϢ + * @param nMsec [IN] ȴʱʱ䣬INFINITEʱʾ޵ȴֱյһ֡ݻֹͣȡ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ \n + ýӿMV_CC_FreeImageBufferʹãȡݺҪMV_CC_FreeImageBufferӿڽpFrameڵָȨ޽ͷš \n + ýӿMV_CC_GetOneFrameTimeoutȣŸߵЧʡȡķsdkڲԶģMV_CC_GetOneFrameTimeoutӿҪͻз䡣\n + ýӿڵMV_CC_Display޷ȡ \n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get a frame of an image using an internal cache + * @param handle [IN] Device handle + * @param pstFrame [OUT] Image data and image information + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API support setting timeout, and SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. \n + This interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. \n + This API cannot be called to stream after calling MV_CC_Display. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. \n + **********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageBuffer(IN void* handle, OUT MV_FRAME_OUT* pstFrame, IN unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ͷͼ񻺴(˽ӿͷŲʹõͼ񻺴棬MV_CC_GetImageBufferʹ) + * @param handle [IN] 豸 + * @param pstFrame [IN] ͼݺͼ + * @return ɹMV_OK󣬷ش + * @remarks ýӿMV_CC_GetImageBufferʹãʹMV_CC_GetImageBufferӿȡͼpFrameҪMV_CC_FreeImageBufferӿڽȨͷš \n + ýӿڶȡЧʸGetOneFrameTimeoutӿڣGetImageBufferڲFree£֧ĽڵSetImageNodeӿõĽڵȣĬϽڵ1\n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) + * @param handle [IN] Device handle + * @param pstFrame [IN] Image data and image information + * @return Success, return MV_OK. Failure, return error code + * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to get image data pFrame, you should call MV_CC_FreeImageBuffer to release the permission. \n + Compared with API MV_CC_GetOneFrameTimeout, this API has higher efficiency of image acquisition. The max. number of nodes can be outputted is same as the "nNum" of API MV_CC_SetImageNodeNum, default value is 1. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. + **********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pstFrame); + +/********************************************************************//** + * @~chinese + * @brief óʱƻȡһ֡ͼƬSDKڲȴֱʱ + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ\n + ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API supports setting timeout, SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + Both the USB3Vision and GIGE camera can support this API. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameTimeout(IN void* handle, IN OUT unsigned char* pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡݻ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿûڲֹͣȡʱ򣬾вҪͼ\n + ýӿģʽдģʽ󣬿ʷݡ + + * @~english + * @brief if Image buffers has retrieved the dataClear them + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface allows user to clear the unnecessary images from the buffer memory without stopping acquisition. \n + This interface allows user to clear previous data after switching from continuous mode to trigger mode. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ClearImageBuffer(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ʾһ֡ͼ + * @param handle [IN] 豸 + * @param pstDisplayInfo [IN] ͼϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Display one frame image + * @param handle [IN] Device handle + * @param pstDisplayInfo [IN] Frame Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is valid for USB3Vision camera and GIGE camera. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pstDisplayInfo); + +/********************************************************************//** + * @~chinese + * @brief SDKڲͼ񻺴ڵڵ1ץͼǰ + * @param handle [IN] 豸 + * @param nNum [IN] ڵ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڿSDKڲͼ񻺴ڵڵMV_CC_StartGrabbingʼץͼǰá\n + SDKĬ1ڵ㡣\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture + * @param handle [IN] Device handle + * @param nNum [IN] Image Node Number + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface to set the number of SDK internal image buffer nodes. The interface should be called before calling MV_CC_StartGrabbing for capturing. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetImageNodeNum(IN void* handle, unsigned int nNum); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param enGrabStrategy [IN] öֵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶȡԣûԸʵѡ񡣾£ + -OneByOne:Ӿɵһ֡һ֡Ĵблȡͼ񣬴豸ĬΪò + -LatestImagesOnly:блȡµһ֡ͼͬʱб + -LatestImages:блȡµOutputQueueSize֡ͼOutputQueueSizeΧΪ1-ImageNodeNumMV_CC_SetOutputQueueSizeӿãImageNodeNumĬΪ1MV_CC_SetImageNodeNumӿ OutputQueueSizeó1ͬLatestImagesOnlyԣOutputQueueSizeóImageNodeNumͬOneByOne + -UpcomingImage:ڵȡӿʱбͼ񣬲ȴ豸ɵһ֡ͼ񡣸òֻ֧GigE豸֧U3V豸 + + * @~english + * @brief Set Grab Strategy + * @param handle [IN] Device handle + * @param enGrabStrategy [IN] The value of Grab Strategy + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is set by four image acquisition approaches, the user may choose one as needed. Specific details are as followed: + -OneByOne:Obtain image from output cache list frame by frame in order, this function is default strategy when device is on. + -LatestImagesOnly:Obtain the latest image from output cache list only, meanwhile clear output cache list. + -LatestImages:Obtain the latest OutputQueueSize image from output cache list, the range of OutputQueueSize is 1-ImageNodeNum, the user may set the value of MV_CC_SetOutputQueueSizeinterface,the default value of ImageNodeNum is 1,If the user usesMV_CC_SetImageNodeNuminterface to set up OutputQueueSize,when the value of OutputQueueSize is set to be 1, the function will be same as LatestImagesOnly; if the value of OutputQueueSize is set to be ImageNodeNum, the function will be same as OneByOne. + -UpcomingImage:Ignore all images in output cache list when calling image acuiqisiotn interface, wait the next upcoming image generated. Support for GigE camera only, not support for U3V camera. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGrabStrategy(IN void* handle, IN MV_GRAB_STRATEGY enGrabStrategy); + +/********************************************************************//** + * @~chinese + * @brief ֻMV_GrabStrategy_LatestImages²ЧΧ1-ImageNodeNum + * @param handle [IN] 豸 + * @param nOutputQueueSize [IN] + * @return ɹMV_OK󣬷ش + * @remarks ýӿLatestImagesȡ׵ãLatestImagesͼĸȡж̬ + + * @~english + * @brief Set The Size of Output Queue(Only work under the strategy of MV_GrabStrategy_LatestImagesrang1-ImageNodeNum) + * @param handle [IN] Device handle + * @param nOutputQueueSize [IN] The Size of Output Queue + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface must be used with LatestImages Grab strategy, it is used for setting the maximum allowance queue size of the image under the LatestImages strategy. The user may change the output queue size while grabbing images. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetOutputQueueSize(IN void* handle, IN unsigned int nOutputQueueSize); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸Ϣȡ֮ǰ + * @param handle [IN] 豸 + * @param pstDevInfo [IN][OUT] ظй豸Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ֧ûڴ豸ȡ豸Ϣ\n + 豸GigE豸øýӿڴգ˲ȡеøýӿڡ + + * @~english + * @brief Get device information + * @param handle [IN] Device handle + * @param pstDevInfo [IN][OUT] Structure pointer of device information + * @return Success, return MV_OK. Failure, return error code + * @remarks The API support users to access device information after opening the device. \n + If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not recommended to call the interface during the fetching process. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief ȡ͵Ϣ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظй豸͵Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӿҪȡϢָͣMV_ALL_MATCH_INFOṹеnTypeͣȡӦϢMV_ALL_MATCH_INFOṹpInfoﷵأ \n + ýӿڵĵǰȡȡϢͣȡGigE豸MV_MATCH_TYPE_NET_DETECTϢڿץͼ֮ãȡU3V豸MV_MATCH_TYPE_USB_DETECTϢڴ豸֮á \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get various type of information + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of various type of information + * @return Success, return MV_OK. Failure, return error code + * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO). \n + The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo); + + +/************************************************************************/ +/* úͻȡ豸ܽӿ */ +/* General interface for getting and setting camera parameters */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡIntegerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param pstIntValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to get width + * @param pstIntValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE_EX *pstIntValue); + +/********************************************************************//** + * @~chinese + * @brief Integerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to set width + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue); + +/********************************************************************//** + * @~chinese + * @brief ȡEnumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param pstEnumValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel format + * @param pstEnumValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetEnumValue(IN void* handle,IN const char* strKey,OUT MVCC_ENUMVALUE *pstEnumValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param strValue [IN] Ҫõ豸ַ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param strValue [IN] Feature String to set + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API after connecting the device. All the values of nodes with IEnumeration type can be set via this API. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetEnumValueByString(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief ȡFloatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstFloatValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstFloatValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFloatValue(IN void* handle,IN const char* strKey,OUT MVCC_FLOATVALUE *pstFloatValue); + +/********************************************************************//** + * @~chinese + * @brief floatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param fValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param fValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFloatValue(IN void* handle,IN const char* strKey,IN float fValue); + +/********************************************************************//** + * @~chinese + * @brief ȡBooleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pbValue [IN][OUT] ظй豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pbValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBoolValue(IN void* handle,IN const char* strKey,OUT bool *pbValue); + +/********************************************************************//** + * @~chinese + * @brief Booleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param bValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param bValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBoolValue(IN void* handle,IN const char* strKey,IN bool bValue); + +/********************************************************************//** + * @~chinese + * @brief ȡStringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstStringValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstStringValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetStringValue(IN void* handle,IN const char* strKey,OUT MVCC_STRINGVALUE *pstStringValue); + +/********************************************************************//** + * @~chinese + * @brief Stringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param strValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param strValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetStringValue(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief Commandֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿָCommandͽڵ㡣strKeyȡֵԲοXMLڵбΪICommandĽڵ㶼ͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Send Command + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Command nodes. For value of strKey, see MvCameraNode. The node values of ICommand can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetCommandValue(IN void* handle,IN const char* strKey); + +/********************************************************************//** + * @~chinese + * @brief GenICamڵ㻺 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Invalidate GenICam Nodes + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_InvalidateNodes(IN void* handle); + + +/************************************************************************/ +/* 豸 Ĵд 쳣¼ص */ +/* Device upgrade, register read and write and exception callback */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFilePathName [IN] ļ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԽ̼ļ͸豸ýӿҪȴ̼ļɹ豸֮ٷأӦʱܽϳ + + * @~english + * @brief Device Local Upgrade + * @param handle [IN] Device handle + * @param strFilePathName [IN] File name + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to send the upgrade firmware to the device for upgrade. This API will wait for return until the upgrade firmware is sent to the device, this response may take a long time. \n + For CameraLink device, it keeps sending upgrade firmware continuously. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_LocalUpgrade(IN void* handle, const void* strFilePathName); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param pnProcess [OUT] Ƚյַ + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Get Upgrade Progress + * @param handle [IN] Device handle + * @param pnProcess [OUT] Progress receiving address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetUpgradeProcess(IN void* handle, unsigned int* pnProcess); + +/********************************************************************//** + * @~chinese + * @brief ڴ + * @param handle [IN] 豸 + * @param pBuffer [IN][OUT] ΪֵʹãڴֵGEV豸ڴֵǰմģʽ洢ģЭ豸С˴洢 + * @param nAddress [IN] ȡڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] ȡڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸ȡijμĴݡ + + * @~english + * @brief Read Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( Memory value is stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be read, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be read + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, read the data from certain register. +*************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ReadMemory(IN void* handle , void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief дڴ + * @param handle [IN] 豸 + * @param pBuffer [IN] дڴֵעGEV豸ڴֵҪմģʽ洢Э豸С˴洢 + * @param nAddress [IN] дڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] дڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸һдijμĴ + + * @~english + * @brief Write Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN] Memory value to be written ( Note the memory value to be stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be written, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be written + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, write a piece of data into a certain segment of register. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_WriteMemory(IN void* handle, const void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief ע쳣Ϣصڴ豸֮ + * @param handle [IN] 豸 + * @param cbException [IN] 쳣صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿҪMV_CC_OpenDevice豸֮á豸쳣ϿӺڻصȡ쳣ϢGigE豸֮ҪȵMV_CC_CloseDeviceӿڹر豸ٵMV_CC_OpenDeviceӿ´豸 + + * @~english + * @brief Register Exception Message CallBack, call after open device + * @param handle [IN] Device handle + * @param cbException [IN] Exception Message CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterExceptionCallBack(IN void* handle, + void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עȫ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterAllEventCallBack(void* handle, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עᵥ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param strEventName [IN] ¼ + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ\n + ýӿڲ֧CameraLink豸֧"豸"һ¼ + + * @~english + * @brief Register single event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param strEventName [IN] Event name + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device . +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBackEx(void* handle, const char* strEventName, + void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + + +/************************************************************************/ +/* GigEVision 豸еĽӿ */ +/* GigEVision device specific interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ǿIP + * @param handle [IN] 豸 + * @param nIP [IN] õIP + * @param nSubNetMask [IN] + * @param nDefaultGateWay [IN] Ĭ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ǿ豸IP롢Ĭأǿ֮Ҫ´豸GigEVision豸֧֡\n + 豸ΪDHCP״̬øýӿǿ豸֮豸 + + * @~english + * @brief Force IP + * @param handle [IN] Device handle + * @param nIP [IN] IP to set + * @param nSubNetMask [IN] Subnet mask + * @param nDefaultGateWay [IN] Default gateway + * @return Success, return MV_OK. Failure, return error code + * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After forced setting, device handle should be created again. This function is only supported by GigEVision camera.\n + If device is in DHCP status, after calling this API to force setting camera network parameter, the device will restart. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIpEx(IN void* handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay); + +/********************************************************************//** + * @~chinese + * @brief IPʽ + * @param handle [IN] 豸 + * @param nType [IN] IPͣMV_IP_CFG_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸IPʽDHCPLLAȣGigEVision豸֧֡ + + * @~english + * @brief IP configuration method + * @param handle [IN] Device handle + * @param nType [IN] IP type, refer to MV_IP_CFG_x + * @return Success, return MV_OK. Failure, return error code + * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetIpConfig(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ýʹijģʽ,type: MV_NET_TRANS_xʱĬʹdriver + * @param handle [IN] 豸 + * @param nType [IN] 紫ģʽMV_NET_TRANS_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿSDKڲʹõģʽĬʹģʽGigEVision豸֧֡ + + * @~english + * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default + * @param handle [IN] Device handle + * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x + * @return Success, return MV_OK. Failure, return error code + * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by GigEVision camera. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetNetTransMode(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ȡ紫Ϣ + * @param handle [IN] 豸 + * @param pstInfo [OUT] Ϣṹ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԻȡ紫ϢѽݴС֡ȣMV_CC_StartGrabbingɼ֮áGigEVision豸֧֡ + + * @~english + * @brief Get net transmission information + * @param handle [IN] Device handle + * @param pstInfo [OUT] Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Get network transmission information through this API, including received data size, number of lost frames. Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by GigEVision Camera. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetNetTransInfo(IN void* handle, MV_NETTRANS_INFO* pstInfo); + +/********************************************************************//** + * @~chinese + * @brief öĻظ + * @param nMode [IN] ظͣĬϹ㲥0-1-㲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻGigEЧ + + * @~english + * @brief Setting the ACK mode of devices Discovery. + * @param nMode [IN] ACK modeDefault-Broadcast,0-Unicast,1-Broadcast. + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is ONLY effective on GigE cameras. \n + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetDiscoveryMode(unsigned int nMode); + +/********************************************************************//** + * @~chinese + * @brief GVSPȡʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ300msΧ>10ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮ȡǰøýӿڿGVSPȡʱʱ䡣GVSPȡʱù̿ͼ쳣ùȡʱ䳤 + + * @~english + * @brief Set GVSP streaming timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 300ms, range: >10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, and just before start streaming, + * call this interface to set GVSP streaming timeout value. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvspTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVSPȡʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVSPȡʱʱ + + * @~english + * @brief Get GVSP streaming timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVSP streaming timeout. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvspTimeout(IN void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief GVCPʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ500msΧ0-10000ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿGVCPʱʱ䡣 + + * @~english + * @brief Set GVCP cammand timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 500ms, range: 0-10000ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set GVCP command timeout time. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGvcpTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVCPʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPʱʱ䡣 + + * @~english + * @brief Get GVCP cammand timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVCP timeout. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGvcpTimeout(IN void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief شGVCP + * @param handle [IN] 豸 + * @param nRetryGvcpTimes [IN] شΧ0-100 + * @return ɹMV_OK󣬷ش + * @remarks ýӿGVCP쳣ʱشĴһ̶ϿԱ豸ߣΧΪ0-100 + + * @~english + * @brief Set the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param nRetryGvcpTimes [IN] The number of retriesrang0-100 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to increase The Times of retransmission when GVCP packet transmission is abnormal,and to some extent, it can avoid dropping the camera, with a range of 0-100. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetRetryGvcpTimes(IN void* handle, unsigned int nRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشGVCP + * @param handle [IN] 豸 + * @param pnRetryGvcpTimes [OUT] شָ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPشĬ3Ρ + + * @~english + * @brief Get the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param pnRetryGvcpTimes [OUT] The number of retries + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of GVCP retransmissions, which defaults to 3. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetRetryGvcpTimes(IN void* handle, unsigned int* pnRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡѵpacket sizeýӿĿǰֻ֧GigE豸 + * @param handle [IN] 豸 + * @return packetsize + * @remarks ȡѵpacket sizeӦGigEVision豸SCPSӦU3V豸ÿδȡİСôСϴһĴСýӿҪMV_CC_OpenDevice֮MV_CC_StartGrabbing֮ǰá \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get the optimal Packet Size, Only support GigE Camera + * @param handle [IN] Device handle + * @return Optimal packetsize + * @remarks To get optimized packet size, for GigEVision device is SCPS, for USB3Vision device is the size of packet read from drive each time, and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOptimalPacketSize(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief Ƿط֧֣ط + * @param handle [IN] 豸 + * @param bEnable [IN] Ƿ֧ط + * @param nMaxResendPercent [IN] ط + * @param nResendTimeout [IN] طʱʱ + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿطԣGigEVision豸֧֡ + + * @~english + * @brief Set whethe to enable resend, and set resend + * @param handle [IN] Device handle + * @param bEnable [IN] enable resend + * @param nMaxResendPercent [IN] Max resend persent + * @param nResendTimeout [IN] Resend timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera. + ************************************************************************/ +#ifndef __cplusplus +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent, unsigned int nResendTimeout); +#else +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent = 10, unsigned int nResendTimeout = 50); +#endif + +/********************************************************************//** + * @~chinese + * @brief شԴ + * @param handle [IN] 豸 + * @param nRetryTimes [IN] شԴĬ20 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set the max resend retry times + * @param handle [IN] Device handle + * @param nRetryTimes [IN] The max times to retry resending lost packetsdefault 20 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendMaxRetryTimes(void* handle, unsigned int nRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشԴ + * @param handle [IN] 豸 + * @param pnRetryTimes [OUT] شԴ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get the max resend retry times + * @param handle [IN] Device handle + * @param pnRetryTimes [OUT] The max times to retry resending lost packets + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendMaxRetryTimes(void* handle, unsigned int* pnRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ͬһش֮ʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ͬһش֮ʱĬ10ms + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set time interval between same resend requests + * @param handle [IN] Device handle + * @param nMillisec [IN] The time interval between same resend requests,default 10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetResendTimeInterval(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡͬһش֮ʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ͬһش֮ʱ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get time interval between same resend requests + * @param handle [IN] Device handle + * @param pnMillisec [OUT] The time interval between same resend requests + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetResendTimeInterval(void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief ôģʽΪģʽ鲥ģʽ + * @param handle [IN] 豸 + * @param stTransmissionType [IN] ģʽṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿôģʽΪ鲥ģʽGigEVision豸֧֡ + + * @~english + * @brief Set transmission type,Unicast or Multicast + * @param handle [IN] Device handle + * @param stTransmissionType [IN] Struct of transmission type + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is only valid for GigEVision camera. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetTransmissionType(void* handle, MV_TRANSMISSION_TYPE * pstTransmissionType); + +/********************************************************************//** + * @~chinese + * @brief + * @param pstActionCmdInfo [IN] Ϣ + * @param pstActionCmdResults [OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks GigEVision豸֧֡ + + * @~english + * @brief Issue Action Command + * @param pstActionCmdInfo [IN] Action Command + * @param pstActionCmdResults [OUT] Action Command Result List + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by GigEVision camera. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults); + +/********************************************************************//** + * @~chinese + * @brief ȡ鲥״̬ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param pbStatus [OUT] 鲥״̬,true:鲥״̬false:鲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿж豸ǰǷ鲥״̬ͻöʱҪ豸ж鲥⡣ + + * @~english + * @brief Get Multicast Status + * @param pstDevInfo [IN] Device Information Structure + * @param pbStatus [OUT] Status of Multicast + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to determine whether the camera is currently in multicast state, and to solve the problem that the client needs to turn on the camera to determine multicast when enumerating. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetMulticastStatus(IN MV_CC_DEVICE_INFO* pstDevInfo, OUT bool* pbStatus); + + +/************************************************************************/ +/* CameraLink 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBaudrate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBaudrate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBaudrates(IN void* handle,unsigned int* pnBaudrateAblity); + +/********************************************************************//** + * @~chinese + * @brief ôڲȴʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ڲĵȴʱ, λΪms + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Sets the timeout for operations on the serial port + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. + * @return Success, return MV_OK. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void* handle, unsigned int nMillisec); + + +/************************************************************************/ +/* U3V 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief U3VĴС + * @param handle [IN] 豸 + * @param nTransferSize [IN] İС, ByteĬΪ1Mrang>=0x10000 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӴСʵȡʱCPUռʡͬPCͲͬUSBչڲͬļԣòùܻȡͼķա + + * @~english + * @brief Set transfer size of U3V device + * @param handle [IN] Device handle + * @param nTransferSize [IN] Transfer sizeBytedefault1Mrang>=0x10000 + * @return Success, return MV_OK. Failure, return error code + * @remarks Increasing the transmission packet size can reduce the CPU utilization at the time of fetching. However, different PCS and different USB extension CARDS have different compatibility, and if this parameter is set too large, there may be the risk of not getting the image. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetTransferSize(IN void* handle, unsigned int nTransferSize); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴС + * @param handle [IN] 豸 + * @param pnTransferSize [OUT] İСָ, Byte + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3VСĬ1M + + * @~english + * @brief Get transfer size of U3V device + * @param handle [IN] Device handle + * @param pnTransferSize [OUT] Transfer sizeByte + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current U3V transfer packet size, default 1M. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetTransferSize(IN void* handle, unsigned int* pnTransferSize); + +/********************************************************************//** + * @~chinese + * @brief U3VĴͨ + * @param handle [IN] 豸 + * @param nTransferWays [IN] ͨΧ1-10 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ûԸPCܡ豸ͼ֡ʡͼСڴʹʵضԸòеڡͬPCͲͬUSBչڲͬļԡ + + * @~english + * @brief Set transfer ways of U3V device + * @param handle [IN] Device handle + * @param nTransferWays [IN] Transfer waysrang1-10 + * @return Success, return MV_OK. Failure, return error code + * @remarks Users can adjust this parameter according to PC performance, camera image frame rate, image size, memory utilization and other factors. But different PCS and different USB expansion CARDS have different compatibility. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_SetTransferWays(IN void* handle, unsigned int nTransferWays); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴͨ + * @param handle [IN] 豸 + * @param pnTransferWays [OUT] ָͨ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3V첽ȡڵ2000W豸MONO8ĬΪ3YUVΪĬ2RGBΪĬ1Ĭ8ڵ㡣 + + * @~english + * @brief Get transfer ways of U3V device + * @param handle [IN] Device handle + * @param pnTransferWays [OUT] Transfer ways + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of U3V asynchronous feed nodes. For 2000W camera, MONO8 defaults to 3, YUV defaults to 2, RGB defaults to 1, and other cases default to 8 nodes. +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_USB_GetTransferWays(IN void* handle, unsigned int* pnTransferWays); + +/************************************************************************/ +/* GenTLؽӿڣӿڿԸãֽӿڲ֧֣ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͨGenTLöInterfaces + * @param pstIFList [OUT] Interfacesб + * @param strGenTLPath [IN] GenTLctiļ· + * @return ɹMV_OK󣬷ش + * @remarks InterfacesбڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Interfaces with GenTL + * @param pstIFList [OUT] Interfaces List + * @param strGenTLPath [IN] GenTL cti file path + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the Interfaces list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumInterfacesByGenTL(IN OUT MV_GENTL_IF_INFO_LIST* pstIFList, IN const char * strGenTLPath); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL Interfaceö豸 + * @param pstIFInfo [IN] InterfaceϢ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Devices with GenTL interface + * @param pstIFInfo [IN] Interface information + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_EnumDevicesByGenTL(IN MV_GENTL_IF_INFO* pstIFInfo, IN OUT MV_GENTL_DEV_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL豸Ϣ豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹָ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣 + + * @~english + * @brief Create Device Handle with GenTL Device Info + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_CreateHandleByGenTL(OUT void ** handle, IN const MV_GENTL_DEV_INFO* pstDevInfo); + + +/************************************************************************/ +/* XML */ +/* XML parse tree generation */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡ豸XML + * @param handle [IN] 豸 + * @param pData [OUT] XMLݽջ + * @param nDataSize [IN] ջС + * @param pnDataLen [OUT] ʵݴС + * @return ɹMV_OK󣬷ش + * @remarks pDataΪNULLnDataSizeʵʵxmlļСʱݣpnDataLenxmlļС\n + pDataΪЧַһ㹻ʱݱڸû棬pnDataLenxmlļʵʴС + + * @~english + * @brief Get camera feature tree XML + * @param handle [IN] Device handle + * @param pData [OUT] XML data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pnDataLen [OUT] Actual data length + * @return Success, return MV_OK. Failure, return error code + * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, returned by pnDataLen XML file size.\n + When pData is a valid cache address and the cache is large enough, copy the full data into the cache, and pnDataLen returns the actual size of the XML file. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, OUT unsigned int* pnDataLen); + +/********************************************************************//** + * @~chinese + * @brief õǰڵķģʽ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penAccessMode [OUT] ڵķģʽ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Get Access mode of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penAccessMode [OUT] Access mode of the node + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeAccessMode(IN void* handle, IN const char * strName, OUT MV_XML_AccessMode *penAccessMode); + +/********************************************************************//** + * @~chinese + * @brief õǰڵ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penInterfaceType [OUT] ڵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڿڵܽӿ֮ǰǰ֪ڵͣûѡʵܽӿڽнڵֵúͻȡ + + * @~english + * @brief Get Interface Type of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penInterfaceType [OUT] Interface Type of the node + * @return Success, return MV_OK. Failure, return error code + * @remarks The interface can know the node type in advance before calling the universal interface, so as to facilitate users to select the appropriate universal interface for setting and obtaining the node value. + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeInterfaceType(IN void* handle, IN const char * strName, OUT MV_XML_InterfaceType *penInterfaceType); + +/************************************************************************/ +/* ӽӿ */ +/* Additional interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͼƬ֧BmpJpeg. + * @param handle [IN] 豸 + * @param pstSaveParam [IN][OUT] ͼƬṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתJPEGBMPȸʽָڴУȻûԽתֱ֮ӱͼƬļýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ \n + MV_CC_SaveImageEx2MV_CC_SaveImageExӲhandleΪ˱֤ӿڵͳһ + + * @~english + * @brief Save image, support Bmp and Jpeg. + * @param handle [IN] Device handle + * @param pstSaveParam [IN][OUT] Save image parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Once there is image data, you can call this API to convert the data. \n + You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. \n + Comparing with the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx2(IN void* handle, MV_SAVE_IMAGE_PARAM_EX* pstSaveParam); + +/********************************************************************//** + * @~chinese + * @brief ͼļ + * @param handle [IN] 豸 + * @param pstSaveFileParam [IN][OUT] ͼƬļṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧BMP/JPEG/PNG/TIFF + + * @~english + * @brief Save the image file. + * @param handle [IN] Device handle + * @param pstSaveFileParam [IN][OUT] Save the image file parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support BMP/JPEG/PNG/TIFF. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageToFile(IN void* handle, MV_SAVE_IMG_TO_FILE_PARAM* pstSaveFileParam); + +/********************************************************************//** + * @~chinese + * @brief 3Dݣ֧PLYCSVOBJָʽ + * @param handle [IN] 豸 + * @param pstPointDataParam [IN][OUT] ݲṹ + * @return ɹMV_OK󣬷ش + * @remarks 3Dݸʽ3Dļʽ֧PLY/CSV/OBJ/n + Ŀǰ֧PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,ݲ֧3Dʽ + + * @~english + * @brief Save 3D point data, support PLYCSV and OBJ + * @param handle [IN] Device handle + * @param pstPointDataParam [IN][OUT] Save 3D point data parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Save the 3D data format to 3D file formatsupport PLYCSV and OBJ/n + only support PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,Other 3D format is not supported now. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SavePointCloudData(IN void* handle, MV_SAVE_POINT_CLOUD_PARAM* pstPointDataParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstRotateParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵ90/180/270ת + + * @~english + * @brief Rotate Image + * @param handle [IN] Device handle + * @param pstRotateParam [IN][OUT] Rotate image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support 90/180/270 rotation of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RotateImage(IN void* handle, IN OUT MV_CC_ROTATE_IMAGE_PARAM* pstRotateParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstFlipParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵĴֱˮƽת + + * @~english + * @brief Flip Image + * @param handle [IN] Device handle + * @param pstFlipParam [IN][OUT] Flip image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support vertical and horizontal reverse of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FlipImage(IN void* handle, IN OUT MV_CC_FLIP_IMAGE_PARAM* pstFlipParam); + +/********************************************************************//** + * @~chinese + * @brief ظʽת + * @param handle [IN] 豸 + * @param pstCvtParam [IN][OUT] ظʽתṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתûظʽָڴСýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ豸ǰɼͼJPEGѹĸʽֵ֧øýӿڽת \n + + * @~english + * @brief Pixel format conversion + * @param handle [IN] Device handle + * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. There is no order requirement to call this API, the transformation will execute when there is image data. First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, then call this API to transform the format. \n + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_ConvertPixelType(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam); + +/********************************************************************//** + * @~chinese + * @brief òֵ㷨 + * @param handle [IN] 豸 + * @param nBayerCvtQuality [IN] BayerIJֵ 0- 1- 2-ţĬΪţ + * @return ɹMV_OK󣬷ش + * @remarks ڲͼתӿڵıֵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڲʹõIJֵ㷨Ǹýӿ趨ġ + + * @~english + * @brief Interpolation algorithm type setting + * @param handle [IN] Device handle + * @param nBayerCvtQuality [IN] Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + * @return Success, return MV_OK. Failure, return error code + * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, and the interpolation algorithm used in the MV CC ConvertPixelType and MV CC SaveImageEx2 interfaces is set by this interface. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int nBayerCvtQuality); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵGammaֵ + * @param handle [IN] 豸 + * @param fBayerGammaValue [IN] Gammaֵ[0.1,4.0] + * @return ɹMV_OK󣬷ش + * @remarks øֵڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set Gamma value after Bayer interpolation + * @param handle [IN] Device handle + * @param fBayerGammaValue [IN] Gamma value[0.1,4.0] + * @return Success, return MV_OK. Failure, return error code + * @remarks After setting the value, it work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerGammaValue(IN void* handle, IN float fBayerGammaValue); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵɫУʹܺ; + * @param handle [IN] 豸 + * @param pstCCMParam [IN] ɫУṹ + * @return ɹMV_OK󣬷ش + * @remarks ɫУɫУڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set CCM param after Bayer interpolation + * @param handle [IN] Device handle + * @param pstCCMParam [IN] Color correction parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the color correction and set the color correction matrix, It work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBayerCCMParam(IN void* handle, IN MV_CC_CCM_PARAM* pstCCMParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstNoiseEstimateParam [IN][OUT] BayerƲṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Noise estimate of Bayer format + * @param handle [IN] Device handle + * @param pstNoiseEstimateParam [IN][OUT] Noise estimate parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_BayerNoiseEstimate(IN void* handle, IN OUT MV_CC_BAYER_NOISE_ESTIMATE_PARAM* pstNoiseEstimateParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstSpatialDenoiseParam [IN][OUT] Bayerṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Spatial Denoise of Bayer format + * @param handle [IN] Device handle + * @param pstSpatialDenoiseParam [IN][OUT] Spatial Denoise parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_BayerSpatialDenoise(IN void* handle, IN OUT MV_CC_BAYER_SPATIAL_DENOISE_PARAM* pstSpatialDenoiseParam); + +/********************************************************************//** + * @~chinese + * @brief + * @param handle [IN] 豸 + * @param pstDecodeParam [IN][OUT] ṹ + * @return ɹMV_OK󣬷ش + * @remarks ȡѹݣͬʱֽ֧ǰʵʱͼˮӡϢǵǰ߲ʵʱȡģˮӡ쳣 + + * @~english + * @brief High Bandwidth Decode + * @param handle [IN] Device handle + * @param pstDecodeParam [IN][OUT] High Bandwidth Decode parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Decode the lossless compressed data from the camera into raw data + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_HB_Decode(IN void* handle, IN OUT MV_CC_HB_DECODE_PARAM* pstDecodeParam); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Save camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FeatureSave(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Load camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FeatureLoad(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸ȡļ + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Read the file from the camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessRead(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ļд豸 + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Write the file to camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_FileAccessWrite(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ȡļȡĽ + * @param handle [IN] 豸 + * @param pstFileAccessProgress [IN] + * @return ɹMV_OK󣬷ش ǰļȡ״̬ + + * @~english + * @brief Get File Access Progress + * @param handle [IN] Device handle + * @param pstFileAccessProgress [IN] File access Progress + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFileAccessProgress(IN void* handle, OUT MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress); + +/********************************************************************//** + * @~chinese + * @brief ʼ¼ + * @param handle [IN] 豸 + * @param pstRecordParam [IN] ¼ṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Start Record + * @param handle [IN] Device handle + * @param pstRecordParam [IN] Record param structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam); + +/********************************************************************//** + * @~chinese + * @brief ¼ + * @param handle [IN] 豸 + * @param pstInputFrameInfo [IN] ¼ݽṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Input RAW data to Record + * @param handle [IN] Device handle + * @param pstInputFrameInfo [IN] Record data structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo); + +/********************************************************************//** + * @~chinese + * @brief ֹͣ¼ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Stop Record + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_StopRecord(IN void* handle); +#ifdef __cplusplus +} +#endif + +#endif //_MV_CAMERA_CTRL_H_ diff --git a/CigaretteSingle/MVS3.2.1/Include/MvErrorDefine.h b/CigaretteSingle/MVS3.2.1/Include/MvErrorDefine.h new file mode 100644 index 0000000..6ad3d6b --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/MvErrorDefine.h @@ -0,0 +1,105 @@ + +#ifndef _MV_ERROR_DEFINE_H_ +#define _MV_ERROR_DEFINE_H_ + +/********************************************************************/ +/// \~chinese +/// \name ȷ붨 +/// @{ +/// \~english +/// \name Definition of correct code +/// @{ +#define MV_OK 0x00000000 ///< \~chinese ɹ޴ \~english Successed, no error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name ͨô붨:Χ0x80000000-0x800000FF +/// @{ +/// \~english +/// \name Definition of General error code +/// @{ +#define MV_E_HANDLE 0x80000000 ///< \~chinese Чľ \~english Error or invalid handle +#define MV_E_SUPPORT 0x80000001 ///< \~chinese ֵ֧Ĺ \~english Not supported function +#define MV_E_BUFOVER 0x80000002 ///< \~chinese \~english Buffer overflow +#define MV_E_CALLORDER 0x80000003 ///< \~chinese ˳ \~english Function calling order error +#define MV_E_PARAMETER 0x80000004 ///< \~chinese IJ \~english Incorrect parameter +#define MV_E_RESOURCE 0x80000006 ///< \~chinese Դʧ \~english Applying resource failed +#define MV_E_NODATA 0x80000007 ///< \~chinese \~english No data +#define MV_E_PRECONDITION 0x80000008 ///< \~chinese ǰ󣬻лѷ仯 \~english Precondition error, or running environment changed +#define MV_E_VERSION 0x80000009 ///< \~chinese 汾ƥ \~english Version mismatches +#define MV_E_NOENOUGH_BUF 0x8000000A ///< \~chinese ڴռ䲻 \~english Insufficient memory +#define MV_E_ABNORMAL_IMAGE 0x8000000B ///< \~chinese 쳣ͼ񣬿Ƕͼ \~english Abnormal image, maybe incomplete image because of lost packet +#define MV_E_LOAD_LIBRARY 0x8000000C ///< \~chinese ̬DLLʧ \~english Load library failed +#define MV_E_NOOUTBUF 0x8000000D ///< \~chinese ûпĻ \~english No Avaliable Buffer +#define MV_E_ENCRYPT 0x8000000E ///< \~chinese ܴ \~english Encryption error +#define MV_E_UNKNOW 0x800000FF ///< \~chinese δ֪Ĵ \~english Unknown error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name GenICamϵд:Χ0x80000100-0x800001FF +/// @{ +/// \~english +/// \name GenICam Series Error Codes: Range from 0x80000100 to 0x800001FF +/// @{ +#define MV_E_GC_GENERIC 0x80000100 ///< \~chinese ͨô \~english General error +#define MV_E_GC_ARGUMENT 0x80000101 ///< \~chinese Ƿ \~english Illegal parameters +#define MV_E_GC_RANGE 0x80000102 ///< \~chinese ֵΧ \~english The value is out of range +#define MV_E_GC_PROPERTY 0x80000103 ///< \~chinese \~english Property +#define MV_E_GC_RUNTIME 0x80000104 ///< \~chinese л \~english Running environment error +#define MV_E_GC_LOGICAL 0x80000105 ///< \~chinese ߼ \~english Logical error +#define MV_E_GC_ACCESS 0x80000106 ///< \~chinese ڵ \~english Node accessing condition error +#define MV_E_GC_TIMEOUT 0x80000107 ///< \~chinese ʱ \~english Timeout +#define MV_E_GC_DYNAMICCAST 0x80000108 ///< \~chinese ת쳣 \~english Transformation exception +#define MV_E_GC_UNKNOW 0x800001FF ///< \~chinese GenICamδ֪ \~english GenICam unknown error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name GigE_STATUSӦĴ:Χ0x80000200-0x800002FF +/// @{ +/// \~english +/// \name GigE_STATUS Error Codes: Range from 0x80000200 to 0x800002FF +/// @{ +#define MV_E_NOT_IMPLEMENTED 0x80000200 ///< \~chinese 豸֧ \~english The command is not supported by device +#define MV_E_INVALID_ADDRESS 0x80000201 ///< \~chinese ʵĿַ \~english The target address being accessed does not exist +#define MV_E_WRITE_PROTECT 0x80000202 ///< \~chinese Ŀַд \~english The target address is not writable +#define MV_E_ACCESS_DENIED 0x80000203 ///< \~chinese 豸޷Ȩ \~english No permission +#define MV_E_BUSY 0x80000204 ///< \~chinese 豸æϿ \~english Device is busy, or network disconnected +#define MV_E_PACKET 0x80000205 ///< \~chinese ݴ \~english Network data packet error +#define MV_E_NETER 0x80000206 ///< \~chinese ش \~english Network error +#define MV_E_IP_CONFLICT 0x80000221 ///< \~chinese 豸IPͻ \~english Device IP conflict +/// @} + +/********************************************************************/ +/// \~chinese +/// \name USB_STATUSӦĴ:Χ0x80000300-0x800003FF +/// @{ +/// \~english +/// \name USB_STATUS Error Codes: Range from 0x80000300 to 0x800003FF +/// @{ +#define MV_E_USB_READ 0x80000300 ///< \~chinese usb \~english Reading USB error +#define MV_E_USB_WRITE 0x80000301 ///< \~chinese дusb \~english Writing USB error +#define MV_E_USB_DEVICE 0x80000302 ///< \~chinese 豸쳣 \~english Device exception +#define MV_E_USB_GENICAM 0x80000303 ///< \~chinese GenICamش \~english GenICam error +#define MV_E_USB_BANDWIDTH 0x80000304 ///< \~chinese ô \~english Insufficient bandwidth, this error code is newly added +#define MV_E_USB_DRIVER 0x80000305 ///< \~chinese ƥδװ \~english Driver mismatch or unmounted drive +#define MV_E_USB_UNKNOW 0x800003FF ///< \~chinese USBδ֪Ĵ \~english USB unknown error +/// @} + +/********************************************************************/ +/// \~chinese +/// \name ʱӦĴ:Χ0x80000400-0x800004FF +/// @{ +/// \~english +/// \name Upgrade Error Codes: Range from 0x80000400 to 0x800004FF +/// @{ +#define MV_E_UPG_FILE_MISMATCH 0x80000400 ///< \~chinese ̼ƥ \~english Firmware mismatches +#define MV_E_UPG_LANGUSGE_MISMATCH 0x80000401 ///< \~chinese ̼Բƥ \~english Firmware language mismatches +#define MV_E_UPG_CONFLICT 0x80000402 ///< \~chinese ͻ豸Ѿٴش˴ \~english Upgrading conflicted (repeated upgrading requests during device upgrade) +#define MV_E_UPG_INNER_ERR 0x80000403 ///< \~chinese ʱ豸ڲִ \~english Camera internal error during upgrade +#define MV_E_UPG_UNKNOW 0x800004FF ///< \~chinese ʱδ֪ \~english Unknown error during upgrade +/// @} + +#endif //_MV_ERROR_DEFINE_H_ diff --git a/CigaretteSingle/MVS3.2.1/Include/MvObsoleteInterfaces.h b/CigaretteSingle/MVS3.2.1/Include/MvObsoleteInterfaces.h new file mode 100644 index 0000000..c039dc3 --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/MvObsoleteInterfaces.h @@ -0,0 +1,1687 @@ + +#ifndef _MV_OBSOLETE_INTERFACES_H_ +#define _MV_OBSOLETE_INTERFACES_H_ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "ObsoleteCamParams.h" + +/** +* @brief ̬⵼뵼 +* @brief Import and export definition of the dynamic library +*/ +#ifndef MV_CAMCTRL_API + + #if (defined (_WIN32) || defined(WIN64)) + #if defined(MV_CAMCTRL_EXPORTS) + #define MV_CAMCTRL_API __declspec(dllexport) + #else + #define MV_CAMCTRL_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MV_CAMCTRL_API + #define MV_CAMCTRL_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* ʹõĽӿ */ +/* Interfaces not recommended */ +/************************************************************************/ +/************************************************************************ + * @fn MV_CC_GetImageInfo + * @brief ȡͼϢ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظйͼϢṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CC_GetImageInfo + * @brief Get basic information of image + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of image basic information + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetImageInfo(IN void* handle, IN OUT MV_IMAGE_BASIC_INFO* pstInfo); + +/************************************************************************ + * @fn MV_CC_GetTlProxy + * @brief ȡGenICam + * @param handle [IN] ַ + * @return GenICamָ ֵNULL쳣NULL + + * @fn MV_CC_GetTlProxy + * @brief Get GenICam proxy + * @param handle [IN] Handle address + * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL + ************************************************************************/ +MV_CAMCTRL_API void* __stdcall MV_CC_GetTlProxy(IN void* handle); + +/*********************************************************************** + * @fn MV_XML_GetRootNode + * @brief ȡڵ + * @param handle [IN] + * @param pstNode [OUT] ڵϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetRootNode + * @brief Get root node + * @param handle [IN] Handle + * @param pstNode [OUT] Root node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetRootNode(IN void* handle, IN OUT MV_XML_NODE_FEATURE* pstNode); + +/*********************************************************************** + * @fn MV_XML_GetChildren + * @brief xmlлȡָڵӽڵ㣬ڵΪRoot + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstNodesList [OUT] ڵбṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetChildren + * @brief Get all children node of specific node from xml, root node is Root + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstNodesList [OUT] Node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetChildren(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT MV_XML_NODES_LIST* pstNodesList); + +/*********************************************************************** + * @fn MV_XML_GetNodeFeature + * @brief õǰڵ + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstFeature [OUT] ǰڵԽṹ壬 + pstFeature ṹݲο MV_XML_FEATURE_x + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetNodeFeature + * @brief Get current node feature + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstFeature [OUT] Current node feature structure + Details of pstFeature refer to MV_XML_FEATURE_x + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_GetNodeFeature(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT void* pstFeature); + +/*********************************************************************** + * @fn MV_XML_UpdateNodeFeature + * @brief ½ڵ + * @param handle [IN] + * @param enType [IN] ڵ + * @param pstFeature [OUT] ǰڵԽṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_UpdateNodeFeature + * @brief Update node + * @param handle [IN] Handle + * @param enType [IN] Node type + * @param pstFeature [OUT] Current node feature structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_UpdateNodeFeature(IN void* handle, IN enum MV_XML_InterfaceType enType, IN void* pstFeature); + +// нڵҪʱĻص +// MV_XML_UpdateNodeFeatureӿڸ½ڵʱעĻصcbUpdatepstNodesListз֮Ľڵ +/*********************************************************************** + * @fn MV_XML_RegisterUpdateCallBack + * @brief ע»ص + * @param handle [IN] + * @param cbUpdate [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_RegisterUpdateCallBack + * @brief Register update callback + * @param handle [IN] Handle + * @param cbUpdate [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_XML_RegisterUpdateCallBack(IN void* handle, + IN void(__stdcall* cbUpdate)(enum MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser), + IN void* pUser); + +/************************************************************************/ +/* õĽӿڣڸŻĽӿڿ滻 */ +/* Abandoned interface */ +/************************************************************************/ +/*********************************************************************** + * @fn MV_CC_GetOneFrame + * @brief ȡһ֡ͼ񣬴˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrame + * @brief Get one frame data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrame(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_GetOneFrameEx + * @brief ȡһ֡trunckݣ˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrameEx + * @brief Get one frame of trunck data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetOneFrameEx(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_RegisterImageCallBack + * @brief עͼݻصýӿã MV_CC_RegisterImageCallBackExӿڣ + * @param handle [IN] + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_RegisterImageCallBack + * @brief Register image data callback (This interface is abandoned, it is recommended to use the MV_CC_RegisterImageCallBackEx) + * @param handle [IN] Handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterImageCallBack(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser), + void* pUser); + +/************************************************************************ + * @fn MV_CC_SaveImage + * @brief ͼƬýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImage + * @brief Save image (This interface is abandoned, it is recommended to use the MV_CC_SaveImageEx) + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Input data pixel format + nWidth; // [IN] Width + nHeight; // [IN] Height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Provided output buffer size + enImageType; // [IN] Output image type + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM* pSaveParam); + +/************************************************************************ + * @fn MV_CC_SaveImageEx + * @brief ͼƬ֧BmpJpeg.50-99֮ǰ ýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + nJpgQuality; // [IN] , (50-99] + nReserved[4]; + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImageEx + * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Pixel format of input data + nWidth; // [IN] Image width + nHeight; // [IN] Image height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Output buffer size provided + enImageType; // [IN] Output image format + nJpgQuality; // [IN] Encoding quality, (50-99] + nReserved[4]; + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX* pSaveParam); + +/************************************************************************ + * @fn MV_GIGE_ForceIp + * @brief ǿIPýӿã MV_GIGE_ForceIpExӿڣ + * @param handle豸 + * @param nIP [IN] õIP + * @return ش + + * @fn MV_GIGE_ForceIp + * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) + * @param handle Handle + * @param nIP [IN] IP to set + * @return Refer to error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_ForceIp(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CC_RegisterEventCallBack + * @brief ע¼صýӿã MV_CC_RegisterEventCallBackExӿڣ + * @param handle豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ش + + * @fn MV_CC_RegisterEventCallBack + * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the MV_CC_RegisterEventCallBackEx interface) + * @param handle豸 + * @param cbEvent [IN] event callback pointer + * @param pUser [IN] User defined value + * @return ش +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_RegisterEventCallBack(void* handle, void(__stdcall* cbEvent)(unsigned int nExternalEventId, void* pUser), void* pUser); + +/*********************************************************************** + * @fn MV_CC_Display + * @brief ʾͼעʾڣڲԶʾMV_CC_GetImageBufferͬʱʹãMV_CC_DisplayOneFrameӿڣ + * @param handle [IN] + * @param hWnd [IN] ʾھ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_Display + * @brief Display one frame image, register display window, automatic display internally + * @param handle [IN] Handle + * @param hWnd [IN] Display Window Handle + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_Display(IN void* handle, void* hWnd); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief ȡIntegerֵMV_CC_GetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйԽṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief Get Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to get width + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetIntValue(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE *pIntValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief IntegerֵMV_CC_SetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief Set Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to set width + * const unsigned int nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetIntValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + + +/************************************************************************/ +/* ȡãģнӿѷʹܽӿڴ */ +/* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ +/************************************************************************/ +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȵϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰĿֵ + * unsigned int nMax; // ʾõĿֵ + * unsigned int nMin; // ʾСõĿֵ + * unsigned int nInc; // ʾõĿnIncıЧ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image width + * @param void* handle [IN] Camera Handle + * MVCC_INTVALUE* pstValue [IN][OUT] Returns the information structure pointer about the camera's width for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // Represents the current width value of the camera + * unsigned int nMax; // Indicates the maximum settable width value allowed by the camera + * unsigned int nMin; // Indicates the minimum settable width value allowed by the camera + * unsigned int nInc; // Indicates that the width increment set by the camera must be a multiple of nInc, otherwise it is invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other Integer structure parameters interface can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); +* @brief ͼ +* @param void* handle [IN] +* const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ +* @return ɹ,MV_OK,ȽΪӦֵʧ,ش + +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + * @brief Set image width + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] To set the value of the camera width, note that the width value must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface + * @return Success, return MV_OK, and the camera width will change to the corresponding value. Failure, return error code +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ߶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظй߶ȵϢṹָ + * @return ɹ,MV_OK,߶ϢصṹУʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image height + * @param void* handle [IN] Camera handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera height to user + * @return Success, return MV_OK, and return height information to the structure. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief ͼ߶ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ + * @return ɹ,MV_OK,߶ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief Set image height + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera height value to set, note that this value must be times of nInc of pstValue returned by MV_CC_GetWidth + * @return Success, return MV_OK, and the camera height will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼXƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйXƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image X offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera X offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief Set image X offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera X offset value to set + * @return Success, return MV_OK, and the camera X offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼYƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйYƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image Y offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera Y offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + * @brief Set image Y offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera Y offset value to set + * @return Success, return MV_OK, and the camera Y offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure lower limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure lower to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure lower limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure lower to set + * @return Success, return MV_OK, and the camera exposure time lower limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure upper limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure upper to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure upper limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure upper to set + * @return Success, return MV_OK, and the camera exposure time upper limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡֵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get brightness + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera brightness to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief ֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief Set brightness + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Brightness upper to set + * @return Success, return MV_OK, and the camera brightness value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ֡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظй֡ʵϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Frame Rate + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera frame rate to user + * The meaning of returns pstValue structure + * float fCurValue; // Indicates the current frame rate of the camera + * float fMax; // Indicates the maximum frame rate allowed by the camera + * float fMin; // Indicates the minimum frame rate allowed by the camera + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief Set frame rate + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Camera frame rate to set + * @return Success, return MV_OK, and camera frame rate will be changed to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gain + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to gain to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current gain + * float fMax; // The maximum gain camera allowed + * float fMin; // The minimum gain camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief Set Gain + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Gain value to set + * @return Success, return MV_OK, and the camera gain value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡعʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйعʱϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get exposure time + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to exposure time to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current exposure time + * float fMax; // The maximum exposure time camera allowed + * float fMin; // The minimum exposure time camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief عʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief Set exposure time + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Exposure time to set + * @return Success, return MV_OK, and the camera exposure time value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡظʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйظʽϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰظʽö,˵PixelType_Gvsp_Mono8, õֵ,ֵPixelType.hMvGvspPixelTypeö + * unsigned int nSupportedNum; // ֵ֧ظʽĸ + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // ֵ֧ظʽӦֵбҪظʽʱеһ֣Ч + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + öͲӿڿɲմ˽ӿڣйӦöͶӦֵPixelType.h CameraParams.hӦĶ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Pixel Format + * @param void* handle [IN] Camera Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Returns the information structure pointer about pixel format for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // The current pixel format of the camera, is the enumeration type, such as PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to MvGvspPixelType enumeration type in PixelType.h + * unsigned int nSupportedNum; // Number of pixel formats supported by the camera + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this list, otherwise invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Other interface of Enumeration structure parameters can refer to this interface, look for the corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõظʽӦֵô˽ӿʱֱдöֵMV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return ɹ,MV_OK,ظʽΪӦֵʧ,ش + * + * ҪõöͱGetӿڷصnSupportValue[MV_MAX_XML_SYMBOLIC_NUM]еһ֣ʧ + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief Set Pixel Format + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] The corresponding integer value for pixel format to be set, when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return Success, return MV_OK, and the camera pixel format will change to the corresponding value. Failure, return error code + * + * Other interface of Enumeration structure parameters can refer to this interface, the enumeration type to be set must be one of the nSupportValue [MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it will fail + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡɼģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйزɼģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_ACQUISITION_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get acquisition mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of acquisition mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_ACQUISITION_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõIJɼģʽӦֵ + * @return ɹ,MV_OK,ɼģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief Set acquisition mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to acquisition mode + * @return Success, return MV_OK, and the camera acquisition mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAIN_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get gain mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gain mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAIN_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief ģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief Set gain mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gain mode + * @return Success, return MV_OK, and the camera gain mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶعģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶعģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_EXPOSURE_AUTO_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get auto exposure mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto exposure mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_EXPOSURE_AUTO_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Զعģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶعģʽӦֵ + * @return ɹ,MV_OK,ԶعģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Set auto exposure mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto exposure mode + * @return Success, return MV_OK, and the camera auto exposure mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_MODE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_MODE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief ôģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger mode + * @return Success, return MV_OK, and the camera trigger mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйʱϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get tigger delay + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of trigger delay + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief ôʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõʱ + * @return ɹ,MV_OK,ʱΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief Set tigger delay + * @param void* handle [IN] Handle + * const float fValue [IN] Trigger delay to set + * @return Success, return MV_OK, and the camera trigger delay will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԴ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشԴϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_SOURCE + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger source + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger source + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief ôԴ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴԴӦֵ + * @return ɹ,MV_OK,ԴΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger source + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger source + * @return Success, return MV_OK, and the camera trigger source will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief һΣӿڽѡĴԴΪʱЧ + * @param void* handle [IN] + * @return ɹ,MV_OK, ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) + * @param void* handle [IN] Handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡGamma + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйGamma͵Ϣṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAMMA_SELECTOR + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Gamma mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gamma mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Gamma + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõGammaͶӦֵ + * @return ɹ,MV_OK,GammaͽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Set Gamma mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gamma mode + * @return Success, return MV_OK, and the camera gamma mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡGammaֵ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйGammaֵϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gamma value + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of gamma value + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Gammaֵ + * @param void* handle [IN] + * const float fValue [IN] ҪõGammaֵ + * @return ɹ,MV_OK,GammaֵΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Set Gamma value + * @param void* handle [IN] Handle + * const float fValue [IN] Gamma value to set + * @return Success, return MV_OK, and the camera gamma value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get sharpness + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of sharpness + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief Set sharpness + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Sharpness to set + * @return Success, return MV_OK, and the camera sharpness will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡҶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйҶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Hue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Hue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief ûҶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĻҶ + * @return ɹ,MV_OK,ҶȽΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief Set Hue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Hue to set + * @return Success, return MV_OK, and the camera Hue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Saturation + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Saturation + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief ñͶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõıͶ + * @return ɹ,MV_OK,ͶȽΪӦֵʧ,ش + +* @fn MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief Set Saturation + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Saturation to set + * @return Success, return MV_OK, and the camera Saturation will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶƽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶƽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_BALANCEWHITE_AUTO + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Auto white balance + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto white balance + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParam.h + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Զƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶƽӦֵ + * @return ɹ,MV_OK,Զƽ⽫ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Set Auto white balance + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto white balance + * @return Success, return MV_OK, and the camera auto white balance will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance red + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance red + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ 콫ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance red + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance red to set + * @return Success, return MV_OK, and the camera white balance red will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ̽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance green + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance green + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ̽ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance green + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance green to set + * @return Success, return MV_OK, and the camera white balance green will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance blue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance blue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance blue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance blue to set + * @return Success, return MV_OK, and the camera white balance blue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡˮӡϢڰϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйˮӡϢڰϢͽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get information type included by frame stamp + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of information type included by frame stamp + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief ˮӡϢڰϢ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõˮӡϢڰϢ + * @return ɹ,MV_OK,ˮӡϢڰϢͻΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief Set information type included by frame stamp + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Information type included by frame stamp to set + * @return Success, return MV_OK, and the camera information type included by frame stamp will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief ȡ豸Զ + * @param void* handle [IN] + * MVCC_STRINGVALUE* pstValue [IN OUT] ظйֽṹָ + * @return ɹ,MV_OK,һȡԶ֣ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief Get device user defined name + * @param void* handle [IN] Handle + * MVCC_STRINGVALUE* pstValue [IN OUT] Structure pointer of device name + * @return Success, return MV_OK, and get the camera user defined name. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief 豸Զ + * @param void* handle [IN] + * IN const char* chValue [IN] 豸 + * @return ɹ,MV_OK,豸Զ֣ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief Set device user defined name + * @param void* handle [IN] Handle + * IN const char* chValue [IN] Device name + * @return Success, return MV_OK, and set the camera user defined name. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡһδ֡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйһδ֡ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get frame number trigger by once + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of frame number trigger by once + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief һδ֡ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõһδ֡ + * @return ɹ,MV_OK,һδ֡ΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief Set frame number trigger by once + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Frame number trigger by once to set + * @return Success, return MV_OK, and the camera frame number trigger by once will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƵṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get line rate + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of line rate + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Ƶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõƵ + * @return ɹ,MV_OK,ƵΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Set line rate + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Line rate to set + * @return Success, return MV_OK, and the camera line rate will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get heartbeat information + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of heartbeat information + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Ϣ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõϢ + * @return ɹ,MV_OK,ϢΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Set heartbeat information + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Heartbeat information to set + * @return Success, return MV_OK, and the camera heartbeat information will change to the corresponding value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡС + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйСṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet size + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet size + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief С + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõС + * @return ɹ,MV_OK,СΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet size + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet size to set + * @return Success, return MV_OK, and change packet size to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͼṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet sending delay + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet sending delay + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief ͼ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõͼ + * @return ɹ,MV_OK,ͼΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet sending delay + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet delay to set + * @return Success, return MV_OK, and change packet delay to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief ȡնIPַ0xa9fe0102 ʾ 169.254.1.2 + * @param void* handle [IN] + * @param unsigned int* pnIP [IN][OUT] ظ߽նIPַ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 + * @param void* handle [IN] Handle + * @param unsigned int* pnIP [IN][OUT] Receiver IP address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief ýնIPַ + * @param void* handle [IN] + * unsigned int nIP [IN] ҪõĽնIPַ + * @return ɹ,MV_OK,նIPַΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief Set receiver IP address + * @param void* handle [IN] Handel + * unsigned int nIP [IN] Receiver IP address to set + * @return Success, return MV_OK, and change receiver IP address to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief ȡͶ˵Ķ˿ں + * @param void* handle [IN] + * @param unsigned int* pnPort [IN][OUT] ظ߷Ͷ˵Ķ˿ں + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief Get transmitter port number + * @param void* handle [IN] Handle + * @param unsigned int* pnPort [IN][OUT] Transmitter port number + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + +/************************************************************************ + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief ÷Ͷ˵Ķ˿ں + * @param void* handle [IN] + * unsigned int nPort [IN] ҪõķͶ˵Ķ˿ں + * @return ɹ,MV_OK,Ͷ˵Ķ˿ںŻΪӦֵʧ,ش + + * @fn MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief Set transmitter port number + * @param void* handle [IN] Handle + * unsigned int nPort [IN] Transmitter port number to set + * @return Success, return MV_OK, and change transmitter port number to setting value. Failure, return error code + ************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_SetDeviceBaudrateӿڣ + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_SetDeviceBaudrate) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetDeviceBaudrateӿڣ + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetDeviceBaudrate) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetDeviceBauderate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetSupportBaudratesӿڣ + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetSupportBaudrates) +************************************************************************/ +MV_CAMCTRL_API int __stdcall MV_CAML_GetSupportBauderates(IN void* handle,unsigned int* pnBaudrateAblity); + +#ifdef __cplusplus +} +#endif + +#endif //_MV_OBSOLETE_INTERFACES_H_ diff --git a/CigaretteSingle/MVS3.2.1/Include/MvSdkExport.h b/CigaretteSingle/MVS3.2.1/Include/MvSdkExport.h new file mode 100644 index 0000000..2bfc02d --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/MvSdkExport.h @@ -0,0 +1,3630 @@ +#ifndef _MV_SDK_EXPORT_H__ +#define _MV_SDK_EXPORT_H__ + +#include "MvErrorDefine.h" +#include "CameraParams.h" +#include "ObsoleteCamParams.h" + +#ifndef MVSDKEXPORT_API + + #ifdef _WIN32 + #if defined(MVSDKEXPORT_EXPORTS) + #define MVSDKEXPORT_API __declspec(dllexport) + #else + #define MVSDKEXPORT_API __declspec(dllimport) + #endif + #else + #ifndef __stdcall + #define __stdcall + #endif + + #ifndef MVSDKEXPORT_API + #define MVSDKEXPORT_API + #endif + #endif + +#endif + +#ifndef IN + #define IN +#endif + +#ifndef OUT + #define OUT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************/ +/* 豸ĻָͲ */ +/* Camera basic instructions and operations */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡSDK汾 + * @return 4ֽڰ汾 + | | | | | + 8bits 8bits 8bits 8bits + * @remarks 緵ֵΪ0x01000001SDK汾ΪV1.0.0.1 + + * @~english + * @brief Get SDK Version + * @return Always return 4 Bytes of version number + |Main |Sub |Rev | Test| + 8bits 8bits 8bits 8bits + * @remarks For example, if the return value is 0x01000001, the SDK version is V1.0.0.1. + ************************************************************************/ +MVSDKEXPORT_API unsigned int __stdcall MV_CC_GetSDKVersion(); + +/********************************************************************//** + * @~chinese + * @brief ȡֵ֧Ĵ + * @return ֵ֧Ĵ + + * @~english + * @brief Get supported Transport Layer + * @return Supported Transport Layer number + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumerateTls(); + +/********************************************************************//** + * @~chinese + * @brief ö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Device + * @param nTLayerType [IN] Enumerate TLs + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumDevices(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ݳö豸 + * @param nTLayerType [IN] öٴ + * @param pstDevList [OUT] 豸б + * @param strManufacturerName [IN] + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate device according to manufacture name + * @param nTLayerType [IN] Transmission layer of enumeration + * @param pstDevList [OUT] Device list + * @param strManufacturerName [IN] Manufacture Name + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the device list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumDevicesEx(IN unsigned int nTLayerType, IN OUT MV_CC_DEVICE_INFO_LIST* pstDevList, IN const char* strManufacturerName); + +/********************************************************************//** + * @~chinese + * @brief 豸Ƿɴ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param nAccessMode [IN] Ȩ + * @return ɴtrueɴfalse + * @remarks ȡ豸CCPĴֵжϵǰ״̬ǷijַȨޡ \n + 豸֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableWithKeyģʽӿڷfalseĿǰ豸֧3ռģʽij̵豸Ҳݲ֧3ģʽ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Is the device accessible + * @param pstDevInfo [IN] Device Information Structure + * @param nAccessMode [IN] Access Right + * @return Access, return true. Not access, return false + * @remarks Read device CCP register value and determine current access permission.\n + Return false if the device does not support the modes MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MVSDKEXPORT_API bool __stdcall MV_CC_IsDeviceAccessible(IN MV_CC_DEVICE_INFO* pstDevInfo, IN unsigned int nAccessMode); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandleWithoutLog + + * @~english + * @brief Create Device Handle + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will be created by default. Creating handle through MV_CC_CreateHandleWithoutLog will not generate log files. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CreateHandle(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸־ + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣ͨýӿڴSDKӿڣĬSDK־ļҪ־ļͨMV_CC_CreateHandle־ļԶɡ + + * @~english + * @brief Create Device Handle without log + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CreateHandleWithoutLog(OUT void ** handle, IN const MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Destroy Device Handle + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_DestroyHandle(IN void * handle); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nAccessMode [IN] Ȩ + * @param nSwitchoverKey [IN] лȨʱԿ + * @return ɹMV_OK󣬷ش + * @remarks õ豸ҵӦ豸豸\n + ýӿʱɲnAccessModenSwitchoverKeyʱĬ豸ģʽΪռȨޡĿǰ豸ݲ֧MV_ACCESS_ExclusiveWithSwitchMV_ACCESS_ControlWithSwitchMV_ACCESS_ControlSwitchEnableMV_ACCESS_ControlSwitchEnableWithKeyռģʽ\n + U3V豸nAccessModenSwitchoverKeyЧ + + * @~english + * @brief Open Device + * @param handle [IN] Device handle + * @param nAccessMode [IN] Access Right + * @param nSwitchoverKey [IN] Switch key of access right + * @return Success, return MV_OK. Failure, return error code + * @remarks Find specific device and connect according to set device parameters. \n + When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access mode is exclusive. Currently the device does not support the following preemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.\n + For USB3Vision device, nAccessMode, nSwitchoverKey are invalid. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_OpenDevice(IN void* handle, IN unsigned int nAccessMode, IN unsigned short nSwitchoverKey); + +/********************************************************************//** + * @~chinese + * @brief ر豸 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ͨMV_CC_OpenDevice豸󣬿ͨýӿڶϿ豸ӣͷԴ + + * @~english + * @brief Close Device + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CloseDevice(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ж豸Ƿ״̬ + * @param handle [IN] 豸 + * @return 豸״̬trueûӻʧȥӣfalse + + * @~english + * @brief Is The Device Connected + * @param handle [IN] Device handle + * @return Connected, return true. Not Connected or DIsconnected, return false + ***********************************************************************/ +MVSDKEXPORT_API bool __stdcall MV_CC_IsDeviceConnected(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief עͼݻص + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackExͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetOneFrameTimeoutȡָظʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register the image callback function + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks After MV_CC_CreateHandle, call this interface to set image data callback function.\n + There are two available image data acquisition modes, and cannot be used together: \n + Mode 1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrameTimeout repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBackEx(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصRGB + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá \n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForRGBRGB24ʽͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForRGBȡRGB24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, RGB + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForRGB to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForRGB repeatedly in application layer to get frame data with RGB24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBackForRGB(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עͼݻصBGR + * @param handle [IN] 豸 + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿͼݻصMV_CC_CreateHandle֮󼴿ɵá\n + ͼݲɼַʽַʽܸã\n + ʽһMV_CC_RegisterImageCallBackForBGRBGR24ͼݻصȻMV_CC_StartGrabbingʼɼɼͼõĻصзء\n + ʽMV_CC_StartGrabbingʼɼȻӦòѭMV_CC_GetImageForBGRȡBGR24ʽ֡ݣȡ֡ʱϲӦóҪ֡ʿƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief register image data callback, BGR + * @param handle [IN] Device handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.\n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBackForBGR(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser), + void* pUser); + +/********************************************************************//** + * @~chinese + * @brief ʼȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Start Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StartGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ֹͣȡ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڲ֧CameraLink豸 + + * @~english + * @brief Stop Grabbing + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StopGrabbing(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡RGBݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתRGB24ʽأû򷵻ش롣ΪͼתRGB24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡\n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of RGB data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Each time the API is called, the internal cache is checked for data. If there is data, it will be transformed as RGB24 format for return, if there is no data, return error code. As time-consuming exists when transform the image to RGB24 format, this API may cause frame loss when the data frame rate is too high. \n + Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageForRGB(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡһ֡BGRݣ˺Ϊѯʽȡÿεòѯڲ + ݣȡݣݷش + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks ÿεøýӿڣѯڲǷݣתBGR24ʽأû򷵻ش롣ΪͼתBGR24ʽкʱԵ֡ʹʱýӿڿܻᵼ¶֡ \n + øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡ\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get one frame of BGR data, this function is using query to get data + query whether the internal cache has data, get data if there has, return error code if no data + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to set image data callback function, you should call this API MV_CC_CreateHandle. \n + There are two image acquisition modes, the two modes cannot be reused: \n + Mode 1: Call MV_CC_RegisterImageCallBackForBGR to set RGB24 format image data callback function, and then call MV_CC_StartGrabbing to start acquisition, the collected image data will be returned in the configured callback function.\n + Mode 2: Call MV_CC_StartGrabbing to start acquisition, and the call MV_CC_GetImageForBGR repeatedly in application layer to get frame data with BGR24 format. When getting frame data, the upper application program should control the frequency of calling this API according to frame rate. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageForBGR(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ʹڲȡһ֡ͼƬMV_CC_Displayͬʱʹã + * @param handle [IN] 豸 + * @param pstFrame [OUT] ͼݺͼϢ + * @param nMsec [IN] ȴʱʱ䣬INFINITEʱʾ޵ȴֱյһ֡ݻֹͣȡ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ \n + ýӿMV_CC_FreeImageBufferʹãȡݺҪMV_CC_FreeImageBufferӿڽpFrameڵָȨ޽ͷš \n + ýӿMV_CC_GetOneFrameTimeoutȣŸߵЧʡȡķsdkڲԶģMV_CC_GetOneFrameTimeoutӿҪͻз䡣\n + ýӿڵMV_CC_Display޷ȡ \n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get a frame of an image using an internal cache + * @param handle [IN] Device handle + * @param pstFrame [OUT] Image data and image information + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, you should call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API support setting timeout, and SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + This API and MV_CC_FreeImageBuffer should be called in pairs, after processing the acquired data, you should call MV_CC_FreeImageBuffer to release the data pointer permission of pFrame. \n + This interface is more efficient than MV_CC_GetOneFrameTimeout. The allocation of the stream cache is automatically allocated within the SDK.The MV_CC_GetOneFrameTimeout interface needs to be allocated by customers themselves. \n + This API cannot be called to stream after calling MV_CC_Display. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. \n + **********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageBuffer(IN void* handle, OUT MV_FRAME_OUT* pstFrame, IN int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ͷͼ񻺴(˽ӿͷŲʹõͼ񻺴棬MV_CC_GetImageBufferʹ) + * @param handle [IN] 豸 + * @param pstFrame [IN] ͼݺͼ + * @return ɹMV_OK󣬷ش + * @remarks ýӿMV_CC_GetImageBufferʹãʹMV_CC_GetImageBufferӿȡͼpFrameҪMV_CC_FreeImageBufferӿڽȨͷš \n + ýӿڶȡЧʸGetOneFrameTimeoutӿڣGetImageBufferڲFree£֧ĽڵSetImageNodeӿõĽڵȣĬϽڵ1\n + ýӿڶU3VGIGE豸֧֡ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Free image buffer(this interface can free image buffer, used with MV_CC_GetImageBuffer) + * @param handle [IN] Device handle + * @param pstFrame [IN] Image data and image information + * @return Success, return MV_OK. Failure, return error code + * @remarks This API and MV_CC_GetImageBuffer should be called in pairs, before calling MV_CC_GetImageBuffer to get image data pFrame, you should call MV_CC_FreeImageBuffer to release the permission. \n + Compared with API MV_CC_GetOneFrameTimeout, this API has higher efficiency of image acquisition. The max. number of nodes can be outputted is same as the "nNum" of API MV_CC_SetImageNodeNum, default value is 1. \n + This API is not supported by CameraLink device. \n + This API is supported by both USB3 vision camera and GigE camera. + **********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FreeImageBuffer(IN void* handle, IN MV_FRAME_OUT* pstFrame); + +/********************************************************************//** + * @~chinese + * @brief óʱƻȡһ֡ͼƬSDKڲȴֱʱ + * @param handle [IN] 豸 + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pstFrameInfo [OUT] ͼϢṹ + * @param nMsec [IN] ȴʱʱ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڻȡͼ֮֡ǰҪȵMV_CC_StartGrabbingͼɼýӿΪʽȡ֡ݣϲӦóҪ֡ʣƺõøýӿڵƵʡýӿ֧óʱʱ䣬SDKڲȴֱʱأȡƽԣʺڶƽҪϸߵijϡ\n + ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Timeout mechanism is used to get image, and the SDK waits inside until the data is returned + * @param handle [IN] Device handle + * @param pData [OUT] Image data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pstFrameInfo [OUT] Image information structure + * @param nMsec [IN] Waiting timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks Before calling this API to get image data frame, call MV_CC_StartGrabbing to start image acquisition. This API can get frame data actively, the upper layer program should control the frequency of calling this API according to the frame rate. This API supports setting timeout, SDK will wait to return until data appears. This function will increase the streaming stability, which can be used in the situation with high stability requirement. \n + Both the USB3Vision and GIGE camera can support this API. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOneFrameTimeout(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pstFrameInfo, unsigned int nMsec); + +/********************************************************************//** + * @~chinese + * @brief ȡݻ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + * @remarks ýӿûڲֹͣȡʱ򣬾вҪͼ\n + ýӿģʽдģʽ󣬿ʷݡ + + * @~english + * @brief if Image buffers has retrieved the dataClear them + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface allows user to clear the unnecessary images from the buffer memory without stopping acquisition. \n + This interface allows user to clear previous data after switching from continuous mode to trigger mode. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_ClearImageBuffer(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief ʾһ֡ͼ + * @param handle [IN] 豸 + * @param pstDisplayInfo [IN] ͼϢ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶU3VGIGE豸֧֡\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Display one frame image + * @param handle [IN] Device handle + * @param pstDisplayInfo [IN] Frame Info + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is valid for USB3Vision camera and GIGE camera. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_DisplayOneFrame(IN void* handle, IN MV_DISPLAY_FRAME_INFO* pstDisplayInfo); + +/********************************************************************//** + * @~chinese + * @brief SDKڲͼ񻺴ڵڵ1ץͼǰ + * @param handle [IN] 豸 + * @param nNum [IN] ڵ + * @return ɹMV_OK󣬷ش + * @remarks øýӿڿSDKڲͼ񻺴ڵڵMV_CC_StartGrabbingʼץͼǰá\n + SDKĬ1ڵ㡣\n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Set the number of the internal image cache nodes in SDK, Greater than or equal to 1, to be called before the capture + * @param handle [IN] Device handle + * @param nNum [IN] Image Node Number + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface to set the number of SDK internal image buffer nodes. The interface should be called before calling MV_CC_StartGrabbing for capturing. \n + This API is not supported by CameraLink device. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetImageNodeNum(IN void* handle, unsigned int nNum); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param enGrabStrategy [IN] öֵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڶȡԣûԸʵѡ񡣾£ + -OneByOne:Ӿɵһ֡һ֡Ĵблȡͼ񣬴豸ĬΪò + -LatestImagesOnly:блȡµһ֡ͼͬʱб + -LatestImages:блȡµOutputQueueSize֡ͼOutputQueueSizeΧΪ1-ImageNodeNumMV_CC_SetOutputQueueSizeӿãImageNodeNumĬΪ1MV_CC_SetImageNodeNumӿ OutputQueueSizeó1ͬLatestImagesOnlyԣOutputQueueSizeóImageNodeNumͬOneByOne + -UpcomingImage:ڵȡӿʱбͼ񣬲ȴ豸ɵһ֡ͼ񡣸òֻ֧GigE豸֧U3V豸 + + * @~english + * @brief Set Grab Strategy + * @param handle [IN] Device handle + * @param enGrabStrategy [IN] The value of Grab Strategy + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is set by four image acquisition approaches, the user may choose one as needed. Specific details are as followed: + -OneByOne:Obtain image from output cache list frame by frame in order, this function is default strategy when device is on. + -LatestImagesOnly:Obtain the latest image from output cache list only, meanwhile clear output cache list. + -LatestImages:Obtain the latest OutputQueueSize image from output cache list, the range of OutputQueueSize is 1-ImageNodeNum, the user may set the value of MV_CC_SetOutputQueueSizeinterface,the default value of ImageNodeNum is 1,If the user usesMV_CC_SetImageNodeNuminterface to set up OutputQueueSize,when the value of OutputQueueSize is set to be 1, the function will be same as LatestImagesOnly; if the value of OutputQueueSize is set to be ImageNodeNum, the function will be same as OneByOne. + -UpcomingImage:Ignore all images in output cache list when calling image acuiqisiotn interface, wait the next upcoming image generated. Support for GigE camera only, not support for U3V camera. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGrabStrategy(IN void* handle, IN MV_GRAB_STRATEGY enGrabStrategy); + +/********************************************************************//** + * @~chinese + * @brief ֻMV_GrabStrategy_LatestImages²ЧΧ1-ImageNodeNum + * @param handle [IN] 豸 + * @param nOutputQueueSize [IN] + * @return ɹMV_OK󣬷ش + * @remarks ýӿLatestImagesȡ׵ãLatestImagesͼĸȡж̬ + + * @~english + * @brief Set The Size of Output Queue(Only work under the strategy of MV_GrabStrategy_LatestImagesrang1-ImageNodeNum) + * @param handle [IN] Device handle + * @param nOutputQueueSize [IN] The Size of Output Queue + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface must be used with LatestImages Grab strategy, it is used for setting the maximum allowance queue size of the image under the LatestImages strategy. The user may change the output queue size while grabbing images. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetOutputQueueSize(IN void* handle, IN unsigned int nOutputQueueSize); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸Ϣȡ֮ǰ + * @param handle [IN] 豸 + * @param pstDevInfo [IN][OUT] ظй豸Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ֧ûڴ豸ȡ豸Ϣ\n + 豸GigE豸øýӿڴգ˲ȡеøýӿڡ + + * @~english + * @brief Get device information + * @param handle [IN] Device handle + * @param pstDevInfo [IN][OUT] Structure pointer of device information + * @return Success, return MV_OK. Failure, return error code + * @remarks The API support users to access device information after opening the device. \n + If the device is a GigE camera, there is a blocking risk in calling the interface, so it is not recommended to call the interface during the fetching process. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceInfo(IN void * handle, IN OUT MV_CC_DEVICE_INFO* pstDevInfo); + +/********************************************************************//** + * @~chinese + * @brief ȡ͵Ϣ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظй豸͵Ϣṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӿҪȡϢָͣMV_ALL_MATCH_INFOṹеnTypeͣȡӦϢMV_ALL_MATCH_INFOṹpInfoﷵأ \n + ýӿڵĵǰȡȡϢͣȡGigE豸MV_MATCH_TYPE_NET_DETECTϢڿץͼ֮ãȡU3V豸MV_MATCH_TYPE_USB_DETECTϢڴ豸֮á \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get various type of information + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of various type of information + * @return Success, return MV_OK. Failure, return error code + * @remarks Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO). \n + The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of USB3Vision device. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAllMatchInfo(IN void* handle, IN OUT MV_ALL_MATCH_INFO* pstInfo); + + +/************************************************************************/ +/* úͻȡ豸ܽӿ */ +/* General interface for getting and setting camera parameters */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡIntegerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param pstIntValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to get width + * @param pstIntValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetIntValueEx(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE_EX *pstIntValue); + +/********************************************************************//** + * @~chinese + * @brief Integerֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡϢΪ"Width" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿint͵ָڵֵstrKeyȡֵԲοXMLڵбΪIIntegerĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Integer value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "Width" to set width + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks You can call this API to get the value of camera node with integer type after connecting the device. For strKey value, refer to MvCameraNode. All the node values of "IInteger" in the list can be obtained via this API. strKey corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetIntValueEx(IN void* handle,IN const char* strKey,IN int64_t nValue); + +/********************************************************************//** + * @~chinese + * @brief ȡEnumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param pstEnumValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to get pixel format + * @param pstEnumValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetEnumValue(IN void* handle,IN const char* strKey,OUT MVCC_ENUMVALUE *pstEnumValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param nValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see MvCameraNode, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetEnumValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + +/********************************************************************//** + * @~chinese + * @brief Enumֵ + * @param handle [IN] 豸 + * @param strKey [IN] ԼֵȡظʽϢΪ"PixelFormat" + * @param strValue [IN] Ҫõ豸ַ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿEnum͵ָڵֵstrKeyȡֵԲοXMLڵбΪIEnumerationĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Enum value + * @param handle [IN] Device handle + * @param strKey [IN] Key value, for example, using "PixelFormat" to set pixel format + * @param strValue [IN] Feature String to set + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API after connecting the device. All the values of nodes with IEnumeration type can be set via this API. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetEnumValueByString(IN void* handle,IN const char* strKey,IN const char* strValue); + +/********************************************************************//** + * @~chinese + * @brief ȡFloatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstFloatValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstFloatValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFloatValue(IN void* handle,IN const char* strKey,OUT MVCC_FLOATVALUE *pstFloatValue); + +/********************************************************************//** + * @~chinese + * @brief floatֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param fValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿfloat͵ָڵֵstrKeyȡֵԲοXMLڵбΪIFloatĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set float value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param fValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified float node. For detailed strKey value see: MvCameraNode. The node values of IFloat can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetFloatValue(IN void* handle,IN const char* strKey,IN float fValue); + +/********************************************************************//** + * @~chinese + * @brief ȡBooleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pbValue [IN][OUT] ظй豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pbValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBoolValue(IN void* handle,IN const char* strKey,OUT bool *pbValue); + +/********************************************************************//** + * @~chinese + * @brief Booleanֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param bValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿbool͵ָڵֵstrKeyȡֵԲοXMLڵбΪIBooleanĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set Boolean value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param bValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified bool nodes. For value of strKey, see MvCameraNode. The node values of IBoolean can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBoolValue(IN void* handle,IN const char* strKey,IN bool bValue); + +/********************************************************************//** + * @~chinese + * @brief ȡStringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param pstStringValue [IN][OUT] ظй豸Խṹָ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿԻȡstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿڻȡstrKeyȡֵӦбġơһС + + * @~english + * @brief Get String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param pstStringValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to get specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be obtained through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetStringValue(IN void* handle,IN const char* strKey,OUT MVCC_STRINGVALUE *pstStringValue); + +/********************************************************************//** + * @~chinese + * @brief Stringֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @param strValue [IN] Ҫõ豸ֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿstring͵ָڵֵstrKeyȡֵԲοXMLڵбΪIStringĽڵֵͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Set String value + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @param strValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified string nodes. For value of strKey, see MvCameraNode. The node values of IString can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetStringValue(IN void* handle,IN const char* strKey,IN const char * strValue); + +/********************************************************************//** + * @~chinese + * @brief Commandֵ + * @param handle [IN] 豸 + * @param strKey [IN] Լֵ + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸֮øýӿڿָCommandͽڵ㡣strKeyȡֵԲοXMLڵбΪICommandĽڵ㶼ͨýӿãstrKeyȡֵӦбġơһС + + * @~english + * @brief Send Command + * @param handle [IN] Device handle + * @param strKey [IN] Key value + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set specified Command nodes. For value of strKey, see MvCameraNode. The node values of ICommand can be set through this interface, strKey value corresponds to the Name column. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetCommandValue(IN void* handle,IN const char* strKey); + +/********************************************************************//** + * @~chinese + * @brief GenICamڵ㻺 + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Invalidate GenICam Nodes + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_InvalidateNodes(IN void* handle); + + +/************************************************************************/ +/* 豸 Ĵд 쳣¼ص */ +/* Device upgrade, register read and write and exception callback */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFilePathName [IN] ļ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԽ̼ļ͸豸ýӿҪȴ̼ļɹ豸֮ٷأӦʱܽϳ + + * @~english + * @brief Device Local Upgrade + * @param handle [IN] Device handle + * @param strFilePathName [IN] File name + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to send the upgrade firmware to the device for upgrade. This API will wait for return until the upgrade firmware is sent to the device, this response may take a long time. \n + For CameraLink device, it keeps sending upgrade firmware continuously. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_LocalUpgrade(IN void* handle, const void *strFilePathName); + +/********************************************************************//** + * @~chinese + * @brief ȡ + * @param handle [IN] 豸 + * @param pnProcess [OUT] Ƚյַ + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Get Upgrade Progress + * @param handle [IN] Device handle + * @param pnProcess [OUT] Progress receiving address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetUpgradeProcess(IN void* handle, unsigned int* pnProcess); + +/********************************************************************//** + * @~chinese + * @brief ڴ + * @param handle [IN] 豸 + * @param pBuffer [IN][OUT] ΪֵʹãڴֵGEV豸ڴֵǰմģʽ洢ģЭ豸С˴洢 + * @param nAddress [IN] ȡڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] ȡڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸ȡijμĴݡ + + * @~english + * @brief Read Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN][OUT] Used as a return value, save the read-in memory value ( Memory value is stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be read, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be read + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, read the data from certain register. +*************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_ReadMemory(IN void* handle , void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief дڴ + * @param handle [IN] 豸 + * @param pBuffer [IN] дڴֵעGEV豸ڴֵҪմģʽ洢Э豸С˴洢 + * @param nAddress [IN] дڴַõַԴ豸Camera.xmlļлȡxxx_RegAddrxmlڵֵ + * @param nLength [IN] дڴ泤 + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸һдijμĴ + + * @~english + * @brief Write Memory + * @param handle [IN] Device Handle + * @param pBuffer [IN] Memory value to be written ( Note the memory value to be stored in accordance with the big end model) + * @param nAddress [IN] Memory address to be written, which can be obtained from the Camera.xml file of the device, the form xml node value of xxx_RegAddr + * @param nLength [IN] Length of the memory to be written + * @return Success, return MV_OK. Failure, return error code + * @remarks Access device, write a piece of data into a certain segment of register. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_WriteMemory(IN void* handle , const void *pBuffer, int64_t nAddress, int64_t nLength); + +/********************************************************************//** + * @~chinese + * @brief ע쳣Ϣصڴ豸֮ + * @param handle [IN] 豸 + * @param cbException [IN] 쳣صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿҪMV_CC_OpenDevice豸֮á豸쳣ϿӺڻصȡ쳣ϢGigE豸֮ҪȵMV_CC_CloseDeviceӿڹر豸ٵMV_CC_OpenDeviceӿ´豸 + + * @~english + * @brief Register Exception Message CallBack, call after open device + * @param handle [IN] Device handle + * @param cbException [IN] Exception Message CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterExceptionCallBack(IN void* handle, + void(__stdcall* cbException)(unsigned int nMsgType, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עȫ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Register event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterAllEventCallBack(void* handle, void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + +/********************************************************************//** + * @~chinese + * @brief עᵥ¼صڴ豸֮ + * @param handle [IN] 豸 + * @param strEventName [IN] ¼ + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿ¼صڻصȡɼع¼Ϣ\n + ýӿڲ֧CameraLink豸֧"豸"һ¼ + + * @~english + * @brief Register single event callback, which is called after the device is opened + * @param handle [IN] Device handle + * @param strEventName [IN] Event name + * @param cbEvent [IN] Event CallBack Function Pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the event callback function to get the event information, e.g., acquisition, exposure, and so on. \n + This API is not supported by CameraLink device . +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterEventCallBackEx(void* handle, const char* strEventName, + void(__stdcall* cbEvent)(MV_EVENT_OUT_INFO * pEventInfo, void* pUser), void* pUser); + + +/************************************************************************/ +/* GigEVision 豸еĽӿ */ +/* GigEVision device specific interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ǿIP + * @param handle [IN] 豸 + * @param nIP [IN] õIP + * @param nSubNetMask [IN] + * @param nDefaultGateWay [IN] Ĭ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ǿ豸IP롢Ĭأǿ֮Ҫ´豸GigEVision豸֧֡\n + 豸ΪDHCP״̬øýӿǿ豸֮豸 + + * @~english + * @brief Force IP + * @param handle [IN] Device handle + * @param nIP [IN] IP to set + * @param nSubNetMask [IN] Subnet mask + * @param nDefaultGateWay [IN] Default gateway + * @return Success, return MV_OK. Failure, return error code + * @remarks Force setting camera network parameter (including IP address, subnet mask, default gateway). After forced setting, device handle should be created again. This function is only supported by GigEVision camera.\n + If device is in DHCP status, after calling this API to force setting camera network parameter, the device will restart. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_ForceIpEx(IN void* handle, unsigned int nIP, unsigned int nSubNetMask, unsigned int nDefaultGateWay); + +/********************************************************************//** + * @~chinese + * @brief IPʽ + * @param handle [IN] 豸 + * @param nType [IN] IPͣMV_IP_CFG_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks 豸IPʽDHCPLLAȣGigEVision豸֧֡ + + * @~english + * @brief IP configuration method + * @param handle [IN] Device handle + * @param nType [IN] IP type, refer to MV_IP_CFG_x + * @return Success, return MV_OK. Failure, return error code + * @remarks Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetIpConfig(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ýʹijģʽ,type: MV_NET_TRANS_xʱĬʹdriver + * @param handle [IN] 豸 + * @param nType [IN] 紫ģʽMV_NET_TRANS_x + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿSDKڲʹõģʽĬʹģʽGigEVision豸֧֡ + + * @~english + * @brief Set to use only one mode,type: MV_NET_TRANS_x. When do not set, priority is to use driver by default + * @param handle [IN] Device handle + * @param nType [IN] Net transmission mode, refer to MV_NET_TRANS_x + * @return Success, return MV_OK. Failure, return error code + * @remarksSet SDK internal priority network mode through this interface, drive mode by default, only supported by GigEVision camera. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetNetTransMode(IN void* handle, unsigned int nType); + +/********************************************************************//** + * @~chinese + * @brief ȡ紫Ϣ + * @param handle [IN] 豸 + * @param pstInfo [OUT] Ϣṹ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ͨýӿڿԻȡ紫ϢѽݴС֡ȣMV_CC_StartGrabbingɼ֮áGigEVision豸֧֡ + + * @~english + * @brief Get net transmission information + * @param handle [IN] Device handle + * @param pstInfo [OUT] Information Structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Get network transmission information through this API, including received data size, number of lost frames. Call this API after starting image acquiring through MV_CC_StartGrabbing. This API is supported only by GigEVision Camera. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetNetTransInfo(IN void* handle, MV_NETTRANS_INFO* pstInfo); + +/********************************************************************//** + * @~chinese + * @brief öĻظ + * @param nMode [IN] ظͣĬϹ㲥0-1-㲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻGigEЧ + + * @~english + * @brief Setting the ACK mode of devices Discovery. + * @param nMode [IN] ACK modeDefault-Broadcast,0-Unicast,1-Broadcast. + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is ONLY effective on GigE cameras. \n + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetDiscoveryMode(unsigned int nMode); + +/********************************************************************//** + * @~chinese + * @brief GVSPȡʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ300msΧ>10ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮ȡǰøýӿڿGVSPȡʱʱ䡣GVSPȡʱù̿ͼ쳣ùȡʱ䳤 + + * @~english + * @brief Set GVSP streaming timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 300ms, range: >10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, and just before start streaming, + * call this interface to set GVSP streaming timeout value. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGvspTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVSPȡʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVSPȡʱʱ + + * @~english + * @brief Get GVSP streaming timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVSP streaming timeout. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGvspTimeout(IN void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief GVCPʱʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ʱʱ䣬Ĭ500msΧ0-10000ms + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿGVCPʱʱ䡣 + + * @~english + * @brief Set GVCP cammand timeout + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout, default 500ms, range: 0-10000ms + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set GVCP command timeout time. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGvcpTimeout(void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡGVCPʱʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ʱʱָ룬Ժλλ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPʱʱ䡣 + + * @~english + * @brief Get GVCP cammand timeout + * @param handle [IN] Device handle + * @param pnMillisec [OUT] Timeout, ms as unit + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current GVCP timeout. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGvcpTimeout(void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief شGVCP + * @param handle [IN] 豸 + * @param nRetryGvcpTimes [IN] شΧ0-100 + * @return ɹMV_OK󣬷ش + * @remarks ýӿGVCP쳣ʱشĴһ̶ϿԱ豸ߣΧΪ0-100 + + * @~english + * @brief Set the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param nRetryGvcpTimes [IN] The number of retriesrang0-100 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to increase The Times of retransmission when GVCP packet transmission is abnormal,and to some extent, it can avoid dropping the camera, with a range of 0-100. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetRetryGvcpTimes(void* handle, unsigned int nRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشGVCP + * @param handle [IN] 豸 + * @param pnRetryGvcpTimes [OUT] شָ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڻȡǰGVCPشĬ3Ρ + + * @~english + * @brief Get the number of retry GVCP cammand + * @param handle [IN] Device handle + * @param pnRetryGvcpTimes [OUT] The number of retries + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of GVCP retransmissions, which defaults to 3. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetRetryGvcpTimes(void* handle, unsigned int* pnRetryGvcpTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡѵpacket sizeýӿĿǰֻ֧GigE豸 + * @param handle [IN] 豸 + * @return packetsize + * @remarks ȡѵpacket sizeӦGigEVision豸SCPSӦU3V豸ÿδȡİСôСϴһĴСýӿҪMV_CC_OpenDevice֮MV_CC_StartGrabbing֮ǰá \n + ýӿڲ֧CameraLink豸 + + * @~english + * @brief Get the optimal Packet Size, Only support GigE Camera + * @param handle [IN] Device handle + * @return Optimal packetsize + * @remarks To get optimized packet size, for GigEVision device is SCPS, for USB3Vision device is the size of packet read from drive each time, and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing. \n + This API is not supported by CameraLink device. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOptimalPacketSize(IN void* handle); + +/********************************************************************//** + * @~chinese + * @brief Ƿط֧֣ط + * @param handle [IN] 豸 + * @param bEnable [IN] Ƿ֧ط + * @param nMaxResendPercent [IN] ط + * @param nResendTimeout [IN] طʱʱ + * @return ɹMV_OK󣬷ش + * @remarks 豸֮øýӿڿطԣGigEVision豸֧֡ + + * @~english + * @brief Set whethe to enable resend, and set resend + * @param handle [IN] Device handle + * @param bEnable [IN] enable resend + * @param nMaxResendPercent [IN] Max resend persent + * @param nResendTimeout [IN] Resend timeout + * @return Success, return MV_OK. Failure, return error code + * @remarks After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetResend(void* handle, unsigned int bEnable, unsigned int nMaxResendPercent, unsigned int nResendTimeout); + +/********************************************************************//** + * @~chinese + * @brief شԴ + * @param handle [IN] 豸 + * @param nRetryTimes [IN] شԴĬ20 + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set the max resend retry times + * @param handle [IN] Device handle + * @param nRetryTimes [IN] The max times to retry resending lost packetsdefault 20 + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetResendMaxRetryTimes (void* handle, unsigned int nRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ȡشԴ + * @param handle [IN] 豸 + * @param pnRetryTimes [OUT] شԴ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get the max resend retry times + * @param handle [IN] Device handle + * @param pnRetryTimes [OUT] The max times to retry resending lost packets + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetResendMaxRetryTimes (void* handle, unsigned int* pnRetryTimes); + +/********************************************************************//** + * @~chinese + * @brief ͬһش֮ʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ͬһش֮ʱĬ10ms + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief set time interval between same resend requests + * @param handle [IN] Device handle + * @param nMillisec [IN] The time interval between same resend requests,default 10ms + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetResendTimeInterval (void* handle, unsigned int nMillisec); + +/********************************************************************//** + * @~chinese + * @brief ȡͬһش֮ʱ + * @param handle [IN] 豸 + * @param pnMillisec [OUT] ͬһش֮ʱ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڱڵMV_GIGE_SetResendش֮ãʧҷMV_E_CALLORDER + + * @~english + * @brief get time interval between same resend requests + * @param handle [IN] Device handle + * @param pnMillisec [OUT] The time interval between same resend requests + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface MUST be called after enabling resending lost packets by calling MV_GIGE_SetResend, \n + * otherwise would fail and return MV_E_CALLORDER. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetResendTimeInterval (void* handle, unsigned int* pnMillisec); + +/********************************************************************//** + * @~chinese + * @brief ôģʽΪģʽ鲥ģʽ + * @param handle [IN] 豸 + * @param stTransmissionType [IN] ģʽṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨýӿڿôģʽΪ鲥ģʽGigEVision豸֧֡ + + * @~english + * @brief Set transmission type,Unicast or Multicast + * @param handle [IN] Device handle + * @param stTransmissionType [IN] Struct of transmission type + * @return Success, return MV_OK. Failure, return error code + * @remarks Call this API to set the transmission mode as single cast mode and multicast mode. And this API is only valid for GigEVision camera. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetTransmissionType(void* handle, MV_TRANSMISSION_TYPE * pstTransmissionType); + +/********************************************************************//** + * @~chinese + * @brief + * @param pstActionCmdInfo [IN] Ϣ + * @param pstActionCmdResults [OUT] Ϣб + * @return ɹMV_OK󣬷ش + * @remarks GigEVision豸֧֡ + + * @~english + * @brief Issue Action Command + * @param pstActionCmdInfo [IN] Action Command + * @param pstActionCmdResults [OUT] Action Command Result List + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by GigEVision camera. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_IssueActionCommand(IN MV_ACTION_CMD_INFO* pstActionCmdInfo, OUT MV_ACTION_CMD_RESULT_LIST* pstActionCmdResults); + +/********************************************************************//** + * @~chinese + * @brief ȡ鲥״̬ + * @param pstDevInfo [IN] 豸Ϣṹ + * @param pbStatus [OUT] 鲥״̬,true:鲥״̬false:鲥 + * @return ɹMV_OK󣬷ش + * @remarks ýӿж豸ǰǷ鲥״̬ͻöʱҪ豸ж鲥⡣ + + * @~english + * @brief Get Multicast Status + * @param pstDevInfo [IN] Device Information Structure + * @param pbStatus [OUT] Status of Multicast + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to determine whether the camera is currently in multicast state, and to solve the problem that the client needs to turn on the camera to determine multicast when enumerating. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetMulticastStatus(IN MV_CC_DEVICE_INFO* pstDevInfo, OUT bool* pbStatus); + + +/************************************************************************/ +/* CameraLink 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_SetDeviceBaudrate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetDeviceBaudrate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿ֧豸δʱá + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is supported only by CameraLink device.\n + This API support calls when devices are not connected. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetSupportBaudrates(IN void* handle,unsigned int* pnBaudrateAblity); + +/********************************************************************//** + * @~chinese + * @brief ôڲȴʱ + * @param handle [IN] 豸 + * @param nMillisec [IN] ڲĵȴʱ, λΪms + * @return ɹ,MV_OK,ʧ,ش + + * @~english + * @brief Sets the timeout for operations on the serial port + * @param handle [IN] Device handle + * @param nMillisec [IN] Timeout in [ms] for operations on the serial port. + * @return Success, return MV_OK. Failure, return error code +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_SetGenCPTimeOut(IN void* handle, unsigned int nMillisec); + + +/************************************************************************/ +/* U3V 豸еĽӿ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief U3VĴС + * @param handle [IN] 豸 + * @param nTransferSize [IN] İС, ByteĬΪ1Mrang>=0x10000 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ӴСʵȡʱCPUռʡͬPCͲͬUSBչڲͬļԣòùܻȡͼķա + + * @~english + * @brief Set transfer size of U3V device + * @param handle [IN] Device handle + * @param nTransferSize [IN] Transfer sizeBytedefault1Mrang>=0x10000 + * @return Success, return MV_OK. Failure, return error code + * @remarks Increasing the transmission packet size can reduce the CPU utilization at the time of fetching. However, different PCS and different USB extension CARDS have different compatibility, and if this parameter is set too large, there may be the risk of not getting the image. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_SetTransferSize(IN void* handle, unsigned int nTransferSize); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴС + * @param handle [IN] 豸 + * @param pnTransferSize [OUT] İСָ, Byte + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3VСĬ1M + + * @~english + * @brief Get transfer size of U3V device + * @param handle [IN] Device handle + * @param pnTransferSize [OUT] Transfer sizeByte + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current U3V transfer packet size, default 1M. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_GetTransferSize(IN void* handle, unsigned int* pnTransferSize); + +/********************************************************************//** + * @~chinese + * @brief U3VĴͨ + * @param handle [IN] 豸 + * @param nTransferWays [IN] ͨΧ1-10 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ûԸPCܡ豸ͼ֡ʡͼСڴʹʵضԸòеڡͬPCͲͬUSBչڲͬļԡ + + * @~english + * @brief Set transfer ways of U3V device + * @param handle [IN] Device handle + * @param nTransferWays [IN] Transfer waysrang1-10 + * @return Success, return MV_OK. Failure, return error code + * @remarks Users can adjust this parameter according to PC performance, camera image frame rate, image size, memory utilization and other factors. But different PCS and different USB expansion CARDS have different compatibility. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_SetTransferWays(IN void* handle, unsigned int nTransferWays); + +/********************************************************************//** + * @~chinese + * @brief ȡU3VĴͨ + * @param handle [IN] 豸 + * @param pnTransferWays [OUT] ָͨ + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿڻȡǰU3V첽ȡڵ2000W豸MONO8ĬΪ3YUVΪĬ2RGBΪĬ1Ĭ8ڵ㡣 + + * @~english + * @brief Get transfer ways of U3V device + * @param handle [IN] Device handle + * @param pnTransferWays [OUT] Transfer ways + * @return Success, return MV_OK. Failure, return error code + * @remarks This interface is used to get the current number of U3V asynchronous feed nodes. For 2000W camera, MONO8 defaults to 3, YUV defaults to 2, RGB defaults to 1, and other cases default to 8 nodes. +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_USB_GetTransferWays(IN void* handle, unsigned int* pnTransferWays); + +/************************************************************************/ +/* GenTLؽӿڣӿڿԸãֽӿڲ֧֣ */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͨGenTLöInterfaces + * @param pstIFList [OUT] Interfacesб + * @param strGenTLPath [IN] GenTLctiļ· + * @return ɹMV_OK󣬷ش + * @remarks InterfacesбڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Interfaces with GenTL + * @param pstIFList [OUT] Interfaces List + * @param strGenTLPath [IN] GenTL cti file path + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the Interfaces list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumInterfacesByGenTL(IN OUT MV_GENTL_IF_INFO_LIST* pstIFList, IN const char * strGenTLPath); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL Interfaceö豸 + * @param pstIFInfo [IN] InterfaceϢ + * @param pstDevList [OUT] 豸б + * @return ɹMV_OK󣬷ش + * @remarks 豸бڴSDKڲģ̵߳øýӿʱ豸бڴͷź룬\n + 龡߳öٲ + + * @~english + * @brief Enumerate Devices with GenTL interface + * @param pstIFInfo [IN] Interface information + * @param pstDevList [OUT] Device List + * @return Success, return MV_OK. Failure, return error code + * @remarks The memory of the list is allocated within the SDK. When the interface is invoked by multiple threads, the memory of the device list will be released and applied.\n + It is recommended to avoid multithreaded enumeration operations as much as possible. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_EnumDevicesByGenTL(IN MV_GENTL_IF_INFO* pstIFInfo, IN OUT MV_GENTL_DEV_INFO_LIST* pstDevList); + +/********************************************************************//** + * @~chinese + * @brief ͨGenTL豸Ϣ豸 + * @param handle [OUT] 豸 + * @param pstDevInfo [IN] 豸Ϣṹָ + * @return ɹMV_OK󣬷ش + * @remarks 豸ϢڲԴͳʼڲģ顣 + + * @~english + * @brief Create Device Handle with GenTL Device Info + * @param handle [OUT] Device handle + * @param pstDevInfo [IN] Device Information + * @return Success, return MV_OK. Failure, return error code + * @remarks Create required resources within library and initialize internal module according to input device information. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_CreateHandleByGenTL(OUT void ** handle, IN const MV_GENTL_DEV_INFO* pstDevInfo); + + +/************************************************************************/ +/* XML */ +/* XML parse tree generation */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ȡ豸XML + * @param handle [IN] 豸 + * @param pData [OUT] XMLݽջ + * @param nDataSize [IN] ջС + * @param pnDataLen [OUT] ʵݴС + * @return ɹMV_OK󣬷ش + * @remarks pDataΪNULLnDataSizeʵʵxmlļСʱݣpnDataLenxmlļС\n + pDataΪЧַһ㹻ʱݱڸû棬pnDataLenxmlļʵʴС + + * @~english + * @brief Get camera feature tree XML + * @param handle [IN] Device handle + * @param pData [OUT] XML data receiving buffer + * @param nDataSize [IN] Buffer size + * @param pnDataLen [OUT] Actual data length + * @return Success, return MV_OK. Failure, return error code + * @remarks When pData is NULL or nDataSize than the actual XML file hours, do not copy the data, returned by pnDataLen XML file size.\n + When pData is a valid cache address and the cache is large enough, copy the full data into the cache, and pnDataLen returns the actual size of the XML file. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetGenICamXML(IN void* handle, IN OUT unsigned char* pData, IN unsigned int nDataSize, OUT unsigned int* pnDataLen); + +/********************************************************************//** + * @~chinese + * @brief õǰڵķģʽ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penAccessMode [OUT] ڵķģʽ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Get Access mode of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penAccessMode [OUT] Access mode of the node + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetNodeAccessMode(IN void* handle, IN const char * pstrName, OUT MV_XML_AccessMode *penAccessMode); + +/********************************************************************//** + * @~chinese + * @brief õǰڵ + * @param handle [IN] 豸 + * @param strName [IN] ڵ + * @param penInterfaceType [OUT] ڵ + * @return ɹMV_OK󣬷ش + * @remarks ýӿڿڵܽӿ֮ǰǰ֪ڵͣûѡʵܽӿڽнڵֵúͻȡ + + * @~english + * @brief Get Interface Type of cur node + * @param handle [IN] Device handle + * @param strName [IN] Name of node + * @param penInterfaceType [OUT] Interface Type of the node + * @return Success, return MV_OK. Failure, return error code + * @remarks The interface can know the node type in advance before calling the universal interface, so as to facilitate users to select the appropriate universal interface for setting and obtaining the node value. + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetNodeInterfaceType(IN void* handle, IN const char * pstrName, OUT MV_XML_InterfaceType *penInterfaceType); + +/************************************************************************/ +/* ӽӿ */ +/* Additional interface */ +/************************************************************************/ +/********************************************************************//** + * @~chinese + * @brief ͼƬ֧BmpJpeg. + * @param handle [IN] 豸 + * @param pstSaveParam [IN][OUT] ͼƬṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתJPEGBMPȸʽָڴУȻûԽתֱ֮ӱͼƬļýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ \n + MV_CC_SaveImageEx2MV_CC_SaveImageExӲhandleΪ˱֤ӿڵͳһ + + * @~english + * @brief Save image, support Bmp and Jpeg. + * @param handle [IN] Device handle + * @param pstSaveParam [IN][OUT] Save image parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Once there is image data, you can call this API to convert the data. \n + You can also call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx or MV_CC_GetImageBuffer to get one image frame and set the callback function, and then call this API to convert the format. \n + Comparing with the API MV_CC_SaveImageEx, this API added the parameter handle to ensure the unity with other API. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImageEx2(IN void* handle, MV_SAVE_IMAGE_PARAM_EX* pstSaveParam); + +/********************************************************************//** + * @~chinese + * @brief ͼļ + * @param handle [IN] 豸 + * @param pstSaveFileParam [IN][OUT] ͼƬļṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿ֧BMP/JPEG/PNG/TIFF + + * @~english + * @brief Save the image file. + * @param handle [IN] Device handle + * @param pstSaveFileParam [IN][OUT] Save the image file parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API support BMP/JPEG/PNG/TIFF. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImageToFile(IN void* handle, MV_SAVE_IMG_TO_FILE_PARAM* pstSaveFileParam); + +/********************************************************************//** + * @~chinese + * @brief 3Dݣ֧PLYCSVOBJָʽ + * @param handle [IN] 豸 + * @param pstPointDataParam [IN][OUT] ݲṹ + * @return ɹMV_OK󣬷ش + * @remarks 3Dݸʽ3Dļʽ֧PLY/CSV/OBJ/n + Ŀǰ֧PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,ݲ֧3Dʽ + + * @~english + * @brief Save 3D point data, support PLYCSV and OBJ + * @param handle [IN] Device handle + * @param pstPointDataParam [IN][OUT] Save 3D point data parameters structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Save the 3D data format to 3D file formatsupport PLYCSV and OBJ/n + only support PixelType_Gvsp_Coord3D_ABC32PixelType_Gvsp_Coord3D_ABC32fPixelType_Gvsp_Coord3D_AB32PixelType_Gvsp_Coord3D_AB32fPixelType_Gvsp_Coord3D_AC32PixelType_Gvsp_Coord3D_AC32f,Other 3D format is not supported now. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SavePointCloudData(IN void* handle, MV_SAVE_POINT_CLOUD_PARAM* pstPointDataParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstRotateParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵ90/180/270ת + + * @~english + * @brief Rotate Image + * @param handle [IN] Device handle + * @param pstRotateParam [IN][OUT] Rotate image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support 90/180/270 rotation of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RotateImage(IN void* handle, IN OUT MV_CC_ROTATE_IMAGE_PARAM* pstRotateParam); + +/********************************************************************//** + * @~chinese + * @brief ͼת + * @param handle [IN] 豸 + * @param pstFlipParam [IN][OUT] ͼתṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧MONO8/RGB24/BGR24ʽݵĴֱˮƽת + + * @~english + * @brief Flip Image + * @param handle [IN] Device handle + * @param pstFlipParam [IN][OUT] Flip image parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support vertical and horizontal reverse of data in the MONO8/RGB24/BGR24 format. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FlipImage(IN void* handle, IN OUT MV_CC_FLIP_IMAGE_PARAM* pstFlipParam); + +/********************************************************************//** + * @~chinese + * @brief ظʽת + * @param handle [IN] 豸 + * @param pstCvtParam [IN][OUT] ظʽתṹ + * @return ɹMV_OK󣬷ش + * @remarks ͨӿڿԽ豸ɼԭʼͼתûظʽָڴСýӿڵ޽ӿ˳ҪͼԴݾͿԽתȵMV_CC_GetOneFrameTimeoutMV_CC_RegisterImageCallBackExûصȡһ֡ͼݣȻͨýӿתʽ豸ǰɼͼJPEGѹĸʽֵ֧øýӿڽת \n + + * @~english + * @brief Pixel format conversion + * @param handle [IN] Device handle + * @param pstCvtParam [IN][OUT] Convert Pixel Type parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API is used to transform the collected original data to pixel format and save to specified memory. There is no order requirement to call this API, the transformation will execute when there is image data. First call MV_CC_GetOneFrameTimeout or MV_CC_RegisterImageCallBackEx to set callback function, and get a frame of image data, then call this API to transform the format. \n + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_ConvertPixelType(IN void* handle, IN OUT MV_CC_PIXEL_CONVERT_PARAM* pstCvtParam); + +/********************************************************************//** + * @~chinese + * @brief òֵ㷨 + * @param handle [IN] 豸 + * @param nBayerCvtQuality [IN] BayerIJֵ 0- 1- 2-ţĬΪţ + * @return ɹMV_OK󣬷ش + * @remarks ڲͼתӿڵıֵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڲʹõIJֵ㷨Ǹýӿ趨ġ + + * @~english + * @brief Interpolation algorithm type setting + * @param handle [IN] Device handle + * @param nBayerCvtQuality [IN] Bayer interpolation method 0-Fast 1-Equilibrium 2-Optimal + * @return Success, return MV_OK. Failure, return error code + * @remarks Set the bell interpolation quality parameters of the internal image conversion interface, and the interpolation algorithm used in the MV CC ConvertPixelType and MV CC SaveImageEx2 interfaces is set by this interface. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBayerCvtQuality(IN void* handle, IN unsigned int nBayerCvtQuality); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵGammaֵ + * @param handle [IN] 豸 + * @param fBayerGammaValue [IN] Gammaֵ[0.1,4.0] + * @return ɹMV_OK󣬷ش + * @remarks øֵڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set Gamma value after Bayer interpolation + * @param handle [IN] Device handle + * @param fBayerGammaValue [IN] Gamma value[0.1,4.0] + * @return Success, return MV_OK. Failure, return error code + * @remarks After setting the value, it work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBayerGammaValue(IN void* handle, IN float fBayerGammaValue); + +/********************************************************************//** + * @~chinese + * @brief BayerʽֵɫУʹܺ; + * @param handle [IN] 豸 + * @param pstCCMParam [IN] ɫУṹ + * @return ɹMV_OK󣬷ش + * @remarks ɫУɫУڵMV_CC_ConvertPixelTypeMV_CC_SaveImageEx2ӿڽBayerʽתRGB24/BGR24/RGBA32/BGRA32ʱЧ + + * @~english + * @brief Set CCM param after Bayer interpolation + * @param handle [IN] Device handle + * @param pstCCMParam [IN] Color correction parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks After enable the color correction and set the color correction matrix, It work in the calling MV_CC_ConvertPixelType\MV_CC_SaveImageEx2 API convert Bayer to RGB24/BGR24/RGBA32/BGRA32. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBayerCCMParam(IN void* handle, IN MV_CC_CCM_PARAM* pstCCMParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstNoiseEstimateParam [IN][OUT] BayerƲṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Noise estimate of Bayer format + * @param handle [IN] Device handle + * @param pstNoiseEstimateParam [IN][OUT] Noise estimate parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_BayerNoiseEstimate(IN void* handle, IN OUT MV_CC_BAYER_NOISE_ESTIMATE_PARAM* pstNoiseEstimateParam); + +/********************************************************************//** + * @~chinese + * @brief Bayer + * @param handle [IN] 豸 + * @param pstSpatialDenoiseParam [IN][OUT] Bayerṹ + * @return ɹMV_OK󣬷ش + * @remarks ýӿֻ֧Bayer8/Bayer10/Bayer12ʽ,BayerʽתBayer8/Bayer10/Bayer12ʽ\n + ýӿֻڴ˾ضɫſʹãϿߵߺ󣬼ʹøýӿڻᱨ + + * @~english + * @brief Spatial Denoise of Bayer format + * @param handle [IN] Device handle + * @param pstSpatialDenoiseParam [IN][OUT] Spatial Denoise parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks This API only support Bayer8/Bayer10/Bayer12 format, other Bayer format must Convert to Bayer8/Bayer10/Bayer12 format.\n + This API is only available when the camera is turned on, and when the camera is disconnected or disconnected, continuing to use This API will return an error. + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_BayerSpatialDenoise(IN void* handle, IN OUT MV_CC_BAYER_SPATIAL_DENOISE_PARAM* pstSpatialDenoiseParam); + +/********************************************************************//** + * @~chinese + * @brief + * @param handle [IN] 豸 + * @param pstDecodeParam [IN][OUT] ṹ + * @return ɹMV_OK󣬷ش + * @remarks ȡѹݣͬʱֽ֧ǰʵʱͼˮӡϢǵǰ߲ʵʱȡģˮӡ쳣 + + * @~english + * @brief High Bandwidth Decode + * @param handle [IN] Device handle + * @param pstDecodeParam [IN][OUT] High Bandwidth Decode parameter structure + * @return Success, return MV_OK. Failure, return error code + * @remarks Decode the lossless compressed data from the camera into raw data + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_HB_Decode(IN void* handle, IN OUT MV_CC_HB_DECODE_PARAM* pstDecodeParam); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Save camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FeatureSave(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param strFileName [IN] ļ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Load camera feature + * @param handle [IN] Device handle + * @param strFileName [IN] File name + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FeatureLoad(IN void* handle, IN const char* strFileName); + +/********************************************************************//** + * @~chinese + * @brief 豸ȡļ + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Read the file from the camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FileAccessRead(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ļд豸 + * @param handle [IN] 豸 + * @param pstFileAccess [IN] ļȡṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Write the file to camera + * @param handle [IN] Device handle + * @param pstFileAccess [IN] File access structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_FileAccessWrite(IN void* handle, IN MV_CC_FILE_ACCESS * pstFileAccess); + +/********************************************************************//** + * @~chinese + * @brief ȡļȡĽ + * @param handle [IN] 豸 + * @param pstFileAccessProgress [IN] + * @return ɹMV_OK󣬷ش ǰļȡ״̬ + + * @~english + * @brief Get File Access Progress + * @param handle [IN] Device handle + * @param pstFileAccessProgress [IN] File access Progress + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFileAccessProgress(IN void* handle, OUT MV_CC_FILE_ACCESS_PROGRESS * pstFileAccessProgress); + +/********************************************************************//** + * @~chinese + * @brief ʼ¼ + * @param handle [IN] 豸 + * @param pstRecordParam [IN] ¼ṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Start Record + * @param handle [IN] Device handle + * @param pstRecordParam [IN] Record param structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StartRecord(IN void* handle, IN MV_CC_RECORD_PARAM* pstRecordParam); + +/********************************************************************//** + * @~chinese + * @brief ¼ + * @param handle [IN] 豸 + * @param pstInputFrameInfo [IN] ¼ݽṹ + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Input RAW data to Record + * @param handle [IN] Device handle + * @param pstInputFrameInfo [IN] Record data structure + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_InputOneFrame(IN void* handle, IN MV_CC_INPUT_FRAME_INFO * pstInputFrameInfo); + +/********************************************************************//** + * @~chinese + * @brief ֹͣ¼ + * @param handle [IN] 豸 + * @return ɹMV_OK󣬷ش + + * @~english + * @brief Stop Record + * @param handle [IN] Device handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_StopRecord(IN void* handle); + + +/************************************************************************/ +/* ʹõĽӿ */ +/* Interfaces not recommended */ +/************************************************************************/ +/************************************************************************ + * @fn MV_CC_GetImageInfo + * @brief ȡͼϢ + * @param handle [IN] 豸 + * @param pstInfo [IN][OUT] ظйͼϢṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MV_CC_GetImageInfo + * @brief Get basic information of image + * @param handle [IN] Device handle + * @param pstInfo [IN][OUT] Structure pointer of image basic information + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetImageInfo(IN void* handle, IN OUT MV_IMAGE_BASIC_INFO* pstInfo); + +/************************************************************************ + * @fn MV_CC_SetSDKLogPath() + * @brief SDK־·־MvLogServerãýӿЧĬ־Ϊ״̬ + * @param pSDKLogPath [IN] SDK־· + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SetSDKLogPath() + * @brief Set SDK log path + * @param pSDKLogPath [IN] SDK log path + * @return Access, return true. Not access, return false + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetSDKLogPath(IN const char * pSDKLogPath); + +/************************************************************************ + * @fn MV_CC_GetTlProxy + * @brief ȡGenICam + * @param handle [IN] ַ + * @return GenICamָ ֵNULL쳣NULL + + * @fn MV_CC_GetTlProxy + * @brief Get GenICam proxy + * @param handle [IN] Handle address + * @return GenICam proxy pointer, normal, return non-NULL; exception, return NULL + ************************************************************************/ +MVSDKEXPORT_API void* __stdcall MV_CC_GetTlProxy(IN void* handle); + +/*********************************************************************** + * @fn MV_XML_GetRootNode + * @brief ȡڵ + * @param handle [IN] + * @param pstNode [OUT] ڵϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetRootNode + * @brief Get root node + * @param handle [IN] Handle + * @param pstNode [OUT] Root node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetRootNode(IN void* handle, IN OUT MV_XML_NODE_FEATURE* pstNode); + +/*********************************************************************** + * @fn MV_XML_GetChildren + * @brief xmlлȡָڵӽڵ㣬ڵΪRoot + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstNodesList [OUT] ڵбṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetChildren + * @brief Get all children node of specific node from xml, root node is Root + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstNodesList [OUT] Node information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetChildren(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT MV_XML_NODES_LIST* pstNodesList); + +/*********************************************************************** + * @fn MV_XML_GetNodeFeature + * @brief õǰڵ + * @param handle [IN] + * @param pstNode [IN] ڵϢṹ + * @param pstFeature [OUT] ǰڵԽṹ壬 + pstFeature ṹݲο MV_XML_FEATURE_x + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_GetNodeFeature + * @brief Get current node feature + * @param handle [IN] Handle + * @param pstNode [IN] Root node information structure + * @param pstFeature [OUT] Current node feature structure + Details of pstFeature refer to MV_XML_FEATURE_x + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_GetNodeFeature(IN void* handle, IN MV_XML_NODE_FEATURE* pstNode, IN OUT void* pstFeature); + +/*********************************************************************** + * @fn MV_XML_UpdateNodeFeature + * @brief ½ڵ + * @param handle [IN] + * @param enType [IN] ڵ + * @param pstFeature [OUT] ǰڵԽṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_UpdateNodeFeature + * @brief Update node + * @param handle [IN] Handle + * @param enType [IN] Node type + * @param pstFeature [OUT] Current node feature structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_UpdateNodeFeature(IN void* handle, IN enum MV_XML_InterfaceType enType, IN void* pstFeature); + +// нڵҪʱĻص +// MV_XML_UpdateNodeFeatureӿڸ½ڵʱעĻصcbUpdatepstNodesListз֮Ľڵ +/*********************************************************************** + * @fn MV_XML_RegisterUpdateCallBack + * @brief ע»ص + * @param handle [IN] + * @param cbUpdate [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_XML_RegisterUpdateCallBack + * @brief Register update callback + * @param handle [IN] Handle + * @param cbUpdate [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_XML_RegisterUpdateCallBack(IN void* handle, + IN void(__stdcall* cbUpdate)(enum MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser), + IN void* pUser); + +/************************************************************************/ +/* õĽӿڣڸŻĽӿڿ滻 */ +/* Abandoned interface */ +/************************************************************************/ +/*********************************************************************** + * @fn MV_CC_GetOneFrame + * @brief ȡһ֡ͼ񣬴˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrame + * @brief Get one frame data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOneFrame(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_GetOneFrameEx + * @brief ȡһ֡trunckݣ˺Ϊѯʽȡÿεòѯڲ + ݣΧݣݷش + ýӿã MV_CC_GetOneFrameTimeOutӿڣ + * @param handle [IN] + * @param pData [OUT] ͼݽָ + * @param nDataSize [IN] ջС + * @param pFrameInfo [OUT] ͼϢṹ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_GetOneFrameEx + * @brief Get one frame of trunck data, this function is using query to get data, + query whether the internal cache has data, return data if there has, return error code if no data + (This interface is abandoned, it is recommended to use the MV_CC_GetOneFrameTimeOut) + * @param handle [IN] Handle + * @param pData [OUT] Recevied image data pointer + * @param nDataSize [IN] Recevied buffer size + * @param pFrameInfo [OUT] Image information structure + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetOneFrameEx(IN void* handle, IN OUT unsigned char * pData , IN unsigned int nDataSize, IN OUT MV_FRAME_OUT_INFO_EX* pFrameInfo); + +/*********************************************************************** + * @fn MV_CC_RegisterImageCallBack + * @brief עͼݻصýӿã MV_CC_RegisterImageCallBackExӿڣ + * @param handle [IN] + * @param cbOutput [IN] صָ + * @param pUser [IN] ûԶ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_RegisterImageCallBack + * @brief Register image data callback (This interface is abandoned, it is recommended to use the MV_CC_RegisterImageCallBackEx) + * @param handle [IN] Handle + * @param cbOutput [IN] Callback function pointer + * @param pUser [IN] User defined variable + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterImageCallBack(void* handle, + void(__stdcall* cbOutput)(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser), + void* pUser); + +/************************************************************************ + * @fn MV_CC_SaveImage + * @brief ͼƬýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImage + * @brief Save image (This interface is abandoned, it is recommended to use the MV_CC_SaveImageEx) + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Input data pixel format + nWidth; // [IN] Width + nHeight; // [IN] Height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Provided output buffer size + enImageType; // [IN] Output image type + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImage(IN OUT MV_SAVE_IMAGE_PARAM* pSaveParam); + +/************************************************************************ + * @fn MV_CC_SaveImageEx + * @brief ͼƬ֧BmpJpeg.50-99֮ǰ ýӿã MV_CC_SaveImageEx2ӿڣ + * @param pSaveParam [IN][OUT] ͼƬṹ + pData; // [IN] ݻ + nDataLen; // [IN] ݴС + enPixelType; // [IN] ݵظʽ + nWidth; // [IN] ͼ + nHeight; // [IN] ͼ + pImageBuffer; // [OUT] ͼƬ + nImageLen; // [OUT] ͼƬС + nBufferSize; // [IN] ṩС + enImageType; // [IN] ͼƬʽ + nJpgQuality; // [IN] , (50-99] + nReserved[4]; + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_SaveImageEx + * @brief Save image, support Bmp and Jpeg. Encoding quality, (50-99] + * @param pSaveParam [IN][OUT] Save image parameters structure + pData; // [IN] Input data buffer + nDataLen; // [IN] Input data size + enPixelType; // [IN] Pixel format of input data + nWidth; // [IN] Image width + nHeight; // [IN] Image height + pImageBuffer; // [OUT] Output image buffer + nImageLen; // [OUT] Output image size + nBufferSize; // [IN] Output buffer size provided + enImageType; // [IN] Output image format + nJpgQuality; // [IN] Encoding quality, (50-99] + nReserved[4]; + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SaveImageEx(IN OUT MV_SAVE_IMAGE_PARAM_EX* pSaveParam); + +/************************************************************************ + * @fn MV_GIGE_ForceIp + * @brief ǿIPýӿã MV_GIGE_ForceIpExӿڣ + * @param handle豸 + * @param nIP [IN] õIP + * @return ش + + * @fn MV_GIGE_ForceIp + * @brief Force IP (This interface is abandoned, it is recommended to use the MV_GIGE_ForceIpEx) + * @param handle Handle + * @param nIP [IN] IP to set + * @return Refer to error code +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_ForceIp(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MV_CC_RegisterEventCallBack + * @brief ע¼صýӿã MV_CC_RegisterEventCallBackExӿڣ + * @param handle豸 + * @param cbEvent [IN] ¼صָ + * @param pUser [IN] ûԶ + * @return ش + + * @fn MV_CC_RegisterEventCallBack + * @brief Register event callback (this interface has been deprecated and is recommended to be converted to the MV_CC_RegisterEventCallBackEx interface) + * @param handle豸 + * @param cbEvent [IN] event callback pointer + * @param pUser [IN] User defined value + * @return ش +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_RegisterEventCallBack(void* handle, void(__stdcall* cbEvent)(unsigned int nExternalEventId, void* pUser), void* pUser); + +/*********************************************************************** + * @fn MV_CC_Display + * @brief ʾͼעʾڣڲԶʾMV_CC_GetImageBufferͬʱʹãMV_CC_DisplayOneFrameӿڣ + * @param handle [IN] + * @param hWnd [IN] ʾھ + * @return ɹMV_OK󣬷ش + + * @fn MV_CC_Display + * @brief Display one frame image, register display window, automatic display internally + * @param handle [IN] Handle + * @param hWnd [IN] Display Window Handle + * @return Success, return MV_OK. Failure, return error code + ***********************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_Display(IN void* handle, void* hWnd); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief ȡIntegerֵMV_CC_GetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйԽṹָ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetIntValue(IN void* handle, + IN const char* strKey, + OUT MVCC_INTVALUE *pIntValue); + * @brief Get Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to get width + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of camera features + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetIntValue(IN void* handle,IN const char* strKey,OUT MVCC_INTVALUE *pIntValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief IntegerֵMV_CC_SetIntValueExӿڣ + * @param void* handle [IN] + * @param char* strKey [IN] ԼֵȡϢΪ"Width" + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetIntValue(IN void* handle, + IN const char* strKey, + IN unsigned int nValue); + * @brief Set Integer value + * @param void* handle [IN] Handle + * @param char* strKey [IN] Key value, for example, using "Width" to set width + * const unsigned int nValue [IN] Feature value to set + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetIntValue(IN void* handle,IN const char* strKey,IN unsigned int nValue); + + +/************************************************************************/ +/* ȡãģнӿѷʹܽӿڴ */ +/* Get and set camara parameters, all interfaces of this module will be replaced by general interface*/ +/************************************************************************/ +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȵϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰĿֵ + * unsigned int nMax; // ʾõĿֵ + * unsigned int nMin; // ʾСõĿֵ + * unsigned int nInc; // ʾõĿnIncıЧ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image width + * @param void* handle [IN] Camera Handle + * MVCC_INTVALUE* pstValue [IN][OUT] Returns the information structure pointer about the camera's width for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // Represents the current width value of the camera + * unsigned int nMax; // Indicates the maximum settable width value allowed by the camera + * unsigned int nMin; // Indicates the minimum settable width value allowed by the camera + * unsigned int nInc; // Indicates that the width increment set by the camera must be a multiple of nInc, otherwise it is invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other Integer structure parameters interface can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetWidth(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ +* @fn MVSDKEXPORT_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); +* @brief ͼ +* @param void* handle [IN] +* const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ +* @return ɹ,MV_OK,ȽΪӦֵʧ,ش + +* @fn MVSDKEXPORT_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + * @brief Set image width + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] To set the value of the camera width, note that the width value must be a multiple of nInc in the pstValue returned by the MV_CC_GetWidth interface + * @return Success, return MV_OK, and the camera width will change to the corresponding value. Failure, return error code +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetWidth(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ߶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظй߶ȵϢṹָ + * @return ɹ,MV_OK,߶ϢصṹУʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image height + * @param void* handle [IN] Camera handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera height to user + * @return Success, return MV_OK, and return height information to the structure. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetHeight(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief ͼ߶ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõȵֵ,ע˿ֵMV_CC_GetWidthӿڷصpstValueеnIncıóɹ + * @return ɹ,MV_OK,߶ȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + * @brief Set image height + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera height value to set, note that this value must be times of nInc of pstValue returned by MV_CC_GetWidth + * @return Success, return MV_OK, and the camera height will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetHeight(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼXƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйXƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image X offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera X offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetX(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief Set image X offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera X offset value to set + * @return Success, return MV_OK, and the camera X offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼYƫ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйYƫƵϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get image Y offset + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera Y offset to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAOIoffsetY(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetX(IN void* handle, IN const unsigned int nValue); + * @brief ͼAOIƫ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõAOIֵ + * @return ɹ,MV_OK,AOIƫƽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + * @brief Set image Y offset + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Camera Y offset value to set + * @return Success, return MV_OK, and the camera Y offset will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAOIoffsetY(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure lower limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure lower to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeLower(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure lower limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure lower to set + * @return Success, return MV_OK, and the camera exposure time lower limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeLower(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡع + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйعֵ޽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get exposure upper limit + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera exposure upper to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAutoExposureTimeUpper(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief عֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõعֵ + * @return ɹ,MV_OK,ع޽ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + * @brief Set exposure upper limit + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Exposure upper to set + * @return Success, return MV_OK, and the camera exposure time upper limit value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAutoExposureTimeUpper(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡֵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get brightness + * @param void* handle [IN] Camera Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera brightness to user + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBrightness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief ֵ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõֵ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + * @brief Set brightness + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] Brightness upper to set + * @return Success, return MV_OK, and the camera brightness value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBrightness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ֡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظй֡ʵϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Frame Rate + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to camera frame rate to user + * The meaning of returns pstValue structure + * float fCurValue; // Indicates the current frame rate of the camera + * float fMax; // Indicates the maximum frame rate allowed by the camera + * float fMin; // Indicates the minimum frame rate allowed by the camera + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFrameRate(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + * @brief Set frame rate + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Camera frame rate to set + * @return Success, return MV_OK, and camera frame rate will be changed to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetFrameRate(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gain + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to gain to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current gain + * float fMax; // The maximum gain camera allowed + * float fMin; // The minimum gain camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGain(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief ֡ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + * @brief Set Gain + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Gain value to set + * @return Success, return MV_OK, and the camera gain value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGain(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡعʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйعʱϢṹָ + * صpstValueṹ + * float fCurValue; // ʾǰ֡ + * float fMax; // ʾõ֡ + * float fMin; // ʾõС֡ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ͽṹĽӿڿɲմ˽ӿ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get exposure time + * @param void* handle [IN] Camera Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Return pointer of information structure related to exposure time to user + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * float fCurValue; // Camera current exposure time + * float fMax; // The maximum exposure time camera allowed + * float fMin; // The minimum exposure time camera allowed + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Other interface of Float structure parameters can refer to this interface + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetExposureTime(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief عʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõ֡ + * @return ɹ,MV_OK,֡ʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + * @brief Set exposure time + * @param void* handle [IN] Camera Handle + * const float fValue [IN] Exposure time to set + * @return Success, return MV_OK, and the camera exposure time value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetExposureTime(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡظʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйظʽϢṹָ + * صpstValueṹ + * unsigned int nCurValue; // ǰظʽö,˵PixelType_Gvsp_Mono8, õֵ,ֵPixelType.hMvGvspPixelTypeö + * unsigned int nSupportedNum; // ֵ֧ظʽĸ + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // ֵ֧ظʽӦֵбҪظʽʱеһ֣Ч + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + öͲӿڿɲմ˽ӿڣйӦöͶӦֵPixelType.h CameraParams.hӦĶ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Pixel Format + * @param void* handle [IN] Camera Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Returns the information structure pointer about pixel format for the caller + * The meaning of returns pstValue structure + * unsigned int nCurValue; // The current pixel format of the camera, is the enumeration type, such as PixelType_Gvsp_Mono8, here is the integer value, the specific value please refer to MvGvspPixelType enumeration type in PixelType.h + * unsigned int nSupportedNum; // Number of pixel formats supported by the camera + * unsigned int nSupportValue[MV_MAX_XML_SYMBOLIC_NUM]; // The integer values list correspond to all supported pixel formats of the camera, followed by when set the pixel format, the parameter must be one of this list, otherwise invalid + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Other interface of Enumeration structure parameters can refer to this interface, look for the corresponding definition in PixelType.h and CameraParams.h for the integer values of the enum type parameter + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetPixelFormat(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõظʽӦֵô˽ӿʱֱдöֵMV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return ɹ,MV_OK,ظʽΪӦֵʧ,ش + * + * ҪõöͱGetӿڷصnSupportValue[MV_MAX_XML_SYMBOLIC_NUM]еһ֣ʧ + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + * @brief Set Pixel Format + * @param void* handle [IN] Camera Handle + * const unsigned int nValue [IN] The corresponding integer value for pixel format to be set, when calling this interface can be directly filled in enumeration values, such as MV_CC_SetPixelFormat(m_handle, PixelType_Gvsp_RGB8_Packed); + * @return Success, return MV_OK, and the camera pixel format will change to the corresponding value. Failure, return error code + * + * Other interface of Enumeration structure parameters can refer to this interface, the enumeration type to be set must be one of the nSupportValue [MV_MAX_XML_SYMBOLIC_NUM] returned by the Get interface, otherwise it will fail + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetPixelFormat(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡɼģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйزɼģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_ACQUISITION_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get acquisition mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of acquisition mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_ACQUISITION_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief ظʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõIJɼģʽӦֵ + * @return ɹ,MV_OK,ɼģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + * @brief Set acquisition mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to acquisition mode + * @return Success, return MV_OK, and the camera acquisition mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAIN_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get gain mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gain mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAIN_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGainMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief ģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + * @brief Set gain mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gain mode + * @return Success, return MV_OK, and the camera gain mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGainMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶعģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶعģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_EXPOSURE_AUTO_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get auto exposure mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto exposure mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_EXPOSURE_AUTO_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetExposureAutoMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Զعģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶعģʽӦֵ + * @return ɹ,MV_OK,ԶعģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + * @brief Set auto exposure mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto exposure mode + * @return Success, return MV_OK, and the camera auto exposure mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetExposureAutoMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡģʽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشģʽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_MODE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_MODE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerMode(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief ôģʽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴģʽӦֵ + * @return ɹ,MV_OK,ģʽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger mode + * @return Success, return MV_OK, and the camera trigger mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerMode(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡʱ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйʱϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get tigger delay + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of trigger delay + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerDelay(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief ôʱ + * @param void* handle [IN] + * const float fValue [IN] Ҫõʱ + * @return ɹ,MV_OK,ʱΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + * @brief Set tigger delay + * @param void* handle [IN] Handle + * const float fValue [IN] Trigger delay to set + * @return Success, return MV_OK, and the camera trigger delay will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerDelay(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԴ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйشԴϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_TRIGGER_SOURCE + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get trigger source + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of trigger source + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_TRIGGER_SOURCE in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetTriggerSource(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief ôԴ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĴԴӦֵ + * @return ɹ,MV_OK,ԴΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + * @brief Set trigger source + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to trigger source + * @return Success, return MV_OK, and the camera trigger source will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetTriggerSource(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief һΣӿڽѡĴԴΪʱЧ + * @param void* handle [IN] + * @return ɹ,MV_OK, ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + * @brief Execute software trigger once (this interface only valid when the trigger source is set to software) + * @param void* handle [IN] Handle + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_TriggerSoftwareExecute(IN void* handle); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡGamma + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйGamma͵Ϣṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_GAMMA_SELECTOR + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Gamma mode + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of gamma mode + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_GAMMA_SELECTOR in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGammaSelector(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Gamma + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõGammaͶӦֵ + * @return ɹ,MV_OK,GammaͽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + * @brief Set Gamma mode + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to gamma mode + * @return Success, return MV_OK, and the camera gamma mode will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGammaSelector(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief ȡGammaֵ + * @param void* handle [IN] + * MVCC_FLOATVALUE* pstValue [IN][OUT] ظйGammaֵϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + * ɲսӿMV_CC_GetFrameRate + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + * @brief Get Gamma value + * @param void* handle [IN] Handle + * MVCC_FLOATVALUE* pstValue [IN][OUT] Structure pointer of gamma value + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + * Refer to MV_CC_GetFrameRate + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetGamma(IN void* handle, IN OUT MVCC_FLOATVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Gammaֵ + * @param void* handle [IN] + * const float fValue [IN] ҪõGammaֵ + * @return ɹ,MV_OK,GammaֵΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + * @brief Set Gamma value + * @param void* handle [IN] Handle + * const float fValue [IN] Gamma value to set + * @return Success, return MV_OK, and the camera gamma value will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetGamma(IN void* handle, IN const float fValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get sharpness + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of sharpness + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetSharpness(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõ + * @return ɹ,MV_OK,ȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + * @brief Set sharpness + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Sharpness to set + * @return Success, return MV_OK, and the camera sharpness will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetSharpness(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡҶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйҶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Hue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Hue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetHue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief ûҶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõĻҶ + * @return ɹ,MV_OK,ҶȽΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + * @brief Set Hue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Hue to set + * @return Success, return MV_OK, and the camera Hue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetHue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͶ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͶȽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get Saturation + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of Saturation + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetSaturation(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief ñͶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõıͶ + * @return ɹ,MV_OK,ͶȽΪӦֵʧ,ش + +* @fn MVSDKEXPORT_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + * @brief Set Saturation + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Saturation to set + * @return Success, return MV_OK, and the camera Saturation will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetSaturation(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief ȡԶƽ + * @param void* handle [IN] + * MVCC_ENUMVALUE* pstValue [IN][OUT] ظߵйԶƽϢṹָ + * @return ɹ,MV_OK,ӦϢĽṹ, ʧ, ش + * + ɲսӿMV_CC_GetPixelFormatο CameraParam.h е MV_CAM_BALANCEWHITE_AUTO + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + * @brief Get Auto white balance + * @param void* handle [IN] Handle + * MVCC_ENUMVALUE* pstValue [IN][OUT] Structure pointer of auto white balance + * @return Success, return MV_OK, and get the structure of the corresponding parameters. Failure, return error code + * + Refer to MV_CC_GetPixelFormat and definition of MV_CAM_BALANCEWHITE_AUTO in CameraParam.h + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceWhiteAuto(IN void* handle, IN OUT MVCC_ENUMVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Զƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõԶƽӦֵ + * @return ɹ,MV_OK,Զƽ⽫ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + * @brief Set Auto white balance + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Integer value to set corresponding to auto white balance + * @return Success, return MV_OK, and the camera auto white balance will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceWhiteAuto(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance red + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance red + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioRed(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ 콫ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance red + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance red to set + * @return Success, return MV_OK, and the camera white balance red will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioRed(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ̽ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance green + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance green + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioGreen(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ̽ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance green + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance green to set + * @return Success, return MV_OK, and the camera white balance green will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioGreen(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƽ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƽ ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get white balance blue + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of white balance blue + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBalanceRatioBlue(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief ðƽ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõİƽ + * @return ɹ,MV_OK,ƽ ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + * @brief Set white balance blue + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] White balance blue to set + * @return Success, return MV_OK, and the camera white balance blue will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBalanceRatioBlue(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡˮӡϢڰϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйˮӡϢڰϢͽṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get information type included by frame stamp + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of information type included by frame stamp + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetFrameSpecInfoAbility(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief ˮӡϢڰϢ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõˮӡϢڰϢ + * @return ɹ,MV_OK,ˮӡϢڰϢͻΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + * @brief Set information type included by frame stamp + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Information type included by frame stamp to set + * @return Success, return MV_OK, and the camera information type included by frame stamp will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetFrameSpecInfoAbility(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief ȡ豸Զ + * @param void* handle [IN] + * MVCC_STRINGVALUE* pstValue [IN OUT] ظйֽṹָ + * @return ɹ,MV_OK,һȡԶ֣ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + * @brief Get device user defined name + * @param void* handle [IN] Handle + * MVCC_STRINGVALUE* pstValue [IN OUT] Structure pointer of device name + * @return Success, return MV_OK, and get the camera user defined name. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetDeviceUserID(IN void* handle, IN OUT MVCC_STRINGVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief 豸Զ + * @param void* handle [IN] + * IN const char* chValue [IN] 豸 + * @return ɹ,MV_OK,豸Զ֣ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + * @brief Set device user defined name + * @param void* handle [IN] Handle + * IN const char* chValue [IN] Device name + * @return Success, return MV_OK, and set the camera user defined name. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetDeviceUserID(IN void* handle, IN const char* chValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡһδ֡ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйһδ֡ṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get frame number trigger by once + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of frame number trigger by once + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetBurstFrameCount(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief һδ֡ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõһδ֡ + * @return ɹ,MV_OK,һδ֡ΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + * @brief Set frame number trigger by once + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Frame number trigger by once to set + * @return Success, return MV_OK, and the camera frame number trigger by once will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetBurstFrameCount(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡƵ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйƵṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get line rate + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of line rate + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetAcquisitionLineRate(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Ƶ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõƵ + * @return ɹ,MV_OK,ƵΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + * @brief Set line rate + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Line rate to set + * @return Success, return MV_OK, and the camera line rate will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetAcquisitionLineRate(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡϢ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйϢṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get heartbeat information + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of heartbeat information + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_GetHeartBeatTimeout(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Ϣ + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõϢ + * @return ɹ,MV_OK,ϢΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + * @brief Set heartbeat information + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Heartbeat information to set + * @return Success, return MV_OK, and the camera heartbeat information will change to the corresponding value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CC_SetHeartBeatTimeout(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡС + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйСṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet size + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet size + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPSPacketSize(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief С + * @param void* handle [IN] + * const unsigned int nValue [IN] ҪõС + * @return ɹ,MV_OK,СΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet size + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet size to set + * @return Success, return MV_OK, and change packet size to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPSPacketSize(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief ȡͼ + * @param void* handle [IN] + * @param MVCC_INTVALUE* pstValue [IN][OUT] ظйͼṹָ + * @return ɹ,MV_OK,ʧ,ش + * + * ɲսӿMV_CC_GetWidth + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + * @brief Get network packet sending delay + * @param void* handle [IN] Handle + * @param MVCC_INTVALUE* pstValue [IN][OUT] Structure pointer of network packet sending delay + * @return Success, return MV_OK. Failure, return error code + * + * Refer to MV_CC_GetWidth + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCPD(IN void* handle, IN OUT MVCC_INTVALUE* pstValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief ͼ + * @param void* handle [IN] + * const unsigned int nValue [IN] Ҫõͼ + * @return ɹ,MV_OK,ͼΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + * @brief Set network packet sending delay + * @param void* handle [IN] Handle + * const unsigned int nValue [IN] Packet delay to set + * @return Success, return MV_OK, and change packet delay to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCPD(IN void* handle, IN const unsigned int nValue); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief ȡնIPַ0xa9fe0102 ʾ 169.254.1.2 + * @param void* handle [IN] + * @param unsigned int* pnIP [IN][OUT] ظ߽նIPַ + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + * @brief Get receiver IP address, 0xa9fe0102 indicates 169.254.1.2 + * @param void* handle [IN] Handle + * @param unsigned int* pnIP [IN][OUT] Receiver IP address + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCDA(IN void* handle, unsigned int* pnIP); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief ýնIPַ + * @param void* handle [IN] + * unsigned int nIP [IN] ҪõĽնIPַ + * @return ɹ,MV_OK,նIPַΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + * @brief Set receiver IP address + * @param void* handle [IN] Handel + * unsigned int nIP [IN] Receiver IP address to set + * @return Success, return MV_OK, and change receiver IP address to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCDA(IN void* handle, unsigned int nIP); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief ȡͶ˵Ķ˿ں + * @param void* handle [IN] + * @param unsigned int* pnPort [IN][OUT] ظ߷Ͷ˵Ķ˿ں + * @return ɹ,MV_OK,ʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + * @brief Get transmitter port number + * @param void* handle [IN] Handle + * @param unsigned int* pnPort [IN][OUT] Transmitter port number + * @return Success, return MV_OK. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_GetGevSCSP(IN void* handle, unsigned int* pnPort); + +/************************************************************************ + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief ÷Ͷ˵Ķ˿ں + * @param void* handle [IN] + * unsigned int nPort [IN] ҪõķͶ˵Ķ˿ں + * @return ɹ,MV_OK,Ͷ˵Ķ˿ںŻΪӦֵʧ,ش + + * @fn MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + * @brief Set transmitter port number + * @param void* handle [IN] Handle + * unsigned int nPort [IN] Transmitter port number to set + * @return Success, return MV_OK, and change transmitter port number to setting value. Failure, return error code + ************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_GIGE_SetGevSCSP(IN void* handle, unsigned int nPort); + +/********************************************************************//** + * @~chinese + * @brief 豸 + * @param handle [IN] 豸 + * @param nBaudrate [IN] õIJֵֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_SetDeviceBaudrateӿڣ + + * @~english + * @brief Set device baudrate using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param nBaudrate [IN] baud rate to set. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_SetDeviceBaudrate) +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_SetDeviceBauderate(IN void* handle, unsigned int nBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸 + * @param handle [IN] 豸 + * @param pnCurrentBaudrate [OUT] Ϣָ룬ֵοCameraParams.hк궨壬#define MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetDeviceBaudrateӿڣ + + * @~english + * @brief Returns the current device baudrate, using one of the CL_BAUDRATE_XXXX value + * @param handle [IN] Device handle + * @param pnCurrentBaudrate [OUT] Return pointer of baud rate to user. Refer to the 'CameraParams.h' for parameter definitions, for example, #define MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetDeviceBaudrate) +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetDeviceBauderate(IN void* handle,unsigned int* pnCurrentBaudrate); + +/********************************************************************//** + * @~chinese + * @brief ȡ豸ֵ֧IJ + * @param handle [IN] 豸 + * @param pnBaudrateAblity [OUT] ֵ֧IJϢָ롣ֲ֧ʵĻֵοCameraParams.hк궨壬MV_CAML_BAUDRATE_9600 0x00000001 + * @return ɹ,MV_OK,ʧ,ش + * @remarks ýӿã MV_CAML_GetSupportBaudratesӿڣ + + * @~english + * @brief Returns supported baudrates of the combined device and host interface + * @param handle [IN] Device handle + * @param pnBaudrateAblity [OUT] Return pointer of the supported baudrates to user. 'OR' operation results of the supported baudrates. Refer to the 'CameraParams.h' for single value definitions, for example, MV_CAML_BAUDRATE_9600 0x00000001 + * @return Success, return MV_OK. Failure, return error code + * @remarks (This interface is abandoned, it is recommended to use the MV_CAML_GetSupportBaudrates) +************************************************************************/ +MVSDKEXPORT_API int __stdcall MV_CAML_GetSupportBauderates(IN void* handle,unsigned int* pnBaudrateAblity); + +#ifdef __cplusplus +} +#endif + +#endif //_MV_SDK_EXPORT_H__ diff --git a/CigaretteSingle/MVS3.2.1/Include/ObsoleteCamParams.h b/CigaretteSingle/MVS3.2.1/Include/ObsoleteCamParams.h new file mode 100644 index 0000000..937a40f --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/ObsoleteCamParams.h @@ -0,0 +1,301 @@ + +#ifndef _MV_OBSOLETE_CAM_PARAMS_H_ +#define _MV_OBSOLETE_CAM_PARAMS_H_ + +#include "PixelType.h" + +/// \~chinese ֡Ϣ \~english Output Frame Information +typedef struct _MV_FRAME_OUT_INFO_ +{ + unsigned short nWidth; ///< [OUT] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [OUT] \~chinese ͼ \~english Image Height + enum MvGvspPixelType enPixelType; ///< [OUT] \~chinese ظʽ \~english Pixel Type + + unsigned int nFrameNum; ///< [OUT] \~chinese ֡ \~english Frame Number + unsigned int nDevTimeStampHigh; ///< [OUT] \~chinese ʱ32λ \~english Timestamp high 32 bits + unsigned int nDevTimeStampLow; ///< [OUT] \~chinese ʱ32λ \~english Timestamp low 32 bits + unsigned int nReserved0; ///< [OUT] \~chinese 8ֽڶ \~english Reserved, 8-byte aligned + int64_t nHostTimeStamp; ///< [OUT] \~chinese ɵʱ \~english Host-generated timestamp + + unsigned int nFrameLen; + + unsigned int nLostPacket; // ֡ + unsigned int nReserved[2]; +}MV_FRAME_OUT_INFO; + +/// \~chinese ͼƬ \~english Save image type +typedef struct _MV_SAVE_IMAGE_PARAM_T_ +{ + unsigned char* pData; ///< [IN] \~chinese ݻ \~english Input Data Buffer + unsigned int nDataLen; ///< [IN] \~chinese ݴС \~english Input Data Size + enum MvGvspPixelType enPixelType; ///< [IN] \~chinese ظʽ \~english Input Data Pixel Format + unsigned short nWidth; ///< [IN] \~chinese ͼ \~english Image Width + unsigned short nHeight; ///< [IN] \~chinese ͼ \~english Image Height + + unsigned char* pImageBuffer; ///< [OUT] \~chinese ͼƬ \~english Output Image Buffer + unsigned int nImageLen; ///< [OUT] \~chinese ͼƬС \~english Output Image Size + unsigned int nBufferSize; ///< [IN] \~chinese ṩС \~english Output buffer size provided + enum MV_SAVE_IAMGE_TYPE enImageType; ///< [IN] \~chinese ͼƬʽ \~english Output Image Format + +}MV_SAVE_IMAGE_PARAM; + +typedef struct _MV_IMAGE_BASIC_INFO_ +{ + unsigned short nWidthValue; + unsigned short nWidthMin; + unsigned int nWidthMax; + unsigned int nWidthInc; + + unsigned int nHeightValue; + unsigned int nHeightMin; + unsigned int nHeightMax; + unsigned int nHeightInc; + + float fFrameRateValue; + float fFrameRateMin; + float fFrameRateMax; + + unsigned int enPixelType; ///< [OUT] \~chinese ǰظʽ \~english Current pixel format + unsigned int nSupportedPixelFmtNum; ///< [OUT] \~chinese ֵ֧ظʽ \~english Support pixel format + unsigned int enPixelList[MV_MAX_XML_SYMBOLIC_NUM]; + unsigned int nReserved[8]; + +}MV_IMAGE_BASIC_INFO; + +/// \~chinese ijڵӦӽڵֵ \~english The maximum number of child nodes corresponding to a node +#define MV_MAX_XML_NODE_NUM_C 128 + +/// \~chinese ڵַ󳤶 \~english The maximum length of node name string +#define MV_MAX_XML_NODE_STRLEN_C 64 + +/// \~chinese ڵStringֵ󳤶 \~english The maximum length of Node String +#define MV_MAX_XML_STRVALUE_STRLEN_C 64 + +/// \~chinese ڵֶ󳤶 \~english The maximum length of the node description field +#define MV_MAX_XML_DISC_STRLEN_C 512 + +/// \~chinese ĵԪ \~english The maximum number of units +#define MV_MAX_XML_ENTRY_NUM 10 + +/// \~chinese ڵ \~english The maximum number of parent nodes +#define MV_MAX_XML_PARENTS_NUM 8 + +/// \~chinese ÿѾʵֵԪƳ \~english The length of the name of each unit that has been implemented +#define MV_MAX_XML_SYMBOLIC_STRLEN_C 64 + +enum MV_XML_Visibility +{ + V_Beginner = 0, ///< Always visible + V_Expert = 1, ///< Visible for experts or Gurus + V_Guru = 2, ///< Visible for Gurus + V_Invisible = 3, ///< Not Visible + V_Undefined = 99 ///< Object is not yet initialized +}; + +/// \~chinese ڵ | en:Single Node Basic Attributes +typedef struct _MV_XML_NODE_FEATURE_ +{ + enum MV_XML_InterfaceType enType; ///< \~chinese ڵ \~english Node Type + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Is visibility + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + unsigned int nReserved[4]; +}MV_XML_NODE_FEATURE; + +/// \~chinese ڵб | en:Node List +typedef struct _MV_XML_NODES_LIST_ +{ + unsigned int nNodeNum; ///< \~chinese ڵ \~english Node Number + MV_XML_NODE_FEATURE stNodes[MV_MAX_XML_NODE_NUM_C]; +}MV_XML_NODES_LIST; + +typedef struct _MV_XML_FEATURE_Value_ +{ + enum MV_XML_InterfaceType enType; ///< \~chinese ڵ \~english Node Type + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + unsigned int nReserved[4]; +}MV_XML_FEATURE_Value; + +typedef struct _MV_XML_FEATURE_Base_ +{ + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode +}MV_XML_FEATURE_Base; + +typedef struct _MV_XML_FEATURE_Integer_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + int64_t nMinValue; ///< \~chinese Сֵ \~english Min Value + int64_t nMaxValue; ///< \~chinese ֵ \~english Max Value + int64_t nIncrement; ///< \~chinese \~english Increment + + unsigned int nReserved[4]; + +}MV_XML_FEATURE_Integer; + +typedef struct _MV_XML_FEATURE_Boolean_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + bool bValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Boolean; + +typedef struct _MV_XML_FEATURE_Command_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Command; + +typedef struct _MV_XML_FEATURE_Float_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + double dfValue; ///< \~chinese ǰֵ \~english Current Value + double dfMinValue; ///< \~chinese Сֵ \~english Min Value + double dfMaxValue; ///< \~chinese ֵ \~english Max Value + double dfIncrement; ///< \~chinese \~english Increment + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Float; + +typedef struct _MV_XML_FEATURE_String_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + char strValue[MV_MAX_XML_STRVALUE_STRLEN_C]; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_String; + +typedef struct _MV_XML_FEATURE_Register_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nAddrValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Register; + +typedef struct _MV_XML_FEATURE_Category_ +{ + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Category; + +typedef struct _MV_XML_FEATURE_EnumEntry_ +{ + char strName[MV_MAX_XML_NODE_STRLEN_C]; + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese Ŀǰݲ֧ \~english NOT SUPPORT NOW + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; + int bIsImplemented; + int nParentsNum; + MV_XML_NODE_FEATURE stParentsList[MV_MAX_XML_PARENTS_NUM]; + + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int nReserved[8]; + +}MV_XML_FEATURE_EnumEntry; + +typedef struct _MV_XML_FEATURE_Enumeration_ +{ + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + int nSymbolicNum; ///< \~chinese ymbolic \~english Symbolic Number + char strCurrentSymbolic[MV_MAX_XML_SYMBOLIC_STRLEN_C];///< \~chinese ǰSymbolic \~english Current Symbolic Index + char strSymbolic[MV_MAX_XML_SYMBOLIC_NUM][MV_MAX_XML_SYMBOLIC_STRLEN_C]; + enum MV_XML_AccessMode enAccessMode; ////< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + int64_t nValue; ///< \~chinese ǰֵ \~english Current Value + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Enumeration; + +typedef struct _MV_XML_FEATURE_Port_ +{ + enum MV_XML_Visibility enVisivility; ///< \~chinese Ƿɼ \~english Visible + char strDescription[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ڵ,Ŀǰݲ֧ \~english Node Description, NOT SUPPORT NOW + char strDisplayName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ʾ \~english Display Name + char strName[MV_MAX_XML_NODE_STRLEN_C]; ///< \~chinese ڵ \~english Node Name + char strToolTip[MV_MAX_XML_DISC_STRLEN_C]; ///< \~chinese ʾ \~english Notice + + enum MV_XML_AccessMode enAccessMode; ///< \~chinese ģʽ \~english Access Mode + int bIsLocked; ///< \~chinese Ƿ0-1-,Ŀǰݲ֧ \~english Locked. 0-NO; 1-YES, NOT SUPPORT NOW + + unsigned int nReserved[4]; +}MV_XML_FEATURE_Port; + +typedef struct _MV_XML_CAMERA_FEATURE_ +{ + enum MV_XML_InterfaceType enType; + union + { + MV_XML_FEATURE_Integer stIntegerFeature; + MV_XML_FEATURE_Float stFloatFeature; + MV_XML_FEATURE_Enumeration stEnumerationFeature; + MV_XML_FEATURE_String stStringFeature; + }SpecialFeature; + +}MV_XML_CAMERA_FEATURE; + +#endif /* _MV_OBSOLETE_CAM_PARAMS_H_ */ diff --git a/CigaretteSingle/MVS3.2.1/Include/PixelType.h b/CigaretteSingle/MVS3.2.1/Include/PixelType.h new file mode 100644 index 0000000..95ae41a --- /dev/null +++ b/CigaretteSingle/MVS3.2.1/Include/PixelType.h @@ -0,0 +1,178 @@ + +#ifndef _MV_PIXEL_TYPE_H_ +#define _MV_PIXEL_TYPE_H_ + +/************************************************************************/ +/* GigE Vision (2.0.03) PIXEL FORMATS */ +/************************************************************************/ + +// Indicate if pixel is monochrome or RGB +#define MV_GVSP_PIX_MONO 0x01000000 +#define MV_GVSP_PIX_RGB 0x02000000 // deprecated in version 1.1 +#define MV_GVSP_PIX_COLOR 0x02000000 +#define MV_GVSP_PIX_CUSTOM 0x80000000 +#define MV_GVSP_PIX_COLOR_MASK 0xFF000000 + +// Indicate effective number of bits occupied by the pixel (including padding). +// This can be used to compute amount of memory required to store an image. +#define MV_PIXEL_BIT_COUNT(n) ((n) << 16) + +#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_MASK 0x00FF0000 +#define MV_GVSP_PIX_EFFECTIVE_PIXEL_SIZE_SHIFT 16 + +// Pixel ID: lower 16-bit of the pixel formats +#define MV_GVSP_PIX_ID_MASK 0x0000FFFF +#define MV_GVSP_PIX_COUNT 0x46 // next Pixel ID available + +enum MvGvspPixelType +{ + // Undefined pixel type + PixelType_Gvsp_Undefined = 0xFFFFFFFF, + + // Mono buffer format defines + PixelType_Gvsp_Mono1p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(1) | 0x0037), + PixelType_Gvsp_Mono2p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(2) | 0x0038), + PixelType_Gvsp_Mono4p = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(4) | 0x0039), + PixelType_Gvsp_Mono8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), + PixelType_Gvsp_Mono8_Signed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0002), + PixelType_Gvsp_Mono10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), + PixelType_Gvsp_Mono10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), + PixelType_Gvsp_Mono12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), + PixelType_Gvsp_Mono12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), + PixelType_Gvsp_Mono14 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0025), + PixelType_Gvsp_Mono16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), + + // Bayer buffer format defines + PixelType_Gvsp_BayerGR8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), + PixelType_Gvsp_BayerRG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), + PixelType_Gvsp_BayerGB8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), + PixelType_Gvsp_BayerBG8 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), + PixelType_Gvsp_BayerGR10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), + PixelType_Gvsp_BayerRG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), + PixelType_Gvsp_BayerGB10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), + PixelType_Gvsp_BayerBG10 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), + PixelType_Gvsp_BayerGR12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), + PixelType_Gvsp_BayerRG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), + PixelType_Gvsp_BayerGB12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), + PixelType_Gvsp_BayerBG12 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), + PixelType_Gvsp_BayerGR10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), + PixelType_Gvsp_BayerRG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), + PixelType_Gvsp_BayerGB10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), + PixelType_Gvsp_BayerBG10_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), + PixelType_Gvsp_BayerGR12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), + PixelType_Gvsp_BayerRG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), + PixelType_Gvsp_BayerGB12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), + PixelType_Gvsp_BayerBG12_Packed = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), + PixelType_Gvsp_BayerGR16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002E), + PixelType_Gvsp_BayerRG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002F), + PixelType_Gvsp_BayerGB16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0030), + PixelType_Gvsp_BayerBG16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0031), + + // RGB Packed buffer format defines + PixelType_Gvsp_RGB8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), + PixelType_Gvsp_BGR8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), + PixelType_Gvsp_RGBA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), + PixelType_Gvsp_BGRA8_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), + PixelType_Gvsp_RGB10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0018), + PixelType_Gvsp_BGR10_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0019), + PixelType_Gvsp_RGB12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001A), + PixelType_Gvsp_BGR12_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001B), + PixelType_Gvsp_RGB16_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033), + PixelType_Gvsp_RGB10V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001C), + PixelType_Gvsp_RGB10V2_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001D), + PixelType_Gvsp_RGB12V1_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(36) | 0X0034), + PixelType_Gvsp_RGB565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0035), + PixelType_Gvsp_BGR565_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0X0036), + + // YUV Packed buffer format defines + PixelType_Gvsp_YUV411_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x001E), + PixelType_Gvsp_YUV422_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), + PixelType_Gvsp_YUV422_YUYV_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), + PixelType_Gvsp_YUV444_Packed = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0020), + PixelType_Gvsp_YCBCR8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003A), + PixelType_Gvsp_YCBCR422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003B), + PixelType_Gvsp_YCBCR422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0043), + PixelType_Gvsp_YCBCR411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003C), + PixelType_Gvsp_YCBCR601_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003D), + PixelType_Gvsp_YCBCR601_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003E), + PixelType_Gvsp_YCBCR601_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0044), + PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003F), + PixelType_Gvsp_YCBCR709_8_CBYCR = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0040), + PixelType_Gvsp_YCBCR709_422_8 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0041), + PixelType_Gvsp_YCBCR709_422_8_CBYCRY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0045), + PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x0042), + + // RGB Planar buffer format defines + PixelType_Gvsp_RGB8_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0021), + PixelType_Gvsp_RGB10_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0022), + PixelType_Gvsp_RGB12_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0023), + PixelType_Gvsp_RGB16_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0024), + + // ԶͼƬʽ + PixelType_Gvsp_Jpeg = (MV_GVSP_PIX_CUSTOM | MV_PIXEL_BIT_COUNT(24) | 0x0001), + + PixelType_Gvsp_Coord3D_ABC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C0),//0x026000C0 + PixelType_Gvsp_Coord3D_ABC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x00C1),//0x026000C1 + + // ֵοPixelType_Gvsp_Coord3D_AC32f_64; the value is discarded + PixelType_Gvsp_Coord3D_AC32f = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(40) | 0x00C2), + // ֵ; the value is discarded (ѷChunkdata) + PixelType_Gvsp_COORD3D_DEPTH_PLUS_MASK = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(28) | 0x0001), + + PixelType_Gvsp_Coord3D_ABC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(96) | 0x3001),//0x82603001 + PixelType_Gvsp_Coord3D_AB32f = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3002),//0x82403002 + PixelType_Gvsp_Coord3D_AB32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3003),//0x82403003 + PixelType_Gvsp_Coord3D_AC32f_64 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C2),//0x024000C2 + PixelType_Gvsp_Coord3D_AC32f_Planar = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x00C3),//0x024000C3 + PixelType_Gvsp_Coord3D_AC32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(64) | 0x3004),//0x82403004 + PixelType_Gvsp_Coord3D_A32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BD),//0x012000BD + PixelType_Gvsp_Coord3D_A32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3005),//0x81203005 + PixelType_Gvsp_Coord3D_C32f = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x00BF),//0x012000BF + PixelType_Gvsp_Coord3D_C32 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(32) | 0x3006),//0x81203006 + PixelType_Gvsp_Coord3D_ABC16 = (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x00B9),//0x023000B9 + PixelType_Gvsp_Coord3D_C16 = (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x00B8),//0x011000B8 + + //ѹظʽ + PixelType_Gvsp_HB_Mono8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001), + PixelType_Gvsp_HB_Mono10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003), + PixelType_Gvsp_HB_Mono10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004), + PixelType_Gvsp_HB_Mono12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005), + PixelType_Gvsp_HB_Mono12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006), + PixelType_Gvsp_HB_Mono16 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007), + PixelType_Gvsp_HB_BayerGR8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008), + PixelType_Gvsp_HB_BayerRG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009), + PixelType_Gvsp_HB_BayerGB8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A), + PixelType_Gvsp_HB_BayerBG8 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B), + PixelType_Gvsp_HB_BayerGR10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C), + PixelType_Gvsp_HB_BayerRG10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D), + PixelType_Gvsp_HB_BayerGB10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E), + PixelType_Gvsp_HB_BayerBG10 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F), + PixelType_Gvsp_HB_BayerGR12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010), + PixelType_Gvsp_HB_BayerRG12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011), + PixelType_Gvsp_HB_BayerGB12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012), + PixelType_Gvsp_HB_BayerBG12 = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013), + PixelType_Gvsp_HB_BayerGR10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026), + PixelType_Gvsp_HB_BayerRG10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027), + PixelType_Gvsp_HB_BayerGB10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028), + PixelType_Gvsp_HB_BayerBG10_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029), + PixelType_Gvsp_HB_BayerGR12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A), + PixelType_Gvsp_HB_BayerRG12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B), + PixelType_Gvsp_HB_BayerGB12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C), + PixelType_Gvsp_HB_BayerBG12_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D), + PixelType_Gvsp_HB_YUV422_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F), + PixelType_Gvsp_HB_YUV422_YUYV_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032), + PixelType_Gvsp_HB_RGB8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014), + PixelType_Gvsp_HB_BGR8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015), + PixelType_Gvsp_HB_RGBA8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016), + PixelType_Gvsp_HB_BGRA8_Packed = (MV_GVSP_PIX_CUSTOM | MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017), + +}; + +#ifdef WIN32 +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +#endif /* _MV_PIXEL_TYPE_H_ */ diff --git a/CigaretteSingle/MVS3.2.1/lib/win32/C++ Builder/MvCameraControlBC.lib b/CigaretteSingle/MVS3.2.1/lib/win32/C++ Builder/MvCameraControlBC.lib new file mode 100644 index 0000000..8f77d05 Binary files /dev/null and b/CigaretteSingle/MVS3.2.1/lib/win32/C++ Builder/MvCameraControlBC.lib differ diff --git a/CigaretteSingle/MVS3.2.1/lib/win32/MvCameraControl.lib b/CigaretteSingle/MVS3.2.1/lib/win32/MvCameraControl.lib new file mode 100644 index 0000000..7a8b5ff Binary files /dev/null and b/CigaretteSingle/MVS3.2.1/lib/win32/MvCameraControl.lib differ diff --git a/CigaretteSingle/MVS3.2.1/lib/win32/VC6/MvSdkExport.lib b/CigaretteSingle/MVS3.2.1/lib/win32/VC6/MvSdkExport.lib new file mode 100644 index 0000000..0672c18 Binary files /dev/null and b/CigaretteSingle/MVS3.2.1/lib/win32/VC6/MvSdkExport.lib differ diff --git a/CigaretteSingle/MVS3.2.1/lib/win64/C++ Builder/MvCameraControlBC.a b/CigaretteSingle/MVS3.2.1/lib/win64/C++ Builder/MvCameraControlBC.a new file mode 100644 index 0000000..a8ac039 Binary files /dev/null and b/CigaretteSingle/MVS3.2.1/lib/win64/C++ Builder/MvCameraControlBC.a differ diff --git a/CigaretteSingle/MVS3.2.1/lib/win64/MvCameraControl.lib b/CigaretteSingle/MVS3.2.1/lib/win64/MvCameraControl.lib new file mode 100644 index 0000000..97017f4 Binary files /dev/null and b/CigaretteSingle/MVS3.2.1/lib/win64/MvCameraControl.lib differ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d.hpp new file mode 100644 index 0000000..b3709c8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d.hpp @@ -0,0 +1,4024 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CALIB3D_HPP +#define OPENCV_CALIB3D_HPP + +#include "opencv2/core.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/core/affine.hpp" + +/** + @defgroup calib3d Camera Calibration and 3D Reconstruction + +The functions in this section use a so-called pinhole camera model. The view of a scene +is obtained by projecting a scene's 3D point \f$P_w\f$ into the image plane using a perspective +transformation which forms the corresponding pixel \f$p\f$. Both \f$P_w\f$ and \f$p\f$ are +represented in homogeneous coordinates, i.e. as 3D and 2D homogeneous vector respectively. You will +find a brief introduction to projective geometry, homogeneous vectors and homogeneous +transformations at the end of this section's introduction. For more succinct notation, we often drop +the 'homogeneous' and say vector instead of homogeneous vector. + +The distortion-free projective transformation given by a pinhole camera model is shown below. + +\f[s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w,\f] + +where \f$P_w\f$ is a 3D point expressed with respect to the world coordinate system, +\f$p\f$ is a 2D pixel in the image plane, \f$A\f$ is the camera intrinsic matrix, +\f$R\f$ and \f$t\f$ are the rotation and translation that describe the change of coordinates from +world to camera coordinate systems (or camera frame) and \f$s\f$ is the projective transformation's +arbitrary scaling and not part of the camera model. + +The camera intrinsic matrix \f$A\f$ (notation used as in @cite Zhang2000 and also generally notated +as \f$K\f$) projects 3D points given in the camera coordinate system to 2D pixel coordinates, i.e. + +\f[p = A P_c.\f] + +The camera intrinsic matrix \f$A\f$ is composed of the focal lengths \f$f_x\f$ and \f$f_y\f$, which are +expressed in pixel units, and the principal point \f$(c_x, c_y)\f$, that is usually close to the +image center: + +\f[A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1},\f] + +and thus + +\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} \vecthree{X_c}{Y_c}{Z_c}.\f] + +The matrix of intrinsic parameters does not depend on the scene viewed. So, once estimated, it can +be re-used as long as the focal length is fixed (in case of a zoom lens). Thus, if an image from the +camera is scaled by a factor, all of these parameters need to be scaled (multiplied/divided, +respectively) by the same factor. + +The joint rotation-translation matrix \f$[R|t]\f$ is the matrix product of a projective +transformation and a homogeneous transformation. The 3-by-4 projective transformation maps 3D points +represented in camera coordinates to 2D points in the image plane and represented in normalized +camera coordinates \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$: + +\f[Z_c \begin{bmatrix} +x' \\ +y' \\ +1 +\end{bmatrix} = \begin{bmatrix} +1 & 0 & 0 & 0 \\ +0 & 1 & 0 & 0 \\ +0 & 0 & 1 & 0 +\end{bmatrix} +\begin{bmatrix} +X_c \\ +Y_c \\ +Z_c \\ +1 +\end{bmatrix}.\f] + +The homogeneous transformation is encoded by the extrinsic parameters \f$R\f$ and \f$t\f$ and +represents the change of basis from world coordinate system \f$w\f$ to the camera coordinate sytem +\f$c\f$. Thus, given the representation of the point \f$P\f$ in world coordinates, \f$P_w\f$, we +obtain \f$P\f$'s representation in the camera coordinate system, \f$P_c\f$, by + +\f[P_c = \begin{bmatrix} +R & t \\ +0 & 1 +\end{bmatrix} P_w,\f] + +This homogeneous transformation is composed out of \f$R\f$, a 3-by-3 rotation matrix, and \f$t\f$, a +3-by-1 translation vector: + +\f[\begin{bmatrix} +R & t \\ +0 & 1 +\end{bmatrix} = \begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z \\ +0 & 0 & 0 & 1 +\end{bmatrix}, +\f] + +and therefore + +\f[\begin{bmatrix} +X_c \\ +Y_c \\ +Z_c \\ +1 +\end{bmatrix} = \begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z \\ +0 & 0 & 0 & 1 +\end{bmatrix} +\begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix}.\f] + +Combining the projective transformation and the homogeneous transformation, we obtain the projective +transformation that maps 3D points in world coordinates into 2D points in the image plane and in +normalized camera coordinates: + +\f[Z_c \begin{bmatrix} +x' \\ +y' \\ +1 +\end{bmatrix} = \begin{bmatrix} R|t \end{bmatrix} \begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix} = \begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z +\end{bmatrix} +\begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix},\f] + +with \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$. Putting the equations for instrincs and extrinsics together, we can write out +\f$s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w\f$ as + +\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} +\begin{bmatrix} +r_{11} & r_{12} & r_{13} & t_x \\ +r_{21} & r_{22} & r_{23} & t_y \\ +r_{31} & r_{32} & r_{33} & t_z +\end{bmatrix} +\begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix}.\f] + +If \f$Z_c \ne 0\f$, the transformation above is equivalent to the following, + +\f[\begin{bmatrix} +u \\ +v +\end{bmatrix} = \begin{bmatrix} +f_x X_c/Z_c + c_x \\ +f_y Y_c/Z_c + c_y +\end{bmatrix}\f] + +with + +\f[\vecthree{X_c}{Y_c}{Z_c} = \begin{bmatrix} +R|t +\end{bmatrix} \begin{bmatrix} +X_w \\ +Y_w \\ +Z_w \\ +1 +\end{bmatrix}.\f] + +The following figure illustrates the pinhole camera model. + +![Pinhole camera model](pics/pinhole_camera_model.png) + +Real lenses usually have some distortion, mostly radial distortion, and slight tangential distortion. +So, the above model is extended as: + +\f[\begin{bmatrix} +u \\ +v +\end{bmatrix} = \begin{bmatrix} +f_x x'' + c_x \\ +f_y y'' + c_y +\end{bmatrix}\f] + +where + +\f[\begin{bmatrix} +x'' \\ +y'' +\end{bmatrix} = \begin{bmatrix} +x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + 2 p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4 \\ +y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\ +\end{bmatrix}\f] + +with + +\f[r^2 = x'^2 + y'^2\f] + +and + +\f[\begin{bmatrix} +x'\\ +y' +\end{bmatrix} = \begin{bmatrix} +X_c/Z_c \\ +Y_c/Z_c +\end{bmatrix},\f] + +if \f$Z_c \ne 0\f$. + +The distortion parameters are the radial coefficients \f$k_1\f$, \f$k_2\f$, \f$k_3\f$, \f$k_4\f$, \f$k_5\f$, and \f$k_6\f$ +,\f$p_1\f$ and \f$p_2\f$ are the tangential distortion coefficients, and \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, +are the thin prism distortion coefficients. Higher-order coefficients are not considered in OpenCV. + +The next figures show two common types of radial distortion: barrel distortion +(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing) +and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing). +Radial distortion is always monotonic for real lenses, +and if the estimator produces a non-monotonic result, +this should be considered a calibration failure. +More generally, radial distortion must be monotonic and the distortion function must be bijective. +A failed estimation result may look deceptively good near the image center +but will work poorly in e.g. AR/SFM applications. +The optimization method used in OpenCV camera calibration does not include these constraints as +the framework does not support the required integer programming and polynomial inequalities. +See [issue #15992](https://github.com/opencv/opencv/issues/15992) for additional information. + +![](pics/distortion_examples.png) +![](pics/distortion_examples2.png) + +In some cases, the image sensor may be tilted in order to focus an oblique plane in front of the +camera (Scheimpflug principle). This can be useful for particle image velocimetry (PIV) or +triangulation with a laser fan. The tilt causes a perspective distortion of \f$x''\f$ and +\f$y''\f$. This distortion can be modeled in the following way, see e.g. @cite Louhichi07. + +\f[\begin{bmatrix} +u \\ +v +\end{bmatrix} = \begin{bmatrix} +f_x x''' + c_x \\ +f_y y''' + c_y +\end{bmatrix},\f] + +where + +\f[s\vecthree{x'''}{y'''}{1} = +\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}(\tau_x, \tau_y)} +{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)} +{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\f] + +and the matrix \f$R(\tau_x, \tau_y)\f$ is defined by two rotations with angular parameter +\f$\tau_x\f$ and \f$\tau_y\f$, respectively, + +\f[ +R(\tau_x, \tau_y) = +\vecthreethree{\cos(\tau_y)}{0}{-\sin(\tau_y)}{0}{1}{0}{\sin(\tau_y)}{0}{\cos(\tau_y)} +\vecthreethree{1}{0}{0}{0}{\cos(\tau_x)}{\sin(\tau_x)}{0}{-\sin(\tau_x)}{\cos(\tau_x)} = +\vecthreethree{\cos(\tau_y)}{\sin(\tau_y)\sin(\tau_x)}{-\sin(\tau_y)\cos(\tau_x)} +{0}{\cos(\tau_x)}{\sin(\tau_x)} +{\sin(\tau_y)}{-\cos(\tau_y)\sin(\tau_x)}{\cos(\tau_y)\cos(\tau_x)}. +\f] + +In the functions below the coefficients are passed or returned as + +\f[(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f] + +vector. That is, if the vector contains four elements, it means that \f$k_3=0\f$ . The distortion +coefficients do not depend on the scene viewed. Thus, they also belong to the intrinsic camera +parameters. And they remain the same regardless of the captured image resolution. If, for example, a +camera has been calibrated on images of 320 x 240 resolution, absolutely the same distortion +coefficients can be used for 640 x 480 images from the same camera while \f$f_x\f$, \f$f_y\f$, +\f$c_x\f$, and \f$c_y\f$ need to be scaled appropriately. + +The functions below use the above model to do the following: + +- Project 3D points to the image plane given intrinsic and extrinsic parameters. +- Compute extrinsic parameters given intrinsic parameters, a few 3D points, and their +projections. +- Estimate intrinsic and extrinsic camera parameters from several views of a known calibration +pattern (every view is described by several 3D-2D point correspondences). +- Estimate the relative position and orientation of the stereo camera "heads" and compute the +*rectification* transformation that makes the camera optical axes parallel. + + Homogeneous Coordinates
+Homogeneous Coordinates are a system of coordinates that are used in projective geometry. Their use +allows to represent points at infinity by finite coordinates and simplifies formulas when compared +to the cartesian counterparts, e.g. they have the advantage that affine transformations can be +expressed as linear homogeneous transformation. + +One obtains the homogeneous vector \f$P_h\f$ by appending a 1 along an n-dimensional cartesian +vector \f$P\f$ e.g. for a 3D cartesian vector the mapping \f$P \rightarrow P_h\f$ is: + +\f[\begin{bmatrix} +X \\ +Y \\ +Z +\end{bmatrix} \rightarrow \begin{bmatrix} +X \\ +Y \\ +Z \\ +1 +\end{bmatrix}.\f] + +For the inverse mapping \f$P_h \rightarrow P\f$, one divides all elements of the homogeneous vector +by its last element, e.g. for a 3D homogeneous vector one gets its 2D cartesian counterpart by: + +\f[\begin{bmatrix} +X \\ +Y \\ +W +\end{bmatrix} \rightarrow \begin{bmatrix} +X / W \\ +Y / W +\end{bmatrix},\f] + +if \f$W \ne 0\f$. + +Due to this mapping, all multiples \f$k P_h\f$, for \f$k \ne 0\f$, of a homogeneous point represent +the same point \f$P_h\f$. An intuitive understanding of this property is that under a projective +transformation, all multiples of \f$P_h\f$ are mapped to the same point. This is the physical +observation one does for pinhole cameras, as all points along a ray through the camera's pinhole are +projected to the same image point, e.g. all points along the red ray in the image of the pinhole +camera model above would be mapped to the same image coordinate. This property is also the source +for the scale ambiguity s in the equation of the pinhole camera model. + +As mentioned, by using homogeneous coordinates we can express any change of basis parameterized by +\f$R\f$ and \f$t\f$ as a linear transformation, e.g. for the change of basis from coordinate system +0 to coordinate system 1 becomes: + +\f[P_1 = R P_0 + t \rightarrow P_{h_1} = \begin{bmatrix} +R & t \\ +0 & 1 +\end{bmatrix} P_{h_0}.\f] + +@note + - Many functions in this module take a camera intrinsic matrix as an input parameter. Although all + functions assume the same structure of this parameter, they may name it differently. The + parameter's description, however, will be clear in that a camera intrinsic matrix with the structure + shown above is required. + - A calibration sample for 3 cameras in a horizontal position can be found at + opencv_source_code/samples/cpp/3calibration.cpp + - A calibration sample based on a sequence of images can be found at + opencv_source_code/samples/cpp/calibration.cpp + - A calibration sample in order to do 3D reconstruction can be found at + opencv_source_code/samples/cpp/build3dmodel.cpp + - A calibration example on stereo calibration can be found at + opencv_source_code/samples/cpp/stereo_calib.cpp + - A calibration example on stereo matching can be found at + opencv_source_code/samples/cpp/stereo_match.cpp + - (Python) A camera calibration sample can be found at + opencv_source_code/samples/python/calibrate.py + + @{ + @defgroup calib3d_fisheye Fisheye camera model + + Definitions: Let P be a point in 3D of coordinates X in the world reference frame (stored in the + matrix X) The coordinate vector of P in the camera reference frame is: + + \f[Xc = R X + T\f] + + where R is the rotation matrix corresponding to the rotation vector om: R = rodrigues(om); call x, y + and z the 3 coordinates of Xc: + + \f[x = Xc_1 \\ y = Xc_2 \\ z = Xc_3\f] + + The pinhole projection coordinates of P is [a; b] where + + \f[a = x / z \ and \ b = y / z \\ r^2 = a^2 + b^2 \\ \theta = atan(r)\f] + + Fisheye distortion: + + \f[\theta_d = \theta (1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8)\f] + + The distorted point coordinates are [x'; y'] where + + \f[x' = (\theta_d / r) a \\ y' = (\theta_d / r) b \f] + + Finally, conversion into pixel coordinates: The final pixel coordinates vector [u; v] where: + + \f[u = f_x (x' + \alpha y') + c_x \\ + v = f_y y' + c_y\f] + + @defgroup calib3d_c C API + + @} + */ + +namespace cv +{ + +//! @addtogroup calib3d +//! @{ + +//! type of the robust estimation algorithm +enum { LMEDS = 4, //!< least-median of squares algorithm + RANSAC = 8, //!< RANSAC algorithm + RHO = 16, //!< RHO algorithm + USAC_DEFAULT = 32, //!< USAC algorithm, default settings + USAC_PARALLEL = 33, //!< USAC, parallel version + USAC_FM_8PTS = 34, //!< USAC, fundamental matrix 8 points + USAC_FAST = 35, //!< USAC, fast settings + USAC_ACCURATE = 36, //!< USAC, accurate settings + USAC_PROSAC = 37, //!< USAC, sorted points, runs PROSAC + USAC_MAGSAC = 38 //!< USAC, runs MAGSAC++ + }; + +enum SolvePnPMethod { + SOLVEPNP_ITERATIVE = 0, //!< Pose refinement using non-linear Levenberg-Marquardt minimization scheme @cite Madsen04 @cite Eade13 \n + //!< Initial solution for non-planar "objectPoints" needs at least 6 points and uses the DLT algorithm. \n + //!< Initial solution for planar "objectPoints" needs at least 4 points and uses pose from homography decomposition. + SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp + SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete + SOLVEPNP_DLS = 3, //!< **Broken implementation. Using this flag will fallback to EPnP.** \n + //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct + SOLVEPNP_UPNP = 4, //!< **Broken implementation. Using this flag will fallback to EPnP.** \n + //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive + SOLVEPNP_AP3P = 5, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17 + SOLVEPNP_IPPE = 6, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n + //!< Object points must be coplanar. + SOLVEPNP_IPPE_SQUARE = 7, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n + //!< This is a special case suitable for marker pose estimation.\n + //!< 4 coplanar object points must be defined in the following order: + //!< - point 0: [-squareLength / 2, squareLength / 2, 0] + //!< - point 1: [ squareLength / 2, squareLength / 2, 0] + //!< - point 2: [ squareLength / 2, -squareLength / 2, 0] + //!< - point 3: [-squareLength / 2, -squareLength / 2, 0] + SOLVEPNP_SQPNP = 8, //!< SQPnP: A Consistently Fast and Globally OptimalSolution to the Perspective-n-Point Problem @cite Terzakis2020SQPnP +#ifndef CV_DOXYGEN + SOLVEPNP_MAX_COUNT //!< Used for count +#endif +}; + +enum { CALIB_CB_ADAPTIVE_THRESH = 1, + CALIB_CB_NORMALIZE_IMAGE = 2, + CALIB_CB_FILTER_QUADS = 4, + CALIB_CB_FAST_CHECK = 8, + CALIB_CB_EXHAUSTIVE = 16, + CALIB_CB_ACCURACY = 32, + CALIB_CB_LARGER = 64, + CALIB_CB_MARKER = 128 + }; + +enum { CALIB_CB_SYMMETRIC_GRID = 1, + CALIB_CB_ASYMMETRIC_GRID = 2, + CALIB_CB_CLUSTERING = 4 + }; + +enum { CALIB_NINTRINSIC = 18, + CALIB_USE_INTRINSIC_GUESS = 0x00001, + CALIB_FIX_ASPECT_RATIO = 0x00002, + CALIB_FIX_PRINCIPAL_POINT = 0x00004, + CALIB_ZERO_TANGENT_DIST = 0x00008, + CALIB_FIX_FOCAL_LENGTH = 0x00010, + CALIB_FIX_K1 = 0x00020, + CALIB_FIX_K2 = 0x00040, + CALIB_FIX_K3 = 0x00080, + CALIB_FIX_K4 = 0x00800, + CALIB_FIX_K5 = 0x01000, + CALIB_FIX_K6 = 0x02000, + CALIB_RATIONAL_MODEL = 0x04000, + CALIB_THIN_PRISM_MODEL = 0x08000, + CALIB_FIX_S1_S2_S3_S4 = 0x10000, + CALIB_TILTED_MODEL = 0x40000, + CALIB_FIX_TAUX_TAUY = 0x80000, + CALIB_USE_QR = 0x100000, //!< use QR instead of SVD decomposition for solving. Faster but potentially less precise + CALIB_FIX_TANGENT_DIST = 0x200000, + // only for stereo + CALIB_FIX_INTRINSIC = 0x00100, + CALIB_SAME_FOCAL_LENGTH = 0x00200, + // for stereo rectification + CALIB_ZERO_DISPARITY = 0x00400, + CALIB_USE_LU = (1 << 17), //!< use LU instead of SVD decomposition for solving. much faster but potentially less precise + CALIB_USE_EXTRINSIC_GUESS = (1 << 22) //!< for stereoCalibrate + }; + +//! the algorithm for finding fundamental matrix +enum { FM_7POINT = 1, //!< 7-point algorithm + FM_8POINT = 2, //!< 8-point algorithm + FM_LMEDS = 4, //!< least-median algorithm. 7-point algorithm is used. + FM_RANSAC = 8 //!< RANSAC algorithm. It needs at least 15 points. 7-point algorithm is used. + }; + +enum HandEyeCalibrationMethod +{ + CALIB_HAND_EYE_TSAI = 0, //!< A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/Eye Calibration @cite Tsai89 + CALIB_HAND_EYE_PARK = 1, //!< Robot Sensor Calibration: Solving AX = XB on the Euclidean Group @cite Park94 + CALIB_HAND_EYE_HORAUD = 2, //!< Hand-eye Calibration @cite Horaud95 + CALIB_HAND_EYE_ANDREFF = 3, //!< On-line Hand-Eye Calibration @cite Andreff99 + CALIB_HAND_EYE_DANIILIDIS = 4 //!< Hand-Eye Calibration Using Dual Quaternions @cite Daniilidis98 +}; + +enum RobotWorldHandEyeCalibrationMethod +{ + CALIB_ROBOT_WORLD_HAND_EYE_SHAH = 0, //!< Solving the robot-world/hand-eye calibration problem using the kronecker product @cite Shah2013SolvingTR + CALIB_ROBOT_WORLD_HAND_EYE_LI = 1 //!< Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product @cite Li2010SimultaneousRA +}; + +enum SamplingMethod { SAMPLING_UNIFORM, SAMPLING_PROGRESSIVE_NAPSAC, SAMPLING_NAPSAC, + SAMPLING_PROSAC }; +enum LocalOptimMethod {LOCAL_OPTIM_NULL, LOCAL_OPTIM_INNER_LO, LOCAL_OPTIM_INNER_AND_ITER_LO, + LOCAL_OPTIM_GC, LOCAL_OPTIM_SIGMA}; +enum ScoreMethod {SCORE_METHOD_RANSAC, SCORE_METHOD_MSAC, SCORE_METHOD_MAGSAC, SCORE_METHOD_LMEDS}; +enum NeighborSearchMethod { NEIGH_FLANN_KNN, NEIGH_GRID, NEIGH_FLANN_RADIUS }; + +struct CV_EXPORTS_W_SIMPLE UsacParams +{ // in alphabetical order + CV_WRAP UsacParams(); + CV_PROP_RW double confidence; + CV_PROP_RW bool isParallel; + CV_PROP_RW int loIterations; + CV_PROP_RW LocalOptimMethod loMethod; + CV_PROP_RW int loSampleSize; + CV_PROP_RW int maxIterations; + CV_PROP_RW NeighborSearchMethod neighborsSearch; + CV_PROP_RW int randomGeneratorState; + CV_PROP_RW SamplingMethod sampler; + CV_PROP_RW ScoreMethod score; + CV_PROP_RW double threshold; +}; + +/** @brief Converts a rotation matrix to a rotation vector or vice versa. + +@param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3). +@param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively. +@param jacobian Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial +derivatives of the output array components with respect to the input array components. + +\f[\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\f] + +Inverse transformation can be also done easily, since + +\f[\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\f] + +A rotation vector is a convenient and most compact representation of a rotation matrix (since any +rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry +optimization procedures like @ref calibrateCamera, @ref stereoCalibrate, or @ref solvePnP . + +@note More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate +can be found in: + - A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi @cite Gallego2014ACF + +@note Useful information on SE(3) and Lie Groups can be found in: + - A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco @cite blanco2010tutorial + - Lie Groups for 2D and 3D Transformation, Ethan Eade @cite Eade17 + - A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan @cite Sol2018AML + */ +CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() ); + + + +/** Levenberg-Marquardt solver. Starting with the specified vector of parameters it + optimizes the target vector criteria "err" + (finds local minima of each target vector component absolute value). + + When needed, it calls user-provided callback. +*/ +class CV_EXPORTS LMSolver : public Algorithm +{ +public: + class CV_EXPORTS Callback + { + public: + virtual ~Callback() {} + /** + computes error and Jacobian for the specified vector of parameters + + @param param the current vector of parameters + @param err output vector of errors: err_i = actual_f_i - ideal_f_i + @param J output Jacobian: J_ij = d(err_i)/d(param_j) + + when J=noArray(), it means that it does not need to be computed. + Dimensionality of error vector and param vector can be different. + The callback should explicitly allocate (with "create" method) each output array + (unless it's noArray()). + */ + virtual bool compute(InputArray param, OutputArray err, OutputArray J) const = 0; + }; + + /** + Runs Levenberg-Marquardt algorithm using the passed vector of parameters as the start point. + The final vector of parameters (whether the algorithm converged or not) is stored at the same + vector. The method returns the number of iterations used. If it's equal to the previously specified + maxIters, there is a big chance the algorithm did not converge. + + @param param initial/final vector of parameters. + + Note that the dimensionality of parameter space is defined by the size of param vector, + and the dimensionality of optimized criteria is defined by the size of err vector + computed by the callback. + */ + virtual int run(InputOutputArray param) const = 0; + + /** + Sets the maximum number of iterations + @param maxIters the number of iterations + */ + virtual void setMaxIters(int maxIters) = 0; + /** + Retrieves the current maximum number of iterations + */ + virtual int getMaxIters() const = 0; + + /** + Creates Levenberg-Marquard solver + + @param cb callback + @param maxIters maximum number of iterations that can be further + modified using setMaxIters() method. + */ + static Ptr create(const Ptr& cb, int maxIters); + static Ptr create(const Ptr& cb, int maxIters, double eps); +}; + + + +/** @example samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp +An example program about pose estimation from coplanar points + +Check @ref tutorial_homography "the corresponding tutorial" for more details +*/ + +/** @brief Finds a perspective transformation between two planes. + +@param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2 +or vector\ . +@param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or +a vector\ . +@param method Method used to compute a homography matrix. The following methods are possible: +- **0** - a regular method using all the points, i.e., the least squares method +- @ref RANSAC - RANSAC-based robust method +- @ref LMEDS - Least-Median robust method +- @ref RHO - PROSAC-based robust method +@param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier +(used in the RANSAC and RHO methods only). That is, if +\f[\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} * \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\f] +then the point \f$i\f$ is considered as an outlier. If srcPoints and dstPoints are measured in pixels, +it usually makes sense to set this parameter somewhere in the range of 1 to 10. +@param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input +mask values are ignored. +@param maxIters The maximum number of RANSAC iterations. +@param confidence Confidence level, between 0 and 1. + +The function finds and returns the perspective transformation \f$H\f$ between the source and the +destination planes: + +\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] + +so that the back-projection error + +\f[\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\f] + +is minimized. If the parameter method is set to the default value 0, the function uses all the point +pairs to compute an initial homography estimate with a simple least-squares scheme. + +However, if not all of the point pairs ( \f$srcPoints_i\f$, \f$dstPoints_i\f$ ) fit the rigid perspective +transformation (that is, there are some outliers), this initial estimate will be poor. In this case, +you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different +random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix +using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the +computed homography (which is the number of inliers for RANSAC or the least median re-projection error for +LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and +the mask of inliers/outliers. + +Regardless of the method, robust or not, the computed homography matrix is refined further (using +inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the +re-projection error even more. + +The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to +distinguish inliers from outliers. The method LMeDS does not need any threshold but it works +correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the +noise is rather small, use the default method (method=0). + +The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is +determined up to a scale. Thus, it is normalized so that \f$h_{33}=1\f$. Note that whenever an \f$H\f$ matrix +cannot be estimated, an empty one will be returned. + +@sa +getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective, +perspectiveTransform + */ +CV_EXPORTS_W Mat findHomography( InputArray srcPoints, InputArray dstPoints, + int method = 0, double ransacReprojThreshold = 3, + OutputArray mask=noArray(), const int maxIters = 2000, + const double confidence = 0.995); + +/** @overload */ +CV_EXPORTS Mat findHomography( InputArray srcPoints, InputArray dstPoints, + OutputArray mask, int method = 0, double ransacReprojThreshold = 3 ); + + +CV_EXPORTS_W Mat findHomography(InputArray srcPoints, InputArray dstPoints, OutputArray mask, + const UsacParams ¶ms); + +/** @brief Computes an RQ decomposition of 3x3 matrices. + +@param src 3x3 input matrix. +@param mtxR Output 3x3 upper-triangular matrix. +@param mtxQ Output 3x3 orthogonal matrix. +@param Qx Optional output 3x3 rotation matrix around x-axis. +@param Qy Optional output 3x3 rotation matrix around y-axis. +@param Qz Optional output 3x3 rotation matrix around z-axis. + +The function computes a RQ decomposition using the given rotations. This function is used in +#decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera +and a rotation matrix. + +It optionally returns three rotation matrices, one for each axis, and the three Euler angles in +degrees (as the return value) that could be used in OpenGL. Note, there is always more than one +sequence of rotations about the three principal axes that results in the same orientation of an +object, e.g. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angles +are only one of the possible solutions. + */ +CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mtxQ, + OutputArray Qx = noArray(), + OutputArray Qy = noArray(), + OutputArray Qz = noArray()); + +/** @brief Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix. + +@param projMatrix 3x4 input projection matrix P. +@param cameraMatrix Output 3x3 camera intrinsic matrix \f$\cameramatrix{A}\f$. +@param rotMatrix Output 3x3 external rotation matrix R. +@param transVect Output 4x1 translation vector T. +@param rotMatrixX Optional 3x3 rotation matrix around x-axis. +@param rotMatrixY Optional 3x3 rotation matrix around y-axis. +@param rotMatrixZ Optional 3x3 rotation matrix around z-axis. +@param eulerAngles Optional three-element vector containing three Euler angles of rotation in +degrees. + +The function computes a decomposition of a projection matrix into a calibration and a rotation +matrix and the position of a camera. + +It optionally returns three rotation matrices, one for each axis, and three Euler angles that could +be used in OpenGL. Note, there is always more than one sequence of rotations about the three +principal axes that results in the same orientation of an object, e.g. see @cite Slabaugh . Returned +tree rotation matrices and corresponding three Euler angles are only one of the possible solutions. + +The function is based on RQDecomp3x3 . + */ +CV_EXPORTS_W void decomposeProjectionMatrix( InputArray projMatrix, OutputArray cameraMatrix, + OutputArray rotMatrix, OutputArray transVect, + OutputArray rotMatrixX = noArray(), + OutputArray rotMatrixY = noArray(), + OutputArray rotMatrixZ = noArray(), + OutputArray eulerAngles =noArray() ); + +/** @brief Computes partial derivatives of the matrix product for each multiplied matrix. + +@param A First multiplied matrix. +@param B Second multiplied matrix. +@param dABdA First output derivative matrix d(A\*B)/dA of size +\f$\texttt{A.rows*B.cols} \times {A.rows*A.cols}\f$ . +@param dABdB Second output derivative matrix d(A\*B)/dB of size +\f$\texttt{A.rows*B.cols} \times {B.rows*B.cols}\f$ . + +The function computes partial derivatives of the elements of the matrix product \f$A*B\f$ with regard to +the elements of each of the two input matrices. The function is used to compute the Jacobian +matrices in #stereoCalibrate but can also be used in any other similar optimization function. + */ +CV_EXPORTS_W void matMulDeriv( InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB ); + +/** @brief Combines two rotation-and-shift transformations. + +@param rvec1 First rotation vector. +@param tvec1 First translation vector. +@param rvec2 Second rotation vector. +@param tvec2 Second translation vector. +@param rvec3 Output rotation vector of the superposition. +@param tvec3 Output translation vector of the superposition. +@param dr3dr1 Optional output derivative of rvec3 with regard to rvec1 +@param dr3dt1 Optional output derivative of rvec3 with regard to tvec1 +@param dr3dr2 Optional output derivative of rvec3 with regard to rvec2 +@param dr3dt2 Optional output derivative of rvec3 with regard to tvec2 +@param dt3dr1 Optional output derivative of tvec3 with regard to rvec1 +@param dt3dt1 Optional output derivative of tvec3 with regard to tvec1 +@param dt3dr2 Optional output derivative of tvec3 with regard to rvec2 +@param dt3dt2 Optional output derivative of tvec3 with regard to tvec2 + +The functions compute: + +\f[\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\f] + +where \f$\mathrm{rodrigues}\f$ denotes a rotation vector to a rotation matrix transformation, and +\f$\mathrm{rodrigues}^{-1}\f$ denotes the inverse transformation. See Rodrigues for details. + +Also, the functions can compute the derivatives of the output vectors with regards to the input +vectors (see matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in +your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a +function that contains a matrix multiplication. + */ +CV_EXPORTS_W void composeRT( InputArray rvec1, InputArray tvec1, + InputArray rvec2, InputArray tvec2, + OutputArray rvec3, OutputArray tvec3, + OutputArray dr3dr1 = noArray(), OutputArray dr3dt1 = noArray(), + OutputArray dr3dr2 = noArray(), OutputArray dr3dt2 = noArray(), + OutputArray dt3dr1 = noArray(), OutputArray dt3dt1 = noArray(), + OutputArray dt3dr2 = noArray(), OutputArray dt3dt2 = noArray() ); + +/** @brief Projects 3D points to an image plane. + +@param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3 +1-channel or 1xN/Nx1 3-channel (or vector\ ), where N is the number of points in the view. +@param rvec The rotation vector (@ref Rodrigues) that, together with tvec, performs a change of +basis from world to camera coordinate system, see @ref calibrateCamera for details. +@param tvec The translation vector, see parameter description above. +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$ . If the vector is empty, the zero distortion coefficients are assumed. +@param imagePoints Output array of image points, 1xN/Nx1 2-channel, or +vector\ . +@param jacobian Optional output 2Nx(10+\) jacobian matrix of derivatives of image +points with respect to components of the rotation vector, translation vector, focal lengths, +coordinates of the principal point and the distortion coefficients. In the old interface different +components of the jacobian are returned via different output parameters. +@param aspectRatio Optional "fixed aspect ratio" parameter. If the parameter is not 0, the +function assumes that the aspect ratio (\f$f_x / f_y\f$) is fixed and correspondingly adjusts the +jacobian matrix. + +The function computes the 2D projections of 3D points to the image plane, given intrinsic and +extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial +derivatives of image points coordinates (as functions of all the input parameters) with respect to +the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global +optimization in @ref calibrateCamera, @ref solvePnP, and @ref stereoCalibrate. The function itself +can also be used to compute a re-projection error, given the current intrinsic and extrinsic +parameters. + +@note By setting rvec = tvec = \f$[0, 0, 0]\f$, or by setting cameraMatrix to a 3x3 identity matrix, +or by passing zero distortion coefficients, one can get various useful partial cases of the +function. This means, one can compute the distorted coordinates for a sparse set of points or apply +a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup. + */ +CV_EXPORTS_W void projectPoints( InputArray objectPoints, + InputArray rvec, InputArray tvec, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray imagePoints, + OutputArray jacobian = noArray(), + double aspectRatio = 0 ); + +/** @example samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp +An example program about homography from the camera displacement + +Check @ref tutorial_homography "the corresponding tutorial" for more details +*/ + +/** @brief Finds an object pose from 3D-2D point correspondences. + +@see @ref calib3d_solvePnP + +This function returns the rotation and the translation vectors that transform a 3D point expressed in the object +coordinate frame to the camera coordinate frame, using different methods: +- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): need 4 input points to return a unique solution. +- @ref SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. +- @ref SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation. +Number of input points must be 4. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] +- for all the other flags, number of input points must be >= 4 and object points can be in any configuration. + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or +1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. +@param tvec Output translation vector. +@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses +the provided rvec and tvec values as initial approximations of the rotation and translation +vectors, respectively, and further optimizes them. +@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags + +More information about Perspective-n-Points is described in @ref calib3d_solvePnP + +@note + - An example of how to use solvePnP for planar augmented reality can be found at + opencv_source_code/samples/python/plane_ar.py + - If you are using Python: + - Numpy array slices won't work as input because solvePnP requires contiguous + arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of + modules/calib3d/src/solvepnp.cpp version 2.4.9) + - The P3P algorithm requires image points to be in an array of shape (N,1,2) due + to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9) + which requires 2-channel information. + - Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of + it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints = + np.ascontiguousarray(D[:,:2]).reshape((N,1,2)) + - The methods @ref SOLVEPNP_DLS and @ref SOLVEPNP_UPNP cannot be used as the current implementations are + unstable and sometimes give completely wrong results. If you pass one of these two + flags, @ref SOLVEPNP_EPNP method will be used instead. + - The minimum number of points is 4 in the general case. In the case of @ref SOLVEPNP_P3P and @ref SOLVEPNP_AP3P + methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions + of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error). + - With @ref SOLVEPNP_ITERATIVE method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points + are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the + global solution to converge. + - With @ref SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar. + - With @ref SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation. + Number of input points must be 4. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] + - With @ref SOLVEPNP_SQPNP input points must be >= 3 + */ +CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvec, OutputArray tvec, + bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE ); + +/** @brief Finds an object pose from 3D-2D point correspondences using the RANSAC scheme. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or +1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. +@param tvec Output translation vector. +@param useExtrinsicGuess Parameter used for @ref SOLVEPNP_ITERATIVE. If true (1), the function uses +the provided rvec and tvec values as initial approximations of the rotation and translation +vectors, respectively, and further optimizes them. +@param iterationsCount Number of iterations. +@param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value +is the maximum allowed distance between the observed and computed point projections to consider it +an inlier. +@param confidence The probability that the algorithm produces a useful result. +@param inliers Output vector that contains indices of inliers in objectPoints and imagePoints . +@param flags Method for solving a PnP problem (see @ref solvePnP ). + +The function estimates an object pose given a set of object points, their corresponding image +projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such +a pose that minimizes reprojection error, that is, the sum of squared distances between the observed +projections imagePoints and the projected (using @ref projectPoints ) objectPoints. The use of RANSAC +makes the function resistant to outliers. + +@note + - An example of how to use solvePNPRansac for object detection can be found at + opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/ + - The default method used to estimate the camera pose for the Minimal Sample Sets step + is #SOLVEPNP_EPNP. Exceptions are: + - if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used. + - if the number of input points is equal to 4, #SOLVEPNP_P3P is used. + - The method used to estimate the camera pose using all the inliers is defined by the + flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case, + the method #SOLVEPNP_EPNP will be used instead. + */ +CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvec, OutputArray tvec, + bool useExtrinsicGuess = false, int iterationsCount = 100, + float reprojectionError = 8.0, double confidence = 0.99, + OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE ); + + +/* +Finds rotation and translation vector. +If cameraMatrix is given then run P3P. Otherwise run linear P6P and output cameraMatrix too. +*/ +CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints, + InputOutputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvec, OutputArray tvec, OutputArray inliers, + const UsacParams ¶ms=UsacParams()); + +/** @brief Finds an object pose from 3 3D-2D point correspondences. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or +1x3/3x1 3-channel. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel. + vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvecs Output rotation vectors (see @ref Rodrigues ) that, together with tvecs, brings points from +the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions. +@param tvecs Output translation vectors. +@param flags Method for solving a P3P problem: +- @ref SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang +"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete). +- @ref SOLVEPNP_AP3P Method is based on the paper of T. Ke and S. Roumeliotis. +"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17). + +The function estimates the object pose given 3 object points, their corresponding image +projections, as well as the camera intrinsic matrix and the distortion coefficients. + +@note +The solutions are sorted by reprojection errors (lowest to highest). + */ +CV_EXPORTS_W int solveP3P( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + int flags ); + +/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame +to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel, +where N is the number of points. vector\ can also be passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can also be passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Input/Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. Input values are used as an initial solution. +@param tvec Input/Output translation vector. Input values are used as an initial solution. +@param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm. + +The function refines the object pose given at least 3 object points, their corresponding image +projections, an initial solution for the rotation and translation vector, +as well as the camera intrinsic matrix and the distortion coefficients. +The function minimizes the projection error with respect to the rotation and the translation vectors, according +to a Levenberg-Marquardt iterative minimization @cite Madsen04 @cite Eade13 process. + */ +CV_EXPORTS_W void solvePnPRefineLM( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + InputOutputArray rvec, InputOutputArray tvec, + TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON)); + +/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame +to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution. + +@see @ref calib3d_solvePnP + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel, +where N is the number of points. vector\ can also be passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can also be passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvec Input/Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. Input values are used as an initial solution. +@param tvec Input/Output translation vector. Input values are used as an initial solution. +@param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm. +@param VVSlambda Gain for the virtual visual servoing control law, equivalent to the \f$\alpha\f$ +gain in the Damped Gauss-Newton formulation. + +The function refines the object pose given at least 3 object points, their corresponding image +projections, an initial solution for the rotation and translation vector, +as well as the camera intrinsic matrix and the distortion coefficients. +The function minimizes the projection error with respect to the rotation and the translation vectors, using a +virtual visual servoing (VVS) @cite Chaumette06 @cite Marchand16 scheme. + */ +CV_EXPORTS_W void solvePnPRefineVVS( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + InputOutputArray rvec, InputOutputArray tvec, + TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON), + double VVSlambda = 1); + +/** @brief Finds an object pose from 3D-2D point correspondences. + +@see @ref calib3d_solvePnP + +This function returns a list of all the possible solutions (a solution is a +couple), depending on the number of input points and the chosen method: +- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points. +- @ref SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions. +- @ref SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation. +Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] +- for all the other flags, number of input points must be >= 4 and object points can be in any configuration. +Only 1 solution is returned. + +@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or +1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here. +@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, +where N is the number of points. vector\ can be also passed here. +@param cameraMatrix Input camera intrinsic matrix \f$\cameramatrix{A}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param rvecs Vector of output rotation vectors (see @ref Rodrigues ) that, together with tvecs, brings points from +the model coordinate system to the camera coordinate system. +@param tvecs Vector of output translation vectors. +@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses +the provided rvec and tvec values as initial approximations of the rotation and translation +vectors, respectively, and further optimizes them. +@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags +@param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is @ref SOLVEPNP_ITERATIVE +and useExtrinsicGuess is set to true. +@param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is @ref SOLVEPNP_ITERATIVE +and useExtrinsicGuess is set to true. +@param reprojectionError Optional vector of reprojection error, that is the RMS error +(\f$ \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \f$) between the input image points +and the 3D object points projected with the estimated pose. + +More information is described in @ref calib3d_solvePnP + +@note + - An example of how to use solvePnP for planar augmented reality can be found at + opencv_source_code/samples/python/plane_ar.py + - If you are using Python: + - Numpy array slices won't work as input because solvePnP requires contiguous + arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of + modules/calib3d/src/solvepnp.cpp version 2.4.9) + - The P3P algorithm requires image points to be in an array of shape (N,1,2) due + to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9) + which requires 2-channel information. + - Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of + it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints = + np.ascontiguousarray(D[:,:2]).reshape((N,1,2)) + - The methods @ref SOLVEPNP_DLS and @ref SOLVEPNP_UPNP cannot be used as the current implementations are + unstable and sometimes give completely wrong results. If you pass one of these two + flags, @ref SOLVEPNP_EPNP method will be used instead. + - The minimum number of points is 4 in the general case. In the case of @ref SOLVEPNP_P3P and @ref SOLVEPNP_AP3P + methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions + of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error). + - With @ref SOLVEPNP_ITERATIVE method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points + are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the + global solution to converge. + - With @ref SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar. + - With @ref SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation. + Number of input points must be 4. Object points must be defined in the following order: + - point 0: [-squareLength / 2, squareLength / 2, 0] + - point 1: [ squareLength / 2, squareLength / 2, 0] + - point 2: [ squareLength / 2, -squareLength / 2, 0] + - point 3: [-squareLength / 2, -squareLength / 2, 0] + */ +CV_EXPORTS_W int solvePnPGeneric( InputArray objectPoints, InputArray imagePoints, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE, + InputArray rvec = noArray(), InputArray tvec = noArray(), + OutputArray reprojectionError = noArray() ); + +/** @brief Finds an initial camera intrinsic matrix from 3D-2D point correspondences. + +@param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern +coordinate space. In the old interface all the per-view vectors are concatenated. See +#calibrateCamera for details. +@param imagePoints Vector of vectors of the projections of the calibration pattern points. In the +old interface all the per-view vectors are concatenated. +@param imageSize Image size in pixels used to initialize the principal point. +@param aspectRatio If it is zero or negative, both \f$f_x\f$ and \f$f_y\f$ are estimated independently. +Otherwise, \f$f_x = f_y * \texttt{aspectRatio}\f$ . + +The function estimates and returns an initial camera intrinsic matrix for the camera calibration process. +Currently, the function only supports planar calibration patterns, which are patterns where each +object point has z-coordinate =0. + */ +CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, + Size imageSize, double aspectRatio = 1.0 ); + +/** @brief Finds the positions of internal corners of the chessboard. + +@param image Source chessboard view. It must be an 8-bit grayscale or color image. +@param patternSize Number of inner corners per a chessboard row and column +( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ). +@param corners Output array of detected corners. +@param flags Various operation flags that can be zero or a combination of the following values: +- @ref CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black +and white, rather than a fixed threshold level (computed from the average image brightness). +- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before +applying fixed or adaptive thresholding. +- @ref CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter, +square-like shape) to filter out false quads extracted at the contour retrieval stage. +- @ref CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners, +and shortcut the call if none is found. This can drastically speed up the call in the +degenerate condition when no chessboard is observed. + +The function attempts to determine whether the input image is a view of the chessboard pattern and +locate the internal chessboard corners. The function returns a non-zero value if all of the corners +are found and they are placed in a certain order (row by row, left to right in every row). +Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example, +a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black +squares touch each other. The detected coordinates are approximate, and to determine their positions +more accurately, the function calls cornerSubPix. You also may use the function cornerSubPix with +different parameters if returned coordinates are not accurate enough. + +Sample usage of detecting and drawing chessboard corners: : +@code + Size patternsize(8,6); //interior number of corners + Mat gray = ....; //source image + vector corners; //this will be filled by the detected corners + + //CALIB_CB_FAST_CHECK saves a lot of time on images + //that do not contain any chessboard corners + bool patternfound = findChessboardCorners(gray, patternsize, corners, + CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + + CALIB_CB_FAST_CHECK); + + if(patternfound) + cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1), + TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); + + drawChessboardCorners(img, patternsize, Mat(corners), patternfound); +@endcode +@note The function requires white space (like a square-thick border, the wider the better) around +the board to make the detection more robust in various environments. Otherwise, if there is no +border and the background is dark, the outer black squares cannot be segmented properly and so the +square grouping and ordering algorithm fails. + +Use gen_pattern.py (@ref tutorial_camera_calibration_pattern) to create checkerboard. + */ +CV_EXPORTS_W bool findChessboardCorners( InputArray image, Size patternSize, OutputArray corners, + int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE ); + +/* + Checks whether the image contains chessboard of the specific size or not. + If yes, nonzero value is returned. +*/ +CV_EXPORTS_W bool checkChessboard(InputArray img, Size size); + +/** @brief Finds the positions of internal corners of the chessboard using a sector based approach. + +@param image Source chessboard view. It must be an 8-bit grayscale or color image. +@param patternSize Number of inner corners per a chessboard row and column +( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ). +@param corners Output array of detected corners. +@param flags Various operation flags that can be zero or a combination of the following values: +- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection. +- @ref CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate. +- @ref CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects. +- @ref CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description). +- @ref CALIB_CB_MARKER The detected pattern must have a marker (see description). +This should be used if an accurate camera calibration is required. +@param meta Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)). +Each entry stands for one corner of the pattern and can have one of the following values: +- 0 = no meta data attached +- 1 = left-top corner of a black cell +- 2 = left-top corner of a white cell +- 3 = left-top corner of a black cell with a white marker dot +- 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner) + +The function is analog to #findChessboardCorners but uses a localized radon +transformation approximated by box filters being more robust to all sort of +noise, faster on larger images and is able to directly return the sub-pixel +position of the internal chessboard corners. The Method is based on the paper +@cite duda2018 "Accurate Detection and Localization of Checkerboard Corners for +Calibration" demonstrating that the returned sub-pixel positions are more +accurate than the one returned by cornerSubPix allowing a precise camera +calibration for demanding applications. + +In the case, the flags @ref CALIB_CB_LARGER or @ref CALIB_CB_MARKER are given, +the result can be recovered from the optional meta array. Both flags are +helpful to use calibration patterns exceeding the field of view of the camera. +These oversized patterns allow more accurate calibrations as corners can be +utilized, which are as close as possible to the image borders. For a +consistent coordinate system across all images, the optional marker (see image +below) can be used to move the origin of the board to the location where the +black circle is located. + +@note The function requires a white boarder with roughly the same width as one +of the checkerboard fields around the whole board to improve the detection in +various environments. In addition, because of the localized radon +transformation it is beneficial to use round corners for the field corners +which are located on the outside of the board. The following figure illustrates +a sample checkerboard optimized for the detection. However, any other checkerboard +can be used as well. + +Use gen_pattern.py (@ref tutorial_camera_calibration_pattern) to create checkerboard. +![Checkerboard](pics/checkerboard_radon.png) + */ +CV_EXPORTS_AS(findChessboardCornersSBWithMeta) +bool findChessboardCornersSB(InputArray image,Size patternSize, OutputArray corners, + int flags,OutputArray meta); +/** @overload */ +CV_EXPORTS_W inline +bool findChessboardCornersSB(InputArray image, Size patternSize, OutputArray corners, + int flags = 0) +{ + return findChessboardCornersSB(image, patternSize, corners, flags, noArray()); +} + +/** @brief Estimates the sharpness of a detected chessboard. + +Image sharpness, as well as brightness, are a critical parameter for accuracte +camera calibration. For accessing these parameters for filtering out +problematic calibraiton images, this method calculates edge profiles by traveling from +black to white chessboard cell centers. Based on this, the number of pixels is +calculated required to transit from black to white. This width of the +transition area is a good indication of how sharp the chessboard is imaged +and should be below ~3.0 pixels. + +@param image Gray image used to find chessboard corners +@param patternSize Size of a found chessboard pattern +@param corners Corners found by #findChessboardCornersSB +@param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength +@param vertical By default edge responses for horizontal lines are calculated +@param sharpness Optional output array with a sharpness value for calculated edge responses (see description) + +The optional sharpness array is of type CV_32FC1 and has for each calculated +profile one row with the following five entries: +* 0 = x coordinate of the underlying edge in the image +* 1 = y coordinate of the underlying edge in the image +* 2 = width of the transition area (sharpness) +* 3 = signal strength in the black cell (min brightness) +* 4 = signal strength in the white cell (max brightness) + +@return Scalar(average sharpness, average min brightness, average max brightness,0) +*/ +CV_EXPORTS_W Scalar estimateChessboardSharpness(InputArray image, Size patternSize, InputArray corners, + float rise_distance=0.8F,bool vertical=false, + OutputArray sharpness=noArray()); + + +//! finds subpixel-accurate positions of the chessboard corners +CV_EXPORTS_W bool find4QuadCornerSubpix( InputArray img, InputOutputArray corners, Size region_size ); + +/** @brief Renders the detected chessboard corners. + +@param image Destination image. It must be an 8-bit color image. +@param patternSize Number of inner corners per a chessboard row and column +(patternSize = cv::Size(points_per_row,points_per_column)). +@param corners Array of detected corners, the output of #findChessboardCorners. +@param patternWasFound Parameter indicating whether the complete board was found or not. The +return value of #findChessboardCorners should be passed here. + +The function draws individual chessboard corners detected either as red circles if the board was not +found, or as colored corners connected with lines if the board was found. + */ +CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize, + InputArray corners, bool patternWasFound ); + +/** @brief Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP + +@param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered. +@param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters. +\f$\cameramatrix{A}\f$ +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is empty, the zero distortion coefficients are assumed. +@param rvec Rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from +the model coordinate system to the camera coordinate system. +@param tvec Translation vector. +@param length Length of the painted axes in the same unit than tvec (usually in meters). +@param thickness Line thickness of the painted axes. + +This function draws the axes of the world/object coordinate system w.r.t. to the camera frame. +OX is drawn in red, OY in green and OZ in blue. + */ +CV_EXPORTS_W void drawFrameAxes(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs, + InputArray rvec, InputArray tvec, float length, int thickness=3); + +struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters +{ + CV_WRAP CirclesGridFinderParameters(); + CV_PROP_RW cv::Size2f densityNeighborhoodSize; + CV_PROP_RW float minDensity; + CV_PROP_RW int kmeansAttempts; + CV_PROP_RW int minDistanceToAddKeypoint; + CV_PROP_RW int keypointScale; + CV_PROP_RW float minGraphConfidence; + CV_PROP_RW float vertexGain; + CV_PROP_RW float vertexPenalty; + CV_PROP_RW float existingVertexGain; + CV_PROP_RW float edgeGain; + CV_PROP_RW float edgePenalty; + CV_PROP_RW float convexHullFactor; + CV_PROP_RW float minRNGEdgeSwitchDist; + + enum GridType + { + SYMMETRIC_GRID, ASYMMETRIC_GRID + }; + GridType gridType; + + CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING. + CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from prediction. Used by CALIB_CB_CLUSTERING. +}; + +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +typedef CirclesGridFinderParameters CirclesGridFinderParameters2; +#endif + +/** @brief Finds centers in the grid of circles. + +@param image grid view of input circles; it must be an 8-bit grayscale or color image. +@param patternSize number of circles per row and column +( patternSize = Size(points_per_row, points_per_colum) ). +@param centers output array of detected centers. +@param flags various operation flags that can be one of the following values: +- @ref CALIB_CB_SYMMETRIC_GRID uses symmetric pattern of circles. +- @ref CALIB_CB_ASYMMETRIC_GRID uses asymmetric pattern of circles. +- @ref CALIB_CB_CLUSTERING uses a special algorithm for grid detection. It is more robust to +perspective distortions but much more sensitive to background clutter. +@param blobDetector feature detector that finds blobs like dark circles on light background. + If `blobDetector` is NULL then `image` represents Point2f array of candidates. +@param parameters struct for finding circles in a grid pattern. + +The function attempts to determine whether the input image contains a grid of circles. If it is, the +function locates centers of the circles. The function returns a non-zero value if all of the centers +have been found and they have been placed in a certain order (row by row, left to right in every +row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0. + +Sample usage of detecting and drawing the centers of circles: : +@code + Size patternsize(7,7); //number of centers + Mat gray = ...; //source image + vector centers; //this will be filled by the detected centers + + bool patternfound = findCirclesGrid(gray, patternsize, centers); + + drawChessboardCorners(img, patternsize, Mat(centers), patternfound); +@endcode +@note The function requires white space (like a square-thick border, the wider the better) around +the board to make the detection more robust in various environments. + */ +CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, + OutputArray centers, int flags, + const Ptr &blobDetector, + const CirclesGridFinderParameters& parameters); + +/** @overload */ +CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, + OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID, + const Ptr &blobDetector = SimpleBlobDetector::create()); + +/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration +pattern. + +@param objectPoints In the new interface it is a vector of vectors of calibration pattern points in +the calibration pattern coordinate space (e.g. std::vector>). The outer +vector contains as many elements as the number of pattern views. If the same calibration pattern +is shown in each view and it is fully visible, all the vectors will be the same. Although, it is +possible to use partially occluded patterns or even different patterns in different views. Then, +the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's +XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig. +In the old interface all the vectors of object points from different views are concatenated +together. +@param imagePoints In the new interface it is a vector of vectors of the projections of calibration +pattern points (e.g. std::vector>). imagePoints.size() and +objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal, +respectively. In the old interface all the vectors of object points from different views are +concatenated together. +@param imageSize Size of the image used only to initialize the camera intrinsic matrix. +@param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix +\f$\cameramatrix{A}\f$ . If @ref CALIB_USE_INTRINSIC_GUESS +and/or @ref CALIB_FIX_ASPECT_RATIO, @ref CALIB_FIX_PRINCIPAL_POINT or @ref CALIB_FIX_FOCAL_LENGTH +are specified, some or all of fx, fy, cx, cy must be initialized before calling the function. +@param distCoeffs Input/output vector of distortion coefficients +\f$\distcoeffs\f$. +@param rvecs Output vector of rotation vectors (@ref Rodrigues ) estimated for each pattern view +(e.g. std::vector>). That is, each i-th rotation vector together with the corresponding +i-th translation vector (see the next output parameter description) brings the calibration pattern +from the object coordinate space (in which object points are specified) to the camera coordinate +space. In more technical terms, the tuple of the i-th rotation and translation vector performs +a change of basis from object coordinate space to camera coordinate space. Due to its duality, this +tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate +space. +@param tvecs Output vector of translation vectors estimated for each pattern view, see parameter +describtion above. +@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic +parameters. Order of deviations values: +\f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3, + s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero. +@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic +parameters. Order of deviations values: \f$(R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\f$ where M is +the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors. + @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view. +@param flags Different flags that may be zero or a combination of the following values: +- @ref CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of +fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image +center ( imageSize is used), and focal distances are computed in a least-squares fashion. +Note, that if intrinsic parameters are known, there is no need to use this function just to +estimate extrinsic parameters. Use @ref solvePnP instead. +- @ref CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global +optimization. It stays at the center or at a different location specified when + @ref CALIB_USE_INTRINSIC_GUESS is set too. +- @ref CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The +ratio fx/fy stays the same as in the input cameraMatrix . When + @ref CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are +ignored, only their ratio is computed and used further. +- @ref CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \f$(p_1, p_2)\f$ are set +to zeros and stay zero. +- @ref CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if + @ref CALIB_USE_INTRINSIC_GUESS is set. +- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 The corresponding radial distortion +coefficient is not changed during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is +set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the rational model and return 8 coefficients or more. +- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the thin prism model and return 12 coefficients or more. +- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the tilted sensor model and return 14 coefficients. +- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +@param criteria Termination criteria for the iterative optimization algorithm. + +@return the overall RMS re-projection error. + +The function estimates the intrinsic camera parameters and extrinsic parameters for each of the +views. The algorithm is based on @cite Zhang2000 and @cite BouguetMCT . The coordinates of 3D object +points and their corresponding 2D projections in each view must be specified. That may be achieved +by using an object with known geometry and easily detectable feature points. Such an object is +called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as +a calibration rig (see @ref findChessboardCorners). Currently, initialization of intrinsic +parameters (when @ref CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration +patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also +be used as long as initial cameraMatrix is provided. + +The algorithm performs the following steps: + +- Compute the initial intrinsic parameters (the option only available for planar calibration + patterns) or read them from the input parameters. The distortion coefficients are all set to + zeros initially unless some of CALIB_FIX_K? are specified. + +- Estimate the initial camera pose as if the intrinsic parameters have been already known. This is + done using @ref solvePnP . + +- Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, + that is, the total sum of squared distances between the observed feature points imagePoints and + the projected (using the current estimates for camera parameters and the poses) object points + objectPoints. See @ref projectPoints for details. + +@note + If you use a non-square (i.e. non-N-by-N) grid and @ref findChessboardCorners for calibration, + and @ref calibrateCamera returns bad values (zero distortion coefficients, \f$c_x\f$ and + \f$c_y\f$ very far from the image center, and/or large differences between \f$f_x\f$ and + \f$f_y\f$ (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) + instead of using patternSize=cvSize(cols,rows) in @ref findChessboardCorners. + +@sa + calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, + undistort + */ +CV_EXPORTS_AS(calibrateCameraExtended) double calibrateCamera( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray stdDeviationsIntrinsics, + OutputArray stdDeviationsExtrinsics, + OutputArray perViewErrors, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @overload */ +CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. + +This function is an extension of #calibrateCamera with the method of releasing object which was +proposed in @cite strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar +targets (calibration plates), this method can dramatically improve the precision of the estimated +camera parameters. Both the object-releasing method and standard method are supported by this +function. Use the parameter **iFixedPoint** for method selection. In the internal implementation, +#calibrateCamera is a wrapper for this function. + +@param objectPoints Vector of vectors of calibration pattern points in the calibration pattern +coordinate space. See #calibrateCamera for details. If the method of releasing object to be used, +the identical calibration board must be used in each view and it must be fully visible, and all +objectPoints[i] must be the same and all points should be roughly close to a plane. **The calibration +target has to be rigid, or at least static if the camera (rather than the calibration target) is +shifted for grabbing images.** +@param imagePoints Vector of vectors of the projections of calibration pattern points. See +#calibrateCamera for details. +@param imageSize Size of the image used only to initialize the intrinsic camera matrix. +@param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as +a switch for calibration method selection. If object-releasing method to be used, pass in the +parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will +make standard calibration method selected. Usually the top-right corner point of the calibration +board grid is recommended to be fixed when object-releasing method being utilized. According to +\cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front +and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and +newObjPoints are only possible if coordinates of these three fixed points are accurate enough. +@param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details. +@param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details. +@param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera +for details. +@param tvecs Output vector of translation vectors estimated for each pattern view. +@param newObjPoints The updated output vector of calibration pattern points. The coordinates might +be scaled based on three fixed points. The returned coordinates are accurate only if the above +mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter +is ignored with standard calibration method. +@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters. +See #calibrateCamera for details. +@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters. +See #calibrateCamera for details. +@param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates +of calibration pattern points. It has the same size and order as objectPoints[0] vector. This +parameter is ignored with standard calibration method. + @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view. +@param flags Different flags that may be zero or a combination of some predefined values. See +#calibrateCamera for details. If the method of releasing object is used, the calibration time may +be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially +less precise and less stable in some rare cases. +@param criteria Termination criteria for the iterative optimization algorithm. + +@return the overall RMS re-projection error. + +The function estimates the intrinsic camera parameters and extrinsic parameters for each of the +views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See +#calibrateCamera for other detailed explanations. +@sa + calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort + */ +CV_EXPORTS_AS(calibrateCameraROExtended) double calibrateCameraRO( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray newObjPoints, + OutputArray stdDeviationsIntrinsics, + OutputArray stdDeviationsExtrinsics, + OutputArray stdDeviationsObjPoints, + OutputArray perViewErrors, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @overload */ +CV_EXPORTS_W double calibrateCameraRO( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint, + InputOutputArray cameraMatrix, InputOutputArray distCoeffs, + OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, + OutputArray newObjPoints, + int flags = 0, TermCriteria criteria = TermCriteria( + TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) ); + +/** @brief Computes useful camera characteristics from the camera intrinsic matrix. + +@param cameraMatrix Input camera intrinsic matrix that can be estimated by #calibrateCamera or +#stereoCalibrate . +@param imageSize Input image size in pixels. +@param apertureWidth Physical width in mm of the sensor. +@param apertureHeight Physical height in mm of the sensor. +@param fovx Output field of view in degrees along the horizontal sensor axis. +@param fovy Output field of view in degrees along the vertical sensor axis. +@param focalLength Focal length of the lens in mm. +@param principalPoint Principal point in mm. +@param aspectRatio \f$f_y/f_x\f$ + +The function computes various useful camera characteristics from the previously estimated camera +matrix. + +@note + Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for + the chessboard pitch (it can thus be any value). + */ +CV_EXPORTS_W void calibrationMatrixValues( InputArray cameraMatrix, Size imageSize, + double apertureWidth, double apertureHeight, + CV_OUT double& fovx, CV_OUT double& fovy, + CV_OUT double& focalLength, CV_OUT Point2d& principalPoint, + CV_OUT double& aspectRatio ); + +/** @brief Calibrates a stereo camera set up. This function finds the intrinsic parameters +for each of the two cameras and the extrinsic parameters between the two cameras. + +@param objectPoints Vector of vectors of the calibration pattern points. The same structure as +in @ref calibrateCamera. For each pattern view, both cameras need to see the same object +points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be +equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to +be equal for each i. +@param imagePoints1 Vector of vectors of the projections of the calibration pattern points, +observed by the first camera. The same structure as in @ref calibrateCamera. +@param imagePoints2 Vector of vectors of the projections of the calibration pattern points, +observed by the second camera. The same structure as in @ref calibrateCamera. +@param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in +@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below. +@param distCoeffs1 Input/output vector of distortion coefficients, the same as in +@ref calibrateCamera. +@param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for +cameraMatrix1. +@param distCoeffs2 Input/output lens distortion coefficients for the second camera. See +description for distCoeffs1. +@param imageSize Size of the image used only to initialize the camera intrinsic matrices. +@param R Output rotation matrix. Together with the translation vector T, this matrix brings +points given in the first camera's coordinate system to points in the second camera's +coordinate system. In more technical terms, the tuple of R and T performs a change of basis +from the first camera's coordinate system to the second camera's coordinate system. Due to its +duality, this tuple is equivalent to the position of the first camera with respect to the +second camera coordinate system. +@param T Output translation vector, see description above. +@param E Output essential matrix. +@param F Output fundamental matrix. +@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view. +@param flags Different flags that may be zero or a combination of the following values: +- @ref CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F +matrices are estimated. +- @ref CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters +according to the specified flags. Initial values are provided by the user. +- @ref CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further. +Otherwise R and T are initialized to the median value of the pattern views (each dimension separately). +- @ref CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization. +- @ref CALIB_FIX_FOCAL_LENGTH Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ . +- @ref CALIB_FIX_ASPECT_RATIO Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$ +. +- @ref CALIB_SAME_FOCAL_LENGTH Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ . +- @ref CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to +zeros and fix there. +- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 Do not change the corresponding radial +distortion coefficient during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, +the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_RATIONAL_MODEL Enable coefficients k4, k5, and k6. To provide the backward +compatibility, this extra flag should be explicitly specified to make the calibration +function use the rational model and return 8 coefficients. If the flag is not set, the +function computes and returns only 5 distortion coefficients. +- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the thin prism model and return 12 coefficients. If the flag is not +set, the function computes and returns only 5 distortion coefficients. +- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +- @ref CALIB_TILTED_MODEL Coefficients tauX and tauY are enabled. To provide the +backward compatibility, this extra flag should be explicitly specified to make the +calibration function use the tilted sensor model and return 14 coefficients. If the flag is not +set, the function computes and returns only 5 distortion coefficients. +- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during +the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the +supplied distCoeffs matrix is used. Otherwise, it is set to 0. +@param criteria Termination criteria for the iterative optimization algorithm. + +The function estimates the transformation between two cameras making a stereo pair. If one computes +the poses of an object relative to the first camera and to the second camera, +( \f$R_1\f$,\f$T_1\f$ ) and (\f$R_2\f$,\f$T_2\f$), respectively, for a stereo camera where the +relative position and orientation between the two cameras are fixed, then those poses definitely +relate to each other. This means, if the relative position and orientation (\f$R\f$,\f$T\f$) of the +two cameras is known, it is possible to compute (\f$R_2\f$,\f$T_2\f$) when (\f$R_1\f$,\f$T_1\f$) is +given. This is what the described function does. It computes (\f$R\f$,\f$T\f$) such that: + +\f[R_2=R R_1\f] +\f[T_2=R T_1 + T.\f] + +Therefore, one can compute the coordinate representation of a 3D point for the second camera's +coordinate system when given the point's coordinate representation in the first camera's coordinate +system: + +\f[\begin{bmatrix} +X_2 \\ +Y_2 \\ +Z_2 \\ +1 +\end{bmatrix} = \begin{bmatrix} +R & T \\ +0 & 1 +\end{bmatrix} \begin{bmatrix} +X_1 \\ +Y_1 \\ +Z_1 \\ +1 +\end{bmatrix}.\f] + + +Optionally, it computes the essential matrix E: + +\f[E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\f] + +where \f$T_i\f$ are components of the translation vector \f$T\f$ : \f$T=[T_0, T_1, T_2]^T\f$ . +And the function can also compute the fundamental matrix F: + +\f[F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\f] + +Besides the stereo-related information, the function can also perform a full calibration of each of +the two cameras. However, due to the high dimensionality of the parameter space and noise in the +input data, the function can diverge from the correct solution. If the intrinsic parameters can be +estimated with high accuracy for each of the cameras individually (for example, using +#calibrateCamera ), you are recommended to do so and then pass @ref CALIB_FIX_INTRINSIC flag to the +function along with the computed intrinsic parameters. Otherwise, if all the parameters are +estimated at once, it makes sense to restrict some parameters, for example, pass + @ref CALIB_SAME_FOCAL_LENGTH and @ref CALIB_ZERO_TANGENT_DIST flags, which is usually a +reasonable assumption. + +Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the +points in all the available views from both cameras. The function returns the final value of the +re-projection error. + */ +CV_EXPORTS_AS(stereoCalibrateExtended) double stereoCalibrate( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, + InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, + Size imageSize, InputOutputArray R,InputOutputArray T, OutputArray E, OutputArray F, + OutputArray perViewErrors, int flags = CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6) ); + +/// @overload +CV_EXPORTS_W double stereoCalibrate( InputArrayOfArrays objectPoints, + InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1, + InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2, + Size imageSize, OutputArray R,OutputArray T, OutputArray E, OutputArray F, + int flags = CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6) ); + +/** @brief Computes rectification transforms for each head of a calibrated stereo camera. + +@param cameraMatrix1 First camera intrinsic matrix. +@param distCoeffs1 First camera distortion parameters. +@param cameraMatrix2 Second camera intrinsic matrix. +@param distCoeffs2 Second camera distortion parameters. +@param imageSize Size of the image used for stereo calibration. +@param R Rotation matrix from the coordinate system of the first camera to the second camera, +see @ref stereoCalibrate. +@param T Translation vector from the coordinate system of the first camera to the second camera, +see @ref stereoCalibrate. +@param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix +brings points given in the unrectified first camera's coordinate system to points in the rectified +first camera's coordinate system. In more technical terms, it performs a change of basis from the +unrectified first camera's coordinate system to the rectified first camera's coordinate system. +@param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix +brings points given in the unrectified second camera's coordinate system to points in the rectified +second camera's coordinate system. In more technical terms, it performs a change of basis from the +unrectified second camera's coordinate system to the rectified second camera's coordinate system. +@param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first +camera, i.e. it projects points given in the rectified first camera coordinate system into the +rectified first camera's image. +@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second +camera, i.e. it projects points given in the rectified first camera coordinate system into the +rectified second camera's image. +@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see @ref reprojectImageTo3D). +@param flags Operation flags that may be zero or @ref CALIB_ZERO_DISPARITY . If the flag is set, +the function makes the principal points of each camera have the same pixel coordinates in the +rectified views. And if the flag is not set, the function may still shift the images in the +horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the +useful image area. +@param alpha Free scaling parameter. If it is -1 or absent, the function performs the default +scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified +images are zoomed and shifted so that only valid pixels are visible (no black areas after +rectification). alpha=1 means that the rectified image is decimated and shifted so that all the +pixels from the original images from the cameras are retained in the rectified images (no source +image pixels are lost). Any intermediate value yields an intermediate result between +those two extreme cases. +@param newImageSize New image resolution after rectification. The same size should be passed to +#initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) +is passed (default), it is set to the original imageSize . Setting it to a larger value can help you +preserve details in the original image, especially when there is a big radial distortion. +@param validPixROI1 Optional output rectangles inside the rectified images where all the pixels +are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller +(see the picture below). +@param validPixROI2 Optional output rectangles inside the rectified images where all the pixels +are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller +(see the picture below). + +The function computes the rotation matrices for each camera that (virtually) make both camera image +planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies +the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate +as input. As output, it provides two rotation matrices and also two projection matrices in the new +coordinates. The function distinguishes the following two cases: + +- **Horizontal stereo**: the first and the second camera views are shifted relative to each other + mainly along the x-axis (with possible small vertical shift). In the rectified images, the + corresponding epipolar lines in the left and right cameras are horizontal and have the same + y-coordinate. P1 and P2 look like: + + \f[\texttt{P1} = \begin{bmatrix} + f & 0 & cx_1 & 0 \\ + 0 & f & cy & 0 \\ + 0 & 0 & 1 & 0 + \end{bmatrix}\f] + + \f[\texttt{P2} = \begin{bmatrix} + f & 0 & cx_2 & T_x*f \\ + 0 & f & cy & 0 \\ + 0 & 0 & 1 & 0 + \end{bmatrix} ,\f] + + where \f$T_x\f$ is a horizontal shift between the cameras and \f$cx_1=cx_2\f$ if + @ref CALIB_ZERO_DISPARITY is set. + +- **Vertical stereo**: the first and the second camera views are shifted relative to each other + mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar + lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like: + + \f[\texttt{P1} = \begin{bmatrix} + f & 0 & cx & 0 \\ + 0 & f & cy_1 & 0 \\ + 0 & 0 & 1 & 0 + \end{bmatrix}\f] + + \f[\texttt{P2} = \begin{bmatrix} + f & 0 & cx & 0 \\ + 0 & f & cy_2 & T_y*f \\ + 0 & 0 & 1 & 0 + \end{bmatrix},\f] + + where \f$T_y\f$ is a vertical shift between the cameras and \f$cy_1=cy_2\f$ if + @ref CALIB_ZERO_DISPARITY is set. + +As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera +matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to +initialize the rectification map for each camera. + +See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through +the corresponding image regions. This means that the images are well rectified, which is what most +stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that +their interiors are all valid pixels. + +![image](pics/stereo_undistort.jpg) + */ +CV_EXPORTS_W void stereoRectify( InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + Size imageSize, InputArray R, InputArray T, + OutputArray R1, OutputArray R2, + OutputArray P1, OutputArray P2, + OutputArray Q, int flags = CALIB_ZERO_DISPARITY, + double alpha = -1, Size newImageSize = Size(), + CV_OUT Rect* validPixROI1 = 0, CV_OUT Rect* validPixROI2 = 0 ); + +/** @brief Computes a rectification transform for an uncalibrated stereo camera. + +@param points1 Array of feature points in the first image. +@param points2 The corresponding points in the second image. The same formats as in +#findFundamentalMat are supported. +@param F Input fundamental matrix. It can be computed from the same set of point pairs using +#findFundamentalMat . +@param imgSize Size of the image. +@param H1 Output rectification homography matrix for the first image. +@param H2 Output rectification homography matrix for the second image. +@param threshold Optional threshold used to filter out the outliers. If the parameter is greater +than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points +for which \f$|\texttt{points2[i]}^T*\texttt{F}*\texttt{points1[i]}|>\texttt{threshold}\f$ ) are +rejected prior to computing the homographies. Otherwise, all the points are considered inliers. + +The function computes the rectification transformations without knowing intrinsic parameters of the +cameras and their relative position in the space, which explains the suffix "uncalibrated". Another +related difference from #stereoRectify is that the function outputs not the rectification +transformations in the object (3D) space, but the planar perspective transformations encoded by the +homography matrices H1 and H2 . The function implements the algorithm @cite Hartley99 . + +@note + While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily + depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion, + it would be better to correct it before computing the fundamental matrix and calling this + function. For example, distortion coefficients can be estimated for each head of stereo camera + separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or + just the point coordinates can be corrected with #undistortPoints . + */ +CV_EXPORTS_W bool stereoRectifyUncalibrated( InputArray points1, InputArray points2, + InputArray F, Size imgSize, + OutputArray H1, OutputArray H2, + double threshold = 5 ); + +//! computes the rectification transformations for 3-head camera, where all the heads are on the same line. +CV_EXPORTS_W float rectify3Collinear( InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + InputArray cameraMatrix3, InputArray distCoeffs3, + InputArrayOfArrays imgpt1, InputArrayOfArrays imgpt3, + Size imageSize, InputArray R12, InputArray T12, + InputArray R13, InputArray T13, + OutputArray R1, OutputArray R2, OutputArray R3, + OutputArray P1, OutputArray P2, OutputArray P3, + OutputArray Q, double alpha, Size newImgSize, + CV_OUT Rect* roi1, CV_OUT Rect* roi2, int flags ); + +/** @brief Returns the new camera intrinsic matrix based on the free scaling parameter. + +@param cameraMatrix Input camera intrinsic matrix. +@param distCoeffs Input vector of distortion coefficients +\f$\distcoeffs\f$. If the vector is NULL/empty, the zero distortion coefficients are +assumed. +@param imageSize Original image size. +@param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are +valid) and 1 (when all the source image pixels are retained in the undistorted image). See +#stereoRectify for details. +@param newImgSize Image size after rectification. By default, it is set to imageSize . +@param validPixROI Optional output rectangle that outlines all-good-pixels region in the +undistorted image. See roi1, roi2 description in #stereoRectify . +@param centerPrincipalPoint Optional flag that indicates whether in the new camera intrinsic matrix the +principal point should be at the image center or not. By default, the principal point is chosen to +best fit a subset of the source image (determined by alpha) to the corrected image. +@return new_camera_matrix Output new camera intrinsic matrix. + +The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter. +By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original +image pixels if there is valuable information in the corners alpha=1 , or get something in between. +When alpha\>0 , the undistorted result is likely to have some black pixels corresponding to +"virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion +coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to +#initUndistortRectifyMap to produce the maps for #remap . + */ +CV_EXPORTS_W Mat getOptimalNewCameraMatrix( InputArray cameraMatrix, InputArray distCoeffs, + Size imageSize, double alpha, Size newImgSize = Size(), + CV_OUT Rect* validPixROI = 0, + bool centerPrincipalPoint = false); + +/** @brief Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$ + +@param[in] R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from gripper frame to robot base frame. +@param[in] t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from gripper frame to robot base frame. +@param[in] R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from calibration target frame to camera frame. +@param[in] t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from calibration target frame to camera frame. +@param[out] R_cam2gripper Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point +expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$). +@param[out] t_cam2gripper Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point +expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$). +@param[in] method One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod + +The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the +rotation then the translation (separable solutions) and the following methods are implemented: + - R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89 + - F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94 + - R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95 + +Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions), +with the following implemented methods: + - N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99 + - K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98 + +The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye") +mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand. + +The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot +end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting +the suitable transformations to the function, see below. + +![](pics/hand-eye_figure.png) + +The calibration procedure is the following: + - a static calibration pattern is used to estimate the transformation between the target frame + and the camera frame + - the robot gripper is moved in order to acquire several poses + - for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for + instance the robot kinematics +\f[ + \begin{bmatrix} + X_b\\ + Y_b\\ + Z_b\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} +\f] + - for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using + for instance a pose estimation method (PnP) from 2D-3D point correspondences +\f[ + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_t\\ + Y_t\\ + Z_t\\ + 1 + \end{bmatrix} +\f] + +The Hand-Eye calibration procedure returns the following homogeneous transformation +\f[ + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} +\f] + +This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\f$ equation: + - for an eye-in-hand configuration +\f[ + \begin{align*} + ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= + \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ + + (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &= + \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\ + + \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\ + \end{align*} +\f] + + - for an eye-to-hand configuration +\f[ + \begin{align*} + ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= + \hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ + + (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &= + \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\ + + \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\ + \end{align*} +\f] + +\note +Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration). +\note +A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation. +So at least 3 different poses are required, but it is strongly recommended to use many more poses. + + */ +CV_EXPORTS_W void calibrateHandEye( InputArrayOfArrays R_gripper2base, InputArrayOfArrays t_gripper2base, + InputArrayOfArrays R_target2cam, InputArrayOfArrays t_target2cam, + OutputArray R_cam2gripper, OutputArray t_cam2gripper, + HandEyeCalibrationMethod method=CALIB_HAND_EYE_TSAI ); + +/** @brief Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$ + +@param[in] R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from world frame to the camera frame. +@param[in] t_world2cam Translation part extracted from the homogeneous matrix that transforms a point +expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from world frame to the camera frame. +@param[in] R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). +This is a vector (`vector`) that contains the rotation, `(3x3)` rotation matrices or `(3x1)` rotation vectors, +for all the transformations from robot base frame to the gripper frame. +@param[in] t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). +This is a vector (`vector`) that contains the `(3x1)` translation vectors for all the transformations +from robot base frame to the gripper frame. +@param[out] R_base2world Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$). +@param[out] t_base2world Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point +expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$). +@param[out] R_gripper2cam Estimated `(3x3)` rotation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$). +@param[out] t_gripper2cam Estimated `(3x1)` translation part extracted from the homogeneous matrix that transforms a point +expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$). +@param[in] method One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod + +The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the +rotation then the translation (separable solutions): + - M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR + +Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions), +with the following implemented method: + - A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA + +The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame +and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated. + +![](pics/robot-world_hand-eye_figure.png) + +The calibration procedure is the following: + - a static calibration pattern is used to estimate the transformation between the target frame + and the camera frame + - the robot gripper is moved in order to acquire several poses + - for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for + instance the robot kinematics +\f[ + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_b\\ + Y_b\\ + Z_b\\ + 1 + \end{bmatrix} +\f] + - for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using + for instance a pose estimation method (PnP) from 2D-3D point correspondences +\f[ + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_w\\ + Y_w\\ + Z_w\\ + 1 + \end{bmatrix} +\f] + +The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations +\f[ + \begin{bmatrix} + X_w\\ + Y_w\\ + Z_w\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{w}\textrm{R}_b & _{}^{w}\textrm{t}_b \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_b\\ + Y_b\\ + Z_b\\ + 1 + \end{bmatrix} +\f] +\f[ + \begin{bmatrix} + X_c\\ + Y_c\\ + Z_c\\ + 1 + \end{bmatrix} + = + \begin{bmatrix} + _{}^{c}\textrm{R}_g & _{}^{c}\textrm{t}_g \\ + 0_{1 \times 3} & 1 + \end{bmatrix} + \begin{bmatrix} + X_g\\ + Y_g\\ + Z_g\\ + 1 + \end{bmatrix} +\f] + +This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\f$ equation, with: + - \f$\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\f$ + - \f$\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\f$ + - \f$\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\f$ + - \f$\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\f$ + +\note +At least 3 measurements are required (input vectors size must be greater or equal to 3). + + */ +CV_EXPORTS_W void calibrateRobotWorldHandEye( InputArrayOfArrays R_world2cam, InputArrayOfArrays t_world2cam, + InputArrayOfArrays R_base2gripper, InputArrayOfArrays t_base2gripper, + OutputArray R_base2world, OutputArray t_base2world, + OutputArray R_gripper2cam, OutputArray t_gripper2cam, + RobotWorldHandEyeCalibrationMethod method=CALIB_ROBOT_WORLD_HAND_EYE_SHAH ); + +/** @brief Converts points from Euclidean to homogeneous space. + +@param src Input vector of N-dimensional points. +@param dst Output vector of N+1-dimensional points. + +The function converts points from Euclidean to homogeneous space by appending 1's to the tuple of +point coordinates. That is, each point (x1, x2, ..., xn) is converted to (x1, x2, ..., xn, 1). + */ +CV_EXPORTS_W void convertPointsToHomogeneous( InputArray src, OutputArray dst ); + +/** @brief Converts points from homogeneous to Euclidean space. + +@param src Input vector of N-dimensional points. +@param dst Output vector of N-1-dimensional points. + +The function converts points homogeneous to Euclidean space using perspective projection. That is, +each point (x1, x2, ... x(n-1), xn) is converted to (x1/xn, x2/xn, ..., x(n-1)/xn). When xn=0, the +output point coordinates will be (0,0,0,...). + */ +CV_EXPORTS_W void convertPointsFromHomogeneous( InputArray src, OutputArray dst ); + +/** @brief Converts points to/from homogeneous coordinates. + +@param src Input array or vector of 2D, 3D, or 4D points. +@param dst Output vector of 2D, 3D, or 4D points. + +The function converts 2D or 3D points from/to homogeneous coordinates by calling either +#convertPointsToHomogeneous or #convertPointsFromHomogeneous. + +@note The function is obsolete. Use one of the previous two functions instead. + */ +CV_EXPORTS void convertPointsHomogeneous( InputArray src, OutputArray dst ); + +/** @brief Calculates a fundamental matrix from the corresponding points in two images. + +@param points1 Array of N points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param method Method for computing a fundamental matrix. +- @ref FM_7POINT for a 7-point algorithm. \f$N = 7\f$ +- @ref FM_8POINT for an 8-point algorithm. \f$N \ge 8\f$ +- @ref FM_RANSAC for the RANSAC algorithm. \f$N \ge 8\f$ +- @ref FM_LMEDS for the LMedS algorithm. \f$N \ge 8\f$ +@param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level +of confidence (probability) that the estimated matrix is correct. +@param[out] mask optional output mask +@param maxIters The maximum number of robust method iterations. + +The epipolar geometry is described by the following equation: + +\f[[p_2; 1]^T F [p_1; 1] = 0\f] + +where \f$F\f$ is a fundamental matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the +second images, respectively. + +The function calculates the fundamental matrix using one of four methods listed above and returns +the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point +algorithm, the function may return up to 3 solutions ( \f$9 \times 3\f$ matrix that stores all 3 +matrices sequentially). + +The calculated fundamental matrix may be passed further to computeCorrespondEpilines that finds the +epipolar lines corresponding to the specified points. It can also be passed to +#stereoRectifyUncalibrated to compute the rectification transformation. : +@code + // Example. Estimation of fundamental matrix using the RANSAC algorithm + int point_count = 100; + vector points1(point_count); + vector points2(point_count); + + // initialize the points here ... + for( int i = 0; i < point_count; i++ ) + { + points1[i] = ...; + points2[i] = ...; + } + + Mat fundamental_matrix = + findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99); +@endcode + */ +CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2, + int method, double ransacReprojThreshold, double confidence, + int maxIters, OutputArray mask = noArray() ); + +/** @overload */ +CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2, + int method = FM_RANSAC, + double ransacReprojThreshold = 3., double confidence = 0.99, + OutputArray mask = noArray() ); + +/** @overload */ +CV_EXPORTS Mat findFundamentalMat( InputArray points1, InputArray points2, + OutputArray mask, int method = FM_RANSAC, + double ransacReprojThreshold = 3., double confidence = 0.99 ); + + +CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2, + OutputArray mask, const UsacParams ¶ms); + +/** @brief Calculates an essential matrix from the corresponding points in two images. + +@param points1 Array of N (N \>= 5) 2D points from the first image. The point coordinates should +be floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera intrinsic matrix. If this assumption does not hold for your use case, use +#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points +to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When +passing these coordinates, pass the identity matrix for this parameter. +@param method Method for computing an essential matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 +for the other points. The array is computed only in the RANSAC and LMedS methods. +@param maxIters The maximum number of robust method iterations. + +This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 . +@cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation: + +\f[[p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\f] + +where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the +second images, respectively. The result of this function may be passed further to +#decomposeEssentialMat or #recoverPose to recover the relative pose between cameras. + */ +CV_EXPORTS_W +Mat findEssentialMat( + InputArray points1, InputArray points2, + InputArray cameraMatrix, int method = RANSAC, + double prob = 0.999, double threshold = 1.0, + int maxIters = 1000, OutputArray mask = noArray() +); + +/** @overload */ +CV_EXPORTS +Mat findEssentialMat( + InputArray points1, InputArray points2, + InputArray cameraMatrix, int method, + double prob, double threshold, + OutputArray mask +); // TODO remove from OpenCV 5.0 + +/** @overload +@param points1 Array of N (N \>= 5) 2D points from the first image. The point coordinates should +be floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param focal focal length of the camera. Note that this function assumes that points1 and points2 +are feature points from cameras with same focal length and principal point. +@param pp principal point of the camera. +@param method Method for computing a fundamental matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 +for the other points. The array is computed only in the RANSAC and LMedS methods. +@param maxIters The maximum number of robust method iterations. + +This function differs from the one above that it computes camera intrinsic matrix from focal length and +principal point: + +\f[A = +\begin{bmatrix} +f & 0 & x_{pp} \\ +0 & f & y_{pp} \\ +0 & 0 & 1 +\end{bmatrix}\f] + */ +CV_EXPORTS_W +Mat findEssentialMat( + InputArray points1, InputArray points2, + double focal = 1.0, Point2d pp = Point2d(0, 0), + int method = RANSAC, double prob = 0.999, + double threshold = 1.0, int maxIters = 1000, + OutputArray mask = noArray() +); + +/** @overload */ +CV_EXPORTS +Mat findEssentialMat( + InputArray points1, InputArray points2, + double focal, Point2d pp, + int method, double prob, + double threshold, OutputArray mask +); // TODO remove from OpenCV 5.0 + +/** @brief Calculates an essential matrix from the corresponding points in two images from potentially two different cameras. + +@param points1 Array of N (N \>= 5) 2D points from the first image. The point coordinates should +be floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix1 Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera matrix. If this assumption does not hold for your use case, use +#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points +to normalized image coordinates, which are valid for the identity camera matrix. When +passing these coordinates, pass the identity matrix for this parameter. +@param cameraMatrix2 Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera matrix. If this assumption does not hold for your use case, use +#undistortPoints with `P = cv::NoArray()` for both cameras to transform image points +to normalized image coordinates, which are valid for the identity camera matrix. When +passing these coordinates, pass the identity matrix for this parameter. +@param distCoeffs1 Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param distCoeffs2 Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param method Method for computing an essential matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1 +for the other points. The array is computed only in the RANSAC and LMedS methods. + +This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 . +@cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation: + +\f[[p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\f] + +where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding points in the first and the +second images, respectively. The result of this function may be passed further to +#decomposeEssentialMat or #recoverPose to recover the relative pose between cameras. + */ +CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2, + InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + int method = RANSAC, + double prob = 0.999, double threshold = 1.0, + OutputArray mask = noArray() ); + + +CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2, + InputArray cameraMatrix1, InputArray cameraMatrix2, + InputArray dist_coeff1, InputArray dist_coeff2, OutputArray mask, + const UsacParams ¶ms); + +/** @brief Decompose an essential matrix to possible rotations and translation. + +@param E The input essential matrix. +@param R1 One possible rotation matrix. +@param R2 Another possible rotation matrix. +@param t One possible translation. + +This function decomposes the essential matrix E using svd decomposition @cite HartleyZ00. In +general, four possible poses exist for the decomposition of E. They are \f$[R_1, t]\f$, +\f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$. + +If E gives the epipolar constraint \f$[p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\f$ between the image +points \f$p_1\f$ in the first image and \f$p_2\f$ in second image, then any of the tuples +\f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$ is a change of basis from the first +camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one +can only get the direction of the translation. For this reason, the translation t is returned with +unit length. + */ +CV_EXPORTS_W void decomposeEssentialMat( InputArray E, OutputArray R1, OutputArray R2, OutputArray t ); + +/** @brief Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of +inliers that pass the check. + +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix1 Input/output camera matrix for the first camera, the same as in +@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below. +@param distCoeffs1 Input/output vector of distortion coefficients, the same as in +@ref calibrateCamera. +@param cameraMatrix2 Input/output camera matrix for the first camera, the same as in +@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below. +@param distCoeffs2 Input/output vector of distortion coefficients, the same as in +@ref calibrateCamera. +@param E The output essential matrix. +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +described below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param method Method for computing an essential matrix. +- @ref RANSAC for the RANSAC algorithm. +- @ref LMEDS for the LMedS algorithm. +@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of +confidence (probability) that the estimated matrix is correct. +@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar +line in pixels, beyond which the point is considered an outlier and is not used for computing the +final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the +point localization, image resolution, and the image noise. +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. + +This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies +possible pose hypotheses by doing cheirality check. The cheirality check means that the +triangulated 3D points should have positive depth. Some details can be found in @cite Nister03. + +This function can be used to process the output E and mask from @ref findEssentialMat. In this +scenario, points1 and points2 are the same input for findEssentialMat.: +@code + // Example. Estimation of fundamental matrix using the RANSAC algorithm + int point_count = 100; + vector points1(point_count); + vector points2(point_count); + + // initialize the points here ... + for( int i = 0; i < point_count; i++ ) + { + points1[i] = ...; + points2[i] = ...; + } + + // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration. + Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2; + + // Output: Essential matrix, relative rotation and relative translation. + Mat E, R, t, mask; + + recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask); +@endcode + */ +CV_EXPORTS_W int recoverPose( InputArray points1, InputArray points2, + InputArray cameraMatrix1, InputArray distCoeffs1, + InputArray cameraMatrix2, InputArray distCoeffs2, + OutputArray E, OutputArray R, OutputArray t, + int method = cv::RANSAC, double prob = 0.999, double threshold = 1.0, + InputOutputArray mask = noArray()); + +/** @brief Recovers the relative camera rotation and the translation from an estimated essential +matrix and the corresponding points in two images, using cheirality check. Returns the number of +inliers that pass the check. + +@param E The input essential matrix. +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera intrinsic matrix. +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +described below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. + +This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies +possible pose hypotheses by doing cheirality check. The cheirality check means that the +triangulated 3D points should have positive depth. Some details can be found in @cite Nister03. + +This function can be used to process the output E and mask from @ref findEssentialMat. In this +scenario, points1 and points2 are the same input for #findEssentialMat : +@code + // Example. Estimation of fundamental matrix using the RANSAC algorithm + int point_count = 100; + vector points1(point_count); + vector points2(point_count); + + // initialize the points here ... + for( int i = 0; i < point_count; i++ ) + { + points1[i] = ...; + points2[i] = ...; + } + + // cametra matrix with both focal lengths = 1, and principal point = (0, 0) + Mat cameraMatrix = Mat::eye(3, 3, CV_64F); + + Mat E, R, t, mask; + + E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask); + recoverPose(E, points1, points2, cameraMatrix, R, t, mask); +@endcode + */ +CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, + InputArray cameraMatrix, OutputArray R, OutputArray t, + InputOutputArray mask = noArray() ); + +/** @overload +@param E The input essential matrix. +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1 . +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +description below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param focal Focal length of the camera. Note that this function assumes that points1 and points2 +are feature points from cameras with same focal length and principal point. +@param pp principal point of the camera. +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. + +This function differs from the one above that it computes camera intrinsic matrix from focal length and +principal point: + +\f[A = +\begin{bmatrix} +f & 0 & x_{pp} \\ +0 & f & y_{pp} \\ +0 & 0 & 1 +\end{bmatrix}\f] + */ +CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, + OutputArray R, OutputArray t, + double focal = 1.0, Point2d pp = Point2d(0, 0), + InputOutputArray mask = noArray() ); + +/** @overload +@param E The input essential matrix. +@param points1 Array of N 2D points from the first image. The point coordinates should be +floating-point (single or double precision). +@param points2 Array of the second image points of the same size and format as points1. +@param cameraMatrix Camera intrinsic matrix \f$\cameramatrix{A}\f$ . +Note that this function assumes that points1 and points2 are feature points from cameras with the +same camera intrinsic matrix. +@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple +that performs a change of basis from the first camera's coordinate system to the second camera's +coordinate system. Note that, in general, t can not be used for this tuple, see the parameter +description below. +@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and +therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit +length. +@param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite +points). +@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks +inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to +recover pose. In the output mask only inliers which pass the cheirality check. +@param triangulatedPoints 3D points which were reconstructed by triangulation. + +This function differs from the one above that it outputs the triangulated 3D point that are used for +the cheirality check. + */ +CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2, + InputArray cameraMatrix, OutputArray R, OutputArray t, double distanceThresh, InputOutputArray mask = noArray(), + OutputArray triangulatedPoints = noArray()); + +/** @brief For points in an image of a stereo pair, computes the corresponding epilines in the other image. + +@param points Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or +vector\ . +@param whichImage Index of the image (1 or 2) that contains the points . +@param F Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify . +@param lines Output vector of the epipolar lines corresponding to the points in the other image. +Each line \f$ax + by + c=0\f$ is encoded by 3 numbers \f$(a, b, c)\f$ . + +For every point in one of the two images of a stereo pair, the function finds the equation of the +corresponding epipolar line in the other image. + +From the fundamental matrix definition (see #findFundamentalMat ), line \f$l^{(2)}_i\f$ in the second +image for the point \f$p^{(1)}_i\f$ in the first image (when whichImage=1 ) is computed as: + +\f[l^{(2)}_i = F p^{(1)}_i\f] + +And vice versa, when whichImage=2, \f$l^{(1)}_i\f$ is computed from \f$p^{(2)}_i\f$ as: + +\f[l^{(1)}_i = F^T p^{(2)}_i\f] + +Line coefficients are defined up to a scale. They are normalized so that \f$a_i^2+b_i^2=1\f$ . + */ +CV_EXPORTS_W void computeCorrespondEpilines( InputArray points, int whichImage, + InputArray F, OutputArray lines ); + +/** @brief This function reconstructs 3-dimensional points (in homogeneous coordinates) by using +their observations with a stereo camera. + +@param projMatr1 3x4 projection matrix of the first camera, i.e. this matrix projects 3D points +given in the world's coordinate system into the first image. +@param projMatr2 3x4 projection matrix of the second camera, i.e. this matrix projects 3D points +given in the world's coordinate system into the second image. +@param projPoints1 2xN array of feature points in the first image. In the case of the c++ version, +it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1. +@param projPoints2 2xN array of corresponding points in the second image. In the case of the c++ +version, it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1. +@param points4D 4xN array of reconstructed points in homogeneous coordinates. These points are +returned in the world's coordinate system. + +@note + Keep in mind that all input data should be of float type in order for this function to work. + +@note + If the projection matrices from @ref stereoRectify are used, then the returned points are + represented in the first camera's rectified coordinate system. + +@sa + reprojectImageTo3D + */ +CV_EXPORTS_W void triangulatePoints( InputArray projMatr1, InputArray projMatr2, + InputArray projPoints1, InputArray projPoints2, + OutputArray points4D ); + +/** @brief Refines coordinates of corresponding points. + +@param F 3x3 fundamental matrix. +@param points1 1xN array containing the first set of points. +@param points2 1xN array containing the second set of points. +@param newPoints1 The optimized points1. +@param newPoints2 The optimized points2. + +The function implements the Optimal Triangulation Method (see Multiple View Geometry for details). +For each given point correspondence points1[i] \<-\> points2[i], and a fundamental matrix F, it +computes the corrected correspondences newPoints1[i] \<-\> newPoints2[i] that minimize the geometric +error \f$d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\f$ (where \f$d(a,b)\f$ is the +geometric distance between points \f$a\f$ and \f$b\f$ ) subject to the epipolar constraint +\f$newPoints2^T * F * newPoints1 = 0\f$ . + */ +CV_EXPORTS_W void correctMatches( InputArray F, InputArray points1, InputArray points2, + OutputArray newPoints1, OutputArray newPoints2 ); + +/** @brief Filters off small noise blobs (speckles) in the disparity map + +@param img The input 16-bit signed disparity image +@param newVal The disparity value used to paint-off the speckles +@param maxSpeckleSize The maximum speckle size to consider it a speckle. Larger blobs are not +affected by the algorithm +@param maxDiff Maximum difference between neighbor disparity pixels to put them into the same +blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point +disparity map, where disparity values are multiplied by 16, this scale factor should be taken into +account when specifying this parameter value. +@param buf The optional temporary buffer to avoid memory allocation within the function. + */ +CV_EXPORTS_W void filterSpeckles( InputOutputArray img, double newVal, + int maxSpeckleSize, double maxDiff, + InputOutputArray buf = noArray() ); + +//! computes valid disparity ROI from the valid ROIs of the rectified images (that are returned by #stereoRectify) +CV_EXPORTS_W Rect getValidDisparityROI( Rect roi1, Rect roi2, + int minDisparity, int numberOfDisparities, + int blockSize ); + +//! validates disparity using the left-right check. The matrix "cost" should be computed by the stereo correspondence algorithm +CV_EXPORTS_W void validateDisparity( InputOutputArray disparity, InputArray cost, + int minDisparity, int numberOfDisparities, + int disp12MaxDisp = 1 ); + +/** @brief Reprojects a disparity image to 3D space. + +@param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit +floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no +fractional bits. If the disparity is 16-bit signed format, as computed by @ref StereoBM or +@ref StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before +being used here. +@param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of +_3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one +uses Q obtained by @ref stereoRectify, then the returned points are represented in the first +camera's rectified coordinate system. +@param Q \f$4 \times 4\f$ perspective transformation matrix that can be obtained with +@ref stereoRectify. +@param handleMissingValues Indicates, whether the function should handle missing values (i.e. +points where the disparity was not computed). If handleMissingValues=true, then pixels with the +minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed +to 3D points with a very large Z value (currently set to 10000). +@param ddepth The optional output array depth. If it is -1, the output image will have CV_32F +depth. ddepth can also be set to CV_16S, CV_32S or CV_32F. + +The function transforms a single-channel disparity map to a 3-channel image representing a 3D +surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it +computes: + +\f[\begin{bmatrix} +X \\ +Y \\ +Z \\ +W +\end{bmatrix} = Q \begin{bmatrix} +x \\ +y \\ +\texttt{disparity} (x,y) \\ +z +\end{bmatrix}.\f] + +@sa + To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform. + */ +CV_EXPORTS_W void reprojectImageTo3D( InputArray disparity, + OutputArray _3dImage, InputArray Q, + bool handleMissingValues = false, + int ddepth = -1 ); + +/** @brief Calculates the Sampson Distance between two points. + +The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as: +\f[ +sd( \texttt{pt1} , \texttt{pt2} )= +\frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2} +{((\texttt{F} \cdot \texttt{pt1})(0))^2 + +((\texttt{F} \cdot \texttt{pt1})(1))^2 + +((\texttt{F}^t \cdot \texttt{pt2})(0))^2 + +((\texttt{F}^t \cdot \texttt{pt2})(1))^2} +\f] +The fundamental matrix may be calculated using the #findFundamentalMat function. See @cite HartleyZ00 11.4.3 for details. +@param pt1 first homogeneous 2d point +@param pt2 second homogeneous 2d point +@param F fundamental matrix +@return The computed Sampson distance. +*/ +CV_EXPORTS_W double sampsonDistance(InputArray pt1, InputArray pt2, InputArray F); + +/** @brief Computes an optimal affine transformation between two 3D point sets. + +It computes +\f[ +\begin{bmatrix} +x\\ +y\\ +z\\ +\end{bmatrix} += +\begin{bmatrix} +a_{11} & a_{12} & a_{13}\\ +a_{21} & a_{22} & a_{23}\\ +a_{31} & a_{32} & a_{33}\\ +\end{bmatrix} +\begin{bmatrix} +X\\ +Y\\ +Z\\ +\end{bmatrix} ++ +\begin{bmatrix} +b_1\\ +b_2\\ +b_3\\ +\end{bmatrix} +\f] + +@param src First input 3D point set containing \f$(X,Y,Z)\f$. +@param dst Second input 3D point set containing \f$(x,y,z)\f$. +@param out Output 3D affine transformation matrix \f$3 \times 4\f$ of the form +\f[ +\begin{bmatrix} +a_{11} & a_{12} & a_{13} & b_1\\ +a_{21} & a_{22} & a_{23} & b_2\\ +a_{31} & a_{32} & a_{33} & b_3\\ +\end{bmatrix} +\f] +@param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier). +@param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as +an inlier. +@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything +between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation +significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. + +The function estimates an optimal 3D affine transformation between two 3D point sets using the +RANSAC algorithm. + */ +CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst, + OutputArray out, OutputArray inliers, + double ransacThreshold = 3, double confidence = 0.99); + +/** @brief Computes an optimal affine transformation between two 3D point sets. + +It computes \f$R,s,t\f$ minimizing \f$\sum{i} dst_i - c \cdot R \cdot src_i \f$ +where \f$R\f$ is a 3x3 rotation matrix, \f$t\f$ is a 3x1 translation vector and \f$s\f$ is a +scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least . +The estimated affine transform has a homogeneous scale which is a subclass of affine +transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3 +points each. + +@param src First input 3D point set. +@param dst Second input 3D point set. +@param scale If null is passed, the scale parameter c will be assumed to be 1.0. +Else the pointed-to variable will be set to the optimal scale. +@param force_rotation If true, the returned rotation will never be a reflection. +This might be unwanted, e.g. when optimizing a transform between a right- and a +left-handed coordinate system. +@return 3D affine transformation matrix \f$3 \times 4\f$ of the form +\f[T = +\begin{bmatrix} +R & t\\ +\end{bmatrix} +\f] + + */ +CV_EXPORTS_W cv::Mat estimateAffine3D(InputArray src, InputArray dst, + CV_OUT double* scale = nullptr, bool force_rotation = true); + +/** @brief Computes an optimal translation between two 3D point sets. + * + * It computes + * \f[ + * \begin{bmatrix} + * x\\ + * y\\ + * z\\ + * \end{bmatrix} + * = + * \begin{bmatrix} + * X\\ + * Y\\ + * Z\\ + * \end{bmatrix} + * + + * \begin{bmatrix} + * b_1\\ + * b_2\\ + * b_3\\ + * \end{bmatrix} + * \f] + * + * @param src First input 3D point set containing \f$(X,Y,Z)\f$. + * @param dst Second input 3D point set containing \f$(x,y,z)\f$. + * @param out Output 3D translation vector \f$3 \times 1\f$ of the form + * \f[ + * \begin{bmatrix} + * b_1 \\ + * b_2 \\ + * b_3 \\ + * \end{bmatrix} + * \f] + * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier). + * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as + * an inlier. + * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything + * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation + * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. + * + * The function estimates an optimal 3D translation between two 3D point sets using the + * RANSAC algorithm. + * */ +CV_EXPORTS_W int estimateTranslation3D(InputArray src, InputArray dst, + OutputArray out, OutputArray inliers, + double ransacThreshold = 3, double confidence = 0.99); + +/** @brief Computes an optimal affine transformation between two 2D point sets. + +It computes +\f[ +\begin{bmatrix} +x\\ +y\\ +\end{bmatrix} += +\begin{bmatrix} +a_{11} & a_{12}\\ +a_{21} & a_{22}\\ +\end{bmatrix} +\begin{bmatrix} +X\\ +Y\\ +\end{bmatrix} ++ +\begin{bmatrix} +b_1\\ +b_2\\ +\end{bmatrix} +\f] + +@param from First input 2D point set containing \f$(X,Y)\f$. +@param to Second input 2D point set containing \f$(x,y)\f$. +@param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier). +@param method Robust method used to compute transformation. The following methods are possible: +- @ref RANSAC - RANSAC-based robust method +- @ref LMEDS - Least-Median robust method +RANSAC is the default method. +@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider +a point as an inlier. Applies only to RANSAC. +@param maxIters The maximum number of robust method iterations. +@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything +between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation +significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. +@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt). +Passing 0 will disable refining, so the output matrix will be output of robust method. + +@return Output 2D affine transformation matrix \f$2 \times 3\f$ or empty matrix if transformation +could not be estimated. The returned matrix has the following form: +\f[ +\begin{bmatrix} +a_{11} & a_{12} & b_1\\ +a_{21} & a_{22} & b_2\\ +\end{bmatrix} +\f] + +The function estimates an optimal 2D affine transformation between two 2D point sets using the +selected robust algorithm. + +The computed transformation is then refined further (using only inliers) with the +Levenberg-Marquardt method to reduce the re-projection error even more. + +@note +The RANSAC method can handle practically any ratio of outliers but needs a threshold to +distinguish inliers from outliers. The method LMeDS does not need any threshold but it works +correctly only when there are more than 50% of inliers. + +@sa estimateAffinePartial2D, getAffineTransform +*/ +CV_EXPORTS_W cv::Mat estimateAffine2D(InputArray from, InputArray to, OutputArray inliers = noArray(), + int method = RANSAC, double ransacReprojThreshold = 3, + size_t maxIters = 2000, double confidence = 0.99, + size_t refineIters = 10); + + +CV_EXPORTS_W cv::Mat estimateAffine2D(InputArray pts1, InputArray pts2, OutputArray inliers, + const UsacParams ¶ms); + +/** @brief Computes an optimal limited affine transformation with 4 degrees of freedom between +two 2D point sets. + +@param from First input 2D point set. +@param to Second input 2D point set. +@param inliers Output vector indicating which points are inliers. +@param method Robust method used to compute transformation. The following methods are possible: +- @ref RANSAC - RANSAC-based robust method +- @ref LMEDS - Least-Median robust method +RANSAC is the default method. +@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider +a point as an inlier. Applies only to RANSAC. +@param maxIters The maximum number of robust method iterations. +@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything +between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation +significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation. +@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt). +Passing 0 will disable refining, so the output matrix will be output of robust method. + +@return Output 2D affine transformation (4 degrees of freedom) matrix \f$2 \times 3\f$ or +empty matrix if transformation could not be estimated. + +The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to +combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust +estimation. + +The computed transformation is then refined further (using only inliers) with the +Levenberg-Marquardt method to reduce the re-projection error even more. + +Estimated transformation matrix is: +\f[ \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\ + \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y +\end{bmatrix} \f] +Where \f$ \theta \f$ is the rotation angle, \f$ s \f$ the scaling factor and \f$ t_x, t_y \f$ are +translations in \f$ x, y \f$ axes respectively. + +@note +The RANSAC method can handle practically any ratio of outliers but need a threshold to +distinguish inliers from outliers. The method LMeDS does not need any threshold but it works +correctly only when there are more than 50% of inliers. + +@sa estimateAffine2D, getAffineTransform +*/ +CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, OutputArray inliers = noArray(), + int method = RANSAC, double ransacReprojThreshold = 3, + size_t maxIters = 2000, double confidence = 0.99, + size_t refineIters = 10); + +/** @example samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp +An example program with homography decomposition. + +Check @ref tutorial_homography "the corresponding tutorial" for more details. +*/ + +/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s). + +@param H The input homography matrix between two images. +@param K The input camera intrinsic matrix. +@param rotations Array of rotation matrices. +@param translations Array of translation matrices. +@param normals Array of plane normal matrices. + +This function extracts relative camera motion between two views of a planar object and returns up to +four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of +the homography matrix H is described in detail in @cite Malis. + +If the homography H, induced by the plane, gives the constraint +\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] on the source image points +\f$p_i\f$ and the destination image points \f$p'_i\f$, then the tuple of rotations[k] and +translations[k] is a change of basis from the source camera's coordinate system to the destination +camera's coordinate system. However, by decomposing H, one can only get the translation normalized +by the (typically unknown) depth of the scene, i.e. its direction but with normalized length. + +If point correspondences are available, at least two solutions may further be invalidated, by +applying positive depth constraint, i.e. all points must be in front of the camera. + */ +CV_EXPORTS_W int decomposeHomographyMat(InputArray H, + InputArray K, + OutputArrayOfArrays rotations, + OutputArrayOfArrays translations, + OutputArrayOfArrays normals); + +/** @brief Filters homography decompositions based on additional information. + +@param rotations Vector of rotation matrices. +@param normals Vector of plane normal matrices. +@param beforePoints Vector of (rectified) visible reference points before the homography is applied +@param afterPoints Vector of (rectified) visible reference points after the homography is applied +@param possibleSolutions Vector of int indices representing the viable solution set after filtering +@param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function + +This function is intended to filter the output of the #decomposeHomographyMat based on additional +information as described in @cite Malis . The summary of the method: the #decomposeHomographyMat function +returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the +sets of points visible in the camera frame before and after the homography transformation is applied, +we can determine which are the true potential solutions and which are the opposites by verifying which +homographies are consistent with all visible reference points being in front of the camera. The inputs +are left unchanged; the filtered solution set is returned as indices into the existing one. + +*/ +CV_EXPORTS_W void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays rotations, + InputArrayOfArrays normals, + InputArray beforePoints, + InputArray afterPoints, + OutputArray possibleSolutions, + InputArray pointsMask = noArray()); + +/** @brief The base class for stereo correspondence algorithms. + */ +class CV_EXPORTS_W StereoMatcher : public Algorithm +{ +public: + enum { DISP_SHIFT = 4, + DISP_SCALE = (1 << DISP_SHIFT) + }; + + /** @brief Computes disparity map for the specified stereo pair + + @param left Left 8-bit single-channel image. + @param right Right image of the same size and the same type as the left one. + @param disparity Output disparity map. It has the same size as the input images. Some algorithms, + like StereoBM or StereoSGBM compute 16-bit fixed-point disparity map (where each disparity value + has 4 fractional bits), whereas other algorithms output 32-bit floating-point disparity map. + */ + CV_WRAP virtual void compute( InputArray left, InputArray right, + OutputArray disparity ) = 0; + + CV_WRAP virtual int getMinDisparity() const = 0; + CV_WRAP virtual void setMinDisparity(int minDisparity) = 0; + + CV_WRAP virtual int getNumDisparities() const = 0; + CV_WRAP virtual void setNumDisparities(int numDisparities) = 0; + + CV_WRAP virtual int getBlockSize() const = 0; + CV_WRAP virtual void setBlockSize(int blockSize) = 0; + + CV_WRAP virtual int getSpeckleWindowSize() const = 0; + CV_WRAP virtual void setSpeckleWindowSize(int speckleWindowSize) = 0; + + CV_WRAP virtual int getSpeckleRange() const = 0; + CV_WRAP virtual void setSpeckleRange(int speckleRange) = 0; + + CV_WRAP virtual int getDisp12MaxDiff() const = 0; + CV_WRAP virtual void setDisp12MaxDiff(int disp12MaxDiff) = 0; +}; + + +/** @brief Class for computing stereo correspondence using the block matching algorithm, introduced and +contributed to OpenCV by K. Konolige. + */ +class CV_EXPORTS_W StereoBM : public StereoMatcher +{ +public: + enum { PREFILTER_NORMALIZED_RESPONSE = 0, + PREFILTER_XSOBEL = 1 + }; + + CV_WRAP virtual int getPreFilterType() const = 0; + CV_WRAP virtual void setPreFilterType(int preFilterType) = 0; + + CV_WRAP virtual int getPreFilterSize() const = 0; + CV_WRAP virtual void setPreFilterSize(int preFilterSize) = 0; + + CV_WRAP virtual int getPreFilterCap() const = 0; + CV_WRAP virtual void setPreFilterCap(int preFilterCap) = 0; + + CV_WRAP virtual int getTextureThreshold() const = 0; + CV_WRAP virtual void setTextureThreshold(int textureThreshold) = 0; + + CV_WRAP virtual int getUniquenessRatio() const = 0; + CV_WRAP virtual void setUniquenessRatio(int uniquenessRatio) = 0; + + CV_WRAP virtual int getSmallerBlockSize() const = 0; + CV_WRAP virtual void setSmallerBlockSize(int blockSize) = 0; + + CV_WRAP virtual Rect getROI1() const = 0; + CV_WRAP virtual void setROI1(Rect roi1) = 0; + + CV_WRAP virtual Rect getROI2() const = 0; + CV_WRAP virtual void setROI2(Rect roi2) = 0; + + /** @brief Creates StereoBM object + + @param numDisparities the disparity search range. For each pixel algorithm will find the best + disparity from 0 (default minimum disparity) to numDisparities. The search range can then be + shifted by changing the minimum disparity. + @param blockSize the linear size of the blocks compared by the algorithm. The size should be odd + (as the block is centered at the current pixel). Larger block size implies smoother, though less + accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher + chance for algorithm to find a wrong correspondence. + + The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for + a specific stereo pair. + */ + CV_WRAP static Ptr create(int numDisparities = 0, int blockSize = 21); +}; + +/** @brief The class implements the modified H. Hirschmuller algorithm @cite HH08 that differs from the original +one as follows: + +- By default, the algorithm is single-pass, which means that you consider only 5 directions +instead of 8. Set mode=StereoSGBM::MODE_HH in createStereoSGBM to run the full variant of the +algorithm but beware that it may consume a lot of memory. +- The algorithm matches blocks, not individual pixels. Though, setting blockSize=1 reduces the +blocks to single pixels. +- Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi +sub-pixel metric from @cite BT98 is used. Though, the color images are supported as well. +- Some pre- and post- processing steps from K. Konolige algorithm StereoBM are included, for +example: pre-filtering (StereoBM::PREFILTER_XSOBEL type) and post-filtering (uniqueness +check, quadratic interpolation and speckle filtering). + +@note + - (Python) An example illustrating the use of the StereoSGBM matching algorithm can be found + at opencv_source_code/samples/python/stereo_match.py + */ +class CV_EXPORTS_W StereoSGBM : public StereoMatcher +{ +public: + enum + { + MODE_SGBM = 0, + MODE_HH = 1, + MODE_SGBM_3WAY = 2, + MODE_HH4 = 3 + }; + + CV_WRAP virtual int getPreFilterCap() const = 0; + CV_WRAP virtual void setPreFilterCap(int preFilterCap) = 0; + + CV_WRAP virtual int getUniquenessRatio() const = 0; + CV_WRAP virtual void setUniquenessRatio(int uniquenessRatio) = 0; + + CV_WRAP virtual int getP1() const = 0; + CV_WRAP virtual void setP1(int P1) = 0; + + CV_WRAP virtual int getP2() const = 0; + CV_WRAP virtual void setP2(int P2) = 0; + + CV_WRAP virtual int getMode() const = 0; + CV_WRAP virtual void setMode(int mode) = 0; + + /** @brief Creates StereoSGBM object + + @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes + rectification algorithms can shift images, so this parameter needs to be adjusted accordingly. + @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than + zero. In the current implementation, this parameter must be divisible by 16. + @param blockSize Matched block size. It must be an odd number \>=1 . Normally, it should be + somewhere in the 3..11 range. + @param P1 The first parameter controlling the disparity smoothness. See below. + @param P2 The second parameter controlling the disparity smoothness. The larger the values are, + the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1 + between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor + pixels. The algorithm requires P2 \> P1 . See stereo_match.cpp sample where some reasonably good + P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and + 32\*number_of_image_channels\*blockSize\*blockSize , respectively). + @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right + disparity check. Set it to a non-positive value to disable the check. + @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first + computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval. + The result values are passed to the Birchfield-Tomasi pixel cost function. + @param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function + value should "win" the second best value to consider the found match correct. Normally, a value + within the 5-15 range is good enough. + @param speckleWindowSize Maximum size of smooth disparity regions to consider their noise speckles + and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the + 50-200 range. + @param speckleRange Maximum disparity variation within each connected component. If you do speckle + filtering, set the parameter to a positive value, it will be implicitly multiplied by 16. + Normally, 1 or 2 is good enough. + @param mode Set it to StereoSGBM::MODE_HH to run the full-scale two-pass dynamic programming + algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and + huge for HD-size pictures. By default, it is set to false . + + The first constructor initializes StereoSGBM with all the default parameters. So, you only have to + set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter + to a custom value. + */ + CV_WRAP static Ptr create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3, + int P1 = 0, int P2 = 0, int disp12MaxDiff = 0, + int preFilterCap = 0, int uniquenessRatio = 0, + int speckleWindowSize = 0, int speckleRange = 0, + int mode = StereoSGBM::MODE_SGBM); +}; + + +//! cv::undistort mode +enum UndistortTypes +{ + PROJ_SPHERICAL_ORTHO = 0, + PROJ_SPHERICAL_EQRECT = 1 +}; + +/** @brief Transforms an image to compensate for lens distortion. + +The function transforms an image to compensate radial and tangential lens distortion. + +The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap +(with bilinear interpolation). See the former function for details of the transformation being +performed. + +Those pixels in the destination image, for which there is no correspondent pixels in the source +image, are filled with zeros (black color). + +A particular subset of the source image that will be visible in the corrected image can be regulated +by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate +newCameraMatrix depending on your requirements. + +The camera matrix and the distortion parameters can be determined using #calibrateCamera. If +the resolution of images is different from the resolution used at the calibration stage, \f$f_x, +f_y, c_x\f$ and \f$c_y\f$ need to be scaled accordingly, while the distortion coefficients remain +the same. + +@param src Input (distorted) image. +@param dst Output (corrected) image that has the same size and type as src . +@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param newCameraMatrix Camera matrix of the distorted image. By default, it is the same as +cameraMatrix but you may additionally scale and shift the result by using a different matrix. + */ +CV_EXPORTS_W void undistort( InputArray src, OutputArray dst, + InputArray cameraMatrix, + InputArray distCoeffs, + InputArray newCameraMatrix = noArray() ); + +/** @brief Computes the undistortion and rectification transformation map. + +The function computes the joint undistortion and rectification transformation and represents the +result in the form of maps for #remap. The undistorted image looks like original, as if it is +captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a +monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by +#getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera, +newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify . + +Also, this new camera is oriented differently in the coordinate space, according to R. That, for +example, helps to align two heads of a stereo camera so that the epipolar lines on both images +become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera). + +The function actually builds the maps for the inverse mapping algorithm that is used by #remap. That +is, for each pixel \f$(u, v)\f$ in the destination (corrected and rectified) image, the function +computes the corresponding coordinates in the source image (that is, in the original image from +camera). The following process is applied: +\f[ +\begin{array}{l} +x \leftarrow (u - {c'}_x)/{f'}_x \\ +y \leftarrow (v - {c'}_y)/{f'}_y \\ +{[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\ +x' \leftarrow X/W \\ +y' \leftarrow Y/W \\ +r^2 \leftarrow x'^2 + y'^2 \\ +x'' \leftarrow x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} ++ 2p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4\\ +y'' \leftarrow y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} ++ p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\ +s\vecthree{x'''}{y'''}{1} = +\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)} +{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)} +{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\ +map_x(u,v) \leftarrow x''' f_x + c_x \\ +map_y(u,v) \leftarrow y''' f_y + c_y +\end{array} +\f] +where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +are the distortion coefficients. + +In case of a stereo camera, this function is called twice: once for each camera head, after +#stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera +was not calibrated, it is still possible to compute the rectification transformations directly from +the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes +homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D +space. R can be computed from H as +\f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f] +where cameraMatrix can be chosen arbitrarily. + +@param cameraMatrix Input camera matrix \f$A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2 , +computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation +is assumed. In cvInitUndistortMap R assumed to be an identity matrix. +@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$. +@param size Undistorted image size. +@param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps +@param map1 The first output map. +@param map2 The second output map. + */ +CV_EXPORTS_W +void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, + InputArray R, InputArray newCameraMatrix, + Size size, int m1type, OutputArray map1, OutputArray map2); + +/** @brief Computes the projection and inverse-rectification transformation map. In essense, this is the inverse of +#initUndistortRectifyMap to accomodate stereo-rectification of projectors ('inverse-cameras') in projector-camera pairs. + +The function computes the joint projection and inverse rectification transformation and represents the +result in the form of maps for #remap. The projected image looks like a distorted version of the original which, +once projected by a projector, should visually match the original. In case of a monocular camera, newCameraMatrix +is usually equal to cameraMatrix, or it can be computed by +#getOptimalNewCameraMatrix for a better control over scaling. In case of a projector-camera pair, +newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify . + +The projector is oriented differently in the coordinate space, according to R. In case of projector-camera pairs, +this helps align the projector (in the same manner as #initUndistortRectifyMap for the camera) to create a stereo-rectified pair. This +allows epipolar lines on both images to become horizontal and have the same y-coordinate (in case of a horizontally aligned projector-camera pair). + +The function builds the maps for the inverse mapping algorithm that is used by #remap. That +is, for each pixel \f$(u, v)\f$ in the destination (projected and inverse-rectified) image, the function +computes the corresponding coordinates in the source image (that is, in the original digital image). The following process is applied: + +\f[ +\begin{array}{l} +\text{newCameraMatrix}\\ +x \leftarrow (u - {c'}_x)/{f'}_x \\ +y \leftarrow (v - {c'}_y)/{f'}_y \\ + +\\\text{Undistortion} +\\\scriptsize{\textit{though equation shown is for radial undistortion, function implements cv::undistortPoints()}}\\ +r^2 \leftarrow x^2 + y^2 \\ +\theta \leftarrow \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}\\ +x' \leftarrow \frac{x}{\theta} \\ +y' \leftarrow \frac{y}{\theta} \\ + +\\\text{Rectification}\\ +{[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\ +x'' \leftarrow X/W \\ +y'' \leftarrow Y/W \\ + +\\\text{cameraMatrix}\\ +map_x(u,v) \leftarrow x'' f_x + c_x \\ +map_y(u,v) \leftarrow y'' f_y + c_y +\end{array} +\f] +where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +are the distortion coefficients vector distCoeffs. + +In case of a stereo-rectified projector-camera pair, this function is called for the projector while #initUndistortRectifyMap is called for the camera head. +This is done after #stereoRectify, which in turn is called after #stereoCalibrate. If the projector-camera pair +is not calibrated, it is still possible to compute the rectification transformations directly from +the fundamental matrix using #stereoRectifyUncalibrated. For the projector and camera, the function computes +homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D +space. R can be computed from H as +\f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f] +where cameraMatrix can be chosen arbitrarily. + +@param cameraMatrix Input camera matrix \f$A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2, +computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation +is assumed. +@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$. +@param size Distorted image size. +@param m1type Type of the first output map. Can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps +@param map1 The first output map for #remap. +@param map2 The second output map for #remap. + */ +CV_EXPORTS_W +void initInverseRectificationMap( InputArray cameraMatrix, InputArray distCoeffs, + InputArray R, InputArray newCameraMatrix, + const Size& size, int m1type, OutputArray map1, OutputArray map2 ); + +//! initializes maps for #remap for wide-angle +CV_EXPORTS +float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs, + Size imageSize, int destImageWidth, + int m1type, OutputArray map1, OutputArray map2, + enum UndistortTypes projType = PROJ_SPHERICAL_EQRECT, double alpha = 0); +static inline +float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs, + Size imageSize, int destImageWidth, + int m1type, OutputArray map1, OutputArray map2, + int projType, double alpha = 0) +{ + return initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize, destImageWidth, + m1type, map1, map2, (UndistortTypes)projType, alpha); +} + +/** @brief Returns the default new camera matrix. + +The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when +centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true). + +In the latter case, the new camera matrix will be: + +\f[\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\f] + +where \f$f_x\f$ and \f$f_y\f$ are \f$(0,0)\f$ and \f$(1,1)\f$ elements of cameraMatrix, respectively. + +By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not +move the principal point. However, when you work with stereo, it is important to move the principal +points in both views to the same y-coordinate (which is required by most of stereo correspondence +algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for +each view where the principal points are located at the center. + +@param cameraMatrix Input camera matrix. +@param imgsize Camera view image size in pixels. +@param centerPrincipalPoint Location of the principal point in the new camera matrix. The +parameter indicates whether this location should be at the image center or not. + */ +CV_EXPORTS_W +Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgsize = Size(), + bool centerPrincipalPoint = false); + +/** @brief Computes the ideal point coordinates from the observed point coordinates. + +The function is similar to #undistort and #initUndistortRectifyMap but it operates on a +sparse set of points instead of a raster image. Also the function performs a reverse transformation +to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a +planar object, it does, up to a translation vector, if the proper R is specified. + +For each observed point coordinate \f$(u, v)\f$ the function computes: +\f[ +\begin{array}{l} +x^{"} \leftarrow (u - c_x)/f_x \\ +y^{"} \leftarrow (v - c_y)/f_y \\ +(x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\ +{[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\ +x \leftarrow X/W \\ +y \leftarrow Y/W \\ +\text{only performed if P is specified:} \\ +u' \leftarrow x {f'}_x + {c'}_x \\ +v' \leftarrow y {f'}_y + {c'}_y +\end{array} +\f] + +where *undistort* is an approximate iterative algorithm that estimates the normalized original +point coordinates out of the normalized distorted point coordinates ("normalized" means that the +coordinates do not depend on the camera matrix). + +The function can be used for both a stereo camera head or a monocular camera (when R is empty). +@param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or +vector\ ). +@param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector\ ) after undistortion and reverse perspective +transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates. +@param cameraMatrix Camera matrix \f$\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . +@param distCoeffs Input vector of distortion coefficients +\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ +of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed. +@param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by +#stereoRectify can be passed here. If the matrix is empty, the identity transformation is used. +@param P New camera matrix (3x3) or new projection matrix (3x4) \f$\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\f$. P1 or P2 computed by +#stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used. + */ +CV_EXPORTS_W +void undistortPoints(InputArray src, OutputArray dst, + InputArray cameraMatrix, InputArray distCoeffs, + InputArray R = noArray(), InputArray P = noArray()); +/** @overload + @note Default version of #undistortPoints does 5 iterations to compute undistorted points. + */ +CV_EXPORTS_AS(undistortPointsIter) +void undistortPoints(InputArray src, OutputArray dst, + InputArray cameraMatrix, InputArray distCoeffs, + InputArray R, InputArray P, TermCriteria criteria); + +//! @} calib3d + +/** @brief The methods in this namespace use a so-called fisheye camera model. + @ingroup calib3d_fisheye +*/ +namespace fisheye +{ +//! @addtogroup calib3d_fisheye +//! @{ + + enum{ + CALIB_USE_INTRINSIC_GUESS = 1 << 0, + CALIB_RECOMPUTE_EXTRINSIC = 1 << 1, + CALIB_CHECK_COND = 1 << 2, + CALIB_FIX_SKEW = 1 << 3, + CALIB_FIX_K1 = 1 << 4, + CALIB_FIX_K2 = 1 << 5, + CALIB_FIX_K3 = 1 << 6, + CALIB_FIX_K4 = 1 << 7, + CALIB_FIX_INTRINSIC = 1 << 8, + CALIB_FIX_PRINCIPAL_POINT = 1 << 9, + CALIB_ZERO_DISPARITY = 1 << 10, + CALIB_FIX_FOCAL_LENGTH = 1 << 11 + }; + + /** @brief Projects points using fisheye model + + @param objectPoints Array of object points, 1xN/Nx1 3-channel (or vector\ ), where N is + the number of points in the view. + @param imagePoints Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or + vector\. + @param affine + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param alpha The skew coefficient. + @param jacobian Optional output 2Nx15 jacobian matrix of derivatives of image points with respect + to components of the focal lengths, coordinates of the principal point, distortion coefficients, + rotation vector, translation vector, and the skew. In the old interface different components of + the jacobian are returned via different output parameters. + + The function computes projections of 3D points to the image plane given intrinsic and extrinsic + camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of + image points coordinates (as functions of all the input parameters) with respect to the particular + parameters, intrinsic and/or extrinsic. + */ + CV_EXPORTS void projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine, + InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()); + + /** @overload */ + CV_EXPORTS_W void projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, + InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()); + + /** @brief Distorts 2D points using fisheye model. + + @param undistorted Array of object points, 1xN/Nx1 2-channel (or vector\ ), where N is + the number of points in the view. + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param alpha The skew coefficient. + @param distorted Output array of image points, 1xN/Nx1 2-channel, or vector\ . + + Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity. + This means if you want to transform back points undistorted with #fisheye::undistortPoints you have to + multiply them with \f$P^{-1}\f$. + */ + CV_EXPORTS_W void distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0); + + /** @brief Undistorts 2D points using fisheye model + + @param distorted Array of object points, 1xN/Nx1 2-channel (or vector\ ), where N is the + number of points in the view. + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 + 1-channel or 1x1 3-channel + @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4) + @param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector\ . + */ + CV_EXPORTS_W void undistortPoints(InputArray distorted, OutputArray undistorted, + InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray()); + + /** @brief Computes undistortion and rectification maps for image transform by #remap. If D is empty zero + distortion is used, if R or P is empty identity matrixes are used. + + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 + 1-channel or 1x1 3-channel + @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4) + @param size Undistorted image size. + @param m1type Type of the first output map that can be CV_32FC1 or CV_16SC2 . See #convertMaps + for details. + @param map1 The first output map. + @param map2 The second output map. + */ + CV_EXPORTS_W void initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, + const cv::Size& size, int m1type, OutputArray map1, OutputArray map2); + + /** @brief Transforms an image to compensate for fisheye lens distortion. + + @param distorted image with fisheye lens distortion. + @param undistorted Output image with compensated fisheye lens distortion. + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you + may additionally scale and shift the result by using a different matrix. + @param new_size the new size + + The function transforms an image to compensate radial and tangential lens distortion. + + The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap + (with bilinear interpolation). See the former function for details of the transformation being + performed. + + See below the results of undistortImage. + - a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3, + k_4, k_5, k_6) of distortion were optimized under calibration) + - b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2, + k_3, k_4) of fisheye distortion were optimized under calibration) + - c\) original image was captured with fisheye lens + + Pictures a) and b) almost the same. But if we consider points of image located far from the center + of image, we can notice that on image a) these points are distorted. + + ![image](pics/fisheye_undistorted.jpg) + */ + CV_EXPORTS_W void undistortImage(InputArray distorted, OutputArray undistorted, + InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size()); + + /** @brief Estimates new camera intrinsic matrix for undistortion or rectification. + + @param K Camera intrinsic matrix \f$cameramatrix{K}\f$. + @param image_size Size of the image + @param D Input vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 + 1-channel or 1x1 3-channel + @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4) + @param balance Sets the new focal length in range between the min focal length and the max focal + length. Balance is in range of [0, 1]. + @param new_size the new size + @param fov_scale Divisor for new focal length. + */ + CV_EXPORTS_W void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R, + OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0); + + /** @brief Performs camera calibaration + + @param objectPoints vector of vectors of calibration pattern points in the calibration pattern + coordinate space. + @param imagePoints vector of vectors of the projections of calibration pattern points. + imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to + objectPoints[i].size() for each i. + @param image_size Size of the image used only to initialize the camera intrinsic matrix. + @param K Output 3x3 floating-point camera intrinsic matrix + \f$\cameramatrix{A}\f$ . If + @ref fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be + initialized before calling the function. + @param D Output vector of distortion coefficients \f$\distcoeffsfisheye\f$. + @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view. + That is, each k-th rotation vector together with the corresponding k-th translation vector (see + the next output parameter description) brings the calibration pattern from the model coordinate + space (in which object points are specified) to the world coordinate space, that is, a real + position of the calibration pattern in the k-th pattern view (k=0.. *M* -1). + @param tvecs Output vector of translation vectors estimated for each pattern view. + @param flags Different flags that may be zero or a combination of the following values: + - @ref fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of + fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image + center ( imageSize is used), and focal distances are computed in a least-squares fashion. + - @ref fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration + of intrinsic optimization. + - @ref fisheye::CALIB_CHECK_COND The functions will check validity of condition number. + - @ref fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero. + - @ref fisheye::CALIB_FIX_K1,..., @ref fisheye::CALIB_FIX_K4 Selected distortion coefficients + are set to zeros and stay zero. + - @ref fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global +optimization. It stays at the center or at a different location specified when @ref fisheye::CALIB_USE_INTRINSIC_GUESS is set too. + - @ref fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global +optimization. It is the \f$max(width,height)/\pi\f$ or the provided \f$f_x\f$, \f$f_y\f$ when @ref fisheye::CALIB_USE_INTRINSIC_GUESS is set too. + @param criteria Termination criteria for the iterative optimization algorithm. + */ + CV_EXPORTS_W double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size, + InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)); + + /** @brief Stereo rectification for fisheye camera model + + @param K1 First camera intrinsic matrix. + @param D1 First camera distortion parameters. + @param K2 Second camera intrinsic matrix. + @param D2 Second camera distortion parameters. + @param imageSize Size of the image used for stereo calibration. + @param R Rotation matrix between the coordinate systems of the first and the second + cameras. + @param tvec Translation vector between coordinate systems of the cameras. + @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. + @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. + @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first + camera. + @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second + camera. + @param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ). + @param flags Operation flags that may be zero or @ref fisheye::CALIB_ZERO_DISPARITY . If the flag is set, + the function makes the principal points of each camera have the same pixel coordinates in the + rectified views. And if the flag is not set, the function may still shift the images in the + horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the + useful image area. + @param newImageSize New image resolution after rectification. The same size should be passed to + #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0) + is passed (default), it is set to the original imageSize . Setting it to larger value can help you + preserve details in the original image, especially when there is a big radial distortion. + @param balance Sets the new focal length in range between the min focal length and the max focal + length. Balance is in range of [0, 1]. + @param fov_scale Divisor for new focal length. + */ + CV_EXPORTS_W void stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec, + OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(), + double balance = 0.0, double fov_scale = 1.0); + + /** @brief Performs stereo calibration + + @param objectPoints Vector of vectors of the calibration pattern points. + @param imagePoints1 Vector of vectors of the projections of the calibration pattern points, + observed by the first camera. + @param imagePoints2 Vector of vectors of the projections of the calibration pattern points, + observed by the second camera. + @param K1 Input/output first camera intrinsic matrix: + \f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If + any of @ref fisheye::CALIB_USE_INTRINSIC_GUESS , @ref fisheye::CALIB_FIX_INTRINSIC are specified, + some or all of the matrix components must be initialized. + @param D1 Input/output vector of distortion coefficients \f$\distcoeffsfisheye\f$ of 4 elements. + @param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 . + @param D2 Input/output lens distortion coefficients for the second camera. The parameter is + similar to D1 . + @param imageSize Size of the image used only to initialize camera intrinsic matrix. + @param R Output rotation matrix between the 1st and the 2nd camera coordinate systems. + @param T Output translation vector between the coordinate systems of the cameras. + @param flags Different flags that may be zero or a combination of the following values: + - @ref fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices + are estimated. + - @ref fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of + fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image + center (imageSize is used), and focal distances are computed in a least-squares fashion. + - @ref fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration + of intrinsic optimization. + - @ref fisheye::CALIB_CHECK_COND The functions will check validity of condition number. + - @ref fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero. + - @ref fisheye::CALIB_FIX_K1,..., @ref fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay + zero. + @param criteria Termination criteria for the iterative optimization algorithm. + */ + CV_EXPORTS_W double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize, + OutputArray R, OutputArray T, int flags = fisheye::CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)); + +//! @} calib3d_fisheye +} // end namespace fisheye + +} //end namespace cv + +#if 0 //def __cplusplus +////////////////////////////////////////////////////////////////////////////////////////// +class CV_EXPORTS CvLevMarq +{ +public: + CvLevMarq(); + CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + ~CvLevMarq(); + void init( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + bool update( const CvMat*& param, CvMat*& J, CvMat*& err ); + bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm ); + + void clear(); + void step(); + enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 }; + + cv::Ptr mask; + cv::Ptr prevParam; + cv::Ptr param; + cv::Ptr J; + cv::Ptr err; + cv::Ptr JtJ; + cv::Ptr JtJN; + cv::Ptr JtErr; + cv::Ptr JtJV; + cv::Ptr JtJW; + double prevErrNorm, errNorm; + int lambdaLg10; + CvTermCriteria criteria; + int state; + int iters; + bool completeSymmFlag; + int solveMethod; +}; +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d/calib3d.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d/calib3d.hpp new file mode 100644 index 0000000..b3da45e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d/calib3d.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/calib3d.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d/calib3d_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d/calib3d_c.h new file mode 100644 index 0000000..e2af07b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/calib3d/calib3d_c.h @@ -0,0 +1,150 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CALIB3D_C_H +#define OPENCV_CALIB3D_C_H + +#include "opencv2/core/types_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Calculates fundamental matrix given a set of corresponding points */ +#define CV_FM_7POINT 1 +#define CV_FM_8POINT 2 + +#define CV_LMEDS 4 +#define CV_RANSAC 8 + +#define CV_FM_LMEDS_ONLY CV_LMEDS +#define CV_FM_RANSAC_ONLY CV_RANSAC +#define CV_FM_LMEDS CV_LMEDS +#define CV_FM_RANSAC CV_RANSAC + +enum +{ + CV_ITERATIVE = 0, + CV_EPNP = 1, // F.Moreno-Noguer, V.Lepetit and P.Fua "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" + CV_P3P = 2, // X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang; "Complete Solution Classification for the Perspective-Three-Point Problem" + CV_DLS = 3 // Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP" +}; + +#define CV_CALIB_CB_ADAPTIVE_THRESH 1 +#define CV_CALIB_CB_NORMALIZE_IMAGE 2 +#define CV_CALIB_CB_FILTER_QUADS 4 +#define CV_CALIB_CB_FAST_CHECK 8 + +#define CV_CALIB_USE_INTRINSIC_GUESS 1 +#define CV_CALIB_FIX_ASPECT_RATIO 2 +#define CV_CALIB_FIX_PRINCIPAL_POINT 4 +#define CV_CALIB_ZERO_TANGENT_DIST 8 +#define CV_CALIB_FIX_FOCAL_LENGTH 16 +#define CV_CALIB_FIX_K1 32 +#define CV_CALIB_FIX_K2 64 +#define CV_CALIB_FIX_K3 128 +#define CV_CALIB_FIX_K4 2048 +#define CV_CALIB_FIX_K5 4096 +#define CV_CALIB_FIX_K6 8192 +#define CV_CALIB_RATIONAL_MODEL 16384 +#define CV_CALIB_THIN_PRISM_MODEL 32768 +#define CV_CALIB_FIX_S1_S2_S3_S4 65536 +#define CV_CALIB_TILTED_MODEL 262144 +#define CV_CALIB_FIX_TAUX_TAUY 524288 +#define CV_CALIB_FIX_TANGENT_DIST 2097152 + +#define CV_CALIB_NINTRINSIC 18 + +#define CV_CALIB_FIX_INTRINSIC 256 +#define CV_CALIB_SAME_FOCAL_LENGTH 512 + +#define CV_CALIB_ZERO_DISPARITY 1024 + +/* stereo correspondence parameters and functions */ +#define CV_STEREO_BM_NORMALIZED_RESPONSE 0 +#define CV_STEREO_BM_XSOBEL 1 + +#ifdef __cplusplus +} // extern "C" + +////////////////////////////////////////////////////////////////////////////////////////// +class CV_EXPORTS CvLevMarq +{ +public: + CvLevMarq(); + CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + ~CvLevMarq(); + void init( int nparams, int nerrs, CvTermCriteria criteria= + cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON), + bool completeSymmFlag=false ); + bool update( const CvMat*& param, CvMat*& J, CvMat*& err ); + bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm ); + + void clear(); + void step(); + enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 }; + + cv::Ptr mask; + cv::Ptr prevParam; + cv::Ptr param; + cv::Ptr J; + cv::Ptr err; + cv::Ptr JtJ; + cv::Ptr JtJN; + cv::Ptr JtErr; + cv::Ptr JtJV; + cv::Ptr JtJW; + double prevErrNorm, errNorm; + int lambdaLg10; + CvTermCriteria criteria; + int state; + int iters; + bool completeSymmFlag; + int solveMethod; +}; + +#endif + +#endif /* OPENCV_CALIB3D_C_H */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core.hpp new file mode 100644 index 0000000..70ea4f8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core.hpp @@ -0,0 +1,3344 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2015, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. +// Copyright (C) 2015, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_HPP +#define OPENCV_CORE_HPP + +#ifndef __cplusplus +# error core.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/base.hpp" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/traits.hpp" +#include "opencv2/core/matx.hpp" +#include "opencv2/core/types.hpp" +#include "opencv2/core/mat.hpp" +#include "opencv2/core/persistence.hpp" + +/** +@defgroup core Core functionality +@{ + @defgroup core_basic Basic structures + @defgroup core_c C structures and operations + @{ + @defgroup core_c_glue Connections with C++ + @} + @defgroup core_array Operations on arrays + @defgroup core_async Asynchronous API + @defgroup core_xml XML/YAML Persistence + @defgroup core_cluster Clustering + @defgroup core_utils Utility and system functions and macros + @{ + @defgroup core_logging Logging facilities + @defgroup core_utils_sse SSE utilities + @defgroup core_utils_neon NEON utilities + @defgroup core_utils_vsx VSX utilities + @defgroup core_utils_softfloat Softfloat support + @defgroup core_utils_samples Utility functions for OpenCV samples + @} + @defgroup core_opengl OpenGL interoperability + @defgroup core_ipp Intel IPP Asynchronous C/C++ Converters + @defgroup core_optim Optimization Algorithms + @defgroup core_directx DirectX interoperability + @defgroup core_eigen Eigen support + @defgroup core_opencl OpenCL support + @defgroup core_va_intel Intel VA-API/OpenCL (CL-VA) interoperability + @defgroup core_hal Hardware Acceleration Layer + @{ + @defgroup core_hal_functions Functions + @defgroup core_hal_interface Interface + @defgroup core_hal_intrin Universal intrinsics + @{ + @defgroup core_hal_intrin_impl Private implementation helpers + @} + @defgroup core_lowlevel_api Low-level API for external libraries / plugins + @} + @defgroup core_parallel Parallel Processing + @{ + @defgroup core_parallel_backend Parallel backends API + @} +@} + */ + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +/*! @brief Class passed to an error. + +This class encapsulates all or almost all necessary +information about the error happened in the program. The exception is +usually constructed and thrown implicitly via CV_Error and CV_Error_ macros. +@see error + */ +class CV_EXPORTS Exception : public std::exception +{ +public: + /*! + Default constructor + */ + Exception(); + /*! + Full constructor. Normally the constructor is not called explicitly. + Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used. + */ + Exception(int _code, const String& _err, const String& _func, const String& _file, int _line); + virtual ~Exception() throw(); + + /*! + \return the error description and the context as a text string. + */ + virtual const char *what() const throw() CV_OVERRIDE; + void formatMessage(); + + String msg; ///< the formatted error message + + int code; ///< error code @see CVStatus + String err; ///< error description + String func; ///< function name. Available only when the compiler supports getting it + String file; ///< source file name where the error has occurred + int line; ///< line number in the source file where the error has occurred +}; + +/*! @brief Signals an error and raises the exception. + +By default the function prints information about the error to stderr, +then it either stops if cv::setBreakOnError() had been called before or raises the exception. +It is possible to alternate error processing by using #redirectError(). +@param exc the exception raisen. +@deprecated drop this version + */ +CV_EXPORTS CV_NORETURN void error(const Exception& exc); + +enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently + SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted + //!< independently; this flag and the previous one are + //!< mutually exclusive. + SORT_ASCENDING = 0, //!< each matrix row is sorted in the ascending + //!< order. + SORT_DESCENDING = 16 //!< each matrix row is sorted in the + //!< descending order; this flag and the previous one are also + //!< mutually exclusive. + }; + +//! @} core_utils + +//! @addtogroup core +//! @{ + +//! Covariation flags +enum CovarFlags { + /** The output covariance matrix is calculated as: + \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...],\f] + The covariance matrix will be nsamples x nsamples. Such an unusual covariance matrix is used + for fast PCA of a set of very large vectors (see, for example, the EigenFaces technique for + face recognition). Eigenvalues of this "scrambled" matrix match the eigenvalues of the true + covariance matrix. The "true" eigenvectors can be easily calculated from the eigenvectors of + the "scrambled" covariance matrix. */ + COVAR_SCRAMBLED = 0, + /**The output covariance matrix is calculated as: + \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\f] + covar will be a square matrix of the same size as the total number of elements in each input + vector. One and only one of #COVAR_SCRAMBLED and #COVAR_NORMAL must be specified.*/ + COVAR_NORMAL = 1, + /** If the flag is specified, the function does not calculate mean from + the input vectors but, instead, uses the passed mean vector. This is useful if mean has been + pre-calculated or known in advance, or if the covariance matrix is calculated by parts. In + this case, mean is not a mean vector of the input sub-set of vectors but rather the mean + vector of the whole set.*/ + COVAR_USE_AVG = 2, + /** If the flag is specified, the covariance matrix is scaled. In the + "normal" mode, scale is 1./nsamples . In the "scrambled" mode, scale is the reciprocal of the + total number of elements in each input vector. By default (if the flag is not specified), the + covariance matrix is not scaled ( scale=1 ).*/ + COVAR_SCALE = 4, + /** If the flag is + specified, all the input vectors are stored as rows of the samples matrix. mean should be a + single-row vector in this case.*/ + COVAR_ROWS = 8, + /** If the flag is + specified, all the input vectors are stored as columns of the samples matrix. mean should be a + single-column vector in this case.*/ + COVAR_COLS = 16 +}; + +//! @addtogroup core_cluster +//! @{ + +//! k-Means flags +enum KmeansFlags { + /** Select random initial centers in each attempt.*/ + KMEANS_RANDOM_CENTERS = 0, + /** Use kmeans++ center initialization by Arthur and Vassilvitskii [Arthur2007].*/ + KMEANS_PP_CENTERS = 2, + /** During the first (and possibly the only) attempt, use the + user-supplied labels instead of computing them from the initial centers. For the second and + further attempts, use the random or semi-random centers. Use one of KMEANS_\*_CENTERS flag + to specify the exact method.*/ + KMEANS_USE_INITIAL_LABELS = 1 +}; + +//! @} core_cluster + +//! @addtogroup core_array +//! @{ + +enum ReduceTypes { REDUCE_SUM = 0, //!< the output is the sum of all rows/columns of the matrix. + REDUCE_AVG = 1, //!< the output is the mean vector of all rows/columns of the matrix. + REDUCE_MAX = 2, //!< the output is the maximum (column/row-wise) of all rows/columns of the matrix. + REDUCE_MIN = 3 //!< the output is the minimum (column/row-wise) of all rows/columns of the matrix. + }; + +//! @} core_array + +/** @brief Swaps two matrices +*/ +CV_EXPORTS void swap(Mat& a, Mat& b); +/** @overload */ +CV_EXPORTS void swap( UMat& a, UMat& b ); + +//! @} core + +//! @addtogroup core_array +//! @{ + +/** @brief Computes the source location of an extrapolated pixel. + +The function computes and returns the coordinate of a donor pixel corresponding to the specified +extrapolated pixel when using the specified extrapolation border mode. For example, if you use +cv::BORDER_WRAP mode in the horizontal direction, cv::BORDER_REFLECT_101 in the vertical direction and +want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img , it +looks like: +@code{.cpp} + float val = img.at(borderInterpolate(100, img.rows, cv::BORDER_REFLECT_101), + borderInterpolate(-5, img.cols, cv::BORDER_WRAP)); +@endcode +Normally, the function is not called directly. It is used inside filtering functions and also in +copyMakeBorder. +@param p 0-based coordinate of the extrapolated pixel along one of the axes, likely \<0 or \>= len +@param len Length of the array along the corresponding axis. +@param borderType Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and +#BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless +of p and len. + +@sa copyMakeBorder +*/ +CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType); + +/** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp +An example using copyMakeBorder function. +Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details +*/ + +/** @brief Forms a border around an image. + +The function copies the source image into the middle of the destination image. The areas to the +left, to the right, above and below the copied source image will be filled with extrapolated +pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but +what other more complex functions, including your own, may do to simplify image boundary handling. + +The function supports the mode when src is already in the middle of dst . In this case, the +function does not copy src itself but simply constructs the border, for example: + +@code{.cpp} + // let border be the same in all directions + int border=2; + // constructs a larger image to fit both the image and the border + Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth()); + // select the middle part of it w/o copying data + Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows)); + // convert image from RGB to grayscale + cvtColor(rgb, gray, COLOR_RGB2GRAY); + // form a border in-place + copyMakeBorder(gray, gray_buf, border, border, + border, border, BORDER_REPLICATE); + // now do some custom filtering ... + ... +@endcode +@note When the source image is a part (ROI) of a bigger image, the function will try to use the +pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as +if src was not a ROI, use borderType | #BORDER_ISOLATED. + +@param src Source image. +@param dst Destination image of the same type as src and the size Size(src.cols+left+right, +src.rows+top+bottom) . +@param top the top pixels +@param bottom the bottom pixels +@param left the left pixels +@param right Parameter specifying how many pixels in each direction from the source image rectangle +to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs +to be built. +@param borderType Border type. See borderInterpolate for details. +@param value Border value if borderType==BORDER_CONSTANT . + +@sa borderInterpolate +*/ +CV_EXPORTS_W void copyMakeBorder(InputArray src, OutputArray dst, + int top, int bottom, int left, int right, + int borderType, const Scalar& value = Scalar() ); + +/** @brief Calculates the per-element sum of two arrays or an array and a scalar. + +The function add calculates: +- Sum of two arrays when both input arrays have the same size and the same number of channels: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f] +- Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of +elements as `src1.channels()`: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f] +- Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of +elements as `src2.channels()`: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f] +where `I` is a multi-dimensional index of array elements. In case of multi-channel arrays, each +channel is processed independently. + +The first function in the list above can be replaced with matrix expressions: +@code{.cpp} + dst = src1 + src2; + dst += src1; // equivalent to add(dst, src1, dst); +@endcode +The input arrays and the output array can all have the same or different depths. For example, you +can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit +floating-point array. Depth of the output array is determined by the dtype parameter. In the second +and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can +be set to the default -1. In this case, the output array will have the same depth as the input +array, be it src1, src2 or both. +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and number of channels as the input array(s); the +depth is defined by dtype or src1/src2. +@param mask optional operation mask - 8-bit single channel array, that specifies elements of the +output array to be changed. +@param dtype optional depth of the output array (see the discussion below). +@sa subtract, addWeighted, scaleAdd, Mat::convertTo +*/ +CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask = noArray(), int dtype = -1); + +/** @brief Calculates the per-element difference between two arrays or array and a scalar. + +The function subtract calculates: +- Difference between two arrays, when both input arrays have the same size and the same number of +channels: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f] +- Difference between an array and a scalar, when src2 is constructed from Scalar or has the same +number of elements as `src1.channels()`: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f] +- Difference between a scalar and an array, when src1 is constructed from Scalar or has the same +number of elements as `src2.channels()`: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f] +- The reverse difference between a scalar and an array in the case of `SubRS`: + \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\f] +where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each +channel is processed independently. + +The first function in the list above can be replaced with matrix expressions: +@code{.cpp} + dst = src1 - src2; + dst -= src1; // equivalent to subtract(dst, src1, dst); +@endcode +The input arrays and the output array can all have the same or different depths. For example, you +can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of +the output array is determined by dtype parameter. In the second and third cases above, as well as +in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this +case the output array will have the same depth as the input array, be it src1, src2 or both. +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array of the same size and the same number of channels as the input array. +@param mask optional operation mask; this is an 8-bit single channel array that specifies elements +of the output array to be changed. +@param dtype optional depth of the output array +@sa add, addWeighted, scaleAdd, Mat::convertTo + */ +CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, + InputArray mask = noArray(), int dtype = -1); + + +/** @brief Calculates the per-element scaled product of two arrays. + +The function multiply calculates the per-element product of two arrays: + +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\f] + +There is also a @ref MatrixExpressions -friendly variant of the first function. See Mat::mul . + +For a not-per-element matrix product, see gemm . + +@note Saturation is not applied when the output array has the depth +CV_32S. You may even get result of an incorrect sign in the case of +overflow. +@param src1 first input array. +@param src2 second input array of the same size and the same type as src1. +@param dst output array of the same size and type as src1. +@param scale optional scale factor. +@param dtype optional depth of the output array +@sa add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare, +Mat::convertTo +*/ +CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, + OutputArray dst, double scale = 1, int dtype = -1); + +/** @brief Performs per-element division of two arrays or a scalar by an array. + +The function cv::divide divides one array by another: +\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f] +or a scalar by an array when there is no src1 : +\f[\texttt{dst(I) = saturate(scale/src2(I))}\f] + +Different channels of multi-channel arrays are processed independently. + +For integer types when src2(I) is zero, dst(I) will also be zero. + +@note In case of floating point data there is no special defined behavior for zero src2(I) values. +Regular floating-point division is used. +Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values). + +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array. +@param src2 second input array of the same size and type as src1. +@param scale scalar factor. +@param dst output array of the same size and type as src2. +@param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in +case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth(). +@sa multiply, add, subtract +*/ +CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, + double scale = 1, int dtype = -1); + +/** @overload */ +CV_EXPORTS_W void divide(double scale, InputArray src2, + OutputArray dst, int dtype = -1); + +/** @brief Calculates the sum of a scaled array and another array. + +The function scaleAdd is one of the classical primitive linear algebra operations, known as DAXPY +or SAXPY in [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It calculates +the sum of a scaled array and another array: +\f[\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\f] +The function can also be emulated with a matrix expression, for example: +@code{.cpp} + Mat A(3, 3, CV_64F); + ... + A.row(0) = A.row(1)*2 + A.row(2); +@endcode +@param src1 first input array. +@param alpha scale factor for the first array. +@param src2 second input array of the same size and type as src1. +@param dst output array of the same size and type as src1. +@sa add, addWeighted, subtract, Mat::dot, Mat::convertTo +*/ +CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst); + +/** @example samples/cpp/tutorial_code/HighGUI/AddingImagesTrackbar.cpp +Check @ref tutorial_trackbar "the corresponding tutorial" for more details +*/ + +/** @brief Calculates the weighted sum of two arrays. + +The function addWeighted calculates the weighted sum of two arrays as follows: +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] +where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each +channel is processed independently. +The function can be replaced with a matrix expression: +@code{.cpp} + dst = src1*alpha + src2*beta + gamma; +@endcode +@note Saturation is not applied when the output array has the depth CV_32S. You may even get +result of an incorrect sign in the case of overflow. +@param src1 first input array. +@param alpha weight of the first array elements. +@param src2 second input array of the same size and channel number as src1. +@param beta weight of the second array elements. +@param gamma scalar added to each sum. +@param dst output array that has the same size and number of channels as the input arrays. +@param dtype optional depth of the output array; when both input arrays have the same depth, dtype +can be set to -1, which will be equivalent to src1.depth(). +@sa add, subtract, scaleAdd, Mat::convertTo +*/ +CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, + double beta, double gamma, OutputArray dst, int dtype = -1); + +/** @brief Scales, calculates absolute values, and converts the result to 8-bit. + +On each element of the input array, the function convertScaleAbs +performs three operations sequentially: scaling, taking an absolute +value, conversion to an unsigned 8-bit type: +\f[\texttt{dst} (I)= \texttt{saturate\_cast} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\f] +In case of multi-channel arrays, the function processes each channel +independently. When the output is not 8-bit, the operation can be +emulated by calling the Mat::convertTo method (or by using matrix +expressions) and then by calculating an absolute value of the result. +For example: +@code{.cpp} + Mat_ A(30,30); + randu(A, Scalar(-100), Scalar(100)); + Mat_ B = A*5 + 3; + B = abs(B); + // Mat_ B = abs(A*5+3) will also do the job, + // but it will allocate a temporary matrix +@endcode +@param src input array. +@param dst output array. +@param alpha optional scale factor. +@param beta optional delta added to the scaled values. +@sa Mat::convertTo, cv::abs(const Mat&) +*/ +CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst, + double alpha = 1, double beta = 0); + +/** @brief Converts an array to half precision floating number. + +This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). CV_16S format is used to represent FP16 data. +There are two use modes (src -> dst): CV_32F -> CV_16S and CV_16S -> CV_32F. The input array has to have type of CV_32F or +CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error. +The format of half precision floating point is defined in IEEE 754-2008. + +@param src input array. +@param dst output array. +*/ +CV_EXPORTS_W void convertFp16(InputArray src, OutputArray dst); + +/** @brief Performs a look-up table transform of an array. + +The function LUT fills the output array with values from the look-up table. Indices of the entries +are taken from the input array. That is, the function processes each element of src as follows: +\f[\texttt{dst} (I) \leftarrow \texttt{lut(src(I) + d)}\f] +where +\f[d = \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\f] +@param src input array of 8-bit elements. +@param lut look-up table of 256 elements; in case of multi-channel input array, the table should +either have a single channel (in this case the same table is used for all channels) or the same +number of channels as in the input array. +@param dst output array of the same size and number of channels as src, and the same depth as lut. +@sa convertScaleAbs, Mat::convertTo +*/ +CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst); + +/** @brief Calculates the sum of array elements. + +The function cv::sum calculates and returns the sum of array elements, +independently for each channel. +@param src input array that must have from 1 to 4 channels. +@sa countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce +*/ +CV_EXPORTS_AS(sumElems) Scalar sum(InputArray src); + +/** @brief Counts non-zero array elements. + +The function returns the number of non-zero elements in src : +\f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f] +@param src single-channel array. +@sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix +*/ +CV_EXPORTS_W int countNonZero( InputArray src ); + +/** @brief Returns the list of locations of non-zero pixels + +Given a binary matrix (likely returned from an operation such +as threshold(), compare(), >, ==, etc, return all of +the non-zero indices as a cv::Mat or std::vector (x,y) +For example: +@code{.cpp} + cv::Mat binaryImage; // input, binary image + cv::Mat locations; // output, locations of non-zero pixels + cv::findNonZero(binaryImage, locations); + + // access pixel coordinates + Point pnt = locations.at(i); +@endcode +or +@code{.cpp} + cv::Mat binaryImage; // input, binary image + vector locations; // output, locations of non-zero pixels + cv::findNonZero(binaryImage, locations); + + // access pixel coordinates + Point pnt = locations[i]; +@endcode +@param src single-channel array +@param idx the output array, type of cv::Mat or std::vector, corresponding to non-zero indices in the input +*/ +CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx ); + +/** @brief Calculates an average (mean) of array elements. + +The function cv::mean calculates the mean value M of array elements, +independently for each channel, and return it: +\f[\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\f] +When all the mask elements are 0's, the function returns Scalar::all(0) +@param src input array that should have from 1 to 4 channels so that the result can be stored in +Scalar_ . +@param mask optional operation mask. +@sa countNonZero, meanStdDev, norm, minMaxLoc +*/ +CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray()); + +/** Calculates a mean and standard deviation of array elements. + +The function cv::meanStdDev calculates the mean and the standard deviation M +of array elements independently for each channel and returns it via the +output parameters: +\f[\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\f] +When all the mask elements are 0's, the function returns +mean=stddev=Scalar::all(0). +@note The calculated standard deviation is only the diagonal of the +complete normalized covariance matrix. If the full matrix is needed, you +can reshape the multi-channel array M x N to the single-channel array +M\*N x mtx.channels() (only possible when the matrix is continuous) and +then pass the matrix to calcCovarMatrix . +@param src input array that should have from 1 to 4 channels so that the results can be stored in +Scalar_ 's. +@param mean output parameter: calculated mean value. +@param stddev output parameter: calculated standard deviation. +@param mask optional operation mask. +@sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix +*/ +CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, + InputArray mask=noArray()); + +/** @brief Calculates the absolute norm of an array. + +This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\ + \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\ + \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2 +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\ + \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\ + \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5. +\f} +The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$. +It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$. +![Graphs for the different norm functions from the above example](pics/NormTypes_OneArray_1-2-INF.png) + +When the mask parameter is specified and it is not empty, the norm is + +If normType is not specified, #NORM_L2 is used. +calculated only over the region specified by the mask. + +Multi-channel input arrays are treated as single-channel arrays, that is, +the results for all channels are combined. + +Hamming norms can only be calculated with CV_8U depth arrays. + +@param src1 first input array. +@param normType type of the norm (see #NormTypes). +@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. +*/ +CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray()); + +/** @brief Calculates an absolute difference norm or a relative difference norm. + +This version of cv::norm calculates the absolute difference norm +or the relative difference norm of arrays src1 and src2. +The type of norm to calculate is specified using #NormTypes. + +@param src1 first input array. +@param src2 second input array of the same size and the same type as src1. +@param normType type of the norm (see #NormTypes). +@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type. +*/ +CV_EXPORTS_W double norm(InputArray src1, InputArray src2, + int normType = NORM_L2, InputArray mask = noArray()); +/** @overload +@param src first input array. +@param normType type of the norm (see #NormTypes). +*/ +CV_EXPORTS double norm( const SparseMat& src, int normType ); + +/** @brief Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric. + +This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB), +between two input arrays src1 and src2. The arrays must have the same type. + +The PSNR is calculated as follows: + +\f[ +\texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) } +\f] + +where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data) +and MSE is the mean squared error between the two arrays. + +@param src1 first input array. +@param src2 second input array of the same size as src1. +@param R the maximum pixel value (255 by default) + + */ +CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2, double R=255.); + +/** @brief naive nearest neighbor finder + +see http://en.wikipedia.org/wiki/Nearest_neighbor_search +@todo document + */ +CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, + OutputArray dist, int dtype, OutputArray nidx, + int normType = NORM_L2, int K = 0, + InputArray mask = noArray(), int update = 0, + bool crosscheck = false); + +/** @brief Normalizes the norm or value range of an array. + +The function cv::normalize normalizes scale and shift the input array elements so that +\f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f] +(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that +\f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f] + +when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be +normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this +sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or +min-max but modify the whole array, you can use norm and Mat::convertTo. + +In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this, +the range transformation for sparse matrices is not allowed since it can shift the zero level. + +Possible usage with some positive example data: +@code{.cpp} + vector positiveData = { 2.0, 8.0, 10.0 }; + vector normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax; + + // Norm to probability (total count) + // sum(numbers) = 20.0 + // 2.0 0.1 (2.0/20.0) + // 8.0 0.4 (8.0/20.0) + // 10.0 0.5 (10.0/20.0) + normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1); + + // Norm to unit vector: ||positiveData|| = 1.0 + // 2.0 0.15 + // 8.0 0.62 + // 10.0 0.77 + normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2); + + // Norm to max element + // 2.0 0.2 (2.0/10.0) + // 8.0 0.8 (8.0/10.0) + // 10.0 1.0 (10.0/10.0) + normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF); + + // Norm to range [0.0;1.0] + // 2.0 0.0 (shift to left border) + // 8.0 0.75 (6.0/8.0) + // 10.0 1.0 (shift to right border) + normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX); +@endcode + +@param src input array. +@param dst output array of the same size as src . +@param alpha norm value to normalize to or the lower range boundary in case of the range +normalization. +@param beta upper range boundary in case of the range normalization; it is not used for the norm +normalization. +@param norm_type normalization type (see cv::NormTypes). +@param dtype when negative, the output array has the same type as src; otherwise, it has the same +number of channels as src and the depth =CV_MAT_DEPTH(dtype). +@param mask optional operation mask. +@sa norm, Mat::convertTo, SparseMat::convertTo +*/ +CV_EXPORTS_W void normalize( InputArray src, InputOutputArray dst, double alpha = 1, double beta = 0, + int norm_type = NORM_L2, int dtype = -1, InputArray mask = noArray()); + +/** @overload +@param src input array. +@param dst output array of the same size as src . +@param alpha norm value to normalize to or the lower range boundary in case of the range +normalization. +@param normType normalization type (see cv::NormTypes). +*/ +CV_EXPORTS void normalize( const SparseMat& src, SparseMat& dst, double alpha, int normType ); + +/** @brief Finds the global minimum and maximum in an array. + +The function cv::minMaxLoc finds the minimum and maximum element values and their positions. The +extremums are searched across the whole array or, if mask is not an empty array, in the specified +array region. + +The function do not work with multi-channel arrays. If you need to find minimum or maximum +elements across all the channels, use Mat::reshape first to reinterpret the array as +single-channel. Or you may extract the particular channel using either extractImageCOI , or +mixChannels , or split . +@param src input single-channel array. +@param minVal pointer to the returned minimum value; NULL is used if not required. +@param maxVal pointer to the returned maximum value; NULL is used if not required. +@param minLoc pointer to the returned minimum location (in 2D case); NULL is used if not required. +@param maxLoc pointer to the returned maximum location (in 2D case); NULL is used if not required. +@param mask optional mask used to select a sub-array. +@sa max, min, reduceArgMin, reduceArgMax, compare, inRange, extractImageCOI, mixChannels, split, Mat::reshape +*/ +CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal, + CV_OUT double* maxVal = 0, CV_OUT Point* minLoc = 0, + CV_OUT Point* maxLoc = 0, InputArray mask = noArray()); + +/** + * @brief Finds indices of min elements along provided axis + * + * @note + * - If input or output array is not continuous, this function will create an internal copy. + * - NaN handling is left unspecified, see patchNaNs(). + * - The returned index is always in bounds of input matrix. + * + * @param src input single-channel array. + * @param dst output array of type CV_32SC1 with the same dimensionality as src, + * except for axis being reduced - it should be set to 1. + * @param lastIndex whether to get the index of first or last occurrence of min. + * @param axis axis to reduce along. + * @sa reduceArgMax, minMaxLoc, min, max, compare, reduce + */ +CV_EXPORTS_W void reduceArgMin(InputArray src, OutputArray dst, int axis, bool lastIndex = false); + +/** + * @brief Finds indices of max elements along provided axis + * + * @note + * - If input or output array is not continuous, this function will create an internal copy. + * - NaN handling is left unspecified, see patchNaNs(). + * - The returned index is always in bounds of input matrix. + * + * @param src input single-channel array. + * @param dst output array of type CV_32SC1 with the same dimensionality as src, + * except for axis being reduced - it should be set to 1. + * @param lastIndex whether to get the index of first or last occurrence of max. + * @param axis axis to reduce along. + * @sa reduceArgMin, minMaxLoc, min, max, compare, reduce + */ +CV_EXPORTS_W void reduceArgMax(InputArray src, OutputArray dst, int axis, bool lastIndex = false); + +/** @brief Finds the global minimum and maximum in an array + +The function cv::minMaxIdx finds the minimum and maximum element values and their positions. The +extremums are searched across the whole array or, if mask is not an empty array, in the specified +array region. The function does not work with multi-channel arrays. If you need to find minimum or +maximum elements across all the channels, use Mat::reshape first to reinterpret the array as +single-channel. Or you may extract the particular channel using either extractImageCOI , or +mixChannels , or split . In case of a sparse matrix, the minimum is found among non-zero elements +only. +@note When minIdx is not NULL, it must have at least 2 elements (as well as maxIdx), even if src is +a single-row or single-column matrix. In OpenCV (following MATLAB) each array has at least 2 +dimensions, i.e. single-column matrix is Mx1 matrix (and therefore minIdx/maxIdx will be +(i1,0)/(i2,0)) and single-row matrix is 1xN matrix (and therefore minIdx/maxIdx will be +(0,j1)/(0,j2)). +@param src input single-channel array. +@param minVal pointer to the returned minimum value; NULL is used if not required. +@param maxVal pointer to the returned maximum value; NULL is used if not required. +@param minIdx pointer to the returned minimum location (in nD case); NULL is used if not required; +Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element +in each dimension are stored there sequentially. +@param maxIdx pointer to the returned maximum location (in nD case). NULL is used if not required. +@param mask specified array region +*/ +CV_EXPORTS void minMaxIdx(InputArray src, double* minVal, double* maxVal = 0, + int* minIdx = 0, int* maxIdx = 0, InputArray mask = noArray()); + +/** @overload +@param a input single-channel array. +@param minVal pointer to the returned minimum value; NULL is used if not required. +@param maxVal pointer to the returned maximum value; NULL is used if not required. +@param minIdx pointer to the returned minimum location (in nD case); NULL is used if not required; +Otherwise, it must point to an array of src.dims elements, the coordinates of the minimum element +in each dimension are stored there sequentially. +@param maxIdx pointer to the returned maximum location (in nD case). NULL is used if not required. +*/ +CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal, + double* maxVal, int* minIdx = 0, int* maxIdx = 0); + +/** @brief Reduces a matrix to a vector. + +The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of +1D vectors and performing the specified operation on the vectors until a single row/column is +obtained. For example, the function can be used to compute horizontal and vertical projections of a +raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one. +In case of #REDUCE_SUM and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy. +And multi-channel arrays are also supported in these two reduction modes. + +The following code demonstrates its usage for a single channel matrix. +@snippet snippets/core_reduce.cpp example + +And the following code demonstrates its usage for a two-channel matrix. +@snippet snippets/core_reduce.cpp example2 + +@param src input 2D matrix. +@param dst output vector. Its size and type is defined by dim and dtype parameters. +@param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to +a single row. 1 means that the matrix is reduced to a single column. +@param rtype reduction operation that could be one of #ReduceTypes +@param dtype when negative, the output vector will have the same type as the input matrix, +otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()). +@sa repeat, reduceArgMin, reduceArgMax +*/ +CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype = -1); + +/** @brief Creates one multi-channel array out of several single-channel ones. + +The function cv::merge merges several arrays to make a single multi-channel array. That is, each +element of the output array will be a concatenation of the elements of the input arrays, where +elements of i-th input array are treated as mv[i].channels()-element vectors. + +The function cv::split does the reverse operation. If you need to shuffle channels in some other +advanced way, use cv::mixChannels. + +The following example shows how to merge 3 single channel matrices into a single 3-channel matrix. +@snippet snippets/core_merge.cpp example + +@param mv input array of matrices to be merged; all the matrices in mv must have the same +size and the same depth. +@param count number of input matrices when mv is a plain C array; it must be greater than zero. +@param dst output array of the same size and the same depth as mv[0]; The number of channels will +be equal to the parameter count. +@sa mixChannels, split, Mat::reshape +*/ +CV_EXPORTS void merge(const Mat* mv, size_t count, OutputArray dst); + +/** @overload +@param mv input vector of matrices to be merged; all the matrices in mv must have the same +size and the same depth. +@param dst output array of the same size and the same depth as mv[0]; The number of channels will +be the total number of channels in the matrix array. + */ +CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst); + +/** @brief Divides a multi-channel array into several single-channel arrays. + +The function cv::split splits a multi-channel array into separate single-channel arrays: +\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f] +If you need to extract a single channel or do some other sophisticated channel permutation, use +mixChannels . + +The following example demonstrates how to split a 3-channel matrix into 3 single channel matrices. +@snippet snippets/core_split.cpp example + +@param src input multi-channel array. +@param mvbegin output array; the number of arrays must match src.channels(); the arrays themselves are +reallocated, if needed. +@sa merge, mixChannels, cvtColor +*/ +CV_EXPORTS void split(const Mat& src, Mat* mvbegin); + +/** @overload +@param m input multi-channel array. +@param mv output vector of arrays; the arrays themselves are reallocated, if needed. +*/ +CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv); + +/** @brief Copies specified channels from input arrays to the specified channels of +output arrays. + +The function cv::mixChannels provides an advanced mechanism for shuffling image channels. + +cv::split,cv::merge,cv::extractChannel,cv::insertChannel and some forms of cv::cvtColor are partial cases of cv::mixChannels. + +In the example below, the code splits a 4-channel BGRA image into a 3-channel BGR (with B and R +channels swapped) and a separate alpha-channel image: +@code{.cpp} + Mat bgra( 100, 100, CV_8UC4, Scalar(255,0,0,255) ); + Mat bgr( bgra.rows, bgra.cols, CV_8UC3 ); + Mat alpha( bgra.rows, bgra.cols, CV_8UC1 ); + + // forming an array of matrices is a quite efficient operation, + // because the matrix data is not copied, only the headers + Mat out[] = { bgr, alpha }; + // bgra[0] -> bgr[2], bgra[1] -> bgr[1], + // bgra[2] -> bgr[0], bgra[3] -> alpha[0] + int from_to[] = { 0,2, 1,1, 2,0, 3,3 }; + mixChannels( &bgra, 1, out, 2, from_to, 4 ); +@endcode +@note Unlike many other new-style C++ functions in OpenCV (see the introduction section and +Mat::create ), cv::mixChannels requires the output arrays to be pre-allocated before calling the +function. +@param src input array or vector of matrices; all of the matrices must have the same size and the +same depth. +@param nsrcs number of matrices in `src`. +@param dst output array or vector of matrices; all the matrices **must be allocated**; their size and +depth must be the same as in `src[0]`. +@param ndsts number of matrices in `dst`. +@param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is +a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in +dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to +src[0].channels()-1, the second input image channels are indexed from src[0].channels() to +src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image +channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is +filled with zero . +@param npairs number of index pairs in `fromTo`. +@sa split, merge, extractChannel, insertChannel, cvtColor +*/ +CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, + const int* fromTo, size_t npairs); + +/** @overload +@param src input array or vector of matrices; all of the matrices must have the same size and the +same depth. +@param dst output array or vector of matrices; all the matrices **must be allocated**; their size and +depth must be the same as in src[0]. +@param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is +a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in +dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to +src[0].channels()-1, the second input image channels are indexed from src[0].channels() to +src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image +channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is +filled with zero . +@param npairs number of index pairs in fromTo. +*/ +CV_EXPORTS void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst, + const int* fromTo, size_t npairs); + +/** @overload +@param src input array or vector of matrices; all of the matrices must have the same size and the +same depth. +@param dst output array or vector of matrices; all the matrices **must be allocated**; their size and +depth must be the same as in src[0]. +@param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is +a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in +dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to +src[0].channels()-1, the second input image channels are indexed from src[0].channels() to +src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image +channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is +filled with zero . +*/ +CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst, + const std::vector& fromTo); + +/** @brief Extracts a single channel from src (coi is 0-based index) +@param src input array +@param dst output array +@param coi index of channel to extract +@sa mixChannels, split +*/ +CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi); + +/** @brief Inserts a single channel to dst (coi is 0-based index) +@param src input array +@param dst output array +@param coi index of channel for insertion +@sa mixChannels, merge +*/ +CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi); + +/** @brief Flips a 2D array around vertical, horizontal, or both axes. + +The function cv::flip flips the array in one of three different ways (row +and column indices are 0-based): +\f[\texttt{dst} _{ij} = +\left\{ +\begin{array}{l l} +\texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\ +\texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\ +\texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\ +\end{array} +\right.\f] +The example scenarios of using the function are the following: +* Vertical flipping of the image (flipCode == 0) to switch between + top-left and bottom-left image origin. This is a typical operation + in video processing on Microsoft Windows\* OS. +* Horizontal flipping of the image with the subsequent horizontal + shift and absolute difference calculation to check for a + vertical-axis symmetry (flipCode \> 0). +* Simultaneous horizontal and vertical flipping of the image with + the subsequent shift and absolute difference calculation to check + for a central symmetry (flipCode \< 0). +* Reversing the order of point arrays (flipCode \> 0 or + flipCode == 0). +@param src input array. +@param dst output array of the same size and type as src. +@param flipCode a flag to specify how to flip the array; 0 means +flipping around the x-axis and positive value (for example, 1) means +flipping around y-axis. Negative value (for example, -1) means flipping +around both axes. +@sa transpose , repeat , completeSymm +*/ +CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode); + +enum RotateFlags { + ROTATE_90_CLOCKWISE = 0, //! A = (cv::Mat_(3, 2) << 1, 4, + 2, 5, + 3, 6); + cv::Mat_ B = (cv::Mat_(3, 2) << 7, 10, + 8, 11, + 9, 12); + + cv::Mat C; + cv::hconcat(A, B, C); + //C: + //[1, 4, 7, 10; + // 2, 5, 8, 11; + // 3, 6, 9, 12] + @endcode + @param src1 first input array to be considered for horizontal concatenation. + @param src2 second input array to be considered for horizontal concatenation. + @param dst output array. It has the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2. + */ +CV_EXPORTS void hconcat(InputArray src1, InputArray src2, OutputArray dst); +/** @overload + @code{.cpp} + std::vector matrices = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)), + cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)), + cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),}; + + cv::Mat out; + cv::hconcat( matrices, out ); + //out: + //[1, 2, 3; + // 1, 2, 3; + // 1, 2, 3; + // 1, 2, 3] + @endcode + @param src input array or vector of matrices. all of the matrices must have the same number of rows and the same depth. + @param dst output array. It has the same number of rows and depth as the src, and the sum of cols of the src. +same depth. + */ +CV_EXPORTS_W void hconcat(InputArrayOfArrays src, OutputArray dst); + +/** @brief Applies vertical concatenation to given matrices. + +The function vertically concatenates two or more cv::Mat matrices (with the same number of cols). +@code{.cpp} + cv::Mat matArray[] = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),}; + + cv::Mat out; + cv::vconcat( matArray, 3, out ); + //out: + //[1, 1, 1, 1; + // 2, 2, 2, 2; + // 3, 3, 3, 3] +@endcode +@param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth. +@param nsrc number of matrices in src. +@param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src. +@sa cv::hconcat(const Mat*, size_t, OutputArray), @sa cv::hconcat(InputArrayOfArrays, OutputArray) and @sa cv::hconcat(InputArray, InputArray, OutputArray) +*/ +CV_EXPORTS void vconcat(const Mat* src, size_t nsrc, OutputArray dst); +/** @overload + @code{.cpp} + cv::Mat_ A = (cv::Mat_(3, 2) << 1, 7, + 2, 8, + 3, 9); + cv::Mat_ B = (cv::Mat_(3, 2) << 4, 10, + 5, 11, + 6, 12); + + cv::Mat C; + cv::vconcat(A, B, C); + //C: + //[1, 7; + // 2, 8; + // 3, 9; + // 4, 10; + // 5, 11; + // 6, 12] + @endcode + @param src1 first input array to be considered for vertical concatenation. + @param src2 second input array to be considered for vertical concatenation. + @param dst output array. It has the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2. + */ +CV_EXPORTS void vconcat(InputArray src1, InputArray src2, OutputArray dst); +/** @overload + @code{.cpp} + std::vector matrices = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)), + cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),}; + + cv::Mat out; + cv::vconcat( matrices, out ); + //out: + //[1, 1, 1, 1; + // 2, 2, 2, 2; + // 3, 3, 3, 3] + @endcode + @param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth + @param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src. +same depth. + */ +CV_EXPORTS_W void vconcat(InputArrayOfArrays src, OutputArray dst); + +/** @brief computes bitwise conjunction of the two arrays (dst = src1 & src2) +Calculates the per-element bit-wise conjunction of two arrays or an +array and a scalar. + +The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for: +* Two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +* An array and a scalar when src2 is constructed from Scalar or has + the same number of elements as `src1.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\f] +* A scalar and an array when src1 is constructed from Scalar or has + the same number of elements as `src2.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +In case of floating-point arrays, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel arrays, each channel is processed +independently. In the second and third cases above, the scalar is first +converted to the array type. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as the input +arrays. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2, + OutputArray dst, InputArray mask = noArray()); + +/** @brief Calculates the per-element bit-wise disjunction of two arrays or an +array and a scalar. + +The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for: +* Two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +* An array and a scalar when src2 is constructed from Scalar or has + the same number of elements as `src1.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\f] +* A scalar and an array when src1 is constructed from Scalar or has + the same number of elements as `src2.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +In case of floating-point arrays, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel arrays, each channel is processed +independently. In the second and third cases above, the scalar is first +converted to the array type. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as the input +arrays. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2, + OutputArray dst, InputArray mask = noArray()); + +/** @brief Calculates the per-element bit-wise "exclusive or" operation on two +arrays or an array and a scalar. + +The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or" +operation for: +* Two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +* An array and a scalar when src2 is constructed from Scalar or has + the same number of elements as `src1.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\f] +* A scalar and an array when src1 is constructed from Scalar or has + the same number of elements as `src2.channels()`: + \f[\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\f] +In case of floating-point arrays, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel arrays, each channel is processed +independently. In the 2nd and 3rd cases above, the scalar is first +converted to the array type. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as the input +arrays. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2, + OutputArray dst, InputArray mask = noArray()); + +/** @brief Inverts every bit of an array. + +The function cv::bitwise_not calculates per-element bit-wise inversion of the input +array: +\f[\texttt{dst} (I) = \neg \texttt{src} (I)\f] +In case of a floating-point input array, its machine-specific bit +representation (usually IEEE754-compliant) is used for the operation. In +case of multi-channel arrays, each channel is processed independently. +@param src input array. +@param dst output array that has the same size and type as the input +array. +@param mask optional operation mask, 8-bit single channel array, that +specifies elements of the output array to be changed. +*/ +CV_EXPORTS_W void bitwise_not(InputArray src, OutputArray dst, + InputArray mask = noArray()); + +/** @brief Calculates the per-element absolute difference between two arrays or between an array and a scalar. + +The function cv::absdiff calculates: +* Absolute difference between two arrays when they have the same + size and type: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f] +* Absolute difference between an array and a scalar when the second + array is constructed from Scalar or has as many elements as the + number of channels in `src1`: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\f] +* Absolute difference between a scalar and an array when the first + array is constructed from Scalar or has as many elements as the + number of channels in `src2`: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\f] + where I is a multi-dimensional index of array elements. In case of + multi-channel arrays, each channel is processed independently. +@note Saturation is not applied when the arrays have the depth CV_32S. +You may even get a negative value in the case of overflow. +@param src1 first input array or a scalar. +@param src2 second input array or a scalar. +@param dst output array that has the same size and type as input arrays. +@sa cv::abs(const Mat&) +*/ +CV_EXPORTS_W void absdiff(InputArray src1, InputArray src2, OutputArray dst); + +/** @brief This is an overloaded member function, provided for convenience (python) +Copies the matrix to another one. +When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data. +@param src source matrix. +@param dst Destination matrix. If it does not have a proper size or type before the operation, it is +reallocated. +@param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix +elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. +*/ + +void CV_EXPORTS_W copyTo(InputArray src, OutputArray dst, InputArray mask); +/** @brief Checks if array elements lie between the elements of two other arrays. + +The function checks the range as follows: +- For every element of a single-channel input array: + \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0\f] +- For two-channel arrays: + \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0 \land \texttt{lowerb} (I)_1 \leq \texttt{src} (I)_1 \leq \texttt{upperb} (I)_1\f] +- and so forth. + +That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the +specified 1D, 2D, 3D, ... box and 0 otherwise. + +When the lower and/or upper boundary parameters are scalars, the indexes +(I) at lowerb and upperb in the above formulas should be omitted. +@param src first input array. +@param lowerb inclusive lower boundary array or a scalar. +@param upperb inclusive upper boundary array or a scalar. +@param dst output array of the same size as src and CV_8U type. +*/ +CV_EXPORTS_W void inRange(InputArray src, InputArray lowerb, + InputArray upperb, OutputArray dst); + +/** @brief Performs the per-element comparison of two arrays or an array and scalar value. + +The function compares: +* Elements of two arrays when src1 and src2 have the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\f] +* Elements of src1 with a scalar src2 when src2 is constructed from + Scalar or has a single element: + \f[\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\f] +* src1 with elements of src2 when src1 is constructed from Scalar or + has a single element: + \f[\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\f] +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: +@code{.cpp} + Mat dst1 = src1 >= src2; + Mat dst2 = src1 < 8; + ... +@endcode +@param src1 first input array or a scalar; when it is an array, it must have a single channel. +@param src2 second input array or a scalar; when it is an array, it must have a single channel. +@param dst output array of type ref CV_8U that has the same size and the same number of channels as + the input arrays. +@param cmpop a flag, that specifies correspondence between the arrays (cv::CmpTypes) +@sa checkRange, min, max, threshold +*/ +CV_EXPORTS_W void compare(InputArray src1, InputArray src2, OutputArray dst, int cmpop); + +/** @brief Calculates per-element minimum of two arrays or an array and a scalar. + +The function cv::min calculates the per-element minimum of two arrays: +\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f] +or array and a scalar: +\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\f] +@param src1 first input array. +@param src2 second input array of the same size and type as src1. +@param dst output array of the same size and type as src1. +@sa max, compare, inRange, minMaxLoc +*/ +CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void min(const Mat& src1, const Mat& src2, Mat& dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void min(const UMat& src1, const UMat& src2, UMat& dst); + +/** @brief Calculates per-element maximum of two arrays or an array and a scalar. + +The function cv::max calculates the per-element maximum of two arrays: +\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f] +or array and a scalar: +\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\f] +@param src1 first input array. +@param src2 second input array of the same size and type as src1 . +@param dst output array of the same size and type as src1. +@sa min, compare, inRange, minMaxLoc, @ref MatrixExpressions +*/ +CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void max(const Mat& src1, const Mat& src2, Mat& dst); +/** @overload +needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&, _Compare) +*/ +CV_EXPORTS void max(const UMat& src1, const UMat& src2, UMat& dst); + +/** @brief Calculates a square root of array elements. + +The function cv::sqrt calculates a square root of each input array element. +In case of multi-channel arrays, each channel is processed +independently. The accuracy is approximately the same as of the built-in +std::sqrt . +@param src input floating-point array. +@param dst output array of the same size and type as src. +*/ +CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst); + +/** @brief Raises every array element to a power. + +The function cv::pow raises every element of the input array to power : +\f[\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\f] + +So, for a non-integer power exponent, the absolute values of input array +elements are used. However, it is possible to get true values for +negative values using some extra operations. In the example below, +computing the 5th root of array src shows: +@code{.cpp} + Mat mask = src < 0; + pow(src, 1./5, dst); + subtract(Scalar::all(0), dst, dst, mask); +@endcode +For some values of power, such as integer values, 0.5 and -0.5, +specialized faster algorithms are used. + +Special values (NaN, Inf) are not handled. +@param src input array. +@param power exponent of power. +@param dst output array of the same size and type as src. +@sa sqrt, exp, log, cartToPolar, polarToCart +*/ +CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst); + +/** @brief Calculates the exponent of every array element. + +The function cv::exp calculates the exponent of every element of the input +array: +\f[\texttt{dst} [I] = e^{ src(I) }\f] + +The maximum relative error is about 7e-6 for single-precision input and +less than 1e-10 for double-precision input. Currently, the function +converts denormalized values to zeros on output. Special values (NaN, +Inf) are not handled. +@param src input array. +@param dst output array of the same size and type as src. +@sa log , cartToPolar , polarToCart , phase , pow , sqrt , magnitude +*/ +CV_EXPORTS_W void exp(InputArray src, OutputArray dst); + +/** @brief Calculates the natural logarithm of every array element. + +The function cv::log calculates the natural logarithm of every element of the input array: +\f[\texttt{dst} (I) = \log (\texttt{src}(I)) \f] + +Output on zero, negative and special (NaN, Inf) values is undefined. + +@param src input array. +@param dst output array of the same size and type as src . +@sa exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude +*/ +CV_EXPORTS_W void log(InputArray src, OutputArray dst); + +/** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle. + +The function cv::polarToCart calculates the Cartesian coordinates of each 2D +vector represented by the corresponding elements of magnitude and angle: +\f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f] + +The relative accuracy of the estimated coordinates is about 1e-6. +@param magnitude input floating-point array of magnitudes of 2D vectors; +it can be an empty matrix (=Mat()), in this case, the function assumes +that all the magnitudes are =1; if it is not empty, it must have the +same size and type as angle. +@param angle input floating-point array of angles of 2D vectors. +@param x output array of x-coordinates of 2D vectors; it has the same +size and type as angle. +@param y output array of y-coordinates of 2D vectors; it has the same +size and type as angle. +@param angleInDegrees when true, the input angles are measured in +degrees, otherwise, they are measured in radians. +@sa cartToPolar, magnitude, phase, exp, log, pow, sqrt +*/ +CV_EXPORTS_W void polarToCart(InputArray magnitude, InputArray angle, + OutputArray x, OutputArray y, bool angleInDegrees = false); + +/** @brief Calculates the magnitude and angle of 2D vectors. + +The function cv::cartToPolar calculates either the magnitude, angle, or both +for every 2D vector (x(I),y(I)): +\f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f] + +The angles are calculated with accuracy about 0.3 degrees. For the point +(0,0), the angle is set to 0. +@param x array of x-coordinates; this must be a single-precision or +double-precision floating-point array. +@param y array of y-coordinates, that must have the same size and same type as x. +@param magnitude output array of magnitudes of the same size and type as x. +@param angle output array of angles that has the same size and type as +x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees). +@param angleInDegrees a flag, indicating whether the angles are measured +in radians (which is by default), or in degrees. +@sa Sobel, Scharr +*/ +CV_EXPORTS_W void cartToPolar(InputArray x, InputArray y, + OutputArray magnitude, OutputArray angle, + bool angleInDegrees = false); + +/** @brief Calculates the rotation angle of 2D vectors. + +The function cv::phase calculates the rotation angle of each 2D vector that +is formed from the corresponding elements of x and y : +\f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f] + +The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 , +the corresponding angle(I) is set to 0. +@param x input floating-point array of x-coordinates of 2D vectors. +@param y input array of y-coordinates of 2D vectors; it must have the +same size and the same type as x. +@param angle output array of vector angles; it has the same size and +same type as x . +@param angleInDegrees when true, the function calculates the angle in +degrees, otherwise, they are measured in radians. +*/ +CV_EXPORTS_W void phase(InputArray x, InputArray y, OutputArray angle, + bool angleInDegrees = false); + +/** @brief Calculates the magnitude of 2D vectors. + +The function cv::magnitude calculates the magnitude of 2D vectors formed +from the corresponding elements of x and y arrays: +\f[\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\f] +@param x floating-point array of x-coordinates of the vectors. +@param y floating-point array of y-coordinates of the vectors; it must +have the same size as x. +@param magnitude output array of the same size and type as x. +@sa cartToPolar, polarToCart, phase, sqrt +*/ +CV_EXPORTS_W void magnitude(InputArray x, InputArray y, OutputArray magnitude); + +/** @brief Checks every element of an input array for invalid values. + +The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal \> +-DBL_MAX and maxVal \< DBL_MAX, the function also checks that each value is between minVal and +maxVal. In case of multi-channel arrays, each channel is processed independently. If some values +are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the +function either returns false (when quiet=true) or throws an exception. +@param a input array. +@param quiet a flag, indicating whether the functions quietly return false when the array elements +are out of range or they throw an exception. +@param pos optional output parameter, when not NULL, must be a pointer to array of src.dims +elements. +@param minVal inclusive lower boundary of valid values range. +@param maxVal exclusive upper boundary of valid values range. +*/ +CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true, CV_OUT Point* pos = 0, + double minVal = -DBL_MAX, double maxVal = DBL_MAX); + +/** @brief converts NaNs to the given number +@param a input/output matrix (CV_32F type). +@param val value to convert the NaNs +*/ +CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0); + +/** @brief Performs generalized matrix multiplication. + +The function cv::gemm performs generalized matrix multiplication similar to the +gemm functions in BLAS level 3. For example, +`gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)` +corresponds to +\f[\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\f] + +In case of complex (two-channel) data, performed a complex matrix +multiplication. + +The function can be replaced with a matrix expression. For example, the +above call can be replaced with: +@code{.cpp} + dst = alpha*src1.t()*src2 + beta*src3.t(); +@endcode +@param src1 first multiplied input matrix that could be real(CV_32FC1, +CV_64FC1) or complex(CV_32FC2, CV_64FC2). +@param src2 second multiplied input matrix of the same type as src1. +@param alpha weight of the matrix product. +@param src3 third optional delta matrix added to the matrix product; it +should have the same type as src1 and src2. +@param beta weight of src3. +@param dst output matrix; it has the proper size and the same type as +input matrices. +@param flags operation flags (cv::GemmFlags) +@sa mulTransposed , transform +*/ +CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha, + InputArray src3, double beta, OutputArray dst, int flags = 0); + +/** @brief Calculates the product of a matrix and its transposition. + +The function cv::mulTransposed calculates the product of src and its +transposition: +\f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\f] +if aTa=true , and +\f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\f] +otherwise. The function is used to calculate the covariance matrix. With +zero delta, it can be used as a faster substitute for general matrix +product A\*B when B=A' +@param src input single-channel matrix. Note that unlike gemm, the +function can multiply not only floating-point matrices. +@param dst output square matrix. +@param aTa Flag specifying the multiplication ordering. See the +description below. +@param delta Optional delta matrix subtracted from src before the +multiplication. When the matrix is empty ( delta=noArray() ), it is +assumed to be zero, that is, nothing is subtracted. If it has the same +size as src , it is simply subtracted. Otherwise, it is "repeated" (see +repeat ) to cover the full src and then subtracted. Type of the delta +matrix, when it is not empty, must be the same as the type of created +output matrix. See the dtype parameter description below. +@param scale Optional scale factor for the matrix product. +@param dtype Optional type of the output matrix. When it is negative, +the output matrix will have the same type as src . Otherwise, it will be +type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F . +@sa calcCovarMatrix, gemm, repeat, reduce +*/ +CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, + InputArray delta = noArray(), + double scale = 1, int dtype = -1 ); + +/** @brief Transposes a matrix. + +The function cv::transpose transposes the matrix src : +\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f] +@note No complex conjugation is done in case of a complex matrix. It +should be done separately if needed. +@param src input array. +@param dst output array of the same type as src. +*/ +CV_EXPORTS_W void transpose(InputArray src, OutputArray dst); + +/** @brief Performs the matrix transformation of every array element. + +The function cv::transform performs the matrix transformation of every +element of the array src and stores the results in dst : +\f[\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\f] +(when m.cols=src.channels() ), or +\f[\texttt{dst} (I) = \texttt{m} \cdot [ \texttt{src} (I); 1]\f] +(when m.cols=src.channels()+1 ) + +Every element of the N -channel array src is interpreted as N -element +vector that is transformed using the M x N or M x (N+1) matrix m to +M-element vector - the corresponding element of the output array dst . + +The function may be used for geometrical transformation of +N -dimensional points, arbitrary linear color space transformation (such +as various kinds of RGB to YUV transforms), shuffling the image +channels, and so forth. +@param src input array that must have as many channels (1 to 4) as +m.cols or m.cols-1. +@param dst output array of the same size and depth as src; it has as +many channels as m.rows. +@param m transformation 2x2 or 2x3 floating-point matrix. +@sa perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective +*/ +CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m ); + +/** @brief Performs the perspective matrix transformation of vectors. + +The function cv::perspectiveTransform transforms every element of src by +treating it as a 2D or 3D vector, in the following way: +\f[(x, y, z) \rightarrow (x'/w, y'/w, z'/w)\f] +where +\f[(x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1 \end{bmatrix}\f] +and +\f[w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\f] + +Here a 3D vector transformation is shown. In case of a 2D vector +transformation, the z component is omitted. + +@note The function transforms a sparse set of 2D or 3D vectors. If you +want to transform an image using perspective transformation, use +warpPerspective . If you have an inverse problem, that is, you want to +compute the most probable perspective transformation out of several +pairs of corresponding points, you can use getPerspectiveTransform or +findHomography . +@param src input two-channel or three-channel floating-point array; each +element is a 2D/3D vector to be transformed. +@param dst output array of the same size and type as src. +@param m 3x3 or 4x4 floating-point transformation matrix. +@sa transform, warpPerspective, getPerspectiveTransform, findHomography +*/ +CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst, InputArray m ); + +/** @brief Copies the lower or the upper half of a square matrix to its another half. + +The function cv::completeSymm copies the lower or the upper half of a square matrix to +its another half. The matrix diagonal remains unchanged: + - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i > j\f$ if + lowerToUpper=false + - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i < j\f$ if + lowerToUpper=true + +@param m input-output floating-point square matrix. +@param lowerToUpper operation flag; if true, the lower half is copied to +the upper half. Otherwise, the upper half is copied to the lower half. +@sa flip, transpose +*/ +CV_EXPORTS_W void completeSymm(InputOutputArray m, bool lowerToUpper = false); + +/** @brief Initializes a scaled identity matrix. + +The function cv::setIdentity initializes a scaled identity matrix: +\f[\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\f] + +The function can also be emulated using the matrix initializers and the +matrix expressions: +@code + Mat A = Mat::eye(4, 3, CV_32F)*5; + // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]] +@endcode +@param mtx matrix to initialize (not necessarily square). +@param s value to assign to diagonal elements. +@sa Mat::zeros, Mat::ones, Mat::setTo, Mat::operator= +*/ +CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s = Scalar(1)); + +/** @brief Returns the determinant of a square floating-point matrix. + +The function cv::determinant calculates and returns the determinant of the +specified matrix. For small matrices ( mtx.cols=mtx.rows\<=3 ), the +direct method is used. For larger matrices, the function uses LU +factorization with partial pivoting. + +For symmetric positively-determined matrices, it is also possible to use +eigen decomposition to calculate the determinant. +@param mtx input matrix that must have CV_32FC1 or CV_64FC1 type and +square size. +@sa trace, invert, solve, eigen, @ref MatrixExpressions +*/ +CV_EXPORTS_W double determinant(InputArray mtx); + +/** @brief Returns the trace of a matrix. + +The function cv::trace returns the sum of the diagonal elements of the +matrix mtx . +\f[\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\f] +@param mtx input matrix. +*/ +CV_EXPORTS_W Scalar trace(InputArray mtx); + +/** @brief Finds the inverse or pseudo-inverse of a matrix. + +The function cv::invert inverts the matrix src and stores the result in dst +. When the matrix src is singular or non-square, the function calculates +the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is +minimal, where I is an identity matrix. + +In case of the #DECOMP_LU method, the function returns non-zero value if +the inverse has been successfully calculated and 0 if src is singular. + +In case of the #DECOMP_SVD method, the function returns the inverse +condition number of src (the ratio of the smallest singular value to the +largest singular value) and 0 if src is singular. The SVD method +calculates a pseudo-inverse matrix if src is singular. + +Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with +non-singular square matrices that should also be symmetrical and +positively defined. In this case, the function stores the inverted +matrix in dst and returns non-zero. Otherwise, it returns 0. + +@param src input floating-point M x N matrix. +@param dst output matrix of N x M size and the same type as src. +@param flags inversion method (cv::DecompTypes) +@sa solve, SVD +*/ +CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags = DECOMP_LU); + +/** @brief Solves one or more linear systems or least-squares problems. + +The function cv::solve solves a linear system or least-squares problem (the +latter is possible with SVD or QR methods, or by specifying the flag +#DECOMP_NORMAL ): +\f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\f] + +If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1 +if src1 (or \f$\texttt{src1}^T\texttt{src1}\f$ ) is non-singular. Otherwise, +it returns 0. In the latter case, dst is not valid. Other methods find a +pseudo-solution in case of a singular left-hand side part. + +@note If you want to find a unity-norm solution of an under-defined +singular system \f$\texttt{src1}\cdot\texttt{dst}=0\f$ , the function solve +will not do the work. Use SVD::solveZ instead. + +@param src1 input matrix on the left-hand side of the system. +@param src2 input matrix on the right-hand side of the system. +@param dst output solution. +@param flags solution (matrix inversion) method (#DecompTypes) +@sa invert, SVD, eigen +*/ +CV_EXPORTS_W bool solve(InputArray src1, InputArray src2, + OutputArray dst, int flags = DECOMP_LU); + +/** @brief Sorts each row or each column of a matrix. + +The function cv::sort sorts each matrix row or each matrix column in +ascending or descending order. So you should pass two operation flags to +get desired behaviour. If you want to sort matrix rows or columns +lexicographically, you can use STL std::sort generic function with the +proper comparison predicate. + +@param src input single-channel array. +@param dst output array of the same size and type as src. +@param flags operation flags, a combination of #SortFlags +@sa sortIdx, randShuffle +*/ +CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags); + +/** @brief Sorts each row or each column of a matrix. + +The function cv::sortIdx sorts each matrix row or each matrix column in the +ascending or descending order. So you should pass two operation flags to +get desired behaviour. Instead of reordering the elements themselves, it +stores the indices of sorted elements in the output array. For example: +@code + Mat A = Mat::eye(3,3,CV_32F), B; + sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING); + // B will probably contain + // (because of equal elements in A some permutations are possible): + // [[1, 2, 0], [0, 2, 1], [0, 1, 2]] +@endcode +@param src input single-channel array. +@param dst output integer array of the same size as src. +@param flags operation flags that could be a combination of cv::SortFlags +@sa sort, randShuffle +*/ +CV_EXPORTS_W void sortIdx(InputArray src, OutputArray dst, int flags); + +/** @brief Finds the real roots of a cubic equation. + +The function solveCubic finds the real roots of a cubic equation: +- if coeffs is a 4-element vector: +\f[\texttt{coeffs} [0] x^3 + \texttt{coeffs} [1] x^2 + \texttt{coeffs} [2] x + \texttt{coeffs} [3] = 0\f] +- if coeffs is a 3-element vector: +\f[x^3 + \texttt{coeffs} [0] x^2 + \texttt{coeffs} [1] x + \texttt{coeffs} [2] = 0\f] + +The roots are stored in the roots array. +@param coeffs equation coefficients, an array of 3 or 4 elements. +@param roots output array of real roots that has 1 or 3 elements. +@return number of real roots. It can be 0, 1 or 2. +*/ +CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots); + +/** @brief Finds the real or complex roots of a polynomial equation. + +The function cv::solvePoly finds real and complex roots of a polynomial equation: +\f[\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\f] +@param coeffs array of polynomial coefficients. +@param roots output (complex) array of roots. +@param maxIters maximum number of iterations the algorithm does. +*/ +CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters = 300); + +/** @brief Calculates eigenvalues and eigenvectors of a symmetric matrix. + +The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric +matrix src: +@code + src*eigenvectors.row(i).t() = eigenvalues.at(i)*eigenvectors.row(i).t() +@endcode + +@note Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix. + +@param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical +(src ^T^ == src). +@param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored +in the descending order. +@param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the +eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding +eigenvalues. +@sa eigenNonSymmetric, completeSymm , PCA +*/ +CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues, + OutputArray eigenvectors = noArray()); + +/** @brief Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only). + +@note Assumes real eigenvalues. + +The function calculates eigenvalues and eigenvectors (optional) of the square matrix src: +@code + src*eigenvectors.row(i).t() = eigenvalues.at(i)*eigenvectors.row(i).t() +@endcode + +@param src input matrix (CV_32FC1 or CV_64FC1 type). +@param eigenvalues output vector of eigenvalues (type is the same type as src). +@param eigenvectors output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues. +@sa eigen +*/ +CV_EXPORTS_W void eigenNonSymmetric(InputArray src, OutputArray eigenvalues, + OutputArray eigenvectors); + +/** @brief Calculates the covariance matrix of a set of vectors. + +The function cv::calcCovarMatrix calculates the covariance matrix and, optionally, the mean vector of +the set of input vectors. +@param samples samples stored as separate matrices +@param nsamples number of samples +@param covar output covariance matrix of the type ctype and square size. +@param mean input or output (depending on the flags) array as the average value of the input vectors. +@param flags operation flags as a combination of #CovarFlags +@param ctype type of the matrixl; it equals 'CV_64F' by default. +@sa PCA, mulTransposed, Mahalanobis +@todo InputArrayOfArrays +*/ +CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, + int flags, int ctype = CV_64F); + +/** @overload +@note use #COVAR_ROWS or #COVAR_COLS flag +@param samples samples stored as rows/columns of a single matrix. +@param covar output covariance matrix of the type ctype and square size. +@param mean input or output (depending on the flags) array as the average value of the input vectors. +@param flags operation flags as a combination of #CovarFlags +@param ctype type of the matrixl; it equals 'CV_64F' by default. +*/ +CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, + InputOutputArray mean, int flags, int ctype = CV_64F); + +/** wrap PCA::operator() */ +CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, int maxComponents = 0); + +/** wrap PCA::operator() and add eigenvalues output parameter */ +CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, OutputArray eigenvalues, + int maxComponents = 0); + +/** wrap PCA::operator() */ +CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, double retainedVariance); + +/** wrap PCA::operator() and add eigenvalues output parameter */ +CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean, + OutputArray eigenvectors, OutputArray eigenvalues, + double retainedVariance); + +/** wrap PCA::project */ +CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean, + InputArray eigenvectors, OutputArray result); + +/** wrap PCA::backProject */ +CV_EXPORTS_W void PCABackProject(InputArray data, InputArray mean, + InputArray eigenvectors, OutputArray result); + +/** wrap SVD::compute */ +CV_EXPORTS_W void SVDecomp( InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags = 0 ); + +/** wrap SVD::backSubst */ +CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt, + InputArray rhs, OutputArray dst ); + +/** @brief Calculates the Mahalanobis distance between two vectors. + +The function cv::Mahalanobis calculates and returns the weighted distance between two vectors: +\f[d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\f] +The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using +the invert function (preferably using the #DECOMP_SVD method, as the most accurate). +@param v1 first 1D input vector. +@param v2 second 1D input vector. +@param icovar inverse covariance matrix. +*/ +CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar); + +/** @brief Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array. + +The function cv::dft performs one of the following: +- Forward the Fourier transform of a 1D vector of N elements: + \f[Y = F^{(N)} \cdot X,\f] + where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$ +- Inverse the Fourier transform of a 1D vector of N elements: + \f[\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\f] + where \f$F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\f$ +- Forward the 2D Fourier transform of a M x N matrix: + \f[Y = F^{(M)} \cdot X \cdot F^{(N)}\f] +- Inverse the 2D Fourier transform of a M x N matrix: + \f[\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\f] + +In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input +spectrum of the inverse Fourier transform can be represented in a packed format called *CCS* +(complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here +is how 2D *CCS* spectrum looks: +\f[\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\f] + +In case of 1D transform of a real vector, the output looks like the first row of the matrix above. + +So, the function chooses an operation mode depending on the flags and size of the input array: +- If #DFT_ROWS is set or the input array has a single row or single column, the function + performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set. + Otherwise, it performs a 2D transform. +- If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or + 2D transform: + - When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as + input. + - When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as + input. In case of 2D transform, it uses the packed format as shown above. In case of a + single 1D transform, it looks like the first row of the matrix above. In case of + multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix + looks like the first row of the matrix above. +- If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the + output is a complex array of the same size as input. The function performs a forward or + inverse 1D or 2D transform of the whole input array or each row of the input array + independently, depending on the flags DFT_INVERSE and DFT_ROWS. +- When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT + is set, the output is a real array of the same size as input. The function performs a 1D or 2D + inverse transformation of the whole input array or each individual row, depending on the flags + #DFT_INVERSE and #DFT_ROWS. + +If #DFT_SCALE is set, the scaling is done after the transformation. + +Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed +efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the +current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize +method. + +The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays: +@code + void convolveDFT(InputArray A, InputArray B, OutputArray C) + { + // reallocate the output array if needed + C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type()); + Size dftSize; + // calculate the size of DFT transform + dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1); + dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1); + + // allocate temporary buffers and initialize them with 0's + Mat tempA(dftSize, A.type(), Scalar::all(0)); + Mat tempB(dftSize, B.type(), Scalar::all(0)); + + // copy A and B to the top-left corners of tempA and tempB, respectively + Mat roiA(tempA, Rect(0,0,A.cols,A.rows)); + A.copyTo(roiA); + Mat roiB(tempB, Rect(0,0,B.cols,B.rows)); + B.copyTo(roiB); + + // now transform the padded A & B in-place; + // use "nonzeroRows" hint for faster processing + dft(tempA, tempA, 0, A.rows); + dft(tempB, tempB, 0, B.rows); + + // multiply the spectrums; + // the function handles packed spectrum representations well + mulSpectrums(tempA, tempB, tempA); + + // transform the product back from the frequency domain. + // Even though all the result rows will be non-zero, + // you need only the first C.rows of them, and thus you + // pass nonzeroRows == C.rows + dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows); + + // now copy the result back to C. + tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C); + + // all the temporary buffers will be deallocated automatically + } +@endcode +To optimize this sample, consider the following approaches: +- Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to + the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole + tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols) + rightmost columns of the matrices. +- This DFT-based convolution does not have to be applied to the whole big arrays, especially if B + is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts. + To do this, you need to split the output array C into multiple tiles. For each tile, estimate + which parts of A and B are required to calculate convolution in this tile. If the tiles in C are + too small, the speed will decrease a lot because of repeated work. In the ultimate case, when + each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution + algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and + there is also a slowdown because of bad cache locality. So, there is an optimal tile size + somewhere in the middle. +- If different tiles in C can be calculated in parallel and, thus, the convolution is done by + parts, the loop can be threaded. + +All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by +using them, you can get the performance even better than with the above theoretically optimal +implementation. Though, those two functions actually calculate cross-correlation, not convolution, +so you need to "flip" the second convolution operand B vertically and horizontally using flip . +@note +- An example using the discrete fourier transform can be found at + opencv_source_code/samples/cpp/dft.cpp +- (Python) An example using the dft functionality to perform Wiener deconvolution can be found + at opencv_source/samples/python/deconvolution.py +- (Python) An example rearranging the quadrants of a Fourier image can be found at + opencv_source/samples/python/dft.py +@param src input array that could be real or complex. +@param dst output array whose size and type depends on the flags . +@param flags transformation flags, representing a combination of the #DftFlags +@param nonzeroRows when the parameter is not zero, the function assumes that only the first +nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the +output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the +rows more efficiently and save some time; this technique is very useful for calculating array +cross-correlation or convolution using DFT. +@sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar , +magnitude , phase +*/ +CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0); + +/** @brief Calculates the inverse Discrete Fourier Transform of a 1D or 2D array. + +idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) . +@note None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of +dft or idft explicitly to make these transforms mutually inverse. +@sa dft, dct, idct, mulSpectrums, getOptimalDFTSize +@param src input floating-point real or complex array. +@param dst output array whose size and type depend on the flags. +@param flags operation flags (see dft and #DftFlags). +@param nonzeroRows number of dst rows to process; the rest of the rows have undefined content (see +the convolution sample in dft description. +*/ +CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags = 0, int nonzeroRows = 0); + +/** @brief Performs a forward or inverse discrete Cosine transform of 1D or 2D array. + +The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D +floating-point array: +- Forward Cosine transform of a 1D vector of N elements: + \f[Y = C^{(N)} \cdot X\f] + where + \f[C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\f] + and + \f$\alpha_0=1\f$, \f$\alpha_j=2\f$ for *j \> 0*. +- Inverse Cosine transform of a 1D vector of N elements: + \f[X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\f] + (since \f$C^{(N)}\f$ is an orthogonal matrix, \f$C^{(N)} \cdot \left(C^{(N)}\right)^T = I\f$ ) +- Forward 2D Cosine transform of M x N matrix: + \f[Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\f] +- Inverse 2D Cosine transform of M x N matrix: + \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f] + +The function chooses the mode of operation by looking at the flags and size of the input array: +- If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it + is an inverse 1D or 2D transform. +- If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row. +- If the array is a single column or a single row, the function performs a 1D transform. +- If none of the above is true, the function performs a 2D transform. + +@note Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you +can pad the array when necessary. +Also, the function performance depends very much, and not monotonically, on the array size (see +getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT +of a vector of size N/2 . Thus, the optimal DCT size N1 \>= N can be calculated as: +@code + size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); } + N1 = getOptimalDCTSize(N); +@endcode +@param src input floating-point array. +@param dst output array of the same size and type as src . +@param flags transformation flags as a combination of cv::DftFlags (DCT_*) +@sa dft , getOptimalDFTSize , idct +*/ +CV_EXPORTS_W void dct(InputArray src, OutputArray dst, int flags = 0); + +/** @brief Calculates the inverse Discrete Cosine Transform of a 1D or 2D array. + +idct(src, dst, flags) is equivalent to dct(src, dst, flags | DCT_INVERSE). +@param src input floating-point single-channel array. +@param dst output array of the same size and type as src. +@param flags operation flags. +@sa dct, dft, idft, getOptimalDFTSize +*/ +CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags = 0); + +/** @brief Performs the per-element multiplication of two Fourier spectrums. + +The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex +matrices that are results of a real or complex Fourier transform. + +The function, together with dft and idft , may be used to calculate convolution (pass conjB=false ) +or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are +simply multiplied (per element) with an optional conjugation of the second-array elements. When the +arrays are real, they are assumed to be CCS-packed (see dft for details). +@param a first input array. +@param b second input array of the same size and type as src1 . +@param c output array of the same size and type as src1 . +@param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that +each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a `0` as value. +@param conjB optional flag that conjugates the second input array before the multiplication (true) +or not (false). +*/ +CV_EXPORTS_W void mulSpectrums(InputArray a, InputArray b, OutputArray c, + int flags, bool conjB = false); + +/** @brief Returns the optimal DFT size for a given vector size. + +DFT performance is not a monotonic function of a vector size. Therefore, when you calculate +convolution of two arrays or perform the spectral analysis of an array, it usually makes sense to +pad the input data with zeros to get a bit larger array that can be transformed much faster than the +original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the fastest to process. +Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2) +are also processed quite efficiently. + +The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize +so that the DFT of a vector of size N can be processed efficiently. In the current implementation N += 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r. + +The function returns a negative number if vecsize is too large (very close to INT_MAX ). + +While the function cannot be used directly to estimate the optimal vector size for DCT transform +(since the current DCT implementation supports only even-size vectors), it can be easily processed +as getOptimalDFTSize((vecsize+1)/2)\*2. +@param vecsize vector size. +@sa dft , dct , idft , idct , mulSpectrums +*/ +CV_EXPORTS_W int getOptimalDFTSize(int vecsize); + +/** @brief Returns the default random number generator. + +The function cv::theRNG returns the default random number generator. For each thread, there is a +separate random number generator, so you can use the function safely in multi-thread environments. +If you just need to get a single random number using this generator or initialize an array, you can +use randu or randn instead. But if you are going to generate many random numbers inside a loop, it +is much faster to use this function to retrieve the generator and then use RNG::operator _Tp() . +@sa RNG, randu, randn +*/ +CV_EXPORTS RNG& theRNG(); + +/** @brief Sets state of default random number generator. + +The function cv::setRNGSeed sets state of default random number generator to custom value. +@param seed new state for default random number generator +@sa RNG, randu, randn +*/ +CV_EXPORTS_W void setRNGSeed(int seed); + +/** @brief Generates a single uniformly-distributed random number or an array of random numbers. + +Non-template variant of the function fills the matrix dst with uniformly-distributed +random numbers from the specified range: +\f[\texttt{low} _c \leq \texttt{dst} (I)_c < \texttt{high} _c\f] +@param dst output array of random numbers; the array must be pre-allocated. +@param low inclusive lower boundary of the generated random numbers. +@param high exclusive upper boundary of the generated random numbers. +@sa RNG, randn, theRNG +*/ +CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high); + +/** @brief Fills the array with normally distributed random numbers. + +The function cv::randn fills the matrix dst with normally distributed random numbers with the specified +mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the +value range of the output array data type. +@param dst output array of random numbers; the array must be pre-allocated and have 1 to 4 channels. +@param mean mean value (expectation) of the generated random numbers. +@param stddev standard deviation of the generated random numbers; it can be either a vector (in +which case a diagonal standard deviation matrix is assumed) or a square matrix. +@sa RNG, randu +*/ +CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev); + +/** @brief Shuffles the array elements randomly. + +The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and +swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor . +@param dst input/output numerical 1D array. +@param iterFactor scale factor that determines the number of random swap operations (see the details +below). +@param rng optional random number generator used for shuffling; if it is zero, theRNG () is used +instead. +@sa RNG, sort +*/ +CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0); + +/** @brief Principal Component Analysis + +The class is used to calculate a special basis for a set of vectors. The +basis will consist of eigenvectors of the covariance matrix calculated +from the input set of vectors. The class %PCA can also transform +vectors to/from the new coordinate space defined by the basis. Usually, +in this new coordinate system, each vector from the original set (and +any linear combination of such vectors) can be quite accurately +approximated by taking its first few components, corresponding to the +eigenvectors of the largest eigenvalues of the covariance matrix. +Geometrically it means that you calculate a projection of the vector to +a subspace formed by a few eigenvectors corresponding to the dominant +eigenvalues of the covariance matrix. And usually such a projection is +very close to the original vector. So, you can represent the original +vector from a high-dimensional space with a much shorter vector +consisting of the projected vector's coordinates in the subspace. Such a +transformation is also known as Karhunen-Loeve Transform, or KLT. +See http://en.wikipedia.org/wiki/Principal_component_analysis + +The sample below is the function that takes two matrices. The first +function stores a set of vectors (a row per vector) that is used to +calculate PCA. The second function stores another "test" set of vectors +(a row per vector). First, these vectors are compressed with PCA, then +reconstructed back, and then the reconstruction error norm is computed +and printed for each vector. : + +@code{.cpp} +using namespace cv; + +PCA compressPCA(const Mat& pcaset, int maxComponents, + const Mat& testset, Mat& compressed) +{ + PCA pca(pcaset, // pass the data + Mat(), // we do not have a pre-computed mean vector, + // so let the PCA engine to compute it + PCA::DATA_AS_ROW, // indicate that the vectors + // are stored as matrix rows + // (use PCA::DATA_AS_COL if the vectors are + // the matrix columns) + maxComponents // specify, how many principal components to retain + ); + // if there is no test data, just return the computed basis, ready-to-use + if( !testset.data ) + return pca; + CV_Assert( testset.cols == pcaset.cols ); + + compressed.create(testset.rows, maxComponents, testset.type()); + + Mat reconstructed; + for( int i = 0; i < testset.rows; i++ ) + { + Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed; + // compress the vector, the result will be stored + // in the i-th row of the output matrix + pca.project(vec, coeffs); + // and then reconstruct it + pca.backProject(coeffs, reconstructed); + // and measure the error + printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2)); + } + return pca; +} +@endcode +@sa calcCovarMatrix, mulTransposed, SVD, dft, dct +*/ +class CV_EXPORTS PCA +{ +public: + enum Flags { DATA_AS_ROW = 0, //!< indicates that the input samples are stored as matrix rows + DATA_AS_COL = 1, //!< indicates that the input samples are stored as matrix columns + USE_AVG = 2 //! + }; + + /** @brief default constructor + + The default constructor initializes an empty %PCA structure. The other + constructors initialize the structure and call PCA::operator()(). + */ + PCA(); + + /** @overload + @param data input samples stored as matrix rows or matrix columns. + @param mean optional mean value; if the matrix is empty (@c noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout (PCA::Flags) + @param maxComponents maximum number of components that %PCA should + retain; by default, all the components are retained. + */ + PCA(InputArray data, InputArray mean, int flags, int maxComponents = 0); + + /** @overload + @param data input samples stored as matrix rows or matrix columns. + @param mean optional mean value; if the matrix is empty (noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout (PCA::Flags) + @param retainedVariance Percentage of variance that PCA should retain. + Using this parameter will let the PCA decided how many components to + retain but it will always keep at least 2. + */ + PCA(InputArray data, InputArray mean, int flags, double retainedVariance); + + /** @brief performs %PCA + + The operator performs %PCA of the supplied dataset. It is safe to reuse + the same PCA structure for multiple datasets. That is, if the structure + has been previously used with another dataset, the existing internal + data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref + mean are allocated and computed. + + The computed @ref eigenvalues are sorted from the largest to the smallest and + the corresponding @ref eigenvectors are stored as eigenvectors rows. + + @param data input samples stored as the matrix rows or as the matrix + columns. + @param mean optional mean value; if the matrix is empty (noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout. (Flags) + @param maxComponents maximum number of components that PCA should + retain; by default, all the components are retained. + */ + PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents = 0); + + /** @overload + @param data input samples stored as the matrix rows or as the matrix + columns. + @param mean optional mean value; if the matrix is empty (noArray()), + the mean is computed from the data. + @param flags operation flags; currently the parameter is only used to + specify the data layout. (PCA::Flags) + @param retainedVariance Percentage of variance that %PCA should retain. + Using this parameter will let the %PCA decided how many components to + retain but it will always keep at least 2. + */ + PCA& operator()(InputArray data, InputArray mean, int flags, double retainedVariance); + + /** @brief Projects vector(s) to the principal component subspace. + + The methods project one or more vectors to the principal component + subspace, where each vector projection is represented by coefficients in + the principal component basis. The first form of the method returns the + matrix that the second form writes to the result. So the first form can + be used as a part of expression while the second form can be more + efficient in a processing loop. + @param vec input vector(s); must have the same dimensionality and the + same layout as the input data used at %PCA phase, that is, if + DATA_AS_ROW are specified, then `vec.cols==data.cols` + (vector dimensionality) and `vec.rows` is the number of vectors to + project, and the same is true for the PCA::DATA_AS_COL case. + */ + Mat project(InputArray vec) const; + + /** @overload + @param vec input vector(s); must have the same dimensionality and the + same layout as the input data used at PCA phase, that is, if + DATA_AS_ROW are specified, then `vec.cols==data.cols` + (vector dimensionality) and `vec.rows` is the number of vectors to + project, and the same is true for the PCA::DATA_AS_COL case. + @param result output vectors; in case of PCA::DATA_AS_COL, the + output matrix has as many columns as the number of input vectors, this + means that `result.cols==vec.cols` and the number of rows match the + number of principal components (for example, `maxComponents` parameter + passed to the constructor). + */ + void project(InputArray vec, OutputArray result) const; + + /** @brief Reconstructs vectors from their PC projections. + + The methods are inverse operations to PCA::project. They take PC + coordinates of projected vectors and reconstruct the original vectors. + Unless all the principal components have been retained, the + reconstructed vectors are different from the originals. But typically, + the difference is small if the number of components is large enough (but + still much smaller than the original vector dimensionality). As a + result, PCA is used. + @param vec coordinates of the vectors in the principal component + subspace, the layout and size are the same as of PCA::project output + vectors. + */ + Mat backProject(InputArray vec) const; + + /** @overload + @param vec coordinates of the vectors in the principal component + subspace, the layout and size are the same as of PCA::project output + vectors. + @param result reconstructed vectors; the layout and size are the same as + of PCA::project input vectors. + */ + void backProject(InputArray vec, OutputArray result) const; + + /** @brief write PCA objects + + Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage + */ + void write(FileStorage& fs) const; + + /** @brief load PCA objects + + Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode + */ + void read(const FileNode& fn); + + Mat eigenvectors; //!< eigenvectors of the covariation matrix + Mat eigenvalues; //!< eigenvalues of the covariation matrix + Mat mean; //!< mean value subtracted before the projection and added after the back projection +}; + +/** @example samples/cpp/pca.cpp +An example using %PCA for dimensionality reduction while maintaining an amount of variance +*/ + +/** @example samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp +Check @ref tutorial_introduction_to_pca "the corresponding tutorial" for more details +*/ + +/** +@brief Linear Discriminant Analysis +@todo document this class +*/ +class CV_EXPORTS LDA +{ +public: + /** @brief constructor + Initializes a LDA with num_components (default 0). + */ + explicit LDA(int num_components = 0); + + /** Initializes and performs a Discriminant Analysis with Fisher's + Optimization Criterion on given data in src and corresponding labels + in labels. If 0 (or less) number of components are given, they are + automatically determined for given data in computation. + */ + LDA(InputArrayOfArrays src, InputArray labels, int num_components = 0); + + /** Serializes this object to a given filename. + */ + void save(const String& filename) const; + + /** Deserializes this object from a given filename. + */ + void load(const String& filename); + + /** Serializes this object to a given cv::FileStorage. + */ + void save(FileStorage& fs) const; + + /** Deserializes this object from a given cv::FileStorage. + */ + void load(const FileStorage& node); + + /** destructor + */ + ~LDA(); + + /** Compute the discriminants for data in src (row aligned) and labels. + */ + void compute(InputArrayOfArrays src, InputArray labels); + + /** Projects samples into the LDA subspace. + src may be one or more row aligned samples. + */ + Mat project(InputArray src); + + /** Reconstructs projections from the LDA subspace. + src may be one or more row aligned projections. + */ + Mat reconstruct(InputArray src); + + /** Returns the eigenvectors of this LDA. + */ + Mat eigenvectors() const { return _eigenvectors; } + + /** Returns the eigenvalues of this LDA. + */ + Mat eigenvalues() const { return _eigenvalues; } + + static Mat subspaceProject(InputArray W, InputArray mean, InputArray src); + static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src); + +protected: + int _num_components; + Mat _eigenvectors; + Mat _eigenvalues; + void lda(InputArrayOfArrays src, InputArray labels); +}; + +/** @brief Singular Value Decomposition + +Class for computing Singular Value Decomposition of a floating-point +matrix. The Singular Value Decomposition is used to solve least-square +problems, under-determined linear systems, invert matrices, compute +condition numbers, and so on. + +If you want to compute a condition number of a matrix or an absolute value of +its determinant, you do not need `u` and `vt`. You can pass +flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u +and vt must be computed, which is not necessary most of the time. + +@sa invert, solve, eigen, determinant +*/ +class CV_EXPORTS SVD +{ +public: + enum Flags { + /** allow the algorithm to modify the decomposed matrix; it can save space and speed up + processing. currently ignored. */ + MODIFY_A = 1, + /** indicates that only a vector of singular values `w` is to be processed, while u and vt + will be set to empty matrices */ + NO_UV = 2, + /** when the matrix is not square, by default the algorithm produces u and vt matrices of + sufficiently large size for the further A reconstruction; if, however, FULL_UV flag is + specified, u and vt will be full-size square orthogonal matrices.*/ + FULL_UV = 4 + }; + + /** @brief the default constructor + + initializes an empty SVD structure + */ + SVD(); + + /** @overload + initializes an empty SVD structure and then calls SVD::operator() + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param flags operation flags (SVD::Flags) + */ + SVD( InputArray src, int flags = 0 ); + + /** @brief the operator that performs SVD. The previously allocated u, w and vt are released. + + The operator performs the singular value decomposition of the supplied + matrix. The u,`vt` , and the vector of singular values w are stored in + the structure. The same SVD structure can be reused many times with + different matrices. Each time, if needed, the previous u,`vt` , and w + are reclaimed and the new matrices are created, which is all handled by + Mat::create. + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param flags operation flags (SVD::Flags) + */ + SVD& operator ()( InputArray src, int flags = 0 ); + + /** @brief decomposes matrix and stores the results to user-provided matrices + + The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor + and SVD::operator(), they store the results to the user-provided + matrices: + + @code{.cpp} + Mat A, w, u, vt; + SVD::compute(A, w, u, vt); + @endcode + + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param w calculated singular values + @param u calculated left singular vectors + @param vt transposed matrix of right singular vectors + @param flags operation flags - see SVD::Flags. + */ + static void compute( InputArray src, OutputArray w, + OutputArray u, OutputArray vt, int flags = 0 ); + + /** @overload + computes singular values of a matrix + @param src decomposed matrix. The depth has to be CV_32F or CV_64F. + @param w calculated singular values + @param flags operation flags - see SVD::Flags. + */ + static void compute( InputArray src, OutputArray w, int flags = 0 ); + + /** @brief performs back substitution + */ + static void backSubst( InputArray w, InputArray u, + InputArray vt, InputArray rhs, + OutputArray dst ); + + /** @brief solves an under-determined singular linear system + + The method finds a unit-length solution x of a singular linear system + A\*x = 0. Depending on the rank of A, there can be no solutions, a + single solution or an infinite number of solutions. In general, the + algorithm solves the following problem: + \f[dst = \arg \min _{x: \| x \| =1} \| src \cdot x \|\f] + @param src left-hand-side matrix. + @param dst found solution. + */ + static void solveZ( InputArray src, OutputArray dst ); + + /** @brief performs a singular value back substitution. + + The method calculates a back substitution for the specified right-hand + side: + + \f[\texttt{x} = \texttt{vt} ^T \cdot diag( \texttt{w} )^{-1} \cdot \texttt{u} ^T \cdot \texttt{rhs} \sim \texttt{A} ^{-1} \cdot \texttt{rhs}\f] + + Using this technique you can either get a very accurate solution of the + convenient linear system, or the best (in the least-squares terms) + pseudo-solution of an overdetermined linear system. + + @param rhs right-hand side of a linear system (u\*w\*v')\*dst = rhs to + be solved, where A has been previously decomposed. + + @param dst found solution of the system. + + @note Explicit SVD with the further back substitution only makes sense + if you need to solve many linear systems with the same left-hand side + (for example, src ). If all you need is to solve a single system + (possibly with multiple rhs immediately available), simply call solve + add pass #DECOMP_SVD there. It does absolutely the same thing. + */ + void backSubst( InputArray rhs, OutputArray dst ) const; + + /** @todo document */ + template static + void compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt ); + + /** @todo document */ + template static + void compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w ); + + /** @todo document */ + template static + void backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u, const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, Matx<_Tp, n, nb>& dst ); + + Mat u, w, vt; +}; + +/** @brief Random Number Generator + +Random number generator. It encapsulates the state (currently, a 64-bit +integer) and has methods to return scalar random values and to fill +arrays with random values. Currently it supports uniform and Gaussian +(normal) distributions. The generator uses Multiply-With-Carry +algorithm, introduced by G. Marsaglia ( + ). +Gaussian-distribution random numbers are generated using the Ziggurat +algorithm ( ), +introduced by G. Marsaglia and W. W. Tsang. +*/ +class CV_EXPORTS RNG +{ +public: + enum { UNIFORM = 0, + NORMAL = 1 + }; + + /** @brief constructor + + These are the RNG constructors. The first form sets the state to some + pre-defined value, equal to 2\*\*32-1 in the current implementation. The + second form sets the state to the specified value. If you passed state=0 + , the constructor uses the above default value instead to avoid the + singular random number sequence, consisting of all zeros. + */ + RNG(); + /** @overload + @param state 64-bit value used to initialize the RNG. + */ + RNG(uint64 state); + /**The method updates the state using the MWC algorithm and returns the + next 32-bit random number.*/ + unsigned next(); + + /**Each of the methods updates the state using the MWC algorithm and + returns the next random number of the specified type. In case of integer + types, the returned number is from the available value range for the + specified type. In case of floating-point types, the returned value is + from [0,1) range. + */ + operator uchar(); + /** @overload */ + operator schar(); + /** @overload */ + operator ushort(); + /** @overload */ + operator short(); + /** @overload */ + operator unsigned(); + /** @overload */ + operator int(); + /** @overload */ + operator float(); + /** @overload */ + operator double(); + + /** @brief returns a random integer sampled uniformly from [0, N). + + The methods transform the state using the MWC algorithm and return the + next random number. The first form is equivalent to RNG::next . The + second form returns the random number modulo N , which means that the + result is in the range [0, N) . + */ + unsigned operator ()(); + /** @overload + @param N upper non-inclusive boundary of the returned random number. + */ + unsigned operator ()(unsigned N); + + /** @brief returns uniformly distributed integer random number from [a,b) range + + The methods transform the state using the MWC algorithm and return the + next uniformly-distributed random number of the specified type, deduced + from the input parameter type, from the range [a, b) . There is a nuance + illustrated by the following sample: + + @code{.cpp} + RNG rng; + + // always produces 0 + double a = rng.uniform(0, 1); + + // produces double from [0, 1) + double a1 = rng.uniform((double)0, (double)1); + + // produces float from [0, 1) + float b = rng.uniform(0.f, 1.f); + + // produces double from [0, 1) + double c = rng.uniform(0., 1.); + + // may cause compiler error because of ambiguity: + // RNG::uniform(0, (int)0.999999)? or RNG::uniform((double)0, 0.99999)? + double d = rng.uniform(0, 0.999999); + @endcode + + The compiler does not take into account the type of the variable to + which you assign the result of RNG::uniform . The only thing that + matters to the compiler is the type of a and b parameters. So, if you + want a floating-point random number, but the range boundaries are + integer numbers, either put dots in the end, if they are constants, or + use explicit type cast operators, as in the a1 initialization above. + @param a lower inclusive boundary of the returned random number. + @param b upper non-inclusive boundary of the returned random number. + */ + int uniform(int a, int b); + /** @overload */ + float uniform(float a, float b); + /** @overload */ + double uniform(double a, double b); + + /** @brief Fills arrays with random numbers. + + @param mat 2D or N-dimensional matrix; currently matrices with more than + 4 channels are not supported by the methods, use Mat::reshape as a + possible workaround. + @param distType distribution type, RNG::UNIFORM or RNG::NORMAL. + @param a first distribution parameter; in case of the uniform + distribution, this is an inclusive lower boundary, in case of the normal + distribution, this is a mean value. + @param b second distribution parameter; in case of the uniform + distribution, this is a non-inclusive upper boundary, in case of the + normal distribution, this is a standard deviation (diagonal of the + standard deviation matrix or the full standard deviation matrix). + @param saturateRange pre-saturation flag; for uniform distribution only; + if true, the method will first convert a and b to the acceptable value + range (according to the mat datatype) and then will generate uniformly + distributed random numbers within the range [saturate(a), saturate(b)), + if saturateRange=false, the method will generate uniformly distributed + random numbers in the original range [a, b) and then will saturate them, + it means, for example, that + theRNG().fill(mat_8u, RNG::UNIFORM, -DBL_MAX, DBL_MAX) will likely + produce array mostly filled with 0's and 255's, since the range (0, 255) + is significantly smaller than [-DBL_MAX, DBL_MAX). + + Each of the methods fills the matrix with the random values from the + specified distribution. As the new numbers are generated, the RNG state + is updated accordingly. In case of multiple-channel images, every + channel is filled independently, which means that RNG cannot generate + samples from the multi-dimensional Gaussian distribution with + non-diagonal covariance matrix directly. To do that, the method + generates samples from multi-dimensional standard Gaussian distribution + with zero mean and identity covariation matrix, and then transforms them + using transform to get samples from the specified Gaussian distribution. + */ + void fill( InputOutputArray mat, int distType, InputArray a, InputArray b, bool saturateRange = false ); + + /** @brief Returns the next random number sampled from the Gaussian distribution + @param sigma standard deviation of the distribution. + + The method transforms the state using the MWC algorithm and returns the + next random number from the Gaussian distribution N(0,sigma) . That is, + the mean value of the returned random numbers is zero and the standard + deviation is the specified sigma . + */ + double gaussian(double sigma); + + uint64 state; + + bool operator ==(const RNG& other) const; +}; + +/** @brief Mersenne Twister random number generator + +Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c +@todo document +*/ +class CV_EXPORTS RNG_MT19937 +{ +public: + RNG_MT19937(); + RNG_MT19937(unsigned s); + void seed(unsigned s); + + unsigned next(); + + operator int(); + operator unsigned(); + operator float(); + operator double(); + + unsigned operator ()(unsigned N); + unsigned operator ()(); + + /** @brief returns uniformly distributed integer random number from [a,b) range*/ + int uniform(int a, int b); + /** @brief returns uniformly distributed floating-point random number from [a,b) range*/ + float uniform(float a, float b); + /** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range*/ + double uniform(double a, double b); + +private: + enum PeriodParameters {N = 624, M = 397}; + unsigned state[N]; + int mti; +}; + +//! @} core_array + +//! @addtogroup core_cluster +//! @{ + +/** @example samples/cpp/kmeans.cpp +An example on K-means clustering +*/ + +/** @brief Finds centers of clusters and groups input samples around the clusters. + +The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters +and groups the input samples around the clusters. As an output, \f$\texttt{bestLabels}_i\f$ contains a +0-based cluster index for the sample stored in the \f$i^{th}\f$ row of the samples matrix. + +@note +- (Python) An example on K-means clustering can be found at + opencv_source_code/samples/python/kmeans.py +@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed. +Examples of this array can be: +- Mat points(count, 2, CV_32F); +- Mat points(count, 1, CV_32FC2); +- Mat points(1, count, CV_32FC2); +- std::vector\ points(sampleCount); +@param K Number of clusters to split the set by. +@param bestLabels Input/output integer array that stores the cluster indices for every sample. +@param criteria The algorithm termination criteria, that is, the maximum number of iterations and/or +the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster +centers moves by less than criteria.epsilon on some iteration, the algorithm stops. +@param attempts Flag to specify the number of times the algorithm is executed using different +initial labellings. The algorithm returns the labels that yield the best compactness (see the last +function parameter). +@param flags Flag that can take values of cv::KmeansFlags +@param centers Output matrix of the cluster centers, one row per each cluster center. +@return The function returns the compactness measure that is computed as +\f[\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\f] +after every attempt. The best (minimum) value is chosen and the corresponding labels and the +compactness value are returned by the function. Basically, you can use only the core of the +function, set the number of attempts to 1, initialize labels each time using a custom algorithm, +pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best +(most-compact) clustering. +*/ +CV_EXPORTS_W double kmeans( InputArray data, int K, InputOutputArray bestLabels, + TermCriteria criteria, int attempts, + int flags, OutputArray centers = noArray() ); + +//! @} core_cluster + +//! @addtogroup core_basic +//! @{ + +/////////////////////////////// Formatted output of cv::Mat /////////////////////////// + +/** @todo document */ +class CV_EXPORTS Formatted +{ +public: + virtual const char* next() = 0; + virtual void reset() = 0; + virtual ~Formatted(); +}; + +/** @todo document */ +class CV_EXPORTS Formatter +{ +public: + enum FormatType { + FMT_DEFAULT = 0, + FMT_MATLAB = 1, + FMT_CSV = 2, + FMT_PYTHON = 3, + FMT_NUMPY = 4, + FMT_C = 5 + }; + + virtual ~Formatter(); + + virtual Ptr format(const Mat& mtx) const = 0; + + virtual void set16fPrecision(int p = 4) = 0; + virtual void set32fPrecision(int p = 8) = 0; + virtual void set64fPrecision(int p = 16) = 0; + virtual void setMultiline(bool ml = true) = 0; + + static Ptr get(Formatter::FormatType fmt = FMT_DEFAULT); + +}; + +static inline +String& operator << (String& out, Ptr fmtd) +{ + fmtd->reset(); + for(const char* str = fmtd->next(); str; str = fmtd->next()) + out += cv::String(str); + return out; +} + +static inline +String& operator << (String& out, const Mat& mtx) +{ + return out << Formatter::get()->format(mtx); +} + +//////////////////////////////////////// Algorithm //////////////////////////////////// + +class CV_EXPORTS Algorithm; + +template struct ParamType {}; + + +/** @brief This is a base class for all more or less complex algorithms in OpenCV + +especially for classes of algorithms, for which there can be multiple implementations. The examples +are stereo correspondence (for which there are algorithms like block matching, semi-global block +matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians +models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck +etc.). + +Here is example of SimpleBlobDetector use in your application via Algorithm interface: +@snippet snippets/core_various.cpp Algorithm +*/ +class CV_EXPORTS_W Algorithm +{ +public: + Algorithm(); + virtual ~Algorithm(); + + /** @brief Clears the algorithm state + */ + CV_WRAP virtual void clear() {} + + /** @brief Stores algorithm parameters in a file storage + */ + virtual void write(FileStorage& fs) const { CV_UNUSED(fs); } + + /** @brief simplified API for language bindings + * @overload + */ + CV_WRAP void write(const Ptr& fs, const String& name = String()) const; + + /** @brief Reads algorithm parameters from a file storage + */ + CV_WRAP virtual void read(const FileNode& fn) { CV_UNUSED(fn); } + + /** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read + */ + CV_WRAP virtual bool empty() const { return false; } + + /** @brief Reads algorithm from the file node + + This is static template method of Algorithm. It's usage is following (in the case of SVM): + @code + cv::FileStorage fsRead("example.xml", FileStorage::READ); + Ptr svm = Algorithm::read(fsRead.root()); + @endcode + In order to make this method work, the derived class must overwrite Algorithm::read(const + FileNode& fn) and also have static create() method without parameters + (or with all the optional parameters) + */ + template static Ptr<_Tp> read(const FileNode& fn) + { + Ptr<_Tp> obj = _Tp::create(); + obj->read(fn); + return !obj->empty() ? obj : Ptr<_Tp>(); + } + + /** @brief Loads algorithm from the file + + @param filename Name of the file to read. + @param objname The optional name of the node to read (if empty, the first top-level node will be used) + + This is static template method of Algorithm. It's usage is following (in the case of SVM): + @code + Ptr svm = Algorithm::load("my_svm_model.xml"); + @endcode + In order to make this method work, the derived class must overwrite Algorithm::read(const + FileNode& fn). + */ + template static Ptr<_Tp> load(const String& filename, const String& objname=String()) + { + FileStorage fs(filename, FileStorage::READ); + CV_Assert(fs.isOpened()); + FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname]; + if (fn.empty()) return Ptr<_Tp>(); + Ptr<_Tp> obj = _Tp::create(); + obj->read(fn); + return !obj->empty() ? obj : Ptr<_Tp>(); + } + + /** @brief Loads algorithm from a String + + @param strModel The string variable containing the model you want to load. + @param objname The optional name of the node to read (if empty, the first top-level node will be used) + + This is static template method of Algorithm. It's usage is following (in the case of SVM): + @code + Ptr svm = Algorithm::loadFromString(myStringModel); + @endcode + */ + template static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String()) + { + FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY); + FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname]; + Ptr<_Tp> obj = _Tp::create(); + obj->read(fn); + return !obj->empty() ? obj : Ptr<_Tp>(); + } + + /** Saves the algorithm to a file. + In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */ + CV_WRAP virtual void save(const String& filename) const; + + /** Returns the algorithm string identifier. + This string is used as top level xml/yml node tag when the object is saved to a file or string. */ + CV_WRAP virtual String getDefaultName() const; + +protected: + void writeFormat(FileStorage& fs) const; +}; + +enum struct Param { + INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, + UNSIGNED_INT=8, UINT64=9, UCHAR=11, SCALAR=12 +}; + + + +template<> struct ParamType +{ + typedef bool const_param_type; + typedef bool member_type; + + static const Param type = Param::BOOLEAN; +}; + +template<> struct ParamType +{ + typedef int const_param_type; + typedef int member_type; + + static const Param type = Param::INT; +}; + +template<> struct ParamType +{ + typedef double const_param_type; + typedef double member_type; + + static const Param type = Param::REAL; +}; + +template<> struct ParamType +{ + typedef const String& const_param_type; + typedef String member_type; + + static const Param type = Param::STRING; +}; + +template<> struct ParamType +{ + typedef const Mat& const_param_type; + typedef Mat member_type; + + static const Param type = Param::MAT; +}; + +template<> struct ParamType > +{ + typedef const std::vector& const_param_type; + typedef std::vector member_type; + + static const Param type = Param::MAT_VECTOR; +}; + +template<> struct ParamType +{ + typedef const Ptr& const_param_type; + typedef Ptr member_type; + + static const Param type = Param::ALGORITHM; +}; + +template<> struct ParamType +{ + typedef float const_param_type; + typedef float member_type; + + static const Param type = Param::FLOAT; +}; + +template<> struct ParamType +{ + typedef unsigned const_param_type; + typedef unsigned member_type; + + static const Param type = Param::UNSIGNED_INT; +}; + +template<> struct ParamType +{ + typedef uint64 const_param_type; + typedef uint64 member_type; + + static const Param type = Param::UINT64; +}; + +template<> struct ParamType +{ + typedef uchar const_param_type; + typedef uchar member_type; + + static const Param type = Param::UCHAR; +}; + +template<> struct ParamType +{ + typedef const Scalar& const_param_type; + typedef Scalar member_type; + + static const Param type = Param::SCALAR; +}; + +template +struct ParamType<_Tp, typename std::enable_if< std::is_enum<_Tp>::value >::type> +{ + typedef typename std::underlying_type<_Tp>::type const_param_type; + typedef typename std::underlying_type<_Tp>::type member_type; + + static const Param type = Param::INT; +}; + +//! @} core_basic + +} //namespace cv + +#include "opencv2/core/operations.hpp" +#include "opencv2/core/cvstd.inl.hpp" +#include "opencv2/core/utility.hpp" +#include "opencv2/core/optim.hpp" +#include "opencv2/core/ovx.hpp" + +#endif /*OPENCV_CORE_HPP*/ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/affine.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/affine.hpp new file mode 100644 index 0000000..1806382 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/affine.hpp @@ -0,0 +1,678 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_AFFINE3_HPP +#define OPENCV_CORE_AFFINE3_HPP + +#ifdef __cplusplus + +#include + +namespace cv +{ + +//! @addtogroup core +//! @{ + + /** @brief Affine transform + * + * It represents a 4x4 homogeneous transformation matrix \f$T\f$ + * + * \f[T = + * \begin{bmatrix} + * R & t\\ + * 0 & 1\\ + * \end{bmatrix} + * \f] + * + * where \f$R\f$ is a 3x3 rotation matrix and \f$t\f$ is a 3x1 translation vector. + * + * You can specify \f$R\f$ either by a 3x3 rotation matrix or by a 3x1 rotation vector, + * which is converted to a 3x3 rotation matrix by the Rodrigues formula. + * + * To construct a matrix \f$T\f$ representing first rotation around the axis \f$r\f$ with rotation + * angle \f$|r|\f$ in radian (right hand rule) and then translation by the vector \f$t\f$, you can use + * + * @code + * cv::Vec3f r, t; + * cv::Affine3f T(r, t); + * @endcode + * + * If you already have the rotation matrix \f$R\f$, then you can use + * + * @code + * cv::Matx33f R; + * cv::Affine3f T(R, t); + * @endcode + * + * To extract the rotation matrix \f$R\f$ from \f$T\f$, use + * + * @code + * cv::Matx33f R = T.rotation(); + * @endcode + * + * To extract the translation vector \f$t\f$ from \f$T\f$, use + * + * @code + * cv::Vec3f t = T.translation(); + * @endcode + * + * To extract the rotation vector \f$r\f$ from \f$T\f$, use + * + * @code + * cv::Vec3f r = T.rvec(); + * @endcode + * + * Note that since the mapping from rotation vectors to rotation matrices + * is many to one. The returned rotation vector is not necessarily the one + * you used before to set the matrix. + * + * If you have two transformations \f$T = T_1 * T_2\f$, use + * + * @code + * cv::Affine3f T, T1, T2; + * T = T2.concatenate(T1); + * @endcode + * + * To get the inverse transform of \f$T\f$, use + * + * @code + * cv::Affine3f T, T_inv; + * T_inv = T.inv(); + * @endcode + * + */ + template + class Affine3 + { + public: + typedef T float_type; + typedef Matx Mat3; + typedef Matx Mat4; + typedef Vec Vec3; + + //! Default constructor. It represents a 4x4 identity matrix. + Affine3(); + + //! Augmented affine matrix + Affine3(const Mat4& affine); + + /** + * The resulting 4x4 matrix is + * + * \f[ + * \begin{bmatrix} + * R & t\\ + * 0 & 1\\ + * \end{bmatrix} + * \f] + * + * @param R 3x3 rotation matrix. + * @param t 3x1 translation vector. + */ + Affine3(const Mat3& R, const Vec3& t = Vec3::all(0)); + + /** + * Rodrigues vector. + * + * The last row of the current matrix is set to [0,0,0,1]. + * + * @param rvec 3x1 rotation vector. Its direction indicates the rotation axis and its length + * indicates the rotation angle in radian (using right hand rule). + * @param t 3x1 translation vector. + */ + Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0)); + + /** + * Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix. + * + * The last row of the current matrix is set to [0,0,0,1] when data is not 4x4. + * + * @param data 1-channel matrix. + * when it is 4x4, it is copied to the current matrix and t is not used. + * When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used. + * When it is 3x3, it is copied to the upper left 3x3 part of the current matrix. + * When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used + * to compute a 3x3 rotation matrix. + * @param t 3x1 translation vector. It is used only when data is neither 4x4 nor 3x4. + */ + explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0)); + + //! From 16-element array + explicit Affine3(const float_type* vals); + + //! Create an 4x4 identity transform + static Affine3 Identity(); + + /** + * Rotation matrix. + * + * Copy the rotation matrix to the upper left 3x3 part of the current matrix. + * The remaining elements of the current matrix are not changed. + * + * @param R 3x3 rotation matrix. + * + */ + void rotation(const Mat3& R); + + /** + * Rodrigues vector. + * + * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected. + * + * @param rvec 3x1 rotation vector. The direction indicates the rotation axis and + * its length indicates the rotation angle in radian (using the right thumb convention). + */ + void rotation(const Vec3& rvec); + + /** + * Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix. + * + * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected. + * + * @param data 1-channel matrix. + * When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix. + * When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula + * is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix. + */ + void rotation(const Mat& data); + + /** + * Copy the 3x3 matrix L to the upper left part of the current matrix + * + * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected. + * + * @param L 3x3 matrix. + */ + void linear(const Mat3& L); + + /** + * Copy t to the first three elements of the last column of the current matrix + * + * It sets the upper right 3x1 part of the matrix. The remaining part is unaffected. + * + * @param t 3x1 translation vector. + */ + void translation(const Vec3& t); + + //! @return the upper left 3x3 part + Mat3 rotation() const; + + //! @return the upper left 3x3 part + Mat3 linear() const; + + //! @return the upper right 3x1 part + Vec3 translation() const; + + //! Rodrigues vector. + //! @return a vector representing the upper left 3x3 rotation matrix of the current matrix. + //! @warning Since the mapping between rotation vectors and rotation matrices is many to one, + //! this function returns only one rotation vector that represents the current rotation matrix, + //! which is not necessarily the same one set by `rotation(const Vec3& rvec)`. + Vec3 rvec() const; + + //! @return the inverse of the current matrix. + Affine3 inv(int method = cv::DECOMP_SVD) const; + + //! a.rotate(R) is equivalent to Affine(R, 0) * a; + Affine3 rotate(const Mat3& R) const; + + //! a.rotate(rvec) is equivalent to Affine(rvec, 0) * a; + Affine3 rotate(const Vec3& rvec) const; + + //! a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix + Affine3 translate(const Vec3& t) const; + + //! a.concatenate(affine) is equivalent to affine * a; + Affine3 concatenate(const Affine3& affine) const; + + template operator Affine3() const; + + template Affine3 cast() const; + + Mat4 matrix; + +#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H + Affine3(const Eigen::Transform& affine); + Affine3(const Eigen::Transform& affine); + operator Eigen::Transform() const; + operator Eigen::Transform() const; +#endif + }; + + template static + Affine3 operator*(const Affine3& affine1, const Affine3& affine2); + + //! V is a 3-element vector with member fields x, y and z + template static + V operator*(const Affine3& affine, const V& vector); + + typedef Affine3 Affine3f; + typedef Affine3 Affine3d; + + static Vec3f operator*(const Affine3f& affine, const Vec3f& vector); + static Vec3d operator*(const Affine3d& affine, const Vec3d& vector); + + template class DataType< Affine3<_Tp> > + { + public: + typedef Affine3<_Tp> value_type; + typedef Affine3::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 16, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; + }; + + namespace traits { + template + struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; }; + template + struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; }; + } // namespace + +//! @} core + +} + +//! @cond IGNORED + +/////////////////////////////////////////////////////////////////////////////////// +// Implementation + +template inline +cv::Affine3::Affine3() + : matrix(Mat4::eye()) +{} + +template inline +cv::Affine3::Affine3(const Mat4& affine) + : matrix(affine) +{} + +template inline +cv::Affine3::Affine3(const Mat3& R, const Vec3& t) +{ + rotation(R); + translation(t); + matrix.val[12] = matrix.val[13] = matrix.val[14] = 0; + matrix.val[15] = 1; +} + +template inline +cv::Affine3::Affine3(const Vec3& _rvec, const Vec3& t) +{ + rotation(_rvec); + translation(t); + matrix.val[12] = matrix.val[13] = matrix.val[14] = 0; + matrix.val[15] = 1; +} + +template inline +cv::Affine3::Affine3(const cv::Mat& data, const Vec3& t) +{ + CV_Assert(data.type() == cv::traits::Type::value); + CV_Assert(data.channels() == 1); + + if (data.cols == 4 && data.rows == 4) + { + data.copyTo(matrix); + return; + } + else if (data.cols == 4 && data.rows == 3) + { + rotation(data(Rect(0, 0, 3, 3))); + translation(data(Rect(3, 0, 1, 3))); + } + else + { + rotation(data); + translation(t); + } + + matrix.val[12] = matrix.val[13] = matrix.val[14] = 0; + matrix.val[15] = 1; +} + +template inline +cv::Affine3::Affine3(const float_type* vals) : matrix(vals) +{} + +template inline +cv::Affine3 cv::Affine3::Identity() +{ + return Affine3(cv::Affine3::Mat4::eye()); +} + +template inline +void cv::Affine3::rotation(const Mat3& R) +{ + linear(R); +} + +template inline +void cv::Affine3::rotation(const Vec3& _rvec) +{ + double theta = norm(_rvec); + + if (theta < DBL_EPSILON) + rotation(Mat3::eye()); + else + { + double c = std::cos(theta); + double s = std::sin(theta); + double c1 = 1. - c; + double itheta = (theta != 0) ? 1./theta : 0.; + + Point3_ r = _rvec*itheta; + + Mat3 rrt( r.x*r.x, r.x*r.y, r.x*r.z, r.x*r.y, r.y*r.y, r.y*r.z, r.x*r.z, r.y*r.z, r.z*r.z ); + Mat3 r_x( 0, -r.z, r.y, r.z, 0, -r.x, -r.y, r.x, 0 ); + + // R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x] + // where [r_x] is [0 -rz ry; rz 0 -rx; -ry rx 0] + Mat3 R = c*Mat3::eye() + c1*rrt + s*r_x; + + rotation(R); + } +} + +//Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix; +template inline +void cv::Affine3::rotation(const cv::Mat& data) +{ + CV_Assert(data.type() == cv::traits::Type::value); + CV_Assert(data.channels() == 1); + + if (data.cols == 3 && data.rows == 3) + { + Mat3 R; + data.copyTo(R); + rotation(R); + } + else if ((data.cols == 3 && data.rows == 1) || (data.cols == 1 && data.rows == 3)) + { + Vec3 _rvec; + data.reshape(1, 3).copyTo(_rvec); + rotation(_rvec); + } + else + CV_Error(Error::StsError, "Input matrix can only be 3x3, 1x3 or 3x1"); +} + +template inline +void cv::Affine3::linear(const Mat3& L) +{ + matrix.val[0] = L.val[0]; matrix.val[1] = L.val[1]; matrix.val[ 2] = L.val[2]; + matrix.val[4] = L.val[3]; matrix.val[5] = L.val[4]; matrix.val[ 6] = L.val[5]; + matrix.val[8] = L.val[6]; matrix.val[9] = L.val[7]; matrix.val[10] = L.val[8]; +} + +template inline +void cv::Affine3::translation(const Vec3& t) +{ + matrix.val[3] = t[0]; matrix.val[7] = t[1]; matrix.val[11] = t[2]; +} + +template inline +typename cv::Affine3::Mat3 cv::Affine3::rotation() const +{ + return linear(); +} + +template inline +typename cv::Affine3::Mat3 cv::Affine3::linear() const +{ + typename cv::Affine3::Mat3 R; + R.val[0] = matrix.val[0]; R.val[1] = matrix.val[1]; R.val[2] = matrix.val[ 2]; + R.val[3] = matrix.val[4]; R.val[4] = matrix.val[5]; R.val[5] = matrix.val[ 6]; + R.val[6] = matrix.val[8]; R.val[7] = matrix.val[9]; R.val[8] = matrix.val[10]; + return R; +} + +template inline +typename cv::Affine3::Vec3 cv::Affine3::translation() const +{ + return Vec3(matrix.val[3], matrix.val[7], matrix.val[11]); +} + +template inline +typename cv::Affine3::Vec3 cv::Affine3::rvec() const +{ + cv::Vec3d w; + cv::Matx33d u, vt, R = rotation(); + cv::SVD::compute(R, w, u, vt, cv::SVD::FULL_UV + cv::SVD::MODIFY_A); + R = u * vt; + + double rx = R.val[7] - R.val[5]; + double ry = R.val[2] - R.val[6]; + double rz = R.val[3] - R.val[1]; + + double s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25); + double c = (R.val[0] + R.val[4] + R.val[8] - 1) * 0.5; + c = c > 1.0 ? 1.0 : c < -1.0 ? -1.0 : c; + double theta = std::acos(c); + + if( s < 1e-5 ) + { + if( c > 0 ) + rx = ry = rz = 0; + else + { + double t; + t = (R.val[0] + 1) * 0.5; + rx = std::sqrt(std::max(t, 0.0)); + t = (R.val[4] + 1) * 0.5; + ry = std::sqrt(std::max(t, 0.0)) * (R.val[1] < 0 ? -1.0 : 1.0); + t = (R.val[8] + 1) * 0.5; + rz = std::sqrt(std::max(t, 0.0)) * (R.val[2] < 0 ? -1.0 : 1.0); + + if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R.val[5] > 0) != (ry*rz > 0) ) + rz = -rz; + theta /= std::sqrt(rx*rx + ry*ry + rz*rz); + rx *= theta; + ry *= theta; + rz *= theta; + } + } + else + { + double vth = 1/(2*s); + vth *= theta; + rx *= vth; ry *= vth; rz *= vth; + } + + return cv::Vec3d(rx, ry, rz); +} + +template inline +cv::Affine3 cv::Affine3::inv(int method) const +{ + return matrix.inv(method); +} + +template inline +cv::Affine3 cv::Affine3::rotate(const Mat3& R) const +{ + Mat3 Lc = linear(); + Vec3 tc = translation(); + Mat4 result; + result.val[12] = result.val[13] = result.val[14] = 0; + result.val[15] = 1; + + for(int j = 0; j < 3; ++j) + { + for(int i = 0; i < 3; ++i) + { + float_type value = 0; + for(int k = 0; k < 3; ++k) + value += R(j, k) * Lc(k, i); + result(j, i) = value; + } + + result(j, 3) = R.row(j).dot(tc.t()); + } + return result; +} + +template inline +cv::Affine3 cv::Affine3::rotate(const Vec3& _rvec) const +{ + return rotate(Affine3f(_rvec).rotation()); +} + +template inline +cv::Affine3 cv::Affine3::translate(const Vec3& t) const +{ + Mat4 m = matrix; + m.val[ 3] += t[0]; + m.val[ 7] += t[1]; + m.val[11] += t[2]; + return m; +} + +template inline +cv::Affine3 cv::Affine3::concatenate(const Affine3& affine) const +{ + return (*this).rotate(affine.rotation()).translate(affine.translation()); +} + +template template inline +cv::Affine3::operator Affine3() const +{ + return Affine3(matrix); +} + +template template inline +cv::Affine3 cv::Affine3::cast() const +{ + return Affine3(matrix); +} + +template inline +cv::Affine3 cv::operator*(const cv::Affine3& affine1, const cv::Affine3& affine2) +{ + return affine2.concatenate(affine1); +} + +template inline +V cv::operator*(const cv::Affine3& affine, const V& v) +{ + const typename Affine3::Mat4& m = affine.matrix; + + V r; + r.x = m.val[0] * v.x + m.val[1] * v.y + m.val[ 2] * v.z + m.val[ 3]; + r.y = m.val[4] * v.x + m.val[5] * v.y + m.val[ 6] * v.z + m.val[ 7]; + r.z = m.val[8] * v.x + m.val[9] * v.y + m.val[10] * v.z + m.val[11]; + return r; +} + +static inline +cv::Vec3f cv::operator*(const cv::Affine3f& affine, const cv::Vec3f& v) +{ + const cv::Matx44f& m = affine.matrix; + cv::Vec3f r; + r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3]; + r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7]; + r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11]; + return r; +} + +static inline +cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v) +{ + const cv::Matx44d& m = affine.matrix; + cv::Vec3d r; + r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3]; + r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7]; + r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11]; + return r; +} + + + +#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H + +template inline +cv::Affine3::Affine3(const Eigen::Transform& affine) +{ + cv::Mat(4, 4, cv::traits::Type::value, affine.matrix().data()).copyTo(matrix); +} + +template inline +cv::Affine3::Affine3(const Eigen::Transform& affine) +{ + Eigen::Transform a = affine; + cv::Mat(4, 4, cv::traits::Type::value, a.matrix().data()).copyTo(matrix); +} + +template inline +cv::Affine3::operator Eigen::Transform() const +{ + Eigen::Transform r; + cv::Mat hdr(4, 4, cv::traits::Type::value, r.matrix().data()); + cv::Mat(matrix, false).copyTo(hdr); + return r; +} + +template inline +cv::Affine3::operator Eigen::Transform() const +{ + return this->operator Eigen::Transform(); +} + +#endif /* defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H */ + +//! @endcond + +#endif /* __cplusplus */ + +#endif /* OPENCV_CORE_AFFINE3_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/async.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/async.hpp new file mode 100644 index 0000000..54560c7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/async.hpp @@ -0,0 +1,105 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ASYNC_HPP +#define OPENCV_CORE_ASYNC_HPP + +#include + +#ifdef CV_CXX11 +//#include +#include +#endif + +namespace cv { + +/** @addtogroup core_async + +@{ +*/ + + +/** @brief Returns result of asynchronous operations + +Object has attached asynchronous state. +Assignment operator doesn't clone asynchronous state (it is shared between all instances). + +Result can be fetched via get() method only once. + +*/ +class CV_EXPORTS_W AsyncArray +{ +public: + ~AsyncArray() CV_NOEXCEPT; + CV_WRAP AsyncArray() CV_NOEXCEPT; + AsyncArray(const AsyncArray& o) CV_NOEXCEPT; + AsyncArray& operator=(const AsyncArray& o) CV_NOEXCEPT; + CV_WRAP void release() CV_NOEXCEPT; + + /** Fetch the result. + @param[out] dst destination array + + Waits for result until container has valid result. + Throws exception if exception was stored as a result. + + Throws exception on invalid container state. + + @note Result or stored exception can be fetched only once. + */ + CV_WRAP void get(OutputArray dst) const; + + /** Retrieving the result with timeout + @param[out] dst destination array + @param[in] timeoutNs timeout in nanoseconds, -1 for infinite wait + + @returns true if result is ready, false if the timeout has expired + + @note Result or stored exception can be fetched only once. + */ + bool get(OutputArray dst, int64 timeoutNs) const; + + CV_WRAP inline + bool get(OutputArray dst, double timeoutNs) const { return get(dst, (int64)timeoutNs); } + + bool wait_for(int64 timeoutNs) const; + + CV_WRAP inline + bool wait_for(double timeoutNs) const { return wait_for((int64)timeoutNs); } + + CV_WRAP bool valid() const CV_NOEXCEPT; + +#ifdef CV_CXX11 + inline AsyncArray(AsyncArray&& o) { p = o.p; o.p = NULL; } + inline AsyncArray& operator=(AsyncArray&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; } + + template + inline bool get(OutputArray dst, const std::chrono::duration<_Rep, _Period>& timeout) + { + return get(dst, (int64)(std::chrono::nanoseconds(timeout).count())); + } + + template + inline bool wait_for(const std::chrono::duration<_Rep, _Period>& timeout) + { + return wait_for((int64)(std::chrono::nanoseconds(timeout).count())); + } + +#if 0 + std::future getFutureMat() const; + std::future getFutureUMat() const; +#endif +#endif + + + // PImpl + struct Impl; friend struct Impl; + inline void* _getImpl() const CV_NOEXCEPT { return p; } +protected: + Impl* p; +}; + + +//! @} +} // namespace +#endif // OPENCV_CORE_ASYNC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/base.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/base.hpp new file mode 100644 index 0000000..21a61a4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/base.hpp @@ -0,0 +1,664 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2014, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_BASE_HPP +#define OPENCV_CORE_BASE_HPP + +#ifndef __cplusplus +# error base.hpp header must be compiled as C++ +#endif + +#include "opencv2/opencv_modules.hpp" + +#include +#include + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" + +namespace cv +{ + +//! @addtogroup core_utils +//! @{ + +namespace Error { +//! error codes +enum Code { + StsOk= 0, //!< everything is ok + StsBackTrace= -1, //!< pseudo error for back trace + StsError= -2, //!< unknown /unspecified error + StsInternal= -3, //!< internal error (bad state) + StsNoMem= -4, //!< insufficient memory + StsBadArg= -5, //!< function arg/param is bad + StsBadFunc= -6, //!< unsupported function + StsNoConv= -7, //!< iteration didn't converge + StsAutoTrace= -8, //!< tracing + HeaderIsNull= -9, //!< image header is NULL + BadImageSize= -10, //!< image size is invalid + BadOffset= -11, //!< offset is invalid + BadDataPtr= -12, //!< + BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix. + BadModelOrChSeq= -14, //!< + BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices. + BadNumChannel1U= -16, //!< + BadDepth= -17, //!< input image depth is not supported by the function + BadAlphaChannel= -18, //!< + BadOrder= -19, //!< number of dimensions is out of range + BadOrigin= -20, //!< incorrect input origin + BadAlign= -21, //!< incorrect input align + BadCallBack= -22, //!< + BadTileSize= -23, //!< + BadCOI= -24, //!< input COI is not supported + BadROISize= -25, //!< incorrect input roi + MaskIsTiled= -26, //!< + StsNullPtr= -27, //!< null pointer + StsVecLengthErr= -28, //!< incorrect vector length + StsFilterStructContentErr= -29, //!< incorrect filter structure content + StsKernelStructContentErr= -30, //!< incorrect transform kernel content + StsFilterOffsetErr= -31, //!< incorrect filter offset value + StsBadSize= -201, //!< the input/output structure size is incorrect + StsDivByZero= -202, //!< division by zero + StsInplaceNotSupported= -203, //!< in-place operation is not supported + StsObjectNotFound= -204, //!< request can't be completed + StsUnmatchedFormats= -205, //!< formats of input/output arrays differ + StsBadFlag= -206, //!< flag is wrong or not supported + StsBadPoint= -207, //!< bad CvPoint + StsBadMask= -208, //!< bad format of mask (neither 8uC1 nor 8sC1) + StsUnmatchedSizes= -209, //!< sizes of input/output structures do not match + StsUnsupportedFormat= -210, //!< the data format/type is not supported by the function + StsOutOfRange= -211, //!< some of parameters are out of range + StsParseError= -212, //!< invalid syntax/structure of the parsed file + StsNotImplemented= -213, //!< the requested function/feature is not implemented + StsBadMemBlock= -214, //!< an allocated block has been corrupted + StsAssert= -215, //!< assertion failed + GpuNotSupported= -216, //!< no CUDA support + GpuApiCallError= -217, //!< GPU API call error + OpenGlNotSupported= -218, //!< no OpenGL support + OpenGlApiCallError= -219, //!< OpenGL API call error + OpenCLApiCallError= -220, //!< OpenCL API call error + OpenCLDoubleNotSupported= -221, + OpenCLInitError= -222, //!< OpenCL initialization error + OpenCLNoAMDBlasFft= -223 +}; +} //Error + +//! @} core_utils + +//! @addtogroup core_array +//! @{ + +//! matrix decomposition types +enum DecompTypes { + /** Gaussian elimination with the optimal pivot element chosen. */ + DECOMP_LU = 0, + /** singular value decomposition (SVD) method; the system can be over-defined and/or the matrix + src1 can be singular */ + DECOMP_SVD = 1, + /** eigenvalue decomposition; the matrix src1 must be symmetrical */ + DECOMP_EIG = 2, + /** Cholesky \f$LL^T\f$ factorization; the matrix src1 must be symmetrical and positively + defined */ + DECOMP_CHOLESKY = 3, + /** QR factorization; the system can be over-defined and/or the matrix src1 can be singular */ + DECOMP_QR = 4, + /** while all the previous flags are mutually exclusive, this flag can be used together with + any of the previous; it means that the normal equations + \f$\texttt{src1}^T\cdot\texttt{src1}\cdot\texttt{dst}=\texttt{src1}^T\texttt{src2}\f$ are + solved instead of the original system + \f$\texttt{src1}\cdot\texttt{dst}=\texttt{src2}\f$ */ + DECOMP_NORMAL = 16 +}; + +/** norm types + +src1 and src2 denote input arrays. +*/ + +enum NormTypes { + /** + \f[ + norm = \forkthree + {\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) } + {\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) } + {\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_INF}\) } + \f] + */ + NORM_INF = 1, + /** + \f[ + norm = \forkthree + {\| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\)} + { \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) } + { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L1}\) } + \f]*/ + NORM_L1 = 2, + /** + \f[ + norm = \forkthree + { \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) } + { \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) } + { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) } + \f] + */ + NORM_L2 = 4, + /** + \f[ + norm = \forkthree + { \| \texttt{src1} \| _{L_2} ^{2} = \sum_I \texttt{src1}(I)^2} {if \(\texttt{normType} = \texttt{NORM_L2SQR}\)} + { \| \texttt{src1} - \texttt{src2} \| _{L_2} ^{2} = \sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2 }{if \(\texttt{normType} = \texttt{NORM_L2SQR}\) } + { \left(\frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}}\right)^2 }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2SQR}\) } + \f] + */ + NORM_L2SQR = 5, + /** + In the case of one input array, calculates the Hamming distance of the array from zero, + In the case of two input arrays, calculates the Hamming distance between the arrays. + */ + NORM_HAMMING = 6, + /** + Similar to NORM_HAMMING, but in the calculation, each two bits of the input sequence will + be added and treated as a single bit to be used in the same calculation as NORM_HAMMING. + */ + NORM_HAMMING2 = 7, + NORM_TYPE_MASK = 7, //!< bit-mask which can be used to separate norm type from norm flags + NORM_RELATIVE = 8, //!< flag + NORM_MINMAX = 32 //!< flag + }; + +//! comparison types +enum CmpTypes { CMP_EQ = 0, //!< src1 is equal to src2. + CMP_GT = 1, //!< src1 is greater than src2. + CMP_GE = 2, //!< src1 is greater than or equal to src2. + CMP_LT = 3, //!< src1 is less than src2. + CMP_LE = 4, //!< src1 is less than or equal to src2. + CMP_NE = 5 //!< src1 is unequal to src2. + }; + +//! generalized matrix multiplication flags +enum GemmFlags { GEMM_1_T = 1, //!< transposes src1 + GEMM_2_T = 2, //!< transposes src2 + GEMM_3_T = 4 //!< transposes src3 + }; + +enum DftFlags { + /** performs an inverse 1D or 2D transform instead of the default forward + transform. */ + DFT_INVERSE = 1, + /** scales the result: divide it by the number of array elements. Normally, it is + combined with DFT_INVERSE. */ + DFT_SCALE = 2, + /** performs a forward or inverse transform of every individual row of the input + matrix; this flag enables you to transform multiple vectors simultaneously and can be used to + decrease the overhead (which is sometimes several times larger than the processing itself) to + perform 3D and higher-dimensional transformations and so forth.*/ + DFT_ROWS = 4, + /** performs a forward transformation of 1D or 2D real array; the result, + though being a complex array, has complex-conjugate symmetry (*CCS*, see the function + description below for details), and such an array can be packed into a real array of the same + size as input, which is the fastest option and which is what the function does by default; + however, you may wish to get a full complex array (for simpler spectrum analysis, and so on) - + pass the flag to enable the function to produce a full-size complex output array. */ + DFT_COMPLEX_OUTPUT = 16, + /** performs an inverse transformation of a 1D or 2D complex array; the + result is normally a complex array of the same size, however, if the input array has + conjugate-complex symmetry (for example, it is a result of forward transformation with + DFT_COMPLEX_OUTPUT flag), the output is a real array; while the function itself does not + check whether the input is symmetrical or not, you can pass the flag and then the function + will assume the symmetry and produce the real output array (note that when the input is packed + into a real array and inverse transformation is executed, the function treats the input as a + packed complex-conjugate symmetrical array, and the output will also be a real array). */ + DFT_REAL_OUTPUT = 32, + /** specifies that input is complex input. If this flag is set, the input must have 2 channels. + On the other hand, for backwards compatibility reason, if input has 2 channels, input is + already considered complex. */ + DFT_COMPLEX_INPUT = 64, + /** performs an inverse 1D or 2D transform instead of the default forward transform. */ + DCT_INVERSE = DFT_INVERSE, + /** performs a forward or inverse transform of every individual row of the input + matrix. This flag enables you to transform multiple vectors simultaneously and can be used to + decrease the overhead (which is sometimes several times larger than the processing itself) to + perform 3D and higher-dimensional transforms and so forth.*/ + DCT_ROWS = DFT_ROWS +}; + +//! Various border types, image boundaries are denoted with `|` +//! @see borderInterpolate, copyMakeBorder +enum BorderTypes { + BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i` + BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh` + BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb` + BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg` + BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba` + BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno` + + BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_ISOLATED = 16 //!< do not look outside of ROI +}; + +//! @} core_array + +//! @addtogroup core_utils +//! @{ + +/*! @brief Signals an error and raises the exception. + +By default the function prints information about the error to stderr, +then it either stops if setBreakOnError() had been called before or raises the exception. +It is possible to alternate error processing by using redirectError(). +@param _code - error code (Error::Code) +@param _err - error description +@param _func - function name. Available only when the compiler supports getting it +@param _file - source file name where the error has occurred +@param _line - line number in the source file where the error has occurred +@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert + */ +CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _func, const char* _file, int _line); + +#ifdef CV_STATIC_ANALYSIS + +// In practice, some macro are not processed correctly (noreturn is not detected). +// We need to use simplified definition for them. +#define CV_Error(code, msg) do { (void)(code); (void)(msg); abort(); } while (0) +#define CV_Error_(code, args) do { (void)(code); (void)(cv::format args); abort(); } while (0) +#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0) + +#else // CV_STATIC_ANALYSIS + +/** @brief Call the error handler. + +Currently, the error handler prints the error code and the error message to the standard +error stream `stderr`. In the Debug configuration, it then provokes memory access violation, so that +the execution stack and all the parameters can be analyzed by the debugger. In the Release +configuration, the exception is thrown. + +@param code one of Error::Code +@param msg error message +*/ +#define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ ) + +/** @brief Call the error handler. + +This macro can be used to construct an error message on-fly to include some dynamic information, +for example: +@code + // note the extra parentheses around the formatted text message + CV_Error_(Error::StsOutOfRange, + ("the value at (%d, %d)=%g is out of range", badPt.x, badPt.y, badValue)); +@endcode +@param code one of Error::Code +@param args printf-like formatted error message in parentheses +*/ +#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ ) + +/** @brief Checks a condition at runtime and throws exception if it fails + +The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros +raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release +configurations while CV_DbgAssert is only retained in the Debug configuration. +*/ +#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0) + +#endif // CV_STATIC_ANALYSIS + +//! @cond IGNORED +#if !defined(__OPENCV_BUILD) // TODO: backward compatibility only +#ifndef CV_ErrorNoReturn +#define CV_ErrorNoReturn CV_Error +#endif +#ifndef CV_ErrorNoReturn_ +#define CV_ErrorNoReturn_ CV_Error_ +#endif +#endif + +#define CV_Assert_1 CV_Assert +#define CV_Assert_2( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_1( __VA_ARGS__ )) +#define CV_Assert_3( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_2( __VA_ARGS__ )) +#define CV_Assert_4( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_3( __VA_ARGS__ )) +#define CV_Assert_5( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_4( __VA_ARGS__ )) +#define CV_Assert_6( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_5( __VA_ARGS__ )) +#define CV_Assert_7( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_6( __VA_ARGS__ )) +#define CV_Assert_8( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_7( __VA_ARGS__ )) +#define CV_Assert_9( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_8( __VA_ARGS__ )) +#define CV_Assert_10( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_9( __VA_ARGS__ )) + +#define CV_Assert_N(...) do { __CV_EXPAND(__CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__)); } while(0) + +//! @endcond + +#if defined _DEBUG || defined CV_STATIC_ANALYSIS +# define CV_DbgAssert(expr) CV_Assert(expr) +#else +/** replaced with CV_Assert(expr) in Debug configuration */ +# define CV_DbgAssert(expr) +#endif + +/* + * Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor + * bit count of A exclusive XOR'ed with B + */ +struct CV_EXPORTS Hamming +{ + static const NormTypes normType = NORM_HAMMING; + typedef unsigned char ValueType; + typedef int ResultType; + + /** this will count the bits in a ^ b + */ + ResultType operator()( const unsigned char* a, const unsigned char* b, int size ) const; +}; + +typedef Hamming HammingLUT; + +/////////////////////////////////// inline norms //////////////////////////////////// + +template inline _Tp cv_abs(_Tp x) { return std::abs(x); } +inline int cv_abs(uchar x) { return x; } +inline int cv_abs(schar x) { return std::abs(x); } +inline int cv_abs(ushort x) { return x; } +inline int cv_abs(short x) { return std::abs(x); } + +template static inline +_AccTp normL2Sqr(const _Tp* a, int n) +{ + _AccTp s = 0; + int i=0; +#if CV_ENABLE_UNROLLED + for( ; i <= n - 4; i += 4 ) + { + _AccTp v0 = a[i], v1 = a[i+1], v2 = a[i+2], v3 = a[i+3]; + s += v0*v0 + v1*v1 + v2*v2 + v3*v3; + } +#endif + for( ; i < n; i++ ) + { + _AccTp v = a[i]; + s += v*v; + } + return s; +} + +template static inline +_AccTp normL1(const _Tp* a, int n) +{ + _AccTp s = 0; + int i = 0; +#if CV_ENABLE_UNROLLED + for(; i <= n - 4; i += 4 ) + { + s += (_AccTp)cv_abs(a[i]) + (_AccTp)cv_abs(a[i+1]) + + (_AccTp)cv_abs(a[i+2]) + (_AccTp)cv_abs(a[i+3]); + } +#endif + for( ; i < n; i++ ) + s += cv_abs(a[i]); + return s; +} + +template static inline +_AccTp normInf(const _Tp* a, int n) +{ + _AccTp s = 0; + for( int i = 0; i < n; i++ ) + s = std::max(s, (_AccTp)cv_abs(a[i])); + return s; +} + +template static inline +_AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) +{ + _AccTp s = 0; + int i= 0; +#if CV_ENABLE_UNROLLED + for(; i <= n - 4; i += 4 ) + { + _AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]); + s += v0*v0 + v1*v1 + v2*v2 + v3*v3; + } +#endif + for( ; i < n; i++ ) + { + _AccTp v = _AccTp(a[i] - b[i]); + s += v*v; + } + return s; +} + +static inline float normL2Sqr(const float* a, const float* b, int n) +{ + float s = 0.f; + for( int i = 0; i < n; i++ ) + { + float v = a[i] - b[i]; + s += v*v; + } + return s; +} + +template static inline +_AccTp normL1(const _Tp* a, const _Tp* b, int n) +{ + _AccTp s = 0; + int i= 0; +#if CV_ENABLE_UNROLLED + for(; i <= n - 4; i += 4 ) + { + _AccTp v0 = _AccTp(a[i] - b[i]), v1 = _AccTp(a[i+1] - b[i+1]), v2 = _AccTp(a[i+2] - b[i+2]), v3 = _AccTp(a[i+3] - b[i+3]); + s += std::abs(v0) + std::abs(v1) + std::abs(v2) + std::abs(v3); + } +#endif + for( ; i < n; i++ ) + { + _AccTp v = _AccTp(a[i] - b[i]); + s += std::abs(v); + } + return s; +} + +inline float normL1(const float* a, const float* b, int n) +{ + float s = 0.f; + for( int i = 0; i < n; i++ ) + { + s += std::abs(a[i] - b[i]); + } + return s; +} + +inline int normL1(const uchar* a, const uchar* b, int n) +{ + int s = 0; + for( int i = 0; i < n; i++ ) + { + s += std::abs(a[i] - b[i]); + } + return s; +} + +template static inline +_AccTp normInf(const _Tp* a, const _Tp* b, int n) +{ + _AccTp s = 0; + for( int i = 0; i < n; i++ ) + { + _AccTp v0 = a[i] - b[i]; + s = std::max(s, std::abs(v0)); + } + return s; +} + +/** @brief Computes the cube root of an argument. + + The function cubeRoot computes \f$\sqrt[3]{\texttt{val}}\f$. Negative arguments are handled correctly. + NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for + single-precision data. + @param val A function argument. + */ +CV_EXPORTS_W float cubeRoot(float val); + +/** @overload + +cubeRoot with argument of `double` type calls `std::cbrt(double)` +*/ +static inline +double cubeRoot(double val) +{ + return std::cbrt(val); +} + +/** @brief Calculates the angle of a 2D vector in degrees. + + The function fastAtan2 calculates the full-range angle of an input 2D vector. The angle is measured + in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees. + @param x x-coordinate of the vector. + @param y y-coordinate of the vector. + */ +CV_EXPORTS_W float fastAtan2(float y, float x); + +/** proxy for hal::LU */ +CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n); +/** proxy for hal::LU */ +CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n); +/** proxy for hal::Cholesky */ +CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n); +/** proxy for hal::Cholesky */ +CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n); + +////////////////// forward declarations for important OpenCV types ////////////////// + +//! @cond IGNORED + +template class Vec; +template class Matx; + +template class Complex; +template class Point_; +template class Point3_; +template class Size_; +template class Rect_; +template class Scalar_; + +class CV_EXPORTS RotatedRect; +class CV_EXPORTS Range; +class CV_EXPORTS TermCriteria; +class CV_EXPORTS KeyPoint; +class CV_EXPORTS DMatch; +class CV_EXPORTS RNG; + +class CV_EXPORTS Mat; +class CV_EXPORTS MatExpr; + +class CV_EXPORTS UMat; + +class CV_EXPORTS SparseMat; +typedef Mat MatND; + +template class Mat_; +template class SparseMat_; + +class CV_EXPORTS MatConstIterator; +class CV_EXPORTS SparseMatIterator; +class CV_EXPORTS SparseMatConstIterator; +template class MatIterator_; +template class MatConstIterator_; +template class SparseMatIterator_; +template class SparseMatConstIterator_; + +namespace ogl +{ + class CV_EXPORTS Buffer; + class CV_EXPORTS Texture2D; + class CV_EXPORTS Arrays; +} + +namespace cuda +{ + class CV_EXPORTS GpuMat; + class CV_EXPORTS HostMem; + class CV_EXPORTS Stream; + class CV_EXPORTS Event; +} + +namespace cudev +{ + template class GpuMat_; +} + +namespace ipp +{ +CV_EXPORTS unsigned long long getIppFeatures(); +CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL, + int line = 0); +CV_EXPORTS int getIppStatus(); +CV_EXPORTS String getIppErrorLocation(); +CV_EXPORTS_W bool useIPP(); +CV_EXPORTS_W void setUseIPP(bool flag); +CV_EXPORTS_W String getIppVersion(); + +// IPP Not-Exact mode. This function may force use of IPP then both IPP and OpenCV provide proper results +// but have internal accuracy differences which have too much direct or indirect impact on accuracy tests. +CV_EXPORTS_W bool useIPP_NotExact(); +CV_EXPORTS_W void setUseIPP_NotExact(bool flag); +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +static inline bool useIPP_NE() { return useIPP_NotExact(); } +static inline void setUseIPP_NE(bool flag) { setUseIPP_NotExact(flag); } +#endif + +} // ipp + +//! @endcond + +//! @} core_utils + + + + +} // cv + +#include "opencv2/core/neon_utils.hpp" +#include "opencv2/core/vsx_utils.hpp" +#include "opencv2/core/check.hpp" + +#endif //OPENCV_CORE_BASE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/bindings_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/bindings_utils.hpp new file mode 100644 index 0000000..22a86ff --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/bindings_utils.hpp @@ -0,0 +1,248 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_BINDINGS_UTILS_HPP +#define OPENCV_CORE_BINDINGS_UTILS_HPP + +#include +#include +#include + +#include + +namespace cv { namespace utils { +//! @addtogroup core_utils +//! @{ + +CV_EXPORTS_W String dumpInputArray(InputArray argument); + +CV_EXPORTS_W String dumpInputArrayOfArrays(InputArrayOfArrays argument); + +CV_EXPORTS_W String dumpInputOutputArray(InputOutputArray argument); + +CV_EXPORTS_W String dumpInputOutputArrayOfArrays(InputOutputArrayOfArrays argument); + +CV_WRAP static inline +String dumpBool(bool argument) +{ + return (argument) ? String("Bool: True") : String("Bool: False"); +} + +CV_WRAP static inline +String dumpInt(int argument) +{ + return cv::format("Int: %d", argument); +} + +CV_WRAP static inline +String dumpSizeT(size_t argument) +{ + std::ostringstream oss("size_t: ", std::ios::ate); + oss << argument; + return oss.str(); +} + +CV_WRAP static inline +String dumpFloat(float argument) +{ + return cv::format("Float: %.2f", argument); +} + +CV_WRAP static inline +String dumpDouble(double argument) +{ + return cv::format("Double: %.2f", argument); +} + +CV_WRAP static inline +String dumpCString(const char* argument) +{ + return cv::format("String: %s", argument); +} + +CV_WRAP static inline +String dumpString(const String& argument) +{ + return cv::format("String: %s", argument.c_str()); +} + +CV_WRAP static inline +String testOverloadResolution(int value, const Point& point = Point(42, 24)) +{ + return format("overload (int=%d, point=(x=%d, y=%d))", value, point.x, + point.y); +} + +CV_WRAP static inline +String testOverloadResolution(const Rect& rect) +{ + return format("overload (rect=(x=%d, y=%d, w=%d, h=%d))", rect.x, rect.y, + rect.width, rect.height); +} + +CV_WRAP static inline +String dumpRect(const Rect& argument) +{ + return format("rect: (x=%d, y=%d, w=%d, h=%d)", argument.x, argument.y, + argument.width, argument.height); +} + +CV_WRAP static inline +String dumpTermCriteria(const TermCriteria& argument) +{ + return format("term_criteria: (type=%d, max_count=%d, epsilon=%lf", + argument.type, argument.maxCount, argument.epsilon); +} + +CV_WRAP static inline +String dumpRotatedRect(const RotatedRect& argument) +{ + return format("rotated_rect: (c_x=%f, c_y=%f, w=%f, h=%f, a=%f)", + argument.center.x, argument.center.y, argument.size.width, + argument.size.height, argument.angle); +} + +CV_WRAP static inline +RotatedRect testRotatedRect(float x, float y, float w, float h, float angle) +{ + return RotatedRect(Point2f(x, y), Size2f(w, h), angle); +} + +CV_WRAP static inline +std::vector testRotatedRectVector(float x, float y, float w, float h, float angle) +{ + std::vector result; + for (int i = 0; i < 10; i++) + result.push_back(RotatedRect(Point2f(x + i, y + 2 * i), Size2f(w, h), angle + 10 * i)); + return result; +} + +CV_WRAP static inline +String dumpRange(const Range& argument) +{ + if (argument == Range::all()) + { + return "range: all"; + } + else + { + return format("range: (s=%d, e=%d)", argument.start, argument.end); + } +} + +CV_WRAP static inline +int testOverwriteNativeMethod(int argument) +{ + return argument; +} + +CV_WRAP static inline +String testReservedKeywordConversion(int positional_argument, int lambda = 2, int from = 3) +{ + return format("arg=%d, lambda=%d, from=%d", positional_argument, lambda, from); +} + +CV_EXPORTS_W String dumpVectorOfInt(const std::vector& vec); + +CV_EXPORTS_W String dumpVectorOfDouble(const std::vector& vec); + +CV_EXPORTS_W String dumpVectorOfRect(const std::vector& vec); + +CV_WRAP static inline +void generateVectorOfRect(size_t len, CV_OUT std::vector& vec) +{ + vec.resize(len); + if (len > 0) + { + RNG rng(12345); + Mat tmp(static_cast(len), 1, CV_32SC4); + rng.fill(tmp, RNG::UNIFORM, 10, 20); + tmp.copyTo(vec); + } +} + +CV_WRAP static inline +void generateVectorOfInt(size_t len, CV_OUT std::vector& vec) +{ + vec.resize(len); + if (len > 0) + { + RNG rng(554433); + Mat tmp(static_cast(len), 1, CV_32SC1); + rng.fill(tmp, RNG::UNIFORM, -10, 10); + tmp.copyTo(vec); + } +} + +CV_WRAP static inline +void generateVectorOfMat(size_t len, int rows, int cols, int dtype, CV_OUT std::vector& vec) +{ + vec.resize(len); + if (len > 0) + { + RNG rng(65431); + for (size_t i = 0; i < len; ++i) + { + vec[i].create(rows, cols, dtype); + rng.fill(vec[i], RNG::UNIFORM, 0, 10); + } + } +} + +CV_WRAP static inline +void testRaiseGeneralException() +{ + throw std::runtime_error("exception text"); +} + +CV_WRAP static inline +AsyncArray testAsyncArray(InputArray argument) +{ + AsyncPromise p; + p.setValue(argument); + return p.getArrayResult(); +} + +CV_WRAP static inline +AsyncArray testAsyncException() +{ + AsyncPromise p; + try + { + CV_Error(Error::StsOk, "Test: Generated async error"); + } + catch (const cv::Exception& e) + { + p.setException(e); + } + return p.getArrayResult(); +} + +namespace fs { + CV_EXPORTS_W cv::String getCacheDirectoryForDownloads(); +} // namespace fs + +//! @} // core_utils +} // namespace cv::utils + +//! @cond IGNORED + +CV_WRAP static inline +int setLogLevel(int level) +{ + // NB: Binding generators doesn't work with enums properly yet, so we define separate overload here + return cv::utils::logging::setLogLevel((cv::utils::logging::LogLevel)level); +} + +CV_WRAP static inline +int getLogLevel() +{ + return cv::utils::logging::getLogLevel(); +} + +//! @endcond IGNORED + +} // namespaces cv / utils + +#endif // OPENCV_CORE_BINDINGS_UTILS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/bufferpool.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/bufferpool.hpp new file mode 100644 index 0000000..4698e5d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/bufferpool.hpp @@ -0,0 +1,40 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. + +#ifndef OPENCV_CORE_BUFFER_POOL_HPP +#define OPENCV_CORE_BUFFER_POOL_HPP + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4265) +#endif + +namespace cv +{ + +//! @addtogroup core +//! @{ + +class BufferPoolController +{ +protected: + ~BufferPoolController() { } +public: + virtual size_t getReservedSize() const = 0; + virtual size_t getMaxReservedSize() const = 0; + virtual void setMaxReservedSize(size_t size) = 0; + virtual void freeAllReservedBuffers() = 0; +}; + +//! @} + +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif // OPENCV_CORE_BUFFER_POOL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/check.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/check.hpp new file mode 100644 index 0000000..d975223 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/check.hpp @@ -0,0 +1,160 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_CHECK_HPP +#define OPENCV_CORE_CHECK_HPP + +#include + +namespace cv { + +/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or "" */ +CV_EXPORTS const char* depthToString(int depth); + +/** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or "" */ +CV_EXPORTS const String typeToString(int type); + + +//! @cond IGNORED +namespace detail { + +/** Returns string of cv::Mat depth value: CV_8U -> "CV_8U" or NULL */ +CV_EXPORTS const char* depthToString_(int depth); + +/** Returns string of cv::Mat depth value: CV_8UC3 -> "CV_8UC3" or cv::String() */ +CV_EXPORTS const cv::String typeToString_(int type); + +enum TestOp { + TEST_CUSTOM = 0, + TEST_EQ = 1, + TEST_NE = 2, + TEST_LE = 3, + TEST_LT = 4, + TEST_GE = 5, + TEST_GT = 6, + CV__LAST_TEST_OP +}; + +struct CheckContext { + const char* func; + const char* file; + int line; + enum TestOp testOp; + const char* message; + const char* p1_str; + const char* p2_str; +}; + +#ifndef CV__CHECK_FILENAME +# define CV__CHECK_FILENAME __FILE__ +#endif + +#ifndef CV__CHECK_FUNCTION +# if defined _MSC_VER +# define CV__CHECK_FUNCTION __FUNCSIG__ +# elif defined __GNUC__ +# define CV__CHECK_FUNCTION __PRETTY_FUNCTION__ +# else +# define CV__CHECK_FUNCTION "" +# endif +#endif + +#define CV__CHECK_LOCATION_VARNAME(id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_check_, id), __LINE__) +#define CV__DEFINE_CHECK_CONTEXT(id, message, testOp, p1_str, p2_str) \ + static const cv::detail::CheckContext CV__CHECK_LOCATION_VARNAME(id) = \ + { CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, "" message, "" p1_str, "" p2_str } + +CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_ v1, const Size_ v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); + +CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const Size_ v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_auto(const std::string& v1, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v, const CheckContext& ctx); +CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckContext& ctx); + + +#define CV__TEST_EQ(v1, v2) ((v1) == (v2)) +#define CV__TEST_NE(v1, v2) ((v1) != (v2)) +#define CV__TEST_LE(v1, v2) ((v1) <= (v2)) +#define CV__TEST_LT(v1, v2) ((v1) < (v2)) +#define CV__TEST_GE(v1, v2) ((v1) >= (v2)) +#define CV__TEST_GT(v1, v2) ((v1) > (v2)) + +#define CV__CHECK(id, op, type, v1, v2, v1_str, v2_str, msg_str) do { \ + if(CV__TEST_##op((v1), (v2))) ; else { \ + CV__DEFINE_CHECK_CONTEXT(id, msg_str, cv::detail::TEST_ ## op, v1_str, v2_str); \ + cv::detail::check_failed_ ## type((v1), (v2), CV__CHECK_LOCATION_VARNAME(id)); \ + } \ +} while (0) + +#define CV__CHECK_CUSTOM_TEST(id, type, v, test_expr, v_str, test_expr_str, msg_str) do { \ + if(!!(test_expr)) ; else { \ + CV__DEFINE_CHECK_CONTEXT(id, msg_str, cv::detail::TEST_CUSTOM, v_str, test_expr_str); \ + cv::detail::check_failed_ ## type((v), CV__CHECK_LOCATION_VARNAME(id)); \ + } \ +} while (0) + +} // namespace +//! @endcond + + +/// Supported values of these types: int, float, double +#define CV_CheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg) +#define CV_CheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg) + +/// Check with additional "decoding" of type values in error message +#define CV_CheckTypeEQ(t1, t2, msg) CV__CHECK(_, EQ, MatType, t1, t2, #t1, #t2, msg) +/// Check with additional "decoding" of depth values in error message +#define CV_CheckDepthEQ(d1, d2, msg) CV__CHECK(_, EQ, MatDepth, d1, d2, #d1, #d2, msg) + +#define CV_CheckChannelsEQ(c1, c2, msg) CV__CHECK(_, EQ, MatChannels, c1, c2, #c1, #c2, msg) + +/// Example: type == CV_8UC1 || type == CV_8UC3 +#define CV_CheckType(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatType, t, (test_expr), #t, #test_expr, msg) + +/// Example: depth == CV_32F || depth == CV_64F +#define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg) + +/// Example: v == A || v == B +#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg) + +/// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1") +// TODO define pretty-printers + +#ifndef NDEBUG +#define CV_DbgCheck(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg) +#define CV_DbgCheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg) +#define CV_DbgCheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg) +#else +#define CV_DbgCheck(v, test_expr, msg) do { } while (0) +#define CV_DbgCheckEQ(v1, v2, msg) do { } while (0) +#define CV_DbgCheckNE(v1, v2, msg) do { } while (0) +#define CV_DbgCheckLE(v1, v2, msg) do { } while (0) +#define CV_DbgCheckLT(v1, v2, msg) do { } while (0) +#define CV_DbgCheckGE(v1, v2, msg) do { } while (0) +#define CV_DbgCheckGT(v1, v2, msg) do { } while (0) +#endif + +} // namespace + +#endif // OPENCV_CORE_CHECK_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/core.hpp new file mode 100644 index 0000000..4389183 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/core.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/core.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/core_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/core_c.h new file mode 100644 index 0000000..09ac1e7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/core_c.h @@ -0,0 +1,3125 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + + +#ifndef OPENCV_CORE_C_H +#define OPENCV_CORE_C_H + +#include "opencv2/core/types_c.h" + +#ifdef __cplusplus +# ifdef _MSC_VER +/* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename' + which is incompatible with C + + It is OK to disable it because we only extend few plain structures with + C++ constructors for simpler interoperability with C++ API of the library +*/ +# pragma warning(disable:4190) +# elif defined __clang__ && __clang_major__ >= 3 +# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup core_c + @{ +*/ + +/****************************************************************************************\ +* Array allocation, deallocation, initialization and access to elements * +\****************************************************************************************/ + +/** `malloc` wrapper. + If there is no enough memory, the function + (as well as other OpenCV functions that call cvAlloc) + raises an error. */ +CVAPI(void*) cvAlloc( size_t size ); + +/** `free` wrapper. + Here and further all the memory releasing functions + (that all call cvFree) take double pointer in order to + to clear pointer to the data after releasing it. + Passing pointer to NULL pointer is Ok: nothing happens in this case +*/ +CVAPI(void) cvFree_( void* ptr ); +#define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0) + +/** @brief Creates an image header but does not allocate the image data. + +@param size Image width and height +@param depth Image depth (see cvCreateImage ) +@param channels Number of channels (see cvCreateImage ) + */ +CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); + +/** @brief Initializes an image header that was previously allocated. + +The returned IplImage\* points to the initialized header. +@param image Image header to initialize +@param size Image width and height +@param depth Image depth (see cvCreateImage ) +@param channels Number of channels (see cvCreateImage ) +@param origin Top-left IPL_ORIGIN_TL or bottom-left IPL_ORIGIN_BL +@param align Alignment for image rows, typically 4 or 8 bytes + */ +CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth, + int channels, int origin CV_DEFAULT(0), + int align CV_DEFAULT(4)); + +/** @brief Creates an image header and allocates the image data. + +This function call is equivalent to the following code: +@code + header = cvCreateImageHeader(size, depth, channels); + cvCreateData(header); +@endcode +@param size Image width and height +@param depth Bit depth of image elements. See IplImage for valid depths. +@param channels Number of channels per pixel. See IplImage for details. This function only creates +images with interleaved channels. + */ +CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); + +/** @brief Deallocates an image header. + +This call is an analogue of : +@code + if(image ) + { + iplDeallocate(*image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI); + *image = 0; + } +@endcode +but it does not use IPL functions by default (see the CV_TURN_ON_IPL_COMPATIBILITY macro). +@param image Double pointer to the image header + */ +CVAPI(void) cvReleaseImageHeader( IplImage** image ); + +/** @brief Deallocates the image header and the image data. + +This call is a shortened form of : +@code + if(*image ) + { + cvReleaseData(*image); + cvReleaseImageHeader(image); + } +@endcode +@param image Double pointer to the image header +*/ +CVAPI(void) cvReleaseImage( IplImage** image ); + +/** Creates a copy of IPL image (widthStep may differ) */ +CVAPI(IplImage*) cvCloneImage( const IplImage* image ); + +/** @brief Sets the channel of interest in an IplImage. + +If the ROI is set to NULL and the coi is *not* 0, the ROI is allocated. Most OpenCV functions do +*not* support the COI setting, so to process an individual image/matrix channel one may copy (via +cvCopy or cvSplit) the channel to a separate image/matrix, process it and then copy the result +back (via cvCopy or cvMerge) if needed. +@param image A pointer to the image header +@param coi The channel of interest. 0 - all channels are selected, 1 - first channel is selected, +etc. Note that the channel indices become 1-based. + */ +CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); + +/** @brief Returns the index of the channel of interest. + +Returns the channel of interest of in an IplImage. Returned values correspond to the coi in +cvSetImageCOI. +@param image A pointer to the image header + */ +CVAPI(int) cvGetImageCOI( const IplImage* image ); + +/** @brief Sets an image Region Of Interest (ROI) for a given rectangle. + +If the original image ROI was NULL and the rect is not the whole image, the ROI structure is +allocated. + +Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For +example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the +ROI, not the original image. +@param image A pointer to the image header +@param rect The ROI rectangle + */ +CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); + +/** @brief Resets the image ROI to include the entire image and releases the ROI structure. + +This produces a similar result to the following, but in addition it releases the ROI structure. : +@code + cvSetImageROI(image, cvRect(0, 0, image->width, image->height )); + cvSetImageCOI(image, 0); +@endcode +@param image A pointer to the image header + */ +CVAPI(void) cvResetImageROI( IplImage* image ); + +/** @brief Returns the image ROI. + +If there is no ROI set, cvRect(0,0,image-\>width,image-\>height) is returned. +@param image A pointer to the image header + */ +CVAPI(CvRect) cvGetImageROI( const IplImage* image ); + +/** @brief Creates a matrix header but does not allocate the matrix data. + +The function allocates a new matrix header and returns a pointer to it. The matrix data can then be +allocated using cvCreateData or set explicitly to user-allocated data via cvSetData. +@param rows Number of rows in the matrix +@param cols Number of columns in the matrix +@param type Type of the matrix elements, see cvCreateMat + */ +CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); + +#define CV_AUTOSTEP 0x7fffffff + +/** @brief Initializes a pre-allocated matrix header. + +This function is often used to process raw data with OpenCV matrix functions. For example, the +following code computes the matrix product of two matrices, stored as ordinary arrays: +@code + double a[] = { 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12 }; + + double b[] = { 1, 5, 9, + 2, 6, 10, + 3, 7, 11, + 4, 8, 12 }; + + double c[9]; + CvMat Ma, Mb, Mc ; + + cvInitMatHeader(&Ma, 3, 4, CV_64FC1, a); + cvInitMatHeader(&Mb, 4, 3, CV_64FC1, b); + cvInitMatHeader(&Mc, 3, 3, CV_64FC1, c); + + cvMatMulAdd(&Ma, &Mb, 0, &Mc); + // the c array now contains the product of a (3x4) and b (4x3) +@endcode +@param mat A pointer to the matrix header to be initialized +@param rows Number of rows in the matrix +@param cols Number of columns in the matrix +@param type Type of the matrix elements, see cvCreateMat . +@param data Optional: data pointer assigned to the matrix header +@param step Optional: full row width in bytes of the assigned data. By default, the minimal +possible step is used which assumes there are no gaps between subsequent rows of the matrix. + */ +CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols, + int type, void* data CV_DEFAULT(NULL), + int step CV_DEFAULT(CV_AUTOSTEP) ); + +/** @brief Creates a matrix header and allocates the matrix data. + +The function call is equivalent to the following code: +@code + CvMat* mat = cvCreateMatHeader(rows, cols, type); + cvCreateData(mat); +@endcode +@param rows Number of rows in the matrix +@param cols Number of columns in the matrix +@param type The type of the matrix elements in the form +CV_\\C\ , where S=signed, U=unsigned, F=float. For +example, CV _ 8UC1 means the elements are 8-bit unsigned and the there is 1 channel, and CV _ +32SC2 means the elements are 32-bit signed and there are 2 channels. + */ +CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); + +/** @brief Deallocates a matrix. + +The function decrements the matrix data reference counter and deallocates matrix header. If the data +reference counter is 0, it also deallocates the data. : +@code + if(*mat ) + cvDecRefData(*mat); + cvFree((void**)mat); +@endcode +@param mat Double pointer to the matrix + */ +CVAPI(void) cvReleaseMat( CvMat** mat ); + +/** @brief Decrements an array data reference counter. + +The function decrements the data reference counter in a CvMat or CvMatND if the reference counter + +pointer is not NULL. If the counter reaches zero, the data is deallocated. In the current +implementation the reference counter is not NULL only if the data was allocated using the +cvCreateData function. The counter will be NULL in other cases such as: external data was assigned +to the header using cvSetData, header is part of a larger matrix or image, or the header was +converted from an image or n-dimensional matrix header. +@param arr Pointer to an array header + */ +CV_INLINE void cvDecRefData( CvArr* arr ) +{ + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + mat->data.ptr = NULL; + if( mat->refcount != NULL && --*mat->refcount == 0 ) + cvFree( &mat->refcount ); + mat->refcount = NULL; + } +} + +/** @brief Increments array data reference counter. + +The function increments CvMat or CvMatND data reference counter and returns the new counter value if +the reference counter pointer is not NULL, otherwise it returns zero. +@param arr Array header + */ +CV_INLINE int cvIncRefData( CvArr* arr ) +{ + int refcount = 0; + if( CV_IS_MAT( arr )) + { + CvMat* mat = (CvMat*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + else if( CV_IS_MATND( arr )) + { + CvMatND* mat = (CvMatND*)arr; + if( mat->refcount != NULL ) + refcount = ++*mat->refcount; + } + return refcount; +} + + +/** Creates an exact copy of the input matrix (except, may be, step value) */ +CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); + + +/** @brief Returns matrix header corresponding to the rectangular sub-array of input image or matrix. + +The function returns header, corresponding to a specified rectangle of the input array. In other + +words, it allows the user to treat a rectangular part of input array as a stand-alone array. ROI is +taken into account by the function so the sub-array of ROI is actually extracted. +@param arr Input array +@param submat Pointer to the resultant sub-array header +@param rect Zero-based coordinates of the rectangle of interest + */ +CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); +#define cvGetSubArr cvGetSubRect + +/** @brief Returns array row or row span. + +The function returns the header, corresponding to a specified row/row span of the input array. +cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr, submat, row, row+1). +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param start_row Zero-based index of the starting row (inclusive) of the span +@param end_row Zero-based index of the ending row (exclusive) of the span +@param delta_row Index step in the row span. That is, the function extracts every delta_row -th +row from start_row and up to (but not including) end_row . + */ +CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat, + int start_row, int end_row, + int delta_row CV_DEFAULT(1)); + +/** @overload +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param row Zero-based index of the selected row +*/ +CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) +{ + return cvGetRows( arr, submat, row, row + 1, 1 ); +} + + +/** @brief Returns one of more array columns. + +The function returns the header, corresponding to a specified column span of the input array. That + +is, no data is copied. Therefore, any modifications of the submatrix will affect the original array. +If you need to copy the columns, use cvCloneMat. cvGetCol(arr, submat, col) is a shortcut for +cvGetCols(arr, submat, col, col+1). +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param start_col Zero-based index of the starting column (inclusive) of the span +@param end_col Zero-based index of the ending column (exclusive) of the span + */ +CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat, + int start_col, int end_col ); + +/** @overload +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param col Zero-based index of the selected column +*/ +CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col ) +{ + return cvGetCols( arr, submat, col, col + 1 ); +} + +/** @brief Returns one of array diagonals. + +The function returns the header, corresponding to a specified diagonal of the input array. +@param arr Input array +@param submat Pointer to the resulting sub-array header +@param diag Index of the array diagonal. Zero value corresponds to the main diagonal, -1 +corresponds to the diagonal above the main, 1 corresponds to the diagonal below the main, and so +forth. + */ +CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat, + int diag CV_DEFAULT(0)); + +/** low-level scalar <-> raw data conversion functions */ +CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, + int extend_to_12 CV_DEFAULT(0) ); + +CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); + +/** @brief Creates a new matrix header but does not allocate the matrix data. + +The function allocates a header for a multi-dimensional dense array. The array data can further be +allocated using cvCreateData or set explicitly to user-allocated data via cvSetData. +@param dims Number of array dimensions +@param sizes Array of dimension sizes +@param type Type of array elements, see cvCreateMat + */ +CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); + +/** @brief Creates the header and allocates the data for a multi-dimensional dense array. + +This function call is equivalent to the following code: +@code + CvMatND* mat = cvCreateMatNDHeader(dims, sizes, type); + cvCreateData(mat); +@endcode +@param dims Number of array dimensions. This must not exceed CV_MAX_DIM (32 by default, but can be +changed at build time). +@param sizes Array of dimension sizes. +@param type Type of array elements, see cvCreateMat . + */ +CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); + +/** @brief Initializes a pre-allocated multi-dimensional array header. + +@param mat A pointer to the array header to be initialized +@param dims The number of array dimensions +@param sizes An array of dimension sizes +@param type Type of array elements, see cvCreateMat +@param data Optional data pointer assigned to the matrix header + */ +CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, + int type, void* data CV_DEFAULT(NULL) ); + +/** @brief Deallocates a multi-dimensional array. + +The function decrements the array data reference counter and releases the array header. If the +reference counter reaches 0, it also deallocates the data. : +@code + if(*mat ) + cvDecRefData(*mat); + cvFree((void**)mat); +@endcode +@param mat Double pointer to the array + */ +CV_INLINE void cvReleaseMatND( CvMatND** mat ) +{ + cvReleaseMat( (CvMat**)mat ); +} + +/** Creates a copy of CvMatND (except, may be, steps) */ +CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); + +/** @brief Creates sparse array. + +The function allocates a multi-dimensional sparse array. Initially the array contain no elements, +that is PtrND and other related functions will return 0 for every index. +@param dims Number of array dimensions. In contrast to the dense matrix, the number of dimensions is +practically unlimited (up to \f$2^{16}\f$ ). +@param sizes Array of dimension sizes +@param type Type of array elements. The same as for CvMat + */ +CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); + +/** @brief Deallocates sparse array. + +The function releases the sparse array and clears the array pointer upon exit. +@param mat Double pointer to the array + */ +CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); + +/** Creates a copy of CvSparseMat (except, may be, zero items) */ +CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); + +/** @brief Initializes sparse array elements iterator. + +The function initializes iterator of sparse array elements and returns pointer to the first element, +or NULL if the array is empty. +@param mat Input array +@param mat_iterator Initialized iterator + */ +CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, + CvSparseMatIterator* mat_iterator ); + +/** @brief Returns the next sparse matrix element + +The function moves iterator to the next sparse matrix element and returns pointer to it. In the +current version there is no any particular order of the elements, because they are stored in the +hash table. The sample below demonstrates how to iterate through the sparse matrix: +@code + // print all the non-zero sparse matrix elements and compute their sum + double sum = 0; + int i, dims = cvGetDims(sparsemat); + CvSparseMatIterator it; + CvSparseNode* node = cvInitSparseMatIterator(sparsemat, &it); + + for(; node != 0; node = cvGetNextSparseNode(&it)) + { + int* idx = CV_NODE_IDX(array, node); + float val = *(float*)CV_NODE_VAL(array, node); + printf("M"); + for(i = 0; i < dims; i++ ) + printf("[%d]", idx[i]); + printf("=%g\n", val); + + sum += val; + } + + printf("nTotal sum = %g\n", sum); +@endcode +@param mat_iterator Sparse array iterator + */ +CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator ) +{ + if( mat_iterator->node->next ) + return mat_iterator->node = mat_iterator->node->next; + else + { + int idx; + for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ ) + { + CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx]; + if( node ) + { + mat_iterator->curidx = idx; + return mat_iterator->node = node; + } + } + return NULL; + } +} + + +#define CV_MAX_ARR 10 + +/** matrix iterator: used for n-ary operations on dense arrays */ +typedef struct CvNArrayIterator +{ + int count; /**< number of arrays */ + int dims; /**< number of dimensions to iterate */ + CvSize size; /**< maximal common linear size: { width = size, height = 1 } */ + uchar* ptr[CV_MAX_ARR]; /**< pointers to the array slices */ + int stack[CV_MAX_DIM]; /**< for internal use */ + CvMatND* hdr[CV_MAX_ARR]; /**< pointers to the headers of the + matrices that are processed */ +} +CvNArrayIterator; + +#define CV_NO_DEPTH_CHECK 1 +#define CV_NO_CN_CHECK 2 +#define CV_NO_SIZE_CHECK 4 + +/** initializes iterator that traverses through several arrays simultaneously + (the function together with cvNextArraySlice is used for + N-ari element-wise operations) */ +CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs, + const CvArr* mask, CvMatND* stubs, + CvNArrayIterator* array_iterator, + int flags CV_DEFAULT(0) ); + +/** returns zero value if iteration is finished, non-zero (slice length) otherwise */ +CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); + + +/** @brief Returns type of array elements. + +The function returns type of the array elements. In the case of IplImage the type is converted to +CvMat-like representation. For example, if the image has been created as: +@code + IplImage* img = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3); +@endcode +The code cvGetElemType(img) will return CV_8UC3. +@param arr Input array + */ +CVAPI(int) cvGetElemType( const CvArr* arr ); + +/** @brief Return number of array dimensions + +The function returns the array dimensionality and the array of dimension sizes. In the case of +IplImage or CvMat it always returns 2 regardless of number of image/matrix rows. For example, the +following code calculates total number of array elements: +@code + int sizes[CV_MAX_DIM]; + int i, total = 1; + int dims = cvGetDims(arr, size); + for(i = 0; i < dims; i++ ) + total *= sizes[i]; +@endcode +@param arr Input array +@param sizes Optional output vector of the array dimension sizes. For 2d arrays the number of rows +(height) goes first, number of columns (width) next. + */ +CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) ); + + +/** @brief Returns array size along the specified dimension. + +@param arr Input array +@param index Zero-based dimension index (for matrices 0 means number of rows, 1 means number of +columns; for images 0 means height, 1 means width) + */ +CVAPI(int) cvGetDimSize( const CvArr* arr, int index ); + + +/** @brief Return pointer to a particular array element. + +The functions return a pointer to a specific array element. Number of array dimension should match +to the number of indices passed to the function except for cvPtr1D function that can be used for +sequential access to 1D, 2D or nD dense arrays. + +The functions can be used for sparse arrays as well - if the requested node does not exist they +create it and set it to zero. + +All these as well as other functions accessing array elements ( cvGetND , cvGetRealND , cvSet +, cvSetND , cvSetRealND ) raise an error in case if the element index is out of range. +@param arr Input array +@param idx0 The first zero-based component of the element index +@param type Optional output parameter: type of matrix elements + */ +CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL)); +/** @overload */ +CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) ); +/** @overload */ +CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, + int* type CV_DEFAULT(NULL)); +/** @overload +@param arr Input array +@param idx Array of the element indices +@param type Optional output parameter: type of matrix elements +@param create_node Optional input parameter for sparse matrices. Non-zero value of the parameter +means that the requested element is created if it does not exist already. +@param precalc_hashval Optional input parameter for sparse matrices. If the pointer is not NULL, +the function does not recalculate the node hash value, but takes it from the specified location. +It is useful for speeding up pair-wise operations (TODO: provide an example) +*/ +CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL), + int create_node CV_DEFAULT(1), + unsigned* precalc_hashval CV_DEFAULT(NULL)); + +/** @brief Return a specific array element. + +The functions return a specific array element. In the case of a sparse array the functions return 0 +if the requested node does not exist (no new node is created by the functions). +@param arr Input array +@param idx0 The first zero-based component of the element index + */ +CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 ); +/** @overload */ +CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 ); +/** @overload */ +CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +/** @overload +@param arr Input array +@param idx Array of the element indices +*/ +CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx ); + +/** @brief Return a specific element of single-channel 1D, 2D, 3D or nD array. + +Returns a specific element of a single-channel array. If the array has multiple channels, a runtime +error is raised. Note that Get?D functions can be used safely for both single-channel and +multiple-channel arrays though they are a bit slower. + +In the case of a sparse array the functions return 0 if the requested node does not exist (no new +node is created by the functions). +@param arr Input array. Must have a single channel. +@param idx0 The first zero-based component of the element index + */ +CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 ); +/** @overload */ +CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 ); +/** @overload */ +CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 ); +/** @overload +@param arr Input array. Must have a single channel. +@param idx Array of the element indices +*/ +CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx ); + +/** @brief Change the particular array element. + +The functions assign the new value to a particular array element. In the case of a sparse array the +functions create the node if it does not exist yet. +@param arr Input array +@param idx0 The first zero-based component of the element index +@param value The assigned value + */ +CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value ); +/** @overload */ +CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value ); +/** @overload */ +CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); +/** @overload +@param arr Input array +@param idx Array of the element indices +@param value The assigned value +*/ +CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value ); + +/** @brief Change a specific array element. + +The functions assign a new value to a specific element of a single-channel array. If the array has +multiple channels, a runtime error is raised. Note that the Set\*D function can be used safely for +both single-channel and multiple-channel arrays, though they are a bit slower. + +In the case of a sparse array the functions create the node if it does not yet exist. +@param arr Input array +@param idx0 The first zero-based component of the element index +@param value The assigned value + */ +CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value ); +/** @overload */ +CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value ); +/** @overload */ +CVAPI(void) cvSetReal3D( CvArr* arr, int idx0, + int idx1, int idx2, double value ); +/** @overload +@param arr Input array +@param idx Array of the element indices +@param value The assigned value +*/ +CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value ); + +/** clears element of ND dense array, + in case of sparse arrays it deletes the specified node */ +CVAPI(void) cvClearND( CvArr* arr, const int* idx ); + +/** @brief Returns matrix header for arbitrary array. + +The function returns a matrix header for the input array that can be a matrix - CvMat, an image - +IplImage, or a multi-dimensional dense array - CvMatND (the third option is allowed only if +allowND != 0) . In the case of matrix the function simply returns the input pointer. In the case of +IplImage\* or CvMatND it initializes the header structure with parameters of the current image ROI +and returns &header. Because COI is not supported by CvMat, it is returned separately. + +The function provides an easy way to handle both types of arrays - IplImage and CvMat using the same +code. Input array must have non-zero data pointer, otherwise the function will report an error. + +@note If the input array is IplImage with planar data layout and COI set, the function returns the +pointer to the selected plane and COI == 0. This feature allows user to process IplImage structures +with planar data layout, even though OpenCV does not support such images. +@param arr Input array +@param header Pointer to CvMat structure used as a temporary buffer +@param coi Optional output parameter for storing COI +@param allowND If non-zero, the function accepts multi-dimensional dense arrays (CvMatND\*) and +returns 2D matrix (if CvMatND has two dimensions) or 1D matrix (when CvMatND has 1 dimension or +more than 2 dimensions). The CvMatND array must be continuous. +@sa cvGetImage, cvarrToMat. + */ +CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header, + int* coi CV_DEFAULT(NULL), + int allowND CV_DEFAULT(0)); + +/** @brief Returns image header for arbitrary array. + +The function returns the image header for the input array that can be a matrix (CvMat) or image +(IplImage). In the case of an image the function simply returns the input pointer. In the case of +CvMat it initializes an image_header structure with the parameters of the input matrix. Note that +if we transform IplImage to CvMat using cvGetMat and then transform CvMat back to IplImage using +this function, we will get different headers if the ROI is set in the original image. +@param arr Input array +@param image_header Pointer to IplImage structure used as a temporary buffer + */ +CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header ); + + +/** @brief Changes the shape of a multi-dimensional array without copying the data. + +The function is an advanced version of cvReshape that can work with multi-dimensional arrays as +well (though it can work with ordinary images and matrices) and change the number of dimensions. + +Below are the two samples from the cvReshape description rewritten using cvReshapeMatND: +@code + IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3); + IplImage gray_img_hdr, *gray_img; + gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr), &gray_img_hdr, 1, 0, 0); + ... + int size[] = { 2, 2, 2 }; + CvMatND* mat = cvCreateMatND(3, size, CV_32F); + CvMat row_header, *row; + row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0); +@endcode +In C, the header file for this function includes a convenient macro cvReshapeND that does away with +the sizeof_header parameter. So, the lines containing the call to cvReshapeMatND in the examples +may be replaced as follow: +@code + gray_img = (IplImage*)cvReshapeND(color_img, &gray_img_hdr, 1, 0, 0); + ... + row = (CvMat*)cvReshapeND(mat, &row_header, 0, 1, 0); +@endcode +@param arr Input array +@param sizeof_header Size of output header to distinguish between IplImage, CvMat and CvMatND +output headers +@param header Output header to be filled +@param new_cn New number of channels. new_cn = 0 means that the number of channels remains +unchanged. +@param new_dims New number of dimensions. new_dims = 0 means that the number of dimensions +remains the same. +@param new_sizes Array of new dimension sizes. Only new_dims-1 values are used, because the +total number of elements must remain the same. Thus, if new_dims = 1, new_sizes array is not +used. + */ +CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr, + int sizeof_header, CvArr* header, + int new_cn, int new_dims, int* new_sizes ); + +#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \ + cvReshapeMatND( (arr), sizeof(*(header)), (header), \ + (new_cn), (new_dims), (new_sizes)) + +/** @brief Changes shape of matrix/image without copying data. + +The function initializes the CvMat header so that it points to the same data as the original array +but has a different shape - different number of channels, different number of rows, or both. + +The following example code creates one image buffer and two image headers, the first is for a +320x240x3 image and the second is for a 960x240x1 image: +@code + IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3); + CvMat gray_mat_hdr; + IplImage gray_img_hdr, *gray_img; + cvReshape(color_img, &gray_mat_hdr, 1); + gray_img = cvGetImage(&gray_mat_hdr, &gray_img_hdr); +@endcode +And the next example converts a 3x3 matrix to a single 1x9 vector: +@code + CvMat* mat = cvCreateMat(3, 3, CV_32F); + CvMat row_header, *row; + row = cvReshape(mat, &row_header, 0, 1); +@endcode +@param arr Input array +@param header Output header to be filled +@param new_cn New number of channels. 'new_cn = 0' means that the number of channels remains +unchanged. +@param new_rows New number of rows. 'new_rows = 0' means that the number of rows remains +unchanged unless it needs to be changed according to new_cn value. +*/ +CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header, + int new_cn, int new_rows CV_DEFAULT(0) ); + +/** Repeats source 2d array several times in both horizontal and + vertical direction to fill destination array */ +CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst ); + +/** @brief Allocates array data + +The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of +matrix types OpenCV allocation functions are used. In the case of IplImage they are used unless +CV_TURN_ON_IPL_COMPATIBILITY() has been called before. In the latter case IPL functions are used +to allocate the data. +@param arr Array header + */ +CVAPI(void) cvCreateData( CvArr* arr ); + +/** @brief Releases array data. + +The function releases the array data. In the case of CvMat or CvMatND it simply calls +cvDecRefData(), that is the function can not deallocate external data. See also the note to +cvCreateData . +@param arr Array header + */ +CVAPI(void) cvReleaseData( CvArr* arr ); + +/** @brief Assigns user data to the array header. + +The function assigns user data to the array header. Header should be initialized before using +cvCreateMatHeader, cvCreateImageHeader, cvCreateMatNDHeader, cvInitMatHeader, +cvInitImageHeader or cvInitMatNDHeader. +@param arr Array header +@param data User data +@param step Full row length in bytes + */ +CVAPI(void) cvSetData( CvArr* arr, void* data, int step ); + +/** @brief Retrieves low-level information about the array. + +The function fills output variables with low-level information about the array data. All output + +parameters are optional, so some of the pointers may be set to NULL. If the array is IplImage with +ROI set, the parameters of ROI are returned. + +The following example shows how to get access to array elements. It computes absolute values of the +array elements : +@code + float* data; + int step; + CvSize size; + + cvGetRawData(array, (uchar**)&data, &step, &size); + step /= sizeof(data[0]); + + for(int y = 0; y < size.height; y++, data += step ) + for(int x = 0; x < size.width; x++ ) + data[x] = (float)fabs(data[x]); +@endcode +@param arr Array header +@param data Output pointer to the whole image origin or ROI origin if ROI is set +@param step Output full row length in bytes +@param roi_size Output ROI size + */ +CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data, + int* step CV_DEFAULT(NULL), + CvSize* roi_size CV_DEFAULT(NULL)); + +/** @brief Returns size of matrix or image ROI. + +The function returns number of rows (CvSize::height) and number of columns (CvSize::width) of the +input matrix or image. In the case of image the size of ROI is returned. +@param arr array header + */ +CVAPI(CvSize) cvGetSize( const CvArr* arr ); + +/** @brief Copies one array to another. + +The function copies selected elements from an input array to an output array: + +\f[\texttt{dst} (I)= \texttt{src} (I) \quad \text{if} \quad \texttt{mask} (I) \ne 0.\f] + +If any of the passed arrays is of IplImage type, then its ROI and COI fields are used. Both arrays +must have the same type, the same number of dimensions, and the same size. The function can also +copy sparse arrays (mask is not supported in this case). +@param src The source array +@param dst The destination array +@param mask Operation mask, 8-bit single channel array; specifies elements of the destination array +to be changed + */ +CVAPI(void) cvCopy( const CvArr* src, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Sets every element of an array to a given value. + +The function copies the scalar value to every selected element of the destination array: +\f[\texttt{arr} (I)= \texttt{value} \quad \text{if} \quad \texttt{mask} (I) \ne 0\f] +If array arr is of IplImage type, then is ROI used, but COI must not be set. +@param arr The destination array +@param value Fill value +@param mask Operation mask, 8-bit single channel array; specifies elements of the destination +array to be changed + */ +CVAPI(void) cvSet( CvArr* arr, CvScalar value, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Clears the array. + +The function clears the array. In the case of dense arrays (CvMat, CvMatND or IplImage), +cvZero(array) is equivalent to cvSet(array,cvScalarAll(0),0). In the case of sparse arrays all the +elements are removed. +@param arr Array to be cleared + */ +CVAPI(void) cvSetZero( CvArr* arr ); +#define cvZero cvSetZero + + +/** Splits a multi-channel array into the set of single-channel arrays or + extracts particular [color] plane */ +CVAPI(void) cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1, + CvArr* dst2, CvArr* dst3 ); + +/** Merges a set of single-channel arrays into the single multi-channel array + or inserts one particular [color] plane to the array */ +CVAPI(void) cvMerge( const CvArr* src0, const CvArr* src1, + const CvArr* src2, const CvArr* src3, + CvArr* dst ); + +/** Copies several channels from input arrays to + certain channels of output arrays */ +CVAPI(void) cvMixChannels( const CvArr** src, int src_count, + CvArr** dst, int dst_count, + const int* from_to, int pair_count ); + +/** @brief Converts one array to another with optional linear transformation. + +The function has several different purposes, and thus has several different names. It copies one +array to another with optional scaling, which is performed first, and/or optional type conversion, +performed after: + +\f[\texttt{dst} (I) = \texttt{scale} \texttt{src} (I) + ( \texttt{shift} _0, \texttt{shift} _1,...)\f] + +All the channels of multi-channel arrays are processed independently. + +The type of conversion is done with rounding and saturation, that is if the result of scaling + +conversion can not be represented exactly by a value of the destination array element type, it is +set to the nearest representable value on the real axis. +@param src Source array +@param dst Destination array +@param scale Scale factor +@param shift Value added to the scaled source array elements + */ +CVAPI(void) cvConvertScale( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScale cvConvertScale +#define cvScale cvConvertScale +#define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 ) + + +/** Performs linear transformation on every source array element, + stores absolute value of the result: + dst(x,y,c) = abs(scale*src(x,y,c)+shift). + destination array must have 8u type. + In other cases one may use cvConvertScale + cvAbsDiffS */ +CVAPI(void) cvConvertScaleAbs( const CvArr* src, CvArr* dst, + double scale CV_DEFAULT(1), + double shift CV_DEFAULT(0) ); +#define cvCvtScaleAbs cvConvertScaleAbs + + +/** checks termination criteria validity and + sets eps to default_eps (if it is not set), + max_iter to default_max_iters (if it is not set) +*/ +CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria, + double default_eps, + int default_max_iters ); + +/****************************************************************************************\ +* Arithmetic, logic and comparison operations * +\****************************************************************************************/ + +/** dst(mask) = src1(mask) + src2(mask) */ +CVAPI(void) cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(mask) = src(mask) + value */ +CVAPI(void) cvAddS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(mask) = src1(mask) - src2(mask) */ +CVAPI(void) cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(mask) = src(mask) - value = src(mask) + (-value) */ +CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)) +{ + cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]), + dst, mask ); +} + +/** dst(mask) = value - src(mask) */ +CVAPI(void) cvSubRS( const CvArr* src, CvScalar value, CvArr* dst, + const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src1(idx) * src2(idx) * scale + (scaled element-wise multiplication of 2 arrays) */ +CVAPI(void) cvMul( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1) ); + +/** element-wise division/inversion with scaling: + dst(idx) = src1(idx) * scale / src2(idx) + or dst(idx) = scale / src2(idx) if src1 == 0 */ +CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2, + CvArr* dst, double scale CV_DEFAULT(1)); + +/** dst = src1 * scale + src2 */ +CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale, + const CvArr* src2, CvArr* dst ); +#define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C) + +/** dst = src1 * alpha + src2 * beta + gamma */ +CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha, + const CvArr* src2, double beta, + double gamma, CvArr* dst ); + +/** @brief Calculates the dot product of two arrays in Euclidean metrics. + +The function calculates and returns the Euclidean dot product of two arrays. + +\f[src1 \bullet src2 = \sum _I ( \texttt{src1} (I) \texttt{src2} (I))\f] + +In the case of multiple channel arrays, the results for all channels are accumulated. In particular, +cvDotProduct(a,a) where a is a complex vector, will return \f$||\texttt{a}||^2\f$. The function can +process multi-dimensional arrays, row by row, layer by layer, and so on. +@param src1 The first source array +@param src2 The second source array + */ +CVAPI(double) cvDotProduct( const CvArr* src1, const CvArr* src2 ); + +/** dst(idx) = src1(idx) & src2(idx) */ +CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src(idx) & value */ +CVAPI(void) cvAndS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src1(idx) | src2(idx) */ +CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src(idx) | value */ +CVAPI(void) cvOrS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src1(idx) ^ src2(idx) */ +CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = src(idx) ^ value */ +CVAPI(void) cvXorS( const CvArr* src, CvScalar value, + CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); + +/** dst(idx) = ~src(idx) */ +CVAPI(void) cvNot( const CvArr* src, CvArr* dst ); + +/** dst(idx) = lower(idx) <= src(idx) < upper(idx) */ +CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower, + const CvArr* upper, CvArr* dst ); + +/** dst(idx) = lower <= src(idx) < upper */ +CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower, + CvScalar upper, CvArr* dst ); + +#define CV_CMP_EQ 0 +#define CV_CMP_GT 1 +#define CV_CMP_GE 2 +#define CV_CMP_LT 3 +#define CV_CMP_LE 4 +#define CV_CMP_NE 5 + +/** The comparison operation support single-channel arrays only. + Destination image should be 8uC1 or 8sC1 */ + +/** dst(idx) = src1(idx) _cmp_op_ src2(idx) */ +CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op ); + +/** dst(idx) = src1(idx) _cmp_op_ value */ +CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op ); + +/** dst(idx) = min(src1(idx),src2(idx)) */ +CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** dst(idx) = max(src1(idx),src2(idx)) */ +CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** dst(idx) = min(src(idx),value) */ +CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst ); + +/** dst(idx) = max(src(idx),value) */ +CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst ); + +/** dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */ +CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** dst(x,y,c) = abs(src(x,y,c) - value(c)) */ +CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); +#define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0)) + +/****************************************************************************************\ +* Math operations * +\****************************************************************************************/ + +/** Does cartesian->polar coordinates conversion. + Either of output components (magnitude or angle) is optional */ +CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y, + CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL), + int angle_in_degrees CV_DEFAULT(0)); + +/** Does polar->cartesian coordinates conversion. + Either of output components (magnitude or angle) is optional. + If magnitude is missing it is assumed to be all 1's */ +CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle, + CvArr* x, CvArr* y, + int angle_in_degrees CV_DEFAULT(0)); + +/** Does powering: dst(idx) = src(idx)^power */ +CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power ); + +/** Does exponention: dst(idx) = exp(src(idx)). + Overflow is not handled yet. Underflow is handled. + Maximal relative error is ~7e-6 for single-precision input */ +CVAPI(void) cvExp( const CvArr* src, CvArr* dst ); + +/** Calculates natural logarithms: dst(idx) = log(abs(src(idx))). + Logarithm of 0 gives large negative number(~-700) + Maximal relative error is ~3e-7 for single-precision output +*/ +CVAPI(void) cvLog( const CvArr* src, CvArr* dst ); + +/** Fast arctangent calculation */ +CVAPI(float) cvFastArctan( float y, float x ); + +/** Fast cubic root calculation */ +CVAPI(float) cvCbrt( float value ); + +#define CV_CHECK_RANGE 1 +#define CV_CHECK_QUIET 2 +/** Checks array values for NaNs, Infs or simply for too large numbers + (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set, + no runtime errors is raised (function returns zero value in case of "bad" values). + Otherwise cvError is called */ +CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), + double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0)); +#define cvCheckArray cvCheckArr + +#define CV_RAND_UNI 0 +#define CV_RAND_NORMAL 1 + +/** @brief Fills an array with random numbers and updates the RNG state. + +The function fills the destination array with uniformly or normally distributed random numbers. +@param rng CvRNG state initialized by cvRNG +@param arr The destination array +@param dist_type Distribution type +> - **CV_RAND_UNI** uniform distribution +> - **CV_RAND_NORMAL** normal or Gaussian distribution +@param param1 The first parameter of the distribution. In the case of a uniform distribution it is +the inclusive lower boundary of the random numbers range. In the case of a normal distribution it +is the mean value of the random numbers. +@param param2 The second parameter of the distribution. In the case of a uniform distribution it +is the exclusive upper boundary of the random numbers range. In the case of a normal distribution +it is the standard deviation of the random numbers. +@sa randu, randn, RNG::fill. + */ +CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, + CvScalar param1, CvScalar param2 ); + +CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, + double iter_factor CV_DEFAULT(1.)); + +#define CV_SORT_EVERY_ROW 0 +#define CV_SORT_EVERY_COLUMN 1 +#define CV_SORT_ASCENDING 0 +#define CV_SORT_DESCENDING 16 + +CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), + CvArr* idxmat CV_DEFAULT(NULL), + int flags CV_DEFAULT(0)); + +/** Finds real roots of a cubic equation */ +CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots ); + +/** Finds all real and complex roots of a polynomial equation */ +CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2, + int maxiter CV_DEFAULT(20), int fig CV_DEFAULT(100)); + +/****************************************************************************************\ +* Matrix operations * +\****************************************************************************************/ + +/** @brief Calculates the cross product of two 3D vectors. + +The function calculates the cross product of two 3D vectors: +\f[\texttt{dst} = \texttt{src1} \times \texttt{src2}\f] +or: +\f[\begin{array}{l} \texttt{dst} _1 = \texttt{src1} _2 \texttt{src2} _3 - \texttt{src1} _3 \texttt{src2} _2 \\ \texttt{dst} _2 = \texttt{src1} _3 \texttt{src2} _1 - \texttt{src1} _1 \texttt{src2} _3 \\ \texttt{dst} _3 = \texttt{src1} _1 \texttt{src2} _2 - \texttt{src1} _2 \texttt{src2} _1 \end{array}\f] +@param src1 The first source vector +@param src2 The second source vector +@param dst The destination vector + */ +CVAPI(void) cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst ); + +/** Matrix transform: dst = A*B + C, C is optional */ +#define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 ) +#define cvMatMul( src1, src2, dst ) cvMatMulAdd( (src1), (src2), NULL, (dst)) + +#define CV_GEMM_A_T 1 +#define CV_GEMM_B_T 2 +#define CV_GEMM_C_T 4 +/** Extended matrix transform: + dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */ +CVAPI(void) cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, + const CvArr* src3, double beta, CvArr* dst, + int tABC CV_DEFAULT(0)); +#define cvMatMulAddEx cvGEMM + +/** Transforms each element of source array and stores + resultant vectors in destination array */ +CVAPI(void) cvTransform( const CvArr* src, CvArr* dst, + const CvMat* transmat, + const CvMat* shiftvec CV_DEFAULT(NULL)); +#define cvMatMulAddS cvTransform + +/** Does perspective transform on every element of input array */ +CVAPI(void) cvPerspectiveTransform( const CvArr* src, CvArr* dst, + const CvMat* mat ); + +/** Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */ +CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order, + const CvArr* delta CV_DEFAULT(NULL), + double scale CV_DEFAULT(1.) ); + +/** Transposes matrix. Square matrices can be transposed in-place */ +CVAPI(void) cvTranspose( const CvArr* src, CvArr* dst ); +#define cvT cvTranspose + +/** Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part */ +CVAPI(void) cvCompleteSymm( CvMat* matrix, int LtoR CV_DEFAULT(0) ); + +/** Mirror array data around horizontal (flip=0), + vertical (flip=1) or both(flip=-1) axises: + cvFlip(src) flips images vertically and sequences horizontally (inplace) */ +CVAPI(void) cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), + int flip_mode CV_DEFAULT(0)); +#define cvMirror cvFlip + + +#define CV_SVD_MODIFY_A 1 +#define CV_SVD_U_T 2 +#define CV_SVD_V_T 4 + +/** Performs Singular Value Decomposition of a matrix */ +CVAPI(void) cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL), + CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0)); + +/** Performs Singular Value Back Substitution (solves A*X = B): + flags must be the same as in cvSVD */ +CVAPI(void) cvSVBkSb( const CvArr* W, const CvArr* U, + const CvArr* V, const CvArr* B, + CvArr* X, int flags ); + +#define CV_LU 0 +#define CV_SVD 1 +#define CV_SVD_SYM 2 +#define CV_CHOLESKY 3 +#define CV_QR 4 +#define CV_NORMAL 16 + +/** Inverts matrix */ +CVAPI(double) cvInvert( const CvArr* src, CvArr* dst, + int method CV_DEFAULT(CV_LU)); +#define cvInv cvInvert + +/** Solves linear system (src1)*(dst) = (src2) + (returns 0 if src1 is a singular and CV_LU method is used) */ +CVAPI(int) cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst, + int method CV_DEFAULT(CV_LU)); + +/** Calculates determinant of input matrix */ +CVAPI(double) cvDet( const CvArr* mat ); + +/** Calculates trace of the matrix (sum of elements on the main diagonal) */ +CVAPI(CvScalar) cvTrace( const CvArr* mat ); + +/** Finds eigen values and vectors of a symmetric matrix */ +CVAPI(void) cvEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, + double eps CV_DEFAULT(0), + int lowindex CV_DEFAULT(-1), + int highindex CV_DEFAULT(-1)); + +///* Finds selected eigen values and vectors of a symmetric matrix */ +//CVAPI(void) cvSelectedEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, +// int lowindex, int highindex ); + +/** Makes an identity matrix (mat_ij = i == j) */ +CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) ); + +/** Fills matrix with given range of numbers */ +CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end ); + +/** @anchor core_c_CovarFlags +@name Flags for cvCalcCovarMatrix +@see cvCalcCovarMatrix + @{ +*/ + +/** flag for cvCalcCovarMatrix, transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */ +#define CV_COVAR_SCRAMBLED 0 + +/** flag for cvCalcCovarMatrix, [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */ +#define CV_COVAR_NORMAL 1 + +/** flag for cvCalcCovarMatrix, do not calc average (i.e. mean vector) - use the input vector instead + (useful for calculating covariance matrix by parts) */ +#define CV_COVAR_USE_AVG 2 + +/** flag for cvCalcCovarMatrix, scale the covariance matrix coefficients by number of the vectors */ +#define CV_COVAR_SCALE 4 + +/** flag for cvCalcCovarMatrix, all the input vectors are stored in a single matrix, as its rows */ +#define CV_COVAR_ROWS 8 + +/** flag for cvCalcCovarMatrix, all the input vectors are stored in a single matrix, as its columns */ +#define CV_COVAR_COLS 16 + +/** @} */ + +/** Calculates covariation matrix for a set of vectors +@see @ref core_c_CovarFlags "flags" +*/ +CVAPI(void) cvCalcCovarMatrix( const CvArr** vects, int count, + CvArr* cov_mat, CvArr* avg, int flags ); + +#define CV_PCA_DATA_AS_ROW 0 +#define CV_PCA_DATA_AS_COL 1 +#define CV_PCA_USE_AVG 2 +CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean, + CvArr* eigenvals, CvArr* eigenvects, int flags ); + +CVAPI(void) cvProjectPCA( const CvArr* data, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +CVAPI(void) cvBackProjectPCA( const CvArr* proj, const CvArr* mean, + const CvArr* eigenvects, CvArr* result ); + +/** Calculates Mahalanobis(weighted) distance */ +CVAPI(double) cvMahalanobis( const CvArr* vec1, const CvArr* vec2, const CvArr* mat ); +#define cvMahalonobis cvMahalanobis + +/****************************************************************************************\ +* Array Statistics * +\****************************************************************************************/ + +/** Finds sum of array elements */ +CVAPI(CvScalar) cvSum( const CvArr* arr ); + +/** Calculates number of non-zero pixels */ +CVAPI(int) cvCountNonZero( const CvArr* arr ); + +/** Calculates mean value of array elements */ +CVAPI(CvScalar) cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) ); + +/** Calculates mean and standard deviation of pixel values */ +CVAPI(void) cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** Finds global minimum, maximum and their positions */ +CVAPI(void) cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val, + CvPoint* min_loc CV_DEFAULT(NULL), + CvPoint* max_loc CV_DEFAULT(NULL), + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @anchor core_c_NormFlags + @name Flags for cvNorm and cvNormalize + @{ +*/ +#define CV_C 1 +#define CV_L1 2 +#define CV_L2 4 +#define CV_NORM_MASK 7 +#define CV_RELATIVE 8 +#define CV_DIFF 16 +#define CV_MINMAX 32 + +#define CV_DIFF_C (CV_DIFF | CV_C) +#define CV_DIFF_L1 (CV_DIFF | CV_L1) +#define CV_DIFF_L2 (CV_DIFF | CV_L2) +#define CV_RELATIVE_C (CV_RELATIVE | CV_C) +#define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1) +#define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2) +/** @} */ + +/** Finds norm, difference norm or relative difference norm for an array (or two arrays) +@see ref core_c_NormFlags "flags" +*/ +CVAPI(double) cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @see ref core_c_NormFlags "flags" */ +CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst, + double a CV_DEFAULT(1.), double b CV_DEFAULT(0.), + int norm_type CV_DEFAULT(CV_L2), + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @anchor core_c_ReduceFlags + @name Flags for cvReduce + @{ +*/ +#define CV_REDUCE_SUM 0 +#define CV_REDUCE_AVG 1 +#define CV_REDUCE_MAX 2 +#define CV_REDUCE_MIN 3 +/** @} */ + +/** @see @ref core_c_ReduceFlags "flags" */ +CVAPI(void) cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1), + int op CV_DEFAULT(CV_REDUCE_SUM) ); + +/****************************************************************************************\ +* Discrete Linear Transforms and Related Functions * +\****************************************************************************************/ + +/** @anchor core_c_DftFlags + @name Flags for cvDFT, cvDCT and cvMulSpectrums + @{ + */ +#define CV_DXT_FORWARD 0 +#define CV_DXT_INVERSE 1 +#define CV_DXT_SCALE 2 /**< divide result by size of array */ +#define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE) +#define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE +#define CV_DXT_ROWS 4 /**< transform each row individually */ +#define CV_DXT_MUL_CONJ 8 /**< conjugate the second argument of cvMulSpectrums */ +/** @} */ + +/** Discrete Fourier Transform: + complex->complex, + real->ccs (forward), + ccs->real (inverse) +@see core_c_DftFlags "flags" +*/ +CVAPI(void) cvDFT( const CvArr* src, CvArr* dst, int flags, + int nonzero_rows CV_DEFAULT(0) ); +#define cvFFT cvDFT + +/** Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) +@see core_c_DftFlags "flags" +*/ +CVAPI(void) cvMulSpectrums( const CvArr* src1, const CvArr* src2, + CvArr* dst, int flags ); + +/** Finds optimal DFT vector size >= size0 */ +CVAPI(int) cvGetOptimalDFTSize( int size0 ); + +/** Discrete Cosine Transform +@see core_c_DftFlags "flags" +*/ +CVAPI(void) cvDCT( const CvArr* src, CvArr* dst, int flags ); + +/****************************************************************************************\ +* Dynamic data structures * +\****************************************************************************************/ + +/** Calculates length of sequence slice (with support of negative indices). */ +CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq ); + + +/** Creates new memory storage. + block_size == 0 means that default, + somewhat optimal size, is used (currently, it is 64K) */ +CVAPI(CvMemStorage*) cvCreateMemStorage( int block_size CV_DEFAULT(0)); + + +/** Creates a memory storage that will borrow memory blocks from parent storage */ +CVAPI(CvMemStorage*) cvCreateChildMemStorage( CvMemStorage* parent ); + + +/** Releases memory storage. All the children of a parent must be released before + the parent. A child storage returns all the blocks to parent when it is released */ +CVAPI(void) cvReleaseMemStorage( CvMemStorage** storage ); + + +/** Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) + to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... + do not free any memory. + A child storage returns all the blocks to the parent when it is cleared */ +CVAPI(void) cvClearMemStorage( CvMemStorage* storage ); + +/** Remember a storage "free memory" position */ +CVAPI(void) cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos ); + +/** Restore a storage "free memory" position */ +CVAPI(void) cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos ); + +/** Allocates continuous buffer of the specified size in the storage */ +CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); + +/** Allocates string in memory storage */ +//CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, +// int len CV_DEFAULT(-1) ); + +/** Creates new empty sequence that will reside in the specified storage */ +CVAPI(CvSeq*) cvCreateSeq( int seq_flags, size_t header_size, + size_t elem_size, CvMemStorage* storage ); + +/** Changes default size (granularity) of sequence blocks. + The default size is ~1Kbyte */ +CVAPI(void) cvSetSeqBlockSize( CvSeq* seq, int delta_elems ); + + +/** Adds new element to the end of sequence. Returns pointer to the element */ +CVAPI(schar*) cvSeqPush( CvSeq* seq, const void* element CV_DEFAULT(NULL)); + + +/** Adds new element to the beginning of sequence. Returns pointer to it */ +CVAPI(schar*) cvSeqPushFront( CvSeq* seq, const void* element CV_DEFAULT(NULL)); + + +/** Removes the last element from sequence and optionally saves it */ +CVAPI(void) cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +/** Removes the first element from sequence and optioanally saves it */ +CVAPI(void) cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); + + +#define CV_FRONT 1 +#define CV_BACK 0 +/** Adds several new elements to the end of sequence */ +CVAPI(void) cvSeqPushMulti( CvSeq* seq, const void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/** Removes several elements from the end of sequence and optionally saves them */ +CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements, + int count, int in_front CV_DEFAULT(0) ); + +/** Inserts a new element in the middle of sequence. + cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */ +CVAPI(schar*) cvSeqInsert( CvSeq* seq, int before_index, + const void* element CV_DEFAULT(NULL)); + +/** Removes specified sequence element */ +CVAPI(void) cvSeqRemove( CvSeq* seq, int index ); + + +/** Removes all the elements from the sequence. The freed memory + can be reused later only by the same sequence unless cvClearMemStorage + or cvRestoreMemStoragePos is called */ +CVAPI(void) cvClearSeq( CvSeq* seq ); + + +/** Retrieves pointer to specified sequence element. + Negative indices are supported and mean counting from the end + (e.g -1 means the last sequence element) */ +CVAPI(schar*) cvGetSeqElem( const CvSeq* seq, int index ); + +/** Calculates index of the specified sequence element. + Returns -1 if element does not belong to the sequence */ +CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element, + CvSeqBlock** block CV_DEFAULT(NULL) ); + +/** Initializes sequence writer. The new elements will be added to the end of sequence */ +CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer ); + + +/** Combination of cvCreateSeq and cvStartAppendToSeq */ +CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size, + int elem_size, CvMemStorage* storage, + CvSeqWriter* writer ); + +/** Closes sequence writer, updates sequence header and returns pointer + to the resultant sequence + (which may be useful if the sequence was created using cvStartWriteSeq)) +*/ +CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer ); + + +/** Updates sequence header. May be useful to get access to some of previously + written elements via cvGetSeqElem or sequence reader */ +CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer ); + + +/** Initializes sequence reader. + The sequence can be read in forward or backward direction */ +CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, + int reverse CV_DEFAULT(0) ); + + +/** Returns current sequence reader position (currently observed sequence element) */ +CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader ); + + +/** Changes sequence reader position. It may seek to an absolute or + to relative to the current position */ +CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index, + int is_relative CV_DEFAULT(0)); + +/** Copies sequence content to a continuous piece of memory */ +CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements, + CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) ); + +/** Creates sequence header for array. + After that all the operations on sequences that do not alter the content + can be applied to the resultant sequence */ +CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size, + int elem_size, void* elements, int total, + CvSeq* seq, CvSeqBlock* block ); + +/** Extracts sequence slice (with or without copying sequence elements) */ +CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice, + CvMemStorage* storage CV_DEFAULT(NULL), + int copy_data CV_DEFAULT(0)); + +CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL)) +{ + return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 ); +} + +/** Removes sequence slice */ +CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ); + +/** Inserts a sequence or array into another sequence */ +CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); + +/** a < b ? -1 : a > b ? 1 : 0 */ +typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata ); + +/** Sorts sequence in-place given element comparison function */ +CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) ); + +/** Finds element in a [sorted] sequence */ +CVAPI(schar*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func, + int is_sorted, int* elem_idx, + void* userdata CV_DEFAULT(NULL) ); + +/** Reverses order of sequence elements in-place */ +CVAPI(void) cvSeqInvert( CvSeq* seq ); + +/** Splits sequence into one or more equivalence classes using the specified criteria */ +CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, + CvSeq** labels, CvCmpFunc is_equal, void* userdata ); + +/************ Internal sequence functions ************/ +CVAPI(void) cvChangeSeqBlock( void* reader, int direction ); +CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer ); + + +/** Creates a new set */ +CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size, + int elem_size, CvMemStorage* storage ); + +/** Adds new element to the set and returns pointer to it */ +CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL), + CvSetElem** inserted_elem CV_DEFAULT(NULL) ); + +/** Fast variant of cvSetAdd */ +CV_INLINE CvSetElem* cvSetNew( CvSet* set_header ) +{ + CvSetElem* elem = set_header->free_elems; + if( elem ) + { + set_header->free_elems = elem->next_free; + elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK; + set_header->active_count++; + } + else + cvSetAdd( set_header, NULL, &elem ); + return elem; +} + +/** Removes set element given its pointer */ +CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem ) +{ + CvSetElem* _elem = (CvSetElem*)elem; + assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ ); + _elem->next_free = set_header->free_elems; + _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG; + set_header->free_elems = _elem; + set_header->active_count--; +} + +/** Removes element from the set by its index */ +CVAPI(void) cvSetRemove( CvSet* set_header, int index ); + +/** Returns a set element by index. If the element doesn't belong to the set, + NULL is returned */ +CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int idx ) +{ + CvSetElem* elem = (CvSetElem*)(void *)cvGetSeqElem( (CvSeq*)set_header, idx ); + return elem && CV_IS_SET_ELEM( elem ) ? elem : 0; +} + +/** Removes all the elements from the set */ +CVAPI(void) cvClearSet( CvSet* set_header ); + +/** Creates new graph */ +CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size, + int vtx_size, int edge_size, + CvMemStorage* storage ); + +/** Adds new vertex to the graph */ +CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL), + CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) ); + + +/** Removes vertex from the graph together with all incident edges */ +CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index ); +CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx ); + + +/** Link two vertices specified by indices or pointers if they + are not connected or return pointer to already existing edge + connecting the vertices. + Functions return 1 if a new edge was created, 0 otherwise */ +CVAPI(int) cvGraphAddEdge( CvGraph* graph, + int start_idx, int end_idx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph, + CvGraphVtx* start_vtx, CvGraphVtx* end_vtx, + const CvGraphEdge* edge CV_DEFAULT(NULL), + CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); + +/** Remove edge connecting two vertices */ +CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx ); +CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, + CvGraphVtx* end_vtx ); + +/** Find edge connecting two vertices */ +CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx ); +CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph, + const CvGraphVtx* start_vtx, + const CvGraphVtx* end_vtx ); +#define cvGraphFindEdge cvFindGraphEdge +#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr + +/** Remove all vertices and edges from the graph */ +CVAPI(void) cvClearGraph( CvGraph* graph ); + + +/** Count number of edges incident to the vertex */ +CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx ); +CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx ); + + +/** Retrieves graph vertex by given index */ +#define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx)) + +/** Retrieves index of a graph vertex given its pointer */ +#define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK) + +/** Retrieves index of a graph edge given its pointer */ +#define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK) + +#define cvGraphGetVtxCount( graph ) ((graph)->active_count) +#define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count) + +#define CV_GRAPH_VERTEX 1 +#define CV_GRAPH_TREE_EDGE 2 +#define CV_GRAPH_BACK_EDGE 4 +#define CV_GRAPH_FORWARD_EDGE 8 +#define CV_GRAPH_CROSS_EDGE 16 +#define CV_GRAPH_ANY_EDGE 30 +#define CV_GRAPH_NEW_TREE 32 +#define CV_GRAPH_BACKTRACKING 64 +#define CV_GRAPH_OVER -1 + +#define CV_GRAPH_ALL_ITEMS -1 + +/** flags for graph vertices and edges */ +#define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30) +#define CV_IS_GRAPH_VERTEX_VISITED(vtx) \ + (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_IS_GRAPH_EDGE_VISITED(edge) \ + (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG) +#define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29) +#define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28) + +typedef struct CvGraphScanner +{ + CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */ + CvGraphVtx* dst; /* current graph edge destination vertex */ + CvGraphEdge* edge; /* current edge */ + + CvGraph* graph; /* the graph */ + CvSeq* stack; /* the graph vertex stack */ + int index; /* the lower bound of certainly visited vertices */ + int mask; /* event mask */ +} +CvGraphScanner; + +/** Creates new graph scanner. */ +CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph, + CvGraphVtx* vtx CV_DEFAULT(NULL), + int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)); + +/** Releases graph scanner. */ +CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner ); + +/** Get next graph element */ +CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner ); + +/** Creates a copy of graph */ +CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ); + + +/** Does look-up transformation. Elements of the source array + (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */ +CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut ); + + +/******************* Iteration through the sequence tree *****************/ +typedef struct CvTreeNodeIterator +{ + const void* node; + int level; + int max_level; +} +CvTreeNodeIterator; + +CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, + const void* first, int max_level ); +CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator ); +CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator ); + +/** Inserts sequence into tree with specified "parent" sequence. + If parent is equal to frame (e.g. the most external contour), + then added contour will have null pointer to parent. */ +CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame ); + +/** Removes contour from tree (together with the contour children). */ +CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame ); + +/** Gathers pointers to all the sequences, + accessible from the `first`, to the single sequence */ +CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, + CvMemStorage* storage ); + +/** The function implements the K-means algorithm for clustering an array of sample + vectors in a specified number of classes */ +#define CV_KMEANS_USE_INITIAL_LABELS 1 +CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, + CvTermCriteria termcrit, int attempts CV_DEFAULT(1), + CvRNG* rng CV_DEFAULT(0), int flags CV_DEFAULT(0), + CvArr* _centers CV_DEFAULT(0), double* compactness CV_DEFAULT(0) ); + +/****************************************************************************************\ +* System functions * +\****************************************************************************************/ + +/** Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ +CVAPI(int) cvUseOptimized( int on_off ); + +typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) + (int,int,int,char*,char*,int,int,int,int,int, + IplROI*,IplImage*,void*,IplTileInfo*); +typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int); +typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int); +typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int); +typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*); + +/** @brief Makes OpenCV use IPL functions for allocating IplImage and IplROI structures. + +Normally, the function is not called directly. Instead, a simple macro +CV_TURN_ON_IPL_COMPATIBILITY() is used that calls cvSetIPLAllocators and passes there pointers +to IPL allocation functions. : +@code + ... + CV_TURN_ON_IPL_COMPATIBILITY() + ... +@endcode +@param create_header pointer to a function, creating IPL image header. +@param allocate_data pointer to a function, allocating IPL image data. +@param deallocate pointer to a function, deallocating IPL image. +@param create_roi pointer to a function, creating IPL image ROI (i.e. Region of Interest). +@param clone_image pointer to a function, cloning an IPL image. + */ +CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, + Cv_iplAllocateImageData allocate_data, + Cv_iplDeallocate deallocate, + Cv_iplCreateROI create_roi, + Cv_iplCloneImage clone_image ); + +#define CV_TURN_ON_IPL_COMPATIBILITY() \ + cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ + iplDeallocate, iplCreateROI, iplCloneImage ) + +/****************************************************************************************\ +* Data Persistence * +\****************************************************************************************/ + +#if 0 +/********************************** High-level functions ********************************/ + +/** @brief Opens file storage for reading or writing data. + +The function opens file storage for reading or writing data. In the latter case, a new file is +created or an existing file is rewritten. The type of the read or written file is determined by the +filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON. + +At the same time, it also supports adding parameters like "example.xml?base64". + +The function returns a pointer to the CvFileStorage structure. +If the file cannot be opened then the function returns NULL. +@param filename Name of the file associated with the storage +@param memstorage Memory storage used for temporary data and for +: storing dynamic structures, such as CvSeq or CvGraph . If it is NULL, a temporary memory + storage is created and used. +@param flags Can be one of the following: +> - **CV_STORAGE_READ** the storage is open for reading +> - **CV_STORAGE_WRITE** the storage is open for writing + (use **CV_STORAGE_WRITE | CV_STORAGE_WRITE_BASE64** to write rawdata in Base64) +@param encoding + */ +CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage, + int flags, const char* encoding CV_DEFAULT(NULL) ); + +/** @brief Releases file storage. + +The function closes the file associated with the storage and releases all the temporary structures. +It must be called after all I/O operations with the storage are finished. +@param fs Double pointer to the released file storage + */ +CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs ); + +/** returns attribute value or 0 (NULL) if there is no such attribute */ +CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name ); + +/** @brief Starts writing a new structure. + +The function starts writing a compound structure (collection) that can be a sequence or a map. After +all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should +be called. The function can be used to group some objects or to implement the write function for a +some user object (see CvTypeInfo). +@param fs File storage +@param name Name of the written structure. The structure can be accessed by this name when the +storage is read. +@param struct_flags A combination one of the following values: +- **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ), + that is, its elements do not have a name. +- **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that + is, all its elements have names. +One and only one of the two above flags must be specified +- **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that + the structure is written as a flow (not as a block), which is more compact. It is + recommended to use this flag for structures or arrays whose elements are all scalars. +@param type_name Optional parameter - the object type name. In + case of XML it is written as a type_id attribute of the structure opening tag. In the case of + YAML it is written after a colon following the structure name (see the example in + CvFileStorage description). In case of JSON it is written as a name/value pair. + Mainly it is used with user objects. When the storage is read, the + encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ). +@param attributes This parameter is not used in the current implementation + */ +CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name, + int struct_flags, const char* type_name CV_DEFAULT(NULL), + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/** @brief Finishes writing to a file node collection. +@param fs File storage +@sa cvStartWriteStruct. + */ +CVAPI(void) cvEndWriteStruct( CvFileStorage* fs ); + +/** @brief Writes an integer value. + +The function writes a single integer value (with or without a name) to the file storage. +@param fs File storage +@param name Name of the written value. Should be NULL if and only if the parent structure is a +sequence. +@param value The written value + */ +CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value ); + +/** @brief Writes a floating-point value. + +The function writes a single floating-point value (with or without a name) to file storage. Special +values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf. + +The following example shows how to use the low-level writing functions to store custom structures, +such as termination criteria, without registering a new type. : +@code + void write_termcriteria( CvFileStorage* fs, const char* struct_name, + CvTermCriteria* termcrit ) + { + cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0)); + cvWriteComment( fs, "termination criteria", 1 ); // just a description + if( termcrit->type & CV_TERMCRIT_ITER ) + cvWriteInteger( fs, "max_iterations", termcrit->max_iter ); + if( termcrit->type & CV_TERMCRIT_EPS ) + cvWriteReal( fs, "accuracy", termcrit->epsilon ); + cvEndWriteStruct( fs ); + } +@endcode +@param fs File storage +@param name Name of the written value. Should be NULL if and only if the parent structure is a +sequence. +@param value The written value +*/ +CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value ); + +/** @brief Writes a text string. + +The function writes a text string to file storage. +@param fs File storage +@param name Name of the written string . Should be NULL if and only if the parent structure is a +sequence. +@param str The written text string +@param quote If non-zero, the written string is put in quotes, regardless of whether they are +required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when +the string starts with a digit or contains spaces). + */ +CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name, + const char* str, int quote CV_DEFAULT(0) ); + +/** @brief Writes a comment. + +The function writes a comment into file storage. The comments are skipped when the storage is read. +@param fs File storage +@param comment The written comment, single-line or multi-line +@param eol_comment If non-zero, the function tries to put the comment at the end of current line. +If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current +line, the comment starts a new line. + */ +CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment, + int eol_comment ); + +/** @brief Writes an object to file storage. + +The function writes an object to file storage. First, the appropriate type info is found using +cvTypeOf. Then, the write method associated with the type info is called. + +Attributes are used to customize the writing procedure. The standard types support the following +attributes (all the dt attributes have the same format as in cvWriteRawData): + +-# CvSeq + - **header_dt** description of user fields of the sequence header that follow CvSeq, or + CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or + point sequence) + - **dt** description of the sequence elements. + - **recursive** if the attribute is present and is not equal to "0" or "false", the whole + tree of sequences (contours) is stored. +-# CvGraph + - **header_dt** description of user fields of the graph header that follows CvGraph; + - **vertex_dt** description of user fields of graph vertices + - **edge_dt** description of user fields of graph edges (note that the edge weight is + always written, so there is no need to specify it explicitly) + +Below is the code that creates the YAML file shown in the CvFileStorage description: +@code + #include "cxcore.h" + + int main( int argc, char** argv ) + { + CvMat* mat = cvCreateMat( 3, 3, CV_32F ); + CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE ); + + cvSetIdentity( mat ); + cvWrite( fs, "A", mat, cvAttrList(0,0) ); + + cvReleaseFileStorage( &fs ); + cvReleaseMat( &mat ); + return 0; + } +@endcode +@param fs File storage +@param name Name of the written object. Should be NULL if and only if the parent structure is a +sequence. +@param ptr Pointer to the object +@param attributes The attributes of the object. They are specific for each particular type (see +the discussion below). + */ +CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr, + CvAttrList attributes CV_DEFAULT(cvAttrList())); + +/** @brief Starts the next stream. + +The function finishes the currently written stream and starts the next stream. In the case of XML +the file with multiple streams looks like this: +@code{.xml} + + + + + + + ... +@endcode +The YAML file will look like this: +@code{.yaml} + %YAML 1.0 + # stream #1 data + ... + --- + # stream #2 data +@endcode +This is useful for concatenating files or for resuming the writing process. +@param fs File storage + */ +CVAPI(void) cvStartNextStream( CvFileStorage* fs ); + +/** @brief Writes multiple numbers. + +The function writes an array, whose elements consist of single or multiple numbers. The function +call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single +call is more efficient. Note that because none of the elements have a name, they should be written +to a sequence rather than a map. +@param fs File storage +@param src Pointer to the written array +@param len Number of the array elements to write +@param dt Specification of each array element, see @ref format_spec "format specification" + */ +CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src, + int len, const char* dt ); + +/** @brief Writes multiple numbers in Base64. + +If either CV_STORAGE_WRITE_BASE64 or cv::FileStorage::WRITE_BASE64 is used, +this function will be the same as cvWriteRawData. If neither, the main +difference is that it outputs a sequence in Base64 encoding rather than +in plain text. + +This function can only be used to write a sequence with a type "binary". + +@param fs File storage +@param src Pointer to the written array +@param len Number of the array elements to write +@param dt Specification of each array element, see @ref format_spec "format specification" +*/ +CVAPI(void) cvWriteRawDataBase64( CvFileStorage* fs, const void* src, + int len, const char* dt ); + +/** @brief Returns a unique pointer for a given name. + +The function returns a unique pointer for each particular file node name. This pointer can be then +passed to the cvGetFileNode function that is faster than cvGetFileNodeByName because it compares +text strings by comparing pointers rather than the strings' content. + +Consider the following example where an array of points is encoded as a sequence of 2-entry maps: +@code + points: + - { x: 10, y: 10 } + - { x: 20, y: 20 } + - { x: 30, y: 30 } + # ... +@endcode +Then, it is possible to get hashed "x" and "y" pointers to speed up decoding of the points. : +@code + #include "cxcore.h" + + int main( int argc, char** argv ) + { + CvFileStorage* fs = cvOpenFileStorage( "points.yml", 0, CV_STORAGE_READ ); + CvStringHashNode* x_key = cvGetHashedNode( fs, "x", -1, 1 ); + CvStringHashNode* y_key = cvGetHashedNode( fs, "y", -1, 1 ); + CvFileNode* points = cvGetFileNodeByName( fs, 0, "points" ); + + if( CV_NODE_IS_SEQ(points->tag) ) + { + CvSeq* seq = points->data.seq; + int i, total = seq->total; + CvSeqReader reader; + cvStartReadSeq( seq, &reader, 0 ); + for( i = 0; i < total; i++ ) + { + CvFileNode* pt = (CvFileNode*)reader.ptr; + #if 1 // faster variant + CvFileNode* xnode = cvGetFileNode( fs, pt, x_key, 0 ); + CvFileNode* ynode = cvGetFileNode( fs, pt, y_key, 0 ); + assert( xnode && CV_NODE_IS_INT(xnode->tag) && + ynode && CV_NODE_IS_INT(ynode->tag)); + int x = xnode->data.i; // or x = cvReadInt( xnode, 0 ); + int y = ynode->data.i; // or y = cvReadInt( ynode, 0 ); + #elif 1 // slower variant; does not use x_key & y_key + CvFileNode* xnode = cvGetFileNodeByName( fs, pt, "x" ); + CvFileNode* ynode = cvGetFileNodeByName( fs, pt, "y" ); + assert( xnode && CV_NODE_IS_INT(xnode->tag) && + ynode && CV_NODE_IS_INT(ynode->tag)); + int x = xnode->data.i; // or x = cvReadInt( xnode, 0 ); + int y = ynode->data.i; // or y = cvReadInt( ynode, 0 ); + #else // the slowest yet the easiest to use variant + int x = cvReadIntByName( fs, pt, "x", 0 ); + int y = cvReadIntByName( fs, pt, "y", 0 ); + #endif + CV_NEXT_SEQ_ELEM( seq->elem_size, reader ); + printf(" + } + } + cvReleaseFileStorage( &fs ); + return 0; + } +@endcode +Please note that whatever method of accessing a map you are using, it is still much slower than +using plain sequences; for example, in the above example, it is more efficient to encode the points +as pairs of integers in a single numeric sequence. +@param fs File storage +@param name Literal node name +@param len Length of the name (if it is known apriori), or -1 if it needs to be calculated +@param create_missing Flag that specifies, whether an absent key should be added into the hash table +*/ +CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name, + int len CV_DEFAULT(-1), + int create_missing CV_DEFAULT(0)); + +/** @brief Retrieves one of the top-level nodes of the file storage. + +The function returns one of the top-level file nodes. The top-level nodes do not have a name, they +correspond to the streams that are stored one after another in the file storage. If the index is out +of range, the function returns a NULL pointer, so all the top-level nodes can be iterated by +subsequent calls to the function with stream_index=0,1,..., until the NULL pointer is returned. +This function can be used as a base for recursive traversal of the file storage. +@param fs File storage +@param stream_index Zero-based index of the stream. See cvStartNextStream . In most cases, +there is only one stream in the file; however, there can be several. + */ +CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs, + int stream_index CV_DEFAULT(0) ); + +/** @brief Finds a node in a map or file storage. + +The function finds a file node. It is a faster version of cvGetFileNodeByName (see +cvGetHashedKey discussion). Also, the function can insert a new node, if it is not in the map yet. +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. If both map and +key are NULLs, the function returns the root file node - a map that contains top-level nodes. +@param key Unique pointer to the node name, retrieved with cvGetHashedKey +@param create_missing Flag that specifies whether an absent node should be added to the map + */ +CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map, + const CvStringHashNode* key, + int create_missing CV_DEFAULT(0) ); + +/** @brief Finds a node in a map or file storage. + +The function finds a file node by name. The node is searched either in map or, if the pointer is +NULL, among the top-level file storage nodes. Using this function for maps and cvGetSeqElem (or +sequence reader) for sequences, it is possible to navigate through the file storage. To speed up +multiple queries for a certain key (e.g., in the case of an array of structures) one may use a +combination of cvGetHashedKey and cvGetFileNode. +@param fs File storage +@param map The parent map. If it is NULL, the function searches in all the top-level nodes +(streams), starting with the first one. +@param name The file node name + */ +CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs, + const CvFileNode* map, + const char* name ); + +/** @brief Retrieves an integer value from a file node. + +The function returns an integer that is represented by the file node. If the file node is NULL, the +default_value is returned (thus, it is convenient to call the function right after cvGetFileNode +without checking for a NULL pointer). If the file node has type CV_NODE_INT, then node-\>data.i is +returned. If the file node has type CV_NODE_REAL, then node-\>data.f is converted to an integer +and returned. Otherwise the error is reported. +@param node File node +@param default_value The value that is returned if node is NULL + */ +CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? node->data.i : + CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff; +} + +/** @brief Finds a file node and returns its value. + +The function is a simple superposition of cvGetFileNodeByName and cvReadInt. +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param default_value The value that is returned if the file node is not found + */ +CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, int default_value CV_DEFAULT(0) ) +{ + return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value ); +} + +/** @brief Retrieves a floating-point value from a file node. + +The function returns a floating-point value that is represented by the file node. If the file node +is NULL, the default_value is returned (thus, it is convenient to call the function right after +cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_REAL , +then node-\>data.f is returned. If the file node has type CV_NODE_INT , then node-:math:\>data.f +is converted to floating-point and returned. Otherwise the result is not determined. +@param node File node +@param default_value The value that is returned if node is NULL + */ +CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) ) +{ + return !node ? default_value : + CV_NODE_IS_INT(node->tag) ? (double)node->data.i : + CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300; +} + +/** @brief Finds a file node and returns its value. + +The function is a simple superposition of cvGetFileNodeByName and cvReadReal . +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param default_value The value that is returned if the file node is not found + */ +CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, double default_value CV_DEFAULT(0.) ) +{ + return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value ); +} + +/** @brief Retrieves a text string from a file node. + +The function returns a text string that is represented by the file node. If the file node is NULL, +the default_value is returned (thus, it is convenient to call the function right after +cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_STR , then +node-:math:\>data.str.ptr is returned. Otherwise the result is not determined. +@param node File node +@param default_value The value that is returned if node is NULL + */ +CV_INLINE const char* cvReadString( const CvFileNode* node, + const char* default_value CV_DEFAULT(NULL) ) +{ + return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0; +} + +/** @brief Finds a file node by its name and returns its value. + +The function is a simple superposition of cvGetFileNodeByName and cvReadString . +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param default_value The value that is returned if the file node is not found + */ +CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map, + const char* name, const char* default_value CV_DEFAULT(NULL) ) +{ + return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value ); +} + + +/** @brief Decodes an object and returns a pointer to it. + +The function decodes a user object (creates an object in a native representation from the file +storage subtree) and returns it. The object to be decoded must be an instance of a registered type +that supports the read method (see CvTypeInfo). The type of the object is determined by the type +name that is encoded in the file. If the object is a dynamic structure, it is created either in +memory storage and passed to cvOpenFileStorage or, if a NULL pointer was passed, in temporary +memory storage, which is released when cvReleaseFileStorage is called. Otherwise, if the object is +not a dynamic structure, it is created in a heap and should be released with a specialized function +or by using the generic cvRelease. +@param fs File storage +@param node The root object node +@param attributes Unused parameter + */ +CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node, + CvAttrList* attributes CV_DEFAULT(NULL)); + +/** @brief Finds an object by name and decodes it. + +The function is a simple superposition of cvGetFileNodeByName and cvRead. +@param fs File storage +@param map The parent map. If it is NULL, the function searches a top-level node. +@param name The node name +@param attributes Unused parameter + */ +CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map, + const char* name, CvAttrList* attributes CV_DEFAULT(NULL) ) +{ + return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes ); +} + + +/** @brief Initializes the file node sequence reader. + +The function initializes the sequence reader to read data from a file node. The initialized reader +can be then passed to cvReadRawDataSlice. +@param fs File storage +@param src The file node (a sequence) to read numbers from +@param reader Pointer to the sequence reader + */ +CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, + CvSeqReader* reader ); + +/** @brief Initializes file node sequence reader. + +The function reads one or more elements from the file node, representing a sequence, to a +user-specified array. The total number of read sequence elements is a product of total and the +number of components in each array element. For example, if dt=2if, the function will read total\*3 +sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read +repeatedly by repositioning the reader using cvSetSeqReaderPos. +@param fs File storage +@param reader The sequence reader. Initialize it with cvStartReadRawData . +@param count The number of elements to read +@param dst Pointer to the destination array +@param dt Specification of each array element. It has the same format as in cvWriteRawData . + */ +CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, + int count, void* dst, const char* dt ); + +/** @brief Reads multiple numbers. + +The function reads elements from a file node that represents a sequence of scalars. +@param fs File storage +@param src The file node (a sequence) to read numbers from +@param dst Pointer to the destination array +@param dt Specification of each array element. It has the same format as in cvWriteRawData . + */ +CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, + void* dst, const char* dt ); + +/** @brief Writes a file node to another file storage. + +The function writes a copy of a file node to file storage. Possible applications of the function are +merging several file storages into one and conversion between XML, YAML and JSON formats. +@param fs Destination file storage +@param new_node_name New name of the file node in the destination file storage. To keep the +existing name, use cvcvGetFileNodeName +@param node The written node +@param embed If the written node is a collection and this parameter is not zero, no extra level of +hierarchy is created. Instead, all the elements of node are written into the currently written +structure. Of course, map elements can only be embedded into another map, and sequence elements +can only be embedded into another sequence. + */ +CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, + const CvFileNode* node, int embed ); + +/** @brief Returns the name of a file node. + +The function returns the name of a file node or NULL, if the file node does not have a name or if +node is NULL. +@param node File node + */ +CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node ); + +/*********************************** Adding own types ***********************************/ + +/** @brief Registers a new type. + +The function registers a new type, which is described by info . The function creates a copy of the +structure, so the user should delete it after calling the function. +@param info Type info structure + */ +CVAPI(void) cvRegisterType( const CvTypeInfo* info ); + +/** @brief Unregisters the type. + +The function unregisters a type with a specified name. If the name is unknown, it is possible to +locate the type info by an instance of the type using cvTypeOf or by iterating the type list, +starting from cvFirstType, and then calling cvUnregisterType(info-\>typeName). +@param type_name Name of an unregistered type + */ +CVAPI(void) cvUnregisterType( const char* type_name ); + +/** @brief Returns the beginning of a type list. + +The function returns the first type in the list of registered types. Navigation through the list can +be done via the prev and next fields of the CvTypeInfo structure. + */ +CVAPI(CvTypeInfo*) cvFirstType(void); + +/** @brief Finds a type by its name. + +The function finds a registered type by its name. It returns NULL if there is no type with the +specified name. +@param type_name Type name + */ +CVAPI(CvTypeInfo*) cvFindType( const char* type_name ); + +/** @brief Returns the type of an object. + +The function finds the type of a given object. It iterates through the list of registered types and +calls the is_instance function/method for every type info structure with that object until one of +them returns non-zero or until the whole list has been traversed. In the latter case, the function +returns NULL. +@param struct_ptr The object pointer + */ +CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr ); + +#endif + +/** @brief Releases an object. + + The function finds the type of a given object and calls release with the double pointer. + @param struct_ptr Double pointer to the object + */ +CVAPI(void) cvRelease( void** struct_ptr ); + +/** @brief Makes a clone of an object. + +The function finds the type of a given object and calls clone with the passed object. Of course, if +you know the object type, for example, struct_ptr is CvMat\*, it is faster to call the specific +function, like cvCloneMat. +@param struct_ptr The object to clone + */ +CVAPI(void*) cvClone( const void* struct_ptr ); + +/*********************************** Measuring Execution Time ***************************/ + +/** helper functions for RNG initialization and accurate time measurement: + uses internal clock counter on x86 */ +CVAPI(int64) cvGetTickCount( void ); +CVAPI(double) cvGetTickFrequency( void ); + +/*********************************** CPU capabilities ***********************************/ + +CVAPI(int) cvCheckHardwareSupport(int feature); + +/*********************************** Multi-Threading ************************************/ + +/** retrieve/set the number of threads used in OpenMP implementations */ +CVAPI(int) cvGetNumThreads( void ); +CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) ); +/** get index of the thread being executed */ +CVAPI(int) cvGetThreadNum( void ); + + +/********************************** Error Handling **************************************/ + +/** Get current OpenCV error status */ +CVAPI(int) cvGetErrStatus( void ); + +/** Sets error status silently */ +CVAPI(void) cvSetErrStatus( int status ); + +#define CV_ErrModeLeaf 0 /* Print error and exit program */ +#define CV_ErrModeParent 1 /* Print error and continue */ +#define CV_ErrModeSilent 2 /* Don't print and continue */ + +/** Retrieves current error processing mode */ +CVAPI(int) cvGetErrMode( void ); + +/** Sets error processing mode, returns previously used mode */ +CVAPI(int) cvSetErrMode( int mode ); + +/** Sets error status and performs some additional actions (displaying message box, + writing message to stderr, terminating application etc.) + depending on the current error mode */ +CVAPI(void) cvError( int status, const char* func_name, + const char* err_msg, const char* file_name, int line ); + +/** Retrieves textual description of the error given its code */ +CVAPI(const char*) cvErrorStr( int status ); + +/** Retrieves detailed information about the last error occurred */ +CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, + const char** filename, int* line ); + +/** Maps IPP error codes to the counterparts from OpenCV */ +CVAPI(int) cvErrorFromIppStatus( int ipp_status ); + +typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, int line, void* userdata ); + +/** Assigns a new error-handling function */ +CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, + void* userdata CV_DEFAULT(NULL), + void** prev_userdata CV_DEFAULT(NULL) ); + +/** Output nothing */ +CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +/** Output to console(fprintf(stderr,...)) */ +CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +/** Output to MessageBox(WIN32) */ +CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, + const char* file_name, int line, void* userdata ); + +#define OPENCV_ERROR(status,func,context) \ +cvError((status),(func),(context),__FILE__,__LINE__) + +#define OPENCV_ASSERT(expr,func,context) \ +{if (! (expr)) \ +{OPENCV_ERROR(CV_StsInternal,(func),(context));}} + +#define OPENCV_CALL( Func ) \ +{ \ +Func; \ +} + + +/** CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */ +#ifdef CV_NO_FUNC_NAMES +#define CV_FUNCNAME( Name ) +#define cvFuncName "" +#else +#define CV_FUNCNAME( Name ) \ +static char cvFuncName[] = Name +#endif + + +/** + CV_ERROR macro unconditionally raises error with passed code and message. + After raising error, control will be transferred to the exit label. + */ +#define CV_ERROR( Code, Msg ) \ +{ \ + cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \ + __CV_EXIT__; \ +} + +/** + CV_CHECK macro checks error status after CV (or IPL) + function call. If error detected, control will be transferred to the exit + label. + */ +#define CV_CHECK() \ +{ \ + if( cvGetErrStatus() < 0 ) \ + CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ +} + + +/** + CV_CALL macro calls CV (or IPL) function, checks error status and + signals a error if the function failed. Useful in "parent node" + error processing mode + */ +#define CV_CALL( Func ) \ +{ \ + Func; \ + CV_CHECK(); \ +} + + +/** Runtime assertion macro */ +#define CV_ASSERT( Condition ) \ +{ \ + if( !(Condition) ) \ + CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \ +} + +#define __CV_BEGIN__ { +#define __CV_END__ goto exit; exit: ; } +#define __CV_EXIT__ goto exit + +/** @} core_c */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#ifdef __cplusplus + +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @addtogroup core_c_glue +//! @{ + +/////////////////////////////////////////// glue /////////////////////////////////////////// + +//! converts array (CvMat or IplImage) to cv::Mat +CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, + bool allowND=true, int coiMode=0, + AutoBuffer* buf=0); + +static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) +{ + return cvarrToMat(arr, copyData, true, coiMode); +} + + +//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. +CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); +//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage +CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); + + + +////// specialized implementations of DefaultDeleter::operator() for classic OpenCV types ////// + +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvMat* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(IplImage* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvMatND* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvSparseMat* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvMemStorage* obj) const; }; + +////////////// convenient wrappers for operating old-style dynamic structures ////////////// + +template class SeqIterator; + +typedef Ptr MemStorage; + +/*! + Template Sequence Class derived from CvSeq + + The class provides more convenient access to sequence elements, + STL-style operations and iterators. + + \note The class is targeted for simple data types, + i.e. no constructors or destructors + are called for the sequence elements. +*/ +template class Seq +{ +public: + typedef SeqIterator<_Tp> iterator; + typedef SeqIterator<_Tp> const_iterator; + + //! the default constructor + Seq(); + //! the constructor for wrapping CvSeq structure. The real element type in CvSeq should match _Tp. + Seq(const CvSeq* seq); + //! creates the empty sequence that resides in the specified storage + Seq(MemStorage& storage, int headerSize = sizeof(CvSeq)); + //! returns read-write reference to the specified element + _Tp& operator [](int idx); + //! returns read-only reference to the specified element + const _Tp& operator[](int idx) const; + //! returns iterator pointing to the beginning of the sequence + SeqIterator<_Tp> begin() const; + //! returns iterator pointing to the element following the last sequence element + SeqIterator<_Tp> end() const; + //! returns the number of elements in the sequence + size_t size() const; + //! returns the type of sequence elements (CV_8UC1 ... CV_64FC(CV_CN_MAX) ...) + int type() const; + //! returns the depth of sequence elements (CV_8U ... CV_64F) + int depth() const; + //! returns the number of channels in each sequence element + int channels() const; + //! returns the size of each sequence element + size_t elemSize() const; + //! returns index of the specified sequence element + size_t index(const _Tp& elem) const; + //! appends the specified element to the end of the sequence + void push_back(const _Tp& elem); + //! appends the specified element to the front of the sequence + void push_front(const _Tp& elem); + //! appends zero or more elements to the end of the sequence + void push_back(const _Tp* elems, size_t count); + //! appends zero or more elements to the front of the sequence + void push_front(const _Tp* elems, size_t count); + //! inserts the specified element to the specified position + void insert(int idx, const _Tp& elem); + //! inserts zero or more elements to the specified position + void insert(int idx, const _Tp* elems, size_t count); + //! removes element at the specified position + void remove(int idx); + //! removes the specified subsequence + void remove(const Range& r); + + //! returns reference to the first sequence element + _Tp& front(); + //! returns read-only reference to the first sequence element + const _Tp& front() const; + //! returns reference to the last sequence element + _Tp& back(); + //! returns read-only reference to the last sequence element + const _Tp& back() const; + //! returns true iff the sequence contains no elements + bool empty() const; + + //! removes all the elements from the sequence + void clear(); + //! removes the first element from the sequence + void pop_front(); + //! removes the last element from the sequence + void pop_back(); + //! removes zero or more elements from the beginning of the sequence + void pop_front(_Tp* elems, size_t count); + //! removes zero or more elements from the end of the sequence + void pop_back(_Tp* elems, size_t count); + + //! copies the whole sequence or the sequence slice to the specified vector + void copyTo(std::vector<_Tp>& vec, const Range& range=Range::all()) const; + //! returns the vector containing all the sequence elements + operator std::vector<_Tp>() const; + + CvSeq* seq; +}; + + +/*! + STL-style Sequence Iterator inherited from the CvSeqReader structure +*/ +template class SeqIterator : public CvSeqReader +{ +public: + //! the default constructor + SeqIterator(); + //! the constructor setting the iterator to the beginning or to the end of the sequence + SeqIterator(const Seq<_Tp>& seq, bool seekEnd=false); + //! positions the iterator within the sequence + void seek(size_t pos); + //! reports the current iterator position + size_t tell() const; + //! returns reference to the current sequence element + _Tp& operator *(); + //! returns read-only reference to the current sequence element + const _Tp& operator *() const; + //! moves iterator to the next sequence element + SeqIterator& operator ++(); + //! moves iterator to the next sequence element + SeqIterator operator ++(int) const; + //! moves iterator to the previous sequence element + SeqIterator& operator --(); + //! moves iterator to the previous sequence element + SeqIterator operator --(int) const; + + //! moves iterator forward by the specified offset (possibly negative) + SeqIterator& operator +=(int); + //! moves iterator backward by the specified offset (possibly negative) + SeqIterator& operator -=(int); + + // this is index of the current element module seq->total*2 + // (to distinguish between 0 and seq->total) + int index; +}; + + + +// bridge C++ => C Seq API +CV_EXPORTS schar* seqPush( CvSeq* seq, const void* element=0); +CV_EXPORTS schar* seqPushFront( CvSeq* seq, const void* element=0); +CV_EXPORTS void seqPop( CvSeq* seq, void* element=0); +CV_EXPORTS void seqPopFront( CvSeq* seq, void* element=0); +CV_EXPORTS void seqPopMulti( CvSeq* seq, void* elements, + int count, int in_front=0 ); +CV_EXPORTS void seqRemove( CvSeq* seq, int index ); +CV_EXPORTS void clearSeq( CvSeq* seq ); +CV_EXPORTS schar* getSeqElem( const CvSeq* seq, int index ); +CV_EXPORTS void seqRemoveSlice( CvSeq* seq, CvSlice slice ); +CV_EXPORTS void seqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); + +template inline Seq<_Tp>::Seq() : seq(0) {} +template inline Seq<_Tp>::Seq( const CvSeq* _seq ) : seq((CvSeq*)_seq) +{ + CV_Assert(!_seq || _seq->elem_size == sizeof(_Tp)); +} + +template inline Seq<_Tp>::Seq( MemStorage& storage, + int headerSize ) +{ + CV_Assert(headerSize >= (int)sizeof(CvSeq)); + seq = cvCreateSeq(DataType<_Tp>::type, headerSize, sizeof(_Tp), storage); +} + +template inline _Tp& Seq<_Tp>::operator [](int idx) +{ return *(_Tp*)getSeqElem(seq, idx); } + +template inline const _Tp& Seq<_Tp>::operator [](int idx) const +{ return *(_Tp*)getSeqElem(seq, idx); } + +template inline SeqIterator<_Tp> Seq<_Tp>::begin() const +{ return SeqIterator<_Tp>(*this); } + +template inline SeqIterator<_Tp> Seq<_Tp>::end() const +{ return SeqIterator<_Tp>(*this, true); } + +template inline size_t Seq<_Tp>::size() const +{ return seq ? seq->total : 0; } + +template inline int Seq<_Tp>::type() const +{ return seq ? CV_MAT_TYPE(seq->flags) : 0; } + +template inline int Seq<_Tp>::depth() const +{ return seq ? CV_MAT_DEPTH(seq->flags) : 0; } + +template inline int Seq<_Tp>::channels() const +{ return seq ? CV_MAT_CN(seq->flags) : 0; } + +template inline size_t Seq<_Tp>::elemSize() const +{ return seq ? seq->elem_size : 0; } + +template inline size_t Seq<_Tp>::index(const _Tp& elem) const +{ return cvSeqElemIdx(seq, &elem); } + +template inline void Seq<_Tp>::push_back(const _Tp& elem) +{ cvSeqPush(seq, &elem); } + +template inline void Seq<_Tp>::push_front(const _Tp& elem) +{ cvSeqPushFront(seq, &elem); } + +template inline void Seq<_Tp>::push_back(const _Tp* elem, size_t count) +{ cvSeqPushMulti(seq, elem, (int)count, 0); } + +template inline void Seq<_Tp>::push_front(const _Tp* elem, size_t count) +{ cvSeqPushMulti(seq, elem, (int)count, 1); } + +template inline _Tp& Seq<_Tp>::back() +{ return *(_Tp*)getSeqElem(seq, -1); } + +template inline const _Tp& Seq<_Tp>::back() const +{ return *(const _Tp*)getSeqElem(seq, -1); } + +template inline _Tp& Seq<_Tp>::front() +{ return *(_Tp*)getSeqElem(seq, 0); } + +template inline const _Tp& Seq<_Tp>::front() const +{ return *(const _Tp*)getSeqElem(seq, 0); } + +template inline bool Seq<_Tp>::empty() const +{ return !seq || seq->total == 0; } + +template inline void Seq<_Tp>::clear() +{ if(seq) clearSeq(seq); } + +template inline void Seq<_Tp>::pop_back() +{ seqPop(seq); } + +template inline void Seq<_Tp>::pop_front() +{ seqPopFront(seq); } + +template inline void Seq<_Tp>::pop_back(_Tp* elem, size_t count) +{ seqPopMulti(seq, elem, (int)count, 0); } + +template inline void Seq<_Tp>::pop_front(_Tp* elem, size_t count) +{ seqPopMulti(seq, elem, (int)count, 1); } + +template inline void Seq<_Tp>::insert(int idx, const _Tp& elem) +{ seqInsert(seq, idx, &elem); } + +template inline void Seq<_Tp>::insert(int idx, const _Tp* elems, size_t count) +{ + CvMat m = cvMat(1, count, DataType<_Tp>::type, elems); + seqInsertSlice(seq, idx, &m); +} + +template inline void Seq<_Tp>::remove(int idx) +{ seqRemove(seq, idx); } + +template inline void Seq<_Tp>::remove(const Range& r) +{ seqRemoveSlice(seq, cvSlice(r.start, r.end)); } + +template inline void Seq<_Tp>::copyTo(std::vector<_Tp>& vec, const Range& range) const +{ + size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start; + vec.resize(len); + if( seq && len ) + cvCvtSeqToArray(seq, &vec[0], cvSlice(range)); +} + +template inline Seq<_Tp>::operator std::vector<_Tp>() const +{ + std::vector<_Tp> vec; + copyTo(vec); + return vec; +} + +template inline SeqIterator<_Tp>::SeqIterator() +{ memset(this, 0, sizeof(*this)); } + +template inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& _seq, bool seekEnd) +{ + cvStartReadSeq(_seq.seq, this); + index = seekEnd ? _seq.seq->total : 0; +} + +template inline void SeqIterator<_Tp>::seek(size_t pos) +{ + cvSetSeqReaderPos(this, (int)pos, false); + index = pos; +} + +template inline size_t SeqIterator<_Tp>::tell() const +{ return index; } + +template inline _Tp& SeqIterator<_Tp>::operator *() +{ return *(_Tp*)ptr; } + +template inline const _Tp& SeqIterator<_Tp>::operator *() const +{ return *(const _Tp*)ptr; } + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator ++() +{ + CV_NEXT_SEQ_ELEM(sizeof(_Tp), *this); + if( ++index >= seq->total*2 ) + index = 0; + return *this; +} + +template inline SeqIterator<_Tp> SeqIterator<_Tp>::operator ++(int) const +{ + SeqIterator<_Tp> it = *this; + ++*this; + return it; +} + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator --() +{ + CV_PREV_SEQ_ELEM(sizeof(_Tp), *this); + if( --index < 0 ) + index = seq->total*2-1; + return *this; +} + +template inline SeqIterator<_Tp> SeqIterator<_Tp>::operator --(int) const +{ + SeqIterator<_Tp> it = *this; + --*this; + return it; +} + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator +=(int delta) +{ + cvSetSeqReaderPos(this, delta, 1); + index += delta; + int n = seq->total*2; + if( index < 0 ) + index += n; + if( index >= n ) + index -= n; + return *this; +} + +template inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator -=(int delta) +{ + return (*this += -delta); +} + +template inline ptrdiff_t operator - (const SeqIterator<_Tp>& a, + const SeqIterator<_Tp>& b) +{ + ptrdiff_t delta = a.index - b.index, n = a.seq->total; + if( delta > n || delta < -n ) + delta += delta < 0 ? n : -n; + return delta; +} + +template inline bool operator == (const SeqIterator<_Tp>& a, + const SeqIterator<_Tp>& b) +{ + return a.seq == b.seq && a.index == b.index; +} + +template inline bool operator != (const SeqIterator<_Tp>& a, + const SeqIterator<_Tp>& b) +{ + return !(a == b); +} + +//! @} + +} // cv + +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda.hpp new file mode 100644 index 0000000..716b8bf --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda.hpp @@ -0,0 +1,1270 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDA_HPP +#define OPENCV_CORE_CUDA_HPP + +#ifndef __cplusplus +# error cuda.hpp header must be compiled as C++ +#endif + +#include "opencv2/core.hpp" +#include "opencv2/core/cuda_types.hpp" + +/** + @defgroup cuda CUDA-accelerated Computer Vision + @{ + @defgroup cudacore Core part + @{ + @defgroup cudacore_init Initialization and Information + @defgroup cudacore_struct Data Structures + @} + @} + */ + +namespace cv { namespace cuda { + +//! @addtogroup cudacore_struct +//! @{ + +//=================================================================================== +// GpuMat +//=================================================================================== + +/** @brief Base storage class for GPU memory with reference counting. + +Its interface matches the Mat interface with the following limitations: + +- no arbitrary dimensions support (only 2D) +- no functions that return references to their data (because references on GPU are not valid for + CPU) +- no expression templates technique support + +Beware that the latter limitation may lead to overloaded matrix operators that cause memory +allocations. The GpuMat class is convertible to cuda::PtrStepSz and cuda::PtrStep so it can be +passed directly to the kernel. + +@note In contrast with Mat, in most cases GpuMat::isContinuous() == false . This means that rows are +aligned to a size depending on the hardware. Single-row GpuMat is always a continuous matrix. + +@note You are not recommended to leave static or global GpuMat variables allocated, that is, to rely +on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory +release function returns error if the CUDA context has been destroyed before. + +Some member functions are described as a "Blocking Call" while some are described as a +"Non-Blocking Call". Blocking functions are synchronous to host. It is guaranteed that the GPU +operation is finished when the function returns. However, non-blocking functions are asynchronous to +host. Those functions may return even if the GPU operation is not finished. + +Compared to their blocking counterpart, non-blocking functions accept Stream as an additional +argument. If a non-default stream is passed, the GPU operation may overlap with operations in other +streams. + +@sa Mat + */ +class CV_EXPORTS_W GpuMat +{ +public: + class CV_EXPORTS_W Allocator + { + public: + virtual ~Allocator() {} + + // allocator must fill data, step and refcount fields + virtual bool allocate(GpuMat* mat, int rows, int cols, size_t elemSize) = 0; + virtual void free(GpuMat* mat) = 0; + }; + + //! default allocator + CV_WRAP static GpuMat::Allocator* defaultAllocator(); + CV_WRAP static void setDefaultAllocator(GpuMat::Allocator* allocator); + + //! default constructor + CV_WRAP explicit GpuMat(GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! constructs GpuMat of the specified size and type + CV_WRAP GpuMat(int rows, int cols, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, int type, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! constructs GpuMat and fills it with the specified value _s + CV_WRAP GpuMat(int rows, int cols, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + CV_WRAP GpuMat(Size size, int type, Scalar s, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! copy constructor + CV_WRAP GpuMat(const GpuMat& m); + + //! constructor for GpuMat headers pointing to user-allocated data + GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP); + GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP); + + //! creates a GpuMat header for a part of the bigger matrix + CV_WRAP GpuMat(const GpuMat& m, Range rowRange, Range colRange); + CV_WRAP GpuMat(const GpuMat& m, Rect roi); + + //! builds GpuMat from host memory (Blocking call) + CV_WRAP explicit GpuMat(InputArray arr, GpuMat::Allocator* allocator = GpuMat::defaultAllocator()); + + //! destructor - calls release() + ~GpuMat(); + + //! assignment operators + GpuMat& operator =(const GpuMat& m); + + //! allocates new GpuMat data unless the GpuMat already has specified size and type + CV_WRAP void create(int rows, int cols, int type); + CV_WRAP void create(Size size, int type); + + //! decreases reference counter, deallocate the data when reference counter reaches 0 + void release(); + + //! swaps with other smart pointer + CV_WRAP void swap(GpuMat& mat); + + /** @brief Performs data upload to GpuMat (Blocking call) + + This function copies data from host memory to device memory. As being a blocking call, it is + guaranteed that the copy operation is finished when this function returns. + */ + CV_WRAP void upload(InputArray arr); + + /** @brief Performs data upload to GpuMat (Non-Blocking call) + + This function copies data from host memory to device memory. As being a non-blocking call, this + function may return even if the copy operation is not finished. + + The copy operation may be overlapped with operations in other non-default streams if \p stream is + not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. + */ + CV_WRAP void upload(InputArray arr, Stream& stream); + + /** @brief Performs data download from GpuMat (Blocking call) + + This function copies data from device memory to host memory. As being a blocking call, it is + guaranteed that the copy operation is finished when this function returns. + */ + CV_WRAP void download(OutputArray dst) const; + + /** @brief Performs data download from GpuMat (Non-Blocking call) + + This function copies data from device memory to host memory. As being a non-blocking call, this + function may return even if the copy operation is not finished. + + The copy operation may be overlapped with operations in other non-default streams if \p stream is + not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option. + */ + CV_WRAP void download(OutputArray dst, Stream& stream) const; + + //! returns deep copy of the GpuMat, i.e. the data is copied + CV_WRAP GpuMat clone() const; + + //! copies the GpuMat content to device memory (Blocking call) + CV_WRAP void copyTo(OutputArray dst) const; + + //! copies the GpuMat content to device memory (Non-Blocking call) + CV_WRAP void copyTo(OutputArray dst, Stream& stream) const; + + //! copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call) + CV_WRAP void copyTo(OutputArray dst, InputArray mask) const; + + //! copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call) + CV_WRAP void copyTo(OutputArray dst, InputArray mask, Stream& stream) const; + + //! sets some of the GpuMat elements to s (Blocking call) + CV_WRAP GpuMat& setTo(Scalar s); + + //! sets some of the GpuMat elements to s (Non-Blocking call) + CV_WRAP GpuMat& setTo(Scalar s, Stream& stream); + + //! sets some of the GpuMat elements to s, according to the mask (Blocking call) + CV_WRAP GpuMat& setTo(Scalar s, InputArray mask); + + //! sets some of the GpuMat elements to s, according to the mask (Non-Blocking call) + CV_WRAP GpuMat& setTo(Scalar s, InputArray mask, Stream& stream); + + //! converts GpuMat to another datatype (Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype) const; + + //! converts GpuMat to another datatype (Non-Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, Stream& stream) const; + + //! converts GpuMat to another datatype with scaling (Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const; + + //! converts GpuMat to another datatype with scaling (Non-Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const; + + //! converts GpuMat to another datatype with scaling (Non-Blocking call) + CV_WRAP void convertTo(OutputArray dst, int rtype, double alpha, double beta, Stream& stream) const; + + CV_WRAP void assignTo(GpuMat& m, int type = -1) const; + + //! returns pointer to y-th row + uchar* ptr(int y = 0); + const uchar* ptr(int y = 0) const; + + //! template version of the above method + template _Tp* ptr(int y = 0); + template const _Tp* ptr(int y = 0) const; + + template operator PtrStepSz<_Tp>() const; + template operator PtrStep<_Tp>() const; + + //! returns a new GpuMat header for the specified row + CV_WRAP GpuMat row(int y) const; + + //! returns a new GpuMat header for the specified column + CV_WRAP GpuMat col(int x) const; + + //! ... for the specified row span + CV_WRAP GpuMat rowRange(int startrow, int endrow) const; + CV_WRAP GpuMat rowRange(Range r) const; + + //! ... for the specified column span + CV_WRAP GpuMat colRange(int startcol, int endcol) const; + CV_WRAP GpuMat colRange(Range r) const; + + //! extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.) + GpuMat operator ()(Range rowRange, Range colRange) const; + GpuMat operator ()(Rect roi) const; + + //! creates alternative GpuMat header for the same data, with different + //! number of channels and/or different number of rows + CV_WRAP GpuMat reshape(int cn, int rows = 0) const; + + //! locates GpuMat header within a parent GpuMat + CV_WRAP void locateROI(Size& wholeSize, Point& ofs) const; + + //! moves/resizes the current GpuMat ROI inside the parent GpuMat + CV_WRAP GpuMat& adjustROI(int dtop, int dbottom, int dleft, int dright); + + //! returns true iff the GpuMat data is continuous + //! (i.e. when there are no gaps between successive rows) + CV_WRAP bool isContinuous() const; + + //! returns element size in bytes + CV_WRAP size_t elemSize() const; + + //! returns the size of element channel in bytes + CV_WRAP size_t elemSize1() const; + + //! returns element type + CV_WRAP int type() const; + + //! returns element type + CV_WRAP int depth() const; + + //! returns number of channels + CV_WRAP int channels() const; + + //! returns step/elemSize1() + CV_WRAP size_t step1() const; + + //! returns GpuMat size : width == number of columns, height == number of rows + CV_WRAP Size size() const; + + //! returns true if GpuMat data is NULL + CV_WRAP bool empty() const; + + // returns pointer to cuda memory + CV_WRAP void* cudaPtr() const; + + //! internal use method: updates the continuity flag + CV_WRAP void updateContinuityFlag(); + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + + //! the number of rows and columns + int rows, cols; + + //! a distance between successive rows in bytes; includes the gap if any + CV_PROP size_t step; + + //! pointer to the data + uchar* data; + + //! pointer to the reference counter; + //! when GpuMat points to user-allocated data, the pointer is NULL + int* refcount; + + //! helper fields used in locateROI and adjustROI + uchar* datastart; + const uchar* dataend; + + //! allocator + Allocator* allocator; +}; + +struct CV_EXPORTS_W GpuData +{ + explicit GpuData(size_t _size); + ~GpuData(); + + GpuData(const GpuData&) = delete; + GpuData& operator=(const GpuData&) = delete; + + GpuData(GpuData&&) = delete; + GpuData& operator=(GpuData&&) = delete; + + uchar* data; + size_t size; +}; + +class CV_EXPORTS_W GpuMatND +{ +public: + using SizeArray = std::vector; + using StepArray = std::vector; + using IndexArray = std::vector; + + //! destructor + ~GpuMatND(); + + //! default constructor + GpuMatND(); + + /** @overload + @param size Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + GpuMatND(SizeArray size, int type); + + /** @overload + @param size Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_16FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param step Array of _size.size()-1 steps in case of a multi-dimensional array (the last step is always + set to the element size). If not specified, the matrix is assumed to be continuous. + */ + GpuMatND(SizeArray size, int type, void* data, StepArray step = StepArray()); + + /** @brief Allocates GPU memory. + Suppose there is some GPU memory already allocated. In that case, this method may choose to reuse that + GPU memory under the specific condition: it must be of the same size and type, not externally allocated, + the GPU memory is continuous(i.e., isContinuous() is true), and is not a sub-matrix of another GpuMatND + (i.e., isSubmatrix() is false). In other words, this method guarantees that the GPU memory allocated by + this method is always continuous and is not a sub-region of another GpuMatND. + */ + void create(SizeArray size, int type); + + void release(); + + void swap(GpuMatND& m) noexcept; + + /** @brief Creates a full copy of the array and the underlying data. + The method creates a full copy of the array. It mimics the behavior of Mat::clone(), i.e. + the original step is not taken into account. So, the array copy is a continuous array + occupying total()\*elemSize() bytes. + */ + GpuMatND clone() const; + + /** @overload + This overload is non-blocking, so it may return even if the copy operation is not finished. + */ + GpuMatND clone(Stream& stream) const; + + /** @brief Extracts a sub-matrix. + The operator makes a new header for the specified sub-array of \*this. + The operator is an O(1) operation, that is, no matrix data is copied. + @param ranges Array of selected ranges along each dimension. + */ + GpuMatND operator()(const std::vector& ranges) const; + + /** @brief Creates a GpuMat header for a 2D plane part of an n-dim matrix. + @note The returned GpuMat is constructed with the constructor for user-allocated data. + That is, It does not perform reference counting. + @note This function does not increment this GpuMatND's reference counter. + */ + GpuMat createGpuMatHeader(IndexArray idx, Range rowRange, Range colRange) const; + + /** @overload + Creates a GpuMat header if this GpuMatND is effectively 2D. + @note The returned GpuMat is constructed with the constructor for user-allocated data. + That is, It does not perform reference counting. + @note This function does not increment this GpuMatND's reference counter. + */ + GpuMat createGpuMatHeader() const; + + /** @brief Extracts a 2D plane part of an n-dim matrix. + It differs from createGpuMatHeader(IndexArray, Range, Range) in that it clones a part of this + GpuMatND to the returned GpuMat. + @note This operator does not increment this GpuMatND's reference counter; + */ + GpuMat operator()(IndexArray idx, Range rowRange, Range colRange) const; + + /** @brief Extracts a 2D plane part of an n-dim matrix if this GpuMatND is effectively 2D. + It differs from createGpuMatHeader() in that it clones a part of this GpuMatND. + @note This operator does not increment this GpuMatND's reference counter; + */ + operator GpuMat() const; + + GpuMatND(const GpuMatND&) = default; + GpuMatND& operator=(const GpuMatND&) = default; + +#if defined(__GNUC__) && __GNUC__ < 5 + // error: function '...' defaulted on its first declaration with an exception-specification + // that differs from the implicit declaration '...' + + GpuMatND(GpuMatND&&) = default; + GpuMatND& operator=(GpuMatND&&) = default; +#else + GpuMatND(GpuMatND&&) noexcept = default; + GpuMatND& operator=(GpuMatND&&) noexcept = default; +#endif + + void upload(InputArray src); + void upload(InputArray src, Stream& stream); + void download(OutputArray dst) const; + void download(OutputArray dst, Stream& stream) const; + + //! returns true iff the GpuMatND data is continuous + //! (i.e. when there are no gaps between successive rows) + bool isContinuous() const; + + //! returns true if the matrix is a sub-matrix of another matrix + bool isSubmatrix() const; + + //! returns element size in bytes + size_t elemSize() const; + + //! returns the size of element channel in bytes + size_t elemSize1() const; + + //! returns true if data is null + bool empty() const; + + //! returns true if not empty and points to external(user-allocated) gpu memory + bool external() const; + + //! returns pointer to the first byte of the GPU memory + uchar* getDevicePtr() const; + + //! returns the total number of array elements + size_t total() const; + + //! returns the size of underlying memory in bytes + size_t totalMemSize() const; + + //! returns element type + int type() const; + +private: + //! internal use + void setFields(SizeArray size, int type, StepArray step = StepArray()); + +public: + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + + //! matrix dimensionality + int dims; + + //! shape of this array + SizeArray size; + + /*! step values + Their semantics is identical to the semantics of step for Mat. + */ + StepArray step; + +private: + /*! internal use + If this GpuMatND holds external memory, this is empty. + */ + std::shared_ptr data_; + + /*! internal use + If this GpuMatND manages memory with reference counting, this value is + always equal to data_->data. If this GpuMatND holds external memory, + data_ is empty and data points to the external memory. + */ + uchar* data; + + /*! internal use + If this GpuMatND is a sub-matrix of a larger matrix, this value is the + difference of the first byte between the sub-matrix and the whole matrix. + */ + size_t offset; +}; + +/** @brief Creates a continuous matrix. + +@param rows Row count. +@param cols Column count. +@param type Type of the matrix. +@param arr Destination matrix. This parameter changes only if it has a proper type and area ( +\f$\texttt{rows} \times \texttt{cols}\f$ ). + +Matrix is called continuous if its elements are stored continuously, that is, without gaps at the +end of each row. + */ +CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr); + +/** @brief Ensures that the size of a matrix is big enough and the matrix has a proper type. + +@param rows Minimum desired number of rows. +@param cols Minimum desired number of columns. +@param type Desired matrix type. +@param arr Destination matrix. + +The function does not reallocate memory if the matrix has proper attributes already. + */ +CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr); + +/** @brief BufferPool for use with CUDA streams + +BufferPool utilizes Stream's allocator to create new buffers for GpuMat's. It is +only useful when enabled with #setBufferPoolUsage. + +@code + setBufferPoolUsage(true); +@endcode + +@note #setBufferPoolUsage must be called \em before any Stream declaration. + +Users may specify custom allocator for Stream and may implement their own stream based +functions utilizing the same underlying GPU memory management. + +If custom allocator is not specified, BufferPool utilizes StackAllocator by +default. StackAllocator allocates a chunk of GPU device memory beforehand, +and when GpuMat is declared later on, it is given the pre-allocated memory. +This kind of strategy reduces the number of calls for memory allocating APIs +such as cudaMalloc or cudaMallocPitch. + +Below is an example that utilizes BufferPool with StackAllocator: + +@code + #include + + using namespace cv; + using namespace cv::cuda + + int main() + { + setBufferPoolUsage(true); // Tell OpenCV that we are going to utilize BufferPool + setBufferPoolConfig(getDevice(), 1024 * 1024 * 64, 2); // Allocate 64 MB, 2 stacks (default is 10 MB, 5 stacks) + + Stream stream1, stream2; // Each stream uses 1 stack + BufferPool pool1(stream1), pool2(stream2); + + GpuMat d_src1 = pool1.getBuffer(4096, 4096, CV_8UC1); // 16MB + GpuMat d_dst1 = pool1.getBuffer(4096, 4096, CV_8UC3); // 48MB, pool1 is now full + + GpuMat d_src2 = pool2.getBuffer(1024, 1024, CV_8UC1); // 1MB + GpuMat d_dst2 = pool2.getBuffer(1024, 1024, CV_8UC3); // 3MB + + cvtColor(d_src1, d_dst1, CV_GRAY2BGR, 0, stream1); + cvtColor(d_src2, d_dst2, CV_GRAY2BGR, 0, stream2); + } +@endcode + +If we allocate another GpuMat on pool1 in the above example, it will be carried out by +the DefaultAllocator since the stack for pool1 is full. + +@code + GpuMat d_add1 = pool1.getBuffer(1024, 1024, CV_8UC1); // Stack for pool1 is full, memory is allocated with DefaultAllocator +@endcode + +If a third stream is declared in the above example, allocating with #getBuffer +within that stream will also be carried out by the DefaultAllocator because we've run out of +stacks. + +@code + Stream stream3; // Only 2 stacks were allocated, we've run out of stacks + BufferPool pool3(stream3); + GpuMat d_src3 = pool3.getBuffer(1024, 1024, CV_8UC1); // Memory is allocated with DefaultAllocator +@endcode + +@warning When utilizing StackAllocator, deallocation order is important. + +Just like a stack, deallocation must be done in LIFO order. Below is an example of +erroneous usage that violates LIFO rule. If OpenCV is compiled in Debug mode, this +sample code will emit CV_Assert error. + +@code + int main() + { + setBufferPoolUsage(true); // Tell OpenCV that we are going to utilize BufferPool + Stream stream; // A default size (10 MB) stack is allocated to this stream + BufferPool pool(stream); + + GpuMat mat1 = pool.getBuffer(1024, 1024, CV_8UC1); // Allocate mat1 (1MB) + GpuMat mat2 = pool.getBuffer(1024, 1024, CV_8UC1); // Allocate mat2 (1MB) + + mat1.release(); // erroneous usage : mat2 must be deallocated before mat1 + } +@endcode + +Since C++ local variables are destroyed in the reverse order of construction, +the code sample below satisfies the LIFO rule. Local GpuMat's are deallocated +and the corresponding memory is automatically returned to the pool for later usage. + +@code + int main() + { + setBufferPoolUsage(true); // Tell OpenCV that we are going to utilize BufferPool + setBufferPoolConfig(getDevice(), 1024 * 1024 * 64, 2); // Allocate 64 MB, 2 stacks (default is 10 MB, 5 stacks) + + Stream stream1, stream2; // Each stream uses 1 stack + BufferPool pool1(stream1), pool2(stream2); + + for (int i = 0; i < 10; i++) + { + GpuMat d_src1 = pool1.getBuffer(4096, 4096, CV_8UC1); // 16MB + GpuMat d_dst1 = pool1.getBuffer(4096, 4096, CV_8UC3); // 48MB, pool1 is now full + + GpuMat d_src2 = pool2.getBuffer(1024, 1024, CV_8UC1); // 1MB + GpuMat d_dst2 = pool2.getBuffer(1024, 1024, CV_8UC3); // 3MB + + d_src1.setTo(Scalar(i), stream1); + d_src2.setTo(Scalar(i), stream2); + + cvtColor(d_src1, d_dst1, CV_GRAY2BGR, 0, stream1); + cvtColor(d_src2, d_dst2, CV_GRAY2BGR, 0, stream2); + // The order of destruction of the local variables is: + // d_dst2 => d_src2 => d_dst1 => d_src1 + // LIFO rule is satisfied, this code runs without error + } + } +@endcode + */ +class CV_EXPORTS_W BufferPool +{ +public: + + //! Gets the BufferPool for the given stream. + explicit BufferPool(Stream& stream); + + //! Allocates a new GpuMat of given size and type. + CV_WRAP GpuMat getBuffer(int rows, int cols, int type); + + //! Allocates a new GpuMat of given size and type. + CV_WRAP GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); } + + //! Returns the allocator associated with the stream. + CV_WRAP Ptr getAllocator() const { return allocator_; } + +private: + Ptr allocator_; +}; + +//! BufferPool management (must be called before Stream creation) +CV_EXPORTS_W void setBufferPoolUsage(bool on); +CV_EXPORTS_W void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount); + +//=================================================================================== +// HostMem +//=================================================================================== + +/** @brief Class with reference counting wrapping special memory type allocation functions from CUDA. + +Its interface is also Mat-like but with additional memory type parameters. + +- **PAGE_LOCKED** sets a page locked memory type used commonly for fast and asynchronous + uploading/downloading data from/to GPU. +- **SHARED** specifies a zero copy memory allocation that enables mapping the host memory to GPU + address space, if supported. +- **WRITE_COMBINED** sets the write combined buffer that is not cached by CPU. Such buffers are + used to supply GPU with data when GPU only reads it. The advantage is a better CPU cache + utilization. + +@note Allocation size of such memory types is usually limited. For more details, see *CUDA 2.2 +Pinned Memory APIs* document or *CUDA C Programming Guide*. + */ +class CV_EXPORTS_W HostMem +{ +public: + enum AllocType { PAGE_LOCKED = 1, SHARED = 2, WRITE_COMBINED = 4 }; + + static MatAllocator* getAllocator(HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + CV_WRAP explicit HostMem(HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + HostMem(const HostMem& m); + + CV_WRAP HostMem(int rows, int cols, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + CV_WRAP HostMem(Size size, int type, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + //! creates from host memory with coping data + CV_WRAP explicit HostMem(InputArray arr, HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED); + + ~HostMem(); + + HostMem& operator =(const HostMem& m); + + //! swaps with other smart pointer + CV_WRAP void swap(HostMem& b); + + //! returns deep copy of the matrix, i.e. the data is copied + CV_WRAP HostMem clone() const; + + //! allocates new matrix data unless the matrix already has specified size and type. + CV_WRAP void create(int rows, int cols, int type); + void create(Size size, int type); + + //! creates alternative HostMem header for the same data, with different + //! number of channels and/or different number of rows + CV_WRAP HostMem reshape(int cn, int rows = 0) const; + + //! decrements reference counter and released memory if needed. + void release(); + + //! returns matrix header with disabled reference counting for HostMem data. + CV_WRAP Mat createMatHeader() const; + + /** @brief Maps CPU memory to GPU address space and creates the cuda::GpuMat header without reference counting + for it. + + This can be done only if memory was allocated with the SHARED flag and if it is supported by the + hardware. Laptops often share video and CPU memory, so address spaces can be mapped, which + eliminates an extra copy. + */ + GpuMat createGpuMatHeader() const; + + // Please see cv::Mat for descriptions + CV_WRAP bool isContinuous() const; + CV_WRAP size_t elemSize() const; + CV_WRAP size_t elemSize1() const; + CV_WRAP int type() const; + CV_WRAP int depth() const; + CV_WRAP int channels() const; + CV_WRAP size_t step1() const; + CV_WRAP Size size() const; + CV_WRAP bool empty() const; + + // Please see cv::Mat for descriptions + int flags; + int rows, cols; + CV_PROP size_t step; + + uchar* data; + int* refcount; + + uchar* datastart; + const uchar* dataend; + + AllocType alloc_type; +}; + +/** @brief Page-locks the memory of matrix and maps it for the device(s). + +@param m Input matrix. + */ +CV_EXPORTS_W void registerPageLocked(Mat& m); + +/** @brief Unmaps the memory of matrix and makes it pageable again. + +@param m Input matrix. + */ +CV_EXPORTS_W void unregisterPageLocked(Mat& m); + +//=================================================================================== +// Stream +//=================================================================================== + +/** @brief This class encapsulates a queue of asynchronous calls. + +@note Currently, you may face problems if an operation is enqueued twice with different data. Some +functions use the constant GPU memory, and next call may update the memory before the previous one +has been finished. But calling different operations asynchronously is safe because each operation +has its own constant buffer. Memory copy/upload/download/set operations to the buffers you hold are +also safe. + +@note The Stream class is not thread-safe. Please use different Stream objects for different CPU threads. + +@code +void thread1() +{ + cv::cuda::Stream stream1; + cv::cuda::func1(..., stream1); +} + +void thread2() +{ + cv::cuda::Stream stream2; + cv::cuda::func2(..., stream2); +} +@endcode + +@note By default all CUDA routines are launched in Stream::Null() object, if the stream is not specified by user. +In multi-threading environment the stream objects must be passed explicitly (see previous note). + */ +class CV_EXPORTS_W Stream +{ + typedef void (Stream::*bool_type)() const; + void this_type_does_not_support_comparisons() const {} + +public: + typedef void (*StreamCallback)(int status, void* userData); + + //! creates a new asynchronous stream + CV_WRAP Stream(); + + //! creates a new asynchronous stream with custom allocator + CV_WRAP Stream(const Ptr& allocator); + + /** @brief creates a new Stream using the cudaFlags argument to determine the behaviors of the stream + + @note The cudaFlags parameter is passed to the underlying api cudaStreamCreateWithFlags() and + supports the same parameter values. + @code + // creates an OpenCV cuda::Stream that manages an asynchronous, non-blocking, + // non-default CUDA stream + cv::cuda::Stream cvStream(cudaStreamNonBlocking); + @endcode + */ + CV_WRAP Stream(const size_t cudaFlags); + + /** @brief Returns true if the current stream queue is finished. Otherwise, it returns false. + */ + CV_WRAP bool queryIfComplete() const; + + /** @brief Blocks the current CPU thread until all operations in the stream are complete. + */ + CV_WRAP void waitForCompletion(); + + /** @brief Makes a compute stream wait on an event. + */ + CV_WRAP void waitEvent(const Event& event); + + /** @brief Adds a callback to be called on the host after all currently enqueued items in the stream have + completed. + + @note Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization + that may depend on outstanding device work or other callbacks that are not mandated to run earlier. + Callbacks without a mandated order (in independent streams) execute in undefined order and may be + serialized. + */ + void enqueueHostCallback(StreamCallback callback, void* userData); + + //! return Stream object for default CUDA stream + CV_WRAP static Stream& Null(); + + //! returns true if stream object is not default (!= 0) + operator bool_type() const; + + //! return Pointer to CUDA stream + CV_WRAP void* cudaPtr() const; + + class Impl; + +private: + Ptr impl_; + Stream(const Ptr& impl); + + friend struct StreamAccessor; + friend class BufferPool; + friend class DefaultDeviceInitializer; +}; + +class CV_EXPORTS_W Event +{ +public: + enum CreateFlags + { + DEFAULT = 0x00, /**< Default event flag */ + BLOCKING_SYNC = 0x01, /**< Event uses blocking synchronization */ + DISABLE_TIMING = 0x02, /**< Event will not record timing data */ + INTERPROCESS = 0x04 /**< Event is suitable for interprocess use. DisableTiming must be set */ + }; + + CV_WRAP explicit Event(Event::CreateFlags flags = Event::CreateFlags::DEFAULT); + + //! records an event + CV_WRAP void record(Stream& stream = Stream::Null()); + + //! queries an event's status + CV_WRAP bool queryIfComplete() const; + + //! waits for an event to complete + CV_WRAP void waitForCompletion(); + + //! computes the elapsed time between events + CV_WRAP static float elapsedTime(const Event& start, const Event& end); + + class Impl; + +private: + Ptr impl_; + Event(const Ptr& impl); + + friend struct EventAccessor; +}; + +//! @} cudacore_struct + +//=================================================================================== +// Initialization & Info +//=================================================================================== + +//! @addtogroup cudacore_init +//! @{ + +/** @brief Returns the number of installed CUDA-enabled devices. + +Use this function before any other CUDA functions calls. If OpenCV is compiled without CUDA support, +this function returns 0. If the CUDA driver is not installed, or is incompatible, this function +returns -1. + */ +CV_EXPORTS_W int getCudaEnabledDeviceCount(); + +/** @brief Sets a device and initializes it for the current thread. + +@param device System index of a CUDA device starting with 0. + +If the call of this function is omitted, a default device is initialized at the fist CUDA usage. + */ +CV_EXPORTS_W void setDevice(int device); + +/** @brief Returns the current device index set by cuda::setDevice or initialized by default. + */ +CV_EXPORTS_W int getDevice(); + +/** @brief Explicitly destroys and cleans up all resources associated with the current device in the current +process. + +Any subsequent API call to this device will reinitialize the device. + */ +CV_EXPORTS_W void resetDevice(); + +/** @brief Enumeration providing CUDA computing features. + */ +enum FeatureSet +{ + FEATURE_SET_COMPUTE_10 = 10, + FEATURE_SET_COMPUTE_11 = 11, + FEATURE_SET_COMPUTE_12 = 12, + FEATURE_SET_COMPUTE_13 = 13, + FEATURE_SET_COMPUTE_20 = 20, + FEATURE_SET_COMPUTE_21 = 21, + FEATURE_SET_COMPUTE_30 = 30, + FEATURE_SET_COMPUTE_32 = 32, + FEATURE_SET_COMPUTE_35 = 35, + FEATURE_SET_COMPUTE_50 = 50, + + GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11, + SHARED_ATOMICS = FEATURE_SET_COMPUTE_12, + NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13, + WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30, + DYNAMIC_PARALLELISM = FEATURE_SET_COMPUTE_35 +}; + +//! checks whether current device supports the given feature +CV_EXPORTS bool deviceSupports(FeatureSet feature_set); + +/** @brief Class providing a set of static methods to check what NVIDIA\* card architecture the CUDA module was +built for. + +According to the CUDA C Programming Guide Version 3.2: "PTX code produced for some specific compute +capability can always be compiled to binary code of greater or equal compute capability". + */ +class CV_EXPORTS_W TargetArchs +{ +public: + /** @brief The following method checks whether the module was built with the support of the given feature: + + @param feature_set Features to be checked. See :ocvcuda::FeatureSet. + */ + static bool builtWith(FeatureSet feature_set); + + /** @brief There is a set of methods to check whether the module contains intermediate (PTX) or binary CUDA + code for the given architecture(s): + + @param major Major compute capability version. + @param minor Minor compute capability version. + */ + CV_WRAP static bool has(int major, int minor); + CV_WRAP static bool hasPtx(int major, int minor); + CV_WRAP static bool hasBin(int major, int minor); + + CV_WRAP static bool hasEqualOrLessPtx(int major, int minor); + CV_WRAP static bool hasEqualOrGreater(int major, int minor); + CV_WRAP static bool hasEqualOrGreaterPtx(int major, int minor); + CV_WRAP static bool hasEqualOrGreaterBin(int major, int minor); +}; + +/** @brief Class providing functionality for querying the specified GPU properties. + */ +class CV_EXPORTS_W DeviceInfo +{ +public: + //! creates DeviceInfo object for the current GPU + CV_WRAP DeviceInfo(); + + /** @brief The constructors. + + @param device_id System index of the CUDA device starting with 0. + + Constructs the DeviceInfo object for the specified device. If device_id parameter is missed, it + constructs an object for the current device. + */ + CV_WRAP DeviceInfo(int device_id); + + /** @brief Returns system index of the CUDA device starting with 0. + */ + CV_WRAP int deviceID() const; + + //! ASCII string identifying device + const char* name() const; + + //! global memory available on device in bytes + CV_WRAP size_t totalGlobalMem() const; + + //! shared memory available per block in bytes + CV_WRAP size_t sharedMemPerBlock() const; + + //! 32-bit registers available per block + CV_WRAP int regsPerBlock() const; + + //! warp size in threads + CV_WRAP int warpSize() const; + + //! maximum pitch in bytes allowed by memory copies + CV_WRAP size_t memPitch() const; + + //! maximum number of threads per block + CV_WRAP int maxThreadsPerBlock() const; + + //! maximum size of each dimension of a block + CV_WRAP Vec3i maxThreadsDim() const; + + //! maximum size of each dimension of a grid + CV_WRAP Vec3i maxGridSize() const; + + //! clock frequency in kilohertz + CV_WRAP int clockRate() const; + + //! constant memory available on device in bytes + CV_WRAP size_t totalConstMem() const; + + //! major compute capability + CV_WRAP int majorVersion() const; + + //! minor compute capability + CV_WRAP int minorVersion() const; + + //! alignment requirement for textures + CV_WRAP size_t textureAlignment() const; + + //! pitch alignment requirement for texture references bound to pitched memory + CV_WRAP size_t texturePitchAlignment() const; + + //! number of multiprocessors on device + CV_WRAP int multiProcessorCount() const; + + //! specified whether there is a run time limit on kernels + CV_WRAP bool kernelExecTimeoutEnabled() const; + + //! device is integrated as opposed to discrete + CV_WRAP bool integrated() const; + + //! device can map host memory with cudaHostAlloc/cudaHostGetDevicePointer + CV_WRAP bool canMapHostMemory() const; + + enum ComputeMode + { + ComputeModeDefault, /**< default compute mode (Multiple threads can use cudaSetDevice with this device) */ + ComputeModeExclusive, /**< compute-exclusive-thread mode (Only one thread in one process will be able to use cudaSetDevice with this device) */ + ComputeModeProhibited, /**< compute-prohibited mode (No threads can use cudaSetDevice with this device) */ + ComputeModeExclusiveProcess /**< compute-exclusive-process mode (Many threads in one process will be able to use cudaSetDevice with this device) */ + }; + + //! compute mode + CV_WRAP DeviceInfo::ComputeMode computeMode() const; + + //! maximum 1D texture size + CV_WRAP int maxTexture1D() const; + + //! maximum 1D mipmapped texture size + CV_WRAP int maxTexture1DMipmap() const; + + //! maximum size for 1D textures bound to linear memory + CV_WRAP int maxTexture1DLinear() const; + + //! maximum 2D texture dimensions + CV_WRAP Vec2i maxTexture2D() const; + + //! maximum 2D mipmapped texture dimensions + CV_WRAP Vec2i maxTexture2DMipmap() const; + + //! maximum dimensions (width, height, pitch) for 2D textures bound to pitched memory + CV_WRAP Vec3i maxTexture2DLinear() const; + + //! maximum 2D texture dimensions if texture gather operations have to be performed + CV_WRAP Vec2i maxTexture2DGather() const; + + //! maximum 3D texture dimensions + CV_WRAP Vec3i maxTexture3D() const; + + //! maximum Cubemap texture dimensions + CV_WRAP int maxTextureCubemap() const; + + //! maximum 1D layered texture dimensions + CV_WRAP Vec2i maxTexture1DLayered() const; + + //! maximum 2D layered texture dimensions + CV_WRAP Vec3i maxTexture2DLayered() const; + + //! maximum Cubemap layered texture dimensions + CV_WRAP Vec2i maxTextureCubemapLayered() const; + + //! maximum 1D surface size + CV_WRAP int maxSurface1D() const; + + //! maximum 2D surface dimensions + CV_WRAP Vec2i maxSurface2D() const; + + //! maximum 3D surface dimensions + CV_WRAP Vec3i maxSurface3D() const; + + //! maximum 1D layered surface dimensions + CV_WRAP Vec2i maxSurface1DLayered() const; + + //! maximum 2D layered surface dimensions + CV_WRAP Vec3i maxSurface2DLayered() const; + + //! maximum Cubemap surface dimensions + CV_WRAP int maxSurfaceCubemap() const; + + //! maximum Cubemap layered surface dimensions + CV_WRAP Vec2i maxSurfaceCubemapLayered() const; + + //! alignment requirements for surfaces + CV_WRAP size_t surfaceAlignment() const; + + //! device can possibly execute multiple kernels concurrently + CV_WRAP bool concurrentKernels() const; + + //! device has ECC support enabled + CV_WRAP bool ECCEnabled() const; + + //! PCI bus ID of the device + CV_WRAP int pciBusID() const; + + //! PCI device ID of the device + CV_WRAP int pciDeviceID() const; + + //! PCI domain ID of the device + CV_WRAP int pciDomainID() const; + + //! true if device is a Tesla device using TCC driver, false otherwise + CV_WRAP bool tccDriver() const; + + //! number of asynchronous engines + CV_WRAP int asyncEngineCount() const; + + //! device shares a unified address space with the host + CV_WRAP bool unifiedAddressing() const; + + //! peak memory clock frequency in kilohertz + CV_WRAP int memoryClockRate() const; + + //! global memory bus width in bits + CV_WRAP int memoryBusWidth() const; + + //! size of L2 cache in bytes + CV_WRAP int l2CacheSize() const; + + //! maximum resident threads per multiprocessor + CV_WRAP int maxThreadsPerMultiProcessor() const; + + //! gets free and total device memory + CV_WRAP void queryMemory(size_t& totalMemory, size_t& freeMemory) const; + CV_WRAP size_t freeMemory() const; + CV_WRAP size_t totalMemory() const; + + /** @brief Provides information on CUDA feature support. + + @param feature_set Features to be checked. See cuda::FeatureSet. + + This function returns true if the device has the specified CUDA feature. Otherwise, it returns false + */ + bool supports(FeatureSet feature_set) const; + + /** @brief Checks the CUDA module and device compatibility. + + This function returns true if the CUDA module can be run on the specified device. Otherwise, it + returns false . + */ + CV_WRAP bool isCompatible() const; + +private: + int device_id_; +}; + +CV_EXPORTS_W void printCudaDeviceInfo(int device); +CV_EXPORTS_W void printShortCudaDeviceInfo(int device); + +/** @brief Converts an array to half precision floating number. + +@param _src input array. +@param _dst output array. +@param stream Stream for the asynchronous version. +@sa convertFp16 +*/ +CV_EXPORTS void convertFp16(InputArray _src, OutputArray _dst, Stream& stream = Stream::Null()); + +//! @} cudacore_init + +}} // namespace cv { namespace cuda { + + +#include "opencv2/core/cuda.inl.hpp" + +#endif /* OPENCV_CORE_CUDA_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda.inl.hpp new file mode 100644 index 0000000..3f2a0c7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda.inl.hpp @@ -0,0 +1,723 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDAINL_HPP +#define OPENCV_CORE_CUDAINL_HPP + +#include "opencv2/core/cuda.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { + +//=================================================================================== +// GpuMat +//=================================================================================== + +inline +GpuMat::GpuMat(Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{} + +inline +GpuMat::GpuMat(int rows_, int cols_, int type_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (rows_ > 0 && cols_ > 0) + create(rows_, cols_, type_); +} + +inline +GpuMat::GpuMat(Size size_, int type_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (size_.height > 0 && size_.width > 0) + create(size_.height, size_.width, type_); +} + +inline +GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (rows_ > 0 && cols_ > 0) + { + create(rows_, cols_, type_); + setTo(s_); + } +} + +inline +GpuMat::GpuMat(Size size_, int type_, Scalar s_, Allocator* allocator_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + if (size_.height > 0 && size_.width > 0) + { + create(size_.height, size_.width, type_); + setTo(s_); + } +} + +inline +GpuMat::GpuMat(const GpuMat& m) + : flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), allocator(m.allocator) +{ + if (refcount) + CV_XADD(refcount, 1); +} + +inline +GpuMat::GpuMat(InputArray arr, Allocator* allocator_) : + flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_) +{ + upload(arr); +} + +inline +GpuMat::~GpuMat() +{ + release(); +} + +inline +GpuMat& GpuMat::operator =(const GpuMat& m) +{ + if (this != &m) + { + GpuMat temp(m); + swap(temp); + } + + return *this; +} + +inline +void GpuMat::create(Size size_, int type_) +{ + create(size_.height, size_.width, type_); +} + +inline +void GpuMat::swap(GpuMat& b) +{ + std::swap(flags, b.flags); + std::swap(rows, b.rows); + std::swap(cols, b.cols); + std::swap(step, b.step); + std::swap(data, b.data); + std::swap(datastart, b.datastart); + std::swap(dataend, b.dataend); + std::swap(refcount, b.refcount); + std::swap(allocator, b.allocator); +} + +inline +GpuMat GpuMat::clone() const +{ + GpuMat m; + copyTo(m); + return m; +} + +inline +void GpuMat::copyTo(OutputArray dst, InputArray mask) const +{ + copyTo(dst, mask, Stream::Null()); +} + +inline +GpuMat& GpuMat::setTo(Scalar s) +{ + return setTo(s, Stream::Null()); +} + +inline +GpuMat& GpuMat::setTo(Scalar s, InputArray mask) +{ + return setTo(s, mask, Stream::Null()); +} + +inline +void GpuMat::convertTo(OutputArray dst, int rtype) const +{ + convertTo(dst, rtype, Stream::Null()); +} + +inline +void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, double beta) const +{ + convertTo(dst, rtype, alpha, beta, Stream::Null()); +} + +inline +void GpuMat::convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const +{ + convertTo(dst, rtype, alpha, 0.0, stream); +} + +inline +void GpuMat::assignTo(GpuMat& m, int _type) const +{ + if (_type < 0) + m = *this; + else + convertTo(m, _type); +} + +inline +uchar* GpuMat::ptr(int y) +{ + CV_DbgAssert( (unsigned)y < (unsigned)rows ); + return data + step * y; +} + +inline +const uchar* GpuMat::ptr(int y) const +{ + CV_DbgAssert( (unsigned)y < (unsigned)rows ); + return data + step * y; +} + +template inline +_Tp* GpuMat::ptr(int y) +{ + return (_Tp*)ptr(y); +} + +template inline +const _Tp* GpuMat::ptr(int y) const +{ + return (const _Tp*)ptr(y); +} + +template inline +GpuMat::operator PtrStepSz() const +{ + return PtrStepSz(rows, cols, (T*)data, step); +} + +template inline +GpuMat::operator PtrStep() const +{ + return PtrStep((T*)data, step); +} + +inline +GpuMat GpuMat::row(int y) const +{ + return GpuMat(*this, Range(y, y+1), Range::all()); +} + +inline +GpuMat GpuMat::col(int x) const +{ + return GpuMat(*this, Range::all(), Range(x, x+1)); +} + +inline +GpuMat GpuMat::rowRange(int startrow, int endrow) const +{ + return GpuMat(*this, Range(startrow, endrow), Range::all()); +} + +inline +GpuMat GpuMat::rowRange(Range r) const +{ + return GpuMat(*this, r, Range::all()); +} + +inline +GpuMat GpuMat::colRange(int startcol, int endcol) const +{ + return GpuMat(*this, Range::all(), Range(startcol, endcol)); +} + +inline +GpuMat GpuMat::colRange(Range r) const +{ + return GpuMat(*this, Range::all(), r); +} + +inline +GpuMat GpuMat::operator ()(Range rowRange_, Range colRange_) const +{ + return GpuMat(*this, rowRange_, colRange_); +} + +inline +GpuMat GpuMat::operator ()(Rect roi) const +{ + return GpuMat(*this, roi); +} + +inline +bool GpuMat::isContinuous() const +{ + return (flags & Mat::CONTINUOUS_FLAG) != 0; +} + +inline +size_t GpuMat::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t GpuMat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int GpuMat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int GpuMat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int GpuMat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +size_t GpuMat::step1() const +{ + return step / elemSize1(); +} + +inline +Size GpuMat::size() const +{ + return Size(cols, rows); +} + +inline +bool GpuMat::empty() const +{ + return data == 0; +} + +inline +void* GpuMat::cudaPtr() const +{ + return data; +} + +static inline +GpuMat createContinuous(int rows, int cols, int type) +{ + GpuMat m; + createContinuous(rows, cols, type, m); + return m; +} + +static inline +void createContinuous(Size size, int type, OutputArray arr) +{ + createContinuous(size.height, size.width, type, arr); +} + +static inline +GpuMat createContinuous(Size size, int type) +{ + GpuMat m; + createContinuous(size, type, m); + return m; +} + +static inline +void ensureSizeIsEnough(Size size, int type, OutputArray arr) +{ + ensureSizeIsEnough(size.height, size.width, type, arr); +} + +static inline +void swap(GpuMat& a, GpuMat& b) +{ + a.swap(b); +} + +//=================================================================================== +// GpuMatND +//=================================================================================== + +inline +GpuMatND::GpuMatND() : + flags(0), dims(0), data(nullptr), offset(0) +{ +} + +inline +GpuMatND::GpuMatND(SizeArray _size, int _type) : + flags(0), dims(0), data(nullptr), offset(0) +{ + create(std::move(_size), _type); +} + +inline +void GpuMatND::swap(GpuMatND& m) noexcept +{ + std::swap(*this, m); +} + +inline +bool GpuMatND::isContinuous() const +{ + return (flags & Mat::CONTINUOUS_FLAG) != 0; +} + +inline +bool GpuMatND::isSubmatrix() const +{ + return (flags & Mat::SUBMATRIX_FLAG) != 0; +} + +inline +size_t GpuMatND::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t GpuMatND::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +bool GpuMatND::empty() const +{ + return data == nullptr; +} + +inline +bool GpuMatND::external() const +{ + return !empty() && data_.use_count() == 0; +} + +inline +uchar* GpuMatND::getDevicePtr() const +{ + return data + offset; +} + +inline +size_t GpuMatND::total() const +{ + size_t p = 1; + for(auto s : size) + p *= s; + return p; +} + +inline +size_t GpuMatND::totalMemSize() const +{ + return size[0] * step[0]; +} + +inline +int GpuMatND::type() const +{ + return CV_MAT_TYPE(flags); +} + +//=================================================================================== +// HostMem +//=================================================================================== + +inline +HostMem::HostMem(AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ +} + +inline +HostMem::HostMem(const HostMem& m) + : flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), alloc_type(m.alloc_type) +{ + if( refcount ) + CV_XADD(refcount, 1); +} + +inline +HostMem::HostMem(int rows_, int cols_, int type_, AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ + if (rows_ > 0 && cols_ > 0) + create(rows_, cols_, type_); +} + +inline +HostMem::HostMem(Size size_, int type_, AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ + if (size_.height > 0 && size_.width > 0) + create(size_.height, size_.width, type_); +} + +inline +HostMem::HostMem(InputArray arr, AllocType alloc_type_) + : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_) +{ + arr.getMat().copyTo(*this); +} + +inline +HostMem::~HostMem() +{ + release(); +} + +inline +HostMem& HostMem::operator =(const HostMem& m) +{ + if (this != &m) + { + HostMem temp(m); + swap(temp); + } + + return *this; +} + +inline +void HostMem::swap(HostMem& b) +{ + std::swap(flags, b.flags); + std::swap(rows, b.rows); + std::swap(cols, b.cols); + std::swap(step, b.step); + std::swap(data, b.data); + std::swap(datastart, b.datastart); + std::swap(dataend, b.dataend); + std::swap(refcount, b.refcount); + std::swap(alloc_type, b.alloc_type); +} + +inline +HostMem HostMem::clone() const +{ + HostMem m(size(), type(), alloc_type); + createMatHeader().copyTo(m); + return m; +} + +inline +void HostMem::create(Size size_, int type_) +{ + create(size_.height, size_.width, type_); +} + +inline +Mat HostMem::createMatHeader() const +{ + return Mat(size(), type(), data, step); +} + +inline +bool HostMem::isContinuous() const +{ + return (flags & Mat::CONTINUOUS_FLAG) != 0; +} + +inline +size_t HostMem::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t HostMem::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int HostMem::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int HostMem::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int HostMem::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +size_t HostMem::step1() const +{ + return step / elemSize1(); +} + +inline +Size HostMem::size() const +{ + return Size(cols, rows); +} + +inline +bool HostMem::empty() const +{ + return data == 0; +} + +static inline +void swap(HostMem& a, HostMem& b) +{ + a.swap(b); +} + +//=================================================================================== +// Stream +//=================================================================================== + +inline +Stream::Stream(const Ptr& impl) + : impl_(impl) +{ +} + +//=================================================================================== +// Event +//=================================================================================== + +inline +Event::Event(const Ptr& impl) + : impl_(impl) +{ +} + +//=================================================================================== +// Initialization & Info +//=================================================================================== + +inline +bool TargetArchs::has(int major, int minor) +{ + return hasPtx(major, minor) || hasBin(major, minor); +} + +inline +bool TargetArchs::hasEqualOrGreater(int major, int minor) +{ + return hasEqualOrGreaterPtx(major, minor) || hasEqualOrGreaterBin(major, minor); +} + +inline +DeviceInfo::DeviceInfo() +{ + device_id_ = getDevice(); +} + +inline +DeviceInfo::DeviceInfo(int device_id) +{ + CV_Assert( device_id >= 0 && device_id < getCudaEnabledDeviceCount() ); + device_id_ = device_id; +} + +inline +int DeviceInfo::deviceID() const +{ + return device_id_; +} + +inline +size_t DeviceInfo::freeMemory() const +{ + size_t _totalMemory = 0, _freeMemory = 0; + queryMemory(_totalMemory, _freeMemory); + return _freeMemory; +} + +inline +size_t DeviceInfo::totalMemory() const +{ + size_t _totalMemory = 0, _freeMemory = 0; + queryMemory(_totalMemory, _freeMemory); + return _totalMemory; +} + +inline +bool DeviceInfo::supports(FeatureSet feature_set) const +{ + int version = majorVersion() * 10 + minorVersion(); + return version >= feature_set; +} + + +}} // namespace cv { namespace cuda { + +//=================================================================================== +// Mat +//=================================================================================== + +namespace cv { + +inline +Mat::Mat(const cuda::GpuMat& m) + : flags(0), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows) +{ + m.download(*this); +} + +} + +//! @endcond + +#endif // OPENCV_CORE_CUDAINL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/block.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/block.hpp new file mode 100644 index 0000000..c277f0e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/block.hpp @@ -0,0 +1,211 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DEVICE_BLOCK_HPP +#define OPENCV_CUDA_DEVICE_BLOCK_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct Block + { + static __device__ __forceinline__ unsigned int id() + { + return blockIdx.x; + } + + static __device__ __forceinline__ unsigned int stride() + { + return blockDim.x * blockDim.y * blockDim.z; + } + + static __device__ __forceinline__ void sync() + { + __syncthreads(); + } + + static __device__ __forceinline__ int flattenedThreadId() + { + return threadIdx.z * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x; + } + + template + static __device__ __forceinline__ void fill(It beg, It end, const T& value) + { + int STRIDE = stride(); + It t = beg + flattenedThreadId(); + + for(; t < end; t += STRIDE) + *t = value; + } + + template + static __device__ __forceinline__ void yota(OutIt beg, OutIt end, T value) + { + int STRIDE = stride(); + int tid = flattenedThreadId(); + value += tid; + + for(OutIt t = beg + tid; t < end; t += STRIDE, value += STRIDE) + *t = value; + } + + template + static __device__ __forceinline__ void copy(InIt beg, InIt end, OutIt out) + { + int STRIDE = stride(); + InIt t = beg + flattenedThreadId(); + OutIt o = out + (t - beg); + + for(; t < end; t += STRIDE, o += STRIDE) + *o = *t; + } + + template + static __device__ __forceinline__ void transform(InIt beg, InIt end, OutIt out, UnOp op) + { + int STRIDE = stride(); + InIt t = beg + flattenedThreadId(); + OutIt o = out + (t - beg); + + for(; t < end; t += STRIDE, o += STRIDE) + *o = op(*t); + } + + template + static __device__ __forceinline__ void transform(InIt1 beg1, InIt1 end1, InIt2 beg2, OutIt out, BinOp op) + { + int STRIDE = stride(); + InIt1 t1 = beg1 + flattenedThreadId(); + InIt2 t2 = beg2 + flattenedThreadId(); + OutIt o = out + (t1 - beg1); + + for(; t1 < end1; t1 += STRIDE, t2 += STRIDE, o += STRIDE) + *o = op(*t1, *t2); + } + + template + static __device__ __forceinline__ void reduce(volatile T* buffer, BinOp op) + { + int tid = flattenedThreadId(); + T val = buffer[tid]; + + if (CTA_SIZE >= 1024) { if (tid < 512) buffer[tid] = val = op(val, buffer[tid + 512]); __syncthreads(); } + if (CTA_SIZE >= 512) { if (tid < 256) buffer[tid] = val = op(val, buffer[tid + 256]); __syncthreads(); } + if (CTA_SIZE >= 256) { if (tid < 128) buffer[tid] = val = op(val, buffer[tid + 128]); __syncthreads(); } + if (CTA_SIZE >= 128) { if (tid < 64) buffer[tid] = val = op(val, buffer[tid + 64]); __syncthreads(); } + + if (tid < 32) + { + if (CTA_SIZE >= 64) { buffer[tid] = val = op(val, buffer[tid + 32]); } + if (CTA_SIZE >= 32) { buffer[tid] = val = op(val, buffer[tid + 16]); } + if (CTA_SIZE >= 16) { buffer[tid] = val = op(val, buffer[tid + 8]); } + if (CTA_SIZE >= 8) { buffer[tid] = val = op(val, buffer[tid + 4]); } + if (CTA_SIZE >= 4) { buffer[tid] = val = op(val, buffer[tid + 2]); } + if (CTA_SIZE >= 2) { buffer[tid] = val = op(val, buffer[tid + 1]); } + } + } + + template + static __device__ __forceinline__ T reduce(volatile T* buffer, T init, BinOp op) + { + int tid = flattenedThreadId(); + T val = buffer[tid] = init; + __syncthreads(); + + if (CTA_SIZE >= 1024) { if (tid < 512) buffer[tid] = val = op(val, buffer[tid + 512]); __syncthreads(); } + if (CTA_SIZE >= 512) { if (tid < 256) buffer[tid] = val = op(val, buffer[tid + 256]); __syncthreads(); } + if (CTA_SIZE >= 256) { if (tid < 128) buffer[tid] = val = op(val, buffer[tid + 128]); __syncthreads(); } + if (CTA_SIZE >= 128) { if (tid < 64) buffer[tid] = val = op(val, buffer[tid + 64]); __syncthreads(); } + + if (tid < 32) + { + if (CTA_SIZE >= 64) { buffer[tid] = val = op(val, buffer[tid + 32]); } + if (CTA_SIZE >= 32) { buffer[tid] = val = op(val, buffer[tid + 16]); } + if (CTA_SIZE >= 16) { buffer[tid] = val = op(val, buffer[tid + 8]); } + if (CTA_SIZE >= 8) { buffer[tid] = val = op(val, buffer[tid + 4]); } + if (CTA_SIZE >= 4) { buffer[tid] = val = op(val, buffer[tid + 2]); } + if (CTA_SIZE >= 2) { buffer[tid] = val = op(val, buffer[tid + 1]); } + } + __syncthreads(); + return buffer[0]; + } + + template + static __device__ __forceinline__ void reduce_n(T* data, unsigned int n, BinOp op) + { + int ftid = flattenedThreadId(); + int sft = stride(); + + if (sft < n) + { + for (unsigned int i = sft + ftid; i < n; i += sft) + data[ftid] = op(data[ftid], data[i]); + + __syncthreads(); + + n = sft; + } + + while (n > 1) + { + unsigned int half = n/2; + + if (ftid < half) + data[ftid] = op(data[ftid], data[n - ftid - 1]); + + __syncthreads(); + + n = n - half; + } + } + }; +}}} + +//! @endcond + +#endif /* OPENCV_CUDA_DEVICE_BLOCK_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/border_interpolate.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/border_interpolate.hpp new file mode 100644 index 0000000..874f705 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/border_interpolate.hpp @@ -0,0 +1,722 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_BORDER_INTERPOLATE_HPP +#define OPENCV_CUDA_BORDER_INTERPOLATE_HPP + +#include "saturate_cast.hpp" +#include "vec_traits.hpp" +#include "vec_math.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + ////////////////////////////////////////////////////////////// + // BrdConstant + + template struct BrdRowConstant + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowConstant(int width_, const D& val_ = VecTraits::all(0)) : width(width_), val(val_) {} + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return x >= 0 ? saturate_cast(data[x]) : val; + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return x < width ? saturate_cast(data[x]) : val; + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return (x >= 0 && x < width) ? saturate_cast(data[x]) : val; + } + + int width; + D val; + }; + + template struct BrdColConstant + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColConstant(int height_, const D& val_ = VecTraits::all(0)) : height(height_), val(val_) {} + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return y >= 0 ? saturate_cast(*(const T*)((const char*)data + y * step)) : val; + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return y < height ? saturate_cast(*(const T*)((const char*)data + y * step)) : val; + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return (y >= 0 && y < height) ? saturate_cast(*(const T*)((const char*)data + y * step)) : val; + } + + int height; + D val; + }; + + template struct BrdConstant + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdConstant(int height_, int width_, const D& val_ = VecTraits::all(0)) : height(height_), width(width_), val(val_) + { + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast(((const T*)((const uchar*)data + y * step))[x]) : val; + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast(src(y, x)) : val; + } + + int height; + int width; + D val; + }; + + ////////////////////////////////////////////////////////////// + // BrdReplicate + + template struct BrdRowReplicate + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowReplicate(int width) : last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdRowReplicate(int width, U) : last_col(width - 1) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::max(x, 0); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::min(x, last_col); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int last_col; + }; + + template struct BrdColReplicate + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColReplicate(int height) : last_row(height - 1) {} + template __host__ __device__ __forceinline__ BrdColReplicate(int height, U) : last_row(height - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::max(y, 0); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::min(y, last_row); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const T*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const T*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const T*)((const char*)data + idx_row(y) * step)); + } + + int last_row; + }; + + template struct BrdReplicate + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdReplicate(int height, int width) : last_row(height - 1), last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdReplicate(int height, int width, U) : last_row(height - 1), last_col(width - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::max(y, 0); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::min(y, last_row); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::max(x, 0); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::min(x, last_col); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int last_row; + int last_col; + }; + + ////////////////////////////////////////////////////////////// + // BrdReflect101 + + template struct BrdRowReflect101 + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowReflect101(int width) : last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdRowReflect101(int width, U) : last_col(width - 1) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::abs(x) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::abs(last_col - ::abs(last_col - x)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int last_col; + }; + + template struct BrdColReflect101 + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColReflect101(int height) : last_row(height - 1) {} + template __host__ __device__ __forceinline__ BrdColReflect101(int height, U) : last_row(height - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::abs(y) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::abs(last_row - ::abs(last_row - y)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row(y) * step)); + } + + int last_row; + }; + + template struct BrdReflect101 + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdReflect101(int height, int width) : last_row(height - 1), last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdReflect101(int height, int width, U) : last_row(height - 1), last_col(width - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return ::abs(y) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::abs(last_row - ::abs(last_row - y)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return ::abs(x) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::abs(last_col - ::abs(last_col - x)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int last_row; + int last_col; + }; + + ////////////////////////////////////////////////////////////// + // BrdReflect + + template struct BrdRowReflect + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowReflect(int width) : last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdRowReflect(int width, U) : last_col(width - 1) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (::abs(x) - (x < 0)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return ::abs(last_col - ::abs(last_col - x) + (x > last_col)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_high(::abs(x) - (x < 0)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int last_col; + }; + + template struct BrdColReflect + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColReflect(int height) : last_row(height - 1) {} + template __host__ __device__ __forceinline__ BrdColReflect(int height, U) : last_row(height - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (::abs(y) - (y < 0)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return ::abs(last_row - ::abs(last_row - y) + (y > last_row)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_high(::abs(y) - (y < 0)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row(y) * step)); + } + + int last_row; + }; + + template struct BrdReflect + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdReflect(int height, int width) : last_row(height - 1), last_col(width - 1) {} + template __host__ __device__ __forceinline__ BrdReflect(int height, int width, U) : last_row(height - 1), last_col(width - 1) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (::abs(y) - (y < 0)) % (last_row + 1); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return /*::abs*/(last_row - ::abs(last_row - y) + (y > last_row)) /*% (last_row + 1)*/; + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_low(idx_row_high(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (::abs(x) - (x < 0)) % (last_col + 1); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return (last_col - ::abs(last_col - x) + (x > last_col)); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_low(idx_col_high(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int last_row; + int last_col; + }; + + ////////////////////////////////////////////////////////////// + // BrdWrap + + template struct BrdRowWrap + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdRowWrap(int width_) : width(width_) {} + template __host__ __device__ __forceinline__ BrdRowWrap(int width_, U) : width(width_) {} + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (x >= 0) * x + (x < 0) * (x - ((x - width + 1) / width) * width); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return (x < width) * x + (x >= width) * (x % width); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_high(idx_col_low(x)); + } + + template __device__ __forceinline__ D at_low(int x, const T* data) const + { + return saturate_cast(data[idx_col_low(x)]); + } + + template __device__ __forceinline__ D at_high(int x, const T* data) const + { + return saturate_cast(data[idx_col_high(x)]); + } + + template __device__ __forceinline__ D at(int x, const T* data) const + { + return saturate_cast(data[idx_col(x)]); + } + + int width; + }; + + template struct BrdColWrap + { + typedef D result_type; + + explicit __host__ __device__ __forceinline__ BrdColWrap(int height_) : height(height_) {} + template __host__ __device__ __forceinline__ BrdColWrap(int height_, U) : height(height_) {} + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (y >= 0) * y + (y < 0) * (y - ((y - height + 1) / height) * height); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return (y < height) * y + (y >= height) * (y % height); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_high(idx_row_low(y)); + } + + template __device__ __forceinline__ D at_low(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_low(y) * step)); + } + + template __device__ __forceinline__ D at_high(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row_high(y) * step)); + } + + template __device__ __forceinline__ D at(int y, const T* data, size_t step) const + { + return saturate_cast(*(const D*)((const char*)data + idx_row(y) * step)); + } + + int height; + }; + + template struct BrdWrap + { + typedef D result_type; + + __host__ __device__ __forceinline__ BrdWrap(int height_, int width_) : + height(height_), width(width_) + { + } + template + __host__ __device__ __forceinline__ BrdWrap(int height_, int width_, U) : + height(height_), width(width_) + { + } + + __device__ __forceinline__ int idx_row_low(int y) const + { + return (y >= 0) ? y : (y - ((y - height + 1) / height) * height); + } + + __device__ __forceinline__ int idx_row_high(int y) const + { + return (y < height) ? y : (y % height); + } + + __device__ __forceinline__ int idx_row(int y) const + { + return idx_row_high(idx_row_low(y)); + } + + __device__ __forceinline__ int idx_col_low(int x) const + { + return (x >= 0) ? x : (x - ((x - width + 1) / width) * width); + } + + __device__ __forceinline__ int idx_col_high(int x) const + { + return (x < width) ? x : (x % width); + } + + __device__ __forceinline__ int idx_col(int x) const + { + return idx_col_high(idx_col_low(x)); + } + + template __device__ __forceinline__ D at(int y, int x, const T* data, size_t step) const + { + return saturate_cast(((const T*)((const char*)data + idx_row(y) * step))[idx_col(x)]); + } + + template __device__ __forceinline__ D at(typename Ptr2D::index_type y, typename Ptr2D::index_type x, const Ptr2D& src) const + { + return saturate_cast(src(idx_row(y), idx_col(x))); + } + + int height; + int width; + }; + + ////////////////////////////////////////////////////////////// + // BorderReader + + template struct BorderReader + { + typedef typename B::result_type elem_type; + typedef typename Ptr2D::index_type index_type; + + __host__ __device__ __forceinline__ BorderReader(const Ptr2D& ptr_, const B& b_) : ptr(ptr_), b(b_) {} + + __device__ __forceinline__ elem_type operator ()(index_type y, index_type x) const + { + return b.at(y, x, ptr); + } + + Ptr2D ptr; + B b; + }; + + // under win32 there is some bug with templated types that passed as kernel parameters + // with this specialization all works fine + template struct BorderReader< Ptr2D, BrdConstant > + { + typedef typename BrdConstant::result_type elem_type; + typedef typename Ptr2D::index_type index_type; + + __host__ __device__ __forceinline__ BorderReader(const Ptr2D& src_, const BrdConstant& b) : + src(src_), height(b.height), width(b.width), val(b.val) + { + } + + __device__ __forceinline__ D operator ()(index_type y, index_type x) const + { + return (x >= 0 && x < width && y >= 0 && y < height) ? saturate_cast(src(y, x)) : val; + } + + Ptr2D src; + int height; + int width; + D val; + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_BORDER_INTERPOLATE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/color.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/color.hpp new file mode 100644 index 0000000..dcce280 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/color.hpp @@ -0,0 +1,309 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_COLOR_HPP +#define OPENCV_CUDA_COLOR_HPP + +#include "detail/color_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + // All OPENCV_CUDA_IMPLEMENT_*_TRAITS(ColorSpace1_to_ColorSpace2, ...) macros implements + // template class ColorSpace1_to_ColorSpace2_traits + // { + // typedef ... functor_type; + // static __host__ __device__ functor_type create_functor(); + // }; + + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgr_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(bgra_to_rgba, 4, 4, 2) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgr_to_bgr555, 3, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgr_to_bgr565, 3, 0, 6) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgb_to_bgr555, 3, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgb_to_bgr565, 3, 2, 6) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgra_to_bgr555, 4, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(bgra_to_bgr565, 4, 0, 6) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgba_to_bgr555, 4, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(rgba_to_bgr565, 4, 2, 6) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_rgb, 3, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_rgb, 3, 2, 6) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_bgr, 3, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_bgr, 3, 0, 6) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_rgba, 4, 2, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_rgba, 4, 2, 6) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr555_to_bgra, 4, 0, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(bgr565_to_bgra, 4, 0, 6) + + #undef OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(gray_to_bgr, 3) + OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(gray_to_bgra, 4) + + #undef OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(gray_to_bgr555, 5) + OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(gray_to_bgr565, 6) + + #undef OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(bgr555_to_gray, 5) + OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(bgr565_to_gray, 6) + + #undef OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(rgb_to_gray, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(bgr_to_gray, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(rgba_to_gray, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(bgra_to_gray, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS + + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgb_to_YCrCb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgba_to_YCrCb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgb_to_YCrCb4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(rgba_to_YCrCb4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgr_to_YCrCb, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgra_to_YCrCb, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgr_to_YCrCb4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(bgra_to_YCrCb4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS + + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(YCrCb4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgb_to_xyz, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgba_to_xyz, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgb_to_xyz4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(rgba_to_xyz4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgr_to_xyz, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgra_to_xyz, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgr_to_xyz4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(bgra_to_xyz4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS + + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(xyz4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgb_to_hsv, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgba_to_hsv, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgb_to_hsv4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(rgba_to_hsv4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgr_to_hsv, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgra_to_hsv, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgr_to_hsv4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(bgra_to_hsv4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS + + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(hsv4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgb_to_hls, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgba_to_hls, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgb_to_hls4, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(rgba_to_hls4, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgr_to_hls, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgra_to_hls, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgr_to_hls4, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(bgra_to_hls4, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS + + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_rgb, 3, 3, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_rgba, 3, 4, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_rgb, 4, 3, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_rgba, 4, 4, 2) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_bgr, 3, 3, 0) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls_to_bgra, 3, 4, 0) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_bgr, 4, 3, 0) + OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(hls4_to_bgra, 4, 4, 0) + + #undef OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgb_to_lab, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgba_to_lab, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgb_to_lab4, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(rgba_to_lab4, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgr_to_lab, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgra_to_lab, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgr_to_lab4, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(bgra_to_lab4, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgb_to_lab, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgba_to_lab, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgb_to_lab4, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lrgba_to_lab4, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgr_to_lab, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgra_to_lab, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgr_to_lab4, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(lbgra_to_lab4, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS + + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_rgb, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_rgb, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_rgba, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_rgba, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_bgr, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_bgr, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_bgra, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_bgra, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lrgb, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lrgb, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lrgba, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lrgba, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lbgr, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lbgr, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab_to_lbgra, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(lab4_to_lbgra, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS + + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgb_to_luv, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgba_to_luv, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgb_to_luv4, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(rgba_to_luv4, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgr_to_luv, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgra_to_luv, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgr_to_luv4, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(bgra_to_luv4, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgb_to_luv, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgba_to_luv, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgb_to_luv4, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lrgba_to_luv4, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgr_to_luv, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgra_to_luv, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgr_to_luv4, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(lbgra_to_luv4, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS + + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_rgb, 3, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_rgb, 4, 3, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_rgba, 3, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_rgba, 4, 4, true, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_bgr, 3, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_bgr, 4, 3, true, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_bgra, 3, 4, true, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_bgra, 4, 4, true, 0) + + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lrgb, 3, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lrgb, 4, 3, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lrgba, 3, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lrgba, 4, 4, false, 2) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lbgr, 3, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lbgr, 4, 3, false, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv_to_lbgra, 3, 4, false, 0) + OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(luv4_to_lbgra, 4, 4, false, 0) + + #undef OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_COLOR_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/common.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/common.hpp new file mode 100644 index 0000000..80b2ff0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/common.hpp @@ -0,0 +1,123 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_COMMON_HPP +#define OPENCV_CUDA_COMMON_HPP + +#include +#include "opencv2/core/cuda_types.hpp" +#include "opencv2/core/cvdef.h" +#include "opencv2/core/base.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +#ifndef CV_PI_F + #ifndef CV_PI + #define CV_PI_F 3.14159265f + #else + #define CV_PI_F ((float)CV_PI) + #endif +#endif + +namespace cv { namespace cuda { + static inline void checkCudaError(cudaError_t err, const char* file, const int line, const char* func) + { + if (cudaSuccess != err) + cv::error(cv::Error::GpuApiCallError, cudaGetErrorString(err), func, file, line); + } +}} + +#ifndef cudaSafeCall + #define cudaSafeCall(expr) cv::cuda::checkCudaError(expr, __FILE__, __LINE__, CV_Func) +#endif + +namespace cv { namespace cuda +{ + template static inline bool isAligned(const T* ptr, size_t size) + { + return reinterpret_cast(ptr) % size == 0; + } + + static inline bool isAligned(size_t step, size_t size) + { + return step % size == 0; + } +}} + +namespace cv { namespace cuda +{ + namespace device + { + __host__ __device__ __forceinline__ int divUp(int total, int grain) + { + return (total + grain - 1) / grain; + } + + template inline void bindTexture(const textureReference* tex, const PtrStepSz& img) + { + cudaChannelFormatDesc desc = cudaCreateChannelDesc(); + cudaSafeCall( cudaBindTexture2D(0, tex, img.ptr(), &desc, img.cols, img.rows, img.step) ); + } + + template inline void createTextureObjectPitch2D(cudaTextureObject_t* tex, PtrStepSz& img, const cudaTextureDesc& texDesc) + { + cudaResourceDesc resDesc; + memset(&resDesc, 0, sizeof(resDesc)); + resDesc.resType = cudaResourceTypePitch2D; + resDesc.res.pitch2D.devPtr = static_cast(img.ptr()); + resDesc.res.pitch2D.height = img.rows; + resDesc.res.pitch2D.width = img.cols; + resDesc.res.pitch2D.pitchInBytes = img.step; + resDesc.res.pitch2D.desc = cudaCreateChannelDesc(); + + cudaSafeCall( cudaCreateTextureObject(tex, &resDesc, &texDesc, NULL) ); + } + } +}} + +//! @endcond + +#endif // OPENCV_CUDA_COMMON_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/datamov_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/datamov_utils.hpp new file mode 100644 index 0000000..6820d0f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/datamov_utils.hpp @@ -0,0 +1,113 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DATAMOV_UTILS_HPP +#define OPENCV_CUDA_DATAMOV_UTILS_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 200 + + // for Fermi memory space is detected automatically + template struct ForceGlob + { + __device__ __forceinline__ static void Load(const T* ptr, int offset, T& val) { val = ptr[offset]; } + }; + + #else // __CUDA_ARCH__ >= 200 + + #if defined(_WIN64) || defined(__LP64__) + // 64-bit register modifier for inlined asm + #define OPENCV_CUDA_ASM_PTR "l" + #else + // 32-bit register modifier for inlined asm + #define OPENCV_CUDA_ASM_PTR "r" + #endif + + template struct ForceGlob; + + #define OPENCV_CUDA_DEFINE_FORCE_GLOB(base_type, ptx_type, reg_mod) \ + template <> struct ForceGlob \ + { \ + __device__ __forceinline__ static void Load(const base_type* ptr, int offset, base_type& val) \ + { \ + asm("ld.global."#ptx_type" %0, [%1];" : "="#reg_mod(val) : OPENCV_CUDA_ASM_PTR(ptr + offset)); \ + } \ + }; + + #define OPENCV_CUDA_DEFINE_FORCE_GLOB_B(base_type, ptx_type) \ + template <> struct ForceGlob \ + { \ + __device__ __forceinline__ static void Load(const base_type* ptr, int offset, base_type& val) \ + { \ + asm("ld.global."#ptx_type" %0, [%1];" : "=r"(*reinterpret_cast(&val)) : OPENCV_CUDA_ASM_PTR(ptr + offset)); \ + } \ + }; + + OPENCV_CUDA_DEFINE_FORCE_GLOB_B(uchar, u8) + OPENCV_CUDA_DEFINE_FORCE_GLOB_B(schar, s8) + OPENCV_CUDA_DEFINE_FORCE_GLOB_B(char, b8) + OPENCV_CUDA_DEFINE_FORCE_GLOB (ushort, u16, h) + OPENCV_CUDA_DEFINE_FORCE_GLOB (short, s16, h) + OPENCV_CUDA_DEFINE_FORCE_GLOB (uint, u32, r) + OPENCV_CUDA_DEFINE_FORCE_GLOB (int, s32, r) + OPENCV_CUDA_DEFINE_FORCE_GLOB (float, f32, f) + OPENCV_CUDA_DEFINE_FORCE_GLOB (double, f64, d) + + #undef OPENCV_CUDA_DEFINE_FORCE_GLOB + #undef OPENCV_CUDA_DEFINE_FORCE_GLOB_B + #undef OPENCV_CUDA_ASM_PTR + + #endif // __CUDA_ARCH__ >= 200 +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_DATAMOV_UTILS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/color_detail.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/color_detail.hpp new file mode 100644 index 0000000..f4b4796 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/color_detail.hpp @@ -0,0 +1,2018 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_COLOR_DETAIL_HPP +#define OPENCV_CUDA_COLOR_DETAIL_HPP + +#include "../common.hpp" +#include "../vec_traits.hpp" +#include "../saturate_cast.hpp" +#include "../limits.hpp" +#include "../functional.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + #ifndef CV_DESCALE + #define CV_DESCALE(x, n) (((x) + (1 << ((n)-1))) >> (n)) + #endif + + namespace color_detail + { + template struct ColorChannel + { + typedef float worktype_f; + static __device__ __forceinline__ T max() { return numeric_limits::max(); } + static __device__ __forceinline__ T half() { return (T)(max()/2 + 1); } + }; + + template<> struct ColorChannel + { + typedef float worktype_f; + static __device__ __forceinline__ float max() { return 1.f; } + static __device__ __forceinline__ float half() { return 0.5f; } + }; + + template static __device__ __forceinline__ void setAlpha(typename TypeVec::vec_type& vec, T val) + { + } + + template static __device__ __forceinline__ void setAlpha(typename TypeVec::vec_type& vec, T val) + { + vec.w = val; + } + + template static __device__ __forceinline__ T getAlpha(const typename TypeVec::vec_type& vec) + { + return ColorChannel::max(); + } + + template static __device__ __forceinline__ T getAlpha(const typename TypeVec::vec_type& vec) + { + return vec.w; + } + + //constants for conversion from/to RGB and Gray, YUV, YCrCb according to BT.601 + constexpr float B2YF = 0.114f; + constexpr float G2YF = 0.587f; + constexpr float R2YF = 0.299f; + + //to YCbCr + constexpr float YCBF = 0.564f; // == 1/2/(1-B2YF) + constexpr float YCRF = 0.713f; // == 1/2/(1-R2YF) + const int YCBI = 9241; // == YCBF*16384 + const int YCRI = 11682; // == YCRF*16384 + //to YUV + constexpr float B2UF = 0.492f; + constexpr float R2VF = 0.877f; + const int B2UI = 8061; // == B2UF*16384 + const int R2VI = 14369; // == R2VF*16384 + //from YUV + constexpr float U2BF = 2.032f; + constexpr float U2GF = -0.395f; + constexpr float V2GF = -0.581f; + constexpr float V2RF = 1.140f; + const int U2BI = 33292; + const int U2GI = -6472; + const int V2GI = -9519; + const int V2RI = 18678; + //from YCrCb + constexpr float CB2BF = 1.773f; + constexpr float CB2GF = -0.344f; + constexpr float CR2GF = -0.714f; + constexpr float CR2RF = 1.403f; + const int CB2BI = 29049; + const int CB2GI = -5636; + const int CR2GI = -11698; + const int CR2RI = 22987; + + enum + { + yuv_shift = 14, + xyz_shift = 12, + gray_shift = 15, + R2Y = 4899, + G2Y = 9617, + B2Y = 1868, + RY15 = 9798, // == R2YF*32768 + 0.5 + GY15 = 19235, // == G2YF*32768 + 0.5 + BY15 = 3735, // == B2YF*32768 + 0.5 + BLOCK_SIZE = 256 + }; + } + +////////////////// Various 3/4-channel to 3/4-channel RGB transformations ///////////////// + + namespace color_detail + { + template struct RGB2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + dst.x = (&src.x)[bidx]; + dst.y = src.y; + dst.z = (&src.x)[bidx^2]; + setAlpha(dst, getAlpha(src)); + + return dst; + } + + __host__ __device__ __forceinline__ RGB2RGB() {} + __host__ __device__ __forceinline__ RGB2RGB(const RGB2RGB&) {} + }; + + template <> struct RGB2RGB : unary_function + { + __device__ uint operator()(uint src) const + { + uint dst = 0; + + dst |= (0xffu & (src >> 16)); + dst |= (0xffu & (src >> 8)) << 8; + dst |= (0xffu & (src)) << 16; + dst |= (0xffu & (src >> 24)) << 24; + + return dst; + } + + __host__ __device__ __forceinline__ RGB2RGB() {} + __host__ __device__ __forceinline__ RGB2RGB(const RGB2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +/////////// Transforming 16-bit (565 or 555) RGB to/from 24/32-bit (888[8]) RGB ////////// + + namespace color_detail + { + template struct RGB2RGB5x5Converter; + template struct RGB2RGB5x5Converter<6, bidx> + { + static __device__ __forceinline__ ushort cvt(const uchar3& src) + { + return (ushort)(((&src.x)[bidx] >> 3) | ((src.y & ~3) << 3) | (((&src.x)[bidx^2] & ~7) << 8)); + } + + static __device__ __forceinline__ ushort cvt(uint src) + { + uint b = 0xffu & (src >> (bidx * 8)); + uint g = 0xffu & (src >> 8); + uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + return (ushort)((b >> 3) | ((g & ~3) << 3) | ((r & ~7) << 8)); + } + }; + + template struct RGB2RGB5x5Converter<5, bidx> + { + static __device__ __forceinline__ ushort cvt(const uchar3& src) + { + return (ushort)(((&src.x)[bidx] >> 3) | ((src.y & ~7) << 2) | (((&src.x)[bidx^2] & ~7) << 7)); + } + + static __device__ __forceinline__ ushort cvt(uint src) + { + uint b = 0xffu & (src >> (bidx * 8)); + uint g = 0xffu & (src >> 8); + uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + uint a = 0xffu & (src >> 24); + return (ushort)((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7) | (a * 0x8000)); + } + }; + + template struct RGB2RGB5x5; + + template struct RGB2RGB5x5<3, bidx,green_bits> : unary_function + { + __device__ __forceinline__ ushort operator()(const uchar3& src) const + { + return RGB2RGB5x5Converter::cvt(src); + } + + __host__ __device__ __forceinline__ RGB2RGB5x5() {} + __host__ __device__ __forceinline__ RGB2RGB5x5(const RGB2RGB5x5&) {} + }; + + template struct RGB2RGB5x5<4, bidx,green_bits> : unary_function + { + __device__ __forceinline__ ushort operator()(uint src) const + { + return RGB2RGB5x5Converter::cvt(src); + } + + __host__ __device__ __forceinline__ RGB2RGB5x5() {} + __host__ __device__ __forceinline__ RGB2RGB5x5(const RGB2RGB5x5&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2RGB5x5_TRAITS(name, scn, bidx, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2RGB5x5 functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template struct RGB5x52RGBConverter; + + template struct RGB5x52RGBConverter<5, bidx> + { + static __device__ __forceinline__ void cvt(uint src, uchar3& dst) + { + (&dst.x)[bidx] = src << 3; + dst.y = (src >> 2) & ~7; + (&dst.x)[bidx ^ 2] = (src >> 7) & ~7; + } + + static __device__ __forceinline__ void cvt(uint src, uint& dst) + { + dst = 0; + + dst |= (0xffu & (src << 3)) << (bidx * 8); + dst |= (0xffu & ((src >> 2) & ~7)) << 8; + dst |= (0xffu & ((src >> 7) & ~7)) << ((bidx ^ 2) * 8); + dst |= ((src & 0x8000) * 0xffu) << 24; + } + }; + + template struct RGB5x52RGBConverter<6, bidx> + { + static __device__ __forceinline__ void cvt(uint src, uchar3& dst) + { + (&dst.x)[bidx] = src << 3; + dst.y = (src >> 3) & ~3; + (&dst.x)[bidx ^ 2] = (src >> 8) & ~7; + } + + static __device__ __forceinline__ void cvt(uint src, uint& dst) + { + dst = 0xffu << 24; + + dst |= (0xffu & (src << 3)) << (bidx * 8); + dst |= (0xffu &((src >> 3) & ~3)) << 8; + dst |= (0xffu & ((src >> 8) & ~7)) << ((bidx ^ 2) * 8); + } + }; + + template struct RGB5x52RGB; + + template struct RGB5x52RGB<3, bidx, green_bits> : unary_function + { + __device__ __forceinline__ uchar3 operator()(ushort src) const + { + uchar3 dst; + RGB5x52RGBConverter::cvt(src, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB5x52RGB() {} + __host__ __device__ __forceinline__ RGB5x52RGB(const RGB5x52RGB&) {} + + }; + + template struct RGB5x52RGB<4, bidx, green_bits> : unary_function + { + __device__ __forceinline__ uint operator()(ushort src) const + { + uint dst; + RGB5x52RGBConverter::cvt(src, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB5x52RGB() {} + __host__ __device__ __forceinline__ RGB5x52RGB(const RGB5x52RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB5x52RGB_TRAITS(name, dcn, bidx, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB5x52RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////// Grayscale to Color //////////////////////////////// + + namespace color_detail + { + template struct Gray2RGB : unary_function::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(T src) const + { + typename TypeVec::vec_type dst; + + dst.z = dst.y = dst.x = src; + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ Gray2RGB() {} + __host__ __device__ __forceinline__ Gray2RGB(const Gray2RGB&) {} + }; + + template <> struct Gray2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + uint dst = 0xffu << 24; + + dst |= src; + dst |= src << 8; + dst |= src << 16; + + return dst; + } + __host__ __device__ __forceinline__ Gray2RGB() {} + __host__ __device__ __forceinline__ Gray2RGB(const Gray2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_GRAY2RGB_TRAITS(name, dcn) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Gray2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template struct Gray2RGB5x5Converter; + template<> struct Gray2RGB5x5Converter<6> + { + static __device__ __forceinline__ ushort cvt(uint t) + { + return (ushort)((t >> 3) | ((t & ~3) << 3) | ((t & ~7) << 8)); + } + }; + + template<> struct Gray2RGB5x5Converter<5> + { + static __device__ __forceinline__ ushort cvt(uint t) + { + t >>= 3; + return (ushort)(t | (t << 5) | (t << 10)); + } + }; + + template struct Gray2RGB5x5 : unary_function + { + __device__ __forceinline__ ushort operator()(uint src) const + { + return Gray2RGB5x5Converter::cvt(src); + } + + __host__ __device__ __forceinline__ Gray2RGB5x5() {} + __host__ __device__ __forceinline__ Gray2RGB5x5(const Gray2RGB5x5&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_GRAY2RGB5x5_TRAITS(name, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Gray2RGB5x5 functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////// Color to Grayscale //////////////////////////////// + + namespace color_detail + { + template struct RGB5x52GrayConverter; + template <> struct RGB5x52GrayConverter<6> + { + static __device__ __forceinline__ uchar cvt(uint t) + { + return (uchar)CV_DESCALE(((t << 3) & 0xf8) * BY15 + ((t >> 3) & 0xfc) * GY15 + ((t >> 8) & 0xf8) * RY15, gray_shift); + } + }; + + template <> struct RGB5x52GrayConverter<5> + { + static __device__ __forceinline__ uchar cvt(uint t) + { + return (uchar)CV_DESCALE(((t << 3) & 0xf8) * BY15 + ((t >> 2) & 0xf8) * GY15 + ((t >> 7) & 0xf8) * RY15, gray_shift); + } + }; + + template struct RGB5x52Gray : unary_function + { + __device__ __forceinline__ uchar operator()(uint src) const + { + return RGB5x52GrayConverter::cvt(src); + } + __host__ __device__ __forceinline__ RGB5x52Gray() {} + __host__ __device__ __forceinline__ RGB5x52Gray(const RGB5x52Gray&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB5x52GRAY_TRAITS(name, green_bits) \ + struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB5x52Gray functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template static __device__ __forceinline__ T RGB2GrayConvert(const T* src) + { + return (T)CV_DESCALE((unsigned)(src[bidx] * BY15 + src[1] * GY15 + src[bidx^2] * RY15), gray_shift); + } + + template static __device__ __forceinline__ uchar RGB2GrayConvert(uint src) + { + uint b = 0xffu & (src >> (bidx * 8)); + uint g = 0xffu & (src >> 8); + uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + return CV_DESCALE((uint)(b * BY15 + g * GY15 + r * RY15), gray_shift); + } + + template static __device__ __forceinline__ float RGB2GrayConvert(const float* src) + { + return src[bidx] * B2YF + src[1] * G2YF + src[bidx^2] * R2YF; + } + + template struct RGB2Gray : unary_function::vec_type, T> + { + __device__ __forceinline__ T operator()(const typename TypeVec::vec_type& src) const + { + return RGB2GrayConvert(&src.x); + } + __host__ __device__ __forceinline__ RGB2Gray() {} + __host__ __device__ __forceinline__ RGB2Gray(const RGB2Gray&) {} + }; + + template struct RGB2Gray : unary_function + { + __device__ __forceinline__ uchar operator()(uint src) const + { + return RGB2GrayConvert(src); + } + __host__ __device__ __forceinline__ RGB2Gray() {} + __host__ __device__ __forceinline__ RGB2Gray(const RGB2Gray&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2GRAY_TRAITS(name, scn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2Gray functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> YUV ////////////////////////////////////// + + namespace color_detail + { + __constant__ float c_RGB2YUVCoeffs_f[5] = { B2YF, G2YF, R2YF, B2UF, R2VF }; + __constant__ int c_RGB2YUVCoeffs_i[5] = { B2Y, G2Y, R2Y, B2UI, R2VI }; + + template static __device__ void RGB2YUVConvert(const T* src, D& dst) + { + const int delta = ColorChannel::half() * (1 << yuv_shift); + + const int Y = CV_DESCALE(src[0] * c_RGB2YUVCoeffs_i[bidx^2] + src[1] * c_RGB2YUVCoeffs_i[1] + src[2] * c_RGB2YUVCoeffs_i[bidx], yuv_shift); + const int Cr = CV_DESCALE((src[bidx^2] - Y) * c_RGB2YUVCoeffs_i[3] + delta, yuv_shift); + const int Cb = CV_DESCALE((src[bidx] - Y) * c_RGB2YUVCoeffs_i[4] + delta, yuv_shift); + + dst.x = saturate_cast(Y); + dst.y = saturate_cast(Cr); + dst.z = saturate_cast(Cb); + } + + template static __device__ __forceinline__ void RGB2YUVConvert(const float* src, D& dst) + { + dst.x = src[0] * c_RGB2YUVCoeffs_f[bidx^2] + src[1] * c_RGB2YUVCoeffs_f[1] + src[2] * c_RGB2YUVCoeffs_f[bidx]; + dst.y = (src[bidx^2] - dst.x) * c_RGB2YUVCoeffs_f[3] + ColorChannel::half(); + dst.z = (src[bidx] - dst.x) * c_RGB2YUVCoeffs_f[4] + ColorChannel::half(); + } + + template struct RGB2YUV + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + RGB2YUVConvert(&src.x, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB2YUV() {} + __host__ __device__ __forceinline__ RGB2YUV(const RGB2YUV&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2YUV_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2YUV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_YUV2RGBCoeffs_f[5] = { U2BF, U2GF, V2GF, V2RF }; + __constant__ int c_YUV2RGBCoeffs_i[5] = { U2BI, U2GI, V2GI, V2RI }; + + template static __device__ void YUV2RGBConvert(const T& src, D* dst) + { + const int b = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[3], yuv_shift); + + const int g = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[2] + + (src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[1], yuv_shift); + + const int r = src.x + CV_DESCALE((src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[0], yuv_shift); + + dst[bidx] = saturate_cast(b); + dst[1] = saturate_cast(g); + dst[bidx^2] = saturate_cast(r); + } + + template static __device__ uint YUV2RGBConvert(uint src) + { + const int x = 0xff & (src); + const int y = 0xff & (src >> 8); + const int z = 0xff & (src >> 16); + + const int b = x + CV_DESCALE((z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[3], yuv_shift); + + const int g = x + CV_DESCALE((z - ColorChannel::half()) * c_YUV2RGBCoeffs_i[2] + + (y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[1], yuv_shift); + + const int r = x + CV_DESCALE((y - ColorChannel::half()) * c_YUV2RGBCoeffs_i[0], yuv_shift); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(b) << (bidx * 8); + dst |= saturate_cast(g) << 8; + dst |= saturate_cast(r) << ((bidx ^ 2) * 8); + + return dst; + } + + template static __device__ __forceinline__ void YUV2RGBConvert(const T& src, float* dst) + { + dst[bidx] = src.x + (src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_f[3]; + + dst[1] = src.x + (src.z - ColorChannel::half()) * c_YUV2RGBCoeffs_f[2] + + (src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_f[1]; + + dst[bidx^2] = src.x + (src.y - ColorChannel::half()) * c_YUV2RGBCoeffs_f[0]; + } + + template struct YUV2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + YUV2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ YUV2RGB() {} + __host__ __device__ __forceinline__ YUV2RGB(const YUV2RGB&) {} + }; + + template struct YUV2RGB : unary_function + { + __device__ __forceinline__ uint operator ()(uint src) const + { + return YUV2RGBConvert(src); + } + __host__ __device__ __forceinline__ YUV2RGB() {} + __host__ __device__ __forceinline__ YUV2RGB(const YUV2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_YUV2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::YUV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> YCrCb ////////////////////////////////////// + + namespace color_detail + { + __constant__ float c_RGB2YCrCbCoeffs_f[5] = {R2YF, G2YF, B2YF, YCRF, YCBF}; + __constant__ int c_RGB2YCrCbCoeffs_i[5] = {R2Y, G2Y, B2Y, YCRI, YCBI}; + + template static __device__ void RGB2YCrCbConvert(const T* src, D& dst) + { + const int delta = ColorChannel::half() * (1 << yuv_shift); + + const int Y = CV_DESCALE(src[0] * c_RGB2YCrCbCoeffs_i[bidx^2] + src[1] * c_RGB2YCrCbCoeffs_i[1] + src[2] * c_RGB2YCrCbCoeffs_i[bidx], yuv_shift); + const int Cr = CV_DESCALE((src[bidx^2] - Y) * c_RGB2YCrCbCoeffs_i[3] + delta, yuv_shift); + const int Cb = CV_DESCALE((src[bidx] - Y) * c_RGB2YCrCbCoeffs_i[4] + delta, yuv_shift); + + dst.x = saturate_cast(Y); + dst.y = saturate_cast(Cr); + dst.z = saturate_cast(Cb); + } + + template static __device__ uint RGB2YCrCbConvert(uint src) + { + const int delta = ColorChannel::half() * (1 << yuv_shift); + + const int Y = CV_DESCALE((0xffu & src) * c_RGB2YCrCbCoeffs_i[bidx^2] + (0xffu & (src >> 8)) * c_RGB2YCrCbCoeffs_i[1] + (0xffu & (src >> 16)) * c_RGB2YCrCbCoeffs_i[bidx], yuv_shift); + const int Cr = CV_DESCALE(((0xffu & (src >> ((bidx ^ 2) * 8))) - Y) * c_RGB2YCrCbCoeffs_i[3] + delta, yuv_shift); + const int Cb = CV_DESCALE(((0xffu & (src >> (bidx * 8))) - Y) * c_RGB2YCrCbCoeffs_i[4] + delta, yuv_shift); + + uint dst = 0; + + dst |= saturate_cast(Y); + dst |= saturate_cast(Cr) << 8; + dst |= saturate_cast(Cb) << 16; + + return dst; + } + + template static __device__ __forceinline__ void RGB2YCrCbConvert(const float* src, D& dst) + { + dst.x = src[0] * c_RGB2YCrCbCoeffs_f[bidx^2] + src[1] * c_RGB2YCrCbCoeffs_f[1] + src[2] * c_RGB2YCrCbCoeffs_f[bidx]; + dst.y = (src[bidx^2] - dst.x) * c_RGB2YCrCbCoeffs_f[3] + ColorChannel::half(); + dst.z = (src[bidx] - dst.x) * c_RGB2YCrCbCoeffs_f[4] + ColorChannel::half(); + } + + template struct RGB2YCrCb + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + RGB2YCrCbConvert(&src.x, dst); + return dst; + } + __host__ __device__ __forceinline__ RGB2YCrCb() {} + __host__ __device__ __forceinline__ RGB2YCrCb(const RGB2YCrCb&) {} + }; + + template struct RGB2YCrCb : unary_function + { + __device__ __forceinline__ uint operator ()(uint src) const + { + return RGB2YCrCbConvert(src); + } + + __host__ __device__ __forceinline__ RGB2YCrCb() {} + __host__ __device__ __forceinline__ RGB2YCrCb(const RGB2YCrCb&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2YCrCb_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2YCrCb functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_YCrCb2RGBCoeffs_f[5] = {CR2RF, CR2GF, CB2GF, CB2BF}; + __constant__ int c_YCrCb2RGBCoeffs_i[5] = {CR2RI, CR2GI, CB2GI, CB2BI}; + + template static __device__ void YCrCb2RGBConvert(const T& src, D* dst) + { + const int b = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[3], yuv_shift); + const int g = src.x + CV_DESCALE((src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[2] + (src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[1], yuv_shift); + const int r = src.x + CV_DESCALE((src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[0], yuv_shift); + + dst[bidx] = saturate_cast(b); + dst[1] = saturate_cast(g); + dst[bidx^2] = saturate_cast(r); + } + + template static __device__ uint YCrCb2RGBConvert(uint src) + { + const int x = 0xff & (src); + const int y = 0xff & (src >> 8); + const int z = 0xff & (src >> 16); + + const int b = x + CV_DESCALE((z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[3], yuv_shift); + const int g = x + CV_DESCALE((z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[2] + (y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[1], yuv_shift); + const int r = x + CV_DESCALE((y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_i[0], yuv_shift); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(b) << (bidx * 8); + dst |= saturate_cast(g) << 8; + dst |= saturate_cast(r) << ((bidx ^ 2) * 8); + + return dst; + } + + template __device__ __forceinline__ void YCrCb2RGBConvert(const T& src, float* dst) + { + dst[bidx] = src.x + (src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[3]; + dst[1] = src.x + (src.z - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[2] + (src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[1]; + dst[bidx^2] = src.x + (src.y - ColorChannel::half()) * c_YCrCb2RGBCoeffs_f[0]; + } + + template struct YCrCb2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + YCrCb2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ YCrCb2RGB() {} + __host__ __device__ __forceinline__ YCrCb2RGB(const YCrCb2RGB&) {} + }; + + template struct YCrCb2RGB : unary_function + { + __device__ __forceinline__ uint operator ()(uint src) const + { + return YCrCb2RGBConvert(src); + } + __host__ __device__ __forceinline__ YCrCb2RGB() {} + __host__ __device__ __forceinline__ YCrCb2RGB(const YCrCb2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_YCrCb2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::YCrCb2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +////////////////////////////////////// RGB <-> XYZ /////////////////////////////////////// + + namespace color_detail + { + __constant__ float c_RGB2XYZ_D65f[9] = { 0.412453f, 0.357580f, 0.180423f, 0.212671f, 0.715160f, 0.072169f, 0.019334f, 0.119193f, 0.950227f }; + __constant__ int c_RGB2XYZ_D65i[9] = { 1689, 1465, 739, 871, 2929, 296, 79, 488, 3892 }; + + template static __device__ __forceinline__ void RGB2XYZConvert(const T* src, D& dst) + { + dst.z = saturate_cast(CV_DESCALE(src[bidx^2] * c_RGB2XYZ_D65i[6] + src[1] * c_RGB2XYZ_D65i[7] + src[bidx] * c_RGB2XYZ_D65i[8], xyz_shift)); + dst.x = saturate_cast(CV_DESCALE(src[bidx^2] * c_RGB2XYZ_D65i[0] + src[1] * c_RGB2XYZ_D65i[1] + src[bidx] * c_RGB2XYZ_D65i[2], xyz_shift)); + dst.y = saturate_cast(CV_DESCALE(src[bidx^2] * c_RGB2XYZ_D65i[3] + src[1] * c_RGB2XYZ_D65i[4] + src[bidx] * c_RGB2XYZ_D65i[5], xyz_shift)); + } + + template static __device__ __forceinline__ uint RGB2XYZConvert(uint src) + { + const uint b = 0xffu & (src >> (bidx * 8)); + const uint g = 0xffu & (src >> 8); + const uint r = 0xffu & (src >> ((bidx ^ 2) * 8)); + + const uint x = saturate_cast(CV_DESCALE(r * c_RGB2XYZ_D65i[0] + g * c_RGB2XYZ_D65i[1] + b * c_RGB2XYZ_D65i[2], xyz_shift)); + const uint y = saturate_cast(CV_DESCALE(r * c_RGB2XYZ_D65i[3] + g * c_RGB2XYZ_D65i[4] + b * c_RGB2XYZ_D65i[5], xyz_shift)); + const uint z = saturate_cast(CV_DESCALE(r * c_RGB2XYZ_D65i[6] + g * c_RGB2XYZ_D65i[7] + b * c_RGB2XYZ_D65i[8], xyz_shift)); + + uint dst = 0; + + dst |= x; + dst |= y << 8; + dst |= z << 16; + + return dst; + } + + template static __device__ __forceinline__ void RGB2XYZConvert(const float* src, D& dst) + { + dst.x = src[bidx^2] * c_RGB2XYZ_D65f[0] + src[1] * c_RGB2XYZ_D65f[1] + src[bidx] * c_RGB2XYZ_D65f[2]; + dst.y = src[bidx^2] * c_RGB2XYZ_D65f[3] + src[1] * c_RGB2XYZ_D65f[4] + src[bidx] * c_RGB2XYZ_D65f[5]; + dst.z = src[bidx^2] * c_RGB2XYZ_D65f[6] + src[1] * c_RGB2XYZ_D65f[7] + src[bidx] * c_RGB2XYZ_D65f[8]; + } + + template struct RGB2XYZ + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2XYZConvert(&src.x, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2XYZ() {} + __host__ __device__ __forceinline__ RGB2XYZ(const RGB2XYZ&) {} + }; + + template struct RGB2XYZ : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return RGB2XYZConvert(src); + } + __host__ __device__ __forceinline__ RGB2XYZ() {} + __host__ __device__ __forceinline__ RGB2XYZ(const RGB2XYZ&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2XYZ_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2XYZ functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_XYZ2sRGB_D65f[9] = { 3.240479f, -1.53715f, -0.498535f, -0.969256f, 1.875991f, 0.041556f, 0.055648f, -0.204043f, 1.057311f }; + __constant__ int c_XYZ2sRGB_D65i[9] = { 13273, -6296, -2042, -3970, 7684, 170, 228, -836, 4331 }; + + template static __device__ __forceinline__ void XYZ2RGBConvert(const T& src, D* dst) + { + dst[bidx^2] = saturate_cast(CV_DESCALE(src.x * c_XYZ2sRGB_D65i[0] + src.y * c_XYZ2sRGB_D65i[1] + src.z * c_XYZ2sRGB_D65i[2], xyz_shift)); + dst[1] = saturate_cast(CV_DESCALE(src.x * c_XYZ2sRGB_D65i[3] + src.y * c_XYZ2sRGB_D65i[4] + src.z * c_XYZ2sRGB_D65i[5], xyz_shift)); + dst[bidx] = saturate_cast(CV_DESCALE(src.x * c_XYZ2sRGB_D65i[6] + src.y * c_XYZ2sRGB_D65i[7] + src.z * c_XYZ2sRGB_D65i[8], xyz_shift)); + } + + template static __device__ __forceinline__ uint XYZ2RGBConvert(uint src) + { + const int x = 0xff & src; + const int y = 0xff & (src >> 8); + const int z = 0xff & (src >> 16); + + const uint r = saturate_cast(CV_DESCALE(x * c_XYZ2sRGB_D65i[0] + y * c_XYZ2sRGB_D65i[1] + z * c_XYZ2sRGB_D65i[2], xyz_shift)); + const uint g = saturate_cast(CV_DESCALE(x * c_XYZ2sRGB_D65i[3] + y * c_XYZ2sRGB_D65i[4] + z * c_XYZ2sRGB_D65i[5], xyz_shift)); + const uint b = saturate_cast(CV_DESCALE(x * c_XYZ2sRGB_D65i[6] + y * c_XYZ2sRGB_D65i[7] + z * c_XYZ2sRGB_D65i[8], xyz_shift)); + + uint dst = 0xffu << 24; + + dst |= b << (bidx * 8); + dst |= g << 8; + dst |= r << ((bidx ^ 2) * 8); + + return dst; + } + + template static __device__ __forceinline__ void XYZ2RGBConvert(const T& src, float* dst) + { + dst[bidx^2] = src.x * c_XYZ2sRGB_D65f[0] + src.y * c_XYZ2sRGB_D65f[1] + src.z * c_XYZ2sRGB_D65f[2]; + dst[1] = src.x * c_XYZ2sRGB_D65f[3] + src.y * c_XYZ2sRGB_D65f[4] + src.z * c_XYZ2sRGB_D65f[5]; + dst[bidx] = src.x * c_XYZ2sRGB_D65f[6] + src.y * c_XYZ2sRGB_D65f[7] + src.z * c_XYZ2sRGB_D65f[8]; + } + + template struct XYZ2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + XYZ2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ XYZ2RGB() {} + __host__ __device__ __forceinline__ XYZ2RGB(const XYZ2RGB&) {} + }; + + template struct XYZ2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return XYZ2RGBConvert(src); + } + __host__ __device__ __forceinline__ XYZ2RGB() {} + __host__ __device__ __forceinline__ XYZ2RGB(const XYZ2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_XYZ2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::XYZ2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +////////////////////////////////////// RGB <-> HSV /////////////////////////////////////// + + namespace color_detail + { + __constant__ int c_HsvDivTable [256] = {0, 1044480, 522240, 348160, 261120, 208896, 174080, 149211, 130560, 116053, 104448, 94953, 87040, 80345, 74606, 69632, 65280, 61440, 58027, 54973, 52224, 49737, 47476, 45412, 43520, 41779, 40172, 38684, 37303, 36017, 34816, 33693, 32640, 31651, 30720, 29842, 29013, 28229, 27486, 26782, 26112, 25475, 24869, 24290, 23738, 23211, 22706, 22223, 21760, 21316, 20890, 20480, 20086, 19707, 19342, 18991, 18651, 18324, 18008, 17703, 17408, 17123, 16846, 16579, 16320, 16069, 15825, 15589, 15360, 15137, 14921, 14711, 14507, 14308, 14115, 13926, 13743, 13565, 13391, 13221, 13056, 12895, 12738, 12584, 12434, 12288, 12145, 12006, 11869, 11736, 11605, 11478, 11353, 11231, 11111, 10995, 10880, 10768, 10658, 10550, 10445, 10341, 10240, 10141, 10043, 9947, 9854, 9761, 9671, 9582, 9495, 9410, 9326, 9243, 9162, 9082, 9004, 8927, 8852, 8777, 8704, 8632, 8561, 8492, 8423, 8356, 8290, 8224, 8160, 8097, 8034, 7973, 7913, 7853, 7795, 7737, 7680, 7624, 7569, 7514, 7461, 7408, 7355, 7304, 7253, 7203, 7154, 7105, 7057, 7010, 6963, 6917, 6872, 6827, 6782, 6739, 6695, 6653, 6611, 6569, 6528, 6487, 6447, 6408, 6369, 6330, 6292, 6254, 6217, 6180, 6144, 6108, 6073, 6037, 6003, 5968, 5935, 5901, 5868, 5835, 5803, 5771, 5739, 5708, 5677, 5646, 5615, 5585, 5556, 5526, 5497, 5468, 5440, 5412, 5384, 5356, 5329, 5302, 5275, 5249, 5222, 5196, 5171, 5145, 5120, 5095, 5070, 5046, 5022, 4998, 4974, 4950, 4927, 4904, 4881, 4858, 4836, 4813, 4791, 4769, 4748, 4726, 4705, 4684, 4663, 4642, 4622, 4601, 4581, 4561, 4541, 4522, 4502, 4483, 4464, 4445, 4426, 4407, 4389, 4370, 4352, 4334, 4316, 4298, 4281, 4263, 4246, 4229, 4212, 4195, 4178, 4161, 4145, 4128, 4112, 4096}; + __constant__ int c_HsvDivTable180[256] = {0, 122880, 61440, 40960, 30720, 24576, 20480, 17554, 15360, 13653, 12288, 11171, 10240, 9452, 8777, 8192, 7680, 7228, 6827, 6467, 6144, 5851, 5585, 5343, 5120, 4915, 4726, 4551, 4389, 4237, 4096, 3964, 3840, 3724, 3614, 3511, 3413, 3321, 3234, 3151, 3072, 2997, 2926, 2858, 2793, 2731, 2671, 2614, 2560, 2508, 2458, 2409, 2363, 2318, 2276, 2234, 2194, 2156, 2119, 2083, 2048, 2014, 1982, 1950, 1920, 1890, 1862, 1834, 1807, 1781, 1755, 1731, 1707, 1683, 1661, 1638, 1617, 1596, 1575, 1555, 1536, 1517, 1499, 1480, 1463, 1446, 1429, 1412, 1396, 1381, 1365, 1350, 1336, 1321, 1307, 1293, 1280, 1267, 1254, 1241, 1229, 1217, 1205, 1193, 1182, 1170, 1159, 1148, 1138, 1127, 1117, 1107, 1097, 1087, 1078, 1069, 1059, 1050, 1041, 1033, 1024, 1016, 1007, 999, 991, 983, 975, 968, 960, 953, 945, 938, 931, 924, 917, 910, 904, 897, 890, 884, 878, 871, 865, 859, 853, 847, 842, 836, 830, 825, 819, 814, 808, 803, 798, 793, 788, 783, 778, 773, 768, 763, 759, 754, 749, 745, 740, 736, 731, 727, 723, 719, 714, 710, 706, 702, 698, 694, 690, 686, 683, 679, 675, 671, 668, 664, 661, 657, 654, 650, 647, 643, 640, 637, 633, 630, 627, 624, 621, 617, 614, 611, 608, 605, 602, 599, 597, 594, 591, 588, 585, 582, 580, 577, 574, 572, 569, 566, 564, 561, 559, 556, 554, 551, 549, 546, 544, 541, 539, 537, 534, 532, 530, 527, 525, 523, 521, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 497, 495, 493, 492, 490, 488, 486, 484, 482}; + __constant__ int c_HsvDivTable256[256] = {0, 174763, 87381, 58254, 43691, 34953, 29127, 24966, 21845, 19418, 17476, 15888, 14564, 13443, 12483, 11651, 10923, 10280, 9709, 9198, 8738, 8322, 7944, 7598, 7282, 6991, 6722, 6473, 6242, 6026, 5825, 5638, 5461, 5296, 5140, 4993, 4855, 4723, 4599, 4481, 4369, 4263, 4161, 4064, 3972, 3884, 3799, 3718, 3641, 3567, 3495, 3427, 3361, 3297, 3236, 3178, 3121, 3066, 3013, 2962, 2913, 2865, 2819, 2774, 2731, 2689, 2648, 2608, 2570, 2533, 2497, 2461, 2427, 2394, 2362, 2330, 2300, 2270, 2241, 2212, 2185, 2158, 2131, 2106, 2081, 2056, 2032, 2009, 1986, 1964, 1942, 1920, 1900, 1879, 1859, 1840, 1820, 1802, 1783, 1765, 1748, 1730, 1713, 1697, 1680, 1664, 1649, 1633, 1618, 1603, 1589, 1574, 1560, 1547, 1533, 1520, 1507, 1494, 1481, 1469, 1456, 1444, 1432, 1421, 1409, 1398, 1387, 1376, 1365, 1355, 1344, 1334, 1324, 1314, 1304, 1295, 1285, 1276, 1266, 1257, 1248, 1239, 1231, 1222, 1214, 1205, 1197, 1189, 1181, 1173, 1165, 1157, 1150, 1142, 1135, 1128, 1120, 1113, 1106, 1099, 1092, 1085, 1079, 1072, 1066, 1059, 1053, 1046, 1040, 1034, 1028, 1022, 1016, 1010, 1004, 999, 993, 987, 982, 976, 971, 966, 960, 955, 950, 945, 940, 935, 930, 925, 920, 915, 910, 906, 901, 896, 892, 887, 883, 878, 874, 869, 865, 861, 857, 853, 848, 844, 840, 836, 832, 828, 824, 820, 817, 813, 809, 805, 802, 798, 794, 791, 787, 784, 780, 777, 773, 770, 767, 763, 760, 757, 753, 750, 747, 744, 741, 737, 734, 731, 728, 725, 722, 719, 716, 713, 710, 708, 705, 702, 699, 696, 694, 691, 688, 685}; + + template static __device__ void RGB2HSVConvert(const uchar* src, D& dst) + { + const int hsv_shift = 12; + const int* hdiv_table = hr == 180 ? c_HsvDivTable180 : c_HsvDivTable256; + + int b = src[bidx], g = src[1], r = src[bidx^2]; + int h, s, v = b; + int vmin = b, diff; + int vr, vg; + + v = ::max(v, g); + v = ::max(v, r); + vmin = ::min(vmin, g); + vmin = ::min(vmin, r); + + diff = v - vmin; + vr = (v == r) * -1; + vg = (v == g) * -1; + + s = (diff * c_HsvDivTable[v] + (1 << (hsv_shift-1))) >> hsv_shift; + h = (vr & (g - b)) + (~vr & ((vg & (b - r + 2 * diff)) + ((~vg) & (r - g + 4 * diff)))); + h = (h * hdiv_table[diff] + (1 << (hsv_shift-1))) >> hsv_shift; + h += (h < 0) * hr; + + dst.x = saturate_cast(h); + dst.y = (uchar)s; + dst.z = (uchar)v; + } + + template static __device__ uint RGB2HSVConvert(uint src) + { + const int hsv_shift = 12; + const int* hdiv_table = hr == 180 ? c_HsvDivTable180 : c_HsvDivTable256; + + const int b = 0xff & (src >> (bidx * 8)); + const int g = 0xff & (src >> 8); + const int r = 0xff & (src >> ((bidx ^ 2) * 8)); + + int h, s, v = b; + int vmin = b, diff; + int vr, vg; + + v = ::max(v, g); + v = ::max(v, r); + vmin = ::min(vmin, g); + vmin = ::min(vmin, r); + + diff = v - vmin; + vr = (v == r) * -1; + vg = (v == g) * -1; + + s = (diff * c_HsvDivTable[v] + (1 << (hsv_shift-1))) >> hsv_shift; + h = (vr & (g - b)) + (~vr & ((vg & (b - r + 2 * diff)) + ((~vg) & (r - g + 4 * diff)))); + h = (h * hdiv_table[diff] + (1 << (hsv_shift-1))) >> hsv_shift; + h += (h < 0) * hr; + + uint dst = 0; + + dst |= saturate_cast(h); + dst |= (0xffu & s) << 8; + dst |= (0xffu & v) << 16; + + return dst; + } + + template static __device__ void RGB2HSVConvert(const float* src, D& dst) + { + const float hscale = hr * (1.f / 360.f); + + float b = src[bidx], g = src[1], r = src[bidx^2]; + float h, s, v; + + float vmin, diff; + + v = vmin = r; + v = fmax(v, g); + v = fmax(v, b); + vmin = fmin(vmin, g); + vmin = fmin(vmin, b); + + diff = v - vmin; + s = diff / (float)(::fabs(v) + numeric_limits::epsilon()); + diff = (float)(60. / (diff + numeric_limits::epsilon())); + + h = (v == r) * (g - b) * diff; + h += (v != r && v == g) * ((b - r) * diff + 120.f); + h += (v != r && v != g) * ((r - g) * diff + 240.f); + h += (h < 0) * 360.f; + + dst.x = h * hscale; + dst.y = s; + dst.z = v; + } + + template struct RGB2HSV + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2HSVConvert(&src.x, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2HSV() {} + __host__ __device__ __forceinline__ RGB2HSV(const RGB2HSV&) {} + }; + + template struct RGB2HSV : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return RGB2HSVConvert(src); + } + __host__ __device__ __forceinline__ RGB2HSV() {} + __host__ __device__ __forceinline__ RGB2HSV(const RGB2HSV&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2HSV_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HSV functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ int c_HsvSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; + + template static __device__ void HSV2RGBConvert(const T& src, float* dst) + { + const float hscale = 6.f / hr; + + float h = src.x, s = src.y, v = src.z; + float b = v, g = v, r = v; + + if (s != 0) + { + h *= hscale; + + if( h < 0 ) + do h += 6; while( h < 0 ); + else if( h >= 6 ) + do h -= 6; while( h >= 6 ); + + int sector = __float2int_rd(h); + h -= sector; + + if ( (unsigned)sector >= 6u ) + { + sector = 0; + h = 0.f; + } + + float tab[4]; + tab[0] = v; + tab[1] = v * (1.f - s); + tab[2] = v * (1.f - s * h); + tab[3] = v * (1.f - s * (1.f - h)); + + b = tab[c_HsvSectorData[sector][0]]; + g = tab[c_HsvSectorData[sector][1]]; + r = tab[c_HsvSectorData[sector][2]]; + } + + dst[bidx] = b; + dst[1] = g; + dst[bidx^2] = r; + } + + template static __device__ void HSV2RGBConvert(const T& src, uchar* dst) + { + float3 buf; + + buf.x = src.x; + buf.y = src.y * (1.f / 255.f); + buf.z = src.z * (1.f / 255.f); + + HSV2RGBConvert(buf, &buf.x); + + dst[0] = saturate_cast(buf.x * 255.f); + dst[1] = saturate_cast(buf.y * 255.f); + dst[2] = saturate_cast(buf.z * 255.f); + } + + template static __device__ uint HSV2RGBConvert(uint src) + { + float3 buf; + + buf.x = src & 0xff; + buf.y = ((src >> 8) & 0xff) * (1.f/255.f); + buf.z = ((src >> 16) & 0xff) * (1.f/255.f); + + HSV2RGBConvert(buf, &buf.x); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(buf.x * 255.f); + dst |= saturate_cast(buf.y * 255.f) << 8; + dst |= saturate_cast(buf.z * 255.f) << 16; + + return dst; + } + + template struct HSV2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + HSV2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ HSV2RGB() {} + __host__ __device__ __forceinline__ HSV2RGB(const HSV2RGB&) {} + }; + + template struct HSV2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return HSV2RGBConvert(src); + } + __host__ __device__ __forceinline__ HSV2RGB() {} + __host__ __device__ __forceinline__ HSV2RGB(const HSV2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_HSV2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HSV2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +/////////////////////////////////////// RGB <-> HLS //////////////////////////////////////// + + namespace color_detail + { + template static __device__ void RGB2HLSConvert(const float* src, D& dst) + { + const float hscale = hr * (1.f / 360.f); + + float b = src[bidx], g = src[1], r = src[bidx^2]; + float h = 0.f, s = 0.f, l; + float vmin, vmax, diff; + + vmax = vmin = r; + vmax = fmax(vmax, g); + vmax = fmax(vmax, b); + vmin = fmin(vmin, g); + vmin = fmin(vmin, b); + + diff = vmax - vmin; + l = (vmax + vmin) * 0.5f; + + if (diff > numeric_limits::epsilon()) + { + s = (l < 0.5f) * diff / (vmax + vmin); + s += (l >= 0.5f) * diff / (2.0f - vmax - vmin); + + diff = 60.f / diff; + + h = (vmax == r) * (g - b) * diff; + h += (vmax != r && vmax == g) * ((b - r) * diff + 120.f); + h += (vmax != r && vmax != g) * ((r - g) * diff + 240.f); + h += (h < 0.f) * 360.f; + } + + dst.x = h * hscale; + dst.y = l; + dst.z = s; + } + + template static __device__ void RGB2HLSConvert(const uchar* src, D& dst) + { + float3 buf; + + buf.x = src[0] * (1.f / 255.f); + buf.y = src[1] * (1.f / 255.f); + buf.z = src[2] * (1.f / 255.f); + + RGB2HLSConvert(&buf.x, buf); + + dst.x = saturate_cast(buf.x); + dst.y = saturate_cast(buf.y*255.f); + dst.z = saturate_cast(buf.z*255.f); + } + + template static __device__ uint RGB2HLSConvert(uint src) + { + float3 buf; + + buf.x = (0xff & src) * (1.f / 255.f); + buf.y = (0xff & (src >> 8)) * (1.f / 255.f); + buf.z = (0xff & (src >> 16)) * (1.f / 255.f); + + RGB2HLSConvert(&buf.x, buf); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(buf.x); + dst |= saturate_cast(buf.y * 255.f) << 8; + dst |= saturate_cast(buf.z * 255.f) << 16; + + return dst; + } + + template struct RGB2HLS + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2HLSConvert(&src.x, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2HLS() {} + __host__ __device__ __forceinline__ RGB2HLS(const RGB2HLS&) {} + }; + + template struct RGB2HLS : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return RGB2HLSConvert(src); + } + __host__ __device__ __forceinline__ RGB2HLS() {} + __host__ __device__ __forceinline__ RGB2HLS(const RGB2HLS&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2HLS_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2HLS functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ int c_HlsSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; + + template static __device__ void HLS2RGBConvert(const T& src, float* dst) + { + const float hscale = 6.0f / hr; + + float h = src.x, l = src.y, s = src.z; + float b = l, g = l, r = l; + + if (s != 0) + { + float p2 = (l <= 0.5f) * l * (1 + s); + p2 += (l > 0.5f) * (l + s - l * s); + float p1 = 2 * l - p2; + + h *= hscale; + + if( h < 0 ) + do h += 6; while( h < 0 ); + else if( h >= 6 ) + do h -= 6; while( h >= 6 ); + + int sector; + sector = __float2int_rd(h); + + h -= sector; + + float tab[4]; + tab[0] = p2; + tab[1] = p1; + tab[2] = p1 + (p2 - p1) * (1 - h); + tab[3] = p1 + (p2 - p1) * h; + + b = tab[c_HlsSectorData[sector][0]]; + g = tab[c_HlsSectorData[sector][1]]; + r = tab[c_HlsSectorData[sector][2]]; + } + + dst[bidx] = b; + dst[1] = g; + dst[bidx^2] = r; + } + + template static __device__ void HLS2RGBConvert(const T& src, uchar* dst) + { + float3 buf; + + buf.x = src.x; + buf.y = src.y * (1.f / 255.f); + buf.z = src.z * (1.f / 255.f); + + HLS2RGBConvert(buf, &buf.x); + + dst[0] = saturate_cast(buf.x * 255.f); + dst[1] = saturate_cast(buf.y * 255.f); + dst[2] = saturate_cast(buf.z * 255.f); + } + + template static __device__ uint HLS2RGBConvert(uint src) + { + float3 buf; + + buf.x = 0xff & src; + buf.y = (0xff & (src >> 8)) * (1.f / 255.f); + buf.z = (0xff & (src >> 16)) * (1.f / 255.f); + + HLS2RGBConvert(buf, &buf.x); + + uint dst = 0xffu << 24; + + dst |= saturate_cast(buf.x * 255.f); + dst |= saturate_cast(buf.y * 255.f) << 8; + dst |= saturate_cast(buf.z * 255.f) << 16; + + return dst; + } + + template struct HLS2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + HLS2RGBConvert(src, &dst.x); + setAlpha(dst, ColorChannel::max()); + + return dst; + } + __host__ __device__ __forceinline__ HLS2RGB() {} + __host__ __device__ __forceinline__ HLS2RGB(const HLS2RGB&) {} + }; + + template struct HLS2RGB : unary_function + { + __device__ __forceinline__ uint operator()(uint src) const + { + return HLS2RGBConvert(src); + } + __host__ __device__ __forceinline__ HLS2RGB() {} + __host__ __device__ __forceinline__ HLS2RGB(const HLS2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_HLS2RGB_TRAITS(name, scn, dcn, bidx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; \ + template <> struct name ## _full_traits \ + { \ + typedef ::cv::cuda::device::color_detail::HLS2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> Lab ///////////////////////////////////// + + namespace color_detail + { + enum + { + LAB_CBRT_TAB_SIZE = 1024, + GAMMA_TAB_SIZE = 1024, + lab_shift = xyz_shift, + gamma_shift = 3, + lab_shift2 = (lab_shift + gamma_shift), + LAB_CBRT_TAB_SIZE_B = (256 * 3 / 2 * (1 << gamma_shift)) + }; + + __constant__ ushort c_sRGBGammaTab_b[] = {0,1,1,2,2,3,4,4,5,6,6,7,8,8,9,10,11,11,12,13,14,15,16,17,19,20,21,22,24,25,26,28,29,31,33,34,36,38,40,41,43,45,47,49,51,54,56,58,60,63,65,68,70,73,75,78,81,83,86,89,92,95,98,101,105,108,111,115,118,121,125,129,132,136,140,144,147,151,155,160,164,168,172,176,181,185,190,194,199,204,209,213,218,223,228,233,239,244,249,255,260,265,271,277,282,288,294,300,306,312,318,324,331,337,343,350,356,363,370,376,383,390,397,404,411,418,426,433,440,448,455,463,471,478,486,494,502,510,518,527,535,543,552,560,569,578,586,595,604,613,622,631,641,650,659,669,678,688,698,707,717,727,737,747,757,768,778,788,799,809,820,831,842,852,863,875,886,897,908,920,931,943,954,966,978,990,1002,1014,1026,1038,1050,1063,1075,1088,1101,1113,1126,1139,1152,1165,1178,1192,1205,1218,1232,1245,1259,1273,1287,1301,1315,1329,1343,1357,1372,1386,1401,1415,1430,1445,1460,1475,1490,1505,1521,1536,1551,1567,1583,1598,1614,1630,1646,1662,1678,1695,1711,1728,1744,1761,1778,1794,1811,1828,1846,1863,1880,1897,1915,1933,1950,1968,1986,2004,2022,2040}; + + __device__ __forceinline__ int LabCbrt_b(int i) + { + float x = i * (1.f / (255.f * (1 << gamma_shift))); + return (1 << lab_shift2) * (x < 0.008856f ? x * 7.787f + 0.13793103448275862f : ::cbrtf(x)); + } + + template + __device__ __forceinline__ void RGB2LabConvert_b(const T& src, D& dst) + { + const int Lscale = (116 * 255 + 50) / 100; + const int Lshift = -((16 * 255 * (1 << lab_shift2) + 50) / 100); + + int B = blueIdx == 0 ? src.x : src.z; + int G = src.y; + int R = blueIdx == 0 ? src.z : src.x; + + if (srgb) + { + B = c_sRGBGammaTab_b[B]; + G = c_sRGBGammaTab_b[G]; + R = c_sRGBGammaTab_b[R]; + } + else + { + B <<= 3; + G <<= 3; + R <<= 3; + } + + int fX = LabCbrt_b(CV_DESCALE(B * 778 + G * 1541 + R * 1777, lab_shift)); + int fY = LabCbrt_b(CV_DESCALE(B * 296 + G * 2929 + R * 871, lab_shift)); + int fZ = LabCbrt_b(CV_DESCALE(B * 3575 + G * 448 + R * 73, lab_shift)); + + int L = CV_DESCALE(Lscale * fY + Lshift, lab_shift2); + int a = CV_DESCALE(500 * (fX - fY) + 128 * (1 << lab_shift2), lab_shift2); + int b = CV_DESCALE(200 * (fY - fZ) + 128 * (1 << lab_shift2), lab_shift2); + + dst.x = saturate_cast(L); + dst.y = saturate_cast(a); + dst.z = saturate_cast(b); + } + + __device__ __forceinline__ float splineInterpolate(float x, const float* tab, int n) + { + int ix = ::min(::max(int(x), 0), n-1); + x -= ix; + tab += ix * 4; + return ((tab[3] * x + tab[2]) * x + tab[1]) * x + tab[0]; + } + + __constant__ float c_sRGBGammaTab[] = {0,7.55853e-05,0.,-7.51331e-13,7.55853e-05,7.55853e-05,-2.25399e-12,3.75665e-12,0.000151171,7.55853e-05,9.01597e-12,-6.99932e-12,0.000226756,7.55853e-05,-1.1982e-11,2.41277e-12,0.000302341,7.55853e-05,-4.74369e-12,1.19001e-11,0.000377927,7.55853e-05,3.09568e-11,-2.09095e-11,0.000453512,7.55853e-05,-3.17718e-11,1.35303e-11,0.000529097,7.55853e-05,8.81905e-12,-4.10782e-12,0.000604683,7.55853e-05,-3.50439e-12,2.90097e-12,0.000680268,7.55853e-05,5.19852e-12,-7.49607e-12,0.000755853,7.55853e-05,-1.72897e-11,2.70833e-11,0.000831439,7.55854e-05,6.39602e-11,-4.26295e-11,0.000907024,7.55854e-05,-6.39282e-11,2.70193e-11,0.000982609,7.55853e-05,1.71298e-11,-7.24017e-12,0.00105819,7.55853e-05,-4.59077e-12,1.94137e-12,0.00113378,7.55853e-05,1.23333e-12,-5.25291e-13,0.00120937,7.55853e-05,-3.42545e-13,1.59799e-13,0.00128495,7.55853e-05,1.36852e-13,-1.13904e-13,0.00136054,7.55853e-05,-2.04861e-13,2.95818e-13,0.00143612,7.55853e-05,6.82594e-13,-1.06937e-12,0.00151171,7.55853e-05,-2.52551e-12,3.98166e-12,0.00158729,7.55853e-05,9.41946e-12,-1.48573e-11,0.00166288,7.55853e-05,-3.51523e-11,5.54474e-11,0.00173846,7.55854e-05,1.3119e-10,-9.0517e-11,0.00181405,7.55854e-05,-1.40361e-10,7.37899e-11,0.00188963,7.55853e-05,8.10085e-11,-8.82272e-11,0.00196522,7.55852e-05,-1.83673e-10,1.62704e-10,0.0020408,7.55853e-05,3.04438e-10,-2.13341e-10,0.00211639,7.55853e-05,-3.35586e-10,2.25e-10,0.00219197,7.55853e-05,3.39414e-10,-2.20997e-10,0.00226756,7.55853e-05,-3.23576e-10,1.93326e-10,0.00234315,7.55853e-05,2.564e-10,-8.66446e-11,0.00241873,7.55855e-05,-3.53328e-12,-7.9578e-11,0.00249432,7.55853e-05,-2.42267e-10,1.72126e-10,0.0025699,7.55853e-05,2.74111e-10,-1.43265e-10,0.00264549,7.55854e-05,-1.55683e-10,-6.47292e-11,0.00272107,7.55849e-05,-3.4987e-10,8.67842e-10,0.00279666,7.55868e-05,2.25366e-09,-3.8723e-09,0.00287224,7.55797e-05,-9.36325e-09,1.5087e-08,0.00294783,7.56063e-05,3.58978e-08,-5.69415e-08,0.00302341,7.55072e-05,-1.34927e-07,2.13144e-07,0.003099,7.58768e-05,5.04507e-07,1.38713e-07,0.00317552,7.7302e-05,9.20646e-07,-1.55186e-07,0.00325359,7.86777e-05,4.55087e-07,4.26813e-08,0.00333276,7.97159e-05,5.83131e-07,-1.06495e-08,0.00341305,8.08502e-05,5.51182e-07,3.87467e-09,0.00349446,8.19642e-05,5.62806e-07,-1.92586e-10,0.00357698,8.30892e-05,5.62228e-07,1.0866e-09,0.00366063,8.4217e-05,5.65488e-07,5.02818e-10,0.00374542,8.53494e-05,5.66997e-07,8.60211e-10,0.00383133,8.6486e-05,5.69577e-07,7.13044e-10,0.00391839,8.76273e-05,5.71716e-07,4.78527e-10,0.00400659,8.87722e-05,5.73152e-07,1.09818e-09,0.00409594,8.99218e-05,5.76447e-07,2.50964e-10,0.00418644,9.10754e-05,5.772e-07,1.15762e-09,0.00427809,9.22333e-05,5.80672e-07,2.40865e-10,0.0043709,9.33954e-05,5.81395e-07,1.13854e-09,0.00446488,9.45616e-05,5.84811e-07,3.27267e-10,0.00456003,9.57322e-05,5.85792e-07,8.1197e-10,0.00465635,9.69062e-05,5.88228e-07,6.15823e-10,0.00475384,9.80845e-05,5.90076e-07,9.15747e-10,0.00485252,9.92674e-05,5.92823e-07,3.778e-10,0.00495238,0.000100454,5.93956e-07,8.32623e-10,0.00505343,0.000101645,5.96454e-07,4.82695e-10,0.00515567,0.000102839,5.97902e-07,9.61904e-10,0.00525911,0.000104038,6.00788e-07,3.26281e-10,0.00536375,0.00010524,6.01767e-07,9.926e-10,0.00546959,0.000106447,6.04745e-07,3.59933e-10,0.00557664,0.000107657,6.05824e-07,8.2728e-10,0.0056849,0.000108871,6.08306e-07,5.21898e-10,0.00579438,0.00011009,6.09872e-07,8.10492e-10,0.00590508,0.000111312,6.12303e-07,4.27046e-10,0.00601701,0.000112538,6.13585e-07,7.40878e-10,0.00613016,0.000113767,6.15807e-07,8.00469e-10,0.00624454,0.000115001,6.18209e-07,2.48178e-10,0.00636016,0.000116238,6.18953e-07,1.00073e-09,0.00647702,0.000117479,6.21955e-07,4.05654e-10,0.00659512,0.000118724,6.23172e-07,6.36192e-10,0.00671447,0.000119973,6.25081e-07,7.74927e-10,0.00683507,0.000121225,6.27406e-07,4.54975e-10,0.00695692,0.000122481,6.28771e-07,6.64841e-10,0.00708003,0.000123741,6.30765e-07,6.10972e-10,0.00720441,0.000125004,6.32598e-07,6.16543e-10,0.00733004,0.000126271,6.34448e-07,6.48204e-10,0.00745695,0.000127542,6.36392e-07,5.15835e-10,0.00758513,0.000128816,6.3794e-07,5.48103e-10,0.00771458,0.000130094,6.39584e-07,1.01706e-09,0.00784532,0.000131376,6.42635e-07,4.0283e-11,0.00797734,0.000132661,6.42756e-07,6.84471e-10,0.00811064,0.000133949,6.4481e-07,9.47144e-10,0.00824524,0.000135241,6.47651e-07,1.83472e-10,0.00838112,0.000136537,6.48201e-07,1.11296e-09,0.00851831,0.000137837,6.5154e-07,2.13163e-11,0.0086568,0.00013914,6.51604e-07,6.64462e-10,0.00879659,0.000140445,6.53598e-07,1.04613e-09,0.00893769,0.000141756,6.56736e-07,-1.92377e-10,0.0090801,0.000143069,6.56159e-07,1.58601e-09,0.00922383,0.000144386,6.60917e-07,-5.63754e-10,0.00936888,0.000145706,6.59226e-07,1.60033e-09,0.00951524,0.000147029,6.64027e-07,-2.49543e-10,0.00966294,0.000148356,6.63278e-07,1.26043e-09,0.00981196,0.000149687,6.67059e-07,-1.35572e-10,0.00996231,0.00015102,6.66653e-07,1.14458e-09,0.010114,0.000152357,6.70086e-07,2.13864e-10,0.010267,0.000153698,6.70728e-07,7.93856e-10,0.0104214,0.000155042,6.73109e-07,3.36077e-10,0.0105771,0.000156389,6.74118e-07,6.55765e-10,0.0107342,0.000157739,6.76085e-07,7.66211e-10,0.0108926,0.000159094,6.78384e-07,4.66116e-12,0.0110524,0.000160451,6.78398e-07,1.07775e-09,0.0112135,0.000161811,6.81631e-07,3.41023e-10,0.011376,0.000163175,6.82654e-07,3.5205e-10,0.0115398,0.000164541,6.8371e-07,1.04473e-09,0.0117051,0.000165912,6.86844e-07,1.25757e-10,0.0118717,0.000167286,6.87222e-07,3.14818e-10,0.0120396,0.000168661,6.88166e-07,1.40886e-09,0.012209,0.000170042,6.92393e-07,-3.62244e-10,0.0123797,0.000171425,6.91306e-07,9.71397e-10,0.0125518,0.000172811,6.9422e-07,2.02003e-10,0.0127253,0.0001742,6.94826e-07,1.01448e-09,0.0129002,0.000175593,6.97869e-07,3.96653e-10,0.0130765,0.00017699,6.99059e-07,1.92927e-10,0.0132542,0.000178388,6.99638e-07,6.94305e-10,0.0134333,0.00017979,7.01721e-07,7.55108e-10,0.0136138,0.000181195,7.03986e-07,1.05918e-11,0.0137957,0.000182603,7.04018e-07,1.06513e-09,0.013979,0.000184015,7.07214e-07,3.85512e-10,0.0141637,0.00018543,7.0837e-07,1.86769e-10,0.0143499,0.000186848,7.0893e-07,7.30116e-10,0.0145374,0.000188268,7.11121e-07,6.17983e-10,0.0147264,0.000189692,7.12975e-07,5.23282e-10,0.0149168,0.000191119,7.14545e-07,8.28398e-11,0.0151087,0.000192549,7.14793e-07,1.0081e-09,0.0153019,0.000193981,7.17817e-07,5.41244e-10,0.0154966,0.000195418,7.19441e-07,-3.7907e-10,0.0156928,0.000196856,7.18304e-07,1.90641e-09,0.0158903,0.000198298,7.24023e-07,-7.27387e-10,0.0160893,0.000199744,7.21841e-07,1.00317e-09,0.0162898,0.000201191,7.24851e-07,4.39949e-10,0.0164917,0.000202642,7.2617e-07,9.6234e-10,0.0166951,0.000204097,7.29057e-07,-5.64019e-10,0.0168999,0.000205554,7.27365e-07,1.29374e-09,0.0171062,0.000207012,7.31247e-07,9.77025e-10,0.017314,0.000208478,7.34178e-07,-1.47651e-09,0.0175232,0.000209942,7.29748e-07,3.06636e-09,0.0177338,0.00021141,7.38947e-07,-1.47573e-09,0.017946,0.000212884,7.3452e-07,9.7386e-10,0.0181596,0.000214356,7.37442e-07,1.30562e-09,0.0183747,0.000215835,7.41358e-07,-6.08376e-10,0.0185913,0.000217315,7.39533e-07,1.12785e-09,0.0188093,0.000218798,7.42917e-07,-1.77711e-10,0.0190289,0.000220283,7.42384e-07,1.44562e-09,0.0192499,0.000221772,7.46721e-07,-1.68825e-11,0.0194724,0.000223266,7.4667e-07,4.84533e-10,0.0196964,0.000224761,7.48124e-07,-5.85298e-11,0.0199219,0.000226257,7.47948e-07,1.61217e-09,0.0201489,0.000227757,7.52785e-07,-8.02136e-10,0.0203775,0.00022926,7.50378e-07,1.59637e-09,0.0206075,0.000230766,7.55167e-07,4.47168e-12,0.020839,0.000232276,7.55181e-07,2.48387e-10,0.021072,0.000233787,7.55926e-07,8.6474e-10,0.0213066,0.000235302,7.5852e-07,1.78299e-11,0.0215426,0.000236819,7.58573e-07,9.26567e-10,0.0217802,0.000238339,7.61353e-07,1.34529e-12,0.0220193,0.000239862,7.61357e-07,9.30659e-10,0.0222599,0.000241387,7.64149e-07,1.34529e-12,0.0225021,0.000242915,7.64153e-07,9.26567e-10,0.0227458,0.000244447,7.66933e-07,1.76215e-11,0.022991,0.00024598,7.66986e-07,8.65536e-10,0.0232377,0.000247517,7.69582e-07,2.45677e-10,0.023486,0.000249057,7.70319e-07,1.44193e-11,0.0237358,0.000250598,7.70363e-07,1.55918e-09,0.0239872,0.000252143,7.7504e-07,-6.63173e-10,0.0242401,0.000253691,7.73051e-07,1.09357e-09,0.0244946,0.000255241,7.76331e-07,1.41919e-11,0.0247506,0.000256793,7.76374e-07,7.12248e-10,0.0250082,0.000258348,7.78511e-07,8.62049e-10,0.0252673,0.000259908,7.81097e-07,-4.35061e-10,0.025528,0.000261469,7.79792e-07,8.7825e-10,0.0257902,0.000263031,7.82426e-07,6.47181e-10,0.0260541,0.000264598,7.84368e-07,2.58448e-10,0.0263194,0.000266167,7.85143e-07,1.81558e-10,0.0265864,0.000267738,7.85688e-07,8.78041e-10,0.0268549,0.000269312,7.88322e-07,3.15102e-11,0.027125,0.000270889,7.88417e-07,8.58525e-10,0.0273967,0.000272468,7.90992e-07,2.59812e-10,0.02767,0.000274051,7.91772e-07,-3.5224e-11,0.0279448,0.000275634,7.91666e-07,1.74377e-09,0.0282212,0.000277223,7.96897e-07,-1.35196e-09,0.0284992,0.000278813,7.92841e-07,1.80141e-09,0.0287788,0.000280404,7.98246e-07,-2.65629e-10,0.0290601,0.000281999,7.97449e-07,1.12374e-09,0.0293428,0.000283598,8.0082e-07,-5.04106e-10,0.0296272,0.000285198,7.99308e-07,8.92764e-10,0.0299132,0.000286799,8.01986e-07,6.58379e-10,0.0302008,0.000288405,8.03961e-07,1.98971e-10,0.0304901,0.000290014,8.04558e-07,4.08382e-10,0.0307809,0.000291624,8.05783e-07,3.01839e-11,0.0310733,0.000293236,8.05874e-07,1.33343e-09,0.0313673,0.000294851,8.09874e-07,2.2419e-10,0.031663,0.000296472,8.10547e-07,-3.67606e-10,0.0319603,0.000298092,8.09444e-07,1.24624e-09,0.0322592,0.000299714,8.13182e-07,-8.92025e-10,0.0325597,0.000301338,8.10506e-07,2.32183e-09,0.0328619,0.000302966,8.17472e-07,-9.44719e-10,0.0331657,0.000304598,8.14638e-07,1.45703e-09,0.0334711,0.000306232,8.19009e-07,-1.15805e-09,0.0337781,0.000307866,8.15535e-07,3.17507e-09,0.0340868,0.000309507,8.2506e-07,-4.09161e-09,0.0343971,0.000311145,8.12785e-07,5.74079e-09,0.0347091,0.000312788,8.30007e-07,-3.97034e-09,0.0350227,0.000314436,8.18096e-07,2.68985e-09,0.035338,0.00031608,8.26166e-07,6.61676e-10,0.0356549,0.000317734,8.28151e-07,-1.61123e-09,0.0359734,0.000319386,8.23317e-07,2.05786e-09,0.0362936,0.000321038,8.29491e-07,8.30388e-10,0.0366155,0.0003227,8.31982e-07,-1.65424e-09,0.036939,0.000324359,8.27019e-07,2.06129e-09,0.0372642,0.000326019,8.33203e-07,8.59719e-10,0.0375911,0.000327688,8.35782e-07,-1.77488e-09,0.0379196,0.000329354,8.30458e-07,2.51464e-09,0.0382498,0.000331023,8.38002e-07,-8.33135e-10,0.0385817,0.000332696,8.35502e-07,8.17825e-10,0.0389152,0.00033437,8.37956e-07,1.28718e-09,0.0392504,0.00033605,8.41817e-07,-2.2413e-09,0.0395873,0.000337727,8.35093e-07,3.95265e-09,0.0399258,0.000339409,8.46951e-07,-2.39332e-09,0.0402661,0.000341095,8.39771e-07,1.89533e-09,0.040608,0.000342781,8.45457e-07,-1.46271e-09,0.0409517,0.000344467,8.41069e-07,3.95554e-09,0.041297,0.000346161,8.52936e-07,-3.18369e-09,0.041644,0.000347857,8.43385e-07,1.32873e-09,0.0419927,0.000349548,8.47371e-07,1.59402e-09,0.0423431,0.000351248,8.52153e-07,-2.54336e-10,0.0426952,0.000352951,8.5139e-07,-5.76676e-10,0.043049,0.000354652,8.4966e-07,2.56114e-09,0.0434045,0.000356359,8.57343e-07,-2.21744e-09,0.0437617,0.000358067,8.50691e-07,2.58344e-09,0.0441206,0.000359776,8.58441e-07,-6.65826e-10,0.0444813,0.000361491,8.56444e-07,7.99218e-11,0.0448436,0.000363204,8.56684e-07,3.46063e-10,0.0452077,0.000364919,8.57722e-07,2.26116e-09,0.0455734,0.000366641,8.64505e-07,-1.94005e-09,0.045941,0.000368364,8.58685e-07,1.77384e-09,0.0463102,0.000370087,8.64007e-07,-1.43005e-09,0.0466811,0.000371811,8.59717e-07,3.94634e-09,0.0470538,0.000373542,8.71556e-07,-3.17946e-09,0.0474282,0.000375276,8.62017e-07,1.32104e-09,0.0478043,0.000377003,8.6598e-07,1.62045e-09,0.0481822,0.00037874,8.70842e-07,-3.52297e-10,0.0485618,0.000380481,8.69785e-07,-2.11211e-10,0.0489432,0.00038222,8.69151e-07,1.19716e-09,0.0493263,0.000383962,8.72743e-07,-8.52026e-10,0.0497111,0.000385705,8.70187e-07,2.21092e-09,0.0500977,0.000387452,8.76819e-07,-5.41339e-10,0.050486,0.000389204,8.75195e-07,-4.5361e-11,0.0508761,0.000390954,8.75059e-07,7.22669e-10,0.0512679,0.000392706,8.77227e-07,8.79936e-10,0.0516615,0.000394463,8.79867e-07,-5.17048e-10,0.0520568,0.000396222,8.78316e-07,1.18833e-09,0.0524539,0.000397982,8.81881e-07,-5.11022e-10,0.0528528,0.000399744,8.80348e-07,8.55683e-10,0.0532534,0.000401507,8.82915e-07,8.13562e-10,0.0536558,0.000403276,8.85356e-07,-3.84603e-10,0.05406,0.000405045,8.84202e-07,7.24962e-10,0.0544659,0.000406816,8.86377e-07,1.20986e-09,0.0548736,0.000408592,8.90006e-07,-1.83896e-09,0.0552831,0.000410367,8.84489e-07,2.42071e-09,0.0556944,0.000412143,8.91751e-07,-3.93413e-10,0.0561074,0.000413925,8.90571e-07,-8.46967e-10,0.0565222,0.000415704,8.8803e-07,3.78122e-09,0.0569388,0.000417491,8.99374e-07,-3.1021e-09,0.0573572,0.000419281,8.90068e-07,1.17658e-09,0.0577774,0.000421064,8.93597e-07,2.12117e-09,0.0581993,0.000422858,8.99961e-07,-2.21068e-09,0.0586231,0.000424651,8.93329e-07,2.9961e-09,0.0590486,0.000426447,9.02317e-07,-2.32311e-09,0.059476,0.000428244,8.95348e-07,2.57122e-09,0.0599051,0.000430043,9.03062e-07,-5.11098e-10,0.0603361,0.000431847,9.01528e-07,-5.27166e-10,0.0607688,0.000433649,8.99947e-07,2.61984e-09,0.0612034,0.000435457,9.07806e-07,-2.50141e-09,0.0616397,0.000437265,9.00302e-07,3.66045e-09,0.0620779,0.000439076,9.11283e-07,-4.68977e-09,0.0625179,0.000440885,8.97214e-07,7.64783e-09,0.0629597,0.000442702,9.20158e-07,-7.27499e-09,0.0634033,0.000444521,8.98333e-07,6.55113e-09,0.0638487,0.000446337,9.17986e-07,-4.02844e-09,0.0642959,0.000448161,9.05901e-07,2.11196e-09,0.064745,0.000449979,9.12236e-07,3.03125e-09,0.0651959,0.000451813,9.2133e-07,-6.78648e-09,0.0656486,0.000453635,9.00971e-07,9.21375e-09,0.0661032,0.000455464,9.28612e-07,-7.71684e-09,0.0665596,0.000457299,9.05462e-07,6.7522e-09,0.0670178,0.00045913,9.25718e-07,-4.3907e-09,0.0674778,0.000460968,9.12546e-07,3.36e-09,0.0679397,0.000462803,9.22626e-07,-1.59876e-09,0.0684034,0.000464644,9.1783e-07,3.0351e-09,0.068869,0.000466488,9.26935e-07,-3.09101e-09,0.0693364,0.000468333,9.17662e-07,1.8785e-09,0.0698057,0.000470174,9.23298e-07,3.02733e-09,0.0702768,0.00047203,9.3238e-07,-6.53722e-09,0.0707497,0.000473875,9.12768e-07,8.22054e-09,0.0712245,0.000475725,9.37429e-07,-3.99325e-09,0.0717012,0.000477588,9.2545e-07,3.01839e-10,0.0721797,0.00047944,9.26355e-07,2.78597e-09,0.0726601,0.000481301,9.34713e-07,-3.99507e-09,0.0731423,0.000483158,9.22728e-07,5.7435e-09,0.0736264,0.000485021,9.39958e-07,-4.07776e-09,0.0741123,0.000486888,9.27725e-07,3.11695e-09,0.0746002,0.000488753,9.37076e-07,-9.39394e-10,0.0750898,0.000490625,9.34258e-07,6.4055e-10,0.0755814,0.000492495,9.3618e-07,-1.62265e-09,0.0760748,0.000494363,9.31312e-07,5.84995e-09,0.0765701,0.000496243,9.48861e-07,-6.87601e-09,0.0770673,0.00049812,9.28233e-07,6.75296e-09,0.0775664,0.000499997,9.48492e-07,-5.23467e-09,0.0780673,0.000501878,9.32788e-07,6.73523e-09,0.0785701,0.000503764,9.52994e-07,-6.80514e-09,0.0790748,0.000505649,9.32578e-07,5.5842e-09,0.0795814,0.000507531,9.49331e-07,-6.30583e-10,0.0800899,0.000509428,9.47439e-07,-3.0618e-09,0.0806003,0.000511314,9.38254e-07,5.4273e-09,0.0811125,0.000513206,9.54536e-07,-3.74627e-09,0.0816267,0.000515104,9.43297e-07,2.10713e-09,0.0821427,0.000516997,9.49618e-07,2.76839e-09,0.0826607,0.000518905,9.57924e-07,-5.73006e-09,0.0831805,0.000520803,9.40733e-07,5.25072e-09,0.0837023,0.0005227,9.56486e-07,-3.71718e-10,0.084226,0.000524612,9.5537e-07,-3.76404e-09,0.0847515,0.000526512,9.44078e-07,7.97735e-09,0.085279,0.000528424,9.6801e-07,-5.79367e-09,0.0858084,0.000530343,9.50629e-07,2.96268e-10,0.0863397,0.000532245,9.51518e-07,4.6086e-09,0.0868729,0.000534162,9.65344e-07,-3.82947e-09,0.087408,0.000536081,9.53856e-07,3.25861e-09,0.087945,0.000537998,9.63631e-07,-1.7543e-09,0.088484,0.00053992,9.58368e-07,3.75849e-09,0.0890249,0.000541848,9.69644e-07,-5.82891e-09,0.0895677,0.00054377,9.52157e-07,4.65593e-09,0.0901124,0.000545688,9.66125e-07,2.10643e-09,0.0906591,0.000547627,9.72444e-07,-5.63099e-09,0.0912077,0.000549555,9.55551e-07,5.51627e-09,0.0917582,0.000551483,9.721e-07,-1.53292e-09,0.0923106,0.000553422,9.67501e-07,6.15311e-10,0.092865,0.000555359,9.69347e-07,-9.28291e-10,0.0934213,0.000557295,9.66562e-07,3.09774e-09,0.0939796,0.000559237,9.75856e-07,-4.01186e-09,0.0945398,0.000561177,9.6382e-07,5.49892e-09,0.095102,0.000563121,9.80317e-07,-3.08258e-09,0.0956661,0.000565073,9.71069e-07,-6.19176e-10,0.0962321,0.000567013,9.69212e-07,5.55932e-09,0.0968001,0.000568968,9.8589e-07,-6.71704e-09,0.09737,0.00057092,9.65738e-07,6.40762e-09,0.0979419,0.00057287,9.84961e-07,-4.0122e-09,0.0985158,0.000574828,9.72925e-07,2.19059e-09,0.0990916,0.000576781,9.79496e-07,2.70048e-09,0.0996693,0.000578748,9.87598e-07,-5.54193e-09,0.100249,0.000580706,9.70972e-07,4.56597e-09,0.100831,0.000582662,9.8467e-07,2.17923e-09,0.101414,0.000584638,9.91208e-07,-5.83232e-09,0.102,0.000586603,9.73711e-07,6.24884e-09,0.102588,0.000588569,9.92457e-07,-4.26178e-09,0.103177,0.000590541,9.79672e-07,3.34781e-09,0.103769,0.00059251,9.89715e-07,-1.67904e-09,0.104362,0.000594485,9.84678e-07,3.36839e-09,0.104958,0.000596464,9.94783e-07,-4.34397e-09,0.105555,0.000598441,9.81751e-07,6.55696e-09,0.106155,0.000600424,1.00142e-06,-6.98272e-09,0.106756,0.000602406,9.80474e-07,6.4728e-09,0.107359,0.000604386,9.99893e-07,-4.00742e-09,0.107965,0.000606374,9.8787e-07,2.10654e-09,0.108572,0.000608356,9.9419e-07,3.0318e-09,0.109181,0.000610353,1.00329e-06,-6.7832e-09,0.109793,0.00061234,9.82936e-07,9.1998e-09,0.110406,0.000614333,1.01054e-06,-7.6642e-09,0.111021,0.000616331,9.87543e-07,6.55579e-09,0.111639,0.000618326,1.00721e-06,-3.65791e-09,0.112258,0.000620329,9.96236e-07,6.25467e-10,0.112879,0.000622324,9.98113e-07,1.15593e-09,0.113503,0.000624323,1.00158e-06,2.20158e-09,0.114128,0.000626333,1.00819e-06,-2.51191e-09,0.114755,0.000628342,1.00065e-06,3.95517e-10,0.115385,0.000630345,1.00184e-06,9.29807e-10,0.116016,0.000632351,1.00463e-06,3.33599e-09,0.116649,0.00063437,1.01463e-06,-6.82329e-09,0.117285,0.000636379,9.94163e-07,9.05595e-09,0.117922,0.000638395,1.02133e-06,-7.04862e-09,0.118562,0.000640416,1.00019e-06,4.23737e-09,0.119203,0.000642429,1.0129e-06,-2.45033e-09,0.119847,0.000644448,1.00555e-06,5.56395e-09,0.120492,0.000646475,1.02224e-06,-4.9043e-09,0.121139,0.000648505,1.00753e-06,-8.47952e-10,0.121789,0.000650518,1.00498e-06,8.29622e-09,0.122441,0.000652553,1.02987e-06,-9.98538e-09,0.123094,0.000654582,9.99914e-07,9.2936e-09,0.12375,0.00065661,1.02779e-06,-4.83707e-09,0.124407,0.000658651,1.01328e-06,2.60411e-09,0.125067,0.000660685,1.0211e-06,-5.57945e-09,0.125729,0.000662711,1.00436e-06,1.22631e-08,0.126392,0.000664756,1.04115e-06,-1.36704e-08,0.127058,0.000666798,1.00014e-06,1.26161e-08,0.127726,0.000668836,1.03798e-06,-6.99155e-09,0.128396,0.000670891,1.01701e-06,4.48836e-10,0.129068,0.000672926,1.01836e-06,5.19606e-09,0.129742,0.000674978,1.03394e-06,-6.3319e-09,0.130418,0.000677027,1.01495e-06,5.2305e-09,0.131096,0.000679073,1.03064e-06,3.11123e-10,0.131776,0.000681135,1.03157e-06,-6.47511e-09,0.132458,0.000683179,1.01215e-06,1.06882e-08,0.133142,0.000685235,1.04421e-06,-6.47519e-09,0.133829,0.000687304,1.02479e-06,3.11237e-10,0.134517,0.000689355,1.02572e-06,5.23035e-09,0.135207,0.000691422,1.04141e-06,-6.3316e-09,0.1359,0.000693486,1.02242e-06,5.19484e-09,0.136594,0.000695546,1.038e-06,4.53497e-10,0.137291,0.000697623,1.03936e-06,-7.00891e-09,0.137989,0.000699681,1.01834e-06,1.2681e-08,0.13869,0.000701756,1.05638e-06,-1.39128e-08,0.139393,0.000703827,1.01464e-06,1.31679e-08,0.140098,0.000705896,1.05414e-06,-8.95659e-09,0.140805,0.000707977,1.02727e-06,7.75742e-09,0.141514,0.000710055,1.05055e-06,-7.17182e-09,0.142225,0.000712135,1.02903e-06,6.02862e-09,0.142938,0.000714211,1.04712e-06,-2.04163e-09,0.143653,0.000716299,1.04099e-06,2.13792e-09,0.144371,0.000718387,1.04741e-06,-6.51009e-09,0.14509,0.000720462,1.02787e-06,9.00123e-09,0.145812,0.000722545,1.05488e-06,3.07523e-10,0.146535,0.000724656,1.0558e-06,-1.02312e-08,0.147261,0.000726737,1.02511e-06,1.0815e-08,0.147989,0.000728819,1.05755e-06,-3.22681e-09,0.148719,0.000730925,1.04787e-06,2.09244e-09,0.14945,0.000733027,1.05415e-06,-5.143e-09,0.150185,0.00073512,1.03872e-06,3.57844e-09,0.150921,0.000737208,1.04946e-06,5.73027e-09,0.151659,0.000739324,1.06665e-06,-1.15983e-08,0.152399,0.000741423,1.03185e-06,1.08605e-08,0.153142,0.000743519,1.06443e-06,-2.04106e-09,0.153886,0.000745642,1.05831e-06,-2.69642e-09,0.154633,0.00074775,1.05022e-06,-2.07425e-09,0.155382,0.000749844,1.044e-06,1.09934e-08,0.156133,0.000751965,1.07698e-06,-1.20972e-08,0.156886,0.000754083,1.04069e-06,7.59288e-09,0.157641,0.000756187,1.06347e-06,-3.37305e-09,0.158398,0.000758304,1.05335e-06,5.89921e-09,0.159158,0.000760428,1.07104e-06,-5.32248e-09,0.159919,0.000762554,1.05508e-06,4.8927e-10,0.160683,0.000764666,1.05654e-06,3.36547e-09,0.161448,0.000766789,1.06664e-06,9.50081e-10,0.162216,0.000768925,1.06949e-06,-7.16568e-09,0.162986,0.000771043,1.04799e-06,1.28114e-08,0.163758,0.000773177,1.08643e-06,-1.42774e-08,0.164533,0.000775307,1.0436e-06,1.44956e-08,0.165309,0.000777438,1.08708e-06,-1.39025e-08,0.166087,0.00077957,1.04538e-06,1.13118e-08,0.166868,0.000781695,1.07931e-06,-1.54224e-09,0.167651,0.000783849,1.07468e-06,-5.14312e-09,0.168436,0.000785983,1.05925e-06,7.21381e-09,0.169223,0.000788123,1.0809e-06,-8.81096e-09,0.170012,0.000790259,1.05446e-06,1.31289e-08,0.170803,0.000792407,1.09385e-06,-1.39022e-08,0.171597,0.000794553,1.05214e-06,1.26775e-08,0.172392,0.000796695,1.09018e-06,-7.00557e-09,0.17319,0.000798855,1.06916e-06,4.43796e-10,0.17399,0.000800994,1.07049e-06,5.23031e-09,0.174792,0.000803151,1.08618e-06,-6.46397e-09,0.175596,0.000805304,1.06679e-06,5.72444e-09,0.176403,0.000807455,1.08396e-06,-1.53254e-09,0.177211,0.000809618,1.07937e-06,4.05673e-10,0.178022,0.000811778,1.08058e-06,-9.01916e-11,0.178835,0.000813939,1.08031e-06,-4.49821e-11,0.17965,0.000816099,1.08018e-06,2.70234e-10,0.180467,0.00081826,1.08099e-06,-1.03603e-09,0.181286,0.000820419,1.07788e-06,3.87392e-09,0.182108,0.000822587,1.0895e-06,4.41522e-10,0.182932,0.000824767,1.09083e-06,-5.63997e-09,0.183758,0.000826932,1.07391e-06,7.21707e-09,0.184586,0.000829101,1.09556e-06,-8.32718e-09,0.185416,0.000831267,1.07058e-06,1.11907e-08,0.186248,0.000833442,1.10415e-06,-6.63336e-09,0.187083,0.00083563,1.08425e-06,4.41484e-10,0.187919,0.0008378,1.08557e-06,4.86754e-09,0.188758,0.000839986,1.10017e-06,-5.01041e-09,0.189599,0.000842171,1.08514e-06,2.72811e-10,0.190443,0.000844342,1.08596e-06,3.91916e-09,0.191288,0.000846526,1.09772e-06,-1.04819e-09,0.192136,0.000848718,1.09457e-06,2.73531e-10,0.192985,0.000850908,1.0954e-06,-4.58916e-11,0.193837,0.000853099,1.09526e-06,-9.01158e-11,0.194692,0.000855289,1.09499e-06,4.06506e-10,0.195548,0.00085748,1.09621e-06,-1.53595e-09,0.196407,0.000859668,1.0916e-06,5.73717e-09,0.197267,0.000861869,1.10881e-06,-6.51164e-09,0.19813,0.000864067,1.08928e-06,5.40831e-09,0.198995,0.000866261,1.1055e-06,-2.20401e-10,0.199863,0.000868472,1.10484e-06,-4.52652e-09,0.200732,0.000870668,1.09126e-06,3.42508e-09,0.201604,0.000872861,1.10153e-06,5.72762e-09,0.202478,0.000875081,1.11872e-06,-1.14344e-08,0.203354,0.000877284,1.08441e-06,1.02076e-08,0.204233,0.000879484,1.11504e-06,4.06355e-10,0.205113,0.000881715,1.11626e-06,-1.18329e-08,0.205996,0.000883912,1.08076e-06,1.71227e-08,0.206881,0.000886125,1.13213e-06,-1.19546e-08,0.207768,0.000888353,1.09626e-06,8.93465e-10,0.208658,0.000890548,1.09894e-06,8.38062e-09,0.209549,0.000892771,1.12408e-06,-4.61353e-09,0.210443,0.000895006,1.11024e-06,-4.82756e-09,0.211339,0.000897212,1.09576e-06,9.02245e-09,0.212238,0.00089943,1.12283e-06,-1.45997e-09,0.213138,0.000901672,1.11845e-06,-3.18255e-09,0.214041,0.000903899,1.1089e-06,-7.11073e-10,0.214946,0.000906115,1.10677e-06,6.02692e-09,0.215853,0.000908346,1.12485e-06,-8.49548e-09,0.216763,0.00091057,1.09936e-06,1.30537e-08,0.217675,0.000912808,1.13852e-06,-1.3917e-08,0.218588,0.000915044,1.09677e-06,1.28121e-08,0.219505,0.000917276,1.13521e-06,-7.5288e-09,0.220423,0.000919523,1.11262e-06,2.40205e-09,0.221344,0.000921756,1.11983e-06,-2.07941e-09,0.222267,0.000923989,1.11359e-06,5.91551e-09,0.223192,0.000926234,1.13134e-06,-6.68149e-09,0.224119,0.000928477,1.11129e-06,5.90929e-09,0.225049,0.000930717,1.12902e-06,-2.05436e-09,0.22598,0.000932969,1.12286e-06,2.30807e-09,0.226915,0.000935222,1.12978e-06,-7.17796e-09,0.227851,0.00093746,1.10825e-06,1.15028e-08,0.228789,0.000939711,1.14276e-06,-9.03083e-09,0.22973,0.000941969,1.11566e-06,9.71932e-09,0.230673,0.00094423,1.14482e-06,-1.49452e-08,0.231619,0.000946474,1.09998e-06,2.02591e-08,0.232566,0.000948735,1.16076e-06,-2.13879e-08,0.233516,0.000950993,1.0966e-06,2.05888e-08,0.234468,0.000953247,1.15837e-06,-1.62642e-08,0.235423,0.000955515,1.10957e-06,1.46658e-08,0.236379,0.000957779,1.15357e-06,-1.25966e-08,0.237338,0.000960048,1.11578e-06,5.91793e-09,0.238299,0.000962297,1.13353e-06,3.82602e-09,0.239263,0.000964576,1.14501e-06,-6.3208e-09,0.240229,0.000966847,1.12605e-06,6.55613e-09,0.241197,0.000969119,1.14572e-06,-5.00268e-09,0.242167,0.000971395,1.13071e-06,-1.44659e-09,0.243139,0.000973652,1.12637e-06,1.07891e-08,0.244114,0.000975937,1.15874e-06,-1.19073e-08,0.245091,0.000978219,1.12302e-06,7.03782e-09,0.246071,0.000980486,1.14413e-06,-1.34276e-09,0.247052,0.00098277,1.1401e-06,-1.66669e-09,0.248036,0.000985046,1.1351e-06,8.00935e-09,0.249022,0.00098734,1.15913e-06,-1.54694e-08,0.250011,0.000989612,1.11272e-06,2.4066e-08,0.251002,0.000991909,1.18492e-06,-2.11901e-08,0.251995,0.000994215,1.12135e-06,1.08973e-09,0.25299,0.000996461,1.12462e-06,1.68311e-08,0.253988,0.000998761,1.17511e-06,-8.8094e-09,0.254987,0.00100109,1.14868e-06,-1.13958e-08,0.25599,0.00100335,1.1145e-06,2.45902e-08,0.256994,0.00100565,1.18827e-06,-2.73603e-08,0.258001,0.00100795,1.10618e-06,2.52464e-08,0.25901,0.00101023,1.18192e-06,-1.40207e-08,0.260021,0.00101256,1.13986e-06,1.03387e-09,0.261035,0.00101484,1.14296e-06,9.8853e-09,0.262051,0.00101715,1.17262e-06,-1.07726e-08,0.263069,0.00101947,1.1403e-06,3.40272e-09,0.26409,0.00102176,1.15051e-06,-2.83827e-09,0.265113,0.00102405,1.142e-06,7.95039e-09,0.266138,0.00102636,1.16585e-06,8.39047e-10,0.267166,0.00102869,1.16836e-06,-1.13066e-08,0.268196,0.00103099,1.13444e-06,1.4585e-08,0.269228,0.00103331,1.1782e-06,-1.72314e-08,0.270262,0.00103561,1.1265e-06,2.45382e-08,0.271299,0.00103794,1.20012e-06,-2.13166e-08,0.272338,0.00104028,1.13617e-06,1.12364e-09,0.273379,0.00104255,1.13954e-06,1.68221e-08,0.274423,0.00104488,1.19001e-06,-8.80736e-09,0.275469,0.00104723,1.16358e-06,-1.13948e-08,0.276518,0.00104953,1.1294e-06,2.45839e-08,0.277568,0.00105186,1.20315e-06,-2.73361e-08,0.278621,0.00105418,1.12114e-06,2.51559e-08,0.279677,0.0010565,1.19661e-06,-1.36832e-08,0.280734,0.00105885,1.15556e-06,-2.25706e-10,0.281794,0.00106116,1.15488e-06,1.45862e-08,0.282857,0.00106352,1.19864e-06,-2.83167e-08,0.283921,0.00106583,1.11369e-06,3.90759e-08,0.284988,0.00106817,1.23092e-06,-3.85801e-08,0.286058,0.00107052,1.11518e-06,2.58375e-08,0.287129,0.00107283,1.19269e-06,-5.16498e-09,0.288203,0.0010752,1.1772e-06,-5.17768e-09,0.28928,0.00107754,1.16167e-06,-3.92671e-09,0.290358,0.00107985,1.14988e-06,2.08846e-08,0.29144,0.00108221,1.21254e-06,-2.00072e-08,0.292523,0.00108458,1.15252e-06,-4.60659e-10,0.293609,0.00108688,1.15114e-06,2.18499e-08,0.294697,0.00108925,1.21669e-06,-2.73343e-08,0.295787,0.0010916,1.13468e-06,2.78826e-08,0.29688,0.00109395,1.21833e-06,-2.45915e-08,0.297975,0.00109632,1.14456e-06,1.08787e-08,0.299073,0.00109864,1.17719e-06,1.08788e-08,0.300172,0.00110102,1.20983e-06,-2.45915e-08,0.301275,0.00110337,1.13605e-06,2.78828e-08,0.302379,0.00110573,1.2197e-06,-2.73348e-08,0.303486,0.00110808,1.1377e-06,2.18518e-08,0.304595,0.00111042,1.20325e-06,-4.67556e-10,0.305707,0.00111283,1.20185e-06,-1.99816e-08,0.306821,0.00111517,1.14191e-06,2.07891e-08,0.307937,0.00111752,1.20427e-06,-3.57026e-09,0.309056,0.00111992,1.19356e-06,-6.50797e-09,0.310177,0.00112228,1.17404e-06,-2.00165e-10,0.3113,0.00112463,1.17344e-06,7.30874e-09,0.312426,0.001127,1.19536e-06,7.67424e-10,0.313554,0.00112939,1.19767e-06,-1.03784e-08,0.314685,0.00113176,1.16653e-06,1.09437e-08,0.315818,0.00113412,1.19936e-06,-3.59406e-09,0.316953,0.00113651,1.18858e-06,3.43251e-09,0.318091,0.0011389,1.19888e-06,-1.0136e-08,0.319231,0.00114127,1.16847e-06,7.30915e-09,0.320374,0.00114363,1.1904e-06,1.07018e-08,0.321518,0.00114604,1.2225e-06,-2.03137e-08,0.322666,0.00114842,1.16156e-06,1.09484e-08,0.323815,0.00115078,1.19441e-06,6.32224e-09,0.324967,0.00115319,1.21337e-06,-6.43509e-09,0.326122,0.00115559,1.19407e-06,-1.03842e-08,0.327278,0.00115795,1.16291e-06,1.81697e-08,0.328438,0.00116033,1.21742e-06,-2.6901e-09,0.329599,0.00116276,1.20935e-06,-7.40939e-09,0.330763,0.00116515,1.18713e-06,2.52533e-09,0.331929,0.00116754,1.1947e-06,-2.69191e-09,0.333098,0.00116992,1.18663e-06,8.24218e-09,0.334269,0.00117232,1.21135e-06,-4.74377e-10,0.335443,0.00117474,1.20993e-06,-6.34471e-09,0.336619,0.00117714,1.1909e-06,-3.94922e-09,0.337797,0.00117951,1.17905e-06,2.21417e-08,0.338978,0.00118193,1.24547e-06,-2.50128e-08,0.340161,0.00118435,1.17043e-06,1.8305e-08,0.341346,0.00118674,1.22535e-06,-1.84048e-08,0.342534,0.00118914,1.17013e-06,2.55121e-08,0.343725,0.00119156,1.24667e-06,-2.40389e-08,0.344917,0.00119398,1.17455e-06,1.10389e-08,0.346113,0.00119636,1.20767e-06,9.68574e-09,0.34731,0.0011988,1.23673e-06,-1.99797e-08,0.34851,0.00120122,1.17679e-06,1.06284e-08,0.349713,0.0012036,1.20867e-06,7.26868e-09,0.350917,0.00120604,1.23048e-06,-9.90072e-09,0.352125,0.00120847,1.20078e-06,2.53177e-09,0.353334,0.00121088,1.20837e-06,-2.26199e-10,0.354546,0.0012133,1.20769e-06,-1.62705e-09,0.355761,0.00121571,1.20281e-06,6.73435e-09,0.356978,0.00121813,1.22302e-06,4.49207e-09,0.358197,0.00122059,1.23649e-06,-2.47027e-08,0.359419,0.00122299,1.16238e-06,3.47142e-08,0.360643,0.00122542,1.26653e-06,-2.47472e-08,0.36187,0.00122788,1.19229e-06,4.66965e-09,0.363099,0.00123028,1.20629e-06,6.06872e-09,0.36433,0.00123271,1.2245e-06,8.57729e-10,0.365564,0.00123516,1.22707e-06,-9.49952e-09,0.366801,0.00123759,1.19858e-06,7.33792e-09,0.36804,0.00124001,1.22059e-06,9.95025e-09,0.369281,0.00124248,1.25044e-06,-1.73366e-08,0.370525,0.00124493,1.19843e-06,-2.08464e-10,0.371771,0.00124732,1.1978e-06,1.81704e-08,0.373019,0.00124977,1.25232e-06,-1.28683e-08,0.37427,0.00125224,1.21371e-06,3.50042e-09,0.375524,0.00125468,1.22421e-06,-1.1335e-09,0.37678,0.00125712,1.22081e-06,1.03345e-09,0.378038,0.00125957,1.22391e-06,-3.00023e-09,0.379299,0.00126201,1.21491e-06,1.09676e-08,0.380562,0.00126447,1.24781e-06,-1.10676e-08,0.381828,0.00126693,1.21461e-06,3.50042e-09,0.383096,0.00126937,1.22511e-06,-2.93403e-09,0.384366,0.00127181,1.21631e-06,8.23574e-09,0.385639,0.00127427,1.24102e-06,-2.06607e-10,0.386915,0.00127675,1.2404e-06,-7.40935e-09,0.388193,0.00127921,1.21817e-06,4.1761e-11,0.389473,0.00128165,1.21829e-06,7.24223e-09,0.390756,0.0012841,1.24002e-06,7.91564e-10,0.392042,0.00128659,1.2424e-06,-1.04086e-08,0.393329,0.00128904,1.21117e-06,1.10405e-08,0.39462,0.0012915,1.24429e-06,-3.951e-09,0.395912,0.00129397,1.23244e-06,4.7634e-09,0.397208,0.00129645,1.24673e-06,-1.51025e-08,0.398505,0.0012989,1.20142e-06,2.58443e-08,0.399805,0.00130138,1.27895e-06,-2.86702e-08,0.401108,0.00130385,1.19294e-06,2.92318e-08,0.402413,0.00130632,1.28064e-06,-2.86524e-08,0.403721,0.0013088,1.19468e-06,2.57731e-08,0.405031,0.00131127,1.272e-06,-1.48355e-08,0.406343,0.00131377,1.2275e-06,3.76652e-09,0.407658,0.00131623,1.23879e-06,-2.30784e-10,0.408976,0.00131871,1.2381e-06,-2.84331e-09,0.410296,0.00132118,1.22957e-06,1.16041e-08,0.411618,0.00132367,1.26438e-06,-1.37708e-08,0.412943,0.00132616,1.22307e-06,1.36768e-08,0.41427,0.00132865,1.2641e-06,-1.1134e-08,0.4156,0.00133114,1.2307e-06,1.05714e-09,0.416933,0.00133361,1.23387e-06,6.90538e-09,0.418267,0.00133609,1.25459e-06,1.12372e-09,0.419605,0.00133861,1.25796e-06,-1.14002e-08,0.420945,0.00134109,1.22376e-06,1.46747e-08,0.422287,0.00134358,1.26778e-06,-1.7496e-08,0.423632,0.00134606,1.21529e-06,2.5507e-08,0.424979,0.00134857,1.29182e-06,-2.49272e-08,0.426329,0.00135108,1.21703e-06,1.45972e-08,0.427681,0.00135356,1.26083e-06,-3.65935e-09,0.429036,0.00135607,1.24985e-06,4.00178e-11,0.430393,0.00135857,1.24997e-06,3.49917e-09,0.431753,0.00136108,1.26047e-06,-1.40366e-08,0.433116,0.00136356,1.21836e-06,2.28448e-08,0.43448,0.00136606,1.28689e-06,-1.77378e-08,0.435848,0.00136858,1.23368e-06,1.83043e-08,0.437218,0.0013711,1.28859e-06,-2.56769e-08,0.43859,0.0013736,1.21156e-06,2.47987e-08,0.439965,0.0013761,1.28595e-06,-1.39133e-08,0.441342,0.00137863,1.24421e-06,1.05202e-09,0.442722,0.00138112,1.24737e-06,9.70507e-09,0.444104,0.00138365,1.27649e-06,-1.00698e-08,0.445489,0.00138617,1.24628e-06,7.72123e-10,0.446877,0.00138867,1.24859e-06,6.98132e-09,0.448267,0.00139118,1.26954e-06,1.10477e-09,0.449659,0.00139373,1.27285e-06,-1.14003e-08,0.451054,0.00139624,1.23865e-06,1.4694e-08,0.452452,0.00139876,1.28273e-06,-1.75734e-08,0.453852,0.00140127,1.23001e-06,2.5797e-08,0.455254,0.00140381,1.3074e-06,-2.60097e-08,0.456659,0.00140635,1.22937e-06,1.86371e-08,0.458067,0.00140886,1.28529e-06,-1.8736e-08,0.459477,0.00141137,1.22908e-06,2.65048e-08,0.46089,0.00141391,1.30859e-06,-2.76784e-08,0.462305,0.00141645,1.22556e-06,2.46043e-08,0.463722,0.00141897,1.29937e-06,-1.11341e-08,0.465143,0.00142154,1.26597e-06,-9.87033e-09,0.466565,0.00142404,1.23636e-06,2.08131e-08,0.467991,0.00142657,1.2988e-06,-1.37773e-08,0.469419,0.00142913,1.25746e-06,4.49378e-09,0.470849,0.00143166,1.27094e-06,-4.19781e-09,0.472282,0.00143419,1.25835e-06,1.22975e-08,0.473717,0.00143674,1.29524e-06,-1.51902e-08,0.475155,0.00143929,1.24967e-06,1.86608e-08,0.476596,0.00144184,1.30566e-06,-2.96506e-08,0.478039,0.00144436,1.2167e-06,4.03368e-08,0.479485,0.00144692,1.33771e-06,-4.22896e-08,0.480933,0.00144947,1.21085e-06,3.94148e-08,0.482384,0.00145201,1.32909e-06,-2.59626e-08,0.483837,0.00145459,1.2512e-06,4.83124e-09,0.485293,0.0014571,1.2657e-06,6.63757e-09,0.486751,0.00145966,1.28561e-06,-1.57911e-09,0.488212,0.00146222,1.28087e-06,-3.21468e-10,0.489676,0.00146478,1.27991e-06,2.86517e-09,0.491142,0.00146735,1.2885e-06,-1.11392e-08,0.49261,0.00146989,1.25508e-06,1.18893e-08,0.494081,0.00147244,1.29075e-06,-6.61574e-09,0.495555,0.001475,1.27091e-06,1.45736e-08,0.497031,0.00147759,1.31463e-06,-2.18759e-08,0.49851,0.00148015,1.249e-06,1.33252e-08,0.499992,0.00148269,1.28897e-06,-1.62277e-09,0.501476,0.00148526,1.28411e-06,-6.83421e-09,0.502962,0.00148781,1.2636e-06,2.89596e-08,0.504451,0.00149042,1.35048e-06,-4.93997e-08,0.505943,0.00149298,1.20228e-06,4.94299e-08,0.507437,0.00149553,1.35057e-06,-2.91107e-08,0.508934,0.00149814,1.26324e-06,7.40848e-09,0.510434,0.00150069,1.28547e-06,-5.23187e-10,0.511936,0.00150326,1.2839e-06,-5.31585e-09,0.51344,0.00150581,1.26795e-06,2.17866e-08,0.514947,0.00150841,1.33331e-06,-2.22257e-08,0.516457,0.00151101,1.26663e-06,7.51178e-09,0.517969,0.00151357,1.28917e-06,-7.82128e-09,0.519484,0.00151613,1.2657e-06,2.37733e-08,0.521002,0.00151873,1.33702e-06,-2.76674e-08,0.522522,0.00152132,1.25402e-06,2.72917e-08,0.524044,0.00152391,1.3359e-06,-2.18949e-08,0.525569,0.00152652,1.27021e-06,6.83372e-10,0.527097,0.00152906,1.27226e-06,1.91613e-08,0.528628,0.00153166,1.32974e-06,-1.77241e-08,0.53016,0.00153427,1.27657e-06,-7.86963e-09,0.531696,0.0015368,1.25296e-06,4.92027e-08,0.533234,0.00153945,1.40057e-06,-6.9732e-08,0.534775,0.00154204,1.19138e-06,5.09114e-08,0.536318,0.00154458,1.34411e-06,-1.4704e-08,0.537864,0.00154722,1.3e-06,7.9048e-09,0.539413,0.00154984,1.32371e-06,-1.69152e-08,0.540964,0.00155244,1.27297e-06,1.51355e-10,0.542517,0.00155499,1.27342e-06,1.63099e-08,0.544074,0.00155758,1.32235e-06,-5.78647e-09,0.545633,0.00156021,1.30499e-06,6.83599e-09,0.547194,0.00156284,1.3255e-06,-2.15575e-08,0.548758,0.00156543,1.26083e-06,1.97892e-08,0.550325,0.00156801,1.32019e-06,2.00525e-09,0.551894,0.00157065,1.32621e-06,-2.78103e-08,0.553466,0.00157322,1.24278e-06,4.96314e-08,0.555041,0.00157586,1.39167e-06,-5.1506e-08,0.556618,0.00157849,1.23716e-06,3.71835e-08,0.558198,0.00158107,1.34871e-06,-3.76233e-08,0.55978,0.00158366,1.23584e-06,5.37052e-08,0.561365,0.00158629,1.39695e-06,-5.79884e-08,0.562953,0.00158891,1.22299e-06,5.90392e-08,0.564543,0.00159153,1.4001e-06,-5.89592e-08,0.566136,0.00159416,1.22323e-06,5.7588e-08,0.567731,0.00159678,1.39599e-06,-5.21835e-08,0.569329,0.00159941,1.23944e-06,3.19369e-08,0.57093,0.00160199,1.33525e-06,-1.59594e-08,0.572533,0.00160461,1.28737e-06,3.19006e-08,0.574139,0.00160728,1.38307e-06,-5.20383e-08,0.575748,0.00160989,1.22696e-06,5.70431e-08,0.577359,0.00161251,1.39809e-06,-5.69247e-08,0.578973,0.00161514,1.22731e-06,5.14463e-08,0.580589,0.00161775,1.38165e-06,-2.9651e-08,0.582208,0.00162042,1.2927e-06,7.55339e-09,0.58383,0.00162303,1.31536e-06,-5.62636e-10,0.585455,0.00162566,1.31367e-06,-5.30281e-09,0.587081,0.00162827,1.29776e-06,2.17738e-08,0.588711,0.00163093,1.36309e-06,-2.21875e-08,0.590343,0.00163359,1.29652e-06,7.37164e-09,0.591978,0.00163621,1.31864e-06,-7.29907e-09,0.593616,0.00163882,1.29674e-06,2.18247e-08,0.595256,0.00164148,1.36221e-06,-2.03952e-08,0.596899,0.00164414,1.30103e-06,1.51241e-10,0.598544,0.00164675,1.30148e-06,1.97902e-08,0.600192,0.00164941,1.36085e-06,-1.97074e-08,0.601843,0.00165207,1.30173e-06,-5.65175e-10,0.603496,0.00165467,1.30004e-06,2.1968e-08,0.605152,0.00165734,1.36594e-06,-2.77024e-08,0.606811,0.00165999,1.28283e-06,2.92369e-08,0.608472,0.00166264,1.37054e-06,-2.96407e-08,0.610136,0.00166529,1.28162e-06,2.97215e-08,0.611803,0.00166795,1.37079e-06,-2.96408e-08,0.613472,0.0016706,1.28186e-06,2.92371e-08,0.615144,0.00167325,1.36957e-06,-2.77031e-08,0.616819,0.00167591,1.28647e-06,2.19708e-08,0.618496,0.00167855,1.35238e-06,-5.75407e-10,0.620176,0.00168125,1.35065e-06,-1.9669e-08,0.621858,0.00168389,1.29164e-06,1.96468e-08,0.623544,0.00168653,1.35058e-06,6.86403e-10,0.625232,0.00168924,1.35264e-06,-2.23924e-08,0.626922,0.00169187,1.28547e-06,2.92788e-08,0.628615,0.00169453,1.3733e-06,-3.51181e-08,0.630311,0.00169717,1.26795e-06,5.15889e-08,0.63201,0.00169987,1.42272e-06,-5.2028e-08,0.633711,0.00170255,1.26663e-06,3.73139e-08,0.635415,0.0017052,1.37857e-06,-3.76227e-08,0.637121,0.00170784,1.2657e-06,5.35722e-08,0.63883,0.00171054,1.42642e-06,-5.74567e-08,0.640542,0.00171322,1.25405e-06,5.70456e-08,0.642257,0.0017159,1.42519e-06,-5.15163e-08,0.643974,0.00171859,1.27064e-06,2.98103e-08,0.645694,0.00172122,1.36007e-06,-8.12016e-09,0.647417,0.00172392,1.33571e-06,2.67039e-09,0.649142,0.0017266,1.34372e-06,-2.56152e-09,0.65087,0.00172928,1.33604e-06,7.57571e-09,0.6526,0.00173197,1.35876e-06,-2.77413e-08,0.654334,0.00173461,1.27554e-06,4.3785e-08,0.65607,0.00173729,1.40689e-06,-2.81896e-08,0.657808,0.00174002,1.32233e-06,9.36893e-09,0.65955,0.00174269,1.35043e-06,-9.28617e-09,0.661294,0.00174536,1.32257e-06,2.77757e-08,0.66304,0.00174809,1.4059e-06,-4.2212e-08,0.66479,0.00175078,1.27926e-06,2.1863e-08,0.666542,0.0017534,1.34485e-06,1.43648e-08,0.668297,0.00175613,1.38795e-06,-1.97177e-08,0.670054,0.00175885,1.3288e-06,4.90115e-09,0.671814,0.00176152,1.3435e-06,1.13232e-10,0.673577,0.00176421,1.34384e-06,-5.3542e-09,0.675343,0.00176688,1.32778e-06,2.13035e-08,0.677111,0.0017696,1.39169e-06,-2.02553e-08,0.678882,0.00177232,1.33092e-06,1.13005e-10,0.680656,0.00177499,1.33126e-06,1.98031e-08,0.682432,0.00177771,1.39067e-06,-1.97211e-08,0.684211,0.00178043,1.33151e-06,-5.2349e-10,0.685993,0.00178309,1.32994e-06,2.18151e-08,0.687777,0.00178582,1.39538e-06,-2.71325e-08,0.689564,0.00178853,1.31398e-06,2.71101e-08,0.691354,0.00179124,1.39531e-06,-2.17035e-08,0.693147,0.00179396,1.3302e-06,9.92865e-11,0.694942,0.00179662,1.3305e-06,2.13063e-08,0.69674,0.00179935,1.39442e-06,-2.57198e-08,0.698541,0.00180206,1.31726e-06,2.19682e-08,0.700344,0.00180476,1.38317e-06,-2.54852e-09,0.70215,0.00180752,1.37552e-06,-1.17741e-08,0.703959,0.00181023,1.3402e-06,-9.95999e-09,0.705771,0.00181288,1.31032e-06,5.16141e-08,0.707585,0.00181566,1.46516e-06,-7.72869e-08,0.709402,0.00181836,1.2333e-06,7.87197e-08,0.711222,0.00182106,1.46946e-06,-5.87781e-08,0.713044,0.00182382,1.29312e-06,3.71834e-08,0.714869,0.00182652,1.40467e-06,-3.03511e-08,0.716697,0.00182924,1.31362e-06,2.46161e-08,0.718528,0.00183194,1.38747e-06,-8.5087e-09,0.720361,0.00183469,1.36194e-06,9.41892e-09,0.722197,0.00183744,1.3902e-06,-2.91671e-08,0.724036,0.00184014,1.3027e-06,4.76448e-08,0.725878,0.00184288,1.44563e-06,-4.22028e-08,0.727722,0.00184565,1.31902e-06,1.95682e-09,0.729569,0.00184829,1.3249e-06,3.43754e-08,0.731419,0.00185104,1.42802e-06,-2.0249e-08,0.733271,0.00185384,1.36727e-06,-1.29838e-08,0.735126,0.00185654,1.32832e-06,1.25794e-08,0.736984,0.00185923,1.36606e-06,2.22711e-08,0.738845,0.00186203,1.43287e-06,-4.20594e-08,0.740708,0.00186477,1.3067e-06,2.67571e-08,0.742574,0.00186746,1.38697e-06,-5.36424e-09,0.744443,0.00187022,1.37087e-06,-5.30023e-09,0.746315,0.00187295,1.35497e-06,2.65653e-08,0.748189,0.00187574,1.43467e-06,-4.13564e-08,0.750066,0.00187848,1.3106e-06,1.9651e-08,0.751946,0.00188116,1.36955e-06,2.23572e-08,0.753828,0.00188397,1.43663e-06,-4.9475e-08,0.755714,0.00188669,1.2882e-06,5.63335e-08,0.757602,0.00188944,1.4572e-06,-5.66499e-08,0.759493,0.00189218,1.28725e-06,5.10567e-08,0.761386,0.00189491,1.44042e-06,-2.83677e-08,0.763283,0.00189771,1.35532e-06,2.80962e-09,0.765182,0.00190042,1.36375e-06,1.71293e-08,0.767083,0.0019032,1.41513e-06,-1.17221e-08,0.768988,0.001906,1.37997e-06,-2.98453e-08,0.770895,0.00190867,1.29043e-06,7.14987e-08,0.772805,0.00191146,1.50493e-06,-7.73354e-08,0.774718,0.00191424,1.27292e-06,5.90292e-08,0.776634,0.00191697,1.45001e-06,-3.9572e-08,0.778552,0.00191975,1.33129e-06,3.9654e-08,0.780473,0.00192253,1.45026e-06,-5.94395e-08,0.782397,0.00192525,1.27194e-06,7.88945e-08,0.784324,0.00192803,1.50862e-06,-7.73249e-08,0.786253,0.00193082,1.27665e-06,5.15913e-08,0.788185,0.00193352,1.43142e-06,-9.83099e-09,0.79012,0.00193636,1.40193e-06,-1.22672e-08,0.792058,0.00193912,1.36513e-06,-7.05275e-10,0.793999,0.00194185,1.36301e-06,1.50883e-08,0.795942,0.00194462,1.40828e-06,-4.33147e-11,0.797888,0.00194744,1.40815e-06,-1.49151e-08,0.799837,0.00195021,1.3634e-06,9.93244e-11,0.801788,0.00195294,1.3637e-06,1.45179e-08,0.803743,0.00195571,1.40725e-06,1.43363e-09,0.8057,0.00195853,1.41155e-06,-2.02525e-08,0.80766,0.00196129,1.35079e-06,1.99718e-08,0.809622,0.00196405,1.41071e-06,-3.01649e-11,0.811588,0.00196687,1.41062e-06,-1.9851e-08,0.813556,0.00196964,1.35107e-06,1.98296e-08,0.815527,0.0019724,1.41056e-06,1.37485e-10,0.817501,0.00197522,1.41097e-06,-2.03796e-08,0.819477,0.00197798,1.34983e-06,2.17763e-08,0.821457,0.00198074,1.41516e-06,-7.12085e-09,0.823439,0.00198355,1.3938e-06,6.70707e-09,0.825424,0.00198636,1.41392e-06,-1.97074e-08,0.827412,0.00198913,1.35479e-06,1.25179e-08,0.829402,0.00199188,1.39235e-06,2.92405e-08,0.831396,0.00199475,1.48007e-06,-6.98755e-08,0.833392,0.0019975,1.27044e-06,7.14477e-08,0.835391,0.00200026,1.48479e-06,-3.71014e-08,0.837392,0.00200311,1.37348e-06,1.73533e-08,0.839397,0.00200591,1.42554e-06,-3.23118e-08,0.841404,0.00200867,1.32861e-06,5.2289e-08,0.843414,0.00201148,1.48547e-06,-5.76348e-08,0.845427,0.00201428,1.31257e-06,5.9041e-08,0.847443,0.00201708,1.48969e-06,-5.93197e-08,0.849461,0.00201988,1.31173e-06,5.90289e-08,0.851482,0.00202268,1.48882e-06,-5.75864e-08,0.853507,0.00202549,1.31606e-06,5.21075e-08,0.855533,0.00202828,1.47238e-06,-3.16344e-08,0.857563,0.00203113,1.37748e-06,1.48257e-08,0.859596,0.00203393,1.42196e-06,-2.76684e-08,0.861631,0.00203669,1.33895e-06,3.62433e-08,0.863669,0.00203947,1.44768e-06,1.90463e-09,0.86571,0.00204237,1.45339e-06,-4.38617e-08,0.867754,0.00204515,1.32181e-06,5.43328e-08,0.8698,0.00204796,1.48481e-06,-5.42603e-08,0.87185,0.00205076,1.32203e-06,4.34989e-08,0.873902,0.00205354,1.45252e-06,-5.26029e-10,0.875957,0.00205644,1.45095e-06,-4.13949e-08,0.878015,0.00205922,1.32676e-06,4.68962e-08,0.880075,0.00206201,1.46745e-06,-2.69807e-08,0.882139,0.00206487,1.38651e-06,1.42181e-09,0.884205,0.00206764,1.39077e-06,2.12935e-08,0.886274,0.00207049,1.45465e-06,-2.69912e-08,0.888346,0.00207332,1.37368e-06,2.70664e-08,0.890421,0.00207615,1.45488e-06,-2.16698e-08,0.892498,0.00207899,1.38987e-06,8.14756e-12,0.894579,0.00208177,1.38989e-06,2.16371e-08,0.896662,0.00208462,1.45481e-06,-2.6952e-08,0.898748,0.00208744,1.37395e-06,2.65663e-08,0.900837,0.00209027,1.45365e-06,-1.97084e-08,0.902928,0.00209312,1.39452e-06,-7.33731e-09,0.905023,0.00209589,1.37251e-06,4.90578e-08,0.90712,0.00209878,1.51968e-06,-6.96845e-08,0.90922,0.00210161,1.31063e-06,5.08664e-08,0.911323,0.00210438,1.46323e-06,-1.45717e-08,0.913429,0.00210727,1.41952e-06,7.42038e-09,0.915538,0.00211013,1.44178e-06,-1.51097e-08,0.917649,0.00211297,1.39645e-06,-6.58618e-09,0.919764,0.00211574,1.37669e-06,4.14545e-08,0.921881,0.00211862,1.50105e-06,-4.00222e-08,0.924001,0.0021215,1.38099e-06,-5.7518e-10,0.926124,0.00212426,1.37926e-06,4.23229e-08,0.92825,0.00212714,1.50623e-06,-4.9507e-08,0.930378,0.00213001,1.35771e-06,3.64958e-08,0.93251,0.00213283,1.4672e-06,-3.68713e-08,0.934644,0.00213566,1.35658e-06,5.13848e-08,0.936781,0.00213852,1.51074e-06,-4.94585e-08,0.938921,0.0021414,1.36236e-06,2.72399e-08,0.941064,0.0021442,1.44408e-06,1.0372e-10,0.943209,0.00214709,1.44439e-06,-2.76547e-08,0.945358,0.0021499,1.36143e-06,5.09106e-08,0.947509,0.00215277,1.51416e-06,-5.67784e-08,0.949663,0.00215563,1.34382e-06,5.69935e-08,0.95182,0.00215849,1.5148e-06,-5.19861e-08,0.95398,0.00216136,1.35885e-06,3.17417e-08,0.956143,0.00216418,1.45407e-06,-1.53758e-08,0.958309,0.00216704,1.40794e-06,2.97615e-08,0.960477,0.00216994,1.49723e-06,-4.40657e-08,0.962649,0.00217281,1.36503e-06,2.72919e-08,0.964823,0.00217562,1.44691e-06,-5.49729e-09,0.967,0.0021785,1.43041e-06,-5.30273e-09,0.96918,0.00218134,1.41451e-06,2.67084e-08,0.971363,0.00218425,1.49463e-06,-4.19265e-08,0.973548,0.00218711,1.36885e-06,2.17881e-08,0.975737,0.00218992,1.43422e-06,1.43789e-08,0.977928,0.00219283,1.47735e-06,-1.96989e-08,0.980122,0.00219572,1.41826e-06,4.81221e-09,0.98232,0.00219857,1.43269e-06,4.50048e-10,0.98452,0.00220144,1.43404e-06,-6.61237e-09,0.986722,0.00220429,1.41421e-06,2.59993e-08,0.988928,0.0022072,1.4922e-06,-3.77803e-08,0.991137,0.00221007,1.37886e-06,5.9127e-09,0.993348,0.00221284,1.3966e-06,1.33339e-07,0.995563,0.00221604,1.79662e-06,-5.98872e-07,0.99778,0.00222015,0.,0.}; + + template + __device__ __forceinline__ void RGB2LabConvert_f(const T& src, D& dst) + { + const float _1_3 = 1.0f / 3.0f; + const float _a = 16.0f / 116.0f; + + float B = blueIdx == 0 ? src.x : src.z; + float G = src.y; + float R = blueIdx == 0 ? src.z : src.x; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + } + + float X = B * 0.189828f + G * 0.376219f + R * 0.433953f; + float Y = B * 0.072169f + G * 0.715160f + R * 0.212671f; + float Z = B * 0.872766f + G * 0.109477f + R * 0.017758f; + + float FX = X > 0.008856f ? ::powf(X, _1_3) : (7.787f * X + _a); + float FY = Y > 0.008856f ? ::powf(Y, _1_3) : (7.787f * Y + _a); + float FZ = Z > 0.008856f ? ::powf(Z, _1_3) : (7.787f * Z + _a); + + float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y); + float a = 500.f * (FX - FY); + float b = 200.f * (FY - FZ); + + dst.x = L; + dst.y = a; + dst.z = b; + } + + template struct RGB2Lab; + template + struct RGB2Lab + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LabConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Lab() {} + __host__ __device__ __forceinline__ RGB2Lab(const RGB2Lab&) {} + }; + template + struct RGB2Lab + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LabConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Lab() {} + __host__ __device__ __forceinline__ RGB2Lab(const RGB2Lab&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2Lab_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2Lab functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + __constant__ float c_sRGBInvGammaTab[] = {0,0.0126255,0.,-8.33961e-06,0.0126172,0.0126005,-2.50188e-05,4.1698e-05,0.0252344,0.0126756,0.000100075,-0.000158451,0.0378516,0.0124004,-0.000375277,-0.000207393,0.0496693,0.0110276,-0.000997456,0.00016837,0.0598678,0.00953783,-0.000492346,2.07235e-05,0.068934,0.00861531,-0.000430176,3.62876e-05,0.0771554,0.00786382,-0.000321313,1.87625e-05,0.0847167,0.00727748,-0.000265025,1.53594e-05,0.0917445,0.00679351,-0.000218947,1.10545e-05,0.0983301,0.00638877,-0.000185784,8.66984e-06,0.104542,0.00604322,-0.000159774,6.82996e-06,0.110432,0.00574416,-0.000139284,5.51008e-06,0.116042,0.00548212,-0.000122754,4.52322e-06,0.121406,0.00525018,-0.000109184,3.75557e-06,0.126551,0.00504308,-9.79177e-05,3.17134e-06,0.131499,0.00485676,-8.84037e-05,2.68469e-06,0.13627,0.004688,-8.03496e-05,2.31725e-06,0.14088,0.00453426,-7.33978e-05,2.00868e-06,0.145343,0.00439349,-6.73718e-05,1.74775e-06,0.149671,0.00426399,-6.21286e-05,1.53547e-06,0.153875,0.00414434,-5.75222e-05,1.364e-06,0.157963,0.00403338,-5.34301e-05,1.20416e-06,0.161944,0.00393014,-4.98177e-05,1.09114e-06,0.165825,0.00383377,-4.65443e-05,9.57987e-07,0.169613,0.00374356,-4.36703e-05,8.88359e-07,0.173314,0.00365888,-4.10052e-05,7.7849e-07,0.176933,0.00357921,-3.86697e-05,7.36254e-07,0.180474,0.00350408,-3.6461e-05,6.42534e-07,0.183942,0.00343308,-3.45334e-05,6.12614e-07,0.187342,0.00336586,-3.26955e-05,5.42894e-07,0.190675,0.00330209,-3.10669e-05,5.08967e-07,0.193947,0.00324149,-2.954e-05,4.75977e-07,0.197159,0.00318383,-2.8112e-05,4.18343e-07,0.200315,0.00312887,-2.6857e-05,4.13651e-07,0.203418,0.00307639,-2.5616e-05,3.70847e-07,0.206469,0.00302627,-2.45035e-05,3.3813e-07,0.209471,0.00297828,-2.34891e-05,3.32999e-07,0.212426,0.0029323,-2.24901e-05,2.96826e-07,0.215336,0.00288821,-2.15996e-05,2.82736e-07,0.218203,0.00284586,-2.07514e-05,2.70961e-07,0.221029,0.00280517,-1.99385e-05,2.42744e-07,0.223814,0.00276602,-1.92103e-05,2.33277e-07,0.226561,0.0027283,-1.85105e-05,2.2486e-07,0.229271,0.00269195,-1.78359e-05,2.08383e-07,0.231945,0.00265691,-1.72108e-05,1.93305e-07,0.234585,0.00262307,-1.66308e-05,1.80687e-07,0.237192,0.00259035,-1.60888e-05,1.86632e-07,0.239766,0.00255873,-1.55289e-05,1.60569e-07,0.24231,0.00252815,-1.50472e-05,1.54566e-07,0.244823,0.00249852,-1.45835e-05,1.59939e-07,0.247307,0.00246983,-1.41037e-05,1.29549e-07,0.249763,0.00244202,-1.3715e-05,1.41429e-07,0.252191,0.00241501,-1.32907e-05,1.39198e-07,0.254593,0.00238885,-1.28731e-05,1.06444e-07,0.256969,0.00236342,-1.25538e-05,1.2048e-07,0.25932,0.00233867,-1.21924e-05,1.26892e-07,0.261647,0.00231467,-1.18117e-05,8.72084e-08,0.26395,0.00229131,-1.15501e-05,1.20323e-07,0.26623,0.00226857,-1.11891e-05,8.71514e-08,0.268487,0.00224645,-1.09276e-05,9.73165e-08,0.270723,0.00222489,-1.06357e-05,8.98259e-08,0.272937,0.00220389,-1.03662e-05,7.98218e-08,0.275131,0.00218339,-1.01267e-05,9.75254e-08,0.277304,0.00216343,-9.83416e-06,6.65195e-08,0.279458,0.00214396,-9.63461e-06,8.34313e-08,0.281592,0.00212494,-9.38431e-06,7.65919e-08,0.283708,0.00210641,-9.15454e-06,5.7236e-08,0.285805,0.00208827,-8.98283e-06,8.18939e-08,0.287885,0.00207055,-8.73715e-06,6.2224e-08,0.289946,0.00205326,-8.55047e-06,5.66388e-08,0.291991,0.00203633,-8.38056e-06,6.88491e-08,0.294019,0.00201978,-8.17401e-06,5.53955e-08,0.296031,0.00200359,-8.00782e-06,6.71971e-08,0.298027,0.00198778,-7.80623e-06,3.34439e-08,0.300007,0.00197227,-7.7059e-06,6.7248e-08,0.301971,0.00195706,-7.50416e-06,5.51915e-08,0.303921,0.00194221,-7.33858e-06,3.98124e-08,0.305856,0.00192766,-7.21915e-06,5.37795e-08,0.307776,0.00191338,-7.05781e-06,4.30919e-08,0.309683,0.00189939,-6.92853e-06,4.20744e-08,0.311575,0.00188566,-6.80231e-06,5.68321e-08,0.313454,0.00187223,-6.63181e-06,2.86195e-08,0.31532,0.00185905,-6.54595e-06,3.73075e-08,0.317172,0.00184607,-6.43403e-06,6.05684e-08,0.319012,0.00183338,-6.25233e-06,1.84426e-08,0.320839,0.00182094,-6.197e-06,4.44757e-08,0.322654,0.00180867,-6.06357e-06,4.20729e-08,0.324456,0.00179667,-5.93735e-06,2.56511e-08,0.326247,0.00178488,-5.8604e-06,3.41368e-08,0.328026,0.00177326,-5.75799e-06,4.64177e-08,0.329794,0.00176188,-5.61874e-06,1.86107e-08,0.33155,0.0017507,-5.5629e-06,2.81511e-08,0.333295,0.00173966,-5.47845e-06,4.75987e-08,0.335029,0.00172884,-5.33565e-06,1.98726e-08,0.336753,0.00171823,-5.27604e-06,2.19226e-08,0.338466,0.00170775,-5.21027e-06,4.14483e-08,0.340169,0.00169745,-5.08592e-06,2.09017e-08,0.341861,0.00168734,-5.02322e-06,2.39561e-08,0.343543,0.00167737,-4.95135e-06,3.22852e-08,0.345216,0.00166756,-4.85449e-06,2.57173e-08,0.346878,0.00165793,-4.77734e-06,1.38569e-08,0.348532,0.00164841,-4.73577e-06,3.80634e-08,0.350175,0.00163906,-4.62158e-06,1.27043e-08,0.35181,0.00162985,-4.58347e-06,3.03279e-08,0.353435,0.00162078,-4.49249e-06,1.49961e-08,0.355051,0.00161184,-4.4475e-06,2.88977e-08,0.356659,0.00160303,-4.3608e-06,1.84241e-08,0.358257,0.00159436,-4.30553e-06,1.6616e-08,0.359848,0.0015858,-4.25568e-06,3.43218e-08,0.361429,0.00157739,-4.15272e-06,-4.89172e-09,0.363002,0.00156907,-4.16739e-06,4.48498e-08,0.364567,0.00156087,-4.03284e-06,4.30676e-09,0.366124,0.00155282,-4.01992e-06,2.73303e-08,0.367673,0.00154486,-3.93793e-06,5.58036e-09,0.369214,0.001537,-3.92119e-06,3.97554e-08,0.370747,0.00152928,-3.80193e-06,-1.55904e-08,0.372272,0.00152163,-3.8487e-06,5.24081e-08,0.37379,0.00151409,-3.69147e-06,-1.52272e-08,0.375301,0.00150666,-3.73715e-06,3.83028e-08,0.376804,0.0014993,-3.62225e-06,1.10278e-08,0.378299,0.00149209,-3.58916e-06,6.99326e-09,0.379788,0.00148493,-3.56818e-06,2.06038e-08,0.381269,0.00147786,-3.50637e-06,2.98009e-08,0.382744,0.00147093,-3.41697e-06,-2.05978e-08,0.384211,0.00146404,-3.47876e-06,5.25899e-08,0.385672,0.00145724,-3.32099e-06,-1.09471e-08,0.387126,0.00145056,-3.35383e-06,2.10009e-08,0.388573,0.00144392,-3.29083e-06,1.63501e-08,0.390014,0.00143739,-3.24178e-06,3.00641e-09,0.391448,0.00143091,-3.23276e-06,3.12282e-08,0.392875,0.00142454,-3.13908e-06,-8.70932e-09,0.394297,0.00141824,-3.16521e-06,3.34114e-08,0.395712,0.00141201,-3.06497e-06,-5.72754e-09,0.397121,0.00140586,-3.08215e-06,1.9301e-08,0.398524,0.00139975,-3.02425e-06,1.7931e-08,0.39992,0.00139376,-2.97046e-06,-1.61822e-09,0.401311,0.00138781,-2.97531e-06,1.83442e-08,0.402696,0.00138192,-2.92028e-06,1.76485e-08,0.404075,0.00137613,-2.86733e-06,4.68617e-10,0.405448,0.00137039,-2.86593e-06,1.02794e-08,0.406816,0.00136469,-2.83509e-06,1.80179e-08,0.408178,0.00135908,-2.78104e-06,7.05594e-09,0.409534,0.00135354,-2.75987e-06,1.33633e-08,0.410885,0.00134806,-2.71978e-06,-9.04568e-10,0.41223,0.00134261,-2.72249e-06,2.0057e-08,0.41357,0.00133723,-2.66232e-06,1.00841e-08,0.414905,0.00133194,-2.63207e-06,-7.88835e-10,0.416234,0.00132667,-2.63444e-06,2.28734e-08,0.417558,0.00132147,-2.56582e-06,-1.29785e-09,0.418877,0.00131633,-2.56971e-06,1.21205e-08,0.420191,0.00131123,-2.53335e-06,1.24202e-08,0.421499,0.0013062,-2.49609e-06,-2.19681e-09,0.422803,0.0013012,-2.50268e-06,2.61696e-08,0.424102,0.00129628,-2.42417e-06,-1.30747e-08,0.425396,0.00129139,-2.46339e-06,2.6129e-08,0.426685,0.00128654,-2.38501e-06,-2.03454e-09,0.427969,0.00128176,-2.39111e-06,1.18115e-08,0.429248,0.00127702,-2.35567e-06,1.43932e-08,0.430523,0.00127235,-2.31249e-06,-9.77965e-09,0.431793,0.00126769,-2.34183e-06,2.47253e-08,0.433058,0.00126308,-2.26766e-06,2.85278e-10,0.434319,0.00125855,-2.2668e-06,3.93614e-09,0.435575,0.00125403,-2.25499e-06,1.37722e-08,0.436827,0.00124956,-2.21368e-06,5.79803e-10,0.438074,0.00124513,-2.21194e-06,1.37112e-08,0.439317,0.00124075,-2.1708e-06,4.17973e-09,0.440556,0.00123642,-2.15826e-06,-6.27703e-10,0.44179,0.0012321,-2.16015e-06,2.81332e-08,0.44302,0.00122787,-2.07575e-06,-2.24985e-08,0.444246,0.00122365,-2.14324e-06,3.20586e-08,0.445467,0.00121946,-2.04707e-06,-1.6329e-08,0.446685,0.00121532,-2.09605e-06,3.32573e-08,0.447898,0.00121122,-1.99628e-06,-2.72927e-08,0.449107,0.00120715,-2.07816e-06,4.6111e-08,0.450312,0.00120313,-1.93983e-06,-3.79416e-08,0.451514,0.00119914,-2.05365e-06,4.60507e-08,0.452711,0.00119517,-1.9155e-06,-2.7052e-08,0.453904,0.00119126,-1.99666e-06,3.23551e-08,0.455093,0.00118736,-1.89959e-06,-1.29613e-08,0.456279,0.00118352,-1.93848e-06,1.94905e-08,0.45746,0.0011797,-1.88e-06,-5.39588e-09,0.458638,0.00117593,-1.89619e-06,2.09282e-09,0.459812,0.00117214,-1.88991e-06,2.68267e-08,0.460982,0.00116844,-1.80943e-06,-1.99925e-08,0.462149,0.00116476,-1.86941e-06,2.3341e-08,0.463312,0.00116109,-1.79939e-06,-1.37674e-08,0.464471,0.00115745,-1.84069e-06,3.17287e-08,0.465627,0.00115387,-1.7455e-06,-2.37407e-08,0.466779,0.00115031,-1.81673e-06,3.34315e-08,0.467927,0.00114677,-1.71643e-06,-2.05786e-08,0.469073,0.00114328,-1.77817e-06,1.90802e-08,0.470214,0.00113978,-1.72093e-06,3.86247e-09,0.471352,0.00113635,-1.70934e-06,-4.72759e-09,0.472487,0.00113292,-1.72352e-06,1.50478e-08,0.473618,0.00112951,-1.67838e-06,4.14108e-09,0.474746,0.00112617,-1.66595e-06,-1.80986e-09,0.47587,0.00112283,-1.67138e-06,3.09816e-09,0.476991,0.0011195,-1.66209e-06,1.92198e-08,0.478109,0.00111623,-1.60443e-06,-2.03726e-08,0.479224,0.00111296,-1.66555e-06,3.2468e-08,0.480335,0.00110973,-1.56814e-06,-2.00922e-08,0.481443,0.00110653,-1.62842e-06,1.80983e-08,0.482548,0.00110333,-1.57413e-06,7.30362e-09,0.48365,0.0011002,-1.55221e-06,-1.75107e-08,0.484749,0.00109705,-1.60475e-06,3.29373e-08,0.485844,0.00109393,-1.50594e-06,-2.48315e-08,0.486937,0.00109085,-1.58043e-06,3.65865e-08,0.488026,0.0010878,-1.47067e-06,-3.21078e-08,0.489112,0.00108476,-1.56699e-06,3.22397e-08,0.490195,0.00108172,-1.47027e-06,-7.44391e-09,0.491276,0.00107876,-1.49261e-06,-2.46428e-09,0.492353,0.00107577,-1.5e-06,1.73011e-08,0.493427,0.00107282,-1.4481e-06,-7.13552e-09,0.494499,0.0010699,-1.4695e-06,1.1241e-08,0.495567,0.001067,-1.43578e-06,-8.02637e-09,0.496633,0.0010641,-1.45986e-06,2.08645e-08,0.497695,0.00106124,-1.39726e-06,-1.58271e-08,0.498755,0.0010584,-1.44475e-06,1.26415e-08,0.499812,0.00105555,-1.40682e-06,2.48655e-08,0.500866,0.00105281,-1.33222e-06,-5.24988e-08,0.501918,0.00104999,-1.48972e-06,6.59206e-08,0.502966,0.00104721,-1.29196e-06,-3.237e-08,0.504012,0.00104453,-1.38907e-06,3.95479e-09,0.505055,0.00104176,-1.3772e-06,1.65509e-08,0.506096,0.00103905,-1.32755e-06,-1.05539e-08,0.507133,0.00103637,-1.35921e-06,2.56648e-08,0.508168,0.00103373,-1.28222e-06,-3.25007e-08,0.509201,0.00103106,-1.37972e-06,4.47336e-08,0.51023,0.00102844,-1.24552e-06,-2.72245e-08,0.511258,0.00102587,-1.32719e-06,4.55952e-09,0.512282,0.00102323,-1.31352e-06,8.98645e-09,0.513304,0.00102063,-1.28656e-06,1.90992e-08,0.514323,0.00101811,-1.22926e-06,-2.57786e-08,0.51534,0.00101557,-1.30659e-06,2.44104e-08,0.516355,0.00101303,-1.23336e-06,-1.22581e-08,0.517366,0.00101053,-1.27014e-06,2.4622e-08,0.518376,0.00100806,-1.19627e-06,-2.66253e-08,0.519383,0.00100559,-1.27615e-06,2.22744e-08,0.520387,0.00100311,-1.20932e-06,-2.8679e-09,0.521389,0.00100068,-1.21793e-06,-1.08029e-08,0.522388,0.000998211,-1.25034e-06,4.60795e-08,0.523385,0.000995849,-1.1121e-06,-5.4306e-08,0.52438,0.000993462,-1.27502e-06,5.19354e-08,0.525372,0.000991067,-1.11921e-06,-3.42262e-08,0.526362,0.000988726,-1.22189e-06,2.53646e-08,0.52735,0.000986359,-1.14579e-06,-7.62782e-09,0.528335,0.000984044,-1.16868e-06,5.14668e-09,0.529318,0.000981722,-1.15324e-06,-1.29589e-08,0.530298,0.000979377,-1.19211e-06,4.66888e-08,0.531276,0.000977133,-1.05205e-06,-5.45868e-08,0.532252,0.000974865,-1.21581e-06,5.24495e-08,0.533226,0.000972591,-1.05846e-06,-3.60019e-08,0.534198,0.000970366,-1.16647e-06,3.19537e-08,0.535167,0.000968129,-1.07061e-06,-3.2208e-08,0.536134,0.000965891,-1.16723e-06,3.72738e-08,0.537099,0.000963668,-1.05541e-06,2.32205e-09,0.538061,0.000961564,-1.04844e-06,-4.65618e-08,0.539022,0.000959328,-1.18813e-06,6.47159e-08,0.53998,0.000957146,-9.93979e-07,-3.3488e-08,0.540936,0.000955057,-1.09444e-06,9.63166e-09,0.54189,0.000952897,-1.06555e-06,-5.03871e-09,0.542842,0.000950751,-1.08066e-06,1.05232e-08,0.543792,0.000948621,-1.04909e-06,2.25503e-08,0.544739,0.000946591,-9.81444e-07,-4.11195e-08,0.545685,0.000944504,-1.1048e-06,2.27182e-08,0.546628,0.000942363,-1.03665e-06,9.85146e-09,0.54757,0.000940319,-1.00709e-06,-2.51938e-09,0.548509,0.000938297,-1.01465e-06,2.25858e-10,0.549446,0.000936269,-1.01397e-06,1.61598e-09,0.550381,0.000934246,-1.00913e-06,-6.68983e-09,0.551315,0.000932207,-1.0292e-06,2.51434e-08,0.552246,0.000930224,-9.53765e-07,-3.42793e-08,0.553175,0.000928214,-1.0566e-06,5.23688e-08,0.554102,0.000926258,-8.99497e-07,-5.59865e-08,0.555028,0.000924291,-1.06746e-06,5.23679e-08,0.555951,0.000922313,-9.10352e-07,-3.42763e-08,0.556872,0.00092039,-1.01318e-06,2.51326e-08,0.557792,0.000918439,-9.37783e-07,-6.64954e-09,0.558709,0.000916543,-9.57732e-07,1.46554e-09,0.559625,0.000914632,-9.53335e-07,7.87281e-10,0.560538,0.000912728,-9.50973e-07,-4.61466e-09,0.56145,0.000910812,-9.64817e-07,1.76713e-08,0.56236,0.000908935,-9.11804e-07,-6.46564e-09,0.563268,0.000907092,-9.312e-07,8.19121e-09,0.564174,0.000905255,-9.06627e-07,-2.62992e-08,0.565078,0.000903362,-9.85524e-07,3.74007e-08,0.565981,0.000901504,-8.73322e-07,-4.0942e-09,0.566882,0.000899745,-8.85605e-07,-2.1024e-08,0.56778,0.00089791,-9.48677e-07,2.85854e-08,0.568677,0.000896099,-8.62921e-07,-3.3713e-08,0.569573,0.000894272,-9.64059e-07,4.6662e-08,0.570466,0.000892484,-8.24073e-07,-3.37258e-08,0.571358,0.000890734,-9.25251e-07,2.86365e-08,0.572247,0.00088897,-8.39341e-07,-2.12155e-08,0.573135,0.000887227,-9.02988e-07,-3.37913e-09,0.574022,0.000885411,-9.13125e-07,3.47319e-08,0.574906,0.000883689,-8.08929e-07,-1.63394e-08,0.575789,0.000882022,-8.57947e-07,-2.8979e-08,0.57667,0.00088022,-9.44885e-07,7.26509e-08,0.57755,0.000878548,-7.26932e-07,-8.28106e-08,0.578427,0.000876845,-9.75364e-07,7.97774e-08,0.579303,0.000875134,-7.36032e-07,-5.74849e-08,0.580178,0.00087349,-9.08486e-07,3.09529e-08,0.58105,0.000871765,-8.15628e-07,-6.72206e-09,0.581921,0.000870114,-8.35794e-07,-4.06451e-09,0.582791,0.00086843,-8.47987e-07,2.29799e-08,0.583658,0.000866803,-7.79048e-07,-2.82503e-08,0.584524,0.00086516,-8.63799e-07,3.04167e-08,0.585388,0.000863524,-7.72548e-07,-3.38119e-08,0.586251,0.000861877,-8.73984e-07,4.52264e-08,0.587112,0.000860265,-7.38305e-07,-2.78842e-08,0.587972,0.000858705,-8.21958e-07,6.70567e-09,0.58883,0.000857081,-8.01841e-07,1.06161e-09,0.589686,0.000855481,-7.98656e-07,-1.09521e-08,0.590541,0.00085385,-8.31512e-07,4.27468e-08,0.591394,0.000852316,-7.03272e-07,-4.08257e-08,0.592245,0.000850787,-8.25749e-07,1.34677e-09,0.593095,0.000849139,-8.21709e-07,3.54387e-08,0.593944,0.000847602,-7.15393e-07,-2.38924e-08,0.59479,0.0008461,-7.8707e-07,5.26143e-10,0.595636,0.000844527,-7.85491e-07,2.17879e-08,0.596479,0.000843021,-7.20127e-07,-2.80733e-08,0.597322,0.000841497,-8.04347e-07,3.09005e-08,0.598162,0.000839981,-7.11646e-07,-3.5924e-08,0.599002,0.00083845,-8.19418e-07,5.3191e-08,0.599839,0.000836971,-6.59845e-07,-5.76307e-08,0.600676,0.000835478,-8.32737e-07,5.81227e-08,0.60151,0.000833987,-6.58369e-07,-5.56507e-08,0.602344,0.000832503,-8.25321e-07,4.52706e-08,0.603175,0.000830988,-6.89509e-07,-6.22236e-09,0.604006,0.000829591,-7.08176e-07,-2.03811e-08,0.604834,0.000828113,-7.6932e-07,2.8142e-08,0.605662,0.000826659,-6.84894e-07,-3.25822e-08,0.606488,0.000825191,-7.8264e-07,4.25823e-08,0.607312,0.000823754,-6.54893e-07,-1.85376e-08,0.608135,0.000822389,-7.10506e-07,-2.80365e-08,0.608957,0.000820883,-7.94616e-07,7.1079e-08,0.609777,0.000819507,-5.81379e-07,-7.74655e-08,0.610596,0.000818112,-8.13775e-07,5.9969e-08,0.611413,0.000816665,-6.33868e-07,-4.32013e-08,0.612229,0.000815267,-7.63472e-07,5.32313e-08,0.613044,0.0008139,-6.03778e-07,-5.05148e-08,0.613857,0.000812541,-7.55323e-07,2.96187e-08,0.614669,0.000811119,-6.66466e-07,-8.35545e-09,0.615479,0.000809761,-6.91533e-07,3.80301e-09,0.616288,0.00080839,-6.80124e-07,-6.85666e-09,0.617096,0.000807009,-7.00694e-07,2.36237e-08,0.617903,0.000805678,-6.29822e-07,-2.80336e-08,0.618708,0.000804334,-7.13923e-07,2.8906e-08,0.619511,0.000802993,-6.27205e-07,-2.79859e-08,0.620314,0.000801655,-7.11163e-07,2.34329e-08,0.621114,0.000800303,-6.40864e-07,-6.14108e-09,0.621914,0.000799003,-6.59287e-07,1.13151e-09,0.622712,0.000797688,-6.55893e-07,1.61507e-09,0.62351,0.000796381,-6.51048e-07,-7.59186e-09,0.624305,0.000795056,-6.73823e-07,2.87524e-08,0.6251,0.000793794,-5.87566e-07,-4.7813e-08,0.625893,0.000792476,-7.31005e-07,4.32901e-08,0.626685,0.000791144,-6.01135e-07,-6.13814e-09,0.627475,0.000789923,-6.19549e-07,-1.87376e-08,0.628264,0.000788628,-6.75762e-07,2.14837e-08,0.629052,0.000787341,-6.11311e-07,-7.59265e-09,0.629839,0.000786095,-6.34089e-07,8.88692e-09,0.630625,0.000784854,-6.07428e-07,-2.7955e-08,0.631409,0.000783555,-6.91293e-07,4.33285e-08,0.632192,0.000782302,-5.61307e-07,-2.61497e-08,0.632973,0.000781101,-6.39757e-07,1.6658e-09,0.633754,0.000779827,-6.34759e-07,1.94866e-08,0.634533,0.000778616,-5.76299e-07,-2.00076e-08,0.635311,0.000777403,-6.36322e-07,9.39091e-10,0.636088,0.000776133,-6.33505e-07,1.62512e-08,0.636863,0.000774915,-5.84751e-07,-6.33937e-09,0.637638,0.000773726,-6.03769e-07,9.10609e-09,0.638411,0.000772546,-5.76451e-07,-3.00849e-08,0.639183,0.000771303,-6.66706e-07,5.1629e-08,0.639953,0.000770125,-5.11819e-07,-5.7222e-08,0.640723,0.000768929,-6.83485e-07,5.80497e-08,0.641491,0.000767736,-5.09336e-07,-5.57674e-08,0.642259,0.000766551,-6.76638e-07,4.58105e-08,0.643024,0.000765335,-5.39206e-07,-8.26541e-09,0.643789,0.000764231,-5.64002e-07,-1.27488e-08,0.644553,0.000763065,-6.02249e-07,-3.44168e-10,0.645315,0.00076186,-6.03281e-07,1.41254e-08,0.646077,0.000760695,-5.60905e-07,3.44727e-09,0.646837,0.000759584,-5.50563e-07,-2.79144e-08,0.647596,0.000758399,-6.34307e-07,4.86057e-08,0.648354,0.000757276,-4.88489e-07,-4.72989e-08,0.64911,0.000756158,-6.30386e-07,2.13807e-08,0.649866,0.000754961,-5.66244e-07,2.13808e-08,0.65062,0.000753893,-5.02102e-07,-4.7299e-08,0.651374,0.000752746,-6.43999e-07,4.86059e-08,0.652126,0.000751604,-4.98181e-07,-2.79154e-08,0.652877,0.000750524,-5.81927e-07,3.45089e-09,0.653627,0.000749371,-5.71575e-07,1.41119e-08,0.654376,0.00074827,-5.29239e-07,-2.93748e-10,0.655123,0.00074721,-5.3012e-07,-1.29368e-08,0.65587,0.000746111,-5.68931e-07,-7.56355e-09,0.656616,0.000744951,-5.91621e-07,4.3191e-08,0.65736,0.000743897,-4.62048e-07,-4.59911e-08,0.658103,0.000742835,-6.00022e-07,2.15642e-08,0.658846,0.0007417,-5.35329e-07,1.93389e-08,0.659587,0.000740687,-4.77312e-07,-3.93152e-08,0.660327,0.000739615,-5.95258e-07,1.87126e-08,0.661066,0.00073848,-5.3912e-07,2.40695e-08,0.661804,0.000737474,-4.66912e-07,-5.53859e-08,0.662541,0.000736374,-6.33069e-07,7.82648e-08,0.663277,0.000735343,-3.98275e-07,-7.88593e-08,0.664012,0.00073431,-6.34853e-07,5.83585e-08,0.664745,0.000733215,-4.59777e-07,-3.53656e-08,0.665478,0.000732189,-5.65874e-07,2.34994e-08,0.66621,0.000731128,-4.95376e-07,9.72743e-10,0.66694,0.00073014,-4.92458e-07,-2.73903e-08,0.66767,0.000729073,-5.74629e-07,4.89839e-08,0.668398,0.000728071,-4.27677e-07,-4.93359e-08,0.669126,0.000727068,-5.75685e-07,2.91504e-08,0.669853,0.000726004,-4.88234e-07,-7.66109e-09,0.670578,0.000725004,-5.11217e-07,1.49392e-09,0.671303,0.000723986,-5.06735e-07,1.68533e-09,0.672026,0.000722978,-5.01679e-07,-8.23525e-09,0.672749,0.00072195,-5.26385e-07,3.12556e-08,0.67347,0.000720991,-4.32618e-07,-5.71825e-08,0.674191,0.000719954,-6.04166e-07,7.8265e-08,0.67491,0.00071898,-3.69371e-07,-7.70634e-08,0.675628,0.00071801,-6.00561e-07,5.11747e-08,0.676346,0.000716963,-4.47037e-07,-8.42615e-09,0.677062,0.000716044,-4.72315e-07,-1.747e-08,0.677778,0.000715046,-5.24725e-07,1.87015e-08,0.678493,0.000714053,-4.68621e-07,2.26856e-09,0.679206,0.000713123,-4.61815e-07,-2.77758e-08,0.679919,0.000712116,-5.45142e-07,4.92298e-08,0.68063,0.000711173,-3.97453e-07,-4.99339e-08,0.681341,0.000710228,-5.47255e-07,3.12967e-08,0.682051,0.000709228,-4.53365e-07,-1.56481e-08,0.68276,0.000708274,-5.00309e-07,3.12958e-08,0.683467,0.000707367,-4.06422e-07,-4.99303e-08,0.684174,0.000706405,-5.56213e-07,4.9216e-08,0.68488,0.00070544,-4.08565e-07,-2.77245e-08,0.685585,0.00070454,-4.91738e-07,2.07748e-09,0.686289,0.000703562,-4.85506e-07,1.94146e-08,0.686992,0.00070265,-4.27262e-07,-2.01314e-08,0.687695,0.000701735,-4.87656e-07,1.50616e-09,0.688396,0.000700764,-4.83137e-07,1.41067e-08,0.689096,0.00069984,-4.40817e-07,1.67168e-09,0.689795,0.000698963,-4.35802e-07,-2.07934e-08,0.690494,0.000698029,-4.98182e-07,2.18972e-08,0.691192,0.000697099,-4.32491e-07,-7.19092e-09,0.691888,0.000696212,-4.54064e-07,6.86642e-09,0.692584,0.000695325,-4.33464e-07,-2.02747e-08,0.693279,0.000694397,-4.94288e-07,1.46279e-08,0.693973,0.000693452,-4.50405e-07,2.13678e-08,0.694666,0.000692616,-3.86301e-07,-4.04945e-08,0.695358,0.000691721,-5.07785e-07,2.14009e-08,0.696049,0.00069077,-4.43582e-07,1.44955e-08,0.69674,0.000689926,-4.00096e-07,-1.97783e-08,0.697429,0.000689067,-4.5943e-07,5.01296e-09,0.698118,0.000688163,-4.44392e-07,-2.73521e-10,0.698805,0.000687273,-4.45212e-07,-3.91893e-09,0.699492,0.000686371,-4.56969e-07,1.59493e-08,0.700178,0.000685505,-4.09121e-07,-2.73351e-10,0.700863,0.000684686,-4.09941e-07,-1.4856e-08,0.701548,0.000683822,-4.54509e-07,9.25979e-11,0.702231,0.000682913,-4.54231e-07,1.44855e-08,0.702913,0.000682048,-4.10775e-07,1.56992e-09,0.703595,0.000681231,-4.06065e-07,-2.07652e-08,0.704276,0.000680357,-4.68361e-07,2.18864e-08,0.704956,0.000679486,-4.02701e-07,-7.17595e-09,0.705635,0.000678659,-4.24229e-07,6.81748e-09,0.706313,0.000677831,-4.03777e-07,-2.0094e-08,0.70699,0.000676963,-4.64059e-07,1.39538e-08,0.707667,0.000676077,-4.22197e-07,2.38835e-08,0.708343,0.000675304,-3.50547e-07,-4.98831e-08,0.709018,0.000674453,-5.00196e-07,5.64395e-08,0.709692,0.000673622,-3.30878e-07,-5.66657e-08,0.710365,0.00067279,-5.00875e-07,5.1014e-08,0.711037,0.000671942,-3.47833e-07,-2.81809e-08,0.711709,0.000671161,-4.32376e-07,2.10513e-09,0.712379,0.000670303,-4.2606e-07,1.97604e-08,0.713049,0.00066951,-3.66779e-07,-2.15422e-08,0.713718,0.000668712,-4.31406e-07,6.8038e-09,0.714387,0.000667869,-4.10994e-07,-5.67295e-09,0.715054,0.00066703,-4.28013e-07,1.5888e-08,0.715721,0.000666222,-3.80349e-07,1.72576e-09,0.716387,0.000665467,-3.75172e-07,-2.27911e-08,0.717052,0.000664648,-4.43545e-07,2.9834e-08,0.717716,0.00066385,-3.54043e-07,-3.69401e-08,0.718379,0.000663031,-4.64864e-07,5.83219e-08,0.719042,0.000662277,-2.89898e-07,-7.71382e-08,0.719704,0.000661465,-5.21313e-07,7.14171e-08,0.720365,0.000660637,-3.07061e-07,-2.97161e-08,0.721025,0.000659934,-3.96209e-07,-1.21575e-08,0.721685,0.000659105,-4.32682e-07,1.87412e-08,0.722343,0.000658296,-3.76458e-07,-3.2029e-09,0.723001,0.000657533,-3.86067e-07,-5.9296e-09,0.723659,0.000656743,-4.03856e-07,2.69213e-08,0.724315,0.000656016,-3.23092e-07,-4.21511e-08,0.724971,0.000655244,-4.49545e-07,2.24737e-08,0.725625,0.000654412,-3.82124e-07,1.18611e-08,0.726279,0.000653683,-3.46541e-07,-1.03132e-08,0.726933,0.000652959,-3.7748e-07,-3.02128e-08,0.727585,0.000652114,-4.68119e-07,7.15597e-08,0.728237,0.000651392,-2.5344e-07,-7.72119e-08,0.728888,0.000650654,-4.85075e-07,5.8474e-08,0.729538,0.000649859,-3.09654e-07,-3.74746e-08,0.730188,0.000649127,-4.22077e-07,3.18197e-08,0.730837,0.000648379,-3.26618e-07,-3.01997e-08,0.731485,0.000647635,-4.17217e-07,2.93747e-08,0.732132,0.000646888,-3.29093e-07,-2.76943e-08,0.732778,0.000646147,-4.12176e-07,2.17979e-08,0.733424,0.000645388,-3.46783e-07,1.07292e-10,0.734069,0.000644695,-3.46461e-07,-2.22271e-08,0.734713,0.000643935,-4.13142e-07,2.91963e-08,0.735357,0.000643197,-3.25553e-07,-3.49536e-08,0.736,0.000642441,-4.30414e-07,5.10133e-08,0.736642,0.000641733,-2.77374e-07,-4.98904e-08,0.737283,0.000641028,-4.27045e-07,2.93392e-08,0.737924,0.000640262,-3.39028e-07,-7.86156e-09,0.738564,0.000639561,-3.62612e-07,2.10703e-09,0.739203,0.000638842,-3.56291e-07,-5.6653e-10,0.739842,0.000638128,-3.57991e-07,1.59086e-10,0.740479,0.000637412,-3.57513e-07,-6.98321e-11,0.741116,0.000636697,-3.57723e-07,1.20214e-10,0.741753,0.000635982,-3.57362e-07,-4.10987e-10,0.742388,0.000635266,-3.58595e-07,1.5237e-09,0.743023,0.000634553,-3.54024e-07,-5.68376e-09,0.743657,0.000633828,-3.71075e-07,2.12113e-08,0.744291,0.00063315,-3.07441e-07,-1.95569e-08,0.744924,0.000632476,-3.66112e-07,-2.58816e-09,0.745556,0.000631736,-3.73877e-07,2.99096e-08,0.746187,0.000631078,-2.84148e-07,-5.74454e-08,0.746818,0.000630337,-4.56484e-07,8.06629e-08,0.747448,0.000629666,-2.14496e-07,-8.63922e-08,0.748077,0.000628978,-4.73672e-07,8.60918e-08,0.748706,0.000628289,-2.15397e-07,-7.91613e-08,0.749334,0.000627621,-4.5288e-07,5.17393e-08,0.749961,0.00062687,-2.97663e-07,-8.58662e-09,0.750588,0.000626249,-3.23422e-07,-1.73928e-08,0.751214,0.00062555,-3.75601e-07,1.85532e-08,0.751839,0.000624855,-3.19941e-07,2.78479e-09,0.752463,0.000624223,-3.11587e-07,-2.96923e-08,0.753087,0.000623511,-4.00664e-07,5.63799e-08,0.75371,0.000622879,-2.31524e-07,-7.66179e-08,0.754333,0.000622186,-4.61378e-07,7.12778e-08,0.754955,0.000621477,-2.47545e-07,-2.96794e-08,0.755576,0.000620893,-3.36583e-07,-1.21648e-08,0.756196,0.000620183,-3.73077e-07,1.87339e-08,0.756816,0.000619493,-3.16875e-07,-3.16622e-09,0.757435,0.00061885,-3.26374e-07,-6.0691e-09,0.758054,0.000618179,-3.44581e-07,2.74426e-08,0.758672,0.000617572,-2.62254e-07,-4.40968e-08,0.759289,0.000616915,-3.94544e-07,2.97352e-08,0.759906,0.000616215,-3.05338e-07,-1.52393e-08,0.760522,0.000615559,-3.51056e-07,3.12221e-08,0.761137,0.000614951,-2.5739e-07,-5.00443e-08,0.761751,0.000614286,-4.07523e-07,4.9746e-08,0.762365,0.00061362,-2.58285e-07,-2.97303e-08,0.762979,0.000613014,-3.47476e-07,9.57079e-09,0.763591,0.000612348,-3.18764e-07,-8.55287e-09,0.764203,0.000611685,-3.44422e-07,2.46407e-08,0.764815,0.00061107,-2.705e-07,-3.04053e-08,0.765426,0.000610437,-3.61716e-07,3.73759e-08,0.766036,0.000609826,-2.49589e-07,-5.94935e-08,0.766645,0.000609149,-4.28069e-07,8.13889e-08,0.767254,0.000608537,-1.83902e-07,-8.72483e-08,0.767862,0.000607907,-4.45647e-07,8.87901e-08,0.76847,0.000607282,-1.79277e-07,-8.90983e-08,0.769077,0.000606656,-4.46572e-07,8.87892e-08,0.769683,0.000606029,-1.80204e-07,-8.72446e-08,0.770289,0.000605407,-4.41938e-07,8.13752e-08,0.770894,0.000604768,-1.97812e-07,-5.94423e-08,0.771498,0.000604194,-3.76139e-07,3.71848e-08,0.772102,0.000603553,-2.64585e-07,-2.96922e-08,0.772705,0.000602935,-3.53661e-07,2.19793e-08,0.773308,0.000602293,-2.87723e-07,1.37955e-09,0.77391,0.000601722,-2.83585e-07,-2.74976e-08,0.774512,0.000601072,-3.66077e-07,4.9006e-08,0.775112,0.000600487,-2.19059e-07,-4.93171e-08,0.775712,0.000599901,-3.67011e-07,2.90531e-08,0.776312,0.000599254,-2.79851e-07,-7.29081e-09,0.776911,0.000598673,-3.01724e-07,1.10077e-10,0.777509,0.00059807,-3.01393e-07,6.85053e-09,0.778107,0.000597487,-2.80842e-07,-2.75123e-08,0.778704,0.000596843,-3.63379e-07,4.35939e-08,0.779301,0.000596247,-2.32597e-07,-2.7654e-08,0.779897,0.000595699,-3.15559e-07,7.41741e-09,0.780492,0.00059509,-2.93307e-07,-2.01562e-09,0.781087,0.000594497,-2.99354e-07,6.45059e-10,0.781681,0.000593901,-2.97418e-07,-5.64635e-10,0.782275,0.000593304,-2.99112e-07,1.61347e-09,0.782868,0.000592711,-2.94272e-07,-5.88926e-09,0.78346,0.000592105,-3.1194e-07,2.19436e-08,0.784052,0.000591546,-2.46109e-07,-2.22805e-08,0.784643,0.000590987,-3.1295e-07,7.57368e-09,0.785234,0.000590384,-2.90229e-07,-8.01428e-09,0.785824,0.00058978,-3.14272e-07,2.44834e-08,0.786414,0.000589225,-2.40822e-07,-3.03148e-08,0.787003,0.000588652,-3.31766e-07,3.7171e-08,0.787591,0.0005881,-2.20253e-07,-5.87646e-08,0.788179,0.000587483,-3.96547e-07,7.86782e-08,0.788766,0.000586926,-1.60512e-07,-7.71342e-08,0.789353,0.000586374,-3.91915e-07,5.10444e-08,0.789939,0.000585743,-2.38782e-07,-7.83422e-09,0.790524,0.000585242,-2.62284e-07,-1.97076e-08,0.791109,0.000584658,-3.21407e-07,2.70598e-08,0.791693,0.000584097,-2.40228e-07,-2.89269e-08,0.792277,0.000583529,-3.27008e-07,2.90431e-08,0.792861,0.000582963,-2.39879e-07,-2.76409e-08,0.793443,0.0005824,-3.22802e-07,2.1916e-08,0.794025,0.00058182,-2.57054e-07,-4.18368e-10,0.794607,0.000581305,-2.58309e-07,-2.02425e-08,0.795188,0.000580727,-3.19036e-07,2.17838e-08,0.795768,0.000580155,-2.53685e-07,-7.28814e-09,0.796348,0.000579625,-2.75549e-07,7.36871e-09,0.796928,0.000579096,-2.53443e-07,-2.21867e-08,0.797506,0.000578523,-3.20003e-07,2.17736e-08,0.798085,0.000577948,-2.54683e-07,-5.30296e-09,0.798662,0.000577423,-2.70592e-07,-5.61698e-10,0.799239,0.00057688,-2.72277e-07,7.54977e-09,0.799816,0.000576358,-2.49627e-07,-2.96374e-08,0.800392,0.00057577,-3.38539e-07,5.1395e-08,0.800968,0.000575247,-1.84354e-07,-5.67335e-08,0.801543,0.000574708,-3.54555e-07,5.63297e-08,0.802117,0.000574168,-1.85566e-07,-4.93759e-08,0.802691,0.000573649,-3.33693e-07,2.19646e-08,0.803264,0.000573047,-2.678e-07,2.1122e-08,0.803837,0.000572575,-2.04433e-07,-4.68482e-08,0.804409,0.000572026,-3.44978e-07,4.70613e-08,0.804981,0.000571477,-2.03794e-07,-2.21877e-08,0.805552,0.000571003,-2.70357e-07,-1.79153e-08,0.806123,0.000570408,-3.24103e-07,3.42443e-08,0.806693,0.000569863,-2.2137e-07,1.47556e-10,0.807263,0.000569421,-2.20928e-07,-3.48345e-08,0.807832,0.000568874,-3.25431e-07,1.99812e-08,0.808401,0.000568283,-2.65487e-07,1.45143e-08,0.808969,0.000567796,-2.21945e-07,-1.84338e-08,0.809536,0.000567297,-2.77246e-07,-3.83608e-10,0.810103,0.000566741,-2.78397e-07,1.99683e-08,0.81067,0.000566244,-2.18492e-07,-1.98848e-08,0.811236,0.000565747,-2.78146e-07,-3.38976e-11,0.811801,0.000565191,-2.78248e-07,2.00204e-08,0.812366,0.000564695,-2.18187e-07,-2.04429e-08,0.812931,0.000564197,-2.79516e-07,2.1467e-09,0.813495,0.000563644,-2.73076e-07,1.18561e-08,0.814058,0.000563134,-2.37507e-07,1.00334e-08,0.814621,0.000562689,-2.07407e-07,-5.19898e-08,0.815183,0.000562118,-3.63376e-07,7.87163e-08,0.815745,0.000561627,-1.27227e-07,-8.40616e-08,0.816306,0.000561121,-3.79412e-07,7.87163e-08,0.816867,0.000560598,-1.43263e-07,-5.19898e-08,0.817428,0.000560156,-2.99233e-07,1.00335e-08,0.817988,0.000559587,-2.69132e-07,1.18559e-08,0.818547,0.000559085,-2.33564e-07,2.14764e-09,0.819106,0.000558624,-2.27122e-07,-2.04464e-08,0.819664,0.000558108,-2.88461e-07,2.00334e-08,0.820222,0.000557591,-2.28361e-07,-8.24277e-11,0.820779,0.000557135,-2.28608e-07,-1.97037e-08,0.821336,0.000556618,-2.87719e-07,1.92925e-08,0.821893,0.000556101,-2.29841e-07,2.13831e-09,0.822448,0.000555647,-2.23427e-07,-2.78458e-08,0.823004,0.000555117,-3.06964e-07,4.96402e-08,0.823559,0.000554652,-1.58043e-07,-5.15058e-08,0.824113,0.000554181,-3.12561e-07,3.71737e-08,0.824667,0.000553668,-2.0104e-07,-3.75844e-08,0.82522,0.000553153,-3.13793e-07,5.35592e-08,0.825773,0.000552686,-1.53115e-07,-5.74431e-08,0.826326,0.000552207,-3.25444e-07,5.7004e-08,0.826878,0.000551728,-1.54433e-07,-5.13635e-08,0.827429,0.000551265,-3.08523e-07,2.92406e-08,0.82798,0.000550735,-2.20801e-07,-5.99424e-09,0.828531,0.000550276,-2.38784e-07,-5.26363e-09,0.829081,0.000549782,-2.54575e-07,2.70488e-08,0.82963,0.000549354,-1.73429e-07,-4.33268e-08,0.83018,0.000548878,-3.03409e-07,2.7049e-08,0.830728,0.000548352,-2.22262e-07,-5.26461e-09,0.831276,0.000547892,-2.38056e-07,-5.99057e-09,0.831824,0.000547397,-2.56027e-07,2.92269e-08,0.832371,0.000546973,-1.68347e-07,-5.13125e-08,0.832918,0.000546482,-3.22284e-07,5.68139e-08,0.833464,0.000546008,-1.51843e-07,-5.67336e-08,0.83401,0.000545534,-3.22043e-07,5.09113e-08,0.834555,0.000545043,-1.6931e-07,-2.77022e-08,0.8351,0.000544621,-2.52416e-07,2.92924e-10,0.835644,0.000544117,-2.51537e-07,2.65305e-08,0.836188,0.000543694,-1.71946e-07,-4.68105e-08,0.836732,0.00054321,-3.12377e-07,4.15021e-08,0.837275,0.000542709,-1.87871e-07,1.13355e-11,0.837817,0.000542334,-1.87837e-07,-4.15474e-08,0.838359,0.000541833,-3.12479e-07,4.69691e-08,0.838901,0.000541349,-1.71572e-07,-2.71196e-08,0.839442,0.000540925,-2.52931e-07,1.90462e-09,0.839983,0.000540425,-2.47217e-07,1.95011e-08,0.840523,0.000539989,-1.88713e-07,-2.03045e-08,0.841063,0.00053955,-2.49627e-07,2.11216e-09,0.841602,0.000539057,-2.4329e-07,1.18558e-08,0.842141,0.000538606,-2.07723e-07,1.00691e-08,0.842679,0.000538221,-1.77516e-07,-5.21324e-08,0.843217,0.00053771,-3.33913e-07,7.92513e-08,0.843755,0.00053728,-9.6159e-08,-8.60587e-08,0.844292,0.000536829,-3.54335e-07,8.61696e-08,0.844828,0.000536379,-9.58263e-08,-7.98057e-08,0.845364,0.000535948,-3.35243e-07,5.42394e-08,0.8459,0.00053544,-1.72525e-07,-1.79426e-08,0.846435,0.000535041,-2.26353e-07,1.75308e-08,0.84697,0.000534641,-1.73761e-07,-5.21806e-08,0.847505,0.000534137,-3.30302e-07,7.19824e-08,0.848038,0.000533692,-1.14355e-07,-5.69349e-08,0.848572,0.000533293,-2.8516e-07,3.65479e-08,0.849105,0.000532832,-1.75516e-07,-2.96519e-08,0.849638,0.000532392,-2.64472e-07,2.2455e-08,0.85017,0.000531931,-1.97107e-07,-5.63451e-10,0.850702,0.000531535,-1.98797e-07,-2.02011e-08,0.851233,0.000531077,-2.59401e-07,2.17634e-08,0.851764,0.000530623,-1.94111e-07,-7.24794e-09,0.852294,0.000530213,-2.15854e-07,7.22832e-09,0.852824,0.000529803,-1.94169e-07,-2.16653e-08,0.853354,0.00052935,-2.59165e-07,1.98283e-08,0.853883,0.000528891,-1.9968e-07,1.95678e-09,0.854412,0.000528497,-1.9381e-07,-2.76554e-08,0.85494,0.000528027,-2.76776e-07,4.90603e-08,0.855468,0.00052762,-1.29596e-07,-4.93764e-08,0.855995,0.000527213,-2.77725e-07,2.92361e-08,0.856522,0.000526745,-1.90016e-07,-7.96341e-09,0.857049,0.000526341,-2.13907e-07,2.61752e-09,0.857575,0.000525922,-2.06054e-07,-2.50665e-09,0.8581,0.000525502,-2.13574e-07,7.40906e-09,0.858626,0.000525097,-1.91347e-07,-2.71296e-08,0.859151,0.000524633,-2.72736e-07,4.15048e-08,0.859675,0.000524212,-1.48221e-07,-1.96802e-08,0.860199,0.000523856,-2.07262e-07,-2.23886e-08,0.860723,0.000523375,-2.74428e-07,4.96299e-08,0.861246,0.000522975,-1.25538e-07,-5.69216e-08,0.861769,0.000522553,-2.96303e-07,5.88473e-08,0.862291,0.000522137,-1.19761e-07,-5.92584e-08,0.862813,0.00052172,-2.97536e-07,5.8977e-08,0.863334,0.000521301,-1.20605e-07,-5.74403e-08,0.863855,0.000520888,-2.92926e-07,5.15751e-08,0.864376,0.000520457,-1.38201e-07,-2.96506e-08,0.864896,0.000520091,-2.27153e-07,7.42277e-09,0.865416,0.000519659,-2.04885e-07,-4.05057e-11,0.865936,0.00051925,-2.05006e-07,-7.26074e-09,0.866455,0.000518818,-2.26788e-07,2.90835e-08,0.866973,0.000518451,-1.39538e-07,-4.94686e-08,0.867492,0.000518024,-2.87944e-07,4.95814e-08,0.868009,0.000517597,-1.39199e-07,-2.96479e-08,0.868527,0.000517229,-2.28143e-07,9.40539e-09,0.869044,0.000516801,-1.99927e-07,-7.9737e-09,0.86956,0.000516378,-2.23848e-07,2.24894e-08,0.870077,0.000515997,-1.5638e-07,-2.23793e-08,0.870592,0.000515617,-2.23517e-07,7.42302e-09,0.871108,0.000515193,-2.01248e-07,-7.31283e-09,0.871623,0.000514768,-2.23187e-07,2.18283e-08,0.872137,0.000514387,-1.57702e-07,-2.03959e-08,0.872652,0.000514011,-2.1889e-07,1.50711e-10,0.873165,0.000513573,-2.18437e-07,1.97931e-08,0.873679,0.000513196,-1.59058e-07,-1.97183e-08,0.874192,0.000512819,-2.18213e-07,-5.24324e-10,0.874704,0.000512381,-2.19786e-07,2.18156e-08,0.875217,0.000512007,-1.54339e-07,-2.71336e-08,0.875728,0.000511616,-2.3574e-07,2.71141e-08,0.87624,0.000511226,-1.54398e-07,-2.17182e-08,0.876751,0.000510852,-2.19552e-07,1.54131e-10,0.877262,0.000510414,-2.1909e-07,2.11017e-08,0.877772,0.000510039,-1.55785e-07,-2.49562e-08,0.878282,0.000509652,-2.30654e-07,1.91183e-08,0.878791,0.000509248,-1.73299e-07,8.08751e-09,0.8793,0.000508926,-1.49036e-07,-5.14684e-08,0.879809,0.000508474,-3.03441e-07,7.85766e-08,0.880317,0.000508103,-6.77112e-08,-8.40242e-08,0.880825,0.000507715,-3.19784e-07,7.87063e-08,0.881333,0.000507312,-8.36649e-08,-5.19871e-08,0.88184,0.000506988,-2.39626e-07,1.00327e-08,0.882346,0.000506539,-2.09528e-07,1.18562e-08,0.882853,0.000506156,-1.73959e-07,2.14703e-09,0.883359,0.000505814,-1.67518e-07,-2.04444e-08,0.883864,0.000505418,-2.28851e-07,2.00258e-08,0.88437,0.00050502,-1.68774e-07,-5.42855e-11,0.884874,0.000504682,-1.68937e-07,-1.98087e-08,0.885379,0.000504285,-2.28363e-07,1.96842e-08,0.885883,0.000503887,-1.6931e-07,6.76342e-10,0.886387,0.000503551,-1.67281e-07,-2.23896e-08,0.88689,0.000503149,-2.3445e-07,2.92774e-08,0.887393,0.000502768,-1.46618e-07,-3.51152e-08,0.887896,0.00050237,-2.51963e-07,5.15787e-08,0.888398,0.00050202,-9.72271e-08,-5.19903e-08,0.8889,0.00050167,-2.53198e-07,3.71732e-08,0.889401,0.000501275,-1.41678e-07,-3.70978e-08,0.889902,0.00050088,-2.52972e-07,5.16132e-08,0.890403,0.000500529,-9.81321e-08,-5.01459e-08,0.890903,0.000500183,-2.4857e-07,2.9761e-08,0.891403,0.000499775,-1.59287e-07,-9.29351e-09,0.891903,0.000499428,-1.87167e-07,7.41301e-09,0.892402,0.000499076,-1.64928e-07,-2.03585e-08,0.892901,0.000498685,-2.26004e-07,1.44165e-08,0.893399,0.000498276,-1.82754e-07,2.22974e-08,0.893898,0.000497978,-1.15862e-07,-4.40013e-08,0.894395,0.000497614,-2.47866e-07,3.44985e-08,0.894893,0.000497222,-1.44371e-07,-3.43882e-08,0.89539,0.00049683,-2.47535e-07,4.34497e-08,0.895886,0.000496465,-1.17186e-07,-2.02012e-08,0.896383,0.00049617,-1.7779e-07,-2.22497e-08,0.896879,0.000495748,-2.44539e-07,4.95952e-08,0.897374,0.000495408,-9.57532e-08,-5.69217e-08,0.89787,0.000495045,-2.66518e-07,5.88823e-08,0.898364,0.000494689,-8.98713e-08,-5.93983e-08,0.898859,0.000494331,-2.68066e-07,5.95017e-08,0.899353,0.000493973,-8.95613e-08,-5.9399e-08,0.899847,0.000493616,-2.67758e-07,5.8885e-08,0.90034,0.000493257,-9.11033e-08,-5.69317e-08,0.900833,0.000492904,-2.61898e-07,4.96326e-08,0.901326,0.000492529,-1.13001e-07,-2.23893e-08,0.901819,0.000492236,-1.80169e-07,-1.968e-08,0.902311,0.000491817,-2.39209e-07,4.15047e-08,0.902802,0.000491463,-1.14694e-07,-2.71296e-08,0.903293,0.000491152,-1.96083e-07,7.409e-09,0.903784,0.000490782,-1.73856e-07,-2.50645e-09,0.904275,0.000490427,-1.81376e-07,2.61679e-09,0.904765,0.000490072,-1.73525e-07,-7.96072e-09,0.905255,0.000489701,-1.97407e-07,2.92261e-08,0.905745,0.000489394,-1.09729e-07,-4.93389e-08,0.906234,0.000489027,-2.57746e-07,4.89204e-08,0.906723,0.000488658,-1.10985e-07,-2.71333e-08,0.907211,0.000488354,-1.92385e-07,8.30861e-12,0.907699,0.00048797,-1.9236e-07,2.71001e-08,0.908187,0.000487666,-1.1106e-07,-4.88041e-08,0.908675,0.000487298,-2.57472e-07,4.89069e-08,0.909162,0.000486929,-1.10751e-07,-2.76143e-08,0.909649,0.000486625,-1.93594e-07,1.9457e-09,0.910135,0.000486244,-1.87757e-07,1.98315e-08,0.910621,0.000485928,-1.28262e-07,-2.16671e-08,0.911107,0.000485606,-1.93264e-07,7.23216e-09,0.911592,0.000485241,-1.71567e-07,-7.26152e-09,0.912077,0.000484877,-1.93352e-07,2.18139e-08,0.912562,0.000484555,-1.2791e-07,-2.03895e-08,0.913047,0.000484238,-1.89078e-07,1.39494e-10,0.913531,0.000483861,-1.8866e-07,1.98315e-08,0.914014,0.000483543,-1.29165e-07,-1.98609e-08,0.914498,0.000483225,-1.88748e-07,7.39912e-12,0.914981,0.000482847,-1.88726e-07,1.98313e-08,0.915463,0.000482529,-1.29232e-07,-1.9728e-08,0.915946,0.000482212,-1.88416e-07,-5.24035e-10,0.916428,0.000481833,-1.89988e-07,2.18241e-08,0.916909,0.000481519,-1.24516e-07,-2.71679e-08,0.917391,0.000481188,-2.06019e-07,2.72427e-08,0.917872,0.000480858,-1.24291e-07,-2.21985e-08,0.918353,0.000480543,-1.90886e-07,1.94644e-09,0.918833,0.000480167,-1.85047e-07,1.44127e-08,0.919313,0.00047984,-1.41809e-07,7.39438e-12,0.919793,0.000479556,-1.41787e-07,-1.44423e-08,0.920272,0.000479229,-1.85114e-07,-1.84291e-09,0.920751,0.000478854,-1.90642e-07,2.18139e-08,0.92123,0.000478538,-1.25201e-07,-2.58081e-08,0.921708,0.00047821,-2.02625e-07,2.18139e-08,0.922186,0.00047787,-1.37183e-07,-1.84291e-09,0.922664,0.00047759,-1.42712e-07,-1.44423e-08,0.923141,0.000477262,-1.86039e-07,7.34701e-12,0.923618,0.00047689,-1.86017e-07,1.44129e-08,0.924095,0.000476561,-1.42778e-07,1.94572e-09,0.924572,0.000476281,-1.36941e-07,-2.21958e-08,0.925048,0.000475941,-2.03528e-07,2.72327e-08,0.925523,0.000475615,-1.2183e-07,-2.71304e-08,0.925999,0.00047529,-2.03221e-07,2.16843e-08,0.926474,0.000474949,-1.38168e-07,-2.16005e-12,0.926949,0.000474672,-1.38175e-07,-2.16756e-08,0.927423,0.000474331,-2.03202e-07,2.71001e-08,0.927897,0.000474006,-1.21902e-07,-2.71201e-08,0.928371,0.000473681,-2.03262e-07,2.17757e-08,0.928845,0.00047334,-1.37935e-07,-3.78028e-10,0.929318,0.000473063,-1.39069e-07,-2.02636e-08,0.929791,0.000472724,-1.9986e-07,2.18276e-08,0.930263,0.000472389,-1.34377e-07,-7.44231e-09,0.930736,0.000472098,-1.56704e-07,7.94165e-09,0.931208,0.000471809,-1.32879e-07,-2.43243e-08,0.931679,0.00047147,-2.05851e-07,2.97508e-08,0.932151,0.000471148,-1.16599e-07,-3.50742e-08,0.932622,0.000470809,-2.21822e-07,5.09414e-08,0.933092,0.000470518,-6.89976e-08,-4.94821e-08,0.933563,0.000470232,-2.17444e-07,2.77775e-08,0.934033,0.00046988,-1.34111e-07,-2.02351e-09,0.934502,0.000469606,-1.40182e-07,-1.96835e-08,0.934972,0.000469267,-1.99232e-07,2.11529e-08,0.935441,0.000468932,-1.35774e-07,-5.32332e-09,0.93591,0.000468644,-1.51743e-07,1.40413e-10,0.936378,0.000468341,-1.51322e-07,4.76166e-09,0.936846,0.000468053,-1.37037e-07,-1.9187e-08,0.937314,0.000467721,-1.94598e-07,1.23819e-08,0.937782,0.000467369,-1.57453e-07,2.92642e-08,0.938249,0.000467142,-6.96601e-08,-6.98342e-08,0.938716,0.000466793,-2.79163e-07,7.12586e-08,0.939183,0.000466449,-6.53869e-08,-3.63863e-08,0.939649,0.000466209,-1.74546e-07,1.46818e-08,0.940115,0.000465904,-1.305e-07,-2.2341e-08,0.940581,0.000465576,-1.97523e-07,1.50774e-08,0.941046,0.000465226,-1.52291e-07,2.16359e-08,0.941511,0.000464986,-8.73832e-08,-4.20162e-08,0.941976,0.000464685,-2.13432e-07,2.72198e-08,0.942441,0.00046434,-1.31773e-07,-7.2581e-09,0.942905,0.000464055,-1.53547e-07,1.81263e-09,0.943369,0.000463753,-1.48109e-07,7.58386e-12,0.943832,0.000463457,-1.48086e-07,-1.84298e-09,0.944296,0.000463155,-1.53615e-07,7.36433e-09,0.944759,0.00046287,-1.31522e-07,-2.76143e-08,0.945221,0.000462524,-2.14365e-07,4.34883e-08,0.945684,0.000462226,-8.39003e-08,-2.71297e-08,0.946146,0.000461977,-1.65289e-07,5.42595e-09,0.946608,0.000461662,-1.49012e-07,5.42593e-09,0.947069,0.000461381,-1.32734e-07,-2.71297e-08,0.94753,0.000461034,-2.14123e-07,4.34881e-08,0.947991,0.000460736,-8.36585e-08,-2.76134e-08,0.948452,0.000460486,-1.66499e-07,7.36083e-09,0.948912,0.000460175,-1.44416e-07,-1.82993e-09,0.949372,0.000459881,-1.49906e-07,-4.11073e-11,0.949832,0.000459581,-1.50029e-07,1.99434e-09,0.950291,0.000459287,-1.44046e-07,-7.93627e-09,0.950751,0.000458975,-1.67855e-07,2.97507e-08,0.951209,0.000458728,-7.86029e-08,-5.1462e-08,0.951668,0.000458417,-2.32989e-07,5.6888e-08,0.952126,0.000458121,-6.2325e-08,-5.68806e-08,0.952584,0.000457826,-2.32967e-07,5.14251e-08,0.953042,0.000457514,-7.86914e-08,-2.96107e-08,0.953499,0.000457268,-1.67523e-07,7.41296e-09,0.953956,0.000456955,-1.45285e-07,-4.11262e-11,0.954413,0.000456665,-1.45408e-07,-7.24847e-09,0.95487,0.000456352,-1.67153e-07,2.9035e-08,0.955326,0.000456105,-8.00484e-08,-4.92869e-08,0.955782,0.000455797,-2.27909e-07,4.89032e-08,0.956238,0.000455488,-8.11994e-08,-2.71166e-08,0.956693,0.000455244,-1.62549e-07,-4.13678e-11,0.957148,0.000454919,-1.62673e-07,2.72821e-08,0.957603,0.000454675,-8.0827e-08,-4.94824e-08,0.958057,0.000454365,-2.29274e-07,5.14382e-08,0.958512,0.000454061,-7.49597e-08,-3.7061e-08,0.958965,0.0004538,-1.86143e-07,3.72013e-08,0.959419,0.000453539,-7.45389e-08,-5.21396e-08,0.959873,0.000453234,-2.30958e-07,5.21476e-08,0.960326,0.000452928,-7.45146e-08,-3.72416e-08,0.960778,0.000452667,-1.8624e-07,3.72143e-08,0.961231,0.000452407,-7.45967e-08,-5.20109e-08,0.961683,0.000452101,-2.30629e-07,5.16199e-08,0.962135,0.000451795,-7.57696e-08,-3.52595e-08,0.962587,0.000451538,-1.81548e-07,2.98133e-08,0.963038,0.000451264,-9.2108e-08,-2.43892e-08,0.963489,0.000451007,-1.65276e-07,8.13892e-09,0.96394,0.000450701,-1.40859e-07,-8.16647e-09,0.964391,0.000450394,-1.65358e-07,2.45269e-08,0.964841,0.000450137,-9.17775e-08,-3.03367e-08,0.965291,0.000449863,-1.82787e-07,3.7215e-08,0.965741,0.000449609,-7.11424e-08,-5.89188e-08,0.96619,0.00044929,-2.47899e-07,7.92509e-08,0.966639,0.000449032,-1.01462e-08,-7.92707e-08,0.967088,0.000448773,-2.47958e-07,5.90181e-08,0.967537,0.000448455,-7.0904e-08,-3.75925e-08,0.967985,0.0004482,-1.83681e-07,3.17471e-08,0.968433,0.000447928,-8.84401e-08,-2.97913e-08,0.968881,0.000447662,-1.77814e-07,2.78133e-08,0.969329,0.000447389,-9.4374e-08,-2.18572e-08,0.969776,0.000447135,-1.59946e-07,1.10134e-11,0.970223,0.000446815,-1.59913e-07,2.18132e-08,0.97067,0.000446561,-9.44732e-08,-2.76591e-08,0.971116,0.000446289,-1.7745e-07,2.92185e-08,0.971562,0.000446022,-8.97948e-08,-2.96104e-08,0.972008,0.000445753,-1.78626e-07,2.96185e-08,0.972454,0.000445485,-8.97706e-08,-2.92588e-08,0.972899,0.000445218,-1.77547e-07,2.78123e-08,0.973344,0.000444946,-9.41103e-08,-2.23856e-08,0.973789,0.000444691,-1.61267e-07,2.12559e-09,0.974233,0.000444374,-1.5489e-07,1.38833e-08,0.974678,0.000444106,-1.13241e-07,1.94591e-09,0.975122,0.000443886,-1.07403e-07,-2.16669e-08,0.975565,0.000443606,-1.72404e-07,2.5117e-08,0.976009,0.000443336,-9.70526e-08,-1.91963e-08,0.976452,0.000443085,-1.54642e-07,-7.93627e-09,0.976895,0.000442752,-1.7845e-07,5.09414e-08,0.977338,0.000442548,-2.56262e-08,-7.66201e-08,0.97778,0.000442266,-2.55486e-07,7.67249e-08,0.978222,0.000441986,-2.53118e-08,-5.14655e-08,0.978664,0.000441781,-1.79708e-07,9.92773e-09,0.979106,0.000441451,-1.49925e-07,1.17546e-08,0.979547,0.000441186,-1.14661e-07,2.65868e-09,0.979988,0.000440965,-1.06685e-07,-2.23893e-08,0.980429,0.000440684,-1.73853e-07,2.72939e-08,0.980869,0.000440419,-9.19716e-08,-2.71816e-08,0.98131,0.000440153,-1.73516e-07,2.18278e-08,0.98175,0.000439872,-1.08033e-07,-5.24833e-10,0.982189,0.000439654,-1.09607e-07,-1.97284e-08,0.982629,0.000439376,-1.68793e-07,1.98339e-08,0.983068,0.000439097,-1.09291e-07,-2.62901e-12,0.983507,0.000438879,-1.09299e-07,-1.98234e-08,0.983946,0.000438601,-1.68769e-07,1.96916e-08,0.984384,0.000438322,-1.09694e-07,6.6157e-10,0.984823,0.000438105,-1.0771e-07,-2.23379e-08,0.985261,0.000437823,-1.74723e-07,2.90855e-08,0.985698,0.00043756,-8.74669e-08,-3.43992e-08,0.986136,0.000437282,-1.90665e-07,4.89068e-08,0.986573,0.000437048,-4.39442e-08,-4.20188e-08,0.98701,0.000436834,-1.7e-07,-4.11073e-11,0.987446,0.000436494,-1.70124e-07,4.21832e-08,0.987883,0.00043628,-4.35742e-08,-4.94824e-08,0.988319,0.000436044,-1.92021e-07,3.6537e-08,0.988755,0.00043577,-8.24102e-08,-3.70611e-08,0.989191,0.000435494,-1.93593e-07,5.21026e-08,0.989626,0.000435263,-3.72855e-08,-5.21402e-08,0.990061,0.000435032,-1.93706e-07,3.7249e-08,0.990496,0.000434756,-8.19592e-08,-3.72512e-08,0.990931,0.000434481,-1.93713e-07,5.21511e-08,0.991365,0.00043425,-3.72595e-08,-5.21439e-08,0.991799,0.000434019,-1.93691e-07,3.72152e-08,0.992233,0.000433743,-8.20456e-08,-3.71123e-08,0.992667,0.000433468,-1.93382e-07,5.16292e-08,0.9931,0.000433236,-3.84947e-08,-5.01953e-08,0.993533,0.000433008,-1.89081e-07,2.99427e-08,0.993966,0.00043272,-9.92525e-08,-9.9708e-09,0.994399,0.000432491,-1.29165e-07,9.94051e-09,0.994831,0.000432263,-9.93434e-08,-2.97912e-08,0.995263,0.000431975,-1.88717e-07,4.96198e-08,0.995695,0.000431746,-3.98578e-08,-4.94785e-08,0.996127,0.000431518,-1.88293e-07,2.9085e-08,0.996558,0.000431229,-1.01038e-07,-7.25675e-09,0.996989,0.000431005,-1.22809e-07,-5.79945e-11,0.99742,0.000430759,-1.22983e-07,7.48873e-09,0.997851,0.000430536,-1.00516e-07,-2.98969e-08,0.998281,0.000430245,-1.90207e-07,5.24942e-08,0.998711,0.000430022,-3.27246e-08,-6.08706e-08,0.999141,0.000429774,-2.15336e-07,7.17788e-08,0.999571,0.000429392,0.,0.}; + + template + __device__ __forceinline__ void Lab2RGBConvert_f(const T& src, D& dst) + { + const float lThresh = 0.008856f * 903.3f; + const float fThresh = 7.787f * 0.008856f + 16.0f / 116.0f; + + float Y, fy; + + if (src.x <= lThresh) + { + Y = src.x / 903.3f; + fy = 7.787f * Y + 16.0f / 116.0f; + } + else + { + fy = (src.x + 16.0f) / 116.0f; + Y = fy * fy * fy; + } + + float X = src.y / 500.0f + fy; + float Z = fy - src.z / 200.0f; + + if (X <= fThresh) + X = (X - 16.0f / 116.0f) / 7.787f; + else + X = X * X * X; + + if (Z <= fThresh) + Z = (Z - 16.0f / 116.0f) / 7.787f; + else + Z = Z * Z * Z; + + float B = 0.052891f * X - 0.204043f * Y + 1.151152f * Z; + float G = -0.921235f * X + 1.875991f * Y + 0.045244f * Z; + float R = 3.079933f * X - 1.537150f * Y - 0.542782f * Z; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + } + + dst.x = blueIdx == 0 ? B : R; + dst.y = G; + dst.z = blueIdx == 0 ? R : B; + setAlpha(dst, ColorChannel::max()); + } + + template + __device__ __forceinline__ void Lab2RGBConvert_b(const T& src, D& dst) + { + float3 srcf, dstf; + + srcf.x = src.x * (100.f / 255.f); + srcf.y = src.y - 128; + srcf.z = src.z - 128; + + Lab2RGBConvert_f(srcf, dstf); + + dst.x = saturate_cast(dstf.x * 255.f); + dst.y = saturate_cast(dstf.y * 255.f); + dst.z = saturate_cast(dstf.z * 255.f); + setAlpha(dst, ColorChannel::max()); + } + + template struct Lab2RGB; + template + struct Lab2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Lab2RGBConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Lab2RGB() {} + __host__ __device__ __forceinline__ Lab2RGB(const Lab2RGB&) {} + }; + template + struct Lab2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Lab2RGBConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Lab2RGB() {} + __host__ __device__ __forceinline__ Lab2RGB(const Lab2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_Lab2RGB_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Lab2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + +///////////////////////////////////// RGB <-> Luv ///////////////////////////////////// + + namespace color_detail + { + __constant__ float c_LabCbrtTab[] = {0.137931,0.0114066,0.,1.18859e-07,0.149338,0.011407,3.56578e-07,-5.79396e-07,0.160745,0.0114059,-1.38161e-06,2.16892e-06,0.172151,0.0114097,5.12516e-06,-8.0814e-06,0.183558,0.0113957,-1.9119e-05,3.01567e-05,0.194965,0.0114479,7.13509e-05,-0.000112545,0.206371,0.011253,-0.000266285,-0.000106493,0.217252,0.0104009,-0.000585765,7.32149e-05,0.22714,0.00944906,-0.00036612,1.21917e-05,0.236235,0.0087534,-0.000329545,2.01753e-05,0.244679,0.00815483,-0.000269019,1.24435e-05,0.252577,0.00765412,-0.000231689,1.05618e-05,0.26001,0.00722243,-0.000200003,8.26662e-06,0.267041,0.00684723,-0.000175203,6.76746e-06,0.27372,0.00651712,-0.000154901,5.61192e-06,0.280088,0.00622416,-0.000138065,4.67009e-06,0.286179,0.00596204,-0.000124055,3.99012e-06,0.292021,0.0057259,-0.000112085,3.36032e-06,0.297638,0.00551181,-0.000102004,2.95338e-06,0.30305,0.00531666,-9.31435e-05,2.52875e-06,0.308277,0.00513796,-8.55572e-05,2.22022e-06,0.313331,0.00497351,-7.88966e-05,1.97163e-06,0.318228,0.00482163,-7.29817e-05,1.7248e-06,0.322978,0.00468084,-6.78073e-05,1.55998e-06,0.327593,0.0045499,-6.31274e-05,1.36343e-06,0.332081,0.00442774,-5.90371e-05,1.27136e-06,0.336451,0.00431348,-5.5223e-05,1.09111e-06,0.34071,0.00420631,-5.19496e-05,1.0399e-06,0.344866,0.00410553,-4.88299e-05,9.18347e-07,0.348923,0.00401062,-4.60749e-05,8.29942e-07,0.352889,0.00392096,-4.35851e-05,7.98478e-07,0.356767,0.00383619,-4.11896e-05,6.84917e-07,0.360562,0.00375586,-3.91349e-05,6.63976e-07,0.36428,0.00367959,-3.7143e-05,5.93086e-07,0.367923,0.00360708,-3.53637e-05,5.6976e-07,0.371495,0.00353806,-3.36544e-05,4.95533e-07,0.375,0.00347224,-3.21678e-05,4.87951e-07,0.378441,0.00340937,-3.0704e-05,4.4349e-07,0.38182,0.00334929,-2.93735e-05,4.20297e-07,0.38514,0.0032918,-2.81126e-05,3.7872e-07,0.388404,0.00323671,-2.69764e-05,3.596e-07,0.391614,0.00318384,-2.58976e-05,3.5845e-07,0.394772,0.00313312,-2.48223e-05,2.92765e-07,0.397881,0.00308435,-2.3944e-05,3.18232e-07,0.400942,0.00303742,-2.29893e-05,2.82046e-07,0.403957,0.00299229,-2.21432e-05,2.52315e-07,0.406927,0.00294876,-2.13862e-05,2.58416e-07,0.409855,0.00290676,-2.0611e-05,2.33939e-07,0.412741,0.00286624,-1.99092e-05,2.36342e-07,0.415587,0.00282713,-1.92001e-05,1.916e-07,0.418396,0.00278931,-1.86253e-05,2.1915e-07,0.421167,0.00275271,-1.79679e-05,1.83498e-07,0.423901,0.00271733,-1.74174e-05,1.79343e-07,0.426602,0.00268303,-1.68794e-05,1.72013e-07,0.429268,0.00264979,-1.63633e-05,1.75686e-07,0.431901,0.00261759,-1.58363e-05,1.3852e-07,0.434503,0.00258633,-1.54207e-05,1.64304e-07,0.437074,0.00255598,-1.49278e-05,1.28136e-07,0.439616,0.00252651,-1.45434e-05,1.57618e-07,0.442128,0.0024979,-1.40705e-05,1.0566e-07,0.444612,0.00247007,-1.37535e-05,1.34998e-07,0.447068,0.00244297,-1.33485e-05,1.29207e-07,0.449498,0.00241666,-1.29609e-05,9.32347e-08,0.451902,0.00239102,-1.26812e-05,1.23703e-07,0.45428,0.00236603,-1.23101e-05,9.74072e-08,0.456634,0.0023417,-1.20179e-05,1.12518e-07,0.458964,0.002318,-1.16803e-05,7.83681e-08,0.46127,0.00229488,-1.14452e-05,1.10452e-07,0.463554,0.00227232,-1.11139e-05,7.58719e-08,0.465815,0.00225032,-1.08863e-05,9.2699e-08,0.468055,0.00222882,-1.06082e-05,8.97738e-08,0.470273,0.00220788,-1.03388e-05,5.4845e-08,0.47247,0.00218736,-1.01743e-05,1.0808e-07,0.474648,0.00216734,-9.85007e-06,4.9277e-08,0.476805,0.00214779,-9.70224e-06,8.22408e-08,0.478943,0.00212863,-9.45551e-06,6.87942e-08,0.481063,0.00210993,-9.24913e-06,5.98144e-08,0.483163,0.00209161,-9.06969e-06,7.93789e-08,0.485246,0.00207371,-8.83155e-06,3.99032e-08,0.487311,0.00205616,-8.71184e-06,8.88325e-08,0.489358,0.002039,-8.44534e-06,2.20004e-08,0.491389,0.00202218,-8.37934e-06,9.13872e-08,0.493403,0.0020057,-8.10518e-06,2.96829e-08,0.495401,0.00198957,-8.01613e-06,5.81028e-08,0.497382,0.00197372,-7.84183e-06,6.5731e-08,0.499348,0.00195823,-7.64463e-06,3.66019e-08,0.501299,0.00194305,-7.53483e-06,2.62811e-08,0.503234,0.00192806,-7.45598e-06,9.66907e-08,0.505155,0.00191344,-7.16591e-06,4.18928e-09,0.507061,0.00189912,-7.15334e-06,6.53665e-08,0.508953,0.00188501,-6.95724e-06,3.23686e-08,0.510831,0.00187119,-6.86014e-06,4.35774e-08,0.512696,0.0018576,-6.72941e-06,3.17406e-08,0.514547,0.00184424,-6.63418e-06,6.78785e-08,0.516384,0.00183117,-6.43055e-06,-5.23126e-09,0.518209,0.0018183,-6.44624e-06,7.22562e-08,0.520021,0.00180562,-6.22947e-06,1.42292e-08,0.52182,0.0017932,-6.18679e-06,4.9641e-08,0.523607,0.00178098,-6.03786e-06,2.56259e-08,0.525382,0.00176898,-5.96099e-06,2.66696e-08,0.527145,0.00175714,-5.88098e-06,4.65094e-08,0.528897,0.00174552,-5.74145e-06,2.57114e-08,0.530637,0.00173411,-5.66431e-06,2.94588e-08,0.532365,0.00172287,-5.57594e-06,3.52667e-08,0.534082,0.00171182,-5.47014e-06,8.28868e-09,0.535789,0.00170091,-5.44527e-06,5.07871e-08,0.537484,0.00169017,-5.29291e-06,2.69817e-08,0.539169,0.00167967,-5.21197e-06,2.01009e-08,0.540844,0.0016693,-5.15166e-06,1.18237e-08,0.542508,0.00165903,-5.11619e-06,5.18135e-08,0.544162,0.00164896,-4.96075e-06,1.9341e-08,0.545806,0.00163909,-4.90273e-06,-9.96867e-09,0.54744,0.00162926,-4.93263e-06,8.01382e-08,0.549064,0.00161963,-4.69222e-06,-1.25601e-08,0.550679,0.00161021,-4.7299e-06,2.97067e-08,0.552285,0.00160084,-4.64078e-06,1.29426e-08,0.553881,0.0015916,-4.60195e-06,3.77327e-08,0.555468,0.00158251,-4.48875e-06,1.49412e-08,0.557046,0.00157357,-4.44393e-06,2.17118e-08,0.558615,0.00156475,-4.3788e-06,1.74206e-08,0.560176,0.00155605,-4.32653e-06,2.78152e-08,0.561727,0.00154748,-4.24309e-06,-9.47239e-09,0.563271,0.00153896,-4.27151e-06,6.9679e-08,0.564805,0.00153063,-4.06247e-06,-3.08246e-08,0.566332,0.00152241,-4.15494e-06,5.36188e-08,0.56785,0.00151426,-3.99409e-06,-4.83594e-09,0.56936,0.00150626,-4.00859e-06,2.53293e-08,0.570863,0.00149832,-3.93261e-06,2.27286e-08,0.572357,0.00149052,-3.86442e-06,2.96541e-09,0.573844,0.0014828,-3.85552e-06,2.50147e-08,0.575323,0.00147516,-3.78048e-06,1.61842e-08,0.576794,0.00146765,-3.73193e-06,2.94582e-08,0.578258,0.00146028,-3.64355e-06,-1.48076e-08,0.579715,0.00145295,-3.68798e-06,2.97724e-08,0.581164,0.00144566,-3.59866e-06,1.49272e-08,0.582606,0.00143851,-3.55388e-06,2.97285e-08,0.584041,0.00143149,-3.46469e-06,-1.46323e-08,0.585469,0.00142451,-3.50859e-06,2.88004e-08,0.58689,0.00141758,-3.42219e-06,1.864e-08,0.588304,0.00141079,-3.36627e-06,1.58482e-08,0.589712,0.00140411,-3.31872e-06,-2.24279e-08,0.591112,0.00139741,-3.38601e-06,7.38639e-08,0.592507,0.00139085,-3.16441e-06,-3.46088e-08,0.593894,0.00138442,-3.26824e-06,4.96675e-09,0.595275,0.0013779,-3.25334e-06,7.4346e-08,0.59665,0.00137162,-3.0303e-06,-6.39319e-08,0.598019,0.00136536,-3.2221e-06,6.21725e-08,0.599381,0.00135911,-3.03558e-06,-5.94423e-09,0.600737,0.00135302,-3.05341e-06,2.12091e-08,0.602087,0.00134697,-2.98979e-06,-1.92876e-08,0.603431,0.00134094,-3.04765e-06,5.5941e-08,0.604769,0.00133501,-2.87983e-06,-2.56622e-08,0.606101,0.00132917,-2.95681e-06,4.67078e-08,0.607427,0.0013234,-2.81669e-06,-4.19592e-08,0.608748,0.00131764,-2.94257e-06,6.15243e-08,0.610062,0.00131194,-2.75799e-06,-2.53244e-08,0.611372,0.00130635,-2.83397e-06,3.97739e-08,0.612675,0.0013008,-2.71465e-06,-1.45618e-08,0.613973,0.00129533,-2.75833e-06,1.84733e-08,0.615266,0.00128986,-2.70291e-06,2.73606e-10,0.616553,0.00128446,-2.70209e-06,4.00367e-08,0.617835,0.00127918,-2.58198e-06,-4.12113e-08,0.619111,0.00127389,-2.70561e-06,6.52039e-08,0.620383,0.00126867,-2.51e-06,-4.07901e-08,0.621649,0.00126353,-2.63237e-06,3.83516e-08,0.62291,0.00125838,-2.51732e-06,6.59315e-09,0.624166,0.00125337,-2.49754e-06,-5.11939e-09,0.625416,0.00124836,-2.5129e-06,1.38846e-08,0.626662,0.00124337,-2.47124e-06,9.18514e-09,0.627903,0.00123846,-2.44369e-06,8.97952e-09,0.629139,0.0012336,-2.41675e-06,1.45012e-08,0.63037,0.00122881,-2.37325e-06,-7.37949e-09,0.631597,0.00122404,-2.39538e-06,1.50169e-08,0.632818,0.00121929,-2.35033e-06,6.91648e-09,0.634035,0.00121461,-2.32958e-06,1.69219e-08,0.635248,0.00121,-2.27882e-06,-1.49997e-08,0.636455,0.0012054,-2.32382e-06,4.30769e-08,0.637659,0.00120088,-2.19459e-06,-3.80986e-08,0.638857,0.00119638,-2.30888e-06,4.97134e-08,0.640051,0.00119191,-2.15974e-06,-4.15463e-08,0.641241,0.00118747,-2.28438e-06,5.68667e-08,0.642426,0.00118307,-2.11378e-06,-7.10641e-09,0.643607,0.00117882,-2.1351e-06,-2.8441e-08,0.644784,0.00117446,-2.22042e-06,6.12658e-08,0.645956,0.00117021,-2.03663e-06,-3.78083e-08,0.647124,0.00116602,-2.15005e-06,3.03627e-08,0.648288,0.00116181,-2.05896e-06,-2.40379e-08,0.649448,0.00115762,-2.13108e-06,6.57887e-08,0.650603,0.00115356,-1.93371e-06,-6.03028e-08,0.651755,0.00114951,-2.11462e-06,5.62134e-08,0.652902,0.00114545,-1.94598e-06,-4.53417e-08,0.654046,0.00114142,-2.082e-06,6.55489e-08,0.655185,0.00113745,-1.88536e-06,-3.80396e-08,0.656321,0.00113357,-1.99948e-06,2.70049e-08,0.657452,0.00112965,-1.91846e-06,-1.03755e-08,0.65858,0.00112578,-1.94959e-06,1.44973e-08,0.659704,0.00112192,-1.9061e-06,1.1991e-08,0.660824,0.00111815,-1.87012e-06,-2.85634e-09,0.66194,0.0011144,-1.87869e-06,-5.65782e-10,0.663053,0.00111064,-1.88039e-06,5.11947e-09,0.664162,0.0011069,-1.86503e-06,3.96924e-08,0.665267,0.00110328,-1.74595e-06,-4.46795e-08,0.666368,0.00109966,-1.87999e-06,1.98161e-08,0.667466,0.00109596,-1.82054e-06,2.502e-08,0.66856,0.00109239,-1.74548e-06,-6.86593e-10,0.669651,0.0010889,-1.74754e-06,-2.22739e-08,0.670738,0.00108534,-1.81437e-06,3.01776e-08,0.671821,0.0010818,-1.72383e-06,2.07732e-08,0.672902,0.00107841,-1.66151e-06,-5.36658e-08,0.673978,0.00107493,-1.82251e-06,7.46802e-08,0.675051,0.00107151,-1.59847e-06,-6.62411e-08,0.676121,0.00106811,-1.79719e-06,7.10748e-08,0.677188,0.00106473,-1.58397e-06,-3.92441e-08,0.678251,0.00106145,-1.7017e-06,2.62973e-08,0.679311,0.00105812,-1.62281e-06,-6.34035e-09,0.680367,0.00105486,-1.64183e-06,-9.36249e-10,0.68142,0.00105157,-1.64464e-06,1.00854e-08,0.68247,0.00104831,-1.61438e-06,2.01995e-08,0.683517,0.00104514,-1.55378e-06,-3.1279e-08,0.68456,0.00104194,-1.64762e-06,4.53114e-08,0.685601,0.00103878,-1.51169e-06,-3.07573e-08,0.686638,0.00103567,-1.60396e-06,1.81133e-08,0.687672,0.00103251,-1.54962e-06,1.79085e-08,0.688703,0.00102947,-1.49589e-06,-3.01428e-08,0.689731,0.00102639,-1.58632e-06,4.30583e-08,0.690756,0.00102334,-1.45715e-06,-2.28814e-08,0.691778,0.00102036,-1.52579e-06,-1.11373e-08,0.692797,0.00101727,-1.5592e-06,6.74305e-08,0.693812,0.00101436,-1.35691e-06,-7.97709e-08,0.694825,0.0010114,-1.59622e-06,7.28391e-08,0.695835,0.00100843,-1.37771e-06,-3.27715e-08,0.696842,0.00100558,-1.47602e-06,-1.35807e-09,0.697846,0.00100262,-1.48009e-06,3.82037e-08,0.698847,0.000999775,-1.36548e-06,-3.22474e-08,0.699846,0.000996948,-1.46223e-06,3.11809e-08,0.700841,0.000994117,-1.36868e-06,-3.28714e-08,0.701834,0.000991281,-1.4673e-06,4.07001e-08,0.702824,0.000988468,-1.3452e-06,-1.07197e-08,0.703811,0.000985746,-1.37736e-06,2.17866e-09,0.704795,0.000982998,-1.37082e-06,2.00521e-09,0.705777,0.000980262,-1.3648e-06,-1.01996e-08,0.706756,0.000977502,-1.3954e-06,3.87931e-08,0.707732,0.000974827,-1.27902e-06,-2.57632e-08,0.708706,0.000972192,-1.35631e-06,4.65513e-09,0.709676,0.000969493,-1.34235e-06,7.14257e-09,0.710645,0.00096683,-1.32092e-06,2.63791e-08,0.71161,0.000964267,-1.24178e-06,-5.30543e-08,0.712573,0.000961625,-1.40095e-06,6.66289e-08,0.713533,0.000959023,-1.20106e-06,-3.46474e-08,0.714491,0.000956517,-1.305e-06,1.23559e-08,0.715446,0.000953944,-1.26793e-06,-1.47763e-08,0.716399,0.000951364,-1.31226e-06,4.67494e-08,0.717349,0.000948879,-1.17201e-06,-5.3012e-08,0.718297,0.000946376,-1.33105e-06,4.60894e-08,0.719242,0.000943852,-1.19278e-06,-1.21366e-08,0.720185,0.00094143,-1.22919e-06,2.45673e-09,0.721125,0.000938979,-1.22182e-06,2.30966e-09,0.722063,0.000936543,-1.21489e-06,-1.16954e-08,0.722998,0.000934078,-1.24998e-06,4.44718e-08,0.723931,0.000931711,-1.11656e-06,-4.69823e-08,0.724861,0.000929337,-1.25751e-06,2.4248e-08,0.725789,0.000926895,-1.18477e-06,9.5949e-09,0.726715,0.000924554,-1.15598e-06,-3.02286e-09,0.727638,0.000922233,-1.16505e-06,2.49649e-09,0.72856,0.00091991,-1.15756e-06,-6.96321e-09,0.729478,0.000917575,-1.17845e-06,2.53564e-08,0.730395,0.000915294,-1.10238e-06,-3.48578e-08,0.731309,0.000912984,-1.20695e-06,5.44704e-08,0.732221,0.000910734,-1.04354e-06,-6.38144e-08,0.73313,0.000908455,-1.23499e-06,8.15781e-08,0.734038,0.00090623,-9.90253e-07,-8.3684e-08,0.734943,0.000903999,-1.2413e-06,7.43441e-08,0.735846,0.000901739,-1.01827e-06,-3.48787e-08,0.736746,0.000899598,-1.12291e-06,5.56596e-09,0.737645,0.000897369,-1.10621e-06,1.26148e-08,0.738541,0.000895194,-1.06837e-06,3.57935e-09,0.739435,0.000893068,-1.05763e-06,-2.69322e-08,0.740327,0.000890872,-1.13842e-06,4.45448e-08,0.741217,0.000888729,-1.00479e-06,-3.20376e-08,0.742105,0.000886623,-1.1009e-06,2.40011e-08,0.74299,0.000884493,-1.0289e-06,-4.36209e-09,0.743874,0.000882422,-1.04199e-06,-6.55268e-09,0.744755,0.000880319,-1.06164e-06,3.05728e-08,0.745634,0.000878287,-9.69926e-07,-5.61338e-08,0.746512,0.000876179,-1.13833e-06,7.4753e-08,0.747387,0.000874127,-9.14068e-07,-6.40644e-08,0.74826,0.000872106,-1.10626e-06,6.22955e-08,0.749131,0.000870081,-9.19375e-07,-6.59083e-08,0.75,0.000868044,-1.1171e-06,8.21284e-08,0.750867,0.000866056,-8.70714e-07,-8.37915e-08,0.751732,0.000864064,-1.12209e-06,7.42237e-08,0.752595,0.000862042,-8.99418e-07,-3.42894e-08,0.753456,0.00086014,-1.00229e-06,3.32955e-09,0.754315,0.000858146,-9.92297e-07,2.09712e-08,0.755173,0.000856224,-9.29384e-07,-2.76096e-08,0.756028,0.000854282,-1.01221e-06,2.98627e-08,0.756881,0.000852348,-9.22625e-07,-3.22365e-08,0.757733,0.000850406,-1.01933e-06,3.94786e-08,0.758582,0.000848485,-9.00898e-07,-6.46833e-09,0.75943,0.000846664,-9.20303e-07,-1.36052e-08,0.760275,0.000844783,-9.61119e-07,1.28447e-09,0.761119,0.000842864,-9.57266e-07,8.4674e-09,0.761961,0.000840975,-9.31864e-07,2.44506e-08,0.762801,0.000839185,-8.58512e-07,-4.6665e-08,0.763639,0.000837328,-9.98507e-07,4.30001e-08,0.764476,0.00083546,-8.69507e-07,-6.12609e-09,0.76531,0.000833703,-8.87885e-07,-1.84959e-08,0.766143,0.000831871,-9.43372e-07,2.05052e-08,0.766974,0.000830046,-8.81857e-07,-3.92026e-09,0.767803,0.000828271,-8.93618e-07,-4.82426e-09,0.768631,0.000826469,-9.0809e-07,2.32172e-08,0.769456,0.000824722,-8.38439e-07,-2.84401e-08,0.77028,0.00082296,-9.23759e-07,3.09386e-08,0.771102,0.000821205,-8.30943e-07,-3.57099e-08,0.771922,0.000819436,-9.38073e-07,5.22963e-08,0.772741,0.000817717,-7.81184e-07,-5.42658e-08,0.773558,0.000815992,-9.43981e-07,4.55579e-08,0.774373,0.000814241,-8.07308e-07,-8.75656e-09,0.775186,0.0008126,-8.33578e-07,-1.05315e-08,0.775998,0.000810901,-8.65172e-07,-8.72188e-09,0.776808,0.000809145,-8.91338e-07,4.54191e-08,0.777616,0.000807498,-7.5508e-07,-5.37454e-08,0.778423,0.000805827,-9.16317e-07,5.03532e-08,0.779228,0.000804145,-7.65257e-07,-2.84584e-08,0.780031,0.000802529,-8.50632e-07,3.87579e-09,0.780833,0.00080084,-8.39005e-07,1.29552e-08,0.781633,0.0007992,-8.00139e-07,3.90804e-09,0.782432,0.000797612,-7.88415e-07,-2.85874e-08,0.783228,0.000795949,-8.74177e-07,5.0837e-08,0.784023,0.000794353,-7.21666e-07,-5.55513e-08,0.784817,0.000792743,-8.8832e-07,5.21587e-08,0.785609,0.000791123,-7.31844e-07,-3.38744e-08,0.786399,0.000789558,-8.33467e-07,2.37342e-08,0.787188,0.000787962,-7.62264e-07,-1.45775e-09,0.787975,0.000786433,-7.66638e-07,-1.79034e-08,0.788761,0.000784846,-8.20348e-07,1.34665e-08,0.789545,0.000783246,-7.79948e-07,2.3642e-08,0.790327,0.000781757,-7.09022e-07,-4.84297e-08,0.791108,0.000780194,-8.54311e-07,5.08674e-08,0.791888,0.000778638,-7.01709e-07,-3.58303e-08,0.792666,0.000777127,-8.092e-07,3.28493e-08,0.793442,0.000775607,-7.10652e-07,-3.59624e-08,0.794217,0.000774078,-8.1854e-07,5.13959e-08,0.79499,0.000772595,-6.64352e-07,-5.04121e-08,0.795762,0.000771115,-8.15588e-07,3.10431e-08,0.796532,0.000769577,-7.22459e-07,-1.41557e-08,0.797301,0.00076809,-7.64926e-07,2.55795e-08,0.798069,0.000766636,-6.88187e-07,-2.85578e-08,0.798835,0.000765174,-7.73861e-07,2.90472e-08,0.799599,0.000763714,-6.86719e-07,-2.80262e-08,0.800362,0.000762256,-7.70798e-07,2.34531e-08,0.801123,0.000760785,-7.00438e-07,-6.18144e-09,0.801884,0.000759366,-7.18983e-07,1.27263e-09,0.802642,0.000757931,-7.15165e-07,1.09101e-09,0.803399,0.000756504,-7.11892e-07,-5.63675e-09,0.804155,0.000755064,-7.28802e-07,2.14559e-08,0.80491,0.00075367,-6.64434e-07,-2.05821e-08,0.805663,0.00075228,-7.26181e-07,1.26812e-09,0.806414,0.000750831,-7.22377e-07,1.55097e-08,0.807164,0.000749433,-6.75848e-07,-3.70216e-09,0.807913,0.00074807,-6.86954e-07,-7.0105e-10,0.80866,0.000746694,-6.89057e-07,6.5063e-09,0.809406,0.000745336,-6.69538e-07,-2.53242e-08,0.810151,0.000743921,-7.45511e-07,3.51858e-08,0.810894,0.000742535,-6.39953e-07,3.79034e-09,0.811636,0.000741267,-6.28582e-07,-5.03471e-08,0.812377,0.000739858,-7.79624e-07,7.83886e-08,0.813116,0.000738534,-5.44458e-07,-8.43935e-08,0.813854,0.000737192,-7.97638e-07,8.03714e-08,0.81459,0.000735838,-5.56524e-07,-5.82784e-08,0.815325,0.00073455,-7.31359e-07,3.35329e-08,0.816059,0.000733188,-6.3076e-07,-1.62486e-08,0.816792,0.000731878,-6.79506e-07,3.14614e-08,0.817523,0.000730613,-5.85122e-07,-4.99925e-08,0.818253,0.000729293,-7.35099e-07,4.92994e-08,0.818982,0.000727971,-5.87201e-07,-2.79959e-08,0.819709,0.000726712,-6.71189e-07,3.07959e-09,0.820435,0.000725379,-6.6195e-07,1.56777e-08,0.82116,0.000724102,-6.14917e-07,-6.18564e-09,0.821883,0.000722854,-6.33474e-07,9.06488e-09,0.822606,0.000721614,-6.06279e-07,-3.00739e-08,0.823327,0.000720311,-6.96501e-07,5.16262e-08,0.824046,0.000719073,-5.41623e-07,-5.72214e-08,0.824765,0.000717818,-7.13287e-07,5.80503e-08,0.825482,0.000716566,-5.39136e-07,-5.57703e-08,0.826198,0.00071532,-7.06447e-07,4.58215e-08,0.826912,0.000714045,-5.68983e-07,-8.30636e-09,0.827626,0.000712882,-5.93902e-07,-1.25961e-08,0.828338,0.000711656,-6.3169e-07,-9.13985e-10,0.829049,0.00071039,-6.34432e-07,1.62519e-08,0.829759,0.00070917,-5.85676e-07,-4.48904e-09,0.830468,0.000707985,-5.99143e-07,1.70418e-09,0.831175,0.000706792,-5.9403e-07,-2.32768e-09,0.831881,0.000705597,-6.01014e-07,7.60648e-09,0.832586,0.000704418,-5.78194e-07,-2.80982e-08,0.83329,0.000703177,-6.62489e-07,4.51817e-08,0.833993,0.000701988,-5.26944e-07,-3.34192e-08,0.834694,0.000700834,-6.27201e-07,2.88904e-08,0.835394,0.000699666,-5.4053e-07,-2.25378e-08,0.836093,0.000698517,-6.08143e-07,1.65589e-09,0.836791,0.000697306,-6.03176e-07,1.59142e-08,0.837488,0.000696147,-5.55433e-07,-5.70801e-09,0.838184,0.000695019,-5.72557e-07,6.91792e-09,0.838878,0.000693895,-5.51803e-07,-2.19637e-08,0.839571,0.000692725,-6.17694e-07,2.13321e-08,0.840263,0.000691554,-5.53698e-07,-3.75996e-09,0.840954,0.000690435,-5.64978e-07,-6.29219e-09,0.841644,0.000689287,-5.83855e-07,2.89287e-08,0.842333,0.000688206,-4.97068e-07,-4.98181e-08,0.843021,0.000687062,-6.46523e-07,5.11344e-08,0.843707,0.000685922,-4.9312e-07,-3.55102e-08,0.844393,0.00068483,-5.9965e-07,3.13019e-08,0.845077,0.000683724,-5.05745e-07,-3.00925e-08,0.84576,0.000682622,-5.96022e-07,2.94636e-08,0.846442,0.000681519,-5.07631e-07,-2.81572e-08,0.847123,0.000680419,-5.92103e-07,2.35606e-08,0.847803,0.000679306,-5.21421e-07,-6.48045e-09,0.848482,0.000678243,-5.40863e-07,2.36124e-09,0.849159,0.000677169,-5.33779e-07,-2.96461e-09,0.849836,0.000676092,-5.42673e-07,9.49728e-09,0.850512,0.000675035,-5.14181e-07,-3.50245e-08,0.851186,0.000673902,-6.19254e-07,7.09959e-08,0.851859,0.000672876,-4.06267e-07,-7.01453e-08,0.852532,0.000671853,-6.16703e-07,3.07714e-08,0.853203,0.000670712,-5.24388e-07,6.66423e-09,0.853873,0.000669684,-5.04396e-07,2.17629e-09,0.854542,0.000668681,-4.97867e-07,-1.53693e-08,0.855211,0.000667639,-5.43975e-07,-3.03752e-10,0.855878,0.000666551,-5.44886e-07,1.65844e-08,0.856544,0.000665511,-4.95133e-07,-6.42907e-09,0.857209,0.000664501,-5.1442e-07,9.13195e-09,0.857873,0.0006635,-4.87024e-07,-3.00987e-08,0.858536,0.000662435,-5.7732e-07,5.16584e-08,0.859198,0.000661436,-4.22345e-07,-5.73255e-08,0.859859,0.000660419,-5.94322e-07,5.84343e-08,0.860518,0.000659406,-4.19019e-07,-5.72022e-08,0.861177,0.000658396,-5.90626e-07,5.11653e-08,0.861835,0.000657368,-4.3713e-07,-2.82495e-08,0.862492,0.000656409,-5.21878e-07,2.22788e-09,0.863148,0.000655372,-5.15195e-07,1.9338e-08,0.863803,0.0006544,-4.5718e-07,-1.99754e-08,0.864457,0.000653425,-5.17107e-07,9.59024e-10,0.86511,0.000652394,-5.1423e-07,1.61393e-08,0.865762,0.000651414,-4.65812e-07,-5.91149e-09,0.866413,0.000650465,-4.83546e-07,7.50665e-09,0.867063,0.00064952,-4.61026e-07,-2.4115e-08,0.867712,0.000648526,-5.33371e-07,2.93486e-08,0.86836,0.000647547,-4.45325e-07,-3.36748e-08,0.869007,0.000646555,-5.4635e-07,4.57461e-08,0.869653,0.0006456,-4.09112e-07,-3.01002e-08,0.870298,0.000644691,-4.99412e-07,1.50501e-08,0.870942,0.000643738,-4.54262e-07,-3.01002e-08,0.871585,0.000642739,-5.44563e-07,4.57461e-08,0.872228,0.000641787,-4.07324e-07,-3.36748e-08,0.872869,0.000640871,-5.08349e-07,2.93486e-08,0.873509,0.000639943,-4.20303e-07,-2.4115e-08,0.874149,0.00063903,-4.92648e-07,7.50655e-09,0.874787,0.000638067,-4.70128e-07,-5.91126e-09,0.875425,0.000637109,-4.87862e-07,1.61385e-08,0.876062,0.000636182,-4.39447e-07,9.61961e-10,0.876697,0.000635306,-4.36561e-07,-1.99863e-08,0.877332,0.000634373,-4.9652e-07,1.93785e-08,0.877966,0.000633438,-4.38384e-07,2.07697e-09,0.878599,0.000632567,-4.32153e-07,-2.76864e-08,0.879231,0.00063162,-5.15212e-07,4.90641e-08,0.879862,0.000630737,-3.6802e-07,-4.93606e-08,0.880493,0.000629852,-5.16102e-07,2.9169e-08,0.881122,0.000628908,-4.28595e-07,-7.71083e-09,0.881751,0.000628027,-4.51727e-07,1.6744e-09,0.882378,0.000627129,-4.46704e-07,1.01317e-09,0.883005,0.000626239,-4.43665e-07,-5.72703e-09,0.883631,0.000625334,-4.60846e-07,2.1895e-08,0.884255,0.000624478,-3.95161e-07,-2.22481e-08,0.88488,0.000623621,-4.61905e-07,7.4928e-09,0.885503,0.00062272,-4.39427e-07,-7.72306e-09,0.886125,0.000621818,-4.62596e-07,2.33995e-08,0.886746,0.000620963,-3.92398e-07,-2.62704e-08,0.887367,0.000620099,-4.71209e-07,2.20775e-08,0.887987,0.000619223,-4.04976e-07,-2.43496e-09,0.888605,0.000618406,-4.12281e-07,-1.23377e-08,0.889223,0.000617544,-4.49294e-07,-7.81876e-09,0.88984,0.000616622,-4.72751e-07,4.36128e-08,0.890457,0.000615807,-3.41912e-07,-4.7423e-08,0.891072,0.000614981,-4.84181e-07,2.68698e-08,0.891687,0.000614093,-4.03572e-07,-4.51384e-10,0.8923,0.000613285,-4.04926e-07,-2.50643e-08,0.892913,0.0006124,-4.80119e-07,4.11038e-08,0.893525,0.000611563,-3.56808e-07,-2.01414e-08,0.894136,0.000610789,-4.17232e-07,-2.01426e-08,0.894747,0.000609894,-4.7766e-07,4.11073e-08,0.895356,0.000609062,-3.54338e-07,-2.50773e-08,0.895965,0.000608278,-4.2957e-07,-4.02954e-10,0.896573,0.000607418,-4.30779e-07,2.66891e-08,0.89718,0.000606636,-3.50711e-07,-4.67489e-08,0.897786,0.000605795,-4.90958e-07,4.10972e-08,0.898391,0.000604936,-3.67666e-07,1.56948e-09,0.898996,0.000604205,-3.62958e-07,-4.73751e-08,0.8996,0.000603337,-5.05083e-07,6.87214e-08,0.900202,0.000602533,-2.98919e-07,-4.86966e-08,0.900805,0.000601789,-4.45009e-07,6.85589e-09,0.901406,0.00060092,-4.24441e-07,2.1273e-08,0.902007,0.000600135,-3.60622e-07,-3.23434e-08,0.902606,0.000599317,-4.57652e-07,4.84959e-08,0.903205,0.000598547,-3.12164e-07,-4.24309e-08,0.903803,0.000597795,-4.39457e-07,2.01844e-09,0.904401,0.000596922,-4.33402e-07,3.43571e-08,0.904997,0.000596159,-3.30331e-07,-2.02374e-08,0.905593,0.000595437,-3.91043e-07,-1.30123e-08,0.906188,0.000594616,-4.3008e-07,1.26819e-08,0.906782,0.000593794,-3.92034e-07,2.18894e-08,0.907376,0.000593076,-3.26366e-07,-4.06349e-08,0.907968,0.000592301,-4.4827e-07,2.1441e-08,0.90856,0.000591469,-3.83947e-07,1.44754e-08,0.909151,0.000590744,-3.40521e-07,-1.97379e-08,0.909742,0.000590004,-3.99735e-07,4.87161e-09,0.910331,0.000589219,-3.8512e-07,2.51532e-10,0.91092,0.00058845,-3.84366e-07,-5.87776e-09,0.911508,0.000587663,-4.01999e-07,2.32595e-08,0.912096,0.000586929,-3.3222e-07,-2.75554e-08,0.912682,0.000586182,-4.14887e-07,2.73573e-08,0.913268,0.000585434,-3.32815e-07,-2.22692e-08,0.913853,0.000584702,-3.99622e-07,2.11486e-09,0.914437,0.000583909,-3.93278e-07,1.38098e-08,0.915021,0.000583164,-3.51848e-07,2.25042e-09,0.915604,0.000582467,-3.45097e-07,-2.28115e-08,0.916186,0.000581708,-4.13531e-07,2.93911e-08,0.916767,0.000580969,-3.25358e-07,-3.51481e-08,0.917348,0.000580213,-4.30803e-07,5.15967e-08,0.917928,0.000579506,-2.76012e-07,-5.20296e-08,0.918507,0.000578798,-4.32101e-07,3.73124e-08,0.919085,0.000578046,-3.20164e-07,-3.76154e-08,0.919663,0.000577293,-4.3301e-07,5.35447e-08,0.92024,0.000576587,-2.72376e-07,-5.7354e-08,0.920816,0.000575871,-4.44438e-07,5.66621e-08,0.921391,0.000575152,-2.74452e-07,-5.00851e-08,0.921966,0.000574453,-4.24707e-07,2.4469e-08,0.92254,0.000573677,-3.513e-07,1.18138e-08,0.923114,0.000573009,-3.15859e-07,-1.21195e-08,0.923686,0.000572341,-3.52217e-07,-2.29403e-08,0.924258,0.000571568,-4.21038e-07,4.4276e-08,0.924829,0.000570859,-2.8821e-07,-3.49546e-08,0.9254,0.000570178,-3.93074e-07,3.59377e-08,0.92597,0.000569499,-2.85261e-07,-4.91915e-08,0.926539,0.000568781,-4.32835e-07,4.16189e-08,0.927107,0.00056804,-3.07979e-07,1.92523e-09,0.927675,0.00056743,-3.02203e-07,-4.93198e-08,0.928242,0.000566678,-4.50162e-07,7.61447e-08,0.928809,0.000566006,-2.21728e-07,-7.6445e-08,0.929374,0.000565333,-4.51063e-07,5.08216e-08,0.929939,0.000564583,-2.98599e-07,-7.63212e-09,0.930503,0.000563963,-3.21495e-07,-2.02931e-08,0.931067,0.000563259,-3.82374e-07,2.92001e-08,0.93163,0.000562582,-2.94774e-07,-3.69025e-08,0.932192,0.000561882,-4.05482e-07,5.88053e-08,0.932754,0.000561247,-2.29066e-07,-7.91094e-08,0.933315,0.000560552,-4.66394e-07,7.88184e-08,0.933875,0.000559856,-2.29939e-07,-5.73501e-08,0.934434,0.000559224,-4.01989e-07,3.13727e-08,0.934993,0.000558514,-3.07871e-07,-8.53611e-09,0.935551,0.000557873,-3.33479e-07,2.77175e-09,0.936109,0.000557214,-3.25164e-07,-2.55091e-09,0.936666,0.000556556,-3.32817e-07,7.43188e-09,0.937222,0.000555913,-3.10521e-07,-2.71766e-08,0.937778,0.00055521,-3.92051e-07,4.167e-08,0.938333,0.000554551,-2.67041e-07,-2.02941e-08,0.938887,0.000553956,-3.27923e-07,-2.00984e-08,0.93944,0.00055324,-3.88218e-07,4.10828e-08,0.939993,0.000552587,-2.6497e-07,-2.50237e-08,0.940546,0.000551982,-3.40041e-07,-5.92583e-10,0.941097,0.0005513,-3.41819e-07,2.7394e-08,0.941648,0.000550698,-2.59637e-07,-4.93788e-08,0.942199,0.000550031,-4.07773e-07,5.09119e-08,0.942748,0.000549368,-2.55038e-07,-3.50595e-08,0.943297,0.000548753,-3.60216e-07,2.97214e-08,0.943846,0.000548122,-2.71052e-07,-2.42215e-08,0.944394,0.000547507,-3.43716e-07,7.55985e-09,0.944941,0.000546842,-3.21037e-07,-6.01796e-09,0.945487,0.000546182,-3.3909e-07,1.65119e-08,0.946033,0.000545553,-2.89555e-07,-4.2498e-10,0.946578,0.000544973,-2.9083e-07,-1.4812e-08,0.947123,0.000544347,-3.35266e-07,6.83068e-11,0.947667,0.000543676,-3.35061e-07,1.45388e-08,0.94821,0.00054305,-2.91444e-07,1.38123e-09,0.948753,0.000542471,-2.87301e-07,-2.00637e-08,0.949295,0.000541836,-3.47492e-07,1.92688e-08,0.949837,0.000541199,-2.89685e-07,2.59298e-09,0.950378,0.000540628,-2.81906e-07,-2.96407e-08,0.950918,0.000539975,-3.70829e-07,5.63652e-08,0.951458,0.000539402,-2.01733e-07,-7.66107e-08,0.951997,0.000538769,-4.31565e-07,7.12638e-08,0.952535,0.00053812,-2.17774e-07,-2.96305e-08,0.953073,0.000537595,-3.06665e-07,-1.23464e-08,0.95361,0.000536945,-3.43704e-07,1.94114e-08,0.954147,0.000536316,-2.8547e-07,-5.69451e-09,0.954683,0.000535728,-3.02554e-07,3.36666e-09,0.955219,0.000535133,-2.92454e-07,-7.77208e-09,0.955753,0.000534525,-3.1577e-07,2.77216e-08,0.956288,0.000533976,-2.32605e-07,-4.35097e-08,0.956821,0.00053338,-3.63134e-07,2.7108e-08,0.957354,0.000532735,-2.8181e-07,-5.31772e-09,0.957887,0.000532156,-2.97764e-07,-5.83718e-09,0.958419,0.000531543,-3.15275e-07,2.86664e-08,0.95895,0.000530998,-2.29276e-07,-4.9224e-08,0.959481,0.000530392,-3.76948e-07,4.90201e-08,0.960011,0.000529785,-2.29887e-07,-2.76471e-08,0.96054,0.000529243,-3.12829e-07,1.96385e-09,0.961069,0.000528623,-3.06937e-07,1.97917e-08,0.961598,0.000528068,-2.47562e-07,-2.15261e-08,0.962125,0.000527508,-3.1214e-07,6.70795e-09,0.962653,0.000526904,-2.92016e-07,-5.30573e-09,0.963179,0.000526304,-3.07934e-07,1.4515e-08,0.963705,0.000525732,-2.64389e-07,6.85048e-09,0.964231,0.000525224,-2.43837e-07,-4.19169e-08,0.964756,0.00052461,-3.69588e-07,4.1608e-08,0.96528,0.000523996,-2.44764e-07,-5.30598e-09,0.965804,0.000523491,-2.60682e-07,-2.03841e-08,0.966327,0.000522908,-3.21834e-07,2.72378e-08,0.966849,0.000522346,-2.40121e-07,-2.89625e-08,0.967371,0.000521779,-3.27008e-07,2.90075e-08,0.967893,0.000521212,-2.39986e-07,-2.74629e-08,0.968414,0.00052065,-3.22374e-07,2.12396e-08,0.968934,0.000520069,-2.58656e-07,2.10922e-09,0.969454,0.000519558,-2.52328e-07,-2.96765e-08,0.969973,0.000518964,-3.41357e-07,5.6992e-08,0.970492,0.000518452,-1.70382e-07,-7.90821e-08,0.97101,0.000517874,-4.07628e-07,8.05224e-08,0.971528,0.000517301,-1.66061e-07,-6.41937e-08,0.972045,0.000516776,-3.58642e-07,5.70429e-08,0.972561,0.00051623,-1.87513e-07,-4.47686e-08,0.973077,0.00051572,-3.21819e-07,2.82237e-09,0.973593,0.000515085,-3.13352e-07,3.34792e-08,0.974108,0.000514559,-2.12914e-07,-1.75298e-08,0.974622,0.000514081,-2.65503e-07,-2.29648e-08,0.975136,0.000513481,-3.34398e-07,4.97843e-08,0.975649,0.000512961,-1.85045e-07,-5.6963e-08,0.976162,0.00051242,-3.55934e-07,5.88585e-08,0.976674,0.000511885,-1.79359e-07,-5.92616e-08,0.977185,0.000511348,-3.57143e-07,5.89785e-08,0.977696,0.000510811,-1.80208e-07,-5.74433e-08,0.978207,0.000510278,-3.52538e-07,5.15854e-08,0.978717,0.000509728,-1.97781e-07,-2.9689e-08,0.979226,0.000509243,-2.86848e-07,7.56591e-09,0.979735,0.000508692,-2.64151e-07,-5.74649e-10,0.980244,0.000508162,-2.65875e-07,-5.26732e-09,0.980752,0.000507615,-2.81677e-07,2.16439e-08,0.981259,0.000507116,-2.16745e-07,-2.17037e-08,0.981766,0.000506618,-2.81856e-07,5.56636e-09,0.982272,0.000506071,-2.65157e-07,-5.61689e-10,0.982778,0.000505539,-2.66842e-07,-3.31963e-09,0.983283,0.000504995,-2.76801e-07,1.38402e-08,0.983788,0.000504483,-2.3528e-07,7.56339e-09,0.984292,0.000504035,-2.1259e-07,-4.40938e-08,0.984796,0.000503478,-3.44871e-07,4.96026e-08,0.985299,0.000502937,-1.96064e-07,-3.51071e-08,0.985802,0.000502439,-3.01385e-07,3.12212e-08,0.986304,0.00050193,-2.07721e-07,-3.0173e-08,0.986806,0.000501424,-2.9824e-07,2.9866e-08,0.987307,0.000500917,-2.08642e-07,-2.96865e-08,0.987808,0.000500411,-2.97702e-07,2.92753e-08,0.988308,0.000499903,-2.09876e-07,-2.78101e-08,0.988807,0.0004994,-2.93306e-07,2.23604e-08,0.989307,0.000498881,-2.26225e-07,-2.02681e-09,0.989805,0.000498422,-2.32305e-07,-1.42531e-08,0.990303,0.000497915,-2.75065e-07,-5.65232e-10,0.990801,0.000497363,-2.76761e-07,1.65141e-08,0.991298,0.000496859,-2.27218e-07,-5.88639e-09,0.991795,0.000496387,-2.44878e-07,7.0315e-09,0.992291,0.000495918,-2.23783e-07,-2.22396e-08,0.992787,0.000495404,-2.90502e-07,2.23224e-08,0.993282,0.00049489,-2.23535e-07,-7.44543e-09,0.993776,0.000494421,-2.45871e-07,7.45924e-09,0.994271,0.000493951,-2.23493e-07,-2.23915e-08,0.994764,0.000493437,-2.90668e-07,2.25021e-08,0.995257,0.000492923,-2.23161e-07,-8.01218e-09,0.99575,0.000492453,-2.47198e-07,9.54669e-09,0.996242,0.000491987,-2.18558e-07,-3.01746e-08,0.996734,0.000491459,-3.09082e-07,5.1547e-08,0.997225,0.000490996,-1.54441e-07,-5.68039e-08,0.997716,0.000490517,-3.24853e-07,5.64594e-08,0.998206,0.000490036,-1.55474e-07,-4.98245e-08,0.998696,0.000489576,-3.04948e-07,2.36292e-08,0.999186,0.000489037,-2.3406e-07,1.49121e-08,0.999674,0.000488613,-1.89324e-07,-2.3673e-08,1.00016,0.000488164,-2.60343e-07,2.01754e-08,1.00065,0.000487704,-1.99816e-07,-5.70288e-08,1.00114,0.000487133,-3.70903e-07,8.87303e-08,1.00162,0.000486657,-1.04712e-07,-5.94737e-08,1.00211,0.000486269,-2.83133e-07,2.99553e-08,1.0026,0.000485793,-1.93267e-07,-6.03474e-08,1.00308,0.000485225,-3.74309e-07,9.2225e-08,1.00357,0.000484754,-9.76345e-08,-7.0134e-08,1.00405,0.000484348,-3.08036e-07,6.91016e-08,1.00454,0.000483939,-1.00731e-07,-8.70633e-08,1.00502,0.000483476,-3.61921e-07,4.07328e-08,1.0055,0.000482875,-2.39723e-07,4.33413e-08,1.00599,0.000482525,-1.09699e-07,-9.48886e-08,1.00647,0.000482021,-3.94365e-07,9.77947e-08,1.00695,0.000481526,-1.00981e-07,-5.78713e-08,1.00743,0.00048115,-2.74595e-07,1.44814e-08,1.00791,0.000480645,-2.31151e-07,-5.42665e-11,1.00839,0.000480182,-2.31314e-07,-1.42643e-08,1.00887,0.000479677,-2.74106e-07,5.71115e-08,1.00935,0.0004793,-1.02772e-07,-9.49724e-08,1.00983,0.000478809,-3.87689e-07,8.43596e-08,1.01031,0.000478287,-1.3461e-07,-4.04755e-09,1.01079,0.000478006,-1.46753e-07,-6.81694e-08,1.01127,0.000477508,-3.51261e-07,3.83067e-08,1.01174,0.00047692,-2.36341e-07,3.41521e-08,1.01222,0.00047655,-1.33885e-07,-5.57058e-08,1.0127,0.000476115,-3.01002e-07,6.94616e-08,1.01317,0.000475721,-9.26174e-08,-1.02931e-07,1.01365,0.000475227,-4.01412e-07,1.03846e-07,1.01412,0.000474736,-8.98751e-08,-7.40321e-08,1.0146,0.000474334,-3.11971e-07,7.30735e-08,1.01507,0.00047393,-9.27508e-08,-9.90527e-08,1.01554,0.000473447,-3.89909e-07,8.47188e-08,1.01602,0.000472921,-1.35753e-07,-1.40381e-09,1.01649,0.000472645,-1.39964e-07,-7.91035e-08,1.01696,0.000472128,-3.77275e-07,7.93993e-08,1.01744,0.000471612,-1.39077e-07,-7.52607e-11,1.01791,0.000471334,-1.39302e-07,-7.90983e-08,1.01838,0.000470818,-3.76597e-07,7.80499e-08,1.01885,0.000470299,-1.42448e-07,5.31733e-09,1.01932,0.00047003,-1.26496e-07,-9.93193e-08,1.01979,0.000469479,-4.24453e-07,1.53541e-07,1.02026,0.00046909,3.617e-08,-1.57217e-07,1.02073,0.000468691,-4.35482e-07,1.177e-07,1.02119,0.000468173,-8.23808e-08,-7.51659e-08,1.02166,0.000467783,-3.07878e-07,6.37538e-08,1.02213,0.000467358,-1.16617e-07,-6.064e-08,1.0226,0.000466943,-2.98537e-07,5.9597e-08,1.02306,0.000466525,-1.19746e-07,-5.85386e-08,1.02353,0.00046611,-2.95362e-07,5.53482e-08,1.024,0.000465685,-1.29317e-07,-4.36449e-08,1.02446,0.000465296,-2.60252e-07,2.20268e-11,1.02493,0.000464775,-2.60186e-07,4.35568e-08,1.02539,0.000464386,-1.29516e-07,-5.50398e-08,1.02586,0.000463961,-2.94635e-07,5.73932e-08,1.02632,0.000463544,-1.22456e-07,-5.53236e-08,1.02678,0.000463133,-2.88426e-07,4.46921e-08,1.02725,0.000462691,-1.5435e-07,-4.23534e-09,1.02771,0.000462369,-1.67056e-07,-2.77507e-08,1.02817,0.000461952,-2.50308e-07,-3.97101e-09,1.02863,0.000461439,-2.62221e-07,4.36348e-08,1.02909,0.000461046,-1.31317e-07,-5.13589e-08,1.02955,0.000460629,-2.85394e-07,4.25913e-08,1.03001,0.000460186,-1.5762e-07,2.0285e-10,1.03047,0.000459871,-1.57011e-07,-4.34027e-08,1.03093,0.000459427,-2.87219e-07,5.41987e-08,1.03139,0.000459015,-1.24623e-07,-5.4183e-08,1.03185,0.000458604,-2.87172e-07,4.33239e-08,1.03231,0.000458159,-1.572e-07,9.65817e-11,1.03277,0.000457845,-1.56911e-07,-4.37103e-08,1.03323,0.0004574,-2.88041e-07,5.55351e-08,1.03368,0.000456991,-1.21436e-07,-5.9221e-08,1.03414,0.00045657,-2.99099e-07,6.21394e-08,1.0346,0.000456158,-1.1268e-07,-7.01275e-08,1.03505,0.000455723,-3.23063e-07,9.91614e-08,1.03551,0.000455374,-2.55788e-08,-8.80996e-08,1.03596,0.000455058,-2.89878e-07,1.48184e-08,1.03642,0.000454523,-2.45422e-07,2.88258e-08,1.03687,0.000454119,-1.58945e-07,-1.09125e-08,1.03733,0.000453768,-1.91682e-07,1.48241e-08,1.03778,0.000453429,-1.4721e-07,-4.83838e-08,1.03823,0.00045299,-2.92361e-07,5.95019e-08,1.03869,0.000452584,-1.13856e-07,-7.04146e-08,1.03914,0.000452145,-3.25099e-07,1.02947e-07,1.03959,0.000451803,-1.62583e-08,-1.02955e-07,1.04004,0.000451462,-3.25123e-07,7.04544e-08,1.04049,0.000451023,-1.1376e-07,-5.96534e-08,1.04094,0.000450616,-2.9272e-07,4.89499e-08,1.04139,0.000450178,-1.45871e-07,-1.69369e-08,1.04184,0.000449835,-1.96681e-07,1.87977e-08,1.04229,0.000449498,-1.40288e-07,-5.82539e-08,1.04274,0.000449043,-3.1505e-07,9.50087e-08,1.04319,0.000448698,-3.00238e-08,-8.33623e-08,1.04364,0.000448388,-2.80111e-07,2.20363e-11,1.04409,0.000447828,-2.80045e-07,8.32742e-08,1.04454,0.000447517,-3.02221e-08,-9.47002e-08,1.04498,0.000447173,-3.14323e-07,5.7108e-08,1.04543,0.000446716,-1.42999e-07,-1.45225e-08,1.04588,0.000446386,-1.86566e-07,9.82022e-10,1.04632,0.000446016,-1.8362e-07,1.05944e-08,1.04677,0.00044568,-1.51837e-07,-4.33597e-08,1.04721,0.000445247,-2.81916e-07,4.36352e-08,1.04766,0.000444814,-1.51011e-07,-1.19717e-08,1.0481,0.000444476,-1.86926e-07,4.25158e-09,1.04855,0.000444115,-1.74171e-07,-5.03461e-09,1.04899,0.000443751,-1.89275e-07,1.58868e-08,1.04944,0.00044342,-1.41614e-07,-5.85127e-08,1.04988,0.000442961,-3.17152e-07,9.89548e-08,1.05032,0.000442624,-2.0288e-08,-9.88878e-08,1.05076,0.000442287,-3.16951e-07,5.81779e-08,1.05121,0.000441827,-1.42418e-07,-1.46144e-08,1.05165,0.000441499,-1.86261e-07,2.79892e-10,1.05209,0.000441127,-1.85421e-07,1.34949e-08,1.05253,0.000440797,-1.44937e-07,-5.42594e-08,1.05297,0.000440344,-3.07715e-07,8.43335e-08,1.05341,0.000439982,-5.47146e-08,-4.46558e-08,1.05385,0.000439738,-1.88682e-07,-2.49193e-08,1.05429,0.000439286,-2.6344e-07,2.5124e-08,1.05473,0.000438835,-1.88068e-07,4.36328e-08,1.05517,0.000438589,-5.71699e-08,-8.04459e-08,1.05561,0.000438234,-2.98508e-07,3.97324e-08,1.05605,0.000437756,-1.79311e-07,4.07258e-08,1.05648,0.000437519,-5.71332e-08,-8.34263e-08,1.05692,0.000437155,-3.07412e-07,5.45608e-08,1.05736,0.000436704,-1.4373e-07,-1.56078e-08,1.05779,0.000436369,-1.90553e-07,7.87043e-09,1.05823,0.000436012,-1.66942e-07,-1.58739e-08,1.05867,0.00043563,-2.14563e-07,5.56251e-08,1.0591,0.000435368,-4.76881e-08,-8.74172e-08,1.05954,0.000435011,-3.0994e-07,5.56251e-08,1.05997,0.000434558,-1.43064e-07,-1.58739e-08,1.06041,0.000434224,-1.90686e-07,7.87042e-09,1.06084,0.000433866,-1.67075e-07,-1.56078e-08,1.06127,0.000433485,-2.13898e-07,5.45609e-08,1.06171,0.000433221,-5.02157e-08,-8.34263e-08,1.06214,0.00043287,-3.00495e-07,4.07258e-08,1.06257,0.000432391,-1.78317e-07,3.97325e-08,1.063,0.000432154,-5.91198e-08,-8.04464e-08,1.06344,0.000431794,-3.00459e-07,4.36347e-08,1.06387,0.000431324,-1.69555e-07,2.5117e-08,1.0643,0.000431061,-9.42041e-08,-2.48934e-08,1.06473,0.000430798,-1.68884e-07,-4.47527e-08,1.06516,0.000430326,-3.03142e-07,8.46951e-08,1.06559,0.000429973,-4.90573e-08,-5.56089e-08,1.06602,0.000429708,-2.15884e-07,1.85314e-08,1.06645,0.000429332,-1.6029e-07,-1.85166e-08,1.06688,0.000428956,-2.1584e-07,5.5535e-08,1.06731,0.000428691,-4.92347e-08,-8.44142e-08,1.06774,0.000428339,-3.02477e-07,4.37032e-08,1.06816,0.000427865,-1.71368e-07,2.88107e-08,1.06859,0.000427609,-8.49356e-08,-3.97367e-08,1.06902,0.00042732,-2.04146e-07,1.09267e-08,1.06945,0.000426945,-1.71365e-07,-3.97023e-09,1.06987,0.00042659,-1.83276e-07,4.9542e-09,1.0703,0.000426238,-1.68414e-07,-1.58466e-08,1.07073,0.000425854,-2.15953e-07,5.84321e-08,1.07115,0.000425597,-4.0657e-08,-9.86725e-08,1.07158,0.00042522,-3.36674e-07,9.78392e-08,1.072,0.00042484,-4.31568e-08,-5.42658e-08,1.07243,0.000424591,-2.05954e-07,1.45377e-11,1.07285,0.000424179,-2.0591e-07,5.42076e-08,1.07328,0.00042393,-4.32877e-08,-9.76357e-08,1.0737,0.00042355,-3.36195e-07,9.79165e-08,1.07412,0.000423172,-4.24451e-08,-5.56118e-08,1.07455,0.00042292,-2.09281e-07,5.32143e-09,1.07497,0.000422518,-1.93316e-07,3.43261e-08,1.07539,0.000422234,-9.0338e-08,-2.34165e-08,1.07581,0.000421983,-1.60588e-07,-5.98692e-08,1.07623,0.000421482,-3.40195e-07,1.43684e-07,1.07666,0.000421233,9.08574e-08,-1.5724e-07,1.07708,0.000420943,-3.80862e-07,1.27647e-07,1.0775,0.000420564,2.0791e-09,-1.1493e-07,1.07792,0.000420223,-3.4271e-07,9.36534e-08,1.07834,0.000419819,-6.17499e-08,-2.12653e-08,1.07876,0.000419632,-1.25546e-07,-8.59219e-09,1.07918,0.000419355,-1.51322e-07,-6.35752e-08,1.0796,0.000418861,-3.42048e-07,1.43684e-07,1.08002,0.000418608,8.90034e-08,-1.53532e-07,1.08043,0.000418326,-3.71593e-07,1.12817e-07,1.08085,0.000417921,-3.31414e-08,-5.93184e-08,1.08127,0.000417677,-2.11097e-07,5.24697e-09,1.08169,0.00041727,-1.95356e-07,3.83305e-08,1.0821,0.000416995,-8.03642e-08,-3.93597e-08,1.08252,0.000416716,-1.98443e-07,-1.0094e-10,1.08294,0.000416319,-1.98746e-07,3.97635e-08,1.08335,0.00041604,-7.94557e-08,-3.97437e-08,1.08377,0.000415762,-1.98687e-07,1.94215e-12,1.08419,0.000415365,-1.98681e-07,3.97359e-08,1.0846,0.000415087,-7.94732e-08,-3.97362e-08,1.08502,0.000414809,-1.98682e-07,-4.31063e-13,1.08543,0.000414411,-1.98683e-07,3.97379e-08,1.08584,0.000414133,-7.94694e-08,-3.97418e-08,1.08626,0.000413855,-1.98695e-07,2.00563e-11,1.08667,0.000413458,-1.98635e-07,3.96616e-08,1.08709,0.000413179,-7.965e-08,-3.9457e-08,1.0875,0.000412902,-1.98021e-07,-1.04281e-09,1.08791,0.000412502,-2.01149e-07,4.36282e-08,1.08832,0.000412231,-7.02648e-08,-5.42608e-08,1.08874,0.000411928,-2.33047e-07,5.42057e-08,1.08915,0.000411624,-7.04301e-08,-4.33527e-08,1.08956,0.000411353,-2.00488e-07,-4.07378e-12,1.08997,0.000410952,-2.005e-07,4.3369e-08,1.09038,0.000410681,-7.03934e-08,-5.42627e-08,1.09079,0.000410378,-2.33182e-07,5.44726e-08,1.0912,0.000410075,-6.97637e-08,-4.44186e-08,1.09161,0.000409802,-2.03019e-07,3.99235e-09,1.09202,0.000409408,-1.91042e-07,2.84491e-08,1.09243,0.000409111,-1.05695e-07,1.42043e-09,1.09284,0.000408904,-1.01434e-07,-3.41308e-08,1.09325,0.000408599,-2.03826e-07,1.58937e-08,1.09366,0.000408239,-1.56145e-07,-2.94438e-08,1.09406,0.000407838,-2.44476e-07,1.01881e-07,1.09447,0.000407655,6.11676e-08,-1.39663e-07,1.09488,0.000407358,-3.57822e-07,9.91432e-08,1.09529,0.00040694,-6.03921e-08,-1.84912e-08,1.09569,0.000406764,-1.15866e-07,-2.51785e-08,1.0961,0.000406457,-1.91401e-07,-4.03115e-12,1.09651,0.000406074,-1.91413e-07,2.51947e-08,1.09691,0.000405767,-1.15829e-07,1.84346e-08,1.09732,0.00040559,-6.05254e-08,-9.89332e-08,1.09772,0.000405172,-3.57325e-07,1.3888e-07,1.09813,0.000404874,5.93136e-08,-9.8957e-08,1.09853,0.000404696,-2.37557e-07,1.853e-08,1.09894,0.000404277,-1.81968e-07,2.48372e-08,1.09934,0.000403987,-1.07456e-07,1.33047e-09,1.09975,0.000403776,-1.03465e-07,-3.01591e-08,1.10015,0.000403479,-1.93942e-07,9.66054e-11,1.10055,0.000403091,-1.93652e-07,2.97727e-08,1.10096,0.000402793,-1.04334e-07,2.19273e-11,1.10136,0.000402585,-1.04268e-07,-2.98604e-08,1.10176,0.000402287,-1.93849e-07,2.10325e-10,1.10216,0.0004019,-1.93218e-07,2.90191e-08,1.10256,0.0004016,-1.06161e-07,2.92264e-09,1.10297,0.000401397,-9.73931e-08,-4.07096e-08,1.10337,0.00040108,-2.19522e-07,4.07067e-08,1.10377,0.000400763,-9.7402e-08,-2.90783e-09,1.10417,0.000400559,-1.06126e-07,-2.90754e-08,1.10457,0.00040026,-1.93352e-07,9.00021e-14,1.10497,0.000399873,-1.93351e-07,2.9075e-08,1.10537,0.000399574,-1.06126e-07,2.90902e-09,1.10577,0.00039937,-9.73992e-08,-4.07111e-08,1.10617,0.000399053,-2.19533e-07,4.07262e-08,1.10657,0.000398736,-9.73541e-08,-2.98424e-09,1.10697,0.000398533,-1.06307e-07,-2.87892e-08,1.10736,0.000398234,-1.92674e-07,-1.06824e-09,1.10776,0.000397845,-1.95879e-07,3.30622e-08,1.10816,0.000397552,-9.66926e-08,-1.19712e-08,1.10856,0.000397323,-1.32606e-07,1.48225e-08,1.10895,0.000397102,-8.81387e-08,-4.73187e-08,1.10935,0.000396784,-2.30095e-07,5.52429e-08,1.10975,0.00039649,-6.4366e-08,-5.44437e-08,1.11014,0.000396198,-2.27697e-07,4.33226e-08,1.11054,0.000395872,-9.77293e-08,3.62656e-10,1.11094,0.000395678,-9.66414e-08,-4.47732e-08,1.11133,0.00039535,-2.30961e-07,5.95208e-08,1.11173,0.000395067,-5.23985e-08,-7.41008e-08,1.11212,0.00039474,-2.74701e-07,1.17673e-07,1.11252,0.000394543,7.83181e-08,-1.58172e-07,1.11291,0.000394225,-3.96199e-07,1.57389e-07,1.1133,0.000393905,7.59679e-08,-1.13756e-07,1.1137,0.000393716,-2.653e-07,5.92165e-08,1.11409,0.000393363,-8.76507e-08,-3.90074e-09,1.11449,0.000393176,-9.93529e-08,-4.36136e-08,1.11488,0.000392846,-2.30194e-07,5.91457e-08,1.11527,0.000392563,-5.27564e-08,-7.376e-08,1.11566,0.000392237,-2.74037e-07,1.16685e-07,1.11606,0.000392039,7.60189e-08,-1.54562e-07,1.11645,0.000391727,-3.87667e-07,1.43935e-07,1.11684,0.000391384,4.4137e-08,-6.35487e-08,1.11723,0.000391281,-1.46509e-07,-8.94896e-09,1.11762,0.000390961,-1.73356e-07,-1.98647e-08,1.11801,0.000390555,-2.3295e-07,8.8408e-08,1.1184,0.000390354,3.22736e-08,-9.53486e-08,1.11879,0.000390133,-2.53772e-07,5.45677e-08,1.11918,0.000389789,-9.0069e-08,-3.71296e-09,1.11957,0.000389598,-1.01208e-07,-3.97159e-08,1.11996,0.000389276,-2.20355e-07,4.33671e-08,1.12035,0.000388966,-9.02542e-08,-1.45431e-08,1.12074,0.000388741,-1.33883e-07,1.48052e-08,1.12113,0.000388518,-8.94678e-08,-4.46778e-08,1.12152,0.000388205,-2.23501e-07,4.46966e-08,1.12191,0.000387892,-8.94114e-08,-1.48992e-08,1.12229,0.000387669,-1.34109e-07,1.49003e-08,1.12268,0.000387445,-8.94082e-08,-4.47019e-08,1.12307,0.000387132,-2.23514e-07,4.4698e-08,1.12345,0.000386819,-8.942e-08,-1.48806e-08,1.12384,0.000386596,-1.34062e-07,1.48245e-08,1.12423,0.000386372,-8.95885e-08,-4.44172e-08,1.12461,0.00038606,-2.2284e-07,4.36351e-08,1.125,0.000385745,-9.19348e-08,-1.09139e-08,1.12539,0.000385528,-1.24677e-07,2.05584e-11,1.12577,0.000385279,-1.24615e-07,1.08317e-08,1.12616,0.000385062,-9.21198e-08,-4.33473e-08,1.12654,0.000384748,-2.22162e-07,4.33481e-08,1.12693,0.000384434,-9.21174e-08,-1.08356e-08,1.12731,0.000384217,-1.24624e-07,-5.50907e-12,1.12769,0.000383968,-1.24641e-07,1.08577e-08,1.12808,0.000383751,-9.20679e-08,-4.34252e-08,1.12846,0.000383437,-2.22343e-07,4.36337e-08,1.12884,0.000383123,-9.14422e-08,-1.19005e-08,1.12923,0.000382904,-1.27144e-07,3.96813e-09,1.12961,0.000382662,-1.15239e-07,-3.97207e-09,1.12999,0.000382419,-1.27155e-07,1.19201e-08,1.13038,0.000382201,-9.1395e-08,-4.37085e-08,1.13076,0.000381887,-2.2252e-07,4.37046e-08,1.13114,0.000381573,-9.14068e-08,-1.19005e-08,1.13152,0.000381355,-1.27108e-07,3.89734e-09,1.1319,0.000381112,-1.15416e-07,-3.68887e-09,1.13228,0.00038087,-1.26483e-07,1.08582e-08,1.13266,0.00038065,-9.39083e-08,-3.97438e-08,1.13304,0.000380343,-2.1314e-07,2.89076e-08,1.13342,0.000380003,-1.26417e-07,4.33225e-08,1.1338,0.00037988,3.55072e-09,-8.29883e-08,1.13418,0.000379638,-2.45414e-07,5.0212e-08,1.13456,0.000379298,-9.47781e-08,1.34964e-09,1.13494,0.000379113,-9.07292e-08,-5.56105e-08,1.13532,0.000378764,-2.57561e-07,1.01883e-07,1.1357,0.000378555,4.80889e-08,-1.13504e-07,1.13608,0.000378311,-2.92423e-07,1.13713e-07,1.13646,0.000378067,4.87176e-08,-1.02931e-07,1.13683,0.000377856,-2.60076e-07,5.95923e-08,1.13721,0.000377514,-8.12988e-08,-1.62288e-08,1.13759,0.000377303,-1.29985e-07,5.32278e-09,1.13797,0.000377059,-1.14017e-07,-5.06237e-09,1.13834,0.000376816,-1.29204e-07,1.49267e-08,1.13872,0.000376602,-8.44237e-08,-5.46444e-08,1.1391,0.000376269,-2.48357e-07,8.44417e-08,1.13947,0.000376026,4.96815e-09,-4.47039e-08,1.13985,0.000375902,-1.29143e-07,-2.48355e-08,1.14023,0.000375569,-2.0365e-07,2.48368e-08,1.1406,0.000375236,-1.2914e-07,4.46977e-08,1.14098,0.000375112,4.95341e-09,-8.44184e-08,1.14135,0.000374869,-2.48302e-07,5.45572e-08,1.14173,0.000374536,-8.463e-08,-1.46013e-08,1.1421,0.000374323,-1.28434e-07,3.8478e-09,1.14247,0.000374077,-1.1689e-07,-7.89941e-10,1.14285,0.000373841,-1.1926e-07,-6.88042e-10,1.14322,0.0003736,-1.21324e-07,3.54213e-09,1.1436,0.000373368,-1.10698e-07,-1.34805e-08,1.14397,0.000373107,-1.51139e-07,5.03798e-08,1.14434,0.000372767,0.,0.}; + + template + __device__ __forceinline__ void RGB2LuvConvert_f(const T& src, D& dst) + { + const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); + const float _un = 13 * (4 * 0.950456f * _d); + const float _vn = 13 * (9 * _d); + + float B = blueIdx == 0 ? src.x : src.z; + float G = src.y; + float R = blueIdx == 0 ? src.z : src.x; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); + } + + float X = R * 0.412453f + G * 0.357580f + B * 0.180423f; + float Y = R * 0.212671f + G * 0.715160f + B * 0.072169f; + float Z = R * 0.019334f + G * 0.119193f + B * 0.950227f; + + float L = splineInterpolate(Y * (LAB_CBRT_TAB_SIZE / 1.5f), c_LabCbrtTab, LAB_CBRT_TAB_SIZE); + L = 116.f * L - 16.f; + + const float d = (4 * 13) / ::fmaxf(X + 15 * Y + 3 * Z, numeric_limits::epsilon()); + float u = L * (X * d - _un); + float v = L * ((9 * 0.25f) * Y * d - _vn); + + dst.x = L; + dst.y = u; + dst.z = v; + } + + template + __device__ __forceinline__ void RGB2LuvConvert_b(const T& src, D& dst) + { + float3 srcf, dstf; + + srcf.x = src.x * (1.f / 255.f); + srcf.y = src.y * (1.f / 255.f); + srcf.z = src.z * (1.f / 255.f); + + RGB2LuvConvert_f(srcf, dstf); + + dst.x = saturate_cast(dstf.x * 2.55f); + dst.y = saturate_cast(dstf.y * 0.72033898305084743f + 96.525423728813564f); + dst.z = saturate_cast(dstf.z * 0.9732824427480916f + 136.259541984732824f); + } + + template struct RGB2Luv; + template + struct RGB2Luv + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LuvConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Luv() {} + __host__ __device__ __forceinline__ RGB2Luv(const RGB2Luv&) {} + }; + template + struct RGB2Luv + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + RGB2LuvConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ RGB2Luv() {} + __host__ __device__ __forceinline__ RGB2Luv(const RGB2Luv&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_RGB2Luv_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::RGB2Luv functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + namespace color_detail + { + template + __device__ __forceinline__ void Luv2RGBConvert_f(const T& src, D& dst) + { + const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); + const float _un = 4 * 0.950456f * _d; + const float _vn = 9 * _d; + + float L = src.x; + float u = src.y; + float v = src.z; + + float Y = (L + 16.f) * (1.f / 116.f); + Y = Y * Y * Y; + + float d = (1.f / 13.f) / L; + u = u * d + _un; + v = v * d + _vn; + + float iv = 1.f / v; + float X = 2.25f * u * Y * iv; + float Z = (12 - 3 * u - 20 * v) * Y * 0.25f * iv; + + float B = 0.055648f * X - 0.204043f * Y + 1.057311f * Z; + float G = -0.969256f * X + 1.875991f * Y + 0.041556f * Z; + float R = 3.240479f * X - 1.537150f * Y - 0.498535f * Z; + + if (srgb) + { + B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); + } + + dst.x = blueIdx == 0 ? B : R; + dst.y = G; + dst.z = blueIdx == 0 ? R : B; + setAlpha(dst, ColorChannel::max()); + } + + template + __device__ __forceinline__ void Luv2RGBConvert_b(const T& src, D& dst) + { + float3 srcf, dstf; + + srcf.x = src.x * (100.f / 255.f); + srcf.y = src.y * 1.388235294117647f - 134.f; + srcf.z = src.z * 1.027450980392157f - 140.f; + + Luv2RGBConvert_f(srcf, dstf); + + dst.x = saturate_cast(dstf.x * 255.f); + dst.y = saturate_cast(dstf.y * 255.f); + dst.z = saturate_cast(dstf.z * 255.f); + setAlpha(dst, ColorChannel::max()); + } + + template struct Luv2RGB; + template + struct Luv2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Luv2RGBConvert_b(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Luv2RGB() {} + __host__ __device__ __forceinline__ Luv2RGB(const Luv2RGB&) {} + }; + template + struct Luv2RGB + : unary_function::vec_type, typename TypeVec::vec_type> + { + __device__ __forceinline__ typename TypeVec::vec_type operator ()(const typename TypeVec::vec_type& src) const + { + typename TypeVec::vec_type dst; + + Luv2RGBConvert_f(src, dst); + + return dst; + } + __host__ __device__ __forceinline__ Luv2RGB() {} + __host__ __device__ __forceinline__ Luv2RGB(const Luv2RGB&) {} + }; + } + +#define OPENCV_CUDA_IMPLEMENT_Luv2RGB_TRAITS(name, scn, dcn, srgb, blueIdx) \ + template struct name ## _traits \ + { \ + typedef ::cv::cuda::device::color_detail::Luv2RGB functor_type; \ + static __host__ __device__ __forceinline__ functor_type create_functor() \ + { \ + return functor_type(); \ + } \ + }; + + #undef CV_DESCALE + +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_COLOR_DETAIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce.hpp new file mode 100644 index 0000000..8af20b0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce.hpp @@ -0,0 +1,365 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_REDUCE_DETAIL_HPP +#define OPENCV_CUDA_REDUCE_DETAIL_HPP + +#include +#include "../warp.hpp" +#include "../warp_shuffle.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace reduce_detail + { + template struct GetType; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple& smem, const ValTuple& val, unsigned int tid) + { + thrust::get(smem)[tid] = thrust::get(val); + + For::loadToSmem(smem, val, tid); + } + template + static __device__ void loadFromSmem(const PointerTuple& smem, const ValTuple& val, unsigned int tid) + { + thrust::get(val) = thrust::get(smem)[tid]; + + For::loadFromSmem(smem, val, tid); + } + + template + static __device__ void merge(const PointerTuple& smem, const ValTuple& val, unsigned int tid, unsigned int delta, const OpTuple& op) + { + typename GetType::type>::type reg = thrust::get(smem)[tid + delta]; + thrust::get(smem)[tid] = thrust::get(val) = thrust::get(op)(thrust::get(val), reg); + + For::merge(smem, val, tid, delta, op); + } + template + static __device__ void mergeShfl(const ValTuple& val, unsigned int delta, unsigned int width, const OpTuple& op) + { + typename GetType::type>::type reg = shfl_down(thrust::get(val), delta, width); + thrust::get(val) = thrust::get(op)(thrust::get(val), reg); + + For::mergeShfl(val, delta, width, op); + } + }; + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple&, const ValTuple&, unsigned int) + { + } + template + static __device__ void loadFromSmem(const PointerTuple&, const ValTuple&, unsigned int) + { + } + + template + static __device__ void merge(const PointerTuple&, const ValTuple&, unsigned int, unsigned int, const OpTuple&) + { + } + template + static __device__ void mergeShfl(const ValTuple&, unsigned int, unsigned int, const OpTuple&) + { + } + }; + + template + __device__ __forceinline__ void loadToSmem(volatile T* smem, T& val, unsigned int tid) + { + smem[tid] = val; + } + template + __device__ __forceinline__ void loadFromSmem(volatile T* smem, T& val, unsigned int tid) + { + val = smem[tid]; + } + template + __device__ __forceinline__ void loadToSmem(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadToSmem(smem, val, tid); + } + template + __device__ __forceinline__ void loadFromSmem(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadFromSmem(smem, val, tid); + } + + template + __device__ __forceinline__ void merge(volatile T* smem, T& val, unsigned int tid, unsigned int delta, const Op& op) + { + T reg = smem[tid + delta]; + smem[tid] = val = op(val, reg); + } + template + __device__ __forceinline__ void mergeShfl(T& val, unsigned int delta, unsigned int width, const Op& op) + { + T reg = shfl_down(val, delta, width); + val = op(val, reg); + } + template + __device__ __forceinline__ void merge(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid, + unsigned int delta, + const thrust::tuple& op) + { + For<0, thrust::tuple_size >::value>::merge(smem, val, tid, delta, op); + } + template + __device__ __forceinline__ void mergeShfl(const thrust::tuple& val, + unsigned int delta, + unsigned int width, + const thrust::tuple& op) + { + For<0, thrust::tuple_size >::value>::mergeShfl(val, delta, width, op); + } + + template struct Generic + { + template + static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op) + { + loadToSmem(smem, val, tid); + if (N >= 32) + __syncthreads(); + + if (N >= 2048) + { + if (tid < 1024) + merge(smem, val, tid, 1024, op); + + __syncthreads(); + } + if (N >= 1024) + { + if (tid < 512) + merge(smem, val, tid, 512, op); + + __syncthreads(); + } + if (N >= 512) + { + if (tid < 256) + merge(smem, val, tid, 256, op); + + __syncthreads(); + } + if (N >= 256) + { + if (tid < 128) + merge(smem, val, tid, 128, op); + + __syncthreads(); + } + if (N >= 128) + { + if (tid < 64) + merge(smem, val, tid, 64, op); + + __syncthreads(); + } + if (N >= 64) + { + if (tid < 32) + merge(smem, val, tid, 32, op); + } + + if (tid < 16) + { + merge(smem, val, tid, 16, op); + merge(smem, val, tid, 8, op); + merge(smem, val, tid, 4, op); + merge(smem, val, tid, 2, op); + merge(smem, val, tid, 1, op); + } + } + }; + + template + struct Unroll + { + static __device__ void loopShfl(Reference val, Op op, unsigned int N) + { + mergeShfl(val, I, N, op); + Unroll::loopShfl(val, op, N); + } + static __device__ void loop(Pointer smem, Reference val, unsigned int tid, Op op) + { + merge(smem, val, tid, I, op); + Unroll::loop(smem, val, tid, op); + } + }; + template + struct Unroll<0, Pointer, Reference, Op> + { + static __device__ void loopShfl(Reference, Op, unsigned int) + { + } + static __device__ void loop(Pointer, Reference, unsigned int, Op) + { + } + }; + + template struct WarpOptimized + { + template + static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + CV_UNUSED(smem); + CV_UNUSED(tid); + + Unroll::loopShfl(val, op, N); + #else + loadToSmem(smem, val, tid); + + if (tid < N / 2) + Unroll::loop(smem, val, tid, op); + #endif + } + }; + + template struct GenericOptimized32 + { + enum { M = N / 32 }; + + template + static __device__ void reduce(Pointer smem, Reference val, unsigned int tid, Op op) + { + const unsigned int laneId = Warp::laneId(); + + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + Unroll<16, Pointer, Reference, Op>::loopShfl(val, op, warpSize); + + if (laneId == 0) + loadToSmem(smem, val, tid / 32); + #else + loadToSmem(smem, val, tid); + + if (laneId < 16) + Unroll<16, Pointer, Reference, Op>::loop(smem, val, tid, op); + + __syncthreads(); + + if (laneId == 0) + loadToSmem(smem, val, tid / 32); + #endif + + __syncthreads(); + + loadFromSmem(smem, val, tid); + + if (tid < 32) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + Unroll::loopShfl(val, op, M); + #else + Unroll::loop(smem, val, tid, op); + #endif + } + } + }; + + template struct StaticIf; + template struct StaticIf + { + typedef T1 type; + }; + template struct StaticIf + { + typedef T2 type; + }; + + template struct IsPowerOf2 + { + enum { value = ((N != 0) && !(N & (N - 1))) }; + }; + + template struct Dispatcher + { + typedef typename StaticIf< + (N <= 32) && IsPowerOf2::value, + WarpOptimized, + typename StaticIf< + (N <= 1024) && IsPowerOf2::value, + GenericOptimized32, + Generic + >::type + >::type reductor; + }; + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_REDUCE_DETAIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce_key_val.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce_key_val.hpp new file mode 100644 index 0000000..df37c17 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/reduce_key_val.hpp @@ -0,0 +1,502 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP +#define OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP + +#include +#include "../warp.hpp" +#include "../warp_shuffle.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace reduce_key_val_detail + { + template struct GetType; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + template struct GetType + { + typedef T type; + }; + + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple& smem, const ReferenceTuple& data, unsigned int tid) + { + thrust::get(smem)[tid] = thrust::get(data); + + For::loadToSmem(smem, data, tid); + } + template + static __device__ void loadFromSmem(const PointerTuple& smem, const ReferenceTuple& data, unsigned int tid) + { + thrust::get(data) = thrust::get(smem)[tid]; + + For::loadFromSmem(smem, data, tid); + } + + template + static __device__ void copyShfl(const ReferenceTuple& val, unsigned int delta, int width) + { + thrust::get(val) = shfl_down(thrust::get(val), delta, width); + + For::copyShfl(val, delta, width); + } + template + static __device__ void copy(const PointerTuple& svals, const ReferenceTuple& val, unsigned int tid, unsigned int delta) + { + thrust::get(svals)[tid] = thrust::get(val) = thrust::get(svals)[tid + delta]; + + For::copy(svals, val, tid, delta); + } + + template + static __device__ void mergeShfl(const KeyReferenceTuple& key, const ValReferenceTuple& val, const CmpTuple& cmp, unsigned int delta, int width) + { + typename GetType::type>::type reg = shfl_down(thrust::get(key), delta, width); + + if (thrust::get(cmp)(reg, thrust::get(key))) + { + thrust::get(key) = reg; + thrust::get(val) = shfl_down(thrust::get(val), delta, width); + } + + For::mergeShfl(key, val, cmp, delta, width); + } + template + static __device__ void merge(const KeyPointerTuple& skeys, const KeyReferenceTuple& key, + const ValPointerTuple& svals, const ValReferenceTuple& val, + const CmpTuple& cmp, + unsigned int tid, unsigned int delta) + { + typename GetType::type>::type reg = thrust::get(skeys)[tid + delta]; + + if (thrust::get(cmp)(reg, thrust::get(key))) + { + thrust::get(skeys)[tid] = thrust::get(key) = reg; + thrust::get(svals)[tid] = thrust::get(val) = thrust::get(svals)[tid + delta]; + } + + For::merge(skeys, key, svals, val, cmp, tid, delta); + } + }; + template + struct For + { + template + static __device__ void loadToSmem(const PointerTuple&, const ReferenceTuple&, unsigned int) + { + } + template + static __device__ void loadFromSmem(const PointerTuple&, const ReferenceTuple&, unsigned int) + { + } + + template + static __device__ void copyShfl(const ReferenceTuple&, unsigned int, int) + { + } + template + static __device__ void copy(const PointerTuple&, const ReferenceTuple&, unsigned int, unsigned int) + { + } + + template + static __device__ void mergeShfl(const KeyReferenceTuple&, const ValReferenceTuple&, const CmpTuple&, unsigned int, int) + { + } + template + static __device__ void merge(const KeyPointerTuple&, const KeyReferenceTuple&, + const ValPointerTuple&, const ValReferenceTuple&, + const CmpTuple&, + unsigned int, unsigned int) + { + } + }; + + ////////////////////////////////////////////////////// + // loadToSmem + + template + __device__ __forceinline__ void loadToSmem(volatile T* smem, T& data, unsigned int tid) + { + smem[tid] = data; + } + template + __device__ __forceinline__ void loadFromSmem(volatile T* smem, T& data, unsigned int tid) + { + data = smem[tid]; + } + template + __device__ __forceinline__ void loadToSmem(const thrust::tuple& smem, + const thrust::tuple& data, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadToSmem(smem, data, tid); + } + template + __device__ __forceinline__ void loadFromSmem(const thrust::tuple& smem, + const thrust::tuple& data, + unsigned int tid) + { + For<0, thrust::tuple_size >::value>::loadFromSmem(smem, data, tid); + } + + ////////////////////////////////////////////////////// + // copyVals + + template + __device__ __forceinline__ void copyValsShfl(V& val, unsigned int delta, int width) + { + val = shfl_down(val, delta, width); + } + template + __device__ __forceinline__ void copyVals(volatile V* svals, V& val, unsigned int tid, unsigned int delta) + { + svals[tid] = val = svals[tid + delta]; + } + template + __device__ __forceinline__ void copyValsShfl(const thrust::tuple& val, + unsigned int delta, + int width) + { + For<0, thrust::tuple_size >::value>::copyShfl(val, delta, width); + } + template + __device__ __forceinline__ void copyVals(const thrust::tuple& svals, + const thrust::tuple& val, + unsigned int tid, unsigned int delta) + { + For<0, thrust::tuple_size >::value>::copy(svals, val, tid, delta); + } + + ////////////////////////////////////////////////////// + // merge + + template + __device__ __forceinline__ void mergeShfl(K& key, V& val, const Cmp& cmp, unsigned int delta, int width) + { + K reg = shfl_down(key, delta, width); + + if (cmp(reg, key)) + { + key = reg; + copyValsShfl(val, delta, width); + } + } + template + __device__ __forceinline__ void merge(volatile K* skeys, K& key, volatile V* svals, V& val, const Cmp& cmp, unsigned int tid, unsigned int delta) + { + K reg = skeys[tid + delta]; + + if (cmp(reg, key)) + { + skeys[tid] = key = reg; + copyVals(svals, val, tid, delta); + } + } + template + __device__ __forceinline__ void mergeShfl(K& key, + const thrust::tuple& val, + const Cmp& cmp, + unsigned int delta, int width) + { + K reg = shfl_down(key, delta, width); + + if (cmp(reg, key)) + { + key = reg; + copyValsShfl(val, delta, width); + } + } + template + __device__ __forceinline__ void merge(volatile K* skeys, K& key, + const thrust::tuple& svals, + const thrust::tuple& val, + const Cmp& cmp, unsigned int tid, unsigned int delta) + { + K reg = skeys[tid + delta]; + + if (cmp(reg, key)) + { + skeys[tid] = key = reg; + copyVals(svals, val, tid, delta); + } + } + template + __device__ __forceinline__ void mergeShfl(const thrust::tuple& key, + const thrust::tuple& val, + const thrust::tuple& cmp, + unsigned int delta, int width) + { + For<0, thrust::tuple_size >::value>::mergeShfl(key, val, cmp, delta, width); + } + template + __device__ __forceinline__ void merge(const thrust::tuple& skeys, + const thrust::tuple& key, + const thrust::tuple& svals, + const thrust::tuple& val, + const thrust::tuple& cmp, + unsigned int tid, unsigned int delta) + { + For<0, thrust::tuple_size >::value>::merge(skeys, key, svals, val, cmp, tid, delta); + } + + ////////////////////////////////////////////////////// + // Generic + + template struct Generic + { + template + static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + loadToSmem(skeys, key, tid); + loadValsToSmem(svals, val, tid); + if (N >= 32) + __syncthreads(); + + if (N >= 2048) + { + if (tid < 1024) + merge(skeys, key, svals, val, cmp, tid, 1024); + + __syncthreads(); + } + if (N >= 1024) + { + if (tid < 512) + merge(skeys, key, svals, val, cmp, tid, 512); + + __syncthreads(); + } + if (N >= 512) + { + if (tid < 256) + merge(skeys, key, svals, val, cmp, tid, 256); + + __syncthreads(); + } + if (N >= 256) + { + if (tid < 128) + merge(skeys, key, svals, val, cmp, tid, 128); + + __syncthreads(); + } + if (N >= 128) + { + if (tid < 64) + merge(skeys, key, svals, val, cmp, tid, 64); + + __syncthreads(); + } + if (N >= 64) + { + if (tid < 32) + merge(skeys, key, svals, val, cmp, tid, 32); + } + + if (tid < 16) + { + merge(skeys, key, svals, val, cmp, tid, 16); + merge(skeys, key, svals, val, cmp, tid, 8); + merge(skeys, key, svals, val, cmp, tid, 4); + merge(skeys, key, svals, val, cmp, tid, 2); + merge(skeys, key, svals, val, cmp, tid, 1); + } + } + }; + + template + struct Unroll + { + static __device__ void loopShfl(KR key, VR val, Cmp cmp, unsigned int N) + { + mergeShfl(key, val, cmp, I, N); + Unroll::loopShfl(key, val, cmp, N); + } + static __device__ void loop(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + merge(skeys, key, svals, val, cmp, tid, I); + Unroll::loop(skeys, key, svals, val, tid, cmp); + } + }; + template + struct Unroll<0, KP, KR, VP, VR, Cmp> + { + static __device__ void loopShfl(KR, VR, Cmp, unsigned int) + { + } + static __device__ void loop(KP, KR, VP, VR, unsigned int, Cmp) + { + } + }; + + template struct WarpOptimized + { + template + static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + #if 0 // __CUDA_ARCH__ >= 300 + CV_UNUSED(skeys); + CV_UNUSED(svals); + CV_UNUSED(tid); + + Unroll::loopShfl(key, val, cmp, N); + #else + loadToSmem(skeys, key, tid); + loadToSmem(svals, val, tid); + + if (tid < N / 2) + Unroll::loop(skeys, key, svals, val, tid, cmp); + #endif + } + }; + + template struct GenericOptimized32 + { + enum { M = N / 32 }; + + template + static __device__ void reduce(KP skeys, KR key, VP svals, VR val, unsigned int tid, Cmp cmp) + { + const unsigned int laneId = Warp::laneId(); + + #if 0 // __CUDA_ARCH__ >= 300 + Unroll<16, KP, KR, VP, VR, Cmp>::loopShfl(key, val, cmp, warpSize); + + if (laneId == 0) + { + loadToSmem(skeys, key, tid / 32); + loadToSmem(svals, val, tid / 32); + } + #else + loadToSmem(skeys, key, tid); + loadToSmem(svals, val, tid); + + if (laneId < 16) + Unroll<16, KP, KR, VP, VR, Cmp>::loop(skeys, key, svals, val, tid, cmp); + + __syncthreads(); + + if (laneId == 0) + { + loadToSmem(skeys, key, tid / 32); + loadToSmem(svals, val, tid / 32); + } + #endif + + __syncthreads(); + + loadFromSmem(skeys, key, tid); + + if (tid < 32) + { + #if 0 // __CUDA_ARCH__ >= 300 + loadFromSmem(svals, val, tid); + + Unroll::loopShfl(key, val, cmp, M); + #else + Unroll::loop(skeys, key, svals, val, tid, cmp); + #endif + } + } + }; + + template struct StaticIf; + template struct StaticIf + { + typedef T1 type; + }; + template struct StaticIf + { + typedef T2 type; + }; + + template struct IsPowerOf2 + { + enum { value = ((N != 0) && !(N & (N - 1))) }; + }; + + template struct Dispatcher + { + typedef typename StaticIf< + (N <= 32) && IsPowerOf2::value, + WarpOptimized, + typename StaticIf< + (N <= 1024) && IsPowerOf2::value, + GenericOptimized32, + Generic + >::type + >::type reductor; + }; + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_PRED_VAL_REDUCE_DETAIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/transform_detail.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/transform_detail.hpp new file mode 100644 index 0000000..1919848 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/transform_detail.hpp @@ -0,0 +1,392 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TRANSFORM_DETAIL_HPP +#define OPENCV_CUDA_TRANSFORM_DETAIL_HPP + +#include "../common.hpp" +#include "../vec_traits.hpp" +#include "../functional.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace transform_detail + { + //! Read Write Traits + + template struct UnaryReadWriteTraits + { + typedef typename TypeVec::vec_type read_type; + typedef typename TypeVec::vec_type write_type; + }; + + template struct BinaryReadWriteTraits + { + typedef typename TypeVec::vec_type read_type1; + typedef typename TypeVec::vec_type read_type2; + typedef typename TypeVec::vec_type write_type; + }; + + //! Transform kernels + + template struct OpUnroller; + template <> struct OpUnroller<1> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + } + }; + template <> struct OpUnroller<2> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src.y); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src1.y, src2.y); + } + }; + template <> struct OpUnroller<3> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src.z); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src1.y, src2.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src1.z, src2.z); + } + }; + template <> struct OpUnroller<4> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src.z); + if (mask(y, x_shifted + 3)) + dst.w = op(src.w); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.x = op(src1.x, src2.x); + if (mask(y, x_shifted + 1)) + dst.y = op(src1.y, src2.y); + if (mask(y, x_shifted + 2)) + dst.z = op(src1.z, src2.z); + if (mask(y, x_shifted + 3)) + dst.w = op(src1.w, src2.w); + } + }; + template <> struct OpUnroller<8> + { + template + static __device__ __forceinline__ void unroll(const T& src, D& dst, const Mask& mask, const UnOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.a0 = op(src.a0); + if (mask(y, x_shifted + 1)) + dst.a1 = op(src.a1); + if (mask(y, x_shifted + 2)) + dst.a2 = op(src.a2); + if (mask(y, x_shifted + 3)) + dst.a3 = op(src.a3); + if (mask(y, x_shifted + 4)) + dst.a4 = op(src.a4); + if (mask(y, x_shifted + 5)) + dst.a5 = op(src.a5); + if (mask(y, x_shifted + 6)) + dst.a6 = op(src.a6); + if (mask(y, x_shifted + 7)) + dst.a7 = op(src.a7); + } + + template + static __device__ __forceinline__ void unroll(const T1& src1, const T2& src2, D& dst, const Mask& mask, const BinOp& op, int x_shifted, int y) + { + if (mask(y, x_shifted)) + dst.a0 = op(src1.a0, src2.a0); + if (mask(y, x_shifted + 1)) + dst.a1 = op(src1.a1, src2.a1); + if (mask(y, x_shifted + 2)) + dst.a2 = op(src1.a2, src2.a2); + if (mask(y, x_shifted + 3)) + dst.a3 = op(src1.a3, src2.a3); + if (mask(y, x_shifted + 4)) + dst.a4 = op(src1.a4, src2.a4); + if (mask(y, x_shifted + 5)) + dst.a5 = op(src1.a5, src2.a5); + if (mask(y, x_shifted + 6)) + dst.a6 = op(src1.a6, src2.a6); + if (mask(y, x_shifted + 7)) + dst.a7 = op(src1.a7, src2.a7); + } + }; + + template + static __global__ void transformSmart(const PtrStepSz src_, PtrStep dst_, const Mask mask, const UnOp op) + { + typedef TransformFunctorTraits ft; + typedef typename UnaryReadWriteTraits::read_type read_type; + typedef typename UnaryReadWriteTraits::write_type write_type; + + const int x = threadIdx.x + blockIdx.x * blockDim.x; + const int y = threadIdx.y + blockIdx.y * blockDim.y; + const int x_shifted = x * ft::smart_shift; + + if (y < src_.rows) + { + const T* src = src_.ptr(y); + D* dst = dst_.ptr(y); + + if (x_shifted + ft::smart_shift - 1 < src_.cols) + { + const read_type src_n_el = ((const read_type*)src)[x]; + OpUnroller::unroll(src_n_el, ((write_type*)dst)[x], mask, op, x_shifted, y); + } + else + { + for (int real_x = x_shifted; real_x < src_.cols; ++real_x) + { + if (mask(y, real_x)) + dst[real_x] = op(src[real_x]); + } + } + } + } + + template + __global__ static void transformSimple(const PtrStepSz src, PtrStep dst, const Mask mask, const UnOp op) + { + const int x = blockDim.x * blockIdx.x + threadIdx.x; + const int y = blockDim.y * blockIdx.y + threadIdx.y; + + if (x < src.cols && y < src.rows && mask(y, x)) + { + dst.ptr(y)[x] = op(src.ptr(y)[x]); + } + } + + template + static __global__ void transformSmart(const PtrStepSz src1_, const PtrStep src2_, PtrStep dst_, + const Mask mask, const BinOp op) + { + typedef TransformFunctorTraits ft; + typedef typename BinaryReadWriteTraits::read_type1 read_type1; + typedef typename BinaryReadWriteTraits::read_type2 read_type2; + typedef typename BinaryReadWriteTraits::write_type write_type; + + const int x = threadIdx.x + blockIdx.x * blockDim.x; + const int y = threadIdx.y + blockIdx.y * blockDim.y; + const int x_shifted = x * ft::smart_shift; + + if (y < src1_.rows) + { + const T1* src1 = src1_.ptr(y); + const T2* src2 = src2_.ptr(y); + D* dst = dst_.ptr(y); + + if (x_shifted + ft::smart_shift - 1 < src1_.cols) + { + const read_type1 src1_n_el = ((const read_type1*)src1)[x]; + const read_type2 src2_n_el = ((const read_type2*)src2)[x]; + + OpUnroller::unroll(src1_n_el, src2_n_el, ((write_type*)dst)[x], mask, op, x_shifted, y); + } + else + { + for (int real_x = x_shifted; real_x < src1_.cols; ++real_x) + { + if (mask(y, real_x)) + dst[real_x] = op(src1[real_x], src2[real_x]); + } + } + } + } + + template + static __global__ void transformSimple(const PtrStepSz src1, const PtrStep src2, PtrStep dst, + const Mask mask, const BinOp op) + { + const int x = blockDim.x * blockIdx.x + threadIdx.x; + const int y = blockDim.y * blockIdx.y + threadIdx.y; + + if (x < src1.cols && y < src1.rows && mask(y, x)) + { + const T1 src1_data = src1.ptr(y)[x]; + const T2 src2_data = src2.ptr(y)[x]; + dst.ptr(y)[x] = op(src1_data, src2_data); + } + } + + template struct TransformDispatcher; + template<> struct TransformDispatcher + { + template + static void call(PtrStepSz src, PtrStepSz dst, UnOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + const dim3 threads(ft::simple_block_dim_x, ft::simple_block_dim_y, 1); + const dim3 grid(divUp(src.cols, threads.x), divUp(src.rows, threads.y), 1); + + transformSimple<<>>(src, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + + template + static void call(PtrStepSz src1, PtrStepSz src2, PtrStepSz dst, BinOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + const dim3 threads(ft::simple_block_dim_x, ft::simple_block_dim_y, 1); + const dim3 grid(divUp(src1.cols, threads.x), divUp(src1.rows, threads.y), 1); + + transformSimple<<>>(src1, src2, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + }; + template<> struct TransformDispatcher + { + template + static void call(PtrStepSz src, PtrStepSz dst, UnOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + CV_StaticAssert(ft::smart_shift != 1, ""); + + if (!isAligned(src.data, ft::smart_shift * sizeof(T)) || !isAligned(src.step, ft::smart_shift * sizeof(T)) || + !isAligned(dst.data, ft::smart_shift * sizeof(D)) || !isAligned(dst.step, ft::smart_shift * sizeof(D))) + { + TransformDispatcher::call(src, dst, op, mask, stream); + return; + } + + const dim3 threads(ft::smart_block_dim_x, ft::smart_block_dim_y, 1); + const dim3 grid(divUp(src.cols, threads.x * ft::smart_shift), divUp(src.rows, threads.y), 1); + + transformSmart<<>>(src, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + + template + static void call(PtrStepSz src1, PtrStepSz src2, PtrStepSz dst, BinOp op, Mask mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + + CV_StaticAssert(ft::smart_shift != 1, ""); + + if (!isAligned(src1.data, ft::smart_shift * sizeof(T1)) || !isAligned(src1.step, ft::smart_shift * sizeof(T1)) || + !isAligned(src2.data, ft::smart_shift * sizeof(T2)) || !isAligned(src2.step, ft::smart_shift * sizeof(T2)) || + !isAligned(dst.data, ft::smart_shift * sizeof(D)) || !isAligned(dst.step, ft::smart_shift * sizeof(D))) + { + TransformDispatcher::call(src1, src2, dst, op, mask, stream); + return; + } + + const dim3 threads(ft::smart_block_dim_x, ft::smart_block_dim_y, 1); + const dim3 grid(divUp(src1.cols, threads.x * ft::smart_shift), divUp(src1.rows, threads.y), 1); + + transformSmart<<>>(src1, src2, dst, mask, op); + cudaSafeCall( cudaGetLastError() ); + + if (stream == 0) + cudaSafeCall( cudaDeviceSynchronize() ); + } + }; + } // namespace transform_detail +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_TRANSFORM_DETAIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/type_traits_detail.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/type_traits_detail.hpp new file mode 100644 index 0000000..a78bd2c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/type_traits_detail.hpp @@ -0,0 +1,191 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP +#define OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP + +#include "../common.hpp" +#include "../vec_traits.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace type_traits_detail + { + template struct Select { typedef T1 type; }; + template struct Select { typedef T2 type; }; + + template struct IsSignedIntergral { enum {value = 0}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + template <> struct IsSignedIntergral { enum {value = 1}; }; + + template struct IsUnsignedIntegral { enum {value = 0}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + template <> struct IsUnsignedIntegral { enum {value = 1}; }; + + template struct IsIntegral { enum {value = IsSignedIntergral::value || IsUnsignedIntegral::value}; }; + template <> struct IsIntegral { enum {value = 1}; }; + template <> struct IsIntegral { enum {value = 1}; }; + + template struct IsFloat { enum {value = 0}; }; + template <> struct IsFloat { enum {value = 1}; }; + template <> struct IsFloat { enum {value = 1}; }; + + template struct IsVec { enum {value = 0}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + template <> struct IsVec { enum {value = 1}; }; + + template struct AddParameterType { typedef const U& type; }; + template struct AddParameterType { typedef U& type; }; + template <> struct AddParameterType { typedef void type; }; + + template struct ReferenceTraits + { + enum { value = false }; + typedef U type; + }; + template struct ReferenceTraits + { + enum { value = true }; + typedef U type; + }; + + template struct PointerTraits + { + enum { value = false }; + typedef void type; + }; + template struct PointerTraits + { + enum { value = true }; + typedef U type; + }; + template struct PointerTraits + { + enum { value = true }; + typedef U type; + }; + + template struct UnConst + { + typedef U type; + enum { value = 0 }; + }; + template struct UnConst + { + typedef U type; + enum { value = 1 }; + }; + template struct UnConst + { + typedef U& type; + enum { value = 1 }; + }; + + template struct UnVolatile + { + typedef U type; + enum { value = 0 }; + }; + template struct UnVolatile + { + typedef U type; + enum { value = 1 }; + }; + template struct UnVolatile + { + typedef U& type; + enum { value = 1 }; + }; + } // namespace type_traits_detail +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_TYPE_TRAITS_DETAIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/vec_distance_detail.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/vec_distance_detail.hpp new file mode 100644 index 0000000..8283a99 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/detail/vec_distance_detail.hpp @@ -0,0 +1,121 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP +#define OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP + +#include "../datamov_utils.hpp" + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + namespace vec_distance_detail + { + template struct UnrollVecDiffCached + { + template + static __device__ void calcCheck(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int ind) + { + if (ind < len) + { + T1 val1 = *vecCached++; + + T2 val2; + ForceGlob::Load(vecGlob, ind, val2); + + dist.reduceIter(val1, val2); + + UnrollVecDiffCached::calcCheck(vecCached, vecGlob, len, dist, ind + THREAD_DIM); + } + } + + template + static __device__ void calcWithoutCheck(const T1* vecCached, const T2* vecGlob, Dist& dist) + { + T1 val1 = *vecCached++; + + T2 val2; + ForceGlob::Load(vecGlob, 0, val2); + vecGlob += THREAD_DIM; + + dist.reduceIter(val1, val2); + + UnrollVecDiffCached::calcWithoutCheck(vecCached, vecGlob, dist); + } + }; + template struct UnrollVecDiffCached + { + template + static __device__ __forceinline__ void calcCheck(const T1*, const T2*, int, Dist&, int) + { + } + + template + static __device__ __forceinline__ void calcWithoutCheck(const T1*, const T2*, Dist&) + { + } + }; + + template struct VecDiffCachedCalculator; + template struct VecDiffCachedCalculator + { + template + static __device__ __forceinline__ void calc(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int tid) + { + UnrollVecDiffCached::calcCheck(vecCached, vecGlob, len, dist, tid); + } + }; + template struct VecDiffCachedCalculator + { + template + static __device__ __forceinline__ void calc(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, int tid) + { + UnrollVecDiffCached::calcWithoutCheck(vecCached, vecGlob + tid, dist); + } + }; + } // namespace vec_distance_detail +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_VEC_DISTANCE_DETAIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/dynamic_smem.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/dynamic_smem.hpp new file mode 100644 index 0000000..42570c6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/dynamic_smem.hpp @@ -0,0 +1,88 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DYNAMIC_SMEM_HPP +#define OPENCV_CUDA_DYNAMIC_SMEM_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct DynamicSharedMem + { + __device__ __forceinline__ operator T*() + { + extern __shared__ int __smem[]; + return (T*)__smem; + } + + __device__ __forceinline__ operator const T*() const + { + extern __shared__ int __smem[]; + return (T*)__smem; + } + }; + + // specialize for double to avoid unaligned memory access compile errors + template<> struct DynamicSharedMem + { + __device__ __forceinline__ operator double*() + { + extern __shared__ double __smem_d[]; + return (double*)__smem_d; + } + + __device__ __forceinline__ operator const double*() const + { + extern __shared__ double __smem_d[]; + return (double*)__smem_d; + } + }; +}}} + +//! @endcond + +#endif // OPENCV_CUDA_DYNAMIC_SMEM_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/emulation.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/emulation.hpp new file mode 100644 index 0000000..17dc117 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/emulation.hpp @@ -0,0 +1,269 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_EMULATION_HPP_ +#define OPENCV_CUDA_EMULATION_HPP_ + +#include "common.hpp" +#include "warp_reduce.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct Emulation + { + + static __device__ __forceinline__ int syncthreadsOr(int pred) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 200) + // just campilation stab + return 0; +#else + return __syncthreads_or(pred); +#endif + } + + template + static __forceinline__ __device__ int Ballot(int predicate) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200) + return __ballot(predicate); +#else + __shared__ volatile int cta_buffer[CTA_SIZE]; + + int tid = threadIdx.x; + cta_buffer[tid] = predicate ? (1 << (tid & 31)) : 0; + return warp_reduce(cta_buffer); +#endif + } + + struct smem + { + enum { TAG_MASK = (1U << ( (sizeof(unsigned int) << 3) - 5U)) - 1U }; + + template + static __device__ __forceinline__ T atomicInc(T* address, T val) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120) + T count; + unsigned int tag = threadIdx.x << ( (sizeof(unsigned int) << 3) - 5U); + do + { + count = *address & TAG_MASK; + count = tag | (count + 1); + *address = count; + } while (*address != count); + + return (count & TAG_MASK) - 1; +#else + return ::atomicInc(address, val); +#endif + } + + template + static __device__ __forceinline__ T atomicAdd(T* address, T val) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120) + T count; + unsigned int tag = threadIdx.x << ( (sizeof(unsigned int) << 3) - 5U); + do + { + count = *address & TAG_MASK; + count = tag | (count + val); + *address = count; + } while (*address != count); + + return (count & TAG_MASK) - val; +#else + return ::atomicAdd(address, val); +#endif + } + + template + static __device__ __forceinline__ T atomicMin(T* address, T val) + { +#if defined (__CUDA_ARCH__) && (__CUDA_ARCH__ < 120) + T count = ::min(*address, val); + do + { + *address = count; + } while (*address > count); + + return count; +#else + return ::atomicMin(address, val); +#endif + } + }; // struct cmem + + struct glob + { + static __device__ __forceinline__ int atomicAdd(int* address, int val) + { + return ::atomicAdd(address, val); + } + static __device__ __forceinline__ unsigned int atomicAdd(unsigned int* address, unsigned int val) + { + return ::atomicAdd(address, val); + } + static __device__ __forceinline__ float atomicAdd(float* address, float val) + { + #if __CUDA_ARCH__ >= 200 + return ::atomicAdd(address, val); + #else + int* address_as_i = (int*) address; + int old = *address_as_i, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_i, assumed, + __float_as_int(val + __int_as_float(assumed))); + } while (assumed != old); + return __int_as_float(old); + #endif + } + static __device__ __forceinline__ double atomicAdd(double* address, double val) + { + #if __CUDA_ARCH__ >= 130 + unsigned long long int* address_as_ull = (unsigned long long int*) address; + unsigned long long int old = *address_as_ull, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_ull, assumed, + __double_as_longlong(val + __longlong_as_double(assumed))); + } while (assumed != old); + return __longlong_as_double(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0; + #endif + } + + static __device__ __forceinline__ int atomicMin(int* address, int val) + { + return ::atomicMin(address, val); + } + static __device__ __forceinline__ float atomicMin(float* address, float val) + { + #if __CUDA_ARCH__ >= 120 + int* address_as_i = (int*) address; + int old = *address_as_i, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_i, assumed, + __float_as_int(::fminf(val, __int_as_float(assumed)))); + } while (assumed != old); + return __int_as_float(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0f; + #endif + } + static __device__ __forceinline__ double atomicMin(double* address, double val) + { + #if __CUDA_ARCH__ >= 130 + unsigned long long int* address_as_ull = (unsigned long long int*) address; + unsigned long long int old = *address_as_ull, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_ull, assumed, + __double_as_longlong(::fmin(val, __longlong_as_double(assumed)))); + } while (assumed != old); + return __longlong_as_double(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0; + #endif + } + + static __device__ __forceinline__ int atomicMax(int* address, int val) + { + return ::atomicMax(address, val); + } + static __device__ __forceinline__ float atomicMax(float* address, float val) + { + #if __CUDA_ARCH__ >= 120 + int* address_as_i = (int*) address; + int old = *address_as_i, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_i, assumed, + __float_as_int(::fmaxf(val, __int_as_float(assumed)))); + } while (assumed != old); + return __int_as_float(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0f; + #endif + } + static __device__ __forceinline__ double atomicMax(double* address, double val) + { + #if __CUDA_ARCH__ >= 130 + unsigned long long int* address_as_ull = (unsigned long long int*) address; + unsigned long long int old = *address_as_ull, assumed; + do { + assumed = old; + old = ::atomicCAS(address_as_ull, assumed, + __double_as_longlong(::fmax(val, __longlong_as_double(assumed)))); + } while (assumed != old); + return __longlong_as_double(old); + #else + CV_UNUSED(address); + CV_UNUSED(val); + return 0.0; + #endif + } + }; + }; //struct Emulation +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif /* OPENCV_CUDA_EMULATION_HPP_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/filters.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/filters.hpp new file mode 100644 index 0000000..bf3147e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/filters.hpp @@ -0,0 +1,293 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_FILTERS_HPP +#define OPENCV_CUDA_FILTERS_HPP + +#include "saturate_cast.hpp" +#include "vec_traits.hpp" +#include "vec_math.hpp" +#include "type_traits.hpp" +#include "nppdefs.h" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct PointFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ PointFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f) + : src(src_) + { + CV_UNUSED(fx); + CV_UNUSED(fy); + } + + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + return src(__float2int_rz(y), __float2int_rz(x)); + } + + Ptr2D src; + }; + + template struct LinearFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ LinearFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f) + : src(src_) + { + CV_UNUSED(fx); + CV_UNUSED(fy); + } + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + typedef typename TypeVec::cn>::vec_type work_type; + + work_type out = VecTraits::all(0); + + const int x1 = __float2int_rd(x); + const int y1 = __float2int_rd(y); + if (x1 <= NPP_MIN_32S || x1 >= NPP_MAX_32S || y1 <= NPP_MIN_32S || y1 >= NPP_MAX_32S) + { + elem_type src_reg = src(y1, x1); + out = out + src_reg * 1.0f; + return saturate_cast(out); + } + const int x2 = x1 + 1; + const int y2 = y1 + 1; + + elem_type src_reg = src(y1, x1); + out = out + src_reg * ((x2 - x) * (y2 - y)); + + src_reg = src(y1, x2); + out = out + src_reg * ((x - x1) * (y2 - y)); + + src_reg = src(y2, x1); + out = out + src_reg * ((x2 - x) * (y - y1)); + + src_reg = src(y2, x2); + out = out + src_reg * ((x - x1) * (y - y1)); + + return saturate_cast(out); + } + + Ptr2D src; + }; + + template struct CubicFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + typedef typename TypeVec::cn>::vec_type work_type; + + explicit __host__ __device__ __forceinline__ CubicFilter(const Ptr2D& src_, float fx = 0.f, float fy = 0.f) + : src(src_) + { + CV_UNUSED(fx); + CV_UNUSED(fy); + } + + static __device__ __forceinline__ float bicubicCoeff(float x_) + { + float x = fabsf(x_); + if (x <= 1.0f) + { + return x * x * (1.5f * x - 2.5f) + 1.0f; + } + else if (x < 2.0f) + { + return x * (x * (-0.5f * x + 2.5f) - 4.0f) + 2.0f; + } + else + { + return 0.0f; + } + } + + __device__ elem_type operator ()(float y, float x) const + { + const float xmin = ::ceilf(x - 2.0f); + const float xmax = ::floorf(x + 2.0f); + + const float ymin = ::ceilf(y - 2.0f); + const float ymax = ::floorf(y + 2.0f); + + work_type sum = VecTraits::all(0); + float wsum = 0.0f; + + for (float cy = ymin; cy <= ymax; cy += 1.0f) + { + for (float cx = xmin; cx <= xmax; cx += 1.0f) + { + const float w = bicubicCoeff(x - cx) * bicubicCoeff(y - cy); + sum = sum + w * src(__float2int_rd(cy), __float2int_rd(cx)); + wsum += w; + } + } + + work_type res = (!wsum)? VecTraits::all(0) : sum / wsum; + + return saturate_cast(res); + } + + Ptr2D src; + }; + // for integer scaling + template struct IntegerAreaFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ IntegerAreaFilter(const Ptr2D& src_, float scale_x_, float scale_y_) + : src(src_), scale_x(scale_x_), scale_y(scale_y_), scale(1.f / (scale_x * scale_y)) {} + + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + float fsx1 = x * scale_x; + float fsx2 = fsx1 + scale_x; + + int sx1 = __float2int_ru(fsx1); + int sx2 = __float2int_rd(fsx2); + + float fsy1 = y * scale_y; + float fsy2 = fsy1 + scale_y; + + int sy1 = __float2int_ru(fsy1); + int sy2 = __float2int_rd(fsy2); + + typedef typename TypeVec::cn>::vec_type work_type; + work_type out = VecTraits::all(0.f); + + for(int dy = sy1; dy < sy2; ++dy) + for(int dx = sx1; dx < sx2; ++dx) + { + out = out + src(dy, dx) * scale; + } + + return saturate_cast(out); + } + + Ptr2D src; + float scale_x, scale_y ,scale; + }; + + template struct AreaFilter + { + typedef typename Ptr2D::elem_type elem_type; + typedef float index_type; + + explicit __host__ __device__ __forceinline__ AreaFilter(const Ptr2D& src_, float scale_x_, float scale_y_) + : src(src_), scale_x(scale_x_), scale_y(scale_y_){} + + __device__ __forceinline__ elem_type operator ()(float y, float x) const + { + float fsx1 = x * scale_x; + float fsx2 = fsx1 + scale_x; + + int sx1 = __float2int_ru(fsx1); + int sx2 = __float2int_rd(fsx2); + + float fsy1 = y * scale_y; + float fsy2 = fsy1 + scale_y; + + int sy1 = __float2int_ru(fsy1); + int sy2 = __float2int_rd(fsy2); + + float scale = 1.f / (fminf(scale_x, src.width - fsx1) * fminf(scale_y, src.height - fsy1)); + + typedef typename TypeVec::cn>::vec_type work_type; + work_type out = VecTraits::all(0.f); + + for (int dy = sy1; dy < sy2; ++dy) + { + for (int dx = sx1; dx < sx2; ++dx) + out = out + src(dy, dx) * scale; + + if (sx1 > fsx1) + out = out + src(dy, (sx1 -1) ) * ((sx1 - fsx1) * scale); + + if (sx2 < fsx2) + out = out + src(dy, sx2) * ((fsx2 -sx2) * scale); + } + + if (sy1 > fsy1) + for (int dx = sx1; dx < sx2; ++dx) + out = out + src( (sy1 - 1) , dx) * ((sy1 -fsy1) * scale); + + if (sy2 < fsy2) + for (int dx = sx1; dx < sx2; ++dx) + out = out + src(sy2, dx) * ((fsy2 -sy2) * scale); + + if ((sy1 > fsy1) && (sx1 > fsx1)) + out = out + src( (sy1 - 1) , (sx1 - 1)) * ((sy1 -fsy1) * (sx1 -fsx1) * scale); + + if ((sy1 > fsy1) && (sx2 < fsx2)) + out = out + src( (sy1 - 1) , sx2) * ((sy1 -fsy1) * (fsx2 -sx2) * scale); + + if ((sy2 < fsy2) && (sx2 < fsx2)) + out = out + src(sy2, sx2) * ((fsy2 -sy2) * (fsx2 -sx2) * scale); + + if ((sy2 < fsy2) && (sx1 > fsx1)) + out = out + src(sy2, (sx1 - 1)) * ((fsy2 -sy2) * (sx1 -fsx1) * scale); + + return saturate_cast(out); + } + + Ptr2D src; + float scale_x, scale_y; + int width, haight; + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_FILTERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/funcattrib.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/funcattrib.hpp new file mode 100644 index 0000000..f582080 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/funcattrib.hpp @@ -0,0 +1,79 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP +#define OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP + +#include + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + void printFuncAttrib(Func& func) + { + + cudaFuncAttributes attrs; + cudaFuncGetAttributes(&attrs, func); + + printf("=== Function stats ===\n"); + printf("Name: \n"); + printf("sharedSizeBytes = %d\n", attrs.sharedSizeBytes); + printf("constSizeBytes = %d\n", attrs.constSizeBytes); + printf("localSizeBytes = %d\n", attrs.localSizeBytes); + printf("maxThreadsPerBlock = %d\n", attrs.maxThreadsPerBlock); + printf("numRegs = %d\n", attrs.numRegs); + printf("ptxVersion = %d\n", attrs.ptxVersion); + printf("binaryVersion = %d\n", attrs.binaryVersion); + printf("\n"); + fflush(stdout); + } +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif /* OPENCV_CUDA_DEVICE_FUNCATTRIB_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/functional.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/functional.hpp new file mode 100644 index 0000000..9f53d87 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/functional.hpp @@ -0,0 +1,805 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_FUNCTIONAL_HPP +#define OPENCV_CUDA_FUNCTIONAL_HPP + +#include +#include "saturate_cast.hpp" +#include "vec_traits.hpp" +#include "type_traits.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + // Function Objects + template struct unary_function + { + typedef Argument argument_type; + typedef Result result_type; + }; + template struct binary_function + { + typedef Argument1 first_argument_type; + typedef Argument2 second_argument_type; + typedef Result result_type; + }; + + // Arithmetic Operations + template struct plus : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a + b; + } + __host__ __device__ __forceinline__ plus() {} + __host__ __device__ __forceinline__ plus(const plus&) {} + }; + + template struct minus : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a - b; + } + __host__ __device__ __forceinline__ minus() {} + __host__ __device__ __forceinline__ minus(const minus&) {} + }; + + template struct multiplies : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a * b; + } + __host__ __device__ __forceinline__ multiplies() {} + __host__ __device__ __forceinline__ multiplies(const multiplies&) {} + }; + + template struct divides : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a / b; + } + __host__ __device__ __forceinline__ divides() {} + __host__ __device__ __forceinline__ divides(const divides&) {} + }; + + template struct modulus : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a % b; + } + __host__ __device__ __forceinline__ modulus() {} + __host__ __device__ __forceinline__ modulus(const modulus&) {} + }; + + template struct negate : unary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a) const + { + return -a; + } + __host__ __device__ __forceinline__ negate() {} + __host__ __device__ __forceinline__ negate(const negate&) {} + }; + + // Comparison Operations + template struct equal_to : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a == b; + } + __host__ __device__ __forceinline__ equal_to() {} + __host__ __device__ __forceinline__ equal_to(const equal_to&) {} + }; + + template struct not_equal_to : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a != b; + } + __host__ __device__ __forceinline__ not_equal_to() {} + __host__ __device__ __forceinline__ not_equal_to(const not_equal_to&) {} + }; + + template struct greater : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a > b; + } + __host__ __device__ __forceinline__ greater() {} + __host__ __device__ __forceinline__ greater(const greater&) {} + }; + + template struct less : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a < b; + } + __host__ __device__ __forceinline__ less() {} + __host__ __device__ __forceinline__ less(const less&) {} + }; + + template struct greater_equal : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a >= b; + } + __host__ __device__ __forceinline__ greater_equal() {} + __host__ __device__ __forceinline__ greater_equal(const greater_equal&) {} + }; + + template struct less_equal : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a <= b; + } + __host__ __device__ __forceinline__ less_equal() {} + __host__ __device__ __forceinline__ less_equal(const less_equal&) {} + }; + + // Logical Operations + template struct logical_and : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a && b; + } + __host__ __device__ __forceinline__ logical_and() {} + __host__ __device__ __forceinline__ logical_and(const logical_and&) {} + }; + + template struct logical_or : binary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a || b; + } + __host__ __device__ __forceinline__ logical_or() {} + __host__ __device__ __forceinline__ logical_or(const logical_or&) {} + }; + + template struct logical_not : unary_function + { + __device__ __forceinline__ bool operator ()(typename TypeTraits::ParameterType a) const + { + return !a; + } + __host__ __device__ __forceinline__ logical_not() {} + __host__ __device__ __forceinline__ logical_not(const logical_not&) {} + }; + + // Bitwise Operations + template struct bit_and : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a & b; + } + __host__ __device__ __forceinline__ bit_and() {} + __host__ __device__ __forceinline__ bit_and(const bit_and&) {} + }; + + template struct bit_or : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a | b; + } + __host__ __device__ __forceinline__ bit_or() {} + __host__ __device__ __forceinline__ bit_or(const bit_or&) {} + }; + + template struct bit_xor : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType a, + typename TypeTraits::ParameterType b) const + { + return a ^ b; + } + __host__ __device__ __forceinline__ bit_xor() {} + __host__ __device__ __forceinline__ bit_xor(const bit_xor&) {} + }; + + template struct bit_not : unary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType v) const + { + return ~v; + } + __host__ __device__ __forceinline__ bit_not() {} + __host__ __device__ __forceinline__ bit_not(const bit_not&) {} + }; + + // Generalized Identity Operations + template struct identity : unary_function + { + __device__ __forceinline__ typename TypeTraits::ParameterType operator()(typename TypeTraits::ParameterType x) const + { + return x; + } + __host__ __device__ __forceinline__ identity() {} + __host__ __device__ __forceinline__ identity(const identity&) {} + }; + + template struct project1st : binary_function + { + __device__ __forceinline__ typename TypeTraits::ParameterType operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return lhs; + } + __host__ __device__ __forceinline__ project1st() {} + __host__ __device__ __forceinline__ project1st(const project1st&) {} + }; + + template struct project2nd : binary_function + { + __device__ __forceinline__ typename TypeTraits::ParameterType operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return rhs; + } + __host__ __device__ __forceinline__ project2nd() {} + __host__ __device__ __forceinline__ project2nd(const project2nd&) {} + }; + + // Min/Max Operations + +#define OPENCV_CUDA_IMPLEMENT_MINMAX(name, type, op) \ + template <> struct name : binary_function \ + { \ + __device__ __forceinline__ type operator()(type lhs, type rhs) const {return op(lhs, rhs);} \ + __host__ __device__ __forceinline__ name() {}\ + __host__ __device__ __forceinline__ name(const name&) {}\ + }; + + template struct maximum : binary_function + { + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return max(lhs, rhs); + } + __host__ __device__ __forceinline__ maximum() {} + __host__ __device__ __forceinline__ maximum(const maximum&) {} + }; + + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, uchar, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, schar, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, char, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, ushort, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, short, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, int, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, uint, ::max) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, float, ::fmax) + OPENCV_CUDA_IMPLEMENT_MINMAX(maximum, double, ::fmax) + + template struct minimum : binary_function + { + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType lhs, typename TypeTraits::ParameterType rhs) const + { + return min(lhs, rhs); + } + __host__ __device__ __forceinline__ minimum() {} + __host__ __device__ __forceinline__ minimum(const minimum&) {} + }; + + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, uchar, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, schar, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, char, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, ushort, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, short, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, int, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, uint, ::min) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, float, ::fmin) + OPENCV_CUDA_IMPLEMENT_MINMAX(minimum, double, ::fmin) + +#undef OPENCV_CUDA_IMPLEMENT_MINMAX + + // Math functions + + template struct abs_func : unary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType x) const + { + return abs(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ unsigned char operator ()(unsigned char x) const + { + return x; + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ signed char operator ()(signed char x) const + { + return ::abs((int)x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ char operator ()(char x) const + { + return ::abs((int)x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ unsigned short operator ()(unsigned short x) const + { + return x; + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ short operator ()(short x) const + { + return ::abs((int)x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ unsigned int operator ()(unsigned int x) const + { + return x; + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ int operator ()(int x) const + { + return ::abs(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ float operator ()(float x) const + { + return ::fabsf(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + template <> struct abs_func : unary_function + { + __device__ __forceinline__ double operator ()(double x) const + { + return ::fabs(x); + } + + __host__ __device__ __forceinline__ abs_func() {} + __host__ __device__ __forceinline__ abs_func(const abs_func&) {} + }; + +#define OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(name, func) \ + template struct name ## _func : unary_function \ + { \ + __device__ __forceinline__ float operator ()(typename TypeTraits::ParameterType v) const \ + { \ + return func ## f(v); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; \ + template <> struct name ## _func : unary_function \ + { \ + __device__ __forceinline__ double operator ()(double v) const \ + { \ + return func(v); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; + +#define OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(name, func) \ + template struct name ## _func : binary_function \ + { \ + __device__ __forceinline__ float operator ()(typename TypeTraits::ParameterType v1, typename TypeTraits::ParameterType v2) const \ + { \ + return func ## f(v1, v2); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; \ + template <> struct name ## _func : binary_function \ + { \ + __device__ __forceinline__ double operator ()(double v1, double v2) const \ + { \ + return func(v1, v2); \ + } \ + __host__ __device__ __forceinline__ name ## _func() {} \ + __host__ __device__ __forceinline__ name ## _func(const name ## _func&) {} \ + }; + + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sqrt, ::sqrt) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp, ::exp) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp2, ::exp2) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(exp10, ::exp10) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log, ::log) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log2, ::log2) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(log10, ::log10) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sin, ::sin) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(cos, ::cos) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(tan, ::tan) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(asin, ::asin) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(acos, ::acos) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(atan, ::atan) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(sinh, ::sinh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(cosh, ::cosh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(tanh, ::tanh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(asinh, ::asinh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(acosh, ::acosh) + OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR(atanh, ::atanh) + + OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(hypot, ::hypot) + OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(atan2, ::atan2) + OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR(pow, ::pow) + + #undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR + #undef OPENCV_CUDA_IMPLEMENT_UN_FUNCTOR_NO_DOUBLE + #undef OPENCV_CUDA_IMPLEMENT_BIN_FUNCTOR + + template struct hypot_sqr_func : binary_function + { + __device__ __forceinline__ T operator ()(typename TypeTraits::ParameterType src1, typename TypeTraits::ParameterType src2) const + { + return src1 * src1 + src2 * src2; + } + __host__ __device__ __forceinline__ hypot_sqr_func() {} + __host__ __device__ __forceinline__ hypot_sqr_func(const hypot_sqr_func&) {} + }; + + // Saturate Cast Functor + template struct saturate_cast_func : unary_function + { + __device__ __forceinline__ D operator ()(typename TypeTraits::ParameterType v) const + { + return saturate_cast(v); + } + __host__ __device__ __forceinline__ saturate_cast_func() {} + __host__ __device__ __forceinline__ saturate_cast_func(const saturate_cast_func&) {} + }; + + // Threshold Functors + template struct thresh_binary_func : unary_function + { + __host__ __device__ __forceinline__ thresh_binary_func(T thresh_, T maxVal_) : thresh(thresh_), maxVal(maxVal_) {} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src > thresh) * maxVal; + } + + __host__ __device__ __forceinline__ thresh_binary_func() {} + __host__ __device__ __forceinline__ thresh_binary_func(const thresh_binary_func& other) + : thresh(other.thresh), maxVal(other.maxVal) {} + + T thresh; + T maxVal; + }; + + template struct thresh_binary_inv_func : unary_function + { + __host__ __device__ __forceinline__ thresh_binary_inv_func(T thresh_, T maxVal_) : thresh(thresh_), maxVal(maxVal_) {} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src <= thresh) * maxVal; + } + + __host__ __device__ __forceinline__ thresh_binary_inv_func() {} + __host__ __device__ __forceinline__ thresh_binary_inv_func(const thresh_binary_inv_func& other) + : thresh(other.thresh), maxVal(other.maxVal) {} + + T thresh; + T maxVal; + }; + + template struct thresh_trunc_func : unary_function + { + explicit __host__ __device__ __forceinline__ thresh_trunc_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return minimum()(src, thresh); + } + + __host__ __device__ __forceinline__ thresh_trunc_func() {} + __host__ __device__ __forceinline__ thresh_trunc_func(const thresh_trunc_func& other) + : thresh(other.thresh) {} + + T thresh; + }; + + template struct thresh_to_zero_func : unary_function + { + explicit __host__ __device__ __forceinline__ thresh_to_zero_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src > thresh) * src; + } + + __host__ __device__ __forceinline__ thresh_to_zero_func() {} + __host__ __device__ __forceinline__ thresh_to_zero_func(const thresh_to_zero_func& other) + : thresh(other.thresh) {} + + T thresh; + }; + + template struct thresh_to_zero_inv_func : unary_function + { + explicit __host__ __device__ __forceinline__ thresh_to_zero_inv_func(T thresh_, T maxVal_ = 0) : thresh(thresh_) {CV_UNUSED(maxVal_);} + + __device__ __forceinline__ T operator()(typename TypeTraits::ParameterType src) const + { + return (src <= thresh) * src; + } + + __host__ __device__ __forceinline__ thresh_to_zero_inv_func() {} + __host__ __device__ __forceinline__ thresh_to_zero_inv_func(const thresh_to_zero_inv_func& other) + : thresh(other.thresh) {} + + T thresh; + }; + + // Function Object Adaptors + template struct unary_negate : unary_function + { + explicit __host__ __device__ __forceinline__ unary_negate(const Predicate& p) : pred(p) {} + + __device__ __forceinline__ bool operator()(typename TypeTraits::ParameterType x) const + { + return !pred(x); + } + + __host__ __device__ __forceinline__ unary_negate() {} + __host__ __device__ __forceinline__ unary_negate(const unary_negate& other) : pred(other.pred) {} + + Predicate pred; + }; + + template __host__ __device__ __forceinline__ unary_negate not1(const Predicate& pred) + { + return unary_negate(pred); + } + + template struct binary_negate : binary_function + { + explicit __host__ __device__ __forceinline__ binary_negate(const Predicate& p) : pred(p) {} + + __device__ __forceinline__ bool operator()(typename TypeTraits::ParameterType x, + typename TypeTraits::ParameterType y) const + { + return !pred(x,y); + } + + __host__ __device__ __forceinline__ binary_negate() {} + __host__ __device__ __forceinline__ binary_negate(const binary_negate& other) : pred(other.pred) {} + + Predicate pred; + }; + + template __host__ __device__ __forceinline__ binary_negate not2(const BinaryPredicate& pred) + { + return binary_negate(pred); + } + + template struct binder1st : unary_function + { + __host__ __device__ __forceinline__ binder1st(const Op& op_, const typename Op::first_argument_type& arg1_) : op(op_), arg1(arg1_) {} + + __device__ __forceinline__ typename Op::result_type operator ()(typename TypeTraits::ParameterType a) const + { + return op(arg1, a); + } + + __host__ __device__ __forceinline__ binder1st() {} + __host__ __device__ __forceinline__ binder1st(const binder1st& other) : op(other.op), arg1(other.arg1) {} + + Op op; + typename Op::first_argument_type arg1; + }; + + template __host__ __device__ __forceinline__ binder1st bind1st(const Op& op, const T& x) + { + return binder1st(op, typename Op::first_argument_type(x)); + } + + template struct binder2nd : unary_function + { + __host__ __device__ __forceinline__ binder2nd(const Op& op_, const typename Op::second_argument_type& arg2_) : op(op_), arg2(arg2_) {} + + __forceinline__ __device__ typename Op::result_type operator ()(typename TypeTraits::ParameterType a) const + { + return op(a, arg2); + } + + __host__ __device__ __forceinline__ binder2nd() {} + __host__ __device__ __forceinline__ binder2nd(const binder2nd& other) : op(other.op), arg2(other.arg2) {} + + Op op; + typename Op::second_argument_type arg2; + }; + + template __host__ __device__ __forceinline__ binder2nd bind2nd(const Op& op, const T& x) + { + return binder2nd(op, typename Op::second_argument_type(x)); + } + + // Functor Traits + template struct IsUnaryFunction + { + typedef char Yes; + struct No {Yes a[2];}; + + template static Yes check(unary_function); + static No check(...); + + static F makeF(); + + enum { value = (sizeof(check(makeF())) == sizeof(Yes)) }; + }; + + template struct IsBinaryFunction + { + typedef char Yes; + struct No {Yes a[2];}; + + template static Yes check(binary_function); + static No check(...); + + static F makeF(); + + enum { value = (sizeof(check(makeF())) == sizeof(Yes)) }; + }; + + namespace functional_detail + { + template struct UnOpShift { enum { shift = 1 }; }; + template struct UnOpShift { enum { shift = 4 }; }; + template struct UnOpShift { enum { shift = 2 }; }; + + template struct DefaultUnaryShift + { + enum { shift = UnOpShift::shift }; + }; + + template struct BinOpShift { enum { shift = 1 }; }; + template struct BinOpShift { enum { shift = 4 }; }; + template struct BinOpShift { enum { shift = 2 }; }; + + template struct DefaultBinaryShift + { + enum { shift = BinOpShift::shift }; + }; + + template ::value> struct ShiftDispatcher; + template struct ShiftDispatcher + { + enum { shift = DefaultUnaryShift::shift }; + }; + template struct ShiftDispatcher + { + enum { shift = DefaultBinaryShift::shift }; + }; + } + + template struct DefaultTransformShift + { + enum { shift = functional_detail::ShiftDispatcher::shift }; + }; + + template struct DefaultTransformFunctorTraits + { + enum { simple_block_dim_x = 16 }; + enum { simple_block_dim_y = 16 }; + + enum { smart_block_dim_x = 16 }; + enum { smart_block_dim_y = 16 }; + enum { smart_shift = DefaultTransformShift::shift }; + }; + + template struct TransformFunctorTraits : DefaultTransformFunctorTraits {}; + +#define OPENCV_CUDA_TRANSFORM_FUNCTOR_TRAITS(type) \ + template <> struct TransformFunctorTraits< type > : DefaultTransformFunctorTraits< type > +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_FUNCTIONAL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/limits.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/limits.hpp new file mode 100644 index 0000000..7e15ed6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/limits.hpp @@ -0,0 +1,128 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_LIMITS_HPP +#define OPENCV_CUDA_LIMITS_HPP + +#include +#include +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ +template struct numeric_limits; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static bool min() { return false; } + __device__ __forceinline__ static bool max() { return true; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static signed char min() { return SCHAR_MIN; } + __device__ __forceinline__ static signed char max() { return SCHAR_MAX; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static unsigned char min() { return 0; } + __device__ __forceinline__ static unsigned char max() { return UCHAR_MAX; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static short min() { return SHRT_MIN; } + __device__ __forceinline__ static short max() { return SHRT_MAX; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static unsigned short min() { return 0; } + __device__ __forceinline__ static unsigned short max() { return USHRT_MAX; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static int min() { return INT_MIN; } + __device__ __forceinline__ static int max() { return INT_MAX; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static unsigned int min() { return 0; } + __device__ __forceinline__ static unsigned int max() { return UINT_MAX; } + static const bool is_signed = false; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static float min() { return FLT_MIN; } + __device__ __forceinline__ static float max() { return FLT_MAX; } + __device__ __forceinline__ static float epsilon() { return FLT_EPSILON; } + static const bool is_signed = true; +}; + +template <> struct numeric_limits +{ + __device__ __forceinline__ static double min() { return DBL_MIN; } + __device__ __forceinline__ static double max() { return DBL_MAX; } + __device__ __forceinline__ static double epsilon() { return DBL_EPSILON; } + static const bool is_signed = true; +}; +}}} // namespace cv { namespace cuda { namespace cudev { + +//! @endcond + +#endif // OPENCV_CUDA_LIMITS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/reduce.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/reduce.hpp new file mode 100644 index 0000000..5de3650 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/reduce.hpp @@ -0,0 +1,209 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_REDUCE_HPP +#define OPENCV_CUDA_REDUCE_HPP + +#ifndef THRUST_DEBUG // eliminate -Wundef warning +#define THRUST_DEBUG 0 +#endif + +#include +#include "detail/reduce.hpp" +#include "detail/reduce_key_val.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + __device__ __forceinline__ void reduce(volatile T* smem, T& val, unsigned int tid, const Op& op) + { + reduce_detail::Dispatcher::reductor::template reduce(smem, val, tid, op); + } + template + __device__ __forceinline__ void reduce(const thrust::tuple& smem, + const thrust::tuple& val, + unsigned int tid, + const thrust::tuple& op) + { + reduce_detail::Dispatcher::reductor::template reduce< + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple&>(smem, val, tid, op); + } + + template + __device__ __forceinline__ void reduceKeyVal(volatile K* skeys, K& key, volatile V* svals, V& val, unsigned int tid, const Cmp& cmp) + { + reduce_key_val_detail::Dispatcher::reductor::template reduce(skeys, key, svals, val, tid, cmp); + } + template + __device__ __forceinline__ void reduceKeyVal(volatile K* skeys, K& key, + const thrust::tuple& svals, + const thrust::tuple& val, + unsigned int tid, const Cmp& cmp) + { + reduce_key_val_detail::Dispatcher::reductor::template reduce&, + const thrust::tuple&, + const Cmp&>(skeys, key, svals, val, tid, cmp); + } + template + __device__ __forceinline__ void reduceKeyVal(const thrust::tuple& skeys, + const thrust::tuple& key, + const thrust::tuple& svals, + const thrust::tuple& val, + unsigned int tid, + const thrust::tuple& cmp) + { + reduce_key_val_detail::Dispatcher::reductor::template reduce< + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple&, + const thrust::tuple& + >(skeys, key, svals, val, tid, cmp); + } + + // smem_tuple + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0) + { + return thrust::make_tuple((volatile T0*) t0); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6, (volatile T7*) t7); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7, T8* t8) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6, (volatile T7*) t7, (volatile T8*) t8); + } + + template + __device__ __forceinline__ + thrust::tuple + smem_tuple(T0* t0, T1* t1, T2* t2, T3* t3, T4* t4, T5* t5, T6* t6, T7* t7, T8* t8, T9* t9) + { + return thrust::make_tuple((volatile T0*) t0, (volatile T1*) t1, (volatile T2*) t2, (volatile T3*) t3, (volatile T4*) t4, (volatile T5*) t5, (volatile T6*) t6, (volatile T7*) t7, (volatile T8*) t8, (volatile T9*) t9); + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_REDUCE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/saturate_cast.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/saturate_cast.hpp new file mode 100644 index 0000000..c3a3d1c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/saturate_cast.hpp @@ -0,0 +1,292 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_SATURATE_CAST_HPP +#define OPENCV_CUDA_SATURATE_CAST_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template __device__ __forceinline__ _Tp saturate_cast(uchar v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(schar v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(ushort v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(short v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(uint v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(int v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(float v) { return _Tp(v); } + template __device__ __forceinline__ _Tp saturate_cast(double v) { return _Tp(v); } + + template<> __device__ __forceinline__ uchar saturate_cast(schar v) + { + uint res = 0; + int vi = v; + asm("cvt.sat.u8.s8 %0, %1;" : "=r"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(short v) + { + uint res = 0; + asm("cvt.sat.u8.s16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(ushort v) + { + uint res = 0; + asm("cvt.sat.u8.u16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(int v) + { + uint res = 0; + asm("cvt.sat.u8.s32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(uint v) + { + uint res = 0; + asm("cvt.sat.u8.u32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(float v) + { + uint res = 0; + asm("cvt.rni.sat.u8.f32 %0, %1;" : "=r"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ uchar saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + uint res = 0; + asm("cvt.rni.sat.u8.f64 %0, %1;" : "=r"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ schar saturate_cast(uchar v) + { + uint res = 0; + uint vi = v; + asm("cvt.sat.s8.u8 %0, %1;" : "=r"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(short v) + { + uint res = 0; + asm("cvt.sat.s8.s16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(ushort v) + { + uint res = 0; + asm("cvt.sat.s8.u16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(int v) + { + uint res = 0; + asm("cvt.sat.s8.s32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(uint v) + { + uint res = 0; + asm("cvt.sat.s8.u32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(float v) + { + uint res = 0; + asm("cvt.rni.sat.s8.f32 %0, %1;" : "=r"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ schar saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + uint res = 0; + asm("cvt.rni.sat.s8.f64 %0, %1;" : "=r"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ ushort saturate_cast(schar v) + { + ushort res = 0; + int vi = v; + asm("cvt.sat.u16.s8 %0, %1;" : "=h"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(short v) + { + ushort res = 0; + asm("cvt.sat.u16.s16 %0, %1;" : "=h"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(int v) + { + ushort res = 0; + asm("cvt.sat.u16.s32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(uint v) + { + ushort res = 0; + asm("cvt.sat.u16.u32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(float v) + { + ushort res = 0; + asm("cvt.rni.sat.u16.f32 %0, %1;" : "=h"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ ushort saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + ushort res = 0; + asm("cvt.rni.sat.u16.f64 %0, %1;" : "=h"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ short saturate_cast(ushort v) + { + short res = 0; + asm("cvt.sat.s16.u16 %0, %1;" : "=h"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(int v) + { + short res = 0; + asm("cvt.sat.s16.s32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(uint v) + { + short res = 0; + asm("cvt.sat.s16.u32 %0, %1;" : "=h"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(float v) + { + short res = 0; + asm("cvt.rni.sat.s16.f32 %0, %1;" : "=h"(res) : "f"(v)); + return res; + } + template<> __device__ __forceinline__ short saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + short res = 0; + asm("cvt.rni.sat.s16.f64 %0, %1;" : "=h"(res) : "d"(v)); + return res; + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ int saturate_cast(uint v) + { + int res = 0; + asm("cvt.sat.s32.u32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ int saturate_cast(float v) + { + return __float2int_rn(v); + } + template<> __device__ __forceinline__ int saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + return __double2int_rn(v); + #else + return saturate_cast((float)v); + #endif + } + + template<> __device__ __forceinline__ uint saturate_cast(schar v) + { + uint res = 0; + int vi = v; + asm("cvt.sat.u32.s8 %0, %1;" : "=r"(res) : "r"(vi)); + return res; + } + template<> __device__ __forceinline__ uint saturate_cast(short v) + { + uint res = 0; + asm("cvt.sat.u32.s16 %0, %1;" : "=r"(res) : "h"(v)); + return res; + } + template<> __device__ __forceinline__ uint saturate_cast(int v) + { + uint res = 0; + asm("cvt.sat.u32.s32 %0, %1;" : "=r"(res) : "r"(v)); + return res; + } + template<> __device__ __forceinline__ uint saturate_cast(float v) + { + return __float2uint_rn(v); + } + template<> __device__ __forceinline__ uint saturate_cast(double v) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 130 + return __double2uint_rn(v); + #else + return saturate_cast((float)v); + #endif + } +}}} + +//! @endcond + +#endif /* OPENCV_CUDA_SATURATE_CAST_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/scan.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/scan.hpp new file mode 100644 index 0000000..e128fb0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/scan.hpp @@ -0,0 +1,258 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_SCAN_HPP +#define OPENCV_CUDA_SCAN_HPP + +#include "opencv2/core/cuda/common.hpp" +#include "opencv2/core/cuda/utility.hpp" +#include "opencv2/core/cuda/warp.hpp" +#include "opencv2/core/cuda/warp_shuffle.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + enum ScanKind { EXCLUSIVE = 0, INCLUSIVE = 1 }; + + template struct WarpScan + { + __device__ __forceinline__ WarpScan() {} + __device__ __forceinline__ WarpScan(const WarpScan& other) { CV_UNUSED(other); } + + __device__ __forceinline__ T operator()( volatile T *ptr , const unsigned int idx) + { + const unsigned int lane = idx & 31; + F op; + + if ( lane >= 1) ptr [idx ] = op(ptr [idx - 1], ptr [idx]); + if ( lane >= 2) ptr [idx ] = op(ptr [idx - 2], ptr [idx]); + if ( lane >= 4) ptr [idx ] = op(ptr [idx - 4], ptr [idx]); + if ( lane >= 8) ptr [idx ] = op(ptr [idx - 8], ptr [idx]); + if ( lane >= 16) ptr [idx ] = op(ptr [idx - 16], ptr [idx]); + + if( Kind == INCLUSIVE ) + return ptr [idx]; + else + return (lane > 0) ? ptr [idx - 1] : 0; + } + + __device__ __forceinline__ unsigned int index(const unsigned int tid) + { + return tid; + } + + __device__ __forceinline__ void init(volatile T *ptr){} + + static const int warp_offset = 0; + + typedef WarpScan merge; + }; + + template struct WarpScanNoComp + { + __device__ __forceinline__ WarpScanNoComp() {} + __device__ __forceinline__ WarpScanNoComp(const WarpScanNoComp& other) { CV_UNUSED(other); } + + __device__ __forceinline__ T operator()( volatile T *ptr , const unsigned int idx) + { + const unsigned int lane = threadIdx.x & 31; + F op; + + ptr [idx ] = op(ptr [idx - 1], ptr [idx]); + ptr [idx ] = op(ptr [idx - 2], ptr [idx]); + ptr [idx ] = op(ptr [idx - 4], ptr [idx]); + ptr [idx ] = op(ptr [idx - 8], ptr [idx]); + ptr [idx ] = op(ptr [idx - 16], ptr [idx]); + + if( Kind == INCLUSIVE ) + return ptr [idx]; + else + return (lane > 0) ? ptr [idx - 1] : 0; + } + + __device__ __forceinline__ unsigned int index(const unsigned int tid) + { + return (tid >> warp_log) * warp_smem_stride + 16 + (tid & warp_mask); + } + + __device__ __forceinline__ void init(volatile T *ptr) + { + ptr[threadIdx.x] = 0; + } + + static const int warp_smem_stride = 32 + 16 + 1; + static const int warp_offset = 16; + static const int warp_log = 5; + static const int warp_mask = 31; + + typedef WarpScanNoComp merge; + }; + + template struct BlockScan + { + __device__ __forceinline__ BlockScan() {} + __device__ __forceinline__ BlockScan(const BlockScan& other) { CV_UNUSED(other); } + + __device__ __forceinline__ T operator()(volatile T *ptr) + { + const unsigned int tid = threadIdx.x; + const unsigned int lane = tid & warp_mask; + const unsigned int warp = tid >> warp_log; + + Sc scan; + typename Sc::merge merge_scan; + const unsigned int idx = scan.index(tid); + + T val = scan(ptr, idx); + __syncthreads (); + + if( warp == 0) + scan.init(ptr); + __syncthreads (); + + if( lane == 31 ) + ptr [scan.warp_offset + warp ] = (Kind == INCLUSIVE) ? val : ptr [idx]; + __syncthreads (); + + if( warp == 0 ) + merge_scan(ptr, idx); + __syncthreads(); + + if ( warp > 0) + val = ptr [scan.warp_offset + warp - 1] + val; + __syncthreads (); + + ptr[idx] = val; + __syncthreads (); + + return val ; + } + + static const int warp_log = 5; + static const int warp_mask = 31; + }; + + template + __device__ T warpScanInclusive(T idata, volatile T* s_Data, unsigned int tid) + { + #if __CUDA_ARCH__ >= 300 + const unsigned int laneId = cv::cuda::device::Warp::laneId(); + + // scan on shuffl functions + #pragma unroll + for (int i = 1; i <= (OPENCV_CUDA_WARP_SIZE / 2); i *= 2) + { + const T n = cv::cuda::device::shfl_up(idata, i); + if (laneId >= i) + idata += n; + } + + return idata; + #else + unsigned int pos = 2 * tid - (tid & (OPENCV_CUDA_WARP_SIZE - 1)); + s_Data[pos] = 0; + pos += OPENCV_CUDA_WARP_SIZE; + s_Data[pos] = idata; + + s_Data[pos] += s_Data[pos - 1]; + s_Data[pos] += s_Data[pos - 2]; + s_Data[pos] += s_Data[pos - 4]; + s_Data[pos] += s_Data[pos - 8]; + s_Data[pos] += s_Data[pos - 16]; + + return s_Data[pos]; + #endif + } + + template + __device__ __forceinline__ T warpScanExclusive(T idata, volatile T* s_Data, unsigned int tid) + { + return warpScanInclusive(idata, s_Data, tid) - idata; + } + + template + __device__ T blockScanInclusive(T idata, volatile T* s_Data, unsigned int tid) + { + if (tiNumScanThreads > OPENCV_CUDA_WARP_SIZE) + { + //Bottom-level inclusive warp scan + T warpResult = warpScanInclusive(idata, s_Data, tid); + + //Save top elements of each warp for exclusive warp scan + //sync to wait for warp scans to complete (because s_Data is being overwritten) + __syncthreads(); + if ((tid & (OPENCV_CUDA_WARP_SIZE - 1)) == (OPENCV_CUDA_WARP_SIZE - 1)) + { + s_Data[tid >> OPENCV_CUDA_LOG_WARP_SIZE] = warpResult; + } + + //wait for warp scans to complete + __syncthreads(); + + if (tid < (tiNumScanThreads / OPENCV_CUDA_WARP_SIZE) ) + { + //grab top warp elements + T val = s_Data[tid]; + //calculate exclusive scan and write back to shared memory + s_Data[tid] = warpScanExclusive(val, s_Data, tid); + } + + //return updated warp scans with exclusive scan results + __syncthreads(); + + return warpResult + s_Data[tid >> OPENCV_CUDA_LOG_WARP_SIZE]; + } + else + { + return warpScanInclusive(idata, s_Data, tid); + } + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_SCAN_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/simd_functions.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/simd_functions.hpp new file mode 100644 index 0000000..3d8c2e0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/simd_functions.hpp @@ -0,0 +1,869 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +/* + * Copyright (c) 2013 NVIDIA Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of NVIDIA Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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 OPENCV_CUDA_SIMD_FUNCTIONS_HPP +#define OPENCV_CUDA_SIMD_FUNCTIONS_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + // 2 + + static __device__ __forceinline__ unsigned int vadd2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vadd2.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vadd.u32.u32.u32.sat %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = a ^ b; // sum bits + r = a + b; // actual sum + s = s ^ r; // determine carry-ins for each bit position + s = s & 0x00010000; // carry-in to high word (= carry-out from low word) + r = r - s; // subtract out carry-out from low word + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsub2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vsub2.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vsub.u32.u32.u32.sat %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = a ^ b; // sum bits + r = a - b; // actual sum + s = s ^ r; // determine carry-ins for each bit position + s = s & 0x00010000; // borrow to high word + r = r + s; // compensate for borrow from low word + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vabsdiff2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vabsdiff2.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vabsdiff.u32.u32.u32.sat %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t, u, v; + s = a & 0x0000ffff; // extract low halfword + r = b & 0x0000ffff; // extract low halfword + u = ::max(r, s); // maximum of low halfwords + v = ::min(r, s); // minimum of low halfwords + s = a & 0xffff0000; // extract high halfword + r = b & 0xffff0000; // extract high halfword + t = ::max(r, s); // maximum of high halfwords + s = ::min(r, s); // minimum of high halfwords + r = u | t; // maximum of both halfwords + s = v | s; // minimum of both halfwords + r = r - s; // |a - b| = max(a,b) - min(a,b); + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vavg2(unsigned int a, unsigned int b) + { + unsigned int r, s; + + // HAKMEM #23: a + b = 2 * (a & b) + (a ^ b) ==> + // (a + b) / 2 = (a & b) + ((a ^ b) >> 1) + s = a ^ b; + r = a & b; + s = s & 0xfffefffe; // ensure shift doesn't cross halfword boundaries + s = s >> 1; + s = r + s; + + return s; + } + + static __device__ __forceinline__ unsigned int vavrg2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vavrg2.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // HAKMEM #23: a + b = 2 * (a | b) - (a ^ b) ==> + // (a + b + 1) / 2 = (a | b) - ((a ^ b) >> 1) + unsigned int s; + s = a ^ b; + r = a | b; + s = s & 0xfffefffe; // ensure shift doesn't cross half-word boundaries + s = s >> 1; + r = r - s; + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vseteq2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.eq %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + r = r ^ c; // extract msbs, msb = 1 if r < 0x8000 + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r & ~c; // msb = 1, if r was 0x0000 + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpeq2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vseteq2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + r = r ^ c; // extract msbs, msb = 1 if r < 0x8000 + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r & ~c; // msb = 1, if r was 0x0000 + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetge2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.ge %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavrg2(a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpge2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetge2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavrg2(a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetgt2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.gt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg2(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80008000; // msbs = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpgt2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetgt2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg2(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80008000; // msbs = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetle2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.le %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg2(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmple2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetle2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg2(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetlt2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset2.u32.u32.lt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg2(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmplt2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetlt2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg2(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80008000; // msb = carry-outs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetne2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm ("vset2.u32.u32.ne %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r | c; // msb = 1, if r was not 0x0000 + c = c & 0x80008000; // extract msbs + r = c >> 15; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpne2(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetne2(a, b); + c = r << 16; // convert bool + r = c - r; // into mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + r = a ^ b; // 0x0000 if a == b + c = r | 0x80008000; // set msbs, to catch carry out + c = c - 0x00010001; // msb = 0, if r was 0x0000 or 0x8000 + c = r | c; // msb = 1, if r was not 0x0000 + c = c & 0x80008000; // extract msbs + r = c >> 15; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vmax2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmax2.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmax.u32.u32.u32 %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t, u; + r = a & 0x0000ffff; // extract low halfword + s = b & 0x0000ffff; // extract low halfword + t = ::max(r, s); // maximum of low halfwords + r = a & 0xffff0000; // extract high halfword + s = b & 0xffff0000; // extract high halfword + u = ::max(r, s); // maximum of high halfwords + r = t | u; // combine halfword maximums + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vmin2(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmin2.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmin.u32.u32.u32 %0.h0, %1.h0, %2.h0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.h1, %1.h1, %2.h1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t, u; + r = a & 0x0000ffff; // extract low halfword + s = b & 0x0000ffff; // extract low halfword + t = ::min(r, s); // minimum of low halfwords + r = a & 0xffff0000; // extract high halfword + s = b & 0xffff0000; // extract high halfword + u = ::min(r, s); // minimum of high halfwords + r = t | u; // combine halfword minimums + #endif + + return r; + } + + // 4 + + static __device__ __forceinline__ unsigned int vadd4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vadd4.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vadd.u32.u32.u32.sat %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vadd.u32.u32.u32.sat %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t; + s = a ^ b; // sum bits + r = a & 0x7f7f7f7f; // clear msbs + t = b & 0x7f7f7f7f; // clear msbs + s = s & 0x80808080; // msb sum bits + r = r + t; // add without msbs, record carry-out in msbs + r = r ^ s; // sum of msb sum and carry-in bits, w/o carry-out + #endif /* __CUDA_ARCH__ >= 300 */ + + return r; + } + + static __device__ __forceinline__ unsigned int vsub4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vsub4.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vsub.u32.u32.u32.sat %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vsub.u32.u32.u32.sat %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s, t; + s = a ^ ~b; // inverted sum bits + r = a | 0x80808080; // set msbs + t = b & 0x7f7f7f7f; // clear msbs + s = s & 0x80808080; // inverted msb sum bits + r = r - t; // subtract w/o msbs, record inverted borrows in msb + r = r ^ s; // combine inverted msb sum bits and borrows + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vavg4(unsigned int a, unsigned int b) + { + unsigned int r, s; + + // HAKMEM #23: a + b = 2 * (a & b) + (a ^ b) ==> + // (a + b) / 2 = (a & b) + ((a ^ b) >> 1) + s = a ^ b; + r = a & b; + s = s & 0xfefefefe; // ensure following shift doesn't cross byte boundaries + s = s >> 1; + s = r + s; + + return s; + } + + static __device__ __forceinline__ unsigned int vavrg4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vavrg4.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // HAKMEM #23: a + b = 2 * (a | b) - (a ^ b) ==> + // (a + b + 1) / 2 = (a | b) - ((a ^ b) >> 1) + unsigned int c; + c = a ^ b; + r = a | b; + c = c & 0xfefefefe; // ensure following shift doesn't cross byte boundaries + c = c >> 1; + r = r - c; + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vseteq4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.eq %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x00 if a == b + c = r | 0x80808080; // set msbs, to catch carry out + r = r ^ c; // extract msbs, msb = 1 if r < 0x80 + c = c - 0x01010101; // msb = 0, if r was 0x00 or 0x80 + c = r & ~c; // msb = 1, if r was 0x00 + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpeq4(unsigned int a, unsigned int b) + { + unsigned int r, t; + + #if __CUDA_ARCH__ >= 300 + r = vseteq4(a, b); + t = r << 8; // convert bool + r = t - r; // to mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + t = a ^ b; // 0x00 if a == b + r = t | 0x80808080; // set msbs, to catch carry out + t = t ^ r; // extract msbs, msb = 1 if t < 0x80 + r = r - 0x01010101; // msb = 0, if t was 0x00 or 0x80 + r = t & ~r; // msb = 1, if t was 0x00 + t = r >> 7; // build mask + t = r - t; // from + r = t | r; // msbs + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetle4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.le %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg4(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmple4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetle4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavrg4(a, b); // (b + ~a + 1) / 2 = (b - a) / 2 + c = c & 0x80808080; // msbs = carry-outs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetlt4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.lt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg4(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmplt4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetlt4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + asm("not.b32 %0, %0;" : "+r"(a)); + c = vavg4(a, b); // (b + ~a) / 2 = (b - a) / 2 [rounded down] + c = c & 0x80808080; // msbs = carry-outs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetge4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.ge %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavrg4(a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpge4(unsigned int a, unsigned int b) + { + unsigned int r, s; + + #if __CUDA_ARCH__ >= 300 + r = vsetge4(a, b); + s = r << 8; // convert bool + r = s - r; // to mask + #else + asm ("not.b32 %0,%0;" : "+r"(b)); + r = vavrg4 (a, b); // (a + ~b + 1) / 2 = (a - b) / 2 + r = r & 0x80808080; // msb = carry-outs + s = r >> 7; // build mask + s = r - s; // from + r = s | r; // msbs + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetgt4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.gt %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int c; + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg4(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpgt4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetgt4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + asm("not.b32 %0, %0;" : "+r"(b)); + c = vavg4(a, b); // (a + ~b) / 2 = (a - b) / 2 [rounded down] + c = c & 0x80808080; // msb = carry-outs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vsetne4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vset4.u32.u32.ne %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + unsigned int c; + r = a ^ b; // 0x00 if a == b + c = r | 0x80808080; // set msbs, to catch carry out + c = c - 0x01010101; // msb = 0, if r was 0x00 or 0x80 + c = r | c; // msb = 1, if r was not 0x00 + c = c & 0x80808080; // extract msbs + r = c >> 7; // convert to bool + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vcmpne4(unsigned int a, unsigned int b) + { + unsigned int r, c; + + #if __CUDA_ARCH__ >= 300 + r = vsetne4(a, b); + c = r << 8; // convert bool + r = c - r; // to mask + #else + // inspired by Alan Mycroft's null-byte detection algorithm: + // null_byte(x) = ((x - 0x01010101) & (~x & 0x80808080)) + r = a ^ b; // 0x00 if a == b + c = r | 0x80808080; // set msbs, to catch carry out + c = c - 0x01010101; // msb = 0, if r was 0x00 or 0x80 + c = r | c; // msb = 1, if r was not 0x00 + c = c & 0x80808080; // extract msbs + r = c >> 7; // convert + r = c - r; // msbs to + r = c | r; // mask + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vabsdiff4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vabsdiff4.u32.u32.u32.sat %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vabsdiff.u32.u32.u32.sat %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vabsdiff.u32.u32.u32.sat %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = vcmpge4(a, b); // mask = 0xff if a >= b + r = a ^ b; // + s = (r & s) ^ b; // select a when a >= b, else select b => max(a,b) + r = s ^ r; // select a when b >= a, else select b => min(a,b) + r = s - r; // |a - b| = max(a,b) - min(a,b); + #endif + + return r; + } + + static __device__ __forceinline__ unsigned int vmax4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmax4.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmax.u32.u32.u32 %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmax.u32.u32.u32 %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = vcmpge4(a, b); // mask = 0xff if a >= b + r = a & s; // select a when b >= a + s = b & ~s; // select b when b < a + r = r | s; // combine byte selections + #endif + + return r; // byte-wise unsigned maximum + } + + static __device__ __forceinline__ unsigned int vmin4(unsigned int a, unsigned int b) + { + unsigned int r = 0; + + #if __CUDA_ARCH__ >= 300 + asm("vmin4.u32.u32.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #elif __CUDA_ARCH__ >= 200 + asm("vmin.u32.u32.u32 %0.b0, %1.b0, %2.b0, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.b1, %1.b1, %2.b1, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.b2, %1.b2, %2.b2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + asm("vmin.u32.u32.u32 %0.b3, %1.b3, %2.b3, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(r)); + #else + unsigned int s; + s = vcmpge4(b, a); // mask = 0xff if a >= b + r = a & s; // select a when b >= a + s = b & ~s; // select b when b < a + r = r | s; // combine byte selections + #endif + + return r; + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_SIMD_FUNCTIONS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/transform.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/transform.hpp new file mode 100644 index 0000000..42aa6ea --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/transform.hpp @@ -0,0 +1,75 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TRANSFORM_HPP +#define OPENCV_CUDA_TRANSFORM_HPP + +#include "common.hpp" +#include "utility.hpp" +#include "detail/transform_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + static inline void transform(PtrStepSz src, PtrStepSz dst, UnOp op, const Mask& mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + transform_detail::TransformDispatcher::cn == 1 && VecTraits::cn == 1 && ft::smart_shift != 1>::call(src, dst, op, mask, stream); + } + + template + static inline void transform(PtrStepSz src1, PtrStepSz src2, PtrStepSz dst, BinOp op, const Mask& mask, cudaStream_t stream) + { + typedef TransformFunctorTraits ft; + transform_detail::TransformDispatcher::cn == 1 && VecTraits::cn == 1 && VecTraits::cn == 1 && ft::smart_shift != 1>::call(src1, src2, dst, op, mask, stream); + } +}}} + +//! @endcond + +#endif // OPENCV_CUDA_TRANSFORM_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/type_traits.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/type_traits.hpp new file mode 100644 index 0000000..8b7a3fd --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/type_traits.hpp @@ -0,0 +1,90 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_TYPE_TRAITS_HPP +#define OPENCV_CUDA_TYPE_TRAITS_HPP + +#include "detail/type_traits_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct IsSimpleParameter + { + enum {value = type_traits_detail::IsIntegral::value || type_traits_detail::IsFloat::value || + type_traits_detail::PointerTraits::type>::value}; + }; + + template struct TypeTraits + { + typedef typename type_traits_detail::UnConst::type NonConstType; + typedef typename type_traits_detail::UnVolatile::type NonVolatileType; + typedef typename type_traits_detail::UnVolatile::type>::type UnqualifiedType; + typedef typename type_traits_detail::PointerTraits::type PointeeType; + typedef typename type_traits_detail::ReferenceTraits::type ReferredType; + + enum { isConst = type_traits_detail::UnConst::value }; + enum { isVolatile = type_traits_detail::UnVolatile::value }; + + enum { isReference = type_traits_detail::ReferenceTraits::value }; + enum { isPointer = type_traits_detail::PointerTraits::type>::value }; + + enum { isUnsignedInt = type_traits_detail::IsUnsignedIntegral::value }; + enum { isSignedInt = type_traits_detail::IsSignedIntergral::value }; + enum { isIntegral = type_traits_detail::IsIntegral::value }; + enum { isFloat = type_traits_detail::IsFloat::value }; + enum { isArith = isIntegral || isFloat }; + enum { isVec = type_traits_detail::IsVec::value }; + + typedef typename type_traits_detail::Select::value, + T, typename type_traits_detail::AddParameterType::type>::type ParameterType; + }; +}}} + +//! @endcond + +#endif // OPENCV_CUDA_TYPE_TRAITS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/utility.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/utility.hpp new file mode 100644 index 0000000..7f5db48 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/utility.hpp @@ -0,0 +1,230 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_UTILITY_HPP +#define OPENCV_CUDA_UTILITY_HPP + +#include "saturate_cast.hpp" +#include "datamov_utils.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct CV_EXPORTS ThrustAllocator + { + typedef uchar value_type; + virtual ~ThrustAllocator(); + virtual __device__ __host__ uchar* allocate(size_t numBytes) = 0; + virtual __device__ __host__ void deallocate(uchar* ptr, size_t numBytes) = 0; + static ThrustAllocator& getAllocator(); + static void setAllocator(ThrustAllocator* allocator); + }; + #define OPENCV_CUDA_LOG_WARP_SIZE (5) + #define OPENCV_CUDA_WARP_SIZE (1 << OPENCV_CUDA_LOG_WARP_SIZE) + #define OPENCV_CUDA_LOG_MEM_BANKS ((__CUDA_ARCH__ >= 200) ? 5 : 4) // 32 banks on fermi, 16 on tesla + #define OPENCV_CUDA_MEM_BANKS (1 << OPENCV_CUDA_LOG_MEM_BANKS) + + /////////////////////////////////////////////////////////////////////////////// + // swap + + template void __device__ __host__ __forceinline__ swap(T& a, T& b) + { + const T temp = a; + a = b; + b = temp; + } + + /////////////////////////////////////////////////////////////////////////////// + // Mask Reader + + struct SingleMask + { + explicit __host__ __device__ __forceinline__ SingleMask(PtrStepb mask_) : mask(mask_) {} + __host__ __device__ __forceinline__ SingleMask(const SingleMask& mask_): mask(mask_.mask){} + + __device__ __forceinline__ bool operator()(int y, int x) const + { + return mask.ptr(y)[x] != 0; + } + + PtrStepb mask; + }; + + struct SingleMaskChannels + { + __host__ __device__ __forceinline__ SingleMaskChannels(PtrStepb mask_, int channels_) + : mask(mask_), channels(channels_) {} + __host__ __device__ __forceinline__ SingleMaskChannels(const SingleMaskChannels& mask_) + :mask(mask_.mask), channels(mask_.channels){} + + __device__ __forceinline__ bool operator()(int y, int x) const + { + return mask.ptr(y)[x / channels] != 0; + } + + PtrStepb mask; + int channels; + }; + + struct MaskCollection + { + explicit __host__ __device__ __forceinline__ MaskCollection(PtrStepb* maskCollection_) + : maskCollection(maskCollection_) {} + + __device__ __forceinline__ MaskCollection(const MaskCollection& masks_) + : maskCollection(masks_.maskCollection), curMask(masks_.curMask){} + + __device__ __forceinline__ void next() + { + curMask = *maskCollection++; + } + __device__ __forceinline__ void setMask(int z) + { + curMask = maskCollection[z]; + } + + __device__ __forceinline__ bool operator()(int y, int x) const + { + uchar val; + return curMask.data == 0 || (ForceGlob::Load(curMask.ptr(y), x, val), (val != 0)); + } + + const PtrStepb* maskCollection; + PtrStepb curMask; + }; + + struct WithOutMask + { + __host__ __device__ __forceinline__ WithOutMask(){} + __host__ __device__ __forceinline__ WithOutMask(const WithOutMask&){} + + __device__ __forceinline__ void next() const + { + } + __device__ __forceinline__ void setMask(int) const + { + } + + __device__ __forceinline__ bool operator()(int, int) const + { + return true; + } + + __device__ __forceinline__ bool operator()(int, int, int) const + { + return true; + } + + static __device__ __forceinline__ bool check(int, int) + { + return true; + } + + static __device__ __forceinline__ bool check(int, int, int) + { + return true; + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // Solve linear system + + // solve 2x2 linear system Ax=b + template __device__ __forceinline__ bool solve2x2(const T A[2][2], const T b[2], T x[2]) + { + T det = A[0][0] * A[1][1] - A[1][0] * A[0][1]; + + if (det != 0) + { + double invdet = 1.0 / det; + + x[0] = saturate_cast(invdet * (b[0] * A[1][1] - b[1] * A[0][1])); + + x[1] = saturate_cast(invdet * (A[0][0] * b[1] - A[1][0] * b[0])); + + return true; + } + + return false; + } + + // solve 3x3 linear system Ax=b + template __device__ __forceinline__ bool solve3x3(const T A[3][3], const T b[3], T x[3]) + { + T det = A[0][0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) + - A[0][1] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) + + A[0][2] * (A[1][0] * A[2][1] - A[1][1] * A[2][0]); + + if (det != 0) + { + double invdet = 1.0 / det; + + x[0] = saturate_cast(invdet * + (b[0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) - + A[0][1] * (b[1] * A[2][2] - A[1][2] * b[2] ) + + A[0][2] * (b[1] * A[2][1] - A[1][1] * b[2] ))); + + x[1] = saturate_cast(invdet * + (A[0][0] * (b[1] * A[2][2] - A[1][2] * b[2] ) - + b[0] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) + + A[0][2] * (A[1][0] * b[2] - b[1] * A[2][0]))); + + x[2] = saturate_cast(invdet * + (A[0][0] * (A[1][1] * b[2] - b[1] * A[2][1]) - + A[0][1] * (A[1][0] * b[2] - b[1] * A[2][0]) + + b[0] * (A[1][0] * A[2][1] - A[1][1] * A[2][0]))); + + return true; + } + + return false; + } +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_UTILITY_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_distance.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_distance.hpp new file mode 100644 index 0000000..ef6e510 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_distance.hpp @@ -0,0 +1,232 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VEC_DISTANCE_HPP +#define OPENCV_CUDA_VEC_DISTANCE_HPP + +#include "reduce.hpp" +#include "functional.hpp" +#include "detail/vec_distance_detail.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct L1Dist + { + typedef int value_type; + typedef int result_type; + + __device__ __forceinline__ L1Dist() : mySum(0) {} + + __device__ __forceinline__ void reduceIter(int val1, int val2) + { + mySum = __sad(val1, val2, mySum); + } + + template __device__ __forceinline__ void reduceAll(int* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator int() const + { + return mySum; + } + + int mySum; + }; + template <> struct L1Dist + { + typedef float value_type; + typedef float result_type; + + __device__ __forceinline__ L1Dist() : mySum(0.0f) {} + + __device__ __forceinline__ void reduceIter(float val1, float val2) + { + mySum += ::fabs(val1 - val2); + } + + template __device__ __forceinline__ void reduceAll(float* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator float() const + { + return mySum; + } + + float mySum; + }; + + struct L2Dist + { + typedef float value_type; + typedef float result_type; + + __device__ __forceinline__ L2Dist() : mySum(0.0f) {} + + __device__ __forceinline__ void reduceIter(float val1, float val2) + { + float reg = val1 - val2; + mySum += reg * reg; + } + + template __device__ __forceinline__ void reduceAll(float* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator float() const + { + return sqrtf(mySum); + } + + float mySum; + }; + + struct HammingDist + { + typedef int value_type; + typedef int result_type; + + __device__ __forceinline__ HammingDist() : mySum(0) {} + + __device__ __forceinline__ void reduceIter(int val1, int val2) + { + mySum += __popc(val1 ^ val2); + } + + template __device__ __forceinline__ void reduceAll(int* smem, int tid) + { + reduce(smem, mySum, tid, plus()); + } + + __device__ __forceinline__ operator int() const + { + return mySum; + } + + int mySum; + }; + + // calc distance between two vectors in global memory + template + __device__ void calcVecDiffGlobal(const T1* vec1, const T2* vec2, int len, Dist& dist, typename Dist::result_type* smem, int tid) + { + for (int i = tid; i < len; i += THREAD_DIM) + { + T1 val1; + ForceGlob::Load(vec1, i, val1); + + T2 val2; + ForceGlob::Load(vec2, i, val2); + + dist.reduceIter(val1, val2); + } + + dist.reduceAll(smem, tid); + } + + // calc distance between two vectors, first vector is cached in register or shared memory, second vector is in global memory + template + __device__ __forceinline__ void calcVecDiffCached(const T1* vecCached, const T2* vecGlob, int len, Dist& dist, typename Dist::result_type* smem, int tid) + { + vec_distance_detail::VecDiffCachedCalculator::calc(vecCached, vecGlob, len, dist, tid); + + dist.reduceAll(smem, tid); + } + + // calc distance between two vectors in global memory + template struct VecDiffGlobal + { + explicit __device__ __forceinline__ VecDiffGlobal(const T1* vec1_, int = 0, void* = 0, int = 0, int = 0) + { + vec1 = vec1_; + } + + template + __device__ __forceinline__ void calc(const T2* vec2, int len, Dist& dist, typename Dist::result_type* smem, int tid) const + { + calcVecDiffGlobal(vec1, vec2, len, dist, smem, tid); + } + + const T1* vec1; + }; + + // calc distance between two vectors, first vector is cached in register memory, second vector is in global memory + template struct VecDiffCachedRegister + { + template __device__ __forceinline__ VecDiffCachedRegister(const T1* vec1, int len, U* smem, int glob_tid, int tid) + { + if (glob_tid < len) + smem[glob_tid] = vec1[glob_tid]; + __syncthreads(); + + U* vec1ValsPtr = vec1Vals; + + #pragma unroll + for (int i = tid; i < MAX_LEN; i += THREAD_DIM) + *vec1ValsPtr++ = smem[i]; + + __syncthreads(); + } + + template + __device__ __forceinline__ void calc(const T2* vec2, int len, Dist& dist, typename Dist::result_type* smem, int tid) const + { + calcVecDiffCached(vec1Vals, vec2, len, dist, smem, tid); + } + + U vec1Vals[MAX_LEN / THREAD_DIM]; + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_VEC_DISTANCE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_math.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_math.hpp new file mode 100644 index 0000000..80b1303 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_math.hpp @@ -0,0 +1,923 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VECMATH_HPP +#define OPENCV_CUDA_VECMATH_HPP + +#include "vec_traits.hpp" +#include "saturate_cast.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + +// saturate_cast + +namespace vec_math_detail +{ + template struct SatCastHelper; + template struct SatCastHelper<1, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x)); + } + }; + template struct SatCastHelper<2, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x), saturate_cast(v.y)); + } + }; + template struct SatCastHelper<3, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x), saturate_cast(v.y), saturate_cast(v.z)); + } + }; + template struct SatCastHelper<4, VecD> + { + template static __device__ __forceinline__ VecD cast(const VecS& v) + { + typedef typename VecTraits::elem_type D; + return VecTraits::make(saturate_cast(v.x), saturate_cast(v.y), saturate_cast(v.z), saturate_cast(v.w)); + } + }; + + template static __device__ __forceinline__ VecD saturate_cast_helper(const VecS& v) + { + return SatCastHelper::cn, VecD>::cast(v); + } +} + +template static __device__ __forceinline__ T saturate_cast(const uchar1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float1& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double1& v) {return vec_math_detail::saturate_cast_helper(v);} + +template static __device__ __forceinline__ T saturate_cast(const uchar2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float2& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double2& v) {return vec_math_detail::saturate_cast_helper(v);} + +template static __device__ __forceinline__ T saturate_cast(const uchar3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float3& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double3& v) {return vec_math_detail::saturate_cast_helper(v);} + +template static __device__ __forceinline__ T saturate_cast(const uchar4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const char4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const ushort4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const short4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const uint4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const int4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const float4& v) {return vec_math_detail::saturate_cast_helper(v);} +template static __device__ __forceinline__ T saturate_cast(const double4& v) {return vec_math_detail::saturate_cast_helper(v);} + +// unary operators + +#define CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(op, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 operator op(const input_type ## 1 & a) \ + { \ + return VecTraits::make(op (a.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(const input_type ## 2 & a) \ + { \ + return VecTraits::make(op (a.x), op (a.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(const input_type ## 3 & a) \ + { \ + return VecTraits::make(op (a.x), op (a.y), op (a.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(const input_type ## 4 & a) \ + { \ + return VecTraits::make(op (a.x), op (a.y), op (a.z), op (a.w)); \ + } + +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, char, char) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, short, short) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, int, int) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(-, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(!, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, char, char) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, short, short) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, int, int) +CV_CUDEV_IMPLEMENT_VEC_UNARY_OP(~, uint, uint) + +#undef CV_CUDEV_IMPLEMENT_VEC_UNARY_OP + +// unary functions + +#define CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(func_name, func, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 func_name(const input_type ## 1 & a) \ + { \ + return VecTraits::make(func (a.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(const input_type ## 2 & a) \ + { \ + return VecTraits::make(func (a.x), func (a.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(const input_type ## 3 & a) \ + { \ + return VecTraits::make(func (a.x), func (a.y), func (a.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(const input_type ## 4 & a) \ + { \ + return VecTraits::make(func (a.x), func (a.y), func (a.z), func (a.w)); \ + } + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(abs, ::fabsf, float, float) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrtf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sqrt, ::sqrt, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::expf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp, ::exp, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp2, ::exp2, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(exp10, ::exp10, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::logf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log, ::log, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log2, ::log2, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10f, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(log10, ::log10, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sinf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sin, ::sin, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cosf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cos, ::cos, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tanf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tan, ::tan, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asinf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asin, ::asin, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acosf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acos, ::acos, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atanf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atan, ::atan, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(sinh, ::sinh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::coshf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(cosh, ::cosh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(tanh, ::tanh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(asinh, ::asinh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acoshf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(acosh, ::acosh, double, double) + +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, char, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, short, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, int, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanhf, float, float) +CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC(atanh, ::atanh, double, double) + +#undef CV_CUDEV_IMPLEMENT_VEC_UNARY_FUNC + +// binary operators (vec & vec) + +#define CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(op, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 operator op(const input_type ## 1 & a, const input_type ## 1 & b) \ + { \ + return VecTraits::make(a.x op b.x); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(const input_type ## 2 & a, const input_type ## 2 & b) \ + { \ + return VecTraits::make(a.x op b.x, a.y op b.y); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(const input_type ## 3 & a, const input_type ## 3 & b) \ + { \ + return VecTraits::make(a.x op b.x, a.y op b.y, a.z op b.z); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(const input_type ## 4 & a, const input_type ## 4 & b) \ + { \ + return VecTraits::make(a.x op b.x, a.y op b.y, a.z op b.z, a.w op b.w); \ + } + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(+, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(-, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(*, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, uchar, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, char, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, ushort, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, short, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(/, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(==, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(!=, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(>=, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(<=, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&&, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, char, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, ushort, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, short, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, int, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, uint, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, float, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(||, double, uchar) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(&, uint, uint) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(|, uint, uint) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_OP(^, uint, uint) + +#undef CV_CUDEV_IMPLEMENT_VEC_BINARY_OP + +// binary operators (vec & scalar) + +#define CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(op, input_type, scalar_type, output_type) \ + __device__ __forceinline__ output_type ## 1 operator op(const input_type ## 1 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s); \ + } \ + __device__ __forceinline__ output_type ## 1 operator op(scalar_type s, const input_type ## 1 & b) \ + { \ + return VecTraits::make(s op b.x); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(const input_type ## 2 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s, a.y op s); \ + } \ + __device__ __forceinline__ output_type ## 2 operator op(scalar_type s, const input_type ## 2 & b) \ + { \ + return VecTraits::make(s op b.x, s op b.y); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(const input_type ## 3 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s, a.y op s, a.z op s); \ + } \ + __device__ __forceinline__ output_type ## 3 operator op(scalar_type s, const input_type ## 3 & b) \ + { \ + return VecTraits::make(s op b.x, s op b.y, s op b.z); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(const input_type ## 4 & a, scalar_type s) \ + { \ + return VecTraits::make(a.x op s, a.y op s, a.z op s, a.w op s); \ + } \ + __device__ __forceinline__ output_type ## 4 operator op(scalar_type s, const input_type ## 4 & b) \ + { \ + return VecTraits::make(s op b.x, s op b.y, s op b.z, s op b.w); \ + } + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(+, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(-, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(*, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uchar, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, char, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, ushort, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, short, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(/, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(==, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(!=, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(>=, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(<=, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&&, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, char, char, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, ushort, ushort, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, short, short, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, int, int, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, uint, uint, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, float, float, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(||, double, double, uchar) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(&, uint, uint, uint) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(|, uint, uint, uint) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP(^, uint, uint, uint) + +#undef CV_CUDEV_IMPLEMENT_SCALAR_BINARY_OP + +// binary function (vec & vec) + +#define CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(func_name, func, input_type, output_type) \ + __device__ __forceinline__ output_type ## 1 func_name(const input_type ## 1 & a, const input_type ## 1 & b) \ + { \ + return VecTraits::make(func (a.x, b.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(const input_type ## 2 & a, const input_type ## 2 & b) \ + { \ + return VecTraits::make(func (a.x, b.x), func (a.y, b.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(const input_type ## 3 & a, const input_type ## 3 & b) \ + { \ + return VecTraits::make(func (a.x, b.x), func (a.y, b.y), func (a.z, b.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(const input_type ## 4 & a, const input_type ## 4 & b) \ + { \ + return VecTraits::make(func (a.x, b.x), func (a.y, b.y), func (a.z, b.z), func (a.w, b.w)); \ + } + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::max, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::fmaxf, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(max, ::fmax, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, uchar, uchar) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, char, char) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, ushort, ushort) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, short, short) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, uint, uint) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::min, int, int) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::fminf, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(min, ::fmin, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, char, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, short, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, uint, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, int, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypotf, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(hypot, ::hypot, double, double) + +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, uchar, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, char, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, ushort, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, short, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, uint, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, int, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2f, float, float) +CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC(atan2, ::atan2, double, double) + +#undef CV_CUDEV_IMPLEMENT_VEC_BINARY_FUNC + +// binary function (vec & scalar) + +#define CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(func_name, func, input_type, scalar_type, output_type) \ + __device__ __forceinline__ output_type ## 1 func_name(const input_type ## 1 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 1 func_name(scalar_type s, const input_type ## 1 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(const input_type ## 2 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s), func ((output_type) a.y, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 2 func_name(scalar_type s, const input_type ## 2 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x), func ((output_type) s, (output_type) b.y)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(const input_type ## 3 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s), func ((output_type) a.y, (output_type) s), func ((output_type) a.z, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 3 func_name(scalar_type s, const input_type ## 3 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x), func ((output_type) s, (output_type) b.y), func ((output_type) s, (output_type) b.z)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(const input_type ## 4 & a, scalar_type s) \ + { \ + return VecTraits::make(func ((output_type) a.x, (output_type) s), func ((output_type) a.y, (output_type) s), func ((output_type) a.z, (output_type) s), func ((output_type) a.w, (output_type) s)); \ + } \ + __device__ __forceinline__ output_type ## 4 func_name(scalar_type s, const input_type ## 4 & b) \ + { \ + return VecTraits::make(func ((output_type) s, (output_type) b.x), func ((output_type) s, (output_type) b.y), func ((output_type) s, (output_type) b.z), func ((output_type) s, (output_type) b.w)); \ + } + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::max, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmaxf, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(max, ::fmax, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, uchar, uchar, uchar) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, char, char, char) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, ushort, ushort, ushort) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, short, short, short) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, uint, uint, uint) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::min, int, int, int) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fminf, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(min, ::fmin, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypotf, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(hypot, ::hypot, double, double, double) + +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, uchar, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, uchar, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, char, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, char, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, ushort, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, ushort, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, short, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, short, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, uint, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, uint, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, int, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, int, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2f, float, float, float) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, float, double, double) +CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC(atan2, ::atan2, double, double, double) + +#undef CV_CUDEV_IMPLEMENT_SCALAR_BINARY_FUNC + +}}} // namespace cv { namespace cuda { namespace device + +//! @endcond + +#endif // OPENCV_CUDA_VECMATH_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_traits.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_traits.hpp new file mode 100644 index 0000000..b5ff281 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/vec_traits.hpp @@ -0,0 +1,288 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_VEC_TRAITS_HPP +#define OPENCV_CUDA_VEC_TRAITS_HPP + +#include "common.hpp" + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template struct TypeVec; + + struct __align__(8) uchar8 + { + uchar a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ uchar8 make_uchar8(uchar a0, uchar a1, uchar a2, uchar a3, uchar a4, uchar a5, uchar a6, uchar a7) + { + uchar8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(8) char8 + { + schar a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ char8 make_char8(schar a0, schar a1, schar a2, schar a3, schar a4, schar a5, schar a6, schar a7) + { + char8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(16) ushort8 + { + ushort a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ ushort8 make_ushort8(ushort a0, ushort a1, ushort a2, ushort a3, ushort a4, ushort a5, ushort a6, ushort a7) + { + ushort8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(16) short8 + { + short a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ short8 make_short8(short a0, short a1, short a2, short a3, short a4, short a5, short a6, short a7) + { + short8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(32) uint8 + { + uint a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ uint8 make_uint8(uint a0, uint a1, uint a2, uint a3, uint a4, uint a5, uint a6, uint a7) + { + uint8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(32) int8 + { + int a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ int8 make_int8(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { + int8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct __align__(32) float8 + { + float a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ float8 make_float8(float a0, float a1, float a2, float a3, float a4, float a5, float a6, float a7) + { + float8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + struct double8 + { + double a0, a1, a2, a3, a4, a5, a6, a7; + }; + static __host__ __device__ __forceinline__ double8 make_double8(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7) + { + double8 val = {a0, a1, a2, a3, a4, a5, a6, a7}; + return val; + } + +#define OPENCV_CUDA_IMPLEMENT_TYPE_VEC(type) \ + template<> struct TypeVec { typedef type vec_type; }; \ + template<> struct TypeVec { typedef type ## 1 vec_type; }; \ + template<> struct TypeVec { typedef type ## 2 vec_type; }; \ + template<> struct TypeVec { typedef type ## 2 vec_type; }; \ + template<> struct TypeVec { typedef type ## 3 vec_type; }; \ + template<> struct TypeVec { typedef type ## 3 vec_type; }; \ + template<> struct TypeVec { typedef type ## 4 vec_type; }; \ + template<> struct TypeVec { typedef type ## 4 vec_type; }; \ + template<> struct TypeVec { typedef type ## 8 vec_type; }; \ + template<> struct TypeVec { typedef type ## 8 vec_type; }; + + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(uchar) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(char) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(ushort) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(short) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(int) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(uint) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(float) + OPENCV_CUDA_IMPLEMENT_TYPE_VEC(double) + + #undef OPENCV_CUDA_IMPLEMENT_TYPE_VEC + + template<> struct TypeVec { typedef schar vec_type; }; + template<> struct TypeVec { typedef char2 vec_type; }; + template<> struct TypeVec { typedef char3 vec_type; }; + template<> struct TypeVec { typedef char4 vec_type; }; + template<> struct TypeVec { typedef char8 vec_type; }; + + template<> struct TypeVec { typedef uchar vec_type; }; + template<> struct TypeVec { typedef uchar2 vec_type; }; + template<> struct TypeVec { typedef uchar3 vec_type; }; + template<> struct TypeVec { typedef uchar4 vec_type; }; + template<> struct TypeVec { typedef uchar8 vec_type; }; + + template struct VecTraits; + +#define OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(type) \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=1}; \ + static __device__ __host__ __forceinline__ type all(type v) {return v;} \ + static __device__ __host__ __forceinline__ type make(type x) {return x;} \ + static __device__ __host__ __forceinline__ type make(const type* v) {return *v;} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=1}; \ + static __device__ __host__ __forceinline__ type ## 1 all(type v) {return make_ ## type ## 1(v);} \ + static __device__ __host__ __forceinline__ type ## 1 make(type x) {return make_ ## type ## 1(x);} \ + static __device__ __host__ __forceinline__ type ## 1 make(const type* v) {return make_ ## type ## 1(*v);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=2}; \ + static __device__ __host__ __forceinline__ type ## 2 all(type v) {return make_ ## type ## 2(v, v);} \ + static __device__ __host__ __forceinline__ type ## 2 make(type x, type y) {return make_ ## type ## 2(x, y);} \ + static __device__ __host__ __forceinline__ type ## 2 make(const type* v) {return make_ ## type ## 2(v[0], v[1]);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=3}; \ + static __device__ __host__ __forceinline__ type ## 3 all(type v) {return make_ ## type ## 3(v, v, v);} \ + static __device__ __host__ __forceinline__ type ## 3 make(type x, type y, type z) {return make_ ## type ## 3(x, y, z);} \ + static __device__ __host__ __forceinline__ type ## 3 make(const type* v) {return make_ ## type ## 3(v[0], v[1], v[2]);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=4}; \ + static __device__ __host__ __forceinline__ type ## 4 all(type v) {return make_ ## type ## 4(v, v, v, v);} \ + static __device__ __host__ __forceinline__ type ## 4 make(type x, type y, type z, type w) {return make_ ## type ## 4(x, y, z, w);} \ + static __device__ __host__ __forceinline__ type ## 4 make(const type* v) {return make_ ## type ## 4(v[0], v[1], v[2], v[3]);} \ + }; \ + template<> struct VecTraits \ + { \ + typedef type elem_type; \ + enum {cn=8}; \ + static __device__ __host__ __forceinline__ type ## 8 all(type v) {return make_ ## type ## 8(v, v, v, v, v, v, v, v);} \ + static __device__ __host__ __forceinline__ type ## 8 make(type a0, type a1, type a2, type a3, type a4, type a5, type a6, type a7) {return make_ ## type ## 8(a0, a1, a2, a3, a4, a5, a6, a7);} \ + static __device__ __host__ __forceinline__ type ## 8 make(const type* v) {return make_ ## type ## 8(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);} \ + }; + + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(uchar) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(ushort) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(short) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(int) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(uint) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(float) + OPENCV_CUDA_IMPLEMENT_VEC_TRAITS(double) + + #undef OPENCV_CUDA_IMPLEMENT_VEC_TRAITS + + template<> struct VecTraits + { + typedef char elem_type; + enum {cn=1}; + static __device__ __host__ __forceinline__ char all(char v) {return v;} + static __device__ __host__ __forceinline__ char make(char x) {return x;} + static __device__ __host__ __forceinline__ char make(const char* x) {return *x;} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=1}; + static __device__ __host__ __forceinline__ schar all(schar v) {return v;} + static __device__ __host__ __forceinline__ schar make(schar x) {return x;} + static __device__ __host__ __forceinline__ schar make(const schar* x) {return *x;} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=1}; + static __device__ __host__ __forceinline__ char1 all(schar v) {return make_char1(v);} + static __device__ __host__ __forceinline__ char1 make(schar x) {return make_char1(x);} + static __device__ __host__ __forceinline__ char1 make(const schar* v) {return make_char1(v[0]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=2}; + static __device__ __host__ __forceinline__ char2 all(schar v) {return make_char2(v, v);} + static __device__ __host__ __forceinline__ char2 make(schar x, schar y) {return make_char2(x, y);} + static __device__ __host__ __forceinline__ char2 make(const schar* v) {return make_char2(v[0], v[1]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=3}; + static __device__ __host__ __forceinline__ char3 all(schar v) {return make_char3(v, v, v);} + static __device__ __host__ __forceinline__ char3 make(schar x, schar y, schar z) {return make_char3(x, y, z);} + static __device__ __host__ __forceinline__ char3 make(const schar* v) {return make_char3(v[0], v[1], v[2]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=4}; + static __device__ __host__ __forceinline__ char4 all(schar v) {return make_char4(v, v, v, v);} + static __device__ __host__ __forceinline__ char4 make(schar x, schar y, schar z, schar w) {return make_char4(x, y, z, w);} + static __device__ __host__ __forceinline__ char4 make(const schar* v) {return make_char4(v[0], v[1], v[2], v[3]);} + }; + template<> struct VecTraits + { + typedef schar elem_type; + enum {cn=8}; + static __device__ __host__ __forceinline__ char8 all(schar v) {return make_char8(v, v, v, v, v, v, v, v);} + static __device__ __host__ __forceinline__ char8 make(schar a0, schar a1, schar a2, schar a3, schar a4, schar a5, schar a6, schar a7) {return make_char8(a0, a1, a2, a3, a4, a5, a6, a7);} + static __device__ __host__ __forceinline__ char8 make(const schar* v) {return make_char8(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);} + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif // OPENCV_CUDA_VEC_TRAITS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp.hpp new file mode 100644 index 0000000..8af7e6a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp.hpp @@ -0,0 +1,139 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_DEVICE_WARP_HPP +#define OPENCV_CUDA_DEVICE_WARP_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + struct Warp + { + enum + { + LOG_WARP_SIZE = 5, + WARP_SIZE = 1 << LOG_WARP_SIZE, + STRIDE = WARP_SIZE + }; + + /** \brief Returns the warp lane ID of the calling thread. */ + static __device__ __forceinline__ unsigned int laneId() + { + unsigned int ret; + asm("mov.u32 %0, %%laneid;" : "=r"(ret) ); + return ret; + } + + template + static __device__ __forceinline__ void fill(It beg, It end, const T& value) + { + for(It t = beg + laneId(); t < end; t += STRIDE) + *t = value; + } + + template + static __device__ __forceinline__ OutIt copy(InIt beg, InIt end, OutIt out) + { + for(InIt t = beg + laneId(); t < end; t += STRIDE, out += STRIDE) + *out = *t; + return out; + } + + template + static __device__ __forceinline__ OutIt transform(InIt beg, InIt end, OutIt out, UnOp op) + { + for(InIt t = beg + laneId(); t < end; t += STRIDE, out += STRIDE) + *out = op(*t); + return out; + } + + template + static __device__ __forceinline__ OutIt transform(InIt1 beg1, InIt1 end1, InIt2 beg2, OutIt out, BinOp op) + { + unsigned int lane = laneId(); + + InIt1 t1 = beg1 + lane; + InIt2 t2 = beg2 + lane; + for(; t1 < end1; t1 += STRIDE, t2 += STRIDE, out += STRIDE) + *out = op(*t1, *t2); + return out; + } + + template + static __device__ __forceinline__ T reduce(volatile T *ptr, BinOp op) + { + const unsigned int lane = laneId(); + + if (lane < 16) + { + T partial = ptr[lane]; + + ptr[lane] = partial = op(partial, ptr[lane + 16]); + ptr[lane] = partial = op(partial, ptr[lane + 8]); + ptr[lane] = partial = op(partial, ptr[lane + 4]); + ptr[lane] = partial = op(partial, ptr[lane + 2]); + ptr[lane] = partial = op(partial, ptr[lane + 1]); + } + + return *ptr; + } + + template + static __device__ __forceinline__ void yota(OutIt beg, OutIt end, T value) + { + unsigned int lane = laneId(); + value += lane; + + for(OutIt t = beg + lane; t < end; t += STRIDE, value += STRIDE) + *t = value; + } + }; +}}} // namespace cv { namespace cuda { namespace cudev + +//! @endcond + +#endif /* OPENCV_CUDA_DEVICE_WARP_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp_reduce.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp_reduce.hpp new file mode 100644 index 0000000..530303d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp_reduce.hpp @@ -0,0 +1,76 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_WARP_REDUCE_HPP__ +#define OPENCV_CUDA_WARP_REDUCE_HPP__ + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ + template + __device__ __forceinline__ T warp_reduce(volatile T *ptr , const unsigned int tid = threadIdx.x) + { + const unsigned int lane = tid & 31; // index of thread in warp (0..31) + + if (lane < 16) + { + T partial = ptr[tid]; + + ptr[tid] = partial = partial + ptr[tid + 16]; + ptr[tid] = partial = partial + ptr[tid + 8]; + ptr[tid] = partial = partial + ptr[tid + 4]; + ptr[tid] = partial = partial + ptr[tid + 2]; + ptr[tid] = partial = partial + ptr[tid + 1]; + } + + return ptr[tid - lane]; + } +}}} // namespace cv { namespace cuda { namespace cudev { + +//! @endcond + +#endif /* OPENCV_CUDA_WARP_REDUCE_HPP__ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp_shuffle.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp_shuffle.hpp new file mode 100644 index 0000000..0da54ae --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda/warp_shuffle.hpp @@ -0,0 +1,162 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CUDA_WARP_SHUFFLE_HPP +#define OPENCV_CUDA_WARP_SHUFFLE_HPP + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +namespace cv { namespace cuda { namespace device +{ +#if __CUDACC_VER_MAJOR__ >= 9 +# define __shfl(x, y, z) __shfl_sync(0xFFFFFFFFU, x, y, z) +# define __shfl_up(x, y, z) __shfl_up_sync(0xFFFFFFFFU, x, y, z) +# define __shfl_down(x, y, z) __shfl_down_sync(0xFFFFFFFFU, x, y, z) +#endif + template + __device__ __forceinline__ T shfl(T val, int srcLane, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return __shfl(val, srcLane, width); + #else + return T(); + #endif + } + __device__ __forceinline__ unsigned int shfl(unsigned int val, int srcLane, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return (unsigned int) __shfl((int) val, srcLane, width); + #else + return 0; + #endif + } + __device__ __forceinline__ double shfl(double val, int srcLane, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + int lo = __double2loint(val); + int hi = __double2hiint(val); + + lo = __shfl(lo, srcLane, width); + hi = __shfl(hi, srcLane, width); + + return __hiloint2double(hi, lo); + #else + return 0.0; + #endif + } + + template + __device__ __forceinline__ T shfl_down(T val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return __shfl_down(val, delta, width); + #else + return T(); + #endif + } + __device__ __forceinline__ unsigned int shfl_down(unsigned int val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return (unsigned int) __shfl_down((int) val, delta, width); + #else + return 0; + #endif + } + __device__ __forceinline__ double shfl_down(double val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + int lo = __double2loint(val); + int hi = __double2hiint(val); + + lo = __shfl_down(lo, delta, width); + hi = __shfl_down(hi, delta, width); + + return __hiloint2double(hi, lo); + #else + return 0.0; + #endif + } + + template + __device__ __forceinline__ T shfl_up(T val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return __shfl_up(val, delta, width); + #else + return T(); + #endif + } + __device__ __forceinline__ unsigned int shfl_up(unsigned int val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + return (unsigned int) __shfl_up((int) val, delta, width); + #else + return 0; + #endif + } + __device__ __forceinline__ double shfl_up(double val, unsigned int delta, int width = warpSize) + { + #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300 + int lo = __double2loint(val); + int hi = __double2hiint(val); + + lo = __shfl_up(lo, delta, width); + hi = __shfl_up(hi, delta, width); + + return __hiloint2double(hi, lo); + #else + return 0.0; + #endif + } +}}} + +# undef __shfl +# undef __shfl_up +# undef __shfl_down + +//! @endcond + +#endif // OPENCV_CUDA_WARP_SHUFFLE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda_stream_accessor.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda_stream_accessor.hpp new file mode 100644 index 0000000..deaf356 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda_stream_accessor.hpp @@ -0,0 +1,86 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP +#define OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP + +#ifndef __cplusplus +# error cuda_stream_accessor.hpp header must be compiled as C++ +#endif + +/** @file cuda_stream_accessor.hpp + * This is only header file that depends on CUDA Runtime API. All other headers are independent. + */ + +#include +#include "opencv2/core/cuda.hpp" + +namespace cv +{ + namespace cuda + { + +//! @addtogroup cudacore_struct +//! @{ + + /** @brief Class that enables getting cudaStream_t from cuda::Stream + */ + struct StreamAccessor + { + CV_EXPORTS static cudaStream_t getStream(const Stream& stream); + CV_EXPORTS static Stream wrapStream(cudaStream_t stream); + }; + + /** @brief Class that enables getting cudaEvent_t from cuda::Event + */ + struct EventAccessor + { + CV_EXPORTS static cudaEvent_t getEvent(const Event& event); + CV_EXPORTS static Event wrapEvent(cudaEvent_t event); + }; + +//! @} + + } +} + +#endif /* OPENCV_CORE_CUDA_STREAM_ACCESSOR_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda_types.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda_types.hpp new file mode 100644 index 0000000..b33f061 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cuda_types.hpp @@ -0,0 +1,144 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CUDA_TYPES_HPP +#define OPENCV_CORE_CUDA_TYPES_HPP + +#ifndef __cplusplus +# error cuda_types.hpp header must be compiled as C++ +#endif + +#if defined(__OPENCV_BUILD) && defined(__clang__) +#pragma clang diagnostic ignored "-Winconsistent-missing-override" +#endif +#if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic ignored "-Wsuggest-override" +#endif + +/** @file + * @deprecated Use @ref cudev instead. + */ + +//! @cond IGNORED + +#ifdef __CUDACC__ + #define __CV_CUDA_HOST_DEVICE__ __host__ __device__ __forceinline__ +#else + #define __CV_CUDA_HOST_DEVICE__ +#endif + +namespace cv +{ + namespace cuda + { + + // Simple lightweight structures that encapsulates information about an image on device. + // It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile + + template struct DevPtr + { + typedef T elem_type; + typedef int index_type; + + enum { elem_size = sizeof(elem_type) }; + + T* data; + + __CV_CUDA_HOST_DEVICE__ DevPtr() : data(0) {} + __CV_CUDA_HOST_DEVICE__ DevPtr(T* data_) : data(data_) {} + + __CV_CUDA_HOST_DEVICE__ size_t elemSize() const { return elem_size; } + __CV_CUDA_HOST_DEVICE__ operator T*() { return data; } + __CV_CUDA_HOST_DEVICE__ operator const T*() const { return data; } + }; + + template struct PtrSz : public DevPtr + { + __CV_CUDA_HOST_DEVICE__ PtrSz() : size(0) {} + __CV_CUDA_HOST_DEVICE__ PtrSz(T* data_, size_t size_) : DevPtr(data_), size(size_) {} + + size_t size; + }; + + template struct PtrStep : public DevPtr + { + __CV_CUDA_HOST_DEVICE__ PtrStep() : step(0) {} + __CV_CUDA_HOST_DEVICE__ PtrStep(T* data_, size_t step_) : DevPtr(data_), step(step_) {} + + size_t step; + + __CV_CUDA_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)(((DevPtr*)this)->data) + y * step); } + __CV_CUDA_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)(((DevPtr*)this)->data) + y * step); } + + __CV_CUDA_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; } + __CV_CUDA_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; } + }; + + template struct PtrStepSz : public PtrStep + { + __CV_CUDA_HOST_DEVICE__ PtrStepSz() : cols(0), rows(0) {} + __CV_CUDA_HOST_DEVICE__ PtrStepSz(int rows_, int cols_, T* data_, size_t step_) + : PtrStep(data_, step_), cols(cols_), rows(rows_) {} + + template + explicit PtrStepSz(const PtrStepSz& d) : PtrStep((T*)d.data, d.step), cols(d.cols), rows(d.rows){} + + int cols; + int rows; + }; + + typedef PtrStepSz PtrStepSzb; + typedef PtrStepSz PtrStepSzus; + typedef PtrStepSz PtrStepSzf; + typedef PtrStepSz PtrStepSzi; + + typedef PtrStep PtrStepb; + typedef PtrStep PtrStepus; + typedef PtrStep PtrStepf; + typedef PtrStep PtrStepi; + + } +} + +//! @endcond + +#endif /* OPENCV_CORE_CUDA_TYPES_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cv_cpu_dispatch.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cv_cpu_dispatch.h new file mode 100644 index 0000000..ab5a67d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cv_cpu_dispatch.h @@ -0,0 +1,368 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#if defined __OPENCV_BUILD \ + +#include "cv_cpu_config.h" +#include "cv_cpu_helper.h" + +#ifdef CV_CPU_DISPATCH_MODE +#define CV_CPU_OPTIMIZATION_NAMESPACE __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) +#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) { +#define CV_CPU_OPTIMIZATION_NAMESPACE_END } +#else +#define CV_CPU_OPTIMIZATION_NAMESPACE cpu_baseline +#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace cpu_baseline { +#define CV_CPU_OPTIMIZATION_NAMESPACE_END } +#define CV_CPU_BASELINE_MODE 1 +#endif + + +#define __CV_CPU_DISPATCH_CHAIN_END(fn, args, mode, ...) /* done */ +#define __CV_CPU_DISPATCH(fn, args, mode, ...) __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) +#define __CV_CPU_DISPATCH_EXPAND(fn, args, ...) __CV_EXPAND(__CV_CPU_DISPATCH(fn, args, __VA_ARGS__)) +#define CV_CPU_DISPATCH(fn, args, ...) __CV_CPU_DISPATCH_EXPAND(fn, args, __VA_ARGS__, END) // expand macros + + +#if defined CV_ENABLE_INTRINSICS \ + && !defined CV_DISABLE_OPTIMIZATION \ + && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ \ + +#ifdef CV_CPU_COMPILE_SSE2 +# include +# define CV_MMX 1 +# define CV_SSE 1 +# define CV_SSE2 1 +#endif +#ifdef CV_CPU_COMPILE_SSE3 +# include +# define CV_SSE3 1 +#endif +#ifdef CV_CPU_COMPILE_SSSE3 +# include +# define CV_SSSE3 1 +#endif +#ifdef CV_CPU_COMPILE_SSE4_1 +# include +# define CV_SSE4_1 1 +#endif +#ifdef CV_CPU_COMPILE_SSE4_2 +# include +# define CV_SSE4_2 1 +#endif +#ifdef CV_CPU_COMPILE_POPCNT +# ifdef _MSC_VER +# include +# if defined(_M_X64) +# define CV_POPCNT_U64 (int)_mm_popcnt_u64 +# endif +# define CV_POPCNT_U32 _mm_popcnt_u32 +# else +# include +# if defined(__x86_64__) +# define CV_POPCNT_U64 __builtin_popcountll +# endif +# define CV_POPCNT_U32 __builtin_popcount +# endif +# define CV_POPCNT 1 +#endif +#ifdef CV_CPU_COMPILE_AVX +# include +# define CV_AVX 1 +#endif +#ifdef CV_CPU_COMPILE_FP16 +# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64) +# include +# else +# include +# endif +# define CV_FP16 1 +#endif +#ifdef CV_CPU_COMPILE_AVX2 +# include +# define CV_AVX2 1 +#endif +#ifdef CV_CPU_COMPILE_AVX_512F +# include +# define CV_AVX_512F 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_COMMON +# define CV_AVX512_COMMON 1 +# define CV_AVX_512CD 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_KNL +# define CV_AVX512_KNL 1 +# define CV_AVX_512ER 1 +# define CV_AVX_512PF 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_KNM +# define CV_AVX512_KNM 1 +# define CV_AVX_5124FMAPS 1 +# define CV_AVX_5124VNNIW 1 +# define CV_AVX_512VPOPCNTDQ 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_SKX +# define CV_AVX512_SKX 1 +# define CV_AVX_512VL 1 +# define CV_AVX_512BW 1 +# define CV_AVX_512DQ 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_CNL +# define CV_AVX512_CNL 1 +# define CV_AVX_512IFMA 1 +# define CV_AVX_512VBMI 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_CLX +# define CV_AVX512_CLX 1 +# define CV_AVX_512VNNI 1 +#endif +#ifdef CV_CPU_COMPILE_AVX512_ICL +# define CV_AVX512_ICL 1 +# undef CV_AVX_512IFMA +# define CV_AVX_512IFMA 1 +# undef CV_AVX_512VBMI +# define CV_AVX_512VBMI 1 +# undef CV_AVX_512VNNI +# define CV_AVX_512VNNI 1 +# define CV_AVX_512VBMI2 1 +# define CV_AVX_512BITALG 1 +# define CV_AVX_512VPOPCNTDQ 1 +#endif +#ifdef CV_CPU_COMPILE_FMA3 +# define CV_FMA3 1 +#endif + +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) +# include +# include +# define CV_NEON 1 +#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__)) +# include +# define CV_NEON 1 +#endif + +#if defined(__riscv) && defined(__riscv_vector) && defined(__riscv_vector_071) +# include +# define CV_RVV071 1 +#endif + +#if defined(__ARM_NEON__) || defined(__aarch64__) +# include +#endif + +#ifdef CV_CPU_COMPILE_VSX +# include +# undef vector +# undef pixel +# undef bool +# define CV_VSX 1 +#endif + +#ifdef CV_CPU_COMPILE_VSX3 +# define CV_VSX3 1 +#endif + +#ifdef CV_CPU_COMPILE_MSA +# include "hal/msa_macros.h" +# define CV_MSA 1 +#endif + +#ifdef __EMSCRIPTEN__ +# define CV_WASM_SIMD 1 +# include +#endif + +#if defined CV_CPU_COMPILE_RVV +# define CV_RVV 1 +# include +#endif + +#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__ + +#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX +struct VZeroUpperGuard { +#ifdef __GNUC__ + __attribute__((always_inline)) +#endif + inline VZeroUpperGuard() { _mm256_zeroupper(); } +#ifdef __GNUC__ + __attribute__((always_inline)) +#endif + inline ~VZeroUpperGuard() { _mm256_zeroupper(); } +}; +#define __CV_AVX_GUARD VZeroUpperGuard __vzeroupper_guard; CV_UNUSED(__vzeroupper_guard); +#endif + +#ifdef __CV_AVX_GUARD +#define CV_AVX_GUARD __CV_AVX_GUARD +#else +#define CV_AVX_GUARD +#endif + +#endif // __OPENCV_BUILD + + + +#if !defined __OPENCV_BUILD /* Compatibility code */ \ + && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ +#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) +# include +# define CV_MMX 1 +# define CV_SSE 1 +# define CV_SSE2 1 +#elif defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) && (defined(CV_CPU_COMPILE_NEON) || !defined(_MSC_VER)) +# include +# include +# define CV_NEON 1 +#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__)) +# include +# define CV_NEON 1 +#elif defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__) +# include +# undef vector +# undef pixel +# undef bool +# define CV_VSX 1 +#endif + +#ifdef __F16C__ +# include +# define CV_FP16 1 +#endif + +#endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code) + + + +#ifndef CV_MMX +# define CV_MMX 0 +#endif +#ifndef CV_SSE +# define CV_SSE 0 +#endif +#ifndef CV_SSE2 +# define CV_SSE2 0 +#endif +#ifndef CV_SSE3 +# define CV_SSE3 0 +#endif +#ifndef CV_SSSE3 +# define CV_SSSE3 0 +#endif +#ifndef CV_SSE4_1 +# define CV_SSE4_1 0 +#endif +#ifndef CV_SSE4_2 +# define CV_SSE4_2 0 +#endif +#ifndef CV_POPCNT +# define CV_POPCNT 0 +#endif +#ifndef CV_AVX +# define CV_AVX 0 +#endif +#ifndef CV_FP16 +# define CV_FP16 0 +#endif +#ifndef CV_AVX2 +# define CV_AVX2 0 +#endif +#ifndef CV_FMA3 +# define CV_FMA3 0 +#endif +#ifndef CV_AVX_512F +# define CV_AVX_512F 0 +#endif +#ifndef CV_AVX_512BW +# define CV_AVX_512BW 0 +#endif +#ifndef CV_AVX_512CD +# define CV_AVX_512CD 0 +#endif +#ifndef CV_AVX_512DQ +# define CV_AVX_512DQ 0 +#endif +#ifndef CV_AVX_512ER +# define CV_AVX_512ER 0 +#endif +#ifndef CV_AVX_512IFMA +# define CV_AVX_512IFMA 0 +#endif +#define CV_AVX_512IFMA512 CV_AVX_512IFMA // deprecated +#ifndef CV_AVX_512PF +# define CV_AVX_512PF 0 +#endif +#ifndef CV_AVX_512VBMI +# define CV_AVX_512VBMI 0 +#endif +#ifndef CV_AVX_512VL +# define CV_AVX_512VL 0 +#endif +#ifndef CV_AVX_5124FMAPS +# define CV_AVX_5124FMAPS 0 +#endif +#ifndef CV_AVX_5124VNNIW +# define CV_AVX_5124VNNIW 0 +#endif +#ifndef CV_AVX_512VPOPCNTDQ +# define CV_AVX_512VPOPCNTDQ 0 +#endif +#ifndef CV_AVX_512VNNI +# define CV_AVX_512VNNI 0 +#endif +#ifndef CV_AVX_512VBMI2 +# define CV_AVX_512VBMI2 0 +#endif +#ifndef CV_AVX_512BITALG +# define CV_AVX_512BITALG 0 +#endif +#ifndef CV_AVX512_COMMON +# define CV_AVX512_COMMON 0 +#endif +#ifndef CV_AVX512_KNL +# define CV_AVX512_KNL 0 +#endif +#ifndef CV_AVX512_KNM +# define CV_AVX512_KNM 0 +#endif +#ifndef CV_AVX512_SKX +# define CV_AVX512_SKX 0 +#endif +#ifndef CV_AVX512_CNL +# define CV_AVX512_CNL 0 +#endif +#ifndef CV_AVX512_CLX +# define CV_AVX512_CLX 0 +#endif +#ifndef CV_AVX512_ICL +# define CV_AVX512_ICL 0 +#endif + +#ifndef CV_NEON +# define CV_NEON 0 +#endif + +#ifndef CV_RVV071 +# define CV_RVV071 0 +#endif + +#ifndef CV_VSX +# define CV_VSX 0 +#endif + +#ifndef CV_VSX3 +# define CV_VSX3 0 +#endif + +#ifndef CV_MSA +# define CV_MSA 0 +#endif + +#ifndef CV_WASM_SIMD +# define CV_WASM_SIMD 0 +#endif + +#ifndef CV_RVV +# define CV_RVV 0 +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cv_cpu_helper.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cv_cpu_helper.h new file mode 100644 index 0000000..39ae0b9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cv_cpu_helper.h @@ -0,0 +1,508 @@ +// AUTOGENERATED, DO NOT EDIT + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE +# define CV_TRY_SSE 1 +# define CV_CPU_FORCE_SSE 1 +# define CV_CPU_HAS_SUPPORT_SSE 1 +# define CV_CPU_CALL_SSE(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE_(fn, args) return (opt_SSE::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE +# define CV_TRY_SSE 1 +# define CV_CPU_FORCE_SSE 0 +# define CV_CPU_HAS_SUPPORT_SSE (cv::checkHardwareSupport(CV_CPU_SSE)) +# define CV_CPU_CALL_SSE(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args) +# define CV_CPU_CALL_SSE_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args) +#else +# define CV_TRY_SSE 0 +# define CV_CPU_FORCE_SSE 0 +# define CV_CPU_HAS_SUPPORT_SSE 0 +# define CV_CPU_CALL_SSE(fn, args) +# define CV_CPU_CALL_SSE_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE(fn, args, mode, ...) CV_CPU_CALL_SSE(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE2 +# define CV_TRY_SSE2 1 +# define CV_CPU_FORCE_SSE2 1 +# define CV_CPU_HAS_SUPPORT_SSE2 1 +# define CV_CPU_CALL_SSE2(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE2_(fn, args) return (opt_SSE2::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE2 +# define CV_TRY_SSE2 1 +# define CV_CPU_FORCE_SSE2 0 +# define CV_CPU_HAS_SUPPORT_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2)) +# define CV_CPU_CALL_SSE2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args) +# define CV_CPU_CALL_SSE2_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args) +#else +# define CV_TRY_SSE2 0 +# define CV_CPU_FORCE_SSE2 0 +# define CV_CPU_HAS_SUPPORT_SSE2 0 +# define CV_CPU_CALL_SSE2(fn, args) +# define CV_CPU_CALL_SSE2_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE2(fn, args, mode, ...) CV_CPU_CALL_SSE2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE3 +# define CV_TRY_SSE3 1 +# define CV_CPU_FORCE_SSE3 1 +# define CV_CPU_HAS_SUPPORT_SSE3 1 +# define CV_CPU_CALL_SSE3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE3_(fn, args) return (opt_SSE3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE3 +# define CV_TRY_SSE3 1 +# define CV_CPU_FORCE_SSE3 0 +# define CV_CPU_HAS_SUPPORT_SSE3 (cv::checkHardwareSupport(CV_CPU_SSE3)) +# define CV_CPU_CALL_SSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args) +# define CV_CPU_CALL_SSE3_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args) +#else +# define CV_TRY_SSE3 0 +# define CV_CPU_FORCE_SSE3 0 +# define CV_CPU_HAS_SUPPORT_SSE3 0 +# define CV_CPU_CALL_SSE3(fn, args) +# define CV_CPU_CALL_SSE3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE3(fn, args, mode, ...) CV_CPU_CALL_SSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSSE3 +# define CV_TRY_SSSE3 1 +# define CV_CPU_FORCE_SSSE3 1 +# define CV_CPU_HAS_SUPPORT_SSSE3 1 +# define CV_CPU_CALL_SSSE3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSSE3_(fn, args) return (opt_SSSE3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSSE3 +# define CV_TRY_SSSE3 1 +# define CV_CPU_FORCE_SSSE3 0 +# define CV_CPU_HAS_SUPPORT_SSSE3 (cv::checkHardwareSupport(CV_CPU_SSSE3)) +# define CV_CPU_CALL_SSSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args) +# define CV_CPU_CALL_SSSE3_(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args) +#else +# define CV_TRY_SSSE3 0 +# define CV_CPU_FORCE_SSSE3 0 +# define CV_CPU_HAS_SUPPORT_SSSE3 0 +# define CV_CPU_CALL_SSSE3(fn, args) +# define CV_CPU_CALL_SSSE3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSSE3(fn, args, mode, ...) CV_CPU_CALL_SSSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_1 +# define CV_TRY_SSE4_1 1 +# define CV_CPU_FORCE_SSE4_1 1 +# define CV_CPU_HAS_SUPPORT_SSE4_1 1 +# define CV_CPU_CALL_SSE4_1(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE4_1_(fn, args) return (opt_SSE4_1::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_1 +# define CV_TRY_SSE4_1 1 +# define CV_CPU_FORCE_SSE4_1 0 +# define CV_CPU_HAS_SUPPORT_SSE4_1 (cv::checkHardwareSupport(CV_CPU_SSE4_1)) +# define CV_CPU_CALL_SSE4_1(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args) +# define CV_CPU_CALL_SSE4_1_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args) +#else +# define CV_TRY_SSE4_1 0 +# define CV_CPU_FORCE_SSE4_1 0 +# define CV_CPU_HAS_SUPPORT_SSE4_1 0 +# define CV_CPU_CALL_SSE4_1(fn, args) +# define CV_CPU_CALL_SSE4_1_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE4_1(fn, args, mode, ...) CV_CPU_CALL_SSE4_1(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_2 +# define CV_TRY_SSE4_2 1 +# define CV_CPU_FORCE_SSE4_2 1 +# define CV_CPU_HAS_SUPPORT_SSE4_2 1 +# define CV_CPU_CALL_SSE4_2(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_SSE4_2_(fn, args) return (opt_SSE4_2::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_2 +# define CV_TRY_SSE4_2 1 +# define CV_CPU_FORCE_SSE4_2 0 +# define CV_CPU_HAS_SUPPORT_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2)) +# define CV_CPU_CALL_SSE4_2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args) +# define CV_CPU_CALL_SSE4_2_(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args) +#else +# define CV_TRY_SSE4_2 0 +# define CV_CPU_FORCE_SSE4_2 0 +# define CV_CPU_HAS_SUPPORT_SSE4_2 0 +# define CV_CPU_CALL_SSE4_2(fn, args) +# define CV_CPU_CALL_SSE4_2_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_SSE4_2(fn, args, mode, ...) CV_CPU_CALL_SSE4_2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_POPCNT +# define CV_TRY_POPCNT 1 +# define CV_CPU_FORCE_POPCNT 1 +# define CV_CPU_HAS_SUPPORT_POPCNT 1 +# define CV_CPU_CALL_POPCNT(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_POPCNT_(fn, args) return (opt_POPCNT::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_POPCNT +# define CV_TRY_POPCNT 1 +# define CV_CPU_FORCE_POPCNT 0 +# define CV_CPU_HAS_SUPPORT_POPCNT (cv::checkHardwareSupport(CV_CPU_POPCNT)) +# define CV_CPU_CALL_POPCNT(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args) +# define CV_CPU_CALL_POPCNT_(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args) +#else +# define CV_TRY_POPCNT 0 +# define CV_CPU_FORCE_POPCNT 0 +# define CV_CPU_HAS_SUPPORT_POPCNT 0 +# define CV_CPU_CALL_POPCNT(fn, args) +# define CV_CPU_CALL_POPCNT_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_POPCNT(fn, args, mode, ...) CV_CPU_CALL_POPCNT(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX +# define CV_TRY_AVX 1 +# define CV_CPU_FORCE_AVX 1 +# define CV_CPU_HAS_SUPPORT_AVX 1 +# define CV_CPU_CALL_AVX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX_(fn, args) return (opt_AVX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX +# define CV_TRY_AVX 1 +# define CV_CPU_FORCE_AVX 0 +# define CV_CPU_HAS_SUPPORT_AVX (cv::checkHardwareSupport(CV_CPU_AVX)) +# define CV_CPU_CALL_AVX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args) +# define CV_CPU_CALL_AVX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args) +#else +# define CV_TRY_AVX 0 +# define CV_CPU_FORCE_AVX 0 +# define CV_CPU_HAS_SUPPORT_AVX 0 +# define CV_CPU_CALL_AVX(fn, args) +# define CV_CPU_CALL_AVX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX(fn, args, mode, ...) CV_CPU_CALL_AVX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FP16 +# define CV_TRY_FP16 1 +# define CV_CPU_FORCE_FP16 1 +# define CV_CPU_HAS_SUPPORT_FP16 1 +# define CV_CPU_CALL_FP16(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_FP16_(fn, args) return (opt_FP16::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FP16 +# define CV_TRY_FP16 1 +# define CV_CPU_FORCE_FP16 0 +# define CV_CPU_HAS_SUPPORT_FP16 (cv::checkHardwareSupport(CV_CPU_FP16)) +# define CV_CPU_CALL_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args) +# define CV_CPU_CALL_FP16_(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args) +#else +# define CV_TRY_FP16 0 +# define CV_CPU_FORCE_FP16 0 +# define CV_CPU_HAS_SUPPORT_FP16 0 +# define CV_CPU_CALL_FP16(fn, args) +# define CV_CPU_CALL_FP16_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_FP16(fn, args, mode, ...) CV_CPU_CALL_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX2 +# define CV_TRY_AVX2 1 +# define CV_CPU_FORCE_AVX2 1 +# define CV_CPU_HAS_SUPPORT_AVX2 1 +# define CV_CPU_CALL_AVX2(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX2_(fn, args) return (opt_AVX2::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX2 +# define CV_TRY_AVX2 1 +# define CV_CPU_FORCE_AVX2 0 +# define CV_CPU_HAS_SUPPORT_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2)) +# define CV_CPU_CALL_AVX2(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args) +# define CV_CPU_CALL_AVX2_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args) +#else +# define CV_TRY_AVX2 0 +# define CV_CPU_FORCE_AVX2 0 +# define CV_CPU_HAS_SUPPORT_AVX2 0 +# define CV_CPU_CALL_AVX2(fn, args) +# define CV_CPU_CALL_AVX2_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX2(fn, args, mode, ...) CV_CPU_CALL_AVX2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FMA3 +# define CV_TRY_FMA3 1 +# define CV_CPU_FORCE_FMA3 1 +# define CV_CPU_HAS_SUPPORT_FMA3 1 +# define CV_CPU_CALL_FMA3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_FMA3_(fn, args) return (opt_FMA3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FMA3 +# define CV_TRY_FMA3 1 +# define CV_CPU_FORCE_FMA3 0 +# define CV_CPU_HAS_SUPPORT_FMA3 (cv::checkHardwareSupport(CV_CPU_FMA3)) +# define CV_CPU_CALL_FMA3(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args) +# define CV_CPU_CALL_FMA3_(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args) +#else +# define CV_TRY_FMA3 0 +# define CV_CPU_FORCE_FMA3 0 +# define CV_CPU_HAS_SUPPORT_FMA3 0 +# define CV_CPU_CALL_FMA3(fn, args) +# define CV_CPU_CALL_FMA3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX_512F +# define CV_TRY_AVX_512F 1 +# define CV_CPU_FORCE_AVX_512F 1 +# define CV_CPU_HAS_SUPPORT_AVX_512F 1 +# define CV_CPU_CALL_AVX_512F(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX_512F_(fn, args) return (opt_AVX_512F::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX_512F +# define CV_TRY_AVX_512F 1 +# define CV_CPU_FORCE_AVX_512F 0 +# define CV_CPU_HAS_SUPPORT_AVX_512F (cv::checkHardwareSupport(CV_CPU_AVX_512F)) +# define CV_CPU_CALL_AVX_512F(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args) +# define CV_CPU_CALL_AVX_512F_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args) +#else +# define CV_TRY_AVX_512F 0 +# define CV_CPU_FORCE_AVX_512F 0 +# define CV_CPU_HAS_SUPPORT_AVX_512F 0 +# define CV_CPU_CALL_AVX_512F(fn, args) +# define CV_CPU_CALL_AVX_512F_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX_512F(fn, args, mode, ...) CV_CPU_CALL_AVX_512F(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_COMMON +# define CV_TRY_AVX512_COMMON 1 +# define CV_CPU_FORCE_AVX512_COMMON 1 +# define CV_CPU_HAS_SUPPORT_AVX512_COMMON 1 +# define CV_CPU_CALL_AVX512_COMMON(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_COMMON_(fn, args) return (opt_AVX512_COMMON::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_COMMON +# define CV_TRY_AVX512_COMMON 1 +# define CV_CPU_FORCE_AVX512_COMMON 0 +# define CV_CPU_HAS_SUPPORT_AVX512_COMMON (cv::checkHardwareSupport(CV_CPU_AVX512_COMMON)) +# define CV_CPU_CALL_AVX512_COMMON(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_COMMON) return (opt_AVX512_COMMON::fn args) +# define CV_CPU_CALL_AVX512_COMMON_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_COMMON) return (opt_AVX512_COMMON::fn args) +#else +# define CV_TRY_AVX512_COMMON 0 +# define CV_CPU_FORCE_AVX512_COMMON 0 +# define CV_CPU_HAS_SUPPORT_AVX512_COMMON 0 +# define CV_CPU_CALL_AVX512_COMMON(fn, args) +# define CV_CPU_CALL_AVX512_COMMON_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_COMMON(fn, args, mode, ...) CV_CPU_CALL_AVX512_COMMON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_KNL +# define CV_TRY_AVX512_KNL 1 +# define CV_CPU_FORCE_AVX512_KNL 1 +# define CV_CPU_HAS_SUPPORT_AVX512_KNL 1 +# define CV_CPU_CALL_AVX512_KNL(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_KNL_(fn, args) return (opt_AVX512_KNL::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_KNL +# define CV_TRY_AVX512_KNL 1 +# define CV_CPU_FORCE_AVX512_KNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNL (cv::checkHardwareSupport(CV_CPU_AVX512_KNL)) +# define CV_CPU_CALL_AVX512_KNL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNL) return (opt_AVX512_KNL::fn args) +# define CV_CPU_CALL_AVX512_KNL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNL) return (opt_AVX512_KNL::fn args) +#else +# define CV_TRY_AVX512_KNL 0 +# define CV_CPU_FORCE_AVX512_KNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNL 0 +# define CV_CPU_CALL_AVX512_KNL(fn, args) +# define CV_CPU_CALL_AVX512_KNL_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_KNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_KNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_KNM +# define CV_TRY_AVX512_KNM 1 +# define CV_CPU_FORCE_AVX512_KNM 1 +# define CV_CPU_HAS_SUPPORT_AVX512_KNM 1 +# define CV_CPU_CALL_AVX512_KNM(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_KNM_(fn, args) return (opt_AVX512_KNM::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_KNM +# define CV_TRY_AVX512_KNM 1 +# define CV_CPU_FORCE_AVX512_KNM 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNM (cv::checkHardwareSupport(CV_CPU_AVX512_KNM)) +# define CV_CPU_CALL_AVX512_KNM(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNM) return (opt_AVX512_KNM::fn args) +# define CV_CPU_CALL_AVX512_KNM_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_KNM) return (opt_AVX512_KNM::fn args) +#else +# define CV_TRY_AVX512_KNM 0 +# define CV_CPU_FORCE_AVX512_KNM 0 +# define CV_CPU_HAS_SUPPORT_AVX512_KNM 0 +# define CV_CPU_CALL_AVX512_KNM(fn, args) +# define CV_CPU_CALL_AVX512_KNM_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_KNM(fn, args, mode, ...) CV_CPU_CALL_AVX512_KNM(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_SKX +# define CV_TRY_AVX512_SKX 1 +# define CV_CPU_FORCE_AVX512_SKX 1 +# define CV_CPU_HAS_SUPPORT_AVX512_SKX 1 +# define CV_CPU_CALL_AVX512_SKX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_SKX_(fn, args) return (opt_AVX512_SKX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_SKX +# define CV_TRY_AVX512_SKX 1 +# define CV_CPU_FORCE_AVX512_SKX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_SKX (cv::checkHardwareSupport(CV_CPU_AVX512_SKX)) +# define CV_CPU_CALL_AVX512_SKX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_SKX) return (opt_AVX512_SKX::fn args) +# define CV_CPU_CALL_AVX512_SKX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_SKX) return (opt_AVX512_SKX::fn args) +#else +# define CV_TRY_AVX512_SKX 0 +# define CV_CPU_FORCE_AVX512_SKX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_SKX 0 +# define CV_CPU_CALL_AVX512_SKX(fn, args) +# define CV_CPU_CALL_AVX512_SKX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_SKX(fn, args, mode, ...) CV_CPU_CALL_AVX512_SKX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CNL +# define CV_TRY_AVX512_CNL 1 +# define CV_CPU_FORCE_AVX512_CNL 1 +# define CV_CPU_HAS_SUPPORT_AVX512_CNL 1 +# define CV_CPU_CALL_AVX512_CNL(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_CNL_(fn, args) return (opt_AVX512_CNL::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CNL +# define CV_TRY_AVX512_CNL 1 +# define CV_CPU_FORCE_AVX512_CNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CNL (cv::checkHardwareSupport(CV_CPU_AVX512_CNL)) +# define CV_CPU_CALL_AVX512_CNL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CNL) return (opt_AVX512_CNL::fn args) +# define CV_CPU_CALL_AVX512_CNL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CNL) return (opt_AVX512_CNL::fn args) +#else +# define CV_TRY_AVX512_CNL 0 +# define CV_CPU_FORCE_AVX512_CNL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CNL 0 +# define CV_CPU_CALL_AVX512_CNL(fn, args) +# define CV_CPU_CALL_AVX512_CNL_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_CNL(fn, args, mode, ...) CV_CPU_CALL_AVX512_CNL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_CLX +# define CV_TRY_AVX512_CLX 1 +# define CV_CPU_FORCE_AVX512_CLX 1 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX 1 +# define CV_CPU_CALL_AVX512_CLX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) return (opt_AVX512_CLX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_CLX +# define CV_TRY_AVX512_CLX 1 +# define CV_CPU_FORCE_AVX512_CLX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX (cv::checkHardwareSupport(CV_CPU_AVX512_CLX)) +# define CV_CPU_CALL_AVX512_CLX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_CLX) return (opt_AVX512_CLX::fn args) +#else +# define CV_TRY_AVX512_CLX 0 +# define CV_CPU_FORCE_AVX512_CLX 0 +# define CV_CPU_HAS_SUPPORT_AVX512_CLX 0 +# define CV_CPU_CALL_AVX512_CLX(fn, args) +# define CV_CPU_CALL_AVX512_CLX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_CLX(fn, args, mode, ...) CV_CPU_CALL_AVX512_CLX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512_ICL +# define CV_TRY_AVX512_ICL 1 +# define CV_CPU_FORCE_AVX512_ICL 1 +# define CV_CPU_HAS_SUPPORT_AVX512_ICL 1 +# define CV_CPU_CALL_AVX512_ICL(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_AVX512_ICL_(fn, args) return (opt_AVX512_ICL::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512_ICL +# define CV_TRY_AVX512_ICL 1 +# define CV_CPU_FORCE_AVX512_ICL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_ICL (cv::checkHardwareSupport(CV_CPU_AVX512_ICL)) +# define CV_CPU_CALL_AVX512_ICL(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_ICL) return (opt_AVX512_ICL::fn args) +# define CV_CPU_CALL_AVX512_ICL_(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512_ICL) return (opt_AVX512_ICL::fn args) +#else +# define CV_TRY_AVX512_ICL 0 +# define CV_CPU_FORCE_AVX512_ICL 0 +# define CV_CPU_HAS_SUPPORT_AVX512_ICL 0 +# define CV_CPU_CALL_AVX512_ICL(fn, args) +# define CV_CPU_CALL_AVX512_ICL_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_AVX512_ICL(fn, args, mode, ...) CV_CPU_CALL_AVX512_ICL(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON +# define CV_TRY_NEON 1 +# define CV_CPU_FORCE_NEON 1 +# define CV_CPU_HAS_SUPPORT_NEON 1 +# define CV_CPU_CALL_NEON(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_NEON_(fn, args) return (opt_NEON::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON +# define CV_TRY_NEON 1 +# define CV_CPU_FORCE_NEON 0 +# define CV_CPU_HAS_SUPPORT_NEON (cv::checkHardwareSupport(CV_CPU_NEON)) +# define CV_CPU_CALL_NEON(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args) +# define CV_CPU_CALL_NEON_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args) +#else +# define CV_TRY_NEON 0 +# define CV_CPU_FORCE_NEON 0 +# define CV_CPU_HAS_SUPPORT_NEON 0 +# define CV_CPU_CALL_NEON(fn, args) +# define CV_CPU_CALL_NEON_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_MSA +# define CV_TRY_MSA 1 +# define CV_CPU_FORCE_MSA 1 +# define CV_CPU_HAS_SUPPORT_MSA 1 +# define CV_CPU_CALL_MSA(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_MSA_(fn, args) return (opt_MSA::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_MSA +# define CV_TRY_MSA 1 +# define CV_CPU_FORCE_MSA 0 +# define CV_CPU_HAS_SUPPORT_MSA (cv::checkHardwareSupport(CV_CPU_MSA)) +# define CV_CPU_CALL_MSA(fn, args) if (CV_CPU_HAS_SUPPORT_MSA) return (opt_MSA::fn args) +# define CV_CPU_CALL_MSA_(fn, args) if (CV_CPU_HAS_SUPPORT_MSA) return (opt_MSA::fn args) +#else +# define CV_TRY_MSA 0 +# define CV_CPU_FORCE_MSA 0 +# define CV_CPU_HAS_SUPPORT_MSA 0 +# define CV_CPU_CALL_MSA(fn, args) +# define CV_CPU_CALL_MSA_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_MSA(fn, args, mode, ...) CV_CPU_CALL_MSA(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX +# define CV_TRY_VSX 1 +# define CV_CPU_FORCE_VSX 1 +# define CV_CPU_HAS_SUPPORT_VSX 1 +# define CV_CPU_CALL_VSX(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_VSX_(fn, args) return (opt_VSX::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX +# define CV_TRY_VSX 1 +# define CV_CPU_FORCE_VSX 0 +# define CV_CPU_HAS_SUPPORT_VSX (cv::checkHardwareSupport(CV_CPU_VSX)) +# define CV_CPU_CALL_VSX(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args) +# define CV_CPU_CALL_VSX_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args) +#else +# define CV_TRY_VSX 0 +# define CV_CPU_FORCE_VSX 0 +# define CV_CPU_HAS_SUPPORT_VSX 0 +# define CV_CPU_CALL_VSX(fn, args) +# define CV_CPU_CALL_VSX_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_VSX(fn, args, mode, ...) CV_CPU_CALL_VSX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX3 +# define CV_TRY_VSX3 1 +# define CV_CPU_FORCE_VSX3 1 +# define CV_CPU_HAS_SUPPORT_VSX3 1 +# define CV_CPU_CALL_VSX3(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_VSX3_(fn, args) return (opt_VSX3::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX3 +# define CV_TRY_VSX3 1 +# define CV_CPU_FORCE_VSX3 0 +# define CV_CPU_HAS_SUPPORT_VSX3 (cv::checkHardwareSupport(CV_CPU_VSX3)) +# define CV_CPU_CALL_VSX3(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args) +# define CV_CPU_CALL_VSX3_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args) +#else +# define CV_TRY_VSX3 0 +# define CV_CPU_FORCE_VSX3 0 +# define CV_CPU_HAS_SUPPORT_VSX3 0 +# define CV_CPU_CALL_VSX3(fn, args) +# define CV_CPU_CALL_VSX3_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_VSX3(fn, args, mode, ...) CV_CPU_CALL_VSX3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_RVV +# define CV_TRY_RVV 1 +# define CV_CPU_FORCE_RVV 1 +# define CV_CPU_HAS_SUPPORT_RVV 1 +# define CV_CPU_CALL_RVV(fn, args) return (cpu_baseline::fn args) +# define CV_CPU_CALL_RVV_(fn, args) return (opt_RVV::fn args) +#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_RVV +# define CV_TRY_RVV 1 +# define CV_CPU_FORCE_RVV 0 +# define CV_CPU_HAS_SUPPORT_RVV (cv::checkHardwareSupport(CV_CPU_RVV)) +# define CV_CPU_CALL_RVV(fn, args) if (CV_CPU_HAS_SUPPORT_RVV) return (opt_RVV::fn args) +# define CV_CPU_CALL_RVV_(fn, args) if (CV_CPU_HAS_SUPPORT_RVV) return (opt_RVV::fn args) +#else +# define CV_TRY_RVV 0 +# define CV_CPU_FORCE_RVV 0 +# define CV_CPU_HAS_SUPPORT_RVV 0 +# define CV_CPU_CALL_RVV(fn, args) +# define CV_CPU_CALL_RVV_(fn, args) +#endif +#define __CV_CPU_DISPATCH_CHAIN_RVV(fn, args, mode, ...) CV_CPU_CALL_RVV(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__)) + +#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args) +#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvdef.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvdef.h new file mode 100644 index 0000000..f785f32 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvdef.h @@ -0,0 +1,967 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CVDEF_H +#define OPENCV_CORE_CVDEF_H + +#include "opencv2/core/version.hpp" + +//! @addtogroup core_utils +//! @{ + +#ifdef OPENCV_INCLUDE_PORT_FILE // User-provided header file with custom platform configuration +#include OPENCV_INCLUDE_PORT_FILE +#endif + +#if !defined CV_DOXYGEN && !defined CV_IGNORE_DEBUG_BUILD_GUARD +#if (defined(_MSC_VER) && (defined(DEBUG) || defined(_DEBUG))) || \ + (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_DEBUG_PEDANTIC)) +// Guard to prevent using of binary incompatible binaries / runtimes +// https://github.com/opencv/opencv/pull/9161 +#define CV__DEBUG_NS_BEGIN namespace debug_build_guard { +#define CV__DEBUG_NS_END } +namespace cv { namespace debug_build_guard { } using namespace debug_build_guard; } +#endif +#endif + +#ifndef CV__DEBUG_NS_BEGIN +#define CV__DEBUG_NS_BEGIN +#define CV__DEBUG_NS_END +#endif + + +#ifdef __OPENCV_BUILD +#include "cvconfig.h" +#endif + +#ifndef __CV_EXPAND +#define __CV_EXPAND(x) x +#endif + +#ifndef __CV_CAT +#define __CV_CAT__(x, y) x ## y +#define __CV_CAT_(x, y) __CV_CAT__(x, y) +#define __CV_CAT(x, y) __CV_CAT_(x, y) +#endif + +#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N +#define __CV_VA_NUM_ARGS(...) __CV_EXPAND(__CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) + +#ifdef CV_Func +// keep current value (through OpenCV port file) +#elif defined __GNUC__ || (defined (__cpluscplus) && (__cpluscplus >= 201103)) +#define CV_Func __func__ +#elif defined __clang__ && (__clang_minor__ * 100 + __clang_major__ >= 305) +#define CV_Func __func__ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION >= 199901) +#define CV_Func __func__ +#elif defined _MSC_VER +#define CV_Func __FUNCTION__ +#elif defined(__INTEL_COMPILER) && (_INTEL_COMPILER >= 600) +#define CV_Func __FUNCTION__ +#elif defined __IBMCPP__ && __IBMCPP__ >=500 +#define CV_Func __FUNCTION__ +#elif defined __BORLAND__ && (__BORLANDC__ >= 0x550) +#define CV_Func __FUNC__ +#else +#define CV_Func "" +#endif + +//! @cond IGNORED + +//////////////// static assert ///////////////// +#define CVAUX_CONCAT_EXP(a, b) a##b +#define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b) + +#if defined(__clang__) +# ifndef __has_extension +# define __has_extension __has_feature /* compatibility, for older versions of clang */ +# endif +# if __has_extension(cxx_static_assert) +# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) +# elif __has_extension(c_static_assert) +# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition) +# endif +#elif defined(__GNUC__) +# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) +# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) +# endif +#elif defined(_MSC_VER) +# if _MSC_VER >= 1600 /* MSVC 10 */ +# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) +# endif +#endif +#ifndef CV_StaticAssert +# if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302) +# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); }) +# else +namespace cv { + template struct CV_StaticAssert_failed; + template <> struct CV_StaticAssert_failed { enum { val = 1 }; }; + template struct CV_StaticAssert_test {}; +} +# define CV_StaticAssert(condition, reason)\ + typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__) +# endif +#endif + +// Suppress warning "-Wdeprecated-declarations" / C4996 +#if defined(_MSC_VER) + #define CV_DO_PRAGMA(x) __pragma(x) +#elif defined(__GNUC__) + #define CV_DO_PRAGMA(x) _Pragma (#x) +#else + #define CV_DO_PRAGMA(x) +#endif + +#ifdef _MSC_VER +#define CV_SUPPRESS_DEPRECATED_START \ + CV_DO_PRAGMA(warning(push)) \ + CV_DO_PRAGMA(warning(disable: 4996)) +#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop)) +#elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405)) +#define CV_SUPPRESS_DEPRECATED_START \ + CV_DO_PRAGMA(GCC diagnostic push) \ + CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") +#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop) +#else +#define CV_SUPPRESS_DEPRECATED_START +#define CV_SUPPRESS_DEPRECATED_END +#endif + +#define CV_UNUSED(name) (void)name + +//! @endcond + +// undef problematic defines sometimes defined by system headers (windows.h in particular) +#undef small +#undef min +#undef max +#undef abs +#undef Complex + +#if defined __cplusplus +#include +#else +#include +#endif + +#include "opencv2/core/hal/interface.h" + +#if defined __ICL +# define CV_ICC __ICL +#elif defined __ICC +# define CV_ICC __ICC +#elif defined __ECL +# define CV_ICC __ECL +#elif defined __ECC +# define CV_ICC __ECC +#elif defined __INTEL_COMPILER +# define CV_ICC __INTEL_COMPILER +#endif + +#ifndef CV_INLINE +# if defined __cplusplus +# define CV_INLINE static inline +# elif defined _MSC_VER +# define CV_INLINE __inline +# else +# define CV_INLINE static +# endif +#endif + +#ifndef CV_ALWAYS_INLINE +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#define CV_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define CV_ALWAYS_INLINE __forceinline +#else +#define CV_ALWAYS_INLINE inline +#endif +#endif + +#if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED) +# define CV_ENABLE_UNROLLED 0 +#else +# define CV_ENABLE_UNROLLED 1 +#endif + +#ifdef __GNUC__ +# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x))) +#elif defined _MSC_VER +# define CV_DECL_ALIGNED(x) __declspec(align(x)) +#else +# define CV_DECL_ALIGNED(x) +#endif + +/* CPU features and intrinsics support */ +#define CV_CPU_NONE 0 +#define CV_CPU_MMX 1 +#define CV_CPU_SSE 2 +#define CV_CPU_SSE2 3 +#define CV_CPU_SSE3 4 +#define CV_CPU_SSSE3 5 +#define CV_CPU_SSE4_1 6 +#define CV_CPU_SSE4_2 7 +#define CV_CPU_POPCNT 8 +#define CV_CPU_FP16 9 +#define CV_CPU_AVX 10 +#define CV_CPU_AVX2 11 +#define CV_CPU_FMA3 12 + +#define CV_CPU_AVX_512F 13 +#define CV_CPU_AVX_512BW 14 +#define CV_CPU_AVX_512CD 15 +#define CV_CPU_AVX_512DQ 16 +#define CV_CPU_AVX_512ER 17 +#define CV_CPU_AVX_512IFMA512 18 // deprecated +#define CV_CPU_AVX_512IFMA 18 +#define CV_CPU_AVX_512PF 19 +#define CV_CPU_AVX_512VBMI 20 +#define CV_CPU_AVX_512VL 21 +#define CV_CPU_AVX_512VBMI2 22 +#define CV_CPU_AVX_512VNNI 23 +#define CV_CPU_AVX_512BITALG 24 +#define CV_CPU_AVX_512VPOPCNTDQ 25 +#define CV_CPU_AVX_5124VNNIW 26 +#define CV_CPU_AVX_5124FMAPS 27 + +#define CV_CPU_NEON 100 + +#define CV_CPU_MSA 150 + +#define CV_CPU_RISCVV 170 + +#define CV_CPU_VSX 200 +#define CV_CPU_VSX3 201 + +#define CV_CPU_RVV 210 + +// CPU features groups +#define CV_CPU_AVX512_SKX 256 +#define CV_CPU_AVX512_COMMON 257 +#define CV_CPU_AVX512_KNL 258 +#define CV_CPU_AVX512_KNM 259 +#define CV_CPU_AVX512_CNL 260 +#define CV_CPU_AVX512_CLX 261 +#define CV_CPU_AVX512_ICL 262 + +// when adding to this list remember to update the following enum +#define CV_HARDWARE_MAX_FEATURE 512 + +/** @brief Available CPU features. +*/ +enum CpuFeatures { + CPU_MMX = 1, + CPU_SSE = 2, + CPU_SSE2 = 3, + CPU_SSE3 = 4, + CPU_SSSE3 = 5, + CPU_SSE4_1 = 6, + CPU_SSE4_2 = 7, + CPU_POPCNT = 8, + CPU_FP16 = 9, + CPU_AVX = 10, + CPU_AVX2 = 11, + CPU_FMA3 = 12, + + CPU_AVX_512F = 13, + CPU_AVX_512BW = 14, + CPU_AVX_512CD = 15, + CPU_AVX_512DQ = 16, + CPU_AVX_512ER = 17, + CPU_AVX_512IFMA512 = 18, // deprecated + CPU_AVX_512IFMA = 18, + CPU_AVX_512PF = 19, + CPU_AVX_512VBMI = 20, + CPU_AVX_512VL = 21, + CPU_AVX_512VBMI2 = 22, + CPU_AVX_512VNNI = 23, + CPU_AVX_512BITALG = 24, + CPU_AVX_512VPOPCNTDQ= 25, + CPU_AVX_5124VNNIW = 26, + CPU_AVX_5124FMAPS = 27, + + CPU_NEON = 100, + + CPU_MSA = 150, + + CPU_RISCVV = 170, + + CPU_VSX = 200, + CPU_VSX3 = 201, + + CPU_RVV = 210, + + CPU_AVX512_SKX = 256, //!< Skylake-X with AVX-512F/CD/BW/DQ/VL + CPU_AVX512_COMMON = 257, //!< Common instructions AVX-512F/CD for all CPUs that support AVX-512 + CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF + CPU_AVX512_KNM = 259, //!< Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ + CPU_AVX512_CNL = 260, //!< Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI + CPU_AVX512_CLX = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI + CPU_AVX512_ICL = 262, //!< Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ + + CPU_MAX_FEATURE = 512 // see CV_HARDWARE_MAX_FEATURE +}; + + +#include "cv_cpu_dispatch.h" + +#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64)) +// int*, int64* should be propertly aligned pointers on ARMv7 +#define CV_STRONG_ALIGNMENT 1 +#endif +#if !defined(CV_STRONG_ALIGNMENT) +#define CV_STRONG_ALIGNMENT 0 +#endif + +/* fundamental constants */ +#define CV_PI 3.1415926535897932384626433832795 +#define CV_2PI 6.283185307179586476925286766559 +#define CV_LOG2 0.69314718055994530941723212145818 + +#if defined __ARM_FP16_FORMAT_IEEE \ + && !defined __CUDACC__ +# define CV_FP16_TYPE 1 +#else +# define CV_FP16_TYPE 0 +#endif + +typedef union Cv16suf +{ + short i; + ushort u; +#if CV_FP16_TYPE + __fp16 h; +#endif +} +Cv16suf; + +typedef union Cv32suf +{ + int i; + unsigned u; + float f; +} +Cv32suf; + +typedef union Cv64suf +{ + int64 i; + uint64 u; + double f; +} +Cv64suf; + +#ifndef OPENCV_ABI_COMPATIBILITY +#define OPENCV_ABI_COMPATIBILITY 400 +#endif + +#ifdef __OPENCV_BUILD +# define DISABLE_OPENCV_3_COMPATIBILITY +# define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY +#endif + +#ifndef CV_EXPORTS +# if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined(CVAPI_EXPORTS) +# define CV_EXPORTS __declspec(dllexport) +# elif defined __GNUC__ && __GNUC__ >= 4 && (defined(CVAPI_EXPORTS) || defined(__APPLE__)) +# define CV_EXPORTS __attribute__ ((visibility ("default"))) +# endif +#endif + +#ifndef CV_EXPORTS +# define CV_EXPORTS +#endif + +#ifdef _MSC_VER +# define CV_EXPORTS_TEMPLATE +#else +# define CV_EXPORTS_TEMPLATE CV_EXPORTS +#endif + +#ifndef CV_DEPRECATED +# if defined(__GNUC__) +# define CV_DEPRECATED __attribute__ ((deprecated)) +# elif defined(_MSC_VER) +# define CV_DEPRECATED __declspec(deprecated) +# else +# define CV_DEPRECATED +# endif +#endif + +#ifndef CV_DEPRECATED_EXTERNAL +# if defined(__OPENCV_BUILD) +# define CV_DEPRECATED_EXTERNAL /* nothing */ +# else +# define CV_DEPRECATED_EXTERNAL CV_DEPRECATED +# endif +#endif + + +#ifndef CV_EXTERN_C +# ifdef __cplusplus +# define CV_EXTERN_C extern "C" +# else +# define CV_EXTERN_C +# endif +#endif + +/* special informative macros for wrapper generators */ +#define CV_EXPORTS_W CV_EXPORTS +#define CV_EXPORTS_W_SIMPLE CV_EXPORTS +#define CV_EXPORTS_AS(synonym) CV_EXPORTS +#define CV_EXPORTS_W_MAP CV_EXPORTS +#define CV_IN_OUT +#define CV_OUT +#define CV_PROP +#define CV_PROP_RW +#define CV_WRAP +#define CV_WRAP_AS(synonym) +#define CV_WRAP_MAPPABLE(mappable) +#define CV_WRAP_PHANTOM(phantom_header) +#define CV_WRAP_DEFAULT(val) + +/****************************************************************************************\ +* Matrix type (Mat) * +\****************************************************************************************/ + +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_CONT_FLAG_SHIFT 14 +#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) +#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) +#define CV_IS_CONT_MAT CV_IS_MAT_CONT +#define CV_SUBMAT_FLAG_SHIFT 15 +#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT) +#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG) + +/** Size of each channel item, + 0x28442211 = 0010 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ +#define CV_ELEM_SIZE1(type) ((0x28442211 >> CV_MAT_DEPTH(type)*4) & 15) + +#define CV_ELEM_SIZE(type) (CV_MAT_CN(type)*CV_ELEM_SIZE1(type)) + +#ifndef MIN +# define MIN(a,b) ((a) > (b) ? (b) : (a)) +#endif + +#ifndef MAX +# define MAX(a,b) ((a) < (b) ? (b) : (a)) +#endif + +///////////////////////////////////////// Enum operators /////////////////////////////////////// + +/** + +Provides compatibility operators for both classical and C++11 enum classes, +as well as exposing the C++11 enum class members for backwards compatibility + +@code + // Provides operators required for flag enums + CV_ENUM_FLAGS(AccessFlag) + + // Exposes the listed members of the enum class AccessFlag to the current namespace + CV_ENUM_CLASS_EXPOSE(AccessFlag, ACCESS_READ [, ACCESS_WRITE [, ...] ]); +@endcode +*/ + +#define __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST) \ +static const EnumType MEMBER_CONST = EnumType::MEMBER_CONST; \ + +#define __CV_ENUM_CLASS_EXPOSE_2(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_1(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_3(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_2(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_4(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_3(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_5(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_4(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_6(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_5(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_7(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_6(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_8(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_7(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_CLASS_EXPOSE_9(EnumType, MEMBER_CONST, ...) \ +__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \ +__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_8(EnumType, __VA_ARGS__)); \ + +#define __CV_ENUM_FLAGS_LOGICAL_NOT(EnumType) \ +static inline bool operator!(const EnumType& val) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return !static_cast(val); \ +} \ + +#define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \ +static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \ +{ \ + return static_cast(a) != static_cast(b); \ +} \ + +#define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \ +static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \ +{ \ + return static_cast(a) == static_cast(b); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \ +static inline EnumType operator~(const EnumType& val) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(~static_cast(val)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \ +static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(static_cast(a) | static_cast(b)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \ +static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(static_cast(a) & static_cast(b)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \ +static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \ +{ \ + typedef std::underlying_type::type UnderlyingType; \ + return static_cast(static_cast(a) ^ static_cast(b)); \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \ +static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \ +{ \ + _this = static_cast(static_cast(_this) | static_cast(val)); \ + return _this; \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \ +static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \ +{ \ + _this = static_cast(static_cast(_this) & static_cast(val)); \ + return _this; \ +} \ + +#define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \ +static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \ +{ \ + _this = static_cast(static_cast(_this) ^ static_cast(val)); \ + return _this; \ +} \ + +#define CV_ENUM_CLASS_EXPOSE(EnumType, ...) \ +__CV_EXPAND(__CV_CAT(__CV_ENUM_CLASS_EXPOSE_, __CV_VA_NUM_ARGS(__VA_ARGS__))(EnumType, __VA_ARGS__)); \ + +#define CV_ENUM_FLAGS(EnumType) \ +__CV_ENUM_FLAGS_LOGICAL_NOT (EnumType) \ +__CV_ENUM_FLAGS_LOGICAL_EQ (EnumType, int) \ +__CV_ENUM_FLAGS_LOGICAL_NOT_EQ (EnumType, int) \ + \ +__CV_ENUM_FLAGS_BITWISE_NOT (EnumType) \ +__CV_ENUM_FLAGS_BITWISE_OR (EnumType, EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_AND (EnumType, EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_XOR (EnumType, EnumType, EnumType) \ + \ +__CV_ENUM_FLAGS_BITWISE_OR_EQ (EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_AND_EQ (EnumType, EnumType) \ +__CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType) \ + +/****************************************************************************************\ +* static analysys * +\****************************************************************************************/ + +// In practice, some macro are not processed correctly (noreturn is not detected). +// We need to use simplified definition for them. +#ifndef CV_STATIC_ANALYSIS +# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__) +# define CV_STATIC_ANALYSIS 1 +# endif +#else +# if defined(CV_STATIC_ANALYSIS) && !(__CV_CAT(1, CV_STATIC_ANALYSIS) == 1) // defined and not empty +# if 0 == CV_STATIC_ANALYSIS +# undef CV_STATIC_ANALYSIS +# endif +# endif +#endif + +/****************************************************************************************\ +* Thread sanitizer * +\****************************************************************************************/ +#ifndef CV_THREAD_SANITIZER +# if defined(__has_feature) +# if __has_feature(thread_sanitizer) +# define CV_THREAD_SANITIZER +# endif +# endif +#endif + +/****************************************************************************************\ +* exchange-add operation for atomic operations on reference counters * +\****************************************************************************************/ + +#ifdef CV_XADD + // allow to use user-defined macro +#elif defined __GNUC__ || defined __clang__ +# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER +# ifdef __ATOMIC_ACQ_REL +# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL) +# else +# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4) +# endif +# else +# if defined __ATOMIC_ACQ_REL && !defined __clang__ + // version for gcc >= 4.7 +# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL) +# else +# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta)) +# endif +# endif +#elif defined _MSC_VER && !defined RC_INVOKED +# include +# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta) +#else + #ifdef OPENCV_FORCE_UNSAFE_XADD + CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } + #else + #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)" + #endif +#endif + + +/****************************************************************************************\ +* CV_NORETURN attribute * +\****************************************************************************************/ + +#ifndef CV_NORETURN +# if defined(__GNUC__) +# define CV_NORETURN __attribute__((__noreturn__)) +# elif defined(_MSC_VER) && (_MSC_VER >= 1300) +# define CV_NORETURN __declspec(noreturn) +# else +# define CV_NORETURN /* nothing by default */ +# endif +#endif + +/****************************************************************************************\ +* CV_NODISCARD_STD attribute (C++17) * +* encourages the compiler to issue a warning if the return value is discarded * +\****************************************************************************************/ +#ifndef CV_NODISCARD_STD +# ifndef __has_cpp_attribute +// workaround preprocessor non-compliance https://reviews.llvm.org/D57851 +# define __has_cpp_attribute(__x) 0 +# endif +# if __has_cpp_attribute(nodiscard) +# define CV_NODISCARD_STD [[nodiscard]] +# elif __cplusplus >= 201703L +// available when compiler is C++17 compliant +# define CV_NODISCARD_STD [[nodiscard]] +# elif defined(__INTEL_COMPILER) + // see above, available when C++17 is enabled +# elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L +// available with VS2017 v15.3+ with /std:c++17 or higher; works on functions and classes +# define CV_NODISCARD_STD [[nodiscard]] +# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 700) && (__cplusplus >= 201103L) +// available with GCC 7.0+; works on functions, works or silently fails on classes +# define CV_NODISCARD_STD [[nodiscard]] +# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && (__cplusplus >= 201103L) +// available with GCC 4.8+ but it usually does nothing and can fail noisily -- therefore not used +// define CV_NODISCARD_STD [[gnu::warn_unused_result]] +# endif +#endif +#ifndef CV_NODISCARD_STD +# define CV_NODISCARD_STD /* nothing by default */ +#endif + + +/****************************************************************************************\ +* CV_NODISCARD attribute (deprecated, GCC only) * +* DONT USE: use instead the standard CV_NODISCARD_STD macro above * +* this legacy method silently fails to issue warning until some version * +* after gcc 6.3.0. Yet with gcc 7+ you can use the above standard method * +* which makes this method useless. Don't use it. * +* @deprecated use instead CV_NODISCARD_STD * +\****************************************************************************************/ +#ifndef CV_NODISCARD +# if defined(__GNUC__) +# define CV_NODISCARD __attribute__((__warn_unused_result__)) +# elif defined(__clang__) && defined(__has_attribute) +# if __has_attribute(__warn_unused_result__) +# define CV_NODISCARD __attribute__((__warn_unused_result__)) +# endif +# endif +#endif +#ifndef CV_NODISCARD +# define CV_NODISCARD /* nothing by default */ +#endif + + +/****************************************************************************************\ +* C++ 11 * +\****************************************************************************************/ +#ifndef CV_CXX11 +# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) +# define CV_CXX11 1 +# endif +#else +# if CV_CXX11 == 0 +# undef CV_CXX11 +# endif +#endif +#ifndef CV_CXX11 +# error "OpenCV 4.x+ requires enabled C++11 support" +#endif + +#define CV_CXX_MOVE_SEMANTICS 1 +#define CV_CXX_MOVE(x) std::move(x) +#define CV_CXX_STD_ARRAY 1 +#include +#ifndef CV_OVERRIDE +# define CV_OVERRIDE override +#endif +#ifndef CV_FINAL +# define CV_FINAL final +#endif + +#ifndef CV_NOEXCEPT +# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) +# define CV_NOEXCEPT noexcept +# endif +#endif +#ifndef CV_NOEXCEPT +# define CV_NOEXCEPT +#endif + +#ifndef CV_CONSTEXPR +# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) +# define CV_CONSTEXPR constexpr +# endif +#endif +#ifndef CV_CONSTEXPR +# define CV_CONSTEXPR +#endif + +// Integer types portatibility +#ifdef OPENCV_STDINT_HEADER +#include OPENCV_STDINT_HEADER +#elif defined(__cplusplus) +#if defined(_MSC_VER) && _MSC_VER < 1600 /* MSVS 2010 */ +namespace cv { +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +} +#elif defined(_MSC_VER) || __cplusplus >= 201103L +#include +namespace cv { +using std::int8_t; +using std::uint8_t; +using std::int16_t; +using std::uint16_t; +using std::int32_t; +using std::uint32_t; +using std::int64_t; +using std::uint64_t; +} +#else +#include +namespace cv { +typedef ::int8_t int8_t; +typedef ::uint8_t uint8_t; +typedef ::int16_t int16_t; +typedef ::uint16_t uint16_t; +typedef ::int32_t int32_t; +typedef ::uint32_t uint32_t; +typedef ::int64_t int64_t; +typedef ::uint64_t uint64_t; +} +#endif +#else // pure C +#include +#endif + +#ifdef __cplusplus +namespace cv +{ + +class float16_t +{ +public: +#if CV_FP16_TYPE + + float16_t() : h(0) {} + explicit float16_t(float x) { h = (__fp16)x; } + operator float() const { return (float)h; } + static float16_t fromBits(ushort w) + { + Cv16suf u; + u.u = w; + float16_t result; + result.h = u.h; + return result; + } + static float16_t zero() + { + float16_t result; + result.h = (__fp16)0; + return result; + } + ushort bits() const + { + Cv16suf u; + u.h = h; + return u.u; + } +protected: + __fp16 h; + +#else + float16_t() : w(0) {} + explicit float16_t(float x) + { + #if CV_FP16 + __m128 v = _mm_load_ss(&x); + w = (ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0)); + #else + Cv32suf in; + in.f = x; + unsigned sign = in.u & 0x80000000; + in.u ^= sign; + + if( in.u >= 0x47800000 ) + w = (ushort)(in.u > 0x7f800000 ? 0x7e00 : 0x7c00); + else + { + if (in.u < 0x38800000) + { + in.f += 0.5f; + w = (ushort)(in.u - 0x3f000000); + } + else + { + unsigned t = in.u + 0xc8000fff; + w = (ushort)((t + ((in.u >> 13) & 1)) >> 13); + } + } + + w = (ushort)(w | (sign >> 16)); + #endif + } + + operator float() const + { + #if CV_FP16 + float f; + _mm_store_ss(&f, _mm_cvtph_ps(_mm_cvtsi32_si128(w))); + return f; + #else + Cv32suf out; + + unsigned t = ((w & 0x7fff) << 13) + 0x38000000; + unsigned sign = (w & 0x8000) << 16; + unsigned e = w & 0x7c00; + + out.u = t + (1 << 23); + out.u = (e >= 0x7c00 ? t + 0x38000000 : + e == 0 ? (static_cast(out.f -= 6.103515625e-05f), out.u) : t) | sign; + return out.f; + #endif + } + + static float16_t fromBits(ushort b) + { + float16_t result; + result.w = b; + return result; + } + static float16_t zero() + { + float16_t result; + result.w = (ushort)0; + return result; + } + ushort bits() const { return w; } +protected: + ushort w; + +#endif +}; + +} +#endif + +//! @} + +#ifndef __cplusplus +#include "opencv2/core/fast_math.hpp" // define cvRound(double) +#endif + +#endif // OPENCV_CORE_CVDEF_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd.hpp new file mode 100644 index 0000000..6ce9e4b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd.hpp @@ -0,0 +1,190 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CVSTD_HPP +#define OPENCV_CORE_CVSTD_HPP + +#ifndef __cplusplus +# error cvstd.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" +#include +#include +#include + +#include + +// import useful primitives from stl +# include +# include +# include //for abs(int) +# include + +namespace cv +{ + static inline uchar abs(uchar a) { return a; } + static inline ushort abs(ushort a) { return a; } + static inline unsigned abs(unsigned a) { return a; } + static inline uint64 abs(uint64 a) { return a; } + + using std::min; + using std::max; + using std::abs; + using std::swap; + using std::sqrt; + using std::exp; + using std::pow; + using std::log; +} + +#include "cvstd_wrapper.hpp" + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +//////////////////////////// memory management functions //////////////////////////// + +/** @brief Allocates an aligned memory buffer. + +The function allocates the buffer of the specified size and returns it. When the buffer size is 16 +bytes or more, the returned buffer is aligned to 16 bytes. +@param bufSize Allocated buffer size. + */ +CV_EXPORTS void* fastMalloc(size_t bufSize); + +/** @brief Deallocates a memory buffer. + +The function deallocates the buffer allocated with fastMalloc . If NULL pointer is passed, the +function does nothing. C version of the function clears the pointer *pptr* to avoid problems with +double memory deallocation. +@param ptr Pointer to the allocated buffer. + */ +CV_EXPORTS void fastFree(void* ptr); + +/*! + The STL-compliant memory Allocator based on cv::fastMalloc() and cv::fastFree() +*/ +template class Allocator +{ +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + template class rebind { typedef Allocator other; }; + + explicit Allocator() {} + ~Allocator() {} + explicit Allocator(Allocator const&) {} + template + explicit Allocator(Allocator const&) {} + + // address + pointer address(reference r) { return &r; } + const_pointer address(const_reference r) { return &r; } + + pointer allocate(size_type count, const void* =0) { return reinterpret_cast(fastMalloc(count * sizeof (_Tp))); } + void deallocate(pointer p, size_type) { fastFree(p); } + + void construct(pointer p, const _Tp& v) { new(static_cast(p)) _Tp(v); } + void destroy(pointer p) { p->~_Tp(); } + + size_type max_size() const { return cv::max(static_cast<_Tp>(-1)/sizeof(_Tp), 1); } +}; + +//! @} core_utils + +//! @endcond + +//! @addtogroup core_basic +//! @{ + +//////////////////////////////// string class //////////////////////////////// + +class CV_EXPORTS FileNode; //for string constructor from FileNode + +typedef std::string String; + +#ifndef OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS + +//! @cond IGNORED +namespace details { +// std::tolower is int->int +static inline char char_tolower(char ch) +{ + return (char)std::tolower((int)ch); +} +// std::toupper is int->int +static inline char char_toupper(char ch) +{ + return (char)std::toupper((int)ch); +} +} // namespace details +//! @endcond + +static inline std::string toLowerCase(const std::string& str) +{ + std::string result(str); + std::transform(result.begin(), result.end(), result.begin(), details::char_tolower); + return result; +} + +static inline std::string toUpperCase(const std::string& str) +{ + std::string result(str); + std::transform(result.begin(), result.end(), result.begin(), details::char_toupper); + return result; +} + +#endif // OPENCV_DISABLE_STRING_LOWER_UPPER_CONVERSIONS + +//! @} core_basic +} // cv + +#endif //OPENCV_CORE_CVSTD_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd.inl.hpp new file mode 100644 index 0000000..37ad1e6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd.inl.hpp @@ -0,0 +1,197 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_CVSTDINL_HPP +#define OPENCV_CORE_CVSTDINL_HPP + +#include +#include +#include + +//! @cond IGNORED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4127 ) +#endif + +namespace cv +{ + +template class DataType< std::complex<_Tp> > +{ +public: + typedef std::complex<_Tp> value_type; + typedef value_type work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + depth = DataType::depth, + channels = 2, + fmt = DataType::fmt + ((channels - 1) << 8), + type = CV_MAKETYPE(depth, channels) }; + + typedef Vec vec_type; +}; + +static inline +std::ostream& operator << (std::ostream& out, Ptr fmtd) +{ + fmtd->reset(); + for(const char* str = fmtd->next(); str; str = fmtd->next()) + out << str; + return out; +} + +static inline +std::ostream& operator << (std::ostream& out, const Mat& mtx) +{ + return out << Formatter::get()->format(mtx); +} + +static inline +std::ostream& operator << (std::ostream& out, const UMat& m) +{ + return out << m.getMat(ACCESS_READ); +} + +template static inline +std::ostream& operator << (std::ostream& out, const Complex<_Tp>& c) +{ + return out << "(" << c.re << "," << c.im << ")"; +} + +template static inline +std::ostream& operator << (std::ostream& out, const std::vector >& vec) +{ + return out << Formatter::get()->format(Mat(vec)); +} + + +template static inline +std::ostream& operator << (std::ostream& out, const std::vector >& vec) +{ + return out << Formatter::get()->format(Mat(vec)); +} + + +template static inline +std::ostream& operator << (std::ostream& out, const Matx<_Tp, m, n>& matx) +{ + return out << Formatter::get()->format(Mat(matx)); +} + +template static inline +std::ostream& operator << (std::ostream& out, const Point_<_Tp>& p) +{ + out << "[" << p.x << ", " << p.y << "]"; + return out; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Point3_<_Tp>& p) +{ + out << "[" << p.x << ", " << p.y << ", " << p.z << "]"; + return out; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec) +{ + out << "["; + if (cv::traits::Depth<_Tp>::value <= CV_32S) + { + for (int i = 0; i < n - 1; ++i) { + out << (int)vec[i] << ", "; + } + out << (int)vec[n-1] << "]"; + } + else + { + for (int i = 0; i < n - 1; ++i) { + out << vec[i] << ", "; + } + out << vec[n-1] << "]"; + } + + return out; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Size_<_Tp>& size) +{ + return out << "[" << size.width << " x " << size.height << "]"; +} + +template static inline +std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect) +{ + return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]"; +} + +static inline std::ostream& operator << (std::ostream& out, const MatSize& msize) +{ + int i, dims = msize.dims(); + for( i = 0; i < dims; i++ ) + { + out << msize[i]; + if( i < dims-1 ) + out << " x "; + } + return out; +} + +static inline std::ostream &operator<< (std::ostream &s, cv::Range &r) +{ + return s << "[" << r.start << " : " << r.end << ")"; +} + +} // cv + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +//! @endcond + +#endif // OPENCV_CORE_CVSTDINL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd_wrapper.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd_wrapper.hpp new file mode 100644 index 0000000..25e0041 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/cvstd_wrapper.hpp @@ -0,0 +1,154 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_CVSTD_WRAPPER_HPP +#define OPENCV_CORE_CVSTD_WRAPPER_HPP + +#include "opencv2/core/cvdef.h" + +#include +#include // std::shared_ptr +#include // std::enable_if + +namespace cv { + +using std::nullptr_t; + +//! @addtogroup core_basic +//! @{ + +#ifdef CV_DOXYGEN + +template using Ptr = std::shared_ptr<_Tp>; // In ideal world it should look like this, but we need some compatibility workarounds below + +template static inline +Ptr<_Tp> makePtr(const A1&... a1) { return std::make_shared<_Tp>(a1...); } + +#else // cv::Ptr with compatibility workarounds + +// It should be defined for C-API types only. +// C++ types should use regular "delete" operator. +template struct DefaultDeleter; +#if 0 +{ + void operator()(Y* p) const; +}; +#endif + +namespace sfinae { +template +struct has_parenthesis_operator +{ +private: + template + static CV_CONSTEXPR std::true_type has_parenthesis_operator_check(typename std::is_same().operator()(std::declval()...))>::type, Ret>::type*); + + template static CV_CONSTEXPR std::false_type has_parenthesis_operator_check(...); + + typedef decltype(has_parenthesis_operator_check(0)) type; + +public: +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) + static CV_CONSTEXPR bool value = type::value; +#else + // support MSVS 2013 + static const int value = type::value; +#endif +}; +} // namespace sfinae + +template +struct has_custom_delete + : public std::false_type {}; + +// Force has_custom_delete to std::false_type when NVCC is compiling CUDA source files +#ifndef __CUDACC__ +template +struct has_custom_delete, void, T*>::value >::type > + : public std::true_type {}; +#endif + +template +struct Ptr : public std::shared_ptr +{ +#if 0 + using std::shared_ptr::shared_ptr; // GCC 5.x can't handle this +#else + inline Ptr() CV_NOEXCEPT : std::shared_ptr() {} + inline Ptr(nullptr_t) CV_NOEXCEPT : std::shared_ptr(nullptr) {} + template inline Ptr(Y* p, D d) : std::shared_ptr(p, d) {} + template inline Ptr(nullptr_t, D d) : std::shared_ptr(nullptr, d) {} + + template inline Ptr(const Ptr& r, T* ptr) CV_NOEXCEPT : std::shared_ptr(r, ptr) {} + + inline Ptr(const Ptr& o) CV_NOEXCEPT : std::shared_ptr(o) {} + inline Ptr(Ptr&& o) CV_NOEXCEPT : std::shared_ptr(std::move(o)) {} + + template inline Ptr(const Ptr& o) CV_NOEXCEPT : std::shared_ptr(o) {} + template inline Ptr(Ptr&& o) CV_NOEXCEPT : std::shared_ptr(std::move(o)) {} +#endif + inline Ptr(const std::shared_ptr& o) CV_NOEXCEPT : std::shared_ptr(o) {} + inline Ptr(std::shared_ptr&& o) CV_NOEXCEPT : std::shared_ptr(std::move(o)) {} + + // Overload with custom DefaultDeleter: Ptr(...) + template + inline Ptr(const std::true_type&, Y* ptr) : std::shared_ptr(ptr, DefaultDeleter()) {} + + // Overload without custom deleter: Ptr(...); + template + inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr(ptr) {} + + template + inline Ptr(Y* ptr) : Ptr(has_custom_delete(), ptr) {} + + // Overload with custom DefaultDeleter: Ptr(...) + template + inline void reset(const std::true_type&, Y* ptr) { std::shared_ptr::reset(ptr, DefaultDeleter()); } + + // Overload without custom deleter: Ptr(...); + template + inline void reset(const std::false_type&, Y* ptr) { std::shared_ptr::reset(ptr); } + + template + inline void reset(Y* ptr) { Ptr::reset(has_custom_delete(), ptr); } + + template + void reset(Y* ptr, Deleter d) { std::shared_ptr::reset(ptr, d); } + + void reset() CV_NOEXCEPT { std::shared_ptr::reset(); } + + Ptr& operator=(const Ptr& o) { std::shared_ptr::operator =(o); return *this; } + template inline Ptr& operator=(const Ptr& o) { std::shared_ptr::operator =(o); return *this; } + + T* operator->() const CV_NOEXCEPT { return std::shared_ptr::get();} + typename std::add_lvalue_reference::type operator*() const CV_NOEXCEPT { return *std::shared_ptr::get(); } + + // OpenCV 3.x methods (not a part of standard C++ library) + inline void release() { std::shared_ptr::reset(); } + inline operator T* () const { return std::shared_ptr::get(); } + inline bool empty() const { return std::shared_ptr::get() == nullptr; } + + template inline + Ptr staticCast() const CV_NOEXCEPT { return std::static_pointer_cast(*this); } + + template inline + Ptr constCast() const CV_NOEXCEPT { return std::const_pointer_cast(*this); } + + template inline + Ptr dynamicCast() const CV_NOEXCEPT { return std::dynamic_pointer_cast(*this); } +}; + +template static inline +Ptr<_Tp> makePtr(const A1&... a1) +{ + static_assert( !has_custom_delete<_Tp>::value, "Can't use this makePtr with custom DefaultDeleter"); + return (Ptr<_Tp>)std::make_shared<_Tp>(a1...); +} + +#endif // CV_DOXYGEN + +//! @} core_basic +} // cv + +#endif //OPENCV_CORE_CVSTD_WRAPPER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/async_promise.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/async_promise.hpp new file mode 100644 index 0000000..6eb3fb5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/async_promise.hpp @@ -0,0 +1,71 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ASYNC_PROMISE_HPP +#define OPENCV_CORE_ASYNC_PROMISE_HPP + +#include "../async.hpp" + +#include "exception_ptr.hpp" + +namespace cv { + +/** @addtogroup core_async +@{ +*/ + + +/** @brief Provides result of asynchronous operations + +*/ +class CV_EXPORTS AsyncPromise +{ +public: + ~AsyncPromise() CV_NOEXCEPT; + AsyncPromise() CV_NOEXCEPT; + explicit AsyncPromise(const AsyncPromise& o) CV_NOEXCEPT; + AsyncPromise& operator=(const AsyncPromise& o) CV_NOEXCEPT; + void release() CV_NOEXCEPT; + + /** Returns associated AsyncArray + @note Can be called once + */ + AsyncArray getArrayResult(); + + /** Stores asynchronous result. + @param[in] value result + */ + void setValue(InputArray value); + + // TODO "move" setters + +#if CV__EXCEPTION_PTR + /** Stores exception. + @param[in] exception exception to be raised in AsyncArray + */ + void setException(std::exception_ptr exception); +#endif + + /** Stores exception. + @param[in] exception exception to be raised in AsyncArray + */ + void setException(const cv::Exception& exception); + +#ifdef CV_CXX11 + explicit AsyncPromise(AsyncPromise&& o) { p = o.p; o.p = NULL; } + AsyncPromise& operator=(AsyncPromise&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; } +#endif + + + // PImpl + typedef struct AsyncArray::Impl Impl; friend struct AsyncArray::Impl; + inline void* _getImpl() const CV_NOEXCEPT { return p; } +protected: + Impl* p; +}; + + +//! @} +} // namespace +#endif // OPENCV_CORE_ASYNC_PROMISE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/dispatch_helper.impl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/dispatch_helper.impl.hpp new file mode 100644 index 0000000..d6ec676 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/dispatch_helper.impl.hpp @@ -0,0 +1,49 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP +#define OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP + +//! @cond IGNORED + +namespace cv { +namespace detail { + +template class Functor, typename... Args> +static inline void depthDispatch(const int depth, Args&&... args) +{ + switch (depth) + { + case CV_8U: + Functor{}(std::forward(args)...); + break; + case CV_8S: + Functor{}(std::forward(args)...); + break; + case CV_16U: + Functor{}(std::forward(args)...); + break; + case CV_16S: + Functor{}(std::forward(args)...); + break; + case CV_32S: + Functor{}(std::forward(args)...); + break; + case CV_32F: + Functor{}(std::forward(args)...); + break; + case CV_64F: + Functor{}(std::forward(args)...); + break; + case CV_16F: + default: + CV_Error(cv::Error::BadDepth, "Unsupported matrix type."); + }; +} + +}} + +//! @endcond + +#endif //OPENCV_CORE_DETAIL_DISPATCH_HELPER_IMPL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/exception_ptr.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/exception_ptr.hpp new file mode 100644 index 0000000..d98ffc4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/detail/exception_ptr.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_DETAILS_EXCEPTION_PTR_H +#define OPENCV_CORE_DETAILS_EXCEPTION_PTR_H + +#ifndef CV__EXCEPTION_PTR +# if defined(__ANDROID__) && defined(ATOMIC_INT_LOCK_FREE) && ATOMIC_INT_LOCK_FREE < 2 +# define CV__EXCEPTION_PTR 0 // Not supported, details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58938 +# elif defined(CV_CXX11) +# define CV__EXCEPTION_PTR 1 +# elif defined(_MSC_VER) +# define CV__EXCEPTION_PTR (_MSC_VER >= 1600) +# elif defined(__clang__) +# define CV__EXCEPTION_PTR 0 // C++11 only (see above) +# elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) +# define CV__EXCEPTION_PTR (__GXX_EXPERIMENTAL_CXX0X__ > 0) +# endif +#endif +#ifndef CV__EXCEPTION_PTR +# define CV__EXCEPTION_PTR 0 +#elif CV__EXCEPTION_PTR +# include // std::exception_ptr +#endif + +#endif // OPENCV_CORE_DETAILS_EXCEPTION_PTR_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/directx.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/directx.hpp new file mode 100644 index 0000000..056a85a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/directx.hpp @@ -0,0 +1,184 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors as is and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the copyright holders or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_DIRECTX_HPP +#define OPENCV_CORE_DIRECTX_HPP + +#include "mat.hpp" +#include "ocl.hpp" + +#if !defined(__d3d11_h__) +struct ID3D11Device; +struct ID3D11Texture2D; +#endif + +#if !defined(__d3d10_h__) +struct ID3D10Device; +struct ID3D10Texture2D; +#endif + +#if !defined(_D3D9_H_) +struct IDirect3DDevice9; +struct IDirect3DDevice9Ex; +struct IDirect3DSurface9; +#endif + + +namespace cv { namespace directx { + +namespace ocl { +using namespace cv::ocl; + +//! @addtogroup core_directx +// This section describes OpenCL and DirectX interoperability. +// +// To enable DirectX support, configure OpenCV using CMake with WITH_DIRECTX=ON . Note, DirectX is +// supported only on Windows. +// +// To use OpenCL functionality you should first initialize OpenCL context from DirectX resource. +// +//! @{ + +// TODO static functions in the Context class +//! @brief Creates OpenCL context from D3D11 device +// +//! @param pD3D11Device - pointer to D3D11 device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device); + +//! @brief Creates OpenCL context from D3D10 device +// +//! @param pD3D10Device - pointer to D3D10 device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device); + +//! @brief Creates OpenCL context from Direct3DDevice9Ex device +// +//! @param pDirect3DDevice9Ex - pointer to Direct3DDevice9Ex device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex); + +//! @brief Creates OpenCL context from Direct3DDevice9 device +// +//! @param pDirect3DDevice9 - pointer to Direct3Device9 device +//! @return Returns reference to OpenCL Context +CV_EXPORTS Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9); + +//! @} + +} // namespace cv::directx::ocl + +//! @addtogroup core_directx +//! @{ + +//! @brief Converts InputArray to ID3D11Texture2D. If destination texture format is DXGI_FORMAT_NV12 then +//! input UMat expected to be in BGR format and data will be downsampled and color-converted to NV12. +// +//! @note Note: Destination texture must be allocated by application. Function does memory copy from src to +//! pD3D11Texture2D +// +//! @param src - source InputArray +//! @param pD3D11Texture2D - destination D3D11 texture +CV_EXPORTS void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D); + +//! @brief Converts ID3D11Texture2D to OutputArray. If input texture format is DXGI_FORMAT_NV12 then +//! data will be upsampled and color-converted to BGR format. +// +//! @note Note: Destination matrix will be re-allocated if it has not enough memory to match texture size. +//! function does memory copy from pD3D11Texture2D to dst +// +//! @param pD3D11Texture2D - source D3D11 texture +//! @param dst - destination OutputArray +CV_EXPORTS void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst); + +//! @brief Converts InputArray to ID3D10Texture2D +// +//! @note Note: function does memory copy from src to +//! pD3D10Texture2D +// +//! @param src - source InputArray +//! @param pD3D10Texture2D - destination D3D10 texture +CV_EXPORTS void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D); + +//! @brief Converts ID3D10Texture2D to OutputArray +// +//! @note Note: function does memory copy from pD3D10Texture2D +//! to dst +// +//! @param pD3D10Texture2D - source D3D10 texture +//! @param dst - destination OutputArray +CV_EXPORTS void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst); + +//! @brief Converts InputArray to IDirect3DSurface9 +// +//! @note Note: function does memory copy from src to +//! pDirect3DSurface9 +// +//! @param src - source InputArray +//! @param pDirect3DSurface9 - destination D3D10 texture +//! @param surfaceSharedHandle - shared handle +CV_EXPORTS void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurface9, void* surfaceSharedHandle = NULL); + +//! @brief Converts IDirect3DSurface9 to OutputArray +// +//! @note Note: function does memory copy from pDirect3DSurface9 +//! to dst +// +//! @param pDirect3DSurface9 - source D3D10 texture +//! @param dst - destination OutputArray +//! @param surfaceSharedHandle - shared handle +CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArray dst, void* surfaceSharedHandle = NULL); + +//! @brief Get OpenCV type from DirectX type +//! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11 +//! @return OpenCV type or -1 if there is no equivalent +CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11 + +//! @brief Get OpenCV type from DirectX type +//! @param iD3DFORMAT - enum D3DTYPE for D3D9 +//! @return OpenCV type or -1 if there is no equivalent +CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9 + +//! @} + +} } // namespace cv::directx + +#endif // OPENCV_CORE_DIRECTX_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/dualquaternion.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/dualquaternion.hpp new file mode 100644 index 0000000..1f644e9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/dualquaternion.hpp @@ -0,0 +1,979 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang +#ifndef OPENCV_CORE_DUALQUATERNION_HPP +#define OPENCV_CORE_DUALQUATERNION_HPP + +#include +#include + +namespace cv{ +//! @addtogroup core +//! @{ + +template class DualQuat; +template std::ostream& operator<<(std::ostream&, const DualQuat<_Tp>&); + +/** + * Dual quaternions were introduced to describe rotation together with translation while ordinary + * quaternions can only describe rotation. It can be used for shortest path pose interpolation, + * local pose optimization or volumetric deformation. More details can be found + * - https://en.wikipedia.org/wiki/Dual_quaternion + * - ["A beginners guide to dual-quaternions: what they are, how they work, and how to use them for 3D character hierarchies", Ben Kenwright, 2012](https://borodust.org/public/shared/beginner_dual_quats.pdf) + * - ["Dual Quaternions", Yan-Bin Jia, 2013](http://web.cs.iastate.edu/~cs577/handouts/dual-quaternion.pdf) + * - ["Geometric Skinning with Approximate Dual Quaternion Blending", Kavan, 2008](https://www.cs.utah.edu/~ladislav/kavan08geometric/kavan08geometric) + * - http://rodolphe-vaillant.fr/?e=29 + * + * A unit dual quaternion can be classically represented as: + * \f[ + * \begin{equation} + * \begin{split} + * \sigma &= \left(r+\frac{\epsilon}{2}tr\right)\\ + * &= [w, x, y, z, w\_, x\_, y\_, z\_] + * \end{split} + * \end{equation} + * \f] + * where \f$r, t\f$ represents the rotation (ordinary unit quaternion) and translation (pure ordinary quaternion) respectively. + * + * A general dual quaternions which consist of two quaternions is usually represented in form of: + * \f[ + * \sigma = p + \epsilon q + * \f] + * where the introduced dual unit \f$\epsilon\f$ satisfies \f$\epsilon^2 = \epsilon^3 =...=0\f$, and \f$p, q\f$ are quaternions. + * + * Alternatively, dual quaternions can also be interpreted as four components which are all [dual numbers](https://www.cs.utah.edu/~ladislav/kavan08geometric/kavan08geometric): + * \f[ + * \sigma = \hat{q}_w + \hat{q}_xi + \hat{q}_yj + \hat{q}_zk + * \f] + * If we set \f$\hat{q}_x, \hat{q}_y\f$ and \f$\hat{q}_z\f$ equal to 0, a dual quaternion is transformed to a dual number. see normalize(). + * + * If you want to create a dual quaternion, you can use: + * + * ``` + * using namespace cv; + * double angle = CV_PI; + * + * // create from eight number + * DualQuatd dq1(1, 2, 3, 4, 5, 6, 7, 8); //p = [1,2,3,4]. q=[5,6,7,8] + * + * // create from Vec + * Vec v{1,2,3,4,5,6,7,8}; + * DualQuatd dq_v{v}; + * + * // create from two quaternion + * Quatd p(1, 2, 3, 4); + * Quatd q(5, 6, 7, 8); + * DualQuatd dq2 = DualQuatd::createFromQuat(p, q); + * + * // create from an angle, an axis and a translation + * Vec3d axis{0, 0, 1}; + * Vec3d trans{3, 4, 5}; + * DualQuatd dq3 = DualQuatd::createFromAngleAxisTrans(angle, axis, trans); + * + * // If you already have an instance of class Affine3, then you can use + * Affine3d R = dq3.toAffine3(); + * DualQuatd dq4 = DualQuatd::createFromAffine3(R); + * + * // or create directly by affine transformation matrix Rt + * // see createFromMat() in detail for the form of Rt + * Matx44d Rt = dq3.toMat(); + * DualQuatd dq5 = DualQuatd::createFromMat(Rt); + * + * // Any rotation + translation movement can + * // be expressed as a rotation + translation around the same line in space (expressed by Plucker + * // coords), and here's a way to represent it this way. + * Vec3d axis{1, 1, 1}; // axis will be normalized in createFromPitch + * Vec3d trans{3, 4 ,5}; + * axis = axis / std::sqrt(axis.dot(axis));// The formula for computing moment that I use below requires a normalized axis + * Vec3d moment = 1.0 / 2 * (trans.cross(axis) + axis.cross(trans.cross(axis)) * + * std::cos(rotation_angle / 2) / std::sin(rotation_angle / 2)); + * double d = trans.dot(qaxis); + * DualQuatd dq6 = DualQuatd::createFromPitch(angle, d, axis, moment); + * ``` + * + * A point \f$v=(x, y, z)\f$ in form of dual quaternion is \f$[1+\epsilon v]=[1,0,0,0,0,x,y,z]\f$. + * The transformation of a point \f$v_1\f$ to another point \f$v_2\f$ under the dual quaternion \f$\sigma\f$ is + * \f[ + * 1 + \epsilon v_2 = \sigma * (1 + \epsilon v_1) * \sigma^{\star} + * \f] + * where \f$\sigma^{\star}=p^*-\epsilon q^*.\f$ + * + * A line in the \f$Pl\ddot{u}cker\f$ coordinates \f$(\hat{l}, m)\f$ defined by the dual quaternion \f$l=\hat{l}+\epsilon m\f$. + * To transform a line, \f[l_2 = \sigma * l_1 * \sigma^*,\f] where \f$\sigma=r+\frac{\epsilon}{2}rt\f$ and + * \f$\sigma^*=p^*+\epsilon q^*\f$. + * + * To extract the Vec or Vec, see toVec(); + * + * To extract the affine transformation matrix, see toMat(); + * + * To extract the instance of Affine3, see toAffine3(); + * + * If two quaternions \f$q_0, q_1\f$ are needed to be interpolated, you can use sclerp() + * ``` + * DualQuatd::sclerp(q0, q1, t) + * ``` + * or dqblend(). + * ``` + * DualQuatd::dqblend(q0, q1, t) + * ``` + * With more than two dual quaternions to be blended, you can use generalize linear dual quaternion blending + * with the corresponding weights, i.e. gdqblend(). + * + */ +template +class CV_EXPORTS DualQuat{ + static_assert(std::is_floating_point<_Tp>::value, "Dual quaternion only make sense with type of float or double"); + using value_type = _Tp; + +public: + static constexpr _Tp CV_DUAL_QUAT_EPS = (_Tp)1.e-6; + + DualQuat(); + + /** + * @brief create from eight same type numbers. + */ + DualQuat(const _Tp w, const _Tp x, const _Tp y, const _Tp z, const _Tp w_, const _Tp x_, const _Tp y_, const _Tp z_); + + /** + * @brief create from a double or float vector. + */ + DualQuat(const Vec<_Tp, 8> &q); + + _Tp w, x, y, z, w_, x_, y_, z_; + + /** + * @brief create Dual Quaternion from two same type quaternions p and q. + * A Dual Quaternion \f$\sigma\f$ has the form: + * \f[\sigma = p + \epsilon q\f] + * where p and q are defined as follows: + * \f[\begin{equation} + * \begin{split} + * p &= w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\\ + * q &= w\_ + x\_\boldsymbol{i} + y\_\boldsymbol{j} + z\_\boldsymbol{k}. + * \end{split} + * \end{equation} + * \f] + * The p and q are the real part and dual part respectively. + * @param realPart a quaternion, real part of dual quaternion. + * @param dualPart a quaternion, dual part of dual quaternion. + * @sa Quat + */ + static DualQuat<_Tp> createFromQuat(const Quat<_Tp> &realPart, const Quat<_Tp> &dualPart); + + /** + * @brief create a dual quaternion from a rotation angle \f$\theta\f$, a rotation axis + * \f$\boldsymbol{u}\f$ and a translation \f$\boldsymbol{t}\f$. + * It generates a dual quaternion \f$\sigma\f$ in the form of + * \f[\begin{equation} + * \begin{split} + * \sigma &= r + \frac{\epsilon}{2}\boldsymbol{t}r \\ + * &= [\cos(\frac{\theta}{2}), \boldsymbol{u}\sin(\frac{\theta}{2})] + * + \frac{\epsilon}{2}[0, \boldsymbol{t}][[\cos(\frac{\theta}{2}), + * \boldsymbol{u}\sin(\frac{\theta}{2})]]\\ + * &= \cos(\frac{\theta}{2}) + \boldsymbol{u}\sin(\frac{\theta}{2}) + * + \frac{\epsilon}{2}(-(\boldsymbol{t} \cdot \boldsymbol{u})\sin(\frac{\theta}{2}) + * + \boldsymbol{t}\cos(\frac{\theta}{2}) + \boldsymbol{u} \times \boldsymbol{t} \sin(\frac{\theta}{2})). + * \end{split} + * \end{equation}\f] + * @param angle rotation angle. + * @param axis rotation axis. + * @param translation a vector of length 3. + * @note Axis will be normalized in this function. And translation is applied + * after the rotation. Use @ref createFromQuat(r, r * t / 2) to create a dual quaternion + * which translation is applied before rotation. + * @sa Quat + */ + static DualQuat<_Tp> createFromAngleAxisTrans(const _Tp angle, const Vec<_Tp, 3> &axis, const Vec<_Tp, 3> &translation); + + /** + * @brief Transform this dual quaternion to an affine transformation matrix \f$M\f$. + * Dual quaternion consists of a rotation \f$r=[a,b,c,d]\f$ and a translation \f$t=[\Delta x,\Delta y,\Delta z]\f$. The + * affine transformation matrix \f$M\f$ has the form + * \f[ + * \begin{bmatrix} + * 1-2(e_2^2 +e_3^2) &2(e_1e_2-e_0e_3) &2(e_0e_2+e_1e_3) &\Delta x\\ + * 2(e_0e_3+e_1e_2) &1-2(e_1^2+e_3^2) &2(e_2e_3-e_0e_1) &\Delta y\\ + * 2(e_1e_3-e_0e_2) &2(e_0e_1+e_2e_3) &1-2(e_1^2-e_2^2) &\Delta z\\ + * 0&0&0&1 + * \end{bmatrix} + * \f] + * if A is a matrix consisting of n points to be transformed, this could be achieved by + * \f[ + * new\_A = M * A + * \f] + * where A has the form + * \f[ + * \begin{bmatrix} + * x_0& x_1& x_2&...&x_n\\ + * y_0& y_1& y_2&...&y_n\\ + * z_0& z_1& z_2&...&z_n\\ + * 1&1&1&...&1 + * \end{bmatrix} + * \f] + * where the same subscript represent the same point. The size of A should be \f$[4,n]\f$. + * and the same size for matrix new_A. + * @param _R 4x4 matrix that represents rotations and translation. + * @note Translation is applied after the rotation. Use createFromQuat(r, r * t / 2) to create + * a dual quaternion which translation is applied before rotation. + */ + static DualQuat<_Tp> createFromMat(InputArray _R); + + /** + * @brief create dual quaternion from an affine matrix. The definition of affine matrix can refer to createFromMat() + */ + static DualQuat<_Tp> createFromAffine3(const Affine3<_Tp> &R); + + /** + * @brief A dual quaternion is a vector in form of + * \f[ + * \begin{equation} + * \begin{split} + * \sigma &=\boldsymbol{p} + \epsilon \boldsymbol{q}\\ + * &= \cos\hat{\frac{\theta}{2}}+\overline{\hat{l}}\sin\frac{\hat{\theta}}{2} + * \end{split} + * \end{equation} + * \f] + * where \f$\hat{\theta}\f$ is dual angle and \f$\overline{\hat{l}}\f$ is dual axis: + * \f[ + * \hat{\theta}=\theta + \epsilon d,\\ + * \overline{\hat{l}}= \hat{l} +\epsilon m. + * \f] + * In this representation, \f$\theta\f$ is rotation angle and \f$(\hat{l},m)\f$ is the screw axis, d is the translation distance along the axis. + * + * @param angle rotation angle. + * @param d translation along the rotation axis. + * @param axis rotation axis represented by quaternion with w = 0. + * @param moment the moment of line, and it should be orthogonal to axis. + * @note Translation is applied after the rotation. Use createFromQuat(r, r * t / 2) to create + * a dual quaternion which translation is applied before rotation. + */ + static DualQuat<_Tp> createFromPitch(const _Tp angle, const _Tp d, const Vec<_Tp, 3> &axis, const Vec<_Tp, 3> &moment); + + /** + * @brief return a quaternion which represent the real part of dual quaternion. + * The definition of real part is in createFromQuat(). + * @sa createFromQuat, getDualPart + */ + Quat<_Tp> getRealPart() const; + + /** + * @brief return a quaternion which represent the dual part of dual quaternion. + * The definition of dual part is in createFromQuat(). + * @sa createFromQuat, getRealPart + */ + Quat<_Tp> getDualPart() const; + + /** + * @brief return the conjugate of a dual quaternion. + * \f[ + * \begin{equation} + * \begin{split} + * \sigma^* &= (p + \epsilon q)^* + * &= (p^* + \epsilon q^*) + * \end{split} + * \end{equation} + * \f] + * @param dq a dual quaternion. + */ + template + friend DualQuat conjugate(const DualQuat &dq); + + /** + * @brief return the conjugate of a dual quaternion. + * \f[ + * \begin{equation} + * \begin{split} + * \sigma^* &= (p + \epsilon q)^* + * &= (p^* + \epsilon q^*) + * \end{split} + * \end{equation} + * \f] + */ + DualQuat<_Tp> conjugate() const; + + /** + * @brief return the rotation in quaternion form. + */ + Quat<_Tp> getRotation(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the translation vector. + * The rotation \f$r\f$ in this dual quaternion \f$\sigma\f$ is applied before translation \f$t\f$. + * The dual quaternion \f$\sigma\f$ is defined as + * \f[\begin{equation} + * \begin{split} + * \sigma &= p + \epsilon q \\ + * &= r + \frac{\epsilon}{2}{t}r. + * \end{split} + * \end{equation}\f] + * Thus, the translation can be obtained as follows + * \f[t = 2qp^*.\f] + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + * @note This dual quaternion's translation is applied after the rotation. + */ + Vec<_Tp, 3> getTranslation(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the norm \f$||\sigma||\f$ of dual quaternion \f$\sigma = p + \epsilon q\f$. + * \f[ + * \begin{equation} + * \begin{split} + * ||\sigma|| &= \sqrt{\sigma * \sigma^*} \\ + * &= ||p|| + \epsilon \frac{p \cdot q}{||p||}. + * \end{split} + * \end{equation} + * \f] + * Generally speaking, the norm of a not unit dual + * quaternion is a dual number. For convenience, we return it in the form of a dual quaternion + * , i.e. + * \f[ ||\sigma|| = [||p||, 0, 0, 0, \frac{p \cdot q}{||p||}, 0, 0, 0].\f] + * + * @note The data type of dual number is dual quaternion. + */ + DualQuat<_Tp> norm() const; + + /** + * @brief return a normalized dual quaternion. + * A dual quaternion can be expressed as + * \f[ + * \begin{equation} + * \begin{split} + * \sigma &= p + \epsilon q\\ + * &=||\sigma||\left(r+\frac{1}{2}tr\right) + * \end{split} + * \end{equation} + * \f] + * where \f$r, t\f$ represents the rotation (ordinary quaternion) and translation (pure ordinary quaternion) respectively, + * and \f$||\sigma||\f$ is the norm of dual quaternion(a dual number). + * A dual quaternion is unit if and only if + * \f[ + * ||p||=1, p \cdot q=0 + * \f] + * where \f$\cdot\f$ means dot product. + * The process of normalization is + * \f[ + * \sigma_{u}=\frac{\sigma}{||\sigma||} + * \f] + * Next, we simply proof \f$\sigma_u\f$ is a unit dual quaternion: + * \f[ + * \renewcommand{\Im}{\operatorname{Im}} + * \begin{equation} + * \begin{split} + * \sigma_{u}=\frac{\sigma}{||\sigma||}&=\frac{p + \epsilon q}{||p||+\epsilon\frac{p\cdot q}{||p||}}\\ + * &=\frac{p}{||p||}+\epsilon\left(\frac{q}{||p||}-p\frac{p\cdot q}{||p||^3}\right)\\ + * &=\frac{p}{||p||}+\epsilon\frac{1}{||p||^2}\left(qp^{*}-p\cdot q\right)\frac{p}{||p||}\\ + * &=\frac{p}{||p||}+\epsilon\frac{1}{||p||^2}\Im(qp^*)\frac{p}{||p||}.\\ + * \end{split} + * \end{equation} + * \f] + * As expected, the real part is a rotation and dual part is a pure quaternion. + */ + DualQuat<_Tp> normalize() const; + + /** + * @brief if \f$\sigma = p + \epsilon q\f$ is a dual quaternion, p is not zero, + * the inverse dual quaternion is + * \f[\sigma^{-1} = \frac{\sigma^*}{||\sigma||^2}, \f] + * or equivalentlly, + * \f[\sigma^{-1} = p^{-1} - \epsilon p^{-1}qp^{-1}.\f] + * @param dq a dual quaternion. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion dq assume to be a unit dual quaternion + * and this function will save some computations. + */ + template + friend DualQuat inv(const DualQuat &dq, QuatAssumeType assumeUnit); + + /** + * @brief if \f$\sigma = p + \epsilon q\f$ is a dual quaternion, p is not zero, + * the inverse dual quaternion is + * \f[\sigma^{-1} = \frac{\sigma^*}{||\sigma||^2}, \f] + * or equivalentlly, + * \f[\sigma^{-1} = p^{-1} - \epsilon p^{-1}qp^{-1}.\f] + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> inv(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the dot product of two dual quaternion. + * @param p other dual quaternion. + */ + _Tp dot(DualQuat<_Tp> p) const; + + /** + ** @brief return the value of \f$p^t\f$ where p is a dual quaternion. + * This could be calculated as: + * \f[ + * p^t = \exp(t\ln p) + * \f] + * @param dq a dual quaternion. + * @param t index of power function. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion dq assume to be a unit dual quaternion + * and this function will save some computations. + */ + template + friend DualQuat power(const DualQuat &dq, const T t, QuatAssumeType assumeUnit); + + /** + ** @brief return the value of \f$p^t\f$ where p is a dual quaternion. + * This could be calculated as: + * \f[ + * p^t = \exp(t\ln p) + * \f] + * + * @param t index of power function. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> power(const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of \f$p^q\f$ where p and q are dual quaternions. + * This could be calculated as: + * \f[ + * p^q = \exp(q\ln p) + * \f] + * @param p a dual quaternion. + * @param q a dual quaternion. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion p assume to be a dual unit quaternion + * and this function will save some computations. + */ + template + friend DualQuat power(const DualQuat& p, const DualQuat& q, QuatAssumeType assumeUnit); + + /** + * @brief return the value of \f$p^q\f$ where p and q are dual quaternions. + * This could be calculated as: + * \f[ + * p^q = \exp(q\ln p) + * \f] + * + * @param q a dual quaternion + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a dual unit quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> power(const DualQuat<_Tp>& q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of exponential function value + * @param dq a dual quaternion. + */ + template + friend DualQuat exp(const DualQuat &dq); + + /** + * @brief return the value of exponential function value + */ + DualQuat<_Tp> exp() const; + + /** + * @brief return the value of logarithm function value + * + * @param dq a dual quaternion. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, dual quaternion dq assume to be a unit dual quaternion + * and this function will save some computations. + */ + template + friend DualQuat log(const DualQuat &dq, QuatAssumeType assumeUnit); + + /** + * @brief return the value of logarithm function value + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + */ + DualQuat<_Tp> log(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief Transform this dual quaternion to a vector. + */ + Vec<_Tp, 8> toVec() const; + + /** + * @brief Transform this dual quaternion to a affine transformation matrix + * the form of matrix, see createFromMat(). + */ + Matx<_Tp, 4, 4> toMat(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief Transform this dual quaternion to a instance of Affine3. + */ + Affine3<_Tp> toAffine3(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief The screw linear interpolation(ScLERP) is an extension of spherical linear interpolation of dual quaternion. + * If \f$\sigma_1\f$ and \f$\sigma_2\f$ are two dual quaternions representing the initial and final pose. + * The interpolation of ScLERP function can be defined as: + * \f[ + * ScLERP(t;\sigma_1,\sigma_2) = \sigma_1 * (\sigma_1^{-1} * \sigma_2)^t, t\in[0,1] + * \f] + * + * @param q1 a dual quaternion represents a initial pose. + * @param q2 a dual quaternion represents a final pose. + * @param t interpolation parameter + * @param directChange if true, it always return the shortest path. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + * + * For example + * ``` + * double angle1 = CV_PI / 2; + * Vec3d axis{0, 0, 1}; + * Vec3d t(0, 0, 3); + * DualQuatd initial = DualQuatd::createFromAngleAxisTrans(angle1, axis, t); + * double angle2 = CV_PI; + * DualQuatd final = DualQuatd::createFromAngleAxisTrans(angle2, axis, t); + * DualQuatd inter = DualQuatd::sclerp(initial, final, 0.5); + * ``` + */ + static DualQuat<_Tp> sclerp(const DualQuat<_Tp> &q1, const DualQuat<_Tp> &q2, const _Tp t, + bool directChange=true, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + /** + * @brief The method of Dual Quaternion linear Blending(DQB) is to compute a transformation between dual quaternion + * \f$q_1\f$ and \f$q_2\f$ and can be defined as: + * \f[ + * DQB(t;{\boldsymbol{q}}_1,{\boldsymbol{q}}_2)= + * \frac{(1-t){\boldsymbol{q}}_1+t{\boldsymbol{q}}_2}{||(1-t){\boldsymbol{q}}_1+t{\boldsymbol{q}}_2||}. + * \f] + * where \f$q_1\f$ and \f$q_2\f$ are unit dual quaternions representing the input transformations. + * If you want to use DQB that works for more than two rigid transformations, see @ref gdqblend + * + * @param q1 a unit dual quaternion representing the input transformations. + * @param q2 a unit dual quaternion representing the input transformations. + * @param t parameter \f$t\in[0,1]\f$. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, this dual quaternion assume to be a unit dual quaternion + * and this function will save some computations. + * + * @sa gdqblend + */ + static DualQuat<_Tp> dqblend(const DualQuat<_Tp> &q1, const DualQuat<_Tp> &q2, const _Tp t, + QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief The generalized Dual Quaternion linear Blending works for more than two rigid transformations. + * If these transformations are expressed as unit dual quaternions \f$q_1,...,q_n\f$ with convex weights + * \f$w = (w_1,...,w_n)\f$, the generalized DQB is simply + * \f[ + * gDQB(\boldsymbol{w};{\boldsymbol{q}}_1,...,{\boldsymbol{q}}_n)=\frac{w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n} + * {||w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n||}. + * \f] + * @param dualquat vector of dual quaternions + * @param weights vector of weights, the size of weights should be the same as dualquat, and the weights should + * satisfy \f$\sum_0^n w_{i} = 1\f$ and \f$w_i>0\f$. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, these dual quaternions assume to be unit quaternions + * and this function will save some computations. + * @note the type of weights' element should be the same as the date type of dual quaternion inside the dualquat. + */ + template + static DualQuat<_Tp> gdqblend(const Vec, cn> &dualquat, InputArray weights, + QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief The generalized Dual Quaternion linear Blending works for more than two rigid transformations. + * If these transformations are expressed as unit dual quaternions \f$q_1,...,q_n\f$ with convex weights + * \f$w = (w_1,...,w_n)\f$, the generalized DQB is simply + * \f[ + * gDQB(\boldsymbol{w};{\boldsymbol{q}}_1,...,{\boldsymbol{q}}_n)=\frac{w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n} + * {||w_1{\boldsymbol{q}}_1+...+w_n{\boldsymbol{q}}_n||}. + * \f] + * @param dualquat The dual quaternions which have 8 channels and 1 row or 1 col. + * @param weights vector of weights, the size of weights should be the same as dualquat, and the weights should + * satisfy \f$\sum_0^n w_{i} = 1\f$ and \f$w_i>0\f$. + * @param assumeUnit if @ref QUAT_ASSUME_UNIT, these dual quaternions assume to be unit quaternions + * and this function will save some computations. + * @note the type of weights' element should be the same as the date type of dual quaternion inside the dualquat. + */ + static DualQuat<_Tp> gdqblend(InputArray dualquat, InputArray weights, + QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief Return opposite dual quaternion \f$-p\f$ + * which satisfies \f$p + (-p) = 0.\f$ + * + * For example + * ``` + * DualQuatd q{1, 2, 3, 4, 5, 6, 7, 8}; + * std::cout << -q << std::endl; // [-1, -2, -3, -4, -5, -6, -7, -8] + * ``` + */ + DualQuat<_Tp> operator-() const; + + /** + * @brief return true if two dual quaternions p and q are nearly equal, i.e. when the absolute + * value of each \f$p_i\f$ and \f$q_i\f$ is less than CV_DUAL_QUAT_EPS. + */ + bool operator==(const DualQuat<_Tp>&) const; + + /** + * @brief Subtraction operator of two dual quaternions p and q. + * It returns a new dual quaternion that each value is the sum of \f$p_i\f$ and \f$-q_i\f$. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p - q << std::endl; //[-4, -4, -4, -4, 4, -4, -4, -4] + * ``` + */ + DualQuat<_Tp> operator-(const DualQuat<_Tp>&) const; + + /** + * @brief Subtraction assignment operator of two dual quaternions p and q. + * It subtracts right operand from the left operand and assign the result to left operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p -= q; // equivalent to p = p - q + * std::cout << p << std::endl; //[-4, -4, -4, -4, 4, -4, -4, -4] + * + * ``` + */ + DualQuat<_Tp>& operator-=(const DualQuat<_Tp>&); + + /** + * @brief Addition operator of two dual quaternions p and q. + * It returns a new dual quaternion that each value is the sum of \f$p_i\f$ and \f$q_i\f$. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p + q << std::endl; //[6, 8, 10, 12, 14, 16, 18, 20] + * ``` + */ + DualQuat<_Tp> operator+(const DualQuat<_Tp>&) const; + + /** + * @brief Addition assignment operator of two dual quaternions p and q. + * It adds right operand to the left operand and assign the result to left operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p += q; // equivalent to p = p + q + * std::cout << p << std::endl; //[6, 8, 10, 12, 14, 16, 18, 20] + * + * ``` + */ + DualQuat<_Tp>& operator+=(const DualQuat<_Tp>&); + + /** + * @brief Multiplication assignment operator of two quaternions. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication: + * The dual quaternion can be written as an ordered pair of quaternions [A, B]. Thus + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [A, B][C, D]\\ + * &=[AC, AD + BC] + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p *= q; + * std::cout << p << std::endl; //[-60, 12, 30, 24, -216, 80, 124, 120] + * ``` + */ + DualQuat<_Tp>& operator*=(const DualQuat<_Tp>&); + + /** + * @brief Multiplication assignment operator of a quaternions and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z, w\_, x\_, y\_, z\_] * s\\ + * &=[w s, x s, y s, z s, w\_ \space s, x\_ \space s, y\_ \space s, z\_ \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * p *= s; + * std::cout << p << std::endl; //[2, 4, 6, 8, 10, 12, 14, 16] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + DualQuat<_Tp> operator*=(const _Tp s); + + + /** + * @brief Multiplication operator of two dual quaternions q and p. + * Multiplies values on either side of the operator. + * + * Rule of dual quaternion multiplication: + * The dual quaternion can be written as an ordered pair of quaternions [A, B]. Thus + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [A, B][C, D]\\ + * &=[AC, AD + BC] + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p * q << std::endl; //[-60, 12, 30, 24, -216, 80, 124, 120] + * ``` + */ + DualQuat<_Tp> operator*(const DualQuat<_Tp>&) const; + + /** + * @brief Division operator of a dual quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of dual quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z, w\_, x\_, y\_, z\_] / s\\ + * &=[w/s, x/s, y/s, z/s, w\_/s, x\_/s, y\_/s, z\_/s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4] + * ``` + * @note the type of scalar should be equal to this dual quaternion. + */ + DualQuat<_Tp> operator/(const _Tp s) const; + + /** + * @brief Division operator of two dual quaternions p and q. + * Divides left hand operand by right hand operand. + * + * Rule of dual quaternion division with a dual quaternion: + * \f[ + * \begin{equation} + * \begin{split} + * p / q &= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * std::cout << p / q << std::endl; // equivalent to p * q.inv() + * ``` + */ + DualQuat<_Tp> operator/(const DualQuat<_Tp>&) const; + + /** + * @brief Division assignment operator of two dual quaternions p and q; + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of dual quaternion division with a quaternion: + * \f[ + * \begin{equation} + * \begin{split} + * p / q&= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * DualQuatd q{5, 6, 7, 8, 9, 10, 11, 12}; + * p /= q; // equivalent to p = p * q.inv() + * std::cout << p << std::endl; + * ``` + */ + DualQuat<_Tp>& operator/=(const DualQuat<_Tp>&); + + /** + * @brief Division assignment operator of a dual quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of dual quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z, w\_, x\_, y\_ ,z\_] / s\\ + * &=[w / s, x / s, y / s, z / s, w\_ / \space s, x\_ / \space s, y\_ / \space s, z\_ / \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0;; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + Quat<_Tp>& operator/=(const _Tp s); + + /** + * @brief Addition operator of a scalar and a dual quaternions. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << scalar + p << std::endl; //[3.0, 2, 3, 4, 5, 6, 7, 8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator+(const T s, const DualQuat&); + + /** + * @brief Addition operator of a dual quaternions and a scalar. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << p + scalar << std::endl; //[3.0, 2, 3, 4, 5, 6, 7, 8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator+(const DualQuat&, const T s); + + /** + * @brief Multiplication operator of a scalar and a dual quaternions. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z, w\_, x\_, y\_, z\_] * s\\ + * &=[w s, x s, y s, z s, w\_ \space s, x\_ \space s, y\_ \space s, z\_ \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * std::cout << s * p << std::endl; //[2, 4, 6, 8, 10, 12, 14, 16] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator*(const T s, const DualQuat&); + + /** + * @brief Subtraction operator of a dual quaternion and a scalar. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << p - scalar << std::endl; //[-1, 2, 3, 4, 5, 6, 7, 8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator-(const DualQuat&, const T s); + + /** + * @brief Subtraction operator of a scalar and a dual quaternions. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double scalar = 2.0; + * std::cout << scalar - p << std::endl; //[1.0, -2, -3, -4, -5, -6, -7, -8] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator-(const T s, const DualQuat&); + + /** + * @brief Multiplication operator of a dual quaternions and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of dual quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z, w\_, x\_, y\_, z\_] * s\\ + * &=[w s, x s, y s, z s, w\_ \space s, x\_ \space s, y\_ \space s, z\_ \space s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * DualQuatd p{1, 2, 3, 4, 5, 6, 7, 8}; + * double s = 2.0; + * std::cout << p * s << std::endl; //[2, 4, 6, 8, 10, 12, 14, 16] + * ``` + * @note the type of scalar should be equal to the dual quaternion. + */ + template + friend DualQuat cv::operator*(const DualQuat&, const T s); + + template + friend std::ostream& cv::operator<<(std::ostream&, const DualQuat&); + +}; + +using DualQuatd = DualQuat; +using DualQuatf = DualQuat; + +//! @} core +}//namespace + +#include "dualquaternion.inl.hpp" + +#endif /* OPENCV_CORE_QUATERNION_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/dualquaternion.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/dualquaternion.inl.hpp new file mode 100644 index 0000000..6abb159 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/dualquaternion.inl.hpp @@ -0,0 +1,487 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang + +#ifndef OPENCV_CORE_DUALQUATERNION_INL_HPP +#define OPENCV_CORE_DUALQUATERNION_INL_HPP + +#ifndef OPENCV_CORE_DUALQUATERNION_HPP +#error This is not a standalone header. Include dualquaternion.hpp instead. +#endif + +/////////////////////////////////////////////////////////////////////////////////////// +//Implementation +namespace cv { + +template +DualQuat::DualQuat():w(0), x(0), y(0), z(0), w_(0), x_(0), y_(0), z_(0){}; + +template +DualQuat::DualQuat(const T vw, const T vx, const T vy, const T vz, const T _w, const T _x, const T _y, const T _z): + w(vw), x(vx), y(vy), z(vz), w_(_w), x_(_x), y_(_y), z_(_z){}; + +template +DualQuat::DualQuat(const Vec &q):w(q[0]), x(q[1]), y(q[2]), z(q[3]), + w_(q[4]), x_(q[5]), y_(q[6]), z_(q[7]){}; + +template +DualQuat DualQuat::createFromQuat(const Quat &realPart, const Quat &dualPart) +{ + T w = realPart.w; + T x = realPart.x; + T y = realPart.y; + T z = realPart.z; + T w_ = dualPart.w; + T x_ = dualPart.x; + T y_ = dualPart.y; + T z_ = dualPart.z; + return DualQuat(w, x, y, z, w_, x_, y_, z_); +} + +template +DualQuat DualQuat::createFromAngleAxisTrans(const T angle, const Vec &axis, const Vec &trans) +{ + Quat r = Quat::createFromAngleAxis(angle, axis); + Quat t{0, trans[0], trans[1], trans[2]}; + return createFromQuat(r, t * r * T(0.5)); +} + +template +DualQuat DualQuat::createFromMat(InputArray _R) +{ + CV_CheckTypeEQ(_R.type(), cv::traits::Type::value, ""); + if (_R.size() != Size(4, 4)) + { + CV_Error(Error::StsBadArg, "The input matrix must have 4 columns and 4 rows"); + } + Mat R = _R.getMat(); + Quat r = Quat::createFromRotMat(R.colRange(0, 3).rowRange(0, 3)); + Quat trans(0, R.at(0, 3), R.at(1, 3), R.at(2, 3)); + return createFromQuat(r, trans * r * T(0.5)); +} + +template +DualQuat DualQuat::createFromAffine3(const Affine3 &R) +{ + return createFromMat(R.matrix); +} + +template +DualQuat DualQuat::createFromPitch(const T angle, const T d, const Vec &axis, const Vec &moment) +{ + T half_angle = angle * T(0.5), half_d = d * T(0.5); + Quat qaxis = Quat(0, axis[0], axis[1], axis[2]).normalize(); + Quat qmoment = Quat(0, moment[0], moment[1], moment[2]); + qmoment -= qaxis * axis.dot(moment); + Quat dual = -half_d * std::sin(half_angle) + std::sin(half_angle) * qmoment + + half_d * std::cos(half_angle) * qaxis; + return createFromQuat(Quat::createFromAngleAxis(angle, axis), dual); +} + +template +inline bool DualQuat::operator==(const DualQuat &q) const +{ + return (abs(w - q.w) < CV_DUAL_QUAT_EPS && abs(x - q.x) < CV_DUAL_QUAT_EPS && + abs(y - q.y) < CV_DUAL_QUAT_EPS && abs(z - q.z) < CV_DUAL_QUAT_EPS && + abs(w_ - q.w_) < CV_DUAL_QUAT_EPS && abs(x_ - q.x_) < CV_DUAL_QUAT_EPS && + abs(y_ - q.y_) < CV_DUAL_QUAT_EPS && abs(z_ - q.z_) < CV_DUAL_QUAT_EPS); +} + +template +inline Quat DualQuat::getRealPart() const +{ + return Quat(w, x, y, z); +} + +template +inline Quat DualQuat::getDualPart() const +{ + return Quat(w_, x_, y_, z_); +} + +template +inline DualQuat conjugate(const DualQuat &dq) +{ + return dq.conjugate(); +} + +template +inline DualQuat DualQuat::conjugate() const +{ + return DualQuat(w, -x, -y, -z, w_, -x_, -y_, -z_); +} + +template +DualQuat DualQuat::norm() const +{ + Quat real = getRealPart(); + T realNorm = real.norm(); + Quat dual = getDualPart(); + if (realNorm < CV_DUAL_QUAT_EPS){ + return DualQuat(0, 0, 0, 0, 0, 0, 0, 0); + } + return DualQuat(realNorm, 0, 0, 0, real.dot(dual) / realNorm, 0, 0, 0); +} + +template +inline Quat DualQuat::getRotation(QuatAssumeType assumeUnit) const +{ + if (assumeUnit) + { + return getRealPart(); + } + return getRealPart().normalize(); +} + +template +inline Vec DualQuat::getTranslation(QuatAssumeType assumeUnit) const +{ + Quat trans = T(2.0) * (getDualPart() * getRealPart().inv(assumeUnit)); + return Vec{trans[1], trans[2], trans[3]}; +} + +template +DualQuat DualQuat::normalize() const +{ + Quat p = getRealPart(); + Quat q = getDualPart(); + T p_norm = p.norm(); + if (p_norm < CV_DUAL_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "Cannot normalize this dual quaternion: the norm is too small."); + } + Quat p_nr = p / p_norm; + Quat q_nr = q / p_norm; + return createFromQuat(p_nr, q_nr - p_nr * p_nr.dot(q_nr)); +} + +template +inline T DualQuat::dot(DualQuat q) const +{ + return q.w * w + q.x * x + q.y * y + q.z * z + q.w_ * w_ + q.x_ * x_ + q.y_ * y_ + q.z_ * z_; +} + +template +inline DualQuat inv(const DualQuat &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return dq.inv(assumeUnit); +} + +template +inline DualQuat DualQuat::inv(QuatAssumeType assumeUnit) const +{ + Quat real = getRealPart(); + Quat dual = getDualPart(); + return createFromQuat(real.inv(assumeUnit), -real.inv(assumeUnit) * dual * real.inv(assumeUnit)); +} + +template +inline DualQuat DualQuat::operator-(const DualQuat &q) const +{ + return DualQuat(w - q.w, x - q.x, y - q.y, z - q.z, w_ - q.w_, x_ - q.x_, y_ - q.y_, z_ - q.z_); +} + +template +inline DualQuat DualQuat::operator-() const +{ + return DualQuat(-w, -x, -y, -z, -w_, -x_, -y_, -z_); +} + +template +inline DualQuat DualQuat::operator+(const DualQuat &q) const +{ + return DualQuat(w + q.w, x + q.x, y + q.y, z + q.z, w_ + q.w_, x_ + q.x_, y_ + q.y_, z_ + q.z_); +} + +template +inline DualQuat& DualQuat::operator+=(const DualQuat &q) +{ + *this = *this + q; + return *this; +} + +template +inline DualQuat DualQuat::operator*(const DualQuat &q) const +{ + Quat A = getRealPart(); + Quat B = getDualPart(); + Quat C = q.getRealPart(); + Quat D = q.getDualPart(); + return DualQuat::createFromQuat(A * C, A * D + B * C); +} + +template +inline DualQuat& DualQuat::operator*=(const DualQuat &q) +{ + *this = *this * q; + return *this; +} + +template +inline DualQuat operator+(const T a, const DualQuat &q) +{ + return DualQuat(a + q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_); +} + +template +inline DualQuat operator+(const DualQuat &q, const T a) +{ + return DualQuat(a + q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_); +} + +template +inline DualQuat operator-(const DualQuat &q, const T a) +{ + return DualQuat(q.w - a, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_); +} + +template +inline DualQuat& DualQuat::operator-=(const DualQuat &q) +{ + *this = *this - q; + return *this; +} + +template +inline DualQuat operator-(const T a, const DualQuat &q) +{ + return DualQuat(a - q.w, -q.x, -q.y, -q.z, -q.w_, -q.x_, -q.y_, -q.z_); +} + +template +inline DualQuat operator*(const T a, const DualQuat &q) +{ + return DualQuat(q.w * a, q.x * a, q.y * a, q.z * a, q.w_ * a, q.x_ * a, q.y_ * a, q.z_ * a); +} + +template +inline DualQuat operator*(const DualQuat &q, const T a) +{ + return DualQuat(q.w * a, q.x * a, q.y * a, q.z * a, q.w_ * a, q.x_ * a, q.y_ * a, q.z_ * a); +} + +template +inline DualQuat DualQuat::operator/(const T a) const +{ + return DualQuat(w / a, x / a, y / a, z / a, w_ / a, x_ / a, y_ / a, z_ / a); +} + +template +inline DualQuat DualQuat::operator/(const DualQuat &q) const +{ + return *this * q.inv(); +} + +template +inline DualQuat& DualQuat::operator/=(const DualQuat &q) +{ + *this = *this / q; + return *this; +} + +template +std::ostream & operator<<(std::ostream &os, const DualQuat &q) +{ + os << "DualQuat " << Vec{q.w, q.x, q.y, q.z, q.w_, q.x_, q.y_, q.z_}; + return os; +} + +template +inline DualQuat exp(const DualQuat &dq) +{ + return dq.exp(); +} + +namespace detail { + +template +Matx<_Tp, 4, 4> jacob_exp(const Quat<_Tp> &q) +{ + _Tp nv = std::sqrt(q.x * q.x + q.y * q.y + q.z * q.z); + _Tp sinc_nv = abs(nv) < cv::DualQuat<_Tp>::CV_DUAL_QUAT_EPS ? _Tp(1.0) - nv * nv * _Tp(1.0/6.0) : std::sin(nv) / nv; + _Tp csiii_nv = abs(nv) < cv::DualQuat<_Tp>::CV_DUAL_QUAT_EPS ? -_Tp(1.0/3.0) : (std::cos(nv) - sinc_nv) / nv / nv; + Matx<_Tp, 4, 4> J_exp_quat { + std::cos(nv), -sinc_nv * q.x, -sinc_nv * q.y, -sinc_nv * q.z, + sinc_nv * q.x, csiii_nv * q.x * q.x + sinc_nv, csiii_nv * q.x * q.y, csiii_nv * q.x * q.z, + sinc_nv * q.y, csiii_nv * q.y * q.x, csiii_nv * q.y * q.y + sinc_nv, csiii_nv * q.y * q.z, + sinc_nv * q.z, csiii_nv * q.z * q.x, csiii_nv * q.z * q.y, csiii_nv * q.z * q.z + sinc_nv + }; + return std::exp(q.w) * J_exp_quat; +} + +} // namespace detail + +template +DualQuat DualQuat::exp() const +{ + Quat real = getRealPart(); + return createFromQuat(real.exp(), Quat(detail::jacob_exp(real) * getDualPart().toVec())); +} + +template +DualQuat log(const DualQuat &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return dq.log(assumeUnit); +} + +template +DualQuat DualQuat::log(QuatAssumeType assumeUnit) const +{ + Quat plog = getRealPart().log(assumeUnit); + Matx jacob = detail::jacob_exp(plog); + return createFromQuat(plog, Quat(jacob.inv() * getDualPart().toVec())); +} + +template +inline DualQuat power(const DualQuat &dq, const T t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return dq.power(t, assumeUnit); +} + +template +inline DualQuat DualQuat::power(const T t, QuatAssumeType assumeUnit) const +{ + return (t * log(assumeUnit)).exp(); +} + +template +inline DualQuat power(const DualQuat &p, const DualQuat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) +{ + return p.power(q, assumeUnit); +} + +template +inline DualQuat DualQuat::power(const DualQuat &q, QuatAssumeType assumeUnit) const +{ + return (q * log(assumeUnit)).exp(); +} + +template +inline Vec DualQuat::toVec() const +{ + return Vec(w, x, y, z, w_, x_, y_, z_); +} + +template +Affine3 DualQuat::toAffine3(QuatAssumeType assumeUnit) const +{ + return Affine3(toMat(assumeUnit)); +} + +template +Matx DualQuat::toMat(QuatAssumeType assumeUnit) const +{ + Matx rot44 = getRotation(assumeUnit).toRotMat4x4(); + Vec translation = getTranslation(assumeUnit); + rot44(0, 3) = translation[0]; + rot44(1, 3) = translation[1]; + rot44(2, 3) = translation[2]; + return rot44; +} + +template +DualQuat DualQuat::sclerp(const DualQuat &q0, const DualQuat &q1, const T t, bool directChange, QuatAssumeType assumeUnit) +{ + DualQuat v0(q0), v1(q1); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + } + Quat v0Real = v0.getRealPart(); + Quat v1Real = v1.getRealPart(); + if (directChange && v1Real.dot(v0Real) < 0) + { + v0 = -v0; + } + DualQuat v0inv1 = v0.inv() * v1; + return v0 * v0inv1.power(t, QUAT_ASSUME_UNIT); +} + +template +DualQuat DualQuat::dqblend(const DualQuat &q1, const DualQuat &q2, const T t, QuatAssumeType assumeUnit) +{ + DualQuat v1(q1), v2(q2); + if (!assumeUnit) + { + v1 = v1.normalize(); + v2 = v2.normalize(); + } + if (v1.getRotation(assumeUnit).dot(v2.getRotation(assumeUnit)) < 0) + { + return ((1 - t) * v1 - t * v2).normalize(); + } + return ((1 - t) * v1 + t * v2).normalize(); +} + +template +DualQuat DualQuat::gdqblend(InputArray _dualquat, InputArray _weight, QuatAssumeType assumeUnit) +{ + CV_CheckTypeEQ(_weight.type(), cv::traits::Type::value, ""); + CV_CheckTypeEQ(_dualquat.type(), CV_MAKETYPE(CV_MAT_DEPTH(cv::traits::Type::value), 8), ""); + Size dq_s = _dualquat.size(); + if (dq_s != _weight.size() || (dq_s.height != 1 && dq_s.width != 1)) + { + CV_Error(Error::StsBadArg, "The size of weight must be the same as dualquat, both of them should be (1, n) or (n, 1)"); + } + Mat dualquat = _dualquat.getMat(), weight = _weight.getMat(); + const int cn = std::max(dq_s.width, dq_s.height); + if (!assumeUnit) + { + for (int i = 0; i < cn; ++i) + { + dualquat.at>(i) = DualQuat{dualquat.at>(i)}.normalize().toVec(); + } + } + Vec dq_blend = dualquat.at>(0) * weight.at(0); + Quat q0 = DualQuat {dualquat.at>(0)}.getRotation(assumeUnit); + for (int i = 1; i < cn; ++i) + { + T k = q0.dot(DualQuat{dualquat.at>(i)}.getRotation(assumeUnit)) < 0 ? -1: 1; + dq_blend = dq_blend + dualquat.at>(i) * k * weight.at(i); + } + return DualQuat{dq_blend}.normalize(); +} + +template +template +DualQuat DualQuat::gdqblend(const Vec, cn> &_dualquat, InputArray _weight, QuatAssumeType assumeUnit) +{ + Vec, cn> dualquat(_dualquat); + if (cn == 0) + { + return DualQuat(1, 0, 0, 0, 0, 0, 0, 0); + } + Mat dualquat_mat(cn, 1, CV_64FC(8)); + for (int i = 0; i < cn ; ++i) + { + dualquat_mat.at>(i) = dualquat[i].toVec(); + } + return gdqblend(dualquat_mat, _weight, assumeUnit); +} + +} //namespace cv + +#endif /*OPENCV_CORE_DUALQUATERNION_INL_HPP*/ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/eigen.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/eigen.hpp new file mode 100644 index 0000000..51f4147 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/eigen.hpp @@ -0,0 +1,402 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + + +#ifndef OPENCV_CORE_EIGEN_HPP +#define OPENCV_CORE_EIGEN_HPP + +#ifndef EIGEN_WORLD_VERSION +#error "Wrong usage of OpenCV's Eigen utility header. Include Eigen's headers first. See https://github.com/opencv/opencv/issues/17366" +#endif + +#include "opencv2/core.hpp" + +#if defined _MSC_VER && _MSC_VER >= 1200 +#define NOMINMAX // fix https://github.com/opencv/opencv/issues/17548 +#pragma warning( disable: 4714 ) //__forceinline is not inlined +#pragma warning( disable: 4127 ) //conditional expression is constant +#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data +#endif + +#if !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT) +#if EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 \ + && defined(CV_CXX11) && defined(CV_CXX_STD_ARRAY) +#include +#define OPENCV_EIGEN_TENSOR_SUPPORT 1 +#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 +#endif // !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT) + +namespace cv +{ + +/** @addtogroup core_eigen +These functions are provided for OpenCV-Eigen interoperability. They convert `Mat` +objects to corresponding `Eigen::Matrix` objects and vice-versa. Consult the [Eigen +documentation](https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html) for +information about the `Matrix` template type. + +@note Using these functions requires the `Eigen/Dense` or similar header to be +included before this header. +*/ +//! @{ + +#if defined(OPENCV_EIGEN_TENSOR_SUPPORT) || defined(CV_DOXYGEN) +/** @brief Converts an Eigen::Tensor to a cv::Mat. + +The method converts an Eigen::Tensor with shape (H x W x C) to a cv::Mat where: + H = number of rows + W = number of columns + C = number of channels + +Usage: +\code +Eigen::Tensor a_tensor(...); +// populate tensor with values +Mat a_mat; +eigen2cv(a_tensor, a_mat); +\endcode +*/ +template static inline +void eigen2cv( const Eigen::Tensor<_Tp, 3, _layout> &src, OutputArray dst ) +{ + if( !(_layout & Eigen::RowMajorBit) ) + { + const std::array shuffle{2, 1, 0}; + Eigen::Tensor<_Tp, 3, !_layout> row_major_tensor = src.swap_layout().shuffle(shuffle); + Mat _src(src.dimension(0), src.dimension(1), CV_MAKETYPE(DataType<_Tp>::type, src.dimension(2)), row_major_tensor.data()); + _src.copyTo(dst); + } + else + { + Mat _src(src.dimension(0), src.dimension(1), CV_MAKETYPE(DataType<_Tp>::type, src.dimension(2)), (void *)src.data()); + _src.copyTo(dst); + } +} + +/** @brief Converts a cv::Mat to an Eigen::Tensor. + +The method converts a cv::Mat to an Eigen Tensor with shape (H x W x C) where: + H = number of rows + W = number of columns + C = number of channels + +Usage: +\code +Mat a_mat(...); +// populate Mat with values +Eigen::Tensor a_tensor(...); +cv2eigen(a_mat, a_tensor); +\endcode +*/ +template static inline +void cv2eigen( const Mat &src, Eigen::Tensor<_Tp, 3, _layout> &dst ) +{ + if( !(_layout & Eigen::RowMajorBit) ) + { + Eigen::Tensor<_Tp, 3, !_layout> row_major_tensor(src.rows, src.cols, src.channels()); + Mat _dst(src.rows, src.cols, CV_MAKETYPE(DataType<_Tp>::type, src.channels()), row_major_tensor.data()); + if (src.type() == _dst.type()) + src.copyTo(_dst); + else + src.convertTo(_dst, _dst.type()); + const std::array shuffle{2, 1, 0}; + dst = row_major_tensor.swap_layout().shuffle(shuffle); + } + else + { + dst.resize(src.rows, src.cols, src.channels()); + Mat _dst(src.rows, src.cols, CV_MAKETYPE(DataType<_Tp>::type, src.channels()), dst.data()); + if (src.type() == _dst.type()) + src.copyTo(_dst); + else + src.convertTo(_dst, _dst.type()); + } +} + +/** @brief Maps cv::Mat data to an Eigen::TensorMap. + +The method wraps an existing Mat data array with an Eigen TensorMap of shape (H x W x C) where: + H = number of rows + W = number of columns + C = number of channels + +Explicit instantiation of the return type is required. + +@note Caller should be aware of the lifetime of the cv::Mat instance and take appropriate safety measures. +The cv::Mat instance will retain ownership of the data and the Eigen::TensorMap will lose access when the cv::Mat data is deallocated. + +The example below initializes a cv::Mat and produces an Eigen::TensorMap: +\code +float arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; +Mat a_mat(2, 2, CV_32FC3, arr); +Eigen::TensorMap> a_tensormap = cv2eigen_tensormap(a_mat); +\endcode +*/ +template static inline +Eigen::TensorMap> cv2eigen_tensormap(InputArray src) +{ + Mat mat = src.getMat(); + CV_CheckTypeEQ(mat.type(), CV_MAKETYPE(traits::Type<_Tp>::value, mat.channels()), ""); + return Eigen::TensorMap>((_Tp *)mat.data, mat.rows, mat.cols, mat.channels()); +} +#endif // OPENCV_EIGEN_TENSOR_SUPPORT + +template static inline +void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, OutputArray dst ) +{ + if( !(src.Flags & Eigen::RowMajorBit) ) + { + Mat _src(src.cols(), src.rows(), traits::Type<_Tp>::value, + (void*)src.data(), src.outerStride()*sizeof(_Tp)); + transpose(_src, dst); + } + else + { + Mat _src(src.rows(), src.cols(), traits::Type<_Tp>::value, + (void*)src.data(), src.outerStride()*sizeof(_Tp)); + _src.copyTo(dst); + } +} + +// Matx case +template static inline +void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, + Matx<_Tp, _rows, _cols>& dst ) +{ + if( !(src.Flags & Eigen::RowMajorBit) ) + { + dst = Matx<_Tp, _cols, _rows>(static_cast(src.data())).t(); + } + else + { + dst = Matx<_Tp, _rows, _cols>(static_cast(src.data())); + } +} + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) +{ + CV_DbgAssert(src.rows == _rows && src.cols == _cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else if( src.cols == src.rows ) + { + src.convertTo(_dst, _dst.type()); + transpose(_dst, _dst); + } + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +// Matx case +template static inline +void cv2eigen( const Matx<_Tp, _rows, _cols>& src, + Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) +{ + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(_cols, _rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(_rows, _cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + Mat(src).copyTo(_dst); + } +} + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) +{ + dst.resize(src.rows, src.cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else if( src.cols == src.rows ) + { + src.convertTo(_dst, _dst.type()); + transpose(_dst, _dst); + } + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +// Matx case +template static inline +void cv2eigen( const Matx<_Tp, _rows, _cols>& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) +{ + dst.resize(_rows, _cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(_cols, _rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(_rows, _cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + Mat(src).copyTo(_dst); + } +} + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) +{ + CV_Assert(src.cols == 1); + dst.resize(src.rows); + + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +// Matx case +template static inline +void cv2eigen( const Matx<_Tp, _rows, 1>& src, + Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) +{ + dst.resize(_rows); + + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(1, _rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(_rows, 1, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.copyTo(_dst); + } +} + + +template static inline +void cv2eigen( const Mat& src, + Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) +{ + CV_Assert(src.rows == 1); + dst.resize(src.cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + if( src.type() == _dst.type() ) + transpose(src, _dst); + else + Mat(src.t()).convertTo(_dst, _dst.type()); + } + else + { + const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + src.convertTo(_dst, _dst.type()); + } +} + +//Matx +template static inline +void cv2eigen( const Matx<_Tp, 1, _cols>& src, + Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) +{ + dst.resize(_cols); + if( !(dst.Flags & Eigen::RowMajorBit) ) + { + const Mat _dst(_cols, 1, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + transpose(src, _dst); + } + else + { + const Mat _dst(1, _cols, traits::Type<_Tp>::value, + dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp))); + Mat(src).copyTo(_dst); + } +} + +//! @} + +} // cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/fast_math.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/fast_math.hpp new file mode 100644 index 0000000..eb4fbe2 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/fast_math.hpp @@ -0,0 +1,411 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_FAST_MATH_HPP +#define OPENCV_CORE_FAST_MATH_HPP + +#include "opencv2/core/cvdef.h" + +//! @addtogroup core_utils +//! @{ + +/****************************************************************************************\ +* fast math * +\****************************************************************************************/ + +#ifdef __cplusplus +# include +#else +# ifdef __BORLANDC__ +# include +# else +# include +# endif +#endif + +#if defined(__CUDACC__) + // nothing, intrinsics/asm code is not supported +#else + #if ((defined _MSC_VER && defined _M_X64) \ + || (defined __GNUC__ && defined __x86_64__ && defined __SSE2__)) \ + && !defined(OPENCV_SKIP_INCLUDE_EMMINTRIN_H) + #include + #endif + + #if defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 \ + && !defined(OPENCV_SKIP_INCLUDE_ALTIVEC_H) + #include + #undef vector + #undef bool + #undef pixel + #endif + + #if defined(CV_INLINE_ROUND_FLT) + // user-specified version + // CV_INLINE_ROUND_DBL should be defined too + #elif defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ + // 1. general scheme + #define ARM_ROUND(_value, _asm_string) \ + int res; \ + float temp; \ + CV_UNUSED(temp); \ + __asm__(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \ + return res + // 2. version for double + #ifdef __clang__ + #define CV_INLINE_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %[value] \n vmov %[res], %[temp]") + #else + #define CV_INLINE_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %P[value] \n vmov %[res], %[temp]") + #endif + // 3. version for float + #define CV_INLINE_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]") + #elif defined __PPC64__ && defined __GNUC__ && defined _ARCH_PWR8 + // P8 and newer machines can convert fp32/64 to int quickly. + #define CV_INLINE_ROUND_DBL(value) \ + int out; \ + double temp; \ + __asm__( "fctiw %[temp],%[in]\n\tmfvsrwz %[out],%[temp]\n\t" : [out] "=r" (out), [temp] "=d" (temp) : [in] "d" ((double)(value)) : ); \ + return out; + + // FP32 also works with FP64 routine above + #define CV_INLINE_ROUND_FLT(value) CV_INLINE_ROUND_DBL(value) + #endif + + #ifdef CV_INLINE_ISINF_FLT + // user-specified version + // CV_INLINE_ISINF_DBL should be defined too + #elif defined __PPC64__ && defined _ARCH_PWR9 && defined(scalar_test_data_class) + #define CV_INLINE_ISINF_DBL(value) return scalar_test_data_class(value, 0x30); + #define CV_INLINE_ISINF_FLT(value) CV_INLINE_ISINF_DBL(value) + #endif + + #ifdef CV_INLINE_ISNAN_FLT + // user-specified version + // CV_INLINE_ISNAN_DBL should be defined too + #elif defined __PPC64__ && defined _ARCH_PWR9 && defined(scalar_test_data_class) + #define CV_INLINE_ISNAN_DBL(value) return scalar_test_data_class(value, 0x40); + #define CV_INLINE_ISNAN_FLT(value) CV_INLINE_ISNAN_DBL(value) + #endif + + #if !defined(OPENCV_USE_FASTMATH_BUILTINS) \ + && ( \ + defined(__x86_64__) || defined(__i686__) \ + || defined(__arm__) \ + || defined(__PPC64__) \ + ) + /* Let builtin C math functions when available. Dedicated hardware is available to + round and convert FP values. */ + #define OPENCV_USE_FASTMATH_BUILTINS 1 + #endif + + /* Enable builtin math functions if possible, desired, and available. + Note, not all math functions inline equally. E.g lrint will not inline + without the -fno-math-errno option. */ + #if defined(CV_ICC) + // nothing + #elif defined(OPENCV_USE_FASTMATH_BUILTINS) && OPENCV_USE_FASTMATH_BUILTINS + #if defined(__clang__) + #define CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS + #if !defined(CV_INLINE_ISNAN_DBL) && __has_builtin(__builtin_isnan) + #define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value); + #endif + #if !defined(CV_INLINE_ISNAN_FLT) && __has_builtin(__builtin_isnan) + #define CV_INLINE_ISNAN_FLT(value) return __builtin_isnan(value); + #endif + #if !defined(CV_INLINE_ISINF_DBL) && __has_builtin(__builtin_isinf) + #define CV_INLINE_ISINF_DBL(value) return __builtin_isinf(value); + #endif + #if !defined(CV_INLINE_ISINF_FLT) && __has_builtin(__builtin_isinf) + #define CV_INLINE_ISINF_FLT(value) return __builtin_isinf(value); + #endif + #elif defined(__GNUC__) + #define CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS + #if !defined(CV_INLINE_ISNAN_DBL) + #define CV_INLINE_ISNAN_DBL(value) return __builtin_isnan(value); + #endif + #if !defined(CV_INLINE_ISNAN_FLT) + #define CV_INLINE_ISNAN_FLT(value) return __builtin_isnanf(value); + #endif + #if !defined(CV_INLINE_ISINF_DBL) + #define CV_INLINE_ISINF_DBL(value) return __builtin_isinf(value); + #endif + #if !defined(CV_INLINE_ISINF_FLT) + #define CV_INLINE_ISINF_FLT(value) return __builtin_isinff(value); + #endif + #elif defined(_MSC_VER) + #if !defined(CV_INLINE_ISNAN_DBL) + #define CV_INLINE_ISNAN_DBL(value) return isnan(value); + #endif + #if !defined(CV_INLINE_ISNAN_FLT) + #define CV_INLINE_ISNAN_FLT(value) return isnan(value); + #endif + #if !defined(CV_INLINE_ISINF_DBL) + #define CV_INLINE_ISINF_DBL(value) return isinf(value); + #endif + #if !defined(CV_INLINE_ISINF_FLT) + #define CV_INLINE_ISINF_FLT(value) return isinf(value); + #endif + #endif + #endif + +#endif // defined(__CUDACC__) + +/** @brief Rounds floating-point number to the nearest integer + + @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the + result is not defined. + */ +CV_INLINE int +cvRound( double value ) +{ +#if defined CV_INLINE_ROUND_DBL + CV_INLINE_ROUND_DBL(value); +#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \ + && defined __SSE2__ && !defined __APPLE__) || CV_SSE2) \ + && !defined(__CUDACC__) + __m128d t = _mm_set_sd( value ); + return _mm_cvtsd_si32(t); +#elif defined _MSC_VER && defined _M_IX86 + int t; + __asm + { + fld value; + fistp t; + } + return t; +#elif defined CV_ICC || defined __GNUC__ + return (int)(lrint(value)); +#else + /* it's ok if round does not comply with IEEE754 standard; + the tests should allow +/-1 difference when the tested functions use round */ + return (int)(value + (value >= 0 ? 0.5 : -0.5)); +#endif +} + + +/** @brief Rounds floating-point number to the nearest integer not larger than the original. + + The function computes an integer i such that: + \f[i \le \texttt{value} < i+1\f] + @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the + result is not defined. + */ +CV_INLINE int cvFloor( double value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_floor(value); +#else + int i = (int)value; + return i - (i > value); +#endif +} + +/** @brief Rounds floating-point number to the nearest integer not smaller than the original. + + The function computes an integer i such that: + \f[i \le \texttt{value} < i+1\f] + @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the + result is not defined. + */ +CV_INLINE int cvCeil( double value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_ceil(value); +#else + int i = (int)value; + return i + (i < value); +#endif +} + +/** @brief Determines if the argument is Not A Number. + + @param value The input floating-point value + + The function returns 1 if the argument is Not A Number (as defined by IEEE754 standard), 0 + otherwise. */ +CV_INLINE int cvIsNaN( double value ) +{ +#if defined CV_INLINE_ISNAN_DBL + CV_INLINE_ISNAN_DBL(value); +#else + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) + + ((unsigned)ieee754.u != 0) > 0x7ff00000; +#endif +} + +/** @brief Determines if the argument is Infinity. + + @param value The input floating-point value + + The function returns 1 if the argument is a plus or minus infinity (as defined by IEEE754 standard) + and 0 otherwise. */ +CV_INLINE int cvIsInf( double value ) +{ +#if defined CV_INLINE_ISINF_DBL + CV_INLINE_ISINF_DBL(value); +#elif defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__PPC64__) + Cv64suf ieee754; + ieee754.f = value; + return (ieee754.u & 0x7fffffff00000000) == + 0x7ff0000000000000; +#else + Cv64suf ieee754; + ieee754.f = value; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && + (unsigned)ieee754.u == 0; +#endif +} + +#ifdef __cplusplus + +/** @overload */ +CV_INLINE int cvRound(float value) +{ +#if defined CV_INLINE_ROUND_FLT + CV_INLINE_ROUND_FLT(value); +#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \ + && defined __SSE2__ && !defined __APPLE__) || CV_SSE2) \ + && !defined(__CUDACC__) + __m128 t = _mm_set_ss( value ); + return _mm_cvtss_si32(t); +#elif defined _MSC_VER && defined _M_IX86 + int t; + __asm + { + fld value; + fistp t; + } + return t; +#elif defined CV_ICC || defined __GNUC__ + return (int)(lrintf(value)); +#else + /* it's ok if round does not comply with IEEE754 standard; + the tests should allow +/-1 difference when the tested functions use round */ + return (int)(value + (value >= 0 ? 0.5f : -0.5f)); +#endif +} + +/** @overload */ +CV_INLINE int cvRound( int value ) +{ + return value; +} + +/** @overload */ +CV_INLINE int cvFloor( float value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_floorf(value); +#else + int i = (int)value; + return i - (i > value); +#endif +} + +/** @overload */ +CV_INLINE int cvFloor( int value ) +{ + return value; +} + +/** @overload */ +CV_INLINE int cvCeil( float value ) +{ +#if (defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS) \ + && ( \ + defined(__PPC64__) \ + ) + return __builtin_ceilf(value); +#else + int i = (int)value; + return i + (i < value); +#endif +} + +/** @overload */ +CV_INLINE int cvCeil( int value ) +{ + return value; +} + +/** @overload */ +CV_INLINE int cvIsNaN( float value ) +{ +#if defined CV_INLINE_ISNAN_FLT + CV_INLINE_ISNAN_FLT(value); +#else + Cv32suf ieee754; + ieee754.f = value; + return (ieee754.u & 0x7fffffff) > 0x7f800000; +#endif +} + +/** @overload */ +CV_INLINE int cvIsInf( float value ) +{ +#if defined CV_INLINE_ISINF_FLT + CV_INLINE_ISINF_FLT(value); +#else + Cv32suf ieee754; + ieee754.f = value; + return (ieee754.u & 0x7fffffff) == 0x7f800000; +#endif +} + +#endif // __cplusplus + +//! @} core_utils + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/hal.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/hal.hpp new file mode 100644 index 0000000..0d68078 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/hal.hpp @@ -0,0 +1,256 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_HPP +#define OPENCV_HAL_HPP + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/hal/interface.h" + +namespace cv { namespace hal { + +//! @addtogroup core_hal_functions +//! @{ + +CV_EXPORTS int normHamming(const uchar* a, int n); +CV_EXPORTS int normHamming(const uchar* a, const uchar* b, int n); + +CV_EXPORTS int normHamming(const uchar* a, int n, int cellSize); +CV_EXPORTS int normHamming(const uchar* a, const uchar* b, int n, int cellSize); + +CV_EXPORTS int LU32f(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS int LU64f(double* A, size_t astep, int m, double* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky32f(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky64f(double* A, size_t astep, int m, double* b, size_t bstep, int n); +CV_EXPORTS void SVD32f(float* At, size_t astep, float* W, float* U, size_t ustep, float* Vt, size_t vstep, int m, int n, int flags); +CV_EXPORTS void SVD64f(double* At, size_t astep, double* W, double* U, size_t ustep, double* Vt, size_t vstep, int m, int n, int flags); +CV_EXPORTS int QR32f(float* A, size_t astep, int m, int n, int k, float* b, size_t bstep, float* hFactors); +CV_EXPORTS int QR64f(double* A, size_t astep, int m, int n, int k, double* b, size_t bstep, double* hFactors); + +CV_EXPORTS void gemm32f(const float* src1, size_t src1_step, const float* src2, size_t src2_step, + float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); +CV_EXPORTS void gemm64f(const double* src1, size_t src1_step, const double* src2, size_t src2_step, + double alpha, const double* src3, size_t src3_step, double beta, double* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); +CV_EXPORTS void gemm32fc(const float* src1, size_t src1_step, const float* src2, size_t src2_step, + float alpha, const float* src3, size_t src3_step, float beta, float* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); +CV_EXPORTS void gemm64fc(const double* src1, size_t src1_step, const double* src2, size_t src2_step, + double alpha, const double* src3, size_t src3_step, double beta, double* dst, size_t dst_step, + int m_a, int n_a, int n_d, int flags); + +CV_EXPORTS int normL1_(const uchar* a, const uchar* b, int n); +CV_EXPORTS float normL1_(const float* a, const float* b, int n); +CV_EXPORTS float normL2Sqr_(const float* a, const float* b, int n); + +CV_EXPORTS void exp32f(const float* src, float* dst, int n); +CV_EXPORTS void exp64f(const double* src, double* dst, int n); +CV_EXPORTS void log32f(const float* src, float* dst, int n); +CV_EXPORTS void log64f(const double* src, double* dst, int n); + +CV_EXPORTS void fastAtan32f(const float* y, const float* x, float* dst, int n, bool angleInDegrees); +CV_EXPORTS void fastAtan64f(const double* y, const double* x, double* dst, int n, bool angleInDegrees); +CV_EXPORTS void magnitude32f(const float* x, const float* y, float* dst, int n); +CV_EXPORTS void magnitude64f(const double* x, const double* y, double* dst, int n); +CV_EXPORTS void sqrt32f(const float* src, float* dst, int len); +CV_EXPORTS void sqrt64f(const double* src, double* dst, int len); +CV_EXPORTS void invSqrt32f(const float* src, float* dst, int len); +CV_EXPORTS void invSqrt64f(const double* src, double* dst, int len); + +CV_EXPORTS void split8u(const uchar* src, uchar** dst, int len, int cn ); +CV_EXPORTS void split16u(const ushort* src, ushort** dst, int len, int cn ); +CV_EXPORTS void split32s(const int* src, int** dst, int len, int cn ); +CV_EXPORTS void split64s(const int64* src, int64** dst, int len, int cn ); + +CV_EXPORTS void merge8u(const uchar** src, uchar* dst, int len, int cn ); +CV_EXPORTS void merge16u(const ushort** src, ushort* dst, int len, int cn ); +CV_EXPORTS void merge32s(const int** src, int* dst, int len, int cn ); +CV_EXPORTS void merge64s(const int64** src, int64* dst, int len, int cn ); + +CV_EXPORTS void add8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void add64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void sub8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void sub64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void max8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void max64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void min8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void min64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void absdiff8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void absdiff64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void and8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void or8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void xor8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); +CV_EXPORTS void not8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* ); + +CV_EXPORTS void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp8s(const schar* src1, size_t step1, const schar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp16s(const short* src1, size_t step1, const short* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp32s(const int* src1, size_t step1, const int* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp32f(const float* src1, size_t step1, const float* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); +CV_EXPORTS void cmp64f(const double* src1, size_t step1, const double* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _cmpop); + +CV_EXPORTS void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void mul64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale); + +CV_EXPORTS void div8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void div64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scale); + +CV_EXPORTS void recip8u( const uchar *, size_t, const uchar * src2, size_t step2, uchar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip8s( const schar *, size_t, const schar * src2, size_t step2, schar* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip16u( const ushort *, size_t, const ushort * src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip16s( const short *, size_t, const short * src2, size_t step2, short* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip32s( const int *, size_t, const int * src2, size_t step2, int* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip32f( const float *, size_t, const float * src2, size_t step2, float* dst, size_t step, int width, int height, void* scale); +CV_EXPORTS void recip64f( const double *, size_t, const double * src2, size_t step2, double* dst, size_t step, int width, int height, void* scale); + +CV_EXPORTS void addWeighted8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, int width, int height, void* _scalars ); +CV_EXPORTS void addWeighted8s( const schar* src1, size_t step1, const schar* src2, size_t step2, schar* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted32s( const int* src1, size_t step1, const int* src2, size_t step2, int* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, int width, int height, void* scalars ); +CV_EXPORTS void addWeighted64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, int width, int height, void* scalars ); + +CV_EXPORTS void cvt16f32f( const float16_t* src, float* dst, int len ); +CV_EXPORTS void cvt32f16f( const float* src, float16_t* dst, int len ); + +CV_EXPORTS void addRNGBias32f( float* arr, const float* scaleBiasPairs, int len ); +CV_EXPORTS void addRNGBias64f( double* arr, const double* scaleBiasPairs, int len ); + +struct CV_EXPORTS DFT1D +{ + static Ptr create(int len, int count, int depth, int flags, bool * useBuffer = 0); + virtual void apply(const uchar *src, uchar *dst) = 0; + virtual ~DFT1D() {} +}; + +struct CV_EXPORTS DFT2D +{ + static Ptr create(int width, int height, int depth, + int src_channels, int dst_channels, + int flags, int nonzero_rows = 0); + virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; + virtual ~DFT2D() {} +}; + +struct CV_EXPORTS DCT2D +{ + static Ptr create(int width, int height, int depth, int flags); + virtual void apply(const uchar *src_data, size_t src_step, uchar *dst_data, size_t dst_step) = 0; + virtual ~DCT2D() {} +}; + +//! @} core_hal + +//============================================================================= +// for binary compatibility with 3.0 + +//! @cond IGNORED + +CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n); +CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n); + +CV_EXPORTS void exp(const float* src, float* dst, int n); +CV_EXPORTS void exp(const double* src, double* dst, int n); +CV_EXPORTS void log(const float* src, float* dst, int n); +CV_EXPORTS void log(const double* src, double* dst, int n); + +CV_EXPORTS void fastAtan2(const float* y, const float* x, float* dst, int n, bool angleInDegrees); +CV_EXPORTS void magnitude(const float* x, const float* y, float* dst, int n); +CV_EXPORTS void magnitude(const double* x, const double* y, double* dst, int n); +CV_EXPORTS void sqrt(const float* src, float* dst, int len); +CV_EXPORTS void sqrt(const double* src, double* dst, int len); +CV_EXPORTS void invSqrt(const float* src, float* dst, int len); +CV_EXPORTS void invSqrt(const double* src, double* dst, int len); + +//! @endcond + +}} //cv::hal + +#endif //OPENCV_HAL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/interface.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/interface.h new file mode 100644 index 0000000..6f0a83d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/interface.h @@ -0,0 +1,190 @@ +#ifndef OPENCV_CORE_HAL_INTERFACE_H +#define OPENCV_CORE_HAL_INTERFACE_H + +//! @addtogroup core_hal_interface +//! @{ + +//! @name Return codes +//! @{ +#define CV_HAL_ERROR_OK 0 +#define CV_HAL_ERROR_NOT_IMPLEMENTED 1 +#define CV_HAL_ERROR_UNKNOWN -1 +//! @} + +#ifdef __cplusplus +#include +#else +#include +#include +#endif + +//! @name Data types +//! primitive types +//! - schar - signed 1 byte integer +//! - uchar - unsigned 1 byte integer +//! - short - signed 2 byte integer +//! - ushort - unsigned 2 byte integer +//! - int - signed 4 byte integer +//! - uint - unsigned 4 byte integer +//! - int64 - signed 8 byte integer +//! - uint64 - unsigned 8 byte integer +//! @{ +#if !defined _MSC_VER && !defined __BORLANDC__ +# if defined __cplusplus && __cplusplus >= 201103L && !defined __APPLE__ +# include +# ifdef __NEWLIB__ + typedef unsigned int uint; +# else + typedef std::uint32_t uint; +# endif +# else +# include + typedef uint32_t uint; +# endif +#else + typedef unsigned uint; +#endif + +typedef signed char schar; + +#ifndef __IPL_H__ + typedef unsigned char uchar; + typedef unsigned short ushort; +#endif + +#if defined _MSC_VER || defined __BORLANDC__ + typedef __int64 int64; + typedef unsigned __int64 uint64; +# define CV_BIG_INT(n) n##I64 +# define CV_BIG_UINT(n) n##UI64 +#else + typedef int64_t int64; + typedef uint64_t uint64; +# define CV_BIG_INT(n) n##LL +# define CV_BIG_UINT(n) n##ULL +#endif + +#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" + +#define CV_CN_MAX 512 +#define CV_CN_SHIFT 3 +#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) + +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 +#define CV_16F 7 + +#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) +#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) + +#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKE_TYPE CV_MAKETYPE + +#define CV_8UC1 CV_MAKETYPE(CV_8U,1) +#define CV_8UC2 CV_MAKETYPE(CV_8U,2) +#define CV_8UC3 CV_MAKETYPE(CV_8U,3) +#define CV_8UC4 CV_MAKETYPE(CV_8U,4) +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) + +#define CV_8SC1 CV_MAKETYPE(CV_8S,1) +#define CV_8SC2 CV_MAKETYPE(CV_8S,2) +#define CV_8SC3 CV_MAKETYPE(CV_8S,3) +#define CV_8SC4 CV_MAKETYPE(CV_8S,4) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) + +#define CV_16UC1 CV_MAKETYPE(CV_16U,1) +#define CV_16UC2 CV_MAKETYPE(CV_16U,2) +#define CV_16UC3 CV_MAKETYPE(CV_16U,3) +#define CV_16UC4 CV_MAKETYPE(CV_16U,4) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) + +#define CV_16SC1 CV_MAKETYPE(CV_16S,1) +#define CV_16SC2 CV_MAKETYPE(CV_16S,2) +#define CV_16SC3 CV_MAKETYPE(CV_16S,3) +#define CV_16SC4 CV_MAKETYPE(CV_16S,4) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_32SC1 CV_MAKETYPE(CV_32S,1) +#define CV_32SC2 CV_MAKETYPE(CV_32S,2) +#define CV_32SC3 CV_MAKETYPE(CV_32S,3) +#define CV_32SC4 CV_MAKETYPE(CV_32S,4) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) + +#define CV_32FC1 CV_MAKETYPE(CV_32F,1) +#define CV_32FC2 CV_MAKETYPE(CV_32F,2) +#define CV_32FC3 CV_MAKETYPE(CV_32F,3) +#define CV_32FC4 CV_MAKETYPE(CV_32F,4) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) + +#define CV_64FC1 CV_MAKETYPE(CV_64F,1) +#define CV_64FC2 CV_MAKETYPE(CV_64F,2) +#define CV_64FC3 CV_MAKETYPE(CV_64F,3) +#define CV_64FC4 CV_MAKETYPE(CV_64F,4) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + +#define CV_16FC1 CV_MAKETYPE(CV_16F,1) +#define CV_16FC2 CV_MAKETYPE(CV_16F,2) +#define CV_16FC3 CV_MAKETYPE(CV_16F,3) +#define CV_16FC4 CV_MAKETYPE(CV_16F,4) +#define CV_16FC(n) CV_MAKETYPE(CV_16F,(n)) +//! @} + +//! @name Comparison operation +//! @sa cv::CmpTypes +//! @{ +#define CV_HAL_CMP_EQ 0 +#define CV_HAL_CMP_GT 1 +#define CV_HAL_CMP_GE 2 +#define CV_HAL_CMP_LT 3 +#define CV_HAL_CMP_LE 4 +#define CV_HAL_CMP_NE 5 +//! @} + +//! @name Border processing modes +//! @sa cv::BorderTypes +//! @{ +#define CV_HAL_BORDER_CONSTANT 0 +#define CV_HAL_BORDER_REPLICATE 1 +#define CV_HAL_BORDER_REFLECT 2 +#define CV_HAL_BORDER_WRAP 3 +#define CV_HAL_BORDER_REFLECT_101 4 +#define CV_HAL_BORDER_TRANSPARENT 5 +#define CV_HAL_BORDER_ISOLATED 16 +//! @} + +//! @name DFT flags +//! @{ +#define CV_HAL_DFT_INVERSE 1 +#define CV_HAL_DFT_SCALE 2 +#define CV_HAL_DFT_ROWS 4 +#define CV_HAL_DFT_COMPLEX_OUTPUT 16 +#define CV_HAL_DFT_REAL_OUTPUT 32 +#define CV_HAL_DFT_TWO_STAGE 64 +#define CV_HAL_DFT_STAGE_COLS 128 +#define CV_HAL_DFT_IS_CONTINUOUS 512 +#define CV_HAL_DFT_IS_INPLACE 1024 +//! @} + +//! @name SVD flags +//! @{ +#define CV_HAL_SVD_NO_UV 1 +#define CV_HAL_SVD_SHORT_UV 2 +#define CV_HAL_SVD_MODIFY_A 4 +#define CV_HAL_SVD_FULL_UV 8 +//! @} + +//! @name Gemm flags +//! @{ +#define CV_HAL_GEMM_1_T 1 +#define CV_HAL_GEMM_2_T 2 +#define CV_HAL_GEMM_3_T 4 +//! @} + +//! @} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin.hpp new file mode 100644 index 0000000..ac331f2 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin.hpp @@ -0,0 +1,706 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_INTRIN_HPP +#define OPENCV_HAL_INTRIN_HPP + +#include +#include +#include +#include "opencv2/core/cvdef.h" + +#define OPENCV_HAL_ADD(a, b) ((a) + (b)) +#define OPENCV_HAL_AND(a, b) ((a) & (b)) +#define OPENCV_HAL_NOP(a) (a) +#define OPENCV_HAL_1ST(a, b) (a) + +namespace { +inline unsigned int trailingZeros32(unsigned int value) { +#if defined(_MSC_VER) +#if (_MSC_VER < 1700) || defined(_M_ARM) || defined(_M_ARM64) + unsigned long index = 0; + _BitScanForward(&index, value); + return (unsigned int)index; +#elif defined(__clang__) + // clang-cl doesn't export _tzcnt_u32 for non BMI systems + return value ? __builtin_ctz(value) : 32; +#else + return _tzcnt_u32(value); +#endif +#elif defined(__GNUC__) || defined(__GNUG__) + return __builtin_ctz(value); +#elif defined(__ICC) || defined(__INTEL_COMPILER) + return _bit_scan_forward(value); +#elif defined(__clang__) + return llvm.cttz.i32(value, true); +#else + static const int MultiplyDeBruijnBitPosition[32] = { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; + return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27]; +#endif +} +} + +// unlike HAL API, which is in cv::hal, +// we put intrinsics into cv namespace to make its +// access from within opencv code more accessible +namespace cv { + +namespace hal { + +enum StoreMode +{ + STORE_UNALIGNED = 0, + STORE_ALIGNED = 1, + STORE_ALIGNED_NOCACHE = 2 +}; + +} + +// TODO FIXIT: Don't use "God" traits. Split on separate cases. +template struct V_TypeTraits +{ +}; + +#define CV_INTRIN_DEF_TYPE_TRAITS(type, int_type_, uint_type_, abs_type_, w_type_, q_type_, sum_type_) \ + template<> struct V_TypeTraits \ + { \ + typedef type value_type; \ + typedef int_type_ int_type; \ + typedef abs_type_ abs_type; \ + typedef uint_type_ uint_type; \ + typedef w_type_ w_type; \ + typedef q_type_ q_type; \ + typedef sum_type_ sum_type; \ + \ + static inline int_type reinterpret_int(type x) \ + { \ + union { type l; int_type i; } v; \ + v.l = x; \ + return v.i; \ + } \ + \ + static inline type reinterpret_from_int(int_type x) \ + { \ + union { type l; int_type i; } v; \ + v.i = x; \ + return v.l; \ + } \ + } + +#define CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(type, int_type_, uint_type_, abs_type_, w_type_, sum_type_) \ + template<> struct V_TypeTraits \ + { \ + typedef type value_type; \ + typedef int_type_ int_type; \ + typedef abs_type_ abs_type; \ + typedef uint_type_ uint_type; \ + typedef w_type_ w_type; \ + typedef sum_type_ sum_type; \ + \ + static inline int_type reinterpret_int(type x) \ + { \ + union { type l; int_type i; } v; \ + v.l = x; \ + return v.i; \ + } \ + \ + static inline type reinterpret_from_int(int_type x) \ + { \ + union { type l; int_type i; } v; \ + v.i = x; \ + return v.l; \ + } \ + } + +CV_INTRIN_DEF_TYPE_TRAITS(uchar, schar, uchar, uchar, ushort, unsigned, unsigned); +CV_INTRIN_DEF_TYPE_TRAITS(schar, schar, uchar, uchar, short, int, int); +CV_INTRIN_DEF_TYPE_TRAITS(ushort, short, ushort, ushort, unsigned, uint64, unsigned); +CV_INTRIN_DEF_TYPE_TRAITS(short, short, ushort, ushort, int, int64, int); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(unsigned, int, unsigned, unsigned, uint64, unsigned); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(int, int, unsigned, unsigned, int64, int); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(float, int, unsigned, float, double, float); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(uint64, int64, uint64, uint64, void, uint64); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(int64, int64, uint64, uint64, void, int64); +CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(double, int64, uint64, double, void, double); + +#ifndef CV_DOXYGEN + +#ifndef CV_CPU_OPTIMIZATION_HAL_NAMESPACE +#ifdef CV_FORCE_SIMD128_CPP + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_EMULATOR_CPP + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_EMULATOR_CPP { + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END } +#elif defined(CV_CPU_DISPATCH_MODE) + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) { + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END } +#else + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline { + #define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END } +#endif +#endif // CV_CPU_OPTIMIZATION_HAL_NAMESPACE + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END +using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE; +#endif +} + +#ifdef CV_DOXYGEN +# undef CV_AVX2 +# undef CV_SSE2 +# undef CV_NEON +# undef CV_VSX +# undef CV_FP16 +# undef CV_MSA +# undef CV_RVV +#endif + +#if (CV_SSE2 || CV_NEON || CV_VSX || CV_MSA || CV_WASM_SIMD || CV_RVV071 || CV_RVV) && !defined(CV_FORCE_SIMD128_CPP) +#define CV__SIMD_FORWARD 128 +#include "opencv2/core/hal/intrin_forward.hpp" +#endif + +#if CV_SSE2 && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_sse_em.hpp" +#include "opencv2/core/hal/intrin_sse.hpp" + +#elif CV_NEON && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_neon.hpp" + +#elif CV_RVV071 && !defined(CV_FORCE_SIMD128_CPP) +#define CV_SIMD128_CPP 0 +#include "opencv2/core/hal/intrin_rvv071.hpp" + +#elif CV_VSX && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_vsx.hpp" + +#elif CV_MSA && !defined(CV_FORCE_SIMD128_CPP) + +#include "opencv2/core/hal/intrin_msa.hpp" + +#elif CV_WASM_SIMD && !defined(CV_FORCE_SIMD128_CPP) +#include "opencv2/core/hal/intrin_wasm.hpp" + +#elif CV_RVV && !defined(CV_FORCE_SIMD128_CPP) +#include "opencv2/core/hal/intrin_rvv.hpp" + +#else + +#include "opencv2/core/hal/intrin_cpp.hpp" + +#endif + +// AVX2 can be used together with SSE2, so +// we define those two sets of intrinsics at once. +// Most of the intrinsics do not conflict (the proper overloaded variant is +// resolved by the argument types, e.g. v_float32x4 ~ SSE2, v_float32x8 ~ AVX2), +// but some of AVX2 intrinsics get v256_ prefix instead of v_, e.g. v256_load() vs v_load(). +// Correspondingly, the wide intrinsics (which are mapped to the "widest" +// available instruction set) will get vx_ prefix +// (and will be mapped to v256_ counterparts) (e.g. vx_load() => v256_load()) +#if CV_AVX2 + +#define CV__SIMD_FORWARD 256 +#include "opencv2/core/hal/intrin_forward.hpp" +#include "opencv2/core/hal/intrin_avx.hpp" + +#endif + +// AVX512 can be used together with SSE2 and AVX2, so +// we define those sets of intrinsics at once. +// For some of AVX512 intrinsics get v512_ prefix instead of v_, e.g. v512_load() vs v_load(). +// Wide intrinsics will be mapped to v512_ counterparts in this case(e.g. vx_load() => v512_load()) +#if CV_AVX512_SKX + +#define CV__SIMD_FORWARD 512 +#include "opencv2/core/hal/intrin_forward.hpp" +#include "opencv2/core/hal/intrin_avx512.hpp" + +#endif + +//! @cond IGNORED + +namespace cv { + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN +#endif + +#ifndef CV_SIMD128 +#define CV_SIMD128 0 +#endif + +#ifndef CV_SIMD128_CPP +#define CV_SIMD128_CPP 0 +#endif + +#ifndef CV_SIMD128_64F +#define CV_SIMD128_64F 0 +#endif + +#ifndef CV_SIMD256 +#define CV_SIMD256 0 +#endif + +#ifndef CV_SIMD256_64F +#define CV_SIMD256_64F 0 +#endif + +#ifndef CV_SIMD512 +#define CV_SIMD512 0 +#endif + +#ifndef CV_SIMD512_64F +#define CV_SIMD512_64F 0 +#endif + +#ifndef CV_SIMD128_FP16 +#define CV_SIMD128_FP16 0 +#endif + +#ifndef CV_SIMD256_FP16 +#define CV_SIMD256_FP16 0 +#endif + +#ifndef CV_SIMD512_FP16 +#define CV_SIMD512_FP16 0 +#endif + +//================================================================================================== + +template struct V_RegTraits +{ +}; + +#define CV_DEF_REG_TRAITS(prefix, _reg, lane_type, suffix, _u_reg, _w_reg, _q_reg, _int_reg, _round_reg) \ + template<> struct V_RegTraits<_reg> \ + { \ + typedef _reg reg; \ + typedef _u_reg u_reg; \ + typedef _w_reg w_reg; \ + typedef _q_reg q_reg; \ + typedef _int_reg int_reg; \ + typedef _round_reg round_reg; \ + } + +#if CV_SIMD128 || CV_SIMD128_CPP + CV_DEF_REG_TRAITS(v, v_uint8x16, uchar, u8, v_uint8x16, v_uint16x8, v_uint32x4, v_int8x16, void); + CV_DEF_REG_TRAITS(v, v_int8x16, schar, s8, v_uint8x16, v_int16x8, v_int32x4, v_int8x16, void); + CV_DEF_REG_TRAITS(v, v_uint16x8, ushort, u16, v_uint16x8, v_uint32x4, v_uint64x2, v_int16x8, void); + CV_DEF_REG_TRAITS(v, v_int16x8, short, s16, v_uint16x8, v_int32x4, v_int64x2, v_int16x8, void); + CV_DEF_REG_TRAITS(v, v_uint32x4, unsigned, u32, v_uint32x4, v_uint64x2, void, v_int32x4, void); + CV_DEF_REG_TRAITS(v, v_int32x4, int, s32, v_uint32x4, v_int64x2, void, v_int32x4, void); +#if CV_SIMD128_64F || CV_SIMD128_CPP + CV_DEF_REG_TRAITS(v, v_float32x4, float, f32, v_float32x4, v_float64x2, void, v_int32x4, v_int32x4); +#else + CV_DEF_REG_TRAITS(v, v_float32x4, float, f32, v_float32x4, void, void, v_int32x4, v_int32x4); +#endif + CV_DEF_REG_TRAITS(v, v_uint64x2, uint64, u64, v_uint64x2, void, void, v_int64x2, void); + CV_DEF_REG_TRAITS(v, v_int64x2, int64, s64, v_uint64x2, void, void, v_int64x2, void); +#if CV_SIMD128_64F + CV_DEF_REG_TRAITS(v, v_float64x2, double, f64, v_float64x2, void, void, v_int64x2, v_int32x4); +#endif +#endif + +#if CV_SIMD256 + CV_DEF_REG_TRAITS(v256, v_uint8x32, uchar, u8, v_uint8x32, v_uint16x16, v_uint32x8, v_int8x32, void); + CV_DEF_REG_TRAITS(v256, v_int8x32, schar, s8, v_uint8x32, v_int16x16, v_int32x8, v_int8x32, void); + CV_DEF_REG_TRAITS(v256, v_uint16x16, ushort, u16, v_uint16x16, v_uint32x8, v_uint64x4, v_int16x16, void); + CV_DEF_REG_TRAITS(v256, v_int16x16, short, s16, v_uint16x16, v_int32x8, v_int64x4, v_int16x16, void); + CV_DEF_REG_TRAITS(v256, v_uint32x8, unsigned, u32, v_uint32x8, v_uint64x4, void, v_int32x8, void); + CV_DEF_REG_TRAITS(v256, v_int32x8, int, s32, v_uint32x8, v_int64x4, void, v_int32x8, void); + CV_DEF_REG_TRAITS(v256, v_float32x8, float, f32, v_float32x8, v_float64x4, void, v_int32x8, v_int32x8); + CV_DEF_REG_TRAITS(v256, v_uint64x4, uint64, u64, v_uint64x4, void, void, v_int64x4, void); + CV_DEF_REG_TRAITS(v256, v_int64x4, int64, s64, v_uint64x4, void, void, v_int64x4, void); + CV_DEF_REG_TRAITS(v256, v_float64x4, double, f64, v_float64x4, void, void, v_int64x4, v_int32x8); +#endif + +#if CV_SIMD512 + CV_DEF_REG_TRAITS(v512, v_uint8x64, uchar, u8, v_uint8x64, v_uint16x32, v_uint32x16, v_int8x64, void); + CV_DEF_REG_TRAITS(v512, v_int8x64, schar, s8, v_uint8x64, v_int16x32, v_int32x16, v_int8x64, void); + CV_DEF_REG_TRAITS(v512, v_uint16x32, ushort, u16, v_uint16x32, v_uint32x16, v_uint64x8, v_int16x32, void); + CV_DEF_REG_TRAITS(v512, v_int16x32, short, s16, v_uint16x32, v_int32x16, v_int64x8, v_int16x32, void); + CV_DEF_REG_TRAITS(v512, v_uint32x16, unsigned, u32, v_uint32x16, v_uint64x8, void, v_int32x16, void); + CV_DEF_REG_TRAITS(v512, v_int32x16, int, s32, v_uint32x16, v_int64x8, void, v_int32x16, void); + CV_DEF_REG_TRAITS(v512, v_float32x16, float, f32, v_float32x16, v_float64x8, void, v_int32x16, v_int32x16); + CV_DEF_REG_TRAITS(v512, v_uint64x8, uint64, u64, v_uint64x8, void, void, v_int64x8, void); + CV_DEF_REG_TRAITS(v512, v_int64x8, int64, s64, v_uint64x8, void, void, v_int64x8, void); + CV_DEF_REG_TRAITS(v512, v_float64x8, double, f64, v_float64x8, void, void, v_int64x8, v_int32x16); +#endif +//! @endcond + +#if CV_SIMD512 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 512) +#define CV__SIMD_NAMESPACE simd512 +namespace CV__SIMD_NAMESPACE { + #define CV_SIMD 1 + #define CV_SIMD_64F CV_SIMD512_64F + #define CV_SIMD_FP16 CV_SIMD512_FP16 + #define CV_SIMD_WIDTH 64 +//! @addtogroup core_hal_intrin +//! @{ + //! @brief Maximum available vector register capacity 8-bit unsigned integer values + typedef v_uint8x64 v_uint8; + //! @brief Maximum available vector register capacity 8-bit signed integer values + typedef v_int8x64 v_int8; + //! @brief Maximum available vector register capacity 16-bit unsigned integer values + typedef v_uint16x32 v_uint16; + //! @brief Maximum available vector register capacity 16-bit signed integer values + typedef v_int16x32 v_int16; + //! @brief Maximum available vector register capacity 32-bit unsigned integer values + typedef v_uint32x16 v_uint32; + //! @brief Maximum available vector register capacity 32-bit signed integer values + typedef v_int32x16 v_int32; + //! @brief Maximum available vector register capacity 64-bit unsigned integer values + typedef v_uint64x8 v_uint64; + //! @brief Maximum available vector register capacity 64-bit signed integer values + typedef v_int64x8 v_int64; + //! @brief Maximum available vector register capacity 32-bit floating point values (single precision) + typedef v_float32x16 v_float32; + #if CV_SIMD512_64F + //! @brief Maximum available vector register capacity 64-bit floating point values (double precision) + typedef v_float64x8 v_float64; + #endif +//! @} + + #define VXPREFIX(func) v512##func +} // namespace +using namespace CV__SIMD_NAMESPACE; +#elif CV_SIMD256 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 256) +#define CV__SIMD_NAMESPACE simd256 +namespace CV__SIMD_NAMESPACE { + #define CV_SIMD 1 + #define CV_SIMD_64F CV_SIMD256_64F + #define CV_SIMD_FP16 CV_SIMD256_FP16 + #define CV_SIMD_WIDTH 32 +//! @addtogroup core_hal_intrin +//! @{ + //! @brief Maximum available vector register capacity 8-bit unsigned integer values + typedef v_uint8x32 v_uint8; + //! @brief Maximum available vector register capacity 8-bit signed integer values + typedef v_int8x32 v_int8; + //! @brief Maximum available vector register capacity 16-bit unsigned integer values + typedef v_uint16x16 v_uint16; + //! @brief Maximum available vector register capacity 16-bit signed integer values + typedef v_int16x16 v_int16; + //! @brief Maximum available vector register capacity 32-bit unsigned integer values + typedef v_uint32x8 v_uint32; + //! @brief Maximum available vector register capacity 32-bit signed integer values + typedef v_int32x8 v_int32; + //! @brief Maximum available vector register capacity 64-bit unsigned integer values + typedef v_uint64x4 v_uint64; + //! @brief Maximum available vector register capacity 64-bit signed integer values + typedef v_int64x4 v_int64; + //! @brief Maximum available vector register capacity 32-bit floating point values (single precision) + typedef v_float32x8 v_float32; + #if CV_SIMD256_64F + //! @brief Maximum available vector register capacity 64-bit floating point values (double precision) + typedef v_float64x4 v_float64; + #endif +//! @} + + #define VXPREFIX(func) v256##func +} // namespace +using namespace CV__SIMD_NAMESPACE; +#elif (CV_SIMD128 || CV_SIMD128_CPP) && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 128) +#if defined CV_SIMD128_CPP +#define CV__SIMD_NAMESPACE simd128_cpp +#else +#define CV__SIMD_NAMESPACE simd128 +#endif +namespace CV__SIMD_NAMESPACE { + #define CV_SIMD CV_SIMD128 + #define CV_SIMD_64F CV_SIMD128_64F + #define CV_SIMD_WIDTH 16 +//! @addtogroup core_hal_intrin +//! @{ + //! @brief Maximum available vector register capacity 8-bit unsigned integer values + typedef v_uint8x16 v_uint8; + //! @brief Maximum available vector register capacity 8-bit signed integer values + typedef v_int8x16 v_int8; + //! @brief Maximum available vector register capacity 16-bit unsigned integer values + typedef v_uint16x8 v_uint16; + //! @brief Maximum available vector register capacity 16-bit signed integer values + typedef v_int16x8 v_int16; + //! @brief Maximum available vector register capacity 32-bit unsigned integer values + typedef v_uint32x4 v_uint32; + //! @brief Maximum available vector register capacity 32-bit signed integer values + typedef v_int32x4 v_int32; + //! @brief Maximum available vector register capacity 64-bit unsigned integer values + typedef v_uint64x2 v_uint64; + //! @brief Maximum available vector register capacity 64-bit signed integer values + typedef v_int64x2 v_int64; + //! @brief Maximum available vector register capacity 32-bit floating point values (single precision) + typedef v_float32x4 v_float32; + #if CV_SIMD128_64F + //! @brief Maximum available vector register capacity 64-bit floating point values (double precision) + typedef v_float64x2 v_float64; + #endif +//! @} + + #define VXPREFIX(func) v##func +} // namespace +using namespace CV__SIMD_NAMESPACE; +#endif + +namespace CV__SIMD_NAMESPACE { +//! @addtogroup core_hal_intrin +//! @{ + //! @name Wide init with value + //! @{ + //! @brief Create maximum available capacity vector with elements set to a specific value + inline v_uint8 vx_setall_u8(uchar v) { return VXPREFIX(_setall_u8)(v); } + inline v_int8 vx_setall_s8(schar v) { return VXPREFIX(_setall_s8)(v); } + inline v_uint16 vx_setall_u16(ushort v) { return VXPREFIX(_setall_u16)(v); } + inline v_int16 vx_setall_s16(short v) { return VXPREFIX(_setall_s16)(v); } + inline v_int32 vx_setall_s32(int v) { return VXPREFIX(_setall_s32)(v); } + inline v_uint32 vx_setall_u32(unsigned v) { return VXPREFIX(_setall_u32)(v); } + inline v_float32 vx_setall_f32(float v) { return VXPREFIX(_setall_f32)(v); } + inline v_int64 vx_setall_s64(int64 v) { return VXPREFIX(_setall_s64)(v); } + inline v_uint64 vx_setall_u64(uint64 v) { return VXPREFIX(_setall_u64)(v); } +#if CV_SIMD_64F + inline v_float64 vx_setall_f64(double v) { return VXPREFIX(_setall_f64)(v); } +#endif + //! @} + + //! @name Wide init with zero + //! @{ + //! @brief Create maximum available capacity vector with elements set to zero + inline v_uint8 vx_setzero_u8() { return VXPREFIX(_setzero_u8)(); } + inline v_int8 vx_setzero_s8() { return VXPREFIX(_setzero_s8)(); } + inline v_uint16 vx_setzero_u16() { return VXPREFIX(_setzero_u16)(); } + inline v_int16 vx_setzero_s16() { return VXPREFIX(_setzero_s16)(); } + inline v_int32 vx_setzero_s32() { return VXPREFIX(_setzero_s32)(); } + inline v_uint32 vx_setzero_u32() { return VXPREFIX(_setzero_u32)(); } + inline v_float32 vx_setzero_f32() { return VXPREFIX(_setzero_f32)(); } + inline v_int64 vx_setzero_s64() { return VXPREFIX(_setzero_s64)(); } + inline v_uint64 vx_setzero_u64() { return VXPREFIX(_setzero_u64)(); } +#if CV_SIMD_64F + inline v_float64 vx_setzero_f64() { return VXPREFIX(_setzero_f64)(); } +#endif + //! @} + + //! @name Wide load from memory + //! @{ + //! @brief Load maximum available capacity register contents from memory + inline v_uint8 vx_load(const uchar * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int8 vx_load(const schar * ptr) { return VXPREFIX(_load)(ptr); } + inline v_uint16 vx_load(const ushort * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int16 vx_load(const short * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int32 vx_load(const int * ptr) { return VXPREFIX(_load)(ptr); } + inline v_uint32 vx_load(const unsigned * ptr) { return VXPREFIX(_load)(ptr); } + inline v_float32 vx_load(const float * ptr) { return VXPREFIX(_load)(ptr); } + inline v_int64 vx_load(const int64 * ptr) { return VXPREFIX(_load)(ptr); } + inline v_uint64 vx_load(const uint64 * ptr) { return VXPREFIX(_load)(ptr); } +#if CV_SIMD_64F + inline v_float64 vx_load(const double * ptr) { return VXPREFIX(_load)(ptr); } +#endif + //! @} + + //! @name Wide load from memory(aligned) + //! @{ + //! @brief Load maximum available capacity register contents from memory(aligned) + inline v_uint8 vx_load_aligned(const uchar * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int8 vx_load_aligned(const schar * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_uint16 vx_load_aligned(const ushort * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int16 vx_load_aligned(const short * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int32 vx_load_aligned(const int * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_uint32 vx_load_aligned(const unsigned * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_float32 vx_load_aligned(const float * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_int64 vx_load_aligned(const int64 * ptr) { return VXPREFIX(_load_aligned)(ptr); } + inline v_uint64 vx_load_aligned(const uint64 * ptr) { return VXPREFIX(_load_aligned)(ptr); } +#if CV_SIMD_64F + inline v_float64 vx_load_aligned(const double * ptr) { return VXPREFIX(_load_aligned)(ptr); } +#endif + //! @} + + //! @name Wide load lower half from memory + //! @{ + //! @brief Load lower half of maximum available capacity register from memory + inline v_uint8 vx_load_low(const uchar * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int8 vx_load_low(const schar * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_uint16 vx_load_low(const ushort * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int16 vx_load_low(const short * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int32 vx_load_low(const int * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_uint32 vx_load_low(const unsigned * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_float32 vx_load_low(const float * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_int64 vx_load_low(const int64 * ptr) { return VXPREFIX(_load_low)(ptr); } + inline v_uint64 vx_load_low(const uint64 * ptr) { return VXPREFIX(_load_low)(ptr); } +#if CV_SIMD_64F + inline v_float64 vx_load_low(const double * ptr) { return VXPREFIX(_load_low)(ptr); } +#endif + //! @} + + //! @name Wide load halfs from memory + //! @{ + //! @brief Load maximum available capacity register contents from two memory blocks + inline v_uint8 vx_load_halves(const uchar * ptr0, const uchar * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int8 vx_load_halves(const schar * ptr0, const schar * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_uint16 vx_load_halves(const ushort * ptr0, const ushort * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int16 vx_load_halves(const short * ptr0, const short * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int32 vx_load_halves(const int * ptr0, const int * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_uint32 vx_load_halves(const unsigned * ptr0, const unsigned * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_float32 vx_load_halves(const float * ptr0, const float * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_int64 vx_load_halves(const int64 * ptr0, const int64 * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } + inline v_uint64 vx_load_halves(const uint64 * ptr0, const uint64 * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } +#if CV_SIMD_64F + inline v_float64 vx_load_halves(const double * ptr0, const double * ptr1) { return VXPREFIX(_load_halves)(ptr0, ptr1); } +#endif + //! @} + + //! @name Wide LUT of elements + //! @{ + //! @brief Load maximum available capacity register contents with array elements by provided indexes + inline v_uint8 vx_lut(const uchar * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int8 vx_lut(const schar * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_uint16 vx_lut(const ushort * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int16 vx_lut(const short* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int32 vx_lut(const int* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_uint32 vx_lut(const unsigned* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_float32 vx_lut(const float* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_int64 vx_lut(const int64 * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } + inline v_uint64 vx_lut(const uint64 * ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } +#if CV_SIMD_64F + inline v_float64 vx_lut(const double* ptr, const int* idx) { return VXPREFIX(_lut)(ptr, idx); } +#endif + //! @} + + //! @name Wide LUT of element pairs + //! @{ + //! @brief Load maximum available capacity register contents with array element pairs by provided indexes + inline v_uint8 vx_lut_pairs(const uchar * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int8 vx_lut_pairs(const schar * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_uint16 vx_lut_pairs(const ushort * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int16 vx_lut_pairs(const short* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int32 vx_lut_pairs(const int* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_uint32 vx_lut_pairs(const unsigned* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_float32 vx_lut_pairs(const float* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_int64 vx_lut_pairs(const int64 * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } + inline v_uint64 vx_lut_pairs(const uint64 * ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } +#if CV_SIMD_64F + inline v_float64 vx_lut_pairs(const double* ptr, const int* idx) { return VXPREFIX(_lut_pairs)(ptr, idx); } +#endif + //! @} + + //! @name Wide LUT of element quads + //! @{ + //! @brief Load maximum available capacity register contents with array element quads by provided indexes + inline v_uint8 vx_lut_quads(const uchar* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_int8 vx_lut_quads(const schar* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_uint16 vx_lut_quads(const ushort* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_int16 vx_lut_quads(const short* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_int32 vx_lut_quads(const int* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_uint32 vx_lut_quads(const unsigned* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + inline v_float32 vx_lut_quads(const float* ptr, const int* idx) { return VXPREFIX(_lut_quads)(ptr, idx); } + //! @} + + //! @name Wide load with double expansion + //! @{ + //! @brief Load maximum available capacity register contents from memory with double expand + inline v_uint16 vx_load_expand(const uchar * ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_int16 vx_load_expand(const schar * ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_uint32 vx_load_expand(const ushort * ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_int32 vx_load_expand(const short* ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_int64 vx_load_expand(const int* ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_uint64 vx_load_expand(const unsigned* ptr) { return VXPREFIX(_load_expand)(ptr); } + inline v_float32 vx_load_expand(const float16_t * ptr) { return VXPREFIX(_load_expand)(ptr); } + //! @} + + //! @name Wide load with quad expansion + //! @{ + //! @brief Load maximum available capacity register contents from memory with quad expand + inline v_uint32 vx_load_expand_q(const uchar * ptr) { return VXPREFIX(_load_expand_q)(ptr); } + inline v_int32 vx_load_expand_q(const schar * ptr) { return VXPREFIX(_load_expand_q)(ptr); } + //! @} + + /** @brief SIMD processing state cleanup call */ + inline void vx_cleanup() { VXPREFIX(_cleanup)(); } + + +//! @cond IGNORED + + // backward compatibility + template static inline + void vx_store(_Tp* dst, const _Tvec& v) { return v_store(dst, v); } + // backward compatibility + template static inline + void vx_store_aligned(_Tp* dst, const _Tvec& v) { return v_store_aligned(dst, v); } + +//! @endcond + + +//! @} + #undef VXPREFIX +} // namespace + +//! @cond IGNORED +#ifndef CV_SIMD_64F +#define CV_SIMD_64F 0 +#endif + +#ifndef CV_SIMD_FP16 +#define CV_SIMD_FP16 0 //!< Defined to 1 on native support of operations with float16x8_t / float16x16_t (SIMD256) types +#endif + +#ifndef CV_SIMD +#define CV_SIMD 0 +#endif + +#include "simd_utils.impl.hpp" + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END +#endif + +} // cv:: + +//! @endcond + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_avx.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_avx.hpp new file mode 100644 index 0000000..979b616 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_avx.hpp @@ -0,0 +1,3177 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_INTRIN_AVX_HPP +#define OPENCV_HAL_INTRIN_AVX_HPP + +#define CV_SIMD256 1 +#define CV_SIMD256_64F 1 +#define CV_SIMD256_FP16 0 // no native operations with FP16 type. Only load/store from float32x8 are available (if CV_FP16 == 1) + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Utils //////////// + +inline __m256i _v256_combine(const __m128i& lo, const __m128i& hi) +{ return _mm256_inserti128_si256(_mm256_castsi128_si256(lo), hi, 1); } + +inline __m256 _v256_combine(const __m128& lo, const __m128& hi) +{ return _mm256_insertf128_ps(_mm256_castps128_ps256(lo), hi, 1); } + +inline __m256d _v256_combine(const __m128d& lo, const __m128d& hi) +{ return _mm256_insertf128_pd(_mm256_castpd128_pd256(lo), hi, 1); } + +inline int _v_cvtsi256_si32(const __m256i& a) +{ return _mm_cvtsi128_si32(_mm256_castsi256_si128(a)); } + +inline __m256i _v256_shuffle_odd_64(const __m256i& v) +{ return _mm256_permute4x64_epi64(v, _MM_SHUFFLE(3, 1, 2, 0)); } + +inline __m256d _v256_shuffle_odd_64(const __m256d& v) +{ return _mm256_permute4x64_pd(v, _MM_SHUFFLE(3, 1, 2, 0)); } + +template +inline __m256i _v256_permute2x128(const __m256i& a, const __m256i& b) +{ return _mm256_permute2x128_si256(a, b, imm); } + +template +inline __m256 _v256_permute2x128(const __m256& a, const __m256& b) +{ return _mm256_permute2f128_ps(a, b, imm); } + +template +inline __m256d _v256_permute2x128(const __m256d& a, const __m256d& b) +{ return _mm256_permute2f128_pd(a, b, imm); } + +template +inline _Tpvec v256_permute2x128(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(_v256_permute2x128(a.val, b.val)); } + +template +inline __m256i _v256_permute4x64(const __m256i& a) +{ return _mm256_permute4x64_epi64(a, imm); } + +template +inline __m256d _v256_permute4x64(const __m256d& a) +{ return _mm256_permute4x64_pd(a, imm); } + +template +inline _Tpvec v256_permute4x64(const _Tpvec& a) +{ return _Tpvec(_v256_permute4x64(a.val)); } + +inline __m128i _v256_extract_high(const __m256i& v) +{ return _mm256_extracti128_si256(v, 1); } + +inline __m128 _v256_extract_high(const __m256& v) +{ return _mm256_extractf128_ps(v, 1); } + +inline __m128d _v256_extract_high(const __m256d& v) +{ return _mm256_extractf128_pd(v, 1); } + +inline __m128i _v256_extract_low(const __m256i& v) +{ return _mm256_castsi256_si128(v); } + +inline __m128 _v256_extract_low(const __m256& v) +{ return _mm256_castps256_ps128(v); } + +inline __m128d _v256_extract_low(const __m256d& v) +{ return _mm256_castpd256_pd128(v); } + +inline __m256i _v256_packs_epu32(const __m256i& a, const __m256i& b) +{ + const __m256i m = _mm256_set1_epi32(65535); + __m256i am = _mm256_min_epu32(a, m); + __m256i bm = _mm256_min_epu32(b, m); + return _mm256_packus_epi32(am, bm); +} + +template +inline int _v256_extract_epi8(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi8(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 4)); + return _mm_extract_epi8(b, i & 15); // SSE4.1 +#endif +} + +template +inline int _v256_extract_epi16(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi16(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 3)); + return _mm_extract_epi16(b, i & 7); // SSE2 +#endif +} + +template +inline int _v256_extract_epi32(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi32(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 2)); + return _mm_extract_epi32(b, i & 3); // SSE4.1 +#endif +} + +template +inline int64 _v256_extract_epi64(const __m256i& a) +{ +#if defined(CV__SIMD_HAVE_mm256_extract_epi8) || (CV_AVX2 && (!defined(_MSC_VER) || _MSC_VER >= 1910/*MSVS 2017*/)) + return _mm256_extract_epi64(a, i); +#else + __m128i b = _mm256_extractf128_si256(a, ((i) >> 1)); + return _mm_extract_epi64(b, i & 1); // SSE4.1 +#endif +} + +///////// Types //////////// + +struct v_uint8x32 +{ + typedef uchar lane_type; + enum { nlanes = 32 }; + __m256i val; + + explicit v_uint8x32(__m256i v) : val(v) {} + v_uint8x32(uchar v0, uchar v1, uchar v2, uchar v3, + uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, + uchar v12, uchar v13, uchar v14, uchar v15, + uchar v16, uchar v17, uchar v18, uchar v19, + uchar v20, uchar v21, uchar v22, uchar v23, + uchar v24, uchar v25, uchar v26, uchar v27, + uchar v28, uchar v29, uchar v30, uchar v31) + { + val = _mm256_setr_epi8((char)v0, (char)v1, (char)v2, (char)v3, + (char)v4, (char)v5, (char)v6 , (char)v7, (char)v8, (char)v9, + (char)v10, (char)v11, (char)v12, (char)v13, (char)v14, (char)v15, + (char)v16, (char)v17, (char)v18, (char)v19, (char)v20, (char)v21, + (char)v22, (char)v23, (char)v24, (char)v25, (char)v26, (char)v27, + (char)v28, (char)v29, (char)v30, (char)v31); + } + /* coverity[uninit_ctor]: suppress warning */ + v_uint8x32() {} + + uchar get0() const { return (uchar)_v_cvtsi256_si32(val); } +}; + +struct v_int8x32 +{ + typedef schar lane_type; + enum { nlanes = 32 }; + __m256i val; + + explicit v_int8x32(__m256i v) : val(v) {} + v_int8x32(schar v0, schar v1, schar v2, schar v3, + schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, + schar v12, schar v13, schar v14, schar v15, + schar v16, schar v17, schar v18, schar v19, + schar v20, schar v21, schar v22, schar v23, + schar v24, schar v25, schar v26, schar v27, + schar v28, schar v29, schar v30, schar v31) + { + val = _mm256_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, + v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, + v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31); + } + /* coverity[uninit_ctor]: suppress warning */ + v_int8x32() {} + + schar get0() const { return (schar)_v_cvtsi256_si32(val); } +}; + +struct v_uint16x16 +{ + typedef ushort lane_type; + enum { nlanes = 16 }; + __m256i val; + + explicit v_uint16x16(__m256i v) : val(v) {} + v_uint16x16(ushort v0, ushort v1, ushort v2, ushort v3, + ushort v4, ushort v5, ushort v6, ushort v7, + ushort v8, ushort v9, ushort v10, ushort v11, + ushort v12, ushort v13, ushort v14, ushort v15) + { + val = _mm256_setr_epi16((short)v0, (short)v1, (short)v2, (short)v3, + (short)v4, (short)v5, (short)v6, (short)v7, (short)v8, (short)v9, + (short)v10, (short)v11, (short)v12, (short)v13, (short)v14, (short)v15); + } + /* coverity[uninit_ctor]: suppress warning */ + v_uint16x16() {} + + ushort get0() const { return (ushort)_v_cvtsi256_si32(val); } +}; + +struct v_int16x16 +{ + typedef short lane_type; + enum { nlanes = 16 }; + __m256i val; + + explicit v_int16x16(__m256i v) : val(v) {} + v_int16x16(short v0, short v1, short v2, short v3, + short v4, short v5, short v6, short v7, + short v8, short v9, short v10, short v11, + short v12, short v13, short v14, short v15) + { + val = _mm256_setr_epi16(v0, v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15); + } + /* coverity[uninit_ctor]: suppress warning */ + v_int16x16() {} + + short get0() const { return (short)_v_cvtsi256_si32(val); } +}; + +struct v_uint32x8 +{ + typedef unsigned lane_type; + enum { nlanes = 8 }; + __m256i val; + + explicit v_uint32x8(__m256i v) : val(v) {} + v_uint32x8(unsigned v0, unsigned v1, unsigned v2, unsigned v3, + unsigned v4, unsigned v5, unsigned v6, unsigned v7) + { + val = _mm256_setr_epi32((unsigned)v0, (unsigned)v1, (unsigned)v2, + (unsigned)v3, (unsigned)v4, (unsigned)v5, (unsigned)v6, (unsigned)v7); + } + /* coverity[uninit_ctor]: suppress warning */ + v_uint32x8() {} + + unsigned get0() const { return (unsigned)_v_cvtsi256_si32(val); } +}; + +struct v_int32x8 +{ + typedef int lane_type; + enum { nlanes = 8 }; + __m256i val; + + explicit v_int32x8(__m256i v) : val(v) {} + v_int32x8(int v0, int v1, int v2, int v3, + int v4, int v5, int v6, int v7) + { + val = _mm256_setr_epi32(v0, v1, v2, v3, v4, v5, v6, v7); + } + /* coverity[uninit_ctor]: suppress warning */ + v_int32x8() {} + + int get0() const { return _v_cvtsi256_si32(val); } +}; + +struct v_float32x8 +{ + typedef float lane_type; + enum { nlanes = 8 }; + __m256 val; + + explicit v_float32x8(__m256 v) : val(v) {} + v_float32x8(float v0, float v1, float v2, float v3, + float v4, float v5, float v6, float v7) + { + val = _mm256_setr_ps(v0, v1, v2, v3, v4, v5, v6, v7); + } + /* coverity[uninit_ctor]: suppress warning */ + v_float32x8() {} + + float get0() const { return _mm_cvtss_f32(_mm256_castps256_ps128(val)); } +}; + +struct v_uint64x4 +{ + typedef uint64 lane_type; + enum { nlanes = 4 }; + __m256i val; + + explicit v_uint64x4(__m256i v) : val(v) {} + v_uint64x4(uint64 v0, uint64 v1, uint64 v2, uint64 v3) + { val = _mm256_setr_epi64x((int64)v0, (int64)v1, (int64)v2, (int64)v3); } + /* coverity[uninit_ctor]: suppress warning */ + v_uint64x4() {} + + uint64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (uint64)_mm_cvtsi128_si64(_mm256_castsi256_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm256_castsi256_si128(val)); + int b = _mm_cvtsi128_si32(_mm256_castsi256_si128(_mm256_srli_epi64(val, 32))); + return (unsigned)a | ((uint64)(unsigned)b << 32); + #endif + } +}; + +struct v_int64x4 +{ + typedef int64 lane_type; + enum { nlanes = 4 }; + __m256i val; + + explicit v_int64x4(__m256i v) : val(v) {} + v_int64x4(int64 v0, int64 v1, int64 v2, int64 v3) + { val = _mm256_setr_epi64x(v0, v1, v2, v3); } + /* coverity[uninit_ctor]: suppress warning */ + v_int64x4() {} + + int64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (int64)_mm_cvtsi128_si64(_mm256_castsi256_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm256_castsi256_si128(val)); + int b = _mm_cvtsi128_si32(_mm256_castsi256_si128(_mm256_srli_epi64(val, 32))); + return (int64)((unsigned)a | ((uint64)(unsigned)b << 32)); + #endif + } +}; + +struct v_float64x4 +{ + typedef double lane_type; + enum { nlanes = 4 }; + __m256d val; + + explicit v_float64x4(__m256d v) : val(v) {} + v_float64x4(double v0, double v1, double v2, double v3) + { val = _mm256_setr_pd(v0, v1, v2, v3); } + /* coverity[uninit_ctor]: suppress warning */ + v_float64x4() {} + + double get0() const { return _mm_cvtsd_f64(_mm256_castpd256_pd128(val)); } +}; + +//////////////// Load and store operations /////////////// + +#define OPENCV_HAL_IMPL_AVX_LOADSTORE(_Tpvec, _Tp) \ + inline _Tpvec v256_load(const _Tp* ptr) \ + { return _Tpvec(_mm256_loadu_si256((const __m256i*)ptr)); } \ + inline _Tpvec v256_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm256_load_si256((const __m256i*)ptr)); } \ + inline _Tpvec v256_load_low(const _Tp* ptr) \ + { \ + __m128i v128 = _mm_loadu_si128((const __m128i*)ptr); \ + return _Tpvec(_mm256_castsi128_si256(v128)); \ + } \ + inline _Tpvec v256_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + __m128i vlo = _mm_loadu_si128((const __m128i*)ptr0); \ + __m128i vhi = _mm_loadu_si128((const __m128i*)ptr1); \ + return _Tpvec(_v256_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_si256((__m256i*)ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm256_store_si256((__m256i*)ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm256_stream_si256((__m256i*)ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm256_storeu_si256((__m256i*)ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm256_stream_si256((__m256i*)ptr, a.val); \ + else \ + _mm256_store_si256((__m256i*)ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_si128((__m128i*)ptr, _v256_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_si128((__m128i*)ptr, _v256_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint8x32, uchar) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int8x32, schar) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint16x16, ushort) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int16x16, short) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint32x8, unsigned) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int32x8, int) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_uint64x4, uint64) +OPENCV_HAL_IMPL_AVX_LOADSTORE(v_int64x4, int64) + +#define OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(_Tpvec, _Tp, suffix, halfreg) \ + inline _Tpvec v256_load(const _Tp* ptr) \ + { return _Tpvec(_mm256_loadu_##suffix(ptr)); } \ + inline _Tpvec v256_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm256_load_##suffix(ptr)); } \ + inline _Tpvec v256_load_low(const _Tp* ptr) \ + { \ + return _Tpvec(_mm256_cast##suffix##128_##suffix##256 \ + (_mm_loadu_##suffix(ptr))); \ + } \ + inline _Tpvec v256_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + halfreg vlo = _mm_loadu_##suffix(ptr0); \ + halfreg vhi = _mm_loadu_##suffix(ptr1); \ + return _Tpvec(_v256_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_##suffix(ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm256_store_##suffix(ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm256_stream_##suffix(ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm256_storeu_##suffix(ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm256_stream_##suffix(ptr, a.val); \ + else \ + _mm256_store_##suffix(ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_##suffix(ptr, _v256_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm_storeu_##suffix(ptr, _v256_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(v_float32x8, float, ps, __m128) +OPENCV_HAL_IMPL_AVX_LOADSTORE_FLT(v_float64x4, double, pd, __m128d) + +#define OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, _Tpvecf, suffix, cast) \ + inline _Tpvec v_reinterpret_as_##suffix(const _Tpvecf& a) \ + { return _Tpvec(cast(a.val)); } + +#define OPENCV_HAL_IMPL_AVX_INIT(_Tpvec, _Tp, suffix, ssuffix, ctype_s) \ + inline _Tpvec v256_setzero_##suffix() \ + { return _Tpvec(_mm256_setzero_si256()); } \ + inline _Tpvec v256_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm256_set1_##ssuffix((ctype_s)v)); } \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint8x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int8x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint16x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int16x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint32x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int32x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint64x4, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int64x4, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_float32x8, suffix, _mm256_castps_si256) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_float64x4, suffix, _mm256_castpd_si256) + +OPENCV_HAL_IMPL_AVX_INIT(v_uint8x32, uchar, u8, epi8, char) +OPENCV_HAL_IMPL_AVX_INIT(v_int8x32, schar, s8, epi8, char) +OPENCV_HAL_IMPL_AVX_INIT(v_uint16x16, ushort, u16, epi16, short) +OPENCV_HAL_IMPL_AVX_INIT(v_int16x16, short, s16, epi16, short) +OPENCV_HAL_IMPL_AVX_INIT(v_uint32x8, unsigned, u32, epi32, int) +OPENCV_HAL_IMPL_AVX_INIT(v_int32x8, int, s32, epi32, int) +OPENCV_HAL_IMPL_AVX_INIT(v_uint64x4, uint64, u64, epi64x, int64) +OPENCV_HAL_IMPL_AVX_INIT(v_int64x4, int64, s64, epi64x, int64) + +#define OPENCV_HAL_IMPL_AVX_INIT_FLT(_Tpvec, _Tp, suffix, zsuffix, cast) \ + inline _Tpvec v256_setzero_##suffix() \ + { return _Tpvec(_mm256_setzero_##zsuffix()); } \ + inline _Tpvec v256_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm256_set1_##zsuffix(v)); } \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint8x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int8x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint16x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int16x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint32x8, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int32x8, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_uint64x4, suffix, cast) \ + OPENCV_HAL_IMPL_AVX_CAST(_Tpvec, v_int64x4, suffix, cast) + +OPENCV_HAL_IMPL_AVX_INIT_FLT(v_float32x8, float, f32, ps, _mm256_castsi256_ps) +OPENCV_HAL_IMPL_AVX_INIT_FLT(v_float64x4, double, f64, pd, _mm256_castsi256_pd) + +inline v_float32x8 v_reinterpret_as_f32(const v_float32x8& a) +{ return a; } +inline v_float32x8 v_reinterpret_as_f32(const v_float64x4& a) +{ return v_float32x8(_mm256_castpd_ps(a.val)); } + +inline v_float64x4 v_reinterpret_as_f64(const v_float64x4& a) +{ return a; } +inline v_float64x4 v_reinterpret_as_f64(const v_float32x8& a) +{ return v_float64x4(_mm256_castps_pd(a.val)); } + +/* Recombine */ +/*#define OPENCV_HAL_IMPL_AVX_COMBINE(_Tpvec, perm) \ + inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(perm(a.val, b.val, 0x20)); } \ + inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(perm(a.val, b.val, 0x31)); } \ + inline void v_recombine(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ + { c = v_combine_low(a, b); d = v_combine_high(a, b); } + +#define OPENCV_HAL_IMPL_AVX_UNPACKS(_Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_COMBINE(_Tpvec, _mm256_permute2x128_si256) \ + inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, \ + _Tpvec& b0, _Tpvec& b1) \ + { \ + __m256i v0 = _v256_shuffle_odd_64(a0.val); \ + __m256i v1 = _v256_shuffle_odd_64(a1.val); \ + b0.val = _mm256_unpacklo_##suffix(v0, v1); \ + b1.val = _mm256_unpackhi_##suffix(v0, v1); \ + } + +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_uint64x4, epi64) +OPENCV_HAL_IMPL_AVX_UNPACKS(v_int64x4, epi64) +OPENCV_HAL_IMPL_AVX_COMBINE(v_float32x8, _mm256_permute2f128_ps) +OPENCV_HAL_IMPL_AVX_COMBINE(v_float64x4, _mm256_permute2f128_pd) + +inline void v_zip(const v_float32x8& a0, const v_float32x8& a1, v_float32x8& b0, v_float32x8& b1) +{ + __m256 v0 = _mm256_unpacklo_ps(a0.val, a1.val); + __m256 v1 = _mm256_unpackhi_ps(a0.val, a1.val); + v_recombine(v_float32x8(v0), v_float32x8(v1), b0, b1); +} + +inline void v_zip(const v_float64x4& a0, const v_float64x4& a1, v_float64x4& b0, v_float64x4& b1) +{ + __m256d v0 = _v_shuffle_odd_64(a0.val); + __m256d v1 = _v_shuffle_odd_64(a1.val); + b0.val = _mm256_unpacklo_pd(v0, v1); + b1.val = _mm256_unpackhi_pd(v0, v1); +}*/ + +//////////////// Variant Value reordering /////////////// + +// unpacks +#define OPENCV_HAL_IMPL_AVX_UNPACK(_Tpvec, suffix) \ + inline _Tpvec v256_unpacklo(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_unpacklo_##suffix(a.val, b.val)); } \ + inline _Tpvec v256_unpackhi(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_unpackhi_##suffix(a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int8x32, epi8) +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int16x16, epi16) +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int32x8, epi32) +OPENCV_HAL_IMPL_AVX_UNPACK(v_uint64x4, epi64) +OPENCV_HAL_IMPL_AVX_UNPACK(v_int64x4, epi64) +OPENCV_HAL_IMPL_AVX_UNPACK(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_UNPACK(v_float64x4, pd) + +// blend +#define OPENCV_HAL_IMPL_AVX_BLEND(_Tpvec, suffix) \ + template \ + inline _Tpvec v256_blend(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_blend_##suffix(a.val, b.val, m)); } + +OPENCV_HAL_IMPL_AVX_BLEND(v_uint16x16, epi16) +OPENCV_HAL_IMPL_AVX_BLEND(v_int16x16, epi16) +OPENCV_HAL_IMPL_AVX_BLEND(v_uint32x8, epi32) +OPENCV_HAL_IMPL_AVX_BLEND(v_int32x8, epi32) +OPENCV_HAL_IMPL_AVX_BLEND(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_BLEND(v_float64x4, pd) + +template +inline v_uint64x4 v256_blend(const v_uint64x4& a, const v_uint64x4& b) +{ + enum {M0 = m}; + enum {M1 = (M0 | (M0 << 2)) & 0x33}; + enum {M2 = (M1 | (M1 << 1)) & 0x55}; + enum {MM = M2 | (M2 << 1)}; + return v_uint64x4(_mm256_blend_epi32(a.val, b.val, MM)); +} +template +inline v_int64x4 v256_blend(const v_int64x4& a, const v_int64x4& b) +{ return v_int64x4(v256_blend(v_uint64x4(a.val), v_uint64x4(b.val)).val); } + +// shuffle +// todo: emulate 64bit +#define OPENCV_HAL_IMPL_AVX_SHUFFLE(_Tpvec, intrin) \ + template \ + inline _Tpvec v256_shuffle(const _Tpvec& a) \ + { return _Tpvec(_mm256_##intrin(a.val, m)); } + +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_uint32x8, shuffle_epi32) +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_int32x8, shuffle_epi32) +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_float32x8, permute_ps) +OPENCV_HAL_IMPL_AVX_SHUFFLE(v_float64x4, permute_pd) + +template +inline void v256_zip(const _Tpvec& a, const _Tpvec& b, _Tpvec& ab0, _Tpvec& ab1) +{ + ab0 = v256_unpacklo(a, b); + ab1 = v256_unpackhi(a, b); +} + +template +inline _Tpvec v256_combine_diagonal(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(_mm256_blend_epi32(a.val, b.val, 0xf0)); } + +inline v_float32x8 v256_combine_diagonal(const v_float32x8& a, const v_float32x8& b) +{ return v256_blend<0xf0>(a, b); } + +inline v_float64x4 v256_combine_diagonal(const v_float64x4& a, const v_float64x4& b) +{ return v256_blend<0xc>(a, b); } + +template +inline _Tpvec v256_alignr_128(const _Tpvec& a, const _Tpvec& b) +{ return v256_permute2x128<0x21>(a, b); } + +template +inline _Tpvec v256_alignr_64(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(_mm256_alignr_epi8(a.val, b.val, 8)); } +inline v_float64x4 v256_alignr_64(const v_float64x4& a, const v_float64x4& b) +{ return v_float64x4(_mm256_shuffle_pd(b.val, a.val, _MM_SHUFFLE(0, 0, 1, 1))); } +// todo: emulate float32 + +template +inline _Tpvec v256_swap_halves(const _Tpvec& a) +{ return v256_permute2x128<1>(a, a); } + +template +inline _Tpvec v256_reverse_64(const _Tpvec& a) +{ return v256_permute4x64<_MM_SHUFFLE(0, 1, 2, 3)>(a); } + +// ZIP +#define OPENCV_HAL_IMPL_AVX_ZIP(_Tpvec) \ + inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ + { return v256_permute2x128<0x20>(a, b); } \ + inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ + { return v256_permute2x128<0x31>(a, b); } \ + inline void v_recombine(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ + { \ + _Tpvec a1b0 = v256_alignr_128(a, b); \ + c = v256_combine_diagonal(a, a1b0); \ + d = v256_combine_diagonal(a1b0, b); \ + } \ + inline void v_zip(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& ab0, _Tpvec& ab1) \ + { \ + _Tpvec ab0ab2, ab1ab3; \ + v256_zip(a, b, ab0ab2, ab1ab3); \ + v_recombine(ab0ab2, ab1ab3, ab0, ab1); \ + } + +OPENCV_HAL_IMPL_AVX_ZIP(v_uint8x32) +OPENCV_HAL_IMPL_AVX_ZIP(v_int8x32) +OPENCV_HAL_IMPL_AVX_ZIP(v_uint16x16) +OPENCV_HAL_IMPL_AVX_ZIP(v_int16x16) +OPENCV_HAL_IMPL_AVX_ZIP(v_uint32x8) +OPENCV_HAL_IMPL_AVX_ZIP(v_int32x8) +OPENCV_HAL_IMPL_AVX_ZIP(v_uint64x4) +OPENCV_HAL_IMPL_AVX_ZIP(v_int64x4) +OPENCV_HAL_IMPL_AVX_ZIP(v_float32x8) +OPENCV_HAL_IMPL_AVX_ZIP(v_float64x4) + +////////// Arithmetic, bitwise and comparison operations ///////// + +/* Element-wise binary and unary operations */ + +/** Arithmetics **/ +#define OPENCV_HAL_IMPL_AVX_BIN_OP(bin_op, _Tpvec, intrin) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } \ + inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ + { a.val = intrin(a.val, b.val); return a; } + +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint8x32, _mm256_adds_epu8) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint8x32, _mm256_subs_epu8) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int8x32, _mm256_adds_epi8) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int8x32, _mm256_subs_epi8) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint16x16, _mm256_adds_epu16) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint16x16, _mm256_subs_epu16) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int16x16, _mm256_adds_epi16) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int16x16, _mm256_subs_epi16) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint32x8, _mm256_add_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint32x8, _mm256_sub_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_uint32x8, _mm256_mullo_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int32x8, _mm256_add_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int32x8, _mm256_sub_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_int32x8, _mm256_mullo_epi32) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_uint64x4, _mm256_add_epi64) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_uint64x4, _mm256_sub_epi64) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_int64x4, _mm256_add_epi64) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_int64x4, _mm256_sub_epi64) + +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_float32x8, _mm256_add_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_float32x8, _mm256_sub_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_float32x8, _mm256_mul_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(/, v_float32x8, _mm256_div_ps) +OPENCV_HAL_IMPL_AVX_BIN_OP(+, v_float64x4, _mm256_add_pd) +OPENCV_HAL_IMPL_AVX_BIN_OP(-, v_float64x4, _mm256_sub_pd) +OPENCV_HAL_IMPL_AVX_BIN_OP(*, v_float64x4, _mm256_mul_pd) +OPENCV_HAL_IMPL_AVX_BIN_OP(/, v_float64x4, _mm256_div_pd) + +// saturating multiply 8-bit, 16-bit +inline v_uint8x32 operator * (const v_uint8x32& a, const v_uint8x32& b) +{ + v_uint16x16 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_int8x32 operator * (const v_int8x32& a, const v_int8x32& b) +{ + v_int16x16 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_uint16x16 operator * (const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i pl = _mm256_mullo_epi16(a.val, b.val); + __m256i ph = _mm256_mulhi_epu16(a.val, b.val); + __m256i p0 = _mm256_unpacklo_epi16(pl, ph); + __m256i p1 = _mm256_unpackhi_epi16(pl, ph); + return v_uint16x16(_v256_packs_epu32(p0, p1)); +} +inline v_int16x16 operator * (const v_int16x16& a, const v_int16x16& b) +{ + __m256i pl = _mm256_mullo_epi16(a.val, b.val); + __m256i ph = _mm256_mulhi_epi16(a.val, b.val); + __m256i p0 = _mm256_unpacklo_epi16(pl, ph); + __m256i p1 = _mm256_unpackhi_epi16(pl, ph); + return v_int16x16(_mm256_packs_epi32(p0, p1)); +} +inline v_uint8x32& operator *= (v_uint8x32& a, const v_uint8x32& b) +{ a = a * b; return a; } +inline v_int8x32& operator *= (v_int8x32& a, const v_int8x32& b) +{ a = a * b; return a; } +inline v_uint16x16& operator *= (v_uint16x16& a, const v_uint16x16& b) +{ a = a * b; return a; } +inline v_int16x16& operator *= (v_int16x16& a, const v_int16x16& b) +{ a = a * b; return a; } + +/** Non-saturating arithmetics **/ +#define OPENCV_HAL_IMPL_AVX_BIN_FUNC(func, _Tpvec, intrin) \ + inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_uint8x32, _mm256_add_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_int8x32, _mm256_add_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_uint16x16, _mm256_add_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_add_wrap, v_int16x16, _mm256_add_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_uint8x32, _mm256_sub_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_int8x32, _mm256_sub_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_uint16x16, _mm256_sub_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_sub_wrap, v_int16x16, _mm256_sub_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_mul_wrap, v_uint16x16, _mm256_mullo_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_mul_wrap, v_int16x16, _mm256_mullo_epi16) + +inline v_uint8x32 v_mul_wrap(const v_uint8x32& a, const v_uint8x32& b) +{ + __m256i ad = _mm256_srai_epi16(a.val, 8); + __m256i bd = _mm256_srai_epi16(b.val, 8); + __m256i p0 = _mm256_mullo_epi16(a.val, b.val); // even + __m256i p1 = _mm256_slli_epi16(_mm256_mullo_epi16(ad, bd), 8); // odd + + const __m256i b01 = _mm256_set1_epi32(0xFF00FF00); + return v_uint8x32(_mm256_blendv_epi8(p0, p1, b01)); +} +inline v_int8x32 v_mul_wrap(const v_int8x32& a, const v_int8x32& b) +{ + return v_reinterpret_as_s8(v_mul_wrap(v_reinterpret_as_u8(a), v_reinterpret_as_u8(b))); +} + +// Multiply and expand +inline void v_mul_expand(const v_uint8x32& a, const v_uint8x32& b, + v_uint16x16& c, v_uint16x16& d) +{ + v_uint16x16 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x32& a, const v_int8x32& b, + v_int16x16& c, v_int16x16& d) +{ + v_int16x16 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x16& a, const v_int16x16& b, + v_int32x8& c, v_int32x8& d) +{ + v_int16x16 vhi = v_int16x16(_mm256_mulhi_epi16(a.val, b.val)); + + v_int16x16 v0, v1; + v_zip(v_mul_wrap(a, b), vhi, v0, v1); + + c = v_reinterpret_as_s32(v0); + d = v_reinterpret_as_s32(v1); +} + +inline void v_mul_expand(const v_uint16x16& a, const v_uint16x16& b, + v_uint32x8& c, v_uint32x8& d) +{ + v_uint16x16 vhi = v_uint16x16(_mm256_mulhi_epu16(a.val, b.val)); + + v_uint16x16 v0, v1; + v_zip(v_mul_wrap(a, b), vhi, v0, v1); + + c = v_reinterpret_as_u32(v0); + d = v_reinterpret_as_u32(v1); +} + +inline void v_mul_expand(const v_uint32x8& a, const v_uint32x8& b, + v_uint64x4& c, v_uint64x4& d) +{ + __m256i v0 = _mm256_mul_epu32(a.val, b.val); + __m256i v1 = _mm256_mul_epu32(_mm256_srli_epi64(a.val, 32), _mm256_srli_epi64(b.val, 32)); + v_zip(v_uint64x4(v0), v_uint64x4(v1), c, d); +} + +inline v_int16x16 v_mul_hi(const v_int16x16& a, const v_int16x16& b) { return v_int16x16(_mm256_mulhi_epi16(a.val, b.val)); } +inline v_uint16x16 v_mul_hi(const v_uint16x16& a, const v_uint16x16& b) { return v_uint16x16(_mm256_mulhi_epu16(a.val, b.val)); } + +/** Bitwise shifts **/ +#define OPENCV_HAL_IMPL_AVX_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, srai) \ + inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm256_slli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ + { return _Tpsvec(_mm256_slli_##suffix(a.val, imm)); } \ + inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm256_srli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ + { return _Tpsvec(srai(a.val, imm)); } \ + template \ + inline _Tpuvec v_shl(const _Tpuvec& a) \ + { return _Tpuvec(_mm256_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shl(const _Tpsvec& a) \ + { return _Tpsvec(_mm256_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpuvec v_shr(const _Tpuvec& a) \ + { return _Tpuvec(_mm256_srli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shr(const _Tpsvec& a) \ + { return _Tpsvec(srai(a.val, imm)); } + +OPENCV_HAL_IMPL_AVX_SHIFT_OP(v_uint16x16, v_int16x16, epi16, _mm256_srai_epi16) +OPENCV_HAL_IMPL_AVX_SHIFT_OP(v_uint32x8, v_int32x8, epi32, _mm256_srai_epi32) + +inline __m256i _mm256_srai_epi64xx(const __m256i a, int imm) +{ + __m256i d = _mm256_set1_epi64x((int64)1 << 63); + __m256i r = _mm256_srli_epi64(_mm256_add_epi64(a, d), imm); + return _mm256_sub_epi64(r, _mm256_srli_epi64(d, imm)); +} +OPENCV_HAL_IMPL_AVX_SHIFT_OP(v_uint64x4, v_int64x4, epi64, _mm256_srai_epi64xx) + + +/** Bitwise logic **/ +#define OPENCV_HAL_IMPL_AVX_LOGIC_OP(_Tpvec, suffix, not_const) \ + OPENCV_HAL_IMPL_AVX_BIN_OP(&, _Tpvec, _mm256_and_##suffix) \ + OPENCV_HAL_IMPL_AVX_BIN_OP(|, _Tpvec, _mm256_or_##suffix) \ + OPENCV_HAL_IMPL_AVX_BIN_OP(^, _Tpvec, _mm256_xor_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { return _Tpvec(_mm256_xor_##suffix(a.val, not_const)); } + +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint8x32, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int8x32, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint16x16, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int16x16, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint32x8, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int32x8, si256, _mm256_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_uint64x4, si256, _mm256_set1_epi64x(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_int64x4, si256, _mm256_set1_epi64x(-1)) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_float32x8, ps, _mm256_castsi256_ps(_mm256_set1_epi32(-1))) +OPENCV_HAL_IMPL_AVX_LOGIC_OP(v_float64x4, pd, _mm256_castsi256_pd(_mm256_set1_epi32(-1))) + +/** Select **/ +#define OPENCV_HAL_IMPL_AVX_SELECT(_Tpvec, suffix) \ + inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_blendv_##suffix(b.val, a.val, mask.val)); } + +OPENCV_HAL_IMPL_AVX_SELECT(v_uint8x32, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_int8x32, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_uint16x16, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_int16x16, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_uint32x8, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_int32x8, epi8) +OPENCV_HAL_IMPL_AVX_SELECT(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_SELECT(v_float64x4, pd) + +/** Comparison **/ +#define OPENCV_HAL_IMPL_AVX_CMP_OP_OV(_Tpvec) \ + inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ + { return ~(a == b); } \ + inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ + { return b > a; } \ + inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ + { return ~(a < b); } \ + inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ + { return b >= a; } + +#define OPENCV_HAL_IMPL_AVX_CMP_OP_INT(_Tpuvec, _Tpsvec, suffix, sbit) \ + inline _Tpuvec operator == (const _Tpuvec& a, const _Tpuvec& b) \ + { return _Tpuvec(_mm256_cmpeq_##suffix(a.val, b.val)); } \ + inline _Tpuvec operator > (const _Tpuvec& a, const _Tpuvec& b) \ + { \ + __m256i smask = _mm256_set1_##suffix(sbit); \ + return _Tpuvec(_mm256_cmpgt_##suffix( \ + _mm256_xor_si256(a.val, smask), \ + _mm256_xor_si256(b.val, smask))); \ + } \ + inline _Tpsvec operator == (const _Tpsvec& a, const _Tpsvec& b) \ + { return _Tpsvec(_mm256_cmpeq_##suffix(a.val, b.val)); } \ + inline _Tpsvec operator > (const _Tpsvec& a, const _Tpsvec& b) \ + { return _Tpsvec(_mm256_cmpgt_##suffix(a.val, b.val)); } \ + OPENCV_HAL_IMPL_AVX_CMP_OP_OV(_Tpuvec) \ + OPENCV_HAL_IMPL_AVX_CMP_OP_OV(_Tpsvec) + +OPENCV_HAL_IMPL_AVX_CMP_OP_INT(v_uint8x32, v_int8x32, epi8, (char)-128) +OPENCV_HAL_IMPL_AVX_CMP_OP_INT(v_uint16x16, v_int16x16, epi16, (short)-32768) +OPENCV_HAL_IMPL_AVX_CMP_OP_INT(v_uint32x8, v_int32x8, epi32, (int)0x80000000) + +#define OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(_Tpvec) \ + inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_cmpeq_epi64(a.val, b.val)); } \ + inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ + { return ~(a == b); } + +OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(v_uint64x4) +OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(v_int64x4) + +#define OPENCV_HAL_IMPL_AVX_CMP_FLT(bin_op, imm8, _Tpvec, suffix) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm256_cmp_##suffix(a.val, b.val, imm8)); } + +#define OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(_Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(==, _CMP_EQ_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(!=, _CMP_NEQ_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(<, _CMP_LT_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(>, _CMP_GT_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(<=, _CMP_LE_OQ, _Tpvec, suffix) \ + OPENCV_HAL_IMPL_AVX_CMP_FLT(>=, _CMP_GE_OQ, _Tpvec, suffix) + +OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(v_float64x4, pd) + +inline v_float32x8 v_not_nan(const v_float32x8& a) +{ return v_float32x8(_mm256_cmp_ps(a.val, a.val, _CMP_ORD_Q)); } +inline v_float64x4 v_not_nan(const v_float64x4& a) +{ return v_float64x4(_mm256_cmp_pd(a.val, a.val, _CMP_ORD_Q)); } + +/** min/max **/ +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint8x32, _mm256_min_epu8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint8x32, _mm256_max_epu8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_int8x32, _mm256_min_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_int8x32, _mm256_max_epi8) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint16x16, _mm256_min_epu16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint16x16, _mm256_max_epu16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_int16x16, _mm256_min_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_int16x16, _mm256_max_epi16) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint32x8, _mm256_min_epu32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint32x8, _mm256_max_epu32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_int32x8, _mm256_min_epi32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_int32x8, _mm256_max_epi32) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_float32x8, _mm256_min_ps) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_float32x8, _mm256_max_ps) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_float64x4, _mm256_min_pd) +OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_float64x4, _mm256_max_pd) + +/** Rotate **/ +template +inline v_uint8x32 v_rotate_left(const v_uint8x32& a, const v_uint8x32& b) +{ + enum {IMM_R = (16 - imm) & 0xFF}; + enum {IMM_R2 = (32 - imm) & 0xFF}; + + if (imm == 0) return a; + if (imm == 32) return b; + if (imm > 32) return v_uint8x32(); + + __m256i swap = _mm256_permute2x128_si256(a.val, b.val, 0x03); + if (imm == 16) return v_uint8x32(swap); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(a.val, swap, IMM_R)); + return v_uint8x32(_mm256_alignr_epi8(swap, b.val, IMM_R2)); // imm < 32 +} + +template +inline v_uint8x32 v_rotate_right(const v_uint8x32& a, const v_uint8x32& b) +{ + enum {IMM_L = (imm - 16) & 0xFF}; + + if (imm == 0) return a; + if (imm == 32) return b; + if (imm > 32) return v_uint8x32(); + + __m256i swap = _mm256_permute2x128_si256(a.val, b.val, 0x21); + if (imm == 16) return v_uint8x32(swap); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(swap, a.val, imm)); + return v_uint8x32(_mm256_alignr_epi8(b.val, swap, IMM_L)); +} + +template +inline v_uint8x32 v_rotate_left(const v_uint8x32& a) +{ + enum {IMM_L = (imm - 16) & 0xFF}; + enum {IMM_R = (16 - imm) & 0xFF}; + + if (imm == 0) return a; + if (imm > 32) return v_uint8x32(); + + // ESAC control[3] ? [127:0] = 0 + __m256i swapz = _mm256_permute2x128_si256(a.val, a.val, _MM_SHUFFLE(0, 0, 2, 0)); + if (imm == 16) return v_uint8x32(swapz); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(a.val, swapz, IMM_R)); + return v_uint8x32(_mm256_slli_si256(swapz, IMM_L)); +} + +template +inline v_uint8x32 v_rotate_right(const v_uint8x32& a) +{ + enum {IMM_L = (imm - 16) & 0xFF}; + + if (imm == 0) return a; + if (imm > 32) return v_uint8x32(); + + // ESAC control[3] ? [127:0] = 0 + __m256i swapz = _mm256_permute2x128_si256(a.val, a.val, _MM_SHUFFLE(2, 0, 0, 1)); + if (imm == 16) return v_uint8x32(swapz); + if (imm < 16) return v_uint8x32(_mm256_alignr_epi8(swapz, a.val, imm)); + return v_uint8x32(_mm256_srli_si256(swapz, IMM_L)); +} + +#define OPENCV_HAL_IMPL_AVX_ROTATE_CAST(intrin, _Tpvec, cast) \ + template \ + inline _Tpvec intrin(const _Tpvec& a, const _Tpvec& b) \ + { \ + enum {IMMxW = imm * sizeof(typename _Tpvec::lane_type)}; \ + v_uint8x32 ret = intrin(v_reinterpret_as_u8(a), \ + v_reinterpret_as_u8(b)); \ + return _Tpvec(cast(ret.val)); \ + } \ + template \ + inline _Tpvec intrin(const _Tpvec& a) \ + { \ + enum {IMMxW = imm * sizeof(typename _Tpvec::lane_type)}; \ + v_uint8x32 ret = intrin(v_reinterpret_as_u8(a)); \ + return _Tpvec(cast(ret.val)); \ + } + +#define OPENCV_HAL_IMPL_AVX_ROTATE(_Tpvec) \ + OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_left, _Tpvec, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_right, _Tpvec, OPENCV_HAL_NOP) + +OPENCV_HAL_IMPL_AVX_ROTATE(v_int8x32) +OPENCV_HAL_IMPL_AVX_ROTATE(v_uint16x16) +OPENCV_HAL_IMPL_AVX_ROTATE(v_int16x16) +OPENCV_HAL_IMPL_AVX_ROTATE(v_uint32x8) +OPENCV_HAL_IMPL_AVX_ROTATE(v_int32x8) +OPENCV_HAL_IMPL_AVX_ROTATE(v_uint64x4) +OPENCV_HAL_IMPL_AVX_ROTATE(v_int64x4) + +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_left, v_float32x8, _mm256_castsi256_ps) +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_right, v_float32x8, _mm256_castsi256_ps) +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_left, v_float64x4, _mm256_castsi256_pd) +OPENCV_HAL_IMPL_AVX_ROTATE_CAST(v_rotate_right, v_float64x4, _mm256_castsi256_pd) + +/** Reverse **/ +inline v_uint8x32 v_reverse(const v_uint8x32 &a) +{ + static const __m256i perm = _mm256_setr_epi8( + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); + __m256i vec = _mm256_shuffle_epi8(a.val, perm); + return v_uint8x32(_mm256_permute2x128_si256(vec, vec, 1)); +} + +inline v_int8x32 v_reverse(const v_int8x32 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x16 v_reverse(const v_uint16x16 &a) +{ + static const __m256i perm = _mm256_setr_epi8( + 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1, + 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1); + __m256i vec = _mm256_shuffle_epi8(a.val, perm); + return v_uint16x16(_mm256_permute2x128_si256(vec, vec, 1)); +} + +inline v_int16x16 v_reverse(const v_int16x16 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x8 v_reverse(const v_uint32x8 &a) +{ + static const __m256i perm = _mm256_setr_epi32(7, 6, 5, 4, 3, 2, 1, 0); + return v_uint32x8(_mm256_permutevar8x32_epi32(a.val, perm)); +} + +inline v_int32x8 v_reverse(const v_int32x8 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x8 v_reverse(const v_float32x8 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x4 v_reverse(const v_uint64x4 &a) +{ + return v_uint64x4(_mm256_permute4x64_epi64(a.val, _MM_SHUFFLE(0, 1, 2, 3))); +} + +inline v_int64x4 v_reverse(const v_int64x4 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x4 v_reverse(const v_float64x4 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +////////// Reduce and mask ///////// + +/** Reduce **/ +inline unsigned v_reduce_sum(const v_uint8x32& a) +{ + __m256i half = _mm256_sad_epu8(a.val, _mm256_setzero_si256()); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline int v_reduce_sum(const v_int8x32& a) +{ + __m256i half = _mm256_sad_epu8(_mm256_xor_si256(a.val, _mm256_set1_epi8((schar)-128)), _mm256_setzero_si256()); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))) - 4096; +} +#define OPENCV_HAL_IMPL_AVX_REDUCE_32(_Tpvec, sctype, func, intrin) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { \ + __m128i val = intrin(_v256_extract_low(a.val), _v256_extract_high(a.val)); \ + val = intrin(val, _mm_srli_si128(val,8)); \ + val = intrin(val, _mm_srli_si128(val,4)); \ + val = intrin(val, _mm_srli_si128(val,2)); \ + val = intrin(val, _mm_srli_si128(val,1)); \ + return (sctype)_mm_cvtsi128_si32(val); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_uint8x32, uchar, min, _mm_min_epu8) +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_int8x32, schar, min, _mm_min_epi8) +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_uint8x32, uchar, max, _mm_max_epu8) +OPENCV_HAL_IMPL_AVX_REDUCE_32(v_int8x32, schar, max, _mm_max_epi8) + +#define OPENCV_HAL_IMPL_AVX_REDUCE_16(_Tpvec, sctype, func, intrin) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { \ + __m128i v0 = _v256_extract_low(a.val); \ + __m128i v1 = _v256_extract_high(a.val); \ + v0 = intrin(v0, v1); \ + v0 = intrin(v0, _mm_srli_si128(v0, 8)); \ + v0 = intrin(v0, _mm_srli_si128(v0, 4)); \ + v0 = intrin(v0, _mm_srli_si128(v0, 2)); \ + return (sctype) _mm_cvtsi128_si32(v0); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_uint16x16, ushort, min, _mm_min_epu16) +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_int16x16, short, min, _mm_min_epi16) +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_uint16x16, ushort, max, _mm_max_epu16) +OPENCV_HAL_IMPL_AVX_REDUCE_16(v_int16x16, short, max, _mm_max_epi16) + +#define OPENCV_HAL_IMPL_AVX_REDUCE_8(_Tpvec, sctype, func, intrin) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { \ + __m128i v0 = _v256_extract_low(a.val); \ + __m128i v1 = _v256_extract_high(a.val); \ + v0 = intrin(v0, v1); \ + v0 = intrin(v0, _mm_srli_si128(v0, 8)); \ + v0 = intrin(v0, _mm_srli_si128(v0, 4)); \ + return (sctype) _mm_cvtsi128_si32(v0); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_uint32x8, unsigned, min, _mm_min_epu32) +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_int32x8, int, min, _mm_min_epi32) +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_uint32x8, unsigned, max, _mm_max_epu32) +OPENCV_HAL_IMPL_AVX_REDUCE_8(v_int32x8, int, max, _mm_max_epi32) + +#define OPENCV_HAL_IMPL_AVX_REDUCE_FLT(func, intrin) \ + inline float v_reduce_##func(const v_float32x8& a) \ + { \ + __m128 v0 = _v256_extract_low(a.val); \ + __m128 v1 = _v256_extract_high(a.val); \ + v0 = intrin(v0, v1); \ + v0 = intrin(v0, _mm_permute_ps(v0, _MM_SHUFFLE(0, 0, 3, 2))); \ + v0 = intrin(v0, _mm_permute_ps(v0, _MM_SHUFFLE(0, 0, 0, 1))); \ + return _mm_cvtss_f32(v0); \ + } + +OPENCV_HAL_IMPL_AVX_REDUCE_FLT(min, _mm_min_ps) +OPENCV_HAL_IMPL_AVX_REDUCE_FLT(max, _mm_max_ps) + +inline int v_reduce_sum(const v_int32x8& a) +{ + __m256i s0 = _mm256_hadd_epi32(a.val, a.val); + s0 = _mm256_hadd_epi32(s0, s0); + + __m128i s1 = _v256_extract_high(s0); + s1 = _mm_add_epi32(_v256_extract_low(s0), s1); + + return _mm_cvtsi128_si32(s1); +} + +inline unsigned v_reduce_sum(const v_uint32x8& a) +{ return v_reduce_sum(v_reinterpret_as_s32(a)); } + +inline int v_reduce_sum(const v_int16x16& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } +inline unsigned v_reduce_sum(const v_uint16x16& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } + +inline float v_reduce_sum(const v_float32x8& a) +{ + __m256 s0 = _mm256_hadd_ps(a.val, a.val); + s0 = _mm256_hadd_ps(s0, s0); + + __m128 s1 = _v256_extract_high(s0); + s1 = _mm_add_ps(_v256_extract_low(s0), s1); + + return _mm_cvtss_f32(s1); +} + +inline uint64 v_reduce_sum(const v_uint64x4& a) +{ + uint64 CV_DECL_ALIGNED(32) idx[2]; + _mm_store_si128((__m128i*)idx, _mm_add_epi64(_v256_extract_low(a.val), _v256_extract_high(a.val))); + return idx[0] + idx[1]; +} +inline int64 v_reduce_sum(const v_int64x4& a) +{ + int64 CV_DECL_ALIGNED(32) idx[2]; + _mm_store_si128((__m128i*)idx, _mm_add_epi64(_v256_extract_low(a.val), _v256_extract_high(a.val))); + return idx[0] + idx[1]; +} +inline double v_reduce_sum(const v_float64x4& a) +{ + __m256d s0 = _mm256_hadd_pd(a.val, a.val); + return _mm_cvtsd_f64(_mm_add_pd(_v256_extract_low(s0), _v256_extract_high(s0))); +} + +inline v_float32x8 v_reduce_sum4(const v_float32x8& a, const v_float32x8& b, + const v_float32x8& c, const v_float32x8& d) +{ + __m256 ab = _mm256_hadd_ps(a.val, b.val); + __m256 cd = _mm256_hadd_ps(c.val, d.val); + return v_float32x8(_mm256_hadd_ps(ab, cd)); +} + +inline unsigned v_reduce_sad(const v_uint8x32& a, const v_uint8x32& b) +{ + __m256i half = _mm256_sad_epu8(a.val, b.val); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_int8x32& a, const v_int8x32& b) +{ + __m256i half = _mm256_set1_epi8(0x7f); + half = _mm256_sad_epu8(_mm256_add_epi8(a.val, half), _mm256_add_epi8(b.val, half)); + __m128i quarter = _mm_add_epi32(_v256_extract_low(half), _v256_extract_high(half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_uint16x16& a, const v_uint16x16& b) +{ + v_uint32x8 l, h; + v_expand(v_add_wrap(a - b, b - a), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_int16x16& a, const v_int16x16& b) +{ + v_uint32x8 l, h; + v_expand(v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_uint32x8& a, const v_uint32x8& b) +{ + return v_reduce_sum(v_max(a, b) - v_min(a, b)); +} +inline unsigned v_reduce_sad(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 m = a < b; + return v_reduce_sum(v_reinterpret_as_u32(((a - b) ^ m) - m)); +} +inline float v_reduce_sad(const v_float32x8& a, const v_float32x8& b) +{ + return v_reduce_sum((a - b) & v_float32x8(_mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff)))); +} + +/** Popcount **/ +inline v_uint8x32 v_popcount(const v_uint8x32& a) +{ + __m256i _popcnt_table = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4); + __m256i _popcnt_mask = _mm256_set1_epi8(0x0F); + return v_uint8x32(_mm256_add_epi8(_mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256( a.val , _popcnt_mask)), + _mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256(_mm256_srli_epi16(a.val, 4), _popcnt_mask)))); +} +inline v_uint16x16 v_popcount(const v_uint16x16& a) +{ + v_uint8x32 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v256_setall_u16(0x00ff); +} +inline v_uint32x8 v_popcount(const v_uint32x8& a) +{ + v_uint8x32 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v256_setall_u32(0x000000ff); +} +inline v_uint64x4 v_popcount(const v_uint64x4& a) +{ + return v_uint64x4(_mm256_sad_epu8(v_popcount(v_reinterpret_as_u8(a)).val, _mm256_setzero_si256())); +} +inline v_uint8x32 v_popcount(const v_int8x32& a) +{ return v_popcount(v_reinterpret_as_u8(a)); } +inline v_uint16x16 v_popcount(const v_int16x16& a) +{ return v_popcount(v_reinterpret_as_u16(a)); } +inline v_uint32x8 v_popcount(const v_int32x8& a) +{ return v_popcount(v_reinterpret_as_u32(a)); } +inline v_uint64x4 v_popcount(const v_int64x4& a) +{ return v_popcount(v_reinterpret_as_u64(a)); } + +/** Mask **/ +inline int v_signmask(const v_int8x32& a) +{ return _mm256_movemask_epi8(a.val); } +inline int v_signmask(const v_uint8x32& a) +{ return v_signmask(v_reinterpret_as_s8(a)); } + +inline int v_signmask(const v_int16x16& a) +{ return v_signmask(v_pack(a, a)) & 0xFFFF; } +inline int v_signmask(const v_uint16x16& a) +{ return v_signmask(v_reinterpret_as_s16(a)); } + +inline int v_signmask(const v_float32x8& a) +{ return _mm256_movemask_ps(a.val); } +inline int v_signmask(const v_float64x4& a) +{ return _mm256_movemask_pd(a.val); } + +inline int v_signmask(const v_int32x8& a) +{ return v_signmask(v_reinterpret_as_f32(a)); } +inline int v_signmask(const v_uint32x8& a) +{ return v_signmask(v_reinterpret_as_f32(a)); } + +inline int v_signmask(const v_int64x4& a) +{ return v_signmask(v_reinterpret_as_f64(a)); } +inline int v_signmask(const v_uint64x4& a) +{ return v_signmask(v_reinterpret_as_f64(a)); } + +inline int v_scan_forward(const v_int8x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_uint8x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_int16x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_uint16x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_int32x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_uint32x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_float32x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_int64x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_uint64x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_float64x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } + +/** Checks **/ +#define OPENCV_HAL_IMPL_AVX_CHECK(_Tpvec, allmask) \ + inline bool v_check_all(const _Tpvec& a) { return v_signmask(a) == allmask; } \ + inline bool v_check_any(const _Tpvec& a) { return v_signmask(a) != 0; } +OPENCV_HAL_IMPL_AVX_CHECK(v_uint8x32, -1) +OPENCV_HAL_IMPL_AVX_CHECK(v_int8x32, -1) +OPENCV_HAL_IMPL_AVX_CHECK(v_uint32x8, 255) +OPENCV_HAL_IMPL_AVX_CHECK(v_int32x8, 255) +OPENCV_HAL_IMPL_AVX_CHECK(v_uint64x4, 15) +OPENCV_HAL_IMPL_AVX_CHECK(v_int64x4, 15) +OPENCV_HAL_IMPL_AVX_CHECK(v_float32x8, 255) +OPENCV_HAL_IMPL_AVX_CHECK(v_float64x4, 15) + +#define OPENCV_HAL_IMPL_AVX_CHECK_SHORT(_Tpvec) \ + inline bool v_check_all(const _Tpvec& a) { return (v_signmask(v_reinterpret_as_s8(a)) & 0xaaaaaaaa) == 0xaaaaaaaa; } \ + inline bool v_check_any(const _Tpvec& a) { return (v_signmask(v_reinterpret_as_s8(a)) & 0xaaaaaaaa) != 0; } +OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_uint16x16) +OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_int16x16) + +////////// Other math ///////// + +/** Some frequent operations **/ +#if CV_FMA3 +#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } +#else +#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } +#endif + +#define OPENCV_HAL_IMPL_AVX_MISC(_Tpvec, suffix) \ + inline _Tpvec v_sqrt(const _Tpvec& x) \ + { return _Tpvec(_mm256_sqrt_##suffix(x.val)); } \ + inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_fma(a, a, b * b); } \ + inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_sqrt(v_fma(a, a, b*b)); } + +OPENCV_HAL_IMPL_AVX_MULADD(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_MULADD(v_float64x4, pd) +OPENCV_HAL_IMPL_AVX_MISC(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_MISC(v_float64x4, pd) + +inline v_int32x8 v_fma(const v_int32x8& a, const v_int32x8& b, const v_int32x8& c) +{ + return a * b + c; +} + +inline v_int32x8 v_muladd(const v_int32x8& a, const v_int32x8& b, const v_int32x8& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x8 v_invsqrt(const v_float32x8& x) +{ + v_float32x8 half = x * v256_setall_f32(0.5); + v_float32x8 t = v_float32x8(_mm256_rsqrt_ps(x.val)); + // todo: _mm256_fnmsub_ps + t *= v256_setall_f32(1.5) - ((t * t) * half); + return t; +} + +inline v_float64x4 v_invsqrt(const v_float64x4& x) +{ + return v256_setall_f64(1.) / v_sqrt(x); +} + +/** Absolute values **/ +#define OPENCV_HAL_IMPL_AVX_ABS(_Tpvec, suffix) \ + inline v_u##_Tpvec v_abs(const v_##_Tpvec& x) \ + { return v_u##_Tpvec(_mm256_abs_##suffix(x.val)); } + +OPENCV_HAL_IMPL_AVX_ABS(int8x32, epi8) +OPENCV_HAL_IMPL_AVX_ABS(int16x16, epi16) +OPENCV_HAL_IMPL_AVX_ABS(int32x8, epi32) + +inline v_float32x8 v_abs(const v_float32x8& x) +{ return x & v_float32x8(_mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff))); } +inline v_float64x4 v_abs(const v_float64x4& x) +{ return x & v_float64x4(_mm256_castsi256_pd(_mm256_srli_epi64(_mm256_set1_epi64x(-1), 1))); } + +/** Absolute difference **/ +inline v_uint8x32 v_absdiff(const v_uint8x32& a, const v_uint8x32& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x16 v_absdiff(const v_uint16x16& a, const v_uint16x16& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x8 v_absdiff(const v_uint32x8& a, const v_uint32x8& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x32 v_absdiff(const v_int8x32& a, const v_int8x32& b) +{ + v_int8x32 d = v_sub_wrap(a, b); + v_int8x32 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} + +inline v_uint16x16 v_absdiff(const v_int16x16& a, const v_int16x16& b) +{ return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); } + +inline v_uint32x8 v_absdiff(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 d = a - b; + v_int32x8 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +inline v_float32x8 v_absdiff(const v_float32x8& a, const v_float32x8& b) +{ return v_abs(a - b); } + +inline v_float64x4 v_absdiff(const v_float64x4& a, const v_float64x4& b) +{ return v_abs(a - b); } + +/** Saturating absolute difference **/ +inline v_int8x32 v_absdiffs(const v_int8x32& a, const v_int8x32& b) +{ + v_int8x32 d = a - b; + v_int8x32 m = a < b; + return (d ^ m) - m; +} +inline v_int16x16 v_absdiffs(const v_int16x16& a, const v_int16x16& b) +{ return v_max(a, b) - v_min(a, b); } + +////////// Conversions ///////// + +/** Rounding **/ +inline v_int32x8 v_round(const v_float32x8& a) +{ return v_int32x8(_mm256_cvtps_epi32(a.val)); } + +inline v_int32x8 v_round(const v_float64x4& a) +{ return v_int32x8(_mm256_castsi128_si256(_mm256_cvtpd_epi32(a.val))); } + +inline v_int32x8 v_round(const v_float64x4& a, const v_float64x4& b) +{ + __m128i ai = _mm256_cvtpd_epi32(a.val), bi = _mm256_cvtpd_epi32(b.val); + return v_int32x8(_v256_combine(ai, bi)); +} + +inline v_int32x8 v_trunc(const v_float32x8& a) +{ return v_int32x8(_mm256_cvttps_epi32(a.val)); } + +inline v_int32x8 v_trunc(const v_float64x4& a) +{ return v_int32x8(_mm256_castsi128_si256(_mm256_cvttpd_epi32(a.val))); } + +inline v_int32x8 v_floor(const v_float32x8& a) +{ return v_int32x8(_mm256_cvttps_epi32(_mm256_floor_ps(a.val))); } + +inline v_int32x8 v_floor(const v_float64x4& a) +{ return v_trunc(v_float64x4(_mm256_floor_pd(a.val))); } + +inline v_int32x8 v_ceil(const v_float32x8& a) +{ return v_int32x8(_mm256_cvttps_epi32(_mm256_ceil_ps(a.val))); } + +inline v_int32x8 v_ceil(const v_float64x4& a) +{ return v_trunc(v_float64x4(_mm256_ceil_pd(a.val))); } + +/** To float **/ +inline v_float32x8 v_cvt_f32(const v_int32x8& a) +{ return v_float32x8(_mm256_cvtepi32_ps(a.val)); } + +inline v_float32x8 v_cvt_f32(const v_float64x4& a) +{ return v_float32x8(_mm256_castps128_ps256(_mm256_cvtpd_ps(a.val))); } + +inline v_float32x8 v_cvt_f32(const v_float64x4& a, const v_float64x4& b) +{ + __m128 af = _mm256_cvtpd_ps(a.val), bf = _mm256_cvtpd_ps(b.val); + return v_float32x8(_v256_combine(af, bf)); +} + +inline v_float64x4 v_cvt_f64(const v_int32x8& a) +{ return v_float64x4(_mm256_cvtepi32_pd(_v256_extract_low(a.val))); } + +inline v_float64x4 v_cvt_f64_high(const v_int32x8& a) +{ return v_float64x4(_mm256_cvtepi32_pd(_v256_extract_high(a.val))); } + +inline v_float64x4 v_cvt_f64(const v_float32x8& a) +{ return v_float64x4(_mm256_cvtps_pd(_v256_extract_low(a.val))); } + +inline v_float64x4 v_cvt_f64_high(const v_float32x8& a) +{ return v_float64x4(_mm256_cvtps_pd(_v256_extract_high(a.val))); } + +// from (Mysticial and wim) https://stackoverflow.com/q/41144668 +inline v_float64x4 v_cvt_f64(const v_int64x4& v) +{ + // constants encoded as floating-point + __m256i magic_i_lo = _mm256_set1_epi64x(0x4330000000000000); // 2^52 + __m256i magic_i_hi32 = _mm256_set1_epi64x(0x4530000080000000); // 2^84 + 2^63 + __m256i magic_i_all = _mm256_set1_epi64x(0x4530000080100000); // 2^84 + 2^63 + 2^52 + __m256d magic_d_all = _mm256_castsi256_pd(magic_i_all); + + // Blend the 32 lowest significant bits of v with magic_int_lo + __m256i v_lo = _mm256_blend_epi32(magic_i_lo, v.val, 0x55); + // Extract the 32 most significant bits of v + __m256i v_hi = _mm256_srli_epi64(v.val, 32); + // Flip the msb of v_hi and blend with 0x45300000 + v_hi = _mm256_xor_si256(v_hi, magic_i_hi32); + // Compute in double precision + __m256d v_hi_dbl = _mm256_sub_pd(_mm256_castsi256_pd(v_hi), magic_d_all); + // (v_hi - magic_d_all) + v_lo Do not assume associativity of floating point addition + __m256d result = _mm256_add_pd(v_hi_dbl, _mm256_castsi256_pd(v_lo)); + return v_float64x4(result); +} + +////////////// Lookup table access //////////////////// + +inline v_int8x32 v256_lut(const schar* tab, const int* idx) +{ + return v_int8x32(_mm256_setr_epi8(tab[idx[ 0]], tab[idx[ 1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[ 8]], tab[idx[ 9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]], + tab[idx[16]], tab[idx[17]], tab[idx[18]], tab[idx[19]], tab[idx[20]], tab[idx[21]], tab[idx[22]], tab[idx[23]], + tab[idx[24]], tab[idx[25]], tab[idx[26]], tab[idx[27]], tab[idx[28]], tab[idx[29]], tab[idx[30]], tab[idx[31]])); +} +inline v_int8x32 v256_lut_pairs(const schar* tab, const int* idx) +{ + return v_int8x32(_mm256_setr_epi16(*(const short*)(tab + idx[ 0]), *(const short*)(tab + idx[ 1]), *(const short*)(tab + idx[ 2]), *(const short*)(tab + idx[ 3]), + *(const short*)(tab + idx[ 4]), *(const short*)(tab + idx[ 5]), *(const short*)(tab + idx[ 6]), *(const short*)(tab + idx[ 7]), + *(const short*)(tab + idx[ 8]), *(const short*)(tab + idx[ 9]), *(const short*)(tab + idx[10]), *(const short*)(tab + idx[11]), + *(const short*)(tab + idx[12]), *(const short*)(tab + idx[13]), *(const short*)(tab + idx[14]), *(const short*)(tab + idx[15]))); +} +inline v_int8x32 v256_lut_quads(const schar* tab, const int* idx) +{ + return v_int8x32(_mm256_i32gather_epi32((const int*)tab, _mm256_loadu_si256((const __m256i*)idx), 1)); +} +inline v_uint8x32 v256_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v256_lut((const schar *)tab, idx)); } +inline v_uint8x32 v256_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v256_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x32 v256_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v256_lut_quads((const schar *)tab, idx)); } + +inline v_int16x16 v256_lut(const short* tab, const int* idx) +{ + return v_int16x16(_mm256_setr_epi16(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]])); +} +inline v_int16x16 v256_lut_pairs(const short* tab, const int* idx) +{ + return v_int16x16(_mm256_i32gather_epi32((const int*)tab, _mm256_loadu_si256((const __m256i*)idx), 2)); +} +inline v_int16x16 v256_lut_quads(const short* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int16x16(_mm256_i32gather_epi64((const long long int*)tab, _mm_loadu_si128((const __m128i*)idx), 2));//Looks like intrinsic has wrong definition +#else + return v_int16x16(_mm256_i32gather_epi64((const int64*)tab, _mm_loadu_si128((const __m128i*)idx), 2)); +#endif +} +inline v_uint16x16 v256_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v256_lut((const short *)tab, idx)); } +inline v_uint16x16 v256_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v256_lut_pairs((const short *)tab, idx)); } +inline v_uint16x16 v256_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v256_lut_quads((const short *)tab, idx)); } + +inline v_int32x8 v256_lut(const int* tab, const int* idx) +{ + return v_int32x8(_mm256_i32gather_epi32(tab, _mm256_loadu_si256((const __m256i*)idx), 4)); +} +inline v_int32x8 v256_lut_pairs(const int* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int32x8(_mm256_i32gather_epi64((const long long int*)tab, _mm_loadu_si128((const __m128i*)idx), 4)); +#else + return v_int32x8(_mm256_i32gather_epi64((const int64*)tab, _mm_loadu_si128((const __m128i*)idx), 4)); +#endif +} +inline v_int32x8 v256_lut_quads(const int* tab, const int* idx) +{ + return v_int32x8(_v256_combine(_mm_loadu_si128((const __m128i*)(tab + idx[0])), _mm_loadu_si128((const __m128i*)(tab + idx[1])))); +} +inline v_uint32x8 v256_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v256_lut((const int *)tab, idx)); } +inline v_uint32x8 v256_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v256_lut_pairs((const int *)tab, idx)); } +inline v_uint32x8 v256_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v256_lut_quads((const int *)tab, idx)); } + +inline v_int64x4 v256_lut(const int64* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int64x4(_mm256_i32gather_epi64((const long long int*)tab, _mm_loadu_si128((const __m128i*)idx), 8)); +#else + return v_int64x4(_mm256_i32gather_epi64(tab, _mm_loadu_si128((const __m128i*)idx), 8)); +#endif +} +inline v_int64x4 v256_lut_pairs(const int64* tab, const int* idx) +{ + return v_int64x4(_v256_combine(_mm_loadu_si128((const __m128i*)(tab + idx[0])), _mm_loadu_si128((const __m128i*)(tab + idx[1])))); +} +inline v_uint64x4 v256_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v256_lut((const int64 *)tab, idx)); } +inline v_uint64x4 v256_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v256_lut_pairs((const int64 *)tab, idx)); } + +inline v_float32x8 v256_lut(const float* tab, const int* idx) +{ + return v_float32x8(_mm256_i32gather_ps(tab, _mm256_loadu_si256((const __m256i*)idx), 4)); +} +inline v_float32x8 v256_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v256_lut_pairs((const int *)tab, idx)); } +inline v_float32x8 v256_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v256_lut_quads((const int *)tab, idx)); } + +inline v_float64x4 v256_lut(const double* tab, const int* idx) +{ + return v_float64x4(_mm256_i32gather_pd(tab, _mm_loadu_si128((const __m128i*)idx), 8)); +} +inline v_float64x4 v256_lut_pairs(const double* tab, const int* idx) { return v_float64x4(_v256_combine(_mm_loadu_pd(tab + idx[0]), _mm_loadu_pd(tab + idx[1]))); } + +inline v_int32x8 v_lut(const int* tab, const v_int32x8& idxvec) +{ + return v_int32x8(_mm256_i32gather_epi32(tab, idxvec.val, 4)); +} + +inline v_uint32x8 v_lut(const unsigned* tab, const v_int32x8& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x8 v_lut(const float* tab, const v_int32x8& idxvec) +{ + return v_float32x8(_mm256_i32gather_ps(tab, idxvec.val, 4)); +} + +inline v_float64x4 v_lut(const double* tab, const v_int32x8& idxvec) +{ + return v_float64x4(_mm256_i32gather_pd(tab, _mm256_castsi256_si128(idxvec.val), 8)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x8& idxvec, v_float32x8& x, v_float32x8& y) +{ + int CV_DECL_ALIGNED(32) idx[8]; + v_store_aligned(idx, idxvec); + __m128 z = _mm_setzero_ps(); + __m128 xy01, xy45, xy23, xy67; + xy01 = _mm_loadl_pi(z, (const __m64*)(tab + idx[0])); + xy01 = _mm_loadh_pi(xy01, (const __m64*)(tab + idx[1])); + xy45 = _mm_loadl_pi(z, (const __m64*)(tab + idx[4])); + xy45 = _mm_loadh_pi(xy45, (const __m64*)(tab + idx[5])); + __m256 xy0145 = _v256_combine(xy01, xy45); + xy23 = _mm_loadl_pi(z, (const __m64*)(tab + idx[2])); + xy23 = _mm_loadh_pi(xy23, (const __m64*)(tab + idx[3])); + xy67 = _mm_loadl_pi(z, (const __m64*)(tab + idx[6])); + xy67 = _mm_loadh_pi(xy67, (const __m64*)(tab + idx[7])); + __m256 xy2367 = _v256_combine(xy23, xy67); + + __m256 xxyy0145 = _mm256_unpacklo_ps(xy0145, xy2367); + __m256 xxyy2367 = _mm256_unpackhi_ps(xy0145, xy2367); + + x = v_float32x8(_mm256_unpacklo_ps(xxyy0145, xxyy2367)); + y = v_float32x8(_mm256_unpackhi_ps(xxyy0145, xxyy2367)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x8& idxvec, v_float64x4& x, v_float64x4& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_low(idx, idxvec); + __m128d xy0 = _mm_loadu_pd(tab + idx[0]); + __m128d xy2 = _mm_loadu_pd(tab + idx[2]); + __m128d xy1 = _mm_loadu_pd(tab + idx[1]); + __m128d xy3 = _mm_loadu_pd(tab + idx[3]); + __m256d xy02 = _v256_combine(xy0, xy2); + __m256d xy13 = _v256_combine(xy1, xy3); + + x = v_float64x4(_mm256_unpacklo_pd(xy02, xy13)); + y = v_float64x4(_mm256_unpackhi_pd(xy02, xy13)); +} + +inline v_int8x32 v_interleave_pairs(const v_int8x32& vec) +{ + return v_int8x32(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0d0e0c0b090a08, 0x0705060403010200, 0x0f0d0e0c0b090a08, 0x0705060403010200))); +} +inline v_uint8x32 v_interleave_pairs(const v_uint8x32& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x32 v_interleave_quads(const v_int8x32& vec) +{ + return v_int8x32(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0b0e0a0d090c08, 0x0703060205010400, 0x0f0b0e0a0d090c08, 0x0703060205010400))); +} +inline v_uint8x32 v_interleave_quads(const v_uint8x32& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x16 v_interleave_pairs(const v_int16x16& vec) +{ + return v_int16x16(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0e0b0a0d0c0908, 0x0706030205040100, 0x0f0e0b0a0d0c0908, 0x0706030205040100))); +} +inline v_uint16x16 v_interleave_pairs(const v_uint16x16& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x16 v_interleave_quads(const v_int16x16& vec) +{ + return v_int16x16(_mm256_shuffle_epi8(vec.val, _mm256_set_epi64x(0x0f0e07060d0c0504, 0x0b0a030209080100, 0x0f0e07060d0c0504, 0x0b0a030209080100))); +} +inline v_uint16x16 v_interleave_quads(const v_uint16x16& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x8 v_interleave_pairs(const v_int32x8& vec) +{ + return v_int32x8(_mm256_shuffle_epi32(vec.val, _MM_SHUFFLE(3, 1, 2, 0))); +} +inline v_uint32x8 v_interleave_pairs(const v_uint32x8& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x8 v_interleave_pairs(const v_float32x8& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x32 v_pack_triplets(const v_int8x32& vec) +{ + return v_int8x32(_mm256_permutevar8x32_epi32(_mm256_shuffle_epi8(vec.val, _mm256_broadcastsi128_si256(_mm_set_epi64x(0xffffff0f0e0d0c0a, 0x0908060504020100))), + _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} +inline v_uint8x32 v_pack_triplets(const v_uint8x32& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x16 v_pack_triplets(const v_int16x16& vec) +{ + return v_int16x16(_mm256_permutevar8x32_epi32(_mm256_shuffle_epi8(vec.val, _mm256_broadcastsi128_si256(_mm_set_epi64x(0xffff0f0e0d0c0b0a, 0x0908050403020100))), + _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} +inline v_uint16x16 v_pack_triplets(const v_uint16x16& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x8 v_pack_triplets(const v_int32x8& vec) +{ + return v_int32x8(_mm256_permutevar8x32_epi32(vec.val, _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} +inline v_uint32x8 v_pack_triplets(const v_uint32x8& vec) { return v_reinterpret_as_u32(v_pack_triplets(v_reinterpret_as_s32(vec))); } +inline v_float32x8 v_pack_triplets(const v_float32x8& vec) +{ + return v_float32x8(_mm256_permutevar8x32_ps(vec.val, _mm256_set_epi64x(0x0000000700000007, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000))); +} + +////////// Matrix operations ///////// + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x8 v_dotprod(const v_int16x16& a, const v_int16x16& b) +{ return v_int32x8(_mm256_madd_epi16(a.val, b.val)); } +inline v_int32x8 v_dotprod(const v_int16x16& a, const v_int16x16& b, const v_int32x8& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x4 v_dotprod(const v_int32x8& a, const v_int32x8& b) +{ + __m256i even = _mm256_mul_epi32(a.val, b.val); + __m256i odd = _mm256_mul_epi32(_mm256_srli_epi64(a.val, 32), _mm256_srli_epi64(b.val, 32)); + return v_int64x4(_mm256_add_epi64(even, odd)); +} +inline v_int64x4 v_dotprod(const v_int32x8& a, const v_int32x8& b, const v_int64x4& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x8 v_dotprod_expand(const v_uint8x32& a, const v_uint8x32& b) +{ + __m256i even_m = _mm256_set1_epi32(0xFF00FF00); + __m256i even_a = _mm256_blendv_epi8(a.val, _mm256_setzero_si256(), even_m); + __m256i odd_a = _mm256_srli_epi16(a.val, 8); + + __m256i even_b = _mm256_blendv_epi8(b.val, _mm256_setzero_si256(), even_m); + __m256i odd_b = _mm256_srli_epi16(b.val, 8); + + __m256i prod0 = _mm256_madd_epi16(even_a, even_b); + __m256i prod1 = _mm256_madd_epi16(odd_a, odd_b); + return v_uint32x8(_mm256_add_epi32(prod0, prod1)); +} +inline v_uint32x8 v_dotprod_expand(const v_uint8x32& a, const v_uint8x32& b, const v_uint32x8& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x8 v_dotprod_expand(const v_int8x32& a, const v_int8x32& b) +{ + __m256i even_a = _mm256_srai_epi16(_mm256_bslli_epi128(a.val, 1), 8); + __m256i odd_a = _mm256_srai_epi16(a.val, 8); + + __m256i even_b = _mm256_srai_epi16(_mm256_bslli_epi128(b.val, 1), 8); + __m256i odd_b = _mm256_srai_epi16(b.val, 8); + + __m256i prod0 = _mm256_madd_epi16(even_a, even_b); + __m256i prod1 = _mm256_madd_epi16(odd_a, odd_b); + return v_int32x8(_mm256_add_epi32(prod0, prod1)); +} +inline v_int32x8 v_dotprod_expand(const v_int8x32& a, const v_int8x32& b, const v_int32x8& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x4 v_dotprod_expand(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i mullo = _mm256_mullo_epi16(a.val, b.val); + __m256i mulhi = _mm256_mulhi_epu16(a.val, b.val); + __m256i mul0 = _mm256_unpacklo_epi16(mullo, mulhi); + __m256i mul1 = _mm256_unpackhi_epi16(mullo, mulhi); + + __m256i p02 = _mm256_blend_epi32(mul0, _mm256_setzero_si256(), 0xAA); + __m256i p13 = _mm256_srli_epi64(mul0, 32); + __m256i p46 = _mm256_blend_epi32(mul1, _mm256_setzero_si256(), 0xAA); + __m256i p57 = _mm256_srli_epi64(mul1, 32); + + __m256i p15_ = _mm256_add_epi64(p02, p13); + __m256i p9d_ = _mm256_add_epi64(p46, p57); + + return v_uint64x4(_mm256_add_epi64( + _mm256_unpacklo_epi64(p15_, p9d_), + _mm256_unpackhi_epi64(p15_, p9d_) + )); +} +inline v_uint64x4 v_dotprod_expand(const v_uint16x16& a, const v_uint16x16& b, const v_uint64x4& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x4 v_dotprod_expand(const v_int16x16& a, const v_int16x16& b) +{ + __m256i prod = _mm256_madd_epi16(a.val, b.val); + __m256i sign = _mm256_srai_epi32(prod, 31); + + __m256i lo = _mm256_unpacklo_epi32(prod, sign); + __m256i hi = _mm256_unpackhi_epi32(prod, sign); + + return v_int64x4(_mm256_add_epi64( + _mm256_unpacklo_epi64(lo, hi), + _mm256_unpackhi_epi64(lo, hi) + )); +} +inline v_int64x4 v_dotprod_expand(const v_int16x16& a, const v_int16x16& b, const v_int64x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x4 v_dotprod_expand(const v_int32x8& a, const v_int32x8& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x4 v_dotprod_expand(const v_int32x8& a, const v_int32x8& b, const v_float64x4& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x8 v_dotprod_fast(const v_int16x16& a, const v_int16x16& b) +{ return v_dotprod(a, b); } +inline v_int32x8 v_dotprod_fast(const v_int16x16& a, const v_int16x16& b, const v_int32x8& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x4 v_dotprod_fast(const v_int32x8& a, const v_int32x8& b) +{ return v_dotprod(a, b); } +inline v_int64x4 v_dotprod_fast(const v_int32x8& a, const v_int32x8& b, const v_int64x4& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x8 v_dotprod_expand_fast(const v_uint8x32& a, const v_uint8x32& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x8 v_dotprod_expand_fast(const v_uint8x32& a, const v_uint8x32& b, const v_uint32x8& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_int32x8 v_dotprod_expand_fast(const v_int8x32& a, const v_int8x32& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x8 v_dotprod_expand_fast(const v_int8x32& a, const v_int8x32& b, const v_int32x8& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x4 v_dotprod_expand_fast(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i mullo = _mm256_mullo_epi16(a.val, b.val); + __m256i mulhi = _mm256_mulhi_epu16(a.val, b.val); + __m256i mul0 = _mm256_unpacklo_epi16(mullo, mulhi); + __m256i mul1 = _mm256_unpackhi_epi16(mullo, mulhi); + + __m256i p02 = _mm256_blend_epi32(mul0, _mm256_setzero_si256(), 0xAA); + __m256i p13 = _mm256_srli_epi64(mul0, 32); + __m256i p46 = _mm256_blend_epi32(mul1, _mm256_setzero_si256(), 0xAA); + __m256i p57 = _mm256_srli_epi64(mul1, 32); + + __m256i p15_ = _mm256_add_epi64(p02, p13); + __m256i p9d_ = _mm256_add_epi64(p46, p57); + + return v_uint64x4(_mm256_add_epi64(p15_, p9d_)); +} +inline v_uint64x4 v_dotprod_expand_fast(const v_uint16x16& a, const v_uint16x16& b, const v_uint64x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x4 v_dotprod_expand_fast(const v_int16x16& a, const v_int16x16& b) +{ + __m256i prod = _mm256_madd_epi16(a.val, b.val); + __m256i sign = _mm256_srai_epi32(prod, 31); + __m256i lo = _mm256_unpacklo_epi32(prod, sign); + __m256i hi = _mm256_unpackhi_epi32(prod, sign); + return v_int64x4(_mm256_add_epi64(lo, hi)); +} +inline v_int64x4 v_dotprod_expand_fast(const v_int16x16& a, const v_int16x16& b, const v_int64x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +inline v_float64x4 v_dotprod_expand_fast(const v_int32x8& a, const v_int32x8& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x4 v_dotprod_expand_fast(const v_int32x8& a, const v_int32x8& b, const v_float64x4& c) +{ return v_dotprod_expand(a, b, c); } + +#define OPENCV_HAL_AVX_SPLAT2_PS(a, im) \ + v_float32x8(_mm256_permute_ps(a.val, _MM_SHUFFLE(im, im, im, im))) + +inline v_float32x8 v_matmul(const v_float32x8& v, const v_float32x8& m0, + const v_float32x8& m1, const v_float32x8& m2, + const v_float32x8& m3) +{ + v_float32x8 v04 = OPENCV_HAL_AVX_SPLAT2_PS(v, 0); + v_float32x8 v15 = OPENCV_HAL_AVX_SPLAT2_PS(v, 1); + v_float32x8 v26 = OPENCV_HAL_AVX_SPLAT2_PS(v, 2); + v_float32x8 v37 = OPENCV_HAL_AVX_SPLAT2_PS(v, 3); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, v37 * m3))); +} + +inline v_float32x8 v_matmuladd(const v_float32x8& v, const v_float32x8& m0, + const v_float32x8& m1, const v_float32x8& m2, + const v_float32x8& a) +{ + v_float32x8 v04 = OPENCV_HAL_AVX_SPLAT2_PS(v, 0); + v_float32x8 v15 = OPENCV_HAL_AVX_SPLAT2_PS(v, 1); + v_float32x8 v26 = OPENCV_HAL_AVX_SPLAT2_PS(v, 2); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, a))); +} + +#define OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(_Tpvec, suffix, cast_from, cast_to) \ + inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \ + { \ + __m256i t0 = cast_from(_mm256_unpacklo_##suffix(a0.val, a1.val)); \ + __m256i t1 = cast_from(_mm256_unpacklo_##suffix(a2.val, a3.val)); \ + __m256i t2 = cast_from(_mm256_unpackhi_##suffix(a0.val, a1.val)); \ + __m256i t3 = cast_from(_mm256_unpackhi_##suffix(a2.val, a3.val)); \ + b0.val = cast_to(_mm256_unpacklo_epi64(t0, t1)); \ + b1.val = cast_to(_mm256_unpackhi_epi64(t0, t1)); \ + b2.val = cast_to(_mm256_unpacklo_epi64(t2, t3)); \ + b3.val = cast_to(_mm256_unpackhi_epi64(t2, t3)); \ + } + +OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(v_uint32x8, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(v_int32x8, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX_TRANSPOSE4x4(v_float32x8, ps, _mm256_castps_si256, _mm256_castsi256_ps) + +//////////////// Value reordering /////////////// + +/* Expand */ +#define OPENCV_HAL_IMPL_AVX_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ + inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ + { \ + b0.val = intrin(_v256_extract_low(a.val)); \ + b1.val = intrin(_v256_extract_high(a.val)); \ + } \ + inline _Tpwvec v_expand_low(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v256_extract_low(a.val))); } \ + inline _Tpwvec v_expand_high(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v256_extract_high(a.val))); } \ + inline _Tpwvec v256_load_expand(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadu_si128((const __m128i*)ptr); \ + return _Tpwvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX_EXPAND(v_uint8x32, v_uint16x16, uchar, _mm256_cvtepu8_epi16) +OPENCV_HAL_IMPL_AVX_EXPAND(v_int8x32, v_int16x16, schar, _mm256_cvtepi8_epi16) +OPENCV_HAL_IMPL_AVX_EXPAND(v_uint16x16, v_uint32x8, ushort, _mm256_cvtepu16_epi32) +OPENCV_HAL_IMPL_AVX_EXPAND(v_int16x16, v_int32x8, short, _mm256_cvtepi16_epi32) +OPENCV_HAL_IMPL_AVX_EXPAND(v_uint32x8, v_uint64x4, unsigned, _mm256_cvtepu32_epi64) +OPENCV_HAL_IMPL_AVX_EXPAND(v_int32x8, v_int64x4, int, _mm256_cvtepi32_epi64) + +#define OPENCV_HAL_IMPL_AVX_EXPAND_Q(_Tpvec, _Tp, intrin) \ + inline _Tpvec v256_load_expand_q(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadl_epi64((const __m128i*)ptr); \ + return _Tpvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX_EXPAND_Q(v_uint32x8, uchar, _mm256_cvtepu8_epi32) +OPENCV_HAL_IMPL_AVX_EXPAND_Q(v_int32x8, schar, _mm256_cvtepi8_epi32) + +/* pack */ +// 16 +inline v_int8x32 v_pack(const v_int16x16& a, const v_int16x16& b) +{ return v_int8x32(_v256_shuffle_odd_64(_mm256_packs_epi16(a.val, b.val))); } + +inline v_uint8x32 v_pack(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i t = _mm256_set1_epi16(255); + __m256i a1 = _mm256_min_epu16(a.val, t); + __m256i b1 = _mm256_min_epu16(b.val, t); + return v_uint8x32(_v256_shuffle_odd_64(_mm256_packus_epi16(a1, b1))); +} + +inline v_uint8x32 v_pack_u(const v_int16x16& a, const v_int16x16& b) +{ + return v_uint8x32(_v256_shuffle_odd_64(_mm256_packus_epi16(a.val, b.val))); +} + +inline void v_pack_store(schar* ptr, const v_int16x16& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(uchar* ptr, const v_uint16x16& a) +{ + const __m256i m = _mm256_set1_epi16(255); + __m256i am = _mm256_min_epu16(a.val, m); + am = _v256_shuffle_odd_64(_mm256_packus_epi16(am, am)); + v_store_low(ptr, v_uint8x32(am)); +} + +inline void v_pack_u_store(uchar* ptr, const v_int16x16& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + +template inline +v_uint8x32 v_rshr_pack(const v_uint16x16& a, const v_uint16x16& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + v_uint16x16 delta = v256_setall_u16((short)(1 << (n-1))); + return v_pack_u(v_reinterpret_as_s16((a + delta) >> n), + v_reinterpret_as_s16((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(uchar* ptr, const v_uint16x16& a) +{ + v_uint16x16 delta = v256_setall_u16((short)(1 << (n-1))); + v_pack_u_store(ptr, v_reinterpret_as_s16((a + delta) >> n)); +} + +template inline +v_uint8x32 v_rshr_pack_u(const v_int16x16& a, const v_int16x16& b) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(uchar* ptr, const v_int16x16& a) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int8x32 v_rshr_pack(const v_int16x16& a, const v_int16x16& b) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(schar* ptr, const v_int16x16& a) +{ + v_int16x16 delta = v256_setall_s16((short)(1 << (n-1))); + v_pack_store(ptr, (a + delta) >> n); +} + +// 32 +inline v_int16x16 v_pack(const v_int32x8& a, const v_int32x8& b) +{ return v_int16x16(_v256_shuffle_odd_64(_mm256_packs_epi32(a.val, b.val))); } + +inline v_uint16x16 v_pack(const v_uint32x8& a, const v_uint32x8& b) +{ return v_uint16x16(_v256_shuffle_odd_64(_v256_packs_epu32(a.val, b.val))); } + +inline v_uint16x16 v_pack_u(const v_int32x8& a, const v_int32x8& b) +{ return v_uint16x16(_v256_shuffle_odd_64(_mm256_packus_epi32(a.val, b.val))); } + +inline void v_pack_store(short* ptr, const v_int32x8& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(ushort* ptr, const v_uint32x8& a) +{ + const __m256i m = _mm256_set1_epi32(65535); + __m256i am = _mm256_min_epu32(a.val, m); + am = _v256_shuffle_odd_64(_mm256_packus_epi32(am, am)); + v_store_low(ptr, v_uint16x16(am)); +} + +inline void v_pack_u_store(ushort* ptr, const v_int32x8& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + + +template inline +v_uint16x16 v_rshr_pack(const v_uint32x8& a, const v_uint32x8& b) +{ + // we assume that n > 0, and so the shifted 32-bit values can be treated as signed numbers. + v_uint32x8 delta = v256_setall_u32(1 << (n-1)); + return v_pack_u(v_reinterpret_as_s32((a + delta) >> n), + v_reinterpret_as_s32((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(ushort* ptr, const v_uint32x8& a) +{ + v_uint32x8 delta = v256_setall_u32(1 << (n-1)); + v_pack_u_store(ptr, v_reinterpret_as_s32((a + delta) >> n)); +} + +template inline +v_uint16x16 v_rshr_pack_u(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(ushort* ptr, const v_int32x8& a) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int16x16 v_rshr_pack(const v_int32x8& a, const v_int32x8& b) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(short* ptr, const v_int32x8& a) +{ + v_int32x8 delta = v256_setall_s32(1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// 64 +// Non-saturating pack +inline v_uint32x8 v_pack(const v_uint64x4& a, const v_uint64x4& b) +{ + __m256i a0 = _mm256_shuffle_epi32(a.val, _MM_SHUFFLE(0, 0, 2, 0)); + __m256i b0 = _mm256_shuffle_epi32(b.val, _MM_SHUFFLE(0, 0, 2, 0)); + __m256i ab = _mm256_unpacklo_epi64(a0, b0); // a0, a1, b0, b1, a2, a3, b2, b3 + return v_uint32x8(_v256_shuffle_odd_64(ab)); +} + +inline v_int32x8 v_pack(const v_int64x4& a, const v_int64x4& b) +{ return v_reinterpret_as_s32(v_pack(v_reinterpret_as_u64(a), v_reinterpret_as_u64(b))); } + +inline void v_pack_store(unsigned* ptr, const v_uint64x4& a) +{ + __m256i a0 = _mm256_shuffle_epi32(a.val, _MM_SHUFFLE(0, 0, 2, 0)); + v_store_low(ptr, v_uint32x8(_v256_shuffle_odd_64(a0))); +} + +inline void v_pack_store(int* ptr, const v_int64x4& b) +{ v_pack_store((unsigned*)ptr, v_reinterpret_as_u64(b)); } + +template inline +v_uint32x8 v_rshr_pack(const v_uint64x4& a, const v_uint64x4& b) +{ + v_uint64x4 delta = v256_setall_u64((uint64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(unsigned* ptr, const v_uint64x4& a) +{ + v_uint64x4 delta = v256_setall_u64((uint64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +template inline +v_int32x8 v_rshr_pack(const v_int64x4& a, const v_int64x4& b) +{ + v_int64x4 delta = v256_setall_s64((int64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(int* ptr, const v_int64x4& a) +{ + v_int64x4 delta = v256_setall_s64((int64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// pack boolean +inline v_uint8x32 v_pack_b(const v_uint16x16& a, const v_uint16x16& b) +{ + __m256i ab = _mm256_packs_epi16(a.val, b.val); + return v_uint8x32(_v256_shuffle_odd_64(ab)); +} + +inline v_uint8x32 v_pack_b(const v_uint32x8& a, const v_uint32x8& b, + const v_uint32x8& c, const v_uint32x8& d) +{ + __m256i ab = _mm256_packs_epi32(a.val, b.val); + __m256i cd = _mm256_packs_epi32(c.val, d.val); + + __m256i abcd = _v256_shuffle_odd_64(_mm256_packs_epi16(ab, cd)); + return v_uint8x32(_mm256_shuffle_epi32(abcd, _MM_SHUFFLE(3, 1, 2, 0))); +} + +inline v_uint8x32 v_pack_b(const v_uint64x4& a, const v_uint64x4& b, const v_uint64x4& c, + const v_uint64x4& d, const v_uint64x4& e, const v_uint64x4& f, + const v_uint64x4& g, const v_uint64x4& h) +{ + __m256i ab = _mm256_packs_epi32(a.val, b.val); + __m256i cd = _mm256_packs_epi32(c.val, d.val); + __m256i ef = _mm256_packs_epi32(e.val, f.val); + __m256i gh = _mm256_packs_epi32(g.val, h.val); + + __m256i abcd = _mm256_packs_epi32(ab, cd); + __m256i efgh = _mm256_packs_epi32(ef, gh); + __m256i pkall = _v256_shuffle_odd_64(_mm256_packs_epi16(abcd, efgh)); + + __m256i rev = _mm256_alignr_epi8(pkall, pkall, 8); + return v_uint8x32(_mm256_unpacklo_epi16(pkall, rev)); +} + +/* Recombine */ +// its up there with load and store operations + +/* Extract */ +#define OPENCV_HAL_IMPL_AVX_EXTRACT(_Tpvec) \ + template \ + inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ + { return v_rotate_right(a, b); } + +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint8x32) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int8x32) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint16x16) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int16x16) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint32x8) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int32x8) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_uint64x4) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_int64x4) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_float32x8) +OPENCV_HAL_IMPL_AVX_EXTRACT(v_float64x4) + +template +inline uchar v_extract_n(v_uint8x32 a) +{ + return (uchar)_v256_extract_epi8(a.val); +} + +template +inline schar v_extract_n(v_int8x32 a) +{ + return (schar)v_extract_n(v_reinterpret_as_u8(a)); +} + +template +inline ushort v_extract_n(v_uint16x16 a) +{ + return (ushort)_v256_extract_epi16(a.val); +} + +template +inline short v_extract_n(v_int16x16 a) +{ + return (short)v_extract_n(v_reinterpret_as_u16(a)); +} + +template +inline uint v_extract_n(v_uint32x8 a) +{ + return (uint)_v256_extract_epi32(a.val); +} + +template +inline int v_extract_n(v_int32x8 a) +{ + return (int)v_extract_n(v_reinterpret_as_u32(a)); +} + +template +inline uint64 v_extract_n(v_uint64x4 a) +{ + return (uint64)_v256_extract_epi64(a.val); +} + +template +inline int64 v_extract_n(v_int64x4 v) +{ + return (int64)v_extract_n(v_reinterpret_as_u64(v)); +} + +template +inline float v_extract_n(v_float32x8 v) +{ + union { uint iv; float fv; } d; + d.iv = v_extract_n(v_reinterpret_as_u32(v)); + return d.fv; +} + +template +inline double v_extract_n(v_float64x4 v) +{ + union { uint64 iv; double dv; } d; + d.iv = v_extract_n(v_reinterpret_as_u64(v)); + return d.dv; +} + +template +inline v_uint32x8 v_broadcast_element(v_uint32x8 a) +{ + static const __m256i perm = _mm256_set1_epi32((char)i); + return v_uint32x8(_mm256_permutevar8x32_epi32(a.val, perm)); +} + +template +inline v_int32x8 v_broadcast_element(const v_int32x8 &a) +{ return v_reinterpret_as_s32(v_broadcast_element(v_reinterpret_as_u32(a))); } + +template +inline v_float32x8 v_broadcast_element(const v_float32x8 &a) +{ return v_reinterpret_as_f32(v_broadcast_element(v_reinterpret_as_u32(a))); } + + +///////////////////// load deinterleave ///////////////////////////// + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x32& a, v_uint8x32& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + + const __m256i sh = _mm256_setr_epi8(0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15, + 0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15); + __m256i p0 = _mm256_shuffle_epi8(ab0, sh); + __m256i p1 = _mm256_shuffle_epi8(ab1, sh); + __m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint8x32(a0); + b = v_uint8x32(b0); +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x16& a, v_uint16x16& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + + const __m256i sh = _mm256_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15, + 0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15); + __m256i p0 = _mm256_shuffle_epi8(ab0, sh); + __m256i p1 = _mm256_shuffle_epi8(ab1, sh); + __m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint16x16(a0); + b = v_uint16x16(b0); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + + enum { sh = 0+2*4+1*16+3*64 }; + __m256i p0 = _mm256_shuffle_epi32(ab0, sh); + __m256i p1 = _mm256_shuffle_epi32(ab1, sh); + __m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint32x8(a0); + b = v_uint32x8(b0); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x4& a, v_uint64x4& b ) +{ + __m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 4)); + + __m256i pl = _mm256_permute2x128_si256(ab0, ab1, 0 + 2*16); + __m256i ph = _mm256_permute2x128_si256(ab0, ab1, 1 + 3*16); + __m256i a0 = _mm256_unpacklo_epi64(pl, ph); + __m256i b0 = _mm256_unpackhi_epi64(pl, ph); + a = v_uint64x4(a0); + b = v_uint64x4(b0); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x32& a, v_uint8x32& b, v_uint8x32& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 64)); + + __m256i s02_low = _mm256_permute2x128_si256(bgr0, bgr2, 0 + 2*16); + __m256i s02_high = _mm256_permute2x128_si256(bgr0, bgr2, 1 + 3*16); + + const __m256i m0 = _mm256_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, + 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, + -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1); + + __m256i b0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_low, s02_high, m0), bgr1, m1); + __m256i g0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_high, s02_low, m1), bgr1, m0); + __m256i r0 = _mm256_blendv_epi8(_mm256_blendv_epi8(bgr1, s02_low, m0), s02_high, m1); + + const __m256i + sh_b = _mm256_setr_epi8(0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13, + 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13), + sh_g = _mm256_setr_epi8(1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, + 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14), + sh_r = _mm256_setr_epi8(2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, + 2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15); + b0 = _mm256_shuffle_epi8(b0, sh_b); + g0 = _mm256_shuffle_epi8(g0, sh_g); + r0 = _mm256_shuffle_epi8(r0, sh_r); + + a = v_uint8x32(b0); + b = v_uint8x32(g0); + c = v_uint8x32(r0); +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x16& a, v_uint16x16& b, v_uint16x16& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + + __m256i s02_low = _mm256_permute2x128_si256(bgr0, bgr2, 0 + 2*16); + __m256i s02_high = _mm256_permute2x128_si256(bgr0, bgr2, 1 + 3*16); + + const __m256i m0 = _mm256_setr_epi8(0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, + 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, + -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0); + __m256i b0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_low, s02_high, m0), bgr1, m1); + __m256i g0 = _mm256_blendv_epi8(_mm256_blendv_epi8(bgr1, s02_low, m0), s02_high, m1); + __m256i r0 = _mm256_blendv_epi8(_mm256_blendv_epi8(s02_high, s02_low, m1), bgr1, m0); + const __m256i sh_b = _mm256_setr_epi8(0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11, + 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m256i sh_g = _mm256_setr_epi8(2, 3, 8, 9, 14, 15, 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, + 2, 3, 8, 9, 14, 15, 4, 5, 10, 11, 0, 1, 6, 7, 12, 13); + const __m256i sh_r = _mm256_setr_epi8(4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, + 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + b0 = _mm256_shuffle_epi8(b0, sh_b); + g0 = _mm256_shuffle_epi8(g0, sh_g); + r0 = _mm256_shuffle_epi8(r0, sh_r); + + a = v_uint16x16(b0); + b = v_uint16x16(g0); + c = v_uint16x16(r0); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8& b, v_uint32x8& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + + __m256i s02_low = _mm256_permute2x128_si256(bgr0, bgr2, 0 + 2*16); + __m256i s02_high = _mm256_permute2x128_si256(bgr0, bgr2, 1 + 3*16); + + __m256i b0 = _mm256_blend_epi32(_mm256_blend_epi32(s02_low, s02_high, 0x24), bgr1, 0x92); + __m256i g0 = _mm256_blend_epi32(_mm256_blend_epi32(s02_high, s02_low, 0x92), bgr1, 0x24); + __m256i r0 = _mm256_blend_epi32(_mm256_blend_epi32(bgr1, s02_low, 0x24), s02_high, 0x92); + + b0 = _mm256_shuffle_epi32(b0, 0x6c); + g0 = _mm256_shuffle_epi32(g0, 0xb1); + r0 = _mm256_shuffle_epi32(r0, 0xc6); + + a = v_uint32x8(b0); + b = v_uint32x8(g0); + c = v_uint32x8(r0); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x4& a, v_uint64x4& b, v_uint64x4& c ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 4)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + + __m256i s01 = _mm256_blend_epi32(bgr0, bgr1, 0xf0); + __m256i s12 = _mm256_blend_epi32(bgr1, bgr2, 0xf0); + __m256i s20r = _mm256_permute4x64_epi64(_mm256_blend_epi32(bgr2, bgr0, 0xf0), 0x1b); + __m256i b0 = _mm256_unpacklo_epi64(s01, s20r); + __m256i g0 = _mm256_alignr_epi8(s12, s01, 8); + __m256i r0 = _mm256_unpackhi_epi64(s20r, s12); + + a = v_uint64x4(b0); + b = v_uint64x4(g0); + c = v_uint64x4(r0); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x32& a, v_uint8x32& b, v_uint8x32& c, v_uint8x32& d ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 64)); + __m256i bgr3 = _mm256_loadu_si256((const __m256i*)(ptr + 96)); + const __m256i sh = _mm256_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, + 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + + __m256i p0 = _mm256_shuffle_epi8(bgr0, sh); + __m256i p1 = _mm256_shuffle_epi8(bgr1, sh); + __m256i p2 = _mm256_shuffle_epi8(bgr2, sh); + __m256i p3 = _mm256_shuffle_epi8(bgr3, sh); + + __m256i p01l = _mm256_unpacklo_epi32(p0, p1); + __m256i p01h = _mm256_unpackhi_epi32(p0, p1); + __m256i p23l = _mm256_unpacklo_epi32(p2, p3); + __m256i p23h = _mm256_unpackhi_epi32(p2, p3); + + __m256i pll = _mm256_permute2x128_si256(p01l, p23l, 0 + 2*16); + __m256i plh = _mm256_permute2x128_si256(p01l, p23l, 1 + 3*16); + __m256i phl = _mm256_permute2x128_si256(p01h, p23h, 0 + 2*16); + __m256i phh = _mm256_permute2x128_si256(p01h, p23h, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi32(pll, plh); + __m256i g0 = _mm256_unpackhi_epi32(pll, plh); + __m256i r0 = _mm256_unpacklo_epi32(phl, phh); + __m256i a0 = _mm256_unpackhi_epi32(phl, phh); + + a = v_uint8x32(b0); + b = v_uint8x32(g0); + c = v_uint8x32(r0); + d = v_uint8x32(a0); +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x16& a, v_uint16x16& b, v_uint16x16& c, v_uint16x16& d ) +{ + __m256i bgr0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgr1 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + __m256i bgr2 = _mm256_loadu_si256((const __m256i*)(ptr + 32)); + __m256i bgr3 = _mm256_loadu_si256((const __m256i*)(ptr + 48)); + const __m256i sh = _mm256_setr_epi8(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15, + 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15); + __m256i p0 = _mm256_shuffle_epi8(bgr0, sh); + __m256i p1 = _mm256_shuffle_epi8(bgr1, sh); + __m256i p2 = _mm256_shuffle_epi8(bgr2, sh); + __m256i p3 = _mm256_shuffle_epi8(bgr3, sh); + + __m256i p01l = _mm256_unpacklo_epi32(p0, p1); + __m256i p01h = _mm256_unpackhi_epi32(p0, p1); + __m256i p23l = _mm256_unpacklo_epi32(p2, p3); + __m256i p23h = _mm256_unpackhi_epi32(p2, p3); + + __m256i pll = _mm256_permute2x128_si256(p01l, p23l, 0 + 2*16); + __m256i plh = _mm256_permute2x128_si256(p01l, p23l, 1 + 3*16); + __m256i phl = _mm256_permute2x128_si256(p01h, p23h, 0 + 2*16); + __m256i phh = _mm256_permute2x128_si256(p01h, p23h, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi32(pll, plh); + __m256i g0 = _mm256_unpackhi_epi32(pll, plh); + __m256i r0 = _mm256_unpacklo_epi32(phl, phh); + __m256i a0 = _mm256_unpackhi_epi32(phl, phh); + + a = v_uint16x16(b0); + b = v_uint16x16(g0); + c = v_uint16x16(r0); + d = v_uint16x16(a0); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8& b, v_uint32x8& c, v_uint32x8& d ) +{ + __m256i p0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i p1 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + __m256i p2 = _mm256_loadu_si256((const __m256i*)(ptr + 16)); + __m256i p3 = _mm256_loadu_si256((const __m256i*)(ptr + 24)); + + __m256i p01l = _mm256_unpacklo_epi32(p0, p1); + __m256i p01h = _mm256_unpackhi_epi32(p0, p1); + __m256i p23l = _mm256_unpacklo_epi32(p2, p3); + __m256i p23h = _mm256_unpackhi_epi32(p2, p3); + + __m256i pll = _mm256_permute2x128_si256(p01l, p23l, 0 + 2*16); + __m256i plh = _mm256_permute2x128_si256(p01l, p23l, 1 + 3*16); + __m256i phl = _mm256_permute2x128_si256(p01h, p23h, 0 + 2*16); + __m256i phh = _mm256_permute2x128_si256(p01h, p23h, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi32(pll, plh); + __m256i g0 = _mm256_unpackhi_epi32(pll, plh); + __m256i r0 = _mm256_unpacklo_epi32(phl, phh); + __m256i a0 = _mm256_unpackhi_epi32(phl, phh); + + a = v_uint32x8(b0); + b = v_uint32x8(g0); + c = v_uint32x8(r0); + d = v_uint32x8(a0); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x4& a, v_uint64x4& b, v_uint64x4& c, v_uint64x4& d ) +{ + __m256i bgra0 = _mm256_loadu_si256((const __m256i*)ptr); + __m256i bgra1 = _mm256_loadu_si256((const __m256i*)(ptr + 4)); + __m256i bgra2 = _mm256_loadu_si256((const __m256i*)(ptr + 8)); + __m256i bgra3 = _mm256_loadu_si256((const __m256i*)(ptr + 12)); + + __m256i l02 = _mm256_permute2x128_si256(bgra0, bgra2, 0 + 2*16); + __m256i h02 = _mm256_permute2x128_si256(bgra0, bgra2, 1 + 3*16); + __m256i l13 = _mm256_permute2x128_si256(bgra1, bgra3, 0 + 2*16); + __m256i h13 = _mm256_permute2x128_si256(bgra1, bgra3, 1 + 3*16); + + __m256i b0 = _mm256_unpacklo_epi64(l02, l13); + __m256i g0 = _mm256_unpackhi_epi64(l02, l13); + __m256i r0 = _mm256_unpacklo_epi64(h02, h13); + __m256i a0 = _mm256_unpackhi_epi64(h02, h13); + + a = v_uint64x4(b0); + b = v_uint64x4(g0); + c = v_uint64x4(r0); + d = v_uint64x4(a0); +} + +///////////////////////////// store interleave ///////////////////////////////////// + +inline void v_store_interleave( uchar* ptr, const v_uint8x32& x, const v_uint8x32& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi8(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi8(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 32), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 32), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 32), xy1); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x16& x, const v_uint16x16& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi16(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi16(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 16), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 16), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 16), xy1); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x8& x, const v_uint32x8& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi32(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi32(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 8), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 8), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 8), xy1); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x4& x, const v_uint64x4& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i xy_l = _mm256_unpacklo_epi64(x.val, y.val); + __m256i xy_h = _mm256_unpackhi_epi64(x.val, y.val); + + __m256i xy0 = _mm256_permute2x128_si256(xy_l, xy_h, 0 + 2*16); + __m256i xy1 = _mm256_permute2x128_si256(xy_l, xy_h, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, xy0); + _mm256_stream_si256((__m256i*)(ptr + 4), xy1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, xy0); + _mm256_store_si256((__m256i*)(ptr + 4), xy1); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, xy0); + _mm256_storeu_si256((__m256i*)(ptr + 4), xy1); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x32& a, const v_uint8x32& b, const v_uint8x32& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + const __m256i sh_b = _mm256_setr_epi8( + 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5, + 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5); + const __m256i sh_g = _mm256_setr_epi8( + 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, + 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10); + const __m256i sh_r = _mm256_setr_epi8( + 10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, + 10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15); + + __m256i b0 = _mm256_shuffle_epi8(a.val, sh_b); + __m256i g0 = _mm256_shuffle_epi8(b.val, sh_g); + __m256i r0 = _mm256_shuffle_epi8(c.val, sh_r); + + const __m256i m0 = _mm256_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, + 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, + 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); + + __m256i p0 = _mm256_blendv_epi8(_mm256_blendv_epi8(b0, g0, m0), r0, m1); + __m256i p1 = _mm256_blendv_epi8(_mm256_blendv_epi8(g0, r0, m0), b0, m1); + __m256i p2 = _mm256_blendv_epi8(_mm256_blendv_epi8(r0, b0, m0), g0, m1); + + __m256i bgr0 = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + __m256i bgr1 = _mm256_permute2x128_si256(p2, p0, 0 + 3*16); + __m256i bgr2 = _mm256_permute2x128_si256(p1, p2, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 32), bgr1); + _mm256_stream_si256((__m256i*)(ptr + 64), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 32), bgr1); + _mm256_store_si256((__m256i*)(ptr + 64), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgr1); + _mm256_storeu_si256((__m256i*)(ptr + 64), bgr2); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x16& a, const v_uint16x16& b, const v_uint16x16& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + const __m256i sh_b = _mm256_setr_epi8( + 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11, + 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m256i sh_g = _mm256_setr_epi8( + 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, + 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5); + const __m256i sh_r = _mm256_setr_epi8( + 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, + 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + + __m256i b0 = _mm256_shuffle_epi8(a.val, sh_b); + __m256i g0 = _mm256_shuffle_epi8(b.val, sh_g); + __m256i r0 = _mm256_shuffle_epi8(c.val, sh_r); + + const __m256i m0 = _mm256_setr_epi8(0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, + 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0); + const __m256i m1 = _mm256_setr_epi8(0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, + -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0); + + __m256i p0 = _mm256_blendv_epi8(_mm256_blendv_epi8(b0, g0, m0), r0, m1); + __m256i p1 = _mm256_blendv_epi8(_mm256_blendv_epi8(g0, r0, m0), b0, m1); + __m256i p2 = _mm256_blendv_epi8(_mm256_blendv_epi8(r0, b0, m0), g0, m1); + + __m256i bgr0 = _mm256_permute2x128_si256(p0, p2, 0 + 2*16); + //__m256i bgr1 = p1; + __m256i bgr2 = _mm256_permute2x128_si256(p0, p2, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 16), p1); + _mm256_stream_si256((__m256i*)(ptr + 32), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 16), p1); + _mm256_store_si256((__m256i*)(ptr + 32), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 16), p1); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgr2); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x8& a, const v_uint32x8& b, const v_uint32x8& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i b0 = _mm256_shuffle_epi32(a.val, 0x6c); + __m256i g0 = _mm256_shuffle_epi32(b.val, 0xb1); + __m256i r0 = _mm256_shuffle_epi32(c.val, 0xc6); + + __m256i p0 = _mm256_blend_epi32(_mm256_blend_epi32(b0, g0, 0x92), r0, 0x24); + __m256i p1 = _mm256_blend_epi32(_mm256_blend_epi32(g0, r0, 0x92), b0, 0x24); + __m256i p2 = _mm256_blend_epi32(_mm256_blend_epi32(r0, b0, 0x92), g0, 0x24); + + __m256i bgr0 = _mm256_permute2x128_si256(p0, p1, 0 + 2*16); + //__m256i bgr1 = p2; + __m256i bgr2 = _mm256_permute2x128_si256(p0, p1, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 8), p2); + _mm256_stream_si256((__m256i*)(ptr + 16), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 8), p2); + _mm256_store_si256((__m256i*)(ptr + 16), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 8), p2); + _mm256_storeu_si256((__m256i*)(ptr + 16), bgr2); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x4& a, const v_uint64x4& b, const v_uint64x4& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i s01 = _mm256_unpacklo_epi64(a.val, b.val); + __m256i s12 = _mm256_unpackhi_epi64(b.val, c.val); + __m256i s20 = _mm256_blend_epi32(c.val, a.val, 0xcc); + + __m256i bgr0 = _mm256_permute2x128_si256(s01, s20, 0 + 2*16); + __m256i bgr1 = _mm256_blend_epi32(s01, s12, 0x0f); + __m256i bgr2 = _mm256_permute2x128_si256(s20, s12, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgr0); + _mm256_stream_si256((__m256i*)(ptr + 4), bgr1); + _mm256_stream_si256((__m256i*)(ptr + 8), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgr0); + _mm256_store_si256((__m256i*)(ptr + 4), bgr1); + _mm256_store_si256((__m256i*)(ptr + 8), bgr2); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgr0); + _mm256_storeu_si256((__m256i*)(ptr + 4), bgr1); + _mm256_storeu_si256((__m256i*)(ptr + 8), bgr2); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x32& a, const v_uint8x32& b, + const v_uint8x32& c, const v_uint8x32& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi8(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi8(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi8(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi8(c.val, d.val); + + __m256i bgra0_ = _mm256_unpacklo_epi16(bg0, ra0); + __m256i bgra1_ = _mm256_unpackhi_epi16(bg0, ra0); + __m256i bgra2_ = _mm256_unpacklo_epi16(bg1, ra1); + __m256i bgra3_ = _mm256_unpackhi_epi16(bg1, ra1); + + __m256i bgra0 = _mm256_permute2x128_si256(bgra0_, bgra1_, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bgra0_, bgra1_, 1 + 3*16); + __m256i bgra1 = _mm256_permute2x128_si256(bgra2_, bgra3_, 0 + 2*16); + __m256i bgra3 = _mm256_permute2x128_si256(bgra2_, bgra3_, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 32), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 64), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 96), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 32), bgra1); + _mm256_store_si256((__m256i*)(ptr + 64), bgra2); + _mm256_store_si256((__m256i*)(ptr + 96), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 64), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 96), bgra3); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x16& a, const v_uint16x16& b, + const v_uint16x16& c, const v_uint16x16& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi16(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi16(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi16(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi16(c.val, d.val); + + __m256i bgra0_ = _mm256_unpacklo_epi32(bg0, ra0); + __m256i bgra1_ = _mm256_unpackhi_epi32(bg0, ra0); + __m256i bgra2_ = _mm256_unpacklo_epi32(bg1, ra1); + __m256i bgra3_ = _mm256_unpackhi_epi32(bg1, ra1); + + __m256i bgra0 = _mm256_permute2x128_si256(bgra0_, bgra1_, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bgra0_, bgra1_, 1 + 3*16); + __m256i bgra1 = _mm256_permute2x128_si256(bgra2_, bgra3_, 0 + 2*16); + __m256i bgra3 = _mm256_permute2x128_si256(bgra2_, bgra3_, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 16), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 32), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 48), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 16), bgra1); + _mm256_store_si256((__m256i*)(ptr + 32), bgra2); + _mm256_store_si256((__m256i*)(ptr + 48), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 16), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 32), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 48), bgra3); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x8& a, const v_uint32x8& b, + const v_uint32x8& c, const v_uint32x8& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi32(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi32(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi32(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi32(c.val, d.val); + + __m256i bgra0_ = _mm256_unpacklo_epi64(bg0, ra0); + __m256i bgra1_ = _mm256_unpackhi_epi64(bg0, ra0); + __m256i bgra2_ = _mm256_unpacklo_epi64(bg1, ra1); + __m256i bgra3_ = _mm256_unpackhi_epi64(bg1, ra1); + + __m256i bgra0 = _mm256_permute2x128_si256(bgra0_, bgra1_, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bgra0_, bgra1_, 1 + 3*16); + __m256i bgra1 = _mm256_permute2x128_si256(bgra2_, bgra3_, 0 + 2*16); + __m256i bgra3 = _mm256_permute2x128_si256(bgra2_, bgra3_, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 8), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 16), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 24), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 8), bgra1); + _mm256_store_si256((__m256i*)(ptr + 16), bgra2); + _mm256_store_si256((__m256i*)(ptr + 24), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 8), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 16), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 24), bgra3); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x4& a, const v_uint64x4& b, + const v_uint64x4& c, const v_uint64x4& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m256i bg0 = _mm256_unpacklo_epi64(a.val, b.val); + __m256i bg1 = _mm256_unpackhi_epi64(a.val, b.val); + __m256i ra0 = _mm256_unpacklo_epi64(c.val, d.val); + __m256i ra1 = _mm256_unpackhi_epi64(c.val, d.val); + + __m256i bgra0 = _mm256_permute2x128_si256(bg0, ra0, 0 + 2*16); + __m256i bgra1 = _mm256_permute2x128_si256(bg1, ra1, 0 + 2*16); + __m256i bgra2 = _mm256_permute2x128_si256(bg0, ra0, 1 + 3*16); + __m256i bgra3 = _mm256_permute2x128_si256(bg1, ra1, 1 + 3*16); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm256_stream_si256((__m256i*)ptr, bgra0); + _mm256_stream_si256((__m256i*)(ptr + 4), bgra1); + _mm256_stream_si256((__m256i*)(ptr + 8), bgra2); + _mm256_stream_si256((__m256i*)(ptr + 12), bgra3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm256_store_si256((__m256i*)ptr, bgra0); + _mm256_store_si256((__m256i*)(ptr + 4), bgra1); + _mm256_store_si256((__m256i*)(ptr + 8), bgra2); + _mm256_store_si256((__m256i*)(ptr + 12), bgra3); + } + else + { + _mm256_storeu_si256((__m256i*)ptr, bgra0); + _mm256_storeu_si256((__m256i*)(ptr + 4), bgra1); + _mm256_storeu_si256((__m256i*)(ptr + 8), bgra2); + _mm256_storeu_si256((__m256i*)(ptr + 12), bgra3); + } +} + +#define OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, const _Tpvec0& c0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int8x32, schar, s8, v_uint8x32, uchar, u8) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int16x16, short, s16, v_uint16x16, ushort, u16) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int32x8, int, s32, v_uint32x8, unsigned, u32) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_float32x8, float, f32, v_uint32x8, unsigned, u32) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int64x4, int64, s64, v_uint64x4, uint64, u64) +OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_float64x4, double, f64, v_uint64x4, uint64, u64) + +// +// FP16 +// + +inline v_float32x8 v256_load_expand(const float16_t* ptr) +{ +#if CV_FP16 + return v_float32x8(_mm256_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr))); +#else + float CV_DECL_ALIGNED(32) buf[8]; + for (int i = 0; i < 8; i++) + buf[i] = (float)ptr[i]; + return v256_load_aligned(buf); +#endif +} + +inline void v_pack_store(float16_t* ptr, const v_float32x8& a) +{ +#if CV_FP16 + __m128i ah = _mm256_cvtps_ph(a.val, 0); + _mm_storeu_si128((__m128i*)ptr, ah); +#else + float CV_DECL_ALIGNED(32) buf[8]; + v_store_aligned(buf, a); + for (int i = 0; i < 8; i++) + ptr[i] = float16_t(buf[i]); +#endif +} + +// +// end of FP16 +// + +inline void v256_cleanup() { _mm256_zeroall(); } + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: + +#endif // OPENCV_HAL_INTRIN_AVX_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_avx512.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_avx512.hpp new file mode 100644 index 0000000..d20d6dd --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_avx512.hpp @@ -0,0 +1,3090 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_INTRIN_AVX512_HPP +#define OPENCV_HAL_INTRIN_AVX512_HPP + +#if defined(_MSC_VER) && (_MSC_VER < 1920/*MSVS2019*/) +# pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned +# pragma warning(disable:4309) // 'argument': truncation of constant value +# pragma warning(disable:4310) // cast truncates constant value +#endif + +#define CVT_ROUND_MODES_IMPLEMENTED 0 + +#define CV_SIMD512 1 +#define CV_SIMD512_64F 1 +#define CV_SIMD512_FP16 0 // no native operations with FP16 type. Only load/store from float32x8 are available (if CV_FP16 == 1) + +#define _v512_set_epu64(a7, a6, a5, a4, a3, a2, a1, a0) _mm512_set_epi64((int64)(a7),(int64)(a6),(int64)(a5),(int64)(a4),(int64)(a3),(int64)(a2),(int64)(a1),(int64)(a0)) +#define _v512_set_epu32(a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _mm512_set_epi64(((int64)(a15)<<32)|(int64)(a14), ((int64)(a13)<<32)|(int64)(a12), ((int64)(a11)<<32)|(int64)(a10), ((int64)( a9)<<32)|(int64)( a8), \ + ((int64)( a7)<<32)|(int64)( a6), ((int64)( a5)<<32)|(int64)( a4), ((int64)( a3)<<32)|(int64)( a2), ((int64)( a1)<<32)|(int64)( a0)) +#define _v512_set_epu16(a31, a30, a29, a28, a27, a26, a25, a24, a23, a22, a21, a20, a19, a18, a17, a16, \ + a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _v512_set_epu32(((unsigned)(a31)<<16)|(unsigned)(a30), ((unsigned)(a29)<<16)|(unsigned)(a28), ((unsigned)(a27)<<16)|(unsigned)(a26), ((unsigned)(a25)<<16)|(unsigned)(a24), \ + ((unsigned)(a23)<<16)|(unsigned)(a22), ((unsigned)(a21)<<16)|(unsigned)(a20), ((unsigned)(a19)<<16)|(unsigned)(a18), ((unsigned)(a17)<<16)|(unsigned)(a16), \ + ((unsigned)(a15)<<16)|(unsigned)(a14), ((unsigned)(a13)<<16)|(unsigned)(a12), ((unsigned)(a11)<<16)|(unsigned)(a10), ((unsigned)( a9)<<16)|(unsigned)( a8), \ + ((unsigned)( a7)<<16)|(unsigned)( a6), ((unsigned)( a5)<<16)|(unsigned)( a4), ((unsigned)( a3)<<16)|(unsigned)( a2), ((unsigned)( a1)<<16)|(unsigned)( a0)) +#define _v512_set_epu8(a63, a62, a61, a60, a59, a58, a57, a56, a55, a54, a53, a52, a51, a50, a49, a48, \ + a47, a46, a45, a44, a43, a42, a41, a40, a39, a38, a37, a36, a35, a34, a33, a32, \ + a31, a30, a29, a28, a27, a26, a25, a24, a23, a22, a21, a20, a19, a18, a17, a16, \ + a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _v512_set_epu32(((unsigned)(a63)<<24)|((unsigned)(a62)<<16)|((unsigned)(a61)<<8)|(unsigned)(a60),((unsigned)(a59)<<24)|((unsigned)(a58)<<16)|((unsigned)(a57)<<8)|(unsigned)(a56), \ + ((unsigned)(a55)<<24)|((unsigned)(a54)<<16)|((unsigned)(a53)<<8)|(unsigned)(a52),((unsigned)(a51)<<24)|((unsigned)(a50)<<16)|((unsigned)(a49)<<8)|(unsigned)(a48), \ + ((unsigned)(a47)<<24)|((unsigned)(a46)<<16)|((unsigned)(a45)<<8)|(unsigned)(a44),((unsigned)(a43)<<24)|((unsigned)(a42)<<16)|((unsigned)(a41)<<8)|(unsigned)(a40), \ + ((unsigned)(a39)<<24)|((unsigned)(a38)<<16)|((unsigned)(a37)<<8)|(unsigned)(a36),((unsigned)(a35)<<24)|((unsigned)(a34)<<16)|((unsigned)(a33)<<8)|(unsigned)(a32), \ + ((unsigned)(a31)<<24)|((unsigned)(a30)<<16)|((unsigned)(a29)<<8)|(unsigned)(a28),((unsigned)(a27)<<24)|((unsigned)(a26)<<16)|((unsigned)(a25)<<8)|(unsigned)(a24), \ + ((unsigned)(a23)<<24)|((unsigned)(a22)<<16)|((unsigned)(a21)<<8)|(unsigned)(a20),((unsigned)(a19)<<24)|((unsigned)(a18)<<16)|((unsigned)(a17)<<8)|(unsigned)(a16), \ + ((unsigned)(a15)<<24)|((unsigned)(a14)<<16)|((unsigned)(a13)<<8)|(unsigned)(a12),((unsigned)(a11)<<24)|((unsigned)(a10)<<16)|((unsigned)( a9)<<8)|(unsigned)( a8), \ + ((unsigned)( a7)<<24)|((unsigned)( a6)<<16)|((unsigned)( a5)<<8)|(unsigned)( a4),((unsigned)( a3)<<24)|((unsigned)( a2)<<16)|((unsigned)( a1)<<8)|(unsigned)( a0)) +#define _v512_set_epi8(a63, a62, a61, a60, a59, a58, a57, a56, a55, a54, a53, a52, a51, a50, a49, a48, \ + a47, a46, a45, a44, a43, a42, a41, a40, a39, a38, a37, a36, a35, a34, a33, a32, \ + a31, a30, a29, a28, a27, a26, a25, a24, a23, a22, a21, a20, a19, a18, a17, a16, \ + a15, a14, a13, a12, a11, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0) \ + _v512_set_epu8((uchar)(a63), (uchar)(a62), (uchar)(a61), (uchar)(a60), (uchar)(a59), (uchar)(a58), (uchar)(a57), (uchar)(a56), \ + (uchar)(a55), (uchar)(a54), (uchar)(a53), (uchar)(a52), (uchar)(a51), (uchar)(a50), (uchar)(a49), (uchar)(a48), \ + (uchar)(a47), (uchar)(a46), (uchar)(a45), (uchar)(a44), (uchar)(a43), (uchar)(a42), (uchar)(a41), (uchar)(a40), \ + (uchar)(a39), (uchar)(a38), (uchar)(a37), (uchar)(a36), (uchar)(a35), (uchar)(a34), (uchar)(a33), (uchar)(a32), \ + (uchar)(a31), (uchar)(a30), (uchar)(a29), (uchar)(a28), (uchar)(a27), (uchar)(a26), (uchar)(a25), (uchar)(a24), \ + (uchar)(a23), (uchar)(a22), (uchar)(a21), (uchar)(a20), (uchar)(a19), (uchar)(a18), (uchar)(a17), (uchar)(a16), \ + (uchar)(a15), (uchar)(a14), (uchar)(a13), (uchar)(a12), (uchar)(a11), (uchar)(a10), (uchar)( a9), (uchar)( a8), \ + (uchar)( a7), (uchar)( a6), (uchar)( a5), (uchar)( a4), (uchar)( a3), (uchar)( a2), (uchar)( a1), (uchar)( a0)) + +#ifndef _mm512_cvtpd_pslo +#ifdef _mm512_zextsi256_si512 +#define _mm512_cvtpd_pslo(a) _mm512_zextps256_ps512(_mm512_cvtpd_ps(a)) +#else +//if preferred way to extend with zeros is unavailable +#define _mm512_cvtpd_pslo(a) _mm512_castps256_ps512(_mm512_cvtpd_ps(a)) +#endif +#endif +///////// Utils //////////// + +namespace +{ + +inline __m512i _v512_combine(const __m256i& lo, const __m256i& hi) +{ return _mm512_inserti32x8(_mm512_castsi256_si512(lo), hi, 1); } + +inline __m512 _v512_combine(const __m256& lo, const __m256& hi) +{ return _mm512_insertf32x8(_mm512_castps256_ps512(lo), hi, 1); } + +inline __m512d _v512_combine(const __m256d& lo, const __m256d& hi) +{ return _mm512_insertf64x4(_mm512_castpd256_pd512(lo), hi, 1); } + +inline int _v_cvtsi512_si32(const __m512i& a) +{ return _mm_cvtsi128_si32(_mm512_castsi512_si128(a)); } + +inline __m256i _v512_extract_high(const __m512i& v) +{ return _mm512_extracti32x8_epi32(v, 1); } + +inline __m256 _v512_extract_high(const __m512& v) +{ return _mm512_extractf32x8_ps(v, 1); } + +inline __m256d _v512_extract_high(const __m512d& v) +{ return _mm512_extractf64x4_pd(v, 1); } + +inline __m256i _v512_extract_low(const __m512i& v) +{ return _mm512_castsi512_si256(v); } + +inline __m256 _v512_extract_low(const __m512& v) +{ return _mm512_castps512_ps256(v); } + +inline __m256d _v512_extract_low(const __m512d& v) +{ return _mm512_castpd512_pd256(v); } + +inline __m512i _v512_insert(const __m512i& a, const __m256i& b) +{ return _mm512_inserti32x8(a, b, 0); } + +inline __m512 _v512_insert(const __m512& a, const __m256& b) +{ return _mm512_insertf32x8(a, b, 0); } + +inline __m512d _v512_insert(const __m512d& a, const __m256d& b) +{ return _mm512_insertf64x4(a, b, 0); } + +} + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Types //////////// + +struct v_uint8x64 +{ + typedef uchar lane_type; + enum { nlanes = 64 }; + __m512i val; + + explicit v_uint8x64(__m512i v) : val(v) {} + v_uint8x64(uchar v0, uchar v1, uchar v2, uchar v3, + uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, + uchar v12, uchar v13, uchar v14, uchar v15, + uchar v16, uchar v17, uchar v18, uchar v19, + uchar v20, uchar v21, uchar v22, uchar v23, + uchar v24, uchar v25, uchar v26, uchar v27, + uchar v28, uchar v29, uchar v30, uchar v31, + uchar v32, uchar v33, uchar v34, uchar v35, + uchar v36, uchar v37, uchar v38, uchar v39, + uchar v40, uchar v41, uchar v42, uchar v43, + uchar v44, uchar v45, uchar v46, uchar v47, + uchar v48, uchar v49, uchar v50, uchar v51, + uchar v52, uchar v53, uchar v54, uchar v55, + uchar v56, uchar v57, uchar v58, uchar v59, + uchar v60, uchar v61, uchar v62, uchar v63) + { + val = _v512_set_epu8(v63, v62, v61, v60, v59, v58, v57, v56, v55, v54, v53, v52, v51, v50, v49, v48, + v47, v46, v45, v44, v43, v42, v41, v40, v39, v38, v37, v36, v35, v34, v33, v32, + v31, v30, v29, v28, v27, v26, v25, v24, v23, v22, v21, v20, v19, v18, v17, v16, + v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0); + } + v_uint8x64() {} + + static inline v_uint8x64 zero() { return v_uint8x64(_mm512_setzero_si512()); } + + uchar get0() const { return (uchar)_v_cvtsi512_si32(val); } +}; + +struct v_int8x64 +{ + typedef schar lane_type; + enum { nlanes = 64 }; + __m512i val; + + explicit v_int8x64(__m512i v) : val(v) {} + v_int8x64(schar v0, schar v1, schar v2, schar v3, + schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, + schar v12, schar v13, schar v14, schar v15, + schar v16, schar v17, schar v18, schar v19, + schar v20, schar v21, schar v22, schar v23, + schar v24, schar v25, schar v26, schar v27, + schar v28, schar v29, schar v30, schar v31, + schar v32, schar v33, schar v34, schar v35, + schar v36, schar v37, schar v38, schar v39, + schar v40, schar v41, schar v42, schar v43, + schar v44, schar v45, schar v46, schar v47, + schar v48, schar v49, schar v50, schar v51, + schar v52, schar v53, schar v54, schar v55, + schar v56, schar v57, schar v58, schar v59, + schar v60, schar v61, schar v62, schar v63) + { + val = _v512_set_epi8(v63, v62, v61, v60, v59, v58, v57, v56, v55, v54, v53, v52, v51, v50, v49, v48, + v47, v46, v45, v44, v43, v42, v41, v40, v39, v38, v37, v36, v35, v34, v33, v32, + v31, v30, v29, v28, v27, v26, v25, v24, v23, v22, v21, v20, v19, v18, v17, v16, + v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0); + } + v_int8x64() {} + + static inline v_int8x64 zero() { return v_int8x64(_mm512_setzero_si512()); } + + schar get0() const { return (schar)_v_cvtsi512_si32(val); } +}; + +struct v_uint16x32 +{ + typedef ushort lane_type; + enum { nlanes = 32 }; + __m512i val; + + explicit v_uint16x32(__m512i v) : val(v) {} + v_uint16x32(ushort v0, ushort v1, ushort v2, ushort v3, + ushort v4, ushort v5, ushort v6, ushort v7, + ushort v8, ushort v9, ushort v10, ushort v11, + ushort v12, ushort v13, ushort v14, ushort v15, + ushort v16, ushort v17, ushort v18, ushort v19, + ushort v20, ushort v21, ushort v22, ushort v23, + ushort v24, ushort v25, ushort v26, ushort v27, + ushort v28, ushort v29, ushort v30, ushort v31) + { + val = _v512_set_epu16(v31, v30, v29, v28, v27, v26, v25, v24, v23, v22, v21, v20, v19, v18, v17, v16, + v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0); + } + v_uint16x32() {} + + static inline v_uint16x32 zero() { return v_uint16x32(_mm512_setzero_si512()); } + + ushort get0() const { return (ushort)_v_cvtsi512_si32(val); } +}; + +struct v_int16x32 +{ + typedef short lane_type; + enum { nlanes = 32 }; + __m512i val; + + explicit v_int16x32(__m512i v) : val(v) {} + v_int16x32(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7, + short v8, short v9, short v10, short v11, short v12, short v13, short v14, short v15, + short v16, short v17, short v18, short v19, short v20, short v21, short v22, short v23, + short v24, short v25, short v26, short v27, short v28, short v29, short v30, short v31) + { + val = _v512_set_epu16((ushort)v31, (ushort)v30, (ushort)v29, (ushort)v28, (ushort)v27, (ushort)v26, (ushort)v25, (ushort)v24, + (ushort)v23, (ushort)v22, (ushort)v21, (ushort)v20, (ushort)v19, (ushort)v18, (ushort)v17, (ushort)v16, + (ushort)v15, (ushort)v14, (ushort)v13, (ushort)v12, (ushort)v11, (ushort)v10, (ushort)v9 , (ushort)v8, + (ushort)v7 , (ushort)v6 , (ushort)v5 , (ushort)v4 , (ushort)v3 , (ushort)v2 , (ushort)v1 , (ushort)v0); + } + v_int16x32() {} + + static inline v_int16x32 zero() { return v_int16x32(_mm512_setzero_si512()); } + + short get0() const { return (short)_v_cvtsi512_si32(val); } +}; + +struct v_uint32x16 +{ + typedef unsigned lane_type; + enum { nlanes = 16 }; + __m512i val; + + explicit v_uint32x16(__m512i v) : val(v) {} + v_uint32x16(unsigned v0, unsigned v1, unsigned v2, unsigned v3, + unsigned v4, unsigned v5, unsigned v6, unsigned v7, + unsigned v8, unsigned v9, unsigned v10, unsigned v11, + unsigned v12, unsigned v13, unsigned v14, unsigned v15) + { + val = _mm512_setr_epi32((int)v0, (int)v1, (int)v2, (int)v3, (int)v4, (int)v5, (int)v6, (int)v7, + (int)v8, (int)v9, (int)v10, (int)v11, (int)v12, (int)v13, (int)v14, (int)v15); + } + v_uint32x16() {} + + static inline v_uint32x16 zero() { return v_uint32x16(_mm512_setzero_si512()); } + + unsigned get0() const { return (unsigned)_v_cvtsi512_si32(val); } +}; + +struct v_int32x16 +{ + typedef int lane_type; + enum { nlanes = 16 }; + __m512i val; + + explicit v_int32x16(__m512i v) : val(v) {} + v_int32x16(int v0, int v1, int v2, int v3, int v4, int v5, int v6, int v7, + int v8, int v9, int v10, int v11, int v12, int v13, int v14, int v15) + { + val = _mm512_setr_epi32(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + v_int32x16() {} + + static inline v_int32x16 zero() { return v_int32x16(_mm512_setzero_si512()); } + + int get0() const { return _v_cvtsi512_si32(val); } +}; + +struct v_float32x16 +{ + typedef float lane_type; + enum { nlanes = 16 }; + __m512 val; + + explicit v_float32x16(__m512 v) : val(v) {} + v_float32x16(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, + float v8, float v9, float v10, float v11, float v12, float v13, float v14, float v15) + { + val = _mm512_setr_ps(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + v_float32x16() {} + + static inline v_float32x16 zero() { return v_float32x16(_mm512_setzero_ps()); } + + float get0() const { return _mm_cvtss_f32(_mm512_castps512_ps128(val)); } +}; + +struct v_uint64x8 +{ + typedef uint64 lane_type; + enum { nlanes = 8 }; + __m512i val; + + explicit v_uint64x8(__m512i v) : val(v) {} + v_uint64x8(uint64 v0, uint64 v1, uint64 v2, uint64 v3, uint64 v4, uint64 v5, uint64 v6, uint64 v7) + { val = _mm512_setr_epi64((int64)v0, (int64)v1, (int64)v2, (int64)v3, (int64)v4, (int64)v5, (int64)v6, (int64)v7); } + v_uint64x8() {} + + static inline v_uint64x8 zero() { return v_uint64x8(_mm512_setzero_si512()); } + + uint64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (uint64)_mm_cvtsi128_si64(_mm512_castsi512_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm512_castsi512_si128(val)); + int b = _mm_cvtsi128_si32(_mm512_castsi512_si128(_mm512_srli_epi64(val, 32))); + return (unsigned)a | ((uint64)(unsigned)b << 32); + #endif + } +}; + +struct v_int64x8 +{ + typedef int64 lane_type; + enum { nlanes = 8 }; + __m512i val; + + explicit v_int64x8(__m512i v) : val(v) {} + v_int64x8(int64 v0, int64 v1, int64 v2, int64 v3, int64 v4, int64 v5, int64 v6, int64 v7) + { val = _mm512_setr_epi64(v0, v1, v2, v3, v4, v5, v6, v7); } + v_int64x8() {} + + static inline v_int64x8 zero() { return v_int64x8(_mm512_setzero_si512()); } + + int64 get0() const + { + #if defined __x86_64__ || defined _M_X64 + return (int64)_mm_cvtsi128_si64(_mm512_castsi512_si128(val)); + #else + int a = _mm_cvtsi128_si32(_mm512_castsi512_si128(val)); + int b = _mm_cvtsi128_si32(_mm512_castsi512_si128(_mm512_srli_epi64(val, 32))); + return (int64)((unsigned)a | ((uint64)(unsigned)b << 32)); + #endif + } +}; + +struct v_float64x8 +{ + typedef double lane_type; + enum { nlanes = 8 }; + __m512d val; + + explicit v_float64x8(__m512d v) : val(v) {} + v_float64x8(double v0, double v1, double v2, double v3, double v4, double v5, double v6, double v7) + { val = _mm512_setr_pd(v0, v1, v2, v3, v4, v5, v6, v7); } + v_float64x8() {} + + static inline v_float64x8 zero() { return v_float64x8(_mm512_setzero_pd()); } + + double get0() const { return _mm_cvtsd_f64(_mm512_castpd512_pd128(val)); } +}; + +//////////////// Load and store operations /////////////// + +#define OPENCV_HAL_IMPL_AVX512_LOADSTORE(_Tpvec, _Tp) \ + inline _Tpvec v512_load(const _Tp* ptr) \ + { return _Tpvec(_mm512_loadu_si512((const __m512i*)ptr)); } \ + inline _Tpvec v512_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm512_load_si512((const __m512i*)ptr)); } \ + inline _Tpvec v512_load_low(const _Tp* ptr) \ + { \ + __m256i v256 = _mm256_loadu_si256((const __m256i*)ptr); \ + return _Tpvec(_mm512_castsi256_si512(v256)); \ + } \ + inline _Tpvec v512_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + __m256i vlo = _mm256_loadu_si256((const __m256i*)ptr0); \ + __m256i vhi = _mm256_loadu_si256((const __m256i*)ptr1); \ + return _Tpvec(_v512_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm512_storeu_si512((__m512i*)ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm512_store_si512((__m512i*)ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm512_stream_si512((__m512i*)ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm512_storeu_si512((__m512i*)ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm512_stream_si512((__m512i*)ptr, a.val); \ + else \ + _mm512_store_si512((__m512i*)ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_si256((__m256i*)ptr, _v512_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_si256((__m256i*)ptr, _v512_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint8x64, uchar) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int8x64, schar) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint16x32, ushort) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int16x32, short) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint32x16, unsigned) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int32x16, int) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_uint64x8, uint64) +OPENCV_HAL_IMPL_AVX512_LOADSTORE(v_int64x8, int64) + +#define OPENCV_HAL_IMPL_AVX512_LOADSTORE_FLT(_Tpvec, _Tp, suffix, halfreg) \ + inline _Tpvec v512_load(const _Tp* ptr) \ + { return _Tpvec(_mm512_loadu_##suffix(ptr)); } \ + inline _Tpvec v512_load_aligned(const _Tp* ptr) \ + { return _Tpvec(_mm512_load_##suffix(ptr)); } \ + inline _Tpvec v512_load_low(const _Tp* ptr) \ + { \ + return _Tpvec(_mm512_cast##suffix##256_##suffix##512 \ + (_mm256_loadu_##suffix(ptr))); \ + } \ + inline _Tpvec v512_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ + { \ + halfreg vlo = _mm256_loadu_##suffix(ptr0); \ + halfreg vhi = _mm256_loadu_##suffix(ptr1); \ + return _Tpvec(_v512_combine(vlo, vhi)); \ + } \ + inline void v_store(_Tp* ptr, const _Tpvec& a) \ + { _mm512_storeu_##suffix(ptr, a.val); } \ + inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ + { _mm512_store_##suffix(ptr, a.val); } \ + inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ + { _mm512_stream_##suffix(ptr, a.val); } \ + inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ + { \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm512_storeu_##suffix(ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm512_stream_##suffix(ptr, a.val); \ + else \ + _mm512_store_##suffix(ptr, a.val); \ + } \ + inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_##suffix(ptr, _v512_extract_low(a.val)); } \ + inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ + { _mm256_storeu_##suffix(ptr, _v512_extract_high(a.val)); } + +OPENCV_HAL_IMPL_AVX512_LOADSTORE_FLT(v_float32x16, float, ps, __m256) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_FLT(v_float64x8, double, pd, __m256d) + +#define OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, _Tpvecf, suffix, cast) \ + inline _Tpvec v_reinterpret_as_##suffix(const _Tpvecf& a) \ + { return _Tpvec(cast(a.val)); } + +#define OPENCV_HAL_IMPL_AVX512_INIT(_Tpvec, _Tp, suffix, ssuffix, ctype_s) \ + inline _Tpvec v512_setzero_##suffix() \ + { return _Tpvec(_mm512_setzero_si512()); } \ + inline _Tpvec v512_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm512_set1_##ssuffix((ctype_s)v)); } \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint8x64, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int8x64, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint16x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int16x32, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint32x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int32x16, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint64x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int64x8, suffix, OPENCV_HAL_NOP) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_float32x16, suffix, _mm512_castps_si512) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_float64x8, suffix, _mm512_castpd_si512) + +OPENCV_HAL_IMPL_AVX512_INIT(v_uint8x64, uchar, u8, epi8, char) +OPENCV_HAL_IMPL_AVX512_INIT(v_int8x64, schar, s8, epi8, char) +OPENCV_HAL_IMPL_AVX512_INIT(v_uint16x32, ushort, u16, epi16, short) +OPENCV_HAL_IMPL_AVX512_INIT(v_int16x32, short, s16, epi16, short) +OPENCV_HAL_IMPL_AVX512_INIT(v_uint32x16, unsigned, u32, epi32, int) +OPENCV_HAL_IMPL_AVX512_INIT(v_int32x16, int, s32, epi32, int) +OPENCV_HAL_IMPL_AVX512_INIT(v_uint64x8, uint64, u64, epi64, int64) +OPENCV_HAL_IMPL_AVX512_INIT(v_int64x8, int64, s64, epi64, int64) + +#define OPENCV_HAL_IMPL_AVX512_INIT_FLT(_Tpvec, _Tp, suffix, zsuffix, cast) \ + inline _Tpvec v512_setzero_##suffix() \ + { return _Tpvec(_mm512_setzero_##zsuffix()); } \ + inline _Tpvec v512_setall_##suffix(_Tp v) \ + { return _Tpvec(_mm512_set1_##zsuffix(v)); } \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint8x64, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int8x64, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint16x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int16x32, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint32x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int32x16, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_uint64x8, suffix, cast) \ + OPENCV_HAL_IMPL_AVX512_CAST(_Tpvec, v_int64x8, suffix, cast) + +OPENCV_HAL_IMPL_AVX512_INIT_FLT(v_float32x16, float, f32, ps, _mm512_castsi512_ps) +OPENCV_HAL_IMPL_AVX512_INIT_FLT(v_float64x8, double, f64, pd, _mm512_castsi512_pd) + +inline v_float32x16 v_reinterpret_as_f32(const v_float32x16& a) +{ return a; } +inline v_float32x16 v_reinterpret_as_f32(const v_float64x8& a) +{ return v_float32x16(_mm512_castpd_ps(a.val)); } + +inline v_float64x8 v_reinterpret_as_f64(const v_float64x8& a) +{ return a; } +inline v_float64x8 v_reinterpret_as_f64(const v_float32x16& a) +{ return v_float64x8(_mm512_castps_pd(a.val)); } + +// FP16 +inline v_float32x16 v512_load_expand(const float16_t* ptr) +{ + return v_float32x16(_mm512_cvtph_ps(_mm256_loadu_si256((const __m256i*)ptr))); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x16& a) +{ + __m256i ah = _mm512_cvtps_ph(a.val, 0); + _mm256_storeu_si256((__m256i*)ptr, ah); +} + +/* Recombine & ZIP */ +inline void v_zip(const v_int8x64& a, const v_int8x64& b, v_int8x64& ab0, v_int8x64& ab1) +{ +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8( 95, 31, 94, 30, 93, 29, 92, 28, 91, 27, 90, 26, 89, 25, 88, 24, + 87, 23, 86, 22, 85, 21, 84, 20, 83, 19, 82, 18, 81, 17, 80, 16, + 79, 15, 78, 14, 77, 13, 76, 12, 75, 11, 74, 10, 73, 9, 72, 8, + 71, 7, 70, 6, 69, 5, 68, 4, 67, 3, 66, 2, 65, 1, 64, 0); + ab0 = v_int8x64(_mm512_permutex2var_epi8(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu8(127, 63, 126, 62, 125, 61, 124, 60, 123, 59, 122, 58, 121, 57, 120, 56, + 119, 55, 118, 54, 117, 53, 116, 52, 115, 51, 114, 50, 113, 49, 112, 48, + 111, 47, 110, 46, 109, 45, 108, 44, 107, 43, 106, 42, 105, 41, 104, 40, + 103, 39, 102, 38, 101, 37, 100, 36, 99, 35, 98, 34, 97, 33, 96, 32); + ab1 = v_int8x64(_mm512_permutex2var_epi8(a.val, mask1, b.val)); +#else + __m512i low = _mm512_unpacklo_epi8(a.val, b.val); + __m512i high = _mm512_unpackhi_epi8(a.val, b.val); + ab0 = v_int8x64(_mm512_permutex2var_epi64(low, _v512_set_epu64(11, 10, 3, 2, 9, 8, 1, 0), high)); + ab1 = v_int8x64(_mm512_permutex2var_epi64(low, _v512_set_epu64(15, 14, 7, 6, 13, 12, 5, 4), high)); +#endif +} +inline void v_zip(const v_int16x32& a, const v_int16x32& b, v_int16x32& ab0, v_int16x32& ab1) +{ + __m512i mask0 = _v512_set_epu16(47, 15, 46, 14, 45, 13, 44, 12, 43, 11, 42, 10, 41, 9, 40, 8, + 39, 7, 38, 6, 37, 5, 36, 4, 35, 3, 34, 2, 33, 1, 32, 0); + ab0 = v_int16x32(_mm512_permutex2var_epi16(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu16(63, 31, 62, 30, 61, 29, 60, 28, 59, 27, 58, 26, 57, 25, 56, 24, + 55, 23, 54, 22, 53, 21, 52, 20, 51, 19, 50, 18, 49, 17, 48, 16); + ab1 = v_int16x32(_mm512_permutex2var_epi16(a.val, mask1, b.val)); +} +inline void v_zip(const v_int32x16& a, const v_int32x16& b, v_int32x16& ab0, v_int32x16& ab1) +{ + __m512i mask0 = _v512_set_epu32(23, 7, 22, 6, 21, 5, 20, 4, 19, 3, 18, 2, 17, 1, 16, 0); + ab0 = v_int32x16(_mm512_permutex2var_epi32(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu32(31, 15, 30, 14, 29, 13, 28, 12, 27, 11, 26, 10, 25, 9, 24, 8); + ab1 = v_int32x16(_mm512_permutex2var_epi32(a.val, mask1, b.val)); +} +inline void v_zip(const v_int64x8& a, const v_int64x8& b, v_int64x8& ab0, v_int64x8& ab1) +{ + __m512i mask0 = _v512_set_epu64(11, 3, 10, 2, 9, 1, 8, 0); + ab0 = v_int64x8(_mm512_permutex2var_epi64(a.val, mask0, b.val)); + __m512i mask1 = _v512_set_epu64(15, 7, 14, 6, 13, 5, 12, 4); + ab1 = v_int64x8(_mm512_permutex2var_epi64(a.val, mask1, b.val)); +} + +inline void v_zip(const v_uint8x64& a, const v_uint8x64& b, v_uint8x64& ab0, v_uint8x64& ab1) +{ + v_int8x64 i0, i1; + v_zip(v_reinterpret_as_s8(a), v_reinterpret_as_s8(b), i0, i1); + ab0 = v_reinterpret_as_u8(i0); + ab1 = v_reinterpret_as_u8(i1); +} +inline void v_zip(const v_uint16x32& a, const v_uint16x32& b, v_uint16x32& ab0, v_uint16x32& ab1) +{ + v_int16x32 i0, i1; + v_zip(v_reinterpret_as_s16(a), v_reinterpret_as_s16(b), i0, i1); + ab0 = v_reinterpret_as_u16(i0); + ab1 = v_reinterpret_as_u16(i1); +} +inline void v_zip(const v_uint32x16& a, const v_uint32x16& b, v_uint32x16& ab0, v_uint32x16& ab1) +{ + v_int32x16 i0, i1; + v_zip(v_reinterpret_as_s32(a), v_reinterpret_as_s32(b), i0, i1); + ab0 = v_reinterpret_as_u32(i0); + ab1 = v_reinterpret_as_u32(i1); +} +inline void v_zip(const v_uint64x8& a, const v_uint64x8& b, v_uint64x8& ab0, v_uint64x8& ab1) +{ + v_int64x8 i0, i1; + v_zip(v_reinterpret_as_s64(a), v_reinterpret_as_s64(b), i0, i1); + ab0 = v_reinterpret_as_u64(i0); + ab1 = v_reinterpret_as_u64(i1); +} +inline void v_zip(const v_float32x16& a, const v_float32x16& b, v_float32x16& ab0, v_float32x16& ab1) +{ + v_int32x16 i0, i1; + v_zip(v_reinterpret_as_s32(a), v_reinterpret_as_s32(b), i0, i1); + ab0 = v_reinterpret_as_f32(i0); + ab1 = v_reinterpret_as_f32(i1); +} +inline void v_zip(const v_float64x8& a, const v_float64x8& b, v_float64x8& ab0, v_float64x8& ab1) +{ + v_int64x8 i0, i1; + v_zip(v_reinterpret_as_s64(a), v_reinterpret_as_s64(b), i0, i1); + ab0 = v_reinterpret_as_f64(i0); + ab1 = v_reinterpret_as_f64(i1); +} + +#define OPENCV_HAL_IMPL_AVX512_COMBINE(_Tpvec, suffix) \ + inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_v512_combine(_v512_extract_low(a.val), _v512_extract_low(b.val))); } \ + inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_v512_insert(b.val, _v512_extract_high(a.val))); } \ + inline void v_recombine(const _Tpvec& a, const _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ + { \ + c.val = _v512_combine(_v512_extract_low(a.val),_v512_extract_low(b.val)); \ + d.val = _v512_insert(b.val,_v512_extract_high(a.val)); \ + } + + +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint8x64, epi8) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int8x64, epi8) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint16x32, epi16) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int16x32, epi16) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint32x16, epi32) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int32x16, epi32) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_uint64x8, epi64) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_int64x8, epi64) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_COMBINE(v_float64x8, pd) + +////////// Arithmetic, bitwise and comparison operations ///////// + +/* Element-wise binary and unary operations */ + +/** Non-saturating arithmetics **/ +#define OPENCV_HAL_IMPL_AVX512_BIN_FUNC(func, _Tpvec, intrin) \ + inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_uint8x64, _mm512_add_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_int8x64, _mm512_add_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_uint16x32, _mm512_add_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_add_wrap, v_int16x32, _mm512_add_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_uint8x64, _mm512_sub_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_int8x64, _mm512_sub_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_uint16x32, _mm512_sub_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_sub_wrap, v_int16x32, _mm512_sub_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_mul_wrap, v_uint16x32, _mm512_mullo_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_mul_wrap, v_int16x32, _mm512_mullo_epi16) + +inline v_uint8x64 v_mul_wrap(const v_uint8x64& a, const v_uint8x64& b) +{ + __m512i ad = _mm512_srai_epi16(a.val, 8); + __m512i bd = _mm512_srai_epi16(b.val, 8); + __m512i p0 = _mm512_mullo_epi16(a.val, b.val); // even + __m512i p1 = _mm512_slli_epi16(_mm512_mullo_epi16(ad, bd), 8); // odd + return v_uint8x64(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, p0, p1)); +} +inline v_int8x64 v_mul_wrap(const v_int8x64& a, const v_int8x64& b) +{ + return v_reinterpret_as_s8(v_mul_wrap(v_reinterpret_as_u8(a), v_reinterpret_as_u8(b))); +} + +#define OPENCV_HAL_IMPL_AVX512_BIN_OP(bin_op, _Tpvec, intrin) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(intrin(a.val, b.val)); } \ + inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ + { a.val = intrin(a.val, b.val); return a; } + +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint32x16, _mm512_add_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint32x16, _mm512_sub_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int32x16, _mm512_add_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int32x16, _mm512_sub_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint64x8, _mm512_add_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint64x8, _mm512_sub_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int64x8, _mm512_add_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int64x8, _mm512_sub_epi64) + +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_uint32x16, _mm512_mullo_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_int32x16, _mm512_mullo_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_uint64x8, _mm512_mullo_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_int64x8, _mm512_mullo_epi64) + +/** Saturating arithmetics **/ +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint8x64, _mm512_adds_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint8x64, _mm512_subs_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int8x64, _mm512_adds_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int8x64, _mm512_subs_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_uint16x32, _mm512_adds_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_uint16x32, _mm512_subs_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_int16x32, _mm512_adds_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_int16x32, _mm512_subs_epi16) + +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_float32x16, _mm512_add_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_float32x16, _mm512_sub_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_float32x16, _mm512_mul_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(/, v_float32x16, _mm512_div_ps) +OPENCV_HAL_IMPL_AVX512_BIN_OP(+, v_float64x8, _mm512_add_pd) +OPENCV_HAL_IMPL_AVX512_BIN_OP(-, v_float64x8, _mm512_sub_pd) +OPENCV_HAL_IMPL_AVX512_BIN_OP(*, v_float64x8, _mm512_mul_pd) +OPENCV_HAL_IMPL_AVX512_BIN_OP(/, v_float64x8, _mm512_div_pd) + +// saturating multiply +inline v_uint8x64 operator * (const v_uint8x64& a, const v_uint8x64& b) +{ + v_uint16x32 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_int8x64 operator * (const v_int8x64& a, const v_int8x64& b) +{ + v_int16x32 c, d; + v_mul_expand(a, b, c, d); + return v_pack(c, d); +} +inline v_uint16x32 operator * (const v_uint16x32& a, const v_uint16x32& b) +{ + __m512i pl = _mm512_mullo_epi16(a.val, b.val); + __m512i ph = _mm512_mulhi_epu16(a.val, b.val); + __m512i p0 = _mm512_unpacklo_epi16(pl, ph); + __m512i p1 = _mm512_unpackhi_epi16(pl, ph); + + const __m512i m = _mm512_set1_epi32(65535); + return v_uint16x32(_mm512_packus_epi32(_mm512_min_epu32(p0, m), _mm512_min_epu32(p1, m))); +} +inline v_int16x32 operator * (const v_int16x32& a, const v_int16x32& b) +{ + __m512i pl = _mm512_mullo_epi16(a.val, b.val); + __m512i ph = _mm512_mulhi_epi16(a.val, b.val); + __m512i p0 = _mm512_unpacklo_epi16(pl, ph); + __m512i p1 = _mm512_unpackhi_epi16(pl, ph); + return v_int16x32(_mm512_packs_epi32(p0, p1)); +} + +inline v_uint8x64& operator *= (v_uint8x64& a, const v_uint8x64& b) +{ a = a * b; return a; } +inline v_int8x64& operator *= (v_int8x64& a, const v_int8x64& b) +{ a = a * b; return a; } +inline v_uint16x32& operator *= (v_uint16x32& a, const v_uint16x32& b) +{ a = a * b; return a; } +inline v_int16x32& operator *= (v_int16x32& a, const v_int16x32& b) +{ a = a * b; return a; } + +inline v_int16x32 v_mul_hi(const v_int16x32& a, const v_int16x32& b) { return v_int16x32(_mm512_mulhi_epi16(a.val, b.val)); } +inline v_uint16x32 v_mul_hi(const v_uint16x32& a, const v_uint16x32& b) { return v_uint16x32(_mm512_mulhi_epu16(a.val, b.val)); } + +// Multiply and expand +inline void v_mul_expand(const v_uint8x64& a, const v_uint8x64& b, + v_uint16x32& c, v_uint16x32& d) +{ + v_uint16x32 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x64& a, const v_int8x64& b, + v_int16x32& c, v_int16x32& d) +{ + v_int16x32 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x32& a, const v_int16x32& b, + v_int32x16& c, v_int32x16& d) +{ + v_int16x32 v0, v1; + v_zip(v_mul_wrap(a, b), v_mul_hi(a, b), v0, v1); + + c = v_reinterpret_as_s32(v0); + d = v_reinterpret_as_s32(v1); +} + +inline void v_mul_expand(const v_uint16x32& a, const v_uint16x32& b, + v_uint32x16& c, v_uint32x16& d) +{ + v_uint16x32 v0, v1; + v_zip(v_mul_wrap(a, b), v_mul_hi(a, b), v0, v1); + + c = v_reinterpret_as_u32(v0); + d = v_reinterpret_as_u32(v1); +} + +inline void v_mul_expand(const v_uint32x16& a, const v_uint32x16& b, + v_uint64x8& c, v_uint64x8& d) +{ + v_zip(v_uint64x8(_mm512_mul_epu32(a.val, b.val)), + v_uint64x8(_mm512_mul_epu32(_mm512_srli_epi64(a.val, 32), _mm512_srli_epi64(b.val, 32))), c, d); +} + +inline void v_mul_expand(const v_int32x16& a, const v_int32x16& b, + v_int64x8& c, v_int64x8& d) +{ + v_zip(v_int64x8(_mm512_mul_epi32(a.val, b.val)), + v_int64x8(_mm512_mul_epi32(_mm512_srli_epi64(a.val, 32), _mm512_srli_epi64(b.val, 32))), c, d); +} + +/** Bitwise shifts **/ +#define OPENCV_HAL_IMPL_AVX512_SHIFT_OP(_Tpuvec, _Tpsvec, suffix) \ + inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm512_slli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ + { return _Tpsvec(_mm512_slli_##suffix(a.val, imm)); } \ + inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ + { return _Tpuvec(_mm512_srli_##suffix(a.val, imm)); } \ + inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ + { return _Tpsvec(_mm512_srai_##suffix(a.val, imm)); } \ + template \ + inline _Tpuvec v_shl(const _Tpuvec& a) \ + { return _Tpuvec(_mm512_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shl(const _Tpsvec& a) \ + { return _Tpsvec(_mm512_slli_##suffix(a.val, imm)); } \ + template \ + inline _Tpuvec v_shr(const _Tpuvec& a) \ + { return _Tpuvec(_mm512_srli_##suffix(a.val, imm)); } \ + template \ + inline _Tpsvec v_shr(const _Tpsvec& a) \ + { return _Tpsvec(_mm512_srai_##suffix(a.val, imm)); } + +OPENCV_HAL_IMPL_AVX512_SHIFT_OP(v_uint16x32, v_int16x32, epi16) +OPENCV_HAL_IMPL_AVX512_SHIFT_OP(v_uint32x16, v_int32x16, epi32) +OPENCV_HAL_IMPL_AVX512_SHIFT_OP(v_uint64x8, v_int64x8, epi64) + + +/** Bitwise logic **/ +#define OPENCV_HAL_IMPL_AVX512_LOGIC_OP(_Tpvec, suffix, not_const) \ + OPENCV_HAL_IMPL_AVX512_BIN_OP(&, _Tpvec, _mm512_and_##suffix) \ + OPENCV_HAL_IMPL_AVX512_BIN_OP(|, _Tpvec, _mm512_or_##suffix) \ + OPENCV_HAL_IMPL_AVX512_BIN_OP(^, _Tpvec, _mm512_xor_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { return _Tpvec(_mm512_xor_##suffix(a.val, not_const)); } + +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint8x64, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int8x64, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint16x32, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int16x32, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint32x16, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int32x16, si512, _mm512_set1_epi32(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_uint64x8, si512, _mm512_set1_epi64(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_int64x8, si512, _mm512_set1_epi64(-1)) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_float32x16, ps, _mm512_castsi512_ps(_mm512_set1_epi32(-1))) +OPENCV_HAL_IMPL_AVX512_LOGIC_OP(v_float64x8, pd, _mm512_castsi512_pd(_mm512_set1_epi32(-1))) + +/** Select **/ +#define OPENCV_HAL_IMPL_AVX512_SELECT(_Tpvec, suffix, zsuf) \ + inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm512_mask_blend_##suffix(_mm512_cmp_##suffix##_mask(mask.val, _mm512_setzero_##zsuf(), _MM_CMPINT_EQ), a.val, b.val)); } + +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint8x64, epi8, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int8x64, epi8, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint16x32, epi16, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int16x32, epi16, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint32x16, epi32, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int32x16, epi32, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_uint64x8, epi64, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_int64x8, epi64, si512) +OPENCV_HAL_IMPL_AVX512_SELECT(v_float32x16, ps, ps) +OPENCV_HAL_IMPL_AVX512_SELECT(v_float64x8, pd, pd) + +/** Comparison **/ +#define OPENCV_HAL_IMPL_AVX512_CMP_INT(bin_op, imm8, _Tpvec, sufcmp, sufset, tval) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm512_maskz_set1_##sufset(_mm512_cmp_##sufcmp##_mask(a.val, b.val, imm8), tval)); } + +#define OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(_Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(==, _MM_CMPINT_EQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(!=, _MM_CMPINT_NE, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(<, _MM_CMPINT_LT, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(>, _MM_CMPINT_NLE, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(<=, _MM_CMPINT_LE, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_INT(>=, _MM_CMPINT_NLT, _Tpvec, sufcmp, sufset, tval) + +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint8x64, epu8, epi8, (char)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int8x64, epi8, epi8, (char)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint16x32, epu16, epi16, (short)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int16x32, epi16, epi16, (short)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint32x16, epu32, epi32, (int)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int32x16, epi32, epi32, (int)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_uint64x8, epu64, epi64, (int64)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_INT(v_int64x8, epi64, epi64, (int64)-1) + +#define OPENCV_HAL_IMPL_AVX512_CMP_FLT(bin_op, imm8, _Tpvec, sufcmp, sufset, tval) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { return _Tpvec(_mm512_castsi512_##sufcmp(_mm512_maskz_set1_##sufset(_mm512_cmp_##sufcmp##_mask(a.val, b.val, imm8), tval))); } + +#define OPENCV_HAL_IMPL_AVX512_CMP_OP_FLT(_Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(==, _CMP_EQ_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(!=, _CMP_NEQ_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(<, _CMP_LT_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(>, _CMP_GT_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(<=, _CMP_LE_OQ, _Tpvec, sufcmp, sufset, tval) \ + OPENCV_HAL_IMPL_AVX512_CMP_FLT(>=, _CMP_GE_OQ, _Tpvec, sufcmp, sufset, tval) + +OPENCV_HAL_IMPL_AVX512_CMP_OP_FLT(v_float32x16, ps, epi32, (int)-1) +OPENCV_HAL_IMPL_AVX512_CMP_OP_FLT(v_float64x8, pd, epi64, (int64)-1) + +inline v_float32x16 v_not_nan(const v_float32x16& a) +{ return v_float32x16(_mm512_castsi512_ps(_mm512_maskz_set1_epi32(_mm512_cmp_ps_mask(a.val, a.val, _CMP_ORD_Q), (int)-1))); } +inline v_float64x8 v_not_nan(const v_float64x8& a) +{ return v_float64x8(_mm512_castsi512_pd(_mm512_maskz_set1_epi64(_mm512_cmp_pd_mask(a.val, a.val, _CMP_ORD_Q), (int64)-1))); } + +/** min/max **/ +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint8x64, _mm512_min_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint8x64, _mm512_max_epu8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int8x64, _mm512_min_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int8x64, _mm512_max_epi8) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint16x32, _mm512_min_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint16x32, _mm512_max_epu16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int16x32, _mm512_min_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int16x32, _mm512_max_epi16) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint32x16, _mm512_min_epu32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint32x16, _mm512_max_epu32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int32x16, _mm512_min_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int32x16, _mm512_max_epi32) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_uint64x8, _mm512_min_epu64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_uint64x8, _mm512_max_epu64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_int64x8, _mm512_min_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_int64x8, _mm512_max_epi64) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_float32x16, _mm512_min_ps) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_float32x16, _mm512_max_ps) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_min, v_float64x8, _mm512_min_pd) +OPENCV_HAL_IMPL_AVX512_BIN_FUNC(v_max, v_float64x8, _mm512_max_pd) + +/** Rotate **/ +namespace { + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64&) { return v_int8x64(); }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64& b) + { + return v_int8x64(_mm512_or_si512(_mm512_srli_epi32(_mm512_alignr_epi32(b.val, a.val, imm32 ), imm4 *8), + _mm512_slli_epi32(_mm512_alignr_epi32(b.val, a.val, imm32 + 1), (4-imm4)*8))); + }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64& b) + { + return v_int8x64(_mm512_or_si512(_mm512_srli_epi32(_mm512_alignr_epi32(b.val, a.val, 15), imm4 *8), + _mm512_slli_epi32( b.val, (4-imm4)*8))); + }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) + { + return v_int8x64(_mm512_or_si512(_mm512_srli_epi32(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, imm32 - 16), imm4 *8), + _mm512_slli_epi32(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, imm32 - 15), (4-imm4)*8))); + }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) + { return v_int8x64(_mm512_srli_epi32(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, 15), imm4*8)); }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64& b) + { return v_int8x64(_mm512_alignr_epi32(b.val, a.val, imm32)); }}; + template<> + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64& a, const v_int8x64&) { return a; }}; + template + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) + { return v_int8x64(_mm512_alignr_epi32(_mm512_setzero_si512(), b.val, imm32 - 16)); }}; + template<> + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64& b) { return b; }}; + template<> + struct _v_rotate_right { static inline v_int8x64 eval(const v_int8x64&, const v_int8x64&) { return v_int8x64(); }}; +} +template inline v_int8x64 v_rotate_right(const v_int8x64& a, const v_int8x64& b) +{ + return imm >= 128 ? v_int8x64() : +#if CV_AVX_512VBMI + v_int8x64(_mm512_permutex2var_epi8(a.val, + _v512_set_epu8(0x3f + imm, 0x3e + imm, 0x3d + imm, 0x3c + imm, 0x3b + imm, 0x3a + imm, 0x39 + imm, 0x38 + imm, + 0x37 + imm, 0x36 + imm, 0x35 + imm, 0x34 + imm, 0x33 + imm, 0x32 + imm, 0x31 + imm, 0x30 + imm, + 0x2f + imm, 0x2e + imm, 0x2d + imm, 0x2c + imm, 0x2b + imm, 0x2a + imm, 0x29 + imm, 0x28 + imm, + 0x27 + imm, 0x26 + imm, 0x25 + imm, 0x24 + imm, 0x23 + imm, 0x22 + imm, 0x21 + imm, 0x20 + imm, + 0x1f + imm, 0x1e + imm, 0x1d + imm, 0x1c + imm, 0x1b + imm, 0x1a + imm, 0x19 + imm, 0x18 + imm, + 0x17 + imm, 0x16 + imm, 0x15 + imm, 0x14 + imm, 0x13 + imm, 0x12 + imm, 0x11 + imm, 0x10 + imm, + 0x0f + imm, 0x0e + imm, 0x0d + imm, 0x0c + imm, 0x0b + imm, 0x0a + imm, 0x09 + imm, 0x08 + imm, + 0x07 + imm, 0x06 + imm, 0x05 + imm, 0x04 + imm, 0x03 + imm, 0x02 + imm, 0x01 + imm, 0x00 + imm), b.val)); +#else + _v_rotate_right 15), imm/4>::eval(a, b); +#endif +} +template +inline v_int8x64 v_rotate_left(const v_int8x64& a, const v_int8x64& b) +{ + if (imm == 0) return a; + if (imm == 64) return b; + if (imm >= 128) return v_int8x64(); +#if CV_AVX_512VBMI + return v_int8x64(_mm512_permutex2var_epi8(b.val, + _v512_set_epi8(0x7f - imm,0x7e - imm,0x7d - imm,0x7c - imm,0x7b - imm,0x7a - imm,0x79 - imm,0x78 - imm, + 0x77 - imm,0x76 - imm,0x75 - imm,0x74 - imm,0x73 - imm,0x72 - imm,0x71 - imm,0x70 - imm, + 0x6f - imm,0x6e - imm,0x6d - imm,0x6c - imm,0x6b - imm,0x6a - imm,0x69 - imm,0x68 - imm, + 0x67 - imm,0x66 - imm,0x65 - imm,0x64 - imm,0x63 - imm,0x62 - imm,0x61 - imm,0x60 - imm, + 0x5f - imm,0x5e - imm,0x5d - imm,0x5c - imm,0x5b - imm,0x5a - imm,0x59 - imm,0x58 - imm, + 0x57 - imm,0x56 - imm,0x55 - imm,0x54 - imm,0x53 - imm,0x52 - imm,0x51 - imm,0x50 - imm, + 0x4f - imm,0x4e - imm,0x4d - imm,0x4c - imm,0x4b - imm,0x4a - imm,0x49 - imm,0x48 - imm, + 0x47 - imm,0x46 - imm,0x45 - imm,0x44 - imm,0x43 - imm,0x42 - imm,0x41 - imm,0x40 - imm), a.val)); +#else + return imm < 64 ? v_rotate_right<64 - imm>(b, a) : v_rotate_right<128 - imm>(v512_setzero_s8(), b); +#endif +} +template +inline v_int8x64 v_rotate_right(const v_int8x64& a) +{ + if (imm == 0) return a; + if (imm >= 64) return v_int8x64(); +#if CV_AVX_512VBMI + return v_int8x64(_mm512_maskz_permutexvar_epi8(0xFFFFFFFFFFFFFFFF >> imm, + _v512_set_epu8(0x3f + imm,0x3e + imm,0x3d + imm,0x3c + imm,0x3b + imm,0x3a + imm,0x39 + imm,0x38 + imm, + 0x37 + imm,0x36 + imm,0x35 + imm,0x34 + imm,0x33 + imm,0x32 + imm,0x31 + imm,0x30 + imm, + 0x2f + imm,0x2e + imm,0x2d + imm,0x2c + imm,0x2b + imm,0x2a + imm,0x29 + imm,0x28 + imm, + 0x27 + imm,0x26 + imm,0x25 + imm,0x24 + imm,0x23 + imm,0x22 + imm,0x21 + imm,0x20 + imm, + 0x1f + imm,0x1e + imm,0x1d + imm,0x1c + imm,0x1b + imm,0x1a + imm,0x19 + imm,0x18 + imm, + 0x17 + imm,0x16 + imm,0x15 + imm,0x14 + imm,0x13 + imm,0x12 + imm,0x11 + imm,0x10 + imm, + 0x0f + imm,0x0e + imm,0x0d + imm,0x0c + imm,0x0b + imm,0x0a + imm,0x09 + imm,0x08 + imm, + 0x07 + imm,0x06 + imm,0x05 + imm,0x04 + imm,0x03 + imm,0x02 + imm,0x01 + imm,0x00 + imm), a.val)); +#else + return v_rotate_right(a, v512_setzero_s8()); +#endif +} +template +inline v_int8x64 v_rotate_left(const v_int8x64& a) +{ + if (imm == 0) return a; + if (imm >= 64) return v_int8x64(); +#if CV_AVX_512VBMI + return v_int8x64(_mm512_maskz_permutexvar_epi8(0xFFFFFFFFFFFFFFFF << imm, + _v512_set_epi8(0x3f - imm,0x3e - imm,0x3d - imm,0x3c - imm,0x3b - imm,0x3a - imm,0x39 - imm,0x38 - imm, + 0x37 - imm,0x36 - imm,0x35 - imm,0x34 - imm,0x33 - imm,0x32 - imm,0x31 - imm,0x30 - imm, + 0x2f - imm,0x2e - imm,0x2d - imm,0x2c - imm,0x2b - imm,0x2a - imm,0x29 - imm,0x28 - imm, + 0x27 - imm,0x26 - imm,0x25 - imm,0x24 - imm,0x23 - imm,0x22 - imm,0x21 - imm,0x20 - imm, + 0x1f - imm,0x1e - imm,0x1d - imm,0x1c - imm,0x1b - imm,0x1a - imm,0x19 - imm,0x18 - imm, + 0x17 - imm,0x16 - imm,0x15 - imm,0x14 - imm,0x13 - imm,0x12 - imm,0x11 - imm,0x10 - imm, + 0x0f - imm,0x0e - imm,0x0d - imm,0x0c - imm,0x0b - imm,0x0a - imm,0x09 - imm,0x08 - imm, + 0x07 - imm,0x06 - imm,0x05 - imm,0x04 - imm,0x03 - imm,0x02 - imm,0x01 - imm,0x00 - imm), a.val)); +#else + return v_rotate_right<64 - imm>(v512_setzero_s8(), a); +#endif +} + +#define OPENCV_HAL_IMPL_AVX512_ROTATE_PM(_Tpvec, suffix) \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ return v_reinterpret_as_##suffix(v_rotate_left(v_reinterpret_as_s8(a), v_reinterpret_as_s8(b))); } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ return v_reinterpret_as_##suffix(v_rotate_right(v_reinterpret_as_s8(a), v_reinterpret_as_s8(b))); } \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ return v_reinterpret_as_##suffix(v_rotate_left(v_reinterpret_as_s8(a))); } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ return v_reinterpret_as_##suffix(v_rotate_right(v_reinterpret_as_s8(a))); } + +#define OPENCV_HAL_IMPL_AVX512_ROTATE_EC(_Tpvec, suffix) \ +template \ +inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + enum { SHIFT2 = (_Tpvec::nlanes - imm) }; \ + enum { MASK = ((1 << _Tpvec::nlanes) - 1) }; \ + if (imm == 0) return a; \ + if (imm == _Tpvec::nlanes) return b; \ + if (imm >= 2*_Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_mask_expand_##suffix(_mm512_maskz_compress_##suffix((MASK << SHIFT2)&MASK, b.val), (MASK << (imm))&MASK, a.val)); \ +} \ +template \ +inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + enum { SHIFT2 = (_Tpvec::nlanes - imm) }; \ + enum { MASK = ((1 << _Tpvec::nlanes) - 1) }; \ + if (imm == 0) return a; \ + if (imm == _Tpvec::nlanes) return b; \ + if (imm >= 2*_Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_mask_expand_##suffix(_mm512_maskz_compress_##suffix((MASK << (imm))&MASK, a.val), (MASK << SHIFT2)&MASK, b.val)); \ +} \ +template \ +inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + if (imm == 0) return a; \ + if (imm >= _Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_maskz_expand_##suffix((1 << _Tpvec::nlanes) - (1 << (imm)), a.val)); \ +} \ +template \ +inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + if (imm == 0) return a; \ + if (imm >= _Tpvec::nlanes) return _Tpvec::zero(); \ + return _Tpvec(_mm512_maskz_compress_##suffix((1 << _Tpvec::nlanes) - (1 << (imm)), a.val)); \ +} + +OPENCV_HAL_IMPL_AVX512_ROTATE_PM(v_uint8x64, u8) +OPENCV_HAL_IMPL_AVX512_ROTATE_PM(v_uint16x32, u16) +OPENCV_HAL_IMPL_AVX512_ROTATE_PM(v_int16x32, s16) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_uint32x16, epi32) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_int32x16, epi32) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_uint64x8, epi64) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_int64x8, epi64) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_ROTATE_EC(v_float64x8, pd) + +/** Reverse **/ +inline v_uint8x64 v_reverse(const v_uint8x64 &a) +{ +#if CV_AVX_512VBMI + static const __m512i perm = _mm512_set_epi32( + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f, + 0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f, + 0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f); + return v_uint8x64(_mm512_permutexvar_epi8(perm, a.val)); +#else + static const __m512i shuf = _mm512_set_epi32( + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f); + static const __m512i perm = _mm512_set_epi64(1, 0, 3, 2, 5, 4, 7, 6); + __m512i vec = _mm512_shuffle_epi8(a.val, shuf); + return v_uint8x64(_mm512_permutexvar_epi64(perm, vec)); +#endif +} + +inline v_int8x64 v_reverse(const v_int8x64 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x32 v_reverse(const v_uint16x32 &a) +{ +#if CV_AVX_512VBMI + static const __m512i perm = _mm512_set_epi32( + 0x00000001, 0x00020003, 0x00040005, 0x00060007, + 0x00080009, 0x000a000b, 0x000c000d, 0x000e000f, + 0x00100011, 0x00120013, 0x00140015, 0x00160017, + 0x00180019, 0x001a001b, 0x001c001d, 0x001e001f); + return v_uint16x32(_mm512_permutexvar_epi16(perm, a.val)); +#else + static const __m512i shuf = _mm512_set_epi32( + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e, + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e, + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e, + 0x01000302, 0x05040706, 0x09080b0a, 0x0d0c0f0e); + static const __m512i perm = _mm512_set_epi64(1, 0, 3, 2, 5, 4, 7, 6); + __m512i vec = _mm512_shuffle_epi8(a.val, shuf); + return v_uint16x32(_mm512_permutexvar_epi64(perm, vec)); +#endif +} + +inline v_int16x32 v_reverse(const v_int16x32 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x16 v_reverse(const v_uint32x16 &a) +{ + static const __m512i perm = _mm512_set_epi32(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,14, 15); + return v_uint32x16(_mm512_permutexvar_epi32(perm, a.val)); +} + +inline v_int32x16 v_reverse(const v_int32x16 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x16 v_reverse(const v_float32x16 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x8 v_reverse(const v_uint64x8 &a) +{ + static const __m512i perm = _mm512_set_epi64(0, 1, 2, 3, 4, 5, 6, 7); + return v_uint64x8(_mm512_permutexvar_epi64(perm, a.val)); +} + +inline v_int64x8 v_reverse(const v_int64x8 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x8 v_reverse(const v_float64x8 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +////////// Reduce ///////// + +/** Reduce **/ +#define OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64(a, b) a + b +#define OPENCV_HAL_IMPL_AVX512_REDUCE_8(sctype, func, _Tpvec, ifunc, scop) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + sctype CV_DECL_ALIGNED(64) idx[2]; \ + _mm_store_si128((__m128i*)idx, _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1))); \ + return scop(idx[0], idx[1]); } +OPENCV_HAL_IMPL_AVX512_REDUCE_8(uint64, min, v_uint64x8, min_epu64, min) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(uint64, max, v_uint64x8, max_epu64, max) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(uint64, sum, v_uint64x8, add_epi64, OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(int64, min, v_int64x8, min_epi64, min) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(int64, max, v_int64x8, max_epi64, max) +OPENCV_HAL_IMPL_AVX512_REDUCE_8(int64, sum, v_int64x8, add_epi64, OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_8F(func, ifunc, scop) \ + inline double v_reduce_##func(const v_float64x8& a) \ + { __m256d half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + double CV_DECL_ALIGNED(64) idx[2]; \ + _mm_store_pd(idx, _mm_##ifunc(_mm256_castpd256_pd128(half), _mm256_extractf128_pd(half, 1))); \ + return scop(idx[0], idx[1]); } +OPENCV_HAL_IMPL_AVX512_REDUCE_8F(min, min_pd, min) +OPENCV_HAL_IMPL_AVX512_REDUCE_8F(max, max_pd, max) +OPENCV_HAL_IMPL_AVX512_REDUCE_8F(sum, add_pd, OPENCV_HAL_IMPL_AVX512_REDUCE_ADD64) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_16(sctype, func, _Tpvec, ifunc) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128i quarter = _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 8)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 4)); \ + return (sctype)_mm_cvtsi128_si32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_16(uint, min, v_uint32x16, min_epu32) +OPENCV_HAL_IMPL_AVX512_REDUCE_16(uint, max, v_uint32x16, max_epu32) +OPENCV_HAL_IMPL_AVX512_REDUCE_16(int, min, v_int32x16, min_epi32) +OPENCV_HAL_IMPL_AVX512_REDUCE_16(int, max, v_int32x16, max_epi32) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_16F(func, ifunc) \ + inline float v_reduce_##func(const v_float32x16& a) \ + { __m256 half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128 quarter = _mm_##ifunc(_mm256_castps256_ps128(half), _mm256_extractf128_ps(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_permute_ps(quarter, _MM_SHUFFLE(0, 0, 3, 2))); \ + quarter = _mm_##ifunc(quarter, _mm_permute_ps(quarter, _MM_SHUFFLE(0, 0, 0, 1))); \ + return _mm_cvtss_f32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_16F(min, min_ps) +OPENCV_HAL_IMPL_AVX512_REDUCE_16F(max, max_ps) + +inline float v_reduce_sum(const v_float32x16& a) +{ + __m256 half = _mm256_add_ps(_v512_extract_low(a.val), _v512_extract_high(a.val)); + __m128 quarter = _mm_add_ps(_mm256_castps256_ps128(half), _mm256_extractf128_ps(half, 1)); + quarter = _mm_hadd_ps(quarter, quarter); + return _mm_cvtss_f32(_mm_hadd_ps(quarter, quarter)); +} +inline int v_reduce_sum(const v_int32x16& a) +{ + __m256i half = _mm256_add_epi32(_v512_extract_low(a.val), _v512_extract_high(a.val)); + __m128i quarter = _mm_add_epi32(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); + quarter = _mm_hadd_epi32(quarter, quarter); + return _mm_cvtsi128_si32(_mm_hadd_epi32(quarter, quarter)); +} +inline uint v_reduce_sum(const v_uint32x16& a) +{ return (uint)v_reduce_sum(v_reinterpret_as_s32(a)); } + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_32(sctype, func, _Tpvec, ifunc) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128i quarter = _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 8)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 4)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 2)); \ + return (sctype)_mm_cvtsi128_si32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_32(ushort, min, v_uint16x32, min_epu16) +OPENCV_HAL_IMPL_AVX512_REDUCE_32(ushort, max, v_uint16x32, max_epu16) +OPENCV_HAL_IMPL_AVX512_REDUCE_32(short, min, v_int16x32, min_epi16) +OPENCV_HAL_IMPL_AVX512_REDUCE_32(short, max, v_int16x32, max_epi16) + +inline int v_reduce_sum(const v_int16x32& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } +inline uint v_reduce_sum(const v_uint16x32& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_64(sctype, func, _Tpvec, ifunc) \ + inline sctype v_reduce_##func(const _Tpvec& a) \ + { __m256i half = _mm256_##ifunc(_v512_extract_low(a.val), _v512_extract_high(a.val)); \ + __m128i quarter = _mm_##ifunc(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 8)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 4)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 2)); \ + quarter = _mm_##ifunc(quarter, _mm_srli_si128(quarter, 1)); \ + return (sctype)_mm_cvtsi128_si32(quarter); } +OPENCV_HAL_IMPL_AVX512_REDUCE_64(uchar, min, v_uint8x64, min_epu8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64(uchar, max, v_uint8x64, max_epu8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64(schar, min, v_int8x64, min_epi8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64(schar, max, v_int8x64, max_epi8) + +#define OPENCV_HAL_IMPL_AVX512_REDUCE_64_SUM(sctype, _Tpvec, suffix) \ + inline sctype v_reduce_sum(const _Tpvec& a) \ + { __m512i a16 = _mm512_add_epi16(_mm512_cvt##suffix##_epi16(_v512_extract_low(a.val)), \ + _mm512_cvt##suffix##_epi16(_v512_extract_high(a.val))); \ + a16 = _mm512_cvtepi16_epi32(_mm256_add_epi16(_v512_extract_low(a16), _v512_extract_high(a16))); \ + __m256i a8 = _mm256_add_epi32(_v512_extract_low(a16), _v512_extract_high(a16)); \ + __m128i a4 = _mm_add_epi32(_mm256_castsi256_si128(a8), _mm256_extracti128_si256(a8, 1)); \ + a4 = _mm_hadd_epi32(a4, a4); \ + return (sctype)_mm_cvtsi128_si32(_mm_hadd_epi32(a4, a4)); } +OPENCV_HAL_IMPL_AVX512_REDUCE_64_SUM(uint, v_uint8x64, epu8) +OPENCV_HAL_IMPL_AVX512_REDUCE_64_SUM(int, v_int8x64, epi8) + +inline v_float32x16 v_reduce_sum4(const v_float32x16& a, const v_float32x16& b, + const v_float32x16& c, const v_float32x16& d) +{ + __m256 abl = _mm256_hadd_ps(_v512_extract_low(a.val), _v512_extract_low(b.val)); + __m256 abh = _mm256_hadd_ps(_v512_extract_high(a.val), _v512_extract_high(b.val)); + __m256 cdl = _mm256_hadd_ps(_v512_extract_low(c.val), _v512_extract_low(d.val)); + __m256 cdh = _mm256_hadd_ps(_v512_extract_high(c.val), _v512_extract_high(d.val)); + return v_float32x16(_v512_combine(_mm256_hadd_ps(abl, cdl), _mm256_hadd_ps(abh, cdh))); +} + +inline unsigned v_reduce_sad(const v_uint8x64& a, const v_uint8x64& b) +{ + __m512i val = _mm512_sad_epu8(a.val, b.val); + __m256i half = _mm256_add_epi32(_v512_extract_low(val), _v512_extract_high(val)); + __m128i quarter = _mm_add_epi32(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_int8x64& a, const v_int8x64& b) +{ + __m512i val = _mm512_set1_epi8(-128); + val = _mm512_sad_epu8(_mm512_add_epi8(a.val, val), _mm512_add_epi8(b.val, val)); + __m256i half = _mm256_add_epi32(_v512_extract_low(val), _v512_extract_high(val)); + __m128i quarter = _mm_add_epi32(_mm256_castsi256_si128(half), _mm256_extracti128_si256(half, 1)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(quarter, _mm_unpackhi_epi64(quarter, quarter))); +} +inline unsigned v_reduce_sad(const v_uint16x32& a, const v_uint16x32& b) +{ return v_reduce_sum(v_add_wrap(a - b, b - a)); } +inline unsigned v_reduce_sad(const v_int16x32& a, const v_int16x32& b) +{ return v_reduce_sum(v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b)))); } +inline unsigned v_reduce_sad(const v_uint32x16& a, const v_uint32x16& b) +{ return v_reduce_sum(v_max(a, b) - v_min(a, b)); } +inline unsigned v_reduce_sad(const v_int32x16& a, const v_int32x16& b) +{ return v_reduce_sum(v_reinterpret_as_u32(v_max(a, b) - v_min(a, b))); } +inline float v_reduce_sad(const v_float32x16& a, const v_float32x16& b) +{ return v_reduce_sum((a - b) & v_float32x16(_mm512_castsi512_ps(_mm512_set1_epi32(0x7fffffff)))); } +inline double v_reduce_sad(const v_float64x8& a, const v_float64x8& b) +{ return v_reduce_sum((a - b) & v_float64x8(_mm512_castsi512_pd(_mm512_set1_epi64(0x7fffffffffffffff)))); } + +/** Popcount **/ +inline v_uint8x64 v_popcount(const v_int8x64& a) +{ +#if CV_AVX_512BITALG + return v_uint8x64(_mm512_popcnt_epi8(a.val)); +#elif CV_AVX_512VBMI + __m512i _popcnt_table0 = _v512_set_epu8(7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3, + 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1, + 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1, + 4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0); + __m512i _popcnt_table1 = _v512_set_epu8(7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3, + 6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, + 6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2, + 5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1); + return v_uint8x64(_mm512_sub_epi8(_mm512_permutex2var_epi8(_popcnt_table0, a.val, _popcnt_table1), _mm512_movm_epi8(_mm512_movepi8_mask(a.val)))); +#else + __m512i _popcnt_table = _mm512_set4_epi32(0x04030302, 0x03020201, 0x03020201, 0x02010100); + __m512i _popcnt_mask = _mm512_set1_epi8(0x0F); + + return v_uint8x64(_mm512_add_epi8(_mm512_shuffle_epi8(_popcnt_table, _mm512_and_si512( a.val, _popcnt_mask)), + _mm512_shuffle_epi8(_popcnt_table, _mm512_and_si512(_mm512_srli_epi16(a.val, 4), _popcnt_mask)))); +#endif +} +inline v_uint16x32 v_popcount(const v_int16x32& a) +{ +#if CV_AVX_512BITALG + return v_uint16x32(_mm512_popcnt_epi16(a.val)); +#elif CV_AVX_512VPOPCNTDQ + __m512i zero = _mm512_setzero_si512(); + return v_uint16x32(_mm512_packs_epi32(_mm512_popcnt_epi32(_mm512_unpacklo_epi16(a.val, zero)), + _mm512_popcnt_epi32(_mm512_unpackhi_epi16(a.val, zero)))); +#else + v_uint8x64 p = v_popcount(v_reinterpret_as_s8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v512_setall_u16(0x00ff); +#endif +} +inline v_uint32x16 v_popcount(const v_int32x16& a) +{ +#if CV_AVX_512VPOPCNTDQ + return v_uint32x16(_mm512_popcnt_epi32(a.val)); +#else + v_uint8x64 p = v_popcount(v_reinterpret_as_s8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v512_setall_u32(0x000000ff); +#endif +} +inline v_uint64x8 v_popcount(const v_int64x8& a) +{ +#if CV_AVX_512VPOPCNTDQ + return v_uint64x8(_mm512_popcnt_epi64(a.val)); +#else + return v_uint64x8(_mm512_sad_epu8(v_popcount(v_reinterpret_as_s8(a)).val, _mm512_setzero_si512())); +#endif +} + + +inline v_uint8x64 v_popcount(const v_uint8x64& a) { return v_popcount(v_reinterpret_as_s8 (a)); } +inline v_uint16x32 v_popcount(const v_uint16x32& a) { return v_popcount(v_reinterpret_as_s16(a)); } +inline v_uint32x16 v_popcount(const v_uint32x16& a) { return v_popcount(v_reinterpret_as_s32(a)); } +inline v_uint64x8 v_popcount(const v_uint64x8& a) { return v_popcount(v_reinterpret_as_s64(a)); } + + +////////// Other math ///////// + +/** Some frequent operations **/ +#if CV_FMA3 +#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } +#else +#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } +#endif + +#define OPENCV_HAL_IMPL_AVX512_MISC(_Tpvec, suffix) \ + inline _Tpvec v_sqrt(const _Tpvec& x) \ + { return _Tpvec(_mm512_sqrt_##suffix(x.val)); } \ + inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_fma(a, a, b * b); } \ + inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ + { return v_sqrt(v_fma(a, a, b * b)); } + +OPENCV_HAL_IMPL_AVX512_MULADD(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_MULADD(v_float64x8, pd) +OPENCV_HAL_IMPL_AVX512_MISC(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_MISC(v_float64x8, pd) + +inline v_int32x16 v_fma(const v_int32x16& a, const v_int32x16& b, const v_int32x16& c) +{ return a * b + c; } +inline v_int32x16 v_muladd(const v_int32x16& a, const v_int32x16& b, const v_int32x16& c) +{ return v_fma(a, b, c); } + +inline v_float32x16 v_invsqrt(const v_float32x16& x) +{ +#if CV_AVX_512ER + return v_float32x16(_mm512_rsqrt28_ps(x.val)); +#else + v_float32x16 half = x * v512_setall_f32(0.5); + v_float32x16 t = v_float32x16(_mm512_rsqrt14_ps(x.val)); + t *= v512_setall_f32(1.5) - ((t * t) * half); + return t; +#endif +} + +inline v_float64x8 v_invsqrt(const v_float64x8& x) +{ +#if CV_AVX_512ER + return v_float64x8(_mm512_rsqrt28_pd(x.val)); +#else + return v512_setall_f64(1.) / v_sqrt(x); +// v_float64x8 half = x * v512_setall_f64(0.5); +// v_float64x8 t = v_float64x8(_mm512_rsqrt14_pd(x.val)); +// t *= v512_setall_f64(1.5) - ((t * t) * half); +// t *= v512_setall_f64(1.5) - ((t * t) * half); +// return t; +#endif +} + +/** Absolute values **/ +#define OPENCV_HAL_IMPL_AVX512_ABS(_Tpvec, _Tpuvec, suffix) \ + inline _Tpuvec v_abs(const _Tpvec& x) \ + { return _Tpuvec(_mm512_abs_##suffix(x.val)); } + +OPENCV_HAL_IMPL_AVX512_ABS(v_int8x64, v_uint8x64, epi8) +OPENCV_HAL_IMPL_AVX512_ABS(v_int16x32, v_uint16x32, epi16) +OPENCV_HAL_IMPL_AVX512_ABS(v_int32x16, v_uint32x16, epi32) +OPENCV_HAL_IMPL_AVX512_ABS(v_int64x8, v_uint64x8, epi64) + +inline v_float32x16 v_abs(const v_float32x16& x) +{ +#ifdef _mm512_abs_pd + return v_float32x16(_mm512_abs_ps(x.val)); +#else + return v_float32x16(_mm512_castsi512_ps(_mm512_and_si512(_mm512_castps_si512(x.val), + _v512_set_epu64(0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, + 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF, 0x7FFFFFFF7FFFFFFF)))); +#endif +} + +inline v_float64x8 v_abs(const v_float64x8& x) +{ +#ifdef _mm512_abs_pd + #if defined __GNUC__ && (__GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ <= 3) || (__GNUC__ == 8 && __GNUC_MINOR__ <= 2)) + // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87476 + return v_float64x8(_mm512_abs_pd(_mm512_castpd_ps(x.val))); + #else + return v_float64x8(_mm512_abs_pd(x.val)); + #endif +#else + return v_float64x8(_mm512_castsi512_pd(_mm512_and_si512(_mm512_castpd_si512(x.val), + _v512_set_epu64(0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, + 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF)))); +#endif +} + +/** Absolute difference **/ +inline v_uint8x64 v_absdiff(const v_uint8x64& a, const v_uint8x64& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x32 v_absdiff(const v_uint16x32& a, const v_uint16x32& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x16 v_absdiff(const v_uint32x16& a, const v_uint32x16& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x64 v_absdiff(const v_int8x64& a, const v_int8x64& b) +{ + v_int8x64 d = v_sub_wrap(a, b); + v_int8x64 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} + +inline v_uint16x32 v_absdiff(const v_int16x32& a, const v_int16x32& b) +{ return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); } + +inline v_uint32x16 v_absdiff(const v_int32x16& a, const v_int32x16& b) +{ + v_int32x16 d = a - b; + v_int32x16 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +inline v_float32x16 v_absdiff(const v_float32x16& a, const v_float32x16& b) +{ return v_abs(a - b); } + +inline v_float64x8 v_absdiff(const v_float64x8& a, const v_float64x8& b) +{ return v_abs(a - b); } + +/** Saturating absolute difference **/ +inline v_int8x64 v_absdiffs(const v_int8x64& a, const v_int8x64& b) +{ + v_int8x64 d = a - b; + v_int8x64 m = a < b; + return (d ^ m) - m; +} +inline v_int16x32 v_absdiffs(const v_int16x32& a, const v_int16x32& b) +{ return v_max(a, b) - v_min(a, b); } + +////////// Conversions ///////// + +/** Rounding **/ +inline v_int32x16 v_round(const v_float32x16& a) +{ return v_int32x16(_mm512_cvtps_epi32(a.val)); } + +inline v_int32x16 v_round(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvtpd_epi32(a.val))); } + +inline v_int32x16 v_round(const v_float64x8& a, const v_float64x8& b) +{ return v_int32x16(_v512_combine(_mm512_cvtpd_epi32(a.val), _mm512_cvtpd_epi32(b.val))); } + +inline v_int32x16 v_trunc(const v_float32x16& a) +{ return v_int32x16(_mm512_cvttps_epi32(a.val)); } + +inline v_int32x16 v_trunc(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvttpd_epi32(a.val))); } + +#if CVT_ROUND_MODES_IMPLEMENTED +inline v_int32x16 v_floor(const v_float32x16& a) +{ return v_int32x16(_mm512_cvt_roundps_epi32(a.val, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)); } + +inline v_int32x16 v_floor(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvt_roundpd_epi32(a.val, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC))); } + +inline v_int32x16 v_ceil(const v_float32x16& a) +{ return v_int32x16(_mm512_cvt_roundps_epi32(a.val, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)); } + +inline v_int32x16 v_ceil(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvt_roundpd_epi32(a.val, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC))); } +#else +inline v_int32x16 v_floor(const v_float32x16& a) +{ return v_int32x16(_mm512_cvtps_epi32(_mm512_roundscale_ps(a.val, 1))); } + +inline v_int32x16 v_floor(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvtpd_epi32(_mm512_roundscale_pd(a.val, 1)))); } + +inline v_int32x16 v_ceil(const v_float32x16& a) +{ return v_int32x16(_mm512_cvtps_epi32(_mm512_roundscale_ps(a.val, 2))); } + +inline v_int32x16 v_ceil(const v_float64x8& a) +{ return v_int32x16(_mm512_castsi256_si512(_mm512_cvtpd_epi32(_mm512_roundscale_pd(a.val, 2)))); } +#endif + +/** To float **/ +inline v_float32x16 v_cvt_f32(const v_int32x16& a) +{ return v_float32x16(_mm512_cvtepi32_ps(a.val)); } + +inline v_float32x16 v_cvt_f32(const v_float64x8& a) +{ return v_float32x16(_mm512_cvtpd_pslo(a.val)); } + +inline v_float32x16 v_cvt_f32(const v_float64x8& a, const v_float64x8& b) +{ return v_float32x16(_v512_combine(_mm512_cvtpd_ps(a.val), _mm512_cvtpd_ps(b.val))); } + +inline v_float64x8 v_cvt_f64(const v_int32x16& a) +{ return v_float64x8(_mm512_cvtepi32_pd(_v512_extract_low(a.val))); } + +inline v_float64x8 v_cvt_f64_high(const v_int32x16& a) +{ return v_float64x8(_mm512_cvtepi32_pd(_v512_extract_high(a.val))); } + +inline v_float64x8 v_cvt_f64(const v_float32x16& a) +{ return v_float64x8(_mm512_cvtps_pd(_v512_extract_low(a.val))); } + +inline v_float64x8 v_cvt_f64_high(const v_float32x16& a) +{ return v_float64x8(_mm512_cvtps_pd(_v512_extract_high(a.val))); } + +// from (Mysticial and wim) https://stackoverflow.com/q/41144668 +inline v_float64x8 v_cvt_f64(const v_int64x8& v) +{ +#if CV_AVX_512DQ + return v_float64x8(_mm512_cvtepi64_pd(v.val)); +#else + // constants encoded as floating-point + __m512i magic_i_lo = _mm512_set1_epi64(0x4330000000000000); // 2^52 + __m512i magic_i_hi32 = _mm512_set1_epi64(0x4530000080000000); // 2^84 + 2^63 + __m512i magic_i_all = _mm512_set1_epi64(0x4530000080100000); // 2^84 + 2^63 + 2^52 + __m512d magic_d_all = _mm512_castsi512_pd(magic_i_all); + + // Blend the 32 lowest significant bits of v with magic_int_lo + __m512i v_lo = _mm512_mask_blend_epi32(0x5555, magic_i_lo, v.val); + // Extract the 32 most significant bits of v + __m512i v_hi = _mm512_srli_epi64(v.val, 32); + // Flip the msb of v_hi and blend with 0x45300000 + v_hi = _mm512_xor_si512(v_hi, magic_i_hi32); + // Compute in double precision + __m512d v_hi_dbl = _mm512_sub_pd(_mm512_castsi512_pd(v_hi), magic_d_all); + // (v_hi - magic_d_all) + v_lo Do not assume associativity of floating point addition + __m512d result = _mm512_add_pd(v_hi_dbl, _mm512_castsi512_pd(v_lo)); + return v_float64x8(result); +#endif +} + +////////////// Lookup table access //////////////////// + +inline v_int8x64 v512_lut(const schar* tab, const int* idx) +{ + __m128i p0 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx ), (const int *)tab, 1)); + __m128i p1 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 1), (const int *)tab, 1)); + __m128i p2 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 2), (const int *)tab, 1)); + __m128i p3 = _mm512_cvtepi32_epi8(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 3), (const int *)tab, 1)); + return v_int8x64(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_castsi128_si512(p0), p1, 1), p2, 2), p3, 3)); +} +inline v_int8x64 v512_lut_pairs(const schar* tab, const int* idx) +{ + __m256i p0 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx ), (const int *)tab, 1)); + __m256i p1 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 1), (const int *)tab, 1)); + return v_int8x64(_v512_combine(p0, p1)); +} +inline v_int8x64 v512_lut_quads(const schar* tab, const int* idx) +{ + return v_int8x64(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx), (const int *)tab, 1)); +} +inline v_uint8x64 v512_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v512_lut((const schar *)tab, idx)); } +inline v_uint8x64 v512_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v512_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x64 v512_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v512_lut_quads((const schar *)tab, idx)); } + +inline v_int16x32 v512_lut(const short* tab, const int* idx) +{ + __m256i p0 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx ), (const int *)tab, 2)); + __m256i p1 = _mm512_cvtepi32_epi16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx + 1), (const int *)tab, 2)); + return v_int16x32(_v512_combine(p0, p1)); +} +inline v_int16x32 v512_lut_pairs(const short* tab, const int* idx) +{ + return v_int16x32(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx), (const int *)tab, 2)); +} +inline v_int16x32 v512_lut_quads(const short* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int16x32(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const long long int*)tab, 2)); +#else + return v_int16x32(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const int64*)tab, 2)); +#endif +} +inline v_uint16x32 v512_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v512_lut((const short *)tab, idx)); } +inline v_uint16x32 v512_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v512_lut_pairs((const short *)tab, idx)); } +inline v_uint16x32 v512_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v512_lut_quads((const short *)tab, idx)); } + +inline v_int32x16 v512_lut(const int* tab, const int* idx) +{ + return v_int32x16(_mm512_i32gather_epi32(_mm512_loadu_si512((const __m512i*)idx), tab, 4)); +} +inline v_int32x16 v512_lut_pairs(const int* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int32x16(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const long long int*)tab, 4)); +#else + return v_int32x16(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const int64*)tab, 4)); +#endif +} +inline v_int32x16 v512_lut_quads(const int* tab, const int* idx) +{ + return v_int32x16(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_castsi128_si512( + _mm_loadu_si128((const __m128i*)(tab + idx[0]))), + _mm_loadu_si128((const __m128i*)(tab + idx[1])), 1), + _mm_loadu_si128((const __m128i*)(tab + idx[2])), 2), + _mm_loadu_si128((const __m128i*)(tab + idx[3])), 3)); +} +inline v_uint32x16 v512_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v512_lut((const int *)tab, idx)); } +inline v_uint32x16 v512_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v512_lut_pairs((const int *)tab, idx)); } +inline v_uint32x16 v512_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v512_lut_quads((const int *)tab, idx)); } + +inline v_int64x8 v512_lut(const int64* tab, const int* idx) +{ +#if defined(__GNUC__) + return v_int64x8(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), (const long long int*)tab, 8)); +#else + return v_int64x8(_mm512_i32gather_epi64(_mm256_loadu_si256((const __m256i*)idx), tab , 8)); +#endif +} +inline v_int64x8 v512_lut_pairs(const int64* tab, const int* idx) +{ + return v_int64x8(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_inserti32x4(_mm512_castsi128_si512( + _mm_loadu_si128((const __m128i*)(tab + idx[0]))), + _mm_loadu_si128((const __m128i*)(tab + idx[1])), 1), + _mm_loadu_si128((const __m128i*)(tab + idx[2])), 2), + _mm_loadu_si128((const __m128i*)(tab + idx[3])), 3)); +} +inline v_uint64x8 v512_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v512_lut((const int64 *)tab, idx)); } +inline v_uint64x8 v512_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v512_lut_pairs((const int64 *)tab, idx)); } + +inline v_float32x16 v512_lut(const float* tab, const int* idx) +{ + return v_float32x16(_mm512_i32gather_ps(_mm512_loadu_si512((const __m512i*)idx), tab, 4)); +} +inline v_float32x16 v512_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v512_lut_pairs((const int *)tab, idx)); } +inline v_float32x16 v512_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v512_lut_quads((const int *)tab, idx)); } + +inline v_float64x8 v512_lut(const double* tab, const int* idx) +{ + return v_float64x8(_mm512_i32gather_pd(_mm256_loadu_si256((const __m256i*)idx), tab, 8)); +} +inline v_float64x8 v512_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x8(_mm512_insertf64x2(_mm512_insertf64x2(_mm512_insertf64x2(_mm512_castpd128_pd512( + _mm_loadu_pd(tab + idx[0])), + _mm_loadu_pd(tab + idx[1]), 1), + _mm_loadu_pd(tab + idx[2]), 2), + _mm_loadu_pd(tab + idx[3]), 3)); +} + +inline v_int32x16 v_lut(const int* tab, const v_int32x16& idxvec) +{ + return v_int32x16(_mm512_i32gather_epi32(idxvec.val, tab, 4)); +} + +inline v_uint32x16 v_lut(const unsigned* tab, const v_int32x16& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x16 v_lut(const float* tab, const v_int32x16& idxvec) +{ + return v_float32x16(_mm512_i32gather_ps(idxvec.val, tab, 4)); +} + +inline v_float64x8 v_lut(const double* tab, const v_int32x16& idxvec) +{ + return v_float64x8(_mm512_i32gather_pd(_v512_extract_low(idxvec.val), tab, 8)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x16& idxvec, v_float32x16& x, v_float32x16& y) +{ + x.val = _mm512_i32gather_ps(idxvec.val, tab, 4); + y.val = _mm512_i32gather_ps(idxvec.val, &tab[1], 4); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x16& idxvec, v_float64x8& x, v_float64x8& y) +{ + x.val = _mm512_i32gather_pd(_v512_extract_low(idxvec.val), tab, 8); + y.val = _mm512_i32gather_pd(_v512_extract_low(idxvec.val), &tab[1], 8); +} + +inline v_int8x64 v_interleave_pairs(const v_int8x64& vec) +{ + return v_int8x64(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0d0e0c, 0x0b090a08, 0x07050604, 0x03010200))); +} +inline v_uint8x64 v_interleave_pairs(const v_uint8x64& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x64 v_interleave_quads(const v_int8x64& vec) +{ + return v_int8x64(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0b0e0a, 0x0d090c08, 0x07030602, 0x05010400))); +} +inline v_uint8x64 v_interleave_quads(const v_uint8x64& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x32 v_interleave_pairs(const v_int16x32& vec) +{ + return v_int16x32(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0e0b0a, 0x0d0c0908, 0x07060302, 0x05040100))); +} +inline v_uint16x32 v_interleave_pairs(const v_uint16x32& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x32 v_interleave_quads(const v_int16x32& vec) +{ + return v_int16x32(_mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0x0f0e0706, 0x0d0c0504, 0x0b0a0302, 0x09080100))); +} +inline v_uint16x32 v_interleave_quads(const v_uint16x32& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x16 v_interleave_pairs(const v_int32x16& vec) +{ + return v_int32x16(_mm512_shuffle_epi32(vec.val, _MM_PERM_ACBD)); +} +inline v_uint32x16 v_interleave_pairs(const v_uint32x16& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x16 v_interleave_pairs(const v_float32x16& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x64 v_pack_triplets(const v_int8x64& vec) +{ + return v_int8x64(_mm512_permutexvar_epi32(_v512_set_epu64(0x0000000f0000000f, 0x0000000f0000000f, 0x0000000e0000000d, 0x0000000c0000000a, + 0x0000000900000008, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000), + _mm512_shuffle_epi8(vec.val, _mm512_set4_epi32(0xffffff0f, 0x0e0d0c0a, 0x09080605, 0x04020100)))); +} +inline v_uint8x64 v_pack_triplets(const v_uint8x64& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x32 v_pack_triplets(const v_int16x32& vec) +{ + return v_int16x32(_mm512_permutexvar_epi16(_v512_set_epu64(0x001f001f001f001f, 0x001f001f001f001f, 0x001e001d001c001a, 0x0019001800160015, + 0x0014001200110010, 0x000e000d000c000a, 0x0009000800060005, 0x0004000200010000), vec.val)); +} +inline v_uint16x32 v_pack_triplets(const v_uint16x32& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x16 v_pack_triplets(const v_int32x16& vec) +{ + return v_int32x16(_mm512_permutexvar_epi32(_v512_set_epu64(0x0000000f0000000f, 0x0000000f0000000f, 0x0000000e0000000d, 0x0000000c0000000a, + 0x0000000900000008, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000), vec.val)); +} +inline v_uint32x16 v_pack_triplets(const v_uint32x16& vec) { return v_reinterpret_as_u32(v_pack_triplets(v_reinterpret_as_s32(vec))); } +inline v_float32x16 v_pack_triplets(const v_float32x16& vec) +{ + return v_float32x16(_mm512_permutexvar_ps(_v512_set_epu64(0x0000000f0000000f, 0x0000000f0000000f, 0x0000000e0000000d, 0x0000000c0000000a, + 0x0000000900000008, 0x0000000600000005, 0x0000000400000002, 0x0000000100000000), vec.val)); +} + +////////// Matrix operations ///////// + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x16 v_dotprod(const v_int16x32& a, const v_int16x32& b) +{ return v_int32x16(_mm512_madd_epi16(a.val, b.val)); } +inline v_int32x16 v_dotprod(const v_int16x32& a, const v_int16x32& b, const v_int32x16& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x8 v_dotprod(const v_int32x16& a, const v_int32x16& b) +{ + __m512i even = _mm512_mul_epi32(a.val, b.val); + __m512i odd = _mm512_mul_epi32(_mm512_srli_epi64(a.val, 32), _mm512_srli_epi64(b.val, 32)); + return v_int64x8(_mm512_add_epi64(even, odd)); +} +inline v_int64x8 v_dotprod(const v_int32x16& a, const v_int32x16& b, const v_int64x8& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x16 v_dotprod_expand(const v_uint8x64& a, const v_uint8x64& b) +{ + __m512i even_a = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, a.val, _mm512_setzero_si512()); + __m512i odd_a = _mm512_srli_epi16(a.val, 8); + + __m512i even_b = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, b.val, _mm512_setzero_si512()); + __m512i odd_b = _mm512_srli_epi16(b.val, 8); + + __m512i prod0 = _mm512_madd_epi16(even_a, even_b); + __m512i prod1 = _mm512_madd_epi16(odd_a, odd_b); + return v_uint32x16(_mm512_add_epi32(prod0, prod1)); +} +inline v_uint32x16 v_dotprod_expand(const v_uint8x64& a, const v_uint8x64& b, const v_uint32x16& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x16 v_dotprod_expand(const v_int8x64& a, const v_int8x64& b) +{ + __m512i even_a = _mm512_srai_epi16(_mm512_bslli_epi128(a.val, 1), 8); + __m512i odd_a = _mm512_srai_epi16(a.val, 8); + + __m512i even_b = _mm512_srai_epi16(_mm512_bslli_epi128(b.val, 1), 8); + __m512i odd_b = _mm512_srai_epi16(b.val, 8); + + __m512i prod0 = _mm512_madd_epi16(even_a, even_b); + __m512i prod1 = _mm512_madd_epi16(odd_a, odd_b); + return v_int32x16(_mm512_add_epi32(prod0, prod1)); +} +inline v_int32x16 v_dotprod_expand(const v_int8x64& a, const v_int8x64& b, const v_int32x16& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x8 v_dotprod_expand(const v_uint16x32& a, const v_uint16x32& b) +{ + __m512i mullo = _mm512_mullo_epi16(a.val, b.val); + __m512i mulhi = _mm512_mulhi_epu16(a.val, b.val); + __m512i mul0 = _mm512_unpacklo_epi16(mullo, mulhi); + __m512i mul1 = _mm512_unpackhi_epi16(mullo, mulhi); + + __m512i p02 = _mm512_mask_blend_epi32(0xAAAA, mul0, _mm512_setzero_si512()); + __m512i p13 = _mm512_srli_epi64(mul0, 32); + __m512i p46 = _mm512_mask_blend_epi32(0xAAAA, mul1, _mm512_setzero_si512()); + __m512i p57 = _mm512_srli_epi64(mul1, 32); + + __m512i p15_ = _mm512_add_epi64(p02, p13); + __m512i p9d_ = _mm512_add_epi64(p46, p57); + + return v_uint64x8(_mm512_add_epi64( + _mm512_unpacklo_epi64(p15_, p9d_), + _mm512_unpackhi_epi64(p15_, p9d_) + )); +} +inline v_uint64x8 v_dotprod_expand(const v_uint16x32& a, const v_uint16x32& b, const v_uint64x8& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x8 v_dotprod_expand(const v_int16x32& a, const v_int16x32& b) +{ + __m512i prod = _mm512_madd_epi16(a.val, b.val); + __m512i even = _mm512_srai_epi64(_mm512_bslli_epi128(prod, 4), 32); + __m512i odd = _mm512_srai_epi64(prod, 32); + return v_int64x8(_mm512_add_epi64(even, odd)); +} +inline v_int64x8 v_dotprod_expand(const v_int16x32& a, const v_int16x32& b, const v_int64x8& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x8 v_dotprod_expand(const v_int32x16& a, const v_int32x16& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x8 v_dotprod_expand(const v_int32x16& a, const v_int32x16& b, const v_float64x8& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x16 v_dotprod_fast(const v_int16x32& a, const v_int16x32& b) +{ return v_dotprod(a, b); } +inline v_int32x16 v_dotprod_fast(const v_int16x32& a, const v_int16x32& b, const v_int32x16& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x8 v_dotprod_fast(const v_int32x16& a, const v_int32x16& b) +{ return v_dotprod(a, b); } +inline v_int64x8 v_dotprod_fast(const v_int32x16& a, const v_int32x16& b, const v_int64x8& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x16 v_dotprod_expand_fast(const v_uint8x64& a, const v_uint8x64& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x16 v_dotprod_expand_fast(const v_uint8x64& a, const v_uint8x64& b, const v_uint32x16& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_int32x16 v_dotprod_expand_fast(const v_int8x64& a, const v_int8x64& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x16 v_dotprod_expand_fast(const v_int8x64& a, const v_int8x64& b, const v_int32x16& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x8 v_dotprod_expand_fast(const v_uint16x32& a, const v_uint16x32& b) +{ + __m512i mullo = _mm512_mullo_epi16(a.val, b.val); + __m512i mulhi = _mm512_mulhi_epu16(a.val, b.val); + __m512i mul0 = _mm512_unpacklo_epi16(mullo, mulhi); + __m512i mul1 = _mm512_unpackhi_epi16(mullo, mulhi); + + __m512i p02 = _mm512_mask_blend_epi32(0xAAAA, mul0, _mm512_setzero_si512()); + __m512i p13 = _mm512_srli_epi64(mul0, 32); + __m512i p46 = _mm512_mask_blend_epi32(0xAAAA, mul1, _mm512_setzero_si512()); + __m512i p57 = _mm512_srli_epi64(mul1, 32); + + __m512i p15_ = _mm512_add_epi64(p02, p13); + __m512i p9d_ = _mm512_add_epi64(p46, p57); + return v_uint64x8(_mm512_add_epi64(p15_, p9d_)); +} +inline v_uint64x8 v_dotprod_expand_fast(const v_uint16x32& a, const v_uint16x32& b, const v_uint64x8& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x8 v_dotprod_expand_fast(const v_int16x32& a, const v_int16x32& b) +{ return v_dotprod_expand(a, b); } +inline v_int64x8 v_dotprod_expand_fast(const v_int16x32& a, const v_int16x32& b, const v_int64x8& c) +{ return v_dotprod_expand(a, b, c); } + +// 32 >> 64f +inline v_float64x8 v_dotprod_expand_fast(const v_int32x16& a, const v_int32x16& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x8 v_dotprod_expand_fast(const v_int32x16& a, const v_int32x16& b, const v_float64x8& c) +{ return v_dotprod_expand(a, b) + c; } + + +#define OPENCV_HAL_AVX512_SPLAT2_PS(a, im) \ + v_float32x16(_mm512_permute_ps(a.val, _MM_SHUFFLE(im, im, im, im))) + +inline v_float32x16 v_matmul(const v_float32x16& v, + const v_float32x16& m0, const v_float32x16& m1, + const v_float32x16& m2, const v_float32x16& m3) +{ + v_float32x16 v04 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 0); + v_float32x16 v15 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 1); + v_float32x16 v26 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 2); + v_float32x16 v37 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 3); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, v37 * m3))); +} + +inline v_float32x16 v_matmuladd(const v_float32x16& v, + const v_float32x16& m0, const v_float32x16& m1, + const v_float32x16& m2, const v_float32x16& a) +{ + v_float32x16 v04 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 0); + v_float32x16 v15 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 1); + v_float32x16 v26 = OPENCV_HAL_AVX512_SPLAT2_PS(v, 2); + return v_fma(v04, m0, v_fma(v15, m1, v_fma(v26, m2, a))); +} + +#define OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(_Tpvec, suffix, cast_from, cast_to) \ + inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \ + { \ + __m512i t0 = cast_from(_mm512_unpacklo_##suffix(a0.val, a1.val)); \ + __m512i t1 = cast_from(_mm512_unpacklo_##suffix(a2.val, a3.val)); \ + __m512i t2 = cast_from(_mm512_unpackhi_##suffix(a0.val, a1.val)); \ + __m512i t3 = cast_from(_mm512_unpackhi_##suffix(a2.val, a3.val)); \ + b0.val = cast_to(_mm512_unpacklo_epi64(t0, t1)); \ + b1.val = cast_to(_mm512_unpackhi_epi64(t0, t1)); \ + b2.val = cast_to(_mm512_unpacklo_epi64(t2, t3)); \ + b3.val = cast_to(_mm512_unpackhi_epi64(t2, t3)); \ + } + +OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(v_uint32x16, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(v_int32x16, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_AVX512_TRANSPOSE4x4(v_float32x16, ps, _mm512_castps_si512, _mm512_castsi512_ps) + +//////////////// Value reordering /////////////// + +/* Expand */ +#define OPENCV_HAL_IMPL_AVX512_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ + inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ + { \ + b0.val = intrin(_v512_extract_low(a.val)); \ + b1.val = intrin(_v512_extract_high(a.val)); \ + } \ + inline _Tpwvec v_expand_low(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v512_extract_low(a.val))); } \ + inline _Tpwvec v_expand_high(const _Tpvec& a) \ + { return _Tpwvec(intrin(_v512_extract_high(a.val))); } \ + inline _Tpwvec v512_load_expand(const _Tp* ptr) \ + { \ + __m256i a = _mm256_loadu_si256((const __m256i*)ptr); \ + return _Tpwvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX512_EXPAND(v_uint8x64, v_uint16x32, uchar, _mm512_cvtepu8_epi16) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_int8x64, v_int16x32, schar, _mm512_cvtepi8_epi16) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_uint16x32, v_uint32x16, ushort, _mm512_cvtepu16_epi32) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_int16x32, v_int32x16, short, _mm512_cvtepi16_epi32) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_uint32x16, v_uint64x8, unsigned, _mm512_cvtepu32_epi64) +OPENCV_HAL_IMPL_AVX512_EXPAND(v_int32x16, v_int64x8, int, _mm512_cvtepi32_epi64) + +#define OPENCV_HAL_IMPL_AVX512_EXPAND_Q(_Tpvec, _Tp, intrin) \ + inline _Tpvec v512_load_expand_q(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadu_si128((const __m128i*)ptr); \ + return _Tpvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_AVX512_EXPAND_Q(v_uint32x16, uchar, _mm512_cvtepu8_epi32) +OPENCV_HAL_IMPL_AVX512_EXPAND_Q(v_int32x16, schar, _mm512_cvtepi8_epi32) + +/* pack */ +// 16 +inline v_int8x64 v_pack(const v_int16x32& a, const v_int16x32& b) +{ return v_int8x64(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packs_epi16(a.val, b.val))); } + +inline v_uint8x64 v_pack(const v_uint16x32& a, const v_uint16x32& b) +{ + const __m512i t = _mm512_set1_epi16(255); + return v_uint8x64(_v512_combine(_mm512_cvtepi16_epi8(_mm512_min_epu16(a.val, t)), _mm512_cvtepi16_epi8(_mm512_min_epu16(b.val, t)))); +} + +inline v_uint8x64 v_pack_u(const v_int16x32& a, const v_int16x32& b) +{ + return v_uint8x64(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packus_epi16(a.val, b.val))); +} + +inline void v_pack_store(schar* ptr, const v_int16x32& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(uchar* ptr, const v_uint16x32& a) +{ + const __m512i m = _mm512_set1_epi16(255); + _mm256_storeu_si256((__m256i*)ptr, _mm512_cvtepi16_epi8(_mm512_min_epu16(a.val, m))); +} + +inline void v_pack_u_store(uchar* ptr, const v_int16x32& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + +template inline +v_uint8x64 v_rshr_pack(const v_uint16x32& a, const v_uint16x32& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + v_uint16x32 delta = v512_setall_u16((short)(1 << (n-1))); + return v_pack_u(v_reinterpret_as_s16((a + delta) >> n), + v_reinterpret_as_s16((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(uchar* ptr, const v_uint16x32& a) +{ + v_uint16x32 delta = v512_setall_u16((short)(1 << (n-1))); + v_pack_u_store(ptr, v_reinterpret_as_s16((a + delta) >> n)); +} + +template inline +v_uint8x64 v_rshr_pack_u(const v_int16x32& a, const v_int16x32& b) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(uchar* ptr, const v_int16x32& a) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int8x64 v_rshr_pack(const v_int16x32& a, const v_int16x32& b) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(schar* ptr, const v_int16x32& a) +{ + v_int16x32 delta = v512_setall_s16((short)(1 << (n-1))); + v_pack_store(ptr, (a + delta) >> n); +} + +// 32 +inline v_int16x32 v_pack(const v_int32x16& a, const v_int32x16& b) +{ return v_int16x32(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packs_epi32(a.val, b.val))); } + +inline v_uint16x32 v_pack(const v_uint32x16& a, const v_uint32x16& b) +{ + const __m512i m = _mm512_set1_epi32(65535); + return v_uint16x32(_v512_combine(_mm512_cvtepi32_epi16(_mm512_min_epu32(a.val, m)), _mm512_cvtepi32_epi16(_mm512_min_epu32(b.val, m)))); +} + +inline v_uint16x32 v_pack_u(const v_int32x16& a, const v_int32x16& b) +{ return v_uint16x32(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packus_epi32(a.val, b.val))); } + +inline void v_pack_store(short* ptr, const v_int32x16& a) +{ v_store_low(ptr, v_pack(a, a)); } + +inline void v_pack_store(ushort* ptr, const v_uint32x16& a) +{ + const __m512i m = _mm512_set1_epi32(65535); + _mm256_storeu_si256((__m256i*)ptr, _mm512_cvtepi32_epi16(_mm512_min_epu32(a.val, m))); +} + +inline void v_pack_u_store(ushort* ptr, const v_int32x16& a) +{ v_store_low(ptr, v_pack_u(a, a)); } + + +template inline +v_uint16x32 v_rshr_pack(const v_uint32x16& a, const v_uint32x16& b) +{ + v_uint32x16 delta = v512_setall_u32(1 << (n-1)); + return v_pack_u(v_reinterpret_as_s32((a + delta) >> n), + v_reinterpret_as_s32((b + delta) >> n)); +} + +template inline +void v_rshr_pack_store(ushort* ptr, const v_uint32x16& a) +{ + v_uint32x16 delta = v512_setall_u32(1 << (n-1)); + v_pack_u_store(ptr, v_reinterpret_as_s32((a + delta) >> n)); +} + +template inline +v_uint16x32 v_rshr_pack_u(const v_int32x16& a, const v_int32x16& b) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + return v_pack_u((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_u_store(ushort* ptr, const v_int32x16& a) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + v_pack_u_store(ptr, (a + delta) >> n); +} + +template inline +v_int16x32 v_rshr_pack(const v_int32x16& a, const v_int32x16& b) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(short* ptr, const v_int32x16& a) +{ + v_int32x16 delta = v512_setall_s32(1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// 64 +// Non-saturating pack +inline v_uint32x16 v_pack(const v_uint64x8& a, const v_uint64x8& b) +{ return v_uint32x16(_v512_combine(_mm512_cvtepi64_epi32(a.val), _mm512_cvtepi64_epi32(b.val))); } + +inline v_int32x16 v_pack(const v_int64x8& a, const v_int64x8& b) +{ return v_reinterpret_as_s32(v_pack(v_reinterpret_as_u64(a), v_reinterpret_as_u64(b))); } + +inline void v_pack_store(unsigned* ptr, const v_uint64x8& a) +{ _mm256_storeu_si256((__m256i*)ptr, _mm512_cvtepi64_epi32(a.val)); } + +inline void v_pack_store(int* ptr, const v_int64x8& b) +{ v_pack_store((unsigned*)ptr, v_reinterpret_as_u64(b)); } + +template inline +v_uint32x16 v_rshr_pack(const v_uint64x8& a, const v_uint64x8& b) +{ + v_uint64x8 delta = v512_setall_u64((uint64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(unsigned* ptr, const v_uint64x8& a) +{ + v_uint64x8 delta = v512_setall_u64((uint64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +template inline +v_int32x16 v_rshr_pack(const v_int64x8& a, const v_int64x8& b) +{ + v_int64x8 delta = v512_setall_s64((int64)1 << (n-1)); + return v_pack((a + delta) >> n, (b + delta) >> n); +} + +template inline +void v_rshr_pack_store(int* ptr, const v_int64x8& a) +{ + v_int64x8 delta = v512_setall_s64((int64)1 << (n-1)); + v_pack_store(ptr, (a + delta) >> n); +} + +// pack boolean +inline v_uint8x64 v_pack_b(const v_uint16x32& a, const v_uint16x32& b) +{ return v_uint8x64(_mm512_permutexvar_epi64(_v512_set_epu64(7, 5, 3, 1, 6, 4, 2, 0), _mm512_packs_epi16(a.val, b.val))); } + +inline v_uint8x64 v_pack_b(const v_uint32x16& a, const v_uint32x16& b, + const v_uint32x16& c, const v_uint32x16& d) +{ + __m512i ab = _mm512_packs_epi32(a.val, b.val); + __m512i cd = _mm512_packs_epi32(c.val, d.val); + + return v_uint8x64(_mm512_permutexvar_epi32(_v512_set_epu32(15, 11, 7, 3, 14, 10, 6, 2, 13, 9, 5, 1, 12, 8, 4, 0), _mm512_packs_epi16(ab, cd))); +} + +inline v_uint8x64 v_pack_b(const v_uint64x8& a, const v_uint64x8& b, const v_uint64x8& c, + const v_uint64x8& d, const v_uint64x8& e, const v_uint64x8& f, + const v_uint64x8& g, const v_uint64x8& h) +{ + __m512i ab = _mm512_packs_epi32(a.val, b.val); + __m512i cd = _mm512_packs_epi32(c.val, d.val); + __m512i ef = _mm512_packs_epi32(e.val, f.val); + __m512i gh = _mm512_packs_epi32(g.val, h.val); + + __m512i abcd = _mm512_packs_epi32(ab, cd); + __m512i efgh = _mm512_packs_epi32(ef, gh); + + return v_uint8x64(_mm512_permutexvar_epi16(_v512_set_epu16(31, 23, 15, 7, 30, 22, 14, 6, 29, 21, 13, 5, 28, 20, 12, 4, + 27, 19, 11, 3, 26, 18, 10, 2, 25, 17, 9, 1, 24, 16, 8, 0), _mm512_packs_epi16(abcd, efgh))); +} + +/* Recombine */ +// its up there with load and store operations + +/* Extract */ +#define OPENCV_HAL_IMPL_AVX512_EXTRACT(_Tpvec) \ + template \ + inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ + { return v_rotate_right(a, b); } + +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint8x64) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int8x64) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint16x32) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int16x32) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint32x16) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int32x16) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_uint64x8) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_int64x8) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_float32x16) +OPENCV_HAL_IMPL_AVX512_EXTRACT(v_float64x8) + +#define OPENCV_HAL_IMPL_AVX512_EXTRACT_N(_Tpvec, _Tp) \ +template inline _Tp v_extract_n(_Tpvec v) { return v_rotate_right(v).get0(); } + +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint8x64, uchar) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int8x64, schar) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint16x32, ushort) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int16x32, short) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint32x16, uint) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int32x16, int) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_uint64x8, uint64) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_int64x8, int64) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_float32x16, float) +OPENCV_HAL_IMPL_AVX512_EXTRACT_N(v_float64x8, double) + +template +inline v_uint32x16 v_broadcast_element(v_uint32x16 a) +{ + static const __m512i perm = _mm512_set1_epi32((char)i); + return v_uint32x16(_mm512_permutexvar_epi32(perm, a.val)); +} + +template +inline v_int32x16 v_broadcast_element(const v_int32x16 &a) +{ return v_reinterpret_as_s32(v_broadcast_element(v_reinterpret_as_u32(a))); } + +template +inline v_float32x16 v_broadcast_element(const v_float32x16 &a) +{ return v_reinterpret_as_f32(v_broadcast_element(v_reinterpret_as_u32(a))); } + + +///////////////////// load deinterleave ///////////////////////////// + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x64& a, v_uint8x64& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8(126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, + 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, + 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu8(127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107, 105, 103, 101, 99, 97, + 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, + 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint8x64(_mm512_permutex2var_epi8(ab0, mask0, ab1)); + b = v_uint8x64(_mm512_permutex2var_epi8(ab0, mask1, ab1)); +#else + __m512i mask0 = _mm512_set4_epi32(0x0f0d0b09, 0x07050301, 0x0e0c0a08, 0x06040200); + __m512i a0b0 = _mm512_shuffle_epi8(ab0, mask0); + __m512i a1b1 = _mm512_shuffle_epi8(ab1, mask0); + __m512i mask1 = _v512_set_epu64(14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask2 = _v512_set_epu64(15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint8x64(_mm512_permutex2var_epi64(a0b0, mask1, a1b1)); + b = v_uint8x64(_mm512_permutex2var_epi64(a0b0, mask2, a1b1)); +#endif +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x32& a, v_uint16x32& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i mask0 = _v512_set_epu16(62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu16(63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint16x32(_mm512_permutex2var_epi16(ab0, mask0, ab1)); + b = v_uint16x32(_mm512_permutex2var_epi16(ab0, mask1, ab1)); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x16& a, v_uint32x16& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i mask0 = _v512_set_epu32(30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu32(31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint32x16(_mm512_permutex2var_epi32(ab0, mask0, ab1)); + b = v_uint32x16(_mm512_permutex2var_epi32(ab0, mask1, ab1)); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x8& a, v_uint64x8& b ) +{ + __m512i ab0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i ab1 = _mm512_loadu_si512((const __m512i*)(ptr + 8)); + __m512i mask0 = _v512_set_epu64(14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu64(15, 13, 11, 9, 7, 5, 3, 1); + a = v_uint64x8(_mm512_permutex2var_epi64(ab0, mask0, ab1)); + b = v_uint64x8(_mm512_permutex2var_epi64(ab0, mask1, ab1)); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x64& a, v_uint8x64& b, v_uint8x64& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 128)); + +#if CV_AVX_512VBMI2 + __m512i mask0 = _v512_set_epu8(126, 123, 120, 117, 114, 111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81, + 78, 75, 72, 69, 66, 63, 60, 57, 54, 51, 48, 45, 42, 39, 36, 33, + 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 62, 59, 56, 53, 50, + 47, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2); + __m512i r0b01 = _mm512_permutex2var_epi8(bgr0, mask0, bgr1); + __m512i b1g12 = _mm512_permutex2var_epi8(bgr1, mask0, bgr2); + __m512i r12b2 = _mm512_permutex2var_epi8(bgr1, + _v512_set_epu8(125, 122, 119, 116, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, + 77, 74, 71, 68, 65, 127, 124, 121, 118, 115, 112, 109, 106, 103, 100, 97, + 94, 91, 88, 85, 82, 79, 76, 73, 70, 67, 64, 61, 58, 55, 52, 49, + 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1), bgr2); + a = v_uint8x64(_mm512_mask_compress_epi8(r12b2, 0xffffffffffe00000, r0b01)); + b = v_uint8x64(_mm512_mask_compress_epi8(b1g12, 0x2492492492492492, bgr0)); + c = v_uint8x64(_mm512_mask_expand_epi8(r0b01, 0xffffffffffe00000, r12b2)); +#elif CV_AVX_512VBMI + __m512i b0g0b1 = _mm512_mask_blend_epi8(0xb6db6db6db6db6db, bgr1, bgr0); + __m512i g1r1g2 = _mm512_mask_blend_epi8(0xb6db6db6db6db6db, bgr2, bgr1); + __m512i r2b2r0 = _mm512_mask_blend_epi8(0xb6db6db6db6db6db, bgr0, bgr2); + a = v_uint8x64(_mm512_permutex2var_epi8(b0g0b1, _v512_set_epu8(125, 122, 119, 116, 113, 110, 107, 104, 101, 98, 95, 92, 89, 86, 83, 80, + 77, 74, 71, 68, 65, 63, 61, 60, 58, 57, 55, 54, 52, 51, 49, 48, + 46, 45, 43, 42, 40, 39, 37, 36, 34, 33, 31, 30, 28, 27, 25, 24, + 23, 21, 20, 18, 17, 15, 14, 12, 11, 9, 8, 6, 5, 3, 2, 0), bgr2)); + b = v_uint8x64(_mm512_permutex2var_epi8(g1r1g2, _v512_set_epu8( 63, 61, 60, 58, 57, 55, 54, 52, 51, 49, 48, 46, 45, 43, 42, 40, + 39, 37, 36, 34, 33, 31, 30, 28, 27, 25, 24, 23, 21, 20, 18, 17, + 15, 14, 12, 11, 9, 8, 6, 5, 3, 2, 0, 126, 123, 120, 117, 114, + 111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81, 78, 75, 72, 69, 66), bgr0)); + c = v_uint8x64(_mm512_permutex2var_epi8(r2b2r0, _v512_set_epu8( 63, 60, 57, 54, 51, 48, 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, + 15, 12, 9, 6, 3, 0, 125, 122, 119, 116, 113, 110, 107, 104, 101, 98, + 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 65, 62, 59, 56, 53, 50, + 47, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2), bgr1)); +#else + __m512i mask0 = _v512_set_epu16(61, 58, 55, 52, 49, 46, 43, 40, 37, 34, 63, 60, 57, 54, 51, 48, + 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0); + __m512i b01g1 = _mm512_permutex2var_epi16(bgr0, mask0, bgr1); + __m512i r12b2 = _mm512_permutex2var_epi16(bgr1, mask0, bgr2); + __m512i g20r0 = _mm512_permutex2var_epi16(bgr2, mask0, bgr0); + + __m512i b0g0 = _mm512_mask_blend_epi32(0xf800, b01g1, r12b2); + __m512i r0b1 = _mm512_permutex2var_epi16(bgr1, _v512_set_epu16(42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 29, 26, 23, 20, 17, + 14, 11, 8, 5, 2, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43), g20r0); + __m512i g1r1 = _mm512_alignr_epi32(r12b2, g20r0, 11); + a = v_uint8x64(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, b0g0, r0b1)); + c = v_uint8x64(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, r0b1, g1r1)); + b = v_uint8x64(_mm512_shuffle_epi8(_mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, g1r1, b0g0), _mm512_set4_epi32(0x0e0f0c0d, 0x0a0b0809, 0x06070405, 0x02030001))); +#endif +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x32& a, v_uint16x32& b, v_uint16x32& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + + __m512i mask0 = _v512_set_epu16(61, 58, 55, 52, 49, 46, 43, 40, 37, 34, 63, 60, 57, 54, 51, 48, + 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0); + __m512i b01g1 = _mm512_permutex2var_epi16(bgr0, mask0, bgr1); + __m512i r12b2 = _mm512_permutex2var_epi16(bgr1, mask0, bgr2); + __m512i g20r0 = _mm512_permutex2var_epi16(bgr2, mask0, bgr0); + + a = v_uint16x32(_mm512_mask_blend_epi32(0xf800, b01g1, r12b2)); + b = v_uint16x32(_mm512_permutex2var_epi16(bgr1, _v512_set_epu16(42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 29, 26, 23, 20, 17, + 14, 11, 8, 5, 2, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43), g20r0)); + c = v_uint16x32(_mm512_alignr_epi32(r12b2, g20r0, 11)); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x16& a, v_uint32x16& b, v_uint32x16& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + + __m512i mask0 = _v512_set_epu32(29, 26, 23, 20, 17, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0); + __m512i b01r1 = _mm512_permutex2var_epi32(bgr0, mask0, bgr1); + __m512i g12b2 = _mm512_permutex2var_epi32(bgr1, mask0, bgr2); + __m512i r20g0 = _mm512_permutex2var_epi32(bgr2, mask0, bgr0); + + a = v_uint32x16(_mm512_mask_blend_epi32(0xf800, b01r1, g12b2)); + b = v_uint32x16(_mm512_alignr_epi32(g12b2, r20g0, 11)); + c = v_uint32x16(_mm512_permutex2var_epi32(bgr1, _v512_set_epu32(21, 20, 19, 18, 17, 16, 13, 10, 7, 4, 1, 26, 25, 24, 23, 22), r20g0)); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x8& a, v_uint64x8& b, v_uint64x8& c ) +{ + __m512i bgr0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgr1 = _mm512_loadu_si512((const __m512i*)(ptr + 8)); + __m512i bgr2 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + + __m512i mask0 = _v512_set_epu64(13, 10, 15, 12, 9, 6, 3, 0); + __m512i b01g1 = _mm512_permutex2var_epi64(bgr0, mask0, bgr1); + __m512i r12b2 = _mm512_permutex2var_epi64(bgr1, mask0, bgr2); + __m512i g20r0 = _mm512_permutex2var_epi64(bgr2, mask0, bgr0); + + a = v_uint64x8(_mm512_mask_blend_epi64(0xc0, b01g1, r12b2)); + c = v_uint64x8(_mm512_alignr_epi64(r12b2, g20r0, 6)); + b = v_uint64x8(_mm512_permutex2var_epi64(bgr1, _v512_set_epu64(10, 9, 8, 5, 2, 13, 12, 11), g20r0)); +} + +inline void v_load_deinterleave( const uchar* ptr, v_uint8x64& a, v_uint8x64& b, v_uint8x64& c, v_uint8x64& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 128)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 192)); + +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8(126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, + 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, + 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu8(127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107, 105, 103, 101, 99, 97, + 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, + 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi8(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi8(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi8(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi8(bgra2, mask1, bgra3); + + a = v_uint8x64(_mm512_permutex2var_epi8(br01, mask0, br23)); + c = v_uint8x64(_mm512_permutex2var_epi8(br01, mask1, br23)); + b = v_uint8x64(_mm512_permutex2var_epi8(ga01, mask0, ga23)); + d = v_uint8x64(_mm512_permutex2var_epi8(ga01, mask1, ga23)); +#else + __m512i mask = _mm512_set4_epi32(0x0f0b0703, 0x0e0a0602, 0x0d090501, 0x0c080400); + __m512i b0g0r0a0 = _mm512_shuffle_epi8(bgra0, mask); + __m512i b1g1r1a1 = _mm512_shuffle_epi8(bgra1, mask); + __m512i b2g2r2a2 = _mm512_shuffle_epi8(bgra2, mask); + __m512i b3g3r3a3 = _mm512_shuffle_epi8(bgra3, mask); + + __m512i mask0 = _v512_set_epu32(30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu32(31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi32(b0g0r0a0, mask0, b1g1r1a1); + __m512i ga01 = _mm512_permutex2var_epi32(b0g0r0a0, mask1, b1g1r1a1); + __m512i br23 = _mm512_permutex2var_epi32(b2g2r2a2, mask0, b3g3r3a3); + __m512i ga23 = _mm512_permutex2var_epi32(b2g2r2a2, mask1, b3g3r3a3); + + a = v_uint8x64(_mm512_permutex2var_epi32(br01, mask0, br23)); + c = v_uint8x64(_mm512_permutex2var_epi32(br01, mask1, br23)); + b = v_uint8x64(_mm512_permutex2var_epi32(ga01, mask0, ga23)); + d = v_uint8x64(_mm512_permutex2var_epi32(ga01, mask1, ga23)); +#endif +} + +inline void v_load_deinterleave( const ushort* ptr, v_uint16x32& a, v_uint16x32& b, v_uint16x32& c, v_uint16x32& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 64)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 96)); + + __m512i mask0 = _v512_set_epu16(62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, + 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu16(63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, + 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi16(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi16(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi16(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi16(bgra2, mask1, bgra3); + + a = v_uint16x32(_mm512_permutex2var_epi16(br01, mask0, br23)); + c = v_uint16x32(_mm512_permutex2var_epi16(br01, mask1, br23)); + b = v_uint16x32(_mm512_permutex2var_epi16(ga01, mask0, ga23)); + d = v_uint16x32(_mm512_permutex2var_epi16(ga01, mask1, ga23)); +} + +inline void v_load_deinterleave( const unsigned* ptr, v_uint32x16& a, v_uint32x16& b, v_uint32x16& c, v_uint32x16& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 32)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 48)); + + __m512i mask0 = _v512_set_epu32(30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu32(31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi32(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi32(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi32(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi32(bgra2, mask1, bgra3); + + a = v_uint32x16(_mm512_permutex2var_epi32(br01, mask0, br23)); + c = v_uint32x16(_mm512_permutex2var_epi32(br01, mask1, br23)); + b = v_uint32x16(_mm512_permutex2var_epi32(ga01, mask0, ga23)); + d = v_uint32x16(_mm512_permutex2var_epi32(ga01, mask1, ga23)); +} + +inline void v_load_deinterleave( const uint64* ptr, v_uint64x8& a, v_uint64x8& b, v_uint64x8& c, v_uint64x8& d ) +{ + __m512i bgra0 = _mm512_loadu_si512((const __m512i*)ptr); + __m512i bgra1 = _mm512_loadu_si512((const __m512i*)(ptr + 8)); + __m512i bgra2 = _mm512_loadu_si512((const __m512i*)(ptr + 16)); + __m512i bgra3 = _mm512_loadu_si512((const __m512i*)(ptr + 24)); + + __m512i mask0 = _v512_set_epu64(14, 12, 10, 8, 6, 4, 2, 0); + __m512i mask1 = _v512_set_epu64(15, 13, 11, 9, 7, 5, 3, 1); + + __m512i br01 = _mm512_permutex2var_epi64(bgra0, mask0, bgra1); + __m512i ga01 = _mm512_permutex2var_epi64(bgra0, mask1, bgra1); + __m512i br23 = _mm512_permutex2var_epi64(bgra2, mask0, bgra3); + __m512i ga23 = _mm512_permutex2var_epi64(bgra2, mask1, bgra3); + + a = v_uint64x8(_mm512_permutex2var_epi64(br01, mask0, br23)); + c = v_uint64x8(_mm512_permutex2var_epi64(br01, mask1, br23)); + b = v_uint64x8(_mm512_permutex2var_epi64(ga01, mask0, ga23)); + d = v_uint64x8(_mm512_permutex2var_epi64(ga01, mask1, ga23)); +} + +///////////////////////////// store interleave ///////////////////////////////////// + +inline void v_store_interleave( uchar* ptr, const v_uint8x64& x, const v_uint8x64& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint8x64 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 64), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 64), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 64), high.val); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x32& x, const v_uint16x32& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint16x32 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 32), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 32), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 32), high.val); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x16& x, const v_uint32x16& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint32x16 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 16), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 16), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 16), high.val); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x8& x, const v_uint64x8& y, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint64x8 low, high; + v_zip(x, y, low, high); + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, low.val); + _mm512_stream_si512((__m512i*)(ptr + 8), high.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, low.val); + _mm512_store_si512((__m512i*)(ptr + 8), high.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, low.val); + _mm512_storeu_si512((__m512i*)(ptr + 8), high.val); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x64& a, const v_uint8x64& b, const v_uint8x64& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ +#if CV_AVX_512VBMI + __m512i mask0 = _v512_set_epu8(127, 84, 20, 126, 83, 19, 125, 82, 18, 124, 81, 17, 123, 80, 16, 122, + 79, 15, 121, 78, 14, 120, 77, 13, 119, 76, 12, 118, 75, 11, 117, 74, + 10, 116, 73, 9, 115, 72, 8, 114, 71, 7, 113, 70, 6, 112, 69, 5, + 111, 68, 4, 110, 67, 3, 109, 66, 2, 108, 65, 1, 107, 64, 0, 106); + __m512i mask1 = _v512_set_epu8( 21, 42, 105, 20, 41, 104, 19, 40, 103, 18, 39, 102, 17, 38, 101, 16, + 37, 100, 15, 36, 99, 14, 35, 98, 13, 34, 97, 12, 33, 96, 11, 32, + 95, 10, 31, 94, 9, 30, 93, 8, 29, 92, 7, 28, 91, 6, 27, 90, + 5, 26, 89, 4, 25, 88, 3, 24, 87, 2, 23, 86, 1, 22, 85, 0); + __m512i mask2 = _v512_set_epu8(106, 127, 63, 105, 126, 62, 104, 125, 61, 103, 124, 60, 102, 123, 59, 101, + 122, 58, 100, 121, 57, 99, 120, 56, 98, 119, 55, 97, 118, 54, 96, 117, + 53, 95, 116, 52, 94, 115, 51, 93, 114, 50, 92, 113, 49, 91, 112, 48, + 90, 111, 47, 89, 110, 46, 88, 109, 45, 87, 108, 44, 86, 107, 43, 85); + __m512i r2g0r0 = _mm512_permutex2var_epi8(b.val, mask0, c.val); + __m512i b0r1b1 = _mm512_permutex2var_epi8(a.val, mask1, c.val); + __m512i g1b2g2 = _mm512_permutex2var_epi8(a.val, mask2, b.val); + + __m512i bgr0 = _mm512_mask_blend_epi8(0x9249249249249249, r2g0r0, b0r1b1); + __m512i bgr1 = _mm512_mask_blend_epi8(0x9249249249249249, b0r1b1, g1b2g2); + __m512i bgr2 = _mm512_mask_blend_epi8(0x9249249249249249, g1b2g2, r2g0r0); +#else + __m512i g1g0 = _mm512_shuffle_epi8(b.val, _mm512_set4_epi32(0x0e0f0c0d, 0x0a0b0809, 0x06070405, 0x02030001)); + __m512i b0g0 = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, a.val, g1g0); + __m512i r0b1 = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, c.val, a.val); + __m512i g1r1 = _mm512_mask_blend_epi8(0xAAAAAAAAAAAAAAAA, g1g0, c.val); + + __m512i mask0 = _v512_set_epu16(42, 10, 31, 41, 9, 30, 40, 8, 29, 39, 7, 28, 38, 6, 27, 37, + 5, 26, 36, 4, 25, 35, 3, 24, 34, 2, 23, 33, 1, 22, 32, 0); + __m512i mask1 = _v512_set_epu16(21, 52, 41, 20, 51, 40, 19, 50, 39, 18, 49, 38, 17, 48, 37, 16, + 47, 36, 15, 46, 35, 14, 45, 34, 13, 44, 33, 12, 43, 32, 11, 42); + __m512i mask2 = _v512_set_epu16(63, 31, 20, 62, 30, 19, 61, 29, 18, 60, 28, 17, 59, 27, 16, 58, + 26, 15, 57, 25, 14, 56, 24, 13, 55, 23, 12, 54, 22, 11, 53, 21); + __m512i b0g0b2 = _mm512_permutex2var_epi16(b0g0, mask0, r0b1); + __m512i r1b1r0 = _mm512_permutex2var_epi16(b0g0, mask1, g1r1); + __m512i g2r2g1 = _mm512_permutex2var_epi16(r0b1, mask2, g1r1); + + __m512i bgr0 = _mm512_mask_blend_epi16(0x24924924, b0g0b2, r1b1r0); + __m512i bgr1 = _mm512_mask_blend_epi16(0x24924924, r1b1r0, g2r2g1); + __m512i bgr2 = _mm512_mask_blend_epi16(0x24924924, g2r2g1, b0g0b2); +#endif + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 64), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 128), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 64), bgr1); + _mm512_store_si512((__m512i*)(ptr + 128), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 128), bgr2); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x32& a, const v_uint16x32& b, const v_uint16x32& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m512i mask0 = _v512_set_epu16(42, 10, 31, 41, 9, 30, 40, 8, 29, 39, 7, 28, 38, 6, 27, 37, + 5, 26, 36, 4, 25, 35, 3, 24, 34, 2, 23, 33, 1, 22, 32, 0); + __m512i mask1 = _v512_set_epu16(21, 52, 41, 20, 51, 40, 19, 50, 39, 18, 49, 38, 17, 48, 37, 16, + 47, 36, 15, 46, 35, 14, 45, 34, 13, 44, 33, 12, 43, 32, 11, 42); + __m512i mask2 = _v512_set_epu16(63, 31, 20, 62, 30, 19, 61, 29, 18, 60, 28, 17, 59, 27, 16, 58, + 26, 15, 57, 25, 14, 56, 24, 13, 55, 23, 12, 54, 22, 11, 53, 21); + __m512i b0g0b2 = _mm512_permutex2var_epi16(a.val, mask0, b.val); + __m512i r1b1r0 = _mm512_permutex2var_epi16(a.val, mask1, c.val); + __m512i g2r2g1 = _mm512_permutex2var_epi16(b.val, mask2, c.val); + + __m512i bgr0 = _mm512_mask_blend_epi16(0x24924924, b0g0b2, r1b1r0); + __m512i bgr1 = _mm512_mask_blend_epi16(0x24924924, r1b1r0, g2r2g1); + __m512i bgr2 = _mm512_mask_blend_epi16(0x24924924, g2r2g1, b0g0b2); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 32), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 64), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 32), bgr1); + _mm512_store_si512((__m512i*)(ptr + 64), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgr2); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x16& a, const v_uint32x16& b, const v_uint32x16& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m512i mask0 = _v512_set_epu32(26, 31, 15, 25, 30, 14, 24, 29, 13, 23, 28, 12, 22, 27, 11, 21); + __m512i mask1 = _v512_set_epu32(31, 10, 25, 30, 9, 24, 29, 8, 23, 28, 7, 22, 27, 6, 21, 26); + __m512i g1b2g2 = _mm512_permutex2var_epi32(a.val, mask0, b.val); + __m512i r2r1b1 = _mm512_permutex2var_epi32(a.val, mask1, c.val); + + __m512i bgr0 = _mm512_mask_expand_epi32(_mm512_mask_expand_epi32(_mm512_maskz_expand_epi32(0x9249, a.val), 0x2492, b.val), 0x4924, c.val); + __m512i bgr1 = _mm512_mask_blend_epi32(0x9249, r2r1b1, g1b2g2); + __m512i bgr2 = _mm512_mask_blend_epi32(0x9249, g1b2g2, r2r1b1); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 16), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 32), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 16), bgr1); + _mm512_store_si512((__m512i*)(ptr + 32), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgr2); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x8& a, const v_uint64x8& b, const v_uint64x8& c, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + __m512i mask0 = _v512_set_epu64( 5, 12, 7, 4, 11, 6, 3, 10); + __m512i mask1 = _v512_set_epu64(15, 7, 4, 14, 6, 3, 13, 5); + __m512i r1b1b2 = _mm512_permutex2var_epi64(a.val, mask0, c.val); + __m512i g2r2g1 = _mm512_permutex2var_epi64(b.val, mask1, c.val); + + __m512i bgr0 = _mm512_mask_expand_epi64(_mm512_mask_expand_epi64(_mm512_maskz_expand_epi64(0x49, a.val), 0x92, b.val), 0x24, c.val); + __m512i bgr1 = _mm512_mask_blend_epi64(0xdb, g2r2g1, r1b1b2); + __m512i bgr2 = _mm512_mask_blend_epi64(0xdb, r1b1b2, g2r2g1); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgr0); + _mm512_stream_si512((__m512i*)(ptr + 8), bgr1); + _mm512_stream_si512((__m512i*)(ptr + 16), bgr2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgr0); + _mm512_store_si512((__m512i*)(ptr + 8), bgr1); + _mm512_store_si512((__m512i*)(ptr + 16), bgr2); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgr0); + _mm512_storeu_si512((__m512i*)(ptr + 8), bgr1); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgr2); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x64& a, const v_uint8x64& b, + const v_uint8x64& c, const v_uint8x64& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint8x64 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint8x64 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 64), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 128), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 192), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 64), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 128), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 192), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 128), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 192), bgra3.val); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x32& a, const v_uint16x32& b, + const v_uint16x32& c, const v_uint16x32& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint16x32 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint16x32 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 32), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 64), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 96), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 32), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 64), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 96), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 64), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 96), bgra3.val); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x16& a, const v_uint32x16& b, + const v_uint32x16& c, const v_uint32x16& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint32x16 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint32x16 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 16), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 32), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 48), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 16), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 32), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 48), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 32), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 48), bgra3.val); + } +} + +inline void v_store_interleave( uint64* ptr, const v_uint64x8& a, const v_uint64x8& b, + const v_uint64x8& c, const v_uint64x8& d, + hal::StoreMode mode=hal::STORE_UNALIGNED ) +{ + v_uint64x8 br01, br23, ga01, ga23; + v_zip(a, c, br01, br23); + v_zip(b, d, ga01, ga23); + v_uint64x8 bgra0, bgra1, bgra2, bgra3; + v_zip(br01, ga01, bgra0, bgra1); + v_zip(br23, ga23, bgra2, bgra3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm512_stream_si512((__m512i*)ptr, bgra0.val); + _mm512_stream_si512((__m512i*)(ptr + 8), bgra1.val); + _mm512_stream_si512((__m512i*)(ptr + 16), bgra2.val); + _mm512_stream_si512((__m512i*)(ptr + 24), bgra3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm512_store_si512((__m512i*)ptr, bgra0.val); + _mm512_store_si512((__m512i*)(ptr + 8), bgra1.val); + _mm512_store_si512((__m512i*)(ptr + 16), bgra2.val); + _mm512_store_si512((__m512i*)(ptr + 24), bgra3.val); + } + else + { + _mm512_storeu_si512((__m512i*)ptr, bgra0.val); + _mm512_storeu_si512((__m512i*)(ptr + 8), bgra1.val); + _mm512_storeu_si512((__m512i*)(ptr + 16), bgra2.val); + _mm512_storeu_si512((__m512i*)(ptr + 24), bgra3.val); + } +} + +#define OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, const _Tpvec0& c0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int8x64, schar, s8, v_uint8x64, uchar, u8) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int16x32, short, s16, v_uint16x32, ushort, u16) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int32x16, int, s32, v_uint32x16, unsigned, u32) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_float32x16, float, f32, v_uint32x16, unsigned, u32) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_int64x8, int64, s64, v_uint64x8, uint64, u64) +OPENCV_HAL_IMPL_AVX512_LOADSTORE_INTERLEAVE(v_float64x8, double, f64, v_uint64x8, uint64, u64) + +////////// Mask and checks ///////// + +/** Mask **/ +inline int64 v_signmask(const v_int8x64& a) { return (int64)_mm512_movepi8_mask(a.val); } +inline int v_signmask(const v_int16x32& a) { return (int)_mm512_cmp_epi16_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline int v_signmask(const v_int32x16& a) { return (int)_mm512_cmp_epi32_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline int v_signmask(const v_int64x8& a) { return (int)_mm512_cmp_epi64_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } + +inline int64 v_signmask(const v_uint8x64& a) { return v_signmask(v_reinterpret_as_s8(a)); } +inline int v_signmask(const v_uint16x32& a) { return v_signmask(v_reinterpret_as_s16(a)); } +inline int v_signmask(const v_uint32x16& a) { return v_signmask(v_reinterpret_as_s32(a)); } +inline int v_signmask(const v_uint64x8& a) { return v_signmask(v_reinterpret_as_s64(a)); } +inline int v_signmask(const v_float32x16& a) { return v_signmask(v_reinterpret_as_s32(a)); } +inline int v_signmask(const v_float64x8& a) { return v_signmask(v_reinterpret_as_s64(a)); } + +/** Checks **/ +inline bool v_check_all(const v_int8x64& a) { return !(bool)_mm512_cmp_epi8_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int8x64& a) { return (bool)_mm512_movepi8_mask(a.val); } +inline bool v_check_all(const v_int16x32& a) { return !(bool)_mm512_cmp_epi16_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int16x32& a) { return (bool)_mm512_cmp_epi16_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline bool v_check_all(const v_int32x16& a) { return !(bool)_mm512_cmp_epi32_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int32x16& a) { return (bool)_mm512_cmp_epi32_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } +inline bool v_check_all(const v_int64x8& a) { return !(bool)_mm512_cmp_epi64_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_NLT); } +inline bool v_check_any(const v_int64x8& a) { return (bool)_mm512_cmp_epi64_mask(a.val, _mm512_setzero_si512(), _MM_CMPINT_LT); } + +inline bool v_check_all(const v_float32x16& a) { return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_float32x16& a) { return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_float64x8& a) { return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_float64x8& a) { return v_check_any(v_reinterpret_as_s64(a)); } +inline bool v_check_all(const v_uint8x64& a) { return v_check_all(v_reinterpret_as_s8(a)); } +inline bool v_check_all(const v_uint16x32& a) { return v_check_all(v_reinterpret_as_s16(a)); } +inline bool v_check_all(const v_uint32x16& a) { return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_uint64x8& a) { return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_uint8x64& a) { return v_check_any(v_reinterpret_as_s8(a)); } +inline bool v_check_any(const v_uint16x32& a) { return v_check_any(v_reinterpret_as_s16(a)); } +inline bool v_check_any(const v_uint32x16& a) { return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_uint64x8& a) { return v_check_any(v_reinterpret_as_s64(a)); } + +inline int v_scan_forward(const v_int8x64& a) +{ + int64 mask = _mm512_movepi8_mask(a.val); + int mask32 = (int)mask; + return mask != 0 ? mask32 != 0 ? trailingZeros32(mask32) : 32 + trailingZeros32((int)(mask >> 32)) : 0; +} +inline int v_scan_forward(const v_uint8x64& a) { return v_scan_forward(v_reinterpret_as_s8(a)); } +inline int v_scan_forward(const v_int16x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))); } +inline int v_scan_forward(const v_uint16x32& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))); } +inline int v_scan_forward(const v_int32x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 2; } +inline int v_scan_forward(const v_uint32x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 2; } +inline int v_scan_forward(const v_float32x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 2; } +inline int v_scan_forward(const v_int64x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 4; } +inline int v_scan_forward(const v_uint64x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 4; } +inline int v_scan_forward(const v_float64x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s16(a))) / 4; } + +inline void v512_cleanup() { _mm256_zeroall(); } + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: + +#endif // OPENCV_HAL_INTRIN_AVX_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_cpp.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_cpp.hpp new file mode 100644 index 0000000..4622214 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_cpp.hpp @@ -0,0 +1,3320 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_INTRIN_CPP_HPP +#define OPENCV_HAL_INTRIN_CPP_HPP + +#include +#include +#include +#include "opencv2/core/saturate.hpp" + +//! @cond IGNORED +#define CV_SIMD128_CPP 1 +#if defined(CV_FORCE_SIMD128_CPP) +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +#endif +#if defined(CV_DOXYGEN) +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +#define CV_SIMD256 1 +#define CV_SIMD256_64F 1 +#define CV_SIMD512 1 +#define CV_SIMD512_64F 1 +#else +#define CV_SIMD256 0 // Explicitly disable SIMD256 and SIMD512 support for scalar intrinsic implementation +#define CV_SIMD512 0 // to avoid warnings during compilation +#endif +//! @endcond + +namespace cv +{ + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN +#endif + +/** @addtogroup core_hal_intrin + +"Universal intrinsics" is a types and functions set intended to simplify vectorization of code on +different platforms. Currently a few different SIMD extensions on different architectures are supported. +128 bit registers of various types support is implemented for a wide range of architectures +including x86(__SSE/SSE2/SSE4.2__), ARM(__NEON__), PowerPC(__VSX__), MIPS(__MSA__). +256 bit long registers are supported on x86(__AVX2__) and 512 bit long registers are supported on x86(__AVX512__). +In case when there is no SIMD extension available during compilation, fallback C++ implementation of intrinsics +will be chosen and code will work as expected although it could be slower. + +### Types + +There are several types representing packed values vector registers, each type is +implemented as a structure based on a one SIMD register. + +- cv::v_uint8 and cv::v_int8: 8-bit integer values (unsigned/signed) - char +- cv::v_uint16 and cv::v_int16: 16-bit integer values (unsigned/signed) - short +- cv::v_uint32 and cv::v_int32: 32-bit integer values (unsigned/signed) - int +- cv::v_uint64 and cv::v_int64: 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32: 32-bit floating point values (signed) - float +- cv::v_float64: 64-bit floating point values (signed) - double + +Exact bit length(and value quantity) of listed types is compile time deduced and depends on architecture SIMD +capabilities chosen as available during compilation of the library. All the types contains __nlanes__ enumeration +to check for exact value quantity of the type. + +In case the exact bit length of the type is important it is possible to use specific fixed length register types. + +There are several types representing 128-bit registers. + +- cv::v_uint8x16 and cv::v_int8x16: sixteen 8-bit integer values (unsigned/signed) - char +- cv::v_uint16x8 and cv::v_int16x8: eight 16-bit integer values (unsigned/signed) - short +- cv::v_uint32x4 and cv::v_int32x4: four 32-bit integer values (unsigned/signed) - int +- cv::v_uint64x2 and cv::v_int64x2: two 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32x4: four 32-bit floating point values (signed) - float +- cv::v_float64x2: two 64-bit floating point values (signed) - double + +There are several types representing 256-bit registers. + +- cv::v_uint8x32 and cv::v_int8x32: thirty two 8-bit integer values (unsigned/signed) - char +- cv::v_uint16x16 and cv::v_int16x16: sixteen 16-bit integer values (unsigned/signed) - short +- cv::v_uint32x8 and cv::v_int32x8: eight 32-bit integer values (unsigned/signed) - int +- cv::v_uint64x4 and cv::v_int64x4: four 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32x8: eight 32-bit floating point values (signed) - float +- cv::v_float64x4: four 64-bit floating point values (signed) - double + +@note +256 bit registers at the moment implemented for AVX2 SIMD extension only, if you want to use this type directly, +don't forget to check the CV_SIMD256 preprocessor definition: +@code +#if CV_SIMD256 +//... +#endif +@endcode + +There are several types representing 512-bit registers. + +- cv::v_uint8x64 and cv::v_int8x64: sixty four 8-bit integer values (unsigned/signed) - char +- cv::v_uint16x32 and cv::v_int16x32: thirty two 16-bit integer values (unsigned/signed) - short +- cv::v_uint32x16 and cv::v_int32x16: sixteen 32-bit integer values (unsigned/signed) - int +- cv::v_uint64x8 and cv::v_int64x8: eight 64-bit integer values (unsigned/signed) - int64 +- cv::v_float32x16: sixteen 32-bit floating point values (signed) - float +- cv::v_float64x8: eight 64-bit floating point values (signed) - double +@note +512 bit registers at the moment implemented for AVX512 SIMD extension only, if you want to use this type directly, +don't forget to check the CV_SIMD512 preprocessor definition. + +@note +cv::v_float64x2 is not implemented in NEON variant, if you want to use this type, don't forget to +check the CV_SIMD128_64F preprocessor definition. + +### Load and store operations + +These operations allow to set contents of the register explicitly or by loading it from some memory +block and to save contents of the register to memory block. + +There are variable size register load operations that provide result of maximum available size +depending on chosen platform capabilities. +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +- Other create methods: +vx_setall_s8, vx_setall_u8, ..., +vx_setzero_u8, vx_setzero_s8, ... +- Memory load operations: +vx_load, vx_load_aligned, vx_load_low, vx_load_halves, +- Memory operations with expansion of values: +vx_load_expand, vx_load_expand_q + +Also there are fixed size register load/store operations. + +For 128 bit registers +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +@ref v_reg::v_reg(_Tp s0, _Tp s1) "from two values", ... +- Other create methods: +@ref v_setall_s8, @ref v_setall_u8, ..., +@ref v_setzero_u8, @ref v_setzero_s8, ... +- Memory load operations: +@ref v_load, @ref v_load_aligned, @ref v_load_low, @ref v_load_halves, +- Memory operations with expansion of values: +@ref v_load_expand, @ref v_load_expand_q + +For 256 bit registers(check CV_SIMD256 preprocessor definition) +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +@ref v_reg::v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3) "from four values", ... +- Other create methods: +@ref v256_setall_s8, @ref v256_setall_u8, ..., +@ref v256_setzero_u8, @ref v256_setzero_s8, ... +- Memory load operations: +@ref v256_load, @ref v256_load_aligned, @ref v256_load_low, @ref v256_load_halves, +- Memory operations with expansion of values: +@ref v256_load_expand, @ref v256_load_expand_q + +For 512 bit registers(check CV_SIMD512 preprocessor definition) +- Constructors: +@ref v_reg::v_reg(const _Tp *ptr) "from memory", +@ref v_reg::v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3, _Tp s4, _Tp s5, _Tp s6, _Tp s7) "from eight values", ... +- Other create methods: +@ref v512_setall_s8, @ref v512_setall_u8, ..., +@ref v512_setzero_u8, @ref v512_setzero_s8, ... +- Memory load operations: +@ref v512_load, @ref v512_load_aligned, @ref v512_load_low, @ref v512_load_halves, +- Memory operations with expansion of values: +@ref v512_load_expand, @ref v512_load_expand_q + +Store to memory operations are similar across different platform capabilities: +@ref v_store, @ref v_store_aligned, +@ref v_store_high, @ref v_store_low + +### Value reordering + +These operations allow to reorder or recombine elements in one or multiple vectors. + +- Interleave, deinterleave (2, 3 and 4 channels): @ref v_load_deinterleave, @ref v_store_interleave +- Expand: @ref v_expand, @ref v_expand_low, @ref v_expand_high +- Pack: @ref v_pack, @ref v_pack_u, @ref v_pack_b, @ref v_rshr_pack, @ref v_rshr_pack_u, +@ref v_pack_store, @ref v_pack_u_store, @ref v_rshr_pack_store, @ref v_rshr_pack_u_store +- Recombine: @ref v_zip, @ref v_recombine, @ref v_combine_low, @ref v_combine_high +- Reverse: @ref v_reverse +- Extract: @ref v_extract + + +### Arithmetic, bitwise and comparison operations + +Element-wise binary and unary operations. + +- Arithmetics: +@ref operator +(const v_reg &a, const v_reg &b) "+", +@ref operator -(const v_reg &a, const v_reg &b) "-", +@ref operator *(const v_reg &a, const v_reg &b) "*", +@ref operator /(const v_reg &a, const v_reg &b) "/", +@ref v_mul_expand + +- Non-saturating arithmetics: @ref v_add_wrap, @ref v_sub_wrap + +- Bitwise shifts: +@ref operator <<(const v_reg &a, int s) "<<", +@ref operator >>(const v_reg &a, int s) ">>", +@ref v_shl, @ref v_shr + +- Bitwise logic: +@ref operator &(const v_reg &a, const v_reg &b) "&", +@ref operator |(const v_reg &a, const v_reg &b) "|", +@ref operator ^(const v_reg &a, const v_reg &b) "^", +@ref operator ~(const v_reg &a) "~" + +- Comparison: +@ref operator >(const v_reg &a, const v_reg &b) ">", +@ref operator >=(const v_reg &a, const v_reg &b) ">=", +@ref operator <(const v_reg &a, const v_reg &b) "<", +@ref operator <=(const v_reg &a, const v_reg &b) "<=", +@ref operator ==(const v_reg &a, const v_reg &b) "==", +@ref operator !=(const v_reg &a, const v_reg &b) "!=" + +- min/max: @ref v_min, @ref v_max + +### Reduce and mask + +Most of these operations return only one value. + +- Reduce: @ref v_reduce_min, @ref v_reduce_max, @ref v_reduce_sum, @ref v_popcount +- Mask: @ref v_signmask, @ref v_check_all, @ref v_check_any, @ref v_select + +### Other math + +- Some frequent operations: @ref v_sqrt, @ref v_invsqrt, @ref v_magnitude, @ref v_sqr_magnitude +- Absolute values: @ref v_abs, @ref v_absdiff, @ref v_absdiffs + +### Conversions + +Different type conversions and casts: + +- Rounding: @ref v_round, @ref v_floor, @ref v_ceil, @ref v_trunc, +- To float: @ref v_cvt_f32, @ref v_cvt_f64 +- Reinterpret: @ref v_reinterpret_as_u8, @ref v_reinterpret_as_s8, ... + +### Matrix operations + +In these operations vectors represent matrix rows/columns: @ref v_dotprod, @ref v_dotprod_fast, +@ref v_dotprod_expand, @ref v_dotprod_expand_fast, @ref v_matmul, @ref v_transpose4x4 + +### Usability + +Most operations are implemented only for some subset of the available types, following matrices +shows the applicability of different operations to the types. + +Regular integers: + +| Operations\\Types | uint 8 | int 8 | uint 16 | int 16 | uint 32 | int 32 | +|-------------------|:-:|:-:|:-:|:-:|:-:|:-:| +|load, store | x | x | x | x | x | x | +|interleave | x | x | x | x | x | x | +|expand | x | x | x | x | x | x | +|expand_low | x | x | x | x | x | x | +|expand_high | x | x | x | x | x | x | +|expand_q | x | x | | | | | +|add, sub | x | x | x | x | x | x | +|add_wrap, sub_wrap | x | x | x | x | | | +|mul_wrap | x | x | x | x | | | +|mul | x | x | x | x | x | x | +|mul_expand | x | x | x | x | x | | +|compare | x | x | x | x | x | x | +|shift | | | x | x | x | x | +|dotprod | | | | x | | x | +|dotprod_fast | | | | x | | x | +|dotprod_expand | x | x | x | x | | x | +|dotprod_expand_fast| x | x | x | x | | x | +|logical | x | x | x | x | x | x | +|min, max | x | x | x | x | x | x | +|absdiff | x | x | x | x | x | x | +|absdiffs | | x | | x | | | +|reduce | x | x | x | x | x | x | +|mask | x | x | x | x | x | x | +|pack | x | x | x | x | x | x | +|pack_u | x | | x | | | | +|pack_b | x | | | | | | +|unpack | x | x | x | x | x | x | +|extract | x | x | x | x | x | x | +|rotate (lanes) | x | x | x | x | x | x | +|cvt_flt32 | | | | | | x | +|cvt_flt64 | | | | | | x | +|transpose4x4 | | | | | x | x | +|reverse | x | x | x | x | x | x | +|extract_n | x | x | x | x | x | x | +|broadcast_element | | | | | x | x | + +Big integers: + +| Operations\\Types | uint 64 | int 64 | +|-------------------|:-:|:-:| +|load, store | x | x | +|add, sub | x | x | +|shift | x | x | +|logical | x | x | +|reverse | x | x | +|extract | x | x | +|rotate (lanes) | x | x | +|cvt_flt64 | | x | +|extract_n | x | x | + +Floating point: + +| Operations\\Types | float 32 | float 64 | +|-------------------|:-:|:-:| +|load, store | x | x | +|interleave | x | | +|add, sub | x | x | +|mul | x | x | +|div | x | x | +|compare | x | x | +|min, max | x | x | +|absdiff | x | x | +|reduce | x | | +|mask | x | x | +|unpack | x | x | +|cvt_flt32 | | x | +|cvt_flt64 | x | | +|sqrt, abs | x | x | +|float math | x | x | +|transpose4x4 | x | | +|extract | x | x | +|rotate (lanes) | x | x | +|reverse | x | x | +|extract_n | x | x | +|broadcast_element | x | | + + @{ */ + +template struct v_reg +{ +//! @cond IGNORED + typedef _Tp lane_type; + enum { nlanes = n }; +// !@endcond + + /** @brief Constructor + + Initializes register with data from memory + @param ptr pointer to memory block with data for register */ + explicit v_reg(const _Tp* ptr) { for( int i = 0; i < n; i++ ) s[i] = ptr[i]; } + + /** @brief Constructor + + Initializes register with two 64-bit values */ + v_reg(_Tp s0, _Tp s1) { s[0] = s0; s[1] = s1; } + + /** @brief Constructor + + Initializes register with four 32-bit values */ + v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3) { s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; } + + /** @brief Constructor + + Initializes register with eight 16-bit values */ + v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3, + _Tp s4, _Tp s5, _Tp s6, _Tp s7) + { + s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; + s[4] = s4; s[5] = s5; s[6] = s6; s[7] = s7; + } + + /** @brief Constructor + + Initializes register with sixteen 8-bit values */ + v_reg(_Tp s0, _Tp s1, _Tp s2, _Tp s3, + _Tp s4, _Tp s5, _Tp s6, _Tp s7, + _Tp s8, _Tp s9, _Tp s10, _Tp s11, + _Tp s12, _Tp s13, _Tp s14, _Tp s15) + { + s[0] = s0; s[1] = s1; s[2] = s2; s[3] = s3; + s[4] = s4; s[5] = s5; s[6] = s6; s[7] = s7; + s[8] = s8; s[9] = s9; s[10] = s10; s[11] = s11; + s[12] = s12; s[13] = s13; s[14] = s14; s[15] = s15; + } + + /** @brief Default constructor + + Does not initialize anything*/ + v_reg() {} + + /** @brief Copy constructor */ + v_reg(const v_reg<_Tp, n> & r) + { + for( int i = 0; i < n; i++ ) + s[i] = r.s[i]; + } + /** @brief Access first value + + Returns value of the first lane according to register type, for example: + @code{.cpp} + v_int32x4 r(1, 2, 3, 4); + int v = r.get0(); // returns 1 + v_uint64x2 r(1, 2); + uint64_t v = r.get0(); // returns 1 + @endcode + */ + _Tp get0() const { return s[0]; } + +//! @cond IGNORED + _Tp get(const int i) const { return s[i]; } + v_reg<_Tp, n> high() const + { + v_reg<_Tp, n> c; + int i; + for( i = 0; i < n/2; i++ ) + { + c.s[i] = s[i+(n/2)]; + c.s[i+(n/2)] = 0; + } + return c; + } + + static v_reg<_Tp, n> zero() + { + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = (_Tp)0; + return c; + } + + static v_reg<_Tp, n> all(_Tp s) + { + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = s; + return c; + } + + template v_reg<_Tp2, n2> reinterpret_as() const + { + size_t bytes = std::min(sizeof(_Tp2)*n2, sizeof(_Tp)*n); + v_reg<_Tp2, n2> c; + std::memcpy(&c.s[0], &s[0], bytes); + return c; + } + + v_reg& operator=(const v_reg<_Tp, n> & r) + { + for( int i = 0; i < n; i++ ) + s[i] = r.s[i]; + return *this; + } + + _Tp s[n]; +//! @endcond +}; + +/** @brief Sixteen 8-bit unsigned integer values */ +typedef v_reg v_uint8x16; +/** @brief Sixteen 8-bit signed integer values */ +typedef v_reg v_int8x16; +/** @brief Eight 16-bit unsigned integer values */ +typedef v_reg v_uint16x8; +/** @brief Eight 16-bit signed integer values */ +typedef v_reg v_int16x8; +/** @brief Four 32-bit unsigned integer values */ +typedef v_reg v_uint32x4; +/** @brief Four 32-bit signed integer values */ +typedef v_reg v_int32x4; +/** @brief Four 32-bit floating point values (single precision) */ +typedef v_reg v_float32x4; +/** @brief Two 64-bit floating point values (double precision) */ +typedef v_reg v_float64x2; +/** @brief Two 64-bit unsigned integer values */ +typedef v_reg v_uint64x2; +/** @brief Two 64-bit signed integer values */ +typedef v_reg v_int64x2; + +#if CV_SIMD256 +/** @brief Thirty two 8-bit unsigned integer values */ +typedef v_reg v_uint8x32; +/** @brief Thirty two 8-bit signed integer values */ +typedef v_reg v_int8x32; +/** @brief Sixteen 16-bit unsigned integer values */ +typedef v_reg v_uint16x16; +/** @brief Sixteen 16-bit signed integer values */ +typedef v_reg v_int16x16; +/** @brief Eight 32-bit unsigned integer values */ +typedef v_reg v_uint32x8; +/** @brief Eight 32-bit signed integer values */ +typedef v_reg v_int32x8; +/** @brief Eight 32-bit floating point values (single precision) */ +typedef v_reg v_float32x8; +/** @brief Four 64-bit floating point values (double precision) */ +typedef v_reg v_float64x4; +/** @brief Four 64-bit unsigned integer values */ +typedef v_reg v_uint64x4; +/** @brief Four 64-bit signed integer values */ +typedef v_reg v_int64x4; +#endif + +#if CV_SIMD512 +/** @brief Sixty four 8-bit unsigned integer values */ +typedef v_reg v_uint8x64; +/** @brief Sixty four 8-bit signed integer values */ +typedef v_reg v_int8x64; +/** @brief Thirty two 16-bit unsigned integer values */ +typedef v_reg v_uint16x32; +/** @brief Thirty two 16-bit signed integer values */ +typedef v_reg v_int16x32; +/** @brief Sixteen 32-bit unsigned integer values */ +typedef v_reg v_uint32x16; +/** @brief Sixteen 32-bit signed integer values */ +typedef v_reg v_int32x16; +/** @brief Sixteen 32-bit floating point values (single precision) */ +typedef v_reg v_float32x16; +/** @brief Eight 64-bit floating point values (double precision) */ +typedef v_reg v_float64x8; +/** @brief Eight 64-bit unsigned integer values */ +typedef v_reg v_uint64x8; +/** @brief Eight 64-bit signed integer values */ +typedef v_reg v_int64x8; +#endif + +enum { + simd128_width = 16, +#if CV_SIMD256 + simd256_width = 32, +#endif +#if CV_SIMD512 + simd512_width = 64, + simdmax_width = simd512_width +#elif CV_SIMD256 + simdmax_width = simd256_width +#else + simdmax_width = simd128_width +#endif +}; + +/** @brief Add values + +For all types. */ +template CV_INLINE v_reg<_Tp, n> operator+(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator+=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Subtract values + +For all types. */ +template CV_INLINE v_reg<_Tp, n> operator-(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator-=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Multiply values + +For 16- and 32-bit integer types and floating types. */ +template CV_INLINE v_reg<_Tp, n> operator*(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator*=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Divide values + +For floating types only. */ +template CV_INLINE v_reg<_Tp, n> operator/(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator/=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + + +/** @brief Bitwise AND + +Only for integer types. */ +template CV_INLINE v_reg<_Tp, n> operator&(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator&=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Bitwise OR + +Only for integer types. */ +template CV_INLINE v_reg<_Tp, n> operator|(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator|=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Bitwise XOR + +Only for integer types.*/ +template CV_INLINE v_reg<_Tp, n> operator^(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); +template CV_INLINE v_reg<_Tp, n>& operator^=(v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); + +/** @brief Bitwise NOT + +Only for integer types.*/ +template CV_INLINE v_reg<_Tp, n> operator~(const v_reg<_Tp, n>& a); + + +#ifndef CV_DOXYGEN + +#define CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(macro_name, ...) \ +__CV_EXPAND(macro_name(uchar, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(schar, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(ushort, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(short, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(unsigned, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(int, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(uint64, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(int64, __VA_ARGS__)) \ + +#define CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(macro_name, ...) \ +__CV_EXPAND(macro_name(float, __VA_ARGS__)) \ +__CV_EXPAND(macro_name(double, __VA_ARGS__)) \ + +#define CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES(macro_name, ...) \ +CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(macro_name, __VA_ARGS__) \ +CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(macro_name, __VA_ARGS__) \ + +#define CV__HAL_INTRIN_IMPL_BIN_OP_(_Tp, bin_op) \ +template inline \ +v_reg<_Tp, n> operator bin_op (const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = saturate_cast<_Tp>(a.s[i] bin_op b.s[i]); \ + return c; \ +} \ +template inline \ +v_reg<_Tp, n>& operator bin_op##= (v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + for( int i = 0; i < n; i++ ) \ + a.s[i] = saturate_cast<_Tp>(a.s[i] bin_op b.s[i]); \ + return a; \ +} + +#define CV__HAL_INTRIN_IMPL_BIN_OP(bin_op) CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES(CV__HAL_INTRIN_IMPL_BIN_OP_, bin_op) + +CV__HAL_INTRIN_IMPL_BIN_OP(+) +CV__HAL_INTRIN_IMPL_BIN_OP(-) +CV__HAL_INTRIN_IMPL_BIN_OP(*) +CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(CV__HAL_INTRIN_IMPL_BIN_OP_, /) + +#define CV__HAL_INTRIN_IMPL_BIT_OP_(_Tp, bit_op) \ +template CV_INLINE \ +v_reg<_Tp, n> operator bit_op (const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + typedef typename V_TypeTraits<_Tp>::int_type itype; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int((itype)(V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) bit_op \ + V_TypeTraits<_Tp>::reinterpret_int(b.s[i]))); \ + return c; \ +} \ +template CV_INLINE \ +v_reg<_Tp, n>& operator bit_op##= (v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + typedef typename V_TypeTraits<_Tp>::int_type itype; \ + for( int i = 0; i < n; i++ ) \ + a.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int((itype)(V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) bit_op \ + V_TypeTraits<_Tp>::reinterpret_int(b.s[i]))); \ + return a; \ +} + +#define CV__HAL_INTRIN_IMPL_BIT_OP(bit_op) \ +CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(CV__HAL_INTRIN_IMPL_BIT_OP_, bit_op) \ +CV__HAL_INTRIN_EXPAND_WITH_FP_TYPES(CV__HAL_INTRIN_IMPL_BIT_OP_, bit_op) /* TODO: FIXIT remove this after masks refactoring */ + + +CV__HAL_INTRIN_IMPL_BIT_OP(&) +CV__HAL_INTRIN_IMPL_BIT_OP(|) +CV__HAL_INTRIN_IMPL_BIT_OP(^) + +#define CV__HAL_INTRIN_IMPL_BITWISE_NOT_(_Tp, dummy) \ +template CV_INLINE \ +v_reg<_Tp, n> operator ~ (const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int(~V_TypeTraits<_Tp>::reinterpret_int(a.s[i])); \ + return c; \ +} \ + +CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(CV__HAL_INTRIN_IMPL_BITWISE_NOT_, ~) + +#endif // !CV_DOXYGEN + + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_MATH_FUNC(func, cfunc, _Tp2) \ +template inline v_reg<_Tp2, n> func(const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp2, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = cfunc(a.s[i]); \ + return c; \ +} + +/** @brief Square root of elements + +Only for floating point types.*/ +OPENCV_HAL_IMPL_MATH_FUNC(v_sqrt, std::sqrt, _Tp) + +//! @cond IGNORED +OPENCV_HAL_IMPL_MATH_FUNC(v_sin, std::sin, _Tp) +OPENCV_HAL_IMPL_MATH_FUNC(v_cos, std::cos, _Tp) +OPENCV_HAL_IMPL_MATH_FUNC(v_exp, std::exp, _Tp) +OPENCV_HAL_IMPL_MATH_FUNC(v_log, std::log, _Tp) +//! @endcond + +/** @brief Absolute value of elements + +Only for floating point types.*/ +OPENCV_HAL_IMPL_MATH_FUNC(v_abs, (typename V_TypeTraits<_Tp>::abs_type)std::abs, + typename V_TypeTraits<_Tp>::abs_type) + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_MINMAX_FUNC(func, cfunc) \ +template inline v_reg<_Tp, n> func(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = cfunc(a.s[i], b.s[i]); \ + return c; \ +} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(func, cfunc) \ +template inline _Tp func(const v_reg<_Tp, n>& a) \ +{ \ + _Tp c = a.s[0]; \ + for( int i = 1; i < n; i++ ) \ + c = cfunc(c, a.s[i]); \ + return c; \ +} + +/** @brief Choose min values for each pair + +Scheme: +@code +{A1 A2 ...} +{B1 B2 ...} +-------------- +{min(A1,B1) min(A2,B2) ...} +@endcode +For all types except 64-bit integer. */ +OPENCV_HAL_IMPL_MINMAX_FUNC(v_min, std::min) + +/** @brief Choose max values for each pair + +Scheme: +@code +{A1 A2 ...} +{B1 B2 ...} +-------------- +{max(A1,B1) max(A2,B2) ...} +@endcode +For all types except 64-bit integer. */ +OPENCV_HAL_IMPL_MINMAX_FUNC(v_max, std::max) + +/** @brief Find one min value + +Scheme: +@code +{A1 A2 A3 ...} => min(A1,A2,A3,...) +@endcode +For all types except 64-bit integer and 64-bit floating point types. */ +OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(v_reduce_min, std::min) + +/** @brief Find one max value + +Scheme: +@code +{A1 A2 A3 ...} => max(A1,A2,A3,...) +@endcode +For all types except 64-bit integer and 64-bit floating point types. */ +OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(v_reduce_max, std::max) + +static const unsigned char popCountTable[] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; +/** @brief Count the 1 bits in the vector lanes and return result as corresponding unsigned type + +Scheme: +@code +{A1 A2 A3 ...} => {popcount(A1), popcount(A2), popcount(A3), ...} +@endcode +For all integer types. */ +template +inline v_reg::abs_type, n> v_popcount(const v_reg<_Tp, n>& a) +{ + v_reg::abs_type, n> b = v_reg::abs_type, n>::zero(); + for (int i = 0; i < n*(int)sizeof(_Tp); i++) + b.s[i/sizeof(_Tp)] += popCountTable[v_reinterpret_as_u8(a).s[i]]; + return b; +} + + +//! @cond IGNORED +template +inline void v_minmax( const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + v_reg<_Tp, n>& minval, v_reg<_Tp, n>& maxval ) +{ + for( int i = 0; i < n; i++ ) + { + minval.s[i] = std::min(a.s[i], b.s[i]); + maxval.s[i] = std::max(a.s[i], b.s[i]); + } +} +//! @endcond + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_CMP_OP(cmp_op) \ +template \ +inline v_reg<_Tp, n> operator cmp_op(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + typedef typename V_TypeTraits<_Tp>::int_type itype; \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = V_TypeTraits<_Tp>::reinterpret_from_int((itype)-(int)(a.s[i] cmp_op b.s[i])); \ + return c; \ +} + +/** @brief Less-than comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(<) + +/** @brief Greater-than comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(>) + +/** @brief Less-than or equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(<=) + +/** @brief Greater-than or equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(>=) + +/** @brief Equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(==) + +/** @brief Not equal comparison + +For all types except 64-bit integer values. */ +OPENCV_HAL_IMPL_CMP_OP(!=) + +template +inline v_reg v_not_nan(const v_reg& a) +{ + typedef typename V_TypeTraits::int_type itype; + v_reg c; + for (int i = 0; i < n; i++) + c.s[i] = V_TypeTraits::reinterpret_from_int((itype)-(int)(a.s[i] == a.s[i])); + return c; +} +template +inline v_reg v_not_nan(const v_reg& a) +{ + typedef typename V_TypeTraits::int_type itype; + v_reg c; + for (int i = 0; i < n; i++) + c.s[i] = V_TypeTraits::reinterpret_from_int((itype)-(int)(a.s[i] == a.s[i])); + return c; +} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_ARITHM_OP(func, bin_op, cast_op, _Tp2) \ +template \ +inline v_reg<_Tp2, n> func(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + typedef _Tp2 rtype; \ + v_reg c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = cast_op(a.s[i] bin_op b.s[i]); \ + return c; \ +} + +/** @brief Add values without saturation + +For 8- and 16-bit integer values. */ +OPENCV_HAL_IMPL_ARITHM_OP(v_add_wrap, +, (_Tp), _Tp) + +/** @brief Subtract values without saturation + +For 8- and 16-bit integer values. */ +OPENCV_HAL_IMPL_ARITHM_OP(v_sub_wrap, -, (_Tp), _Tp) + +/** @brief Multiply values without saturation + +For 8- and 16-bit integer values. */ +OPENCV_HAL_IMPL_ARITHM_OP(v_mul_wrap, *, (_Tp), _Tp) + +//! @cond IGNORED +template inline T _absdiff(T a, T b) +{ + return a > b ? a - b : b - a; +} +//! @endcond + +/** @brief Absolute difference + +Returns \f$ |a - b| \f$ converted to corresponding unsigned type. +Example: +@code{.cpp} +v_int32x4 a, b; // {1, 2, 3, 4} and {4, 3, 2, 1} +v_uint32x4 c = v_absdiff(a, b); // result is {3, 1, 1, 3} +@endcode +For 8-, 16-, 32-bit integer source types. */ +template +inline v_reg::abs_type, n> v_absdiff(const v_reg<_Tp, n>& a, const v_reg<_Tp, n> & b) +{ + typedef typename V_TypeTraits<_Tp>::abs_type rtype; + v_reg c; + const rtype mask = (rtype)(std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0); + for( int i = 0; i < n; i++ ) + { + rtype ua = a.s[i] ^ mask; + rtype ub = b.s[i] ^ mask; + c.s[i] = _absdiff(ua, ub); + } + return c; +} + +/** @overload + +For 32-bit floating point values */ +template inline v_reg v_absdiff(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + c.s[i] = _absdiff(a.s[i], b.s[i]); + return c; +} + +/** @overload + +For 64-bit floating point values */ +template inline v_reg v_absdiff(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + c.s[i] = _absdiff(a.s[i], b.s[i]); + return c; +} + +/** @brief Saturating absolute difference + +Returns \f$ saturate(|a - b|) \f$ . +For 8-, 16-bit signed integer source types. */ +template +inline v_reg<_Tp, n> v_absdiffs(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++) + c.s[i] = saturate_cast<_Tp>(std::abs(a.s[i] - b.s[i])); + return c; +} + +/** @brief Inversed square root + +Returns \f$ 1/sqrt(a) \f$ +For floating point types only. */ +template +inline v_reg<_Tp, n> v_invsqrt(const v_reg<_Tp, n>& a) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = 1.f/std::sqrt(a.s[i]); + return c; +} + +/** @brief Magnitude + +Returns \f$ sqrt(a^2 + b^2) \f$ +For floating point types only. */ +template +inline v_reg<_Tp, n> v_magnitude(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = std::sqrt(a.s[i]*a.s[i] + b.s[i]*b.s[i]); + return c; +} + +/** @brief Square of the magnitude + +Returns \f$ a^2 + b^2 \f$ +For floating point types only. */ +template +inline v_reg<_Tp, n> v_sqr_magnitude(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = a.s[i]*a.s[i] + b.s[i]*b.s[i]; + return c; +} + +/** @brief Multiply and add + + Returns \f$ a*b + c \f$ + For floating point types and signed 32bit int only. */ +template +inline v_reg<_Tp, n> v_fma(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg<_Tp, n>& c) +{ + v_reg<_Tp, n> d; + for( int i = 0; i < n; i++ ) + d.s[i] = a.s[i]*b.s[i] + c.s[i]; + return d; +} + +/** @brief A synonym for v_fma */ +template +inline v_reg<_Tp, n> v_muladd(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg<_Tp, n>& c) +{ + return v_fma(a, b, c); +} + +/** @brief Dot product of elements + +Multiply values in two registers and sum adjacent result pairs. + +Scheme: +@code + {A1 A2 ...} // 16-bit +x {B1 B2 ...} // 16-bit +------------- +{A1B1+A2B2 ...} // 32-bit + +@endcode +*/ +template inline v_reg::w_type, n/2> +v_dotprod(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (w_type)a.s[i*2]*b.s[i*2] + (w_type)a.s[i*2+1]*b.s[i*2+1]; + return c; +} + +/** @brief Dot product of elements + +Same as cv::v_dotprod, but add a third element to the sum of adjacent pairs. +Scheme: +@code + {A1 A2 ...} // 16-bit +x {B1 B2 ...} // 16-bit +------------- + {A1B1+A2B2+C1 ...} // 32-bit +@endcode +*/ +template inline v_reg::w_type, n/2> +v_dotprod(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::w_type, n / 2>& c) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg s; + for( int i = 0; i < (n/2); i++ ) + s.s[i] = (w_type)a.s[i*2]*b.s[i*2] + (w_type)a.s[i*2+1]*b.s[i*2+1] + c.s[i]; + return s; +} + +/** @brief Fast Dot product of elements + +Same as cv::v_dotprod, but it may perform unorder sum between result pairs in some platforms, +this intrinsic can be used if the sum among all lanes is only matters +and also it should be yielding better performance on the affected platforms. + +*/ +template inline v_reg::w_type, n/2> +v_dotprod_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ return v_dotprod(a, b); } + +/** @brief Fast Dot product of elements + +Same as cv::v_dotprod_fast, but add a third element to the sum of adjacent pairs. +*/ +template inline v_reg::w_type, n/2> +v_dotprod_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::w_type, n / 2>& c) +{ return v_dotprod(a, b, c); } + +/** @brief Dot product of elements and expand + +Multiply values in two registers and expand the sum of adjacent result pairs. + +Scheme: +@code + {A1 A2 A3 A4 ...} // 8-bit +x {B1 B2 B3 B4 ...} // 8-bit +------------- + {A1B1+A2B2+A3B3+A4B4 ...} // 32-bit + +@endcode +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg s; + for( int i = 0; i < (n/4); i++ ) + s.s[i] = (q_type)a.s[i*4 ]*b.s[i*4 ] + (q_type)a.s[i*4 + 1]*b.s[i*4 + 1] + + (q_type)a.s[i*4 + 2]*b.s[i*4 + 2] + (q_type)a.s[i*4 + 3]*b.s[i*4 + 3]; + return s; +} + +/** @brief Dot product of elements + +Same as cv::v_dotprod_expand, but add a third element to the sum of adjacent pairs. +Scheme: +@code + {A1 A2 A3 A4 ...} // 8-bit +x {B1 B2 B3 B4 ...} // 8-bit +------------- + {A1B1+A2B2+A3B3+A4B4+C1 ...} // 32-bit +@endcode +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::q_type, n / 4>& c) +{ + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg s; + for( int i = 0; i < (n/4); i++ ) + s.s[i] = (q_type)a.s[i*4 ]*b.s[i*4 ] + (q_type)a.s[i*4 + 1]*b.s[i*4 + 1] + + (q_type)a.s[i*4 + 2]*b.s[i*4 + 2] + (q_type)a.s[i*4 + 3]*b.s[i*4 + 3] + c.s[i]; + return s; +} + +/** @brief Fast Dot product of elements and expand + +Multiply values in two registers and expand the sum of adjacent result pairs. + +Same as cv::v_dotprod_expand, but it may perform unorder sum between result pairs in some platforms, +this intrinsic can be used if the sum among all lanes is only matters +and also it should be yielding better performance on the affected platforms. + +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ return v_dotprod_expand(a, b); } + +/** @brief Fast Dot product of elements + +Same as cv::v_dotprod_expand_fast, but add a third element to the sum of adjacent pairs. +*/ +template inline v_reg::q_type, n/4> +v_dotprod_expand_fast(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + const v_reg::q_type, n / 4>& c) +{ return v_dotprod_expand(a, b, c); } + +/** @brief Multiply and expand + +Multiply values two registers and store results in two registers with wider pack type. +Scheme: +@code + {A B C D} // 32-bit +x {E F G H} // 32-bit +--------------- +{AE BF} // 64-bit + {CG DH} // 64-bit +@endcode +Example: +@code{.cpp} +v_uint32x4 a, b; // {1,2,3,4} and {2,2,2,2} +v_uint64x2 c, d; // results +v_mul_expand(a, b, c, d); // c, d = {2,4}, {6, 8} +@endcode +Implemented only for 16- and unsigned 32-bit source types (v_int16x8, v_uint16x8, v_uint32x4). +*/ +template inline void v_mul_expand(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + v_reg::w_type, n/2>& c, + v_reg::w_type, n/2>& d) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = (w_type)a.s[i]*b.s[i]; + d.s[i] = (w_type)a.s[i+(n/2)]*b.s[i+(n/2)]; + } +} + +/** @brief Multiply and extract high part + +Multiply values two registers and store high part of the results. +Implemented only for 16-bit source types (v_int16x8, v_uint16x8). Returns \f$ a*b >> 16 \f$ +*/ +template inline v_reg<_Tp, n> v_mul_hi(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg<_Tp, n> c; + for (int i = 0; i < n; i++) + c.s[i] = (_Tp)(((w_type)a.s[i] * b.s[i]) >> sizeof(_Tp)*8); + return c; +} + +//! @cond IGNORED +template inline void v_hsum(const v_reg<_Tp, n>& a, + v_reg::w_type, n/2>& c) +{ + typedef typename V_TypeTraits<_Tp>::w_type w_type; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = (w_type)a.s[i*2] + a.s[i*2+1]; + } +} +//! @endcond + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_SHIFT_OP(shift_op) \ +template inline v_reg<_Tp, n> operator shift_op(const v_reg<_Tp, n>& a, int imm) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = (_Tp)(a.s[i] shift_op imm); \ + return c; \ +} + +/** @brief Bitwise shift left + +For 16-, 32- and 64-bit integer values. */ +OPENCV_HAL_IMPL_SHIFT_OP(<< ) + +/** @brief Bitwise shift right + +For 16-, 32- and 64-bit integer values. */ +OPENCV_HAL_IMPL_SHIFT_OP(>> ) + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(suffix,opA,opB) \ +template inline v_reg<_Tp, n> v_rotate_##suffix(const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp, n> b; \ + for (int i = 0; i < n; i++) \ + { \ + int sIndex = i opA imm; \ + if (0 <= sIndex && sIndex < n) \ + { \ + b.s[i] = a.s[sIndex]; \ + } \ + else \ + { \ + b.s[i] = 0; \ + } \ + } \ + return b; \ +} \ +template inline v_reg<_Tp, n> v_rotate_##suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tp, n> c; \ + for (int i = 0; i < n; i++) \ + { \ + int aIndex = i opA imm; \ + int bIndex = i opA imm opB n; \ + if (0 <= bIndex && bIndex < n) \ + { \ + c.s[i] = b.s[bIndex]; \ + } \ + else if (0 <= aIndex && aIndex < n) \ + { \ + c.s[i] = a.s[aIndex]; \ + } \ + else \ + { \ + c.s[i] = 0; \ + } \ + } \ + return c; \ +} + +/** @brief Element shift left among vector + +For all type */ +OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(left, -, +) + +/** @brief Element shift right among vector + +For all type */ +OPENCV_HAL_IMPL_ROTATE_SHIFT_OP(right, +, -) + +/** @brief Sum packed values + +Scheme: +@code +{A1 A2 A3 ...} => sum{A1,A2,A3,...} +@endcode +*/ +template inline typename V_TypeTraits<_Tp>::sum_type v_reduce_sum(const v_reg<_Tp, n>& a) +{ + typename V_TypeTraits<_Tp>::sum_type c = a.s[0]; + for( int i = 1; i < n; i++ ) + c += a.s[i]; + return c; +} + +/** @brief Sums all elements of each input vector, returns the vector of sums + + Scheme: + @code + result[0] = a[0] + a[1] + a[2] + a[3] + result[1] = b[0] + b[1] + b[2] + b[3] + result[2] = c[0] + c[1] + c[2] + c[3] + result[3] = d[0] + d[1] + d[2] + d[3] + @endcode +*/ +template inline v_reg v_reduce_sum4(const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg r; + for(int i = 0; i < (n/4); i++) + { + r.s[i*4 + 0] = a.s[i*4 + 0] + a.s[i*4 + 1] + a.s[i*4 + 2] + a.s[i*4 + 3]; + r.s[i*4 + 1] = b.s[i*4 + 0] + b.s[i*4 + 1] + b.s[i*4 + 2] + b.s[i*4 + 3]; + r.s[i*4 + 2] = c.s[i*4 + 0] + c.s[i*4 + 1] + c.s[i*4 + 2] + c.s[i*4 + 3]; + r.s[i*4 + 3] = d.s[i*4 + 0] + d.s[i*4 + 1] + d.s[i*4 + 2] + d.s[i*4 + 3]; + } + return r; +} + +/** @brief Sum absolute differences of values + +Scheme: +@code +{A1 A2 A3 ...} {B1 B2 B3 ...} => sum{ABS(A1-B1),abs(A2-B2),abs(A3-B3),...} +@endcode +For all types except 64-bit types.*/ +template inline typename V_TypeTraits< typename V_TypeTraits<_Tp>::abs_type >::sum_type v_reduce_sad(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typename V_TypeTraits< typename V_TypeTraits<_Tp>::abs_type >::sum_type c = _absdiff(a.s[0], b.s[0]); + for (int i = 1; i < n; i++) + c += _absdiff(a.s[i], b.s[i]); + return c; +} + +/** @brief Get negative values mask +@deprecated v_signmask depends on a lane count heavily and therefore isn't universal enough + +Returned value is a bit mask with bits set to 1 on places corresponding to negative packed values indexes. +Example: +@code{.cpp} +v_int32x4 r; // set to {-1, -1, 1, 1} +int mask = v_signmask(r); // mask = 3 <== 00000000 00000000 00000000 00000011 +@endcode +*/ +template inline int v_signmask(const v_reg<_Tp, n>& a) +{ + int mask = 0; + for( int i = 0; i < n; i++ ) + mask |= (V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) < 0) << i; + return mask; +} + +/** @brief Get first negative lane index + +Returned value is an index of first negative lane (undefined for input of all positive values) +Example: +@code{.cpp} +v_int32x4 r; // set to {0, 0, -1, -1} +int idx = v_heading_zeros(r); // idx = 2 +@endcode +*/ +template inline int v_scan_forward(const v_reg<_Tp, n>& a) +{ + for (int i = 0; i < n; i++) + if(V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) < 0) + return i; + return 0; +} + +/** @brief Check if all packed values are less than zero + +Unsigned values will be casted to signed: `uchar 254 => char -2`. +*/ +template inline bool v_check_all(const v_reg<_Tp, n>& a) +{ + for( int i = 0; i < n; i++ ) + if( V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) >= 0 ) + return false; + return true; +} + +/** @brief Check if any of packed values is less than zero + +Unsigned values will be casted to signed: `uchar 254 => char -2`. +*/ +template inline bool v_check_any(const v_reg<_Tp, n>& a) +{ + for( int i = 0; i < n; i++ ) + if( V_TypeTraits<_Tp>::reinterpret_int(a.s[i]) < 0 ) + return true; + return false; +} + +/** @brief Per-element select (blend operation) + +Return value will be built by combining values _a_ and _b_ using the following scheme: + result[i] = mask[i] ? a[i] : b[i]; + +@note: _mask_ element values are restricted to these values: +- 0: select element from _b_ +- 0xff/0xffff/etc: select element from _a_ +(fully compatible with bitwise-based operator) +*/ +template inline v_reg<_Tp, n> v_select(const v_reg<_Tp, n>& mask, + const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + typedef V_TypeTraits<_Tp> Traits; + typedef typename Traits::int_type int_type; + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + { + int_type m = Traits::reinterpret_int(mask.s[i]); + CV_DbgAssert(m == 0 || m == (~(int_type)0)); // restrict mask values: 0 or 0xff/0xffff/etc + c.s[i] = m ? a.s[i] : b.s[i]; + } + return c; +} + +/** @brief Expand values to the wider pack type + +Copy contents of register to two registers with 2x wider pack type. +Scheme: +@code + int32x4 int64x2 int64x2 +{A B C D} ==> {A B} , {C D} +@endcode */ +template inline void v_expand(const v_reg<_Tp, n>& a, + v_reg::w_type, n/2>& b0, + v_reg::w_type, n/2>& b1) +{ + for( int i = 0; i < (n/2); i++ ) + { + b0.s[i] = a.s[i]; + b1.s[i] = a.s[i+(n/2)]; + } +} + +/** @brief Expand lower values to the wider pack type + +Same as cv::v_expand, but return lower half of the vector. + +Scheme: +@code + int32x4 int64x2 +{A B C D} ==> {A B} +@endcode */ +template +inline v_reg::w_type, n/2> +v_expand_low(const v_reg<_Tp, n>& a) +{ + v_reg::w_type, n/2> b; + for( int i = 0; i < (n/2); i++ ) + b.s[i] = a.s[i]; + return b; +} + +/** @brief Expand higher values to the wider pack type + +Same as cv::v_expand_low, but expand higher half of the vector instead. + +Scheme: +@code + int32x4 int64x2 +{A B C D} ==> {C D} +@endcode */ +template +inline v_reg::w_type, n/2> +v_expand_high(const v_reg<_Tp, n>& a) +{ + v_reg::w_type, n/2> b; + for( int i = 0; i < (n/2); i++ ) + b.s[i] = a.s[i+(n/2)]; + return b; +} + +//! @cond IGNORED +template inline v_reg::int_type, n> + v_reinterpret_as_int(const v_reg<_Tp, n>& a) +{ + v_reg::int_type, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = V_TypeTraits<_Tp>::reinterpret_int(a.s[i]); + return c; +} + +template inline v_reg::uint_type, n> + v_reinterpret_as_uint(const v_reg<_Tp, n>& a) +{ + v_reg::uint_type, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = V_TypeTraits<_Tp>::reinterpret_uint(a.s[i]); + return c; +} +//! @endcond + +/** @brief Interleave two vectors + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +--------------- + {A1 B1 A2 B2} and {A3 B3 A4 B4} +@endcode +For all types except 64-bit. +*/ +template inline void v_zip( const v_reg<_Tp, n>& a0, const v_reg<_Tp, n>& a1, + v_reg<_Tp, n>& b0, v_reg<_Tp, n>& b1 ) +{ + int i; + for( i = 0; i < n/2; i++ ) + { + b0.s[i*2] = a0.s[i]; + b0.s[i*2+1] = a1.s[i]; + } + for( ; i < n; i++ ) + { + b1.s[i*2-n] = a0.s[i]; + b1.s[i*2-n+1] = a1.s[i]; + } +} + +/** @brief Load register contents from memory + +@param ptr pointer to memory block with data +@return register object + +@note Returned type will be detected from passed pointer type, for example uchar ==> cv::v_uint8x16, int ==> cv::v_int32x4, etc. + +@note Use vx_load version to get maximum available register length result + +@note Alignment requirement: +if CV_STRONG_ALIGNMENT=1 then passed pointer must be aligned (`sizeof(lane type)` should be enough). +Do not cast pointer types without runtime check for pointer alignment (like `uchar*` => `int*`). + */ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + return v_reg<_Tp, simd128_width / sizeof(_Tp)>(ptr); +} + +#if CV_SIMD256 +/** @brief Load 256-bit length register contents from memory + +@param ptr pointer to memory block with data +@return register object + +@note Returned type will be detected from passed pointer type, for example uchar ==> cv::v_uint8x32, int ==> cv::v_int32x8, etc. + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load version to get maximum available register length result + +@note Alignment requirement: +if CV_STRONG_ALIGNMENT=1 then passed pointer must be aligned (`sizeof(lane type)` should be enough). +Do not cast pointer types without runtime check for pointer alignment (like `uchar*` => `int*`). + */ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + return v_reg<_Tp, simd256_width / sizeof(_Tp)>(ptr); +} +#endif + +#if CV_SIMD512 +/** @brief Load 512-bit length register contents from memory + +@param ptr pointer to memory block with data +@return register object + +@note Returned type will be detected from passed pointer type, for example uchar ==> cv::v_uint8x64, int ==> cv::v_int32x16, etc. + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load version to get maximum available register length result + +@note Alignment requirement: +if CV_STRONG_ALIGNMENT=1 then passed pointer must be aligned (`sizeof(lane type)` should be enough). +Do not cast pointer types without runtime check for pointer alignment (like `uchar*` => `int*`). + */ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + return v_reg<_Tp, simd512_width / sizeof(_Tp)>(ptr); +} +#endif + +/** @brief Load register contents from memory (aligned) + +similar to cv::v_load, but source memory block should be aligned (to 16-byte boundary in case of SIMD128, 32-byte - SIMD256, etc) + +@note Use vx_load_aligned version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load_aligned(const _Tp* ptr) +{ + CV_Assert(isAligned)>(ptr)); + return v_reg<_Tp, simd128_width / sizeof(_Tp)>(ptr); +} + +#if CV_SIMD256 +/** @brief Load register contents from memory (aligned) + +similar to cv::v256_load, but source memory block should be aligned (to 32-byte boundary in case of SIMD256, 64-byte - SIMD512, etc) + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_aligned version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load_aligned(const _Tp* ptr) +{ + CV_Assert(isAligned)>(ptr)); + return v_reg<_Tp, simd256_width / sizeof(_Tp)>(ptr); +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from memory (aligned) + +similar to cv::v512_load, but source memory block should be aligned (to 64-byte boundary in case of SIMD512, etc) + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_aligned version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load_aligned(const _Tp* ptr) +{ + CV_Assert(isAligned)>(ptr)); + return v_reg<_Tp, simd512_width / sizeof(_Tp)>(ptr); +} +#endif + +/** @brief Load 64-bits of data to lower part (high part is undefined). + +@param ptr memory block containing data for first half (0..n/2) + +@code{.cpp} +int lo[2] = { 1, 2 }; +v_int32x4 r = v_load_low(lo); +@endcode + +@note Use vx_load_low version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load_low(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for( int i = 0; i < c.nlanes/2; i++ ) + { + c.s[i] = ptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load 128-bits of data to lower part (high part is undefined). + +@param ptr memory block containing data for first half (0..n/2) + +@code{.cpp} +int lo[4] = { 1, 2, 3, 4 }; +v_int32x8 r = v256_load_low(lo); +@endcode + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_low version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load_low(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_reg<_Tp, simd256_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load 256-bits of data to lower part (high part is undefined). + +@param ptr memory block containing data for first half (0..n/2) + +@code{.cpp} +int lo[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; +v_int32x16 r = v512_load_low(lo); +@endcode + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_low version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load_low(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_reg<_Tp, simd512_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +/** @brief Load register contents from two memory blocks + +@param loptr memory block containing data for first half (0..n/2) +@param hiptr memory block containing data for second half (n/2..n) + +@code{.cpp} +int lo[2] = { 1, 2 }, hi[2] = { 3, 4 }; +v_int32x4 r = v_load_halves(lo, hi); +@endcode + +@note Use vx_load_halves version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_load_halves(const _Tp* loptr, const _Tp* hiptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(loptr)); + CV_Assert(isAligned(hiptr)); +#endif + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for( int i = 0; i < c.nlanes/2; i++ ) + { + c.s[i] = loptr[i]; + c.s[i+c.nlanes/2] = hiptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load register contents from two memory blocks + +@param loptr memory block containing data for first half (0..n/2) +@param hiptr memory block containing data for second half (n/2..n) + +@code{.cpp} +int lo[4] = { 1, 2, 3, 4 }, hi[4] = { 5, 6, 7, 8 }; +v_int32x8 r = v256_load_halves(lo, hi); +@endcode + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_halves version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd256_width / sizeof(_Tp)> v256_load_halves(const _Tp* loptr, const _Tp* hiptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(loptr)); + CV_Assert(isAligned(hiptr)); +#endif + v_reg<_Tp, simd256_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = loptr[i]; + c.s[i + c.nlanes / 2] = hiptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from two memory blocks + +@param loptr memory block containing data for first half (0..n/2) +@param hiptr memory block containing data for second half (n/2..n) + +@code{.cpp} +int lo[4] = { 1, 2, 3, 4, 5, 6, 7, 8 }, hi[4] = { 9, 10, 11, 12, 13, 14, 15, 16 }; +v_int32x16 r = v512_load_halves(lo, hi); +@endcode + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_halves version to get maximum available register length result +*/ +template +inline v_reg<_Tp, simd512_width / sizeof(_Tp)> v512_load_halves(const _Tp* loptr, const _Tp* hiptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(loptr)); + CV_Assert(isAligned(hiptr)); +#endif + v_reg<_Tp, simd512_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes / 2; i++) + { + c.s[i] = loptr[i]; + c.s[i + c.nlanes / 2] = hiptr[i]; + } + return c; +} +#endif + +/** @brief Load register contents from memory with double expand + +Same as cv::v_load, but result pack type will be 2x wider than memory type. + +@code{.cpp} +short buf[4] = {1, 2, 3, 4}; // type is int16 +v_int32x4 r = v_load_expand(buf); // r = {1, 2, 3, 4} - type is int32 +@endcode +For 8-, 16-, 32-bit integer source types. + +@note Use vx_load_expand version to get maximum available register length result +*/ +template +inline v_reg::w_type, simd128_width / sizeof(typename V_TypeTraits<_Tp>::w_type)> +v_load_expand(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + { + c.s[i] = ptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load register contents from memory with double expand + +Same as cv::v256_load, but result pack type will be 2x wider than memory type. + +@code{.cpp} +short buf[8] = {1, 2, 3, 4, 5, 6, 7, 8}; // type is int16 +v_int32x8 r = v256_load_expand(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8} - type is int32 +@endcode +For 8-, 16-, 32-bit integer source types. + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_expand version to get maximum available register length result +*/ +template +inline v_reg::w_type, simd256_width / sizeof(typename V_TypeTraits<_Tp>::w_type)> +v256_load_expand(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from memory with double expand + +Same as cv::v512_load, but result pack type will be 2x wider than memory type. + +@code{.cpp} +short buf[8] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // type is int16 +v_int32x16 r = v512_load_expand(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} - type is int32 +@endcode +For 8-, 16-, 32-bit integer source types. + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_expand version to get maximum available register length result +*/ +template +inline v_reg::w_type, simd512_width / sizeof(typename V_TypeTraits<_Tp>::w_type)> +v512_load_expand(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::w_type w_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +/** @brief Load register contents from memory with quad expand + +Same as cv::v_load_expand, but result type is 4 times wider than source. +@code{.cpp} +char buf[4] = {1, 2, 3, 4}; // type is int8 +v_int32x4 r = v_load_expand_q(buf); // r = {1, 2, 3, 4} - type is int32 +@endcode +For 8-bit integer source types. + +@note Use vx_load_expand_q version to get maximum available register length result +*/ +template +inline v_reg::q_type, simd128_width / sizeof(typename V_TypeTraits<_Tp>::q_type)> +v_load_expand_q(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg c; + for( int i = 0; i < c.nlanes; i++ ) + { + c.s[i] = ptr[i]; + } + return c; +} + +#if CV_SIMD256 +/** @brief Load register contents from memory with quad expand + +Same as cv::v256_load_expand, but result type is 4 times wider than source. +@code{.cpp} +char buf[8] = {1, 2, 3, 4, 5, 6, 7, 8}; // type is int8 +v_int32x8 r = v256_load_expand_q(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8} - type is int32 +@endcode +For 8-bit integer source types. + +@note Check CV_SIMD256 preprocessor definition prior to use. +Use vx_load_expand_q version to get maximum available register length result +*/ +template +inline v_reg::q_type, simd256_width / sizeof(typename V_TypeTraits<_Tp>::q_type)> +v256_load_expand_q(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +#if CV_SIMD512 +/** @brief Load register contents from memory with quad expand + +Same as cv::v512_load_expand, but result type is 4 times wider than source. +@code{.cpp} +char buf[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // type is int8 +v_int32x16 r = v512_load_expand_q(buf); // r = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} - type is int32 +@endcode +For 8-bit integer source types. + +@note Check CV_SIMD512 preprocessor definition prior to use. +Use vx_load_expand_q version to get maximum available register length result +*/ +template +inline v_reg::q_type, simd512_width / sizeof(typename V_TypeTraits<_Tp>::q_type)> +v512_load_expand_q(const _Tp* ptr) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + typedef typename V_TypeTraits<_Tp>::q_type q_type; + v_reg c; + for (int i = 0; i < c.nlanes; i++) + { + c.s[i] = ptr[i]; + } + return c; +} +#endif + +/** @brief Load and deinterleave (2 channels) + +Load data from memory deinterleave and store to 2 registers. +Scheme: +@code +{A1 B1 A2 B2 ...} ==> {A1 A2 ...}, {B1 B2 ...} +@endcode +For all types except 64-bit. */ +template inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a, + v_reg<_Tp, n>& b) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i2; + for( i = i2 = 0; i < n; i++, i2 += 2 ) + { + a.s[i] = ptr[i2]; + b.s[i] = ptr[i2+1]; + } +} + +/** @brief Load and deinterleave (3 channels) + +Load data from memory deinterleave and store to 3 registers. +Scheme: +@code +{A1 B1 C1 A2 B2 C2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...} +@endcode +For all types except 64-bit. */ +template inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a, + v_reg<_Tp, n>& b, v_reg<_Tp, n>& c) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i3; + for( i = i3 = 0; i < n; i++, i3 += 3 ) + { + a.s[i] = ptr[i3]; + b.s[i] = ptr[i3+1]; + c.s[i] = ptr[i3+2]; + } +} + +/** @brief Load and deinterleave (4 channels) + +Load data from memory deinterleave and store to 4 registers. +Scheme: +@code +{A1 B1 C1 D1 A2 B2 C2 D2 ...} ==> {A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...} +@endcode +For all types except 64-bit. */ +template +inline void v_load_deinterleave(const _Tp* ptr, v_reg<_Tp, n>& a, + v_reg<_Tp, n>& b, v_reg<_Tp, n>& c, + v_reg<_Tp, n>& d) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i4; + for( i = i4 = 0; i < n; i++, i4 += 4 ) + { + a.s[i] = ptr[i4]; + b.s[i] = ptr[i4+1]; + c.s[i] = ptr[i4+2]; + d.s[i] = ptr[i4+3]; + } +} + +/** @brief Interleave and store (2 channels) + +Interleave and store data from 2 registers to memory. +Scheme: +@code +{A1 A2 ...}, {B1 B2 ...} ==> {A1 B1 A2 B2 ...} +@endcode +For all types except 64-bit. */ +template +inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a, + const v_reg<_Tp, n>& b, + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i2; + for( i = i2 = 0; i < n; i++, i2 += 2 ) + { + ptr[i2] = a.s[i]; + ptr[i2+1] = b.s[i]; + } +} + +/** @brief Interleave and store (3 channels) + +Interleave and store data from 3 registers to memory. +Scheme: +@code +{A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...} ==> {A1 B1 C1 A2 B2 C2 ...} +@endcode +For all types except 64-bit. */ +template +inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a, + const v_reg<_Tp, n>& b, const v_reg<_Tp, n>& c, + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i3; + for( i = i3 = 0; i < n; i++, i3 += 3 ) + { + ptr[i3] = a.s[i]; + ptr[i3+1] = b.s[i]; + ptr[i3+2] = c.s[i]; + } +} + +/** @brief Interleave and store (4 channels) + +Interleave and store data from 4 registers to memory. +Scheme: +@code +{A1 A2 ...}, {B1 B2 ...}, {C1 C2 ...}, {D1 D2 ...} ==> {A1 B1 C1 D1 A2 B2 C2 D2 ...} +@endcode +For all types except 64-bit. */ +template inline void v_store_interleave( _Tp* ptr, const v_reg<_Tp, n>& a, + const v_reg<_Tp, n>& b, const v_reg<_Tp, n>& c, + const v_reg<_Tp, n>& d, + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + int i, i4; + for( i = i4 = 0; i < n; i++, i4 += 4 ) + { + ptr[i4] = a.s[i]; + ptr[i4+1] = b.s[i]; + ptr[i4+2] = c.s[i]; + ptr[i4+3] = d.s[i]; + } +} + +/** @brief Store data to memory + +Store register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {A B C D} +@endcode +Pointer can be unaligned. */ +template +inline void v_store(_Tp* ptr, const v_reg<_Tp, n>& a) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + for( int i = 0; i < n; i++ ) + ptr[i] = a.s[i]; +} + +template +inline void v_store(_Tp* ptr, const v_reg<_Tp, n>& a, hal::StoreMode /*mode*/) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + v_store(ptr, a); +} + +/** @brief Store data to memory (lower half) + +Store lower half of register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {A B} +@endcode */ +template +inline void v_store_low(_Tp* ptr, const v_reg<_Tp, n>& a) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + for( int i = 0; i < (n/2); i++ ) + ptr[i] = a.s[i]; +} + +/** @brief Store data to memory (higher half) + +Store higher half of register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {C D} +@endcode */ +template +inline void v_store_high(_Tp* ptr, const v_reg<_Tp, n>& a) +{ +#if CV_STRONG_ALIGNMENT + CV_Assert(isAligned(ptr)); +#endif + for( int i = 0; i < (n/2); i++ ) + ptr[i] = a.s[i+(n/2)]; +} + +/** @brief Store data to memory (aligned) + +Store register contents to memory. +Scheme: +@code + REG {A B C D} ==> MEM {A B C D} +@endcode +Pointer __should__ be aligned by 16-byte boundary. */ +template +inline void v_store_aligned(_Tp* ptr, const v_reg<_Tp, n>& a) +{ + CV_Assert(isAligned)>(ptr)); + v_store(ptr, a); +} + +template +inline void v_store_aligned_nocache(_Tp* ptr, const v_reg<_Tp, n>& a) +{ + CV_Assert(isAligned)>(ptr)); + v_store(ptr, a); +} + +template +inline void v_store_aligned(_Tp* ptr, const v_reg<_Tp, n>& a, hal::StoreMode /*mode*/) +{ + CV_Assert(isAligned)>(ptr)); + v_store(ptr, a); +} + +/** @brief Combine vector from first elements of two vectors + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +--------------- + {A1 A2 B1 B2} +@endcode +For all types except 64-bit. */ +template +inline v_reg<_Tp, n> v_combine_low(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = a.s[i]; + c.s[i+(n/2)] = b.s[i]; + } + return c; +} + +/** @brief Combine vector from last elements of two vectors + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +--------------- + {A3 A4 B3 B4} +@endcode +For all types except 64-bit. */ +template +inline v_reg<_Tp, n> v_combine_high(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < (n/2); i++ ) + { + c.s[i] = a.s[i+(n/2)]; + c.s[i+(n/2)] = b.s[i+(n/2)]; + } + return c; +} + +/** @brief Combine two vectors from lower and higher parts of two other vectors + +@code{.cpp} +low = cv::v_combine_low(a, b); +high = cv::v_combine_high(a, b); +@endcode */ +template +inline void v_recombine(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b, + v_reg<_Tp, n>& low, v_reg<_Tp, n>& high) +{ + for( int i = 0; i < (n/2); i++ ) + { + low.s[i] = a.s[i]; + low.s[i+(n/2)] = b.s[i]; + high.s[i] = a.s[i+(n/2)]; + high.s[i+(n/2)] = b.s[i+(n/2)]; + } +} + +/** @brief Vector reverse order + +Reverse the order of the vector +Scheme: +@code + REG {A1 ... An} ==> REG {An ... A1} +@endcode +For all types. */ +template +inline v_reg<_Tp, n> v_reverse(const v_reg<_Tp, n>& a) +{ + v_reg<_Tp, n> c; + for( int i = 0; i < n; i++ ) + c.s[i] = a.s[n-i-1]; + return c; +} + +/** @brief Vector extract + +Scheme: +@code + {A1 A2 A3 A4} + {B1 B2 B3 B4} +======================== +shift = 1 {A2 A3 A4 B1} +shift = 2 {A3 A4 B1 B2} +shift = 3 {A4 B1 B2 B3} +@endcode +Restriction: 0 <= shift < nlanes + +Usage: +@code +v_int32x4 a, b, c; +c = v_extract<2>(a, b); +@endcode +For all types. */ +template +inline v_reg<_Tp, n> v_extract(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + v_reg<_Tp, n> r; + const int shift = n - s; + int i = 0; + for (; i < shift; ++i) + r.s[i] = a.s[i+s]; + for (; i < n; ++i) + r.s[i] = b.s[i-shift]; + return r; +} + +/** @brief Vector extract + +Scheme: +Return the s-th element of v. +Restriction: 0 <= s < nlanes + +Usage: +@code +v_int32x4 a; +int r; +r = v_extract_n<2>(a); +@endcode +For all types. */ +template +inline _Tp v_extract_n(const v_reg<_Tp, n>& v) +{ + CV_DbgAssert(s >= 0 && s < n); + return v.s[s]; +} + +/** @brief Broadcast i-th element of vector + +Scheme: +@code +{ v[0] v[1] v[2] ... v[SZ] } => { v[i], v[i], v[i] ... v[i] } +@endcode +Restriction: 0 <= i < nlanes +Supported types: 32-bit integers and floats (s32/u32/f32) + */ +template +inline v_reg<_Tp, n> v_broadcast_element(const v_reg<_Tp, n>& a) +{ + CV_DbgAssert(i >= 0 && i < n); + return v_reg<_Tp, n>::all(a.s[i]); +} + +/** @brief Round elements + +Rounds each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_round(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = cvRound(a.s[i]); + return c; +} + +/** @overload */ +template inline v_reg v_round(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvRound(a.s[i]); + c.s[i+n] = cvRound(b.s[i]); + } + return c; +} + +/** @brief Floor elements + +Floor each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_floor(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = cvFloor(a.s[i]); + return c; +} + +/** @brief Ceil elements + +Ceil each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_ceil(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = cvCeil(a.s[i]); + return c; +} + +/** @brief Truncate elements + +Truncate each value. Input type is float vector ==> output type is int vector. +@note Only for floating point types. +*/ +template inline v_reg v_trunc(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = (int)(a.s[i]); + return c; +} + +/** @overload */ +template inline v_reg v_round(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvRound(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @overload */ +template inline v_reg v_floor(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvFloor(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @overload */ +template inline v_reg v_ceil(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = cvCeil(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @overload */ +template inline v_reg v_trunc(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = (int)(a.s[i]); + c.s[i+n] = 0; + } + return c; +} + +/** @brief Convert to float + +Supported input type is cv::v_int32. */ +template inline v_reg v_cvt_f32(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = (float)a.s[i]; + return c; +} + +/** @brief Convert lower half to float + +Supported input type is cv::v_float64. */ +template inline v_reg v_cvt_f32(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = (float)a.s[i]; + c.s[i+n] = 0; + } + return c; +} + +/** @brief Convert to float + +Supported input type is cv::v_float64. */ +template inline v_reg v_cvt_f32(const v_reg& a, const v_reg& b) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + { + c.s[i] = (float)a.s[i]; + c.s[i+n] = (float)b.s[i]; + } + return c; +} + +/** @brief Convert lower half to double + +Supported input type is cv::v_int32. */ +template CV_INLINE v_reg v_cvt_f64(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i]; + return c; +} + +/** @brief Convert to double high part of vector + +Supported input type is cv::v_int32. */ +template CV_INLINE v_reg v_cvt_f64_high(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i + (n/2)]; + return c; +} + +/** @brief Convert lower half to double + +Supported input type is cv::v_float32. */ +template CV_INLINE v_reg v_cvt_f64(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i]; + return c; +} + +/** @brief Convert to double high part of vector + +Supported input type is cv::v_float32. */ +template CV_INLINE v_reg v_cvt_f64_high(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < (n/2); i++ ) + c.s[i] = (double)a.s[i + (n/2)]; + return c; +} + +/** @brief Convert to double + +Supported input type is cv::v_int64. */ +template CV_INLINE v_reg v_cvt_f64(const v_reg& a) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = (double)a.s[i]; + return c; +} + + +template inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_lut(const _Tp* tab, const int* idx) +{ + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes; i++) + c.s[i] = tab[idx[i]]; + return c; +} +template inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_lut_pairs(const _Tp* tab, const int* idx) +{ + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes; i++) + c.s[i] = tab[idx[i / 2] + i % 2]; + return c; +} +template inline v_reg<_Tp, simd128_width / sizeof(_Tp)> v_lut_quads(const _Tp* tab, const int* idx) +{ + v_reg<_Tp, simd128_width / sizeof(_Tp)> c; + for (int i = 0; i < c.nlanes; i++) + c.s[i] = tab[idx[i / 4] + i % 4]; + return c; +} + +template inline v_reg v_lut(const int* tab, const v_reg& idx) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = tab[idx.s[i]]; + return c; +} + +template inline v_reg v_lut(const unsigned* tab, const v_reg& idx) +{ + v_reg c; + for (int i = 0; i < n; i++) + c.s[i] = tab[idx.s[i]]; + return c; +} + +template inline v_reg v_lut(const float* tab, const v_reg& idx) +{ + v_reg c; + for( int i = 0; i < n; i++ ) + c.s[i] = tab[idx.s[i]]; + return c; +} + +template inline v_reg v_lut(const double* tab, const v_reg& idx) +{ + v_reg c; + for( int i = 0; i < n/2; i++ ) + c.s[i] = tab[idx.s[i]]; + return c; +} + + +template inline void v_lut_deinterleave(const float* tab, const v_reg& idx, + v_reg& x, v_reg& y) +{ + for( int i = 0; i < n; i++ ) + { + int j = idx.s[i]; + x.s[i] = tab[j]; + y.s[i] = tab[j+1]; + } +} + +template inline void v_lut_deinterleave(const double* tab, const v_reg& idx, + v_reg& x, v_reg& y) +{ + for( int i = 0; i < n; i++ ) + { + int j = idx.s[i]; + x.s[i] = tab[j]; + y.s[i] = tab[j+1]; + } +} + +template inline v_reg<_Tp, n> v_interleave_pairs(const v_reg<_Tp, n>& vec) +{ + v_reg<_Tp, n> c; + for (int i = 0; i < n/4; i++) + { + c.s[4*i ] = vec.s[4*i ]; + c.s[4*i+1] = vec.s[4*i+2]; + c.s[4*i+2] = vec.s[4*i+1]; + c.s[4*i+3] = vec.s[4*i+3]; + } + return c; +} + +template inline v_reg<_Tp, n> v_interleave_quads(const v_reg<_Tp, n>& vec) +{ + v_reg<_Tp, n> c; + for (int i = 0; i < n/8; i++) + { + c.s[8*i ] = vec.s[8*i ]; + c.s[8*i+1] = vec.s[8*i+4]; + c.s[8*i+2] = vec.s[8*i+1]; + c.s[8*i+3] = vec.s[8*i+5]; + c.s[8*i+4] = vec.s[8*i+2]; + c.s[8*i+5] = vec.s[8*i+6]; + c.s[8*i+6] = vec.s[8*i+3]; + c.s[8*i+7] = vec.s[8*i+7]; + } + return c; +} + +template inline v_reg<_Tp, n> v_pack_triplets(const v_reg<_Tp, n>& vec) +{ + v_reg<_Tp, n> c; + for (int i = 0; i < n/4; i++) + { + c.s[3*i ] = vec.s[4*i ]; + c.s[3*i+1] = vec.s[4*i+1]; + c.s[3*i+2] = vec.s[4*i+2]; + } + return c; +} + +/** @brief Transpose 4x4 matrix + +Scheme: +@code +a0 {A1 A2 A3 A4} +a1 {B1 B2 B3 B4} +a2 {C1 C2 C3 C4} +a3 {D1 D2 D3 D4} +=============== +b0 {A1 B1 C1 D1} +b1 {A2 B2 C2 D2} +b2 {A3 B3 C3 D3} +b3 {A4 B4 C4 D4} +@endcode +*/ +template +inline void v_transpose4x4( v_reg<_Tp, n>& a0, const v_reg<_Tp, n>& a1, + const v_reg<_Tp, n>& a2, const v_reg<_Tp, n>& a3, + v_reg<_Tp, n>& b0, v_reg<_Tp, n>& b1, + v_reg<_Tp, n>& b2, v_reg<_Tp, n>& b3 ) +{ + for (int i = 0; i < n / 4; i++) + { + b0.s[0 + i*4] = a0.s[0 + i*4]; b0.s[1 + i*4] = a1.s[0 + i*4]; + b0.s[2 + i*4] = a2.s[0 + i*4]; b0.s[3 + i*4] = a3.s[0 + i*4]; + b1.s[0 + i*4] = a0.s[1 + i*4]; b1.s[1 + i*4] = a1.s[1 + i*4]; + b1.s[2 + i*4] = a2.s[1 + i*4]; b1.s[3 + i*4] = a3.s[1 + i*4]; + b2.s[0 + i*4] = a0.s[2 + i*4]; b2.s[1 + i*4] = a1.s[2 + i*4]; + b2.s[2 + i*4] = a2.s[2 + i*4]; b2.s[3 + i*4] = a3.s[2 + i*4]; + b3.s[0 + i*4] = a0.s[3 + i*4]; b3.s[1 + i*4] = a1.s[3 + i*4]; + b3.s[2 + i*4] = a2.s[3 + i*4]; b3.s[3 + i*4] = a3.s[3 + i*4]; + } +} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_INIT_ZERO(_Tpvec, prefix, suffix) \ +inline _Tpvec prefix##_setzero_##suffix() { return _Tpvec::zero(); } + +//! @name Init with zero +//! @{ +//! @brief Create new vector with zero elements +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint8x16, v, u8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int8x16, v, s8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint16x8, v, u16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int16x8, v, s16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint32x4, v, u32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int32x4, v, s32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float32x4, v, f32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float64x2, v, f64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint64x2, v, u64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int64x2, v, s64) + +#if CV_SIMD256 +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint8x32, v256, u8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int8x32, v256, s8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint16x16, v256, u16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int16x16, v256, s16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint32x8, v256, u32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int32x8, v256, s32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float32x8, v256, f32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float64x4, v256, f64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint64x4, v256, u64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int64x4, v256, s64) +#endif + +#if CV_SIMD512 +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint8x64, v512, u8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int8x64, v512, s8) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint16x32, v512, u16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int16x32, v512, s16) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint32x16, v512, u32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int32x16, v512, s32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float32x16, v512, f32) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_float64x8, v512, f64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_uint64x8, v512, u64) +OPENCV_HAL_IMPL_C_INIT_ZERO(v_int64x8, v512, s64) +#endif +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_INIT_VAL(_Tpvec, _Tp, prefix, suffix) \ +inline _Tpvec prefix##_setall_##suffix(_Tp val) { return _Tpvec::all(val); } + +//! @name Init with value +//! @{ +//! @brief Create new vector with elements set to a specific value +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint8x16, uchar, v, u8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int8x16, schar, v, s8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint16x8, ushort, v, u16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int16x8, short, v, s16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint32x4, unsigned, v, u32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int32x4, int, v, s32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float32x4, float, v, f32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float64x2, double, v, f64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint64x2, uint64, v, u64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int64x2, int64, v, s64) + +#if CV_SIMD256 +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint8x32, uchar, v256, u8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int8x32, schar, v256, s8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint16x16, ushort, v256, u16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int16x16, short, v256, s16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint32x8, unsigned, v256, u32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int32x8, int, v256, s32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float32x8, float, v256, f32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float64x4, double, v256, f64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint64x4, uint64, v256, u64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int64x4, int64, v256, s64) +#endif + +#if CV_SIMD512 +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint8x64, uchar, v512, u8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int8x64, schar, v512, s8) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint16x32, ushort, v512, u16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int16x32, short, v512, s16) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint32x16, unsigned, v512, u32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int32x16, int, v512, s32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float32x16, float, v512, f32) +OPENCV_HAL_IMPL_C_INIT_VAL(v_float64x8, double, v512, f64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_uint64x8, uint64, v512, u64) +OPENCV_HAL_IMPL_C_INIT_VAL(v_int64x8, int64, v512, s64) +#endif +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_REINTERPRET(_Tp, suffix) \ +template inline v_reg<_Tp, n0*sizeof(_Tp0)/sizeof(_Tp)> \ + v_reinterpret_as_##suffix(const v_reg<_Tp0, n0>& a) \ +{ return a.template reinterpret_as<_Tp, n0*sizeof(_Tp0)/sizeof(_Tp)>(); } + +//! @name Reinterpret +//! @{ +//! @brief Convert vector to different type without modifying underlying data. +OPENCV_HAL_IMPL_C_REINTERPRET(uchar, u8) +OPENCV_HAL_IMPL_C_REINTERPRET(schar, s8) +OPENCV_HAL_IMPL_C_REINTERPRET(ushort, u16) +OPENCV_HAL_IMPL_C_REINTERPRET(short, s16) +OPENCV_HAL_IMPL_C_REINTERPRET(unsigned, u32) +OPENCV_HAL_IMPL_C_REINTERPRET(int, s32) +OPENCV_HAL_IMPL_C_REINTERPRET(float, f32) +OPENCV_HAL_IMPL_C_REINTERPRET(double, f64) +OPENCV_HAL_IMPL_C_REINTERPRET(uint64, u64) +OPENCV_HAL_IMPL_C_REINTERPRET(int64, s64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_SHIFTL(_Tp) \ +template inline v_reg<_Tp, n> v_shl(const v_reg<_Tp, n>& a) \ +{ return a << shift; } + +//! @name Left shift +//! @{ +//! @brief Shift left +OPENCV_HAL_IMPL_C_SHIFTL(ushort) +OPENCV_HAL_IMPL_C_SHIFTL(short) +OPENCV_HAL_IMPL_C_SHIFTL(unsigned) +OPENCV_HAL_IMPL_C_SHIFTL(int) +OPENCV_HAL_IMPL_C_SHIFTL(uint64) +OPENCV_HAL_IMPL_C_SHIFTL(int64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_SHIFTR(_Tp) \ +template inline v_reg<_Tp, n> v_shr(const v_reg<_Tp, n>& a) \ +{ return a >> shift; } + +//! @name Right shift +//! @{ +//! @brief Shift right +OPENCV_HAL_IMPL_C_SHIFTR(ushort) +OPENCV_HAL_IMPL_C_SHIFTR(short) +OPENCV_HAL_IMPL_C_SHIFTR(unsigned) +OPENCV_HAL_IMPL_C_SHIFTR(int) +OPENCV_HAL_IMPL_C_SHIFTR(uint64) +OPENCV_HAL_IMPL_C_SHIFTR(int64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_RSHIFTR(_Tp) \ +template inline v_reg<_Tp, n> v_rshr(const v_reg<_Tp, n>& a) \ +{ \ + v_reg<_Tp, n> c; \ + for( int i = 0; i < n; i++ ) \ + c.s[i] = (_Tp)((a.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ + return c; \ +} + +//! @name Rounding shift +//! @{ +//! @brief Rounding shift right +OPENCV_HAL_IMPL_C_RSHIFTR(ushort) +OPENCV_HAL_IMPL_C_RSHIFTR(short) +OPENCV_HAL_IMPL_C_RSHIFTR(unsigned) +OPENCV_HAL_IMPL_C_RSHIFTR(int) +OPENCV_HAL_IMPL_C_RSHIFTR(uint64) +OPENCV_HAL_IMPL_C_RSHIFTR(int64) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_PACK(_Tp, _Tpn, pack_suffix, cast) \ +template inline v_reg<_Tpn, 2*n> v_##pack_suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tpn, 2*n> c; \ + for( int i = 0; i < n; i++ ) \ + { \ + c.s[i] = cast<_Tpn>(a.s[i]); \ + c.s[i+n] = cast<_Tpn>(b.s[i]); \ + } \ + return c; \ +} + +//! @name Pack +//! @{ +//! @brief Pack values from two vectors to one +//! +//! Return vector type have twice more elements than input vector types. Variant with _u_ suffix also +//! converts to corresponding unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_PACK(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_PACK(int, ushort, pack_u, saturate_cast) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_RSHR_PACK(_Tp, _Tpn, pack_suffix, cast) \ +template inline v_reg<_Tpn, 2*n> v_rshr_##pack_suffix(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) \ +{ \ + v_reg<_Tpn, 2*n> c; \ + for( int i = 0; i < n; i++ ) \ + { \ + c.s[i] = cast<_Tpn>((a.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ + c.s[i+n] = cast<_Tpn>((b.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ + } \ + return c; \ +} + +//! @name Pack with rounding shift +//! @{ +//! @brief Pack values from two vectors to one with rounding shift +//! +//! Values from the input vectors will be shifted right by _n_ bits with rounding, converted to narrower +//! type and returned in the result vector. Variant with _u_ suffix converts to unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_RSHR_PACK(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK(int, ushort, pack_u, saturate_cast) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_PACK_STORE(_Tp, _Tpn, pack_suffix, cast) \ +template inline void v_##pack_suffix##_store(_Tpn* ptr, const v_reg<_Tp, n>& a) \ +{ \ + for( int i = 0; i < n; i++ ) \ + ptr[i] = cast<_Tpn>(a.s[i]); \ +} + +//! @name Pack and store +//! @{ +//! @brief Store values from the input vector into memory with pack +//! +//! Values will be stored into memory with conversion to narrower type. +//! Variant with _u_ suffix converts to corresponding unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_PACK_STORE(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_PACK_STORE(int, ushort, pack_u, saturate_cast) +//! @} + +//! @brief Helper macro +//! @ingroup core_hal_intrin_impl +#define OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(_Tp, _Tpn, pack_suffix, cast) \ +template inline void v_rshr_##pack_suffix##_store(_Tpn* ptr, const v_reg<_Tp, n>& a) \ +{ \ + for( int i = 0; i < n; i++ ) \ + ptr[i] = cast<_Tpn>((a.s[i] + ((_Tp)1 << (shift - 1))) >> shift); \ +} + +//! @name Pack and store with rounding shift +//! @{ +//! @brief Store values from the input vector into memory with pack +//! +//! Values will be shifted _n_ bits right with rounding, converted to narrower type and stored into +//! memory. Variant with _u_ suffix converts to unsigned type. +//! +//! - pack: for 16-, 32- and 64-bit integer input types +//! - pack_u: for 16- and 32-bit signed integer input types +//! +//! @note All variants except 64-bit use saturation. +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(ushort, uchar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(short, schar, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(unsigned, ushort, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(int, short, pack, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(uint64, unsigned, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(int64, int, pack, static_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(short, uchar, pack_u, saturate_cast) +OPENCV_HAL_IMPL_C_RSHR_PACK_STORE(int, ushort, pack_u, saturate_cast) +//! @} + +//! @cond IGNORED +template +inline void _pack_b(_Tpm* mptr, const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b) +{ + for (int i = 0; i < n; ++i) + { + mptr[i] = (_Tpm)a.s[i]; + mptr[i + n] = (_Tpm)b.s[i]; + } +} +//! @endcond + +//! @name Pack boolean values +//! @{ +//! @brief Pack boolean values from multiple vectors to one unsigned 8-bit integer vector +//! +//! @note Must provide valid boolean values to guarantee same result for all architectures. + +/** @brief +//! For 16-bit boolean values + +Scheme: +@code +a {0xFFFF 0 0 0xFFFF 0 0xFFFF 0xFFFF 0} +b {0xFFFF 0 0xFFFF 0 0 0xFFFF 0 0xFFFF} +=============== +{ + 0xFF 0 0 0xFF 0 0xFF 0xFF 0 + 0xFF 0 0xFF 0 0 0xFF 0 0xFF +} +@endcode */ + +template inline v_reg v_pack_b(const v_reg& a, const v_reg& b) +{ + v_reg mask; + _pack_b(mask.s, a, b); + return mask; +} + +/** @overload +For 32-bit boolean values + +Scheme: +@code +a {0xFFFF.. 0 0 0xFFFF..} +b {0 0xFFFF.. 0xFFFF.. 0} +c {0xFFFF.. 0 0xFFFF.. 0} +d {0 0xFFFF.. 0 0xFFFF..} +=============== +{ + 0xFF 0 0 0xFF 0 0xFF 0xFF 0 + 0xFF 0 0xFF 0 0 0xFF 0 0xFF +} +@endcode */ + +template inline v_reg v_pack_b(const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg mask; + _pack_b(mask.s, a, b); + _pack_b(mask.s + 2*n, c, d); + return mask; +} + +/** @overload +For 64-bit boolean values + +Scheme: +@code +a {0xFFFF.. 0} +b {0 0xFFFF..} +c {0xFFFF.. 0} +d {0 0xFFFF..} + +e {0xFFFF.. 0} +f {0xFFFF.. 0} +g {0 0xFFFF..} +h {0 0xFFFF..} +=============== +{ + 0xFF 0 0 0xFF 0xFF 0 0 0xFF + 0xFF 0 0xFF 0 0 0xFF 0 0xFF +} +@endcode */ +template inline v_reg v_pack_b(const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d, + const v_reg& e, const v_reg& f, + const v_reg& g, const v_reg& h) +{ + v_reg mask; + _pack_b(mask.s, a, b); + _pack_b(mask.s + 2*n, c, d); + _pack_b(mask.s + 4*n, e, f); + _pack_b(mask.s + 6*n, g, h); + return mask; +} +//! @} + +/** @brief Matrix multiplication + +Scheme: +@code +{A0 A1 A2 A3} |V0| +{B0 B1 B2 B3} |V1| +{C0 C1 C2 C3} |V2| +{D0 D1 D2 D3} x |V3| +==================== +{R0 R1 R2 R3}, where: +R0 = A0V0 + B0V1 + C0V2 + D0V3, +R1 = A1V0 + B1V1 + C1V2 + D1V3 +... +@endcode +*/ +template +inline v_reg v_matmul(const v_reg& v, + const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg res; + for (int i = 0; i < n / 4; i++) + { + res.s[0 + i*4] = v.s[0 + i*4] * a.s[0 + i*4] + v.s[1 + i*4] * b.s[0 + i*4] + v.s[2 + i*4] * c.s[0 + i*4] + v.s[3 + i*4] * d.s[0 + i*4]; + res.s[1 + i*4] = v.s[0 + i*4] * a.s[1 + i*4] + v.s[1 + i*4] * b.s[1 + i*4] + v.s[2 + i*4] * c.s[1 + i*4] + v.s[3 + i*4] * d.s[1 + i*4]; + res.s[2 + i*4] = v.s[0 + i*4] * a.s[2 + i*4] + v.s[1 + i*4] * b.s[2 + i*4] + v.s[2 + i*4] * c.s[2 + i*4] + v.s[3 + i*4] * d.s[2 + i*4]; + res.s[3 + i*4] = v.s[0 + i*4] * a.s[3 + i*4] + v.s[1 + i*4] * b.s[3 + i*4] + v.s[2 + i*4] * c.s[3 + i*4] + v.s[3 + i*4] * d.s[3 + i*4]; + } + return res; +} + +/** @brief Matrix multiplication and add + +Scheme: +@code +{A0 A1 A2 A3} |V0| |D0| +{B0 B1 B2 B3} |V1| |D1| +{C0 C1 C2 C3} x |V2| + |D2| +==================== |D3| +{R0 R1 R2 R3}, where: +R0 = A0V0 + B0V1 + C0V2 + D0, +R1 = A1V0 + B1V1 + C1V2 + D1 +... +@endcode +*/ +template +inline v_reg v_matmuladd(const v_reg& v, + const v_reg& a, const v_reg& b, + const v_reg& c, const v_reg& d) +{ + v_reg res; + for (int i = 0; i < n / 4; i++) + { + res.s[0 + i * 4] = v.s[0 + i * 4] * a.s[0 + i * 4] + v.s[1 + i * 4] * b.s[0 + i * 4] + v.s[2 + i * 4] * c.s[0 + i * 4] + d.s[0 + i * 4]; + res.s[1 + i * 4] = v.s[0 + i * 4] * a.s[1 + i * 4] + v.s[1 + i * 4] * b.s[1 + i * 4] + v.s[2 + i * 4] * c.s[1 + i * 4] + d.s[1 + i * 4]; + res.s[2 + i * 4] = v.s[0 + i * 4] * a.s[2 + i * 4] + v.s[1 + i * 4] * b.s[2 + i * 4] + v.s[2 + i * 4] * c.s[2 + i * 4] + d.s[2 + i * 4]; + res.s[3 + i * 4] = v.s[0 + i * 4] * a.s[3 + i * 4] + v.s[1 + i * 4] * b.s[3 + i * 4] + v.s[2 + i * 4] * c.s[3 + i * 4] + d.s[3 + i * 4]; + } + return res; +} + + +template inline v_reg v_dotprod_expand(const v_reg& a, const v_reg& b) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_cvt_f64_high(a) * v_cvt_f64_high(b)); } +template inline v_reg v_dotprod_expand(const v_reg& a, const v_reg& b, + const v_reg& c) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_fma(v_cvt_f64_high(a), v_cvt_f64_high(b), c)); } + +template inline v_reg v_dotprod_expand_fast(const v_reg& a, const v_reg& b) +{ return v_dotprod_expand(a, b); } +template inline v_reg v_dotprod_expand_fast(const v_reg& a, const v_reg& b, + const v_reg& c) +{ return v_dotprod_expand(a, b, c); } + +////// FP16 support /////// + +inline v_reg +v_load_expand(const float16_t* ptr) +{ + v_reg v; + for( int i = 0; i < v.nlanes; i++ ) + { + v.s[i] = ptr[i]; + } + return v; +} +#if CV_SIMD256 +inline v_reg +v256_load_expand(const float16_t* ptr) +{ + v_reg v; + for (int i = 0; i < v.nlanes; i++) + { + v.s[i] = ptr[i]; + } + return v; +} +#endif +#if CV_SIMD512 +inline v_reg +v512_load_expand(const float16_t* ptr) +{ + v_reg v; + for (int i = 0; i < v.nlanes; i++) + { + v.s[i] = ptr[i]; + } + return v; +} +#endif + +template inline void +v_pack_store(float16_t* ptr, const v_reg& v) +{ + for( int i = 0; i < v.nlanes; i++ ) + { + ptr[i] = float16_t(v.s[i]); + } +} + +inline void v_cleanup() {} +#if CV_SIMD256 +inline void v256_cleanup() {} +#endif +#if CV_SIMD512 +inline void v512_cleanup() {} +#endif + +//! @} + +#ifndef CV_DOXYGEN +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END +#endif +} + +#if !defined(CV_DOXYGEN) +#undef CV_SIMD256 +#undef CV_SIMD512 +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_forward.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_forward.hpp new file mode 100644 index 0000000..979f15a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_forward.hpp @@ -0,0 +1,191 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef CV__SIMD_FORWARD +#error "Need to pre-define forward width" +#endif + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +/** Types **/ +#if CV__SIMD_FORWARD == 1024 +// [todo] 1024 +#error "1024-long ops not implemented yet" +#elif CV__SIMD_FORWARD == 512 +// 512 +#define __CV_VX(fun) v512_##fun +#define __CV_V_UINT8 v_uint8x64 +#define __CV_V_INT8 v_int8x64 +#define __CV_V_UINT16 v_uint16x32 +#define __CV_V_INT16 v_int16x32 +#define __CV_V_UINT32 v_uint32x16 +#define __CV_V_INT32 v_int32x16 +#define __CV_V_UINT64 v_uint64x8 +#define __CV_V_INT64 v_int64x8 +#define __CV_V_FLOAT32 v_float32x16 +#define __CV_V_FLOAT64 v_float64x8 +struct v_uint8x64; +struct v_int8x64; +struct v_uint16x32; +struct v_int16x32; +struct v_uint32x16; +struct v_int32x16; +struct v_uint64x8; +struct v_int64x8; +struct v_float32x16; +struct v_float64x8; +#elif CV__SIMD_FORWARD == 256 +// 256 +#define __CV_VX(fun) v256_##fun +#define __CV_V_UINT8 v_uint8x32 +#define __CV_V_INT8 v_int8x32 +#define __CV_V_UINT16 v_uint16x16 +#define __CV_V_INT16 v_int16x16 +#define __CV_V_UINT32 v_uint32x8 +#define __CV_V_INT32 v_int32x8 +#define __CV_V_UINT64 v_uint64x4 +#define __CV_V_INT64 v_int64x4 +#define __CV_V_FLOAT32 v_float32x8 +#define __CV_V_FLOAT64 v_float64x4 +struct v_uint8x32; +struct v_int8x32; +struct v_uint16x16; +struct v_int16x16; +struct v_uint32x8; +struct v_int32x8; +struct v_uint64x4; +struct v_int64x4; +struct v_float32x8; +struct v_float64x4; +#else +// 128 +#define __CV_VX(fun) v_##fun +#define __CV_V_UINT8 v_uint8x16 +#define __CV_V_INT8 v_int8x16 +#define __CV_V_UINT16 v_uint16x8 +#define __CV_V_INT16 v_int16x8 +#define __CV_V_UINT32 v_uint32x4 +#define __CV_V_INT32 v_int32x4 +#define __CV_V_UINT64 v_uint64x2 +#define __CV_V_INT64 v_int64x2 +#define __CV_V_FLOAT32 v_float32x4 +#define __CV_V_FLOAT64 v_float64x2 +struct v_uint8x16; +struct v_int8x16; +struct v_uint16x8; +struct v_int16x8; +struct v_uint32x4; +struct v_int32x4; +struct v_uint64x2; +struct v_int64x2; +struct v_float32x4; +struct v_float64x2; +#endif + +/** Value reordering **/ + +// Expansion +void v_expand(const __CV_V_UINT8&, __CV_V_UINT16&, __CV_V_UINT16&); +void v_expand(const __CV_V_INT8&, __CV_V_INT16&, __CV_V_INT16&); +void v_expand(const __CV_V_UINT16&, __CV_V_UINT32&, __CV_V_UINT32&); +void v_expand(const __CV_V_INT16&, __CV_V_INT32&, __CV_V_INT32&); +void v_expand(const __CV_V_UINT32&, __CV_V_UINT64&, __CV_V_UINT64&); +void v_expand(const __CV_V_INT32&, __CV_V_INT64&, __CV_V_INT64&); +// Low Expansion +__CV_V_UINT16 v_expand_low(const __CV_V_UINT8&); +__CV_V_INT16 v_expand_low(const __CV_V_INT8&); +__CV_V_UINT32 v_expand_low(const __CV_V_UINT16&); +__CV_V_INT32 v_expand_low(const __CV_V_INT16&); +__CV_V_UINT64 v_expand_low(const __CV_V_UINT32&); +__CV_V_INT64 v_expand_low(const __CV_V_INT32&); +// High Expansion +__CV_V_UINT16 v_expand_high(const __CV_V_UINT8&); +__CV_V_INT16 v_expand_high(const __CV_V_INT8&); +__CV_V_UINT32 v_expand_high(const __CV_V_UINT16&); +__CV_V_INT32 v_expand_high(const __CV_V_INT16&); +__CV_V_UINT64 v_expand_high(const __CV_V_UINT32&); +__CV_V_INT64 v_expand_high(const __CV_V_INT32&); +// Load & Low Expansion +__CV_V_UINT16 __CV_VX(load_expand)(const uchar*); +__CV_V_INT16 __CV_VX(load_expand)(const schar*); +__CV_V_UINT32 __CV_VX(load_expand)(const ushort*); +__CV_V_INT32 __CV_VX(load_expand)(const short*); +__CV_V_UINT64 __CV_VX(load_expand)(const uint*); +__CV_V_INT64 __CV_VX(load_expand)(const int*); +// Load lower 8-bit and expand into 32-bit +__CV_V_UINT32 __CV_VX(load_expand_q)(const uchar*); +__CV_V_INT32 __CV_VX(load_expand_q)(const schar*); + +// Saturating Pack +__CV_V_UINT8 v_pack(const __CV_V_UINT16&, const __CV_V_UINT16&); +__CV_V_INT8 v_pack(const __CV_V_INT16&, const __CV_V_INT16&); +__CV_V_UINT16 v_pack(const __CV_V_UINT32&, const __CV_V_UINT32&); +__CV_V_INT16 v_pack(const __CV_V_INT32&, const __CV_V_INT32&); +// Non-saturating Pack +__CV_V_UINT32 v_pack(const __CV_V_UINT64&, const __CV_V_UINT64&); +__CV_V_INT32 v_pack(const __CV_V_INT64&, const __CV_V_INT64&); +// Pack signed integers with unsigned saturation +__CV_V_UINT8 v_pack_u(const __CV_V_INT16&, const __CV_V_INT16&); +__CV_V_UINT16 v_pack_u(const __CV_V_INT32&, const __CV_V_INT32&); + +/** Arithmetic, bitwise and comparison operations **/ + +// Non-saturating multiply +#if CV_VSX +template +Tvec v_mul_wrap(const Tvec& a, const Tvec& b); +#else +__CV_V_UINT8 v_mul_wrap(const __CV_V_UINT8&, const __CV_V_UINT8&); +__CV_V_INT8 v_mul_wrap(const __CV_V_INT8&, const __CV_V_INT8&); +__CV_V_UINT16 v_mul_wrap(const __CV_V_UINT16&, const __CV_V_UINT16&); +__CV_V_INT16 v_mul_wrap(const __CV_V_INT16&, const __CV_V_INT16&); +#endif + +// Multiply and expand +#if CV_VSX +template +void v_mul_expand(const Tvec& a, const Tvec& b, Twvec& c, Twvec& d); +#else +void v_mul_expand(const __CV_V_UINT8&, const __CV_V_UINT8&, __CV_V_UINT16&, __CV_V_UINT16&); +void v_mul_expand(const __CV_V_INT8&, const __CV_V_INT8&, __CV_V_INT16&, __CV_V_INT16&); +void v_mul_expand(const __CV_V_UINT16&, const __CV_V_UINT16&, __CV_V_UINT32&, __CV_V_UINT32&); +void v_mul_expand(const __CV_V_INT16&, const __CV_V_INT16&, __CV_V_INT32&, __CV_V_INT32&); +void v_mul_expand(const __CV_V_UINT32&, const __CV_V_UINT32&, __CV_V_UINT64&, __CV_V_UINT64&); +void v_mul_expand(const __CV_V_INT32&, const __CV_V_INT32&, __CV_V_INT64&, __CV_V_INT64&); +#endif + +// Conversions +__CV_V_FLOAT32 v_cvt_f32(const __CV_V_INT32& a); +__CV_V_FLOAT32 v_cvt_f32(const __CV_V_FLOAT64& a); +__CV_V_FLOAT32 v_cvt_f32(const __CV_V_FLOAT64& a, const __CV_V_FLOAT64& b); +__CV_V_FLOAT64 v_cvt_f64(const __CV_V_INT32& a); +__CV_V_FLOAT64 v_cvt_f64_high(const __CV_V_INT32& a); +__CV_V_FLOAT64 v_cvt_f64(const __CV_V_FLOAT32& a); +__CV_V_FLOAT64 v_cvt_f64_high(const __CV_V_FLOAT32& a); +__CV_V_FLOAT64 v_cvt_f64(const __CV_V_INT64& a); + +/** Cleanup **/ +#undef CV__SIMD_FORWARD +#undef __CV_VX +#undef __CV_V_UINT8 +#undef __CV_V_INT8 +#undef __CV_V_UINT16 +#undef __CV_V_INT16 +#undef __CV_V_UINT32 +#undef __CV_V_INT32 +#undef __CV_V_UINT64 +#undef __CV_V_INT64 +#undef __CV_V_FLOAT32 +#undef __CV_V_FLOAT64 + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: \ No newline at end of file diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_msa.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_msa.hpp new file mode 100644 index 0000000..a1fbb09 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_msa.hpp @@ -0,0 +1,1887 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_HAL_INTRIN_MSA_HPP +#define OPENCV_HAL_INTRIN_MSA_HPP + +#include +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @cond IGNORED +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 + +//MSA implements 128-bit wide vector registers shared with the 64-bit wide floating-point unit registers. +//MSA and FPU can not be both present, unless the FPU has 64-bit floating-point registers. +#define CV_SIMD128_64F 1 + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(v16u8 v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = msa_ld1q_u8(v); + } + + uchar get0() const + { + return msa_getq_lane_u8(val, 0); + } + + v16u8 val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(v16i8 v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = msa_ld1q_s8(v); + } + + schar get0() const + { + return msa_getq_lane_s8(val, 0); + } + + v16i8 val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(v8u16 v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = msa_ld1q_u16(v); + } + + ushort get0() const + { + return msa_getq_lane_u16(val, 0); + } + + v8u16 val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(v8i16 v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = msa_ld1q_s16(v); + } + + short get0() const + { + return msa_getq_lane_s16(val, 0); + } + + v8i16 val; +}; + +struct v_uint32x4 +{ + typedef unsigned int lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(v4u32 v) : val(v) {} + v_uint32x4(unsigned int v0, unsigned int v1, unsigned int v2, unsigned int v3) + { + unsigned int v[] = {v0, v1, v2, v3}; + val = msa_ld1q_u32(v); + } + + unsigned int get0() const + { + return msa_getq_lane_u32(val, 0); + } + + v4u32 val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(v4i32 v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = msa_ld1q_s32(v); + } + + int get0() const + { + return msa_getq_lane_s32(val, 0); + } + + v4i32 val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(v4f32 v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = msa_ld1q_f32(v); + } + + float get0() const + { + return msa_getq_lane_f32(val, 0); + } + + v4f32 val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(v2u64 v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = msa_ld1q_u64(v); + } + + uint64 get0() const + { + return msa_getq_lane_u64(val, 0); + } + + v2u64 val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(v2i64 v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = msa_ld1q_s64(v); + } + + int64 get0() const + { + return msa_getq_lane_s64(val, 0); + } + + v2i64 val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(v2f64 v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = msa_ld1q_f64(v); + } + + double get0() const + { + return msa_getq_lane_f64(val, 0); + } + + v2f64 val; +}; + +#define OPENCV_HAL_IMPL_MSA_INIT(_Tpv, _Tp, suffix) \ +inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(msa_dupq_n_##suffix((_Tp)0)); } \ +inline v_##_Tpv v_setall_##suffix(_Tp v) { return v_##_Tpv(msa_dupq_n_##suffix(v)); } \ +inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16(MSA_TPV_REINTERPRET(v16u8, v.val)); } \ +inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16(MSA_TPV_REINTERPRET(v16i8, v.val)); } \ +inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8(MSA_TPV_REINTERPRET(v8u16, v.val)); } \ +inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8(MSA_TPV_REINTERPRET(v8i16, v.val)); } \ +inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4(MSA_TPV_REINTERPRET(v4u32, v.val)); } \ +inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4(MSA_TPV_REINTERPRET(v4i32, v.val)); } \ +inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2(MSA_TPV_REINTERPRET(v2u64, v.val)); } \ +inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2(MSA_TPV_REINTERPRET(v2i64, v.val)); } \ +inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4(MSA_TPV_REINTERPRET(v4f32, v.val)); } \ +inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2(MSA_TPV_REINTERPRET(v2f64, v.val)); } + +OPENCV_HAL_IMPL_MSA_INIT(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_MSA_INIT(int8x16, schar, s8) +OPENCV_HAL_IMPL_MSA_INIT(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_MSA_INIT(int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_INIT(uint32x4, unsigned int, u32) +OPENCV_HAL_IMPL_MSA_INIT(int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_INIT(uint64x2, uint64, u64) +OPENCV_HAL_IMPL_MSA_INIT(int64x2, int64, s64) +OPENCV_HAL_IMPL_MSA_INIT(float32x4, float, f32) +OPENCV_HAL_IMPL_MSA_INIT(float64x2, double, f64) + +#define OPENCV_HAL_IMPL_MSA_PACK(_Tpvec, _Tpwvec, pack, mov, rshr) \ +inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + return _Tpvec(mov(a.val, b.val)); \ +} \ +template inline \ +_Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + return _Tpvec(rshr(a.val, b.val, n)); \ +} + +OPENCV_HAL_IMPL_MSA_PACK(v_uint8x16, v_uint16x8, pack, msa_qpack_u16, msa_qrpackr_u16) +OPENCV_HAL_IMPL_MSA_PACK(v_int8x16, v_int16x8, pack, msa_qpack_s16, msa_qrpackr_s16) +OPENCV_HAL_IMPL_MSA_PACK(v_uint16x8, v_uint32x4, pack, msa_qpack_u32, msa_qrpackr_u32) +OPENCV_HAL_IMPL_MSA_PACK(v_int16x8, v_int32x4, pack, msa_qpack_s32, msa_qrpackr_s32) +OPENCV_HAL_IMPL_MSA_PACK(v_uint32x4, v_uint64x2, pack, msa_pack_u64, msa_rpackr_u64) +OPENCV_HAL_IMPL_MSA_PACK(v_int32x4, v_int64x2, pack, msa_pack_s64, msa_rpackr_s64) +OPENCV_HAL_IMPL_MSA_PACK(v_uint8x16, v_int16x8, pack_u, msa_qpacku_s16, msa_qrpackru_s16) +OPENCV_HAL_IMPL_MSA_PACK(v_uint16x8, v_int32x4, pack_u, msa_qpacku_s32, msa_qrpackru_s32) + +#define OPENCV_HAL_IMPL_MSA_PACK_STORE(_Tpvec, _Tp, hreg, suffix, _Tpwvec, pack, mov, rshr) \ +inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = mov(a.val); \ + msa_st1_##suffix(ptr, a1); \ +} \ +template inline \ +void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = rshr(a.val, n); \ + msa_st1_##suffix(ptr, a1); \ +} + +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint8x16, uchar, v8u8, u8, v_uint16x8, pack, msa_qmovn_u16, msa_qrshrn_n_u16) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_int8x16, schar, v8i8, s8, v_int16x8, pack, msa_qmovn_s16, msa_qrshrn_n_s16) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint16x8, ushort, v4u16, u16, v_uint32x4, pack, msa_qmovn_u32, msa_qrshrn_n_u32) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_int16x8, short, v4i16, s16, v_int32x4, pack, msa_qmovn_s32, msa_qrshrn_n_s32) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint32x4, unsigned, v2u32, u32, v_uint64x2, pack, msa_movn_u64, msa_rshrn_n_u64) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_int32x4, int, v2i32, s32, v_int64x2, pack, msa_movn_s64, msa_rshrn_n_s64) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint8x16, uchar, v8u8, u8, v_int16x8, pack_u, msa_qmovun_s16, msa_qrshrun_n_s16) +OPENCV_HAL_IMPL_MSA_PACK_STORE(v_uint16x8, ushort, v4u16, u16, v_int32x4, pack_u, msa_qmovun_s32, msa_qrshrun_n_s32) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint8x16(msa_pack_u16(a.val, b.val)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + return v_uint8x16(msa_pack_u16(msa_pack_u32(a.val, b.val), msa_pack_u32(c.val, d.val))); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + v8u16 abcd = msa_pack_u32(msa_pack_u64(a.val, b.val), msa_pack_u64(c.val, d.val)); + v8u16 efgh = msa_pack_u32(msa_pack_u64(e.val, f.val), msa_pack_u64(g.val, h.val)); + return v_uint8x16(msa_pack_u16(abcd, efgh)); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + v4f32 v0 = v.val; + v4f32 res = msa_mulq_lane_f32(m0.val, v0, 0); + res = msa_mlaq_lane_f32(res, m1.val, v0, 1); + res = msa_mlaq_lane_f32(res, m2.val, v0, 2); + res = msa_mlaq_lane_f32(res, m3.val, v0, 3); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + v4f32 v0 = v.val; + v4f32 res = msa_mulq_lane_f32(m0.val, v0, 0); + res = msa_mlaq_lane_f32(res, m1.val, v0, 1); + res = msa_mlaq_lane_f32(res, m2.val, v0, 2); + res = msa_addq_f32(res, a.val); + return v_float32x4(res); +} + +#define OPENCV_HAL_IMPL_MSA_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint8x16, msa_qaddq_u8) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint8x16, msa_qsubq_u8) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int8x16, msa_qaddq_s8) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int8x16, msa_qsubq_s8) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint16x8, msa_qaddq_u16) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint16x8, msa_qsubq_u16) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int16x8, msa_qaddq_s16) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int16x8, msa_qsubq_s16) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int32x4, msa_addq_s32) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int32x4, msa_subq_s32) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_int32x4, msa_mulq_s32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint32x4, msa_addq_u32) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint32x4, msa_subq_u32) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_uint32x4, msa_mulq_u32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_float32x4, msa_addq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_float32x4, msa_subq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_float32x4, msa_mulq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_int64x2, msa_addq_s64) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_int64x2, msa_subq_s64) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_uint64x2, msa_addq_u64) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_uint64x2, msa_subq_u64) +OPENCV_HAL_IMPL_MSA_BIN_OP(/, v_float32x4, msa_divq_f32) +OPENCV_HAL_IMPL_MSA_BIN_OP(+, v_float64x2, msa_addq_f64) +OPENCV_HAL_IMPL_MSA_BIN_OP(-, v_float64x2, msa_subq_f64) +OPENCV_HAL_IMPL_MSA_BIN_OP(*, v_float64x2, msa_mulq_f64) +OPENCV_HAL_IMPL_MSA_BIN_OP(/, v_float64x2, msa_divq_f64) + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_MSA_MUL_SAT(_Tpvec, _Tpwvec) \ +inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ +} \ +inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ +{a = a * b; return a; } + +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_MSA_MUL_SAT(v_uint16x8, v_uint32x4) + +// Multiply and expand +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + v16i8 a_lo, a_hi, b_lo, b_hi; + + ILVRL_B2_SB(a.val, msa_dupq_n_s8(0), a_lo, a_hi); + ILVRL_B2_SB(b.val, msa_dupq_n_s8(0), b_lo, b_hi); + c.val = msa_mulq_s16(msa_paddlq_s8(a_lo), msa_paddlq_s8(b_lo)); + d.val = msa_mulq_s16(msa_paddlq_s8(a_hi), msa_paddlq_s8(b_hi)); +} + +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + v16u8 a_lo, a_hi, b_lo, b_hi; + + ILVRL_B2_UB(a.val, msa_dupq_n_u8(0), a_lo, a_hi); + ILVRL_B2_UB(b.val, msa_dupq_n_u8(0), b_lo, b_hi); + c.val = msa_mulq_u16(msa_paddlq_u8(a_lo), msa_paddlq_u8(b_lo)); + d.val = msa_mulq_u16(msa_paddlq_u8(a_hi), msa_paddlq_u8(b_hi)); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + v8i16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_SH(a.val, msa_dupq_n_s16(0), a_lo, a_hi); + ILVRL_H2_SH(b.val, msa_dupq_n_s16(0), b_lo, b_hi); + c.val = msa_mulq_s32(msa_paddlq_s16(a_lo), msa_paddlq_s16(b_lo)); + d.val = msa_mulq_s32(msa_paddlq_s16(a_hi), msa_paddlq_s16(b_hi)); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + v8u16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_UH(a.val, msa_dupq_n_u16(0), a_lo, a_hi); + ILVRL_H2_UH(b.val, msa_dupq_n_u16(0), b_lo, b_hi); + c.val = msa_mulq_u32(msa_paddlq_u16(a_lo), msa_paddlq_u16(b_lo)); + d.val = msa_mulq_u32(msa_paddlq_u16(a_hi), msa_paddlq_u16(b_hi)); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + v4u32 a_lo, a_hi, b_lo, b_hi; + + ILVRL_W2_UW(a.val, msa_dupq_n_u32(0), a_lo, a_hi); + ILVRL_W2_UW(b.val, msa_dupq_n_u32(0), b_lo, b_hi); + c.val = msa_mulq_u64(msa_paddlq_u32(a_lo), msa_paddlq_u32(b_lo)); + d.val = msa_mulq_u64(msa_paddlq_u32(a_hi), msa_paddlq_u32(b_hi)); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + v8i16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_SH(a.val, msa_dupq_n_s16(0), a_lo, a_hi); + ILVRL_H2_SH(b.val, msa_dupq_n_s16(0), b_lo, b_hi); + + return v_int16x8(msa_packr_s32(msa_mulq_s32(msa_paddlq_s16(a_lo), msa_paddlq_s16(b_lo)), + msa_mulq_s32(msa_paddlq_s16(a_hi), msa_paddlq_s16(b_hi)), 16)); +} + +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + v8u16 a_lo, a_hi, b_lo, b_hi; + + ILVRL_H2_UH(a.val, msa_dupq_n_u16(0), a_lo, a_hi); + ILVRL_H2_UH(b.val, msa_dupq_n_u16(0), b_lo, b_hi); + + return v_uint16x8(msa_packr_u32(msa_mulq_u32(msa_paddlq_u16(a_lo), msa_paddlq_u16(b_lo)), + msa_mulq_u32(msa_paddlq_u16(a_hi), msa_paddlq_u16(b_hi)), 16)); +} + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ return v_int32x4(msa_dotp_s_w(a.val, b.val)); } +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_int32x4(msa_dpadd_s_w(c.val , a.val, b.val)); } + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ return v_int64x2(msa_dotp_s_d(a.val, b.val)); } +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_int64x2(msa_dpadd_s_d(c.val , a.val, b.val)); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + v8u16 even_a = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8), 8); + v8u16 odd_a = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8); + v8u16 even_b = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8), 8); + v8u16 odd_b = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8); + v4u32 prod = msa_dotp_u_w(even_a, even_b); + return v_uint32x4(msa_dpadd_u_w(prod, odd_a, odd_b)); +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ + v8u16 even_a = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8), 8); + v8u16 odd_a = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, a.val), 8); + v8u16 even_b = msa_shrq_n_u16(msa_shlq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8), 8); + v8u16 odd_b = msa_shrq_n_u16(MSA_TPV_REINTERPRET(v8u16, b.val), 8); + v4u32 prod = msa_dpadd_u_w(c.val, even_a, even_b); + return v_uint32x4(msa_dpadd_u_w(prod, odd_a, odd_b)); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + v8i16 prod = msa_dotp_s_h(a.val, b.val); + return v_int32x4(msa_hadd_s32(prod, prod)); +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + v4u32 even_a = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16), 16); + v4u32 odd_a = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16); + v4u32 even_b = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16), 16); + v4u32 odd_b = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16); + v2u64 prod = msa_dotp_u_d(even_a, even_b); + return v_uint64x2(msa_dpadd_u_d(prod, odd_a, odd_b)); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, + const v_uint64x2& c) +{ + v4u32 even_a = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16), 16); + v4u32 odd_a = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, a.val), 16); + v4u32 even_b = msa_shrq_n_u32(msa_shlq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16), 16); + v4u32 odd_b = msa_shrq_n_u32(MSA_TPV_REINTERPRET(v4u32, b.val), 16); + v2u64 prod = msa_dpadd_u_d(c.val, even_a, even_b); + return v_uint64x2(msa_dpadd_u_d(prod, odd_a, odd_b)); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v4i32 prod = msa_dotp_s_w(a.val, b.val); + return v_int64x2(msa_hadd_s64(prod, prod)); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b, c); } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b, c); } + +#define OPENCV_HAL_IMPL_MSA_LOGIC_OP(_Tpvec, _Tpv, suffix) \ +OPENCV_HAL_IMPL_MSA_BIN_OP(&, _Tpvec, msa_andq_##suffix) \ +OPENCV_HAL_IMPL_MSA_BIN_OP(|, _Tpvec, msa_orrq_##suffix) \ +OPENCV_HAL_IMPL_MSA_BIN_OP(^, _Tpvec, msa_eorq_##suffix) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_mvnq_u8(MSA_TPV_REINTERPRET(v16u8, a.val)))); \ +} + +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint8x16, v16u8, u8) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int8x16, v16i8, s8) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint16x8, v8u16, u16) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int16x8, v8i16, s16) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint32x4, v4u32, u32) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int32x4, v4i32, s32) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_uint64x2, v2u64, u64) +OPENCV_HAL_IMPL_MSA_LOGIC_OP(v_int64x2, v2i64, s64) + +#define OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(MSA_TPV_REINTERPRET(v4f32, intrin(MSA_TPV_REINTERPRET(v4i32, a.val), MSA_TPV_REINTERPRET(v4i32, b.val)))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a.val = MSA_TPV_REINTERPRET(v4f32, intrin(MSA_TPV_REINTERPRET(v4i32, a.val), MSA_TPV_REINTERPRET(v4i32, b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(&, msa_andq_s32) +OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(|, msa_orrq_s32) +OPENCV_HAL_IMPL_MSA_FLT_BIT_OP(^, msa_eorq_s32) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_mvnq_s32(MSA_TPV_REINTERPRET(v4i32, a.val)))); +} + +/* v_abs */ +#define OPENCV_HAL_IMPL_MSA_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ +inline _Tpuvec v_abs(const _Tpsvec& a) \ +{ \ + return v_reinterpret_as_##usuffix(_Tpsvec(msa_absq_##ssuffix(a.val))); \ +} + +OPENCV_HAL_IMPL_MSA_ABS(v_uint8x16, v_int8x16, u8, s8) +OPENCV_HAL_IMPL_MSA_ABS(v_uint16x8, v_int16x8, u16, s16) +OPENCV_HAL_IMPL_MSA_ABS(v_uint32x4, v_int32x4, u32, s32) + +/* v_abs(float), v_sqrt, v_invsqrt */ +#define OPENCV_HAL_IMPL_MSA_BASIC_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a) \ +{ \ + return _Tpvec(intrin(a.val)); \ +} + +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float32x4, v_abs, msa_absq_f32) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float64x2, v_abs, msa_absq_f64) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float32x4, v_sqrt, msa_sqrtq_f32) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float32x4, v_invsqrt, msa_rsqrtq_f32) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float64x2, v_sqrt, msa_sqrtq_f64) +OPENCV_HAL_IMPL_MSA_BASIC_FUNC(v_float64x2, v_invsqrt, msa_rsqrtq_f64) + +#define OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(MSA_TPV_REINTERPRET(v2f64, intrin(MSA_TPV_REINTERPRET(v2i64, a.val), MSA_TPV_REINTERPRET(v2i64, b.val)))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a.val = MSA_TPV_REINTERPRET(v2f64, intrin(MSA_TPV_REINTERPRET(v2i64, a.val), MSA_TPV_REINTERPRET(v2i64, b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(&, msa_andq_s64) +OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(|, msa_orrq_s64) +OPENCV_HAL_IMPL_MSA_DBL_BIT_OP(^, msa_eorq_s64) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_mvnq_s32(MSA_TPV_REINTERPRET(v4i32, a.val)))); +} + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_MSA_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_min, msa_minq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_max, msa_maxq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_min, msa_minq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_max, msa_maxq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_min, msa_minq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_max, msa_maxq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_min, msa_minq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_max, msa_maxq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint32x4, v_min, msa_minq_u32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint32x4, v_max, msa_maxq_u32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int32x4, v_min, msa_minq_s32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int32x4, v_max, msa_maxq_s32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float32x4, v_min, msa_minq_f32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float32x4, v_max, msa_maxq_f32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float64x2, v_min, msa_minq_f64) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float64x2, v_max, msa_maxq_f64) + +#define OPENCV_HAL_IMPL_MSA_INT_CMP_OP(_Tpvec, _Tpv, suffix, not_suffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_ceqq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_mvnq_##not_suffix(msa_ceqq_##suffix(a.val, b.val)))); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cltq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cgtq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cleq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_cgeq_##suffix(a.val, b.val))); } + +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint8x16, v16u8, u8, u8) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int8x16, v16i8, s8, u8) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint16x8, v8u16, u16, u16) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int16x8, v8i16, s16, u16) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint32x4, v4u32, u32, u32) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int32x4, v4i32, s32, u32) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_float32x4, v4f32, f32, u32) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_uint64x2, v2u64, u64, u64) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_int64x2, v2i64, s64, u64) +OPENCV_HAL_IMPL_MSA_INT_CMP_OP(v_float64x2, v2f64, f64, u64) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ceqq_f32(a.val, a.val))); } +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_ceqq_f64(a.val, a.val))); } + +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_add_wrap, msa_addq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_add_wrap, msa_addq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_add_wrap, msa_addq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_add_wrap, msa_addq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_sub_wrap, msa_subq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_sub_wrap, msa_subq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_sub_wrap, msa_subq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_sub_wrap, msa_subq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_mul_wrap, msa_mulq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_mul_wrap, msa_mulq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_mul_wrap, msa_mulq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_mul_wrap, msa_mulq_s16) + +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint8x16, v_absdiff, msa_abdq_u8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint16x8, v_absdiff, msa_abdq_u16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_uint32x4, v_absdiff, msa_abdq_u32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float32x4, v_absdiff, msa_abdq_f32) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_float64x2, v_absdiff, msa_abdq_f64) + +/** Saturating absolute difference **/ +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int8x16, v_absdiffs, msa_qabdq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC(v_int16x8, v_absdiffs, msa_qabdq_s16) + +#define OPENCV_HAL_IMPL_MSA_BIN_FUNC2(_Tpvec, _Tpvec2, _Tpv, func, intrin) \ +inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec2(MSA_TPV_REINTERPRET(_Tpv, intrin(a.val, b.val))); \ +} + +OPENCV_HAL_IMPL_MSA_BIN_FUNC2(v_int8x16, v_uint8x16, v16u8, v_absdiff, msa_abdq_s8) +OPENCV_HAL_IMPL_MSA_BIN_FUNC2(v_int16x8, v_uint16x8, v8u16, v_absdiff, msa_abdq_s16) +OPENCV_HAL_IMPL_MSA_BIN_FUNC2(v_int32x4, v_uint32x4, v4u32, v_absdiff, msa_abdq_s32) + +/* v_magnitude, v_sqr_magnitude, v_fma, v_muladd */ +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(msa_mlaq_f32(msa_mulq_f32(a.val, a.val), b.val, b.val)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(msa_mlaq_f32(msa_mulq_f32(a.val, a.val), b.val, b.val)); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_float32x4(msa_mlaq_f32(c.val, a.val, b.val)); +} + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(msa_mlaq_s32(c.val, a.val, b.val)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(msa_mlaq_f64(msa_mulq_f64(a.val, a.val), b.val, b.val)); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(msa_mlaq_f64(msa_mulq_f64(a.val, a.val), b.val, b.val)); +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(msa_mlaq_f64(c.val, a.val, b.val)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} + +// trade efficiency for convenience +#define OPENCV_HAL_IMPL_MSA_SHIFT_OP(_Tpvec, suffix, _Tps, ssuffix) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ return _Tpvec(msa_shlq_##suffix(a.val, msa_dupq_n_##ssuffix((_Tps)n))); } \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ return _Tpvec(msa_shrq_##suffix(a.val, msa_dupq_n_##ssuffix((_Tps)n))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec(msa_shlq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec(msa_shrq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_rshr(const _Tpvec& a) \ +{ return _Tpvec(msa_rshrq_n_##suffix(a.val, n)); } + +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint8x16, u8, schar, s8) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int8x16, s8, schar, s8) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint16x8, u16, short, s16) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int16x8, s16, short, s16) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint32x4, u32, int, s32) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int32x4, s32, int, s32) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_uint64x2, u64, int64, s64) +OPENCV_HAL_IMPL_MSA_SHIFT_OP(v_int64x2, s64, int64, s64) + +/* v_rotate_right, v_rotate_left */ +#define OPENCV_HAL_IMPL_MSA_ROTATE_OP(_Tpvec, _Tpv, _Tpvs, suffix) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##suffix(0), n))); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(msa_dupq_n_##suffix(0), MSA_TPV_REINTERPRET(_Tpvs, a.val), _Tpvec::nlanes - n))); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ \ + return a; \ +} \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), MSA_TPV_REINTERPRET(_Tpvs, b.val), n))); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, b.val), MSA_TPV_REINTERPRET(_Tpvs, a.val), _Tpvec::nlanes - n))); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ \ + CV_UNUSED(b); \ + return a; \ +} + +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint8x16, v16u8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int8x16, v16i8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint16x8, v8u16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int16x8, v8i16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_float32x4, v4f32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_uint64x2, v2u64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_int64x2, v2i64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_ROTATE_OP(v_float64x2, v2f64, v2i64, s64) + +#define OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(msa_ld1q_##suffix(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(msa_ld1q_##suffix(ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(msa_combine_##suffix(msa_ld1_##suffix(ptr), msa_dup_n_##suffix((_Tp)0))); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ return _Tpvec(msa_combine_##suffix(msa_ld1_##suffix(ptr0), msa_ld1_##suffix(ptr1))); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ msa_st1q_##suffix(ptr, a.val); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ \ + int n = _Tpvec::nlanes; \ + for( int i = 0; i < (n/2); i++ ) \ + ptr[i] = a.val[i]; \ +} \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + int n = _Tpvec::nlanes; \ + for( int i = 0; i < (n/2); i++ ) \ + ptr[i] = a.val[i+(n/2)]; \ +} + +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_float32x4, float, f32) +OPENCV_HAL_IMPL_MSA_LOADSTORE_OP(v_float64x2, double, f64) + + +/** Reverse **/ +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + v_uint8x16 c = v_uint8x16((v16u8)__builtin_msa_vshf_b((v16i8)((v2i64){0x08090A0B0C0D0E0F, 0x0001020304050607}), msa_dupq_n_s8(0), (v16i8)a.val)); + return c; +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + v_uint16x8 c = v_uint16x8((v8u16)__builtin_msa_vshf_h((v8i16)((v2i64){0x0004000500060007, 0x0000000100020003}), msa_dupq_n_s16(0), (v8i16)a.val)); + return c; +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + v_uint32x4 c; + c.val[0] = a.val[3]; + c.val[1] = a.val[2]; + c.val[2] = a.val[1]; + c.val[3] = a.val[0]; + return c; +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + v_uint64x2 c; + c.val[0] = a.val[1]; + c.val[1] = a.val[0]; + return c; +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_8U(func, cfunc) \ +inline unsigned short v_reduce_##func(const v_uint16x8& a) \ +{ \ + v8u16 a_lo, a_hi; \ + ILVRL_H2_UH(a.val, msa_dupq_n_u16(0), a_lo, a_hi); \ + v4u32 b = msa_##func##q_u32(msa_paddlq_u16(a_lo), msa_paddlq_u16(a_hi)); \ + v4u32 b_lo, b_hi; \ + ILVRL_W2_UW(b, msa_dupq_n_u32(0), b_lo, b_hi); \ + v2u64 c = msa_##func##q_u64(msa_paddlq_u32(b_lo), msa_paddlq_u32(b_hi)); \ + return (unsigned short)cfunc(c[0], c[1]); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8U(max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8U(min, std::min) + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_8S(func, cfunc) \ +inline short v_reduce_##func(const v_int16x8& a) \ +{ \ + v8i16 a_lo, a_hi; \ + ILVRL_H2_SH(a.val, msa_dupq_n_s16(0), a_lo, a_hi); \ + v4i32 b = msa_##func##q_s32(msa_paddlq_s16(a_lo), msa_paddlq_s16(a_hi)); \ + v4i32 b_lo, b_hi; \ + ILVRL_W2_SW(b, msa_dupq_n_s32(0), b_lo, b_hi); \ + v2i64 c = msa_##func##q_s64(msa_paddlq_s32(b_lo), msa_paddlq_s32(b_hi)); \ + return (short)cfunc(c[0], c[1]); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8S(max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_8S(min, std::min) + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(_Tpvec, scalartype, func, cfunc) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return (scalartype)cfunc(cfunc(a.val[0], a.val[1]), cfunc(a.val[2], a.val[3])); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_int32x4, int, max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_int32x4, int, min, std::min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_float32x4, float, max, std::max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_4(v_float32x4, float, min, std::min) + + +#define OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(_Tpvec, scalartype, _Tpvec2, func) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpvec2 a1, a2; \ + v_expand(a, a1, a2); \ + return (scalartype)v_reduce_##func(v_##func(a1, a2)); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_uint8x16, uchar, v_uint16x8, min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_uint8x16, uchar, v_uint16x8, max) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_int8x16, char, v_int16x8, min) +OPENCV_HAL_IMPL_MSA_REDUCE_OP_16(v_int8x16, char, v_int16x8, max) + + + +#define OPENCV_HAL_IMPL_MSA_REDUCE_SUM(_Tpvec, scalartype, suffix) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + return (scalartype)msa_sum_##suffix(a.val); \ +} + +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_uint8x16, unsigned char, u8) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_int8x16, char, s8) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_uint16x8, unsigned short, u16) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_REDUCE_SUM(v_float32x4, float, f32) + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ return (uint64)(msa_getq_lane_u64(a.val, 0) + msa_getq_lane_u64(a.val, 1)); } +inline int64 v_reduce_sum(const v_int64x2& a) +{ return (int64)(msa_getq_lane_s64(a.val, 0) + msa_getq_lane_s64(a.val, 1)); } +inline double v_reduce_sum(const v_float64x2& a) +{ + return msa_getq_lane_f64(a.val, 0) + msa_getq_lane_f64(a.val, 1); +} + +/* v_reduce_sum4, v_reduce_sad */ +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + v4f32 u0 = msa_addq_f32(MSA_TPV_REINTERPRET(v4f32, msa_ilvevq_s32(MSA_TPV_REINTERPRET(v4i32, b.val), MSA_TPV_REINTERPRET(v4i32, a.val))), + MSA_TPV_REINTERPRET(v4f32, msa_ilvodq_s32(MSA_TPV_REINTERPRET(v4i32, b.val), MSA_TPV_REINTERPRET(v4i32, a.val)))); // a0+a1 b0+b1 a2+a3 b2+b3 + v4f32 u1 = msa_addq_f32(MSA_TPV_REINTERPRET(v4f32, msa_ilvevq_s32(MSA_TPV_REINTERPRET(v4i32, d.val), MSA_TPV_REINTERPRET(v4i32, c.val))), + MSA_TPV_REINTERPRET(v4f32, msa_ilvodq_s32(MSA_TPV_REINTERPRET(v4i32, d.val), MSA_TPV_REINTERPRET(v4i32, c.val)))); // c0+c1 d0+d1 c2+c3 d2+d3 + + return v_float32x4(msa_addq_f32(MSA_TPV_REINTERPRET(v4f32, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, u1), MSA_TPV_REINTERPRET(v2i64, u0))), + MSA_TPV_REINTERPRET(v4f32, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, u1), MSA_TPV_REINTERPRET(v2i64, u0))))); +} + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + v16u8 t0 = msa_abdq_u8(a.val, b.val); + v8u16 t1 = msa_paddlq_u8(t0); + v4u32 t2 = msa_paddlq_u16(t1); + return msa_sum_u32(t2); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + v16u8 t0 = MSA_TPV_REINTERPRET(v16u8, msa_abdq_s8(a.val, b.val)); + v8u16 t1 = msa_paddlq_u8(t0); + v4u32 t2 = msa_paddlq_u16(t1); + return msa_sum_u32(t2); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + v8u16 t0 = msa_abdq_u16(a.val, b.val); + v4u32 t1 = msa_paddlq_u16(t0); + return msa_sum_u32(t1); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + v8u16 t0 = MSA_TPV_REINTERPRET(v8u16, msa_abdq_s16(a.val, b.val)); + v4u32 t1 = msa_paddlq_u16(t0); + return msa_sum_u32(t1); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + v4u32 t0 = msa_abdq_u32(a.val, b.val); + return msa_sum_u32(t0); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + v4u32 t0 = MSA_TPV_REINTERPRET(v4u32, msa_abdq_s32(a.val, b.val)); + return msa_sum_u32(t0); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + v4f32 t0 = msa_abdq_f32(a.val, b.val); + return msa_sum_f32(t0); +} + +/* v_popcount */ +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE8(_Tpvec) \ +inline v_uint8x16 v_popcount(const _Tpvec& a) \ +{ \ + v16u8 t = MSA_TPV_REINTERPRET(v16u8, msa_cntq_s8(MSA_TPV_REINTERPRET(v16i8, a.val))); \ + return v_uint8x16(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE8(v_uint8x16) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE8(v_int8x16) + +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE16(_Tpvec) \ +inline v_uint16x8 v_popcount(const _Tpvec& a) \ +{ \ + v8u16 t = MSA_TPV_REINTERPRET(v8u16, msa_cntq_s16(MSA_TPV_REINTERPRET(v8i16, a.val))); \ + return v_uint16x8(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE16(v_uint16x8) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE16(v_int16x8) + +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE32(_Tpvec) \ +inline v_uint32x4 v_popcount(const _Tpvec& a) \ +{ \ + v4u32 t = MSA_TPV_REINTERPRET(v4u32, msa_cntq_s32(MSA_TPV_REINTERPRET(v4i32, a.val))); \ + return v_uint32x4(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE32(v_uint32x4) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE32(v_int32x4) + +#define OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE64(_Tpvec) \ +inline v_uint64x2 v_popcount(const _Tpvec& a) \ +{ \ + v2u64 t = MSA_TPV_REINTERPRET(v2u64, msa_cntq_s64(MSA_TPV_REINTERPRET(v2i64, a.val))); \ + return v_uint64x2(t); \ +} +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE64(v_uint64x2) +OPENCV_HAL_IMPL_MSA_POPCOUNT_SIZE64(v_int64x2) + +inline int v_signmask(const v_uint8x16& a) +{ + v8i8 m0 = msa_create_s8(CV_BIG_UINT(0x0706050403020100)); + v16u8 v0 = msa_shlq_u8(msa_shrq_n_u8(a.val, 7), msa_combine_s8(m0, m0)); + v8u16 v1 = msa_paddlq_u8(v0); + v4u32 v2 = msa_paddlq_u16(v1); + v2u64 v3 = msa_paddlq_u32(v2); + return (int)msa_getq_lane_u64(v3, 0) + ((int)msa_getq_lane_u64(v3, 1) << 8); +} +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } + +inline int v_signmask(const v_uint16x8& a) +{ + v4i16 m0 = msa_create_s16(CV_BIG_UINT(0x0003000200010000)); + v8u16 v0 = msa_shlq_u16(msa_shrq_n_u16(a.val, 15), msa_combine_s16(m0, m0)); + v4u32 v1 = msa_paddlq_u16(v0); + v2u64 v2 = msa_paddlq_u32(v1); + return (int)msa_getq_lane_u64(v2, 0) + ((int)msa_getq_lane_u64(v2, 1) << 4); +} +inline int v_signmask(const v_int16x8& a) +{ return v_signmask(v_reinterpret_as_u16(a)); } + +inline int v_signmask(const v_uint32x4& a) +{ + v2i32 m0 = msa_create_s32(CV_BIG_UINT(0x0000000100000000)); + v4u32 v0 = msa_shlq_u32(msa_shrq_n_u32(a.val, 31), msa_combine_s32(m0, m0)); + v2u64 v1 = msa_paddlq_u32(v0); + return (int)msa_getq_lane_u64(v1, 0) + ((int)msa_getq_lane_u64(v1, 1) << 2); +} +inline int v_signmask(const v_int32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } + +inline int v_signmask(const v_uint64x2& a) +{ + v2u64 v0 = msa_shrq_n_u64(a.val, 63); + return (int)msa_getq_lane_u64(v0, 0) + ((int)msa_getq_lane_u64(v0, 1) << 1); +} +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(a)); } + +#define OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(_Tpvec, _Tpvec2, suffix, shift) \ +inline bool v_check_all(const v_##_Tpvec& a) \ +{ \ + _Tpvec2 v0 = msa_shrq_n_##suffix(msa_mvnq_##suffix(a.val), shift); \ + v2u64 v1 = MSA_TPV_REINTERPRET(v2u64, v0); \ + return (msa_getq_lane_u64(v1, 0) | msa_getq_lane_u64(v1, 1)) == 0; \ +} \ +inline bool v_check_any(const v_##_Tpvec& a) \ +{ \ + _Tpvec2 v0 = msa_shrq_n_##suffix(a.val, shift); \ + v2u64 v1 = MSA_TPV_REINTERPRET(v2u64, v0); \ + return (msa_getq_lane_u64(v1, 0) | msa_getq_lane_u64(v1, 1)) != 0; \ +} + +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint8x16, v16u8, u8, 7) +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint16x8, v8u16, u16, 15) +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint32x4, v4u32, u32, 31) +OPENCV_HAL_IMPL_MSA_CHECK_ALLANY(uint64x2, v2u64, u64, 63) + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } + +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } + +/* v_select */ +#define OPENCV_HAL_IMPL_MSA_SELECT(_Tpvec, _Tpv, _Tpvu) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_bslq_u8(MSA_TPV_REINTERPRET(_Tpvu, mask.val), \ + MSA_TPV_REINTERPRET(_Tpvu, b.val), MSA_TPV_REINTERPRET(_Tpvu, a.val)))); \ +} + +OPENCV_HAL_IMPL_MSA_SELECT(v_uint8x16, v16u8, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_int8x16, v16i8, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_uint16x8, v8u16, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_int16x8, v8i16, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_uint32x4, v4u32, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_int32x4, v4i32, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_float32x4, v4f32, v16u8) +OPENCV_HAL_IMPL_MSA_SELECT(v_float64x2, v2f64, v16u8) + +#define OPENCV_HAL_IMPL_MSA_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix, ssuffix, _Tpv, _Tpvs) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + _Tpv a_lo = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + _Tpv a_hi = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + b0.val = msa_paddlq_##suffix(a_lo); \ + b1.val = msa_paddlq_##suffix(a_hi); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + _Tpv a_lo = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + return _Tpwvec(msa_paddlq_##suffix(a_lo)); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + _Tpv a_hi = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), msa_dupq_n_##ssuffix(0))); \ + return _Tpwvec(msa_paddlq_##suffix(a_hi)); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(msa_movl_##suffix(msa_ld1_##suffix(ptr))); \ +} + +OPENCV_HAL_IMPL_MSA_EXPAND(v_uint8x16, v_uint16x8, uchar, u8, s8, v16u8, v16i8) +OPENCV_HAL_IMPL_MSA_EXPAND(v_int8x16, v_int16x8, schar, s8, s8, v16i8, v16i8) +OPENCV_HAL_IMPL_MSA_EXPAND(v_uint16x8, v_uint32x4, ushort, u16, s16, v8u16, v8i16) +OPENCV_HAL_IMPL_MSA_EXPAND(v_int16x8, v_int32x4, short, s16, s16, v8i16, v8i16) +OPENCV_HAL_IMPL_MSA_EXPAND(v_uint32x4, v_uint64x2, uint, u32, s32, v4u32, v4i32) +OPENCV_HAL_IMPL_MSA_EXPAND(v_int32x4, v_int64x2, int, s32, s32, v4i32, v4i32) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + return v_uint32x4((v4u32){ptr[0], ptr[1], ptr[2], ptr[3]}); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + return v_int32x4((v4i32){ptr[0], ptr[1], ptr[2], ptr[3]}); +} + +/* v_zip, v_combine_low, v_combine_high, v_recombine */ +#define OPENCV_HAL_IMPL_MSA_UNPACKS(_Tpvec, _Tpv, _Tpvs, ssuffix) \ +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) \ +{ \ + b0.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ + b1.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ +} \ +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val)))); \ +} \ +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val)))); \ +} \ +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) \ +{ \ + c.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val))); \ + d.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, b.val), MSA_TPV_REINTERPRET(v2i64, a.val))); \ +} + +OPENCV_HAL_IMPL_MSA_UNPACKS(v_uint8x16, v16u8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_int8x16, v16i8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_uint16x8, v8u16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_int16x8, v8i16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_float32x4, v4f32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_UNPACKS(v_float64x2, v2f64, v2i64, s64) + +/* v_extract */ +#define OPENCV_HAL_IMPL_MSA_EXTRACT(_Tpvec, _Tpv, _Tpvs, suffix) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(MSA_TPV_REINTERPRET(_Tpv, msa_extq_##suffix(MSA_TPV_REINTERPRET(_Tpvs, a.val), MSA_TPV_REINTERPRET(_Tpvs, b.val), s))); \ +} + +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint8x16, v16u8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int8x16, v16i8, v16i8, s8) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint16x8, v8u16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int16x8, v8i16, v8i16, s16) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_uint64x2, v2u64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_int64x2, v2i64, v2i64, s64) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_float32x4, v4f32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_EXTRACT(v_float64x2, v2f64, v2i64, s64) + +/* v_round, v_floor, v_ceil, v_trunc */ +inline v_int32x4 v_round(const v_float32x4& a) +{ + return v_int32x4(msa_cvttintq_s32_f32(a.val)); +} + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + v4i32 a1 = msa_cvttintq_s32_f32(a.val); + return v_int32x4(msa_addq_s32(a1, MSA_TPV_REINTERPRET(v4i32, msa_cgtq_f32(msa_cvtfintq_f32_s32(a1), a.val)))); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + v4i32 a1 = msa_cvttintq_s32_f32(a.val); + return v_int32x4(msa_subq_s32(a1, MSA_TPV_REINTERPRET(v4i32, msa_cgtq_f32(a.val, msa_cvtfintq_f32_s32(a1))))); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ + return v_int32x4(msa_cvttruncq_s32_f32(a.val)); +} + +inline v_int32x4 v_round(const v_float64x2& a) +{ + return v_int32x4(msa_pack_s64(msa_cvttintq_s64_f64(a.val), msa_dupq_n_s64(0))); +} + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + return v_int32x4(msa_pack_s64(msa_cvttintq_s64_f64(a.val), msa_cvttintq_s64_f64(b.val))); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + v2f64 a1 = msa_cvtrintq_f64(a.val); + return v_int32x4(msa_pack_s64(msa_addq_s64(msa_cvttruncq_s64_f64(a1), MSA_TPV_REINTERPRET(v2i64, msa_cgtq_f64(a1, a.val))), msa_dupq_n_s64(0))); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + v2f64 a1 = msa_cvtrintq_f64(a.val); + return v_int32x4(msa_pack_s64(msa_subq_s64(msa_cvttruncq_s64_f64(a1), MSA_TPV_REINTERPRET(v2i64, msa_cgtq_f64(a.val, a1))), msa_dupq_n_s64(0))); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + return v_int32x4(msa_pack_s64(msa_cvttruncq_s64_f64(a.val), msa_dupq_n_s64(0))); +} + +#define OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(_Tpvec, _Tpv, _Tpvs, ssuffix) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, \ + _Tpvec& b2, _Tpvec& b3) \ +{ \ + _Tpv t00 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ + _Tpv t01 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a1.val), MSA_TPV_REINTERPRET(_Tpvs, a0.val))); \ + _Tpv t10 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a3.val), MSA_TPV_REINTERPRET(_Tpvs, a2.val))); \ + _Tpv t11 = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_##ssuffix(MSA_TPV_REINTERPRET(_Tpvs, a3.val), MSA_TPV_REINTERPRET(_Tpvs, a2.val))); \ + b0.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, t10), MSA_TPV_REINTERPRET(v2i64, t00))); \ + b1.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, t10), MSA_TPV_REINTERPRET(v2i64, t00))); \ + b2.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvrq_s64(MSA_TPV_REINTERPRET(v2i64, t11), MSA_TPV_REINTERPRET(v2i64, t01))); \ + b3.val = MSA_TPV_REINTERPRET(_Tpv, msa_ilvlq_s64(MSA_TPV_REINTERPRET(v2i64, t11), MSA_TPV_REINTERPRET(v2i64, t01))); \ +} + +OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(v_uint32x4, v4u32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(v_int32x4, v4i32, v4i32, s32) +OPENCV_HAL_IMPL_MSA_TRANSPOSE4x4(v_float32x4, v4f32, v4i32, s32) + +#define OPENCV_HAL_IMPL_MSA_INTERLEAVED(_Tpvec, _Tp, suffix) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ +{ \ + msa_ld2q_##suffix(ptr, &a.val, &b.val); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ +{ \ + msa_ld3q_##suffix(ptr, &a.val, &b.val, &c.val); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ + v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + msa_ld4q_##suffix(ptr, &a.val, &b.val, &c.val, &d.val); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + msa_st2q_##suffix(ptr, a.val, b.val); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + msa_st3q_##suffix(ptr, a.val, b.val, c.val); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, const v_##_Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + msa_st4q_##suffix(ptr, a.val, b.val, c.val, d.val); \ +} + +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int8x16, schar, s8) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int16x8, short, s16) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int32x4, int, s32) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(float32x4, float, f32) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(uint64x2, uint64, u64) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(int64x2, int64, s64) +OPENCV_HAL_IMPL_MSA_INTERLEAVED(float64x2, double, f64) + +/* v_cvt_f32, v_cvt_f64, v_cvt_f64_high */ +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(msa_cvtfintq_f32_s32(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + return v_float32x4(msa_cvtfq_f32_f64(a.val, msa_dupq_n_f64(0.0f))); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + return v_float32x4(msa_cvtfq_f32_f64(a.val, b.val)); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + return v_float64x2(msa_cvtflq_f64_f32(msa_cvtfintq_f32_s32(a.val))); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + return v_float64x2(msa_cvtfhq_f64_f32(msa_cvtfintq_f32_s32(a.val))); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + return v_float64x2(msa_cvtflq_f64_f32(a.val)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + return v_float64x2(msa_cvtfhq_f64_f32(a.val)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ + return v_float64x2(msa_cvtfintq_f64_s64(a.val)); +} + +////////////// Lookup table access //////////////////// +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(msa_ld1q_s8(elems)); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(msa_ld1q_s8(elems)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(msa_ld1q_s8(elems)); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(msa_ld1q_s16(elems)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(msa_ld1q_s16(elems)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(msa_combine_s16(msa_ld1_s16(tab + idx[0]), msa_ld1_s16(tab + idx[1]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(msa_ld1q_s32(elems)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(msa_combine_s32(msa_ld1_s32(tab + idx[0]), msa_ld1_s32(tab + idx[1]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(msa_ld1q_s32(tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(msa_combine_s64(msa_create_s64(tab[idx[0]]), msa_create_s64(tab[idx[1]]))); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(msa_ld1q_s64(tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(msa_ld1q_f32(elems)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + uint64 CV_DECL_ALIGNED(32) elems[2] = + { + *(uint64*)(tab + idx[0]), + *(uint64*)(tab + idx[1]) + }; + return v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ld1q_u64(elems))); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(msa_ld1q_f32(tab + idx[0])); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + return v_int32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned CV_DECL_ALIGNED(32) elems[4] = + { + tab[msa_getq_lane_s32(idxvec.val, 0)], + tab[msa_getq_lane_s32(idxvec.val, 1)], + tab[msa_getq_lane_s32(idxvec.val, 2)], + tab[msa_getq_lane_s32(idxvec.val, 3)] + }; + return v_uint32x4(msa_ld1q_u32(elems)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + v4f32 xy02 = msa_combine_f32(msa_ld1_f32(tab + idx[0]), msa_ld1_f32(tab + idx[2])); + v4f32 xy13 = msa_combine_f32(msa_ld1_f32(tab + idx[1]), msa_ld1_f32(tab + idx[3])); + x = v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ilvevq_s32(MSA_TPV_REINTERPRET(v4i32, xy13), MSA_TPV_REINTERPRET(v4i32, xy02)))); + y = v_float32x4(MSA_TPV_REINTERPRET(v4f32, msa_ilvodq_s32(MSA_TPV_REINTERPRET(v4i32, xy13), MSA_TPV_REINTERPRET(v4i32, xy02)))); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + v_int8x16 c = v_int8x16(__builtin_msa_vshf_b((v16i8)((v2i64){0x0705060403010200, 0x0F0D0E0C0B090A08}), msa_dupq_n_s8(0), vec.val)); + return c; +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + v_int8x16 c = v_int8x16(__builtin_msa_vshf_b((v16i8)((v2i64){0x0703060205010400, 0x0F0B0E0A0D090C08}), msa_dupq_n_s8(0), vec.val)); + return c; +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + v_int16x8 c = v_int16x8(__builtin_msa_vshf_h((v8i16)((v2i64){0x0003000100020000, 0x0007000500060004}), msa_dupq_n_s16(0), vec.val)); + return c; +} + +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } + +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + v_int16x8 c = v_int16x8(__builtin_msa_vshf_h((v8i16)((v2i64){0x0005000100040000, 0x0007000300060002}), msa_dupq_n_s16(0), vec.val)); + return c; +} + +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + v_int32x4 c; + c.val[0] = vec.val[0]; + c.val[1] = vec.val[2]; + c.val[2] = vec.val[1]; + c.val[3] = vec.val[3]; + return c; +} + +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + v_int8x16 c = v_int8x16(__builtin_msa_vshf_b((v16i8)((v2i64){0x0908060504020100, 0x131211100E0D0C0A}), msa_dupq_n_s8(0), vec.val)); + return c; +} + +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + v_int16x8 c = v_int16x8(__builtin_msa_vshf_h((v8i16)((v2i64){0x0004000200010000, 0x0009000800060005}), msa_dupq_n_s16(0), vec.val)); + return c; +} + +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + double CV_DECL_ALIGNED(32) elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_float64x2(msa_ld1q_f64(elems)); +} + +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(msa_ld1q_f64(tab + idx[0])); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + v2f64 xy0 = msa_ld1q_f64(tab + idx[0]); + v2f64 xy1 = msa_ld1q_f64(tab + idx[1]); + x = v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_ilvevq_s64(MSA_TPV_REINTERPRET(v2i64, xy1), MSA_TPV_REINTERPRET(v2i64, xy0)))); + y = v_float64x2(MSA_TPV_REINTERPRET(v2f64, msa_ilvodq_s64(MSA_TPV_REINTERPRET(v2i64, xy1), MSA_TPV_REINTERPRET(v2i64, xy0)))); +} + +template +inline typename _Tp::lane_type v_extract_n(const _Tp& a) +{ + return v_rotate_right(a).get0(); +} + +template +inline v_uint32x4 v_broadcast_element(const v_uint32x4& a) +{ + return v_setall_u32(v_extract_n(a)); +} +template +inline v_int32x4 v_broadcast_element(const v_int32x4& a) +{ + return v_setall_s32(v_extract_n(a)); +} +template +inline v_float32x4 v_broadcast_element(const v_float32x4& a) +{ + return v_setall_f32(v_extract_n(a)); +} + +////// FP16 support /////// +#if CV_FP16 +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ +#ifndef msa_ld1_f16 + v4f16 v = (v4f16)msa_ld1_s16((const short*)ptr); +#else + v4f16 v = msa_ld1_f16((const __fp16*)ptr); +#endif + return v_float32x4(msa_cvt_f32_f16(v)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + v4f16 hv = msa_cvt_f16_f32(v.val); + +#ifndef msa_st1_f16 + msa_st1_s16((short*)ptr, (int16x4_t)hv); +#else + msa_st1_f16((__fp16*)ptr, hv); +#endif +} +#else +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + float buf[4]; + for( int i = 0; i < 4; i++ ) + buf[i] = (float)ptr[i]; + return v_load(buf); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + float buf[4]; + v_store(buf, v); + for( int i = 0; i < 4; i++ ) + ptr[i] = (float16_t)buf[i]; +} +#endif + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_neon.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_neon.hpp new file mode 100644 index 0000000..e17972a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_neon.hpp @@ -0,0 +1,2613 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_INTRIN_NEON_HPP +#define OPENCV_HAL_INTRIN_NEON_HPP + +#include +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 +#if defined(__aarch64__) || defined(_M_ARM64) +#define CV_SIMD128_64F 1 +#else +#define CV_SIMD128_64F 0 +#endif + +// The following macro checks if the code is being compiled for the +// AArch64 execution state of Armv8, to enable the 128-bit +// intrinsics. The macro `__ARM_64BIT_STATE` is the one recommended by +// the Arm C Language Extension (ACLE) specifications [1] to check the +// availability of 128-bit intrinsics, and it is supporrted by clang +// and gcc. The macro `_M_ARM64` is the equivalent one for Microsoft +// Visual Studio [2] . +// +// [1] https://developer.arm.com/documentation/101028/0012/13--Advanced-SIMD--Neon--intrinsics +// [2] https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros +#if defined(__ARM_64BIT_STATE) || defined(_M_ARM64) +#define CV_NEON_AARCH64 1 +#else +#define CV_NEON_AARCH64 0 +#endif + +// TODO +#define CV_NEON_DOT 0 + +//////////// Utils //////////// + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv& a, const _Tpv& b, _Tpv& c, _Tpv& d) \ + { c = vuzp1q_##suffix(a, b); d = vuzp2q_##suffix(a, b); } +#define OPENCV_HAL_IMPL_NEON_UNZIP_L(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv&a, const _Tpv&b, _Tpv& c, _Tpv& d) \ + { c = vuzp1_##suffix(a, b); d = vuzp2_##suffix(a, b); } +#else +#define OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv& a, const _Tpv& b, _Tpv& c, _Tpv& d) \ + { _Tpvx2 ab = vuzpq_##suffix(a, b); c = ab.val[0]; d = ab.val[1]; } +#define OPENCV_HAL_IMPL_NEON_UNZIP_L(_Tpv, _Tpvx2, suffix) \ + inline void _v128_unzip(const _Tpv& a, const _Tpv& b, _Tpv& c, _Tpv& d) \ + { _Tpvx2 ab = vuzp_##suffix(a, b); c = ab.val[0]; d = ab.val[1]; } +#endif + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) \ + template static inline \ + _Tpv vreinterpretq_##suffix##_f64(T a) { return (_Tpv) a; } \ + template static inline \ + float64x2_t vreinterpretq_f64_##suffix(T a) { return (float64x2_t) a; } +#else +#define OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv, suffix) +#endif + +#define OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(_Tpv, _Tpvl, suffix) \ + OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv##_t, _Tpv##x2_t, suffix) \ + OPENCV_HAL_IMPL_NEON_UNZIP_L(_Tpvl##_t, _Tpvl##x2_t, suffix) \ + OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv##_t, suffix) + +#define OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_I64(_Tpv, _Tpvl, suffix) \ + OPENCV_HAL_IMPL_NEON_REINTERPRET(_Tpv##_t, suffix) + +#define OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_F64(_Tpv, _Tpvl, suffix) \ + OPENCV_HAL_IMPL_NEON_UNZIP(_Tpv##_t, _Tpv##x2_t, suffix) + +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(uint8x16, uint8x8, u8) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(int8x16, int8x8, s8) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(uint16x8, uint16x4, u16) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(int16x8, int16x4, s16) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(uint32x4, uint32x2, u32) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(int32x4, int32x2, s32) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX(float32x4, float32x2, f32) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_I64(uint64x2, uint64x1, u64) +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_I64(int64x2, int64x1, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_UTILS_SUFFIX_F64(float64x2, float64x1,f64) +#endif + +//////////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(uint8x16_t v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = vld1q_u8(v); + } + uchar get0() const + { + return vgetq_lane_u8(val, 0); + } + + uint8x16_t val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(int8x16_t v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = vld1q_s8(v); + } + schar get0() const + { + return vgetq_lane_s8(val, 0); + } + + int8x16_t val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(uint16x8_t v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = vld1q_u16(v); + } + ushort get0() const + { + return vgetq_lane_u16(val, 0); + } + + uint16x8_t val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(int16x8_t v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = vld1q_s16(v); + } + short get0() const + { + return vgetq_lane_s16(val, 0); + } + + int16x8_t val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(uint32x4_t v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + val = vld1q_u32(v); + } + unsigned get0() const + { + return vgetq_lane_u32(val, 0); + } + + uint32x4_t val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(int32x4_t v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = vld1q_s32(v); + } + int get0() const + { + return vgetq_lane_s32(val, 0); + } + int32x4_t val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(float32x4_t v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = vld1q_f32(v); + } + float get0() const + { + return vgetq_lane_f32(val, 0); + } + float32x4_t val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(uint64x2_t v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = vld1q_u64(v); + } + uint64 get0() const + { + return vgetq_lane_u64(val, 0); + } + uint64x2_t val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(int64x2_t v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = vld1q_s64(v); + } + int64 get0() const + { + return vgetq_lane_s64(val, 0); + } + int64x2_t val; +}; + +#if CV_SIMD128_64F +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(float64x2_t v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = vld1q_f64(v); + } + double get0() const + { + return vgetq_lane_f64(val, 0); + } + float64x2_t val; +}; +#endif + +#define OPENCV_HAL_IMPL_NEON_INIT(_Tpv, _Tp, suffix) \ +inline v_##_Tpv v_setzero_##suffix() { return v_##_Tpv(vdupq_n_##suffix((_Tp)0)); } \ +inline v_##_Tpv v_setall_##suffix(_Tp v) { return v_##_Tpv(vdupq_n_##suffix(v)); } \ +inline _Tpv##_t vreinterpretq_##suffix##_##suffix(_Tpv##_t v) { return v; } \ +inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16(vreinterpretq_u8_##suffix(v.val)); } \ +inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16(vreinterpretq_s8_##suffix(v.val)); } \ +inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8(vreinterpretq_u16_##suffix(v.val)); } \ +inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8(vreinterpretq_s16_##suffix(v.val)); } \ +inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4(vreinterpretq_u32_##suffix(v.val)); } \ +inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4(vreinterpretq_s32_##suffix(v.val)); } \ +inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2(vreinterpretq_u64_##suffix(v.val)); } \ +inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2(vreinterpretq_s64_##suffix(v.val)); } \ +inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4(vreinterpretq_f32_##suffix(v.val)); } + +OPENCV_HAL_IMPL_NEON_INIT(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_INIT(int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_INIT(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_INIT(int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_INIT(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_NEON_INIT(int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_INIT(uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_INIT(int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_INIT(float32x4, float, f32) +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_INIT_64(_Tpv, suffix) \ +inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2(vreinterpretq_f64_##suffix(v.val)); } +OPENCV_HAL_IMPL_NEON_INIT(float64x2, double, f64) +OPENCV_HAL_IMPL_NEON_INIT_64(uint8x16, u8) +OPENCV_HAL_IMPL_NEON_INIT_64(int8x16, s8) +OPENCV_HAL_IMPL_NEON_INIT_64(uint16x8, u16) +OPENCV_HAL_IMPL_NEON_INIT_64(int16x8, s16) +OPENCV_HAL_IMPL_NEON_INIT_64(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_INIT_64(int32x4, s32) +OPENCV_HAL_IMPL_NEON_INIT_64(uint64x2, u64) +OPENCV_HAL_IMPL_NEON_INIT_64(int64x2, s64) +OPENCV_HAL_IMPL_NEON_INIT_64(float32x4, f32) +OPENCV_HAL_IMPL_NEON_INIT_64(float64x2, f64) +#endif + +#define OPENCV_HAL_IMPL_NEON_PACK(_Tpvec, _Tp, hreg, suffix, _Tpwvec, pack, mov, rshr) \ +inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + hreg a1 = mov(a.val), b1 = mov(b.val); \ + return _Tpvec(vcombine_##suffix(a1, b1)); \ +} \ +inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = mov(a.val); \ + vst1_##suffix(ptr, a1); \ +} \ +template inline \ +_Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + hreg a1 = rshr(a.val, n); \ + hreg b1 = rshr(b.val, n); \ + return _Tpvec(vcombine_##suffix(a1, b1)); \ +} \ +template inline \ +void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + hreg a1 = rshr(a.val, n); \ + vst1_##suffix(ptr, a1); \ +} + +OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_uint16x8, pack, vqmovn_u16, vqrshrn_n_u16) +OPENCV_HAL_IMPL_NEON_PACK(v_int8x16, schar, int8x8_t, s8, v_int16x8, pack, vqmovn_s16, vqrshrn_n_s16) +OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_uint32x4, pack, vqmovn_u32, vqrshrn_n_u32) +OPENCV_HAL_IMPL_NEON_PACK(v_int16x8, short, int16x4_t, s16, v_int32x4, pack, vqmovn_s32, vqrshrn_n_s32) +OPENCV_HAL_IMPL_NEON_PACK(v_uint32x4, unsigned, uint32x2_t, u32, v_uint64x2, pack, vmovn_u64, vrshrn_n_u64) +OPENCV_HAL_IMPL_NEON_PACK(v_int32x4, int, int32x2_t, s32, v_int64x2, pack, vmovn_s64, vrshrn_n_s64) + +OPENCV_HAL_IMPL_NEON_PACK(v_uint8x16, uchar, uint8x8_t, u8, v_int16x8, pack_u, vqmovun_s16, vqrshrun_n_s16) +OPENCV_HAL_IMPL_NEON_PACK(v_uint16x8, ushort, uint16x4_t, u16, v_int32x4, pack_u, vqmovun_s32, vqrshrun_n_s32) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + uint8x16_t ab = vcombine_u8(vmovn_u16(a.val), vmovn_u16(b.val)); + return v_uint8x16(ab); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + uint16x8_t nab = vcombine_u16(vmovn_u32(a.val), vmovn_u32(b.val)); + uint16x8_t ncd = vcombine_u16(vmovn_u32(c.val), vmovn_u32(d.val)); + return v_uint8x16(vcombine_u8(vmovn_u16(nab), vmovn_u16(ncd))); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + uint32x4_t ab = vcombine_u32(vmovn_u64(a.val), vmovn_u64(b.val)); + uint32x4_t cd = vcombine_u32(vmovn_u64(c.val), vmovn_u64(d.val)); + uint32x4_t ef = vcombine_u32(vmovn_u64(e.val), vmovn_u64(f.val)); + uint32x4_t gh = vcombine_u32(vmovn_u64(g.val), vmovn_u64(h.val)); + + uint16x8_t abcd = vcombine_u16(vmovn_u32(ab), vmovn_u32(cd)); + uint16x8_t efgh = vcombine_u16(vmovn_u32(ef), vmovn_u32(gh)); + return v_uint8x16(vcombine_u8(vmovn_u16(abcd), vmovn_u16(efgh))); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val); + float32x4_t res = vmulq_lane_f32(m0.val, vl, 0); + res = vmlaq_lane_f32(res, m1.val, vl, 1); + res = vmlaq_lane_f32(res, m2.val, vh, 0); + res = vmlaq_lane_f32(res, m3.val, vh, 1); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + float32x2_t vl = vget_low_f32(v.val), vh = vget_high_f32(v.val); + float32x4_t res = vmulq_lane_f32(m0.val, vl, 0); + res = vmlaq_lane_f32(res, m1.val, vl, 1); + res = vmlaq_lane_f32(res, m2.val, vh, 0); + res = vaddq_f32(res, a.val); + return v_float32x4(res); +} + +#define OPENCV_HAL_IMPL_NEON_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint8x16, vqaddq_u8) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint8x16, vqsubq_u8) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int8x16, vqaddq_s8) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int8x16, vqsubq_s8) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint16x8, vqaddq_u16) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint16x8, vqsubq_u16) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int16x8, vqaddq_s16) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int16x8, vqsubq_s16) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int32x4, vaddq_s32) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int32x4, vsubq_s32) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_int32x4, vmulq_s32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint32x4, vaddq_u32) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint32x4, vsubq_u32) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_uint32x4, vmulq_u32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float32x4, vaddq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float32x4, vsubq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float32x4, vmulq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_int64x2, vaddq_s64) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_int64x2, vsubq_s64) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_uint64x2, vaddq_u64) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_uint64x2, vsubq_u64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float32x4, vdivq_f32) +OPENCV_HAL_IMPL_NEON_BIN_OP(+, v_float64x2, vaddq_f64) +OPENCV_HAL_IMPL_NEON_BIN_OP(-, v_float64x2, vsubq_f64) +OPENCV_HAL_IMPL_NEON_BIN_OP(*, v_float64x2, vmulq_f64) +OPENCV_HAL_IMPL_NEON_BIN_OP(/, v_float64x2, vdivq_f64) +#else +inline v_float32x4 operator / (const v_float32x4& a, const v_float32x4& b) +{ + float32x4_t reciprocal = vrecpeq_f32(b.val); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + return v_float32x4(vmulq_f32(a.val, reciprocal)); +} +inline v_float32x4& operator /= (v_float32x4& a, const v_float32x4& b) +{ + float32x4_t reciprocal = vrecpeq_f32(b.val); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + reciprocal = vmulq_f32(vrecpsq_f32(b.val, reciprocal), reciprocal); + a.val = vmulq_f32(a.val, reciprocal); + return a; +} +#endif + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_NEON_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_NEON_MUL_SAT(v_uint16x8, v_uint32x4) + +// Multiply and expand +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + c.val = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_s8(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_s8(vget_high_s8(a.val), vget_high_s8(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + c.val = vmull_u8(vget_low_u8(a.val), vget_low_u8(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_u8(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_u8(vget_high_u8(a.val), vget_high_u8(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + c.val = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_s16(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + c.val = vmull_u16(vget_low_u16(a.val), vget_low_u16(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_u16(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + c.val = vmull_u32(vget_low_u32(a.val), vget_low_u32(b.val)); +#if CV_NEON_AARCH64 + d.val = vmull_high_u32(a.val, b.val); +#else // #if CV_NEON_AARCH64 + d.val = vmull_u32(vget_high_u32(a.val), vget_high_u32(b.val)); +#endif // #if CV_NEON_AARCH64 +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + return v_int16x8(vcombine_s16( + vshrn_n_s32(vmull_s16( vget_low_s16(a.val), vget_low_s16(b.val)), 16), + vshrn_n_s32( +#if CV_NEON_AARCH64 + vmull_high_s16(a.val, b.val) +#else // #if CV_NEON_AARCH64 + vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)) +#endif // #if CV_NEON_AARCH64 + , 16) + )); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint16x8(vcombine_u16( + vshrn_n_u32(vmull_u16( vget_low_u16(a.val), vget_low_u16(b.val)), 16), + vshrn_n_u32( +#if CV_NEON_AARCH64 + vmull_high_u16(a.val, b.val) +#else // #if CV_NEON_AARCH64 + vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)) +#endif // #if CV_NEON_AARCH64 + , 16) + )); +} + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + int16x8_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int16x4_t a0 = vget_low_s16(uzp1); + int16x4_t b0 = vget_high_s16(uzp1); + int16x4_t a1 = vget_low_s16(uzp2); + int16x4_t b1 = vget_high_s16(uzp2); + int32x4_t p = vmull_s16(a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +} +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + int16x8_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int16x4_t a0 = vget_low_s16(uzp1); + int16x4_t b0 = vget_high_s16(uzp1); + int16x4_t a1 = vget_low_s16(uzp2); + int16x4_t b1 = vget_high_s16(uzp2); + int32x4_t p = vmlal_s16(c.val, a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +} + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + int32x4_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int32x2_t a0 = vget_low_s32(uzp1); + int32x2_t b0 = vget_high_s32(uzp1); + int32x2_t a1 = vget_low_s32(uzp2); + int32x2_t b1 = vget_high_s32(uzp2); + int64x2_t p = vmull_s32(a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + int32x4_t uzp1, uzp2; + _v128_unzip(a.val, b.val, uzp1, uzp2); + int32x2_t a0 = vget_low_s32(uzp1); + int32x2_t b0 = vget_high_s32(uzp1); + int32x2_t a1 = vget_low_s32(uzp2); + int32x2_t b1 = vget_high_s32(uzp2); + int64x2_t p = vmlal_s32(c.val, a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(vdupq_n_u32(0), a.val, b.val)); +#else + const uint8x16_t zero = vreinterpretq_u8_u32(vdupq_n_u32(0)); + const uint8x16_t mask = vreinterpretq_u8_u32(vdupq_n_u32(0x00FF00FF)); + const uint16x8_t zero32 = vreinterpretq_u16_u32(vdupq_n_u32(0)); + const uint16x8_t mask32 = vreinterpretq_u16_u32(vdupq_n_u32(0x0000FFFF)); + + uint16x8_t even = vmulq_u16(vreinterpretq_u16_u8(vbslq_u8(mask, a.val, zero)), + vreinterpretq_u16_u8(vbslq_u8(mask, b.val, zero))); + uint16x8_t odd = vmulq_u16(vshrq_n_u16(vreinterpretq_u16_u8(a.val), 8), + vshrq_n_u16(vreinterpretq_u16_u8(b.val), 8)); + + uint32x4_t s0 = vaddq_u32(vreinterpretq_u32_u16(vbslq_u16(mask32, even, zero32)), + vreinterpretq_u32_u16(vbslq_u16(mask32, odd, zero32))); + uint32x4_t s1 = vaddq_u32(vshrq_n_u32(vreinterpretq_u32_u16(even), 16), + vshrq_n_u32(vreinterpretq_u32_u16(odd), 16)); + return v_uint32x4(vaddq_u32(s0, s1)); +#endif +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, + const v_uint32x4& c) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(c.val, a.val, b.val)); +#else + return v_dotprod_expand(a, b) + c; +#endif +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(vdupq_n_s32(0), a.val, b.val)); +#else + int16x8_t p0 = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); + int16x8_t p1 = vmull_s8(vget_high_s8(a.val), vget_high_s8(b.val)); + int16x8_t uzp1, uzp2; + _v128_unzip(p0, p1, uzp1, uzp2); + int16x8_t sum = vaddq_s16(uzp1, uzp2); + int16x4_t uzpl1, uzpl2; + _v128_unzip(vget_low_s16(sum), vget_high_s16(sum), uzpl1, uzpl2); + return v_int32x4(vaddl_s16(uzpl1, uzpl2)); +#endif +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(c.val, a.val, b.val)); +#else + return v_dotprod_expand(a, b) + c; +#endif +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + const uint16x8_t zero = vreinterpretq_u16_u32(vdupq_n_u32(0)); + const uint16x8_t mask = vreinterpretq_u16_u32(vdupq_n_u32(0x0000FFFF)); + + uint32x4_t even = vmulq_u32(vreinterpretq_u32_u16(vbslq_u16(mask, a.val, zero)), + vreinterpretq_u32_u16(vbslq_u16(mask, b.val, zero))); + uint32x4_t odd = vmulq_u32(vshrq_n_u32(vreinterpretq_u32_u16(a.val), 16), + vshrq_n_u32(vreinterpretq_u32_u16(b.val), 16)); + uint32x4_t uzp1, uzp2; + _v128_unzip(even, odd, uzp1, uzp2); + uint64x2_t s0 = vaddl_u32(vget_low_u32(uzp1), vget_high_u32(uzp1)); + uint64x2_t s1 = vaddl_u32(vget_low_u32(uzp2), vget_high_u32(uzp2)); + return v_uint64x2(vaddq_u64(s0, s1)); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + int32x4_t p0 = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); + int32x4_t p1 = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val)); + + int32x4_t uzp1, uzp2; + _v128_unzip(p0, p1, uzp1, uzp2); + int32x4_t sum = vaddq_s32(uzp1, uzp2); + + int32x2_t uzpl1, uzpl2; + _v128_unzip(vget_low_s32(sum), vget_high_s32(sum), uzpl1, uzpl2); + return v_int64x2(vaddl_s32(uzpl1, uzpl2)); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, + const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, + const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } +#endif + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ +#if CV_NEON_AARCH64 + int32x4_t p = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); + return v_int32x4(vmlal_high_s16(p, a.val, b.val)); +#else + int16x4_t a0 = vget_low_s16(a.val); + int16x4_t a1 = vget_high_s16(a.val); + int16x4_t b0 = vget_low_s16(b.val); + int16x4_t b1 = vget_high_s16(b.val); + int32x4_t p = vmull_s16(a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +#endif +} +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ +#if CV_NEON_AARCH64 + int32x4_t p = vmlal_s16(c.val, vget_low_s16(a.val), vget_low_s16(b.val)); + return v_int32x4(vmlal_high_s16(p, a.val, b.val)); +#else + int16x4_t a0 = vget_low_s16(a.val); + int16x4_t a1 = vget_high_s16(a.val); + int16x4_t b0 = vget_low_s16(b.val); + int16x4_t b1 = vget_high_s16(b.val); + int32x4_t p = vmlal_s16(c.val, a0, b0); + return v_int32x4(vmlal_s16(p, a1, b1)); +#endif +} + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_NEON_AARCH64 + int64x2_t p = vmull_s32(vget_low_s32(a.val), vget_low_s32(b.val)); + return v_int64x2(vmlal_high_s32(p, a.val, b.val)); +#else + int32x2_t a0 = vget_low_s32(a.val); + int32x2_t a1 = vget_high_s32(a.val); + int32x2_t b0 = vget_low_s32(b.val); + int32x2_t b1 = vget_high_s32(b.val); + int64x2_t p = vmull_s32(a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +#endif +} +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ +#if CV_NEON_AARCH64 + int64x2_t p = vmlal_s32(c.val, vget_low_s32(a.val), vget_low_s32(b.val)); + return v_int64x2(vmlal_high_s32(p, a.val, b.val)); +#else + int32x2_t a0 = vget_low_s32(a.val); + int32x2_t a1 = vget_high_s32(a.val); + int32x2_t b0 = vget_low_s32(b.val); + int32x2_t b1 = vget_high_s32(b.val); + int64x2_t p = vmlal_s32(c.val, a0, b0); + return v_int64x2(vmlal_s32(p, a1, b1)); +#endif +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(vdupq_n_u32(0), a.val, b.val)); +#else + uint16x8_t p0 = vmull_u8(vget_low_u8(a.val), vget_low_u8(b.val)); + uint16x8_t p1 = vmull_u8(vget_high_u8(a.val), vget_high_u8(b.val)); + uint32x4_t s0 = vaddl_u16(vget_low_u16(p0), vget_low_u16(p1)); + uint32x4_t s1 = vaddl_u16(vget_high_u16(p0), vget_high_u16(p1)); + return v_uint32x4(vaddq_u32(s0, s1)); +#endif +} +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ +#if CV_NEON_DOT + return v_uint32x4(vdotq_u32(c.val, a.val, b.val)); +#else + return v_dotprod_expand_fast(a, b) + c; +#endif +} + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(vdupq_n_s32(0), a.val, b.val)); +#else + int16x8_t prod = vmull_s8(vget_low_s8(a.val), vget_low_s8(b.val)); + prod = vmlal_s8(prod, vget_high_s8(a.val), vget_high_s8(b.val)); + return v_int32x4(vaddl_s16(vget_low_s16(prod), vget_high_s16(prod))); +#endif +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ +#if CV_NEON_DOT + return v_int32x4(vdotq_s32(c.val, a.val, b.val)); +#else + return v_dotprod_expand_fast(a, b) + c; +#endif +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + uint32x4_t p0 = vmull_u16(vget_low_u16(a.val), vget_low_u16(b.val)); + uint32x4_t p1 = vmull_u16(vget_high_u16(a.val), vget_high_u16(b.val)); + uint64x2_t s0 = vaddl_u32(vget_low_u32(p0), vget_high_u32(p0)); + uint64x2_t s1 = vaddl_u32(vget_low_u32(p1), vget_high_u32(p1)); + return v_uint64x2(vaddq_u64(s0, s1)); +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + int32x4_t prod = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val)); + prod = vmlal_s16(prod, vget_high_s16(a.val), vget_high_s16(b.val)); + return v_int64x2(vaddl_s32(vget_low_s32(prod), vget_high_s32(prod))); +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod_fast(a, b)); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } +#endif + + +#define OPENCV_HAL_IMPL_NEON_LOGIC_OP(_Tpvec, suffix) \ + OPENCV_HAL_IMPL_NEON_BIN_OP(&, _Tpvec, vandq_##suffix) \ + OPENCV_HAL_IMPL_NEON_BIN_OP(|, _Tpvec, vorrq_##suffix) \ + OPENCV_HAL_IMPL_NEON_BIN_OP(^, _Tpvec, veorq_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { \ + return _Tpvec(vreinterpretq_##suffix##_u8(vmvnq_u8(vreinterpretq_u8_##suffix(a.val)))); \ + } + +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint8x16, u8) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int8x16, s8) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint16x8, u16) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int16x8, s16) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint32x4, u32) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int32x4, s32) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_uint64x2, u64) +OPENCV_HAL_IMPL_NEON_LOGIC_OP(v_int64x2, s64) + +#define OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(vreinterpretq_f32_s32(intrin(vreinterpretq_s32_f32(a.val), vreinterpretq_s32_f32(b.val)))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a.val = vreinterpretq_f32_s32(intrin(vreinterpretq_s32_f32(a.val), vreinterpretq_s32_f32(b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(&, vandq_s32) +OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(|, vorrq_s32) +OPENCV_HAL_IMPL_NEON_FLT_BIT_OP(^, veorq_s32) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4(vreinterpretq_f32_s32(vmvnq_s32(vreinterpretq_s32_f32(a.val)))); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(vsqrtq_f32(x.val)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + v_float32x4 one = v_setall_f32(1.0f); + return one / v_sqrt(x); +} +#else +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + float32x4_t x1 = vmaxq_f32(x.val, vdupq_n_f32(FLT_MIN)); + float32x4_t e = vrsqrteq_f32(x1); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); + return v_float32x4(vmulq_f32(x.val, e)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + float32x4_t e = vrsqrteq_f32(x.val); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x.val, e), e), e); + return v_float32x4(e); +} +#endif + +#define OPENCV_HAL_IMPL_NEON_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ +inline _Tpuvec v_abs(const _Tpsvec& a) { return v_reinterpret_as_##usuffix(_Tpsvec(vabsq_##ssuffix(a.val))); } + +OPENCV_HAL_IMPL_NEON_ABS(v_uint8x16, v_int8x16, u8, s8) +OPENCV_HAL_IMPL_NEON_ABS(v_uint16x8, v_int16x8, u16, s16) +OPENCV_HAL_IMPL_NEON_ABS(v_uint32x4, v_int32x4, u32, s32) + +inline v_float32x4 v_abs(v_float32x4 x) +{ return v_float32x4(vabsq_f32(x.val)); } + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val)))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a.val = vreinterpretq_f64_s64(intrin(vreinterpretq_s64_f64(a.val), vreinterpretq_s64_f64(b.val))); \ + return a; \ +} + +OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(&, vandq_s64) +OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(|, vorrq_s64) +OPENCV_HAL_IMPL_NEON_DBL_BIT_OP(^, veorq_s64) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2(vreinterpretq_f64_s32(vmvnq_s32(vreinterpretq_s32_f64(a.val)))); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(vsqrtq_f64(x.val)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + v_float64x2 one = v_setall_f64(1.0f); + return one / v_sqrt(x); +} + +inline v_float64x2 v_abs(v_float64x2 x) +{ return v_float64x2(vabsq_f64(x.val)); } +#endif + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_NEON_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_min, vminq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_max, vmaxq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_min, vminq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_max, vmaxq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_min, vminq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_max, vmaxq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_min, vminq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_max, vmaxq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_min, vminq_u32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_max, vmaxq_u32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_min, vminq_s32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int32x4, v_max, vmaxq_s32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_min, vminq_f32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_max, vmaxq_f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_min, vminq_f64) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_max, vmaxq_f64) +#endif + +#if CV_SIMD128_64F +inline int64x2_t vmvnq_s64(int64x2_t a) +{ + int64x2_t vx = vreinterpretq_s64_u32(vdupq_n_u32(0xFFFFFFFF)); + return veorq_s64(a, vx); +} +inline uint64x2_t vmvnq_u64(uint64x2_t a) +{ + uint64x2_t vx = vreinterpretq_u64_u32(vdupq_n_u32(0xFFFFFFFF)); + return veorq_u64(a, vx); +} +#endif +#define OPENCV_HAL_IMPL_NEON_INT_CMP_OP(_Tpvec, cast, suffix, not_suffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vceqq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vmvnq_##not_suffix(vceqq_##suffix(a.val, b.val)))); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcltq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcgtq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcleq_##suffix(a.val, b.val))); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(cast(vcgeq_##suffix(a.val, b.val))); } + +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint8x16, OPENCV_HAL_NOP, u8, u8) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int8x16, vreinterpretq_s8_u8, s8, u8) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint16x8, OPENCV_HAL_NOP, u16, u16) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int16x8, vreinterpretq_s16_u16, s16, u16) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint32x4, OPENCV_HAL_NOP, u32, u32) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int32x4, vreinterpretq_s32_u32, s32, u32) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float32x4, vreinterpretq_f32_u32, f32, u32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_uint64x2, OPENCV_HAL_NOP, u64, u64) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int64x2, vreinterpretq_s64_u64, s64, u64) +OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float64x2, vreinterpretq_f64_u64, f64, u64) +#endif + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(vreinterpretq_f32_u32(vceqq_f32(a.val, a.val))); } +#if CV_SIMD128_64F +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(vreinterpretq_f64_u64(vceqq_f64(a.val, a.val))); } +#endif + +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_add_wrap, vaddq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_add_wrap, vaddq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_add_wrap, vaddq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_add_wrap, vaddq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_sub_wrap, vsubq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_sub_wrap, vsubq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_sub_wrap, vsubq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_sub_wrap, vsubq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_mul_wrap, vmulq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_mul_wrap, vmulq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_mul_wrap, vmulq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int16x8, v_mul_wrap, vmulq_s16) + +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_absdiff, vabdq_u8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_absdiff, vabdq_u16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint32x4, v_absdiff, vabdq_u32) +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float32x4, v_absdiff, vabdq_f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_float64x2, v_absdiff, vabdq_f64) +#endif + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ return v_int8x16(vqabsq_s8(vqsubq_s8(a.val, b.val))); } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_int16x8(vqabsq_s16(vqsubq_s16(a.val, b.val))); } + +#define OPENCV_HAL_IMPL_NEON_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \ +inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec2(cast(intrin(a.val, b.val))); \ +} + +OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int8x16, v_uint8x16, vreinterpretq_u8_s8, v_absdiff, vabdq_s8) +OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int16x8, v_uint16x8, vreinterpretq_u16_s16, v_absdiff, vabdq_s16) +OPENCV_HAL_IMPL_NEON_BIN_FUNC2(v_int32x4, v_uint32x4, vreinterpretq_u32_s32, v_absdiff, vabdq_s32) + +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vmlaq_f32(vmulq_f32(a.val, a.val), b.val, b.val)); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ +#if CV_SIMD128_64F + // ARMv8, which adds support for 64-bit floating-point (so CV_SIMD128_64F is defined), + // also adds FMA support both for single- and double-precision floating-point vectors + return v_float32x4(vfmaq_f32(c.val, a.val, b.val)); +#else + return v_float32x4(vmlaq_f32(c.val, a.val, b.val)); +#endif +} + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(vmlaq_s32(c.val, a.val, b.val)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val))); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vaddq_f64(vmulq_f64(a.val, a.val), vmulq_f64(b.val, b.val))); +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(vfmaq_f64(c.val, a.val, b.val)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} +#endif + +// trade efficiency for convenience +#define OPENCV_HAL_IMPL_NEON_SHIFT_OP(_Tpvec, suffix, _Tps, ssuffix) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ return _Tpvec(vshlq_##suffix(a.val, vdupq_n_##ssuffix((_Tps)n))); } \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ return _Tpvec(vshlq_##suffix(a.val, vdupq_n_##ssuffix((_Tps)-n))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec(vshlq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec(vshrq_n_##suffix(a.val, n)); } \ +template inline _Tpvec v_rshr(const _Tpvec& a) \ +{ return _Tpvec(vrshrq_n_##suffix(a.val, n)); } + +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint8x16, u8, schar, s8) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int8x16, s8, schar, s8) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint16x8, u16, short, s16) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int16x8, s16, short, s16) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint32x4, u32, int, s32) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int32x4, s32, int, s32) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_uint64x2, u64, int64, s64) +OPENCV_HAL_IMPL_NEON_SHIFT_OP(v_int64x2, s64, int64, s64) + +#define OPENCV_HAL_IMPL_NEON_ROTATE_OP(_Tpvec, suffix) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ return _Tpvec(vextq_##suffix(a.val, vdupq_n_##suffix(0), n)); } \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ return _Tpvec(vextq_##suffix(vdupq_n_##suffix(0), a.val, _Tpvec::nlanes - n)); } \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vextq_##suffix(a.val, b.val, n)); } \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vextq_##suffix(b.val, a.val, _Tpvec::nlanes - n)); } \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ CV_UNUSED(b); return a; } + +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint8x16, u8) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int8x16, s8) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint16x8, u16) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int16x8, s16) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint32x4, u32) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int32x4, s32) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_float32x4, f32) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_uint64x2, u64) +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_int64x2, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_ROTATE_OP(v_float64x2, f64) +#endif + +#if defined(__clang__) && defined(__aarch64__) +// avoid LD2 instruction. details: https://github.com/opencv/opencv/issues/14863 +#define OPENCV_HAL_IMPL_NEON_LOAD_LOW_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ \ +typedef uint64 CV_DECL_ALIGNED(1) unaligned_uint64; \ +uint64 v = *(unaligned_uint64*)ptr; \ +return _Tpvec(v_reinterpret_as_##suffix(v_uint64x2(v, (uint64)123456))); \ +} +#else +#define OPENCV_HAL_IMPL_NEON_LOAD_LOW_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr), vdup_n_##suffix((_Tp)0))); } +#endif + +#define OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(vld1q_##suffix(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(vld1q_##suffix(ptr)); } \ +OPENCV_HAL_IMPL_NEON_LOAD_LOW_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ return _Tpvec(vcombine_##suffix(vld1_##suffix(ptr0), vld1_##suffix(ptr1))); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ vst1q_##suffix(ptr, a.val); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ vst1_##suffix(ptr, vget_low_##suffix(a.val)); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ vst1_##suffix(ptr, vget_high_##suffix(a.val)); } + +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64) +#endif + +inline unsigned v_reduce_sum(const v_uint8x16& a) +{ +#if CV_NEON_AARCH64 + uint16_t t0 = vaddlvq_u8(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(a.val)); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline int v_reduce_sum(const v_int8x16& a) +{ +#if CV_NEON_AARCH64 + int16_t t0 = vaddlvq_s8(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + int32x4_t t0 = vpaddlq_s16(vpaddlq_s8(a.val)); + int32x2_t t1 = vpadd_s32(vget_low_s32(t0), vget_high_s32(t0)); + return vget_lane_s32(vpadd_s32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sum(const v_uint16x8& a) +{ +#if CV_NEON_AARCH64 + uint32_t t0 = vaddlvq_u16(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(a.val); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline int v_reduce_sum(const v_int16x8& a) +{ +#if CV_NEON_AARCH64 + int32_t t0 = vaddlvq_s16(a.val); + return t0; +#else // #if CV_NEON_AARCH64 + int32x4_t t0 = vpaddlq_s16(a.val); + int32x2_t t1 = vpadd_s32(vget_low_s32(t0), vget_high_s32(t0)); + return vget_lane_s32(vpadd_s32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return v##vectorfunc##vq_##suffix(a.val); \ +} +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ + a0 = vp##vectorfunc##_##suffix(a0, a0); \ + a0 = vp##vectorfunc##_##suffix(a0, a0); \ + return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, a0),0); \ +} +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_uint8x16, uint8x8, uchar, max, max, u8) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_uint8x16, uint8x8, uchar, min, min, u8) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_int8x16, int8x8, schar, max, max, s8) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_16(v_int8x16, int8x8, schar, min, min, s8) + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return v##vectorfunc##vq_##suffix(a.val); \ +} +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ + a0 = vp##vectorfunc##_##suffix(a0, a0); \ + return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, a0),0); \ +} +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, ushort, max, max, u16) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_uint16x8, uint16x4, ushort, min, min, u16) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, max, max, s16) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(v_int16x8, int16x4, short, min, min, s16) + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + return v##vectorfunc##vq_##suffix(a.val); \ +} +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpnvec##_t a0 = vp##vectorfunc##_##suffix(vget_low_##suffix(a.val), vget_high_##suffix(a.val)); \ + return (scalartype)vget_lane_##suffix(vp##vectorfunc##_##suffix(a0, vget_high_##suffix(a.val)),0); \ +} +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, sum, add, u32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, max, max, u32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_uint32x4, uint32x2, unsigned, min, min, u32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, sum, add, s32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, max, max, s32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_int32x4, int32x2, int, min, min, s32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, sum, add, f32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, max, max, f32) +OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, min, min, f32) + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ +#if CV_NEON_AARCH64 + return vaddvq_u64(a.val); +#else // #if CV_NEON_AARCH64 + return vget_lane_u64(vadd_u64(vget_low_u64(a.val), vget_high_u64(a.val)),0); +#endif // #if CV_NEON_AARCH64 +} +inline int64 v_reduce_sum(const v_int64x2& a) +{ +#if CV_NEON_AARCH64 + return vaddvq_s64(a.val); +#else // #if CV_NEON_AARCH64 + return vget_lane_s64(vadd_s64(vget_low_s64(a.val), vget_high_s64(a.val)),0); +#endif // #if CV_NEON_AARCH64 +} +#if CV_SIMD128_64F +inline double v_reduce_sum(const v_float64x2& a) +{ + return vaddvq_f64(a.val); +} +#endif + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ +#if CV_NEON_AARCH64 + float32x4_t ab = vpaddq_f32(a.val, b.val); // a0+a1 a2+a3 b0+b1 b2+b3 + float32x4_t cd = vpaddq_f32(c.val, d.val); // c0+c1 d0+d1 c2+c3 d2+d3 + return v_float32x4(vpaddq_f32(ab, cd)); // sumA sumB sumC sumD +#else // #if CV_NEON_AARCH64 + float32x4x2_t ab = vtrnq_f32(a.val, b.val); + float32x4x2_t cd = vtrnq_f32(c.val, d.val); + + float32x4_t u0 = vaddq_f32(ab.val[0], ab.val[1]); // a0+a1 b0+b1 a2+a3 b2+b3 + float32x4_t u1 = vaddq_f32(cd.val[0], cd.val[1]); // c0+c1 d0+d1 c2+c3 d2+d3 + + float32x4_t v0 = vcombine_f32(vget_low_f32(u0), vget_low_f32(u1)); + float32x4_t v1 = vcombine_f32(vget_high_f32(u0), vget_high_f32(u1)); + + return v_float32x4(vaddq_f32(v0, v1)); +#endif // #if CV_NEON_AARCH64 +} + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ +#if CV_NEON_AARCH64 + uint8x16_t t0 = vabdq_u8(a.val, b.val); + uint16_t t1 = vaddlvq_u8(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vabdq_u8(a.val, b.val))); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_NEON_AARCH64 + uint8x16_t t0 = vreinterpretq_u8_s8(vabdq_s8(a.val, b.val)); + uint16_t t1 = vaddlvq_u8(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vreinterpretq_u8_s8(vabdq_s8(a.val, b.val)))); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ +#if CV_NEON_AARCH64 + uint16x8_t t0 = vabdq_u16(a.val, b.val); + uint32_t t1 = vaddlvq_u16(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vabdq_u16(a.val, b.val)); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ +#if CV_NEON_AARCH64 + uint16x8_t t0 = vreinterpretq_u16_s16(vabdq_s16(a.val, b.val)); + uint32_t t1 = vaddlvq_u16(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vpaddlq_u16(vreinterpretq_u16_s16(vabdq_s16(a.val, b.val))); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ +#if CV_NEON_AARCH64 + uint32x4_t t0 = vabdq_u32(a.val, b.val); + uint32_t t1 = vaddvq_u32(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vabdq_u32(a.val, b.val); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_NEON_AARCH64 + uint32x4_t t0 = vreinterpretq_u32_s32(vabdq_s32(a.val, b.val)); + uint32_t t1 = vaddvq_u32(t0); + return t1; +#else // #if CV_NEON_AARCH64 + uint32x4_t t0 = vreinterpretq_u32_s32(vabdq_s32(a.val, b.val)); + uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0)); + return vget_lane_u32(vpadd_u32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ +#if CV_NEON_AARCH64 + float32x4_t t0 = vabdq_f32(a.val, b.val); + return vaddvq_f32(t0); +#else // #if CV_NEON_AARCH64 + float32x4_t t0 = vabdq_f32(a.val, b.val); + float32x2_t t1 = vpadd_f32(vget_low_f32(t0), vget_high_f32(t0)); + return vget_lane_f32(vpadd_f32(t1, t1), 0); +#endif // #if CV_NEON_AARCH64 +} + +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ return v_uint8x16(vcntq_u8(a.val)); } +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_uint8x16(vcntq_u8(vreinterpretq_u8_s8(a.val))); } +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ return v_uint16x8(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_u16(a.val)))); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_uint16x8(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_s16(a.val)))); } +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ return v_uint32x4(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_u32(a.val))))); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_uint32x4(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_s32(a.val))))); } +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ return v_uint64x2(vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_u64(a.val)))))); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_uint64x2(vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(vcntq_u8(vreinterpretq_u8_s64(a.val)))))); } + +inline int v_signmask(const v_uint8x16& a) +{ +#if CV_NEON_AARCH64 + const int8x16_t signPosition = {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7}; + const uint8x16_t byteOrder = {0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15}; + uint8x16_t v0 = vshlq_u8(vshrq_n_u8(a.val, 7), signPosition); + uint8x16_t v1 = vqtbl1q_u8(v0, byteOrder); + uint32_t t0 = vaddlvq_u16(vreinterpretq_u16_u8(v1)); + return t0; +#else // #if CV_NEON_AARCH64 + int8x8_t m0 = vcreate_s8(CV_BIG_UINT(0x0706050403020100)); + uint8x16_t v0 = vshlq_u8(vshrq_n_u8(a.val, 7), vcombine_s8(m0, m0)); + uint64x2_t v1 = vpaddlq_u32(vpaddlq_u16(vpaddlq_u8(v0))); + return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 8); +#endif // #if CV_NEON_AARCH64 +} + +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } + +inline int v_signmask(const v_uint16x8& a) +{ +#if CV_NEON_AARCH64 + const int16x8_t signPosition = {0,1,2,3,4,5,6,7}; + uint16x8_t v0 = vshlq_u16(vshrq_n_u16(a.val, 15), signPosition); + uint32_t t0 = vaddlvq_u16(v0); + return t0; +#else // #if CV_NEON_AARCH64 + int16x4_t m0 = vcreate_s16(CV_BIG_UINT(0x0003000200010000)); + uint16x8_t v0 = vshlq_u16(vshrq_n_u16(a.val, 15), vcombine_s16(m0, m0)); + uint64x2_t v1 = vpaddlq_u32(vpaddlq_u16(v0)); + return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 4); +#endif // #if CV_NEON_AARCH64 +} +inline int v_signmask(const v_int16x8& a) +{ return v_signmask(v_reinterpret_as_u16(a)); } + +inline int v_signmask(const v_uint32x4& a) +{ +#if CV_NEON_AARCH64 + const int32x4_t signPosition = {0,1,2,3}; + uint32x4_t v0 = vshlq_u32(vshrq_n_u32(a.val, 31), signPosition); + uint32_t t0 = vaddvq_u32(v0); + return t0; +#else // #if CV_NEON_AARCH64 + int32x2_t m0 = vcreate_s32(CV_BIG_UINT(0x0000000100000000)); + uint32x4_t v0 = vshlq_u32(vshrq_n_u32(a.val, 31), vcombine_s32(m0, m0)); + uint64x2_t v1 = vpaddlq_u32(v0); + return (int)vgetq_lane_u64(v1, 0) + ((int)vgetq_lane_u64(v1, 1) << 2); +#endif // #if CV_NEON_AARCH64 +} +inline int v_signmask(const v_int32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_uint64x2& a) +{ +#if CV_NEON_AARCH64 + const int64x2_t signPosition = {0,1}; + uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), signPosition); + uint64_t t0 = vaddvq_u64(v0); + return t0; +#else // #if CV_NEON_AARCH64 + int64x1_t m0 = vdup_n_s64(0); + uint64x2_t v0 = vshlq_u64(vshrq_n_u64(a.val, 63), vcombine_s64(m0, m0)); + return (int)vgetq_lane_u64(v0, 0) + ((int)vgetq_lane_u64(v0, 1) << 1); +#endif // #if CV_NEON_AARCH64 +} +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#if CV_SIMD128_64F +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#endif + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(a)); } +#if CV_SIMD128_64F +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(a)); } +#endif + +#if CV_NEON_AARCH64 + #define OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(_Tpvec, suffix, shift) \ + inline bool v_check_all(const v_##_Tpvec& a) \ + { \ + return (vminvq_##suffix(a.val) >> shift) != 0; \ + } \ + inline bool v_check_any(const v_##_Tpvec& a) \ + { \ + return (vmaxvq_##suffix(a.val) >> shift) != 0; \ + } +#else // #if CV_NEON_AARCH64 + #define OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(_Tpvec, suffix, shift) \ + inline bool v_check_all(const v_##_Tpvec& a) \ + { \ + _Tpvec##_t v0 = vshrq_n_##suffix(vmvnq_##suffix(a.val), shift); \ + uint64x2_t v1 = vreinterpretq_u64_##suffix(v0); \ + return (vgetq_lane_u64(v1, 0) | vgetq_lane_u64(v1, 1)) == 0; \ + } \ + inline bool v_check_any(const v_##_Tpvec& a) \ + { \ + _Tpvec##_t v0 = vshrq_n_##suffix(a.val, shift); \ + uint64x2_t v1 = vreinterpretq_u64_##suffix(v0); \ + return (vgetq_lane_u64(v1, 0) | vgetq_lane_u64(v1, 1)) != 0; \ + } +#endif // #if CV_NEON_AARCH64 + +OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint8x16, u8, 7) +OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint16x8, u16, 15) +OPENCV_HAL_IMPL_NEON_CHECK_ALLANY(uint32x4, u32, 31) + +inline bool v_check_all(const v_uint64x2& a) +{ + uint64x2_t v0 = vshrq_n_u64(a.val, 63); + return (vgetq_lane_u64(v0, 0) & vgetq_lane_u64(v0, 1)) == 1; +} +inline bool v_check_any(const v_uint64x2& a) +{ + uint64x2_t v0 = vshrq_n_u64(a.val, 63); + return (vgetq_lane_u64(v0, 0) | vgetq_lane_u64(v0, 1)) != 0; +} + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } + +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +#if CV_SIMD128_64F +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +#endif + +#define OPENCV_HAL_IMPL_NEON_SELECT(_Tpvec, suffix, usuffix) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vbslq_##suffix(vreinterpretq_##usuffix##_##suffix(mask.val), a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_NEON_SELECT(v_uint8x16, u8, u8) +OPENCV_HAL_IMPL_NEON_SELECT(v_int8x16, s8, u8) +OPENCV_HAL_IMPL_NEON_SELECT(v_uint16x8, u16, u16) +OPENCV_HAL_IMPL_NEON_SELECT(v_int16x8, s16, u16) +OPENCV_HAL_IMPL_NEON_SELECT(v_uint32x4, u32, u32) +OPENCV_HAL_IMPL_NEON_SELECT(v_int32x4, s32, u32) +OPENCV_HAL_IMPL_NEON_SELECT(v_float32x4, f32, u32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_SELECT(v_float64x2, f64, u64) +#endif + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = vmovl_##suffix(vget_low_##suffix(a.val)); \ + b1.val = vmovl_high_##suffix(a.val); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_##suffix(vget_low_##suffix(a.val))); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_high_##suffix(a.val)); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(vmovl_##suffix(vld1_##suffix(ptr))); \ +} +#else +#define OPENCV_HAL_IMPL_NEON_EXPAND(_Tpvec, _Tpwvec, _Tp, suffix) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = vmovl_##suffix(vget_low_##suffix(a.val)); \ + b1.val = vmovl_##suffix(vget_high_##suffix(a.val)); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_##suffix(vget_low_##suffix(a.val))); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + return _Tpwvec(vmovl_##suffix(vget_high_##suffix(a.val))); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(vmovl_##suffix(vld1_##suffix(ptr))); \ +} +#endif + +OPENCV_HAL_IMPL_NEON_EXPAND(v_uint8x16, v_uint16x8, uchar, u8) +OPENCV_HAL_IMPL_NEON_EXPAND(v_int8x16, v_int16x8, schar, s8) +OPENCV_HAL_IMPL_NEON_EXPAND(v_uint16x8, v_uint32x4, ushort, u16) +OPENCV_HAL_IMPL_NEON_EXPAND(v_int16x8, v_int32x4, short, s16) +OPENCV_HAL_IMPL_NEON_EXPAND(v_uint32x4, v_uint64x2, uint, u32) +OPENCV_HAL_IMPL_NEON_EXPAND(v_int32x4, v_int64x2, int, s32) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + typedef unsigned int CV_DECL_ALIGNED(1) unaligned_uint; + uint8x8_t v0 = vcreate_u8(*(unaligned_uint*)ptr); + uint16x4_t v1 = vget_low_u16(vmovl_u8(v0)); + return v_uint32x4(vmovl_u16(v1)); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + typedef unsigned int CV_DECL_ALIGNED(1) unaligned_uint; + int8x8_t v0 = vcreate_s8(*(unaligned_uint*)ptr); + int16x4_t v1 = vget_low_s16(vmovl_s8(v0)); + return v_int32x4(vmovl_s16(v1)); +} + +#if defined(__aarch64__) || defined(_M_ARM64) +#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + b0.val = vzip1q_##suffix(a0.val, a1.val); \ + b1.val = vzip2q_##suffix(a0.val, a1.val); \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \ + d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \ +} +#else +#define OPENCV_HAL_IMPL_NEON_UNPACKS(_Tpvec, suffix) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + _Tpvec##x2_t p = vzipq_##suffix(a0.val, a1.val); \ + b0.val = p.val[0]; \ + b1.val = p.val[1]; \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val))); \ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val))); \ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c.val = vcombine_##suffix(vget_low_##suffix(a.val), vget_low_##suffix(b.val)); \ + d.val = vcombine_##suffix(vget_high_##suffix(a.val), vget_high_##suffix(b.val)); \ +} +#endif + +OPENCV_HAL_IMPL_NEON_UNPACKS(uint8x16, u8) +OPENCV_HAL_IMPL_NEON_UNPACKS(int8x16, s8) +OPENCV_HAL_IMPL_NEON_UNPACKS(uint16x8, u16) +OPENCV_HAL_IMPL_NEON_UNPACKS(int16x8, s16) +OPENCV_HAL_IMPL_NEON_UNPACKS(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_UNPACKS(int32x4, s32) +OPENCV_HAL_IMPL_NEON_UNPACKS(float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_UNPACKS(float64x2, f64) +#endif + +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + uint8x16_t vec = vrev64q_u8(a.val); + return v_uint8x16(vextq_u8(vec, vec, 8)); +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + uint16x8_t vec = vrev64q_u16(a.val); + return v_uint16x8(vextq_u16(vec, vec, 4)); +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + uint32x4_t vec = vrev64q_u32(a.val); + return v_uint32x4(vextq_u32(vec, vec, 2)); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + uint64x2_t vec = a.val; + uint64x1_t vec_lo = vget_low_u64(vec); + uint64x1_t vec_hi = vget_high_u64(vec); + return v_uint64x2(vcombine_u64(vec_hi, vec_lo)); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +#if CV_SIMD128_64F +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } +#endif + +#define OPENCV_HAL_IMPL_NEON_EXTRACT(_Tpvec, suffix) \ +template \ +inline v_##_Tpvec v_extract(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + return v_##_Tpvec(vextq_##suffix(a.val, b.val, s)); \ +} + +OPENCV_HAL_IMPL_NEON_EXTRACT(uint8x16, u8) +OPENCV_HAL_IMPL_NEON_EXTRACT(int8x16, s8) +OPENCV_HAL_IMPL_NEON_EXTRACT(uint16x8, u16) +OPENCV_HAL_IMPL_NEON_EXTRACT(int16x8, s16) +OPENCV_HAL_IMPL_NEON_EXTRACT(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_EXTRACT(int32x4, s32) +OPENCV_HAL_IMPL_NEON_EXTRACT(uint64x2, u64) +OPENCV_HAL_IMPL_NEON_EXTRACT(int64x2, s64) +OPENCV_HAL_IMPL_NEON_EXTRACT(float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_EXTRACT(float64x2, f64) +#endif + +#define OPENCV_HAL_IMPL_NEON_EXTRACT_N(_Tpvec, _Tp, suffix) \ +template inline _Tp v_extract_n(_Tpvec v) { return vgetq_lane_##suffix(v.val, i); } + +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint32x4, uint, u32) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_EXTRACT_N(v_float64x2, double, f64) +#endif + +#define OPENCV_HAL_IMPL_NEON_BROADCAST(_Tpvec, _Tp, suffix) \ +template inline _Tpvec v_broadcast_element(_Tpvec v) { _Tp t = v_extract_n(v); return v_setall_##suffix(t); } + +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint32x4, uint, u32) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_NEON_BROADCAST(v_float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_BROADCAST(v_float64x2, double, f64) +#endif + +#if CV_SIMD128_64F +inline v_int32x4 v_round(const v_float32x4& a) +{ + float32x4_t a_ = a.val; + int32x4_t result; + __asm__ ("fcvtns %0.4s, %1.4s" + : "=w"(result) + : "w"(a_) + : /* No clobbers */); + return v_int32x4(result); +} +#else +inline v_int32x4 v_round(const v_float32x4& a) +{ + static const int32x4_t v_sign = vdupq_n_s32(1 << 31), + v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f)); + + int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(a.val))); + return v_int32x4(vcvtq_s32_f32(vaddq_f32(a.val, vreinterpretq_f32_s32(v_addition)))); +} +#endif +inline v_int32x4 v_floor(const v_float32x4& a) +{ + int32x4_t a1 = vcvtq_s32_f32(a.val); + uint32x4_t mask = vcgtq_f32(vcvtq_f32_s32(a1), a.val); + return v_int32x4(vaddq_s32(a1, vreinterpretq_s32_u32(mask))); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + int32x4_t a1 = vcvtq_s32_f32(a.val); + uint32x4_t mask = vcgtq_f32(a.val, vcvtq_f32_s32(a1)); + return v_int32x4(vsubq_s32(a1, vreinterpretq_s32_u32(mask))); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(vcvtq_s32_f32(a.val)); } + +#if CV_SIMD128_64F +inline v_int32x4 v_round(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); +} + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), vmovn_s64(vcvtaq_s64_f64(b.val)))); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + int64x2_t a1 = vcvtq_s64_f64(a.val); + uint64x2_t mask = vcgtq_f64(vcvtq_f64_s64(a1), a.val); + a1 = vaddq_s64(a1, vreinterpretq_s64_u64(mask)); + return v_int32x4(vcombine_s32(vmovn_s64(a1), zero)); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + int64x2_t a1 = vcvtq_s64_f64(a.val); + uint64x2_t mask = vcgtq_f64(a.val, vcvtq_f64_s64(a1)); + a1 = vsubq_s64(a1, vreinterpretq_s64_u64(mask)); + return v_int32x4(vcombine_s32(vmovn_s64(a1), zero)); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + static const int32x2_t zero = vdup_n_s32(0); + return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); +} +#endif + +#if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(_Tpvec, suffix) \ +inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ + const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ + v_##_Tpvec& b0, v_##_Tpvec& b1, \ + v_##_Tpvec& b2, v_##_Tpvec& b3) \ +{ \ + /* -- Pass 1: 64b transpose */ \ + _Tpvec##_t t0 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn1q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a0.val), \ + vreinterpretq_##suffix##64_##suffix##32(a2.val))); \ + _Tpvec##_t t1 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn1q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a1.val), \ + vreinterpretq_##suffix##64_##suffix##32(a3.val))); \ + _Tpvec##_t t2 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn2q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a0.val), \ + vreinterpretq_##suffix##64_##suffix##32(a2.val))); \ + _Tpvec##_t t3 = vreinterpretq_##suffix##32_##suffix##64( \ + vtrn2q_##suffix##64(vreinterpretq_##suffix##64_##suffix##32(a1.val), \ + vreinterpretq_##suffix##64_##suffix##32(a3.val))); \ + /* -- Pass 2: 32b transpose */ \ + b0.val = vtrn1q_##suffix##32(t0, t1); \ + b1.val = vtrn2q_##suffix##32(t0, t1); \ + b2.val = vtrn1q_##suffix##32(t2, t3); \ + b3.val = vtrn2q_##suffix##32(t2, t3); \ +} + +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(uint32x4, u) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(int32x4, s) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(float32x4, f) +#else // #if CV_NEON_AARCH64 +#define OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(_Tpvec, suffix) \ +inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ + const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ + v_##_Tpvec& b0, v_##_Tpvec& b1, \ + v_##_Tpvec& b2, v_##_Tpvec& b3) \ +{ \ + /* m00 m01 m02 m03 */ \ + /* m10 m11 m12 m13 */ \ + /* m20 m21 m22 m23 */ \ + /* m30 m31 m32 m33 */ \ + _Tpvec##x2_t t0 = vtrnq_##suffix(a0.val, a1.val); \ + _Tpvec##x2_t t1 = vtrnq_##suffix(a2.val, a3.val); \ + /* m00 m10 m02 m12 */ \ + /* m01 m11 m03 m13 */ \ + /* m20 m30 m22 m32 */ \ + /* m21 m31 m23 m33 */ \ + b0.val = vcombine_##suffix(vget_low_##suffix(t0.val[0]), vget_low_##suffix(t1.val[0])); \ + b1.val = vcombine_##suffix(vget_low_##suffix(t0.val[1]), vget_low_##suffix(t1.val[1])); \ + b2.val = vcombine_##suffix(vget_high_##suffix(t0.val[0]), vget_high_##suffix(t1.val[0])); \ + b3.val = vcombine_##suffix(vget_high_##suffix(t0.val[1]), vget_high_##suffix(t1.val[1])); \ +} + +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(uint32x4, u32) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(int32x4, s32) +OPENCV_HAL_IMPL_NEON_TRANSPOSE4x4(float32x4, f32) +#endif // #if CV_NEON_AARCH64 + +#define OPENCV_HAL_IMPL_NEON_INTERLEAVED(_Tpvec, _Tp, suffix) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ +{ \ + _Tpvec##x2_t v = vld2q_##suffix(ptr); \ + a.val = v.val[0]; \ + b.val = v.val[1]; \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ +{ \ + _Tpvec##x3_t v = vld3q_##suffix(ptr); \ + a.val = v.val[0]; \ + b.val = v.val[1]; \ + c.val = v.val[2]; \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ + v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + _Tpvec##x4_t v = vld4q_##suffix(ptr); \ + a.val = v.val[0]; \ + b.val = v.val[1]; \ + c.val = v.val[2]; \ + d.val = v.val[3]; \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + _Tpvec##x2_t v; \ + v.val[0] = a.val; \ + v.val[1] = b.val; \ + vst2q_##suffix(ptr, v); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + _Tpvec##x3_t v; \ + v.val[0] = a.val; \ + v.val[1] = b.val; \ + v.val[2] = c.val; \ + vst3q_##suffix(ptr, v); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, const v_##_Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec##x4_t v; \ + v.val[0] = a.val; \ + v.val[1] = b.val; \ + v.val[2] = c.val; \ + v.val[3] = d.val; \ + vst4q_##suffix(ptr, v); \ +} + +#define OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(tp, suffix) \ +inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, v_##tp##x2& b ) \ +{ \ + tp##x1_t a0 = vld1_##suffix(ptr); \ + tp##x1_t b0 = vld1_##suffix(ptr + 1); \ + tp##x1_t a1 = vld1_##suffix(ptr + 2); \ + tp##x1_t b1 = vld1_##suffix(ptr + 3); \ + a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ + b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ +} \ + \ +inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, \ + v_##tp##x2& b, v_##tp##x2& c ) \ +{ \ + tp##x1_t a0 = vld1_##suffix(ptr); \ + tp##x1_t b0 = vld1_##suffix(ptr + 1); \ + tp##x1_t c0 = vld1_##suffix(ptr + 2); \ + tp##x1_t a1 = vld1_##suffix(ptr + 3); \ + tp##x1_t b1 = vld1_##suffix(ptr + 4); \ + tp##x1_t c1 = vld1_##suffix(ptr + 5); \ + a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ + b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ + c = v_##tp##x2(vcombine_##suffix(c0, c1)); \ +} \ + \ +inline void v_load_deinterleave( const tp* ptr, v_##tp##x2& a, v_##tp##x2& b, \ + v_##tp##x2& c, v_##tp##x2& d ) \ +{ \ + tp##x1_t a0 = vld1_##suffix(ptr); \ + tp##x1_t b0 = vld1_##suffix(ptr + 1); \ + tp##x1_t c0 = vld1_##suffix(ptr + 2); \ + tp##x1_t d0 = vld1_##suffix(ptr + 3); \ + tp##x1_t a1 = vld1_##suffix(ptr + 4); \ + tp##x1_t b1 = vld1_##suffix(ptr + 5); \ + tp##x1_t c1 = vld1_##suffix(ptr + 6); \ + tp##x1_t d1 = vld1_##suffix(ptr + 7); \ + a = v_##tp##x2(vcombine_##suffix(a0, a1)); \ + b = v_##tp##x2(vcombine_##suffix(b0, b1)); \ + c = v_##tp##x2(vcombine_##suffix(c0, c1)); \ + d = v_##tp##x2(vcombine_##suffix(d0, d1)); \ +} \ + \ +inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, const v_##tp##x2& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ + vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ + vst1_##suffix(ptr + 2, vget_high_##suffix(a.val)); \ + vst1_##suffix(ptr + 3, vget_high_##suffix(b.val)); \ +} \ + \ +inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, \ + const v_##tp##x2& b, const v_##tp##x2& c, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ + vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ + vst1_##suffix(ptr + 2, vget_low_##suffix(c.val)); \ + vst1_##suffix(ptr + 3, vget_high_##suffix(a.val)); \ + vst1_##suffix(ptr + 4, vget_high_##suffix(b.val)); \ + vst1_##suffix(ptr + 5, vget_high_##suffix(c.val)); \ +} \ + \ +inline void v_store_interleave( tp* ptr, const v_##tp##x2& a, const v_##tp##x2& b, \ + const v_##tp##x2& c, const v_##tp##x2& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + vst1_##suffix(ptr, vget_low_##suffix(a.val)); \ + vst1_##suffix(ptr + 1, vget_low_##suffix(b.val)); \ + vst1_##suffix(ptr + 2, vget_low_##suffix(c.val)); \ + vst1_##suffix(ptr + 3, vget_low_##suffix(d.val)); \ + vst1_##suffix(ptr + 4, vget_high_##suffix(a.val)); \ + vst1_##suffix(ptr + 5, vget_high_##suffix(b.val)); \ + vst1_##suffix(ptr + 6, vget_high_##suffix(c.val)); \ + vst1_##suffix(ptr + 7, vget_high_##suffix(d.val)); \ +} + +OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(int8x16, schar, s8) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(int16x8, short, s16) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(int32x4, int, s32) +OPENCV_HAL_IMPL_NEON_INTERLEAVED(float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_NEON_INTERLEAVED(float64x2, double, f64) +#endif + +OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(int64, s64) +OPENCV_HAL_IMPL_NEON_INTERLEAVED_INT64(uint64, u64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(vcvtq_f32_s32(a.val)); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + float32x2_t zero = vdup_n_f32(0.0f); + return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), zero)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + return v_float32x4(vcombine_f32(vcvt_f32_f64(a.val), vcvt_f32_f64(b.val))); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_low_s32(a.val)))); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vcvt_f32_s32(vget_high_s32(a.val)))); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vget_low_f32(a.val))); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + return v_float64x2(vcvt_f64_f32(vget_high_f32(a.val))); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ return v_float64x2(vcvtq_f64_s64(a.val)); } + +#endif + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(vld1q_s8(elems)); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(vld1q_s8(elems)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(vld1q_s8(elems)); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(vld1q_s16(elems)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(vld1q_s16(elems)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(vcombine_s16(vld1_s16(tab + idx[0]), vld1_s16(tab + idx[1]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(vld1q_s32(elems)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(vcombine_s32(vld1_s32(tab + idx[0]), vld1_s32(tab + idx[1]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vld1q_s32(tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(vcombine_s64(vcreate_s64(tab[idx[0]]), vcreate_s64(tab[idx[1]]))); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(vld1q_s64(tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(vld1q_f32(elems)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + typedef uint64 CV_DECL_ALIGNED(1) unaligned_uint64; + + uint64 CV_DECL_ALIGNED(32) elems[2] = + { + *(unaligned_uint64*)(tab + idx[0]), + *(unaligned_uint64*)(tab + idx[1]) + }; + return v_float32x4(vreinterpretq_f32_u64(vld1q_u64(elems))); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(vld1q_f32(tab + idx[0])); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + tab[vgetq_lane_s32(idxvec.val, 2)], + tab[vgetq_lane_s32(idxvec.val, 3)] + }; + return v_int32x4(vld1q_s32(elems)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned CV_DECL_ALIGNED(32) elems[4] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + tab[vgetq_lane_s32(idxvec.val, 2)], + tab[vgetq_lane_s32(idxvec.val, 3)] + }; + return v_uint32x4(vld1q_u32(elems)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + tab[vgetq_lane_s32(idxvec.val, 2)], + tab[vgetq_lane_s32(idxvec.val, 3)] + }; + return v_float32x4(vld1q_f32(elems)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + /*int CV_DECL_ALIGNED(32) idx[4]; + v_store(idx, idxvec); + + float32x4_t xy02 = vcombine_f32(vld1_f32(tab + idx[0]), vld1_f32(tab + idx[2])); + float32x4_t xy13 = vcombine_f32(vld1_f32(tab + idx[1]), vld1_f32(tab + idx[3])); + + float32x4x2_t xxyy = vuzpq_f32(xy02, xy13); + x = v_float32x4(xxyy.val[0]); + y = v_float32x4(xxyy.val[1]);*/ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); + y = v_float32x4(tab[idx[0]+1], tab[idx[1]+1], tab[idx[2]+1], tab[idx[3]+1]); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + return v_int8x16(vcombine_s8(vtbl1_s8(vget_low_s8(vec.val), vcreate_s8(0x0705060403010200)), vtbl1_s8(vget_high_s8(vec.val), vcreate_s8(0x0705060403010200)))); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + return v_int8x16(vcombine_s8(vtbl1_s8(vget_low_s8(vec.val), vcreate_s8(0x0703060205010400)), vtbl1_s8(vget_high_s8(vec.val), vcreate_s8(0x0703060205010400)))); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + return v_int16x8(vreinterpretq_s16_s8(vcombine_s8(vtbl1_s8(vget_low_s8(vreinterpretq_s8_s16(vec.val)), vcreate_s8(0x0706030205040100)), vtbl1_s8(vget_high_s8(vreinterpretq_s8_s16(vec.val)), vcreate_s8(0x0706030205040100))))); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + int16x4x2_t res = vzip_s16(vget_low_s16(vec.val), vget_high_s16(vec.val)); + return v_int16x8(vcombine_s16(res.val[0], res.val[1])); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + int32x2x2_t res = vzip_s32(vget_low_s32(vec.val), vget_high_s32(vec.val)); + return v_int32x4(vcombine_s32(res.val[0], res.val[1])); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + return v_int8x16(vextq_s8(vcombine_s8(vtbl1_s8(vget_low_s8(vec.val), vcreate_s8(0x0605040201000000)), vtbl1_s8(vget_high_s8(vec.val), vcreate_s8(0x0807060504020100))), vdupq_n_s8(0), 2)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + return v_int16x8(vreinterpretq_s16_s8(vextq_s8(vcombine_s8(vtbl1_s8(vget_low_s8(vreinterpretq_s8_s16(vec.val)), vcreate_s8(0x0504030201000000)), vget_high_s8(vreinterpretq_s8_s16(vec.val))), vdupq_n_s8(0), 2))); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#if CV_SIMD128_64F +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + double CV_DECL_ALIGNED(32) elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_float64x2(vld1q_f64(elems)); +} + +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(vld1q_f64(tab + idx[0])); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + double CV_DECL_ALIGNED(32) elems[2] = + { + tab[vgetq_lane_s32(idxvec.val, 0)], + tab[vgetq_lane_s32(idxvec.val, 1)], + }; + return v_float64x2(vld1q_f64(elems)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float64x2(tab[idx[0]], tab[idx[1]]); + y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); +} +#endif + +////// FP16 support /////// +#if CV_FP16 +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + float16x4_t v = + #ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro + (float16x4_t)vld1_s16((const short*)ptr); + #else + vld1_f16((const __fp16*)ptr); + #endif + return v_float32x4(vcvt_f32_f16(v)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + float16x4_t hv = vcvt_f16_f32(v.val); + + #ifndef vst1_f16 // APPLE compiler defines vst1_f16 as macro + vst1_s16((short*)ptr, (int16x4_t)hv); + #else + vst1_f16((__fp16*)ptr, hv); + #endif +} +#else +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + const int N = 4; + float buf[N]; + for( int i = 0; i < N; i++ ) buf[i] = (float)ptr[i]; + return v_load(buf); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + const int N = 4; + float buf[N]; + v_store(buf, v); + for( int i = 0; i < N; i++ ) ptr[i] = float16_t(buf[i]); +} +#endif + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv.hpp new file mode 100644 index 0000000..fe6c077 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv.hpp @@ -0,0 +1,2887 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// The original implementation has been contributed by Yin Zhang. +// Copyright (C) 2020, Institute of Software, Chinese Academy of Sciences. + +#ifndef OPENCV_HAL_INTRIN_RVV_HPP +#define OPENCV_HAL_INTRIN_RVV_HPP + +#include + +namespace cv +{ + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 + +//////////// Unsupported native intrinsics in C++ //////////// +// The following types have been defined in clang, but not in GCC yet. +#ifndef __clang__ + +struct vuint8mf2_t +{ + uchar val[8] = {0}; + vuint8mf2_t() {} + vuint8mf2_t(const uchar* ptr) + { + for (int i = 0; i < 8; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vint8mf2_t +{ + schar val[8] = {0}; + vint8mf2_t() {} + vint8mf2_t(const schar* ptr) + { + for (int i = 0; i < 8; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vuint16mf2_t +{ + ushort val[4] = {0}; + vuint16mf2_t() {} + vuint16mf2_t(const ushort* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vint16mf2_t +{ + short val[4] = {0}; + vint16mf2_t() {} + vint16mf2_t(const short* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vuint32mf2_t +{ + unsigned val[2] = {0}; + vuint32mf2_t() {} + vuint32mf2_t(const unsigned* ptr) + { + val[0] = ptr[0]; + val[1] = ptr[1]; + } +}; +struct vint32mf2_t +{ + int val[2] = {0}; + vint32mf2_t() {} + vint32mf2_t(const int* ptr) + { + val[0] = ptr[0]; + val[1] = ptr[1]; + } +}; +struct vfloat32mf2_t +{ + float val[2] = {0}; + vfloat32mf2_t() {} + vfloat32mf2_t(const float* ptr) + { + val[0] = ptr[0]; + val[1] = ptr[1]; + } +}; +struct vuint64mf2_t +{ + uint64 val[1] = {0}; + vuint64mf2_t() {} + vuint64mf2_t(const uint64* ptr) + { + val[0] = ptr[0]; + } +}; +struct vint64mf2_t +{ + int64 val[1] = {0}; + vint64mf2_t() {} + vint64mf2_t(const int64* ptr) + { + val[0] = ptr[0]; + } +}; +struct vfloat64mf2_t +{ + double val[1] = {0}; + vfloat64mf2_t() {} + vfloat64mf2_t(const double* ptr) + { + val[0] = ptr[0]; + } +}; +struct vuint8mf4_t +{ + uchar val[4] = {0}; + vuint8mf4_t() {} + vuint8mf4_t(const uchar* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; +struct vint8mf4_t +{ + schar val[4] = {0}; + vint8mf4_t() {} + vint8mf4_t(const schar* ptr) + { + for (int i = 0; i < 4; ++i) + { + val[i] = ptr[i]; + } + } +}; + +#define OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(_Tpvec, _Tp, suffix, width, n) \ +inline _Tpvec vle##width##_v_##suffix##mf2(const _Tp* ptr, size_t vl) \ +{ \ + CV_UNUSED(vl); \ + return _Tpvec(ptr); \ +} \ +inline void vse##width##_v_##suffix##mf2(_Tp* ptr, _Tpvec v, size_t vl) \ +{ \ + CV_UNUSED(vl); \ + for (int i = 0; i < n; ++i) \ + { \ + ptr[i] = v.val[i]; \ + } \ +} + +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint8mf2_t, uint8_t, u8, 8, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint8mf2_t, int8_t, i8, 8, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint16mf2_t, uint16_t, u16, 16, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint16mf2_t, int16_t, i16, 16, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint32mf2_t, uint32_t, u32, 32, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint32mf2_t, int32_t, i32, 32, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vfloat32mf2_t, float32_t, f32, 32, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vuint64mf2_t, uint64_t, u64, 64, 1) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vint64mf2_t, int64_t, i64, 64, 1) +OPENCV_HAL_IMPL_RVV_NATIVE_LOADSTORE_MF2(vfloat64mf2_t, float64_t, f64, 64, 1) + + +#define OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(_Tpwvec, _Tpvec, _wTp, wcvt, suffix, width, n) \ +inline _Tpwvec wcvt (_Tpvec v, size_t vl) \ +{ \ + _wTp tmp[n]; \ + for (int i = 0; i < n; ++i) \ + { \ + tmp[i] = (_wTp)v.val[i]; \ + } \ + return vle##width##_v_##suffix##m1(tmp, vl); \ +} + +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vuint16m1_t, vuint8mf2_t, ushort, vwcvtu_x_x_v_u16m1, u16, 16, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vint16m1_t, vint8mf2_t, short, vwcvt_x_x_v_i16m1, i16, 16, 8) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vuint32m1_t, vuint16mf2_t, unsigned, vwcvtu_x_x_v_u32m1, u32, 32, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vint32m1_t, vint16mf2_t, int, vwcvt_x_x_v_i32m1, i32, 32, 4) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vuint64m1_t, vuint32mf2_t, uint64, vwcvtu_x_x_v_u64m1, u64, 64, 2) +OPENCV_HAL_IMPL_RVV_NATIVE_WCVT(vint64m1_t, vint32mf2_t, int64, vwcvt_x_x_v_i64m1, i64, 64, 2) + +inline vuint8mf4_t vle8_v_u8mf4 (const uint8_t *base, size_t vl) +{ + CV_UNUSED(vl); + return vuint8mf4_t(base); +} +inline vint8mf4_t vle8_v_i8mf4 (const int8_t *base, size_t vl) +{ + CV_UNUSED(vl); + return vint8mf4_t(base); +} + +inline vuint16mf2_t vwcvtu_x_x_v_u16mf2 (vuint8mf4_t src, size_t vl) +{ + ushort tmp[4]; + for (int i = 0; i < 4; ++i) + { + tmp[i] = (ushort)src.val[i]; + } + return vle16_v_u16mf2(tmp, vl); +} +inline vint16mf2_t vwcvt_x_x_v_i16mf2 (vint8mf4_t src, size_t vl) +{ + short tmp[4]; + for (int i = 0; i < 4; ++i) + { + tmp[i] = (short)src.val[i]; + } + return vle16_v_i16mf2(tmp, vl); +} +#endif + +//////////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(vuint8m1_t v) + { + vse8_v_u8m1(val, v, nlanes); + } + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint8m1_t() const + { + return vle8_v_u8m1(val, nlanes); + } + uchar get0() const + { + return val[0]; + } + + uchar val[16]; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(vint8m1_t v) + { + vse8_v_i8m1(val, v, nlanes); + } + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint8m1_t() const + { + return vle8_v_i8m1(val, nlanes); + } + schar get0() const + { + return val[0]; + } + + schar val[16]; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(vuint16m1_t v) + { + vse16_v_u16m1(val, v, nlanes); + } + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint16m1_t() const + { + return vle16_v_u16m1(val, nlanes); + } + ushort get0() const + { + return val[0]; + } + + ushort val[8]; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(vint16m1_t v) + { + vse16_v_i16m1(val, v, nlanes); + } + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint16m1_t() const + { + return vle16_v_i16m1(val, nlanes); + } + short get0() const + { + return val[0]; + } + + short val[8]; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(vuint32m1_t v) + { + vse32_v_u32m1(val, v, nlanes); + } + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint32m1_t() const + { + return vle32_v_u32m1(val, nlanes); + } + unsigned get0() const + { + return val[0]; + } + + unsigned val[4]; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(vint32m1_t v) + { + vse32_v_i32m1(val, v, nlanes); + } + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint32m1_t() const + { + return vle32_v_i32m1(val, nlanes); + } + int get0() const + { + return val[0]; + } + int val[4]; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(vfloat32m1_t v) + { + vse32_v_f32m1(val, v, nlanes); + } + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vfloat32m1_t() const + { + return vle32_v_f32m1(val, nlanes); + } + float get0() const + { + return val[0]; + } + float val[4]; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(vuint64m1_t v) + { + vse64_v_u64m1(val, v, nlanes); + } + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vuint64m1_t() const + { + return vle64_v_u64m1(val, nlanes); + } + uint64 get0() const + { + return val[0]; + } + + uint64 val[2]; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(vint64m1_t v) + { + vse64_v_i64m1(val, v, nlanes); + } + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vint64m1_t() const + { + return vle64_v_i64m1(val, nlanes); + } + int64 get0() const + { + return val[0]; + } + + int64 val[2]; +}; + +#if CV_SIMD128_64F +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(vfloat64m1_t v) + { + vse64_v_f64m1(val, v, nlanes); + } + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + for (int i = 0; i < nlanes; ++i) + { + val[i] = v[i]; + } + } + operator vfloat64m1_t() const + { + return vle64_v_f64m1(val, nlanes); + } + double get0() const + { + return val[0]; + } + + double val[2]; +}; +#endif + + +//////////// Initial //////////// + +#define OPENCV_HAL_IMPL_RVV_INIT_INTEGER(_Tpvec, _Tp, suffix1, suffix2, vl) \ +inline v_##_Tpvec v_setzero_##suffix1() \ +{ \ + return v_##_Tpvec(vmv_v_x_##suffix2##m1(0, vl)); \ +} \ +inline v_##_Tpvec v_setall_##suffix1(_Tp v) \ +{ \ + return v_##_Tpvec(vmv_v_x_##suffix2##m1(v, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint8x16, uchar, u8, u8, 16) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int8x16, schar, s8, i8, 16) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint16x8, ushort, u16, u16, 8) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int16x8, short, s16, i16, 8) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint32x4, unsigned, u32, u32, 4) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int32x4, int, s32, i32, 4) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(uint64x2, uint64, u64, u64, 2) +OPENCV_HAL_IMPL_RVV_INIT_INTEGER(int64x2, int64, s64, i64, 2) + +#define OPENCV_HAL_IMPL_RVV_INIT_FP(_Tpv, _Tp, suffix, vl) \ +inline v_##_Tpv v_setzero_##suffix() \ +{ \ + return v_##_Tpv(vfmv_v_f_##suffix##m1(0, vl)); \ +} \ +inline v_##_Tpv v_setall_##suffix(_Tp v) \ +{ \ + return v_##_Tpv(vfmv_v_f_##suffix##m1(v, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_INIT_FP(float32x4, float, f32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_INIT_FP(float64x2, double, f64, 2) +#endif + +//////////// Reinterpret //////////// + +#define OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(_Tpvec, suffix) \ +inline v_##_Tpvec v_reinterpret_as_##suffix(const v_##_Tpvec& v) { return v; } + +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint8x16, u8) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int8x16, s8) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint16x8, u16) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int16x8, s16) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint32x4, u32) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int32x4, s32) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(float32x4, f32) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(uint64x2, u64) +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(int64x2, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_SELF_REINTERPRET(float64x2, f64) +#endif + +#define OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(_Tpvec1, _Tpvec2, suffix1, suffix2, nsuffix1, nsuffix2) \ +inline v_##_Tpvec1 v_reinterpret_as_##suffix1(const v_##_Tpvec2& v) \ +{ \ + return v_##_Tpvec1(vreinterpret_v_##nsuffix2##m1_##nsuffix1##m1(v));\ +} \ +inline v_##_Tpvec2 v_reinterpret_as_##suffix2(const v_##_Tpvec1& v) \ +{ \ + return v_##_Tpvec2(vreinterpret_v_##nsuffix1##m1_##nsuffix2##m1(v));\ +} + +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, int8x16, u8, s8, u8, i8) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint16x8, int16x8, u16, s16, u16, i16) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint32x4, int32x4, u32, s32, u32, i32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint32x4, float32x4, u32, f32, u32, f32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int32x4, float32x4, s32, f32, i32, f32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint64x2, int64x2, u64, s64, u64, i64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint64x2, float64x2, u64, f64, u64, f64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int64x2, float64x2, s64, f64, i64, f64) +#endif +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, uint16x8, u8, u16, u8, u16) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, uint32x4, u8, u32, u8, u32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint8x16, uint64x2, u8, u64, u8, u64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint16x8, uint32x4, u16, u32, u16, u32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint16x8, uint64x2, u16, u64, u16, u64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(uint32x4, uint64x2, u32, u64, u32, u64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int8x16, int16x8, s8, s16, i8, i16) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int8x16, int32x4, s8, s32, i8, i32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int8x16, int64x2, s8, s64, i8, i64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int16x8, int32x4, s16, s32, i16, i32) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int16x8, int64x2, s16, s64, i16, i64) +OPENCV_HAL_IMPL_RVV_NATIVE_REINTERPRET(int32x4, int64x2, s32, s64, i32, i64) + + +#define OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(_Tpvec1, _Tpvec2, suffix1, suffix2, nsuffix1, nsuffix2, width1, width2) \ +inline v_##_Tpvec1 v_reinterpret_as_##suffix1(const v_##_Tpvec2& v) \ +{ \ + return v_##_Tpvec1(vreinterpret_v_##nsuffix1##width2##m1_##nsuffix1##width1##m1(vreinterpret_v_##nsuffix2##width2##m1_##nsuffix1##width2##m1(v)));\ +} \ +inline v_##_Tpvec2 v_reinterpret_as_##suffix2(const v_##_Tpvec1& v) \ +{ \ + return v_##_Tpvec2(vreinterpret_v_##nsuffix1##width2##m1_##nsuffix2##width2##m1(vreinterpret_v_##nsuffix1##width1##m1_##nsuffix1##width2##m1(v)));\ +} + +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, int16x8, u8, s16, u, i, 8, 16) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, int32x4, u8, s32, u, i, 8, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, int64x2, u8, s64, u, i, 8, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, int8x16, u16, s8, u, i, 16, 8) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, int32x4, u16, s32, u, i, 16, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, int64x2, u16, s64, u, i, 16, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, int8x16, u32, s8, u, i, 32, 8) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, int16x8, u32, s16, u, i, 32, 16) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, int64x2, u32, s64, u, i, 32, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, int8x16, u64, s8, u, i, 64, 8) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, int16x8, u64, s16, u, i, 64, 16) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, int32x4, u64, s32, u, i, 64, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, float32x4, u8, f32, u, f, 8, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, float32x4, u16, f32, u, f, 16, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint64x2, float32x4, u64, f32, u, f, 64, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int8x16, float32x4, s8, f32, i, f, 8, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int16x8, float32x4, s16, f32, i, f, 16, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int64x2, float32x4, s64, f32, i, f, 64, 32) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint8x16, float64x2, u8, f64, u, f, 8, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint16x8, float64x2, u16, f64, u, f, 16, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(uint32x4, float64x2, u32, f64, u, f, 32, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int8x16, float64x2, s8, f64, i, f, 8, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int16x8, float64x2, s16, f64, i, f, 16, 64) +OPENCV_HAL_IMPL_RVV_TWO_TIMES_REINTERPRET(int32x4, float64x2, s32, f64, i, f, 32, 64) + +// Three times reinterpret +inline v_float32x4 v_reinterpret_as_f32(const v_float64x2& v) \ +{ \ + return v_float32x4(vreinterpret_v_u32m1_f32m1(vreinterpret_v_u64m1_u32m1(vreinterpret_v_f64m1_u64m1(v))));\ +} \ +inline v_float64x2 v_reinterpret_as_f64(const v_float32x4& v) \ +{ \ + return v_float64x2(vreinterpret_v_u64m1_f64m1(vreinterpret_v_u32m1_u64m1(vreinterpret_v_f32m1_u32m1(v))));\ +} + +////////////// Extract ////////////// + +#define OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(_Tpvec, _Tp, suffix, vmv, vl) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, s, vl), b, _Tpvec::nlanes - s, vl)); \ +} \ +template inline _Tp v_extract_n(_Tpvec v) \ +{ \ + return _Tp(vmv(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), v, i, vl))); \ +} + + +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint8x16, uchar, u8, vmv_x_s_u8m1_u8, 16) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int8x16, schar, i8, vmv_x_s_i8m1_i8, 16) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint16x8, ushort, u16, vmv_x_s_u16m1_u16, 8) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int16x8, short, i16, vmv_x_s_i16m1_i16, 8) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint32x4, uint, u32, vmv_x_s_u32m1_u32, 4) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int32x4, int, i32, vmv_x_s_i32m1_i32, 4) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_uint64x2, uint64, u64, vmv_x_s_u64m1_u64, 2) +OPENCV_HAL_IMPL_RVV_EXTRACT_INTEGER(v_int64x2, int64, i64, vmv_x_s_i64m1_i64, 2) + +#define OPENCV_HAL_IMPL_RVV_EXTRACT_FP(_Tpvec, _Tp, suffix, vmv, vl) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, s, vl), b, _Tpvec::nlanes - s, vl)); \ +} \ +template inline _Tp v_extract_n(_Tpvec v) \ +{ \ + return _Tp(vmv(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), v, i, vl))); \ +} + +OPENCV_HAL_IMPL_RVV_EXTRACT_FP(v_float32x4, float, f32, vfmv_f_s_f32m1_f32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_EXTRACT_FP(v_float64x2, double, f64, vfmv_f_s_f64m1_f64, 2) +#endif + +////////////// Load/Store ////////////// + +#define OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(_Tpvec, _nTpvec, _Tp, hvl, vl, width, suffix, vmv) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ \ + return _Tpvec(vle##width##_v_##suffix##m1(ptr, vl)); \ +} \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ \ + return _Tpvec(vle##width##_v_##suffix##m1(ptr, vl)); \ +} \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ \ + _Tpvec res = _Tpvec(vle##width##_v_##suffix##m1(ptr, hvl)); \ + return res; \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, vl); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, a, hvl); \ +} \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + vse##width##_v_##suffix##m1(ptr, vslidedown_vx_##suffix##m1(vmv(0, vl), a, hvl, vl), hvl); \ +} + +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint8x16, vuint8m1_t, uchar, 8, 16, 8, u8, vmv_v_x_u8m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int8x16, vint8m1_t, schar, 8, 16, 8, i8, vmv_v_x_i8m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint16x8, vuint16m1_t, ushort, 4, 8, 16, u16, vmv_v_x_u16m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int16x8, vint16m1_t, short, 4, 8, 16, i16, vmv_v_x_i16m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint32x4, vuint32m1_t, unsigned, 2, 4, 32, u32, vmv_v_x_u32m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int32x4, vint32m1_t, int, 2, 4, 32, i32, vmv_v_x_i32m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_uint64x2, vuint64m1_t, uint64, 1, 2, 64, u64, vmv_v_x_u64m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_int64x2, vint64m1_t, int64, 1, 2, 64, i64, vmv_v_x_i64m1) +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float32x4, vfloat32m1_t, float, 2, 4, 32, f32, vfmv_v_f_f32m1) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float64x2, vfloat64m1_t, double, 1, 2, 64, f64, vfmv_v_f_f64m1) +#endif + +inline v_int8x16 v_load_halves(const schar* ptr0, const schar* ptr1) +{ + schar elems[16] = + { + ptr0[0], ptr0[1], ptr0[2], ptr0[3], ptr0[4], ptr0[5], ptr0[6], ptr0[7], + ptr1[0], ptr1[1], ptr1[2], ptr1[3], ptr1[4], ptr1[5], ptr1[6], ptr1[7] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_uint8x16 v_load_halves(const uchar* ptr0, const uchar* ptr1) { return v_reinterpret_as_u8(v_load_halves((schar*)ptr0, (schar*)ptr1)); } + +inline v_int16x8 v_load_halves(const short* ptr0, const short* ptr1) +{ + short elems[8] = + { + ptr0[0], ptr0[1], ptr0[2], ptr0[3], ptr1[0], ptr1[1], ptr1[2], ptr1[3] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_uint16x8 v_load_halves(const ushort* ptr0, const ushort* ptr1) { return v_reinterpret_as_u16(v_load_halves((short*)ptr0, (short*)ptr1)); } + +inline v_int32x4 v_load_halves(const int* ptr0, const int* ptr1) +{ + int elems[4] = + { + ptr0[0], ptr0[1], ptr1[0], ptr1[1] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} +inline v_float32x4 v_load_halves(const float* ptr0, const float* ptr1) +{ + float elems[4] = + { + ptr0[0], ptr0[1], ptr1[0], ptr1[1] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} +inline v_uint32x4 v_load_halves(const unsigned* ptr0, const unsigned* ptr1) { return v_reinterpret_as_u32(v_load_halves((int*)ptr0, (int*)ptr1)); } + +inline v_int64x2 v_load_halves(const int64* ptr0, const int64* ptr1) +{ + int64 elems[2] = + { + ptr0[0], ptr1[0] + }; + return v_int64x2(vle64_v_i64m1(elems, 2)); +} +inline v_uint64x2 v_load_halves(const uint64* ptr0, const uint64* ptr1) { return v_reinterpret_as_u64(v_load_halves((int64*)ptr0, (int64*)ptr1)); } + +#if CV_SIMD128_64F +inline v_float64x2 v_load_halves(const double* ptr0, const double* ptr1) +{ + double elems[2] = + { + ptr0[0], ptr1[0] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} +#endif + + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + schar elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + schar elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(vle8_v_i8m1(elems, 16)); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + short elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3] + }; + return v_int16x8(vle16_v_i16m1(elems, 8)); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + int elems[4] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vle32_v_i32m1(tab + idx[0], 4)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + int64_t elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_int64x2(vle64_v_i64m1(elems, 2)); +} +inline v_int64x2 v_lut_pairs(const int64* tab, const int* idx) +{ + return v_int64x2(vle64_v_i64m1(tab + idx[0], 2)); +} +inline v_uint64x2 v_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + float elems[4] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(vle32_v_f32m1(tab + idx[0], 4)); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int elems[4] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)], + tab[v_extract_n<2>(idxvec)], + tab[v_extract_n<3>(idxvec)] + }; + return v_int32x4(vle32_v_i32m1(elems, 4)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned elems[4] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)], + tab[v_extract_n<2>(idxvec)], + tab[v_extract_n<3>(idxvec)] + }; + return v_uint32x4(vle32_v_u32m1(elems, 4)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + float elems[4] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)], + tab[v_extract_n<2>(idxvec)], + tab[v_extract_n<3>(idxvec)] + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + int idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); + y = v_float32x4(tab[idx[0]+1], tab[idx[1]+1], tab[idx[2]+1], tab[idx[3]+1]); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + double elems[2] = + { + tab[idx[0]], + tab[idx[1]] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(vle64_v_f64m1(tab + idx[0], 2)); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + double elems[2] = + { + tab[v_extract_n<0>(idxvec)], + tab[v_extract_n<1>(idxvec)] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int idx[4] = {0}; + v_store_aligned(idx, idxvec); + + x = v_float64x2(tab[idx[0]], tab[idx[1]]); + y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); +} +#endif + +////////////// Pack boolean //////////////////// + +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + ushort ptr[16] = {0}; + v_store(ptr, a); + v_store(ptr + 8, b); + return v_uint8x16(vnsrl_wx_u8m1(vle16_v_u16m2(ptr, 16), 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + unsigned ptr[16] = {0}; + v_store(ptr, a); + v_store(ptr + 4, b); + v_store(ptr + 8, c); + v_store(ptr + 12, d); + return v_uint8x16(vnsrl_wx_u8m1(vnsrl_wx_u16m2(vle32_v_u32m4(ptr, 16), 0, 16), 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + uint64 ptr[16] = {0}; + v_store(ptr, a); + v_store(ptr + 2, b); + v_store(ptr + 4, c); + v_store(ptr + 6, d); + v_store(ptr + 8, e); + v_store(ptr + 10, f); + v_store(ptr + 12, g); + v_store(ptr + 14, h); + return v_uint8x16(vnsrl_wx_u8m1(vnsrl_wx_u16m2(vnsrl_wx_u32m4(vle64_v_u64m8(ptr, 16), 0, 16), 0, 16), 0, 16)); +} + +////////////// Arithmetics ////////////// +#define OPENCV_HAL_IMPL_RVV_BIN_OP(bin_op, _Tpvec, intrin, vl) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a, b, vl)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a = _Tpvec(intrin(a, b, vl)); \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint8x16, vsaddu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint8x16, vssubu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint8x16, vdivu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int8x16, vsadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int8x16, vssub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int8x16, vdiv_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint16x8, vsaddu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint16x8, vssubu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint16x8, vdivu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int16x8, vsadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int16x8, vssub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int16x8, vdiv_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint32x4, vadd_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint32x4, vsub_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_uint32x4, vmul_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint32x4, vdivu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int32x4, vadd_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int32x4, vsub_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_int32x4, vmul_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int32x4, vdiv_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_float32x4, vfadd_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_float32x4, vfsub_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_float32x4, vfmul_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_float32x4, vfdiv_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_uint64x2, vadd_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_uint64x2, vsub_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_uint64x2, vmul_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_uint64x2, vdivu_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_int64x2, vadd_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_int64x2, vsub_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_int64x2, vmul_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_int64x2, vdiv_vv_i64m1, 2) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_BIN_OP(+, v_float64x2, vfadd_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(-, v_float64x2, vfsub_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(*, v_float64x2, vfmul_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_OP(/, v_float64x2, vfdiv_vv_f64m1, 2) +#endif + + +////////////// Bitwise logic ////////////// + +#define OPENCV_HAL_IMPL_RVV_LOGIC_OP(_Tpvec, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_BIN_OP(&, _Tpvec, vand_vv_##suffix##m1, vl) \ +OPENCV_HAL_IMPL_RVV_BIN_OP(|, _Tpvec, vor_vv_##suffix##m1, vl) \ +OPENCV_HAL_IMPL_RVV_BIN_OP(^, _Tpvec, vxor_vv_##suffix##m1, vl) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ \ + return _Tpvec(vnot_v_##suffix##m1(a, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RVV_LOGIC_OP(v_int64x2, i64, 2) + +#define OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(vreinterpret_v_i32m1_f32m1(intrin(vreinterpret_v_f32m1_i32m1(a), vreinterpret_v_f32m1_i32m1(b), 4))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a = v_float32x4(vreinterpret_v_i32m1_f32m1(intrin(vreinterpret_v_f32m1_i32m1(a), vreinterpret_v_f32m1_i32m1(b), 4))); \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(&, vand_vv_i32m1) +OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(|, vor_vv_i32m1) +OPENCV_HAL_IMPL_RVV_FLT_BIT_OP(^, vxor_vv_i32m1) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4(vreinterpret_v_i32m1_f32m1(vnot_v_i32m1(vreinterpret_v_f32m1_i32m1(a), 4))); +} + +#if CV_SIMD128_64F +#define OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(vreinterpret_v_i64m1_f64m1(intrin(vreinterpret_v_f64m1_i64m1(a), vreinterpret_v_f64m1_i64m1(b), 2))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a = v_float64x2(vreinterpret_v_i64m1_f64m1(intrin(vreinterpret_v_f64m1_i64m1(a), vreinterpret_v_f64m1_i64m1(b), 2))); \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(&, vand_vv_i64m1) +OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(|, vor_vv_i64m1) +OPENCV_HAL_IMPL_RVV_FLT64_BIT_OP(^, vxor_vv_i64m1) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2(vreinterpret_v_i64m1_f64m1(vnot_v_i64m1(vreinterpret_v_f64m1_i64m1(a), 2))); +} +#endif + +////////////// Bitwise shifts ////////////// + +#define OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(_Tpvec, suffix, vl) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsrl_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ \ + return _Tpvec(vsrl_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} + +#define OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(_Tpvec, suffix, vl) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ \ + return _Tpvec(vsra_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ \ + return _Tpvec(vsll_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ \ + return _Tpvec(vsra_vx_##suffix##m1(a, uint8_t(n), vl)); \ +} + +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RVV_UNSIGNED_SHIFT_OP(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RVV_SIGNED_SHIFT_OP(v_int64x2, i64, 2) + + +////////////// Comparison ////////////// + +#define OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, op, intrin, suffix, vl) \ +inline _Tpvec operator op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + uint64_t ones = -1; \ + return _Tpvec(vmerge_vxm_##suffix##m1(intrin(a, b, vl), vmv_v_x_##suffix##m1(0, vl), ones, vl)); \ +} + +#define OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, op, intrin, suffix, vl) \ +inline _Tpvec operator op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + union { uint64 u; double d; } ones; ones.u = -1; \ + return _Tpvec(vfmerge_vfm_##suffix##m1(intrin(a, b, vl), vfmv_v_f_##suffix##m1(0, vl), ones.d, vl)); \ +} + +#define OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(_Tpvec, suffix, width, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, ==, vmseq_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, !=, vmsne_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <, vmsltu_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >, vmsgtu_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <=, vmsleu_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >=, vmsgeu_vv_##suffix##m1_b##width, suffix, vl) + +#define OPENCV_HAL_IMPL_RVV_SIGNED_CMP(_Tpvec, suffix, width, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, ==, vmseq_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, !=, vmsne_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <, vmslt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >, vmsgt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, <=, vmsle_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_INT_CMP_OP(_Tpvec, >=, vmsge_vv_##suffix##m1_b##width, suffix, vl) + +#define OPENCV_HAL_IMPL_RVV_FLOAT_CMP(_Tpvec, suffix, width, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, ==, vmfeq_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, !=, vmfne_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, <, vmflt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, >, vmfgt_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, <=, vmfle_vv_##suffix##m1_b##width, suffix, vl) \ +OPENCV_HAL_IMPL_RVV_FLOAT_CMP_OP(_Tpvec, >=, vmfge_vv_##suffix##m1_b##width, suffix, vl) + + +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint8x16, u8, 8, 16) +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint16x8, u16, 16, 8) +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint32x4, u32, 32, 4) +OPENCV_HAL_IMPL_RVV_UNSIGNED_CMP(v_uint64x2, u64, 64, 2) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int8x16, i8, 8, 16) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int16x8, i16, 16, 8) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int32x4, i32, 32, 4) +OPENCV_HAL_IMPL_RVV_SIGNED_CMP(v_int64x2, i64, 64, 2) +OPENCV_HAL_IMPL_RVV_FLOAT_CMP(v_float32x4, f32, 32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_FLOAT_CMP(v_float64x2, f64, 64, 2) +#endif + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return a == a; } + +#if CV_SIMD128_64F +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return a == a; } +#endif + +////////////// Min/Max ////////////// + +#define OPENCV_HAL_IMPL_RVV_BIN_FUNC(_Tpvec, func, intrin, vl) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a, b, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_min, vminu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_max, vmaxu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_min, vmin_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_max, vmax_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_min, vminu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_max, vmaxu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_min, vmin_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_max, vmax_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint32x4, v_min, vminu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint32x4, v_max, vmaxu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int32x4, v_min, vmin_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int32x4, v_max, vmax_vv_i32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float32x4, v_min, vfmin_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float32x4, v_max, vfmax_vv_f32m1, 4) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint64x2, v_min, vminu_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint64x2, v_max, vmaxu_vv_u64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int64x2, v_min, vmin_vv_i64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int64x2, v_max, vmax_vv_i64m1, 2) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float64x2, v_min, vfmin_vv_f64m1, 2) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_float64x2, v_max, vfmax_vv_f64m1, 2) +#endif + +////////////// Arithmetics wrap ////////////// + +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_add_wrap, vadd_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_add_wrap, vadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_add_wrap, vadd_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_add_wrap, vadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_sub_wrap, vsub_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_sub_wrap, vsub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_sub_wrap, vsub_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_sub_wrap, vsub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint8x16, v_mul_wrap, vmul_vv_u8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int8x16, v_mul_wrap, vmul_vv_i8m1, 16) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_uint16x8, v_mul_wrap, vmul_vv_u16m1, 8) +OPENCV_HAL_IMPL_RVV_BIN_FUNC(v_int16x8, v_mul_wrap, vmul_vv_i16m1, 8) + +////////////// Reduce ////////////// + +#define OPENCV_HAL_IMPL_RVV_REDUCE_SUM(_Tpvec, _wTpvec, _nwTpvec, scalartype, suffix, wsuffix, vl, red) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + _nwTpvec zero = vmv_v_x_##wsuffix##m1(0, vl); \ + _nwTpvec res = vmv_v_x_##wsuffix##m1(0, vl); \ + res = v##red##_vs_##suffix##m1_##wsuffix##m1(res, a, zero, vl); \ + return (scalartype)(_wTpvec(res).get0()); \ +} + +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint8x16, v_uint16x8, vuint16m1_t, unsigned, u8, u16, 16, wredsumu) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int8x16, v_int16x8, vint16m1_t, int, i8, i16, 16, wredsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint16x8, v_uint32x4, vuint32m1_t, unsigned, u16, u32, 8, wredsumu) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int16x8, v_int32x4, vint32m1_t, int, i16, i32, 8, wredsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint32x4, v_uint64x2, vuint64m1_t, unsigned, u32, u64, 4, wredsumu) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int32x4, v_int64x2, vint64m1_t, int, i32, i64, 4, wredsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_uint64x2, v_uint64x2, vuint64m1_t, uint64, u64, u64, 2, redsum) +OPENCV_HAL_IMPL_RVV_REDUCE_SUM(v_int64x2, v_int64x2, vint64m1_t, int64, i64, i64, 2, redsum) + +#define OPENCV_HAL_IMPL_RVV_REDUCE_SUM_FP(_Tpvec, _wTpvec, _nwTpvec, scalartype, suffix, wsuffix, vl, red) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + _nwTpvec zero = vfmv_v_f_##wsuffix##m1(0, vl); \ + _nwTpvec res = vfmv_v_f_##wsuffix##m1(0, vl); \ + res = v##red##_vs_##suffix##m1_##wsuffix##m1(res, a, zero, vl); \ + return (scalartype)(_wTpvec(res).get0()); \ +} + +// vfredsum for float has renamed to fredosum, also updated in GNU. +OPENCV_HAL_IMPL_RVV_REDUCE_SUM_FP(v_float32x4, v_float32x4, vfloat32m1_t, float, f32, f32, 4, fredosum) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_REDUCE_SUM_FP(v_float64x2, v_float64x2, vfloat64m1_t, double, f64, f64, 2, fredosum) +#endif + + +#define OPENCV_HAL_IMPL_RVV_REDUCE(_Tpvec, func, scalartype, suffix, vl, red) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + _Tpvec res = _Tpvec(v##red##_vs_##suffix##m1_##suffix##m1(a, a, a, vl)); \ + return scalartype(res.get0()); \ +} + +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint8x16, min, uchar, u8, 16, redminu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int8x16, min, schar, i8, 16, redmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint16x8, min, ushort, u16, 8, redminu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int16x8, min, short, i16, 8, redmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint32x4, min, unsigned, u32, 4, redminu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int32x4, min, int, i32, 4, redmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_float32x4, min, float, f32, 4, fredmin) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint8x16, max, uchar, u8, 16, redmaxu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int8x16, max, schar, i8, 16, redmax) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint16x8, max, ushort, u16, 8, redmaxu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int16x8, max, short, i16, 8, redmax) +OPENCV_HAL_IMPL_RVV_REDUCE(v_uint32x4, max, unsigned, u32, 4, redmaxu) +OPENCV_HAL_IMPL_RVV_REDUCE(v_int32x4, max, int, i32, 4, redmax) +OPENCV_HAL_IMPL_RVV_REDUCE(v_float32x4, max, float, f32, 4, fredmax) + + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + float elems[4] = + { + v_reduce_sum(a), + v_reduce_sum(b), + v_reduce_sum(c), + v_reduce_sum(d) + }; + return v_float32x4(vle32_v_f32m1(elems, 4)); +} + +////////////// Square-Root ////////////// + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(vfsqrt_v_f32m1(x, 4)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + v_float32x4 one = v_setall_f32(1.0f); + return one / v_sqrt(x); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(vfsqrt_v_f64m1(x, 4)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + v_float64x2 one = v_setall_f64(1.0f); + return one / v_sqrt(x); +} +#endif + +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(vfmacc_vv_f32m1(vfmul_vv_f32m1(a, a, 4), b, b, 4)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vfmacc_vv_f32m1(vfmul_vv_f32m1(a, a, 4), b, b, 4)); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(vfmacc_vv_f64m1(vfmul_vv_f64m1(a, a, 2), b, b, 2)); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vfmacc_vv_f64m1(vfmul_vv_f64m1(a, a, 2), b, b, 2)); +} +#endif + +////////////// Multiply-Add ////////////// + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_float32x4(vfmacc_vv_f32m1(c, a, b, 4)); +} +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(vmacc_vv_i32m1(c, a, b, 4)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +#if CV_SIMD128_64F +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(vfmacc_vv_f64m1(c, a, b, 2)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} +#endif + +////////////// Check all/any ////////////// + +// use overloaded vcpop in clang, no casting like (vuint64m1_t) is needed. +#ifndef __clang__ +#define OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(_Tpvec, suffix, shift, vl) \ +inline bool v_check_all(const _Tpvec& a) \ +{ \ + v_uint64x2 v = v_uint64x2((vuint64m1_t)vsrl_vx_##suffix##m1(vnot_v_##suffix##m1(a, vl), shift, vl)); \ + return (v.val[0] | v.val[1]) == 0; \ +} \ +inline bool v_check_any(const _Tpvec& a) \ +{ \ + v_uint64x2 v = v_uint64x2((vuint64m1_t)vsrl_vx_##suffix##m1(a, shift, vl)); \ + return (v.val[0] | v.val[1]) != 0; \ +} + +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint8x16, u8, 7, 16) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint16x8, u16, 15, 8) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint32x4, u32, 31, 4) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint64x2, u64, 63, 2) + + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } + +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } + +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } + +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } + +#if CV_SIMD128_64F +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +#endif +#else +#define OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(_Tpvec, vl) \ +inline bool v_check_all(const _Tpvec& a) \ +{ \ + return vcpop(vmslt(a, 0, vl), vl) == vl; \ +} \ +inline bool v_check_any(const _Tpvec& a) \ +{ \ + return vcpop(vmslt(a, 0, vl), vl) != 0; \ +} + +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int8x16, 16) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int16x8, 8) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int32x4, 4) +OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_int64x2, 2) + + +inline bool v_check_all(const v_uint8x16& a) +{ return v_check_all(v_reinterpret_as_s8(a)); } +inline bool v_check_any(const v_uint8x16& a) +{ return v_check_any(v_reinterpret_as_s8(a)); } + +inline bool v_check_all(const v_uint16x8& a) +{ return v_check_all(v_reinterpret_as_s16(a)); } +inline bool v_check_any(const v_uint16x8& a) +{ return v_check_any(v_reinterpret_as_s16(a)); } + +inline bool v_check_all(const v_uint32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_uint32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } + +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } + +inline bool v_check_all(const v_uint64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_uint64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } + +#if CV_SIMD128_64F +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } +#endif +#endif +////////////// abs ////////////// + +#define OPENCV_HAL_IMPL_RVV_ABSDIFF(_Tpvec, abs) \ +inline _Tpvec v_##abs(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return v_max(a, b) - v_min(a, b); \ +} + +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_uint8x16, absdiff) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_uint16x8, absdiff) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_uint32x4, absdiff) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_float32x4, absdiff) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_float64x2, absdiff) +#endif +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_int8x16, absdiffs) +OPENCV_HAL_IMPL_RVV_ABSDIFF(v_int16x8, absdiffs) + +// use reinterpret instead of c-style casting. +#ifndef __clang__ +#define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, vl) \ +inline _rTpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _rTpvec(rshr((_nwTpvec)sub(v_max(a, b), v_min(a, b), vl), 0, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int8x16, v_uint8x16, vuint16m2_t, vwsub_vv_i16m2, vnclipu_wx_u8m1, 16) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int16x8, v_uint16x8, vuint32m2_t, vwsub_vv_i32m2, vnclipu_wx_u16m1, 8) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int32x4, v_uint32x4, vuint64m2_t, vwsub_vv_i64m2, vnclipu_wx_u32m1, 4) +#else +#define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, width, vl) \ +inline _rTpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _rTpvec(rshr(vreinterpret_u##width##m2(sub(v_max(a, b), v_min(a, b), vl)), 0, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int8x16, v_uint8x16, vuint16m2_t, vwsub_vv_i16m2, vnclipu_wx_u8m1, 16, 16) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int16x8, v_uint16x8, vuint32m2_t, vwsub_vv_i32m2, vnclipu_wx_u16m1, 32, 8) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int32x4, v_uint32x4, vuint64m2_t, vwsub_vv_i64m2, vnclipu_wx_u32m1, 64, 4) +#endif +#define OPENCV_HAL_IMPL_RVV_ABS(_Tprvec, _Tpvec, suffix) \ +inline _Tprvec v_abs(const _Tpvec& a) \ +{ \ + return v_absdiff(a, v_setzero_##suffix()); \ +} + +OPENCV_HAL_IMPL_RVV_ABS(v_uint8x16, v_int8x16, s8) +OPENCV_HAL_IMPL_RVV_ABS(v_uint16x8, v_int16x8, s16) +OPENCV_HAL_IMPL_RVV_ABS(v_uint32x4, v_int32x4, s32) +OPENCV_HAL_IMPL_RVV_ABS(v_float32x4, v_float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_ABS(v_float64x2, v_float64x2, f64) +#endif + + +#define OPENCV_HAL_IMPL_RVV_REDUCE_SAD(_Tpvec, scalartype) \ +inline scalartype v_reduce_sad(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return v_reduce_sum(v_absdiff(a, b)); \ +} + +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_uint8x16, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_int8x16, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_uint16x8, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_int16x8, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_uint32x4, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_int32x4, unsigned) +OPENCV_HAL_IMPL_RVV_REDUCE_SAD(v_float32x4, float) + +////////////// Select ////////////// + +#define OPENCV_HAL_IMPL_RVV_SELECT(_Tpvec, merge, ne, vl) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(merge(ne(mask, 0, vl), b, a, vl)); \ +} + +OPENCV_HAL_IMPL_RVV_SELECT(v_uint8x16, vmerge_vvm_u8m1, vmsne_vx_u8m1_b8, 16) +OPENCV_HAL_IMPL_RVV_SELECT(v_int8x16, vmerge_vvm_i8m1, vmsne_vx_i8m1_b8, 16) +OPENCV_HAL_IMPL_RVV_SELECT(v_uint16x8, vmerge_vvm_u16m1, vmsne_vx_u16m1_b16, 8) +OPENCV_HAL_IMPL_RVV_SELECT(v_int16x8, vmerge_vvm_i16m1, vmsne_vx_i16m1_b16, 8) +OPENCV_HAL_IMPL_RVV_SELECT(v_uint32x4, vmerge_vvm_u32m1, vmsne_vx_u32m1_b32, 4) +OPENCV_HAL_IMPL_RVV_SELECT(v_int32x4, vmerge_vvm_i32m1, vmsne_vx_i32m1_b32, 4) +OPENCV_HAL_IMPL_RVV_SELECT(v_float32x4, vmerge_vvm_f32m1, vmfne_vf_f32m1_b32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_SELECT(v_float64x2, vmerge_vvm_f64m1, vmfne_vf_f64m1_b64, 2) +#endif + +////////////// Rotate shift ////////////// + +#define OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(_Tpvec, suffix, vl) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), a, n, vl), b, _Tpvec::nlanes - n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vmv_v_x_##suffix##m1(0, vl), b, _Tpvec::nlanes - n, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ CV_UNUSED(b); return a; } + +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RVV_ROTATE_INTEGER(v_int64x2, i64, 2) + +#define OPENCV_HAL_IMPL_RVV_ROTATE_FP(_Tpvec, suffix, vl) \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), a, n, vl), b, _Tpvec::nlanes - n, vl)); \ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vslideup_vx_##suffix##m1(vslidedown_vx_##suffix##m1(vfmv_v_f_##suffix##m1(0, vl), b, _Tpvec::nlanes - n, vl), a, n, vl)); \ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ CV_UNUSED(b); return a; } + +OPENCV_HAL_IMPL_RVV_ROTATE_FP(v_float32x4, f32, 4) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_ROTATE_FP(v_float64x2, f64, 2) +#endif + +////////////// Convert to float ////////////// + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(vfcvt_f_x_v_f32m1(a, 4)); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + double arr[4] = {a.val[0], a.val[1], 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_float32x4(vfncvt_f_f_w_f32m1(tmp, 4)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + double arr[4] = {a.val[0], a.val[1], b.val[0], b.val[1]}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_float32x4(vfncvt_f_f_w_f32m1(tmp, 4)); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_x_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[0], ptr[1] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_x_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[2], ptr[3] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_f_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[0], ptr[1] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + double ptr[4] = {0}; + vse64_v_f64m2(ptr, vfwcvt_f_f_v_f64m2(a, 4), 4); + double elems[2] = + { + ptr[2], ptr[3] + }; + return v_float64x2(vle64_v_f64m1(elems, 2)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ + return v_float64x2(vfcvt_f_x_v_f64m1(a, 2)); +} +#endif + +////////////// Broadcast ////////////// + +#define OPENCV_HAL_IMPL_RVV_BROADCAST(_Tpvec, suffix) \ +template inline _Tpvec v_broadcast_element(_Tpvec v) \ +{ \ + return v_setall_##suffix(v_extract_n(v)); \ +} + +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint8x16, u8) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int8x16, s8) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint16x8, u16) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int16x8, s16) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint32x4, u32) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int32x4, s32) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_uint64x2, u64) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_int64x2, s64) +OPENCV_HAL_IMPL_RVV_BROADCAST(v_float32x4, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_BROADCAST(v_float64x2, f64) +#endif + +////////////// Transpose4x4 ////////////// + +#define OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(_Tpvec, _Tp, suffix) \ +inline void v_transpose4x4(const v_##_Tpvec& a0, const v_##_Tpvec& a1, \ + const v_##_Tpvec& a2, const v_##_Tpvec& a3, \ + v_##_Tpvec& b0, v_##_Tpvec& b1, \ + v_##_Tpvec& b2, v_##_Tpvec& b3) \ +{ \ + _Tp elems0[4] = \ + { \ + v_extract_n<0>(a0), \ + v_extract_n<0>(a1), \ + v_extract_n<0>(a2), \ + v_extract_n<0>(a3) \ + }; \ + b0 = v_load(elems0); \ + _Tp elems1[4] = \ + { \ + v_extract_n<1>(a0), \ + v_extract_n<1>(a1), \ + v_extract_n<1>(a2), \ + v_extract_n<1>(a3) \ + }; \ + b1 = v_load(elems1); \ + _Tp elems2[4] = \ + { \ + v_extract_n<2>(a0), \ + v_extract_n<2>(a1), \ + v_extract_n<2>(a2), \ + v_extract_n<2>(a3) \ + }; \ + b2 = v_load(elems2); \ + _Tp elems3[4] = \ + { \ + v_extract_n<3>(a0), \ + v_extract_n<3>(a1), \ + v_extract_n<3>(a2), \ + v_extract_n<3>(a3) \ + }; \ + b3 = v_load(elems3); \ +} + +OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(int32x4, int, i32) +OPENCV_HAL_IMPL_RVV_TRANSPOSE4x4(float32x4, float, f32) + +////////////// Reverse ////////////// + +#define OPENCV_HAL_IMPL_RVV_REVERSE(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_reverse(const _Tpvec& a) \ +{ \ + _Tp ptr[_Tpvec::nlanes] = {0}; \ + _Tp ptra[_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + for (int i = 0; i < _Tpvec::nlanes; i++) \ + { \ + ptr[i] = ptra[_Tpvec::nlanes-i-1]; \ + } \ + return v_load(ptr); \ +} + +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int8x16, schar, i8) +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int16x8, short, i16) +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int32x4, int, i32) +OPENCV_HAL_IMPL_RVV_REVERSE(v_float32x4, float, f32) +OPENCV_HAL_IMPL_RVV_REVERSE(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_RVV_REVERSE(v_int64x2, int64, i64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_REVERSE(v_float64x2, double, f64) +#endif + +//////////// Value reordering //////////// + +#define OPENCV_HAL_IMPL_RVV_EXPAND(_Tpwvec, _Tp, _Tpvec, width, suffix, wcvt, vl) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + _Tp lptr[_Tpvec::nlanes/2] = {0}; \ + _Tp hptr[_Tpvec::nlanes/2] = {0}; \ + v_store_low(lptr, a); \ + v_store_high(hptr, a); \ + b0 = _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(lptr, vl), vl)); \ + b1 = _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(hptr, vl), vl)); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + _Tp lptr[_Tpvec::nlanes/2] = {0}; \ + v_store_low(lptr, a); \ + return _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(lptr, vl), vl)); \ +} \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + _Tp hptr[_Tpvec::nlanes/2] = {0}; \ + v_store_high(hptr, a); \ + return _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(hptr, vl), vl)); \ +} \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + return _Tpwvec(wcvt(vle##width##_v_##suffix##mf2(ptr, vl), vl)); \ +} + +OPENCV_HAL_IMPL_RVV_EXPAND(v_uint16x8, uchar, v_uint8x16, 8, u8, vwcvtu_x_x_v_u16m1, 8) +OPENCV_HAL_IMPL_RVV_EXPAND(v_int16x8, schar, v_int8x16, 8, i8, vwcvt_x_x_v_i16m1, 8) +OPENCV_HAL_IMPL_RVV_EXPAND(v_uint32x4, ushort, v_uint16x8, 16, u16, vwcvtu_x_x_v_u32m1, 4) +OPENCV_HAL_IMPL_RVV_EXPAND(v_int32x4, short, v_int16x8, 16, i16, vwcvt_x_x_v_i32m1, 4) +OPENCV_HAL_IMPL_RVV_EXPAND(v_uint64x2, uint, v_uint32x4, 32, u32, vwcvtu_x_x_v_u64m1, 2) +OPENCV_HAL_IMPL_RVV_EXPAND(v_int64x2, int, v_int32x4, 32, i32, vwcvt_x_x_v_i64m1, 2) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + return v_uint32x4(vwcvtu_x_x_v_u32m1(vwcvtu_x_x_v_u16mf2(vle8_v_u8mf4(ptr, 4), 4), 4)); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + return v_int32x4(vwcvt_x_x_v_i32m1(vwcvt_x_x_v_i16mf2(vle8_v_i8mf4(ptr, 4), 4), 4)); +} + + +#define OPENCV_HAL_IMPL_RVV_PACK(_Tpvec, _Tp, _wTpvec, _wTp, hwidth, width, hsuffix, suffix, rshr, shr, hvl, vl) \ +inline _Tpvec v_pack(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(shr(vle##width##_v_##suffix##m2(arr, vl), 0, vl)); \ +} \ +inline void v_pack_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + vse##hwidth##_v_##hsuffix##m1(ptr, shr(vle##width##_v_##suffix##m2(arr, vl), 0, vl), hvl); \ +} \ +template inline \ +_Tpvec v_rshr_pack(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(rshr(vle##width##_v_##suffix##m2(arr, vl), n, vl)); \ +} \ +template inline \ +void v_rshr_pack_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + vse##hwidth##_v_##hsuffix##m1(ptr, _Tpvec(rshr(vle##width##_v_##suffix##m2(arr, vl), n, vl)), hvl); \ +} + +OPENCV_HAL_IMPL_RVV_PACK(v_uint8x16, uchar, v_uint16x8, ushort, 8, 16, u8, u16, vnclipu_wx_u8m1, vnclipu_wx_u8m1, 8, 16) +OPENCV_HAL_IMPL_RVV_PACK(v_int8x16, schar, v_int16x8, short, 8, 16, i8, i16, vnclip_wx_i8m1, vnclip_wx_i8m1, 8, 16) +OPENCV_HAL_IMPL_RVV_PACK(v_uint16x8, ushort, v_uint32x4, unsigned, 16, 32, u16, u32, vnclipu_wx_u16m1, vnclipu_wx_u16m1, 4, 8) +OPENCV_HAL_IMPL_RVV_PACK(v_int16x8, short, v_int32x4, int, 16, 32, i16, i32, vnclip_wx_i16m1, vnclip_wx_i16m1, 4, 8) +OPENCV_HAL_IMPL_RVV_PACK(v_uint32x4, unsigned, v_uint64x2, uint64, 32, 64, u32, u64, vnclipu_wx_u32m1, vnsrl_wx_u32m1, 2, 4) +OPENCV_HAL_IMPL_RVV_PACK(v_int32x4, int, v_int64x2, int64, 32, 64, i32, i64, vnclip_wx_i32m1, vnsra_wx_i32m1, 2, 4) + + +#define OPENCV_HAL_IMPL_RVV_PACK_U(_Tpvec, _Tp, _wTpvec, _wTp, hwidth, width, hsuffix, suffix, rshr, cast, hvl, vl) \ +inline _Tpvec v_pack_u(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), 0, vl)); \ +} \ +inline void v_pack_u_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + vse##hwidth##_v_##hsuffix##m1(ptr, rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), 0, vl), hvl); \ +} \ +template inline \ +_Tpvec v_rshr_pack_u(const _wTpvec& a, const _wTpvec& b) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, b); \ + return _Tpvec(rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), n, vl)); \ +} \ +template inline \ +void v_rshr_pack_u_store(_Tp* ptr, const _wTpvec& a) \ +{ \ + _wTp arr[_Tpvec::nlanes] = {0}; \ + v_store(arr, a); \ + v_store(arr + _wTpvec::nlanes, _wTpvec(vmv_v_x_##suffix##m1(0, hvl))); \ + v_store(ptr, _Tpvec(rshr(cast(vmax_vx_##suffix##m2(vle##width##_v_##suffix##m2(arr, vl), 0, vl)), n, vl))); \ +} + +OPENCV_HAL_IMPL_RVV_PACK_U(v_uint8x16, uchar, v_int16x8, short, 8, 16, u8, i16, vnclipu_wx_u8m1, vreinterpret_v_i16m2_u16m2, 8, 16) +OPENCV_HAL_IMPL_RVV_PACK_U(v_uint16x8, ushort, v_int32x4, int, 16, 32, u16, i32, vnclipu_wx_u16m1, vreinterpret_v_i32m2_u32m2, 4, 8) + + +#define OPENCV_HAL_IMPL_RVV_UNPACKS(_Tpvec, _Tp, suffix) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + _Tp ptra0[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptra1[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb0[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb1[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra0, a0); \ + v_store(ptra1, a1); \ + int i; \ + for( i = 0; i < v_##_Tpvec::nlanes/2; i++ ) \ + { \ + ptrb0[i*2] = ptra0[i]; \ + ptrb0[i*2+1] = ptra1[i]; \ + } \ + for( ; i < v_##_Tpvec::nlanes; i++ ) \ + { \ + ptrb1[i*2-v_##_Tpvec::nlanes] = ptra0[i]; \ + ptrb1[i*2-v_##_Tpvec::nlanes+1] = ptra1[i]; \ + } \ + b0 = v_load(ptrb0); \ + b1 = v_load(ptrb1); \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes/2] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes/2] = {0}; \ + v_store_low(ptra, a); \ + v_store_low(ptrb, b); \ + return v_load_halves(ptra, ptrb); \ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes/2] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes/2] = {0}; \ + v_store_high(ptra, a); \ + v_store_high(ptrb, b); \ + return v_load_halves(ptra, ptrb); \ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c = v_combine_low(a, b); \ + d = v_combine_high(a, b); \ +} + +OPENCV_HAL_IMPL_RVV_UNPACKS(uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RVV_UNPACKS(int8x16, schar, i8) +OPENCV_HAL_IMPL_RVV_UNPACKS(uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RVV_UNPACKS(int16x8, short, i16) +OPENCV_HAL_IMPL_RVV_UNPACKS(uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_UNPACKS(int32x4, int, i32) +OPENCV_HAL_IMPL_RVV_UNPACKS(float32x4, float, f32) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_UNPACKS(float64x2, double, f64) +#endif + + +#define OPENCV_HAL_IMPL_RVV_INTERLEAVED(_Tpvec, _Tp) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + int i, i2; \ + for( i = i2 = 0; i < v_##_Tpvec::nlanes; i++, i2 += 2 ) \ + { \ + ptra[i] = ptr[i2]; \ + ptrb[i] = ptr[i2+1]; \ + } \ + a = v_load(ptra); \ + b = v_load(ptrb); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, v_##_Tpvec& c) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + int i, i3; \ + for( i = i3 = 0; i < v_##_Tpvec::nlanes; i++, i3 += 3 ) \ + { \ + ptra[i] = ptr[i3]; \ + ptrb[i] = ptr[i3+1]; \ + ptrc[i] = ptr[i3+2]; \ + } \ + a = v_load(ptra); \ + b = v_load(ptrb); \ + c = v_load(ptrc); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec& a, v_##_Tpvec& b, \ + v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrd[v_##_Tpvec::nlanes] = {0}; \ + int i, i4; \ + for( i = i4 = 0; i < v_##_Tpvec::nlanes; i++, i4 += 4 ) \ + { \ + ptra[i] = ptr[i4]; \ + ptrb[i] = ptr[i4+1]; \ + ptrc[i] = ptr[i4+2]; \ + ptrd[i] = ptr[i4+3]; \ + } \ + a = v_load(ptra); \ + b = v_load(ptrb); \ + c = v_load(ptrc); \ + d = v_load(ptrd); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + int i, i2; \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + v_store(ptrb, b); \ + for( i = i2 = 0; i < v_##_Tpvec::nlanes; i++, i2 += 2 ) \ + { \ + ptr[i2] = ptra[i]; \ + ptr[i2+1] = ptrb[i]; \ + } \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + int i, i3; \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + v_store(ptrb, b); \ + v_store(ptrc, c); \ + for( i = i3 = 0; i < v_##_Tpvec::nlanes; i++, i3 += 3 ) \ + { \ + ptr[i3] = ptra[i]; \ + ptr[i3+1] = ptrb[i]; \ + ptr[i3+2] = ptrc[i]; \ + } \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec& a, const v_##_Tpvec& b, \ + const v_##_Tpvec& c, const v_##_Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + int i, i4; \ + _Tp ptra[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrb[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrc[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrd[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptra, a); \ + v_store(ptrb, b); \ + v_store(ptrc, c); \ + v_store(ptrd, d); \ + for( i = i4 = 0; i < v_##_Tpvec::nlanes; i++, i4 += 4 ) \ + { \ + ptr[i4] = ptra[i]; \ + ptr[i4+1] = ptrb[i]; \ + ptr[i4+2] = ptrc[i]; \ + ptr[i4+3] = ptrd[i]; \ + } \ +} \ +inline v_##_Tpvec v_interleave_pairs(const v_##_Tpvec& vec) \ +{ \ + _Tp ptr[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrvec[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptrvec, vec); \ + for (int i = 0; i < v_##_Tpvec::nlanes/4; i++) \ + { \ + ptr[4*i ] = ptrvec[4*i ]; \ + ptr[4*i+1] = ptrvec[4*i+2]; \ + ptr[4*i+2] = ptrvec[4*i+1]; \ + ptr[4*i+3] = ptrvec[4*i+3]; \ + } \ + return v_load(ptr); \ +} \ +inline v_##_Tpvec v_interleave_quads(const v_##_Tpvec& vec) \ +{ \ + _Tp ptr[v_##_Tpvec::nlanes] = {0}; \ + _Tp ptrvec[v_##_Tpvec::nlanes] = {0}; \ + v_store(ptrvec, vec); \ + for (int i = 0; i < v_##_Tpvec::nlanes/8; i++) \ + { \ + ptr[8*i ] = ptrvec[4*i ]; \ + ptr[8*i+1] = ptrvec[4*i+4]; \ + ptr[8*i+2] = ptrvec[4*i+1]; \ + ptr[8*i+3] = ptrvec[4*i+5]; \ + ptr[8*i+4] = ptrvec[4*i+2]; \ + ptr[8*i+5] = ptrvec[4*i+6]; \ + ptr[8*i+6] = ptrvec[4*i+3]; \ + ptr[8*i+7] = ptrvec[4*i+7]; \ + } \ + return v_load(ptr); \ +} + +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint8x16, uchar) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int8x16, schar) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint16x8, ushort) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int16x8, short) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint32x4, unsigned) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int32x4, int) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(float32x4, float) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(uint64x2, uint64) +OPENCV_HAL_IMPL_RVV_INTERLEAVED(int64x2, int64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_INTERLEAVED(float64x2, double) +#endif + +//////////// PopCount //////////// + +static const unsigned char popCountTable[] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; + +#define OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(_rTpvec, _Tpvec, _rTp, _Tp, suffix) \ +inline _rTpvec v_popcount(const _Tpvec& a) \ +{ \ + uchar ptra[16] = {0}; \ + v_store(ptra, v_reinterpret_as_u8(a)); \ + _rTp ptr[_Tpvec::nlanes] = {0}; \ + v_store(ptr, v_setzero_##suffix()); \ + for (int i = 0; i < _Tpvec::nlanes*(int)sizeof(_Tp); i++) \ + ptr[i/sizeof(_Tp)] += popCountTable[ptra[i]]; \ + return v_load(ptr); \ +} + +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint8x16, v_uint8x16, uchar, uchar, u8) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint8x16, v_int8x16, uchar, schar, u8) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint16x8, v_uint16x8, ushort, ushort, u16) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint16x8, v_int16x8, ushort, short, u16) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint32x4, v_uint32x4, unsigned, unsigned, u32) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint32x4, v_int32x4, unsigned, int, u32) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint64x2, v_uint64x2, uint64, uint64, u64) +OPENCV_HAL_IMPL_RVV_POPCOUNT_OP(v_uint64x2, v_int64x2, uint64, int64, u64) + +//////////// SignMask //////////// + +#define OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(_Tpvec, _Tp, suffix, vl, shift) \ +inline int v_signmask(const _Tpvec& a) \ +{ \ + int mask = 0; \ + _Tpvec tmp = _Tpvec(vsrl_vx_##suffix##m1(a, shift, vl)); \ + for( int i = 0; i < _Tpvec::nlanes; i++ ) \ + mask |= (int)(tmp.val[i]) << i; \ + return mask; \ +} + +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint8x16, uchar, u8, 16, 7) +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint16x8, ushort, u16, 8, 15) +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint32x4, unsigned, u32, 4, 31) +OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_uint64x2, uint64, u64, 2, 63) + +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } +inline int v_signmask(const v_int16x8& a) +{ return v_signmask(v_reinterpret_as_u16(a)); } +inline int v_signmask(const v_int32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_u32(a)); } +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#if CV_SIMD128_64F +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +#endif + + +//////////// Scan forward //////////// + +#define OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(_Tpvec, _Tp, suffix) \ +inline int v_scan_forward(const _Tpvec& a) \ +{ \ + _Tp ptr[_Tpvec::nlanes] = {0}; \ + v_store(ptr, v_reinterpret_as_##suffix(a)); \ + for (int i = 0; i < _Tpvec::nlanes; i++) \ + if(int(ptr[i]) < 0) \ + return i; \ + return 0; \ +} + +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int16x8, short, s16) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int32x4, int, s32) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float32x4, float, f32) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_int64x2, int64, s64) +#if CV_SIMD128_64F +OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float64x2, double, f64) +#endif + +//////////// Pack triplets //////////// + +// use reinterpret instead of c-style casting. +#ifndef __clang__ +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)vint8m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); +} + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vint16m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) +{ + return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); +} + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#else + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int8x16(vreinterpret_i8m1(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16))); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); +} + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int16x8(v_reinterpret_as_s16(v_uint8x16(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16)))); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) +{ + return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); +} + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#endif + +////// FP16 support /////// + +#if CV_FP16 +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + return v_float32x4(vfwcvt_f_f_v_f32m1(vle16_v_f16mf2(ptr, 4), 4)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + vse16_v_f16mf2(ptr, vfncvt_f_f_w_f16mf2(v, 4), 4); +} +#else +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + const int N = 4; + float buf[N]; + for( int i = 0; i < N; i++ ) buf[i] = (float)ptr[i]; + return v_load(buf); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + const int N = 4; + float buf[N]; + v_store(buf, v); + for( int i = 0; i < N; i++ ) ptr[i] = float16_t(buf[i]); +} +#endif + +////////////// Rounding ////////////// + +inline v_int32x4 v_round(const v_float32x4& a) +{ + return v_int32x4(vfcvt_x_f_v_i32m1(a, 4)); +} + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + v_float32x4 ZP5 = v_setall_f32(0.5f); + v_float32x4 t = a - ZP5; + return v_int32x4(vfcvt_x_f_v_i32m1(t, 4)); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + v_float32x4 ZP5 = v_setall_f32(0.5f); + v_float32x4 t = a + ZP5; + return v_int32x4(vfcvt_x_f_v_i32m1(t, 4)); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ + return v_int32x4(vfcvt_rtz_x_f_v_i32m1(a, 4)); +} +#if CV_SIMD128_64F +inline v_int32x4 v_round(const v_float64x2& a) +{ + double arr[4] = {a.val[0], a.val[1], 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + double arr[4] = {a.val[0], a.val[1], b.val[0], b.val[1]}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + double arr[4] = {a.val[0]-0.5f, a.val[1]-0.5f, 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + double arr[4] = {a.val[0]+0.5f, a.val[1]+0.5f, 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_x_f_w_i32m1(tmp, 4)); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + double arr[4] = {a.val[0], a.val[1], 0, 0}; + vfloat64m2_t tmp = vle64_v_f64m2(arr, 4); + return v_int32x4(vfncvt_rtz_x_f_w_i32m1(tmp, 4)); +} +#endif + + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + int ptr[8] = {0}; + v_int32x4 t1, t2; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2; +} +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + int ptr[8] = {0}; + v_int32x4 t1, t2; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2 + c; +} + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + int64 ptr[4] = {0}; + v_int64x2 t1, t2; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2; +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + int64 ptr[4] = {0}; + v_int64x2 t1, t2; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_load_deinterleave(ptr, t1, t2); + return t1 + t2 + c; +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + unsigned ptr[16] = {0}; + v_uint32x4 t1, t2, t3, t4; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, + const v_uint32x4& c) +{ + unsigned ptr[16] = {0}; + v_uint32x4 t1, t2, t3, t4; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + int ptr[16] = {0}; + v_int32x4 t1, t2, t3, t4; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ + int ptr[16] = {0}; + v_int32x4 t1, t2, t3, t4; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + uint64 ptr[8] = {0}; + v_uint64x2 t1, t2, t3, t4; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ + uint64 ptr[8] = {0}; + v_uint64x2 t1, t2, t3, t4; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + int64 ptr[8] = {0}; + v_int64x2 t1, t2, t3, t4; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4; +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, + const v_int64x2& c) +{ + int64 ptr[8] = {0}; + v_int64x2 t1, t2, t3, t4; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_load_deinterleave(ptr, t1, t2, t3, t4); + return t1 + t2 + t3 + t4 + c; +} + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, + const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } +#endif + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ + int ptr[8] = {0}; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + return t1 + t2; +} +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + int ptr[8] = {0}; + vse32_v_i32m2(ptr, vwmul_vv_i32m2(a, b, 8), 8); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + return t1 + t2 + c; +} + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ + int64 ptr[4] = {0}; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + return t1 + t2; +} +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + int64 ptr[4] = {0}; + vse64_v_i64m2(ptr, vwmul_vv_i64m2(a, b, 4), 4); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + return t1 + t2 + c; +} + + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ + unsigned ptr[16] = {0}; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_uint32x4 t1 = v_load(ptr); + v_uint32x4 t2 = v_load(ptr+4); + v_uint32x4 t3 = v_load(ptr+8); + v_uint32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4; +} +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ + unsigned ptr[16] = {0}; + vse32_v_u32m4(ptr, vwcvtu_x_x_v_u32m4(vwmulu_vv_u16m2(a, b, 16), 16), 16); + v_uint32x4 t1 = v_load(ptr); + v_uint32x4 t2 = v_load(ptr+4); + v_uint32x4 t3 = v_load(ptr+8); + v_uint32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4 + c; +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ + int ptr[16] = {0}; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + v_int32x4 t3 = v_load(ptr+8); + v_int32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4; +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ + int ptr[16] = {0}; + vse32_v_i32m4(ptr, vwcvt_x_x_v_i32m4(vwmul_vv_i16m2(a, b, 16), 16), 16); + v_int32x4 t1 = v_load(ptr); + v_int32x4 t2 = v_load(ptr+4); + v_int32x4 t3 = v_load(ptr+8); + v_int32x4 t4 = v_load(ptr+12); + return t1 + t2 + t3 + t4 + c; +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + uint64 ptr[8] = {0}; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_uint64x2 t1 = v_load(ptr); + v_uint64x2 t2 = v_load(ptr+2); + v_uint64x2 t3 = v_load(ptr+4); + v_uint64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4; +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ + uint64 ptr[8] = {0}; + vse64_v_u64m4(ptr, vwcvtu_x_x_v_u64m4(vwmulu_vv_u32m2(a, b, 8), 8), 8); + v_uint64x2 t1 = v_load(ptr); + v_uint64x2 t2 = v_load(ptr+2); + v_uint64x2 t3 = v_load(ptr+4); + v_uint64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4 + c; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + int64 ptr[8] = {0}; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + v_int64x2 t3 = v_load(ptr+4); + v_int64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ + int64 ptr[8] = {0}; + vse64_v_i64m4(ptr, vwcvt_x_x_v_i64m4(vwmul_vv_i32m2(a, b, 8), 8), 8); + v_int64x2 t1 = v_load(ptr); + v_int64x2 t2 = v_load(ptr+2); + v_int64x2 t3 = v_load(ptr+4); + v_int64x2 t4 = v_load(ptr+6); + return t1 + t2 + t3 + t4 + c; +} + +// 32 >> 64f +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod_fast(a, b)); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } +#endif + + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0, v_extract_n<0>(v), 4); + res = vfmacc_vf_f32m1(res, v_extract_n<1>(v), m1, 4); + res = vfmacc_vf_f32m1(res, v_extract_n<2>(v), m2, 4); + res = vfmacc_vf_f32m1(res, v_extract_n<3>(v), m3, 4); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0, v_extract_n<0>(v), 4); + res = vfmacc_vf_f32m1(res, v_extract_n<1>(v), m1, 4); + res = vfmacc_vf_f32m1(res, v_extract_n<2>(v), m2, 4); + return v_float32x4(res) + a; +} + +#define OPENCV_HAL_IMPL_RVV_MUL_EXPAND(_Tpvec, _Tpwvec, _Tpw, suffix, wmul, width, vl, hvl) \ +inline void v_mul_expand(const _Tpvec& a, const _Tpvec& b, _Tpwvec& c, _Tpwvec& d) \ +{ \ + _Tpw ptr[_Tpwvec::nlanes*2] = {0}; \ + vse##width##_v_##suffix##m2(ptr, wmul(a, b, vl), vl); \ + c = _Tpwvec(vle##width##_v_##suffix##m1(ptr, hvl)); \ + d = _Tpwvec(vle##width##_v_##suffix##m1(ptr+_Tpwvec::nlanes, hvl)); \ +} + +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_uint8x16, v_uint16x8, ushort, u16, vwmulu_vv_u16m2, 16, 16, 8) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_int8x16, v_int16x8, short, i16, vwmul_vv_i16m2, 16, 16, 8) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_uint16x8, v_uint32x4, unsigned, u32, vwmulu_vv_u32m2, 32, 8, 4) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_int16x8, v_int32x4, int, i32, vwmul_vv_i32m2, 32, 8, 4) +OPENCV_HAL_IMPL_RVV_MUL_EXPAND(v_uint32x4, v_uint64x2, uint64, u64, vwmulu_vv_u64m2, 64, 4, 2) + + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + return v_int16x8(vnsra_wx_i16m1(vwmul_vv_i32m2(a, b, 8), 16, 8)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint16x8(vnsrl_wx_u16m1(vwmulu_vv_u32m2(a, b, 8), 16, 8)); +} + + +//////// Saturating Multiply //////// + +#define OPENCV_HAL_IMPL_RVV_MUL_SAT(_Tpvec, _wTpvec) \ +inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ +{ \ + _wTpvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ +} \ +inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a = a * b; \ + return a; \ +} + +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_uint16x8, v_uint32x4) +OPENCV_HAL_IMPL_RVV_MUL_SAT(v_int16x8, v_int32x4) + + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + + +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv071.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv071.hpp new file mode 100644 index 0000000..2bdc622 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_rvv071.hpp @@ -0,0 +1,2545 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +// Copyright (C) 2015, PingTouGe Semiconductor Co., Ltd., all rights reserved. + +#ifndef OPENCV_HAL_INTRIN_RISCVV_HPP +#define OPENCV_HAL_INTRIN_RISCVV_HPP + +#include +#include +#include "opencv2/core/utility.hpp" + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +//////////// Types //////////// +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(vuint8m1_t v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = (vuint8m1_t)vle_v_u8m1((unsigned char*)v, 16); + } + uchar get0() const + { + return vmv_x_s_u8m1_u8(val, 16); + } + + vuint8m1_t val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(vint8m1_t v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = (vint8m1_t)vle_v_i8m1((schar*)v, 16); + } + schar get0() const + { + return vmv_x_s_i8m1_i8(val, 16); + } + + vint8m1_t val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(vuint16m1_t v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = (vuint16m1_t)vle_v_u16m1((unsigned short*)v, 8); + } + ushort get0() const + { + return vmv_x_s_u16m1_u16(val, 8); + } + + vuint16m1_t val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(vint16m1_t v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = (vint16m1_t)vle_v_i16m1((signed short*)v, 8); + } + short get0() const + { + return vmv_x_s_i16m1_i16(val, 8); + } + + vint16m1_t val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(vuint32m1_t v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + val = (vuint32m1_t)vle_v_u32m1((unsigned int*)v, 4); + } + unsigned get0() const + { + return vmv_x_s_u32m1_u32(val, 4); + } + + vuint32m1_t val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(vint32m1_t v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = (vint32m1_t)vle_v_i32m1((signed int*)v, 4); + } + int get0() const + { + return vmv_x_s_i32m1_i32(val, 4); + } + vint32m1_t val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(vfloat32m1_t v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = (vfloat32m1_t)vle_v_f32m1((float*)v, 4); + } + float get0() const + { + return vfmv_f_s_f32m1_f32(val, 4); + } + vfloat32m1_t val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(vuint64m1_t v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = (vuint64m1_t)vle_v_u64m1((unsigned long*)v, 2); + } + uint64 get0() const + { + return vmv_x_s_u64m1_u64(val, 2); + } + vuint64m1_t val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(vint64m1_t v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = (vint64m1_t)vle_v_i64m1((long*)v, 2); + } + int64 get0() const + { + return vmv_x_s_i64m1_i64(val, 2); + } + vint64m1_t val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(vfloat64m1_t v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = (vfloat64m1_t)vle_v_f64m1((double*)v, 2); + } + double get0() const + { + return vfmv_f_s_f64m1_f64(val, 2); + } + vfloat64m1_t val; +}; + +#define OPENCV_HAL_IMPL_RISCVV_INIT(_Tpv, _Tp, suffix) \ +inline _Tp##m1_t vreinterpretq_##suffix##_##suffix(_Tp##m1_t v) { return v; } \ +inline v_uint8x16 v_reinterpret_as_u8(const v_##_Tpv& v) { return v_uint8x16((vuint8m1_t)(v.val)); } \ +inline v_int8x16 v_reinterpret_as_s8(const v_##_Tpv& v) { return v_int8x16((vint8m1_t)(v.val)); } \ +inline v_uint16x8 v_reinterpret_as_u16(const v_##_Tpv& v) { return v_uint16x8((vuint16m1_t)(v.val)); } \ +inline v_int16x8 v_reinterpret_as_s16(const v_##_Tpv& v) { return v_int16x8((vint16m1_t)(v.val)); } \ +inline v_uint32x4 v_reinterpret_as_u32(const v_##_Tpv& v) { return v_uint32x4((vuint32m1_t)(v.val)); } \ +inline v_int32x4 v_reinterpret_as_s32(const v_##_Tpv& v) { return v_int32x4((vint32m1_t)(v.val)); } \ +inline v_uint64x2 v_reinterpret_as_u64(const v_##_Tpv& v) { return v_uint64x2((vuint64m1_t)(v.val)); } \ +inline v_int64x2 v_reinterpret_as_s64(const v_##_Tpv& v) { return v_int64x2((vint64m1_t)(v.val)); } \ +inline v_float32x4 v_reinterpret_as_f32(const v_##_Tpv& v) { return v_float32x4((vfloat32m1_t)(v.val)); }\ +inline v_float64x2 v_reinterpret_as_f64(const v_##_Tpv& v) { return v_float64x2((vfloat64m1_t)(v.val)); } + + +OPENCV_HAL_IMPL_RISCVV_INIT(uint8x16, vuint8, u8) +OPENCV_HAL_IMPL_RISCVV_INIT(int8x16, vint8, s8) +OPENCV_HAL_IMPL_RISCVV_INIT(uint16x8, vuint16, u16) +OPENCV_HAL_IMPL_RISCVV_INIT(int16x8, vint16, s16) +OPENCV_HAL_IMPL_RISCVV_INIT(uint32x4, vuint32, u32) +OPENCV_HAL_IMPL_RISCVV_INIT(int32x4, vint32, s32) +OPENCV_HAL_IMPL_RISCVV_INIT(uint64x2, vuint64, u64) +OPENCV_HAL_IMPL_RISCVV_INIT(int64x2, vint64, s64) +OPENCV_HAL_IMPL_RISCVV_INIT(float64x2, vfloat64, f64) +OPENCV_HAL_IMPL_RISCVV_INIT(float32x4, vfloat32, f32) +#define OPENCV_HAL_IMPL_RISCVV_INIT_SET(__Tp, _Tp, suffix, len, num) \ +inline v_##_Tp##x##num v_setzero_##suffix() { return v_##_Tp##x##num((v##_Tp##m1_t){0}); } \ +inline v_##_Tp##x##num v_setall_##suffix(__Tp v) { return v_##_Tp##x##num(vmv_v_x_##len##m1(v, num)); } + +OPENCV_HAL_IMPL_RISCVV_INIT_SET(uchar, uint8, u8, u8, 16) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(char, int8, s8, i8, 16) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(ushort, uint16, u16, u16, 8) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(short, int16, s16, i16, 8) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(unsigned int, uint32, u32, u32, 4) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(int, int32, s32, i32, 4) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(unsigned long, uint64, u64, u64, 2) +OPENCV_HAL_IMPL_RISCVV_INIT_SET(long, int64, s64, i64, 2) +inline v_float32x4 v_setzero_f32() { return v_float32x4((vfloat32m1_t){0}); } +inline v_float32x4 v_setall_f32(float v) { return v_float32x4(vfmv_v_f_f32m1(v, 4)); } + +inline v_float64x2 v_setzero_f64() { return v_float64x2(vfmv_v_f_f64m1(0, 2)); } +inline v_float64x2 v_setall_f64(double v) { return v_float64x2(vfmv_v_f_f64m1(v, 2)); } + + +#define OPENCV_HAL_IMPL_RISCVV_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +#define OPENCV_HAL_IMPL_RISCVV_BIN_OPN(bin_op, _Tpvec, intrin, num) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val, num)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val, num); \ + return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint8x16, vsaddu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint8x16, vssubu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int8x16, vsadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int8x16, vssub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint16x8, vsaddu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint16x8, vssubu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int16x8, vsadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int16x8, vssub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int32x4, vsadd_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int32x4, vssub_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_int32x4, vmul_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint32x4, vadd_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint32x4, vsub_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_uint32x4, vmul_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_int64x2, vsadd_vv_i64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_int64x2, vssub_vv_i64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_uint64x2, vadd_vv_u64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_uint64x2, vsub_vv_u64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_float32x4, vfadd_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_float32x4, vfsub_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_float32x4, vfmul_vv_f32m1, 4) +inline v_float32x4 operator / (const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vfdiv_vv_f32m1(a.val, b.val, 4)); +} +inline v_float32x4& operator /= (v_float32x4& a, const v_float32x4& b) +{ + a.val = vfdiv_vv_f32m1(a.val, b.val, 4); + return a; +} + +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(+, v_float64x2, vfadd_vv_f64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(-, v_float64x2, vfsub_vv_f64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BIN_OPN(*, v_float64x2, vfmul_vv_f64m1, 2) +inline v_float64x2 operator / (const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vfdiv_vv_f64m1(a.val, b.val, 2)); +} +inline v_float64x2& operator /= (v_float64x2& a, const v_float64x2& b) +{ + a.val = vfdiv_vv_f64m1(a.val, b.val, 2); + return a; +} +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_RISCVV_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +#define OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(_Tpvec, func, intrin, num) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val, num)); \ +} +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_min, vminu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_max, vmaxu_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_min, vmin_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_max, vmax_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_min, vminu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_max, vmaxu_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_min, vmin_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_max, vmax_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint32x4, v_min, vminu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint32x4, v_max, vmaxu_vv_u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int32x4, v_min, vmin_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int32x4, v_max, vmax_vv_i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float32x4, v_min, vfmin_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float32x4, v_max, vfmax_vv_f32m1, 4) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float64x2, v_min, vfmin_vv_f64m1, 2) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_float64x2, v_max, vfmax_vv_f64m1, 2) + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(vfsqrt_v_f32m1(x.val, 4)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + return v_float32x4(vfrdiv_vf_f32m1(vfsqrt_v_f32m1(x.val, 4), 1, 4)); +} + +inline v_float32x4 v_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + v_float32x4 x(vfmacc_vv_f32m1(vfmul_vv_f32m1(a.val, a.val, 4), b.val, b.val, 4)); + return v_sqrt(x); +} + +inline v_float32x4 v_sqr_magnitude(const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4(vfmacc_vv_f32m1(vfmul_vv_f32m1(a.val, a.val, 4), b.val, b.val, 4)); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_float32x4(vfmacc_vv_f32m1(c.val, a.val, b.val, 4)); +} + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_int32x4(vmacc_vv_i32m1(c.val, a.val, b.val, 4)); +} + +inline v_float32x4 v_muladd(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0.val, v.val[0], 4);//vmuli_f32(m0.val, v.val, 0); + res = vfmacc_vf_f32m1(res, v.val[1], m1.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfmacc_vf_f32m1(res, v.val[2], m2.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfmacc_vf_f32m1(res, v.val[3], m3.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + return v_float32x4(res); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + vfloat32m1_t res = vfmul_vf_f32m1(m0.val, v.val[0], 4);//vmuli_f32(m0.val, v.val, 0); + res = vfmacc_vf_f32m1(res, v.val[1], m1.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfmacc_vf_f32m1(res, v.val[2], m2.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + res = vfadd_vv_f32m1(res, a.val, 4);//vmulai_f32(res, m1.val, v.val, 1); + return v_float32x4(res); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(vfsqrt_v_f64m1(x.val, 2)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + return v_float64x2(vfrdiv_vf_f64m1(vfsqrt_v_f64m1(x.val, 2), 1, 2)); +} + +inline v_float64x2 v_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + v_float64x2 x(vfmacc_vv_f64m1(vfmul_vv_f64m1(a.val, a.val, 2), b.val, b.val, 2)); + return v_sqrt(x); +} + +inline v_float64x2 v_sqr_magnitude(const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2(vfmacc_vv_f64m1(vfmul_vv_f64m1(a.val, a.val, 2), b.val, b.val, 2)); +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_float64x2(vfmacc_vv_f64m1(c.val, a.val, b.val, 2)); +} + +inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return v_fma(a, b, c); +} + +#define OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(_Tpvec, suffix, num) \ + OPENCV_HAL_IMPL_RISCVV_BIN_OPN(&, _Tpvec, vand_vv_##suffix, num) \ + OPENCV_HAL_IMPL_RISCVV_BIN_OPN(|, _Tpvec, vor_vv_##suffix, num) \ + OPENCV_HAL_IMPL_RISCVV_BIN_OPN(^, _Tpvec, vxor_vv_##suffix, num) \ + inline _Tpvec operator ~ (const _Tpvec & a) \ + { \ + return _Tpvec(vnot_v_##suffix(a.val, num)); \ + } + +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint8x16, u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint16x8, u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint32x4, u32m1, 4) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_uint64x2, u64m1, 2) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int8x16, i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int16x8, i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int32x4, i32m1, 4) +OPENCV_HAL_IMPL_RISCVV_LOGIC_OPN(v_int64x2, i64m1, 2) + +#define OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(bin_op, intrin) \ +inline v_float32x4 operator bin_op (const v_float32x4& a, const v_float32x4& b) \ +{ \ + return v_float32x4(vfloat32m1_t(intrin(vint32m1_t(a.val), vint32m1_t(b.val), 4))); \ +} \ +inline v_float32x4& operator bin_op##= (v_float32x4& a, const v_float32x4& b) \ +{ \ + a.val = vfloat32m1_t(intrin(vint32m1_t(a.val), vint32m1_t(b.val), 4)); \ + return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(&, vand_vv_i32m1) +OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(|, vor_vv_i32m1) +OPENCV_HAL_IMPL_RISCVV_FLT_BIT_OP(^, vxor_vv_i32m1) + +inline v_float32x4 operator ~ (const v_float32x4& a) +{ + return v_float32x4((vfloat32m1_t)(vnot_v_i32m1((vint32m1_t)(a.val), 4))); +} + +#define OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(bin_op, intrin) \ +inline v_float64x2 operator bin_op (const v_float64x2& a, const v_float64x2& b) \ +{ \ + return v_float64x2(vfloat64m1_t(intrin(vint64m1_t(a.val), vint64m1_t(b.val), 2))); \ +} \ +inline v_float64x2& operator bin_op##= (v_float64x2& a, const v_float64x2& b) \ +{ \ + a.val = vfloat64m1_t(intrin(vint64m1_t(a.val), vint64m1_t(b.val), 2)); \ + return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(&, vand_vv_i64m1) +OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(|, vor_vv_i64m1) +OPENCV_HAL_IMPL_RISCVV_FLT_64BIT_OP(^, vxor_vv_i64m1) + +inline v_float64x2 operator ~ (const v_float64x2& a) +{ + return v_float64x2((vfloat64m1_t)(vnot_v_i64m1((vint64m1_t)(a.val), 2))); +} +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + return v_int16x8(vmulh_vv_i16m1(a.val, b.val, 8)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + return v_uint16x8(vmulhu_vv_u16m1(a.val, b.val, 8)); +} + +//#define OPENCV_HAL_IMPL_RISCVV_ABS(_Tpuvec, _Tpsvec, usuffix, ssuffix) \ +//inline _Tpuvec v_abs(const _Tpsvec& a) { \ +// E##xm1_t mask=vmflt_vf_e32xm1_f32m1(x.val, 0.0, 4); + +//OPENCV_HAL_IMPL_RISCVV_ABS(v_uint8x16, v_int8x16, u8, s8) +//OPENCV_HAL_IMPL_RISCVV_ABS(v_uint16x8, v_int16x8, u16, s16) +//OPENCV_HAL_IMPL_RISCVV_ABS(v_uint32x4, v_int32x4, u32, s32) + +inline v_uint32x4 v_abs(v_int32x4 x) +{ + vbool32_t mask=vmslt_vx_i32m1_b32(x.val, 0, 4); + return v_uint32x4((vuint32m1_t)vrsub_vx_i32m1_m(mask, x.val, x.val, 0, 4)); +} + +inline v_uint16x8 v_abs(v_int16x8 x) +{ + vbool16_t mask=vmslt_vx_i16m1_b16(x.val, 0, 8); + return v_uint16x8((vuint16m1_t)vrsub_vx_i16m1_m(mask, x.val, x.val, 0, 8)); +} + +inline v_uint8x16 v_abs(v_int8x16 x) +{ + vbool8_t mask=vmslt_vx_i8m1_b8(x.val, 0, 16); + return v_uint8x16((vuint8m1_t)vrsub_vx_i8m1_m(mask, x.val, x.val, 0, 16)); +} + +inline v_float32x4 v_abs(v_float32x4 x) +{ + return (v_float32x4)vfsgnjx_vv_f32m1(x.val, x.val, 4); +} + +inline v_float64x2 v_abs(v_float64x2 x) +{ + return (v_float64x2)vfsgnjx_vv_f64m1(x.val, x.val, 2); +} + +inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b) +{ + vfloat32m1_t ret = vfsub_vv_f32m1(a.val, b.val, 4); + return (v_float32x4)vfsgnjx_vv_f32m1(ret, ret, 4); +} + +inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b) +{ + vfloat64m1_t ret = vfsub_vv_f64m1(a.val, b.val, 2); + return (v_float64x2)vfsgnjx_vv_f64m1(ret, ret, 2); +} + +#define OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(bit, num) \ +inline v_uint##bit##x##num v_absdiff(v_uint##bit##x##num a, v_uint##bit##x##num b){ \ + vuint##bit##m1_t vmax = vmaxu_vv_u##bit##m1(a.val, b.val, num); \ + vuint##bit##m1_t vmin = vminu_vv_u##bit##m1(a.val, b.val, num); \ + return v_uint##bit##x##num(vsub_vv_u##bit##m1(vmax, vmin, num));\ +} + +OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(8, 16) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(16, 8) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF_U(32, 4) + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(v_int8x16 a, v_int8x16 b){ + vint8m1_t vmax = vmax_vv_i8m1(a.val, b.val, 16); + vint8m1_t vmin = vmin_vv_i8m1(a.val, b.val, 16); + return v_int8x16(vssub_vv_i8m1(vmax, vmin, 16)); +} +inline v_int16x8 v_absdiffs(v_int16x8 a, v_int16x8 b){ + vint16m1_t vmax = vmax_vv_i16m1(a.val, b.val, 8); + vint16m1_t vmin = vmin_vv_i16m1(a.val, b.val, 8); + return v_int16x8(vssub_vv_i16m1(vmax, vmin, 8)); +} + +#define OPENCV_HAL_IMPL_RISCVV_ABSDIFF(_Tpvec, _Tpv, num) \ +inline v_uint##_Tpvec v_absdiff(v_int##_Tpvec a, v_int##_Tpvec b){ \ + vint##_Tpv##_t max = vmax_vv_i##_Tpv(a.val, b.val, num);\ + vint##_Tpv##_t min = vmin_vv_i##_Tpv(a.val, b.val, num);\ + return v_uint##_Tpvec((vuint##_Tpv##_t)vsub_vv_i##_Tpv(max, min, num)); \ +} + +OPENCV_HAL_IMPL_RISCVV_ABSDIFF(8x16, 8m1, 16) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF(16x8, 16m1, 8) +OPENCV_HAL_IMPL_RISCVV_ABSDIFF(32x4, 32m1, 4) + +// Multiply and expand +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + vint16m2_t res = vundefined_i16m2(); + res = vwmul_vv_i16m2(a.val, b.val, 16); + c.val = vget_i16m2_i16m1(res, 0); + d.val = vget_i16m2_i16m1(res, 1); +} + +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + vuint16m2_t res = vundefined_u16m2(); + res = vwmulu_vv_u16m2(a.val, b.val, 16); + c.val = vget_u16m2_u16m1(res, 0); + d.val = vget_u16m2_u16m1(res, 1); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + vint32m2_t res = vundefined_i32m2(); + res = vwmul_vv_i32m2(a.val, b.val, 8); + c.val = vget_i32m2_i32m1(res, 0); + d.val = vget_i32m2_i32m1(res, 1); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + vuint32m2_t res = vundefined_u32m2(); + res = vwmulu_vv_u32m2(a.val, b.val, 8); + c.val = vget_u32m2_u32m1(res, 0); + d.val = vget_u32m2_u32m1(res, 1); +} + +inline void v_mul_expand(const v_int32x4& a, const v_int32x4& b, + v_int64x2& c, v_int64x2& d) +{ + vint64m2_t res = vundefined_i64m2(); + res = vwmul_vv_i64m2(a.val, b.val, 4); + c.val = vget_i64m2_i64m1(res, 0); + d.val = vget_i64m2_i64m1(res, 1); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + vuint64m2_t res = vundefined_u64m2(); + res = vwmulu_vv_u64m2(a.val, b.val, 4); + c.val = vget_u64m2_u64m1(res, 0); + d.val = vget_u64m2_u64m1(res, 1); +} + +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_add_wrap, vadd_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_add_wrap, vadd_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_add_wrap, vadd_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_add_wrap, vadd_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_sub_wrap, vsub_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_sub_wrap, vsub_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_sub_wrap, vsub_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_sub_wrap, vsub_vv_i16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint8x16, v_mul_wrap, vmul_vv_u8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int8x16, v_mul_wrap, vmul_vv_i8m1, 16) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_uint16x8, v_mul_wrap, vmul_vv_u16m1, 8) +OPENCV_HAL_IMPL_RISCVV_BINN_FUNC(v_int16x8, v_mul_wrap, vmul_vv_i16m1, 8) +//////// Dot Product //////// +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t res = vundefined_i32m2(); + res = vwmul_vv_i32m2(a.val, b.val, 8); + res = vrgather_vv_i32m2(res, (vuint32m2_t){0, 2, 4, 6, 1, 3, 5, 7}, 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(res, 0), vget_i32m2_i32m1(res, 1), 4)); +} +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + vint32m2_t res = vundefined_i32m2(); + res = vwmul_vv_i32m2(a.val, b.val, 8); + res = vrgather_vv_i32m2(res, (vuint32m2_t){0, 2, 4, 6, 1, 3, 5, 7}, 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(res, 0),vget_i32m2_i32m1(res, 1), 4), c.val, 4)); +} + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + vint64m2_t res = vundefined_i64m2(); + res = vwmul_vv_i64m2(a.val, b.val, 4); + res = vrgather_vv_i64m2(res, (vuint64m2_t){0, 2, 1, 3}, 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(res, 0), vget_i64m2_i64m1(res, 1), 2)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + vint64m2_t res = vundefined_i64m2(); + res = vwmul_vv_i64m2(a.val, b.val, 4); + res = vrgather_vv_i64m2(res, (vuint64m2_t){0, 2, 1, 3}, 4); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(res, 0), vget_i64m2_i64m1(res, 1), 2), c.val, 2)); +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v1 = vrgather_vv_u16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4)); +} + +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, + const v_uint32x4& c) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v1 = vrgather_vv_u16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4), c.val, 4)); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v1 = vrgather_vv_i16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4)); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, + const v_int32x4& c) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v1 = vrgather_vv_i16m2(v1, (vuint16m2_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4), c.val, 4)); +} + +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v1 = vrgather_vv_u32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2)); +} + +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, + const v_uint64x2& c) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v1 = vrgather_vv_u32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2), c.val, 2)); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v1 = vrgather_vv_i32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2)); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, + const v_int64x2& c) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v1 = vrgather_vv_i32m2(v1, (vuint32m2_t){0, 4, 1, 5, 2, 6, 3, 7}, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2), c.val, 2)); +} + +//////// Fast Dot Product //////// +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t v1 = vundefined_i32m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4)); +} + +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ + vint32m2_t v1 = vundefined_i32m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4), c.val, 4)); +} + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ + vint64m2_t v1 = vundefined_i64m2(); + v1 = vwmul_vv_i64m2(a.val, b.val, 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(v1, 0), vget_i64m2_i64m1(v1, 1), 2)); +} +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + vint64m2_t v1 = vundefined_i64m2(); + v1 = vwmul_vv_i64m2(a.val, b.val, 8); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v1, 0), vget_i64m2_i64m1(v1, 1), 4), c.val, 4)); +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4)); +} + +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ + vuint16m2_t v1 = vundefined_u16m2(); + vuint32m2_t v2 = vundefined_u32m2(); + v1 = vwmulu_vv_u16m2(a.val, b.val, 16); + v2 = vwaddu_vv_u32m2(vget_u16m2_u16m1(v1, 0), vget_u16m2_u16m1(v1, 1), 8); + return v_uint32x4(vadd_vv_u32m1(vadd_vv_u32m1(vget_u32m2_u32m1(v2, 0), vget_u32m2_u32m1(v2, 1), 4), c.val, 4)); +} + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4)); +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ + vint16m2_t v1 = vundefined_i16m2(); + vint32m2_t v2 = vundefined_i32m2(); + v1 = vwmul_vv_i16m2(a.val, b.val, 16); + v2 = vwadd_vv_i32m2(vget_i16m2_i16m1(v1, 0), vget_i16m2_i16m1(v1, 1), 8); + return v_int32x4(vadd_vv_i32m1(vadd_vv_i32m1(vget_i32m2_i32m1(v2, 0), vget_i32m2_i32m1(v2, 1), 4), c.val, 4)); +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2)); +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ + vuint32m2_t v1 = vundefined_u32m2(); + vuint64m2_t v2 = vundefined_u64m2(); + v1 = vwmulu_vv_u32m2(a.val, b.val, 8); + v2 = vwaddu_vv_u64m2(vget_u32m2_u32m1(v1, 0), vget_u32m2_u32m1(v1, 1), 4); + return v_uint64x2(vadd_vv_u64m1(vadd_vv_u64m1(vget_u64m2_u64m1(v2, 0), vget_u64m2_u64m1(v2, 1), 2), c.val, 2)); +} + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2)); +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ + vint32m2_t v1 = vundefined_i32m2(); + vint64m2_t v2 = vundefined_i64m2(); + v1 = vwmul_vv_i32m2(a.val, b.val, 8); + v2 = vwadd_vv_i64m2(vget_i32m2_i32m1(v1, 0), vget_i32m2_i32m1(v1, 1), 4); + return v_int64x2(vadd_vv_i64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v2, 0), vget_i64m2_i64m1(v2, 1), 2), c.val, 2)); +} + + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(_Tpvec, _Tpvec2, len, scalartype, func, intrin, num) \ +inline scalartype v_reduce_##func(const v_##_Tpvec##x##num& a) \ +{\ + v##_Tpvec2##m1_t val = vmv_v_x_##len##m1(0, num); \ + val = intrin(val, a.val, val, num); \ + return vmv_x_s_##len##m1_##len(val, num); \ +} + + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(_Tpvec, _Tpvec2, scalartype, func, funcu, num) \ +inline scalartype v_reduce_##func(const v_##_Tpvec##x##num& a) \ +{\ + v##_Tpvec##m1_t val = (v##_Tpvec##m1_t)vmv_v_x_i8m1(0, num); \ + val = v##funcu##_vs_##_Tpvec2##m1_##_Tpvec2##m1(val, a.val, a.val, num); \ + return val[0]; \ +} +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int8, int16, i16, int, sum, vwredsum_vs_i8m1_i16m1, 16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int16, int32, i32, int, sum, vwredsum_vs_i16m1_i32m1, 8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(int32, int64, i64, int, sum, vwredsum_vs_i32m1_i64m1, 4) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint8, uint16, u16, unsigned, sum, vwredsumu_vs_u8m1_u16m1, 16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint16, uint32, u32, unsigned, sum, vwredsumu_vs_u16m1_u32m1, 8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_W(uint32, uint64, u64, unsigned, sum, vwredsumu_vs_u32m1_u64m1, 4) +inline float v_reduce_sum(const v_float32x4& a) \ +{\ + vfloat32m1_t val = vfmv_v_f_f32m1(0.0, 4); \ + val = vfredsum_vs_f32m1_f32m1(val, a.val, val, 4); \ + return vfmv_f_s_f32m1_f32(val, 4); \ +} +inline double v_reduce_sum(const v_float64x2& a) \ +{\ + vfloat64m1_t val = vfmv_v_f_f64m1(0.0, 2); \ + val = vfredsum_vs_f64m1_f64m1(val, a.val, val, 2); \ + return vfmv_f_s_f64m1_f64(val, 2); \ +} +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ return vext_x_v_u64m1_u64((vuint64m1_t)a.val, 0, 2)+vext_x_v_u64m1_u64((vuint64m1_t)a.val, 1, 2); } + +inline int64 v_reduce_sum(const v_int64x2& a) +{ return vext_x_v_i64m1_i64((vint64m1_t)a.val, 0, 2)+vext_x_v_i64m1_i64((vint64m1_t)a.val, 1, 2); } + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(func) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int8, i8, int, func, red##func, 16) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int16, i16, int, func, red##func, 8) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int32, i32, int, func, red##func, 4) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(int64, i64, int, func, red##func, 2) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint8, u8, unsigned, func, red##func##u, 16) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint16, u16, unsigned, func, red##func##u, 8) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(uint32, u32, unsigned, func, red##func##u, 4) \ +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP_(float32, f32, float, func, fred##func, 4) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(max) +OPENCV_HAL_IMPL_RISCVV_REDUCE_OP(min) + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + vfloat32m1_t a0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t b0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t c0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t d0 = vfmv_v_f_f32m1(0.0, 4); + a0 = vfredsum_vs_f32m1_f32m1(a0, a.val, a0, 4); + b0 = vfredsum_vs_f32m1_f32m1(b0, b.val, b0, 4); + c0 = vfredsum_vs_f32m1_f32m1(c0, c.val, c0, 4); + d0 = vfredsum_vs_f32m1_f32m1(d0, d.val, d0, 4); + return v_float32x4(a0[0], b0[0], c0[0], d0[0]); +} + +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + vfloat32m1_t a0 = vfmv_v_f_f32m1(0.0, 4); + vfloat32m1_t x = vfsub_vv_f32m1(a.val, b.val, 4); + vbool32_t mask=vmflt_vf_f32m1_b32(x, 0, 4); + vfloat32m1_t val = vfrsub_vf_f32m1_m(mask, x, x, 0, 4); + a0 = vfredsum_vs_f32m1_f32m1(a0, val, a0, 4); + return a0[0]; +} + +#define OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(_Tpvec, _Tpvec2) \ +inline unsigned v_reduce_sad(const _Tpvec& a, const _Tpvec&b){ \ + _Tpvec2 x = v_absdiff(a, b); \ + return v_reduce_sum(x); \ +} + +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int8x16, v_uint8x16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint8x16, v_uint8x16) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int16x8, v_uint16x8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint16x8, v_uint16x8) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_int32x4, v_uint32x4) +OPENCV_HAL_IMPL_RISCVV_REDUCE_SAD(v_uint32x4, v_uint32x4) + +#define OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(_Tpvec, _Tp, _T, num, uv) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmseq_vv_##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmsne_vv_##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmslt##uv##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmslt##uv##_Tp##_b##_T(b.val, a.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmsle##uv##_Tp##_b##_T(a.val, b.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ \ + vbool##_T##_t mask = vmsle##uv##_Tp##_b##_T(b.val, a.val, num); \ + return _Tpvec(vmerge_vxm_##_Tp(mask, vmv_v_x_##_Tp(0, num), -1, num)); \ +} \ + +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int8x16, i8m1, 8, 16, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int16x8, i16m1, 16, 8, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int32x4, i32m1, 32, 4, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_int64x2, i64m1, 64, 2, _vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint8x16, u8m1, 8, 16, u_vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint16x8, u16m1, 16, 8, u_vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint32x4, u32m1, 32, 4, u_vv_) +OPENCV_HAL_IMPL_RISCVV_INT_CMP_OP(v_uint64x2, u64m1, 64, 2, u_vv_) + +//TODO: == +inline v_float32x4 operator == (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfeq_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator != (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfne_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator < (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmflt_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator <= (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfle_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator > (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfgt_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 operator >= (const v_float32x4& a, const v_float32x4& b) +{ + vbool32_t mask = vmfge_vv_f32m1_b32(a.val, b.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ + vbool32_t mask = vmford_vv_f32m1_b32(a.val, a.val, 4); + vint32m1_t res = vmerge_vxm_i32m1(mask, vmv_v_x_i32m1(0.0, 4), -1, 4); + return v_float32x4((vfloat32m1_t)res); +} + +//TODO: == +inline v_float64x2 operator == (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfeq_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator != (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfne_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator < (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmflt_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator <= (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfle_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator > (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfgt_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 operator >= (const v_float64x2& a, const v_float64x2& b) +{ + vbool64_t mask = vmfge_vv_f64m1_b64(a.val, b.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ + vbool64_t mask = vmford_vv_f64m1_b64(a.val, a.val, 2); + vint64m1_t res = vmerge_vxm_i64m1(mask, vmv_v_x_i64m1(0.0, 2), -1, 2); + return v_float64x2((vfloat64m1_t)res); +} +#define OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(_Tp, _T) \ +inline void v_transpose4x4(const v_##_Tp##32x4& a0, const v_##_Tp##32x4& a1, \ + const v_##_Tp##32x4& a2, const v_##_Tp##32x4& a3, \ + v_##_Tp##32x4& b0, v_##_Tp##32x4& b1, \ + v_##_Tp##32x4& b2, v_##_Tp##32x4& b3) \ +{ \ + v##_Tp##32m4_t val = vundefined_##_T##m4(); \ + val = vset_##_T##m4(val, 0, a0.val); \ + val = vset_##_T##m4(val, 1, a1.val); \ + val = vset_##_T##m4(val, 2, a2.val); \ + val = vset_##_T##m4(val, 3, a3.val); \ + val = vrgather_vv_##_T##m4(val, (vuint32m4_t){0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}, 16); \ + b0.val = vget_##_T##m4_##_T##m1(val, 0); \ + b1.val = vget_##_T##m4_##_T##m1(val, 1); \ + b2.val = vget_##_T##m4_##_T##m1(val, 2); \ + b3.val = vget_##_T##m4_##_T##m1(val, 3); \ +} +OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(uint, u32) +OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(int, i32) +OPENCV_HAL_IMPL_RISCVV_TRANSPOSE4x4(float, f32) + + +#define OPENCV_HAL_IMPL_RISCVV_SHIFT_LEFT(_Tpvec, suffix, _T, num) \ +inline _Tpvec operator << (const _Tpvec& a, int n) \ +{ return _Tpvec((vsll_vx_##_T##m1(a.val, n, num))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec((vsll_vx_##_T##m1(a.val, n, num))); } + +#define OPENCV_HAL_IMPL_RISCVV_SHIFT_RIGHT(_Tpvec, suffix, _T, num, intric) \ +inline _Tpvec operator >> (const _Tpvec& a, int n) \ +{ return _Tpvec((v##intric##_vx_##_T##m1(a.val, n, num))); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec((v##intric##_vx_##_T##m1(a.val, n, num))); }\ +template inline _Tpvec v_rshr(const _Tpvec& a) \ +{ return _Tpvec((v##intric##_vx_##_T##m1(vadd_vx_##_T##m1(a.val, 1<<(n-1), num), n, num))); } + +// trade efficiency for convenience +#define OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(suffix, _T, num, intrin) \ +OPENCV_HAL_IMPL_RISCVV_SHIFT_LEFT(v_##suffix##x##num, suffix, _T, num) \ +OPENCV_HAL_IMPL_RISCVV_SHIFT_RIGHT(v_##suffix##x##num, suffix, _T, num, intrin) + +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint8, u8, 16, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint16, u16, 8, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint32, u32, 4, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(uint64, u64, 2, srl) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int8, i8, 16, sra) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int16, i16, 8, sra) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int32, i32, 4, sra) +OPENCV_HAL_IMPL_RISCVV_SHIFT_OP(int64, i64, 2, sra) + +#if 0 +#define VUP4(n) {0, 1, 2, 3} +#define VUP8(n) {0, 1, 2, 3, 4, 5, 6, 7} +#define VUP16(n) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} +#define VUP2(n) {0, 1} +#endif +#define OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(_Tpvec, suffix, _T, num, num2, vmv, len) \ +template inline _Tpvec v_rotate_left(const _Tpvec& a) \ +{ \ + suffix##m1_t tmp = vmv##_##_T##m1(0, num);\ + tmp = vslideup_vx_##_T##m1_m(vmset_m_##len(num), tmp, a.val, n, num);\ + return _Tpvec(tmp);\ +} \ +template inline _Tpvec v_rotate_right(const _Tpvec& a) \ +{ \ + return _Tpvec(vslidedown_vx_##_T##m1(a.val, n, num));\ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \ +{ return a; } \ +template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \ +{ \ + suffix##m2_t tmp = vundefined_##_T##m2(); \ + tmp = vset_##_T##m2(tmp, 0, a.val); \ + tmp = vset_##_T##m2(tmp, 1, b.val); \ + tmp = vslidedown_vx_##_T##m2(tmp, n, num2);\ + return _Tpvec(vget_##_T##m2_##_T##m1(tmp, 0));\ +} \ +template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \ +{ \ + suffix##m2_t tmp = vundefined_##_T##m2(); \ + tmp = vset_##_T##m2(tmp, 0, b.val); \ + tmp = vset_##_T##m2(tmp, 1, a.val); \ + tmp = vslideup_vx_##_T##m2(tmp, n, num2);\ + return _Tpvec(vget_##_T##m2_##_T##m1(tmp, 1));\ +} \ +template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \ +{ \ + CV_UNUSED(b); return a; \ +} + +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint8x16, vuint8, u8, 16, 32, vmv_v_x, b8) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int8x16, vint8, i8, 16, 32, vmv_v_x, b8) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint16x8, vuint16, u16, 8, 16, vmv_v_x, b16) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int16x8, vint16, i16, 8, 16, vmv_v_x, b16) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint32x4, vuint32, u32, 4, 8, vmv_v_x, b32) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int32x4, vint32, i32, 4, 8, vmv_v_x, b32) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_uint64x2, vuint64, u64, 2, 4, vmv_v_x, b64) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_int64x2, vint64, i64, 2, 4, vmv_v_x, b64) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_float32x4, vfloat32, f32, 4, 8, vfmv_v_f, b32) +OPENCV_HAL_IMPL_RISCVV_ROTATE_OP(v_float64x2, vfloat64, f64, 2, 4, vfmv_v_f, b64) + +#define OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(_Tpvec, _Tp, _Tp2, len, hnum, num) \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + typedef uint64 CV_DECL_ALIGNED(1) unaligned_uint64; \ + vuint64m1_t tmp = {*(unaligned_uint64*)ptr0, *(unaligned_uint64*)ptr1};\ + return _Tpvec(_Tp2##_t(tmp)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(vle_v_##len(ptr, hnum)); }\ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(vle_v_##len(ptr, num)); } \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec((_Tp2##_t)vle_v_##len((const _Tp *)ptr, num)); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, hnum);}\ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + _Tp2##_t a0 = vslidedown_vx_##len(a.val, hnum, num); \ + vse_v_##len(ptr, a0, hnum);}\ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, num); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, num); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ vse_v_##len(ptr, a.val, num); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ vse_v_##len(ptr, a.val, num); } + +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint8x16, uchar, vuint8m1, u8m1, 8, 16) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int8x16, schar, vint8m1, i8m1, 8, 16) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint16x8, ushort, vuint16m1, u16m1, 4, 8) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int16x8, short, vint16m1, i16m1, 4, 8) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint32x4, unsigned, vuint32m1, u32m1, 2, 4) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int32x4, int, vint32m1, i32m1, 2, 4) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_uint64x2, unsigned long, vuint64m1, u64m1, 1, 2) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_int64x2, long, vint64m1, i64m1, 1, 2) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_float32x4, float, vfloat32m1, f32m1, 2, 4) +OPENCV_HAL_IMPL_RISCVV_LOADSTORE_OP(v_float64x2, double, vfloat64m1, f64m1, 1, 2) + + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ +#if 1 + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[ 0]], + tab[idx[ 1]], + tab[idx[ 2]], + tab[idx[ 3]], + tab[idx[ 4]], + tab[idx[ 5]], + tab[idx[ 6]], + tab[idx[ 7]], + tab[idx[ 8]], + tab[idx[ 9]], + tab[idx[10]], + tab[idx[11]], + tab[idx[12]], + tab[idx[13]], + tab[idx[14]], + tab[idx[15]] + }; + return v_int8x16(vle_v_i8m1(elems, 16)); +#else + int32xm4_t index32 = vlev_int32xm4(idx, 16); + vint16m2_t index16 = vnsra_vx_i16m2_int32xm4(index32, 0, 16); + vint8m1_t index = vnsra_vx_i8m1_i16m2(index16, 0, 16); + return v_int8x16(vlxbv_i8m1(tab, index, 16)); +#endif +} + +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx){ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[4]], + tab[idx[4] + 1], + tab[idx[5]], + tab[idx[5] + 1], + tab[idx[6]], + tab[idx[6] + 1], + tab[idx[7]], + tab[idx[7] + 1] + }; + return v_int8x16(vle_v_i8m1(elems, 16)); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + schar CV_DECL_ALIGNED(32) elems[16] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[2] + 2], + tab[idx[2] + 3], + tab[idx[3]], + tab[idx[3] + 1], + tab[idx[3] + 2], + tab[idx[3] + 3] + }; + return v_int8x16(vle_v_i8m1(elems, 16)); +} + +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]], + tab[idx[4]], + tab[idx[5]], + tab[idx[6]], + tab[idx[7]] + }; + return v_int16x8(vle_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[2]], + tab[idx[2] + 1], + tab[idx[3]], + tab[idx[3] + 1] + }; + return v_int16x8(vle_v_i16m1(elems, 8)); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + short CV_DECL_ALIGNED(32) elems[8] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[0] + 2], + tab[idx[0] + 3], + tab[idx[1]], + tab[idx[1] + 1], + tab[idx[1] + 2], + tab[idx[1] + 3] + }; + return v_int16x8(vle_v_i16m1(elems, 8)); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_int32x4(vle_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[0] + 1], + tab[idx[1]], + tab[idx[1] + 1] + }; + return v_int32x4(vle_v_i32m1(elems, 4)); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vle_v_i32m1(tab+idx[0], 4)); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + vint64m1_t res = {tab[idx[0]], tab[idx[1]]}; + return v_int64x2(res); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(vle_v_i64m1(tab+idx[0], 2)); +} + +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) +{ + vuint64m1_t res = {tab[idx[0]], tab[idx[1]]}; + return v_uint64x2(res); +} +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) +{ + return v_uint64x2(vle_v_u64m1(tab+idx[0], 2)); +} + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[1]], + tab[idx[2]], + tab[idx[3]] + }; + return v_float32x4(vle_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idx[0]], + tab[idx[0]+1], + tab[idx[1]], + tab[idx[1]+1] + }; + return v_float32x4(vle_v_f32m1(elems, 4)); +} +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) +{ + return v_float32x4(vle_v_f32m1(tab + idx[0], 4)); +} +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + vfloat64m1_t res = {tab[idx[0]], tab[idx[1]]}; + return v_float64x2(res); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(vle_v_f64m1(tab+idx[0], 2)); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) elems[4] = + { + tab[idxvec.val[0]], + tab[idxvec.val[1]], + tab[idxvec.val[2]], + tab[idxvec.val[3]] + }; + return v_int32x4(vle_v_i32m1(elems, 4)); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + unsigned CV_DECL_ALIGNED(32) elems[4] = + { + tab[idxvec.val[0]], + tab[idxvec.val[1]], + tab[idxvec.val[2]], + tab[idxvec.val[3]] + }; + return v_uint32x4(vle_v_u32m1(elems, 4)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + float CV_DECL_ALIGNED(32) elems[4] = + { + tab[idxvec.val[0]], + tab[idxvec.val[1]], + tab[idxvec.val[2]], + tab[idxvec.val[3]] + }; + return v_float32x4(vle_v_f32m1(elems, 4)); +} +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + vfloat64m1_t res = {tab[idxvec.val[0]], tab[idxvec.val[1]]}; + return v_float64x2(res); +} +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + vint32m1_t index_x = vmul_vx_i32m1(idxvec.val, 4, 4); + vint32m1_t index_y = vadd_vx_i32m1(index_x, 4, 4); + + x.val = vlxe_v_f32m1(tab, index_x, 4); + y.val = vlxe_v_f32m1(tab, index_y, 4); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + + x = v_float64x2(tab[idx[0]], tab[idx[1]]); + y = v_float64x2(tab[idx[0]+1], tab[idx[1]+1]); +} + +#define OPENCV_HAL_IMPL_RISCVV_PACKS(_Tp, _Tp2, _T2, num2, _T1, num, intrin, shr, _Type) \ +inline v_##_Tp##x##num v_pack(const v_##_Tp2##x##num2& a, const v_##_Tp2##x##num2& b) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, b.val); \ + return v_##_Tp##x##num(shr##_##_T1##m1(tmp, 0, num)); \ +}\ +template inline \ +v_##_Tp##x##num v_rshr_pack(const v_##_Tp2##x##num2& a, const v_##_Tp2##x##num2& b) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, b.val); \ + return v_##_Tp##x##num(intrin##_##_T1##m1(tmp, n, num)); \ +}\ +inline void v_pack_store(_Type* ptr, const v_##_Tp2##x##num2& a) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, vmv_v_x_##_T2##m1(0, num2)); \ + asm("" ::: "memory"); \ + vse_v_##_T1##m1(ptr, shr##_##_T1##m1(tmp, 0, num), num2); \ +}\ +template inline \ +void v_rshr_pack_store(_Type* ptr, const v_##_Tp2##x##num2& a) \ +{ \ + v##_Tp2##m2_t tmp = vundefined_##_T2##m2(); \ + tmp = vset_##_T2##m2(tmp, 0, a.val); \ + tmp = vset_##_T2##m2(tmp, 1, vmv_v_x_##_T2##m1(0, num2)); \ + vse_v_##_T1##m1(ptr, intrin##_##_T1##m1(tmp, n, num), num2); \ +} +OPENCV_HAL_IMPL_RISCVV_PACKS(int8, int16, i16, 8, i8, 16, vnclip_vx, vnclip_vx, signed char) +OPENCV_HAL_IMPL_RISCVV_PACKS(int16, int32, i32, 4, i16, 8, vnclip_vx, vnclip_vx, signed short) +OPENCV_HAL_IMPL_RISCVV_PACKS(int32, int64, i64, 2, i32, 4, vnclip_vx, vnsra_vx, int) +OPENCV_HAL_IMPL_RISCVV_PACKS(uint8, uint16, u16, 8, u8, 16, vnclipu_vx, vnclipu_vx, unsigned char) +OPENCV_HAL_IMPL_RISCVV_PACKS(uint16, uint32, u32, 4, u16, 8, vnclipu_vx, vnclipu_vx, unsigned short) +OPENCV_HAL_IMPL_RISCVV_PACKS(uint32, uint64, u64, 2, u32, 4, vnclipu_vx, vnsrl_vx, unsigned int) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + vuint16m2_t tmp = vundefined_u16m2(); \ + tmp = vset_u16m2(tmp, 0, a.val); \ + tmp = vset_u16m2(tmp, 1, b.val); \ + return v_uint8x16(vnsrl_vx_u8m1(tmp, 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + vuint32m4_t vabcd = vundefined_u32m4(); \ + vuint16m2_t v16 = vundefined_u16m2(); \ + vabcd = vset_u32m4(vabcd, 0, a.val); \ + vabcd = vset_u32m4(vabcd, 1, b.val); \ + vabcd = vset_u32m4(vabcd, 2, c.val); \ + vabcd = vset_u32m4(vabcd, 3, d.val); \ + v16 = vnsrl_vx_u16m2(vabcd, 0, 16); + return v_uint8x16(vnsrl_vx_u8m1(v16, 0, 16)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + vuint64m8_t v64 = vundefined_u64m8(); \ + vuint32m4_t v32 = vundefined_u32m4(); \ + vuint16m2_t v16 = vundefined_u16m2(); \ + v64 = vset_u64m8(v64, 0, a.val); \ + v64 = vset_u64m8(v64, 1, b.val); \ + v64 = vset_u64m8(v64, 2, c.val); \ + v64 = vset_u64m8(v64, 3, d.val); \ + v64 = vset_u64m8(v64, 4, e.val); \ + v64 = vset_u64m8(v64, 5, f.val); \ + v64 = vset_u64m8(v64, 6, g.val); \ + v64 = vset_u64m8(v64, 7, h.val); \ + v32 = vnsrl_vx_u32m4(v64, 0, 16); + v16 = vnsrl_vx_u16m2(v32, 0, 16); + return v_uint8x16(vnsrl_vx_u8m1(v16, 0, 16)); +} + +//inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) \ +//{ \ +// int16xm2_u tmp; \ +// tmp.m1[0] = (vint16m1_t)a.val; \ +// tmp.m1[1] = (vint16m1_t)b.val; \ +// e8xm1_t mask = (e8xm1_t)vmsge_vx_e16xm2_i16m2(tmp.v, 0, 16);\ +// return v_uint8x16(vnclipuvi_mask_u8m1_u16m2(vmv_v_x_u8m1(0, 16), (vuint16m2_t)tmp.v, 0, mask, 16)); +//} + +#define OPENCV_HAL_IMPL_RISCVV_PACK_U(tp1, num1, tp2, num2, _Tp) \ +inline v_uint##tp1##x##num1 v_pack_u(const v_int##tp2##x##num2& a, const v_int##tp2##x##num2& b) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + tmp = vset_##i##tp2##m2(tmp, 1, b.val); \ + vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + return v_uint##tp1##x##num1(vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val, 0, num1)); \ +} \ +inline void v_pack_u_store(_Tp* ptr, const v_int##tp2##x##num2& a) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + return vse_v_u##tp1##m1(ptr, vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val, 0, num1), num2); \ +} \ +template inline \ +v_uint##tp1##x##num1 v_rshr_pack_u(const v_int##tp2##x##num2& a, const v_int##tp2##x##num2& b) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + tmp = vset_##i##tp2##m2(tmp, 1, b.val); \ + vint##tp2##m2_t val = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + return v_uint##tp1##x##num1(vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val, n, num1)); \ +} \ +template inline \ +void v_rshr_pack_u_store(_Tp* ptr, const v_int##tp2##x##num2& a) \ +{ \ + vint##tp2##m2_t tmp = vundefined_##i##tp2##m2(); \ + tmp = vset_##i##tp2##m2(tmp, 0, a.val); \ + vint##tp2##m2_t val_ = vmax_vx_i##tp2##m2(tmp, 0, num1);\ + vuint##tp1##m1_t val = vnclipu_vx_u##tp1##m1((vuint##tp2##m2_t)val_, n, num1); \ + return vse_v_u##tp1##m1(ptr, val, num2);\ +} +OPENCV_HAL_IMPL_RISCVV_PACK_U(8, 16, 16, 8, unsigned char ) +OPENCV_HAL_IMPL_RISCVV_PACK_U(16, 8, 32, 4, unsigned short) + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_RISCVV_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_RISCVV_MUL_SAT(v_uint16x8, v_uint32x4) + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +static const signed char popCountTable[256] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; + +inline vuint8m1_t vcnt_u8(vuint8m1_t val){ + vuint8m1_t v0 = val & 1; + return vlxe_v_u8m1((unsigned char*)popCountTable, val >> 1, 16)+v0; +} + +inline v_uint8x16 +v_popcount(const v_uint8x16& a) +{ + return v_uint8x16(vcnt_u8(a.val)); +} + +inline v_uint8x16 +v_popcount(const v_int8x16& a) +{ + return v_uint8x16(vcnt_u8((vuint8m1_t)a.val)); +} + +inline v_uint16x8 +v_popcount(const v_uint16x8& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0E0C0A0806040200, 0, 0x0F0D0B0907050301, 0}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 8); + return v_uint16x8(vget_u16m2_u16m1(res, 0)); +} + +inline v_uint16x8 +v_popcount(const v_int16x8& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0E0C0A0806040200, 0, 0x0F0D0B0907050301, 0}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 8); + return v_uint16x8(vget_u16m2_u16m1(res, 0)); +} + +inline v_uint32x4 +v_popcount(const v_uint32x4& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0xFFFFFFFF0C080400, 0xFFFFFFFF0D090501, + 0xFFFFFFFF0E0A0602, 0xFFFFFFFF0F0B0703}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res_ = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 16); + vuint32m2_t res = vwaddu_vv_u32m2(vget_u16m2_u16m1(res_, 0), vget_u16m2_u16m1(res_, 1), 8); + return v_uint32x4(vget_u32m2_u32m1(res, 0)); +} + +inline v_uint32x4 +v_popcount(const v_int32x4& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0xFFFFFFFF0C080400, 0xFFFFFFFF0D090501, + 0xFFFFFFFF0E0A0602, 0xFFFFFFFF0F0B0703}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint16m2_t res_ = vwaddu_vv_u16m2(vget_u8m2_u8m1(tmp, 0), vget_u8m2_u8m1(tmp, 1), 16); + vuint32m2_t res = vwaddu_vv_u32m2(vget_u16m2_u16m1(res_, 0), vget_u16m2_u16m1(res_, 1), 8); + return v_uint32x4(vget_u32m2_u32m1(res, 0)); +} + +inline v_uint64x2 +v_popcount(const v_uint64x2& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0706050403020100, 0x0000000000000000, + 0x0F0E0D0C0B0A0908, 0x0000000000000000}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint8m1_t zero = vmv_v_x_u8m1(0, 16); + vuint8m1_t res1 = zero; + vuint8m1_t res2 = zero; + res1 = vredsum_vs_u8m1_u8m1(res1, vget_u8m2_u8m1(tmp, 0), zero, 8); + res2 = vredsum_vs_u8m1_u8m1(res2, vget_u8m2_u8m1(tmp, 1), zero, 8); + + return v_uint64x2((unsigned long)vmv_x_s_u8m1_u8(res1, 8), (unsigned long)vmv_x_s_u8m1_u8(res2, 8)); +} + +inline v_uint64x2 +v_popcount(const v_int64x2& a) +{ + vuint8m2_t tmp = vundefined_u8m2(); + tmp = vset_u8m2(tmp, 0, vcnt_u8((vuint8m1_t)a.val)); + vuint64m2_t mask = (vuint64m2_t){0x0706050403020100, 0x0000000000000000, + 0x0F0E0D0C0B0A0908, 0x0000000000000000}; + tmp = vrgather_vv_u8m2(tmp, (vuint8m2_t)mask, 32); \ + vuint8m1_t zero = vmv_v_x_u8m1(0, 16); + vuint8m1_t res1 = zero; + vuint8m1_t res2 = zero; + res1 = vredsum_vs_u8m1_u8m1(res1, vget_u8m2_u8m1(tmp, 0), zero, 8); + res2 = vredsum_vs_u8m1_u8m1(res2, vget_u8m2_u8m1(tmp, 1), zero, 8); + + return v_uint64x2((unsigned long)vmv_x_s_u8m1_u8(res1, 8), (unsigned long)vmv_x_s_u8m1_u8(res2, 8)); +} + +#define SMASK 1, 2, 4, 8, 16, 32, 64, 128 +inline int v_signmask(const v_uint8x16& a) +{ + vuint8m1_t t0 = vsrl_vx_u8m1(a.val, 7, 16); + vuint8m1_t m1 = (vuint8m1_t){SMASK, SMASK}; + vuint16m2_t t1 = vwmulu_vv_u16m2(t0, m1, 16); + vuint32m1_t res = vmv_v_x_u32m1(0, 4); + vuint32m2_t t2 = vwmulu_vx_u32m2(vget_u16m2_u16m1(t1, 1), 256, 8); + res = vredsum_vs_u32m2_u32m1(res, t2, res, 8); + res = vwredsumu_vs_u16m1_u32m1(res, vget_u16m2_u16m1(t1, 0), res, 8); + return vmv_x_s_u32m1_u32(res, 8); +} +inline int v_signmask(const v_int8x16& a) +{ + vuint8m1_t t0 = vsrl_vx_u8m1((vuint8m1_t)a.val, 7, 16); + vuint8m1_t m1 = (vuint8m1_t){SMASK, SMASK}; + vint16m2_t t1 = (vint16m2_t)vwmulu_vv_u16m2(t0, m1, 16); + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m2_t t2 = vwmul_vx_i32m2(vget_i16m2_i16m1(t1, 1), 256, 8); + res = vredsum_vs_i32m2_i32m1(res, t2, res, 8); + res = vwredsum_vs_i16m1_i32m1(res, vget_i16m2_i16m1(t1, 0), res, 8); + return vmv_x_s_i32m1_i32(res, 8); +} + +inline int v_signmask(const v_int16x8& a) +{ + vint16m1_t t0 = (vint16m1_t)vsrl_vx_u16m1((vuint16m1_t)a.val, 15, 8); + vint16m1_t m1 = (vint16m1_t){SMASK}; + vint16m1_t t1 = vmul_vv_i16m1(t0, m1, 8); + vint16m1_t res = vmv_v_x_i16m1(0, 8); + res = vredsum_vs_i16m1_i16m1(res, t1, res, 8); + return vmv_x_s_i16m1_i16(res, 8); +} +inline int v_signmask(const v_uint16x8& a) +{ + vint16m1_t t0 = (vint16m1_t)vsrl_vx_u16m1((vuint16m1_t)a.val, 15, 8); + vint16m1_t m1 = (vint16m1_t){SMASK}; + vint16m1_t t1 = vmul_vv_i16m1(t0, m1, 8); + vint16m1_t res = vmv_v_x_i16m1(0, 8); + res = vredsum_vs_i16m1_i16m1(res, t1, res, 8); + return vmv_x_s_i16m1_i16(res, 8); +} +inline int v_signmask(const v_int32x4& a) +{ + vint32m1_t t0 = (vint32m1_t)vsrl_vx_u32m1((vuint32m1_t)a.val, 31, 4); + vint32m1_t m1 = (vint32m1_t){1, 2, 4, 8}; + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m1_t t1 = vmul_vv_i32m1(t0, m1, 4); + res = vredsum_vs_i32m1_i32m1(res, t1, res, 4); + return vmv_x_s_i32m1_i32(res, 4); +} +inline int v_signmask(const v_uint32x4& a) +{ + vint32m1_t t0 = (vint32m1_t)vsrl_vx_u32m1(a.val, 31, 4); + vint32m1_t m1 = (vint32m1_t){1, 2, 4, 8}; + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m1_t t1 = vmul_vv_i32m1(t0, m1, 4); + res = vredsum_vs_i32m1_i32m1(res, t1, res, 4); + return vmv_x_s_i32m1_i32(res, 4); +} +inline int v_signmask(const v_uint64x2& a) +{ + vuint64m1_t v0 = vsrl_vx_u64m1(a.val, 63, 2); + int res = (int)vext_x_v_u64m1_u64(v0, 0, 2) + ((int)vext_x_v_u64m1_u64(v0, 1, 2) << 1); + return res; +} +inline int v_signmask(const v_int64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_u64(a)); } +inline int v_signmask(const v_float32x4& a) +{ + vint32m1_t t0 = (vint32m1_t)vsrl_vx_u32m1((vuint32m1_t)a.val, 31, 4); + vint32m1_t m1 = (vint32m1_t){1, 2, 4, 8}; + vint32m1_t res = vmv_v_x_i32m1(0, 4); + vint32m1_t t1 = vmul_vv_i32m1(t0, m1, 4); + res = vredsum_vs_i32m1_i32m1(res, t1, res, 4); + return vmv_x_s_i32m1_i32(res, 4); +} + +inline int v_scan_forward(const v_int8x16& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint8x16& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_int16x8& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint16x8& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_int32x4& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint32x4& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_float32x4& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_int64x2& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } +inline int v_scan_forward(const v_uint64x2& a) { +int val = v_signmask(a); +if(val==0) return 0; +else return trailingZeros32(val); } + +#define OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(_Tpvec, suffix, _T, shift, num) \ +inline bool v_check_all(const v_##_Tpvec& a) \ +{ \ + suffix##m1_t v0 = vsrl_vx_##_T(vnot_v_##_T(a.val, num), shift, num); \ + vuint64m1_t v1 = vuint64m1_t(v0); \ + return (v1[0] | v1[1]) == 0; \ +} \ +inline bool v_check_any(const v_##_Tpvec& a) \ +{ \ + suffix##m1_t v0 = vsrl_vx_##_T(a.val, shift, num); \ + vuint64m1_t v1 = vuint64m1_t(v0); \ + return (v1[0] | v1[1]) != 0; \ +} + +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint8x16, vuint8, u8m1, 7, 16) +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint16x8, vuint16, u16m1, 15, 8) +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint32x4, vuint32, u32m1, 31, 4) +OPENCV_HAL_IMPL_RISCVV_CHECK_ALLANY(uint64x2, vuint64, u64m1, 63, 2) + +inline bool v_check_all(const v_int8x16& a) +{ return v_check_all(v_reinterpret_as_u8(a)); } +inline bool v_check_all(const v_int16x8& a) +{ return v_check_all(v_reinterpret_as_u16(a)); } +inline bool v_check_all(const v_int32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_u32(a)); } +inline bool v_check_all(const v_int64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_u64(a)); } + +inline bool v_check_any(const v_int8x16& a) +{ return v_check_any(v_reinterpret_as_u8(a)); } +inline bool v_check_any(const v_int16x8& a) +{ return v_check_any(v_reinterpret_as_u16(a)); } +inline bool v_check_any(const v_int32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_u32(a)); } +inline bool v_check_any(const v_int64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_u64(a)); } + +#define OPENCV_HAL_IMPL_RISCVV_SELECT(_Tpvec, suffix, _Tpvec2, num) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(vmerge_vvm_##suffix(_Tpvec2(mask.val), b.val, a.val, num)); \ +} + +OPENCV_HAL_IMPL_RISCVV_SELECT(v_int8x16, i8m1, vbool8_t, 16) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_int16x8, i16m1, vbool16_t, 8) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_int32x4, i32m1, vbool32_t, 4) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint8x16, u8m1, vbool8_t, 16) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint16x8, u16m1, vbool16_t, 8) +OPENCV_HAL_IMPL_RISCVV_SELECT(v_uint32x4, u32m1, vbool32_t, 4) +inline v_float32x4 v_select(const v_float32x4& mask, const v_float32x4& a, const v_float32x4& b) +{ + return v_float32x4((vfloat32m1_t)vmerge_vvm_u32m1((vbool32_t)mask.val, (vuint32m1_t)b.val, (vuint32m1_t)a.val, 4)); +} +inline v_float64x2 v_select(const v_float64x2& mask, const v_float64x2& a, const v_float64x2& b) +{ + return v_float64x2((vfloat64m1_t)vmerge_vvm_u64m1((vbool64_t)mask.val, (vuint64m1_t)b.val, (vuint64m1_t)a.val, 2)); +} + +#define OPENCV_HAL_IMPL_RISCVV_EXPAND(add, _Tpvec, _Tpwvec, _Tp, _Tp1, num1, _Tp2, num2, _T1, _T2) \ +inline void v_expand(const _Tpvec& a, v_##_Tpwvec& b0, v_##_Tpwvec& b1) \ +{ \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(a.val, vmv_v_x_##_Tp1(0, num1), num1); \ + b0.val = vget_##_Tp2##m2_##_Tp2##m1(b, 0); \ + b1.val = vget_##_Tp2##m2_##_Tp2##m1(b, 1); \ +} \ +inline v_##_Tpwvec v_expand_low(const _Tpvec& a) \ +{ \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(a.val, vmv_v_x_##_Tp1(0, num2), num2); \ + return v_##_Tpwvec(vget_##_Tp2##m2_##_Tp2##m1(b, 0)); \ +} \ +inline v_##_Tpwvec v_expand_high(const _Tpvec& a) \ +{ \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(a.val, vmv_v_x_##_Tp1(0, num1), num1); \ + return v_##_Tpwvec(vget_##_Tp2##m2_##_Tp2##m1(b, 1)); \ +} \ +inline v_##_Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + _T2##_t val = vle##_v_##_Tp1(ptr, num2); \ + _T1##_t b = vw##add##_vv_##_Tp2##m2(val, vmv_v_x_##_Tp1(0, num2), num2); \ + return v_##_Tpwvec(vget_##_Tp2##m2_##_Tp2##m1(b, 0)); \ +} + +OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint8x16, uint16x8, uchar, u8m1, 16, u16, 8, vuint16m2, vuint8m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint16x8, uint32x4, ushort, u16m1, 8, u32, 4, vuint32m2, vuint16m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(addu, v_uint32x4, uint64x2, uint, u32m1, 4, u64, 2, vuint64m2, vuint32m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int8x16, int16x8, schar, i8m1, 16, i16, 8, vint16m2, vint8m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int16x8, int32x4, short, i16m1, 8, i32, 4, vint32m2, vint16m1) +OPENCV_HAL_IMPL_RISCVV_EXPAND(add, v_int32x4, int64x2, int, i32m1, 4, i64, 2, vint64m2, vint32m1) + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + vuint16m2_t b = vundefined_u16m2(); + vuint32m2_t c = vundefined_u32m2(); + vuint8m1_t val = vle_v_u8m1(ptr, 4); \ + b = vwaddu_vv_u16m2(val, vmv_v_x_u8m1(0, 4), 4); \ + c = vwaddu_vv_u32m2(vget_u16m2_u16m1(b, 0), vmv_v_x_u16m1(0, 4), 4); \ + return v_uint32x4(vget_u32m2_u32m1(c, 0)); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + vint16m2_t b = vundefined_i16m2(); + vint32m2_t c = vundefined_i32m2(); + vint8m1_t val = vle_v_i8m1(ptr, 4); \ + b = vwadd_vv_i16m2(val, vmv_v_x_i8m1(0, 4), 4); \ + c = vwadd_vv_i32m2(vget_i16m2_i16m1(b, 0), vmv_v_x_i16m1(0, 4), 4); \ + return v_int32x4(vget_i32m2_i32m1(c, 0)); +} +#define VITL_16 (vuint64m2_t){0x1303120211011000, 0x1707160615051404, 0x1B0B1A0A19091808, 0x1F0F1E0E1D0D1C0C} +#define VITL_8 (vuint64m2_t){0x0009000100080000, 0x000B0003000A0002, 0x000D0005000C0004, 0x000F0007000E0006} +#define VITL_4 (vuint64m2_t){0x0000000400000000, 0x0000000500000001, 0x0000000600000002, 0x0000000700000003} +#define VITL_2 (vuint64m2_t){0, 2, 1, 3} +#define LOW_4 0x0000000100000000, 0x0000000500000004 +#define LOW_8 0x0003000200010000, 0x000B000A00090008 +#define LOW_16 0x0706050403020100, 0x1716151413121110 +#define HIGH_4 0x0000000300000002, 0x0000000700000006 +#define HIGH_8 0x0007000600050004, 0x000F000E000D000C +#define HIGH_16 0x0F0E0D0C0B0A0908, 0x1F1E1D1C1B1A1918 +#define OPENCV_HAL_IMPL_RISCVV_UNPACKS(_Tpvec, _Tp, _T, _UTp, _UT, num, num2, len, numh) \ +inline void v_zip(const v_##_Tpvec& a0, const v_##_Tpvec& a1, v_##_Tpvec& b0, v_##_Tpvec& b1) \ +{ \ + v##_Tp##m2_t tmp = vundefined_##_T##m2();\ + tmp = vset_##_T##m2(tmp, 0, a0.val); \ + tmp = vset_##_T##m2(tmp, 1, a1.val); \ + vuint64m2_t mask = VITL_##num; \ + tmp = (v##_Tp##m2_t)vrgather_vv_##_T##m2((v##_Tp##m2_t)tmp, (v##_UTp##m2_t)mask, num2); \ + b0.val = vget_##_T##m2_##_T##m1(tmp, 0); \ + b1.val = vget_##_T##m2_##_T##m1(tmp, 1); \ +} \ +inline v_##_Tpvec v_combine_low(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + v##_Tp##m1_t b0 = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a.val, b.val, numh, num); \ + return v_##_Tpvec(b0);\ +} \ +inline v_##_Tpvec v_combine_high(const v_##_Tpvec& a, const v_##_Tpvec& b) \ +{ \ + v##_Tp##m1_t b0 = vslidedown_vx_##_T##m1(b.val, numh, num); \ + v##_Tp##m1_t a0 = vslidedown_vx_##_T##m1(a.val, numh, num); \ + v##_Tp##m1_t b1 = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a0, b0, numh, num); \ + return v_##_Tpvec(b1);\ +} \ +inline void v_recombine(const v_##_Tpvec& a, const v_##_Tpvec& b, v_##_Tpvec& c, v_##_Tpvec& d) \ +{ \ + c.val = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a.val, b.val, numh, num); \ + v##_Tp##m1_t b0 = vslidedown_vx_##_T##m1(b.val, numh, num); \ + v##_Tp##m1_t a0 = vslidedown_vx_##_T##m1(a.val, numh, num); \ + d.val = vslideup_vx_##_T##m1_m(vmset_m_##len(num), a0, b0, numh, num); \ +} + +OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint8x16, uint8, u8, uint8, u8, 16, 32, b8, 8) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(int8x16, int8, i8, uint8, u8, 16, 32, b8, 8) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint16x8, uint16, u16, uint16, u16, 8, 16, b16, 4) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(int16x8, int16, i16, uint16, u16, 8, 16, b16, 4) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(uint32x4, uint32, u32, uint32, u32, 4, 8, b32, 2) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(int32x4, int32, i32, uint32, u32, 4, 8, b32, 2) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(float32x4, float32, f32, uint32, u32, 4, 8, b32, 2) +OPENCV_HAL_IMPL_RISCVV_UNPACKS(float64x2, float64, f64, uint64, u64, 2, 4, b64, 1) + +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + vuint64m1_t mask = (vuint64m1_t){0x08090A0B0C0D0E0F, 0x0001020304050607}; + return v_uint8x16(vrgather_vv_u8m1(a.val, (vuint8m1_t)mask, 16)); +} +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ + vint64m1_t mask = (vint64m1_t){0x08090A0B0C0D0E0F, 0x0001020304050607}; + return v_int8x16(vrgather_vv_i8m1(a.val, (vuint8m1_t)mask, 16)); +} + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + vuint64m1_t mask = (vuint64m1_t){0x0004000500060007, 0x000000100020003}; + return v_uint16x8(vrgather_vv_u16m1(a.val, (vuint16m1_t)mask, 8)); +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ + vint64m1_t mask = (vint64m1_t){0x0004000500060007, 0x000000100020003}; + return v_int16x8(vrgather_vv_i16m1(a.val, (vuint16m1_t)mask, 8)); +} +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + return v_uint32x4(vrgather_vv_u32m1(a.val, (vuint32m1_t){3, 2, 1, 0}, 4)); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ + return v_int32x4(vrgather_vv_i32m1(a.val, (vuint32m1_t){3, 2, 1, 0}, 4)); +} + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + return v_uint64x2(a.val[1], a.val[0]); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ + return v_int64x2(a.val[1], a.val[0]); +} + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ + return v_float64x2(a.val[1], a.val[0]); +} + +#define OPENCV_HAL_IMPL_RISCVV_EXTRACT(_Tpvec, suffix, size) \ +template \ +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \ +{ return v_rotate_right(a, b);} +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint8x16, u8, 0) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int8x16, s8, 0) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint16x8, u16, 1) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int16x8, s16, 1) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint32x4, u32, 2) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int32x4, s32, 2) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_uint64x2, u64, 3) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_int64x2, s64, 3) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_float32x4, f32, 2) +OPENCV_HAL_IMPL_RISCVV_EXTRACT(v_float64x2, f64, 3) + + +#define OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(_Tpvec, _Tp, suffix) \ +template inline _Tp v_extract_n(_Tpvec v) { return v.val[i]; } + +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int8x16, schar, s8) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int16x8, short, s16) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint32x4, uint, u32) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int32x4, int, s32) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_int64x2, int64, s64) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_float32x4, float, f32) +OPENCV_HAL_IMPL_RISCVV_EXTRACT_N(v_float64x2, double, f64) + +#define OPENCV_HAL_IMPL_RISCVV_BROADCAST(_Tpvec, _Tp, num) \ +template inline _Tpvec v_broadcast_element(_Tpvec v) { return _Tpvec(vrgather_vx_##_Tp##m1(v.val, i, num)); } + +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint8x16, u8, 16) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int8x16, i8, 16) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint16x8, u16, 8) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int16x8, i16, 8) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint32x4, u32, 4) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int32x4, i32, 4) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_uint64x2, u64, 2) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_int64x2, i64, 2) +OPENCV_HAL_IMPL_RISCVV_BROADCAST(v_float32x4, f32, 4) +inline v_int32x4 v_round(const v_float32x4& a) +{ + __builtin_riscv_fsrm(0); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} +inline v_int32x4 v_floor(const v_float32x4& a) +{ + __builtin_riscv_fsrm(2); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + __builtin_riscv_fsrm(3); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ + __builtin_riscv_fsrm(1); + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)a.val, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), a.val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_round(const v_float64x2& a) +{ + __builtin_riscv_fsrm(0); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + //_val = vset_f64m2(_val, 1, a.val); + _val = vset_f64m2(_val, 1, vfmv_v_f_f64m1(0, 2)); + vint32m1_t val = vfncvt_x_f_v_i32m1(_val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + __builtin_riscv_fsrm(0); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + _val = vset_f64m2(_val, 1, b.val); + vint32m1_t val = vfncvt_x_f_v_i32m1(_val, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} +inline v_int32x4 v_floor(const v_float64x2& a) +{ + __builtin_riscv_fsrm(2); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)aval, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + __builtin_riscv_fsrm(3); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)aval, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ + __builtin_riscv_fsrm(1); + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + + vint32m1_t nan = vand_vx_i32m1((vint32m1_t)aval, 0x7f800000, 4); + vbool32_t mask = vmsne_vx_i32m1_b32(nan, 0x7f800000, 4); + vint32m1_t val = vfcvt_x_f_v_i32m1_m(mask, vmv_v_x_i32m1(0, 4), aval, 4); + __builtin_riscv_fsrm(0); + return v_int32x4(val); +} + +#define OPENCV_HAL_IMPL_RISCVV_LOAD_DEINTERLEAVED(intrin, _Tpvec, num, _Tp, _T) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b) \ +{ \ + v##_Tpvec##m1x2_t ret = intrin##2e_v_##_T##m1x2(ptr, num);\ + a.val = vget_##_T##m1x2_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x2_##_T##m1(ret, 1); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, v_##_Tpvec##x##num& c) \ +{ \ + v##_Tpvec##m1x3_t ret = intrin##3e_v_##_T##m1x3(ptr, num);\ + a.val = vget_##_T##m1x3_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x3_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x3_##_T##m1(ret, 2); \ +}\ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, \ + v_##_Tpvec##x##num& c, v_##_Tpvec##x##num& d) \ +{ \ + v##_Tpvec##m1x4_t ret = intrin##4e_v_##_T##m1x4(ptr, num);\ + a.val = vget_##_T##m1x4_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x4_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x4_##_T##m1(ret, 2); \ + d.val = vget_##_T##m1x4_##_T##m1(ret, 3); \ +} \ + +#define OPENCV_HAL_IMPL_RISCVV_STORE_INTERLEAVED(intrin, _Tpvec, num, _Tp, _T) \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x2_t ret = vundefined_##_T##m1x2(); \ + ret = vset_##_T##m1x2(ret, 0, a.val); \ + ret = vset_##_T##m1x2(ret, 1, b.val); \ + intrin##2e_v_##_T##m1x2(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x3_t ret = vundefined_##_T##m1x3(); \ + ret = vset_##_T##m1x3(ret, 0, a.val); \ + ret = vset_##_T##m1x3(ret, 1, b.val); \ + ret = vset_##_T##m1x3(ret, 2, c.val); \ + intrin##3e_v_##_T##m1x3(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, const v_##_Tpvec##x##num& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + v##_Tpvec##m1x4_t ret = vundefined_##_T##m1x4(); \ + ret = vset_##_T##m1x4(ret, 0, a.val); \ + ret = vset_##_T##m1x4(ret, 1, b.val); \ + ret = vset_##_T##m1x4(ret, 2, c.val); \ + ret = vset_##_T##m1x4(ret, 3, d.val); \ + intrin##4e_v_##_T##m1x4(ptr, ret, num); \ +} + +#define OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(_Tpvec, _Tp, num, ld, st, _T) \ +OPENCV_HAL_IMPL_RISCVV_LOAD_DEINTERLEAVED(ld, _Tpvec, num, _Tp, _T) \ +OPENCV_HAL_IMPL_RISCVV_STORE_INTERLEAVED(st, _Tpvec, num, _Tp, _T) + +//OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint8, uchar, ) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int8, schar, 16, vlseg, vsseg, i8) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int16, short, 8, vlseg, vsseg, i16) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(int32, int, 4, vlseg, vsseg, i32) + +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint8, unsigned char, 16, vlseg, vsseg, u8) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint16, unsigned short, 8, vlseg, vsseg, u16) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED(uint32, unsigned int, 4, vlseg, vsseg, u32) + +#define OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(_Tpvec, _Tp, num, _T) \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b) \ +{ \ + v##_Tpvec##m1x2_t ret = vlseg2e_v_##_T##m1x2(ptr, num); \ + a.val = vget_##_T##m1x2_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x2_##_T##m1(ret, 1); \ +} \ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, v_##_Tpvec##x##num& c) \ +{ \ + v##_Tpvec##m1x3_t ret = vlseg3e_v_##_T##m1x3(ptr, num); \ + a.val = vget_##_T##m1x3_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x3_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x3_##_T##m1(ret, 2); \ +}\ +inline void v_load_deinterleave(const _Tp* ptr, v_##_Tpvec##x##num& a, v_##_Tpvec##x##num& b, \ + v_##_Tpvec##x##num& c, v_##_Tpvec##x##num& d) \ +{ \ + v##_Tpvec##m1x4_t ret = vlseg4e_v_##_T##m1x4(ptr, num); \ + a.val = vget_##_T##m1x4_##_T##m1(ret, 0); \ + b.val = vget_##_T##m1x4_##_T##m1(ret, 1); \ + c.val = vget_##_T##m1x4_##_T##m1(ret, 2); \ + d.val = vget_##_T##m1x4_##_T##m1(ret, 3); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x2_t ret = vundefined_##_T##m1x2(); \ + ret = vset_##_T##m1x2(ret, 0, a.val); \ + ret = vset_##_T##m1x2(ret, 1, b.val); \ + vsseg2e_v_##_T##m1x2(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ \ + v##_Tpvec##m1x3_t ret = vundefined_##_T##m1x3(); \ + ret = vset_##_T##m1x3(ret, 0, a.val); \ + ret = vset_##_T##m1x3(ret, 1, b.val); \ + ret = vset_##_T##m1x3(ret, 2, c.val); \ + vsseg3e_v_##_T##m1x3(ptr, ret, num); \ +} \ +inline void v_store_interleave( _Tp* ptr, const v_##_Tpvec##x##num& a, const v_##_Tpvec##x##num& b, \ + const v_##_Tpvec##x##num& c, const v_##_Tpvec##x##num& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED ) \ +{ \ + v##_Tpvec##m1x4_t ret = vundefined_##_T##m1x4(); \ + ret = vset_##_T##m1x4(ret, 0, a.val); \ + ret = vset_##_T##m1x4(ret, 1, b.val); \ + ret = vset_##_T##m1x4(ret, 2, c.val); \ + ret = vset_##_T##m1x4(ret, 3, d.val); \ + vsseg4e_v_##_T##m1x4(ptr, ret, num); \ +} +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(float32, float, 4, f32) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(float64, double, 2, f64) + +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(uint64, unsigned long, 2, u64) +OPENCV_HAL_IMPL_RISCVV_INTERLEAVED_(int64, long, 2, i64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(vfcvt_f_x_v_f32m1(a.val, 4)); +} + +#if CV_SIMD128_64F +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 2); + return v_float32x4(aval); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + vfloat64m2_t _val = vundefined_f64m2(); + _val = vset_f64m2(_val, 0, a.val); + _val = vset_f64m2(_val, 1, b.val); + vfloat32m1_t aval = vfncvt_f_f_v_f32m1(_val, 4); + return v_float32x4(aval); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + vfloat32m1_t val = vfcvt_f_x_v_f32m1(a.val, 4); + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 0)); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + vfloat32m1_t val = vfcvt_f_x_v_f32m1(a.val, 4); + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 1)); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(a.val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 0)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + vfloat64m2_t _val = vfwcvt_f_f_v_f64m2(a.val, 4); + return v_float64x2(vget_f64m2_f64m1(_val, 1)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ + return v_float64x2(vfcvt_f_x_v_f64m1(a.val, 2)); +} + +#endif +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + vuint64m1_t m0 = {0x0705060403010200, 0x0F0D0E0C0B090A08}; + return v_int8x16(vrgather_vv_i8m1(vec.val, (vuint8m1_t)m0, 16)); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); +} + +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + vuint64m1_t m0 = {0x0703060205010400, 0x0F0B0E0A0D090C08}; + return v_int8x16(vrgather_vv_i8m1(vec.val, (vuint8m1_t)m0, 16)); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) +{ + return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); +} + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + vuint64m1_t m0 = {0x0706030205040100, 0x0F0E0B0A0D0C0908}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vec.val, (vuint8m1_t)m0, 16)); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + vuint64m1_t m0 = {0x0B0A030209080100, 0x0F0E07060D0C0504}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + vuint64m1_t m0 = {0x0B0A090803020100, 0x0F0E0D0C07060504}; + return v_int32x4((vint32m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + vuint64m1_t m0 = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + vuint64m1_t m0 = {0x0908050403020100, 0xFFFFFFFF0D0C0B0A}; + return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)(vec.val), (vuint8m1_t)m0, 16)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +#if CV_SIMD128_64F +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, + const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ + vint64m2_t v1 = vwmul_vv_i64m2(a.val, b.val, 4); + vfloat64m1_t res = vfcvt_f_x_v_f64m1(vadd_vv_i64m1(vget_i64m2_i64m1(v1, 0), vget_i64m2_i64m1(v1, 1), 2), 2); + return v_float64x2(res); +} +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ v_float64x2 res = v_dotprod_expand_fast(a, b); + return res + c; } +#endif +////// FP16 support /////// +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + vfloat16m1_t v = vle_v_f16m1((__fp16*)ptr, 4); + vfloat32m2_t v32 = vfwcvt_f_f_v_f32m2(v, 4); + return v_float32x4(vget_f32m2_f32m1(v32, 0)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + vfloat32m2_t v32 = vundefined_f32m2(); + v32 = vset_f32m2(v32, 0, v.val); + vfloat16m1_t hv = vfncvt_f_f_v_f16m1(v32, 4); + vse_v_f16m1((__fp16*)ptr, hv, 4); +} + + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_sse.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_sse.hpp new file mode 100644 index 0000000..443ee16 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_sse.hpp @@ -0,0 +1,3467 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_SSE_HPP +#define OPENCV_HAL_SSE_HPP + +#include +#include "opencv2/core/utility.hpp" + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 +#define CV_SIMD128_FP16 0 // no native operations with FP16 type. + +namespace cv +{ + +//! @cond IGNORED + +// +// Compilation troubleshooting: +// - MSVC: error C2719: 'a': formal parameter with requested alignment of 16 won't be aligned +// Replace parameter declaration to const reference: +// -v_int32x4 a +// +const v_int32x4& a +// + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + typedef __m128i vector_type; + enum { nlanes = 16 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint8x16() {} + explicit v_uint8x16(__m128i v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + val = _mm_setr_epi8((char)v0, (char)v1, (char)v2, (char)v3, + (char)v4, (char)v5, (char)v6, (char)v7, + (char)v8, (char)v9, (char)v10, (char)v11, + (char)v12, (char)v13, (char)v14, (char)v15); + } + + uchar get0() const + { + return (uchar)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + typedef __m128i vector_type; + enum { nlanes = 16 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int8x16() {} + explicit v_int8x16(__m128i v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + val = _mm_setr_epi8((char)v0, (char)v1, (char)v2, (char)v3, + (char)v4, (char)v5, (char)v6, (char)v7, + (char)v8, (char)v9, (char)v10, (char)v11, + (char)v12, (char)v13, (char)v14, (char)v15); + } + + schar get0() const + { + return (schar)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + typedef __m128i vector_type; + enum { nlanes = 8 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint16x8() {} + explicit v_uint16x8(__m128i v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + val = _mm_setr_epi16((short)v0, (short)v1, (short)v2, (short)v3, + (short)v4, (short)v5, (short)v6, (short)v7); + } + + ushort get0() const + { + return (ushort)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + typedef __m128i vector_type; + enum { nlanes = 8 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int16x8() {} + explicit v_int16x8(__m128i v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + val = _mm_setr_epi16((short)v0, (short)v1, (short)v2, (short)v3, + (short)v4, (short)v5, (short)v6, (short)v7); + } + + short get0() const + { + return (short)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + typedef __m128i vector_type; + enum { nlanes = 4 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint32x4() {} + explicit v_uint32x4(__m128i v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + val = _mm_setr_epi32((int)v0, (int)v1, (int)v2, (int)v3); + } + + unsigned get0() const + { + return (unsigned)_mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + typedef __m128i vector_type; + enum { nlanes = 4 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int32x4() {} + explicit v_int32x4(__m128i v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + val = _mm_setr_epi32(v0, v1, v2, v3); + } + + int get0() const + { + return _mm_cvtsi128_si32(val); + } + + __m128i val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + typedef __m128 vector_type; + enum { nlanes = 4 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_float32x4() {} + explicit v_float32x4(__m128 v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + val = _mm_setr_ps(v0, v1, v2, v3); + } + + float get0() const + { + return _mm_cvtss_f32(val); + } + + __m128 val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + typedef __m128i vector_type; + enum { nlanes = 2 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_uint64x2() {} + explicit v_uint64x2(__m128i v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { +#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__) + val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1); +#elif defined(__GNUC__) + val = _mm_setr_epi64((__m64)v0, (__m64)v1); +#else + val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32)); +#endif + } + + uint64 get0() const + { + #if !defined(__x86_64__) && !defined(_M_X64) + int a = _mm_cvtsi128_si32(val); + int b = _mm_cvtsi128_si32(_mm_srli_epi64(val, 32)); + return (unsigned)a | ((uint64)(unsigned)b << 32); + #else + return (uint64)_mm_cvtsi128_si64(val); + #endif + } + + __m128i val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + typedef __m128i vector_type; + enum { nlanes = 2 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_int64x2() {} + explicit v_int64x2(__m128i v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { +#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__) + val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1); +#elif defined(__GNUC__) + val = _mm_setr_epi64((__m64)v0, (__m64)v1); +#else + val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32)); +#endif + } + + int64 get0() const + { + #if !defined(__x86_64__) && !defined(_M_X64) + int a = _mm_cvtsi128_si32(val); + int b = _mm_cvtsi128_si32(_mm_srli_epi64(val, 32)); + return (int64)((unsigned)a | ((uint64)(unsigned)b << 32)); + #else + return _mm_cvtsi128_si64(val); + #endif + } + + __m128i val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + typedef __m128d vector_type; + enum { nlanes = 2 }; + + /* coverity[uninit_ctor]: suppress warning */ + v_float64x2() {} + explicit v_float64x2(__m128d v) : val(v) {} + v_float64x2(double v0, double v1) + { + val = _mm_setr_pd(v0, v1); + } + + double get0() const + { + return _mm_cvtsd_f64(val); + } + + __m128d val; +}; + +namespace hal_sse_internal +{ + template + to_sse_type v_sse_reinterpret_as(const from_sse_type& val); + +#define OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(to_sse_type, from_sse_type, sse_cast_intrin) \ + template<> inline \ + to_sse_type v_sse_reinterpret_as(const from_sse_type& a) \ + { return sse_cast_intrin(a); } + + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128i, __m128i, OPENCV_HAL_NOP) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128i, __m128, _mm_castps_si128) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128i, __m128d, _mm_castpd_si128) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128, __m128i, _mm_castsi128_ps) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128, __m128, OPENCV_HAL_NOP) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128, __m128d, _mm_castpd_ps) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128d, __m128i, _mm_castsi128_pd) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128d, __m128, _mm_castps_pd) + OPENCV_HAL_IMPL_SSE_REINTERPRET_RAW(__m128d, __m128d, OPENCV_HAL_NOP) +} + +#define OPENCV_HAL_IMPL_SSE_INITVEC(_Tpvec, _Tp, suffix, zsuffix, ssuffix, _Tps, cast) \ +inline _Tpvec v_setzero_##suffix() { return _Tpvec(_mm_setzero_##zsuffix()); } \ +inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(_mm_set1_##ssuffix((_Tps)v)); } \ +template inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0& a) \ +{ return _Tpvec(cast(a.val)); } + +OPENCV_HAL_IMPL_SSE_INITVEC(v_uint8x16, uchar, u8, si128, epi8, schar, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_int8x16, schar, s8, si128, epi8, schar, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_uint16x8, ushort, u16, si128, epi16, short, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_int16x8, short, s16, si128, epi16, short, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_uint32x4, unsigned, u32, si128, epi32, int, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_int32x4, int, s32, si128, epi32, int, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_INITVEC(v_float32x4, float, f32, ps, ps, float, _mm_castsi128_ps) +OPENCV_HAL_IMPL_SSE_INITVEC(v_float64x2, double, f64, pd, pd, double, _mm_castsi128_pd) + +inline v_uint64x2 v_setzero_u64() { return v_uint64x2(_mm_setzero_si128()); } +inline v_int64x2 v_setzero_s64() { return v_int64x2(_mm_setzero_si128()); } +inline v_uint64x2 v_setall_u64(uint64 val) { return v_uint64x2(val, val); } +inline v_int64x2 v_setall_s64(int64 val) { return v_int64x2(val, val); } + +template inline +v_uint64x2 v_reinterpret_as_u64(const _Tpvec& a) { return v_uint64x2(a.val); } +template inline +v_int64x2 v_reinterpret_as_s64(const _Tpvec& a) { return v_int64x2(a.val); } +inline v_float32x4 v_reinterpret_as_f32(const v_uint64x2& a) +{ return v_float32x4(_mm_castsi128_ps(a.val)); } +inline v_float32x4 v_reinterpret_as_f32(const v_int64x2& a) +{ return v_float32x4(_mm_castsi128_ps(a.val)); } +inline v_float64x2 v_reinterpret_as_f64(const v_uint64x2& a) +{ return v_float64x2(_mm_castsi128_pd(a.val)); } +inline v_float64x2 v_reinterpret_as_f64(const v_int64x2& a) +{ return v_float64x2(_mm_castsi128_pd(a.val)); } + +#define OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(_Tpvec, suffix) \ +inline _Tpvec v_reinterpret_as_##suffix(const v_float32x4& a) \ +{ return _Tpvec(_mm_castps_si128(a.val)); } \ +inline _Tpvec v_reinterpret_as_##suffix(const v_float64x2& a) \ +{ return _Tpvec(_mm_castpd_si128(a.val)); } + +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint8x16, u8) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int8x16, s8) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint16x8, u16) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int16x8, s16) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint32x4, u32) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int32x4, s32) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_uint64x2, u64) +OPENCV_HAL_IMPL_SSE_INIT_FROM_FLT(v_int64x2, s64) + +inline v_float32x4 v_reinterpret_as_f32(const v_float32x4& a) {return a; } +inline v_float64x2 v_reinterpret_as_f64(const v_float64x2& a) {return a; } +inline v_float32x4 v_reinterpret_as_f32(const v_float64x2& a) {return v_float32x4(_mm_castpd_ps(a.val)); } +inline v_float64x2 v_reinterpret_as_f64(const v_float32x4& a) {return v_float64x2(_mm_castps_pd(a.val)); } + +//////////////// PACK /////////////// +inline v_uint8x16 v_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + __m128i delta = _mm_set1_epi16(255); + return v_uint8x16(_mm_packus_epi16(_mm_subs_epu16(a.val, _mm_subs_epu16(a.val, delta)), + _mm_subs_epu16(b.val, _mm_subs_epu16(b.val, delta)))); +} + +inline void v_pack_store(uchar* ptr, const v_uint16x8& a) +{ + __m128i delta = _mm_set1_epi16(255); + __m128i a1 = _mm_subs_epu16(a.val, _mm_subs_epu16(a.val, delta)); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a1, a1)); +} + +inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) +{ return v_uint8x16(_mm_packus_epi16(a.val, b.val)); } + +inline void v_pack_u_store(uchar* ptr, const v_int16x8& a) +{ _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a.val, a.val)); } + +template inline +v_uint8x16 v_rshr_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + return v_uint8x16(_mm_packus_epi16(_mm_srli_epi16(_mm_adds_epu16(a.val, delta), n), + _mm_srli_epi16(_mm_adds_epu16(b.val, delta), n))); +} + +template inline +void v_rshr_pack_store(uchar* ptr, const v_uint16x8& a) +{ + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + __m128i a1 = _mm_srli_epi16(_mm_adds_epu16(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a1, a1)); +} + +template inline +v_uint8x16 v_rshr_pack_u(const v_int16x8& a, const v_int16x8& b) +{ + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + return v_uint8x16(_mm_packus_epi16(_mm_srai_epi16(_mm_adds_epi16(a.val, delta), n), + _mm_srai_epi16(_mm_adds_epi16(b.val, delta), n))); +} + +template inline +void v_rshr_pack_u_store(uchar* ptr, const v_int16x8& a) +{ + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + __m128i a1 = _mm_srai_epi16(_mm_adds_epi16(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi16(a1, a1)); +} + +inline v_int8x16 v_pack(const v_int16x8& a, const v_int16x8& b) +{ return v_int8x16(_mm_packs_epi16(a.val, b.val)); } + +inline void v_pack_store(schar* ptr, const v_int16x8& a) +{ _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi16(a.val, a.val)); } + +template inline +v_int8x16 v_rshr_pack(const v_int16x8& a, const v_int16x8& b) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + return v_int8x16(_mm_packs_epi16(_mm_srai_epi16(_mm_adds_epi16(a.val, delta), n), + _mm_srai_epi16(_mm_adds_epi16(b.val, delta), n))); +} +template inline +void v_rshr_pack_store(schar* ptr, const v_int16x8& a) +{ + // we assume that n > 0, and so the shifted 16-bit values can be treated as signed numbers. + __m128i delta = _mm_set1_epi16((short)(1 << (n-1))); + __m128i a1 = _mm_srai_epi16(_mm_adds_epi16(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi16(a1, a1)); +} + + +// byte-wise "mask ? a : b" +inline __m128i v_select_si128(__m128i mask, __m128i a, __m128i b) +{ +#if CV_SSE4_1 + return _mm_blendv_epi8(b, a, mask); +#else + return _mm_xor_si128(b, _mm_and_si128(_mm_xor_si128(a, b), mask)); +#endif +} + +inline v_uint16x8 v_pack(const v_uint32x4& a, const v_uint32x4& b) +{ return v_uint16x8(_v128_packs_epu32(a.val, b.val)); } + +inline void v_pack_store(ushort* ptr, const v_uint32x4& a) +{ + __m128i z = _mm_setzero_si128(), maxval32 = _mm_set1_epi32(65535), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(v_select_si128(_mm_cmpgt_epi32(z, a.val), maxval32, a.val), delta32); + __m128i r = _mm_packs_epi32(a1, a1); + _mm_storel_epi64((__m128i*)ptr, _mm_sub_epi16(r, _mm_set1_epi16(-32768))); +} + +template inline +v_uint16x8 v_rshr_pack(const v_uint32x4& a, const v_uint32x4& b) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srli_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i b1 = _mm_sub_epi32(_mm_srli_epi32(_mm_add_epi32(b.val, delta), n), delta32); + return v_uint16x8(_mm_sub_epi16(_mm_packs_epi32(a1, b1), _mm_set1_epi16(-32768))); +} + +template inline +void v_rshr_pack_store(ushort* ptr, const v_uint32x4& a) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srli_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + _mm_storel_epi64((__m128i*)ptr, a2); +} + +inline v_uint16x8 v_pack_u(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_uint16x8(_mm_packus_epi32(a.val, b.val)); +#else + __m128i delta32 = _mm_set1_epi32(32768); + + // preliminary saturate negative values to zero + __m128i a1 = _mm_and_si128(a.val, _mm_cmpgt_epi32(a.val, _mm_set1_epi32(0))); + __m128i b1 = _mm_and_si128(b.val, _mm_cmpgt_epi32(b.val, _mm_set1_epi32(0))); + + __m128i r = _mm_packs_epi32(_mm_sub_epi32(a1, delta32), _mm_sub_epi32(b1, delta32)); + return v_uint16x8(_mm_sub_epi16(r, _mm_set1_epi16(-32768))); +#endif +} + +inline void v_pack_u_store(ushort* ptr, const v_int32x4& a) +{ +#if CV_SSE4_1 + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi32(a.val, a.val)); +#else + __m128i delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(a.val, delta32); + __m128i r = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + _mm_storel_epi64((__m128i*)ptr, r); +#endif +} + +template inline +v_uint16x8 v_rshr_pack_u(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + __m128i delta = _mm_set1_epi32(1 << (n - 1)); + return v_uint16x8(_mm_packus_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), + _mm_srai_epi32(_mm_add_epi32(b.val, delta), n))); +#else + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + __m128i b1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(b.val, delta), n), delta32); + __m128i b2 = _mm_sub_epi16(_mm_packs_epi32(b1, b1), _mm_set1_epi16(-32768)); + return v_uint16x8(_mm_unpacklo_epi64(a2, b2)); +#endif +} + +template inline +void v_rshr_pack_u_store(ushort* ptr, const v_int32x4& a) +{ +#if CV_SSE4_1 + __m128i delta = _mm_set1_epi32(1 << (n - 1)); + __m128i a1 = _mm_srai_epi32(_mm_add_epi32(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packus_epi32(a1, a1)); +#else + __m128i delta = _mm_set1_epi32(1 << (n-1)), delta32 = _mm_set1_epi32(32768); + __m128i a1 = _mm_sub_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), delta32); + __m128i a2 = _mm_sub_epi16(_mm_packs_epi32(a1, a1), _mm_set1_epi16(-32768)); + _mm_storel_epi64((__m128i*)ptr, a2); +#endif +} + +inline v_int16x8 v_pack(const v_int32x4& a, const v_int32x4& b) +{ return v_int16x8(_mm_packs_epi32(a.val, b.val)); } + +inline void v_pack_store(short* ptr, const v_int32x4& a) +{ + _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi32(a.val, a.val)); +} + +template inline +v_int16x8 v_rshr_pack(const v_int32x4& a, const v_int32x4& b) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)); + return v_int16x8(_mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(a.val, delta), n), + _mm_srai_epi32(_mm_add_epi32(b.val, delta), n))); +} + +template inline +void v_rshr_pack_store(short* ptr, const v_int32x4& a) +{ + __m128i delta = _mm_set1_epi32(1 << (n-1)); + __m128i a1 = _mm_srai_epi32(_mm_add_epi32(a.val, delta), n); + _mm_storel_epi64((__m128i*)ptr, _mm_packs_epi32(a1, a1)); +} + + +// [a0 0 | b0 0] [a1 0 | b1 0] +inline v_uint32x4 v_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + __m128i v0 = _mm_unpacklo_epi32(a.val, b.val); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a.val, b.val); // b0 b1 0 0 + return v_uint32x4(_mm_unpacklo_epi32(v0, v1)); +} + +inline void v_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + __m128i a1 = _mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a1); +} + +// [a0 0 | b0 0] [a1 0 | b1 0] +inline v_int32x4 v_pack(const v_int64x2& a, const v_int64x2& b) +{ + __m128i v0 = _mm_unpacklo_epi32(a.val, b.val); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a.val, b.val); // b0 b1 0 0 + return v_int32x4(_mm_unpacklo_epi32(v0, v1)); +} + +inline void v_pack_store(int* ptr, const v_int64x2& a) +{ + __m128i a1 = _mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a1); +} + +template inline +v_uint32x4 v_rshr_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + uint64 delta = (uint64)1 << (n-1); + v_uint64x2 delta2(delta, delta); + __m128i a1 = _mm_srli_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i b1 = _mm_srli_epi64(_mm_add_epi64(b.val, delta2.val), n); + __m128i v0 = _mm_unpacklo_epi32(a1, b1); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a1, b1); // b0 b1 0 0 + return v_uint32x4(_mm_unpacklo_epi32(v0, v1)); +} + +template inline +void v_rshr_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + uint64 delta = (uint64)1 << (n-1); + v_uint64x2 delta2(delta, delta); + __m128i a1 = _mm_srli_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i a2 = _mm_shuffle_epi32(a1, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a2); +} + +inline __m128i v_sign_epi64(__m128i a) +{ + return _mm_shuffle_epi32(_mm_srai_epi32(a, 31), _MM_SHUFFLE(3, 3, 1, 1)); // x m0 | x m1 +} + +inline __m128i v_srai_epi64(__m128i a, int imm) +{ + __m128i smask = v_sign_epi64(a); + return _mm_xor_si128(_mm_srli_epi64(_mm_xor_si128(a, smask), imm), smask); +} + +template inline +v_int32x4 v_rshr_pack(const v_int64x2& a, const v_int64x2& b) +{ + int64 delta = (int64)1 << (n-1); + v_int64x2 delta2(delta, delta); + __m128i a1 = v_srai_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i b1 = v_srai_epi64(_mm_add_epi64(b.val, delta2.val), n); + __m128i v0 = _mm_unpacklo_epi32(a1, b1); // a0 a1 0 0 + __m128i v1 = _mm_unpackhi_epi32(a1, b1); // b0 b1 0 0 + return v_int32x4(_mm_unpacklo_epi32(v0, v1)); +} + +template inline +void v_rshr_pack_store(int* ptr, const v_int64x2& a) +{ + int64 delta = (int64)1 << (n-1); + v_int64x2 delta2(delta, delta); + __m128i a1 = v_srai_epi64(_mm_add_epi64(a.val, delta2.val), n); + __m128i a2 = _mm_shuffle_epi32(a1, _MM_SHUFFLE(0, 2, 2, 0)); + _mm_storel_epi64((__m128i*)ptr, a2); +} + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + __m128i ab = _mm_packs_epi16(a.val, b.val); + return v_uint8x16(ab); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + __m128i ab = _mm_packs_epi32(a.val, b.val); + __m128i cd = _mm_packs_epi32(c.val, d.val); + return v_uint8x16(_mm_packs_epi16(ab, cd)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + __m128i ab = _mm_packs_epi32(a.val, b.val); + __m128i cd = _mm_packs_epi32(c.val, d.val); + __m128i ef = _mm_packs_epi32(e.val, f.val); + __m128i gh = _mm_packs_epi32(g.val, h.val); + + __m128i abcd = _mm_packs_epi32(ab, cd); + __m128i efgh = _mm_packs_epi32(ef, gh); + return v_uint8x16(_mm_packs_epi16(abcd, efgh)); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + __m128 v0 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(0, 0, 0, 0)), m0.val); + __m128 v1 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(1, 1, 1, 1)), m1.val); + __m128 v2 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(2, 2, 2, 2)), m2.val); + __m128 v3 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(3, 3, 3, 3)), m3.val); + + return v_float32x4(_mm_add_ps(_mm_add_ps(v0, v1), _mm_add_ps(v2, v3))); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + __m128 v0 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(0, 0, 0, 0)), m0.val); + __m128 v1 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(1, 1, 1, 1)), m1.val); + __m128 v2 = _mm_mul_ps(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE(2, 2, 2, 2)), m2.val); + + return v_float32x4(_mm_add_ps(_mm_add_ps(v0, v1), _mm_add_ps(v2, a.val))); +} + +#define OPENCV_HAL_IMPL_SSE_BIN_OP(bin_op, _Tpvec, intrin) \ + inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ + { \ + return _Tpvec(intrin(a.val, b.val)); \ + } \ + inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ + { \ + a.val = intrin(a.val, b.val); \ + return a; \ + } + +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint8x16, _mm_adds_epu8) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint8x16, _mm_subs_epu8) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int8x16, _mm_adds_epi8) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int8x16, _mm_subs_epi8) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint16x8, _mm_adds_epu16) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint16x8, _mm_subs_epu16) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int16x8, _mm_adds_epi16) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int16x8, _mm_subs_epi16) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint32x4, _mm_add_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint32x4, _mm_sub_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_uint32x4, _v128_mullo_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int32x4, _mm_add_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int32x4, _mm_sub_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_int32x4, _v128_mullo_epi32) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_float32x4, _mm_add_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_float32x4, _mm_sub_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_float32x4, _mm_mul_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(/, v_float32x4, _mm_div_ps) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_float64x2, _mm_add_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_float64x2, _mm_sub_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(*, v_float64x2, _mm_mul_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(/, v_float64x2, _mm_div_pd) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_uint64x2, _mm_add_epi64) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_uint64x2, _mm_sub_epi64) +OPENCV_HAL_IMPL_SSE_BIN_OP(+, v_int64x2, _mm_add_epi64) +OPENCV_HAL_IMPL_SSE_BIN_OP(-, v_int64x2, _mm_sub_epi64) + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_SSE_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_uint16x8, v_uint32x4) +OPENCV_HAL_IMPL_SSE_MUL_SAT(v_int16x8, v_int32x4) + +// Multiply and expand +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + v_uint16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + v_int16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + __m128i v0 = _mm_mullo_epi16(a.val, b.val); + __m128i v1 = _mm_mulhi_epi16(a.val, b.val); + c.val = _mm_unpacklo_epi16(v0, v1); + d.val = _mm_unpackhi_epi16(v0, v1); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + __m128i v0 = _mm_mullo_epi16(a.val, b.val); + __m128i v1 = _mm_mulhi_epu16(a.val, b.val); + c.val = _mm_unpacklo_epi16(v0, v1); + d.val = _mm_unpackhi_epi16(v0, v1); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + __m128i c0 = _mm_mul_epu32(a.val, b.val); + __m128i c1 = _mm_mul_epu32(_mm_srli_epi64(a.val, 32), _mm_srli_epi64(b.val, 32)); + c.val = _mm_unpacklo_epi64(c0, c1); + d.val = _mm_unpackhi_epi64(c0, c1); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) { return v_int16x8(_mm_mulhi_epi16(a.val, b.val)); } +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) { return v_uint16x8(_mm_mulhi_epu16(a.val, b.val)); } + +//////// Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ return v_int32x4(_mm_madd_epi16(a.val, b.val)); } +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + __m128i even = _mm_mul_epi32(a.val, b.val); + __m128i odd = _mm_mul_epi32(_mm_srli_epi64(a.val, 32), _mm_srli_epi64(b.val, 32)); + return v_int64x2(_mm_add_epi64(even, odd)); +#else + __m128i even_u = _mm_mul_epu32(a.val, b.val); + __m128i odd_u = _mm_mul_epu32(_mm_srli_epi64(a.val, 32), _mm_srli_epi64(b.val, 32)); + // convert unsigned to signed high multiplication (from: Agner Fog(veclib) and H S Warren: Hacker's delight, 2003, p. 132) + __m128i a_sign = _mm_srai_epi32(a.val, 31); + __m128i b_sign = _mm_srai_epi32(b.val, 31); + // |x * sign of x + __m128i axb = _mm_and_si128(a.val, b_sign); + __m128i bxa = _mm_and_si128(b.val, a_sign); + // sum of sign corrections + __m128i ssum = _mm_add_epi32(bxa, axb); + __m128i even_ssum = _mm_slli_epi64(ssum, 32); + __m128i odd_ssum = _mm_and_si128(ssum, _mm_set_epi32(-1, 0, -1, 0)); + // convert to signed and prod + return v_int64x2(_mm_add_epi64(_mm_sub_epi64(even_u, even_ssum), _mm_sub_epi64(odd_u, odd_ssum))); +#endif +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i a0 = _mm_srli_epi16(_mm_slli_si128(a.val, 1), 8); // even + __m128i a1 = _mm_srli_epi16(a.val, 8); // odd + __m128i b0 = _mm_srli_epi16(_mm_slli_si128(b.val, 1), 8); + __m128i b1 = _mm_srli_epi16(b.val, 8); + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_uint32x4(_mm_add_epi32(p0, p1)); +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + __m128i a0 = _mm_srai_epi16(_mm_slli_si128(a.val, 1), 8); // even + __m128i a1 = _mm_srai_epi16(a.val, 8); // odd + __m128i b0 = _mm_srai_epi16(_mm_slli_si128(b.val, 1), 8); + __m128i b1 = _mm_srai_epi16(b.val, 8); + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_int32x4(_mm_add_epi32(p0, p1)); +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 c, d; + v_mul_expand(a, b, c, d); + + v_uint64x2 c0, c1, d0, d1; + v_expand(c, c0, c1); + v_expand(d, d0, d1); + + c0 += c1; d0 += d1; + return v_uint64x2(_mm_add_epi64( + _mm_unpacklo_epi64(c0.val, d0.val), + _mm_unpackhi_epi64(c0.val, d0.val) + )); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return v_int64x2(_mm_add_epi64( + _mm_unpacklo_epi64(c.val, d.val), + _mm_unpackhi_epi64(c.val, d.val) + )); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_cvt_f64(v_dotprod(a, b)); +#else + v_float64x2 c = v_cvt_f64(a) * v_cvt_f64(b); + v_float64x2 d = v_cvt_f64_high(a) * v_cvt_f64_high(b); + + return v_float64x2(_mm_add_pd( + _mm_unpacklo_pd(c.val, d.val), + _mm_unpackhi_pd(c.val, d.val) + )); +#endif +} +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b) + c; } + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod_fast(a, b) + c; } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i a0 = v_expand_low(a).val; + __m128i a1 = v_expand_high(a).val; + __m128i b0 = v_expand_low(b).val; + __m128i b1 = v_expand_high(b).val; + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_uint32x4(_mm_add_epi32(p0, p1)); +} +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_SSE4_1 + __m128i a0 = _mm_cvtepi8_epi16(a.val); + __m128i a1 = v_expand_high(a).val; + __m128i b0 = _mm_cvtepi8_epi16(b.val); + __m128i b1 = v_expand_high(b).val; + __m128i p0 = _mm_madd_epi16(a0, b0); + __m128i p1 = _mm_madd_epi16(a1, b1); + return v_int32x4(_mm_add_epi32(p0, p1)); +#else + return v_dotprod_expand(a, b); +#endif +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 c, d; + v_mul_expand(a, b, c, d); + + v_uint64x2 c0, c1, d0, d1; + v_expand(c, c0, c1); + v_expand(d, d0, d1); + + c0 += c1; d0 += d1; + return c0 + d0; +} +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return c + d; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c); +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_cvt_f64_high(a) * v_cvt_f64_high(b)); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_fma(v_cvt_f64(a), v_cvt_f64(b), v_fma(v_cvt_f64_high(a), v_cvt_f64_high(b), c)); } + +#define OPENCV_HAL_IMPL_SSE_LOGIC_OP(_Tpvec, suffix, not_const) \ + OPENCV_HAL_IMPL_SSE_BIN_OP(&, _Tpvec, _mm_and_##suffix) \ + OPENCV_HAL_IMPL_SSE_BIN_OP(|, _Tpvec, _mm_or_##suffix) \ + OPENCV_HAL_IMPL_SSE_BIN_OP(^, _Tpvec, _mm_xor_##suffix) \ + inline _Tpvec operator ~ (const _Tpvec& a) \ + { \ + return _Tpvec(_mm_xor_##suffix(a.val, not_const)); \ + } + +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint8x16, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int8x16, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint16x8, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int16x8, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint32x4, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int32x4, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_uint64x2, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_int64x2, si128, _mm_set1_epi32(-1)) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_float32x4, ps, _mm_castsi128_ps(_mm_set1_epi32(-1))) +OPENCV_HAL_IMPL_SSE_LOGIC_OP(v_float64x2, pd, _mm_castsi128_pd(_mm_set1_epi32(-1))) + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ return v_float32x4(_mm_sqrt_ps(x.val)); } + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + const __m128 _0_5 = _mm_set1_ps(0.5f), _1_5 = _mm_set1_ps(1.5f); + __m128 t = x.val; + __m128 h = _mm_mul_ps(t, _0_5); + t = _mm_rsqrt_ps(t); + t = _mm_mul_ps(t, _mm_sub_ps(_1_5, _mm_mul_ps(_mm_mul_ps(t, t), h))); + return v_float32x4(t); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ return v_float64x2(_mm_sqrt_pd(x.val)); } + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + const __m128d v_1 = _mm_set1_pd(1.); + return v_float64x2(_mm_div_pd(v_1, _mm_sqrt_pd(x.val))); +} + +#define OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(_Tpuvec, _Tpsvec, func, suffix, subWidth) \ +inline _Tpuvec v_abs(const _Tpsvec& x) \ +{ return _Tpuvec(_mm_##func##_ep##suffix(x.val, _mm_sub_ep##subWidth(_mm_setzero_si128(), x.val))); } + +OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(v_uint8x16, v_int8x16, min, u8, i8) +OPENCV_HAL_IMPL_SSE_ABS_INT_FUNC(v_uint16x8, v_int16x8, max, i16, i16) +inline v_uint32x4 v_abs(const v_int32x4& x) +{ + __m128i s = _mm_srli_epi32(x.val, 31); + __m128i f = _mm_srai_epi32(x.val, 31); + return v_uint32x4(_mm_add_epi32(_mm_xor_si128(x.val, f), s)); +} +inline v_float32x4 v_abs(const v_float32x4& x) +{ return v_float32x4(_mm_and_ps(x.val, _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)))); } +inline v_float64x2 v_abs(const v_float64x2& x) +{ + return v_float64x2(_mm_and_pd(x.val, + _mm_castsi128_pd(_mm_srli_epi64(_mm_set1_epi32(-1), 1)))); +} + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_SSE_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_min, _mm_min_epu8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_max, _mm_max_epu8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_min, _mm_min_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_max, _mm_max_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float32x4, v_min, _mm_min_ps) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float32x4, v_max, _mm_max_ps) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float64x2, v_min, _mm_min_pd) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_float64x2, v_max, _mm_max_pd) + +inline v_int8x16 v_min(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_SSE4_1 + return v_int8x16(_mm_min_epi8(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi8((char)-128); + return v_int8x16(_mm_xor_si128(delta, _mm_min_epu8(_mm_xor_si128(a.val, delta), + _mm_xor_si128(b.val, delta)))); +#endif +} +inline v_int8x16 v_max(const v_int8x16& a, const v_int8x16& b) +{ +#if CV_SSE4_1 + return v_int8x16(_mm_max_epi8(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi8((char)-128); + return v_int8x16(_mm_xor_si128(delta, _mm_max_epu8(_mm_xor_si128(a.val, delta), + _mm_xor_si128(b.val, delta)))); +#endif +} +inline v_uint16x8 v_min(const v_uint16x8& a, const v_uint16x8& b) +{ +#if CV_SSE4_1 + return v_uint16x8(_mm_min_epu16(a.val, b.val)); +#else + return v_uint16x8(_mm_subs_epu16(a.val, _mm_subs_epu16(a.val, b.val))); +#endif +} +inline v_uint16x8 v_max(const v_uint16x8& a, const v_uint16x8& b) +{ +#if CV_SSE4_1 + return v_uint16x8(_mm_max_epu16(a.val, b.val)); +#else + return v_uint16x8(_mm_adds_epu16(_mm_subs_epu16(a.val, b.val), b.val)); +#endif +} +inline v_uint32x4 v_min(const v_uint32x4& a, const v_uint32x4& b) +{ +#if CV_SSE4_1 + return v_uint32x4(_mm_min_epu32(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi32((int)0x80000000); + __m128i mask = _mm_cmpgt_epi32(_mm_xor_si128(a.val, delta), _mm_xor_si128(b.val, delta)); + return v_uint32x4(v_select_si128(mask, b.val, a.val)); +#endif +} +inline v_uint32x4 v_max(const v_uint32x4& a, const v_uint32x4& b) +{ +#if CV_SSE4_1 + return v_uint32x4(_mm_max_epu32(a.val, b.val)); +#else + __m128i delta = _mm_set1_epi32((int)0x80000000); + __m128i mask = _mm_cmpgt_epi32(_mm_xor_si128(a.val, delta), _mm_xor_si128(b.val, delta)); + return v_uint32x4(v_select_si128(mask, a.val, b.val)); +#endif +} +inline v_int32x4 v_min(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_int32x4(_mm_min_epi32(a.val, b.val)); +#else + return v_int32x4(v_select_si128(_mm_cmpgt_epi32(a.val, b.val), b.val, a.val)); +#endif +} +inline v_int32x4 v_max(const v_int32x4& a, const v_int32x4& b) +{ +#if CV_SSE4_1 + return v_int32x4(_mm_max_epi32(a.val, b.val)); +#else + return v_int32x4(v_select_si128(_mm_cmpgt_epi32(a.val, b.val), a.val, b.val)); +#endif +} + +#define OPENCV_HAL_IMPL_SSE_INT_CMP_OP(_Tpuvec, _Tpsvec, suffix, sbit) \ +inline _Tpuvec operator == (const _Tpuvec& a, const _Tpuvec& b) \ +{ return _Tpuvec(_mm_cmpeq_##suffix(a.val, b.val)); } \ +inline _Tpuvec operator != (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpuvec(_mm_xor_si128(_mm_cmpeq_##suffix(a.val, b.val), not_mask)); \ +} \ +inline _Tpsvec operator == (const _Tpsvec& a, const _Tpsvec& b) \ +{ return _Tpsvec(_mm_cmpeq_##suffix(a.val, b.val)); } \ +inline _Tpsvec operator != (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpsvec(_mm_xor_si128(_mm_cmpeq_##suffix(a.val, b.val), not_mask)); \ +} \ +inline _Tpuvec operator < (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + return _Tpuvec(_mm_cmpgt_##suffix(_mm_xor_si128(b.val, smask), _mm_xor_si128(a.val, smask))); \ +} \ +inline _Tpuvec operator > (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + return _Tpuvec(_mm_cmpgt_##suffix(_mm_xor_si128(a.val, smask), _mm_xor_si128(b.val, smask))); \ +} \ +inline _Tpuvec operator <= (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + __m128i not_mask = _mm_set1_epi32(-1); \ + __m128i res = _mm_cmpgt_##suffix(_mm_xor_si128(a.val, smask), _mm_xor_si128(b.val, smask)); \ + return _Tpuvec(_mm_xor_si128(res, not_mask)); \ +} \ +inline _Tpuvec operator >= (const _Tpuvec& a, const _Tpuvec& b) \ +{ \ + __m128i smask = _mm_set1_##suffix(sbit); \ + __m128i not_mask = _mm_set1_epi32(-1); \ + __m128i res = _mm_cmpgt_##suffix(_mm_xor_si128(b.val, smask), _mm_xor_si128(a.val, smask)); \ + return _Tpuvec(_mm_xor_si128(res, not_mask)); \ +} \ +inline _Tpsvec operator < (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + return _Tpsvec(_mm_cmpgt_##suffix(b.val, a.val)); \ +} \ +inline _Tpsvec operator > (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + return _Tpsvec(_mm_cmpgt_##suffix(a.val, b.val)); \ +} \ +inline _Tpsvec operator <= (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpsvec(_mm_xor_si128(_mm_cmpgt_##suffix(a.val, b.val), not_mask)); \ +} \ +inline _Tpsvec operator >= (const _Tpsvec& a, const _Tpsvec& b) \ +{ \ + __m128i not_mask = _mm_set1_epi32(-1); \ + return _Tpsvec(_mm_xor_si128(_mm_cmpgt_##suffix(b.val, a.val), not_mask)); \ +} + +OPENCV_HAL_IMPL_SSE_INT_CMP_OP(v_uint8x16, v_int8x16, epi8, (char)-128) +OPENCV_HAL_IMPL_SSE_INT_CMP_OP(v_uint16x8, v_int16x8, epi16, (short)-32768) +OPENCV_HAL_IMPL_SSE_INT_CMP_OP(v_uint32x4, v_int32x4, epi32, (int)0x80000000) + +#define OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(_Tpvec, suffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpeq_##suffix(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpneq_##suffix(a.val, b.val)); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmplt_##suffix(a.val, b.val)); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpgt_##suffix(a.val, b.val)); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmple_##suffix(a.val, b.val)); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpge_##suffix(a.val, b.val)); } + +OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float32x4, ps) +OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float64x2, pd) + +#if CV_SSE4_1 +#define OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(_Tpvec) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(_mm_cmpeq_epi64(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return ~(a == b); } +#else +#define OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(_Tpvec) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ __m128i cmp = _mm_cmpeq_epi32(a.val, b.val); \ + return _Tpvec(_mm_and_si128(cmp, _mm_shuffle_epi32(cmp, _MM_SHUFFLE(2, 3, 0, 1)))); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return ~(a == b); } +#endif + +OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_uint64x2) +OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_int64x2) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(_mm_cmpord_ps(a.val, a.val)); } +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(_mm_cmpord_pd(a.val, a.val)); } + +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_add_wrap, _mm_add_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_add_wrap, _mm_add_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_add_wrap, _mm_add_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_add_wrap, _mm_add_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_sub_wrap, _mm_sub_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_sub_wrap, _mm_sub_epi8) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_sub_wrap, _mm_sub_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_sub_wrap, _mm_sub_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_mul_wrap, _mm_mullo_epi16) +OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int16x8, v_mul_wrap, _mm_mullo_epi16) + +inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i ad = _mm_srai_epi16(a.val, 8); + __m128i bd = _mm_srai_epi16(b.val, 8); + __m128i p0 = _mm_mullo_epi16(a.val, b.val); // even + __m128i p1 = _mm_slli_epi16(_mm_mullo_epi16(ad, bd), 8); // odd + const __m128i b01 = _mm_set1_epi32(0xFF00FF00); + return v_uint8x16(_v128_blendv_epi8(p0, p1, b01)); +} +inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b) +{ + return v_reinterpret_as_s8(v_mul_wrap(v_reinterpret_as_u8(a), v_reinterpret_as_u8(b))); +} + +/** Absolute difference **/ + +inline v_uint8x16 v_absdiff(const v_uint8x16& a, const v_uint8x16& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x8 v_absdiff(const v_uint16x8& a, const v_uint16x8& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x4 v_absdiff(const v_uint32x4& a, const v_uint32x4& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x16 v_absdiff(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = v_sub_wrap(a, b); + v_int8x16 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} +inline v_uint16x8 v_absdiff(const v_int16x8& a, const v_int16x8& b) +{ + return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); +} +inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b) +{ + v_int32x4 d = a - b; + v_int32x4 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = a - b; + v_int8x16 m = a < b; + return (d ^ m) - m; + } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_max(a, b) - v_min(a, b); } + + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return a * b + c; +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ +#if CV_FMA3 + return v_float32x4(_mm_fmadd_ps(a.val, b.val, c.val)); +#else + return v_float32x4(_mm_add_ps(_mm_mul_ps(a.val, b.val), c.val)); +#endif +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ +#if CV_FMA3 + return v_float64x2(_mm_fmadd_pd(a.val, b.val, c.val)); +#else + return v_float64x2(_mm_add_pd(_mm_mul_pd(a.val, b.val), c.val)); +#endif +} + +#define OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(_Tpvec, _Tp, _Tpreg, suffix, absmask_vec) \ +inline _Tpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpreg absmask = _mm_castsi128_##suffix(absmask_vec); \ + return _Tpvec(_mm_and_##suffix(_mm_sub_##suffix(a.val, b.val), absmask)); \ +} \ +inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpvec res = v_fma(a, a, b*b); \ + return _Tpvec(_mm_sqrt_##suffix(res.val)); \ +} \ +inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return v_fma(a, a, b*b); \ +} \ +inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ \ + return v_fma(a, b, c); \ +} + +OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(v_float32x4, float, __m128, ps, _mm_set1_epi32((int)0x7fffffff)) +OPENCV_HAL_IMPL_SSE_MISC_FLT_OP(v_float64x2, double, __m128d, pd, _mm_srli_epi64(_mm_set1_epi32(-1), 1)) + +#define OPENCV_HAL_IMPL_SSE_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, srai) \ +inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(_mm_srli_##suffix(a.val, imm)); \ +} \ +inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(srai(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shl(const _Tpuvec& a) \ +{ \ + return _Tpuvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shl(const _Tpsvec& a) \ +{ \ + return _Tpsvec(_mm_slli_##suffix(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shr(const _Tpuvec& a) \ +{ \ + return _Tpuvec(_mm_srli_##suffix(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shr(const _Tpsvec& a) \ +{ \ + return _Tpsvec(srai(a.val, imm)); \ +} + +OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint16x8, v_int16x8, epi16, _mm_srai_epi16) +OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint32x4, v_int32x4, epi32, _mm_srai_epi32) +OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64) + +namespace hal_sse_internal +{ + template 16)), + bool is_first = (imm == 0), + bool is_half = (imm == 8), + bool is_second = (imm == 16), + bool is_other = (((imm > 0) && (imm < 8)) || ((imm > 8) && (imm < 16)))> + class v_sse_palignr_u8_class; + + template + class v_sse_palignr_u8_class; + + template + class v_sse_palignr_u8_class + { + public: + inline __m128i operator()(const __m128i& a, const __m128i&) const + { + return a; + } + }; + + template + class v_sse_palignr_u8_class + { + public: + inline __m128i operator()(const __m128i& a, const __m128i& b) const + { + return _mm_unpacklo_epi64(_mm_unpackhi_epi64(a, a), b); + } + }; + + template + class v_sse_palignr_u8_class + { + public: + inline __m128i operator()(const __m128i&, const __m128i& b) const + { + return b; + } + }; + + template + class v_sse_palignr_u8_class + { +#if CV_SSSE3 + public: + inline __m128i operator()(const __m128i& a, const __m128i& b) const + { + return _mm_alignr_epi8(b, a, imm); + } +#else + public: + inline __m128i operator()(const __m128i& a, const __m128i& b) const + { + enum { imm2 = (sizeof(__m128i) - imm) }; + return _mm_or_si128(_mm_srli_si128(a, imm), _mm_slli_si128(b, imm2)); + } +#endif + }; + + template + inline __m128i v_sse_palignr_u8(const __m128i& a, const __m128i& b) + { + CV_StaticAssert((imm >= 0) && (imm <= 16), "Invalid imm for v_sse_palignr_u8."); + return v_sse_palignr_u8_class()(a, b); + } +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a) +{ + using namespace hal_sse_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + _mm_srli_si128( + v_sse_reinterpret_as<__m128i>(a.val), imm2))); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a) +{ + using namespace hal_sse_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + _mm_slli_si128( + v_sse_reinterpret_as<__m128i>(a.val), imm2))); +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_sse_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + v_sse_palignr_u8( + v_sse_reinterpret_as<__m128i>(a.val), + v_sse_reinterpret_as<__m128i>(b.val)))); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_sse_internal; + enum { imm2 = ((_Tpvec::nlanes - imm) * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_sse_reinterpret_as( + v_sse_palignr_u8( + v_sse_reinterpret_as<__m128i>(b.val), + v_sse_reinterpret_as<__m128i>(a.val)))); +} + +#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(_Tpvec, _Tp) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(_mm_loadu_si128((const __m128i*)ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(_mm_load_si128((const __m128i*)ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(_mm_loadl_epi64((const __m128i*)ptr)); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + return _Tpvec(_mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i*)ptr0), \ + _mm_loadl_epi64((const __m128i*)ptr1))); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storeu_si128((__m128i*)ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ _mm_store_si128((__m128i*)ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ _mm_stream_si128((__m128i*)ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ +{ \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm_storeu_si128((__m128i*)ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm_stream_si128((__m128i*)ptr, a.val); \ + else \ + _mm_store_si128((__m128i*)ptr, a.val); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storel_epi64((__m128i*)ptr, a.val); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storel_epi64((__m128i*)ptr, _mm_unpackhi_epi64(a.val, a.val)); } + +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint8x16, uchar) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int8x16, schar) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint16x8, ushort) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int16x8, short) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint32x4, unsigned) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int32x4, int) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_uint64x2, uint64) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(v_int64x2, int64) + +#define OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(_Tpvec, _Tp, suffix) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(_mm_loadu_##suffix(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(_mm_load_##suffix(ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(_mm_castsi128_##suffix(_mm_loadl_epi64((const __m128i*)ptr))); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + return _Tpvec(_mm_castsi128_##suffix( \ + _mm_unpacklo_epi64(_mm_loadl_epi64((const __m128i*)ptr0), \ + _mm_loadl_epi64((const __m128i*)ptr1)))); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storeu_##suffix(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ _mm_store_##suffix(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ _mm_stream_##suffix(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ +{ \ + if( mode == hal::STORE_UNALIGNED ) \ + _mm_storeu_##suffix(ptr, a.val); \ + else if( mode == hal::STORE_ALIGNED_NOCACHE ) \ + _mm_stream_##suffix(ptr, a.val); \ + else \ + _mm_store_##suffix(ptr, a.val); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ _mm_storel_epi64((__m128i*)ptr, _mm_cast##suffix##_si128(a.val)); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + __m128i a1 = _mm_cast##suffix##_si128(a.val); \ + _mm_storel_epi64((__m128i*)ptr, _mm_unpackhi_epi64(a1, a1)); \ +} + +OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps) +OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd) + +inline unsigned v_reduce_sum(const v_uint8x16& a) +{ + __m128i half = _mm_sad_epu8(a.val, _mm_setzero_si128()); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))); +} +inline int v_reduce_sum(const v_int8x16& a) +{ + __m128i half = _mm_set1_epi8((schar)-128); + half = _mm_sad_epu8(_mm_xor_si128(a.val, half), _mm_setzero_si128()); + return _mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))) - 2048; +} +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_16(func) \ +inline schar v_reduce_##func(const v_int8x16& a) \ +{ \ + __m128i val = a.val; \ + __m128i smask = _mm_set1_epi8((schar)-128); \ + val = _mm_xor_si128(val, smask); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,2)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,1)); \ + return (schar)_mm_cvtsi128_si32(val) ^ (schar)-128; \ +} \ +inline uchar v_reduce_##func(const v_uint8x16& a) \ +{ \ + __m128i val = a.val; \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,2)); \ + val = _mm_##func##_epu8(val, _mm_srli_si128(val,1)); \ + return (uchar)_mm_cvtsi128_si32(val); \ +} +OPENCV_HAL_IMPL_SSE_REDUCE_OP_16(max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_16(min) + +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(_Tpvec, scalartype, func, suffix, sbit) \ +inline scalartype v_reduce_##func(const v_##_Tpvec& a) \ +{ \ + __m128i val = a.val; \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,2)); \ + return (scalartype)_mm_cvtsi128_si32(val); \ +} \ +inline unsigned scalartype v_reduce_##func(const v_u##_Tpvec& a) \ +{ \ + __m128i val = a.val; \ + __m128i smask = _mm_set1_epi16(sbit); \ + val = _mm_xor_si128(val, smask); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,8)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,4)); \ + val = _mm_##func##_##suffix(val, _mm_srli_si128(val,2)); \ + return (unsigned scalartype)(_mm_cvtsi128_si32(val) ^ sbit); \ +} +OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, max, epi16, (short)-32768) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, min, epi16, (short)-32768) + +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(_Tpvec, scalartype, regtype, suffix, cast_from, cast_to, extract) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + regtype val = a.val; \ + val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 8))); \ + val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 4))); \ + return (scalartype)_mm_cvt##extract(val); \ +} + +#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(_Tpvec, scalartype, func, scalar_func) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + scalartype CV_DECL_ALIGNED(16) buf[4]; \ + v_store_aligned(buf, a); \ + scalartype s0 = scalar_func(buf[0], buf[1]); \ + scalartype s1 = scalar_func(buf[2], buf[3]); \ + return scalar_func(s0, s1); \ +} + +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_uint32x4, unsigned, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_int32x4, int, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_float32x4, float, __m128, ps, _mm_castps_si128, _mm_castsi128_ps, ss_f32) + +inline int v_reduce_sum(const v_int16x8& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } +inline unsigned v_reduce_sum(const v_uint16x8& a) +{ return v_reduce_sum(v_expand_low(a) + v_expand_high(a)); } + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ + uint64 CV_DECL_ALIGNED(32) idx[2]; + v_store_aligned(idx, a); + return idx[0] + idx[1]; +} +inline int64 v_reduce_sum(const v_int64x2& a) +{ + int64 CV_DECL_ALIGNED(32) idx[2]; + v_store_aligned(idx, a); + return idx[0] + idx[1]; +} +inline double v_reduce_sum(const v_float64x2& a) +{ + double CV_DECL_ALIGNED(32) idx[2]; + v_store_aligned(idx, a); + return idx[0] + idx[1]; +} + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ +#if CV_SSE3 + __m128 ab = _mm_hadd_ps(a.val, b.val); + __m128 cd = _mm_hadd_ps(c.val, d.val); + return v_float32x4(_mm_hadd_ps(ab, cd)); +#else + __m128 ac = _mm_add_ps(_mm_unpacklo_ps(a.val, c.val), _mm_unpackhi_ps(a.val, c.val)); + __m128 bd = _mm_add_ps(_mm_unpacklo_ps(b.val, d.val), _mm_unpackhi_ps(b.val, d.val)); + return v_float32x4(_mm_add_ps(_mm_unpacklo_ps(ac, bd), _mm_unpackhi_ps(ac, bd))); +#endif +} + +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, max, std::max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, min, std::min) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, max, std::max) +OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, min, std::min) + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + __m128i half = _mm_sad_epu8(a.val, b.val); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + __m128i half = _mm_set1_epi8(0x7f); + half = _mm_sad_epu8(_mm_add_epi8(a.val, half), _mm_add_epi8(b.val, half)); + return (unsigned)_mm_cvtsi128_si32(_mm_add_epi32(half, _mm_unpackhi_epi64(half, half))); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} + +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ + __m128i m1 = _mm_set1_epi32(0x55555555); + __m128i m2 = _mm_set1_epi32(0x33333333); + __m128i m4 = _mm_set1_epi32(0x0f0f0f0f); + __m128i p = a.val; + p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 1), m1), _mm_and_si128(p, m1)); + p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 2), m2), _mm_and_si128(p, m2)); + p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 4), m4), _mm_and_si128(p, m4)); + return v_uint8x16(p); +} +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v_setall_u16(0x00ff); +} +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v_setall_u32(0x000000ff); +} +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ + return v_uint64x2(_mm_sad_epu8(v_popcount(v_reinterpret_as_u8(a)).val, _mm_setzero_si128())); +} +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_popcount(v_reinterpret_as_u8(a)); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_popcount(v_reinterpret_as_u16(a)); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_popcount(v_reinterpret_as_u32(a)); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_popcount(v_reinterpret_as_u64(a)); } + +#define OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(_Tpvec, suffix, cast_op, allmask) \ +inline int v_signmask(const _Tpvec& a) { return _mm_movemask_##suffix(cast_op(a.val)); } \ +inline bool v_check_all(const _Tpvec& a) { return _mm_movemask_##suffix(cast_op(a.val)) == allmask; } \ +inline bool v_check_any(const _Tpvec& a) { return _mm_movemask_##suffix(cast_op(a.val)) != 0; } +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_uint8x16, epi8, OPENCV_HAL_NOP, 65535) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int8x16, epi8, OPENCV_HAL_NOP, 65535) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_uint32x4, ps, _mm_castsi128_ps, 15) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int32x4, ps, _mm_castsi128_ps, 15) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_uint64x2, pd, _mm_castsi128_pd, 3) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int64x2, pd, _mm_castsi128_pd, 3) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_float32x4, ps, OPENCV_HAL_NOP, 15) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_float64x2, pd, OPENCV_HAL_NOP, 3) + +#define OPENCV_HAL_IMPL_SSE_CHECK_SIGNS_SHORT(_Tpvec) \ +inline int v_signmask(const _Tpvec& a) { return _mm_movemask_epi8(_mm_packs_epi16(a.val, a.val)) & 255; } \ +inline bool v_check_all(const _Tpvec& a) { return (_mm_movemask_epi8(a.val) & 0xaaaa) == 0xaaaa; } \ +inline bool v_check_any(const _Tpvec& a) { return (_mm_movemask_epi8(a.val) & 0xaaaa) != 0; } +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS_SHORT(v_uint16x8) +OPENCV_HAL_IMPL_SSE_CHECK_SIGNS_SHORT(v_int16x8) + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } + +#if CV_SSE4_1 +#define OPENCV_HAL_IMPL_SSE_SELECT(_Tpvec, cast_ret, cast, suffix) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(cast_ret(_mm_blendv_##suffix(cast(b.val), cast(a.val), cast(mask.val)))); \ +} + +OPENCV_HAL_IMPL_SSE_SELECT(v_uint8x16, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_int8x16, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint16x8, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_int16x8, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint32x4, _mm_castps_si128, _mm_castsi128_ps, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, _mm_castps_si128, _mm_castsi128_ps, ps) +// OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, TBD, TBD, pd) +// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, TBD, TBD, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, OPENCV_HAL_NOP, OPENCV_HAL_NOP, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, OPENCV_HAL_NOP, OPENCV_HAL_NOP, pd) + +#else // CV_SSE4_1 + +#define OPENCV_HAL_IMPL_SSE_SELECT(_Tpvec, suffix) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(_mm_xor_##suffix(b.val, _mm_and_##suffix(_mm_xor_##suffix(b.val, a.val), mask.val))); \ +} + +OPENCV_HAL_IMPL_SSE_SELECT(v_uint8x16, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_int8x16, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint16x8, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_int16x8, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_uint32x4, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, si128) +// OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, si128) +// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, si128) +OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, ps) +OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, pd) +#endif + +/* Expand */ +#define OPENCV_HAL_IMPL_SSE_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ + inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ + { \ + b0.val = intrin(a.val); \ + b1.val = __CV_CAT(intrin, _high)(a.val); \ + } \ + inline _Tpwvec v_expand_low(const _Tpvec& a) \ + { return _Tpwvec(intrin(a.val)); } \ + inline _Tpwvec v_expand_high(const _Tpvec& a) \ + { return _Tpwvec(__CV_CAT(intrin, _high)(a.val)); } \ + inline _Tpwvec v_load_expand(const _Tp* ptr) \ + { \ + __m128i a = _mm_loadl_epi64((const __m128i*)ptr); \ + return _Tpwvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_SSE_EXPAND(v_uint8x16, v_uint16x8, uchar, _v128_cvtepu8_epi16) +OPENCV_HAL_IMPL_SSE_EXPAND(v_int8x16, v_int16x8, schar, _v128_cvtepi8_epi16) +OPENCV_HAL_IMPL_SSE_EXPAND(v_uint16x8, v_uint32x4, ushort, _v128_cvtepu16_epi32) +OPENCV_HAL_IMPL_SSE_EXPAND(v_int16x8, v_int32x4, short, _v128_cvtepi16_epi32) +OPENCV_HAL_IMPL_SSE_EXPAND(v_uint32x4, v_uint64x2, unsigned, _v128_cvtepu32_epi64) +OPENCV_HAL_IMPL_SSE_EXPAND(v_int32x4, v_int64x2, int, _v128_cvtepi32_epi64) + +#define OPENCV_HAL_IMPL_SSE_EXPAND_Q(_Tpvec, _Tp, intrin) \ + inline _Tpvec v_load_expand_q(const _Tp* ptr) \ + { \ + __m128i a = _mm_cvtsi32_si128(*(const int*)ptr); \ + return _Tpvec(intrin(a)); \ + } + +OPENCV_HAL_IMPL_SSE_EXPAND_Q(v_uint32x4, uchar, _v128_cvtepu8_epi32) +OPENCV_HAL_IMPL_SSE_EXPAND_Q(v_int32x4, schar, _v128_cvtepi8_epi32) + +#define OPENCV_HAL_IMPL_SSE_UNPACKS(_Tpvec, suffix, cast_from, cast_to) \ +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) \ +{ \ + b0.val = _mm_unpacklo_##suffix(a0.val, a1.val); \ + b1.val = _mm_unpackhi_##suffix(a0.val, a1.val); \ +} \ +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ +{ \ + __m128i a1 = cast_from(a.val), b1 = cast_from(b.val); \ + return _Tpvec(cast_to(_mm_unpacklo_epi64(a1, b1))); \ +} \ +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ +{ \ + __m128i a1 = cast_from(a.val), b1 = cast_from(b.val); \ + return _Tpvec(cast_to(_mm_unpackhi_epi64(a1, b1))); \ +} \ +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) \ +{ \ + __m128i a1 = cast_from(a.val), b1 = cast_from(b.val); \ + c.val = cast_to(_mm_unpacklo_epi64(a1, b1)); \ + d.val = cast_to(_mm_unpackhi_epi64(a1, b1)); \ +} + +OPENCV_HAL_IMPL_SSE_UNPACKS(v_uint8x16, epi8, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_int8x16, epi8, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_uint16x8, epi16, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_int16x8, epi16, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_uint32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_int32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_float32x4, ps, _mm_castps_si128, _mm_castsi128_ps) +OPENCV_HAL_IMPL_SSE_UNPACKS(v_float64x2, pd, _mm_castpd_si128, _mm_castsi128_pd) + +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ +#if CV_SSSE3 + static const __m128i perm = _mm_setr_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); + return v_uint8x16(_mm_shuffle_epi8(a.val, perm)); +#else + uchar CV_DECL_ALIGNED(32) d[16]; + v_store_aligned(d, a); + return v_uint8x16(d[15], d[14], d[13], d[12], d[11], d[10], d[9], d[8], d[7], d[6], d[5], d[4], d[3], d[2], d[1], d[0]); +#endif +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ +#if CV_SSSE3 + static const __m128i perm = _mm_setr_epi8(14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1); + return v_uint16x8(_mm_shuffle_epi8(a.val, perm)); +#else + __m128i r = _mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 1, 2, 3)); + r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(2, 3, 0, 1)); + r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(2, 3, 0, 1)); + return v_uint16x8(r); +#endif +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + return v_uint32x4(_mm_shuffle_epi32(a.val, _MM_SHUFFLE(0, 1, 2, 3))); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + return v_uint64x2(_mm_shuffle_epi32(a.val, _MM_SHUFFLE(1, 0, 3, 2))); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +template +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) +{ + return v_rotate_right(a, b); +} + +inline v_int32x4 v_round(const v_float32x4& a) +{ return v_int32x4(_mm_cvtps_epi32(a.val)); } + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + __m128i a1 = _mm_cvtps_epi32(a.val); + __m128i mask = _mm_castps_si128(_mm_cmpgt_ps(_mm_cvtepi32_ps(a1), a.val)); + return v_int32x4(_mm_add_epi32(a1, mask)); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + __m128i a1 = _mm_cvtps_epi32(a.val); + __m128i mask = _mm_castps_si128(_mm_cmpgt_ps(a.val, _mm_cvtepi32_ps(a1))); + return v_int32x4(_mm_sub_epi32(a1, mask)); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(_mm_cvttps_epi32(a.val)); } + +inline v_int32x4 v_round(const v_float64x2& a) +{ return v_int32x4(_mm_cvtpd_epi32(a.val)); } + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + __m128i ai = _mm_cvtpd_epi32(a.val), bi = _mm_cvtpd_epi32(b.val); + return v_int32x4(_mm_unpacklo_epi64(ai, bi)); +} + +inline v_int32x4 v_floor(const v_float64x2& a) +{ + __m128i a1 = _mm_cvtpd_epi32(a.val); + __m128i mask = _mm_castpd_si128(_mm_cmpgt_pd(_mm_cvtepi32_pd(a1), a.val)); + mask = _mm_srli_si128(_mm_slli_si128(mask, 4), 8); // m0 m0 m1 m1 => m0 m1 0 0 + return v_int32x4(_mm_add_epi32(a1, mask)); +} + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ + __m128i a1 = _mm_cvtpd_epi32(a.val); + __m128i mask = _mm_castpd_si128(_mm_cmpgt_pd(a.val, _mm_cvtepi32_pd(a1))); + mask = _mm_srli_si128(_mm_slli_si128(mask, 4), 8); // m0 m0 m1 m1 => m0 m1 0 0 + return v_int32x4(_mm_sub_epi32(a1, mask)); +} + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ return v_int32x4(_mm_cvttpd_epi32(a.val)); } + +#define OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(_Tpvec, suffix, cast_from, cast_to) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, \ + _Tpvec& b2, _Tpvec& b3) \ +{ \ + __m128i t0 = cast_from(_mm_unpacklo_##suffix(a0.val, a1.val)); \ + __m128i t1 = cast_from(_mm_unpacklo_##suffix(a2.val, a3.val)); \ + __m128i t2 = cast_from(_mm_unpackhi_##suffix(a0.val, a1.val)); \ + __m128i t3 = cast_from(_mm_unpackhi_##suffix(a2.val, a3.val)); \ +\ + b0.val = cast_to(_mm_unpacklo_epi64(t0, t1)); \ + b1.val = cast_to(_mm_unpackhi_epi64(t0, t1)); \ + b2.val = cast_to(_mm_unpacklo_epi64(t2, t3)); \ + b3.val = cast_to(_mm_unpackhi_epi64(t2, t3)); \ +} + +OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_uint32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_int32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP) +OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_float32x4, ps, _mm_castps_si128, _mm_castsi128_ps) + +// load deinterleave +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b) +{ + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + + __m128i t10 = _mm_unpacklo_epi8(t00, t01); + __m128i t11 = _mm_unpackhi_epi8(t00, t01); + + __m128i t20 = _mm_unpacklo_epi8(t10, t11); + __m128i t21 = _mm_unpackhi_epi8(t10, t11); + + __m128i t30 = _mm_unpacklo_epi8(t20, t21); + __m128i t31 = _mm_unpackhi_epi8(t20, t21); + + a.val = _mm_unpacklo_epi8(t30, t31); + b.val = _mm_unpackhi_epi8(t30, t31); +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c) +{ +#if CV_SSE4_1 + const __m128i m0 = _mm_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); + const __m128i m1 = _mm_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + __m128i s0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i s1 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + __m128i s2 = _mm_loadu_si128((const __m128i*)(ptr + 32)); + __m128i a0 = _mm_blendv_epi8(_mm_blendv_epi8(s0, s1, m0), s2, m1); + __m128i b0 = _mm_blendv_epi8(_mm_blendv_epi8(s1, s2, m0), s0, m1); + __m128i c0 = _mm_blendv_epi8(_mm_blendv_epi8(s2, s0, m0), s1, m1); + const __m128i sh_b = _mm_setr_epi8(0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13); + const __m128i sh_g = _mm_setr_epi8(1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14); + const __m128i sh_r = _mm_setr_epi8(2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15); + a0 = _mm_shuffle_epi8(a0, sh_b); + b0 = _mm_shuffle_epi8(b0, sh_g); + c0 = _mm_shuffle_epi8(c0, sh_r); + a.val = a0; + b.val = b0; + c.val = c0; +#elif CV_SSSE3 + const __m128i m0 = _mm_setr_epi8(0, 3, 6, 9, 12, 15, 1, 4, 7, 10, 13, 2, 5, 8, 11, 14); + const __m128i m1 = _mm_alignr_epi8(m0, m0, 11); + const __m128i m2 = _mm_alignr_epi8(m0, m0, 6); + + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 32)); + + __m128i s0 = _mm_shuffle_epi8(t0, m0); + __m128i s1 = _mm_shuffle_epi8(t1, m1); + __m128i s2 = _mm_shuffle_epi8(t2, m2); + + t0 = _mm_alignr_epi8(s1, _mm_slli_si128(s0, 10), 5); + a.val = _mm_alignr_epi8(s2, t0, 5); + + t1 = _mm_alignr_epi8(_mm_srli_si128(s1, 5), _mm_slli_si128(s0, 5), 6); + b.val = _mm_alignr_epi8(_mm_srli_si128(s2, 5), t1, 5); + + t2 = _mm_alignr_epi8(_mm_srli_si128(s2, 10), s1, 11); + c.val = _mm_alignr_epi8(t2, s0, 11); +#else + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + __m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 32)); + + __m128i t10 = _mm_unpacklo_epi8(t00, _mm_unpackhi_epi64(t01, t01)); + __m128i t11 = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t00, t00), t02); + __m128i t12 = _mm_unpacklo_epi8(t01, _mm_unpackhi_epi64(t02, t02)); + + __m128i t20 = _mm_unpacklo_epi8(t10, _mm_unpackhi_epi64(t11, t11)); + __m128i t21 = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t10, t10), t12); + __m128i t22 = _mm_unpacklo_epi8(t11, _mm_unpackhi_epi64(t12, t12)); + + __m128i t30 = _mm_unpacklo_epi8(t20, _mm_unpackhi_epi64(t21, t21)); + __m128i t31 = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t20, t20), t22); + __m128i t32 = _mm_unpacklo_epi8(t21, _mm_unpackhi_epi64(t22, t22)); + + a.val = _mm_unpacklo_epi8(t30, _mm_unpackhi_epi64(t31, t31)); + b.val = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t30, t30), t32); + c.val = _mm_unpacklo_epi8(t31, _mm_unpackhi_epi64(t32, t32)); +#endif +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c, v_uint8x16& d) +{ + __m128i u0 = _mm_loadu_si128((const __m128i*)ptr); // a0 b0 c0 d0 a1 b1 c1 d1 ... + __m128i u1 = _mm_loadu_si128((const __m128i*)(ptr + 16)); // a4 b4 c4 d4 ... + __m128i u2 = _mm_loadu_si128((const __m128i*)(ptr + 32)); // a8 b8 c8 d8 ... + __m128i u3 = _mm_loadu_si128((const __m128i*)(ptr + 48)); // a12 b12 c12 d12 ... + + __m128i v0 = _mm_unpacklo_epi8(u0, u2); // a0 a8 b0 b8 ... + __m128i v1 = _mm_unpackhi_epi8(u0, u2); // a2 a10 b2 b10 ... + __m128i v2 = _mm_unpacklo_epi8(u1, u3); // a4 a12 b4 b12 ... + __m128i v3 = _mm_unpackhi_epi8(u1, u3); // a6 a14 b6 b14 ... + + u0 = _mm_unpacklo_epi8(v0, v2); // a0 a4 a8 a12 ... + u1 = _mm_unpacklo_epi8(v1, v3); // a2 a6 a10 a14 ... + u2 = _mm_unpackhi_epi8(v0, v2); // a1 a5 a9 a13 ... + u3 = _mm_unpackhi_epi8(v1, v3); // a3 a7 a11 a15 ... + + v0 = _mm_unpacklo_epi8(u0, u1); // a0 a2 a4 a6 ... + v1 = _mm_unpacklo_epi8(u2, u3); // a1 a3 a5 a7 ... + v2 = _mm_unpackhi_epi8(u0, u1); // c0 c2 c4 c6 ... + v3 = _mm_unpackhi_epi8(u2, u3); // c1 c3 c5 c7 ... + + a.val = _mm_unpacklo_epi8(v0, v1); + b.val = _mm_unpackhi_epi8(v0, v1); + c.val = _mm_unpacklo_epi8(v2, v3); + d.val = _mm_unpackhi_epi8(v2, v3); +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b) +{ + __m128i v0 = _mm_loadu_si128((__m128i*)(ptr)); // a0 b0 a1 b1 a2 b2 a3 b3 + __m128i v1 = _mm_loadu_si128((__m128i*)(ptr + 8)); // a4 b4 a5 b5 a6 b6 a7 b7 + + __m128i v2 = _mm_unpacklo_epi16(v0, v1); // a0 a4 b0 b4 a1 a5 b1 b5 + __m128i v3 = _mm_unpackhi_epi16(v0, v1); // a2 a6 b2 b6 a3 a7 b3 b7 + __m128i v4 = _mm_unpacklo_epi16(v2, v3); // a0 a2 a4 a6 b0 b2 b4 b6 + __m128i v5 = _mm_unpackhi_epi16(v2, v3); // a1 a3 a5 a7 b1 b3 b5 b7 + + a.val = _mm_unpacklo_epi16(v4, v5); // a0 a1 a2 a3 a4 a5 a6 a7 + b.val = _mm_unpackhi_epi16(v4, v5); // b0 b1 ab b3 b4 b5 b6 b7 +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c) +{ +#if CV_SSE4_1 + __m128i v0 = _mm_loadu_si128((__m128i*)(ptr)); + __m128i v1 = _mm_loadu_si128((__m128i*)(ptr + 8)); + __m128i v2 = _mm_loadu_si128((__m128i*)(ptr + 16)); + __m128i a0 = _mm_blend_epi16(_mm_blend_epi16(v0, v1, 0x92), v2, 0x24); + __m128i b0 = _mm_blend_epi16(_mm_blend_epi16(v2, v0, 0x92), v1, 0x24); + __m128i c0 = _mm_blend_epi16(_mm_blend_epi16(v1, v2, 0x92), v0, 0x24); + + const __m128i sh_a = _mm_setr_epi8(0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m128i sh_b = _mm_setr_epi8(2, 3, 8, 9, 14, 15, 4, 5, 10, 11, 0, 1, 6, 7, 12, 13); + const __m128i sh_c = _mm_setr_epi8(4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + a0 = _mm_shuffle_epi8(a0, sh_a); + b0 = _mm_shuffle_epi8(b0, sh_b); + c0 = _mm_shuffle_epi8(c0, sh_c); + + a.val = a0; + b.val = b0; + c.val = c0; +#else + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 8)); + __m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 16)); + + __m128i t10 = _mm_unpacklo_epi16(t00, _mm_unpackhi_epi64(t01, t01)); + __m128i t11 = _mm_unpacklo_epi16(_mm_unpackhi_epi64(t00, t00), t02); + __m128i t12 = _mm_unpacklo_epi16(t01, _mm_unpackhi_epi64(t02, t02)); + + __m128i t20 = _mm_unpacklo_epi16(t10, _mm_unpackhi_epi64(t11, t11)); + __m128i t21 = _mm_unpacklo_epi16(_mm_unpackhi_epi64(t10, t10), t12); + __m128i t22 = _mm_unpacklo_epi16(t11, _mm_unpackhi_epi64(t12, t12)); + + a.val = _mm_unpacklo_epi16(t20, _mm_unpackhi_epi64(t21, t21)); + b.val = _mm_unpacklo_epi16(_mm_unpackhi_epi64(t20, t20), t22); + c.val = _mm_unpacklo_epi16(t21, _mm_unpackhi_epi64(t22, t22)); +#endif +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c, v_uint16x8& d) +{ + __m128i u0 = _mm_loadu_si128((const __m128i*)ptr); // a0 b0 c0 d0 a1 b1 c1 d1 + __m128i u1 = _mm_loadu_si128((const __m128i*)(ptr + 8)); // a2 b2 c2 d2 ... + __m128i u2 = _mm_loadu_si128((const __m128i*)(ptr + 16)); // a4 b4 c4 d4 ... + __m128i u3 = _mm_loadu_si128((const __m128i*)(ptr + 24)); // a6 b6 c6 d6 ... + + __m128i v0 = _mm_unpacklo_epi16(u0, u2); // a0 a4 b0 b4 ... + __m128i v1 = _mm_unpackhi_epi16(u0, u2); // a1 a5 b1 b5 ... + __m128i v2 = _mm_unpacklo_epi16(u1, u3); // a2 a6 b2 b6 ... + __m128i v3 = _mm_unpackhi_epi16(u1, u3); // a3 a7 b3 b7 ... + + u0 = _mm_unpacklo_epi16(v0, v2); // a0 a2 a4 a6 ... + u1 = _mm_unpacklo_epi16(v1, v3); // a1 a3 a5 a7 ... + u2 = _mm_unpackhi_epi16(v0, v2); // c0 c2 c4 c6 ... + u3 = _mm_unpackhi_epi16(v1, v3); // c1 c3 c5 c7 ... + + a.val = _mm_unpacklo_epi16(u0, u1); + b.val = _mm_unpackhi_epi16(u0, u1); + c.val = _mm_unpacklo_epi16(u2, u3); + d.val = _mm_unpackhi_epi16(u2, u3); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b) +{ + __m128i v0 = _mm_loadu_si128((__m128i*)(ptr)); // a0 b0 a1 b1 + __m128i v1 = _mm_loadu_si128((__m128i*)(ptr + 4)); // a2 b2 a3 b3 + + __m128i v2 = _mm_unpacklo_epi32(v0, v1); // a0 a2 b0 b2 + __m128i v3 = _mm_unpackhi_epi32(v0, v1); // a1 a3 b1 b3 + + a.val = _mm_unpacklo_epi32(v2, v3); // a0 a1 a2 a3 + b.val = _mm_unpackhi_epi32(v2, v3); // b0 b1 ab b3 +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c) +{ + __m128i t00 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 4)); + __m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 8)); + + __m128i t10 = _mm_unpacklo_epi32(t00, _mm_unpackhi_epi64(t01, t01)); + __m128i t11 = _mm_unpacklo_epi32(_mm_unpackhi_epi64(t00, t00), t02); + __m128i t12 = _mm_unpacklo_epi32(t01, _mm_unpackhi_epi64(t02, t02)); + + a.val = _mm_unpacklo_epi32(t10, _mm_unpackhi_epi64(t11, t11)); + b.val = _mm_unpacklo_epi32(_mm_unpackhi_epi64(t10, t10), t12); + c.val = _mm_unpacklo_epi32(t11, _mm_unpackhi_epi64(t12, t12)); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c, v_uint32x4& d) +{ + v_uint32x4 s0(_mm_loadu_si128((const __m128i*)ptr)); // a0 b0 c0 d0 + v_uint32x4 s1(_mm_loadu_si128((const __m128i*)(ptr + 4))); // a1 b1 c1 d1 + v_uint32x4 s2(_mm_loadu_si128((const __m128i*)(ptr + 8))); // a2 b2 c2 d2 + v_uint32x4 s3(_mm_loadu_si128((const __m128i*)(ptr + 12))); // a3 b3 c3 d3 + + v_transpose4x4(s0, s1, s2, s3, a, b, c, d); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b) +{ + __m128 u0 = _mm_loadu_ps(ptr); // a0 b0 a1 b1 + __m128 u1 = _mm_loadu_ps((ptr + 4)); // a2 b2 a3 b3 + + a.val = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(2, 0, 2, 0)); // a0 a1 a2 a3 + b.val = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(3, 1, 3, 1)); // b0 b1 ab b3 +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c) +{ + __m128 t0 = _mm_loadu_ps(ptr + 0); + __m128 t1 = _mm_loadu_ps(ptr + 4); + __m128 t2 = _mm_loadu_ps(ptr + 8); + + __m128 at12 = _mm_shuffle_ps(t1, t2, _MM_SHUFFLE(0, 1, 0, 2)); + a.val = _mm_shuffle_ps(t0, at12, _MM_SHUFFLE(2, 0, 3, 0)); + + __m128 bt01 = _mm_shuffle_ps(t0, t1, _MM_SHUFFLE(0, 0, 0, 1)); + __m128 bt12 = _mm_shuffle_ps(t1, t2, _MM_SHUFFLE(0, 2, 0, 3)); + b.val = _mm_shuffle_ps(bt01, bt12, _MM_SHUFFLE(2, 0, 2, 0)); + + __m128 ct01 = _mm_shuffle_ps(t0, t1, _MM_SHUFFLE(0, 1, 0, 2)); + c.val = _mm_shuffle_ps(ct01, t2, _MM_SHUFFLE(3, 0, 2, 0)); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c, v_float32x4& d) +{ + __m128 t0 = _mm_loadu_ps(ptr + 0); + __m128 t1 = _mm_loadu_ps(ptr + 4); + __m128 t2 = _mm_loadu_ps(ptr + 8); + __m128 t3 = _mm_loadu_ps(ptr + 12); + __m128 t02lo = _mm_unpacklo_ps(t0, t2); + __m128 t13lo = _mm_unpacklo_ps(t1, t3); + __m128 t02hi = _mm_unpackhi_ps(t0, t2); + __m128 t13hi = _mm_unpackhi_ps(t1, t3); + a.val = _mm_unpacklo_ps(t02lo, t13lo); + b.val = _mm_unpackhi_ps(t02lo, t13lo); + c.val = _mm_unpacklo_ps(t02hi, t13hi); + d.val = _mm_unpackhi_ps(t02hi, t13hi); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b) +{ + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2)); + + a = v_uint64x2(_mm_unpacklo_epi64(t0, t1)); + b = v_uint64x2(_mm_unpackhi_epi64(t0, t1)); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b, v_uint64x2& c) +{ + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); // a0, b0 + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2)); // c0, a1 + __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 4)); // b1, c1 + + t1 = _mm_shuffle_epi32(t1, 0x4e); // a1, c0 + + a = v_uint64x2(_mm_unpacklo_epi64(t0, t1)); + b = v_uint64x2(_mm_unpacklo_epi64(_mm_unpackhi_epi64(t0, t0), t2)); + c = v_uint64x2(_mm_unpackhi_epi64(t1, t2)); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, + v_uint64x2& b, v_uint64x2& c, v_uint64x2& d) +{ + __m128i t0 = _mm_loadu_si128((const __m128i*)ptr); // a0 b0 + __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2)); // c0 d0 + __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 4)); // a1 b1 + __m128i t3 = _mm_loadu_si128((const __m128i*)(ptr + 6)); // c1 d1 + + a = v_uint64x2(_mm_unpacklo_epi64(t0, t2)); + b = v_uint64x2(_mm_unpackhi_epi64(t0, t2)); + c = v_uint64x2(_mm_unpacklo_epi64(t1, t3)); + d = v_uint64x2(_mm_unpackhi_epi64(t1, t3)); +} + +// store interleave + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi8(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi8(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 16), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 16), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 16), v1); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ +#if CV_SSE4_1 + const __m128i sh_a = _mm_setr_epi8(0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5); + const __m128i sh_b = _mm_setr_epi8(5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10); + const __m128i sh_c = _mm_setr_epi8(10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15); + __m128i a0 = _mm_shuffle_epi8(a.val, sh_a); + __m128i b0 = _mm_shuffle_epi8(b.val, sh_b); + __m128i c0 = _mm_shuffle_epi8(c.val, sh_c); + + const __m128i m0 = _mm_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); + const __m128i m1 = _mm_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); + __m128i v0 = _mm_blendv_epi8(_mm_blendv_epi8(a0, b0, m1), c0, m0); + __m128i v1 = _mm_blendv_epi8(_mm_blendv_epi8(b0, c0, m1), a0, m0); + __m128i v2 = _mm_blendv_epi8(_mm_blendv_epi8(c0, a0, m1), b0, m0); +#elif CV_SSSE3 + const __m128i m0 = _mm_setr_epi8(0, 6, 11, 1, 7, 12, 2, 8, 13, 3, 9, 14, 4, 10, 15, 5); + const __m128i m1 = _mm_setr_epi8(5, 11, 0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10); + const __m128i m2 = _mm_setr_epi8(10, 0, 5, 11, 1, 6, 12, 2, 7, 13, 3, 8, 14, 4, 9, 15); + + __m128i t0 = _mm_alignr_epi8(b.val, _mm_slli_si128(a.val, 10), 5); + t0 = _mm_alignr_epi8(c.val, t0, 5); + __m128i v0 = _mm_shuffle_epi8(t0, m0); + + __m128i t1 = _mm_alignr_epi8(_mm_srli_si128(b.val, 5), _mm_slli_si128(a.val, 5), 6); + t1 = _mm_alignr_epi8(_mm_srli_si128(c.val, 5), t1, 5); + __m128i v1 = _mm_shuffle_epi8(t1, m1); + + __m128i t2 = _mm_alignr_epi8(_mm_srli_si128(c.val, 10), b.val, 11); + t2 = _mm_alignr_epi8(t2, a.val, 11); + __m128i v2 = _mm_shuffle_epi8(t2, m2); +#else + __m128i z = _mm_setzero_si128(); + __m128i ab0 = _mm_unpacklo_epi8(a.val, b.val); + __m128i ab1 = _mm_unpackhi_epi8(a.val, b.val); + __m128i c0 = _mm_unpacklo_epi8(c.val, z); + __m128i c1 = _mm_unpackhi_epi8(c.val, z); + + __m128i p00 = _mm_unpacklo_epi16(ab0, c0); + __m128i p01 = _mm_unpackhi_epi16(ab0, c0); + __m128i p02 = _mm_unpacklo_epi16(ab1, c1); + __m128i p03 = _mm_unpackhi_epi16(ab1, c1); + + __m128i p10 = _mm_unpacklo_epi32(p00, p01); + __m128i p11 = _mm_unpackhi_epi32(p00, p01); + __m128i p12 = _mm_unpacklo_epi32(p02, p03); + __m128i p13 = _mm_unpackhi_epi32(p02, p03); + + __m128i p20 = _mm_unpacklo_epi64(p10, p11); + __m128i p21 = _mm_unpackhi_epi64(p10, p11); + __m128i p22 = _mm_unpacklo_epi64(p12, p13); + __m128i p23 = _mm_unpackhi_epi64(p12, p13); + + p20 = _mm_slli_si128(p20, 1); + p22 = _mm_slli_si128(p22, 1); + + __m128i p30 = _mm_slli_epi64(_mm_unpacklo_epi32(p20, p21), 8); + __m128i p31 = _mm_srli_epi64(_mm_unpackhi_epi32(p20, p21), 8); + __m128i p32 = _mm_slli_epi64(_mm_unpacklo_epi32(p22, p23), 8); + __m128i p33 = _mm_srli_epi64(_mm_unpackhi_epi32(p22, p23), 8); + + __m128i p40 = _mm_unpacklo_epi64(p30, p31); + __m128i p41 = _mm_unpackhi_epi64(p30, p31); + __m128i p42 = _mm_unpacklo_epi64(p32, p33); + __m128i p43 = _mm_unpackhi_epi64(p32, p33); + + __m128i v0 = _mm_or_si128(_mm_srli_si128(p40, 2), _mm_slli_si128(p41, 10)); + __m128i v1 = _mm_or_si128(_mm_srli_si128(p41, 6), _mm_slli_si128(p42, 6)); + __m128i v2 = _mm_or_si128(_mm_srli_si128(p42, 10), _mm_slli_si128(p43, 2)); +#endif + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 16), v1); + _mm_stream_si128((__m128i*)(ptr + 32), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 16), v1); + _mm_store_si128((__m128i*)(ptr + 32), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 16), v1); + _mm_storeu_si128((__m128i*)(ptr + 32), v2); + } +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, const v_uint8x16& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + __m128i u0 = _mm_unpacklo_epi8(a.val, c.val); // a0 c0 a1 c1 ... + __m128i u1 = _mm_unpackhi_epi8(a.val, c.val); // a8 c8 a9 c9 ... + __m128i u2 = _mm_unpacklo_epi8(b.val, d.val); // b0 d0 b1 d1 ... + __m128i u3 = _mm_unpackhi_epi8(b.val, d.val); // b8 d8 b9 d9 ... + + __m128i v0 = _mm_unpacklo_epi8(u0, u2); // a0 b0 c0 d0 ... + __m128i v1 = _mm_unpackhi_epi8(u0, u2); // a4 b4 c4 d4 ... + __m128i v2 = _mm_unpacklo_epi8(u1, u3); // a8 b8 c8 d8 ... + __m128i v3 = _mm_unpackhi_epi8(u1, u3); // a12 b12 c12 d12 ... + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 16), v1); + _mm_stream_si128((__m128i*)(ptr + 32), v2); + _mm_stream_si128((__m128i*)(ptr + 48), v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 16), v1); + _mm_store_si128((__m128i*)(ptr + 32), v2); + _mm_store_si128((__m128i*)(ptr + 48), v3); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 16), v1); + _mm_storeu_si128((__m128i*)(ptr + 32), v2); + _mm_storeu_si128((__m128i*)(ptr + 48), v3); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi16(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi16(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 8), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 8), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 8), v1); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, + const v_uint16x8& b, const v_uint16x8& c, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ +#if CV_SSE4_1 + const __m128i sh_a = _mm_setr_epi8(0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11); + const __m128i sh_b = _mm_setr_epi8(10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5); + const __m128i sh_c = _mm_setr_epi8(4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15); + __m128i a0 = _mm_shuffle_epi8(a.val, sh_a); + __m128i b0 = _mm_shuffle_epi8(b.val, sh_b); + __m128i c0 = _mm_shuffle_epi8(c.val, sh_c); + + __m128i v0 = _mm_blend_epi16(_mm_blend_epi16(a0, b0, 0x92), c0, 0x24); + __m128i v1 = _mm_blend_epi16(_mm_blend_epi16(c0, a0, 0x92), b0, 0x24); + __m128i v2 = _mm_blend_epi16(_mm_blend_epi16(b0, c0, 0x92), a0, 0x24); +#else + __m128i z = _mm_setzero_si128(); + __m128i ab0 = _mm_unpacklo_epi16(a.val, b.val); + __m128i ab1 = _mm_unpackhi_epi16(a.val, b.val); + __m128i c0 = _mm_unpacklo_epi16(c.val, z); + __m128i c1 = _mm_unpackhi_epi16(c.val, z); + + __m128i p10 = _mm_unpacklo_epi32(ab0, c0); + __m128i p11 = _mm_unpackhi_epi32(ab0, c0); + __m128i p12 = _mm_unpacklo_epi32(ab1, c1); + __m128i p13 = _mm_unpackhi_epi32(ab1, c1); + + __m128i p20 = _mm_unpacklo_epi64(p10, p11); + __m128i p21 = _mm_unpackhi_epi64(p10, p11); + __m128i p22 = _mm_unpacklo_epi64(p12, p13); + __m128i p23 = _mm_unpackhi_epi64(p12, p13); + + p20 = _mm_slli_si128(p20, 2); + p22 = _mm_slli_si128(p22, 2); + + __m128i p30 = _mm_unpacklo_epi64(p20, p21); + __m128i p31 = _mm_unpackhi_epi64(p20, p21); + __m128i p32 = _mm_unpacklo_epi64(p22, p23); + __m128i p33 = _mm_unpackhi_epi64(p22, p23); + + __m128i v0 = _mm_or_si128(_mm_srli_si128(p30, 2), _mm_slli_si128(p31, 10)); + __m128i v1 = _mm_or_si128(_mm_srli_si128(p31, 6), _mm_slli_si128(p32, 6)); + __m128i v2 = _mm_or_si128(_mm_srli_si128(p32, 10), _mm_slli_si128(p33, 2)); +#endif + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 8), v1); + _mm_stream_si128((__m128i*)(ptr + 16), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 8), v1); + _mm_store_si128((__m128i*)(ptr + 16), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 8), v1); + _mm_storeu_si128((__m128i*)(ptr + 16), v2); + } +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + const v_uint16x8& c, const v_uint16x8& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + __m128i u0 = _mm_unpacklo_epi16(a.val, c.val); // a0 c0 a1 c1 ... + __m128i u1 = _mm_unpackhi_epi16(a.val, c.val); // a4 c4 a5 c5 ... + __m128i u2 = _mm_unpacklo_epi16(b.val, d.val); // b0 d0 b1 d1 ... + __m128i u3 = _mm_unpackhi_epi16(b.val, d.val); // b4 d4 b5 d5 ... + + __m128i v0 = _mm_unpacklo_epi16(u0, u2); // a0 b0 c0 d0 ... + __m128i v1 = _mm_unpackhi_epi16(u0, u2); // a2 b2 c2 d2 ... + __m128i v2 = _mm_unpacklo_epi16(u1, u3); // a4 b4 c4 d4 ... + __m128i v3 = _mm_unpackhi_epi16(u1, u3); // a6 b6 c6 d6 ... + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 8), v1); + _mm_stream_si128((__m128i*)(ptr + 16), v2); + _mm_stream_si128((__m128i*)(ptr + 24), v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 8), v1); + _mm_store_si128((__m128i*)(ptr + 16), v2); + _mm_store_si128((__m128i*)(ptr + 24), v3); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 8), v1); + _mm_storeu_si128((__m128i*)(ptr + 16), v2); + _mm_storeu_si128((__m128i*)(ptr + 24), v3); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi32(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi32(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 4), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 4), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 4), v1); + } +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + v_uint32x4 z = v_setzero_u32(), u0, u1, u2, u3; + v_transpose4x4(a, b, c, z, u0, u1, u2, u3); + + __m128i v0 = _mm_or_si128(u0.val, _mm_slli_si128(u1.val, 12)); + __m128i v1 = _mm_or_si128(_mm_srli_si128(u1.val, 4), _mm_slli_si128(u2.val, 8)); + __m128i v2 = _mm_or_si128(_mm_srli_si128(u2.val, 8), _mm_slli_si128(u3.val, 4)); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 4), v1); + _mm_stream_si128((__m128i*)(ptr + 8), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 4), v1); + _mm_store_si128((__m128i*)(ptr + 8), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 4), v1); + _mm_storeu_si128((__m128i*)(ptr + 8), v2); + } +} + +inline void v_store_interleave(unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + v_uint32x4 v0, v1, v2, v3; + v_transpose4x4(a, b, c, d, v0, v1, v2, v3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0.val); + _mm_stream_si128((__m128i*)(ptr + 4), v1.val); + _mm_stream_si128((__m128i*)(ptr + 8), v2.val); + _mm_stream_si128((__m128i*)(ptr + 12), v3.val); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0.val); + _mm_store_si128((__m128i*)(ptr + 4), v1.val); + _mm_store_si128((__m128i*)(ptr + 8), v2.val); + _mm_store_si128((__m128i*)(ptr + 12), v3.val); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0.val); + _mm_storeu_si128((__m128i*)(ptr + 4), v1.val); + _mm_storeu_si128((__m128i*)(ptr + 8), v2.val); + _mm_storeu_si128((__m128i*)(ptr + 12), v3.val); + } +} + +// 2-channel, float only +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128 v0 = _mm_unpacklo_ps(a.val, b.val); // a0 b0 a1 b1 + __m128 v1 = _mm_unpackhi_ps(a.val, b.val); // a2 b2 a3 b3 + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_ps(ptr, v0); + _mm_stream_ps(ptr + 4, v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_ps(ptr, v0); + _mm_store_ps(ptr + 4, v1); + } + else + { + _mm_storeu_ps(ptr, v0); + _mm_storeu_ps(ptr + 4, v1); + } +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128 u0 = _mm_shuffle_ps(a.val, b.val, _MM_SHUFFLE(0, 0, 0, 0)); + __m128 u1 = _mm_shuffle_ps(c.val, a.val, _MM_SHUFFLE(1, 1, 0, 0)); + __m128 v0 = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(2, 0, 2, 0)); + __m128 u2 = _mm_shuffle_ps(b.val, c.val, _MM_SHUFFLE(1, 1, 1, 1)); + __m128 u3 = _mm_shuffle_ps(a.val, b.val, _MM_SHUFFLE(2, 2, 2, 2)); + __m128 v1 = _mm_shuffle_ps(u2, u3, _MM_SHUFFLE(2, 0, 2, 0)); + __m128 u4 = _mm_shuffle_ps(c.val, a.val, _MM_SHUFFLE(3, 3, 2, 2)); + __m128 u5 = _mm_shuffle_ps(b.val, c.val, _MM_SHUFFLE(3, 3, 3, 3)); + __m128 v2 = _mm_shuffle_ps(u4, u5, _MM_SHUFFLE(2, 0, 2, 0)); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_ps(ptr, v0); + _mm_stream_ps(ptr + 4, v1); + _mm_stream_ps(ptr + 8, v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_ps(ptr, v0); + _mm_store_ps(ptr + 4, v1); + _mm_store_ps(ptr + 8, v2); + } + else + { + _mm_storeu_ps(ptr, v0); + _mm_storeu_ps(ptr + 4, v1); + _mm_storeu_ps(ptr + 8, v2); + } +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128 u0 = _mm_unpacklo_ps(a.val, c.val); + __m128 u1 = _mm_unpacklo_ps(b.val, d.val); + __m128 u2 = _mm_unpackhi_ps(a.val, c.val); + __m128 u3 = _mm_unpackhi_ps(b.val, d.val); + __m128 v0 = _mm_unpacklo_ps(u0, u1); + __m128 v2 = _mm_unpacklo_ps(u2, u3); + __m128 v1 = _mm_unpackhi_ps(u0, u1); + __m128 v3 = _mm_unpackhi_ps(u2, u3); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_ps(ptr, v0); + _mm_stream_ps(ptr + 4, v1); + _mm_stream_ps(ptr + 8, v2); + _mm_stream_ps(ptr + 12, v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_ps(ptr, v0); + _mm_store_ps(ptr + 4, v1); + _mm_store_ps(ptr + 8, v2); + _mm_store_ps(ptr + 12, v3); + } + else + { + _mm_storeu_ps(ptr, v0); + _mm_storeu_ps(ptr + 4, v1); + _mm_storeu_ps(ptr + 8, v2); + _mm_storeu_ps(ptr + 12, v3); + } +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi64(a.val, b.val); + __m128i v1 = _mm_unpackhi_epi64(a.val, b.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 2), v1); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 2), v1); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 2), v1); + } +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi64(a.val, b.val); + __m128i v1 = _mm_unpacklo_epi64(c.val, _mm_unpackhi_epi64(a.val, a.val)); + __m128i v2 = _mm_unpackhi_epi64(b.val, c.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 2), v1); + _mm_stream_si128((__m128i*)(ptr + 4), v2); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 2), v1); + _mm_store_si128((__m128i*)(ptr + 4), v2); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 2), v1); + _mm_storeu_si128((__m128i*)(ptr + 4), v2); + } +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, const v_uint64x2& d, + hal::StoreMode mode = hal::STORE_UNALIGNED) +{ + __m128i v0 = _mm_unpacklo_epi64(a.val, b.val); + __m128i v1 = _mm_unpacklo_epi64(c.val, d.val); + __m128i v2 = _mm_unpackhi_epi64(a.val, b.val); + __m128i v3 = _mm_unpackhi_epi64(c.val, d.val); + + if( mode == hal::STORE_ALIGNED_NOCACHE ) + { + _mm_stream_si128((__m128i*)(ptr), v0); + _mm_stream_si128((__m128i*)(ptr + 2), v1); + _mm_stream_si128((__m128i*)(ptr + 4), v2); + _mm_stream_si128((__m128i*)(ptr + 6), v3); + } + else if( mode == hal::STORE_ALIGNED ) + { + _mm_store_si128((__m128i*)(ptr), v0); + _mm_store_si128((__m128i*)(ptr + 2), v1); + _mm_store_si128((__m128i*)(ptr + 4), v2); + _mm_store_si128((__m128i*)(ptr + 6), v3); + } + else + { + _mm_storeu_si128((__m128i*)(ptr), v0); + _mm_storeu_si128((__m128i*)(ptr + 2), v1); + _mm_storeu_si128((__m128i*)(ptr + 4), v2); + _mm_storeu_si128((__m128i*)(ptr + 6), v3); + } +} + +#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int8x16, schar, s8, v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int16x8, short, s16, v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int32x4, int, s32, v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_int64x2, int64, s64, v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(v_float64x2, double, f64, v_uint64x2, uint64, u64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(_mm_cvtepi32_ps(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + return v_float32x4(_mm_cvtpd_ps(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + return v_float32x4(_mm_movelh_ps(_mm_cvtpd_ps(a.val), _mm_cvtpd_ps(b.val))); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ + return v_float64x2(_mm_cvtepi32_pd(a.val)); +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ + return v_float64x2(_mm_cvtepi32_pd(_mm_srli_si128(a.val,8))); +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + return v_float64x2(_mm_cvtps_pd(a.val)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + return v_float64x2(_mm_cvtps_pd(_mm_movehl_ps(a.val, a.val))); +} + +// from (Mysticial and wim) https://stackoverflow.com/q/41144668 +inline v_float64x2 v_cvt_f64(const v_int64x2& v) +{ + // constants encoded as floating-point + __m128i magic_i_hi32 = _mm_set1_epi64x(0x4530000080000000); // 2^84 + 2^63 + __m128i magic_i_all = _mm_set1_epi64x(0x4530000080100000); // 2^84 + 2^63 + 2^52 + __m128d magic_d_all = _mm_castsi128_pd(magic_i_all); + // Blend the 32 lowest significant bits of v with magic_int_lo +#if CV_SSE4_1 + __m128i magic_i_lo = _mm_set1_epi64x(0x4330000000000000); // 2^52 + __m128i v_lo = _mm_blend_epi16(v.val, magic_i_lo, 0xcc); +#else + __m128i magic_i_lo = _mm_set1_epi32(0x43300000); // 2^52 + __m128i v_lo = _mm_unpacklo_epi32(_mm_shuffle_epi32(v.val, _MM_SHUFFLE(0, 0, 2, 0)), magic_i_lo); +#endif + // Extract the 32 most significant bits of v + __m128i v_hi = _mm_srli_epi64(v.val, 32); + // Flip the msb of v_hi and blend with 0x45300000 + v_hi = _mm_xor_si128(v_hi, magic_i_hi32); + // Compute in double precision + __m128d v_hi_dbl = _mm_sub_pd(_mm_castsi128_pd(v_hi), magic_d_all); + // (v_hi - magic_d_all) + v_lo Do not assume associativity of floating point addition + __m128d result = _mm_add_pd(v_hi_dbl, _mm_castsi128_pd(v_lo)); + return v_float64x2(result); +} + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int8x16(_mm_setr_epi8(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]])); +#else + return v_int8x16(_mm_setr_epi64( + _mm_setr_pi8(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]]), + _mm_setr_pi8(tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]]) + )); +#endif +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int8x16(_mm_setr_epi16(*(const short*)(tab + idx[0]), *(const short*)(tab + idx[1]), *(const short*)(tab + idx[2]), *(const short*)(tab + idx[3]), + *(const short*)(tab + idx[4]), *(const short*)(tab + idx[5]), *(const short*)(tab + idx[6]), *(const short*)(tab + idx[7]))); +#else + return v_int8x16(_mm_setr_epi64( + _mm_setr_pi16(*(const short*)(tab + idx[0]), *(const short*)(tab + idx[1]), *(const short*)(tab + idx[2]), *(const short*)(tab + idx[3])), + _mm_setr_pi16(*(const short*)(tab + idx[4]), *(const short*)(tab + idx[5]), *(const short*)(tab + idx[6]), *(const short*)(tab + idx[7])) + )); +#endif +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int8x16(_mm_setr_epi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1]), + *(const int*)(tab + idx[2]), *(const int*)(tab + idx[3]))); +#else + return v_int8x16(_mm_setr_epi64( + _mm_setr_pi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1])), + _mm_setr_pi32(*(const int*)(tab + idx[2]), *(const int*)(tab + idx[3])) + )); +#endif +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((const schar *)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int16x8(_mm_setr_epi16(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], + tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]])); +#else + return v_int16x8(_mm_setr_epi64( + _mm_setr_pi16(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]), + _mm_setr_pi16(tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]) + )); +#endif +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int16x8(_mm_setr_epi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1]), + *(const int*)(tab + idx[2]), *(const int*)(tab + idx[3]))); +#else + return v_int16x8(_mm_setr_epi64( + _mm_setr_pi32(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1])), + _mm_setr_pi32(*(const int*)(tab + idx[2]), *(const int*)(tab + idx[3])) + )); +#endif +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(_mm_set_epi64x(*(const int64_t*)(tab + idx[1]), *(const int64_t*)(tab + idx[0]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((const short *)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((const short *)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((const short *)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ +#if defined(_MSC_VER) + return v_int32x4(_mm_setr_epi32(tab[idx[0]], tab[idx[1]], + tab[idx[2]], tab[idx[3]])); +#else + return v_int32x4(_mm_setr_epi64( + _mm_setr_pi32(tab[idx[0]], tab[idx[1]]), + _mm_setr_pi32(tab[idx[2]], tab[idx[3]]) + )); +#endif +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(_mm_set_epi64x(*(const int64_t*)(tab + idx[1]), *(const int64_t*)(tab + idx[0]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(_mm_loadu_si128((const __m128i*)(tab + idx[0]))); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((const int *)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((const int *)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((const int *)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(_mm_set_epi64x(tab[idx[1]], tab[idx[0]])); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(_mm_loadu_si128((const __m128i*)(tab + idx[0]))); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + return v_float32x4(_mm_setr_ps(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]])); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_pairs((const int *)tab, idx)); } +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_quads((const int *)tab, idx)); } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + return v_float64x2(_mm_setr_pd(tab[idx[0]], tab[idx[1]])); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) { return v_float64x2(_mm_castsi128_pd(_mm_loadu_si128((const __m128i*)(tab + idx[0])))); } + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + return v_int32x4(_mm_setr_epi32(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]])); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + return v_float32x4(_mm_setr_ps(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]])); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + int idx[2]; + v_store_low(idx, idxvec); + return v_float64x2(_mm_setr_pd(tab[idx[0]], tab[idx[1]])); +} + +// loads pairs from the table and deinterleaves them, e.g. returns: +// x = (tab[idxvec[0], tab[idxvec[1]], tab[idxvec[2]], tab[idxvec[3]]), +// y = (tab[idxvec[0]+1], tab[idxvec[1]+1], tab[idxvec[2]+1], tab[idxvec[3]+1]) +// note that the indices are float's indices, not the float-pair indices. +// in theory, this function can be used to implement bilinear interpolation, +// when idxvec are the offsets within the image. +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + int CV_DECL_ALIGNED(32) idx[4]; + v_store_aligned(idx, idxvec); + __m128 z = _mm_setzero_ps(); + __m128 xy01 = _mm_loadl_pi(z, (__m64*)(tab + idx[0])); + __m128 xy23 = _mm_loadl_pi(z, (__m64*)(tab + idx[2])); + xy01 = _mm_loadh_pi(xy01, (__m64*)(tab + idx[1])); + xy23 = _mm_loadh_pi(xy23, (__m64*)(tab + idx[3])); + __m128 xxyy02 = _mm_unpacklo_ps(xy01, xy23); + __m128 xxyy13 = _mm_unpackhi_ps(xy01, xy23); + x = v_float32x4(_mm_unpacklo_ps(xxyy02, xxyy13)); + y = v_float32x4(_mm_unpackhi_ps(xxyy02, xxyy13)); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + int idx[2]; + v_store_low(idx, idxvec); + __m128d xy0 = _mm_loadu_pd(tab + idx[0]); + __m128d xy1 = _mm_loadu_pd(tab + idx[1]); + x = v_float64x2(_mm_unpacklo_pd(xy0, xy1)); + y = v_float64x2(_mm_unpackhi_pd(xy0, xy1)); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ +#if CV_SSSE3 + return v_int8x16(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0d0e0c0b090a08, 0x0705060403010200))); +#else + __m128i a = _mm_shufflelo_epi16(vec.val, _MM_SHUFFLE(3, 1, 2, 0)); + a = _mm_shufflehi_epi16(a, _MM_SHUFFLE(3, 1, 2, 0)); + a = _mm_shuffle_epi32(a, _MM_SHUFFLE(3, 1, 2, 0)); + return v_int8x16(_mm_unpacklo_epi8(a, _mm_unpackhi_epi64(a, a))); +#endif +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ +#if CV_SSSE3 + return v_int8x16(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0b0e0a0d090c08, 0x0703060205010400))); +#else + __m128i a = _mm_shuffle_epi32(vec.val, _MM_SHUFFLE(3, 1, 2, 0)); + return v_int8x16(_mm_unpacklo_epi8(a, _mm_unpackhi_epi64(a, a))); +#endif +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ +#if CV_SSSE3 + return v_int16x8(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0e0b0a0d0c0908, 0x0706030205040100))); +#else + __m128i a = _mm_shufflelo_epi16(vec.val, _MM_SHUFFLE(3, 1, 2, 0)); + return v_int16x8(_mm_shufflehi_epi16(a, _MM_SHUFFLE(3, 1, 2, 0))); +#endif +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ +#if CV_SSSE3 + return v_int16x8(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0x0f0e07060d0c0504, 0x0b0a030209080100))); +#else + return v_int16x8(_mm_unpacklo_epi16(vec.val, _mm_unpackhi_epi64(vec.val, vec.val))); +#endif +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + return v_int32x4(_mm_shuffle_epi32(vec.val, _MM_SHUFFLE(3, 1, 2, 0))); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) { return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ +#if CV_SSSE3 + return v_int8x16(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0xffffff0f0e0d0c0a, 0x0908060504020100))); +#else + __m128i mask = _mm_set1_epi64x(0x00000000FFFFFFFF); + __m128i a = _mm_srli_si128(_mm_or_si128(_mm_andnot_si128(mask, vec.val), _mm_and_si128(mask, _mm_sll_epi32(vec.val, _mm_set_epi64x(0, 8)))), 1); + return v_int8x16(_mm_srli_si128(_mm_shufflelo_epi16(a, _MM_SHUFFLE(2, 1, 0, 3)), 2)); +#endif +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ +#if CV_SSSE3 + return v_int16x8(_mm_shuffle_epi8(vec.val, _mm_set_epi64x(0xffff0f0e0d0c0b0a, 0x0908050403020100))); +#else + return v_int16x8(_mm_srli_si128(_mm_shufflelo_epi16(vec.val, _MM_SHUFFLE(2, 1, 0, 3)), 2)); +#endif +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +template +inline uchar v_extract_n(const v_uint8x16& v) +{ +#if CV_SSE4_1 + return (uchar)_mm_extract_epi8(v.val, i); +#else + return v_rotate_right(v).get0(); +#endif +} + +template +inline schar v_extract_n(const v_int8x16& v) +{ + return (schar)v_extract_n(v_reinterpret_as_u8(v)); +} + +template +inline ushort v_extract_n(const v_uint16x8& v) +{ + return (ushort)_mm_extract_epi16(v.val, i); +} + +template +inline short v_extract_n(const v_int16x8& v) +{ + return (short)v_extract_n(v_reinterpret_as_u16(v)); +} + +template +inline uint v_extract_n(const v_uint32x4& v) +{ +#if CV_SSE4_1 + return (uint)_mm_extract_epi32(v.val, i); +#else + return v_rotate_right(v).get0(); +#endif +} + +template +inline int v_extract_n(const v_int32x4& v) +{ + return (int)v_extract_n(v_reinterpret_as_u32(v)); +} + +template +inline uint64 v_extract_n(const v_uint64x2& v) +{ +#ifdef CV__SIMD_NATIVE_mm_extract_epi64 + return (uint64)_v128_extract_epi64(v.val); +#else + return v_rotate_right(v).get0(); +#endif +} + +template +inline int64 v_extract_n(const v_int64x2& v) +{ + return (int64)v_extract_n(v_reinterpret_as_u64(v)); +} + +template +inline float v_extract_n(const v_float32x4& v) +{ + union { uint iv; float fv; } d; + d.iv = v_extract_n(v_reinterpret_as_u32(v)); + return d.fv; +} + +template +inline double v_extract_n(const v_float64x2& v) +{ + union { uint64 iv; double dv; } d; + d.iv = v_extract_n(v_reinterpret_as_u64(v)); + return d.dv; +} + +template +inline v_int32x4 v_broadcast_element(const v_int32x4& v) +{ + return v_int32x4(_mm_shuffle_epi32(v.val, _MM_SHUFFLE(i,i,i,i))); +} + +template +inline v_uint32x4 v_broadcast_element(const v_uint32x4& v) +{ + return v_uint32x4(_mm_shuffle_epi32(v.val, _MM_SHUFFLE(i,i,i,i))); +} + +template +inline v_float32x4 v_broadcast_element(const v_float32x4& v) +{ + return v_float32x4(_mm_shuffle_ps(v.val, v.val, _MM_SHUFFLE((char)i,(char)i,(char)i,(char)i))); +} + +////////////// FP16 support /////////////////////////// + +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ +#if CV_FP16 + return v_float32x4(_mm_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr))); +#else + const __m128i z = _mm_setzero_si128(), delta = _mm_set1_epi32(0x38000000); + const __m128i signmask = _mm_set1_epi32(0x80000000), maxexp = _mm_set1_epi32(0x7c000000); + const __m128 deltaf = _mm_castsi128_ps(_mm_set1_epi32(0x38800000)); + __m128i bits = _mm_unpacklo_epi16(z, _mm_loadl_epi64((const __m128i*)ptr)); // h << 16 + __m128i e = _mm_and_si128(bits, maxexp), sign = _mm_and_si128(bits, signmask); + __m128i t = _mm_add_epi32(_mm_srli_epi32(_mm_xor_si128(bits, sign), 3), delta); // ((h & 0x7fff) << 13) + delta + __m128i zt = _mm_castps_si128(_mm_sub_ps(_mm_castsi128_ps(_mm_add_epi32(t, _mm_set1_epi32(1 << 23))), deltaf)); + + t = _mm_add_epi32(t, _mm_and_si128(delta, _mm_cmpeq_epi32(maxexp, e))); + __m128i zmask = _mm_cmpeq_epi32(e, z); + __m128i ft = v_select_si128(zmask, zt, t); + return v_float32x4(_mm_castsi128_ps(_mm_or_si128(ft, sign))); +#endif +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ +#if CV_FP16 + __m128i fp16_value = _mm_cvtps_ph(v.val, 0); + _mm_storel_epi64((__m128i*)ptr, fp16_value); +#else + const __m128i signmask = _mm_set1_epi32(0x80000000); + const __m128i rval = _mm_set1_epi32(0x3f000000); + + __m128i t = _mm_castps_si128(v.val); + __m128i sign = _mm_srai_epi32(_mm_and_si128(t, signmask), 16); + t = _mm_andnot_si128(signmask, t); + + __m128i finitemask = _mm_cmpgt_epi32(_mm_set1_epi32(0x47800000), t); + __m128i isnan = _mm_cmpgt_epi32(t, _mm_set1_epi32(0x7f800000)); + __m128i naninf = v_select_si128(isnan, _mm_set1_epi32(0x7e00), _mm_set1_epi32(0x7c00)); + __m128i tinymask = _mm_cmpgt_epi32(_mm_set1_epi32(0x38800000), t); + __m128i tt = _mm_castps_si128(_mm_add_ps(_mm_castsi128_ps(t), _mm_castsi128_ps(rval))); + tt = _mm_sub_epi32(tt, rval); + __m128i odd = _mm_and_si128(_mm_srli_epi32(t, 13), _mm_set1_epi32(1)); + __m128i nt = _mm_add_epi32(t, _mm_set1_epi32(0xc8000fff)); + nt = _mm_srli_epi32(_mm_add_epi32(nt, odd), 13); + t = v_select_si128(tinymask, tt, nt); + t = v_select_si128(finitemask, t, naninf); + t = _mm_or_si128(t, sign); + t = _mm_packs_epi32(t, t); + _mm_storel_epi64((__m128i*)ptr, t); +#endif +} + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_sse_em.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_sse_em.hpp new file mode 100644 index 0000000..6fb0881 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_sse_em.hpp @@ -0,0 +1,180 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_INTRIN_SSE_EM_HPP +#define OPENCV_HAL_INTRIN_SSE_EM_HPP + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#define OPENCV_HAL_SSE_WRAP_1(fun, tp) \ + inline tp _v128_##fun(const tp& a) \ + { return _mm_##fun(a); } + +#define OPENCV_HAL_SSE_WRAP_2(fun, tp) \ + inline tp _v128_##fun(const tp& a, const tp& b) \ + { return _mm_##fun(a, b); } + +#define OPENCV_HAL_SSE_WRAP_3(fun, tp) \ + inline tp _v128_##fun(const tp& a, const tp& b, const tp& c) \ + { return _mm_##fun(a, b, c); } + +///////////////////////////// XOP ///////////////////////////// + +// [todo] define CV_XOP +#if 1 // CV_XOP +inline __m128i _v128_comgt_epu32(const __m128i& a, const __m128i& b) +{ + const __m128i delta = _mm_set1_epi32((int)0x80000000); + return _mm_cmpgt_epi32(_mm_xor_si128(a, delta), _mm_xor_si128(b, delta)); +} +// wrapping XOP +#else +OPENCV_HAL_SSE_WRAP_2(_v128_comgt_epu32, __m128i) +#endif // !CV_XOP + +///////////////////////////// SSE4.1 ///////////////////////////// + +#if !CV_SSE4_1 + +/** Swizzle **/ +inline __m128i _v128_blendv_epi8(const __m128i& a, const __m128i& b, const __m128i& mask) +{ return _mm_xor_si128(a, _mm_and_si128(_mm_xor_si128(b, a), mask)); } + +/** Convert **/ +// 8 >> 16 +inline __m128i _v128_cvtepu8_epi16(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi8(a, z); +} +inline __m128i _v128_cvtepi8_epi16(const __m128i& a) +{ return _mm_srai_epi16(_mm_unpacklo_epi8(a, a), 8); } +// 8 >> 32 +inline __m128i _v128_cvtepu8_epi32(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi16(_mm_unpacklo_epi8(a, z), z); +} +inline __m128i _v128_cvtepi8_epi32(const __m128i& a) +{ + __m128i r = _mm_unpacklo_epi8(a, a); + r = _mm_unpacklo_epi8(r, r); + return _mm_srai_epi32(r, 24); +} +// 16 >> 32 +inline __m128i _v128_cvtepu16_epi32(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi16(a, z); +} +inline __m128i _v128_cvtepi16_epi32(const __m128i& a) +{ return _mm_srai_epi32(_mm_unpacklo_epi16(a, a), 16); } +// 32 >> 64 +inline __m128i _v128_cvtepu32_epi64(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpacklo_epi32(a, z); +} +inline __m128i _v128_cvtepi32_epi64(const __m128i& a) +{ return _mm_unpacklo_epi32(a, _mm_srai_epi32(a, 31)); } + +/** Arithmetic **/ +inline __m128i _v128_mullo_epi32(const __m128i& a, const __m128i& b) +{ + __m128i c0 = _mm_mul_epu32(a, b); + __m128i c1 = _mm_mul_epu32(_mm_srli_epi64(a, 32), _mm_srli_epi64(b, 32)); + __m128i d0 = _mm_unpacklo_epi32(c0, c1); + __m128i d1 = _mm_unpackhi_epi32(c0, c1); + return _mm_unpacklo_epi64(d0, d1); +} + +/** Math **/ +inline __m128i _v128_min_epu32(const __m128i& a, const __m128i& b) +{ return _v128_blendv_epi8(a, b, _v128_comgt_epu32(a, b)); } + +// wrapping SSE4.1 +#else +OPENCV_HAL_SSE_WRAP_1(cvtepu8_epi16, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi8_epi16, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepu8_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi8_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepu16_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi16_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepu32_epi64, __m128i) +OPENCV_HAL_SSE_WRAP_1(cvtepi32_epi64, __m128i) +OPENCV_HAL_SSE_WRAP_2(min_epu32, __m128i) +OPENCV_HAL_SSE_WRAP_2(mullo_epi32, __m128i) +OPENCV_HAL_SSE_WRAP_3(blendv_epi8, __m128i) +#endif // !CV_SSE4_1 + +///////////////////////////// Revolutionary ///////////////////////////// + +/** Convert **/ +// 16 << 8 +inline __m128i _v128_cvtepu8_epi16_high(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpackhi_epi8(a, z); +} +inline __m128i _v128_cvtepi8_epi16_high(const __m128i& a) +{ return _mm_srai_epi16(_mm_unpackhi_epi8(a, a), 8); } +// 32 << 16 +inline __m128i _v128_cvtepu16_epi32_high(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpackhi_epi16(a, z); +} +inline __m128i _v128_cvtepi16_epi32_high(const __m128i& a) +{ return _mm_srai_epi32(_mm_unpackhi_epi16(a, a), 16); } +// 64 << 32 +inline __m128i _v128_cvtepu32_epi64_high(const __m128i& a) +{ + const __m128i z = _mm_setzero_si128(); + return _mm_unpackhi_epi32(a, z); +} +inline __m128i _v128_cvtepi32_epi64_high(const __m128i& a) +{ return _mm_unpackhi_epi32(a, _mm_srai_epi32(a, 31)); } + +/** Miscellaneous **/ +inline __m128i _v128_packs_epu32(const __m128i& a, const __m128i& b) +{ + const __m128i m = _mm_set1_epi32(65535); + __m128i am = _v128_min_epu32(a, m); + __m128i bm = _v128_min_epu32(b, m); +#if CV_SSE4_1 + return _mm_packus_epi32(am, bm); +#else + const __m128i d = _mm_set1_epi32(32768), nd = _mm_set1_epi16(-32768); + am = _mm_sub_epi32(am, d); + bm = _mm_sub_epi32(bm, d); + am = _mm_packs_epi32(am, bm); + return _mm_sub_epi16(am, nd); +#endif +} + +template +inline int64 _v128_extract_epi64(const __m128i& a) +{ +#if defined(CV__SIMD_HAVE_mm_extract_epi64) || (CV_SSE4_1 && (defined(__x86_64__)/*GCC*/ || defined(_M_X64)/*MSVC*/)) +#define CV__SIMD_NATIVE_mm_extract_epi64 1 + return _mm_extract_epi64(a, i); +#else + CV_DECL_ALIGNED(16) int64 tmp[2]; + _mm_store_si128((__m128i*)tmp, a); + return tmp[i]; +#endif +} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} // cv:: + +#endif // OPENCV_HAL_INTRIN_SSE_EM_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_vsx.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_vsx.hpp new file mode 100644 index 0000000..b198643 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_vsx.hpp @@ -0,0 +1,1608 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_VSX_HPP +#define OPENCV_HAL_VSX_HPP + +#include +#include "opencv2/core/utility.hpp" + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 1 + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +///////// Types //////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + enum { nlanes = 16 }; + vec_uchar16 val; + + explicit v_uint8x16(const vec_uchar16& v) : val(v) + {} + v_uint8x16() + {} + v_uint8x16(vec_bchar16 v) : val(vec_uchar16_c(v)) + {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + : val(vec_uchar16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)) + {} + + static inline v_uint8x16 zero() { return v_uint8x16(vec_uchar16_z); } + + uchar get0() const + { return vec_extract(val, 0); } +}; + +struct v_int8x16 +{ + typedef schar lane_type; + enum { nlanes = 16 }; + vec_char16 val; + + explicit v_int8x16(const vec_char16& v) : val(v) + {} + v_int8x16() + {} + v_int8x16(vec_bchar16 v) : val(vec_char16_c(v)) + {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + : val(vec_char16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)) + {} + + static inline v_int8x16 zero() { return v_int8x16(vec_char16_z); } + + schar get0() const + { return vec_extract(val, 0); } +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + enum { nlanes = 8 }; + vec_ushort8 val; + + explicit v_uint16x8(const vec_ushort8& v) : val(v) + {} + v_uint16x8() + {} + v_uint16x8(vec_bshort8 v) : val(vec_ushort8_c(v)) + {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + : val(vec_ushort8_set(v0, v1, v2, v3, v4, v5, v6, v7)) + {} + + static inline v_uint16x8 zero() { return v_uint16x8(vec_ushort8_z); } + + ushort get0() const + { return vec_extract(val, 0); } +}; + +struct v_int16x8 +{ + typedef short lane_type; + enum { nlanes = 8 }; + vec_short8 val; + + explicit v_int16x8(const vec_short8& v) : val(v) + {} + v_int16x8() + {} + v_int16x8(vec_bshort8 v) : val(vec_short8_c(v)) + {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + : val(vec_short8_set(v0, v1, v2, v3, v4, v5, v6, v7)) + {} + + static inline v_int16x8 zero() { return v_int16x8(vec_short8_z); } + + short get0() const + { return vec_extract(val, 0); } +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + enum { nlanes = 4 }; + vec_uint4 val; + + explicit v_uint32x4(const vec_uint4& v) : val(v) + {} + v_uint32x4() + {} + v_uint32x4(vec_bint4 v) : val(vec_uint4_c(v)) + {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) : val(vec_uint4_set(v0, v1, v2, v3)) + {} + + static inline v_uint32x4 zero() { return v_uint32x4(vec_uint4_z); } + + uint get0() const + { return vec_extract(val, 0); } +}; + +struct v_int32x4 +{ + typedef int lane_type; + enum { nlanes = 4 }; + vec_int4 val; + + explicit v_int32x4(const vec_int4& v) : val(v) + {} + v_int32x4() + {} + v_int32x4(vec_bint4 v) : val(vec_int4_c(v)) + {} + v_int32x4(int v0, int v1, int v2, int v3) : val(vec_int4_set(v0, v1, v2, v3)) + {} + + static inline v_int32x4 zero() { return v_int32x4(vec_int4_z); } + + int get0() const + { return vec_extract(val, 0); } +}; + +struct v_float32x4 +{ + typedef float lane_type; + enum { nlanes = 4 }; + vec_float4 val; + + explicit v_float32x4(const vec_float4& v) : val(v) + {} + v_float32x4() + {} + v_float32x4(vec_bint4 v) : val(vec_float4_c(v)) + {} + v_float32x4(float v0, float v1, float v2, float v3) : val(vec_float4_set(v0, v1, v2, v3)) + {} + + static inline v_float32x4 zero() { return v_float32x4(vec_float4_z); } + + float get0() const + { return vec_extract(val, 0); } +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + enum { nlanes = 2 }; + vec_udword2 val; + + explicit v_uint64x2(const vec_udword2& v) : val(v) + {} + v_uint64x2() + {} + v_uint64x2(vec_bdword2 v) : val(vec_udword2_c(v)) + {} + v_uint64x2(uint64 v0, uint64 v1) : val(vec_udword2_set(v0, v1)) + {} + + static inline v_uint64x2 zero() { return v_uint64x2(vec_udword2_z); } + + uint64 get0() const + { return vec_extract(val, 0); } +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + enum { nlanes = 2 }; + vec_dword2 val; + + explicit v_int64x2(const vec_dword2& v) : val(v) + {} + v_int64x2() + {} + v_int64x2(vec_bdword2 v) : val(vec_dword2_c(v)) + {} + v_int64x2(int64 v0, int64 v1) : val(vec_dword2_set(v0, v1)) + {} + + static inline v_int64x2 zero() { return v_int64x2(vec_dword2_z); } + + int64 get0() const + { return vec_extract(val, 0); } +}; + +struct v_float64x2 +{ + typedef double lane_type; + enum { nlanes = 2 }; + vec_double2 val; + + explicit v_float64x2(const vec_double2& v) : val(v) + {} + v_float64x2() + {} + v_float64x2(vec_bdword2 v) : val(vec_double2_c(v)) + {} + v_float64x2(double v0, double v1) : val(vec_double2_set(v0, v1)) + {} + + static inline v_float64x2 zero() { return v_float64x2(vec_double2_z); } + + double get0() const + { return vec_extract(val, 0); } +}; + +#define OPENCV_HAL_IMPL_VSX_EXTRACT_N(_Tpvec, _Tp) \ +template inline _Tp v_extract_n(VSX_UNUSED(_Tpvec v)) { return vec_extract(v.val, i); } + +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint8x16, uchar) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int8x16, schar) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint16x8, ushort) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int16x8, short) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint32x4, uint) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int32x4, int) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_uint64x2, uint64) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_int64x2, int64) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float32x4, float) +OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double) + +//////////////// Load and store operations /////////////// + +/* + * clang-5 aborted during parse "vec_xxx_c" only if it's + * inside a function template which is defined by preprocessor macro. + * + * if vec_xxx_c defined as C++ cast, clang-5 will pass it +*/ +#define OPENCV_HAL_IMPL_VSX_INITVEC(_Tpvec, _Tp, suffix, cast) \ +inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); } \ +inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));} \ +template inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a) \ +{ return _Tpvec((cast)a.val); } + +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint8x16, uchar, u8, vec_uchar16) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int8x16, schar, s8, vec_char16) +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint16x8, ushort, u16, vec_ushort8) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int16x8, short, s16, vec_short8) +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint32x4, uint, u32, vec_uint4) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int32x4, int, s32, vec_int4) +OPENCV_HAL_IMPL_VSX_INITVEC(v_uint64x2, uint64, u64, vec_udword2) +OPENCV_HAL_IMPL_VSX_INITVEC(v_int64x2, int64, s64, vec_dword2) +OPENCV_HAL_IMPL_VSX_INITVEC(v_float32x4, float, f32, vec_float4) +OPENCV_HAL_IMPL_VSX_INITVEC(v_float64x2, double, f64, vec_double2) + +#define OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, ld, ld_a, st, st_a) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(ld(0, ptr)); } \ +inline _Tpvec v_load_aligned(VSX_UNUSED(const _Tp* ptr)) \ +{ return _Tpvec(ld_a(0, ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ return _Tpvec(vec_ld_l8(ptr)); } \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ return _Tpvec(vec_mergesqh(vec_ld_l8(ptr0), vec_ld_l8(ptr1))); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ st(a.val, 0, ptr); } \ +inline void v_store_aligned(VSX_UNUSED(_Tp* ptr), const _Tpvec& a) \ +{ st_a(a.val, 0, ptr); } \ +inline void v_store_aligned_nocache(VSX_UNUSED(_Tp* ptr), const _Tpvec& a) \ +{ st_a(a.val, 0, ptr); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode mode) \ +{ if(mode == hal::STORE_UNALIGNED) st(a.val, 0, ptr); else st_a(a.val, 0, ptr); } \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ vec_st_l8(a.val, ptr); } \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ vec_st_h8(a.val, ptr); } + +// working around gcc bug for aligned ld/st +// if runtime check for vec_ld/st fail we failback to unaligned ld/st +// https://github.com/opencv/opencv/issues/13211 +#ifdef CV_COMPILER_VSX_BROKEN_ALIGNED + #define OPENCV_HAL_IMPL_VSX_LOADSTORE(_Tpvec, _Tp) \ + OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, vsx_ld, vsx_ld, vsx_st, vsx_st) +#else + #define OPENCV_HAL_IMPL_VSX_LOADSTORE(_Tpvec, _Tp) \ + OPENCV_HAL_IMPL_VSX_LOADSTORE_C(_Tpvec, _Tp, vsx_ld, vec_ld, vsx_st, vec_st) +#endif + +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_uint8x16, uchar) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_int8x16, schar) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_uint16x8, ushort) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_int16x8, short) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_uint32x4, uint) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_int32x4, int) +OPENCV_HAL_IMPL_VSX_LOADSTORE(v_float32x4, float) + +OPENCV_HAL_IMPL_VSX_LOADSTORE_C(v_float64x2, double, vsx_ld, vsx_ld, vsx_st, vsx_st) +OPENCV_HAL_IMPL_VSX_LOADSTORE_C(v_uint64x2, uint64, vsx_ld2, vsx_ld2, vsx_st2, vsx_st2) +OPENCV_HAL_IMPL_VSX_LOADSTORE_C(v_int64x2, int64, vsx_ld2, vsx_ld2, vsx_st2, vsx_st2) + +//////////////// Value reordering /////////////// + +/* de&interleave */ +#define OPENCV_HAL_IMPL_VSX_INTERLEAVE(_Tp, _Tpvec) \ +inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b) \ +{ vec_ld_deinterleave(ptr, a.val, b.val);} \ +inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, \ + _Tpvec& b, _Tpvec& c) \ +{ vec_ld_deinterleave(ptr, a.val, b.val, c.val); } \ +inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b, \ + _Tpvec& c, _Tpvec& d) \ +{ vec_ld_deinterleave(ptr, a.val, b.val, c.val, d.val); } \ +inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ vec_st_interleave(a.val, b.val, ptr); } \ +inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, \ + const _Tpvec& b, const _Tpvec& c, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ vec_st_interleave(a.val, b.val, c.val, ptr); } \ +inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \ + const _Tpvec& c, const _Tpvec& d, \ + hal::StoreMode /*mode*/=hal::STORE_UNALIGNED) \ +{ vec_st_interleave(a.val, b.val, c.val, d.val, ptr); } + +OPENCV_HAL_IMPL_VSX_INTERLEAVE(uchar, v_uint8x16) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(schar, v_int8x16) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(ushort, v_uint16x8) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(short, v_int16x8) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(uint, v_uint32x4) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(int, v_int32x4) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(float, v_float32x4) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(double, v_float64x2) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(int64, v_int64x2) +OPENCV_HAL_IMPL_VSX_INTERLEAVE(uint64, v_uint64x2) + +/* Expand */ +#define OPENCV_HAL_IMPL_VSX_EXPAND(_Tpvec, _Tpwvec, _Tp, fl, fh) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = fh(a.val); \ + b1.val = fl(a.val); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ return _Tpwvec(fh(a.val)); } \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ return _Tpwvec(fl(a.val)); } \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ return _Tpwvec(fh(vec_ld_l8(ptr))); } + +OPENCV_HAL_IMPL_VSX_EXPAND(v_uint8x16, v_uint16x8, uchar, vec_unpacklu, vec_unpackhu) +OPENCV_HAL_IMPL_VSX_EXPAND(v_int8x16, v_int16x8, schar, vec_unpackl, vec_unpackh) +OPENCV_HAL_IMPL_VSX_EXPAND(v_uint16x8, v_uint32x4, ushort, vec_unpacklu, vec_unpackhu) +OPENCV_HAL_IMPL_VSX_EXPAND(v_int16x8, v_int32x4, short, vec_unpackl, vec_unpackh) +OPENCV_HAL_IMPL_VSX_EXPAND(v_uint32x4, v_uint64x2, uint, vec_unpacklu, vec_unpackhu) +OPENCV_HAL_IMPL_VSX_EXPAND(v_int32x4, v_int64x2, int, vec_unpackl, vec_unpackh) + +/* Load and zero expand a 4 byte value into the second dword, first is don't care. */ +#if !defined(CV_COMPILER_VSX_BROKEN_ASM) + #define _LXSIWZX(out, ptr, T) __asm__ ("lxsiwzx %x0, 0, %1\r\n" : "=wa"(out) : "r" (ptr) : "memory"); +#else + /* This is compiler-agnostic, but will introduce an unneeded splat on the critical path. */ + #define _LXSIWZX(out, ptr, T) out = (T)vec_udword2_sp(*(uint32_t*)(ptr)); +#endif + +inline v_uint32x4 v_load_expand_q(const uchar* ptr) +{ + // Zero-extend the extra 24B instead of unpacking. Usually faster in small kernel + // Likewise note, value is zero extended and upper 4 bytes are zero'ed. + vec_uchar16 pmu = {8, 12, 12, 12, 9, 12, 12, 12, 10, 12, 12, 12, 11, 12, 12, 12}; + vec_uchar16 out; + + _LXSIWZX(out, ptr, vec_uchar16); + out = vec_perm(out, out, pmu); + return v_uint32x4((vec_uint4)out); +} + +inline v_int32x4 v_load_expand_q(const schar* ptr) +{ + vec_char16 out; + vec_short8 outs; + vec_int4 outw; + + _LXSIWZX(out, ptr, vec_char16); + outs = vec_unpackl(out); + outw = vec_unpackh(outs); + return v_int32x4(outw); +} + +/* pack */ +#define OPENCV_HAL_IMPL_VSX_PACK(_Tpvec, _Tp, _Tpwvec, _Tpvn, _Tpdel, sfnc, pkfnc, addfnc, pack) \ +inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + return _Tpvec(pkfnc(a.val, b.val)); \ +} \ +inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + vec_st_l8(pkfnc(a.val, a.val), ptr); \ +} \ +template \ +inline _Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \ +{ \ + const __vector _Tpvn vn = vec_splats((_Tpvn)n); \ + const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \ + return _Tpvec(pkfnc(sfnc(addfnc(a.val, delta), vn), sfnc(addfnc(b.val, delta), vn))); \ +} \ +template \ +inline void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \ +{ \ + const __vector _Tpvn vn = vec_splats((_Tpvn)n); \ + const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \ + vec_st_l8(pkfnc(sfnc(addfnc(a.val, delta), vn), delta), ptr); \ +} + +OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_uint16x8, unsigned short, unsigned short, + vec_sr, vec_packs, vec_adds, pack) +OPENCV_HAL_IMPL_VSX_PACK(v_int8x16, schar, v_int16x8, unsigned short, short, + vec_sra, vec_packs, vec_adds, pack) + +OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_uint32x4, unsigned int, unsigned int, + vec_sr, vec_packs, vec_add, pack) +OPENCV_HAL_IMPL_VSX_PACK(v_int16x8, short, v_int32x4, unsigned int, int, + vec_sra, vec_packs, vec_add, pack) + +OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_uint64x2, unsigned long long, unsigned long long, + vec_sr, vec_pack, vec_add, pack) +OPENCV_HAL_IMPL_VSX_PACK(v_int32x4, int, v_int64x2, unsigned long long, long long, + vec_sra, vec_pack, vec_add, pack) + +OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_int16x8, unsigned short, short, + vec_sra, vec_packsu, vec_adds, pack_u) +OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_int32x4, unsigned int, int, + vec_sra, vec_packsu, vec_add, pack_u) +// Following variant is not implemented on other platforms: +//OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_int64x2, unsigned long long, long long, +// vec_sra, vec_packsu, vec_add, pack_u) + +// pack boolean +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + vec_uchar16 ab = vec_pack(a.val, b.val); + return v_uint8x16(ab); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + vec_ushort8 ab = vec_pack(a.val, b.val); + vec_ushort8 cd = vec_pack(c.val, d.val); + return v_uint8x16(vec_pack(ab, cd)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + vec_uint4 ab = vec_pack(a.val, b.val); + vec_uint4 cd = vec_pack(c.val, d.val); + vec_uint4 ef = vec_pack(e.val, f.val); + vec_uint4 gh = vec_pack(g.val, h.val); + + vec_ushort8 abcd = vec_pack(ab, cd); + vec_ushort8 efgh = vec_pack(ef, gh); + return v_uint8x16(vec_pack(abcd, efgh)); +} + +/* Recombine */ +template +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) +{ + b0.val = vec_mergeh(a0.val, a1.val); + b1.val = vec_mergel(a0.val, a1.val); +} + +template +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(vec_mergesql(a.val, b.val)); } + +template +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) +{ return _Tpvec(vec_mergesqh(a.val, b.val)); } + +template +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) +{ + c.val = vec_mergesqh(a.val, b.val); + d.val = vec_mergesql(a.val, b.val); +} + +////////// Arithmetic, bitwise and comparison operations ///////// + +/* Element-wise binary and unary operations */ +/** Arithmetics **/ +#define OPENCV_HAL_IMPL_VSX_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(intrin(a.val, b.val)); } \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ a.val = intrin(a.val, b.val); return a; } + +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint8x16, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint8x16, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int8x16, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int8x16, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint16x8, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint16x8, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int16x8, vec_adds) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int16x8, vec_subs) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint32x4, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint32x4, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_uint32x4, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int32x4, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int32x4, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_int32x4, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float32x4, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float32x4, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float32x4, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float32x4, vec_div) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float64x2, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float64x2, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float64x2, vec_mul) +OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float64x2, vec_div) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint64x2, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint64x2, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int64x2, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int64x2, vec_sub) + +// saturating multiply +#define OPENCV_HAL_IMPL_VSX_MUL_SAT(_Tpvec, _Tpwvec) \ + inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ + { \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ + } \ + inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ + { a = a * b; return a; } + +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_int16x8, v_int32x4) +OPENCV_HAL_IMPL_VSX_MUL_SAT(v_uint16x8, v_uint32x4) + +template +inline void v_mul_expand(const Tvec& a, const Tvec& b, Twvec& c, Twvec& d) +{ + Twvec p0 = Twvec(vec_mule(a.val, b.val)); + Twvec p1 = Twvec(vec_mulo(a.val, b.val)); + v_zip(p0, p1, c, d); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + vec_int4 p0 = vec_mule(a.val, b.val); + vec_int4 p1 = vec_mulo(a.val, b.val); + static const vec_uchar16 perm = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}; + return v_int16x8(vec_perm(vec_short8_c(p0), vec_short8_c(p1), perm)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + vec_uint4 p0 = vec_mule(a.val, b.val); + vec_uint4 p1 = vec_mulo(a.val, b.val); + static const vec_uchar16 perm = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}; + return v_uint16x8(vec_perm(vec_ushort8_c(p0), vec_ushort8_c(p1), perm)); +} + +/** Non-saturating arithmetics **/ +#define OPENCV_HAL_IMPL_VSX_BIN_FUNC(func, intrin) \ +template \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(intrin(a.val, b.val)); } + +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_add_wrap, vec_add) +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_sub_wrap, vec_sub) +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_mul_wrap, vec_mul) + +/** Bitwise shifts **/ +#define OPENCV_HAL_IMPL_VSX_SHIFT_OP(_Tpvec, shr, splfunc) \ +inline _Tpvec operator << (const _Tpvec& a, int imm) \ +{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \ +inline _Tpvec operator >> (const _Tpvec& a, int imm) \ +{ return _Tpvec(shr(a.val, splfunc(imm))); } \ +template inline _Tpvec v_shl(const _Tpvec& a) \ +{ return _Tpvec(vec_sl(a.val, splfunc(imm))); } \ +template inline _Tpvec v_shr(const _Tpvec& a) \ +{ return _Tpvec(shr(a.val, splfunc(imm))); } + +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint8x16, vec_sr, vec_uchar16_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint16x8, vec_sr, vec_ushort8_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint32x4, vec_sr, vec_uint4_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint64x2, vec_sr, vec_udword2_sp) +// algebraic right shift +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int8x16, vec_sra, vec_uchar16_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int16x8, vec_sra, vec_ushort8_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int32x4, vec_sra, vec_uint4_sp) +OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int64x2, vec_sra, vec_udword2_sp) + +/** Bitwise logic **/ +#define OPENCV_HAL_IMPL_VSX_LOGIC_OP(_Tpvec) \ +OPENCV_HAL_IMPL_VSX_BIN_OP(&, _Tpvec, vec_and) \ +OPENCV_HAL_IMPL_VSX_BIN_OP(|, _Tpvec, vec_or) \ +OPENCV_HAL_IMPL_VSX_BIN_OP(^, _Tpvec, vec_xor) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ return _Tpvec(vec_not(a.val)); } + +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint8x16) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int8x16) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint16x8) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int16x8) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint32x4) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int32x4) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint64x2) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int64x2) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float32x4) +OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float64x2) + +/** Bitwise select **/ +#define OPENCV_HAL_IMPL_VSX_SELECT(_Tpvec, cast) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_sel(b.val, a.val, cast(mask.val))); } + +OPENCV_HAL_IMPL_VSX_SELECT(v_uint8x16, vec_bchar16_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_int8x16, vec_bchar16_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_uint16x8, vec_bshort8_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_int16x8, vec_bshort8_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_uint32x4, vec_bint4_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_int32x4, vec_bint4_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_float32x4, vec_bint4_c) +OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c) + +/** Comparison **/ +#define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpeq(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpne(a.val, b.val)); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmplt(a.val, b.val)); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpgt(a.val, b.val)); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmple(a.val, b.val)); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_cmpge(a.val, b.val)); } + +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint8x16) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int8x16) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint16x8) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int16x8) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint32x4) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int32x4) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float32x4) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float64x2) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint64x2) +OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int64x2) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ return v_float32x4(vec_cmpeq(a.val, a.val)); } +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ return v_float64x2(vec_cmpeq(a.val, a.val)); } + +/** min/max **/ +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_min, vec_min) +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_max, vec_max) + +/** Rotate **/ +#define OPENCV_IMPL_VSX_ROTATE(_Tpvec, suffix, shf, cast) \ +template \ +inline _Tpvec v_rotate_##suffix(const _Tpvec& a) \ +{ \ + const int wd = imm * sizeof(typename _Tpvec::lane_type); \ + if (wd > 15) \ + return _Tpvec::zero(); \ + return _Tpvec((cast)shf(vec_uchar16_c(a.val), vec_uchar16_sp(wd << 3))); \ +} + +#define OPENCV_IMPL_VSX_ROTATE_LR(_Tpvec, cast) \ +OPENCV_IMPL_VSX_ROTATE(_Tpvec, left, vec_slo, cast) \ +OPENCV_IMPL_VSX_ROTATE(_Tpvec, right, vec_sro, cast) + +OPENCV_IMPL_VSX_ROTATE_LR(v_uint8x16, vec_uchar16) +OPENCV_IMPL_VSX_ROTATE_LR(v_int8x16, vec_char16) +OPENCV_IMPL_VSX_ROTATE_LR(v_uint16x8, vec_ushort8) +OPENCV_IMPL_VSX_ROTATE_LR(v_int16x8, vec_short8) +OPENCV_IMPL_VSX_ROTATE_LR(v_uint32x4, vec_uint4) +OPENCV_IMPL_VSX_ROTATE_LR(v_int32x4, vec_int4) +OPENCV_IMPL_VSX_ROTATE_LR(v_float32x4, vec_float4) +OPENCV_IMPL_VSX_ROTATE_LR(v_uint64x2, vec_udword2) +OPENCV_IMPL_VSX_ROTATE_LR(v_int64x2, vec_dword2) +OPENCV_IMPL_VSX_ROTATE_LR(v_float64x2, vec_double2) + +template +inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) +{ + enum { CV_SHIFT = 16 - imm * (sizeof(typename _Tpvec::lane_type)) }; + if (CV_SHIFT == 16) + return a; +#ifdef __IBMCPP__ + return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT & 15)); +#else + return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT)); +#endif +} + +template +inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) +{ + enum { CV_SHIFT = imm * (sizeof(typename _Tpvec::lane_type)) }; + if (CV_SHIFT == 16) + return b; + return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT)); +} + +#define OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, suffix, rg1, rg2) \ +template \ +inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \ +{ \ + if (imm == 1) \ + return _Tpvec(vec_permi(rg1.val, rg2.val, 2)); \ + return imm ? b : a; \ +} + +#define OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(_Tpvec) \ +OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, left, b, a) \ +OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, right, a, b) + +OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_float64x2) +OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_uint64x2) +OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_int64x2) + +/* Reverse */ +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ + static const vec_uchar16 perm = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_uint8x16(vec_perm(vec, vec, perm)); +} + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ + static const vec_uchar16 perm = {14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_reinterpret_as_u16(v_uint8x16(vec_perm(vec, vec, perm))); +} + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ + static const vec_uchar16 perm = {12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_reinterpret_as_u32(v_uint8x16(vec_perm(vec, vec, perm))); +} + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ + static const vec_uchar16 perm = {8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7}; + vec_uchar16 vec = (vec_uchar16)a.val; + return v_reinterpret_as_u64(v_uint8x16(vec_perm(vec, vec, perm))); +} + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + +/* Extract */ +template +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) +{ return v_rotate_right(a, b); } + +////////// Reduce and mask ///////// + +/** Reduce **/ +inline uint v_reduce_sum(const v_uint8x16& a) +{ + const vec_uint4 zero4 = vec_uint4_z; + vec_uint4 sum4 = vec_sum4s(a.val, zero4); + return (uint)vec_extract(vec_sums(vec_int4_c(sum4), vec_int4_c(zero4)), 3); +} +inline int v_reduce_sum(const v_int8x16& a) +{ + const vec_int4 zero4 = vec_int4_z; + vec_int4 sum4 = vec_sum4s(a.val, zero4); + return (int)vec_extract(vec_sums(sum4, zero4), 3); +} +inline int v_reduce_sum(const v_int16x8& a) +{ + const vec_int4 zero = vec_int4_z; + return saturate_cast(vec_extract(vec_sums(vec_sum4s(a.val, zero), zero), 3)); +} +inline uint v_reduce_sum(const v_uint16x8& a) +{ + const vec_int4 v4 = vec_int4_c(vec_unpackhu(vec_adds(a.val, vec_sld(a.val, a.val, 8)))); + return saturate_cast(vec_extract(vec_sums(v4, vec_int4_z), 3)); +} + +#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(_Tpvec, _Tpvec2, scalartype, suffix, func) \ +inline scalartype v_reduce_##suffix(const _Tpvec& a) \ +{ \ + const _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \ + return vec_extract(func(rs, vec_sld(rs, rs, 4)), 0); \ +} +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, sum, vec_add) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, sum, vec_add) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, sum, vec_add) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, min, vec_min) + +inline uint64 v_reduce_sum(const v_uint64x2& a) +{ + return vec_extract(vec_add(a.val, vec_permi(a.val, a.val, 3)), 0); +} +inline int64 v_reduce_sum(const v_int64x2& a) +{ + return vec_extract(vec_add(a.val, vec_permi(a.val, a.val, 3)), 0); +} +inline double v_reduce_sum(const v_float64x2& a) +{ + return vec_extract(vec_add(a.val, vec_permi(a.val, a.val, 3)), 0); +} + +#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(_Tpvec, _Tpvec2, scalartype, suffix, func) \ +inline scalartype v_reduce_##suffix(const _Tpvec& a) \ +{ \ + _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \ + rs = func(rs, vec_sld(rs, rs, 4)); \ + return vec_extract(func(rs, vec_sld(rs, rs, 2)), 0); \ +} +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, min, vec_min) + +#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(_Tpvec, _Tpvec2, scalartype, suffix, func) \ +inline scalartype v_reduce_##suffix(const _Tpvec& a) \ +{ \ + _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \ + rs = func(rs, vec_sld(rs, rs, 4)); \ + rs = func(rs, vec_sld(rs, rs, 2)); \ + return vec_extract(func(rs, vec_sld(rs, rs, 1)), 0); \ +} +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_uint8x16, vec_uchar16, uchar, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_uint8x16, vec_uchar16, uchar, min, vec_min) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_int8x16, vec_char16, schar, max, vec_max) +OPENCV_HAL_IMPL_VSX_REDUCE_OP_16(v_int8x16, vec_char16, schar, min, vec_min) + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + vec_float4 ac = vec_add(vec_mergel(a.val, c.val), vec_mergeh(a.val, c.val)); + ac = vec_add(ac, vec_sld(ac, ac, 8)); + + vec_float4 bd = vec_add(vec_mergel(b.val, d.val), vec_mergeh(b.val, d.val)); + bd = vec_add(bd, vec_sld(bd, bd, 8)); + return v_float32x4(vec_mergeh(ac, bd)); +} + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + const vec_uint4 zero4 = vec_uint4_z; + vec_uint4 sum4 = vec_sum4s(vec_absd(a.val, b.val), zero4); + return (unsigned)vec_extract(vec_sums(vec_int4_c(sum4), vec_int4_c(zero4)), 3); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + const vec_int4 zero4 = vec_int4_z; + vec_char16 ad = vec_abss(vec_subs(a.val, b.val)); + vec_int4 sum4 = vec_sum4s(ad, zero4); + return (unsigned)vec_extract(vec_sums(sum4, zero4), 3); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + vec_ushort8 ad = vec_absd(a.val, b.val); + VSX_UNUSED(vec_int4) sum = vec_sums(vec_int4_c(vec_unpackhu(ad)) + vec_int4_c(vec_unpacklu(ad)), vec_int4_z); + return (unsigned)vec_extract(sum, 3); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + const vec_int4 zero4 = vec_int4_z; + vec_short8 ad = vec_abss(vec_subs(a.val, b.val)); + vec_int4 sum4 = vec_sum4s(ad, zero4); + return (unsigned)vec_extract(vec_sums(sum4, zero4), 3); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + const vec_uint4 ad = vec_absd(a.val, b.val); + const vec_uint4 rd = vec_add(ad, vec_sld(ad, ad, 8)); + return vec_extract(vec_add(rd, vec_sld(rd, rd, 4)), 0); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + vec_int4 ad = vec_abss(vec_sub(a.val, b.val)); + return (unsigned)vec_extract(vec_sums(ad, vec_int4_z), 3); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + const vec_float4 ad = vec_abs(vec_sub(a.val, b.val)); + const vec_float4 rd = vec_add(ad, vec_sld(ad, ad, 8)); + return vec_extract(vec_add(rd, vec_sld(rd, rd, 4)), 0); +} + +/** Popcount **/ +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ return v_uint8x16(vec_popcntu(a.val)); } +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_uint8x16(vec_popcntu(a.val)); } +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ return v_uint16x8(vec_popcntu(a.val)); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_uint16x8(vec_popcntu(a.val)); } +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ return v_uint32x4(vec_popcntu(a.val)); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_uint32x4(vec_popcntu(a.val)); } +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ return v_uint64x2(vec_popcntu(a.val)); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_uint64x2(vec_popcntu(a.val)); } + +/** Mask **/ +inline int v_signmask(const v_uint8x16& a) +{ + static const vec_uchar16 qperm = {120, 112, 104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0}; + return vec_extract((vec_int4)vec_vbpermq(v_reinterpret_as_u8(a).val, qperm), 2); +} +inline int v_signmask(const v_int8x16& a) +{ return v_signmask(v_reinterpret_as_u8(a)); } + +inline int v_signmask(const v_int16x8& a) +{ + static const vec_uchar16 qperm = {112, 96, 80, 64, 48, 32, 16, 0, 128, 128, 128, 128, 128, 128, 128, 128}; + return vec_extract((vec_int4)vec_vbpermq(v_reinterpret_as_u8(a).val, qperm), 2); +} +inline int v_signmask(const v_uint16x8& a) +{ return v_signmask(v_reinterpret_as_s16(a)); } + +inline int v_signmask(const v_int32x4& a) +{ + static const vec_uchar16 qperm = {96, 64, 32, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}; + return vec_extract((vec_int4)vec_vbpermq(v_reinterpret_as_u8(a).val, qperm), 2); +} +inline int v_signmask(const v_uint32x4& a) +{ return v_signmask(v_reinterpret_as_s32(a)); } +inline int v_signmask(const v_float32x4& a) +{ return v_signmask(v_reinterpret_as_s32(a)); } + +inline int v_signmask(const v_int64x2& a) +{ + VSX_UNUSED(const vec_dword2) sv = vec_sr(a.val, vec_udword2_sp(63)); + return (int)vec_extract(sv, 0) | (int)vec_extract(sv, 1) << 1; +} +inline int v_signmask(const v_uint64x2& a) +{ return v_signmask(v_reinterpret_as_s64(a)); } +inline int v_signmask(const v_float64x2& a) +{ return v_signmask(v_reinterpret_as_s64(a)); } + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(a)); } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(a)); } + +template +inline bool v_check_all(const _Tpvec& a) +{ return vec_all_lt(a.val, _Tpvec::zero().val); } +inline bool v_check_all(const v_uint8x16& a) +{ return v_check_all(v_reinterpret_as_s8(a)); } +inline bool v_check_all(const v_uint16x8& a) +{ return v_check_all(v_reinterpret_as_s16(a)); } +inline bool v_check_all(const v_uint32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_uint64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } +inline bool v_check_all(const v_float32x4& a) +{ return v_check_all(v_reinterpret_as_s32(a)); } +inline bool v_check_all(const v_float64x2& a) +{ return v_check_all(v_reinterpret_as_s64(a)); } + +template +inline bool v_check_any(const _Tpvec& a) +{ return vec_any_lt(a.val, _Tpvec::zero().val); } +inline bool v_check_any(const v_uint8x16& a) +{ return v_check_any(v_reinterpret_as_s8(a)); } +inline bool v_check_any(const v_uint16x8& a) +{ return v_check_any(v_reinterpret_as_s16(a)); } +inline bool v_check_any(const v_uint32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_uint64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } +inline bool v_check_any(const v_float32x4& a) +{ return v_check_any(v_reinterpret_as_s32(a)); } +inline bool v_check_any(const v_float64x2& a) +{ return v_check_any(v_reinterpret_as_s64(a)); } + +////////// Other math ///////// + +/** Some frequent operations **/ +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ return v_float32x4(vec_sqrt(x.val)); } +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ return v_float64x2(vec_sqrt(x.val)); } + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ return v_float32x4(vec_rsqrt(x.val)); } +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ return v_float64x2(vec_rsqrt(x.val)); } + +#define OPENCV_HAL_IMPL_VSX_MULADD(_Tpvec) \ +inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_sqrt(vec_madd(a.val, a.val, vec_mul(b.val, b.val)))); } \ +inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(vec_madd(a.val, a.val, vec_mul(b.val, b.val))); } \ +inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ return _Tpvec(vec_madd(a.val, b.val, c.val)); } \ +inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ return _Tpvec(vec_madd(a.val, b.val, c.val)); } + +OPENCV_HAL_IMPL_VSX_MULADD(v_float32x4) +OPENCV_HAL_IMPL_VSX_MULADD(v_float64x2) + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ return a * b + c; } + +// TODO: exp, log, sin, cos + +/** Absolute values **/ +inline v_uint8x16 v_abs(const v_int8x16& x) +{ return v_uint8x16(vec_uchar16_c(vec_abs(x.val))); } + +inline v_uint16x8 v_abs(const v_int16x8& x) +{ return v_uint16x8(vec_ushort8_c(vec_abs(x.val))); } + +inline v_uint32x4 v_abs(const v_int32x4& x) +{ return v_uint32x4(vec_uint4_c(vec_abs(x.val))); } + +inline v_float32x4 v_abs(const v_float32x4& x) +{ return v_float32x4(vec_abs(x.val)); } + +inline v_float64x2 v_abs(const v_float64x2& x) +{ return v_float64x2(vec_abs(x.val)); } + +/** Absolute difference **/ +// unsigned +OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_absdiff, vec_absd) + +inline v_uint8x16 v_absdiff(const v_int8x16& a, const v_int8x16& b) +{ return v_reinterpret_as_u8(v_sub_wrap(v_max(a, b), v_min(a, b))); } +inline v_uint16x8 v_absdiff(const v_int16x8& a, const v_int16x8& b) +{ return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); } +inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b) +{ return v_reinterpret_as_u32(v_max(a, b) - v_min(a, b)); } + +inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b) +{ return v_abs(a - b); } +inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b) +{ return v_abs(a - b); } + +/** Absolute difference for signed integers **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ return v_int8x16(vec_abss(vec_subs(a.val, b.val))); } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_int16x8(vec_abss(vec_subs(a.val, b.val))); } + +////////// Conversions ///////// + +/** Rounding **/ +inline v_int32x4 v_round(const v_float32x4& a) +{ return v_int32x4(vec_cts(vec_rint(a.val))); } + +inline v_int32x4 v_round(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_rint(a.val)), vec_int4_z)); } + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_rint(a.val)), vec_ctso(vec_rint(b.val)))); } + +inline v_int32x4 v_floor(const v_float32x4& a) +{ return v_int32x4(vec_cts(vec_floor(a.val))); } + +inline v_int32x4 v_floor(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_floor(a.val)), vec_int4_z)); } + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ return v_int32x4(vec_cts(vec_ceil(a.val))); } + +inline v_int32x4 v_ceil(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(vec_ceil(a.val)), vec_int4_z)); } + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(vec_cts(a.val)); } + +inline v_int32x4 v_trunc(const v_float64x2& a) +{ return v_int32x4(vec_mergesqo(vec_ctso(a.val), vec_int4_z)); } + +/** To float **/ +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ return v_float32x4(vec_ctf(a.val)); } + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ return v_float32x4(vec_mergesqo(vec_cvfo(a.val), vec_float4_z)); } + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ return v_float32x4(vec_mergesqo(vec_cvfo(a.val), vec_cvfo(b.val))); } + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ return v_float64x2(vec_ctdo(vec_mergeh(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ return v_float64x2(vec_ctdo(vec_mergel(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ return v_float64x2(vec_cvfo(vec_mergeh(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ return v_float64x2(vec_cvfo(vec_mergel(a.val, a.val))); } + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ return v_float64x2(vec_ctd(a.val)); } + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]]); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + return v_reinterpret_as_s8(v_int16x8(*(const short*)(tab+idx[0]), *(const short*)(tab+idx[1]), *(const short*)(tab+idx[2]), *(const short*)(tab+idx[3]), + *(const short*)(tab+idx[4]), *(const short*)(tab+idx[5]), *(const short*)(tab+idx[6]), *(const short*)(tab+idx[7]))); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + return v_reinterpret_as_s8(v_int32x4(*(const int*)(tab+idx[0]), *(const int*)(tab+idx[1]), *(const int*)(tab+idx[2]), *(const int*)(tab+idx[3]))); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((const schar*)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((const schar*)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((const schar*)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + return v_reinterpret_as_s16(v_int32x4(*(const int*)(tab + idx[0]), *(const int*)(tab + idx[1]), *(const int*)(tab + idx[2]), *(const int*)(tab + idx[3]))); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_reinterpret_as_s16(v_int64x2(*(const int64*)(tab + idx[0]), *(const int64*)(tab + idx[1]))); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((const short*)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((const short*)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((const short*)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + return v_int32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_reinterpret_as_s32(v_int64x2(*(const int64*)(tab + idx[0]), *(const int64*)(tab + idx[1]))); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(vsx_ld(0, tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((const int*)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((const int*)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((const int*)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(vsx_ld2(0, tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_pairs((const int*)tab, idx)); } +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) { return v_load(tab + *idx); } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) { return v_load(tab + *idx); } + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + const int idx[4] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1), + vec_extract(idxvec.val, 2), + vec_extract(idxvec.val, 3) + }; + return v_int32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + const int idx[4] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1), + vec_extract(idxvec.val, 2), + vec_extract(idxvec.val, 3) + }; + return v_uint32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + const int idx[4] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1), + vec_extract(idxvec.val, 2), + vec_extract(idxvec.val, 3) + }; + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + const int idx[2] = { + vec_extract(idxvec.val, 0), + vec_extract(idxvec.val, 1) + }; + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} + +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + vec_float4 xy0 = vec_ld_l8(tab + vec_extract(idxvec.val, 0)); + vec_float4 xy1 = vec_ld_l8(tab + vec_extract(idxvec.val, 1)); + vec_float4 xy2 = vec_ld_l8(tab + vec_extract(idxvec.val, 2)); + vec_float4 xy3 = vec_ld_l8(tab + vec_extract(idxvec.val, 3)); + vec_float4 xy02 = vec_mergeh(xy0, xy2); // x0, x2, y0, y2 + vec_float4 xy13 = vec_mergeh(xy1, xy3); // x1, x3, y1, y3 + x.val = vec_mergeh(xy02, xy13); + y.val = vec_mergel(xy02, xy13); +} +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + vec_double2 xy0 = vsx_ld(vec_extract(idxvec.val, 0), tab); + vec_double2 xy1 = vsx_ld(vec_extract(idxvec.val, 1), tab); + x.val = vec_mergeh(xy0, xy1); + y.val = vec_mergel(xy0, xy1); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + static const vec_uchar16 perm = {0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15}; + return v_int8x16(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } + +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + static const vec_uchar16 perm = {0, 4, 1, 5, 2, 6, 3, 7, 8, 12, 9, 13, 10, 14, 11, 15}; + return v_int8x16(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + static const vec_uchar16 perm = {0,1, 4,5, 2,3, 6,7, 8,9, 12,13, 10,11, 14,15}; + return v_int16x8(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) +{ return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } + +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + static const vec_uchar16 perm = {0,1, 8,9, 2,3, 10,11, 4,5, 12,13, 6,7, 14,15}; + return v_int16x8(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) +{ return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + static const vec_uchar16 perm = {0,1,2,3, 8,9,10,11, 4,5,6,7, 12,13,14,15}; + return v_int32x4(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) +{ return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) +{ return v_reinterpret_as_f32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + static const vec_uchar16 perm = {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15, 15, 15, 15}; + return v_int8x16(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) +{ return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + static const vec_uchar16 perm = {0,1, 2,3, 4,5, 8,9, 10,11, 12,13, 14,15, 14,15}; + return v_int16x8(vec_perm(vec.val, vec.val, perm)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) +{ return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) +{ return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) +{ return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) +{ return vec; } + +/////// FP16 support //////// + +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + vec_ushort8 vf16 = vec_ld_l8((const ushort*)ptr); +#if CV_VSX3 && defined(vec_extract_fp_from_shorth) + return v_float32x4(vec_extract_fp_from_shorth(vf16)); +#elif CV_VSX3 && !defined(CV_COMPILER_VSX_BROKEN_ASM) + vec_float4 vf32; + __asm__ __volatile__ ("xvcvhpsp %x0,%x1" : "=wa" (vf32) : "wa" (vec_mergeh(vf16, vf16))); + return v_float32x4(vf32); +#else + const vec_int4 z = vec_int4_z, delta = vec_int4_sp(0x38000000); + const vec_int4 signmask = vec_int4_sp(0x80000000); + const vec_int4 maxexp = vec_int4_sp(0x7c000000); + const vec_float4 deltaf = vec_float4_c(vec_int4_sp(0x38800000)); + + vec_int4 bits = vec_int4_c(vec_mergeh(vec_short8_c(z), vec_short8_c(vf16))); + vec_int4 e = vec_and(bits, maxexp), sign = vec_and(bits, signmask); + vec_int4 t = vec_add(vec_sr(vec_xor(bits, sign), vec_uint4_sp(3)), delta); // ((h & 0x7fff) << 13) + delta + vec_int4 zt = vec_int4_c(vec_sub(vec_float4_c(vec_add(t, vec_int4_sp(1 << 23))), deltaf)); + + t = vec_add(t, vec_and(delta, vec_cmpeq(maxexp, e))); + vec_bint4 zmask = vec_cmpeq(e, z); + vec_int4 ft = vec_sel(t, zt, zmask); + return v_float32x4(vec_float4_c(vec_or(ft, sign))); +#endif +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ +// fixme: Is there any builtin op or intrinsic that cover "xvcvsphp"? +#if CV_VSX3 && !defined(CV_COMPILER_VSX_BROKEN_ASM) + vec_ushort8 vf16; + __asm__ __volatile__ ("xvcvsphp %x0,%x1" : "=wa" (vf16) : "wa" (v.val)); + vec_st_l8(vec_mergesqe(vf16, vf16), ptr); +#else + const vec_int4 signmask = vec_int4_sp(0x80000000); + const vec_int4 rval = vec_int4_sp(0x3f000000); + + vec_int4 t = vec_int4_c(v.val); + vec_int4 sign = vec_sra(vec_and(t, signmask), vec_uint4_sp(16)); + t = vec_and(vec_nor(signmask, signmask), t); + + vec_bint4 finitemask = vec_cmpgt(vec_int4_sp(0x47800000), t); + vec_bint4 isnan = vec_cmpgt(t, vec_int4_sp(0x7f800000)); + vec_int4 naninf = vec_sel(vec_int4_sp(0x7c00), vec_int4_sp(0x7e00), isnan); + vec_bint4 tinymask = vec_cmpgt(vec_int4_sp(0x38800000), t); + vec_int4 tt = vec_int4_c(vec_add(vec_float4_c(t), vec_float4_c(rval))); + tt = vec_sub(tt, rval); + vec_int4 odd = vec_and(vec_sr(t, vec_uint4_sp(13)), vec_int4_sp(1)); + vec_int4 nt = vec_add(t, vec_int4_sp(0xc8000fff)); + nt = vec_sr(vec_add(nt, odd), vec_uint4_sp(13)); + t = vec_sel(nt, tt, tinymask); + t = vec_sel(naninf, t, finitemask); + t = vec_or(t, sign); + vec_st_l8(vec_packs(t, t), ptr); +#endif +} + +inline void v_cleanup() {} + + +/** Reinterpret **/ +/** its up there with load and store operations **/ + +////////// Matrix operations ///////// + +//////// Dot Product //////// +// 16 >> 32 +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)); } +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_int32x4(vec_msum(a.val, b.val, c.val)); } + +// 32 >> 64 +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + vec_dword2 even = vec_mule(a.val, b.val); + vec_dword2 odd = vec_mulo(a.val, b.val); + return v_int64x2(vec_add(even, odd)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b) + c; } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_uint32x4(vec_msum(a.val, b.val, c.val)); } +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)); } + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + const vec_ushort8 eight = vec_ushort8_sp(8); + vec_short8 a0 = vec_sra((vec_short8)vec_sld(a.val, a.val, 1), eight); // even + vec_short8 a1 = vec_sra((vec_short8)a.val, eight); // odd + vec_short8 b0 = vec_sra((vec_short8)vec_sld(b.val, b.val, 1), eight); + vec_short8 b1 = vec_sra((vec_short8)b.val, eight); + return v_int32x4(vec_msum(a0, b0, vec_msum(a1, b1, vec_int4_z))); +} + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ + const vec_ushort8 eight = vec_ushort8_sp(8); + vec_short8 a0 = vec_sra((vec_short8)vec_sld(a.val, a.val, 1), eight); // even + vec_short8 a1 = vec_sra((vec_short8)a.val, eight); // odd + vec_short8 b0 = vec_sra((vec_short8)vec_sld(b.val, b.val, 1), eight); + vec_short8 b1 = vec_sra((vec_short8)b.val, eight); + return v_int32x4(vec_msum(a0, b0, vec_msum(a1, b1, c.val))); +} + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + const vec_uint4 zero = vec_uint4_z; + vec_uint4 even = vec_mule(a.val, b.val); + vec_uint4 odd = vec_mulo(a.val, b.val); + vec_udword2 e0 = (vec_udword2)vec_mergee(even, zero); + vec_udword2 e1 = (vec_udword2)vec_mergeo(even, zero); + vec_udword2 o0 = (vec_udword2)vec_mergee(odd, zero); + vec_udword2 o1 = (vec_udword2)vec_mergeo(odd, zero); + vec_udword2 s0 = vec_add(e0, o0); + vec_udword2 s1 = vec_add(e1, o1); + return v_uint64x2(vec_add(s0, s1)); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return v_int64x2(vec_add(vec_mergeh(c.val, d.val), vec_mergel(c.val, d.val))); +} +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; } +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; } + +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ + vec_short8 a0 = vec_unpackh(a.val); + vec_short8 a1 = vec_unpackl(a.val); + vec_short8 b0 = vec_unpackh(b.val); + vec_short8 b1 = vec_unpackl(b.val); + return v_int32x4(vec_msum(a0, b0, vec_msum(a1, b1, vec_int4_z))); +} +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 prod = v_dotprod(a, b); + v_int64x2 c, d; + v_expand(prod, c, d); + return c + d; +} +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand_fast(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b, c); } + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + const vec_float4 v0 = vec_splat(v.val, 0); + const vec_float4 v1 = vec_splat(v.val, 1); + const vec_float4 v2 = vec_splat(v.val, 2); + VSX_UNUSED(const vec_float4) v3 = vec_splat(v.val, 3); + return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, vec_mul(v3, m3.val))))); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + const vec_float4 v0 = vec_splat(v.val, 0); + const vec_float4 v1 = vec_splat(v.val, 1); + const vec_float4 v2 = vec_splat(v.val, 2); + return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, a.val)))); +} + +#define OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(_Tpvec, _Tpvec2) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \ +{ \ + _Tpvec2 a02 = vec_mergeh(a0.val, a2.val); \ + _Tpvec2 a13 = vec_mergeh(a1.val, a3.val); \ + b0.val = vec_mergeh(a02, a13); \ + b1.val = vec_mergel(a02, a13); \ + a02 = vec_mergel(a0.val, a2.val); \ + a13 = vec_mergel(a1.val, a3.val); \ + b2.val = vec_mergeh(a02, a13); \ + b3.val = vec_mergel(a02, a13); \ +} +OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_uint32x4, vec_uint4) +OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_int32x4, vec_int4) +OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_float32x4, vec_float4) + +template +inline Tvec v_broadcast_element(const Tvec& v) +{ return Tvec(vec_splat(v.val, i)); } + + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif // OPENCV_HAL_VSX_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_wasm.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_wasm.hpp new file mode 100644 index 0000000..b4178af --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/intrin_wasm.hpp @@ -0,0 +1,2782 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_HAL_INTRIN_WASM_HPP +#define OPENCV_HAL_INTRIN_WASM_HPP + +#include +#include +#include +#include "opencv2/core/saturate.hpp" + +#define CV_SIMD128 1 +#define CV_SIMD128_64F 0 // Now all implementation of f64 use fallback, so disable it. +#define CV_SIMD128_FP16 0 + +namespace cv +{ + +//! @cond IGNORED + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN + +#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) < (1038046) +// handle renames: https://github.com/emscripten-core/emscripten/pull/9440 (https://github.com/emscripten-core/emscripten/commit/755d5b46cb84d0aa120c10981b11d05646c29673) +#define wasm_i32x4_trunc_saturate_f32x4 wasm_trunc_saturate_i32x4_f32x4 +#define wasm_u32x4_trunc_saturate_f32x4 wasm_trunc_saturate_u32x4_f32x4 +#define wasm_i64x2_trunc_saturate_f64x2 wasm_trunc_saturate_i64x2_f64x2 +#define wasm_u64x2_trunc_saturate_f64x2 wasm_trunc_saturate_u64x2_f64x2 +#define wasm_f32x4_convert_i32x4 wasm_convert_f32x4_i32x4 +#define wasm_f32x4_convert_u32x4 wasm_convert_f32x4_u32x4 +#define wasm_f64x2_convert_i64x2 wasm_convert_f64x2_i64x2 +#define wasm_f64x2_convert_u64x2 wasm_convert_f64x2_u64x2 +#endif // COMPATIBILITY: <1.38.46 + +///////// Types /////////// + +struct v_uint8x16 +{ + typedef uchar lane_type; + typedef v128_t vector_type; + enum { nlanes = 16 }; + + v_uint8x16() {} + explicit v_uint8x16(v128_t v) : val(v) {} + v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7, + uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15) + { + uchar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = wasm_v128_load(v); + } + + uchar get0() const + { + return (uchar)wasm_i8x16_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_int8x16 +{ + typedef schar lane_type; + typedef v128_t vector_type; + enum { nlanes = 16 }; + + v_int8x16() {} + explicit v_int8x16(v128_t v) : val(v) {} + v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7, + schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15) + { + schar v[] = {v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15}; + val = wasm_v128_load(v); + } + + schar get0() const + { + return wasm_i8x16_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_uint16x8 +{ + typedef ushort lane_type; + typedef v128_t vector_type; + enum { nlanes = 8 }; + + v_uint16x8() {} + explicit v_uint16x8(v128_t v) : val(v) {} + v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7) + { + ushort v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = wasm_v128_load(v); + } + + ushort get0() const + { + return (ushort)wasm_i16x8_extract_lane(val, 0); // wasm_u16x8_extract_lane() unimplemented yet + } + + v128_t val; +}; + +struct v_int16x8 +{ + typedef short lane_type; + typedef v128_t vector_type; + enum { nlanes = 8 }; + + v_int16x8() {} + explicit v_int16x8(v128_t v) : val(v) {} + v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7) + { + short v[] = {v0, v1, v2, v3, v4, v5, v6, v7}; + val = wasm_v128_load(v); + } + + short get0() const + { + return wasm_i16x8_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_uint32x4 +{ + typedef unsigned lane_type; + typedef v128_t vector_type; + enum { nlanes = 4 }; + + v_uint32x4() {} + explicit v_uint32x4(v128_t v) : val(v) {} + v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) + { + unsigned v[] = {v0, v1, v2, v3}; + val = wasm_v128_load(v); + } + + unsigned get0() const + { + return (unsigned)wasm_i32x4_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_int32x4 +{ + typedef int lane_type; + typedef v128_t vector_type; + enum { nlanes = 4 }; + + v_int32x4() {} + explicit v_int32x4(v128_t v) : val(v) {} + v_int32x4(int v0, int v1, int v2, int v3) + { + int v[] = {v0, v1, v2, v3}; + val = wasm_v128_load(v); + } + + int get0() const + { + return wasm_i32x4_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_float32x4 +{ + typedef float lane_type; + typedef v128_t vector_type; + enum { nlanes = 4 }; + + v_float32x4() {} + explicit v_float32x4(v128_t v) : val(v) {} + v_float32x4(float v0, float v1, float v2, float v3) + { + float v[] = {v0, v1, v2, v3}; + val = wasm_v128_load(v); + } + + float get0() const + { + return wasm_f32x4_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_uint64x2 +{ + typedef uint64 lane_type; + typedef v128_t vector_type; + enum { nlanes = 2 }; + + v_uint64x2() {} + explicit v_uint64x2(v128_t v) : val(v) {} + v_uint64x2(uint64 v0, uint64 v1) + { + uint64 v[] = {v0, v1}; + val = wasm_v128_load(v); + } + + uint64 get0() const + { + return (uint64)wasm_i64x2_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_int64x2 +{ + typedef int64 lane_type; + typedef v128_t vector_type; + enum { nlanes = 2 }; + + v_int64x2() {} + explicit v_int64x2(v128_t v) : val(v) {} + v_int64x2(int64 v0, int64 v1) + { + int64 v[] = {v0, v1}; + val = wasm_v128_load(v); + } + + int64 get0() const + { + return wasm_i64x2_extract_lane(val, 0); + } + + v128_t val; +}; + +struct v_float64x2 +{ + typedef double lane_type; + typedef v128_t vector_type; + enum { nlanes = 2 }; + + v_float64x2() {} + explicit v_float64x2(v128_t v) : val(v) {} + v_float64x2(double v0, double v1) + { + double v[] = {v0, v1}; + val = wasm_v128_load(v); + } + + double get0() const + { + return wasm_f64x2_extract_lane(val, 0); + } + + v128_t val; +}; + +namespace +{ +#define OPENCV_HAL_IMPL_REINTERPRET_INT(ft, tt) \ +inline tt reinterpret_int(ft x) { union { ft l; tt i; } v; v.l = x; return v.i; } +OPENCV_HAL_IMPL_REINTERPRET_INT(uchar, schar) +OPENCV_HAL_IMPL_REINTERPRET_INT(schar, schar) +OPENCV_HAL_IMPL_REINTERPRET_INT(ushort, short) +OPENCV_HAL_IMPL_REINTERPRET_INT(short, short) +OPENCV_HAL_IMPL_REINTERPRET_INT(unsigned, int) +OPENCV_HAL_IMPL_REINTERPRET_INT(int, int) +OPENCV_HAL_IMPL_REINTERPRET_INT(float, int) +OPENCV_HAL_IMPL_REINTERPRET_INT(uint64, int64) +OPENCV_HAL_IMPL_REINTERPRET_INT(int64, int64) +OPENCV_HAL_IMPL_REINTERPRET_INT(double, int64) + +static const unsigned char popCountTable[] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, +}; +} // namespace + +static v128_t wasm_unpacklo_i8x16(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,16,1,17,2,18,3,19,4,20,5,21,6,22,7,23); +} + +static v128_t wasm_unpacklo_i16x8(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,1,16,17,2,3,18,19,4,5,20,21,6,7,22,23); +} + +static v128_t wasm_unpacklo_i32x4(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,1,2,3,16,17,18,19,4,5,6,7,20,21,22,23); +} + +static v128_t wasm_unpacklo_i64x2(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); +} + +static v128_t wasm_unpackhi_i8x16(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,24,9,25,10,26,11,27,12,28,13,29,14,30,15,31); +} + +static v128_t wasm_unpackhi_i16x8(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,9,24,25,10,11,26,27,12,13,28,29,14,15,30,31); +} + +static v128_t wasm_unpackhi_i32x4(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,9,10,11,24,25,26,27,12,13,14,15,28,29,30,31); +} + +static v128_t wasm_unpackhi_i64x2(v128_t a, v128_t b) { + return wasm_v8x16_shuffle(a, b, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); +} + +/** Convert **/ +// 8 >> 16 +inline v128_t v128_cvtu8x16_i16x8(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i8x16(a, z); +} +inline v128_t v128_cvti8x16_i16x8(const v128_t& a) +{ return wasm_i16x8_shr(wasm_unpacklo_i8x16(a, a), 8); } +// 8 >> 32 +inline v128_t v128_cvtu8x16_i32x4(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i16x8(wasm_unpacklo_i8x16(a, z), z); +} +inline v128_t v128_cvti8x16_i32x4(const v128_t& a) +{ + v128_t r = wasm_unpacklo_i8x16(a, a); + r = wasm_unpacklo_i8x16(r, r); + return wasm_i32x4_shr(r, 24); +} +// 16 >> 32 +inline v128_t v128_cvtu16x8_i32x4(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i16x8(a, z); +} +inline v128_t v128_cvti16x8_i32x4(const v128_t& a) +{ return wasm_i32x4_shr(wasm_unpacklo_i16x8(a, a), 16); } +// 32 >> 64 +inline v128_t v128_cvtu32x4_i64x2(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpacklo_i32x4(a, z); +} +inline v128_t v128_cvti32x4_i64x2(const v128_t& a) +{ return wasm_unpacklo_i32x4(a, wasm_i32x4_shr(a, 31)); } + +// 16 << 8 +inline v128_t v128_cvtu8x16_i16x8_high(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpackhi_i8x16(a, z); +} +inline v128_t v128_cvti8x16_i16x8_high(const v128_t& a) +{ return wasm_i16x8_shr(wasm_unpackhi_i8x16(a, a), 8); } +// 32 << 16 +inline v128_t v128_cvtu16x8_i32x4_high(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpackhi_i16x8(a, z); +} +inline v128_t v128_cvti16x8_i32x4_high(const v128_t& a) +{ return wasm_i32x4_shr(wasm_unpackhi_i16x8(a, a), 16); } +// 64 << 32 +inline v128_t v128_cvtu32x4_i64x2_high(const v128_t& a) +{ + const v128_t z = wasm_i8x16_splat(0); + return wasm_unpackhi_i32x4(a, z); +} +inline v128_t v128_cvti32x4_i64x2_high(const v128_t& a) +{ return wasm_unpackhi_i32x4(a, wasm_i32x4_shr(a, 31)); } + +#define OPENCV_HAL_IMPL_WASM_INITVEC(_Tpvec, _Tp, suffix, zsuffix, _Tps) \ +inline _Tpvec v_setzero_##suffix() { return _Tpvec(wasm_##zsuffix##_splat((_Tps)0)); } \ +inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(wasm_##zsuffix##_splat((_Tps)v)); } \ +template inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0& a) \ +{ return _Tpvec(a.val); } + +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint8x16, uchar, u8, i8x16, schar) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int8x16, schar, s8, i8x16, schar) +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint16x8, ushort, u16, i16x8, short) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int16x8, short, s16, i16x8, short) +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint32x4, unsigned, u32, i32x4, int) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int32x4, int, s32, i32x4, int) +OPENCV_HAL_IMPL_WASM_INITVEC(v_float32x4, float, f32, f32x4, float) +OPENCV_HAL_IMPL_WASM_INITVEC(v_uint64x2, uint64, u64, i64x2, int64) +OPENCV_HAL_IMPL_WASM_INITVEC(v_int64x2, int64, s64, i64x2, int64) +OPENCV_HAL_IMPL_WASM_INITVEC(v_float64x2, double, f64, f64x2, double) + +//////////////// PACK /////////////// +inline v_uint8x16 v_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u16x8_gt(b.val, maxval)); + return v_uint8x16(wasm_v8x16_shuffle(a1, b1, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +inline v_int8x16 v_pack(const v_int16x8& a, const v_int16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i16x8_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i16x8_lt(b1, minval)); + return v_int8x16(wasm_v8x16_shuffle(a2, b2, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +inline v_uint16x8 v_pack(const v_uint32x4& a, const v_uint32x4& b) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u32x4_gt(b.val, maxval)); + return v_uint16x8(wasm_v8x16_shuffle(a1, b1, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +inline v_int16x8 v_pack(const v_int32x4& a, const v_int32x4& b) +{ + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i32x4_splat(-32768); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i32x4_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i32x4_lt(b1, minval)); + return v_int16x8(wasm_v8x16_shuffle(a2, b2, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +inline v_uint32x4 v_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + return v_uint32x4(wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +inline v_int32x4 v_pack(const v_int64x2& a, const v_int64x2& b) +{ + return v_int32x4(wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +inline v_uint8x16 v_pack_u(const v_int16x8& a, const v_int16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i16x8_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i16x8_lt(b1, minval)); + return v_uint8x16(wasm_v8x16_shuffle(a2, b2, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +inline v_uint16x8 v_pack_u(const v_int32x4& a, const v_int32x4& b) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i32x4_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_i32x4_gt(b.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t b2 = wasm_v128_bitselect(minval, b1, wasm_i32x4_lt(b1, minval)); + return v_uint16x8(wasm_v8x16_shuffle(a2, b2, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} + +template +inline v_uint8x16 v_rshr_pack(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_u16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t b1 = wasm_u16x8_shr(wasm_i16x8_add(b.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u16x8_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_u16x8_gt(b1, maxval)); + return v_uint8x16(wasm_v8x16_shuffle(a2, b2, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +template +inline v_int8x16 v_rshr_pack(const v_int16x8& a, const v_int16x8& b) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t b1 = wasm_i16x8_shr(wasm_i16x8_add(b.val, delta), n); + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i16x8_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i16x8_lt(b1, minval)); + return v_int8x16(wasm_v8x16_shuffle(a3, b3, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +template +inline v_uint16x8 v_rshr_pack(const v_uint32x4& a, const v_uint32x4& b) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_u32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t b1 = wasm_u32x4_shr(wasm_i32x4_add(b.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u32x4_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_u32x4_gt(b1, maxval)); + return v_uint16x8(wasm_v8x16_shuffle(a2, b2, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +template +inline v_int16x8 v_rshr_pack(const v_int32x4& a, const v_int32x4& b) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t b1 = wasm_i32x4_shr(wasm_i32x4_add(b.val, delta), n); + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i16x8_splat(-32768); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i32x4_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i32x4_lt(b1, minval)); + return v_int16x8(wasm_v8x16_shuffle(a3, b3, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} +template +inline v_uint32x4 v_rshr_pack(const v_uint64x2& a, const v_uint64x2& b) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_u64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t b1 = wasm_u64x2_shr(wasm_i64x2_add(b.val, delta), n); + return v_uint32x4(wasm_v8x16_shuffle(a1, b1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +template +inline v_int32x4 v_rshr_pack(const v_int64x2& a, const v_int64x2& b) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_i64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t b1 = wasm_i64x2_shr(wasm_i64x2_add(b.val, delta), n); + return v_int32x4(wasm_v8x16_shuffle(a1, b1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27)); +} +template +inline v_uint8x16 v_rshr_pack_u(const v_int16x8& a, const v_int16x8& b) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t b1 = wasm_i16x8_shr(wasm_i16x8_add(b.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i16x8_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i16x8_lt(b1, minval)); + return v_uint8x16(wasm_v8x16_shuffle(a3, b3, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} +template +inline v_uint16x8 v_rshr_pack_u(const v_int32x4& a, const v_int32x4& b) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t b1 = wasm_i32x4_shr(wasm_i32x4_add(b.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i16x8_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t b2 = wasm_v128_bitselect(maxval, b1, wasm_i32x4_gt(b1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t b3 = wasm_v128_bitselect(minval, b2, wasm_i32x4_lt(b1, minval)); + return v_uint16x8(wasm_v8x16_shuffle(a3, b3, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29)); +} + +inline void v_pack_store(uchar* ptr, const v_uint16x8& a) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u16x8_gt(a.val, maxval)); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(schar* ptr, const v_int16x8& a) +{ + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + schar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(ushort* ptr, const v_uint32x4& a) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u32x4_gt(a.val, maxval)); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(short* ptr, const v_int32x4& a) +{ + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i32x4_splat(-32768); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + short t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + v128_t r = wasm_v8x16_shuffle(a.val, a.val, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + unsigned t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_store(int* ptr, const v_int64x2& a) +{ + v128_t r = wasm_v8x16_shuffle(a.val, a.val, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + int t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_u_store(uchar* ptr, const v_int16x8& a) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i16x8_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +inline void v_pack_u_store(ushort* ptr, const v_int32x4& a) +{ + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i32x4_splat(0); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_i32x4_gt(a.val, maxval)); + v128_t a2 = wasm_v128_bitselect(minval, a1, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} + +template +inline void v_rshr_pack_store(uchar* ptr, const v_uint16x8& a) +{ + v128_t delta = wasm_i16x8_splat((short)(1 << (n-1))); + v128_t a1 = wasm_u16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u16x8_gt(a1, maxval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(schar* ptr, const v_int16x8& a) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t maxval = wasm_i16x8_splat(127); + v128_t minval = wasm_i16x8_splat(-128); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + schar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(ushort* ptr, const v_uint32x4& a) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_u32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_u32x4_gt(a1, maxval)); + v128_t r = wasm_v8x16_shuffle(a2, a2, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(short* ptr, const v_int32x4& a) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t maxval = wasm_i32x4_splat(32767); + v128_t minval = wasm_i32x4_splat(-32768); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + short t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(unsigned* ptr, const v_uint64x2& a) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_u64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + unsigned t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_store(int* ptr, const v_int64x2& a) +{ + v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1))); + v128_t a1 = wasm_i64x2_shr(wasm_i64x2_add(a.val, delta), n); + v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11); + int t_ptr[4]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<2; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_u_store(uchar* ptr, const v_int16x8& a) +{ + v128_t delta = wasm_i16x8_splat(((short)1 << (n-1))); + v128_t a1 = wasm_i16x8_shr(wasm_i16x8_add(a.val, delta), n); + v128_t maxval = wasm_i16x8_splat(255); + v128_t minval = wasm_i16x8_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i16x8_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i16x8_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14); + uchar t_ptr[16]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<8; ++i) { + ptr[i] = t_ptr[i]; + } +} +template +inline void v_rshr_pack_u_store(ushort* ptr, const v_int32x4& a) +{ + v128_t delta = wasm_i32x4_splat(((int)1 << (n-1))); + v128_t a1 = wasm_i32x4_shr(wasm_i32x4_add(a.val, delta), n); + v128_t maxval = wasm_i32x4_splat(65535); + v128_t minval = wasm_i32x4_splat(0); + v128_t a2 = wasm_v128_bitselect(maxval, a1, wasm_i32x4_gt(a1, maxval)); + v128_t a3 = wasm_v128_bitselect(minval, a2, wasm_i32x4_lt(a1, minval)); + v128_t r = wasm_v8x16_shuffle(a3, a3, 0,1,4,5,8,9,12,13,0,1,4,5,8,9,12,13); + ushort t_ptr[8]; + wasm_v128_store(t_ptr, r); + for (int i=0; i<4; ++i) { + ptr[i] = t_ptr[i]; + } +} + +inline v_uint8x16 v_pack_b(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t maxval = wasm_i16x8_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u16x8_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u16x8_gt(b.val, maxval)); + return v_uint8x16(wasm_v8x16_shuffle(a1, b1, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30)); +} + +inline v_uint8x16 v_pack_b(const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d) +{ + v128_t maxval = wasm_i32x4_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, wasm_u32x4_gt(a.val, maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, wasm_u32x4_gt(b.val, maxval)); + v128_t c1 = wasm_v128_bitselect(maxval, c.val, wasm_u32x4_gt(c.val, maxval)); + v128_t d1 = wasm_v128_bitselect(maxval, d.val, wasm_u32x4_gt(d.val, maxval)); + v128_t ab = wasm_v8x16_shuffle(a1, b1, 0,4,8,12,16,20,24,28,0,4,8,12,16,20,24,28); + v128_t cd = wasm_v8x16_shuffle(c1, d1, 0,4,8,12,16,20,24,28,0,4,8,12,16,20,24,28); + return v_uint8x16(wasm_v8x16_shuffle(ab, cd, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23)); +} + +inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c, + const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f, + const v_uint64x2& g, const v_uint64x2& h) +{ + v128_t maxval = wasm_i32x4_splat(255); + v128_t a1 = wasm_v128_bitselect(maxval, a.val, ((__u64x2)(a.val) > (__u64x2)maxval)); + v128_t b1 = wasm_v128_bitselect(maxval, b.val, ((__u64x2)(b.val) > (__u64x2)maxval)); + v128_t c1 = wasm_v128_bitselect(maxval, c.val, ((__u64x2)(c.val) > (__u64x2)maxval)); + v128_t d1 = wasm_v128_bitselect(maxval, d.val, ((__u64x2)(d.val) > (__u64x2)maxval)); + v128_t e1 = wasm_v128_bitselect(maxval, e.val, ((__u64x2)(e.val) > (__u64x2)maxval)); + v128_t f1 = wasm_v128_bitselect(maxval, f.val, ((__u64x2)(f.val) > (__u64x2)maxval)); + v128_t g1 = wasm_v128_bitselect(maxval, g.val, ((__u64x2)(g.val) > (__u64x2)maxval)); + v128_t h1 = wasm_v128_bitselect(maxval, h.val, ((__u64x2)(h.val) > (__u64x2)maxval)); + v128_t ab = wasm_v8x16_shuffle(a1, b1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t cd = wasm_v8x16_shuffle(c1, d1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t ef = wasm_v8x16_shuffle(e1, f1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t gh = wasm_v8x16_shuffle(g1, h1, 0,8,16,24,0,8,16,24,0,8,16,24,0,8,16,24); + v128_t abcd = wasm_v8x16_shuffle(ab, cd, 0,1,2,3,16,17,18,19,0,1,2,3,16,17,18,19); + v128_t efgh = wasm_v8x16_shuffle(ef, gh, 0,1,2,3,16,17,18,19,0,1,2,3,16,17,18,19); + return v_uint8x16(wasm_v8x16_shuffle(abcd, efgh, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23)); +} + +inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& m3) +{ + v128_t v0 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 0)); + v128_t v1 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 1)); + v128_t v2 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 2)); + v128_t v3 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 3)); + v0 = wasm_f32x4_mul(v0, m0.val); + v1 = wasm_f32x4_mul(v1, m1.val); + v2 = wasm_f32x4_mul(v2, m2.val); + v3 = wasm_f32x4_mul(v3, m3.val); + + return v_float32x4(wasm_f32x4_add(wasm_f32x4_add(v0, v1), wasm_f32x4_add(v2, v3))); +} + +inline v_float32x4 v_matmuladd(const v_float32x4& v, const v_float32x4& m0, + const v_float32x4& m1, const v_float32x4& m2, + const v_float32x4& a) +{ + v128_t v0 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 0)); + v128_t v1 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 1)); + v128_t v2 = wasm_f32x4_splat(wasm_f32x4_extract_lane(v.val, 2)); + v0 = wasm_f32x4_mul(v0, m0.val); + v1 = wasm_f32x4_mul(v1, m1.val); + v2 = wasm_f32x4_mul(v2, m2.val); + + return v_float32x4(wasm_f32x4_add(wasm_f32x4_add(v0, v1), wasm_f32x4_add(v2, a.val))); +} + +#define OPENCV_HAL_IMPL_WASM_BIN_OP(bin_op, _Tpvec, intrin) \ +inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} \ +inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \ +{ \ + a.val = intrin(a.val, b.val); \ + return a; \ +} + +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint8x16, wasm_u8x16_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint8x16, wasm_u8x16_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int8x16, wasm_i8x16_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int8x16, wasm_i8x16_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint16x8, wasm_u16x8_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint16x8, wasm_u16x8_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int16x8, wasm_i16x8_add_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int16x8, wasm_i16x8_sub_saturate) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint32x4, wasm_i32x4_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint32x4, wasm_i32x4_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_uint32x4, wasm_i32x4_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int32x4, wasm_i32x4_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int32x4, wasm_i32x4_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_int32x4, wasm_i32x4_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_float32x4, wasm_f32x4_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_float32x4, wasm_f32x4_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_float32x4, wasm_f32x4_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(/, v_float32x4, wasm_f32x4_div) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint64x2, wasm_i64x2_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint64x2, wasm_i64x2_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int64x2, wasm_i64x2_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_int64x2, wasm_i64x2_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_float64x2, wasm_f64x2_add) +OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_float64x2, wasm_f64x2_sub) +OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_float64x2, wasm_f64x2_mul) +OPENCV_HAL_IMPL_WASM_BIN_OP(/, v_float64x2, wasm_f64x2_div) + +// saturating multiply 8-bit, 16-bit +#define OPENCV_HAL_IMPL_WASM_MUL_SAT(_Tpvec, _Tpwvec) \ +inline _Tpvec operator * (const _Tpvec& a, const _Tpvec& b) \ +{ \ + _Tpwvec c, d; \ + v_mul_expand(a, b, c, d); \ + return v_pack(c, d); \ +} \ +inline _Tpvec& operator *= (_Tpvec& a, const _Tpvec& b) \ +{ a = a * b; return a; } + +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_uint8x16, v_uint16x8) +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_int8x16, v_int16x8) +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_uint16x8, v_uint32x4) +OPENCV_HAL_IMPL_WASM_MUL_SAT(v_int16x8, v_int32x4) + +// Multiply and expand +inline void v_mul_expand(const v_uint8x16& a, const v_uint8x16& b, + v_uint16x8& c, v_uint16x8& d) +{ + v_uint16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int8x16& a, const v_int8x16& b, + v_int16x8& c, v_int16x8& d) +{ + v_int16x8 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c = v_mul_wrap(a0, b0); + d = v_mul_wrap(a1, b1); +} + +inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, + v_int32x4& c, v_int32x4& d) +{ + v_int32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c.val = wasm_i32x4_mul(a0.val, b0.val); + d.val = wasm_i32x4_mul(a1.val, b1.val); +} + +inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, + v_uint32x4& c, v_uint32x4& d) +{ + v_uint32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c.val = wasm_i32x4_mul(a0.val, b0.val); + d.val = wasm_i32x4_mul(a1.val, b1.val); +} + +inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, + v_uint64x2& c, v_uint64x2& d) +{ + v_uint64x2 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + c.val = ((__u64x2)(a0.val) * (__u64x2)(b0.val)); + d.val = ((__u64x2)(a1.val) * (__u64x2)(b1.val)); +} + +inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b) +{ + v_int32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + v128_t c = wasm_i32x4_mul(a0.val, b0.val); + v128_t d = wasm_i32x4_mul(a1.val, b1.val); + return v_int16x8(wasm_v8x16_shuffle(c, d, 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31)); +} +inline v_uint16x8 v_mul_hi(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 a0, a1, b0, b1; + v_expand(a, a0, a1); + v_expand(b, b0, b1); + v128_t c = wasm_i32x4_mul(a0.val, b0.val); + v128_t d = wasm_i32x4_mul(a1.val, b1.val); + return v_uint16x8(wasm_v8x16_shuffle(c, d, 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31)); +} + +//////// Dot Product //////// + +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b) +{ + v128_t a0 = wasm_i32x4_shr(wasm_i32x4_shl(a.val, 16), 16); + v128_t a1 = wasm_i32x4_shr(a.val, 16); + v128_t b0 = wasm_i32x4_shr(wasm_i32x4_shl(b.val, 16), 16); + v128_t b1 = wasm_i32x4_shr(b.val, 16); + v128_t c = wasm_i32x4_mul(a0, b0); + v128_t d = wasm_i32x4_mul(a1, b1); + return v_int32x4(wasm_i32x4_add(c, d)); +} + +inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b) + c; } + +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b) +{ + v128_t a0 = wasm_i64x2_shr(wasm_i64x2_shl(a.val, 32), 32); + v128_t a1 = wasm_i64x2_shr(a.val, 32); + v128_t b0 = wasm_i64x2_shr(wasm_i64x2_shl(b.val, 32), 32); + v128_t b1 = wasm_i64x2_shr(b.val, 32); + v128_t c = (v128_t)((__i64x2)a0 * (__i64x2)b0); + v128_t d = (v128_t)((__i64x2)a1 * (__i64x2)b1); + return v_int64x2(wasm_i64x2_add(c, d)); +} +inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ + return v_dotprod(a, b) + c; +} + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b) +{ + v128_t a0 = wasm_u16x8_shr(wasm_i16x8_shl(a.val, 8), 8); + v128_t a1 = wasm_u16x8_shr(a.val, 8); + v128_t b0 = wasm_u16x8_shr(wasm_i16x8_shl(b.val, 8), 8); + v128_t b1 = wasm_u16x8_shr(b.val, 8); + return v_uint32x4(( + v_dotprod(v_int16x8(a0), v_int16x8(b0)) + + v_dotprod(v_int16x8(a1), v_int16x8(b1))).val + ); +} +inline v_uint32x4 v_dotprod_expand(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b) +{ + v128_t a0 = wasm_i16x8_shr(wasm_i16x8_shl(a.val, 8), 8); + v128_t a1 = wasm_i16x8_shr(a.val, 8); + v128_t b0 = wasm_i16x8_shr(wasm_i16x8_shl(b.val, 8), 8); + v128_t b1 = wasm_i16x8_shr(b.val, 8); + return v_int32x4( + v_dotprod(v_int16x8(a0), v_int16x8(b0)) + + v_dotprod(v_int16x8(a1), v_int16x8(b1)) + ); +} +inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b) + c; } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b) +{ + v128_t a0 = wasm_u32x4_shr(wasm_i32x4_shl(a.val, 16), 16); + v128_t a1 = wasm_u32x4_shr(a.val, 16); + v128_t b0 = wasm_u32x4_shr(wasm_i32x4_shl(b.val, 16), 16); + v128_t b1 = wasm_u32x4_shr(b.val, 16); + return v_uint64x2(( + v_dotprod(v_int32x4(a0), v_int32x4(b0)) + + v_dotprod(v_int32x4(a1), v_int32x4(b1))).val + ); +} +inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b) +{ + v128_t a0 = wasm_i32x4_shr(wasm_i32x4_shl(a.val, 16), 16); + v128_t a1 = wasm_i32x4_shr(a.val, 16); + v128_t b0 = wasm_i32x4_shr(wasm_i32x4_shl(b.val, 16), 16); + v128_t b1 = wasm_i32x4_shr(b.val, 16); + return v_int64x2(( + v_dotprod(v_int32x4(a0), v_int32x4(b0)) + + v_dotprod(v_int32x4(a1), v_int32x4(b1))) + ); +} + +inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b) +{ return v_cvt_f64(v_dotprod(a, b)); } +inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b) + c; } + +//////// Fast Dot Product //////// + +// 16 >> 32 +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod(a, b); } +inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c) +{ return v_dotprod(a, b, c); } + +// 32 >> 64 +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod(a, b); } +inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c) +{ return v_dotprod(a, b, c); } + +// 8 >> 32 +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b) +{ return v_dotprod_expand(a, b); } +inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b, const v_int32x4& c) +{ return v_dotprod_expand(a, b, c); } + +// 16 >> 64 +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_uint64x2 v_dotprod_expand_fast(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c) +{ return v_dotprod_expand(a, b, c); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b) +{ return v_dotprod_expand(a, b); } +inline v_int64x2 v_dotprod_expand_fast(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c) +{ return v_dotprod_expand(a, b, c); } + +// 32 >> 64f +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b) +{ return v_dotprod_expand(a, b); } +inline v_float64x2 v_dotprod_expand_fast(const v_int32x4& a, const v_int32x4& b, const v_float64x2& c) +{ return v_dotprod_expand(a, b, c); } + +#define OPENCV_HAL_IMPL_WASM_LOGIC_OP(_Tpvec) \ +OPENCV_HAL_IMPL_WASM_BIN_OP(&, _Tpvec, wasm_v128_and) \ +OPENCV_HAL_IMPL_WASM_BIN_OP(|, _Tpvec, wasm_v128_or) \ +OPENCV_HAL_IMPL_WASM_BIN_OP(^, _Tpvec, wasm_v128_xor) \ +inline _Tpvec operator ~ (const _Tpvec& a) \ +{ \ + return _Tpvec(wasm_v128_not(a.val)); \ +} + +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint8x16) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int8x16) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint16x8) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int16x8) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint32x4) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int32x4) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_uint64x2) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_int64x2) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_float32x4) +OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_float64x2) + +inline v_float32x4 v_sqrt(const v_float32x4& x) +{ + return v_float32x4(wasm_f32x4_sqrt(x.val)); +} + +inline v_float32x4 v_invsqrt(const v_float32x4& x) +{ + const v128_t _1_0 = wasm_f32x4_splat(1.0); + return v_float32x4(wasm_f32x4_div(_1_0, wasm_f32x4_sqrt(x.val))); +} + +inline v_float64x2 v_sqrt(const v_float64x2& x) +{ + return v_float64x2(wasm_f64x2_sqrt(x.val)); +} + +inline v_float64x2 v_invsqrt(const v_float64x2& x) +{ + const v128_t _1_0 = wasm_f64x2_splat(1.0); + return v_float64x2(wasm_f64x2_div(_1_0, wasm_f64x2_sqrt(x.val))); +} + +#define OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(_Tpuvec, _Tpsvec, suffix, zsuffix, shiftWidth) \ +inline _Tpuvec v_abs(const _Tpsvec& x) \ +{ \ + v128_t s = wasm_##suffix##_shr(x.val, shiftWidth); \ + v128_t f = wasm_##zsuffix##_shr(x.val, shiftWidth); \ + return _Tpuvec(wasm_##zsuffix##_add(wasm_v128_xor(x.val, f), s)); \ +} + +OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(v_uint8x16, v_int8x16, u8x16, i8x16, 7) +OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(v_uint16x8, v_int16x8, u16x8, i16x8, 15) +OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(v_uint32x4, v_int32x4, u32x4, i32x4, 31) + +inline v_float32x4 v_abs(const v_float32x4& x) +{ return v_float32x4(wasm_f32x4_abs(x.val)); } +inline v_float64x2 v_abs(const v_float64x2& x) +{ + return v_float64x2(wasm_f64x2_abs(x.val)); +} + +// TODO: exp, log, sin, cos + +#define OPENCV_HAL_IMPL_WASM_BIN_FUNC(_Tpvec, func, intrin) \ +inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(intrin(a.val, b.val)); \ +} + +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float32x4, v_min, wasm_f32x4_min) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float32x4, v_max, wasm_f32x4_max) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float64x2, v_min, wasm_f64x2_min) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float64x2, v_max, wasm_f64x2_max) + +#define OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(_Tpvec, suffix) \ +inline _Tpvec v_min(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_v128_bitselect(b.val, a.val, wasm_##suffix##_gt(a.val, b.val))); \ +} \ +inline _Tpvec v_max(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_v128_bitselect(a.val, b.val, wasm_##suffix##_gt(a.val, b.val))); \ +} + +OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(v_int8x16, i8x16) +OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(v_int16x8, i16x8) +OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(v_int32x4, i32x4) + +#define OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(_Tpvec, suffix, deltaNum) \ +inline _Tpvec v_min(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t delta = wasm_##suffix##_splat(deltaNum); \ + v128_t mask = wasm_##suffix##_gt(wasm_v128_xor(a.val, delta), wasm_v128_xor(b.val, delta)); \ + return _Tpvec(wasm_v128_bitselect(b.val, a.val, mask)); \ +} \ +inline _Tpvec v_max(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t delta = wasm_##suffix##_splat(deltaNum); \ + v128_t mask = wasm_##suffix##_gt(wasm_v128_xor(a.val, delta), wasm_v128_xor(b.val, delta)); \ + return _Tpvec(wasm_v128_bitselect(a.val, b.val, mask)); \ +} + +OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(v_uint8x16, i8x16, (schar)0x80) +OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(v_uint16x8, i16x8, (short)0x8000) +OPENCV_HAL_IMPL_WASM_MINMAX_U_INIT_FUNC(v_uint32x4, i32x4, (int)0x80000000) + +#define OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(_Tpvec, suffix, esuffix) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##esuffix##_eq(a.val, b.val)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##esuffix##_ne(a.val, b.val)); } \ +inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_lt(a.val, b.val)); } \ +inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_gt(a.val, b.val)); } \ +inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_le(a.val, b.val)); } \ +inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \ +{ return _Tpvec(wasm_##suffix##_ge(a.val, b.val)); } + +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint8x16, u8x16, i8x16) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int8x16, i8x16, i8x16) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint16x8, u16x8, i16x8) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int16x8, i16x8, i16x8) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint32x4, u32x4, i32x4) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int32x4, i32x4, i32x4) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_float32x4, f32x4, f32x4) +OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_float64x2, f64x2, f64x2) + +#define OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(_Tpvec, cast) \ +inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \ +{ return cast(v_reinterpret_as_f64(a) == v_reinterpret_as_f64(b)); } \ +inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \ +{ return cast(v_reinterpret_as_f64(a) != v_reinterpret_as_f64(b)); } + +OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(v_uint64x2, v_reinterpret_as_u64) +OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(v_int64x2, v_reinterpret_as_s64) + +inline v_float32x4 v_not_nan(const v_float32x4& a) +{ + v128_t z = wasm_i32x4_splat(0x7fffffff); + v128_t t = wasm_i32x4_splat(0x7f800000); + return v_float32x4(wasm_u32x4_lt(wasm_v128_and(a.val, z), t)); +} +inline v_float64x2 v_not_nan(const v_float64x2& a) +{ + v128_t z = wasm_i64x2_splat(0x7fffffffffffffff); + v128_t t = wasm_i64x2_splat(0x7ff0000000000000); + return v_float64x2((__u64x2)(wasm_v128_and(a.val, z)) < (__u64x2)t); +} + +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_add_wrap, wasm_i8x16_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_add_wrap, wasm_i8x16_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_add_wrap, wasm_i16x8_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_add_wrap, wasm_i16x8_add) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_sub_wrap, wasm_i8x16_sub) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_sub_wrap, wasm_i8x16_sub) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_sub_wrap, wasm_i16x8_sub) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_sub_wrap, wasm_i16x8_sub) +#if (__EMSCRIPTEN_major__ * 1000000 + __EMSCRIPTEN_minor__ * 1000 + __EMSCRIPTEN_tiny__) >= (1039012) +// details: https://github.com/opencv/opencv/issues/18097 ( https://github.com/emscripten-core/emscripten/issues/12018 ) +// 1.39.12: https://github.com/emscripten-core/emscripten/commit/cd801d0f110facfd694212a3c8b2ed2ffcd630e2 +inline v_uint8x16 v_mul_wrap(const v_uint8x16& a, const v_uint8x16& b) +{ + uchar a_[16], b_[16]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + for (int i = 0; i < 16; i++) + a_[i] = (uchar)(a_[i] * b_[i]); + return v_uint8x16(wasm_v128_load(a_)); +} +inline v_int8x16 v_mul_wrap(const v_int8x16& a, const v_int8x16& b) +{ + schar a_[16], b_[16]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + for (int i = 0; i < 16; i++) + a_[i] = (schar)(a_[i] * b_[i]); + return v_int8x16(wasm_v128_load(a_)); +} +#else +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_mul_wrap, wasm_i8x16_mul) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int8x16, v_mul_wrap, wasm_i8x16_mul) +#endif +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint16x8, v_mul_wrap, wasm_i16x8_mul) +OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_int16x8, v_mul_wrap, wasm_i16x8_mul) + + +/** Absolute difference **/ + +inline v_uint8x16 v_absdiff(const v_uint8x16& a, const v_uint8x16& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint16x8 v_absdiff(const v_uint16x8& a, const v_uint16x8& b) +{ return v_add_wrap(a - b, b - a); } +inline v_uint32x4 v_absdiff(const v_uint32x4& a, const v_uint32x4& b) +{ return v_max(a, b) - v_min(a, b); } + +inline v_uint8x16 v_absdiff(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = v_sub_wrap(a, b); + v_int8x16 m = a < b; + return v_reinterpret_as_u8(v_sub_wrap(d ^ m, m)); +} +inline v_uint16x8 v_absdiff(const v_int16x8& a, const v_int16x8& b) +{ + return v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))); +} +inline v_uint32x4 v_absdiff(const v_int32x4& a, const v_int32x4& b) +{ + v_int32x4 d = a - b; + v_int32x4 m = a < b; + return v_reinterpret_as_u32((d ^ m) - m); +} + +/** Saturating absolute difference **/ +inline v_int8x16 v_absdiffs(const v_int8x16& a, const v_int8x16& b) +{ + v_int8x16 d = a - b; + v_int8x16 m = a < b; + return (d ^ m) - m; + } +inline v_int16x8 v_absdiffs(const v_int16x8& a, const v_int16x8& b) +{ return v_max(a, b) - v_min(a, b); } + + +inline v_int32x4 v_fma(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return a * b + c; +} + +inline v_int32x4 v_muladd(const v_int32x4& a, const v_int32x4& b, const v_int32x4& c) +{ + return v_fma(a, b, c); +} + +inline v_float32x4 v_fma(const v_float32x4& a, const v_float32x4& b, const v_float32x4& c) +{ + return a * b + c; +} + +inline v_float64x2 v_fma(const v_float64x2& a, const v_float64x2& b, const v_float64x2& c) +{ + return a * b + c; +} + +inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b) +{ + v128_t absmask_vec = wasm_i32x4_splat(0x7fffffff); + return v_float32x4(wasm_v128_and(wasm_f32x4_sub(a.val, b.val), absmask_vec)); +} +inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b) +{ + v128_t absmask_vec = wasm_u64x2_shr(wasm_i32x4_splat(-1), 1); + return v_float64x2(wasm_v128_and(wasm_f64x2_sub(a.val, b.val), absmask_vec)); +} + +#define OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(_Tpvec, suffix) \ +inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t a_Square = wasm_##suffix##_mul(a.val, a.val); \ + v128_t b_Square = wasm_##suffix##_mul(b.val, b.val); \ + return _Tpvec(wasm_##suffix##_sqrt(wasm_##suffix##_add(a_Square, b_Square))); \ +} \ +inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ +{ \ + v128_t a_Square = wasm_##suffix##_mul(a.val, a.val); \ + v128_t b_Square = wasm_##suffix##_mul(b.val, b.val); \ + return _Tpvec(wasm_##suffix##_add(a_Square, b_Square)); \ +} \ +inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ +{ \ + return _Tpvec(wasm_##suffix##_add(wasm_##suffix##_mul(a.val, b.val), c.val)); \ +} + +OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float32x4, f32x4) +OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float64x2, f64x2) + +#define OPENCV_HAL_IMPL_WASM_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, ssuffix) \ +inline _Tpuvec operator << (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +inline _Tpsvec operator << (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \ +{ \ + return _Tpuvec(wasm_##ssuffix##_shr(a.val, imm)); \ +} \ +inline _Tpsvec operator >> (const _Tpsvec& a, int imm) \ +{ \ + return _Tpsvec(wasm_##suffix##_shr(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shl(const _Tpuvec& a) \ +{ \ + return _Tpuvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shl(const _Tpsvec& a) \ +{ \ + return _Tpsvec(wasm_##suffix##_shl(a.val, imm)); \ +} \ +template \ +inline _Tpuvec v_shr(const _Tpuvec& a) \ +{ \ + return _Tpuvec(wasm_##ssuffix##_shr(a.val, imm)); \ +} \ +template \ +inline _Tpsvec v_shr(const _Tpsvec& a) \ +{ \ + return _Tpsvec(wasm_##suffix##_shr(a.val, imm)); \ +} + +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint8x16, v_int8x16, i8x16, u8x16) +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint16x8, v_int16x8, i16x8, u16x8) +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint32x4, v_int32x4, i32x4, u32x4) +OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint64x2, v_int64x2, i64x2, u64x2) + +namespace hal_wasm_internal +{ + template 16)), + bool is_first = (imm == 0), + bool is_second = (imm == 16), + bool is_other = (((imm > 0) && (imm < 16)))> + class v_wasm_palignr_u8_class; + + template + class v_wasm_palignr_u8_class; + + template + class v_wasm_palignr_u8_class + { + public: + inline v128_t operator()(const v128_t& a, const v128_t&) const + { + return a; + } + }; + + template + class v_wasm_palignr_u8_class + { + public: + inline v128_t operator()(const v128_t&, const v128_t& b) const + { + return b; + } + }; + + template + class v_wasm_palignr_u8_class + { + public: + inline v128_t operator()(const v128_t& a, const v128_t& b) const + { + enum { imm2 = (sizeof(v128_t) - imm) }; + return wasm_v8x16_shuffle(a, b, + imm, imm+1, imm+2, imm+3, + imm+4, imm+5, imm+6, imm+7, + imm+8, imm+9, imm+10, imm+11, + imm+12, imm+13, imm+14, imm+15); + } + }; + + template + inline v128_t v_wasm_palignr_u8(const v128_t& a, const v128_t& b) + { + CV_StaticAssert((imm >= 0) && (imm <= 16), "Invalid imm for v_wasm_palignr_u8."); + return v_wasm_palignr_u8_class()(a, b); + } +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a) +{ + using namespace hal_wasm_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + v128_t z = wasm_i8x16_splat(0); + return _Tpvec(v_wasm_palignr_u8(a.val, z)); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a) +{ + using namespace hal_wasm_internal; + enum { imm2 = ((_Tpvec::nlanes - imm) * sizeof(typename _Tpvec::lane_type)) }; + v128_t z = wasm_i8x16_splat(0); + return _Tpvec(v_wasm_palignr_u8(z, a.val)); +} + +template +inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_wasm_internal; + enum { imm2 = (imm * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_wasm_palignr_u8(a.val, b.val)); +} + +template +inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b) +{ + using namespace hal_wasm_internal; + enum { imm2 = ((_Tpvec::nlanes - imm) * sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(v_wasm_palignr_u8(b.val, a.val)); +} + +#define OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(_Tpvec, _Tp) \ +inline _Tpvec v_load(const _Tp* ptr) \ +{ return _Tpvec(wasm_v128_load(ptr)); } \ +inline _Tpvec v_load_aligned(const _Tp* ptr) \ +{ return _Tpvec(wasm_v128_load(ptr)); } \ +inline _Tpvec v_load_low(const _Tp* ptr) \ +{ \ + _Tp tmp[_Tpvec::nlanes] = {0}; \ + for (int i=0; i<_Tpvec::nlanes/2; ++i) { \ + tmp[i] = ptr[i]; \ + } \ + return _Tpvec(wasm_v128_load(tmp)); \ +} \ +inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \ +{ \ + _Tp tmp[_Tpvec::nlanes]; \ + for (int i=0; i<_Tpvec::nlanes/2; ++i) { \ + tmp[i] = ptr0[i]; \ + tmp[i+_Tpvec::nlanes/2] = ptr1[i]; \ + } \ + return _Tpvec(wasm_v128_load(tmp)); \ +} \ +inline void v_store(_Tp* ptr, const _Tpvec& a) \ +{ wasm_v128_store(ptr, a.val); } \ +inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \ +{ wasm_v128_store(ptr, a.val); } \ +inline void v_store_aligned_nocache(_Tp* ptr, const _Tpvec& a) \ +{ wasm_v128_store(ptr, a.val); } \ +inline void v_store(_Tp* ptr, const _Tpvec& a, hal::StoreMode /*mode*/) \ +{ \ + wasm_v128_store(ptr, a.val); \ +} \ +inline void v_store_low(_Tp* ptr, const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + for (int i = 0; i < (_Tpvec::nlanes / 2); i++) \ + ptr[i] = a_[i]; \ +} \ +inline void v_store_high(_Tp* ptr, const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + for (int i = 0; i < (_Tpvec::nlanes / 2); i++) \ + ptr[i] = a_[i + (_Tpvec::nlanes / 2)]; \ +} + +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint8x16, uchar) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int8x16, schar) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint16x8, ushort) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int16x8, short) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint32x4, unsigned) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int32x4, int) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_uint64x2, uint64) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_int64x2, int64) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_float32x4, float) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INT_OP(v_float64x2, double) + + +/** Reverse **/ +inline v_uint8x16 v_reverse(const v_uint8x16 &a) +{ return v_uint8x16(wasm_v8x16_shuffle(a.val, a.val, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)); } + +inline v_int8x16 v_reverse(const v_int8x16 &a) +{ return v_reinterpret_as_s8(v_reverse(v_reinterpret_as_u8(a))); } + +inline v_uint16x8 v_reverse(const v_uint16x8 &a) +{ return v_uint16x8(wasm_v8x16_shuffle(a.val, a.val, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1)); } + +inline v_int16x8 v_reverse(const v_int16x8 &a) +{ return v_reinterpret_as_s16(v_reverse(v_reinterpret_as_u16(a))); } + +inline v_uint32x4 v_reverse(const v_uint32x4 &a) +{ return v_uint32x4(wasm_v8x16_shuffle(a.val, a.val, 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3)); } + +inline v_int32x4 v_reverse(const v_int32x4 &a) +{ return v_reinterpret_as_s32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_float32x4 v_reverse(const v_float32x4 &a) +{ return v_reinterpret_as_f32(v_reverse(v_reinterpret_as_u32(a))); } + +inline v_uint64x2 v_reverse(const v_uint64x2 &a) +{ return v_uint64x2(wasm_v8x16_shuffle(a.val, a.val, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7)); } + +inline v_int64x2 v_reverse(const v_int64x2 &a) +{ return v_reinterpret_as_s64(v_reverse(v_reinterpret_as_u64(a))); } + +inline v_float64x2 v_reverse(const v_float64x2 &a) +{ return v_reinterpret_as_f64(v_reverse(v_reinterpret_as_u64(a))); } + + +#define OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(_Tpvec, scalartype, regtype, suffix, esuffix) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + regtype val = a.val; \ + val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7)); \ + val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3)); \ + return (scalartype)wasm_##esuffix##_extract_lane(val, 0); \ +} + +OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(v_uint32x4, unsigned, v128_t, i32x4, i32x4) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(v_int32x4, int, v128_t, i32x4, i32x4) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_4_SUM(v_float32x4, float, v128_t, f32x4, f32x4) + +// To do: Optimize v_reduce_sum with wasm intrin. +// Now use fallback implementation as there is no widening op in wasm intrin. + +#define OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(_Tpvec, scalartype) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + scalartype c = a_[0]; \ + for (int i = 1; i < _Tpvec::nlanes; i++) \ + c += a_[i]; \ + return c; \ +} + +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint8x16, unsigned) +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int8x16, int) +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint16x8, unsigned) +OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int16x8, int) + + +#define OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(_Tpvec, scalartype, regtype, suffix, esuffix) \ +inline scalartype v_reduce_sum(const _Tpvec& a) \ +{ \ + regtype val = a.val; \ + val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7)); \ + return (scalartype)wasm_##esuffix##_extract_lane(val, 0); \ +} +OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_uint64x2, uint64, v128_t, i64x2, i64x2) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_int64x2, int64, v128_t, i64x2, i64x2) +OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_float64x2, double, v128_t, f64x2,f64x2) + +inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d) +{ + v128_t ac = wasm_f32x4_add(wasm_unpacklo_i32x4(a.val, c.val), wasm_unpackhi_i32x4(a.val, c.val)); + v128_t bd = wasm_f32x4_add(wasm_unpacklo_i32x4(b.val, d.val), wasm_unpackhi_i32x4(b.val, d.val)); + return v_float32x4(wasm_f32x4_add(wasm_unpacklo_i32x4(ac, bd), wasm_unpackhi_i32x4(ac, bd))); +} + +#define OPENCV_HAL_IMPL_WASM_REDUCE_OP(_Tpvec, scalartype, func, scalar_func) \ +inline scalartype v_reduce_##func(const _Tpvec& a) \ +{ \ + scalartype buf[_Tpvec::nlanes]; \ + v_store(buf, a); \ + scalartype tmp = buf[0]; \ + for (int i=1; i<_Tpvec::nlanes; ++i) { \ + tmp = scalar_func(tmp, buf[i]); \ + } \ + return tmp; \ +} + +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint8x16, uchar, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint8x16, uchar, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int8x16, schar, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int8x16, schar, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint16x8, ushort, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint16x8, ushort, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int16x8, short, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int16x8, short, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint32x4, unsigned, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_uint32x4, unsigned, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int32x4, int, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_int32x4, int, min, std::min) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_float32x4, float, max, std::max) +OPENCV_HAL_IMPL_WASM_REDUCE_OP(v_float32x4, float, min, std::min) + +inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b) +{ + v_uint16x8 l16, h16; + v_uint32x4 l16_l32, l16_h32, h16_l32, h16_h32; + v_expand(v_absdiff(a, b), l16, h16); + v_expand(l16, l16_l32, l16_h32); + v_expand(h16, h16_l32, h16_h32); + return v_reduce_sum(l16_l32+l16_h32+h16_l32+h16_h32); +} +inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b) +{ + v_uint16x8 l16, h16; + v_uint32x4 l16_l32, l16_h32, h16_l32, h16_h32; + v_expand(v_absdiff(a, b), l16, h16); + v_expand(l16, l16_l32, l16_h32); + v_expand(h16, h16_l32, h16_h32); + return v_reduce_sum(l16_l32+l16_h32+h16_l32+h16_h32); +} +inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b) +{ + v_uint32x4 l, h; + v_expand(v_absdiff(a, b), l, h); + return v_reduce_sum(l + h); +} +inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} +inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b) +{ + return v_reduce_sum(v_absdiff(a, b)); +} + +inline v_uint8x16 v_popcount(const v_uint8x16& a) +{ + v128_t m1 = wasm_i32x4_splat(0x55555555); + v128_t m2 = wasm_i32x4_splat(0x33333333); + v128_t m4 = wasm_i32x4_splat(0x0f0f0f0f); + v128_t p = a.val; + p = wasm_i32x4_add(wasm_v128_and(wasm_u32x4_shr(p, 1), m1), wasm_v128_and(p, m1)); + p = wasm_i32x4_add(wasm_v128_and(wasm_u32x4_shr(p, 2), m2), wasm_v128_and(p, m2)); + p = wasm_i32x4_add(wasm_v128_and(wasm_u32x4_shr(p, 4), m4), wasm_v128_and(p, m4)); + return v_uint8x16(p); +} +inline v_uint16x8 v_popcount(const v_uint16x8& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + return v_reinterpret_as_u16(p) & v_setall_u16(0x00ff); +} +inline v_uint32x4 v_popcount(const v_uint32x4& a) +{ + v_uint8x16 p = v_popcount(v_reinterpret_as_u8(a)); + p += v_rotate_right<1>(p); + p += v_rotate_right<2>(p); + return v_reinterpret_as_u32(p) & v_setall_u32(0x000000ff); +} +inline v_uint64x2 v_popcount(const v_uint64x2& a) +{ + uint64 a_[2], b_[2] = { 0 }; + wasm_v128_store(a_, a.val); + for (int i = 0; i < 16; i++) + b_[i / 8] += popCountTable[((uint8_t*)a_)[i]]; + return v_uint64x2(wasm_v128_load(b_)); +} +inline v_uint8x16 v_popcount(const v_int8x16& a) +{ return v_popcount(v_reinterpret_as_u8(a)); } +inline v_uint16x8 v_popcount(const v_int16x8& a) +{ return v_popcount(v_reinterpret_as_u16(a)); } +inline v_uint32x4 v_popcount(const v_int32x4& a) +{ return v_popcount(v_reinterpret_as_u32(a)); } +inline v_uint64x2 v_popcount(const v_int64x2& a) +{ return v_popcount(v_reinterpret_as_u64(a)); } + +#define OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(_Tpvec, suffix, scalarType) \ +inline int v_signmask(const _Tpvec& a) \ +{ \ + _Tpvec::lane_type a_[_Tpvec::nlanes]; \ + wasm_v128_store(a_, a.val); \ + int mask = 0; \ + for (int i = 0; i < _Tpvec::nlanes; i++) \ + mask |= (reinterpret_int(a_[i]) < 0) << i; \ + return mask; \ +} \ +inline bool v_check_all(const _Tpvec& a) \ +{ return wasm_i8x16_all_true(wasm_##suffix##_lt(a.val, wasm_##suffix##_splat(0))); } \ +inline bool v_check_any(const _Tpvec& a) \ +{ return wasm_i8x16_any_true(wasm_##suffix##_lt(a.val, wasm_##suffix##_splat(0)));; } + +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint8x16, i8x16, schar) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int8x16, i8x16, schar) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint16x8, i16x8, short) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int16x8, i16x8, short) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint32x4, i32x4, int) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int32x4, i32x4, int) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_float32x4, i32x4, float) +OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_float64x2, f64x2, double) + +#define OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(_Tpvec, suffix, esuffix) \ +inline bool v_check_all(const _Tpvec& a) \ +{ \ + v128_t masked = v_reinterpret_as_##esuffix(a).val; \ + masked = wasm_i32x4_replace_lane(masked, 0, 0xffffffff); \ + masked = wasm_i32x4_replace_lane(masked, 2, 0xffffffff); \ + return wasm_i8x16_all_true(wasm_##suffix##_lt(masked, wasm_##suffix##_splat(0))); \ +} \ +inline bool v_check_any(const _Tpvec& a) \ +{ \ + v128_t masked = v_reinterpret_as_##esuffix(a).val; \ + masked = wasm_i32x4_replace_lane(masked, 0, 0x0); \ + masked = wasm_i32x4_replace_lane(masked, 2, 0x0); \ + return wasm_i8x16_any_true(wasm_##suffix##_lt(masked, wasm_##suffix##_splat(0))); \ +} \ + +OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(v_int64x2, i32x4, s32) +OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(v_uint64x2, i32x4, u32) + + +inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); } +inline int v_scan_forward(const v_int16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_uint16x8& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 2; } +inline int v_scan_forward(const v_int32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_uint32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_float32x4& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 4; } +inline int v_scan_forward(const v_int64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_uint64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } +inline int v_scan_forward(const v_float64x2& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))) / 8; } + +#define OPENCV_HAL_IMPL_WASM_SELECT(_Tpvec) \ +inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_v128_bitselect(a.val, b.val, mask.val)); \ +} + +OPENCV_HAL_IMPL_WASM_SELECT(v_uint8x16) +OPENCV_HAL_IMPL_WASM_SELECT(v_int8x16) +OPENCV_HAL_IMPL_WASM_SELECT(v_uint16x8) +OPENCV_HAL_IMPL_WASM_SELECT(v_int16x8) +OPENCV_HAL_IMPL_WASM_SELECT(v_uint32x4) +OPENCV_HAL_IMPL_WASM_SELECT(v_int32x4) +OPENCV_HAL_IMPL_WASM_SELECT(v_uint64x2) +OPENCV_HAL_IMPL_WASM_SELECT(v_int64x2) +OPENCV_HAL_IMPL_WASM_SELECT(v_float32x4) +OPENCV_HAL_IMPL_WASM_SELECT(v_float64x2) + +#define OPENCV_HAL_IMPL_WASM_EXPAND(_Tpvec, _Tpwvec, _Tp, intrin) \ +inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \ +{ \ + b0.val = intrin(a.val); \ + b1.val = __CV_CAT(intrin, _high)(a.val); \ +} \ +inline _Tpwvec v_expand_low(const _Tpvec& a) \ +{ return _Tpwvec(intrin(a.val)); } \ +inline _Tpwvec v_expand_high(const _Tpvec& a) \ +{ return _Tpwvec(__CV_CAT(intrin, _high)(a.val)); } \ +inline _Tpwvec v_load_expand(const _Tp* ptr) \ +{ \ + v128_t a = wasm_v128_load(ptr); \ + return _Tpwvec(intrin(a)); \ +} + +OPENCV_HAL_IMPL_WASM_EXPAND(v_uint8x16, v_uint16x8, uchar, v128_cvtu8x16_i16x8) +OPENCV_HAL_IMPL_WASM_EXPAND(v_int8x16, v_int16x8, schar, v128_cvti8x16_i16x8) +OPENCV_HAL_IMPL_WASM_EXPAND(v_uint16x8, v_uint32x4, ushort, v128_cvtu16x8_i32x4) +OPENCV_HAL_IMPL_WASM_EXPAND(v_int16x8, v_int32x4, short, v128_cvti16x8_i32x4) +OPENCV_HAL_IMPL_WASM_EXPAND(v_uint32x4, v_uint64x2, unsigned, v128_cvtu32x4_i64x2) +OPENCV_HAL_IMPL_WASM_EXPAND(v_int32x4, v_int64x2, int, v128_cvti32x4_i64x2) + +#define OPENCV_HAL_IMPL_WASM_EXPAND_Q(_Tpvec, _Tp, intrin) \ +inline _Tpvec v_load_expand_q(const _Tp* ptr) \ +{ \ + v128_t a = wasm_v128_load(ptr); \ + return _Tpvec(intrin(a)); \ +} + +OPENCV_HAL_IMPL_WASM_EXPAND_Q(v_uint32x4, uchar, v128_cvtu8x16_i32x4) +OPENCV_HAL_IMPL_WASM_EXPAND_Q(v_int32x4, schar, v128_cvti8x16_i32x4) + +#define OPENCV_HAL_IMPL_WASM_UNPACKS(_Tpvec, suffix) \ +inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1) \ +{ \ + b0.val = wasm_unpacklo_##suffix(a0.val, a1.val); \ + b1.val = wasm_unpackhi_##suffix(a0.val, a1.val); \ +} \ +inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_unpacklo_i64x2(a.val, b.val)); \ +} \ +inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b) \ +{ \ + return _Tpvec(wasm_unpackhi_i64x2(a.val, b.val)); \ +} \ +inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d) \ +{ \ + c.val = wasm_unpacklo_i64x2(a.val, b.val); \ + d.val = wasm_unpackhi_i64x2(a.val, b.val); \ +} + +OPENCV_HAL_IMPL_WASM_UNPACKS(v_uint8x16, i8x16) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_int8x16, i8x16) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_uint16x8, i16x8) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_int16x8, i16x8) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_uint32x4, i32x4) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_int32x4, i32x4) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_float32x4, i32x4) +OPENCV_HAL_IMPL_WASM_UNPACKS(v_float64x2, i64x2) + +template +inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) +{ + return v_rotate_right(a, b); +} + +inline v_int32x4 v_round(const v_float32x4& a) +{ + v128_t h = wasm_f32x4_splat(0.5); + return v_int32x4(wasm_i32x4_trunc_saturate_f32x4(wasm_f32x4_add(a.val, h))); +} + +inline v_int32x4 v_floor(const v_float32x4& a) +{ + v128_t a1 = wasm_i32x4_trunc_saturate_f32x4(a.val); + v128_t mask = wasm_f32x4_lt(a.val, wasm_f32x4_convert_i32x4(a1)); + return v_int32x4(wasm_i32x4_add(a1, mask)); +} + +inline v_int32x4 v_ceil(const v_float32x4& a) +{ + v128_t a1 = wasm_i32x4_trunc_saturate_f32x4(a.val); + v128_t mask = wasm_f32x4_gt(a.val, wasm_f32x4_convert_i32x4(a1)); + return v_int32x4(wasm_i32x4_sub(a1, mask)); +} + +inline v_int32x4 v_trunc(const v_float32x4& a) +{ return v_int32x4(wasm_i32x4_trunc_saturate_f32x4(a.val)); } + +#define OPENCV_HAL_IMPL_WASM_MATH_FUNC(func, cfunc) \ +inline v_int32x4 func(const v_float64x2& a) \ +{ \ + double a_[2]; \ + wasm_v128_store(a_, a.val); \ + int c_[4]; \ + c_[0] = cfunc(a_[0]); \ + c_[1] = cfunc(a_[1]); \ + c_[2] = 0; \ + c_[3] = 0; \ + return v_int32x4(wasm_v128_load(c_)); \ +} + +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_round, cvRound) +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_floor, cvFloor) +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_ceil, cvCeil) +OPENCV_HAL_IMPL_WASM_MATH_FUNC(v_trunc, int) + +inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) +{ + double a_[2], b_[2]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + int c_[4]; + c_[0] = cvRound(a_[0]); + c_[1] = cvRound(a_[1]); + c_[2] = cvRound(b_[0]); + c_[3] = cvRound(b_[1]); + return v_int32x4(wasm_v128_load(c_)); +} + +#define OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(_Tpvec, suffix) \ +inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \ + const _Tpvec& a2, const _Tpvec& a3, \ + _Tpvec& b0, _Tpvec& b1, \ + _Tpvec& b2, _Tpvec& b3) \ +{ \ + v128_t t0 = wasm_unpacklo_##suffix(a0.val, a1.val); \ + v128_t t1 = wasm_unpacklo_##suffix(a2.val, a3.val); \ + v128_t t2 = wasm_unpackhi_##suffix(a0.val, a1.val); \ + v128_t t3 = wasm_unpackhi_##suffix(a2.val, a3.val); \ +\ + b0.val = wasm_unpacklo_i64x2(t0, t1); \ + b1.val = wasm_unpackhi_i64x2(t0, t1); \ + b2.val = wasm_unpacklo_i64x2(t2, t3); \ + b3.val = wasm_unpackhi_i64x2(t2, t3); \ +} + +OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(v_uint32x4, i32x4) +OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(v_int32x4, i32x4) +OPENCV_HAL_IMPL_WASM_TRANSPOSE4x4(v_float32x4, i32x4) + +// load deinterleave +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b) +{ + v128_t t00 = wasm_v128_load(ptr); + v128_t t01 = wasm_v128_load(ptr + 16); + + a.val = wasm_v8x16_shuffle(t00, t01, 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30); + b.val = wasm_v8x16_shuffle(t00, t01, 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31); +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c) +{ + v128_t t00 = wasm_v128_load(ptr); + v128_t t01 = wasm_v128_load(ptr + 16); + v128_t t02 = wasm_v128_load(ptr + 32); + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,3,6,9,12,15,18,21,24,27,30,1,2,4,5,7); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 1,4,7,10,13,16,19,22,25,28,31,0,2,3,5,6); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 2,5,8,11,14,17,20,23,26,29,0,1,3,4,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,17,20,23,26,29); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,10,18,21,24,27,30); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,8,9,16,19,22,25,28,31); +} + +inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c, v_uint8x16& d) +{ + v128_t u0 = wasm_v128_load(ptr); // a0 b0 c0 d0 a1 b1 c1 d1 ... + v128_t u1 = wasm_v128_load(ptr + 16); // a4 b4 c4 d4 ... + v128_t u2 = wasm_v128_load(ptr + 32); // a8 b8 c8 d8 ... + v128_t u3 = wasm_v128_load(ptr + 48); // a12 b12 c12 d12 ... + + v128_t v0 = wasm_v8x16_shuffle(u0, u1, 0,4,8,12,16,20,24,28,1,5,9,13,17,21,25,29); + v128_t v1 = wasm_v8x16_shuffle(u2, u3, 0,4,8,12,16,20,24,28,1,5,9,13,17,21,25,29); + v128_t v2 = wasm_v8x16_shuffle(u0, u1, 2,6,10,14,18,22,26,30,3,7,11,15,19,23,27,31); + v128_t v3 = wasm_v8x16_shuffle(u2, u3, 2,6,10,14,18,22,26,30,3,7,11,15,19,23,27,31); + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + b.val = wasm_v8x16_shuffle(v0, v1, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); + c.val = wasm_v8x16_shuffle(v2, v3, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + d.val = wasm_v8x16_shuffle(v2, v3, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b) +{ + v128_t v0 = wasm_v128_load(ptr); // a0 b0 a1 b1 a2 b2 a3 b3 + v128_t v1 = wasm_v128_load(ptr + 8); // a4 b4 a5 b5 a6 b6 a7 b7 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,4,5,8,9,12,13,16,17,20,21,24,25,28,29); // a0 a1 a2 a3 a4 a5 a6 a7 + b.val = wasm_v8x16_shuffle(v0, v1, 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31); // b0 b1 ab b3 b4 b5 b6 b7 +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c) +{ + v128_t t00 = wasm_v128_load(ptr); // a0 b0 c0 a1 b1 c1 a2 b2 + v128_t t01 = wasm_v128_load(ptr + 8); // c2 a3 b3 c3 a4 b4 c4 a5 + v128_t t02 = wasm_v128_load(ptr + 16); // b5 c5 a6 b6 c6 a7 b7 c7 + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,1,6,7,12,13,18,19,24,25,30,31,2,3,4,5); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 2,3,8,9,14,15,20,21,26,27,0,1,4,5,6,7); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 4,5,10,11,16,17,22,23,28,29,0,1,2,3,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,11,20,21,26,27); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,16,17,22,23,28,29); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,8,9,18,19,24,25,30,31); +} + +inline void v_load_deinterleave(const ushort* ptr, v_uint16x8& a, v_uint16x8& b, v_uint16x8& c, v_uint16x8& d) +{ + v128_t u0 = wasm_v128_load(ptr); // a0 b0 c0 d0 a1 b1 c1 d1 + v128_t u1 = wasm_v128_load(ptr + 8); // a2 b2 c2 d2 ... + v128_t u2 = wasm_v128_load(ptr + 16); // a4 b4 c4 d4 ... + v128_t u3 = wasm_v128_load(ptr + 24); // a6 b6 c6 d6 ... + + v128_t v0 = wasm_v8x16_shuffle(u0, u1, 0,1,8,9,16,17,24,25,2,3,10,11,18,19,26,27); // a0 a1 a2 a3 b0 b1 b2 b3 + v128_t v1 = wasm_v8x16_shuffle(u2, u3, 0,1,8,9,16,17,24,25,2,3,10,11,18,19,26,27); // a4 a5 a6 a7 b4 b5 b6 b7 + v128_t v2 = wasm_v8x16_shuffle(u0, u1, 4,5,12,13,20,21,28,29,6,7,14,15,22,23,30,31); // c0 c1 c2 c3 d0 d1 d2 d3 + v128_t v3 = wasm_v8x16_shuffle(u2, u3, 4,5,12,13,20,21,28,29,6,7,14,15,22,23,30,31); // c4 c5 c6 c7 d4 d5 d6 d7 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + b.val = wasm_v8x16_shuffle(v0, v1, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); + c.val = wasm_v8x16_shuffle(v2, v3, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + d.val = wasm_v8x16_shuffle(v2, v3, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b) +{ + v128_t v0 = wasm_v128_load(ptr); // a0 b0 a1 b1 + v128_t v1 = wasm_v128_load(ptr + 4); // a2 b2 a3 b3 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27); // a0 a1 a2 a3 + b.val = wasm_v8x16_shuffle(v0, v1, 4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31); // b0 b1 b2 b3 +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c) +{ + v128_t t00 = wasm_v128_load(ptr); // a0 b0 c0 a1 + v128_t t01 = wasm_v128_load(ptr + 4); // b2 c2 a3 b3 + v128_t t02 = wasm_v128_load(ptr + 8); // c3 a4 b4 c4 + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,1,2,3,12,13,14,15,24,25,26,27,4,5,6,7); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 4,5,6,7,16,17,18,19,28,29,30,31,0,1,2,3); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 8,9,10,11,20,21,22,23,0,1,2,3,4,5,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,11,20,21,22,23); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,10,11,24,25,26,27); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,16,17,18,19,28,29,30,31); +} + +inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4& b, v_uint32x4& c, v_uint32x4& d) +{ + v_uint32x4 s0(wasm_v128_load(ptr)); // a0 b0 c0 d0 + v_uint32x4 s1(wasm_v128_load(ptr + 4)); // a1 b1 c1 d1 + v_uint32x4 s2(wasm_v128_load(ptr + 8)); // a2 b2 c2 d2 + v_uint32x4 s3(wasm_v128_load(ptr + 12)); // a3 b3 c3 d3 + + v_transpose4x4(s0, s1, s2, s3, a, b, c, d); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b) +{ + v128_t v0 = wasm_v128_load(ptr); // a0 b0 a1 b1 + v128_t v1 = wasm_v128_load((ptr + 4)); // a2 b2 a3 b3 + + a.val = wasm_v8x16_shuffle(v0, v1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27); // a0 a1 a2 a3 + b.val = wasm_v8x16_shuffle(v0, v1, 4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31); // b0 b1 b2 b3 +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c) +{ + v128_t t00 = wasm_v128_load(ptr); // a0 b0 c0 a1 + v128_t t01 = wasm_v128_load(ptr + 4); // b2 c2 a3 b3 + v128_t t02 = wasm_v128_load(ptr + 8); // c3 a4 b4 c4 + + v128_t t10 = wasm_v8x16_shuffle(t00, t01, 0,1,2,3,12,13,14,15,24,25,26,27,4,5,6,7); + v128_t t11 = wasm_v8x16_shuffle(t00, t01, 4,5,6,7,16,17,18,19,28,29,30,31,0,1,2,3); + v128_t t12 = wasm_v8x16_shuffle(t00, t01, 8,9,10,11,20,21,22,23,0,1,2,3,4,5,6,7); + + a.val = wasm_v8x16_shuffle(t10, t02, 0,1,2,3,4,5,6,7,8,9,10,11,20,21,22,23); + b.val = wasm_v8x16_shuffle(t11, t02, 0,1,2,3,4,5,6,7,8,9,10,11,24,25,26,27); + c.val = wasm_v8x16_shuffle(t12, t02, 0,1,2,3,4,5,6,7,16,17,18,19,28,29,30,31); +} + +inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c, v_float32x4& d) +{ + v_float32x4 s0(wasm_v128_load(ptr)); // a0 b0 c0 d0 + v_float32x4 s1(wasm_v128_load(ptr + 4)); // a1 b1 c1 d1 + v_float32x4 s2(wasm_v128_load(ptr + 8)); // a2 b2 c2 d2 + v_float32x4 s3(wasm_v128_load(ptr + 12)); // a3 b3 c3 d3 + + v_transpose4x4(s0, s1, s2, s3, a, b, c, d); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b) +{ + v128_t t0 = wasm_v128_load(ptr); // a0 b0 + v128_t t1 = wasm_v128_load(ptr + 2); // a1 b1 + + a.val = wasm_unpacklo_i64x2(t0, t1); + b.val = wasm_unpackhi_i64x2(t0, t1); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b, v_uint64x2& c) +{ + v128_t t0 = wasm_v128_load(ptr); // a0, b0 + v128_t t1 = wasm_v128_load(ptr + 2); // c0, a1 + v128_t t2 = wasm_v128_load(ptr + 4); // b1, c1 + + a.val = wasm_v8x16_shuffle(t0, t1, 0,1,2,3,4,5,6,7,24,25,26,27,28,29,30,31); + b.val = wasm_v8x16_shuffle(t0, t2, 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23); + c.val = wasm_v8x16_shuffle(t1, t2, 0,1,2,3,4,5,6,7,24,25,26,27,28,29,30,31); +} + +inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, + v_uint64x2& b, v_uint64x2& c, v_uint64x2& d) +{ + v128_t t0 = wasm_v128_load(ptr); // a0 b0 + v128_t t1 = wasm_v128_load(ptr + 2); // c0 d0 + v128_t t2 = wasm_v128_load(ptr + 4); // a1 b1 + v128_t t3 = wasm_v128_load(ptr + 6); // c1 d1 + + a.val = wasm_unpacklo_i64x2(t0, t2); + b.val = wasm_unpackhi_i64x2(t0, t2); + c.val = wasm_unpacklo_i64x2(t1, t3); + d.val = wasm_unpackhi_i64x2(t1, t3); +} + +// store interleave + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i8x16(a.val, b.val); + v128_t v1 = wasm_unpackhi_i8x16(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 16, v1); +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,16,0,1,17,0,2,18,0,3,19,0,4,20,0,5); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 21,0,6,22,0,7,23,0,8,24,0,9,25,0,10,26); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 0,11,27,0,12,28,0,13,29,0,14,30,0,15,31,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,16,3,4,17,6,7,18,9,10,19,12,13,20,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 0,21,2,3,22,5,6,23,8,9,24,11,12,25,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 26,1,2,27,4,5,28,7,8,29,10,11,30,13,14,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 16, t11); + wasm_v128_store(ptr + 32, t12); +} + +inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b, + const v_uint8x16& c, const v_uint8x16& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + v128_t u0 = wasm_unpacklo_i8x16(a.val, c.val); // a0 c0 a1 c1 ... + v128_t u1 = wasm_unpackhi_i8x16(a.val, c.val); // a8 c8 a9 c9 ... + v128_t u2 = wasm_unpacklo_i8x16(b.val, d.val); // b0 d0 b1 d1 ... + v128_t u3 = wasm_unpackhi_i8x16(b.val, d.val); // b8 d8 b9 d9 ... + + v128_t v0 = wasm_unpacklo_i8x16(u0, u2); // a0 b0 c0 d0 ... + v128_t v1 = wasm_unpackhi_i8x16(u0, u2); // a4 b4 c4 d4 ... + v128_t v2 = wasm_unpacklo_i8x16(u1, u3); // a8 b8 c8 d8 ... + v128_t v3 = wasm_unpackhi_i8x16(u1, u3); // a12 b12 c12 d12 ... + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 16, v1); + wasm_v128_store(ptr + 32, v2); + wasm_v128_store(ptr + 48, v3); +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i16x8(a.val, b.val); + v128_t v1 = wasm_unpackhi_i16x8(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 8, v1); +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, + const v_uint16x8& b, const v_uint16x8& c, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,1,16,17,0,0,2,3,18,19,0,0,4,5,20,21); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 0,0,6,7,22,23,0,0,8,9,24,25,0,0,10,11); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 26,27,0,0,12,13,28,29,0,0,14,15,30,31,0,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,2,3,16,17,6,7,8,9,18,19,12,13,14,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 20,21,2,3,4,5,22,23,8,9,10,11,24,25,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 0,1,26,27,4,5,6,7,28,29,10,11,12,13,30,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 8, t11); + wasm_v128_store(ptr + 16, t12); +} + +inline void v_store_interleave( ushort* ptr, const v_uint16x8& a, const v_uint16x8& b, + const v_uint16x8& c, const v_uint16x8& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + // a0 a1 a2 a3 .... + // b0 b1 b2 b3 .... + // c0 c1 c2 c3 .... + // d0 d1 d2 d3 .... + v128_t u0 = wasm_unpacklo_i16x8(a.val, c.val); // a0 c0 a1 c1 ... + v128_t u1 = wasm_unpackhi_i16x8(a.val, c.val); // a4 c4 a5 c5 ... + v128_t u2 = wasm_unpacklo_i16x8(b.val, d.val); // b0 d0 b1 d1 ... + v128_t u3 = wasm_unpackhi_i16x8(b.val, d.val); // b4 d4 b5 d5 ... + + v128_t v0 = wasm_unpacklo_i16x8(u0, u2); // a0 b0 c0 d0 ... + v128_t v1 = wasm_unpackhi_i16x8(u0, u2); // a2 b2 c2 d2 ... + v128_t v2 = wasm_unpacklo_i16x8(u1, u3); // a4 b4 c4 d4 ... + v128_t v3 = wasm_unpackhi_i16x8(u1, u3); // a6 b6 c6 d6 ... + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 8, v1); + wasm_v128_store(ptr + 16, v2); + wasm_v128_store(ptr + 24, v3); +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i32x4(a.val, b.val); + v128_t v1 = wasm_unpackhi_i32x4(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 4, v1); +} + +inline void v_store_interleave( unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,16,17,18,19,0,0,0,0,4,5,6,7); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 20,21,22,23,0,0,0,0,8,9,10,11,24,25,26,27); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 0,0,0,0,12,13,14,15,28,29,30,31,0,0,0,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,2,3,4,5,6,7,16,17,18,19,12,13,14,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 0,1,2,3,20,21,22,23,8,9,10,11,12,13,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 24,25,26,27,4,5,6,7,8,9,10,11,28,29,30,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 4, t11); + wasm_v128_store(ptr + 8, t12); +} + +inline void v_store_interleave(unsigned* ptr, const v_uint32x4& a, const v_uint32x4& b, + const v_uint32x4& c, const v_uint32x4& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v_uint32x4 v0, v1, v2, v3; + v_transpose4x4(a, b, c, d, v0, v1, v2, v3); + + wasm_v128_store(ptr, v0.val); + wasm_v128_store(ptr + 4, v1.val); + wasm_v128_store(ptr + 8, v2.val); + wasm_v128_store(ptr + 12, v3.val); +} + +// 2-channel, float only +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i32x4(a.val, b.val); + v128_t v1 = wasm_unpackhi_i32x4(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 4, v1); +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t t00 = wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,16,17,18,19,0,0,0,0,4,5,6,7); + v128_t t01 = wasm_v8x16_shuffle(a.val, b.val, 20,21,22,23,0,0,0,0,8,9,10,11,24,25,26,27); + v128_t t02 = wasm_v8x16_shuffle(a.val, b.val, 0,0,0,0,12,13,14,15,28,29,30,31,0,0,0,0); + + v128_t t10 = wasm_v8x16_shuffle(t00, c.val, 0,1,2,3,4,5,6,7,16,17,18,19,12,13,14,15); + v128_t t11 = wasm_v8x16_shuffle(t01, c.val, 0,1,2,3,20,21,22,23,8,9,10,11,12,13,14,15); + v128_t t12 = wasm_v8x16_shuffle(t02, c.val, 24,25,26,27,4,5,6,7,8,9,10,11,28,29,30,31); + + wasm_v128_store(ptr, t10); + wasm_v128_store(ptr + 4, t11); + wasm_v128_store(ptr + 8, t12); +} + +inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32x4& b, + const v_float32x4& c, const v_float32x4& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v_float32x4 v0, v1, v2, v3; + v_transpose4x4(a, b, c, d, v0, v1, v2, v3); + + wasm_v128_store(ptr, v0.val); + wasm_v128_store(ptr + 4, v1.val); + wasm_v128_store(ptr + 8, v2.val); + wasm_v128_store(ptr + 12, v3.val); +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i64x2(a.val, b.val); + v128_t v1 = wasm_unpackhi_i64x2(a.val, b.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 2, v1); +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_v8x16_shuffle(a.val, b.val, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23); + v128_t v1 = wasm_v8x16_shuffle(a.val, c.val, 16,17,18,19,20,21,22,23,8,9,10,11,12,13,14,15); + v128_t v2 = wasm_v8x16_shuffle(b.val, c.val, 8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 2, v1); + wasm_v128_store(ptr + 4, v2); +} + +inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, + const v_uint64x2& c, const v_uint64x2& d, + hal::StoreMode /*mode*/ = hal::STORE_UNALIGNED) +{ + v128_t v0 = wasm_unpacklo_i64x2(a.val, b.val); + v128_t v1 = wasm_unpacklo_i64x2(c.val, d.val); + v128_t v2 = wasm_unpackhi_i64x2(a.val, b.val); + v128_t v3 = wasm_unpackhi_i64x2(c.val, d.val); + + wasm_v128_store(ptr, v0); + wasm_v128_store(ptr + 2, v1); + wasm_v128_store(ptr + 4, v2); + wasm_v128_store(ptr + 6, v3); +} + +#define OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(_Tpvec0, _Tp0, suffix0, _Tpvec1, _Tp1, suffix1) \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0 ) \ +{ \ + _Tpvec1 a1, b1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0 ) \ +{ \ + _Tpvec1 a1, b1, c1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ +} \ +inline void v_load_deinterleave( const _Tp0* ptr, _Tpvec0& a0, _Tpvec0& b0, _Tpvec0& c0, _Tpvec0& d0 ) \ +{ \ + _Tpvec1 a1, b1, c1, d1; \ + v_load_deinterleave((const _Tp1*)ptr, a1, b1, c1, d1); \ + a0 = v_reinterpret_as_##suffix0(a1); \ + b0 = v_reinterpret_as_##suffix0(b1); \ + c0 = v_reinterpret_as_##suffix0(c1); \ + d0 = v_reinterpret_as_##suffix0(d1); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, mode); \ +} \ +inline void v_store_interleave( _Tp0* ptr, const _Tpvec0& a0, const _Tpvec0& b0, \ + const _Tpvec0& c0, const _Tpvec0& d0, \ + hal::StoreMode mode = hal::STORE_UNALIGNED ) \ +{ \ + _Tpvec1 a1 = v_reinterpret_as_##suffix1(a0); \ + _Tpvec1 b1 = v_reinterpret_as_##suffix1(b0); \ + _Tpvec1 c1 = v_reinterpret_as_##suffix1(c0); \ + _Tpvec1 d1 = v_reinterpret_as_##suffix1(d0); \ + v_store_interleave((_Tp1*)ptr, a1, b1, c1, d1, mode); \ +} + +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int8x16, schar, s8, v_uint8x16, uchar, u8) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int16x8, short, s16, v_uint16x8, ushort, u16) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int32x4, int, s32, v_uint32x4, unsigned, u32) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_int64x2, int64, s64, v_uint64x2, uint64, u64) +OPENCV_HAL_IMPL_WASM_LOADSTORE_INTERLEAVE(v_float64x2, double, f64, v_uint64x2, uint64, u64) + +inline v_float32x4 v_cvt_f32(const v_int32x4& a) +{ + return v_float32x4(wasm_f32x4_convert_i32x4(a.val)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a) +{ + double a_[2]; + wasm_v128_store(a_, a.val); + float c_[4]; + c_[0] = (float)(a_[0]); + c_[1] = (float)(a_[1]); + c_[2] = 0; + c_[3] = 0; + return v_float32x4(wasm_v128_load(c_)); +} + +inline v_float32x4 v_cvt_f32(const v_float64x2& a, const v_float64x2& b) +{ + double a_[2], b_[2]; + wasm_v128_store(a_, a.val); + wasm_v128_store(b_, b.val); + float c_[4]; + c_[0] = (float)(a_[0]); + c_[1] = (float)(a_[1]); + c_[2] = (float)(b_[0]); + c_[3] = (float)(b_[1]); + return v_float32x4(wasm_v128_load(c_)); +} + +inline v_float64x2 v_cvt_f64(const v_int32x4& a) +{ +#ifdef __wasm_unimplemented_simd128__ + v128_t p = v128_cvti32x4_i64x2(a.val); + return v_float64x2(wasm_f64x2_convert_i64x2(p)); +#else + int a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[0]); + c_[1] = (double)(a_[1]); + return v_float64x2(wasm_v128_load(c_)); +#endif +} + +inline v_float64x2 v_cvt_f64_high(const v_int32x4& a) +{ +#ifdef __wasm_unimplemented_simd128__ + v128_t p = v128_cvti32x4_i64x2_high(a.val); + return v_float64x2(wasm_f64x2_convert_i64x2(p)); +#else + int a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[2]); + c_[1] = (double)(a_[3]); + return v_float64x2(wasm_v128_load(c_)); +#endif +} + +inline v_float64x2 v_cvt_f64(const v_float32x4& a) +{ + float a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[0]); + c_[1] = (double)(a_[1]); + return v_float64x2(wasm_v128_load(c_)); +} + +inline v_float64x2 v_cvt_f64_high(const v_float32x4& a) +{ + float a_[4]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[2]); + c_[1] = (double)(a_[3]); + return v_float64x2(wasm_v128_load(c_)); +} + +inline v_float64x2 v_cvt_f64(const v_int64x2& a) +{ +#ifdef __wasm_unimplemented_simd128__ + return v_float64x2(wasm_f64x2_convert_i64x2(a.val)); +#else + int64 a_[2]; + wasm_v128_store(a_, a.val); + double c_[2]; + c_[0] = (double)(a_[0]); + c_[1] = (double)(a_[1]); + return v_float64x2(wasm_v128_load(c_)); +#endif +} + +////////////// Lookup table access //////////////////// + +inline v_int8x16 v_lut(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[1]], tab[idx[ 2]], tab[idx[ 3]], tab[idx[ 4]], tab[idx[ 5]], tab[idx[ 6]], tab[idx[ 7]], + tab[idx[8]], tab[idx[9]], tab[idx[10]], tab[idx[11]], tab[idx[12]], tab[idx[13]], tab[idx[14]], tab[idx[15]]); +} +inline v_int8x16 v_lut_pairs(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[0]+1], tab[idx[1]], tab[idx[1]+1], tab[idx[2]], tab[idx[2]+1], tab[idx[3]], tab[idx[3]+1], + tab[idx[4]], tab[idx[4]+1], tab[idx[5]], tab[idx[5]+1], tab[idx[6]], tab[idx[6]+1], tab[idx[7]], tab[idx[7]+1]); +} +inline v_int8x16 v_lut_quads(const schar* tab, const int* idx) +{ + return v_int8x16(tab[idx[0]], tab[idx[0]+1], tab[idx[0]+2], tab[idx[0]+3], tab[idx[1]], tab[idx[1]+1], tab[idx[1]+2], tab[idx[1]+3], + tab[idx[2]], tab[idx[2]+1], tab[idx[2]+2], tab[idx[2]+3], tab[idx[3]], tab[idx[3]+1], tab[idx[3]+2], tab[idx[3]+3]); +} +inline v_uint8x16 v_lut(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_pairs(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_pairs((const schar *)tab, idx)); } +inline v_uint8x16 v_lut_quads(const uchar* tab, const int* idx) { return v_reinterpret_as_u8(v_lut_quads((const schar *)tab, idx)); } + +inline v_int16x8 v_lut(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]], + tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]); +} +inline v_int16x8 v_lut_pairs(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[0]+1], tab[idx[1]], tab[idx[1]+1], + tab[idx[2]], tab[idx[2]+1], tab[idx[3]], tab[idx[3]+1]); +} +inline v_int16x8 v_lut_quads(const short* tab, const int* idx) +{ + return v_int16x8(tab[idx[0]], tab[idx[0]+1], tab[idx[0]+2], tab[idx[0]+3], + tab[idx[1]], tab[idx[1]+1], tab[idx[1]+2], tab[idx[1]+3]); +} +inline v_uint16x8 v_lut(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut((const short *)tab, idx)); } +inline v_uint16x8 v_lut_pairs(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_pairs((const short *)tab, idx)); } +inline v_uint16x8 v_lut_quads(const ushort* tab, const int* idx) { return v_reinterpret_as_u16(v_lut_quads((const short *)tab, idx)); } + +inline v_int32x4 v_lut(const int* tab, const int* idx) +{ + return v_int32x4(tab[idx[0]], tab[idx[1]], + tab[idx[2]], tab[idx[3]]); +} +inline v_int32x4 v_lut_pairs(const int* tab, const int* idx) +{ + return v_int32x4(tab[idx[0]], tab[idx[0]+1], + tab[idx[1]], tab[idx[1]+1]); +} +inline v_int32x4 v_lut_quads(const int* tab, const int* idx) +{ + return v_int32x4(wasm_v128_load(tab + idx[0])); +} +inline v_uint32x4 v_lut(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut((const int *)tab, idx)); } +inline v_uint32x4 v_lut_pairs(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_pairs((const int *)tab, idx)); } +inline v_uint32x4 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((const int *)tab, idx)); } + +inline v_int64x2 v_lut(const int64_t* tab, const int* idx) +{ + return v_int64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_int64x2 v_lut_pairs(const int64_t* tab, const int* idx) +{ + return v_int64x2(wasm_v128_load(tab + idx[0])); +} +inline v_uint64x2 v_lut(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); } +inline v_uint64x2 v_lut_pairs(const uint64_t* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); } + +inline v_float32x4 v_lut(const float* tab, const int* idx) +{ + return v_float32x4(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]); +} +inline v_float32x4 v_lut_pairs(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_pairs((const int *)tab, idx)); } +inline v_float32x4 v_lut_quads(const float* tab, const int* idx) { return v_reinterpret_as_f32(v_lut_quads((const int *)tab, idx)); } + +inline v_float64x2 v_lut(const double* tab, const int* idx) +{ + return v_float64x2(tab[idx[0]], tab[idx[1]]); +} +inline v_float64x2 v_lut_pairs(const double* tab, const int* idx) +{ + return v_float64x2(wasm_v128_load(tab + idx[0])); +} + +inline v_int32x4 v_lut(const int* tab, const v_int32x4& idxvec) +{ + return v_int32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)]); +} + +inline v_uint32x4 v_lut(const unsigned* tab, const v_int32x4& idxvec) +{ + return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec)); +} + +inline v_float32x4 v_lut(const float* tab, const v_int32x4& idxvec) +{ + return v_float32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)]); +} + +inline v_float64x2 v_lut(const double* tab, const v_int32x4& idxvec) +{ + return v_float64x2(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)]); +} + +// loads pairs from the table and deinterleaves them, e.g. returns: +// x = (tab[idxvec[0], tab[idxvec[1]], tab[idxvec[2]], tab[idxvec[3]]), +// y = (tab[idxvec[0]+1], tab[idxvec[1]+1], tab[idxvec[2]+1], tab[idxvec[3]+1]) +// note that the indices are float's indices, not the float-pair indices. +// in theory, this function can be used to implement bilinear interpolation, +// when idxvec are the offsets within the image. +inline void v_lut_deinterleave(const float* tab, const v_int32x4& idxvec, v_float32x4& x, v_float32x4& y) +{ + x = v_float32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)]); + y = v_float32x4(tab[wasm_i32x4_extract_lane(idxvec.val, 0)+1], + tab[wasm_i32x4_extract_lane(idxvec.val, 1)+1], + tab[wasm_i32x4_extract_lane(idxvec.val, 2)+1], + tab[wasm_i32x4_extract_lane(idxvec.val, 3)+1]); +} + +inline void v_lut_deinterleave(const double* tab, const v_int32x4& idxvec, v_float64x2& x, v_float64x2& y) +{ + v128_t xy0 = wasm_v128_load(tab + wasm_i32x4_extract_lane(idxvec.val, 0)); + v128_t xy1 = wasm_v128_load(tab + wasm_i32x4_extract_lane(idxvec.val, 1)); + x.val = wasm_unpacklo_i64x2(xy0, xy1); + y.val = wasm_unpacklo_i64x2(xy0, xy1); +} + +inline v_int8x16 v_interleave_pairs(const v_int8x16& vec) +{ + return v_int8x16(wasm_v8x16_shuffle(vec.val, vec.val, 0,2,1,3,4,6,5,7,8,10,9,11,12,14,13,15)); +} +inline v_uint8x16 v_interleave_pairs(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_pairs(v_reinterpret_as_s8(vec))); } +inline v_int8x16 v_interleave_quads(const v_int8x16& vec) +{ + return v_int8x16(wasm_v8x16_shuffle(vec.val, vec.val, 0,4,1,5,2,6,3,7,8,12,9,13,10,14,11,15)); +} +inline v_uint8x16 v_interleave_quads(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_interleave_quads(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_interleave_pairs(const v_int16x8& vec) +{ + return v_int16x8(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15)); +} +inline v_uint16x8 v_interleave_pairs(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_pairs(v_reinterpret_as_s16(vec))); } +inline v_int16x8 v_interleave_quads(const v_int16x8& vec) +{ + return v_int16x8(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,8,9,2,3,10,11,4,5,12,13,6,7,14,15)); +} +inline v_uint16x8 v_interleave_quads(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_interleave_quads(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_interleave_pairs(const v_int32x4& vec) +{ + return v_int32x4(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,3,8,9,10,11,4,5,6,7,12,13,14,15)); +} +inline v_uint32x4 v_interleave_pairs(const v_uint32x4& vec) { return v_reinterpret_as_u32(v_interleave_pairs(v_reinterpret_as_s32(vec))); } +inline v_float32x4 v_interleave_pairs(const v_float32x4& vec) +{ + return v_float32x4(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,3,8,9,10,11,4,5,6,7,12,13,14,15)); +} + +inline v_int8x16 v_pack_triplets(const v_int8x16& vec) +{ + return v_int8x16(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,4,5,6,8,9,10,12,13,14,16,16,16,16)); +} +inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); } + +inline v_int16x8 v_pack_triplets(const v_int16x8& vec) +{ + return v_int16x8(wasm_v8x16_shuffle(vec.val, vec.val, 0,1,2,3,4,5,8,9,10,11,12,13,14,15,6,7)); +} +inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); } + +inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } +inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } +inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } + +template +inline typename _Tp::lane_type v_extract_n(const _Tp& a) +{ + return v_rotate_right(a).get0(); +} + +template +inline v_uint32x4 v_broadcast_element(const v_uint32x4& a) +{ + return v_setall_u32(v_extract_n(a)); +} +template +inline v_int32x4 v_broadcast_element(const v_int32x4& a) +{ + return v_setall_s32(v_extract_n(a)); +} +template +inline v_float32x4 v_broadcast_element(const v_float32x4& a) +{ + return v_setall_f32(v_extract_n(a)); +} + + +////////////// FP16 support /////////////////////////// + +inline v_float32x4 v_load_expand(const float16_t* ptr) +{ + float a[4]; + for (int i = 0; i < 4; i++) + a[i] = ptr[i]; + return v_float32x4(wasm_v128_load(a)); +} + +inline void v_pack_store(float16_t* ptr, const v_float32x4& v) +{ + double v_[4]; + wasm_v128_store(v_, v.val); + ptr[0] = float16_t(v_[0]); + ptr[1] = float16_t(v_[1]); + ptr[2] = float16_t(v_[2]); + ptr[3] = float16_t(v_[3]); +} + +inline void v_cleanup() {} + +CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END + +//! @endcond + +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/msa_macros.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/msa_macros.h new file mode 100644 index 0000000..bd6ddb1 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/msa_macros.h @@ -0,0 +1,1558 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_HAL_MSA_MACROS_H +#define OPENCV_CORE_HAL_MSA_MACROS_H + +#ifdef __mips_msa +#include "msa.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Define 64 bits vector types */ +typedef signed char v8i8 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned char v8u8 __attribute__ ((vector_size(8), aligned(8))); +typedef short v4i16 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned short v4u16 __attribute__ ((vector_size(8), aligned(8))); +typedef int v2i32 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned int v2u32 __attribute__ ((vector_size(8), aligned(8))); +typedef long long v1i64 __attribute__ ((vector_size(8), aligned(8))); +typedef unsigned long long v1u64 __attribute__ ((vector_size(8), aligned(8))); +typedef float v2f32 __attribute__ ((vector_size(8), aligned(8))); +typedef double v1f64 __attribute__ ((vector_size(8), aligned(8))); + + +/* Load values from the given memory a 64-bit vector. */ +#define msa_ld1_s8(__a) (*((v8i8*)(__a))) +#define msa_ld1_s16(__a) (*((v4i16*)(__a))) +#define msa_ld1_s32(__a) (*((v2i32*)(__a))) +#define msa_ld1_s64(__a) (*((v1i64*)(__a))) +#define msa_ld1_u8(__a) (*((v8u8*)(__a))) +#define msa_ld1_u16(__a) (*((v4u16*)(__a))) +#define msa_ld1_u32(__a) (*((v2u32*)(__a))) +#define msa_ld1_u64(__a) (*((v1u64*)(__a))) +#define msa_ld1_f32(__a) (*((v2f32*)(__a))) +#define msa_ld1_f64(__a) (*((v1f64*)(__a))) + +/* Load values from the given memory address to a 128-bit vector */ +#define msa_ld1q_s8(__a) ((v16i8)__builtin_msa_ld_b(__a, 0)) +#define msa_ld1q_s16(__a) ((v8i16)__builtin_msa_ld_h(__a, 0)) +#define msa_ld1q_s32(__a) ((v4i32)__builtin_msa_ld_w(__a, 0)) +#define msa_ld1q_s64(__a) ((v2i64)__builtin_msa_ld_d(__a, 0)) +#define msa_ld1q_u8(__a) ((v16u8)__builtin_msa_ld_b(__a, 0)) +#define msa_ld1q_u16(__a) ((v8u16)__builtin_msa_ld_h(__a, 0)) +#define msa_ld1q_u32(__a) ((v4u32)__builtin_msa_ld_w(__a, 0)) +#define msa_ld1q_u64(__a) ((v2u64)__builtin_msa_ld_d(__a, 0)) +#define msa_ld1q_f32(__a) ((v4f32)__builtin_msa_ld_w(__a, 0)) +#define msa_ld1q_f64(__a) ((v2f64)__builtin_msa_ld_d(__a, 0)) + +/* Store 64bits vector elements values to the given memory address. */ +#define msa_st1_s8(__a, __b) (*((v8i8*)(__a)) = __b) +#define msa_st1_s16(__a, __b) (*((v4i16*)(__a)) = __b) +#define msa_st1_s32(__a, __b) (*((v2i32*)(__a)) = __b) +#define msa_st1_s64(__a, __b) (*((v1i64*)(__a)) = __b) +#define msa_st1_u8(__a, __b) (*((v8u8*)(__a)) = __b) +#define msa_st1_u16(__a, __b) (*((v4u16*)(__a)) = __b) +#define msa_st1_u32(__a, __b) (*((v2u32*)(__a)) = __b) +#define msa_st1_u64(__a, __b) (*((v1u64*)(__a)) = __b) +#define msa_st1_f32(__a, __b) (*((v2f32*)(__a)) = __b) +#define msa_st1_f64(__a, __b) (*((v1f64*)(__a)) = __b) + +/* Store the values of elements in the 128 bits vector __a to the given memory address __a. */ +#define msa_st1q_s8(__a, __b) (__builtin_msa_st_b((v16i8)(__b), __a, 0)) +#define msa_st1q_s16(__a, __b) (__builtin_msa_st_h((v8i16)(__b), __a, 0)) +#define msa_st1q_s32(__a, __b) (__builtin_msa_st_w((v4i32)(__b), __a, 0)) +#define msa_st1q_s64(__a, __b) (__builtin_msa_st_d((v2i64)(__b), __a, 0)) +#define msa_st1q_u8(__a, __b) (__builtin_msa_st_b((v16i8)(__b), __a, 0)) +#define msa_st1q_u16(__a, __b) (__builtin_msa_st_h((v8i16)(__b), __a, 0)) +#define msa_st1q_u32(__a, __b) (__builtin_msa_st_w((v4i32)(__b), __a, 0)) +#define msa_st1q_u64(__a, __b) (__builtin_msa_st_d((v2i64)(__b), __a, 0)) +#define msa_st1q_f32(__a, __b) (__builtin_msa_st_w((v4i32)(__b), __a, 0)) +#define msa_st1q_f64(__a, __b) (__builtin_msa_st_d((v2i64)(__b), __a, 0)) + +/* Store the value of the element with the index __c in vector __a to the given memory address __a. */ +#define msa_st1_lane_s8(__a, __b, __c) (*((int8_t*)(__a)) = __b[__c]) +#define msa_st1_lane_s16(__a, __b, __c) (*((int16_t*)(__a)) = __b[__c]) +#define msa_st1_lane_s32(__a, __b, __c) (*((int32_t*)(__a)) = __b[__c]) +#define msa_st1_lane_s64(__a, __b, __c) (*((int64_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u8(__a, __b, __c) (*((uint8_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u16(__a, __b, __c) (*((uint16_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u32(__a, __b, __c) (*((uint32_t*)(__a)) = __b[__c]) +#define msa_st1_lane_u64(__a, __b, __c) (*((uint64_t*)(__a)) = __b[__c]) +#define msa_st1_lane_f32(__a, __b, __c) (*((float*)(__a)) = __b[__c]) +#define msa_st1_lane_f64(__a, __b, __c) (*((double*)(__a)) = __b[__c]) +#define msa_st1q_lane_s8(__a, __b, __c) (*((int8_t*)(__a)) = (int8_t)__builtin_msa_copy_s_b(__b, __c)) +#define msa_st1q_lane_s16(__a, __b, __c) (*((int16_t*)(__a)) = (int16_t)__builtin_msa_copy_s_h(__b, __c)) +#define msa_st1q_lane_s32(__a, __b, __c) (*((int32_t*)(__a)) = __builtin_msa_copy_s_w(__b, __c)) +#define msa_st1q_lane_s64(__a, __b, __c) (*((int64_t*)(__a)) = __builtin_msa_copy_s_d(__b, __c)) +#define msa_st1q_lane_u8(__a, __b, __c) (*((uint8_t*)(__a)) = (uint8_t)__builtin_msa_copy_u_b((v16i8)(__b), __c)) +#define msa_st1q_lane_u16(__a, __b, __c) (*((uint16_t*)(__a)) = (uint16_t)__builtin_msa_copy_u_h((v8i16)(__b), __c)) +#define msa_st1q_lane_u32(__a, __b, __c) (*((uint32_t*)(__a)) = __builtin_msa_copy_u_w((v4i32)(__b), __c)) +#define msa_st1q_lane_u64(__a, __b, __c) (*((uint64_t*)(__a)) = __builtin_msa_copy_u_d((v2i64)(__b), __c)) +#define msa_st1q_lane_f32(__a, __b, __c) (*((float*)(__a)) = __b[__c]) +#define msa_st1q_lane_f64(__a, __b, __c) (*((double*)(__a)) = __b[__c]) + +/* Duplicate elements for 64-bit doubleword vectors */ +#define msa_dup_n_s8(__a) ((v8i8)__builtin_msa_copy_s_d((v2i64)__builtin_msa_fill_b((int32_t)(__a)), 0)) +#define msa_dup_n_s16(__a) ((v4i16)__builtin_msa_copy_s_d((v2i64)__builtin_msa_fill_h((int32_t)(__a)), 0)) +#define msa_dup_n_s32(__a) ((v2i32){__a, __a}) +#define msa_dup_n_s64(__a) ((v1i64){__a}) +#define msa_dup_n_u8(__a) ((v8u8)__builtin_msa_copy_u_d((v2i64)__builtin_msa_fill_b((int32_t)(__a)), 0)) +#define msa_dup_n_u16(__a) ((v4u16)__builtin_msa_copy_u_d((v2i64)__builtin_msa_fill_h((int32_t)(__a)), 0)) +#define msa_dup_n_u32(__a) ((v2u32){__a, __a}) +#define msa_dup_n_u64(__a) ((v1u64){__a}) +#define msa_dup_n_f32(__a) ((v2f32){__a, __a}) +#define msa_dup_n_f64(__a) ((v1f64){__a}) + +/* Duplicate elements for 128-bit quadword vectors */ +#define msa_dupq_n_s8(__a) (__builtin_msa_fill_b((int32_t)(__a))) +#define msa_dupq_n_s16(__a) (__builtin_msa_fill_h((int32_t)(__a))) +#define msa_dupq_n_s32(__a) (__builtin_msa_fill_w((int32_t)(__a))) +#define msa_dupq_n_s64(__a) (__builtin_msa_fill_d((int64_t)(__a))) +#define msa_dupq_n_u8(__a) ((v16u8)__builtin_msa_fill_b((int32_t)(__a))) +#define msa_dupq_n_u16(__a) ((v8u16)__builtin_msa_fill_h((int32_t)(__a))) +#define msa_dupq_n_u32(__a) ((v4u32)__builtin_msa_fill_w((int32_t)(__a))) +#define msa_dupq_n_u64(__a) ((v2u64)__builtin_msa_fill_d((int64_t)(__a))) +#define msa_dupq_n_f32(__a) ((v4f32){__a, __a, __a, __a}) +#define msa_dupq_n_f64(__a) ((v2f64){__a, __a}) +#define msa_dupq_lane_s8(__a, __b) (__builtin_msa_splat_b(__a, __b)) +#define msa_dupq_lane_s16(__a, __b) (__builtin_msa_splat_h(__a, __b)) +#define msa_dupq_lane_s32(__a, __b) (__builtin_msa_splat_w(__a, __b)) +#define msa_dupq_lane_s64(__a, __b) (__builtin_msa_splat_d(__a, __b)) +#define msa_dupq_lane_u8(__a, __b) ((v16u8)__builtin_msa_splat_b((v16i8)(__a), __b)) +#define msa_dupq_lane_u16(__a, __b) ((v8u16)__builtin_msa_splat_h((v8i16)(__a), __b)) +#define msa_dupq_lane_u32(__a, __b) ((v4u32)__builtin_msa_splat_w((v4i32)(__a), __b)) +#define msa_dupq_lane_u64(__a, __b) ((v2u64)__builtin_msa_splat_d((v2i64)(__a), __b)) + +/* Create a 64 bits vector */ +#define msa_create_s8(__a) ((v8i8)((uint64_t)(__a))) +#define msa_create_s16(__a) ((v4i16)((uint64_t)(__a))) +#define msa_create_s32(__a) ((v2i32)((uint64_t)(__a))) +#define msa_create_s64(__a) ((v1i64)((uint64_t)(__a))) +#define msa_create_u8(__a) ((v8u8)((uint64_t)(__a))) +#define msa_create_u16(__a) ((v4u16)((uint64_t)(__a))) +#define msa_create_u32(__a) ((v2u32)((uint64_t)(__a))) +#define msa_create_u64(__a) ((v1u64)((uint64_t)(__a))) +#define msa_create_f32(__a) ((v2f32)((uint64_t)(__a))) +#define msa_create_f64(__a) ((v1f64)((uint64_t)(__a))) + +/* Sign extends or zero extends each element in a 64 bits vector to twice its original length, and places the results in a 128 bits vector. */ +/*Transform v8i8 to v8i16*/ +#define msa_movl_s8(__a) \ +((v8i16){(__a)[0], (__a)[1], (__a)[2], (__a)[3], \ + (__a)[4], (__a)[5], (__a)[6], (__a)[7]}) + +/*Transform v8u8 to v8u16*/ +#define msa_movl_u8(__a) \ +((v8u16){(__a)[0], (__a)[1], (__a)[2], (__a)[3], \ + (__a)[4], (__a)[5], (__a)[6], (__a)[7]}) + +/*Transform v4i16 to v8i16*/ +#define msa_movl_s16(__a) ((v4i32){(__a)[0], (__a)[1], (__a)[2], (__a)[3]}) + +/*Transform v2i32 to v4i32*/ +#define msa_movl_s32(__a) ((v2i64){(__a)[0], (__a)[1]}) + +/*Transform v4u16 to v8u16*/ +#define msa_movl_u16(__a) ((v4u32){(__a)[0], (__a)[1], (__a)[2], (__a)[3]}) + +/*Transform v2u32 to v4u32*/ +#define msa_movl_u32(__a) ((v2u64){(__a)[0], (__a)[1]}) + +/* Copies the least significant half of each element of a 128 bits vector into the corresponding elements of a 64 bits vector. */ +#define msa_movn_s16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)(__a)); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_movn_s32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)(__a)); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_movn_s64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)(__a)); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_movn_u16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)(__a)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_movn_u32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)(__a)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_movn_u64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)(__a)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* qmovn */ +#define msa_qmovn_s16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_s_h((v8i16)(__a), 7)); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_s32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_s_w((v4i32)(__a), 15)); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_s64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_s_d((v2i64)(__a), 31)); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_u16(__a) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_u_h((v8u16)(__a), 7)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_u32(__a) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_u_w((v4u32)(__a), 15)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_qmovn_u64(__a) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_u_d((v2u64)(__a), 31)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* qmovun */ +#define msa_qmovun_s16(__a) \ +({ \ + v8i16 __d = __builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a)); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_u_h((v8u16)__d, 7)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qmovun_s32(__a) \ +({ \ + v4i32 __d = __builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a)); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_u_w((v4u32)__d, 15)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qmovun_s64(__a) \ +({ \ + v2i64 __d = __builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a)); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_u_d((v2u64)__d, 31)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, and places the results in a 64 bits vector. */ +#define msa_shrn_n_s16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srai_h((v8i16)(__a), (int)(__b))); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_s32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srai_w((v4i32)(__a), (int)(__b))); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_s64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srai_d((v2i64)(__a), (int)(__b))); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_u16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srli_h((v8i16)(__a), (int)(__b))); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_u32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srli_w((v4i32)(__a), (int)(__b))); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_shrn_n_u64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srli_d((v2i64)(__a), (int)(__b))); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, and places the results in a 64 bits vector. */ +#define msa_rshrn_n_s16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srari_h((v8i16)(__a), (int)__b)); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_s32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srari_w((v4i32)(__a), (int)__b)); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_s64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srari_d((v2i64)(__a), (int)__b)); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_u16(__a, __b) \ +({ \ + v16i8 __d = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_srlri_h((v8i16)(__a), (int)__b)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_u32(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_srlri_w((v4i32)(__a), (int)__b)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +#define msa_rshrn_n_u64(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_srlri_d((v2i64)(__a), (int)__b)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__d, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, saturate the results and them in a 64 bits vector. */ +#define msa_qrshrn_n_s16(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_sat_s_h(__builtin_msa_srari_h((v8i16)(__a), (int)(__b)), 7); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__d); \ + (v8i8)__builtin_msa_copy_s_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_s32(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_sat_s_w(__builtin_msa_srari_w((v4i32)(__a), (int)(__b)), 15); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__d); \ + (v4i16)__builtin_msa_copy_s_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_s64(__a, __b) \ +({ \ + v2i64 __d = __builtin_msa_sat_s_d(__builtin_msa_srari_d((v2i64)(__a), (int)(__b)), 31); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__d); \ + (v2i32)__builtin_msa_copy_s_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_u16(__a, __b) \ +({ \ + v8u16 __d = __builtin_msa_sat_u_h((v8u16)__builtin_msa_srlri_h((v8i16)(__a), (int)(__b)), 7); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__d); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_u32(__a, __b) \ +({ \ + v4u32 __d = __builtin_msa_sat_u_w((v4u32)__builtin_msa_srlri_w((v4i32)(__a), (int)(__b)), 15); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__d); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrn_n_u64(__a, __b) \ +({ \ + v2u64 __d = __builtin_msa_sat_u_d((v2u64)__builtin_msa_srlri_d((v2i64)(__a), (int)(__b)), 31); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__d); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +/* Right shift elements in a 128 bits vector by an immediate value, saturate the results and them in a 64 bits vector. + Input is signed and output is unsigned. */ +#define msa_qrshrun_n_s16(__a, __b) \ +({ \ + v8i16 __d = __builtin_msa_srlri_h(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a)), (int)(__b)); \ + v16i8 __e = __builtin_msa_pckev_b(__builtin_msa_fill_b(0), (v16i8)__builtin_msa_sat_u_h((v8u16)__d, 7)); \ + (v8u8)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrun_n_s32(__a, __b) \ +({ \ + v4i32 __d = __builtin_msa_srlri_w(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a)), (int)(__b)); \ + v8i16 __e = __builtin_msa_pckev_h(__builtin_msa_fill_h(0), (v8i16)__builtin_msa_sat_u_w((v4u32)__d, 15)); \ + (v4u16)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +#define msa_qrshrun_n_s64(__a, __b) \ +({ \ + v2i64 __d = __builtin_msa_srlri_d(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a)), (int)(__b)); \ + v4i32 __e = __builtin_msa_pckev_w(__builtin_msa_fill_w(0), (v4i32)__builtin_msa_sat_u_d((v2u64)__d, 31)); \ + (v2u32)__builtin_msa_copy_u_d((v2i64)__e, 0); \ +}) + +/* pack */ +#define msa_pack_s16(__a, __b) (__builtin_msa_pckev_b((v16i8)(__b), (v16i8)(__a))) +#define msa_pack_s32(__a, __b) (__builtin_msa_pckev_h((v8i16)(__b), (v8i16)(__a))) +#define msa_pack_s64(__a, __b) (__builtin_msa_pckev_w((v4i32)(__b), (v4i32)(__a))) +#define msa_pack_u16(__a, __b) ((v16u8)__builtin_msa_pckev_b((v16i8)(__b), (v16i8)(__a))) +#define msa_pack_u32(__a, __b) ((v8u16)__builtin_msa_pckev_h((v8i16)(__b), (v8i16)(__a))) +#define msa_pack_u64(__a, __b) ((v4u32)__builtin_msa_pckev_w((v4i32)(__b), (v4i32)(__a))) + +/* qpack */ +#define msa_qpack_s16(__a, __b) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_s_h((v8i16)(__b), 7), (v16i8)__builtin_msa_sat_s_h((v8i16)(__a), 7))) +#define msa_qpack_s32(__a, __b) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_s_w((v4i32)(__b), 15), (v8i16)__builtin_msa_sat_s_w((v4i32)(__a), 15))) +#define msa_qpack_s64(__a, __b) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_s_d((v2i64)(__b), 31), (v4i32)__builtin_msa_sat_s_d((v2i64)(__a), 31))) +#define msa_qpack_u16(__a, __b) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)(__b), 7), (v16i8)__builtin_msa_sat_u_h((v8u16)(__a), 7))) +#define msa_qpack_u32(__a, __b) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)(__b), 15), (v8i16)__builtin_msa_sat_u_w((v4u32)(__a), 15))) +#define msa_qpack_u64(__a, __b) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)(__b), 31), (v4i32)__builtin_msa_sat_u_d((v2u64)(__a), 31))) + +/* qpacku */ +#define msa_qpacku_s16(__a, __b) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__b))), 7), \ + (v16i8)__builtin_msa_sat_u_h((v8u16)(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a))), 7))) +#define msa_qpacku_s32(__a, __b) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__b))), 15), \ + (v8i16)__builtin_msa_sat_u_w((v4u32)(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a))), 15))) +#define msa_qpacku_s64(__a, __b) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__b))), 31), \ + (v4i32)__builtin_msa_sat_u_d((v2u64)(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a))), 31))) + +/* packr */ +#define msa_packr_s16(__a, __b, __c) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_srai_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srai_h((v8i16)(__a), (int)(__c)))) +#define msa_packr_s32(__a, __b, __c) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_srai_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srai_w((v4i32)(__a), (int)(__c)))) +#define msa_packr_s64(__a, __b, __c) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_srai_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srai_d((v2i64)(__a), (int)(__c)))) +#define msa_packr_u16(__a, __b, __c) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_srli_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srli_h((v8i16)(__a), (int)(__c)))) +#define msa_packr_u32(__a, __b, __c) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_srli_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srli_w((v4i32)(__a), (int)(__c)))) +#define msa_packr_u64(__a, __b, __c) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_srli_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srli_d((v2i64)(__a), (int)(__c)))) + +/* rpackr */ +#define msa_rpackr_s16(__a, __b, __c) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_srari_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srari_h((v8i16)(__a), (int)(__c)))) +#define msa_rpackr_s32(__a, __b, __c) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_srari_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srari_w((v4i32)(__a), (int)(__c)))) +#define msa_rpackr_s64(__a, __b, __c) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_srari_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srari_d((v2i64)(__a), (int)(__c)))) +#define msa_rpackr_u16(__a, __b, __c) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_srlri_h((v8i16)(__b), (int)(__c)), (v16i8)__builtin_msa_srlri_h((v8i16)(__a), (int)(__c)))) +#define msa_rpackr_u32(__a, __b, __c) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_srlri_w((v4i32)(__b), (int)(__c)), (v8i16)__builtin_msa_srlri_w((v4i32)(__a), (int)(__c)))) +#define msa_rpackr_u64(__a, __b, __c) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_srlri_d((v2i64)(__b), (int)(__c)), (v4i32)__builtin_msa_srlri_d((v2i64)(__a), (int)(__c)))) + +/* qrpackr */ +#define msa_qrpackr_s16(__a, __b, __c) \ +(__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_s_h(__builtin_msa_srari_h((v8i16)(__b), (int)(__c)), 7), \ + (v16i8)__builtin_msa_sat_s_h(__builtin_msa_srari_h((v8i16)(__a), (int)(__c)), 7))) +#define msa_qrpackr_s32(__a, __b, __c) \ +(__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_s_w(__builtin_msa_srari_w((v4i32)(__b), (int)(__c)), 15), \ + (v8i16)__builtin_msa_sat_s_w(__builtin_msa_srari_w((v4i32)(__a), (int)(__c)), 15))) +#define msa_qrpackr_s64(__a, __b, __c) \ +(__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_s_d(__builtin_msa_srari_d((v2i64)(__b), (int)(__c)), 31), \ + (v4i32)__builtin_msa_sat_s_d(__builtin_msa_srari_d((v2i64)(__a), (int)(__c)), 31))) +#define msa_qrpackr_u16(__a, __b, __c) \ +((v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)__builtin_msa_srlri_h((v8i16)(__b), (int)(__c)), 7), \ + (v16i8)__builtin_msa_sat_u_h((v8u16)__builtin_msa_srlri_h((v8i16)(__a), (int)(__c)), 7))) +#define msa_qrpackr_u32(__a, __b, __c) \ +((v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)__builtin_msa_srlri_w((v4i32)(__b), (int)(__c)), 15), \ + (v8i16)__builtin_msa_sat_u_w((v4u32)__builtin_msa_srlri_w((v4i32)(__a), (int)(__c)), 15))) +#define msa_qrpackr_u64(__a, __b, __c) \ +((v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)__builtin_msa_srlri_d((v2i64)(__b), (int)(__c)), 31), \ + (v4i32)__builtin_msa_sat_u_d((v2u64)__builtin_msa_srlri_d((v2i64)(__a), (int)(__c)), 31))) + +/* qrpackru */ +#define msa_qrpackru_s16(__a, __b, __c) \ +({ \ + v8i16 __d = __builtin_msa_srlri_h(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__a)), (int)(__c)); \ + v8i16 __e = __builtin_msa_srlri_h(__builtin_msa_max_s_h(__builtin_msa_fill_h(0), (v8i16)(__b)), (int)(__c)); \ + (v16u8)__builtin_msa_pckev_b((v16i8)__builtin_msa_sat_u_h((v8u16)__e, 7), (v16i8)__builtin_msa_sat_u_h((v8u16)__d, 7)); \ +}) + +#define msa_qrpackru_s32(__a, __b, __c) \ +({ \ + v4i32 __d = __builtin_msa_srlri_w(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__a)), (int)(__c)); \ + v4i32 __e = __builtin_msa_srlri_w(__builtin_msa_max_s_w(__builtin_msa_fill_w(0), (v4i32)(__b)), (int)(__c)); \ + (v8u16)__builtin_msa_pckev_h((v8i16)__builtin_msa_sat_u_w((v4u32)__e, 15), (v8i16)__builtin_msa_sat_u_w((v4u32)__d, 15)); \ +}) + +#define msa_qrpackru_s64(__a, __b, __c) \ +({ \ + v2i64 __d = __builtin_msa_srlri_d(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__a)), (int)(__c)); \ + v2i64 __e = __builtin_msa_srlri_d(__builtin_msa_max_s_d(__builtin_msa_fill_d(0), (v2i64)(__b)), (int)(__c)); \ + (v4u32)__builtin_msa_pckev_w((v4i32)__builtin_msa_sat_u_d((v2u64)__e, 31), (v4i32)__builtin_msa_sat_u_d((v2u64)__d, 31)); \ +}) + +/* Minimum values between corresponding elements in the two vectors are written to the returned vector. */ +#define msa_minq_s8(__a, __b) (__builtin_msa_min_s_b(__a, __b)) +#define msa_minq_s16(__a, __b) (__builtin_msa_min_s_h(__a, __b)) +#define msa_minq_s32(__a, __b) (__builtin_msa_min_s_w(__a, __b)) +#define msa_minq_s64(__a, __b) (__builtin_msa_min_s_d(__a, __b)) +#define msa_minq_u8(__a, __b) ((v16u8)__builtin_msa_min_u_b(__a, __b)) +#define msa_minq_u16(__a, __b) ((v8u16)__builtin_msa_min_u_h(__a, __b)) +#define msa_minq_u32(__a, __b) ((v4u32)__builtin_msa_min_u_w(__a, __b)) +#define msa_minq_u64(__a, __b) ((v2u64)__builtin_msa_min_u_d(__a, __b)) +#define msa_minq_f32(__a, __b) (__builtin_msa_fmin_w(__a, __b)) +#define msa_minq_f64(__a, __b) (__builtin_msa_fmin_d(__a, __b)) + +/* Maximum values between corresponding elements in the two vectors are written to the returned vector. */ +#define msa_maxq_s8(__a, __b) (__builtin_msa_max_s_b(__a, __b)) +#define msa_maxq_s16(__a, __b) (__builtin_msa_max_s_h(__a, __b)) +#define msa_maxq_s32(__a, __b) (__builtin_msa_max_s_w(__a, __b)) +#define msa_maxq_s64(__a, __b) (__builtin_msa_max_s_d(__a, __b)) +#define msa_maxq_u8(__a, __b) ((v16u8)__builtin_msa_max_u_b(__a, __b)) +#define msa_maxq_u16(__a, __b) ((v8u16)__builtin_msa_max_u_h(__a, __b)) +#define msa_maxq_u32(__a, __b) ((v4u32)__builtin_msa_max_u_w(__a, __b)) +#define msa_maxq_u64(__a, __b) ((v2u64)__builtin_msa_max_u_d(__a, __b)) +#define msa_maxq_f32(__a, __b) (__builtin_msa_fmax_w(__a, __b)) +#define msa_maxq_f64(__a, __b) (__builtin_msa_fmax_d(__a, __b)) + +/* Vector type reinterpretion */ +#define MSA_TPV_REINTERPRET(_Tpv, Vec) ((_Tpv)(Vec)) + +/* Add the odd elements in vector __a with the even elements in vector __b to double width elements in the returned vector. */ +/* v8i16 msa_hadd_s16 ((v16i8)__a, (v16i8)__b) */ +#define msa_hadd_s16(__a, __b) (__builtin_msa_hadd_s_h((v16i8)(__a), (v16i8)(__b))) +/* v4i32 msa_hadd_s32 ((v8i16)__a, (v8i16)__b) */ +#define msa_hadd_s32(__a, __b) (__builtin_msa_hadd_s_w((v8i16)(__a), (v8i16)(__b))) +/* v2i64 msa_hadd_s64 ((v4i32)__a, (v4i32)__b) */ +#define msa_hadd_s64(__a, __b) (__builtin_msa_hadd_s_d((v4i32)(__a), (v4i32)(__b))) + +/* Copy even elements in __a to the left half and even elements in __b to the right half and return the result vector. */ +#define msa_pckev_s8(__a, __b) (__builtin_msa_pckev_b((v16i8)(__a), (v16i8)(__b))) +#define msa_pckev_s16(__a, __b) (__builtin_msa_pckev_h((v8i16)(__a), (v8i16)(__b))) +#define msa_pckev_s32(__a, __b) (__builtin_msa_pckev_w((v4i32)(__a), (v4i32)(__b))) +#define msa_pckev_s64(__a, __b) (__builtin_msa_pckev_d((v2i64)(__a), (v2i64)(__b))) + +/* Copy even elements in __a to the left half and even elements in __b to the right half and return the result vector. */ +#define msa_pckod_s8(__a, __b) (__builtin_msa_pckod_b((v16i8)(__a), (v16i8)(__b))) +#define msa_pckod_s16(__a, __b) (__builtin_msa_pckod_h((v8i16)(__a), (v8i16)(__b))) +#define msa_pckod_s32(__a, __b) (__builtin_msa_pckod_w((v4i32)(__a), (v4i32)(__b))) +#define msa_pckod_s64(__a, __b) (__builtin_msa_pckod_d((v2i64)(__a), (v2i64)(__b))) + +#ifdef _MIPSEB +#define LANE_IMM0_1(x) (0b1 - ((x) & 0b1)) +#define LANE_IMM0_3(x) (0b11 - ((x) & 0b11)) +#define LANE_IMM0_7(x) (0b111 - ((x) & 0b111)) +#define LANE_IMM0_15(x) (0b1111 - ((x) & 0b1111)) +#else +#define LANE_IMM0_1(x) ((x) & 0b1) +#define LANE_IMM0_3(x) ((x) & 0b11) +#define LANE_IMM0_7(x) ((x) & 0b111) +#define LANE_IMM0_15(x) ((x) & 0b1111) +#endif + +#define msa_get_lane_u8(__a, __b) ((uint8_t)(__a)[LANE_IMM0_7(__b)]) +#define msa_get_lane_s8(__a, __b) ((int8_t)(__a)[LANE_IMM0_7(__b)]) +#define msa_get_lane_u16(__a, __b) ((uint16_t)(__a)[LANE_IMM0_3(__b)]) +#define msa_get_lane_s16(__a, __b) ((int16_t)(__a)[LANE_IMM0_3(__b)]) +#define msa_get_lane_u32(__a, __b) ((uint32_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_s32(__a, __b) ((int32_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_f32(__a, __b) ((float)(__a)[LANE_IMM0_3(__b)]) +#define msa_get_lane_s64(__a, __b) ((int64_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_u64(__a, __b) ((uint64_t)(__a)[LANE_IMM0_1(__b)]) +#define msa_get_lane_f64(__a, __b) ((double)(__a)[LANE_IMM0_1(__b)]) +#define msa_getq_lane_u8(__a, imm0_15) ((uint8_t)__builtin_msa_copy_u_b((v16i8)(__a), imm0_15)) +#define msa_getq_lane_s8(__a, imm0_15) ((int8_t)__builtin_msa_copy_s_b(__a, imm0_15)) +#define msa_getq_lane_u16(__a, imm0_7) ((uint16_t)__builtin_msa_copy_u_h((v8i16)(__a), imm0_7)) +#define msa_getq_lane_s16(__a, imm0_7) ((int16_t)__builtin_msa_copy_s_h(__a, imm0_7)) +#define msa_getq_lane_u32(__a, imm0_3) __builtin_msa_copy_u_w((v4i32)(__a), imm0_3) +#define msa_getq_lane_s32 __builtin_msa_copy_s_w +#define msa_getq_lane_f32(__a, __b) ((float)(__a)[LANE_IMM0_3(__b)]) +#define msa_getq_lane_f64(__a, __b) ((double)(__a)[LANE_IMM0_1(__b)]) +#if (__mips == 64) +#define msa_getq_lane_u64(__a, imm0_1) __builtin_msa_copy_u_d((v2i64)(__a), imm0_1) +#define msa_getq_lane_s64 __builtin_msa_copy_s_d +#else +#define msa_getq_lane_u64(__a, imm0_1) ((uint64_t)(__a)[LANE_IMM0_1(imm0_1)]) +#define msa_getq_lane_s64(__a, imm0_1) ((int64_t)(__a)[LANE_IMM0_1(imm0_1)]) +#endif + +/* combine */ +#if (__mips == 64) +#define __COMBINE_64_64(__TYPE, a, b) ((__TYPE)((v2u64){((v1u64)(a))[0], ((v1u64)(b))[0]})) +#else +#define __COMBINE_64_64(__TYPE, a, b) ((__TYPE)((v4u32){((v2u32)(a))[0], ((v2u32)(a))[1], \ + ((v2u32)(b))[0], ((v2u32)(b))[1]})) +#endif + +/* v16i8 msa_combine_s8 (v8i8 __a, v8i8 __b) */ +#define msa_combine_s8(__a, __b) __COMBINE_64_64(v16i8, __a, __b) + +/* v8i16 msa_combine_s16(v4i16 __a, v4i16 __b) */ +#define msa_combine_s16(__a, __b) __COMBINE_64_64(v8i16, __a, __b) + +/* v4i32 msa_combine_s32(v2i32 __a, v2i32 __b) */ +#define msa_combine_s32(__a, __b) __COMBINE_64_64(v4i32, __a, __b) + +/* v2i64 msa_combine_s64(v1i64 __a, v1i64 __b) */ +#define msa_combine_s64(__a, __b) __COMBINE_64_64(v2i64, __a, __b) + +/* v4f32 msa_combine_f32(v2f32 __a, v2f32 __b) */ +#define msa_combine_f32(__a, __b) __COMBINE_64_64(v4f32, __a, __b) + +/* v16u8 msa_combine_u8(v8u8 __a, v8u8 __b) */ +#define msa_combine_u8(__a, __b) __COMBINE_64_64(v16u8, __a, __b) + +/* v8u16 msa_combine_u16(v4u16 __a, v4u16 __b) */ +#define msa_combine_u16(__a, __b) __COMBINE_64_64(v8u16, __a, __b) + +/* v4u32 msa_combine_u32(v2u32 __a, v2u32 __b) */ +#define msa_combine_u32(__a, __b) __COMBINE_64_64(v4u32, __a, __b) + +/* v2u64 msa_combine_u64(v1u64 __a, v1u64 __b) */ +#define msa_combine_u64(__a, __b) __COMBINE_64_64(v2u64, __a, __b) + +/* v2f64 msa_combine_f64(v1f64 __a, v1f64 __b) */ +#define msa_combine_f64(__a, __b) __COMBINE_64_64(v2f64, __a, __b) + +/* get_low, get_high */ +#if (__mips == 64) +#define __GET_LOW(__TYPE, a) ((__TYPE)((v1u64)(__builtin_msa_copy_u_d((v2i64)(a), 0)))) +#define __GET_HIGH(__TYPE, a) ((__TYPE)((v1u64)(__builtin_msa_copy_u_d((v2i64)(a), 1)))) +#else +#define __GET_LOW(__TYPE, a) ((__TYPE)(((v2u64)(a))[0])) +#define __GET_HIGH(__TYPE, a) ((__TYPE)(((v2u64)(a))[1])) +#endif + +/* v8i8 msa_get_low_s8(v16i8 __a) */ +#define msa_get_low_s8(__a) __GET_LOW(v8i8, __a) + +/* v4i16 msa_get_low_s16(v8i16 __a) */ +#define msa_get_low_s16(__a) __GET_LOW(v4i16, __a) + +/* v2i32 msa_get_low_s32(v4i32 __a) */ +#define msa_get_low_s32(__a) __GET_LOW(v2i32, __a) + +/* v1i64 msa_get_low_s64(v2i64 __a) */ +#define msa_get_low_s64(__a) __GET_LOW(v1i64, __a) + +/* v8u8 msa_get_low_u8(v16u8 __a) */ +#define msa_get_low_u8(__a) __GET_LOW(v8u8, __a) + +/* v4u16 msa_get_low_u16(v8u16 __a) */ +#define msa_get_low_u16(__a) __GET_LOW(v4u16, __a) + +/* v2u32 msa_get_low_u32(v4u32 __a) */ +#define msa_get_low_u32(__a) __GET_LOW(v2u32, __a) + +/* v1u64 msa_get_low_u64(v2u64 __a) */ +#define msa_get_low_u64(__a) __GET_LOW(v1u64, __a) + +/* v2f32 msa_get_low_f32(v4f32 __a) */ +#define msa_get_low_f32(__a) __GET_LOW(v2f32, __a) + +/* v1f64 msa_get_low_f64(v2f64 __a) */ +#define msa_get_low_f64(__a) __GET_LOW(v1f64, __a) + +/* v8i8 msa_get_high_s8(v16i8 __a) */ +#define msa_get_high_s8(__a) __GET_HIGH(v8i8, __a) + +/* v4i16 msa_get_high_s16(v8i16 __a) */ +#define msa_get_high_s16(__a) __GET_HIGH(v4i16, __a) + +/* v2i32 msa_get_high_s32(v4i32 __a) */ +#define msa_get_high_s32(__a) __GET_HIGH(v2i32, __a) + +/* v1i64 msa_get_high_s64(v2i64 __a) */ +#define msa_get_high_s64(__a) __GET_HIGH(v1i64, __a) + +/* v8u8 msa_get_high_u8(v16u8 __a) */ +#define msa_get_high_u8(__a) __GET_HIGH(v8u8, __a) + +/* v4u16 msa_get_high_u16(v8u16 __a) */ +#define msa_get_high_u16(__a) __GET_HIGH(v4u16, __a) + +/* v2u32 msa_get_high_u32(v4u32 __a) */ +#define msa_get_high_u32(__a) __GET_HIGH(v2u32, __a) + +/* v1u64 msa_get_high_u64(v2u64 __a) */ +#define msa_get_high_u64(__a) __GET_HIGH(v1u64, __a) + +/* v2f32 msa_get_high_f32(v4f32 __a) */ +#define msa_get_high_f32(__a) __GET_HIGH(v2f32, __a) + +/* v1f64 msa_get_high_f64(v2f64 __a) */ +#define msa_get_high_f64(__a) __GET_HIGH(v1f64, __a) + +/* ri = ai * b[lane] */ +/* v4f32 msa_mulq_lane_f32(v4f32 __a, v4f32 __b, const int __lane) */ +#define msa_mulq_lane_f32(__a, __b, __lane) ((__a) * msa_getq_lane_f32(__b, __lane)) + +/* ri = ai + bi * c[lane] */ +/* v4f32 msa_mlaq_lane_f32(v4f32 __a, v4f32 __b, v4f32 __c, const int __lane) */ +#define msa_mlaq_lane_f32(__a, __b, __c, __lane) ((__a) + ((__b) * msa_getq_lane_f32(__c, __lane))) + +/* uint16_t msa_sum_u16(v8u16 __a)*/ +#define msa_sum_u16(__a) \ +({ \ + v4u32 _b; \ + v2u64 _c; \ + _b = __builtin_msa_hadd_u_w(__a, __a); \ + _c = __builtin_msa_hadd_u_d(_b, _b); \ + (uint16_t)(_c[0] + _c[1]); \ +}) + +/* int16_t msa_sum_s16(v8i16 __a) */ +#define msa_sum_s16(__a) \ +({ \ + v4i32 _b; \ + v2i64 _c; \ + _b = __builtin_msa_hadd_s_w(__a, __a); \ + _c = __builtin_msa_hadd_s_d(_b, _b); \ + (int16_t)(_c[0] + _c[1]); \ +}) + + +/* uint32_t msa_sum_u32(v4u32 __a)*/ +#define msa_sum_u32(__a) \ +({ \ + v2u64 _b; \ + _b = __builtin_msa_hadd_u_d(__a, __a); \ + (uint32_t)(_b[0] + _b[1]); \ +}) + +/* int32_t msa_sum_s32(v4i32 __a)*/ +#define msa_sum_s32(__a) \ +({ \ + v2i64 _b; \ + _b = __builtin_msa_hadd_s_d(__a, __a); \ + (int32_t)(_b[0] + _b[1]); \ +}) + +/* uint8_t msa_sum_u8(v16u8 __a)*/ +#define msa_sum_u8(__a) \ +({ \ + v8u16 _b16; \ + v4u32 _c32; \ + _b16 = __builtin_msa_hadd_u_h(__a, __a); \ + _c32 = __builtin_msa_hadd_u_w(_b16, _b16); \ + (uint8_t)msa_sum_u32(_c32); \ +}) + +/* int8_t msa_sum_s8(v16s8 __a)*/ +#define msa_sum_s8(__a) \ +({ \ + v8i16 _b16; \ + v4i32 _c32; \ + _b16 = __builtin_msa_hadd_s_h(__a, __a); \ + _c32 = __builtin_msa_hadd_s_w(_b16, _b16); \ + (int8_t)msa_sum_s32(_c32); \ +}) + +/* float msa_sum_f32(v4f32 __a)*/ +#define msa_sum_f32(__a) ((__a)[0] + (__a)[1] + (__a)[2] + (__a)[3]) + +/* v8u16 msa_paddlq_u8(v16u8 __a) */ +#define msa_paddlq_u8(__a) (__builtin_msa_hadd_u_h(__a, __a)) + +/* v8i16 msa_paddlq_s8(v16i8 __a) */ +#define msa_paddlq_s8(__a) (__builtin_msa_hadd_s_h(__a, __a)) + +/* v4u32 msa_paddlq_u16 (v8u16 __a)*/ +#define msa_paddlq_u16(__a) (__builtin_msa_hadd_u_w(__a, __a)) + +/* v4i32 msa_paddlq_s16 (v8i16 __a)*/ +#define msa_paddlq_s16(__a) (__builtin_msa_hadd_s_w(__a, __a)) + +/* v2u64 msa_paddlq_u32(v4u32 __a) */ +#define msa_paddlq_u32(__a) (__builtin_msa_hadd_u_d(__a, __a)) + +/* v2i64 msa_paddlq_s32(v4i32 __a) */ +#define msa_paddlq_s32(__a) (__builtin_msa_hadd_s_d(__a, __a)) + +#define V8U8_2_V8U16(x) {(uint16_t)x[0], (uint16_t)x[1], (uint16_t)x[2], (uint16_t)x[3], \ + (uint16_t)x[4], (uint16_t)x[5], (uint16_t)x[6], (uint16_t)x[7]} +#define V8U8_2_V8I16(x) {(int16_t)x[0], (int16_t)x[1], (int16_t)x[2], (int16_t)x[3], \ + (int16_t)x[4], (int16_t)x[5], (int16_t)x[6], (int16_t)x[7]} +#define V8I8_2_V8I16(x) {(int16_t)x[0], (int16_t)x[1], (int16_t)x[2], (int16_t)x[3], \ + (int16_t)x[4], (int16_t)x[5], (int16_t)x[6], (int16_t)x[7]} +#define V4U16_2_V4U32(x) {(uint32_t)x[0], (uint32_t)x[1], (uint32_t)x[2], (uint32_t)x[3]} +#define V4U16_2_V4I32(x) {(int32_t)x[0], (int32_t)x[1], (int32_t)x[2], (int32_t)x[3]} +#define V4I16_2_V4I32(x) {(int32_t)x[0], (int32_t)x[1], (int32_t)x[2], (int32_t)x[3]} +#define V2U32_2_V2U64(x) {(uint64_t)x[0], (uint64_t)x[1]} +#define V2U32_2_V2I64(x) {(int64_t)x[0], (int64_t)x[1]} + +/* v8u16 msa_mull_u8(v8u8 __a, v8u8 __b) */ +#define msa_mull_u8(__a, __b) ((v8u16)__builtin_msa_mulv_h((v8i16)V8U8_2_V8I16(__a), (v8i16)V8U8_2_V8I16(__b))) + +/* v8i16 msa_mull_s8(v8i8 __a, v8i8 __b)*/ +#define msa_mull_s8(__a, __b) (__builtin_msa_mulv_h((v8i16)V8I8_2_V8I16(__a), (v8i16)V8I8_2_V8I16(__b))) + +/* v4u32 msa_mull_u16(v4u16 __a, v4u16 __b) */ +#define msa_mull_u16(__a, __b) ((v4u32)__builtin_msa_mulv_w((v4i32)V4U16_2_V4I32(__a), (v4i32)V4U16_2_V4I32(__b))) + +/* v4i32 msa_mull_s16(v4i16 __a, v4i16 __b) */ +#define msa_mull_s16(__a, __b) (__builtin_msa_mulv_w((v4i32)V4I16_2_V4I32(__a), (v4i32)V4I16_2_V4I32(__b))) + +/* v2u64 msa_mull_u32(v2u32 __a, v2u32 __b) */ +#define msa_mull_u32(__a, __b) ((v2u64)__builtin_msa_mulv_d((v2i64)V2U32_2_V2I64(__a), (v2i64)V2U32_2_V2I64(__b))) + +/* bitwise and: __builtin_msa_and_v */ +#define msa_andq_u8(__a, __b) ((v16u8)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s8(__a, __b) ((v16i8)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_u16(__a, __b) ((v8u16)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s16(__a, __b) ((v8i16)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_u32(__a, __b) ((v4u32)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s32(__a, __b) ((v4i32)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_u64(__a, __b) ((v2u64)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) +#define msa_andq_s64(__a, __b) ((v2i64)__builtin_msa_and_v((v16u8)(__a), (v16u8)(__b))) + +/* bitwise or: __builtin_msa_or_v */ +#define msa_orrq_u8(__a, __b) ((v16u8)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s8(__a, __b) ((v16i8)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_u16(__a, __b) ((v8u16)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s16(__a, __b) ((v8i16)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_u32(__a, __b) ((v4u32)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s32(__a, __b) ((v4i32)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_u64(__a, __b) ((v2u64)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) +#define msa_orrq_s64(__a, __b) ((v2i64)__builtin_msa_or_v((v16u8)(__a), (v16u8)(__b))) + +/* bitwise xor: __builtin_msa_xor_v */ +#define msa_eorq_u8(__a, __b) ((v16u8)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s8(__a, __b) ((v16i8)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_u16(__a, __b) ((v8u16)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s16(__a, __b) ((v8i16)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_u32(__a, __b) ((v4u32)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s32(__a, __b) ((v4i32)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_u64(__a, __b) ((v2u64)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) +#define msa_eorq_s64(__a, __b) ((v2i64)__builtin_msa_xor_v((v16u8)(__a), (v16u8)(__b))) + +/* bitwise not: v16u8 __builtin_msa_xori_b (v16u8, 0xff) */ +#define msa_mvnq_u8(__a) ((v16u8)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s8(__a) ((v16i8)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_u16(__a) ((v8u16)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s16(__a) ((v8i16)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_u32(__a) ((v4u32)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s32(__a) ((v4i32)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_u64(__a) ((v2u64)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) +#define msa_mvnq_s64(__a) ((v2i64)__builtin_msa_xori_b((v16u8)(__a), 0xFF)) + +/* compare equal: ceq -> ri = ai == bi ? 1...1:0...0 */ +#define msa_ceqq_u8(__a, __b) ((v16u8)__builtin_msa_ceq_b((v16i8)(__a), (v16i8)(__b))) +#define msa_ceqq_s8(__a, __b) ((v16u8)__builtin_msa_ceq_b((v16i8)(__a), (v16i8)(__b))) +#define msa_ceqq_u16(__a, __b) ((v8u16)__builtin_msa_ceq_h((v8i16)(__a), (v8i16)(__b))) +#define msa_ceqq_s16(__a, __b) ((v8u16)__builtin_msa_ceq_h((v8i16)(__a), (v8i16)(__b))) +#define msa_ceqq_u32(__a, __b) ((v4u32)__builtin_msa_ceq_w((v4i32)(__a), (v4i32)(__b))) +#define msa_ceqq_s32(__a, __b) ((v4u32)__builtin_msa_ceq_w((v4i32)(__a), (v4i32)(__b))) +#define msa_ceqq_f32(__a, __b) ((v4u32)__builtin_msa_fceq_w((v4f32)(__a), (v4f32)(__b))) +#define msa_ceqq_u64(__a, __b) ((v2u64)__builtin_msa_ceq_d((v2i64)(__a), (v2i64)(__b))) +#define msa_ceqq_s64(__a, __b) ((v2u64)__builtin_msa_ceq_d((v2i64)(__a), (v2i64)(__b))) +#define msa_ceqq_f64(__a, __b) ((v2u64)__builtin_msa_fceq_d((v2f64)(__a), (v2f64)(__b))) + +/* Compare less-than: clt -> ri = ai < bi ? 1...1:0...0 */ +#define msa_cltq_u8(__a, __b) ((v16u8)__builtin_msa_clt_u_b((v16u8)(__a), (v16u8)(__b))) +#define msa_cltq_s8(__a, __b) ((v16u8)__builtin_msa_clt_s_b((v16i8)(__a), (v16i8)(__b))) +#define msa_cltq_u16(__a, __b) ((v8u16)__builtin_msa_clt_u_h((v8u16)(__a), (v8u16)(__b))) +#define msa_cltq_s16(__a, __b) ((v8u16)__builtin_msa_clt_s_h((v8i16)(__a), (v8i16)(__b))) +#define msa_cltq_u32(__a, __b) ((v4u32)__builtin_msa_clt_u_w((v4u32)(__a), (v4u32)(__b))) +#define msa_cltq_s32(__a, __b) ((v4u32)__builtin_msa_clt_s_w((v4i32)(__a), (v4i32)(__b))) +#define msa_cltq_f32(__a, __b) ((v4u32)__builtin_msa_fclt_w((v4f32)(__a), (v4f32)(__b))) +#define msa_cltq_u64(__a, __b) ((v2u64)__builtin_msa_clt_u_d((v2u64)(__a), (v2u64)(__b))) +#define msa_cltq_s64(__a, __b) ((v2u64)__builtin_msa_clt_s_d((v2i64)(__a), (v2i64)(__b))) +#define msa_cltq_f64(__a, __b) ((v2u64)__builtin_msa_fclt_d((v2f64)(__a), (v2f64)(__b))) + +/* compare greater-than: cgt -> ri = ai > bi ? 1...1:0...0 */ +#define msa_cgtq_u8(__a, __b) ((v16u8)__builtin_msa_clt_u_b((v16u8)(__b), (v16u8)(__a))) +#define msa_cgtq_s8(__a, __b) ((v16u8)__builtin_msa_clt_s_b((v16i8)(__b), (v16i8)(__a))) +#define msa_cgtq_u16(__a, __b) ((v8u16)__builtin_msa_clt_u_h((v8u16)(__b), (v8u16)(__a))) +#define msa_cgtq_s16(__a, __b) ((v8u16)__builtin_msa_clt_s_h((v8i16)(__b), (v8i16)(__a))) +#define msa_cgtq_u32(__a, __b) ((v4u32)__builtin_msa_clt_u_w((v4u32)(__b), (v4u32)(__a))) +#define msa_cgtq_s32(__a, __b) ((v4u32)__builtin_msa_clt_s_w((v4i32)(__b), (v4i32)(__a))) +#define msa_cgtq_f32(__a, __b) ((v4u32)__builtin_msa_fclt_w((v4f32)(__b), (v4f32)(__a))) +#define msa_cgtq_u64(__a, __b) ((v2u64)__builtin_msa_clt_u_d((v2u64)(__b), (v2u64)(__a))) +#define msa_cgtq_s64(__a, __b) ((v2u64)__builtin_msa_clt_s_d((v2i64)(__b), (v2i64)(__a))) +#define msa_cgtq_f64(__a, __b) ((v2u64)__builtin_msa_fclt_d((v2f64)(__b), (v2f64)(__a))) + +/* compare less-equal: cle -> ri = ai <= bi ? 1...1:0...0 */ +#define msa_cleq_u8(__a, __b) ((v16u8)__builtin_msa_cle_u_b((v16u8)(__a), (v16u8)(__b))) +#define msa_cleq_s8(__a, __b) ((v16u8)__builtin_msa_cle_s_b((v16i8)(__a), (v16i8)(__b))) +#define msa_cleq_u16(__a, __b) ((v8u16)__builtin_msa_cle_u_h((v8u16)(__a), (v8u16)(__b))) +#define msa_cleq_s16(__a, __b) ((v8u16)__builtin_msa_cle_s_h((v8i16)(__a), (v8i16)(__b))) +#define msa_cleq_u32(__a, __b) ((v4u32)__builtin_msa_cle_u_w((v4u32)(__a), (v4u32)(__b))) +#define msa_cleq_s32(__a, __b) ((v4u32)__builtin_msa_cle_s_w((v4i32)(__a), (v4i32)(__b))) +#define msa_cleq_f32(__a, __b) ((v4u32)__builtin_msa_fcle_w((v4f32)(__a), (v4f32)(__b))) +#define msa_cleq_u64(__a, __b) ((v2u64)__builtin_msa_cle_u_d((v2u64)(__a), (v2u64)(__b))) +#define msa_cleq_s64(__a, __b) ((v2u64)__builtin_msa_cle_s_d((v2i64)(__a), (v2i64)(__b))) +#define msa_cleq_f64(__a, __b) ((v2u64)__builtin_msa_fcle_d((v2f64)(__a), (v2f64)(__b))) + +/* compare greater-equal: cge -> ri = ai >= bi ? 1...1:0...0 */ +#define msa_cgeq_u8(__a, __b) ((v16u8)__builtin_msa_cle_u_b((v16u8)(__b), (v16u8)(__a))) +#define msa_cgeq_s8(__a, __b) ((v16u8)__builtin_msa_cle_s_b((v16i8)(__b), (v16i8)(__a))) +#define msa_cgeq_u16(__a, __b) ((v8u16)__builtin_msa_cle_u_h((v8u16)(__b), (v8u16)(__a))) +#define msa_cgeq_s16(__a, __b) ((v8u16)__builtin_msa_cle_s_h((v8i16)(__b), (v8i16)(__a))) +#define msa_cgeq_u32(__a, __b) ((v4u32)__builtin_msa_cle_u_w((v4u32)(__b), (v4u32)(__a))) +#define msa_cgeq_s32(__a, __b) ((v4u32)__builtin_msa_cle_s_w((v4i32)(__b), (v4i32)(__a))) +#define msa_cgeq_f32(__a, __b) ((v4u32)__builtin_msa_fcle_w((v4f32)(__b), (v4f32)(__a))) +#define msa_cgeq_u64(__a, __b) ((v2u64)__builtin_msa_cle_u_d((v2u64)(__b), (v2u64)(__a))) +#define msa_cgeq_s64(__a, __b) ((v2u64)__builtin_msa_cle_s_d((v2i64)(__b), (v2i64)(__a))) +#define msa_cgeq_f64(__a, __b) ((v2u64)__builtin_msa_fcle_d((v2f64)(__b), (v2f64)(__a))) + +/* Shift Left Logical: shl -> ri = ai << bi; */ +#define msa_shlq_u8(__a, __b) ((v16u8)__builtin_msa_sll_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shlq_s8(__a, __b) ((v16i8)__builtin_msa_sll_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shlq_u16(__a, __b) ((v8u16)__builtin_msa_sll_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shlq_s16(__a, __b) ((v8i16)__builtin_msa_sll_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shlq_u32(__a, __b) ((v4u32)__builtin_msa_sll_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shlq_s32(__a, __b) ((v4i32)__builtin_msa_sll_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shlq_u64(__a, __b) ((v2u64)__builtin_msa_sll_d((v2i64)(__a), (v2i64)(__b))) +#define msa_shlq_s64(__a, __b) ((v2i64)__builtin_msa_sll_d((v2i64)(__a), (v2i64)(__b))) + +/* Immediate Shift Left Logical: shl -> ri = ai << imm; */ +#define msa_shlq_n_u8(__a, __imm) ((v16u8)__builtin_msa_slli_b((v16i8)(__a), __imm)) +#define msa_shlq_n_s8(__a, __imm) ((v16i8)__builtin_msa_slli_b((v16i8)(__a), __imm)) +#define msa_shlq_n_u16(__a, __imm) ((v8u16)__builtin_msa_slli_h((v8i16)(__a), __imm)) +#define msa_shlq_n_s16(__a, __imm) ((v8i16)__builtin_msa_slli_h((v8i16)(__a), __imm)) +#define msa_shlq_n_u32(__a, __imm) ((v4u32)__builtin_msa_slli_w((v4i32)(__a), __imm)) +#define msa_shlq_n_s32(__a, __imm) ((v4i32)__builtin_msa_slli_w((v4i32)(__a), __imm)) +#define msa_shlq_n_u64(__a, __imm) ((v2u64)__builtin_msa_slli_d((v2i64)(__a), __imm)) +#define msa_shlq_n_s64(__a, __imm) ((v2i64)__builtin_msa_slli_d((v2i64)(__a), __imm)) + +/* shift right: shrq -> ri = ai >> bi; */ +#define msa_shrq_u8(__a, __b) ((v16u8)__builtin_msa_srl_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shrq_s8(__a, __b) ((v16i8)__builtin_msa_sra_b((v16i8)(__a), (v16i8)(__b))) +#define msa_shrq_u16(__a, __b) ((v8u16)__builtin_msa_srl_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shrq_s16(__a, __b) ((v8i16)__builtin_msa_sra_h((v8i16)(__a), (v8i16)(__b))) +#define msa_shrq_u32(__a, __b) ((v4u32)__builtin_msa_srl_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shrq_s32(__a, __b) ((v4i32)__builtin_msa_sra_w((v4i32)(__a), (v4i32)(__b))) +#define msa_shrq_u64(__a, __b) ((v2u64)__builtin_msa_srl_d((v2i64)(__a), (v2i64)(__b))) +#define msa_shrq_s64(__a, __b) ((v2i64)__builtin_msa_sra_d((v2i64)(__a), (v2i64)(__b))) + +/* Immediate Shift Right: shr -> ri = ai >> imm; */ +#define msa_shrq_n_u8(__a, __imm) ((v16u8)__builtin_msa_srli_b((v16i8)(__a), __imm)) +#define msa_shrq_n_s8(__a, __imm) ((v16i8)__builtin_msa_srai_b((v16i8)(__a), __imm)) +#define msa_shrq_n_u16(__a, __imm) ((v8u16)__builtin_msa_srli_h((v8i16)(__a), __imm)) +#define msa_shrq_n_s16(__a, __imm) ((v8i16)__builtin_msa_srai_h((v8i16)(__a), __imm)) +#define msa_shrq_n_u32(__a, __imm) ((v4u32)__builtin_msa_srli_w((v4i32)(__a), __imm)) +#define msa_shrq_n_s32(__a, __imm) ((v4i32)__builtin_msa_srai_w((v4i32)(__a), __imm)) +#define msa_shrq_n_u64(__a, __imm) ((v2u64)__builtin_msa_srli_d((v2i64)(__a), __imm)) +#define msa_shrq_n_s64(__a, __imm) ((v2i64)__builtin_msa_srai_d((v2i64)(__a), __imm)) + +/* Immediate Shift Right Rounded: shr -> ri = ai >> (rounded)imm; */ +#define msa_rshrq_n_u8(__a, __imm) ((v16u8)__builtin_msa_srlri_b((v16i8)(__a), __imm)) +#define msa_rshrq_n_s8(__a, __imm) ((v16i8)__builtin_msa_srari_b((v16i8)(__a), __imm)) +#define msa_rshrq_n_u16(__a, __imm) ((v8u16)__builtin_msa_srlri_h((v8i16)(__a), __imm)) +#define msa_rshrq_n_s16(__a, __imm) ((v8i16)__builtin_msa_srari_h((v8i16)(__a), __imm)) +#define msa_rshrq_n_u32(__a, __imm) ((v4u32)__builtin_msa_srlri_w((v4i32)(__a), __imm)) +#define msa_rshrq_n_s32(__a, __imm) ((v4i32)__builtin_msa_srari_w((v4i32)(__a), __imm)) +#define msa_rshrq_n_u64(__a, __imm) ((v2u64)__builtin_msa_srlri_d((v2i64)(__a), __imm)) +#define msa_rshrq_n_s64(__a, __imm) ((v2i64)__builtin_msa_srari_d((v2i64)(__a), __imm)) + +/* Vector saturating rounding shift left, qrshl -> ri = ai << bi; */ +#define msa_qrshrq_s32(a, b) ((v4i32)__msa_srar_w((v4i32)(a), (v4i32)(b))) + +/* Rename the msa builtin func to unify the name style for intrin_msa.hpp */ +#define msa_qaddq_u8 __builtin_msa_adds_u_b +#define msa_qaddq_s8 __builtin_msa_adds_s_b +#define msa_qaddq_u16 __builtin_msa_adds_u_h +#define msa_qaddq_s16 __builtin_msa_adds_s_h +#define msa_qaddq_u32 __builtin_msa_adds_u_w +#define msa_qaddq_s32 __builtin_msa_adds_s_w +#define msa_qaddq_u64 __builtin_msa_adds_u_d +#define msa_qaddq_s64 __builtin_msa_adds_s_d +#define msa_addq_u8(a, b) ((v16u8)__builtin_msa_addv_b((v16i8)(a), (v16i8)(b))) +#define msa_addq_s8 __builtin_msa_addv_b +#define msa_addq_u16(a, b) ((v8u16)__builtin_msa_addv_h((v8i16)(a), (v8i16)(b))) +#define msa_addq_s16 __builtin_msa_addv_h +#define msa_addq_u32(a, b) ((v4u32)__builtin_msa_addv_w((v4i32)(a), (v4i32)(b))) +#define msa_addq_s32 __builtin_msa_addv_w +#define msa_addq_f32 __builtin_msa_fadd_w +#define msa_addq_u64(a, b) ((v2u64)__builtin_msa_addv_d((v2i64)(a), (v2i64)(b))) +#define msa_addq_s64 __builtin_msa_addv_d +#define msa_addq_f64 __builtin_msa_fadd_d +#define msa_qsubq_u8 __builtin_msa_subs_u_b +#define msa_qsubq_s8 __builtin_msa_subs_s_b +#define msa_qsubq_u16 __builtin_msa_subs_u_h +#define msa_qsubq_s16 __builtin_msa_subs_s_h +#define msa_subq_u8(a, b) ((v16u8)__builtin_msa_subv_b((v16i8)(a), (v16i8)(b))) +#define msa_subq_s8 __builtin_msa_subv_b +#define msa_subq_u16(a, b) ((v8u16)__builtin_msa_subv_h((v8i16)(a), (v8i16)(b))) +#define msa_subq_s16 __builtin_msa_subv_h +#define msa_subq_u32(a, b) ((v4u32)__builtin_msa_subv_w((v4i32)(a), (v4i32)(b))) +#define msa_subq_s32 __builtin_msa_subv_w +#define msa_subq_f32 __builtin_msa_fsub_w +#define msa_subq_u64(a, b) ((v2u64)__builtin_msa_subv_d((v2i64)(a), (v2i64)(b))) +#define msa_subq_s64 __builtin_msa_subv_d +#define msa_subq_f64 __builtin_msa_fsub_d +#define msa_mulq_u8(a, b) ((v16u8)__builtin_msa_mulv_b((v16i8)(a), (v16i8)(b))) +#define msa_mulq_s8(a, b) ((v16i8)__builtin_msa_mulv_b((v16i8)(a), (v16i8)(b))) +#define msa_mulq_u16(a, b) ((v8u16)__builtin_msa_mulv_h((v8i16)(a), (v8i16)(b))) +#define msa_mulq_s16(a, b) ((v8i16)__builtin_msa_mulv_h((v8i16)(a), (v8i16)(b))) +#define msa_mulq_u32(a, b) ((v4u32)__builtin_msa_mulv_w((v4i32)(a), (v4i32)(b))) +#define msa_mulq_s32(a, b) ((v4i32)__builtin_msa_mulv_w((v4i32)(a), (v4i32)(b))) +#define msa_mulq_u64(a, b) ((v2u64)__builtin_msa_mulv_d((v2i64)(a), (v2i64)(b))) +#define msa_mulq_s64(a, b) ((v2i64)__builtin_msa_mulv_d((v2i64)(a), (v2i64)(b))) +#define msa_mulq_f32 __builtin_msa_fmul_w +#define msa_mulq_f64 __builtin_msa_fmul_d +#define msa_divq_f32 __builtin_msa_fdiv_w +#define msa_divq_f64 __builtin_msa_fdiv_d +#define msa_dotp_s_h __builtin_msa_dotp_s_h +#define msa_dotp_s_w __builtin_msa_dotp_s_w +#define msa_dotp_s_d __builtin_msa_dotp_s_d +#define msa_dotp_u_h __builtin_msa_dotp_u_h +#define msa_dotp_u_w __builtin_msa_dotp_u_w +#define msa_dotp_u_d __builtin_msa_dotp_u_d +#define msa_dpadd_s_h __builtin_msa_dpadd_s_h +#define msa_dpadd_s_w __builtin_msa_dpadd_s_w +#define msa_dpadd_s_d __builtin_msa_dpadd_s_d +#define msa_dpadd_u_h __builtin_msa_dpadd_u_h +#define msa_dpadd_u_w __builtin_msa_dpadd_u_w +#define msa_dpadd_u_d __builtin_msa_dpadd_u_d + +#define ILVRL_B2(RTYPE, in0, in1, low, hi) do { \ + low = (RTYPE)__builtin_msa_ilvr_b((v16i8)(in0), (v16i8)(in1)); \ + hi = (RTYPE)__builtin_msa_ilvl_b((v16i8)(in0), (v16i8)(in1)); \ + } while (0) +#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__) +#define ILVRL_B2_SB(...) ILVRL_B2(v16i8, __VA_ARGS__) +#define ILVRL_B2_UH(...) ILVRL_B2(v8u16, __VA_ARGS__) +#define ILVRL_B2_SH(...) ILVRL_B2(v8i16, __VA_ARGS__) +#define ILVRL_B2_SW(...) ILVRL_B2(v4i32, __VA_ARGS__) + +#define ILVRL_H2(RTYPE, in0, in1, low, hi) do { \ + low = (RTYPE)__builtin_msa_ilvr_h((v8i16)(in0), (v8i16)(in1)); \ + hi = (RTYPE)__builtin_msa_ilvl_h((v8i16)(in0), (v8i16)(in1)); \ + } while (0) +#define ILVRL_H2_UB(...) ILVRL_H2(v16u8, __VA_ARGS__) +#define ILVRL_H2_SB(...) ILVRL_H2(v16i8, __VA_ARGS__) +#define ILVRL_H2_UH(...) ILVRL_H2(v8u16, __VA_ARGS__) +#define ILVRL_H2_SH(...) ILVRL_H2(v8i16, __VA_ARGS__) +#define ILVRL_H2_SW(...) ILVRL_H2(v4i32, __VA_ARGS__) +#define ILVRL_H2_UW(...) ILVRL_H2(v4u32, __VA_ARGS__) + +#define ILVRL_W2(RTYPE, in0, in1, low, hi) do { \ + low = (RTYPE)__builtin_msa_ilvr_w((v4i32)(in0), (v4i32)(in1)); \ + hi = (RTYPE)__builtin_msa_ilvl_w((v4i32)(in0), (v4i32)(in1)); \ + } while (0) +#define ILVRL_W2_UB(...) ILVRL_W2(v16u8, __VA_ARGS__) +#define ILVRL_W2_SH(...) ILVRL_W2(v8i16, __VA_ARGS__) +#define ILVRL_W2_SW(...) ILVRL_W2(v4i32, __VA_ARGS__) +#define ILVRL_W2_UW(...) ILVRL_W2(v4u32, __VA_ARGS__) + +/* absq, qabsq (r = |a|;) */ +#define msa_absq_s8(a) __builtin_msa_add_a_b(a, __builtin_msa_fill_b(0)) +#define msa_absq_s16(a) __builtin_msa_add_a_h(a, __builtin_msa_fill_h(0)) +#define msa_absq_s32(a) __builtin_msa_add_a_w(a, __builtin_msa_fill_w(0)) +#define msa_absq_s64(a) __builtin_msa_add_a_d(a, __builtin_msa_fill_d(0)) +#define msa_absq_f32(a) ((v4f32)__builtin_msa_bclri_w((v4u32)(a), 31)) +#define msa_absq_f64(a) ((v2f64)__builtin_msa_bclri_d((v2u64)(a), 63)) +#define msa_qabsq_s8(a) __builtin_msa_adds_a_b(a, __builtin_msa_fill_b(0)) +#define msa_qabsq_s16(a) __builtin_msa_adds_a_h(a, __builtin_msa_fill_h(0)) +#define msa_qabsq_s32(a) __builtin_msa_adds_a_w(a, __builtin_msa_fill_w(0)) +#define msa_qabsq_s64(a) __builtin_msa_adds_a_d(a, __builtin_msa_fill_d(0)) + +/* abdq, qabdq (r = |a - b|;) */ +#define msa_abdq_u8 __builtin_msa_asub_u_b +#define msa_abdq_s8 __builtin_msa_asub_s_b +#define msa_abdq_u16 __builtin_msa_asub_u_h +#define msa_abdq_s16 __builtin_msa_asub_s_h +#define msa_abdq_u32 __builtin_msa_asub_u_w +#define msa_abdq_s32 __builtin_msa_asub_s_w +#define msa_abdq_u64 __builtin_msa_asub_u_d +#define msa_abdq_s64 __builtin_msa_asub_s_d +#define msa_abdq_f32(a, b) msa_absq_f32(__builtin_msa_fsub_w(a, b)) +#define msa_abdq_f64(a, b) msa_absq_f64(__builtin_msa_fsub_d(a, b)) +#define msa_qabdq_s8(a, b) msa_qabsq_s8(__builtin_msa_subs_s_b(a, b)) +#define msa_qabdq_s16(a, b) msa_qabsq_s16(__builtin_msa_subs_s_h(a, b)) +#define msa_qabdq_s32(a, b) msa_qabsq_s32(__builtin_msa_subs_s_w(a, b)) +#define msa_qabdq_s64(a, b) msa_qabsq_s64(__builtin_msa_subs_s_d(a, b)) + +/* sqrtq, rsqrtq */ +#define msa_sqrtq_f32 __builtin_msa_fsqrt_w +#define msa_sqrtq_f64 __builtin_msa_fsqrt_d +#define msa_rsqrtq_f32 __builtin_msa_frsqrt_w +#define msa_rsqrtq_f64 __builtin_msa_frsqrt_d + + +/* mlaq: r = a + b * c; */ +__extension__ extern __inline v4i32 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_s32(v4i32 __a, v4i32 __b, v4i32 __c) +{ + __asm__ volatile("maddv.w %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +__extension__ extern __inline v2i64 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_s64(v2i64 __a, v2i64 __b, v2i64 __c) +{ + __asm__ volatile("maddv.d %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +__extension__ extern __inline v4f32 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_f32(v4f32 __a, v4f32 __b, v4f32 __c) +{ + __asm__ volatile("fmadd.w %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +__extension__ extern __inline v2f64 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_mlaq_f64(v2f64 __a, v2f64 __b, v2f64 __c) +{ + __asm__ volatile("fmadd.d %w[__a], %w[__b], %w[__c]\n" + // Outputs + : [__a] "+f"(__a) + // Inputs + : [__b] "f"(__b), [__c] "f"(__c)); + return __a; +} + +/* cntq */ +#define msa_cntq_s8 __builtin_msa_pcnt_b +#define msa_cntq_s16 __builtin_msa_pcnt_h +#define msa_cntq_s32 __builtin_msa_pcnt_w +#define msa_cntq_s64 __builtin_msa_pcnt_d + +/* bslq (a: mask; r = b(if a == 0); r = c(if a == 1);) */ +#define msa_bslq_u8 __builtin_msa_bsel_v + +/* ilvrq, ilvlq (For EL only, ilvrq: b0, a0, b1, a1; ilvlq: b2, a2, b3, a3;) */ +#define msa_ilvrq_s8 __builtin_msa_ilvr_b +#define msa_ilvrq_s16 __builtin_msa_ilvr_h +#define msa_ilvrq_s32 __builtin_msa_ilvr_w +#define msa_ilvrq_s64 __builtin_msa_ilvr_d +#define msa_ilvlq_s8 __builtin_msa_ilvl_b +#define msa_ilvlq_s16 __builtin_msa_ilvl_h +#define msa_ilvlq_s32 __builtin_msa_ilvl_w +#define msa_ilvlq_s64 __builtin_msa_ilvl_d + +/* ilvevq, ilvodq (ilvevq: b0, a0, b2, a2; ilvodq: b1, a1, b3, a3; ) */ +#define msa_ilvevq_s8 __builtin_msa_ilvev_b +#define msa_ilvevq_s16 __builtin_msa_ilvev_h +#define msa_ilvevq_s32 __builtin_msa_ilvev_w +#define msa_ilvevq_s64 __builtin_msa_ilvev_d +#define msa_ilvodq_s8 __builtin_msa_ilvod_b +#define msa_ilvodq_s16 __builtin_msa_ilvod_h +#define msa_ilvodq_s32 __builtin_msa_ilvod_w +#define msa_ilvodq_s64 __builtin_msa_ilvod_d + +/* extq (r = (a || b); a concatenation b and get elements from index c) */ +#ifdef _MIPSEB +#define msa_extq_s8(a, b, c) \ +(__builtin_msa_vshf_b(__builtin_msa_subv_b((v16i8)((v2i64){0x1716151413121110, 0x1F1E1D1C1B1A1918}), __builtin_msa_fill_b(c)), a, b)) +#define msa_extq_s16(a, b, c) \ +(__builtin_msa_vshf_h(__builtin_msa_subv_h((v8i16)((v2i64){0x000B000A00090008, 0x000F000E000D000C}), __builtin_msa_fill_h(c)), a, b)) +#define msa_extq_s32(a, b, c) \ +(__builtin_msa_vshf_w(__builtin_msa_subv_w((v4i32)((v2i64){0x0000000500000004, 0x0000000700000006}), __builtin_msa_fill_w(c)), a, b)) +#define msa_extq_s64(a, b, c) \ +(__builtin_msa_vshf_d(__builtin_msa_subv_d((v2i64){0x0000000000000002, 0x0000000000000003}, __builtin_msa_fill_d(c)), a, b)) +#else +#define msa_extq_s8(a, b, c) \ +(__builtin_msa_vshf_b(__builtin_msa_addv_b((v16i8)((v2i64){0x0706050403020100, 0x0F0E0D0C0B0A0908}), __builtin_msa_fill_b(c)), b, a)) +#define msa_extq_s16(a, b, c) \ +(__builtin_msa_vshf_h(__builtin_msa_addv_h((v8i16)((v2i64){0x0003000200010000, 0x0007000600050004}), __builtin_msa_fill_h(c)), b, a)) +#define msa_extq_s32(a, b, c) \ +(__builtin_msa_vshf_w(__builtin_msa_addv_w((v4i32)((v2i64){0x0000000100000000, 0x0000000300000002}), __builtin_msa_fill_w(c)), b, a)) +#define msa_extq_s64(a, b, c) \ +(__builtin_msa_vshf_d(__builtin_msa_addv_d((v2i64){0x0000000000000000, 0x0000000000000001}, __builtin_msa_fill_d(c)), b, a)) +#endif /* _MIPSEB */ + +/* cvttruncq, cvttintq, cvtrintq */ +#define msa_cvttruncq_u32_f32 __builtin_msa_ftrunc_u_w +#define msa_cvttruncq_s32_f32 __builtin_msa_ftrunc_s_w +#define msa_cvttruncq_u64_f64 __builtin_msa_ftrunc_u_d +#define msa_cvttruncq_s64_f64 __builtin_msa_ftrunc_s_d +#define msa_cvttintq_u32_f32 __builtin_msa_ftint_u_w +#define msa_cvttintq_s32_f32 __builtin_msa_ftint_s_w +#define msa_cvttintq_u64_f64 __builtin_msa_ftint_u_d +#define msa_cvttintq_s64_f64 __builtin_msa_ftint_s_d +#define msa_cvtrintq_f32 __builtin_msa_frint_w +#define msa_cvtrintq_f64 __builtin_msa_frint_d + +/* cvtfintq, cvtfq */ +#define msa_cvtfintq_f32_u32 __builtin_msa_ffint_u_w +#define msa_cvtfintq_f32_s32 __builtin_msa_ffint_s_w +#define msa_cvtfintq_f64_u64 __builtin_msa_ffint_u_d +#define msa_cvtfintq_f64_s64 __builtin_msa_ffint_s_d +#define msa_cvtfq_f32_f64 __builtin_msa_fexdo_w +#define msa_cvtflq_f64_f32 __builtin_msa_fexupr_d +#define msa_cvtfhq_f64_f32 __builtin_msa_fexupl_d + +#define msa_addl_u8(a, b) ((v8u16)__builtin_msa_addv_h((v8i16)V8U8_2_V8I16(a), (v8i16)V8U8_2_V8I16(b))) +#define msa_addl_s8(a, b) (__builtin_msa_addv_h((v8i16)V8I8_2_V8I16(a), (v8i16)V8I8_2_V8I16(b))) +#define msa_addl_u16(a, b) ((v4u32)__builtin_msa_addv_w((v4i32)V4U16_2_V4I32(a), (v4i32)V4U16_2_V4I32(b))) +#define msa_addl_s16(a, b) (__builtin_msa_addv_w((v4i32)V4I16_2_V4I32(a), (v4i32)V4I16_2_V4I32(b))) +#define msa_subl_s16(a, b) (__builtin_msa_subv_w((v4i32)V4I16_2_V4I32(a), (v4i32)V4I16_2_V4I32(b))) +#define msa_recpeq_f32 __builtin_msa_frcp_w +#define msa_recpsq_f32(a, b) (__builtin_msa_fsub_w(msa_dupq_n_f32(2.0f), __builtin_msa_fmul_w(a, b))) + +#define MSA_INTERLEAVED_IMPL_LOAD2_STORE2(_Tp, _Tpv, _Tpvs, suffix, df, nlanes) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld2q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + nlanes); \ + *a = (_Tpv)__builtin_msa_pckev_##df((_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_pckod_##df((_Tpvs)v1, (_Tpvs)v0); \ +} \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st2q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b) \ +{ \ + msa_st1q_##suffix(ptr, (_Tpv)__builtin_msa_ilvr_##df((_Tpvs)b, (_Tpvs)a)); \ + msa_st1q_##suffix(ptr + nlanes, (_Tpv)__builtin_msa_ilvl_##df((_Tpvs)b, (_Tpvs)a)); \ +} + +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint8_t, v16u8, v16i8, u8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int8_t, v16i8, v16i8, s8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint16_t, v8u16, v8i16, u16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int16_t, v8i16, v8i16, s16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint32_t, v4u32, v4i32, u32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int32_t, v4i32, v4i32, s32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(float, v4f32, v4i32, f32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(uint64_t, v2u64, v2i64, u64, d, 2) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(int64_t, v2i64, v2i64, s64, d, 2) +MSA_INTERLEAVED_IMPL_LOAD2_STORE2(double, v2f64, v2i64, f64, d, 2) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_LOAD3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 16); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 32); \ + _Tpvs v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0704011F1F1F1F1F, 0x1F1C191613100D0A}), (_Tpvs)v0, (_Tpvs)v1); \ + *a = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x1716150E0B080502, 0x1F1E1D1C1B1A1918}), v3, (_Tpvs)v2); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0603001F1F1F1F1F, 0x1E1B1815120F0C09}), (_Tpvs)v0, (_Tpvs)v1); \ + *b = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x1716150D0A070401, 0x1F1E1D1C1B1A1918}), v3, (_Tpvs)v2); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x05021F1F1F1F1F1F, 0x1D1A1714110E0B08}), (_Tpvs)v0, (_Tpvs)v1); \ + *c = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x17160F0C09060300, 0x1F1E1D1C1B1A1918}), v3, (_Tpvs)v2); \ +} +#else +#define MSA_INTERLEAVED_IMPL_LOAD3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 16); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 32); \ + _Tpvs v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x15120F0C09060300, 0x00000000001E1B18}), (_Tpvs)v1, (_Tpvs)v0); \ + *a = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x0706050403020100, 0x1D1A1714110A0908}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x1613100D0A070401, 0x00000000001F1C19}), (_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x0706050403020100, 0x1E1B1815120A0908}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x1714110E0B080502, 0x0000000000001D1A}), (_Tpvs)v1, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_vshf_b((_Tpvs)((v2i64){0x0706050403020100, 0x1F1C191613100908}), (_Tpvs)v2, v3); \ +} +#endif + +MSA_INTERLEAVED_IMPL_LOAD3_8(uint8_t, v16u8, v16i8, u8) +MSA_INTERLEAVED_IMPL_LOAD3_8(int8_t, v16i8, v16i8, s8) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_LOAD3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 8); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 16); \ + _Tpvs v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x00030000000F000F, 0x000F000C00090006}), (_Tpvs)v1, (_Tpvs)v0); \ + *a = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000A00050002, 0x000F000E000D000C}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0002000F000F000F, 0x000E000B00080005}), (_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000700040001, 0x000F000E000D000C}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0001000F000F000F, 0x000D000A00070004}), (_Tpvs)v1, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000600030000, 0x000F000E000D000C}), (_Tpvs)v2, v3); \ +} +#else +#define MSA_INTERLEAVED_IMPL_LOAD3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 8); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 16); \ + _Tpvs v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0009000600030000, 0x00000000000F000C}), (_Tpvs)v1, (_Tpvs)v0); \ + *a = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x0003000200010000, 0x000D000A00050004}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000A000700040001, 0x000000000000000D}), (_Tpvs)v1, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x0003000200010000, 0x000E000B00080004}), (_Tpvs)v2, v3); \ + v3 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B000800050002, 0x000000000000000E}), (_Tpvs)v1, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_vshf_h((_Tpvs)((v2i64){0x0003000200010000, 0x000F000C00090004}), (_Tpvs)v2, v3); \ +} +#endif + +MSA_INTERLEAVED_IMPL_LOAD3_16(uint16_t, v8u16, v8i16, u16) +MSA_INTERLEAVED_IMPL_LOAD3_16(int16_t, v8i16, v8i16, s16) + +#define MSA_INTERLEAVED_IMPL_LOAD3_32(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + _Tpv v00 = msa_ld1q_##suffix(ptr); \ + _Tpv v01 = msa_ld1q_##suffix(ptr + 4); \ + _Tpv v02 = msa_ld1q_##suffix(ptr + 8); \ + _Tpvs v10 = __builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v01, (v2i64)v01), (_Tpvs)v00); \ + _Tpvs v11 = __builtin_msa_ilvr_w((_Tpvs)v02, (_Tpvs)__builtin_msa_ilvl_d((v2i64)v00, (v2i64)v00)); \ + _Tpvs v12 = __builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v02, (v2i64)v02), (_Tpvs)v01); \ + *a = (_Tpv)__builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v11, (v2i64)v11), v10); \ + *b = (_Tpv)__builtin_msa_ilvr_w(v12, (_Tpvs)__builtin_msa_ilvl_d((v2i64)v10, (v2i64)v10)); \ + *c = (_Tpv)__builtin_msa_ilvr_w((_Tpvs)__builtin_msa_ilvl_d((v2i64)v12, (v2i64)v12), v11); \ +} + +MSA_INTERLEAVED_IMPL_LOAD3_32(uint32_t, v4u32, v4i32, u32) +MSA_INTERLEAVED_IMPL_LOAD3_32(int32_t, v4i32, v4i32, s32) +MSA_INTERLEAVED_IMPL_LOAD3_32(float, v4f32, v4i32, f32) + +#define MSA_INTERLEAVED_IMPL_LOAD3_64(_Tp, _Tpv, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld3q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c) \ +{ \ + *((_Tp*)a) = *ptr; *((_Tp*)b) = *(ptr + 1); *((_Tp*)c) = *(ptr + 2); \ + *((_Tp*)a + 1) = *(ptr + 3); *((_Tp*)b + 1) = *(ptr + 4); *((_Tp*)c + 1) = *(ptr + 5); \ +} + +MSA_INTERLEAVED_IMPL_LOAD3_64(uint64_t, v2u64, u64) +MSA_INTERLEAVED_IMPL_LOAD3_64(int64_t, v2i64, s64) +MSA_INTERLEAVED_IMPL_LOAD3_64(double, v2f64, f64) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_STORE3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0F0E0D0C0B1F1F1F, 0x1F1E1D1C1B1A1F1F}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0D1C140C1B130B1A, 0x1F170F1E160E1D15}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0A09080706051F1F, 0x19181716151F1F1F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x1D14071C13061B12, 0x170A1F16091E1508}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x04030201001F1F1F, 0x14131211101F1F1F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x15021C14011B1300, 0x051F17041E16031D}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 32, (_Tpv)v1); \ +} +#else +#define MSA_INTERLEAVED_IMPL_STORE3_8(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0000050403020100, 0x0000001413121110}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0A02110901100800, 0x05140C04130B0312}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0000000A09080706, 0x00001A1918171615}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x170A011609001508, 0x0D04190C03180B02}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x0000000F0E0D0C0B, 0x0000001F1E1D1C1B}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_b((_Tpvs)((v2i64){0x021C09011B08001A, 0x1F0C041E0B031D0A}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 32, (_Tpv)v1); \ +} +#endif + +MSA_INTERLEAVED_IMPL_STORE3_8(uint8_t, v16u8, v16i8, u8) +MSA_INTERLEAVED_IMPL_STORE3_8(int8_t, v16i8, v16i8, s8) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_STORE3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000700060005000F, 0x000F000E000D000F}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000A0006000D0009, 0x000F000B0007000E}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x00040003000F000F, 0x000C000B000A000F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000E000A0003000D, 0x0005000F000B0004}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000200010000000F, 0x00090008000F000F}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0001000E00090000, 0x000B0002000F000A}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ +} +#else +#define MSA_INTERLEAVED_IMPL_STORE3_16(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0000000200010000, 0x0000000A00090008}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0001000800040000, 0x0006000200090005}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0000000500040003, 0x00000000000C000B}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x000B00040000000A, 0x0002000C00050001}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x0000000000070006, 0x0000000F000E000D}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_h((_Tpvs)((v2i64){0x00050000000D0004, 0x000F00060001000E}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 16, (_Tpv)v1); \ +} +#endif + +MSA_INTERLEAVED_IMPL_STORE3_16(uint16_t, v8u16, v8i16, u16) +MSA_INTERLEAVED_IMPL_STORE3_16(int16_t, v8i16, v8i16, s16) + +#ifdef _MIPSEB +#define MSA_INTERLEAVED_IMPL_STORE3_32(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000300000007, 0x0000000700000006}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000300000006, 0x0000000700000005}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000200000001, 0x0000000500000007}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000700000004, 0x0000000500000002}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 4, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000007, 0x0000000400000007}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000500000000, 0x0000000100000007}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ +} +#else +#define MSA_INTERLEAVED_IMPL_STORE3_32(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + _Tpvs v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000100000000, 0x0000000000000004}), (_Tpvs)b, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000200000000, 0x0000000100000004}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000002, 0x0000000600000005}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000500000002, 0x0000000300000000}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 4, (_Tpv)v1); \ + v0 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000003, 0x0000000000000007}), (_Tpvs)b, (_Tpvs)a); \ + v1 = __builtin_msa_vshf_w((_Tpvs)((v2i64){0x0000000000000006, 0x0000000700000002}), (_Tpvs)c, (_Tpvs)v0); \ + msa_st1q_##suffix(ptr + 8, (_Tpv)v1); \ +} +#endif + +MSA_INTERLEAVED_IMPL_STORE3_32(uint32_t, v4u32, v4i32, u32) +MSA_INTERLEAVED_IMPL_STORE3_32(int32_t, v4i32, v4i32, s32) +MSA_INTERLEAVED_IMPL_STORE3_32(float, v4f32, v4i32, f32) + +#define MSA_INTERLEAVED_IMPL_STORE3_64(_Tp, _Tpv, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st3q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c) \ +{ \ + *ptr = a[0]; *(ptr + 1) = b[0]; *(ptr + 2) = c[0]; \ + *(ptr + 3) = a[1]; *(ptr + 4) = b[1]; *(ptr + 5) = c[1]; \ +} + +MSA_INTERLEAVED_IMPL_STORE3_64(uint64_t, v2u64, u64) +MSA_INTERLEAVED_IMPL_STORE3_64(int64_t, v2i64, s64) +MSA_INTERLEAVED_IMPL_STORE3_64(double, v2f64, f64) + +#define MSA_INTERLEAVED_IMPL_LOAD4_STORE4(_Tp, _Tpv, _Tpvs, suffix, df, nlanes) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld4q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c, _Tpv* d) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + nlanes); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + nlanes * 2); \ + _Tpv v3 = msa_ld1q_##suffix(ptr + nlanes * 3); \ + _Tpvs t0 = __builtin_msa_pckev_##df((_Tpvs)v1, (_Tpvs)v0); \ + _Tpvs t1 = __builtin_msa_pckev_##df((_Tpvs)v3, (_Tpvs)v2); \ + _Tpvs t2 = __builtin_msa_pckod_##df((_Tpvs)v1, (_Tpvs)v0); \ + _Tpvs t3 = __builtin_msa_pckod_##df((_Tpvs)v3, (_Tpvs)v2); \ + *a = (_Tpv)__builtin_msa_pckev_##df(t1, t0); \ + *b = (_Tpv)__builtin_msa_pckev_##df(t3, t2); \ + *c = (_Tpv)__builtin_msa_pckod_##df(t1, t0); \ + *d = (_Tpv)__builtin_msa_pckod_##df(t3, t2); \ +} \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st4q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c, const _Tpv d) \ +{ \ + _Tpvs v0 = __builtin_msa_ilvr_##df((_Tpvs)c, (_Tpvs)a); \ + _Tpvs v1 = __builtin_msa_ilvr_##df((_Tpvs)d, (_Tpvs)b); \ + _Tpvs v2 = __builtin_msa_ilvl_##df((_Tpvs)c, (_Tpvs)a); \ + _Tpvs v3 = __builtin_msa_ilvl_##df((_Tpvs)d, (_Tpvs)b); \ + msa_st1q_##suffix(ptr, (_Tpv)__builtin_msa_ilvr_##df(v1, v0)); \ + msa_st1q_##suffix(ptr + nlanes, (_Tpv)__builtin_msa_ilvl_##df(v1, v0)); \ + msa_st1q_##suffix(ptr + 2 * nlanes, (_Tpv)__builtin_msa_ilvr_##df(v3, v2)); \ + msa_st1q_##suffix(ptr + 3 * nlanes, (_Tpv)__builtin_msa_ilvl_##df(v3, v2)); \ +} + +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(uint8_t, v16u8, v16i8, u8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(int8_t, v16i8, v16i8, s8, b, 16) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(uint16_t, v8u16, v8i16, u16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(int16_t, v8i16, v8i16, s16, h, 8) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(uint32_t, v4u32, v4i32, u32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(int32_t, v4i32, v4i32, s32, w, 4) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4(float, v4f32, v4i32, f32, w, 4) + +#define MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(_Tp, _Tpv, _Tpvs, suffix) \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_ld4q_##suffix(const _Tp* ptr, _Tpv* a, _Tpv* b, _Tpv* c, _Tpv* d) \ +{ \ + _Tpv v0 = msa_ld1q_##suffix(ptr); \ + _Tpv v1 = msa_ld1q_##suffix(ptr + 2); \ + _Tpv v2 = msa_ld1q_##suffix(ptr + 4); \ + _Tpv v3 = msa_ld1q_##suffix(ptr + 6); \ + *a = (_Tpv)__builtin_msa_ilvr_d((_Tpvs)v2, (_Tpvs)v0); \ + *b = (_Tpv)__builtin_msa_ilvl_d((_Tpvs)v2, (_Tpvs)v0); \ + *c = (_Tpv)__builtin_msa_ilvr_d((_Tpvs)v3, (_Tpvs)v1); \ + *d = (_Tpv)__builtin_msa_ilvl_d((_Tpvs)v3, (_Tpvs)v1); \ +} \ +__extension__ extern __inline void \ +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \ +msa_st4q_##suffix(_Tp* ptr, const _Tpv a, const _Tpv b, const _Tpv c, const _Tpv d) \ +{ \ + msa_st1q_##suffix(ptr, (_Tpv)__builtin_msa_ilvr_d((_Tpvs)b, (_Tpvs)a)); \ + msa_st1q_##suffix(ptr + 2, (_Tpv)__builtin_msa_ilvr_d((_Tpvs)d, (_Tpvs)c)); \ + msa_st1q_##suffix(ptr + 4, (_Tpv)__builtin_msa_ilvl_d((_Tpvs)b, (_Tpvs)a)); \ + msa_st1q_##suffix(ptr + 6, (_Tpv)__builtin_msa_ilvl_d((_Tpvs)d, (_Tpvs)c)); \ +} + +MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(uint64_t, v2u64, v2i64, u64) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(int64_t, v2i64, v2i64, s64) +MSA_INTERLEAVED_IMPL_LOAD4_STORE4_64(double, v2f64, v2i64, f64) + +__extension__ extern __inline v8i16 +__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) +msa_qdmulhq_n_s16(v8i16 a, int16_t b) +{ + v8i16 a_lo, a_hi; + ILVRL_H2_SH(a, msa_dupq_n_s16(0), a_lo, a_hi); + return msa_packr_s32(msa_shlq_n_s32(msa_mulq_s32(msa_paddlq_s16(a_lo), msa_dupq_n_s32(b)), 1), + msa_shlq_n_s32(msa_mulq_s32(msa_paddlq_s16(a_hi), msa_dupq_n_s32(b)), 1), 16); +} + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /*__mips_msa*/ +#endif /* OPENCV_CORE_MSA_MACROS_H */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/simd_utils.impl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/simd_utils.impl.hpp new file mode 100644 index 0000000..fff8f94 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/hal/simd_utils.impl.hpp @@ -0,0 +1,146 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +// This header is not standalone. Don't include directly, use "intrin.hpp" instead. +#ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp + + +#if CV_SIMD128 || CV_SIMD128_CPP + +template struct Type2Vec128_Traits; +#define CV_INTRIN_DEF_TYPE2VEC128_TRAITS(type_, vec_type_) \ + template<> struct Type2Vec128_Traits \ + { \ + typedef vec_type_ vec_type; \ + } + +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uchar, v_uint8x16); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(schar, v_int8x16); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(ushort, v_uint16x8); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(short, v_int16x8); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(unsigned, v_uint32x4); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int, v_int32x4); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(float, v_float32x4); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uint64, v_uint64x2); +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int64, v_int64x2); +#if CV_SIMD128_64F +CV_INTRIN_DEF_TYPE2VEC128_TRAITS(double, v_float64x2); +#endif + +template static inline +typename Type2Vec128_Traits<_T>::vec_type v_setall(const _T& a); + +template<> inline Type2Vec128_Traits< uchar>::vec_type v_setall< uchar>(const uchar& a) { return v_setall_u8(a); } +template<> inline Type2Vec128_Traits< schar>::vec_type v_setall< schar>(const schar& a) { return v_setall_s8(a); } +template<> inline Type2Vec128_Traits::vec_type v_setall(const ushort& a) { return v_setall_u16(a); } +template<> inline Type2Vec128_Traits< short>::vec_type v_setall< short>(const short& a) { return v_setall_s16(a); } +template<> inline Type2Vec128_Traits< uint>::vec_type v_setall< uint>(const uint& a) { return v_setall_u32(a); } +template<> inline Type2Vec128_Traits< int>::vec_type v_setall< int>(const int& a) { return v_setall_s32(a); } +template<> inline Type2Vec128_Traits::vec_type v_setall(const uint64& a) { return v_setall_u64(a); } +template<> inline Type2Vec128_Traits< int64>::vec_type v_setall< int64>(const int64& a) { return v_setall_s64(a); } +template<> inline Type2Vec128_Traits< float>::vec_type v_setall< float>(const float& a) { return v_setall_f32(a); } +#if CV_SIMD128_64F +template<> inline Type2Vec128_Traits::vec_type v_setall(const double& a) { return v_setall_f64(a); } +#endif + +#endif // SIMD128 + + +#if CV_SIMD256 + +template struct Type2Vec256_Traits; +#define CV_INTRIN_DEF_TYPE2VEC256_TRAITS(type_, vec_type_) \ + template<> struct Type2Vec256_Traits \ + { \ + typedef vec_type_ vec_type; \ + } + +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uchar, v_uint8x32); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(schar, v_int8x32); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(ushort, v_uint16x16); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(short, v_int16x16); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(unsigned, v_uint32x8); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int, v_int32x8); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(float, v_float32x8); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uint64, v_uint64x4); +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int64, v_int64x4); +#if CV_SIMD256_64F +CV_INTRIN_DEF_TYPE2VEC256_TRAITS(double, v_float64x4); +#endif + +template static inline +typename Type2Vec256_Traits<_T>::vec_type v256_setall(const _T& a); + +template<> inline Type2Vec256_Traits< uchar>::vec_type v256_setall< uchar>(const uchar& a) { return v256_setall_u8(a); } +template<> inline Type2Vec256_Traits< schar>::vec_type v256_setall< schar>(const schar& a) { return v256_setall_s8(a); } +template<> inline Type2Vec256_Traits::vec_type v256_setall(const ushort& a) { return v256_setall_u16(a); } +template<> inline Type2Vec256_Traits< short>::vec_type v256_setall< short>(const short& a) { return v256_setall_s16(a); } +template<> inline Type2Vec256_Traits< uint>::vec_type v256_setall< uint>(const uint& a) { return v256_setall_u32(a); } +template<> inline Type2Vec256_Traits< int>::vec_type v256_setall< int>(const int& a) { return v256_setall_s32(a); } +template<> inline Type2Vec256_Traits::vec_type v256_setall(const uint64& a) { return v256_setall_u64(a); } +template<> inline Type2Vec256_Traits< int64>::vec_type v256_setall< int64>(const int64& a) { return v256_setall_s64(a); } +template<> inline Type2Vec256_Traits< float>::vec_type v256_setall< float>(const float& a) { return v256_setall_f32(a); } +#if CV_SIMD256_64F +template<> inline Type2Vec256_Traits::vec_type v256_setall(const double& a) { return v256_setall_f64(a); } +#endif + +#endif // SIMD256 + + +#if CV_SIMD512 + +template struct Type2Vec512_Traits; +#define CV_INTRIN_DEF_TYPE2VEC512_TRAITS(type_, vec_type_) \ + template<> struct Type2Vec512_Traits \ + { \ + typedef vec_type_ vec_type; \ + } + +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uchar, v_uint8x64); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(schar, v_int8x64); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(ushort, v_uint16x32); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(short, v_int16x32); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(unsigned, v_uint32x16); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int, v_int32x16); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(float, v_float32x16); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uint64, v_uint64x8); +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int64, v_int64x8); +#if CV_SIMD512_64F +CV_INTRIN_DEF_TYPE2VEC512_TRAITS(double, v_float64x8); +#endif + +template static inline +typename Type2Vec512_Traits<_T>::vec_type v512_setall(const _T& a); + +template<> inline Type2Vec512_Traits< uchar>::vec_type v512_setall< uchar>(const uchar& a) { return v512_setall_u8(a); } +template<> inline Type2Vec512_Traits< schar>::vec_type v512_setall< schar>(const schar& a) { return v512_setall_s8(a); } +template<> inline Type2Vec512_Traits::vec_type v512_setall(const ushort& a) { return v512_setall_u16(a); } +template<> inline Type2Vec512_Traits< short>::vec_type v512_setall< short>(const short& a) { return v512_setall_s16(a); } +template<> inline Type2Vec512_Traits< uint>::vec_type v512_setall< uint>(const uint& a) { return v512_setall_u32(a); } +template<> inline Type2Vec512_Traits< int>::vec_type v512_setall< int>(const int& a) { return v512_setall_s32(a); } +template<> inline Type2Vec512_Traits::vec_type v512_setall(const uint64& a) { return v512_setall_u64(a); } +template<> inline Type2Vec512_Traits< int64>::vec_type v512_setall< int64>(const int64& a) { return v512_setall_s64(a); } +template<> inline Type2Vec512_Traits< float>::vec_type v512_setall< float>(const float& a) { return v512_setall_f32(a); } +#if CV_SIMD512_64F +template<> inline Type2Vec512_Traits::vec_type v512_setall(const double& a) { return v512_setall_f64(a); } +#endif + +#endif // SIMD512 + + +#if CV_SIMD_WIDTH == 16 +template static inline +typename Type2Vec128_Traits<_T>::vec_type vx_setall(const _T& a) { return v_setall(a); } +#elif CV_SIMD_WIDTH == 32 +template static inline +typename Type2Vec256_Traits<_T>::vec_type vx_setall(const _T& a) { return v256_setall(a); } +#elif CV_SIMD_WIDTH == 64 +template static inline +typename Type2Vec512_Traits<_T>::vec_type vx_setall(const _T& a) { return v512_setall(a); } +#else +#error "Build configuration error, unsupported CV_SIMD_WIDTH" +#endif + + +#endif // OPENCV_HAL_INTRIN_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/mat.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/mat.hpp new file mode 100644 index 0000000..1ef0eb5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/mat.hpp @@ -0,0 +1,3766 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_MAT_HPP +#define OPENCV_CORE_MAT_HPP + +#ifndef __cplusplus +# error mat.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/matx.hpp" +#include "opencv2/core/types.hpp" + +#include "opencv2/core/bufferpool.hpp" + +#include + +namespace cv +{ + +//! @addtogroup core_basic +//! @{ + +enum AccessFlag { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25, + ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 }; +CV_ENUM_FLAGS(AccessFlag) +__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag, int, AccessFlag) + +CV__DEBUG_NS_BEGIN + +class CV_EXPORTS _OutputArray; + +//////////////////////// Input/Output Array Arguments ///////////////////////////////// + +/** @brief This is the proxy class for passing read-only input arrays into OpenCV functions. + +It is defined as: +@code + typedef const _InputArray& InputArray; +@endcode +where _InputArray is a class that can be constructed from `Mat`, `Mat_`, `Matx`, +`std::vector`, `std::vector >`, `std::vector`, `std::vector >`, +`UMat`, `std::vector` or `double`. It can also be constructed from a matrix expression. + +Since this is mostly implementation-level class, and its interface may change in future versions, we +do not describe it in details. There are a few key things, though, that should be kept in mind: + +- When you see in the reference manual or in OpenCV source code a function that takes + InputArray, it means that you can actually pass `Mat`, `Matx`, `vector` etc. (see above the + complete list). +- Optional input arguments: If some of the input arrays may be empty, pass cv::noArray() (or + simply cv::Mat() as you probably did before). +- The class is designed solely for passing parameters. That is, normally you *should not* + declare class members, local and global variables of this type. +- If you want to design your own function or a class method that can operate of arrays of + multiple types, you can use InputArray (or OutputArray) for the respective parameters. Inside + a function you should use _InputArray::getMat() method to construct a matrix header for the + array (without copying data). _InputArray::kind() can be used to distinguish Mat from + `vector<>` etc., but normally it is not needed. + +Here is how you can use a function that takes InputArray : +@code + std::vector vec; + // points or a circle + for( int i = 0; i < 30; i++ ) + vec.push_back(Point2f((float)(100 + 30*cos(i*CV_PI*2/5)), + (float)(100 - 30*sin(i*CV_PI*2/5)))); + cv::transform(vec, vec, cv::Matx23f(0.707, -0.707, 10, 0.707, 0.707, 20)); +@endcode +That is, we form an STL vector containing points, and apply in-place affine transformation to the +vector using the 2x3 matrix created inline as `Matx` instance. + +Here is how such a function can be implemented (for simplicity, we implement a very specific case of +it, according to the assertion statement inside) : +@code + void myAffineTransform(InputArray _src, OutputArray _dst, InputArray _m) + { + // get Mat headers for input arrays. This is O(1) operation, + // unless _src and/or _m are matrix expressions. + Mat src = _src.getMat(), m = _m.getMat(); + CV_Assert( src.type() == CV_32FC2 && m.type() == CV_32F && m.size() == Size(3, 2) ); + + // [re]create the output array so that it has the proper size and type. + // In case of Mat it calls Mat::create, in case of STL vector it calls vector::resize. + _dst.create(src.size(), src.type()); + Mat dst = _dst.getMat(); + + for( int i = 0; i < src.rows; i++ ) + for( int j = 0; j < src.cols; j++ ) + { + Point2f pt = src.at(i, j); + dst.at(i, j) = Point2f(m.at(0, 0)*pt.x + + m.at(0, 1)*pt.y + + m.at(0, 2), + m.at(1, 0)*pt.x + + m.at(1, 1)*pt.y + + m.at(1, 2)); + } + } +@endcode +There is another related type, InputArrayOfArrays, which is currently defined as a synonym for +InputArray: +@code + typedef InputArray InputArrayOfArrays; +@endcode +It denotes function arguments that are either vectors of vectors or vectors of matrices. A separate +synonym is needed to generate Python/Java etc. wrappers properly. At the function implementation +level their use is similar, but _InputArray::getMat(idx) should be used to get header for the +idx-th component of the outer vector and _InputArray::size().area() should be used to find the +number of components (vectors/matrices) of the outer vector. + +In general, type support is limited to cv::Mat types. Other types are forbidden. +But in some cases we need to support passing of custom non-general Mat types, like arrays of cv::KeyPoint, cv::DMatch, etc. +This data is not intended to be interpreted as an image data, or processed somehow like regular cv::Mat. +To pass such custom type use rawIn() / rawOut() / rawInOut() wrappers. +Custom type is wrapped as Mat-compatible `CV_8UC` values (N = sizeof(T), N <= CV_CN_MAX). + */ +class CV_EXPORTS _InputArray +{ +public: + enum KindFlag { + KIND_SHIFT = 16, + FIXED_TYPE = 0x8000 << KIND_SHIFT, + FIXED_SIZE = 0x4000 << KIND_SHIFT, + KIND_MASK = 31 << KIND_SHIFT, + + NONE = 0 << KIND_SHIFT, + MAT = 1 << KIND_SHIFT, + MATX = 2 << KIND_SHIFT, + STD_VECTOR = 3 << KIND_SHIFT, + STD_VECTOR_VECTOR = 4 << KIND_SHIFT, + STD_VECTOR_MAT = 5 << KIND_SHIFT, +#if OPENCV_ABI_COMPATIBILITY < 500 + EXPR = 6 << KIND_SHIFT, //!< removed: https://github.com/opencv/opencv/pull/17046 +#endif + OPENGL_BUFFER = 7 << KIND_SHIFT, + CUDA_HOST_MEM = 8 << KIND_SHIFT, + CUDA_GPU_MAT = 9 << KIND_SHIFT, + UMAT =10 << KIND_SHIFT, + STD_VECTOR_UMAT =11 << KIND_SHIFT, + STD_BOOL_VECTOR =12 << KIND_SHIFT, + STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT, +#if OPENCV_ABI_COMPATIBILITY < 500 + STD_ARRAY =14 << KIND_SHIFT, //!< removed: https://github.com/opencv/opencv/issues/18897 +#endif + STD_ARRAY_MAT =15 << KIND_SHIFT + }; + + _InputArray(); + _InputArray(int _flags, void* _obj); + _InputArray(const Mat& m); + _InputArray(const MatExpr& expr); + _InputArray(const std::vector& vec); + template _InputArray(const Mat_<_Tp>& m); + template _InputArray(const std::vector<_Tp>& vec); + _InputArray(const std::vector& vec); + template _InputArray(const std::vector >& vec); + _InputArray(const std::vector >&) = delete; // not supported + template _InputArray(const std::vector >& vec); + template _InputArray(const _Tp* vec, int n); + template _InputArray(const Matx<_Tp, m, n>& matx); + _InputArray(const double& val); + _InputArray(const cuda::GpuMat& d_mat); + _InputArray(const std::vector& d_mat_array); + _InputArray(const ogl::Buffer& buf); + _InputArray(const cuda::HostMem& cuda_mem); + template _InputArray(const cudev::GpuMat_<_Tp>& m); + _InputArray(const UMat& um); + _InputArray(const std::vector& umv); + + template _InputArray(const std::array<_Tp, _Nm>& arr); + template _InputArray(const std::array& arr); + + template static _InputArray rawIn(const std::vector<_Tp>& vec); + template static _InputArray rawIn(const std::array<_Tp, _Nm>& arr); + + Mat getMat(int idx=-1) const; + Mat getMat_(int idx=-1) const; + UMat getUMat(int idx=-1) const; + void getMatVector(std::vector& mv) const; + void getUMatVector(std::vector& umv) const; + void getGpuMatVector(std::vector& gpumv) const; + cuda::GpuMat getGpuMat() const; + ogl::Buffer getOGlBuffer() const; + + int getFlags() const; + void* getObj() const; + Size getSz() const; + + _InputArray::KindFlag kind() const; + int dims(int i=-1) const; + int cols(int i=-1) const; + int rows(int i=-1) const; + Size size(int i=-1) const; + int sizend(int* sz, int i=-1) const; + bool sameSize(const _InputArray& arr) const; + size_t total(int i=-1) const; + int type(int i=-1) const; + int depth(int i=-1) const; + int channels(int i=-1) const; + bool isContinuous(int i=-1) const; + bool isSubmatrix(int i=-1) const; + bool empty() const; + void copyTo(const _OutputArray& arr) const; + void copyTo(const _OutputArray& arr, const _InputArray & mask) const; + size_t offset(int i=-1) const; + size_t step(int i=-1) const; + bool isMat() const; + bool isUMat() const; + bool isMatVector() const; + bool isUMatVector() const; + bool isMatx() const; + bool isVector() const; + bool isGpuMat() const; + bool isGpuMatVector() const; + ~_InputArray(); + +protected: + int flags; + void* obj; + Size sz; + + void init(int _flags, const void* _obj); + void init(int _flags, const void* _obj, Size _sz); +}; +CV_ENUM_FLAGS(_InputArray::KindFlag) +__CV_ENUM_FLAGS_BITWISE_AND(_InputArray::KindFlag, int, _InputArray::KindFlag) + +/** @brief This type is very similar to InputArray except that it is used for input/output and output function +parameters. + +Just like with InputArray, OpenCV users should not care about OutputArray, they just pass `Mat`, +`vector` etc. to the functions. The same limitation as for `InputArray`: *Do not explicitly +create OutputArray instances* applies here too. + +If you want to make your function polymorphic (i.e. accept different arrays as output parameters), +it is also not very difficult. Take the sample above as the reference. Note that +_OutputArray::create() needs to be called before _OutputArray::getMat(). This way you guarantee +that the output array is properly allocated. + +Optional output parameters. If you do not need certain output array to be computed and returned to +you, pass cv::noArray(), just like you would in the case of optional input array. At the +implementation level, use _OutputArray::needed() to check if certain output array needs to be +computed or not. + +There are several synonyms for OutputArray that are used to assist automatic Python/Java/... wrapper +generators: +@code + typedef OutputArray OutputArrayOfArrays; + typedef OutputArray InputOutputArray; + typedef OutputArray InputOutputArrayOfArrays; +@endcode + */ +class CV_EXPORTS _OutputArray : public _InputArray +{ +public: + enum DepthMask + { + DEPTH_MASK_8U = 1 << CV_8U, + DEPTH_MASK_8S = 1 << CV_8S, + DEPTH_MASK_16U = 1 << CV_16U, + DEPTH_MASK_16S = 1 << CV_16S, + DEPTH_MASK_32S = 1 << CV_32S, + DEPTH_MASK_32F = 1 << CV_32F, + DEPTH_MASK_64F = 1 << CV_64F, + DEPTH_MASK_16F = 1 << CV_16F, + DEPTH_MASK_ALL = (DEPTH_MASK_64F<<1)-1, + DEPTH_MASK_ALL_BUT_8S = DEPTH_MASK_ALL & ~DEPTH_MASK_8S, + DEPTH_MASK_ALL_16F = (DEPTH_MASK_16F<<1)-1, + DEPTH_MASK_FLT = DEPTH_MASK_32F + DEPTH_MASK_64F + }; + + _OutputArray(); + _OutputArray(int _flags, void* _obj); + _OutputArray(Mat& m); + _OutputArray(std::vector& vec); + _OutputArray(cuda::GpuMat& d_mat); + _OutputArray(std::vector& d_mat); + _OutputArray(ogl::Buffer& buf); + _OutputArray(cuda::HostMem& cuda_mem); + template _OutputArray(cudev::GpuMat_<_Tp>& m); + template _OutputArray(std::vector<_Tp>& vec); + _OutputArray(std::vector& vec) = delete; // not supported + template _OutputArray(std::vector >& vec); + _OutputArray(std::vector >&) = delete; // not supported + template _OutputArray(std::vector >& vec); + template _OutputArray(Mat_<_Tp>& m); + template _OutputArray(_Tp* vec, int n); + template _OutputArray(Matx<_Tp, m, n>& matx); + _OutputArray(UMat& m); + _OutputArray(std::vector& vec); + + _OutputArray(const Mat& m); + _OutputArray(const std::vector& vec); + _OutputArray(const cuda::GpuMat& d_mat); + _OutputArray(const std::vector& d_mat); + _OutputArray(const ogl::Buffer& buf); + _OutputArray(const cuda::HostMem& cuda_mem); + template _OutputArray(const cudev::GpuMat_<_Tp>& m); + template _OutputArray(const std::vector<_Tp>& vec); + template _OutputArray(const std::vector >& vec); + template _OutputArray(const std::vector >& vec); + template _OutputArray(const Mat_<_Tp>& m); + template _OutputArray(const _Tp* vec, int n); + template _OutputArray(const Matx<_Tp, m, n>& matx); + _OutputArray(const UMat& m); + _OutputArray(const std::vector& vec); + + template _OutputArray(std::array<_Tp, _Nm>& arr); + template _OutputArray(const std::array<_Tp, _Nm>& arr); + template _OutputArray(std::array& arr); + template _OutputArray(const std::array& arr); + + template static _OutputArray rawOut(std::vector<_Tp>& vec); + template static _OutputArray rawOut(std::array<_Tp, _Nm>& arr); + + bool fixedSize() const; + bool fixedType() const; + bool needed() const; + Mat& getMatRef(int i=-1) const; + UMat& getUMatRef(int i=-1) const; + cuda::GpuMat& getGpuMatRef() const; + std::vector& getGpuMatVecRef() const; + ogl::Buffer& getOGlBufferRef() const; + cuda::HostMem& getHostMemRef() const; + void create(Size sz, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; + void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; + void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, _OutputArray::DepthMask fixedDepthMask=static_cast<_OutputArray::DepthMask>(0)) const; + void createSameSize(const _InputArray& arr, int mtype) const; + void release() const; + void clear() const; + void setTo(const _InputArray& value, const _InputArray & mask = _InputArray()) const; + + void assign(const UMat& u) const; + void assign(const Mat& m) const; + + void assign(const std::vector& v) const; + void assign(const std::vector& v) const; + + void move(UMat& u) const; + void move(Mat& m) const; +}; + + +class CV_EXPORTS _InputOutputArray : public _OutputArray +{ +public: + _InputOutputArray(); + _InputOutputArray(int _flags, void* _obj); + _InputOutputArray(Mat& m); + _InputOutputArray(std::vector& vec); + _InputOutputArray(cuda::GpuMat& d_mat); + _InputOutputArray(ogl::Buffer& buf); + _InputOutputArray(cuda::HostMem& cuda_mem); + template _InputOutputArray(cudev::GpuMat_<_Tp>& m); + template _InputOutputArray(std::vector<_Tp>& vec); + _InputOutputArray(std::vector& vec) = delete; // not supported + template _InputOutputArray(std::vector >& vec); + template _InputOutputArray(std::vector >& vec); + template _InputOutputArray(Mat_<_Tp>& m); + template _InputOutputArray(_Tp* vec, int n); + template _InputOutputArray(Matx<_Tp, m, n>& matx); + _InputOutputArray(UMat& m); + _InputOutputArray(std::vector& vec); + + _InputOutputArray(const Mat& m); + _InputOutputArray(const std::vector& vec); + _InputOutputArray(const cuda::GpuMat& d_mat); + _InputOutputArray(const std::vector& d_mat); + _InputOutputArray(const ogl::Buffer& buf); + _InputOutputArray(const cuda::HostMem& cuda_mem); + template _InputOutputArray(const cudev::GpuMat_<_Tp>& m); + template _InputOutputArray(const std::vector<_Tp>& vec); + template _InputOutputArray(const std::vector >& vec); + template _InputOutputArray(const std::vector >& vec); + template _InputOutputArray(const Mat_<_Tp>& m); + template _InputOutputArray(const _Tp* vec, int n); + template _InputOutputArray(const Matx<_Tp, m, n>& matx); + _InputOutputArray(const UMat& m); + _InputOutputArray(const std::vector& vec); + + template _InputOutputArray(std::array<_Tp, _Nm>& arr); + template _InputOutputArray(const std::array<_Tp, _Nm>& arr); + template _InputOutputArray(std::array& arr); + template _InputOutputArray(const std::array& arr); + + template static _InputOutputArray rawInOut(std::vector<_Tp>& vec); + template _InputOutputArray rawInOut(std::array<_Tp, _Nm>& arr); + +}; + +/** Helper to wrap custom types. @see InputArray */ +template static inline _InputArray rawIn(_Tp& v); +/** Helper to wrap custom types. @see InputArray */ +template static inline _OutputArray rawOut(_Tp& v); +/** Helper to wrap custom types. @see InputArray */ +template static inline _InputOutputArray rawInOut(_Tp& v); + +CV__DEBUG_NS_END + +typedef const _InputArray& InputArray; +typedef InputArray InputArrayOfArrays; +typedef const _OutputArray& OutputArray; +typedef OutputArray OutputArrayOfArrays; +typedef const _InputOutputArray& InputOutputArray; +typedef InputOutputArray InputOutputArrayOfArrays; + +CV_EXPORTS InputOutputArray noArray(); + +/////////////////////////////////// MatAllocator ////////////////////////////////////// + +//! Usage flags for allocator +enum UMatUsageFlags +{ + USAGE_DEFAULT = 0, + + // buffer allocation policy is platform and usage specific + USAGE_ALLOCATE_HOST_MEMORY = 1 << 0, + USAGE_ALLOCATE_DEVICE_MEMORY = 1 << 1, + USAGE_ALLOCATE_SHARED_MEMORY = 1 << 2, // It is not equal to: USAGE_ALLOCATE_HOST_MEMORY | USAGE_ALLOCATE_DEVICE_MEMORY + + __UMAT_USAGE_FLAGS_32BIT = 0x7fffffff // Binary compatibility hint +}; + +struct CV_EXPORTS UMatData; + +/** @brief Custom array allocator +*/ +class CV_EXPORTS MatAllocator +{ +public: + MatAllocator() {} + virtual ~MatAllocator() {} + + // let's comment it off for now to detect and fix all the uses of allocator + //virtual void allocate(int dims, const int* sizes, int type, int*& refcount, + // uchar*& datastart, uchar*& data, size_t* step) = 0; + //virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; + virtual UMatData* allocate(int dims, const int* sizes, int type, + void* data, size_t* step, AccessFlag flags, UMatUsageFlags usageFlags) const = 0; + virtual bool allocate(UMatData* data, AccessFlag accessflags, UMatUsageFlags usageFlags) const = 0; + virtual void deallocate(UMatData* data) const = 0; + virtual void map(UMatData* data, AccessFlag accessflags) const; + virtual void unmap(UMatData* data) const; + virtual void download(UMatData* data, void* dst, int dims, const size_t sz[], + const size_t srcofs[], const size_t srcstep[], + const size_t dststep[]) const; + virtual void upload(UMatData* data, const void* src, int dims, const size_t sz[], + const size_t dstofs[], const size_t dststep[], + const size_t srcstep[]) const; + virtual void copy(UMatData* srcdata, UMatData* dstdata, int dims, const size_t sz[], + const size_t srcofs[], const size_t srcstep[], + const size_t dstofs[], const size_t dststep[], bool sync) const; + + // default implementation returns DummyBufferPoolController + virtual BufferPoolController* getBufferPoolController(const char* id = NULL) const; +}; + + +//////////////////////////////// MatCommaInitializer ////////////////////////////////// + +/** @brief Comma-separated Matrix Initializer + + The class instances are usually not created explicitly. + Instead, they are created on "matrix << firstValue" operator. + + The sample below initializes 2x2 rotation matrix: + + \code + double angle = 30, a = cos(angle*CV_PI/180), b = sin(angle*CV_PI/180); + Mat R = (Mat_(2,2) << a, -b, b, a); + \endcode +*/ +template class MatCommaInitializer_ +{ +public: + //! the constructor, created by "matrix << firstValue" operator, where matrix is cv::Mat + MatCommaInitializer_(Mat_<_Tp>* _m); + //! the operator that takes the next value and put it to the matrix + template MatCommaInitializer_<_Tp>& operator , (T2 v); + //! another form of conversion operator + operator Mat_<_Tp>() const; +protected: + MatIterator_<_Tp> it; +}; + + +/////////////////////////////////////// Mat /////////////////////////////////////////// + +// note that umatdata might be allocated together +// with the matrix data, not as a separate object. +// therefore, it does not have constructor or destructor; +// it should be explicitly initialized using init(). +struct CV_EXPORTS UMatData +{ + enum MemoryFlag { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2, + DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24, + USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64, + ASYNC_CLEANUP=128 + }; + UMatData(const MatAllocator* allocator); + ~UMatData(); + + // provide atomic access to the structure + void lock(); + void unlock(); + + bool hostCopyObsolete() const; + bool deviceCopyObsolete() const; + bool deviceMemMapped() const; + bool copyOnMap() const; + bool tempUMat() const; + bool tempCopiedUMat() const; + void markHostCopyObsolete(bool flag); + void markDeviceCopyObsolete(bool flag); + void markDeviceMemMapped(bool flag); + + const MatAllocator* prevAllocator; + const MatAllocator* currAllocator; + int urefcount; + int refcount; + uchar* data; + uchar* origdata; + size_t size; + + UMatData::MemoryFlag flags; + void* handle; + void* userdata; + int allocatorFlags_; + int mapcount; + UMatData* originalUMatData; + std::shared_ptr allocatorContext; +}; +CV_ENUM_FLAGS(UMatData::MemoryFlag) + + +struct CV_EXPORTS MatSize +{ + explicit MatSize(int* _p) CV_NOEXCEPT; + int dims() const CV_NOEXCEPT; + Size operator()() const; + const int& operator[](int i) const; + int& operator[](int i); + operator const int*() const CV_NOEXCEPT; // TODO OpenCV 4.0: drop this + bool operator == (const MatSize& sz) const CV_NOEXCEPT; + bool operator != (const MatSize& sz) const CV_NOEXCEPT; + + int* p; +}; + +struct CV_EXPORTS MatStep +{ + MatStep() CV_NOEXCEPT; + explicit MatStep(size_t s) CV_NOEXCEPT; + const size_t& operator[](int i) const CV_NOEXCEPT; + size_t& operator[](int i) CV_NOEXCEPT; + operator size_t() const; + MatStep& operator = (size_t s); + + size_t* p; + size_t buf[2]; +protected: + MatStep& operator = (const MatStep&); +}; + +/** @example samples/cpp/cout_mat.cpp +An example demonstrating the serial out capabilities of cv::Mat +*/ + + /** @brief n-dimensional dense array class \anchor CVMat_Details + +The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It +can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel +volumes, vector fields, point clouds, tensors, histograms (though, very high-dimensional histograms +may be better stored in a SparseMat ). The data layout of the array `M` is defined by the array +`M.step[]`, so that the address of element \f$(i_0,...,i_{M.dims-1})\f$, where \f$0\leq i_k= M.step[i+1]` (in fact, `M.step[i] >= M.step[i+1]*M.size[i+1]` ). This means +that 2-dimensional matrices are stored row-by-row, 3-dimensional matrices are stored plane-by-plane, +and so on. M.step[M.dims-1] is minimal and always equal to the element size M.elemSize() . + +So, the data layout in Mat is compatible with the majority of dense array types from the standard +toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device bitmaps), and others, +that is, with any array that uses *steps* (or *strides*) to compute the position of a pixel. +Due to this compatibility, it is possible to make a Mat header for user-allocated data and process +it in-place using OpenCV functions. + +There are many different ways to create a Mat object. The most popular options are listed below: + +- Use the create(nrows, ncols, type) method or the similar Mat(nrows, ncols, type[, fillValue]) +constructor. A new array of the specified size and type is allocated. type has the same meaning as +in the cvCreateMat method. For example, CV_8UC1 means a 8-bit single-channel array, CV_32FC2 +means a 2-channel (complex) floating-point array, and so on. +@code + // make a 7x7 complex matrix filled with 1+3j. + Mat M(7,7,CV_32FC2,Scalar(1,3)); + // and now turn M to a 100x60 15-channel 8-bit matrix. + // The old content will be deallocated + M.create(100,60,CV_8UC(15)); +@endcode +As noted in the introduction to this chapter, create() allocates only a new array when the shape +or type of the current array are different from the specified ones. + +- Create a multi-dimensional array: +@code + // create a 100x100x100 8-bit array + int sz[] = {100, 100, 100}; + Mat bigCube(3, sz, CV_8U, Scalar::all(0)); +@endcode +It passes the number of dimensions =1 to the Mat constructor but the created array will be +2-dimensional with the number of columns set to 1. So, Mat::dims is always \>= 2 (can also be 0 +when the array is empty). + +- Use a copy constructor or assignment operator where there can be an array or expression on the +right side (see below). As noted in the introduction, the array assignment is an O(1) operation +because it only copies the header and increases the reference counter. The Mat::clone() method can +be used to get a full (deep) copy of the array when you need it. + +- Construct a header for a part of another array. It can be a single row, single column, several +rows, several columns, rectangular region in the array (called a *minor* in algebra) or a +diagonal. Such operations are also O(1) because the new header references the same data. You can +actually modify a part of the array using this feature, for example: +@code + // add the 5-th row, multiplied by 3 to the 3rd row + M.row(3) = M.row(3) + M.row(5)*3; + // now copy the 7-th column to the 1-st column + // M.col(1) = M.col(7); // this will not work + Mat M1 = M.col(1); + M.col(7).copyTo(M1); + // create a new 320x240 image + Mat img(Size(320,240),CV_8UC3); + // select a ROI + Mat roi(img, Rect(10,10,100,100)); + // fill the ROI with (0,255,0) (which is green in RGB space); + // the original 320x240 image will be modified + roi = Scalar(0,255,0); +@endcode +Due to the additional datastart and dataend members, it is possible to compute a relative +sub-array position in the main *container* array using locateROI(): +@code + Mat A = Mat::eye(10, 10, CV_32S); + // extracts A columns, 1 (inclusive) to 3 (exclusive). + Mat B = A(Range::all(), Range(1, 3)); + // extracts B rows, 5 (inclusive) to 9 (exclusive). + // that is, C \~ A(Range(5, 9), Range(1, 3)) + Mat C = B(Range(5, 9), Range::all()); + Size size; Point ofs; + C.locateROI(size, ofs); + // size will be (width=10,height=10) and the ofs will be (x=1, y=5) +@endcode +As in case of whole matrices, if you need a deep copy, use the `clone()` method of the extracted +sub-matrices. + +- Make a header for user-allocated data. It can be useful to do the following: + -# Process "foreign" data using OpenCV (for example, when you implement a DirectShow\* filter or + a processing module for gstreamer, and so on). For example: + @code + Mat process_video_frame(const unsigned char* pixels, + int width, int height, int step) + { + // wrap input buffer + Mat img(height, width, CV_8UC3, (unsigned char*)pixels, step); + + Mat result; + GaussianBlur(img, result, Size(7, 7), 1.5, 1.5); + + return result; + } + @endcode + -# Quickly initialize small matrices and/or get a super-fast element access. + @code + double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}}; + Mat M = Mat(3, 3, CV_64F, m).inv(); + @endcode + . + +- Use MATLAB-style array initializers, zeros(), ones(), eye(), for example: +@code + // create a double-precision identity matrix and add it to M. + M += Mat::eye(M.rows, M.cols, CV_64F); +@endcode + +- Use a comma-separated initializer: +@code + // create a 3x3 double-precision identity matrix + Mat M = (Mat_(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1); +@endcode +With this approach, you first call a constructor of the Mat class with the proper parameters, and +then you just put `<< operator` followed by comma-separated values that can be constants, +variables, expressions, and so on. Also, note the extra parentheses required to avoid compilation +errors. + +Once the array is created, it is automatically managed via a reference-counting mechanism. If the +array header is built on top of user-allocated data, you should handle the data by yourself. The +array data is deallocated when no one points to it. If you want to release the data pointed by a +array header before the array destructor is called, use Mat::release(). + +The next important thing to learn about the array class is element access. This manual already +described how to compute an address of each array element. Normally, you are not required to use the +formula directly in the code. If you know the array element type (which can be retrieved using the +method Mat::type() ), you can access the element \f$M_{ij}\f$ of a 2-dimensional array as: +@code + M.at(i,j) += 1.f; +@endcode +assuming that `M` is a double-precision floating-point array. There are several variants of the method +at for a different number of dimensions. + +If you need to process a whole row of a 2D array, the most efficient way is to get the pointer to +the row first, and then just use the plain C operator [] : +@code + // compute sum of positive matrix elements + // (assuming that M is a double-precision matrix) + double sum=0; + for(int i = 0; i < M.rows; i++) + { + const double* Mi = M.ptr(i); + for(int j = 0; j < M.cols; j++) + sum += std::max(Mi[j], 0.); + } +@endcode +Some operations, like the one above, do not actually depend on the array shape. They just process +elements of an array one by one (or elements from multiple arrays that have the same coordinates, +for example, array addition). Such operations are called *element-wise*. It makes sense to check +whether all the input/output arrays are continuous, namely, have no gaps at the end of each row. If +yes, process them as a long single row: +@code + // compute the sum of positive matrix elements, optimized variant + double sum=0; + int cols = M.cols, rows = M.rows; + if(M.isContinuous()) + { + cols *= rows; + rows = 1; + } + for(int i = 0; i < rows; i++) + { + const double* Mi = M.ptr(i); + for(int j = 0; j < cols; j++) + sum += std::max(Mi[j], 0.); + } +@endcode +In case of the continuous matrix, the outer loop body is executed just once. So, the overhead is +smaller, which is especially noticeable in case of small matrices. + +Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows: +@code + // compute sum of positive matrix elements, iterator-based variant + double sum=0; + MatConstIterator_ it = M.begin(), it_end = M.end(); + for(; it != it_end; ++it) + sum += std::max(*it, 0.); +@endcode +The matrix iterators are random-access iterators, so they can be passed to any STL algorithm, +including std::sort(). + +@note Matrix Expressions and arithmetic see MatExpr +*/ +class CV_EXPORTS Mat +{ +public: + /** + These are various constructors that form a matrix. As noted in the AutomaticAllocation, often + the default constructor is enough, and the proper matrix will be allocated by an OpenCV function. + The constructed matrix can further be assigned to another matrix or matrix expression or can be + allocated with Mat::create . In the former case, the old content is de-referenced. + */ + Mat() CV_NOEXCEPT; + + /** @overload + @param rows Number of rows in a 2D array. + @param cols Number of columns in a 2D array. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(int rows, int cols, int type); + + /** @overload + @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + number of columns go in the reverse order. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(Size size, int type); + + /** @overload + @param rows Number of rows in a 2D array. + @param cols Number of columns in a 2D array. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(int rows, int cols, int type, const Scalar& s); + + /** @overload + @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + number of columns go in the reverse order. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(Size size, int type, const Scalar& s); + + /** @overload + @param ndims Array dimensionality. + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(int ndims, const int* sizes, int type); + + /** @overload + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + */ + Mat(const std::vector& sizes, int type); + + /** @overload + @param ndims Array dimensionality. + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(int ndims, const int* sizes, int type, const Scalar& s); + + /** @overload + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param s An optional value to initialize each matrix element with. To set all the matrix elements to + the particular value after the construction, use the assignment operator + Mat::operator=(const Scalar& value) . + */ + Mat(const std::vector& sizes, int type, const Scalar& s); + + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + */ + Mat(const Mat& m); + + /** @overload + @param rows Number of rows in a 2D array. + @param cols Number of columns in a 2D array. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param step Number of bytes each matrix row occupies. The value should include the padding bytes at + the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + */ + Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP); + + /** @overload + @param size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the + number of columns go in the reverse order. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param step Number of bytes each matrix row occupies. The value should include the padding bytes at + the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + */ + Mat(Size size, int type, void* data, size_t step=AUTO_STEP); + + /** @overload + @param ndims Array dimensionality. + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + set to the element size). If not specified, the matrix is assumed to be continuous. + */ + Mat(int ndims, const int* sizes, int type, void* data, const size_t* steps=0); + + /** @overload + @param sizes Array of integers specifying an n-dimensional array shape. + @param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param steps Array of ndims-1 steps in case of a multi-dimensional array (the last step is always + set to the element size). If not specified, the matrix is assumed to be continuous. + */ + Mat(const std::vector& sizes, int type, void* data, const size_t* steps=0); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param rowRange Range of the m rows to take. As usual, the range start is inclusive and the range + end is exclusive. Use Range::all() to take all the rows. + @param colRange Range of the m columns to take. Use Range::all() to take all the columns. + */ + Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all()); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param roi Region of interest. + */ + Mat(const Mat& m, const Rect& roi); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param ranges Array of selected ranges of m along each dimensionality. + */ + Mat(const Mat& m, const Range* ranges); + + /** @overload + @param m Array that (as a whole or partly) is assigned to the constructed matrix. No data is copied + by these constructors. Instead, the header pointing to m data or its sub-array is constructed and + associated with it. The reference counter, if any, is incremented. So, when you modify the matrix + formed using such a constructor, you also modify the corresponding elements of m . If you want to + have an independent copy of the sub-array, use Mat::clone() . + @param ranges Array of selected ranges of m along each dimensionality. + */ + Mat(const Mat& m, const std::vector& ranges); + + /** @overload + @param vec STL vector whose elements form the matrix. The matrix has a single column and the number + of rows equal to the number of vector elements. Type of the matrix matches the type of vector + elements. The constructor can handle arbitrary types, for which there is a properly declared + DataType . This means that the vector elements must be primitive numbers or uni-type numerical + tuples of numbers. Mixed-type structures are not supported. The corresponding constructor is + explicit. Since STL vectors are not automatically converted to Mat instances, you should write + Mat(vec) explicitly. Unless you copy the data into the matrix ( copyData=true ), no new elements + will be added to the vector because it can potentially yield vector data reallocation, and, thus, + the matrix data pointer will be invalid. + @param copyData Flag to specify whether the underlying data of the STL vector should be copied + to (true) or shared with (false) the newly constructed matrix. When the data is copied, the + allocated buffer is managed using Mat reference counting mechanism. While the data is shared, + the reference counter is NULL, and you should not deallocate the data until the matrix is not + destructed. + */ + template explicit Mat(const std::vector<_Tp>& vec, bool copyData=false); + + /** @overload + */ + template::value>::type> + explicit Mat(const std::initializer_list<_Tp> list); + + /** @overload + */ + template explicit Mat(const std::initializer_list sizes, const std::initializer_list<_Tp> list); + + /** @overload + */ + template explicit Mat(const std::array<_Tp, _Nm>& arr, bool copyData=false); + + /** @overload + */ + template explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true); + + /** @overload + */ + template explicit Mat(const Matx<_Tp, m, n>& mtx, bool copyData=true); + + /** @overload + */ + template explicit Mat(const Point_<_Tp>& pt, bool copyData=true); + + /** @overload + */ + template explicit Mat(const Point3_<_Tp>& pt, bool copyData=true); + + /** @overload + */ + template explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer); + + //! download data from GpuMat + explicit Mat(const cuda::GpuMat& m); + + //! destructor - calls release() + ~Mat(); + + /** @brief assignment operators + + These are available assignment operators. Since they all are very different, make sure to read the + operator parameters description. + @param m Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that + no data is copied but the data is shared and the reference counter, if any, is incremented. Before + assigning new data, the old data is de-referenced via Mat::release . + */ + Mat& operator = (const Mat& m); + + /** @overload + @param expr Assigned matrix expression object. As opposite to the first form of the assignment + operation, the second form can reuse already allocated matrix if it has the right size and type to + fit the matrix expression result. It is automatically handled by the real function that the matrix + expressions is expanded to. For example, C=A+B is expanded to add(A, B, C), and add takes care of + automatic C reallocation. + */ + Mat& operator = (const MatExpr& expr); + + //! retrieve UMat from Mat + UMat getUMat(AccessFlag accessFlags, UMatUsageFlags usageFlags = USAGE_DEFAULT) const; + + /** @brief Creates a matrix header for the specified matrix row. + + The method makes a new header for the specified matrix row and returns it. This is an O(1) + operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + original matrix. Here is the example of one of the classical basic matrix processing operations, + axpy, used by LU and many other algorithms: + @code + inline void matrix_axpy(Mat& A, int i, int j, double alpha) + { + A.row(i) += A.row(j)*alpha; + } + @endcode + @note In the current implementation, the following code does not work as expected: + @code + Mat A; + ... + A.row(i) = A.row(j); // will not work + @endcode + This happens because A.row(i) forms a temporary header that is further assigned to another header. + Remember that each of these operations is O(1), that is, no data is copied. Thus, the above + assignment is not true if you may have expected the j-th row to be copied to the i-th row. To + achieve that, you should either turn this simple assignment into an expression or use the + Mat::copyTo method: + @code + Mat A; + ... + // works, but looks a bit obscure. + A.row(i) = A.row(j) + 0; + // this is a bit longer, but the recommended method. + A.row(j).copyTo(A.row(i)); + @endcode + @param y A 0-based row index. + */ + Mat row(int y) const; + + /** @brief Creates a matrix header for the specified matrix column. + + The method makes a new header for the specified matrix column and returns it. This is an O(1) + operation, regardless of the matrix size. The underlying data of the new matrix is shared with the + original matrix. See also the Mat::row description. + @param x A 0-based column index. + */ + Mat col(int x) const; + + /** @brief Creates a matrix header for the specified row span. + + The method makes a new header for the specified row span of the matrix. Similarly to Mat::row and + Mat::col , this is an O(1) operation. + @param startrow An inclusive 0-based start index of the row span. + @param endrow An exclusive 0-based ending index of the row span. + */ + Mat rowRange(int startrow, int endrow) const; + + /** @overload + @param r Range structure containing both the start and the end indices. + */ + Mat rowRange(const Range& r) const; + + /** @brief Creates a matrix header for the specified column span. + + The method makes a new header for the specified column span of the matrix. Similarly to Mat::row and + Mat::col , this is an O(1) operation. + @param startcol An inclusive 0-based start index of the column span. + @param endcol An exclusive 0-based ending index of the column span. + */ + Mat colRange(int startcol, int endcol) const; + + /** @overload + @param r Range structure containing both the start and the end indices. + */ + Mat colRange(const Range& r) const; + + /** @brief Extracts a diagonal from a matrix + + The method makes a new header for the specified matrix diagonal. The new matrix is represented as a + single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation. + @param d index of the diagonal, with the following values: + - `d=0` is the main diagonal. + - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set + immediately below the main one. + - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set + immediately above the main one. + For example: + @code + Mat m = (Mat_(3,3) << + 1,2,3, + 4,5,6, + 7,8,9); + Mat d0 = m.diag(0); + Mat d1 = m.diag(1); + Mat d_1 = m.diag(-1); + @endcode + The resulting matrices are + @code + d0 = + [1; + 5; + 9] + d1 = + [2; + 6] + d_1 = + [4; + 8] + @endcode + */ + Mat diag(int d=0) const; + + /** @brief creates a diagonal matrix + + The method creates a square diagonal matrix from specified main diagonal. + @param d One-dimensional matrix that represents the main diagonal. + */ + CV_NODISCARD_STD static Mat diag(const Mat& d); + + /** @brief Creates a full copy of the array and the underlying data. + + The method creates a full copy of the array. The original step[] is not taken into account. So, the + array copy is a continuous array occupying total()*elemSize() bytes. + */ + CV_NODISCARD_STD Mat clone() const; + + /** @brief Copies the matrix to another one. + + The method copies the matrix data to another matrix. Before copying the data, the method invokes : + @code + m.create(this->size(), this->type()); + @endcode + so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the + function does not handle the case of a partial overlap between the source and the destination + matrices. + + When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, + the newly allocated matrix is initialized with all zeros before copying the data. + @param m Destination matrix. If it does not have a proper size or type before the operation, it is + reallocated. + */ + void copyTo( OutputArray m ) const; + + /** @overload + @param m Destination matrix. If it does not have a proper size or type before the operation, it is + reallocated. + @param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels. + */ + void copyTo( OutputArray m, InputArray mask ) const; + + /** @brief Converts an array to another data type with optional scaling. + + The method converts source pixel values to the target data type. saturate_cast\<\> is applied at + the end to avoid possible overflows: + + \f[m(x,y) = saturate \_ cast( \alpha (*this)(x,y) + \beta )\f] + @param m output matrix; if it does not have a proper size or type before the operation, it is + reallocated. + @param rtype desired output matrix type or, rather, the depth since the number of channels are the + same as the input has; if rtype is negative, the output matrix will have the same type as the input. + @param alpha optional scale factor. + @param beta optional delta added to the scaled values. + */ + void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + + /** @brief Provides a functional form of convertTo. + + This is an internally used method called by the @ref MatrixExpressions engine. + @param m Destination array. + @param type Desired destination array depth (or -1 if it should be the same as the source type). + */ + void assignTo( Mat& m, int type=-1 ) const; + + /** @brief Sets all or some of the array elements to the specified value. + @param s Assigned scalar converted to the actual array type. + */ + Mat& operator = (const Scalar& s); + + /** @brief Sets all or some of the array elements to the specified value. + + This is an advanced variant of the Mat::operator=(const Scalar& s) operator. + @param value Assigned scalar converted to the actual array type. + @param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix + elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels + */ + Mat& setTo(InputArray value, InputArray mask=noArray()); + + /** @brief Changes the shape and/or the number of channels of a 2D matrix without copying the data. + + The method makes a new matrix header for \*this elements. The new matrix may have a different size + and/or different number of channels. Any combination is possible if: + - No extra elements are included into the new matrix and no elements are excluded. Consequently, + the product rows\*cols\*channels() must stay the same after the transformation. + - No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of + rows, or the operation changes the indices of elements row in some other way, the matrix must be + continuous. See Mat::isContinuous . + + For example, if there is a set of 3D points stored as an STL vector, and you want to represent the + points as a 3xN matrix, do the following: + @code + std::vector vec; + ... + Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation + reshape(1). // make Nx3 1-channel matrix out of Nx1 3-channel. + // Also, an O(1) operation + t(); // finally, transpose the Nx3 matrix. + // This involves copying all the elements + @endcode + @param cn New number of channels. If the parameter is 0, the number of channels remains the same. + @param rows New number of rows. If the parameter is 0, the number of rows remains the same. + */ + Mat reshape(int cn, int rows=0) const; + + /** @overload */ + Mat reshape(int cn, int newndims, const int* newsz) const; + + /** @overload */ + Mat reshape(int cn, const std::vector& newshape) const; + + /** @brief Transposes a matrix. + + The method performs matrix transposition by means of matrix expressions. It does not perform the + actual transposition but returns a temporary matrix transposition object that can be further used as + a part of more complex matrix expressions or can be assigned to a matrix: + @code + Mat A1 = A + Mat::eye(A.size(), A.type())*lambda; + Mat C = A1.t()*A1; // compute (A + lambda*I)^t * (A + lamda*I) + @endcode + */ + MatExpr t() const; + + /** @brief Inverses a matrix. + + The method performs a matrix inversion by means of matrix expressions. This means that a temporary + matrix inversion object is returned by the method and can be used further as a part of more complex + matrix expressions or can be assigned to a matrix. + @param method Matrix inversion method. One of cv::DecompTypes + */ + MatExpr inv(int method=DECOMP_LU) const; + + /** @brief Performs an element-wise multiplication or division of the two matrices. + + The method returns a temporary object encoding per-element array multiplication, with optional + scale. Note that this is not a matrix multiplication that corresponds to a simpler "\*" operator. + + Example: + @code + Mat C = A.mul(5/B); // equivalent to divide(A, B, C, 5) + @endcode + @param m Another array of the same type and the same size as \*this, or a matrix expression. + @param scale Optional scale factor. + */ + MatExpr mul(InputArray m, double scale=1) const; + + /** @brief Computes a cross-product of two 3-element vectors. + + The method computes a cross-product of two 3-element vectors. The vectors must be 3-element + floating-point vectors of the same shape and size. The result is another 3-element vector of the + same shape and type as operands. + @param m Another cross-product operand. + */ + Mat cross(InputArray m) const; + + /** @brief Computes a dot-product of two vectors. + + The method computes a dot-product of two matrices. If the matrices are not single-column or + single-row vectors, the top-to-bottom left-to-right scan ordering is used to treat them as 1D + vectors. The vectors must have the same size and type. If the matrices have more than one channel, + the dot products from all the channels are summed together. + @param m another dot-product operand. + */ + double dot(InputArray m) const; + + /** @brief Returns a zero array of the specified size and type. + + The method returns a Matlab-style zero array initializer. It can be used to quickly form a constant + array as a function parameter, part of a matrix expression, or as a matrix initializer: + @code + Mat A; + A = Mat::zeros(3, 3, CV_32F); + @endcode + In the example above, a new matrix is allocated only if A is not a 3x3 floating-point matrix. + Otherwise, the existing matrix A is filled with zeros. + @param rows Number of rows. + @param cols Number of columns. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr zeros(int rows, int cols, int type); + + /** @overload + @param size Alternative to the matrix size specification Size(cols, rows) . + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr zeros(Size size, int type); + + /** @overload + @param ndims Array dimensionality. + @param sz Array of integers specifying the array shape. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr zeros(int ndims, const int* sz, int type); + + /** @brief Returns an array of all 1's of the specified size and type. + + The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using + this method you can initialize an array with an arbitrary value, using the following Matlab idiom: + @code + Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3. + @endcode + The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it + just remembers the scale factor (3 in this case) and use it when actually invoking the matrix + initializer. + @note In case of multi-channels type, only the first channel will be initialized with 1's, the + others will be set to 0's. + @param rows Number of rows. + @param cols Number of columns. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr ones(int rows, int cols, int type); + + /** @overload + @param size Alternative to the matrix size specification Size(cols, rows) . + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr ones(Size size, int type); + + /** @overload + @param ndims Array dimensionality. + @param sz Array of integers specifying the array shape. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr ones(int ndims, const int* sz, int type); + + /** @brief Returns an identity matrix of the specified size and type. + + The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to + Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently: + @code + // make a 4x4 diagonal matrix with 0.1's on the diagonal. + Mat A = Mat::eye(4, 4, CV_32F)*0.1; + @endcode + @note In case of multi-channels type, identity matrix will be initialized only for the first channel, + the others will be set to 0's + @param rows Number of rows. + @param cols Number of columns. + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr eye(int rows, int cols, int type); + + /** @overload + @param size Alternative matrix size specification as Size(cols, rows) . + @param type Created matrix type. + */ + CV_NODISCARD_STD static MatExpr eye(Size size, int type); + + /** @brief Allocates new array data if needed. + + This is one of the key Mat methods. Most new-style OpenCV functions and methods that produce arrays + call this method for each output array. The method uses the following algorithm: + + -# If the current array shape and the type match the new ones, return immediately. Otherwise, + de-reference the previous data by calling Mat::release. + -# Initialize the new header. + -# Allocate the new data of total()\*elemSize() bytes. + -# Allocate the new, associated with the data, reference counter and set it to 1. + + Such a scheme makes the memory management robust and efficient at the same time and helps avoid + extra typing for you. This means that usually there is no need to explicitly allocate output arrays. + That is, instead of writing: + @code + Mat color; + ... + Mat gray(color.rows, color.cols, color.depth()); + cvtColor(color, gray, COLOR_BGR2GRAY); + @endcode + you can simply write: + @code + Mat color; + ... + Mat gray; + cvtColor(color, gray, COLOR_BGR2GRAY); + @endcode + because cvtColor, as well as the most of OpenCV functions, calls Mat::create() for the output array + internally. + @param rows New number of rows. + @param cols New number of columns. + @param type New matrix type. + */ + void create(int rows, int cols, int type); + + /** @overload + @param size Alternative new matrix size specification: Size(cols, rows) + @param type New matrix type. + */ + void create(Size size, int type); + + /** @overload + @param ndims New array dimensionality. + @param sizes Array of integers specifying a new array shape. + @param type New matrix type. + */ + void create(int ndims, const int* sizes, int type); + + /** @overload + @param sizes Array of integers specifying a new array shape. + @param type New matrix type. + */ + void create(const std::vector& sizes, int type); + + /** @brief Increments the reference counter. + + The method increments the reference counter associated with the matrix data. If the matrix header + points to an external data set (see Mat::Mat ), the reference counter is NULL, and the method has no + effect in this case. Normally, to avoid memory leaks, the method should not be called explicitly. It + is called implicitly by the matrix assignment operator. The reference counter increment is an atomic + operation on the platforms that support it. Thus, it is safe to operate on the same matrices + asynchronously in different threads. + */ + void addref(); + + /** @brief Decrements the reference counter and deallocates the matrix if needed. + + The method decrements the reference counter associated with the matrix data. When the reference + counter reaches 0, the matrix data is deallocated and the data and the reference counter pointers + are set to NULL's. If the matrix header points to an external data set (see Mat::Mat ), the + reference counter is NULL, and the method has no effect in this case. + + This method can be called manually to force the matrix data deallocation. But since this method is + automatically called in the destructor, or by any other method that changes the data pointer, it is + usually not needed. The reference counter decrement and check for 0 is an atomic operation on the + platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in + different threads. + */ + void release(); + + //! internal use function, consider to use 'release' method instead; deallocates the matrix data + void deallocate(); + //! internal use function; properly re-allocates _size, _step arrays + void copySize(const Mat& m); + + /** @brief Reserves space for the certain number of rows. + + The method reserves space for sz rows. If the matrix already has enough space to store sz rows, + nothing happens. If the matrix is reallocated, the first Mat::rows rows are preserved. The method + emulates the corresponding method of the STL vector class. + @param sz Number of rows. + */ + void reserve(size_t sz); + + /** @brief Reserves space for the certain number of bytes. + + The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes, + nothing happens. If matrix has to be reallocated its previous content could be lost. + @param sz Number of bytes. + */ + void reserveBuffer(size_t sz); + + /** @brief Changes the number of matrix rows. + + The methods change the number of matrix rows. If the matrix is reallocated, the first + min(Mat::rows, sz) rows are preserved. The methods emulate the corresponding methods of the STL + vector class. + @param sz New number of rows. + */ + void resize(size_t sz); + + /** @overload + @param sz New number of rows. + @param s Value assigned to the newly added elements. + */ + void resize(size_t sz, const Scalar& s); + + //! internal function + void push_back_(const void* elem); + + /** @brief Adds elements to the bottom of the matrix. + + The methods add one or more elements to the bottom of the matrix. They emulate the corresponding + method of the STL vector class. When elem is Mat , its type and the number of columns must be the + same as in the container matrix. + @param elem Added element(s). + */ + template void push_back(const _Tp& elem); + + /** @overload + @param elem Added element(s). + */ + template void push_back(const Mat_<_Tp>& elem); + + /** @overload + @param elem Added element(s). + */ + template void push_back(const std::vector<_Tp>& elem); + + /** @overload + @param m Added line(s). + */ + void push_back(const Mat& m); + + /** @brief Removes elements from the bottom of the matrix. + + The method removes one or more rows from the bottom of the matrix. + @param nelems Number of removed rows. If it is greater than the total number of rows, an exception + is thrown. + */ + void pop_back(size_t nelems=1); + + /** @brief Locates the matrix header within a parent matrix. + + After you extracted a submatrix from a matrix using Mat::row, Mat::col, Mat::rowRange, + Mat::colRange, and others, the resultant submatrix points just to the part of the original big + matrix. However, each submatrix contains information (represented by datastart and dataend + fields) that helps reconstruct the original matrix size and the position of the extracted + submatrix within the original matrix. The method locateROI does exactly that. + @param wholeSize Output parameter that contains the size of the whole matrix containing *this* + as a part. + @param ofs Output parameter that contains an offset of *this* inside the whole matrix. + */ + void locateROI( Size& wholeSize, Point& ofs ) const; + + /** @brief Adjusts a submatrix size and position within the parent matrix. + + The method is complimentary to Mat::locateROI . The typical use of these functions is to determine + the submatrix position within the parent matrix and then shift the position somehow. Typically, it + can be required for filtering operations when pixels outside of the ROI should be taken into + account. When all the method parameters are positive, the ROI needs to grow in all directions by the + specified amount, for example: + @code + A.adjustROI(2, 2, 2, 2); + @endcode + In this example, the matrix size is increased by 4 elements in each direction. The matrix is shifted + by 2 elements to the left and 2 elements up, which brings in all the necessary pixels for the + filtering with the 5x5 kernel. + + adjustROI forces the adjusted ROI to be inside of the parent matrix that is boundaries of the + adjusted ROI are constrained by boundaries of the parent matrix. For example, if the submatrix A is + located in the first row of a parent matrix and you called A.adjustROI(2, 2, 2, 2) then A will not + be increased in the upward direction. + + The function is used internally by the OpenCV filtering functions, like filter2D , morphological + operations, and so on. + @param dtop Shift of the top submatrix boundary upwards. + @param dbottom Shift of the bottom submatrix boundary downwards. + @param dleft Shift of the left submatrix boundary to the left. + @param dright Shift of the right submatrix boundary to the right. + @sa copyMakeBorder + */ + Mat& adjustROI( int dtop, int dbottom, int dleft, int dright ); + + /** @brief Extracts a rectangular submatrix. + + The operators make a new header for the specified sub-array of \*this . They are the most + generalized forms of Mat::row, Mat::col, Mat::rowRange, and Mat::colRange . For example, + `A(Range(0, 10), Range::all())` is equivalent to `A.rowRange(0, 10)`. Similarly to all of the above, + the operators are O(1) operations, that is, no matrix data is copied. + @param rowRange Start and end row of the extracted submatrix. The upper boundary is not included. To + select all the rows, use Range::all(). + @param colRange Start and end column of the extracted submatrix. The upper boundary is not included. + To select all the columns, use Range::all(). + */ + Mat operator()( Range rowRange, Range colRange ) const; + + /** @overload + @param roi Extracted submatrix specified as a rectangle. + */ + Mat operator()( const Rect& roi ) const; + + /** @overload + @param ranges Array of selected ranges along each array dimension. + */ + Mat operator()( const Range* ranges ) const; + + /** @overload + @param ranges Array of selected ranges along each array dimension. + */ + Mat operator()(const std::vector& ranges) const; + + template operator std::vector<_Tp>() const; + template operator Vec<_Tp, n>() const; + template operator Matx<_Tp, m, n>() const; + + template operator std::array<_Tp, _Nm>() const; + + /** @brief Reports whether the matrix is continuous or not. + + The method returns true if the matrix elements are stored continuously without gaps at the end of + each row. Otherwise, it returns false. Obviously, 1x1 or 1xN matrices are always continuous. + Matrices created with Mat::create are always continuous. But if you extract a part of the matrix + using Mat::col, Mat::diag, and so on, or constructed a matrix header for externally allocated data, + such matrices may no longer have this property. + + The continuity flag is stored as a bit in the Mat::flags field and is computed automatically when + you construct a matrix header. Thus, the continuity check is a very fast operation, though + theoretically it could be done as follows: + @code + // alternative implementation of Mat::isContinuous() + bool myCheckMatContinuity(const Mat& m) + { + //return (m.flags & Mat::CONTINUOUS_FLAG) != 0; + return m.rows == 1 || m.step == m.cols*m.elemSize(); + } + @endcode + The method is used in quite a few of OpenCV functions. The point is that element-wise operations + (such as arithmetic and logical operations, math functions, alpha blending, color space + transformations, and others) do not depend on the image geometry. Thus, if all the input and output + arrays are continuous, the functions can process them as very long single-row vectors. The example + below illustrates how an alpha-blending function can be implemented: + @code + template + void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) + { + const float alpha_scale = (float)std::numeric_limits::max(), + inv_scale = 1.f/alpha_scale; + + CV_Assert( src1.type() == src2.type() && + src1.type() == CV_MAKETYPE(traits::Depth::value, 4) && + src1.size() == src2.size()); + Size size = src1.size(); + dst.create(size, src1.type()); + + // here is the idiom: check the arrays for continuity and, + // if this is the case, + // treat the arrays as 1D vectors + if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() ) + { + size.width *= size.height; + size.height = 1; + } + size.width *= 4; + + for( int i = 0; i < size.height; i++ ) + { + // when the arrays are continuous, + // the outer loop is executed only once + const T* ptr1 = src1.ptr(i); + const T* ptr2 = src2.ptr(i); + T* dptr = dst.ptr(i); + + for( int j = 0; j < size.width; j += 4 ) + { + float alpha = ptr1[j+3]*inv_scale, beta = ptr2[j+3]*inv_scale; + dptr[j] = saturate_cast(ptr1[j]*alpha + ptr2[j]*beta); + dptr[j+1] = saturate_cast(ptr1[j+1]*alpha + ptr2[j+1]*beta); + dptr[j+2] = saturate_cast(ptr1[j+2]*alpha + ptr2[j+2]*beta); + dptr[j+3] = saturate_cast((1 - (1-alpha)*(1-beta))*alpha_scale); + } + } + } + @endcode + This approach, while being very simple, can boost the performance of a simple element-operation by + 10-20 percents, especially if the image is rather small and the operation is quite simple. + + Another OpenCV idiom in this function, a call of Mat::create for the destination array, that + allocates the destination array unless it already has the proper size and type. And while the newly + allocated arrays are always continuous, you still need to check the destination array because + Mat::create does not always allocate a new matrix. + */ + bool isContinuous() const; + + //! returns true if the matrix is a submatrix of another matrix + bool isSubmatrix() const; + + /** @brief Returns the matrix element size in bytes. + + The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , + the method returns 3\*sizeof(short) or 6. + */ + size_t elemSize() const; + + /** @brief Returns the size of each matrix element channel in bytes. + + The method returns the matrix element channel size in bytes, that is, it ignores the number of + channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2. + */ + size_t elemSize1() const; + + /** @brief Returns the type of a matrix element. + + The method returns a matrix element type. This is an identifier compatible with the CvMat type + system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. + */ + int type() const; + + /** @brief Returns the depth of a matrix element. + + The method returns the identifier of the matrix element depth (the type of each individual channel). + For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of + matrix types contains the following values: + - CV_8U - 8-bit unsigned integers ( 0..255 ) + - CV_8S - 8-bit signed integers ( -128..127 ) + - CV_16U - 16-bit unsigned integers ( 0..65535 ) + - CV_16S - 16-bit signed integers ( -32768..32767 ) + - CV_32S - 32-bit signed integers ( -2147483648..2147483647 ) + - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) + - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) + */ + int depth() const; + + /** @brief Returns the number of matrix channels. + + The method returns the number of matrix channels. + */ + int channels() const; + + /** @brief Returns a normalized step. + + The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an + arbitrary matrix element. + */ + size_t step1(int i=0) const; + + /** @brief Returns true if the array has no elements. + + The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and + resize() methods `M.total() == 0` does not imply that `M.data == NULL`. + */ + bool empty() const; + + /** @brief Returns the total number of array elements. + + The method returns the number of array elements (a number of pixels if the array represents an + image). + */ + size_t total() const; + + /** @brief Returns the total number of array elements. + + The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim + */ + size_t total(int startDim, int endDim=INT_MAX) const; + + /** + * @param elemChannels Number of channels or number of columns the matrix should have. + * For a 2-D matrix, when the matrix has only 1 column, then it should have + * elemChannels channels; When the matrix has only 1 channel, + * then it should have elemChannels columns. + * For a 3-D matrix, it should have only one channel. Furthermore, + * if the number of planes is not one, then the number of rows + * within every plane has to be 1; if the number of rows within + * every plane is not 1, then the number of planes has to be 1. + * @param depth The depth the matrix should have. Set it to -1 when any depth is fine. + * @param requireContinuous Set it to true to require the matrix to be continuous + * @return -1 if the requirement is not satisfied. + * Otherwise, it returns the number of elements in the matrix. Note + * that an element may have multiple channels. + * + * The following code demonstrates its usage for a 2-d matrix: + * @snippet snippets/core_mat_checkVector.cpp example-2d + * + * The following code demonstrates its usage for a 3-d matrix: + * @snippet snippets/core_mat_checkVector.cpp example-3d + */ + int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + + /** @brief Returns a pointer to the specified matrix row. + + The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + Mat::isContinuous to know how to use these methods. + @param i0 A 0-based row index. + */ + uchar* ptr(int i0=0); + /** @overload */ + const uchar* ptr(int i0=0) const; + + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + uchar* ptr(int row, int col); + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + const uchar* ptr(int row, int col) const; + + /** @overload */ + uchar* ptr(int i0, int i1, int i2); + /** @overload */ + const uchar* ptr(int i0, int i1, int i2) const; + + /** @overload */ + uchar* ptr(const int* idx); + /** @overload */ + const uchar* ptr(const int* idx) const; + /** @overload */ + template uchar* ptr(const Vec& idx); + /** @overload */ + template const uchar* ptr(const Vec& idx) const; + + /** @overload */ + template _Tp* ptr(int i0=0); + /** @overload */ + template const _Tp* ptr(int i0=0) const; + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template _Tp* ptr(int row, int col); + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template const _Tp* ptr(int row, int col) const; + /** @overload */ + template _Tp* ptr(int i0, int i1, int i2); + /** @overload */ + template const _Tp* ptr(int i0, int i1, int i2) const; + /** @overload */ + template _Tp* ptr(const int* idx); + /** @overload */ + template const _Tp* ptr(const int* idx) const; + /** @overload */ + template _Tp* ptr(const Vec& idx); + /** @overload */ + template const _Tp* ptr(const Vec& idx) const; + + /** @brief Returns a reference to the specified array element. + + The template methods return a reference to the specified array element. For the sake of higher + performance, the index range checks are only performed in the Debug configuration. + + Note that the variants with a single index (i) can be used to access elements of single-row or + single-column 2-dimensional arrays. That is, if, for example, A is a 1 x N floating-point matrix and + B is an M x 1 integer matrix, you can simply write `A.at(k+4)` and `B.at(2*i+1)` + instead of `A.at(0,k+4)` and `B.at(2*i+1,0)`, respectively. + + The example below initializes a Hilbert matrix: + @code + Mat H(100, 100, CV_64F); + for(int i = 0; i < H.rows; i++) + for(int j = 0; j < H.cols; j++) + H.at(i,j)=1./(i+j+1); + @endcode + + Keep in mind that the size identifier used in the at operator cannot be chosen at random. It depends + on the image from which you are trying to retrieve the data. The table below gives a better insight in this: + - If matrix is of type `CV_8U` then use `Mat.at(y,x)`. + - If matrix is of type `CV_8S` then use `Mat.at(y,x)`. + - If matrix is of type `CV_16U` then use `Mat.at(y,x)`. + - If matrix is of type `CV_16S` then use `Mat.at(y,x)`. + - If matrix is of type `CV_32S` then use `Mat.at(y,x)`. + - If matrix is of type `CV_32F` then use `Mat.at(y,x)`. + - If matrix is of type `CV_64F` then use `Mat.at(y,x)`. + + @param i0 Index along the dimension 0 + */ + template _Tp& at(int i0=0); + /** @overload + @param i0 Index along the dimension 0 + */ + template const _Tp& at(int i0=0) const; + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template _Tp& at(int row, int col); + /** @overload + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + template const _Tp& at(int row, int col) const; + + /** @overload + @param i0 Index along the dimension 0 + @param i1 Index along the dimension 1 + @param i2 Index along the dimension 2 + */ + template _Tp& at(int i0, int i1, int i2); + /** @overload + @param i0 Index along the dimension 0 + @param i1 Index along the dimension 1 + @param i2 Index along the dimension 2 + */ + template const _Tp& at(int i0, int i1, int i2) const; + + /** @overload + @param idx Array of Mat::dims indices. + */ + template _Tp& at(const int* idx); + /** @overload + @param idx Array of Mat::dims indices. + */ + template const _Tp& at(const int* idx) const; + + /** @overload */ + template _Tp& at(const Vec& idx); + /** @overload */ + template const _Tp& at(const Vec& idx) const; + + /** @overload + special versions for 2D arrays (especially convenient for referencing image pixels) + @param pt Element position specified as Point(j,i) . + */ + template _Tp& at(Point pt); + /** @overload + special versions for 2D arrays (especially convenient for referencing image pixels) + @param pt Element position specified as Point(j,i) . + */ + template const _Tp& at(Point pt) const; + + /** @brief Returns the matrix iterator and sets it to the first matrix element. + + The methods return the matrix read-only or read-write iterators. The use of matrix iterators is very + similar to the use of bi-directional STL iterators. In the example below, the alpha blending + function is rewritten using the matrix iterators: + @code + template + void alphaBlendRGBA(const Mat& src1, const Mat& src2, Mat& dst) + { + typedef Vec VT; + + const float alpha_scale = (float)std::numeric_limits::max(), + inv_scale = 1.f/alpha_scale; + + CV_Assert( src1.type() == src2.type() && + src1.type() == traits::Type::value && + src1.size() == src2.size()); + Size size = src1.size(); + dst.create(size, src1.type()); + + MatConstIterator_ it1 = src1.begin(), it1_end = src1.end(); + MatConstIterator_ it2 = src2.begin(); + MatIterator_ dst_it = dst.begin(); + + for( ; it1 != it1_end; ++it1, ++it2, ++dst_it ) + { + VT pix1 = *it1, pix2 = *it2; + float alpha = pix1[3]*inv_scale, beta = pix2[3]*inv_scale; + *dst_it = VT(saturate_cast(pix1[0]*alpha + pix2[0]*beta), + saturate_cast(pix1[1]*alpha + pix2[1]*beta), + saturate_cast(pix1[2]*alpha + pix2[2]*beta), + saturate_cast((1 - (1-alpha)*(1-beta))*alpha_scale)); + } + } + @endcode + */ + template MatIterator_<_Tp> begin(); + template MatConstIterator_<_Tp> begin() const; + + /** @brief Same as begin() but for inverse traversal + */ + template std::reverse_iterator> rbegin(); + template std::reverse_iterator> rbegin() const; + + /** @brief Returns the matrix iterator and sets it to the after-last matrix element. + + The methods return the matrix read-only or read-write iterators, set to the point following the last + matrix element. + */ + template MatIterator_<_Tp> end(); + template MatConstIterator_<_Tp> end() const; + + /** @brief Same as end() but for inverse traversal + */ + template std::reverse_iterator< MatIterator_<_Tp>> rend(); + template std::reverse_iterator< MatConstIterator_<_Tp>> rend() const; + + + /** @brief Runs the given functor over all matrix elements in parallel. + + The operation passed as argument has to be a function pointer, a function object or a lambda(C++11). + + Example 1. All of the operations below put 0xFF the first channel of all matrix elements: + @code + Mat image(1920, 1080, CV_8UC3); + typedef cv::Point3_ Pixel; + + // first. raw pointer access. + for (int r = 0; r < image.rows; ++r) { + Pixel* ptr = image.ptr(r, 0); + const Pixel* ptr_end = ptr + image.cols; + for (; ptr != ptr_end; ++ptr) { + ptr->x = 255; + } + } + + // Using MatIterator. (Simple but there are a Iterator's overhead) + for (Pixel &p : cv::Mat_(image)) { + p.x = 255; + } + + // Parallel execution with function object. + struct Operator { + void operator ()(Pixel &pixel, const int * position) { + pixel.x = 255; + } + }; + image.forEach(Operator()); + + // Parallel execution using C++11 lambda. + image.forEach([](Pixel &p, const int * position) -> void { + p.x = 255; + }); + @endcode + Example 2. Using the pixel's position: + @code + // Creating 3D matrix (255 x 255 x 255) typed uint8_t + // and initialize all elements by the value which equals elements position. + // i.e. pixels (x,y,z) = (1,2,3) is (b,g,r) = (1,2,3). + + int sizes[] = { 255, 255, 255 }; + typedef cv::Point3_ Pixel; + + Mat_ image = Mat::zeros(3, sizes, CV_8UC3); + + image.forEach([&](Pixel& pixel, const int position[]) -> void { + pixel.x = position[0]; + pixel.y = position[1]; + pixel.z = position[2]; + }); + @endcode + */ + template void forEach(const Functor& operation); + /** @overload */ + template void forEach(const Functor& operation) const; + + Mat(Mat&& m); + Mat& operator = (Mat&& m); + + enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; + enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + //! the matrix dimensionality, >= 2 + int dims; + //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + int rows, cols; + //! pointer to the data + uchar* data; + + //! helper fields used in locateROI and adjustROI + const uchar* datastart; + const uchar* dataend; + const uchar* datalimit; + + //! custom allocator + MatAllocator* allocator; + //! and the standard allocator + static MatAllocator* getStdAllocator(); + static MatAllocator* getDefaultAllocator(); + static void setDefaultAllocator(MatAllocator* allocator); + + //! internal use method: updates the continuity flag + void updateContinuityFlag(); + + //! interaction with UMat + UMatData* u; + + MatSize size; + MatStep step; + +protected: + template void forEach_impl(const Functor& operation); +}; + + +///////////////////////////////// Mat_<_Tp> //////////////////////////////////// + +/** @brief Template matrix class derived from Mat + +@code{.cpp} + template class Mat_ : public Mat + { + public: + // ... some specific methods + // and + // no new extra fields + }; +@endcode +The class `Mat_<_Tp>` is a *thin* template wrapper on top of the Mat class. It does not have any +extra data fields. Nor this class nor Mat has any virtual methods. Thus, references or pointers to +these two classes can be freely but carefully converted one to another. For example: +@code{.cpp} + // create a 100x100 8-bit matrix + Mat M(100,100,CV_8U); + // this will be compiled fine. no any data conversion will be done. + Mat_& M1 = (Mat_&)M; + // the program is likely to crash at the statement below + M1(99,99) = 1.f; +@endcode +While Mat is sufficient in most cases, Mat_ can be more convenient if you use a lot of element +access operations and if you know matrix type at the compilation time. Note that +`Mat::at(int y,int x)` and `Mat_::operator()(int y,int x)` do absolutely the same +and run at the same speed, but the latter is certainly shorter: +@code{.cpp} + Mat_ M(20,20); + for(int i = 0; i < M.rows; i++) + for(int j = 0; j < M.cols; j++) + M(i,j) = 1./(i+j+1); + Mat E, V; + eigen(M,E,V); + cout << E.at(0,0)/E.at(M.rows-1,0); +@endcode +To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter: +@code{.cpp} + // allocate a 320x240 color image and fill it with green (in RGB space) + Mat_ img(240, 320, Vec3b(0,255,0)); + // now draw a diagonal white line + for(int i = 0; i < 100; i++) + img(i,i)=Vec3b(255,255,255); + // and now scramble the 2nd (red) channel of each pixel + for(int i = 0; i < img.rows; i++) + for(int j = 0; j < img.cols; j++) + img(i,j)[2] ^= (uchar)(i ^ j); +@endcode +Mat_ is fully compatible with C++11 range-based for loop. For example such loop +can be used to safely apply look-up table: +@code{.cpp} +void applyTable(Mat_& I, const uchar* const table) +{ + for(auto& pixel : I) + { + pixel = table[pixel]; + } +} +@endcode + */ +template class Mat_ : public Mat +{ +public: + typedef _Tp value_type; + typedef typename DataType<_Tp>::channel_type channel_type; + typedef MatIterator_<_Tp> iterator; + typedef MatConstIterator_<_Tp> const_iterator; + + //! default constructor + Mat_() CV_NOEXCEPT; + //! equivalent to Mat(_rows, _cols, DataType<_Tp>::type) + Mat_(int _rows, int _cols); + //! constructor that sets each matrix element to specified value + Mat_(int _rows, int _cols, const _Tp& value); + //! equivalent to Mat(_size, DataType<_Tp>::type) + explicit Mat_(Size _size); + //! constructor that sets each matrix element to specified value + Mat_(Size _size, const _Tp& value); + //! n-dim array constructor + Mat_(int _ndims, const int* _sizes); + //! n-dim array constructor that sets each matrix element to specified value + Mat_(int _ndims, const int* _sizes, const _Tp& value); + //! copy/conversion constructor. If m is of different type, it's converted + Mat_(const Mat& m); + //! copy constructor + Mat_(const Mat_& m); + //! constructs a matrix on top of user-allocated data. step is in bytes(!!!), regardless of the type + Mat_(int _rows, int _cols, _Tp* _data, size_t _step=AUTO_STEP); + //! constructs n-dim matrix on top of user-allocated data. steps are in bytes(!!!), regardless of the type + Mat_(int _ndims, const int* _sizes, _Tp* _data, const size_t* _steps=0); + //! selects a submatrix + Mat_(const Mat_& m, const Range& rowRange, const Range& colRange=Range::all()); + //! selects a submatrix + Mat_(const Mat_& m, const Rect& roi); + //! selects a submatrix, n-dim version + Mat_(const Mat_& m, const Range* ranges); + //! selects a submatrix, n-dim version + Mat_(const Mat_& m, const std::vector& ranges); + //! from a matrix expression + explicit Mat_(const MatExpr& e); + //! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column + explicit Mat_(const std::vector<_Tp>& vec, bool copyData=false); + template explicit Mat_(const Vec::channel_type, n>& vec, bool copyData=true); + template explicit Mat_(const Matx::channel_type, m, n>& mtx, bool copyData=true); + explicit Mat_(const Point_::channel_type>& pt, bool copyData=true); + explicit Mat_(const Point3_::channel_type>& pt, bool copyData=true); + explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); + + Mat_(std::initializer_list<_Tp> values); + explicit Mat_(const std::initializer_list sizes, const std::initializer_list<_Tp> values); + + template explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false); + + Mat_& operator = (const Mat& m); + Mat_& operator = (const Mat_& m); + //! set all the elements to s. + Mat_& operator = (const _Tp& s); + //! assign a matrix expression + Mat_& operator = (const MatExpr& e); + + //! iterators; they are smart enough to skip gaps in the end of rows + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + + //reverse iterators + std::reverse_iterator rbegin(); + std::reverse_iterator rend(); + std::reverse_iterator rbegin() const; + std::reverse_iterator rend() const; + + //! template methods for for operation over all matrix elements. + // the operations take care of skipping gaps in the end of rows (if any) + template void forEach(const Functor& operation); + template void forEach(const Functor& operation) const; + + //! equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type) + void create(int _rows, int _cols); + //! equivalent to Mat::create(_size, DataType<_Tp>::type) + void create(Size _size); + //! equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type) + void create(int _ndims, const int* _sizes); + //! equivalent to Mat::release() + void release(); + //! cross-product + Mat_ cross(const Mat_& m) const; + //! data type conversion + template operator Mat_() const; + //! overridden forms of Mat::row() etc. + Mat_ row(int y) const; + Mat_ col(int x) const; + Mat_ diag(int d=0) const; + CV_NODISCARD_STD Mat_ clone() const; + + //! overridden forms of Mat::elemSize() etc. + size_t elemSize() const; + size_t elemSize1() const; + int type() const; + int depth() const; + int channels() const; + size_t step1(int i=0) const; + //! returns step()/sizeof(_Tp) + size_t stepT(int i=0) const; + + //! overridden forms of Mat::zeros() etc. Data type is omitted, of course + CV_NODISCARD_STD static MatExpr zeros(int rows, int cols); + CV_NODISCARD_STD static MatExpr zeros(Size size); + CV_NODISCARD_STD static MatExpr zeros(int _ndims, const int* _sizes); + CV_NODISCARD_STD static MatExpr ones(int rows, int cols); + CV_NODISCARD_STD static MatExpr ones(Size size); + CV_NODISCARD_STD static MatExpr ones(int _ndims, const int* _sizes); + CV_NODISCARD_STD static MatExpr eye(int rows, int cols); + CV_NODISCARD_STD static MatExpr eye(Size size); + + //! some more overridden methods + Mat_& adjustROI( int dtop, int dbottom, int dleft, int dright ); + Mat_ operator()( const Range& rowRange, const Range& colRange ) const; + Mat_ operator()( const Rect& roi ) const; + Mat_ operator()( const Range* ranges ) const; + Mat_ operator()(const std::vector& ranges) const; + + //! more convenient forms of row and element access operators + _Tp* operator [](int y); + const _Tp* operator [](int y) const; + + //! returns reference to the specified element + _Tp& operator ()(const int* idx); + //! returns read-only reference to the specified element + const _Tp& operator ()(const int* idx) const; + + //! returns reference to the specified element + template _Tp& operator ()(const Vec& idx); + //! returns read-only reference to the specified element + template const _Tp& operator ()(const Vec& idx) const; + + //! returns reference to the specified element (1D case) + _Tp& operator ()(int idx0); + //! returns read-only reference to the specified element (1D case) + const _Tp& operator ()(int idx0) const; + //! returns reference to the specified element (2D case) + _Tp& operator ()(int row, int col); + //! returns read-only reference to the specified element (2D case) + const _Tp& operator ()(int row, int col) const; + //! returns reference to the specified element (3D case) + _Tp& operator ()(int idx0, int idx1, int idx2); + //! returns read-only reference to the specified element (3D case) + const _Tp& operator ()(int idx0, int idx1, int idx2) const; + + _Tp& operator ()(Point pt); + const _Tp& operator ()(Point pt) const; + + //! conversion to vector. + operator std::vector<_Tp>() const; + + //! conversion to array. + template operator std::array<_Tp, _Nm>() const; + + //! conversion to Vec + template operator Vec::channel_type, n>() const; + //! conversion to Matx + template operator Matx::channel_type, m, n>() const; + + Mat_(Mat_&& m); + Mat_& operator = (Mat_&& m); + + Mat_(Mat&& m); + Mat_& operator = (Mat&& m); + + Mat_(MatExpr&& e); +}; + +typedef Mat_ Mat1b; +typedef Mat_ Mat2b; +typedef Mat_ Mat3b; +typedef Mat_ Mat4b; + +typedef Mat_ Mat1s; +typedef Mat_ Mat2s; +typedef Mat_ Mat3s; +typedef Mat_ Mat4s; + +typedef Mat_ Mat1w; +typedef Mat_ Mat2w; +typedef Mat_ Mat3w; +typedef Mat_ Mat4w; + +typedef Mat_ Mat1i; +typedef Mat_ Mat2i; +typedef Mat_ Mat3i; +typedef Mat_ Mat4i; + +typedef Mat_ Mat1f; +typedef Mat_ Mat2f; +typedef Mat_ Mat3f; +typedef Mat_ Mat4f; + +typedef Mat_ Mat1d; +typedef Mat_ Mat2d; +typedef Mat_ Mat3d; +typedef Mat_ Mat4d; + +/** @todo document */ +class CV_EXPORTS UMat +{ +public: + //! default constructor + UMat(UMatUsageFlags usageFlags = USAGE_DEFAULT) CV_NOEXCEPT; + //! constructs 2D matrix of the specified size and type + // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) + UMat(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + //! constructs 2D matrix and fills it with the specified value _s. + UMat(int rows, int cols, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(Size size, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + + //! constructs n-dimensional matrix + UMat(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + UMat(int ndims, const int* sizes, int type, const Scalar& s, UMatUsageFlags usageFlags = USAGE_DEFAULT); + + //! copy constructor + UMat(const UMat& m); + + //! creates a matrix header for a part of the bigger matrix + UMat(const UMat& m, const Range& rowRange, const Range& colRange=Range::all()); + UMat(const UMat& m, const Rect& roi); + UMat(const UMat& m, const Range* ranges); + UMat(const UMat& m, const std::vector& ranges); + + // FIXIT copyData=false is not implemented, drop this in favor of cv::Mat (OpenCV 5.0) + //! builds matrix from std::vector with or without copying the data + template explicit UMat(const std::vector<_Tp>& vec, bool copyData=false); + + //! destructor - calls release() + ~UMat(); + //! assignment operators + UMat& operator = (const UMat& m); + + Mat getMat(AccessFlag flags) const; + + //! returns a new matrix header for the specified row + UMat row(int y) const; + //! returns a new matrix header for the specified column + UMat col(int x) const; + //! ... for the specified row span + UMat rowRange(int startrow, int endrow) const; + UMat rowRange(const Range& r) const; + //! ... for the specified column span + UMat colRange(int startcol, int endcol) const; + UMat colRange(const Range& r) const; + //! ... for the specified diagonal + //! (d=0 - the main diagonal, + //! >0 - a diagonal from the upper half, + //! <0 - a diagonal from the lower half) + UMat diag(int d=0) const; + //! constructs a square diagonal matrix which main diagonal is vector "d" + CV_NODISCARD_STD static UMat diag(const UMat& d, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat diag(const UMat& d) { return diag(d, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + + //! returns deep copy of the matrix, i.e. the data is copied + CV_NODISCARD_STD UMat clone() const; + //! copies the matrix content to "m". + // It calls m.create(this->size(), this->type()). + void copyTo( OutputArray m ) const; + //! copies those matrix elements to "m" that are marked with non-zero mask elements. + void copyTo( OutputArray m, InputArray mask ) const; + //! converts matrix to another datatype with optional scaling. See cvConvertScale. + void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; + + void assignTo( UMat& m, int type=-1 ) const; + + //! sets every matrix element to s + UMat& operator = (const Scalar& s); + //! sets some of the matrix elements to s, according to the mask + UMat& setTo(InputArray value, InputArray mask=noArray()); + //! creates alternative matrix header for the same data, with different + // number of channels and/or different number of rows. see cvReshape. + UMat reshape(int cn, int rows=0) const; + UMat reshape(int cn, int newndims, const int* newsz) const; + + //! matrix transposition by means of matrix expressions + UMat t() const; + //! matrix inversion by means of matrix expressions + UMat inv(int method=DECOMP_LU) const; + //! per-element matrix multiplication by means of matrix expressions + UMat mul(InputArray m, double scale=1) const; + + //! computes dot-product + double dot(InputArray m) const; + + //! Matlab-style matrix initialization + CV_NODISCARD_STD static UMat zeros(int rows, int cols, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat zeros(Size size, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat zeros(int ndims, const int* sz, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat zeros(int rows, int cols, int type) { return zeros(rows, cols, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat zeros(Size size, int type) { return zeros(size, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat zeros(int ndims, const int* sz, int type) { return zeros(ndims, sz, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat ones(int rows, int cols, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat ones(Size size, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat ones(int ndims, const int* sz, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat ones(int rows, int cols, int type) { return ones(rows, cols, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat ones(Size size, int type) { return ones(size, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat ones(int ndims, const int* sz, int type) { return ones(ndims, sz, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat eye(int rows, int cols, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat eye(Size size, int type, UMatUsageFlags usageFlags /*= USAGE_DEFAULT*/); + CV_NODISCARD_STD static UMat eye(int rows, int cols, int type) { return eye(rows, cols, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + CV_NODISCARD_STD static UMat eye(Size size, int type) { return eye(size, type, USAGE_DEFAULT); } // OpenCV 5.0: remove abi compatibility overload + + //! allocates new matrix data unless the matrix already has specified size and type. + // previous data is unreferenced if needed. + void create(int rows, int cols, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(Size size, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(int ndims, const int* sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + void create(const std::vector& sizes, int type, UMatUsageFlags usageFlags = USAGE_DEFAULT); + + //! increases the reference counter; use with care to avoid memleaks + void addref(); + //! decreases reference counter; + // deallocates the data when reference counter reaches 0. + void release(); + + //! deallocates the matrix data + void deallocate(); + //! internal use function; properly re-allocates _size, _step arrays + void copySize(const UMat& m); + + //! locates matrix header within a parent matrix. See below + void locateROI( Size& wholeSize, Point& ofs ) const; + //! moves/resizes the current matrix ROI inside the parent matrix. + UMat& adjustROI( int dtop, int dbottom, int dleft, int dright ); + //! extracts a rectangular sub-matrix + // (this is a generalized form of row, rowRange etc.) + UMat operator()( Range rowRange, Range colRange ) const; + UMat operator()( const Rect& roi ) const; + UMat operator()( const Range* ranges ) const; + UMat operator()(const std::vector& ranges) const; + + //! returns true iff the matrix data is continuous + // (i.e. when there are no gaps between successive rows). + // similar to CV_IS_MAT_CONT(cvmat->type) + bool isContinuous() const; + + //! returns true if the matrix is a submatrix of another matrix + bool isSubmatrix() const; + + //! returns element size in bytes, + // similar to CV_ELEM_SIZE(cvmat->type) + size_t elemSize() const; + //! returns the size of element channel in bytes. + size_t elemSize1() const; + //! returns element type, similar to CV_MAT_TYPE(cvmat->type) + int type() const; + //! returns element type, similar to CV_MAT_DEPTH(cvmat->type) + int depth() const; + //! returns element type, similar to CV_MAT_CN(cvmat->type) + int channels() const; + //! returns step/elemSize1() + size_t step1(int i=0) const; + //! returns true if matrix data is NULL + bool empty() const; + //! returns the total number of matrix elements + size_t total() const; + + //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise + int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; + + UMat(UMat&& m); + UMat& operator = (UMat&& m); + + /*! Returns the OpenCL buffer handle on which UMat operates on. + The UMat instance should be kept alive during the use of the handle to prevent the buffer to be + returned to the OpenCV buffer pool. + */ + void* handle(AccessFlag accessFlags) const; + void ndoffset(size_t* ofs) const; + + enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG }; + enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 }; + + /*! includes several bit-fields: + - the magic signature + - continuity flag + - depth + - number of channels + */ + int flags; + + //! the matrix dimensionality, >= 2 + int dims; + + //! number of rows in the matrix; -1 when the matrix has more than 2 dimensions + int rows; + + //! number of columns in the matrix; -1 when the matrix has more than 2 dimensions + int cols; + + //! custom allocator + MatAllocator* allocator; + + //! usage flags for allocator; recommend do not set directly, instead set during construct/create/getUMat + UMatUsageFlags usageFlags; + + //! and the standard allocator + static MatAllocator* getStdAllocator(); + + //! internal use method: updates the continuity flag + void updateContinuityFlag(); + + //! black-box container of UMat data + UMatData* u; + + //! offset of the submatrix (or 0) + size_t offset; + + //! dimensional size of the matrix; accessible in various formats + MatSize size; + + //! number of bytes each matrix element/row/plane/dimension occupies + MatStep step; + +protected: +}; + + +/////////////////////////// multi-dimensional sparse matrix ////////////////////////// + +/** @brief The class SparseMat represents multi-dimensional sparse numerical arrays. + +Such a sparse array can store elements of any type that Mat can store. *Sparse* means that only +non-zero elements are stored (though, as a result of operations on a sparse matrix, some of its +stored elements can actually become 0. It is up to you to detect such elements and delete them +using SparseMat::erase ). The non-zero elements are stored in a hash table that grows when it is +filled so that the search time is O(1) in average (regardless of whether element is there or not). +Elements can be accessed using the following methods: +- Query operations (SparseMat::ptr and the higher-level SparseMat::ref, SparseMat::value and + SparseMat::find), for example: + @code + const int dims = 5; + int size[5] = {10, 10, 10, 10, 10}; + SparseMat sparse_mat(dims, size, CV_32F); + for(int i = 0; i < 1000; i++) + { + int idx[dims]; + for(int k = 0; k < dims; k++) + idx[k] = rand() % size[k]; + sparse_mat.ref(idx) += 1.f; + } + cout << "nnz = " << sparse_mat.nzcount() << endl; + @endcode +- Sparse matrix iterators. They are similar to MatIterator but different from NAryMatIterator. + That is, the iteration loop is familiar to STL users: + @code + // prints elements of a sparse floating-point matrix + // and the sum of elements. + SparseMatConstIterator_ + it = sparse_mat.begin(), + it_end = sparse_mat.end(); + double s = 0; + int dims = sparse_mat.dims(); + for(; it != it_end; ++it) + { + // print element indices and the element value + const SparseMat::Node* n = it.node(); + printf("("); + for(int i = 0; i < dims; i++) + printf("%d%s", n->idx[i], i < dims-1 ? ", " : ")"); + printf(": %g\n", it.value()); + s += *it; + } + printf("Element sum is %g\n", s); + @endcode + If you run this loop, you will notice that elements are not enumerated in a logical order + (lexicographical, and so on). They come in the same order as they are stored in the hash table + (semi-randomly). You may collect pointers to the nodes and sort them to get the proper ordering. + Note, however, that pointers to the nodes may become invalid when you add more elements to the + matrix. This may happen due to possible buffer reallocation. +- Combination of the above 2 methods when you need to process 2 or more sparse matrices + simultaneously. For example, this is how you can compute unnormalized cross-correlation of the 2 + floating-point sparse matrices: + @code + double cross_corr(const SparseMat& a, const SparseMat& b) + { + const SparseMat *_a = &a, *_b = &b; + // if b contains less elements than a, + // it is faster to iterate through b + if(_a->nzcount() > _b->nzcount()) + std::swap(_a, _b); + SparseMatConstIterator_ it = _a->begin(), + it_end = _a->end(); + double ccorr = 0; + for(; it != it_end; ++it) + { + // take the next element from the first matrix + float avalue = *it; + const Node* anode = it.node(); + // and try to find an element with the same index in the second matrix. + // since the hash value depends only on the element index, + // reuse the hash value stored in the node + float bvalue = _b->value(anode->idx,&anode->hashval); + ccorr += avalue*bvalue; + } + return ccorr; + } + @endcode + */ +class CV_EXPORTS SparseMat +{ +public: + typedef SparseMatIterator iterator; + typedef SparseMatConstIterator const_iterator; + + enum { MAGIC_VAL=0x42FD0000, MAX_DIM=32, HASH_SCALE=0x5bd1e995, HASH_BIT=0x80000000 }; + + //! the sparse matrix header + struct CV_EXPORTS Hdr + { + Hdr(int _dims, const int* _sizes, int _type); + void clear(); + int refcount; + int dims; + int valueOffset; + size_t nodeSize; + size_t nodeCount; + size_t freeList; + std::vector pool; + std::vector hashtab; + int size[MAX_DIM]; + }; + + //! sparse matrix node - element of a hash table + struct CV_EXPORTS Node + { + //! hash value + size_t hashval; + //! index of the next node in the same hash table entry + size_t next; + //! index of the matrix element + int idx[MAX_DIM]; + }; + + /** @brief Various SparseMat constructors. + */ + SparseMat(); + + /** @overload + @param dims Array dimensionality. + @param _sizes Sparce matrix size on all dementions. + @param _type Sparse matrix data type. + */ + SparseMat(int dims, const int* _sizes, int _type); + + /** @overload + @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted + to sparse representation. + */ + SparseMat(const SparseMat& m); + + /** @overload + @param m Source matrix for copy constructor. If m is dense matrix (ocvMat) then it will be converted + to sparse representation. + */ + explicit SparseMat(const Mat& m); + + //! the destructor + ~SparseMat(); + + //! assignment operator. This is O(1) operation, i.e. no data is copied + SparseMat& operator = (const SparseMat& m); + //! equivalent to the corresponding constructor + SparseMat& operator = (const Mat& m); + + //! creates full copy of the matrix + CV_NODISCARD_STD SparseMat clone() const; + + //! copies all the data to the destination matrix. All the previous content of m is erased + void copyTo( SparseMat& m ) const; + //! converts sparse matrix to dense matrix. + void copyTo( Mat& m ) const; + //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type + void convertTo( SparseMat& m, int rtype, double alpha=1 ) const; + //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. + /*! + @param [out] m - output matrix; if it does not have a proper size or type before the operation, + it is reallocated + @param [in] rtype - desired output matrix type or, rather, the depth since the number of channels + are the same as the input has; if rtype is negative, the output matrix will have the + same type as the input. + @param [in] alpha - optional scale factor + @param [in] beta - optional delta added to the scaled values + */ + void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const; + + // not used now + void assignTo( SparseMat& m, int type=-1 ) const; + + //! reallocates sparse matrix. + /*! + If the matrix already had the proper size and type, + it is simply cleared with clear(), otherwise, + the old matrix is released (using release()) and the new one is allocated. + */ + void create(int dims, const int* _sizes, int _type); + //! sets all the sparse matrix elements to 0, which means clearing the hash table. + void clear(); + //! manually increments the reference counter to the header. + void addref(); + // decrements the header reference counter. When the counter reaches 0, the header and all the underlying data are deallocated. + void release(); + + //! converts sparse matrix to the old-style representation; all the elements are copied. + //operator CvSparseMat*() const; + //! returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements) + size_t elemSize() const; + //! returns elemSize()/channels() + size_t elemSize1() const; + + //! returns type of sparse matrix elements + int type() const; + //! returns the depth of sparse matrix elements + int depth() const; + //! returns the number of channels + int channels() const; + + //! returns the array of sizes, or NULL if the matrix is not allocated + const int* size() const; + //! returns the size of i-th matrix dimension (or 0) + int size(int i) const; + //! returns the matrix dimensionality + int dims() const; + //! returns the number of non-zero elements (=the number of hash table nodes) + size_t nzcount() const; + + //! computes the element hash value (1D case) + size_t hash(int i0) const; + //! computes the element hash value (2D case) + size_t hash(int i0, int i1) const; + //! computes the element hash value (3D case) + size_t hash(int i0, int i1, int i2) const; + //! computes the element hash value (nD case) + size_t hash(const int* idx) const; + + //!@{ + /*! + specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case. + return pointer to the matrix element. + - if the element is there (it's non-zero), the pointer to it is returned + - if it's not there and createMissing=false, NULL pointer is returned + - if it's not there and createMissing=true, then the new element + is created and initialized with 0. Pointer to it is returned + - if the optional hashval pointer is not NULL, the element hash value is + not computed, but *hashval is taken instead. + */ + //! returns pointer to the specified element (1D case) + uchar* ptr(int i0, bool createMissing, size_t* hashval=0); + //! returns pointer to the specified element (2D case) + uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0); + //! returns pointer to the specified element (3D case) + uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0); + //! returns pointer to the specified element (nD case) + uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0); + //!@} + + //!@{ + /*! + return read-write reference to the specified sparse matrix element. + + `ref<_Tp>(i0,...[,hashval])` is equivalent to `*(_Tp*)ptr(i0,...,true[,hashval])`. + The methods always return a valid reference. + If the element did not exist, it is created and initialized with 0. + */ + //! returns reference to the specified element (1D case) + template _Tp& ref(int i0, size_t* hashval=0); + //! returns reference to the specified element (2D case) + template _Tp& ref(int i0, int i1, size_t* hashval=0); + //! returns reference to the specified element (3D case) + template _Tp& ref(int i0, int i1, int i2, size_t* hashval=0); + //! returns reference to the specified element (nD case) + template _Tp& ref(const int* idx, size_t* hashval=0); + //!@} + + //!@{ + /*! + return value of the specified sparse matrix element. + + `value<_Tp>(i0,...[,hashval])` is equivalent to + @code + { const _Tp* p = find<_Tp>(i0,...[,hashval]); return p ? *p : _Tp(); } + @endcode + + That is, if the element did not exist, the methods return 0. + */ + //! returns value of the specified element (1D case) + template _Tp value(int i0, size_t* hashval=0) const; + //! returns value of the specified element (2D case) + template _Tp value(int i0, int i1, size_t* hashval=0) const; + //! returns value of the specified element (3D case) + template _Tp value(int i0, int i1, int i2, size_t* hashval=0) const; + //! returns value of the specified element (nD case) + template _Tp value(const int* idx, size_t* hashval=0) const; + //!@} + + //!@{ + /*! + Return pointer to the specified sparse matrix element if it exists + + `find<_Tp>(i0,...[,hashval])` is equivalent to `(_const Tp*)ptr(i0,...false[,hashval])`. + + If the specified element does not exist, the methods return NULL. + */ + //! returns pointer to the specified element (1D case) + template const _Tp* find(int i0, size_t* hashval=0) const; + //! returns pointer to the specified element (2D case) + template const _Tp* find(int i0, int i1, size_t* hashval=0) const; + //! returns pointer to the specified element (3D case) + template const _Tp* find(int i0, int i1, int i2, size_t* hashval=0) const; + //! returns pointer to the specified element (nD case) + template const _Tp* find(const int* idx, size_t* hashval=0) const; + //!@} + + //! erases the specified element (2D case) + void erase(int i0, int i1, size_t* hashval=0); + //! erases the specified element (3D case) + void erase(int i0, int i1, int i2, size_t* hashval=0); + //! erases the specified element (nD case) + void erase(const int* idx, size_t* hashval=0); + + //!@{ + /*! + return the sparse matrix iterator pointing to the first sparse matrix element + */ + //! returns the sparse matrix iterator at the matrix beginning + SparseMatIterator begin(); + //! returns the sparse matrix iterator at the matrix beginning + template SparseMatIterator_<_Tp> begin(); + //! returns the read-only sparse matrix iterator at the matrix beginning + SparseMatConstIterator begin() const; + //! returns the read-only sparse matrix iterator at the matrix beginning + template SparseMatConstIterator_<_Tp> begin() const; + //!@} + /*! + return the sparse matrix iterator pointing to the element following the last sparse matrix element + */ + //! returns the sparse matrix iterator at the matrix end + SparseMatIterator end(); + //! returns the read-only sparse matrix iterator at the matrix end + SparseMatConstIterator end() const; + //! returns the typed sparse matrix iterator at the matrix end + template SparseMatIterator_<_Tp> end(); + //! returns the typed read-only sparse matrix iterator at the matrix end + template SparseMatConstIterator_<_Tp> end() const; + + //! returns the value stored in the sparse martix node + template _Tp& value(Node* n); + //! returns the value stored in the sparse martix node + template const _Tp& value(const Node* n) const; + + ////////////// some internal-use methods /////////////// + Node* node(size_t nidx); + const Node* node(size_t nidx) const; + + uchar* newNode(const int* idx, size_t hashval); + void removeNode(size_t hidx, size_t nidx, size_t previdx); + void resizeHashTab(size_t newsize); + + int flags; + Hdr* hdr; +}; + + + +///////////////////////////////// SparseMat_<_Tp> //////////////////////////////////// + +/** @brief Template sparse n-dimensional array class derived from SparseMat + +SparseMat_ is a thin wrapper on top of SparseMat created in the same way as Mat_ . It simplifies +notation of some operations: +@code + int sz[] = {10, 20, 30}; + SparseMat_ M(3, sz); + ... + M.ref(1, 2, 3) = M(4, 5, 6) + M(7, 8, 9); +@endcode + */ +template class SparseMat_ : public SparseMat +{ +public: + typedef SparseMatIterator_<_Tp> iterator; + typedef SparseMatConstIterator_<_Tp> const_iterator; + + //! the default constructor + SparseMat_(); + //! the full constructor equivalent to SparseMat(dims, _sizes, DataType<_Tp>::type) + SparseMat_(int dims, const int* _sizes); + //! the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted + SparseMat_(const SparseMat& m); + //! the copy constructor. This is O(1) operation - no data is copied + SparseMat_(const SparseMat_& m); + //! converts dense matrix to the sparse form + SparseMat_(const Mat& m); + //! converts the old-style sparse matrix to the C++ class. All the elements are copied + //SparseMat_(const CvSparseMat* m); + //! the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted + SparseMat_& operator = (const SparseMat& m); + //! the assignment operator. This is O(1) operation - no data is copied + SparseMat_& operator = (const SparseMat_& m); + //! converts dense matrix to the sparse form + SparseMat_& operator = (const Mat& m); + + //! makes full copy of the matrix. All the elements are duplicated + CV_NODISCARD_STD SparseMat_ clone() const; + //! equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type) + void create(int dims, const int* _sizes); + //! converts sparse matrix to the old-style CvSparseMat. All the elements are copied + //operator CvSparseMat*() const; + + //! returns type of the matrix elements + int type() const; + //! returns depth of the matrix elements + int depth() const; + //! returns the number of channels in each matrix element + int channels() const; + + //! equivalent to SparseMat::ref<_Tp>(i0, hashval) + _Tp& ref(int i0, size_t* hashval=0); + //! equivalent to SparseMat::ref<_Tp>(i0, i1, hashval) + _Tp& ref(int i0, int i1, size_t* hashval=0); + //! equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval) + _Tp& ref(int i0, int i1, int i2, size_t* hashval=0); + //! equivalent to SparseMat::ref<_Tp>(idx, hashval) + _Tp& ref(const int* idx, size_t* hashval=0); + + //! equivalent to SparseMat::value<_Tp>(i0, hashval) + _Tp operator()(int i0, size_t* hashval=0) const; + //! equivalent to SparseMat::value<_Tp>(i0, i1, hashval) + _Tp operator()(int i0, int i1, size_t* hashval=0) const; + //! equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval) + _Tp operator()(int i0, int i1, int i2, size_t* hashval=0) const; + //! equivalent to SparseMat::value<_Tp>(idx, hashval) + _Tp operator()(const int* idx, size_t* hashval=0) const; + + //! returns sparse matrix iterator pointing to the first sparse matrix element + SparseMatIterator_<_Tp> begin(); + //! returns read-only sparse matrix iterator pointing to the first sparse matrix element + SparseMatConstIterator_<_Tp> begin() const; + //! returns sparse matrix iterator pointing to the element following the last sparse matrix element + SparseMatIterator_<_Tp> end(); + //! returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element + SparseMatConstIterator_<_Tp> end() const; +}; + + + +////////////////////////////////// MatConstIterator ////////////////////////////////// + +class CV_EXPORTS MatConstIterator +{ +public: + typedef uchar* value_type; + typedef ptrdiff_t difference_type; + typedef const uchar** pointer; + typedef uchar* reference; + + typedef std::random_access_iterator_tag iterator_category; + + //! default constructor + MatConstIterator(); + //! constructor that sets the iterator to the beginning of the matrix + MatConstIterator(const Mat* _m); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator(const Mat* _m, int _row, int _col=0); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator(const Mat* _m, Point _pt); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator(const Mat* _m, const int* _idx); + //! copy constructor + MatConstIterator(const MatConstIterator& it); + + //! copy operator + MatConstIterator& operator = (const MatConstIterator& it); + //! returns the current matrix element + const uchar* operator *() const; + //! returns the i-th matrix element, relative to the current + const uchar* operator [](ptrdiff_t i) const; + + //! shifts the iterator forward by the specified number of elements + MatConstIterator& operator += (ptrdiff_t ofs); + //! shifts the iterator backward by the specified number of elements + MatConstIterator& operator -= (ptrdiff_t ofs); + //! decrements the iterator + MatConstIterator& operator --(); + //! decrements the iterator + MatConstIterator operator --(int); + //! increments the iterator + MatConstIterator& operator ++(); + //! increments the iterator + MatConstIterator operator ++(int); + //! returns the current iterator position + Point pos() const; + //! returns the current iterator position + void pos(int* _idx) const; + + ptrdiff_t lpos() const; + void seek(ptrdiff_t ofs, bool relative = false); + void seek(const int* _idx, bool relative = false); + + const Mat* m; + size_t elemSize; + const uchar* ptr; + const uchar* sliceStart; + const uchar* sliceEnd; +}; + + + +////////////////////////////////// MatConstIterator_ ///////////////////////////////// + +/** @brief Matrix read-only iterator + */ +template +class MatConstIterator_ : public MatConstIterator +{ +public: + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + + typedef std::random_access_iterator_tag iterator_category; + + //! default constructor + MatConstIterator_(); + //! constructor that sets the iterator to the beginning of the matrix + MatConstIterator_(const Mat_<_Tp>* _m); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col=0); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator_(const Mat_<_Tp>* _m, Point _pt); + //! constructor that sets the iterator to the specified element of the matrix + MatConstIterator_(const Mat_<_Tp>* _m, const int* _idx); + //! copy constructor + MatConstIterator_(const MatConstIterator_& it); + + //! copy operator + MatConstIterator_& operator = (const MatConstIterator_& it); + //! returns the current matrix element + const _Tp& operator *() const; + //! returns the i-th matrix element, relative to the current + const _Tp& operator [](ptrdiff_t i) const; + + //! shifts the iterator forward by the specified number of elements + MatConstIterator_& operator += (ptrdiff_t ofs); + //! shifts the iterator backward by the specified number of elements + MatConstIterator_& operator -= (ptrdiff_t ofs); + //! decrements the iterator + MatConstIterator_& operator --(); + //! decrements the iterator + MatConstIterator_ operator --(int); + //! increments the iterator + MatConstIterator_& operator ++(); + //! increments the iterator + MatConstIterator_ operator ++(int); + //! returns the current iterator position + Point pos() const; +}; + + + +//////////////////////////////////// MatIterator_ //////////////////////////////////// + +/** @brief Matrix read-write iterator +*/ +template +class MatIterator_ : public MatConstIterator_<_Tp> +{ +public: + typedef _Tp* pointer; + typedef _Tp& reference; + + typedef std::random_access_iterator_tag iterator_category; + + //! the default constructor + MatIterator_(); + //! constructor that sets the iterator to the beginning of the matrix + MatIterator_(Mat_<_Tp>* _m); + //! constructor that sets the iterator to the specified element of the matrix + MatIterator_(Mat_<_Tp>* _m, int _row, int _col=0); + //! constructor that sets the iterator to the specified element of the matrix + MatIterator_(Mat_<_Tp>* _m, Point _pt); + //! constructor that sets the iterator to the specified element of the matrix + MatIterator_(Mat_<_Tp>* _m, const int* _idx); + //! copy constructor + MatIterator_(const MatIterator_& it); + //! copy operator + MatIterator_& operator = (const MatIterator_<_Tp>& it ); + + //! returns the current matrix element + _Tp& operator *() const; + //! returns the i-th matrix element, relative to the current + _Tp& operator [](ptrdiff_t i) const; + + //! shifts the iterator forward by the specified number of elements + MatIterator_& operator += (ptrdiff_t ofs); + //! shifts the iterator backward by the specified number of elements + MatIterator_& operator -= (ptrdiff_t ofs); + //! decrements the iterator + MatIterator_& operator --(); + //! decrements the iterator + MatIterator_ operator --(int); + //! increments the iterator + MatIterator_& operator ++(); + //! increments the iterator + MatIterator_ operator ++(int); +}; + + + +/////////////////////////////// SparseMatConstIterator /////////////////////////////// + +/** @brief Read-Only Sparse Matrix Iterator. + + Here is how to use the iterator to compute the sum of floating-point sparse matrix elements: + + \code + SparseMatConstIterator it = m.begin(), it_end = m.end(); + double s = 0; + CV_Assert( m.type() == CV_32F ); + for( ; it != it_end; ++it ) + s += it.value(); + \endcode +*/ +class CV_EXPORTS SparseMatConstIterator +{ +public: + //! the default constructor + SparseMatConstIterator(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatConstIterator(const SparseMat* _m); + //! the copy constructor + SparseMatConstIterator(const SparseMatConstIterator& it); + + //! the assignment operator + SparseMatConstIterator& operator = (const SparseMatConstIterator& it); + + //! template method returning the current matrix element + template const _Tp& value() const; + //! returns the current node of the sparse matrix. it.node->idx is the current element index + const SparseMat::Node* node() const; + + //! moves iterator to the previous element + SparseMatConstIterator& operator --(); + //! moves iterator to the previous element + SparseMatConstIterator operator --(int); + //! moves iterator to the next element + SparseMatConstIterator& operator ++(); + //! moves iterator to the next element + SparseMatConstIterator operator ++(int); + + //! moves iterator to the element after the last element + void seekEnd(); + + const SparseMat* m; + size_t hashidx; + uchar* ptr; +}; + + + +////////////////////////////////// SparseMatIterator ///////////////////////////////// + +/** @brief Read-write Sparse Matrix Iterator + + The class is similar to cv::SparseMatConstIterator, + but can be used for in-place modification of the matrix elements. +*/ +class CV_EXPORTS SparseMatIterator : public SparseMatConstIterator +{ +public: + //! the default constructor + SparseMatIterator(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatIterator(SparseMat* _m); + //! the full constructor setting the iterator to the specified sparse matrix element + SparseMatIterator(SparseMat* _m, const int* idx); + //! the copy constructor + SparseMatIterator(const SparseMatIterator& it); + + //! the assignment operator + SparseMatIterator& operator = (const SparseMatIterator& it); + //! returns read-write reference to the current sparse matrix element + template _Tp& value() const; + //! returns pointer to the current sparse matrix node. it.node->idx is the index of the current element (do not modify it!) + SparseMat::Node* node() const; + + //! moves iterator to the next element + SparseMatIterator& operator ++(); + //! moves iterator to the next element + SparseMatIterator operator ++(int); +}; + + + +/////////////////////////////// SparseMatConstIterator_ ////////////////////////////// + +/** @brief Template Read-Only Sparse Matrix Iterator Class. + + This is the derived from SparseMatConstIterator class that + introduces more convenient operator *() for accessing the current element. +*/ +template class SparseMatConstIterator_ : public SparseMatConstIterator +{ +public: + + typedef std::forward_iterator_tag iterator_category; + + //! the default constructor + SparseMatConstIterator_(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatConstIterator_(const SparseMat_<_Tp>* _m); + SparseMatConstIterator_(const SparseMat* _m); + //! the copy constructor + SparseMatConstIterator_(const SparseMatConstIterator_& it); + + //! the assignment operator + SparseMatConstIterator_& operator = (const SparseMatConstIterator_& it); + //! the element access operator + const _Tp& operator *() const; + + //! moves iterator to the next element + SparseMatConstIterator_& operator ++(); + //! moves iterator to the next element + SparseMatConstIterator_ operator ++(int); +}; + + + +///////////////////////////////// SparseMatIterator_ ///////////////////////////////// + +/** @brief Template Read-Write Sparse Matrix Iterator Class. + + This is the derived from cv::SparseMatConstIterator_ class that + introduces more convenient operator *() for accessing the current element. +*/ +template class SparseMatIterator_ : public SparseMatConstIterator_<_Tp> +{ +public: + + typedef std::forward_iterator_tag iterator_category; + + //! the default constructor + SparseMatIterator_(); + //! the full constructor setting the iterator to the first sparse matrix element + SparseMatIterator_(SparseMat_<_Tp>* _m); + SparseMatIterator_(SparseMat* _m); + //! the copy constructor + SparseMatIterator_(const SparseMatIterator_& it); + + //! the assignment operator + SparseMatIterator_& operator = (const SparseMatIterator_& it); + //! returns the reference to the current element + _Tp& operator *() const; + + //! moves the iterator to the next element + SparseMatIterator_& operator ++(); + //! moves the iterator to the next element + SparseMatIterator_ operator ++(int); +}; + + + +/////////////////////////////////// NAryMatIterator ////////////////////////////////// + +/** @brief n-ary multi-dimensional array iterator. + +Use the class to implement unary, binary, and, generally, n-ary element-wise operations on +multi-dimensional arrays. Some of the arguments of an n-ary function may be continuous arrays, some +may be not. It is possible to use conventional MatIterator 's for each array but incrementing all of +the iterators after each small operations may be a big overhead. In this case consider using +NAryMatIterator to iterate through several matrices simultaneously as long as they have the same +geometry (dimensionality and all the dimension sizes are the same). On each iteration `it.planes[0]`, +`it.planes[1]`,... will be the slices of the corresponding matrices. + +The example below illustrates how you can compute a normalized and threshold 3D color histogram: +@code + void computeNormalizedColorHist(const Mat& image, Mat& hist, int N, double minProb) + { + const int histSize[] = {N, N, N}; + + // make sure that the histogram has a proper size and type + hist.create(3, histSize, CV_32F); + + // and clear it + hist = Scalar(0); + + // the loop below assumes that the image + // is a 8-bit 3-channel. check it. + CV_Assert(image.type() == CV_8UC3); + MatConstIterator_ it = image.begin(), + it_end = image.end(); + for( ; it != it_end; ++it ) + { + const Vec3b& pix = *it; + hist.at(pix[0]*N/256, pix[1]*N/256, pix[2]*N/256) += 1.f; + } + + minProb *= image.rows*image.cols; + + // initialize iterator (the style is different from STL). + // after initialization the iterator will contain + // the number of slices or planes the iterator will go through. + // it simultaneously increments iterators for several matrices + // supplied as a null terminated list of pointers + const Mat* arrays[] = {&hist, 0}; + Mat planes[1]; + NAryMatIterator itNAry(arrays, planes, 1); + double s = 0; + // iterate through the matrix. on each iteration + // itNAry.planes[i] (of type Mat) will be set to the current plane + // of the i-th n-dim matrix passed to the iterator constructor. + for(int p = 0; p < itNAry.nplanes; p++, ++itNAry) + { + threshold(itNAry.planes[0], itNAry.planes[0], minProb, 0, THRESH_TOZERO); + s += sum(itNAry.planes[0])[0]; + } + + s = 1./s; + itNAry = NAryMatIterator(arrays, planes, 1); + for(int p = 0; p < itNAry.nplanes; p++, ++itNAry) + itNAry.planes[0] *= s; + } +@endcode + */ +class CV_EXPORTS NAryMatIterator +{ +public: + //! the default constructor + NAryMatIterator(); + //! the full constructor taking arbitrary number of n-dim matrices + NAryMatIterator(const Mat** arrays, uchar** ptrs, int narrays=-1); + //! the full constructor taking arbitrary number of n-dim matrices + NAryMatIterator(const Mat** arrays, Mat* planes, int narrays=-1); + //! the separate iterator initialization method + void init(const Mat** arrays, Mat* planes, uchar** ptrs, int narrays=-1); + + //! proceeds to the next plane of every iterated matrix + NAryMatIterator& operator ++(); + //! proceeds to the next plane of every iterated matrix (postfix increment operator) + NAryMatIterator operator ++(int); + + //! the iterated arrays + const Mat** arrays; + //! the current planes + Mat* planes; + //! data pointers + uchar** ptrs; + //! the number of arrays + int narrays; + //! the number of hyper-planes that the iterator steps through + size_t nplanes; + //! the size of each segment (in elements) + size_t size; +protected: + int iterdepth; + size_t idx; +}; + + + +///////////////////////////////// Matrix Expressions ///////////////////////////////// + +class CV_EXPORTS MatOp +{ +public: + MatOp(); + virtual ~MatOp(); + + virtual bool elementWise(const MatExpr& expr) const; + virtual void assign(const MatExpr& expr, Mat& m, int type=-1) const = 0; + virtual void roi(const MatExpr& expr, const Range& rowRange, + const Range& colRange, MatExpr& res) const; + virtual void diag(const MatExpr& expr, int d, MatExpr& res) const; + virtual void augAssignAdd(const MatExpr& expr, Mat& m) const; + virtual void augAssignSubtract(const MatExpr& expr, Mat& m) const; + virtual void augAssignMultiply(const MatExpr& expr, Mat& m) const; + virtual void augAssignDivide(const MatExpr& expr, Mat& m) const; + virtual void augAssignAnd(const MatExpr& expr, Mat& m) const; + virtual void augAssignOr(const MatExpr& expr, Mat& m) const; + virtual void augAssignXor(const MatExpr& expr, Mat& m) const; + + virtual void add(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; + virtual void add(const MatExpr& expr1, const Scalar& s, MatExpr& res) const; + + virtual void subtract(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; + virtual void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const; + + virtual void multiply(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const; + virtual void multiply(const MatExpr& expr1, double s, MatExpr& res) const; + + virtual void divide(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const; + virtual void divide(double s, const MatExpr& expr, MatExpr& res) const; + + virtual void abs(const MatExpr& expr, MatExpr& res) const; + + virtual void transpose(const MatExpr& expr, MatExpr& res) const; + virtual void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; + virtual void invert(const MatExpr& expr, int method, MatExpr& res) const; + + virtual Size size(const MatExpr& expr) const; + virtual int type(const MatExpr& expr) const; +}; + +/** @brief Matrix expression representation +@anchor MatrixExpressions +This is a list of implemented matrix operations that can be combined in arbitrary complex +expressions (here A, B stand for matrices ( Mat ), s for a scalar ( Scalar ), alpha for a +real-valued scalar ( double )): +- Addition, subtraction, negation: `A+B`, `A-B`, `A+s`, `A-s`, `s+A`, `s-A`, `-A` +- Scaling: `A*alpha` +- Per-element multiplication and division: `A.mul(B)`, `A/B`, `alpha/A` +- Matrix multiplication: `A*B` +- Transposition: `A.t()` (means AT) +- Matrix inversion and pseudo-inversion, solving linear systems and least-squares problems: + `A.inv([method]) (~ A-1)`, `A.inv([method])*B (~ X: AX=B)` +- Comparison: `A cmpop B`, `A cmpop alpha`, `alpha cmpop A`, where *cmpop* is one of + `>`, `>=`, `==`, `!=`, `<=`, `<`. The result of comparison is an 8-bit single channel mask whose + elements are set to 255 (if the particular element or pair of elements satisfy the condition) or + 0. +- Bitwise logical operations: `A logicop B`, `A logicop s`, `s logicop A`, `~A`, where *logicop* is one of + `&`, `|`, `^`. +- Element-wise minimum and maximum: `min(A, B)`, `min(A, alpha)`, `max(A, B)`, `max(A, alpha)` +- Element-wise absolute value: `abs(A)` +- Cross-product, dot-product: `A.cross(B)`, `A.dot(B)` +- Any function of matrix or matrices and scalars that returns a matrix or a scalar, such as norm, + mean, sum, countNonZero, trace, determinant, repeat, and others. +- Matrix initializers ( Mat::eye(), Mat::zeros(), Mat::ones() ), matrix comma-separated + initializers, matrix constructors and operators that extract sub-matrices (see Mat description). +- Mat_() constructors to cast the result to the proper type. +@note Comma-separated initializers and probably some other operations may require additional +explicit Mat() or Mat_() constructor calls to resolve a possible ambiguity. + +Here are examples of matrix expressions: +@code + // compute pseudo-inverse of A, equivalent to A.inv(DECOMP_SVD) + SVD svd(A); + Mat pinvA = svd.vt.t()*Mat::diag(1./svd.w)*svd.u.t(); + + // compute the new vector of parameters in the Levenberg-Marquardt algorithm + x -= (A.t()*A + lambda*Mat::eye(A.cols,A.cols,A.type())).inv(DECOMP_CHOLESKY)*(A.t()*err); + + // sharpen image using "unsharp mask" algorithm + Mat blurred; double sigma = 1, threshold = 5, amount = 1; + GaussianBlur(img, blurred, Size(), sigma, sigma); + Mat lowContrastMask = abs(img - blurred) < threshold; + Mat sharpened = img*(1+amount) + blurred*(-amount); + img.copyTo(sharpened, lowContrastMask); +@endcode +*/ +class CV_EXPORTS MatExpr +{ +public: + MatExpr(); + explicit MatExpr(const Mat& m); + + MatExpr(const MatOp* _op, int _flags, const Mat& _a = Mat(), const Mat& _b = Mat(), + const Mat& _c = Mat(), double _alpha = 1, double _beta = 1, const Scalar& _s = Scalar()); + + operator Mat() const; + template operator Mat_<_Tp>() const; + + Size size() const; + int type() const; + + MatExpr row(int y) const; + MatExpr col(int x) const; + MatExpr diag(int d = 0) const; + MatExpr operator()( const Range& rowRange, const Range& colRange ) const; + MatExpr operator()( const Rect& roi ) const; + + MatExpr t() const; + MatExpr inv(int method = DECOMP_LU) const; + MatExpr mul(const MatExpr& e, double scale=1) const; + MatExpr mul(const Mat& m, double scale=1) const; + + Mat cross(const Mat& m) const; + double dot(const Mat& m) const; + + void swap(MatExpr& b); + + const MatOp* op; + int flags; + + Mat a, b, c; + double alpha, beta; + Scalar s; +}; + +//! @} core_basic + +//! @relates cv::MatExpr +//! @{ +CV_EXPORTS MatExpr operator + (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator + (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator + (const Scalar& s, const Mat& a); +CV_EXPORTS MatExpr operator + (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator + (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator + (const MatExpr& e, const Scalar& s); +CV_EXPORTS MatExpr operator + (const Scalar& s, const MatExpr& e); +CV_EXPORTS MatExpr operator + (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator + (const Mat& a, const Matx<_Tp, m, n>& b) { return a + Mat(b); } +template static inline +MatExpr operator + (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) + b; } + +CV_EXPORTS MatExpr operator - (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator - (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator - (const Scalar& s, const Mat& a); +CV_EXPORTS MatExpr operator - (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator - (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator - (const MatExpr& e, const Scalar& s); +CV_EXPORTS MatExpr operator - (const Scalar& s, const MatExpr& e); +CV_EXPORTS MatExpr operator - (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator - (const Mat& a, const Matx<_Tp, m, n>& b) { return a - Mat(b); } +template static inline +MatExpr operator - (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) - b; } + +CV_EXPORTS MatExpr operator - (const Mat& m); +CV_EXPORTS MatExpr operator - (const MatExpr& e); + +CV_EXPORTS MatExpr operator * (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator * (const Mat& a, double s); +CV_EXPORTS MatExpr operator * (double s, const Mat& a); +CV_EXPORTS MatExpr operator * (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator * (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator * (const MatExpr& e, double s); +CV_EXPORTS MatExpr operator * (double s, const MatExpr& e); +CV_EXPORTS MatExpr operator * (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator * (const Mat& a, const Matx<_Tp, m, n>& b) { return a * Mat(b); } +template static inline +MatExpr operator * (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) * b; } + +CV_EXPORTS MatExpr operator / (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator / (const Mat& a, double s); +CV_EXPORTS MatExpr operator / (double s, const Mat& a); +CV_EXPORTS MatExpr operator / (const MatExpr& e, const Mat& m); +CV_EXPORTS MatExpr operator / (const Mat& m, const MatExpr& e); +CV_EXPORTS MatExpr operator / (const MatExpr& e, double s); +CV_EXPORTS MatExpr operator / (double s, const MatExpr& e); +CV_EXPORTS MatExpr operator / (const MatExpr& e1, const MatExpr& e2); +template static inline +MatExpr operator / (const Mat& a, const Matx<_Tp, m, n>& b) { return a / Mat(b); } +template static inline +MatExpr operator / (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) / b; } + +CV_EXPORTS MatExpr operator < (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator < (const Mat& a, double s); +CV_EXPORTS MatExpr operator < (double s, const Mat& a); +template static inline +MatExpr operator < (const Mat& a, const Matx<_Tp, m, n>& b) { return a < Mat(b); } +template static inline +MatExpr operator < (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) < b; } + +CV_EXPORTS MatExpr operator <= (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator <= (const Mat& a, double s); +CV_EXPORTS MatExpr operator <= (double s, const Mat& a); +template static inline +MatExpr operator <= (const Mat& a, const Matx<_Tp, m, n>& b) { return a <= Mat(b); } +template static inline +MatExpr operator <= (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) <= b; } + +CV_EXPORTS MatExpr operator == (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator == (const Mat& a, double s); +CV_EXPORTS MatExpr operator == (double s, const Mat& a); +template static inline +MatExpr operator == (const Mat& a, const Matx<_Tp, m, n>& b) { return a == Mat(b); } +template static inline +MatExpr operator == (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) == b; } + +CV_EXPORTS MatExpr operator != (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator != (const Mat& a, double s); +CV_EXPORTS MatExpr operator != (double s, const Mat& a); +template static inline +MatExpr operator != (const Mat& a, const Matx<_Tp, m, n>& b) { return a != Mat(b); } +template static inline +MatExpr operator != (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) != b; } + +CV_EXPORTS MatExpr operator >= (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator >= (const Mat& a, double s); +CV_EXPORTS MatExpr operator >= (double s, const Mat& a); +template static inline +MatExpr operator >= (const Mat& a, const Matx<_Tp, m, n>& b) { return a >= Mat(b); } +template static inline +MatExpr operator >= (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) >= b; } + +CV_EXPORTS MatExpr operator > (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator > (const Mat& a, double s); +CV_EXPORTS MatExpr operator > (double s, const Mat& a); +template static inline +MatExpr operator > (const Mat& a, const Matx<_Tp, m, n>& b) { return a > Mat(b); } +template static inline +MatExpr operator > (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) > b; } + +CV_EXPORTS MatExpr operator & (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator & (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator & (const Scalar& s, const Mat& a); +template static inline +MatExpr operator & (const Mat& a, const Matx<_Tp, m, n>& b) { return a & Mat(b); } +template static inline +MatExpr operator & (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) & b; } + +CV_EXPORTS MatExpr operator | (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator | (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator | (const Scalar& s, const Mat& a); +template static inline +MatExpr operator | (const Mat& a, const Matx<_Tp, m, n>& b) { return a | Mat(b); } +template static inline +MatExpr operator | (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) | b; } + +CV_EXPORTS MatExpr operator ^ (const Mat& a, const Mat& b); +CV_EXPORTS MatExpr operator ^ (const Mat& a, const Scalar& s); +CV_EXPORTS MatExpr operator ^ (const Scalar& s, const Mat& a); +template static inline +MatExpr operator ^ (const Mat& a, const Matx<_Tp, m, n>& b) { return a ^ Mat(b); } +template static inline +MatExpr operator ^ (const Matx<_Tp, m, n>& a, const Mat& b) { return Mat(a) ^ b; } + +CV_EXPORTS MatExpr operator ~(const Mat& m); + +CV_EXPORTS MatExpr min(const Mat& a, const Mat& b); +CV_EXPORTS MatExpr min(const Mat& a, double s); +CV_EXPORTS MatExpr min(double s, const Mat& a); +template static inline +MatExpr min (const Mat& a, const Matx<_Tp, m, n>& b) { return min(a, Mat(b)); } +template static inline +MatExpr min (const Matx<_Tp, m, n>& a, const Mat& b) { return min(Mat(a), b); } + +CV_EXPORTS MatExpr max(const Mat& a, const Mat& b); +CV_EXPORTS MatExpr max(const Mat& a, double s); +CV_EXPORTS MatExpr max(double s, const Mat& a); +template static inline +MatExpr max (const Mat& a, const Matx<_Tp, m, n>& b) { return max(a, Mat(b)); } +template static inline +MatExpr max (const Matx<_Tp, m, n>& a, const Mat& b) { return max(Mat(a), b); } + +/** @brief Calculates an absolute value of each matrix element. + +abs is a meta-function that is expanded to one of absdiff or convertScaleAbs forms: +- C = abs(A-B) is equivalent to `absdiff(A, B, C)` +- C = abs(A) is equivalent to `absdiff(A, Scalar::all(0), C)` +- C = `Mat_ >(abs(A*alpha + beta))` is equivalent to `convertScaleAbs(A, C, alpha, +beta)` + +The output matrix has the same size and the same type as the input one except for the last case, +where C is depth=CV_8U . +@param m matrix. +@sa @ref MatrixExpressions, absdiff, convertScaleAbs + */ +CV_EXPORTS MatExpr abs(const Mat& m); +/** @overload +@param e matrix expression. +*/ +CV_EXPORTS MatExpr abs(const MatExpr& e); +//! @} relates cv::MatExpr + +} // cv + +#include "opencv2/core/mat.inl.hpp" + +#endif // OPENCV_CORE_MAT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/mat.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/mat.inl.hpp new file mode 100644 index 0000000..886b82c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/mat.inl.hpp @@ -0,0 +1,3422 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_MATRIX_OPERATIONS_HPP +#define OPENCV_CORE_MATRIX_OPERATIONS_HPP + +#ifndef __cplusplus +# error mat.inl.hpp header must be compiled as C++ +#endif + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4127 ) +#endif + +#if defined(CV_SKIP_DISABLE_CLANG_ENUM_WARNINGS) + // nothing +#elif defined(CV_FORCE_DISABLE_CLANG_ENUM_WARNINGS) + #define CV_DISABLE_CLANG_ENUM_WARNINGS +#elif defined(__clang__) && defined(__has_warning) + #if __has_warning("-Wdeprecated-enum-enum-conversion") && __has_warning("-Wdeprecated-anon-enum-enum-conversion") + #define CV_DISABLE_CLANG_ENUM_WARNINGS + #endif +#endif +#ifdef CV_DISABLE_CLANG_ENUM_WARNINGS +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion" +#pragma clang diagnostic ignored "-Wdeprecated-anon-enum-enum-conversion" +#endif + +namespace cv +{ +CV__DEBUG_NS_BEGIN + + +//! @cond IGNORED + +////////////////////////// Custom (raw) type wrapper ////////////////////////// + +template static inline +int rawType() +{ + CV_StaticAssert(sizeof(_Tp) <= CV_CN_MAX, "sizeof(_Tp) is too large"); + const int elemSize = sizeof(_Tp); + return (int)CV_MAKETYPE(CV_8U, elemSize); +} + +//////////////////////// Input/Output Arrays //////////////////////// + +inline void _InputArray::init(int _flags, const void* _obj) +{ flags = _flags; obj = (void*)_obj; } + +inline void _InputArray::init(int _flags, const void* _obj, Size _sz) +{ flags = _flags; obj = (void*)_obj; sz = _sz; } + +inline void* _InputArray::getObj() const { return obj; } +inline int _InputArray::getFlags() const { return flags; } +inline Size _InputArray::getSz() const { return sz; } + +inline _InputArray::_InputArray() { init(0 + NONE, 0); } +inline _InputArray::_InputArray(int _flags, void* _obj) { init(_flags, _obj); } +inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); } +inline _InputArray::_InputArray(const UMat& m) { init(UMAT+ACCESS_READ, &m); } +inline _InputArray::_InputArray(const std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::vector<_Tp>& vec) +{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); } + +template inline +_InputArray::_InputArray(const std::array& arr) +{ init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); } + +inline +_InputArray::_InputArray(const std::vector& vec) +{ init(FIXED_TYPE + STD_BOOL_VECTOR + traits::Type::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_READ, &vec); } + +template inline +_InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, &mtx, Size(n, m)); } + +template inline +_InputArray::_InputArray(const _Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, vec, Size(n, 1)); } + +template inline +_InputArray::_InputArray(const Mat_<_Tp>& m) +{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_READ, &m); } + +inline _InputArray::_InputArray(const double& val) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F + ACCESS_READ, &val, Size(1,1)); } + +inline _InputArray::_InputArray(const cuda::GpuMat& d_mat) +{ init(CUDA_GPU_MAT + ACCESS_READ, &d_mat); } + +inline _InputArray::_InputArray(const std::vector& d_mat) +{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_READ, &d_mat);} + +inline _InputArray::_InputArray(const ogl::Buffer& buf) +{ init(OPENGL_BUFFER + ACCESS_READ, &buf); } + +inline _InputArray::_InputArray(const cuda::HostMem& cuda_mem) +{ init(CUDA_HOST_MEM + ACCESS_READ, &cuda_mem); } + +template inline +_InputArray _InputArray::rawIn(const std::vector<_Tp>& vec) +{ + _InputArray v; + v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_READ; + v.obj = (void*)&vec; + return v; +} + +template inline +_InputArray _InputArray::rawIn(const std::array<_Tp, _Nm>& arr) +{ + _InputArray v; + v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ; + v.obj = (void*)arr.data(); + v.sz = Size(1, _Nm); + return v; +} + +inline _InputArray::~_InputArray() {} + +inline Mat _InputArray::getMat(int i) const +{ + if( kind() == MAT && i < 0 ) + return *(const Mat*)obj; + return getMat_(i); +} + +inline bool _InputArray::isMat() const { return kind() == _InputArray::MAT; } +inline bool _InputArray::isUMat() const { return kind() == _InputArray::UMAT; } +inline bool _InputArray::isMatVector() const { return kind() == _InputArray::STD_VECTOR_MAT; } +inline bool _InputArray::isUMatVector() const { return kind() == _InputArray::STD_VECTOR_UMAT; } +inline bool _InputArray::isMatx() const { return kind() == _InputArray::MATX; } +inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR || + kind() == _InputArray::STD_BOOL_VECTOR || + (kind() == _InputArray::MATX && (sz.width <= 1 || sz.height <= 1)); } +inline bool _InputArray::isGpuMat() const { return kind() == _InputArray::CUDA_GPU_MAT; } +inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::STD_VECTOR_CUDA_GPU_MAT; } + +//////////////////////////////////////////////////////////////////////////////////////// + +inline _OutputArray::_OutputArray() { init(NONE + ACCESS_WRITE, 0); } +inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags + ACCESS_WRITE, _obj); } +inline _OutputArray::_OutputArray(Mat& m) { init(MAT+ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_MAT + ACCESS_WRITE, &vec); } +inline _OutputArray::_OutputArray(UMat& m) { init(UMAT + ACCESS_WRITE, &m); } +inline _OutputArray::_OutputArray(std::vector& vec) { init(STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(std::vector<_Tp>& vec) +{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(std::array& arr) +{ init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(Mat_<_Tp>& m) +{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } + +template inline +_OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } + +template inline +_OutputArray::_OutputArray(_Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } + +template inline +_OutputArray::_OutputArray(const std::vector<_Tp>& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(const std::array& arr) +{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); } + +template inline +_OutputArray::_OutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &vec); } + +template inline +_OutputArray::_OutputArray(const Mat_<_Tp>& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_WRITE, &m); } + +template inline +_OutputArray::_OutputArray(const Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, &mtx, Size(n, m)); } + +template inline +_OutputArray::_OutputArray(const _Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, vec, Size(n, 1)); } + +inline _OutputArray::_OutputArray(cuda::GpuMat& d_mat) +{ init(CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } + +inline _OutputArray::_OutputArray(std::vector& d_mat) +{ init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_WRITE, &d_mat);} + +inline _OutputArray::_OutputArray(ogl::Buffer& buf) +{ init(OPENGL_BUFFER + ACCESS_WRITE, &buf); } + +inline _OutputArray::_OutputArray(cuda::HostMem& cuda_mem) +{ init(CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } + +inline _OutputArray::_OutputArray(const Mat& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_WRITE, &m); } + +inline _OutputArray::_OutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_WRITE, &vec); } + +inline _OutputArray::_OutputArray(const UMat& m) +{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_WRITE, &m); } + +inline _OutputArray::_OutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } + +inline _OutputArray::_OutputArray(const cuda::GpuMat& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } + + +inline _OutputArray::_OutputArray(const ogl::Buffer& buf) +{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_WRITE, &buf); } + +inline _OutputArray::_OutputArray(const cuda::HostMem& cuda_mem) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } + +template inline +_OutputArray _OutputArray::rawOut(std::vector<_Tp>& vec) +{ + _OutputArray v; + v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_WRITE; + v.obj = (void*)&vec; + return v; +} + +template inline +_OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr) +{ + _OutputArray v; + v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE; + v.obj = (void*)arr.data(); + v.sz = Size(1, _Nm); + return v; +} + +/////////////////////////////////////////////////////////////////////////////////////////// + +inline _InputOutputArray::_InputOutputArray() { init(0+ACCESS_RW, 0); } +inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags+ACCESS_RW, _obj); } +inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT+ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); } +inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); } +inline _InputOutputArray::_InputOutputArray(std::vector& vec) { init(STD_VECTOR_UMAT+ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec) +{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(std::array& arr) +{ init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(std::vector >& vec) +{ init(FIXED_TYPE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(Mat_<_Tp>& m) +{ init(FIXED_TYPE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } + +template inline +_InputOutputArray::_InputOutputArray(Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } + +template inline +_InputOutputArray::_InputOutputArray(_Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } + +template inline +_InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(const std::array& arr) +{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); } + +template inline +_InputOutputArray::_InputOutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(const std::vector >& vec) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + traits::Type<_Tp>::value + ACCESS_RW, &vec); } + +template inline +_InputOutputArray::_InputOutputArray(const Mat_<_Tp>& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + traits::Type<_Tp>::value + ACCESS_RW, &m); } + +template inline +_InputOutputArray::_InputOutputArray(const Matx<_Tp, m, n>& mtx) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, &mtx, Size(n, m)); } + +template inline +_InputOutputArray::_InputOutputArray(const _Tp* vec, int n) +{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, vec, Size(n, 1)); } + +inline _InputOutputArray::_InputOutputArray(cuda::GpuMat& d_mat) +{ init(CUDA_GPU_MAT + ACCESS_RW, &d_mat); } + +inline _InputOutputArray::_InputOutputArray(ogl::Buffer& buf) +{ init(OPENGL_BUFFER + ACCESS_RW, &buf); } + +inline _InputOutputArray::_InputOutputArray(cuda::HostMem& cuda_mem) +{ init(CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } + +inline _InputOutputArray::_InputOutputArray(const Mat& m) +{ init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_RW, &m); } + +inline _InputOutputArray::_InputOutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_RW, &vec); } + +inline _InputOutputArray::_InputOutputArray(const UMat& m) +{ init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_RW, &m); } + +inline _InputOutputArray::_InputOutputArray(const std::vector& vec) +{ init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_RW, &vec); } + +inline _InputOutputArray::_InputOutputArray(const cuda::GpuMat& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_RW, &d_mat); } + +inline _InputOutputArray::_InputOutputArray(const std::vector& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} + +template<> inline _InputOutputArray::_InputOutputArray(std::vector& d_mat) +{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} + +inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf) +{ init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_RW, &buf); } + +inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem) +{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } + +template inline +_InputOutputArray _InputOutputArray::rawInOut(std::vector<_Tp>& vec) +{ + _InputOutputArray v; + v.flags = _InputArray::FIXED_TYPE + _InputArray::STD_VECTOR + rawType<_Tp>() + ACCESS_RW; + v.obj = (void*)&vec; + return v; +} + +template inline +_InputOutputArray _InputOutputArray::rawInOut(std::array<_Tp, _Nm>& arr) +{ + _InputOutputArray v; + v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW; + v.obj = (void*)arr.data(); + v.sz = Size(1, _Nm); + return v; +} + + +template static inline _InputArray rawIn(_Tp& v) { return _InputArray::rawIn(v); } +template static inline _OutputArray rawOut(_Tp& v) { return _OutputArray::rawOut(v); } +template static inline _InputOutputArray rawInOut(_Tp& v) { return _InputOutputArray::rawInOut(v); } + +CV__DEBUG_NS_END + +//////////////////////////////////////////// Mat ////////////////////////////////////////// + +template inline +Mat::Mat(const std::vector<_Tp>& vec, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), + cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if(vec.empty()) + return; + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)&vec[0]; + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); +} + +template inline +Mat::Mat(const std::initializer_list<_Tp> list) + : Mat() +{ + CV_Assert(list.size() != 0); + Mat((int)list.size(), 1, traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this); +} + +template inline +Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp> list) + : Mat() +{ + size_t size_total = 1; + for(auto s : sizes) + size_total *= s; + CV_Assert(list.size() != 0); + CV_Assert(size_total == list.size()); + Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this); +} + +template inline +Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), + cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if(arr.empty()) + return; + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)arr.data(); + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat((int)arr.size(), 1, traits::Type<_Tp>::value, (uchar*)arr.data()).copyTo(*this); +} + +template inline +Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)vec.val; + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat(n, 1, traits::Type<_Tp>::value, (void*)vec.val).copyTo(*this); +} + + +template inline +Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = cols * sizeof(_Tp); + step[1] = sizeof(_Tp); + datastart = data = (uchar*)M.val; + datalimit = dataend = datastart + rows * step[0]; + } + else + Mat(m, n, traits::Type<_Tp>::value, (uchar*)M.val).copyTo(*this); +} + +template inline +Mat::Mat(const Point_<_Tp>& pt, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)&pt.x; + datalimit = dataend = datastart + rows * step[0]; + } + else + { + create(2, 1, traits::Type<_Tp>::value); + ((_Tp*)data)[0] = pt.x; + ((_Tp*)data)[1] = pt.y; + } +} + +template inline +Mat::Mat(const Point3_<_Tp>& pt, bool copyData) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), + datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) +{ + if( !copyData ) + { + step[0] = step[1] = sizeof(_Tp); + datastart = data = (uchar*)&pt.x; + datalimit = dataend = datastart + rows * step[0]; + } + else + { + create(3, 1, traits::Type<_Tp>::value); + ((_Tp*)data)[0] = pt.x; + ((_Tp*)data)[1] = pt.y; + ((_Tp*)data)[2] = pt.z; + } +} + +template inline +Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) + : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), + datastart(0), dataend(0), allocator(0), u(0), size(&rows) +{ + *this = commaInitializer.operator Mat_<_Tp>(); +} + +inline +Mat Mat::row(int y) const +{ + return Mat(*this, Range(y, y + 1), Range::all()); +} + +inline +Mat Mat::col(int x) const +{ + return Mat(*this, Range::all(), Range(x, x + 1)); +} + +inline +Mat Mat::rowRange(int startrow, int endrow) const +{ + return Mat(*this, Range(startrow, endrow), Range::all()); +} + +inline +Mat Mat::rowRange(const Range& r) const +{ + return Mat(*this, r, Range::all()); +} + +inline +Mat Mat::colRange(int startcol, int endcol) const +{ + return Mat(*this, Range::all(), Range(startcol, endcol)); +} + +inline +Mat Mat::colRange(const Range& r) const +{ + return Mat(*this, Range::all(), r); +} + +inline +Mat Mat::operator()( Range _rowRange, Range _colRange ) const +{ + return Mat(*this, _rowRange, _colRange); +} + +inline +Mat Mat::operator()( const Rect& roi ) const +{ + return Mat(*this, roi); +} + +inline +Mat Mat::operator()(const Range* ranges) const +{ + return Mat(*this, ranges); +} + +inline +Mat Mat::operator()(const std::vector& ranges) const +{ + return Mat(*this, ranges); +} + +inline +bool Mat::isContinuous() const +{ + return (flags & CONTINUOUS_FLAG) != 0; +} + +inline +bool Mat::isSubmatrix() const +{ + return (flags & SUBMATRIX_FLAG) != 0; +} + +inline +size_t Mat::elemSize() const +{ + size_t res = dims > 0 ? step.p[dims - 1] : 0; + CV_DbgAssert(res != 0); + return res; +} + +inline +size_t Mat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int Mat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int Mat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int Mat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +uchar* Mat::ptr(int y) +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return data + step.p[0] * y; +} + +inline +const uchar* Mat::ptr(int y) const +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return data + step.p[0] * y; +} + +template inline +_Tp* Mat::ptr(int y) +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return (_Tp*)(data + step.p[0] * y); +} + +template inline +const _Tp* Mat::ptr(int y) const +{ + CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); + return (const _Tp*)(data + step.p[0] * y); +} + +inline +uchar* Mat::ptr(int i0, int i1) +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return data + i0 * step.p[0] + i1 * step.p[1]; +} + +inline +const uchar* Mat::ptr(int i0, int i1) const +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return data + i0 * step.p[0] + i1 * step.p[1]; +} + +template inline +_Tp* Mat::ptr(int i0, int i1) +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return (_Tp*)(data + i0 * step.p[0] + i1 * step.p[1]); +} + +template inline +const _Tp* Mat::ptr(int i0, int i1) const +{ + CV_DbgAssert(dims >= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + return (const _Tp*)(data + i0 * step.p[0] + i1 * step.p[1]); +} + +inline +uchar* Mat::ptr(int i0, int i1, int i2) +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]; +} + +inline +const uchar* Mat::ptr(int i0, int i1, int i2) const +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]; +} + +template inline +_Tp* Mat::ptr(int i0, int i1, int i2) +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return (_Tp*)(data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]); +} + +template inline +const _Tp* Mat::ptr(int i0, int i1, int i2) const +{ + CV_DbgAssert(dims >= 3); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); + return (const _Tp*)(data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]); +} + +inline +uchar* Mat::ptr(const int* idx) +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return p; +} + +inline +const uchar* Mat::ptr(const int* idx) const +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return p; +} + +template inline +_Tp* Mat::ptr(const int* idx) +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return (_Tp*)p; +} + +template inline +const _Tp* Mat::ptr(const int* idx) const +{ + int i, d = dims; + uchar* p = data; + CV_DbgAssert( d >= 1 && p ); + for( i = 0; i < d; i++ ) + { + CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); + p += idx[i] * step.p[i]; + } + return (const _Tp*)p; +} + +template inline +uchar* Mat::ptr(const Vec& idx) +{ + return Mat::ptr(idx.val); +} + +template inline +const uchar* Mat::ptr(const Vec& idx) const +{ + return Mat::ptr(idx.val); +} + +template inline +_Tp* Mat::ptr(const Vec& idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return Mat::ptr<_Tp>(idx.val); +} + +template inline +const _Tp* Mat::ptr(const Vec& idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return Mat::ptr<_Tp>(idx.val); +} + + +template inline +_Tp& Mat::at(int i0, int i1) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((_Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +const _Tp& Mat::at(int i0, int i1) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((const _Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +_Tp& Mat::at(Point pt) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((_Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +const _Tp& Mat::at(Point pt) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); + CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); + return ((const _Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +_Tp& Mat::at(int i0) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)(size.p[0] * size.p[1])); + CV_DbgAssert(elemSize() == sizeof(_Tp)); + if( isContinuous() || size.p[0] == 1 ) + return ((_Tp*)data)[i0]; + if( size.p[1] == 1 ) + return *(_Tp*)(data + step.p[0] * i0); + int i = i0 / cols, j = i0 - i * cols; + return ((_Tp*)(data + step.p[0] * i))[j]; +} + +template inline +const _Tp& Mat::at(int i0) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)(size.p[0] * size.p[1])); + CV_DbgAssert(elemSize() == sizeof(_Tp)); + if( isContinuous() || size.p[0] == 1 ) + return ((const _Tp*)data)[i0]; + if( size.p[1] == 1 ) + return *(const _Tp*)(data + step.p[0] * i0); + int i = i0 / cols, j = i0 - i * cols; + return ((const _Tp*)(data + step.p[0] * i))[j]; +} + +template inline +_Tp& Mat::at(int i0, int i1, int i2) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(_Tp*)ptr(i0, i1, i2); +} + +template inline +const _Tp& Mat::at(int i0, int i1, int i2) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(const _Tp*)ptr(i0, i1, i2); +} + +template inline +_Tp& Mat::at(const int* idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(_Tp*)ptr(idx); +} + +template inline +const _Tp& Mat::at(const int* idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(const _Tp*)ptr(idx); +} + +template inline +_Tp& Mat::at(const Vec& idx) +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(_Tp*)ptr(idx.val); +} + +template inline +const _Tp& Mat::at(const Vec& idx) const +{ + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return *(const _Tp*)ptr(idx.val); +} + +template inline +MatConstIterator_<_Tp> Mat::begin() const +{ + if (empty()) + return MatConstIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return MatConstIterator_<_Tp>((const Mat_<_Tp>*)this); +} + +template inline +std::reverse_iterator> Mat::rbegin() const +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this); + it += total(); + return std::reverse_iterator> (it); +} + +template inline +MatConstIterator_<_Tp> Mat::end() const +{ + if (empty()) + return MatConstIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this); + it += total(); + return it; +} + +template inline +std::reverse_iterator> Mat::rend() const +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return std::reverse_iterator>((const Mat_<_Tp>*)this); +} + +template inline +MatIterator_<_Tp> Mat::begin() +{ + if (empty()) + return MatIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return MatIterator_<_Tp>((Mat_<_Tp>*)this); +} + +template inline +std::reverse_iterator> Mat::rbegin() +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatIterator_<_Tp> it((Mat_<_Tp>*)this); + it += total(); + return std::reverse_iterator>(it); +} + +template inline +MatIterator_<_Tp> Mat::end() +{ + if (empty()) + return MatIterator_<_Tp>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + MatIterator_<_Tp> it((Mat_<_Tp>*)this); + it += total(); + return it; +} + +template inline +std::reverse_iterator> Mat::rend() +{ + if (empty()) + return std::reverse_iterator>(); + CV_DbgAssert( elemSize() == sizeof(_Tp) ); + return std::reverse_iterator>(MatIterator_<_Tp>((Mat_<_Tp>*)this)); +} + +template inline +void Mat::forEach(const Functor& operation) { + this->forEach_impl<_Tp>(operation); +} + +template inline +void Mat::forEach(const Functor& operation) const { + // call as not const + (const_cast(this))->forEach<_Tp>(operation); +} + +template inline +Mat::operator std::vector<_Tp>() const +{ + std::vector<_Tp> v; + copyTo(v); + return v; +} + +template inline +Mat::operator std::array<_Tp, _Nm>() const +{ + std::array<_Tp, _Nm> v; + copyTo(v); + return v; +} + +template inline +Mat::operator Vec<_Tp, n>() const +{ + CV_Assert( data && dims <= 2 && (rows == 1 || cols == 1) && + rows + cols - 1 == n && channels() == 1 ); + + if( isContinuous() && type() == traits::Type<_Tp>::value ) + return Vec<_Tp, n>((_Tp*)data); + Vec<_Tp, n> v; + Mat tmp(rows, cols, traits::Type<_Tp>::value, v.val); + convertTo(tmp, tmp.type()); + return v; +} + +template inline +Mat::operator Matx<_Tp, m, n>() const +{ + CV_Assert( data && dims <= 2 && rows == m && cols == n && channels() == 1 ); + + if( isContinuous() && type() == traits::Type<_Tp>::value ) + return Matx<_Tp, m, n>((_Tp*)data); + Matx<_Tp, m, n> mtx; + Mat tmp(rows, cols, traits::Type<_Tp>::value, mtx.val); + convertTo(tmp, tmp.type()); + return mtx; +} + +template inline +void Mat::push_back(const _Tp& elem) +{ + if( !data ) + { + *this = Mat(1, 1, traits::Type<_Tp>::value, (void*)&elem).clone(); + return; + } + CV_Assert(traits::Type<_Tp>::value == type() && cols == 1 + /* && dims == 2 (cols == 1 implies dims == 2) */); + const uchar* tmp = dataend + step[0]; + if( !isSubmatrix() && isContinuous() && tmp <= datalimit ) + { + *(_Tp*)(data + (size.p[0]++) * step.p[0]) = elem; + dataend = tmp; + } + else + push_back_(&elem); +} + +template inline +void Mat::push_back(const Mat_<_Tp>& m) +{ + push_back((const Mat&)m); +} + +template<> inline +void Mat::push_back(const MatExpr& expr) +{ + push_back(static_cast(expr)); +} + + +template inline +void Mat::push_back(const std::vector<_Tp>& v) +{ + push_back(Mat(v)); +} + + +///////////////////////////// MatSize //////////////////////////// + +inline +MatSize::MatSize(int* _p) CV_NOEXCEPT + : p(_p) {} + +inline +int MatSize::dims() const CV_NOEXCEPT +{ + return (p - 1)[0]; +} + +inline +Size MatSize::operator()() const +{ + CV_DbgAssert(dims() <= 2); + return Size(p[1], p[0]); +} + +inline +const int& MatSize::operator[](int i) const +{ + CV_DbgAssert(i < dims()); +#ifdef __OPENCV_BUILD + CV_DbgAssert(i >= 0); +#endif + return p[i]; +} + +inline +int& MatSize::operator[](int i) +{ + CV_DbgAssert(i < dims()); +#ifdef __OPENCV_BUILD + CV_DbgAssert(i >= 0); +#endif + return p[i]; +} + +inline +MatSize::operator const int*() const CV_NOEXCEPT +{ + return p; +} + +inline +bool MatSize::operator != (const MatSize& sz) const CV_NOEXCEPT +{ + return !(*this == sz); +} + + + +///////////////////////////// MatStep //////////////////////////// + +inline +MatStep::MatStep() CV_NOEXCEPT +{ + p = buf; p[0] = p[1] = 0; +} + +inline +MatStep::MatStep(size_t s) CV_NOEXCEPT +{ + p = buf; p[0] = s; p[1] = 0; +} + +inline +const size_t& MatStep::operator[](int i) const CV_NOEXCEPT +{ + return p[i]; +} + +inline +size_t& MatStep::operator[](int i) CV_NOEXCEPT +{ + return p[i]; +} + +inline MatStep::operator size_t() const +{ + CV_DbgAssert( p == buf ); + return buf[0]; +} + +inline MatStep& MatStep::operator = (size_t s) +{ + CV_DbgAssert( p == buf ); + buf[0] = s; + return *this; +} + + + +////////////////////////////// Mat_<_Tp> //////////////////////////// + +template inline +Mat_<_Tp>::Mat_() CV_NOEXCEPT + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; +} + +template inline +Mat_<_Tp>::Mat_(int _rows, int _cols) + : Mat(_rows, _cols, traits::Type<_Tp>::value) +{ +} + +template inline +Mat_<_Tp>::Mat_(int _rows, int _cols, const _Tp& value) + : Mat(_rows, _cols, traits::Type<_Tp>::value) +{ + *this = value; +} + +template inline +Mat_<_Tp>::Mat_(Size _sz) + : Mat(_sz.height, _sz.width, traits::Type<_Tp>::value) +{} + +template inline +Mat_<_Tp>::Mat_(Size _sz, const _Tp& value) + : Mat(_sz.height, _sz.width, traits::Type<_Tp>::value) +{ + *this = value; +} + +template inline +Mat_<_Tp>::Mat_(int _dims, const int* _sz) + : Mat(_dims, _sz, traits::Type<_Tp>::value) +{} + +template inline +Mat_<_Tp>::Mat_(int _dims, const int* _sz, const _Tp& _s) + : Mat(_dims, _sz, traits::Type<_Tp>::value, Scalar(_s)) +{} + +template inline +Mat_<_Tp>::Mat_(int _dims, const int* _sz, _Tp* _data, const size_t* _steps) + : Mat(_dims, _sz, traits::Type<_Tp>::value, _data, _steps) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const Range* ranges) + : Mat(m, ranges) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const std::vector& ranges) + : Mat(m, ranges) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat& m) + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + *this = m; +} + +template inline +Mat_<_Tp>::Mat_(const Mat_& m) + : Mat(m) +{} + +template inline +Mat_<_Tp>::Mat_(int _rows, int _cols, _Tp* _data, size_t steps) + : Mat(_rows, _cols, traits::Type<_Tp>::value, _data, steps) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_& m, const Range& _rowRange, const Range& _colRange) + : Mat(m, _rowRange, _colRange) +{} + +template inline +Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi) + : Mat(m, roi) +{} + +template template inline +Mat_<_Tp>::Mat_(const Vec::channel_type, n>& vec, bool copyData) + : Mat(n / DataType<_Tp>::channels, 1, traits::Type<_Tp>::value, (void*)&vec) +{ + CV_Assert(n%DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template template inline +Mat_<_Tp>::Mat_(const Matx::channel_type, m, n>& M, bool copyData) + : Mat(m, n / DataType<_Tp>::channels, traits::Type<_Tp>::value, (void*)&M) +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template inline +Mat_<_Tp>::Mat_(const Point_::channel_type>& pt, bool copyData) + : Mat(2 / DataType<_Tp>::channels, 1, traits::Type<_Tp>::value, (void*)&pt) +{ + CV_Assert(2 % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template inline +Mat_<_Tp>::Mat_(const Point3_::channel_type>& pt, bool copyData) + : Mat(3 / DataType<_Tp>::channels, 1, traits::Type<_Tp>::value, (void*)&pt) +{ + CV_Assert(3 % DataType<_Tp>::channels == 0); + if( copyData ) + *this = clone(); +} + +template inline +Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer) + : Mat(commaInitializer) +{} + +template inline +Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData) + : Mat(vec, copyData) +{} + +template inline +Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list) + : Mat(list) +{} + +template inline +Mat_<_Tp>::Mat_(const std::initializer_list sizes, std::initializer_list<_Tp> list) + : Mat(sizes, list) +{} + +template template inline +Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData) + : Mat(arr, copyData) +{} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) +{ + if (m.empty()) + { + release(); + return *this; + } + if( traits::Type<_Tp>::value == m.type() ) + { + Mat::operator = (m); + return *this; + } + if( traits::Depth<_Tp>::value == m.depth() ) + { + return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0)); + } + CV_Assert(DataType<_Tp>::channels == m.channels() || m.empty()); + m.convertTo(*this, type()); + return *this; +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat_& m) +{ + Mat::operator=(m); + return *this; +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const _Tp& s) +{ + typedef typename DataType<_Tp>::vec_type VT; + Mat::operator=(Scalar((const VT&)s)); + return *this; +} + +template inline +void Mat_<_Tp>::create(int _rows, int _cols) +{ + Mat::create(_rows, _cols, traits::Type<_Tp>::value); +} + +template inline +void Mat_<_Tp>::create(Size _sz) +{ + Mat::create(_sz, traits::Type<_Tp>::value); +} + +template inline +void Mat_<_Tp>::create(int _dims, const int* _sz) +{ + Mat::create(_dims, _sz, traits::Type<_Tp>::value); +} + +template inline +void Mat_<_Tp>::release() +{ + Mat::release(); + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; +} + +template inline +Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const +{ + return Mat_<_Tp>(Mat::cross(m)); +} + +template template inline +Mat_<_Tp>::operator Mat_() const +{ + return Mat_(static_cast(*this)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::row(int y) const +{ + return Mat_(*this, Range(y, y+1), Range::all()); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::col(int x) const +{ + return Mat_(*this, Range::all(), Range(x, x+1)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::diag(int d) const +{ + return Mat_(Mat::diag(d)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::clone() const +{ + return Mat_(Mat::clone()); +} + +template inline +size_t Mat_<_Tp>::elemSize() const +{ + CV_DbgAssert( Mat::elemSize() == sizeof(_Tp) ); + return sizeof(_Tp); +} + +template inline +size_t Mat_<_Tp>::elemSize1() const +{ + CV_DbgAssert( Mat::elemSize1() == sizeof(_Tp) / DataType<_Tp>::channels ); + return sizeof(_Tp) / DataType<_Tp>::channels; +} + +template inline +int Mat_<_Tp>::type() const +{ + CV_DbgAssert( Mat::type() == traits::Type<_Tp>::value ); + return traits::Type<_Tp>::value; +} + +template inline +int Mat_<_Tp>::depth() const +{ + CV_DbgAssert( Mat::depth() == traits::Depth<_Tp>::value ); + return traits::Depth<_Tp>::value; +} + +template inline +int Mat_<_Tp>::channels() const +{ + CV_DbgAssert( Mat::channels() == DataType<_Tp>::channels ); + return DataType<_Tp>::channels; +} + +template inline +size_t Mat_<_Tp>::stepT(int i) const +{ + return step.p[i] / elemSize(); +} + +template inline +size_t Mat_<_Tp>::step1(int i) const +{ + return step.p[i] / elemSize1(); +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright ) +{ + return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()( const Range& _rowRange, const Range& _colRange ) const +{ + return Mat_<_Tp>(*this, _rowRange, _colRange); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()( const Rect& roi ) const +{ + return Mat_<_Tp>(*this, roi); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()( const Range* ranges ) const +{ + return Mat_<_Tp>(*this, ranges); +} + +template inline +Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector& ranges) const +{ + return Mat_<_Tp>(*this, ranges); +} + +template inline +_Tp* Mat_<_Tp>::operator [](int y) +{ + CV_DbgAssert( 0 <= y && y < size.p[0] ); + return (_Tp*)(data + y*step.p[0]); +} + +template inline +const _Tp* Mat_<_Tp>::operator [](int y) const +{ + CV_DbgAssert( 0 <= y && y < size.p[0] ); + return (const _Tp*)(data + y*step.p[0]); +} + +template inline +_Tp& Mat_<_Tp>::operator ()(int i0, int i1) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((_Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(int i0, int i1) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((const _Tp*)(data + step.p[0] * i0))[i1]; +} + +template inline +_Tp& Mat_<_Tp>::operator ()(Point pt) +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)pt.x < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((_Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(Point pt) const +{ + CV_DbgAssert(dims <= 2); + CV_DbgAssert(data); + CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); + CV_DbgAssert((unsigned)pt.x < (unsigned)size.p[1]); + CV_DbgAssert(type() == traits::Type<_Tp>::value); + return ((const _Tp*)(data + step.p[0] * pt.y))[pt.x]; +} + +template inline +_Tp& Mat_<_Tp>::operator ()(const int* idx) +{ + return Mat::at<_Tp>(idx); +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(const int* idx) const +{ + return Mat::at<_Tp>(idx); +} + +template template inline +_Tp& Mat_<_Tp>::operator ()(const Vec& idx) +{ + return Mat::at<_Tp>(idx); +} + +template template inline +const _Tp& Mat_<_Tp>::operator ()(const Vec& idx) const +{ + return Mat::at<_Tp>(idx); +} + +template inline +_Tp& Mat_<_Tp>::operator ()(int i0) +{ + return this->at<_Tp>(i0); +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(int i0) const +{ + return this->at<_Tp>(i0); +} + +template inline +_Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) +{ + return this->at<_Tp>(i0, i1, i2); +} + +template inline +const _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) const +{ + return this->at<_Tp>(i0, i1, i2); +} + +template inline +Mat_<_Tp>::operator std::vector<_Tp>() const +{ + std::vector<_Tp> v; + copyTo(v); + return v; +} + +template template inline +Mat_<_Tp>::operator std::array<_Tp, _Nm>() const +{ + std::array<_Tp, _Nm> a; + copyTo(a); + return a; +} + +template template inline +Mat_<_Tp>::operator Vec::channel_type, n>() const +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + +#if defined _MSC_VER + const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) + return pMat->operator Vec::channel_type, n>(); +#else + return this->Mat::operator Vec::channel_type, n>(); +#endif +} + +template template inline +Mat_<_Tp>::operator Matx::channel_type, m, n>() const +{ + CV_Assert(n % DataType<_Tp>::channels == 0); + +#if defined _MSC_VER + const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) + Matx::channel_type, m, n> res = pMat->operator Matx::channel_type, m, n>(); + return res; +#else + Matx::channel_type, m, n> res = this->Mat::operator Matx::channel_type, m, n>(); + return res; +#endif +} + +template inline +MatConstIterator_<_Tp> Mat_<_Tp>::begin() const +{ + return Mat::begin<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rbegin() const +{ + return Mat::rbegin<_Tp>(); +} + +template inline +MatConstIterator_<_Tp> Mat_<_Tp>::end() const +{ + return Mat::end<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rend() const +{ + return Mat::rend<_Tp>(); +} + +template inline +MatIterator_<_Tp> Mat_<_Tp>::begin() +{ + return Mat::begin<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rbegin() +{ + return Mat::rbegin<_Tp>(); +} + +template inline +MatIterator_<_Tp> Mat_<_Tp>::end() +{ + return Mat::end<_Tp>(); +} + +template inline +std::reverse_iterator> Mat_<_Tp>::rend() +{ + return Mat::rend<_Tp>(); +} + +template template inline +void Mat_<_Tp>::forEach(const Functor& operation) { + Mat::forEach<_Tp, Functor>(operation); +} + +template template inline +void Mat_<_Tp>::forEach(const Functor& operation) const { + Mat::forEach<_Tp, Functor>(operation); +} + +template inline +Mat_<_Tp>::Mat_(Mat_&& m) + : Mat(std::move(m)) +{ +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m) +{ + Mat::operator = (std::move(m)); + return *this; +} + +template inline +Mat_<_Tp>::Mat_(Mat&& m) + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + *this = std::move(m); +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m) +{ + if (m.empty()) + { + release(); + return *this; + } + if( traits::Type<_Tp>::value == m.type() ) + { + Mat::operator = ((Mat&&)m); + return *this; + } + if( traits::Depth<_Tp>::value == m.depth() ) + { + Mat::operator = ((Mat&&)m.reshape(DataType<_Tp>::channels, m.dims, 0)); + return *this; + } + CV_DbgAssert(DataType<_Tp>::channels == m.channels()); + m.convertTo(*this, type()); + return *this; +} + +template inline +Mat_<_Tp>::Mat_(MatExpr&& e) + : Mat() +{ + flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value; + *this = Mat(e); +} + + +///////////////////////////// SparseMat ///////////////////////////// + +inline +SparseMat SparseMat::clone() const +{ + SparseMat temp; + this->copyTo(temp); + return temp; +} + +inline +size_t SparseMat::elemSize() const +{ + return CV_ELEM_SIZE(flags); +} + +inline +size_t SparseMat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int SparseMat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int SparseMat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int SparseMat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +const int* SparseMat::size() const +{ + return hdr ? hdr->size : 0; +} + +inline +int SparseMat::size(int i) const +{ + if( hdr ) + { + CV_DbgAssert((unsigned)i < (unsigned)hdr->dims); + return hdr->size[i]; + } + return 0; +} + +inline +int SparseMat::dims() const +{ + return hdr ? hdr->dims : 0; +} + +inline +size_t SparseMat::nzcount() const +{ + return hdr ? hdr->nodeCount : 0; +} + +template inline +_Tp& SparseMat::ref(int i0, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(i0, true, hashval); +} + +template inline +_Tp& SparseMat::ref(int i0, int i1, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, true, hashval); +} + +template inline +_Tp& SparseMat::ref(int i0, int i1, int i2, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, i2, true, hashval); +} + +template inline +_Tp& SparseMat::ref(const int* idx, size_t* hashval) +{ + return *(_Tp*)((SparseMat*)this)->ptr(idx, true, hashval); +} + +template inline +_Tp SparseMat::value(int i0, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); + return p ? *p : _Tp(); +} + +template inline +_Tp SparseMat::value(int i0, int i1, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); + return p ? *p : _Tp(); +} + +template inline +_Tp SparseMat::value(int i0, int i1, int i2, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); + return p ? *p : _Tp(); +} + +template inline +_Tp SparseMat::value(const int* idx, size_t* hashval) const +{ + const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); + return p ? *p : _Tp(); +} + +template inline +const _Tp* SparseMat::find(int i0, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); +} + +template inline +const _Tp* SparseMat::find(int i0, int i1, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); +} + +template inline +const _Tp* SparseMat::find(int i0, int i1, int i2, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); +} + +template inline +const _Tp* SparseMat::find(const int* idx, size_t* hashval) const +{ + return (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); +} + +template inline +_Tp& SparseMat::value(Node* n) +{ + return *(_Tp*)((uchar*)n + hdr->valueOffset); +} + +template inline +const _Tp& SparseMat::value(const Node* n) const +{ + return *(const _Tp*)((const uchar*)n + hdr->valueOffset); +} + +inline +SparseMat::Node* SparseMat::node(size_t nidx) +{ + return (Node*)(void*)&hdr->pool[nidx]; +} + +inline +const SparseMat::Node* SparseMat::node(size_t nidx) const +{ + return (const Node*)(const void*)&hdr->pool[nidx]; +} + +inline +SparseMatIterator SparseMat::begin() +{ + return SparseMatIterator(this); +} + +inline +SparseMatConstIterator SparseMat::begin() const +{ + return SparseMatConstIterator(this); +} + +inline +SparseMatIterator SparseMat::end() +{ + SparseMatIterator it(this); + it.seekEnd(); + return it; +} + +inline +SparseMatConstIterator SparseMat::end() const +{ + SparseMatConstIterator it(this); + it.seekEnd(); + return it; +} + +template inline +SparseMatIterator_<_Tp> SparseMat::begin() +{ + return SparseMatIterator_<_Tp>(this); +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat::begin() const +{ + return SparseMatConstIterator_<_Tp>(this); +} + +template inline +SparseMatIterator_<_Tp> SparseMat::end() +{ + SparseMatIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat::end() const +{ + SparseMatConstIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + + + +///////////////////////////// SparseMat_ //////////////////////////// + +template inline +SparseMat_<_Tp>::SparseMat_() +{ + flags = MAGIC_VAL + traits::Type<_Tp>::value; +} + +template inline +SparseMat_<_Tp>::SparseMat_(int _dims, const int* _sizes) + : SparseMat(_dims, _sizes, traits::Type<_Tp>::value) +{} + +template inline +SparseMat_<_Tp>::SparseMat_(const SparseMat& m) +{ + if( m.type() == traits::Type<_Tp>::value ) + *this = (const SparseMat_<_Tp>&)m; + else + m.convertTo(*this, traits::Type<_Tp>::value); +} + +template inline +SparseMat_<_Tp>::SparseMat_(const SparseMat_<_Tp>& m) +{ + this->flags = m.flags; + this->hdr = m.hdr; + if( this->hdr ) + CV_XADD(&this->hdr->refcount, 1); +} + +template inline +SparseMat_<_Tp>::SparseMat_(const Mat& m) +{ + SparseMat sm(m); + *this = sm; +} + +template inline +SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const SparseMat_<_Tp>& m) +{ + if( this != &m ) + { + if( m.hdr ) CV_XADD(&m.hdr->refcount, 1); + release(); + flags = m.flags; + hdr = m.hdr; + } + return *this; +} + +template inline +SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const SparseMat& m) +{ + if( m.type() == traits::Type<_Tp>::value ) + return (*this = (const SparseMat_<_Tp>&)m); + m.convertTo(*this, traits::Type<_Tp>::value); + return *this; +} + +template inline +SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const Mat& m) +{ + return (*this = SparseMat(m)); +} + +template inline +SparseMat_<_Tp> SparseMat_<_Tp>::clone() const +{ + SparseMat_<_Tp> m; + this->copyTo(m); + return m; +} + +template inline +void SparseMat_<_Tp>::create(int _dims, const int* _sizes) +{ + SparseMat::create(_dims, _sizes, traits::Type<_Tp>::value); +} + +template inline +int SparseMat_<_Tp>::type() const +{ + return traits::Type<_Tp>::value; +} + +template inline +int SparseMat_<_Tp>::depth() const +{ + return traits::Depth<_Tp>::value; +} + +template inline +int SparseMat_<_Tp>::channels() const +{ + return DataType<_Tp>::channels; +} + +template inline +_Tp& SparseMat_<_Tp>::ref(int i0, size_t* hashval) +{ + return SparseMat::ref<_Tp>(i0, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(int i0, size_t* hashval) const +{ + return SparseMat::value<_Tp>(i0, hashval); +} + +template inline +_Tp& SparseMat_<_Tp>::ref(int i0, int i1, size_t* hashval) +{ + return SparseMat::ref<_Tp>(i0, i1, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(int i0, int i1, size_t* hashval) const +{ + return SparseMat::value<_Tp>(i0, i1, hashval); +} + +template inline +_Tp& SparseMat_<_Tp>::ref(int i0, int i1, int i2, size_t* hashval) +{ + return SparseMat::ref<_Tp>(i0, i1, i2, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(int i0, int i1, int i2, size_t* hashval) const +{ + return SparseMat::value<_Tp>(i0, i1, i2, hashval); +} + +template inline +_Tp& SparseMat_<_Tp>::ref(const int* idx, size_t* hashval) +{ + return SparseMat::ref<_Tp>(idx, hashval); +} + +template inline +_Tp SparseMat_<_Tp>::operator()(const int* idx, size_t* hashval) const +{ + return SparseMat::value<_Tp>(idx, hashval); +} + +template inline +SparseMatIterator_<_Tp> SparseMat_<_Tp>::begin() +{ + return SparseMatIterator_<_Tp>(this); +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::begin() const +{ + return SparseMatConstIterator_<_Tp>(this); +} + +template inline +SparseMatIterator_<_Tp> SparseMat_<_Tp>::end() +{ + SparseMatIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + +template inline +SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::end() const +{ + SparseMatConstIterator_<_Tp> it(this); + it.seekEnd(); + return it; +} + + + +////////////////////////// MatConstIterator ///////////////////////// + +inline +MatConstIterator::MatConstIterator() + : m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0) +{} + +inline +MatConstIterator::MatConstIterator(const Mat* _m) + : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) +{ + if( m && m->isContinuous() ) + { + CV_Assert(!m->empty()); + sliceStart = m->ptr(); + sliceEnd = sliceStart + m->total()*elemSize; + } + seek((const int*)0); +} + +inline +MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col) + : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) +{ + CV_Assert(m && m->dims <= 2); + if( m->isContinuous() ) + { + CV_Assert(!m->empty()); + sliceStart = m->ptr(); + sliceEnd = sliceStart + m->total()*elemSize; + } + int idx[] = {_row, _col}; + seek(idx); +} + +inline +MatConstIterator::MatConstIterator(const Mat* _m, Point _pt) + : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) +{ + CV_Assert(m && m->dims <= 2); + if( m->isContinuous() ) + { + CV_Assert(!m->empty()); + sliceStart = m->ptr(); + sliceEnd = sliceStart + m->total()*elemSize; + } + int idx[] = {_pt.y, _pt.x}; + seek(idx); +} + +inline +MatConstIterator::MatConstIterator(const MatConstIterator& it) + : m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd) +{} + +inline +MatConstIterator& MatConstIterator::operator = (const MatConstIterator& it ) +{ + m = it.m; elemSize = it.elemSize; ptr = it.ptr; + sliceStart = it.sliceStart; sliceEnd = it.sliceEnd; + return *this; +} + +inline +const uchar* MatConstIterator::operator *() const +{ + return ptr; +} + +inline MatConstIterator& MatConstIterator::operator += (ptrdiff_t ofs) +{ + if( !m || ofs == 0 ) + return *this; + ptrdiff_t ofsb = ofs*elemSize; + ptr += ofsb; + if( ptr < sliceStart || sliceEnd <= ptr ) + { + ptr -= ofsb; + seek(ofs, true); + } + return *this; +} + +inline +MatConstIterator& MatConstIterator::operator -= (ptrdiff_t ofs) +{ + return (*this += -ofs); +} + +inline +MatConstIterator& MatConstIterator::operator --() +{ + if( m && (ptr -= elemSize) < sliceStart ) + { + ptr += elemSize; + seek(-1, true); + } + return *this; +} + +inline +MatConstIterator MatConstIterator::operator --(int) +{ + MatConstIterator b = *this; + *this += -1; + return b; +} + +inline +MatConstIterator& MatConstIterator::operator ++() +{ + if( m && (ptr += elemSize) >= sliceEnd ) + { + ptr -= elemSize; + seek(1, true); + } + return *this; +} + +inline MatConstIterator MatConstIterator::operator ++(int) +{ + MatConstIterator b = *this; + *this += 1; + return b; +} + + +static inline +bool operator == (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.m == b.m && a.ptr == b.ptr; +} + +static inline +bool operator != (const MatConstIterator& a, const MatConstIterator& b) +{ + return !(a == b); +} + +static inline +bool operator < (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr < b.ptr; +} + +static inline +bool operator > (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr > b.ptr; +} + +static inline +bool operator <= (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr <= b.ptr; +} + +static inline +bool operator >= (const MatConstIterator& a, const MatConstIterator& b) +{ + return a.ptr >= b.ptr; +} + +static inline +ptrdiff_t operator - (const MatConstIterator& b, const MatConstIterator& a) +{ + if( a.m != b.m ) + return ((size_t)(-1) >> 1); + if( a.sliceEnd == b.sliceEnd ) + return (b.ptr - a.ptr)/static_cast(b.elemSize); + + return b.lpos() - a.lpos(); +} + +static inline +MatConstIterator operator + (const MatConstIterator& a, ptrdiff_t ofs) +{ + MatConstIterator b = a; + return b += ofs; +} + +static inline +MatConstIterator operator + (ptrdiff_t ofs, const MatConstIterator& a) +{ + MatConstIterator b = a; + return b += ofs; +} + +static inline +MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t ofs) +{ + MatConstIterator b = a; + return b += -ofs; +} + + +inline +const uchar* MatConstIterator::operator [](ptrdiff_t i) const +{ + return *(*this + i); +} + + + +///////////////////////// MatConstIterator_ ///////////////////////// + +template inline +MatConstIterator_<_Tp>::MatConstIterator_() +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m) + : MatConstIterator(_m) +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col) + : MatConstIterator(_m, _row, _col) +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m, Point _pt) + : MatConstIterator(_m, _pt) +{} + +template inline +MatConstIterator_<_Tp>::MatConstIterator_(const MatConstIterator_& it) + : MatConstIterator(it) +{} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator = (const MatConstIterator_& it ) +{ + MatConstIterator::operator = (it); + return *this; +} + +template inline +const _Tp& MatConstIterator_<_Tp>::operator *() const +{ + return *(_Tp*)(this->ptr); +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator += (ptrdiff_t ofs) +{ + MatConstIterator::operator += (ofs); + return *this; +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator -= (ptrdiff_t ofs) +{ + return (*this += -ofs); +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator --() +{ + MatConstIterator::operator --(); + return *this; +} + +template inline +MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator --(int) +{ + MatConstIterator_ b = *this; + MatConstIterator::operator --(); + return b; +} + +template inline +MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator ++() +{ + MatConstIterator::operator ++(); + return *this; +} + +template inline +MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator ++(int) +{ + MatConstIterator_ b = *this; + MatConstIterator::operator ++(); + return b; +} + + +template inline +Point MatConstIterator_<_Tp>::pos() const +{ + if( !m ) + return Point(); + CV_DbgAssert( m->dims <= 2 ); + if( m->isContinuous() ) + { + ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m->data; + int y = (int)(ofs / m->cols); + int x = (int)(ofs - (ptrdiff_t)y * m->cols); + return Point(x, y); + } + else + { + ptrdiff_t ofs = (uchar*)ptr - m->data; + int y = (int)(ofs / m->step); + int x = (int)((ofs - y * m->step)/sizeof(_Tp)); + return Point(x, y); + } +} + + +template static inline +bool operator == (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) +{ + return a.m == b.m && a.ptr == b.ptr; +} + +template static inline +bool operator != (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) +{ + return a.m != b.m || a.ptr != b.ptr; +} + +template static inline +MatConstIterator_<_Tp> operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatConstIterator_<_Tp>&)t; +} + +template static inline +MatConstIterator_<_Tp> operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatConstIterator_<_Tp>&)t; +} + +template static inline +MatConstIterator_<_Tp> operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a - ofs; + return (MatConstIterator_<_Tp>&)t; +} + +template inline +const _Tp& MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const +{ + return *(_Tp*)MatConstIterator::operator [](i); +} + + + +//////////////////////////// MatIterator_ /////////////////////////// + +template inline +MatIterator_<_Tp>::MatIterator_() + : MatConstIterator_<_Tp>() +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m) + : MatConstIterator_<_Tp>(_m) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, int _row, int _col) + : MatConstIterator_<_Tp>(_m, _row, _col) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, Point _pt) + : MatConstIterator_<_Tp>(_m, _pt) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, const int* _idx) + : MatConstIterator_<_Tp>(_m, _idx) +{} + +template inline +MatIterator_<_Tp>::MatIterator_(const MatIterator_& it) + : MatConstIterator_<_Tp>(it) +{} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator = (const MatIterator_<_Tp>& it ) +{ + MatConstIterator::operator = (it); + return *this; +} + +template inline +_Tp& MatIterator_<_Tp>::operator *() const +{ + return *(_Tp*)(this->ptr); +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator += (ptrdiff_t ofs) +{ + MatConstIterator::operator += (ofs); + return *this; +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator -= (ptrdiff_t ofs) +{ + MatConstIterator::operator += (-ofs); + return *this; +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator --() +{ + MatConstIterator::operator --(); + return *this; +} + +template inline +MatIterator_<_Tp> MatIterator_<_Tp>::operator --(int) +{ + MatIterator_ b = *this; + MatConstIterator::operator --(); + return b; +} + +template inline +MatIterator_<_Tp>& MatIterator_<_Tp>::operator ++() +{ + MatConstIterator::operator ++(); + return *this; +} + +template inline +MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(int) +{ + MatIterator_ b = *this; + MatConstIterator::operator ++(); + return b; +} + +template inline +_Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const +{ + return *(*this + i); +} + + +template static inline +bool operator == (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) +{ + return a.m == b.m && a.ptr == b.ptr; +} + +template static inline +bool operator != (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) +{ + return a.m != b.m || a.ptr != b.ptr; +} + +template static inline +MatIterator_<_Tp> operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatIterator_<_Tp>&)t; +} + +template static inline +MatIterator_<_Tp> operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a) +{ + MatConstIterator t = (const MatConstIterator&)a + ofs; + return (MatIterator_<_Tp>&)t; +} + +template static inline +MatIterator_<_Tp> operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs) +{ + MatConstIterator t = (const MatConstIterator&)a - ofs; + return (MatIterator_<_Tp>&)t; +} + + + +/////////////////////// SparseMatConstIterator ////////////////////// + +inline +SparseMatConstIterator::SparseMatConstIterator() + : m(0), hashidx(0), ptr(0) +{} + +inline +SparseMatConstIterator::SparseMatConstIterator(const SparseMatConstIterator& it) + : m(it.m), hashidx(it.hashidx), ptr(it.ptr) +{} + +inline SparseMatConstIterator& SparseMatConstIterator::operator = (const SparseMatConstIterator& it) +{ + if( this != &it ) + { + m = it.m; + hashidx = it.hashidx; + ptr = it.ptr; + } + return *this; +} + +template inline +const _Tp& SparseMatConstIterator::value() const +{ + return *(const _Tp*)ptr; +} + +inline +const SparseMat::Node* SparseMatConstIterator::node() const +{ + return (ptr && m && m->hdr) ? (const SparseMat::Node*)(const void*)(ptr - m->hdr->valueOffset) : 0; +} + +inline +SparseMatConstIterator SparseMatConstIterator::operator ++(int) +{ + SparseMatConstIterator it = *this; + ++*this; + return it; +} + +inline +void SparseMatConstIterator::seekEnd() +{ + if( m && m->hdr ) + { + hashidx = m->hdr->hashtab.size(); + ptr = 0; + } +} + + +static inline +bool operator == (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) +{ + return it1.m == it2.m && it1.ptr == it2.ptr; +} + +static inline +bool operator != (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) +{ + return !(it1 == it2); +} + + + +///////////////////////// SparseMatIterator ///////////////////////// + +inline +SparseMatIterator::SparseMatIterator() +{} + +inline +SparseMatIterator::SparseMatIterator(SparseMat* _m) + : SparseMatConstIterator(_m) +{} + +inline +SparseMatIterator::SparseMatIterator(const SparseMatIterator& it) + : SparseMatConstIterator(it) +{} + +inline +SparseMatIterator& SparseMatIterator::operator = (const SparseMatIterator& it) +{ + (SparseMatConstIterator&)*this = it; + return *this; +} + +template inline +_Tp& SparseMatIterator::value() const +{ + return *(_Tp*)ptr; +} + +inline +SparseMat::Node* SparseMatIterator::node() const +{ + return (SparseMat::Node*)SparseMatConstIterator::node(); +} + +inline +SparseMatIterator& SparseMatIterator::operator ++() +{ + SparseMatConstIterator::operator ++(); + return *this; +} + +inline +SparseMatIterator SparseMatIterator::operator ++(int) +{ + SparseMatIterator it = *this; + ++*this; + return it; +} + + + +////////////////////// SparseMatConstIterator_ ////////////////////// + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_() +{} + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat_<_Tp>* _m) + : SparseMatConstIterator(_m) +{} + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat* _m) + : SparseMatConstIterator(_m) +{ + CV_Assert( _m->type() == traits::Type<_Tp>::value ); +} + +template inline +SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMatConstIterator_<_Tp>& it) + : SparseMatConstIterator(it) +{} + +template inline +SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator = (const SparseMatConstIterator_<_Tp>& it) +{ + return reinterpret_cast&> + (*reinterpret_cast(this) = + reinterpret_cast(it)); +} + +template inline +const _Tp& SparseMatConstIterator_<_Tp>::operator *() const +{ + return *(const _Tp*)this->ptr; +} + +template inline +SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator ++() +{ + SparseMatConstIterator::operator ++(); + return *this; +} + +template inline +SparseMatConstIterator_<_Tp> SparseMatConstIterator_<_Tp>::operator ++(int) +{ + SparseMatConstIterator_<_Tp> it = *this; + SparseMatConstIterator::operator ++(); + return it; +} + + + +///////////////////////// SparseMatIterator_ //////////////////////// + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_() +{} + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m) + : SparseMatConstIterator_<_Tp>(_m) +{} + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat* _m) + : SparseMatConstIterator_<_Tp>(_m) +{} + +template inline +SparseMatIterator_<_Tp>::SparseMatIterator_(const SparseMatIterator_<_Tp>& it) + : SparseMatConstIterator_<_Tp>(it) +{} + +template inline +SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator = (const SparseMatIterator_<_Tp>& it) +{ + return reinterpret_cast&> + (*reinterpret_cast(this) = + reinterpret_cast(it)); +} + +template inline +_Tp& SparseMatIterator_<_Tp>::operator *() const +{ + return *(_Tp*)this->ptr; +} + +template inline +SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator ++() +{ + SparseMatConstIterator::operator ++(); + return *this; +} + +template inline +SparseMatIterator_<_Tp> SparseMatIterator_<_Tp>::operator ++(int) +{ + SparseMatIterator_<_Tp> it = *this; + SparseMatConstIterator::operator ++(); + return it; +} + + + +//////////////////////// MatCommaInitializer_ /////////////////////// + +template inline +MatCommaInitializer_<_Tp>::MatCommaInitializer_(Mat_<_Tp>* _m) + : it(_m) +{} + +template template inline +MatCommaInitializer_<_Tp>& MatCommaInitializer_<_Tp>::operator , (T2 v) +{ + CV_DbgAssert( this->it < ((const Mat_<_Tp>*)this->it.m)->end() ); + *this->it = _Tp(v); + ++this->it; + return *this; +} + +template inline +MatCommaInitializer_<_Tp>::operator Mat_<_Tp>() const +{ + CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() ); + return Mat_<_Tp>(*this->it.m); +} + + +template static inline +MatCommaInitializer_<_Tp> operator << (const Mat_<_Tp>& m, T2 val) +{ + MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m); + return (commaInitializer, val); +} + + + +///////////////////////// Matrix Expressions //////////////////////// + +inline +Mat& Mat::operator = (const MatExpr& e) +{ + e.op->assign(e, *this); + return *this; +} + +template inline +Mat_<_Tp>::Mat_(const MatExpr& e) +{ + e.op->assign(e, *this, traits::Type<_Tp>::value); +} + +template inline +Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) +{ + e.op->assign(e, *this, traits::Type<_Tp>::value); + return *this; +} + +template inline +MatExpr Mat_<_Tp>::zeros(int rows, int cols) +{ + return Mat::zeros(rows, cols, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::zeros(Size sz) +{ + return Mat::zeros(sz, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::ones(int rows, int cols) +{ + return Mat::ones(rows, cols, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::ones(Size sz) +{ + return Mat::ones(sz, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::eye(int rows, int cols) +{ + return Mat::eye(rows, cols, traits::Type<_Tp>::value); +} + +template inline +MatExpr Mat_<_Tp>::eye(Size sz) +{ + return Mat::eye(sz, traits::Type<_Tp>::value); +} + +inline +MatExpr::MatExpr() + : op(0), flags(0), a(Mat()), b(Mat()), c(Mat()), alpha(0), beta(0), s() +{} + +inline +MatExpr::MatExpr(const MatOp* _op, int _flags, const Mat& _a, const Mat& _b, + const Mat& _c, double _alpha, double _beta, const Scalar& _s) + : op(_op), flags(_flags), a(_a), b(_b), c(_c), alpha(_alpha), beta(_beta), s(_s) +{} + +inline +MatExpr::operator Mat() const +{ + Mat m; + op->assign(*this, m); + return m; +} + +template inline +MatExpr::operator Mat_<_Tp>() const +{ + Mat_<_Tp> m; + op->assign(*this, m, traits::Type<_Tp>::value); + return m; +} + + +template static inline +MatExpr min(const Mat_<_Tp>& a, const Mat_<_Tp>& b) +{ + return cv::min((const Mat&)a, (const Mat&)b); +} + +template static inline +MatExpr min(const Mat_<_Tp>& a, double s) +{ + return cv::min((const Mat&)a, s); +} + +template static inline +MatExpr min(double s, const Mat_<_Tp>& a) +{ + return cv::min((const Mat&)a, s); +} + +template static inline +MatExpr max(const Mat_<_Tp>& a, const Mat_<_Tp>& b) +{ + return cv::max((const Mat&)a, (const Mat&)b); +} + +template static inline +MatExpr max(const Mat_<_Tp>& a, double s) +{ + return cv::max((const Mat&)a, s); +} + +template static inline +MatExpr max(double s, const Mat_<_Tp>& a) +{ + return cv::max((const Mat&)a, s); +} + +template static inline +MatExpr abs(const Mat_<_Tp>& m) +{ + return cv::abs((const Mat&)m); +} + + +static inline +Mat& operator += (Mat& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, a); + return a; +} + +static inline +const Mat& operator += (const Mat& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator += (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignAdd(b, (Mat&)a); + return a; +} + +static inline +Mat& operator -= (Mat& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, a); + return a; +} + +static inline +const Mat& operator -= (const Mat& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator -= (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignSubtract(b, (Mat&)a); + return a; +} + +static inline +Mat& operator *= (Mat& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, a); + return a; +} + +static inline +const Mat& operator *= (const Mat& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator *= (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignMultiply(b, (Mat&)a); + return a; +} + +static inline +Mat& operator /= (Mat& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, a); + return a; +} + +static inline +const Mat& operator /= (const Mat& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, (Mat&)a); + return a; +} + +template static inline +Mat_<_Tp>& operator /= (Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, a); + return a; +} + +template static inline +const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) +{ + b.op->augAssignDivide(b, (Mat&)a); + return a; +} + + +//////////////////////////////// UMat //////////////////////////////// + +template inline +UMat::UMat(const std::vector<_Tp>& vec, bool copyData) +: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), +cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) +{ + if(vec.empty()) + return; + if( !copyData ) + { + // !!!TODO!!! + CV_Error(Error::StsNotImplemented, ""); + } + else + Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); +} + +inline +UMat UMat::row(int y) const +{ + return UMat(*this, Range(y, y + 1), Range::all()); +} + +inline +UMat UMat::col(int x) const +{ + return UMat(*this, Range::all(), Range(x, x + 1)); +} + +inline +UMat UMat::rowRange(int startrow, int endrow) const +{ + return UMat(*this, Range(startrow, endrow), Range::all()); +} + +inline +UMat UMat::rowRange(const Range& r) const +{ + return UMat(*this, r, Range::all()); +} + +inline +UMat UMat::colRange(int startcol, int endcol) const +{ + return UMat(*this, Range::all(), Range(startcol, endcol)); +} + +inline +UMat UMat::colRange(const Range& r) const +{ + return UMat(*this, Range::all(), r); +} + +inline +UMat UMat::operator()( Range _rowRange, Range _colRange ) const +{ + return UMat(*this, _rowRange, _colRange); +} + +inline +UMat UMat::operator()( const Rect& roi ) const +{ + return UMat(*this, roi); +} + +inline +UMat UMat::operator()(const Range* ranges) const +{ + return UMat(*this, ranges); +} + +inline +UMat UMat::operator()(const std::vector& ranges) const +{ + return UMat(*this, ranges); +} + +inline +bool UMat::isContinuous() const +{ + return (flags & CONTINUOUS_FLAG) != 0; +} + +inline +bool UMat::isSubmatrix() const +{ + return (flags & SUBMATRIX_FLAG) != 0; +} + +inline +size_t UMat::elemSize() const +{ + size_t res = dims > 0 ? step.p[dims - 1] : 0; + CV_DbgAssert(res != 0); + return res; +} + +inline +size_t UMat::elemSize1() const +{ + return CV_ELEM_SIZE1(flags); +} + +inline +int UMat::type() const +{ + return CV_MAT_TYPE(flags); +} + +inline +int UMat::depth() const +{ + return CV_MAT_DEPTH(flags); +} + +inline +int UMat::channels() const +{ + return CV_MAT_CN(flags); +} + +inline +size_t UMat::step1(int i) const +{ + return step.p[i] / elemSize1(); +} + + +inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; } +inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; } +inline bool UMatData::deviceMemMapped() const { return (flags & DEVICE_MEM_MAPPED) != 0; } +inline bool UMatData::copyOnMap() const { return (flags & COPY_ON_MAP) != 0; } +inline bool UMatData::tempUMat() const { return (flags & TEMP_UMAT) != 0; } +inline bool UMatData::tempCopiedUMat() const { return (flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; } + +inline void UMatData::markDeviceMemMapped(bool flag) +{ + if(flag) + flags |= DEVICE_MEM_MAPPED; + else + flags &= ~DEVICE_MEM_MAPPED; +} + +inline void UMatData::markHostCopyObsolete(bool flag) +{ + if(flag) + flags |= HOST_COPY_OBSOLETE; + else + flags &= ~HOST_COPY_OBSOLETE; +} +inline void UMatData::markDeviceCopyObsolete(bool flag) +{ + if(flag) + flags |= DEVICE_COPY_OBSOLETE; + else + flags &= ~DEVICE_COPY_OBSOLETE; +} + +//! @endcond + +static inline +void swap(MatExpr& a, MatExpr& b) { a.swap(b); } + +} //cv + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#ifdef CV_DISABLE_CLANG_ENUM_WARNINGS +#undef CV_DISABLE_CLANG_ENUM_WARNINGS +#pragma clang diagnostic pop +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/matx.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/matx.hpp new file mode 100644 index 0000000..3c92e3a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/matx.hpp @@ -0,0 +1,1508 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_MATX_HPP +#define OPENCV_CORE_MATX_HPP + +#ifndef __cplusplus +# error matx.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/base.hpp" +#include "opencv2/core/traits.hpp" +#include "opencv2/core/saturate.hpp" + +#include + +namespace cv +{ + +//! @addtogroup core_basic +//! @{ + +////////////////////////////// Small Matrix /////////////////////////// + +//! @cond IGNORED +// FIXIT Remove this (especially CV_EXPORTS modifier) +struct CV_EXPORTS Matx_AddOp { Matx_AddOp() {} Matx_AddOp(const Matx_AddOp&) {} }; +struct CV_EXPORTS Matx_SubOp { Matx_SubOp() {} Matx_SubOp(const Matx_SubOp&) {} }; +struct CV_EXPORTS Matx_ScaleOp { Matx_ScaleOp() {} Matx_ScaleOp(const Matx_ScaleOp&) {} }; +struct CV_EXPORTS Matx_MulOp { Matx_MulOp() {} Matx_MulOp(const Matx_MulOp&) {} }; +struct CV_EXPORTS Matx_DivOp { Matx_DivOp() {} Matx_DivOp(const Matx_DivOp&) {} }; +struct CV_EXPORTS Matx_MatMulOp { Matx_MatMulOp() {} Matx_MatMulOp(const Matx_MatMulOp&) {} }; +struct CV_EXPORTS Matx_TOp { Matx_TOp() {} Matx_TOp(const Matx_TOp&) {} }; +//! @endcond + +/** @brief Template class for small matrices whose type and size are known at compilation time + +If you need a more flexible type, use Mat . The elements of the matrix M are accessible using the +M(i,j) notation. Most of the common matrix operations (see also @ref MatrixExpressions ) are +available. To do an operation on Matx that is not implemented, you can easily convert the matrix to +Mat and backwards: +@code{.cpp} + Matx33f m(1, 2, 3, + 4, 5, 6, + 7, 8, 9); + cout << sum(Mat(m*m.t())) << endl; +@endcode +Except of the plain constructor which takes a list of elements, Matx can be initialized from a C-array: +@code{.cpp} + float values[] = { 1, 2, 3}; + Matx31f m(values); +@endcode +In case if C++11 features are available, std::initializer_list can be also used to initialize Matx: +@code{.cpp} + Matx31f m = { 1, 2, 3}; +@endcode + */ +template class Matx +{ +public: + enum { + rows = m, + cols = n, + channels = rows*cols, +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + depth = traits::Type<_Tp>::value, + type = CV_MAKETYPE(depth, channels), +#endif + shortdim = (m < n ? m : n) + }; + + typedef _Tp value_type; + typedef Matx<_Tp, m, n> mat_type; + typedef Matx<_Tp, shortdim, 1> diag_type; + + //! default constructor + Matx(); + + explicit Matx(_Tp v0); //!< 1x1 matrix + Matx(_Tp v0, _Tp v1); //!< 1x2 or 2x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2); //!< 1x3 or 3x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 1x4, 2x2 or 4x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 1x5 or 5x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 1x6, 2x3, 3x2 or 6x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 1x7 or 7x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 1x8, 2x4, 4x2 or 8x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 1x9, 3x3 or 9x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 1x10, 2x5 or 5x2 or 10x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, + _Tp v4, _Tp v5, _Tp v6, _Tp v7, + _Tp v8, _Tp v9, _Tp v10, _Tp v11); //!< 1x12, 2x6, 3x4, 4x3, 6x2 or 12x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, + _Tp v4, _Tp v5, _Tp v6, _Tp v7, + _Tp v8, _Tp v9, _Tp v10, _Tp v11, + _Tp v12, _Tp v13); //!< 1x14, 2x7, 7x2 or 14x1 matrix + Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, + _Tp v4, _Tp v5, _Tp v6, _Tp v7, + _Tp v8, _Tp v9, _Tp v10, _Tp v11, + _Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix + explicit Matx(const _Tp* vals); //!< initialize from a plain array + + Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list + + CV_NODISCARD_STD static Matx all(_Tp alpha); + CV_NODISCARD_STD static Matx zeros(); + CV_NODISCARD_STD static Matx ones(); + CV_NODISCARD_STD static Matx eye(); + CV_NODISCARD_STD static Matx diag(const diag_type& d); + /** @brief Generates uniformly distributed random numbers + @param a Range boundary. + @param b The other range boundary (boundaries don't have to be ordered, the lower boundary is inclusive, + the upper one is exclusive). + */ + CV_NODISCARD_STD static Matx randu(_Tp a, _Tp b); + /** @brief Generates normally distributed random numbers + @param a Mean value. + @param b Standard deviation. + */ + CV_NODISCARD_STD static Matx randn(_Tp a, _Tp b); + + //! dot product computed with the default precision + _Tp dot(const Matx<_Tp, m, n>& v) const; + + //! dot product computed in double-precision arithmetics + double ddot(const Matx<_Tp, m, n>& v) const; + + //! conversion to another data type + template operator Matx() const; + + //! change the matrix shape + template Matx<_Tp, m1, n1> reshape() const; + + //! extract part of the matrix + template Matx<_Tp, m1, n1> get_minor(int base_row, int base_col) const; + + //! extract the matrix row + Matx<_Tp, 1, n> row(int i) const; + + //! extract the matrix column + Matx<_Tp, m, 1> col(int i) const; + + //! extract the matrix diagonal + diag_type diag() const; + + //! transpose the matrix + Matx<_Tp, n, m> t() const; + + //! invert the matrix + Matx<_Tp, n, m> inv(int method=DECOMP_LU, bool *p_is_ok = NULL) const; + + //! solve linear system + template Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const; + Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const; + + //! multiply two matrices element-wise + Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const; + + //! divide two matrices element-wise + Matx<_Tp, m, n> div(const Matx<_Tp, m, n>& a) const; + + //! element access + const _Tp& operator ()(int row, int col) const; + _Tp& operator ()(int row, int col); + + //! 1D element access + const _Tp& operator ()(int i) const; + _Tp& operator ()(int i); + + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp); + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp); + template Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp); + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp); + Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp); + template Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp); + Matx(const Matx<_Tp, n, m>& a, Matx_TOp); + + _Tp val[m*n]; //< matrix elements +}; + +typedef Matx Matx12f; +typedef Matx Matx12d; +typedef Matx Matx13f; +typedef Matx Matx13d; +typedef Matx Matx14f; +typedef Matx Matx14d; +typedef Matx Matx16f; +typedef Matx Matx16d; + +typedef Matx Matx21f; +typedef Matx Matx21d; +typedef Matx Matx31f; +typedef Matx Matx31d; +typedef Matx Matx41f; +typedef Matx Matx41d; +typedef Matx Matx61f; +typedef Matx Matx61d; + +typedef Matx Matx22f; +typedef Matx Matx22d; +typedef Matx Matx23f; +typedef Matx Matx23d; +typedef Matx Matx32f; +typedef Matx Matx32d; + +typedef Matx Matx33f; +typedef Matx Matx33d; + +typedef Matx Matx34f; +typedef Matx Matx34d; +typedef Matx Matx43f; +typedef Matx Matx43d; + +typedef Matx Matx44f; +typedef Matx Matx44d; +typedef Matx Matx66f; +typedef Matx Matx66d; + +/*! + traits +*/ +template class DataType< Matx<_Tp, m, n> > +{ +public: + typedef Matx<_Tp, m, n> value_type; + typedef Matx::work_type, m, n> work_type; + typedef _Tp channel_type; + typedef value_type vec_type; + + enum { generic_type = 0, + channels = m * n, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; +}; + +namespace traits { +template +struct Depth< Matx<_Tp, m, n> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Matx<_Tp, m, n> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, n*m) }; }; +} // namespace + + +/** @brief Comma-separated Matrix Initializer +*/ +template class MatxCommaInitializer +{ +public: + MatxCommaInitializer(Matx<_Tp, m, n>* _mtx); + template MatxCommaInitializer<_Tp, m, n>& operator , (T2 val); + Matx<_Tp, m, n> operator *() const; + + Matx<_Tp, m, n>* dst; + int idx; +}; + +/* + Utility methods +*/ +template static double determinant(const Matx<_Tp, m, m>& a); +template static double trace(const Matx<_Tp, m, n>& a); +template static double norm(const Matx<_Tp, m, n>& M); +template static double norm(const Matx<_Tp, m, n>& M, int normType); + + + +/////////////////////// Vec (used as element of multi-channel images ///////////////////// + +/** @brief Template class for short numerical vectors, a partial case of Matx + +This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) on which you +can perform basic arithmetical operations, access individual elements using [] operator etc. The +vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., which +elements are dynamically allocated in the heap. + +The template takes 2 parameters: +@tparam _Tp element type +@tparam cn the number of elements + +In addition to the universal notation like Vec, you can use shorter aliases +for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec. + +It is possible to convert Vec\ to/from Point_, Vec\ to/from Point3_ , and Vec\ +to CvScalar or Scalar_. Use operator[] to access the elements of Vec. + +All the expected vector operations are also implemented: +- v1 = v2 + v3 +- v1 = v2 - v3 +- v1 = v2 \* scale +- v1 = scale \* v2 +- v1 = -v2 +- v1 += v2 and other augmenting operations +- v1 == v2, v1 != v2 +- norm(v1) (euclidean norm) +The Vec class is commonly used to describe pixel types of multi-channel arrays. See Mat for details. +*/ +template class Vec : public Matx<_Tp, cn, 1> +{ +public: + typedef _Tp value_type; + enum { + channels = cn, +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + depth = Matx<_Tp, cn, 1>::depth, + type = CV_MAKETYPE(depth, channels), +#endif + _dummy_enum_finalizer = 0 + }; + + //! default constructor + Vec(); + + Vec(_Tp v0); //!< 1-element vector constructor + Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor + Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor + explicit Vec(const _Tp* values); + + Vec(std::initializer_list<_Tp>); + + Vec(const Vec<_Tp, cn>& v); + + static Vec all(_Tp alpha); + + //! per-element multiplication + Vec mul(const Vec<_Tp, cn>& v) const; + + //! conjugation (makes sense for complex numbers and quaternions) + Vec conj() const; + + /*! + cross product of the two 3D vectors. + + For other dimensionalities the exception is raised + */ + Vec cross(const Vec& v) const; + //! conversion to another data type + template operator Vec() const; + + /*! element access */ + const _Tp& operator [](int i) const; + _Tp& operator[](int i); + const _Tp& operator ()(int i) const; + _Tp& operator ()(int i); + +#ifdef CV_CXX11 + Vec<_Tp, cn>& operator=(const Vec<_Tp, cn>& rhs) = default; +#endif + + Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp); + Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp); + template Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp); +}; + +/** @name Shorter aliases for the most popular specializations of Vec + @{ +*/ +typedef Vec Vec2b; +typedef Vec Vec3b; +typedef Vec Vec4b; + +typedef Vec Vec2s; +typedef Vec Vec3s; +typedef Vec Vec4s; + +typedef Vec Vec2w; +typedef Vec Vec3w; +typedef Vec Vec4w; + +typedef Vec Vec2i; +typedef Vec Vec3i; +typedef Vec Vec4i; +typedef Vec Vec6i; +typedef Vec Vec8i; + +typedef Vec Vec2f; +typedef Vec Vec3f; +typedef Vec Vec4f; +typedef Vec Vec6f; + +typedef Vec Vec2d; +typedef Vec Vec3d; +typedef Vec Vec4d; +typedef Vec Vec6d; +/** @} */ + +/*! + traits +*/ +template class DataType< Vec<_Tp, cn> > +{ +public: + typedef Vec<_Tp, cn> value_type; + typedef Vec::work_type, cn> work_type; + typedef _Tp channel_type; + typedef value_type vec_type; + + enum { generic_type = 0, + channels = cn, + fmt = DataType::fmt + ((channels - 1) << 8), +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + depth = DataType::depth, + type = CV_MAKETYPE(depth, channels), +#endif + _dummy_enum_finalizer = 0 + }; +}; + +namespace traits { +template +struct Depth< Vec<_Tp, cn> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Vec<_Tp, cn> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, cn) }; }; +} // namespace + + +/** @brief Comma-separated Vec Initializer +*/ +template class VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1> +{ +public: + VecCommaInitializer(Vec<_Tp, m>* _vec); + template VecCommaInitializer<_Tp, m>& operator , (T2 val); + Vec<_Tp, m> operator *() const; +}; + +template static Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v); + +//! @} core_basic + +//! @cond IGNORED + +///////////////////////////////////// helper classes ///////////////////////////////////// +namespace internal +{ + +template struct Matx_DetOp +{ + double operator ()(const Matx<_Tp, m, m>& a) const + { + Matx<_Tp, m, m> temp = a; + double p = LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0); + if( p == 0 ) + return p; + for( int i = 0; i < m; i++ ) + p *= temp(i, i); + return p; + } +}; + +template struct Matx_DetOp<_Tp, 1> +{ + double operator ()(const Matx<_Tp, 1, 1>& a) const + { + return a(0,0); + } +}; + +template struct Matx_DetOp<_Tp, 2> +{ + double operator ()(const Matx<_Tp, 2, 2>& a) const + { + return a(0,0)*a(1,1) - a(0,1)*a(1,0); + } +}; + +template struct Matx_DetOp<_Tp, 3> +{ + double operator ()(const Matx<_Tp, 3, 3>& a) const + { + return a(0,0)*(a(1,1)*a(2,2) - a(2,1)*a(1,2)) - + a(0,1)*(a(1,0)*a(2,2) - a(2,0)*a(1,2)) + + a(0,2)*(a(1,0)*a(2,1) - a(2,0)*a(1,1)); + } +}; + +template Vec<_Tp, 2> inline conjugate(const Vec<_Tp, 2>& v) +{ + return Vec<_Tp, 2>(v[0], -v[1]); +} + +template Vec<_Tp, 4> inline conjugate(const Vec<_Tp, 4>& v) +{ + return Vec<_Tp, 4>(v[0], -v[1], -v[2], -v[3]); +} + +} // internal + + + +////////////////////////////////// Matx Implementation /////////////////////////////////// + +template inline +Matx<_Tp, m, n>::Matx() +{ + for(int i = 0; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0) +{ + val[0] = v0; + for(int i = 1; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1) +{ + CV_StaticAssert(channels >= 2, "Matx should have at least 2 elements."); + val[0] = v0; val[1] = v1; + for(int i = 2; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2) +{ + CV_StaticAssert(channels >= 3, "Matx should have at least 3 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; + for(int i = 3; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3) +{ + CV_StaticAssert(channels >= 4, "Matx should have at least 4 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + for(int i = 4; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4) +{ + CV_StaticAssert(channels >= 5, "Matx should have at least 5 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; val[4] = v4; + for(int i = 5; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5) +{ + CV_StaticAssert(channels >= 6, "Matx should have at least 6 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; + for(int i = 6; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6) +{ + CV_StaticAssert(channels >= 7, "Matx should have at least 7 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; + for(int i = 7; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7) +{ + CV_StaticAssert(channels >= 8, "Matx should have at least 8 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + for(int i = 8; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8) +{ + CV_StaticAssert(channels >= 9, "Matx should have at least 9 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; + for(int i = 9; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9) +{ + CV_StaticAssert(channels >= 10, "Matx should have at least 10 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; + for(int i = 10; i < channels; i++) val[i] = _Tp(0); +} + + +template inline +Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11) +{ + CV_StaticAssert(channels >= 12, "Matx should have at least 12 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; + for(int i = 12; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13) +{ + CV_StaticAssert(channels >= 14, "Matx should have at least 14 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; + val[12] = v12; val[13] = v13; + for (int i = 14; i < channels; i++) val[i] = _Tp(0); +} + + +template inline +Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13, _Tp v14, _Tp v15) +{ + CV_StaticAssert(channels >= 16, "Matx should have at least 16 elements."); + val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; + val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; + val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; + val[12] = v12; val[13] = v13; val[14] = v14; val[15] = v15; + for(int i = 16; i < channels; i++) val[i] = _Tp(0); +} + +template inline +Matx<_Tp, m, n>::Matx(const _Tp* values) +{ + for( int i = 0; i < channels; i++ ) val[i] = values[i]; +} + +template inline +Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list) +{ + CV_DbgAssert(list.size() == channels); + int i = 0; + for(const auto& elem : list) + { + val[i++] = elem; + } +} + +template inline +Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha) +{ + Matx<_Tp, m, n> M; + for( int i = 0; i < m*n; i++ ) M.val[i] = alpha; + return M; +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::zeros() +{ + return all(0); +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::ones() +{ + return all(1); +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::eye() +{ + Matx<_Tp,m,n> M; + for(int i = 0; i < shortdim; i++) + M(i,i) = 1; + return M; +} + +template inline +_Tp Matx<_Tp, m, n>::dot(const Matx<_Tp, m, n>& M) const +{ + _Tp s = 0; + for( int i = 0; i < channels; i++ ) s += val[i]*M.val[i]; + return s; +} + +template inline +double Matx<_Tp, m, n>::ddot(const Matx<_Tp, m, n>& M) const +{ + double s = 0; + for( int i = 0; i < channels; i++ ) s += (double)val[i]*M.val[i]; + return s; +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const typename Matx<_Tp,m,n>::diag_type& d) +{ + Matx<_Tp,m,n> M; + for(int i = 0; i < shortdim; i++) + M(i,i) = d(i, 0); + return M; +} + +template template +inline Matx<_Tp, m, n>::operator Matx() const +{ + Matx M; + for( int i = 0; i < m*n; i++ ) M.val[i] = saturate_cast(val[i]); + return M; +} + +template template inline +Matx<_Tp, m1, n1> Matx<_Tp, m, n>::reshape() const +{ + CV_StaticAssert(m1*n1 == m*n, "Input and destnarion matrices must have the same number of elements"); + return (const Matx<_Tp, m1, n1>&)*this; +} + +template +template inline +Matx<_Tp, m1, n1> Matx<_Tp, m, n>::get_minor(int base_row, int base_col) const +{ + CV_DbgAssert(0 <= base_row && base_row+m1 <= m && 0 <= base_col && base_col+n1 <= n); + Matx<_Tp, m1, n1> s; + for( int di = 0; di < m1; di++ ) + for( int dj = 0; dj < n1; dj++ ) + s(di, dj) = (*this)(base_row+di, base_col+dj); + return s; +} + +template inline +Matx<_Tp, 1, n> Matx<_Tp, m, n>::row(int i) const +{ + CV_DbgAssert((unsigned)i < (unsigned)m); + return Matx<_Tp, 1, n>(&val[i*n]); +} + +template inline +Matx<_Tp, m, 1> Matx<_Tp, m, n>::col(int j) const +{ + CV_DbgAssert((unsigned)j < (unsigned)n); + Matx<_Tp, m, 1> v; + for( int i = 0; i < m; i++ ) + v.val[i] = val[i*n + j]; + return v; +} + +template inline +typename Matx<_Tp, m, n>::diag_type Matx<_Tp, m, n>::diag() const +{ + diag_type d; + for( int i = 0; i < shortdim; i++ ) + d.val[i] = val[i*n + i]; + return d; +} + +template inline +const _Tp& Matx<_Tp, m, n>::operator()(int row_idx, int col_idx) const +{ + CV_DbgAssert( (unsigned)row_idx < (unsigned)m && (unsigned)col_idx < (unsigned)n ); + return this->val[row_idx*n + col_idx]; +} + +template inline +_Tp& Matx<_Tp, m, n>::operator ()(int row_idx, int col_idx) +{ + CV_DbgAssert( (unsigned)row_idx < (unsigned)m && (unsigned)col_idx < (unsigned)n ); + return val[row_idx*n + col_idx]; +} + +template inline +const _Tp& Matx<_Tp, m, n>::operator ()(int i) const +{ + CV_StaticAssert(m == 1 || n == 1, "Single index indexation requires matrix to be a column or a row"); + CV_DbgAssert( (unsigned)i < (unsigned)(m+n-1) ); + return val[i]; +} + +template inline +_Tp& Matx<_Tp, m, n>::operator ()(int i) +{ + CV_StaticAssert(m == 1 || n == 1, "Single index indexation requires matrix to be a column or a row"); + CV_DbgAssert( (unsigned)i < (unsigned)(m+n-1) ); + return val[i]; +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] + b.val[i]); +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] - b.val[i]); +} + +template template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] * alpha); +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] * b.val[i]); +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_DivOp) +{ + for( int i = 0; i < channels; i++ ) + val[i] = saturate_cast<_Tp>(a.val[i] / b.val[i]); +} + +template template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp) +{ + for( int i = 0; i < m; i++ ) + for( int j = 0; j < n; j++ ) + { + _Tp s = 0; + for( int k = 0; k < l; k++ ) + s += a(i, k) * b(k, j); + val[i*n + j] = s; + } +} + +template inline +Matx<_Tp,m,n>::Matx(const Matx<_Tp, n, m>& a, Matx_TOp) +{ + for( int i = 0; i < m; i++ ) + for( int j = 0; j < n; j++ ) + val[i*n + j] = a(j, i); +} + +template inline +Matx<_Tp, m, n> Matx<_Tp, m, n>::mul(const Matx<_Tp, m, n>& a) const +{ + return Matx<_Tp, m, n>(*this, a, Matx_MulOp()); +} + +template inline +Matx<_Tp, m, n> Matx<_Tp, m, n>::div(const Matx<_Tp, m, n>& a) const +{ + return Matx<_Tp, m, n>(*this, a, Matx_DivOp()); +} + +template inline +Matx<_Tp, n, m> Matx<_Tp, m, n>::t() const +{ + return Matx<_Tp, n, m>(*this, Matx_TOp()); +} + +template inline +Vec<_Tp, n> Matx<_Tp, m, n>::solve(const Vec<_Tp, m>& rhs, int method) const +{ + Matx<_Tp, n, 1> x = solve((const Matx<_Tp, m, 1>&)(rhs), method); + return (Vec<_Tp, n>&)(x); +} + +template static inline +double determinant(const Matx<_Tp, m, m>& a) +{ + return cv::internal::Matx_DetOp<_Tp, m>()(a); +} + +template static inline +double trace(const Matx<_Tp, m, n>& a) +{ + _Tp s = 0; + for( int i = 0; i < std::min(m, n); i++ ) + s += a(i,i); + return s; +} + +template static inline +double norm(const Matx<_Tp, m, n>& M) +{ + return std::sqrt(normL2Sqr<_Tp, double>(M.val, m*n)); +} + +template static inline +double norm(const Matx<_Tp, m, n>& M, int normType) +{ + switch(normType) { + case NORM_INF: + return (double)normInf<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n); + case NORM_L1: + return (double)normL1<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n); + case NORM_L2SQR: + return (double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n); + default: + case NORM_L2: + return std::sqrt((double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.val, m*n)); + } +} + + + +//////////////////////////////// matx comma initializer ////////////////////////////////// + +template static inline +MatxCommaInitializer<_Tp, m, n> operator << (const Matx<_Tp, m, n>& mtx, _T2 val) +{ + MatxCommaInitializer<_Tp, m, n> commaInitializer((Matx<_Tp, m, n>*)&mtx); + return (commaInitializer, val); +} + +template inline +MatxCommaInitializer<_Tp, m, n>::MatxCommaInitializer(Matx<_Tp, m, n>* _mtx) + : dst(_mtx), idx(0) +{} + +template template inline +MatxCommaInitializer<_Tp, m, n>& MatxCommaInitializer<_Tp, m, n>::operator , (_T2 value) +{ + CV_DbgAssert( idx < m*n ); + dst->val[idx++] = saturate_cast<_Tp>(value); + return *this; +} + +template inline +Matx<_Tp, m, n> MatxCommaInitializer<_Tp, m, n>::operator *() const +{ + CV_DbgAssert( idx == n*m ); + return *dst; +} + + + +/////////////////////////////////// Vec Implementation /////////////////////////////////// + +template inline +Vec<_Tp, cn>::Vec() {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0) + : Matx<_Tp, cn, 1>(v0) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1) + : Matx<_Tp, cn, 1>(v0, v1) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2) + : Matx<_Tp, cn, 1>(v0, v1, v2) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {} + +template inline +Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13) + : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) {} + +template inline +Vec<_Tp, cn>::Vec(const _Tp* values) + : Matx<_Tp, cn, 1>(values) {} + +template inline +Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list) + : Matx<_Tp, cn, 1>(list) {} + +template inline +Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m) + : Matx<_Tp, cn, 1>(m.val) {} + +template inline +Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp op) + : Matx<_Tp, cn, 1>(a, b, op) {} + +template inline +Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp op) + : Matx<_Tp, cn, 1>(a, b, op) {} + +template template inline +Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp op) + : Matx<_Tp, cn, 1>(a, alpha, op) {} + +template inline +Vec<_Tp, cn> Vec<_Tp, cn>::all(_Tp alpha) +{ + Vec v; + for( int i = 0; i < cn; i++ ) v.val[i] = alpha; + return v; +} + +template inline +Vec<_Tp, cn> Vec<_Tp, cn>::mul(const Vec<_Tp, cn>& v) const +{ + Vec<_Tp, cn> w; + for( int i = 0; i < cn; i++ ) w.val[i] = saturate_cast<_Tp>(this->val[i]*v.val[i]); + return w; +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template<> inline +Vec Vec::conj() const +{ + return cv::internal::conjugate(*this); +} + +template inline +Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>&) const +{ + CV_StaticAssert(cn == 3, "for arbitrary-size vector there is no cross-product defined"); + return Vec<_Tp, cn>(); +} + +template<> inline +Vec Vec::cross(const Vec& v) const +{ + return Vec(this->val[1]*v.val[2] - this->val[2]*v.val[1], + this->val[2]*v.val[0] - this->val[0]*v.val[2], + this->val[0]*v.val[1] - this->val[1]*v.val[0]); +} + +template<> inline +Vec Vec::cross(const Vec& v) const +{ + return Vec(this->val[1]*v.val[2] - this->val[2]*v.val[1], + this->val[2]*v.val[0] - this->val[0]*v.val[2], + this->val[0]*v.val[1] - this->val[1]*v.val[0]); +} + +template template inline +Vec<_Tp, cn>::operator Vec() const +{ + Vec v; + for( int i = 0; i < cn; i++ ) v.val[i] = saturate_cast(this->val[i]); + return v; +} + +template inline +const _Tp& Vec<_Tp, cn>::operator [](int i) const +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +_Tp& Vec<_Tp, cn>::operator [](int i) +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +const _Tp& Vec<_Tp, cn>::operator ()(int i) const +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +_Tp& Vec<_Tp, cn>::operator ()(int i) +{ + CV_DbgAssert( (unsigned)i < (unsigned)cn ); + return this->val[i]; +} + +template inline +Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v) +{ + double nv = norm(v); + return v * (nv ? 1./nv : 0.); +} + + + +//////////////////////////////// vec comma initializer ////////////////////////////////// + + +template static inline +VecCommaInitializer<_Tp, cn> operator << (const Vec<_Tp, cn>& vec, _T2 val) +{ + VecCommaInitializer<_Tp, cn> commaInitializer((Vec<_Tp, cn>*)&vec); + return (commaInitializer, val); +} + +template inline +VecCommaInitializer<_Tp, cn>::VecCommaInitializer(Vec<_Tp, cn>* _vec) + : MatxCommaInitializer<_Tp, cn, 1>(_vec) +{} + +template template inline +VecCommaInitializer<_Tp, cn>& VecCommaInitializer<_Tp, cn>::operator , (_T2 value) +{ + CV_DbgAssert( this->idx < cn ); + this->dst->val[this->idx++] = saturate_cast<_Tp>(value); + return *this; +} + +template inline +Vec<_Tp, cn> VecCommaInitializer<_Tp, cn>::operator *() const +{ + CV_DbgAssert( this->idx == cn ); + return *this->dst; +} + +//! @endcond + +///////////////////////////// Matx out-of-class operators //////////////////////////////// + +//! @relates cv::Matx +//! @{ + +template static inline +Matx<_Tp1, m, n>& operator += (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]); + return a; +} + +template static inline +Matx<_Tp1, m, n>& operator -= (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]); + return a; +} + +template static inline +Matx<_Tp, m, n> operator + (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + return Matx<_Tp, m, n>(a, b, Matx_AddOp()); +} + +template static inline +Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + return Matx<_Tp, m, n>(a, b, Matx_SubOp()); +} + +template static inline +Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, int alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); + return a; +} + +template static inline +Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, float alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); + return a; +} + +template static inline +Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, double alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); + return a; +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, int alpha) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, float alpha) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, double alpha) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (int alpha, const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (float alpha, const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, float alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = a.val[i] / alpha; + return a; +} + +template static inline +Matx<_Tp, m, n>& operator /= (Matx<_Tp, m, n>& a, double alpha) +{ + for( int i = 0; i < m*n; i++ ) + a.val[i] = a.val[i] / alpha; + return a; +} + +template static inline +Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha) +{ + return Matx<_Tp, m, n>(a, 1.f/alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, double alpha) +{ + return Matx<_Tp, m, n>(a, 1./alpha, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a) +{ + return Matx<_Tp, m, n>(a, -1, Matx_ScaleOp()); +} + +template static inline +Matx<_Tp, m, n> operator * (const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b) +{ + return Matx<_Tp, m, n>(a, b, Matx_MatMulOp()); +} + +template static inline +Vec<_Tp, m> operator * (const Matx<_Tp, m, n>& a, const Vec<_Tp, n>& b) +{ + Matx<_Tp, m, 1> c(a, b, Matx_MatMulOp()); + return (const Vec<_Tp, m>&)(c); +} + +template static inline +bool operator == (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + for( int i = 0; i < m*n; i++ ) + if( a.val[i] != b.val[i] ) return false; + return true; +} + +template static inline +bool operator != (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) +{ + return !(a == b); +} + +//! @} + +////////////////////////////// Vec out-of-class operators //////////////////////////////// + +//! @relates cv::Vec +//! @{ + +template static inline +Vec<_Tp1, cn>& operator += (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b) +{ + for( int i = 0; i < cn; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]); + return a; +} + +template static inline +Vec<_Tp1, cn>& operator -= (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b) +{ + for( int i = 0; i < cn; i++ ) + a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]); + return a; +} + +template static inline +Vec<_Tp, cn> operator + (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b) +{ + return Vec<_Tp, cn>(a, b, Matx_AddOp()); +} + +template static inline +Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b) +{ + return Vec<_Tp, cn>(a, b, Matx_SubOp()); +} + +template static inline +Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, int alpha) +{ + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*alpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, float alpha) +{ + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*alpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, double alpha) +{ + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*alpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, int alpha) +{ + double ialpha = 1./alpha; + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*ialpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, float alpha) +{ + float ialpha = 1.f/alpha; + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*ialpha); + return a; +} + +template static inline +Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, double alpha) +{ + double ialpha = 1./alpha; + for( int i = 0; i < cn; i++ ) + a[i] = saturate_cast<_Tp>(a[i]*ialpha); + return a; +} + +template static inline +Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, int alpha) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (int alpha, const Vec<_Tp, cn>& a) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, float alpha) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (float alpha, const Vec<_Tp, cn>& a) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (const Vec<_Tp, cn>& a, double alpha) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator * (double alpha, const Vec<_Tp, cn>& a) +{ + return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, int alpha) +{ + return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, float alpha) +{ + return Vec<_Tp, cn>(a, 1.f/alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator / (const Vec<_Tp, cn>& a, double alpha) +{ + return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp()); +} + +template static inline +Vec<_Tp, cn> operator - (const Vec<_Tp, cn>& a) +{ + Vec<_Tp,cn> t; + for( int i = 0; i < cn; i++ ) t.val[i] = saturate_cast<_Tp>(-a.val[i]); + return t; +} + +template inline Vec<_Tp, 4> operator * (const Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2) +{ + return Vec<_Tp, 4>(saturate_cast<_Tp>(v1[0]*v2[0] - v1[1]*v2[1] - v1[2]*v2[2] - v1[3]*v2[3]), + saturate_cast<_Tp>(v1[0]*v2[1] + v1[1]*v2[0] + v1[2]*v2[3] - v1[3]*v2[2]), + saturate_cast<_Tp>(v1[0]*v2[2] - v1[1]*v2[3] + v1[2]*v2[0] + v1[3]*v2[1]), + saturate_cast<_Tp>(v1[0]*v2[3] + v1[1]*v2[2] - v1[2]*v2[1] + v1[3]*v2[0])); +} + +template inline Vec<_Tp, 4>& operator *= (Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2) +{ + v1 = v1 * v2; + return v1; +} + +//! @} + +} // cv + +#endif // OPENCV_CORE_MATX_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/neon_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/neon_utils.hpp new file mode 100644 index 0000000..573ba99 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/neon_utils.hpp @@ -0,0 +1,128 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HAL_NEON_UTILS_HPP +#define OPENCV_HAL_NEON_UTILS_HPP + +#include "opencv2/core/cvdef.h" + +//! @addtogroup core_utils_neon +//! @{ + +#if CV_NEON + +inline int32x2_t cv_vrnd_s32_f32(float32x2_t v) +{ + static int32x2_t v_sign = vdup_n_s32(1 << 31), + v_05 = vreinterpret_s32_f32(vdup_n_f32(0.5f)); + + int32x2_t v_addition = vorr_s32(v_05, vand_s32(v_sign, vreinterpret_s32_f32(v))); + return vcvt_s32_f32(vadd_f32(v, vreinterpret_f32_s32(v_addition))); +} + +inline int32x4_t cv_vrndq_s32_f32(float32x4_t v) +{ + static int32x4_t v_sign = vdupq_n_s32(1 << 31), + v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f)); + + int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(v))); + return vcvtq_s32_f32(vaddq_f32(v, vreinterpretq_f32_s32(v_addition))); +} + +inline uint32x2_t cv_vrnd_u32_f32(float32x2_t v) +{ + static float32x2_t v_05 = vdup_n_f32(0.5f); + return vcvt_u32_f32(vadd_f32(v, v_05)); +} + +inline uint32x4_t cv_vrndq_u32_f32(float32x4_t v) +{ + static float32x4_t v_05 = vdupq_n_f32(0.5f); + return vcvtq_u32_f32(vaddq_f32(v, v_05)); +} + +inline float32x4_t cv_vrecpq_f32(float32x4_t val) +{ + float32x4_t reciprocal = vrecpeq_f32(val); + reciprocal = vmulq_f32(vrecpsq_f32(val, reciprocal), reciprocal); + reciprocal = vmulq_f32(vrecpsq_f32(val, reciprocal), reciprocal); + return reciprocal; +} + +inline float32x2_t cv_vrecp_f32(float32x2_t val) +{ + float32x2_t reciprocal = vrecpe_f32(val); + reciprocal = vmul_f32(vrecps_f32(val, reciprocal), reciprocal); + reciprocal = vmul_f32(vrecps_f32(val, reciprocal), reciprocal); + return reciprocal; +} + +inline float32x4_t cv_vrsqrtq_f32(float32x4_t val) +{ + float32x4_t e = vrsqrteq_f32(val); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(e, e), val), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(e, e), val), e); + return e; +} + +inline float32x2_t cv_vrsqrt_f32(float32x2_t val) +{ + float32x2_t e = vrsqrte_f32(val); + e = vmul_f32(vrsqrts_f32(vmul_f32(e, e), val), e); + e = vmul_f32(vrsqrts_f32(vmul_f32(e, e), val), e); + return e; +} + +inline float32x4_t cv_vsqrtq_f32(float32x4_t val) +{ + return cv_vrecpq_f32(cv_vrsqrtq_f32(val)); +} + +inline float32x2_t cv_vsqrt_f32(float32x2_t val) +{ + return cv_vrecp_f32(cv_vrsqrt_f32(val)); +} + +#endif + +//! @} + +#endif // OPENCV_HAL_NEON_UTILS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ocl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ocl.hpp new file mode 100644 index 0000000..4503fa0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ocl.hpp @@ -0,0 +1,917 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the OpenCV Foundation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OPENCL_HPP +#define OPENCV_OPENCL_HPP + +#include "opencv2/core.hpp" +#include +#include + +namespace cv { namespace ocl { + +//! @addtogroup core_opencl +//! @{ + +CV_EXPORTS_W bool haveOpenCL(); +CV_EXPORTS_W bool useOpenCL(); +CV_EXPORTS_W bool haveAmdBlas(); +CV_EXPORTS_W bool haveAmdFft(); +CV_EXPORTS_W void setUseOpenCL(bool flag); +CV_EXPORTS_W void finish(); + +CV_EXPORTS bool haveSVM(); + +class CV_EXPORTS Context; +class CV_EXPORTS_W_SIMPLE Device; +class CV_EXPORTS Kernel; +class CV_EXPORTS Program; +class CV_EXPORTS ProgramSource; +class CV_EXPORTS Queue; +class CV_EXPORTS PlatformInfo; +class CV_EXPORTS Image2D; + +class CV_EXPORTS_W_SIMPLE Device +{ +public: + CV_WRAP Device() CV_NOEXCEPT; + explicit Device(void* d); + Device(const Device& d); + Device& operator = (const Device& d); + Device(Device&& d) CV_NOEXCEPT; + Device& operator = (Device&& d) CV_NOEXCEPT; + CV_WRAP ~Device(); + + void set(void* d); + + enum + { + TYPE_DEFAULT = (1 << 0), + TYPE_CPU = (1 << 1), + TYPE_GPU = (1 << 2), + TYPE_ACCELERATOR = (1 << 3), + TYPE_DGPU = TYPE_GPU + (1 << 16), + TYPE_IGPU = TYPE_GPU + (1 << 17), + TYPE_ALL = 0xFFFFFFFF + }; + + CV_WRAP String name() const; + CV_WRAP String extensions() const; + CV_WRAP bool isExtensionSupported(const String& extensionName) const; + CV_WRAP String version() const; + CV_WRAP String vendorName() const; + CV_WRAP String OpenCL_C_Version() const; + CV_WRAP String OpenCLVersion() const; + CV_WRAP int deviceVersionMajor() const; + CV_WRAP int deviceVersionMinor() const; + CV_WRAP String driverVersion() const; + void* ptr() const; + + CV_WRAP int type() const; + + CV_WRAP int addressBits() const; + CV_WRAP bool available() const; + CV_WRAP bool compilerAvailable() const; + CV_WRAP bool linkerAvailable() const; + + enum + { + FP_DENORM=(1 << 0), + FP_INF_NAN=(1 << 1), + FP_ROUND_TO_NEAREST=(1 << 2), + FP_ROUND_TO_ZERO=(1 << 3), + FP_ROUND_TO_INF=(1 << 4), + FP_FMA=(1 << 5), + FP_SOFT_FLOAT=(1 << 6), + FP_CORRECTLY_ROUNDED_DIVIDE_SQRT=(1 << 7) + }; + CV_WRAP int doubleFPConfig() const; + CV_WRAP int singleFPConfig() const; + CV_WRAP int halfFPConfig() const; + + CV_WRAP bool endianLittle() const; + CV_WRAP bool errorCorrectionSupport() const; + + enum + { + EXEC_KERNEL=(1 << 0), + EXEC_NATIVE_KERNEL=(1 << 1) + }; + CV_WRAP int executionCapabilities() const; + + CV_WRAP size_t globalMemCacheSize() const; + + enum + { + NO_CACHE=0, + READ_ONLY_CACHE=1, + READ_WRITE_CACHE=2 + }; + CV_WRAP int globalMemCacheType() const; + CV_WRAP int globalMemCacheLineSize() const; + CV_WRAP size_t globalMemSize() const; + + CV_WRAP size_t localMemSize() const; + enum + { + NO_LOCAL_MEM=0, + LOCAL_IS_LOCAL=1, + LOCAL_IS_GLOBAL=2 + }; + CV_WRAP int localMemType() const; + CV_WRAP bool hostUnifiedMemory() const; + + CV_WRAP bool imageSupport() const; + + CV_WRAP bool imageFromBufferSupport() const; + uint imagePitchAlignment() const; + uint imageBaseAddressAlignment() const; + + /// deprecated, use isExtensionSupported() method (probably with "cl_khr_subgroups" value) + CV_WRAP bool intelSubgroupsSupport() const; + + CV_WRAP size_t image2DMaxWidth() const; + CV_WRAP size_t image2DMaxHeight() const; + + CV_WRAP size_t image3DMaxWidth() const; + CV_WRAP size_t image3DMaxHeight() const; + CV_WRAP size_t image3DMaxDepth() const; + + CV_WRAP size_t imageMaxBufferSize() const; + CV_WRAP size_t imageMaxArraySize() const; + + enum + { + UNKNOWN_VENDOR=0, + VENDOR_AMD=1, + VENDOR_INTEL=2, + VENDOR_NVIDIA=3 + }; + CV_WRAP int vendorID() const; + // FIXIT + // dev.isAMD() doesn't work for OpenCL CPU devices from AMD OpenCL platform. + // This method should use platform name instead of vendor name. + // After fix restore code in arithm.cpp: ocl_compare() + CV_WRAP inline bool isAMD() const { return vendorID() == VENDOR_AMD; } + CV_WRAP inline bool isIntel() const { return vendorID() == VENDOR_INTEL; } + CV_WRAP inline bool isNVidia() const { return vendorID() == VENDOR_NVIDIA; } + + CV_WRAP int maxClockFrequency() const; + CV_WRAP int maxComputeUnits() const; + CV_WRAP int maxConstantArgs() const; + CV_WRAP size_t maxConstantBufferSize() const; + + CV_WRAP size_t maxMemAllocSize() const; + CV_WRAP size_t maxParameterSize() const; + + CV_WRAP int maxReadImageArgs() const; + CV_WRAP int maxWriteImageArgs() const; + CV_WRAP int maxSamplers() const; + + CV_WRAP size_t maxWorkGroupSize() const; + CV_WRAP int maxWorkItemDims() const; + void maxWorkItemSizes(size_t*) const; + + CV_WRAP int memBaseAddrAlign() const; + + CV_WRAP int nativeVectorWidthChar() const; + CV_WRAP int nativeVectorWidthShort() const; + CV_WRAP int nativeVectorWidthInt() const; + CV_WRAP int nativeVectorWidthLong() const; + CV_WRAP int nativeVectorWidthFloat() const; + CV_WRAP int nativeVectorWidthDouble() const; + CV_WRAP int nativeVectorWidthHalf() const; + + CV_WRAP int preferredVectorWidthChar() const; + CV_WRAP int preferredVectorWidthShort() const; + CV_WRAP int preferredVectorWidthInt() const; + CV_WRAP int preferredVectorWidthLong() const; + CV_WRAP int preferredVectorWidthFloat() const; + CV_WRAP int preferredVectorWidthDouble() const; + CV_WRAP int preferredVectorWidthHalf() const; + + CV_WRAP size_t printfBufferSize() const; + CV_WRAP size_t profilingTimerResolution() const; + + CV_WRAP static const Device& getDefault(); + + /** + * @param d OpenCL handle (cl_device_id). clRetainDevice() is called on success. + * + * @note Ownership of the passed device is passed to OpenCV on success. + * The caller should additionally call `clRetainDevice` on it if it intends + * to continue using the device. + */ + static Device fromHandle(void* d); + + struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + + +class CV_EXPORTS Context +{ +public: + Context() CV_NOEXCEPT; + explicit Context(int dtype); //!< @deprecated + ~Context(); + Context(const Context& c); + Context& operator= (const Context& c); + Context(Context&& c) CV_NOEXCEPT; + Context& operator = (Context&& c) CV_NOEXCEPT; + + /** @deprecated */ + bool create(); + /** @deprecated */ + bool create(int dtype); + + size_t ndevices() const; + Device& device(size_t idx) const; + Program getProg(const ProgramSource& prog, + const String& buildopt, String& errmsg); + void unloadProg(Program& prog); + + + /** Get thread-local OpenCL context (initialize if necessary) */ +#if 0 // OpenCV 5.0 + static Context& getDefault(); +#else + static Context& getDefault(bool initialize = true); +#endif + + /** @returns cl_context value */ + void* ptr() const; + + /** + * @brief Get OpenCL context property specified on context creation + * @param propertyId Property id (CL_CONTEXT_* as defined in cl_context_properties type) + * @returns Property value if property was specified on clCreateContext, or NULL if context created without the property + */ + void* getOpenCLContextProperty(int propertyId) const; + + bool useSVM() const; + void setUseSVM(bool enabled); + + /** + * @param context OpenCL handle (cl_context). clRetainContext() is called on success + */ + static Context fromHandle(void* context); + static Context fromDevice(const ocl::Device& device); + static Context create(const std::string& configuration); + + void release(); + + class CV_EXPORTS UserContext { + public: + virtual ~UserContext(); + }; + template + inline void setUserContext(const std::shared_ptr& userContext) { + setUserContext(typeid(T), userContext); + } + template + inline std::shared_ptr getUserContext() { + return std::dynamic_pointer_cast(getUserContext(typeid(T))); + } + void setUserContext(std::type_index typeId, const std::shared_ptr& userContext); + std::shared_ptr getUserContext(std::type_index typeId); + + struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +// TODO OpenCV 5.0 +//protected: + Impl* p; +}; + +/** @deprecated */ +class CV_EXPORTS Platform +{ +public: + Platform() CV_NOEXCEPT; + ~Platform(); + Platform(const Platform& p); + Platform& operator = (const Platform& p); + Platform(Platform&& p) CV_NOEXCEPT; + Platform& operator = (Platform&& p) CV_NOEXCEPT; + + void* ptr() const; + + /** @deprecated */ + static Platform& getDefault(); + + struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + +/** @brief Attaches OpenCL context to OpenCV +@note + OpenCV will check if available OpenCL platform has platformName name, then assign context to + OpenCV and call `clRetainContext` function. The deviceID device will be used as target device and + new command queue will be created. +@param platformName name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime +@param platformID ID of platform attached context was created for +@param context OpenCL context to be attached to OpenCV +@param deviceID ID of device, must be created from attached context +*/ +CV_EXPORTS void attachContext(const String& platformName, void* platformID, void* context, void* deviceID); + +/** @brief Convert OpenCL buffer to UMat +@note + OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV. Memory + content is not copied from `clBuffer` to UMat. Instead, buffer handle assigned to UMat and + `clRetainMemObject` is called. +@param cl_mem_buffer source clBuffer handle +@param step num of bytes in single row +@param rows number of rows +@param cols number of cols +@param type OpenCV type of image +@param dst destination UMat +*/ +CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst); + +/** @brief Convert OpenCL image2d_t to UMat +@note + OpenCL `image2d_t` (cl_mem_image), should be compatible with OpenCV UMat formats. Memory content + is copied from image to UMat with `clEnqueueCopyImageToBuffer` function. +@param cl_mem_image source image2d_t handle +@param dst destination UMat +*/ +CV_EXPORTS void convertFromImage(void* cl_mem_image, UMat& dst); + +// TODO Move to internal header +/// @deprecated +void initializeContextFromHandle(Context& ctx, void* platform, void* context, void* device); + +class CV_EXPORTS Queue +{ +public: + Queue() CV_NOEXCEPT; + explicit Queue(const Context& c, const Device& d=Device()); + ~Queue(); + Queue(const Queue& q); + Queue& operator = (const Queue& q); + Queue(Queue&& q) CV_NOEXCEPT; + Queue& operator = (Queue&& q) CV_NOEXCEPT; + + bool create(const Context& c=Context(), const Device& d=Device()); + void finish(); + void* ptr() const; + static Queue& getDefault(); + + /// @brief Returns OpenCL command queue with enable profiling mode support + const Queue& getProfilingQueue() const; + + struct Impl; friend struct Impl; + inline Impl* getImpl() const { return p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + + +class CV_EXPORTS KernelArg +{ +public: + enum { LOCAL=1, READ_ONLY=2, WRITE_ONLY=4, READ_WRITE=6, CONSTANT=8, PTR_ONLY = 16, NO_SIZE=256 }; + KernelArg(int _flags, UMat* _m, int wscale=1, int iwscale=1, const void* _obj=0, size_t _sz=0); + KernelArg() CV_NOEXCEPT; + + static KernelArg Local(size_t localMemSize) + { return KernelArg(LOCAL, 0, 1, 1, 0, localMemSize); } + static KernelArg PtrWriteOnly(const UMat& m) + { return KernelArg(PTR_ONLY+WRITE_ONLY, (UMat*)&m); } + static KernelArg PtrReadOnly(const UMat& m) + { return KernelArg(PTR_ONLY+READ_ONLY, (UMat*)&m); } + static KernelArg PtrReadWrite(const UMat& m) + { return KernelArg(PTR_ONLY+READ_WRITE, (UMat*)&m); } + static KernelArg ReadWrite(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_WRITE, (UMat*)&m, wscale, iwscale); } + static KernelArg ReadWriteNoSize(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_WRITE+NO_SIZE, (UMat*)&m, wscale, iwscale); } + static KernelArg ReadOnly(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_ONLY, (UMat*)&m, wscale, iwscale); } + static KernelArg WriteOnly(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(WRITE_ONLY, (UMat*)&m, wscale, iwscale); } + static KernelArg ReadOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(READ_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); } + static KernelArg WriteOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1) + { return KernelArg(WRITE_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); } + static KernelArg Constant(const Mat& m); + template static KernelArg Constant(const _Tp* arr, size_t n) + { return KernelArg(CONSTANT, 0, 1, 1, (void*)arr, n); } + + int flags; + UMat* m; + const void* obj; + size_t sz; + int wscale, iwscale; +}; + + +class CV_EXPORTS Kernel +{ +public: + Kernel() CV_NOEXCEPT; + Kernel(const char* kname, const Program& prog); + Kernel(const char* kname, const ProgramSource& prog, + const String& buildopts = String(), String* errmsg=0); + ~Kernel(); + Kernel(const Kernel& k); + Kernel& operator = (const Kernel& k); + Kernel(Kernel&& k) CV_NOEXCEPT; + Kernel& operator = (Kernel&& k) CV_NOEXCEPT; + + bool empty() const; + bool create(const char* kname, const Program& prog); + bool create(const char* kname, const ProgramSource& prog, + const String& buildopts, String* errmsg=0); + + int set(int i, const void* value, size_t sz); + int set(int i, const Image2D& image2D); + int set(int i, const UMat& m); + int set(int i, const KernelArg& arg); + template int set(int i, const _Tp& value) + { return set(i, &value, sizeof(value)); } + + +protected: + template inline + int set_args_(int i, const _Tp0& a0) { return set(i, a0); } + template inline + int set_args_(int i, const _Tp0& a0, const _Tps&... rest_args) { i = set(i, a0); return set_args_(i, rest_args...); } +public: + /** @brief Setup OpenCL Kernel arguments. + Avoid direct using of set(i, ...) methods. + @code + bool ok = kernel + .args( + srcUMat, dstUMat, + (float)some_float_param + ).run(ndims, globalSize, localSize); + if (!ok) return false; + @endcode + */ + template inline + Kernel& args(const _Tps&... kernel_args) { set_args_(0, kernel_args...); return *this; } + + /** @brief Run the OpenCL kernel (globalsize value may be adjusted) + + @param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3. + @param globalsize work items for each dimension. It is not the final globalsize passed to + OpenCL. Each dimension will be adjusted to the nearest integer divisible by the corresponding + value in localsize. If localsize is NULL, it will still be adjusted depending on dims. The + adjusted values are greater than or equal to the original values. + @param localsize work-group size for each dimension. + @param sync specify whether to wait for OpenCL computation to finish before return. + @param q command queue + + @note Use run_() if your kernel code doesn't support adjusted globalsize. + */ + bool run(int dims, size_t globalsize[], + size_t localsize[], bool sync, const Queue& q=Queue()); + + /** @brief Run the OpenCL kernel + * + * @param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3. + * @param globalsize work items for each dimension. This value is passed to OpenCL without changes. + * @param localsize work-group size for each dimension. + * @param sync specify whether to wait for OpenCL computation to finish before return. + * @param q command queue + */ + bool run_(int dims, size_t globalsize[], size_t localsize[], bool sync, const Queue& q=Queue()); + + bool runTask(bool sync, const Queue& q=Queue()); + + /** @brief Similar to synchronized run_() call with returning of kernel execution time + * + * Separate OpenCL command queue may be used (with CL_QUEUE_PROFILING_ENABLE) + * @return Execution time in nanoseconds or negative number on error + */ + int64 runProfiling(int dims, size_t globalsize[], size_t localsize[], const Queue& q=Queue()); + + size_t workGroupSize() const; + size_t preferedWorkGroupSizeMultiple() const; + bool compileWorkGroupSize(size_t wsz[]) const; + size_t localMemSize() const; + + void* ptr() const; + struct Impl; + +protected: + Impl* p; +}; + +class CV_EXPORTS Program +{ +public: + Program() CV_NOEXCEPT; + Program(const ProgramSource& src, + const String& buildflags, String& errmsg); + Program(const Program& prog); + Program& operator = (const Program& prog); + Program(Program&& prog) CV_NOEXCEPT; + Program& operator = (Program&& prog) CV_NOEXCEPT; + ~Program(); + + bool create(const ProgramSource& src, + const String& buildflags, String& errmsg); + + void* ptr() const; + + /** + * @brief Query device-specific program binary. + * + * Returns RAW OpenCL executable binary without additional attachments. + * + * @sa ProgramSource::fromBinary + * + * @param[out] binary output buffer + */ + void getBinary(std::vector& binary) const; + + struct Impl; friend struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +public: +#ifndef OPENCV_REMOVE_DEPRECATED_API + // TODO Remove this + CV_DEPRECATED bool read(const String& buf, const String& buildflags); // removed, use ProgramSource instead + CV_DEPRECATED bool write(String& buf) const; // removed, use getBinary() method instead (RAW OpenCL binary) + CV_DEPRECATED const ProgramSource& source() const; // implementation removed + CV_DEPRECATED String getPrefix() const; // deprecated, implementation replaced + CV_DEPRECATED static String getPrefix(const String& buildflags); // deprecated, implementation replaced +#endif +}; + + +class CV_EXPORTS ProgramSource +{ +public: + typedef uint64 hash_t; // deprecated + + ProgramSource() CV_NOEXCEPT; + explicit ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash); + explicit ProgramSource(const String& prog); // deprecated + explicit ProgramSource(const char* prog); // deprecated + ~ProgramSource(); + ProgramSource(const ProgramSource& prog); + ProgramSource& operator = (const ProgramSource& prog); + ProgramSource(ProgramSource&& prog) CV_NOEXCEPT; + ProgramSource& operator = (ProgramSource&& prog) CV_NOEXCEPT; + + const String& source() const; // deprecated + hash_t hash() const; // deprecated + + + /** @brief Describe OpenCL program binary. + * Do not call clCreateProgramWithBinary() and/or clBuildProgram(). + * + * Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies). + * + * This kind of binary is not portable between platforms in general - it is specific to OpenCL vendor / device / driver version. + * + * @param module name of program owner module + * @param name unique name of program (module+name is used as key for OpenCL program caching) + * @param binary buffer address. See buffer lifetime requirement in description. + * @param size buffer size + * @param buildOptions additional program-related build options passed to clBuildProgram() + * @return created ProgramSource object + */ + static ProgramSource fromBinary(const String& module, const String& name, + const unsigned char* binary, const size_t size, + const cv::String& buildOptions = cv::String()); + + /** @brief Describe OpenCL program in SPIR format. + * Do not call clCreateProgramWithBinary() and/or clBuildProgram(). + * + * Supports SPIR 1.2 by default (pass '-spir-std=X.Y' in buildOptions to override this behavior) + * + * Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies). + * + * Programs in this format are portable between OpenCL implementations with 'khr_spir' extension: + * https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/cl_khr_spir.html + * (but they are not portable between different platforms: 32-bit / 64-bit) + * + * Note: these programs can't support vendor specific extensions, like 'cl_intel_subgroups'. + * + * @param module name of program owner module + * @param name unique name of program (module+name is used as key for OpenCL program caching) + * @param binary buffer address. See buffer lifetime requirement in description. + * @param size buffer size + * @param buildOptions additional program-related build options passed to clBuildProgram() + * (these options are added automatically: '-x spir' and '-spir-std=1.2') + * @return created ProgramSource object. + */ + static ProgramSource fromSPIR(const String& module, const String& name, + const unsigned char* binary, const size_t size, + const cv::String& buildOptions = cv::String()); + + //OpenCL 2.1+ only + //static Program fromSPIRV(const String& module, const String& name, + // const unsigned char* binary, const size_t size, + // const cv::String& buildOptions = cv::String()); + + struct Impl; friend struct Impl; + inline Impl* getImpl() const { return (Impl*)p; } + inline bool empty() const { return !p; } +protected: + Impl* p; +}; + +class CV_EXPORTS PlatformInfo +{ +public: + PlatformInfo() CV_NOEXCEPT; + /** + * @param id pointer cl_platform_id (cl_platform_id*) + */ + explicit PlatformInfo(void* id); + ~PlatformInfo(); + + PlatformInfo(const PlatformInfo& i); + PlatformInfo& operator =(const PlatformInfo& i); + PlatformInfo(PlatformInfo&& i) CV_NOEXCEPT; + PlatformInfo& operator = (PlatformInfo&& i) CV_NOEXCEPT; + + String name() const; + String vendor() const; + + /// See CL_PLATFORM_VERSION + String version() const; + int versionMajor() const; + int versionMinor() const; + + int deviceNumber() const; + void getDevice(Device& device, int d) const; + + struct Impl; + bool empty() const { return !p; } +protected: + Impl* p; +}; + +CV_EXPORTS const char* convertTypeStr(int sdepth, int ddepth, int cn, char* buf); +CV_EXPORTS const char* typeToStr(int t); +CV_EXPORTS const char* memopTypeToStr(int t); +CV_EXPORTS const char* vecopTypeToStr(int t); +CV_EXPORTS const char* getOpenCLErrorString(int errorCode); +CV_EXPORTS String kernelToStr(InputArray _kernel, int ddepth = -1, const char * name = NULL); +CV_EXPORTS void getPlatfomsInfo(std::vector& platform_info); + + +enum OclVectorStrategy +{ + // all matrices have its own vector width + OCL_VECTOR_OWN = 0, + // all matrices have maximal vector width among all matrices + // (useful for cases when matrices have different data types) + OCL_VECTOR_MAX = 1, + + // default strategy + OCL_VECTOR_DEFAULT = OCL_VECTOR_OWN +}; + +CV_EXPORTS int predictOptimalVectorWidth(InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), + InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), + InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray(), + OclVectorStrategy strat = OCL_VECTOR_DEFAULT); + +CV_EXPORTS int checkOptimalVectorWidth(const int *vectorWidths, + InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), + InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), + InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray(), + OclVectorStrategy strat = OCL_VECTOR_DEFAULT); + +// with OCL_VECTOR_MAX strategy +CV_EXPORTS int predictOptimalVectorWidthMax(InputArray src1, InputArray src2 = noArray(), InputArray src3 = noArray(), + InputArray src4 = noArray(), InputArray src5 = noArray(), InputArray src6 = noArray(), + InputArray src7 = noArray(), InputArray src8 = noArray(), InputArray src9 = noArray()); + +CV_EXPORTS void buildOptionsAddMatrixDescription(String& buildOptions, const String& name, InputArray _m); + +class CV_EXPORTS Image2D +{ +public: + Image2D() CV_NOEXCEPT; + + /** + @param src UMat object from which to get image properties and data + @param norm flag to enable the use of normalized channel data types + @param alias flag indicating that the image should alias the src UMat. If true, changes to the + image or src will be reflected in both objects. + */ + explicit Image2D(const UMat &src, bool norm = false, bool alias = false); + Image2D(const Image2D & i); + ~Image2D(); + + Image2D & operator = (const Image2D & i); + Image2D(Image2D &&) CV_NOEXCEPT; + Image2D &operator=(Image2D &&) CV_NOEXCEPT; + + /** Indicates if creating an aliased image should succeed. + Depends on the underlying platform and the dimensions of the UMat. + */ + static bool canCreateAlias(const UMat &u); + + /** Indicates if the image format is supported. + */ + static bool isFormatSupported(int depth, int cn, bool norm); + + void* ptr() const; +protected: + struct Impl; + Impl* p; +}; + +class CV_EXPORTS Timer +{ +public: + Timer(const Queue& q); + ~Timer(); + void start(); + void stop(); + + uint64 durationNS() const; //< duration in nanoseconds + +protected: + struct Impl; + Impl* const p; + +private: + Timer(const Timer&); // disabled + Timer& operator=(const Timer&); // disabled +}; + +CV_EXPORTS MatAllocator* getOpenCLAllocator(); + + +class CV_EXPORTS_W OpenCLExecutionContext +{ +public: + OpenCLExecutionContext() = default; + ~OpenCLExecutionContext() = default; + + OpenCLExecutionContext(const OpenCLExecutionContext&) = default; + OpenCLExecutionContext(OpenCLExecutionContext&&) = default; + + OpenCLExecutionContext& operator=(const OpenCLExecutionContext&) = default; + OpenCLExecutionContext& operator=(OpenCLExecutionContext&&) = default; + + /** Get associated ocl::Context */ + Context& getContext() const; + /** Get the single default associated ocl::Device */ + Device& getDevice() const; + /** Get the single ocl::Queue that is associated with the ocl::Context and + * the single default ocl::Device + */ + Queue& getQueue() const; + + bool useOpenCL() const; + void setUseOpenCL(bool flag); + + /** Get OpenCL execution context of current thread. + * + * Initialize OpenCL execution context if it is empty + * - create new + * - reuse context of the main thread (threadID = 0) + */ + static OpenCLExecutionContext& getCurrent(); + + /** Get OpenCL execution context of current thread (can be empty) */ + static OpenCLExecutionContext& getCurrentRef(); + + /** Bind this OpenCL execution context to current thread. + * + * Context can't be empty. + * + * @note clFinish is not called for queue of previous execution context + */ + void bind() const; + + /** Creates new execution context with same OpenCV context and device + * + * @param q OpenCL queue + */ + OpenCLExecutionContext cloneWithNewQueue(const ocl::Queue& q) const; + /** @overload */ + OpenCLExecutionContext cloneWithNewQueue() const; + + /** @brief Creates OpenCL execution context + * OpenCV will check if available OpenCL platform has platformName name, + * then assign context to OpenCV. + * The deviceID device will be used as target device and a new command queue will be created. + * + * @note On success, ownership of one reference of the context and device is taken. + * The caller should additionally call `clRetainContext` and/or `clRetainDevice` + * to increase the reference count if it wishes to continue using them. + * + * @param platformName name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime + * @param platformID ID of platform attached context was created for (cl_platform_id) + * @param context OpenCL context to be attached to OpenCV (cl_context) + * @param deviceID OpenCL device (cl_device_id) + */ + static OpenCLExecutionContext create(const std::string& platformName, void* platformID, void* context, void* deviceID); + + /** @brief Creates OpenCL execution context + * + * @param context non-empty OpenCL context + * @param device non-empty OpenCL device (must be a part of context) + * @param queue non-empty OpenCL queue for provided context and device + */ + static OpenCLExecutionContext create(const Context& context, const Device& device, const ocl::Queue& queue); + /** @overload */ + static OpenCLExecutionContext create(const Context& context, const Device& device); + + struct Impl; + inline bool empty() const { return !p; } + void release(); +protected: + std::shared_ptr p; +}; + +class OpenCLExecutionContextScope +{ + OpenCLExecutionContext ctx_; +public: + inline OpenCLExecutionContextScope(const OpenCLExecutionContext& ctx) + { + CV_Assert(!ctx.empty()); + ctx_ = OpenCLExecutionContext::getCurrentRef(); + ctx.bind(); + } + + inline ~OpenCLExecutionContextScope() + { + if (!ctx_.empty()) + { + ctx_.bind(); + } + } +}; + +#ifdef __OPENCV_BUILD +namespace internal { + +CV_EXPORTS bool isOpenCLForced(); +#define OCL_FORCE_CHECK(condition) (cv::ocl::internal::isOpenCLForced() || (condition)) + +CV_EXPORTS bool isPerformanceCheckBypassed(); +#define OCL_PERFORMANCE_CHECK(condition) (cv::ocl::internal::isPerformanceCheckBypassed() || (condition)) + +CV_EXPORTS bool isCLBuffer(UMat& u); + +} // namespace internal +#endif + +//! @} + +}} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ocl_genbase.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ocl_genbase.hpp new file mode 100644 index 0000000..5334cf1 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ocl_genbase.hpp @@ -0,0 +1,69 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the OpenCV Foundation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OPENCL_GENBASE_HPP +#define OPENCV_OPENCL_GENBASE_HPP + +//! @cond IGNORED + +namespace cv { +namespace ocl { + +class ProgramSource; + +namespace internal { + +struct CV_EXPORTS ProgramEntry +{ + const char* module; + const char* name; + const char* programCode; + const char* programHash; + ProgramSource* pProgramSource; + + operator ProgramSource& () const; +}; + +} } } // namespace + +//! @endcond + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/ocl_defs.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/ocl_defs.hpp new file mode 100644 index 0000000..14df750 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/ocl_defs.hpp @@ -0,0 +1,82 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_CORE_OPENCL_DEFS_HPP +#define OPENCV_CORE_OPENCL_DEFS_HPP + +#include "opencv2/core/utility.hpp" +#include "cvconfig.h" + +namespace cv { namespace ocl { +#ifdef HAVE_OPENCL +/// Call is similar to useOpenCL() but doesn't try to load OpenCL runtime or create OpenCL context +CV_EXPORTS bool isOpenCLActivated(); +#else +static inline bool isOpenCLActivated() { return false; } +#endif +}} // namespace + + +//#define CV_OPENCL_RUN_ASSERT + +#ifdef HAVE_OPENCL + +#ifdef CV_OPENCL_RUN_VERBOSE +#define CV_OCL_RUN_(condition, func, ...) \ + { \ + if (cv::ocl::isOpenCLActivated() && (condition) && func) \ + { \ + printf("%s: OpenCL implementation is running\n", CV_Func); \ + fflush(stdout); \ + CV_IMPL_ADD(CV_IMPL_OCL); \ + return __VA_ARGS__; \ + } \ + else \ + { \ + printf("%s: Plain implementation is running\n", CV_Func); \ + fflush(stdout); \ + } \ + } +#elif defined CV_OPENCL_RUN_ASSERT +#define CV_OCL_RUN_(condition, func, ...) \ + { \ + if (cv::ocl::isOpenCLActivated() && (condition)) \ + { \ + if(func) \ + { \ + CV_IMPL_ADD(CV_IMPL_OCL); \ + } \ + else \ + { \ + CV_Error(cv::Error::StsAssert, #func); \ + } \ + return __VA_ARGS__; \ + } \ + } +#else +#define CV_OCL_RUN_(condition, func, ...) \ +try \ +{ \ + if (cv::ocl::isOpenCLActivated() && (condition) && func) \ + { \ + CV_IMPL_ADD(CV_IMPL_OCL); \ + return __VA_ARGS__; \ + } \ +} \ +catch (const cv::Exception& e) \ +{ \ + CV_UNUSED(e); /* TODO: Add some logging here */ \ +} +#endif + +#else +#define CV_OCL_RUN_(condition, func, ...) +#endif + +#define CV_OCL_RUN(condition, func) CV_OCL_RUN_(condition, func) + +#endif // OPENCV_CORE_OPENCL_DEFS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/opencl_info.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/opencl_info.hpp new file mode 100644 index 0000000..3ead76e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/opencl_info.hpp @@ -0,0 +1,212 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include + +#include +#include + +#ifndef DUMP_CONFIG_PROPERTY +#define DUMP_CONFIG_PROPERTY(...) +#endif + +#ifndef DUMP_MESSAGE_STDOUT +#define DUMP_MESSAGE_STDOUT(...) do { std::cout << __VA_ARGS__ << std::endl; } while (false) +#endif + +namespace cv { + +namespace { +static std::string bytesToStringRepr(size_t value) +{ + size_t b = value % 1024; + value /= 1024; + + size_t kb = value % 1024; + value /= 1024; + + size_t mb = value % 1024; + value /= 1024; + + size_t gb = value; + + std::ostringstream stream; + + if (gb > 0) + stream << gb << " GB "; + if (mb > 0) + stream << mb << " MB "; + if (kb > 0) + stream << kb << " KB "; + if (b > 0) + stream << b << " B"; + + std::string s = stream.str(); + if (s[s.size() - 1] == ' ') + s = s.substr(0, s.size() - 1); + return s; +} + +static String getDeviceTypeString(const cv::ocl::Device& device) +{ + if (device.type() == cv::ocl::Device::TYPE_CPU) { + return "CPU"; + } + + if (device.type() == cv::ocl::Device::TYPE_GPU) { + if (device.hostUnifiedMemory()) { + return "iGPU"; + } else { + return "dGPU"; + } + } + + return "unknown"; +} +} // namespace + +static void dumpOpenCLInformation() +{ + using namespace cv::ocl; + + try + { + if (!haveOpenCL() || !useOpenCL()) + { + DUMP_MESSAGE_STDOUT("OpenCL is disabled"); + DUMP_CONFIG_PROPERTY("cv_ocl", "disabled"); + return; + } + + std::vector platforms; + cv::ocl::getPlatfomsInfo(platforms); + if (platforms.empty()) + { + DUMP_MESSAGE_STDOUT("OpenCL is not available"); + DUMP_CONFIG_PROPERTY("cv_ocl", "not available"); + return; + } + + DUMP_MESSAGE_STDOUT("OpenCL Platforms: "); + for (size_t i = 0; i < platforms.size(); i++) + { + const PlatformInfo* platform = &platforms[i]; + DUMP_MESSAGE_STDOUT(" " << platform->name()); + Device current_device; + for (int j = 0; j < platform->deviceNumber(); j++) + { + platform->getDevice(current_device, j); + String deviceTypeStr = getDeviceTypeString(current_device); + DUMP_MESSAGE_STDOUT( " " << deviceTypeStr << ": " << current_device.name() << " (" << current_device.version() << ")"); + DUMP_CONFIG_PROPERTY( cv::format("cv_ocl_platform_%d_device_%d", (int)i, j ), + cv::format("(Platform=%s)(Type=%s)(Name=%s)(Version=%s)", + platform->name().c_str(), deviceTypeStr.c_str(), current_device.name().c_str(), current_device.version().c_str()) ); + } + } + const Device& device = Device::getDefault(); + if (!device.available()) + CV_Error(Error::OpenCLInitError, "OpenCL device is not available"); + + DUMP_MESSAGE_STDOUT("Current OpenCL device: "); + + String deviceTypeStr = getDeviceTypeString(device); + DUMP_MESSAGE_STDOUT(" Type = " << deviceTypeStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceType", deviceTypeStr); + + DUMP_MESSAGE_STDOUT(" Name = " << device.name()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceName", device.name()); + + DUMP_MESSAGE_STDOUT(" Version = " << device.version()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceVersion", device.version()); + + DUMP_MESSAGE_STDOUT(" Driver version = " << device.driverVersion()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_driverVersion", device.driverVersion()); + + DUMP_MESSAGE_STDOUT(" Address bits = " << device.addressBits()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_addressBits", device.addressBits()); + + DUMP_MESSAGE_STDOUT(" Compute units = " << device.maxComputeUnits()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_maxComputeUnits", device.maxComputeUnits()); + + DUMP_MESSAGE_STDOUT(" Max work group size = " << device.maxWorkGroupSize()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_maxWorkGroupSize", device.maxWorkGroupSize()); + + std::string localMemorySizeStr = bytesToStringRepr(device.localMemSize()); + DUMP_MESSAGE_STDOUT(" Local memory size = " << localMemorySizeStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_localMemSize", device.localMemSize()); + + std::string maxMemAllocSizeStr = bytesToStringRepr(device.maxMemAllocSize()); + DUMP_MESSAGE_STDOUT(" Max memory allocation size = " << maxMemAllocSizeStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_maxMemAllocSize", device.maxMemAllocSize()); + + const char* doubleSupportStr = device.doubleFPConfig() > 0 ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Double support = " << doubleSupportStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_haveDoubleSupport", device.doubleFPConfig() > 0); + + const char* halfSupportStr = device.halfFPConfig() > 0 ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Half support = " << halfSupportStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_haveHalfSupport", device.halfFPConfig() > 0); + + const char* isUnifiedMemoryStr = device.hostUnifiedMemory() ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Host unified memory = " << isUnifiedMemoryStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_hostUnifiedMemory", device.hostUnifiedMemory()); + + DUMP_MESSAGE_STDOUT(" Device extensions:"); + String extensionsStr = device.extensions(); + size_t pos = 0; + while (pos < extensionsStr.size()) + { + size_t pos2 = extensionsStr.find(' ', pos); + if (pos2 == String::npos) + pos2 = extensionsStr.size(); + if (pos2 > pos) + { + String extensionName = extensionsStr.substr(pos, pos2 - pos); + DUMP_MESSAGE_STDOUT(" " << extensionName); + } + pos = pos2 + 1; + } + DUMP_CONFIG_PROPERTY("cv_ocl_current_extensions", extensionsStr); + + const char* haveAmdBlasStr = haveAmdBlas() ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Has AMD Blas = " << haveAmdBlasStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_AmdBlas", haveAmdBlas()); + + const char* haveAmdFftStr = haveAmdFft() ? "Yes" : "No"; + DUMP_MESSAGE_STDOUT(" Has AMD Fft = " << haveAmdFftStr); + DUMP_CONFIG_PROPERTY("cv_ocl_current_AmdFft", haveAmdFft()); + + + DUMP_MESSAGE_STDOUT(" Preferred vector width char = " << device.preferredVectorWidthChar()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthChar", device.preferredVectorWidthChar()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width short = " << device.preferredVectorWidthShort()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthShort", device.preferredVectorWidthShort()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width int = " << device.preferredVectorWidthInt()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthInt", device.preferredVectorWidthInt()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width long = " << device.preferredVectorWidthLong()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthLong", device.preferredVectorWidthLong()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width float = " << device.preferredVectorWidthFloat()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthFloat", device.preferredVectorWidthFloat()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width double = " << device.preferredVectorWidthDouble()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthDouble", device.preferredVectorWidthDouble()); + + DUMP_MESSAGE_STDOUT(" Preferred vector width half = " << device.preferredVectorWidthHalf()); + DUMP_CONFIG_PROPERTY("cv_ocl_current_preferredVectorWidthHalf", device.preferredVectorWidthHalf()); + } + catch (...) + { + DUMP_MESSAGE_STDOUT("Exception. Can't dump OpenCL info"); + DUMP_MESSAGE_STDOUT("OpenCL device not available"); + DUMP_CONFIG_PROPERTY("cv_ocl", "not available"); + } +} +#undef DUMP_MESSAGE_STDOUT +#undef DUMP_CONFIG_PROPERTY + +} // namespace diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/opencl_svm.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/opencl_svm.hpp new file mode 100644 index 0000000..7453082 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opencl/opencl_svm.hpp @@ -0,0 +1,81 @@ +/* See LICENSE file in the root OpenCV directory */ + +#ifndef OPENCV_CORE_OPENCL_SVM_HPP +#define OPENCV_CORE_OPENCL_SVM_HPP + +// +// Internal usage only (binary compatibility is not guaranteed) +// +#ifndef __OPENCV_BUILD +#error Internal header file +#endif + +#if defined(HAVE_OPENCL) && defined(HAVE_OPENCL_SVM) +#include "runtime/opencl_core.hpp" +#include "runtime/opencl_svm_20.hpp" +#include "runtime/opencl_svm_hsa_extension.hpp" + +namespace cv { namespace ocl { namespace svm { + +struct SVMCapabilities +{ + enum Value + { + SVM_COARSE_GRAIN_BUFFER = (1 << 0), + SVM_FINE_GRAIN_BUFFER = (1 << 1), + SVM_FINE_GRAIN_SYSTEM = (1 << 2), + SVM_ATOMICS = (1 << 3), + }; + int value_; + + SVMCapabilities(int capabilities = 0) : value_(capabilities) { } + operator int() const { return value_; } + + inline bool isNoSVMSupport() const { return value_ == 0; } + inline bool isSupportCoarseGrainBuffer() const { return (value_ & SVM_COARSE_GRAIN_BUFFER) != 0; } + inline bool isSupportFineGrainBuffer() const { return (value_ & SVM_FINE_GRAIN_BUFFER) != 0; } + inline bool isSupportFineGrainSystem() const { return (value_ & SVM_FINE_GRAIN_SYSTEM) != 0; } + inline bool isSupportAtomics() const { return (value_ & SVM_ATOMICS) != 0; } +}; + +CV_EXPORTS const SVMCapabilities getSVMCapabilitites(const ocl::Context& context); + +struct SVMFunctions +{ + clSVMAllocAMD_fn fn_clSVMAlloc; + clSVMFreeAMD_fn fn_clSVMFree; + clSetKernelArgSVMPointerAMD_fn fn_clSetKernelArgSVMPointer; + //clSetKernelExecInfoAMD_fn fn_clSetKernelExecInfo; + //clEnqueueSVMFreeAMD_fn fn_clEnqueueSVMFree; + clEnqueueSVMMemcpyAMD_fn fn_clEnqueueSVMMemcpy; + clEnqueueSVMMemFillAMD_fn fn_clEnqueueSVMMemFill; + clEnqueueSVMMapAMD_fn fn_clEnqueueSVMMap; + clEnqueueSVMUnmapAMD_fn fn_clEnqueueSVMUnmap; + + inline SVMFunctions() + : fn_clSVMAlloc(NULL), fn_clSVMFree(NULL), + fn_clSetKernelArgSVMPointer(NULL), /*fn_clSetKernelExecInfo(NULL),*/ + /*fn_clEnqueueSVMFree(NULL),*/ fn_clEnqueueSVMMemcpy(NULL), fn_clEnqueueSVMMemFill(NULL), + fn_clEnqueueSVMMap(NULL), fn_clEnqueueSVMUnmap(NULL) + { + // nothing + } + + inline bool isValid() const + { + return fn_clSVMAlloc != NULL && fn_clSVMFree && fn_clSetKernelArgSVMPointer && + /*fn_clSetKernelExecInfo && fn_clEnqueueSVMFree &&*/ fn_clEnqueueSVMMemcpy && + fn_clEnqueueSVMMemFill && fn_clEnqueueSVMMap && fn_clEnqueueSVMUnmap; + } +}; + +// We should guarantee that SVMFunctions lifetime is not less than context's lifetime +CV_EXPORTS const SVMFunctions* getSVMFunctions(const ocl::Context& context); + +CV_EXPORTS bool useSVM(UMatUsageFlags usageFlags); + +}}} //namespace cv::ocl::svm +#endif + +#endif // OPENCV_CORE_OPENCL_SVM_HPP +/* End of file. */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opengl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opengl.hpp new file mode 100644 index 0000000..a311ce2 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/opengl.hpp @@ -0,0 +1,725 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_OPENGL_HPP +#define OPENCV_CORE_OPENGL_HPP + +#ifndef __cplusplus +# error opengl.hpp header must be compiled as C++ +#endif + +#include "opencv2/core.hpp" +#include "ocl.hpp" + +namespace cv { namespace ogl { + +/** @addtogroup core_opengl +This section describes OpenGL interoperability. + +To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is +supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not +supported). For GTK backend gtkglext-1.0 library is required. + +To use OpenGL functionality you should first create OpenGL context (window or frame buffer). You can +do this with namedWindow function or with other OpenGL toolkit (GLUT, for example). +*/ +//! @{ + +/////////////////// OpenGL Objects /////////////////// + +/** @brief Smart pointer for OpenGL buffer object with reference counting. + +Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL +context. These can be used to store vertex data, pixel data retrieved from images or the +framebuffer, and a variety of other things. + +ogl::Buffer has interface similar with Mat interface and represents 2D array memory. + +ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory. + */ +class CV_EXPORTS Buffer +{ +public: + /** @brief The target defines how you intend to use the buffer object. + */ + enum Target + { + ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data + ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example) + PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures + PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures + }; + + enum Access + { + READ_ONLY = 0x88B8, + WRITE_ONLY = 0x88B9, + READ_WRITE = 0x88BA + }; + + /** @brief The constructors. + + Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId + parameter), allocates memory for ogl::Buffer object or copies from host/device memory. + */ + Buffer(); + + /** @overload + @param arows Number of rows in a 2D array. + @param acols Number of columns in a 2D array. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param abufId Buffer object name. + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param abufId Buffer object name. + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false); + + /** @overload + @param arows Number of rows in a 2D array. + @param acols Number of columns in a 2D array. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @brief Allocates memory for ogl::Buffer object. + + @param arows Number of rows in a 2D array. + @param acols Number of columns in a 2D array. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details. + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @brief Decrements the reference counter and destroys the buffer object if needed. + + The function will call setAutoRelease(true) . + */ + void release(); + + /** @brief Sets auto release mode. + + The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was + bound to a window it could be released at any time (user can close a window). If object's destructor + is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy + OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). + This function can force ogl::Buffer destructor to destroy OpenGL object. + @param flag Auto release mode (if true, release will be called in object's destructor). + */ + void setAutoRelease(bool flag); + + /** @brief Copies from host/device memory to OpenGL buffer. + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ). + @param target Buffer usage. See cv::ogl::Buffer::Target . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @overload */ + void copyFrom(InputArray arr, cuda::Stream& stream, Target target = ARRAY_BUFFER, bool autoRelease = false); + + /** @brief Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. + + @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or + ogl::Buffer ). + */ + void copyTo(OutputArray arr) const; + + /** @overload */ + void copyTo(OutputArray arr, cuda::Stream& stream) const; + + /** @brief Creates a full copy of the buffer object and the underlying data. + + @param target Buffer usage for destination buffer. + @param autoRelease Auto release mode for destination buffer. + */ + Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const; + + /** @brief Binds OpenGL buffer to the specified buffer binding point. + + @param target Binding point. See cv::ogl::Buffer::Target . + */ + void bind(Target target) const; + + /** @brief Unbind any buffers from the specified binding point. + + @param target Binding point. See cv::ogl::Buffer::Target . + */ + static void unbind(Target target); + + /** @brief Maps OpenGL buffer to host memory. + + mapHost maps to the client's address space the entire data store of the buffer object. The data can + then be directly read and/or written relative to the returned pointer, depending on the specified + access policy. + + A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used. + + This operation can lead to memory transfers between host and device. + + Only one buffer object can be mapped at a time. + @param access Access policy, indicating whether it will be possible to read from, write to, or both + read from and write to the buffer object's mapped data store. The symbolic constant must be + ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE . + */ + Mat mapHost(Access access); + + /** @brief Unmaps OpenGL buffer. + */ + void unmapHost(); + + //! map to device memory (blocking) + cuda::GpuMat mapDevice(); + void unmapDevice(); + + /** @brief Maps OpenGL buffer to CUDA device memory. + + This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time. + + A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used. + */ + cuda::GpuMat mapDevice(cuda::Stream& stream); + + /** @brief Unmaps OpenGL buffer. + */ + void unmapDevice(cuda::Stream& stream); + + int rows() const; + int cols() const; + Size size() const; + bool empty() const; + + int type() const; + int depth() const; + int channels() const; + int elemSize() const; + int elemSize1() const; + + //! get OpenGL opject id + unsigned int bufId() const; + + class Impl; + +private: + Ptr impl_; + int rows_; + int cols_; + int type_; +}; + +/** @brief Smart pointer for OpenGL 2D texture memory with reference counting. + */ +class CV_EXPORTS Texture2D +{ +public: + /** @brief An Image Format describes the way that the images in Textures store their data. + */ + enum Format + { + NONE = 0, + DEPTH_COMPONENT = 0x1902, //!< Depth + RGB = 0x1907, //!< Red, Green, Blue + RGBA = 0x1908 //!< Red, Green, Blue, Alpha + }; + + /** @brief The constructors. + + Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from + host/device memory. + */ + Texture2D(); + + /** @overload */ + Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false); + + /** @overload */ + Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false); + + /** @overload + @param arows Number of rows. + @param acols Number of columns. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Texture2D(int arows, int acols, Format aformat, bool autoRelease = false); + + /** @overload + @param asize 2D array size. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + Texture2D(Size asize, Format aformat, bool autoRelease = false); + + /** @overload + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + explicit Texture2D(InputArray arr, bool autoRelease = false); + + /** @brief Allocates memory for ogl::Texture2D object. + + @param arows Number of rows. + @param acols Number of columns. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(int arows, int acols, Format aformat, bool autoRelease = false); + /** @overload + @param asize 2D array size. + @param aformat Image format. See cv::ogl::Texture2D::Format . + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void create(Size asize, Format aformat, bool autoRelease = false); + + /** @brief Decrements the reference counter and destroys the texture object if needed. + + The function will call setAutoRelease(true) . + */ + void release(); + + /** @brief Sets auto release mode. + + @param flag Auto release mode (if true, release will be called in object's destructor). + + The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was + bound to a window it could be released at any time (user can close a window). If object's destructor + is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't + destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL + context). This function can force ogl::Texture2D destructor to destroy OpenGL object. + */ + void setAutoRelease(bool flag); + + /** @brief Copies from host/device memory to OpenGL texture. + + @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ). + @param autoRelease Auto release mode (if true, release will be called in object's destructor). + */ + void copyFrom(InputArray arr, bool autoRelease = false); + + /** @brief Copies from OpenGL texture to host/device memory or another OpenGL texture object. + + @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or + ogl::Texture2D ). + @param ddepth Destination depth. + @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture). + */ + void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const; + + /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target. + */ + void bind() const; + + int rows() const; + int cols() const; + Size size() const; + bool empty() const; + + Format format() const; + + //! get OpenGL opject id + unsigned int texId() const; + + class Impl; + +private: + Ptr impl_; + int rows_; + int cols_; + Format format_; +}; + +/** @brief Wrapper for OpenGL Client-Side Vertex arrays. + +ogl::Arrays stores vertex data in ogl::Buffer objects. + */ +class CV_EXPORTS Arrays +{ +public: + /** @brief Default constructor + */ + Arrays(); + + /** @brief Sets an array of vertex coordinates. + @param vertex array with vertex coordinates, can be both host and device memory. + */ + void setVertexArray(InputArray vertex); + + /** @brief Resets vertex coordinates. + */ + void resetVertexArray(); + + /** @brief Sets an array of vertex colors. + @param color array with vertex colors, can be both host and device memory. + */ + void setColorArray(InputArray color); + + /** @brief Resets vertex colors. + */ + void resetColorArray(); + + /** @brief Sets an array of vertex normals. + @param normal array with vertex normals, can be both host and device memory. + */ + void setNormalArray(InputArray normal); + + /** @brief Resets vertex normals. + */ + void resetNormalArray(); + + /** @brief Sets an array of vertex texture coordinates. + @param texCoord array with vertex texture coordinates, can be both host and device memory. + */ + void setTexCoordArray(InputArray texCoord); + + /** @brief Resets vertex texture coordinates. + */ + void resetTexCoordArray(); + + /** @brief Releases all inner buffers. + */ + void release(); + + /** @brief Sets auto release mode all inner buffers. + @param flag Auto release mode. + */ + void setAutoRelease(bool flag); + + /** @brief Binds all vertex arrays. + */ + void bind() const; + + /** @brief Returns the vertex count. + */ + int size() const; + bool empty() const; + +private: + int size_; + Buffer vertex_; + Buffer color_; + Buffer normal_; + Buffer texCoord_; +}; + +/////////////////// Render Functions /////////////////// + +//! render mode +enum RenderModes { + POINTS = 0x0000, + LINES = 0x0001, + LINE_LOOP = 0x0002, + LINE_STRIP = 0x0003, + TRIANGLES = 0x0004, + TRIANGLE_STRIP = 0x0005, + TRIANGLE_FAN = 0x0006, + QUADS = 0x0007, + QUAD_STRIP = 0x0008, + POLYGON = 0x0009 +}; + +/** @brief Render OpenGL texture or primitives. +@param tex Texture to draw. +@param wndRect Region of window, where to draw a texture (normalized coordinates). +@param texRect Region of texture to draw (normalized coordinates). + */ +CV_EXPORTS void render(const Texture2D& tex, + Rect_ wndRect = Rect_(0.0, 0.0, 1.0, 1.0), + Rect_ texRect = Rect_(0.0, 0.0, 1.0, 1.0)); + +/** @overload +@param arr Array of privitives vertices. +@param mode Render mode. One of cv::ogl::RenderModes +@param color Color for all vertices. Will be used if arr doesn't contain color array. +*/ +CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255)); + +/** @overload +@param arr Array of privitives vertices. +@param indices Array of vertices indices (host or device memory). +@param mode Render mode. One of cv::ogl::RenderModes +@param color Color for all vertices. Will be used if arr doesn't contain color array. +*/ +CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255)); + +/////////////////// CL-GL Interoperability Functions /////////////////// + +namespace ocl { +using namespace cv::ocl; + +// TODO static functions in the Context class +/** @brief Creates OpenCL context from GL. +@return Returns reference to OpenCL Context + */ +CV_EXPORTS Context& initializeContextFromGL(); + +} // namespace cv::ogl::ocl + +/** @brief Converts InputArray to Texture2D object. +@param src - source InputArray. +@param texture - destination Texture2D object. + */ +CV_EXPORTS void convertToGLTexture2D(InputArray src, Texture2D& texture); + +/** @brief Converts Texture2D object to OutputArray. +@param texture - source Texture2D object. +@param dst - destination OutputArray. + */ +CV_EXPORTS void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst); + +/** @brief Maps Buffer object to process on CL side (convert to UMat). + +Function creates CL buffer from GL one, and then constructs UMat that can be used +to process buffer data with OpenCV functions. Note that in current implementation +UMat constructed this way doesn't own corresponding GL buffer object, so it is +the user responsibility to close down CL/GL buffers relationships by explicitly +calling unmapGLBuffer() function. +@param buffer - source Buffer object. +@param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE). +@return Returns UMat object + */ +CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags = ACCESS_READ | ACCESS_WRITE); + +/** @brief Unmaps Buffer object (releases UMat, previously mapped from Buffer). + +Function must be called explicitly by the user for each UMat previously constructed +by the call to mapGLBuffer() function. +@param u - source UMat, created by mapGLBuffer(). + */ +CV_EXPORTS void unmapGLBuffer(UMat& u); + +//! @} +}} // namespace cv::ogl + +namespace cv { namespace cuda { + +/** @brief Sets a CUDA device and initializes it for the current thread with OpenGL interoperability. + +This function should be explicitly called after OpenGL context creation and before any CUDA calls. +@param device System index of a CUDA device starting with 0. +@ingroup core_opengl + */ +CV_EXPORTS void setGlDevice(int device = 0); + +}} + +//! @cond IGNORED + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +inline +cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +{ + create(arows, acols, atype, target, autoRelease); +} + +inline +cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0) +{ + create(asize, atype, target, autoRelease); +} + +inline +void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease) +{ + create(asize.height, asize.width, atype, target, autoRelease); +} + +inline +int cv::ogl::Buffer::rows() const +{ + return rows_; +} + +inline +int cv::ogl::Buffer::cols() const +{ + return cols_; +} + +inline +cv::Size cv::ogl::Buffer::size() const +{ + return Size(cols_, rows_); +} + +inline +bool cv::ogl::Buffer::empty() const +{ + return rows_ == 0 || cols_ == 0; +} + +inline +int cv::ogl::Buffer::type() const +{ + return type_; +} + +inline +int cv::ogl::Buffer::depth() const +{ + return CV_MAT_DEPTH(type_); +} + +inline +int cv::ogl::Buffer::channels() const +{ + return CV_MAT_CN(type_); +} + +inline +int cv::ogl::Buffer::elemSize() const +{ + return CV_ELEM_SIZE(type_); +} + +inline +int cv::ogl::Buffer::elemSize1() const +{ + return CV_ELEM_SIZE1(type_); +} + +/////// + +inline +cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE) +{ + create(arows, acols, aformat, autoRelease); +} + +inline +cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE) +{ + create(asize, aformat, autoRelease); +} + +inline +void cv::ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease) +{ + create(asize.height, asize.width, aformat, autoRelease); +} + +inline +int cv::ogl::Texture2D::rows() const +{ + return rows_; +} + +inline +int cv::ogl::Texture2D::cols() const +{ + return cols_; +} + +inline +cv::Size cv::ogl::Texture2D::size() const +{ + return Size(cols_, rows_); +} + +inline +bool cv::ogl::Texture2D::empty() const +{ + return rows_ == 0 || cols_ == 0; +} + +inline +cv::ogl::Texture2D::Format cv::ogl::Texture2D::format() const +{ + return format_; +} + +/////// + +inline +cv::ogl::Arrays::Arrays() : size_(0) +{ +} + +inline +int cv::ogl::Arrays::size() const +{ + return size_; +} + +inline +bool cv::ogl::Arrays::empty() const +{ + return size_ == 0; +} + +//! @endcond + +#endif /* OPENCV_CORE_OPENGL_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/operations.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/operations.hpp new file mode 100644 index 0000000..bde28c4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/operations.hpp @@ -0,0 +1,594 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_OPERATIONS_HPP +#define OPENCV_CORE_OPERATIONS_HPP + +#ifndef __cplusplus +# error operations.hpp header must be compiled as C++ +#endif + +#include + +#if defined(__GNUC__) || defined(__clang__) // at least GCC 3.1+, clang 3.5+ +# if defined(__MINGW_PRINTF_FORMAT) // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. +# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (__MINGW_PRINTF_FORMAT, string_idx, first_to_check))) +# else +# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (printf, string_idx, first_to_check))) +# endif +#else +# define CV_FORMAT_PRINTF(A, B) +#endif + +//! @cond IGNORED + +namespace cv +{ + +////////////////////////////// Matx methods depending on core API ///////////////////////////// + +namespace internal +{ + +template struct Matx_FastInvOp +{ + bool operator()(const Matx<_Tp, m, n>& a, Matx<_Tp, n, m>& b, int method) const + { + return invert(a, b, method) != 0; + } +}; + +template struct Matx_FastInvOp<_Tp, m, m> +{ + bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const + { + if (method == DECOMP_LU || method == DECOMP_CHOLESKY) + { + Matx<_Tp, m, m> temp = a; + + // assume that b is all 0's on input => make it a unity matrix + for (int i = 0; i < m; i++) + b(i, i) = (_Tp)1; + + if (method == DECOMP_CHOLESKY) + return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m); + + return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0; + } + else + { + return invert(a, b, method) != 0; + } + } +}; + +template struct Matx_FastInvOp<_Tp, 2, 2> +{ + bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int /*method*/) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + b(1,1) = a(0,0)*d; + b(0,0) = a(1,1)*d; + b(0,1) = -a(0,1)*d; + b(1,0) = -a(1,0)*d; + return true; + } +}; + +template struct Matx_FastInvOp<_Tp, 3, 3> +{ + bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int /*method*/) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + b(0,0) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) * d; + b(0,1) = (a(0,2) * a(2,1) - a(0,1) * a(2,2)) * d; + b(0,2) = (a(0,1) * a(1,2) - a(0,2) * a(1,1)) * d; + + b(1,0) = (a(1,2) * a(2,0) - a(1,0) * a(2,2)) * d; + b(1,1) = (a(0,0) * a(2,2) - a(0,2) * a(2,0)) * d; + b(1,2) = (a(0,2) * a(1,0) - a(0,0) * a(1,2)) * d; + + b(2,0) = (a(1,0) * a(2,1) - a(1,1) * a(2,0)) * d; + b(2,1) = (a(0,1) * a(2,0) - a(0,0) * a(2,1)) * d; + b(2,2) = (a(0,0) * a(1,1) - a(0,1) * a(1,0)) * d; + return true; + } +}; + + +template struct Matx_FastSolveOp +{ + bool operator()(const Matx<_Tp, m, l>& a, const Matx<_Tp, m, n>& b, + Matx<_Tp, l, n>& x, int method) const + { + return cv::solve(a, b, x, method); + } +}; + +template struct Matx_FastSolveOp<_Tp, m, m, n> +{ + bool operator()(const Matx<_Tp, m, m>& a, const Matx<_Tp, m, n>& b, + Matx<_Tp, m, n>& x, int method) const + { + if (method == DECOMP_LU || method == DECOMP_CHOLESKY) + { + Matx<_Tp, m, m> temp = a; + x = b; + if( method == DECOMP_CHOLESKY ) + return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n); + + return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0; + } + else + { + return cv::solve(a, b, x, method); + } + } +}; + +template struct Matx_FastSolveOp<_Tp, 2, 2, 1> +{ + bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b, + Matx<_Tp, 2, 1>& x, int) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + x(0) = (b(0)*a(1,1) - b(1)*a(0,1))*d; + x(1) = (b(1)*a(0,0) - b(0)*a(1,0))*d; + return true; + } +}; + +template struct Matx_FastSolveOp<_Tp, 3, 3, 1> +{ + bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b, + Matx<_Tp, 3, 1>& x, int) const + { + _Tp d = (_Tp)determinant(a); + if (d == 0) + return false; + d = 1/d; + x(0) = d*(b(0)*(a(1,1)*a(2,2) - a(1,2)*a(2,1)) - + a(0,1)*(b(1)*a(2,2) - a(1,2)*b(2)) + + a(0,2)*(b(1)*a(2,1) - a(1,1)*b(2))); + + x(1) = d*(a(0,0)*(b(1)*a(2,2) - a(1,2)*b(2)) - + b(0)*(a(1,0)*a(2,2) - a(1,2)*a(2,0)) + + a(0,2)*(a(1,0)*b(2) - b(1)*a(2,0))); + + x(2) = d*(a(0,0)*(a(1,1)*b(2) - b(1)*a(2,1)) - + a(0,1)*(a(1,0)*b(2) - b(1)*a(2,0)) + + b(0)*(a(1,0)*a(2,1) - a(1,1)*a(2,0))); + return true; + } +}; + +} // internal + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::randu(_Tp a, _Tp b) +{ + Matx<_Tp,m,n> M; + cv::randu(M, Scalar(a), Scalar(b)); + return M; +} + +template inline +Matx<_Tp,m,n> Matx<_Tp,m,n>::randn(_Tp a, _Tp b) +{ + Matx<_Tp,m,n> M; + cv::randn(M, Scalar(a), Scalar(b)); + return M; +} + +template inline +Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const +{ + Matx<_Tp, n, m> b; + bool ok = cv::internal::Matx_FastInvOp<_Tp, m, n>()(*this, b, method); + if (p_is_ok) *p_is_ok = ok; + return ok ? b : Matx<_Tp, n, m>::zeros(); +} + +template template inline +Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) const +{ + Matx<_Tp, n, l> x; + bool ok = cv::internal::Matx_FastSolveOp<_Tp, m, n, l>()(*this, rhs, x, method); + return ok ? x : Matx<_Tp, n, l>::zeros(); +} + + + +////////////////////////// Augmenting algebraic & logical operations ////////////////////////// + +#define CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \ + static inline A& operator op (A& a, const B& b) { cvop; return a; } + +#define CV_MAT_AUG_OPERATOR(op, cvop, A, B) \ + CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \ + CV_MAT_AUG_OPERATOR1(op, cvop, const A, B) + +#define CV_MAT_AUG_OPERATOR_T(op, cvop, A, B) \ + template CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \ + template CV_MAT_AUG_OPERATOR1(op, cvop, const A, B) + +#define CV_MAT_AUG_OPERATOR_TN(op, cvop, A) \ + template static inline A& operator op (A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } \ + template static inline const A& operator op (const A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } + +CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (+=, cv::add(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(+=, cv::add(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(+=, cv::add(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (-=, cv::subtract(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(-=, cv::subtract(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(-=, cv::subtract(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat, Mat) +CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(*=, cv::gemm(a, b, 1, Mat(), 0, a, 0), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR (*=, a.convertTo(a, -1, b), Mat, double) +CV_MAT_AUG_OPERATOR_T(*=, a.convertTo(a, -1, b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat) +CV_MAT_AUG_OPERATOR_TN(*=, cv::gemm(a, Mat(b), 1, Mat(), 0, a, 0), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (/=, cv::divide(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(/=, cv::divide(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR (/=, a.convertTo((Mat&)a, -1, 1./b), Mat, double) +CV_MAT_AUG_OPERATOR_T(/=, a.convertTo((Mat&)a, -1, 1./b), Mat_<_Tp>, double) +CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(/=, cv::divide(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (&=, cv::bitwise_and(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(&=, cv::bitwise_and(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(&=, cv::bitwise_and(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (|=, cv::bitwise_or(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(|=, cv::bitwise_or(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(|=, cv::bitwise_or(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Mat) +CV_MAT_AUG_OPERATOR (^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat, Scalar) +CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat) +CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Scalar) +CV_MAT_AUG_OPERATOR_T(^=, cv::bitwise_xor(a, b, (const Mat&)a), Mat_<_Tp>, Mat_<_Tp>) +CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat) +CV_MAT_AUG_OPERATOR_TN(^=, cv::bitwise_xor(a, Mat(b), (const Mat&)a), Mat_<_Tp>) + +#undef CV_MAT_AUG_OPERATOR_TN +#undef CV_MAT_AUG_OPERATOR_T +#undef CV_MAT_AUG_OPERATOR +#undef CV_MAT_AUG_OPERATOR1 + + + +///////////////////////////////////////////// SVD ///////////////////////////////////////////// + +inline SVD::SVD() {} +inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); } +inline void SVD::solveZ( InputArray m, OutputArray _dst ) +{ + Mat mtx = m.getMat(); + SVD svd(mtx, (mtx.rows >= mtx.cols ? 0 : SVD::FULL_UV)); + _dst.create(svd.vt.cols, 1, svd.vt.type()); + Mat dst = _dst.getMat(); + svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst); +} + +template inline void + SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt ) +{ + CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector."); + Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false); + SVD::compute(_a, _w, _u, _vt); + CV_Assert(_w.data == (uchar*)&w.val[0] && _u.data == (uchar*)&u.val[0] && _vt.data == (uchar*)&vt.val[0]); +} + +template inline void +SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w ) +{ + CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector."); + Mat _a(a, false), _w(w, false); + SVD::compute(_a, _w); + CV_Assert(_w.data == (uchar*)&w.val[0]); +} + +template inline void +SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u, + const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, + Matx<_Tp, n, nb>& dst ) +{ + CV_StaticAssert( nm == MIN(m, n), "Invalid size of output vector."); + Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false); + SVD::backSubst(_w, _u, _vt, _rhs, _dst); + CV_Assert(_dst.data == (uchar*)&dst.val[0]); +} + + + +/////////////////////////////////// Multiply-with-Carry RNG /////////////////////////////////// + +inline RNG::RNG() { state = 0xffffffff; } +inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; } + +inline RNG::operator uchar() { return (uchar)next(); } +inline RNG::operator schar() { return (schar)next(); } +inline RNG::operator ushort() { return (ushort)next(); } +inline RNG::operator short() { return (short)next(); } +inline RNG::operator int() { return (int)next(); } +inline RNG::operator unsigned() { return next(); } +inline RNG::operator float() { return next()*2.3283064365386962890625e-10f; } +inline RNG::operator double() { unsigned t = next(); return (((uint64)t << 32) | next()) * 5.4210108624275221700372640043497e-20; } + +inline unsigned RNG::operator ()(unsigned N) { return (unsigned)uniform(0,N); } +inline unsigned RNG::operator ()() { return next(); } + +inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next() % (b - a) + a); } +inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; } +inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; } + +inline bool RNG::operator ==(const RNG& other) const { return state == other.state; } + +inline unsigned RNG::next() +{ + state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32); + return (unsigned)state; +} + +//! returns the next uniformly-distributed random number of the specified type +template static inline _Tp randu() +{ + return (_Tp)theRNG(); +} + +///////////////////////////////// Formatted string generation ///////////////////////////////// + +/** @brief Returns a text string formatted using the printf-like expression. + +The function acts like sprintf but forms and returns an STL string. It can be used to form an error +message in the Exception constructor. +@param fmt printf-compatible formatting specifiers. + +**Note**: +|Type|Specifier| +|-|-| +|`const char*`|`%s`| +|`char`|`%c`| +|`float` / `double`|`%f`,`%g`| +|`int`, `long`, `long long`|`%d`, `%ld`, ``%lld`| +|`unsigned`, `unsigned long`, `unsigned long long`|`%u`, `%lu`, `%llu`| +|`uint64` -> `uintmax_t`, `int64` -> `intmax_t`|`%ju`, `%jd`| +|`size_t`|`%zu`| + */ +CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2); + +///////////////////////////////// Formatted output of cv::Mat ///////////////////////////////// + +static inline +Ptr format(InputArray mtx, Formatter::FormatType fmt) +{ + return Formatter::get(fmt)->format(mtx.getMat()); +} + +static inline +int print(Ptr fmtd, FILE* stream = stdout) +{ + int written = 0; + fmtd->reset(); + for(const char* str = fmtd->next(); str; str = fmtd->next()) + written += fputs(str, stream); + + return written; +} + +static inline +int print(const Mat& mtx, FILE* stream = stdout) +{ + return print(Formatter::get()->format(mtx), stream); +} + +static inline +int print(const UMat& mtx, FILE* stream = stdout) +{ + return print(Formatter::get()->format(mtx.getMat(ACCESS_READ)), stream); +} + +template static inline +int print(const std::vector >& vec, FILE* stream = stdout) +{ + return print(Formatter::get()->format(Mat(vec)), stream); +} + +template static inline +int print(const std::vector >& vec, FILE* stream = stdout) +{ + return print(Formatter::get()->format(Mat(vec)), stream); +} + +template static inline +int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout) +{ + return print(Formatter::get()->format(cv::Mat(matx)), stream); +} + +//! @endcond + +/****************************************************************************************\ +* Auxiliary algorithms * +\****************************************************************************************/ + +/** @brief Splits an element set into equivalency classes. + +The generic function partition implements an \f$O(N^2)\f$ algorithm for splitting a set of \f$N\f$ elements +into one or more equivalency classes, as described in + . The function returns the number of +equivalency classes. +@param _vec Set of elements stored as a vector. +@param labels Output vector of labels. It contains as many elements as vec. Each label labels[i] is +a 0-based cluster index of `vec[i]`. +@param predicate Equivalence predicate (pointer to a boolean function of two arguments or an +instance of the class that has the method bool operator()(const _Tp& a, const _Tp& b) ). The +predicate returns true when the elements are certainly in the same class, and returns false if they +may or may not be in the same class. +@ingroup core_cluster +*/ +template int +partition( const std::vector<_Tp>& _vec, std::vector& labels, + _EqPredicate predicate=_EqPredicate()) +{ + int i, j, N = (int)_vec.size(); + const _Tp* vec = &_vec[0]; + + const int PARENT=0; + const int RANK=1; + + std::vector _nodes(N*2); + int (*nodes)[2] = (int(*)[2])&_nodes[0]; + + // The first O(N) pass: create N single-vertex trees + for(i = 0; i < N; i++) + { + nodes[i][PARENT]=-1; + nodes[i][RANK] = 0; + } + + // The main O(N^2) pass: merge connected components + for( i = 0; i < N; i++ ) + { + int root = i; + + // find root + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + + for( j = 0; j < N; j++ ) + { + if( i == j || !predicate(vec[i], vec[j])) + continue; + int root2 = j; + + while( nodes[root2][PARENT] >= 0 ) + root2 = nodes[root2][PARENT]; + + if( root2 != root ) + { + // unite both trees + int rank = nodes[root][RANK], rank2 = nodes[root2][RANK]; + if( rank > rank2 ) + nodes[root2][PARENT] = root; + else + { + nodes[root][PARENT] = root2; + nodes[root2][RANK] += rank == rank2; + root = root2; + } + CV_Assert( nodes[root][PARENT] < 0 ); + + int k = j, parent; + + // compress the path from node2 to root + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + + // compress the path from node to root + k = i; + while( (parent = nodes[k][PARENT]) >= 0 ) + { + nodes[k][PARENT] = root; + k = parent; + } + } + } + } + + // Final O(N) pass: enumerate classes + labels.resize(N); + int nclasses = 0; + + for( i = 0; i < N; i++ ) + { + int root = i; + while( nodes[root][PARENT] >= 0 ) + root = nodes[root][PARENT]; + // re-use the rank as the class label + if( nodes[root][RANK] >= 0 ) + nodes[root][RANK] = ~nclasses++; + labels[i] = ~nodes[root][RANK]; + } + + return nclasses; +} + +} // cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/optim.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/optim.hpp new file mode 100644 index 0000000..f61a2b9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/optim.hpp @@ -0,0 +1,302 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the OpenCV Foundation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OPTIM_HPP +#define OPENCV_OPTIM_HPP + +#include "opencv2/core.hpp" + +namespace cv +{ + +/** @addtogroup core_optim +The algorithms in this section minimize or maximize function value within specified constraints or +without any constraints. +@{ +*/ + +/** @brief Basic interface for all solvers + */ +class CV_EXPORTS MinProblemSolver : public Algorithm +{ +public: + /** @brief Represents function being optimized + */ + class CV_EXPORTS Function + { + public: + virtual ~Function() {} + virtual int getDims() const = 0; + virtual double getGradientEps() const; + virtual double calc(const double* x) const = 0; + virtual void getGradient(const double* x,double* grad); + }; + + /** @brief Getter for the optimized function. + + The optimized function is represented by Function interface, which requires derivatives to + implement the calc(double*) and getDim() methods to evaluate the function. + + @return Smart-pointer to an object that implements Function interface - it represents the + function that is being optimized. It can be empty, if no function was given so far. + */ + virtual Ptr getFunction() const = 0; + + /** @brief Setter for the optimized function. + + *It should be called at least once before the call to* minimize(), as default value is not usable. + + @param f The new function to optimize. + */ + virtual void setFunction(const Ptr& f) = 0; + + /** @brief Getter for the previously set terminal criteria for this algorithm. + + @return Deep copy of the terminal criteria used at the moment. + */ + virtual TermCriteria getTermCriteria() const = 0; + + /** @brief Set terminal criteria for solver. + + This method *is not necessary* to be called before the first call to minimize(), as the default + value is sensible. + + Algorithm stops when the number of function evaluations done exceeds termcrit.maxCount, when + the function values at the vertices of simplex are within termcrit.epsilon range or simplex + becomes so small that it can enclosed in a box with termcrit.epsilon sides, whatever comes + first. + @param termcrit Terminal criteria to be used, represented as cv::TermCriteria structure. + */ + virtual void setTermCriteria(const TermCriteria& termcrit) = 0; + + /** @brief actually runs the algorithm and performs the minimization. + + The sole input parameter determines the centroid of the starting simplex (roughly, it tells + where to start), all the others (terminal criteria, initial step, function to be minimized) are + supposed to be set via the setters before the call to this method or the default values (not + always sensible) will be used. + + @param x The initial point, that will become a centroid of an initial simplex. After the algorithm + will terminate, it will be set to the point where the algorithm stops, the point of possible + minimum. + @return The value of a function at the point found. + */ + virtual double minimize(InputOutputArray x) = 0; +}; + +/** @brief This class is used to perform the non-linear non-constrained minimization of a function, + +defined on an `n`-dimensional Euclidean space, using the **Nelder-Mead method**, also known as +**downhill simplex method**. The basic idea about the method can be obtained from +. + +It should be noted, that this method, although deterministic, is rather a heuristic and therefore +may converge to a local minima, not necessary a global one. It is iterative optimization technique, +which at each step uses an information about the values of a function evaluated only at `n+1` +points, arranged as a *simplex* in `n`-dimensional space (hence the second name of the method). At +each step new point is chosen to evaluate function at, obtained value is compared with previous +ones and based on this information simplex changes it's shape , slowly moving to the local minimum. +Thus this method is using *only* function values to make decision, on contrary to, say, Nonlinear +Conjugate Gradient method (which is also implemented in optim). + +Algorithm stops when the number of function evaluations done exceeds termcrit.maxCount, when the +function values at the vertices of simplex are within termcrit.epsilon range or simplex becomes so +small that it can enclosed in a box with termcrit.epsilon sides, whatever comes first, for some +defined by user positive integer termcrit.maxCount and positive non-integer termcrit.epsilon. + +@note DownhillSolver is a derivative of the abstract interface +cv::MinProblemSolver, which in turn is derived from the Algorithm interface and is used to +encapsulate the functionality, common to all non-linear optimization algorithms in the optim +module. + +@note term criteria should meet following condition: +@code + termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0 +@endcode + */ +class CV_EXPORTS DownhillSolver : public MinProblemSolver +{ +public: + /** @brief Returns the initial step that will be used in downhill simplex algorithm. + + @param step Initial step that will be used in algorithm. Note, that although corresponding setter + accepts column-vectors as well as row-vectors, this method will return a row-vector. + @see DownhillSolver::setInitStep + */ + virtual void getInitStep(OutputArray step) const=0; + + /** @brief Sets the initial step that will be used in downhill simplex algorithm. + + Step, together with initial point (given in DownhillSolver::minimize) are two `n`-dimensional + vectors that are used to determine the shape of initial simplex. Roughly said, initial point + determines the position of a simplex (it will become simplex's centroid), while step determines the + spread (size in each dimension) of a simplex. To be more precise, if \f$s,x_0\in\mathbb{R}^n\f$ are + the initial step and initial point respectively, the vertices of a simplex will be: + \f$v_0:=x_0-\frac{1}{2} s\f$ and \f$v_i:=x_0+s_i\f$ for \f$i=1,2,\dots,n\f$ where \f$s_i\f$ denotes + projections of the initial step of *n*-th coordinate (the result of projection is treated to be + vector given by \f$s_i:=e_i\cdot\left\f$, where \f$e_i\f$ form canonical basis) + + @param step Initial step that will be used in algorithm. Roughly said, it determines the spread + (size in each dimension) of an initial simplex. + */ + virtual void setInitStep(InputArray step)=0; + + /** @brief This function returns the reference to the ready-to-use DownhillSolver object. + + All the parameters are optional, so this procedure can be called even without parameters at + all. In this case, the default values will be used. As default value for terminal criteria are + the only sensible ones, MinProblemSolver::setFunction() and DownhillSolver::setInitStep() + should be called upon the obtained object, if the respective parameters were not given to + create(). Otherwise, the two ways (give parameters to createDownhillSolver() or miss them out + and call the MinProblemSolver::setFunction() and DownhillSolver::setInitStep()) are absolutely + equivalent (and will drop the same errors in the same way, should invalid input be detected). + @param f Pointer to the function that will be minimized, similarly to the one you submit via + MinProblemSolver::setFunction. + @param initStep Initial step, that will be used to construct the initial simplex, similarly to the one + you submit via MinProblemSolver::setInitStep. + @param termcrit Terminal criteria to the algorithm, similarly to the one you submit via + MinProblemSolver::setTermCriteria. + */ + static Ptr create(const Ptr& f=Ptr(), + InputArray initStep=Mat_(1,1,0.0), + TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5000,0.000001)); +}; + +/** @brief This class is used to perform the non-linear non-constrained minimization of a function +with known gradient, + +defined on an *n*-dimensional Euclidean space, using the **Nonlinear Conjugate Gradient method**. +The implementation was done based on the beautifully clear explanatory article [An Introduction to +the Conjugate Gradient Method Without the Agonizing +Pain](http://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf) by Jonathan Richard +Shewchuk. The method can be seen as an adaptation of a standard Conjugate Gradient method (see, for +example ) for numerically solving the +systems of linear equations. + +It should be noted, that this method, although deterministic, is rather a heuristic method and +therefore may converge to a local minima, not necessary a global one. What is even more disastrous, +most of its behaviour is ruled by gradient, therefore it essentially cannot distinguish between +local minima and maxima. Therefore, if it starts sufficiently near to the local maximum, it may +converge to it. Another obvious restriction is that it should be possible to compute the gradient of +a function at any point, thus it is preferable to have analytic expression for gradient and +computational burden should be born by the user. + +The latter responsibility is accomplished via the getGradient method of a +MinProblemSolver::Function interface (which represents function being optimized). This method takes +point a point in *n*-dimensional space (first argument represents the array of coordinates of that +point) and compute its gradient (it should be stored in the second argument as an array). + +@note class ConjGradSolver thus does not add any new methods to the basic MinProblemSolver interface. + +@note term criteria should meet following condition: +@code + termcrit.type == (TermCriteria::MAX_ITER + TermCriteria::EPS) && termcrit.epsilon > 0 && termcrit.maxCount > 0 + // or + termcrit.type == TermCriteria::MAX_ITER) && termcrit.maxCount > 0 +@endcode + */ +class CV_EXPORTS ConjGradSolver : public MinProblemSolver +{ +public: + /** @brief This function returns the reference to the ready-to-use ConjGradSolver object. + + All the parameters are optional, so this procedure can be called even without parameters at + all. In this case, the default values will be used. As default value for terminal criteria are + the only sensible ones, MinProblemSolver::setFunction() should be called upon the obtained + object, if the function was not given to create(). Otherwise, the two ways (submit it to + create() or miss it out and call the MinProblemSolver::setFunction()) are absolutely equivalent + (and will drop the same errors in the same way, should invalid input be detected). + @param f Pointer to the function that will be minimized, similarly to the one you submit via + MinProblemSolver::setFunction. + @param termcrit Terminal criteria to the algorithm, similarly to the one you submit via + MinProblemSolver::setTermCriteria. + */ + static Ptr create(const Ptr& f=Ptr(), + TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5000,0.000001)); +}; + +//! return codes for cv::solveLP() function +enum SolveLPResult +{ + SOLVELP_UNBOUNDED = -2, //!< problem is unbounded (target function can achieve arbitrary high values) + SOLVELP_UNFEASIBLE = -1, //!< problem is unfeasible (there are no points that satisfy all the constraints imposed) + SOLVELP_SINGLE = 0, //!< there is only one maximum for target function + SOLVELP_MULTI = 1 //!< there are multiple maxima for target function - the arbitrary one is returned +}; + +/** @brief Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method). + +What we mean here by "linear programming problem" (or LP problem, for short) can be formulated as: + +\f[\mbox{Maximize } c\cdot x\\ + \mbox{Subject to:}\\ + Ax\leq b\\ + x\geq 0\f] + +Where \f$c\f$ is fixed `1`-by-`n` row-vector, \f$A\f$ is fixed `m`-by-`n` matrix, \f$b\f$ is fixed `m`-by-`1` +column vector and \f$x\f$ is an arbitrary `n`-by-`1` column vector, which satisfies the constraints. + +Simplex algorithm is one of many algorithms that are designed to handle this sort of problems +efficiently. Although it is not optimal in theoretical sense (there exist algorithms that can solve +any problem written as above in polynomial time, while simplex method degenerates to exponential +time for some special cases), it is well-studied, easy to implement and is shown to work well for +real-life purposes. + +The particular implementation is taken almost verbatim from **Introduction to Algorithms, third +edition** by T. H. Cormen, C. E. Leiserson, R. L. Rivest and Clifford Stein. In particular, the +Bland's rule is used to prevent cycling. + +@param Func This row-vector corresponds to \f$c\f$ in the LP problem formulation (see above). It should +contain 32- or 64-bit floating point numbers. As a convenience, column-vector may be also submitted, +in the latter case it is understood to correspond to \f$c^T\f$. +@param Constr `m`-by-`n+1` matrix, whose rightmost column corresponds to \f$b\f$ in formulation above +and the remaining to \f$A\f$. It should contain 32- or 64-bit floating point numbers. +@param z The solution will be returned here as a column-vector - it corresponds to \f$c\f$ in the +formulation above. It will contain 64-bit floating point numbers. +@return One of cv::SolveLPResult + */ +CV_EXPORTS_W int solveLP(InputArray Func, InputArray Constr, OutputArray z); + +//! @} + +}// cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ovx.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ovx.hpp new file mode 100644 index 0000000..8bb7d54 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/ovx.hpp @@ -0,0 +1,28 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2016, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +// OpenVX related definitions and declarations + +#pragma once +#ifndef OPENCV_OVX_HPP +#define OPENCV_OVX_HPP + +#include "cvdef.h" + +namespace cv +{ +/// Check if use of OpenVX is possible +CV_EXPORTS_W bool haveOpenVX(); + +/// Check if use of OpenVX is enabled +CV_EXPORTS_W bool useOpenVX(); + +/// Enable/disable use of OpenVX +CV_EXPORTS_W void setUseOpenVX(bool flag); +} // namespace cv + +#endif // OPENCV_OVX_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp new file mode 100644 index 0000000..b172cac --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp @@ -0,0 +1,72 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP +#define OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP + +#include "opencv2/core/parallel/parallel_backend.hpp" + +#if !defined(_OPENMP) && !defined(OPENCV_SKIP_OPENMP_PRESENSE_CHECK) +#error "This file must be compiled with enabled OpenMP" +#endif + +#include + +namespace cv { namespace parallel { namespace openmp { + +/** OpenMP parallel_for API implementation + * + * @sa setParallelForBackend + * @ingroup core_parallel_backend + */ +class ParallelForBackend : public ParallelForAPI +{ +protected: + int numThreads; + int numThreadsMax; +public: + ParallelForBackend() + { + numThreads = 0; + numThreadsMax = omp_get_max_threads(); + } + + virtual ~ParallelForBackend() {} + + virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) CV_OVERRIDE + { +#pragma omp parallel for schedule(dynamic) num_threads(numThreads > 0 ? numThreads : numThreadsMax) + for (int i = 0; i < tasks; ++i) + body_callback(i, i + 1, callback_data); + } + + virtual int getThreadNum() const CV_OVERRIDE + { + return omp_get_thread_num(); + } + + virtual int getNumThreads() const CV_OVERRIDE + { + return numThreads > 0 + ? numThreads + : numThreadsMax; + } + + virtual int setNumThreads(int nThreads) CV_OVERRIDE + { + int oldNumThreads = numThreads; + numThreads = nThreads; + // nothing needed as numThreads is used in #pragma omp parallel for directly + return oldNumThreads; + } + + const char* getName() const CV_OVERRIDE + { + return "openmp"; + } +}; + +}}} // namespace + +#endif // OPENCV_CORE_PARALLEL_FOR_OPENMP_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp new file mode 100644 index 0000000..04b0c4c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp @@ -0,0 +1,153 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_PARALLEL_FOR_TBB_HPP +#define OPENCV_CORE_PARALLEL_FOR_TBB_HPP + +#include "opencv2/core/parallel/parallel_backend.hpp" +#include + +#ifndef TBB_SUPPRESS_DEPRECATED_MESSAGES // supress warning +#define TBB_SUPPRESS_DEPRECATED_MESSAGES 1 +#endif +#include "tbb/tbb.h" +#if !defined(TBB_INTERFACE_VERSION) +#error "Unknows/unsupported TBB version" +#endif + +#if TBB_INTERFACE_VERSION >= 8000 +#include "tbb/task_arena.h" +#endif + +namespace cv { namespace parallel { namespace tbb { + +using namespace ::tbb; + +#if TBB_INTERFACE_VERSION >= 8000 +static tbb::task_arena& getArena() +{ + static tbb::task_arena tbbArena(tbb::task_arena::automatic); + return tbbArena; +} +#else +static tbb::task_scheduler_init& getScheduler() +{ + static tbb::task_scheduler_init tbbScheduler(tbb::task_scheduler_init::deferred); + return tbbScheduler; +} +#endif + +/** TBB parallel_for API implementation + * + * @sa setParallelForBackend + * @ingroup core_parallel_backend + */ +class ParallelForBackend : public ParallelForAPI +{ +protected: + int numThreads; + int numThreadsMax; +public: + ParallelForBackend() + { + CV_LOG_INFO(NULL, "Initializing TBB parallel backend: TBB_INTERFACE_VERSION=" << TBB_INTERFACE_VERSION); + numThreads = 0; +#if TBB_INTERFACE_VERSION >= 8000 + (void)getArena(); +#else + (void)getScheduler(); +#endif + } + + virtual ~ParallelForBackend() {} + + class CallbackProxy + { + const FN_parallel_for_body_cb_t& callback; + void* const callback_data; + const int tasks; + public: + inline CallbackProxy(int tasks_, FN_parallel_for_body_cb_t& callback_, void* callback_data_) + : callback(callback_), callback_data(callback_data_), tasks(tasks_) + { + // nothing + } + + void operator()(const tbb::blocked_range& range) const + { + this->callback(range.begin(), range.end(), callback_data); + } + + void operator()() const + { + tbb::parallel_for(tbb::blocked_range(0, tasks), *this); + } + }; + + virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) CV_OVERRIDE + { + CallbackProxy task(tasks, body_callback, callback_data); +#if TBB_INTERFACE_VERSION >= 8000 + getArena().execute(task); +#else + task(); +#endif + } + + virtual int getThreadNum() const CV_OVERRIDE + { +#if TBB_INTERFACE_VERSION >= 9100 + return tbb::this_task_arena::current_thread_index(); +#elif TBB_INTERFACE_VERSION >= 8000 + return tbb::task_arena::current_thread_index(); +#else + return 0; +#endif + } + + virtual int getNumThreads() const CV_OVERRIDE + { +#if TBB_INTERFACE_VERSION >= 9100 + return getArena().max_concurrency(); +#elif TBB_INTERFACE_VERSION >= 8000 + return numThreads > 0 + ? numThreads + : tbb::task_scheduler_init::default_num_threads(); +#else + return getScheduler().is_active() + ? numThreads + : tbb::task_scheduler_init::default_num_threads(); +#endif + } + + virtual int setNumThreads(int nThreads) CV_OVERRIDE + { + int oldNumThreads = numThreads; + numThreads = nThreads; + +#if TBB_INTERFACE_VERSION >= 8000 + auto& tbbArena = getArena(); + if (tbbArena.is_active()) + tbbArena.terminate(); + if (numThreads > 0) + tbbArena.initialize(numThreads); +#else + auto& tbbScheduler = getScheduler(); + if (tbbScheduler.is_active()) + tbbScheduler.terminate(); + if (numThreads > 0) + tbbScheduler.initialize(numThreads); +#endif + return oldNumThreads; + } + + const char* getName() const CV_OVERRIDE + { + return "tbb"; + } +}; + +}}} // namespace + +#endif // OPENCV_CORE_PARALLEL_FOR_TBB_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/parallel_backend.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/parallel_backend.hpp new file mode 100644 index 0000000..c3e8333 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/parallel/parallel_backend.hpp @@ -0,0 +1,90 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_PARALLEL_BACKEND_HPP +#define OPENCV_CORE_PARALLEL_BACKEND_HPP + +#include "opencv2/core/cvdef.h" +#include + +namespace cv { namespace parallel { +#ifndef CV_API_CALL +#define CV_API_CALL +#endif + +/** @addtogroup core_parallel_backend + * @{ + * API below is provided to resolve problem of CPU resource over-subscription by multiple thread pools from different multi-threading frameworks. + * This is common problem for cases when OpenCV compiled threading framework is different from the Users Applications framework. + * + * Applications can replace OpenCV `parallel_for()` backend with own implementation (to reuse Application's thread pool). + * + * + * ### Backend API usage examples + * + * #### Intel TBB + * + * - include header with simple implementation of TBB backend: + * @snippet parallel_backend/example-tbb.cpp tbb_include + * - execute backend replacement code: + * @snippet parallel_backend/example-tbb.cpp tbb_backend + * - configuration of compiler/linker options is responsibility of Application's scripts + * + * #### OpenMP + * + * - include header with simple implementation of OpenMP backend: + * @snippet parallel_backend/example-openmp.cpp openmp_include + * - execute backend replacement code: + * @snippet parallel_backend/example-openmp.cpp openmp_backend + * - Configuration of compiler/linker options is responsibility of Application's scripts + * + * + * ### Plugins support + * + * Runtime configuration options: + * - change backend priority: `OPENCV_PARALLEL_PRIORITY_=9999` + * - disable backend: `OPENCV_PARALLEL_PRIORITY_=0` + * - specify list of backends with high priority (>100000): `OPENCV_PARALLEL_PRIORITY_LIST=TBB,OPENMP`. Unknown backends are registered as new plugins. + * + */ + +/** Interface for parallel_for backends implementations + * + * @sa setParallelForBackend + */ +class CV_EXPORTS ParallelForAPI +{ +public: + virtual ~ParallelForAPI(); + + typedef void (CV_API_CALL *FN_parallel_for_body_cb_t)(int start, int end, void* data); + + virtual void parallel_for(int tasks, FN_parallel_for_body_cb_t body_callback, void* callback_data) = 0; + + virtual int getThreadNum() const = 0; + + virtual int getNumThreads() const = 0; + + virtual int setNumThreads(int nThreads) = 0; + + virtual const char* getName() const = 0; +}; + +/** @brief Replace OpenCV parallel_for backend + * + * Application can replace OpenCV `parallel_for()` backend with own implementation. + * + * @note This call is not thread-safe. Consider calling this function from the `main()` before any other OpenCV processing functions (and without any other created threads). + */ +CV_EXPORTS void setParallelForBackend(const std::shared_ptr& api, bool propagateNumThreads = true); + +/** @brief Change OpenCV parallel_for backend + * + * @note This call is not thread-safe. Consider calling this function from the `main()` before any other OpenCV processing functions (and without any other created threads). + */ +CV_EXPORTS_W bool setParallelForBackend(const std::string& backendName, bool propagateNumThreads = true); + +//! @} +}} // namespace +#endif // OPENCV_CORE_PARALLEL_BACKEND_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/persistence.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/persistence.hpp new file mode 100644 index 0000000..276f640 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/persistence.hpp @@ -0,0 +1,1350 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_PERSISTENCE_HPP +#define OPENCV_CORE_PERSISTENCE_HPP + +#ifndef CV_DOXYGEN +/// Define to support persistence legacy formats +#define CV__LEGACY_PERSISTENCE +#endif + +#ifndef __cplusplus +# error persistence.hpp header must be compiled as C++ +#endif + +//! @addtogroup core_c +//! @{ + +/** @brief "black box" representation of the file storage associated with a file on disk. + +Several functions that are described below take CvFileStorage\* as inputs and allow the user to +save or to load hierarchical collections that consist of scalar values, standard CXCore objects +(such as matrices, sequences, graphs), and user-defined objects. + +OpenCV can read and write data in XML (), YAML () or +JSON () formats. Below is an example of 3x3 floating-point identity matrix A, +stored in XML and YAML files +using CXCore functions: +XML: +@code{.xml} + + + + 3 + 3 +
f
+ 1. 0. 0. 0. 1. 0. 0. 0. 1. +
+
+@endcode +YAML: +@code{.yaml} + %YAML:1.0 + A: !!opencv-matrix + rows: 3 + cols: 3 + dt: f + data: [ 1., 0., 0., 0., 1., 0., 0., 0., 1.] +@endcode +As it can be seen from the examples, XML uses nested tags to represent hierarchy, while YAML uses +indentation for that purpose (similar to the Python programming language). + +The same functions can read and write data in both formats; the particular format is determined by +the extension of the opened file, ".xml" for XML files, ".yml" or ".yaml" for YAML and ".json" for +JSON. + */ + +//! @} core_c + +#include "opencv2/core/types.hpp" +#include "opencv2/core/mat.hpp" + +namespace cv { + +/** @addtogroup core_xml + +XML/YAML/JSON file storages. {#xml_storage} +======================= +Writing to a file storage. +-------------------------- +You can store and then restore various OpenCV data structures to/from XML (), +YAML () or JSON () formats. Also, it is possible to store +and load arbitrarily complex data structures, which include OpenCV data structures, as well as +primitive data types (integer and floating-point numbers and text strings) as their elements. + +Use the following procedure to write something to XML, YAML or JSON: +-# Create new FileStorage and open it for writing. It can be done with a single call to +FileStorage::FileStorage constructor that takes a filename, or you can use the default constructor +and then call FileStorage::open. Format of the file (XML, YAML or JSON) is determined from the filename +extension (".xml", ".yml"/".yaml" and ".json", respectively) +-# Write all the data you want using the streaming operator `<<`, just like in the case of STL +streams. +-# Close the file using FileStorage::release. FileStorage destructor also closes the file. + +Here is an example: +@code + #include "opencv2/core.hpp" + #include + + using namespace cv; + + int main(int, char** argv) + { + FileStorage fs("test.yml", FileStorage::WRITE); + + fs << "frameCount" << 5; + time_t rawtime; time(&rawtime); + fs << "calibrationDate" << asctime(localtime(&rawtime)); + Mat cameraMatrix = (Mat_(3,3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1); + Mat distCoeffs = (Mat_(5,1) << 0.1, 0.01, -0.001, 0, 0); + fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs; + fs << "features" << "["; + for( int i = 0; i < 3; i++ ) + { + int x = rand() % 640; + int y = rand() % 480; + uchar lbp = rand() % 256; + + fs << "{:" << "x" << x << "y" << y << "lbp" << "[:"; + for( int j = 0; j < 8; j++ ) + fs << ((lbp >> j) & 1); + fs << "]" << "}"; + } + fs << "]"; + fs.release(); + return 0; + } +@endcode +The sample above stores to YML an integer, a text string (calibration date), 2 matrices, and a custom +structure "feature", which includes feature coordinates and LBP (local binary pattern) value. Here +is output of the sample: +@code{.yaml} +%YAML:1.0 +frameCount: 5 +calibrationDate: "Fri Jun 17 14:09:29 2011\n" +cameraMatrix: !!opencv-matrix + rows: 3 + cols: 3 + dt: d + data: [ 1000., 0., 320., 0., 1000., 240., 0., 0., 1. ] +distCoeffs: !!opencv-matrix + rows: 5 + cols: 1 + dt: d + data: [ 1.0000000000000001e-01, 1.0000000000000000e-02, + -1.0000000000000000e-03, 0., 0. ] +features: + - { x:167, y:49, lbp:[ 1, 0, 0, 1, 1, 0, 1, 1 ] } + - { x:298, y:130, lbp:[ 0, 0, 0, 1, 0, 0, 1, 1 ] } + - { x:344, y:158, lbp:[ 1, 1, 0, 0, 0, 0, 1, 0 ] } +@endcode + +As an exercise, you can replace ".yml" with ".xml" or ".json" in the sample above and see, how the +corresponding XML file will look like. + +Several things can be noted by looking at the sample code and the output: + +- The produced YAML (and XML/JSON) consists of heterogeneous collections that can be nested. There are + 2 types of collections: named collections (mappings) and unnamed collections (sequences). In mappings + each element has a name and is accessed by name. This is similar to structures and std::map in + C/C++ and dictionaries in Python. In sequences elements do not have names, they are accessed by + indices. This is similar to arrays and std::vector in C/C++ and lists, tuples in Python. + "Heterogeneous" means that elements of each single collection can have different types. + + Top-level collection in YAML/XML/JSON is a mapping. Each matrix is stored as a mapping, and the matrix + elements are stored as a sequence. Then, there is a sequence of features, where each feature is + represented a mapping, and lbp value in a nested sequence. + +- When you write to a mapping (a structure), you write element name followed by its value. When you + write to a sequence, you simply write the elements one by one. OpenCV data structures (such as + cv::Mat) are written in absolutely the same way as simple C data structures - using `<<` + operator. + +- To write a mapping, you first write the special string `{` to the storage, then write the + elements as pairs (`fs << << `) and then write the closing + `}`. + +- To write a sequence, you first write the special string `[`, then write the elements, then + write the closing `]`. + +- In YAML/JSON (but not XML), mappings and sequences can be written in a compact Python-like inline + form. In the sample above matrix elements, as well as each feature, including its lbp value, is + stored in such inline form. To store a mapping/sequence in a compact form, put `:` after the + opening character, e.g. use `{:` instead of `{` and `[:` instead of `[`. When the + data is written to XML, those extra `:` are ignored. + +Reading data from a file storage. +--------------------------------- +To read the previously written XML, YAML or JSON file, do the following: +-# Open the file storage using FileStorage::FileStorage constructor or FileStorage::open method. + In the current implementation the whole file is parsed and the whole representation of file + storage is built in memory as a hierarchy of file nodes (see FileNode) + +-# Read the data you are interested in. Use FileStorage::operator [], FileNode::operator [] + and/or FileNodeIterator. + +-# Close the storage using FileStorage::release. + +Here is how to read the file created by the code sample above: +@code + FileStorage fs2("test.yml", FileStorage::READ); + + // first method: use (type) operator on FileNode. + int frameCount = (int)fs2["frameCount"]; + + String date; + // second method: use FileNode::operator >> + fs2["calibrationDate"] >> date; + + Mat cameraMatrix2, distCoeffs2; + fs2["cameraMatrix"] >> cameraMatrix2; + fs2["distCoeffs"] >> distCoeffs2; + + cout << "frameCount: " << frameCount << endl + << "calibration date: " << date << endl + << "camera matrix: " << cameraMatrix2 << endl + << "distortion coeffs: " << distCoeffs2 << endl; + + FileNode features = fs2["features"]; + FileNodeIterator it = features.begin(), it_end = features.end(); + int idx = 0; + std::vector lbpval; + + // iterate through a sequence using FileNodeIterator + for( ; it != it_end; ++it, idx++ ) + { + cout << "feature #" << idx << ": "; + cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp: ("; + // you can also easily read numerical arrays using FileNode >> std::vector operator. + (*it)["lbp"] >> lbpval; + for( int i = 0; i < (int)lbpval.size(); i++ ) + cout << " " << (int)lbpval[i]; + cout << ")" << endl; + } + fs2.release(); +@endcode + +Format specification {#format_spec} +-------------------- +`([count]{u|c|w|s|i|f|d})`... where the characters correspond to fundamental C++ types: +- `u` 8-bit unsigned number +- `c` 8-bit signed number +- `w` 16-bit unsigned number +- `s` 16-bit signed number +- `i` 32-bit signed number +- `f` single precision floating-point number +- `d` double precision floating-point number +- `r` pointer, 32 lower bits of which are written as a signed integer. The type can be used to + store structures with links between the elements. + +`count` is the optional counter of values of a given type. For example, `2if` means that each array +element is a structure of 2 integers, followed by a single-precision floating-point number. The +equivalent notations of the above specification are `iif`, `2i1f` and so forth. Other examples: `u` +means that the array consists of bytes, and `2d` means the array consists of pairs of doubles. + +@see @ref samples/cpp/filestorage.cpp +*/ + +//! @{ + +/** @example samples/cpp/filestorage.cpp +A complete example using the FileStorage interface +*/ + +////////////////////////// XML & YAML I/O ////////////////////////// + +class CV_EXPORTS FileNode; +class CV_EXPORTS FileNodeIterator; + +/** @brief XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or +reading data to/from a file. + */ +class CV_EXPORTS_W FileStorage +{ +public: + //! file storage mode + enum Mode + { + READ = 0, //!< value, open the file for reading + WRITE = 1, //!< value, open the file for writing + APPEND = 2, //!< value, open the file for appending + MEMORY = 4, //!< flag, read data from source or write data to the internal buffer (which is + //!< returned by FileStorage::release) + FORMAT_MASK = (7<<3), //!< mask for format flags + FORMAT_AUTO = 0, //!< flag, auto format + FORMAT_XML = (1<<3), //!< flag, XML format + FORMAT_YAML = (2<<3), //!< flag, YAML format + FORMAT_JSON = (3<<3), //!< flag, JSON format + + BASE64 = 64, //!< flag, write rawdata in Base64 by default. (consider using WRITE_BASE64) + WRITE_BASE64 = BASE64 | WRITE, //!< flag, enable both WRITE and BASE64 + }; + enum State + { + UNDEFINED = 0, + VALUE_EXPECTED = 1, + NAME_EXPECTED = 2, + INSIDE_MAP = 4 + }; + + /** @brief The constructors. + + The full constructor opens the file. Alternatively you can use the default constructor and then + call FileStorage::open. + */ + CV_WRAP FileStorage(); + + /** @overload + @copydoc open() + */ + CV_WRAP FileStorage(const String& filename, int flags, const String& encoding=String()); + + //! the destructor. calls release() + virtual ~FileStorage(); + + /** @brief Opens a file. + + See description of parameters in FileStorage::FileStorage. The method calls FileStorage::release + before opening the file. + @param filename Name of the file to open or the text string to read the data from. + Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON + respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both + FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify + the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters. + You can use this format, "*?base64" (e.g. "file.json?base64" (case sensitive)), as an alternative to + FileStorage::BASE64 flag. + @param flags Mode of operation. One of FileStorage::Mode + @param encoding Encoding of the file. Note that UTF-16 XML encoding is not supported currently and + you should use 8-bit encoding instead of it. + */ + CV_WRAP virtual bool open(const String& filename, int flags, const String& encoding=String()); + + /** @brief Checks whether the file is opened. + + @returns true if the object is associated with the current file and false otherwise. It is a + good practice to call this method after you tried to open a file. + */ + CV_WRAP virtual bool isOpened() const; + + /** @brief Closes the file and releases all the memory buffers. + + Call this method after all I/O operations with the storage are finished. + */ + CV_WRAP virtual void release(); + + /** @brief Closes the file and releases all the memory buffers. + + Call this method after all I/O operations with the storage are finished. If the storage was + opened for writing data and FileStorage::WRITE was specified + */ + CV_WRAP virtual String releaseAndGetString(); + + /** @brief Returns the first element of the top-level mapping. + @returns The first element of the top-level mapping. + */ + CV_WRAP FileNode getFirstTopLevelNode() const; + + /** @brief Returns the top-level mapping + @param streamidx Zero-based index of the stream. In most cases there is only one stream in the file. + However, YAML supports multiple streams and so there can be several. + @returns The top-level mapping. + */ + CV_WRAP FileNode root(int streamidx=0) const; + + /** @brief Returns the specified element of the top-level mapping. + @param nodename Name of the file node. + @returns Node with the given name. + */ + FileNode operator[](const String& nodename) const; + + /** @overload */ + CV_WRAP_AS(getNode) FileNode operator[](const char* nodename) const; + + /** + * @brief Simplified writing API to use with bindings. + * @param name Name of the written object. When writing to sequences (a.k.a. "arrays"), pass an empty string. + * @param val Value of the written object. + */ + CV_WRAP void write(const String& name, int val); + /// @overload + CV_WRAP void write(const String& name, double val); + /// @overload + CV_WRAP void write(const String& name, const String& val); + /// @overload + CV_WRAP void write(const String& name, const Mat& val); + /// @overload + CV_WRAP void write(const String& name, const std::vector& val); + + /** @brief Writes multiple numbers. + + Writes one or more numbers of the specified format to the currently written structure. Usually it is + more convenient to use operator `<<` instead of this method. + @param fmt Specification of each array element, see @ref format_spec "format specification" + @param vec Pointer to the written array. + @param len Number of the uchar elements to write. + */ + void writeRaw( const String& fmt, const void* vec, size_t len ); + + /** @brief Writes a comment. + + The function writes a comment into file storage. The comments are skipped when the storage is read. + @param comment The written comment, single-line or multi-line + @param append If true, the function tries to put the comment at the end of current line. + Else if the comment is multi-line, or if it does not fit at the end of the current + line, the comment starts a new line. + */ + CV_WRAP void writeComment(const String& comment, bool append = false); + + /** @brief Starts to write a nested structure (sequence or a mapping). + @param name name of the structure. When writing to sequences (a.k.a. "arrays"), pass an empty string. + @param flags type of the structure (FileNode::MAP or FileNode::SEQ (both with optional FileNode::FLOW)). + @param typeName optional name of the type you store. The effect of setting this depends on the storage format. + I.e. if the format has a specification for storing type information, this parameter is used. + */ + CV_WRAP void startWriteStruct(const String& name, int flags, const String& typeName=String()); + + /** @brief Finishes writing nested structure (should pair startWriteStruct()) + */ + CV_WRAP void endWriteStruct(); + + /** @brief Returns the normalized object name for the specified name of a file. + @param filename Name of a file + @returns The normalized object name. + */ + static String getDefaultObjectName(const String& filename); + + /** @brief Returns the current format. + * @returns The current format, see FileStorage::Mode + */ + CV_WRAP int getFormat() const; + + int state; + std::string elname; + + class Impl; + Ptr p; +}; + +/** @brief File Storage Node class. + +The node is used to store each and every element of the file storage opened for reading. When +XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of +nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of +other nodes. There can be named collections (mappings) where each element has a name and it is +accessed by a name, and ordered collections (sequences) where elements do not have names but rather +accessed by index. Type of the file node can be determined using FileNode::type method. + +Note that file nodes are only used for navigating file storages opened for reading. When a file +storage is opened for writing, no data is stored in memory after it is written. + */ +class CV_EXPORTS_W_SIMPLE FileNode +{ +public: + //! type of the file storage node + enum + { + NONE = 0, //!< empty node + INT = 1, //!< an integer + REAL = 2, //!< floating-point number + FLOAT = REAL, //!< synonym or REAL + STR = 3, //!< text string in UTF-8 encoding + STRING = STR, //!< synonym for STR + SEQ = 4, //!< sequence + MAP = 5, //!< mapping + TYPE_MASK = 7, + + FLOW = 8, //!< compact representation of a sequence or mapping. Used only by YAML writer + UNIFORM = 8, //!< if set, means that all the collection elements are numbers of the same type (real's or int's). + //!< UNIFORM is used only when reading FileStorage; FLOW is used only when writing. So they share the same bit + EMPTY = 16, //!< empty structure (sequence or mapping) + NAMED = 32 //!< the node has a name (i.e. it is element of a mapping). + }; + /** @brief The constructors. + + These constructors are used to create a default file node, construct it from obsolete structures or + from the another file node. + */ + CV_WRAP FileNode(); + + /** @overload + @param fs Pointer to the file storage structure. + @param blockIdx Index of the memory block where the file node is stored + @param ofs Offset in bytes from the beginning of the serialized storage + + @deprecated + */ + FileNode(const FileStorage* fs, size_t blockIdx, size_t ofs); + + /** @overload + @param node File node to be used as initialization for the created file node. + */ + FileNode(const FileNode& node); + + FileNode& operator=(const FileNode& node); + + /** @brief Returns element of a mapping node or a sequence node. + @param nodename Name of an element in the mapping node. + @returns Returns the element with the given identifier. + */ + FileNode operator[](const String& nodename) const; + + /** @overload + @param nodename Name of an element in the mapping node. + */ + CV_WRAP_AS(getNode) FileNode operator[](const char* nodename) const; + + /** @overload + @param i Index of an element in the sequence node. + */ + CV_WRAP_AS(at) FileNode operator[](int i) const; + + /** @brief Returns keys of a mapping node. + @returns Keys of a mapping node. + */ + CV_WRAP std::vector keys() const; + + /** @brief Returns type of the node. + @returns Type of the node. See FileNode::Type + */ + CV_WRAP int type() const; + + //! returns true if the node is empty + CV_WRAP bool empty() const; + //! returns true if the node is a "none" object + CV_WRAP bool isNone() const; + //! returns true if the node is a sequence + CV_WRAP bool isSeq() const; + //! returns true if the node is a mapping + CV_WRAP bool isMap() const; + //! returns true if the node is an integer + CV_WRAP bool isInt() const; + //! returns true if the node is a floating-point number + CV_WRAP bool isReal() const; + //! returns true if the node is a text string + CV_WRAP bool isString() const; + //! returns true if the node has a name + CV_WRAP bool isNamed() const; + //! returns the node name or an empty string if the node is nameless + CV_WRAP std::string name() const; + //! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise. + CV_WRAP size_t size() const; + //! returns raw size of the FileNode in bytes + CV_WRAP size_t rawSize() const; + //! returns the node content as an integer. If the node stores floating-point number, it is rounded. + operator int() const; + //! returns the node content as float + operator float() const; + //! returns the node content as double + operator double() const; + //! returns the node content as text string + inline operator std::string() const { return this->string(); } + + static bool isMap(int flags); + static bool isSeq(int flags); + static bool isCollection(int flags); + static bool isEmptyCollection(int flags); + static bool isFlow(int flags); + + uchar* ptr(); + const uchar* ptr() const; + + //! returns iterator pointing to the first node element + FileNodeIterator begin() const; + //! returns iterator pointing to the element following the last node element + FileNodeIterator end() const; + + /** @brief Reads node elements to the buffer with the specified format. + + Usually it is more convenient to use operator `>>` instead of this method. + @param fmt Specification of each array element. See @ref format_spec "format specification" + @param vec Pointer to the destination array. + @param len Number of bytes to read (buffer size limit). If it is greater than number of + remaining elements then all of them will be read. + */ + void readRaw( const String& fmt, void* vec, size_t len ) const; + + /** Internal method used when reading FileStorage. + Sets the type (int, real or string) and value of the previously created node. + */ + void setValue( int type, const void* value, int len=-1 ); + + //! Simplified reading API to use with bindings. + CV_WRAP double real() const; + //! Simplified reading API to use with bindings. + CV_WRAP std::string string() const; + //! Simplified reading API to use with bindings. + CV_WRAP Mat mat() const; + + //protected: + FileNode(FileStorage::Impl* fs, size_t blockIdx, size_t ofs); + + FileStorage::Impl* fs; + size_t blockIdx; + size_t ofs; +}; + + +/** @brief used to iterate through sequences and mappings. + + A standard STL notation, with node.begin(), node.end() denoting the beginning and the end of a + sequence, stored in node. See the data reading sample in the beginning of the section. + */ +class CV_EXPORTS FileNodeIterator +{ +public: + /** @brief The constructors. + + These constructors are used to create a default iterator, set it to specific element in a file node + or construct it from another iterator. + */ + FileNodeIterator(); + + /** @overload + @param node File node - the collection to iterate over; + it can be a scalar (equivalent to 1-element collection) or "none" (equivalent to empty collection). + @param seekEnd - true if iterator needs to be set after the last element of the node; + that is: + * node.begin() => FileNodeIterator(node, false) + * node.end() => FileNodeIterator(node, true) + */ + FileNodeIterator(const FileNode& node, bool seekEnd); + + /** @overload + @param it Iterator to be used as initialization for the created iterator. + */ + FileNodeIterator(const FileNodeIterator& it); + + FileNodeIterator& operator=(const FileNodeIterator& it); + + //! returns the currently observed element + FileNode operator *() const; + + //! moves iterator to the next node + FileNodeIterator& operator ++ (); + //! moves iterator to the next node + FileNodeIterator operator ++ (int); + //! moves iterator forward by the specified offset (possibly negative) + FileNodeIterator& operator += (int ofs); + + /** @brief Reads node elements to the buffer with the specified format. + + Usually it is more convenient to use operator `>>` instead of this method. + @param fmt Specification of each array element. See @ref format_spec "format specification" + @param vec Pointer to the destination array. + @param len Number of bytes to read (buffer size limit). If it is greater than number of + remaining elements then all of them will be read. + */ + FileNodeIterator& readRaw( const String& fmt, void* vec, + size_t len=(size_t)INT_MAX ); + + //! returns the number of remaining (not read yet) elements + size_t remaining() const; + + bool equalTo(const FileNodeIterator& it) const; + +protected: + FileStorage::Impl* fs; + size_t blockIdx; + size_t ofs; + size_t blockSize; + size_t nodeNElems; + size_t idx; +}; + +//! @} core_xml + +/////////////////// XML & YAML I/O implementation ////////////////// + +//! @relates cv::FileStorage +//! @{ + +CV_EXPORTS void write( FileStorage& fs, const String& name, int value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, float value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, double value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, const String& value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, const Mat& value ); +CV_EXPORTS void write( FileStorage& fs, const String& name, const SparseMat& value ); +#ifdef CV__LEGACY_PERSISTENCE +CV_EXPORTS void write( FileStorage& fs, const String& name, const std::vector& value); +CV_EXPORTS void write( FileStorage& fs, const String& name, const std::vector& value); +#endif + +CV_EXPORTS void writeScalar( FileStorage& fs, int value ); +CV_EXPORTS void writeScalar( FileStorage& fs, float value ); +CV_EXPORTS void writeScalar( FileStorage& fs, double value ); +CV_EXPORTS void writeScalar( FileStorage& fs, const String& value ); + +//! @} + +//! @relates cv::FileNode +//! @{ + +CV_EXPORTS void read(const FileNode& node, int& value, int default_value); +CV_EXPORTS void read(const FileNode& node, float& value, float default_value); +CV_EXPORTS void read(const FileNode& node, double& value, double default_value); +CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value); +CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() ); +CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat = SparseMat() ); +#ifdef CV__LEGACY_PERSISTENCE +CV_EXPORTS void read(const FileNode& node, std::vector& keypoints); +CV_EXPORTS void read(const FileNode& node, std::vector& matches); +#endif +CV_EXPORTS void read(const FileNode& node, KeyPoint& value, const KeyPoint& default_value); +CV_EXPORTS void read(const FileNode& node, DMatch& value, const DMatch& default_value); + +template static inline void read(const FileNode& node, Point_<_Tp>& value, const Point_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 2 ? default_value : Point_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1])); +} + +template static inline void read(const FileNode& node, Point3_<_Tp>& value, const Point3_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 3 ? default_value : Point3_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]), + saturate_cast<_Tp>(temp[2])); +} + +template static inline void read(const FileNode& node, Size_<_Tp>& value, const Size_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 2 ? default_value : Size_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1])); +} + +template static inline void read(const FileNode& node, Complex<_Tp>& value, const Complex<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 2 ? default_value : Complex<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1])); +} + +template static inline void read(const FileNode& node, Rect_<_Tp>& value, const Rect_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 4 ? default_value : Rect_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]), + saturate_cast<_Tp>(temp[2]), saturate_cast<_Tp>(temp[3])); +} + +template static inline void read(const FileNode& node, Vec<_Tp, cn>& value, const Vec<_Tp, cn>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != cn ? default_value : Vec<_Tp, cn>(&temp[0]); +} + +template static inline void read(const FileNode& node, Matx<_Tp, m, n>& value, const Matx<_Tp, m, n>& default_matx = Matx<_Tp, m, n>()) +{ + Mat temp; + read(node, temp); // read as a Mat class + + if (temp.empty()) + value = default_matx; + else + value = Matx<_Tp, m, n>(temp); +} + +template static inline void read(const FileNode& node, Scalar_<_Tp>& value, const Scalar_<_Tp>& default_value) +{ + std::vector<_Tp> temp; FileNodeIterator it = node.begin(); it >> temp; + value = temp.size() != 4 ? default_value : Scalar_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]), + saturate_cast<_Tp>(temp[2]), saturate_cast<_Tp>(temp[3])); +} + +static inline void read(const FileNode& node, Range& value, const Range& default_value) +{ + Point2i temp(value.start, value.end); const Point2i default_temp = Point2i(default_value.start, default_value.end); + read(node, temp, default_temp); + value.start = temp.x; value.end = temp.y; +} + +//! @} + +/** @brief Writes string to a file storage. +@relates cv::FileStorage + */ +CV_EXPORTS FileStorage& operator << (FileStorage& fs, const String& str); + +//! @cond IGNORED + +namespace internal +{ + class CV_EXPORTS WriteStructContext + { + public: + WriteStructContext(FileStorage& _fs, const String& name, int flags, const String& typeName = String()); + ~WriteStructContext(); + private: + FileStorage* fs; + }; + + template class VecWriterProxy + { + public: + VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} + void operator()(const std::vector<_Tp>& vec) const + { + size_t count = vec.size(); + for (size_t i = 0; i < count; i++) + write(*fs, vec[i]); + } + private: + FileStorage* fs; + }; + + template class VecWriterProxy<_Tp, 1> + { + public: + VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} + void operator()(const std::vector<_Tp>& vec) const + { + int _fmt = traits::SafeFmt<_Tp>::fmt; + char fmt[] = { (char)((_fmt >> 8) + '1'), (char)_fmt, '\0' }; + fs->writeRaw(fmt, !vec.empty() ? (uchar*)&vec[0] : 0, vec.size() * sizeof(_Tp)); + } + private: + FileStorage* fs; + }; + + template class VecReaderProxy + { + public: + VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} + void operator()(std::vector<_Tp>& vec, size_t count) const + { + count = std::min(count, it->remaining()); + vec.resize(count); + for (size_t i = 0; i < count; i++, ++(*it)) + read(**it, vec[i], _Tp()); + } + private: + FileNodeIterator* it; + }; + + template class VecReaderProxy<_Tp, 1> + { + public: + VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} + void operator()(std::vector<_Tp>& vec, size_t count) const + { + size_t remaining = it->remaining(); + size_t cn = DataType<_Tp>::channels; + int _fmt = traits::SafeFmt<_Tp>::fmt; + CV_Assert((_fmt >> 8) < 9); + char fmt[] = { (char)((_fmt >> 8)+'1'), (char)_fmt, '\0' }; + CV_Assert((remaining % cn) == 0); + size_t remaining1 = remaining / cn; + count = count > remaining1 ? remaining1 : count; + vec.resize(count); + it->readRaw(fmt, !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp)); + } + private: + FileNodeIterator* it; + }; + +} // internal + +//! @endcond + +//! @relates cv::FileStorage +//! @{ + +template static inline +void write(FileStorage& fs, const _Tp& value) +{ + write(fs, String(), value); +} + +template<> inline +void write( FileStorage& fs, const int& value ) +{ + writeScalar(fs, value); +} + +template<> inline +void write( FileStorage& fs, const float& value ) +{ + writeScalar(fs, value); +} + +template<> inline +void write( FileStorage& fs, const double& value ) +{ + writeScalar(fs, value); +} + +template<> inline +void write( FileStorage& fs, const String& value ) +{ + writeScalar(fs, value); +} + +template static inline +void write(FileStorage& fs, const Point_<_Tp>& pt ) +{ + write(fs, pt.x); + write(fs, pt.y); +} + +template static inline +void write(FileStorage& fs, const Point3_<_Tp>& pt ) +{ + write(fs, pt.x); + write(fs, pt.y); + write(fs, pt.z); +} + +template static inline +void write(FileStorage& fs, const Size_<_Tp>& sz ) +{ + write(fs, sz.width); + write(fs, sz.height); +} + +template static inline +void write(FileStorage& fs, const Complex<_Tp>& c ) +{ + write(fs, c.re); + write(fs, c.im); +} + +template static inline +void write(FileStorage& fs, const Rect_<_Tp>& r ) +{ + write(fs, r.x); + write(fs, r.y); + write(fs, r.width); + write(fs, r.height); +} + +template static inline +void write(FileStorage& fs, const Vec<_Tp, cn>& v ) +{ + for(int i = 0; i < cn; i++) + write(fs, v.val[i]); +} + +template static inline +void write(FileStorage& fs, const Matx<_Tp, m, n>& x ) +{ + write(fs, Mat(x)); // write as a Mat class +} + +template static inline +void write(FileStorage& fs, const Scalar_<_Tp>& s ) +{ + write(fs, s.val[0]); + write(fs, s.val[1]); + write(fs, s.val[2]); + write(fs, s.val[3]); +} + +static inline +void write(FileStorage& fs, const Range& r ) +{ + write(fs, r.start); + write(fs, r.end); +} + +template static inline +void write( FileStorage& fs, const std::vector<_Tp>& vec ) +{ + cv::internal::VecWriterProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> w(&fs); + w(vec); +} + +template static inline +void write(FileStorage& fs, const String& name, const Point_<_Tp>& pt ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, pt); +} + +template static inline +void write(FileStorage& fs, const String& name, const Point3_<_Tp>& pt ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, pt); +} + +template static inline +void write(FileStorage& fs, const String& name, const Size_<_Tp>& sz ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, sz); +} + +template static inline +void write(FileStorage& fs, const String& name, const Complex<_Tp>& c ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, c); +} + +template static inline +void write(FileStorage& fs, const String& name, const Rect_<_Tp>& r ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, r); +} + +template static inline +void write(FileStorage& fs, const String& name, const Vec<_Tp, cn>& v ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, v); +} + +template static inline +void write(FileStorage& fs, const String& name, const Matx<_Tp, m, n>& x ) +{ + write(fs, name, Mat(x)); // write as a Mat class +} + +template static inline +void write(FileStorage& fs, const String& name, const Scalar_<_Tp>& s ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, s); +} + +static inline +void write(FileStorage& fs, const String& name, const Range& r ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, r); +} + +static inline +void write(FileStorage& fs, const String& name, const KeyPoint& kpt) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, kpt.pt.x); + write(fs, kpt.pt.y); + write(fs, kpt.size); + write(fs, kpt.angle); + write(fs, kpt.response); + write(fs, kpt.octave); + write(fs, kpt.class_id); +} + +static inline +void write(FileStorage& fs, const String& name, const DMatch& m) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW); + write(fs, m.queryIdx); + write(fs, m.trainIdx); + write(fs, m.imgIdx); + write(fs, m.distance); +} + +template::value >::type* = nullptr> +static inline void write( FileStorage& fs, const String& name, const _Tp& val ) +{ + write(fs, name, static_cast(val)); +} + +template static inline +void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+(traits::SafeFmt<_Tp>::fmt != 0 ? FileNode::FLOW : 0)); + write(fs, vec); +} + +template static inline +void write( FileStorage& fs, const String& name, const std::vector< std::vector<_Tp> >& vec ) +{ + cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ); + for(size_t i = 0; i < vec.size(); i++) + { + cv::internal::WriteStructContext ws_(fs, name, FileNode::SEQ+(traits::SafeFmt<_Tp>::fmt != 0 ? FileNode::FLOW : 0)); + write(fs, vec[i]); + } +} + +#ifdef CV__LEGACY_PERSISTENCE +// This code is not needed anymore, but it is preserved here to keep source compatibility +// Implementation is similar to templates instantiations +static inline void write(FileStorage& fs, const KeyPoint& kpt) { write(fs, String(), kpt); } +static inline void write(FileStorage& fs, const DMatch& m) { write(fs, String(), m); } +static inline void write(FileStorage& fs, const std::vector& vec) +{ + cv::internal::VecWriterProxy w(&fs); + w(vec); +} +static inline void write(FileStorage& fs, const std::vector& vec) +{ + cv::internal::VecWriterProxy w(&fs); + w(vec); + +} +#endif + +//! @} FileStorage + +//! @relates cv::FileNode +//! @{ + +static inline +void read(const FileNode& node, bool& value, bool default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = temp != 0; +} + +static inline +void read(const FileNode& node, uchar& value, uchar default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +static inline +void read(const FileNode& node, schar& value, schar default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +static inline +void read(const FileNode& node, ushort& value, ushort default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +static inline +void read(const FileNode& node, short& value, short default_value) +{ + int temp; + read(node, temp, (int)default_value); + value = saturate_cast(temp); +} + +template static inline +void read( FileNodeIterator& it, std::vector<_Tp>& vec, size_t maxCount = (size_t)INT_MAX ) +{ + cv::internal::VecReaderProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> r(&it); + r(vec, maxCount); +} + +template::value >::type* = nullptr> +static inline void read(const FileNode& node, _Tp& value, const _Tp& default_value = static_cast<_Tp>(0)) +{ + int temp; + read(node, temp, static_cast(default_value)); + value = static_cast<_Tp>(temp); +} + +template static inline +void read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>& default_value = std::vector<_Tp>() ) +{ + if(node.empty()) + vec = default_value; + else + { + FileNodeIterator it = node.begin(); + read( it, vec ); + } +} + +static inline +void read( const FileNode& node, std::vector& vec, const std::vector& default_value ) +{ + if(node.empty()) + vec = default_value; + else + read(node, vec); +} + +static inline +void read( const FileNode& node, std::vector& vec, const std::vector& default_value ) +{ + if(node.empty()) + vec = default_value; + else + read(node, vec); +} + +//! @} FileNode + +//! @relates cv::FileStorage +//! @{ + +/** @brief Writes data to a file storage. + */ +template static inline +FileStorage& operator << (FileStorage& fs, const _Tp& value) +{ + if( !fs.isOpened() ) + return fs; + if( fs.state == FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP ) + CV_Error( Error::StsError, "No element name has been given" ); + write( fs, fs.elname, value ); + if( fs.state & FileStorage::INSIDE_MAP ) + fs.state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP; + return fs; +} + +/** @brief Writes data to a file storage. + */ +static inline +FileStorage& operator << (FileStorage& fs, const char* str) +{ + return (fs << String(str)); +} + +/** @brief Writes data to a file storage. + */ +static inline +FileStorage& operator << (FileStorage& fs, char* value) +{ + return (fs << String(value)); +} + +//! @} FileStorage + +//! @relates cv::FileNodeIterator +//! @{ + +/** @brief Reads data from a file storage. + */ +template static inline +FileNodeIterator& operator >> (FileNodeIterator& it, _Tp& value) +{ + read( *it, value, _Tp()); + return ++it; +} + +/** @brief Reads data from a file storage. + */ +template static inline +FileNodeIterator& operator >> (FileNodeIterator& it, std::vector<_Tp>& vec) +{ + cv::internal::VecReaderProxy<_Tp, traits::SafeFmt<_Tp>::fmt != 0> r(&it); + r(vec, (size_t)INT_MAX); + return it; +} + +//! @} FileNodeIterator + +//! @relates cv::FileNode +//! @{ + +/** @brief Reads data from a file storage. + */ +template static inline +void operator >> (const FileNode& n, _Tp& value) +{ + read( n, value, _Tp()); +} + +/** @brief Reads data from a file storage. + */ +template static inline +void operator >> (const FileNode& n, std::vector<_Tp>& vec) +{ + FileNodeIterator it = n.begin(); + it >> vec; +} + +/** @brief Reads KeyPoint from a file storage. +*/ +//It needs special handling because it contains two types of fields, int & float. +static inline +void operator >> (const FileNode& n, KeyPoint& kpt) +{ + FileNodeIterator it = n.begin(); + it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave >> kpt.class_id; +} + +#ifdef CV__LEGACY_PERSISTENCE +static inline +void operator >> (const FileNode& n, std::vector& vec) +{ + read(n, vec); +} +static inline +void operator >> (const FileNode& n, std::vector& vec) +{ + read(n, vec); +} +#endif + +/** @brief Reads DMatch from a file storage. +*/ +//It needs special handling because it contains two types of fields, int & float. +static inline +void operator >> (const FileNode& n, DMatch& m) +{ + FileNodeIterator it = n.begin(); + it >> m.queryIdx >> m.trainIdx >> m.imgIdx >> m.distance; +} + +//! @} FileNode + +//! @relates cv::FileNodeIterator +//! @{ + +CV_EXPORTS bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2); +CV_EXPORTS bool operator != (const FileNodeIterator& it1, const FileNodeIterator& it2); + +static inline +ptrdiff_t operator - (const FileNodeIterator& it1, const FileNodeIterator& it2) +{ + return it2.remaining() - it1.remaining(); +} + +static inline +bool operator < (const FileNodeIterator& it1, const FileNodeIterator& it2) +{ + return it1.remaining() > it2.remaining(); +} + +//! @} FileNodeIterator + +} // cv + +#endif // OPENCV_CORE_PERSISTENCE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/quaternion.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/quaternion.hpp new file mode 100644 index 0000000..8c21501 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/quaternion.hpp @@ -0,0 +1,1696 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang +#ifndef OPENCV_CORE_QUATERNION_HPP +#define OPENCV_CORE_QUATERNION_HPP + +#include +#include +#include +namespace cv +{ +//! @addtogroup core +//! @{ + +//! Unit quaternion flag +enum QuatAssumeType +{ + /** + * This flag is specified by default. + * If this flag is specified, the input quaternions are assumed to be not unit quaternions. + * It can guarantee the correctness of the calculations, + * although the calculation speed will be slower than the flag QUAT_ASSUME_UNIT. + */ + QUAT_ASSUME_NOT_UNIT, + /** + * If this flag is specified, the input quaternions are assumed to be unit quaternions which + * will save some computations. However, if this flag is specified without unit quaternion, + * the program correctness of the result will not be guaranteed. + */ + QUAT_ASSUME_UNIT +}; + +class QuatEnum +{ +public: + /** @brief Enum of Euler angles type. + * + * Without considering the possibility of using two different convertions for the definition of the rotation axes , + * there exists twelve possible sequences of rotation axes, divided into two groups: + * - Proper Euler angles (Z-X-Z, X-Y-X, Y-Z-Y, Z-Y-Z, X-Z-X, Y-X-Y) + * - Tait–Bryan angles (X-Y-Z, Y-Z-X, Z-X-Y, X-Z-Y, Z-Y-X, Y-X-Z). + * + * The three elemental rotations may be [extrinsic](https://en.wikipedia.org/wiki/Euler_angles#Definition_by_extrinsic_rotations) + * (rotations about the axes *xyz* of the original coordinate system, which is assumed to remain motionless), + * or [intrinsic](https://en.wikipedia.org/wiki/Euler_angles#Definition_by_intrinsic_rotations)(rotations about the axes of the rotating coordinate system *XYZ*, solidary with the moving body, which changes its orientation after each elemental rotation). + * + * + * Extrinsic and intrinsic rotations are relevant. + * + * The definition of the Euler angles is as following, + * - \f$\theta_1 \f$ represents the first rotation angle, + * - \f$\theta_2 \f$ represents the second rotation angle, + * - \f$\theta_3 \f$ represents the third rotation angle. + * + * For intrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:\f[R =X(\theta_1) Y(\theta_2) Z(\theta_3) \f] + * For extrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:\f[R =Z({\theta_3}) Y({\theta_2}) X({\theta_1})\f] + * where + * \f[X({\theta})={\begin{bmatrix}1&0&0\\0&\cos {\theta_1} &-\sin {\theta_1} \\0&\sin {\theta_1} &\cos {\theta_1} \\\end{bmatrix}}, + * Y({\theta})={\begin{bmatrix}\cos \theta_{2}&0&\sin \theta_{2}\\0&1 &0 \\\ -sin \theta_2& 0&\cos \theta_{2} \\\end{bmatrix}}, + * Z({\theta})={\begin{bmatrix}\cos\theta_{3} &-\sin \theta_3&0\\\sin \theta_3 &\cos \theta_3 &0\\0&0&1\\\end{bmatrix}}. + * \f] + * + * The function is designed according to this set of conventions: + * - [Right handed](https://en.wikipedia.org/wiki/Right_hand_rule) reference frames are adopted, and the [right hand rule](https://en.wikipedia.org/wiki/Right_hand_rule) is used to determine the sign of angles. + * - Each matrix is meant to represent an [active rotation](https://en.wikipedia.org/wiki/Active_and_passive_transformation) (the composing and composed matrices + * are supposed to act on the coordinates of vectors defined in the initial fixed reference frame and give as a result the coordinates of a rotated vector defined in the same reference frame). + * - For \f$\theta_1\f$ and \f$\theta_3\f$, the valid range is (−π, π]. + * + * For \f$\theta_2\f$, the valid range is [−π/2, π/2] or [0, π]. + * + * For Tait–Bryan angles, the valid range of \f$\theta_2\f$ is [−π/2, π/2]. When transforming a quaternion to Euler angles, the solution of Euler angles is unique in condition of \f$ \theta_2 \in (−π/2, π/2)\f$ . + * If \f$\theta_2 = −π/2 \f$ or \f$ \theta_2 = π/2\f$, there are infinite solutions. The common name for this situation is gimbal lock. + * For Proper Euler angles,the valid range of \f$\theta_2\f$ is in [0, π]. The solutions of Euler angles are unique in condition of \f$ \theta_2 \in (0, π)\f$ . If \f$\theta_2 =0 \f$ or \f$\theta_2 =π \f$, + * there are infinite solutions and gimbal lock will occur. + */ + enum EulerAnglesType + { + INT_XYZ, ///< Intrinsic rotations with the Euler angles type X-Y-Z + INT_XZY, ///< Intrinsic rotations with the Euler angles type X-Z-Y + INT_YXZ, ///< Intrinsic rotations with the Euler angles type Y-X-Z + INT_YZX, ///< Intrinsic rotations with the Euler angles type Y-Z-X + INT_ZXY, ///< Intrinsic rotations with the Euler angles type Z-X-Y + INT_ZYX, ///< Intrinsic rotations with the Euler angles type Z-Y-X + INT_XYX, ///< Intrinsic rotations with the Euler angles type X-Y-X + INT_XZX, ///< Intrinsic rotations with the Euler angles type X-Z-X + INT_YXY, ///< Intrinsic rotations with the Euler angles type Y-X-Y + INT_YZY, ///< Intrinsic rotations with the Euler angles type Y-Z-Y + INT_ZXZ, ///< Intrinsic rotations with the Euler angles type Z-X-Z + INT_ZYZ, ///< Intrinsic rotations with the Euler angles type Z-Y-Z + + EXT_XYZ, ///< Extrinsic rotations with the Euler angles type X-Y-Z + EXT_XZY, ///< Extrinsic rotations with the Euler angles type X-Z-Y + EXT_YXZ, ///< Extrinsic rotations with the Euler angles type Y-X-Z + EXT_YZX, ///< Extrinsic rotations with the Euler angles type Y-Z-X + EXT_ZXY, ///< Extrinsic rotations with the Euler angles type Z-X-Y + EXT_ZYX, ///< Extrinsic rotations with the Euler angles type Z-Y-X + EXT_XYX, ///< Extrinsic rotations with the Euler angles type X-Y-X + EXT_XZX, ///< Extrinsic rotations with the Euler angles type X-Z-X + EXT_YXY, ///< Extrinsic rotations with the Euler angles type Y-X-Y + EXT_YZY, ///< Extrinsic rotations with the Euler angles type Y-Z-Y + EXT_ZXZ, ///< Extrinsic rotations with the Euler angles type Z-X-Z + EXT_ZYZ, ///< Extrinsic rotations with the Euler angles type Z-Y-Z + #ifndef CV_DOXYGEN + EULER_ANGLES_MAX_VALUE + #endif + }; + +}; + +template class Quat; +template std::ostream& operator<<(std::ostream&, const Quat<_Tp>&); + +/** + * Quaternion is a number system that extends the complex numbers. It can be expressed as a + * rotation in three-dimensional space. + * A quaternion is generally represented in the form: + * \f[q = w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\f] + * \f[q = [w, x, y, z]\f] + * \f[q = [w, \boldsymbol{v}] \f] + * \f[q = ||q||[\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f] + * \f[q = ||q||[\cos\psi, \boldsymbol{u}\sin\psi]\f] + * where \f$\psi = \frac{\theta}{2}\f$, \f$\theta\f$ represents rotation angle, + * \f$\boldsymbol{u} = [u_x, u_y, u_z]\f$ represents normalized rotation axis, + * and \f$||q||\f$ represents the norm of \f$q\f$. + * + * A unit quaternion is usually represents rotation, which has the form: + * \f[q = [\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f] + * + * To create a quaternion representing the rotation around the axis \f$\boldsymbol{u}\f$ + * with angle \f$\theta\f$, you can use + * ``` + * using namespace cv; + * double angle = CV_PI; + * Vec3d axis = {0, 0, 1}; + * Quatd q = Quatd::createFromAngleAxis(angle, axis); + * ``` + * + * You can simply use four same type number to create a quaternion + * ``` + * Quatd q(1, 2, 3, 4); + * ``` + * Or use a Vec4d or Vec4f vector. + * ``` + * Vec4d vec{1, 2, 3, 4}; + * Quatd q(vec); + * ``` + * + * ``` + * Vec4f vec{1, 2, 3, 4}; + * Quatf q(vec); + * ``` + * + * If you already have a 3x3 rotation matrix R, then you can use + * ``` + * Quatd q = Quatd::createFromRotMat(R); + * ``` + * + * If you already have a rotation vector rvec which has the form of `angle * axis`, then you can use + * ``` + * Quatd q = Quatd::createFromRvec(rvec); + * ``` + * + * To extract the rotation matrix from quaternion, see toRotMat3x3() + * + * To extract the Vec4d or Vec4f, see toVec() + * + * To extract the rotation vector, see toRotVec() + * + * If there are two quaternions \f$q_0, q_1\f$ are needed to interpolate, you can use nlerp(), slerp() or spline() + * ``` + * Quatd::nlerp(q0, q1, t) + * + * Quatd::slerp(q0, q1, t) + * + * Quatd::spline(q0, q0, q1, q1, t) + * ``` + * spline can smoothly connect rotations of multiple quaternions + * + * Three ways to get an element in Quaternion + * ``` + * Quatf q(1,2,3,4); + * std::cout << q.w << std::endl; // w=1, x=2, y=3, z=4 + * std::cout << q[0] << std::endl; // q[0]=1, q[1]=2, q[2]=3, q[3]=4 + * std::cout << q.at(0) << std::endl; + * ``` + */ +template +class Quat +{ + static_assert(std::is_floating_point<_Tp>::value, "Quaternion only make sense with type of float or double"); + using value_type = _Tp; +public: + static constexpr _Tp CV_QUAT_EPS = (_Tp)1.e-6; + static constexpr _Tp CV_QUAT_CONVERT_THRESHOLD = (_Tp)1.e-6; + + Quat(); + + /** + * @brief From Vec4d or Vec4f. + */ + explicit Quat(const Vec<_Tp, 4> &coeff); + + /** + * @brief from four numbers. + */ + Quat(_Tp w, _Tp x, _Tp y, _Tp z); + + /** + * @brief from an angle, axis. Axis will be normalized in this function. And + * it generates + * \f[q = [\cos\psi, u_x\sin\psi,u_y\sin\psi, u_z\sin\psi].\f] + * where \f$\psi = \frac{\theta}{2}\f$, \f$\theta\f$ is the rotation angle. + */ + static Quat<_Tp> createFromAngleAxis(const _Tp angle, const Vec<_Tp, 3> &axis); + + /** + * @brief from a 3x3 rotation matrix. + */ + static Quat<_Tp> createFromRotMat(InputArray R); + + /** + * @brief from a rotation vector + * \f$r\f$ has the form \f$\theta \cdot \boldsymbol{u}\f$, where \f$\theta\f$ + * represents rotation angle and \f$\boldsymbol{u}\f$ represents normalized rotation axis. + * + * Angle and axis could be easily derived as: + * \f[ + * \begin{equation} + * \begin{split} + * \psi &= ||r||\\ + * \boldsymbol{u} &= \frac{r}{\theta} + * \end{split} + * \end{equation} + * \f] + * Then a quaternion can be calculated by + * \f[q = [\cos\psi, \boldsymbol{u}\sin\psi]\f] + * where \f$\psi = \theta / 2 \f$ + */ + static Quat<_Tp> createFromRvec(InputArray rvec); + + /** + * @brief + * from Euler angles + * + * A quaternion can be generated from Euler angles by combining the quaternion representations of the Euler rotations. + * + * For example, if we use intrinsic rotations in the order of X-Y-Z,\f$\theta_1 \f$ is rotation around the X-axis, \f$\theta_2 \f$ is rotation around the Y-axis, + * \f$\theta_3 \f$ is rotation around the Z-axis. The final quaternion q can be calculated by + * + * \f[ {q} = q_{X, \theta_1} q_{Y, \theta_2} q_{Z, \theta_3}\f] + * where \f$ q_{X, \theta_1} \f$ is created from @ref createFromXRot, \f$ q_{Y, \theta_2} \f$ is created from @ref createFromYRot, + * \f$ q_{Z, \theta_3} \f$ is created from @ref createFromZRot. + * @param angles the Euler angles in a vector of length 3 + * @param eulerAnglesType the convertion Euler angles type + */ + static Quat<_Tp> createFromEulerAngles(const Vec<_Tp, 3> &angles, QuatEnum::EulerAnglesType eulerAnglesType); + + /** + * @brief get a quaternion from a rotation about the Y-axis by \f$\theta\f$ . + * \f[q = \cos(\theta/2)+0 i+ sin(\theta/2) j +0k \f] + */ + static Quat<_Tp> createFromYRot(const _Tp theta); + + /** + * @brief get a quaternion from a rotation about the X-axis by \f$\theta\f$ . + * \f[q = \cos(\theta/2)+sin(\theta/2) i +0 j +0 k \f] + */ + static Quat<_Tp> createFromXRot(const _Tp theta); + + /** + * @brief get a quaternion from a rotation about the Z-axis by \f$\theta\f$. + * \f[q = \cos(\theta/2)+0 i +0 j +sin(\theta/2) k \f] + */ + static Quat<_Tp> createFromZRot(const _Tp theta); + + /** + * @brief a way to get element. + * @param index over a range [0, 3]. + * + * A quaternion q + * + * q.at(0) is equivalent to q.w, + * + * q.at(1) is equivalent to q.x, + * + * q.at(2) is equivalent to q.y, + * + * q.at(3) is equivalent to q.z. + */ + _Tp at(size_t index) const; + + /** + * @brief return the conjugate of this quaternion. + * \f[q.conjugate() = (w, -x, -y, -z).\f] + */ + Quat<_Tp> conjugate() const; + + /** + * + * @brief return the value of exponential value. + * \f[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||})\sin||\boldsymbol{v}||\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example: + * ``` + * Quatd q{1,2,3,4}; + * cout << exp(q) << endl; + * ``` + */ + template + friend Quat exp(const Quat &q); + + /** + * @brief return the value of exponential value. + * \f[\exp(q) = e^w (\cos||\boldsymbol{v}||+ \frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q{1,2,3,4}; + * cout << q.exp() << endl; + * ``` + */ + Quat<_Tp> exp() const; + + /** + * @brief return the value of logarithm function. + * \f[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}.\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q1{1,2,3,4}; + * cout << log(q1) << endl; + * ``` + */ + template + friend Quat log(const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return the value of logarithm function. + * \f[\ln(q) = \ln||q|| + \frac{\boldsymbol{v}}{||\boldsymbol{v}||}\arccos\frac{w}{||q||}\f]. + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.log(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * Quatd q1(1,2,3,4); + * q1.normalize().log(assumeUnit); + * ``` + */ + Quat<_Tp> log(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of power function with index \f$x\f$. + * \f[q^x = ||q||(cos(x\theta) + \boldsymbol{u}sin(x\theta))).\f] + * @param q a quaternion. + * @param x index of exponentiation. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * power(q, 2.0); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * double angle = CV_PI; + * Vec3d axis{0, 0, 1}; + * Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle + * power(q1, 2.0, assumeUnit);//This assumeUnit means q1 is a unit quaternion. + * ``` + * @note the type of the index should be the same as the quaternion. + */ + template + friend Quat power(const Quat &q, const T x, QuatAssumeType assumeUnit); + + /** + * @brief return the value of power function with index \f$x\f$. + * \f[q^x = ||q||(\cos(x\theta) + \boldsymbol{u}\sin(x\theta))).\f] + * @param x index of exponentiation. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.power(2.0); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * double angle = CV_PI; + * Vec3d axis{0, 0, 1}; + * Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle + * q1.power(2.0, assumeUnit); //This assumeUnt means q1 is a unit quaternion + * ``` + */ + Quat<_Tp> power(const _Tp x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return \f$\sqrt{q}\f$. + * @param q a quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatf q(1,2,3,4); + * sqrt(q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = {1,0,0,0}; + * sqrt(q, assumeUnit); //This assumeUnit means q is a unit quaternion. + * ``` + */ + template + friend Quat sqrt(const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return \f$\sqrt{q}\f$. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatf q(1,2,3,4); + * q.sqrt(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = {1,0,0,0}; + * q.sqrt(assumeUnit); //This assumeUnit means q is a unit quaternion + * ``` + */ + Quat<_Tp> sqrt(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the value of power function with quaternion \f$q\f$. + * \f[p^q = e^{q\ln(p)}.\f] + * @param p base quaternion of power function. + * @param q index quaternion of power function. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion \f$p\f$ assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd p(1,2,3,4); + * Quatd q(5,6,7,8); + * power(p, q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * p = p.normalize(); + * power(p, q, assumeUnit); //This assumeUnit means p is a unit quaternion + * ``` + */ + template + friend Quat power(const Quat &p, const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return the value of power function with quaternion \f$q\f$. + * \f[p^q = e^{q\ln(p)}.\f] + * @param q index quaternion of power function. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd p(1,2,3,4); + * Quatd q(5,6,7,8); + * p.power(q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * p = p.normalize(); + * p.power(q, assumeUnit); //This assumeUnit means p is a unit quaternion + * ``` + */ + Quat<_Tp> power(const Quat<_Tp> &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the crossProduct between \f$p = (a, b, c, d) = (a, \boldsymbol{u})\f$ and \f$q = (w, x, y, z) = (w, \boldsymbol{v})\f$. + * \f[p \times q = \frac{pq- qp}{2}\f] + * \f[p \times q = \boldsymbol{u} \times \boldsymbol{v}\f] + * \f[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k \f] + * + * For example + * ``` + * Quatd q{1,2,3,4}; + * Quatd p{5,6,7,8}; + * crossProduct(p, q); + * ``` + */ + template + friend Quat crossProduct(const Quat &p, const Quat &q); + + /** + * @brief return the crossProduct between \f$p = (a, b, c, d) = (a, \boldsymbol{u})\f$ and \f$q = (w, x, y, z) = (w, \boldsymbol{v})\f$. + * \f[p \times q = \frac{pq- qp}{2}.\f] + * \f[p \times q = \boldsymbol{u} \times \boldsymbol{v}.\f] + * \f[p \times q = (cz-dy)i + (dx-bz)j + (by-xc)k. \f] + * + * For example + * ``` + * Quatd q{1,2,3,4}; + * Quatd p{5,6,7,8}; + * p.crossProduct(q) + * ``` + */ + Quat<_Tp> crossProduct(const Quat<_Tp> &q) const; + + /** + * @brief return the norm of quaternion. + * \f[||q|| = \sqrt{w^2 + x^2 + y^2 + z^2}.\f] + */ + _Tp norm() const; + + /** + * @brief return a normalized \f$p\f$. + * \f[p = \frac{q}{||q||}\f] + * where \f$p\f$ satisfies \f$(p.x)^2 + (p.y)^2 + (p.z)^2 + (p.w)^2 = 1.\f$ + */ + Quat<_Tp> normalize() const; + + /** + * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$ + * which satisfies \f$q * q^{-1} = 1\f$. + * @param q a quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * inv(q); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = q.normalize(); + * inv(q, assumeUnit);//This assumeUnit means p is a unit quaternion + * ``` + */ + template + friend Quat inv(const Quat &q, QuatAssumeType assumeUnit); + + /** + * @brief return \f$q^{-1}\f$ which is an inverse of \f$q\f$ + * satisfying \f$q * q^{-1} = 1\f$. + * @param assumeUnit if QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.inv(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q = q.normalize(); + * q.inv(assumeUnit); //assumeUnit means p is a unit quaternion + * ``` + */ + Quat<_Tp> inv(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return sinh value of quaternion q, sinh could be calculated as: + * \f[\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * sinh(q); + * ``` + */ + template + friend Quat sinh(const Quat &q); + + /** + * @brief return sinh value of this quaternion, sinh could be calculated as: + * \f$\sinh(p) = \sin(w)\cos(||\boldsymbol{v}||) + \cosh(w)\frac{v}{||\boldsymbol{v}||}\sin||\boldsymbol{v}||\f$ + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.sinh(); + * ``` + */ + Quat<_Tp> sinh() const; + + /** + * @brief return cosh value of quaternion q, cosh could be calculated as: + * \f[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sin(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * cosh(q); + * ``` + */ + template + friend Quat cosh(const Quat &q); + + /** + * @brief return cosh value of this quaternion, cosh could be calculated as: + * \f[\cosh(p) = \cosh(w) * \cos(||\boldsymbol{v}||) + \sinh(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}sin(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.cosh(); + * ``` + */ + Quat<_Tp> cosh() const; + + /** + * @brief return tanh value of quaternion q, tanh could be calculated as: + * \f[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\f] + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * tanh(q); + * ``` + * @sa sinh, cosh + */ + template + friend Quat tanh(const Quat &q); + + /** + * @brief return tanh value of this quaternion, tanh could be calculated as: + * \f[ \tanh(q) = \frac{\sinh(q)}{\cosh(q)}.\f] + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.tanh(); + * ``` + * @sa sinh, cosh + */ + Quat<_Tp> tanh() const; + + /** + * @brief return tanh value of quaternion q, sin could be calculated as: + * \f[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * sin(q); + * ``` + */ + template + friend Quat sin(const Quat &q); + + /** + * @brief return sin value of this quaternion, sin could be calculated as: + * \f[\sin(p) = \sin(w) * \cosh(||\boldsymbol{v}||) + \cos(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.sin(); + * ``` + */ + Quat<_Tp> sin() const; + + /** + * @brief return sin value of quaternion q, cos could be calculated as: + * \f[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * cos(q); + * ``` + */ + template + friend Quat cos(const Quat &q); + + /** + * @brief return cos value of this quaternion, cos could be calculated as: + * \f[\cos(p) = \cos(w) * \cosh(||\boldsymbol{v}||) - \sin(w)\frac{\boldsymbol{v}}{||\boldsymbol{v}||}\sinh(||\boldsymbol{v}||)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.cos(); + * ``` + */ + Quat<_Tp> cos() const; + + /** + * @brief return tan value of quaternion q, tan could be calculated as: + * \f[\tan(q) = \frac{\sin(q)}{\cos(q)}.\f] + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * tan(q); + * ``` + */ + template + friend Quat tan(const Quat &q); + + /** + * @brief return tan value of this quaternion, tan could be calculated as: + * \f[\tan(q) = \frac{\sin(q)}{\cos(q)}.\f] + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.tan(); + * ``` + */ + Quat<_Tp> tan() const; + + /** + * @brief return arcsin value of quaternion q, arcsin could be calculated as: + * \f[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * asin(q); + * ``` + */ + template + friend Quat asin(const Quat &q); + + /** + * @brief return arcsin value of this quaternion, arcsin could be calculated as: + * \f[\arcsin(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arcsinh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.asin(); + * ``` + */ + Quat<_Tp> asin() const; + + /** + * @brief return arccos value of quaternion q, arccos could be calculated as: + * \f[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * acos(q); + * ``` + */ + template + friend Quat acos(const Quat &q); + + /** + * @brief return arccos value of this quaternion, arccos could be calculated as: + * \f[\arccos(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arccosh(q)\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.acos(); + * ``` + */ + Quat<_Tp> acos() const; + + /** + * @brief return arctan value of quaternion q, arctan could be calculated as: + * \f[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * atan(q); + * ``` + */ + template + friend Quat atan(const Quat &q); + + /** + * @brief return arctan value of this quaternion, arctan could be calculated as: + * \f[\arctan(q) = -\frac{\boldsymbol{v}}{||\boldsymbol{v}||}arctanh(q\frac{\boldsymbol{v}}{||\boldsymbol{v}||})\f] + * where \f$\boldsymbol{v} = [x, y, z].\f$ + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.atan(); + * ``` + */ + Quat<_Tp> atan() const; + + /** + * @brief return arcsinh value of quaternion q, arcsinh could be calculated as: + * \f[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\f]. + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * asinh(q); + * ``` + */ + template + friend Quat asinh(const Quat &q); + + /** + * @brief return arcsinh value of this quaternion, arcsinh could be calculated as: + * \f[arcsinh(q) = \ln(q + \sqrt{q^2 + 1})\f]. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.asinh(); + * ``` + */ + Quat<_Tp> asinh() const; + + /** + * @brief return arccosh value of quaternion q, arccosh could be calculated as: + * \f[arccosh(q) = \ln(q + \sqrt{q^2 - 1})\f]. + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * acosh(q); + * ``` + */ + template + friend Quat acosh(const Quat &q); + + /** + * @brief return arccosh value of this quaternion, arccosh could be calculated as: + * \f[arcosh(q) = \ln(q + \sqrt{q^2 - 1})\f]. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.acosh(); + * ``` + */ + Quat<_Tp> acosh() const; + + /** + * @brief return arctanh value of quaternion q, arctanh could be calculated as: + * \f[arctanh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\f]. + * @param q a quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * atanh(q); + * ``` + */ + template + friend Quat atanh(const Quat &q); + + /** + * @brief return arctanh value of this quaternion, arctanh could be calculated as: + * \f[arcsinh(q) = \frac{\ln(q + 1) - \ln(1 - q)}{2}\f]. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.atanh(); + * ``` + */ + Quat<_Tp> atanh() const; + + /** + * @brief return true if this quaternion is a unit quaternion. + * @param eps tolerance scope of normalization. The eps could be defined as + * + * \f[eps = |1 - dotValue|\f] where \f[dotValue = (this.w^2 + this.x^2 + this,y^2 + this.z^2).\f] + * And this function will consider it is normalized when the dotValue over a range \f$[1-eps, 1+eps]\f$. + */ + bool isNormal(_Tp eps=CV_QUAT_EPS) const; + + /** + * @brief to throw an error if this quaternion is not a unit quaternion. + * @param eps tolerance scope of normalization. + * @sa isNormal + */ + void assertNormal(_Tp eps=CV_QUAT_EPS) const; + + /** + * @brief transform a quaternion to a 3x3 rotation matrix. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. Otherwise, this function will normalize this + * quaternion at first then do the transformation. + * + * @note Matrix A which is to be rotated should have the form + * \f[\begin{bmatrix} + * x_0& x_1& x_2&...&x_n\\ + * y_0& y_1& y_2&...&y_n\\ + * z_0& z_1& z_2&...&z_n + * \end{bmatrix}\f] + * where the same subscript represents a point. The shape of A assume to be [3, n] + * The points matrix A can be rotated by toRotMat3x3() * A. + * The result has 3 rows and n columns too. + + * For example + * ``` + * double angle = CV_PI; + * Vec3d axis{0,0,1}; + * Quatd q_unit = Quatd::createFromAngleAxis(angle, axis); //quaternion could also be get by interpolation by two or more quaternions. + * + * //assume there is two points (1,0,0) and (1,0,1) to be rotated + * Mat pointsA = (Mat_(2, 3) << 1,0,0,1,0,1); + * //change the shape + * pointsA = pointsA.t(); + * // rotate 180 degrees around the z axis + * Mat new_point = q_unit.toRotMat3x3() * pointsA; + * // print two points + * cout << new_point << endl; + * ``` + */ + Matx<_Tp, 3, 3> toRotMat3x3(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief transform a quaternion to a 4x4 rotation matrix. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. Otherwise, this function will normalize this + * quaternion at first then do the transformation. + * + * The operations is similar as toRotMat3x3 + * except that the points matrix should have the form + * \f[\begin{bmatrix} + * x_0& x_1& x_2&...&x_n\\ + * y_0& y_1& y_2&...&y_n\\ + * z_0& z_1& z_2&...&z_n\\ + * 0&0&0&...&0 + * \end{bmatrix}\f] + * + * @sa toRotMat3x3 + */ + + Matx<_Tp, 4, 4> toRotMat4x4(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief transform the this quaternion to a Vec. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.toVec(); + * ``` + */ + Vec<_Tp, 4> toVec() const; + + /** + * @brief transform this quaternion to a Rotation vector. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. + * Rotation vector rVec is defined as: + * \f[ rVec = [\theta v_x, \theta v_y, \theta v_z]\f] + * where \f$\theta\f$ represents rotation angle, and \f$\boldsymbol{v}\f$ represents the normalized rotation axis. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.toRotVec(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q.normalize().toRotVec(assumeUnit); //answer is same as q.toRotVec(). + * ``` + */ + Vec<_Tp, 3> toRotVec(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief get the angle of quaternion, it returns the rotation angle. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. + * \f[\psi = 2 *arccos(\frac{w}{||q||})\f] + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.getAngle(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q.normalize().getAngle(assumeUnit);//same as q.getAngle(). + * ``` + * @note It always return the value between \f$[0, 2\pi]\f$. + */ + _Tp getAngle(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief get the axis of quaternion, it returns a vector of length 3. + * @param assumeUnit if QUAT_ASSUME_UNIT, this quaternion assume to be a unit quaternion and + * this function will save some computations. + * + * the unit axis \f$\boldsymbol{u}\f$ is defined by + * \f[\begin{equation} + * \begin{split} + * \boldsymbol{v} + * &= \boldsymbol{u} ||\boldsymbol{v}||\\ + * &= \boldsymbol{u}||q||sin(\frac{\theta}{2}) + * \end{split} + * \end{equation}\f] + * where \f$v=[x, y ,z]\f$ and \f$\theta\f$ represents rotation angle. + * + * + * For example + * ``` + * Quatd q(1,2,3,4); + * q.getAxis(); + * + * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; + * q.normalize().getAxis(assumeUnit);//same as q.getAxis() + * ``` + */ + Vec<_Tp, 3> getAxis(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const; + + /** + * @brief return the dot between quaternion \f$q\f$ and this quaternion. + * + * dot(p, q) is a good metric of how close the quaternions are. + * Indeed, consider the unit quaternion difference \f$p^{-1} * q\f$, its real part is dot(p, q). + * At the same time its real part is equal to \f$\cos(\beta/2)\f$ where \f$\beta\f$ is + * an angle of rotation between p and q, i.e., + * Therefore, the closer dot(p, q) to 1, + * the smaller rotation between them. + * \f[p \cdot q = p.w \cdot q.w + p.x \cdot q.x + p.y \cdot q.y + p.z \cdot q.z\f] + * @param q the other quaternion. + * + * For example + * ``` + * Quatd q(1,2,3,4); + * Quatd p(5,6,7,8); + * p.dot(q); + * ``` + */ + _Tp dot(Quat<_Tp> q) const; + + /** + * @brief To calculate the interpolation from \f$q_0\f$ to \f$q_1\f$ by Linear Interpolation(Nlerp) + * For two quaternions, this interpolation curve can be displayed as: + * \f[Lerp(q_0, q_1, t) = (1 - t)q_0 + tq_1.\f] + * Obviously, the lerp will interpolate along a straight line if we think of \f$q_0\f$ and \f$q_1\f$ as a vector + * in a two-dimensional space. When \f$t = 0\f$, it returns \f$q_0\f$ and when \f$t= 1\f$, it returns \f$q_1\f$. + * \f$t\f$ should to be ranged in \f$[0, 1]\f$ normally. + * @param q0 a quaternion used in linear interpolation. + * @param q1 a quaternion used in linear interpolation. + * @param t percent of vector \f$\overrightarrow{q_0q_1}\f$ over a range [0, 1]. + * @note it returns a non-unit quaternion. + */ + static Quat<_Tp> lerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t); + + /** + * @brief To calculate the interpolation from \f$q_0\f$ to \f$q_1\f$ by Normalized Linear Interpolation(Nlerp). + * it returns a normalized quaternion of Linear Interpolation(Lerp). + * \f[ Nlerp(q_0, q_1, t) = \frac{(1 - t)q_0 + tq_1}{||(1 - t)q_0 + tq_1||}.\f] + * The interpolation will always choose the shortest path but the constant speed is not guaranteed. + * @param q0 a quaternion used in normalized linear interpolation. + * @param q1 a quaternion used in normalized linear interpolation. + * @param t percent of vector \f$\overrightarrow{q_0q_1}\f$ over a range [0, 1]. + * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all inputs + quaternion will be normalized inside the function. + * @sa lerp + */ + static Quat<_Tp> nlerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + @brief To calculate the interpolation between \f$q_0\f$ and \f$q_1\f$ by Spherical Linear + Interpolation(Slerp), which can be defined as: + \f[ Slerp(q_0, q_1, t) = \frac{\sin((1-t)\theta)}{\sin(\theta)}q_0 + \frac{\sin(t\theta)}{\sin(\theta)}q_1\f] + where \f$\theta\f$ can be calculated as: + \f[\theta=cos^{-1}(q_0\cdot q_1)\f] + resulting from the both of their norm is unit. + @param q0 a quaternion used in Slerp. + @param q1 a quaternion used in Slerp. + @param t percent of angle between \f$q_0\f$ and \f$q_1\f$ over a range [0, 1]. + @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternions. Otherwise, all input + quaternions will be normalized inside the function. + @param directChange if QUAT_ASSUME_UNIT, the interpolation will choose the nearest path. + @note If the interpolation angle is small, the error between Nlerp and Slerp is not so large. To improve efficiency and + avoid zero division error, we use Nlerp instead of Slerp. + */ + static Quat<_Tp> slerp(const Quat<_Tp> &q0, const Quat &q1, const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT, bool directChange=true); + + /** + * @brief To calculate the interpolation between \f$q_0\f$,\f$q_1\f$,\f$q_2\f$,\f$q_3\f$ by Spherical and quadrangle(Squad). This could be defined as: + * \f[Squad(q_i, s_i, s_{i+1}, q_{i+1}, t) = Slerp(Slerp(q_i, q_{i+1}, t), Slerp(s_i, s_{i+1}, t), 2t(1-t))\f] + * where + * \f[s_i = q_i\exp(-\frac{\log(q^*_iq_{i+1}) + \log(q^*_iq_{i-1})}{4})\f] + * + * The Squad expression is analogous to the \f$B\acute{e}zier\f$ curve, but involves spherical linear + * interpolation instead of simple linear interpolation. Each \f$s_i\f$ needs to be calculated by three + * quaternions. + * + * @param q0 the first quaternion. + * @param s0 the second quaternion. + * @param s1 the third quaternion. + * @param q1 thr fourth quaternion. + * @param t interpolation parameter of quadratic and linear interpolation over a range \f$[0, 1]\f$. + * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all input + * quaternions will be normalized inside the function. + * @param directChange if QUAT_ASSUME_UNIT, squad will find the nearest path to interpolate. + * @sa interPoint, spline + */ + static Quat<_Tp> squad(const Quat<_Tp> &q0, const Quat<_Tp> &s0, + const Quat<_Tp> &s1, const Quat<_Tp> &q1, + const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT, + bool directChange=true); + + /** + * @brief This is the part calculation of squad. + * To calculate the intermedia quaternion \f$s_i\f$ between each three quaternion + * \f[s_i = q_i\exp(-\frac{\log(q^*_iq_{i+1}) + \log(q^*_iq_{i-1})}{4}).\f] + * @param q0 the first quaternion. + * @param q1 the second quaternion. + * @param q2 the third quaternion. + * @param assumeUnit if QUAT_ASSUME_UNIT, all input quaternions assume to be unit quaternion. Otherwise, all input + * quaternions will be normalized inside the function. + * @sa squad + */ + static Quat<_Tp> interPoint(const Quat<_Tp> &q0, const Quat<_Tp> &q1, + const Quat<_Tp> &q2, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief to calculate a quaternion which is the result of a \f$C^1\f$ continuous + * spline curve constructed by squad at the ratio t. Here, the interpolation values are + * between \f$q_1\f$ and \f$q_2\f$. \f$q_0\f$ and \f$q_2\f$ are used to ensure the \f$C^1\f$ + * continuity. if t = 0, it returns \f$q_1\f$, if t = 1, it returns \f$q_2\f$. + * @param q0 the first input quaternion to ensure \f$C^1\f$ continuity. + * @param q1 the second input quaternion. + * @param q2 the third input quaternion. + * @param q3 the fourth input quaternion the same use of \f$q1\f$. + * @param t ratio over a range [0, 1]. + * @param assumeUnit if QUAT_ASSUME_UNIT, \f$q_0, q_1, q_2, q_3\f$ assume to be unit quaternion. Otherwise, all input + * quaternions will be normalized inside the function. + * + * For example: + * + * If there are three double quaternions \f$v_0, v_1, v_2\f$ waiting to be interpolated. + * + * Interpolation between \f$v_0\f$ and \f$v_1\f$ with a ratio \f$t_0\f$ could be calculated as + * ``` + * Quatd::spline(v0, v0, v1, v2, t0); + * ``` + * Interpolation between \f$v_1\f$ and \f$v_2\f$ with a ratio \f$t_0\f$ could be calculated as + * ``` + * Quatd::spline(v0, v1, v2, v2, t0); + * ``` + * @sa squad, slerp + */ + static Quat<_Tp> spline(const Quat<_Tp> &q0, const Quat<_Tp> &q1, + const Quat<_Tp> &q2, const Quat<_Tp> &q3, + const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + + /** + * @brief Return opposite quaternion \f$-p\f$ + * which satisfies \f$p + (-p) = 0.\f$ + * + * For example + * ``` + * Quatd q{1, 2, 3, 4}; + * std::cout << -q << std::endl; // [-1, -2, -3, -4] + * ``` + */ + Quat<_Tp> operator-() const; + + /** + * @brief return true if two quaternions p and q are nearly equal, i.e. when the absolute + * value of each \f$p_i\f$ and \f$q_i\f$ is less than CV_QUAT_EPS. + */ + bool operator==(const Quat<_Tp>&) const; + + /** + * @brief Addition operator of two quaternions p and q. + * It returns a new quaternion that each value is the sum of \f$p_i\f$ and \f$q_i\f$. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p + q << std::endl; //[6, 8, 10, 12] + * ``` + */ + Quat<_Tp> operator+(const Quat<_Tp>&) const; + + /** + * @brief Addition assignment operator of two quaternions p and q. + * It adds right operand to the left operand and assign the result to left operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p += q; // equivalent to p = p + q + * std::cout << p << std::endl; //[6, 8, 10, 12] + * + * ``` + */ + Quat<_Tp>& operator+=(const Quat<_Tp>&); + + /** + * @brief Subtraction operator of two quaternions p and q. + * It returns a new quaternion that each value is the sum of \f$p_i\f$ and \f$-q_i\f$. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p - q << std::endl; //[-4, -4, -4, -4] + * ``` + */ + Quat<_Tp> operator-(const Quat<_Tp>&) const; + + /** + * @brief Subtraction assignment operator of two quaternions p and q. + * It subtracts right operand from the left operand and assign the result to left operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p -= q; // equivalent to p = p - q + * std::cout << p << std::endl; //[-4, -4, -4, -4] + * + * ``` + */ + Quat<_Tp>& operator-=(const Quat<_Tp>&); + + /** + * @brief Multiplication assignment operator of two quaternions q and p. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication: + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [p_0, \boldsymbol{u}]*[q_0, \boldsymbol{v}]\\ + * &=[p_0q_0 - \boldsymbol{u}\cdot \boldsymbol{v}, p_0\boldsymbol{v} + q_0\boldsymbol{u}+ \boldsymbol{u}\times \boldsymbol{v}]. + * \end{split} + * \end{equation} + * \f] + * where \f$\cdot\f$ means dot product and \f$\times \f$ means cross product. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p *= q; // equivalent to p = p * q + * std::cout << p << std::endl; //[-60, 12, 30, 24] + * ``` + */ + Quat<_Tp>& operator*=(const Quat<_Tp>&); + + /** + * @brief Multiplication assignment operator of a quaternions and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z] * s\\ + * &=[w * s, x * s, y * s, z * s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * p *= s; // equivalent to p = p * s + * std::cout << p << std::endl; //[2.0, 4.0, 6.0, 8.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + Quat<_Tp>& operator*=(const _Tp s); + + /** + * @brief Multiplication operator of two quaternions q and p. + * Multiplies values on either side of the operator. + * + * Rule of quaternion multiplication: + * \f[ + * \begin{equation} + * \begin{split} + * p * q &= [p_0, \boldsymbol{u}]*[q_0, \boldsymbol{v}]\\ + * &=[p_0q_0 - \boldsymbol{u}\cdot \boldsymbol{v}, p_0\boldsymbol{v} + q_0\boldsymbol{u}+ \boldsymbol{u}\times \boldsymbol{v}]. + * \end{split} + * \end{equation} + * \f] + * where \f$\cdot\f$ means dot product and \f$\times \f$ means cross product. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p * q << std::endl; //[-60, 12, 30, 24] + * ``` + */ + Quat<_Tp> operator*(const Quat<_Tp>&) const; + + /** + * @brief Division operator of a quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z] / s\\ + * &=[w/s, x/s, y/s, z/s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1, 1.5, 2] + * ``` + * @note the type of scalar should be equal to this quaternion. + */ + Quat<_Tp> operator/(const _Tp s) const; + + /** + * @brief Division operator of two quaternions p and q. + * Divides left hand operand by right hand operand. + * + * Rule of quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / q &= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * std::cout << p / q << std::endl; // equivalent to p * q.inv() + * ``` + */ + Quat<_Tp> operator/(const Quat<_Tp>&) const; + + /** + * @brief Division assignment operator of a quaternions and a scalar. + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of quaternion division with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p / s &= [w, x, y, z] / s\\ + * &=[w / s, x / s, y / s, z / s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0;; + * p /= s; // equivalent to p = p / s + * std::cout << p << std::endl; //[0.5, 1.0, 1.5, 2.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + Quat<_Tp>& operator/=(const _Tp s); + + /** + * @brief Division assignment operator of two quaternions p and q; + * It divides left operand with the right operand and assign the result to left operand. + * + * Rule of quaternion division with a quaternion: + * \f[ + * \begin{equation} + * \begin{split} + * p / q&= p * q.inv()\\ + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * Quatd q{5, 6, 7, 8}; + * p /= q; // equivalent to p = p * q.inv() + * std::cout << p << std::endl; + * ``` + */ + Quat<_Tp>& operator/=(const Quat<_Tp>&); + + _Tp& operator[](std::size_t n); + + const _Tp& operator[](std::size_t n) const; + + /** + * @brief Subtraction operator of a scalar and a quaternions. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << scalar - p << std::endl; //[1.0, -2, -3, -4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator-(const T s, const Quat&); + + /** + * @brief Subtraction operator of a quaternions and a scalar. + * Subtracts right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << p - scalar << std::endl; //[-1.0, 2, 3, 4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator-(const Quat&, const T s); + + /** + * @brief Addition operator of a quaternions and a scalar. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << scalar + p << std::endl; //[3.0, 2, 3, 4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator+(const T s, const Quat&); + + /** + * @brief Addition operator of a quaternions and a scalar. + * Adds right hand operand from left hand operand. + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double scalar = 2.0; + * std::cout << p + scalar << std::endl; //[3.0, 2, 3, 4] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator+(const Quat&, const T s); + + /** + * @brief Multiplication operator of a scalar and a quaternions. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z] * s\\ + * &=[w * s, x * s, y * s, z * s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * std::cout << s * p << std::endl; //[2.0, 4.0, 6.0, 8.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator*(const T s, const Quat&); + + /** + * @brief Multiplication operator of a quaternion and a scalar. + * It multiplies right operand with the left operand and assign the result to left operand. + * + * Rule of quaternion multiplication with a scalar: + * \f[ + * \begin{equation} + * \begin{split} + * p * s &= [w, x, y, z] * s\\ + * &=[w * s, x * s, y * s, z * s]. + * \end{split} + * \end{equation} + * \f] + * + * For example + * ``` + * Quatd p{1, 2, 3, 4}; + * double s = 2.0; + * std::cout << p * s << std::endl; //[2.0, 4.0, 6.0, 8.0] + * ``` + * @note the type of scalar should be equal to the quaternion. + */ + template + friend Quat cv::operator*(const Quat&, const T s); + + template + friend std::ostream& cv::operator<<(std::ostream&, const Quat&); + + /** + * @brief Transform a quaternion q to Euler angles. + * + * + * When transforming a quaternion \f$q = w + x\boldsymbol{i} + y\boldsymbol{j} + z\boldsymbol{k}\f$ to Euler angles, rotation matrix M can be calculated by: + * \f[ \begin{aligned} {M} &={\begin{bmatrix}1-2(y^{2}+z^{2})&2(xy-zx)&2(xz+yw)\\2(xy+zw)&1-2(x^{2}+z^{2})&2(yz-xw)\\2(xz-yw)&2(yz+xw)&1-2(x^{2}+y^{2})\end{bmatrix}}\end{aligned}.\f] + * On the other hand, the rotation matrix can be obtained from Euler angles. + * Using intrinsic rotations with Euler angles type XYZ as an example, + * \f$\theta_1 \f$, \f$\theta_2 \f$, \f$\theta_3 \f$ are three angles for Euler angles, the rotation matrix R can be calculated by:\f[R =X(\theta_1)Y(\theta_2)Z(\theta_3) + * ={\begin{bmatrix}\cos\theta_{2}\cos\theta_{3}&-\cos\theta_{2}\sin\theta_{3}&\sin\theta_{2}\\\cos\theta_{1}\sin\theta_{3}+\cos\theta_{3}\sin\theta_{1}\sin\theta_{2}&\cos\theta_{1}\cos\theta_{3}-\sin\theta_{1}\sin\theta_{2}\sin\theta_{3}&-\cos\theta_{2}\sin\theta_{1}\\\sin\theta_{1}\sin\theta_{3}-\cos\theta_{1}\cos\theta_{3}\sin\theta_{2}&\cos\theta_{3}\sin\theta_{1}+\cos\theta_{1}\sin\theta_{2}\sin\theta_{3}&\cos\theta_{1}\cos_{2}\end{bmatrix}}\f] + * Rotation matrix M and R are equal. As long as \f$ s_{2} \neq 1 \f$, by comparing each element of two matrices ,the solution is\f$\begin{cases} \theta_1 = \arctan2(-m_{23},m_{33})\\\theta_2 = arcsin(m_{13}) \\\theta_3 = \arctan2(-m_{12},m_{11}) \end{cases}\f$. + * + * When \f$ s_{2}=1\f$ or \f$ s_{2}=-1\f$, the gimbal lock occurs. The function will prompt "WARNING: Gimbal Lock will occur. Euler angles is non-unique. For intrinsic rotations, we set the third angle to 0, and for external rotation, we set the first angle to 0.". + * + * When \f$ s_{2}=1\f$ , + * The rotation matrix R is \f$R = {\begin{bmatrix}0&0&1\\\sin(\theta_1+\theta_3)&\cos(\theta_1+\theta_3)&0\\-\cos(\theta_1+\theta_3)&\sin(\theta_1+\theta_3)&0\end{bmatrix}}\f$. + * + * The number of solutions is infinite with the condition \f$\begin{cases} \theta_1+\theta_3 = \arctan2(m_{21},m_{22})\\ \theta_2=\pi/2 \end{cases}\ \f$. + * + * We set \f$ \theta_3 = 0\f$, the solution is \f$\begin{cases} \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \end{cases}\f$. + * + * When \f$ s_{2}=-1\f$, + * The rotation matrix R is \f$X_{1}Y_{2}Z_{3}={\begin{bmatrix}0&0&-1\\-\sin(\theta_1-\theta_3)&\cos(\theta_1-\theta_3)&0\\\cos(\theta_1-\theta_3)&\sin(\theta_1-\theta_3)&0\end{bmatrix}}\f$. + * + * The number of solutions is infinite with the condition \f$\begin{cases} \theta_1+\theta_3 = \arctan2(m_{32},m_{22})\\ \theta_2=\pi/2 \end{cases}\ \f$. + * + * We set \f$ \theta_3 = 0\f$, the solution is \f$ \begin{cases}\theta_1=\arctan2(m_{32},m_{22}) \\ \theta_2=-\pi/2\\ \theta_3=0\end{cases}\f$. + * + * Since \f$ sin \theta\in [-1,1] \f$ and \f$ cos \theta \in [-1,1] \f$, the unnormalized quaternion will cause computational troubles. For this reason, this function will normalize the quaternion at first and @ref QuatAssumeType is not needed. + * + * When the gimbal lock occurs, we set \f$\theta_3 = 0\f$ for intrinsic rotations or \f$\theta_1 = 0\f$ for extrinsic rotations. + * + * As a result, for every Euler angles type, we can get solution as shown in the following table. + * EulerAnglesType | Ordinary | \f$\theta_2 = π/2\f$ | \f$\theta_2 = -π/2\f$ + * ------------- | -------------| -------------| ------------- + * INT_XYZ|\f$ \theta_1 = \arctan2(-m_{23},m_{33})\\\theta_2 = \arcsin(m_{13}) \\\theta_3= \arctan2(-m_{12},m_{11}) \f$|\f$ \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{32},m_{22})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_XZY|\f$ \theta_1 = \arctan2(m_{32},m_{22})\\\theta_2 = -\arcsin(m_{12}) \\\theta_3= \arctan2(m_{13},m_{11}) \f$|\f$ \theta_1=\arctan2(m_{31},m_{33})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{23},m_{33})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_YXZ|\f$ \theta_1 = \arctan2(m_{13},m_{33})\\\theta_2 = -\arcsin(m_{23}) \\\theta_3= \arctan2(m_{21},m_{22}) \f$|\f$ \theta_1=\arctan2(m_{12},m_{11})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{12},m_{11})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_YZX|\f$ \theta_1 = \arctan2(-m_{31},m_{11})\\\theta_2 = \arcsin(m_{21}) \\\theta_3= \arctan2(-m_{23},m_{22}) \f$|\f$ \theta_1=\arctan2(m_{13},m_{33})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{13},m_{12})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_ZXY|\f$ \theta_1 = \arctan2(-m_{12},m_{22})\\\theta_2 = \arcsin(m_{32}) \\\theta_3= \arctan2(-m_{31},m_{33}) \f$|\f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * INT_ZYX|\f$ \theta_1 = \arctan2(m_{21},m_{11})\\\theta_2 = \arcsin(-m_{31}) \\\theta_3= \arctan2(m_{32},m_{33}) \f$|\f$ \theta_1=\arctan2(m_{23},m_{22})\\ \theta_2=\pi/2\\ \theta_3=0 \f$|\f$ \theta_1=\arctan2(-m_{12},m_{22})\\ \theta_2=-\pi/2\\ \theta_3=0 \f$ + * EXT_XYZ|\f$ \theta_1 = \arctan2(m_{32},m_{33})\\\theta_2 = \arcsin(-m_{31}) \\\ \theta_3 = \arctan2(m_{21},m_{11})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{23},m_{22}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{12},m_{22}) \f$ + * EXT_XZY|\f$ \theta_1 = \arctan2(-m_{23},m_{22})\\\theta_2 = \arcsin(m_{21}) \\\theta_3= \arctan2(-m_{31},m_{11})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{13},m_{33}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{13},m_{12}) \f$ + * EXT_YXZ|\f$ \theta_1 = \arctan2(-m_{31},m_{33}) \\\theta_2 = \arcsin(m_{32}) \\\theta_3= \arctan2(-m_{12},m_{22})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{21},m_{11}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{21},m_{11}) \f$ + * EXT_YZX|\f$ \theta_1 = \arctan2(m_{13},m_{11})\\\theta_2 = -\arcsin(m_{12}) \\\theta_3= \arctan2(m_{32},m_{22})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{31},m_{33}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{23},m_{33}) \f$ + * EXT_ZXY|\f$ \theta_1 = \arctan2(m_{21},m_{22})\\\theta_2 = -\arcsin(m_{23}) \\\theta_3= \arctan2(m_{13},m_{33})\f$|\f$ \theta_1= 0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{12},m_{11}) \f$|\f$ \theta_1= 0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(-m_{12},m_{11}) \f$ + * EXT_ZYX|\f$ \theta_1 = \arctan2(-m_{12},m_{11})\\\theta_2 = \arcsin(m_{13}) \\\theta_3= \arctan2(-m_{23},m_{33})\f$|\f$ \theta_1=0\\ \theta_2=\pi/2\\ \theta_3=\arctan2(m_{21},m_{22}) \f$|\f$ \theta_1=0\\ \theta_2=-\pi/2\\ \theta_3=\arctan2(m_{32},m_{22}) \f$ + * + * EulerAnglesType | Ordinary | \f$\theta_2 = 0\f$ | \f$\theta_2 = π\f$ + * ------------- | -------------| -------------| ------------- + * INT_XYX| \f$ \theta_1 = \arctan2(m_{21},-m_{31})\\\theta_2 =\arccos(m_{11}) \\\theta_3 = \arctan2(m_{12},m_{13}) \f$| \f$ \theta_1=\arctan2(m_{32},m_{33})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{23},m_{22})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_XZX| \f$ \theta_1 = \arctan2(m_{31},m_{21})\\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{13},-m_{12}) \f$| \f$ \theta_1=\arctan2(m_{32},m_{33})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(-m_{32},m_{33})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_YXY| \f$ \theta_1 = \arctan2(m_{12},m_{32})\\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{21},-m_{23}) \f$| \f$ \theta_1=\arctan2(m_{13},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(-m_{31},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_YZY| \f$ \theta_1 = \arctan2(m_{32},-m_{12})\\\theta_2 = \arccos(m_{22}) \\\theta_3 =\arctan2(m_{23},m_{21}) \f$| \f$ \theta_1=\arctan2(m_{13},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{13},-m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_ZXZ| \f$ \theta_1 = \arctan2(-m_{13},m_{23})\\\theta_2 = \arccos(m_{33}) \\\theta_3 =\arctan2(m_{31},m_{32}) \f$| \f$ \theta_1=\arctan2(m_{21},m_{22})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * INT_ZYZ| \f$ \theta_1 = \arctan2(m_{23},m_{13})\\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(m_{32},-m_{31}) \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=0\\ \theta_3=0 \f$| \f$ \theta_1=\arctan2(m_{21},m_{11})\\ \theta_2=\pi\\ \theta_3=0 \f$ + * EXT_XYX| \f$ \theta_1 = \arctan2(m_{12},m_{13}) \\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{21},-m_{31})\f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{32},m_{33}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3= \arctan2(m_{23},m_{22}) \f$ + * EXT_XZX| \f$ \theta_1 = \arctan2(m_{13},-m_{12})\\\theta_2 = \arccos(m_{11}) \\\theta_3 = \arctan2(m_{31},m_{21})\f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{32},m_{33}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(-m_{32},m_{33}) \f$ + * EXT_YXY| \f$ \theta_1 = \arctan2(m_{21},-m_{23})\\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{12},m_{32}) \f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{13},m_{11}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(-m_{31},m_{11}) \f$ + * EXT_YZY| \f$ \theta_1 = \arctan2(m_{23},m_{21}) \\\theta_2 = \arccos(m_{22}) \\\theta_3 = \arctan2(m_{32},-m_{12}) \f$| \f$ \theta_1= 0\\ \theta_2=0\\ \theta_3=\arctan2(m_{13},m_{11}) \f$| \f$ \theta_1=0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{13},-m_{11}) \f$ + * EXT_ZXZ| \f$ \theta_1 = \arctan2(m_{31},m_{32}) \\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(-m_{13},m_{23})\f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{21},m_{22}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{21},m_{11}) \f$ + * EXT_ZYZ| \f$ \theta_1 = \arctan2(m_{32},-m_{31})\\\theta_2 = \arccos(m_{33}) \\\theta_3 = \arctan2(m_{23},m_{13}) \f$| \f$ \theta_1=0\\ \theta_2=0\\ \theta_3=\arctan2(m_{21},m_{11}) \f$| \f$ \theta_1= 0\\ \theta_2=\pi\\ \theta_3=\arctan2(m_{21},m_{11}) \f$ + * + * @param eulerAnglesType the convertion Euler angles type + */ + + Vec<_Tp, 3> toEulerAngles(QuatEnum::EulerAnglesType eulerAnglesType); + + _Tp w, x, y, z; + +}; + +template +Quat inv(const Quat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat sinh(const Quat &q); + +template +Quat cosh(const Quat &q); + +template +Quat tanh(const Quat &q); + +template +Quat sin(const Quat &q); + +template +Quat cos(const Quat &q); + +template +Quat tan(const Quat &q); + +template +Quat asinh(const Quat &q); + +template +Quat acosh(const Quat &q); + +template +Quat atanh(const Quat &q); + +template +Quat asin(const Quat &q); + +template +Quat acos(const Quat &q); + +template +Quat atan(const Quat &q); + +template +Quat power(const Quat &q, const Quat &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat exp(const Quat &q); + +template +Quat log(const Quat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat power(const Quat& q, const T x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat crossProduct(const Quat &p, const Quat &q); + +template +Quat sqrt(const Quat &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT); + +template +Quat operator*(const T, const Quat&); + +template +Quat operator*(const Quat&, const T); + +template +std::ostream& operator<<(std::ostream&, const Quat&); + +using Quatd = Quat; +using Quatf = Quat; + +//! @} core +} + +#include "opencv2/core/quaternion.inl.hpp" + +#endif /* OPENCV_CORE_QUATERNION_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/quaternion.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/quaternion.inl.hpp new file mode 100644 index 0000000..29a16d9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/quaternion.inl.hpp @@ -0,0 +1,1063 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2020, Huawei Technologies Co., Ltd. All rights reserved. +// Third party copyrights are property of their respective owners. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Liangqian Kong +// Longbu Wang + +#ifndef OPENCV_CORE_QUATERNION_INL_HPP +#define OPENCV_CORE_QUATERNION_INL_HPP + +#ifndef OPENCV_CORE_QUATERNION_HPP +#erorr This is not a standalone header. Include quaternion.hpp instead. +#endif + +//@cond IGNORE +/////////////////////////////////////////////////////////////////////////////////////// +//Implementation +namespace cv { + +template +Quat::Quat() : w(0), x(0), y(0), z(0) {} + +template +Quat::Quat(const Vec &coeff):w(coeff[0]), x(coeff[1]), y(coeff[2]), z(coeff[3]){} + +template +Quat::Quat(const T qw, const T qx, const T qy, const T qz):w(qw), x(qx), y(qy), z(qz){} + +template +Quat Quat::createFromAngleAxis(const T angle, const Vec &axis) +{ + T w, x, y, z; + T vNorm = std::sqrt(axis.dot(axis)); + if (vNorm < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "this quaternion does not represent a rotation"); + } + const T angle_half = angle * T(0.5); + w = std::cos(angle_half); + const T sin_v = std::sin(angle_half); + const T sin_norm = sin_v / vNorm; + x = sin_norm * axis[0]; + y = sin_norm * axis[1]; + z = sin_norm * axis[2]; + return Quat(w, x, y, z); +} + +template +Quat Quat::createFromRotMat(InputArray _R) +{ + CV_CheckTypeEQ(_R.type(), cv::traits::Type::value, ""); + if (_R.rows() != 3 || _R.cols() != 3) + { + CV_Error(Error::StsBadArg, "Cannot convert matrix to quaternion: rotation matrix should be a 3x3 matrix"); + } + Matx R; + _R.copyTo(R); + + T S, w, x, y, z; + T trace = R(0, 0) + R(1, 1) + R(2, 2); + if (trace > 0) + { + S = std::sqrt(trace + 1) * T(2); + x = (R(1, 2) - R(2, 1)) / S; + y = (R(2, 0) - R(0, 2)) / S; + z = (R(0, 1) - R(1, 0)) / S; + w = -T(0.25) * S; + } + else if (R(0, 0) > R(1, 1) && R(0, 0) > R(2, 2)) + { + + S = std::sqrt(T(1.0) + R(0, 0) - R(1, 1) - R(2, 2)) * T(2); + x = -T(0.25) * S; + y = -(R(1, 0) + R(0, 1)) / S; + z = -(R(0, 2) + R(2, 0)) / S; + w = (R(1, 2) - R(2, 1)) / S; + } + else if (R(1, 1) > R(2, 2)) + { + S = std::sqrt(T(1.0) - R(0, 0) + R(1, 1) - R(2, 2)) * T(2); + x = (R(0, 1) + R(1, 0)) / S; + y = T(0.25) * S; + z = (R(1, 2) + R(2, 1)) / S; + w = (R(0, 2) - R(2, 0)) / S; + } + else + { + S = std::sqrt(T(1.0) - R(0, 0) - R(1, 1) + R(2, 2)) * T(2); + x = (R(0, 2) + R(2, 0)) / S; + y = (R(1, 2) + R(2, 1)) / S; + z = T(0.25) * S; + w = -(R(0, 1) - R(1, 0)) / S; + } + return Quat (w, x, y, z); +} + +template +Quat Quat::createFromRvec(InputArray _rvec) +{ + if (!((_rvec.cols() == 1 && _rvec.rows() == 3) || (_rvec.cols() == 3 && _rvec.rows() == 1))) { + CV_Error(Error::StsBadArg, "Cannot convert rotation vector to quaternion: The length of rotation vector should be 3"); + } + Vec rvec; + _rvec.copyTo(rvec); + T psi = std::sqrt(rvec.dot(rvec)); + if (abs(psi) < CV_QUAT_EPS) { + return Quat (1, 0, 0, 0); + } + Vec axis = rvec / psi; + return createFromAngleAxis(psi, axis); +} + +template +inline Quat Quat::operator-() const +{ + return Quat(-w, -x, -y, -z); +} + + +template +inline bool Quat::operator==(const Quat &q) const +{ + return (abs(w - q.w) < CV_QUAT_EPS && abs(x - q.x) < CV_QUAT_EPS && abs(y - q.y) < CV_QUAT_EPS && abs(z - q.z) < CV_QUAT_EPS); +} + +template +inline Quat Quat::operator+(const Quat &q1) const +{ + return Quat(w + q1.w, x + q1.x, y + q1.y, z + q1.z); +} + +template +inline Quat operator+(const T a, const Quat& q) +{ + return Quat(q.w + a, q.x, q.y, q.z); +} + +template +inline Quat operator+(const Quat& q, const T a) +{ + return Quat(q.w + a, q.x, q.y, q.z); +} + +template +inline Quat operator-(const T a, const Quat& q) +{ + return Quat(a - q.w, -q.x, -q.y, -q.z); +} + +template +inline Quat operator-(const Quat& q, const T a) +{ + return Quat(q.w - a, q.x, q.y, q.z); +} + +template +inline Quat Quat::operator-(const Quat &q1) const +{ + return Quat(w - q1.w, x - q1.x, y - q1.y, z - q1.z); +} + +template +inline Quat& Quat::operator+=(const Quat &q1) +{ + w += q1.w; + x += q1.x; + y += q1.y; + z += q1.z; + return *this; +} + +template +inline Quat& Quat::operator-=(const Quat &q1) +{ + w -= q1.w; + x -= q1.x; + y -= q1.y; + z -= q1.z; + return *this; +} + +template +inline Quat Quat::operator*(const Quat &q1) const +{ + Vec q{w, x, y, z}; + Vec q2{q1.w, q1.x, q1.y, q1.z}; + return Quat(q * q2); +} + + +template +Quat operator*(const Quat &q1, const T a) +{ + return Quat(a * q1.w, a * q1.x, a * q1.y, a * q1.z); +} + +template +Quat operator*(const T a, const Quat &q1) +{ + return Quat(a * q1.w, a * q1.x, a * q1.y, a * q1.z); +} + +template +inline Quat& Quat::operator*=(const Quat &q1) +{ + T qw, qx, qy, qz; + qw = w * q1.w - x * q1.x - y * q1.y - z * q1.z; + qx = x * q1.w + w * q1.x + y * q1.z - z * q1.y; + qy = y * q1.w + w * q1.y + z * q1.x - x * q1.z; + qz = z * q1.w + w * q1.z + x * q1.y - y * q1.x; + w = qw; + x = qx; + y = qy; + z = qz; + return *this; +} + +template +inline Quat& Quat::operator/=(const Quat &q1) +{ + Quat q(*this * q1.inv()); + w = q.w; + x = q.x; + y = q.y; + z = q.z; + return *this; +} +template +Quat& Quat::operator*=(const T q1) +{ + w *= q1; + x *= q1; + y *= q1; + z *= q1; + return *this; +} + +template +inline Quat& Quat::operator/=(const T a) +{ + const T a_inv = 1.0 / a; + w *= a_inv; + x *= a_inv; + y *= a_inv; + z *= a_inv; + return *this; +} + +template +inline Quat Quat::operator/(const T a) const +{ + const T a_inv = T(1.0) / a; + return Quat(w * a_inv, x * a_inv, y * a_inv, z * a_inv); +} + +template +inline Quat Quat::operator/(const Quat &q) const +{ + return *this * q.inv(); +} + +template +inline const T& Quat::operator[](std::size_t n) const +{ + switch (n) { + case 0: + return w; + case 1: + return x; + case 2: + return y; + case 3: + return z; + default: + CV_Error(Error::StsOutOfRange, "subscript exceeds the index range"); + } +} + +template +inline T& Quat::operator[](std::size_t n) +{ + switch (n) { + case 0: + return w; + case 1: + return x; + case 2: + return y; + case 3: + return z; + default: + CV_Error(Error::StsOutOfRange, "subscript exceeds the index range"); + } +} + +template +std::ostream & operator<<(std::ostream &os, const Quat &q) +{ + os << "Quat " << Vec{q.w, q.x, q.y, q.z}; + return os; +} + +template +inline T Quat::at(size_t index) const +{ + return (*this)[index]; +} + +template +inline Quat Quat::conjugate() const +{ + return Quat(w, -x, -y, -z); +} + +template +inline T Quat::norm() const +{ + return std::sqrt(dot(*this)); +} + +template +Quat exp(const Quat &q) +{ + return q.exp(); +} + +template +Quat Quat::exp() const +{ + Vec v{x, y, z}; + T normV = std::sqrt(v.dot(v)); + T k = normV < CV_QUAT_EPS ? 1 : std::sin(normV) / normV; + return std::exp(w) * Quat(std::cos(normV), v[0] * k, v[1] * k, v[2] * k); +} + +template +Quat log(const Quat &q, QuatAssumeType assumeUnit) +{ + return q.log(assumeUnit); +} + +template +Quat Quat::log(QuatAssumeType assumeUnit) const +{ + Vec v{x, y, z}; + T vNorm = std::sqrt(v.dot(v)); + if (assumeUnit) + { + T k = vNorm < CV_QUAT_EPS ? 1 : std::acos(w) / vNorm; + return Quat(0, v[0] * k, v[1] * k, v[2] * k); + } + T qNorm = norm(); + if (qNorm < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "Cannot apply this quaternion to log function: undefined"); + } + T k = vNorm < CV_QUAT_EPS ? 1 : std::acos(w / qNorm) / vNorm; + return Quat(std::log(qNorm), v[0] * k, v[1] * k, v[2] *k); +} + +template +inline Quat power(const Quat &q1, const T alpha, QuatAssumeType assumeUnit) +{ + return q1.power(alpha, assumeUnit); +} + +template +inline Quat Quat::power(const T alpha, QuatAssumeType assumeUnit) const +{ + if (x * x + y * y + z * z > CV_QUAT_EPS) + { + T angle = getAngle(assumeUnit); + Vec axis = getAxis(assumeUnit); + if (assumeUnit) + { + return createFromAngleAxis(alpha * angle, axis); + } + return std::pow(norm(), alpha) * createFromAngleAxis(alpha * angle, axis); + } + else + { + return std::pow(norm(), alpha) * Quat(w, x, y, z); + } +} + + +template +inline Quat sqrt(const Quat &q, QuatAssumeType assumeUnit) +{ + return q.sqrt(assumeUnit); +} + +template +inline Quat Quat::sqrt(QuatAssumeType assumeUnit) const +{ + return power(0.5, assumeUnit); +} + + +template +inline Quat power(const Quat &p, const Quat &q, QuatAssumeType assumeUnit) +{ + return p.power(q, assumeUnit); +} + + +template +inline Quat Quat::power(const Quat &q, QuatAssumeType assumeUnit) const +{ + return cv::exp(q * log(assumeUnit)); +} + +template +inline T Quat::dot(Quat q1) const +{ + return w * q1.w + x * q1.x + y * q1.y + z * q1.z; +} + + +template +inline Quat crossProduct(const Quat &p, const Quat &q) +{ + return p.crossProduct(q); +} + + +template +inline Quat Quat::crossProduct(const Quat &q) const +{ + return Quat (0, y * q.z - z * q.y, z * q.x - x * q.z, x * q.y - q.x * y); +} + +template +inline Quat Quat::normalize() const +{ + T normVal = norm(); + if (normVal < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "Cannot normalize this quaternion: the norm is too small."); + } + return Quat(w / normVal, x / normVal, y / normVal, z / normVal) ; +} + +template +inline Quat inv(const Quat &q, QuatAssumeType assumeUnit) +{ + return q.inv(assumeUnit); +} + + +template +inline Quat Quat::inv(QuatAssumeType assumeUnit) const +{ + if (assumeUnit) + { + return conjugate(); + } + T norm2 = dot(*this); + if (norm2 < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "This quaternion do not have inverse quaternion"); + } + return conjugate() / norm2; +} + +template +inline Quat sinh(const Quat &q) +{ + return q.sinh(); +} + + +template +inline Quat Quat::sinh() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::cosh(w) * std::sin(vNorm) / vNorm; + return Quat(std::sinh(w) * std::cos(vNorm), v[0] * k, v[1] * k, v[2] * k); +} + + +template +inline Quat cosh(const Quat &q) +{ + return q.cosh(); +} + + +template +inline Quat Quat::cosh() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::sinh(w) * std::sin(vNorm) / vNorm; + return Quat(std::cosh(w) * std::cos(vNorm), v[0] * k, v[1] * k, v[2] * k); +} + +template +inline Quat tanh(const Quat &q) +{ + return q.tanh(); +} + +template +inline Quat Quat::tanh() const +{ + return sinh() * cosh().inv(); +} + + +template +inline Quat sin(const Quat &q) +{ + return q.sin(); +} + + +template +inline Quat Quat::sin() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::cos(w) * std::sinh(vNorm) / vNorm; + return Quat(std::sin(w) * std::cosh(vNorm), v[0] * k, v[1] * k, v[2] * k); +} + +template +inline Quat cos(const Quat &q) +{ + return q.cos(); +} + +template +inline Quat Quat::cos() const +{ + Vec v{x, y ,z}; + T vNorm = std::sqrt(v.dot(v)); + T k = vNorm < CV_QUAT_EPS ? 1 : std::sin(w) * std::sinh(vNorm) / vNorm; + return Quat(std::cos(w) * std::cosh(vNorm), -v[0] * k, -v[1] * k, -v[2] * k); +} + +template +inline Quat tan(const Quat &q) +{ + return q.tan(); +} + +template +inline Quat Quat::tan() const +{ + return sin() * cos().inv(); +} + +template +inline Quat asinh(const Quat &q) +{ + return q.asinh(); +} + +template +inline Quat Quat::asinh() const +{ + return cv::log(*this + cv::power(*this * *this + Quat(1, 0, 0, 0), 0.5)); +} + +template +inline Quat acosh(const Quat &q) +{ + return q.acosh(); +} + +template +inline Quat Quat::acosh() const +{ + return cv::log(*this + cv::power(*this * *this - Quat(1,0,0,0), 0.5)); +} + +template +inline Quat atanh(const Quat &q) +{ + return q.atanh(); +} + +template +inline Quat Quat::atanh() const +{ + Quat ident(1, 0, 0, 0); + Quat c1 = (ident + *this).log(); + Quat c2 = (ident - *this).log(); + return 0.5 * (c1 - c2); +} + +template +inline Quat asin(const Quat &q) +{ + return q.asin(); +} + +template +inline Quat Quat::asin() const +{ + Quat v(0, x, y, z); + T vNorm = v.norm(); + T k = vNorm < CV_QUAT_EPS ? 1 : vNorm; + return -v / k * (*this * v / k).asinh(); +} + +template +inline Quat acos(const Quat &q) +{ + return q.acos(); +} + +template +inline Quat Quat::acos() const +{ + Quat v(0, x, y, z); + T vNorm = v.norm(); + T k = vNorm < CV_QUAT_EPS ? 1 : vNorm; + return -v / k * acosh(); +} + +template +inline Quat atan(const Quat &q) +{ + return q.atan(); +} + +template +inline Quat Quat::atan() const +{ + Quat v(0, x, y, z); + T vNorm = v.norm(); + T k = vNorm < CV_QUAT_EPS ? 1 : vNorm; + return -v / k * (*this * v / k).atanh(); +} + +template +inline T Quat::getAngle(QuatAssumeType assumeUnit) const +{ + if (assumeUnit) + { + return 2 * std::acos(w); + } + if (norm() < CV_QUAT_EPS) + { + CV_Error(Error::StsBadArg, "This quaternion does not represent a rotation"); + } + return 2 * std::acos(w / norm()); +} + +template +inline Vec Quat::getAxis(QuatAssumeType assumeUnit) const +{ + T angle = getAngle(assumeUnit); + const T sin_v = std::sin(angle * 0.5); + if (assumeUnit) + { + return Vec{x, y, z} / sin_v; + } + return Vec {x, y, z} / (norm() * sin_v); +} + +template +Matx Quat::toRotMat4x4(QuatAssumeType assumeUnit) const +{ + T a = w, b = x, c = y, d = z; + if (!assumeUnit) + { + Quat qTemp = normalize(); + a = qTemp.w; + b = qTemp.x; + c = qTemp.y; + d = qTemp.z; + } + Matx R{ + 1 - 2 * (c * c + d * d), 2 * (b * c - a * d) , 2 * (b * d + a * c) , 0, + 2 * (b * c + a * d) , 1 - 2 * (b * b + d * d), 2 * (c * d - a * b) , 0, + 2 * (b * d - a * c) , 2 * (c * d + a * b) , 1 - 2 * (b * b + c * c), 0, + 0 , 0 , 0 , 1, + }; + return R; +} + +template +Matx Quat::toRotMat3x3(QuatAssumeType assumeUnit) const +{ + T a = w, b = x, c = y, d = z; + if (!assumeUnit) + { + Quat qTemp = normalize(); + a = qTemp.w; + b = qTemp.x; + c = qTemp.y; + d = qTemp.z; + } + Matx R{ + 1 - 2 * (c * c + d * d), 2 * (b * c - a * d) , 2 * (b * d + a * c), + 2 * (b * c + a * d) , 1 - 2 * (b * b + d * d), 2 * (c * d - a * b), + 2 * (b * d - a * c) , 2 * (c * d + a * b) , 1 - 2 * (b * b + c * c) + }; + return R; +} + +template +Vec Quat::toRotVec(QuatAssumeType assumeUnit) const +{ + T angle = getAngle(assumeUnit); + Vec axis = getAxis(assumeUnit); + return angle * axis; +} + +template +Vec Quat::toVec() const +{ + return Vec{w, x, y, z}; +} + +template +Quat Quat::lerp(const Quat &q0, const Quat &q1, const T t) +{ + return (1 - t) * q0 + t * q1; +} + +template +Quat Quat::slerp(const Quat &q0, const Quat &q1, const T t, QuatAssumeType assumeUnit, bool directChange) +{ + Quatd v0(q0); + Quatd v1(q1); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + } + T cosTheta = v0.dot(v1); + constexpr T DOT_THRESHOLD = 0.995; + if (cosTheta > DOT_THRESHOLD) + { + return nlerp(v0, v1, t, QUAT_ASSUME_UNIT); + } + + if (directChange && cosTheta < 0) + { + v0 = -v0; + cosTheta = -cosTheta; + } + T sinTheta = std::sqrt(1 - cosTheta * cosTheta); + T angle = atan2(sinTheta, cosTheta); + return (std::sin((1 - t) * angle) / (sinTheta) * v0 + std::sin(t * angle) / (sinTheta) * v1).normalize(); +} + + +template +inline Quat Quat::nlerp(const Quat &q0, const Quat &q1, const T t, QuatAssumeType assumeUnit) +{ + Quat v0(q0), v1(q1); + if (v1.dot(v0) < 0) + { + v0 = -v0; + } + if (assumeUnit) + { + return ((1 - t) * v0 + t * v1).normalize(); + } + v0 = v0.normalize(); + v1 = v1.normalize(); + return ((1 - t) * v0 + t * v1).normalize(); +} + + +template +inline bool Quat::isNormal(T eps) const +{ + + double normVar = norm(); + if ((normVar > 1 - eps) && (normVar < 1 + eps)) + return true; + return false; +} + +template +inline void Quat::assertNormal(T eps) const +{ + if (!isNormal(eps)) + CV_Error(Error::StsBadArg, "Quaternion should be normalized"); +} + + +template +inline Quat Quat::squad(const Quat &q0, const Quat &q1, + const Quat &q2, const Quat &q3, + const T t, QuatAssumeType assumeUnit, + bool directChange) +{ + Quat v0(q0), v1(q1), v2(q2), v3(q3); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + v2 = v2.normalize(); + v3 = v3.normalize(); + } + + Quat c0 = slerp(v0, v3, t, assumeUnit, directChange); + Quat c1 = slerp(v1, v2, t, assumeUnit, directChange); + return slerp(c0, c1, 2 * t * (1 - t), assumeUnit, directChange); +} + +template +Quat Quat::interPoint(const Quat &q0, const Quat &q1, + const Quat &q2, QuatAssumeType assumeUnit) +{ + Quat v0(q0), v1(q1), v2(q2); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + v2 = v2.normalize(); + } + return v1 * cv::exp(-(cv::log(v1.conjugate() * v0, assumeUnit) + (cv::log(v1.conjugate() * v2, assumeUnit))) / 4); +} + +template +Quat Quat::spline(const Quat &q0, const Quat &q1, const Quat &q2, const Quat &q3, const T t, QuatAssumeType assumeUnit) +{ + Quatd v0(q0), v1(q1), v2(q2), v3(q3); + if (!assumeUnit) + { + v0 = v0.normalize(); + v1 = v1.normalize(); + v2 = v2.normalize(); + v3 = v3.normalize(); + } + T cosTheta; + std::vector> vec{v0, v1, v2, v3}; + for (size_t i = 0; i < 3; ++i) + { + cosTheta = vec[i].dot(vec[i + 1]); + if (cosTheta < 0) + { + vec[i + 1] = -vec[i + 1]; + } + } + Quat s1 = interPoint(vec[0], vec[1], vec[2], QUAT_ASSUME_UNIT); + Quat s2 = interPoint(vec[1], vec[2], vec[3], QUAT_ASSUME_UNIT); + return squad(vec[1], s1, s2, vec[2], t, assumeUnit, QUAT_ASSUME_NOT_UNIT); +} + +namespace detail { + +template static +Quat createFromAxisRot(int axis, const T theta) +{ + if (axis == 0) + return Quat::createFromXRot(theta); + if (axis == 1) + return Quat::createFromYRot(theta); + if (axis == 2) + return Quat::createFromZRot(theta); + CV_Assert(0); +} + +inline bool isIntAngleType(QuatEnum::EulerAnglesType eulerAnglesType) +{ + return eulerAnglesType < QuatEnum::EXT_XYZ; +} + +inline bool isTaitBryan(QuatEnum::EulerAnglesType eulerAnglesType) +{ + return eulerAnglesType/6 == 1 || eulerAnglesType/6 == 3; +} +} // namespace detail + +template +Quat Quat::createFromYRot(const T theta) +{ + return Quat{std::cos(theta * 0.5f), 0, std::sin(theta * 0.5f), 0}; +} + +template +Quat Quat::createFromXRot(const T theta){ + return Quat{std::cos(theta * 0.5f), std::sin(theta * 0.5f), 0, 0}; +} + +template +Quat Quat::createFromZRot(const T theta){ + return Quat{std::cos(theta * 0.5f), 0, 0, std::sin(theta * 0.5f)}; +} + + +template +Quat Quat::createFromEulerAngles(const Vec &angles, QuatEnum::EulerAnglesType eulerAnglesType) { + CV_Assert(eulerAnglesType < QuatEnum::EulerAnglesType::EULER_ANGLES_MAX_VALUE); + static const int rotationAxis[24][3] = { + {0, 1, 2}, ///< Intrinsic rotations with the Euler angles type X-Y-Z + {0, 2, 1}, ///< Intrinsic rotations with the Euler angles type X-Z-Y + {1, 0, 2}, ///< Intrinsic rotations with the Euler angles type Y-X-Z + {1, 2, 0}, ///< Intrinsic rotations with the Euler angles type Y-Z-X + {2, 0, 1}, ///< Intrinsic rotations with the Euler angles type Z-X-Y + {2, 1, 0}, ///< Intrinsic rotations with the Euler angles type Z-Y-X + {0, 1, 0}, ///< Intrinsic rotations with the Euler angles type X-Y-X + {0, 2, 0}, ///< Intrinsic rotations with the Euler angles type X-Z-X + {1, 0, 1}, ///< Intrinsic rotations with the Euler angles type Y-X-Y + {1, 2, 1}, ///< Intrinsic rotations with the Euler angles type Y-Z-Y + {2, 0, 2}, ///< Intrinsic rotations with the Euler angles type Z-X-Z + {2, 1, 2}, ///< Intrinsic rotations with the Euler angles type Z-Y-Z + {0, 1, 2}, ///< Extrinsic rotations with the Euler angles type X-Y-Z + {0, 2, 1}, ///< Extrinsic rotations with the Euler angles type X-Z-Y + {1, 0, 2}, ///< Extrinsic rotations with the Euler angles type Y-X-Z + {1, 2, 0}, ///< Extrinsic rotations with the Euler angles type Y-Z-X + {2, 0, 1}, ///< Extrinsic rotations with the Euler angles type Z-X-Y + {2, 1, 0}, ///< Extrinsic rotations with the Euler angles type Z-Y-X + {0, 1, 0}, ///< Extrinsic rotations with the Euler angles type X-Y-X + {0, 2, 0}, ///< Extrinsic rotations with the Euler angles type X-Z-X + {1, 0, 1}, ///< Extrinsic rotations with the Euler angles type Y-X-Y + {1, 2, 1}, ///< Extrinsic rotations with the Euler angles type Y-Z-Y + {2, 0, 2}, ///< Extrinsic rotations with the Euler angles type Z-X-Z + {2, 1, 2} ///< Extrinsic rotations with the Euler angles type Z-Y-Z + }; + Quat q1 = detail::createFromAxisRot(rotationAxis[eulerAnglesType][0], angles(0)); + Quat q2 = detail::createFromAxisRot(rotationAxis[eulerAnglesType][1], angles(1)); + Quat q3 = detail::createFromAxisRot(rotationAxis[eulerAnglesType][2], angles(2)); + if (detail::isIntAngleType(eulerAnglesType)) + { + return q1 * q2 * q3; + } + else // (!detail::isIntAngleType(eulerAnglesType)) + { + return q3 * q2 * q1; + } +} + +template +Vec Quat::toEulerAngles(QuatEnum::EulerAnglesType eulerAnglesType){ + CV_Assert(eulerAnglesType < QuatEnum::EulerAnglesType::EULER_ANGLES_MAX_VALUE); + Matx33d R = toRotMat3x3(); + enum { + C_ZERO, + C_PI, + C_PI_2, + N_CONSTANTS, + R_0_0 = N_CONSTANTS, R_0_1, R_0_2, + R_1_0, R_1_1, R_1_2, + R_2_0, R_2_1, R_2_2 + }; + static const T constants_[N_CONSTANTS] = { + 0, // C_ZERO + (T)CV_PI, // C_PI + (T)(CV_PI * 0.5) // C_PI_2, -C_PI_2 + }; + static const int rotationR_[24][12] = { + {+R_0_2, +R_1_0, +R_1_1, C_PI_2, +R_2_1, +R_1_1, -C_PI_2, -R_1_2, +R_2_2, +R_0_2, -R_0_1, +R_0_0}, // INT_XYZ + {+R_0_1, -R_1_2, +R_2_2, -C_PI_2, +R_2_0, +R_2_2, C_PI_2, +R_2_1, +R_1_1, -R_0_1, +R_0_2, +R_0_0}, // INT_XZY + {+R_1_2, -R_0_1, +R_0_0, -C_PI_2, +R_0_1, +R_0_0, C_PI_2, +R_0_2, +R_2_2, -R_1_2, +R_1_0, +R_1_1}, // INT_YXZ + {+R_1_0, +R_0_2, +R_2_2, C_PI_2, +R_0_2, +R_0_1, -C_PI_2, -R_2_0, +R_0_0, +R_1_0, -R_1_2, +R_1_1}, // INT_YZX + {+R_2_1, +R_1_0, +R_0_0, C_PI_2, +R_1_0, +R_0_0, -C_PI_2, -R_0_1, +R_1_1, +R_2_1, -R_2_0, +R_2_2}, // INT_ZXY + {+R_2_0, -R_0_1, +R_1_1, -C_PI_2, +R_1_2, +R_1_1, C_PI_2, +R_1_0, +R_0_0, -R_2_0, +R_2_1, +R_2_2}, // INT_ZYX + {+R_0_0, +R_2_1, +R_2_2, C_ZERO, +R_1_2, +R_1_1, C_PI, +R_1_0, -R_2_0, +R_0_0, +R_0_1, +R_0_2}, // INT_XYX + {+R_0_0, +R_2_1, +R_2_2, C_ZERO, -R_2_1, +R_2_2, C_PI, +R_2_0, +R_1_0, +R_0_0, +R_0_2, -R_0_1}, // INT_XZX + {+R_1_1, +R_0_2, +R_0_0, C_ZERO, -R_2_0, +R_0_0, C_PI, +R_0_1, +R_2_1, +R_1_1, +R_1_0, -R_1_2}, // INT_YXY + {+R_1_1, +R_0_2, +R_0_0, C_ZERO, +R_0_2, -R_0_0, C_PI, +R_2_1, -R_0_1, +R_1_1, +R_1_2, +R_1_0}, // INT_YZY + {+R_2_2, +R_1_0, +R_1_1, C_ZERO, +R_1_0, +R_0_0, C_PI, +R_0_2, -R_1_2, +R_2_2, +R_2_0, +R_2_1}, // INT_ZXZ + {+R_2_2, +R_1_0, +R_0_0, C_ZERO, +R_1_0, +R_0_0, C_PI, +R_1_2, +R_0_2, +R_2_2, +R_2_1, -R_2_0}, // INT_ZYZ + + {+R_2_0, -C_PI_2, -R_0_1, +R_1_1, C_PI_2, +R_1_2, +R_1_1, +R_2_1, +R_2_2, -R_2_0, +R_1_0, +R_0_0}, // EXT_XYZ + {+R_1_0, C_PI_2, +R_0_2, +R_2_2, -C_PI_2, +R_0_2, +R_0_1, -R_1_2, +R_1_1, +R_1_0, -R_2_0, +R_0_0}, // EXT_XZY + {+R_2_1, C_PI_2, +R_1_0, +R_0_0, -C_PI_2, +R_1_0, +R_0_0, -R_2_0, +R_2_2, +R_2_1, -R_0_1, +R_1_1}, // EXT_YXZ + {+R_0_2, -C_PI_2, -R_1_2, +R_2_2, C_PI_2, +R_2_0, +R_2_2, +R_0_2, +R_0_0, -R_0_1, +R_2_1, +R_1_1}, // EXT_YZX + {+R_1_2, -C_PI_2, -R_0_1, +R_0_0, C_PI_2, +R_0_1, +R_0_0, +R_1_0, +R_1_1, -R_1_2, +R_0_2, +R_2_2}, // EXT_ZXY + {+R_0_2, C_PI_2, +R_1_0, +R_1_1, -C_PI_2, +R_2_1, +R_1_1, -R_0_1, +R_0_0, +R_0_2, -R_1_2, +R_2_2}, // EXT_ZYX + {+R_0_0, C_ZERO, +R_2_1, +R_2_2, C_PI, +R_1_2, +R_1_1, +R_0_1, +R_0_2, +R_0_0, +R_1_0, -R_2_0}, // EXT_XYX + {+R_0_0, C_ZERO, +R_2_1, +R_2_2, C_PI, +R_2_1, +R_2_2, +R_0_2, -R_0_1, +R_0_0, +R_2_0, +R_1_0}, // EXT_XZX + {+R_1_1, C_ZERO, +R_0_2, +R_0_0, C_PI, -R_2_0, +R_0_0, +R_1_0, -R_1_2, +R_1_1, +R_0_1, +R_2_1}, // EXT_YXY + {+R_1_1, C_ZERO, +R_0_2, +R_0_0, C_PI, +R_0_2, -R_0_0, +R_1_2, +R_1_0, +R_1_1, +R_2_1, -R_0_1}, // EXT_YZY + {+R_2_2, C_ZERO, +R_1_0, +R_1_1, C_PI, +R_1_0, +R_0_0, +R_2_0, +R_2_1, +R_2_2, +R_0_2, -R_1_2}, // EXT_ZXZ + {+R_2_2, C_ZERO, +R_1_0, +R_0_0, C_PI, +R_1_0, +R_0_0, +R_2_1, -R_2_0, +R_2_2, +R_1_2, +R_0_2}, // EXT_ZYZ + }; + T rotationR[12]; + for (int i = 0; i < 12; i++) + { + int id = rotationR_[eulerAnglesType][i]; + unsigned idx = std::abs(id); + T value = 0.0f; + if (idx < N_CONSTANTS) + { + value = constants_[idx]; + } + else + { + unsigned r_idx = idx - N_CONSTANTS; + CV_DbgAssert(r_idx < 9); + value = R.val[r_idx]; + } + bool isNegative = id < 0; + if (isNegative) + value = -value; + rotationR[i] = value; + } + Vec angles; + if (detail::isIntAngleType(eulerAnglesType)) + { + if (abs(rotationR[0] - 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the third angle to 0"); + angles = {std::atan2(rotationR[1], rotationR[2]), rotationR[3], 0}; + return angles; + } + else if(abs(rotationR[0] + 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the third angle to 0"); + angles = {std::atan2(rotationR[4], rotationR[5]), rotationR[6], 0}; + return angles; + } + } + else // (!detail::isIntAngleType(eulerAnglesType)) + { + if (abs(rotationR[0] - 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the first angle to 0"); + angles = {0, rotationR[1], std::atan2(rotationR[2], rotationR[3])}; + return angles; + } + else if (abs(rotationR[0] + 1) < CV_QUAT_CONVERT_THRESHOLD) + { + CV_LOG_WARNING(NULL,"Gimbal Lock occurs. Euler angles are non-unique, we set the first angle to 0"); + angles = {0, rotationR[4], std::atan2(rotationR[5], rotationR[6])}; + return angles; + } + } + + angles(0) = std::atan2(rotationR[7], rotationR[8]); + if (detail::isTaitBryan(eulerAnglesType)) + angles(1) = std::acos(rotationR[9]); + else + angles(1) = std::asin(rotationR[9]); + angles(2) = std::atan2(rotationR[10], rotationR[11]); + return angles; +} + +} // namepsace +//! @endcond + +#endif /*OPENCV_CORE_QUATERNION_INL_HPP*/ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/saturate.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/saturate.hpp new file mode 100644 index 0000000..8127e3d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/saturate.hpp @@ -0,0 +1,179 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2014, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_SATURATE_HPP +#define OPENCV_CORE_SATURATE_HPP + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/fast_math.hpp" + +namespace cv +{ + +//! @addtogroup core_utils +//! @{ + +/////////////// saturate_cast (used in image & signal processing) /////////////////// + +/** @brief Template function for accurate conversion from one primitive type to another. + + The function saturate_cast resembles the standard C++ cast operations, such as static_cast\() + and others. It perform an efficient and accurate conversion from one primitive type to another + (see the introduction chapter). saturate in the name means that when the input value v is out of the + range of the target type, the result is not formed just by taking low bits of the input, but instead + the value is clipped. For example: + @code + uchar a = saturate_cast(-100); // a = 0 (UCHAR_MIN) + short b = saturate_cast(33333.33333); // b = 32767 (SHRT_MAX) + @endcode + Such clipping is done when the target type is unsigned char , signed char , unsigned short or + signed short . For 32-bit integers, no clipping is done. + + When the parameter is a floating-point value and the target type is an integer (8-, 16- or 32-bit), + the floating-point value is first rounded to the nearest integer and then clipped if needed (when + the target type is 8- or 16-bit). + + @param v Function parameter. + @sa add, subtract, multiply, divide, Mat::convertTo + */ +template static inline _Tp saturate_cast(uchar v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(schar v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(ushort v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(short v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(unsigned v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(int v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(float v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(double v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(int64 v) { return _Tp(v); } +/** @overload */ +template static inline _Tp saturate_cast(uint64 v) { return _Tp(v); } + +template<> inline uchar saturate_cast(schar v) { return (uchar)std::max((int)v, 0); } +template<> inline uchar saturate_cast(ushort v) { return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); } +template<> inline uchar saturate_cast(int v) { return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); } +template<> inline uchar saturate_cast(short v) { return saturate_cast((int)v); } +template<> inline uchar saturate_cast(unsigned v) { return (uchar)std::min(v, (unsigned)UCHAR_MAX); } +template<> inline uchar saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline uchar saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline uchar saturate_cast(int64 v) { return (uchar)((uint64)v <= (uint64)UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); } +template<> inline uchar saturate_cast(uint64 v) { return (uchar)std::min(v, (uint64)UCHAR_MAX); } + +template<> inline schar saturate_cast(uchar v) { return (schar)std::min((int)v, SCHAR_MAX); } +template<> inline schar saturate_cast(ushort v) { return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); } +template<> inline schar saturate_cast(int v) { return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); } +template<> inline schar saturate_cast(short v) { return saturate_cast((int)v); } +template<> inline schar saturate_cast(unsigned v) { return (schar)std::min(v, (unsigned)SCHAR_MAX); } +template<> inline schar saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline schar saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline schar saturate_cast(int64 v) { return (schar)((uint64)((int64)v-SCHAR_MIN) <= (uint64)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); } +template<> inline schar saturate_cast(uint64 v) { return (schar)std::min(v, (uint64)SCHAR_MAX); } + +template<> inline ushort saturate_cast(schar v) { return (ushort)std::max((int)v, 0); } +template<> inline ushort saturate_cast(short v) { return (ushort)std::max((int)v, 0); } +template<> inline ushort saturate_cast(int v) { return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); } +template<> inline ushort saturate_cast(unsigned v) { return (ushort)std::min(v, (unsigned)USHRT_MAX); } +template<> inline ushort saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline ushort saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline ushort saturate_cast(int64 v) { return (ushort)((uint64)v <= (uint64)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); } +template<> inline ushort saturate_cast(uint64 v) { return (ushort)std::min(v, (uint64)USHRT_MAX); } + +template<> inline short saturate_cast(ushort v) { return (short)std::min((int)v, SHRT_MAX); } +template<> inline short saturate_cast(int v) { return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); } +template<> inline short saturate_cast(unsigned v) { return (short)std::min(v, (unsigned)SHRT_MAX); } +template<> inline short saturate_cast(float v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline short saturate_cast(double v) { int iv = cvRound(v); return saturate_cast(iv); } +template<> inline short saturate_cast(int64 v) { return (short)((uint64)((int64)v - SHRT_MIN) <= (uint64)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); } +template<> inline short saturate_cast(uint64 v) { return (short)std::min(v, (uint64)SHRT_MAX); } + +template<> inline int saturate_cast(unsigned v) { return (int)std::min(v, (unsigned)INT_MAX); } +template<> inline int saturate_cast(int64 v) { return (int)((uint64)(v - INT_MIN) <= (uint64)UINT_MAX ? v : v > 0 ? INT_MAX : INT_MIN); } +template<> inline int saturate_cast(uint64 v) { return (int)std::min(v, (uint64)INT_MAX); } +template<> inline int saturate_cast(float v) { return cvRound(v); } +template<> inline int saturate_cast(double v) { return cvRound(v); } + +template<> inline unsigned saturate_cast(schar v) { return (unsigned)std::max(v, (schar)0); } +template<> inline unsigned saturate_cast(short v) { return (unsigned)std::max(v, (short)0); } +template<> inline unsigned saturate_cast(int v) { return (unsigned)std::max(v, (int)0); } +template<> inline unsigned saturate_cast(int64 v) { return (unsigned)((uint64)v <= (uint64)UINT_MAX ? v : v > 0 ? UINT_MAX : 0); } +template<> inline unsigned saturate_cast(uint64 v) { return (unsigned)std::min(v, (uint64)UINT_MAX); } +// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc. +template<> inline unsigned saturate_cast(float v) { return static_cast(cvRound(v)); } +template<> inline unsigned saturate_cast(double v) { return static_cast(cvRound(v)); } + +template<> inline uint64 saturate_cast(schar v) { return (uint64)std::max(v, (schar)0); } +template<> inline uint64 saturate_cast(short v) { return (uint64)std::max(v, (short)0); } +template<> inline uint64 saturate_cast(int v) { return (uint64)std::max(v, (int)0); } +template<> inline uint64 saturate_cast(int64 v) { return (uint64)std::max(v, (int64)0); } + +template<> inline int64 saturate_cast(uint64 v) { return (int64)std::min(v, (uint64)LLONG_MAX); } + +/** @overload */ +template static inline _Tp saturate_cast(float16_t v) { return saturate_cast<_Tp>((float)v); } + +// in theory, we could use a LUT for 8u/8s->16f conversion, +// but with hardware support for FP32->FP16 conversion the current approach is preferable +template<> inline float16_t saturate_cast(uchar v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(schar v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(ushort v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(short v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(unsigned v){ return float16_t((float)v); } +template<> inline float16_t saturate_cast(int v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(uint64 v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(int64 v) { return float16_t((float)v); } +template<> inline float16_t saturate_cast(float v) { return float16_t(v); } +template<> inline float16_t saturate_cast(double v) { return float16_t((float)v); } + +//! @} + +} // cv + +#endif // OPENCV_CORE_SATURATE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/simd_intrinsics.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/simd_intrinsics.hpp new file mode 100644 index 0000000..2658d92 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/simd_intrinsics.hpp @@ -0,0 +1,87 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_SIMD_INTRINSICS_HPP +#define OPENCV_CORE_SIMD_INTRINSICS_HPP + +/** +Helper header to support SIMD intrinsics (universal intrinsics) in user code. +Intrinsics documentation: https://docs.opencv.org/4.x/df/d91/group__core__hal__intrin.html + + +Checks of target CPU instruction set based on compiler definitions don't work well enough. +More reliable solutions require utilization of configuration systems (like CMake). + +So, probably you need to specify your own configuration. + +You can do that via CMake in this way: + add_definitions(/DOPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp) +or + add_definitions(/DOPENCV_SIMD_CONFIG_INCLUDE_DIR=1) + +Additionally you may need to add include directory to your files: + include_directories("${CMAKE_CURRENT_LIST_DIR}/opencv_config_${MYTARGET}") + +These files can be pre-generated for target configurations of your application +or generated by CMake on the fly (use CMAKE_BINARY_DIR for that). + +Notes: +- H/W capability checks are still responsibility of your application +- runtime dispatching is not covered by this helper header +*/ + +#ifdef __OPENCV_BUILD +#error "Use core/hal/intrin.hpp during OpenCV build" +#endif + +#ifdef OPENCV_HAL_INTRIN_HPP +#error "core/simd_intrinsics.hpp must be included before core/hal/intrin.hpp" +#endif + +#include "opencv2/core/cvdef.h" + +#ifdef OPENCV_SIMD_CONFIG_HEADER +#include CVAUX_STR(OPENCV_SIMD_CONFIG_HEADER) +#elif defined(OPENCV_SIMD_CONFIG_INCLUDE_DIR) +#include "opencv_simd_config.hpp" // corresponding directory should be added via -I compiler parameter +#else // custom config headers + +#if (!defined(CV_AVX_512F) || !CV_AVX_512F) && (defined(__AVX512__) || defined(__AVX512F__)) +# include +# undef CV_AVX_512F +# define CV_AVX_512F 1 +# ifndef OPENCV_SIMD_DONT_ASSUME_SKX // Skylake-X with AVX-512F/CD/BW/DQ/VL +# undef CV_AVX512_SKX +# define CV_AVX512_SKX 1 +# undef CV_AVX_512CD +# define CV_AVX_512CD 1 +# undef CV_AVX_512BW +# define CV_AVX_512BW 1 +# undef CV_AVX_512DQ +# define CV_AVX_512DQ 1 +# undef CV_AVX_512VL +# define CV_AVX_512VL 1 +# endif +#endif // AVX512 + +// GCC/Clang: -mavx2 +// MSVC: /arch:AVX2 +#if defined __AVX2__ +# include +# undef CV_AVX2 +# define CV_AVX2 1 +# if defined __F16C__ +# undef CV_FP16 +# define CV_FP16 1 +# endif +#endif + +#endif + +// SSE / NEON / VSX is handled by cv_cpu_dispatch.h compatibility block +#include "cv_cpu_dispatch.h" + +#include "hal/intrin.hpp" + +#endif // OPENCV_CORE_SIMD_INTRINSICS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/softfloat.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/softfloat.hpp new file mode 100644 index 0000000..485e15c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/softfloat.hpp @@ -0,0 +1,514 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +// This file is based on files from package issued with the following license: + +/*============================================================================ + +This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic +Package, Release 3c, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the +University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions, and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS 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. + +=============================================================================*/ + +#pragma once +#ifndef softfloat_h +#define softfloat_h 1 + +#include "cvdef.h" + +namespace cv +{ + +/** @addtogroup core_utils_softfloat + + [SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is a software implementation + of floating-point calculations according to IEEE 754 standard. + All calculations are done in integers, that's why they are machine-independent and bit-exact. + This library can be useful in accuracy-critical parts like look-up tables generation, tests, etc. + OpenCV contains a subset of SoftFloat partially rewritten to C++. + + ### Types + + There are two basic types: @ref softfloat and @ref softdouble. + These types are binary compatible with float and double types respectively + and support conversions to/from them. + Other types from original SoftFloat library like fp16 or fp128 were thrown away + as well as quiet/signaling NaN support, on-the-fly rounding mode switch + and exception flags (though exceptions can be implemented in the future). + + ### Operations + + Both types support the following: + - Construction from signed and unsigned 32-bit and 64 integers, + float/double or raw binary representation + - Conversions between each other, to float or double and to int + using @ref cvRound, @ref cvTrunc, @ref cvFloor, @ref cvCeil or a bunch of + saturate_cast functions + - Add, subtract, multiply, divide, remainder, square root, FMA with absolute precision + - Comparison operations + - Explicit sign, exponent and significand manipulation through get/set methods, + number state indicators (isInf, isNan, isSubnormal) + - Type-specific constants like eps, minimum/maximum value, best pi approximation, etc. + - min(), max(), abs(), exp(), log() and pow() functions + +*/ +//! @{ + +struct softfloat; +struct softdouble; + +struct CV_EXPORTS softfloat +{ +public: + /** @brief Default constructor */ + softfloat() { v = 0; } + /** @brief Copy constructor */ + softfloat( const softfloat& c) { v = c.v; } + /** @brief Assign constructor */ + softfloat& operator=( const softfloat& c ) + { + if(&c != this) v = c.v; + return *this; + } + /** @brief Construct from raw + + Builds new value from raw binary representation + */ + static const softfloat fromRaw( const uint32_t a ) { softfloat x; x.v = a; return x; } + + /** @brief Construct from integer */ + explicit softfloat( const uint32_t ); + explicit softfloat( const uint64_t ); + explicit softfloat( const int32_t ); + explicit softfloat( const int64_t ); + +#ifdef CV_INT32_T_IS_LONG_INT + // for platforms with int32_t = long int + explicit softfloat( const int a ) { *this = softfloat(static_cast(a)); } +#endif + + /** @brief Construct from float */ + explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; } + + /** @brief Type casts */ + operator softdouble() const; + operator float() const { Cv32suf s; s.u = v; return s.f; } + + /** @brief Basic arithmetics */ + softfloat operator + (const softfloat&) const; + softfloat operator - (const softfloat&) const; + softfloat operator * (const softfloat&) const; + softfloat operator / (const softfloat&) const; + softfloat operator - () const { softfloat x; x.v = v ^ (1U << 31); return x; } + + /** @brief Remainder operator + + A quote from original SoftFloat manual: + + > The IEEE Standard remainder operation computes the value + > a - n * b, where n is the integer closest to a / b. + > If a / b is exactly halfway between two integers, n is the even integer + > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding. + > Depending on the relative magnitudes of the operands, the remainder functions + > can take considerably longer to execute than the other SoftFloat functions. + > This is an inherent characteristic of the remainder operation itself and is not a flaw + > in the SoftFloat implementation. + */ + softfloat operator % (const softfloat&) const; + + softfloat& operator += (const softfloat& a) { *this = *this + a; return *this; } + softfloat& operator -= (const softfloat& a) { *this = *this - a; return *this; } + softfloat& operator *= (const softfloat& a) { *this = *this * a; return *this; } + softfloat& operator /= (const softfloat& a) { *this = *this / a; return *this; } + softfloat& operator %= (const softfloat& a) { *this = *this % a; return *this; } + + /** @brief Comparison operations + + - Any operation with NaN produces false + + The only exception is when x is NaN: x != y for any y. + - Positive and negative zeros are equal + */ + bool operator == ( const softfloat& ) const; + bool operator != ( const softfloat& ) const; + bool operator > ( const softfloat& ) const; + bool operator >= ( const softfloat& ) const; + bool operator < ( const softfloat& ) const; + bool operator <= ( const softfloat& ) const; + + /** @brief NaN state indicator */ + inline bool isNaN() const { return (v & 0x7fffffff) > 0x7f800000; } + /** @brief Inf state indicator */ + inline bool isInf() const { return (v & 0x7fffffff) == 0x7f800000; } + /** @brief Subnormal number indicator */ + inline bool isSubnormal() const { return ((v >> 23) & 0xFF) == 0; } + + /** @brief Get sign bit */ + inline bool getSign() const { return (v >> 31) != 0; } + /** @brief Construct a copy with new sign bit */ + inline softfloat setSign(bool sign) const { softfloat x; x.v = (v & ((1U << 31) - 1)) | ((uint32_t)sign << 31); return x; } + /** @brief Get 0-based exponent */ + inline int getExp() const { return ((v >> 23) & 0xFF) - 127; } + /** @brief Construct a copy with new 0-based exponent */ + inline softfloat setExp(int e) const { softfloat x; x.v = (v & 0x807fffff) | (((e + 127) & 0xFF) << 23 ); return x; } + + /** @brief Get a fraction part + + Returns a number 1 <= x < 2 with the same significand + */ + inline softfloat getFrac() const + { + uint_fast32_t vv = (v & 0x007fffff) | (127 << 23); + return softfloat::fromRaw(vv); + } + /** @brief Construct a copy with provided significand + + Constructs a copy of a number with significand taken from parameter + */ + inline softfloat setFrac(const softfloat& s) const + { + softfloat x; + x.v = (v & 0xff800000) | (s.v & 0x007fffff); + return x; + } + + /** @brief Zero constant */ + static softfloat zero() { return softfloat::fromRaw( 0 ); } + /** @brief Positive infinity constant */ + static softfloat inf() { return softfloat::fromRaw( 0xFF << 23 ); } + /** @brief Default NaN constant */ + static softfloat nan() { return softfloat::fromRaw( 0x7fffffff ); } + /** @brief One constant */ + static softfloat one() { return softfloat::fromRaw( 127 << 23 ); } + /** @brief Smallest normalized value */ + static softfloat min() { return softfloat::fromRaw( 0x01 << 23 ); } + /** @brief Difference between 1 and next representable value */ + static softfloat eps() { return softfloat::fromRaw( (127 - 23) << 23 ); } + /** @brief Biggest finite value */ + static softfloat max() { return softfloat::fromRaw( (0xFF << 23) - 1 ); } + /** @brief Correct pi approximation */ + static softfloat pi() { return softfloat::fromRaw( 0x40490fdb ); } + + uint32_t v; +}; + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +struct CV_EXPORTS softdouble +{ +public: + /** @brief Default constructor */ + softdouble() : v(0) { } + /** @brief Copy constructor */ + softdouble( const softdouble& c) { v = c.v; } + /** @brief Assign constructor */ + softdouble& operator=( const softdouble& c ) + { + if(&c != this) v = c.v; + return *this; + } + /** @brief Construct from raw + + Builds new value from raw binary representation + */ + static softdouble fromRaw( const uint64_t a ) { softdouble x; x.v = a; return x; } + + /** @brief Construct from integer */ + explicit softdouble( const uint32_t ); + explicit softdouble( const uint64_t ); + explicit softdouble( const int32_t ); + explicit softdouble( const int64_t ); + +#ifdef CV_INT32_T_IS_LONG_INT + // for platforms with int32_t = long int + explicit softdouble( const int a ) { *this = softdouble(static_cast(a)); } +#endif + + /** @brief Construct from double */ + explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; } + + /** @brief Type casts */ + operator softfloat() const; + operator double() const { Cv64suf s; s.u = v; return s.f; } + + /** @brief Basic arithmetics */ + softdouble operator + (const softdouble&) const; + softdouble operator - (const softdouble&) const; + softdouble operator * (const softdouble&) const; + softdouble operator / (const softdouble&) const; + softdouble operator - () const { softdouble x; x.v = v ^ (1ULL << 63); return x; } + + /** @brief Remainder operator + + A quote from original SoftFloat manual: + + > The IEEE Standard remainder operation computes the value + > a - n * b, where n is the integer closest to a / b. + > If a / b is exactly halfway between two integers, n is the even integer + > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding. + > Depending on the relative magnitudes of the operands, the remainder functions + > can take considerably longer to execute than the other SoftFloat functions. + > This is an inherent characteristic of the remainder operation itself and is not a flaw + > in the SoftFloat implementation. + */ + softdouble operator % (const softdouble&) const; + + softdouble& operator += (const softdouble& a) { *this = *this + a; return *this; } + softdouble& operator -= (const softdouble& a) { *this = *this - a; return *this; } + softdouble& operator *= (const softdouble& a) { *this = *this * a; return *this; } + softdouble& operator /= (const softdouble& a) { *this = *this / a; return *this; } + softdouble& operator %= (const softdouble& a) { *this = *this % a; return *this; } + + /** @brief Comparison operations + + - Any operation with NaN produces false + + The only exception is when x is NaN: x != y for any y. + - Positive and negative zeros are equal + */ + bool operator == ( const softdouble& ) const; + bool operator != ( const softdouble& ) const; + bool operator > ( const softdouble& ) const; + bool operator >= ( const softdouble& ) const; + bool operator < ( const softdouble& ) const; + bool operator <= ( const softdouble& ) const; + + /** @brief NaN state indicator */ + inline bool isNaN() const { return (v & 0x7fffffffffffffff) > 0x7ff0000000000000; } + /** @brief Inf state indicator */ + inline bool isInf() const { return (v & 0x7fffffffffffffff) == 0x7ff0000000000000; } + /** @brief Subnormal number indicator */ + inline bool isSubnormal() const { return ((v >> 52) & 0x7FF) == 0; } + + /** @brief Get sign bit */ + inline bool getSign() const { return (v >> 63) != 0; } + /** @brief Construct a copy with new sign bit */ + softdouble setSign(bool sign) const { softdouble x; x.v = (v & ((1ULL << 63) - 1)) | ((uint_fast64_t)(sign) << 63); return x; } + /** @brief Get 0-based exponent */ + inline int getExp() const { return ((v >> 52) & 0x7FF) - 1023; } + /** @brief Construct a copy with new 0-based exponent */ + inline softdouble setExp(int e) const + { + softdouble x; + x.v = (v & 0x800FFFFFFFFFFFFF) | ((uint_fast64_t)((e + 1023) & 0x7FF) << 52); + return x; + } + + /** @brief Get a fraction part + + Returns a number 1 <= x < 2 with the same significand + */ + inline softdouble getFrac() const + { + uint_fast64_t vv = (v & 0x000FFFFFFFFFFFFF) | ((uint_fast64_t)(1023) << 52); + return softdouble::fromRaw(vv); + } + /** @brief Construct a copy with provided significand + + Constructs a copy of a number with significand taken from parameter + */ + inline softdouble setFrac(const softdouble& s) const + { + softdouble x; + x.v = (v & 0xFFF0000000000000) | (s.v & 0x000FFFFFFFFFFFFF); + return x; + } + + /** @brief Zero constant */ + static softdouble zero() { return softdouble::fromRaw( 0 ); } + /** @brief Positive infinity constant */ + static softdouble inf() { return softdouble::fromRaw( (uint_fast64_t)(0x7FF) << 52 ); } + /** @brief Default NaN constant */ + static softdouble nan() { return softdouble::fromRaw( CV_BIG_INT(0x7FFFFFFFFFFFFFFF) ); } + /** @brief One constant */ + static softdouble one() { return softdouble::fromRaw( (uint_fast64_t)( 1023) << 52 ); } + /** @brief Smallest normalized value */ + static softdouble min() { return softdouble::fromRaw( (uint_fast64_t)( 0x01) << 52 ); } + /** @brief Difference between 1 and next representable value */ + static softdouble eps() { return softdouble::fromRaw( (uint_fast64_t)( 1023 - 52 ) << 52 ); } + /** @brief Biggest finite value */ + static softdouble max() { return softdouble::fromRaw( ((uint_fast64_t)(0x7FF) << 52) - 1 ); } + /** @brief Correct pi approximation */ + static softdouble pi() { return softdouble::fromRaw( CV_BIG_INT(0x400921FB54442D18) ); } + + uint64_t v; +}; + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +/** @brief Fused Multiplication and Addition + +Computes (a*b)+c with single rounding +*/ +CV_EXPORTS softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c); +CV_EXPORTS softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c); + +/** @brief Square root */ +CV_EXPORTS softfloat sqrt( const softfloat& a ); +CV_EXPORTS softdouble sqrt( const softdouble& a ); +} + +/*---------------------------------------------------------------------------- +| Ported from OpenCV and added for usability +*----------------------------------------------------------------------------*/ + +/** @brief Truncates number to integer with minimum magnitude */ +CV_EXPORTS int cvTrunc(const cv::softfloat& a); +CV_EXPORTS int cvTrunc(const cv::softdouble& a); + +/** @brief Rounds a number to nearest even integer */ +CV_EXPORTS int cvRound(const cv::softfloat& a); +CV_EXPORTS int cvRound(const cv::softdouble& a); + +/** @brief Rounds a number to nearest even long long integer */ +CV_EXPORTS int64_t cvRound64(const cv::softdouble& a); + +/** @brief Rounds a number down to integer */ +CV_EXPORTS int cvFloor(const cv::softfloat& a); +CV_EXPORTS int cvFloor(const cv::softdouble& a); + +/** @brief Rounds number up to integer */ +CV_EXPORTS int cvCeil(const cv::softfloat& a); +CV_EXPORTS int cvCeil(const cv::softdouble& a); + +namespace cv +{ +/** @brief Saturate casts */ +template static inline _Tp saturate_cast(softfloat a) { return _Tp(a); } +template static inline _Tp saturate_cast(softdouble a) { return _Tp(a); } + +template<> inline uchar saturate_cast(softfloat a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); } +template<> inline uchar saturate_cast(softdouble a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); } + +template<> inline schar saturate_cast(softfloat a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); } +template<> inline schar saturate_cast(softdouble a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); } + +template<> inline ushort saturate_cast(softfloat a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); } +template<> inline ushort saturate_cast(softdouble a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); } + +template<> inline short saturate_cast(softfloat a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); } +template<> inline short saturate_cast(softdouble a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); } + +template<> inline int saturate_cast(softfloat a) { return cvRound(a); } +template<> inline int saturate_cast(softdouble a) { return cvRound(a); } + +template<> inline int64_t saturate_cast(softfloat a) { return cvRound(a); } +template<> inline int64_t saturate_cast(softdouble a) { return cvRound64(a); } + +/** @brief Saturate cast to unsigned integer and unsigned long long integer +We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc. +*/ +template<> inline unsigned saturate_cast(softfloat a) { return cvRound(a); } +template<> inline unsigned saturate_cast(softdouble a) { return cvRound(a); } + +template<> inline uint64_t saturate_cast(softfloat a) { return cvRound(a); } +template<> inline uint64_t saturate_cast(softdouble a) { return cvRound64(a); } + +/** @brief Min and Max functions */ +inline softfloat min(const softfloat& a, const softfloat& b) { return (a > b) ? b : a; } +inline softdouble min(const softdouble& a, const softdouble& b) { return (a > b) ? b : a; } + +inline softfloat max(const softfloat& a, const softfloat& b) { return (a > b) ? a : b; } +inline softdouble max(const softdouble& a, const softdouble& b) { return (a > b) ? a : b; } + +/** @brief Absolute value */ +inline softfloat abs( softfloat a) { softfloat x; x.v = a.v & ((1U << 31) - 1); return x; } +inline softdouble abs( softdouble a) { softdouble x; x.v = a.v & ((1ULL << 63) - 1); return x; } + +/** @brief Exponent + +Special cases: +- exp(NaN) is NaN +- exp(-Inf) == 0 +- exp(+Inf) == +Inf +*/ +CV_EXPORTS softfloat exp( const softfloat& a); +CV_EXPORTS softdouble exp( const softdouble& a); + +/** @brief Natural logarithm + +Special cases: +- log(NaN), log(x < 0) are NaN +- log(0) == -Inf +*/ +CV_EXPORTS softfloat log( const softfloat& a ); +CV_EXPORTS softdouble log( const softdouble& a ); + +/** @brief Raising to the power + +Special cases: +- x**NaN is NaN for any x +- ( |x| == 1 )**Inf is NaN +- ( |x| > 1 )**+Inf or ( |x| < 1 )**-Inf is +Inf +- ( |x| > 1 )**-Inf or ( |x| < 1 )**+Inf is 0 +- x ** 0 == 1 for any x +- x ** 1 == 1 for any x +- NaN ** y is NaN for any other y +- Inf**(y < 0) == 0 +- Inf ** y is +Inf for any other y +- (x < 0)**y is NaN for any other y if x can't be correctly rounded to integer +- 0 ** 0 == 1 +- 0 ** (y < 0) is +Inf +- 0 ** (y > 0) is 0 +*/ +CV_EXPORTS softfloat pow( const softfloat& a, const softfloat& b); +CV_EXPORTS softdouble pow( const softdouble& a, const softdouble& b); + +/** @brief Cube root + +Special cases: +- cbrt(NaN) is NaN +- cbrt(+/-Inf) is +/-Inf +*/ +CV_EXPORTS softfloat cbrt( const softfloat& a ); + +/** @brief Sine + +Special cases: +- sin(Inf) or sin(NaN) is NaN +- sin(x) == x when sin(x) is close to zero +*/ +CV_EXPORTS softdouble sin( const softdouble& a ); + +/** @brief Cosine + * +Special cases: +- cos(Inf) or cos(NaN) is NaN +- cos(x) == +/- 1 when cos(x) is close to +/- 1 +*/ +CV_EXPORTS softdouble cos( const softdouble& a ); + +//! @} core_utils_softfloat + +} // cv:: + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/sse_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/sse_utils.hpp new file mode 100644 index 0000000..0906583 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/sse_utils.hpp @@ -0,0 +1,652 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_SSE_UTILS_HPP +#define OPENCV_CORE_SSE_UTILS_HPP + +#ifndef __cplusplus +# error sse_utils.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/cvdef.h" + +//! @addtogroup core_utils_sse +//! @{ + +#if CV_SSE2 + +inline void _mm_deinterleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi8(v_r0, v_g0); + __m128i layer1_chunk1 = _mm_unpackhi_epi8(v_r0, v_g0); + __m128i layer1_chunk2 = _mm_unpacklo_epi8(v_r1, v_g1); + __m128i layer1_chunk3 = _mm_unpackhi_epi8(v_r1, v_g1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi8(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk1 = _mm_unpackhi_epi8(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk2 = _mm_unpacklo_epi8(layer1_chunk1, layer1_chunk3); + __m128i layer2_chunk3 = _mm_unpackhi_epi8(layer1_chunk1, layer1_chunk3); + + __m128i layer3_chunk0 = _mm_unpacklo_epi8(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk1 = _mm_unpackhi_epi8(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk2 = _mm_unpacklo_epi8(layer2_chunk1, layer2_chunk3); + __m128i layer3_chunk3 = _mm_unpackhi_epi8(layer2_chunk1, layer2_chunk3); + + __m128i layer4_chunk0 = _mm_unpacklo_epi8(layer3_chunk0, layer3_chunk2); + __m128i layer4_chunk1 = _mm_unpackhi_epi8(layer3_chunk0, layer3_chunk2); + __m128i layer4_chunk2 = _mm_unpacklo_epi8(layer3_chunk1, layer3_chunk3); + __m128i layer4_chunk3 = _mm_unpackhi_epi8(layer3_chunk1, layer3_chunk3); + + v_r0 = _mm_unpacklo_epi8(layer4_chunk0, layer4_chunk2); + v_r1 = _mm_unpackhi_epi8(layer4_chunk0, layer4_chunk2); + v_g0 = _mm_unpacklo_epi8(layer4_chunk1, layer4_chunk3); + v_g1 = _mm_unpackhi_epi8(layer4_chunk1, layer4_chunk3); +} + +inline void _mm_deinterleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi8(v_r0, v_g1); + __m128i layer1_chunk1 = _mm_unpackhi_epi8(v_r0, v_g1); + __m128i layer1_chunk2 = _mm_unpacklo_epi8(v_r1, v_b0); + __m128i layer1_chunk3 = _mm_unpackhi_epi8(v_r1, v_b0); + __m128i layer1_chunk4 = _mm_unpacklo_epi8(v_g0, v_b1); + __m128i layer1_chunk5 = _mm_unpackhi_epi8(v_g0, v_b1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi8(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk1 = _mm_unpackhi_epi8(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk2 = _mm_unpacklo_epi8(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk3 = _mm_unpackhi_epi8(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk4 = _mm_unpacklo_epi8(layer1_chunk2, layer1_chunk5); + __m128i layer2_chunk5 = _mm_unpackhi_epi8(layer1_chunk2, layer1_chunk5); + + __m128i layer3_chunk0 = _mm_unpacklo_epi8(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk1 = _mm_unpackhi_epi8(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk2 = _mm_unpacklo_epi8(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk3 = _mm_unpackhi_epi8(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk4 = _mm_unpacklo_epi8(layer2_chunk2, layer2_chunk5); + __m128i layer3_chunk5 = _mm_unpackhi_epi8(layer2_chunk2, layer2_chunk5); + + __m128i layer4_chunk0 = _mm_unpacklo_epi8(layer3_chunk0, layer3_chunk3); + __m128i layer4_chunk1 = _mm_unpackhi_epi8(layer3_chunk0, layer3_chunk3); + __m128i layer4_chunk2 = _mm_unpacklo_epi8(layer3_chunk1, layer3_chunk4); + __m128i layer4_chunk3 = _mm_unpackhi_epi8(layer3_chunk1, layer3_chunk4); + __m128i layer4_chunk4 = _mm_unpacklo_epi8(layer3_chunk2, layer3_chunk5); + __m128i layer4_chunk5 = _mm_unpackhi_epi8(layer3_chunk2, layer3_chunk5); + + v_r0 = _mm_unpacklo_epi8(layer4_chunk0, layer4_chunk3); + v_r1 = _mm_unpackhi_epi8(layer4_chunk0, layer4_chunk3); + v_g0 = _mm_unpacklo_epi8(layer4_chunk1, layer4_chunk4); + v_g1 = _mm_unpackhi_epi8(layer4_chunk1, layer4_chunk4); + v_b0 = _mm_unpacklo_epi8(layer4_chunk2, layer4_chunk5); + v_b1 = _mm_unpackhi_epi8(layer4_chunk2, layer4_chunk5); +} + +inline void _mm_deinterleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi8(v_r0, v_b0); + __m128i layer1_chunk1 = _mm_unpackhi_epi8(v_r0, v_b0); + __m128i layer1_chunk2 = _mm_unpacklo_epi8(v_r1, v_b1); + __m128i layer1_chunk3 = _mm_unpackhi_epi8(v_r1, v_b1); + __m128i layer1_chunk4 = _mm_unpacklo_epi8(v_g0, v_a0); + __m128i layer1_chunk5 = _mm_unpackhi_epi8(v_g0, v_a0); + __m128i layer1_chunk6 = _mm_unpacklo_epi8(v_g1, v_a1); + __m128i layer1_chunk7 = _mm_unpackhi_epi8(v_g1, v_a1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi8(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk1 = _mm_unpackhi_epi8(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk2 = _mm_unpacklo_epi8(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk3 = _mm_unpackhi_epi8(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk4 = _mm_unpacklo_epi8(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk5 = _mm_unpackhi_epi8(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk6 = _mm_unpacklo_epi8(layer1_chunk3, layer1_chunk7); + __m128i layer2_chunk7 = _mm_unpackhi_epi8(layer1_chunk3, layer1_chunk7); + + __m128i layer3_chunk0 = _mm_unpacklo_epi8(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk1 = _mm_unpackhi_epi8(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk2 = _mm_unpacklo_epi8(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk3 = _mm_unpackhi_epi8(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk4 = _mm_unpacklo_epi8(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk5 = _mm_unpackhi_epi8(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk6 = _mm_unpacklo_epi8(layer2_chunk3, layer2_chunk7); + __m128i layer3_chunk7 = _mm_unpackhi_epi8(layer2_chunk3, layer2_chunk7); + + __m128i layer4_chunk0 = _mm_unpacklo_epi8(layer3_chunk0, layer3_chunk4); + __m128i layer4_chunk1 = _mm_unpackhi_epi8(layer3_chunk0, layer3_chunk4); + __m128i layer4_chunk2 = _mm_unpacklo_epi8(layer3_chunk1, layer3_chunk5); + __m128i layer4_chunk3 = _mm_unpackhi_epi8(layer3_chunk1, layer3_chunk5); + __m128i layer4_chunk4 = _mm_unpacklo_epi8(layer3_chunk2, layer3_chunk6); + __m128i layer4_chunk5 = _mm_unpackhi_epi8(layer3_chunk2, layer3_chunk6); + __m128i layer4_chunk6 = _mm_unpacklo_epi8(layer3_chunk3, layer3_chunk7); + __m128i layer4_chunk7 = _mm_unpackhi_epi8(layer3_chunk3, layer3_chunk7); + + v_r0 = _mm_unpacklo_epi8(layer4_chunk0, layer4_chunk4); + v_r1 = _mm_unpackhi_epi8(layer4_chunk0, layer4_chunk4); + v_g0 = _mm_unpacklo_epi8(layer4_chunk1, layer4_chunk5); + v_g1 = _mm_unpackhi_epi8(layer4_chunk1, layer4_chunk5); + v_b0 = _mm_unpacklo_epi8(layer4_chunk2, layer4_chunk6); + v_b1 = _mm_unpackhi_epi8(layer4_chunk2, layer4_chunk6); + v_a0 = _mm_unpacklo_epi8(layer4_chunk3, layer4_chunk7); + v_a1 = _mm_unpackhi_epi8(layer4_chunk3, layer4_chunk7); +} + +inline void _mm_interleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i v_mask = _mm_set1_epi16(0x00ff); + + __m128i layer4_chunk0 = _mm_packus_epi16(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer4_chunk2 = _mm_packus_epi16(_mm_srli_epi16(v_r0, 8), _mm_srli_epi16(v_r1, 8)); + __m128i layer4_chunk1 = _mm_packus_epi16(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer4_chunk3 = _mm_packus_epi16(_mm_srli_epi16(v_g0, 8), _mm_srli_epi16(v_g1, 8)); + + __m128i layer3_chunk0 = _mm_packus_epi16(_mm_and_si128(layer4_chunk0, v_mask), _mm_and_si128(layer4_chunk1, v_mask)); + __m128i layer3_chunk2 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk0, 8), _mm_srli_epi16(layer4_chunk1, 8)); + __m128i layer3_chunk1 = _mm_packus_epi16(_mm_and_si128(layer4_chunk2, v_mask), _mm_and_si128(layer4_chunk3, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk2, 8), _mm_srli_epi16(layer4_chunk3, 8)); + + __m128i layer2_chunk0 = _mm_packus_epi16(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk2 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk0, 8), _mm_srli_epi16(layer3_chunk1, 8)); + __m128i layer2_chunk1 = _mm_packus_epi16(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk2, 8), _mm_srli_epi16(layer3_chunk3, 8)); + + __m128i layer1_chunk0 = _mm_packus_epi16(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk2 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk0, 8), _mm_srli_epi16(layer2_chunk1, 8)); + __m128i layer1_chunk1 = _mm_packus_epi16(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk2, 8), _mm_srli_epi16(layer2_chunk3, 8)); + + v_r0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk0, 8), _mm_srli_epi16(layer1_chunk1, 8)); + v_r1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_g1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk2, 8), _mm_srli_epi16(layer1_chunk3, 8)); +} + +inline void _mm_interleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i v_mask = _mm_set1_epi16(0x00ff); + + __m128i layer4_chunk0 = _mm_packus_epi16(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer4_chunk3 = _mm_packus_epi16(_mm_srli_epi16(v_r0, 8), _mm_srli_epi16(v_r1, 8)); + __m128i layer4_chunk1 = _mm_packus_epi16(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer4_chunk4 = _mm_packus_epi16(_mm_srli_epi16(v_g0, 8), _mm_srli_epi16(v_g1, 8)); + __m128i layer4_chunk2 = _mm_packus_epi16(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer4_chunk5 = _mm_packus_epi16(_mm_srli_epi16(v_b0, 8), _mm_srli_epi16(v_b1, 8)); + + __m128i layer3_chunk0 = _mm_packus_epi16(_mm_and_si128(layer4_chunk0, v_mask), _mm_and_si128(layer4_chunk1, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk0, 8), _mm_srli_epi16(layer4_chunk1, 8)); + __m128i layer3_chunk1 = _mm_packus_epi16(_mm_and_si128(layer4_chunk2, v_mask), _mm_and_si128(layer4_chunk3, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk2, 8), _mm_srli_epi16(layer4_chunk3, 8)); + __m128i layer3_chunk2 = _mm_packus_epi16(_mm_and_si128(layer4_chunk4, v_mask), _mm_and_si128(layer4_chunk5, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk4, 8), _mm_srli_epi16(layer4_chunk5, 8)); + + __m128i layer2_chunk0 = _mm_packus_epi16(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk0, 8), _mm_srli_epi16(layer3_chunk1, 8)); + __m128i layer2_chunk1 = _mm_packus_epi16(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk2, 8), _mm_srli_epi16(layer3_chunk3, 8)); + __m128i layer2_chunk2 = _mm_packus_epi16(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk4, 8), _mm_srli_epi16(layer3_chunk5, 8)); + + __m128i layer1_chunk0 = _mm_packus_epi16(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk0, 8), _mm_srli_epi16(layer2_chunk1, 8)); + __m128i layer1_chunk1 = _mm_packus_epi16(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk2, 8), _mm_srli_epi16(layer2_chunk3, 8)); + __m128i layer1_chunk2 = _mm_packus_epi16(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk4, 8), _mm_srli_epi16(layer2_chunk5, 8)); + + v_r0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk0, 8), _mm_srli_epi16(layer1_chunk1, 8)); + v_r1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk2, 8), _mm_srli_epi16(layer1_chunk3, 8)); + v_g0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_b1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk4, 8), _mm_srli_epi16(layer1_chunk5, 8)); +} + +inline void _mm_interleave_epi8(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i v_mask = _mm_set1_epi16(0x00ff); + + __m128i layer4_chunk0 = _mm_packus_epi16(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer4_chunk4 = _mm_packus_epi16(_mm_srli_epi16(v_r0, 8), _mm_srli_epi16(v_r1, 8)); + __m128i layer4_chunk1 = _mm_packus_epi16(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer4_chunk5 = _mm_packus_epi16(_mm_srli_epi16(v_g0, 8), _mm_srli_epi16(v_g1, 8)); + __m128i layer4_chunk2 = _mm_packus_epi16(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer4_chunk6 = _mm_packus_epi16(_mm_srli_epi16(v_b0, 8), _mm_srli_epi16(v_b1, 8)); + __m128i layer4_chunk3 = _mm_packus_epi16(_mm_and_si128(v_a0, v_mask), _mm_and_si128(v_a1, v_mask)); + __m128i layer4_chunk7 = _mm_packus_epi16(_mm_srli_epi16(v_a0, 8), _mm_srli_epi16(v_a1, 8)); + + __m128i layer3_chunk0 = _mm_packus_epi16(_mm_and_si128(layer4_chunk0, v_mask), _mm_and_si128(layer4_chunk1, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk0, 8), _mm_srli_epi16(layer4_chunk1, 8)); + __m128i layer3_chunk1 = _mm_packus_epi16(_mm_and_si128(layer4_chunk2, v_mask), _mm_and_si128(layer4_chunk3, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk2, 8), _mm_srli_epi16(layer4_chunk3, 8)); + __m128i layer3_chunk2 = _mm_packus_epi16(_mm_and_si128(layer4_chunk4, v_mask), _mm_and_si128(layer4_chunk5, v_mask)); + __m128i layer3_chunk6 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk4, 8), _mm_srli_epi16(layer4_chunk5, 8)); + __m128i layer3_chunk3 = _mm_packus_epi16(_mm_and_si128(layer4_chunk6, v_mask), _mm_and_si128(layer4_chunk7, v_mask)); + __m128i layer3_chunk7 = _mm_packus_epi16(_mm_srli_epi16(layer4_chunk6, 8), _mm_srli_epi16(layer4_chunk7, 8)); + + __m128i layer2_chunk0 = _mm_packus_epi16(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk0, 8), _mm_srli_epi16(layer3_chunk1, 8)); + __m128i layer2_chunk1 = _mm_packus_epi16(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk2, 8), _mm_srli_epi16(layer3_chunk3, 8)); + __m128i layer2_chunk2 = _mm_packus_epi16(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk6 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk4, 8), _mm_srli_epi16(layer3_chunk5, 8)); + __m128i layer2_chunk3 = _mm_packus_epi16(_mm_and_si128(layer3_chunk6, v_mask), _mm_and_si128(layer3_chunk7, v_mask)); + __m128i layer2_chunk7 = _mm_packus_epi16(_mm_srli_epi16(layer3_chunk6, 8), _mm_srli_epi16(layer3_chunk7, 8)); + + __m128i layer1_chunk0 = _mm_packus_epi16(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk0, 8), _mm_srli_epi16(layer2_chunk1, 8)); + __m128i layer1_chunk1 = _mm_packus_epi16(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk2, 8), _mm_srli_epi16(layer2_chunk3, 8)); + __m128i layer1_chunk2 = _mm_packus_epi16(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk6 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk4, 8), _mm_srli_epi16(layer2_chunk5, 8)); + __m128i layer1_chunk3 = _mm_packus_epi16(_mm_and_si128(layer2_chunk6, v_mask), _mm_and_si128(layer2_chunk7, v_mask)); + __m128i layer1_chunk7 = _mm_packus_epi16(_mm_srli_epi16(layer2_chunk6, 8), _mm_srli_epi16(layer2_chunk7, 8)); + + v_r0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_b0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk0, 8), _mm_srli_epi16(layer1_chunk1, 8)); + v_r1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk2, 8), _mm_srli_epi16(layer1_chunk3, 8)); + v_g0 = _mm_packus_epi16(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_a0 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk4, 8), _mm_srli_epi16(layer1_chunk5, 8)); + v_g1 = _mm_packus_epi16(_mm_and_si128(layer1_chunk6, v_mask), _mm_and_si128(layer1_chunk7, v_mask)); + v_a1 = _mm_packus_epi16(_mm_srli_epi16(layer1_chunk6, 8), _mm_srli_epi16(layer1_chunk7, 8)); +} + +inline void _mm_deinterleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi16(v_r0, v_g0); + __m128i layer1_chunk1 = _mm_unpackhi_epi16(v_r0, v_g0); + __m128i layer1_chunk2 = _mm_unpacklo_epi16(v_r1, v_g1); + __m128i layer1_chunk3 = _mm_unpackhi_epi16(v_r1, v_g1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi16(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk1 = _mm_unpackhi_epi16(layer1_chunk0, layer1_chunk2); + __m128i layer2_chunk2 = _mm_unpacklo_epi16(layer1_chunk1, layer1_chunk3); + __m128i layer2_chunk3 = _mm_unpackhi_epi16(layer1_chunk1, layer1_chunk3); + + __m128i layer3_chunk0 = _mm_unpacklo_epi16(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk1 = _mm_unpackhi_epi16(layer2_chunk0, layer2_chunk2); + __m128i layer3_chunk2 = _mm_unpacklo_epi16(layer2_chunk1, layer2_chunk3); + __m128i layer3_chunk3 = _mm_unpackhi_epi16(layer2_chunk1, layer2_chunk3); + + v_r0 = _mm_unpacklo_epi16(layer3_chunk0, layer3_chunk2); + v_r1 = _mm_unpackhi_epi16(layer3_chunk0, layer3_chunk2); + v_g0 = _mm_unpacklo_epi16(layer3_chunk1, layer3_chunk3); + v_g1 = _mm_unpackhi_epi16(layer3_chunk1, layer3_chunk3); +} + +inline void _mm_deinterleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi16(v_r0, v_g1); + __m128i layer1_chunk1 = _mm_unpackhi_epi16(v_r0, v_g1); + __m128i layer1_chunk2 = _mm_unpacklo_epi16(v_r1, v_b0); + __m128i layer1_chunk3 = _mm_unpackhi_epi16(v_r1, v_b0); + __m128i layer1_chunk4 = _mm_unpacklo_epi16(v_g0, v_b1); + __m128i layer1_chunk5 = _mm_unpackhi_epi16(v_g0, v_b1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi16(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk1 = _mm_unpackhi_epi16(layer1_chunk0, layer1_chunk3); + __m128i layer2_chunk2 = _mm_unpacklo_epi16(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk3 = _mm_unpackhi_epi16(layer1_chunk1, layer1_chunk4); + __m128i layer2_chunk4 = _mm_unpacklo_epi16(layer1_chunk2, layer1_chunk5); + __m128i layer2_chunk5 = _mm_unpackhi_epi16(layer1_chunk2, layer1_chunk5); + + __m128i layer3_chunk0 = _mm_unpacklo_epi16(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk1 = _mm_unpackhi_epi16(layer2_chunk0, layer2_chunk3); + __m128i layer3_chunk2 = _mm_unpacklo_epi16(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk3 = _mm_unpackhi_epi16(layer2_chunk1, layer2_chunk4); + __m128i layer3_chunk4 = _mm_unpacklo_epi16(layer2_chunk2, layer2_chunk5); + __m128i layer3_chunk5 = _mm_unpackhi_epi16(layer2_chunk2, layer2_chunk5); + + v_r0 = _mm_unpacklo_epi16(layer3_chunk0, layer3_chunk3); + v_r1 = _mm_unpackhi_epi16(layer3_chunk0, layer3_chunk3); + v_g0 = _mm_unpacklo_epi16(layer3_chunk1, layer3_chunk4); + v_g1 = _mm_unpackhi_epi16(layer3_chunk1, layer3_chunk4); + v_b0 = _mm_unpacklo_epi16(layer3_chunk2, layer3_chunk5); + v_b1 = _mm_unpackhi_epi16(layer3_chunk2, layer3_chunk5); +} + +inline void _mm_deinterleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i layer1_chunk0 = _mm_unpacklo_epi16(v_r0, v_b0); + __m128i layer1_chunk1 = _mm_unpackhi_epi16(v_r0, v_b0); + __m128i layer1_chunk2 = _mm_unpacklo_epi16(v_r1, v_b1); + __m128i layer1_chunk3 = _mm_unpackhi_epi16(v_r1, v_b1); + __m128i layer1_chunk4 = _mm_unpacklo_epi16(v_g0, v_a0); + __m128i layer1_chunk5 = _mm_unpackhi_epi16(v_g0, v_a0); + __m128i layer1_chunk6 = _mm_unpacklo_epi16(v_g1, v_a1); + __m128i layer1_chunk7 = _mm_unpackhi_epi16(v_g1, v_a1); + + __m128i layer2_chunk0 = _mm_unpacklo_epi16(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk1 = _mm_unpackhi_epi16(layer1_chunk0, layer1_chunk4); + __m128i layer2_chunk2 = _mm_unpacklo_epi16(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk3 = _mm_unpackhi_epi16(layer1_chunk1, layer1_chunk5); + __m128i layer2_chunk4 = _mm_unpacklo_epi16(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk5 = _mm_unpackhi_epi16(layer1_chunk2, layer1_chunk6); + __m128i layer2_chunk6 = _mm_unpacklo_epi16(layer1_chunk3, layer1_chunk7); + __m128i layer2_chunk7 = _mm_unpackhi_epi16(layer1_chunk3, layer1_chunk7); + + __m128i layer3_chunk0 = _mm_unpacklo_epi16(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk1 = _mm_unpackhi_epi16(layer2_chunk0, layer2_chunk4); + __m128i layer3_chunk2 = _mm_unpacklo_epi16(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk3 = _mm_unpackhi_epi16(layer2_chunk1, layer2_chunk5); + __m128i layer3_chunk4 = _mm_unpacklo_epi16(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk5 = _mm_unpackhi_epi16(layer2_chunk2, layer2_chunk6); + __m128i layer3_chunk6 = _mm_unpacklo_epi16(layer2_chunk3, layer2_chunk7); + __m128i layer3_chunk7 = _mm_unpackhi_epi16(layer2_chunk3, layer2_chunk7); + + v_r0 = _mm_unpacklo_epi16(layer3_chunk0, layer3_chunk4); + v_r1 = _mm_unpackhi_epi16(layer3_chunk0, layer3_chunk4); + v_g0 = _mm_unpacklo_epi16(layer3_chunk1, layer3_chunk5); + v_g1 = _mm_unpackhi_epi16(layer3_chunk1, layer3_chunk5); + v_b0 = _mm_unpacklo_epi16(layer3_chunk2, layer3_chunk6); + v_b1 = _mm_unpackhi_epi16(layer3_chunk2, layer3_chunk6); + v_a0 = _mm_unpacklo_epi16(layer3_chunk3, layer3_chunk7); + v_a1 = _mm_unpackhi_epi16(layer3_chunk3, layer3_chunk7); +} + +#if CV_SSE4_1 + +inline void _mm_interleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1) +{ + __m128i v_mask = _mm_set1_epi32(0x0000ffff); + + __m128i layer3_chunk0 = _mm_packus_epi32(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer3_chunk2 = _mm_packus_epi32(_mm_srli_epi32(v_r0, 16), _mm_srli_epi32(v_r1, 16)); + __m128i layer3_chunk1 = _mm_packus_epi32(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi32(_mm_srli_epi32(v_g0, 16), _mm_srli_epi32(v_g1, 16)); + + __m128i layer2_chunk0 = _mm_packus_epi32(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk2 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk0, 16), _mm_srli_epi32(layer3_chunk1, 16)); + __m128i layer2_chunk1 = _mm_packus_epi32(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk2, 16), _mm_srli_epi32(layer3_chunk3, 16)); + + __m128i layer1_chunk0 = _mm_packus_epi32(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk2 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk0, 16), _mm_srli_epi32(layer2_chunk1, 16)); + __m128i layer1_chunk1 = _mm_packus_epi32(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk2, 16), _mm_srli_epi32(layer2_chunk3, 16)); + + v_r0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk0, 16), _mm_srli_epi32(layer1_chunk1, 16)); + v_r1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_g1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk2, 16), _mm_srli_epi32(layer1_chunk3, 16)); +} + +inline void _mm_interleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, + __m128i & v_g1, __m128i & v_b0, __m128i & v_b1) +{ + __m128i v_mask = _mm_set1_epi32(0x0000ffff); + + __m128i layer3_chunk0 = _mm_packus_epi32(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer3_chunk3 = _mm_packus_epi32(_mm_srli_epi32(v_r0, 16), _mm_srli_epi32(v_r1, 16)); + __m128i layer3_chunk1 = _mm_packus_epi32(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi32(_mm_srli_epi32(v_g0, 16), _mm_srli_epi32(v_g1, 16)); + __m128i layer3_chunk2 = _mm_packus_epi32(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi32(_mm_srli_epi32(v_b0, 16), _mm_srli_epi32(v_b1, 16)); + + __m128i layer2_chunk0 = _mm_packus_epi32(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk0, 16), _mm_srli_epi32(layer3_chunk1, 16)); + __m128i layer2_chunk1 = _mm_packus_epi32(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk2, 16), _mm_srli_epi32(layer3_chunk3, 16)); + __m128i layer2_chunk2 = _mm_packus_epi32(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk4, 16), _mm_srli_epi32(layer3_chunk5, 16)); + + __m128i layer1_chunk0 = _mm_packus_epi32(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk3 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk0, 16), _mm_srli_epi32(layer2_chunk1, 16)); + __m128i layer1_chunk1 = _mm_packus_epi32(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk2, 16), _mm_srli_epi32(layer2_chunk3, 16)); + __m128i layer1_chunk2 = _mm_packus_epi32(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk4, 16), _mm_srli_epi32(layer2_chunk5, 16)); + + v_r0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_g1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk0, 16), _mm_srli_epi32(layer1_chunk1, 16)); + v_r1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk2, 16), _mm_srli_epi32(layer1_chunk3, 16)); + v_g0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_b1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk4, 16), _mm_srli_epi32(layer1_chunk5, 16)); +} + +inline void _mm_interleave_epi16(__m128i & v_r0, __m128i & v_r1, __m128i & v_g0, __m128i & v_g1, + __m128i & v_b0, __m128i & v_b1, __m128i & v_a0, __m128i & v_a1) +{ + __m128i v_mask = _mm_set1_epi32(0x0000ffff); + + __m128i layer3_chunk0 = _mm_packus_epi32(_mm_and_si128(v_r0, v_mask), _mm_and_si128(v_r1, v_mask)); + __m128i layer3_chunk4 = _mm_packus_epi32(_mm_srli_epi32(v_r0, 16), _mm_srli_epi32(v_r1, 16)); + __m128i layer3_chunk1 = _mm_packus_epi32(_mm_and_si128(v_g0, v_mask), _mm_and_si128(v_g1, v_mask)); + __m128i layer3_chunk5 = _mm_packus_epi32(_mm_srli_epi32(v_g0, 16), _mm_srli_epi32(v_g1, 16)); + __m128i layer3_chunk2 = _mm_packus_epi32(_mm_and_si128(v_b0, v_mask), _mm_and_si128(v_b1, v_mask)); + __m128i layer3_chunk6 = _mm_packus_epi32(_mm_srli_epi32(v_b0, 16), _mm_srli_epi32(v_b1, 16)); + __m128i layer3_chunk3 = _mm_packus_epi32(_mm_and_si128(v_a0, v_mask), _mm_and_si128(v_a1, v_mask)); + __m128i layer3_chunk7 = _mm_packus_epi32(_mm_srli_epi32(v_a0, 16), _mm_srli_epi32(v_a1, 16)); + + __m128i layer2_chunk0 = _mm_packus_epi32(_mm_and_si128(layer3_chunk0, v_mask), _mm_and_si128(layer3_chunk1, v_mask)); + __m128i layer2_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk0, 16), _mm_srli_epi32(layer3_chunk1, 16)); + __m128i layer2_chunk1 = _mm_packus_epi32(_mm_and_si128(layer3_chunk2, v_mask), _mm_and_si128(layer3_chunk3, v_mask)); + __m128i layer2_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk2, 16), _mm_srli_epi32(layer3_chunk3, 16)); + __m128i layer2_chunk2 = _mm_packus_epi32(_mm_and_si128(layer3_chunk4, v_mask), _mm_and_si128(layer3_chunk5, v_mask)); + __m128i layer2_chunk6 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk4, 16), _mm_srli_epi32(layer3_chunk5, 16)); + __m128i layer2_chunk3 = _mm_packus_epi32(_mm_and_si128(layer3_chunk6, v_mask), _mm_and_si128(layer3_chunk7, v_mask)); + __m128i layer2_chunk7 = _mm_packus_epi32(_mm_srli_epi32(layer3_chunk6, 16), _mm_srli_epi32(layer3_chunk7, 16)); + + __m128i layer1_chunk0 = _mm_packus_epi32(_mm_and_si128(layer2_chunk0, v_mask), _mm_and_si128(layer2_chunk1, v_mask)); + __m128i layer1_chunk4 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk0, 16), _mm_srli_epi32(layer2_chunk1, 16)); + __m128i layer1_chunk1 = _mm_packus_epi32(_mm_and_si128(layer2_chunk2, v_mask), _mm_and_si128(layer2_chunk3, v_mask)); + __m128i layer1_chunk5 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk2, 16), _mm_srli_epi32(layer2_chunk3, 16)); + __m128i layer1_chunk2 = _mm_packus_epi32(_mm_and_si128(layer2_chunk4, v_mask), _mm_and_si128(layer2_chunk5, v_mask)); + __m128i layer1_chunk6 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk4, 16), _mm_srli_epi32(layer2_chunk5, 16)); + __m128i layer1_chunk3 = _mm_packus_epi32(_mm_and_si128(layer2_chunk6, v_mask), _mm_and_si128(layer2_chunk7, v_mask)); + __m128i layer1_chunk7 = _mm_packus_epi32(_mm_srli_epi32(layer2_chunk6, 16), _mm_srli_epi32(layer2_chunk7, 16)); + + v_r0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk0, v_mask), _mm_and_si128(layer1_chunk1, v_mask)); + v_b0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk0, 16), _mm_srli_epi32(layer1_chunk1, 16)); + v_r1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk2, v_mask), _mm_and_si128(layer1_chunk3, v_mask)); + v_b1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk2, 16), _mm_srli_epi32(layer1_chunk3, 16)); + v_g0 = _mm_packus_epi32(_mm_and_si128(layer1_chunk4, v_mask), _mm_and_si128(layer1_chunk5, v_mask)); + v_a0 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk4, 16), _mm_srli_epi32(layer1_chunk5, 16)); + v_g1 = _mm_packus_epi32(_mm_and_si128(layer1_chunk6, v_mask), _mm_and_si128(layer1_chunk7, v_mask)); + v_a1 = _mm_packus_epi32(_mm_srli_epi32(layer1_chunk6, 16), _mm_srli_epi32(layer1_chunk7, 16)); +} + +#endif // CV_SSE4_1 + +inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1) +{ + __m128 layer1_chunk0 = _mm_unpacklo_ps(v_r0, v_g0); + __m128 layer1_chunk1 = _mm_unpackhi_ps(v_r0, v_g0); + __m128 layer1_chunk2 = _mm_unpacklo_ps(v_r1, v_g1); + __m128 layer1_chunk3 = _mm_unpackhi_ps(v_r1, v_g1); + + __m128 layer2_chunk0 = _mm_unpacklo_ps(layer1_chunk0, layer1_chunk2); + __m128 layer2_chunk1 = _mm_unpackhi_ps(layer1_chunk0, layer1_chunk2); + __m128 layer2_chunk2 = _mm_unpacklo_ps(layer1_chunk1, layer1_chunk3); + __m128 layer2_chunk3 = _mm_unpackhi_ps(layer1_chunk1, layer1_chunk3); + + v_r0 = _mm_unpacklo_ps(layer2_chunk0, layer2_chunk2); + v_r1 = _mm_unpackhi_ps(layer2_chunk0, layer2_chunk2); + v_g0 = _mm_unpacklo_ps(layer2_chunk1, layer2_chunk3); + v_g1 = _mm_unpackhi_ps(layer2_chunk1, layer2_chunk3); +} + +inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, + __m128 & v_g1, __m128 & v_b0, __m128 & v_b1) +{ + __m128 layer1_chunk0 = _mm_unpacklo_ps(v_r0, v_g1); + __m128 layer1_chunk1 = _mm_unpackhi_ps(v_r0, v_g1); + __m128 layer1_chunk2 = _mm_unpacklo_ps(v_r1, v_b0); + __m128 layer1_chunk3 = _mm_unpackhi_ps(v_r1, v_b0); + __m128 layer1_chunk4 = _mm_unpacklo_ps(v_g0, v_b1); + __m128 layer1_chunk5 = _mm_unpackhi_ps(v_g0, v_b1); + + __m128 layer2_chunk0 = _mm_unpacklo_ps(layer1_chunk0, layer1_chunk3); + __m128 layer2_chunk1 = _mm_unpackhi_ps(layer1_chunk0, layer1_chunk3); + __m128 layer2_chunk2 = _mm_unpacklo_ps(layer1_chunk1, layer1_chunk4); + __m128 layer2_chunk3 = _mm_unpackhi_ps(layer1_chunk1, layer1_chunk4); + __m128 layer2_chunk4 = _mm_unpacklo_ps(layer1_chunk2, layer1_chunk5); + __m128 layer2_chunk5 = _mm_unpackhi_ps(layer1_chunk2, layer1_chunk5); + + v_r0 = _mm_unpacklo_ps(layer2_chunk0, layer2_chunk3); + v_r1 = _mm_unpackhi_ps(layer2_chunk0, layer2_chunk3); + v_g0 = _mm_unpacklo_ps(layer2_chunk1, layer2_chunk4); + v_g1 = _mm_unpackhi_ps(layer2_chunk1, layer2_chunk4); + v_b0 = _mm_unpacklo_ps(layer2_chunk2, layer2_chunk5); + v_b1 = _mm_unpackhi_ps(layer2_chunk2, layer2_chunk5); +} + +inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1, + __m128 & v_b0, __m128 & v_b1, __m128 & v_a0, __m128 & v_a1) +{ + __m128 layer1_chunk0 = _mm_unpacklo_ps(v_r0, v_b0); + __m128 layer1_chunk1 = _mm_unpackhi_ps(v_r0, v_b0); + __m128 layer1_chunk2 = _mm_unpacklo_ps(v_r1, v_b1); + __m128 layer1_chunk3 = _mm_unpackhi_ps(v_r1, v_b1); + __m128 layer1_chunk4 = _mm_unpacklo_ps(v_g0, v_a0); + __m128 layer1_chunk5 = _mm_unpackhi_ps(v_g0, v_a0); + __m128 layer1_chunk6 = _mm_unpacklo_ps(v_g1, v_a1); + __m128 layer1_chunk7 = _mm_unpackhi_ps(v_g1, v_a1); + + __m128 layer2_chunk0 = _mm_unpacklo_ps(layer1_chunk0, layer1_chunk4); + __m128 layer2_chunk1 = _mm_unpackhi_ps(layer1_chunk0, layer1_chunk4); + __m128 layer2_chunk2 = _mm_unpacklo_ps(layer1_chunk1, layer1_chunk5); + __m128 layer2_chunk3 = _mm_unpackhi_ps(layer1_chunk1, layer1_chunk5); + __m128 layer2_chunk4 = _mm_unpacklo_ps(layer1_chunk2, layer1_chunk6); + __m128 layer2_chunk5 = _mm_unpackhi_ps(layer1_chunk2, layer1_chunk6); + __m128 layer2_chunk6 = _mm_unpacklo_ps(layer1_chunk3, layer1_chunk7); + __m128 layer2_chunk7 = _mm_unpackhi_ps(layer1_chunk3, layer1_chunk7); + + v_r0 = _mm_unpacklo_ps(layer2_chunk0, layer2_chunk4); + v_r1 = _mm_unpackhi_ps(layer2_chunk0, layer2_chunk4); + v_g0 = _mm_unpacklo_ps(layer2_chunk1, layer2_chunk5); + v_g1 = _mm_unpackhi_ps(layer2_chunk1, layer2_chunk5); + v_b0 = _mm_unpacklo_ps(layer2_chunk2, layer2_chunk6); + v_b1 = _mm_unpackhi_ps(layer2_chunk2, layer2_chunk6); + v_a0 = _mm_unpacklo_ps(layer2_chunk3, layer2_chunk7); + v_a1 = _mm_unpackhi_ps(layer2_chunk3, layer2_chunk7); +} + +inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1) +{ + enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) }; + + __m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo); + __m128 layer2_chunk2 = _mm_shuffle_ps(v_r0, v_r1, mask_hi); + __m128 layer2_chunk1 = _mm_shuffle_ps(v_g0, v_g1, mask_lo); + __m128 layer2_chunk3 = _mm_shuffle_ps(v_g0, v_g1, mask_hi); + + __m128 layer1_chunk0 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_lo); + __m128 layer1_chunk2 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_hi); + __m128 layer1_chunk1 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_lo); + __m128 layer1_chunk3 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_hi); + + v_r0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_lo); + v_g0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_hi); + v_r1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_lo); + v_g1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_hi); +} + +inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, + __m128 & v_g1, __m128 & v_b0, __m128 & v_b1) +{ + enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) }; + + __m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo); + __m128 layer2_chunk3 = _mm_shuffle_ps(v_r0, v_r1, mask_hi); + __m128 layer2_chunk1 = _mm_shuffle_ps(v_g0, v_g1, mask_lo); + __m128 layer2_chunk4 = _mm_shuffle_ps(v_g0, v_g1, mask_hi); + __m128 layer2_chunk2 = _mm_shuffle_ps(v_b0, v_b1, mask_lo); + __m128 layer2_chunk5 = _mm_shuffle_ps(v_b0, v_b1, mask_hi); + + __m128 layer1_chunk0 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_lo); + __m128 layer1_chunk3 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_hi); + __m128 layer1_chunk1 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_lo); + __m128 layer1_chunk4 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_hi); + __m128 layer1_chunk2 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_lo); + __m128 layer1_chunk5 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_hi); + + v_r0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_lo); + v_g1 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_hi); + v_r1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_lo); + v_b0 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_hi); + v_g0 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_lo); + v_b1 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_hi); +} + +inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1, + __m128 & v_b0, __m128 & v_b1, __m128 & v_a0, __m128 & v_a1) +{ + enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) }; + + __m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo); + __m128 layer2_chunk4 = _mm_shuffle_ps(v_r0, v_r1, mask_hi); + __m128 layer2_chunk1 = _mm_shuffle_ps(v_g0, v_g1, mask_lo); + __m128 layer2_chunk5 = _mm_shuffle_ps(v_g0, v_g1, mask_hi); + __m128 layer2_chunk2 = _mm_shuffle_ps(v_b0, v_b1, mask_lo); + __m128 layer2_chunk6 = _mm_shuffle_ps(v_b0, v_b1, mask_hi); + __m128 layer2_chunk3 = _mm_shuffle_ps(v_a0, v_a1, mask_lo); + __m128 layer2_chunk7 = _mm_shuffle_ps(v_a0, v_a1, mask_hi); + + __m128 layer1_chunk0 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_lo); + __m128 layer1_chunk4 = _mm_shuffle_ps(layer2_chunk0, layer2_chunk1, mask_hi); + __m128 layer1_chunk1 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_lo); + __m128 layer1_chunk5 = _mm_shuffle_ps(layer2_chunk2, layer2_chunk3, mask_hi); + __m128 layer1_chunk2 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_lo); + __m128 layer1_chunk6 = _mm_shuffle_ps(layer2_chunk4, layer2_chunk5, mask_hi); + __m128 layer1_chunk3 = _mm_shuffle_ps(layer2_chunk6, layer2_chunk7, mask_lo); + __m128 layer1_chunk7 = _mm_shuffle_ps(layer2_chunk6, layer2_chunk7, mask_hi); + + v_r0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_lo); + v_b0 = _mm_shuffle_ps(layer1_chunk0, layer1_chunk1, mask_hi); + v_r1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_lo); + v_b1 = _mm_shuffle_ps(layer1_chunk2, layer1_chunk3, mask_hi); + v_g0 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_lo); + v_a0 = _mm_shuffle_ps(layer1_chunk4, layer1_chunk5, mask_hi); + v_g1 = _mm_shuffle_ps(layer1_chunk6, layer1_chunk7, mask_lo); + v_a1 = _mm_shuffle_ps(layer1_chunk6, layer1_chunk7, mask_hi); +} + +#endif // CV_SSE2 + +//! @} + +#endif //OPENCV_CORE_SSE_UTILS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/traits.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/traits.hpp new file mode 100644 index 0000000..52ab083 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/traits.hpp @@ -0,0 +1,417 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_TRAITS_HPP +#define OPENCV_CORE_TRAITS_HPP + +#include "opencv2/core/cvdef.h" + +namespace cv +{ + +//#define OPENCV_TRAITS_ENABLE_DEPRECATED + +//! @addtogroup core_basic +//! @{ + +/** @brief Template "trait" class for OpenCV primitive data types. + +@note Deprecated. This is replaced by "single purpose" traits: traits::Type and traits::Depth + +A primitive OpenCV data type is one of unsigned char, bool, signed char, unsigned short, signed +short, int, float, double, or a tuple of values of one of these types, where all the values in the +tuple have the same type. Any primitive type from the list can be defined by an identifier in the +form CV_\{U|S|F}C(\), for example: uchar \~ CV_8UC1, 3-element +floating-point tuple \~ CV_32FC3, and so on. A universal OpenCV structure that is able to store a +single instance of such a primitive data type is Vec. Multiple instances of such a type can be +stored in a std::vector, Mat, Mat_, SparseMat, SparseMat_, or any other container that is able to +store Vec instances. + +The DataType class is basically used to provide a description of such primitive data types without +adding any fields or methods to the corresponding classes (and it is actually impossible to add +anything to primitive C/C++ data types). This technique is known in C++ as class traits. It is not +DataType itself that is used but its specialized versions, such as: +@code + template<> class DataType + { + typedef uchar value_type; + typedef int work_type; + typedef uchar channel_type; + enum { channel_type = CV_8U, channels = 1, fmt='u', type = CV_8U }; + }; + ... + template DataType > + { + typedef std::complex<_Tp> value_type; + typedef std::complex<_Tp> work_type; + typedef _Tp channel_type; + // DataDepth is another helper trait class + enum { depth = DataDepth<_Tp>::value, channels=2, + fmt=(channels-1)*256+DataDepth<_Tp>::fmt, + type=CV_MAKETYPE(depth, channels) }; + }; + ... +@endcode +The main purpose of this class is to convert compilation-time type information to an +OpenCV-compatible data type identifier, for example: +@code + // allocates a 30x40 floating-point matrix + Mat A(30, 40, DataType::type); + + Mat B = Mat_ >(3, 3); + // the statement below will print 6, 2 , that is depth == CV_64F, channels == 2 + cout << B.depth() << ", " << B.channels() << endl; +@endcode +So, such traits are used to tell OpenCV which data type you are working with, even if such a type is +not native to OpenCV. For example, the matrix B initialization above is compiled because OpenCV +defines the proper specialized template class DataType\ \> . This mechanism is also +useful (and used in OpenCV this way) for generic algorithms implementations. + +@note Default values were dropped to stop confusing developers about using of unsupported types (see #7599) +*/ +template class DataType +{ +public: +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + typedef _Tp value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 1, + depth = -1, + channels = 1, + fmt = 0, + type = CV_MAKETYPE(depth, channels) + }; +#endif +}; + +template<> class DataType +{ +public: + typedef bool value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8U, + channels = 1, + fmt = (int)'u', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef uchar value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8U, + channels = 1, + fmt = (int)'u', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef schar value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8S, + channels = 1, + fmt = (int)'c', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef schar value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_8S, + channels = 1, + fmt = (int)'c', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef ushort value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_16U, + channels = 1, + fmt = (int)'w', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef short value_type; + typedef int work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_16S, + channels = 1, + fmt = (int)'s', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef int value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_32S, + channels = 1, + fmt = (int)'i', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef float value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_32F, + channels = 1, + fmt = (int)'f', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef double value_type; + typedef value_type work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_64F, + channels = 1, + fmt = (int)'d', + type = CV_MAKETYPE(depth, channels) + }; +}; + +template<> class DataType +{ +public: + typedef float16_t value_type; + typedef float work_type; + typedef value_type channel_type; + typedef value_type vec_type; + enum { generic_type = 0, + depth = CV_16F, + channels = 1, + fmt = (int)'h', + type = CV_MAKETYPE(depth, channels) + }; +}; + +/** @brief A helper class for cv::DataType + +The class is specialized for each fundamental numerical data type supported by OpenCV. It provides +DataDepth::value constant. +*/ +template class DataDepth +{ +public: + enum + { + value = DataType<_Tp>::depth, + fmt = DataType<_Tp>::fmt + }; +}; + + +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + +template class TypeDepth +{ +#ifdef OPENCV_TRAITS_ENABLE_LEGACY_DEFAULTS + enum { depth = CV_USRTYPE1 }; + typedef void value_type; +#endif +}; + +template<> class TypeDepth +{ + enum { depth = CV_8U }; + typedef uchar value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_8S }; + typedef schar value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_16U }; + typedef ushort value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_16S }; + typedef short value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_32S }; + typedef int value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_32F }; + typedef float value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_64F }; + typedef double value_type; +}; + +template<> class TypeDepth +{ + enum { depth = CV_16F }; + typedef float16_t value_type; +}; + +#endif + +//! @} + +namespace traits { + +namespace internal { +#define CV_CREATE_MEMBER_CHECK(X) \ +template class CheckMember_##X { \ + struct Fallback { int X; }; \ + struct Derived : T, Fallback { }; \ + template struct Check; \ + typedef char CV_NO[1]; \ + typedef char CV_YES[2]; \ + template static CV_NO & func(Check *); \ + template static CV_YES & func(...); \ +public: \ + typedef CheckMember_##X type; \ + enum { value = sizeof(func(0)) == sizeof(CV_YES) }; \ +}; + +CV_CREATE_MEMBER_CHECK(fmt) +CV_CREATE_MEMBER_CHECK(type) + +} // namespace internal + + +template +struct Depth +{ enum { value = DataType::depth }; }; + +template +struct Type +{ enum { value = DataType::type }; }; + +/** Similar to traits::Type but has value = -1 in case of unknown type (instead of compiler error) */ +template >::value > +struct SafeType {}; + +template +struct SafeType +{ enum { value = -1 }; }; + +template +struct SafeType +{ enum { value = Type::value }; }; + + +template >::value > +struct SafeFmt {}; + +template +struct SafeFmt +{ enum { fmt = 0 }; }; + +template +struct SafeFmt +{ enum { fmt = DataType::fmt }; }; + + +} // namespace + +} // cv + +#endif // OPENCV_CORE_TRAITS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/types.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/types.hpp new file mode 100644 index 0000000..2867520 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/types.hpp @@ -0,0 +1,2439 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_TYPES_HPP +#define OPENCV_CORE_TYPES_HPP + +#ifndef __cplusplus +# error types.hpp header must be compiled as C++ +#endif + +#include +#include +#include +#include + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/matx.hpp" + +namespace cv +{ + +//! @addtogroup core_basic +//! @{ + +//////////////////////////////// Complex ////////////////////////////// + +/** @brief A complex number class. + + The template class is similar and compatible with std::complex, however it provides slightly + more convenient access to the real and imaginary parts using through the simple field access, as opposite + to std::complex::real() and std::complex::imag(). +*/ +template class Complex +{ +public: + + //! default constructor + Complex(); + Complex( _Tp _re, _Tp _im = 0 ); + + //! conversion to another data type + template operator Complex() const; + //! conjugation + Complex conj() const; + + _Tp re, im; //< the real and the imaginary parts +}; + +typedef Complex Complexf; +typedef Complex Complexd; + +template class DataType< Complex<_Tp> > +{ +public: + typedef Complex<_Tp> value_type; + typedef value_type work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = DataType::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Complex<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Complex<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +} // namespace + + +//////////////////////////////// Point_ //////////////////////////////// + +/** @brief Template class for 2D points specified by its coordinates `x` and `y`. + +An instance of the class is interchangeable with C structures, CvPoint and CvPoint2D32f . There is +also a cast operator to convert point coordinates to the specified type. The conversion from +floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion +uses this operation for each of the coordinates. Besides the class members listed in the +declaration above, the following operations on points are implemented: +@code + pt1 = pt2 + pt3; + pt1 = pt2 - pt3; + pt1 = pt2 * a; + pt1 = a * pt2; + pt1 = pt2 / a; + pt1 += pt2; + pt1 -= pt2; + pt1 *= a; + pt1 /= a; + double value = norm(pt); // L2 norm + pt1 == pt2; + pt1 != pt2; +@endcode +For your convenience, the following type aliases are defined: +@code + typedef Point_ Point2i; + typedef Point2i Point; + typedef Point_ Point2f; + typedef Point_ Point2d; +@endcode +Example: +@code + Point2f a(0.3f, 0.f), b(0.f, 0.4f); + Point pt = (a + b)*10.f; + cout << pt.x << ", " << pt.y << endl; +@endcode +*/ +template class Point_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Point_(); + Point_(_Tp _x, _Tp _y); +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 + Point_(const Point_& pt); + Point_(Point_&& pt) CV_NOEXCEPT = default; +#elif OPENCV_ABI_COMPATIBILITY < 500 + Point_(const Point_& pt) = default; + Point_(Point_&& pt) CV_NOEXCEPT = default; +#endif + Point_(const Size_<_Tp>& sz); + Point_(const Vec<_Tp, 2>& v); + +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 + Point_& operator = (const Point_& pt); + Point_& operator = (Point_&& pt) CV_NOEXCEPT = default; +#elif OPENCV_ABI_COMPATIBILITY < 500 + Point_& operator = (const Point_& pt) = default; + Point_& operator = (Point_&& pt) CV_NOEXCEPT = default; +#endif + //! conversion to another data type + template operator Point_<_Tp2>() const; + + //! conversion to the old-style C structures + operator Vec<_Tp, 2>() const; + + //! dot product + _Tp dot(const Point_& pt) const; + //! dot product computed in double-precision arithmetics + double ddot(const Point_& pt) const; + //! cross-product + double cross(const Point_& pt) const; + //! checks whether the point is inside the specified rectangle + bool inside(const Rect_<_Tp>& r) const; + _Tp x; //!< x coordinate of the point + _Tp y; //!< y coordinate of the point +}; + +typedef Point_ Point2i; +typedef Point_ Point2l; +typedef Point_ Point2f; +typedef Point_ Point2d; +typedef Point2i Point; + +template class DataType< Point_<_Tp> > +{ +public: + typedef Point_<_Tp> value_type; + typedef Point_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Point_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Point_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +} // namespace + + +//////////////////////////////// Point3_ //////////////////////////////// + +/** @brief Template class for 3D points specified by its coordinates `x`, `y` and `z`. + +An instance of the class is interchangeable with the C structure CvPoint2D32f . Similarly to +Point_ , the coordinates of 3D points can be converted to another type. The vector arithmetic and +comparison operations are also supported. + +The following Point3_\<\> aliases are available: +@code + typedef Point3_ Point3i; + typedef Point3_ Point3f; + typedef Point3_ Point3d; +@endcode +@see cv::Point3i, cv::Point3f and cv::Point3d +*/ +template class Point3_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Point3_(); + Point3_(_Tp _x, _Tp _y, _Tp _z); +#if OPENCV_ABI_COMPATIBILITY < 500 + Point3_(const Point3_& pt) = default; + Point3_(Point3_&& pt) CV_NOEXCEPT = default; +#endif + explicit Point3_(const Point_<_Tp>& pt); + Point3_(const Vec<_Tp, 3>& v); + +#if OPENCV_ABI_COMPATIBILITY < 500 + Point3_& operator = (const Point3_& pt) = default; + Point3_& operator = (Point3_&& pt) CV_NOEXCEPT = default; +#endif + //! conversion to another data type + template operator Point3_<_Tp2>() const; + //! conversion to cv::Vec<> + operator Vec<_Tp, 3>() const; + + //! dot product + _Tp dot(const Point3_& pt) const; + //! dot product computed in double-precision arithmetics + double ddot(const Point3_& pt) const; + //! cross product of the 2 3D points + Point3_ cross(const Point3_& pt) const; + _Tp x; //!< x coordinate of the 3D point + _Tp y; //!< y coordinate of the 3D point + _Tp z; //!< z coordinate of the 3D point +}; + +typedef Point3_ Point3i; +typedef Point3_ Point3f; +typedef Point3_ Point3d; + +template class DataType< Point3_<_Tp> > +{ +public: + typedef Point3_<_Tp> value_type; + typedef Point3_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 3, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Point3_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Point3_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) }; }; +} // namespace + +//////////////////////////////// Size_ //////////////////////////////// + +/** @brief Template class for specifying the size of an image or rectangle. + +The class includes two members called width and height. The structure can be converted to and from +the old OpenCV structures CvSize and CvSize2D32f . The same set of arithmetic and comparison +operations as for Point_ is available. + +OpenCV defines the following Size_\<\> aliases: +@code + typedef Size_ Size2i; + typedef Size2i Size; + typedef Size_ Size2f; +@endcode +*/ +template class Size_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Size_(); + Size_(_Tp _width, _Tp _height); +#if OPENCV_ABI_COMPATIBILITY < 500 + Size_(const Size_& sz) = default; + Size_(Size_&& sz) CV_NOEXCEPT = default; +#endif + Size_(const Point_<_Tp>& pt); + +#if OPENCV_ABI_COMPATIBILITY < 500 + Size_& operator = (const Size_& sz) = default; + Size_& operator = (Size_&& sz) CV_NOEXCEPT = default; +#endif + //! the area (width*height) + _Tp area() const; + //! aspect ratio (width/height) + double aspectRatio() const; + //! true if empty + bool empty() const; + + //! conversion of another data type. + template operator Size_<_Tp2>() const; + + _Tp width; //!< the width + _Tp height; //!< the height +}; + +typedef Size_ Size2i; +typedef Size_ Size2l; +typedef Size_ Size2f; +typedef Size_ Size2d; +typedef Size2i Size; + +template class DataType< Size_<_Tp> > +{ +public: + typedef Size_<_Tp> value_type; + typedef Size_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = DataType::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Size_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Size_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) }; }; +} // namespace + +//////////////////////////////// Rect_ //////////////////////////////// + +/** @brief Template class for 2D rectangles + +described by the following parameters: +- Coordinates of the top-left corner. This is a default interpretation of Rect_::x and Rect_::y + in OpenCV. Though, in your algorithms you may count x and y from the bottom-left corner. +- Rectangle width and height. + +OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the +right and bottom boundaries are not. For example, the method Rect_::contains returns true if + +\f[x \leq pt.x < x+width, + y \leq pt.y < y+height\f] + +Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect_\ ) is +implemented as: +@code + for(int y = roi.y; y < roi.y + roi.height; y++) + for(int x = roi.x; x < roi.x + roi.width; x++) + { + // ... + } +@endcode +In addition to the class members, the following operations on rectangles are implemented: +- \f$\texttt{rect} = \texttt{rect} \pm \texttt{point}\f$ (shifting a rectangle by a certain offset) +- \f$\texttt{rect} = \texttt{rect} \pm \texttt{size}\f$ (expanding or shrinking a rectangle by a + certain amount) +- rect += point, rect -= point, rect += size, rect -= size (augmenting operations) +- rect = rect1 & rect2 (rectangle intersection) +- rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 ) +- rect &= rect1, rect |= rect1 (and the corresponding augmenting operations) +- rect == rect1, rect != rect1 (rectangle comparison) + +This is an example how the partial ordering on rectangles can be established (rect1 \f$\subseteq\f$ +rect2): +@code + template inline bool + operator <= (const Rect_<_Tp>& r1, const Rect_<_Tp>& r2) + { + return (r1 & r2) == r1; + } +@endcode +For your convenience, the Rect_\<\> alias is available: cv::Rect +*/ +template class Rect_ +{ +public: + typedef _Tp value_type; + + //! default constructor + Rect_(); + Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height); +#if OPENCV_ABI_COMPATIBILITY < 500 + Rect_(const Rect_& r) = default; + Rect_(Rect_&& r) CV_NOEXCEPT = default; +#endif + Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz); + Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2); + +#if OPENCV_ABI_COMPATIBILITY < 500 + Rect_& operator = (const Rect_& r) = default; + Rect_& operator = (Rect_&& r) CV_NOEXCEPT = default; +#endif + //! the top-left corner + Point_<_Tp> tl() const; + //! the bottom-right corner + Point_<_Tp> br() const; + + //! size (width, height) of the rectangle + Size_<_Tp> size() const; + //! area (width*height) of the rectangle + _Tp area() const; + //! true if empty + bool empty() const; + + //! conversion to another data type + template operator Rect_<_Tp2>() const; + + //! checks whether the rectangle contains the point + bool contains(const Point_<_Tp>& pt) const; + + _Tp x; //!< x coordinate of the top-left corner + _Tp y; //!< y coordinate of the top-left corner + _Tp width; //!< width of the rectangle + _Tp height; //!< height of the rectangle +}; + +typedef Rect_ Rect2i; +typedef Rect_ Rect2f; +typedef Rect_ Rect2d; +typedef Rect2i Rect; + +template class DataType< Rect_<_Tp> > +{ +public: + typedef Rect_<_Tp> value_type; + typedef Rect_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 4, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Rect_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Rect_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +} // namespace + +///////////////////////////// RotatedRect ///////////////////////////// + +/** @brief The class represents rotated (i.e. not up-right) rectangles on a plane. + +Each rectangle is specified by the center point (mass center), length of each side (represented by +#Size2f structure) and the rotation angle in degrees. + +The sample below demonstrates how to use RotatedRect: +@snippet snippets/core_various.cpp RotatedRect_demo +![image](pics/rotatedrect.png) + +@sa CamShift, fitEllipse, minAreaRect, CvBox2D +*/ +class CV_EXPORTS RotatedRect +{ +public: + //! default constructor + RotatedRect(); + /** full constructor + @param center The rectangle mass center. + @param size Width and height of the rectangle. + @param angle The rotation angle in a clockwise direction. When the angle is 0, 90, 180, 270 etc., + the rectangle becomes an up-right rectangle. + */ + RotatedRect(const Point2f& center, const Size2f& size, float angle); + /** + Any 3 end points of the RotatedRect. They must be given in order (either clockwise or + anticlockwise). + */ + RotatedRect(const Point2f& point1, const Point2f& point2, const Point2f& point3); + + /** returns 4 vertices of the rectangle + @param pts The points array for storing rectangle vertices. The order is bottomLeft, topLeft, topRight, bottomRight. + */ + void points(Point2f pts[]) const; + //! returns the minimal up-right integer rectangle containing the rotated rectangle + Rect boundingRect() const; + //! returns the minimal (exact) floating point rectangle containing the rotated rectangle, not intended for use with images + Rect_ boundingRect2f() const; + //! returns the rectangle mass center + Point2f center; + //! returns width and height of the rectangle + Size2f size; + //! returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. + float angle; +}; + +template<> class DataType< RotatedRect > +{ +public: + typedef RotatedRect value_type; + typedef value_type work_type; + typedef float channel_type; + + enum { generic_type = 0, + channels = (int)sizeof(value_type)/sizeof(channel_type), // 5 + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template<> +struct Depth< RotatedRect > { enum { value = Depth::value }; }; +template<> +struct Type< RotatedRect > { enum { value = CV_MAKETYPE(Depth::value, (int)sizeof(RotatedRect)/sizeof(float)) }; }; +} // namespace + + +//////////////////////////////// Range ///////////////////////////////// + +/** @brief Template class specifying a continuous subsequence (slice) of a sequence. + +The class is used to specify a row or a column span in a matrix ( Mat ) and for many other purposes. +Range(a,b) is basically the same as a:b in Matlab or a..b in Python. As in Python, start is an +inclusive left boundary of the range and end is an exclusive right boundary of the range. Such a +half-opened interval is usually denoted as \f$[start,end)\f$ . + +The static method Range::all() returns a special variable that means "the whole sequence" or "the +whole range", just like " : " in Matlab or " ... " in Python. All the methods and functions in +OpenCV that take Range support this special Range::all() value. But, of course, in case of your own +custom processing, you will probably have to check and handle it explicitly: +@code + void my_function(..., const Range& r, ....) + { + if(r == Range::all()) { + // process all the data + } + else { + // process [r.start, r.end) + } + } +@endcode +*/ +class CV_EXPORTS Range +{ +public: + Range(); + Range(int _start, int _end); + int size() const; + bool empty() const; + static Range all(); + + int start, end; +}; + +template<> class DataType +{ +public: + typedef Range value_type; + typedef value_type work_type; + typedef int channel_type; + + enum { generic_type = 0, + channels = 2, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template<> +struct Depth< Range > { enum { value = Depth::value }; }; +template<> +struct Type< Range > { enum { value = CV_MAKETYPE(Depth::value, 2) }; }; +} // namespace + + +//////////////////////////////// Scalar_ /////////////////////////////// + +/** @brief Template class for a 4-element vector derived from Vec. + +Being derived from Vec\<_Tp, 4\> , Scalar\_ and Scalar can be used just as typical 4-element +vectors. In addition, they can be converted to/from CvScalar . The type Scalar is widely used in +OpenCV to pass pixel values. +*/ +template class Scalar_ : public Vec<_Tp, 4> +{ +public: + //! default constructor + Scalar_(); + Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0); + Scalar_(_Tp v0); + + Scalar_(const Scalar_& s); + Scalar_(Scalar_&& s) CV_NOEXCEPT; + + Scalar_& operator=(const Scalar_& s); + Scalar_& operator=(Scalar_&& s) CV_NOEXCEPT; + + template + Scalar_(const Vec<_Tp2, cn>& v); + + //! returns a scalar with all elements set to v0 + static Scalar_<_Tp> all(_Tp v0); + + //! conversion to another data type + template operator Scalar_() const; + + //! per-element product + Scalar_<_Tp> mul(const Scalar_<_Tp>& a, double scale=1 ) const; + + //! returns (v0, -v1, -v2, -v3) + Scalar_<_Tp> conj() const; + + //! returns true iff v1 == v2 == v3 == 0 + bool isReal() const; +}; + +typedef Scalar_ Scalar; + +template class DataType< Scalar_<_Tp> > +{ +public: + typedef Scalar_<_Tp> value_type; + typedef Scalar_::work_type> work_type; + typedef _Tp channel_type; + + enum { generic_type = 0, + channels = 4, + fmt = traits::SafeFmt::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template +struct Depth< Scalar_<_Tp> > { enum { value = Depth<_Tp>::value }; }; +template +struct Type< Scalar_<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) }; }; +} // namespace + + +/////////////////////////////// KeyPoint //////////////////////////////// + +/** @brief Data structure for salient point detectors. + +The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint +detectors, such as Harris corner detector, #FAST, %StarDetector, %SURF, %SIFT etc. + +The keypoint is characterized by the 2D position, scale (proportional to the diameter of the +neighborhood that needs to be taken into account), orientation and some other parameters. The +keypoint neighborhood is then analyzed by another algorithm that builds a descriptor (usually +represented as a feature vector). The keypoints representing the same object in different images +can then be matched using %KDTree or another method. +*/ +class CV_EXPORTS_W_SIMPLE KeyPoint +{ +public: + //! the default constructor + CV_WRAP KeyPoint(); + /** + @param pt x & y coordinates of the keypoint + @param size keypoint diameter + @param angle keypoint orientation + @param response keypoint detector response on the keypoint (that is, strength of the keypoint) + @param octave pyramid octave in which the keypoint has been detected + @param class_id object id + */ + KeyPoint(Point2f pt, float size, float angle=-1, float response=0, int octave=0, int class_id=-1); + /** + @param x x-coordinate of the keypoint + @param y y-coordinate of the keypoint + @param size keypoint diameter + @param angle keypoint orientation + @param response keypoint detector response on the keypoint (that is, strength of the keypoint) + @param octave pyramid octave in which the keypoint has been detected + @param class_id object id + */ + CV_WRAP KeyPoint(float x, float y, float size, float angle=-1, float response=0, int octave=0, int class_id=-1); + + size_t hash() const; + + /** + This method converts vector of keypoints to vector of points or the reverse, where each keypoint is + assigned the same size and the same orientation. + + @param keypoints Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB + @param points2f Array of (x,y) coordinates of each keypoint + @param keypointIndexes Array of indexes of keypoints to be converted to points. (Acts like a mask to + convert only specified keypoints) + */ + CV_WRAP static void convert(const std::vector& keypoints, + CV_OUT std::vector& points2f, + const std::vector& keypointIndexes=std::vector()); + /** @overload + @param points2f Array of (x,y) coordinates of each keypoint + @param keypoints Keypoints obtained from any feature detection algorithm like SIFT/SURF/ORB + @param size keypoint diameter + @param response keypoint detector response on the keypoint (that is, strength of the keypoint) + @param octave pyramid octave in which the keypoint has been detected + @param class_id object id + */ + CV_WRAP static void convert(const std::vector& points2f, + CV_OUT std::vector& keypoints, + float size=1, float response=1, int octave=0, int class_id=-1); + + /** + This method computes overlap for pair of keypoints. Overlap is the ratio between area of keypoint + regions' intersection and area of keypoint regions' union (considering keypoint region as circle). + If they don't overlap, we get zero. If they coincide at same location with same size, we get 1. + @param kp1 First keypoint + @param kp2 Second keypoint + */ + CV_WRAP static float overlap(const KeyPoint& kp1, const KeyPoint& kp2); + + CV_PROP_RW Point2f pt; //!< coordinates of the keypoints + CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood + CV_PROP_RW float angle; //!< computed orientation of the keypoint (-1 if not applicable); + //!< it's in [0,360) degrees and measured relative to + //!< image coordinate system, ie in clockwise. + CV_PROP_RW float response; //!< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling + CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has been extracted + CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to) +}; + +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED +template<> class DataType +{ +public: + typedef KeyPoint value_type; + typedef float work_type; + typedef float channel_type; + + enum { generic_type = 0, + depth = DataType::depth, + channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 7 + fmt = DataType::fmt + ((channels - 1) << 8), + type = CV_MAKETYPE(depth, channels) + }; + + typedef Vec vec_type; +}; +#endif + + +//////////////////////////////// DMatch ///////////////////////////////// + +/** @brief Class for matching keypoint descriptors + +query descriptor index, train descriptor index, train image index, and distance between +descriptors. +*/ +class CV_EXPORTS_W_SIMPLE DMatch +{ +public: + CV_WRAP DMatch(); + CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance); + CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance); + + CV_PROP_RW int queryIdx; //!< query descriptor index + CV_PROP_RW int trainIdx; //!< train descriptor index + CV_PROP_RW int imgIdx; //!< train image index + + CV_PROP_RW float distance; + + // less is better + bool operator<(const DMatch &m) const; +}; + +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED +template<> class DataType +{ +public: + typedef DMatch value_type; + typedef int work_type; + typedef int channel_type; + + enum { generic_type = 0, + depth = DataType::depth, + channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 4 + fmt = DataType::fmt + ((channels - 1) << 8), + type = CV_MAKETYPE(depth, channels) + }; + + typedef Vec vec_type; +}; +#endif + + +///////////////////////////// TermCriteria ////////////////////////////// + +/** @brief The class defining termination criteria for iterative algorithms. + +You can initialize it by default constructor and then override any parameters, or the structure may +be fully initialized using the advanced variant of the constructor. +*/ +class CV_EXPORTS TermCriteria +{ +public: + /** + Criteria type, can be one of: COUNT, EPS or COUNT + EPS + */ + enum Type + { + COUNT=1, //!< the maximum number of iterations or elements to compute + MAX_ITER=COUNT, //!< ditto + EPS=2 //!< the desired accuracy or change in parameters at which the iterative algorithm stops + }; + + //! default constructor + TermCriteria(); + /** + @param type The type of termination criteria, one of TermCriteria::Type + @param maxCount The maximum number of iterations or elements to compute. + @param epsilon The desired accuracy or change in parameters at which the iterative algorithm stops. + */ + TermCriteria(int type, int maxCount, double epsilon); + + inline bool isValid() const + { + const bool isCount = (type & COUNT) && maxCount > 0; + const bool isEps = (type & EPS) && !cvIsNaN(epsilon); + return isCount || isEps; + } + + int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS + int maxCount; //!< the maximum number of iterations/elements + double epsilon; //!< the desired accuracy +}; + + +//! @} core_basic + +///////////////////////// raster image moments ////////////////////////// + +//! @addtogroup imgproc_shape +//! @{ + +/** @brief struct returned by cv::moments + +The spatial moments \f$\texttt{Moments::m}_{ji}\f$ are computed as: + +\f[\texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot y^i \right )\f] + +The central moments \f$\texttt{Moments::mu}_{ji}\f$ are computed as: + +\f[\texttt{mu} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot (x - \bar{x} )^j \cdot (y - \bar{y} )^i \right )\f] + +where \f$(\bar{x}, \bar{y})\f$ is the mass center: + +\f[\bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} = \frac{\texttt{m}_{01}}{\texttt{m}_{00}}\f] + +The normalized central moments \f$\texttt{Moments::nu}_{ij}\f$ are computed as: + +\f[\texttt{nu} _{ji}= \frac{\texttt{mu}_{ji}}{\texttt{m}_{00}^{(i+j)/2+1}} .\f] + +@note +\f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$ +\f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$ , hence the values are not +stored. + +The moments of a contour are defined in the same way but computed using the Green's formula (see +). So, due to a limited raster resolution, the moments +computed for a contour are slightly different from the moments computed for the same rasterized +contour. + +@note +Since the contour moments are computed using Green formula, you may get seemingly odd results for +contours with self-intersections, e.g. a zero area (m00) for butterfly-shaped contours. + */ +class CV_EXPORTS_W_MAP Moments +{ +public: + //! the default constructor + Moments(); + //! the full constructor + Moments(double m00, double m10, double m01, double m20, double m11, + double m02, double m30, double m21, double m12, double m03 ); + ////! the conversion from CvMoments + //Moments( const CvMoments& moments ); + ////! the conversion to CvMoments + //operator CvMoments() const; + + //! @name spatial moments + //! @{ + CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; + //! @} + + //! @name central moments + //! @{ + CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03; + //! @} + + //! @name central normalized moments + //! @{ + CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03; + //! @} +}; + +template<> class DataType +{ +public: + typedef Moments value_type; + typedef double work_type; + typedef double channel_type; + + enum { generic_type = 0, + channels = (int)(sizeof(value_type)/sizeof(channel_type)), // 24 + fmt = DataType::fmt + ((channels - 1) << 8) +#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED + ,depth = DataType::depth + ,type = CV_MAKETYPE(depth, channels) +#endif + }; + + typedef Vec vec_type; +}; + +namespace traits { +template<> +struct Depth< Moments > { enum { value = Depth::value }; }; +template<> +struct Type< Moments > { enum { value = CV_MAKETYPE(Depth::value, (int)(sizeof(Moments)/sizeof(double))) }; }; +} // namespace + +//! @} imgproc_shape + +//! @cond IGNORED + +///////////////////////////////////////////////////////////////////////// +///////////////////////////// Implementation //////////////////////////// +///////////////////////////////////////////////////////////////////////// + +//////////////////////////////// Complex //////////////////////////////// + +template inline +Complex<_Tp>::Complex() + : re(0), im(0) {} + +template inline +Complex<_Tp>::Complex( _Tp _re, _Tp _im ) + : re(_re), im(_im) {} + +template template inline +Complex<_Tp>::operator Complex() const +{ + return Complex(saturate_cast(re), saturate_cast(im)); +} + +template inline +Complex<_Tp> Complex<_Tp>::conj() const +{ + return Complex<_Tp>(re, -im); +} + + +template static inline +bool operator == (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return a.re == b.re && a.im == b.im; +} + +template static inline +bool operator != (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return a.re != b.re || a.im != b.im; +} + +template static inline +Complex<_Tp> operator + (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return Complex<_Tp>( a.re + b.re, a.im + b.im ); +} + +template static inline +Complex<_Tp>& operator += (Complex<_Tp>& a, const Complex<_Tp>& b) +{ + a.re += b.re; a.im += b.im; + return a; +} + +template static inline +Complex<_Tp> operator - (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return Complex<_Tp>( a.re - b.re, a.im - b.im ); +} + +template static inline +Complex<_Tp>& operator -= (Complex<_Tp>& a, const Complex<_Tp>& b) +{ + a.re -= b.re; a.im -= b.im; + return a; +} + +template static inline +Complex<_Tp> operator - (const Complex<_Tp>& a) +{ + return Complex<_Tp>(-a.re, -a.im); +} + +template static inline +Complex<_Tp> operator * (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + return Complex<_Tp>( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re ); +} + +template static inline +Complex<_Tp> operator * (const Complex<_Tp>& a, _Tp b) +{ + return Complex<_Tp>( a.re*b, a.im*b ); +} + +template static inline +Complex<_Tp> operator * (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>( a.re*b, a.im*b ); +} + +template static inline +Complex<_Tp> operator + (const Complex<_Tp>& a, _Tp b) +{ + return Complex<_Tp>( a.re + b, a.im ); +} + +template static inline +Complex<_Tp> operator - (const Complex<_Tp>& a, _Tp b) +{ return Complex<_Tp>( a.re - b, a.im ); } + +template static inline +Complex<_Tp> operator + (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>( a.re + b, a.im ); +} + +template static inline +Complex<_Tp> operator - (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>( b - a.re, -a.im ); +} + +template static inline +Complex<_Tp>& operator += (Complex<_Tp>& a, _Tp b) +{ + a.re += b; return a; +} + +template static inline +Complex<_Tp>& operator -= (Complex<_Tp>& a, _Tp b) +{ + a.re -= b; return a; +} + +template static inline +Complex<_Tp>& operator *= (Complex<_Tp>& a, _Tp b) +{ + a.re *= b; a.im *= b; return a; +} + +template static inline +double abs(const Complex<_Tp>& a) +{ + return std::sqrt( (double)a.re*a.re + (double)a.im*a.im); +} + +template static inline +Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b) +{ + double t = 1./((double)b.re*b.re + (double)b.im*b.im); + return Complex<_Tp>( (_Tp)((a.re*b.re + a.im*b.im)*t), + (_Tp)((-a.re*b.im + a.im*b.re)*t) ); +} + +template static inline +Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b) +{ + a = a / b; + return a; +} + +template static inline +Complex<_Tp> operator / (const Complex<_Tp>& a, _Tp b) +{ + _Tp t = (_Tp)1/b; + return Complex<_Tp>( a.re*t, a.im*t ); +} + +template static inline +Complex<_Tp> operator / (_Tp b, const Complex<_Tp>& a) +{ + return Complex<_Tp>(b)/a; +} + +template static inline +Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b) +{ + _Tp t = (_Tp)1/b; + a.re *= t; a.im *= t; return a; +} + + + +//////////////////////////////// 2D Point /////////////////////////////// + +template inline +Point_<_Tp>::Point_() + : x(0), y(0) {} + +template inline +Point_<_Tp>::Point_(_Tp _x, _Tp _y) + : x(_x), y(_y) {} + +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 +template inline +Point_<_Tp>::Point_(const Point_& pt) + : x(pt.x), y(pt.y) {} +#endif + +template inline +Point_<_Tp>::Point_(const Size_<_Tp>& sz) + : x(sz.width), y(sz.height) {} + +template inline +Point_<_Tp>::Point_(const Vec<_Tp,2>& v) + : x(v[0]), y(v[1]) {} + +#if (defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__) // GCC 4.x bug. Details: https://github.com/opencv/opencv/pull/20837 +template inline +Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) +{ + x = pt.x; y = pt.y; + return *this; +} +#endif + +template template inline +Point_<_Tp>::operator Point_<_Tp2>() const +{ + return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); +} + +template inline +Point_<_Tp>::operator Vec<_Tp, 2>() const +{ + return Vec<_Tp, 2>(x, y); +} + +template inline +_Tp Point_<_Tp>::dot(const Point_& pt) const +{ + return saturate_cast<_Tp>(x*pt.x + y*pt.y); +} + +template inline +double Point_<_Tp>::ddot(const Point_& pt) const +{ + return (double)x*(double)(pt.x) + (double)y*(double)(pt.y); +} + +template inline +double Point_<_Tp>::cross(const Point_& pt) const +{ + return (double)x*pt.y - (double)y*pt.x; +} + +template inline bool +Point_<_Tp>::inside( const Rect_<_Tp>& r ) const +{ + return r.contains(*this); +} + + +template static inline +Point_<_Tp>& operator += (Point_<_Tp>& a, const Point_<_Tp>& b) +{ + a.x += b.x; + a.y += b.y; + return a; +} + +template static inline +Point_<_Tp>& operator -= (Point_<_Tp>& a, const Point_<_Tp>& b) +{ + a.x -= b.x; + a.y -= b.y; + return a; +} + +template static inline +Point_<_Tp>& operator *= (Point_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + return a; +} + +template static inline +Point_<_Tp>& operator *= (Point_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + return a; +} + +template static inline +Point_<_Tp>& operator *= (Point_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +Point_<_Tp>& operator /= (Point_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + return a; +} + +template static inline +double norm(const Point_<_Tp>& pt) +{ + return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y); +} + +template static inline +bool operator == (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return a.x == b.x && a.y == b.y; +} + +template static inline +bool operator != (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return a.x != b.x || a.y != b.y; +} + +template static inline +Point_<_Tp> operator + (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y) ); +} + +template static inline +Point_<_Tp> operator - (const Point_<_Tp>& a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y) ); +} + +template static inline +Point_<_Tp> operator - (const Point_<_Tp>& a) +{ + return Point_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y) ); +} + +template static inline +Point_<_Tp> operator * (const Point_<_Tp>& a, int b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); +} + +template static inline +Point_<_Tp> operator * (int a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); +} + +template static inline +Point_<_Tp> operator * (const Point_<_Tp>& a, float b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); +} + +template static inline +Point_<_Tp> operator * (float a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); +} + +template static inline +Point_<_Tp> operator * (const Point_<_Tp>& a, double b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); +} + +template static inline +Point_<_Tp> operator * (double a, const Point_<_Tp>& b) +{ + return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); +} + +template static inline +Point_<_Tp> operator * (const Matx<_Tp, 2, 2>& a, const Point_<_Tp>& b) +{ + Matx<_Tp, 2, 1> tmp = a * Vec<_Tp,2>(b.x, b.y); + return Point_<_Tp>(tmp.val[0], tmp.val[1]); +} + +template static inline +Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b) +{ + Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, 1); + return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, int b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, float b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point_<_Tp> operator / (const Point_<_Tp>& a, double b) +{ + Point_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + + +template static inline _AccTp normL2Sqr(const Point_& pt); +template static inline _AccTp normL2Sqr(const Point_& pt); +template static inline _AccTp normL2Sqr(const Point_& pt); +template static inline _AccTp normL2Sqr(const Point_& pt); + +template<> inline int normL2Sqr(const Point_& pt) { return pt.dot(pt); } +template<> inline int64 normL2Sqr(const Point_& pt) { return pt.dot(pt); } +template<> inline float normL2Sqr(const Point_& pt) { return pt.dot(pt); } +template<> inline double normL2Sqr(const Point_& pt) { return pt.dot(pt); } + +template<> inline double normL2Sqr(const Point_& pt) { return pt.ddot(pt); } +template<> inline double normL2Sqr(const Point_& pt) { return pt.ddot(pt); } + + + +//////////////////////////////// 3D Point /////////////////////////////// + +template inline +Point3_<_Tp>::Point3_() + : x(0), y(0), z(0) {} + +template inline +Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) + : x(_x), y(_y), z(_z) {} + +template inline +Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) + : x(pt.x), y(pt.y), z(_Tp()) {} + +template inline +Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v) + : x(v[0]), y(v[1]), z(v[2]) {} + +template template inline +Point3_<_Tp>::operator Point3_<_Tp2>() const +{ + return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); +} + +template inline +Point3_<_Tp>::operator Vec<_Tp, 3>() const +{ + return Vec<_Tp, 3>(x, y, z); +} + +template inline +_Tp Point3_<_Tp>::dot(const Point3_& pt) const +{ + return saturate_cast<_Tp>(x*pt.x + y*pt.y + z*pt.z); +} + +template inline +double Point3_<_Tp>::ddot(const Point3_& pt) const +{ + return (double)x*pt.x + (double)y*pt.y + (double)z*pt.z; +} + +template inline +Point3_<_Tp> Point3_<_Tp>::cross(const Point3_<_Tp>& pt) const +{ + return Point3_<_Tp>(y*pt.z - z*pt.y, z*pt.x - x*pt.z, x*pt.y - y*pt.x); +} + + +template static inline +Point3_<_Tp>& operator += (Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + a.x += b.x; + a.y += b.y; + a.z += b.z; + return a; +} + +template static inline +Point3_<_Tp>& operator -= (Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + a.x -= b.x; + a.y -= b.y; + a.z -= b.z; + return a; +} + +template static inline +Point3_<_Tp>& operator *= (Point3_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + a.z = saturate_cast<_Tp>(a.z * b); + return a; +} + +template static inline +Point3_<_Tp>& operator *= (Point3_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + a.z = saturate_cast<_Tp>(a.z * b); + return a; +} + +template static inline +Point3_<_Tp>& operator *= (Point3_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x * b); + a.y = saturate_cast<_Tp>(a.y * b); + a.z = saturate_cast<_Tp>(a.z * b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, int b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, float b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +Point3_<_Tp>& operator /= (Point3_<_Tp>& a, double b) +{ + a.x = saturate_cast<_Tp>(a.x / b); + a.y = saturate_cast<_Tp>(a.y / b); + a.z = saturate_cast<_Tp>(a.z / b); + return a; +} + +template static inline +double norm(const Point3_<_Tp>& pt) +{ + return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y + (double)pt.z*pt.z); +} + +template static inline +bool operator == (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return a.x == b.x && a.y == b.y && a.z == b.z; +} + +template static inline +bool operator != (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return a.x != b.x || a.y != b.y || a.z != b.z; +} + +template static inline +Point3_<_Tp> operator + (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y), saturate_cast<_Tp>(a.z + b.z)); +} + +template static inline +Point3_<_Tp> operator - (const Point3_<_Tp>& a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y), saturate_cast<_Tp>(a.z - b.z)); +} + +template static inline +Point3_<_Tp> operator - (const Point3_<_Tp>& a) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y), saturate_cast<_Tp>(-a.z) ); +} + +template static inline +Point3_<_Tp> operator * (const Point3_<_Tp>& a, int b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b), saturate_cast<_Tp>(a.z*b) ); +} + +template static inline +Point3_<_Tp> operator * (int a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) ); +} + +template static inline +Point3_<_Tp> operator * (const Point3_<_Tp>& a, float b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) ); +} + +template static inline +Point3_<_Tp> operator * (float a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) ); +} + +template static inline +Point3_<_Tp> operator * (const Point3_<_Tp>& a, double b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b), saturate_cast<_Tp>(a.z * b) ); +} + +template static inline +Point3_<_Tp> operator * (double a, const Point3_<_Tp>& b) +{ + return Point3_<_Tp>( saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a), saturate_cast<_Tp>(b.z * a) ); +} + +template static inline +Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point3_<_Tp>& b) +{ + Matx<_Tp, 3, 1> tmp = a * Vec<_Tp,3>(b.x, b.y, b.z); + return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); +} + +template static inline +Matx<_Tp, 4, 1> operator * (const Matx<_Tp, 4, 4>& a, const Point3_<_Tp>& b) +{ + return a * Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1); +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, int b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, float b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Point3_<_Tp> operator / (const Point3_<_Tp>& a, double b) +{ + Point3_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + + + +////////////////////////////////// Size ///////////////////////////////// + +template inline +Size_<_Tp>::Size_() + : width(0), height(0) {} + +template inline +Size_<_Tp>::Size_(_Tp _width, _Tp _height) + : width(_width), height(_height) {} + +template inline +Size_<_Tp>::Size_(const Point_<_Tp>& pt) + : width(pt.x), height(pt.y) {} + +template template inline +Size_<_Tp>::operator Size_<_Tp2>() const +{ + return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); +} + +template inline +_Tp Size_<_Tp>::area() const +{ + const _Tp result = width * height; + CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer + || width == 0 || result / width == height); // make sure the result fits in the return value + return result; +} + +template inline +double Size_<_Tp>::aspectRatio() const +{ + return width / static_cast(height); +} + +template inline +bool Size_<_Tp>::empty() const +{ + return width <= 0 || height <= 0; +} + + +template static inline +Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b) +{ + a.width *= b; + a.height *= b; + return a; +} + +template static inline +Size_<_Tp> operator * (const Size_<_Tp>& a, _Tp b) +{ + Size_<_Tp> tmp(a); + tmp *= b; + return tmp; +} + +template static inline +Size_<_Tp>& operator /= (Size_<_Tp>& a, _Tp b) +{ + a.width /= b; + a.height /= b; + return a; +} + +template static inline +Size_<_Tp> operator / (const Size_<_Tp>& a, _Tp b) +{ + Size_<_Tp> tmp(a); + tmp /= b; + return tmp; +} + +template static inline +Size_<_Tp>& operator += (Size_<_Tp>& a, const Size_<_Tp>& b) +{ + a.width += b.width; + a.height += b.height; + return a; +} + +template static inline +Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + Size_<_Tp> tmp(a); + tmp += b; + return tmp; +} + +template static inline +Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b) +{ + a.width -= b.width; + a.height -= b.height; + return a; +} + +template static inline +Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + Size_<_Tp> tmp(a); + tmp -= b; + return tmp; +} + +template static inline +bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + return a.width == b.width && a.height == b.height; +} + +template static inline +bool operator != (const Size_<_Tp>& a, const Size_<_Tp>& b) +{ + return !(a == b); +} + + + +////////////////////////////////// Rect ///////////////////////////////// + +template inline +Rect_<_Tp>::Rect_() + : x(0), y(0), width(0), height(0) {} + +template inline +Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height) + : x(_x), y(_y), width(_width), height(_height) {} + +template inline +Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz) + : x(org.x), y(org.y), width(sz.width), height(sz.height) {} + +template inline +Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2) +{ + x = std::min(pt1.x, pt2.x); + y = std::min(pt1.y, pt2.y); + width = std::max(pt1.x, pt2.x) - x; + height = std::max(pt1.y, pt2.y) - y; +} + +template inline +Point_<_Tp> Rect_<_Tp>::tl() const +{ + return Point_<_Tp>(x,y); +} + +template inline +Point_<_Tp> Rect_<_Tp>::br() const +{ + return Point_<_Tp>(x + width, y + height); +} + +template inline +Size_<_Tp> Rect_<_Tp>::size() const +{ + return Size_<_Tp>(width, height); +} + +template inline +_Tp Rect_<_Tp>::area() const +{ + const _Tp result = width * height; + CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer + || width == 0 || result / width == height); // make sure the result fits in the return value + return result; +} + +template inline +bool Rect_<_Tp>::empty() const +{ + return width <= 0 || height <= 0; +} + +template template inline +Rect_<_Tp>::operator Rect_<_Tp2>() const +{ + return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); +} + +template inline +bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const +{ + return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height; +} + + +template static inline +Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Point_<_Tp>& b ) +{ + a.x += b.x; + a.y += b.y; + return a; +} + +template static inline +Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Point_<_Tp>& b ) +{ + a.x -= b.x; + a.y -= b.y; + return a; +} + +template static inline +Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b ) +{ + a.width += b.width; + a.height += b.height; + return a; +} + +template static inline +Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b ) +{ + const _Tp width = a.width - b.width; + const _Tp height = a.height - b.height; + CV_DbgAssert(width >= 0 && height >= 0); + a.width = width; + a.height = height; + return a; +} + +template static inline +Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b ) +{ + if (a.empty() || b.empty()) { + a = Rect(); + return a; + } + const Rect_<_Tp>& Rx_min = (a.x < b.x) ? a : b; + const Rect_<_Tp>& Rx_max = (a.x < b.x) ? b : a; + const Rect_<_Tp>& Ry_min = (a.y < b.y) ? a : b; + const Rect_<_Tp>& Ry_max = (a.y < b.y) ? b : a; + // Looking at the formula below, we will compute Rx_min.width - (Rx_max.x - Rx_min.x) + // but we want to avoid overflows. Rx_min.width >= 0 and (Rx_max.x - Rx_min.x) >= 0 + // by definition so the difference does not overflow. The only thing that can overflow + // is (Rx_max.x - Rx_min.x). And it can only overflow if Rx_min.x < 0. + // Let us first deal with the following case. + if ((Rx_min.x < 0 && Rx_min.x + Rx_min.width < Rx_max.x) || + (Ry_min.y < 0 && Ry_min.y + Ry_min.height < Ry_max.y)) { + a = Rect(); + return a; + } + // We now know that either Rx_min.x >= 0, or + // Rx_min.x < 0 && Rx_min.x + Rx_min.width >= Rx_max.x and therefore + // Rx_min.width >= (Rx_max.x - Rx_min.x) which means (Rx_max.x - Rx_min.x) + // is inferior to a valid int and therefore does not overflow. + a.width = std::min(Rx_min.width - (Rx_max.x - Rx_min.x), Rx_max.width); + a.height = std::min(Ry_min.height - (Ry_max.y - Ry_min.y), Ry_max.height); + a.x = Rx_max.x; + a.y = Ry_max.y; + if (a.empty()) + a = Rect(); + return a; +} + +template static inline +Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b ) +{ + if (a.empty()) { + a = b; + } + else if (!b.empty()) { + _Tp x1 = std::min(a.x, b.x); + _Tp y1 = std::min(a.y, b.y); + a.width = std::max(a.x + a.width, b.x + b.width) - x1; + a.height = std::max(a.y + a.height, b.y + b.height) - y1; + a.x = x1; + a.y = y1; + } + return a; +} + +template static inline +bool operator == (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; +} + +template static inline +bool operator != (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height; +} + +template static inline +Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Point_<_Tp>& b) +{ + return Rect_<_Tp>( a.x + b.x, a.y + b.y, a.width, a.height ); +} + +template static inline +Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Point_<_Tp>& b) +{ + return Rect_<_Tp>( a.x - b.x, a.y - b.y, a.width, a.height ); +} + +template static inline +Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b) +{ + return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height ); +} + +template static inline +Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Size_<_Tp>& b) +{ + const _Tp width = a.width - b.width; + const _Tp height = a.height - b.height; + CV_DbgAssert(width >= 0 && height >= 0); + return Rect_<_Tp>( a.x, a.y, width, height ); +} + +template static inline +Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + Rect_<_Tp> c = a; + return c &= b; +} + +template static inline +Rect_<_Tp> operator | (const Rect_<_Tp>& a, const Rect_<_Tp>& b) +{ + Rect_<_Tp> c = a; + return c |= b; +} + +/** + * @brief measure dissimilarity between two sample sets + * + * computes the complement of the Jaccard Index as described in . + * For rectangles this reduces to computing the intersection over the union. + */ +template static inline +double jaccardDistance(const Rect_<_Tp>& a, const Rect_<_Tp>& b) { + _Tp Aa = a.area(); + _Tp Ab = b.area(); + + if ((Aa + Ab) <= std::numeric_limits<_Tp>::epsilon()) { + // jaccard_index = 1 -> distance = 0 + return 0.0; + } + + double Aab = (a & b).area(); + // distance = 1 - jaccard_index + return 1.0 - Aab / (Aa + Ab - Aab); +} + +////////////////////////////// RotatedRect ////////////////////////////// + +inline +RotatedRect::RotatedRect() + : center(), size(), angle(0) {} + +inline +RotatedRect::RotatedRect(const Point2f& _center, const Size2f& _size, float _angle) + : center(_center), size(_size), angle(_angle) {} + +///////////////////////////////// Range ///////////////////////////////// + +inline +Range::Range() + : start(0), end(0) {} + +inline +Range::Range(int _start, int _end) + : start(_start), end(_end) {} + +inline +int Range::size() const +{ + return end - start; +} + +inline +bool Range::empty() const +{ + return start == end; +} + +inline +Range Range::all() +{ + return Range(INT_MIN, INT_MAX); +} + + +static inline +bool operator == (const Range& r1, const Range& r2) +{ + return r1.start == r2.start && r1.end == r2.end; +} + +static inline +bool operator != (const Range& r1, const Range& r2) +{ + return !(r1 == r2); +} + +static inline +bool operator !(const Range& r) +{ + return r.start == r.end; +} + +static inline +Range operator & (const Range& r1, const Range& r2) +{ + Range r(std::max(r1.start, r2.start), std::min(r1.end, r2.end)); + r.end = std::max(r.end, r.start); + return r; +} + +static inline +Range& operator &= (Range& r1, const Range& r2) +{ + r1 = r1 & r2; + return r1; +} + +static inline +Range operator + (const Range& r1, int delta) +{ + return Range(r1.start + delta, r1.end + delta); +} + +static inline +Range operator + (int delta, const Range& r1) +{ + return Range(r1.start + delta, r1.end + delta); +} + +static inline +Range operator - (const Range& r1, int delta) +{ + return r1 + (-delta); +} + + + +///////////////////////////////// Scalar //////////////////////////////// + +template inline +Scalar_<_Tp>::Scalar_() +{ + this->val[0] = this->val[1] = this->val[2] = this->val[3] = 0; +} + +template inline +Scalar_<_Tp>::Scalar_(_Tp v0, _Tp v1, _Tp v2, _Tp v3) +{ + this->val[0] = v0; + this->val[1] = v1; + this->val[2] = v2; + this->val[3] = v3; +} + +template inline +Scalar_<_Tp>::Scalar_(const Scalar_<_Tp>& s) : Vec<_Tp, 4>(s) { +} + +template inline +Scalar_<_Tp>::Scalar_(Scalar_<_Tp>&& s) CV_NOEXCEPT { + this->val[0] = std::move(s.val[0]); + this->val[1] = std::move(s.val[1]); + this->val[2] = std::move(s.val[2]); + this->val[3] = std::move(s.val[3]); +} + +template inline +Scalar_<_Tp>& Scalar_<_Tp>::operator=(const Scalar_<_Tp>& s) { + this->val[0] = s.val[0]; + this->val[1] = s.val[1]; + this->val[2] = s.val[2]; + this->val[3] = s.val[3]; + return *this; +} + +template inline +Scalar_<_Tp>& Scalar_<_Tp>::operator=(Scalar_<_Tp>&& s) CV_NOEXCEPT { + this->val[0] = std::move(s.val[0]); + this->val[1] = std::move(s.val[1]); + this->val[2] = std::move(s.val[2]); + this->val[3] = std::move(s.val[3]); + return *this; +} + +template template inline +Scalar_<_Tp>::Scalar_(const Vec<_Tp2, cn>& v) +{ + int i; + for( i = 0; i < (cn < 4 ? cn : 4); i++ ) + this->val[i] = cv::saturate_cast<_Tp>(v.val[i]); + for( ; i < 4; i++ ) + this->val[i] = 0; +} + +template inline +Scalar_<_Tp>::Scalar_(_Tp v0) +{ + this->val[0] = v0; + this->val[1] = this->val[2] = this->val[3] = 0; +} + +template inline +Scalar_<_Tp> Scalar_<_Tp>::all(_Tp v0) +{ + return Scalar_<_Tp>(v0, v0, v0, v0); +} + + +template inline +Scalar_<_Tp> Scalar_<_Tp>::mul(const Scalar_<_Tp>& a, double scale ) const +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(this->val[0] * a.val[0] * scale), + saturate_cast<_Tp>(this->val[1] * a.val[1] * scale), + saturate_cast<_Tp>(this->val[2] * a.val[2] * scale), + saturate_cast<_Tp>(this->val[3] * a.val[3] * scale)); +} + +template inline +Scalar_<_Tp> Scalar_<_Tp>::conj() const +{ + return Scalar_<_Tp>(saturate_cast<_Tp>( this->val[0]), + saturate_cast<_Tp>(-this->val[1]), + saturate_cast<_Tp>(-this->val[2]), + saturate_cast<_Tp>(-this->val[3])); +} + +template inline +bool Scalar_<_Tp>::isReal() const +{ + return this->val[1] == 0 && this->val[2] == 0 && this->val[3] == 0; +} + + +template template inline +Scalar_<_Tp>::operator Scalar_() const +{ + return Scalar_(saturate_cast(this->val[0]), + saturate_cast(this->val[1]), + saturate_cast(this->val[2]), + saturate_cast(this->val[3])); +} + + +template static inline +Scalar_<_Tp>& operator += (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a.val[0] += b.val[0]; + a.val[1] += b.val[1]; + a.val[2] += b.val[2]; + a.val[3] += b.val[3]; + return a; +} + +template static inline +Scalar_<_Tp>& operator -= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a.val[0] -= b.val[0]; + a.val[1] -= b.val[1]; + a.val[2] -= b.val[2]; + a.val[3] -= b.val[3]; + return a; +} + +template static inline +Scalar_<_Tp>& operator *= ( Scalar_<_Tp>& a, _Tp v ) +{ + a.val[0] *= v; + a.val[1] *= v; + a.val[2] *= v; + a.val[3] *= v; + return a; +} + +template static inline +bool operator == ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b ) +{ + return a.val[0] == b.val[0] && a.val[1] == b.val[1] && + a.val[2] == b.val[2] && a.val[3] == b.val[3]; +} + +template static inline +bool operator != ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b ) +{ + return a.val[0] != b.val[0] || a.val[1] != b.val[1] || + a.val[2] != b.val[2] || a.val[3] != b.val[3]; +} + +template static inline +Scalar_<_Tp> operator + (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return Scalar_<_Tp>(a.val[0] + b.val[0], + a.val[1] + b.val[1], + a.val[2] + b.val[2], + a.val[3] + b.val[3]); +} + +template static inline +Scalar_<_Tp> operator - (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]), + saturate_cast<_Tp>(a.val[1] - b.val[1]), + saturate_cast<_Tp>(a.val[2] - b.val[2]), + saturate_cast<_Tp>(a.val[3] - b.val[3])); +} + +template static inline +Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, _Tp alpha) +{ + return Scalar_<_Tp>(a.val[0] * alpha, + a.val[1] * alpha, + a.val[2] * alpha, + a.val[3] * alpha); +} + +template static inline +Scalar_<_Tp> operator * (_Tp alpha, const Scalar_<_Tp>& a) +{ + return a*alpha; +} + +template static inline +Scalar_<_Tp> operator - (const Scalar_<_Tp>& a) +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(-a.val[0]), + saturate_cast<_Tp>(-a.val[1]), + saturate_cast<_Tp>(-a.val[2]), + saturate_cast<_Tp>(-a.val[3])); +} + + +template static inline +Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return Scalar_<_Tp>(saturate_cast<_Tp>(a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]), + saturate_cast<_Tp>(a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]), + saturate_cast<_Tp>(a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]), + saturate_cast<_Tp>(a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0])); +} + +template static inline +Scalar_<_Tp>& operator *= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a = a * b; + return a; +} + +template static inline +Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, _Tp alpha) +{ + return Scalar_<_Tp>(a.val[0] / alpha, + a.val[1] / alpha, + a.val[2] / alpha, + a.val[3] / alpha); +} + +template static inline +Scalar_ operator / (const Scalar_& a, float alpha) +{ + float s = 1 / alpha; + return Scalar_(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s); +} + +template static inline +Scalar_ operator / (const Scalar_& a, double alpha) +{ + double s = 1 / alpha; + return Scalar_(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s); +} + +template static inline +Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, _Tp alpha) +{ + a = a / alpha; + return a; +} + +template static inline +Scalar_<_Tp> operator / (_Tp a, const Scalar_<_Tp>& b) +{ + _Tp s = a / (b[0]*b[0] + b[1]*b[1] + b[2]*b[2] + b[3]*b[3]); + return b.conj() * s; +} + +template static inline +Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + return a * ((_Tp)1 / b); +} + +template static inline +Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) +{ + a = a / b; + return a; +} + +template static inline +Scalar operator * (const Matx<_Tp, 4, 4>& a, const Scalar& b) +{ + Matx c((Matx)a, b, Matx_MatMulOp()); + return reinterpret_cast(c); +} + +template<> inline +Scalar operator * (const Matx& a, const Scalar& b) +{ + Matx c(a, b, Matx_MatMulOp()); + return reinterpret_cast(c); +} + + + +//////////////////////////////// KeyPoint /////////////////////////////// + +inline +KeyPoint::KeyPoint() + : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {} + +inline +KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle, float _response, int _octave, int _class_id) + : pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} + +inline +KeyPoint::KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) + : pt(x, y), size(_size), angle(_angle), response(_response), octave(_octave), class_id(_class_id) {} + + + +///////////////////////////////// DMatch //////////////////////////////// + +inline +DMatch::DMatch() + : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {} + +inline +DMatch::DMatch(int _queryIdx, int _trainIdx, float _distance) + : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1), distance(_distance) {} + +inline +DMatch::DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) + : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx), distance(_distance) {} + +inline +bool DMatch::operator < (const DMatch &m) const +{ + return distance < m.distance; +} + + + +////////////////////////////// TermCriteria ///////////////////////////// + +inline +TermCriteria::TermCriteria() + : type(0), maxCount(0), epsilon(0) {} + +inline +TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon) + : type(_type), maxCount(_maxCount), epsilon(_epsilon) {} + +//! @endcond + +} // cv + +#endif //OPENCV_CORE_TYPES_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/types_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/types_c.h new file mode 100644 index 0000000..32f3c8c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/types_c.h @@ -0,0 +1,2126 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_TYPES_H +#define OPENCV_CORE_TYPES_H + +#ifdef CV__ENABLE_C_API_CTORS // invalid C API ctors (must be removed) +#if defined(_WIN32) && !defined(CV__SKIP_MESSAGE_MALFORMED_C_API_CTORS) +#error "C API ctors don't work on Win32: https://github.com/opencv/opencv/issues/15990" +#endif +#endif + +//#define CV__VALIDATE_UNUNITIALIZED_VARS 1 // C++11 & GCC only + +#ifdef __cplusplus + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#define CV_STRUCT_INITIALIZER {0,} +#else +#if defined(__GNUC__) && __GNUC__ == 4 // GCC 4.x warns on "= {}" initialization, fixed in GCC 5.0 +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif +#define CV_STRUCT_INITIALIZER {} +#endif + +#else +#define CV_STRUCT_INITIALIZER {0} +#endif + + +#ifdef HAVE_IPL +# ifndef __IPL_H__ +# if defined _WIN32 +# include +# else +# include +# endif +# endif +#elif defined __IPL_H__ +# define HAVE_IPL +#endif + +#include "opencv2/core/cvdef.h" + +#ifndef SKIP_INCLUDES +#include +#include +#include +#include +#endif // SKIP_INCLUDES + +#if defined _WIN32 +# define CV_CDECL __cdecl +# define CV_STDCALL __stdcall +#else +# define CV_CDECL +# define CV_STDCALL +#endif + +#ifndef CV_DEFAULT +# ifdef __cplusplus +# define CV_DEFAULT(val) = val +# else +# define CV_DEFAULT(val) +# endif +#endif + +#ifndef CV_EXTERN_C_FUNCPTR +# ifdef __cplusplus +# define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } +# else +# define CV_EXTERN_C_FUNCPTR(x) typedef x +# endif +#endif + +#ifndef CVAPI +# define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL +#endif + +#ifndef CV_IMPL +# define CV_IMPL CV_EXTERN_C +#endif + +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif + +/** @addtogroup core_c + @{ +*/ + +/** @brief This is the "metatype" used *only* as a function parameter. + +It denotes that the function accepts arrays of multiple types, such as IplImage*, CvMat* or even +CvSeq* sometimes. The particular array type is determined at runtime by analyzing the first 4 +bytes of the header. In C++ interface the role of CvArr is played by InputArray and OutputArray. + */ +typedef void CvArr; + +typedef int CVStatus; + +/** @see cv::Error::Code */ +enum { + CV_StsOk= 0, /**< everything is ok */ + CV_StsBackTrace= -1, /**< pseudo error for back trace */ + CV_StsError= -2, /**< unknown /unspecified error */ + CV_StsInternal= -3, /**< internal error (bad state) */ + CV_StsNoMem= -4, /**< insufficient memory */ + CV_StsBadArg= -5, /**< function arg/param is bad */ + CV_StsBadFunc= -6, /**< unsupported function */ + CV_StsNoConv= -7, /**< iter. didn't converge */ + CV_StsAutoTrace= -8, /**< tracing */ + CV_HeaderIsNull= -9, /**< image header is NULL */ + CV_BadImageSize= -10, /**< image size is invalid */ + CV_BadOffset= -11, /**< offset is invalid */ + CV_BadDataPtr= -12, /**/ + CV_BadStep= -13, /**< image step is wrong, this may happen for a non-continuous matrix */ + CV_BadModelOrChSeq= -14, /**/ + CV_BadNumChannels= -15, /**< bad number of channels, for example, some functions accept only single channel matrices */ + CV_BadNumChannel1U= -16, /**/ + CV_BadDepth= -17, /**< input image depth is not supported by the function */ + CV_BadAlphaChannel= -18, /**/ + CV_BadOrder= -19, /**< number of dimensions is out of range */ + CV_BadOrigin= -20, /**< incorrect input origin */ + CV_BadAlign= -21, /**< incorrect input align */ + CV_BadCallBack= -22, /**/ + CV_BadTileSize= -23, /**/ + CV_BadCOI= -24, /**< input COI is not supported */ + CV_BadROISize= -25, /**< incorrect input roi */ + CV_MaskIsTiled= -26, /**/ + CV_StsNullPtr= -27, /**< null pointer */ + CV_StsVecLengthErr= -28, /**< incorrect vector length */ + CV_StsFilterStructContentErr= -29, /**< incorrect filter structure content */ + CV_StsKernelStructContentErr= -30, /**< incorrect transform kernel content */ + CV_StsFilterOffsetErr= -31, /**< incorrect filter offset value */ + CV_StsBadSize= -201, /**< the input/output structure size is incorrect */ + CV_StsDivByZero= -202, /**< division by zero */ + CV_StsInplaceNotSupported= -203, /**< in-place operation is not supported */ + CV_StsObjectNotFound= -204, /**< request can't be completed */ + CV_StsUnmatchedFormats= -205, /**< formats of input/output arrays differ */ + CV_StsBadFlag= -206, /**< flag is wrong or not supported */ + CV_StsBadPoint= -207, /**< bad CvPoint */ + CV_StsBadMask= -208, /**< bad format of mask (neither 8uC1 nor 8sC1)*/ + CV_StsUnmatchedSizes= -209, /**< sizes of input/output structures do not match */ + CV_StsUnsupportedFormat= -210, /**< the data format/type is not supported by the function*/ + CV_StsOutOfRange= -211, /**< some of parameters are out of range */ + CV_StsParseError= -212, /**< invalid syntax/structure of the parsed file */ + CV_StsNotImplemented= -213, /**< the requested function/feature is not implemented */ + CV_StsBadMemBlock= -214, /**< an allocated block has been corrupted */ + CV_StsAssert= -215, /**< assertion failed */ + CV_GpuNotSupported= -216, /**< no CUDA support */ + CV_GpuApiCallError= -217, /**< GPU API call error */ + CV_OpenGlNotSupported= -218, /**< no OpenGL support */ + CV_OpenGlApiCallError= -219, /**< OpenGL API call error */ + CV_OpenCLApiCallError= -220, /**< OpenCL API call error */ + CV_OpenCLDoubleNotSupported= -221, + CV_OpenCLInitError= -222, /**< OpenCL initialization error */ + CV_OpenCLNoAMDBlasFft= -223 +}; + +/****************************************************************************************\ +* Common macros and inline functions * +\****************************************************************************************/ + +#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t)) + +/** min & max without jumps */ +#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1))) + +#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1))) + +/** absolute value without jumps */ +#ifndef __cplusplus +# define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0)) +#else +# define CV_IABS(a) abs(a) +#endif +#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b))) +#define CV_SIGN(a) CV_CMP((a),0) + +#define cvInvSqrt(value) ((float)(1./sqrt(value))) +#define cvSqrt(value) ((float)sqrt(value)) + + +/*************** Random number generation *******************/ + +typedef uint64 CvRNG; + +#define CV_RNG_COEFF 4164903690U + +/** @brief Initializes a random number generator state. + +The function initializes a random number generator and returns the state. The pointer to the state +can be then passed to the cvRandInt, cvRandReal and cvRandArr functions. In the current +implementation a multiply-with-carry generator is used. +@param seed 64-bit value used to initiate a random sequence +@sa the C++ class RNG replaced CvRNG. + */ +CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1)) +{ + CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1; + return rng; +} + +/** @brief Returns a 32-bit unsigned integer and updates RNG. + +The function returns a uniformly-distributed random 32-bit unsigned integer and updates the RNG +state. It is similar to the rand() function from the C runtime library, except that OpenCV functions +always generates a 32-bit random number, regardless of the platform. +@param rng CvRNG state initialized by cvRNG. + */ +CV_INLINE unsigned cvRandInt( CvRNG* rng ) +{ + uint64 temp = *rng; + temp = (uint64)(unsigned)temp*CV_RNG_COEFF + (temp >> 32); + *rng = temp; + return (unsigned)temp; +} + +/** @brief Returns a floating-point random number and updates RNG. + +The function returns a uniformly-distributed random floating-point number between 0 and 1 (1 is not +included). +@param rng RNG state initialized by cvRNG + */ +CV_INLINE double cvRandReal( CvRNG* rng ) +{ + return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */; +} + +/****************************************************************************************\ +* Image type (IplImage) * +\****************************************************************************************/ + +#ifndef HAVE_IPL + +/* + * The following definitions (until #endif) + * is an extract from IPL headers. + * Copyright (c) 1995 Intel Corporation. + */ +#define IPL_DEPTH_SIGN 0x80000000 + +#define IPL_DEPTH_1U 1 +#define IPL_DEPTH_8U 8 +#define IPL_DEPTH_16U 16 +#define IPL_DEPTH_32F 32 + +#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8) +#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16) +#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32) + +#define IPL_DATA_ORDER_PIXEL 0 +#define IPL_DATA_ORDER_PLANE 1 + +#define IPL_ORIGIN_TL 0 +#define IPL_ORIGIN_BL 1 + +#define IPL_ALIGN_4BYTES 4 +#define IPL_ALIGN_8BYTES 8 +#define IPL_ALIGN_16BYTES 16 +#define IPL_ALIGN_32BYTES 32 + +#define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES +#define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES + +#define IPL_BORDER_CONSTANT 0 +#define IPL_BORDER_REPLICATE 1 +#define IPL_BORDER_REFLECT 2 +#define IPL_BORDER_WRAP 3 + +#ifdef __cplusplus +typedef struct _IplImage IplImage; +CV_EXPORTS _IplImage cvIplImage(const cv::Mat& m); +#endif + +/** The IplImage is taken from the Intel Image Processing Library, in which the format is native. OpenCV +only supports a subset of possible IplImage formats, as outlined in the parameter list above. + +In addition to the above restrictions, OpenCV handles ROIs differently. OpenCV functions require +that the image size or ROI size of all source and destination images match exactly. On the other +hand, the Intel Image Processing Library processes the area of intersection between the source and +destination images (or ROIs), allowing them to vary independently. +*/ +typedef struct +_IplImage +{ + int nSize; /**< sizeof(IplImage) */ + int ID; /**< version (=0)*/ + int nChannels; /**< Most of OpenCV functions support 1,2,3 or 4 channels */ + int alphaChannel; /**< Ignored by OpenCV */ + int depth; /**< Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, + IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported. */ + char colorModel[4]; /**< Ignored by OpenCV */ + char channelSeq[4]; /**< ditto */ + int dataOrder; /**< 0 - interleaved color channels, 1 - separate color channels. + cvCreateImage can only create interleaved images */ + int origin; /**< 0 - top-left origin, + 1 - bottom-left origin (Windows bitmaps style). */ + int align; /**< Alignment of image rows (4 or 8). + OpenCV ignores it and uses widthStep instead. */ + int width; /**< Image width in pixels. */ + int height; /**< Image height in pixels. */ + struct _IplROI *roi; /**< Image ROI. If NULL, the whole image is selected. */ + struct _IplImage *maskROI; /**< Must be NULL. */ + void *imageId; /**< " " */ + struct _IplTileInfo *tileInfo; /**< " " */ + int imageSize; /**< Image data size in bytes + (==image->height*image->widthStep + in case of interleaved data)*/ + char *imageData; /**< Pointer to aligned image data. */ + int widthStep; /**< Size of aligned image row in bytes. */ + int BorderMode[4]; /**< Ignored by OpenCV. */ + int BorderConst[4]; /**< Ditto. */ + char *imageDataOrigin; /**< Pointer to very origin of image data + (not necessarily aligned) - + needed for correct deallocation */ + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + _IplImage() + { + memset(this, 0, sizeof(*this)); // valid for POD structure + nSize = sizeof(IplImage); + } + _IplImage(const cv::Mat& m) { *this = cvIplImage(m); } +#endif +} +IplImage; + +CV_INLINE IplImage cvIplImage() +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + IplImage self = CV_STRUCT_INITIALIZER; self.nSize = sizeof(IplImage); return self; +#else + return _IplImage(); +#endif +} + +typedef struct _IplTileInfo IplTileInfo; + +typedef struct _IplROI +{ + int coi; /**< 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/ + int xOffset; + int yOffset; + int width; + int height; +} +IplROI; + +typedef struct _IplConvKernel +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + int *values; + int nShiftR; +} +IplConvKernel; + +typedef struct _IplConvKernelFP +{ + int nCols; + int nRows; + int anchorX; + int anchorY; + float *values; +} +IplConvKernelFP; + +#define IPL_IMAGE_HEADER 1 +#define IPL_IMAGE_DATA 2 +#define IPL_IMAGE_ROI 4 + +#endif/*HAVE_IPL*/ + +/** extra border mode */ +#define IPL_BORDER_REFLECT_101 4 +#define IPL_BORDER_TRANSPARENT 5 + +#define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage)) +#define CV_TYPE_NAME_IMAGE "opencv-image" + +#define CV_IS_IMAGE_HDR(img) \ + ((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage)) + +#define CV_IS_IMAGE(img) \ + (CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->imageData != NULL) + +/** for storing double-precision + floating point data in IplImage's */ +#define IPL_DEPTH_64F 64 + +/** get reference to pixel at (col,row), + for multi-channel images (col) should be multiplied by number of channels */ +#define CV_IMAGE_ELEM( image, elemtype, row, col ) \ + (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)]) + +/****************************************************************************************\ +* Matrix type (CvMat) * +\****************************************************************************************/ + +#define CV_AUTO_STEP 0x7fffffff +#define CV_WHOLE_ARR cvSlice( 0, 0x3fffffff ) + +#define CV_MAGIC_MASK 0xFFFF0000 +#define CV_MAT_MAGIC_VAL 0x42420000 +#define CV_TYPE_NAME_MAT "opencv-matrix" + +#ifdef __cplusplus +typedef struct CvMat CvMat; +CV_INLINE CvMat cvMat(const cv::Mat& m); +#endif + +/** Matrix elements are stored row by row. Element (i, j) (i - 0-based row index, j - 0-based column +index) of a matrix can be retrieved or modified using CV_MAT_ELEM macro: + + uchar pixval = CV_MAT_ELEM(grayimg, uchar, i, j) + CV_MAT_ELEM(cameraMatrix, float, 0, 2) = image.width*0.5f; + +To access multiple-channel matrices, you can use +CV_MAT_ELEM(matrix, type, i, j\*nchannels + channel_idx). + +@deprecated CvMat is now obsolete; consider using Mat instead. + */ +typedef struct CvMat +{ + int type; + int step; + + /* for internal use only */ + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + short* s; + int* i; + float* fl; + double* db; + } data; + +#ifdef __cplusplus + union + { + int rows; + int height; + }; + + union + { + int cols; + int width; + }; +#else + int rows; + int cols; +#endif + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvMat() {} + CvMat(const cv::Mat& m) { *this = cvMat(m); } +#endif +} +CvMat; + + +#define CV_IS_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ + ((const CvMat*)(mat))->cols > 0 && ((const CvMat*)(mat))->rows > 0) + +#define CV_IS_MAT_HDR_Z(mat) \ + ((mat) != NULL && \ + (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ + ((const CvMat*)(mat))->cols >= 0 && ((const CvMat*)(mat))->rows >= 0) + +#define CV_IS_MAT(mat) \ + (CV_IS_MAT_HDR(mat) && ((const CvMat*)(mat))->data.ptr != NULL) + +#define CV_IS_MASK_ARR(mat) \ + (((mat)->type & (CV_MAT_TYPE_MASK & ~CV_8SC1)) == 0) + +#define CV_ARE_TYPES_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_TYPE_MASK) == 0) + +#define CV_ARE_CNS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_CN_MASK) == 0) + +#define CV_ARE_DEPTHS_EQ(mat1, mat2) \ + ((((mat1)->type ^ (mat2)->type) & CV_MAT_DEPTH_MASK) == 0) + +#define CV_ARE_SIZES_EQ(mat1, mat2) \ + ((mat1)->rows == (mat2)->rows && (mat1)->cols == (mat2)->cols) + +#define CV_IS_MAT_CONST(mat) \ + (((mat)->rows|(mat)->cols) == 1) + +#define IPL2CV_DEPTH(depth) \ + ((((CV_8U)+(CV_16U<<4)+(CV_32F<<8)+(CV_64F<<16)+(CV_8S<<20)+ \ + (CV_16S<<24)+(CV_32S<<28)) >> ((((depth) & 0xF0) >> 2) + \ + (((depth) & IPL_DEPTH_SIGN) ? 20 : 0))) & 15) + +/** Inline constructor. No data is allocated internally!!! + * (Use together with cvCreateData, or use cvCreateMat instead to + * get a matrix with allocated data): + */ +CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)) +{ + CvMat m; + + assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); + type = CV_MAT_TYPE(type); + m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; + m.cols = cols; + m.rows = rows; + m.step = m.cols*CV_ELEM_SIZE(type); + m.data.ptr = (uchar*)data; + m.refcount = NULL; + m.hdr_refcount = 0; + + return m; +} + +#ifdef __cplusplus + +CV_INLINE CvMat cvMat(const cv::Mat& m) +{ + CvMat self; + CV_DbgAssert(m.dims <= 2); + self = cvMat(m.rows, m.dims == 1 ? 1 : m.cols, m.type(), m.data); + self.step = (int)m.step[0]; + self.type = (self.type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG); + return self; +} +CV_INLINE CvMat cvMat() +{ +#if !defined(CV__ENABLE_C_API_CTORS) + CvMat self = CV_STRUCT_INITIALIZER; return self; +#else + return CvMat(); +#endif +} +CV_INLINE CvMat cvMat(const CvMat& m) +{ +#if !defined(CV__ENABLE_C_API_CTORS) + CvMat self = CV_STRUCT_INITIALIZER; memcpy(&self, &m, sizeof(self)); return self; +#else + return CvMat(m); +#endif +} + +#endif // __cplusplus + + +#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \ + (assert( (unsigned)(row) < (unsigned)(mat).rows && \ + (unsigned)(col) < (unsigned)(mat).cols ), \ + (mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col)) + +#define CV_MAT_ELEM_PTR( mat, row, col ) \ + CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) ) + +#define CV_MAT_ELEM( mat, elemtype, row, col ) \ + (*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype))) + +/** @brief Returns the particular element of single-channel floating-point matrix. + +The function is a fast replacement for cvGetReal2D in the case of single-channel floating-point +matrices. It is faster because it is inline, it does fewer checks for array type and array element +type, and it checks for the row and column ranges only in debug mode. +@param mat Input matrix +@param row The zero-based index of row +@param col The zero-based index of column + */ +CV_INLINE double cvmGet( const CvMat* mat, int row, int col ) +{ + int type; + + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + return ((float*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col]; + else + { + assert( type == CV_64FC1 ); + return ((double*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col]; + } +} + +/** @brief Sets a specific element of a single-channel floating-point matrix. + +The function is a fast replacement for cvSetReal2D in the case of single-channel floating-point +matrices. It is faster because it is inline, it does fewer checks for array type and array element +type, and it checks for the row and column ranges only in debug mode. +@param mat The matrix +@param row The zero-based index of row +@param col The zero-based index of column +@param value The new value of the matrix element + */ +CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) +{ + int type; + type = CV_MAT_TYPE(mat->type); + assert( (unsigned)row < (unsigned)mat->rows && + (unsigned)col < (unsigned)mat->cols ); + + if( type == CV_32FC1 ) + ((float*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value; + else + { + assert( type == CV_64FC1 ); + ((double*)(void*)(mat->data.ptr + (size_t)mat->step*row))[col] = value; + } +} + + +CV_INLINE int cvIplDepth( int type ) +{ + int depth = CV_MAT_DEPTH(type); + return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || + depth == CV_32S ? IPL_DEPTH_SIGN : 0); +} + + +/****************************************************************************************\ +* Multi-dimensional dense array (CvMatND) * +\****************************************************************************************/ + +#define CV_MATND_MAGIC_VAL 0x42430000 +#define CV_TYPE_NAME_MATND "opencv-nd-matrix" + +#define CV_MAX_DIM 32 + +#ifdef __cplusplus +typedef struct CvMatND CvMatND; +CV_EXPORTS CvMatND cvMatND(const cv::Mat& m); +#endif + +/** + @deprecated consider using cv::Mat instead + */ +typedef struct +CvMatND +{ + int type; + int dims; + + int* refcount; + int hdr_refcount; + + union + { + uchar* ptr; + float* fl; + double* db; + int* i; + short* s; + } data; + + struct + { + int size; + int step; + } + dim[CV_MAX_DIM]; + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvMatND() {} + CvMatND(const cv::Mat& m) { *this = cvMatND(m); } +#endif +} +CvMatND; + + +CV_INLINE CvMatND cvMatND() +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvMatND self = CV_STRUCT_INITIALIZER; return self; +#else + return CvMatND(); +#endif +} + +#define CV_IS_MATND_HDR(mat) \ + ((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL) + +#define CV_IS_MATND(mat) \ + (CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL) + + +/****************************************************************************************\ +* Multi-dimensional sparse array (CvSparseMat) * +\****************************************************************************************/ + +#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000 +#define CV_TYPE_NAME_SPARSE_MAT "opencv-sparse-matrix" + +struct CvSet; + +typedef struct CvSparseMat +{ + int type; + int dims; + int* refcount; + int hdr_refcount; + + struct CvSet* heap; + void** hashtable; + int hashsize; + int valoffset; + int idxoffset; + int size[CV_MAX_DIM]; + +#ifdef __cplusplus + CV_EXPORTS void copyToSparseMat(cv::SparseMat& m) const; +#endif +} +CvSparseMat; + +#ifdef __cplusplus +CV_EXPORTS CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m); +#endif + +#define CV_IS_SPARSE_MAT_HDR(mat) \ + ((mat) != NULL && \ + (((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL) + +#define CV_IS_SPARSE_MAT(mat) \ + CV_IS_SPARSE_MAT_HDR(mat) + +/**************** iteration through a sparse array *****************/ + +typedef struct CvSparseNode +{ + unsigned hashval; + struct CvSparseNode* next; +} +CvSparseNode; + +typedef struct CvSparseMatIterator +{ + CvSparseMat* mat; + CvSparseNode* node; + int curidx; +} +CvSparseMatIterator; + +#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset)) +#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset)) + +/****************************************************************************************\ +* Histogram * +\****************************************************************************************/ + +typedef int CvHistType; + +#define CV_HIST_MAGIC_VAL 0x42450000 +#define CV_HIST_UNIFORM_FLAG (1 << 10) + +/** indicates whether bin ranges are set already or not */ +#define CV_HIST_RANGES_FLAG (1 << 11) + +#define CV_HIST_ARRAY 0 +#define CV_HIST_SPARSE 1 +#define CV_HIST_TREE CV_HIST_SPARSE + +/** should be used as a parameter only, + it turns to CV_HIST_UNIFORM_FLAG of hist->type */ +#define CV_HIST_UNIFORM 1 + +typedef struct CvHistogram +{ + int type; + CvArr* bins; + float thresh[CV_MAX_DIM][2]; /**< For uniform histograms. */ + float** thresh2; /**< For non-uniform histograms. */ + CvMatND mat; /**< Embedded matrix header for array histograms. */ +} +CvHistogram; + +#define CV_IS_HIST( hist ) \ + ((hist) != NULL && \ + (((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \ + (hist)->bins != NULL) + +#define CV_IS_UNIFORM_HIST( hist ) \ + (((hist)->type & CV_HIST_UNIFORM_FLAG) != 0) + +#define CV_IS_SPARSE_HIST( hist ) \ + CV_IS_SPARSE_MAT((hist)->bins) + +#define CV_HIST_HAS_RANGES( hist ) \ + (((hist)->type & CV_HIST_RANGES_FLAG) != 0) + +/****************************************************************************************\ +* Other supplementary data type definitions * +\****************************************************************************************/ + +/*************************************** CvRect *****************************************/ +/** @sa Rect_ */ +typedef struct CvRect +{ + int x; + int y; + int width; + int height; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvRect() __attribute__(( warning("Non-initialized variable") )) {}; + template CvRect(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 4); + x = y = width = height = 0; + if (list.size() == 4) + { + x = list.begin()[0]; y = list.begin()[1]; width = list.begin()[2]; height = list.begin()[3]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvRect(int _x = 0, int _y = 0, int w = 0, int h = 0): x(_x), y(_y), width(w), height(h) {} + template + CvRect(const cv::Rect_<_Tp>& r): x(cv::saturate_cast(r.x)), y(cv::saturate_cast(r.y)), width(cv::saturate_cast(r.width)), height(cv::saturate_cast(r.height)) {} +#endif +#ifdef __cplusplus + template + operator cv::Rect_<_Tp>() const { return cv::Rect_<_Tp>((_Tp)x, (_Tp)y, (_Tp)width, (_Tp)height); } +#endif +} +CvRect; + +/** constructs CvRect structure. */ +CV_INLINE CvRect cvRect( int x, int y, int width, int height ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvRect r = {x, y, width, height}; +#else + CvRect r(x, y , width, height); +#endif + return r; +} +#ifdef __cplusplus +CV_INLINE CvRect cvRect(const cv::Rect& rc) { return cvRect(rc.x, rc.y, rc.width, rc.height); } +#endif + +CV_INLINE IplROI cvRectToROI( CvRect rect, int coi ) +{ + IplROI roi; + roi.xOffset = rect.x; + roi.yOffset = rect.y; + roi.width = rect.width; + roi.height = rect.height; + roi.coi = coi; + + return roi; +} + + +CV_INLINE CvRect cvROIToRect( IplROI roi ) +{ + return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height ); +} + +/*********************************** CvTermCriteria *************************************/ + +#define CV_TERMCRIT_ITER 1 +#define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER +#define CV_TERMCRIT_EPS 2 + +/** @sa TermCriteria + */ +typedef struct CvTermCriteria +{ + int type; /**< may be combination of + CV_TERMCRIT_ITER + CV_TERMCRIT_EPS */ + int max_iter; + double epsilon; +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvTermCriteria(int _type = 0, int _iter = 0, double _eps = 0) : type(_type), max_iter(_iter), epsilon(_eps) {} + CvTermCriteria(const cv::TermCriteria& t) : type(t.type), max_iter(t.maxCount), epsilon(t.epsilon) {} +#endif +#ifdef __cplusplus + operator cv::TermCriteria() const { return cv::TermCriteria(type, max_iter, epsilon); } +#endif +} +CvTermCriteria; + +CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvTermCriteria t = { type, max_iter, (float)epsilon}; +#else + CvTermCriteria t(type, max_iter, epsilon); +#endif + return t; +} +#ifdef __cplusplus +CV_INLINE CvTermCriteria cvTermCriteria(const cv::TermCriteria& t) { return cvTermCriteria(t.type, t.maxCount, t.epsilon); } +#endif + + +/******************************* CvPoint and variants ***********************************/ + +typedef struct CvPoint +{ + int x; + int y; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + x = y = 0; + if (list.size() == 2) + { + x = list.begin()[0]; y = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvPoint(int _x = 0, int _y = 0): x(_x), y(_y) {} + template + CvPoint(const cv::Point_<_Tp>& pt): x((int)pt.x), y((int)pt.y) {} +#endif +#ifdef __cplusplus + template + operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); } +#endif +} +CvPoint; + +/** constructs CvPoint structure. */ +CV_INLINE CvPoint cvPoint( int x, int y ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint p = {x, y}; +#else + CvPoint p(x, y); +#endif + return p; +} +#ifdef __cplusplus +CV_INLINE CvPoint cvPoint(const cv::Point& pt) { return cvPoint(pt.x, pt.y); } +#endif + +typedef struct CvPoint2D32f +{ + float x; + float y; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint2D32f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint2D32f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + x = y = 0; + if (list.size() == 2) + { + x = list.begin()[0]; y = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvPoint2D32f(float _x = 0, float _y = 0): x(_x), y(_y) {} + template + CvPoint2D32f(const cv::Point_<_Tp>& pt): x((float)pt.x), y((float)pt.y) {} +#endif +#ifdef __cplusplus + template + operator cv::Point_<_Tp>() const { return cv::Point_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y)); } +#endif +} +CvPoint2D32f; + +/** constructs CvPoint2D32f structure. */ +CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint2D32f p = { (float)x, (float)y }; +#else + CvPoint2D32f p((float)x, (float)y); +#endif + return p; +} + +#ifdef __cplusplus +template +CvPoint2D32f cvPoint2D32f(const cv::Point_<_Tp>& pt) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint2D32f p = { (float)pt.x, (float)pt.y }; +#else + CvPoint2D32f p((float)pt.x, (float)pt.y); +#endif + return p; +} +#endif + +/** converts CvPoint to CvPoint2D32f. */ +CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point ) +{ + return cvPoint2D32f( (float)point.x, (float)point.y ); +} + +/** converts CvPoint2D32f to CvPoint. */ +CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint ipt = { cvRound(point.x), cvRound(point.y) }; +#else + CvPoint ipt(cvRound(point.x), cvRound(point.y)); +#endif + return ipt; +} + + +typedef struct CvPoint3D32f +{ + float x; + float y; + float z; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint3D32f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint3D32f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 3); + x = y = z = 0; + if (list.size() == 3) + { + x = list.begin()[0]; y = list.begin()[1]; z = list.begin()[2]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvPoint3D32f(float _x = 0, float _y = 0, float _z = 0): x(_x), y(_y), z(_z) {} + template + CvPoint3D32f(const cv::Point3_<_Tp>& pt): x((float)pt.x), y((float)pt.y), z((float)pt.z) {} +#endif +#ifdef __cplusplus + template + operator cv::Point3_<_Tp>() const { return cv::Point3_<_Tp>(cv::saturate_cast<_Tp>(x), cv::saturate_cast<_Tp>(y), cv::saturate_cast<_Tp>(z)); } +#endif +} +CvPoint3D32f; + +/** constructs CvPoint3D32f structure. */ +CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint3D32f p = { (float)x, (float)y, (float)z }; +#else + CvPoint3D32f p((float)x, (float)y, (float)z); +#endif + return p; +} + +#ifdef __cplusplus +template +CvPoint3D32f cvPoint3D32f(const cv::Point3_<_Tp>& pt) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvPoint3D32f p = { (float)pt.x, (float)pt.y, (float)pt.z }; +#else + CvPoint3D32f p((float)pt.x, (float)pt.y, (float)pt.z); +#endif + return p; +} +#endif + + +typedef struct CvPoint2D64f +{ + double x; + double y; +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint2D64f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint2D64f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + x = y = 0; + if (list.size() == 2) + { + x = list.begin()[0]; y = list.begin()[1]; + } + }; +#endif +} +CvPoint2D64f; + +/** constructs CvPoint2D64f structure.*/ +CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y ) +{ + CvPoint2D64f p = { x, y }; + return p; +} + + +typedef struct CvPoint3D64f +{ + double x; + double y; + double z; +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvPoint3D64f() __attribute__(( warning("Non-initialized variable") )) {} + template CvPoint3D64f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 3); + x = y = z = 0; + if (list.size() == 3) + { + x = list.begin()[0]; y = list.begin()[1]; z = list.begin()[2]; + } + }; +#endif +} +CvPoint3D64f; + +/** constructs CvPoint3D64f structure. */ +CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z ) +{ + CvPoint3D64f p = { x, y, z }; + return p; +} + + +/******************************** CvSize's & CvBox **************************************/ + +typedef struct CvSize +{ + int width; + int height; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvSize() __attribute__(( warning("Non-initialized variable") )) {} + template CvSize(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + width = 0; height = 0; + if (list.size() == 2) + { + width = list.begin()[0]; height = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvSize(int w = 0, int h = 0): width(w), height(h) {} + template + CvSize(const cv::Size_<_Tp>& sz): width(cv::saturate_cast(sz.width)), height(cv::saturate_cast(sz.height)) {} +#endif +#ifdef __cplusplus + template + operator cv::Size_<_Tp>() const { return cv::Size_<_Tp>(cv::saturate_cast<_Tp>(width), cv::saturate_cast<_Tp>(height)); } +#endif +} +CvSize; + +/** constructs CvSize structure. */ +CV_INLINE CvSize cvSize( int width, int height ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize s = { width, height }; +#else + CvSize s(width, height); +#endif + return s; +} + +#ifdef __cplusplus +CV_INLINE CvSize cvSize(const cv::Size& sz) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize s = { sz.width, sz.height }; +#else + CvSize s(sz.width, sz.height); +#endif + return s; +} +#endif + +typedef struct CvSize2D32f +{ + float width; + float height; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvSize2D32f() __attribute__(( warning("Non-initialized variable") )) {} + template CvSize2D32f(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + width = 0; height = 0; + if (list.size() == 2) + { + width = list.begin()[0]; height = list.begin()[1]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvSize2D32f(float w = 0, float h = 0): width(w), height(h) {} + template + CvSize2D32f(const cv::Size_<_Tp>& sz): width(cv::saturate_cast(sz.width)), height(cv::saturate_cast(sz.height)) {} +#endif +#ifdef __cplusplus + template + operator cv::Size_<_Tp>() const { return cv::Size_<_Tp>(cv::saturate_cast<_Tp>(width), cv::saturate_cast<_Tp>(height)); } +#endif +} +CvSize2D32f; + +/** constructs CvSize2D32f structure. */ +CV_INLINE CvSize2D32f cvSize2D32f( double width, double height ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize2D32f s = { (float)width, (float)height }; +#else + CvSize2D32f s((float)width, (float)height); +#endif + return s; +} +#ifdef __cplusplus +template +CvSize2D32f cvSize2D32f(const cv::Size_<_Tp>& sz) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvSize2D32f s = { (float)sz.width, (float)sz.height }; +#else + CvSize2D32f s((float)sz.width, (float)sz.height); +#endif + return s; +} +#endif + +/** @sa RotatedRect + */ +typedef struct CvBox2D +{ + CvPoint2D32f center; /**< Center of the box. */ + CvSize2D32f size; /**< Box width and length. */ + float angle; /**< Angle between the horizontal axis */ + /**< and the first side (i.e. length) in degrees */ + +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) : center(c), size(s), angle(a) {} + CvBox2D(const cv::RotatedRect& rr) : center(rr.center), size(rr.size), angle(rr.angle) {} +#endif +#ifdef __cplusplus + operator cv::RotatedRect() const { return cv::RotatedRect(center, size, angle); } +#endif +} +CvBox2D; + + +#ifdef __cplusplus +CV_INLINE CvBox2D cvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) +{ + CvBox2D self; + self.center = c; + self.size = s; + self.angle = a; + return self; +} +CV_INLINE CvBox2D cvBox2D(const cv::RotatedRect& rr) +{ + CvBox2D self; + self.center = cvPoint2D32f(rr.center); + self.size = cvSize2D32f(rr.size); + self.angle = rr.angle; + return self; +} +#endif + + +/** Line iterator state: */ +typedef struct CvLineIterator +{ + /** Pointer to the current point: */ + uchar* ptr; + + /* Bresenham algorithm state: */ + int err; + int plus_delta; + int minus_delta; + int plus_step; + int minus_step; +} +CvLineIterator; + + + +/************************************* CvSlice ******************************************/ +#define CV_WHOLE_SEQ_END_INDEX 0x3fffffff +#define CV_WHOLE_SEQ cvSlice(0, CV_WHOLE_SEQ_END_INDEX) + +typedef struct CvSlice +{ + int start_index, end_index; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvSlice() __attribute__(( warning("Non-initialized variable") )) {} + template CvSlice(const std::initializer_list<_Tp> list) + { + CV_Assert(list.size() == 0 || list.size() == 2); + start_index = end_index = 0; + if (list.size() == 2) + { + start_index = list.begin()[0]; end_index = list.begin()[1]; + } + }; +#endif +#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) && !defined(__CUDACC__) + CvSlice(int start = 0, int end = 0) : start_index(start), end_index(end) {} + CvSlice(const cv::Range& r) { *this = (r.start != INT_MIN && r.end != INT_MAX) ? CvSlice(r.start, r.end) : CvSlice(0, CV_WHOLE_SEQ_END_INDEX); } + operator cv::Range() const { return (start_index == 0 && end_index == CV_WHOLE_SEQ_END_INDEX ) ? cv::Range::all() : cv::Range(start_index, end_index); } +#endif +} +CvSlice; + +CV_INLINE CvSlice cvSlice( int start, int end ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) && !defined(__CUDACC__)) + CvSlice slice = { start, end }; +#else + CvSlice slice(start, end); +#endif + return slice; +} + +#if defined(__cplusplus) +CV_INLINE CvSlice cvSlice(const cv::Range& r) +{ + CvSlice slice = (r.start != INT_MIN && r.end != INT_MAX) ? cvSlice(r.start, r.end) : cvSlice(0, CV_WHOLE_SEQ_END_INDEX); + return slice; +} +#endif + + +/************************************* CvScalar *****************************************/ +/** @sa Scalar_ + */ +typedef struct CvScalar +{ + double val[4]; + +#ifdef CV__VALIDATE_UNUNITIALIZED_VARS + CvScalar() __attribute__(( warning("Non-initialized variable") )) {} + CvScalar(const std::initializer_list list) + { + CV_Assert(list.size() == 0 || list.size() == 4); + val[0] = val[1] = val[2] = val[3] = 0; + if (list.size() == 4) + { + val[0] = list.begin()[0]; val[1] = list.begin()[1]; val[2] = list.begin()[2]; val[3] = list.begin()[3]; + } + }; +#elif defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) + CvScalar() {} + CvScalar(double d0, double d1 = 0, double d2 = 0, double d3 = 0) { val[0] = d0; val[1] = d1; val[2] = d2; val[3] = d3; } + template + CvScalar(const cv::Scalar_<_Tp>& s) { val[0] = s.val[0]; val[1] = s.val[1]; val[2] = s.val[2]; val[3] = s.val[3]; } + template + CvScalar(const cv::Vec<_Tp, cn>& v) + { + int i; + for( i = 0; i < (cn < 4 ? cn : 4); i++ ) val[i] = v.val[i]; + for( ; i < 4; i++ ) val[i] = 0; + } +#endif +#ifdef __cplusplus + template + operator cv::Scalar_<_Tp>() const { return cv::Scalar_<_Tp>(cv::saturate_cast<_Tp>(val[0]), cv::saturate_cast<_Tp>(val[1]), cv::saturate_cast<_Tp>(val[2]), cv::saturate_cast<_Tp>(val[3])); } +#endif +} +CvScalar; + +CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0), + double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0)) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = val0; scalar.val[1] = val1; + scalar.val[2] = val2; scalar.val[3] = val3; + return scalar; +} + +#ifdef __cplusplus +CV_INLINE CvScalar cvScalar() +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; + return scalar; +} +CV_INLINE CvScalar cvScalar(const cv::Scalar& s) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = s.val[0]; + scalar.val[1] = s.val[1]; + scalar.val[2] = s.val[2]; + scalar.val[3] = s.val[3]; + return scalar; +} +#endif + +CV_INLINE CvScalar cvRealScalar( double val0 ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = val0; + scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; + return scalar; +} + +CV_INLINE CvScalar cvScalarAll( double val0123 ) +{ +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) + CvScalar scalar = CV_STRUCT_INITIALIZER; +#else + CvScalar scalar; +#endif + scalar.val[0] = val0123; + scalar.val[1] = val0123; + scalar.val[2] = val0123; + scalar.val[3] = val0123; + return scalar; +} + +/****************************************************************************************\ +* Dynamic Data structures * +\****************************************************************************************/ + +/******************************** Memory storage ****************************************/ + +typedef struct CvMemBlock +{ + struct CvMemBlock* prev; + struct CvMemBlock* next; +} +CvMemBlock; + +#define CV_STORAGE_MAGIC_VAL 0x42890000 + +typedef struct CvMemStorage +{ + int signature; + CvMemBlock* bottom; /**< First allocated block. */ + CvMemBlock* top; /**< Current memory block - top of the stack. */ + struct CvMemStorage* parent; /**< We get new blocks from parent as needed. */ + int block_size; /**< Block size. */ + int free_space; /**< Remaining free space in current block. */ +} +CvMemStorage; + +#define CV_IS_STORAGE(storage) \ + ((storage) != NULL && \ + (((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) == CV_STORAGE_MAGIC_VAL) + + +typedef struct CvMemStoragePos +{ + CvMemBlock* top; + int free_space; +} +CvMemStoragePos; + + +/*********************************** Sequence *******************************************/ + +typedef struct CvSeqBlock +{ + struct CvSeqBlock* prev; /**< Previous sequence block. */ + struct CvSeqBlock* next; /**< Next sequence block. */ + int start_index; /**< Index of the first element in the block + */ + /**< sequence->first->start_index. */ + int count; /**< Number of elements in the block. */ + schar* data; /**< Pointer to the first element of the block. */ +} +CvSeqBlock; + + +#define CV_TREE_NODE_FIELDS(node_type) \ + int flags; /**< Miscellaneous flags. */ \ + int header_size; /**< Size of sequence header. */ \ + struct node_type* h_prev; /**< Previous sequence. */ \ + struct node_type* h_next; /**< Next sequence. */ \ + struct node_type* v_prev; /**< 2nd previous sequence. */ \ + struct node_type* v_next /**< 2nd next sequence. */ + +/** + Read/Write sequence. + Elements can be dynamically inserted to or deleted from the sequence. +*/ +#define CV_SEQUENCE_FIELDS() \ + CV_TREE_NODE_FIELDS(CvSeq); \ + int total; /**< Total number of elements. */ \ + int elem_size; /**< Size of sequence element in bytes. */ \ + schar* block_max; /**< Maximal bound of the last block. */ \ + schar* ptr; /**< Current write pointer. */ \ + int delta_elems; /**< Grow seq this many at a time. */ \ + CvMemStorage* storage; /**< Where the seq is stored. */ \ + CvSeqBlock* free_blocks; /**< Free blocks list. */ \ + CvSeqBlock* first; /**< Pointer to the first sequence block. */ + +typedef struct CvSeq +{ + CV_SEQUENCE_FIELDS() +} +CvSeq; + +#define CV_TYPE_NAME_SEQ "opencv-sequence" +#define CV_TYPE_NAME_SEQ_TREE "opencv-sequence-tree" + +/*************************************** Set ********************************************/ +/** @brief Set + Order is not preserved. There can be gaps between sequence elements. + After the element has been inserted it stays in the same place all the time. + The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists. +*/ +#define CV_SET_ELEM_FIELDS(elem_type) \ + int flags; \ + struct elem_type* next_free; + +typedef struct CvSetElem +{ + CV_SET_ELEM_FIELDS(CvSetElem) +} +CvSetElem; + +#define CV_SET_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvSetElem* free_elems; \ + int active_count; + +typedef struct CvSet +{ + CV_SET_FIELDS() +} +CvSet; + + +#define CV_SET_ELEM_IDX_MASK ((1 << 26) - 1) +#define CV_SET_ELEM_FREE_FLAG (1 << (sizeof(int)*8-1)) + +/** Checks whether the element pointed by ptr belongs to a set or not */ +#define CV_IS_SET_ELEM( ptr ) (((CvSetElem*)(ptr))->flags >= 0) + +/************************************* Graph ********************************************/ + +/** @name Graph + +We represent a graph as a set of vertices. Vertices contain their adjacency lists (more exactly, +pointers to first incoming or outcoming edge (or 0 if isolated vertex)). Edges are stored in +another set. There is a singly-linked list of incoming/outcoming edges for each vertex. + +Each edge consists of: + +- Two pointers to the starting and ending vertices (vtx[0] and vtx[1] respectively). + + A graph may be oriented or not. In the latter case, edges between vertex i to vertex j are not +distinguished during search operations. + +- Two pointers to next edges for the starting and ending vertices, where next[0] points to the +next edge in the vtx[0] adjacency list and next[1] points to the next edge in the vtx[1] +adjacency list. + +@see CvGraphEdge, CvGraphVtx, CvGraphVtx2D, CvGraph +@{ +*/ +#define CV_GRAPH_EDGE_FIELDS() \ + int flags; \ + float weight; \ + struct CvGraphEdge* next[2]; \ + struct CvGraphVtx* vtx[2]; + + +#define CV_GRAPH_VERTEX_FIELDS() \ + int flags; \ + struct CvGraphEdge* first; + + +typedef struct CvGraphEdge +{ + CV_GRAPH_EDGE_FIELDS() +} +CvGraphEdge; + +typedef struct CvGraphVtx +{ + CV_GRAPH_VERTEX_FIELDS() +} +CvGraphVtx; + +typedef struct CvGraphVtx2D +{ + CV_GRAPH_VERTEX_FIELDS() + CvPoint2D32f* ptr; +} +CvGraphVtx2D; + +/** + Graph is "derived" from the set (this is set a of vertices) + and includes another set (edges) +*/ +#define CV_GRAPH_FIELDS() \ + CV_SET_FIELDS() \ + CvSet* edges; + +typedef struct CvGraph +{ + CV_GRAPH_FIELDS() +} +CvGraph; + +#define CV_TYPE_NAME_GRAPH "opencv-graph" + +/** @} */ + +/*********************************** Chain/Contour *************************************/ + +typedef struct CvChain +{ + CV_SEQUENCE_FIELDS() + CvPoint origin; +} +CvChain; + +#define CV_CONTOUR_FIELDS() \ + CV_SEQUENCE_FIELDS() \ + CvRect rect; \ + int color; \ + int reserved[3]; + +typedef struct CvContour +{ + CV_CONTOUR_FIELDS() +} +CvContour; + +typedef CvContour CvPoint2DSeq; + +/****************************************************************************************\ +* Sequence types * +\****************************************************************************************/ + +#define CV_SEQ_MAGIC_VAL 0x42990000 + +#define CV_IS_SEQ(seq) \ + ((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL) + +#define CV_SET_MAGIC_VAL 0x42980000 +#define CV_IS_SET(set) \ + ((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL) + +#define CV_SEQ_ELTYPE_BITS 12 +#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1) + +#define CV_SEQ_ELTYPE_POINT CV_32SC2 /**< (x,y) */ +#define CV_SEQ_ELTYPE_CODE CV_8UC1 /**< freeman code: 0..7 */ +#define CV_SEQ_ELTYPE_GENERIC 0 +#define CV_SEQ_ELTYPE_PTR CV_MAKE_TYPE(CV_8U, 8 /*sizeof(void*)*/) +#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /**< &(x,y) */ +#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /**< #(x,y) */ +#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /**< &next_o, &next_d, &vtx_o, &vtx_d */ +#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /**< first_edge, &(x,y) */ +#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /**< vertex of the binary tree */ +#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /**< connected component */ +#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /**< (x,y,z) */ + +#define CV_SEQ_KIND_BITS 2 +#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<flags & CV_SEQ_ELTYPE_MASK) +#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK ) + +/** flag checking */ +#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC)) + +#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE) +#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0) +#define CV_IS_SEQ_CONVEX( seq ) 0 +#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0) +#define CV_IS_SEQ_SIMPLE( seq ) 1 + +/** type checking macros */ +#define CV_IS_SEQ_POINT_SET( seq ) \ + ((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2)) + +#define CV_IS_SEQ_POINT_SUBSET( seq ) \ + (CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT) + +#define CV_IS_SEQ_POLYLINE( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq)) + +#define CV_IS_SEQ_POLYGON( seq ) \ + (CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq)) + +#define CV_IS_SEQ_CHAIN( seq ) \ + (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1) + +#define CV_IS_SEQ_CONTOUR( seq ) \ + (CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq))) + +#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \ + (CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq )) + +#define CV_IS_SEQ_POLYGON_TREE( seq ) \ + (CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \ + CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE ) + +#define CV_IS_GRAPH( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH) + +#define CV_IS_GRAPH_ORIENTED( seq ) \ + (((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0) + +#define CV_IS_SUBDIV2D( seq ) \ + (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D) + +/****************************************************************************************/ +/* Sequence writer & reader */ +/****************************************************************************************/ + +#define CV_SEQ_WRITER_FIELDS() \ + int header_size; \ + CvSeq* seq; /**< the sequence written */ \ + CvSeqBlock* block; /**< current block */ \ + schar* ptr; /**< pointer to free space */ \ + schar* block_min; /**< pointer to the beginning of block*/\ + schar* block_max; /**< pointer to the end of block */ + +typedef struct CvSeqWriter +{ + CV_SEQ_WRITER_FIELDS() +} +CvSeqWriter; + + +#define CV_SEQ_READER_FIELDS() \ + int header_size; \ + CvSeq* seq; /**< sequence, beign read */ \ + CvSeqBlock* block; /**< current block */ \ + schar* ptr; /**< pointer to element be read next */ \ + schar* block_min; /**< pointer to the beginning of block */\ + schar* block_max; /**< pointer to the end of block */ \ + int delta_index;/**< = seq->first->start_index */ \ + schar* prev_elem; /**< pointer to previous element */ + +typedef struct CvSeqReader +{ + CV_SEQ_READER_FIELDS() +} +CvSeqReader; + +/****************************************************************************************/ +/* Operations on sequences */ +/****************************************************************************************/ + +#define CV_SEQ_ELEM( seq, elem_type, index ) \ +/** assert gives some guarantee that parameter is valid */ \ +( assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && \ + (seq)->elem_size == sizeof(elem_type)), \ + (elem_type*)((seq)->first && (unsigned)index < \ + (unsigned)((seq)->first->count) ? \ + (seq)->first->data + (index) * sizeof(elem_type) : \ + cvGetSeqElem( (CvSeq*)(seq), (index) ))) +#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) ) + +/** Add element to sequence: */ +#define CV_WRITE_SEQ_ELEM_VAR( elem_ptr, writer ) \ +{ \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + memcpy((writer).ptr, elem_ptr, (writer).seq->elem_size);\ + (writer).ptr += (writer).seq->elem_size; \ +} + +#define CV_WRITE_SEQ_ELEM( elem, writer ) \ +{ \ + assert( (writer).seq->elem_size == sizeof(elem)); \ + if( (writer).ptr >= (writer).block_max ) \ + { \ + cvCreateSeqBlock( &writer); \ + } \ + assert( (writer).ptr <= (writer).block_max - sizeof(elem));\ + memcpy((writer).ptr, &(elem), sizeof(elem)); \ + (writer).ptr += sizeof(elem); \ +} + + +/** Move reader position forward: */ +#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr += (elem_size)) >= (reader).block_max ) \ + { \ + cvChangeSeqBlock( &(reader), 1 ); \ + } \ +} + + +/** Move reader position backward: */ +#define CV_PREV_SEQ_ELEM( elem_size, reader ) \ +{ \ + if( ((reader).ptr -= (elem_size)) < (reader).block_min ) \ + { \ + cvChangeSeqBlock( &(reader), -1 ); \ + } \ +} + +/** Read element and move read position forward: */ +#define CV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy( &(elem), (reader).ptr, sizeof((elem))); \ + CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \ +} + +/** Read element and move read position backward: */ +#define CV_REV_READ_SEQ_ELEM( elem, reader ) \ +{ \ + assert( (reader).seq->elem_size == sizeof(elem)); \ + memcpy(&(elem), (reader).ptr, sizeof((elem))); \ + CV_PREV_SEQ_ELEM( sizeof(elem), reader ) \ +} + + +#define CV_READ_CHAIN_POINT( _pt, reader ) \ +{ \ + (_pt) = (reader).pt; \ + if( (reader).ptr ) \ + { \ + CV_READ_SEQ_ELEM( (reader).code, (reader)); \ + assert( ((reader).code & ~7) == 0 ); \ + (reader).pt.x += (reader).deltas[(int)(reader).code][0]; \ + (reader).pt.y += (reader).deltas[(int)(reader).code][1]; \ + } \ +} + +#define CV_CURRENT_POINT( reader ) (*((CvPoint*)((reader).ptr))) +#define CV_PREV_POINT( reader ) (*((CvPoint*)((reader).prev_elem))) + +#define CV_READ_EDGE( pt1, pt2, reader ) \ +{ \ + assert( sizeof(pt1) == sizeof(CvPoint) && \ + sizeof(pt2) == sizeof(CvPoint) && \ + reader.seq->elem_size == sizeof(CvPoint)); \ + (pt1) = CV_PREV_POINT( reader ); \ + (pt2) = CV_CURRENT_POINT( reader ); \ + (reader).prev_elem = (reader).ptr; \ + CV_NEXT_SEQ_ELEM( sizeof(CvPoint), (reader)); \ +} + +/************ Graph macros ************/ + +/** Return next graph edge for given vertex: */ +#define CV_NEXT_GRAPH_EDGE( edge, vertex ) \ + (assert((edge)->vtx[0] == (vertex) || (edge)->vtx[1] == (vertex)), \ + (edge)->next[(edge)->vtx[1] == (vertex)]) + + + +/****************************************************************************************\ +* Data structures for persistence (a.k.a serialization) functionality * +\****************************************************************************************/ + +#if 0 + +/** "black box" file storage */ +typedef struct CvFileStorage CvFileStorage; + +/** Storage flags: */ +#define CV_STORAGE_READ 0 +#define CV_STORAGE_WRITE 1 +#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE +#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE +#define CV_STORAGE_APPEND 2 +#define CV_STORAGE_MEMORY 4 +#define CV_STORAGE_FORMAT_MASK (7<<3) +#define CV_STORAGE_FORMAT_AUTO 0 +#define CV_STORAGE_FORMAT_XML 8 +#define CV_STORAGE_FORMAT_YAML 16 +#define CV_STORAGE_FORMAT_JSON 24 +#define CV_STORAGE_BASE64 64 +#define CV_STORAGE_WRITE_BASE64 (CV_STORAGE_BASE64 | CV_STORAGE_WRITE) + +/** @brief List of attributes. : + +In the current implementation, attributes are used to pass extra parameters when writing user +objects (see cvWrite). XML attributes inside tags are not supported, aside from the object type +specification (type_id attribute). +@see cvAttrList, cvAttrValue + */ +typedef struct CvAttrList +{ + const char** attr; /**< NULL-terminated array of (attribute_name,attribute_value) pairs. */ + struct CvAttrList* next; /**< Pointer to next chunk of the attributes list. */ +} +CvAttrList; + +/** initializes CvAttrList structure */ +CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL), + CvAttrList* next CV_DEFAULT(NULL) ) +{ + CvAttrList l; + l.attr = attr; + l.next = next; + + return l; +} + +struct CvTypeInfo; + +#define CV_NODE_NONE 0 +#define CV_NODE_INT 1 +#define CV_NODE_INTEGER CV_NODE_INT +#define CV_NODE_REAL 2 +#define CV_NODE_FLOAT CV_NODE_REAL +#define CV_NODE_STR 3 +#define CV_NODE_STRING CV_NODE_STR +#define CV_NODE_REF 4 /**< not used */ +#define CV_NODE_SEQ 5 +#define CV_NODE_MAP 6 +#define CV_NODE_TYPE_MASK 7 + +#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK) + +/** file node flags */ +#define CV_NODE_FLOW 8 /**= CV_NODE_SEQ) +#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0) +#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0) +#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0) +#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0) + +#define CV_NODE_SEQ_SIMPLE 256 +#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0) + +typedef struct CvString +{ + int len; + char* ptr; +} +CvString; + +/** All the keys (names) of elements in the read file storage + are stored in the hash to speed up the lookup operations: */ +typedef struct CvStringHashNode +{ + unsigned hashval; + CvString str; + struct CvStringHashNode* next; +} +CvStringHashNode; + +typedef struct CvGenericHash CvFileNodeHash; + +/** Basic element of the file storage - scalar or collection: */ +typedef struct CvFileNode +{ + int tag; + struct CvTypeInfo* info; /**< type information + (only for user-defined object, for others it is 0) */ + union + { + double f; /**< scalar floating-point number */ + int i; /**< scalar integer number */ + CvString str; /**< text string */ + CvSeq* seq; /**< sequence (ordered collection of file nodes) */ + CvFileNodeHash* map; /**< map (collection of named file nodes) */ + } data; +} +CvFileNode; + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr ); +typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr ); +typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); +typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name, + const void* struct_ptr, CvAttrList attributes ); +typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); +#ifdef __cplusplus +} +#endif + +/** @brief Type information + +The structure contains information about one of the standard or user-defined types. Instances of the +type may or may not contain a pointer to the corresponding CvTypeInfo structure. In any case, there +is a way to find the type info structure for a given object using the cvTypeOf function. +Alternatively, type info can be found by type name using cvFindType, which is used when an object +is read from file storage. The user can register a new type with cvRegisterType that adds the type +information structure into the beginning of the type list. Thus, it is possible to create +specialized types from generic standard types and override the basic methods. + */ +typedef struct CvTypeInfo +{ + int flags; /**< not used */ + int header_size; /**< sizeof(CvTypeInfo) */ + struct CvTypeInfo* prev; /**< previous registered type in the list */ + struct CvTypeInfo* next; /**< next registered type in the list */ + const char* type_name; /**< type name, written to file storage */ + CvIsInstanceFunc is_instance; /**< checks if the passed object belongs to the type */ + CvReleaseFunc release; /**< releases object (memory etc.) */ + CvReadFunc read; /**< reads object from file storage */ + CvWriteFunc write; /**< writes object to file storage */ + CvCloneFunc clone; /**< creates a copy of the object */ +} +CvTypeInfo; +#endif + +/** @} */ + +#endif /*OPENCV_CORE_TYPES_H*/ + +/* End of file. */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utility.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utility.hpp new file mode 100644 index 0000000..108c0d9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utility.hpp @@ -0,0 +1,1229 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2015, Itseez Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_CORE_UTILITY_H +#define OPENCV_CORE_UTILITY_H + +#ifndef __cplusplus +# error utility.hpp header must be compiled as C++ +#endif + +#if defined(check) +# warning Detected Apple 'check' macro definition, it can cause build conflicts. Please, include this header before any Apple headers. +#endif + +#include "opencv2/core.hpp" +#include + +#include + +#if !defined(_M_CEE) +#include // std::mutex, std::lock_guard +#endif + +namespace cv +{ + +//! @addtogroup core_utils +//! @{ + +/** @brief Automatically Allocated Buffer Class + + The class is used for temporary buffers in functions and methods. + If a temporary buffer is usually small (a few K's of memory), + but its size depends on the parameters, it makes sense to create a small + fixed-size array on stack and use it if it's large enough. If the required buffer size + is larger than the fixed size, another buffer of sufficient size is allocated dynamically + and released after the processing. Therefore, in typical cases, when the buffer size is small, + there is no overhead associated with malloc()/free(). + At the same time, there is no limit on the size of processed data. + + This is what AutoBuffer does. The template takes 2 parameters - type of the buffer elements and + the number of stack-allocated elements. Here is how the class is used: + + \code + void my_func(const cv::Mat& m) + { + cv::AutoBuffer buf(1000); // create automatic buffer containing 1000 floats + + buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used, + // otherwise the buffer of "m.rows" floats will be allocated + // dynamically and deallocated in cv::AutoBuffer destructor + ... + } + \endcode +*/ +#ifdef OPENCV_ENABLE_MEMORY_SANITIZER +template class AutoBuffer +#else +template class AutoBuffer +#endif +{ +public: + typedef _Tp value_type; + + //! the default constructor + AutoBuffer(); + //! constructor taking the real buffer size + explicit AutoBuffer(size_t _size); + + //! the copy constructor + AutoBuffer(const AutoBuffer<_Tp, fixed_size>& buf); + //! the assignment operator + AutoBuffer<_Tp, fixed_size>& operator = (const AutoBuffer<_Tp, fixed_size>& buf); + + //! destructor. calls deallocate() + ~AutoBuffer(); + + //! allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used + void allocate(size_t _size); + //! deallocates the buffer if it was dynamically allocated + void deallocate(); + //! resizes the buffer and preserves the content + void resize(size_t _size); + //! returns the current buffer size + size_t size() const; + //! returns pointer to the real buffer, stack-allocated or heap-allocated + inline _Tp* data() { return ptr; } + //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated + inline const _Tp* data() const { return ptr; } + +#if !defined(OPENCV_DISABLE_DEPRECATED_COMPATIBILITY) // use to .data() calls instead + //! returns pointer to the real buffer, stack-allocated or heap-allocated + operator _Tp* () { return ptr; } + //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated + operator const _Tp* () const { return ptr; } +#else + //! returns a reference to the element at specified location. No bounds checking is performed in Release builds. + inline _Tp& operator[] (size_t i) { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; } + //! returns a reference to the element at specified location. No bounds checking is performed in Release builds. + inline const _Tp& operator[] (size_t i) const { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; } +#endif + +protected: + //! pointer to the real buffer, can point to buf if the buffer is small enough + _Tp* ptr; + //! size of the real buffer + size_t sz; + //! pre-allocated buffer. At least 1 element to confirm C++ standard requirements + _Tp buf[(fixed_size > 0) ? fixed_size : 1]; +}; + +/** @brief Sets/resets the break-on-error mode. + +When the break-on-error mode is set, the default error handler issues a hardware exception, which +can make debugging more convenient. + +\return the previous state + */ +CV_EXPORTS bool setBreakOnError(bool flag); + +extern "C" typedef int (*ErrorCallback)( int status, const char* func_name, + const char* err_msg, const char* file_name, + int line, void* userdata ); + + +/** @brief Sets the new error handler and the optional user data. + + The function sets the new error handler, called from cv::error(). + + \param errCallback the new error handler. If NULL, the default error handler is used. + \param userdata the optional user data pointer, passed to the callback. + \param prevUserdata the optional output parameter where the previous user data pointer is stored + + \return the previous error handler +*/ +CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, void* userdata=0, void** prevUserdata=0); + +CV_EXPORTS String tempfile( const char* suffix = 0); +CV_EXPORTS void glob(String pattern, std::vector& result, bool recursive = false); + +/** @brief OpenCV will try to set the number of threads for the next parallel region. + +If threads == 0, OpenCV will disable threading optimizations and run all it's functions +sequentially. Passing threads \< 0 will reset threads number to system default. This function must +be called outside of parallel region. + +OpenCV will try to run its functions with specified threads number, but some behaviour differs from +framework: +- `TBB` - User-defined parallel constructions will run with the same threads number, if + another is not specified. If later on user creates his own scheduler, OpenCV will use it. +- `OpenMP` - No special defined behaviour. +- `Concurrency` - If threads == 1, OpenCV will disable threading optimizations and run its + functions sequentially. +- `GCD` - Supports only values \<= 0. +- `C=` - No special defined behaviour. +@param nthreads Number of threads used by OpenCV. +@sa getNumThreads, getThreadNum + */ +CV_EXPORTS_W void setNumThreads(int nthreads); + +/** @brief Returns the number of threads used by OpenCV for parallel regions. + +Always returns 1 if OpenCV is built without threading support. + +The exact meaning of return value depends on the threading framework used by OpenCV library: +- `TBB` - The number of threads, that OpenCV will try to use for parallel regions. If there is + any tbb::thread_scheduler_init in user code conflicting with OpenCV, then function returns + default number of threads used by TBB library. +- `OpenMP` - An upper bound on the number of threads that could be used to form a new team. +- `Concurrency` - The number of threads, that OpenCV will try to use for parallel regions. +- `GCD` - Unsupported; returns the GCD thread pool limit (512) for compatibility. +- `C=` - The number of threads, that OpenCV will try to use for parallel regions, if before + called setNumThreads with threads \> 0, otherwise returns the number of logical CPUs, + available for the process. +@sa setNumThreads, getThreadNum + */ +CV_EXPORTS_W int getNumThreads(); + +/** @brief Returns the index of the currently executed thread within the current parallel region. Always +returns 0 if called outside of parallel region. + +@deprecated Current implementation doesn't corresponding to this documentation. + +The exact meaning of the return value depends on the threading framework used by OpenCV library: +- `TBB` - Unsupported with current 4.1 TBB release. Maybe will be supported in future. +- `OpenMP` - The thread number, within the current team, of the calling thread. +- `Concurrency` - An ID for the virtual processor that the current context is executing on (0 + for master thread and unique number for others, but not necessary 1,2,3,...). +- `GCD` - System calling thread's ID. Never returns 0 inside parallel region. +- `C=` - The index of the current parallel task. +@sa setNumThreads, getNumThreads + */ +CV_EXPORTS_W int getThreadNum(); + +/** @brief Returns full configuration time cmake output. + +Returned value is raw cmake output including version control system revision, compiler version, +compiler flags, enabled modules and third party libraries, etc. Output format depends on target +architecture. + */ +CV_EXPORTS_W const String& getBuildInformation(); + +/** @brief Returns library version string + +For example "3.4.1-dev". + +@sa getMajorVersion, getMinorVersion, getRevisionVersion +*/ +CV_EXPORTS_W String getVersionString(); + +/** @brief Returns major library version */ +CV_EXPORTS_W int getVersionMajor(); + +/** @brief Returns minor library version */ +CV_EXPORTS_W int getVersionMinor(); + +/** @brief Returns revision field of the library version */ +CV_EXPORTS_W int getVersionRevision(); + +/** @brief Returns the number of ticks. + +The function returns the number of ticks after the certain event (for example, when the machine was +turned on). It can be used to initialize RNG or to measure a function execution time by reading the +tick count before and after the function call. +@sa getTickFrequency, TickMeter + */ +CV_EXPORTS_W int64 getTickCount(); + +/** @brief Returns the number of ticks per second. + +The function returns the number of ticks per second. That is, the following code computes the +execution time in seconds: +@code + double t = (double)getTickCount(); + // do something ... + t = ((double)getTickCount() - t)/getTickFrequency(); +@endcode +@sa getTickCount, TickMeter + */ +CV_EXPORTS_W double getTickFrequency(); + +/** @brief a Class to measure passing time. + +The class computes passing time by counting the number of ticks per second. That is, the following code computes the +execution time in seconds: +@snippet snippets/core_various.cpp TickMeter_total + +It is also possible to compute the average time over multiple runs: +@snippet snippets/core_various.cpp TickMeter_average + +@sa getTickCount, getTickFrequency +*/ +class CV_EXPORTS_W TickMeter +{ +public: + //! the default constructor + CV_WRAP TickMeter() + { + reset(); + } + + //! starts counting ticks. + CV_WRAP void start() + { + startTime = cv::getTickCount(); + } + + //! stops counting ticks. + CV_WRAP void stop() + { + int64 time = cv::getTickCount(); + if (startTime == 0) + return; + ++counter; + sumTime += (time - startTime); + startTime = 0; + } + + //! returns counted ticks. + CV_WRAP int64 getTimeTicks() const + { + return sumTime; + } + + //! returns passed time in microseconds. + CV_WRAP double getTimeMicro() const + { + return getTimeMilli()*1e3; + } + + //! returns passed time in milliseconds. + CV_WRAP double getTimeMilli() const + { + return getTimeSec()*1e3; + } + + //! returns passed time in seconds. + CV_WRAP double getTimeSec() const + { + return (double)getTimeTicks() / getTickFrequency(); + } + + //! returns internal counter value. + CV_WRAP int64 getCounter() const + { + return counter; + } + + //! returns average FPS (frames per second) value. + CV_WRAP double getFPS() const + { + const double sec = getTimeSec(); + if (sec < DBL_EPSILON) + return 0.; + return counter / sec; + } + + //! returns average time in seconds + CV_WRAP double getAvgTimeSec() const + { + if (counter <= 0) + return 0.; + return getTimeSec() / counter; + } + + //! returns average time in milliseconds + CV_WRAP double getAvgTimeMilli() const + { + return getAvgTimeSec() * 1e3; + } + + //! resets internal values. + CV_WRAP void reset() + { + startTime = 0; + sumTime = 0; + counter = 0; + } + +private: + int64 counter; + int64 sumTime; + int64 startTime; +}; + +/** @brief output operator +@code +TickMeter tm; +tm.start(); +// do something ... +tm.stop(); +std::cout << tm; +@endcode +*/ + +static inline +std::ostream& operator << (std::ostream& out, const TickMeter& tm) +{ + return out << tm.getTimeSec() << "sec"; +} + +/** @brief Returns the number of CPU ticks. + +The function returns the current number of CPU ticks on some architectures (such as x86, x64, +PowerPC). On other platforms the function is equivalent to getTickCount. It can also be used for +very accurate time measurements, as well as for RNG initialization. Note that in case of multi-CPU +systems a thread, from which getCPUTickCount is called, can be suspended and resumed at another CPU +with its own counter. So, theoretically (and practically) the subsequent calls to the function do +not necessary return the monotonously increasing values. Also, since a modern CPU varies the CPU +frequency depending on the load, the number of CPU clocks spent in some code cannot be directly +converted to time units. Therefore, getTickCount is generally a preferable solution for measuring +execution time. + */ +CV_EXPORTS_W int64 getCPUTickCount(); + +/** @brief Returns true if the specified feature is supported by the host hardware. + +The function returns true if the host hardware supports the specified feature. When user calls +setUseOptimized(false), the subsequent calls to checkHardwareSupport() will return false until +setUseOptimized(true) is called. This way user can dynamically switch on and off the optimized code +in OpenCV. +@param feature The feature of interest, one of cv::CpuFeatures + */ +CV_EXPORTS_W bool checkHardwareSupport(int feature); + +/** @brief Returns feature name by ID + +Returns empty string if feature is not defined +*/ +CV_EXPORTS_W String getHardwareFeatureName(int feature); + +/** @brief Returns list of CPU features enabled during compilation. + +Returned value is a string containing space separated list of CPU features with following markers: + +- no markers - baseline features +- prefix `*` - features enabled in dispatcher +- suffix `?` - features enabled but not available in HW + +Example: `SSE SSE2 SSE3 *SSE4.1 *SSE4.2 *FP16 *AVX *AVX2 *AVX512-SKX?` +*/ +CV_EXPORTS_W std::string getCPUFeaturesLine(); + +/** @brief Returns the number of logical CPUs available for the process. + */ +CV_EXPORTS_W int getNumberOfCPUs(); + + +/** @brief Aligns a pointer to the specified number of bytes. + +The function returns the aligned pointer of the same type as the input pointer: +\f[\texttt{(_Tp*)(((size_t)ptr + n-1) & -n)}\f] +@param ptr Aligned pointer. +@param n Alignment size that must be a power of two. + */ +template static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp)) +{ + CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2 + return (_Tp*)(((size_t)ptr + n-1) & -n); +} + +/** @brief Aligns a buffer size to the specified number of bytes. + +The function returns the minimum number that is greater than or equal to sz and is divisible by n : +\f[\texttt{(sz + n-1) & -n}\f] +@param sz Buffer size to align. +@param n Alignment size that must be a power of two. + */ +static inline size_t alignSize(size_t sz, int n) +{ + CV_DbgAssert((n & (n - 1)) == 0); // n is a power of 2 + return (sz + n-1) & -n; +} + +/** @brief Integer division with result round up. + +Use this function instead of `ceil((float)a / b)` expressions. + +@sa alignSize +*/ +static inline int divUp(int a, unsigned int b) +{ + CV_DbgAssert(a >= 0); + return (a + b - 1) / b; +} +/** @overload */ +static inline size_t divUp(size_t a, unsigned int b) +{ + return (a + b - 1) / b; +} + +/** @brief Round first value up to the nearest multiple of second value. + +Use this function instead of `ceil((float)a / b) * b` expressions. + +@sa divUp +*/ +static inline int roundUp(int a, unsigned int b) +{ + CV_DbgAssert(a >= 0); + return a + b - 1 - (a + b -1) % b; +} +/** @overload */ +static inline size_t roundUp(size_t a, unsigned int b) +{ + return a + b - 1 - (a + b - 1) % b; +} + +/** @brief Alignment check of passed values + +Usage: `isAligned(...)` + +@note Alignment(N) must be a power of 2 (2**k, 2^k) +*/ +template static inline +bool isAligned(const T& data) +{ + CV_StaticAssert((N & (N - 1)) == 0, ""); // power of 2 + return (((size_t)data) & (N - 1)) == 0; +} +/** @overload */ +template static inline +bool isAligned(const void* p1) +{ + return isAligned((size_t)p1); +} +/** @overload */ +template static inline +bool isAligned(const void* p1, const void* p2) +{ + return isAligned(((size_t)p1)|((size_t)p2)); +} +/** @overload */ +template static inline +bool isAligned(const void* p1, const void* p2, const void* p3) +{ + return isAligned(((size_t)p1)|((size_t)p2)|((size_t)p3)); +} +/** @overload */ +template static inline +bool isAligned(const void* p1, const void* p2, const void* p3, const void* p4) +{ + return isAligned(((size_t)p1)|((size_t)p2)|((size_t)p3)|((size_t)p4)); +} + +/** @brief Enables or disables the optimized code. + +The function can be used to dynamically turn on and off optimized dispatched code (code that uses SSE4.2, AVX/AVX2, +and other instructions on the platforms that support it). It sets a global flag that is further +checked by OpenCV functions. Since the flag is not checked in the inner OpenCV loops, it is only +safe to call the function on the very top level in your application where you can be sure that no +other OpenCV function is currently executed. + +By default, the optimized code is enabled unless you disable it in CMake. The current status can be +retrieved using useOptimized. +@param onoff The boolean flag specifying whether the optimized code should be used (onoff=true) +or not (onoff=false). + */ +CV_EXPORTS_W void setUseOptimized(bool onoff); + +/** @brief Returns the status of optimized code usage. + +The function returns true if the optimized code is enabled. Otherwise, it returns false. + */ +CV_EXPORTS_W bool useOptimized(); + +static inline size_t getElemSize(int type) { return (size_t)CV_ELEM_SIZE(type); } + +/////////////////////////////// Parallel Primitives ////////////////////////////////// + +/** @brief Base class for parallel data processors + +@ingroup core_parallel +*/ +class CV_EXPORTS ParallelLoopBody +{ +public: + virtual ~ParallelLoopBody(); + virtual void operator() (const Range& range) const = 0; +}; + +/** @brief Parallel data processor + +@ingroup core_parallel +*/ +CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.); + +//! @ingroup core_parallel +class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody +{ +private: + std::function m_functor; +public: + inline + ParallelLoopBodyLambdaWrapper(std::function functor) + : m_functor(functor) + { + // nothing + } + + virtual void operator() (const cv::Range& range) const CV_OVERRIDE + { + m_functor(range); + } +}; + +//! @ingroup core_parallel +static inline +void parallel_for_(const Range& range, std::function functor, double nstripes=-1.) +{ + parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes); +} + + +/////////////////////////////// forEach method of cv::Mat //////////////////////////// +template inline +void Mat::forEach_impl(const Functor& operation) { + if (false) { + operation(*reinterpret_cast<_Tp*>(0), reinterpret_cast(0)); + // If your compiler fails in this line. + // Please check that your functor signature is + // (_Tp&, const int*) <- multi-dimensional + // or (_Tp&, void*) <- in case you don't need current idx. + } + + CV_Assert(!empty()); + CV_Assert(this->total() / this->size[this->dims - 1] <= INT_MAX); + const int LINES = static_cast(this->total() / this->size[this->dims - 1]); + + class PixelOperationWrapper :public ParallelLoopBody + { + public: + PixelOperationWrapper(Mat_<_Tp>* const frame, const Functor& _operation) + : mat(frame), op(_operation) {} + virtual ~PixelOperationWrapper(){} + // ! Overloaded virtual operator + // convert range call to row call. + virtual void operator()(const Range &range) const CV_OVERRIDE + { + const int DIMS = mat->dims; + const int COLS = mat->size[DIMS - 1]; + if (DIMS <= 2) { + for (int row = range.start; row < range.end; ++row) { + this->rowCall2(row, COLS); + } + } else { + std::vector idx(DIMS); /// idx is modified in this->rowCall + idx[DIMS - 2] = range.start - 1; + + for (int line_num = range.start; line_num < range.end; ++line_num) { + idx[DIMS - 2]++; + for (int i = DIMS - 2; i >= 0; --i) { + if (idx[i] >= mat->size[i]) { + idx[i - 1] += idx[i] / mat->size[i]; + idx[i] %= mat->size[i]; + continue; // carry-over; + } + else { + break; + } + } + this->rowCall(&idx[0], COLS, DIMS); + } + } + } + private: + Mat_<_Tp>* const mat; + const Functor op; + // ! Call operator for each elements in this row. + inline void rowCall(int* const idx, const int COLS, const int DIMS) const { + int &col = idx[DIMS - 1]; + col = 0; + _Tp* pixel = &(mat->template at<_Tp>(idx)); + + while (col < COLS) { + op(*pixel, const_cast(idx)); + pixel++; col++; + } + col = 0; + } + // ! Call operator for each elements in this row. 2d mat special version. + inline void rowCall2(const int row, const int COLS) const { + union Index{ + int body[2]; + operator const int*() const { + return reinterpret_cast(this); + } + int& operator[](const int i) { + return body[i]; + } + } idx = {{row, 0}}; + // Special union is needed to avoid + // "error: array subscript is above array bounds [-Werror=array-bounds]" + // when call the functor `op` such that access idx[3]. + + _Tp* pixel = &(mat->template at<_Tp>(idx)); + const _Tp* const pixel_end = pixel + COLS; + while(pixel < pixel_end) { + op(*pixel++, static_cast(idx)); + idx[1]++; + } + } + PixelOperationWrapper& operator=(const PixelOperationWrapper &) { + CV_Assert(false); + // We can not remove this implementation because Visual Studio warning C4822. + return *this; + } + }; + + parallel_for_(cv::Range(0, LINES), PixelOperationWrapper(reinterpret_cast*>(this), operation)); +} + +/////////////////////////// Synchronization Primitives /////////////////////////////// + +#if !defined(_M_CEE) +#ifndef OPENCV_DISABLE_THREAD_SUPPORT +typedef std::recursive_mutex Mutex; +typedef std::lock_guard AutoLock; +#else // OPENCV_DISABLE_THREAD_SUPPORT +// Custom (failing) implementation of `std::recursive_mutex`. +struct Mutex { + void lock(){ + CV_Error(cv::Error::StsNotImplemented, + "cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON"); + } + void unlock(){ + CV_Error(cv::Error::StsNotImplemented, + "cv::Mutex is disabled by OPENCV_DISABLE_THREAD_SUPPORT=ON"); + } +}; +// Stub for cv::AutoLock when threads are disabled. +struct AutoLock { + AutoLock(Mutex &) { } +}; +#endif // OPENCV_DISABLE_THREAD_SUPPORT +#endif // !defined(_M_CEE) + + +/** @brief Designed for command line parsing + +The sample below demonstrates how to use CommandLineParser: +@code + CommandLineParser parser(argc, argv, keys); + parser.about("Application name v1.0.0"); + + if (parser.has("help")) + { + parser.printMessage(); + return 0; + } + + int N = parser.get("N"); + double fps = parser.get("fps"); + String path = parser.get("path"); + + use_time_stamp = parser.has("timestamp"); + + String img1 = parser.get(0); + String img2 = parser.get(1); + + int repeat = parser.get(2); + + if (!parser.check()) + { + parser.printErrors(); + return 0; + } +@endcode + +### Keys syntax + +The keys parameter is a string containing several blocks, each one is enclosed in curly braces and +describes one argument. Each argument contains three parts separated by the `|` symbol: + +-# argument names is a space-separated list of option synonyms (to mark argument as positional, prefix it with the `@` symbol) +-# default value will be used if the argument was not provided (can be empty) +-# help message (can be empty) + +For example: + +@code{.cpp} + const String keys = + "{help h usage ? | | print this message }" + "{@image1 | | image1 for compare }" + "{@image2 || image2 for compare }" + "{@repeat |1 | number }" + "{path |. | path to file }" + "{fps | -1.0 | fps for output video }" + "{N count |100 | count of objects }" + "{ts timestamp | | use time stamp }" + ; +} +@endcode + +Note that there are no default values for `help` and `timestamp` so we can check their presence using the `has()` method. +Arguments with default values are considered to be always present. Use the `get()` method in these cases to check their +actual value instead. + +String keys like `get("@image1")` return the empty string `""` by default - even with an empty default value. +Use the special `` default value to enforce that the returned string must not be empty. (like in `get("@image2")`) + +### Usage + +For the described keys: + +@code{.sh} + # Good call (3 positional parameters: image1, image2 and repeat; N is 200, ts is true) + $ ./app -N=200 1.png 2.jpg 19 -ts + + # Bad call + $ ./app -fps=aaa + ERRORS: + Parameter 'fps': can not convert: [aaa] to [double] +@endcode + */ +class CV_EXPORTS CommandLineParser +{ +public: + + /** @brief Constructor + + Initializes command line parser object + + @param argc number of command line arguments (from main()) + @param argv array of command line arguments (from main()) + @param keys string describing acceptable command line parameters (see class description for syntax) + */ + CommandLineParser(int argc, const char* const argv[], const String& keys); + + /** @brief Copy constructor */ + CommandLineParser(const CommandLineParser& parser); + + /** @brief Assignment operator */ + CommandLineParser& operator = (const CommandLineParser& parser); + + /** @brief Destructor */ + ~CommandLineParser(); + + /** @brief Returns application path + + This method returns the path to the executable from the command line (`argv[0]`). + + For example, if the application has been started with such a command: + @code{.sh} + $ ./bin/my-executable + @endcode + this method will return `./bin`. + */ + String getPathToApplication() const; + + /** @brief Access arguments by name + + Returns argument converted to selected type. If the argument is not known or can not be + converted to selected type, the error flag is set (can be checked with @ref check). + + For example, define: + @code{.cpp} + String keys = "{N count||}"; + @endcode + + Call: + @code{.sh} + $ ./my-app -N=20 + # or + $ ./my-app --count=20 + @endcode + + Access: + @code{.cpp} + int N = parser.get("N"); + @endcode + + @param name name of the argument + @param space_delete remove spaces from the left and right of the string + @tparam T the argument will be converted to this type if possible + + @note You can access positional arguments by their `@`-prefixed name: + @code{.cpp} + parser.get("@image"); + @endcode + */ + template + T get(const String& name, bool space_delete = true) const + { + T val = T(); + getByName(name, space_delete, ParamType::type, (void*)&val); + return val; + } + + /** @brief Access positional arguments by index + + Returns argument converted to selected type. Indexes are counted from zero. + + For example, define: + @code{.cpp} + String keys = "{@arg1||}{@arg2||}" + @endcode + + Call: + @code{.sh} + ./my-app abc qwe + @endcode + + Access arguments: + @code{.cpp} + String val_1 = parser.get(0); // returns "abc", arg1 + String val_2 = parser.get(1); // returns "qwe", arg2 + @endcode + + @param index index of the argument + @param space_delete remove spaces from the left and right of the string + @tparam T the argument will be converted to this type if possible + */ + template + T get(int index, bool space_delete = true) const + { + T val = T(); + getByIndex(index, space_delete, ParamType::type, (void*)&val); + return val; + } + + /** @brief Check if field was provided in the command line + + @param name argument name to check + */ + bool has(const String& name) const; + + /** @brief Check for parsing errors + + Returns false if error occurred while accessing the parameters (bad conversion, missing arguments, + etc.). Call @ref printErrors to print error messages list. + */ + bool check() const; + + /** @brief Set the about message + + The about message will be shown when @ref printMessage is called, right before arguments table. + */ + void about(const String& message); + + /** @brief Print help message + + This method will print standard help message containing the about message and arguments description. + + @sa about + */ + void printMessage() const; + + /** @brief Print list of errors occurred + + @sa check + */ + void printErrors() const; + +protected: + void getByName(const String& name, bool space_delete, Param type, void* dst) const; + void getByIndex(int index, bool space_delete, Param type, void* dst) const; + + struct Impl; + Impl* impl; +}; + +//! @} core_utils + +//! @cond IGNORED + +/////////////////////////////// AutoBuffer implementation //////////////////////////////////////// + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer() +{ + ptr = buf; + sz = fixed_size; +} + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size) +{ + ptr = buf; + sz = fixed_size; + allocate(_size); +} + +template inline +AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf ) +{ + ptr = buf; + sz = fixed_size; + allocate(abuf.size()); + for( size_t i = 0; i < sz; i++ ) + ptr[i] = abuf.ptr[i]; +} + +template inline AutoBuffer<_Tp, fixed_size>& +AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf) +{ + if( this != &abuf ) + { + deallocate(); + allocate(abuf.size()); + for( size_t i = 0; i < sz; i++ ) + ptr[i] = abuf.ptr[i]; + } + return *this; +} + +template inline +AutoBuffer<_Tp, fixed_size>::~AutoBuffer() +{ deallocate(); } + +template inline void +AutoBuffer<_Tp, fixed_size>::allocate(size_t _size) +{ + if(_size <= sz) + { + sz = _size; + return; + } + deallocate(); + sz = _size; + if(_size > fixed_size) + { + ptr = new _Tp[_size]; + } +} + +template inline void +AutoBuffer<_Tp, fixed_size>::deallocate() +{ + if( ptr != buf ) + { + delete[] ptr; + ptr = buf; + sz = fixed_size; + } +} + +template inline void +AutoBuffer<_Tp, fixed_size>::resize(size_t _size) +{ + if(_size <= sz) + { + sz = _size; + return; + } + size_t i, prevsize = sz, minsize = MIN(prevsize, _size); + _Tp* prevptr = ptr; + + ptr = _size > fixed_size ? new _Tp[_size] : buf; + sz = _size; + + if( ptr != prevptr ) + for( i = 0; i < minsize; i++ ) + ptr[i] = prevptr[i]; + for( i = prevsize; i < _size; i++ ) + ptr[i] = _Tp(); + + if( prevptr != buf ) + delete[] prevptr; +} + +template inline size_t +AutoBuffer<_Tp, fixed_size>::size() const +{ return sz; } + +//! @endcond + + +// Basic Node class for tree building +template +class CV_EXPORTS Node +{ +public: + Node() + { + m_pParent = 0; + } + Node(OBJECT& payload) : m_payload(payload) + { + m_pParent = 0; + } + ~Node() + { + removeChilds(); + if (m_pParent) + { + int idx = m_pParent->findChild(this); + if (idx >= 0) + m_pParent->m_childs.erase(m_pParent->m_childs.begin() + idx); + } + } + + Node* findChild(OBJECT& payload) const + { + for(size_t i = 0; i < this->m_childs.size(); i++) + { + if(this->m_childs[i]->m_payload == payload) + return this->m_childs[i]; + } + return NULL; + } + + int findChild(Node *pNode) const + { + for (size_t i = 0; i < this->m_childs.size(); i++) + { + if(this->m_childs[i] == pNode) + return (int)i; + } + return -1; + } + + void addChild(Node *pNode) + { + if(!pNode) + return; + + CV_Assert(pNode->m_pParent == 0); + pNode->m_pParent = this; + this->m_childs.push_back(pNode); + } + + void removeChilds() + { + for(size_t i = 0; i < m_childs.size(); i++) + { + m_childs[i]->m_pParent = 0; // avoid excessive parent vector trimming + delete m_childs[i]; + } + m_childs.clear(); + } + + int getDepth() + { + int count = 0; + Node *pParent = m_pParent; + while(pParent) count++, pParent = pParent->m_pParent; + return count; + } + +public: + OBJECT m_payload; + Node* m_pParent; + std::vector*> m_childs; +}; + + +namespace samples { + +//! @addtogroup core_utils_samples +// This section describes utility functions for OpenCV samples. +// +// @note Implementation of these utilities is not thread-safe. +// +//! @{ + +/** @brief Try to find requested data file + +Search directories: + +1. Directories passed via `addSamplesDataSearchPath()` +2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable +3. OPENCV_SAMPLES_DATA_PATH environment variable + If parameter value is not empty and nothing is found then stop searching. +4. Detects build/install path based on: + a. current working directory (CWD) + b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage) +5. Scan `/{,data,samples/data}` directories if build directory is detected or the current directory is in source tree. +6. Scan `/share/OpenCV` directory if install directory is detected. + +@see cv::utils::findDataFile + +@param relative_path Relative path to data file +@param required Specify "file not found" handling. + If true, function prints information message and raises cv::Exception. + If false, function returns empty result +@param silentMode Disables messages +@return Returns path (absolute or relative to the current directory) or empty string if file is not found +*/ +CV_EXPORTS_W cv::String findFile(const cv::String& relative_path, bool required = true, bool silentMode = false); + +CV_EXPORTS_W cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode = false); + +inline cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode) +{ + cv::String res = findFile(relative_path, false, silentMode); + if (res.empty()) + return relative_path; + return res; +} + +/** @brief Override search data path by adding new search location + +Use this only to override default behavior +Passed paths are used in LIFO order. + +@param path Path to used samples data +*/ +CV_EXPORTS_W void addSamplesDataSearchPath(const cv::String& path); + +/** @brief Append samples search data sub directory + +General usage is to add OpenCV modules name (`/modules//samples/data` -> `/samples/data` + `modules//samples/data`). +Passed subdirectories are used in LIFO order. + +@param subdir samples data sub directory +*/ +CV_EXPORTS_W void addSamplesDataSearchSubDirectory(const cv::String& subdir); + +//! @} +} // namespace samples + +namespace utils { + +CV_EXPORTS int getThreadID(); + +} // namespace + +} //namespace cv + +#ifdef CV_COLLECT_IMPL_DATA +#include "opencv2/core/utils/instrumentation.hpp" +#else +/// Collect implementation data on OpenCV function call. Requires ENABLE_IMPL_COLLECTION build option. +#define CV_IMPL_ADD(impl) +#endif + +#endif //OPENCV_CORE_UTILITY_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.hpp new file mode 100644 index 0000000..79e9338 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.hpp @@ -0,0 +1,29 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ALLOCATOR_STATS_HPP +#define OPENCV_CORE_ALLOCATOR_STATS_HPP + +#include "../cvdef.h" + +namespace cv { namespace utils { + +class AllocatorStatisticsInterface +{ +protected: + AllocatorStatisticsInterface() {} + virtual ~AllocatorStatisticsInterface() {} +public: + virtual uint64_t getCurrentUsage() const = 0; + virtual uint64_t getTotalUsage() const = 0; + virtual uint64_t getNumberOfAllocations() const = 0; + virtual uint64_t getPeakUsage() const = 0; + + /** set peak usage = current usage */ + virtual void resetPeakUsage() = 0; +}; + +}} // namespace + +#endif // OPENCV_CORE_ALLOCATOR_STATS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.impl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.impl.hpp new file mode 100644 index 0000000..eb5ecde --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/allocator_stats.impl.hpp @@ -0,0 +1,158 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP +#define OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP + +#include "./allocator_stats.hpp" + +//#define OPENCV_DISABLE_ALLOCATOR_STATS + +#ifdef CV_CXX11 + +#include + +#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE +#if defined(__GNUC__) && (\ + (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4) || \ + (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \ + ) +#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int +#endif +#endif + +#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE +#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE long long +#endif + +#else // CV_CXX11 + +#ifndef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE +#define OPENCV_ALLOCATOR_STATS_COUNTER_TYPE int // CV_XADD supports int only +#endif + +#endif // CV_CXX11 + +namespace cv { namespace utils { + +#ifdef CV__ALLOCATOR_STATS_LOG +namespace { +#endif + +class AllocatorStatistics : public AllocatorStatisticsInterface +{ +#ifdef OPENCV_DISABLE_ALLOCATOR_STATS + +public: + AllocatorStatistics() {} + ~AllocatorStatistics() CV_OVERRIDE {} + + uint64_t getCurrentUsage() const CV_OVERRIDE { return 0; } + uint64_t getTotalUsage() const CV_OVERRIDE { return 0; } + uint64_t getNumberOfAllocations() const CV_OVERRIDE { return 0; } + uint64_t getPeakUsage() const CV_OVERRIDE { return 0; } + + /** set peak usage = current usage */ + void resetPeakUsage() CV_OVERRIDE {}; + + void onAllocate(size_t /*sz*/) {} + void onFree(size_t /*sz*/) {} + +#elif defined(CV_CXX11) + +protected: + typedef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE counter_t; + std::atomic curr, total, total_allocs, peak; +public: + AllocatorStatistics() {} + ~AllocatorStatistics() CV_OVERRIDE {} + + uint64_t getCurrentUsage() const CV_OVERRIDE { return (uint64_t)curr.load(); } + uint64_t getTotalUsage() const CV_OVERRIDE { return (uint64_t)total.load(); } + uint64_t getNumberOfAllocations() const CV_OVERRIDE { return (uint64_t)total_allocs.load(); } + uint64_t getPeakUsage() const CV_OVERRIDE { return (uint64_t)peak.load(); } + + /** set peak usage = current usage */ + void resetPeakUsage() CV_OVERRIDE { peak.store(curr.load()); } + + // Controller interface + void onAllocate(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("allocate: %lld (curr=%lld)", (long long int)sz, (long long int)curr.load())); +#endif + + counter_t new_curr = curr.fetch_add((counter_t)sz) + (counter_t)sz; + + // peak = std::max((uint64_t)peak, new_curr); + auto prev_peak = peak.load(); + while (prev_peak < new_curr) + { + if (peak.compare_exchange_weak(prev_peak, new_curr)) + break; + } + // end of peak = max(...) + + total += (counter_t)sz; + total_allocs++; + } + void onFree(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("free: %lld (curr=%lld)", (long long int)sz, (long long int)curr.load())); +#endif + curr -= (counter_t)sz; + } + +#else // non C++11 + +protected: + typedef OPENCV_ALLOCATOR_STATS_COUNTER_TYPE counter_t; + volatile counter_t curr, total, total_allocs, peak; // overflow is possible, CV_XADD operates with 'int' only +public: + AllocatorStatistics() + : curr(0), total(0), total_allocs(0), peak(0) + {} + ~AllocatorStatistics() CV_OVERRIDE {} + + uint64_t getCurrentUsage() const CV_OVERRIDE { return (uint64_t)curr; } + uint64_t getTotalUsage() const CV_OVERRIDE { return (uint64_t)total; } + uint64_t getNumberOfAllocations() const CV_OVERRIDE { return (uint64_t)total_allocs; } + uint64_t getPeakUsage() const CV_OVERRIDE { return (uint64_t)peak; } + + void resetPeakUsage() CV_OVERRIDE { peak = curr; } + + // Controller interface + void onAllocate(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("allocate: %lld (curr=%lld)", (long long int)sz, (long long int)curr)); +#endif + + counter_t new_curr = (counter_t)CV_XADD(&curr, (counter_t)sz) + (counter_t)sz; + + peak = std::max((counter_t)peak, new_curr); // non-thread safe + + //CV_XADD(&total, (uint64_t)sz); // overflow with int, non-reliable... + total += sz; + + CV_XADD(&total_allocs, (counter_t)1); + } + void onFree(size_t sz) + { +#ifdef CV__ALLOCATOR_STATS_LOG + CV__ALLOCATOR_STATS_LOG(cv::format("free: %lld (curr=%lld)", (long long int)sz, (long long int)curr)); +#endif + CV_XADD(&curr, (counter_t)-sz); + } +#endif +}; + +#ifdef CV__ALLOCATOR_STATS_LOG +} // namespace +#endif + +}} // namespace + +#endif // OPENCV_CORE_ALLOCATOR_STATS_IMPL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/filesystem.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/filesystem.hpp new file mode 100644 index 0000000..a98d220 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/filesystem.hpp @@ -0,0 +1,82 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_UTILS_FILESYSTEM_HPP +#define OPENCV_UTILS_FILESYSTEM_HPP + +namespace cv { namespace utils { namespace fs { + + +CV_EXPORTS bool exists(const cv::String& path); +CV_EXPORTS bool isDirectory(const cv::String& path); + +CV_EXPORTS void remove_all(const cv::String& path); + + +CV_EXPORTS cv::String getcwd(); + +/** @brief Converts path p to a canonical absolute path + * Symlinks are processed if there is support for them on running platform. + * + * @param path input path. Target file/directory should exist. + */ +CV_EXPORTS cv::String canonical(const cv::String& path); + +/** Join path components */ +CV_EXPORTS cv::String join(const cv::String& base, const cv::String& path); + +/** Get parent directory */ +CV_EXPORTS cv::String getParent(const cv::String &path); +CV_EXPORTS std::wstring getParent(const std::wstring& path); + +/** + * Generate a list of all files that match the globbing pattern. + * + * Result entries are prefixed by base directory path. + * + * @param directory base directory + * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results + * @param[out] result result of globing. + * @param recursive scan nested directories too + * @param includeDirectories include directories into results list + */ +CV_EXPORTS void glob(const cv::String& directory, const cv::String& pattern, + CV_OUT std::vector& result, + bool recursive = false, bool includeDirectories = false); + +/** + * Generate a list of all files that match the globbing pattern. + * + * @param directory base directory + * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results + * @param[out] result globbing result with relative paths from base directory + * @param recursive scan nested directories too + * @param includeDirectories include directories into results list + */ +CV_EXPORTS void glob_relative(const cv::String& directory, const cv::String& pattern, + CV_OUT std::vector& result, + bool recursive = false, bool includeDirectories = false); + + +CV_EXPORTS bool createDirectory(const cv::String& path); +CV_EXPORTS bool createDirectories(const cv::String& path); + +#ifdef __OPENCV_BUILD +// TODO +//CV_EXPORTS cv::String getTempDirectory(); + +/** + * @brief Returns directory to store OpenCV cache files + * Create sub-directory in common OpenCV cache directory if it doesn't exist. + * @param sub_directory_name name of sub-directory. NULL or "" value asks to return root cache directory. + * @param configuration_name optional name of configuration parameter name which overrides default behavior. + * @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user. + */ +CV_EXPORTS cv::String getCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL); + +#endif + +}}} // namespace + +#endif // OPENCV_UTILS_FILESYSTEM_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/instrumentation.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/instrumentation.hpp new file mode 100644 index 0000000..3639867 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/instrumentation.hpp @@ -0,0 +1,125 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_UTILS_INSTR_HPP +#define OPENCV_UTILS_INSTR_HPP + +#include +#include + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +#ifdef CV_COLLECT_IMPL_DATA +CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays +CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays +// Get stored implementation flags and functions names arrays +// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function +CV_EXPORTS int getImpl(std::vector &impl, std::vector &funName); + +CV_EXPORTS bool useCollection(); // return implementation collection state +CV_EXPORTS void setUseCollection(bool flag); // set implementation collection state + +#define CV_IMPL_PLAIN 0x01 // native CPU OpenCV implementation +#define CV_IMPL_OCL 0x02 // OpenCL implementation +#define CV_IMPL_IPP 0x04 // IPP implementation +#define CV_IMPL_MT 0x10 // multithreaded implementation + +#undef CV_IMPL_ADD +#define CV_IMPL_ADD(impl) \ + if(cv::useCollection()) \ + { \ + cv::addImpl(impl, CV_Func); \ + } +#endif + +// Instrumentation external interface +namespace instr +{ + +#if !defined OPENCV_ABI_CHECK + +enum TYPE +{ + TYPE_GENERAL = 0, // OpenCV API function, e.g. exported function + TYPE_MARKER, // Information marker + TYPE_WRAPPER, // Wrapper function for implementation + TYPE_FUN, // Simple function call +}; + +enum IMPL +{ + IMPL_PLAIN = 0, + IMPL_IPP, + IMPL_OPENCL, +}; + +struct NodeDataTls +{ + NodeDataTls() + { + m_ticksTotal = 0; + } + uint64 m_ticksTotal; +}; + +class CV_EXPORTS NodeData +{ +public: + NodeData(const char* funName = 0, const char* fileName = NULL, int lineNum = 0, void* retAddress = NULL, bool alwaysExpand = false, cv::instr::TYPE instrType = TYPE_GENERAL, cv::instr::IMPL implType = IMPL_PLAIN); + NodeData(NodeData &ref); + ~NodeData(); + NodeData& operator=(const NodeData&); + + cv::String m_funName; + cv::instr::TYPE m_instrType; + cv::instr::IMPL m_implType; + const char* m_fileName; + int m_lineNum; + void* m_retAddress; + bool m_alwaysExpand; + bool m_funError; + + volatile int m_counter; + volatile uint64 m_ticksTotal; + TLSDataAccumulator m_tls; + int m_threads; + + // No synchronization + double getTotalMs() const { return ((double)m_ticksTotal / cv::getTickFrequency()) * 1000; } + double getMeanMs() const { return (((double)m_ticksTotal/m_counter) / cv::getTickFrequency()) * 1000; } +}; +bool operator==(const NodeData& lhs, const NodeData& rhs); + +typedef Node InstrNode; + +CV_EXPORTS InstrNode* getTrace(); + +#endif // !defined OPENCV_ABI_CHECK + + +CV_EXPORTS bool useInstrumentation(); +CV_EXPORTS void setUseInstrumentation(bool flag); +CV_EXPORTS void resetTrace(); + +enum FLAGS +{ + FLAGS_NONE = 0, + FLAGS_MAPPING = 0x01, + FLAGS_EXPAND_SAME_NAMES = 0x02, +}; + +CV_EXPORTS void setFlags(FLAGS modeFlags); +static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); } +CV_EXPORTS FLAGS getFlags(); + +} // namespace instr + +//! @} + +} // namespace + +#endif // OPENCV_UTILS_TLS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logger.defines.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logger.defines.hpp new file mode 100644 index 0000000..7d73f02 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logger.defines.hpp @@ -0,0 +1,42 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_LOGGER_DEFINES_HPP +#define OPENCV_LOGGER_DEFINES_HPP + +//! @addtogroup core_logging +//! @{ + +// Supported logging levels and their semantic +#define CV_LOG_LEVEL_SILENT 0 //!< for using in setLogLevel() call +#define CV_LOG_LEVEL_FATAL 1 //!< Fatal (critical) error (unrecoverable internal error) +#define CV_LOG_LEVEL_ERROR 2 //!< Error message +#define CV_LOG_LEVEL_WARN 3 //!< Warning message +#define CV_LOG_LEVEL_INFO 4 //!< Info message +#define CV_LOG_LEVEL_DEBUG 5 //!< Debug message. Disabled in the "Release" build. +#define CV_LOG_LEVEL_VERBOSE 6 //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build. + +namespace cv { +namespace utils { +namespace logging { + +//! Supported logging levels and their semantic +enum LogLevel { + LOG_LEVEL_SILENT = 0, //!< for using in setLogVevel() call + LOG_LEVEL_FATAL = 1, //!< Fatal (critical) error (unrecoverable internal error) + LOG_LEVEL_ERROR = 2, //!< Error message + LOG_LEVEL_WARNING = 3, //!< Warning message + LOG_LEVEL_INFO = 4, //!< Info message + LOG_LEVEL_DEBUG = 5, //!< Debug message. Disabled in the "Release" build. + LOG_LEVEL_VERBOSE = 6, //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build. +#ifndef CV_DOXYGEN + ENUM_LOG_LEVEL_FORCE_INT = INT_MAX +#endif +}; + +}}} // namespace + +//! @} + +#endif // OPENCV_LOGGER_DEFINES_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logger.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logger.hpp new file mode 100644 index 0000000..accb860 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logger.hpp @@ -0,0 +1,218 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_LOGGER_HPP +#define OPENCV_LOGGER_HPP + +#include +#include +#include // INT_MAX + +#include "logger.defines.hpp" +#include "logtag.hpp" + +namespace cv { +namespace utils { +namespace logging { + +//! @addtogroup core_logging +//! @{ + +/** Set global logging level +@return previous logging level +*/ +CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel); +/** Get global logging level */ +CV_EXPORTS LogLevel getLogLevel(); + +CV_EXPORTS void registerLogTag(cv::utils::logging::LogTag* plogtag); + +CV_EXPORTS void setLogTagLevel(const char* tag, cv::utils::logging::LogLevel level); + +CV_EXPORTS cv::utils::logging::LogLevel getLogTagLevel(const char* tag); + +namespace internal { + +/** Get global log tag */ +CV_EXPORTS cv::utils::logging::LogTag* getGlobalLogTag(); + +/** Write log message */ +CV_EXPORTS void writeLogMessage(LogLevel logLevel, const char* message); + +/** Write log message */ +CV_EXPORTS void writeLogMessageEx(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message); + +} // namespace + +struct LogTagAuto + : public LogTag +{ + inline LogTagAuto(const char* _name, LogLevel _level) + : LogTag(_name, _level) + { + registerLogTag(this); + } +}; + +/** + * \def CV_LOG_STRIP_LEVEL + * + * Define CV_LOG_STRIP_LEVEL=CV_LOG_LEVEL_[DEBUG|INFO|WARN|ERROR|FATAL|SILENT] to compile out anything at that and before that logging level + */ +#ifndef CV_LOG_STRIP_LEVEL +# if defined NDEBUG +# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG +# else +# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE +# endif +#endif + +#define CV_LOGTAG_PTR_CAST(expr) static_cast(expr) + +// CV_LOGTAG_EXPAND_NAME is intended to be re-defined (undef and then define again) +// to allows logging users to use a shorter name argument when calling +// CV_LOG_WITH_TAG or its related macros such as CV_LOG_INFO. +// +// This macro is intended to modify the tag argument as a string (token), via +// preprocessor token pasting or metaprogramming techniques. A typical usage +// is to apply a prefix, such as +// ...... #define CV_LOGTAG_EXPAND_NAME(tag) cv_logtag_##tag +// +// It is permitted to re-define to a hard-coded expression, ignoring the tag. +// This would work identically like the CV_LOGTAG_FALLBACK macro. +// +// Important: When the logging macro is called with tag being NULL, a user-defined +// CV_LOGTAG_EXPAND_NAME may expand it into cv_logtag_0, cv_logtag_NULL, or +// cv_logtag_nullptr. Use with care. Also be mindful of C++ symbol redefinitions. +// +// If there is significant amount of logging code with tag being NULL, it is +// recommended to use (re-define) CV_LOGTAG_FALLBACK to inject locally a default +// tag at the beginning of a compilation unit, to minimize lines of code changes. +// +#define CV_LOGTAG_EXPAND_NAME(tag) tag + +// CV_LOGTAG_FALLBACK is intended to be re-defined (undef and then define again) +// by any other compilation units to provide a log tag when the logging statement +// does not specify one. The macro needs to expand into a C++ expression that can +// be static_cast into (cv::utils::logging::LogTag*). Null (nullptr) is permitted. +#define CV_LOGTAG_FALLBACK nullptr + +// CV_LOGTAG_GLOBAL is the tag used when a log tag is not specified in the logging +// statement nor the compilation unit. The macro needs to expand into a C++ +// expression that can be static_cast into (cv::utils::logging::LogTag*). Must be +// non-null. Do not re-define. +#define CV_LOGTAG_GLOBAL cv::utils::logging::internal::getGlobalLogTag() + +#define CV_LOG_WITH_TAG(tag, msgLevel, extra_check0, extra_check1, ...) \ + for(;;) { \ + extra_check0; \ + const auto cv_temp_msglevel = (cv::utils::logging::LogLevel)(msgLevel); \ + if (cv_temp_msglevel >= (CV_LOG_STRIP_LEVEL)) break; \ + auto cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_EXPAND_NAME(tag)); \ + if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_FALLBACK); \ + if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_GLOBAL); \ + if (cv_temp_logtagptr && (cv_temp_msglevel > cv_temp_logtagptr->level)) break; \ + extra_check1; \ + std::stringstream cv_temp_logstream; \ + cv_temp_logstream << __VA_ARGS__; \ + cv::utils::logging::internal::writeLogMessageEx( \ + cv_temp_msglevel, \ + (cv_temp_logtagptr ? cv_temp_logtagptr->name : nullptr), \ + __FILE__, \ + __LINE__, \ + CV_Func, \ + cv_temp_logstream.str().c_str()); \ + break; \ + } + +#define CV_LOG_FATAL(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , , __VA_ARGS__) +#define CV_LOG_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , , __VA_ARGS__) +#define CV_LOG_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , , __VA_ARGS__) +#define CV_LOG_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , , __VA_ARGS__) +#define CV_LOG_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , , __VA_ARGS__) +#define CV_LOG_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , , __VA_ARGS__) + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO +#undef CV_LOG_INFO +#define CV_LOG_INFO(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG +#undef CV_LOG_DEBUG +#define CV_LOG_DEBUG(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE +#undef CV_LOG_VERBOSE +#define CV_LOG_VERBOSE(tag, v, ...) +#endif + +//! @cond IGNORED +#define CV__LOG_ONCE_CHECK_PRE \ + static bool _cv_log_once_ ## __LINE__ = false; \ + if (_cv_log_once_ ## __LINE__) break; + +#define CV__LOG_ONCE_CHECK_POST \ + _cv_log_once_ ## __LINE__ = true; + +#define CV__LOG_IF_CHECK(logging_cond) \ + if (!(logging_cond)) break; + +//! @endcond + + +// CV_LOG_ONCE_XXX macros + +#define CV_LOG_ONCE_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) +#define CV_LOG_ONCE_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__) + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO +#undef CV_LOG_ONCE_INFO +#define CV_LOG_ONCE_INFO(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG +#undef CV_LOG_ONCE_DEBUG +#define CV_LOG_ONCE_DEBUG(tag, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE +#undef CV_LOG_ONCE_VERBOSE +#define CV_LOG_ONCE_VERBOSE(tag, v, ...) +#endif + + +// CV_LOG_IF_XXX macros + +#define CV_LOG_IF_FATAL(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_ERROR(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_WARNING(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_INFO(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_DEBUG(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) +#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__) + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO +#undef CV_LOG_IF_INFO +#define CV_LOG_IF_INFO(tag, logging_cond, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG +#undef CV_LOG_IF_DEBUG +#define CV_LOG_IF_DEBUG(tag, logging_cond, ...) +#endif + +#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE +#undef CV_LOG_IF_VERBOSE +#define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) +#endif + + +//! @} + +}}} // namespace + +#endif // OPENCV_LOGGER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logtag.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logtag.hpp new file mode 100644 index 0000000..4089720 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/logtag.hpp @@ -0,0 +1,28 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_LOGTAG_HPP +#define OPENCV_CORE_LOGTAG_HPP + +#include "opencv2/core/cvstd.hpp" +#include "logger.defines.hpp" + +namespace cv { +namespace utils { +namespace logging { + +struct LogTag +{ + const char* name; + LogLevel level; + + inline LogTag(const char* _name, LogLevel _level) + : name(_name) + , level(_level) + {} +}; + +}}} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/tls.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/tls.hpp new file mode 100644 index 0000000..124caeb --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/tls.hpp @@ -0,0 +1,235 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_UTILS_TLS_HPP +#define OPENCV_UTILS_TLS_HPP + +#ifndef OPENCV_CORE_UTILITY_H +#error "tls.hpp must be included after opencv2/core/utility.hpp or opencv2/core.hpp" +#endif + +namespace cv { + +//! @addtogroup core_utils +//! @{ + +namespace details { class TlsStorage; } + +/** TLS container base implementation + * + * Don't use directly. + * + * @sa TLSData, TLSDataAccumulator templates + */ +class CV_EXPORTS TLSDataContainer +{ +protected: + TLSDataContainer(); + virtual ~TLSDataContainer(); + + /// @deprecated use detachData() instead + void gatherData(std::vector &data) const; + /// get TLS data and detach all data from threads (similar to cleanup() call) + void detachData(std::vector& data); + + void* getData() const; + void release(); + +protected: + virtual void* createDataInstance() const = 0; + virtual void deleteDataInstance(void* pData) const = 0; + +private: + int key_; + + friend class cv::details::TlsStorage; // core/src/system.cpp + +public: + void cleanup(); //!< Release created TLS data container objects. It is similar to release() call, but it keeps TLS container valid. + +private: + // Disable copy/assign (noncopyable pattern) + TLSDataContainer(TLSDataContainer &) = delete; + TLSDataContainer& operator =(const TLSDataContainer &) = delete; +}; + + +/** @brief Simple TLS data class + * + * @sa TLSDataAccumulator + */ +template +class TLSData : protected TLSDataContainer +{ +public: + inline TLSData() {} + inline ~TLSData() { release(); } + + inline T* get() const { return (T*)getData(); } //!< Get data associated with key + inline T& getRef() const { T* ptr = (T*)getData(); CV_DbgAssert(ptr); return *ptr; } //!< Get data associated with key + + /// Release associated thread data + inline void cleanup() + { + TLSDataContainer::cleanup(); + } + +protected: + /// Wrapper to allocate data by template + virtual void* createDataInstance() const CV_OVERRIDE { return new T; } + /// Wrapper to release data by template + virtual void deleteDataInstance(void* pData) const CV_OVERRIDE { delete (T*)pData; } +}; + + +/// TLS data accumulator with gathering methods +template +class TLSDataAccumulator : public TLSData +{ + mutable cv::Mutex mutex; + mutable std::vector dataFromTerminatedThreads; + std::vector detachedData; + bool cleanupMode; +public: + TLSDataAccumulator() : cleanupMode(false) {} + ~TLSDataAccumulator() + { + release(); + } + + /** @brief Get data from all threads + * @deprecated replaced by detachData() + * + * Lifetime of vector data is valid until next detachData()/cleanup()/release() calls + * + * @param[out] data result buffer (should be empty) + */ + void gather(std::vector &data) const + { + CV_Assert(cleanupMode == false); // state is not valid + CV_Assert(data.empty()); + { + std::vector &dataVoid = reinterpret_cast&>(data); + TLSDataContainer::gatherData(dataVoid); + } + { + AutoLock lock(mutex); + data.reserve(data.size() + dataFromTerminatedThreads.size()); + for (typename std::vector::const_iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i) + { + data.push_back((T*)*i); + } + } + } + + /** @brief Get and detach data from all threads + * + * Call cleanupDetachedData() when returned vector is not needed anymore. + * + * @return Vector with associated data. Content is preserved (including lifetime of attached data pointers) until next detachData()/cleanupDetachedData()/cleanup()/release() calls + */ + std::vector& detachData() + { + CV_Assert(cleanupMode == false); // state is not valid + std::vector dataVoid; + { + TLSDataContainer::detachData(dataVoid); + } + { + AutoLock lock(mutex); + detachedData.reserve(dataVoid.size() + dataFromTerminatedThreads.size()); + for (typename std::vector::const_iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i) + { + detachedData.push_back((T*)*i); + } + dataFromTerminatedThreads.clear(); + for (typename std::vector::const_iterator i = dataVoid.begin(); i != dataVoid.end(); ++i) + { + detachedData.push_back((T*)(void*)*i); + } + } + dataVoid.clear(); + return detachedData; + } + + /// Release associated thread data returned by detachData() call + void cleanupDetachedData() + { + AutoLock lock(mutex); + cleanupMode = true; + _cleanupDetachedData(); + cleanupMode = false; + } + + /// Release associated thread data + void cleanup() + { + cleanupMode = true; + TLSDataContainer::cleanup(); + + AutoLock lock(mutex); + _cleanupDetachedData(); + _cleanupTerminatedData(); + cleanupMode = false; + } + + /// Release associated thread data and free TLS key + void release() + { + cleanupMode = true; + TLSDataContainer::release(); + { + AutoLock lock(mutex); + _cleanupDetachedData(); + _cleanupTerminatedData(); + } + } + +protected: + // synchronized + void _cleanupDetachedData() + { + for (typename std::vector::iterator i = detachedData.begin(); i != detachedData.end(); ++i) + { + deleteDataInstance((T*)*i); + } + detachedData.clear(); + } + + // synchronized + void _cleanupTerminatedData() + { + for (typename std::vector::iterator i = dataFromTerminatedThreads.begin(); i != dataFromTerminatedThreads.end(); ++i) + { + deleteDataInstance((T*)*i); + } + dataFromTerminatedThreads.clear(); + } + +protected: + virtual void* createDataInstance() const CV_OVERRIDE + { + // Note: we can collect all allocated data here, but this would require raced mutex locks + return new T; + } + virtual void deleteDataInstance(void* pData) const CV_OVERRIDE + { + if (cleanupMode) + { + delete (T*)pData; + } + else + { + AutoLock lock(mutex); + dataFromTerminatedThreads.push_back((T*)pData); + } + } +}; + + +//! @} + +} // namespace + +#endif // OPENCV_UTILS_TLS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/trace.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/trace.hpp new file mode 100644 index 0000000..ef5d35b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/utils/trace.hpp @@ -0,0 +1,252 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_TRACE_HPP +#define OPENCV_TRACE_HPP + +#include + +namespace cv { +namespace utils { +namespace trace { + +//! @addtogroup core_logging +//! @{ + +//! Macro to trace function +#define CV_TRACE_FUNCTION() + +#define CV_TRACE_FUNCTION_SKIP_NESTED() + +//! Trace code scope. +//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "initialize". +#define CV_TRACE_REGION(name_as_static_string_literal) +//! mark completed of the current opened region and create new one +//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "step1". +#define CV_TRACE_REGION_NEXT(name_as_static_string_literal) + +//! Macro to trace argument value +#define CV_TRACE_ARG(arg_id) + +//! Macro to trace argument value (expanded version) +#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) + +//! @cond IGNORED +#define CV_TRACE_NS cv::utils::trace + +#if !defined(OPENCV_DISABLE_TRACE) && defined(__EMSCRIPTEN__) +#define OPENCV_DISABLE_TRACE 1 +#endif + +namespace details { + +#ifndef __OPENCV_TRACE +# if defined __OPENCV_BUILD && !defined __OPENCV_TESTS && !defined __OPENCV_APPS +# define __OPENCV_TRACE 1 +# else +# define __OPENCV_TRACE 0 +# endif +#endif + +#ifndef CV_TRACE_FILENAME +# define CV_TRACE_FILENAME __FILE__ +#endif + +#ifndef CV__TRACE_FUNCTION +# if defined _MSC_VER +# define CV__TRACE_FUNCTION __FUNCSIG__ +# elif defined __GNUC__ +# define CV__TRACE_FUNCTION __PRETTY_FUNCTION__ +# else +# define CV__TRACE_FUNCTION "" +# endif +#endif + +//! Thread-local instance (usually allocated on stack) +class CV_EXPORTS Region +{ +public: + struct LocationExtraData; + struct LocationStaticStorage + { + LocationExtraData** ppExtra; //< implementation specific data + const char* name; //< region name (function name or other custom name) + const char* filename; //< source code filename + int line; //< source code line + int flags; //< flags (implementation code path: Plain, IPP, OpenCL) + }; + + Region(const LocationStaticStorage& location); + inline ~Region() + { + if (implFlags != 0) + destroy(); + CV_DbgAssert(implFlags == 0); + CV_DbgAssert(pImpl == NULL); + } + + class Impl; + Impl* pImpl; // NULL if current region is not active + int implFlags; // see RegionFlag, 0 if region is ignored + + bool isActive() const { return pImpl != NULL; } + + void destroy(); +private: + Region(const Region&); // disabled + Region& operator= (const Region&); // disabled +}; + +//! Specify region flags +enum RegionLocationFlag { + REGION_FLAG_FUNCTION = (1 << 0), //< region is function (=1) / nested named region (=0) + REGION_FLAG_APP_CODE = (1 << 1), //< region is Application code (=1) / OpenCV library code (=0) + REGION_FLAG_SKIP_NESTED = (1 << 2), //< avoid processing of nested regions + + REGION_FLAG_IMPL_IPP = (1 << 16), //< region is part of IPP code path + REGION_FLAG_IMPL_OPENCL = (2 << 16), //< region is part of OpenCL code path + REGION_FLAG_IMPL_OPENVX = (3 << 16), //< region is part of OpenVX code path + + REGION_FLAG_IMPL_MASK = (15 << 16), + + REGION_FLAG_REGION_FORCE = (1 << 30), + REGION_FLAG_REGION_NEXT = (1 << 31), //< close previous region (see #CV_TRACE_REGION_NEXT macro) + + ENUM_REGION_FLAG_FORCE_INT = INT_MAX +}; + +struct CV_EXPORTS TraceArg { +public: + struct ExtraData; + ExtraData** ppExtra; + const char* name; + int flags; +}; +/** @brief Add meta information to current region (function) + * See CV_TRACE_ARG macro + * @param arg argument information structure (global static cache) + * @param value argument value (can by dynamic string literal in case of string, static allocation is not required) + */ +CV_EXPORTS void traceArg(const TraceArg& arg, const char* value); +//! @overload +CV_EXPORTS void traceArg(const TraceArg& arg, int value); +//! @overload +CV_EXPORTS void traceArg(const TraceArg& arg, int64 value); +//! @overload +CV_EXPORTS void traceArg(const TraceArg& arg, double value); + +#define CV__TRACE_LOCATION_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_, loc_id), __LINE__) +#define CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_extra_, loc_id) , __LINE__) + +#define CV__TRACE_DEFINE_LOCATION_(loc_id, name, flags) \ + static CV_TRACE_NS::details::Region::LocationExtraData* CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) = 0; \ + static const CV_TRACE_NS::details::Region::LocationStaticStorage \ + CV__TRACE_LOCATION_VARNAME(loc_id) = { &(CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id)), name, CV_TRACE_FILENAME, __LINE__, flags}; + +#define CV__TRACE_DEFINE_LOCATION_FN(name, flags) CV__TRACE_DEFINE_LOCATION_(fn, name, ((flags) | CV_TRACE_NS::details::REGION_FLAG_FUNCTION)) + + +#define CV__TRACE_OPENCV_FUNCTION() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, 0); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_OPENCV_FUNCTION_NAME(name) \ + CV__TRACE_DEFINE_LOCATION_FN(name, 0); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_APP_FUNCTION() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_APP_FUNCTION_NAME(name) \ + CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + + +#define CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_OPENCV_FUNCTION_NAME_SKIP_NESTED(name) \ + CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + +#define CV__TRACE_APP_FUNCTION_SKIP_NESTED() \ + CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED | CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \ + const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn)); + + +#define CV__TRACE_REGION_(name_as_static_string_literal, flags) \ + CV__TRACE_DEFINE_LOCATION_(region, name_as_static_string_literal, flags); \ + CV_TRACE_NS::details::Region CVAUX_CONCAT(__region_, __LINE__)(CV__TRACE_LOCATION_VARNAME(region)); + +#define CV__TRACE_REGION(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, 0) +#define CV__TRACE_REGION_NEXT(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, CV_TRACE_NS::details::REGION_FLAG_REGION_NEXT) + +#define CV__TRACE_ARG_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_ ## arg_id, __LINE__) +#define CV__TRACE_ARG_EXTRA_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_extra_ ## arg_id, __LINE__) + +#define CV__TRACE_DEFINE_ARG_(arg_id, name, flags) \ + static CV_TRACE_NS::details::TraceArg::ExtraData* CV__TRACE_ARG_EXTRA_VARNAME(arg_id) = 0; \ + static const CV_TRACE_NS::details::TraceArg \ + CV__TRACE_ARG_VARNAME(arg_id) = { &(CV__TRACE_ARG_EXTRA_VARNAME(arg_id)), name, flags }; + +#define CV__TRACE_ARG_VALUE(arg_id, arg_name, value) \ + CV__TRACE_DEFINE_ARG_(arg_id, arg_name, 0); \ + CV_TRACE_NS::details::traceArg((CV__TRACE_ARG_VARNAME(arg_id)), value); + +#define CV__TRACE_ARG(arg_id) CV_TRACE_ARG_VALUE(arg_id, #arg_id, (arg_id)) + +} // namespace + +#ifndef OPENCV_DISABLE_TRACE +#undef CV_TRACE_FUNCTION +#undef CV_TRACE_FUNCTION_SKIP_NESTED +#if __OPENCV_TRACE +#define CV_TRACE_FUNCTION CV__TRACE_OPENCV_FUNCTION +#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED +#else +#define CV_TRACE_FUNCTION CV__TRACE_APP_FUNCTION +#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_APP_FUNCTION_SKIP_NESTED +#endif + +#undef CV_TRACE_REGION +#define CV_TRACE_REGION CV__TRACE_REGION + +#undef CV_TRACE_REGION_NEXT +#define CV_TRACE_REGION_NEXT CV__TRACE_REGION_NEXT + +#undef CV_TRACE_ARG_VALUE +#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) \ + if (__region_fn.isActive()) \ + { \ + CV__TRACE_ARG_VALUE(arg_id, arg_name, value); \ + } + +#undef CV_TRACE_ARG +#define CV_TRACE_ARG CV__TRACE_ARG + +#endif // OPENCV_DISABLE_TRACE + +#ifdef OPENCV_TRACE_VERBOSE +#define CV_TRACE_FUNCTION_VERBOSE CV_TRACE_FUNCTION +#define CV_TRACE_REGION_VERBOSE CV_TRACE_REGION +#define CV_TRACE_REGION_NEXT_VERBOSE CV_TRACE_REGION_NEXT +#define CV_TRACE_ARG_VALUE_VERBOSE CV_TRACE_ARG_VALUE +#define CV_TRACE_ARG_VERBOSE CV_TRACE_ARG +#else +#define CV_TRACE_FUNCTION_VERBOSE(...) +#define CV_TRACE_REGION_VERBOSE(...) +#define CV_TRACE_REGION_NEXT_VERBOSE(...) +#define CV_TRACE_ARG_VALUE_VERBOSE(...) +#define CV_TRACE_ARG_VERBOSE(...) +#endif + +//! @endcond + +//! @} + +}}} // namespace + +#endif // OPENCV_TRACE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/va_intel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/va_intel.hpp new file mode 100644 index 0000000..b37ce75 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/va_intel.hpp @@ -0,0 +1,75 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2015, Itseez, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_CORE_VA_INTEL_HPP +#define OPENCV_CORE_VA_INTEL_HPP + +#ifndef __cplusplus +# error va_intel.hpp header must be compiled as C++ +#endif + +#include "opencv2/core.hpp" +#include "ocl.hpp" + +#if defined(HAVE_VA) +# include "va/va.h" +#else // HAVE_VA +# if !defined(_VA_H_) + typedef void* VADisplay; + typedef unsigned int VASurfaceID; +# endif // !_VA_H_ +#endif // HAVE_VA + +namespace cv { namespace va_intel { + +/** @addtogroup core_va_intel +This section describes Intel VA-API/OpenCL (CL-VA) interoperability. + +To enable basic VA interoperability build OpenCV with libva library integration enabled: `-DWITH_VA=ON` (corresponding dev package should be installed). + +To enable advanced CL-VA interoperability support on Intel HW, enable option: `-DWITH_VA_INTEL=ON` (OpenCL integration should be enabled which is the default setting). Special runtime environment should be set up in order to use this feature: correct combination of [libva](https://github.com/intel/libva), [OpenCL runtime](https://github.com/intel/compute-runtime) and [media driver](https://github.com/intel/media-driver) should be installed. + +Check usage example for details: samples/va_intel/va_intel_interop.cpp +*/ +//! @{ + +/////////////////// CL-VA Interoperability Functions /////////////////// + +namespace ocl { +using namespace cv::ocl; + +// TODO static functions in the Context class +/** @brief Creates OpenCL context from VA. +@param display - VADisplay for which CL interop should be established. +@param tryInterop - try to set up for interoperability, if true; set up for use slow copy if false. +@return Returns reference to OpenCL Context + */ +CV_EXPORTS Context& initializeContextFromVA(VADisplay display, bool tryInterop = true); + +} // namespace cv::va_intel::ocl + +/** @brief Converts InputArray to VASurfaceID object. +@param display - VADisplay object. +@param src - source InputArray. +@param surface - destination VASurfaceID object. +@param size - size of image represented by VASurfaceID object. + */ +CV_EXPORTS void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size); + +/** @brief Converts VASurfaceID object to OutputArray. +@param display - VADisplay object. +@param surface - source VASurfaceID object. +@param size - size of image represented by VASurfaceID object. +@param dst - destination OutputArray. + */ +CV_EXPORTS void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, OutputArray dst); + +//! @} + +}} // namespace cv::va_intel + +#endif /* OPENCV_CORE_VA_INTEL_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/version.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/version.hpp new file mode 100644 index 0000000..2fbd499 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/version.hpp @@ -0,0 +1,26 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VERSION_HPP +#define OPENCV_VERSION_HPP + +#define CV_VERSION_MAJOR 4 +#define CV_VERSION_MINOR 5 +#define CV_VERSION_REVISION 5 +#define CV_VERSION_STATUS "" + +#define CVAUX_STR_EXP(__A) #__A +#define CVAUX_STR(__A) CVAUX_STR_EXP(__A) + +#define CVAUX_STRW_EXP(__A) L ## #__A +#define CVAUX_STRW(__A) CVAUX_STRW_EXP(__A) + +#define CV_VERSION CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS + +/* old style version constants*/ +#define CV_MAJOR_VERSION CV_VERSION_MAJOR +#define CV_MINOR_VERSION CV_VERSION_MINOR +#define CV_SUBMINOR_VERSION CV_VERSION_REVISION + +#endif // OPENCV_VERSION_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/core/vsx_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/vsx_utils.hpp new file mode 100644 index 0000000..68863ff --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/core/vsx_utils.hpp @@ -0,0 +1,1042 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef OPENCV_HAL_VSX_UTILS_HPP +#define OPENCV_HAL_VSX_UTILS_HPP + +#include "opencv2/core/cvdef.h" + +#ifndef SKIP_INCLUDES +# include +#endif + +//! @addtogroup core_utils_vsx +//! @{ +#if CV_VSX + +#define __VSX_S16__(c, v) (c){v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, v} +#define __VSX_S8__(c, v) (c){v, v, v, v, v, v, v, v} +#define __VSX_S4__(c, v) (c){v, v, v, v} +#define __VSX_S2__(c, v) (c){v, v} + +typedef __vector unsigned char vec_uchar16; +#define vec_uchar16_set(...) (vec_uchar16){__VA_ARGS__} +#define vec_uchar16_sp(c) (__VSX_S16__(vec_uchar16, (unsigned char)c)) +#define vec_uchar16_c(v) ((vec_uchar16)(v)) +#define vec_uchar16_z vec_uchar16_sp(0) + +typedef __vector signed char vec_char16; +#define vec_char16_set(...) (vec_char16){__VA_ARGS__} +#define vec_char16_sp(c) (__VSX_S16__(vec_char16, (signed char)c)) +#define vec_char16_c(v) ((vec_char16)(v)) +#define vec_char16_z vec_char16_sp(0) + +typedef __vector unsigned short vec_ushort8; +#define vec_ushort8_set(...) (vec_ushort8){__VA_ARGS__} +#define vec_ushort8_sp(c) (__VSX_S8__(vec_ushort8, (unsigned short)c)) +#define vec_ushort8_c(v) ((vec_ushort8)(v)) +#define vec_ushort8_z vec_ushort8_sp(0) + +typedef __vector signed short vec_short8; +#define vec_short8_set(...) (vec_short8){__VA_ARGS__} +#define vec_short8_sp(c) (__VSX_S8__(vec_short8, (signed short)c)) +#define vec_short8_c(v) ((vec_short8)(v)) +#define vec_short8_z vec_short8_sp(0) + +typedef __vector unsigned int vec_uint4; +#define vec_uint4_set(...) (vec_uint4){__VA_ARGS__} +#define vec_uint4_sp(c) (__VSX_S4__(vec_uint4, (unsigned int)c)) +#define vec_uint4_c(v) ((vec_uint4)(v)) +#define vec_uint4_z vec_uint4_sp(0) + +typedef __vector signed int vec_int4; +#define vec_int4_set(...) (vec_int4){__VA_ARGS__} +#define vec_int4_sp(c) (__VSX_S4__(vec_int4, (signed int)c)) +#define vec_int4_c(v) ((vec_int4)(v)) +#define vec_int4_z vec_int4_sp(0) + +typedef __vector float vec_float4; +#define vec_float4_set(...) (vec_float4){__VA_ARGS__} +#define vec_float4_sp(c) (__VSX_S4__(vec_float4, c)) +#define vec_float4_c(v) ((vec_float4)(v)) +#define vec_float4_z vec_float4_sp(0) + +typedef __vector unsigned long long vec_udword2; +#define vec_udword2_set(...) (vec_udword2){__VA_ARGS__} +#define vec_udword2_sp(c) (__VSX_S2__(vec_udword2, (unsigned long long)c)) +#define vec_udword2_c(v) ((vec_udword2)(v)) +#define vec_udword2_z vec_udword2_sp(0) + +typedef __vector signed long long vec_dword2; +#define vec_dword2_set(...) (vec_dword2){__VA_ARGS__} +#define vec_dword2_sp(c) (__VSX_S2__(vec_dword2, (signed long long)c)) +#define vec_dword2_c(v) ((vec_dword2)(v)) +#define vec_dword2_z vec_dword2_sp(0) + +typedef __vector double vec_double2; +#define vec_double2_set(...) (vec_double2){__VA_ARGS__} +#define vec_double2_c(v) ((vec_double2)(v)) +#define vec_double2_sp(c) (__VSX_S2__(vec_double2, c)) +#define vec_double2_z vec_double2_sp(0) + +#define vec_bchar16 __vector __bool char +#define vec_bchar16_set(...) (vec_bchar16){__VA_ARGS__} +#define vec_bchar16_c(v) ((vec_bchar16)(v)) + +#define vec_bshort8 __vector __bool short +#define vec_bshort8_set(...) (vec_bshort8){__VA_ARGS__} +#define vec_bshort8_c(v) ((vec_bshort8)(v)) + +#define vec_bint4 __vector __bool int +#define vec_bint4_set(...) (vec_bint4){__VA_ARGS__} +#define vec_bint4_c(v) ((vec_bint4)(v)) + +#define vec_bdword2 __vector __bool long long +#define vec_bdword2_set(...) (vec_bdword2){__VA_ARGS__} +#define vec_bdword2_c(v) ((vec_bdword2)(v)) + +#define VSX_FINLINE(tp) extern inline tp __attribute__((always_inline)) + +#define VSX_REDIRECT_1RG(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) { return fn2(a); } + +#define VSX_REDIRECT_2RG(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a, const rg& b) { return fn2(a, b); } + +/* + * GCC VSX compatibility +**/ +#if defined(__GNUG__) && !defined(__clang__) + +// inline asm helper +#define VSX_IMPL_1RG(rt, rg, opc, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ rt rs; __asm__ __volatile__(#opc" %x0,%x1" : "=wa" (rs) : "wa" (a)); return rs; } + +#define VSX_IMPL_1VRG(rt, rg, opc, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ rt rs; __asm__ __volatile__(#opc" %0,%1" : "=v" (rs) : "v" (a)); return rs; } + +#define VSX_IMPL_2VRG_F(rt, rg, fopc, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a, const rg& b) \ +{ rt rs; __asm__ __volatile__(fopc : "=v" (rs) : "v" (a), "v" (b)); return rs; } + +#define VSX_IMPL_2VRG(rt, rg, opc, fnm) VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%1,%2", fnm) + +#if __GNUG__ < 8 + + // Support for int4 -> dword2 expanding multiply was added in GCC 8. + #ifdef vec_mule + #undef vec_mule + #endif + #ifdef vec_mulo + #undef vec_mulo + #endif + + VSX_REDIRECT_2RG(vec_ushort8, vec_uchar16, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_short8, vec_char16, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_int4, vec_short8, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_uint4, vec_ushort8, vec_mule, __builtin_vec_mule) + VSX_REDIRECT_2RG(vec_ushort8, vec_uchar16, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_short8, vec_char16, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_int4, vec_short8, vec_mulo, __builtin_vec_mulo) + VSX_REDIRECT_2RG(vec_uint4, vec_ushort8, vec_mulo, __builtin_vec_mulo) + + // dword2 support arrived in ISA 2.07 and GCC 8+ + VSX_IMPL_2VRG(vec_dword2, vec_int4, vmulosw, vec_mule) + VSX_IMPL_2VRG(vec_udword2, vec_uint4, vmulouw, vec_mule) + VSX_IMPL_2VRG(vec_dword2, vec_int4, vmulesw, vec_mulo) + VSX_IMPL_2VRG(vec_udword2, vec_uint4, vmuleuw, vec_mulo) + +#endif + +#if __GNUG__ < 7 +// up to GCC 6 vec_mul only supports precisions and llong +# ifdef vec_mul +# undef vec_mul +# endif +/* + * there's no a direct instruction for supporting 8-bit, 16-bit multiplication in ISA 2.07, + * XLC Implement it by using instruction "multiply even", "multiply odd" and "permute" +**/ +# define VSX_IMPL_MULH(Tvec, cperm) \ + VSX_FINLINE(Tvec) vec_mul(const Tvec& a, const Tvec& b) \ + { \ + static const vec_uchar16 ev_od = {cperm}; \ + return vec_perm((Tvec)vec_mule(a, b), (Tvec)vec_mulo(a, b), ev_od); \ + } + #define VSX_IMPL_MULH_P16 0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30 + VSX_IMPL_MULH(vec_char16, VSX_IMPL_MULH_P16) + VSX_IMPL_MULH(vec_uchar16, VSX_IMPL_MULH_P16) + #define VSX_IMPL_MULH_P8 0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29 + VSX_IMPL_MULH(vec_short8, VSX_IMPL_MULH_P8) + VSX_IMPL_MULH(vec_ushort8, VSX_IMPL_MULH_P8) + // vmuluwm can be used for unsigned or signed integers, that's what they said + VSX_IMPL_2VRG(vec_int4, vec_int4, vmuluwm, vec_mul) + VSX_IMPL_2VRG(vec_uint4, vec_uint4, vmuluwm, vec_mul) + // redirect to GCC builtin vec_mul, since it already supports precisions and llong + VSX_REDIRECT_2RG(vec_float4, vec_float4, vec_mul, __builtin_vec_mul) + VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mul, __builtin_vec_mul) + VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mul, __builtin_vec_mul) + VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mul, __builtin_vec_mul) +#endif // __GNUG__ < 7 + +#if __GNUG__ < 6 +/* + * Instruction "compare greater than or equal" in ISA 2.07 only supports single + * and double precision. + * In XLC and new versions of GCC implement integers by using instruction "greater than" and NOR. +**/ +# ifdef vec_cmpge +# undef vec_cmpge +# endif +# ifdef vec_cmple +# undef vec_cmple +# endif +# define vec_cmple(a, b) vec_cmpge(b, a) +# define VSX_IMPL_CMPGE(rt, rg, opc, fnm) \ + VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%2,%1\n\t xxlnor %x0,%x0,%x0", fnm) + + VSX_IMPL_CMPGE(vec_bchar16, vec_char16, vcmpgtsb, vec_cmpge) + VSX_IMPL_CMPGE(vec_bchar16, vec_uchar16, vcmpgtub, vec_cmpge) + VSX_IMPL_CMPGE(vec_bshort8, vec_short8, vcmpgtsh, vec_cmpge) + VSX_IMPL_CMPGE(vec_bshort8, vec_ushort8, vcmpgtuh, vec_cmpge) + VSX_IMPL_CMPGE(vec_bint4, vec_int4, vcmpgtsw, vec_cmpge) + VSX_IMPL_CMPGE(vec_bint4, vec_uint4, vcmpgtuw, vec_cmpge) + VSX_IMPL_CMPGE(vec_bdword2, vec_dword2, vcmpgtsd, vec_cmpge) + VSX_IMPL_CMPGE(vec_bdword2, vec_udword2, vcmpgtud, vec_cmpge) + +// redirect to GCC builtin cmpge, since it already supports precisions + VSX_REDIRECT_2RG(vec_bint4, vec_float4, vec_cmpge, __builtin_vec_cmpge) + VSX_REDIRECT_2RG(vec_bdword2, vec_double2, vec_cmpge, __builtin_vec_cmpge) + +// up to gcc5 vec_nor doesn't support bool long long +# undef vec_nor + template + VSX_REDIRECT_2RG(T, T, vec_nor, __builtin_vec_nor) + + VSX_FINLINE(vec_bdword2) vec_nor(const vec_bdword2& a, const vec_bdword2& b) + { return vec_bdword2_c(__builtin_vec_nor(vec_dword2_c(a), vec_dword2_c(b))); } + +// vec_packs doesn't support double words in gcc4 and old versions of gcc5 +# undef vec_packs + VSX_REDIRECT_2RG(vec_char16, vec_short8, vec_packs, __builtin_vec_packs) + VSX_REDIRECT_2RG(vec_uchar16, vec_ushort8, vec_packs, __builtin_vec_packs) + VSX_REDIRECT_2RG(vec_short8, vec_int4, vec_packs, __builtin_vec_packs) + VSX_REDIRECT_2RG(vec_ushort8, vec_uint4, vec_packs, __builtin_vec_packs) + + VSX_IMPL_2VRG_F(vec_int4, vec_dword2, "vpksdss %0,%2,%1", vec_packs) + VSX_IMPL_2VRG_F(vec_uint4, vec_udword2, "vpkudus %0,%2,%1", vec_packs) +#endif // __GNUG__ < 6 + +#if __GNUG__ < 5 +// vec_xxpermdi in gcc4 missing little-endian supports just like clang +# define vec_permi(a, b, c) vec_xxpermdi(b, a, (3 ^ (((c) & 1) << 1 | (c) >> 1))) +// same as vec_xxpermdi +# undef vec_vbpermq + VSX_IMPL_2VRG(vec_udword2, vec_uchar16, vbpermq, vec_vbpermq) + VSX_IMPL_2VRG(vec_dword2, vec_char16, vbpermq, vec_vbpermq) +#else +# define vec_permi vec_xxpermdi +#endif // __GNUG__ < 5 + +// shift left double by word immediate +#ifndef vec_sldw +# define vec_sldw __builtin_vsx_xxsldwi +#endif + +// vector population count +VSX_IMPL_1VRG(vec_uchar16, vec_uchar16, vpopcntb, vec_popcntu) +VSX_IMPL_1VRG(vec_uchar16, vec_char16, vpopcntb, vec_popcntu) +VSX_IMPL_1VRG(vec_ushort8, vec_ushort8, vpopcnth, vec_popcntu) +VSX_IMPL_1VRG(vec_ushort8, vec_short8, vpopcnth, vec_popcntu) +VSX_IMPL_1VRG(vec_uint4, vec_uint4, vpopcntw, vec_popcntu) +VSX_IMPL_1VRG(vec_uint4, vec_int4, vpopcntw, vec_popcntu) +VSX_IMPL_1VRG(vec_udword2, vec_udword2, vpopcntd, vec_popcntu) +VSX_IMPL_1VRG(vec_udword2, vec_dword2, vpopcntd, vec_popcntu) + +// converts between single and double-precision +VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, __builtin_vsx_xvcvdpsp) +VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, __builtin_vsx_xvcvspdp) + +// converts word and doubleword to double-precision +#undef vec_ctd +VSX_IMPL_1RG(vec_double2, vec_int4, xvcvsxwdp, vec_ctdo) +VSX_IMPL_1RG(vec_double2, vec_uint4, xvcvuxwdp, vec_ctdo) +VSX_IMPL_1RG(vec_double2, vec_dword2, xvcvsxddp, vec_ctd) +VSX_IMPL_1RG(vec_double2, vec_udword2, xvcvuxddp, vec_ctd) + +// converts word and doubleword to single-precision +#undef vec_ctf +VSX_IMPL_1RG(vec_float4, vec_int4, xvcvsxwsp, vec_ctf) +VSX_IMPL_1RG(vec_float4, vec_uint4, xvcvuxwsp, vec_ctf) +VSX_IMPL_1RG(vec_float4, vec_dword2, xvcvsxdsp, vec_ctfo) +VSX_IMPL_1RG(vec_float4, vec_udword2, xvcvuxdsp, vec_ctfo) + +// converts single and double precision to signed word +#undef vec_cts +VSX_IMPL_1RG(vec_int4, vec_double2, xvcvdpsxws, vec_ctso) +VSX_IMPL_1RG(vec_int4, vec_float4, xvcvspsxws, vec_cts) + +// converts single and double precision to unsigned word +#undef vec_ctu +VSX_IMPL_1RG(vec_uint4, vec_double2, xvcvdpuxws, vec_ctuo) +VSX_IMPL_1RG(vec_uint4, vec_float4, xvcvspuxws, vec_ctu) + +// converts single and double precision to signed doubleword +#undef vec_ctsl +VSX_IMPL_1RG(vec_dword2, vec_double2, xvcvdpsxds, vec_ctsl) +VSX_IMPL_1RG(vec_dword2, vec_float4, xvcvspsxds, vec_ctslo) + +// converts single and double precision to unsigned doubleword +#undef vec_ctul +VSX_IMPL_1RG(vec_udword2, vec_double2, xvcvdpuxds, vec_ctul) +VSX_IMPL_1RG(vec_udword2, vec_float4, xvcvspuxds, vec_ctulo) + +// just in case if GCC doesn't define it +#ifndef vec_xl +# define vec_xl vec_vsx_ld +# define vec_xst vec_vsx_st +#endif + +#endif // GCC VSX compatibility + +/* + * CLANG VSX compatibility +**/ +#if defined(__clang__) && !defined(__IBMCPP__) + +/* + * CLANG doesn't support %x in the inline asm template which fixes register number + * when using any of the register constraints wa, wd, wf + * + * For more explanation checkout PowerPC and IBM RS6000 in https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html + * Also there's already an open bug https://bugs.llvm.org/show_bug.cgi?id=31837 + * + * So we're not able to use inline asm and only use built-in functions that CLANG supports + * and use __builtin_convertvector if clang missing any of vector conversions built-in functions + * + * todo: clang asm template bug is fixed, need to reconsider the current workarounds. +*/ + +// convert vector helper +#define VSX_IMPL_CONVERT(rt, rg, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) { return __builtin_convertvector(a, rt); } + +#if __clang_major__ < 5 +// implement vec_permi in a dirty way +# define VSX_IMPL_CLANG_4_PERMI(Tvec) \ + VSX_FINLINE(Tvec) vec_permi(const Tvec& a, const Tvec& b, unsigned const char c) \ + { \ + switch (c) \ + { \ + case 0: \ + return vec_mergeh(a, b); \ + case 1: \ + return vec_mergel(vec_mergeh(a, a), b); \ + case 2: \ + return vec_mergeh(vec_mergel(a, a), b); \ + default: \ + return vec_mergel(a, b); \ + } \ + } + VSX_IMPL_CLANG_4_PERMI(vec_udword2) + VSX_IMPL_CLANG_4_PERMI(vec_dword2) + VSX_IMPL_CLANG_4_PERMI(vec_double2) + +// vec_xxsldwi is missing in clang 4 +# define vec_xxsldwi(a, b, c) vec_sld(a, b, (c) * 4) +#else +// vec_xxpermdi is missing little-endian supports in clang 4 just like gcc4 +# define vec_permi(a, b, c) vec_xxpermdi(b, a, (3 ^ (((c) & 1) << 1 | (c) >> 1))) +#endif // __clang_major__ < 5 + +// shift left double by word immediate +#ifndef vec_sldw +# define vec_sldw vec_xxsldwi +#endif + +// Implement vec_rsqrt since clang only supports vec_rsqrte +#ifndef vec_rsqrt + VSX_FINLINE(vec_float4) vec_rsqrt(const vec_float4& a) + { return vec_div(vec_float4_sp(1), vec_sqrt(a)); } + + VSX_FINLINE(vec_double2) vec_rsqrt(const vec_double2& a) + { return vec_div(vec_double2_sp(1), vec_sqrt(a)); } +#endif + +// vec_promote missing support for doubleword +VSX_FINLINE(vec_dword2) vec_promote(long long a, int b) +{ + vec_dword2 ret = vec_dword2_z; + ret[b & 1] = a; + return ret; +} + +VSX_FINLINE(vec_udword2) vec_promote(unsigned long long a, int b) +{ + vec_udword2 ret = vec_udword2_z; + ret[b & 1] = a; + return ret; +} + +// vec_popcnt should return unsigned but clang has different thought just like gcc in vec_vpopcnt +#define VSX_IMPL_POPCNTU(Tvec, Tvec2, ucast) \ +VSX_FINLINE(Tvec) vec_popcntu(const Tvec2& a) \ +{ return ucast(vec_popcnt(a)); } +VSX_IMPL_POPCNTU(vec_uchar16, vec_char16, vec_uchar16_c); +VSX_IMPL_POPCNTU(vec_ushort8, vec_short8, vec_ushort8_c); +VSX_IMPL_POPCNTU(vec_uint4, vec_int4, vec_uint4_c); +VSX_IMPL_POPCNTU(vec_udword2, vec_dword2, vec_udword2_c); +// redirect unsigned types +VSX_REDIRECT_1RG(vec_uchar16, vec_uchar16, vec_popcntu, vec_popcnt) +VSX_REDIRECT_1RG(vec_ushort8, vec_ushort8, vec_popcntu, vec_popcnt) +VSX_REDIRECT_1RG(vec_uint4, vec_uint4, vec_popcntu, vec_popcnt) +VSX_REDIRECT_1RG(vec_udword2, vec_udword2, vec_popcntu, vec_popcnt) + +// converts between single and double precision +VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, __builtin_vsx_xvcvdpsp) +VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, __builtin_vsx_xvcvspdp) + +// converts word and doubleword to double-precision +#ifdef vec_ctd +# undef vec_ctd +#endif +VSX_REDIRECT_1RG(vec_double2, vec_int4, vec_ctdo, __builtin_vsx_xvcvsxwdp) +VSX_REDIRECT_1RG(vec_double2, vec_uint4, vec_ctdo, __builtin_vsx_xvcvuxwdp) + +VSX_IMPL_CONVERT(vec_double2, vec_dword2, vec_ctd) +VSX_IMPL_CONVERT(vec_double2, vec_udword2, vec_ctd) + +// converts word and doubleword to single-precision +#if __clang_major__ > 4 +# undef vec_ctf +#endif +VSX_IMPL_CONVERT(vec_float4, vec_int4, vec_ctf) +VSX_IMPL_CONVERT(vec_float4, vec_uint4, vec_ctf) +VSX_REDIRECT_1RG(vec_float4, vec_dword2, vec_ctfo, __builtin_vsx_xvcvsxdsp) +VSX_REDIRECT_1RG(vec_float4, vec_udword2, vec_ctfo, __builtin_vsx_xvcvuxdsp) + +// converts single and double precision to signed word +#if __clang_major__ > 4 +# undef vec_cts +#endif +VSX_REDIRECT_1RG(vec_int4, vec_double2, vec_ctso, __builtin_vsx_xvcvdpsxws) +VSX_IMPL_CONVERT(vec_int4, vec_float4, vec_cts) + +// converts single and double precision to unsigned word +#if __clang_major__ > 4 +# undef vec_ctu +#endif +VSX_REDIRECT_1RG(vec_uint4, vec_double2, vec_ctuo, __builtin_vsx_xvcvdpuxws) +VSX_IMPL_CONVERT(vec_uint4, vec_float4, vec_ctu) + +// converts single and double precision to signed doubleword +#ifdef vec_ctsl +# undef vec_ctsl +#endif +VSX_IMPL_CONVERT(vec_dword2, vec_double2, vec_ctsl) +// __builtin_convertvector unable to convert, xvcvspsxds is missing on it +VSX_FINLINE(vec_dword2) vec_ctslo(const vec_float4& a) +{ return vec_ctsl(vec_cvfo(a)); } + +// converts single and double precision to unsigned doubleword +#ifdef vec_ctul +# undef vec_ctul +#endif +VSX_IMPL_CONVERT(vec_udword2, vec_double2, vec_ctul) +// __builtin_convertvector unable to convert, xvcvspuxds is missing on it +VSX_FINLINE(vec_udword2) vec_ctulo(const vec_float4& a) +{ return vec_ctul(vec_cvfo(a)); } + +#endif // CLANG VSX compatibility + +/* + * Common GCC, CLANG compatibility +**/ +#if defined(__GNUG__) && !defined(__IBMCPP__) + +#ifdef vec_cvf +# undef vec_cvf +#endif + +#define VSX_IMPL_CONV_EVEN_4_2(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ return fn2(vec_sldw(a, a, 1)); } + +VSX_IMPL_CONV_EVEN_4_2(vec_double2, vec_float4, vec_cvf, vec_cvfo) +VSX_IMPL_CONV_EVEN_4_2(vec_double2, vec_int4, vec_ctd, vec_ctdo) +VSX_IMPL_CONV_EVEN_4_2(vec_double2, vec_uint4, vec_ctd, vec_ctdo) + +VSX_IMPL_CONV_EVEN_4_2(vec_dword2, vec_float4, vec_ctsl, vec_ctslo) +VSX_IMPL_CONV_EVEN_4_2(vec_udword2, vec_float4, vec_ctul, vec_ctulo) + +#define VSX_IMPL_CONV_EVEN_2_4(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ \ + rt v4 = fn2(a); \ + return vec_sldw(v4, v4, 3); \ +} + +VSX_IMPL_CONV_EVEN_2_4(vec_float4, vec_double2, vec_cvf, vec_cvfo) +VSX_IMPL_CONV_EVEN_2_4(vec_float4, vec_dword2, vec_ctf, vec_ctfo) +VSX_IMPL_CONV_EVEN_2_4(vec_float4, vec_udword2, vec_ctf, vec_ctfo) + +VSX_IMPL_CONV_EVEN_2_4(vec_int4, vec_double2, vec_cts, vec_ctso) +VSX_IMPL_CONV_EVEN_2_4(vec_uint4, vec_double2, vec_ctu, vec_ctuo) + +// Only for Eigen! +/* + * changing behavior of conversion intrinsics for gcc has effect on Eigen + * so we redefine old behavior again only on gcc, clang +*/ +#if !defined(__clang__) || __clang_major__ > 4 + // ignoring second arg since Eigen only truncates toward zero +# define VSX_IMPL_CONV_2VARIANT(rt, rg, fnm, fn2) \ + VSX_FINLINE(rt) fnm(const rg& a, int only_truncate) \ + { \ + assert(only_truncate == 0); \ + CV_UNUSED(only_truncate); \ + return fn2(a); \ + } + VSX_IMPL_CONV_2VARIANT(vec_int4, vec_float4, vec_cts, vec_cts) + VSX_IMPL_CONV_2VARIANT(vec_uint4, vec_float4, vec_ctu, vec_ctu) + VSX_IMPL_CONV_2VARIANT(vec_float4, vec_int4, vec_ctf, vec_ctf) + VSX_IMPL_CONV_2VARIANT(vec_float4, vec_uint4, vec_ctf, vec_ctf) + // define vec_cts for converting double precision to signed doubleword + // which isn't compatible with xlc but its okay since Eigen only uses it for gcc + VSX_IMPL_CONV_2VARIANT(vec_dword2, vec_double2, vec_cts, vec_ctsl) +#endif // Eigen + +#endif // Common GCC, CLANG compatibility + +/* + * XLC VSX compatibility +**/ +#if defined(__IBMCPP__) + +// vector population count +#define vec_popcntu vec_popcnt + +// overload and redirect with setting second arg to zero +// since we only support conversions without the second arg +#define VSX_IMPL_OVERLOAD_Z2(rt, rg, fnm) \ +VSX_FINLINE(rt) fnm(const rg& a) { return fnm(a, 0); } + +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_int4, vec_ctd) +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_uint4, vec_ctd) +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_dword2, vec_ctd) +VSX_IMPL_OVERLOAD_Z2(vec_double2, vec_udword2, vec_ctd) + +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_int4, vec_ctf) +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_uint4, vec_ctf) +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_dword2, vec_ctf) +VSX_IMPL_OVERLOAD_Z2(vec_float4, vec_udword2, vec_ctf) + +VSX_IMPL_OVERLOAD_Z2(vec_int4, vec_double2, vec_cts) +VSX_IMPL_OVERLOAD_Z2(vec_int4, vec_float4, vec_cts) + +VSX_IMPL_OVERLOAD_Z2(vec_uint4, vec_double2, vec_ctu) +VSX_IMPL_OVERLOAD_Z2(vec_uint4, vec_float4, vec_ctu) + +VSX_IMPL_OVERLOAD_Z2(vec_dword2, vec_double2, vec_ctsl) +VSX_IMPL_OVERLOAD_Z2(vec_dword2, vec_float4, vec_ctsl) + +VSX_IMPL_OVERLOAD_Z2(vec_udword2, vec_double2, vec_ctul) +VSX_IMPL_OVERLOAD_Z2(vec_udword2, vec_float4, vec_ctul) + +// fixme: implement conversions of odd-numbered elements in a dirty way +// since xlc doesn't support VSX registers operand in inline asm. +#define VSX_IMPL_CONV_ODD_4_2(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) { return fn2(vec_sldw(a, a, 3)); } + +VSX_IMPL_CONV_ODD_4_2(vec_double2, vec_float4, vec_cvfo, vec_cvf) +VSX_IMPL_CONV_ODD_4_2(vec_double2, vec_int4, vec_ctdo, vec_ctd) +VSX_IMPL_CONV_ODD_4_2(vec_double2, vec_uint4, vec_ctdo, vec_ctd) + +VSX_IMPL_CONV_ODD_4_2(vec_dword2, vec_float4, vec_ctslo, vec_ctsl) +VSX_IMPL_CONV_ODD_4_2(vec_udword2, vec_float4, vec_ctulo, vec_ctul) + +#define VSX_IMPL_CONV_ODD_2_4(rt, rg, fnm, fn2) \ +VSX_FINLINE(rt) fnm(const rg& a) \ +{ \ + rt v4 = fn2(a); \ + return vec_sldw(v4, v4, 1); \ +} + +VSX_IMPL_CONV_ODD_2_4(vec_float4, vec_double2, vec_cvfo, vec_cvf) +VSX_IMPL_CONV_ODD_2_4(vec_float4, vec_dword2, vec_ctfo, vec_ctf) +VSX_IMPL_CONV_ODD_2_4(vec_float4, vec_udword2, vec_ctfo, vec_ctf) + +VSX_IMPL_CONV_ODD_2_4(vec_int4, vec_double2, vec_ctso, vec_cts) +VSX_IMPL_CONV_ODD_2_4(vec_uint4, vec_double2, vec_ctuo, vec_ctu) + +#endif // XLC VSX compatibility + +// ignore GCC warning that caused by -Wunused-but-set-variable in rare cases +#if defined(__GNUG__) && !defined(__clang__) +# define VSX_UNUSED(Tvec) Tvec __attribute__((__unused__)) +#else // CLANG, XLC +# define VSX_UNUSED(Tvec) Tvec +#endif + +// gcc can find his way in casting log int and XLC, CLANG ambiguous +#if defined(__clang__) || defined(__IBMCPP__) + VSX_FINLINE(vec_udword2) vec_splats(uint64 v) + { return vec_splats((unsigned long long) v); } + + VSX_FINLINE(vec_dword2) vec_splats(int64 v) + { return vec_splats((long long) v); } + + VSX_FINLINE(vec_udword2) vec_promote(uint64 a, int b) + { return vec_promote((unsigned long long) a, b); } + + VSX_FINLINE(vec_dword2) vec_promote(int64 a, int b) + { return vec_promote((long long) a, b); } +#endif + +/* + * implement vsx_ld(offset, pointer), vsx_st(vector, offset, pointer) + * load and set using offset depend on the pointer type + * + * implement vsx_ldf(offset, pointer), vsx_stf(vector, offset, pointer) + * load and set using offset depend on fixed bytes size + * + * Note: In clang vec_xl and vec_xst fails to load unaligned addresses + * so we are using vec_vsx_ld, vec_vsx_st instead +*/ + +#if defined(__clang__) && !defined(__IBMCPP__) +# define vsx_ldf vec_vsx_ld +# define vsx_stf vec_vsx_st +#else // GCC , XLC +# define vsx_ldf vec_xl +# define vsx_stf vec_xst +#endif + +#define VSX_OFFSET(o, p) ((o) * sizeof(*(p))) +#define vsx_ld(o, p) vsx_ldf(VSX_OFFSET(o, p), p) +#define vsx_st(v, o, p) vsx_stf(v, VSX_OFFSET(o, p), p) + +/* + * implement vsx_ld2(offset, pointer), vsx_st2(vector, offset, pointer) to load and store double words + * In GCC vec_xl and vec_xst it maps to vec_vsx_ld, vec_vsx_st which doesn't support long long + * and in CLANG we are using vec_vsx_ld, vec_vsx_st because vec_xl, vec_xst fails to load unaligned addresses + * + * In XLC vec_xl and vec_xst fail to cast int64(long int) to long long +*/ +#if (defined(__GNUG__) || defined(__clang__)) && !defined(__IBMCPP__) + VSX_FINLINE(vec_udword2) vsx_ld2(long o, const uint64* p) + { return vec_udword2_c(vsx_ldf(VSX_OFFSET(o, p), (unsigned int*)p)); } + + VSX_FINLINE(vec_dword2) vsx_ld2(long o, const int64* p) + { return vec_dword2_c(vsx_ldf(VSX_OFFSET(o, p), (int*)p)); } + + VSX_FINLINE(void) vsx_st2(const vec_udword2& vec, long o, uint64* p) + { vsx_stf(vec_uint4_c(vec), VSX_OFFSET(o, p), (unsigned int*)p); } + + VSX_FINLINE(void) vsx_st2(const vec_dword2& vec, long o, int64* p) + { vsx_stf(vec_int4_c(vec), VSX_OFFSET(o, p), (int*)p); } +#else // XLC + VSX_FINLINE(vec_udword2) vsx_ld2(long o, const uint64* p) + { return vsx_ldf(VSX_OFFSET(o, p), (unsigned long long*)p); } + + VSX_FINLINE(vec_dword2) vsx_ld2(long o, const int64* p) + { return vsx_ldf(VSX_OFFSET(o, p), (long long*)p); } + + VSX_FINLINE(void) vsx_st2(const vec_udword2& vec, long o, uint64* p) + { vsx_stf(vec, VSX_OFFSET(o, p), (unsigned long long*)p); } + + VSX_FINLINE(void) vsx_st2(const vec_dword2& vec, long o, int64* p) + { vsx_stf(vec, VSX_OFFSET(o, p), (long long*)p); } +#endif + +// Store lower 8 byte +#define vec_st_l8(v, p) *((uint64*)(p)) = vec_extract(vec_udword2_c(v), 0) + +// Store higher 8 byte +#define vec_st_h8(v, p) *((uint64*)(p)) = vec_extract(vec_udword2_c(v), 1) + +// Load 64-bits of integer data to lower part +#define VSX_IMPL_LOAD_L8(Tvec, Tp) \ +VSX_FINLINE(Tvec) vec_ld_l8(const Tp *p) \ +{ return ((Tvec)vec_promote(*((uint64*)p), 0)); } + +VSX_IMPL_LOAD_L8(vec_uchar16, uchar) +VSX_IMPL_LOAD_L8(vec_char16, schar) +VSX_IMPL_LOAD_L8(vec_ushort8, ushort) +VSX_IMPL_LOAD_L8(vec_short8, short) +VSX_IMPL_LOAD_L8(vec_uint4, uint) +VSX_IMPL_LOAD_L8(vec_int4, int) +VSX_IMPL_LOAD_L8(vec_float4, float) +VSX_IMPL_LOAD_L8(vec_udword2, uint64) +VSX_IMPL_LOAD_L8(vec_dword2, int64) +VSX_IMPL_LOAD_L8(vec_double2, double) + +// logical not +#define vec_not(a) vec_nor(a, a) + +// power9 yaya +// not equal +#ifndef vec_cmpne +# define vec_cmpne(a, b) vec_not(vec_cmpeq(a, b)) +#endif + +// absolute difference +#ifndef vec_absd +# define vec_absd(a, b) vec_sub(vec_max(a, b), vec_min(a, b)) +#endif + +/* + * Implement vec_unpacklu and vec_unpackhu + * since vec_unpackl, vec_unpackh only support signed integers +**/ +#define VSX_IMPL_UNPACKU(rt, rg, zero) \ +VSX_FINLINE(rt) vec_unpacklu(const rg& a) \ +{ return (rt)(vec_mergel(a, zero)); } \ +VSX_FINLINE(rt) vec_unpackhu(const rg& a) \ +{ return (rt)(vec_mergeh(a, zero)); } + +VSX_IMPL_UNPACKU(vec_ushort8, vec_uchar16, vec_uchar16_z) +VSX_IMPL_UNPACKU(vec_uint4, vec_ushort8, vec_ushort8_z) +VSX_IMPL_UNPACKU(vec_udword2, vec_uint4, vec_uint4_z) + +/* + * Implement vec_mergesqe and vec_mergesqo + * Merges the sequence values of even and odd elements of two vectors +*/ +#define VSX_IMPL_PERM(rt, fnm, ...) \ +VSX_FINLINE(rt) fnm(const rt& a, const rt& b) \ +{ static const vec_uchar16 perm = {__VA_ARGS__}; return vec_perm(a, b, perm); } + +// 16 +#define perm16_mergesqe 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 +#define perm16_mergesqo 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 +VSX_IMPL_PERM(vec_uchar16, vec_mergesqe, perm16_mergesqe) +VSX_IMPL_PERM(vec_uchar16, vec_mergesqo, perm16_mergesqo) +VSX_IMPL_PERM(vec_char16, vec_mergesqe, perm16_mergesqe) +VSX_IMPL_PERM(vec_char16, vec_mergesqo, perm16_mergesqo) +// 8 +#define perm8_mergesqe 0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29 +#define perm8_mergesqo 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 +VSX_IMPL_PERM(vec_ushort8, vec_mergesqe, perm8_mergesqe) +VSX_IMPL_PERM(vec_ushort8, vec_mergesqo, perm8_mergesqo) +VSX_IMPL_PERM(vec_short8, vec_mergesqe, perm8_mergesqe) +VSX_IMPL_PERM(vec_short8, vec_mergesqo, perm8_mergesqo) +// 4 +#define perm4_mergesqe 0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27 +#define perm4_mergesqo 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31 +VSX_IMPL_PERM(vec_uint4, vec_mergesqe, perm4_mergesqe) +VSX_IMPL_PERM(vec_uint4, vec_mergesqo, perm4_mergesqo) +VSX_IMPL_PERM(vec_int4, vec_mergesqe, perm4_mergesqe) +VSX_IMPL_PERM(vec_int4, vec_mergesqo, perm4_mergesqo) +VSX_IMPL_PERM(vec_float4, vec_mergesqe, perm4_mergesqe) +VSX_IMPL_PERM(vec_float4, vec_mergesqo, perm4_mergesqo) +// 2 +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqe, vec_mergeh) +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqo, vec_mergel) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqe, vec_mergeh) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqo, vec_mergel) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqe, vec_mergeh) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqo, vec_mergel) + +/* + * Implement vec_mergesqh and vec_mergesql + * Merges the sequence most and least significant halves of two vectors +*/ +#define VSX_IMPL_MERGESQHL(Tvec) \ +VSX_FINLINE(Tvec) vec_mergesqh(const Tvec& a, const Tvec& b) \ +{ return (Tvec)vec_mergeh(vec_udword2_c(a), vec_udword2_c(b)); } \ +VSX_FINLINE(Tvec) vec_mergesql(const Tvec& a, const Tvec& b) \ +{ return (Tvec)vec_mergel(vec_udword2_c(a), vec_udword2_c(b)); } +VSX_IMPL_MERGESQHL(vec_uchar16) +VSX_IMPL_MERGESQHL(vec_char16) +VSX_IMPL_MERGESQHL(vec_ushort8) +VSX_IMPL_MERGESQHL(vec_short8) +VSX_IMPL_MERGESQHL(vec_uint4) +VSX_IMPL_MERGESQHL(vec_int4) +VSX_IMPL_MERGESQHL(vec_float4) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqh, vec_mergeh) +VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesql, vec_mergel) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqh, vec_mergeh) +VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesql, vec_mergel) +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqh, vec_mergeh) +VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesql, vec_mergel) + + +// 2 and 4 channels interleave for all types except 2 lanes +#define VSX_IMPL_ST_INTERLEAVE(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, Tp* ptr) \ +{ \ + vsx_stf(vec_mergeh(a, b), 0, ptr); \ + vsx_stf(vec_mergel(a, b), 16, ptr); \ +} \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, const Tvec& d, Tp* ptr) \ +{ \ + Tvec ac = vec_mergeh(a, c); \ + Tvec bd = vec_mergeh(b, d); \ + vsx_stf(vec_mergeh(ac, bd), 0, ptr); \ + vsx_stf(vec_mergel(ac, bd), 16, ptr); \ + ac = vec_mergel(a, c); \ + bd = vec_mergel(b, d); \ + vsx_stf(vec_mergeh(ac, bd), 32, ptr); \ + vsx_stf(vec_mergel(ac, bd), 48, ptr); \ +} +VSX_IMPL_ST_INTERLEAVE(uchar, vec_uchar16) +VSX_IMPL_ST_INTERLEAVE(schar, vec_char16) +VSX_IMPL_ST_INTERLEAVE(ushort, vec_ushort8) +VSX_IMPL_ST_INTERLEAVE(short, vec_short8) +VSX_IMPL_ST_INTERLEAVE(uint, vec_uint4) +VSX_IMPL_ST_INTERLEAVE(int, vec_int4) +VSX_IMPL_ST_INTERLEAVE(float, vec_float4) + +// 2 and 4 channels deinterleave for 16 lanes +#define VSX_IMPL_ST_DINTERLEAVE_8(Tp, Tvec) \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(16, ptr); \ + a = vec_mergesqe(v0, v1); \ + b = vec_mergesqo(v0, v1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(16, ptr); \ + Tvec v2 = vsx_ld(32, ptr); \ + Tvec v3 = vsx_ld(48, ptr); \ + Tvec m0 = vec_mergesqe(v0, v1); \ + Tvec m1 = vec_mergesqe(v2, v3); \ + a = vec_mergesqe(m0, m1); \ + c = vec_mergesqo(m0, m1); \ + m0 = vec_mergesqo(v0, v1); \ + m1 = vec_mergesqo(v2, v3); \ + b = vec_mergesqe(m0, m1); \ + d = vec_mergesqo(m0, m1); \ +} +VSX_IMPL_ST_DINTERLEAVE_8(uchar, vec_uchar16) +VSX_IMPL_ST_DINTERLEAVE_8(schar, vec_char16) + +// 2 and 4 channels deinterleave for 8 lanes +#define VSX_IMPL_ST_DINTERLEAVE_16(Tp, Tvec) \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(8, ptr); \ + a = vec_mergesqe(v0, v1); \ + b = vec_mergesqo(v0, v1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(8, ptr); \ + Tvec m0 = vec_mergeh(v0, v1); \ + Tvec m1 = vec_mergel(v0, v1); \ + Tvec ab0 = vec_mergeh(m0, m1); \ + Tvec cd0 = vec_mergel(m0, m1); \ + v0 = vsx_ld(16, ptr); \ + v1 = vsx_ld(24, ptr); \ + m0 = vec_mergeh(v0, v1); \ + m1 = vec_mergel(v0, v1); \ + Tvec ab1 = vec_mergeh(m0, m1); \ + Tvec cd1 = vec_mergel(m0, m1); \ + a = vec_mergesqh(ab0, ab1); \ + b = vec_mergesql(ab0, ab1); \ + c = vec_mergesqh(cd0, cd1); \ + d = vec_mergesql(cd0, cd1); \ +} +VSX_IMPL_ST_DINTERLEAVE_16(ushort, vec_ushort8) +VSX_IMPL_ST_DINTERLEAVE_16(short, vec_short8) + +// 2 and 4 channels deinterleave for 4 lanes +#define VSX_IMPL_ST_DINTERLEAVE_32(Tp, Tvec) \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + a = vsx_ld(0, ptr); \ + b = vsx_ld(4, ptr); \ + Tvec m0 = vec_mergeh(a, b); \ + Tvec m1 = vec_mergel(a, b); \ + a = vec_mergeh(m0, m1); \ + b = vec_mergel(m0, m1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = vsx_ld(0, ptr); \ + Tvec v1 = vsx_ld(4, ptr); \ + Tvec v2 = vsx_ld(8, ptr); \ + Tvec v3 = vsx_ld(12, ptr); \ + Tvec m0 = vec_mergeh(v0, v2); \ + Tvec m1 = vec_mergeh(v1, v3); \ + a = vec_mergeh(m0, m1); \ + b = vec_mergel(m0, m1); \ + m0 = vec_mergel(v0, v2); \ + m1 = vec_mergel(v1, v3); \ + c = vec_mergeh(m0, m1); \ + d = vec_mergel(m0, m1); \ +} +VSX_IMPL_ST_DINTERLEAVE_32(uint, vec_uint4) +VSX_IMPL_ST_DINTERLEAVE_32(int, vec_int4) +VSX_IMPL_ST_DINTERLEAVE_32(float, vec_float4) + +// 2 and 4 channels interleave and deinterleave for 2 lanes +#define VSX_IMPL_ST_D_INTERLEAVE_64(Tp, Tvec, ld_func, st_func) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, Tp* ptr) \ +{ \ + st_func(vec_mergeh(a, b), 0, ptr); \ + st_func(vec_mergel(a, b), 2, ptr); \ +} \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, const Tvec& d, Tp* ptr) \ +{ \ + st_func(vec_mergeh(a, b), 0, ptr); \ + st_func(vec_mergeh(c, d), 2, ptr); \ + st_func(vec_mergel(a, b), 4, ptr); \ + st_func(vec_mergel(c, d), 6, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \ +{ \ + Tvec m0 = ld_func(0, ptr); \ + Tvec m1 = ld_func(2, ptr); \ + a = vec_mergeh(m0, m1); \ + b = vec_mergel(m0, m1); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \ + Tvec& c, Tvec& d) \ +{ \ + Tvec v0 = ld_func(0, ptr); \ + Tvec v1 = ld_func(2, ptr); \ + Tvec v2 = ld_func(4, ptr); \ + Tvec v3 = ld_func(6, ptr); \ + a = vec_mergeh(v0, v2); \ + b = vec_mergel(v0, v2); \ + c = vec_mergeh(v1, v3); \ + d = vec_mergel(v1, v3); \ +} +VSX_IMPL_ST_D_INTERLEAVE_64(int64, vec_dword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_D_INTERLEAVE_64(uint64, vec_udword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_D_INTERLEAVE_64(double, vec_double2, vsx_ld, vsx_st) + +/* 3 channels */ +#define VSX_IMPL_ST_INTERLEAVE_3CH_16(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + static const vec_uchar16 a12 = {0, 16, 0, 1, 17, 0, 2, 18, 0, 3, 19, 0, 4, 20, 0, 5}; \ + static const vec_uchar16 a123 = {0, 1, 16, 3, 4, 17, 6, 7, 18, 9, 10, 19, 12, 13, 20, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, a12), c, a123), 0, ptr); \ + static const vec_uchar16 b12 = {21, 0, 6, 22, 0, 7, 23, 0, 8, 24, 0, 9, 25, 0, 10, 26}; \ + static const vec_uchar16 b123 = {0, 21, 2, 3, 22, 5, 6, 23, 8, 9, 24, 11, 12, 25, 14, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, b12), c, b123), 16, ptr); \ + static const vec_uchar16 c12 = {0, 11, 27, 0, 12, 28, 0, 13, 29, 0, 14, 30, 0, 15, 31, 0}; \ + static const vec_uchar16 c123 = {26, 1, 2, 27, 4, 5, 28, 7, 8, 29, 10, 11, 30, 13, 14, 31}; \ + vsx_st(vec_perm(vec_perm(a, b, c12), c, c123), 32, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = vsx_ld(0, ptr); \ + Tvec v2 = vsx_ld(16, ptr); \ + Tvec v3 = vsx_ld(32, ptr); \ + static const vec_uchar16 a12_perm = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 a123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 17, 20, 23, 26, 29}; \ + a = vec_perm(vec_perm(v1, v2, a12_perm), v3, a123_perm); \ + static const vec_uchar16 b12_perm = {1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 b123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 18, 21, 24, 27, 30}; \ + b = vec_perm(vec_perm(v1, v2, b12_perm), v3, b123_perm); \ + static const vec_uchar16 c12_perm = {2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 0, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 c123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 19, 22, 25, 28, 31}; \ + c = vec_perm(vec_perm(v1, v2, c12_perm), v3, c123_perm); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_16(uchar, vec_uchar16) +VSX_IMPL_ST_INTERLEAVE_3CH_16(schar, vec_char16) + +#define VSX_IMPL_ST_INTERLEAVE_3CH_8(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + static const vec_uchar16 a12 = {0, 1, 16, 17, 0, 0, 2, 3, 18, 19, 0, 0, 4, 5, 20, 21}; \ + static const vec_uchar16 a123 = {0, 1, 2, 3, 16, 17, 6, 7, 8, 9, 18, 19, 12, 13, 14, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, a12), c, a123), 0, ptr); \ + static const vec_uchar16 b12 = {0, 0, 6, 7, 22, 23, 0, 0, 8, 9, 24, 25, 0, 0, 10, 11}; \ + static const vec_uchar16 b123 = {20, 21, 2, 3, 4, 5, 22, 23, 8, 9, 10, 11, 24, 25, 14, 15}; \ + vsx_st(vec_perm(vec_perm(a, b, b12), c, b123), 8, ptr); \ + static const vec_uchar16 c12 = {26, 27, 0, 0, 12, 13, 28, 29, 0, 0, 14, 15, 30, 31, 0, 0}; \ + static const vec_uchar16 c123 = {0, 1, 26, 27, 4, 5, 6, 7, 28, 29, 10, 11, 12, 13, 30, 31}; \ + vsx_st(vec_perm(vec_perm(a, b, c12), c, c123), 16, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = vsx_ld(0, ptr); \ + Tvec v2 = vsx_ld(8, ptr); \ + Tvec v3 = vsx_ld(16, ptr); \ + static const vec_uchar16 a12_perm = {0, 1, 6, 7, 12, 13, 18, 19, 24, 25, 30, 31, 0, 0, 0, 0}; \ + static const vec_uchar16 a123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 26, 27}; \ + a = vec_perm(vec_perm(v1, v2, a12_perm), v3, a123_perm); \ + static const vec_uchar16 b12_perm = {2, 3, 8, 9, 14, 15, 20, 21, 26, 27, 0, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 b123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 22, 23, 28, 29}; \ + b = vec_perm(vec_perm(v1, v2, b12_perm), v3, b123_perm); \ + static const vec_uchar16 c12_perm = {4, 5, 10, 11, 16, 17, 22, 23, 28, 29, 0, 0, 0, 0, 0, 0}; \ + static const vec_uchar16 c123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 19, 24, 25, 30, 31}; \ + c = vec_perm(vec_perm(v1, v2, c12_perm), v3, c123_perm); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_8(ushort, vec_ushort8) +VSX_IMPL_ST_INTERLEAVE_3CH_8(short, vec_short8) + +#define VSX_IMPL_ST_INTERLEAVE_3CH_4(Tp, Tvec) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + Tvec hbc = vec_mergeh(b, c); \ + static const vec_uchar16 ahbc = {0, 1, 2, 3, 16, 17, 18, 19, 20, 21, 22, 23, 4, 5, 6, 7}; \ + vsx_st(vec_perm(a, hbc, ahbc), 0, ptr); \ + Tvec lab = vec_mergel(a, b); \ + vsx_st(vec_sld(lab, hbc, 8), 4, ptr); \ + static const vec_uchar16 clab = {8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 12, 13, 14, 15};\ + vsx_st(vec_perm(c, lab, clab), 8, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = vsx_ld(0, ptr); \ + Tvec v2 = vsx_ld(4, ptr); \ + Tvec v3 = vsx_ld(8, ptr); \ + static const vec_uchar16 flp = {0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31}; \ + a = vec_perm(v1, vec_sld(v3, v2, 8), flp); \ + static const vec_uchar16 flp2 = {28, 29, 30, 31, 0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19}; \ + b = vec_perm(v2, vec_sld(v1, v3, 8), flp2); \ + c = vec_perm(vec_sld(v2, v1, 8), v3, flp); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_4(uint, vec_uint4) +VSX_IMPL_ST_INTERLEAVE_3CH_4(int, vec_int4) +VSX_IMPL_ST_INTERLEAVE_3CH_4(float, vec_float4) + +#define VSX_IMPL_ST_INTERLEAVE_3CH_2(Tp, Tvec, ld_func, st_func) \ +VSX_FINLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \ + const Tvec& c, Tp* ptr) \ +{ \ + st_func(vec_mergeh(a, b), 0, ptr); \ + st_func(vec_permi(c, a, 1), 2, ptr); \ + st_func(vec_mergel(b, c), 4, ptr); \ +} \ +VSX_FINLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, \ + Tvec& b, Tvec& c) \ +{ \ + Tvec v1 = ld_func(0, ptr); \ + Tvec v2 = ld_func(2, ptr); \ + Tvec v3 = ld_func(4, ptr); \ + a = vec_permi(v1, v2, 1); \ + b = vec_permi(v1, v3, 2); \ + c = vec_permi(v2, v3, 1); \ +} +VSX_IMPL_ST_INTERLEAVE_3CH_2(int64, vec_dword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_INTERLEAVE_3CH_2(uint64, vec_udword2, vsx_ld2, vsx_st2) +VSX_IMPL_ST_INTERLEAVE_3CH_2(double, vec_double2, vsx_ld, vsx_st) + +#endif // CV_VSX + +//! @} + +#endif // OPENCV_HAL_VSX_UTILS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/cvconfig.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/cvconfig.h new file mode 100644 index 0000000..922e589 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/cvconfig.h @@ -0,0 +1,149 @@ +#ifndef OPENCV_CVCONFIG_H_INCLUDED +#define OPENCV_CVCONFIG_H_INCLUDED + +/* OpenCV compiled as static or dynamic libs */ +#define BUILD_SHARED_LIBS + +/* OpenCV intrinsics optimized code */ +#define CV_ENABLE_INTRINSICS + +/* OpenCV additional optimized code */ +/* #undef CV_DISABLE_OPTIMIZATION */ + +/* Compile for 'real' NVIDIA GPU architectures */ +#define CUDA_ARCH_BIN "" + +/* NVIDIA GPU features are used */ +#define CUDA_ARCH_FEATURES "" + +/* Compile for 'virtual' NVIDIA PTX architectures */ +#define CUDA_ARCH_PTX "" + +/* AMD's Basic Linear Algebra Subprograms Library*/ +/* #undef HAVE_CLAMDBLAS */ + +/* AMD's OpenCL Fast Fourier Transform Library*/ +/* #undef HAVE_CLAMDFFT */ + +/* Clp support */ +/* #undef HAVE_CLP */ + +/* NVIDIA CUDA Runtime API*/ +/* #undef HAVE_CUDA */ + +/* NVIDIA CUDA Basic Linear Algebra Subprograms (BLAS) API*/ +/* #undef HAVE_CUBLAS */ + +/* NVIDIA CUDA Deep Neural Network (cuDNN) API*/ +/* #undef HAVE_CUDNN */ + +/* NVIDIA CUDA Fast Fourier Transform (FFT) API*/ +/* #undef HAVE_CUFFT */ + +/* DirectX */ +#define HAVE_DIRECTX +#define HAVE_DIRECTX_NV12 +#define HAVE_D3D11 +#define HAVE_D3D10 +#define HAVE_D3D9 + +/* Eigen Matrix & Linear Algebra Library */ +/* #undef HAVE_EIGEN */ + +/* Geospatial Data Abstraction Library */ +/* #undef HAVE_GDAL */ + +/* Halide support */ +/* #undef HAVE_HALIDE */ + +/* Vulkan support */ +/* #undef HAVE_VULKAN */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Intel Integrated Performance Primitives */ +#define HAVE_IPP +#define HAVE_IPP_ICV +#define HAVE_IPP_IW +#define HAVE_IPP_IW_LL + +/* JPEG-2000 codec */ +#define HAVE_OPENJPEG +/* #undef HAVE_JASPER */ + +/* IJG JPEG codec */ +#define HAVE_JPEG + +/* libpng/png.h needs to be included */ +/* #undef HAVE_LIBPNG_PNG_H */ + +/* GDCM DICOM codec */ +/* #undef HAVE_GDCM */ + +/* NVIDIA Video Decoding API*/ +/* #undef HAVE_NVCUVID */ +/* #undef HAVE_NVCUVID_HEADER */ +/* #undef HAVE_DYNLINK_NVCUVID_HEADER */ + +/* NVIDIA Video Encoding API*/ +/* #undef HAVE_NVCUVENC */ + +/* OpenCL Support */ +#define HAVE_OPENCL +/* #undef HAVE_OPENCL_STATIC */ +/* #undef HAVE_OPENCL_SVM */ + +/* NVIDIA OpenCL D3D Extensions support */ +#define HAVE_OPENCL_D3D11_NV + +/* OpenEXR codec */ +#define HAVE_OPENEXR + +/* OpenGL support*/ +/* #undef HAVE_OPENGL */ + +/* PNG codec */ +#define HAVE_PNG + +/* Posix threads (pthreads) */ +/* #undef HAVE_PTHREAD */ + +/* parallel_for with pthreads */ +/* #undef HAVE_PTHREADS_PF */ + +/* Intel Threading Building Blocks */ +/* #undef HAVE_TBB */ + +/* Ste||ar Group High Performance ParallelX */ +/* #undef HAVE_HPX */ + +/* TIFF codec */ +#define HAVE_TIFF + +/* Define if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* VA library (libva) */ +/* #undef HAVE_VA */ + +/* Intel VA-API/OpenCL */ +/* #undef HAVE_VA_INTEL */ + +/* Lapack */ +/* #undef HAVE_LAPACK */ + +/* Library was compiled with functions instrumentation */ +/* #undef ENABLE_INSTRUMENTATION */ + +/* OpenVX */ +/* #undef HAVE_OPENVX */ + +/* OpenCV trace utilities */ +#define OPENCV_TRACE + +/* Library QR-code decoding */ +#define HAVE_QUIRC + +#endif // OPENCV_CVCONFIG_H_INCLUDED diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn.hpp new file mode 100644 index 0000000..97f2fe3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn.hpp @@ -0,0 +1,78 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_HPP +#define OPENCV_DNN_HPP + +// This is an umbrella header to include into you project. +// We are free to change headers layout in dnn subfolder, so please include +// this header for future compatibility + + +/** @defgroup dnn Deep Neural Network module + @{ + This module contains: + - API for new layers creation, layers are building bricks of neural networks; + - set of built-in most-useful Layers; + - API to construct and modify comprehensive neural networks from layers; + - functionality for loading serialized networks models from different frameworks. + + Functionality of this module is designed only for forward pass computations (i.e. network testing). + A network training is in principle not supported. + @} +*/ +/** @example samples/dnn/classification.cpp +Check @ref tutorial_dnn_googlenet "the corresponding tutorial" for more details +*/ +/** @example samples/dnn/colorization.cpp +*/ +/** @example samples/dnn/object_detection.cpp +Check @ref tutorial_dnn_yolo "the corresponding tutorial" for more details +*/ +/** @example samples/dnn/openpose.cpp +*/ +/** @example samples/dnn/segmentation.cpp +*/ +/** @example samples/dnn/text_detection.cpp +*/ +#include + +#endif /* OPENCV_DNN_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/all_layers.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/all_layers.hpp new file mode 100644 index 0000000..44b16f7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/all_layers.hpp @@ -0,0 +1,1011 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_ALL_LAYERS_HPP +#define OPENCV_DNN_DNN_ALL_LAYERS_HPP +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ + +/** @defgroup dnnLayerList Partial List of Implemented Layers + @{ + This subsection of dnn module contains information about built-in layers and their descriptions. + + Classes listed here, in fact, provides C++ API for creating instances of built-in layers. + In addition to this way of layers instantiation, there is a more common factory API (see @ref dnnLayerFactory), it allows to create layers dynamically (by name) and register new ones. + You can use both API, but factory API is less convenient for native C++ programming and basically designed for use inside importers (see @ref readNetFromCaffe(), @ref readNetFromTorch(), @ref readNetFromTensorflow()). + + Built-in layers partially reproduce functionality of corresponding Caffe and Torch7 layers. + In particular, the following layers and Caffe importer were tested to reproduce Caffe functionality: + - Convolution + - Deconvolution + - Pooling + - InnerProduct + - TanH, ReLU, Sigmoid, BNLL, Power, AbsVal + - Softmax + - Reshape, Flatten, Slice, Split + - LRN + - MVN + - Dropout (since it does nothing on forward pass -)) +*/ + + class CV_EXPORTS BlankLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + /** + * Constant layer produces the same data blob at an every forward pass. + */ + class CV_EXPORTS ConstLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + //! LSTM recurrent layer + class CV_EXPORTS LSTMLayer : public Layer + { + public: + /** Creates instance of LSTM layer */ + static Ptr create(const LayerParams& params); + + /** @deprecated Use LayerParams::blobs instead. + @brief Set trained weights for LSTM layer. + + LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights. + + Let @f$x_t@f$ be current input, @f$h_t@f$ be current output, @f$c_t@f$ be current state. + Than current output and current cell state is computed as follows: + @f{eqnarray*}{ + h_t &= o_t \odot tanh(c_t), \\ + c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\ + @f} + where @f$\odot@f$ is per-element multiply operation and @f$i_t, f_t, o_t, g_t@f$ is internal gates that are computed using learned weights. + + Gates are computed as follows: + @f{eqnarray*}{ + i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\ + f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\ + o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\ + g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\ + @f} + where @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices: + @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$. + + For simplicity and performance purposes we use @f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] @f$ + (i.e. @f$W_x@f$ is vertical concatenation of @f$ W_{x?} @f$), @f$ W_x \in R^{4N_h \times N_x} @f$. + The same for @f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} @f$ + and for @f$ b = [b_i; b_f, b_o, b_g]@f$, @f$b \in R^{4N_h} @f$. + + @param Wh is matrix defining how previous output is transformed to internal gates (i.e. according to above mentioned notation is @f$ W_h @f$) + @param Wx is matrix defining how current input is transformed to internal gates (i.e. according to above mentioned notation is @f$ W_x @f$) + @param b is bias vector (i.e. according to above mentioned notation is @f$ b @f$) + */ + CV_DEPRECATED virtual void setWeights(const Mat &Wh, const Mat &Wx, const Mat &b) = 0; + + /** @brief Specifies shape of output blob which will be [[`T`], `N`] + @p outTailShape. + * @details If this parameter is empty or unset then @p outTailShape = [`Wh`.size(0)] will be used, + * where `Wh` is parameter from setWeights(). + */ + virtual void setOutShape(const MatShape &outTailShape = MatShape()) = 0; + + /** @deprecated Use flag `produce_cell_output` in LayerParams. + * @brief Specifies either interpret first dimension of input blob as timestamp dimension either as sample. + * + * If flag is set to true then shape of input blob will be interpreted as [`T`, `N`, `[data dims]`] where `T` specifies number of timestamps, `N` is number of independent streams. + * In this case each forward() call will iterate through `T` timestamps and update layer's state `T` times. + * + * If flag is set to false then shape of input blob will be interpreted as [`N`, `[data dims]`]. + * In this case each forward() call will make one iteration and produce one timestamp with shape [`N`, `[out dims]`]. + */ + CV_DEPRECATED virtual void setUseTimstampsDim(bool use = true) = 0; + + /** @deprecated Use flag `use_timestamp_dim` in LayerParams. + * @brief If this flag is set to true then layer will produce @f$ c_t @f$ as second output. + * @details Shape of the second output is the same as first output. + */ + CV_DEPRECATED virtual void setProduceCellOutput(bool produce = false) = 0; + + /* In common case it use single input with @f$x_t@f$ values to compute output(s) @f$h_t@f$ (and @f$c_t@f$). + * @param input should contain packed values @f$x_t@f$ + * @param output contains computed outputs: @f$h_t@f$ (and @f$c_t@f$ if setProduceCellOutput() flag was set to true). + * + * If setUseTimstampsDim() is set to true then @p input[0] should has at least two dimensions with the following shape: [`T`, `N`, `[data dims]`], + * where `T` specifies number of timestamps, `N` is number of independent streams (i.e. @f$ x_{t_0 + t}^{stream} @f$ is stored inside @p input[0][t, stream, ...]). + * + * If setUseTimstampsDim() is set to false then @p input[0] should contain single timestamp, its shape should has form [`N`, `[data dims]`] with at least one dimension. + * (i.e. @f$ x_{t}^{stream} @f$ is stored inside @p input[0][stream, ...]). + */ + + int inputNameToIndex(String inputName) CV_OVERRIDE; + int outputNameToIndex(const String& outputName) CV_OVERRIDE; + }; + + /** @brief GRU recurrent one-layer + * + * Accepts input sequence and computes the final hidden state for each element in the batch. + * + * - input[0] containing the features of the input sequence. + * input[0] should have shape [`T`, `N`, `data_dims`] where `T` is sequence length, `N` is batch size, `data_dims` is input size + * - output would have shape [`T`, `N`, `D` * `hidden_size`] where `D = 2` if layer is bidirectional otherwise `D = 1` + * + * Depends on the following attributes: + * - hidden_size - Number of neurons in the hidden layer + * - direction - RNN could be bidirectional or forward + * + * The final hidden state @f$ h_t @f$ computes by the following formulas: + * + @f{eqnarray*}{ + r_t = \sigma(W_{ir} x_t + b_{ir} + W_{hr} h_{(t-1)} + b_{hr}) \\ + z_t = \sigma(W_{iz} x_t + b_{iz} + W_{hz} h_{(t-1)} + b_{hz}) \\ + n_t = \tanh(W_{in} x_t + b_{in} + r_t \odot (W_{hn} h_{(t-1)}+ b_{hn})) \\ + h_t = (1 - z_t) \odot n_t + z_t \odot h_{(t-1)} \\ + @f} + * Where @f$x_t@f$ is current input, @f$h_{(t-1)}@f$ is previous or initial hidden state. + * + * @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices: + * @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$. + * + * @f$\odot@f$ is per-element multiply operation. + */ + class CV_EXPORTS GRULayer : public Layer + { + public: + /** Creates instance of GRU layer */ + static Ptr create(const LayerParams& params); + }; + + /** @brief Classical recurrent layer + + Accepts two inputs @f$x_t@f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t@f$ and @f$h_t@f$. + + - input: should contain packed input @f$x_t@f$. + - output: should contain output @f$o_t@f$ (and @f$h_t@f$ if setProduceHiddenOutput() is set to true). + + input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t@f$ respectively. + + output[0] will have shape [`T`, `N`, @f$N_o@f$], where @f$N_o@f$ is number of rows in @f$ W_{xo} @f$ matrix. + + If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h@f$], where @f$N_h@f$ is number of rows in @f$ W_{hh} @f$ matrix. + */ + class CV_EXPORTS RNNLayer : public Layer + { + public: + /** Creates instance of RNNLayer */ + static Ptr create(const LayerParams& params); + + /** Setups learned weights. + + Recurrent-layer behavior on each step is defined by current input @f$ x_t @f$, previous state @f$ h_t @f$ and learned weights as follows: + @f{eqnarray*}{ + h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\ + o_t &= tanh&(W_{ho} h_t + b_o), + @f} + + @param Wxh is @f$ W_{xh} @f$ matrix + @param bh is @f$ b_{h} @f$ vector + @param Whh is @f$ W_{hh} @f$ matrix + @param Who is @f$ W_{xo} @f$ matrix + @param bo is @f$ b_{o} @f$ vector + */ + virtual void setWeights(const Mat &Wxh, const Mat &bh, const Mat &Whh, const Mat &Who, const Mat &bo) = 0; + + /** @brief If this flag is set to true then layer will produce @f$ h_t @f$ as second output. + * @details Shape of the second output is the same as first output. + */ + virtual void setProduceHiddenOutput(bool produce = false) = 0; + + }; + + class CV_EXPORTS BaseConvolutionLayer : public Layer + { + public: + CV_DEPRECATED_EXTERNAL Size kernel, stride, pad, dilation, adjustPad; + std::vector adjust_pads; + std::vector kernel_size, strides, dilations; + std::vector pads_begin, pads_end; + String padMode; + int numOutput; + }; + + class CV_EXPORTS ConvolutionLayer : public BaseConvolutionLayer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ConvolutionLayerInt8 : public BaseConvolutionLayer + { + public: + int input_zp, output_zp; + float output_sc; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS DeconvolutionLayer : public BaseConvolutionLayer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS LRNLayer : public Layer + { + public: + int type; + + int size; + float alpha, beta, bias; + bool normBySize; + + static Ptr create(const LayerParams& params); + }; + + + /** @brief ArgMax/ArgMin layer + * @note returns indices as floats, which means the supported range is [-2^24; 2^24] + */ + class CV_EXPORTS ArgLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS PoolingLayer : public Layer + { + public: + int type; + std::vector kernel_size, strides; + std::vector pads_begin, pads_end; + bool globalPooling; //!< Flag is true if at least one of the axes is global pooled. + std::vector isGlobalPooling; + bool computeMaxIdx; + String padMode; + bool ceilMode; + // If true for average pooling with padding, divide an every output region + // by a whole kernel area. Otherwise exclude zero padded values and divide + // by number of real values. + bool avePoolPaddedArea; + // ROIPooling parameters. + Size pooledSize; + float spatialScale; + // PSROIPooling parameters. + int psRoiOutChannels; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS PoolingLayerInt8 : public PoolingLayer + { + public: + int input_zp, output_zp; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS SoftmaxLayer : public Layer + { + public: + bool logSoftMax; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS SoftmaxLayerInt8 : public SoftmaxLayer + { + public: + float output_sc; + int output_zp; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS InnerProductLayer : public Layer + { + public: + int axis; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS InnerProductLayerInt8 : public InnerProductLayer + { + public: + int output_zp; + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS MVNLayer : public Layer + { + public: + float eps; + bool normVariance, acrossChannels; + + static Ptr create(const LayerParams& params); + }; + + /* Reshaping */ + + class CV_EXPORTS ReshapeLayer : public Layer + { + public: + MatShape newShapeDesc; + Range newShapeRange; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS FlattenLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS QuantizeLayer : public Layer + { + public: + float scale; + int zeropoint; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS DequantizeLayer : public Layer + { + public: + float scale; + int zeropoint; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS RequantizeLayer : public Layer + { + public: + float scale, shift; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ConcatLayer : public Layer + { + public: + int axis; + /** + * @brief Add zero padding in case of concatenation of blobs with different + * spatial sizes. + * + * Details: https://github.com/torch/nn/blob/master/doc/containers.md#depthconcat + */ + bool padding; + int paddingValue; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SplitLayer : public Layer + { + public: + int outputsCount; //!< Number of copies that will be produced (is ignored when negative). + + static Ptr create(const LayerParams ¶ms); + }; + + /** + * Slice layer has several modes: + * 1. Caffe mode + * @param[in] axis Axis of split operation + * @param[in] slice_point Array of split points + * + * Number of output blobs equals to number of split points plus one. The + * first blob is a slice on input from 0 to @p slice_point[0] - 1 by @p axis, + * the second output blob is a slice of input from @p slice_point[0] to + * @p slice_point[1] - 1 by @p axis and the last output blob is a slice of + * input from @p slice_point[-1] up to the end of @p axis size. + * + * 2. TensorFlow mode + * @param begin Vector of start indices + * @param size Vector of sizes + * + * More convenient numpy-like slice. One and only output blob + * is a slice `input[begin[0]:begin[0]+size[0], begin[1]:begin[1]+size[1], ...]` + * + * 3. Torch mode + * @param axis Axis of split operation + * + * Split input blob on the equal parts by @p axis. + */ + class CV_EXPORTS SliceLayer : public Layer + { + public: + /** + * @brief Vector of slice ranges. + * + * The first dimension equals number of output blobs. + * Inner vector has slice ranges for the first number of input dimensions. + */ + std::vector > sliceRanges; + std::vector > sliceSteps; + int axis; + int num_split; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS PermuteLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /** + * Permute channels of 4-dimensional input blob. + * @param group Number of groups to split input channels and pick in turns + * into output blob. + * + * \f[ groupSize = \frac{number\ of\ channels}{group} \f] + * \f[ output(n, c, h, w) = input(n, groupSize \times (c \% group) + \lfloor \frac{c}{group} \rfloor, h, w) \f] + * Read more at https://arxiv.org/pdf/1707.01083.pdf + */ + class CV_EXPORTS ShuffleChannelLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + + int group; + }; + + /** + * @brief Adds extra values for specific axes. + * @param paddings Vector of paddings in format + * @code + * [ pad_before, pad_after, // [0]th dimension + * pad_before, pad_after, // [1]st dimension + * ... + * pad_before, pad_after ] // [n]th dimension + * @endcode + * that represents number of padded values at every dimension + * starting from the first one. The rest of dimensions won't + * be padded. + * @param value Value to be padded. Defaults to zero. + * @param type Padding type: 'constant', 'reflect' + * @param input_dims Torch's parameter. If @p input_dims is not equal to the + * actual input dimensionality then the `[0]th` dimension + * is considered as a batch dimension and @p paddings are shifted + * to a one dimension. Defaults to `-1` that means padding + * corresponding to @p paddings. + */ + class CV_EXPORTS PaddingLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /* Activations */ + class CV_EXPORTS ActivationLayer : public Layer + { + public: + virtual void forwardSlice(const float* src, float* dst, int len, + size_t outPlaneSize, int cn0, int cn1) const {}; + virtual void forwardSlice(const int* src, const int* lut, int* dst, int len, + size_t outPlaneSize, int cn0, int cn1) const {}; + virtual void forwardSlice(const int8_t* src, const int8_t* lut, int8_t* dst, int len, + size_t outPlaneSize, int cn0, int cn1) const {}; + }; + + class CV_EXPORTS ReLULayer : public ActivationLayer + { + public: + float negativeSlope; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ReLU6Layer : public ActivationLayer + { + public: + float minValue, maxValue; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ChannelsPReLULayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ELULayer : public ActivationLayer + { + public: + float alpha; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS TanHLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SwishLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS MishLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SigmoidLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS BNLLLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AbsLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS PowerLayer : public ActivationLayer + { + public: + float power, scale, shift; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ExpLayer : public ActivationLayer + { + public: + float base, scale, shift; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CeilLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS FloorLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS LogLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS RoundLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SqrtLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS NotLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AcosLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AcoshLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AsinLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AsinhLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AtanLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS AtanhLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CosLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CoshLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ErfLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS HardSwishLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SinLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SinhLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SoftplusLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SoftsignLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS TanLayer : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS CeluLayer : public ActivationLayer + { + public: + float alpha; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS HardSigmoidLayer : public ActivationLayer + { + public: + float alpha; + float beta; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS SeluLayer : public ActivationLayer + { + public: + float alpha; + float gamma; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ThresholdedReluLayer : public ActivationLayer + { + public: + float alpha; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ActivationLayerInt8 : public ActivationLayer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + /* Layers used in semantic segmentation */ + + class CV_EXPORTS CropLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + /** @brief Element wise operation on inputs + + Extra optional parameters: + - "operation" as string. Values are "sum" (default), "prod", "max", "div", "min" + - "coeff" as float array. Specify weights of inputs for SUM operation + - "output_channels_mode" as string. Values are "same" (default, all input must have the same layout), "input_0", "input_0_truncate", "max_input_channels" + */ + class CV_EXPORTS EltwiseLayer : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS EltwiseLayerInt8 : public Layer + { + public: + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS BatchNormLayer : public ActivationLayer + { + public: + bool hasWeights, hasBias; + float epsilon; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS BatchNormLayerInt8 : public BatchNormLayer + { + public: + float input_sc, output_sc; + int input_zp, output_zp; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS MaxUnpoolLayer : public Layer + { + public: + Size poolKernel; + Size poolPad; + Size poolStride; + + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ScaleLayer : public Layer + { + public: + bool hasBias; + int axis; + String mode; + + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ScaleLayerInt8 : public ScaleLayer + { + public: + float output_sc; + int output_zp; + static Ptr create(const LayerParams ¶ms); + }; + + class CV_EXPORTS ShiftLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ShiftLayerInt8 : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CompareLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS DataAugmentationLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CorrelationLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS AccumLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS FlowWarpLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS PriorBoxLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ReorgLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS RegionLayer : public Layer + { + public: + float nmsThreshold; + + static Ptr create(const LayerParams& params); + }; + + /** + * @brief Detection output layer. + * + * The layer size is: @f$ (1 \times 1 \times N \times 7) @f$ + * where N is [keep_top_k] parameter multiplied by batch size. Each row is: + * [image_id, label, confidence, xmin, ymin, xmax, ymax] + * where image_id is the index of image input in the batch. + */ + class CV_EXPORTS DetectionOutputLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /** + * @brief \f$ L_p \f$ - normalization layer. + * @param p Normalization factor. The most common `p = 1` for \f$ L_1 \f$ - + * normalization or `p = 2` for \f$ L_2 \f$ - normalization or a custom one. + * @param eps Parameter \f$ \epsilon \f$ to prevent a division by zero. + * @param across_spatial If true, normalize an input across all non-batch dimensions. + * Otherwise normalize an every channel separately. + * + * Across spatial: + * @f[ + * norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\ + * dst(x, y, c) = \frac{ src(x, y, c) }{norm} + * @f] + * + * Channel wise normalization: + * @f[ + * norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\ + * dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)} + * @f] + * + * Where `x, y` - spatial coordinates, `c` - channel. + * + * An every sample in the batch is normalized separately. Optionally, + * output is scaled by the trained parameters. + */ + class CV_EXPORTS NormalizeBBoxLayer : public Layer + { + public: + float pnorm, epsilon; + CV_DEPRECATED_EXTERNAL bool acrossSpatial; + + static Ptr create(const LayerParams& params); + }; + + /** + * @brief Resize input 4-dimensional blob by nearest neighbor or bilinear strategy. + * + * Layer is used to support TensorFlow's resize_nearest_neighbor and resize_bilinear ops. + */ + class CV_EXPORTS ResizeLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + /** + * @brief Bilinear resize layer from https://github.com/cdmh/deeplab-public-ver2 + * + * It differs from @ref ResizeLayer in output shape and resize scales computations. + */ + class CV_EXPORTS InterpLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS ProposalLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CropAndResizeLayer : public Layer + { + public: + static Ptr create(const LayerParams& params); + }; + + class CV_EXPORTS CumSumLayer : public Layer + { + public: + int exclusive; + int reverse; + + static Ptr create(const LayerParams& params); + }; + +//! @} +//! @} +CV__DNN_INLINE_NS_END +} +} +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dict.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dict.hpp new file mode 100644 index 0000000..463d314 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dict.hpp @@ -0,0 +1,160 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#include +#include +#include + +#include + +#ifndef OPENCV_DNN_DNN_DICT_HPP +#define OPENCV_DNN_DNN_DICT_HPP + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ + +/** @brief This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64. + * @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers. + */ +struct CV_EXPORTS_W DictValue +{ + DictValue(const DictValue &r); + DictValue(bool i) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = i ? 1 : 0; } //!< Constructs integer scalar + DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = i; } //!< Constructs integer scalar + CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = i; } //!< Constructs integer scalar + DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer) { (*pi)[0] = p; } //!< Constructs integer scalar + CV_WRAP DictValue(double p) : type(Param::REAL), pd(new AutoBuffer) { (*pd)[0] = p; } //!< Constructs floating point scalar + CV_WRAP DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer) { (*ps)[0] = s; } //!< Constructs string scalar + DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer) { (*ps)[0] = s; } //!< @overload + + template + static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array + template + static DictValue arrayReal(TypeIter begin, int size); //!< Constructs floating point array + template + static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings + + template + T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns its. + + int size() const; + + CV_WRAP bool isInt() const; + CV_WRAP bool isString() const; + CV_WRAP bool isReal() const; + + CV_WRAP int getIntValue(int idx = -1) const; + CV_WRAP double getRealValue(int idx = -1) const; + CV_WRAP String getStringValue(int idx = -1) const; + + DictValue &operator=(const DictValue &r); + + friend std::ostream &operator<<(std::ostream &stream, const DictValue &dictv); + + ~DictValue(); + +private: + + Param type; + + union + { + AutoBuffer *pi; + AutoBuffer *pd; + AutoBuffer *ps; + void *pv; + }; + + DictValue(Param _type, void *_p) : type(_type), pv(_p) {} + void release(); +}; + +/** @brief This class implements name-value dictionary, values are instances of DictValue. */ +class CV_EXPORTS Dict +{ + typedef std::map _Dict; + _Dict dict; + +public: + + //! Checks a presence of the @p key in the dictionary. + bool has(const String &key) const; + + //! If the @p key in the dictionary then returns pointer to its value, else returns NULL. + DictValue *ptr(const String &key); + + /** @overload */ + const DictValue *ptr(const String &key) const; + + //! If the @p key in the dictionary then returns its value, else an error will be generated. + const DictValue &get(const String &key) const; + + /** @overload */ + template + T get(const String &key) const; + + //! If the @p key in the dictionary then returns its value, else returns @p defaultValue. + template + T get(const String &key, const T &defaultValue) const; + + //! Sets new @p value for the @p key, or adds new key-value pair into the dictionary. + template + const T &set(const String &key, const T &value); + + //! Erase @p key from the dictionary. + void erase(const String &key); + + friend std::ostream &operator<<(std::ostream &stream, const Dict &dict); + + std::map::const_iterator begin() const; + + std::map::const_iterator end() const; +}; + +//! @} +CV__DNN_INLINE_NS_END +} +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dnn.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dnn.hpp new file mode 100644 index 0000000..d6b29cf --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dnn.hpp @@ -0,0 +1,1696 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_HPP +#define OPENCV_DNN_DNN_HPP + +#include +#include +#include "opencv2/core/async.hpp" + +#include "../dnn/version.hpp" + +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ + + typedef std::vector MatShape; + + /** + * @brief Enum of computation backends supported by layers. + * @see Net::setPreferableBackend + */ + enum Backend + { + //! DNN_BACKEND_DEFAULT equals to DNN_BACKEND_INFERENCE_ENGINE if + //! OpenCV is built with Intel's Inference Engine library or + //! DNN_BACKEND_OPENCV otherwise. + DNN_BACKEND_DEFAULT = 0, + DNN_BACKEND_HALIDE, + DNN_BACKEND_INFERENCE_ENGINE, //!< Intel's Inference Engine computational backend + //!< @sa setInferenceEngineBackendType + DNN_BACKEND_OPENCV, + DNN_BACKEND_VKCOM, + DNN_BACKEND_CUDA, + DNN_BACKEND_WEBNN, +#ifdef __OPENCV_BUILD + DNN_BACKEND_INFERENCE_ENGINE_NGRAPH = 1000000, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType() + DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019, // internal - use DNN_BACKEND_INFERENCE_ENGINE + setInferenceEngineBackendType() +#endif + }; + + /** + * @brief Enum of target devices for computations. + * @see Net::setPreferableTarget + */ + enum Target + { + DNN_TARGET_CPU = 0, + DNN_TARGET_OPENCL, + DNN_TARGET_OPENCL_FP16, + DNN_TARGET_MYRIAD, + DNN_TARGET_VULKAN, + DNN_TARGET_FPGA, //!< FPGA device with CPU fallbacks using Inference Engine's Heterogeneous plugin. + DNN_TARGET_CUDA, + DNN_TARGET_CUDA_FP16, + DNN_TARGET_HDDL + }; + + CV_EXPORTS std::vector< std::pair > getAvailableBackends(); + CV_EXPORTS_W std::vector getAvailableTargets(dnn::Backend be); + + /** + * @brief Enables detailed logging of the DNN model loading with CV DNN API. + * @param[in] isDiagnosticsMode Indicates whether diagnostic mode should be set. + * + * Diagnostic mode provides detailed logging of the model loading stage to explore + * potential problems (ex.: not implemented layer type). + * + * @note In diagnostic mode series of assertions will be skipped, it can lead to the + * expected application crash. + */ + CV_EXPORTS void enableModelDiagnostics(bool isDiagnosticsMode); + + /** @brief This class provides all data needed to initialize layer. + * + * It includes dictionary with scalar params (which can be read by using Dict interface), + * blob params #blobs and optional meta information: #name and #type of layer instance. + */ + class CV_EXPORTS LayerParams : public Dict + { + public: + //TODO: Add ability to name blob params + std::vector blobs; //!< List of learned parameters stored as blobs. + + String name; //!< Name of the layer instance (optional, can be used internal purposes). + String type; //!< Type name which was used for creating layer by layer factory (optional). + }; + + /** + * @brief Derivatives of this class encapsulates functions of certain backends. + */ + class BackendNode + { + public: + BackendNode(int backendId); + + virtual ~BackendNode(); //!< Virtual destructor to make polymorphism. + + int backendId; //!< Backend identifier. + }; + + /** + * @brief Derivatives of this class wraps cv::Mat for different backends and targets. + */ + class BackendWrapper + { + public: + BackendWrapper(int backendId, int targetId); + + /** + * @brief Wrap cv::Mat for specific backend and target. + * @param[in] targetId Target identifier. + * @param[in] m cv::Mat for wrapping. + * + * Make CPU->GPU data transfer if it's require for the target. + */ + BackendWrapper(int targetId, const cv::Mat& m); + + /** + * @brief Make wrapper for reused cv::Mat. + * @param[in] base Wrapper of cv::Mat that will be reused. + * @param[in] shape Specific shape. + * + * Initialize wrapper from another one. It'll wrap the same host CPU + * memory and mustn't allocate memory on device(i.e. GPU). It might + * has different shape. Use in case of CPU memory reusing for reuse + * associated memory on device too. + */ + BackendWrapper(const Ptr& base, const MatShape& shape); + + virtual ~BackendWrapper(); //!< Virtual destructor to make polymorphism. + + /** + * @brief Transfer data to CPU host memory. + */ + virtual void copyToHost() = 0; + + /** + * @brief Indicate that an actual data is on CPU. + */ + virtual void setHostDirty() = 0; + + int backendId; //!< Backend identifier. + int targetId; //!< Target identifier. + }; + + class CV_EXPORTS ActivationLayer; + + /** @brief This interface class allows to build new Layers - are building blocks of networks. + * + * Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs. + * Also before using the new layer into networks you must register your layer by using one of @ref dnnLayerFactory "LayerFactory" macros. + */ + class CV_EXPORTS_W Layer : public Algorithm + { + public: + + //! List of learned parameters must be stored here to allow read them by using Net::getParam(). + CV_PROP_RW std::vector blobs; + + /** @brief Computes and sets internal parameters according to inputs, outputs and blobs. + * @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead + * @param[in] input vector of already allocated input blobs + * @param[out] output vector of already allocated output blobs + * + * If this method is called after network has allocated all memory for input and output blobs + * and before inferencing. + */ + CV_DEPRECATED_EXTERNAL + virtual void finalize(const std::vector &input, std::vector &output); + + /** @brief Computes and sets internal parameters according to inputs, outputs and blobs. + * @param[in] inputs vector of already allocated input blobs + * @param[out] outputs vector of already allocated output blobs + * + * If this method is called after network has allocated all memory for input and output blobs + * and before inferencing. + */ + CV_WRAP virtual void finalize(InputArrayOfArrays inputs, OutputArrayOfArrays outputs); + + /** @brief Given the @p input blobs, computes the output @p blobs. + * @deprecated Use Layer::forward(InputArrayOfArrays, OutputArrayOfArrays, OutputArrayOfArrays) instead + * @param[in] input the input blobs. + * @param[out] output allocated output blobs, which will store results of the computation. + * @param[out] internals allocated internal blobs + */ + CV_DEPRECATED_EXTERNAL + virtual void forward(std::vector &input, std::vector &output, std::vector &internals); + + /** @brief Given the @p input blobs, computes the output @p blobs. + * @param[in] inputs the input blobs. + * @param[out] outputs allocated output blobs, which will store results of the computation. + * @param[out] internals allocated internal blobs + */ + virtual void forward(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals); + + /** @brief Tries to quantize the given layer and compute the quantization parameters required for fixed point implementation. + * @param[in] scales input and output scales. + * @param[in] zeropoints input and output zeropoints. + * @param[out] params Quantized parameters required for fixed point implementation of that layer. + * @returns True if layer can be quantized. + */ + virtual bool tryQuantize(const std::vector > &scales, + const std::vector > &zeropoints, LayerParams& params); + + /** @brief Given the @p input blobs, computes the output @p blobs. + * @param[in] inputs the input blobs. + * @param[out] outputs allocated output blobs, which will store results of the computation. + * @param[out] internals allocated internal blobs + */ + void forward_fallback(InputArrayOfArrays inputs, OutputArrayOfArrays outputs, OutputArrayOfArrays internals); + + /** @brief + * @overload + * @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead + */ + CV_DEPRECATED_EXTERNAL + void finalize(const std::vector &inputs, CV_OUT std::vector &outputs); + + /** @brief + * @overload + * @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead + */ + CV_DEPRECATED std::vector finalize(const std::vector &inputs); + + /** @brief Allocates layer and computes output. + * @deprecated This method will be removed in the future release. + */ + CV_DEPRECATED CV_WRAP void run(const std::vector &inputs, CV_OUT std::vector &outputs, + CV_IN_OUT std::vector &internals); + + /** @brief Returns index of input blob into the input array. + * @param inputName label of input blob + * + * Each layer input and output can be labeled to easily identify them using "%[.output_name]" notation. + * This method maps label of input blob to its index into input vector. + */ + virtual int inputNameToIndex(String inputName); + /** @brief Returns index of output blob in output array. + * @see inputNameToIndex() + */ + CV_WRAP virtual int outputNameToIndex(const String& outputName); + + /** + * @brief Ask layer if it support specific backend for doing computations. + * @param[in] backendId computation backend identifier. + * @see Backend + */ + virtual bool supportBackend(int backendId); + + /** + * @brief Returns Halide backend node. + * @param[in] inputs Input Halide buffers. + * @see BackendNode, BackendWrapper + * + * Input buffers should be exactly the same that will be used in forward invocations. + * Despite we can use Halide::ImageParam based on input shape only, + * it helps prevent some memory management issues (if something wrong, + * Halide tests will be failed). + */ + virtual Ptr initHalide(const std::vector > &inputs); + + virtual Ptr initInfEngine(const std::vector > &inputs); + + virtual Ptr initNgraph(const std::vector > &inputs, const std::vector >& nodes); + + virtual Ptr initVkCom(const std::vector > &inputs); + + virtual Ptr initWebnn(const std::vector > &inputs, const std::vector >& nodes); + + /** + * @brief Returns a CUDA backend node + * + * @param context void pointer to CSLContext object + * @param inputs layer inputs + * @param outputs layer outputs + */ + virtual Ptr initCUDA( + void *context, + const std::vector>& inputs, + const std::vector>& outputs + ); + + /** + * @brief Automatic Halide scheduling based on layer hyper-parameters. + * @param[in] node Backend node with Halide functions. + * @param[in] inputs Blobs that will be used in forward invocations. + * @param[in] outputs Blobs that will be used in forward invocations. + * @param[in] targetId Target identifier + * @see BackendNode, Target + * + * Layer don't use own Halide::Func members because we can have applied + * layers fusing. In this way the fused function should be scheduled. + */ + virtual void applyHalideScheduler(Ptr& node, + const std::vector &inputs, + const std::vector &outputs, + int targetId) const; + + /** + * @brief Implement layers fusing. + * @param[in] node Backend node of bottom layer. + * @see BackendNode + * + * Actual for graph-based backends. If layer attached successfully, + * returns non-empty cv::Ptr to node of the same backend. + * Fuse only over the last function. + */ + virtual Ptr tryAttach(const Ptr& node); + + /** + * @brief Tries to attach to the layer the subsequent activation layer, i.e. do the layer fusion in a partial case. + * @param[in] layer The subsequent activation layer. + * + * Returns true if the activation layer has been attached successfully. + */ + virtual bool setActivation(const Ptr& layer); + + /** + * @brief Try to fuse current layer with a next one + * @param[in] top Next layer to be fused. + * @returns True if fusion was performed. + */ + virtual bool tryFuse(Ptr& top); + + /** + * @brief Returns parameters of layers with channel-wise multiplication and addition. + * @param[out] scale Channel-wise multipliers. Total number of values should + * be equal to number of channels. + * @param[out] shift Channel-wise offsets. Total number of values should + * be equal to number of channels. + * + * Some layers can fuse their transformations with further layers. + * In example, convolution + batch normalization. This way base layer + * use weights from layer after it. Fused layer is skipped. + * By default, @p scale and @p shift are empty that means layer has no + * element-wise multiplications or additions. + */ + virtual void getScaleShift(Mat& scale, Mat& shift) const; + + /** + * @brief Returns scale and zeropoint of layers + * @param[out] scale Output scale + * @param[out] zeropoint Output zeropoint + * + * By default, @p scale is 1 and @p zeropoint is 0. + */ + virtual void getScaleZeropoint(float& scale, int& zeropoint) const; + + + /** + * @brief "Deattaches" all the layers, attached to particular layer. + */ + virtual void unsetAttached(); + + virtual bool getMemoryShapes(const std::vector &inputs, + const int requiredOutputs, + std::vector &outputs, + std::vector &internals) const; + + virtual int64 getFLOPS(const std::vector &inputs, + const std::vector &outputs) const {CV_UNUSED(inputs); CV_UNUSED(outputs); return 0;} + + virtual bool updateMemoryShapes(const std::vector &inputs); + + CV_PROP String name; //!< Name of the layer instance, can be used for logging or other internal purposes. + CV_PROP String type; //!< Type name which was used for creating layer by layer factory. + CV_PROP int preferableTarget; //!< prefer target for layer forwarding + + Layer(); + explicit Layer(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields. + void setParamsFrom(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields. + virtual ~Layer(); + }; + + /** @brief This class allows to create and manipulate comprehensive artificial neural networks. + * + * Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, + * and edges specify relationships between layers inputs and outputs. + * + * Each network layer has unique integer id and unique string name inside its network. + * LayerId can store either layer name or layer id. + * + * This class supports reference counting of its instances, i. e. copies point to the same instance. + */ + class CV_EXPORTS_W_SIMPLE Net + { + public: + + CV_WRAP Net(); //!< Default constructor. + CV_WRAP ~Net(); //!< Destructor frees the net only if there aren't references to the net anymore. + + /** @brief Create a network from Intel's Model Optimizer intermediate representation (IR). + * @param[in] xml XML configuration file with network's topology. + * @param[in] bin Binary file with trained weights. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_WRAP static Net readFromModelOptimizer(const String& xml, const String& bin); + + /** @brief Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). + * @param[in] bufferModelConfig buffer with model's configuration. + * @param[in] bufferWeights buffer with model's trained weights. + * @returns Net object. + */ + CV_WRAP static + Net readFromModelOptimizer(const std::vector& bufferModelConfig, const std::vector& bufferWeights); + + /** @brief Create a network from Intel's Model Optimizer in-memory buffers with intermediate representation (IR). + * @param[in] bufferModelConfigPtr buffer pointer of model's configuration. + * @param[in] bufferModelConfigSize buffer size of model's configuration. + * @param[in] bufferWeightsPtr buffer pointer of model's trained weights. + * @param[in] bufferWeightsSize buffer size of model's trained weights. + * @returns Net object. + */ + static + Net readFromModelOptimizer(const uchar* bufferModelConfigPtr, size_t bufferModelConfigSize, + const uchar* bufferWeightsPtr, size_t bufferWeightsSize); + + /** Returns true if there are no layers in the network. */ + CV_WRAP bool empty() const; + + /** @brief Dump net to String + * @returns String with structure, hyperparameters, backend, target and fusion + * Call method after setInput(). To see correct backend, target and fusion run after forward(). + */ + CV_WRAP String dump(); + /** @brief Dump net structure, hyperparameters, backend, target and fusion to dot file + * @param path path to output file with .dot extension + * @see dump() + */ + CV_WRAP void dumpToFile(const String& path); + /** @brief Adds new layer to the net. + * @param name unique name of the adding layer. + * @param type typename of the adding layer (type must be registered in LayerRegister). + * @param dtype datatype of output blobs. + * @param params parameters which will be used to initialize the creating layer. + * @returns unique identifier of created layer, or -1 if a failure will happen. + */ + int addLayer(const String &name, const String &type, const int &dtype, LayerParams ¶ms); + + /** @overload Datatype of output blobs set to default CV_32F */ + int addLayer(const String &name, const String &type, LayerParams ¶ms); + + /** @brief Adds new layer and connects its first input to the first output of previously added layer. + * @see addLayer() + */ + int addLayerToPrev(const String &name, const String &type, const int &dtype, LayerParams ¶ms); + + /** @overload */ + int addLayerToPrev(const String &name, const String &type, LayerParams ¶ms); + + /** @brief Converts string name of the layer to the integer identifier. + * @returns id of the layer, or -1 if the layer wasn't found. + */ + CV_WRAP int getLayerId(const String &layer); + + CV_WRAP std::vector getLayerNames() const; + + /** @brief Container for strings and integers. */ + typedef DictValue LayerId; + + /** @brief Returns pointer to layer with specified id or name which the network use. */ + CV_WRAP Ptr getLayer(LayerId layerId); + + /** @brief Returns pointers to input layers of specific layer. */ + std::vector > getLayerInputs(LayerId layerId); // FIXIT: CV_WRAP + + /** @brief Connects output of the first layer to input of the second layer. + * @param outPin descriptor of the first layer output. + * @param inpPin descriptor of the second layer input. + * + * Descriptors have the following template <layer_name>[.input_number]: + * - the first part of the template layer_name is string name of the added layer. + * If this part is empty then the network input pseudo layer will be used; + * - the second optional part of the template input_number + * is either number of the layer input, either label one. + * If this part is omitted then the first layer input will be used. + * + * @see setNetInputs(), Layer::inputNameToIndex(), Layer::outputNameToIndex() + */ + CV_WRAP void connect(String outPin, String inpPin); + + /** @brief Connects #@p outNum output of the first layer to #@p inNum input of the second layer. + * @param outLayerId identifier of the first layer + * @param outNum number of the first layer output + * @param inpLayerId identifier of the second layer + * @param inpNum number of the second layer input + */ + void connect(int outLayerId, int outNum, int inpLayerId, int inpNum); + + /** @brief Sets outputs names of the network input pseudo layer. + * + * Each net always has special own the network input pseudo layer with id=0. + * This layer stores the user blobs only and don't make any computations. + * In fact, this layer provides the only way to pass user data into the network. + * As any other layer, this layer can label its outputs and this function provides an easy way to do this. + */ + CV_WRAP void setInputsNames(const std::vector &inputBlobNames); + + /** @brief Specify shape of network input. + */ + CV_WRAP void setInputShape(const String &inputName, const MatShape& shape); + + /** @brief Runs forward pass to compute output of layer with name @p outputName. + * @param outputName name for layer which output is needed to get + * @return blob for first output of specified layer. + * @details By default runs forward pass for the whole network. + */ + CV_WRAP Mat forward(const String& outputName = String()); + + /** @brief Runs forward pass to compute output of layer with name @p outputName. + * @param outputName name for layer which output is needed to get + * @details By default runs forward pass for the whole network. + * + * This is an asynchronous version of forward(const String&). + * dnn::DNN_BACKEND_INFERENCE_ENGINE backend is required. + */ + CV_WRAP AsyncArray forwardAsync(const String& outputName = String()); + + /** @brief Runs forward pass to compute output of layer with name @p outputName. + * @param outputBlobs contains all output blobs for specified layer. + * @param outputName name for layer which output is needed to get + * @details If @p outputName is empty, runs forward pass for the whole network. + */ + CV_WRAP void forward(OutputArrayOfArrays outputBlobs, const String& outputName = String()); + + /** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames. + * @param outputBlobs contains blobs for first outputs of specified layers. + * @param outBlobNames names for layers which outputs are needed to get + */ + CV_WRAP void forward(OutputArrayOfArrays outputBlobs, + const std::vector& outBlobNames); + + /** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames. + * @param outputBlobs contains all output blobs for each layer specified in @p outBlobNames. + * @param outBlobNames names for layers which outputs are needed to get + */ + CV_WRAP_AS(forwardAndRetrieve) void forward(CV_OUT std::vector >& outputBlobs, + const std::vector& outBlobNames); + + /** @brief Returns a quantized Net from a floating-point Net. + * @param calibData Calibration data to compute the quantization parameters. + * @param inputsDtype Datatype of quantized net's inputs. Can be CV_32F or CV_8S. + * @param outputsDtype Datatype of quantized net's outputs. Can be CV_32F or CV_8S. + */ + CV_WRAP Net quantize(InputArrayOfArrays calibData, int inputsDtype, int outputsDtype); + + /** @brief Returns input scale and zeropoint for a quantized Net. + * @param scales output parameter for returning input scales. + * @param zeropoints output parameter for returning input zeropoints. + */ + CV_WRAP void getInputDetails(CV_OUT std::vector& scales, CV_OUT std::vector& zeropoints) const; + + /** @brief Returns output scale and zeropoint for a quantized Net. + * @param scales output parameter for returning output scales. + * @param zeropoints output parameter for returning output zeropoints. + */ + CV_WRAP void getOutputDetails(CV_OUT std::vector& scales, CV_OUT std::vector& zeropoints) const; + + /** + * @brief Compile Halide layers. + * @param[in] scheduler Path to YAML file with scheduling directives. + * @see setPreferableBackend + * + * Schedule layers that support Halide backend. Then compile them for + * specific target. For layers that not represented in scheduling file + * or if no manual scheduling used at all, automatic scheduling will be applied. + */ + CV_WRAP void setHalideScheduler(const String& scheduler); + + /** + * @brief Ask network to use specific computation backend where it supported. + * @param[in] backendId backend identifier. + * @see Backend + * + * If OpenCV is compiled with Intel's Inference Engine library, DNN_BACKEND_DEFAULT + * means DNN_BACKEND_INFERENCE_ENGINE. Otherwise it equals to DNN_BACKEND_OPENCV. + */ + CV_WRAP void setPreferableBackend(int backendId); + + /** + * @brief Ask network to make computations on specific target device. + * @param[in] targetId target identifier. + * @see Target + * + * List of supported combinations backend / target: + * | | DNN_BACKEND_OPENCV | DNN_BACKEND_INFERENCE_ENGINE | DNN_BACKEND_HALIDE | DNN_BACKEND_CUDA | + * |------------------------|--------------------|------------------------------|--------------------|-------------------| + * | DNN_TARGET_CPU | + | + | + | | + * | DNN_TARGET_OPENCL | + | + | + | | + * | DNN_TARGET_OPENCL_FP16 | + | + | | | + * | DNN_TARGET_MYRIAD | | + | | | + * | DNN_TARGET_FPGA | | + | | | + * | DNN_TARGET_CUDA | | | | + | + * | DNN_TARGET_CUDA_FP16 | | | | + | + * | DNN_TARGET_HDDL | | + | | | + */ + CV_WRAP void setPreferableTarget(int targetId); + + /** @brief Sets the new input value for the network + * @param blob A new blob. Should have CV_32F or CV_8U depth. + * @param name A name of input layer. + * @param scalefactor An optional normalization scale. + * @param mean An optional mean subtraction values. + * @see connect(String, String) to know format of the descriptor. + * + * If scale or mean values are specified, a final input blob is computed + * as: + * \f[input(n,c,h,w) = scalefactor \times (blob(n,c,h,w) - mean_c)\f] + */ + CV_WRAP void setInput(InputArray blob, const String& name = "", + double scalefactor = 1.0, const Scalar& mean = Scalar()); + + /** @brief Sets the new value for the learned param of the layer. + * @param layer name or id of the layer. + * @param numParam index of the layer parameter in the Layer::blobs array. + * @param blob the new value. + * @see Layer::blobs + * @note If shape of the new blob differs from the previous shape, + * then the following forward pass may fail. + */ + CV_WRAP void setParam(LayerId layer, int numParam, const Mat &blob); + + /** @brief Returns parameter blob of the layer. + * @param layer name or id of the layer. + * @param numParam index of the layer parameter in the Layer::blobs array. + * @see Layer::blobs + */ + CV_WRAP Mat getParam(LayerId layer, int numParam = 0); + + /** @brief Returns indexes of layers with unconnected outputs. + */ + CV_WRAP std::vector getUnconnectedOutLayers() const; + + /** @brief Returns names of layers with unconnected outputs. + */ + CV_WRAP std::vector getUnconnectedOutLayersNames() const; + + /** @brief Returns input and output shapes for all layers in loaded model; + * preliminary inferencing isn't necessary. + * @param netInputShapes shapes for all input blobs in net input layer. + * @param layersIds output parameter for layer IDs. + * @param inLayersShapes output parameter for input layers shapes; + * order is the same as in layersIds + * @param outLayersShapes output parameter for output layers shapes; + * order is the same as in layersIds + */ + CV_WRAP void getLayersShapes(const std::vector& netInputShapes, + CV_OUT std::vector& layersIds, + CV_OUT std::vector >& inLayersShapes, + CV_OUT std::vector >& outLayersShapes) const; + + /** @overload */ + CV_WRAP void getLayersShapes(const MatShape& netInputShape, + CV_OUT std::vector& layersIds, + CV_OUT std::vector >& inLayersShapes, + CV_OUT std::vector >& outLayersShapes) const; + + /** @brief Returns input and output shapes for layer with specified + * id in loaded model; preliminary inferencing isn't necessary. + * @param netInputShape shape input blob in net input layer. + * @param layerId id for layer. + * @param inLayerShapes output parameter for input layers shapes; + * order is the same as in layersIds + * @param outLayerShapes output parameter for output layers shapes; + * order is the same as in layersIds + */ + void getLayerShapes(const MatShape& netInputShape, + const int layerId, + CV_OUT std::vector& inLayerShapes, + CV_OUT std::vector& outLayerShapes) const; // FIXIT: CV_WRAP + + /** @overload */ + void getLayerShapes(const std::vector& netInputShapes, + const int layerId, + CV_OUT std::vector& inLayerShapes, + CV_OUT std::vector& outLayerShapes) const; // FIXIT: CV_WRAP + + /** @brief Computes FLOP for whole loaded model with specified input shapes. + * @param netInputShapes vector of shapes for all net inputs. + * @returns computed FLOP. + */ + CV_WRAP int64 getFLOPS(const std::vector& netInputShapes) const; + /** @overload */ + CV_WRAP int64 getFLOPS(const MatShape& netInputShape) const; + /** @overload */ + CV_WRAP int64 getFLOPS(const int layerId, + const std::vector& netInputShapes) const; + /** @overload */ + CV_WRAP int64 getFLOPS(const int layerId, + const MatShape& netInputShape) const; + + /** @brief Returns list of types for layer used in model. + * @param layersTypes output parameter for returning types. + */ + CV_WRAP void getLayerTypes(CV_OUT std::vector& layersTypes) const; + + /** @brief Returns count of layers of specified type. + * @param layerType type. + * @returns count of layers + */ + CV_WRAP int getLayersCount(const String& layerType) const; + + /** @brief Computes bytes number which are required to store + * all weights and intermediate blobs for model. + * @param netInputShapes vector of shapes for all net inputs. + * @param weights output parameter to store resulting bytes for weights. + * @param blobs output parameter to store resulting bytes for intermediate blobs. + */ + void getMemoryConsumption(const std::vector& netInputShapes, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; // FIXIT: CV_WRAP + /** @overload */ + CV_WRAP void getMemoryConsumption(const MatShape& netInputShape, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; + /** @overload */ + CV_WRAP void getMemoryConsumption(const int layerId, + const std::vector& netInputShapes, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; + /** @overload */ + CV_WRAP void getMemoryConsumption(const int layerId, + const MatShape& netInputShape, + CV_OUT size_t& weights, CV_OUT size_t& blobs) const; + + /** @brief Computes bytes number which are required to store + * all weights and intermediate blobs for each layer. + * @param netInputShapes vector of shapes for all net inputs. + * @param layerIds output vector to save layer IDs. + * @param weights output parameter to store resulting bytes for weights. + * @param blobs output parameter to store resulting bytes for intermediate blobs. + */ + void getMemoryConsumption(const std::vector& netInputShapes, + CV_OUT std::vector& layerIds, + CV_OUT std::vector& weights, + CV_OUT std::vector& blobs) const; // FIXIT: CV_WRAP + /** @overload */ + void getMemoryConsumption(const MatShape& netInputShape, + CV_OUT std::vector& layerIds, + CV_OUT std::vector& weights, + CV_OUT std::vector& blobs) const; // FIXIT: CV_WRAP + + /** @brief Enables or disables layer fusion in the network. + * @param fusion true to enable the fusion, false to disable. The fusion is enabled by default. + */ + CV_WRAP void enableFusion(bool fusion); + + /** @brief Returns overall time for inference and timings (in ticks) for layers. + * + * Indexes in returned vector correspond to layers ids. Some layers can be fused with others, + * in this case zero ticks count will be return for that skipped layers. Supported by DNN_BACKEND_OPENCV on DNN_TARGET_CPU only. + * + * @param[out] timings vector for tick timings for all layers. + * @return overall ticks for model inference. + */ + CV_WRAP int64 getPerfProfile(CV_OUT std::vector& timings); + + private: + struct Impl; + Ptr impl; + }; + + /** @brief Reads a network model stored in Darknet model files. + * @param cfgFile path to the .cfg file with text description of the network architecture. + * @param darknetModel path to the .weights file with learned network. + * @returns Network object that ready to do forward, throw an exception in failure cases. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String()); + + /** @brief Reads a network model stored in Darknet model files. + * @param bufferCfg A buffer contains a content of .cfg file with text description of the network architecture. + * @param bufferModel A buffer contains a content of .weights file with learned network. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromDarknet(const std::vector& bufferCfg, + const std::vector& bufferModel = std::vector()); + + /** @brief Reads a network model stored in Darknet model files. + * @param bufferCfg A buffer contains a content of .cfg file with text description of the network architecture. + * @param lenCfg Number of bytes to read from bufferCfg + * @param bufferModel A buffer contains a content of .weights file with learned network. + * @param lenModel Number of bytes to read from bufferModel + * @returns Net object. + */ + CV_EXPORTS Net readNetFromDarknet(const char *bufferCfg, size_t lenCfg, + const char *bufferModel = NULL, size_t lenModel = 0); + + /** @brief Reads a network model stored in Caffe framework's format. + * @param prototxt path to the .prototxt file with text description of the network architecture. + * @param caffeModel path to the .caffemodel file with learned network. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String()); + + /** @brief Reads a network model stored in Caffe model in memory. + * @param bufferProto buffer containing the content of the .prototxt file + * @param bufferModel buffer containing the content of the .caffemodel file + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromCaffe(const std::vector& bufferProto, + const std::vector& bufferModel = std::vector()); + + /** @brief Reads a network model stored in Caffe model in memory. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + * @param bufferProto buffer containing the content of the .prototxt file + * @param lenProto length of bufferProto + * @param bufferModel buffer containing the content of the .caffemodel file + * @param lenModel length of bufferModel + * @returns Net object. + */ + CV_EXPORTS Net readNetFromCaffe(const char *bufferProto, size_t lenProto, + const char *bufferModel = NULL, size_t lenModel = 0); + + /** @brief Reads a network model stored in TensorFlow framework's format. + * @param model path to the .pb file with binary protobuf description of the network architecture + * @param config path to the .pbtxt file that contains text graph definition in protobuf format. + * Resulting Net object is built by text graph using weights from a binary one that + * let us make it more flexible. + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromTensorflow(const String &model, const String &config = String()); + + /** @brief Reads a network model stored in TensorFlow framework's format. + * @param bufferModel buffer containing the content of the pb file + * @param bufferConfig buffer containing the content of the pbtxt file + * @returns Net object. + */ + CV_EXPORTS_W Net readNetFromTensorflow(const std::vector& bufferModel, + const std::vector& bufferConfig = std::vector()); + + /** @brief Reads a network model stored in TensorFlow framework's format. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + * @param bufferModel buffer containing the content of the pb file + * @param lenModel length of bufferModel + * @param bufferConfig buffer containing the content of the pbtxt file + * @param lenConfig length of bufferConfig + */ + CV_EXPORTS Net readNetFromTensorflow(const char *bufferModel, size_t lenModel, + const char *bufferConfig = NULL, size_t lenConfig = 0); + + /** + * @brief Reads a network model stored in Torch7 framework's format. + * @param model path to the file, dumped from Torch by using torch.save() function. + * @param isBinary specifies whether the network was serialized in ascii mode or binary. + * @param evaluate specifies testing phase of network. If true, it's similar to evaluate() method in Torch. + * @returns Net object. + * + * @note Ascii mode of Torch serializer is more preferable, because binary mode extensively use `long` type of C language, + * which has various bit-length on different systems. + * + * The loading file must contain serialized nn.Module object + * with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors. + * + * List of supported layers (i.e. object instances derived from Torch nn.Module class): + * - nn.Sequential + * - nn.Parallel + * - nn.Concat + * - nn.Linear + * - nn.SpatialConvolution + * - nn.SpatialMaxPooling, nn.SpatialAveragePooling + * - nn.ReLU, nn.TanH, nn.Sigmoid + * - nn.Reshape + * - nn.SoftMax, nn.LogSoftMax + * + * Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported. + */ + CV_EXPORTS_W Net readNetFromTorch(const String &model, bool isBinary = true, bool evaluate = true); + + /** + * @brief Read deep learning network represented in one of the supported formats. + * @param[in] model Binary file contains trained weights. The following file + * extensions are expected for models from different frameworks: + * * `*.caffemodel` (Caffe, http://caffe.berkeleyvision.org/) + * * `*.pb` (TensorFlow, https://www.tensorflow.org/) + * * `*.t7` | `*.net` (Torch, http://torch.ch/) + * * `*.weights` (Darknet, https://pjreddie.com/darknet/) + * * `*.bin` (DLDT, https://software.intel.com/openvino-toolkit) + * * `*.onnx` (ONNX, https://onnx.ai/) + * @param[in] config Text file contains network configuration. It could be a + * file with the following extensions: + * * `*.prototxt` (Caffe, http://caffe.berkeleyvision.org/) + * * `*.pbtxt` (TensorFlow, https://www.tensorflow.org/) + * * `*.cfg` (Darknet, https://pjreddie.com/darknet/) + * * `*.xml` (DLDT, https://software.intel.com/openvino-toolkit) + * @param[in] framework Explicit framework name tag to determine a format. + * @returns Net object. + * + * This function automatically detects an origin framework of trained model + * and calls an appropriate function such @ref readNetFromCaffe, @ref readNetFromTensorflow, + * @ref readNetFromTorch or @ref readNetFromDarknet. An order of @p model and @p config + * arguments does not matter. + */ + CV_EXPORTS_W Net readNet(const String& model, const String& config = "", const String& framework = ""); + + /** + * @brief Read deep learning network represented in one of the supported formats. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + * @param[in] framework Name of origin framework. + * @param[in] bufferModel A buffer with a content of binary file with weights + * @param[in] bufferConfig A buffer with a content of text file contains network configuration. + * @returns Net object. + */ + CV_EXPORTS_W Net readNet(const String& framework, const std::vector& bufferModel, + const std::vector& bufferConfig = std::vector()); + + /** @brief Loads blob which was serialized as torch.Tensor object of Torch7 framework. + * @warning This function has the same limitations as readNetFromTorch(). + */ + CV_EXPORTS_W Mat readTorchBlob(const String &filename, bool isBinary = true); + + /** @brief Load a network from Intel's Model Optimizer intermediate representation. + * @param[in] xml XML configuration file with network's topology. + * @param[in] bin Binary file with trained weights. + * @returns Net object. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_EXPORTS_W + Net readNetFromModelOptimizer(const String &xml, const String &bin); + + /** @brief Load a network from Intel's Model Optimizer intermediate representation. + * @param[in] bufferModelConfig Buffer contains XML configuration with network's topology. + * @param[in] bufferWeights Buffer contains binary data with trained weights. + * @returns Net object. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_EXPORTS_W + Net readNetFromModelOptimizer(const std::vector& bufferModelConfig, const std::vector& bufferWeights); + + /** @brief Load a network from Intel's Model Optimizer intermediate representation. + * @param[in] bufferModelConfigPtr Pointer to buffer which contains XML configuration with network's topology. + * @param[in] bufferModelConfigSize Binary size of XML configuration data. + * @param[in] bufferWeightsPtr Pointer to buffer which contains binary data with trained weights. + * @param[in] bufferWeightsSize Binary size of trained weights data. + * @returns Net object. + * Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine + * backend. + */ + CV_EXPORTS + Net readNetFromModelOptimizer(const uchar* bufferModelConfigPtr, size_t bufferModelConfigSize, + const uchar* bufferWeightsPtr, size_t bufferWeightsSize); + + /** @brief Reads a network model ONNX. + * @param onnxFile path to the .onnx file with text description of the network architecture. + * @returns Network object that ready to do forward, throw an exception in failure cases. + */ + CV_EXPORTS_W Net readNetFromONNX(const String &onnxFile); + + /** @brief Reads a network model from ONNX + * in-memory buffer. + * @param buffer memory address of the first byte of the buffer. + * @param sizeBuffer size of the buffer. + * @returns Network object that ready to do forward, throw an exception + * in failure cases. + */ + CV_EXPORTS Net readNetFromONNX(const char* buffer, size_t sizeBuffer); + + /** @brief Reads a network model from ONNX + * in-memory buffer. + * @param buffer in-memory buffer that stores the ONNX model bytes. + * @returns Network object that ready to do forward, throw an exception + * in failure cases. + */ + CV_EXPORTS_W Net readNetFromONNX(const std::vector& buffer); + + /** @brief Creates blob from .pb file. + * @param path to the .pb file with input tensor. + * @returns Mat. + */ + CV_EXPORTS_W Mat readTensorFromONNX(const String& path); + + /** @brief Creates 4-dimensional blob from image. Optionally resizes and crops @p image from center, + * subtract @p mean values, scales values by @p scalefactor, swap Blue and Red channels. + * @param image input image (with 1-, 3- or 4-channels). + * @param size spatial size for output image + * @param mean scalar with mean values which are subtracted from channels. Values are intended + * to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true. + * @param scalefactor multiplier for @p image values. + * @param swapRB flag which indicates that swap first and last channels + * in 3-channel image is necessary. + * @param crop flag which indicates whether image will be cropped after resize or not + * @param ddepth Depth of output blob. Choose CV_32F or CV_8U. + * @details if @p crop is true, input image is resized so one side after resize is equal to corresponding + * dimension in @p size and another one is equal or larger. Then, crop from the center is performed. + * If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. + * @returns 4-dimensional Mat with NCHW dimensions order. + */ + CV_EXPORTS_W Mat blobFromImage(InputArray image, double scalefactor=1.0, const Size& size = Size(), + const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, + int ddepth=CV_32F); + + /** @brief Creates 4-dimensional blob from image. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + */ + CV_EXPORTS void blobFromImage(InputArray image, OutputArray blob, double scalefactor=1.0, + const Size& size = Size(), const Scalar& mean = Scalar(), + bool swapRB=false, bool crop=false, int ddepth=CV_32F); + + + /** @brief Creates 4-dimensional blob from series of images. Optionally resizes and + * crops @p images from center, subtract @p mean values, scales values by @p scalefactor, + * swap Blue and Red channels. + * @param images input images (all with 1-, 3- or 4-channels). + * @param size spatial size for output image + * @param mean scalar with mean values which are subtracted from channels. Values are intended + * to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true. + * @param scalefactor multiplier for @p images values. + * @param swapRB flag which indicates that swap first and last channels + * in 3-channel image is necessary. + * @param crop flag which indicates whether image will be cropped after resize or not + * @param ddepth Depth of output blob. Choose CV_32F or CV_8U. + * @details if @p crop is true, input image is resized so one side after resize is equal to corresponding + * dimension in @p size and another one is equal or larger. Then, crop from the center is performed. + * If @p crop is false, direct resize without cropping and preserving aspect ratio is performed. + * @returns 4-dimensional Mat with NCHW dimensions order. + */ + CV_EXPORTS_W Mat blobFromImages(InputArrayOfArrays images, double scalefactor=1.0, + Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, + int ddepth=CV_32F); + + /** @brief Creates 4-dimensional blob from series of images. + * @details This is an overloaded member function, provided for convenience. + * It differs from the above function only in what argument(s) it accepts. + */ + CV_EXPORTS void blobFromImages(InputArrayOfArrays images, OutputArray blob, + double scalefactor=1.0, Size size = Size(), + const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, + int ddepth=CV_32F); + + /** @brief Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure + * (std::vector). + * @param[in] blob_ 4 dimensional array (images, channels, height, width) in floating point precision (CV_32F) from + * which you would like to extract the images. + * @param[out] images_ array of 2D Mat containing the images extracted from the blob in floating point precision + * (CV_32F). They are non normalized neither mean added. The number of returned images equals the first dimension + * of the blob (batch size). Every image has a number of channels equals to the second dimension of the blob (depth). + */ + CV_EXPORTS_W void imagesFromBlob(const cv::Mat& blob_, OutputArrayOfArrays images_); + + /** @brief Convert all weights of Caffe network to half precision floating point. + * @param src Path to origin model from Caffe framework contains single + * precision floating point weights (usually has `.caffemodel` extension). + * @param dst Path to destination model with updated weights. + * @param layersTypes Set of layers types which parameters will be converted. + * By default, converts only Convolutional and Fully-Connected layers' + * weights. + * + * @note Shrinked model has no origin float32 weights so it can't be used + * in origin Caffe framework anymore. However the structure of data + * is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe. + * So the resulting model may be used there. + */ + CV_EXPORTS_W void shrinkCaffeModel(const String& src, const String& dst, + const std::vector& layersTypes = std::vector()); + + /** @brief Create a text representation for a binary network stored in protocol buffer format. + * @param[in] model A path to binary network. + * @param[in] output A path to output text file to be created. + * + * @note To reduce output file size, trained weights are not included. + */ + CV_EXPORTS_W void writeTextGraph(const String& model, const String& output); + + /** @brief Performs non maximum suppression given boxes and corresponding scores. + + * @param bboxes a set of bounding boxes to apply NMS. + * @param scores a set of corresponding confidences. + * @param score_threshold a threshold used to filter boxes by score. + * @param nms_threshold a threshold used in non maximum suppression. + * @param indices the kept indices of bboxes after NMS. + * @param eta a coefficient in adaptive threshold formula: \f$nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\f$. + * @param top_k if `>0`, keep at most @p top_k picked indices. + */ + CV_EXPORTS void NMSBoxes(const std::vector& bboxes, const std::vector& scores, + const float score_threshold, const float nms_threshold, + CV_OUT std::vector& indices, + const float eta = 1.f, const int top_k = 0); + + CV_EXPORTS_W void NMSBoxes(const std::vector& bboxes, const std::vector& scores, + const float score_threshold, const float nms_threshold, + CV_OUT std::vector& indices, + const float eta = 1.f, const int top_k = 0); + + CV_EXPORTS_AS(NMSBoxesRotated) void NMSBoxes(const std::vector& bboxes, const std::vector& scores, + const float score_threshold, const float nms_threshold, + CV_OUT std::vector& indices, + const float eta = 1.f, const int top_k = 0); + + /** + * @brief Enum of Soft NMS methods. + * @see softNMSBoxes + */ + enum class SoftNMSMethod + { + SOFTNMS_LINEAR = 1, + SOFTNMS_GAUSSIAN = 2 + }; + + /** @brief Performs soft non maximum suppression given boxes and corresponding scores. + * Reference: https://arxiv.org/abs/1704.04503 + * @param bboxes a set of bounding boxes to apply Soft NMS. + * @param scores a set of corresponding confidences. + * @param updated_scores a set of corresponding updated confidences. + * @param score_threshold a threshold used to filter boxes by score. + * @param nms_threshold a threshold used in non maximum suppression. + * @param indices the kept indices of bboxes after NMS. + * @param top_k keep at most @p top_k picked indices. + * @param sigma parameter of Gaussian weighting. + * @param method Gaussian or linear. + * @see SoftNMSMethod + */ + CV_EXPORTS_W void softNMSBoxes(const std::vector& bboxes, + const std::vector& scores, + CV_OUT std::vector& updated_scores, + const float score_threshold, + const float nms_threshold, + CV_OUT std::vector& indices, + size_t top_k = 0, + const float sigma = 0.5, + SoftNMSMethod method = SoftNMSMethod::SOFTNMS_GAUSSIAN); + + + /** @brief This class is presented high-level API for neural networks. + * + * Model allows to set params for preprocessing input image. + * Model creates net from file with trained weights and config, + * sets preprocessing input and runs forward pass. + */ + class CV_EXPORTS_W_SIMPLE Model + { + public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + Model(); + + Model(const Model&) = default; + Model(Model&&) = default; + Model& operator=(const Model&) = default; + Model& operator=(Model&&) = default; + + /** + * @brief Create model from deep learning network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP Model(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP Model(const Net& network); + + /** @brief Set input size for frame. + * @param[in] size New input size. + * @note If shape of the new blob less than 0, then frame size not change. + */ + CV_WRAP Model& setInputSize(const Size& size); + + /** @overload + * @param[in] width New input width. + * @param[in] height New input height. + */ + CV_WRAP inline + Model& setInputSize(int width, int height) { return setInputSize(Size(width, height)); } + + /** @brief Set mean value for frame. + * @param[in] mean Scalar with mean values which are subtracted from channels. + */ + CV_WRAP Model& setInputMean(const Scalar& mean); + + /** @brief Set scalefactor value for frame. + * @param[in] scale Multiplier for frame values. + */ + CV_WRAP Model& setInputScale(double scale); + + /** @brief Set flag crop for frame. + * @param[in] crop Flag which indicates whether image will be cropped after resize or not. + */ + CV_WRAP Model& setInputCrop(bool crop); + + /** @brief Set flag swapRB for frame. + * @param[in] swapRB Flag which indicates that swap first and last channels. + */ + CV_WRAP Model& setInputSwapRB(bool swapRB); + + /** @brief Set preprocessing parameters for frame. + * @param[in] size New input size. + * @param[in] mean Scalar with mean values which are subtracted from channels. + * @param[in] scale Multiplier for frame values. + * @param[in] swapRB Flag which indicates that swap first and last channels. + * @param[in] crop Flag which indicates whether image will be cropped after resize or not. + * blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) ) + */ + CV_WRAP void setInputParams(double scale = 1.0, const Size& size = Size(), + const Scalar& mean = Scalar(), bool swapRB = false, bool crop = false); + + /** @brief Given the @p input frame, create input blob, run net and return the output @p blobs. + * @param[in] frame The input image. + * @param[out] outs Allocated output blobs, which will store results of the computation. + */ + CV_WRAP void predict(InputArray frame, OutputArrayOfArrays outs) const; + + + // ============================== Net proxy methods ============================== + // Never expose methods with network implementation details, like: + // - addLayer, addLayerToPrev, connect, setInputsNames, setInputShape, setParam, getParam + // - getLayer*, getUnconnectedOutLayers, getUnconnectedOutLayersNames, getLayersShapes + // - forward* methods, setInput + + /// @sa Net::setPreferableBackend + CV_WRAP Model& setPreferableBackend(dnn::Backend backendId); + /// @sa Net::setPreferableTarget + CV_WRAP Model& setPreferableTarget(dnn::Target targetId); + + CV_DEPRECATED_EXTERNAL + operator Net&() const { return getNetwork_(); } + + //protected: - internal/tests usage only + Net& getNetwork_() const; + inline Net& getNetwork_() { return const_cast(this)->getNetwork_(); } + + struct Impl; + inline Impl* getImpl() const { return impl.get(); } + inline Impl& getImplRef() const { CV_DbgAssert(impl); return *impl.get(); } + protected: + Ptr impl; + }; + + /** @brief This class represents high-level API for classification models. + * + * ClassificationModel allows to set params for preprocessing input image. + * ClassificationModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and return top-1 prediction. + */ + class CV_EXPORTS_W_SIMPLE ClassificationModel : public Model + { + public: + /** + * @brief Create classification model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP ClassificationModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP ClassificationModel(const Net& network); + + /** @brief Given the @p input frame, create input blob, run net and return top-1 prediction. + * @param[in] frame The input image. + */ + std::pair classify(InputArray frame); + + /** @overload */ + CV_WRAP void classify(InputArray frame, CV_OUT int& classId, CV_OUT float& conf); + }; + + /** @brief This class represents high-level API for keypoints models + * + * KeypointsModel allows to set params for preprocessing input image. + * KeypointsModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and returns the x and y coordinates of each detected keypoint + */ + class CV_EXPORTS_W_SIMPLE KeypointsModel: public Model + { + public: + /** + * @brief Create keypoints model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP KeypointsModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP KeypointsModel(const Net& network); + + /** @brief Given the @p input frame, create input blob, run net + * @param[in] frame The input image. + * @param thresh minimum confidence threshold to select a keypoint + * @returns a vector holding the x and y coordinates of each detected keypoint + * + */ + CV_WRAP std::vector estimate(InputArray frame, float thresh=0.5); + }; + + /** @brief This class represents high-level API for segmentation models + * + * SegmentationModel allows to set params for preprocessing input image. + * SegmentationModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and returns the class prediction for each pixel. + */ + class CV_EXPORTS_W_SIMPLE SegmentationModel: public Model + { + public: + /** + * @brief Create segmentation model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP SegmentationModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP SegmentationModel(const Net& network); + + /** @brief Given the @p input frame, create input blob, run net + * @param[in] frame The input image. + * @param[out] mask Allocated class prediction for each pixel + */ + CV_WRAP void segment(InputArray frame, OutputArray mask); + }; + + /** @brief This class represents high-level API for object detection networks. + * + * DetectionModel allows to set params for preprocessing input image. + * DetectionModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and return result detections. + * For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported. + */ + class CV_EXPORTS_W_SIMPLE DetectionModel : public Model + { + public: + /** + * @brief Create detection model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP DetectionModel(const String& model, const String& config = ""); + + /** + * @brief Create model from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP DetectionModel(const Net& network); + + CV_DEPRECATED_EXTERNAL // avoid using in C++ code (need to fix bindings first) + DetectionModel(); + + /** + * @brief nmsAcrossClasses defaults to false, + * such that when non max suppression is used during the detect() function, it will do so per-class. + * This function allows you to toggle this behaviour. + * @param[in] value The new value for nmsAcrossClasses + */ + CV_WRAP DetectionModel& setNmsAcrossClasses(bool value); + + /** + * @brief Getter for nmsAcrossClasses. This variable defaults to false, + * such that when non max suppression is used during the detect() function, it will do so only per-class + */ + CV_WRAP bool getNmsAcrossClasses(); + + /** @brief Given the @p input frame, create input blob, run net and return result detections. + * @param[in] frame The input image. + * @param[out] classIds Class indexes in result detection. + * @param[out] confidences A set of corresponding confidences. + * @param[out] boxes A set of bounding boxes. + * @param[in] confThreshold A threshold used to filter boxes by confidences. + * @param[in] nmsThreshold A threshold used in non maximum suppression. + */ + CV_WRAP void detect(InputArray frame, CV_OUT std::vector& classIds, + CV_OUT std::vector& confidences, CV_OUT std::vector& boxes, + float confThreshold = 0.5f, float nmsThreshold = 0.0f); + }; + + +/** @brief This class represents high-level API for text recognition networks. + * + * TextRecognitionModel allows to set params for preprocessing input image. + * TextRecognitionModel creates net from file with trained weights and config, + * sets preprocessing input, runs forward pass and return recognition result. + * For TextRecognitionModel, CRNN-CTC is supported. + */ +class CV_EXPORTS_W_SIMPLE TextRecognitionModel : public Model +{ +public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextRecognitionModel(); + + /** + * @brief Create Text Recognition model from deep learning network + * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method + * @param[in] network Net object + */ + CV_WRAP TextRecognitionModel(const Net& network); + + /** + * @brief Create text recognition model from network represented in one of the supported formats + * Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method + * @param[in] model Binary file contains trained weights + * @param[in] config Text file contains network configuration + */ + CV_WRAP inline + TextRecognitionModel(const std::string& model, const std::string& config = "") + : TextRecognitionModel(readNet(model, config)) { /* nothing */ } + + /** + * @brief Set the decoding method of translating the network output into string + * @param[in] decodeType The decoding method of translating the network output into string, currently supported type: + * - `"CTC-greedy"` greedy decoding for the output of CTC-based methods + * - `"CTC-prefix-beam-search"` Prefix beam search decoding for the output of CTC-based methods + */ + CV_WRAP + TextRecognitionModel& setDecodeType(const std::string& decodeType); + + /** + * @brief Get the decoding method + * @return the decoding method + */ + CV_WRAP + const std::string& getDecodeType() const; + + /** + * @brief Set the decoding method options for `"CTC-prefix-beam-search"` decode usage + * @param[in] beamSize Beam size for search + * @param[in] vocPruneSize Parameter to optimize big vocabulary search, + * only take top @p vocPruneSize tokens in each search step, @p vocPruneSize <= 0 stands for disable this prune. + */ + CV_WRAP + TextRecognitionModel& setDecodeOptsCTCPrefixBeamSearch(int beamSize, int vocPruneSize = 0); + + /** + * @brief Set the vocabulary for recognition. + * @param[in] vocabulary the associated vocabulary of the network. + */ + CV_WRAP + TextRecognitionModel& setVocabulary(const std::vector& vocabulary); + + /** + * @brief Get the vocabulary for recognition. + * @return vocabulary the associated vocabulary + */ + CV_WRAP + const std::vector& getVocabulary() const; + + /** + * @brief Given the @p input frame, create input blob, run net and return recognition result + * @param[in] frame The input image + * @return The text recognition result + */ + CV_WRAP + std::string recognize(InputArray frame) const; + + /** + * @brief Given the @p input frame, create input blob, run net and return recognition result + * @param[in] frame The input image + * @param[in] roiRects List of text detection regions of interest (cv::Rect, CV_32SC4). ROIs is be cropped as the network inputs + * @param[out] results A set of text recognition results. + */ + CV_WRAP + void recognize(InputArray frame, InputArrayOfArrays roiRects, CV_OUT std::vector& results) const; +}; + + +/** @brief Base class for text detection networks + */ +class CV_EXPORTS_W_SIMPLE TextDetectionModel : public Model +{ +protected: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextDetectionModel(); + +public: + + /** @brief Performs detection + * + * Given the input @p frame, prepare network input, run network inference, post-process network output and return result detections. + * + * Each result is quadrangle's 4 points in this order: + * - bottom-left + * - top-left + * - top-right + * - bottom-right + * + * Use cv::getPerspectiveTransform function to retrive image region without perspective transformations. + * + * @note If DL model doesn't support that kind of output then result may be derived from detectTextRectangles() output. + * + * @param[in] frame The input image + * @param[out] detections array with detections' quadrangles (4 points per result) + * @param[out] confidences array with detection confidences + */ + CV_WRAP + void detect( + InputArray frame, + CV_OUT std::vector< std::vector >& detections, + CV_OUT std::vector& confidences + ) const; + + /** @overload */ + CV_WRAP + void detect( + InputArray frame, + CV_OUT std::vector< std::vector >& detections + ) const; + + /** @brief Performs detection + * + * Given the input @p frame, prepare network input, run network inference, post-process network output and return result detections. + * + * Each result is rotated rectangle. + * + * @note Result may be inaccurate in case of strong perspective transformations. + * + * @param[in] frame the input image + * @param[out] detections array with detections' RotationRect results + * @param[out] confidences array with detection confidences + */ + CV_WRAP + void detectTextRectangles( + InputArray frame, + CV_OUT std::vector& detections, + CV_OUT std::vector& confidences + ) const; + + /** @overload */ + CV_WRAP + void detectTextRectangles( + InputArray frame, + CV_OUT std::vector& detections + ) const; +}; + +/** @brief This class represents high-level API for text detection DL networks compatible with EAST model. + * + * Configurable parameters: + * - (float) confThreshold - used to filter boxes by confidences, default: 0.5f + * - (float) nmsThreshold - used in non maximum suppression, default: 0.0f + */ +class CV_EXPORTS_W_SIMPLE TextDetectionModel_EAST : public TextDetectionModel +{ +public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextDetectionModel_EAST(); + + /** + * @brief Create text detection algorithm from deep learning network + * @param[in] network Net object + */ + CV_WRAP TextDetectionModel_EAST(const Net& network); + + /** + * @brief Create text detection model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP inline + TextDetectionModel_EAST(const std::string& model, const std::string& config = "") + : TextDetectionModel_EAST(readNet(model, config)) { /* nothing */ } + + /** + * @brief Set the detection confidence threshold + * @param[in] confThreshold A threshold used to filter boxes by confidences + */ + CV_WRAP + TextDetectionModel_EAST& setConfidenceThreshold(float confThreshold); + + /** + * @brief Get the detection confidence threshold + */ + CV_WRAP + float getConfidenceThreshold() const; + + /** + * @brief Set the detection NMS filter threshold + * @param[in] nmsThreshold A threshold used in non maximum suppression + */ + CV_WRAP + TextDetectionModel_EAST& setNMSThreshold(float nmsThreshold); + + /** + * @brief Get the detection confidence threshold + */ + CV_WRAP + float getNMSThreshold() const; +}; + +/** @brief This class represents high-level API for text detection DL networks compatible with DB model. + * + * Related publications: @cite liao2020real + * Paper: https://arxiv.org/abs/1911.08947 + * For more information about the hyper-parameters setting, please refer to https://github.com/MhLiao/DB + * + * Configurable parameters: + * - (float) binaryThreshold - The threshold of the binary map. It is usually set to 0.3. + * - (float) polygonThreshold - The threshold of text polygons. It is usually set to 0.5, 0.6, and 0.7. Default is 0.5f + * - (double) unclipRatio - The unclip ratio of the detected text region, which determines the output size. It is usually set to 2.0. + * - (int) maxCandidates - The max number of the output results. + */ +class CV_EXPORTS_W_SIMPLE TextDetectionModel_DB : public TextDetectionModel +{ +public: + CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first) + TextDetectionModel_DB(); + + /** + * @brief Create text detection algorithm from deep learning network. + * @param[in] network Net object. + */ + CV_WRAP TextDetectionModel_DB(const Net& network); + + /** + * @brief Create text detection model from network represented in one of the supported formats. + * An order of @p model and @p config arguments does not matter. + * @param[in] model Binary file contains trained weights. + * @param[in] config Text file contains network configuration. + */ + CV_WRAP inline + TextDetectionModel_DB(const std::string& model, const std::string& config = "") + : TextDetectionModel_DB(readNet(model, config)) { /* nothing */ } + + CV_WRAP TextDetectionModel_DB& setBinaryThreshold(float binaryThreshold); + CV_WRAP float getBinaryThreshold() const; + + CV_WRAP TextDetectionModel_DB& setPolygonThreshold(float polygonThreshold); + CV_WRAP float getPolygonThreshold() const; + + CV_WRAP TextDetectionModel_DB& setUnclipRatio(double unclipRatio); + CV_WRAP double getUnclipRatio() const; + + CV_WRAP TextDetectionModel_DB& setMaxCandidates(int maxCandidates); + CV_WRAP int getMaxCandidates() const; +}; + +//! @} +CV__DNN_INLINE_NS_END +} +} + +#include +#include + +/// @deprecated Include this header directly from application. Automatic inclusion will be removed +#include + +#endif /* OPENCV_DNN_DNN_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dnn.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dnn.inl.hpp new file mode 100644 index 0000000..8312a41 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/dnn.inl.hpp @@ -0,0 +1,412 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_INL_HPP +#define OPENCV_DNN_DNN_INL_HPP + +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +template +DictValue DictValue::arrayInt(TypeIter begin, int size) +{ + DictValue res(Param::INT, new AutoBuffer(size)); + for (int j = 0; j < size; begin++, j++) + (*res.pi)[j] = *begin; + return res; +} + +template +DictValue DictValue::arrayReal(TypeIter begin, int size) +{ + DictValue res(Param::REAL, new AutoBuffer(size)); + for (int j = 0; j < size; begin++, j++) + (*res.pd)[j] = *begin; + return res; +} + +template +DictValue DictValue::arrayString(TypeIter begin, int size) +{ + DictValue res(Param::STRING, new AutoBuffer(size)); + for (int j = 0; j < size; begin++, j++) + (*res.ps)[j] = *begin; + return res; +} + +template<> +inline DictValue DictValue::get(int idx) const +{ + CV_Assert(idx == -1); + return *this; +} + +template<> +inline int64 DictValue::get(int idx) const +{ + CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size())); + idx = (idx == -1) ? 0 : idx; + + if (type == Param::INT) + { + return (*pi)[idx]; + } + else if (type == Param::REAL) + { + double doubleValue = (*pd)[idx]; + + double fracpart, intpart; + fracpart = std::modf(doubleValue, &intpart); + CV_Assert(fracpart == 0.0); + + return (int64)doubleValue; + } + else if (type == Param::STRING) + { + return std::atoi((*ps)[idx].c_str()); + } + else + { + CV_Assert(isInt() || isReal() || isString()); + return 0; + } +} + +template<> +inline int DictValue::get(int idx) const +{ + return (int)get(idx); +} + +inline int DictValue::getIntValue(int idx) const +{ + return (int)get(idx); +} + +template<> +inline unsigned DictValue::get(int idx) const +{ + return (unsigned)get(idx); +} + +template<> +inline bool DictValue::get(int idx) const +{ + return (get(idx) != 0); +} + +template<> +inline double DictValue::get(int idx) const +{ + CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size())); + idx = (idx == -1) ? 0 : idx; + + if (type == Param::REAL) + { + return (*pd)[idx]; + } + else if (type == Param::INT) + { + return (double)(*pi)[idx]; + } + else if (type == Param::STRING) + { + return std::atof((*ps)[idx].c_str()); + } + else + { + CV_Assert(isReal() || isInt() || isString()); + return 0; + } +} + +inline double DictValue::getRealValue(int idx) const +{ + return get(idx); +} + +template<> +inline float DictValue::get(int idx) const +{ + return (float)get(idx); +} + +template<> +inline String DictValue::get(int idx) const +{ + CV_Assert(isString()); + CV_Assert((idx == -1 && ps->size() == 1) || (idx >= 0 && idx < (int)ps->size())); + return (*ps)[(idx == -1) ? 0 : idx]; +} + + +inline String DictValue::getStringValue(int idx) const +{ + return get(idx); +} + +inline void DictValue::release() +{ + switch (type) + { + case Param::INT: + delete pi; + break; + case Param::STRING: + delete ps; + break; + case Param::REAL: + delete pd; + break; + case Param::BOOLEAN: + case Param::MAT: + case Param::MAT_VECTOR: + case Param::ALGORITHM: + case Param::FLOAT: + case Param::UNSIGNED_INT: + case Param::UINT64: + case Param::UCHAR: + case Param::SCALAR: + break; // unhandled + } +} + +inline DictValue::~DictValue() +{ + release(); +} + +inline DictValue & DictValue::operator=(const DictValue &r) +{ + if (&r == this) + return *this; + + if (r.type == Param::INT) + { + AutoBuffer *tmp = new AutoBuffer(*r.pi); + release(); + pi = tmp; + } + else if (r.type == Param::STRING) + { + AutoBuffer *tmp = new AutoBuffer(*r.ps); + release(); + ps = tmp; + } + else if (r.type == Param::REAL) + { + AutoBuffer *tmp = new AutoBuffer(*r.pd); + release(); + pd = tmp; + } + + type = r.type; + + return *this; +} + +inline DictValue::DictValue(const DictValue &r) + : pv(NULL) +{ + type = r.type; + + if (r.type == Param::INT) + pi = new AutoBuffer(*r.pi); + else if (r.type == Param::STRING) + ps = new AutoBuffer(*r.ps); + else if (r.type == Param::REAL) + pd = new AutoBuffer(*r.pd); +} + +inline bool DictValue::isString() const +{ + return (type == Param::STRING); +} + +inline bool DictValue::isInt() const +{ + return (type == Param::INT); +} + +inline bool DictValue::isReal() const +{ + return (type == Param::REAL || type == Param::INT); +} + +inline int DictValue::size() const +{ + switch (type) + { + case Param::INT: + return (int)pi->size(); + case Param::STRING: + return (int)ps->size(); + case Param::REAL: + return (int)pd->size(); + case Param::BOOLEAN: + case Param::MAT: + case Param::MAT_VECTOR: + case Param::ALGORITHM: + case Param::FLOAT: + case Param::UNSIGNED_INT: + case Param::UINT64: + case Param::UCHAR: + case Param::SCALAR: + break; // unhandled + } + CV_Error_(Error::StsInternal, ("Unhandled type (%d)", static_cast(type))); +} + +inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv) +{ + int i; + + if (dictv.isInt()) + { + for (i = 0; i < dictv.size() - 1; i++) + stream << dictv.get(i) << ", "; + stream << dictv.get(i); + } + else if (dictv.isReal()) + { + for (i = 0; i < dictv.size() - 1; i++) + stream << dictv.get(i) << ", "; + stream << dictv.get(i); + } + else if (dictv.isString()) + { + for (i = 0; i < dictv.size() - 1; i++) + stream << "\"" << dictv.get(i) << "\", "; + stream << dictv.get(i); + } + + return stream; +} + +///////////////////////////////////////////////////////////////// + +inline bool Dict::has(const String &key) const +{ + return dict.count(key) != 0; +} + +inline DictValue *Dict::ptr(const String &key) +{ + _Dict::iterator i = dict.find(key); + return (i == dict.end()) ? NULL : &i->second; +} + +inline const DictValue *Dict::ptr(const String &key) const +{ + _Dict::const_iterator i = dict.find(key); + return (i == dict.end()) ? NULL : &i->second; +} + +inline const DictValue &Dict::get(const String &key) const +{ + _Dict::const_iterator i = dict.find(key); + if (i == dict.end()) + CV_Error(Error::StsObjectNotFound, "Required argument \"" + key + "\" not found into dictionary"); + return i->second; +} + +template +inline T Dict::get(const String &key) const +{ + return this->get(key).get(); +} + +template +inline T Dict::get(const String &key, const T &defaultValue) const +{ + _Dict::const_iterator i = dict.find(key); + + if (i != dict.end()) + return i->second.get(); + else + return defaultValue; +} + +template +inline const T &Dict::set(const String &key, const T &value) +{ + _Dict::iterator i = dict.find(key); + + if (i != dict.end()) + i->second = DictValue(value); + else + dict.insert(std::make_pair(key, DictValue(value))); + + return value; +} + +inline void Dict::erase(const String &key) +{ + dict.erase(key); +} + +inline std::ostream &operator<<(std::ostream &stream, const Dict &dict) +{ + Dict::_Dict::const_iterator it; + for (it = dict.dict.begin(); it != dict.dict.end(); it++) + stream << it->first << " : " << it->second << "\n"; + + return stream; +} + +inline std::map::const_iterator Dict::begin() const +{ + return dict.begin(); +} + +inline std::map::const_iterator Dict::end() const +{ + return dict.end(); +} + +CV__DNN_INLINE_NS_END +} +} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/layer.details.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/layer.details.hpp new file mode 100644 index 0000000..1133da5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/layer.details.hpp @@ -0,0 +1,78 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +#ifndef OPENCV_DNN_LAYER_DETAILS_HPP +#define OPENCV_DNN_LAYER_DETAILS_HPP + +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +/** @brief Registers layer constructor in runtime. +* @param type string, containing type name of the layer. +* @param constructorFunc pointer to the function of type LayerRegister::Constructor, which creates the layer. +* @details This macros must be placed inside the function code. +*/ +#define CV_DNN_REGISTER_LAYER_FUNC(type, constructorFunc) \ + cv::dnn::LayerFactory::registerLayer(#type, constructorFunc); + +/** @brief Registers layer class in runtime. + * @param type string, containing type name of the layer. + * @param class C++ class, derived from Layer. + * @details This macros must be placed inside the function code. + */ +#define CV_DNN_REGISTER_LAYER_CLASS(type, class) \ + cv::dnn::LayerFactory::registerLayer(#type, cv::dnn::details::_layerDynamicRegisterer); + +/** @brief Registers layer constructor on module load time. +* @param type string, containing type name of the layer. +* @param constructorFunc pointer to the function of type LayerRegister::Constructor, which creates the layer. +* @details This macros must be placed outside the function code. +*/ +#define CV_DNN_REGISTER_LAYER_FUNC_STATIC(type, constructorFunc) \ +static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, constructorFunc); + +/** @brief Registers layer class on module load time. + * @param type string, containing type name of the layer. + * @param class C++ class, derived from Layer. + * @details This macros must be placed outside the function code. + */ +#define CV_DNN_REGISTER_LAYER_CLASS_STATIC(type, class) \ +Ptr __LayerStaticRegisterer_func_##type(LayerParams ¶ms) \ + { return Ptr(new class(params)); } \ +static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, __LayerStaticRegisterer_func_##type); + +namespace details { + +template +Ptr _layerDynamicRegisterer(LayerParams ¶ms) +{ + return Ptr(LayerClass::create(params)); +} + +//allows automatically register created layer on module load time +class _LayerStaticRegisterer +{ + String type; +public: + + _LayerStaticRegisterer(const String &layerType, LayerFactory::Constructor layerConstructor) + { + this->type = layerType; + LayerFactory::registerLayer(layerType, layerConstructor); + } + + ~_LayerStaticRegisterer() + { + LayerFactory::unregisterLayer(type); + } +}; + +} // namespace +CV__DNN_INLINE_NS_END +}} // namespace + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/layer.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/layer.hpp new file mode 100644 index 0000000..8500599 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/layer.hpp @@ -0,0 +1,85 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_LAYER_HPP +#define OPENCV_DNN_LAYER_HPP +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN +//! @addtogroup dnn +//! @{ +//! +//! @defgroup dnnLayerFactory Utilities for New Layers Registration +//! @{ + +/** @brief %Layer factory allows to create instances of registered layers. */ +class CV_EXPORTS LayerFactory +{ +public: + + //! Each Layer class must provide this function to the factory + typedef Ptr(*Constructor)(LayerParams ¶ms); + + //! Registers the layer class with typename @p type and specified @p constructor. Thread-safe. + static void registerLayer(const String &type, Constructor constructor); + + //! Unregisters registered layer with specified type name. Thread-safe. + static void unregisterLayer(const String &type); + + /** @brief Creates instance of registered layer. + * @param type type name of creating layer. + * @param params parameters which will be used for layer initialization. + * @note Thread-safe. + */ + static Ptr createLayerInstance(const String &type, LayerParams& params); + +private: + LayerFactory(); +}; + +//! @} +//! @} +CV__DNN_INLINE_NS_END +} +} +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/shape_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/shape_utils.hpp new file mode 100644 index 0000000..4c610f6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/shape_utils.hpp @@ -0,0 +1,259 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_DNN_DNN_SHAPE_UTILS_HPP +#define OPENCV_DNN_DNN_SHAPE_UTILS_HPP + +#include +#include // CV_MAX_DIM +#include +#include +#include + +namespace cv { +namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +//Slicing + +struct _Range : public cv::Range +{ + _Range(const Range &r) : cv::Range(r) {} + _Range(int start_, int size_ = 1) : cv::Range(start_, start_ + size_) {} +}; + +static inline Mat slice(const Mat &m, const _Range &r0) +{ + Range ranges[CV_MAX_DIM]; + for (int i = 1; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + return m(&ranges[0]); +} + +static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1) +{ + CV_Assert(m.dims >= 2); + Range ranges[CV_MAX_DIM]; + for (int i = 2; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + ranges[1] = r1; + return m(&ranges[0]); +} + +static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2) +{ + CV_Assert(m.dims >= 3); + Range ranges[CV_MAX_DIM]; + for (int i = 3; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + ranges[1] = r1; + ranges[2] = r2; + return m(&ranges[0]); +} + +static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, const _Range &r3) +{ + CV_Assert(m.dims >= 4); + Range ranges[CV_MAX_DIM]; + for (int i = 4; i < m.dims; i++) + ranges[i] = Range::all(); + ranges[0] = r0; + ranges[1] = r1; + ranges[2] = r2; + ranges[3] = r3; + return m(&ranges[0]); +} + +static inline Mat getPlane(const Mat &m, int n, int cn) +{ + CV_Assert(m.dims > 2); + int sz[CV_MAX_DIM]; + for(int i = 2; i < m.dims; i++) + { + sz[i-2] = m.size.p[i]; + } + return Mat(m.dims - 2, sz, m.type(), (void*)m.ptr(n, cn)); +} + +static inline MatShape shape(const int* dims, const int n) +{ + MatShape shape; + shape.assign(dims, dims + n); + return shape; +} + +static inline MatShape shape(const Mat& mat) +{ + return shape(mat.size.p, mat.dims); +} + +static inline MatShape shape(const MatSize& sz) +{ + return shape(sz.p, sz.dims()); +} + +static inline MatShape shape(const UMat& mat) +{ + return shape(mat.size.p, mat.dims); +} + +#if 0 // issues with MatExpr wrapped into InputArray +static inline +MatShape shape(InputArray input) +{ + int sz[CV_MAX_DIM]; + int ndims = input.sizend(sz); + return shape(sz, ndims); +} +#endif + +namespace {inline bool is_neg(int i) { return i < 0; }} + +static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1) +{ + int dims[] = {a0, a1, a2, a3}; + MatShape s = shape(dims, 4); + s.erase(std::remove_if(s.begin(), s.end(), is_neg), s.end()); + return s; +} + +static inline int total(const MatShape& shape, int start = -1, int end = -1) +{ + if (start == -1) start = 0; + if (end == -1) end = (int)shape.size(); + + if (shape.empty()) + return 0; + + int elems = 1; + CV_Assert(start <= (int)shape.size() && end <= (int)shape.size() && + start <= end); + for(int i = start; i < end; i++) + { + elems *= shape[i]; + } + return elems; +} + +static inline MatShape concat(const MatShape& a, const MatShape& b) +{ + MatShape c = a; + c.insert(c.end(), b.begin(), b.end()); + + return c; +} + +static inline std::string toString(const MatShape& shape, const String& name = "") +{ + std::ostringstream ss; + if (!name.empty()) + ss << name << ' '; + ss << '['; + for(size_t i = 0, n = shape.size(); i < n; ++i) + ss << ' ' << shape[i]; + ss << " ]"; + return ss.str(); +} +static inline void print(const MatShape& shape, const String& name = "") +{ + std::cout << toString(shape, name) << std::endl; +} +static inline std::ostream& operator<<(std::ostream &out, const MatShape& shape) +{ + out << toString(shape); + return out; +} + +/// @brief Converts axis from `[-dims; dims)` (similar to Python's slice notation) to `[0; dims)` range. +static inline +int normalize_axis(int axis, int dims) +{ + CV_Check(axis, axis >= -dims && axis < dims, ""); + axis = (axis < 0) ? (dims + axis) : axis; + CV_DbgCheck(axis, axis >= 0 && axis < dims, ""); + return axis; +} + +static inline +int normalize_axis(int axis, const MatShape& shape) +{ + return normalize_axis(axis, (int)shape.size()); +} + +static inline +Range normalize_axis_range(const Range& r, int axisSize) +{ + if (r == Range::all()) + return Range(0, axisSize); + CV_CheckGE(r.start, 0, ""); + Range clamped(r.start, + r.end > 0 ? std::min(r.end, axisSize) : axisSize + r.end + 1); + CV_DbgCheckGE(clamped.start, 0, ""); + CV_CheckLT(clamped.start, clamped.end, ""); + CV_CheckLE(clamped.end, axisSize, ""); + return clamped; +} + +static inline +bool isAllOnes(const MatShape &inputShape, int startPos, int endPos) +{ + CV_Assert(!inputShape.empty()); + + CV_CheckGE((int) inputShape.size(), startPos, ""); + CV_CheckGE(startPos, 0, ""); + CV_CheckLE(startPos, endPos, ""); + CV_CheckLE((size_t)endPos, inputShape.size(), ""); + + for (size_t i = startPos; i < endPos; i++) + { + if (inputShape[i] != 1) + return false; + } + return true; +} + +CV__DNN_INLINE_NS_END +} +} +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/utils/debug_utils.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/utils/debug_utils.hpp new file mode 100644 index 0000000..71dd3ab --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/utils/debug_utils.hpp @@ -0,0 +1,24 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_DNN_UTILS_DEBUG_UTILS_HPP +#define OPENCV_DNN_UTILS_DEBUG_UTILS_HPP + +#include "../dnn.hpp" + +namespace cv { namespace dnn { +CV__DNN_INLINE_NS_BEGIN + +/** + * @brief Skip model import after diagnostic run in readNet() functions. + * @param[in] skip Indicates whether to skip the import. + * + * This is an internal OpenCV function not intended for users. + */ +CV_EXPORTS void skipModelImport(bool skip); + +CV__DNN_INLINE_NS_END +}} // namespace + +#endif // OPENCV_DNN_UTILS_DEBUG_UTILS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/utils/inference_engine.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/utils/inference_engine.hpp new file mode 100644 index 0000000..333b1bf --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/utils/inference_engine.hpp @@ -0,0 +1,76 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. + +#ifndef OPENCV_DNN_UTILS_INF_ENGINE_HPP +#define OPENCV_DNN_UTILS_INF_ENGINE_HPP + +#include "../dnn.hpp" + +namespace cv { namespace dnn { +CV__DNN_INLINE_NS_BEGIN + + +/* Values for 'OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE' parameter */ +#define CV_DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_API "NN_BUILDER" +#define CV_DNN_BACKEND_INFERENCE_ENGINE_NGRAPH "NGRAPH" + +/** @brief Returns Inference Engine internal backend API. + * + * See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros. + * + * Default value is controlled through `OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE` runtime parameter (environment variable). + */ +CV_EXPORTS_W cv::String getInferenceEngineBackendType(); + +/** @brief Specify Inference Engine internal backend API. + * + * See values of `CV_DNN_BACKEND_INFERENCE_ENGINE_*` macros. + * + * @returns previous value of internal backend API + */ +CV_EXPORTS_W cv::String setInferenceEngineBackendType(const cv::String& newBackendType); + + +/** @brief Release a Myriad device (binded by OpenCV). + * + * Single Myriad device cannot be shared across multiple processes which uses + * Inference Engine's Myriad plugin. + */ +CV_EXPORTS_W void resetMyriadDevice(); + + +/* Values for 'OPENCV_DNN_IE_VPU_TYPE' parameter */ +#define CV_DNN_INFERENCE_ENGINE_VPU_TYPE_UNSPECIFIED "" +/// Intel(R) Movidius(TM) Neural Compute Stick, NCS (USB 03e7:2150), Myriad2 (https://software.intel.com/en-us/movidius-ncs) +#define CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_2 "Myriad2" +/// Intel(R) Neural Compute Stick 2, NCS2 (USB 03e7:2485), MyriadX (https://software.intel.com/ru-ru/neural-compute-stick) +#define CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X "MyriadX" +#define CV_DNN_INFERENCE_ENGINE_CPU_TYPE_ARM_COMPUTE "ARM_COMPUTE" +#define CV_DNN_INFERENCE_ENGINE_CPU_TYPE_X86 "X86" + + +/** @brief Returns Inference Engine VPU type. + * + * See values of `CV_DNN_INFERENCE_ENGINE_VPU_TYPE_*` macros. + */ +CV_EXPORTS_W cv::String getInferenceEngineVPUType(); + +/** @brief Returns Inference Engine CPU type. + * + * Specify OpenVINO plugin: CPU or ARM. + */ +CV_EXPORTS_W cv::String getInferenceEngineCPUType(); + +/** @brief Release a HDDL plugin. + */ +CV_EXPORTS_W void releaseHDDLPlugin(); + + +CV__DNN_INLINE_NS_END +}} // namespace + +#endif // OPENCV_DNN_UTILS_INF_ENGINE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/version.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/version.hpp new file mode 100644 index 0000000..a0a1754 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/dnn/version.hpp @@ -0,0 +1,21 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_DNN_VERSION_HPP +#define OPENCV_DNN_VERSION_HPP + +/// Use with major OpenCV version only. +#define OPENCV_DNN_API_VERSION 20211220 + +#if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_INLINE_NS +#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION) +#define CV__DNN_INLINE_NS_BEGIN namespace CV__DNN_INLINE_NS { +#define CV__DNN_INLINE_NS_END } +namespace cv { namespace dnn { namespace CV__DNN_INLINE_NS { } using namespace CV__DNN_INLINE_NS; }} +#else +#define CV__DNN_INLINE_NS_BEGIN +#define CV__DNN_INLINE_NS_END +#endif + +#endif // OPENCV_DNN_VERSION_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d.hpp new file mode 100644 index 0000000..26c2b95 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d.hpp @@ -0,0 +1,1535 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_FEATURES_2D_HPP +#define OPENCV_FEATURES_2D_HPP + +#include "opencv2/opencv_modules.hpp" +#include "opencv2/core.hpp" + +#ifdef HAVE_OPENCV_FLANN +#include "opencv2/flann/miniflann.hpp" +#endif + +/** + @defgroup features2d 2D Features Framework + @{ + @defgroup features2d_main Feature Detection and Description + @defgroup features2d_match Descriptor Matchers + +Matchers of keypoint descriptors in OpenCV have wrappers with a common interface that enables you to +easily switch between different algorithms solving the same problem. This section is devoted to +matching descriptors that are represented as vectors in a multidimensional space. All objects that +implement vector descriptor matchers inherit the DescriptorMatcher interface. + + @defgroup features2d_draw Drawing Function of Keypoints and Matches + @defgroup features2d_category Object Categorization + +This section describes approaches based on local 2D features and used to categorize objects. + + @defgroup feature2d_hal Hardware Acceleration Layer + @{ + @defgroup features2d_hal_interface Interface + @} + @} + */ + +namespace cv +{ + +//! @addtogroup features2d_main +//! @{ + +// //! writes vector of keypoints to the file storage +// CV_EXPORTS void write(FileStorage& fs, const String& name, const std::vector& keypoints); +// //! reads vector of keypoints from the specified file storage node +// CV_EXPORTS void read(const FileNode& node, CV_OUT std::vector& keypoints); + +/** @brief A class filters a vector of keypoints. + + Because now it is difficult to provide a convenient interface for all usage scenarios of the + keypoints filter class, it has only several needed by now static methods. + */ +class CV_EXPORTS KeyPointsFilter +{ +public: + KeyPointsFilter(){} + + /* + * Remove keypoints within borderPixels of an image edge. + */ + static void runByImageBorder( std::vector& keypoints, Size imageSize, int borderSize ); + /* + * Remove keypoints of sizes out of range. + */ + static void runByKeypointSize( std::vector& keypoints, float minSize, + float maxSize=FLT_MAX ); + /* + * Remove keypoints from some image by mask for pixels of this image. + */ + static void runByPixelsMask( std::vector& keypoints, const Mat& mask ); + /* + * Remove duplicated keypoints. + */ + static void removeDuplicated( std::vector& keypoints ); + /* + * Remove duplicated keypoints and sort the remaining keypoints + */ + static void removeDuplicatedSorted( std::vector& keypoints ); + + /* + * Retain the specified number of the best keypoints (according to the response) + */ + static void retainBest( std::vector& keypoints, int npoints ); +}; + + +/************************************ Base Classes ************************************/ + +/** @brief Abstract base class for 2D image feature detectors and descriptor extractors +*/ +#ifdef __EMSCRIPTEN__ +class CV_EXPORTS_W Feature2D : public Algorithm +#else +class CV_EXPORTS_W Feature2D : public virtual Algorithm +#endif +{ +public: + virtual ~Feature2D(); + + /** @brief Detects keypoints in an image (first variant) or image set (second variant). + + @param image Image. + @param keypoints The detected keypoints. In the second variant of the method keypoints[i] is a set + of keypoints detected in images[i] . + @param mask Mask specifying where to look for keypoints (optional). It must be a 8-bit integer + matrix with non-zero values in the region of interest. + */ + CV_WRAP virtual void detect( InputArray image, + CV_OUT std::vector& keypoints, + InputArray mask=noArray() ); + + /** @overload + @param images Image set. + @param keypoints The detected keypoints. In the second variant of the method keypoints[i] is a set + of keypoints detected in images[i] . + @param masks Masks for each input image specifying where to look for keypoints (optional). + masks[i] is a mask for images[i]. + */ + CV_WRAP virtual void detect( InputArrayOfArrays images, + CV_OUT std::vector >& keypoints, + InputArrayOfArrays masks=noArray() ); + + /** @brief Computes the descriptors for a set of keypoints detected in an image (first variant) or image set + (second variant). + + @param image Image. + @param keypoints Input collection of keypoints. Keypoints for which a descriptor cannot be + computed are removed. Sometimes new keypoints can be added, for example: SIFT duplicates keypoint + with several dominant orientations (for each orientation). + @param descriptors Computed descriptors. In the second variant of the method descriptors[i] are + descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the + descriptor for keypoint j-th keypoint. + */ + CV_WRAP virtual void compute( InputArray image, + CV_OUT CV_IN_OUT std::vector& keypoints, + OutputArray descriptors ); + + /** @overload + + @param images Image set. + @param keypoints Input collection of keypoints. Keypoints for which a descriptor cannot be + computed are removed. Sometimes new keypoints can be added, for example: SIFT duplicates keypoint + with several dominant orientations (for each orientation). + @param descriptors Computed descriptors. In the second variant of the method descriptors[i] are + descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the + descriptor for keypoint j-th keypoint. + */ + CV_WRAP virtual void compute( InputArrayOfArrays images, + CV_OUT CV_IN_OUT std::vector >& keypoints, + OutputArrayOfArrays descriptors ); + + /** Detects keypoints and computes the descriptors */ + CV_WRAP virtual void detectAndCompute( InputArray image, InputArray mask, + CV_OUT std::vector& keypoints, + OutputArray descriptors, + bool useProvidedKeypoints=false ); + + CV_WRAP virtual int descriptorSize() const; + CV_WRAP virtual int descriptorType() const; + CV_WRAP virtual int defaultNorm() const; + + CV_WRAP void write( const String& fileName ) const; + + CV_WRAP void read( const String& fileName ); + + virtual void write( FileStorage&) const CV_OVERRIDE; + + // see corresponding cv::Algorithm method + CV_WRAP virtual void read( const FileNode&) CV_OVERRIDE; + + //! Return true if detector object is empty + CV_WRAP virtual bool empty() const CV_OVERRIDE; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; + + // see corresponding cv::Algorithm method + CV_WRAP inline void write(const Ptr& fs, const String& name = String()) const { Algorithm::write(fs, name); } +}; + +/** Feature detectors in OpenCV have wrappers with a common interface that enables you to easily switch +between different algorithms solving the same problem. All objects that implement keypoint detectors +inherit the FeatureDetector interface. */ +typedef Feature2D FeatureDetector; + +/** Extractors of keypoint descriptors in OpenCV have wrappers with a common interface that enables you +to easily switch between different algorithms solving the same problem. This section is devoted to +computing descriptors represented as vectors in a multidimensional space. All objects that implement +the vector descriptor extractors inherit the DescriptorExtractor interface. + */ +typedef Feature2D DescriptorExtractor; + + +/** @brief Class for implementing the wrapper which makes detectors and extractors to be affine invariant, +described as ASIFT in @cite YM11 . +*/ +class CV_EXPORTS_W AffineFeature : public Feature2D +{ +public: + /** + @param backend The detector/extractor you want to use as backend. + @param maxTilt The highest power index of tilt factor. 5 is used in the paper as tilt sampling range n. + @param minTilt The lowest power index of tilt factor. 0 is used in the paper. + @param tiltStep Tilt sampling step \f$\delta_t\f$ in Algorithm 1 in the paper. + @param rotateStepBase Rotation sampling step factor b in Algorithm 1 in the paper. + */ + CV_WRAP static Ptr create(const Ptr& backend, + int maxTilt = 5, int minTilt = 0, float tiltStep = 1.4142135623730951f, float rotateStepBase = 72); + + CV_WRAP virtual void setViewParams(const std::vector& tilts, const std::vector& rolls) = 0; + CV_WRAP virtual void getViewParams(std::vector& tilts, std::vector& rolls) const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +typedef AffineFeature AffineFeatureDetector; +typedef AffineFeature AffineDescriptorExtractor; + + +/** @brief Class for extracting keypoints and computing descriptors using the Scale Invariant Feature Transform +(SIFT) algorithm by D. Lowe @cite Lowe04 . +*/ +class CV_EXPORTS_W SIFT : public Feature2D +{ +public: + /** + @param nfeatures The number of best features to retain. The features are ranked by their scores + (measured in SIFT algorithm as the local contrast) + + @param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The + number of octaves is computed automatically from the image resolution. + + @param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform + (low-contrast) regions. The larger the threshold, the less features are produced by the detector. + + @note The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When + nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set + this argument to 0.09. + + @param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning + is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are + filtered out (more features are retained). + + @param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image + is captured with a weak camera with soft lenses, you might want to reduce the number. + */ + CV_WRAP static Ptr create(int nfeatures = 0, int nOctaveLayers = 3, + double contrastThreshold = 0.04, double edgeThreshold = 10, + double sigma = 1.6); + + /** @brief Create SIFT with specified descriptorType. + @param nfeatures The number of best features to retain. The features are ranked by their scores + (measured in SIFT algorithm as the local contrast) + + @param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper. The + number of octaves is computed automatically from the image resolution. + + @param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform + (low-contrast) regions. The larger the threshold, the less features are produced by the detector. + + @note The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When + nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set + this argument to 0.09. + + @param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning + is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are + filtered out (more features are retained). + + @param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image + is captured with a weak camera with soft lenses, you might want to reduce the number. + + @param descriptorType The type of descriptors. Only CV_32F and CV_8U are supported. + */ + CV_WRAP static Ptr create(int nfeatures, int nOctaveLayers, + double contrastThreshold, double edgeThreshold, + double sigma, int descriptorType); + + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +typedef SIFT SiftFeatureDetector; +typedef SIFT SiftDescriptorExtractor; + + +/** @brief Class implementing the BRISK keypoint detector and descriptor extractor, described in @cite LCS11 . + */ +class CV_EXPORTS_W BRISK : public Feature2D +{ +public: + /** @brief The BRISK constructor + + @param thresh AGAST detection threshold score. + @param octaves detection octaves. Use 0 to do single scale. + @param patternScale apply this scale to the pattern used for sampling the neighbourhood of a + keypoint. + */ + CV_WRAP static Ptr create(int thresh=30, int octaves=3, float patternScale=1.0f); + + /** @brief The BRISK constructor for a custom pattern + + @param radiusList defines the radii (in pixels) where the samples around a keypoint are taken (for + keypoint scale 1). + @param numberList defines the number of sampling points on the sampling circle. Must be the same + size as radiusList.. + @param dMax threshold for the short pairings used for descriptor formation (in pixels for keypoint + scale 1). + @param dMin threshold for the long pairings used for orientation determination (in pixels for + keypoint scale 1). + @param indexChange index remapping of the bits. */ + CV_WRAP static Ptr create(const std::vector &radiusList, const std::vector &numberList, + float dMax=5.85f, float dMin=8.2f, const std::vector& indexChange=std::vector()); + + /** @brief The BRISK constructor for a custom pattern, detection threshold and octaves + + @param thresh AGAST detection threshold score. + @param octaves detection octaves. Use 0 to do single scale. + @param radiusList defines the radii (in pixels) where the samples around a keypoint are taken (for + keypoint scale 1). + @param numberList defines the number of sampling points on the sampling circle. Must be the same + size as radiusList.. + @param dMax threshold for the short pairings used for descriptor formation (in pixels for keypoint + scale 1). + @param dMin threshold for the long pairings used for orientation determination (in pixels for + keypoint scale 1). + @param indexChange index remapping of the bits. */ + CV_WRAP static Ptr create(int thresh, int octaves, const std::vector &radiusList, + const std::vector &numberList, float dMax=5.85f, float dMin=8.2f, + const std::vector& indexChange=std::vector()); + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; + + /** @brief Set detection threshold. + @param threshold AGAST detection threshold score. + */ + CV_WRAP virtual void setThreshold(int threshold) { CV_UNUSED(threshold); return; } + CV_WRAP virtual int getThreshold() const { return -1; } + + /** @brief Set detection octaves. + @param octaves detection octaves. Use 0 to do single scale. + */ + CV_WRAP virtual void setOctaves(int octaves) { CV_UNUSED(octaves); return; } + CV_WRAP virtual int getOctaves() const { return -1; } +}; + +/** @brief Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor + +described in @cite RRKB11 . The algorithm uses FAST in pyramids to detect stable keypoints, selects +the strongest features using FAST or Harris response, finds their orientation using first-order +moments and computes the descriptors using BRIEF (where the coordinates of random point pairs (or +k-tuples) are rotated according to the measured orientation). + */ +class CV_EXPORTS_W ORB : public Feature2D +{ +public: + enum ScoreType { HARRIS_SCORE=0, FAST_SCORE=1 }; + static const int kBytes = 32; + + /** @brief The ORB constructor + + @param nfeatures The maximum number of features to retain. + @param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical + pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor + will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor + will mean that to cover certain scale range you will need more pyramid levels and so the speed + will suffer. + @param nlevels The number of pyramid levels. The smallest level will have linear size equal to + input_image_linear_size/pow(scaleFactor, nlevels - firstLevel). + @param edgeThreshold This is size of the border where the features are not detected. It should + roughly match the patchSize parameter. + @param firstLevel The level of pyramid to put source image to. Previous layers are filled + with upscaled source image. + @param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The + default value 2 means the BRIEF where we take a random point pair and compare their brightnesses, + so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3 + random points (of course, those point coordinates are random, but they are generated from the + pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel + rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such + output will occupy 2 bits, and therefore it will need a special variant of Hamming distance, + denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each + bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3). + @param scoreType The default HARRIS_SCORE means that Harris algorithm is used to rank features + (the score is written to KeyPoint::score and is used to retain best nfeatures features); + FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints, + but it is a little faster to compute. + @param patchSize size of the patch used by the oriented BRIEF descriptor. Of course, on smaller + pyramid layers the perceived image area covered by a feature will be larger. + @param fastThreshold the fast threshold + */ + CV_WRAP static Ptr create(int nfeatures=500, float scaleFactor=1.2f, int nlevels=8, int edgeThreshold=31, + int firstLevel=0, int WTA_K=2, ORB::ScoreType scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold=20); + + CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0; + CV_WRAP virtual int getMaxFeatures() const = 0; + + CV_WRAP virtual void setScaleFactor(double scaleFactor) = 0; + CV_WRAP virtual double getScaleFactor() const = 0; + + CV_WRAP virtual void setNLevels(int nlevels) = 0; + CV_WRAP virtual int getNLevels() const = 0; + + CV_WRAP virtual void setEdgeThreshold(int edgeThreshold) = 0; + CV_WRAP virtual int getEdgeThreshold() const = 0; + + CV_WRAP virtual void setFirstLevel(int firstLevel) = 0; + CV_WRAP virtual int getFirstLevel() const = 0; + + CV_WRAP virtual void setWTA_K(int wta_k) = 0; + CV_WRAP virtual int getWTA_K() const = 0; + + CV_WRAP virtual void setScoreType(ORB::ScoreType scoreType) = 0; + CV_WRAP virtual ORB::ScoreType getScoreType() const = 0; + + CV_WRAP virtual void setPatchSize(int patchSize) = 0; + CV_WRAP virtual int getPatchSize() const = 0; + + CV_WRAP virtual void setFastThreshold(int fastThreshold) = 0; + CV_WRAP virtual int getFastThreshold() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @brief Maximally stable extremal region extractor + +The class encapsulates all the parameters of the %MSER extraction algorithm (see [wiki +article](http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions)). + +- there are two different implementation of %MSER: one for grey image, one for color image + +- the grey image algorithm is taken from: @cite nister2008linear ; the paper claims to be faster +than union-find method; it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop. + +- the color image algorithm is taken from: @cite forssen2007maximally ; it should be much slower +than grey image method ( 3~4 times ) + +- (Python) A complete example showing the use of the %MSER detector can be found at samples/python/mser.py +*/ +class CV_EXPORTS_W MSER : public Feature2D +{ +public: + /** @brief Full constructor for %MSER detector + + @param delta it compares \f$(size_{i}-size_{i-delta})/size_{i-delta}\f$ + @param min_area prune the area which smaller than minArea + @param max_area prune the area which bigger than maxArea + @param max_variation prune the area have similar size to its children + @param min_diversity for color image, trace back to cut off mser with diversity less than min_diversity + @param max_evolution for color image, the evolution steps + @param area_threshold for color image, the area threshold to cause re-initialize + @param min_margin for color image, ignore too small margin + @param edge_blur_size for color image, the aperture size for edge blur + */ + CV_WRAP static Ptr create( int delta=5, int min_area=60, int max_area=14400, + double max_variation=0.25, double min_diversity=.2, + int max_evolution=200, double area_threshold=1.01, + double min_margin=0.003, int edge_blur_size=5 ); + + /** @brief Detect %MSER regions + + @param image input image (8UC1, 8UC3 or 8UC4, must be greater or equal than 3x3) + @param msers resulting list of point sets + @param bboxes resulting bounding boxes + */ + CV_WRAP virtual void detectRegions( InputArray image, + CV_OUT std::vector >& msers, + CV_OUT std::vector& bboxes ) = 0; + + CV_WRAP virtual void setDelta(int delta) = 0; + CV_WRAP virtual int getDelta() const = 0; + + CV_WRAP virtual void setMinArea(int minArea) = 0; + CV_WRAP virtual int getMinArea() const = 0; + + CV_WRAP virtual void setMaxArea(int maxArea) = 0; + CV_WRAP virtual int getMaxArea() const = 0; + + CV_WRAP virtual void setPass2Only(bool f) = 0; + CV_WRAP virtual bool getPass2Only() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +//! @} features2d_main + +//! @addtogroup features2d_main +//! @{ + +/** @brief Wrapping class for feature detection using the FAST method. : + */ +class CV_EXPORTS_W FastFeatureDetector : public Feature2D +{ +public: + enum DetectorType + { + TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2 + }; + enum + { + THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, FAST_N=10002 + }; + + + CV_WRAP static Ptr create( int threshold=10, + bool nonmaxSuppression=true, + FastFeatureDetector::DetectorType type=FastFeatureDetector::TYPE_9_16 ); + + CV_WRAP virtual void setThreshold(int threshold) = 0; + CV_WRAP virtual int getThreshold() const = 0; + + CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; + CV_WRAP virtual bool getNonmaxSuppression() const = 0; + + CV_WRAP virtual void setType(FastFeatureDetector::DetectorType type) = 0; + CV_WRAP virtual FastFeatureDetector::DetectorType getType() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @overload */ +CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + +/** @brief Detects corners using the FAST algorithm + +@param image grayscale image where keypoints (corners) are detected. +@param keypoints keypoints detected on the image. +@param threshold threshold on difference between intensity of the central pixel and pixels of a +circle around this pixel. +@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners +(keypoints). +@param type one of the three neighborhoods as defined in the paper: +FastFeatureDetector::TYPE_9_16, FastFeatureDetector::TYPE_7_12, +FastFeatureDetector::TYPE_5_8 + +Detects corners using the FAST algorithm by @cite Rosten06 . + +@note In Python API, types are given as cv.FAST_FEATURE_DETECTOR_TYPE_5_8, +cv.FAST_FEATURE_DETECTOR_TYPE_7_12 and cv.FAST_FEATURE_DETECTOR_TYPE_9_16. For corner +detection, use cv.FAST.detect() method. + */ +CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression, FastFeatureDetector::DetectorType type ); + +//! @} features2d_main + +//! @addtogroup features2d_main +//! @{ + +/** @brief Wrapping class for feature detection using the AGAST method. : + */ +class CV_EXPORTS_W AgastFeatureDetector : public Feature2D +{ +public: + enum DetectorType + { + AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3, + }; + + enum + { + THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001, + }; + + CV_WRAP static Ptr create( int threshold=10, + bool nonmaxSuppression=true, + AgastFeatureDetector::DetectorType type = AgastFeatureDetector::OAST_9_16); + + CV_WRAP virtual void setThreshold(int threshold) = 0; + CV_WRAP virtual int getThreshold() const = 0; + + CV_WRAP virtual void setNonmaxSuppression(bool f) = 0; + CV_WRAP virtual bool getNonmaxSuppression() const = 0; + + CV_WRAP virtual void setType(AgastFeatureDetector::DetectorType type) = 0; + CV_WRAP virtual AgastFeatureDetector::DetectorType getType() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @overload */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + +/** @brief Detects corners using the AGAST algorithm + +@param image grayscale image where keypoints (corners) are detected. +@param keypoints keypoints detected on the image. +@param threshold threshold on difference between intensity of the central pixel and pixels of a +circle around this pixel. +@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners +(keypoints). +@param type one of the four neighborhoods as defined in the paper: +AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, +AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16 + +For non-Intel platforms, there is a tree optimised variant of AGAST with same numerical results. +The 32-bit binary tree tables were generated automatically from original code using perl script. +The perl script and examples of tree generation are placed in features2d/doc folder. +Detects corners using the AGAST algorithm by @cite mair2010_agast . + + */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type ); + +/** @brief Wrapping class for feature detection using the goodFeaturesToTrack function. : + */ +class CV_EXPORTS_W GFTTDetector : public Feature2D +{ +public: + CV_WRAP static Ptr create( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1, + int blockSize=3, bool useHarrisDetector=false, double k=0.04 ); + CV_WRAP static Ptr create( int maxCorners, double qualityLevel, double minDistance, + int blockSize, int gradiantSize, bool useHarrisDetector=false, double k=0.04 ); + CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0; + CV_WRAP virtual int getMaxFeatures() const = 0; + + CV_WRAP virtual void setQualityLevel(double qlevel) = 0; + CV_WRAP virtual double getQualityLevel() const = 0; + + CV_WRAP virtual void setMinDistance(double minDistance) = 0; + CV_WRAP virtual double getMinDistance() const = 0; + + CV_WRAP virtual void setBlockSize(int blockSize) = 0; + CV_WRAP virtual int getBlockSize() const = 0; + + CV_WRAP virtual void setHarrisDetector(bool val) = 0; + CV_WRAP virtual bool getHarrisDetector() const = 0; + + CV_WRAP virtual void setK(double k) = 0; + CV_WRAP virtual double getK() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @brief Class for extracting blobs from an image. : + +The class implements a simple algorithm for extracting blobs from an image: + +1. Convert the source image to binary images by applying thresholding with several thresholds from + minThreshold (inclusive) to maxThreshold (exclusive) with distance thresholdStep between + neighboring thresholds. +2. Extract connected components from every binary image by findContours and calculate their + centers. +3. Group centers from several binary images by their coordinates. Close centers form one group that + corresponds to one blob, which is controlled by the minDistBetweenBlobs parameter. +4. From the groups, estimate final centers of blobs and their radiuses and return as locations and + sizes of keypoints. + +This class performs several filtrations of returned blobs. You should set filterBy\* to true/false +to turn on/off corresponding filtration. Available filtrations: + +- **By color**. This filter compares the intensity of a binary image at the center of a blob to +blobColor. If they differ, the blob is filtered out. Use blobColor = 0 to extract dark blobs +and blobColor = 255 to extract light blobs. +- **By area**. Extracted blobs have an area between minArea (inclusive) and maxArea (exclusive). +- **By circularity**. Extracted blobs have circularity +(\f$\frac{4*\pi*Area}{perimeter * perimeter}\f$) between minCircularity (inclusive) and +maxCircularity (exclusive). +- **By ratio of the minimum inertia to maximum inertia**. Extracted blobs have this ratio +between minInertiaRatio (inclusive) and maxInertiaRatio (exclusive). +- **By convexity**. Extracted blobs have convexity (area / area of blob convex hull) between +minConvexity (inclusive) and maxConvexity (exclusive). + +Default values of parameters are tuned to extract dark circular blobs. + */ +class CV_EXPORTS_W SimpleBlobDetector : public Feature2D +{ +public: + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW float thresholdStep; + CV_PROP_RW float minThreshold; + CV_PROP_RW float maxThreshold; + CV_PROP_RW size_t minRepeatability; + CV_PROP_RW float minDistBetweenBlobs; + + CV_PROP_RW bool filterByColor; + CV_PROP_RW uchar blobColor; + + CV_PROP_RW bool filterByArea; + CV_PROP_RW float minArea, maxArea; + + CV_PROP_RW bool filterByCircularity; + CV_PROP_RW float minCircularity, maxCircularity; + + CV_PROP_RW bool filterByInertia; + CV_PROP_RW float minInertiaRatio, maxInertiaRatio; + + CV_PROP_RW bool filterByConvexity; + CV_PROP_RW float minConvexity, maxConvexity; + + void read( const FileNode& fn ); + void write( FileStorage& fs ) const; + }; + + CV_WRAP static Ptr + create(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params()); + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +//! @} features2d_main + +//! @addtogroup features2d_main +//! @{ + +/** @brief Class implementing the KAZE keypoint detector and descriptor extractor, described in @cite ABD12 . + +@note AKAZE descriptor can only be used with KAZE or AKAZE keypoints .. [ABD12] KAZE Features. Pablo +F. Alcantarilla, Adrien Bartoli and Andrew J. Davison. In European Conference on Computer Vision +(ECCV), Fiorenze, Italy, October 2012. +*/ +class CV_EXPORTS_W KAZE : public Feature2D +{ +public: + enum DiffusivityType + { + DIFF_PM_G1 = 0, + DIFF_PM_G2 = 1, + DIFF_WEICKERT = 2, + DIFF_CHARBONNIER = 3 + }; + + /** @brief The KAZE constructor + + @param extended Set to enable extraction of extended (128-byte) descriptor. + @param upright Set to enable use of upright descriptors (non rotation-invariant). + @param threshold Detector response threshold to accept point + @param nOctaves Maximum octave evolution of the image + @param nOctaveLayers Default number of sublevels per scale level + @param diffusivity Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + DIFF_CHARBONNIER + */ + CV_WRAP static Ptr create(bool extended=false, bool upright=false, + float threshold = 0.001f, + int nOctaves = 4, int nOctaveLayers = 4, + KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2); + + CV_WRAP virtual void setExtended(bool extended) = 0; + CV_WRAP virtual bool getExtended() const = 0; + + CV_WRAP virtual void setUpright(bool upright) = 0; + CV_WRAP virtual bool getUpright() const = 0; + + CV_WRAP virtual void setThreshold(double threshold) = 0; + CV_WRAP virtual double getThreshold() const = 0; + + CV_WRAP virtual void setNOctaves(int octaves) = 0; + CV_WRAP virtual int getNOctaves() const = 0; + + CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0; + CV_WRAP virtual int getNOctaveLayers() const = 0; + + CV_WRAP virtual void setDiffusivity(KAZE::DiffusivityType diff) = 0; + CV_WRAP virtual KAZE::DiffusivityType getDiffusivity() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +/** @brief Class implementing the AKAZE keypoint detector and descriptor extractor, described in @cite ANB13. + +@details AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe. + +@note When you need descriptors use Feature2D::detectAndCompute, which +provides better performance. When using Feature2D::detect followed by +Feature2D::compute scale space pyramid is computed twice. + +@note AKAZE implements T-API. When image is passed as UMat some parts of the algorithm +will use OpenCL. + +@note [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear +Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In +British Machine Vision Conference (BMVC), Bristol, UK, September 2013. + +*/ +class CV_EXPORTS_W AKAZE : public Feature2D +{ +public: + // AKAZE descriptor type + enum DescriptorType + { + DESCRIPTOR_KAZE_UPRIGHT = 2, ///< Upright descriptors, not invariant to rotation + DESCRIPTOR_KAZE = 3, + DESCRIPTOR_MLDB_UPRIGHT = 4, ///< Upright descriptors, not invariant to rotation + DESCRIPTOR_MLDB = 5 + }; + + /** @brief The AKAZE constructor + + @param descriptor_type Type of the extracted descriptor: DESCRIPTOR_KAZE, + DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT. + @param descriptor_size Size of the descriptor in bits. 0 -\> Full size + @param descriptor_channels Number of channels in the descriptor (1, 2, 3) + @param threshold Detector response threshold to accept point + @param nOctaves Maximum octave evolution of the image + @param nOctaveLayers Default number of sublevels per scale level + @param diffusivity Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or + DIFF_CHARBONNIER + */ + CV_WRAP static Ptr create(AKAZE::DescriptorType descriptor_type = AKAZE::DESCRIPTOR_MLDB, + int descriptor_size = 0, int descriptor_channels = 3, + float threshold = 0.001f, int nOctaves = 4, + int nOctaveLayers = 4, KAZE::DiffusivityType diffusivity = KAZE::DIFF_PM_G2); + + CV_WRAP virtual void setDescriptorType(AKAZE::DescriptorType dtype) = 0; + CV_WRAP virtual AKAZE::DescriptorType getDescriptorType() const = 0; + + CV_WRAP virtual void setDescriptorSize(int dsize) = 0; + CV_WRAP virtual int getDescriptorSize() const = 0; + + CV_WRAP virtual void setDescriptorChannels(int dch) = 0; + CV_WRAP virtual int getDescriptorChannels() const = 0; + + CV_WRAP virtual void setThreshold(double threshold) = 0; + CV_WRAP virtual double getThreshold() const = 0; + + CV_WRAP virtual void setNOctaves(int octaves) = 0; + CV_WRAP virtual int getNOctaves() const = 0; + + CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0; + CV_WRAP virtual int getNOctaveLayers() const = 0; + + CV_WRAP virtual void setDiffusivity(KAZE::DiffusivityType diff) = 0; + CV_WRAP virtual KAZE::DiffusivityType getDiffusivity() const = 0; + CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; +}; + +//! @} features2d_main + +/****************************************************************************************\ +* Distance * +\****************************************************************************************/ + +template +struct CV_EXPORTS Accumulator +{ + typedef T Type; +}; + +template<> struct Accumulator { typedef float Type; }; +template<> struct Accumulator { typedef float Type; }; +template<> struct Accumulator { typedef float Type; }; +template<> struct Accumulator { typedef float Type; }; + +/* + * Squared Euclidean distance functor + */ +template +struct CV_EXPORTS SL2 +{ + static const NormTypes normType = NORM_L2SQR; + typedef T ValueType; + typedef typename Accumulator::Type ResultType; + + ResultType operator()( const T* a, const T* b, int size ) const + { + return normL2Sqr(a, b, size); + } +}; + +/* + * Euclidean distance functor + */ +template +struct L2 +{ + static const NormTypes normType = NORM_L2; + typedef T ValueType; + typedef typename Accumulator::Type ResultType; + + ResultType operator()( const T* a, const T* b, int size ) const + { + return (ResultType)std::sqrt((double)normL2Sqr(a, b, size)); + } +}; + +/* + * Manhattan distance (city block distance) functor + */ +template +struct L1 +{ + static const NormTypes normType = NORM_L1; + typedef T ValueType; + typedef typename Accumulator::Type ResultType; + + ResultType operator()( const T* a, const T* b, int size ) const + { + return normL1(a, b, size); + } +}; + +/****************************************************************************************\ +* DescriptorMatcher * +\****************************************************************************************/ + +//! @addtogroup features2d_match +//! @{ + +/** @brief Abstract base class for matching keypoint descriptors. + +It has two groups of match methods: for matching descriptors of an image with another image or with +an image set. + */ +class CV_EXPORTS_W DescriptorMatcher : public Algorithm +{ +public: + enum MatcherType + { + FLANNBASED = 1, + BRUTEFORCE = 2, + BRUTEFORCE_L1 = 3, + BRUTEFORCE_HAMMING = 4, + BRUTEFORCE_HAMMINGLUT = 5, + BRUTEFORCE_SL2 = 6 + }; + + virtual ~DescriptorMatcher(); + + /** @brief Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor + collection. + + If the collection is not empty, the new descriptors are added to existing train descriptors. + + @param descriptors Descriptors to add. Each descriptors[i] is a set of descriptors from the same + train image. + */ + CV_WRAP virtual void add( InputArrayOfArrays descriptors ); + + /** @brief Returns a constant link to the train descriptor collection trainDescCollection . + */ + CV_WRAP const std::vector& getTrainDescriptors() const; + + /** @brief Clears the train descriptor collections. + */ + CV_WRAP virtual void clear() CV_OVERRIDE; + + /** @brief Returns true if there are no train descriptors in the both collections. + */ + CV_WRAP virtual bool empty() const CV_OVERRIDE; + + /** @brief Returns true if the descriptor matcher supports masking permissible matches. + */ + CV_WRAP virtual bool isMaskSupported() const = 0; + + /** @brief Trains a descriptor matcher + + Trains a descriptor matcher (for example, the flann index). In all methods to match, the method + train() is run every time before matching. Some descriptor matchers (for example, BruteForceMatcher) + have an empty implementation of this method. Other matchers really train their inner structures (for + example, FlannBasedMatcher trains flann::Index ). + */ + CV_WRAP virtual void train(); + + /** @brief Finds the best match for each descriptor from a query set. + + @param queryDescriptors Query set of descriptors. + @param trainDescriptors Train set of descriptors. This set is not added to the train descriptors + collection stored in the class object. + @param matches Matches. If a query descriptor is masked out in mask , no match is added for this + descriptor. So, matches size may be smaller than the query descriptors count. + @param mask Mask specifying permissible matches between an input query and train matrices of + descriptors. + + In the first variant of this method, the train descriptors are passed as an input argument. In the + second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is + used. Optional mask (or masks) can be passed to specify which query and training descriptors can be + matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if + mask.at\(i,j) is non-zero. + */ + CV_WRAP void match( InputArray queryDescriptors, InputArray trainDescriptors, + CV_OUT std::vector& matches, InputArray mask=noArray() ) const; + + /** @brief Finds the k best matches for each descriptor from a query set. + + @param queryDescriptors Query set of descriptors. + @param trainDescriptors Train set of descriptors. This set is not added to the train descriptors + collection stored in the class object. + @param mask Mask specifying permissible matches between an input query and train matrices of + descriptors. + @param matches Matches. Each matches[i] is k or less matches for the same query descriptor. + @param k Count of best matches found per each query descriptor or less if a query descriptor has + less than k possible matches in total. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + + These extended variants of DescriptorMatcher::match methods find several best matches for each query + descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match + for the details about query and train descriptors. + */ + CV_WRAP void knnMatch( InputArray queryDescriptors, InputArray trainDescriptors, + CV_OUT std::vector >& matches, int k, + InputArray mask=noArray(), bool compactResult=false ) const; + + /** @brief For each query descriptor, finds the training descriptors not farther than the specified distance. + + @param queryDescriptors Query set of descriptors. + @param trainDescriptors Train set of descriptors. This set is not added to the train descriptors + collection stored in the class object. + @param matches Found matches. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + @param maxDistance Threshold for the distance between matched descriptors. Distance means here + metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured + in Pixels)! + @param mask Mask specifying permissible matches between an input query and train matrices of + descriptors. + + For each query descriptor, the methods find such training descriptors that the distance between the + query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are + returned in the distance increasing order. + */ + CV_WRAP void radiusMatch( InputArray queryDescriptors, InputArray trainDescriptors, + CV_OUT std::vector >& matches, float maxDistance, + InputArray mask=noArray(), bool compactResult=false ) const; + + /** @overload + @param queryDescriptors Query set of descriptors. + @param matches Matches. If a query descriptor is masked out in mask , no match is added for this + descriptor. So, matches size may be smaller than the query descriptors count. + @param masks Set of masks. Each masks[i] specifies permissible matches between the input query + descriptors and stored train descriptors from the i-th image trainDescCollection[i]. + */ + CV_WRAP void match( InputArray queryDescriptors, CV_OUT std::vector& matches, + InputArrayOfArrays masks=noArray() ); + /** @overload + @param queryDescriptors Query set of descriptors. + @param matches Matches. Each matches[i] is k or less matches for the same query descriptor. + @param k Count of best matches found per each query descriptor or less if a query descriptor has + less than k possible matches in total. + @param masks Set of masks. Each masks[i] specifies permissible matches between the input query + descriptors and stored train descriptors from the i-th image trainDescCollection[i]. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + */ + CV_WRAP void knnMatch( InputArray queryDescriptors, CV_OUT std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ); + /** @overload + @param queryDescriptors Query set of descriptors. + @param matches Found matches. + @param maxDistance Threshold for the distance between matched descriptors. Distance means here + metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured + in Pixels)! + @param masks Set of masks. Each masks[i] specifies permissible matches between the input query + descriptors and stored train descriptors from the i-th image trainDescCollection[i]. + @param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is + false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, + the matches vector does not contain matches for fully masked-out query descriptors. + */ + CV_WRAP void radiusMatch( InputArray queryDescriptors, CV_OUT std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ); + + + CV_WRAP void write( const String& fileName ) const + { + FileStorage fs(fileName, FileStorage::WRITE); + write(fs); + } + + CV_WRAP void read( const String& fileName ) + { + FileStorage fs(fileName, FileStorage::READ); + read(fs.root()); + } + // Reads matcher object from a file node + // see corresponding cv::Algorithm method + CV_WRAP virtual void read( const FileNode& ) CV_OVERRIDE; + // Writes matcher object to a file storage + virtual void write( FileStorage& ) const CV_OVERRIDE; + + /** @brief Clones the matcher. + + @param emptyTrainData If emptyTrainData is false, the method creates a deep copy of the object, + that is, copies both parameters and train data. If emptyTrainData is true, the method creates an + object copy with the current parameters but with empty train data. + */ + CV_WRAP CV_NODISCARD_STD virtual Ptr clone( bool emptyTrainData=false ) const = 0; + + /** @brief Creates a descriptor matcher of a given type with the default parameters (using default + constructor). + + @param descriptorMatcherType Descriptor matcher type. Now the following matcher types are + supported: + - `BruteForce` (it uses L2 ) + - `BruteForce-L1` + - `BruteForce-Hamming` + - `BruteForce-Hamming(2)` + - `FlannBased` + */ + CV_WRAP static Ptr create( const String& descriptorMatcherType ); + + CV_WRAP static Ptr create( const DescriptorMatcher::MatcherType& matcherType ); + + + // see corresponding cv::Algorithm method + CV_WRAP inline void write(const Ptr& fs, const String& name = String()) const { Algorithm::write(fs, name); } + +protected: + /** + * Class to work with descriptors from several images as with one merged matrix. + * It is used e.g. in FlannBasedMatcher. + */ + class CV_EXPORTS DescriptorCollection + { + public: + DescriptorCollection(); + DescriptorCollection( const DescriptorCollection& collection ); + virtual ~DescriptorCollection(); + + // Vector of matrices "descriptors" will be merged to one matrix "mergedDescriptors" here. + void set( const std::vector& descriptors ); + virtual void clear(); + + const Mat& getDescriptors() const; + const Mat getDescriptor( int imgIdx, int localDescIdx ) const; + const Mat getDescriptor( int globalDescIdx ) const; + void getLocalIdx( int globalDescIdx, int& imgIdx, int& localDescIdx ) const; + + int size() const; + + protected: + Mat mergedDescriptors; + std::vector startIdxs; + }; + + //! In fact the matching is implemented only by the following two methods. These methods suppose + //! that the class object has been trained already. Public match methods call these methods + //! after calling train(). + virtual void knnMatchImpl( InputArray queryDescriptors, std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) = 0; + virtual void radiusMatchImpl( InputArray queryDescriptors, std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) = 0; + + static bool isPossibleMatch( InputArray mask, int queryIdx, int trainIdx ); + static bool isMaskedOut( InputArrayOfArrays masks, int queryIdx ); + + CV_NODISCARD_STD static Mat clone_op( Mat m ) { return m.clone(); } + void checkMasks( InputArrayOfArrays masks, int queryDescriptorsCount ) const; + + //! Collection of descriptors from train images. + std::vector trainDescCollection; + std::vector utrainDescCollection; +}; + +/** @brief Brute-force descriptor matcher. + +For each descriptor in the first set, this matcher finds the closest descriptor in the second set +by trying each one. This descriptor matcher supports masking permissible matches of descriptor +sets. + */ +class CV_EXPORTS_W BFMatcher : public DescriptorMatcher +{ +public: + /** @brief Brute-force matcher constructor (obsolete). Please use BFMatcher.create() + * + * + */ + CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false ); + + virtual ~BFMatcher() {} + + virtual bool isMaskSupported() const CV_OVERRIDE { return true; } + + /** @brief Brute-force matcher create method. + @param normType One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are + preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and + BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor + description). + @param crossCheck If it is false, this is will be default BFMatcher behaviour when it finds the k + nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with + k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the + matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent + pairs. Such technique usually produces best results with minimal number of outliers when there are + enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper. + */ + CV_WRAP static Ptr create( int normType=NORM_L2, bool crossCheck=false ) ; + + CV_NODISCARD_STD virtual Ptr clone( bool emptyTrainData=false ) const CV_OVERRIDE; +protected: + virtual void knnMatchImpl( InputArray queryDescriptors, std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + virtual void radiusMatchImpl( InputArray queryDescriptors, std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + + int normType; + bool crossCheck; +}; + +#if defined(HAVE_OPENCV_FLANN) || defined(CV_DOXYGEN) + +/** @brief Flann-based descriptor matcher. + +This matcher trains cv::flann::Index on a train descriptor collection and calls its nearest search +methods to find the best matches. So, this matcher may be faster when matching a large train +collection than the brute force matcher. FlannBasedMatcher does not support masking permissible +matches of descriptor sets because flann::Index does not support this. : + */ +class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher +{ +public: + CV_WRAP FlannBasedMatcher( const Ptr& indexParams=makePtr(), + const Ptr& searchParams=makePtr() ); + + virtual void add( InputArrayOfArrays descriptors ) CV_OVERRIDE; + virtual void clear() CV_OVERRIDE; + + // Reads matcher object from a file node + virtual void read( const FileNode& ) CV_OVERRIDE; + // Writes matcher object to a file storage + virtual void write( FileStorage& ) const CV_OVERRIDE; + + virtual void train() CV_OVERRIDE; + virtual bool isMaskSupported() const CV_OVERRIDE; + + CV_WRAP static Ptr create(); + + CV_NODISCARD_STD virtual Ptr clone( bool emptyTrainData=false ) const CV_OVERRIDE; +protected: + static void convertToDMatches( const DescriptorCollection& descriptors, + const Mat& indices, const Mat& distances, + std::vector >& matches ); + + virtual void knnMatchImpl( InputArray queryDescriptors, std::vector >& matches, int k, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + virtual void radiusMatchImpl( InputArray queryDescriptors, std::vector >& matches, float maxDistance, + InputArrayOfArrays masks=noArray(), bool compactResult=false ) CV_OVERRIDE; + + Ptr indexParams; + Ptr searchParams; + Ptr flannIndex; + + DescriptorCollection mergedDescriptors; + int addedDescCount; +}; + +#endif + +//! @} features2d_match + +/****************************************************************************************\ +* Drawing functions * +\****************************************************************************************/ + +//! @addtogroup features2d_draw +//! @{ + +enum struct DrawMatchesFlags +{ + DEFAULT = 0, //!< Output image matrix will be created (Mat::create), + //!< i.e. existing memory of output image may be reused. + //!< Two source image, matches and single keypoints will be drawn. + //!< For each keypoint only the center point will be drawn (without + //!< the circle around keypoint with keypoint size and orientation). + DRAW_OVER_OUTIMG = 1, //!< Output image matrix will not be created (Mat::create). + //!< Matches will be drawn on existing content of output image. + NOT_DRAW_SINGLE_POINTS = 2, //!< Single keypoints will not be drawn. + DRAW_RICH_KEYPOINTS = 4 //!< For each keypoint the circle around keypoint with keypoint size and + //!< orientation will be drawn. +}; +CV_ENUM_FLAGS(DrawMatchesFlags) + +/** @brief Draws keypoints. + +@param image Source image. +@param keypoints Keypoints from the source image. +@param outImage Output image. Its content depends on the flags value defining what is drawn in the +output image. See possible flags bit values below. +@param color Color of keypoints. +@param flags Flags setting drawing features. Possible flags bit values are defined by +DrawMatchesFlags. See details above in drawMatches . + +@note +For Python API, flags are modified as cv.DRAW_MATCHES_FLAGS_DEFAULT, +cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG, +cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS + */ +CV_EXPORTS_W void drawKeypoints( InputArray image, const std::vector& keypoints, InputOutputArray outImage, + const Scalar& color=Scalar::all(-1), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +/** @brief Draws the found matches of keypoints from two images. + +@param img1 First source image. +@param keypoints1 Keypoints from the first source image. +@param img2 Second source image. +@param keypoints2 Keypoints from the second source image. +@param matches1to2 Matches from the first image to the second one, which means that keypoints1[i] +has a corresponding point in keypoints2[matches[i]] . +@param outImg Output image. Its content depends on the flags value defining what is drawn in the +output image. See possible flags bit values below. +@param matchColor Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1) +, the color is generated randomly. +@param singlePointColor Color of single keypoints (circles), which means that keypoints do not +have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly. +@param matchesMask Mask determining which matches are drawn. If the mask is empty, all matches are +drawn. +@param flags Flags setting drawing features. Possible flags bit values are defined by +DrawMatchesFlags. + +This function draws matches of keypoints from two images in the output image. Match is a line +connecting two keypoints (circles). See cv::DrawMatchesFlags. + */ +CV_EXPORTS_W void drawMatches( InputArray img1, const std::vector& keypoints1, + InputArray img2, const std::vector& keypoints2, + const std::vector& matches1to2, InputOutputArray outImg, + const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), + const std::vector& matchesMask=std::vector(), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +/** @overload */ +CV_EXPORTS_W void drawMatches( InputArray img1, const std::vector& keypoints1, + InputArray img2, const std::vector& keypoints2, + const std::vector& matches1to2, InputOutputArray outImg, + const int matchesThickness, const Scalar& matchColor=Scalar::all(-1), + const Scalar& singlePointColor=Scalar::all(-1), const std::vector& matchesMask=std::vector(), + DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +CV_EXPORTS_AS(drawMatchesKnn) void drawMatches( InputArray img1, const std::vector& keypoints1, + InputArray img2, const std::vector& keypoints2, + const std::vector >& matches1to2, InputOutputArray outImg, + const Scalar& matchColor=Scalar::all(-1), const Scalar& singlePointColor=Scalar::all(-1), + const std::vector >& matchesMask=std::vector >(), DrawMatchesFlags flags=DrawMatchesFlags::DEFAULT ); + +//! @} features2d_draw + +/****************************************************************************************\ +* Functions to evaluate the feature detectors and [generic] descriptor extractors * +\****************************************************************************************/ + +CV_EXPORTS void evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H1to2, + std::vector* keypoints1, std::vector* keypoints2, + float& repeatability, int& correspCount, + const Ptr& fdetector=Ptr() ); + +CV_EXPORTS void computeRecallPrecisionCurve( const std::vector >& matches1to2, + const std::vector >& correctMatches1to2Mask, + std::vector& recallPrecisionCurve ); + +CV_EXPORTS float getRecall( const std::vector& recallPrecisionCurve, float l_precision ); +CV_EXPORTS int getNearestPoint( const std::vector& recallPrecisionCurve, float l_precision ); + +/****************************************************************************************\ +* Bag of visual words * +\****************************************************************************************/ + +//! @addtogroup features2d_category +//! @{ + +/** @brief Abstract base class for training the *bag of visual words* vocabulary from a set of descriptors. + +For details, see, for example, *Visual Categorization with Bags of Keypoints* by Gabriella Csurka, +Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. : + */ +class CV_EXPORTS_W BOWTrainer +{ +public: + BOWTrainer(); + virtual ~BOWTrainer(); + + /** @brief Adds descriptors to a training set. + + @param descriptors Descriptors to add to a training set. Each row of the descriptors matrix is a + descriptor. + + The training set is clustered using clustermethod to construct the vocabulary. + */ + CV_WRAP void add( const Mat& descriptors ); + + /** @brief Returns a training set of descriptors. + */ + CV_WRAP const std::vector& getDescriptors() const; + + /** @brief Returns the count of all descriptors stored in the training set. + */ + CV_WRAP int descriptorsCount() const; + + CV_WRAP virtual void clear(); + + /** @overload */ + CV_WRAP virtual Mat cluster() const = 0; + + /** @brief Clusters train descriptors. + + @param descriptors Descriptors to cluster. Each row of the descriptors matrix is a descriptor. + Descriptors are not added to the inner train descriptor set. + + The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first + variant of the method, train descriptors stored in the object are clustered. In the second variant, + input descriptors are clustered. + */ + CV_WRAP virtual Mat cluster( const Mat& descriptors ) const = 0; + +protected: + std::vector descriptors; + int size; +}; + +/** @brief kmeans -based class to train visual vocabulary using the *bag of visual words* approach. : + */ +class CV_EXPORTS_W BOWKMeansTrainer : public BOWTrainer +{ +public: + /** @brief The constructor. + + @see cv::kmeans + */ + CV_WRAP BOWKMeansTrainer( int clusterCount, const TermCriteria& termcrit=TermCriteria(), + int attempts=3, int flags=KMEANS_PP_CENTERS ); + virtual ~BOWKMeansTrainer(); + + // Returns trained vocabulary (i.e. cluster centers). + CV_WRAP virtual Mat cluster() const CV_OVERRIDE; + CV_WRAP virtual Mat cluster( const Mat& descriptors ) const CV_OVERRIDE; + +protected: + + int clusterCount; + TermCriteria termcrit; + int attempts; + int flags; +}; + +/** @brief Class to compute an image descriptor using the *bag of visual words*. + +Such a computation consists of the following steps: + +1. Compute descriptors for a given image and its keypoints set. +2. Find the nearest visual words from the vocabulary for each keypoint descriptor. +3. Compute the bag-of-words image descriptor as is a normalized histogram of vocabulary words +encountered in the image. The i-th bin of the histogram is a frequency of i-th word of the +vocabulary in the given image. + */ +class CV_EXPORTS_W BOWImgDescriptorExtractor +{ +public: + /** @brief The constructor. + + @param dextractor Descriptor extractor that is used to compute descriptors for an input image and + its keypoints. + @param dmatcher Descriptor matcher that is used to find the nearest word of the trained vocabulary + for each keypoint descriptor of the image. + */ + CV_WRAP BOWImgDescriptorExtractor( const Ptr& dextractor, + const Ptr& dmatcher ); + /** @overload */ + BOWImgDescriptorExtractor( const Ptr& dmatcher ); + virtual ~BOWImgDescriptorExtractor(); + + /** @brief Sets a visual vocabulary. + + @param vocabulary Vocabulary (can be trained using the inheritor of BOWTrainer ). Each row of the + vocabulary is a visual word (cluster center). + */ + CV_WRAP void setVocabulary( const Mat& vocabulary ); + + /** @brief Returns the set vocabulary. + */ + CV_WRAP const Mat& getVocabulary() const; + + /** @brief Computes an image descriptor using the set visual vocabulary. + + @param image Image, for which the descriptor is computed. + @param keypoints Keypoints detected in the input image. + @param imgDescriptor Computed output image descriptor. + @param pointIdxsOfClusters Indices of keypoints that belong to the cluster. This means that + pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary) + returned if it is non-zero. + @param descriptors Descriptors of the image keypoints that are returned if they are non-zero. + */ + void compute( InputArray image, std::vector& keypoints, OutputArray imgDescriptor, + std::vector >* pointIdxsOfClusters=0, Mat* descriptors=0 ); + /** @overload + @param keypointDescriptors Computed descriptors to match with vocabulary. + @param imgDescriptor Computed output image descriptor. + @param pointIdxsOfClusters Indices of keypoints that belong to the cluster. This means that + pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary) + returned if it is non-zero. + */ + void compute( InputArray keypointDescriptors, OutputArray imgDescriptor, + std::vector >* pointIdxsOfClusters=0 ); + // compute() is not constant because DescriptorMatcher::match is not constant + + CV_WRAP_AS(compute) void compute2( const Mat& image, std::vector& keypoints, CV_OUT Mat& imgDescriptor ) + { compute(image,keypoints,imgDescriptor); } + + /** @brief Returns an image descriptor size if the vocabulary is set. Otherwise, it returns 0. + */ + CV_WRAP int descriptorSize() const; + + /** @brief Returns an image descriptor type. + */ + CV_WRAP int descriptorType() const; + +protected: + Mat vocabulary; + Ptr dextractor; + Ptr dmatcher; +}; + +//! @} features2d_category + +//! @} features2d + +} /* namespace cv */ + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d/features2d.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d/features2d.hpp new file mode 100644 index 0000000..e81df0a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d/features2d.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/features2d.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d/hal/interface.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d/hal/interface.h new file mode 100644 index 0000000..bc3b084 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/features2d/hal/interface.h @@ -0,0 +1,33 @@ +#ifndef OPENCV_FEATURE2D_HAL_INTERFACE_H +#define OPENCV_FEATURE2D_HAL_INTERFACE_H + +#include "opencv2/core/cvdef.h" +//! @addtogroup features2d_hal_interface +//! @{ + +//! @name Fast feature detector types +//! @sa cv::FastFeatureDetector +//! @{ +#define CV_HAL_TYPE_5_8 0 +#define CV_HAL_TYPE_7_12 1 +#define CV_HAL_TYPE_9_16 2 +//! @} + +//! @name Key point +//! @sa cv::KeyPoint +//! @{ +struct CV_EXPORTS cvhalKeyPoint +{ + float x; + float y; + float size; + float angle; + float response; + int octave; + int class_id; +}; +//! @} + +//! @} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann.hpp new file mode 100644 index 0000000..0468903 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann.hpp @@ -0,0 +1,629 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_FLANN_HPP +#define OPENCV_FLANN_HPP + +#include "opencv2/core.hpp" +#include "opencv2/flann/miniflann.hpp" +#include "opencv2/flann/flann_base.hpp" + +/** +@defgroup flann Clustering and Search in Multi-Dimensional Spaces + +This section documents OpenCV's interface to the FLANN library. FLANN (Fast Library for Approximate +Nearest Neighbors) is a library that contains a collection of algorithms optimized for fast nearest +neighbor search in large datasets and for high dimensional features. More information about FLANN +can be found in @cite Muja2009 . +*/ + +namespace cvflann +{ + CV_EXPORTS flann_distance_t flann_distance_type(); + CV_DEPRECATED CV_EXPORTS void set_distance_type(flann_distance_t distance_type, int order); +} + + +namespace cv +{ +namespace flann +{ + + +//! @addtogroup flann +//! @{ + +template struct CvType {}; +template <> struct CvType { static int type() { return CV_8U; } }; +template <> struct CvType { static int type() { return CV_8S; } }; +template <> struct CvType { static int type() { return CV_16U; } }; +template <> struct CvType { static int type() { return CV_16S; } }; +template <> struct CvType { static int type() { return CV_32S; } }; +template <> struct CvType { static int type() { return CV_32F; } }; +template <> struct CvType { static int type() { return CV_64F; } }; + + +// bring the flann parameters into this namespace +using ::cvflann::get_param; +using ::cvflann::print_params; + +// bring the flann distances into this namespace +using ::cvflann::L2_Simple; +using ::cvflann::L2; +using ::cvflann::L1; +using ::cvflann::MinkowskiDistance; +using ::cvflann::MaxDistance; +using ::cvflann::HammingLUT; +using ::cvflann::Hamming; +using ::cvflann::Hamming2; +using ::cvflann::DNAmmingLUT; +using ::cvflann::DNAmming2; +using ::cvflann::HistIntersectionDistance; +using ::cvflann::HellingerDistance; +using ::cvflann::ChiSquareDistance; +using ::cvflann::KL_Divergence; + + +/** @brief The FLANN nearest neighbor index class. This class is templated with the type of elements for which +the index is built. + +`Distance` functor specifies the metric to be used to calculate the distance between two points. +There are several `Distance` functors that are readily available: + +cv::cvflann::L2_Simple - Squared Euclidean distance functor. +This is the simpler, unrolled version. This is preferable for very low dimensionality data (eg 3D points) + +cv::flann::L2 - Squared Euclidean distance functor, optimized version. + +cv::flann::L1 - Manhattan distance functor, optimized version. + +cv::flann::MinkowskiDistance - The Minkowsky distance functor. +This is highly optimised with loop unrolling. +The computation of squared root at the end is omitted for efficiency. + +cv::flann::MaxDistance - The max distance functor. It computes the +maximum distance between two vectors. This distance is not a valid kdtree distance, it's not +dimensionwise additive. + +cv::flann::HammingLUT - %Hamming distance functor. It counts the bit +differences between two strings using a lookup table implementation. + +cv::flann::Hamming - %Hamming distance functor. Population count is +performed using library calls, if available. Lookup table implementation is used as a fallback. + +cv::flann::Hamming2 - %Hamming distance functor. Population count is +implemented in 12 arithmetic operations (one of which is multiplication). + +cv::flann::DNAmmingLUT - %Adaptation of the Hamming distance functor to DNA comparison. +As the four bases A, C, G, T of the DNA (or A, G, C, U for RNA) can be coded on 2 bits, +it counts the bits pairs differences between two sequences using a lookup table implementation. + +cv::flann::DNAmming2 - %Adaptation of the Hamming distance functor to DNA comparison. +Bases differences count are vectorised thanks to arithmetic operations using standard +registers (AVX2 and AVX-512 should come in a near future). + +cv::flann::HistIntersectionDistance - The histogram +intersection distance functor. + +cv::flann::HellingerDistance - The Hellinger distance functor. + +cv::flann::ChiSquareDistance - The chi-square distance functor. + +cv::flann::KL_Divergence - The Kullback-Leibler divergence functor. + +Although the provided implementations cover a vast range of cases, it is also possible to use +a custom implementation. The distance functor is a class whose `operator()` computes the distance +between two features. If the distance is also a kd-tree compatible distance, it should also provide an +`accum_dist()` method that computes the distance between individual feature dimensions. + +In addition to `operator()` and `accum_dist()`, a distance functor should also define the +`ElementType` and the `ResultType` as the types of the elements it operates on and the type of the +result it computes. If a distance functor can be used as a kd-tree distance (meaning that the full +distance between a pair of features can be accumulated from the partial distances between the +individual dimensions) a typedef `is_kdtree_distance` should be present inside the distance functor. +If the distance is not a kd-tree distance, but it's a distance in a vector space (the individual +dimensions of the elements it operates on can be accessed independently) a typedef +`is_vector_space_distance` should be defined inside the functor. If neither typedef is defined, the +distance is assumed to be a metric distance and will only be used with indexes operating on +generic metric distances. + */ +template +class GenericIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + /** @brief Constructs a nearest neighbor search index for a given dataset. + + @param features Matrix of containing the features(points) to index. The size of the matrix is + num_features x feature_dimensionality and the data type of the elements in the matrix must + coincide with the type of the index. + @param params Structure containing the index parameters. The type of index that will be + constructed depends on the type of this parameter. See the description. + @param distance + + The method constructs a fast search structure from a set of features using the specified algorithm + with specified parameters, as defined by params. params is a reference to one of the following class + IndexParams descendants: + + - **LinearIndexParams** When passing an object of this type, the index will perform a linear, + brute-force search. : + @code + struct LinearIndexParams : public IndexParams + { + }; + @endcode + - **KDTreeIndexParams** When passing an object of this type the index constructed will consist of + a set of randomized kd-trees which will be searched in parallel. : + @code + struct KDTreeIndexParams : public IndexParams + { + KDTreeIndexParams( int trees = 4 ); + }; + @endcode + - **HierarchicalClusteringIndexParams** When passing an object of this type the index constructed + will be a hierarchical tree of clusters, dividing each set of points into n clusters whose centers + are picked among the points without further refinement of their position. + This algorithm fits both floating, integer and binary vectors. : + @code + struct HierarchicalClusteringIndexParams : public IndexParams + { + HierarchicalClusteringIndexParams( + int branching = 32, + flann_centers_init_t centers_init = CENTERS_RANDOM, + int trees = 4, + int leaf_size = 100); + + }; + @endcode + - **KMeansIndexParams** When passing an object of this type the index constructed will be a + hierarchical k-means tree (one tree by default), dividing each set of points into n clusters + whose barycenters are refined iteratively. + Note that this algorithm has been extended to the support of binary vectors as an alternative + to LSH when knn search speed is the criterium. It will also outperform LSH when processing + directly (i.e. without the use of MCA/PCA) datasets whose points share mostly the same values + for most of the dimensions. It is recommended to set more than one tree with binary data. : + @code + struct KMeansIndexParams : public IndexParams + { + KMeansIndexParams( + int branching = 32, + int iterations = 11, + flann_centers_init_t centers_init = CENTERS_RANDOM, + float cb_index = 0.2, + int trees = 1); + }; + @endcode + - **CompositeIndexParams** When using a parameters object of this type the index created + combines the randomized kd-trees and the hierarchical k-means tree. : + @code + struct CompositeIndexParams : public IndexParams + { + CompositeIndexParams( + int trees = 4, + int branching = 32, + int iterations = 11, + flann_centers_init_t centers_init = CENTERS_RANDOM, + float cb_index = 0.2 ); + }; + @endcode + - **LshIndexParams** When using a parameters object of this type the index created uses + multi-probe LSH (by Multi-Probe LSH: Efficient Indexing for High-Dimensional Similarity Search + by Qin Lv, William Josephson, Zhe Wang, Moses Charikar, Kai Li., Proceedings of the 33rd + International Conference on Very Large Data Bases (VLDB). Vienna, Austria. September 2007). + This algorithm is designed for binary vectors. : + @code + struct LshIndexParams : public IndexParams + { + LshIndexParams( + int table_number, + int key_size, + int multi_probe_level ); + }; + @endcode + - **AutotunedIndexParams** When passing an object of this type the index created is + automatically tuned to offer the best performance, by choosing the optimal index type + (randomized kd-trees, hierarchical kmeans, linear) and parameters for the dataset provided. : + @code + struct AutotunedIndexParams : public IndexParams + { + AutotunedIndexParams( + float target_precision = 0.9, + float build_weight = 0.01, + float memory_weight = 0, + float sample_fraction = 0.1 ); + }; + @endcode + - **SavedIndexParams** This object type is used for loading a previously saved index from the + disk. : + @code + struct SavedIndexParams : public IndexParams + { + SavedIndexParams( String filename ); + }; + @endcode + */ + GenericIndex(const Mat& features, const ::cvflann::IndexParams& params, Distance distance = Distance()); + + ~GenericIndex(); + + /** @brief Performs a K-nearest neighbor search for a given query point using the index. + + @param query The query point + @param indices Vector that will contain the indices of the K-nearest neighbors found. It must have + at least knn size. + @param dists Vector that will contain the distances to the K-nearest neighbors found. It must have + at least knn size. + @param knn Number of nearest neighbors to search for. + @param params SearchParams + */ + void knnSearch(const std::vector& query, std::vector& indices, + std::vector& dists, int knn, const ::cvflann::SearchParams& params); + void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& params); + + /** @brief Performs a radius nearest neighbor search for a given query point using the index. + + @param query The query point. + @param indices Vector that will contain the indices of the nearest neighbors found. + @param dists Vector that will contain the distances to the nearest neighbors found. It has the same + number of elements as indices. + @param radius The search radius. + @param params SearchParams + + This function returns the number of nearest neighbors found. + */ + int radiusSearch(const std::vector& query, std::vector& indices, + std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); + int radiusSearch(const Mat& query, Mat& indices, Mat& dists, + DistanceType radius, const ::cvflann::SearchParams& params); + + void save(String filename) { nnIndex->save(filename); } + + int veclen() const { return nnIndex->veclen(); } + + int size() const { return (int)nnIndex->size(); } + + ::cvflann::IndexParams getParameters() { return nnIndex->getParameters(); } + + CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() { return nnIndex->getIndexParameters(); } + +private: + ::cvflann::Index* nnIndex; + Mat _dataset; +}; + +//! @cond IGNORED + +#define FLANN_DISTANCE_CHECK \ + if ( ::cvflann::flann_distance_type() != cvflann::FLANN_DIST_L2) { \ + printf("[WARNING] You are using cv::flann::Index (or cv::flann::GenericIndex) and have also changed "\ + "the distance using cvflann::set_distance_type. This is no longer working as expected "\ + "(cv::flann::Index always uses L2). You should create the index templated on the distance, "\ + "for example for L1 distance use: GenericIndex< L1 > \n"); \ + } + + +template +GenericIndex::GenericIndex(const Mat& dataset, const ::cvflann::IndexParams& params, Distance distance) +: _dataset(dataset) +{ + CV_Assert(dataset.type() == CvType::type()); + CV_Assert(dataset.isContinuous()); + ::cvflann::Matrix m_dataset((ElementType*)_dataset.ptr(0), _dataset.rows, _dataset.cols); + + nnIndex = new ::cvflann::Index(m_dataset, params, distance); + + FLANN_DISTANCE_CHECK + + nnIndex->buildIndex(); +} + +template +GenericIndex::~GenericIndex() +{ + delete nnIndex; +} + +template +void GenericIndex::knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& searchParams) +{ + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + FLANN_DISTANCE_CHECK + + nnIndex->knnSearch(m_query,m_indices,m_dists,knn,searchParams); +} + + +template +void GenericIndex::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams) +{ + CV_Assert(queries.type() == CvType::type()); + CV_Assert(queries.isContinuous()); + ::cvflann::Matrix m_queries((ElementType*)queries.ptr(0), queries.rows, queries.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + FLANN_DISTANCE_CHECK + + nnIndex->knnSearch(m_queries,m_indices,m_dists,knn, searchParams); +} + +template +int GenericIndex::radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) +{ + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + FLANN_DISTANCE_CHECK + + return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); +} + +template +int GenericIndex::radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) +{ + CV_Assert(query.type() == CvType::type()); + CV_Assert(query.isContinuous()); + ::cvflann::Matrix m_query((ElementType*)query.ptr(0), query.rows, query.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + FLANN_DISTANCE_CHECK + + return nnIndex->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); +} + +/** + * @deprecated Use GenericIndex class instead + */ +template +class Index_ +{ +public: + typedef typename L2::ElementType ElementType; + typedef typename L2::ResultType DistanceType; + + CV_DEPRECATED Index_(const Mat& dataset, const ::cvflann::IndexParams& params) + { + printf("[WARNING] The cv::flann::Index_ class is deperecated, use cv::flann::GenericIndex instead\n"); + + CV_Assert(dataset.type() == CvType::type()); + CV_Assert(dataset.isContinuous()); + ::cvflann::Matrix m_dataset((ElementType*)dataset.ptr(0), dataset.rows, dataset.cols); + + if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L2 ) { + nnIndex_L1 = NULL; + nnIndex_L2 = new ::cvflann::Index< L2 >(m_dataset, params); + } + else if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L1 ) { + nnIndex_L1 = new ::cvflann::Index< L1 >(m_dataset, params); + nnIndex_L2 = NULL; + } + else { + printf("[ERROR] cv::flann::Index_ only provides backwards compatibility for the L1 and L2 distances. " + "For other distance types you must use cv::flann::GenericIndex\n"); + CV_Assert(0); + } + if (nnIndex_L1) nnIndex_L1->buildIndex(); + if (nnIndex_L2) nnIndex_L2->buildIndex(); + } + CV_DEPRECATED ~Index_() + { + if (nnIndex_L1) delete nnIndex_L1; + if (nnIndex_L2) delete nnIndex_L2; + } + + CV_DEPRECATED void knnSearch(const std::vector& query, std::vector& indices, std::vector& dists, int knn, const ::cvflann::SearchParams& searchParams) + { + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + if (nnIndex_L1) nnIndex_L1->knnSearch(m_query,m_indices,m_dists,knn,searchParams); + if (nnIndex_L2) nnIndex_L2->knnSearch(m_query,m_indices,m_dists,knn,searchParams); + } + CV_DEPRECATED void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams) + { + CV_Assert(queries.type() == CvType::type()); + CV_Assert(queries.isContinuous()); + ::cvflann::Matrix m_queries((ElementType*)queries.ptr(0), queries.rows, queries.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + if (nnIndex_L1) nnIndex_L1->knnSearch(m_queries,m_indices,m_dists,knn, searchParams); + if (nnIndex_L2) nnIndex_L2->knnSearch(m_queries,m_indices,m_dists,knn, searchParams); + } + + CV_DEPRECATED int radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) + { + ::cvflann::Matrix m_query((ElementType*)&query[0], 1, query.size()); + ::cvflann::Matrix m_indices(&indices[0], 1, indices.size()); + ::cvflann::Matrix m_dists(&dists[0], 1, dists.size()); + + if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + } + + CV_DEPRECATED int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams) + { + CV_Assert(query.type() == CvType::type()); + CV_Assert(query.isContinuous()); + ::cvflann::Matrix m_query((ElementType*)query.ptr(0), query.rows, query.cols); + + CV_Assert(indices.type() == CV_32S); + CV_Assert(indices.isContinuous()); + ::cvflann::Matrix m_indices((int*)indices.ptr(0), indices.rows, indices.cols); + + CV_Assert(dists.type() == CvType::type()); + CV_Assert(dists.isContinuous()); + ::cvflann::Matrix m_dists((DistanceType*)dists.ptr(0), dists.rows, dists.cols); + + if (nnIndex_L1) return nnIndex_L1->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams); + } + + CV_DEPRECATED void save(String filename) + { + if (nnIndex_L1) nnIndex_L1->save(filename); + if (nnIndex_L2) nnIndex_L2->save(filename); + } + + CV_DEPRECATED int veclen() const + { + if (nnIndex_L1) return nnIndex_L1->veclen(); + if (nnIndex_L2) return nnIndex_L2->veclen(); + } + + CV_DEPRECATED int size() const + { + if (nnIndex_L1) return nnIndex_L1->size(); + if (nnIndex_L2) return nnIndex_L2->size(); + } + + CV_DEPRECATED ::cvflann::IndexParams getParameters() + { + if (nnIndex_L1) return nnIndex_L1->getParameters(); + if (nnIndex_L2) return nnIndex_L2->getParameters(); + + } + + CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() + { + if (nnIndex_L1) return nnIndex_L1->getIndexParameters(); + if (nnIndex_L2) return nnIndex_L2->getIndexParameters(); + } + +private: + // providing backwards compatibility for L2 and L1 distances (most common) + ::cvflann::Index< L2 >* nnIndex_L2; + ::cvflann::Index< L1 >* nnIndex_L1; +}; + +//! @endcond + +/** @brief Clusters features using hierarchical k-means algorithm. + +@param features The points to be clustered. The matrix must have elements of type +Distance::ElementType. +@param centers The centers of the clusters obtained. The matrix must have type +Distance::CentersType. The number of rows in this matrix represents the number of clusters desired, +however, because of the way the cut in the hierarchical tree is chosen, the number of clusters +computed will be the highest number of the form (branching-1)\*k+1 that's lower than the number of +clusters desired, where branching is the tree's branching factor (see description of the +KMeansIndexParams). +@param params Parameters used in the construction of the hierarchical k-means tree. +@param d Distance to be used for clustering. + +The method clusters the given feature vectors by constructing a hierarchical k-means tree and +choosing a cut in the tree that minimizes the cluster's variance. It returns the number of clusters +found. + */ +template +int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params, + Distance d = Distance()) +{ + typedef typename Distance::ElementType ElementType; + typedef typename Distance::CentersType CentersType; + + CV_Assert(features.type() == CvType::type()); + CV_Assert(features.isContinuous()); + ::cvflann::Matrix m_features((ElementType*)features.ptr(0), features.rows, features.cols); + + CV_Assert(centers.type() == CvType::type()); + CV_Assert(centers.isContinuous()); + ::cvflann::Matrix m_centers((CentersType*)centers.ptr(0), centers.rows, centers.cols); + + return ::cvflann::hierarchicalClustering(m_features, m_centers, params, d); +} + +//! @cond IGNORED + +template +CV_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params) +{ + printf("[WARNING] cv::flann::hierarchicalClustering is deprecated, use " + "cv::flann::hierarchicalClustering instead\n"); + + if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L2 ) { + return hierarchicalClustering< L2 >(features, centers, params); + } + else if ( ::cvflann::flann_distance_type() == cvflann::FLANN_DIST_L1 ) { + return hierarchicalClustering< L1 >(features, centers, params); + } + else { + printf("[ERROR] cv::flann::hierarchicalClustering only provides backwards " + "compatibility for the L1 and L2 distances. " + "For other distance types you must use cv::flann::hierarchicalClustering\n"); + CV_Assert(0); + } +} + +//! @endcond + +//! @} flann + +} } // namespace cv::flann + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/all_indices.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/all_indices.h new file mode 100644 index 0000000..03877ab --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/all_indices.h @@ -0,0 +1,162 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_ALL_INDICES_H_ +#define OPENCV_FLANN_ALL_INDICES_H_ + +//! @cond IGNORED + +#include "general.h" + +#include "nn_index.h" +#include "kdtree_index.h" +#include "kdtree_single_index.h" +#include "kmeans_index.h" +#include "composite_index.h" +#include "linear_index.h" +#include "hierarchical_clustering_index.h" +#include "lsh_index.h" +#include "autotuned_index.h" + + +namespace cvflann +{ + +template +struct index_creator +{ + static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) + { + flann_algorithm_t index_type = get_param(params, "algorithm"); + + NNIndex* nnIndex; + switch (index_type) { + case FLANN_INDEX_LINEAR: + nnIndex = new LinearIndex(dataset, params, distance); + break; + case FLANN_INDEX_KDTREE_SINGLE: + nnIndex = new KDTreeSingleIndex(dataset, params, distance); + break; + case FLANN_INDEX_KDTREE: + nnIndex = new KDTreeIndex(dataset, params, distance); + break; + case FLANN_INDEX_KMEANS: + nnIndex = new KMeansIndex(dataset, params, distance); + break; + case FLANN_INDEX_COMPOSITE: + nnIndex = new CompositeIndex(dataset, params, distance); + break; + case FLANN_INDEX_AUTOTUNED: + nnIndex = new AutotunedIndex(dataset, params, distance); + break; + case FLANN_INDEX_HIERARCHICAL: + nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); + break; + case FLANN_INDEX_LSH: + nnIndex = new LshIndex(dataset, params, distance); + break; + default: + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); + } + + return nnIndex; + } +}; + +template +struct index_creator +{ + static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) + { + flann_algorithm_t index_type = get_param(params, "algorithm"); + + NNIndex* nnIndex; + switch (index_type) { + case FLANN_INDEX_LINEAR: + nnIndex = new LinearIndex(dataset, params, distance); + break; + case FLANN_INDEX_KMEANS: + nnIndex = new KMeansIndex(dataset, params, distance); + break; + case FLANN_INDEX_HIERARCHICAL: + nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); + break; + case FLANN_INDEX_LSH: + nnIndex = new LshIndex(dataset, params, distance); + break; + default: + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); + } + + return nnIndex; + } +}; + +template +struct index_creator +{ + static NNIndex* create(const Matrix& dataset, const IndexParams& params, const Distance& distance) + { + flann_algorithm_t index_type = get_param(params, "algorithm"); + + NNIndex* nnIndex; + switch (index_type) { + case FLANN_INDEX_LINEAR: + nnIndex = new LinearIndex(dataset, params, distance); + break; + case FLANN_INDEX_KMEANS: + nnIndex = new KMeansIndex(dataset, params, distance); + break; + case FLANN_INDEX_HIERARCHICAL: + nnIndex = new HierarchicalClusteringIndex(dataset, params, distance); + break; + case FLANN_INDEX_LSH: + nnIndex = new LshIndex(dataset, params, distance); + break; + default: + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); + } + + return nnIndex; + } +}; + +template +NNIndex* create_index_by_type(const Matrix& dataset, const IndexParams& params, const Distance& distance) +{ + return index_creator::create(dataset, params,distance); +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_ALL_INDICES_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/allocator.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/allocator.h new file mode 100644 index 0000000..d5870a0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/allocator.h @@ -0,0 +1,196 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_ALLOCATOR_H_ +#define OPENCV_FLANN_ALLOCATOR_H_ + +//! @cond IGNORED + +#include +#include + + +namespace cvflann +{ + +/** + * Allocates (using C's malloc) a generic type T. + * + * Params: + * count = number of instances to allocate. + * Returns: pointer (of type T*) to memory buffer + */ +template +T* allocate(size_t count = 1) +{ + T* mem = (T*) ::malloc(sizeof(T)*count); + return mem; +} + + +/** + * Pooled storage allocator + * + * The following routines allow for the efficient allocation of storage in + * small chunks from a specified pool. Rather than allowing each structure + * to be freed individually, an entire pool of storage is freed at once. + * This method has two advantages over just using malloc() and free(). First, + * it is far more efficient for allocating small objects, as there is + * no overhead for remembering all the information needed to free each + * object or consolidating fragmented memory. Second, the decision about + * how long to keep an object is made at the time of allocation, and there + * is no need to track down all the objects to free them. + * + */ + +const size_t WORDSIZE=16; +const size_t BLOCKSIZE=8192; + +class PooledAllocator +{ + /* We maintain memory alignment to word boundaries by requiring that all + allocations be in multiples of the machine wordsize. */ + /* Size of machine word in bytes. Must be power of 2. */ + /* Minimum number of bytes requested at a time from the system. Must be multiple of WORDSIZE. */ + + + int remaining; /* Number of bytes left in current block of storage. */ + void* base; /* Pointer to base of current block of storage. */ + void* loc; /* Current location in block to next allocate memory. */ + int blocksize; + + +public: + int usedMemory; + int wastedMemory; + + /** + Default constructor. Initializes a new pool. + */ + PooledAllocator(int blockSize = BLOCKSIZE) + { + blocksize = blockSize; + remaining = 0; + base = NULL; + loc = NULL; + + usedMemory = 0; + wastedMemory = 0; + } + + /** + * Destructor. Frees all the memory allocated in this pool. + */ + ~PooledAllocator() + { + void* prev; + + while (base != NULL) { + prev = *((void**) base); /* Get pointer to prev block. */ + ::free(base); + base = prev; + } + } + + /** + * Returns a pointer to a piece of new memory of the given size in bytes + * allocated from the pool. + */ + void* allocateMemory(int size) + { + int blockSize; + + /* Round size up to a multiple of wordsize. The following expression + only works for WORDSIZE that is a power of 2, by masking last bits of + incremented size to zero. + */ + size = (size + (WORDSIZE - 1)) & ~(WORDSIZE - 1); + + /* Check whether a new block must be allocated. Note that the first word + of a block is reserved for a pointer to the previous block. + */ + if (size > remaining) { + + wastedMemory += remaining; + + /* Allocate new storage. */ + blockSize = (size + sizeof(void*) + (WORDSIZE-1) > BLOCKSIZE) ? + size + sizeof(void*) + (WORDSIZE-1) : BLOCKSIZE; + + // use the standard C malloc to allocate memory + void* m = ::malloc(blockSize); + if (!m) { + fprintf(stderr,"Failed to allocate memory.\n"); + return NULL; + } + + /* Fill first word of new block with pointer to previous block. */ + ((void**) m)[0] = base; + base = m; + + int shift = 0; + //int shift = (WORDSIZE - ( (((size_t)m) + sizeof(void*)) & (WORDSIZE-1))) & (WORDSIZE-1); + + remaining = blockSize - sizeof(void*) - shift; + loc = ((char*)m + sizeof(void*) + shift); + } + void* rloc = loc; + loc = (char*)loc + size; + remaining -= size; + + usedMemory += size; + + return rloc; + } + + /** + * Allocates (using this pool) a generic type T. + * + * Params: + * count = number of instances to allocate. + * Returns: pointer (of type T*) to memory buffer + */ + template + T* allocate(size_t count = 1) + { + T* mem = (T*) this->allocateMemory((int)(sizeof(T)*count)); + return mem; + } + +private: + PooledAllocator(const PooledAllocator &); // copy disabled + PooledAllocator& operator=(const PooledAllocator &); // assign disabled +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_ALLOCATOR_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/any.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/any.h new file mode 100644 index 0000000..4906fec --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/any.h @@ -0,0 +1,332 @@ +#ifndef OPENCV_FLANN_ANY_H_ +#define OPENCV_FLANN_ANY_H_ +/* + * (C) Copyright Christopher Diggins 2005-2011 + * (C) Copyright Pablo Aguilar 2005 + * (C) Copyright Kevlin Henney 2001 + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt + * + * Adapted for FLANN by Marius Muja + */ + +//! @cond IGNORED + +#include "defines.h" +#include +#include +#include + +namespace cvflann +{ + +namespace anyimpl +{ + +struct bad_any_cast +{ +}; + +struct empty_any +{ +}; + +inline std::ostream& operator <<(std::ostream& out, const empty_any&) +{ + out << "[empty_any]"; + return out; +} + +struct base_any_policy +{ + virtual void static_delete(void** x) = 0; + virtual void copy_from_value(void const* src, void** dest) = 0; + virtual void clone(void* const* src, void** dest) = 0; + virtual void move(void* const* src, void** dest) = 0; + virtual void* get_value(void** src) = 0; + virtual const void* get_value(void* const * src) = 0; + virtual ::size_t get_size() = 0; + virtual const std::type_info& type() = 0; + virtual void print(std::ostream& out, void* const* src) = 0; + virtual ~base_any_policy() {} +}; + +template +struct typed_base_any_policy : base_any_policy +{ + virtual ::size_t get_size() CV_OVERRIDE { return sizeof(T); } + virtual const std::type_info& type() CV_OVERRIDE { return typeid(T); } + +}; + +template +struct small_any_policy CV_FINAL : typed_base_any_policy +{ + virtual void static_delete(void**) CV_OVERRIDE { } + virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE + { + new (dest) T(* reinterpret_cast(src)); + } + virtual void clone(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; } + virtual void move(void* const* src, void** dest) CV_OVERRIDE { *dest = *src; } + virtual void* get_value(void** src) CV_OVERRIDE { return reinterpret_cast(src); } + virtual const void* get_value(void* const * src) CV_OVERRIDE { return reinterpret_cast(src); } + virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast(src); } +}; + +template +struct big_any_policy CV_FINAL : typed_base_any_policy +{ + virtual void static_delete(void** x) CV_OVERRIDE + { + if (* x) delete (* reinterpret_cast(x)); + *x = NULL; + } + virtual void copy_from_value(void const* src, void** dest) CV_OVERRIDE + { + *dest = new T(*reinterpret_cast(src)); + } + virtual void clone(void* const* src, void** dest) CV_OVERRIDE + { + *dest = new T(**reinterpret_cast(src)); + } + virtual void move(void* const* src, void** dest) CV_OVERRIDE + { + (*reinterpret_cast(dest))->~T(); + **reinterpret_cast(dest) = **reinterpret_cast(src); + } + virtual void* get_value(void** src) CV_OVERRIDE { return *src; } + virtual const void* get_value(void* const * src) CV_OVERRIDE { return *src; } + virtual void print(std::ostream& out, void* const* src) CV_OVERRIDE { out << *reinterpret_cast(*src); } +}; + +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << int(*reinterpret_cast(*src)); +} + +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << int(*reinterpret_cast(*src)); +} + +template<> inline void big_any_policy::print(std::ostream& out, void* const* src) +{ + out << (*reinterpret_cast(*src)).c_str(); +} + +template +struct choose_policy +{ + typedef big_any_policy type; +}; + +template +struct choose_policy +{ + typedef small_any_policy type; +}; + +struct any; + +/// Choosing the policy for an any type is illegal, but should never happen. +/// This is designed to throw a compiler error. +template<> +struct choose_policy +{ + typedef void type; +}; + +/// Specializations for small types. +#define SMALL_POLICY(TYPE) \ + template<> \ + struct choose_policy { typedef small_any_policy type; \ + } + +SMALL_POLICY(signed char); +SMALL_POLICY(unsigned char); +SMALL_POLICY(signed short); +SMALL_POLICY(unsigned short); +SMALL_POLICY(signed int); +SMALL_POLICY(unsigned int); +SMALL_POLICY(signed long); +SMALL_POLICY(unsigned long); +SMALL_POLICY(float); +SMALL_POLICY(bool); + +#undef SMALL_POLICY + +template +class SinglePolicy +{ + SinglePolicy(); + SinglePolicy(const SinglePolicy& other); + SinglePolicy& operator=(const SinglePolicy& other); + +public: + static base_any_policy* get_policy(); +}; + +/// This function will return a different policy for each type. +template +inline base_any_policy* SinglePolicy::get_policy() +{ + static typename choose_policy::type policy; + return &policy; +} + +} // namespace anyimpl + +struct any +{ +private: + // fields + anyimpl::base_any_policy* policy; + void* object; + +public: + /// Initializing constructor. + template + any(const T& x) + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { + assign(x); + } + + /// Empty constructor. + any() + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { } + + /// Special initializing constructor for string literals. + any(const char* x) + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { + assign(x); + } + + /// Copy constructor. + any(const any& x) + : policy(anyimpl::SinglePolicy::get_policy()), object(NULL) + { + assign(x); + } + + /// Destructor. + ~any() + { + policy->static_delete(&object); + } + + /// Assignment function from another any. + any& assign(const any& x) + { + reset(); + policy = x.policy; + policy->clone(&x.object, &object); + return *this; + } + + /// Assignment function. + template + any& assign(const T& x) + { + reset(); + policy = anyimpl::SinglePolicy::get_policy(); + policy->copy_from_value(&x, &object); + return *this; + } + + /// Assignment operator. + template + any& operator=(const T& x) + { + return assign(x); + } + + /// Assignment operator. Template-based version above doesn't work as expected. We need regular assignment operator here. + any& operator=(const any& x) + { + return assign(x); + } + + /// Assignment operator, specialed for literal strings. + /// They have types like const char [6] which don't work as expected. + any& operator=(const char* x) + { + return assign(x); + } + + /// Utility functions + any& swap(any& x) + { + std::swap(policy, x.policy); + std::swap(object, x.object); + return *this; + } + + /// Cast operator. You can only cast to the original type. + template + T& cast() + { + if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); + T* r = reinterpret_cast(policy->get_value(&object)); + return *r; + } + + /// Cast operator. You can only cast to the original type. + template + const T& cast() const + { + if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast(); + const T* r = reinterpret_cast(policy->get_value(&object)); + return *r; + } + + /// Returns true if the any contains no value. + bool empty() const + { + return policy->type() == typeid(anyimpl::empty_any); + } + + /// Frees any allocated memory, and sets the value to NULL. + void reset() + { + policy->static_delete(&object); + policy = anyimpl::SinglePolicy::get_policy(); + } + + /// Returns true if the two types are the same. + bool compatible(const any& x) const + { + return policy->type() == x.policy->type(); + } + + /// Returns if the type is compatible with the policy + template + bool has_type() + { + return policy->type() == typeid(T); + } + + const std::type_info& type() const + { + return policy->type(); + } + + friend std::ostream& operator <<(std::ostream& out, const any& any_val); +}; + +inline std::ostream& operator <<(std::ostream& out, const any& any_val) +{ + any_val.policy->print(out,&any_val.object); + return out; +} + +} + +//! @endcond + +#endif // OPENCV_FLANN_ANY_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/autotuned_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/autotuned_index.h new file mode 100644 index 0000000..d90f739 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/autotuned_index.h @@ -0,0 +1,594 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_AUTOTUNED_INDEX_H_ +#define OPENCV_FLANN_AUTOTUNED_INDEX_H_ + +//! @cond IGNORED + +#include + +#include "nn_index.h" +#include "ground_truth.h" +#include "index_testing.h" +#include "sampling.h" +#include "kdtree_index.h" +#include "kdtree_single_index.h" +#include "kmeans_index.h" +#include "composite_index.h" +#include "linear_index.h" +#include "logger.h" + +namespace cvflann +{ + +template +NNIndex* create_index_by_type(const Matrix& dataset, const IndexParams& params, const Distance& distance); + + +struct AutotunedIndexParams : public IndexParams +{ + AutotunedIndexParams(float target_precision = 0.8, float build_weight = 0.01, float memory_weight = 0, float sample_fraction = 0.1) + { + (*this)["algorithm"] = FLANN_INDEX_AUTOTUNED; + // precision desired (used for autotuning, -1 otherwise) + (*this)["target_precision"] = target_precision; + // build tree time weighting factor + (*this)["build_weight"] = build_weight; + // index memory weighting factor + (*this)["memory_weight"] = memory_weight; + // what fraction of the dataset to use for autotuning + (*this)["sample_fraction"] = sample_fraction; + } +}; + + +template +class AutotunedIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + AutotunedIndex(const Matrix& inputData, const IndexParams& params = AutotunedIndexParams(), Distance d = Distance()) : + dataset_(inputData), distance_(d) + { + target_precision_ = get_param(params, "target_precision",0.8f); + build_weight_ = get_param(params,"build_weight", 0.01f); + memory_weight_ = get_param(params, "memory_weight", 0.0f); + sample_fraction_ = get_param(params,"sample_fraction", 0.1f); + bestIndex_ = NULL; + speedup_ = 0; + } + + AutotunedIndex(const AutotunedIndex&); + AutotunedIndex& operator=(const AutotunedIndex&); + + virtual ~AutotunedIndex() + { + if (bestIndex_ != NULL) { + delete bestIndex_; + bestIndex_ = NULL; + } + } + + /** + * Method responsible with building the index. + */ + virtual void buildIndex() CV_OVERRIDE + { + std::ostringstream stream; + bestParams_ = estimateBuildParams(); + print_params(bestParams_, stream); + Logger::info("----------------------------------------------------\n"); + Logger::info("Autotuned parameters:\n"); + Logger::info("%s", stream.str().c_str()); + Logger::info("----------------------------------------------------\n"); + + bestIndex_ = create_index_by_type(dataset_, bestParams_, distance_); + bestIndex_->buildIndex(); + speedup_ = estimateSearchParams(bestSearchParams_); + stream.str(std::string()); + print_params(bestSearchParams_, stream); + Logger::info("----------------------------------------------------\n"); + Logger::info("Search parameters:\n"); + Logger::info("%s", stream.str().c_str()); + Logger::info("----------------------------------------------------\n"); + } + + /** + * Saves the index to a stream + */ + virtual void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, (int)bestIndex_->getType()); + bestIndex_->saveIndex(stream); + save_value(stream, get_param(bestSearchParams_, "checks")); + } + + /** + * Loads the index from a stream + */ + virtual void loadIndex(FILE* stream) CV_OVERRIDE + { + int index_type; + + load_value(stream, index_type); + IndexParams params; + params["algorithm"] = (flann_algorithm_t)index_type; + bestIndex_ = create_index_by_type(dataset_, params, distance_); + bestIndex_->loadIndex(stream); + int checks; + load_value(stream, checks); + bestSearchParams_["checks"] = checks; + } + + /** + * Method that searches for nearest-neighbors + */ + virtual void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + int checks = get_param(searchParams,"checks",FLANN_CHECKS_AUTOTUNED); + if (checks == FLANN_CHECKS_AUTOTUNED) { + bestIndex_->findNeighbors(result, vec, bestSearchParams_); + } + else { + bestIndex_->findNeighbors(result, vec, searchParams); + } + } + + + IndexParams getParameters() const CV_OVERRIDE + { + return bestIndex_->getParameters(); + } + + SearchParams getSearchParameters() const + { + return bestSearchParams_; + } + + float getSpeedup() const + { + return speedup_; + } + + + /** + * Number of features in this index. + */ + virtual size_t size() const CV_OVERRIDE + { + return bestIndex_->size(); + } + + /** + * The length of each vector in this index. + */ + virtual size_t veclen() const CV_OVERRIDE + { + return bestIndex_->veclen(); + } + + /** + * The amount of memory (in bytes) this index uses. + */ + virtual int usedMemory() const CV_OVERRIDE + { + return bestIndex_->usedMemory(); + } + + /** + * Algorithm name + */ + virtual flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_AUTOTUNED; + } + +private: + + struct CostData + { + float searchTimeCost; + float buildTimeCost; + float memoryCost; + float totalCost; + IndexParams params; + }; + + void evaluate_kmeans(CostData& cost) + { + StartStopTimer t; + int checks; + const int nn = 1; + + Logger::info("KMeansTree using params: max_iterations=%d, branching=%d\n", + get_param(cost.params,"iterations"), + get_param(cost.params,"branching")); + KMeansIndex kmeans(sampledDataset_, cost.params, distance_); + // measure index build time + t.start(); + kmeans.buildIndex(); + t.stop(); + float buildTime = (float)t.value; + + // measure search time + float searchTime = test_index_precision(kmeans, sampledDataset_, testDataset_, gt_matches_, target_precision_, checks, distance_, nn); + + float datasetMemory = float(sampledDataset_.rows * sampledDataset_.cols * sizeof(float)); + cost.memoryCost = (kmeans.usedMemory() + datasetMemory) / datasetMemory; + cost.searchTimeCost = searchTime; + cost.buildTimeCost = buildTime; + Logger::info("KMeansTree buildTime=%g, searchTime=%g, build_weight=%g\n", buildTime, searchTime, build_weight_); + } + + + void evaluate_kdtree(CostData& cost) + { + StartStopTimer t; + int checks; + const int nn = 1; + + Logger::info("KDTree using params: trees=%d\n", get_param(cost.params,"trees")); + KDTreeIndex kdtree(sampledDataset_, cost.params, distance_); + + t.start(); + kdtree.buildIndex(); + t.stop(); + float buildTime = (float)t.value; + + //measure search time + float searchTime = test_index_precision(kdtree, sampledDataset_, testDataset_, gt_matches_, target_precision_, checks, distance_, nn); + + float datasetMemory = float(sampledDataset_.rows * sampledDataset_.cols * sizeof(float)); + cost.memoryCost = (kdtree.usedMemory() + datasetMemory) / datasetMemory; + cost.searchTimeCost = searchTime; + cost.buildTimeCost = buildTime; + Logger::info("KDTree buildTime=%g, searchTime=%g\n", buildTime, searchTime); + } + + + // struct KMeansSimpleDownhillFunctor { + // + // Autotune& autotuner; + // KMeansSimpleDownhillFunctor(Autotune& autotuner_) : autotuner(autotuner_) {} + // + // float operator()(int* params) { + // + // float maxFloat = numeric_limits::max(); + // + // if (params[0]<2) return maxFloat; + // if (params[1]<0) return maxFloat; + // + // CostData c; + // c.params["algorithm"] = KMEANS; + // c.params["centers-init"] = CENTERS_RANDOM; + // c.params["branching"] = params[0]; + // c.params["max-iterations"] = params[1]; + // + // autotuner.evaluate_kmeans(c); + // + // return c.timeCost; + // + // } + // }; + // + // struct KDTreeSimpleDownhillFunctor { + // + // Autotune& autotuner; + // KDTreeSimpleDownhillFunctor(Autotune& autotuner_) : autotuner(autotuner_) {} + // + // float operator()(int* params) { + // float maxFloat = numeric_limits::max(); + // + // if (params[0]<1) return maxFloat; + // + // CostData c; + // c.params["algorithm"] = KDTREE; + // c.params["trees"] = params[0]; + // + // autotuner.evaluate_kdtree(c); + // + // return c.timeCost; + // + // } + // }; + + + + void optimizeKMeans(std::vector& costs) + { + Logger::info("KMEANS, Step 1: Exploring parameter space\n"); + + // explore kmeans parameters space using combinations of the parameters below + int maxIterations[] = { 1, 5, 10, 15 }; + int branchingFactors[] = { 16, 32, 64, 128, 256 }; + + int kmeansParamSpaceSize = FLANN_ARRAY_LEN(maxIterations) * FLANN_ARRAY_LEN(branchingFactors); + costs.reserve(costs.size() + kmeansParamSpaceSize); + + // evaluate kmeans for all parameter combinations + for (size_t i = 0; i < FLANN_ARRAY_LEN(maxIterations); ++i) { + for (size_t j = 0; j < FLANN_ARRAY_LEN(branchingFactors); ++j) { + CostData cost; + cost.params["algorithm"] = FLANN_INDEX_KMEANS; + cost.params["centers_init"] = FLANN_CENTERS_RANDOM; + cost.params["iterations"] = maxIterations[i]; + cost.params["branching"] = branchingFactors[j]; + + evaluate_kmeans(cost); + costs.push_back(cost); + } + } + + // Logger::info("KMEANS, Step 2: simplex-downhill optimization\n"); + // + // const int n = 2; + // // choose initial simplex points as the best parameters so far + // int kmeansNMPoints[n*(n+1)]; + // float kmeansVals[n+1]; + // for (int i=0;i& costs) + { + Logger::info("KD-TREE, Step 1: Exploring parameter space\n"); + + // explore kd-tree parameters space using the parameters below + int testTrees[] = { 1, 4, 8, 16, 32 }; + + // evaluate kdtree for all parameter combinations + for (size_t i = 0; i < FLANN_ARRAY_LEN(testTrees); ++i) { + CostData cost; + cost.params["algorithm"] = FLANN_INDEX_KDTREE; + cost.params["trees"] = testTrees[i]; + + evaluate_kdtree(cost); + costs.push_back(cost); + } + + // Logger::info("KD-TREE, Step 2: simplex-downhill optimization\n"); + // + // const int n = 1; + // // choose initial simplex points as the best parameters so far + // int kdtreeNMPoints[n*(n+1)]; + // float kdtreeVals[n+1]; + // for (int i=0;i costs; + + int sampleSize = int(sample_fraction_ * dataset_.rows); + int testSampleSize = std::min(sampleSize / 10, 1000); + + Logger::info("Entering autotuning, dataset size: %d, sampleSize: %d, testSampleSize: %d, target precision: %g\n", dataset_.rows, sampleSize, testSampleSize, target_precision_); + + // For a very small dataset, it makes no sense to build any fancy index, just + // use linear search + if (testSampleSize < 10) { + Logger::info("Choosing linear, dataset too small\n"); + return LinearIndexParams(); + } + + // We use a fraction of the original dataset to speedup the autotune algorithm + sampledDataset_ = random_sample(dataset_, sampleSize); + // We use a cross-validation approach, first we sample a testset from the dataset + testDataset_ = random_sample(sampledDataset_, testSampleSize, true); + + // We compute the ground truth using linear search + Logger::info("Computing ground truth... \n"); + gt_matches_ = Matrix(new int[testDataset_.rows], testDataset_.rows, 1); + StartStopTimer t; + t.start(); + compute_ground_truth(sampledDataset_, testDataset_, gt_matches_, 0, distance_); + t.stop(); + + CostData linear_cost; + linear_cost.searchTimeCost = (float)t.value; + linear_cost.buildTimeCost = 0; + linear_cost.memoryCost = 0; + linear_cost.params["algorithm"] = FLANN_INDEX_LINEAR; + + costs.push_back(linear_cost); + + // Start parameter autotune process + Logger::info("Autotuning parameters...\n"); + + optimizeKMeans(costs); + optimizeKDTree(costs); + + float bestTimeCost = costs[0].searchTimeCost; + for (size_t i = 0; i < costs.size(); ++i) { + float timeCost = costs[i].buildTimeCost * build_weight_ + costs[i].searchTimeCost; + if (timeCost < bestTimeCost) { + bestTimeCost = timeCost; + } + } + + float bestCost = costs[0].searchTimeCost / bestTimeCost; + IndexParams bestParams = costs[0].params; + if (bestTimeCost > 0) { + for (size_t i = 0; i < costs.size(); ++i) { + float crtCost = (costs[i].buildTimeCost * build_weight_ + costs[i].searchTimeCost) / bestTimeCost + + memory_weight_ * costs[i].memoryCost; + if (crtCost < bestCost) { + bestCost = crtCost; + bestParams = costs[i].params; + } + } + } + + delete[] gt_matches_.data; + delete[] testDataset_.data; + delete[] sampledDataset_.data; + + return bestParams; + } + + + + /** + * Estimates the search time parameters needed to get the desired precision. + * Precondition: the index is built + * Postcondition: the searchParams will have the optimum params set, also the speedup obtained over linear search. + */ + float estimateSearchParams(SearchParams& searchParams) + { + const int nn = 1; + const size_t SAMPLE_COUNT = 1000; + + CV_Assert(bestIndex_ != NULL && "Requires a valid index"); // must have a valid index + + float speedup = 0; + + int samples = (int)std::min(dataset_.rows / 10, SAMPLE_COUNT); + if (samples > 0) { + Matrix testDataset = random_sample(dataset_, samples); + + Logger::info("Computing ground truth\n"); + + // we need to compute the ground truth first + Matrix gt_matches(new int[testDataset.rows], testDataset.rows, 1); + StartStopTimer t; + t.start(); + compute_ground_truth(dataset_, testDataset, gt_matches, 1, distance_); + t.stop(); + float linear = (float)t.value; + + int checks; + Logger::info("Estimating number of checks\n"); + + float searchTime; + float cb_index; + if (bestIndex_->getType() == FLANN_INDEX_KMEANS) { + Logger::info("KMeans algorithm, estimating cluster border factor\n"); + KMeansIndex* kmeans = (KMeansIndex*)bestIndex_; + float bestSearchTime = -1; + float best_cb_index = -1; + int best_checks = -1; + for (cb_index = 0; cb_index < 1.1f; cb_index += 0.2f) { + kmeans->set_cb_index(cb_index); + searchTime = test_index_precision(*kmeans, dataset_, testDataset, gt_matches, target_precision_, checks, distance_, nn, 1); + if ((searchTime < bestSearchTime) || (bestSearchTime == -1)) { + bestSearchTime = searchTime; + best_cb_index = cb_index; + best_checks = checks; + } + } + searchTime = bestSearchTime; + cb_index = best_cb_index; + checks = best_checks; + + kmeans->set_cb_index(best_cb_index); + Logger::info("Optimum cb_index: %g\n", cb_index); + bestParams_["cb_index"] = cb_index; + } + else { + searchTime = test_index_precision(*bestIndex_, dataset_, testDataset, gt_matches, target_precision_, checks, distance_, nn, 1); + } + + Logger::info("Required number of checks: %d \n", checks); + searchParams["checks"] = checks; + + speedup = linear / searchTime; + + delete[] gt_matches.data; + delete[] testDataset.data; + } + + return speedup; + } + +private: + NNIndex* bestIndex_; + + IndexParams bestParams_; + SearchParams bestSearchParams_; + + Matrix sampledDataset_; + Matrix testDataset_; + Matrix gt_matches_; + + float speedup_; + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + /** + * Index parameters + */ + float target_precision_; + float build_weight_; + float memory_weight_; + float sample_fraction_; + + Distance distance_; + + +}; +} + +//! @endcond + +#endif /* OPENCV_FLANN_AUTOTUNED_INDEX_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/composite_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/composite_index.h new file mode 100644 index 0000000..f1af41a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/composite_index.h @@ -0,0 +1,197 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_COMPOSITE_INDEX_H_ +#define OPENCV_FLANN_COMPOSITE_INDEX_H_ + +//! @cond IGNORED + +#include "nn_index.h" +#include "kdtree_index.h" +#include "kmeans_index.h" + +namespace cvflann +{ + +/** + * Index parameters for the CompositeIndex. + */ +struct CompositeIndexParams : public IndexParams +{ + CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11, + flann_centers_init_t centers_init = FLANN_CENTERS_RANDOM, float cb_index = 0.2 ) + { + (*this)["algorithm"] = FLANN_INDEX_KMEANS; + // number of randomized trees to use (for kdtree) + (*this)["trees"] = trees; + // branching factor + (*this)["branching"] = branching; + // max iterations to perform in one kmeans clustering (kmeans tree) + (*this)["iterations"] = iterations; + // algorithm used for picking the initial cluster centers for kmeans tree + (*this)["centers_init"] = centers_init; + // cluster boundary index. Used when searching the kmeans tree + (*this)["cb_index"] = cb_index; + } +}; + + +/** + * This index builds a kd-tree index and a k-means index and performs nearest + * neighbour search both indexes. This gives a slight boost in search performance + * as some of the neighbours that are missed by one index are found by the other. + */ +template +class CompositeIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + /** + * Index constructor + * @param inputData dataset containing the points to index + * @param params Index parameters + * @param d Distance functor + * @return + */ + CompositeIndex(const Matrix& inputData, const IndexParams& params = CompositeIndexParams(), + Distance d = Distance()) : index_params_(params) + { + kdtree_index_ = new KDTreeIndex(inputData, params, d); + kmeans_index_ = new KMeansIndex(inputData, params, d); + + } + + CompositeIndex(const CompositeIndex&); + CompositeIndex& operator=(const CompositeIndex&); + + virtual ~CompositeIndex() + { + delete kdtree_index_; + delete kmeans_index_; + } + + /** + * @return The index type + */ + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_COMPOSITE; + } + + /** + * @return Size of the index + */ + size_t size() const CV_OVERRIDE + { + return kdtree_index_->size(); + } + + /** + * \returns The dimensionality of the features in this index. + */ + size_t veclen() const CV_OVERRIDE + { + return kdtree_index_->veclen(); + } + + /** + * \returns The amount of memory (in bytes) used by the index. + */ + int usedMemory() const CV_OVERRIDE + { + return kmeans_index_->usedMemory() + kdtree_index_->usedMemory(); + } + + /** + * \brief Builds the index + */ + void buildIndex() CV_OVERRIDE + { + Logger::info("Building kmeans tree...\n"); + kmeans_index_->buildIndex(); + Logger::info("Building kdtree tree...\n"); + kdtree_index_->buildIndex(); + } + + /** + * \brief Saves the index to a stream + * \param stream The stream to save the index to + */ + void saveIndex(FILE* stream) CV_OVERRIDE + { + kmeans_index_->saveIndex(stream); + kdtree_index_->saveIndex(stream); + } + + /** + * \brief Loads the index from a stream + * \param stream The stream from which the index is loaded + */ + void loadIndex(FILE* stream) CV_OVERRIDE + { + kmeans_index_->loadIndex(stream); + kdtree_index_->loadIndex(stream); + } + + /** + * \returns The index parameters + */ + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + + /** + * \brief Method that searches for nearest-neighbours + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + kmeans_index_->findNeighbors(result, vec, searchParams); + kdtree_index_->findNeighbors(result, vec, searchParams); + } + +private: + /** The k-means index */ + KMeansIndex* kmeans_index_; + + /** The kd-tree index */ + KDTreeIndex* kdtree_index_; + + /** The index parameters */ + const IndexParams index_params_; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_COMPOSITE_INDEX_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/config.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/config.h new file mode 100644 index 0000000..c9342c0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/config.h @@ -0,0 +1,42 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_CONFIG_H_ +#define OPENCV_FLANN_CONFIG_H_ + +//! @cond IGNORED + +#ifdef FLANN_VERSION_ +#undef FLANN_VERSION_ +#endif +#define FLANN_VERSION_ "1.6.10" + +//! @endcond + +#endif /* OPENCV_FLANN_CONFIG_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/defines.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/defines.h new file mode 100644 index 0000000..8ab8329 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/defines.h @@ -0,0 +1,169 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_DEFINES_H_ +#define OPENCV_FLANN_DEFINES_H_ + +//! @cond IGNORED + +#include "config.h" + +#ifdef FLANN_EXPORT +#undef FLANN_EXPORT +#endif +#ifdef _WIN32 +/* win32 dll export/import directives */ + #ifdef FLANN_EXPORTS + #define FLANN_EXPORT __declspec(dllexport) + #elif defined(FLANN_STATIC) + #define FLANN_EXPORT + #else + #define FLANN_EXPORT __declspec(dllimport) + #endif +#else +/* unix needs nothing */ + #define FLANN_EXPORT +#endif + + +#undef FLANN_PLATFORM_32_BIT +#undef FLANN_PLATFORM_64_BIT +#if defined __amd64__ || defined __x86_64__ || defined _WIN64 || defined _M_X64 +#define FLANN_PLATFORM_64_BIT +#else +#define FLANN_PLATFORM_32_BIT +#endif + + +#undef FLANN_ARRAY_LEN +#define FLANN_ARRAY_LEN(a) (sizeof(a)/sizeof(a[0])) + +namespace cvflann { + +/* Nearest neighbour index algorithms */ +enum flann_algorithm_t +{ + FLANN_INDEX_LINEAR = 0, + FLANN_INDEX_KDTREE = 1, + FLANN_INDEX_KMEANS = 2, + FLANN_INDEX_COMPOSITE = 3, + FLANN_INDEX_KDTREE_SINGLE = 4, + FLANN_INDEX_HIERARCHICAL = 5, + FLANN_INDEX_LSH = 6, + FLANN_INDEX_SAVED = 254, + FLANN_INDEX_AUTOTUNED = 255, + + // deprecated constants, should use the FLANN_INDEX_* ones instead + LINEAR = 0, + KDTREE = 1, + KMEANS = 2, + COMPOSITE = 3, + KDTREE_SINGLE = 4, + SAVED = 254, + AUTOTUNED = 255 +}; + + + +enum flann_centers_init_t +{ + FLANN_CENTERS_RANDOM = 0, + FLANN_CENTERS_GONZALES = 1, + FLANN_CENTERS_KMEANSPP = 2, + FLANN_CENTERS_GROUPWISE = 3, + + // deprecated constants, should use the FLANN_CENTERS_* ones instead + CENTERS_RANDOM = 0, + CENTERS_GONZALES = 1, + CENTERS_KMEANSPP = 2 +}; + +enum flann_log_level_t +{ + FLANN_LOG_NONE = 0, + FLANN_LOG_FATAL = 1, + FLANN_LOG_ERROR = 2, + FLANN_LOG_WARN = 3, + FLANN_LOG_INFO = 4 +}; + +enum flann_distance_t +{ + FLANN_DIST_EUCLIDEAN = 1, + FLANN_DIST_L2 = 1, + FLANN_DIST_MANHATTAN = 2, + FLANN_DIST_L1 = 2, + FLANN_DIST_MINKOWSKI = 3, + FLANN_DIST_MAX = 4, + FLANN_DIST_HIST_INTERSECT = 5, + FLANN_DIST_HELLINGER = 6, + FLANN_DIST_CHI_SQUARE = 7, + FLANN_DIST_CS = 7, + FLANN_DIST_KULLBACK_LEIBLER = 8, + FLANN_DIST_KL = 8, + FLANN_DIST_HAMMING = 9, + FLANN_DIST_DNAMMING = 10, + + // deprecated constants, should use the FLANN_DIST_* ones instead + EUCLIDEAN = 1, + MANHATTAN = 2, + MINKOWSKI = 3, + MAX_DIST = 4, + HIST_INTERSECT = 5, + HELLINGER = 6, + CS = 7, + KL = 8, + KULLBACK_LEIBLER = 8 +}; + +enum flann_datatype_t +{ + FLANN_INT8 = 0, + FLANN_INT16 = 1, + FLANN_INT32 = 2, + FLANN_INT64 = 3, + FLANN_UINT8 = 4, + FLANN_UINT16 = 5, + FLANN_UINT32 = 6, + FLANN_UINT64 = 7, + FLANN_FLOAT32 = 8, + FLANN_FLOAT64 = 9 +}; + +enum +{ + FLANN_CHECKS_UNLIMITED = -1, + FLANN_CHECKS_AUTOTUNED = -2 +}; + +} + +//! @endcond + +#endif /* OPENCV_FLANN_DEFINES_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dist.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dist.h new file mode 100644 index 0000000..608f8a5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dist.h @@ -0,0 +1,1292 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_DIST_H_ +#define OPENCV_FLANN_DIST_H_ + +//! @cond IGNORED + +#include +#include +#include +#ifdef _MSC_VER +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +#include "defines.h" + +#if defined _WIN32 && (defined(_M_ARM) || defined(_M_ARM64)) +# include +#endif + +#if defined(__ARM_NEON__) && !defined(__CUDACC__) +# include "arm_neon.h" +#endif + +namespace cvflann +{ + +template +inline T abs(T x) { return (x<0) ? -x : x; } + +template<> +inline int abs(int x) { return ::abs(x); } + +template<> +inline float abs(float x) { return fabsf(x); } + +template<> +inline double abs(double x) { return fabs(x); } + + +template +inline TargetType round(float x) { return static_cast(x); } + +template<> +inline unsigned int round(float x) { return static_cast(x + 0.5f); } + +template<> +inline unsigned short round(float x) { return static_cast(x + 0.5f); } + +template<> +inline unsigned char round(float x) { return static_cast(x + 0.5f); } + +template<> +inline long long round(float x) { return static_cast(x + 0.5f); } + +template<> +inline long round(float x) { return static_cast(x + 0.5f); } + +template<> +inline int round(float x) { return static_cast(x + 0.5f) - (x<0); } + +template<> +inline short round(float x) { return static_cast(x + 0.5f) - (x<0); } + +template<> +inline char round(float x) { return static_cast(x + 0.5f) - (x<0); } + + +template +inline TargetType round(double x) { return static_cast(x); } + +template<> +inline unsigned int round(double x) { return static_cast(x + 0.5); } + +template<> +inline unsigned short round(double x) { return static_cast(x + 0.5); } + +template<> +inline unsigned char round(double x) { return static_cast(x + 0.5); } + +template<> +inline long long round(double x) { return static_cast(x + 0.5); } + +template<> +inline long round(double x) { return static_cast(x + 0.5); } + +template<> +inline int round(double x) { return static_cast(x + 0.5) - (x<0); } + +template<> +inline short round(double x) { return static_cast(x + 0.5) - (x<0); } + +template<> +inline char round(double x) { return static_cast(x + 0.5) - (x<0); } + + +template +struct Accumulator { typedef T Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; +template<> +struct Accumulator { typedef float Type; }; + +#undef True +#undef False + +class True +{ +public: + static const bool val = true; +}; + +class False +{ +public: + static const bool val = false; +}; + + +/* + * This is a "zero iterator". It basically behaves like a zero filled + * array to all algorithms that use arrays as iterators (STL style). + * It's useful when there's a need to compute the distance between feature + * and origin it and allows for better compiler optimisation than using a + * zero-filled array. + */ +template +struct ZeroIterator +{ + + T operator*() + { + return 0; + } + + T operator[](int) + { + return 0; + } + + const ZeroIterator& operator ++() + { + return *this; + } + + ZeroIterator operator ++(int) + { + return *this; + } + + ZeroIterator& operator+=(int) + { + return *this; + } + +}; + + + +/** + * Squared Euclidean distance functor. + * + * This is the simpler, unrolled version. This is preferable for + * very low dimensionality data (eg 3D points) + */ +template +struct L2_Simple +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + ResultType result = ResultType(); + ResultType diff; + for(size_t i = 0; i < size; ++i ) { + diff = (ResultType)(*a++ - *b++); + result += diff*diff; + } + return result; + } + + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return (a-b)*(a-b); + } +}; + + + +/** + * Squared Euclidean distance functor, optimized version + */ +template +struct L2 +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the squared Euclidean distance between two vectors. + * + * This is highly optimised, with loop unrolling, as it is one + * of the most expensive inner loops. + * + * The computation of squared root at the end is omitted for + * efficiency. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = (ResultType)(a[0] - b[0]); + diff1 = (ResultType)(a[1] - b[1]); + diff2 = (ResultType)(a[2] - b[2]); + diff3 = (ResultType)(a[3] - b[3]); + result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3; + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = (ResultType)(*a++ - *b++); + result += diff0 * diff0; + } + return result; + } + + /** + * Partial euclidean distance, using just one dimension. This is used by the + * kd-tree when computing partial distances while traversing the tree. + * + * Squared root is omitted for efficiency. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return (a-b)*(a-b); + } +}; + + +/* + * Manhattan distance functor, optimized version + */ +template +struct L1 +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the Manhattan (L_1) distance between two vectors. + * + * This is highly optimised, with loop unrolling, as it is one + * of the most expensive inner loops. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = (ResultType)abs(a[0] - b[0]); + diff1 = (ResultType)abs(a[1] - b[1]); + diff2 = (ResultType)abs(a[2] - b[2]); + diff3 = (ResultType)abs(a[3] - b[3]); + result += diff0 + diff1 + diff2 + diff3; + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = (ResultType)abs(*a++ - *b++); + result += diff0; + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return abs(a-b); + } +}; + + + +template +struct MinkowskiDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + int order; + + MinkowskiDistance(int order_) : order(order_) {} + + /** + * Compute the Minkowsky (L_p) distance between two vectors. + * + * This is highly optimised, with loop unrolling, as it is one + * of the most expensive inner loops. + * + * The computation of squared root at the end is omitted for + * efficiency. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = (ResultType)abs(a[0] - b[0]); + diff1 = (ResultType)abs(a[1] - b[1]); + diff2 = (ResultType)abs(a[2] - b[2]); + diff3 = (ResultType)abs(a[3] - b[3]); + result += pow(diff0,order) + pow(diff1,order) + pow(diff2,order) + pow(diff3,order); + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = (ResultType)abs(*a++ - *b++); + result += pow(diff0,order); + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return pow(static_cast(abs(a-b)),order); + } +}; + + + +template +struct MaxDistance +{ + typedef False is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the max distance (L_infinity) between two vectors. + * + * This distance is not a valid kdtree distance, it's not dimensionwise additive. + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = abs(a[0] - b[0]); + diff1 = abs(a[1] - b[1]); + diff2 = abs(a[2] - b[2]); + diff3 = abs(a[3] - b[3]); + if (diff0>result) {result = diff0; } + if (diff1>result) {result = diff1; } + if (diff2>result) {result = diff2; } + if (diff3>result) {result = diff3; } + a += 4; + b += 4; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + diff0 = abs(*a++ - *b++); + result = (diff0>result) ? diff0 : result; + } + return result; + } + + /* This distance functor is not dimension-wise additive, which + * makes it an invalid kd-tree distance, not implementing the accum_dist method */ + +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Hamming distance functor - counts the bit differences between two strings - useful for the Brief descriptor + * bit count of A exclusive XOR'ed with B + */ +struct HammingLUT +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef unsigned char ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** this will count the bits in a ^ b + */ + template + ResultType operator()(const unsigned char* a, const Iterator2 b, size_t size) const + { + static const uchar popCountTable[] = + { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 + }; + ResultType result = 0; + const unsigned char* b2 = reinterpret_cast (b); + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i] ^ b2[i]]; + } + return result; + } + + + ResultType operator()(const unsigned char* a, const ZeroIterator b, size_t size) const + { + (void)b; + static const uchar popCountTable[] = + { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 + }; + ResultType result = 0; + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i]]; + } + return result; + } +}; + +/** + * Hamming distance functor (pop count between two binary vectors, i.e. xor them and count the number of bits set) + * That code was taken from brief.cpp in OpenCV + */ +template +struct Hamming +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + + typedef T ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + template + ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + ResultType result = 0; +#if defined(__ARM_NEON__) && !defined(__CUDACC__) + { + const unsigned char* a2 = reinterpret_cast (a); + const unsigned char* b2 = reinterpret_cast (b); + uint32x4_t bits = vmovq_n_u32(0); + for (size_t i = 0; i < size; i += 16) { + uint8x16_t A_vec = vld1q_u8 (a2 + i); + uint8x16_t B_vec = vld1q_u8 (b2 + i); + uint8x16_t AxorB = veorq_u8 (A_vec, B_vec); + uint8x16_t bitsSet = vcntq_u8 (AxorB); + uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet); + uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8); + bits = vaddq_u32(bits, bitSet4); + } + uint64x2_t bitSet2 = vpaddlq_u32 (bits); + result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0); + result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2); + } +#elif defined(__GNUC__) + { + //for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll) + typedef unsigned long long pop_t; + const size_t modulo = size % sizeof(pop_t); + const pop_t* a2 = reinterpret_cast (a); + const pop_t* b2 = reinterpret_cast (b); + const pop_t* a2_end = a2 + (size / sizeof(pop_t)); + + for (; a2 != a2_end; ++a2, ++b2) result += __builtin_popcountll((*a2) ^ (*b2)); + + if (modulo) { + //in the case where size is not dividable by sizeof(size_t) + //need to mask off the bits at the end + pop_t a_final = 0, b_final = 0; + memcpy(&a_final, a2, modulo); + memcpy(&b_final, b2, modulo); + result += __builtin_popcountll(a_final ^ b_final); + } + } +#else // NO NEON and NOT GNUC + HammingLUT lut; + result = lut(reinterpret_cast (a), + reinterpret_cast (b), size); +#endif + return result; + } + + + template + ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const + { + (void)b; + ResultType result = 0; +#if defined(__ARM_NEON__) && !defined(__CUDACC__) + { + const unsigned char* a2 = reinterpret_cast (a); + uint32x4_t bits = vmovq_n_u32(0); + for (size_t i = 0; i < size; i += 16) { + uint8x16_t A_vec = vld1q_u8 (a2 + i); + uint8x16_t bitsSet = vcntq_u8 (A_vec); + uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet); + uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8); + bits = vaddq_u32(bits, bitSet4); + } + uint64x2_t bitSet2 = vpaddlq_u32 (bits); + result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0); + result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2); + } +#elif defined(__GNUC__) + { + //for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll) + typedef unsigned long long pop_t; + const size_t modulo = size % sizeof(pop_t); + const pop_t* a2 = reinterpret_cast (a); + const pop_t* a2_end = a2 + (size / sizeof(pop_t)); + + for (; a2 != a2_end; ++a2) result += __builtin_popcountll(*a2); + + if (modulo) { + //in the case where size is not dividable by sizeof(size_t) + //need to mask off the bits at the end + pop_t a_final = 0; + memcpy(&a_final, a2, modulo); + result += __builtin_popcountll(a_final); + } + } +#else // NO NEON and NOT GNUC + HammingLUT lut; + result = lut(reinterpret_cast (a), b, size); +#endif + return result; + } +}; + +template +struct Hamming2 +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef T ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** This is popcount_3() from: + * http://en.wikipedia.org/wiki/Hamming_weight */ + unsigned int popcnt32(uint32_t n) const + { + n -= ((n >> 1) & 0x55555555); + n = (n & 0x33333333) + ((n >> 2) & 0x33333333); + return (((n + (n >> 4))& 0xF0F0F0F)* 0x1010101) >> 24; + } + +#ifdef FLANN_PLATFORM_64_BIT + unsigned int popcnt64(uint64_t n) const + { + n -= ((n >> 1) & 0x5555555555555555); + n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333); + return (((n + (n >> 4))& 0x0f0f0f0f0f0f0f0f)* 0x0101010101010101) >> 56; + } +#endif + + template + ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + const uint64_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa ^ *pb); + ++pa; + ++pb; + } +#else + const uint32_t* pa = reinterpret_cast(a); + const uint32_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa ^ *pb); + ++pa; + ++pb; + } +#endif + return result; + } + + + template + ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + + (void)b; +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa); + ++pa; + } +#else + const uint32_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa); + ++pa; + } +#endif + return result; + } + +private: +#ifdef FLANN_PLATFORM_64_BIT + static const size_t long_word_size_ = sizeof(uint64_t)/sizeof(unsigned char); +#else + static const size_t long_word_size_ = sizeof(uint32_t)/sizeof(unsigned char); +#endif +}; + + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +struct DNAmmingLUT +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef unsigned char ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** this will count the bits in a ^ b + */ + template + ResultType operator()(const unsigned char* a, const Iterator2 b, size_t size) const + { + static const uchar popCountTable[] = + { + 0, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4 + }; + ResultType result = 0; + const unsigned char* b2 = reinterpret_cast (b); + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i] ^ b2[i]]; + } + return result; + } + + + ResultType operator()(const unsigned char* a, const ZeroIterator b, size_t size) const + { + (void)b; + static const uchar popCountTable[] = + { + 0, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, + 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 3, 3, 4, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4 + }; + ResultType result = 0; + for (size_t i = 0; i < size; i++) { + result += popCountTable[a[i]]; + } + return result; + } +}; + + +template +struct DNAmming2 +{ + typedef False is_kdtree_distance; + typedef False is_vector_space_distance; + + typedef T ElementType; + typedef int ResultType; + typedef ElementType CentersType; + + /** This is popcount_3() from: + * http://en.wikipedia.org/wiki/Hamming_weight */ + unsigned int popcnt32(uint32_t n) const + { + n = ((n >> 1) | n) & 0x55555555; + n = (n & 0x33333333) + ((n >> 2) & 0x33333333); + return (((n + (n >> 4))& 0x0F0F0F0F)* 0x01010101) >> 24; + } + +#ifdef FLANN_PLATFORM_64_BIT + unsigned int popcnt64(uint64_t n) const + { + n = ((n >> 1) | n) & 0x5555555555555555; + n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333); + return (((n + (n >> 4))& 0x0f0f0f0f0f0f0f0f)* 0x0101010101010101) >> 56; + } +#endif + + template + ResultType operator()(const Iterator1 a, const Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + const uint64_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa ^ *pb); + ++pa; + ++pb; + } +#else + const uint32_t* pa = reinterpret_cast(a); + const uint32_t* pb = reinterpret_cast(b); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa ^ *pb); + ++pa; + ++pb; + } +#endif + return result; + } + + + template + ResultType operator()(const Iterator1 a, ZeroIterator b, size_t size, ResultType /*worst_dist*/ = -1) const + { + CV_DbgAssert(!(size % long_word_size_) && "vectors size must be multiple of long words size (i.e. 8)"); + + (void)b; +#ifdef FLANN_PLATFORM_64_BIT + const uint64_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt64(*pa); + ++pa; + } +#else + const uint32_t* pa = reinterpret_cast(a); + ResultType result = 0; + size /= long_word_size_; + for(size_t i = 0; i < size; ++i ) { + result += popcnt32(*pa); + ++pa; + } +#endif + return result; + } + +private: +#ifdef FLANN_PLATFORM_64_BIT + static const size_t long_word_size_= sizeof(uint64_t)/sizeof(unsigned char); +#else + static const size_t long_word_size_= sizeof(uint32_t)/sizeof(unsigned char); +#endif +}; + + + +template +struct HistIntersectionDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the histogram intersection distance + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType min0, min1, min2, min3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + min0 = (ResultType)(a[0] < b[0] ? a[0] : b[0]); + min1 = (ResultType)(a[1] < b[1] ? a[1] : b[1]); + min2 = (ResultType)(a[2] < b[2] ? a[2] : b[2]); + min3 = (ResultType)(a[3] < b[3] ? a[3] : b[3]); + result += min0 + min1 + min2 + min3; + a += 4; + b += 4; + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + /* Process last 0-3 pixels. Not needed for standard vector lengths. */ + while (a < last) { + min0 = (ResultType)(*a < *b ? *a : *b); + result += min0; + ++a; + ++b; + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + return a +struct HellingerDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the Hellinger distance + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const + { + ResultType result = ResultType(); + ResultType diff0, diff1, diff2, diff3; + Iterator1 last = a + size; + Iterator1 lastgroup = last - 3; + + /* Process 4 items with each loop for efficiency. */ + while (a < lastgroup) { + diff0 = sqrt(static_cast(a[0])) - sqrt(static_cast(b[0])); + diff1 = sqrt(static_cast(a[1])) - sqrt(static_cast(b[1])); + diff2 = sqrt(static_cast(a[2])) - sqrt(static_cast(b[2])); + diff3 = sqrt(static_cast(a[3])) - sqrt(static_cast(b[3])); + result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3; + a += 4; + b += 4; + } + while (a < last) { + diff0 = sqrt(static_cast(*a++)) - sqrt(static_cast(*b++)); + result += diff0 * diff0; + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + ResultType diff = sqrt(static_cast(a)) - sqrt(static_cast(b)); + return diff * diff; + } +}; + + +template +struct ChiSquareDistance +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the chi-square distance + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + ResultType sum, diff; + Iterator1 last = a + size; + + while (a < last) { + sum = (ResultType)(*a + *b); + if (sum>0) { + diff = (ResultType)(*a - *b); + result += diff*diff/sum; + } + ++a; + ++b; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + ResultType result = ResultType(); + ResultType sum, diff; + + sum = (ResultType)(a+b); + if (sum>0) { + diff = (ResultType)(a-b); + result = diff*diff/sum; + } + return result; + } +}; + + +template +struct KL_Divergence +{ + typedef True is_kdtree_distance; + typedef True is_vector_space_distance; + + typedef T ElementType; + typedef typename Accumulator::Type ResultType; + typedef ResultType CentersType; + + /** + * Compute the Kullback-Leibler divergence + */ + template + ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const + { + ResultType result = ResultType(); + Iterator1 last = a + size; + + while (a < last) { + if ( *a != 0 && *b != 0 ) { + ResultType ratio = (ResultType)(*a / *b); + if (ratio>0) { + result += *a * log(ratio); + } + } + ++a; + ++b; + + if ((worst_dist>0)&&(result>worst_dist)) { + return result; + } + } + return result; + } + + /** + * Partial distance, used by the kd-tree. + */ + template + inline ResultType accum_dist(const U& a, const V& b, int) const + { + ResultType result = ResultType(); + if( a != 0 && b != 0 ) { + ResultType ratio = (ResultType)(a / b); + if (ratio>0) { + result = a * log(ratio); + } + } + return result; + } +}; + + +/* + * Depending on processed distances, some of them are already squared (e.g. L2) + * and some are not (e.g.Hamming). In KMeans++ for instance we want to be sure + * we are working on ^2 distances, thus following templates to ensure that. + */ +template +struct squareDistance +{ + typedef typename Distance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist*dist; } +}; + + +template +struct squareDistance, ElementType> +{ + typedef typename L2_Simple::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + +template +struct squareDistance, ElementType> +{ + typedef typename L2::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + + +template +struct squareDistance, ElementType> +{ + typedef typename MinkowskiDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + +template +struct squareDistance, ElementType> +{ + typedef typename HellingerDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + +template +struct squareDistance, ElementType> +{ + typedef typename ChiSquareDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + + +template +typename Distance::ResultType ensureSquareDistance( typename Distance::ResultType dist ) +{ + typedef typename Distance::ElementType ElementType; + + squareDistance dummy; + return dummy( dist ); +} + + +/* + * ...a template to tell the user if the distance he is working with is actually squared + */ + +template +struct isSquareDist +{ + bool operator()() { return false; } +}; + + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + +template +struct isSquareDist, ElementType> +{ + bool operator()() { return true; } +}; + + +template +bool isSquareDistance() +{ + typedef typename Distance::ElementType ElementType; + + isSquareDist dummy; + return dummy(); +} + +/* + * ...and a template to ensure the user that he will process the normal distance, + * and not squared distance, without losing processing time calling sqrt(ensureSquareDistance) + * that will result in doing actually sqrt(dist*dist) for L1 distance for instance. + */ +template +struct simpleDistance +{ + typedef typename Distance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return dist; } +}; + + +template +struct simpleDistance, ElementType> +{ + typedef typename L2_Simple::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + +template +struct simpleDistance, ElementType> +{ + typedef typename L2::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + + +template +struct simpleDistance, ElementType> +{ + typedef typename MinkowskiDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + +template +struct simpleDistance, ElementType> +{ + typedef typename HellingerDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + +template +struct simpleDistance, ElementType> +{ + typedef typename ChiSquareDistance::ResultType ResultType; + ResultType operator()( ResultType dist ) { return sqrt(dist); } +}; + + +template +typename Distance::ResultType ensureSimpleDistance( typename Distance::ResultType dist ) +{ + typedef typename Distance::ElementType ElementType; + + simpleDistance dummy; + return dummy( dist ); +} + +} + +//! @endcond + +#endif //OPENCV_FLANN_DIST_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dummy.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dummy.h new file mode 100644 index 0000000..c176f2e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dummy.h @@ -0,0 +1,16 @@ + +#ifndef OPENCV_FLANN_DUMMY_H_ +#define OPENCV_FLANN_DUMMY_H_ + +//! @cond IGNORED + +namespace cvflann +{ + +CV_DEPRECATED inline void dummyfunc() {} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_DUMMY_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dynamic_bitset.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dynamic_bitset.h new file mode 100644 index 0000000..a00ce1b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/dynamic_bitset.h @@ -0,0 +1,163 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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. + *************************************************************************/ + +/*********************************************************************** + * Author: Vincent Rabaud + *************************************************************************/ + +#ifndef OPENCV_FLANN_DYNAMIC_BITSET_H_ +#define OPENCV_FLANN_DYNAMIC_BITSET_H_ + +//! @cond IGNORED + +#ifndef FLANN_USE_BOOST +# define FLANN_USE_BOOST 0 +#endif +//#define FLANN_USE_BOOST 1 +#if FLANN_USE_BOOST +#include +typedef boost::dynamic_bitset<> DynamicBitset; +#else + +#include + +#include "dist.h" + +namespace cvflann { + +/** Class re-implementing the boost version of it + * This helps not depending on boost, it also does not do the bound checks + * and has a way to reset a block for speed + */ +class DynamicBitset +{ +public: + /** default constructor + */ + DynamicBitset() : size_(0) + { + } + + /** only constructor we use in our code + * @param sz the size of the bitset (in bits) + */ + DynamicBitset(size_t sz) + { + resize(sz); + reset(); + } + + /** Sets all the bits to 0 + */ + void clear() + { + std::fill(bitset_.begin(), bitset_.end(), 0); + } + + /** @brief checks if the bitset is empty + * @return true if the bitset is empty + */ + bool empty() const + { + return bitset_.empty(); + } + + /** set all the bits to 0 + */ + void reset() + { + std::fill(bitset_.begin(), bitset_.end(), 0); + } + + /** @brief set one bit to 0 + * @param index + */ + void reset(size_t index) + { + bitset_[index / cell_bit_size_] &= ~(size_t(1) << (index % cell_bit_size_)); + } + + /** @brief sets a specific bit to 0, and more bits too + * This function is useful when resetting a given set of bits so that the + * whole bitset ends up being 0: if that's the case, we don't care about setting + * other bits to 0 + * @param index + */ + void reset_block(size_t index) + { + bitset_[index / cell_bit_size_] = 0; + } + + /** resize the bitset so that it contains at least sz bits + * @param sz + */ + void resize(size_t sz) + { + size_ = sz; + bitset_.resize(sz / cell_bit_size_ + 1); + } + + /** set a bit to true + * @param index the index of the bit to set to 1 + */ + void set(size_t index) + { + bitset_[index / cell_bit_size_] |= size_t(1) << (index % cell_bit_size_); + } + + /** gives the number of contained bits + */ + size_t size() const + { + return size_; + } + + /** check if a bit is set + * @param index the index of the bit to check + * @return true if the bit is set + */ + bool test(size_t index) const + { + return (bitset_[index / cell_bit_size_] & (size_t(1) << (index % cell_bit_size_))) != 0; + } + +private: + std::vector bitset_; + size_t size_; + static const unsigned int cell_bit_size_ = CHAR_BIT * sizeof(size_t); +}; + +} // namespace cvflann + +#endif + +//! @endcond + +#endif // OPENCV_FLANN_DYNAMIC_BITSET_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/flann.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/flann.hpp new file mode 100644 index 0000000..227683f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/flann.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/flann.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/flann_base.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/flann_base.hpp new file mode 100644 index 0000000..258ec38 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/flann_base.hpp @@ -0,0 +1,299 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_BASE_HPP_ +#define OPENCV_FLANN_BASE_HPP_ + +//! @cond IGNORED + +#include +#include + +#include "general.h" +#include "matrix.h" +#include "params.h" +#include "saving.h" + +#include "all_indices.h" + +namespace cvflann +{ + +/** + * Sets the log level used for all flann functions + * @param level Verbosity level + */ +inline void log_verbosity(int level) +{ + if (level >= 0) { + Logger::setLevel(level); + } +} + +/** + * (Deprecated) Index parameters for creating a saved index. + */ +struct SavedIndexParams : public IndexParams +{ + SavedIndexParams(cv::String filename) + { + (* this)["algorithm"] = FLANN_INDEX_SAVED; + (*this)["filename"] = filename; + } +}; + + +template +NNIndex* load_saved_index(const Matrix& dataset, const cv::String& filename, Distance distance) +{ + typedef typename Distance::ElementType ElementType; + + FILE* fin = fopen(filename.c_str(), "rb"); + if (fin == NULL) { + return NULL; + } + IndexHeader header = load_header(fin); + if (header.data_type != Datatype::type()) { + fclose(fin); + FLANN_THROW(cv::Error::StsError, "Datatype of saved index is different than of the one to be created."); + } + if ((size_t(header.rows) != dataset.rows)||(size_t(header.cols) != dataset.cols)) { + fclose(fin); + FLANN_THROW(cv::Error::StsError, "The index saved belongs to a different dataset"); + } + + IndexParams params; + params["algorithm"] = header.index_type; + NNIndex* nnIndex = create_index_by_type(dataset, params, distance); + nnIndex->loadIndex(fin); + fclose(fin); + + return nnIndex; +} + + +template +class Index : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + Index(const Matrix& features, const IndexParams& params, Distance distance = Distance() ) + : index_params_(params) + { + flann_algorithm_t index_type = get_param(params,"algorithm"); + loaded_ = false; + + if (index_type == FLANN_INDEX_SAVED) { + nnIndex_ = load_saved_index(features, get_param(params,"filename"), distance); + loaded_ = true; + } + else { + nnIndex_ = create_index_by_type(features, params, distance); + } + } + + ~Index() + { + delete nnIndex_; + } + + /** + * Builds the index. + */ + void buildIndex() CV_OVERRIDE + { + if (!loaded_) { + nnIndex_->buildIndex(); + } + } + + void save(cv::String filename) + { + FILE* fout = fopen(filename.c_str(), "wb"); + if (fout == NULL) { + FLANN_THROW(cv::Error::StsError, "Cannot open file"); + } + save_header(fout, *nnIndex_); + saveIndex(fout); + fclose(fout); + } + + /** + * \brief Saves the index to a stream + * \param stream The stream to save the index to + */ + virtual void saveIndex(FILE* stream) CV_OVERRIDE + { + nnIndex_->saveIndex(stream); + } + + /** + * \brief Loads the index from a stream + * \param stream The stream from which the index is loaded + */ + virtual void loadIndex(FILE* stream) CV_OVERRIDE + { + nnIndex_->loadIndex(stream); + } + + /** + * \returns number of features in this index. + */ + size_t veclen() const CV_OVERRIDE + { + return nnIndex_->veclen(); + } + + /** + * \returns The dimensionality of the features in this index. + */ + size_t size() const CV_OVERRIDE + { + return nnIndex_->size(); + } + + /** + * \returns The index type (kdtree, kmeans,...) + */ + flann_algorithm_t getType() const CV_OVERRIDE + { + return nnIndex_->getType(); + } + + /** + * \returns The amount of memory (in bytes) used by the index. + */ + virtual int usedMemory() const CV_OVERRIDE + { + return nnIndex_->usedMemory(); + } + + + /** + * \returns The index parameters + */ + IndexParams getParameters() const CV_OVERRIDE + { + return nnIndex_->getParameters(); + } + + /** + * \brief Perform k-nearest neighbor search + * \param[in] queries The query points for which to find the nearest neighbors + * \param[out] indices The indices of the nearest neighbors found + * \param[out] dists Distances to the nearest neighbors found + * \param[in] knn Number of nearest neighbors to return + * \param[in] params Search parameters + */ + void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE + { + nnIndex_->knnSearch(queries, indices, dists, knn, params); + } + + /** + * \brief Perform radius search + * \param[in] query The query point + * \param[out] indices The indinces of the neighbors found within the given radius + * \param[out] dists The distances to the nearest neighbors found + * \param[in] radius The radius used for search + * \param[in] params Search parameters + * \returns Number of neighbors found + */ + int radiusSearch(const Matrix& query, Matrix& indices, Matrix& dists, float radius, const SearchParams& params) CV_OVERRIDE + { + return nnIndex_->radiusSearch(query, indices, dists, radius, params); + } + + /** + * \brief Method that searches for nearest-neighbours + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + nnIndex_->findNeighbors(result, vec, searchParams); + } + + /** + * \brief Returns actual index + */ + CV_DEPRECATED NNIndex* getIndex() + { + return nnIndex_; + } + + /** + * \brief Returns index parameters. + * \deprecated use getParameters() instead. + */ + CV_DEPRECATED const IndexParams* getIndexParameters() + { + return &index_params_; + } + +private: + /** Pointer to actual index class */ + NNIndex* nnIndex_; + /** Indices if the index was loaded from a file */ + bool loaded_; + /** Parameters passed to the index */ + IndexParams index_params_; + + Index(const Index &); // copy disabled + Index& operator=(const Index &); // assign disabled +}; + +/** + * Performs a hierarchical clustering of the points passed as argument and then takes a cut in the + * the clustering tree to return a flat clustering. + * @param[in] points Points to be clustered + * @param centers The computed cluster centres. Matrix should be preallocated and centers.rows is the + * number of clusters requested. + * @param params Clustering parameters (The same as for cvflann::KMeansIndex) + * @param d Distance to be used for clustering (eg: cvflann::L2) + * @return number of clusters computed (can be different than clusters.rows and is the highest number + * of the form (branching-1)*K+1 smaller than clusters.rows). + */ +template +int hierarchicalClustering(const Matrix& points, Matrix& centers, + const KMeansIndexParams& params, Distance d = Distance()) +{ + KMeansIndex kmeans(points, params, d); + kmeans.buildIndex(); + + int clusterNum = kmeans.getClusterCenters(centers); + return clusterNum; +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_BASE_HPP_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/general.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/general.h new file mode 100644 index 0000000..29fa8be --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/general.h @@ -0,0 +1,63 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_GENERAL_H_ +#define OPENCV_FLANN_GENERAL_H_ + +#if CV_VERSION_MAJOR <= 4 + +//! @cond IGNORED + +#include "opencv2/core.hpp" + +namespace cvflann +{ + +class FLANNException : public cv::Exception +{ +public: + FLANNException(const char* message) : cv::Exception(0, message, "", __FILE__, __LINE__) { } + + FLANNException(const cv::String& message) : cv::Exception(0, message, "", __FILE__, __LINE__) { } +}; + +} + +#define FLANN_THROW(TYPE, STR) throw FLANNException(STR) + +#else + +#define FLANN_THROW(TYPE, STR) CV_Error(TYPE, STR) + +#endif + +//! @endcond + +#endif /* OPENCV_FLANN_GENERAL_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/ground_truth.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/ground_truth.h new file mode 100644 index 0000000..17f2a8e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/ground_truth.h @@ -0,0 +1,98 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_GROUND_TRUTH_H_ +#define OPENCV_FLANN_GROUND_TRUTH_H_ + +//! @cond IGNORED + +#include "dist.h" +#include "matrix.h" + + +namespace cvflann +{ + +template +void find_nearest(const Matrix& dataset, typename Distance::ElementType* query, int* matches, int nn, + int skip = 0, Distance distance = Distance()) +{ + typedef typename Distance::ResultType DistanceType; + int n = nn + skip; + + std::vector match(n); + std::vector dists(n); + + dists[0] = distance(dataset[0], query, dataset.cols); + match[0] = 0; + int dcnt = 1; + + for (size_t i=1; i=1 && dists[j] +void compute_ground_truth(const Matrix& dataset, const Matrix& testset, Matrix& matches, + int skip=0, Distance d = Distance()) +{ + for (size_t i=0; i(dataset, testset[i], matches[i], (int)matches.cols, skip, d); + } +} + + +} + +//! @endcond + +#endif //OPENCV_FLANN_GROUND_TRUTH_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/hdf5.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/hdf5.h new file mode 100644 index 0000000..7554384 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/hdf5.h @@ -0,0 +1,235 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_HDF5_H_ +#define OPENCV_FLANN_HDF5_H_ + +//! @cond IGNORED + +#include + +#include "matrix.h" + + +namespace cvflann +{ + +namespace +{ + +template +hid_t get_hdf5_type() +{ + throw FLANNException("Unsupported type for IO operations"); +} + +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_CHAR; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_UCHAR; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_SHORT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_USHORT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_INT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_UINT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_LONG; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_ULONG; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_FLOAT; } +template<> +hid_t get_hdf5_type() { return H5T_NATIVE_DOUBLE; } +} + + +#define CHECK_ERROR(x,y) if ((x)<0) throw FLANNException((y)); + +template +void save_to_file(const cvflann::Matrix& dataset, const String& filename, const String& name) +{ + +#if H5Eset_auto_vers == 2 + H5Eset_auto( H5E_DEFAULT, NULL, NULL ); +#else + H5Eset_auto( NULL, NULL ); +#endif + + herr_t status; + hid_t file_id; + file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); + if (file_id < 0) { + file_id = H5Fcreate(filename.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT); + } + CHECK_ERROR(file_id,"Error creating hdf5 file."); + + hsize_t dimsf[2]; // dataset dimensions + dimsf[0] = dataset.rows; + dimsf[1] = dataset.cols; + + hid_t space_id = H5Screate_simple(2, dimsf, NULL); + hid_t memspace_id = H5Screate_simple(2, dimsf, NULL); + + hid_t dataset_id; +#if H5Dcreate_vers == 2 + dataset_id = H5Dcreate2(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); +#else + dataset_id = H5Dcreate(file_id, name.c_str(), get_hdf5_type(), space_id, H5P_DEFAULT); +#endif + + if (dataset_id<0) { +#if H5Dopen_vers == 2 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif + } + CHECK_ERROR(dataset_id,"Error creating or opening dataset in file."); + + status = H5Dwrite(dataset_id, get_hdf5_type(), memspace_id, space_id, H5P_DEFAULT, dataset.data ); + CHECK_ERROR(status, "Error writing to dataset"); + + H5Sclose(memspace_id); + H5Sclose(space_id); + H5Dclose(dataset_id); + H5Fclose(file_id); + +} + + +template +void load_from_file(cvflann::Matrix& dataset, const String& filename, const String& name) +{ + herr_t status; + hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT); + CHECK_ERROR(file_id,"Error opening hdf5 file."); + + hid_t dataset_id; +#if H5Dopen_vers == 2 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif + CHECK_ERROR(dataset_id,"Error opening dataset in file."); + + hid_t space_id = H5Dget_space(dataset_id); + + hsize_t dims_out[2]; + H5Sget_simple_extent_dims(space_id, dims_out, NULL); + + dataset = cvflann::Matrix(new T[dims_out[0]*dims_out[1]], dims_out[0], dims_out[1]); + + status = H5Dread(dataset_id, get_hdf5_type(), H5S_ALL, H5S_ALL, H5P_DEFAULT, dataset[0]); + CHECK_ERROR(status, "Error reading dataset"); + + H5Sclose(space_id); + H5Dclose(dataset_id); + H5Fclose(file_id); +} + + +#ifdef HAVE_MPI + +namespace mpi +{ +/** + * Loads a the hyperslice corresponding to this processor from a hdf5 file. + * @param flann_dataset Dataset where the data is loaded + * @param filename HDF5 file name + * @param name Name of dataset inside file + */ +template +void load_from_file(cvflann::Matrix& dataset, const String& filename, const String& name) +{ + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + int mpi_size, mpi_rank; + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + herr_t status; + + hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(plist_id, comm, info); + hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, plist_id); + CHECK_ERROR(file_id,"Error opening hdf5 file."); + H5Pclose(plist_id); + hid_t dataset_id; +#if H5Dopen_vers == 2 + dataset_id = H5Dopen2(file_id, name.c_str(), H5P_DEFAULT); +#else + dataset_id = H5Dopen(file_id, name.c_str()); +#endif + CHECK_ERROR(dataset_id,"Error opening dataset in file."); + + hid_t space_id = H5Dget_space(dataset_id); + hsize_t dims[2]; + H5Sget_simple_extent_dims(space_id, dims, NULL); + + hsize_t count[2]; + hsize_t offset[2]; + + hsize_t item_cnt = dims[0]/mpi_size+(dims[0]%mpi_size==0 ? 0 : 1); + hsize_t cnt = (mpi_rank(), memspace_id, space_id, plist_id, dataset.data); + CHECK_ERROR(status, "Error reading dataset"); + + H5Pclose(plist_id); + H5Sclose(space_id); + H5Sclose(memspace_id); + H5Dclose(dataset_id); + H5Fclose(file_id); +} +} +#endif // HAVE_MPI +} // namespace cvflann::mpi + +//! @endcond + +#endif /* OPENCV_FLANN_HDF5_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/heap.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/heap.h new file mode 100644 index 0000000..8cace20 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/heap.h @@ -0,0 +1,244 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_HEAP_H_ +#define OPENCV_FLANN_HEAP_H_ + +//! @cond IGNORED + +#include +#include + +#include + +namespace cvflann +{ + +// TODO: Define x > y operator and use std::greater instead +template +struct greater +{ + bool operator()(const T& x, const T& y) const + { + return y < x; + } +}; + +/** + * Priority Queue Implementation + * + * The priority queue is implemented with a heap. A heap is a complete + * (full) binary tree in which each parent is less than both of its + * children, but the order of the children is unspecified. + */ +template +class Heap +{ + /** + * Storage array for the heap. + * Type T must be comparable. + */ + std::vector heap; +public: + /** + * \brief Constructs a heap with a pre-allocated capacity + * + * \param capacity heap maximum capacity + */ + Heap(const int capacity) + { + reserve(capacity); + } + + /** + * \brief Move-constructs a heap from an external vector + * + * \param vec external vector + */ + Heap(std::vector&& vec) + : heap(std::move(vec)) + { + std::make_heap(heap.begin(), heap.end(), greater()); + } + + /** + * + * \returns heap size + */ + int size() const + { + return (int)heap.size(); + } + + /** + * + * \returns heap capacity + */ + int capacity() const + { + return (int)heap.capacity(); + } + + /** + * \brief Tests if the heap is empty + * + * \returns true is heap empty, false otherwise + */ + bool empty() + { + return heap.empty(); + } + + /** + * \brief Clears the heap. + */ + void clear() + { + heap.clear(); + } + + /** + * \brief Sets the heap maximum capacity. + * + * \param capacity heap maximum capacity + */ + void reserve(const int capacity) + { + heap.reserve(capacity); + } + + /** + * \brief Inserts a new element in the heap. + * + * We select the next empty leaf node, and then keep moving any larger + * parents down until the right location is found to store this element. + * + * \param value the new element to be inserted in the heap + */ + void insert(T value) + { + /* If heap is full, then return without adding this element. */ + if (size() == capacity()) { + return; + } + + heap.push_back(value); + std::push_heap(heap.begin(), heap.end(), greater()); + } + + /** + * \brief Returns the node of minimum value from the heap (top of the heap). + * + * \param[out] value parameter used to return the min element + * \returns false if heap empty + */ + bool popMin(T& value) + { + if (empty()) { + return false; + } + + value = heap[0]; + std::pop_heap(heap.begin(), heap.end(), greater()); + heap.pop_back(); + + return true; /* Return old last node. */ + } + + /** + * \brief Returns a shared heap for the given memory pool ID. + * + * It constructs the heap if it does not already exists. + * + * \param poolId a user-chosen hashable ID for identifying the heap. + * For thread-safe operations, using current thread ID is a good choice. + * \param capacity heap maximum capacity + * \param iterThreshold remove heaps that were not reused for more than specified iterations count + * if iterThreshold value is less 2, it will be internally adjusted to twice the number of CPU threads + * \returns pointer to the heap + */ + template + static cv::Ptr> getPooledInstance( + const HashableT& poolId, const int capacity, int iterThreshold = 0) + { + static cv::Mutex mutex; + const cv::AutoLock lock(mutex); + + struct HeapMapValueType { + cv::Ptr> heapPtr; + int iterCounter; + }; + typedef std::unordered_map HeapMapType; + + static HeapMapType heapsPool; + typename HeapMapType::iterator heapIt = heapsPool.find(poolId); + + if (heapIt == heapsPool.end()) + { + // Construct the heap as it does not already exists + HeapMapValueType heapAndTimePair = {cv::makePtr>(capacity), 0}; + const std::pair& emplaceResult = heapsPool.emplace(poolId, std::move(heapAndTimePair)); + CV_CheckEQ(static_cast(emplaceResult.second), 1, "Failed to insert the heap into its memory pool"); + heapIt = emplaceResult.first; + } + else + { + CV_CheckEQ(heapIt->second.heapPtr.use_count(), 1, "Cannot modify a heap that is currently accessed by another caller"); + heapIt->second.heapPtr->clear(); + heapIt->second.heapPtr->reserve(capacity); + heapIt->second.iterCounter = 0; + } + + if (iterThreshold <= 1) { + iterThreshold = 2 * cv::getNumThreads(); + } + + // Remove heaps that were not reused for more than given iterThreshold + typename HeapMapType::iterator cleanupIt = heapsPool.begin(); + while (cleanupIt != heapsPool.end()) + { + if (cleanupIt->second.iterCounter++ > iterThreshold) + { + CV_Assert(cleanupIt != heapIt); + cleanupIt = heapsPool.erase(cleanupIt); + continue; + } + ++cleanupIt; + } + + return heapIt->second.heapPtr; + } +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_HEAP_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/hierarchical_clustering_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/hierarchical_clustering_index.h new file mode 100644 index 0000000..60662e7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/hierarchical_clustering_index.h @@ -0,0 +1,846 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ +#define OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include +#include + +#include "general.h" +#include "nn_index.h" +#include "dist.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + + +namespace cvflann +{ + +struct HierarchicalClusteringIndexParams : public IndexParams +{ + HierarchicalClusteringIndexParams(int branching = 32, + flann_centers_init_t centers_init = FLANN_CENTERS_RANDOM, + int trees = 4, int leaf_size = 100) + { + (*this)["algorithm"] = FLANN_INDEX_HIERARCHICAL; + // The branching factor used in the hierarchical clustering + (*this)["branching"] = branching; + // Algorithm used for picking the initial cluster centers + (*this)["centers_init"] = centers_init; + // number of parallel trees to build + (*this)["trees"] = trees; + // maximum leaf size + (*this)["leaf_size"] = leaf_size; + } +}; + + +/** + * Hierarchical index + * + * Contains a tree constructed through a hierarchical clustering + * and other information for indexing a set of points for nearest-neighbour matching. + */ +template +class HierarchicalClusteringIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + +private: + + + typedef void (HierarchicalClusteringIndex::* centersAlgFunction)(int, int*, int, int*, int&); + + /** + * The function used for choosing the cluster centers. + */ + centersAlgFunction chooseCenters; + + + + /** + * Chooses the initial centers in the k-means clustering in a random manner. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * indices_length = length of indices vector + * + */ + void chooseCentersRandom(int k, int* dsindices, int indices_length, int* centers, int& centers_length) + { + UniqueRandom r(indices_length); + + int index; + for (index=0; index=0 && rnd < n); + + centers[0] = dsindices[rnd]; + + int index; + for (index=1; indexbest_val) { + best_val = dist; + best_index = j; + } + } + if (best_index!=-1) { + centers[index] = dsindices[best_index]; + } + else { + break; + } + } + centers_length = index; + } + + + /** + * Chooses the initial centers in the k-means using the algorithm + * proposed in the KMeans++ paper: + * Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding + * + * Implementation of this function was converted from the one provided in Arthur's code. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * Returns: + */ + void chooseCentersKMeanspp(int k, int* dsindices, int indices_length, int* centers, int& centers_length) + { + int n = indices_length; + + double currentPot = 0; + DistanceType* closestDistSq = new DistanceType[n]; + + // Choose one random center and set the closestDistSq values + int index = rand_int(n); + CV_DbgAssert(index >=0 && index < n); + centers[0] = dsindices[index]; + + // Computing distance^2 will have the advantage of even higher probability further to pick new centers + // far from previous centers (and this complies to "k-means++: the advantages of careful seeding" article) + for (int i = 0; i < n; i++) { + closestDistSq[i] = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols); + closestDistSq[i] = ensureSquareDistance( closestDistSq[i] ); + currentPot += closestDistSq[i]; + } + + + const int numLocalTries = 1; + + // Choose each center + int centerCount; + for (centerCount = 1; centerCount < k; centerCount++) { + + // Repeat several trials + double bestNewPot = -1; + int bestNewIndex = 0; + for (int localTrial = 0; localTrial < numLocalTries; localTrial++) { + + // Choose our center - have to be slightly careful to return a valid answer even accounting + // for possible rounding errors + double randVal = rand_double(currentPot); + for (index = 0; index < n-1; index++) { + if (randVal <= closestDistSq[index]) break; + else randVal -= closestDistSq[index]; + } + + // Compute the new potential + double newPot = 0; + for (int i = 0; i < n; i++) { + DistanceType dist = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols); + newPot += std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + + // Store the best result + if ((bestNewPot < 0)||(newPot < bestNewPot)) { + bestNewPot = newPot; + bestNewIndex = index; + } + } + + // Add the appropriate center + centers[centerCount] = dsindices[bestNewIndex]; + currentPot = bestNewPot; + for (int i = 0; i < n; i++) { + DistanceType dist = distance(dataset[dsindices[i]], dataset[dsindices[bestNewIndex]], dataset.cols); + closestDistSq[i] = std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + } + + centers_length = centerCount; + + delete[] closestDistSq; + } + + + /** + * Chooses the initial centers in a way inspired by Gonzales (by Pierre-Emmanuel Viel): + * select the first point of the list as a candidate, then parse the points list. If another + * point is further than current candidate from the other centers, test if it is a good center + * of a local aggregation. If it is, replace current candidate by this point. And so on... + * + * Used with KMeansIndex that computes centers coordinates by averaging positions of clusters points, + * this doesn't make a real difference with previous methods. But used with HierarchicalClusteringIndex + * class that pick centers among existing points instead of computing the barycenters, there is a real + * improvement. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * Returns: + */ + void GroupWiseCenterChooser(int k, int* dsindices, int indices_length, int* centers, int& centers_length) + { + const float kSpeedUpFactor = 1.3f; + + int n = indices_length; + + DistanceType* closestDistSq = new DistanceType[n]; + + // Choose one random center and set the closestDistSq values + int index = rand_int(n); + CV_DbgAssert(index >=0 && index < n); + centers[0] = dsindices[index]; + + for (int i = 0; i < n; i++) { + closestDistSq[i] = distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols); + } + + + // Choose each center + int centerCount; + for (centerCount = 1; centerCount < k; centerCount++) { + + // Repeat several trials + double bestNewPot = -1; + int bestNewIndex = 0; + DistanceType furthest = 0; + for (index = 0; index < n; index++) { + + // We will test only the potential of the points further than current candidate + if( closestDistSq[index] > kSpeedUpFactor * (float)furthest ) { + + // Compute the new potential + double newPot = 0; + for (int i = 0; i < n; i++) { + newPot += std::min( distance(dataset[dsindices[i]], dataset[dsindices[index]], dataset.cols) + , closestDistSq[i] ); + } + + // Store the best result + if ((bestNewPot < 0)||(newPot <= bestNewPot)) { + bestNewPot = newPot; + bestNewIndex = index; + furthest = closestDistSq[index]; + } + } + } + + // Add the appropriate center + centers[centerCount] = dsindices[bestNewIndex]; + for (int i = 0; i < n; i++) { + closestDistSq[i] = std::min( distance(dataset[dsindices[i]], dataset[dsindices[bestNewIndex]], dataset.cols) + , closestDistSq[i] ); + } + } + + centers_length = centerCount; + + delete[] closestDistSq; + } + + +public: + + + /** + * Index constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the hierarchical k-means algorithm + */ + HierarchicalClusteringIndex(const Matrix& inputData, const IndexParams& index_params = HierarchicalClusteringIndexParams(), + Distance d = Distance()) + : dataset(inputData), params(index_params), root(NULL), indices(NULL), distance(d) + { + memoryCounter = 0; + + size_ = dataset.rows; + veclen_ = dataset.cols; + + branching_ = get_param(params,"branching",32); + centers_init_ = get_param(params,"centers_init", FLANN_CENTERS_RANDOM); + trees_ = get_param(params,"trees",4); + leaf_size_ = get_param(params,"leaf_size",100); + + if (centers_init_==FLANN_CENTERS_RANDOM) { + chooseCenters = &HierarchicalClusteringIndex::chooseCentersRandom; + } + else if (centers_init_==FLANN_CENTERS_GONZALES) { + chooseCenters = &HierarchicalClusteringIndex::chooseCentersGonzales; + } + else if (centers_init_==FLANN_CENTERS_KMEANSPP) { + chooseCenters = &HierarchicalClusteringIndex::chooseCentersKMeanspp; + } + else if (centers_init_==FLANN_CENTERS_GROUPWISE) { + chooseCenters = &HierarchicalClusteringIndex::GroupWiseCenterChooser; + } + else { + FLANN_THROW(cv::Error::StsError, "Unknown algorithm for choosing initial centers."); + } + + root = new NodePtr[trees_]; + indices = new int*[trees_]; + + for (int i=0; i(); + computeClustering(root[i], indices[i], (int)size_, branching_,0); + } + } + + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_HIERARCHICAL; + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, branching_); + save_value(stream, trees_); + save_value(stream, centers_init_); + save_value(stream, leaf_size_); + save_value(stream, memoryCounter); + for (int i=0; i& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + + const int maxChecks = get_param(searchParams,"checks",32); + const bool explore_all_trees = get_param(searchParams,"explore_all_trees",false); + + // Priority queue storing intermediate branches in the best-bin-first search + const cv::Ptr>& heap = Heap::getPooledInstance(cv::utils::getThreadID(), (int)size_); + + std::vector checked(size_,false); + int checks = 0; + for (int i=0; i= maxChecks) && result.full()) + break; + } + + BranchSt branch; + while (heap->popMin(branch) && (checks BranchSt; + + + + void save_tree(FILE* stream, NodePtr node, int num) + { + save_value(stream, *node); + if (node->childs==NULL) { + int indices_offset = (int)(node->indices - indices[num]); + save_value(stream, indices_offset); + } + else { + for(int i=0; ichilds[i], num); + } + } + } + + + void load_tree(FILE* stream, NodePtr& node, int num) + { + node = pool.allocate(); + load_value(stream, *node); + if (node->childs==NULL) { + int indices_offset; + load_value(stream, indices_offset); + node->indices = indices[num] + indices_offset; + } + else { + node->childs = pool.allocate(branching_); + for(int i=0; ichilds[i], num); + } + } + } + + + /** + * Release the inner elements of indices[] + */ + void free_indices() + { + if (indices!=NULL) { + for(int i=0; inew_dist) { + labels[i] = j; + dist = new_dist; + } + } + cost += dist; + } + } + + /** + * The method responsible with actually doing the recursive hierarchical + * clustering + * + * Params: + * node = the node to cluster + * indices = indices of the points belonging to the current node + * branching = the branching factor to use in the clustering + * + * TODO: for 1-sized clusters don't store a cluster center (it's the same as the single cluster point) + */ + void computeClustering(NodePtr node, int* dsindices, int indices_length, int branching, int level) + { + node->size = indices_length; + node->level = level; + + if (indices_length < leaf_size_) { // leaf node + node->indices = dsindices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + std::vector centers(branching); + std::vector labels(indices_length); + + int centers_length; + (this->*chooseCenters)(branching, dsindices, indices_length, ¢ers[0], centers_length); + + if (centers_lengthindices = dsindices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + + // assign points to clusters + DistanceType cost; + computeLabels(dsindices, indices_length, ¢ers[0], centers_length, &labels[0], cost); + + node->childs = pool.allocate(branching); + int start = 0; + int end = start; + for (int i=0; ichilds[i] = pool.allocate(); + node->childs[i]->pivot = centers[i]; + node->childs[i]->indices = NULL; + computeClustering(node->childs[i],dsindices+start, end-start, branching, level+1); + start=end; + } + } + + + + /** + * Performs one descent in the hierarchical k-means tree. The branches not + * visited are stored in a priority queue. + * + * Params: + * node = node to explore + * result = container for the k-nearest neighbors found + * vec = query points + * checks = how many points in the dataset have been checked so far + * maxChecks = maximum dataset points to checks + */ + + + void findNN(NodePtr node, ResultSet& result, const ElementType* vec, int& checks, int maxChecks, + const cv::Ptr>& heap, std::vector& checked, bool explore_all_trees = false) + { + if (node->childs==NULL) { + if (!explore_all_trees && (checks>=maxChecks) && result.full()) { + return; + } + for (int i=0; isize; ++i) { + int index = node->indices[i]; + if (!checked[index]) { + DistanceType dist = distance(dataset[index], vec, veclen_); + result.addPoint(dist, index); + checked[index] = true; + ++checks; + } + } + } + else { + DistanceType* domain_distances = new DistanceType[branching_]; + int best_index = 0; + domain_distances[best_index] = distance(vec, dataset[node->childs[best_index]->pivot], veclen_); + for (int i=1; ichilds[i]->pivot], veclen_); + if (domain_distances[i]insert(BranchSt(node->childs[i],domain_distances[i])); + } + } + delete[] domain_distances; + findNN(node->childs[best_index],result,vec, checks, maxChecks, heap, checked, explore_all_trees); + } + } + +private: + + + /** + * The dataset used by this index + */ + const Matrix dataset; + + /** + * Parameters used by this index + */ + IndexParams params; + + + /** + * Number of features in the dataset. + */ + size_t size_; + + /** + * Length of each feature. + */ + size_t veclen_; + + /** + * The root node in the tree. + */ + NodePtr* root; + + /** + * Array of indices to vectors in the dataset. + */ + int** indices; + + + /** + * The distance + */ + Distance distance; + + /** + * Pooled memory allocator. + * + * Using a pooled memory allocator is more efficient + * than allocating memory directly when there is a large + * number small of memory allocations. + */ + PooledAllocator pool; + + /** + * Memory occupied by the index. + */ + int memoryCounter; + + /** index parameters */ + int branching_; + int trees_; + flann_centers_init_t centers_init_; + int leaf_size_; + + +}; + +} + +//! @endcond + +#endif /* OPENCV_FLANN_HIERARCHICAL_CLUSTERING_INDEX_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/index_testing.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/index_testing.h new file mode 100644 index 0000000..207adef --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/index_testing.h @@ -0,0 +1,321 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_INDEX_TESTING_H_ +#define OPENCV_FLANN_INDEX_TESTING_H_ + +//! @cond IGNORED + +#include +#include + +#include "matrix.h" +#include "nn_index.h" +#include "result_set.h" +#include "logger.h" +#include "timer.h" + + +namespace cvflann +{ + +inline int countCorrectMatches(int* neighbors, int* groundTruth, int n) +{ + int count = 0; + for (int i=0; i +typename Distance::ResultType computeDistanceRaport(const Matrix& inputData, typename Distance::ElementType* target, + int* neighbors, int* groundTruth, int veclen, int n, const Distance& distance) +{ + typedef typename Distance::ResultType DistanceType; + + DistanceType ret = 0; + for (int i=0; i +float search_with_ground_truth(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, int nn, int checks, + float& time, typename Distance::ResultType& dist, const Distance& distance, int skipMatches) +{ + typedef typename Distance::ResultType DistanceType; + + if (matches.cols resultSet(nn+skipMatches); + SearchParams searchParams(checks); + + std::vector indices(nn+skipMatches); + std::vector dists(nn+skipMatches); + int* neighbors = &indices[skipMatches]; + + int correct = 0; + DistanceType distR = 0; + StartStopTimer t; + int repeats = 0; + while (t.value<0.2) { + repeats++; + t.start(); + correct = 0; + distR = 0; + for (size_t i = 0; i < testData.rows; i++) { + resultSet.init(&indices[0], &dists[0]); + index.findNeighbors(resultSet, testData[i], searchParams); + + correct += countCorrectMatches(neighbors,matches[i], nn); + distR += computeDistanceRaport(inputData, testData[i], neighbors, matches[i], (int)testData.cols, nn, distance); + } + t.stop(); + } + time = float(t.value/repeats); + + float precicion = (float)correct/(nn*testData.rows); + + dist = distR/(testData.rows*nn); + + Logger::info("%8d %10.4g %10.5g %10.5g %10.5g\n", + checks, precicion, time, 1000.0 * time / testData.rows, dist); + + return precicion; +} + + +template +float test_index_checks(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, + int checks, float& precision, const Distance& distance, int nn = 1, int skipMatches = 0) +{ + typedef typename Distance::ResultType DistanceType; + + Logger::info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n"); + Logger::info("---------------------------------------------------------\n"); + + float time = 0; + DistanceType dist = 0; + precision = search_with_ground_truth(index, inputData, testData, matches, nn, checks, time, dist, distance, skipMatches); + + return time; +} + +template +float test_index_precision(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, + float precision, int& checks, const Distance& distance, int nn = 1, int skipMatches = 0) +{ + typedef typename Distance::ResultType DistanceType; + const float SEARCH_EPS = 0.001f; + + Logger::info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n"); + Logger::info("---------------------------------------------------------\n"); + + int c2 = 1; + float p2; + int c1 = 1; + //float p1; + float time; + DistanceType dist; + + p2 = search_with_ground_truth(index, inputData, testData, matches, nn, c2, time, dist, distance, skipMatches); + + if (p2>precision) { + Logger::info("Got as close as I can\n"); + checks = c2; + return time; + } + + while (p2SEARCH_EPS) { + Logger::info("Start linear estimation\n"); + // after we got to values in the vecinity of the desired precision + // use linear approximation get a better estimation + + cx = (c1+c2)/2; + realPrecision = search_with_ground_truth(index, inputData, testData, matches, nn, cx, time, dist, distance, skipMatches); + while (fabs(realPrecision-precision)>SEARCH_EPS) { + + if (realPrecision +void test_index_precisions(NNIndex& index, const Matrix& inputData, + const Matrix& testData, const Matrix& matches, + float* precisions, int precisions_length, const Distance& distance, int nn = 1, int skipMatches = 0, float maxTime = 0) +{ + typedef typename Distance::ResultType DistanceType; + + const float SEARCH_EPS = 0.001; + + // make sure precisions array is sorted + std::sort(precisions, precisions+precisions_length); + + int pindex = 0; + float precision = precisions[pindex]; + + Logger::info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n"); + Logger::info("---------------------------------------------------------\n"); + + int c2 = 1; + float p2; + + int c1 = 1; + float p1; + + float time; + DistanceType dist; + + p2 = search_with_ground_truth(index, inputData, testData, matches, nn, c2, time, dist, distance, skipMatches); + + // if precision for 1 run down the tree is already + // better then some of the requested precisions, then + // skip those + while (precisions[pindex] 0)&&(time > maxTime)&&(p2SEARCH_EPS) { + Logger::info("Start linear estimation\n"); + // after we got to values in the vecinity of the desired precision + // use linear approximation get a better estimation + + cx = (c1+c2)/2; + realPrecision = search_with_ground_truth(index, inputData, testData, matches, nn, cx, time, dist, distance, skipMatches); + while (fabs(realPrecision-precision)>SEARCH_EPS) { + + if (realPrecision +#include +#include + +#include "nn_index.h" +#include "dynamic_bitset.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + + +namespace cvflann +{ + +struct KDTreeIndexParams : public IndexParams +{ + KDTreeIndexParams(int trees = 4) + { + (*this)["algorithm"] = FLANN_INDEX_KDTREE; + (*this)["trees"] = trees; + } +}; + + +/** + * Randomized kd-tree index + * + * Contains the k-d trees and other information for indexing a set of points + * for nearest-neighbor matching. + */ +template +class KDTreeIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + + /** + * KDTree constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the kdtree algorithm + */ + KDTreeIndex(const Matrix& inputData, const IndexParams& params = KDTreeIndexParams(), + Distance d = Distance() ) : + dataset_(inputData), index_params_(params), distance_(d) + { + size_ = dataset_.rows; + veclen_ = dataset_.cols; + + trees_ = get_param(index_params_,"trees",4); + tree_roots_ = new NodePtr[trees_]; + + // Create a permutable array of indices to the input vectors. + vind_.resize(size_); + for (size_t i = 0; i < size_; ++i) { + vind_[i] = int(i); + } + + mean_ = new DistanceType[veclen_]; + var_ = new DistanceType[veclen_]; + } + + + KDTreeIndex(const KDTreeIndex&); + KDTreeIndex& operator=(const KDTreeIndex&); + + /** + * Standard destructor + */ + ~KDTreeIndex() + { + if (tree_roots_!=NULL) { + delete[] tree_roots_; + } + delete[] mean_; + delete[] var_; + } + + /** + * Builds the index + */ + void buildIndex() CV_OVERRIDE + { + /* Construct the randomized trees. */ + for (int i = 0; i < trees_; i++) { + /* Randomize the order of vectors to allow for unbiased sampling. */ +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::randShuffle(vind_); +#else + std::random_shuffle(vind_.begin(), vind_.end()); +#endif + + tree_roots_[i] = divideTree(&vind_[0], int(size_) ); + } + } + + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_KDTREE; + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, trees_); + for (int i=0; i& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + const int maxChecks = get_param(searchParams,"checks", 32); + const float epsError = 1+get_param(searchParams,"eps",0.0f); + const bool explore_all_trees = get_param(searchParams,"explore_all_trees",false); + + if (maxChecks==FLANN_CHECKS_UNLIMITED) { + getExactNeighbors(result, vec, epsError); + } + else { + getNeighbors(result, vec, maxChecks, epsError, explore_all_trees); + } + } + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + +private: + + + /*--------------------- Internal Data Structures --------------------------*/ + struct Node + { + /** + * Dimension used for subdivision. + */ + int divfeat; + /** + * The values used for subdivision. + */ + DistanceType divval; + /** + * The child nodes. + */ + Node* child1, * child2; + }; + typedef Node* NodePtr; + typedef BranchStruct BranchSt; + typedef BranchSt* Branch; + + + + void save_tree(FILE* stream, NodePtr tree) + { + save_value(stream, *tree); + if (tree->child1!=NULL) { + save_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + save_tree(stream, tree->child2); + } + } + + + void load_tree(FILE* stream, NodePtr& tree) + { + tree = pool_.allocate(); + load_value(stream, *tree); + if (tree->child1!=NULL) { + load_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + load_tree(stream, tree->child2); + } + } + + + /** + * Create a tree node that subdivides the list of vecs from vind[first] + * to vind[last]. The routine is called recursively on each sublist. + * Place a pointer to this new tree node in the location pTree. + * + * Params: pTree = the new node to create + * first = index of the first vector + * last = index of the last vector + */ + NodePtr divideTree(int* ind, int count) + { + NodePtr node = pool_.allocate(); // allocate memory + + /* If too few exemplars remain, then make this a leaf node. */ + if ( count == 1) { + node->child1 = node->child2 = NULL; /* Mark as leaf node. */ + node->divfeat = *ind; /* Store index of this vec. */ + } + else { + int idx; + int cutfeat; + DistanceType cutval; + meanSplit(ind, count, idx, cutfeat, cutval); + + node->divfeat = cutfeat; + node->divval = cutval; + node->child1 = divideTree(ind, idx); + node->child2 = divideTree(ind+idx, count-idx); + } + + return node; + } + + + /** + * Choose which feature to use in order to subdivide this set of vectors. + * Make a random choice among those with the highest variance, and use + * its variance as the threshold value. + */ + void meanSplit(int* ind, int count, int& index, int& cutfeat, DistanceType& cutval) + { + memset(mean_,0,veclen_*sizeof(DistanceType)); + memset(var_,0,veclen_*sizeof(DistanceType)); + + /* Compute mean values. Only the first SAMPLE_MEAN values need to be + sampled to get a good estimate. + */ + int cnt = std::min((int)SAMPLE_MEAN+1, count); + for (int j = 0; j < cnt; ++j) { + ElementType* v = dataset_[ind[j]]; + for (size_t k=0; kcount/2) index = lim1; + else if (lim2 v[topind[num-1]])) { + /* Put this element at end of topind. */ + if (num < RAND_DIM) { + topind[num++] = i; /* Add to list. */ + } + else { + topind[num-1] = i; /* Replace last element. */ + } + /* Bubble end value down to right location by repeated swapping. */ + int j = num - 1; + while (j > 0 && v[topind[j]] > v[topind[j-1]]) { + std::swap(topind[j], topind[j-1]); + --j; + } + } + } + /* Select a random integer in range [0,num-1], and return that index. */ + int rnd = rand_int(num); + return (int)topind[rnd]; + } + + + /** + * Subdivide the list of points by a plane perpendicular on axe corresponding + * to the 'cutfeat' dimension at 'cutval' position. + * + * On return: + * dataset[ind[0..lim1-1]][cutfeat]cutval + */ + void planeSplit(int* ind, int count, int cutfeat, DistanceType cutval, int& lim1, int& lim2) + { + /* Move vector indices for left subtree to front of list. */ + int left = 0; + int right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]=cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + lim1 = left; + right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]<=cutval) ++left; + while (left<=right && dataset_[ind[right]][cutfeat]>cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + lim2 = left; + } + + /** + * Performs an exact nearest neighbor search. The exact search performs a full + * traversal of the tree. + */ + void getExactNeighbors(ResultSet& result, const ElementType* vec, float epsError) + { + // checkID -= 1; /* Set a different unique ID for each search. */ + + if (trees_ > 1) { + fprintf(stderr,"It doesn't make any sense to use more than one tree for exact search"); + } + if (trees_>0) { + searchLevelExact(result, vec, tree_roots_[0], 0.0, epsError); + } + CV_Assert(result.full()); + } + + /** + * Performs the approximate nearest-neighbor search. The search is approximate + * because the tree traversal is abandoned after a given number of descends in + * the tree. + */ + void getNeighbors(ResultSet& result, const ElementType* vec, + int maxCheck, float epsError, bool explore_all_trees = false) + { + int i; + BranchSt branch; + int checkCount = 0; + DynamicBitset checked(size_); + + // Priority queue storing intermediate branches in the best-bin-first search + const cv::Ptr>& heap = Heap::getPooledInstance(cv::utils::getThreadID(), (int)size_); + + /* Search once through each tree down to root. */ + for (i = 0; i < trees_; ++i) { + searchLevel(result, vec, tree_roots_[i], 0, checkCount, maxCheck, + epsError, heap, checked, explore_all_trees); + if (!explore_all_trees && (checkCount >= maxCheck) && result.full()) + break; + } + + /* Keep searching other branches from heap until finished. */ + while ( heap->popMin(branch) && (checkCount < maxCheck || !result.full() )) { + searchLevel(result, vec, branch.node, branch.mindist, checkCount, maxCheck, + epsError, heap, checked, false); + } + + CV_Assert(result.full()); + } + + + /** + * Search starting from a given node of the tree. Based on any mismatches at + * higher levels, all exemplars below this level must have a distance of + * at least "mindistsq". + */ + void searchLevel(ResultSet& result_set, const ElementType* vec, NodePtr node, DistanceType mindist, int& checkCount, int maxCheck, + float epsError, const cv::Ptr>& heap, DynamicBitset& checked, bool explore_all_trees = false) + { + if (result_set.worstDist()child1 == NULL)&&(node->child2 == NULL)) { + /* Do not check same node more than once when searching multiple trees. + Once a vector is checked, we set its location in vind to the + current checkID. + */ + int index = node->divfeat; + if ( checked.test(index) || + (!explore_all_trees && (checkCount>=maxCheck) && result_set.full()) ) { + return; + } + checked.set(index); + checkCount++; + + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result_set.addPoint(dist,index); + + return; + } + + /* Which child branch should be taken first? */ + ElementType val = vec[node->divfeat]; + DistanceType diff = val - node->divval; + NodePtr bestChild = (diff < 0) ? node->child1 : node->child2; + NodePtr otherChild = (diff < 0) ? node->child2 : node->child1; + + /* Create a branch record for the branch not taken. Add distance + of this feature boundary (we don't attempt to correct for any + use of this feature in a parent node, which is unlikely to + happen and would have only a small effect). Don't bother + adding more branches to heap after halfway point, as cost of + adding exceeds their value. + */ + + DistanceType new_distsq = mindist + distance_.accum_dist(val, node->divval, node->divfeat); + // if (2 * checkCount < maxCheck || !result.full()) { + if ((new_distsq*epsError < result_set.worstDist())|| !result_set.full()) { + heap->insert( BranchSt(otherChild, new_distsq) ); + } + + /* Call recursively to search next level down. */ + searchLevel(result_set, vec, bestChild, mindist, checkCount, maxCheck, epsError, heap, checked); + } + + /** + * Performs an exact search in the tree starting from a node. + */ + void searchLevelExact(ResultSet& result_set, const ElementType* vec, const NodePtr node, DistanceType mindist, const float epsError) + { + /* If this is a leaf node, then do check and return. */ + if ((node->child1 == NULL)&&(node->child2 == NULL)) { + int index = node->divfeat; + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result_set.addPoint(dist,index); + return; + } + + /* Which child branch should be taken first? */ + ElementType val = vec[node->divfeat]; + DistanceType diff = val - node->divval; + NodePtr bestChild = (diff < 0) ? node->child1 : node->child2; + NodePtr otherChild = (diff < 0) ? node->child2 : node->child1; + + /* Create a branch record for the branch not taken. Add distance + of this feature boundary (we don't attempt to correct for any + use of this feature in a parent node, which is unlikely to + happen and would have only a small effect). Don't bother + adding more branches to heap after halfway point, as cost of + adding exceeds their value. + */ + + DistanceType new_distsq = mindist + distance_.accum_dist(val, node->divval, node->divfeat); + + /* Call recursively to search next level down. */ + searchLevelExact(result_set, vec, bestChild, mindist, epsError); + + if (new_distsq*epsError<=result_set.worstDist()) { + searchLevelExact(result_set, vec, otherChild, new_distsq, epsError); + } + } + + +private: + + enum + { + /** + * To improve efficiency, only SAMPLE_MEAN random values are used to + * compute the mean and variance at each level when building a tree. + * A value of 100 seems to perform as well as using all values. + */ + SAMPLE_MEAN = 100, + /** + * Top random dimensions to consider + * + * When creating random trees, the dimension on which to subdivide is + * selected at random from among the top RAND_DIM dimensions with the + * highest variance. A value of 5 works well. + */ + RAND_DIM=5 + }; + + + /** + * Number of randomized trees that are used + */ + int trees_; + + /** + * Array of indices to vectors in the dataset. + */ + std::vector vind_; + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + IndexParams index_params_; + + size_t size_; + size_t veclen_; + + + DistanceType* mean_; + DistanceType* var_; + + + /** + * Array of k-d trees used to find neighbours. + */ + NodePtr* tree_roots_; + + /** + * Pooled memory allocator. + * + * Using a pooled memory allocator is more efficient + * than allocating memory directly when there is a large + * number small of memory allocations. + */ + PooledAllocator pool_; + + Distance distance_; + + +}; // class KDTreeForest + +} + +//! @endcond + +#endif //OPENCV_FLANN_KDTREE_INDEX_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/kdtree_single_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/kdtree_single_index.h new file mode 100644 index 0000000..ed95c3d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/kdtree_single_index.h @@ -0,0 +1,645 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_ +#define OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include + +#include "nn_index.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + +namespace cvflann +{ + +struct KDTreeSingleIndexParams : public IndexParams +{ + KDTreeSingleIndexParams(int leaf_max_size = 10, bool reorder = true, int dim = -1) + { + (*this)["algorithm"] = FLANN_INDEX_KDTREE_SINGLE; + (*this)["leaf_max_size"] = leaf_max_size; + (*this)["reorder"] = reorder; + (*this)["dim"] = dim; + } +}; + + +/** + * Randomized kd-tree index + * + * Contains the k-d trees and other information for indexing a set of points + * for nearest-neighbor matching. + */ +template +class KDTreeSingleIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + + /** + * KDTree constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the kdtree algorithm + */ + KDTreeSingleIndex(const Matrix& inputData, const IndexParams& params = KDTreeSingleIndexParams(), + Distance d = Distance() ) : + dataset_(inputData), index_params_(params), distance_(d) + { + size_ = dataset_.rows; + dim_ = dataset_.cols; + root_node_ = 0; + int dim_param = get_param(params,"dim",-1); + if (dim_param>0) dim_ = dim_param; + leaf_max_size_ = get_param(params,"leaf_max_size",10); + reorder_ = get_param(params,"reorder",true); + + // Create a permutable array of indices to the input vectors. + vind_.resize(size_); + for (size_t i = 0; i < size_; i++) { + vind_[i] = (int)i; + } + } + + KDTreeSingleIndex(const KDTreeSingleIndex&); + KDTreeSingleIndex& operator=(const KDTreeSingleIndex&); + + /** + * Standard destructor + */ + ~KDTreeSingleIndex() + { + if (reorder_) delete[] data_.data; + } + + /** + * Builds the index + */ + void buildIndex() CV_OVERRIDE + { + computeBoundingBox(root_bbox_); + root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree + + if (reorder_) { + delete[] data_.data; + data_ = cvflann::Matrix(new ElementType[size_*dim_], size_, dim_); + for (size_t i=0; i& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE + { + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); + + KNNSimpleResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.init(indices[i], dists[i]); + findNeighbors(resultSet, queries[i], params); + } + } + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + + /** + * Find set of nearest neighbors to vec. Their indices are stored inside + * the result object. + * + * Params: + * result = the result object in which the indices of the nearest-neighbors are stored + * vec = the vector for which to search the nearest neighbors + * maxCheck = the maximum number of restarts (in a best-bin-first manner) + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + float epsError = 1+get_param(searchParams,"eps",0.0f); + + std::vector dists(dim_,0); + DistanceType distsq = computeInitialDistances(vec, dists); + searchLevel(result, vec, root_node_, distsq, dists, epsError); + } + +private: + + + /*--------------------- Internal Data Structures --------------------------*/ + struct Node + { + /** + * Indices of points in leaf node + */ + int left, right; + /** + * Dimension used for subdivision. + */ + int divfeat; + /** + * The values used for subdivision. + */ + DistanceType divlow, divhigh; + /** + * The child nodes. + */ + Node* child1, * child2; + }; + typedef Node* NodePtr; + + + struct Interval + { + DistanceType low, high; + }; + + typedef std::vector BoundingBox; + + typedef BranchStruct BranchSt; + typedef BranchSt* Branch; + + + + + void save_tree(FILE* stream, NodePtr tree) + { + save_value(stream, *tree); + if (tree->child1!=NULL) { + save_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + save_tree(stream, tree->child2); + } + } + + + void load_tree(FILE* stream, NodePtr& tree) + { + tree = pool_.allocate(); + load_value(stream, *tree); + if (tree->child1!=NULL) { + load_tree(stream, tree->child1); + } + if (tree->child2!=NULL) { + load_tree(stream, tree->child2); + } + } + + + void computeBoundingBox(BoundingBox& bbox) + { + bbox.resize(dim_); + for (size_t i=0; ibbox[i].high) bbox[i].high = (DistanceType)dataset_[k][i]; + } + } + } + + + /** + * Create a tree node that subdivides the list of vecs from vind[first] + * to vind[last]. The routine is called recursively on each sublist. + * Place a pointer to this new tree node in the location pTree. + * + * Params: pTree = the new node to create + * first = index of the first vector + * last = index of the last vector + */ + NodePtr divideTree(int left, int right, BoundingBox& bbox) + { + NodePtr node = pool_.allocate(); // allocate memory + + /* If too few exemplars remain, then make this a leaf node. */ + if ( (right-left) <= leaf_max_size_) { + node->child1 = node->child2 = NULL; /* Mark as leaf node. */ + node->left = left; + node->right = right; + + // compute bounding-box of leaf points + for (size_t i=0; idataset_[vind_[k]][i]) bbox[i].low=(DistanceType)dataset_[vind_[k]][i]; + if (bbox[i].highdivfeat = cutfeat; + + BoundingBox left_bbox(bbox); + left_bbox[cutfeat].high = cutval; + node->child1 = divideTree(left, left+idx, left_bbox); + + BoundingBox right_bbox(bbox); + right_bbox[cutfeat].low = cutval; + node->child2 = divideTree(left+idx, right, right_bbox); + + node->divlow = left_bbox[cutfeat].high; + node->divhigh = right_bbox[cutfeat].low; + + for (size_t i=0; imax_elem) max_elem = val; + } + } + + void middleSplit(int* ind, int count, int& index, int& cutfeat, DistanceType& cutval, const BoundingBox& bbox) + { + // find the largest span from the approximate bounding box + ElementType max_span = bbox[0].high-bbox[0].low; + cutfeat = 0; + cutval = (bbox[0].high+bbox[0].low)/2; + for (size_t i=1; imax_span) { + max_span = span; + cutfeat = i; + cutval = (bbox[i].high+bbox[i].low)/2; + } + } + + // compute exact span on the found dimension + ElementType min_elem, max_elem; + computeMinMax(ind, count, cutfeat, min_elem, max_elem); + cutval = (min_elem+max_elem)/2; + max_span = max_elem - min_elem; + + // check if a dimension of a largest span exists + size_t k = cutfeat; + for (size_t i=0; imax_span) { + computeMinMax(ind, count, i, min_elem, max_elem); + span = max_elem - min_elem; + if (span>max_span) { + max_span = span; + cutfeat = i; + cutval = (min_elem+max_elem)/2; + } + } + } + int lim1, lim2; + planeSplit(ind, count, cutfeat, cutval, lim1, lim2); + + if (lim1>count/2) index = lim1; + else if (lim2max_span) { + max_span = span; + } + } + DistanceType max_spread = -1; + cutfeat = 0; + for (size_t i=0; i(DistanceType)((1-EPS)*max_span)) { + ElementType min_elem, max_elem; + computeMinMax(ind, count, (int)i, min_elem, max_elem); + DistanceType spread = (DistanceType)(max_elem-min_elem); + if (spread>max_spread) { + cutfeat = (int)i; + max_spread = spread; + } + } + } + // split in the middle + DistanceType split_val = (bbox[cutfeat].low+bbox[cutfeat].high)/2; + ElementType min_elem, max_elem; + computeMinMax(ind, count, cutfeat, min_elem, max_elem); + + if (split_valmax_elem) cutval = (DistanceType)max_elem; + else cutval = split_val; + + int lim1, lim2; + planeSplit(ind, count, cutfeat, cutval, lim1, lim2); + + if (lim1>count/2) index = lim1; + else if (lim2cutval + */ + void planeSplit(int* ind, int count, int cutfeat, DistanceType cutval, int& lim1, int& lim2) + { + /* Move vector indices for left subtree to front of list. */ + int left = 0; + int right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]=cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + /* If either list is empty, it means that all remaining features + * are identical. Split in the middle to maintain a balanced tree. + */ + lim1 = left; + right = count-1; + for (;; ) { + while (left<=right && dataset_[ind[left]][cutfeat]<=cutval) ++left; + while (left<=right && dataset_[ind[right]][cutfeat]>cutval) --right; + if (left>right) break; + std::swap(ind[left], ind[right]); ++left; --right; + } + lim2 = left; + } + + DistanceType computeInitialDistances(const ElementType* vec, std::vector& dists) + { + DistanceType distsq = 0.0; + + for (size_t i = 0; i < dim_; ++i) { + if (vec[i] < root_bbox_[i].low) { + dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, (int)i); + distsq += dists[i]; + } + if (vec[i] > root_bbox_[i].high) { + dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, (int)i); + distsq += dists[i]; + } + } + + return distsq; + } + + /** + * Performs an exact search in the tree starting from a node. + */ + void searchLevel(ResultSet& result_set, const ElementType* vec, const NodePtr node, DistanceType mindistsq, + std::vector& dists, const float epsError) + { + /* If this is a leaf node, then do check and return. */ + if ((node->child1 == NULL)&&(node->child2 == NULL)) { + DistanceType worst_dist = result_set.worstDist(); + if (reorder_) { + for (int i=node->left; iright; ++i) { + DistanceType dist = distance_(vec, data_[i], dim_, worst_dist); + if (distleft; iright; ++i) { + DistanceType dist = distance_(vec, data_[vind_[i]], dim_, worst_dist); + if (distdivfeat; + ElementType val = vec[idx]; + DistanceType diff1 = val - node->divlow; + DistanceType diff2 = val - node->divhigh; + + NodePtr bestChild; + NodePtr otherChild; + DistanceType cut_dist; + if ((diff1+diff2)<0) { + bestChild = node->child1; + otherChild = node->child2; + cut_dist = distance_.accum_dist(val, node->divhigh, idx); + } + else { + bestChild = node->child2; + otherChild = node->child1; + cut_dist = distance_.accum_dist( val, node->divlow, idx); + } + + /* Call recursively to search next level down. */ + searchLevel(result_set, vec, bestChild, mindistsq, dists, epsError); + + DistanceType dst = dists[idx]; + mindistsq = mindistsq + cut_dist - dst; + dists[idx] = cut_dist; + if (mindistsq*epsError<=result_set.worstDist()) { + searchLevel(result_set, vec, otherChild, mindistsq, dists, epsError); + } + dists[idx] = dst; + } + +private: + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + IndexParams index_params_; + + int leaf_max_size_; + bool reorder_; + + + /** + * Array of indices to vectors in the dataset. + */ + std::vector vind_; + + Matrix data_; + + size_t size_; + size_t dim_; + + /** + * Array of k-d trees used to find neighbours. + */ + NodePtr root_node_; + + BoundingBox root_bbox_; + + /** + * Pooled memory allocator. + * + * Using a pooled memory allocator is more efficient + * than allocating memory directly when there is a large + * number small of memory allocations. + */ + PooledAllocator pool_; + + Distance distance_; +}; // class KDTree + +} + +//! @endcond + +#endif //OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/kmeans_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/kmeans_index.h new file mode 100644 index 0000000..fd7fe2b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/kmeans_index.h @@ -0,0 +1,1819 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_KMEANS_INDEX_H_ +#define OPENCV_FLANN_KMEANS_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include +#include + +#include "general.h" +#include "nn_index.h" +#include "dist.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" +#include "logger.h" + +#define BITS_PER_CHAR 8 +#define BITS_PER_BASE 2 // for DNA/RNA sequences +#define BASE_PER_CHAR (BITS_PER_CHAR/BITS_PER_BASE) +#define HISTOS_PER_BASE (1< +class KMeansIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + typedef typename Distance::CentersType CentersType; + + typedef typename Distance::is_kdtree_distance is_kdtree_distance; + typedef typename Distance::is_vector_space_distance is_vector_space_distance; + + + + typedef void (KMeansIndex::* centersAlgFunction)(int, int*, int, int*, int&); + + /** + * The function used for choosing the cluster centers. + */ + centersAlgFunction chooseCenters; + + + + /** + * Chooses the initial centers in the k-means clustering in a random manner. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * indices_length = length of indices vector + * + */ + void chooseCentersRandom(int k, int* indices, int indices_length, int* centers, int& centers_length) + { + UniqueRandom r(indices_length); + + int index; + for (index=0; index=0 && rnd < n); + + centers[0] = indices[rnd]; + + int index; + for (index=1; indexbest_val) { + best_val = dist; + best_index = j; + } + } + if (best_index!=-1) { + centers[index] = indices[best_index]; + } + else { + break; + } + } + centers_length = index; + } + + + /** + * Chooses the initial centers in the k-means using the algorithm + * proposed in the KMeans++ paper: + * Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding + * + * Implementation of this function was converted from the one provided in Arthur's code. + * + * Params: + * k = number of centers + * vecs = the dataset of points + * indices = indices in the dataset + * Returns: + */ + void chooseCentersKMeanspp(int k, int* indices, int indices_length, int* centers, int& centers_length) + { + int n = indices_length; + + double currentPot = 0; + DistanceType* closestDistSq = new DistanceType[n]; + + // Choose one random center and set the closestDistSq values + int index = rand_int(n); + CV_DbgAssert(index >=0 && index < n); + centers[0] = indices[index]; + + for (int i = 0; i < n; i++) { + closestDistSq[i] = distance_(dataset_[indices[i]], dataset_[indices[index]], dataset_.cols); + closestDistSq[i] = ensureSquareDistance( closestDistSq[i] ); + currentPot += closestDistSq[i]; + } + + + const int numLocalTries = 1; + + // Choose each center + int centerCount; + for (centerCount = 1; centerCount < k; centerCount++) { + + // Repeat several trials + double bestNewPot = -1; + int bestNewIndex = -1; + for (int localTrial = 0; localTrial < numLocalTries; localTrial++) { + + // Choose our center - have to be slightly careful to return a valid answer even accounting + // for possible rounding errors + double randVal = rand_double(currentPot); + for (index = 0; index < n-1; index++) { + if (randVal <= closestDistSq[index]) break; + else randVal -= closestDistSq[index]; + } + + // Compute the new potential + double newPot = 0; + for (int i = 0; i < n; i++) { + DistanceType dist = distance_(dataset_[indices[i]], dataset_[indices[index]], dataset_.cols); + newPot += std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + + // Store the best result + if ((bestNewPot < 0)||(newPot < bestNewPot)) { + bestNewPot = newPot; + bestNewIndex = index; + } + } + + // Add the appropriate center + centers[centerCount] = indices[bestNewIndex]; + currentPot = bestNewPot; + for (int i = 0; i < n; i++) { + DistanceType dist = distance_(dataset_[indices[i]], dataset_[indices[bestNewIndex]], dataset_.cols); + closestDistSq[i] = std::min( ensureSquareDistance(dist), closestDistSq[i] ); + } + } + + centers_length = centerCount; + + delete[] closestDistSq; + } + + + +public: + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_KMEANS; + } + + template + class KMeansDistanceComputer : public cv::ParallelLoopBody + { + public: + KMeansDistanceComputer(Distance _distance, const Matrix& _dataset, + const int _branching, const int* _indices, const CentersContainerType& _dcenters, + const size_t _veclen, std::vector &_new_centroids, + std::vector &_sq_dists) + : distance(_distance) + , dataset(_dataset) + , branching(_branching) + , indices(_indices) + , dcenters(_dcenters) + , veclen(_veclen) + , new_centroids(_new_centroids) + , sq_dists(_sq_dists) + { + } + + void operator()(const cv::Range& range) const CV_OVERRIDE + { + const int begin = range.start; + const int end = range.end; + + for( int i = begin; inew_sq_dist) { + new_centroid = j; + sq_dist = new_sq_dist; + } + } + sq_dists[i] = sq_dist; + new_centroids[i] = new_centroid; + } + } + + private: + Distance distance; + const Matrix& dataset; + const int branching; + const int* indices; + const CentersContainerType& dcenters; + const size_t veclen; + std::vector &new_centroids; + std::vector &sq_dists; + KMeansDistanceComputer& operator=( const KMeansDistanceComputer & ) { return *this; } + }; + + /** + * Index constructor + * + * Params: + * inputData = dataset with the input features + * params = parameters passed to the hierarchical k-means algorithm + */ + KMeansIndex(const Matrix& inputData, const IndexParams& params = KMeansIndexParams(), + Distance d = Distance()) + : dataset_(inputData), index_params_(params), root_(NULL), indices_(NULL), distance_(d) + { + memoryCounter_ = 0; + + size_ = dataset_.rows; + veclen_ = dataset_.cols; + + branching_ = get_param(params,"branching",32); + trees_ = get_param(params,"trees",1); + iterations_ = get_param(params,"iterations",11); + if (iterations_<0) { + iterations_ = (std::numeric_limits::max)(); + } + centers_init_ = get_param(params,"centers_init",FLANN_CENTERS_RANDOM); + + if (centers_init_==FLANN_CENTERS_RANDOM) { + chooseCenters = &KMeansIndex::chooseCentersRandom; + } + else if (centers_init_==FLANN_CENTERS_GONZALES) { + chooseCenters = &KMeansIndex::chooseCentersGonzales; + } + else if (centers_init_==FLANN_CENTERS_KMEANSPP) { + chooseCenters = &KMeansIndex::chooseCentersKMeanspp; + } + else { + FLANN_THROW(cv::Error::StsBadArg, "Unknown algorithm for choosing initial centers."); + } + cb_index_ = 0.4f; + + root_ = new KMeansNodePtr[trees_]; + indices_ = new int*[trees_]; + + for (int i=0; i(); + std::memset(root_[i], 0, sizeof(KMeansNode)); + + Distance* dummy = NULL; + computeNodeStatistics(root_[i], indices_[i], (unsigned int)size_, dummy); + + computeClustering(root_[i], indices_[i], (int)size_, branching_,0); + } + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream, branching_); + save_value(stream, iterations_); + save_value(stream, memoryCounter_); + save_value(stream, cb_index_); + save_value(stream, trees_); + for (int i=0; i& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE + { + + const int maxChecks = get_param(searchParams,"checks",32); + + if (maxChecks==FLANN_CHECKS_UNLIMITED) { + findExactNN(root_[0], result, vec); + } + else { + // Priority queue storing intermediate branches in the best-bin-first search + const cv::Ptr>& heap = Heap::getPooledInstance(cv::utils::getThreadID(), (int)size_); + + int checks = 0; + for (int i=0; i= maxChecks) && result.full()) + break; + } + + BranchSt branch; + while (heap->popMin(branch) && (checks& centers) + { + int numClusters = centers.rows; + if (numClusters<1) { + FLANN_THROW(cv::Error::StsBadArg, "Number of clusters must be at least 1"); + } + + DistanceType variance; + KMeansNodePtr* clusters = new KMeansNodePtr[numClusters]; + + int clusterCount = getMinVarianceClusters(root_[0], clusters, numClusters, variance); + + Logger::info("Clusters requested: %d, returning %d\n",numClusters, clusterCount); + + for (int i=0; ipivot; + for (size_t j=0; j BranchSt; + + + + + void save_tree(FILE* stream, KMeansNodePtr node, int num) + { + save_value(stream, *node); + save_value(stream, *(node->pivot), (int)veclen_); + if (node->childs==NULL) { + int indices_offset = (int)(node->indices - indices_[num]); + save_value(stream, indices_offset); + } + else { + for(int i=0; ichilds[i], num); + } + } + } + + + void load_tree(FILE* stream, KMeansNodePtr& node, int num) + { + node = pool_.allocate(); + load_value(stream, *node); + node->pivot = new CentersType[veclen_]; + load_value(stream, *(node->pivot), (int)veclen_); + if (node->childs==NULL) { + int indices_offset; + load_value(stream, indices_offset); + node->indices = indices_[num] + indices_offset; + } + else { + node->childs = pool_.allocate(branching_); + for(int i=0; ichilds[i], num); + } + } + } + + + /** + * Helper function + */ + void free_centers(KMeansNodePtr node) + { + delete[] node->pivot; + if (node->childs!=NULL) { + for (int k=0; kchilds[k]); + } + } + } + + void free_centers() + { + if (root_ != NULL) { + for(int i=0; i(), veclen_); + } + float length = static_cast(indices_length); + for (size_t j=0; j( mean[j] / static_cast(indices_length) ); + } + variance /= static_cast( length ); + variance -= distance_(mean, ZeroIterator(), veclen_); + + DistanceType radius = 0; + for (unsigned int i=0; iradius) { + radius = tmp; + } + } + + node->variance = variance; + node->radius = radius; + node->pivot = mean; + } + + + void computeBitfieldNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length) + { + const unsigned int accumulator_veclen = static_cast( + veclen_*sizeof(CentersType)*BITS_PER_CHAR); + + unsigned long long variance = 0ull; + CentersType* mean = new CentersType[veclen_]; + memoryCounter_ += int(veclen_*sizeof(CentersType)); + unsigned int* mean_accumulator = new unsigned int[accumulator_veclen]; + + memset(mean_accumulator, 0, sizeof(unsigned int)*accumulator_veclen); + + for (unsigned int i=0; i( ensureSquareDistance( + distance_(dataset_[indices[i]], ZeroIterator(), veclen_))); + unsigned char* vec = (unsigned char*)dataset_[indices[i]]; + for (size_t k=0, l=0; k>1) & 0x01; + mean_accumulator[k+2] += (vec[l]>>2) & 0x01; + mean_accumulator[k+3] += (vec[l]>>3) & 0x01; + mean_accumulator[k+4] += (vec[l]>>4) & 0x01; + mean_accumulator[k+5] += (vec[l]>>5) & 0x01; + mean_accumulator[k+6] += (vec[l]>>6) & 0x01; + mean_accumulator[k+7] += (vec[l]>>7) & 0x01; + } + } + double cnt = static_cast(indices_length); + unsigned char* char_mean = (unsigned char*)mean; + for (size_t k=0, l=0; k( + (((int)(0.5 + (double)(mean_accumulator[k]) / cnt))) + | (((int)(0.5 + (double)(mean_accumulator[k+1]) / cnt))<<1) + | (((int)(0.5 + (double)(mean_accumulator[k+2]) / cnt))<<2) + | (((int)(0.5 + (double)(mean_accumulator[k+3]) / cnt))<<3) + | (((int)(0.5 + (double)(mean_accumulator[k+4]) / cnt))<<4) + | (((int)(0.5 + (double)(mean_accumulator[k+5]) / cnt))<<5) + | (((int)(0.5 + (double)(mean_accumulator[k+6]) / cnt))<<6) + | (((int)(0.5 + (double)(mean_accumulator[k+7]) / cnt))<<7)); + } + variance = static_cast( + 0.5 + static_cast(variance) / static_cast(indices_length)); + variance -= static_cast( + ensureSquareDistance( + distance_(mean, ZeroIterator(), veclen_))); + + DistanceType radius = 0; + for (unsigned int i=0; iradius) { + radius = tmp; + } + } + + node->variance = static_cast(variance); + node->radius = radius; + node->pivot = mean; + + delete[] mean_accumulator; + } + + + void computeDnaNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length) + { + const unsigned int histos_veclen = static_cast( + veclen_*sizeof(CentersType)*(HISTOS_PER_BASE*BASE_PER_CHAR)); + + unsigned long long variance = 0ull; + unsigned int* histograms = new unsigned int[histos_veclen]; + memset(histograms, 0, sizeof(unsigned int)*histos_veclen); + + for (unsigned int i=0; i( ensureSquareDistance( + distance_(dataset_[indices[i]], ZeroIterator(), veclen_))); + + unsigned char* vec = (unsigned char*)dataset_[indices[i]]; + for (size_t k=0, l=0; k>2) & 0x03)]++; + histograms[k + 8 + ((vec[l]>>4) & 0x03)]++; + histograms[k +12 + ((vec[l]>>6) & 0x03)]++; + } + } + + CentersType* mean = new CentersType[veclen_]; + memoryCounter_ += int(veclen_*sizeof(CentersType)); + unsigned char* char_mean = (unsigned char*)mean; + unsigned int* h = histograms; + for (size_t k=0, l=0; k h[k+1] ? h[k+2] > h[k+3] ? h[k] > h[k+2] ? 0x00 : 0x10 + : h[k] > h[k+3] ? 0x00 : 0x11 + : h[k+2] > h[k+3] ? h[k+1] > h[k+2] ? 0x01 : 0x10 + : h[k+1] > h[k+3] ? 0x01 : 0x11) + | (h[k+4]>h[k+5] ? h[k+6] > h[k+7] ? h[k+4] > h[k+6] ? 0x00 : 0x1000 + : h[k+4] > h[k+7] ? 0x00 : 0x1100 + : h[k+6] > h[k+7] ? h[k+5] > h[k+6] ? 0x0100 : 0x1000 + : h[k+5] > h[k+7] ? 0x0100 : 0x1100) + | (h[k+8]>h[k+9] ? h[k+10]>h[k+11] ? h[k+8] >h[k+10] ? 0x00 : 0x100000 + : h[k+8] >h[k+11] ? 0x00 : 0x110000 + : h[k+10]>h[k+11] ? h[k+9] >h[k+10] ? 0x010000 : 0x100000 + : h[k+9] >h[k+11] ? 0x010000 : 0x110000) + | (h[k+12]>h[k+13] ? h[k+14]>h[k+15] ? h[k+12] >h[k+14] ? 0x00 : 0x10000000 + : h[k+12] >h[k+15] ? 0x00 : 0x11000000 + : h[k+14]>h[k+15] ? h[k+13] >h[k+14] ? 0x01000000 : 0x10000000 + : h[k+13] >h[k+15] ? 0x01000000 : 0x11000000); + } + variance = static_cast( + 0.5 + static_cast(variance) / static_cast(indices_length)); + variance -= static_cast( + ensureSquareDistance( + distance_(mean, ZeroIterator(), veclen_))); + + DistanceType radius = 0; + for (unsigned int i=0; iradius) { + radius = tmp; + } + } + + node->variance = static_cast(variance); + node->radius = radius; + node->pivot = mean; + + delete[] histograms; + } + + + template + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const DistType* identifier) + { + (void)identifier; + computeNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::HammingLUT* identifier) + { + (void)identifier; + computeBitfieldNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::Hamming* identifier) + { + (void)identifier; + computeBitfieldNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::Hamming2* identifier) + { + (void)identifier; + computeBitfieldNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::DNAmmingLUT* identifier) + { + (void)identifier; + computeDnaNodeStatistics(node, indices, indices_length); + } + + void computeNodeStatistics(KMeansNodePtr node, int* indices, + unsigned int indices_length, + const cvflann::DNAmming2* identifier) + { + (void)identifier; + computeDnaNodeStatistics(node, indices, indices_length); + } + + + void refineClustering(int* indices, int indices_length, int branching, CentersType** centers, + std::vector& radiuses, int* belongs_to, int* count) + { + cv::AutoBuffer dcenters_buf(branching*veclen_); + Matrix dcenters(dcenters_buf.data(), branching, veclen_); + + bool converged = false; + int iteration = 0; + while (!converged && iteration new_centroids(indices_length); + std::vector sq_dists(indices_length); + + // reassign points to clusters + KMeansDistanceComputer > invoker( + distance_, dataset_, branching, indices, dcenters, veclen_, new_centroids, sq_dists); + parallel_for_(cv::Range(0, (int)indices_length), invoker); + + for (int i=0; i < (int)indices_length; ++i) { + DistanceType sq_dist(sq_dists[i]); + int new_centroid(new_centroids[i]); + if (sq_dist > radiuses[new_centroid]) { + radiuses[new_centroid] = sq_dist; + } + if (new_centroid != belongs_to[i]) { + count[belongs_to[i]]--; + count[new_centroid]++; + belongs_to[i] = new_centroid; + converged = false; + } + } + + for (int i=0; i& radiuses, int* belongs_to, int* count) + { + for (int i=0; i( + veclen_*sizeof(ElementType)*BITS_PER_CHAR); + cv::AutoBuffer dcenters_buf(branching*accumulator_veclen); + Matrix dcenters(dcenters_buf.data(), branching, accumulator_veclen); + + bool converged = false; + int iteration = 0; + while (!converged && iteration>1) & 0x01; + dcenter[k+2] += (vec[l]>>2) & 0x01; + dcenter[k+3] += (vec[l]>>3) & 0x01; + dcenter[k+4] += (vec[l]>>4) & 0x01; + dcenter[k+5] += (vec[l]>>5) & 0x01; + dcenter[k+6] += (vec[l]>>6) & 0x01; + dcenter[k+7] += (vec[l]>>7) & 0x01; + } + } + for (int i=0; i(count[i]); + unsigned int* dcenter = dcenters[i]; + unsigned char* charCenter = (unsigned char*)centers[i]; + for (size_t k=0, l=0; k( + (((int)(0.5 + (double)(dcenter[k]) / cnt))) + | (((int)(0.5 + (double)(dcenter[k+1]) / cnt))<<1) + | (((int)(0.5 + (double)(dcenter[k+2]) / cnt))<<2) + | (((int)(0.5 + (double)(dcenter[k+3]) / cnt))<<3) + | (((int)(0.5 + (double)(dcenter[k+4]) / cnt))<<4) + | (((int)(0.5 + (double)(dcenter[k+5]) / cnt))<<5) + | (((int)(0.5 + (double)(dcenter[k+6]) / cnt))<<6) + | (((int)(0.5 + (double)(dcenter[k+7]) / cnt))<<7)); + } + } + + std::vector new_centroids(indices_length); + std::vector dists(indices_length); + + // reassign points to clusters + KMeansDistanceComputer invoker( + distance_, dataset_, branching, indices, centers, veclen_, new_centroids, dists); + parallel_for_(cv::Range(0, (int)indices_length), invoker); + + for (int i=0; i < indices_length; ++i) { + DistanceType dist(dists[i]); + int new_centroid(new_centroids[i]); + if (dist > radiuses[new_centroid]) { + radiuses[new_centroid] = dist; + } + if (new_centroid != belongs_to[i]) { + count[belongs_to[i]]--; + count[new_centroid]++; + belongs_to[i] = new_centroid; + converged = false; + } + } + + for (int i=0; i& radiuses, int* belongs_to, int* count) + { + for (int i=0; i( + veclen_*sizeof(CentersType)*(HISTOS_PER_BASE*BASE_PER_CHAR)); + cv::AutoBuffer histos_buf(branching*histos_veclen); + Matrix histos(histos_buf.data(), branching, histos_veclen); + + bool converged = false; + int iteration = 0; + while (!converged && iteration>2) & 0x03)]++; + h[k + 8 + ((vec[l]>>4) & 0x03)]++; + h[k +12 + ((vec[l]>>6) & 0x03)]++; + } + } + for (int i=0; i h[k+1] ? h[k+2] > h[k+3] ? h[k] > h[k+2] ? 0x00 : 0x10 + : h[k] > h[k+3] ? 0x00 : 0x11 + : h[k+2] > h[k+3] ? h[k+1] > h[k+2] ? 0x01 : 0x10 + : h[k+1] > h[k+3] ? 0x01 : 0x11) + | (h[k+4]>h[k+5] ? h[k+6] > h[k+7] ? h[k+4] > h[k+6] ? 0x00 : 0x1000 + : h[k+4] > h[k+7] ? 0x00 : 0x1100 + : h[k+6] > h[k+7] ? h[k+5] > h[k+6] ? 0x0100 : 0x1000 + : h[k+5] > h[k+7] ? 0x0100 : 0x1100) + | (h[k+8]>h[k+9] ? h[k+10]>h[k+11] ? h[k+8] >h[k+10] ? 0x00 : 0x100000 + : h[k+8] >h[k+11] ? 0x00 : 0x110000 + : h[k+10]>h[k+11] ? h[k+9] >h[k+10] ? 0x010000 : 0x100000 + : h[k+9] >h[k+11] ? 0x010000 : 0x110000) + | (h[k+12]>h[k+13] ? h[k+14]>h[k+15] ? h[k+12] >h[k+14] ? 0x00 : 0x10000000 + : h[k+12] >h[k+15] ? 0x00 : 0x11000000 + : h[k+14]>h[k+15] ? h[k+13] >h[k+14] ? 0x01000000 : 0x10000000 + : h[k+13] >h[k+15] ? 0x01000000 : 0x11000000); + } + } + + std::vector new_centroids(indices_length); + std::vector dists(indices_length); + + // reassign points to clusters + KMeansDistanceComputer invoker( + distance_, dataset_, branching, indices, centers, veclen_, new_centroids, dists); + parallel_for_(cv::Range(0, (int)indices_length), invoker); + + for (int i=0; i < indices_length; ++i) { + DistanceType dist(dists[i]); + int new_centroid(new_centroids[i]); + if (dist > radiuses[new_centroid]) { + radiuses[new_centroid] = dist; + } + if (new_centroid != belongs_to[i]) { + count[belongs_to[i]]--; + count[new_centroid]++; + belongs_to[i] = new_centroid; + converged = false; + } + } + + for (int i=0; i& radiuses, int* belongs_to, int* count) + { + // compute kmeans clustering for each of the resulting clusters + node->childs = pool_.allocate(branching); + int start = 0; + int end = start; + for (int c=0; c(), veclen_); + variance += d; + mean_radius += static_cast( sqrt(d) ); + std::swap(indices[i],indices[end]); + std::swap(belongs_to[i],belongs_to[end]); + end++; + } + } + variance /= s; + mean_radius /= s; + variance -= distance_(centers[c], ZeroIterator(), veclen_); + + node->childs[c] = pool_.allocate(); + std::memset(node->childs[c], 0, sizeof(KMeansNode)); + node->childs[c]->radius = radiuses[c]; + node->childs[c]->pivot = centers[c]; + node->childs[c]->variance = variance; + node->childs[c]->mean_radius = mean_radius; + computeClustering(node->childs[c],indices+start, end-start, branching, level+1); + start=end; + } + } + + + void computeAnyBitfieldSubClustering(KMeansNodePtr node, int* indices, int indices_length, + int branching, int level, CentersType** centers, + std::vector& radiuses, int* belongs_to, int* count) + { + // compute kmeans clustering for each of the resulting clusters + node->childs = pool_.allocate(branching); + int start = 0; + int end = start; + for (int c=0; c(), veclen_); + variance += static_cast( ensureSquareDistance(d) ); + mean_radius += ensureSimpleDistance(d); + std::swap(indices[i],indices[end]); + std::swap(belongs_to[i],belongs_to[end]); + end++; + } + } + mean_radius = static_cast( + 0.5f + static_cast(mean_radius) / static_cast(s)); + variance = static_cast( + 0.5 + static_cast(variance) / static_cast(s)); + variance -= static_cast( + ensureSquareDistance( + distance_(centers[c], ZeroIterator(), veclen_))); + + node->childs[c] = pool_.allocate(); + std::memset(node->childs[c], 0, sizeof(KMeansNode)); + node->childs[c]->radius = radiuses[c]; + node->childs[c]->pivot = centers[c]; + node->childs[c]->variance = static_cast(variance); + node->childs[c]->mean_radius = mean_radius; + computeClustering(node->childs[c],indices+start, end-start, branching, level+1); + start=end; + } + } + + + template + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const DistType* identifier) + { + (void)identifier; + refineClustering(indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + /** + * The methods responsible with doing the recursive hierarchical clustering on + * binary vectors. + * As some might have heard that KMeans on binary data doesn't make sense, + * it's worth a little explanation why it actually fairly works. As + * with the Hierarchical Clustering algortihm, we seed several centers for the + * current node by picking some of its points. Then in a first pass each point + * of the node is then related to its closest center. Now let's have a look at + * the 5 central dimensions of the 9 following points: + * + * xxxxxx11100xxxxx (1) + * xxxxxx11010xxxxx (2) + * xxxxxx11001xxxxx (3) + * xxxxxx10110xxxxx (4) + * xxxxxx10101xxxxx (5) + * xxxxxx10011xxxxx (6) + * xxxxxx01110xxxxx (7) + * xxxxxx01101xxxxx (8) + * xxxxxx01011xxxxx (9) + * sum _____ + * of 1: 66555 + * + * Even if the barycenter notion doesn't apply, we can set a center + * xxxxxx11111xxxxx that will better fit the five dimensions we are focusing + * on for these points. + * + * Note that convergence isn't ensured anymore. In practice, using Gonzales + * as seeding algorithm should be fine for getting convergence ("iterations" + * value can be set to -1). But with KMeans++ seeding you should definitely + * set a maximum number of iterations (but make it higher than the "iterations" + * default value of 11). + * + * Params: + * node = the node to cluster + * indices = indices of the points belonging to the current node + * indices_length = number of points in the current node + * branching = the branching factor to use in the clustering + * level = 0 for the root node, it increases with the subdivision levels + * centers = clusters centers to compute + * radiuses = radiuses of clusters + * belongs_to = LookUp Table returning, for a given indice id, the center id it belongs to + * count = array storing the number of indices for a given center id + * identifier = dummy pointer on an instance of Distance (use to branch correctly among templates) + */ + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::HammingLUT* identifier) + { + (void)identifier; + refineBitfieldClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::Hamming* identifier) + { + (void)identifier; + refineBitfieldClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::Hamming2* identifier) + { + (void)identifier; + refineBitfieldClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::DNAmmingLUT* identifier) + { + (void)identifier; + refineDnaClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + void refineAndSplitClustering( + KMeansNodePtr node, int* indices, int indices_length, int branching, + int level, CentersType** centers, std::vector& radiuses, + int* belongs_to, int* count, const cvflann::DNAmming2* identifier) + { + (void)identifier; + refineDnaClustering( + indices, indices_length, branching, centers, radiuses, belongs_to, count); + + computeAnyBitfieldSubClustering(node, indices, indices_length, branching, + level, centers, radiuses, belongs_to, count); + } + + + /** + * The method responsible with actually doing the recursive hierarchical + * clustering + * + * Params: + * node = the node to cluster + * indices = indices of the points belonging to the current node + * branching = the branching factor to use in the clustering + * + * TODO: for 1-sized clusters don't store a cluster center (it's the same as the single cluster point) + */ + void computeClustering(KMeansNodePtr node, int* indices, int indices_length, int branching, int level) + { + node->size = indices_length; + node->level = level; + + if (indices_length < branching) { + node->indices = indices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + cv::AutoBuffer centers_idx_buf(branching); + int* centers_idx = centers_idx_buf.data(); + int centers_length; + (this->*chooseCenters)(branching, indices, indices_length, centers_idx, centers_length); + + if (centers_lengthindices = indices; + std::sort(node->indices,node->indices+indices_length); + node->childs = NULL; + return; + } + + + std::vector radiuses(branching); + cv::AutoBuffer count_buf(branching); + int* count = count_buf.data(); + for (int i=0; i belongs_to_buf(indices_length); + int* belongs_to = belongs_to_buf.data(); + for (int i=0; inew_sq_dist) { + belongs_to[i] = j; + sq_dist = new_sq_dist; + } + } + if (sq_dist>radiuses[belongs_to[i]]) { + radiuses[belongs_to[i]] = sq_dist; + } + count[belongs_to[i]]++; + } + + CentersType** centers = new CentersType*[branching]; + + Distance* dummy = NULL; + refineAndSplitClustering(node, indices, indices_length, branching, level, + centers, radiuses, belongs_to, count, dummy); + + delete[] centers; + } + + + /** + * Performs one descent in the hierarchical k-means tree. The branches not + * visited are stored in a priority queue. + * + * Params: + * node = node to explore + * result = container for the k-nearest neighbors found + * vec = query points + * checks = how many points in the dataset have been checked so far + * maxChecks = maximum dataset points to checks + */ + + + void findNN(KMeansNodePtr node, ResultSet& result, const ElementType* vec, int& checks, int maxChecks, + const cv::Ptr>& heap) + { + // Ignore those clusters that are too far away + { + DistanceType bsq = distance_(vec, node->pivot, veclen_); + DistanceType rsq = node->radius; + DistanceType wsq = result.worstDist(); + + if (isSquareDistance()) + { + DistanceType val = bsq-rsq-wsq; + if ((val>0) && (val*val > 4*rsq*wsq)) + return; + } + else + { + if (bsq-rsq > wsq) + return; + } + } + + if (node->childs==NULL) { + if ((checks>=maxChecks) && result.full()) { + return; + } + checks += node->size; + for (int i=0; isize; ++i) { + int index = node->indices[i]; + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result.addPoint(dist, index); + } + } + else { + DistanceType* domain_distances = new DistanceType[branching_]; + int closest_center = exploreNodeBranches(node, vec, domain_distances, heap); + delete[] domain_distances; + findNN(node->childs[closest_center],result,vec, checks, maxChecks, heap); + } + } + + /** + * Helper function that computes the nearest childs of a node to a given query point. + * Params: + * node = the node + * q = the query point + * distances = array with the distances to each child node. + * Returns: + */ + int exploreNodeBranches(KMeansNodePtr node, const ElementType* q, DistanceType* domain_distances, const cv::Ptr>& heap) + { + + int best_index = 0; + domain_distances[best_index] = distance_(q, node->childs[best_index]->pivot, veclen_); + for (int i=1; ichilds[i]->pivot, veclen_); + if (domain_distances[i]childs[best_index]->pivot; + for (int i=0; i( + cb_index_*node->childs[i]->variance ); + + // float dist_to_border = getDistanceToBorder(node.childs[i].pivot,best_center,q); + // if (domain_distances[i]insert(BranchSt(node->childs[i],domain_distances[i])); + } + } + + return best_index; + } + + + /** + * Function the performs exact nearest neighbor search by traversing the entire tree. + */ + void findExactNN(KMeansNodePtr node, ResultSet& result, const ElementType* vec) + { + // Ignore those clusters that are too far away + { + DistanceType bsq = distance_(vec, node->pivot, veclen_); + DistanceType rsq = node->radius; + DistanceType wsq = result.worstDist(); + + if (isSquareDistance()) + { + DistanceType val = bsq-rsq-wsq; + if ((val>0) && (val*val > 4*rsq*wsq)) + return; + } + else + { + if (bsq-rsq > wsq) + return; + } + } + + + if (node->childs==NULL) { + for (int i=0; isize; ++i) { + int index = node->indices[i]; + DistanceType dist = distance_(dataset_[index], vec, veclen_); + result.addPoint(dist, index); + } + } + else { + int* sort_indices = new int[branching_]; + + getCenterOrdering(node, vec, sort_indices); + + for (int i=0; ichilds[sort_indices[i]],result,vec); + } + + delete[] sort_indices; + } + } + + + /** + * Helper function. + * + * I computes the order in which to traverse the child nodes of a particular node. + */ + void getCenterOrdering(KMeansNodePtr node, const ElementType* q, int* sort_indices) + { + DistanceType* domain_distances = new DistanceType[branching_]; + for (int i=0; ichilds[i]->pivot, veclen_); + + int j=0; + while (domain_distances[j]j; --k) { + domain_distances[k] = domain_distances[k-1]; + sort_indices[k] = sort_indices[k-1]; + } + domain_distances[j] = dist; + sort_indices[j] = i; + } + delete[] domain_distances; + } + + /** + * Method that computes the squared distance from the query point q + * from inside region with center c to the border between this + * region and the region with center p + */ + DistanceType getDistanceToBorder(DistanceType* p, DistanceType* c, DistanceType* q) + { + DistanceType sum = 0; + DistanceType sum2 = 0; + + for (int i=0; ivariance*root->size; + + while (clusterCount::max)(); + int splitIndex = -1; + + for (int i=0; ichilds != NULL) { + + DistanceType variance = meanVariance - clusters[i]->variance*clusters[i]->size; + + for (int j=0; jchilds[j]->variance*clusters[i]->childs[j]->size; + } + if (variance clusters_length) break; + + meanVariance = minVariance; + + // split node + KMeansNodePtr toSplit = clusters[splitIndex]; + clusters[splitIndex] = toSplit->childs[0]; + for (int i=1; ichilds[i]; + } + } + + varianceValue = meanVariance/root->size; + return clusterCount; + } + +private: + /** The branching factor used in the hierarchical k-means clustering */ + int branching_; + + /** Number of kmeans trees (default is one) */ + int trees_; + + /** Maximum number of iterations to use when performing k-means clustering */ + int iterations_; + + /** Algorithm for choosing the cluster centers */ + flann_centers_init_t centers_init_; + + /** + * Cluster border index. This is used in the tree search phase when determining + * the closest cluster to explore next. A zero value takes into account only + * the cluster centres, a value greater then zero also take into account the size + * of the cluster. + */ + float cb_index_; + + /** + * The dataset used by this index + */ + const Matrix dataset_; + + /** Index parameters */ + IndexParams index_params_; + + /** + * Number of features in the dataset. + */ + size_t size_; + + /** + * Length of each feature. + */ + size_t veclen_; + + /** + * The root node in the tree. + */ + KMeansNodePtr* root_; + + /** + * Array of indices to vectors in the dataset. + */ + int** indices_; + + /** + * The distance + */ + Distance distance_; + + /** + * Pooled memory allocator. + */ + PooledAllocator pool_; + + /** + * Memory occupied by the index. + */ + int memoryCounter_; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_KMEANS_INDEX_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/linear_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/linear_index.h new file mode 100644 index 0000000..6428c0d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/linear_index.h @@ -0,0 +1,135 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_LINEAR_INDEX_H_ +#define OPENCV_FLANN_LINEAR_INDEX_H_ + +//! @cond IGNORED + +#include "nn_index.h" + +namespace cvflann +{ + +struct LinearIndexParams : public IndexParams +{ + LinearIndexParams() + { + (* this)["algorithm"] = FLANN_INDEX_LINEAR; + } +}; + +template +class LinearIndex : public NNIndex +{ +public: + + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + + LinearIndex(const Matrix& inputData, const IndexParams& params = LinearIndexParams(), + Distance d = Distance()) : + dataset_(inputData), index_params_(params), distance_(d) + { + } + + LinearIndex(const LinearIndex&); + LinearIndex& operator=(const LinearIndex&); + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_LINEAR; + } + + + size_t size() const CV_OVERRIDE + { + return dataset_.rows; + } + + size_t veclen() const CV_OVERRIDE + { + return dataset_.cols; + } + + + int usedMemory() const CV_OVERRIDE + { + return 0; + } + + void buildIndex() CV_OVERRIDE + { + /* nothing to do here for linear search */ + } + + void saveIndex(FILE*) CV_OVERRIDE + { + /* nothing to do here for linear search */ + } + + + void loadIndex(FILE*) CV_OVERRIDE + { + /* nothing to do here for linear search */ + + index_params_["algorithm"] = getType(); + } + + void findNeighbors(ResultSet& resultSet, const ElementType* vec, const SearchParams& /*searchParams*/) CV_OVERRIDE + { + ElementType* data = dataset_.data; + for (size_t i = 0; i < dataset_.rows; ++i, data += dataset_.cols) { + DistanceType dist = distance_(data, vec, dataset_.cols); + resultSet.addPoint(dist, (int)i); + } + } + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + +private: + /** The dataset */ + const Matrix dataset_; + /** Index parameters */ + IndexParams index_params_; + /** Index distance */ + Distance distance_; + +}; + +} + +//! @endcond + +#endif // OPENCV_FLANN_LINEAR_INDEX_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/logger.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/logger.h new file mode 100644 index 0000000..8911812 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/logger.h @@ -0,0 +1,139 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_LOGGER_H +#define OPENCV_FLANN_LOGGER_H + +//! @cond IGNORED + +#include +#include + +#include "defines.h" + + +namespace cvflann +{ + +class Logger +{ + Logger() : stream(stdout), logLevel(FLANN_LOG_WARN) {} + + ~Logger() + { + if ((stream!=NULL)&&(stream!=stdout)) { + fclose(stream); + } + } + + static Logger& instance() + { + static Logger logger; + return logger; + } + + void _setDestination(const char* name) + { + if (name==NULL) { + stream = stdout; + } + else { +#ifdef _MSC_VER + if (fopen_s(&stream, name, "w") != 0) + stream = NULL; +#else + stream = fopen(name,"w"); +#endif + if (stream == NULL) { + stream = stdout; + } + } + } + + int _log(int level, const char* fmt, va_list arglist) + { + if (level > logLevel ) return -1; + int ret = vfprintf(stream, fmt, arglist); + return ret; + } + +public: + /** + * Sets the logging level. All messages with lower priority will be ignored. + * @param level Logging level + */ + static void setLevel(int level) { instance().logLevel = level; } + + /** + * Sets the logging destination + * @param name Filename or NULL for console + */ + static void setDestination(const char* name) { instance()._setDestination(name); } + + /** + * Print log message + * @param level Log level + * @param fmt Message format + * @return + */ + static int log(int level, const char* fmt, ...) + { + va_list arglist; + va_start(arglist, fmt); + int ret = instance()._log(level,fmt,arglist); + va_end(arglist); + return ret; + } + +#define LOG_METHOD(NAME,LEVEL) \ + static int NAME(const char* fmt, ...) \ + { \ + va_list ap; \ + va_start(ap, fmt); \ + int ret = instance()._log(LEVEL, fmt, ap); \ + va_end(ap); \ + return ret; \ + } + + LOG_METHOD(fatal, FLANN_LOG_FATAL) + LOG_METHOD(error, FLANN_LOG_ERROR) + LOG_METHOD(warn, FLANN_LOG_WARN) + LOG_METHOD(info, FLANN_LOG_INFO) + +private: + FILE* stream; + int logLevel; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_LOGGER_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/lsh_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/lsh_index.h new file mode 100644 index 0000000..b5e87f6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/lsh_index.h @@ -0,0 +1,403 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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. + *************************************************************************/ + +/*********************************************************************** + * Author: Vincent Rabaud + *************************************************************************/ + +#ifndef OPENCV_FLANN_LSH_INDEX_H_ +#define OPENCV_FLANN_LSH_INDEX_H_ + +//! @cond IGNORED + +#include +#include +#include +#include + +#include "nn_index.h" +#include "matrix.h" +#include "result_set.h" +#include "heap.h" +#include "lsh_table.h" +#include "allocator.h" +#include "random.h" +#include "saving.h" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) //disable unreachable code +#endif + +namespace cvflann +{ + +struct LshIndexParams : public IndexParams +{ + LshIndexParams(int table_number = 12, int key_size = 20, int multi_probe_level = 2) + { + (*this)["algorithm"] = FLANN_INDEX_LSH; + // The number of hash tables to use + (*this)["table_number"] = table_number; + // The length of the key in the hash tables + (*this)["key_size"] = key_size; + // Number of levels to use in multi-probe (0 for standard LSH) + (*this)["multi_probe_level"] = multi_probe_level; + } +}; + +/** + * Locality-sensitive hashing index + * + * Contains the tables and other information for indexing a set of points + * for nearest-neighbor matching. + */ +template +class LshIndex : public NNIndex +{ +public: + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + + /** Constructor + * @param input_data dataset with the input features + * @param params parameters passed to the LSH algorithm + * @param d the distance used + */ + LshIndex(const Matrix& input_data, const IndexParams& params = LshIndexParams(), + Distance d = Distance()) : + dataset_(input_data), index_params_(params), distance_(d) + { + // cv::flann::IndexParams sets integer params as 'int', so it is used with get_param + // in place of 'unsigned int' + table_number_ = get_param(index_params_,"table_number",12); + key_size_ = get_param(index_params_,"key_size",20); + multi_probe_level_ = get_param(index_params_,"multi_probe_level",2); + + feature_size_ = (unsigned)dataset_.cols; + fill_xor_mask(0, key_size_, multi_probe_level_, xor_masks_); + } + + + LshIndex(const LshIndex&); + LshIndex& operator=(const LshIndex&); + + /** + * Builds the index + */ + void buildIndex() CV_OVERRIDE + { + tables_.resize(table_number_); + for (int i = 0; i < table_number_; ++i) { + lsh::LshTable& table = tables_[i]; + table = lsh::LshTable(feature_size_, key_size_); + + // Add the features to the table + table.add(dataset_); + } + } + + flann_algorithm_t getType() const CV_OVERRIDE + { + return FLANN_INDEX_LSH; + } + + + void saveIndex(FILE* stream) CV_OVERRIDE + { + save_value(stream,table_number_); + save_value(stream,key_size_); + save_value(stream,multi_probe_level_); + save_value(stream, dataset_); + } + + void loadIndex(FILE* stream) CV_OVERRIDE + { + load_value(stream, table_number_); + load_value(stream, key_size_); + load_value(stream, multi_probe_level_); + load_value(stream, dataset_); + // Building the index is so fast we can afford not storing it + buildIndex(); + + index_params_["algorithm"] = getType(); + index_params_["table_number"] = table_number_; + index_params_["key_size"] = key_size_; + index_params_["multi_probe_level"] = multi_probe_level_; + } + + /** + * Returns size of index. + */ + size_t size() const CV_OVERRIDE + { + return dataset_.rows; + } + + /** + * Returns the length of an index feature. + */ + size_t veclen() const CV_OVERRIDE + { + return feature_size_; + } + + /** + * Computes the index memory usage + * Returns: memory used by the index + */ + int usedMemory() const CV_OVERRIDE + { + return (int)(dataset_.rows * sizeof(int)); + } + + + IndexParams getParameters() const CV_OVERRIDE + { + return index_params_; + } + + /** + * \brief Perform k-nearest neighbor search + * \param[in] queries The query points for which to find the nearest neighbors + * \param[out] indices The indices of the nearest neighbors found + * \param[out] dists Distances to the nearest neighbors found + * \param[in] knn Number of nearest neighbors to return + * \param[in] params Search parameters + */ + virtual void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) CV_OVERRIDE + { + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); + + + KNNUniqueResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.clear(); + std::fill_n(indices[i], knn, -1); + std::fill_n(dists[i], knn, std::numeric_limits::max()); + findNeighbors(resultSet, queries[i], params); + if (get_param(params,"sorted",true)) resultSet.sortAndCopy(indices[i], dists[i], knn); + else resultSet.copy(indices[i], dists[i], knn); + } + } + + + /** + * Find set of nearest neighbors to vec. Their indices are stored inside + * the result object. + * + * Params: + * result = the result object in which the indices of the nearest-neighbors are stored + * vec = the vector for which to search the nearest neighbors + * maxCheck = the maximum number of restarts (in a best-bin-first manner) + */ + void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& /*searchParams*/) CV_OVERRIDE + { + getNeighbors(vec, result); + } + +private: + /** Defines the comparator on score and index + */ + typedef std::pair ScoreIndexPair; + struct SortScoreIndexPairOnSecond + { + bool operator()(const ScoreIndexPair& left, const ScoreIndexPair& right) const + { + return left.second < right.second; + } + }; + + /** Fills the different xor masks to use when getting the neighbors in multi-probe LSH + * @param key the key we build neighbors from + * @param lowest_index the lowest index of the bit set + * @param level the multi-probe level we are at + * @param xor_masks all the xor mask + */ + void fill_xor_mask(lsh::BucketKey key, int lowest_index, unsigned int level, + std::vector& xor_masks) + { + xor_masks.push_back(key); + if (level == 0) return; + for (int index = lowest_index - 1; index >= 0; --index) { + // Create a new key + lsh::BucketKey new_key = key | (1 << index); + fill_xor_mask(new_key, index, level - 1, xor_masks); + } + } + + /** Performs the approximate nearest-neighbor search. + * @param vec the feature to analyze + * @param do_radius flag indicating if we check the radius too + * @param radius the radius if it is a radius search + * @param do_k flag indicating if we limit the number of nn + * @param k_nn the number of nearest neighbors + * @param checked_average used for debugging + */ + void getNeighbors(const ElementType* vec, bool /*do_radius*/, float radius, bool do_k, unsigned int k_nn, + float& /*checked_average*/) + { + static std::vector score_index_heap; + + if (do_k) { + unsigned int worst_score = std::numeric_limits::max(); + typename std::vector >::const_iterator table = tables_.begin(); + typename std::vector >::const_iterator table_end = tables_.end(); + for (; table != table_end; ++table) { + size_t key = table->getKey(vec); + std::vector::const_iterator xor_mask = xor_masks_.begin(); + std::vector::const_iterator xor_mask_end = xor_masks_.end(); + for (; xor_mask != xor_mask_end; ++xor_mask) { + size_t sub_key = key ^ (*xor_mask); + const lsh::Bucket* bucket = table->getBucketFromKey(sub_key); + if (bucket == 0) continue; + + // Go over each descriptor index + std::vector::const_iterator training_index = bucket->begin(); + std::vector::const_iterator last_training_index = bucket->end(); + DistanceType hamming_distance; + + // Process the rest of the candidates + for (; training_index < last_training_index; ++training_index) { + hamming_distance = distance_(vec, dataset_[*training_index], dataset_.cols); + + if (hamming_distance < worst_score) { + // Insert the new element + score_index_heap.push_back(ScoreIndexPair(hamming_distance, training_index)); + std::push_heap(score_index_heap.begin(), score_index_heap.end()); + + if (score_index_heap.size() > (unsigned int)k_nn) { + // Remove the highest distance value as we have too many elements + std::pop_heap(score_index_heap.begin(), score_index_heap.end()); + score_index_heap.pop_back(); + // Keep track of the worst score + worst_score = score_index_heap.front().first; + } + } + } + } + } + } + else { + typename std::vector >::const_iterator table = tables_.begin(); + typename std::vector >::const_iterator table_end = tables_.end(); + for (; table != table_end; ++table) { + size_t key = table->getKey(vec); + std::vector::const_iterator xor_mask = xor_masks_.begin(); + std::vector::const_iterator xor_mask_end = xor_masks_.end(); + for (; xor_mask != xor_mask_end; ++xor_mask) { + size_t sub_key = key ^ (*xor_mask); + const lsh::Bucket* bucket = table->getBucketFromKey(sub_key); + if (bucket == 0) continue; + + // Go over each descriptor index + std::vector::const_iterator training_index = bucket->begin(); + std::vector::const_iterator last_training_index = bucket->end(); + DistanceType hamming_distance; + + // Process the rest of the candidates + for (; training_index < last_training_index; ++training_index) { + // Compute the Hamming distance + hamming_distance = distance_(vec, dataset_[*training_index], dataset_.cols); + if (hamming_distance < radius) score_index_heap.push_back(ScoreIndexPair(hamming_distance, training_index)); + } + } + } + } + } + + /** Performs the approximate nearest-neighbor search. + * This is a slower version than the above as it uses the ResultSet + * @param vec the feature to analyze + */ + void getNeighbors(const ElementType* vec, ResultSet& result) + { + typename std::vector >::const_iterator table = tables_.begin(); + typename std::vector >::const_iterator table_end = tables_.end(); + for (; table != table_end; ++table) { + size_t key = table->getKey(vec); + std::vector::const_iterator xor_mask = xor_masks_.begin(); + std::vector::const_iterator xor_mask_end = xor_masks_.end(); + for (; xor_mask != xor_mask_end; ++xor_mask) { + size_t sub_key = key ^ (*xor_mask); + const lsh::Bucket* bucket = table->getBucketFromKey((lsh::BucketKey)sub_key); + if (bucket == 0) continue; + + // Go over each descriptor index + std::vector::const_iterator training_index = bucket->begin(); + std::vector::const_iterator last_training_index = bucket->end(); + DistanceType hamming_distance; + + // Process the rest of the candidates + for (; training_index < last_training_index; ++training_index) { + // Compute the Hamming distance + hamming_distance = distance_(vec, dataset_[*training_index], (int)dataset_.cols); + result.addPoint(hamming_distance, *training_index); + } + } + } + } + + /** The different hash tables */ + std::vector > tables_; + + /** The data the LSH tables where built from */ + Matrix dataset_; + + /** The size of the features (as ElementType[]) */ + unsigned int feature_size_; + + IndexParams index_params_; + + /** table number */ + int table_number_; + /** key size */ + int key_size_; + /** How far should we look for neighbors in multi-probe LSH */ + int multi_probe_level_; + + /** The XOR masks to apply to a key to get the neighboring buckets */ + std::vector xor_masks_; + + Distance distance_; +}; +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +//! @endcond + +#endif //OPENCV_FLANN_LSH_INDEX_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/lsh_table.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/lsh_table.h new file mode 100644 index 0000000..a189562 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/lsh_table.h @@ -0,0 +1,525 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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. + *************************************************************************/ + +/*********************************************************************** + * Author: Vincent Rabaud + *************************************************************************/ + +#ifndef OPENCV_FLANN_LSH_TABLE_H_ +#define OPENCV_FLANN_LSH_TABLE_H_ + +//! @cond IGNORED + +#include +#include +#include +#include +// TODO as soon as we use C++0x, use the code in USE_UNORDERED_MAP +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define USE_UNORDERED_MAP 1 +#else +# define USE_UNORDERED_MAP 0 +#endif +#if USE_UNORDERED_MAP +#include +#else +#include +#endif +#include +#include + +#include "dynamic_bitset.h" +#include "matrix.h" + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) //disable unreachable code +#endif + + +namespace cvflann +{ + +namespace lsh +{ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** What is stored in an LSH bucket + */ +typedef uint32_t FeatureIndex; +/** The id from which we can get a bucket back in an LSH table + */ +typedef unsigned int BucketKey; + +/** A bucket in an LSH table + */ +typedef std::vector Bucket; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** POD for stats about an LSH table + */ +struct LshStats +{ + std::vector bucket_sizes_; + size_t n_buckets_; + size_t bucket_size_mean_; + size_t bucket_size_median_; + size_t bucket_size_min_; + size_t bucket_size_max_; + size_t bucket_size_std_dev; + /** Each contained vector contains three value: beginning/end for interval, number of elements in the bin + */ + std::vector > size_histogram_; +}; + +/** Overload the << operator for LshStats + * @param out the streams + * @param stats the stats to display + * @return the streams + */ +inline std::ostream& operator <<(std::ostream& out, const LshStats& stats) +{ + int w = 20; + out << "Lsh Table Stats:\n" << std::setw(w) << std::setiosflags(std::ios::right) << "N buckets : " + << stats.n_buckets_ << "\n" << std::setw(w) << std::setiosflags(std::ios::right) << "mean size : " + << std::setiosflags(std::ios::left) << stats.bucket_size_mean_ << "\n" << std::setw(w) + << std::setiosflags(std::ios::right) << "median size : " << stats.bucket_size_median_ << "\n" << std::setw(w) + << std::setiosflags(std::ios::right) << "min size : " << std::setiosflags(std::ios::left) + << stats.bucket_size_min_ << "\n" << std::setw(w) << std::setiosflags(std::ios::right) << "max size : " + << std::setiosflags(std::ios::left) << stats.bucket_size_max_; + + // Display the histogram + out << std::endl << std::setw(w) << std::setiosflags(std::ios::right) << "histogram : " + << std::setiosflags(std::ios::left); + for (std::vector >::const_iterator iterator = stats.size_histogram_.begin(), end = + stats.size_histogram_.end(); iterator != end; ++iterator) out << (*iterator)[0] << "-" << (*iterator)[1] << ": " << (*iterator)[2] << ", "; + + return out; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Lsh hash table. As its key is a sub-feature, and as usually + * the size of it is pretty small, we keep it as a continuous memory array. + * The value is an index in the corpus of features (we keep it as an unsigned + * int for pure memory reasons, it could be a size_t) + */ +template +class LshTable +{ +public: + /** A container of all the feature indices. Optimized for space + */ +#if USE_UNORDERED_MAP + typedef std::unordered_map BucketsSpace; +#else + typedef std::map BucketsSpace; +#endif + + /** A container of all the feature indices. Optimized for speed + */ + typedef std::vector BucketsSpeed; + + /** Default constructor + */ + LshTable() + { + key_size_ = 0; + feature_size_ = 0; + speed_level_ = kArray; + } + + /** Default constructor + * Create the mask and allocate the memory + * @param feature_size is the size of the feature (considered as a ElementType[]) + * @param key_size is the number of bits that are turned on in the feature + */ + LshTable(unsigned int feature_size, unsigned int key_size) + { + feature_size_ = feature_size; + CV_UNUSED(key_size); + CV_Error(cv::Error::StsUnsupportedFormat, "LSH is not implemented for that type" ); + } + + /** Add a feature to the table + * @param value the value to store for that feature + * @param feature the feature itself + */ + void add(unsigned int value, const ElementType* feature) + { + // Add the value to the corresponding bucket + BucketKey key = (lsh::BucketKey)getKey(feature); + + switch (speed_level_) { + case kArray: + // That means we get the buckets from an array + buckets_speed_[key].push_back(value); + break; + case kBitsetHash: + // That means we can check the bitset for the presence of a key + key_bitset_.set(key); + buckets_space_[key].push_back(value); + break; + case kHash: + { + // That means we have to check for the hash table for the presence of a key + buckets_space_[key].push_back(value); + break; + } + } + } + + /** Add a set of features to the table + * @param dataset the values to store + */ + void add(Matrix dataset) + { +#if USE_UNORDERED_MAP + buckets_space_.rehash((buckets_space_.size() + dataset.rows) * 1.2); +#endif + // Add the features to the table + for (unsigned int i = 0; i < dataset.rows; ++i) add(i, dataset[i]); + // Now that the table is full, optimize it for speed/space + optimize(); + } + + /** Get a bucket given the key + * @param key + * @return + */ + inline const Bucket* getBucketFromKey(BucketKey key) const + { + // Generate other buckets + switch (speed_level_) { + case kArray: + // That means we get the buckets from an array + return &buckets_speed_[key]; + break; + case kBitsetHash: + // That means we can check the bitset for the presence of a key + if (key_bitset_.test(key)) return &buckets_space_.find(key)->second; + else return 0; + break; + case kHash: + { + // That means we have to check for the hash table for the presence of a key + BucketsSpace::const_iterator bucket_it, bucket_end = buckets_space_.end(); + bucket_it = buckets_space_.find(key); + // Stop here if that bucket does not exist + if (bucket_it == bucket_end) return 0; + else return &bucket_it->second; + break; + } + } + return 0; + } + + /** Compute the sub-signature of a feature + */ + size_t getKey(const ElementType* /*feature*/) const + { + CV_Error(cv::Error::StsUnsupportedFormat, "LSH is not implemented for that type" ); + return 0; + } + + /** Get statistics about the table + * @return + */ + LshStats getStats() const; + +private: + /** defines the speed fo the implementation + * kArray uses a vector for storing data + * kBitsetHash uses a hash map but checks for the validity of a key with a bitset + * kHash uses a hash map only + */ + enum SpeedLevel + { + kArray, kBitsetHash, kHash + }; + + /** Initialize some variables + */ + void initialize(size_t key_size) + { + const size_t key_size_lower_bound = 1; + //a value (size_t(1) << key_size) must fit the size_t type so key_size has to be strictly less than size of size_t + const size_t key_size_upper_bound = (std::min)(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT); + if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound) + { + CV_Error(cv::Error::StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound)); + } + + speed_level_ = kHash; + key_size_ = (unsigned)key_size; + } + + /** Optimize the table for speed/space + */ + void optimize() + { + // If we are already using the fast storage, no need to do anything + if (speed_level_ == kArray) return; + + // Use an array if it will be more than half full + if (buckets_space_.size() > ((size_t(1) << key_size_) / 2)) { + speed_level_ = kArray; + // Fill the array version of it + buckets_speed_.resize(size_t(1) << key_size_); + for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) buckets_speed_[key_bucket->first] = key_bucket->second; + + // Empty the hash table + buckets_space_.clear(); + return; + } + + // If the bitset is going to use less than 10% of the RAM of the hash map (at least 1 size_t for the key and two + // for the vector) or less than 512MB (key_size_ <= 30) + if (((std::max(buckets_space_.size(), buckets_speed_.size()) * CHAR_BIT * 3 * sizeof(BucketKey)) / 10 + >= (size_t(1) << key_size_)) || (key_size_ <= 32)) { + speed_level_ = kBitsetHash; + key_bitset_.resize(size_t(1) << key_size_); + key_bitset_.reset(); + // Try with the BucketsSpace + for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) key_bitset_.set(key_bucket->first); + } + else { + speed_level_ = kHash; + key_bitset_.clear(); + } + } + + /** The vector of all the buckets if they are held for speed + */ + BucketsSpeed buckets_speed_; + + /** The hash table of all the buckets in case we cannot use the speed version + */ + BucketsSpace buckets_space_; + + /** What is used to store the data */ + SpeedLevel speed_level_; + + /** If the subkey is small enough, it will keep track of which subkeys are set through that bitset + * That is just a speedup so that we don't look in the hash table (which can be mush slower that checking a bitset) + */ + DynamicBitset key_bitset_; + + /** The size of the sub-signature in bits + */ + unsigned int key_size_; + + unsigned int feature_size_; + + // Members only used for the unsigned char specialization + /** The mask to apply to a feature to get the hash key + * Only used in the unsigned char case + */ + std::vector mask_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Specialization for unsigned char + +template<> +inline LshTable::LshTable(unsigned int feature_size, unsigned int subsignature_size) +{ + feature_size_ = feature_size; + initialize(subsignature_size); + // Allocate the mask + mask_ = std::vector((feature_size * sizeof(char) + sizeof(size_t) - 1) / sizeof(size_t), 0); + + // A bit brutal but fast to code + std::vector indices(feature_size * CHAR_BIT); + for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = (int)i; +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::randShuffle(indices); +#else + std::random_shuffle(indices.begin(), indices.end()); +#endif + + // Generate a random set of order of subsignature_size_ bits + for (unsigned int i = 0; i < key_size_; ++i) { + size_t index = indices[i]; + + // Set that bit in the mask + size_t divisor = CHAR_BIT * sizeof(size_t); + size_t idx = index / divisor; //pick the right size_t index + mask_[idx] |= size_t(1) << (index % divisor); //use modulo to find the bit offset + } + + // Set to 1 if you want to display the mask for debug +#if 0 + { + size_t bcount = 0; + BOOST_FOREACH(size_t mask_block, mask_){ + out << std::setw(sizeof(size_t) * CHAR_BIT / 4) << std::setfill('0') << std::hex << mask_block + << std::endl; + bcount += __builtin_popcountll(mask_block); + } + out << "bit count : " << std::dec << bcount << std::endl; + out << "mask size : " << mask_.size() << std::endl; + return out; + } +#endif +} + +/** Return the Subsignature of a feature + * @param feature the feature to analyze + */ +template<> +inline size_t LshTable::getKey(const unsigned char* feature) const +{ + // no need to check if T is dividable by sizeof(size_t) like in the Hamming + // distance computation as we have a mask + // FIXIT: This is bad assumption, because we reading tail bytes after of the allocated features buffer + const size_t* feature_block_ptr = reinterpret_cast ((const void*)feature); + + // Figure out the subsignature of the feature + // Given the feature ABCDEF, and the mask 001011, the output will be + // 000CEF + size_t subsignature = 0; + size_t bit_index = 1; + + for (unsigned i = 0; i < feature_size_; i += sizeof(size_t)) { + // get the mask and signature blocks + size_t feature_block; + if (i <= feature_size_ - sizeof(size_t)) + { + feature_block = *feature_block_ptr; + } + else + { + size_t tmp = 0; + memcpy(&tmp, feature_block_ptr, feature_size_ - i); // preserve bytes order + feature_block = tmp; + } + size_t mask_block = mask_[i / sizeof(size_t)]; + while (mask_block) { + // Get the lowest set bit in the mask block + size_t lowest_bit = mask_block & (-(ptrdiff_t)mask_block); + // Add it to the current subsignature if necessary + subsignature += (feature_block & lowest_bit) ? bit_index : 0; + // Reset the bit in the mask block + mask_block ^= lowest_bit; + // increment the bit index for the subsignature + bit_index <<= 1; + } + // Check the next feature block + ++feature_block_ptr; + } + return subsignature; +} + +template<> +inline LshStats LshTable::getStats() const +{ + LshStats stats; + stats.bucket_size_mean_ = 0; + if ((buckets_speed_.empty()) && (buckets_space_.empty())) { + stats.n_buckets_ = 0; + stats.bucket_size_median_ = 0; + stats.bucket_size_min_ = 0; + stats.bucket_size_max_ = 0; + return stats; + } + + if (!buckets_speed_.empty()) { + for (BucketsSpeed::const_iterator pbucket = buckets_speed_.begin(); pbucket != buckets_speed_.end(); ++pbucket) { + stats.bucket_sizes_.push_back((lsh::FeatureIndex)pbucket->size()); + stats.bucket_size_mean_ += pbucket->size(); + } + stats.bucket_size_mean_ /= buckets_speed_.size(); + stats.n_buckets_ = buckets_speed_.size(); + } + else { + for (BucketsSpace::const_iterator x = buckets_space_.begin(); x != buckets_space_.end(); ++x) { + stats.bucket_sizes_.push_back((lsh::FeatureIndex)x->second.size()); + stats.bucket_size_mean_ += x->second.size(); + } + stats.bucket_size_mean_ /= buckets_space_.size(); + stats.n_buckets_ = buckets_space_.size(); + } + + std::sort(stats.bucket_sizes_.begin(), stats.bucket_sizes_.end()); + + // BOOST_FOREACH(int size, stats.bucket_sizes_) + // std::cout << size << " "; + // std::cout << std::endl; + stats.bucket_size_median_ = stats.bucket_sizes_[stats.bucket_sizes_.size() / 2]; + stats.bucket_size_min_ = stats.bucket_sizes_.front(); + stats.bucket_size_max_ = stats.bucket_sizes_.back(); + + // TODO compute mean and std + /*float mean, stddev; + stats.bucket_size_mean_ = mean; + stats.bucket_size_std_dev = stddev;*/ + + // Include a histogram of the buckets + unsigned int bin_start = 0; + unsigned int bin_end = 20; + bool is_new_bin = true; + for (std::vector::iterator iterator = stats.bucket_sizes_.begin(), end = stats.bucket_sizes_.end(); iterator + != end; ) + if (*iterator < bin_end) { + if (is_new_bin) { + stats.size_histogram_.push_back(std::vector(3, 0)); + stats.size_histogram_.back()[0] = bin_start; + stats.size_histogram_.back()[1] = bin_end - 1; + is_new_bin = false; + } + ++stats.size_histogram_.back()[2]; + ++iterator; + } + else { + bin_start += 20; + bin_end += 20; + is_new_bin = true; + } + + return stats; +} + +// End the two namespaces +} +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//! @endcond + +#endif /* OPENCV_FLANN_LSH_TABLE_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/matrix.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/matrix.h new file mode 100644 index 0000000..fb871bd --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/matrix.h @@ -0,0 +1,118 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_DATASET_H_ +#define OPENCV_FLANN_DATASET_H_ + +//! @cond IGNORED + +#include + +namespace cvflann +{ + +/** + * Class that implements a simple rectangular matrix stored in a memory buffer and + * provides convenient matrix-like access using the [] operators. + */ +template +class Matrix +{ +public: + typedef T type; + + size_t rows; + size_t cols; + size_t stride; + T* data; + + Matrix() : rows(0), cols(0), stride(0), data(NULL) + { + } + + Matrix(T* data_, size_t rows_, size_t cols_, size_t stride_ = 0) : + rows(rows_), cols(cols_), stride(stride_), data(data_) + { + if (stride==0) stride = cols; + } + + /** + * Convenience function for deallocating the storage data. + */ + CV_DEPRECATED void free() + { + fprintf(stderr, "The cvflann::Matrix::free() method is deprecated " + "and it does not do any memory deallocation any more. You are" + "responsible for deallocating the matrix memory (by doing" + "'delete[] matrix.data' for example)"); + } + + /** + * Operator that return a (pointer to a) row of the data. + */ + T* operator[](size_t index) const + { + return data+index*stride; + } +}; + + +class UntypedMatrix +{ +public: + size_t rows; + size_t cols; + void* data; + flann_datatype_t type; + + UntypedMatrix(void* data_, long rows_, long cols_) : + rows(rows_), cols(cols_), data(data_) + { + } + + ~UntypedMatrix() + { + } + + + template + Matrix as() + { + return Matrix((T*)data, rows, cols); + } +}; + + + +} + +//! @endcond + +#endif //OPENCV_FLANN_DATASET_H_ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/miniflann.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/miniflann.hpp new file mode 100644 index 0000000..b8df92d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/miniflann.hpp @@ -0,0 +1,185 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_MINIFLANN_HPP +#define OPENCV_MINIFLANN_HPP + +//! @cond IGNORED + +#include "opencv2/core.hpp" +#include "opencv2/flann/defines.h" + +namespace cv +{ + +namespace flann +{ + +enum FlannIndexType { + FLANN_INDEX_TYPE_8U = CV_8U, + FLANN_INDEX_TYPE_8S = CV_8S, + FLANN_INDEX_TYPE_16U = CV_16U, + FLANN_INDEX_TYPE_16S = CV_16S, + FLANN_INDEX_TYPE_32S = CV_32S, + FLANN_INDEX_TYPE_32F = CV_32F, + FLANN_INDEX_TYPE_64F = CV_64F, + FLANN_INDEX_TYPE_STRING, + FLANN_INDEX_TYPE_BOOL, + FLANN_INDEX_TYPE_ALGORITHM, + LAST_VALUE_FLANN_INDEX_TYPE = FLANN_INDEX_TYPE_ALGORITHM +}; + +struct CV_EXPORTS IndexParams +{ + IndexParams(); + ~IndexParams(); + + String getString(const String& key, const String& defaultVal=String()) const; + int getInt(const String& key, int defaultVal=-1) const; + double getDouble(const String& key, double defaultVal=-1) const; + + void setString(const String& key, const String& value); + void setInt(const String& key, int value); + void setDouble(const String& key, double value); + void setFloat(const String& key, float value); + void setBool(const String& key, bool value); + void setAlgorithm(int value); + + // FIXIT: replace by void write(FileStorage& fs) const + read() + void getAll(std::vector& names, + std::vector& types, + std::vector& strValues, + std::vector& numValues) const; + + void* params; + +private: + IndexParams(const IndexParams &); // copy disabled + IndexParams& operator=(const IndexParams &); // assign disabled +}; + +struct CV_EXPORTS KDTreeIndexParams : public IndexParams +{ + KDTreeIndexParams(int trees=4); +}; + +struct CV_EXPORTS LinearIndexParams : public IndexParams +{ + LinearIndexParams(); +}; + +struct CV_EXPORTS CompositeIndexParams : public IndexParams +{ + CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11, + cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2f ); +}; + +struct CV_EXPORTS AutotunedIndexParams : public IndexParams +{ + AutotunedIndexParams(float target_precision = 0.8f, float build_weight = 0.01f, + float memory_weight = 0, float sample_fraction = 0.1f); +}; + +struct CV_EXPORTS HierarchicalClusteringIndexParams : public IndexParams +{ + HierarchicalClusteringIndexParams(int branching = 32, + cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, int trees = 4, int leaf_size = 100 ); +}; + +struct CV_EXPORTS KMeansIndexParams : public IndexParams +{ + KMeansIndexParams(int branching = 32, int iterations = 11, + cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2f ); +}; + +struct CV_EXPORTS LshIndexParams : public IndexParams +{ + LshIndexParams(int table_number, int key_size, int multi_probe_level); +}; + +struct CV_EXPORTS SavedIndexParams : public IndexParams +{ + SavedIndexParams(const String& filename); +}; + +struct CV_EXPORTS SearchParams : public IndexParams +{ + SearchParams( int checks, float eps, bool sorted, bool explore_all_trees ); + SearchParams( int checks = 32, float eps = 0, bool sorted = true ); +}; + +class CV_EXPORTS_W Index +{ +public: + CV_WRAP Index(); + CV_WRAP Index(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2); + virtual ~Index(); + + CV_WRAP virtual void build(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2); + CV_WRAP virtual void knnSearch(InputArray query, OutputArray indices, + OutputArray dists, int knn, const SearchParams& params=SearchParams()); + + CV_WRAP virtual int radiusSearch(InputArray query, OutputArray indices, + OutputArray dists, double radius, int maxResults, + const SearchParams& params=SearchParams()); + + CV_WRAP virtual void save(const String& filename) const; + CV_WRAP virtual bool load(InputArray features, const String& filename); + CV_WRAP virtual void release(); + CV_WRAP cvflann::flann_distance_t getDistance() const; + CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const; + +protected: + bool load_(const String& filename); + + cvflann::flann_distance_t distType; + cvflann::flann_algorithm_t algo; + int featureType; + void* index; + Mat features_clone; // index may store features pointer internally for searching, so avoid dangling pointers: https://github.com/opencv/opencv/issues/17553 +}; + +} } // namespace cv::flann + +//! @endcond + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/nn_index.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/nn_index.h new file mode 100644 index 0000000..23a1de7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/nn_index.h @@ -0,0 +1,180 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_NNINDEX_H +#define OPENCV_FLANN_NNINDEX_H + +#include "matrix.h" +#include "result_set.h" +#include "params.h" + +//! @cond IGNORED + +namespace cvflann +{ + +/** + * Nearest-neighbour index base class + */ +template +class NNIndex +{ + typedef typename Distance::ElementType ElementType; + typedef typename Distance::ResultType DistanceType; + +public: + + virtual ~NNIndex() {} + + /** + * \brief Builds the index + */ + virtual void buildIndex() = 0; + + /** + * \brief Perform k-nearest neighbor search + * \param[in] queries The query points for which to find the nearest neighbors + * \param[out] indices The indices of the nearest neighbors found + * \param[out] dists Distances to the nearest neighbors found + * \param[in] knn Number of nearest neighbors to return + * \param[in] params Search parameters + */ + virtual void knnSearch(const Matrix& queries, Matrix& indices, Matrix& dists, int knn, const SearchParams& params) + { + CV_Assert(queries.cols == veclen()); + CV_Assert(indices.rows >= queries.rows); + CV_Assert(dists.rows >= queries.rows); + CV_Assert(int(indices.cols) >= knn); + CV_Assert(int(dists.cols) >= knn); + +#if 0 + KNNResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.init(indices[i], dists[i]); + findNeighbors(resultSet, queries[i], params); + } +#else + KNNUniqueResultSet resultSet(knn); + for (size_t i = 0; i < queries.rows; i++) { + resultSet.clear(); + findNeighbors(resultSet, queries[i], params); + if (get_param(params,"sorted",true)) resultSet.sortAndCopy(indices[i], dists[i], knn); + else resultSet.copy(indices[i], dists[i], knn); + } +#endif + } + + /** + * \brief Perform radius search + * \param[in] query The query point + * \param[out] indices The indinces of the neighbors found within the given radius + * \param[out] dists The distances to the nearest neighbors found + * \param[in] radius The radius used for search + * \param[in] params Search parameters + * \returns Number of neighbors found + */ + virtual int radiusSearch(const Matrix& query, Matrix& indices, Matrix& dists, float radius, const SearchParams& params) + { + if (query.rows != 1) { + fprintf(stderr, "I can only search one feature at a time for range search\n"); + return -1; + } + CV_Assert(query.cols == veclen()); + CV_Assert(indices.cols == dists.cols); + + int n = 0; + int* indices_ptr = NULL; + DistanceType* dists_ptr = NULL; + if (indices.cols > 0) { + n = (int)indices.cols; + indices_ptr = indices[0]; + dists_ptr = dists[0]; + } + + RadiusUniqueResultSet resultSet((DistanceType)radius); + resultSet.clear(); + findNeighbors(resultSet, query[0], params); + if (n>0) { + if (get_param(params,"sorted",true)) resultSet.sortAndCopy(indices_ptr, dists_ptr, n); + else resultSet.copy(indices_ptr, dists_ptr, n); + } + + return (int)resultSet.size(); + } + + /** + * \brief Saves the index to a stream + * \param stream The stream to save the index to + */ + virtual void saveIndex(FILE* stream) = 0; + + /** + * \brief Loads the index from a stream + * \param stream The stream from which the index is loaded + */ + virtual void loadIndex(FILE* stream) = 0; + + /** + * \returns number of features in this index. + */ + virtual size_t size() const = 0; + + /** + * \returns The dimensionality of the features in this index. + */ + virtual size_t veclen() const = 0; + + /** + * \returns The amount of memory (in bytes) used by the index. + */ + virtual int usedMemory() const = 0; + + /** + * \returns The index type (kdtree, kmeans,...) + */ + virtual flann_algorithm_t getType() const = 0; + + /** + * \returns The index parameters + */ + virtual IndexParams getParameters() const = 0; + + + /** + * \brief Method that searches for nearest-neighbours + */ + virtual void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) = 0; +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_NNINDEX_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/object_factory.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/object_factory.h new file mode 100644 index 0000000..5cc45ad --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/object_factory.h @@ -0,0 +1,95 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_OBJECT_FACTORY_H_ +#define OPENCV_FLANN_OBJECT_FACTORY_H_ + +//! @cond IGNORED + +#include + +namespace cvflann +{ + +class CreatorNotFound +{ +}; + +template +class ObjectFactory +{ + typedef ObjectFactory ThisClass; + typedef std::map ObjectRegistry; + + // singleton class, private constructor + ObjectFactory() {} + +public: + + bool subscribe(UniqueIdType id, ObjectCreator creator) + { + if (object_registry.find(id) != object_registry.end()) return false; + + object_registry[id] = creator; + return true; + } + + bool unregister(UniqueIdType id) + { + return object_registry.erase(id) == 1; + } + + ObjectCreator create(UniqueIdType id) + { + typename ObjectRegistry::const_iterator iter = object_registry.find(id); + + if (iter == object_registry.end()) { + throw CreatorNotFound(); + } + + return iter->second; + } + + static ThisClass& instance() + { + static ThisClass the_factory; + return the_factory; + } +private: + ObjectRegistry object_registry; +}; + +} + +//! @endcond + +#endif /* OPENCV_FLANN_OBJECT_FACTORY_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/params.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/params.h new file mode 100644 index 0000000..c9093cd --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/params.h @@ -0,0 +1,116 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_PARAMS_H_ +#define OPENCV_FLANN_PARAMS_H_ + +//! @cond IGNORED + +#include "any.h" +#include "general.h" +#include +#include + + +namespace cvflann +{ + +typedef std::map IndexParams; + +struct SearchParams : public IndexParams +{ + SearchParams(int checks = 32, float eps = 0, bool sorted = true ) + { + init(checks, eps, sorted, false); + } + + SearchParams(int checks, float eps, bool sorted, bool explore_all_trees ) + { + init(checks, eps, sorted, explore_all_trees); + } + + void init(int checks = 32, float eps = 0, bool sorted = true, bool explore_all_trees = false ) + { + // how many leafs to visit when searching for neighbours (-1 for unlimited) + (*this)["checks"] = checks; + // search for eps-approximate neighbours (default: 0) + (*this)["eps"] = eps; + // only for radius search, require neighbours sorted by distance (default: true) + (*this)["sorted"] = sorted; + // if false, search stops at the tree reaching the number of max checks (original behavior). + // When true, we do a descent in each tree and. Like before the alternative paths + // stored in the heap are not be processed further when max checks is reached. + (*this)["explore_all_trees"] = explore_all_trees; + } +}; + + +template +T get_param(const IndexParams& params, cv::String name, const T& default_value) +{ + IndexParams::const_iterator it = params.find(name); + if (it != params.end()) { + return it->second.cast(); + } + else { + return default_value; + } +} + +template +T get_param(const IndexParams& params, cv::String name) +{ + IndexParams::const_iterator it = params.find(name); + if (it != params.end()) { + return it->second.cast(); + } + else { + FLANN_THROW(cv::Error::StsBadArg, cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); + } +} + +inline void print_params(const IndexParams& params, std::ostream& stream) +{ + IndexParams::const_iterator it; + + for(it=params.begin(); it!=params.end(); ++it) { + stream << it->first << " : " << it->second << std::endl; + } +} + +inline void print_params(const IndexParams& params) +{ + print_params(params, std::cout); +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_PARAMS_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/random.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/random.h new file mode 100644 index 0000000..2c1809c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/random.h @@ -0,0 +1,157 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_RANDOM_H +#define OPENCV_FLANN_RANDOM_H + +//! @cond IGNORED + +#include +#include +#include + +namespace cvflann +{ + +inline int rand() +{ +#ifndef OPENCV_FLANN_USE_STD_RAND +# if INT_MAX == RAND_MAX + int v = cv::theRNG().next() & INT_MAX; +# else + int v = cv::theRNG().uniform(0, RAND_MAX + 1); +# endif +#else + int v = std::rand(); +#endif // OPENCV_FLANN_USE_STD_RAND + return v; +} + +/** + * Seeds the random number generator + * @param seed Random seed + */ +inline void seed_random(unsigned int seed) +{ +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::theRNG() = cv::RNG(seed); +#else + std::srand(seed); +#endif +} + +/* + * Generates a random double value. + */ +/** + * Generates a random double value. + * @param high Upper limit + * @param low Lower limit + * @return Random double value + */ +inline double rand_double(double high = 1.0, double low = 0) +{ + return low + ((high-low) * (rand() / (RAND_MAX + 1.0))); +} + +/** + * Generates a random integer value. + * @param high Upper limit + * @param low Lower limit + * @return Random integer value + */ +inline int rand_int(int high = RAND_MAX, int low = 0) +{ + return low + (int) ( double(high-low) * (rand() / (RAND_MAX + 1.0))); +} + +/** + * Random number generator that returns a distinct number from + * the [0,n) interval each time. + */ +class UniqueRandom +{ + std::vector vals_; + int size_; + int counter_; + +public: + /** + * Constructor. + * @param n Size of the interval from which to generate + * @return + */ + UniqueRandom(int n) + { + init(n); + } + + /** + * Initializes the number generator. + * @param n the size of the interval from which to generate random numbers. + */ + void init(int n) + { + // create and initialize an array of size n + vals_.resize(n); + size_ = n; + for (int i = 0; i < size_; ++i) vals_[i] = i; + + // shuffle the elements in the array +#ifndef OPENCV_FLANN_USE_STD_RAND + cv::randShuffle(vals_); +#else + std::random_shuffle(vals_.begin(), vals_.end()); +#endif + + counter_ = 0; + } + + /** + * Return a distinct random integer in greater or equal to 0 and less + * than 'n' on each call. It should be called maximum 'n' times. + * Returns: a random integer + */ + int next() + { + if (counter_ == size_) { + return -1; + } + else { + return vals_[counter_++]; + } + } +}; + +} + +//! @endcond + +#endif //OPENCV_FLANN_RANDOM_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/result_set.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/result_set.h new file mode 100644 index 0000000..47ad231 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/result_set.h @@ -0,0 +1,548 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_RESULTSET_H +#define OPENCV_FLANN_RESULTSET_H + +//! @cond IGNORED + +#include +#include +#include +#include +#include +#include + +namespace cvflann +{ + +/* This record represents a branch point when finding neighbors in + the tree. It contains a record of the minimum distance to the query + point, as well as the node at which the search resumes. + */ + +template +struct BranchStruct +{ + T node; /* Tree node at which search resumes */ + DistanceType mindist; /* Minimum distance to query for all nodes below. */ + + BranchStruct() {} + BranchStruct(const T& aNode, DistanceType dist) : node(aNode), mindist(dist) {} + + bool operator<(const BranchStruct& rhs) const + { + return mindist +class ResultSet +{ +public: + virtual ~ResultSet() {} + + virtual bool full() const = 0; + + virtual void addPoint(DistanceType dist, int index) = 0; + + virtual DistanceType worstDist() const = 0; + +}; + +/** + * KNNSimpleResultSet does not ensure that the element it holds are unique. + * Is used in those cases where the nearest neighbour algorithm used does not + * attempt to insert the same element multiple times. + */ +template +class KNNSimpleResultSet : public ResultSet +{ + int* indices; + DistanceType* dists; + int capacity; + int count; + DistanceType worst_distance_; + +public: + KNNSimpleResultSet(int capacity_) : capacity(capacity_), count(0) + { + } + + void init(int* indices_, DistanceType* dists_) + { + indices = indices_; + dists = dists_; + count = 0; + worst_distance_ = (std::numeric_limits::max)(); + dists[capacity-1] = worst_distance_; + } + + size_t size() const + { + return count; + } + + bool full() const CV_OVERRIDE + { + return count == capacity; + } + + + void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + if (dist >= worst_distance_) return; + int i; + for (i=count; i>0; --i) { +#ifdef FLANN_FIRST_MATCH + if ( (dists[i-1]>dist) || ((dist==dists[i-1])&&(indices[i-1]>index)) ) +#else + if (dists[i-1]>dist) +#endif + { + if (i +class KNNResultSet : public ResultSet +{ + int* indices; + DistanceType* dists; + int capacity; + int count; + DistanceType worst_distance_; + +public: + KNNResultSet(int capacity_) + : indices(NULL), dists(NULL), capacity(capacity_), count(0), worst_distance_(0) + { + } + + void init(int* indices_, DistanceType* dists_) + { + indices = indices_; + dists = dists_; + count = 0; + worst_distance_ = (std::numeric_limits::max)(); + dists[capacity-1] = worst_distance_; + } + + size_t size() const + { + return count; + } + + bool full() const CV_OVERRIDE + { + return count == capacity; + } + + + void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + CV_DbgAssert(indices); + CV_DbgAssert(dists); + if (dist >= worst_distance_) return; + int i; + for (i = count; i > 0; --i) { +#ifdef FLANN_FIRST_MATCH + if ( (dists[i-1]<=dist) && ((dist!=dists[i-1])||(indices[i-1]<=index)) ) +#else + if (dists[i-1]<=dist) +#endif + { + // Check for duplicate indices + for (int j = i; dists[j] == dist && j--;) { + if (indices[j] == index) { + return; + } + } + break; + } + } + + if (count < capacity) ++count; + for (int j = count-1; j > i; --j) { + dists[j] = dists[j-1]; + indices[j] = indices[j-1]; + } + dists[i] = dist; + indices[i] = index; + worst_distance_ = dists[capacity-1]; + } + + DistanceType worstDist() const CV_OVERRIDE + { + return worst_distance_; + } +}; + + +/** + * A result-set class used when performing a radius based search. + */ +template +class RadiusResultSet : public ResultSet +{ + DistanceType radius; + int* indices; + DistanceType* dists; + size_t capacity; + size_t count; + +public: + RadiusResultSet(DistanceType radius_, int* indices_, DistanceType* dists_, int capacity_) : + radius(radius_), indices(indices_), dists(dists_), capacity(capacity_) + { + init(); + } + + ~RadiusResultSet() + { + } + + void init() + { + count = 0; + } + + size_t size() const + { + return count; + } + + bool full() const + { + return true; + } + + void addPoint(DistanceType dist, int index) + { + if (dist0)&&(count < capacity)) { + dists[count] = dist; + indices[count] = index; + } + count++; + } + } + + DistanceType worstDist() const + { + return radius; + } + +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the k NN neighbors + * Faster than KNNResultSet as it uses a binary heap and does not maintain two arrays + */ +template +class UniqueResultSet : public ResultSet +{ +public: + struct DistIndex + { + DistIndex(DistanceType dist, unsigned int index) : + dist_(dist), index_(index) + { + } + bool operator<(const DistIndex dist_index) const + { + return (dist_ < dist_index.dist_) || ((dist_ == dist_index.dist_) && index_ < dist_index.index_); + } + DistanceType dist_; + unsigned int index_; + }; + + /** Default constructor */ + UniqueResultSet() : + is_full_(false), worst_distance_(std::numeric_limits::max()) + { + } + + /** Check the status of the set + * @return true if we have k NN + */ + inline bool full() const CV_OVERRIDE + { + return is_full_; + } + + /** Remove all elements in the set + */ + virtual void clear() = 0; + + /** Copy the set to two C arrays + * @param indices pointer to a C array of indices + * @param dist pointer to a C array of distances + * @param n_neighbors the number of neighbors to copy + */ + virtual void copy(int* indices, DistanceType* dist, int n_neighbors = -1) const + { + if (n_neighbors < 0) { + for (typename std::set::const_iterator dist_index = dist_indices_.begin(), dist_index_end = + dist_indices_.end(); dist_index != dist_index_end; ++dist_index, ++indices, ++dist) { + *indices = dist_index->index_; + *dist = dist_index->dist_; + } + } + else { + int i = 0; + for (typename std::set::const_iterator dist_index = dist_indices_.begin(), dist_index_end = + dist_indices_.end(); (dist_index != dist_index_end) && (i < n_neighbors); ++dist_index, ++indices, ++dist, ++i) { + *indices = dist_index->index_; + *dist = dist_index->dist_; + } + } + } + + /** Copy the set to two C arrays but sort it according to the distance first + * @param indices pointer to a C array of indices + * @param dist pointer to a C array of distances + * @param n_neighbors the number of neighbors to copy + */ + virtual void sortAndCopy(int* indices, DistanceType* dist, int n_neighbors = -1) const + { + copy(indices, dist, n_neighbors); + } + + /** The number of neighbors in the set + * @return + */ + size_t size() const + { + return dist_indices_.size(); + } + + /** The distance of the furthest neighbor + * If we don't have enough neighbors, it returns the max possible value + * @return + */ + inline DistanceType worstDist() const CV_OVERRIDE + { + return worst_distance_; + } +protected: + /** Flag to say if the set is full */ + bool is_full_; + + /** The worst distance found so far */ + DistanceType worst_distance_; + + /** The best candidates so far */ + std::set dist_indices_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the k NN neighbors + * Faster than KNNResultSet as it uses a binary heap and does not maintain two arrays + */ +template +class KNNUniqueResultSet : public UniqueResultSet +{ +public: + /** Constructor + * @param capacity the number of neighbors to store at max + */ + KNNUniqueResultSet(unsigned int capacity) : capacity_(capacity) + { + this->is_full_ = false; + this->clear(); + } + + /** Add a possible candidate to the best neighbors + * @param dist distance for that neighbor + * @param index index of that neighbor + */ + inline void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + // Don't do anything if we are worse than the worst + if (dist >= worst_distance_) return; + dist_indices_.insert(DistIndex(dist, index)); + + if (is_full_) { + if (dist_indices_.size() > capacity_) { + dist_indices_.erase(*dist_indices_.rbegin()); + worst_distance_ = dist_indices_.rbegin()->dist_; + } + } + else if (dist_indices_.size() == capacity_) { + is_full_ = true; + worst_distance_ = dist_indices_.rbegin()->dist_; + } + } + + /** Remove all elements in the set + */ + void clear() CV_OVERRIDE + { + dist_indices_.clear(); + worst_distance_ = std::numeric_limits::max(); + is_full_ = false; + } + +protected: + typedef typename UniqueResultSet::DistIndex DistIndex; + using UniqueResultSet::is_full_; + using UniqueResultSet::worst_distance_; + using UniqueResultSet::dist_indices_; + + /** The number of neighbors to keep */ + unsigned int capacity_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the radius nearest neighbors + * It is more accurate than RadiusResult as it is not limited in the number of neighbors + */ +template +class RadiusUniqueResultSet : public UniqueResultSet +{ +public: + /** Constructor + * @param radius the maximum distance of a neighbor + */ + RadiusUniqueResultSet(DistanceType radius) : + radius_(radius) + { + is_full_ = true; + } + + /** Add a possible candidate to the best neighbors + * @param dist distance for that neighbor + * @param index index of that neighbor + */ + void addPoint(DistanceType dist, int index) CV_OVERRIDE + { + if (dist <= radius_) dist_indices_.insert(DistIndex(dist, index)); + } + + /** Remove all elements in the set + */ + inline void clear() CV_OVERRIDE + { + dist_indices_.clear(); + } + + + /** Check the status of the set + * @return alwys false + */ + inline bool full() const CV_OVERRIDE + { + return true; + } + + /** The distance of the furthest neighbor + * If we don't have enough neighbors, it returns the max possible value + * @return + */ + inline DistanceType worstDist() const CV_OVERRIDE + { + return radius_; + } +private: + typedef typename UniqueResultSet::DistIndex DistIndex; + using UniqueResultSet::dist_indices_; + using UniqueResultSet::is_full_; + + /** The furthest distance a neighbor can be */ + DistanceType radius_; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** Class that holds the k NN neighbors within a radius distance + */ +template +class KNNRadiusUniqueResultSet : public KNNUniqueResultSet +{ +public: + /** Constructor + * @param capacity the number of neighbors to store at max + * @param radius the maximum distance of a neighbor + */ + KNNRadiusUniqueResultSet(unsigned int capacity, DistanceType radius) + { + this->capacity_ = capacity; + this->radius_ = radius; + this->dist_indices_.reserve(capacity_); + this->clear(); + } + + /** Remove all elements in the set + */ + void clear() + { + dist_indices_.clear(); + worst_distance_ = radius_; + is_full_ = false; + } +private: + using KNNUniqueResultSet::dist_indices_; + using KNNUniqueResultSet::is_full_; + using KNNUniqueResultSet::worst_distance_; + + /** The maximum number of neighbors to consider */ + unsigned int capacity_; + + /** The maximum distance of a neighbor */ + DistanceType radius_; +}; +} + +//! @endcond + +#endif //OPENCV_FLANN_RESULTSET_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/sampling.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/sampling.h new file mode 100644 index 0000000..4e452b9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/sampling.h @@ -0,0 +1,84 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_SAMPLING_H_ +#define OPENCV_FLANN_SAMPLING_H_ + +//! @cond IGNORED + +#include "matrix.h" +#include "random.h" + +namespace cvflann +{ + +template +Matrix random_sample(Matrix& srcMatrix, long size, bool remove = false) +{ + Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); + + T* src,* dest; + for (long i=0; i +Matrix random_sample(const Matrix& srcMatrix, size_t size) +{ + UniqueRandom rand((int)srcMatrix.rows); + Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); + + T* src,* dest; + for (size_t i=0; i +#include + +#include "general.h" +#include "nn_index.h" + +#ifdef FLANN_SIGNATURE_ +#undef FLANN_SIGNATURE_ +#endif +#define FLANN_SIGNATURE_ "FLANN_INDEX" + +namespace cvflann +{ + +template +struct Datatype {}; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_INT8; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_INT16; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_INT32; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_UINT8; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_UINT16; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_UINT32; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_FLOAT32; } }; +template<> +struct Datatype { static flann_datatype_t type() { return FLANN_FLOAT64; } }; + + +/** + * Structure representing the index header. + */ +struct IndexHeader +{ + char signature[16]; + char version[16]; + flann_datatype_t data_type; + flann_algorithm_t index_type; + size_t rows; + size_t cols; +}; + +/** + * Saves index header to stream + * + * @param stream - Stream to save to + * @param index - The index to save + */ +template +void save_header(FILE* stream, const NNIndex& index) +{ + IndexHeader header; + memset(header.signature, 0, sizeof(header.signature)); + strcpy(header.signature, FLANN_SIGNATURE_); + memset(header.version, 0, sizeof(header.version)); + strcpy(header.version, FLANN_VERSION_); + header.data_type = Datatype::type(); + header.index_type = index.getType(); + header.rows = index.size(); + header.cols = index.veclen(); + + std::fwrite(&header, sizeof(header),1,stream); +} + + +/** + * + * @param stream - Stream to load from + * @return Index header + */ +inline IndexHeader load_header(FILE* stream) +{ + IndexHeader header; + size_t read_size = fread(&header,sizeof(header),1,stream); + + if (read_size!=(size_t)1) { + FLANN_THROW(cv::Error::StsError, "Invalid index file, cannot read"); + } + + if (strcmp(header.signature,FLANN_SIGNATURE_)!=0) { + FLANN_THROW(cv::Error::StsError, "Invalid index file, wrong signature"); + } + + return header; + +} + + +template +void save_value(FILE* stream, const T& value, size_t count = 1) +{ + fwrite(&value, sizeof(value),count, stream); +} + +template +void save_value(FILE* stream, const cvflann::Matrix& value) +{ + fwrite(&value, sizeof(value),1, stream); + fwrite(value.data, sizeof(T),value.rows*value.cols, stream); +} + +template +void save_value(FILE* stream, const std::vector& value) +{ + size_t size = value.size(); + fwrite(&size, sizeof(size_t), 1, stream); + fwrite(&value[0], sizeof(T), size, stream); +} + +template +void load_value(FILE* stream, T& value, size_t count = 1) +{ + size_t read_cnt = fread(&value, sizeof(value), count, stream); + if (read_cnt != count) { + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); + } +} + +template +void load_value(FILE* stream, cvflann::Matrix& value) +{ + size_t read_cnt = fread(&value, sizeof(value), 1, stream); + if (read_cnt != 1) { + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); + } + value.data = new T[value.rows*value.cols]; + read_cnt = fread(value.data, sizeof(T), value.rows*value.cols, stream); + if (read_cnt != (size_t)(value.rows*value.cols)) { + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); + } +} + + +template +void load_value(FILE* stream, std::vector& value) +{ + size_t size; + size_t read_cnt = fread(&size, sizeof(size_t), 1, stream); + if (read_cnt!=1) { + FLANN_THROW(cv::Error::StsError, "Cannot read from file"); + } + value.resize(size); + read_cnt = fread(&value[0], sizeof(T), size, stream); + if (read_cnt != size) { + FLANN_THROW(cv::Error::StsError, "Cannot read from file"); + } +} + +} + +//! @endcond + +#endif /* OPENCV_FLANN_SAVING_H_ */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/simplex_downhill.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/simplex_downhill.h new file mode 100644 index 0000000..0297014 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/flann/simplex_downhill.h @@ -0,0 +1,190 @@ +/*********************************************************************** + * Software License Agreement (BSD License) + * + * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. + * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. + * + * THE BSD LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF 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 OPENCV_FLANN_SIMPLEX_DOWNHILL_H_ +#define OPENCV_FLANN_SIMPLEX_DOWNHILL_H_ + +//! @cond IGNORED + +namespace cvflann +{ + +/** + Adds val to array vals (and point to array points) and keeping the arrays sorted by vals. + */ +template +void addValue(int pos, float val, float* vals, T* point, T* points, int n) +{ + vals[pos] = val; + for (int i=0; i0 && vals[j] +float optimizeSimplexDownhill(T* points, int n, F func, float* vals = NULL ) +{ + const int MAX_ITERATIONS = 10; + + CV_DbgAssert(n>0); + + T* p_o = new T[n]; + T* p_r = new T[n]; + T* p_e = new T[n]; + + int alpha = 1; + + int iterations = 0; + + bool ownVals = false; + if (vals == NULL) { + ownVals = true; + vals = new float[n+1]; + for (int i=0; i MAX_ITERATIONS) break; + + // compute average of simplex points (except the highest point) + for (int j=0; j=vals[0])&&(val_r=vals[n]) { + for (int i=0; i +#include "opencv2/core.hpp" +#include "opencv2/core/utility.hpp" + +namespace cvflann +{ + +/** + * A start-stop timer class. + * + * Can be used to time portions of code. + */ +class StartStopTimer +{ + int64 startTime; + +public: + /** + * Value of the timer. + */ + double value; + + + /** + * Constructor. + */ + StartStopTimer() + : startTime(0) + { + reset(); + } + + /** + * Starts the timer. + */ + void start() + { + startTime = cv::getTickCount(); + } + + /** + * Stops the timer and updates timer value. + */ + void stop() + { + int64 stopTime = cv::getTickCount(); + value += ( (double)stopTime - startTime) / cv::getTickFrequency(); + } + + /** + * Resets the timer value to 0. + */ + void reset() + { + value = 0; + } + +}; + +} + +//! @endcond + +#endif // FLANN_TIMER_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi.hpp new file mode 100644 index 0000000..f10dfd4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi.hpp @@ -0,0 +1,42 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_HPP +#define OPENCV_GAPI_HPP + +#include + +/** \defgroup gapi G-API framework +@{ + @defgroup gapi_main_classes G-API Main Classes + @defgroup gapi_data_objects G-API Data Types + @{ + @defgroup gapi_meta_args G-API Metadata Descriptors + @} + @defgroup gapi_std_backends G-API Standard Backends + @defgroup gapi_compile_args G-API Graph Compilation Arguments + @defgroup gapi_serialization G-API Serialization functionality +@} + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Include these files here to avoid cyclic dependency between +// Desync & GKernel & GComputation & GStreamingCompiled. +#include +#include + +#endif // OPENCV_GAPI_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/core.hpp new file mode 100644 index 0000000..791aa4c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/core.hpp @@ -0,0 +1,1991 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_CORE_HPP +#define OPENCV_GAPI_CORE_HPP + +#include + +#include // std::tuple + +#include + +#include +#include +#include +#include + +/** \defgroup gapi_core G-API Core functionality +@{ + @defgroup gapi_math Graph API: Math operations + @defgroup gapi_pixelwise Graph API: Pixelwise operations + @defgroup gapi_matrixop Graph API: Operations on matrices + @defgroup gapi_transform Graph API: Image and channel composition functions +@} + */ + +namespace cv { namespace gapi { +/** + * @brief This namespace contains G-API Operation Types for OpenCV + * Core module functionality. + */ +namespace core { + using GMat2 = std::tuple; + using GMat3 = std::tuple; // FIXME: how to avoid this? + using GMat4 = std::tuple; + using GMatScalar = std::tuple; + + G_TYPED_KERNEL(GAdd, , "org.opencv.core.math.add") { + static GMatDesc outMeta(GMatDesc a, GMatDesc b, int ddepth) { + if (ddepth == -1) + { + // OpenCV: When the input arrays in add/subtract/multiply/divide + // functions have different depths, the output array depth must be + // explicitly specified! + // See artim_op() @ arithm.cpp + GAPI_Assert(a.chan == b.chan); + GAPI_Assert(a.depth == b.depth); + return a; + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GAddC, , "org.opencv.core.math.addC") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) { + GAPI_Assert(a.chan <= 4); + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSub, , "org.opencv.core.math.sub") { + static GMatDesc outMeta(GMatDesc a, GMatDesc b, int ddepth) { + if (ddepth == -1) + { + // This macro should select a larger data depth from a and b + // considering the number of channels in the same + // FIXME!!! Clarify if it is valid for sub() + GAPI_Assert(a.chan == b.chan); + ddepth = std::max(a.depth, b.depth); + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSubC, , "org.opencv.core.math.subC") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSubRC,, "org.opencv.core.math.subRC") { + static GMatDesc outMeta(GScalarDesc, GMatDesc b, int ddepth) { + return b.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMul, , "org.opencv.core.math.mul") { + static GMatDesc outMeta(GMatDesc a, GMatDesc, double, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMulCOld, , "org.opencv.core.math.mulCOld") { + static GMatDesc outMeta(GMatDesc a, double, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMulC, , "org.opencv.core.math.mulC"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMulS, , "org.opencv.core.math.muls") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; // FIXME: Merge with MulC + + G_TYPED_KERNEL(GDiv, , "org.opencv.core.math.div") { + static GMatDesc outMeta(GMatDesc a, GMatDesc b, double, int ddepth) { + if (ddepth == -1) + { + GAPI_Assert(a.depth == b.depth); + return b; + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GDivC, , "org.opencv.core.math.divC") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc, double, int ddepth) { + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GDivRC, , "org.opencv.core.math.divRC") { + static GMatDesc outMeta(GScalarDesc, GMatDesc b, double, int ddepth) { + return b.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GMean, , "org.opencv.core.math.mean") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL_M(GPolarToCart, , "org.opencv.core.math.polarToCart") { + static std::tuple outMeta(GMatDesc, GMatDesc a, bool) { + return std::make_tuple(a, a); + } + }; + + G_TYPED_KERNEL_M(GCartToPolar, , "org.opencv.core.math.cartToPolar") { + static std::tuple outMeta(GMatDesc x, GMatDesc, bool) { + return std::make_tuple(x, x); + } + }; + + G_TYPED_KERNEL(GPhase, , "org.opencv.core.math.phase") { + static GMatDesc outMeta(const GMatDesc &inx, const GMatDesc &, bool) { + return inx; + } + }; + + G_TYPED_KERNEL(GMask, , "org.opencv.core.pixelwise.mask") { + static GMatDesc outMeta(GMatDesc in, GMatDesc) { + return in; + } + }; + + G_TYPED_KERNEL(GCmpGT, , "org.opencv.core.pixelwise.compare.cmpGT") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpGE, , "org.opencv.core.pixelwise.compare.cmpGE") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLE, , "org.opencv.core.pixelwise.compare.cmpLE") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLT, , "org.opencv.core.pixelwise.compare.cmpLT") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpEQ, , "org.opencv.core.pixelwise.compare.cmpEQ") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpNE, , "org.opencv.core.pixelwise.compare.cmpNE") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpGTScalar, , "org.opencv.core.pixelwise.compare.cmpGTScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpGEScalar, , "org.opencv.core.pixelwise.compare.cmpGEScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLEScalar, , "org.opencv.core.pixelwise.compare.cmpLEScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpLTScalar, , "org.opencv.core.pixelwise.compare.cmpLTScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpEQScalar, , "org.opencv.core.pixelwise.compare.cmpEQScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GCmpNEScalar, , "org.opencv.core.pixelwise.compare.cmpNEScalar"){ + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a.withDepth(CV_8U); + } + }; + + G_TYPED_KERNEL(GAnd, , "org.opencv.core.pixelwise.bitwise_and") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GAndS, , "org.opencv.core.pixelwise.bitwise_andS") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GOr, , "org.opencv.core.pixelwise.bitwise_or") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GOrS, , "org.opencv.core.pixelwise.bitwise_orS") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GXor, , "org.opencv.core.pixelwise.bitwise_xor") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GXorS, , "org.opencv.core.pixelwise.bitwise_xorS") { + static GMatDesc outMeta(GMatDesc a, GScalarDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GNot, , "org.opencv.core.pixelwise.bitwise_not") { + static GMatDesc outMeta(GMatDesc a) { + return a; + } + }; + + G_TYPED_KERNEL(GSelect, , "org.opencv.core.pixelwise.select") { + static GMatDesc outMeta(GMatDesc a, GMatDesc, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GMin, , "org.opencv.core.matrixop.min") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GMax, , "org.opencv.core.matrixop.max") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GAbsDiff, , "org.opencv.core.matrixop.absdiff") { + static GMatDesc outMeta(GMatDesc a, GMatDesc) { + return a; + } + }; + + G_TYPED_KERNEL(GAbsDiffC, , "org.opencv.core.matrixop.absdiffC") { + static GMatDesc outMeta(const GMatDesc& a, const GScalarDesc&) { + return a; + } + }; + + G_TYPED_KERNEL(GSum, , "org.opencv.core.matrixop.sum") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL(GCountNonZero, (GMat)>, "org.opencv.core.matrixop.countNonZero") { + static GOpaqueDesc outMeta(GMatDesc in) { + GAPI_Assert(in.chan == 1); + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GAddW, , "org.opencv.core.matrixop.addweighted") { + static GMatDesc outMeta(GMatDesc a, double, GMatDesc b, double, double, int ddepth) { + if (ddepth == -1) + { + // OpenCV: When the input arrays in add/subtract/multiply/divide + // functions have different depths, the output array depth must be + // explicitly specified! + // See artim_op() @ arithm.cpp + GAPI_Assert(a.chan == b.chan); + GAPI_Assert(a.depth == b.depth); + return a; + } + return a.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GNormL1, , "org.opencv.core.matrixop.norml1") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL(GNormL2, , "org.opencv.core.matrixop.norml2") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL(GNormInf, , "org.opencv.core.matrixop.norminf") { + static GScalarDesc outMeta(GMatDesc) { + return empty_scalar_desc(); + } + }; + + G_TYPED_KERNEL_M(GIntegral, , "org.opencv.core.matrixop.integral") { + static std::tuple outMeta(GMatDesc in, int sd, int sqd) { + return std::make_tuple(in.withSizeDelta(1,1).withDepth(sd), + in.withSizeDelta(1,1).withDepth(sqd)); + } + }; + + G_TYPED_KERNEL(GThreshold, , "org.opencv.core.matrixop.threshold") { + static GMatDesc outMeta(GMatDesc in, GScalarDesc, GScalarDesc, int) { + return in; + } + }; + + + G_TYPED_KERNEL_M(GThresholdOT, , "org.opencv.core.matrixop.thresholdOT") { + static std::tuple outMeta(GMatDesc in, GScalarDesc, int) { + return std::make_tuple(in, empty_scalar_desc()); + } + }; + + G_TYPED_KERNEL(GInRange, , "org.opencv.core.matrixop.inrange") { + static GMatDesc outMeta(GMatDesc in, GScalarDesc, GScalarDesc) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL_M(GSplit3, , "org.opencv.core.transform.split3") { + static std::tuple outMeta(GMatDesc in) { + const auto out_depth = in.depth; + const auto out_desc = in.withType(out_depth, 1); + return std::make_tuple(out_desc, out_desc, out_desc); + } + }; + + G_TYPED_KERNEL_M(GSplit4, ,"org.opencv.core.transform.split4") { + static std::tuple outMeta(GMatDesc in) { + const auto out_depth = in.depth; + const auto out_desc = in.withType(out_depth, 1); + return std::make_tuple(out_desc, out_desc, out_desc, out_desc); + } + }; + + G_TYPED_KERNEL(GResize, , "org.opencv.core.transform.resize") { + static GMatDesc outMeta(GMatDesc in, Size sz, double fx, double fy, int /*interp*/) { + if (sz.width != 0 && sz.height != 0) + { + return in.withSize(sz); + } + else + { + int outSz_w = static_cast(round(in.size.width * fx)); + int outSz_h = static_cast(round(in.size.height * fy)); + GAPI_Assert(outSz_w > 0 && outSz_h > 0); + return in.withSize(Size(outSz_w, outSz_h)); + } + } + }; + + G_TYPED_KERNEL(GResizeP, , "org.opencv.core.transform.resizeP") { + static GMatDesc outMeta(GMatDesc in, Size sz, int interp) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + GAPI_Assert(in.planar); + GAPI_Assert(interp == cv::INTER_LINEAR); + return in.withSize(sz); + } + }; + + G_TYPED_KERNEL(GMerge3, , "org.opencv.core.transform.merge3") { + static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc) { + // Preserve depth and add channel component + return in.withType(in.depth, 3); + } + }; + + G_TYPED_KERNEL(GMerge4, , "org.opencv.core.transform.merge4") { + static GMatDesc outMeta(GMatDesc in, GMatDesc, GMatDesc, GMatDesc) { + // Preserve depth and add channel component + return in.withType(in.depth, 4); + } + }; + + G_TYPED_KERNEL(GRemap, , "org.opencv.core.transform.remap") { + static GMatDesc outMeta(GMatDesc in, Mat m1, Mat, int, int, Scalar) { + return in.withSize(m1.size()); + } + }; + + G_TYPED_KERNEL(GFlip, , "org.opencv.core.transform.flip") { + static GMatDesc outMeta(GMatDesc in, int) { + return in; + } + }; + + // TODO: eliminate the need in this kernel (streaming) + G_TYPED_KERNEL(GCrop, , "org.opencv.core.transform.crop") { + static GMatDesc outMeta(GMatDesc in, Rect rc) { + return in.withSize(Size(rc.width, rc.height)); + } + }; + + G_TYPED_KERNEL(GConcatHor, , "org.opencv.imgproc.transform.concatHor") { + static GMatDesc outMeta(GMatDesc l, GMatDesc r) { + return l.withSizeDelta(+r.size.width, 0); + } + }; + + G_TYPED_KERNEL(GConcatVert, , "org.opencv.imgproc.transform.concatVert") { + static GMatDesc outMeta(GMatDesc t, GMatDesc b) { + return t.withSizeDelta(0, +b.size.height); + } + }; + + G_TYPED_KERNEL(GLUT, , "org.opencv.core.transform.LUT") { + static GMatDesc outMeta(GMatDesc in, Mat) { + return in; + } + }; + + G_TYPED_KERNEL(GConvertTo, , "org.opencv.core.transform.convertTo") { + static GMatDesc outMeta(GMatDesc in, int rdepth, double, double) { + return rdepth < 0 ? in : in.withDepth(rdepth); + } + }; + + G_TYPED_KERNEL(GSqrt, , "org.opencv.core.math.sqrt") { + static GMatDesc outMeta(GMatDesc in) { + return in; + } + }; + + G_TYPED_KERNEL(GNormalize, , "org.opencv.core.normalize") { + static GMatDesc outMeta(GMatDesc in, double, double, int, int ddepth) { + // unlike opencv doesn't have a mask as a parameter + return (ddepth < 0 ? in : in.withDepth(ddepth)); + } + }; + + G_TYPED_KERNEL(GWarpPerspective, , "org.opencv.core.warpPerspective") { + static GMatDesc outMeta(GMatDesc in, const Mat&, Size dsize, int, int borderMode, const cv::Scalar&) { + GAPI_Assert((borderMode == cv::BORDER_CONSTANT || borderMode == cv::BORDER_REPLICATE) && + "cv::gapi::warpPerspective supports only cv::BORDER_CONSTANT and cv::BORDER_REPLICATE border modes"); + return in.withType(in.depth, in.chan).withSize(dsize); + } + }; + + G_TYPED_KERNEL(GWarpAffine, , "org.opencv.core.warpAffine") { + static GMatDesc outMeta(GMatDesc in, const Mat&, Size dsize, int, int border_mode, const cv::Scalar&) { + GAPI_Assert(border_mode != cv::BORDER_TRANSPARENT && + "cv::BORDER_TRANSPARENT mode is not supported in cv::gapi::warpAffine"); + return in.withType(in.depth, in.chan).withSize(dsize); + } + }; + + G_TYPED_KERNEL( + GKMeansND, + ,GMat,GMat>(GMat,int,GMat,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeansND") { + + static std::tuple + outMeta(const GMatDesc& in, int K, const GMatDesc& bestLabels, const TermCriteria&, int, + KmeansFlags flags) { + GAPI_Assert(in.depth == CV_32F); + std::vector amount_n_dim = detail::checkVector(in); + int amount = amount_n_dim[0], dim = amount_n_dim[1]; + if (amount == -1) // Mat with height != 1, width != 1, channels != 1 given + { // which means that kmeans will consider the following: + amount = in.size.height; + dim = in.size.width * in.chan; + } + // kmeans sets these labels' sizes when no bestLabels given: + GMatDesc out_labels(CV_32S, 1, Size{1, amount}); + // kmeans always sets these centers' sizes: + GMatDesc centers (CV_32F, 1, Size{dim, K}); + if (flags & KMEANS_USE_INITIAL_LABELS) + { + GAPI_Assert(bestLabels.depth == CV_32S); + int labels_amount = detail::checkVector(bestLabels, 1u); + GAPI_Assert(labels_amount == amount); + out_labels = bestLabels; // kmeans preserves bestLabels' sizes if given + } + return std::make_tuple(empty_gopaque_desc(), out_labels, centers); + } + }; + + G_TYPED_KERNEL( + GKMeansNDNoInit, + ,GMat,GMat>(GMat,int,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeansNDNoInit") { + + static std::tuple + outMeta(const GMatDesc& in, int K, const TermCriteria&, int, KmeansFlags flags) { + GAPI_Assert( !(flags & KMEANS_USE_INITIAL_LABELS) ); + GAPI_Assert(in.depth == CV_32F); + std::vector amount_n_dim = detail::checkVector(in); + int amount = amount_n_dim[0], dim = amount_n_dim[1]; + if (amount == -1) // Mat with height != 1, width != 1, channels != 1 given + { // which means that kmeans will consider the following: + amount = in.size.height; + dim = in.size.width * in.chan; + } + GMatDesc out_labels(CV_32S, 1, Size{1, amount}); + GMatDesc centers (CV_32F, 1, Size{dim, K}); + return std::make_tuple(empty_gopaque_desc(), out_labels, centers); + } + }; + + G_TYPED_KERNEL(GKMeans2D, ,GArray,GArray> + (GArray,int,GArray,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeans2D") { + static std::tuple + outMeta(const GArrayDesc&,int,const GArrayDesc&,const TermCriteria&,int,KmeansFlags) { + return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GKMeans3D, ,GArray,GArray> + (GArray,int,GArray,TermCriteria,int,KmeansFlags)>, + "org.opencv.core.kmeans3D") { + static std::tuple + outMeta(const GArrayDesc&,int,const GArrayDesc&,const TermCriteria&,int,KmeansFlags) { + return std::make_tuple(empty_gopaque_desc(), empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GTranspose, , "org.opencv.core.transpose") { + static GMatDesc outMeta(GMatDesc in) { + return in.withSize({in.size.height, in.size.width}); + } + }; +} // namespace core + +namespace streaming { + +// Operations for Streaming (declared in this header for convenience) +G_TYPED_KERNEL(GSize, (GMat)>, "org.opencv.streaming.size") { + static GOpaqueDesc outMeta(const GMatDesc&) { + return empty_gopaque_desc(); + } +}; + +G_TYPED_KERNEL(GSizeR, (GOpaque)>, "org.opencv.streaming.sizeR") { + static GOpaqueDesc outMeta(const GOpaqueDesc&) { + return empty_gopaque_desc(); + } +}; + +G_TYPED_KERNEL(GSizeMF, (GFrame)>, "org.opencv.streaming.sizeMF") { + static GOpaqueDesc outMeta(const GFrameDesc&) { + return empty_gopaque_desc(); + } +}; +} // namespace streaming + +//! @addtogroup gapi_math +//! @{ + +/** @brief Calculates the per-element sum of two matrices. + +The function add calculates sum of two matrices of the same size and the same number of channels: +\f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f] + +The function can be replaced with matrix expressions: + \f[\texttt{dst} = \texttt{src1} + \texttt{src2}\f] + +The input matrices and the output matrix can all have the same or different depths. For example, you +can add a 16-bit unsigned matrix to a 8-bit signed matrix and store the sum as a 32-bit +floating-point matrix. Depth of the output matrix is determined by the ddepth parameter. +If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have +the same depth as the input matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.add" +@param src1 first input matrix. +@param src2 second input matrix. +@param ddepth optional depth of the output matrix. +@sa sub, addWeighted +*/ +GAPI_EXPORTS_W GMat add(const GMat& src1, const GMat& src2, int ddepth = -1); + +/** @brief Calculates the per-element sum of matrix and given scalar. + +The function addC adds a given scalar value to each element of given matrix. +The function can be replaced with matrix expressions: + + \f[\texttt{dst} = \texttt{src1} + \texttt{c}\f] + +Depth of the output matrix is determined by the ddepth parameter. +If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. +The matrices can be single or multi channel. Output matrix must have the same size and number of channels as the input matrix. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.addC" +@param src1 first input matrix. +@param c scalar value to be added. +@param ddepth optional depth of the output matrix. +@sa sub, addWeighted +*/ +GAPI_EXPORTS_W GMat addC(const GMat& src1, const GScalar& c, int ddepth = -1); +//! @overload +GAPI_EXPORTS GMat addC(const GScalar& c, const GMat& src1, int ddepth = -1); + +/** @brief Calculates the per-element difference between two matrices. + +The function sub calculates difference between two matrices, when both matrices have the same size and the same number of +channels: + \f[\texttt{dst}(I) = \texttt{src1}(I) - \texttt{src2}(I)\f] + +The function can be replaced with matrix expressions: +\f[\texttt{dst} = \texttt{src1} - \texttt{src2}\f] + +The input matrices and the output matrix can all have the same or different depths. For example, you +can subtract two 8-bit unsigned matrices store the result as a 16-bit signed matrix. +Depth of the output matrix is determined by the ddepth parameter. +If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have +the same depth as the input matrices. The matrices can be single or multi channel. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.sub" +@param src1 first input matrix. +@param src2 second input matrix. +@param ddepth optional depth of the output matrix. +@sa add, addC + */ +GAPI_EXPORTS GMat sub(const GMat& src1, const GMat& src2, int ddepth = -1); + +/** @brief Calculates the per-element difference between matrix and given scalar. + +The function can be replaced with matrix expressions: + \f[\texttt{dst} = \texttt{src} - \texttt{c}\f] + +Depth of the output matrix is determined by the ddepth parameter. +If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. +The matrices can be single or multi channel. Output matrix must have the same size as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.subC" +@param src first input matrix. +@param c scalar value to subtracted. +@param ddepth optional depth of the output matrix. +@sa add, addC, subRC + */ +GAPI_EXPORTS GMat subC(const GMat& src, const GScalar& c, int ddepth = -1); + +/** @brief Calculates the per-element difference between given scalar and the matrix. + +The function can be replaced with matrix expressions: + \f[\texttt{dst} = \texttt{c} - \texttt{src}\f] + +Depth of the output matrix is determined by the ddepth parameter. +If ddepth is set to default -1, the depth of output matrix will be the same as the depth of input matrix. +The matrices can be single or multi channel. Output matrix must have the same size as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.subRC" +@param c scalar value to subtract from. +@param src input matrix to be subtracted. +@param ddepth optional depth of the output matrix. +@sa add, addC, subC + */ +GAPI_EXPORTS GMat subRC(const GScalar& c, const GMat& src, int ddepth = -1); + +/** @brief Calculates the per-element scaled product of two matrices. + +The function mul calculates the per-element product of two matrices: + +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\f] + +If src1.depth() == src2.depth(), ddepth can be set to the default -1. In this case, the output matrix will have +the same depth as the input matrices. The matrices can be single or multi channel. +Output matrix must have the same size as input matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.mul" +@param src1 first input matrix. +@param src2 second input matrix of the same size and the same depth as src1. +@param scale optional scale factor. +@param ddepth optional depth of the output matrix. +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat mul(const GMat& src1, const GMat& src2, double scale = 1.0, int ddepth = -1); + +/** @brief Multiplies matrix by scalar. + +The function mulC multiplies each element of matrix src by given scalar value: + +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I) \cdot \texttt{multiplier} )\f] + +The matrices can be single or multi channel. Output matrix must have the same size as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.mulC" +@param src input matrix. +@param multiplier factor to be multiplied. +@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth. +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat mulC(const GMat& src, double multiplier, int ddepth = -1); +//! @overload +GAPI_EXPORTS GMat mulC(const GMat& src, const GScalar& multiplier, int ddepth = -1); // FIXME: merge with mulc +//! @overload +GAPI_EXPORTS GMat mulC(const GScalar& multiplier, const GMat& src, int ddepth = -1); // FIXME: merge with mulc + +/** @brief Performs per-element division of two matrices. + +The function divides one matrix by another: +\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f] + +For integer types when src2(I) is zero, dst(I) will also be zero. +Floating point case returns Inf/NaN (according to IEEE). + +Different channels of +multi-channel matrices are processed independently. +The matrices can be single or multi channel. Output matrix must have the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.div" +@param src1 first input matrix. +@param src2 second input matrix of the same size and depth as src1. +@param scale scalar factor. +@param ddepth optional depth of the output matrix; you can only pass -1 when src1.depth() == src2.depth(). +@sa mul, add, sub +*/ +GAPI_EXPORTS GMat div(const GMat& src1, const GMat& src2, double scale, int ddepth = -1); + +/** @brief Divides matrix by scalar. + +The function divC divides each element of matrix src by given scalar value: + +\f[\texttt{dst(I) = saturate(src(I)*scale/divisor)}\f] + +When divisor is zero, dst(I) will also be zero. Different channels of +multi-channel matrices are processed independently. +The matrices can be single or multi channel. Output matrix must have the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.divC" +@param src input matrix. +@param divisor number to be divided by. +@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth. +@param scale scale factor. +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat divC(const GMat& src, const GScalar& divisor, double scale, int ddepth = -1); + +/** @brief Divides scalar by matrix. + +The function divRC divides given scalar by each element of matrix src and keep the division result in new matrix of the same size and type as src: + +\f[\texttt{dst(I) = saturate(divident*scale/src(I))}\f] + +When src(I) is zero, dst(I) will also be zero. Different channels of +multi-channel matrices are processed independently. +The matrices can be single or multi channel. Output matrix must have the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.divRC" +@param src input matrix. +@param divident number to be divided. +@param ddepth optional depth of the output matrix. If -1, the depth of output matrix will be the same as input matrix depth. +@param scale scale factor +@sa add, sub, div, addWeighted +*/ +GAPI_EXPORTS GMat divRC(const GScalar& divident, const GMat& src, double scale, int ddepth = -1); + +/** @brief Applies a mask to a matrix. + +The function mask set value from given matrix if the corresponding pixel value in mask matrix set to true, +and set the matrix value to 0 otherwise. + +Supported src matrix data types are @ref CV_8UC1, @ref CV_16SC1, @ref CV_16UC1. Supported mask data type is @ref CV_8UC1. + +@note Function textual ID is "org.opencv.core.math.mask" +@param src input matrix. +@param mask input mask matrix. +*/ +GAPI_EXPORTS GMat mask(const GMat& src, const GMat& mask); + +/** @brief Calculates an average (mean) of matrix elements. + +The function mean calculates the mean value M of matrix elements, +independently for each channel, and return it. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.math.mean" +@param src input matrix. +@sa countNonZero, min, max +*/ +GAPI_EXPORTS_W GScalar mean(const GMat& src); + +/** @brief Calculates x and y coordinates of 2D vectors from their magnitude and angle. + +The function polarToCart calculates the Cartesian coordinates of each 2D +vector represented by the corresponding elements of magnitude and angle: +\f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\f] + +The relative accuracy of the estimated coordinates is about 1e-6. + +First output is a matrix of x-coordinates of 2D vectors. +Second output is a matrix of y-coordinates of 2D vectors. +Both output must have the same size and depth as input matrices. + +@note Function textual ID is "org.opencv.core.math.polarToCart" + +@param magnitude input floating-point @ref CV_32FC1 matrix (1xN) of magnitudes of 2D vectors; +@param angle input floating-point @ref CV_32FC1 matrix (1xN) of angles of 2D vectors. +@param angleInDegrees when true, the input angles are measured in +degrees, otherwise, they are measured in radians. +@sa cartToPolar, exp, log, pow, sqrt +*/ +GAPI_EXPORTS std::tuple polarToCart(const GMat& magnitude, const GMat& angle, + bool angleInDegrees = false); + +/** @brief Calculates the magnitude and angle of 2D vectors. + +The function cartToPolar calculates either the magnitude, angle, or both +for every 2D vector (x(I),y(I)): +\f[\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f] + +The angles are calculated with accuracy about 0.3 degrees. For the point +(0,0), the angle is set to 0. + +First output is a matrix of magnitudes of the same size and depth as input x. +Second output is a matrix of angles that has the same size and depth as +x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees). + +@note Function textual ID is "org.opencv.core.math.cartToPolar" + +@param x matrix of @ref CV_32FC1 x-coordinates. +@param y array of @ref CV_32FC1 y-coordinates. +@param angleInDegrees a flag, indicating whether the angles are measured +in radians (which is by default), or in degrees. +@sa polarToCart +*/ +GAPI_EXPORTS std::tuple cartToPolar(const GMat& x, const GMat& y, + bool angleInDegrees = false); + +/** @brief Calculates the rotation angle of 2D vectors. + +The function cv::phase calculates the rotation angle of each 2D vector that +is formed from the corresponding elements of x and y : +\f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f] + +The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 , +the corresponding angle(I) is set to 0. +@param x input floating-point array of x-coordinates of 2D vectors. +@param y input array of y-coordinates of 2D vectors; it must have the +same size and the same type as x. +@param angleInDegrees when true, the function calculates the angle in +degrees, otherwise, they are measured in radians. +@return array of vector angles; it has the same size and same type as x. +*/ +GAPI_EXPORTS GMat phase(const GMat& x, const GMat &y, bool angleInDegrees = false); + +/** @brief Calculates a square root of array elements. + +The function cv::gapi::sqrt calculates a square root of each input array element. +In case of multi-channel arrays, each channel is processed +independently. The accuracy is approximately the same as of the built-in +std::sqrt . +@param src input floating-point array. +@return output array of the same size and type as src. +*/ +GAPI_EXPORTS GMat sqrt(const GMat &src); + +//! @} gapi_math +//! +//! @addtogroup gapi_pixelwise +//! @{ + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater compare to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) > \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: +\f[\texttt{dst} = \texttt{src1} > \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices/matrix. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGT" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpLE, cmpGE, cmpLT +*/ +GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGTScalar" +*/ +GAPI_EXPORTS GMat cmpGT(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less than elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) < \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} < \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices/matrix. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLT" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpLE, cmpGE, cmpGT +*/ +GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLTScalar" +*/ +GAPI_EXPORTS GMat cmpLT(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are greater or equal compare to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) >= \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} >= \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpGE" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpLE, cmpGT, cmpLT +*/ +GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLGEcalar" +*/ +GAPI_EXPORTS GMat cmpGE(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are less or equal compare to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) <= \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} <= \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLE" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpGT, cmpGE, cmpLT +*/ +GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpLEScalar" +*/ +GAPI_EXPORTS GMat cmpLE(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are equal to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) == \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} == \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQ" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpNE +*/ +GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpEQScalar" +*/ +GAPI_EXPORTS GMat cmpEQ(const GMat& src1, const GScalar& src2); + +/** @brief Performs the per-element comparison of two matrices checking if elements from first matrix are not equal to elements in second. + +The function compares elements of two matrices src1 and src2 of the same size: + \f[\texttt{dst} (I) = \texttt{src1} (I) != \texttt{src2} (I)\f] + +When the comparison result is true, the corresponding element of output +array is set to 255. The comparison operations can be replaced with the +equivalent matrix expressions: + \f[\texttt{dst} = \texttt{src1} != \texttt{src2}\f] + +Output matrix of depth @ref CV_8U must have the same size and the same number of channels as + the input matrices. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNE" +@param src1 first input matrix. +@param src2 second input matrix/scalar of the same depth as first input matrix. +@sa min, max, threshold, cmpEQ +*/ +GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.compare.cmpNEScalar" +*/ +GAPI_EXPORTS GMat cmpNE(const GMat& src1, const GScalar& src2); + +/** @brief computes bitwise conjunction of the two matrixes (src1 & src2) +Calculates the per-element bit-wise logical conjunction of two matrices of the same size. + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_and" + +@param src1 first input matrix. +@param src2 second input matrix. +*/ +GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_andS" +@param src1 first input matrix. +@param src2 scalar, which will be per-lemenetly conjuncted with elements of src1. +*/ +GAPI_EXPORTS GMat bitwise_and(const GMat& src1, const GScalar& src2); + +/** @brief computes bitwise disjunction of the two matrixes (src1 | src2) +Calculates the per-element bit-wise logical disjunction of two matrices of the same size. + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_or" + +@param src1 first input matrix. +@param src2 second input matrix. +*/ +GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_orS" +@param src1 first input matrix. +@param src2 scalar, which will be per-lemenetly disjuncted with elements of src1. +*/ +GAPI_EXPORTS GMat bitwise_or(const GMat& src1, const GScalar& src2); + + +/** @brief computes bitwise logical "exclusive or" of the two matrixes (src1 ^ src2) +Calculates the per-element bit-wise logical "exclusive or" of two matrices of the same size. + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_xor" + +@param src1 first input matrix. +@param src2 second input matrix. +*/ +GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GMat& src2); +/** @overload +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_xorS" +@param src1 first input matrix. +@param src2 scalar, for which per-lemenet "logical or" operation on elements of src1 will be performed. +*/ +GAPI_EXPORTS GMat bitwise_xor(const GMat& src1, const GScalar& src2); + + +/** @brief Inverts every bit of an array. + +The function bitwise_not calculates per-element bit-wise inversion of the input +matrix: +\f[\texttt{dst} (I) = \neg \texttt{src} (I)\f] + +In case of floating-point matrices, their machine-specific bit +representations (usually IEEE754-compliant) are used for the operation. +In case of multi-channel matrices, each channel is processed +independently. Output matrix must have the same size and depth as the input +matrix. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.bitwise_not" + +@param src input matrix. +*/ +GAPI_EXPORTS GMat bitwise_not(const GMat& src); + +/** @brief Select values from either first or second of input matrices by given mask. +The function set to the output matrix either the value from the first input matrix if corresponding value of mask matrix is 255, + or value from the second input matrix (if value of mask matrix set to 0). + +Input mask matrix must be of @ref CV_8UC1 type, two other inout matrices and output matrix should be of the same type. The size should +be the same for all input and output matrices. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.pixelwise.select" + +@param src1 first input matrix. +@param src2 second input matrix. +@param mask mask input matrix. +*/ +GAPI_EXPORTS GMat select(const GMat& src1, const GMat& src2, const GMat& mask); + +//! @} gapi_pixelwise + + +//! @addtogroup gapi_matrixop +//! @{ +/** @brief Calculates per-element minimum of two matrices. + +The function min calculates the per-element minimum of two matrices of the same size, number of channels and depth: +\f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f] + where I is a multi-dimensional index of matrix elements. In case of + multi-channel matrices, each channel is processed independently. +Output matrix must be of the same size and depth as src1. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.min" +@param src1 first input matrix. +@param src2 second input matrix of the same size and depth as src1. +@sa max, cmpEQ, cmpLT, cmpLE +*/ +GAPI_EXPORTS GMat min(const GMat& src1, const GMat& src2); + +/** @brief Calculates per-element maximum of two matrices. + +The function max calculates the per-element maximum of two matrices of the same size, number of channels and depth: +\f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f] + where I is a multi-dimensional index of matrix elements. In case of + multi-channel matrices, each channel is processed independently. +Output matrix must be of the same size and depth as src1. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.max" +@param src1 first input matrix. +@param src2 second input matrix of the same size and depth as src1. +@sa min, compare, cmpEQ, cmpGT, cmpGE +*/ +GAPI_EXPORTS GMat max(const GMat& src1, const GMat& src2); + +/** @brief Calculates the per-element absolute difference between two matrices. + +The function absDiff calculates absolute difference between two matrices of the same size and depth: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f] + where I is a multi-dimensional index of matrix elements. In case of + multi-channel matrices, each channel is processed independently. +Output matrix must have the same size and depth as input matrices. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.absdiff" +@param src1 first input matrix. +@param src2 second input matrix. +@sa abs +*/ +GAPI_EXPORTS GMat absDiff(const GMat& src1, const GMat& src2); + +/** @brief Calculates absolute value of matrix elements. + +The function abs calculates absolute difference between matrix elements and given scalar value: + \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{matC}(I)|)\f] + where matC is constructed from given scalar c and has the same sizes and depth as input matrix src. + +Output matrix must be of the same size and depth as src. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.absdiffC" +@param src input matrix. +@param c scalar to be subtracted. +@sa min, max +*/ +GAPI_EXPORTS GMat absDiffC(const GMat& src, const GScalar& c); + +/** @brief Calculates sum of all matrix elements. + +The function sum calculates sum of all matrix elements, independently for each channel. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.sum" +@param src input matrix. +@sa countNonZero, mean, min, max +*/ +GAPI_EXPORTS GScalar sum(const GMat& src); + +/** @brief Counts non-zero array elements. + +The function returns the number of non-zero elements in src : +\f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f] + +Supported matrix data types are @ref CV_8UC1, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.countNonZero" +@param src input single-channel matrix. +@sa mean, min, max +*/ +GAPI_EXPORTS GOpaque countNonZero(const GMat& src); + +/** @brief Calculates the weighted sum of two matrices. + +The function addWeighted calculates the weighted sum of two matrices as follows: +\f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] +where I is a multi-dimensional index of array elements. In case of multi-channel matrices, each +channel is processed independently. + +The function can be replaced with a matrix expression: + \f[\texttt{dst}(I) = \texttt{alpha} * \texttt{src1}(I) - \texttt{beta} * \texttt{src2}(I) + \texttt{gamma} \f] + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.addweighted" +@param src1 first input matrix. +@param alpha weight of the first matrix elements. +@param src2 second input matrix of the same size and channel number as src1. +@param beta weight of the second matrix elements. +@param gamma scalar added to each sum. +@param ddepth optional depth of the output matrix. +@sa add, sub +*/ +GAPI_EXPORTS GMat addWeighted(const GMat& src1, double alpha, const GMat& src2, double beta, double gamma, int ddepth = -1); + +/** @brief Calculates the absolute L1 norm of a matrix. + +This version of normL1 calculates the absolute L1 norm of src. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{1} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\ +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\ +\f} + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.norml1" +@param src input matrix. +@sa normL2, normInf +*/ +GAPI_EXPORTS GScalar normL1(const GMat& src); + +/** @brief Calculates the absolute L2 norm of a matrix. + +This version of normL2 calculates the absolute L2 norm of src. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{2} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\ +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\ +\f} + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +@note Function textual ID is "org.opencv.core.matrixop.norml2" +@param src input matrix. +@sa normL1, normInf +*/ +GAPI_EXPORTS GScalar normL2(const GMat& src); + +/** @brief Calculates the absolute infinite norm of a matrix. + +This version of normInf calculates the absolute infinite norm of src. + +As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$. +The \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ +is calculated as follows +\f{align*} + \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2 +\f} +and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is +\f{align*} + \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5. +\f} + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.core.matrixop.norminf" +@param src input matrix. +@sa normL1, normL2 +*/ +GAPI_EXPORTS GScalar normInf(const GMat& src); + +/** @brief Calculates the integral of an image. + +The function calculates one or more integral images for the source image as follows: + +\f[\texttt{sum} (X,Y) = \sum _{x integral(const GMat& src, int sdepth = -1, int sqdepth = -1); + +/** @brief Applies a fixed-level threshold to each matrix element. + +The function applies fixed-level thresholding to a single- or multiple-channel matrix. +The function is typically used to get a bi-level (binary) image out of a grayscale image ( cmp functions could be also used for +this purpose) or for removing a noise, that is, filtering out pixels with too small or too large +values. There are several types of thresholding supported by the function. They are determined by +type parameter. + +Also, the special values cv::THRESH_OTSU or cv::THRESH_TRIANGLE may be combined with one of the +above values. In these cases, the function determines the optimal threshold value using the Otsu's +or Triangle algorithm and uses it instead of the specified thresh . The function returns the +computed threshold value in addititon to thresholded matrix. +The Otsu's and Triangle methods are implemented only for 8-bit matrices. + +Input image should be single channel only in case of cv::THRESH_OTSU or cv::THRESH_TRIANGLE flags. +Output matrix must be of the same size and depth as src. + +@note Function textual ID is "org.opencv.core.matrixop.threshold" + +@param src input matrix (@ref CV_8UC1, @ref CV_8UC3, or @ref CV_32FC1). +@param thresh threshold value. +@param maxval maximum value to use with the cv::THRESH_BINARY and cv::THRESH_BINARY_INV thresholding +types. +@param type thresholding type (see the cv::ThresholdTypes). + +@sa min, max, cmpGT, cmpLE, cmpGE, cmpLT + */ +GAPI_EXPORTS GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type); +/** @overload +This function applicable for all threshold types except CV_THRESH_OTSU and CV_THRESH_TRIANGLE +@note Function textual ID is "org.opencv.core.matrixop.thresholdOT" +*/ +GAPI_EXPORTS_W std::tuple threshold(const GMat& src, const GScalar& maxval, int type); + +/** @brief Applies a range-level threshold to each matrix element. + +The function applies range-level thresholding to a single- or multiple-channel matrix. +It sets output pixel value to OxFF if the corresponding pixel value of input matrix is in specified range,or 0 otherwise. + +Input and output matrices must be CV_8UC1. + +@note Function textual ID is "org.opencv.core.matrixop.inRange" + +@param src input matrix (CV_8UC1). +@param threshLow lower boundary value. +@param threshUp upper boundary value. + +@sa threshold + */ +GAPI_EXPORTS GMat inRange(const GMat& src, const GScalar& threshLow, const GScalar& threshUp); + +//! @} gapi_matrixop + +//! @addtogroup gapi_transform +//! @{ +/** @brief Resizes an image. + +The function resizes the image src down to or up to the specified size. + +Output image size will have the size dsize (when dsize is non-zero) or the size computed from +src.size(), fx, and fy; the depth of output is the same as of src. + +If you want to resize src so that it fits the pre-created dst, +you may call the function as follows: +@code + // explicitly specify dsize=dst.size(); fx and fy will be computed from that. + resize(src, dst, dst.size(), 0, 0, interpolation); +@endcode +If you want to decimate the image by factor of 2 in each direction, you can call the function this +way: +@code + // specify fx and fy and let the function compute the destination image size. + resize(src, dst, Size(), 0.5, 0.5, interpolation); +@endcode +To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to +enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR +(faster but still looks OK). + +@note Function textual ID is "org.opencv.core.transform.resize" + +@param src input image. +@param dsize output image size; if it equals zero, it is computed as: + \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f] + Either dsize or both fx and fy must be non-zero. +@param fx scale factor along the horizontal axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.width/src.cols}\f] +@param fy scale factor along the vertical axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.height/src.rows}\f] +@param interpolation interpolation method, see cv::InterpolationFlags + +@sa warpAffine, warpPerspective, remap, resizeP + */ +GAPI_EXPORTS_W GMat resize(const GMat& src, const Size& dsize, double fx = 0, double fy = 0, int interpolation = INTER_LINEAR); + +/** @brief Resizes a planar image. + +The function resizes the image src down to or up to the specified size. +Planar image memory layout is three planes laying in the memory contiguously, +so the image height should be plane_height*plane_number, image type is @ref CV_8UC1. + +Output image size will have the size dsize, the depth of output is the same as of src. + +@note Function textual ID is "org.opencv.core.transform.resizeP" + +@param src input image, must be of @ref CV_8UC1 type; +@param dsize output image size; +@param interpolation interpolation method, only cv::INTER_LINEAR is supported at the moment + +@sa warpAffine, warpPerspective, remap, resize + */ +GAPI_EXPORTS GMatP resizeP(const GMatP& src, const Size& dsize, int interpolation = cv::INTER_LINEAR); + +/** @brief Creates one 4-channel matrix out of 4 single-channel ones. + +The function merges several matrices to make a single multi-channel matrix. That is, each +element of the output matrix will be a concatenation of the elements of the input matrices, where +elements of i-th input matrix are treated as mv[i].channels()-element vectors. +Output matrix must be of @ref CV_8UC4 type. + +The function split4 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.merge4" + +@param src1 first input @ref CV_8UC1 matrix to be merged. +@param src2 second input @ref CV_8UC1 matrix to be merged. +@param src3 third input @ref CV_8UC1 matrix to be merged. +@param src4 fourth input @ref CV_8UC1 matrix to be merged. +@sa merge3, split4, split3 +*/ +GAPI_EXPORTS GMat merge4(const GMat& src1, const GMat& src2, const GMat& src3, const GMat& src4); + +/** @brief Creates one 3-channel matrix out of 3 single-channel ones. + +The function merges several matrices to make a single multi-channel matrix. That is, each +element of the output matrix will be a concatenation of the elements of the input matrices, where +elements of i-th input matrix are treated as mv[i].channels()-element vectors. +Output matrix must be of @ref CV_8UC3 type. + +The function split3 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.merge3" + +@param src1 first input @ref CV_8UC1 matrix to be merged. +@param src2 second input @ref CV_8UC1 matrix to be merged. +@param src3 third input @ref CV_8UC1 matrix to be merged. +@sa merge4, split4, split3 +*/ +GAPI_EXPORTS GMat merge3(const GMat& src1, const GMat& src2, const GMat& src3); + +/** @brief Divides a 4-channel matrix into 4 single-channel matrices. + +The function splits a 4-channel matrix into 4 single-channel matrices: +\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f] + +All output matrices must be of @ref CV_8UC1 type. + +The function merge4 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.split4" + +@param src input @ref CV_8UC4 matrix. +@sa split3, merge3, merge4 +*/ +GAPI_EXPORTS std::tuple split4(const GMat& src); + +/** @brief Divides a 3-channel matrix into 3 single-channel matrices. + +The function splits a 3-channel matrix into 3 single-channel matrices: +\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f] + +All output matrices must be of @ref CV_8UC1 type. + +The function merge3 does the reverse operation. + +@note + - Function textual ID is "org.opencv.core.transform.split3" + +@param src input @ref CV_8UC3 matrix. +@sa split4, merge3, merge4 +*/ +GAPI_EXPORTS_W std::tuple split3(const GMat& src); + +/** @brief Applies a generic geometrical transformation to an image. + +The function remap transforms the source image using the specified map: + +\f[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\f] + +where values of pixels with non-integer coordinates are computed using one of available +interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps +in \f$map_1\f$ and \f$map_2\f$ respectively, or interleaved floating-point maps of \f$(x,y)\f$ in +\f$map_1\f$, or fixed-point maps created by using convertMaps. The reason you might want to +convert from floating to fixed-point representations of a map is that they can yield much faster +(\~2x) remapping operations. In the converted case, \f$map_1\f$ contains pairs (cvFloor(x), +cvFloor(y)) and \f$map_2\f$ contains indices in a table of interpolation coefficients. +Output image must be of the same size and depth as input one. + +@note + - Function textual ID is "org.opencv.core.transform.remap" + - Due to current implementation limitations the size of an input and output images should be less than 32767x32767. + +@param src Source image. +@param map1 The first map of either (x,y) points or just x values having the type CV_16SC2, +CV_32FC1, or CV_32FC2. +@param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map +if map1 is (x,y) points), respectively. +@param interpolation Interpolation method (see cv::InterpolationFlags). The methods #INTER_AREA +and #INTER_LINEAR_EXACT are not supported by this function. +@param borderMode Pixel extrapolation method (see cv::BorderTypes). When +borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image that +corresponds to the "outliers" in the source image are not modified by the function. +@param borderValue Value used in case of a constant border. By default, it is 0. + */ +GAPI_EXPORTS GMat remap(const GMat& src, const Mat& map1, const Mat& map2, + int interpolation, int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @brief Flips a 2D matrix around vertical, horizontal, or both axes. + +The function flips the matrix in one of three different ways (row +and column indices are 0-based): +\f[\texttt{dst} _{ij} = +\left\{ +\begin{array}{l l} +\texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\ +\texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\ +\texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\ +\end{array} +\right.\f] +The example scenarios of using the function are the following: +* Vertical flipping of the image (flipCode == 0) to switch between + top-left and bottom-left image origin. This is a typical operation + in video processing on Microsoft Windows\* OS. +* Horizontal flipping of the image with the subsequent horizontal + shift and absolute difference calculation to check for a + vertical-axis symmetry (flipCode \> 0). +* Simultaneous horizontal and vertical flipping of the image with + the subsequent shift and absolute difference calculation to check + for a central symmetry (flipCode \< 0). +* Reversing the order of point arrays (flipCode \> 0 or + flipCode == 0). +Output image must be of the same depth as input one, size should be correct for given flipCode. + +@note Function textual ID is "org.opencv.core.transform.flip" + +@param src input matrix. +@param flipCode a flag to specify how to flip the array; 0 means +flipping around the x-axis and positive value (for example, 1) means +flipping around y-axis. Negative value (for example, -1) means flipping +around both axes. +@sa remap +*/ +GAPI_EXPORTS GMat flip(const GMat& src, int flipCode); + +/** @brief Crops a 2D matrix. + +The function crops the matrix by given cv::Rect. + +Output matrix must be of the same depth as input one, size is specified by given rect size. + +@note Function textual ID is "org.opencv.core.transform.crop" + +@param src input matrix. +@param rect a rect to crop a matrix to +@sa resize +*/ +GAPI_EXPORTS GMat crop(const GMat& src, const Rect& rect); + +/** @brief Applies horizontal concatenation to given matrices. + +The function horizontally concatenates two GMat matrices (with the same number of rows). +@code{.cpp} + GMat A = { 1, 4, + 2, 5, + 3, 6 }; + GMat B = { 7, 10, + 8, 11, + 9, 12 }; + + GMat C = gapi::concatHor(A, B); + //C: + //[1, 4, 7, 10; + // 2, 5, 8, 11; + // 3, 6, 9, 12] +@endcode +Output matrix must the same number of rows and depth as the src1 and src2, and the sum of cols of the src1 and src2. +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.imgproc.transform.concatHor" + +@param src1 first input matrix to be considered for horizontal concatenation. +@param src2 second input matrix to be considered for horizontal concatenation. +@sa concatVert +*/ +GAPI_EXPORTS GMat concatHor(const GMat& src1, const GMat& src2); + +/** @overload +The function horizontally concatenates given number of GMat matrices (with the same number of columns). +Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices. + +@param v vector of input matrices to be concatenated horizontally. +*/ +GAPI_EXPORTS GMat concatHor(const std::vector &v); + +/** @brief Applies vertical concatenation to given matrices. + +The function vertically concatenates two GMat matrices (with the same number of cols). + @code{.cpp} + GMat A = { 1, 7, + 2, 8, + 3, 9 }; + GMat B = { 4, 10, + 5, 11, + 6, 12 }; + + GMat C = gapi::concatVert(A, B); + //C: + //[1, 7; + // 2, 8; + // 3, 9; + // 4, 10; + // 5, 11; + // 6, 12] + @endcode + +Output matrix must the same number of cols and depth as the src1 and src2, and the sum of rows of the src1 and src2. +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. + +@note Function textual ID is "org.opencv.imgproc.transform.concatVert" + +@param src1 first input matrix to be considered for vertical concatenation. +@param src2 second input matrix to be considered for vertical concatenation. +@sa concatHor +*/ +GAPI_EXPORTS GMat concatVert(const GMat& src1, const GMat& src2); + +/** @overload +The function vertically concatenates given number of GMat matrices (with the same number of columns). +Output matrix must the same number of columns and depth as the input matrices, and the sum of rows of input matrices. + +@param v vector of input matrices to be concatenated vertically. +*/ +GAPI_EXPORTS GMat concatVert(const std::vector &v); + + +/** @brief Performs a look-up table transform of a matrix. + +The function LUT fills the output matrix with values from the look-up table. Indices of the entries +are taken from the input matrix. That is, the function processes each element of src as follows: +\f[\texttt{dst} (I) \leftarrow \texttt{lut(src(I))}\f] + +Supported matrix data types are @ref CV_8UC1. +Output is a matrix of the same size and number of channels as src, and the same depth as lut. + +@note Function textual ID is "org.opencv.core.transform.LUT" + +@param src input matrix of 8-bit elements. +@param lut look-up table of 256 elements; in case of multi-channel input array, the table should +either have a single channel (in this case the same table is used for all channels) or the same +number of channels as in the input matrix. +*/ +GAPI_EXPORTS GMat LUT(const GMat& src, const Mat& lut); + +/** @brief Converts a matrix to another data depth with optional scaling. + +The method converts source pixel values to the target data depth. saturate_cast\<\> is applied at +the end to avoid possible overflows: + +\f[m(x,y) = saturate \_ cast( \alpha (*this)(x,y) + \beta )\f] +Output matrix must be of the same size as input one. + +@note Function textual ID is "org.opencv.core.transform.convertTo" +@param src input matrix to be converted from. +@param rdepth desired output matrix depth or, rather, the depth since the number of channels are the +same as the input has; if rdepth is negative, the output matrix will have the same depth as the input. +@param alpha optional scale factor. +@param beta optional delta added to the scaled values. + */ +GAPI_EXPORTS GMat convertTo(const GMat& src, int rdepth, double alpha=1, double beta=0); + +/** @brief Normalizes the norm or value range of an array. + +The function normalizes scale and shift the input array elements so that +\f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f] +(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that +\f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f] +when normType=NORM_MINMAX (for dense arrays only). + +@note Function textual ID is "org.opencv.core.normalize" + +@param src input array. +@param alpha norm value to normalize to or the lower range boundary in case of the range +normalization. +@param beta upper range boundary in case of the range normalization; it is not used for the norm +normalization. +@param norm_type normalization type (see cv::NormTypes). +@param ddepth when negative, the output array has the same type as src; otherwise, it has the same +number of channels as src and the depth =ddepth. +@sa norm, Mat::convertTo +*/ +GAPI_EXPORTS GMat normalize(const GMat& src, double alpha, double beta, + int norm_type, int ddepth = -1); + +/** @brief Applies a perspective transformation to an image. + +The function warpPerspective transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , + \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert +and then put in the formula above instead of M. The function cannot operate in-place. + +@param src input image. +@param M \f$3\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the +optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). +@param borderValue value used in case of a constant border; by default, it equals 0. + +@sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform + */ +GAPI_EXPORTS GMat warpPerspective(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR, + int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar()); + +/** @brief Applies an affine transformation to an image. + +The function warpAffine transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted +with #invertAffineTransform and then put in the formula above instead of M. The function cannot +operate in-place. + +@param src input image. +@param M \f$2\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (see #InterpolationFlags) and the optional +flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (see #BorderTypes); +borderMode=#BORDER_TRANSPARENT isn't supported +@param borderValue value used in case of a constant border; by default, it is 0. + +@sa warpPerspective, resize, remap, getRectSubPix, transform + */ +GAPI_EXPORTS GMat warpAffine(const GMat& src, const Mat& M, const Size& dsize, int flags = cv::INTER_LINEAR, + int borderMode = cv::BORDER_CONSTANT, const Scalar& borderValue = Scalar()); +//! @} gapi_transform + +/** @brief Finds centers of clusters and groups input samples around the clusters. + +The function kmeans implements a k-means algorithm that finds the centers of K clusters +and groups the input samples around the clusters. As an output, \f$\texttt{bestLabels}_i\f$ +contains a 0-based cluster index for the \f$i^{th}\f$ sample. + +@note + - Function textual ID is "org.opencv.core.kmeansND" + - In case of an N-dimentional points' set given, input GMat can have the following traits: +2 dimensions, a single row or column if there are N channels, +or N columns if there is a single channel. Mat should have @ref CV_32F depth. + - Although, if GMat with height != 1, width != 1, channels != 1 given as data, n-dimensional +samples are considered given in amount of A, where A = height, n = width * channels. + - In case of GMat given as data: + - the output labels are returned as 1-channel GMat with sizes +width = 1, height = A, where A is samples amount, or width = bestLabels.width, +height = bestLabels.height if bestLabels given; + - the cluster centers are returned as 1-channel GMat with sizes +width = n, height = K, where n is samples' dimentionality and K is clusters' amount. + - As one of possible usages, if you want to control the initial labels for each attempt +by yourself, you can utilize just the core of the function. To do that, set the number +of attempts to 1, initialize labels each time using a custom algorithm, pass them with the +( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best (most-compact) clustering. + +@param data Data for clustering. An array of N-Dimensional points with float coordinates is needed. +Function can take GArray, GArray for 2D and 3D cases or GMat for any +dimentionality and channels. +@param K Number of clusters to split the set by. +@param bestLabels Optional input integer array that can store the supposed initial cluster indices +for every sample. Used when ( flags = #KMEANS_USE_INITIAL_LABELS ) flag is set. +@param criteria The algorithm termination criteria, that is, the maximum number of iterations +and/or the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of +the cluster centers moves by less than criteria.epsilon on some iteration, the algorithm stops. +@param attempts Flag to specify the number of times the algorithm is executed using different +initial labellings. The algorithm returns the labels that yield the best compactness (see the first +function return value). +@param flags Flag that can take values of cv::KmeansFlags . + +@return + - Compactness measure that is computed as +\f[\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\f] +after every attempt. The best (minimum) value is chosen and the corresponding labels and the +compactness value are returned by the function. + - Integer array that stores the cluster indices for every sample. + - Array of the cluster centers. +*/ +GAPI_EXPORTS std::tuple,GMat,GMat> +kmeans(const GMat& data, const int K, const GMat& bestLabels, + const TermCriteria& criteria, const int attempts, const KmeansFlags flags); + +/** @overload +@note + - Function textual ID is "org.opencv.core.kmeansNDNoInit" + - #KMEANS_USE_INITIAL_LABELS flag must not be set while using this overload. + */ +GAPI_EXPORTS_W std::tuple,GMat,GMat> +kmeans(const GMat& data, const int K, const TermCriteria& criteria, const int attempts, + const KmeansFlags flags); + +/** @overload +@note Function textual ID is "org.opencv.core.kmeans2D" + */ +GAPI_EXPORTS_W std::tuple,GArray,GArray> +kmeans(const GArray& data, const int K, const GArray& bestLabels, + const TermCriteria& criteria, const int attempts, const KmeansFlags flags); + +/** @overload +@note Function textual ID is "org.opencv.core.kmeans3D" + */ +GAPI_EXPORTS std::tuple,GArray,GArray> +kmeans(const GArray& data, const int K, const GArray& bestLabels, + const TermCriteria& criteria, const int attempts, const KmeansFlags flags); + + +/** @brief Transposes a matrix. + +The function transposes the matrix: +\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f] + +@note + - Function textual ID is "org.opencv.core.transpose" + - No complex conjugation is done in case of a complex matrix. It should be done separately if needed. + +@param src input array. +*/ +GAPI_EXPORTS GMat transpose(const GMat& src); + + +namespace streaming { +/** @brief Gets dimensions from Mat. + +@note Function textual ID is "org.opencv.streaming.size" + +@param src Input tensor +@return Size (tensor dimensions). +*/ +GAPI_EXPORTS_W GOpaque size(const GMat& src); + +/** @overload +Gets dimensions from rectangle. + +@note Function textual ID is "org.opencv.streaming.sizeR" + +@param r Input rectangle. +@return Size (rectangle dimensions). +*/ +GAPI_EXPORTS_W GOpaque size(const GOpaque& r); + +/** @brief Gets dimensions from MediaFrame. + +@note Function textual ID is "org.opencv.streaming.sizeMF" + +@param src Input frame +@return Size (frame dimensions). +*/ +GAPI_EXPORTS GOpaque size(const GFrame& src); +} //namespace streaming +} //namespace gapi +} //namespace cv + +#endif //OPENCV_GAPI_CORE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/core.hpp new file mode 100644 index 0000000..ac08f91 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/core.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_CPU_CORE_API_HPP +#define OPENCV_GAPI_CPU_CORE_API_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { +namespace gapi { +namespace core { +namespace cpu { + +GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +} // namespace cpu +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_CORE_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/gcpukernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/gcpukernel.hpp new file mode 100644 index 0000000..48909a8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/gcpukernel.hpp @@ -0,0 +1,533 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GCPUKERNEL_HPP +#define OPENCV_GAPI_GCPUKERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include //suppress_unused_warning +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gimpl +{ + // Forward-declare an internal class + class GCPUExecutable; +} // namespace gimpl + +namespace gapi +{ +/** + * @brief This namespace contains G-API CPU backend functions, + * structures, and symbols. + */ +namespace cpu +{ + /** + * \addtogroup gapi_std_backends + * @{ + * + * @brief G-API backends available in this OpenCV version + * + * G-API backends play a corner stone role in G-API execution + * stack. Every backend is hardware-oriented and thus can run its + * kernels efficiently on the target platform. + * + * Backends are usually "black boxes" for G-API users -- on the API + * side, all backends are represented as different objects of the + * same class cv::gapi::GBackend. + * User can manipulate with backends by specifying which kernels to use. + * + * @sa @ref gapi_hld + */ + + /** + * @brief Get a reference to CPU (OpenCV) backend. + * + * This is the default backend in G-API at the moment, providing + * broader functional coverage but losing some graph model + * advantages. Provided mostly for reference and prototyping + * purposes. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ + + class GOCVFunctor; + + //! @cond IGNORED + template + GOCVFunctor ocv_kernel(const Callable& c); + + template + GOCVFunctor ocv_kernel(Callable& c); + //! @endcond + +} // namespace cpu +} // namespace gapi + +// Represents arguments which are passed to a wrapped CPU function +// FIXME: put into detail? +class GAPI_EXPORTS GCPUContext +{ +public: + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const cv::Mat& inMat(int input); + cv::Mat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR() + + const cv::Scalar& inVal(int input); + cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR() + cv::MediaFrame& outFrame(int output); + template std::vector& outVecR(int output) // FIXME: the same issue + { + return outVecRef(output).wref(); + } + template T& outOpaqueR(int output) // FIXME: the same issue + { + return outOpaqueRef(output).wref(); + } + + GArg state() + { + return m_state; + } + +protected: + detail::VectorRef& outVecRef(int output); + detail::OpaqueRef& outOpaqueRef(int output); + + std::vector m_args; + GArg m_state; + + //FIXME: avoid conversion of arguments from internal representation to OpenCV one on each call + //to OCV kernel. (This can be achieved by a two single time conversions in GCPUExecutable::run, + //once on enter for input and output arguments, and once before return for output arguments only + std::unordered_map m_results; + + friend class gimpl::GCPUExecutable; +}; + +class GAPI_EXPORTS GCPUKernel +{ +public: + // This function is a kernel's execution entry point (does the processing work) + using RunF = std::function; + // This function is a stateful kernel's setup routine (configures state) + using SetupF = std::function; + + GCPUKernel(); + GCPUKernel(const RunF& runF, const SetupF& setupF = nullptr); + + RunF m_runF = nullptr; + SetupF m_setupF = nullptr; + + bool m_isStateful = false; +}; + +// FIXME: This is an ugly ad-hoc implementation. TODO: refactor + +namespace detail +{ +template struct get_in; +template<> struct get_in +{ + static cv::Mat get(GCPUContext &ctx, int idx) { return ctx.inMat(idx); } +}; +template<> struct get_in +{ + static cv::Mat get(GCPUContext &ctx, int idx) { return get_in::get(ctx, idx); } +}; +template<> struct get_in +{ + static cv::MediaFrame get(GCPUContext &ctx, int idx) { return ctx.inArg(idx); } +}; +template<> struct get_in +{ + static cv::Scalar get(GCPUContext &ctx, int idx) { return ctx.inVal(idx); } +}; +template struct get_in > +{ + static const std::vector& get(GCPUContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct get_in > +{ + static const U& get(GCPUContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; + +//FIXME(dm): GArray/GArray conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +//FIXME(dm): GArray/GArray conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +// FIXME(dm): GArray>/GArray> conversion should be done more gracefully in the system +template struct get_in> >: public get_in> > +{ +}; + +//FIXME(dm): GOpaque/GOpaque conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +//FIXME(dm): GOpaque/GOpaque conversion should be done more gracefully in the system +template<> struct get_in >: public get_in > +{ +}; + +template struct get_in +{ + static T get(GCPUContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +struct tracked_cv_mat{ + tracked_cv_mat(cv::Mat& m) : r{m}, original_data{m.data} {} + cv::Mat r; + uchar* original_data; + + operator cv::Mat& (){ return r;} + void validate() const{ + if (r.data != original_data) + { + util::throw_error + (std::logic_error + ("OpenCV kernel output parameter was reallocated. \n" + "Incorrect meta data was provided ?")); + } + } +}; + +template +void postprocess(Outputs&... outs) +{ + struct + { + void operator()(tracked_cv_mat* bm) { bm->validate(); } + void operator()(...) { } + + } validate; + //dummy array to unfold parameter pack + int dummy[] = { 0, (validate(&outs), 0)... }; + cv::util::suppress_unused_warning(dummy); +} + +template struct get_out; +template<> struct get_out +{ + static tracked_cv_mat get(GCPUContext &ctx, int idx) + { + auto& r = ctx.outMatR(idx); + return {r}; + } +}; +template<> struct get_out +{ + static tracked_cv_mat get(GCPUContext &ctx, int idx) + { + return get_out::get(ctx, idx); + } +}; +template<> struct get_out +{ + static cv::Scalar& get(GCPUContext &ctx, int idx) + { + return ctx.outValR(idx); + } +}; +template<> struct get_out +{ + static cv::MediaFrame& get(GCPUContext &ctx, int idx) + { + return ctx.outFrame(idx); + } +}; +template struct get_out> +{ + static std::vector& get(GCPUContext &ctx, int idx) + { + return ctx.outVecR(idx); + } +}; + +//FIXME(dm): GArray/GArray conversion should be done more gracefully in the system +template<> struct get_out >: public get_out > +{ +}; + +// FIXME(dm): GArray>/GArray> conversion should be done more gracefully in the system +template struct get_out> >: public get_out> > +{ +}; + +template struct get_out> +{ + static U& get(GCPUContext &ctx, int idx) + { + return ctx.outOpaqueR(idx); + } +}; + +template +struct OCVSetupHelper; + +template +struct OCVSetupHelper> +{ + // Using 'auto' return type and 'decltype' specifier in both 'setup_impl' versions + // to check existence of required 'Impl::setup' functions. + // While 'decltype' specifier accepts expression we pass expression with 'comma-operator' + // where first operand of comma-operator is call attempt to desired 'Impl::setup' and + // the second operand is 'void()' expression. + // + // SFINAE for 'Impl::setup' which accepts compile arguments. + template + static auto setup_impl(const GMetaArgs &metaArgs, const GArgs &args, + GArg &state, const GCompileArgs &compileArgs, + detail::Seq) -> + decltype(Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., + std::declval + >::type + >(), + compileArgs) + , void()) + { + // TODO: unique_ptr <-> shared_ptr conversion ? + // To check: Conversion is possible only if the state which should be passed to + // 'setup' user callback isn't required to have previous value + std::shared_ptr stPtr; + Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., stPtr, compileArgs); + state = GArg(stPtr); + } + + // SFINAE for 'Impl::setup' which doesn't accept compile arguments. + template + static auto setup_impl(const GMetaArgs &metaArgs, const GArgs &args, + GArg &state, const GCompileArgs &/* compileArgs */, + detail::Seq) -> + decltype(Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., + std::declval + >::type + >() + ) + , void()) + { + // The same comment as in 'setup' above. + std::shared_ptr stPtr; + Impl::setup(detail::get_in_meta(metaArgs, args, IIs)..., stPtr); + state = GArg(stPtr); + } + + static void setup(const GMetaArgs &metaArgs, const GArgs &args, + GArg& state, const GCompileArgs &compileArgs) + { + setup_impl(metaArgs, args, state, compileArgs, + typename detail::MkSeq::type()); + } +}; + +// OCVCallHelper is a helper class to call stateless OCV kernels and OCV kernel functors. +template +struct OCVCallHelper; + +// FIXME: probably can be simplified with std::apply or analogue. +template +struct OCVCallHelper, std::tuple> +{ + template + struct call_and_postprocess + { + template + static void call(Inputs&&... ins, Outputs&&... outs) + { + //not using a std::forward on outs is deliberate in order to + //cause compilation error, by trying to bind rvalue references to lvalue references + Impl::run(std::forward(ins)..., outs...); + postprocess(outs...); + } + + template + static void call(Impl& impl, Inputs&&... ins, Outputs&&... outs) + { + impl(std::forward(ins)..., outs...); + } + }; + + template + static void call_impl(GCPUContext &ctx, detail::Seq, detail::Seq) + { + //Make sure that OpenCV kernels do not reallocate memory for output parameters + //by comparing it's state (data ptr) before and after the call. + //This is done by converting each output Mat into tracked_cv_mat object, and binding + //them to parameters of ad-hoc function + call_and_postprocess::get(ctx, IIs))...> + ::call(get_in::get(ctx, IIs)..., get_out::get(ctx, OIs)...); + } + + template + static void call_impl(cv::GCPUContext &ctx, Impl& impl, + detail::Seq, detail::Seq) + { + call_and_postprocess::get(ctx, IIs))...> + ::call(impl, get_in::get(ctx, IIs)..., get_out::get(ctx, OIs)...); + } + + static void call(GCPUContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } + + // NB: Same as call but calling the object + // This necessary for kernel implementations that have a state + // and are represented as an object + static void callFunctor(cv::GCPUContext &ctx, Impl& impl) + { + call_impl(ctx, impl, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +// OCVStCallHelper is a helper class to call stateful OCV kernels. +template +struct OCVStCallHelper; + +template +struct OCVStCallHelper, std::tuple> : + OCVCallHelper, std::tuple> +{ + template + struct call_and_postprocess + { + template + static void call(typename Impl::State& st, Inputs&&... ins, Outputs&&... outs) + { + Impl::run(std::forward(ins)..., outs..., st); + postprocess(outs...); + } + }; + + template + static void call_impl(GCPUContext &ctx, detail::Seq, detail::Seq) + { + auto& st = *ctx.state().get>(); + call_and_postprocess::get(ctx, IIs))...> + ::call(st, get_in::get(ctx, IIs)..., get_out::get(ctx, OIs)...); + } + + static void call(GCPUContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GCPUKernelImpl: public cv::detail::KernelTag +{ + using CallHelper = cv::detail::OCVCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::cpu::backend(); } + static cv::GCPUKernel kernel() { return GCPUKernel(&CallHelper::call); } +}; + +template +class GCPUStKernelImpl: public cv::detail::KernelTag +{ + using StSetupHelper = detail::OCVSetupHelper; + using StCallHelper = detail::OCVStCallHelper; + +public: + using API = K; + using State = S; + + static cv::gapi::GBackend backend() { return cv::gapi::cpu::backend(); } + static cv::GCPUKernel kernel() { return GCPUKernel(&StCallHelper::call, + &StSetupHelper::setup); } +}; + +#define GAPI_OCV_KERNEL(Name, API) struct Name: public cv::GCPUKernelImpl + +// TODO: Reuse Anatoliy's logic for support of types with commas in macro. +// Retrieve the common part from Anatoliy's logic to the separate place. +#define GAPI_OCV_KERNEL_ST(Name, API, State) \ + struct Name: public cv::GCPUStKernelImpl \ + +/// @private +class gapi::cpu::GOCVFunctor : public gapi::GFunctor +{ +public: + using Impl = std::function; + using Meta = cv::GKernel::M; + + GOCVFunctor(const char* id, const Meta &meta, const Impl& impl) + : gapi::GFunctor(id), impl_{GCPUKernel(impl), meta} + { + } + + GKernelImpl impl() const override { return impl_; } + gapi::GBackend backend() const override { return gapi::cpu::backend(); } + +private: + GKernelImpl impl_; +}; + +//! @cond IGNORED +template +gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(Callable& c) +{ + using P = cv::detail::OCVCallHelper; + return GOCVFunctor{ K::id() + , &K::getOutMeta + , std::bind(&P::callFunctor, std::placeholders::_1, std::ref(c)) + }; +} + +template +gapi::cpu::GOCVFunctor gapi::cpu::ocv_kernel(const Callable& c) +{ + using P = cv::detail::OCVCallHelper; + return GOCVFunctor{ K::id() + , &K::getOutMeta + , std::bind(&P::callFunctor, std::placeholders::_1, c) + }; +} +//! @endcond + +} // namespace cv + +#endif // OPENCV_GAPI_GCPUKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/imgproc.hpp new file mode 100644 index 0000000..0b96db0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/imgproc.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_CPU_IMGPROC_API_HPP +#define OPENCV_GAPI_CPU_IMGPROC_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace imgproc { +namespace cpu { + +GAPI_EXPORTS GKernelPackage kernels(); + +} // namespace cpu +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_IMGPROC_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/stereo.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/stereo.hpp new file mode 100644 index 0000000..e2a2242 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/stereo.hpp @@ -0,0 +1,48 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_CPU_STEREO_API_HPP +#define OPENCV_GAPI_CPU_STEREO_API_HPP + +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace calib3d { +namespace cpu { + +GAPI_EXPORTS GKernelPackage kernels(); + +/** @brief Structure for the Stereo operation initialization parameters.*/ +struct GAPI_EXPORTS StereoInitParam { + StereoInitParam(int nD, int bS, double bL, double f): + numDisparities(nD), blockSize(bS), baseline(bL), focus(f) {} + + StereoInitParam() = default; + + int numDisparities = 0; + int blockSize = 21; + double baseline = 63.5; + double focus = 3.6; +}; + +} // namespace cpu +} // namespace calib3d +} // namespace gapi + +namespace detail { + + template<> struct CompileArgTag { + static const char* tag() { + return "org.opencv.stereoInit"; + } +}; + +} // namespace detail +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_STEREO_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/video.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/video.hpp new file mode 100644 index 0000000..d3c1f2e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/cpu/video.hpp @@ -0,0 +1,25 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_CPU_VIDEO_API_HPP +#define OPENCV_GAPI_CPU_VIDEO_API_HPP + +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace video { +namespace cpu { + +GAPI_EXPORTS GKernelPackage kernels(); + +} // namespace cpu +} // namespace video +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_CPU_VIDEO_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/core.hpp new file mode 100644 index 0000000..9eceb82 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/core.hpp @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_CORE_HPP +#define OPENCV_GAPI_FLUID_CORE_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { namespace gapi { namespace core { namespace fluid { + +GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +}}}} + +#endif // OPENCV_GAPI_FLUID_CORE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidbuffer.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidbuffer.hpp new file mode 100644 index 0000000..551f0a3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidbuffer.hpp @@ -0,0 +1,154 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_BUFFER_HPP +#define OPENCV_GAPI_FLUID_BUFFER_HPP + +#include +#include // accumulate +#include // ostream +#include // uint8_t + +#include +#include + +#include + +namespace cv { +namespace gapi { +namespace fluid { + +struct Border +{ + // This constructor is required to support existing kernels which are part of G-API + Border(int _type, cv::Scalar _val) : type(_type), value(_val) {} + + int type; + cv::Scalar value; +}; + +using BorderOpt = util::optional; + +bool operator == (const Border& b1, const Border& b2); + +class GAPI_EXPORTS Buffer; + +class GAPI_EXPORTS View +{ +public: + struct Cache + { + std::vector m_linePtrs; + GMatDesc m_desc; + int m_border_size = 0; + + inline const uint8_t* linePtr(int index) const + { + // "out_of_window" check: + // user must not request the lines which are outside of specified kernel window + GAPI_DbgAssert(index >= -m_border_size + && index < -m_border_size + static_cast(m_linePtrs.size())); + return m_linePtrs[index + m_border_size]; + } + }; + + const inline uint8_t* InLineB(int index) const // -(w-1)/2...0...+(w-1)/2 for Filters + { + return m_cache->linePtr(index); + } + + template const inline T* InLine(int i) const + { + const uint8_t* ptr = this->InLineB(i); + return reinterpret_cast(ptr); + } + + inline operator bool() const { return m_priv != nullptr; } + bool ready() const; + inline int length() const { return m_cache->m_desc.size.width; } + int y() const; + + inline const GMatDesc& meta() const { return m_cache->m_desc; } + + class GAPI_EXPORTS Priv; // internal use only + Priv& priv(); // internal use only + const Priv& priv() const; // internal use only + + View(); + View(std::unique_ptr&& p); + View(View&& v); + View& operator=(View&& v); + ~View(); + +private: + std::unique_ptr m_priv; + const Cache* m_cache = nullptr; +}; + +class GAPI_EXPORTS Buffer +{ +public: + struct Cache + { + std::vector m_linePtrs; + GMatDesc m_desc; + }; + + // Default constructor (executable creation stage, + // all following initialization performed in Priv::init()) + Buffer(); + // Scratch constructor (user kernels) + Buffer(const cv::GMatDesc &desc); + + // Constructor for intermediate buffers (for tests) + Buffer(const cv::GMatDesc &desc, + int max_line_consumption, int border_size, + int skew, + int wlpi, + BorderOpt border); + // Constructor for in/out buffers (for tests) + Buffer(const cv::Mat &data, bool is_input); + ~Buffer(); + Buffer& operator=(Buffer&&); + + inline uint8_t* OutLineB(int index = 0) + { + return m_cache->m_linePtrs[index]; + } + + template inline T* OutLine(int index = 0) + { + uint8_t* ptr = this->OutLineB(index); + return reinterpret_cast(ptr); + } + + int y() const; + + int linesReady() const; + void debug(std::ostream &os) const; + inline int length() const { return m_cache->m_desc.size.width; } + int lpi() const; // LPI for WRITER + + inline const GMatDesc& meta() const { return m_cache->m_desc; } + + View mkView(int borderSize, bool ownStorage); + void addView(const View* v); + + class GAPI_EXPORTS Priv; // internal use only + Priv& priv(); // internal use only + const Priv& priv() const; // internal use only + +private: + std::unique_ptr m_priv; + const Cache* m_cache; +}; + +} // namespace cv::gapi::fluid +} // namespace cv::gapi +} // namespace cv + +#endif // OPENCV_GAPI_FLUID_BUFFER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidkernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidkernel.hpp new file mode 100644 index 0000000..53b68c4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/gfluidkernel.hpp @@ -0,0 +1,442 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_KERNEL_HPP +#define OPENCV_GAPI_FLUID_KERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gapi +{ +/** + * @brief This namespace contains G-API Fluid backend functions, structures, and symbols. + */ +namespace fluid +{ + /** + * \addtogroup gapi_std_backends G-API Standard Backends + * @{ + */ + /** + * @brief Get a reference to Fluid backend. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ +} // namespace fluid +} // namespace gapi + + +class GAPI_EXPORTS GFluidKernel +{ +public: + enum class Kind + { + Filter, + Resize, + YUV420toRGB //Color conversion of 4:2:0 chroma sub-sampling formats (NV12, I420 ..etc) to RGB + }; + + // This function is a generic "doWork" callback + using F = std::function &)>; + + // This function is a generic "initScratch" callback + using IS = std::function; + + // This function is a generic "resetScratch" callback + using RS = std::function; + + // This function describes kernel metadata inference rule. + using M = std::function; + + // This function is a generic "getBorder" callback (extracts border-related data from kernel's input parameters) + using B = std::function; + + // This function is a generic "getWindow" callback (extracts window-related data from kernel's input parameters) + using GW = std::function; + + // FIXME: move implementations out of header file + GFluidKernel() {} + GFluidKernel(Kind k, int l, bool scratch, const F& f, const IS &is, const RS &rs, const B& b, const GW& win) + : m_kind(k) + , m_lpi(l) + , m_scratch(scratch) + , m_f(f) + , m_is(is) + , m_rs(rs) + , m_b(b) + , m_gw(win) {} + + Kind m_kind; + const int m_lpi = -1; + const bool m_scratch = false; + + const F m_f; + const IS m_is; + const RS m_rs; + const B m_b; + const GW m_gw; +}; + +// FIXME!!! +// This is the temporary and experimental API +// which should be replaced by runtime roi-based scheduling +/** \addtogroup gapi_compile_args + * @{ + */ +/** + * @brief This structure allows to control the output image region + * which Fluid backend will produce in the graph. + * + * This feature is useful for external tiling and parallelism, but + * will be deprecated in the future releases. + */ +struct GFluidOutputRois +{ + std::vector rois; +}; + +/** + * @brief This structure forces Fluid backend to generate multiple + * parallel output regions in the graph. These regions execute in parallel. + * + * This feature may be deprecated in the future releases. + */ +struct GFluidParallelOutputRois +{ + std::vector parallel_rois; +}; + +/** + * @brief This structure allows to customize the way how Fluid executes + * parallel regions. + * + * For example, user can utilize his own threading runtime via this parameter. + * The `parallel_for` member functor is called by the Fluid runtime with the + * following arguments: + * + * @param size Size of the parallel range to process + * @param f A function which should be called for every integer index + * in this range by the specified parallel_for implementation. + * + * This feature may be deprecated in the future releases. + */ +struct GFluidParallelFor +{ + //this function accepts: + // - size of the "parallel" range as the first argument + // - and a function to be called on the range items, designated by item index + std::function)> parallel_for; +}; +/** @} gapi_compile_args */ + +namespace detail +{ +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.fluid.outputRois"; } +}; + +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.fluid.parallelFor"; } +}; + +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.fluid.parallelOutputRois"; } +}; + +} // namespace detail + +namespace detail +{ +template struct fluid_get_in; +template<> struct fluid_get_in +{ + static const cv::gapi::fluid::View& get(const cv::GArgs &in_args, int idx) + { + return *in_args[idx].unsafe_get(); + } +}; + +template<> struct fluid_get_in +{ + // FIXME: change to return by reference when moved to own::Scalar + static const cv::Scalar get(const cv::GArgs &in_args, int idx) + { + return in_args[idx].unsafe_get(); + } +}; + +template struct fluid_get_in> +{ + static const std::vector& get(const cv::GArgs &in_args, int idx) + { + return in_args.at(idx).unsafe_get().rref(); + } +}; + +template struct fluid_get_in> +{ + static const U& get(const cv::GArgs &in_args, int idx) + { + return in_args.at(idx).unsafe_get().rref(); + } +}; + +template struct fluid_get_in +{ + static const T& get(const cv::GArgs &in_args, int idx) + { + return in_args[idx].unsafe_get(); + } +}; + +template +struct scratch_helper; + +template +struct scratch_helper +{ + // Init + template + static void help_init_impl(const cv::GMetaArgs &metas, + const cv::GArgs &in_args, + gapi::fluid::Buffer &scratch_buf, + detail::Seq) + { + Impl::initScratch(get_in_meta(metas, in_args, IIs)..., scratch_buf); + } + + static void help_init(const cv::GMetaArgs &metas, + const cv::GArgs &in_args, + gapi::fluid::Buffer &b) + { + help_init_impl(metas, in_args, b, typename detail::MkSeq::type()); + } + + // Reset + static void help_reset(gapi::fluid::Buffer &b) + { + Impl::resetScratch(b); + } +}; + +template +struct scratch_helper +{ + static void help_init(const cv::GMetaArgs &, + const cv::GArgs &, + gapi::fluid::Buffer &) + { + GAPI_Assert(false); + } + static void help_reset(gapi::fluid::Buffer &) + { + GAPI_Assert(false); + } +}; + +template struct is_gmat_type +{ + static const constexpr bool value = std::is_same::value; +}; + +template +struct get_border_helper; + +template +struct get_border_helper +{ + template + static gapi::fluid::BorderOpt get_border_impl(const GMetaArgs &metas, + const cv::GArgs &in_args, + cv::detail::Seq) + { + return util::make_optional(Impl::getBorder(cv::detail::get_in_meta(metas, in_args, IIs)...)); + } + + static gapi::fluid::BorderOpt help(const GMetaArgs &metas, + const cv::GArgs &in_args) + { + return get_border_impl(metas, in_args, typename detail::MkSeq::type()); + } +}; + +template +struct get_border_helper +{ + static gapi::fluid::BorderOpt help(const cv::GMetaArgs &, + const cv::GArgs &) + { + return {}; + } +}; + +template +struct get_window_helper; + +template +struct get_window_helper +{ + template + static int get_window_impl(const GMetaArgs &metas, + const cv::GArgs &in_args, + cv::detail::Seq) + { + return Impl::getWindow(cv::detail::get_in_meta(metas, in_args, IIs)...); + } + + static int help(const GMetaArgs &metas, const cv::GArgs &in_args) + { + return get_window_impl(metas, in_args, typename detail::MkSeq::type()); + } +}; + +template +struct get_window_helper +{ + static int help(const cv::GMetaArgs &, + const cv::GArgs &) + { + return Impl::Window; + } +}; + +template +struct has_Window +{ +private: + template + static constexpr auto Check(U*) -> typename std::is_same::type; + + template + static constexpr std::false_type Check(...); + + typedef decltype(Check(0)) Result; + +public: + static constexpr bool value = Result::value; +}; + +template +struct callCustomGetBorder; + +template +struct callCustomGetBorder +{ + static constexpr bool value = (Impl::Window != 1); +}; + +template +struct callCustomGetBorder +{ + static constexpr bool value = true; +}; + +template +struct FluidCallHelper; + +template +struct FluidCallHelper, std::tuple, UseScratch> +{ + static_assert(all_satisfy::value, "return type must be GMat"); + static_assert(contains::value, "input must contain at least one GMat"); + + // Execution dispatcher //////////////////////////////////////////////////// + template + static void call_impl(const cv::GArgs &in_args, + const std::vector &out_bufs, + detail::Seq, + detail::Seq) + { + Impl::run(fluid_get_in::get(in_args, IIs)..., *out_bufs[OIs]...); + } + + static void call(const cv::GArgs &in_args, + const std::vector &out_bufs) + { + constexpr int numOuts = (sizeof...(Outs)) + (UseScratch ? 1 : 0); + call_impl(in_args, out_bufs, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } + + // Scratch buffer initialization dispatcher //////////////////////////////// + static void init_scratch(const GMetaArgs &metas, + const cv::GArgs &in_args, + gapi::fluid::Buffer &b) + { + scratch_helper::help_init(metas, in_args, b); + } + + // Scratch buffer reset dispatcher ///////////////////////////////////////// + static void reset_scratch(gapi::fluid::Buffer &scratch_buf) + { + scratch_helper::help_reset(scratch_buf); + } + + static gapi::fluid::BorderOpt getBorder(const GMetaArgs &metas, const cv::GArgs &in_args) + { + constexpr bool hasWindow = has_Window::value; + + // User must provide "init" callback if Window != 1 + // TODO: move to constexpr if when we enable C++17 + return get_border_helper::value, Impl, Ins...>::help(metas, in_args); + } + + static int getWindow(const GMetaArgs &metas, const cv::GArgs &in_args) + { + constexpr bool callCustomGetWindow = !(has_Window::value); + return get_window_helper::help(metas, in_args); + } +}; +} // namespace detail + + +template +class GFluidKernelImpl : public cv::detail::KernelTag +{ + static const int LPI = 1; + static const auto Kind = GFluidKernel::Kind::Filter; + using P = detail::FluidCallHelper; + +public: + using API = K; + + static GFluidKernel kernel() + { + // FIXME: call() and getOutMeta() needs to be renamed so it is clear these + // functions are internal wrappers, not user API + return GFluidKernel(Impl::Kind, Impl::LPI, + UseScratch, + &P::call, &P::init_scratch, &P::reset_scratch, &P::getBorder, &P::getWindow); + } + + static cv::gapi::GBackend backend() { return cv::gapi::fluid::backend(); } +}; + +#define GAPI_FLUID_KERNEL(Name, API, Scratch) struct Name: public cv::GFluidKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GCPUKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/imgproc.hpp new file mode 100644 index 0000000..dedfa9d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/fluid/imgproc.hpp @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_FLUID_IMGPROC_HPP +#define OPENCV_GAPI_FLUID_IMGPROC_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { namespace gapi { namespace imgproc { namespace fluid { + +GAPI_EXPORTS GKernelPackage kernels(); + +}}}} + +#endif // OPENCV_GAPI_FLUID_IMGPROC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/garg.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/garg.hpp new file mode 100644 index 0000000..bfe147f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/garg.hpp @@ -0,0 +1,309 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GARG_HPP +#define OPENCV_GAPI_GARG_HPP + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cv { + +class GArg; + +namespace detail { + template + using is_garg = std::is_same::type>; +} + +// Parameter holder class for a node +// Depending on platform capabilities, can either support arbitrary types +// (as `boost::any`) or a limited number of types (as `boot::variant`). +// FIXME: put into "details" as a user shouldn't use it in his code +class GAPI_EXPORTS GArg +{ +public: + GArg() {} + + template::value, int>::type = 0> + explicit GArg(const T &t) + : kind(detail::GTypeTraits::kind) + , opaque_kind(detail::GOpaqueTraits::kind) + , value(detail::wrap_gapi_helper::wrap(t)) + { + } + + template::value, int>::type = 0> + explicit GArg(T &&t) + : kind(detail::GTypeTraits::type>::kind) + , opaque_kind(detail::GOpaqueTraits::type>::kind) + , value(detail::wrap_gapi_helper::wrap(t)) + { + } + + template inline T& get() + { + return util::any_cast::type>(value); + } + + template inline const T& get() const + { + return util::any_cast::type>(value); + } + + template inline T& unsafe_get() + { + return util::unsafe_any_cast::type>(value); + } + + template inline const T& unsafe_get() const + { + return util::unsafe_any_cast::type>(value); + } + + detail::ArgKind kind = detail::ArgKind::OPAQUE_VAL; + detail::OpaqueKind opaque_kind = detail::OpaqueKind::CV_UNKNOWN; + +protected: + util::any value; +}; + +using GArgs = std::vector; + +// FIXME: Express as M::type +// FIXME: Move to a separate file! +using GRunArgBase = util::variant< +#if !defined(GAPI_STANDALONE) + cv::UMat, +#endif // !defined(GAPI_STANDALONE) + cv::RMat, + cv::gapi::wip::IStreamSource::Ptr, + cv::Mat, + cv::Scalar, + cv::detail::VectorRef, + cv::detail::OpaqueRef, + cv::MediaFrame + >; + +namespace detail { +template +struct in_variant; + +template +struct in_variant > + : std::integral_constant::value > { +}; +} // namespace detail + +struct GAPI_EXPORTS GRunArg: public GRunArgBase +{ + // Metadata information here + using Meta = std::unordered_map; + Meta meta; + + // Mimic the old GRunArg semantics here, old of the times when + // GRunArg was an alias to variant<> + GRunArg(); + GRunArg(const cv::GRunArg &arg); + GRunArg(cv::GRunArg &&arg); + + GRunArg& operator= (const GRunArg &arg); + GRunArg& operator= (GRunArg &&arg); + + template + GRunArg(const T &t, + const Meta &m = Meta{}, + typename std::enable_if< detail::in_variant::value, int>::type = 0) + : GRunArgBase(t) + , meta(m) + { + } + template + GRunArg(T &&t, + const Meta &m = Meta{}, + typename std::enable_if< detail::in_variant::value, int>::type = 0) + : GRunArgBase(std::move(t)) + , meta(m) + { + } + template auto operator= (const T &t) + -> typename std::enable_if< detail::in_variant::value, cv::GRunArg>::type& + { + GRunArgBase::operator=(t); + return *this; + } + template auto operator= (T&& t) + -> typename std::enable_if< detail::in_variant::value, cv::GRunArg>::type& + { + GRunArgBase::operator=(std::move(t)); + return *this; + } +}; +using GRunArgs = std::vector; + +// TODO: Think about the addition operator +/** + * @brief This operator allows to complement the input vector at runtime. + * + * It's an ordinary overload of addition assignment operator. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GRunArgs usage + * + */ +inline GRunArgs& operator += (GRunArgs &lhs, const GRunArgs &rhs) +{ + lhs.reserve(lhs.size() + rhs.size()); + lhs.insert(lhs.end(), rhs.begin(), rhs.end()); + return lhs; +} + +namespace gapi +{ +namespace wip +{ +/** + * @brief This aggregate type represents all types which G-API can + * handle (via variant). + * + * It only exists to overcome C++ language limitations (where a + * `using`-defined class can't be forward-declared). + */ +struct GAPI_EXPORTS Data: public GRunArg +{ + using GRunArg::GRunArg; + template + Data& operator= (const T& t) { GRunArg::operator=(t); return *this; } + template + Data& operator= (T&& t) { GRunArg::operator=(std::move(t)); return *this; } +}; +} // namespace wip +} // namespace gapi + +using GRunArgP = util::variant< +#if !defined(GAPI_STANDALONE) + cv::UMat*, +#endif // !defined(GAPI_STANDALONE) + cv::Mat*, + cv::RMat*, + cv::Scalar*, + cv::MediaFrame*, + cv::detail::VectorRef, + cv::detail::OpaqueRef + >; +using GRunArgsP = std::vector; + +// TODO: Think about the addition operator +/** + * @brief This operator allows to complement the output vector at runtime. + * + * It's an ordinary overload of addition assignment operator. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GRunArgsP usage + * + */ +inline GRunArgsP& operator += (GRunArgsP &lhs, const GRunArgsP &rhs) +{ + lhs.reserve(lhs.size() + rhs.size()); + lhs.insert(lhs.end(), rhs.begin(), rhs.end()); + return lhs; +} + +namespace gapi +{ +/** + * \addtogroup gapi_serialization + * @{ + * + * @brief G-API functions and classes for serialization and deserialization. + */ +/** @brief Wraps deserialized output GRunArgs to GRunArgsP which can be used by GCompiled. + * + * Since it's impossible to get modifiable output arguments from deserialization + * it needs to be wrapped by this function. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp bind after deserialization + * + * @param out_args deserialized GRunArgs. + * @return the same GRunArgs wrapped in GRunArgsP. + * @see deserialize + */ +GAPI_EXPORTS cv::GRunArgsP bind(cv::GRunArgs &out_args); +/** @brief Wraps output GRunArgsP available during graph execution to GRunArgs which can be serialized. + * + * GRunArgsP is pointer-to-value, so to be serialized they need to be binded to real values + * which this function does. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp bind before serialization + * + * @param out output GRunArgsP available during graph execution. + * @return the same GRunArgsP wrapped in serializable GRunArgs. + * @see serialize + */ +GAPI_EXPORTS cv::GRunArg bind(cv::GRunArgP &out); // FIXME: think more about it +/** @} */ +} + +template inline GRunArgs gin(const Ts&... args) +{ + return GRunArgs{ GRunArg(detail::wrap_host_helper::wrap_in(args))... }; +} + +template inline GRunArgsP gout(Ts&... args) +{ + return GRunArgsP{ GRunArgP(detail::wrap_host_helper::wrap_out(args))... }; +} + +struct GTypeInfo; +using GTypesInfo = std::vector; + +// FIXME: Needed for python bridge, must be moved to more appropriate header +namespace detail { +struct ExtractArgsCallback +{ + cv::GRunArgs operator()(const cv::GTypesInfo& info) const { return c(info); } + using CallBackT = std::function; + CallBackT c; +}; + +struct ExtractMetaCallback +{ + cv::GMetaArgs operator()(const cv::GTypesInfo& info) const { return c(info); } + using CallBackT = std::function; + CallBackT c; +}; + +void constructGraphOutputs(const cv::GTypesInfo &out_info, + cv::GRunArgs &args, + cv::GRunArgsP &outs); +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_GARG_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/garray.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/garray.hpp new file mode 100644 index 0000000..17b0333 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/garray.hpp @@ -0,0 +1,440 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GARRAY_HPP +#define OPENCV_GAPI_GARRAY_HPP + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include // flatten_g only! +#include // flatten_g only! + +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; +template class GArray; + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GArrayDesc +{ + // FIXME: Body + // FIXME: Also implement proper operator== then + bool operator== (const GArrayDesc&) const { return true; } +}; +template GArrayDesc descr_of(const std::vector &) { return {};} +GAPI_EXPORTS_W inline GArrayDesc empty_array_desc() {return {}; } +/** @} */ + +std::ostream& operator<<(std::ostream& os, const cv::GArrayDesc &desc); + +namespace detail +{ + // ConstructVec is a callback which stores information about T and is used by + // G-API runtime to construct arrays in host memory (T remains opaque for G-API). + // ConstructVec is carried into G-API internals by GArrayU. + // Currently it is suitable for Host (CPU) plugins only, real offload may require + // more information for manual memory allocation on-device. + class VectorRef; + using ConstructVec = std::function; + + // This is the base struct for GArrayU type holder + struct TypeHintBase{virtual ~TypeHintBase() = default;}; + + // This class holds type of initial GArray to be checked from GArrayU + template + struct TypeHint final : public TypeHintBase{}; + + // This class strips type information from GArray and makes it usable + // in the G-API graph compiler (expression unrolling, graph generation, etc). + // Part of GProtoArg. + class GAPI_EXPORTS GArrayU + { + public: + GArrayU(const GNode &n, std::size_t out); // Operation result constructor + + template + bool holds() const; // Check if was created from GArray + + GOrigin& priv(); // Internal use only + const GOrigin& priv() const; // Internal use only + + protected: + GArrayU(); // Default constructor + GArrayU(const detail::VectorRef& vref); // Constant value constructor + template friend class cv::GArray; // (available to GArray only) + + void setConstructFcn(ConstructVec &&cv); // Store T-aware constructor + + template + void specifyType(); // Store type of initial GArray + + template + void storeKind(); + + void setKind(cv::detail::OpaqueKind); + + std::shared_ptr m_priv; + std::shared_ptr m_hint; + }; + + template + bool GArrayU::holds() const{ + GAPI_Assert(m_hint != nullptr); + using U = typename std::decay::type; + return dynamic_cast*>(m_hint.get()) != nullptr; + }; + + template + void GArrayU::specifyType(){ + m_hint.reset(new TypeHint::type>); + }; + + template + void GArrayU::storeKind(){ + setKind(cv::detail::GOpaqueTraits::kind); + }; + + // This class represents a typed STL vector reference. + // Depending on origins, this reference may be either "just a" reference to + // an object created externally, OR actually own the underlying object + // (be value holder). + class BasicVectorRef + { + public: + // These fields are set by the derived class(es) + std::size_t m_elemSize = 0ul; + cv::GArrayDesc m_desc; + virtual ~BasicVectorRef() {} + + virtual void mov(BasicVectorRef &ref) = 0; + virtual const void* ptr() const = 0; + virtual std::size_t size() const = 0; + }; + + template class VectorRefT final: public BasicVectorRef + { + using empty_t = util::monostate; + using ro_ext_t = const std::vector *; + using rw_ext_t = std::vector *; + using rw_own_t = std::vector ; + util::variant m_ref; + + inline bool isEmpty() const { return util::holds_alternative(m_ref); } + inline bool isROExt() const { return util::holds_alternative(m_ref); } + inline bool isRWExt() const { return util::holds_alternative(m_ref); } + inline bool isRWOwn() const { return util::holds_alternative(m_ref); } + + void init(const std::vector* vec = nullptr) + { + m_elemSize = sizeof(T); + if (vec) m_desc = cv::descr_of(*vec); + } + + public: + VectorRefT() { init(); } + virtual ~VectorRefT() {} + + explicit VectorRefT(const std::vector& vec) : m_ref(&vec) { init(&vec); } + explicit VectorRefT(std::vector& vec) : m_ref(&vec) { init(&vec); } + explicit VectorRefT(std::vector&& vec) : m_ref(std::move(vec)) { init(&vec); } + + // Reset a VectorRefT. Called only for objects instantiated + // internally in G-API (e.g. temporary GArray's within a + // computation). Reset here means both initialization + // (creating an object) and reset (discarding its existing + // content before the next execution). Must never be called + // for external VectorRefTs. + void reset() + { + if (isEmpty()) + { + std::vector empty_vector; + m_desc = cv::descr_of(empty_vector); + m_ref = std::move(empty_vector); + GAPI_Assert(isRWOwn()); + } + else if (isRWOwn()) + { + util::get(m_ref).clear(); + } + else GAPI_Assert(false); // shouldn't be called in *EXT modes + } + + // Obtain a WRITE reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + std::vector& wref() + { + GAPI_Assert(isRWExt() || isRWOwn()); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + // Obtain a READ reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + const std::vector& rref() const + { + // ANY vector can be accessed for reading, even if it declared for + // output. Example -- a GComputation from [in] to [out1,out2] + // where [out2] is a result of operation applied to [out1]: + // + // GComputation boundary + // . . . . . . . + // . . + // [in] ----> foo() ----> [out1] + // . . : + // . . . .:. . . + // . V . + // . bar() ---> [out2] + // . . . . . . . . . . . . + // + if (isROExt()) return *util::get(m_ref); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + virtual void mov(BasicVectorRef &v) override { + VectorRefT *tv = dynamic_cast*>(&v); + GAPI_Assert(tv != nullptr); + wref() = std::move(tv->wref()); + } + + virtual const void* ptr() const override { return &rref(); } + virtual std::size_t size() const override { return rref().size(); } + }; + + // This class strips type information from VectorRefT<> and makes it usable + // in the G-API executables (carrying run-time data/information to kernels). + // Part of GRunArg. + // Its methods are typed proxies to VectorRefT. + // VectorRef maintains "reference" semantics so two copies of VectoRef refer + // to the same underlying object. + // FIXME: Put a good explanation on why cv::OutputArray doesn't fit this role + class VectorRef + { + std::shared_ptr m_ref; + cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN; + + template inline void check() const + { + GAPI_DbgAssert(dynamic_cast*>(m_ref.get()) != nullptr); + GAPI_Assert(sizeof(T) == m_ref->m_elemSize); + } + + public: + VectorRef() = default; + template explicit VectorRef(const std::vector& vec) + : m_ref(new VectorRefT(vec)) + , m_kind(GOpaqueTraits::kind) + {} + template explicit VectorRef(std::vector& vec) + : m_ref(new VectorRefT(vec)) + , m_kind(GOpaqueTraits::kind) + {} + template explicit VectorRef(std::vector&& vec) + : m_ref(new VectorRefT(std::move(vec))) + , m_kind(GOpaqueTraits::kind) + {} + + cv::detail::OpaqueKind getKind() const + { + return m_kind; + } + + template void reset() + { + if (!m_ref) m_ref.reset(new VectorRefT()); + check(); + storeKind(); + static_cast&>(*m_ref).reset(); + } + + template + void storeKind() + { + m_kind = cv::detail::GOpaqueTraits::kind; + } + + template std::vector& wref() + { + check(); + return static_cast&>(*m_ref).wref(); + } + + template const std::vector& rref() const + { + check(); + return static_cast&>(*m_ref).rref(); + } + + // Check if was created for/from std::vector + template bool holds() const + { + if (!m_ref) return false; + using U = typename std::decay::type; + return dynamic_cast*>(m_ref.get()) != nullptr; + } + + void mov(VectorRef &v) + { + m_ref->mov(*v.m_ref); + } + + cv::GArrayDesc descr_of() const + { + return m_ref->m_desc; + } + + std::size_t size() const + { + return m_ref->size(); + } + + // May be used to uniquely identify this object internally + const void *ptr() const { return m_ref->ptr(); } + }; + + // Helper (FIXME: work-around?) + // stripping G types to their host types + // like cv::GArray would still map to std::vector + // but not to std::vector +#if defined(GAPI_STANDALONE) +# define FLATTEN_NS cv::gapi::own +#else +# define FLATTEN_NS cv +#endif + template struct flatten_g; + template<> struct flatten_g { using type = FLATTEN_NS::Mat; }; + template<> struct flatten_g { using type = FLATTEN_NS::Scalar; }; + template struct flatten_g> { using type = std::vector; }; + template struct flatten_g { using type = T; }; +#undef FLATTEN_NS + // FIXME: the above mainly duplicates "ProtoToParam" thing from gtyped.hpp + // but I decided not to include gtyped here - probably worth moving that stuff + // to some common place? (DM) +} // namespace detail + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief `cv::GArray` template class represents a list of objects + * of class `T` in the graph. + * + * `cv::GArray` describes a functional relationship between + * operations consuming and producing arrays of objects of class + * `T`. The primary purpose of `cv::GArray` is to represent a + * dynamic list of objects -- where the size of the list is not known + * at the graph construction or compile time. Examples include: corner + * and feature detectors (`cv::GArray`), object detection + * and tracking results (`cv::GArray`). Programmers can use + * their own types with `cv::GArray` in the custom operations. + * + * Similar to `cv::GScalar`, `cv::GArray` may be value-initialized + * -- in this case a graph-constant value is associated with the object. + * + * `GArray` is a virtual counterpart of `std::vector`, which is + * usually used to represent the `GArray` data in G-API during the + * execution. + * + * @sa `cv::GOpaque` + */ +template class GArray +{ +public: + // Host type (or Flat type) - the type this GArray is actually + // specified to. + /// @private + using HT = typename detail::flatten_g::type>::type; + + /** + * @brief Constructs a value-initialized `cv::GArray` + * + * `cv::GArray` objects may have their values + * be associated at graph construction time. It is useful when + * some operation has a `cv::GArray` input which doesn't change during + * the program execution, and is set only once. In this case, + * there is no need to declare such `cv::GArray` as a graph input. + * + * @note The value of `cv::GArray` may be overwritten by assigning some + * other `cv::GArray` to the object using `operator=` -- on the + * assigment, the old association or value is discarded. + * + * @param v a std::vector to associate with this + * `cv::GArray` object. Vector data is copied into the + * `cv::GArray` (no reference to the passed data is held). + */ + explicit GArray(const std::vector& v) // Constant value constructor + : m_ref(detail::GArrayU(detail::VectorRef(v))) { putDetails(); } + + /** + * @overload + * @brief Constructs a value-initialized `cv::GArray` + * + * @param v a std::vector to associate with this + * `cv::GArray` object. Vector data is moved into the `cv::GArray`. + */ + explicit GArray(std::vector&& v) // Move-constructor + : m_ref(detail::GArrayU(detail::VectorRef(std::move(v)))) { putDetails(); } + + /** + * @brief Constructs an empty `cv::GArray` + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty `cv::GArray` is assigned to a result + * of some operation, it obtains a functional link to this + * operation (and is not empty anymore). + */ + GArray() { putDetails(); } // Empty constructor + + /// @private + explicit GArray(detail::GArrayU &&ref) // GArrayU-based constructor + : m_ref(ref) { putDetails(); } // (used by GCall, not for users) + + /// @private + detail::GArrayU strip() const { + return m_ref; + } + /// @private + static void VCtor(detail::VectorRef& vref) { + vref.reset(); + } + +private: + void putDetails() { + m_ref.setConstructFcn(&VCtor); + m_ref.specifyType(); // FIXME: to unify those 2 to avoid excessive dynamic_cast + m_ref.storeKind(); // + } + + detail::GArrayU m_ref; +}; + +/** @} */ + +} // namespace cv + +#endif // OPENCV_GAPI_GARRAY_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gasync_context.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gasync_context.hpp new file mode 100644 index 0000000..f49b598 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gasync_context.hpp @@ -0,0 +1,63 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_GASYNC_CONTEXT_HPP +#define OPENCV_GAPI_GASYNC_CONTEXT_HPP + +#if !defined(GAPI_STANDALONE) +# include +#else // Without OpenCV +# include +#endif // !defined(GAPI_STANDALONE) + +#include + +namespace cv { +namespace gapi{ + +/** + * @brief This namespace contains experimental G-API functionality, + * functions or structures in this namespace are subjects to change or + * removal in the future releases. This namespace also contains + * functions which API is not stabilized yet. + */ +namespace wip { + +/** + * @brief A class to group async requests to cancel them in a single shot. + * + * GAsyncContext is passed as an argument to async() and async_apply() functions + */ + +class GAPI_EXPORTS GAsyncContext{ + std::atomic cancelation_requested = {false}; +public: + /** + * @brief Start cancellation process for an associated request. + * + * User still has to wait for each individual request (either via callback or according std::future object) to make sure it actually canceled. + * + * @return true if it was a first request to cancel the context + */ + bool cancel(); + + /** + * @brief Returns true if cancellation was requested for this context. + * + * @return true if cancellation was requested for this context + */ + bool isCanceled() const; +}; + +class GAPI_EXPORTS GAsyncCanceled : public std::exception { +public: + virtual const char* what() const noexcept CV_OVERRIDE; +}; +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif //OPENCV_GAPI_GASYNC_CONTEXT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcall.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcall.hpp new file mode 100644 index 0000000..8d1b8d6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcall.hpp @@ -0,0 +1,78 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GCALL_HPP +#define OPENCV_GAPI_GCALL_HPP + +#include // GArg +#include // GMat +#include // GScalar +#include // GFrame +#include // GArray +#include // GOpaque + +namespace cv { + +struct GKernel; + +// The whole idea of this class is to represent an operation +// which is applied to arguments. This is part of public API, +// since it is what users should use to define kernel interfaces. + +class GAPI_EXPORTS GCall final +{ +public: + class Priv; + + explicit GCall(const GKernel &k); + ~GCall(); + + template + GCall& pass(Ts&&... args) + { + setArgs({cv::GArg(std::move(args))...}); + return *this; + } + + // A generic yield method - obtain a link to operator's particular GMat output + GMat yield (int output = 0); + GMatP yieldP (int output = 0); + GScalar yieldScalar(int output = 0); + GFrame yieldFrame (int output = 0); + + template GArray yieldArray(int output = 0) + { + return GArray(yieldArray(output)); + } + + template GOpaque yieldOpaque(int output = 0) + { + return GOpaque(yieldOpaque(output)); + } + + // Internal use only + Priv& priv(); + const Priv& priv() const; + + // GKernel and params can be modified, it's needed for infer, + // because information about output shapes doesn't exist in compile time + GKernel& kernel(); + cv::util::any& params(); + + void setArgs(std::vector &&args); + +protected: + std::shared_ptr m_priv; + + // Public versions return a typed array or opaque, those are implementation details + detail::GArrayU yieldArray(int output = 0); + detail::GOpaqueU yieldOpaque(int output = 0); +}; + +} // namespace cv + +#endif // OPENCV_GAPI_GCALL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcommon.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcommon.hpp new file mode 100644 index 0000000..dfbd9e3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcommon.hpp @@ -0,0 +1,287 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMMON_HPP +#define OPENCV_GAPI_GCOMMON_HPP + +#include // std::hash +#include // std::vector +#include // decay + +#include + +#include +#include +#include +#include +#include +#include + +namespace cv { + +class GMat; // FIXME: forward declaration for GOpaqueTraits + +namespace detail +{ + // This is a trait-like structure to mark backend-specific compile arguments + // with tags + template struct CompileArgTag; + + // These structures are tags which separate kernels and transformations + struct KernelTag + {}; + struct TransformTag + {}; + + // This enum is utilized mostly by GArray and GOpaque to store and recognize their internal data + // types (aka Host type). Also it is widely used during serialization routine. + enum class OpaqueKind: int + { + CV_UNKNOWN, // Unknown, generic, opaque-to-GAPI data type unsupported in graph seriallization + CV_BOOL, // bool user G-API data + CV_INT, // int user G-API data + CV_INT64, // int64_t user G-API data + CV_DOUBLE, // double user G-API data + CV_FLOAT, // float user G-API data + CV_UINT64, // uint64_t user G-API data + CV_STRING, // std::string user G-API data + CV_POINT, // cv::Point user G-API data + CV_POINT2F, // cv::Point2f user G-API data + CV_SIZE, // cv::Size user G-API data + CV_RECT, // cv::Rect user G-API data + CV_SCALAR, // cv::Scalar user G-API data + CV_MAT, // cv::Mat user G-API data + CV_DRAW_PRIM, // cv::gapi::wip::draw::Prim user G-API data + }; + + // Type traits helper which simplifies the extraction of kind from type + template struct GOpaqueTraits; + template struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_UNKNOWN; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_INT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_INT64; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_DOUBLE; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_FLOAT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_UINT64; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_BOOL; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_STRING; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_SIZE; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_SCALAR; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_POINT2F; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_RECT; }; + template<> struct GOpaqueTraits { static constexpr const OpaqueKind kind = OpaqueKind::CV_MAT; }; + template<> struct GOpaqueTraits + { static constexpr const OpaqueKind kind = OpaqueKind::CV_DRAW_PRIM; }; + using GOpaqueTraitsArrayTypes = std::tuple; + // GOpaque is not supporting cv::Mat and cv::Scalar since there are GScalar and GMat types + using GOpaqueTraitsOpaqueTypes = std::tuple; +} // namespace detail + +// This definition is here because it is reused by both public(?) and internal +// modules. Keeping it here wouldn't expose public details (e.g., API-level) +// to components which are internal and operate on a lower-level entities +// (e.g., compiler, backends). +// FIXME: merge with ArgKind? +// FIXME: replace with variant[format desc]? +enum class GShape: int +{ + GMAT, + GSCALAR, + GARRAY, + GOPAQUE, + GFRAME, +}; + +namespace gapi { +namespace s11n { +namespace detail { +template struct wrap_serialize; +} // namespace detail +} // namespace s11n +} // namespace gapi + + +struct GCompileArg; + +namespace detail { + template + using is_compile_arg = std::is_same::type>; +} // namespace detail + +// CompileArg is an unified interface over backend-specific compilation +// information +// FIXME: Move to a separate file? +/** \addtogroup gapi_compile_args + * @{ + * + * @brief Compilation arguments: data structures controlling the + * compilation process + * + * G-API comes with a number of graph compilation options which can be + * passed to cv::GComputation::apply() or + * cv::GComputation::compile(). Known compilation options are listed + * in this page, while extra backends may introduce their own + * compilation options (G-API transparently accepts _everything_ which + * can be passed to cv::compile_args(), it depends on underlying + * backends if an option would be interpreted or not). + * + * For example, if an example computation is executed like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_decl_apply + * + * Extra parameter specifying which kernels to compile with can be + * passed like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp apply_with_param + */ + +/** + * @brief Represents an arbitrary compilation argument. + * + * Any value can be wrapped into cv::GCompileArg, but only known ones + * (to G-API or its backends) can be interpreted correctly. + * + * Normally objects of this class shouldn't be created manually, use + * cv::compile_args() function which automatically wraps everything + * passed in (a variadic template parameter pack) into a vector of + * cv::GCompileArg objects. + */ +struct GCompileArg +{ +public: + // NB: Required for pythnon bindings + GCompileArg() = default; + + std::string tag; + + // FIXME: use decay in GArg/other trait-based wrapper before leg is shot! + template::value, int>::type = 0> + explicit GCompileArg(T &&t) + : tag(detail::CompileArgTag::type>::tag()) + , serializeF(cv::gapi::s11n::detail::has_S11N_spec::value ? + &cv::gapi::s11n::detail::wrap_serialize::serialize : + nullptr) + , arg(t) + { + } + + template T& get() + { + return util::any_cast(arg); + } + + template const T& get() const + { + return util::any_cast(arg); + } + + void serialize(cv::gapi::s11n::IOStream& os) const + { + if (serializeF) + { + serializeF(os, *this); + } + } + +private: + std::function serializeF; + util::any arg; +}; + +using GCompileArgs = std::vector; + +inline cv::GCompileArgs& operator += ( cv::GCompileArgs &lhs, + const cv::GCompileArgs &rhs) +{ + lhs.reserve(lhs.size() + rhs.size()); + lhs.insert(lhs.end(), rhs.begin(), rhs.end()); + return lhs; +} + +/** + * @brief Wraps a list of arguments (a parameter pack) into a vector of + * compilation arguments (cv::GCompileArg). + */ +template GCompileArgs compile_args(Ts&&... args) +{ + return GCompileArgs{ GCompileArg(args)... }; +} + +namespace gapi +{ +/** + * @brief Retrieves particular compilation argument by its type from + * cv::GCompileArgs + */ +template +inline cv::util::optional getCompileArg(const cv::GCompileArgs &args) +{ + for (auto &compile_arg : args) + { + if (compile_arg.tag == cv::detail::CompileArgTag::tag()) + { + return cv::util::optional(compile_arg.get()); + } + } + return cv::util::optional(); +} + +namespace s11n { +namespace detail { +template struct wrap_serialize +{ + static void serialize(IOStream& os, const GCompileArg& arg) + { + using DT = typename std::decay::type; + S11N
::serialize(os, arg.get
()); + } +}; +} // namespace detail +} // namespace s11n +} // namespace gapi + +/** + * @brief Ask G-API to dump compiled graph in Graphviz format under + * the given file name. + * + * Specifies a graph dump path (path to .dot file to be generated). + * G-API will dump a .dot file under specified path during a + * compilation process if this flag is passed. + */ +struct graph_dump_path +{ + std::string m_dump_path; +}; +/** @} */ + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.graph_dump_path"; } + }; +} + +} // namespace cv + +// std::hash overload for GShape +namespace std +{ +template<> struct hash +{ + size_t operator() (cv::GShape sh) const + { + return std::hash()(static_cast(sh)); + } +}; +} // namespace std + + +#endif // OPENCV_GAPI_GCOMMON_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompiled.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompiled.hpp new file mode 100644 index 0000000..ac36783 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompiled.hpp @@ -0,0 +1,232 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPILED_HPP +#define OPENCV_GAPI_GCOMPILED_HPP + +#include + +#include +#include +#include + +namespace cv { + +// This class represents a compiled computation. +// In theory (and ideally), it can be used w/o the rest of APIs. +// In theory (and ideally), it can be serialized/deserialized. +// It can enable scenarious like deployment to an autonomous devince, FuSa, etc. +// +// Currently GCompiled assumes all GMats you used to pass data to G-API +// are valid and not destroyed while you use a GCompiled object. +// +// FIXME: In future, there should be a way to name I/O objects and specify it +// to GCompiled externally (for example, when it is loaded on the target system). + +/** + * \addtogroup gapi_main_classes + * @{ + */ +/** + * @brief Represents a compiled computation (graph). Can only be used + * with image / data formats & resolutions it was compiled for, with + * some exceptions. + * + * This class represents a product of graph compilation (calling + * cv::GComputation::compile()). Objects of this class actually do + * data processing, and graph execution is incapsulated into objects + * of this class. Execution model itself depends on kernels and + * backends which were using during the compilation, see @ref + * gapi_compile_args for details. + * + * In a general case, GCompiled objects can be applied to data only in + * that formats/resolutions they were compiled for (see @ref + * gapi_meta_args). However, if the underlying backends allow, a + * compiled object can be _reshaped_ to handle data (images) of + * different resolution, though formats and types must remain the same. + * + * GCompiled is very similar to `std::function<>` in its semantics -- + * running it looks like a function call in the user code. + * + * At the moment, GCompiled objects are not reentrant -- generally, + * the objects are stateful since graph execution itself is a stateful + * process and this state is now maintained in GCompiled's own memory + * (not on the process stack). + * + * At the same time, two different GCompiled objects produced from the + * single cv::GComputation are completely independent and can be used + * concurrently. + * + * @sa GStreamingCompiled + */ +class GAPI_EXPORTS GCompiled +{ +public: + /// @private + class GAPI_EXPORTS Priv; + + /** + * @brief Constructs an empty object + */ + GCompiled(); + + /** + * @brief Run the compiled computation, a generic version. + * + * @param ins vector of inputs to process. + * @param outs vector of outputs to produce. + * + * Input/output vectors must have the same number of elements as + * defined in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::Mat needs to be passed where cv::GMat has been + * declared as input, and so on). Run-time exception is generated + * otherwise. + * + * Objects in output vector may remain empty (like cv::Mat) -- + * G-API will automatically initialize output objects to proper formats. + * + * @note Don't construct GRunArgs/GRunArgsP objects manually, use + * cv::gin()/cv::gout() wrappers instead. + */ + void operator() (GRunArgs &&ins, GRunArgsP &&outs); // Generic arg-to-arg +#if !defined(GAPI_STANDALONE) + + /** + * @brief Execute an unary computation + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Mat for unary computation + * process. + */ + void operator() (cv::Mat in, cv::Mat &out); // Unary overload + + /** + * @brief Execute an unary computation + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Scalar for unary computation + * process. + */ + void operator() (cv::Mat in, cv::Scalar &out); // Unary overload (scalar) + + /** + * @brief Execute a binary computation + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Mat for binary computation + * process. + */ + void operator() (cv::Mat in1, cv::Mat in2, cv::Mat &out); // Binary overload + + /** + * @brief Execute an binary computation + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Scalar for binary computation + * process. + */ + void operator() (cv::Mat in1, cv::Mat in2, cv::Scalar &out); // Binary overload (scalar) + + /** + * @brief Execute a computation with arbitrary number of + * inputs/outputs. + * + * @overload + * @param ins vector of input cv::Mat objects to process by the + * computation. + * @param outs vector of output cv::Mat objects to produce by the + * computation. + * + * Numbers of elements in ins/outs vectors must match numbers of + * inputs/outputs which were used to define the source GComputation. + */ + void operator() (const std::vector &ins, // Compatibility overload + const std::vector &outs); +#endif // !defined(GAPI_STANDALONE) + /// @private + Priv& priv(); + + /** + * @brief Check if compiled object is valid (non-empty) + * + * @return true if the object is runnable (valid), false otherwise + */ + explicit operator bool () const; + + /** + * @brief Vector of metadata this graph was compiled for. + * + * @return Unless _reshape_ is not supported, return value is the + * same vector which was passed to cv::GComputation::compile() to + * produce this compiled object. Otherwise, it is the latest + * metadata vector passed to reshape() (if that call was + * successful). + */ + const GMetaArgs& metas() const; // Meta passed to compile() + + /** + * @brief Vector of metadata descriptions of graph outputs + * + * @return vector with formats/resolutions of graph's output + * objects, auto-inferred from input metadata vector by + * operations which form this computation. + * + * @note GCompiled objects produced from the same + * cv::GComputiation graph with different input metas may return + * different values in this vector. + */ + const GMetaArgs& outMetas() const; + + /** + * @brief Check if the underlying backends support reshape or not. + * + * @return true if supported, false otherwise. + */ + bool canReshape() const; + + /** + * @brief Reshape a compiled graph to support new image + * resolutions. + * + * Throws an exception if an error occurs. + * + * @param inMetas new metadata to reshape on. Vector size and + * metadata shapes must match the computation's protocol. + * @param args compilation arguments to use. + */ + // FIXME: Why it requires compile args? + void reshape(const GMetaArgs& inMetas, const GCompileArgs& args); + + /** + * @brief Prepare inner kernels states for a new video-stream. + * + * GCompiled objects may be used to process video streams frame by frame. + * In this case, a GCompiled is called on every image frame individually. + * Starting OpenCV 4.4, some kernels in the graph may have their internal + * states (see GAPI_OCV_KERNEL_ST for the OpenCV backend). + * In this case, if user starts processing another video stream with + * this GCompiled, this method needs to be called to let kernels re-initialize + * their internal states to a new video stream. + */ + void prepareForNewStream(); + +protected: + /// @private + std::shared_ptr m_priv; +}; +/** @} */ + +} + +#endif // OPENCV_GAPI_GCOMPILED_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompiled_async.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompiled_async.hpp new file mode 100644 index 0000000..a0c2917 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompiled_async.hpp @@ -0,0 +1,73 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPILED_ASYNC_HPP +#define OPENCV_GAPI_GCOMPILED_ASYNC_HPP + +#include //for std::future +#include //for std::exception_ptr +#include //for std::function +#include +#include + +namespace cv { + //fwd declaration + class GCompiled; + +namespace gapi{ +namespace wip { + class GAsyncContext; + /** + These functions asynchronously (i.e. probably on a separate thread of execution) call GCompiled::operator() member function of their first argument with copies of rest of arguments (except callback) passed in. + The difference between the function is the way to get the completion notification (via callback or a waiting on std::future object) + If exception is occurred during execution of apply it is transferred to the callback (via function parameter) or passed to future (and will be thrown on call to std::future::get) + + N.B. : + Input arguments are copied on call to async function (actually on call to cv::gin) and thus do not have to outlive the actual completion of asynchronous activity. + While output arguments are "captured" by reference(pointer) and therefore _must_ outlive the asynchronous activity + (i.e. live at least until callback is called or future is unblocked) + + @param gcmpld Compiled computation (graph) to start asynchronously + @param callback Callback to be called when execution of gcmpld is done + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + */ + GAPI_EXPORTS void async(GCompiled& gcmpld, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs); + + /** @overload + @param gcmpld Compiled computation (graph) to run asynchronously + @param callback Callback to be called when execution of gcmpld is done + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + @param ctx Context this request belongs to + @see async GAsyncContext + */ + GAPI_EXPORTS void async(GCompiled& gcmpld, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx); + + /** @overload + @param gcmpld Compiled computation (graph) to run asynchronously + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + @return std::future object to wait for completion of async operation + @see async + */ + GAPI_EXPORTS std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs); + + /** + @param gcmpld Compiled computation (graph) to run asynchronously + @param ins Input parameters for gcmpld + @param outs Output parameters for gcmpld + @param ctx Context this request belongs to + @return std::future object to wait for completion of async operation + @see async GAsyncContext + */ + GAPI_EXPORTS std::future async(GCompiled& gcmpld, GRunArgs &&ins, GRunArgsP &&outs, GAsyncContext& ctx); +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GCOMPILED_ASYNC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompoundkernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompoundkernel.hpp new file mode 100644 index 0000000..df0ce34 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcompoundkernel.hpp @@ -0,0 +1,139 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPOUNDKERNEL_HPP +#define OPENCV_GAPI_GCOMPOUNDKERNEL_HPP + +#include +#include +#include +#include + +namespace cv { +namespace gapi +{ +namespace compound +{ + // FIXME User does not need to know about this function + // Needs that user may define compound kernels(as cpu kernels) + GAPI_EXPORTS cv::gapi::GBackend backend(); +} // namespace compound +} // namespace gapi + +namespace detail +{ + +struct GCompoundContext +{ + explicit GCompoundContext(const GArgs& in_args); + template + const T& inArg(int input) { return m_args.at(input).get(); } + + GArgs m_args; + GArgs m_results; +}; + +class GAPI_EXPORTS GCompoundKernel +{ +// Compound kernel must use all of it's inputs +public: + using F = std::function; + + explicit GCompoundKernel(const F& f); + void apply(GCompoundContext& ctx); + +protected: + F m_f; +}; + +template struct get_compound_in +{ + static T get(GCompoundContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +template struct get_compound_in> +{ + static cv::GArray get(GCompoundContext &ctx, int idx) + { + auto array = cv::GArray(); + ctx.m_args[idx] = GArg(array); + return array; + } +}; + +template struct get_compound_in> +{ + static cv::GOpaque get(GCompoundContext &ctx, int idx) + { + auto opaq = cv::GOpaque(); + ctx.m_args[idx] = GArg(opaq); + return opaq; + } +}; + +template<> struct get_compound_in +{ + static cv::GMatP get(GCompoundContext &ctx, int idx) + { + auto mat = cv::GMatP(); + ctx.m_args[idx] = GArg(mat); + return mat; + } +}; + +template +struct GCompoundCallHelper; + +template +struct GCompoundCallHelper, std::tuple > +{ + template + static void expand_impl(GCompoundContext &ctx, detail::Seq, detail::Seq) + { + auto result = Impl::expand(get_compound_in::get(ctx, IIs)...); + auto tuple_return = tuple_wrap_helper::get(std::move(result)); + ctx.m_results = { cv::GArg(std::get(tuple_return))... }; + } + + static void expand(GCompoundContext &ctx) + { + expand_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +template +class GCompoundKernelImpl: public cv::detail::GCompoundCallHelper, + public cv::detail::KernelTag +{ + using P = cv::detail::GCompoundCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::compound::backend(); } + static GCompoundKernel kernel() { return GCompoundKernel(&P::expand); } +}; + +} // namespace detail + + +/** + * Declares a new compound kernel. See this + * [documentation chapter](@ref gapi_kernel_compound) + * on compound kernels for more details. + * + * @param Name type name for new kernel + * @param API the interface this kernel implements + */ +#define GAPI_COMPOUND_KERNEL(Name, API) \ + struct Name: public cv::detail::GCompoundKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GCOMPOUNDKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcomputation.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcomputation.hpp new file mode 100644 index 0000000..13944c7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcomputation.hpp @@ -0,0 +1,580 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GCOMPUTATION_HPP +#define OPENCV_GAPI_GCOMPUTATION_HPP + +#include + +#include +#include +#include +#include +#include +#include + +namespace cv { + +namespace detail +{ + // FIXME: move to algorithm, cover with separate tests + // FIXME: replace with O(1) version (both memory and compilation time) + template + struct last_type; + + template + struct last_type { using type = T;}; + + template + struct last_type { using type = typename last_type::type; }; + + template + using last_type_t = typename last_type::type; +} + +// Forward-declare the serialization objects +namespace gapi { +namespace s11n { + struct IIStream; + struct IOStream; +} // namespace s11n +} // namespace gapi + +/** + * \addtogroup gapi_main_classes + * @{ + * + * @brief G-API classes for constructed and compiled graphs. + */ +/** + * @brief GComputation class represents a captured computation + * graph. GComputation objects form boundaries for expression code + * user writes with G-API, allowing to compile and execute it. + * + * G-API computations are defined with input/output data + * objects. G-API will track automatically which operations connect + * specified outputs to the inputs, forming up a call graph to be + * executed. The below example expresses calculation of Sobel operator + * for edge detection (\f$G = \sqrt{G_x^2 + G_y^2}\f$): + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_def + * + * Full pipeline can be now captured with this object declaration: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_cap_full + * + * Input/output data objects on which a call graph should be + * reconstructed are passed using special wrappers cv::GIn and + * cv::GOut. G-API will track automatically which operations form a + * path from inputs to outputs and build the execution graph appropriately. + * + * Note that cv::GComputation doesn't take ownership on data objects + * it is defined. Moreover, multiple GComputation objects may be + * defined on the same expressions, e.g. a smaller pipeline which + * expects that image gradients are already pre-calculated may be + * defined like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_cap_sub + * + * The resulting graph would expect two inputs and produce one + * output. In this case, it doesn't matter if gx/gy data objects are + * results of cv::gapi::Sobel operators -- G-API will stop unrolling + * expressions and building the underlying graph one reaching this + * data objects. + * + * The way how GComputation is defined is important as its definition + * specifies graph _protocol_ -- the way how the graph should be + * used. Protocol is defined by number of inputs, number of outputs, + * and shapes of inputs and outputs. + * + * In the above example, sobelEdge expects one Mat on input and + * produces one Mat; while sobelEdgeSub expects two Mats on input and + * produces one Mat. GComputation's protocol defines how other + * computation methods should be used -- cv::GComputation::compile() and + * cv::GComputation::apply(). For example, if a graph is defined on + * two GMat inputs, two cv::Mat objects have to be passed to apply() + * for execution. GComputation checks protocol correctness in runtime + * so passing a different number of objects in apply() or passing + * cv::Scalar instead of cv::Mat there would compile well as a C++ + * source but raise an exception in run-time. G-API also comes with a + * typed wrapper cv::GComputationT<> which introduces this type-checking in + * compile-time. + * + * cv::GComputation itself is a thin object which just captures what + * the graph is. The compiled graph (which actually process data) is + * represented by class GCompiled. Use compile() method to generate a + * compiled graph with given compile options. cv::GComputation can + * also be used to process data with implicit graph compilation + * on-the-fly, see apply() for details. + * + * GComputation is a reference-counted object -- once defined, all its + * copies will refer to the same instance. + * + * @sa GCompiled + */ +class GAPI_EXPORTS_W GComputation +{ +public: + class Priv; + typedef std::function Generator; + + // Various constructors enable different ways to define a computation: ///// + // 1. Generic constructors + /** + * @brief Define a computation using a generator function. + * + * Graph can be defined in-place directly at the moment of its + * construction with a lambda: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp graph_gen + * + * This may be useful since all temporary objects (cv::GMats) and + * namespaces can be localized to scope of lambda, without + * contaminating the parent scope with probably unnecessary objects + * and information. + * + * @param gen generator function which returns a cv::GComputation, + * see Generator. + */ + GComputation(const Generator& gen); // Generator + // overload + + /** + * @brief Generic GComputation constructor. + * + * Constructs a new graph with a given protocol, specified as a + * flow of operations connecting input/output objects. Throws if + * the passed boundaries are invalid, e.g. if there's no + * functional dependency (path) between given outputs and inputs. + * + * @param ins Input data vector. + * @param outs Output data vector. + * + * @note Don't construct GProtoInputArgs/GProtoOutputArgs objects + * directly, use cv::GIn()/cv::GOut() wrapper functions instead. + * + * @sa @ref gapi_data_objects + */ + GAPI_WRAP GComputation(GProtoInputArgs &&ins, + GProtoOutputArgs &&outs); // Arg-to-arg overload + + // 2. Syntax sugar and compatibility overloads + /** + * @brief Defines an unary (one input -- one output) computation + * + * @overload + * @param in input GMat of the defined unary computation + * @param out output GMat of the defined unary computation + */ + GAPI_WRAP GComputation(GMat in, GMat out); // Unary overload + + /** + * @brief Defines an unary (one input -- one output) computation + * + * @overload + * @param in input GMat of the defined unary computation + * @param out output GScalar of the defined unary computation + */ + GAPI_WRAP GComputation(GMat in, GScalar out); // Unary overload (scalar) + + /** + * @brief Defines a binary (two inputs -- one output) computation + * + * @overload + * @param in1 first input GMat of the defined binary computation + * @param in2 second input GMat of the defined binary computation + * @param out output GMat of the defined binary computation + */ + GAPI_WRAP GComputation(GMat in1, GMat in2, GMat out); // Binary overload + + /** + * @brief Defines a binary (two inputs -- one output) computation + * + * @overload + * @param in1 first input GMat of the defined binary computation + * @param in2 second input GMat of the defined binary computation + * @param out output GScalar of the defined binary computation + */ + GComputation(GMat in1, GMat in2, GScalar out); // Binary + // overload + // (scalar) + + /** + * @brief Defines a computation with arbitrary input/output number. + * + * @overload + * @param ins vector of inputs GMats for this computation + * @param outs vector of outputs GMats for this computation + * + * Use this overload for cases when number of computation + * inputs/outputs is not known in compile-time -- e.g. when graph + * is programmatically generated to build an image pyramid with + * the given number of levels, etc. + */ + GComputation(const std::vector &ins, // Compatibility overload + const std::vector &outs); + + // Various versions of apply(): //////////////////////////////////////////// + // 1. Generic apply() + /** + * @brief Compile graph on-the-fly and immediately execute it on + * the inputs data vectors. + * + * Number of input/output data objects must match GComputation's + * protocol, also types of host data objects (cv::Mat, cv::Scalar) + * must match the shapes of data objects from protocol (cv::GMat, + * cv::GScalar). If there's a mismatch, a run-time exception will + * be generated. + * + * Internally, a cv::GCompiled object is created for the given + * input format configuration, which then is executed on the input + * data immediately. cv::GComputation caches compiled objects + * produced within apply() -- if this method would be called next + * time with the same input parameters (image formats, image + * resolution, etc), the underlying compiled graph will be reused + * without recompilation. If new metadata doesn't match the cached + * one, the underlying compiled graph is regenerated. + * + * @note compile() always triggers a compilation process and + * produces a new GCompiled object regardless if a similar one has + * been cached via apply() or not. + * + * @param ins vector of input data to process. Don't create + * GRunArgs object manually, use cv::gin() wrapper instead. + * @param outs vector of output data to fill results in. cv::Mat + * objects may be empty in this vector, G-API will automatically + * initialize it with the required format & dimensions. Don't + * create GRunArgsP object manually, use cv::gout() wrapper instead. + * @param args a list of compilation arguments to pass to the + * underlying compilation process. Don't create GCompileArgs + * object manually, use cv::compile_args() wrapper instead. + * + * @sa @ref gapi_data_objects, @ref gapi_compile_args + */ + void apply(GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); // Arg-to-arg overload + + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP GRunArgs apply(const cv::detail::ExtractArgsCallback &callback, + GCompileArgs &&args = {}); + + /// @private -- Exclude this function from OpenCV documentation + void apply(const std::vector& ins, // Compatibility overload + const std::vector& outs, + GCompileArgs &&args = {}); + + // 2. Syntax sugar and compatibility overloads +#if !defined(GAPI_STANDALONE) + /** + * @brief Execute an unary computation (with compilation on the fly) + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Mat for unary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in, cv::Mat &out, GCompileArgs &&args = {}); // Unary overload + + /** + * @brief Execute an unary computation (with compilation on the fly) + * + * @overload + * @param in input cv::Mat for unary computation + * @param out output cv::Scalar for unary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in, cv::Scalar &out, GCompileArgs &&args = {}); // Unary overload (scalar) + + /** + * @brief Execute a binary computation (with compilation on the fly) + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Mat for binary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in1, cv::Mat in2, cv::Mat &out, GCompileArgs &&args = {}); // Binary overload + + /** + * @brief Execute an binary computation (with compilation on the fly) + * + * @overload + * @param in1 first input cv::Mat for binary computation + * @param in2 second input cv::Mat for binary computation + * @param out output cv::Scalar for binary computation + * @param args compilation arguments for underlying compilation + * process. + */ + void apply(cv::Mat in1, cv::Mat in2, cv::Scalar &out, GCompileArgs &&args = {}); // Binary overload (scalar) + + /** + * @brief Execute a computation with arbitrary number of + * inputs/outputs (with compilation on-the-fly). + * + * @overload + * @param ins vector of input cv::Mat objects to process by the + * computation. + * @param outs vector of output cv::Mat objects to produce by the + * computation. + * @param args compilation arguments for underlying compilation + * process. + * + * Numbers of elements in ins/outs vectors must match numbers of + * inputs/outputs which were used to define this GComputation. + */ + void apply(const std::vector& ins, // Compatibility overload + std::vector& outs, + GCompileArgs &&args = {}); +#endif // !defined(GAPI_STANDALONE) + // Various versions of compile(): ////////////////////////////////////////// + // 1. Generic compile() - requires metas to be passed as vector + /** + * @brief Compile the computation for specific input format(s). + * + * This method triggers compilation process and produces a new + * GCompiled object which then can process data of the given + * format. Passing data with different format to the compiled + * computation will generate a run-time exception. + * + * @param in_metas vector of input metadata configuration. Grab + * metadata from real data objects (like cv::Mat or cv::Scalar) + * using cv::descr_of(), or create it on your own. + * @param args compilation arguments for this compilation + * process. Compilation arguments directly affect what kind of + * executable object would be produced, e.g. which kernels (and + * thus, devices) would be used to execute computation. + * + * @return GCompiled, an executable computation compiled + * specifically for the given input parameters. + * + * @sa @ref gapi_compile_args + */ + GCompiled compile(GMetaArgs &&in_metas, GCompileArgs &&args = {}); + + // 2. Syntax sugar - variadic list of metas, no extra compile args + // FIXME: SFINAE looks ugly in the generated documentation + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced. + * + * @return GCompiled, an executable computation compiled + * specifically for the given input parameters. + */ + template + auto compile(const Ts&... metas) -> + typename std::enable_if::value, GCompiled>::type + { + return compile(GMetaArgs{GMetaArg(metas)...}, GCompileArgs()); + } + + // 3. Syntax sugar - variadic list of metas, extra compile args + // (seems optional parameters don't work well when there's an variadic template + // comes first) + // + // Ideally it should look like: + // + // template + // GCompiled compile(const Ts&... metas, GCompileArgs &&args) + // + // But not all compilers can handle this (and seems they shouldn't be able to). + // FIXME: SFINAE looks ugly in the generated documentation + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced, + * followed by GCompileArgs object representing compilation + * arguments for this process. + * + * @return GCompiled, an executable computation compiled + * specifically for the given input parameters. + */ + template + auto compile(const Ts&... meta_and_compile_args) -> + typename std::enable_if::value + && std::is_same >::value, + GCompiled>::type + { + //FIXME: wrapping meta_and_compile_args into a tuple to unwrap them inside a helper function is the overkill + return compile(std::make_tuple(meta_and_compile_args...), + typename detail::MkSeq::type()); + } + + + // FIXME: Document properly in the Doxygen format + // Video-oriented pipeline compilation: + // 1. A generic version + /** + * @brief Compile the computation for streaming mode. + * + * This method triggers compilation process and produces a new + * GStreamingCompiled object which then can process video stream + * data of the given format. Passing a stream in a different + * format to the compiled computation will generate a run-time + * exception. + * + * @param in_metas vector of input metadata configuration. Grab + * metadata from real data objects (like cv::Mat or cv::Scalar) + * using cv::descr_of(), or create it on your own. + * + * @param args compilation arguments for this compilation + * process. Compilation arguments directly affect what kind of + * executable object would be produced, e.g. which kernels (and + * thus, devices) would be used to execute computation. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled specifically for the given input + * parameters. + * + * @sa @ref gapi_compile_args + */ + GAPI_WRAP GStreamingCompiled compileStreaming(GMetaArgs &&in_metas, GCompileArgs &&args = {}); + + /** + * @brief Compile the computation for streaming mode. + * + * This method triggers compilation process and produces a new + * GStreamingCompiled object which then can process video stream + * data in any format. Underlying mechanisms will be adjusted to + * every new input video stream automatically, but please note that + * _not all_ existing backends support this (see reshape()). + * + * @param args compilation arguments for this compilation + * process. Compilation arguments directly affect what kind of + * executable object would be produced, e.g. which kernels (and + * thus, devices) would be used to execute computation. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled for any input image format. + * + * @sa @ref gapi_compile_args + */ + GAPI_WRAP GStreamingCompiled compileStreaming(GCompileArgs &&args = {}); + + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP GStreamingCompiled compileStreaming(const cv::detail::ExtractMetaCallback &callback, + GCompileArgs &&args = {}); + + // 2. Direct metadata version + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled specifically for the given input + * parameters. + */ + template + auto compileStreaming(const Ts&... metas) -> + typename std::enable_if::value, GStreamingCompiled>::type + { + return compileStreaming(GMetaArgs{GMetaArg(metas)...}, GCompileArgs()); + } + + // 2. Direct metadata + compile arguments version + /** + * @overload + * + * Takes a variadic parameter pack with metadata + * descriptors for which a compiled object needs to be produced, + * followed by GCompileArgs object representing compilation + * arguments for this process. + * + * @return GStreamingCompiled, a streaming-oriented executable + * computation compiled specifically for the given input + * parameters. + */ + template + auto compileStreaming(const Ts&... meta_and_compile_args) -> + typename std::enable_if::value + && std::is_same >::value, + GStreamingCompiled>::type + { + //FIXME: wrapping meta_and_compile_args into a tuple to unwrap them inside a helper function is the overkill + return compileStreaming(std::make_tuple(meta_and_compile_args...), + typename detail::MkSeq::type()); + } + + // Internal use only + /// @private + Priv& priv(); + /// @private + const Priv& priv() const; + /// @private + explicit GComputation(cv::gapi::s11n::IIStream &); + /// @private + void serialize(cv::gapi::s11n::IOStream &) const; + +protected: + + // 4. Helper methods for (3) + /// @private + template + GCompiled compile(const std::tuple &meta_and_compile_args, detail::Seq) + { + GMetaArgs meta_args = {GMetaArg(std::get(meta_and_compile_args))...}; + GCompileArgs comp_args = std::get(meta_and_compile_args); + return compile(std::move(meta_args), std::move(comp_args)); + } + template + GStreamingCompiled compileStreaming(const std::tuple &meta_and_compile_args, detail::Seq) + { + GMetaArgs meta_args = {GMetaArg(std::get(meta_and_compile_args))...}; + GCompileArgs comp_args = std::get(meta_and_compile_args); + return compileStreaming(std::move(meta_args), std::move(comp_args)); + } + void recompile(GMetaArgs&& in_metas, GCompileArgs &&args); + /// @private + std::shared_ptr m_priv; +}; +/** @} */ + +namespace gapi +{ + // FIXME: all these standalone functions need to be added to some + // common documentation section + /** + * @brief Define an tagged island (subgraph) within a computation. + * + * Declare an Island tagged with `name` and defined from `ins` to `outs` + * (exclusively, as ins/outs are data objects, and regioning is done on + * operations level). + * Throws if any operation between `ins` and `outs` are already assigned + * to another island. + * + * Islands allow to partition graph into subgraphs, fine-tuning + * the way it is scheduled by the underlying executor. + * + * @param name name of the Island to create + * @param ins vector of input data objects where the subgraph + * begins + * @param outs vector of output data objects where the subgraph + * ends. + * + * The way how an island is defined is similar to how + * cv::GComputation is defined on input/output data objects. + * Same rules apply here as well -- if there's no functional + * dependency between inputs and outputs or there's not enough + * input data objects were specified to properly calculate all + * outputs, an exception is thrown. + * + * Use cv::GIn() / cv::GOut() to specify input/output vectors. + */ + void GAPI_EXPORTS island(const std::string &name, + GProtoInputArgs &&ins, + GProtoOutputArgs &&outs); +} // namespace gapi + +} // namespace cv +#endif // OPENCV_GAPI_GCOMPUTATION_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcomputation_async.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcomputation_async.hpp new file mode 100644 index 0000000..8af603e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gcomputation_async.hpp @@ -0,0 +1,69 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP +#define OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP + + +#include //for std::future +#include //for std::exception_ptr +#include //for std::function +#include //for GRunArgs, GRunArgsP +#include //for GCompileArgs +#include + + +namespace cv { + //fwd declaration + class GComputation; +namespace gapi { +namespace wip { + class GAsyncContext; + /** In contrast to async() functions, these do call GComputation::apply() member function of the GComputation passed in. + + @param gcomp Computation (graph) to run asynchronously + @param callback Callback to be called when execution of gcomp is done + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @see async + */ + GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); + /** @overload + @param gcomp Computation (graph) to run asynchronously + @param callback Callback to be called when execution of gcomp is done + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @param ctx Context this request belongs to + @see async_apply async GAsyncContext + */ + GAPI_EXPORTS void async_apply(GComputation& gcomp, std::function&& callback, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx); + /** @overload + @param gcomp Computation (graph) to run asynchronously + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @return std::future object to wait for completion of async operation + @see async_apply async + */ + GAPI_EXPORTS std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args = {}); + /** @overload + @param gcomp Computation (graph) to run asynchronously + @param ins Input parameters for gcomp + @param outs Output parameters for gcomp + @param args Compile arguments to pass to GComputation::apply() + @param ctx Context this request belongs to + @return std::future object to wait for completion of async operation + @see async_apply async GAsyncContext + */ + GAPI_EXPORTS std::future async_apply(GComputation& gcomp, GRunArgs &&ins, GRunArgsP &&outs, GCompileArgs &&args, GAsyncContext& ctx); +} // namespace wip +} // namespace gapi +} // namespace cv + + +#endif //OPENCV_GAPI_GCOMPUTATION_ASYNC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gframe.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gframe.hpp new file mode 100644 index 0000000..96913dc --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gframe.hpp @@ -0,0 +1,112 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GFRAME_HPP +#define OPENCV_GAPI_GFRAME_HPP + +#include +#include // std::shared_ptr + +#include +#include // GShape + +#include +#include + +// TODO GAPI_EXPORTS or so +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief GFrame class represents an image or media frame in the graph. + * + * GFrame doesn't store any data itself, instead it describes a + * functional relationship between operations consuming and producing + * GFrame objects. + * + * GFrame is introduced to handle various media formats (e.g., NV12 or + * I420) under the same type. Various image formats may differ in the + * number of planes (e.g. two for NV12, three for I420) and the pixel + * layout inside. GFrame type allows to handle these media formats in + * the graph uniformly -- the graph structure will not change if the + * media format changes, e.g. a different camera or decoder is used + * with the same graph. G-API provides a number of operations which + * operate directly on GFrame, like `infer<>()` or + * renderFrame(); these operations are expected to handle different + * media formats inside. There is also a number of accessor + * operations like BGR(), Y(), UV() -- these operations provide + * access to frame's data in the familiar cv::GMat form, which can be + * used with the majority of the existing G-API operations. These + * accessor functions may perform color space converion on the fly if + * the image format of the GFrame they are applied to differs from the + * operation's semantic (e.g. the BGR() accessor is called on an NV12 + * image frame). + * + * GFrame is a virtual counterpart of cv::MediaFrame. + * + * @sa cv::MediaFrame, cv::GFrameDesc, BGR(), Y(), UV(), infer<>(). + */ +class GAPI_EXPORTS_W_SIMPLE GFrame +{ +public: + /** + * @brief Constructs an empty GFrame + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty GFrame is assigned to a result of some + * operation, it obtains a functional link to this operation (and + * is not empty anymore). + */ + GAPI_WRAP GFrame(); // Empty constructor + + /// @private + GFrame(const GNode &n, std::size_t out); // Operation result constructor + /// @private + GOrigin& priv(); // Internal use only + /// @private + const GOrigin& priv() const; // Internal use only + +private: + std::shared_ptr m_priv; +}; +/** @} */ + +enum class MediaFormat: int +{ + BGR = 0, + NV12, +}; + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS GFrameDesc +{ + MediaFormat fmt; + cv::Size size; + + bool operator== (const GFrameDesc &) const; +}; +static inline GFrameDesc empty_gframe_desc() { return GFrameDesc{}; } +/** @} */ + +class MediaFrame; +GAPI_EXPORTS GFrameDesc descr_of(const MediaFrame &frame); + +GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GFrameDesc &desc); + +} // namespace cv + +#endif // OPENCV_GAPI_GFRAME_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gkernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gkernel.hpp new file mode 100644 index 0000000..4d3fbd8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gkernel.hpp @@ -0,0 +1,749 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GKERNEL_HPP +#define OPENCV_GAPI_GKERNEL_HPP + +#include +#include +#include // string +#include // false_type, true_type +#include // map (for GKernelPackage) +#include // tuple + +#include // CompileArgTag +#include // Seq +#include +#include // GArg +#include // GMetaArg +#include // GTypeTraits +#include //suppress_unused_warning +#include + +namespace cv { + +struct GTypeInfo +{ + GShape shape; + cv::detail::OpaqueKind kind; + detail::HostCtor ctor; +}; + +using GShapes = std::vector; +using GKinds = std::vector; +using GCtors = std::vector; +using GTypesInfo = std::vector; + +// GKernel describes kernel API to the system +// FIXME: add attributes of a kernel, (e.g. number and types +// of inputs, etc) +struct GAPI_EXPORTS GKernel +{ + using M = std::function; + + std::string name; // kernel ID, defined by its API (signature) + std::string tag; // some (implementation-specific) tag + M outMeta; // generic adaptor to API::outMeta(...) + GShapes outShapes; // types (shapes) kernel's outputs + GKinds inKinds; // kinds of kernel's inputs (fixme: below) + GCtors outCtors; // captured constructors for template output types +}; +// TODO: It's questionable if inKinds should really be here. Instead, +// this information could come from meta. + +// GKernelImpl describes particular kernel implementation to the system +struct GAPI_EXPORTS GKernelImpl +{ + util::any opaque; // backend-specific opaque info + GKernel::M outMeta; // for deserialized graphs, the outMeta is taken here +}; + +template class GKernelTypeM; + +namespace detail +{ + //////////////////////////////////////////////////////////////////////////// + // yield() is used in graph construction time as a generic method to obtain + // lazy "return value" of G-API operations + // + template struct Yield; + template<> struct Yield + { + static inline cv::GMat yield(cv::GCall &call, int i) { return call.yield(i); } + }; + template<> struct Yield + { + static inline cv::GMatP yield(cv::GCall &call, int i) { return call.yieldP(i); } + }; + template<> struct Yield + { + static inline cv::GScalar yield(cv::GCall &call, int i) { return call.yieldScalar(i); } + }; + template struct Yield > + { + static inline cv::GArray yield(cv::GCall &call, int i) { return call.yieldArray(i); } + }; + template struct Yield > + { + static inline cv::GOpaque yield(cv::GCall &call, int i) { return call.yieldOpaque(i); } + }; + template<> struct Yield + { + static inline cv::GFrame yield(cv::GCall &call, int i) { return call.yieldFrame(i); } + }; + + //////////////////////////////////////////////////////////////////////////// + // Helper classes which brings outputMeta() marshalling to kernel + // implementations + // + // 1. MetaType establishes G#Type -> G#Meta mapping between G-API dynamic + // types and its metadata descriptor types. + // This mapping is used to transform types to call outMeta() callback. + template struct MetaType; + template<> struct MetaType { using type = GMatDesc; }; + template<> struct MetaType { using type = GMatDesc; }; + template<> struct MetaType { using type = GFrameDesc; }; + template<> struct MetaType { using type = GScalarDesc; }; + template struct MetaType > { using type = GArrayDesc; }; + template struct MetaType > { using type = GOpaqueDesc; }; + template struct MetaType { using type = T; }; // opaque args passed as-is + // FIXME: Move it to type traits? + + // 2. Hacky test based on MetaType to check if we operate on G-* type or not + template using is_nongapi_type = std::is_same::type>; + + // 3. Two ways to transform input arguments to its meta - for G-* and non-G* types: + template + typename std::enable_if::value, typename MetaType::type> + ::type get_in_meta(const GMetaArgs &in_meta, const GArgs &, int idx) + { + return util::get::type>(in_meta.at(idx)); + } + + template + typename std::enable_if::value, T> + ::type get_in_meta(const GMetaArgs &, const GArgs &in_args, int idx) + { + return in_args.at(idx).template get(); + } + + // 4. The MetaHelper itself: an entity which generates outMeta() call + // based on kernel signature, with arguments properly substituted. + // 4.1 - case for multiple return values + // FIXME: probably can be simplified with std::apply or analogue. + template + struct MetaHelper; + + template + struct MetaHelper, std::tuple > + { + template + static GMetaArgs getOutMeta_impl(const GMetaArgs &in_meta, + const GArgs &in_args, + detail::Seq, + detail::Seq) + { + // FIXME: decay? + using R = std::tuple::type...>; + const R r = K::outMeta( get_in_meta(in_meta, in_args, IIs)... ); + return GMetaArgs{ GMetaArg(std::get(r))... }; + } + // FIXME: help users identify how outMeta must look like (via default impl w/static_assert?) + + static GMetaArgs getOutMeta(const GMetaArgs &in_meta, + const GArgs &in_args) + { + return getOutMeta_impl(in_meta, + in_args, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } + }; + + // 4.1 - case for a single return value + // FIXME: How to avoid duplication here? + template + struct MetaHelper, Out > + { + template + static GMetaArgs getOutMeta_impl(const GMetaArgs &in_meta, + const GArgs &in_args, + detail::Seq) + { + // FIXME: decay? + using R = typename MetaType::type; + const R r = K::outMeta( get_in_meta(in_meta, in_args, IIs)... ); + return GMetaArgs{ GMetaArg(r) }; + } + // FIXME: help users identify how outMeta must look like (via default impl w/static_assert?) + + static GMetaArgs getOutMeta(const GMetaArgs &in_meta, + const GArgs &in_args) + { + return getOutMeta_impl(in_meta, + in_args, + typename detail::MkSeq::type()); + } + }; + + //////////////////////////////////////////////////////////////////////////// + // Helper class to introduce tags to calls. By default there's no tag + struct NoTag { + static constexpr const char *tag() { return ""; } + }; + +} // namespace detail + +// GKernelType and GKernelTypeM are base classes which implement typed ::on() +// method based on kernel signature. GKernelTypeM stands for multiple-return-value kernels +// +// G_TYPED_KERNEL and G_TYPED_KERNEL_M macros inherit user classes from GKernelType and +// GKernelTypeM respectively. + +template +class GKernelTypeM(Args...)> > + : public detail::MetaHelper, std::tuple> + , public detail::NoTag +{ + template + static std::tuple yield(cv::GCall &call, detail::Seq) + { + return std::make_tuple(detail::Yield::yield(call, IIs)...); + } + +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + // TODO: Args&&... here? + static std::tuple on(Args... args) + { + cv::GCall call(GKernel{ K::id() + , K::tag() + , &K::getOutMeta + , {detail::GTypeTraits::shape...} + , {detail::GTypeTraits::op_kind...} + , {detail::GObtainCtor::get()...}}); + call.pass(args...); // TODO: std::forward() here? + return yield(call, typename detail::MkSeq::type()); + } +}; + +template class GKernelType; + +template +class GKernelType > + : public detail::MetaHelper, R> + , public detail::NoTag +{ +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + static R on(Args... args) + { + cv::GCall call(GKernel{ K::id() + , K::tag() + , &K::getOutMeta + , {detail::GTypeTraits::shape} + , {detail::GTypeTraits::op_kind...} + , {detail::GObtainCtor::get()}}); + call.pass(args...); + return detail::Yield::yield(call, 0); + } +}; + +namespace detail { +// This tiny class eliminates the semantic difference between +// GKernelType and GKernelTypeM. +template class KernelTypeMedium; + +template +class KernelTypeMedium(Args...)>> : + public cv::GKernelTypeM(Args...)>> {}; + +template +class KernelTypeMedium> : + public cv::GKernelType> {}; +} // namespace detail + +} // namespace cv + + +// FIXME: I don't know a better way so far. Feel free to suggest one +// The problem is that every typed kernel should have ::id() but body +// of the class is defined by user (with outMeta, other stuff) + +//! @cond IGNORED +#define G_ID_HELPER_CLASS(Class) Class##IdHelper + +#define G_ID_HELPER_BODY(Class, Id) \ + struct G_ID_HELPER_CLASS(Class) \ + { \ + static constexpr const char * id() {return Id;} \ + }; \ +//! @endcond + +#define GET_G_TYPED_KERNEL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, NAME, ...) NAME +#define COMBINE_SIGNATURE(...) __VA_ARGS__ +// Ensure correct __VA_ARGS__ expansion on Windows +#define __WRAP_VAARGS(x) x + +/** + * Helper for G_TYPED_KERNEL declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) + * for more details. + * + * @param Class type name for this operation. + * @param API an `std::function<>`-like signature for the operation; + * return type is a single value or a tuple of multiple values. + * @param Id string identifier for the operation. Must be unique. + */ +#define G_TYPED_KERNEL_HELPER(Class, API, Id) \ + G_ID_HELPER_BODY(Class, Id) \ + struct Class final: public cv::detail::KernelTypeMedium, \ + public G_ID_HELPER_CLASS(Class) +// {body} is to be defined by user + +#define G_TYPED_KERNEL_HELPER_2(Class, _1, _2, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2), Id) + +#define G_TYPED_KERNEL_HELPER_3(Class, _1, _2, _3, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3), Id) + +#define G_TYPED_KERNEL_HELPER_4(Class, _1, _2, _3, _4, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4), Id) + +#define G_TYPED_KERNEL_HELPER_5(Class, _1, _2, _3, _4, _5, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5), Id) + +#define G_TYPED_KERNEL_HELPER_6(Class, _1, _2, _3, _4, _5, _6, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6), Id) + +#define G_TYPED_KERNEL_HELPER_7(Class, _1, _2, _3, _4, _5, _6, _7, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7), Id) + +#define G_TYPED_KERNEL_HELPER_8(Class, _1, _2, _3, _4, _5, _6, _7, _8, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8), Id) + +#define G_TYPED_KERNEL_HELPER_9(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9), Id) + +#define G_TYPED_KERNEL_HELPER_10(Class, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, Id) \ +G_TYPED_KERNEL_HELPER(Class, COMBINE_SIGNATURE(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10), Id) + +/** + * Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) + * for more details. + * + * @param Class type name for this operation. + */ +#define G_TYPED_KERNEL(Class, ...) __WRAP_VAARGS(GET_G_TYPED_KERNEL(__VA_ARGS__, \ + G_TYPED_KERNEL_HELPER_10, \ + G_TYPED_KERNEL_HELPER_9, \ + G_TYPED_KERNEL_HELPER_8, \ + G_TYPED_KERNEL_HELPER_7, \ + G_TYPED_KERNEL_HELPER_6, \ + G_TYPED_KERNEL_HELPER_5, \ + G_TYPED_KERNEL_HELPER_4, \ + G_TYPED_KERNEL_HELPER_3, \ + G_TYPED_KERNEL_HELPER_2, \ + G_TYPED_KERNEL_HELPER)(Class, __VA_ARGS__)) \ + +/** + * Declares a new G-API Operation. See [Kernel API](@ref gapi_kernel_api) for more details. + * + * @deprecated This macro is deprecated in favor of `G_TYPED_KERNEL` that is used for declaring any + * G-API Operation. + * + * @param Class type name for this operation. + */ +#define G_TYPED_KERNEL_M G_TYPED_KERNEL + +#define G_API_OP G_TYPED_KERNEL +#define G_API_OP_M G_API_OP + +namespace cv +{ +namespace gapi +{ + // Prework: model "Device" API before it gets to G-API headers. + // FIXME: Don't mix with internal Backends class! + /// @private + class GAPI_EXPORTS GBackend + { + public: + class Priv; + + // TODO: make it template (call `new` within??) + GBackend(); + explicit GBackend(std::shared_ptr &&p); + + Priv& priv(); + const Priv& priv() const; + std::size_t hash() const; + + bool operator== (const GBackend &rhs) const; + + private: + std::shared_ptr m_priv; + }; + + inline bool operator != (const GBackend &lhs, const GBackend &rhs) + { + return !(lhs == rhs); + } +} // namespace gapi +} // namespace cv + +namespace std +{ + template<> struct hash + { + std::size_t operator() (const cv::gapi::GBackend &b) const + { + return b.hash(); + } + }; +} // namespace std + + +namespace cv { +namespace gapi { + /// @private + class GFunctor + { + public: + virtual cv::GKernelImpl impl() const = 0; + virtual cv::gapi::GBackend backend() const = 0; + const char* id() const { return m_id; } + + virtual ~GFunctor() = default; + protected: + GFunctor(const char* id) : m_id(id) { }; + private: + const char* m_id; + }; + + /** \addtogroup gapi_compile_args + * @{ + */ + + // FIXME: Hide implementation + /** + * @brief A container class for heterogeneous kernel + * implementation collections and graph transformations. + * + * GKernelPackage is a special container class which stores kernel + * _implementations_ and graph _transformations_. Objects of this class + * are created and passed to cv::GComputation::compile() to specify + * which kernels to use and which transformations to apply in the + * compiled graph. GKernelPackage may contain kernels of + * different backends, e.g. be heterogeneous. + * + * The most easy way to create a kernel package is to use function + * cv::gapi::kernels(). This template functions takes kernel + * implementations in form of type list (variadic template) and + * generates a kernel package atop of that. + * + * Kernel packages can be also generated programmatically, starting + * with an empty package (created with the default constructor) + * and then by populating it with kernels via call to + * GKernelPackage::include(). Note this method is also a template + * one since G-API kernel and transformation implementations are _types_, + * not objects. + * + * Finally, two kernel packages can be combined into a new one + * with function cv::gapi::combine(). + */ + class GAPI_EXPORTS_W_SIMPLE GKernelPackage + { + + /// @private + using M = std::unordered_map>; + + /// @private + M m_id_kernels; + + /// @private + std::vector m_transformations; + + protected: + /// @private + // Remove ALL implementations of the given API (identified by ID) + void removeAPI(const std::string &id); + + /// @private + // Partial include() specialization for kernels + template + typename std::enable_if<(std::is_base_of::value), void>::type + includeHelper() + { + auto backend = KImpl::backend(); + auto kernel_id = KImpl::API::id(); + auto kernel_impl = GKernelImpl{KImpl::kernel(), &KImpl::API::getOutMeta}; + removeAPI(kernel_id); + + m_id_kernels[kernel_id] = std::make_pair(backend, kernel_impl); + } + + /// @private + // Partial include() specialization for transformations + template + typename std::enable_if<(std::is_base_of::value), void>::type + includeHelper() + { + m_transformations.emplace_back(TImpl::transformation()); + } + + public: + void include(const GFunctor& functor) + { + m_id_kernels[functor.id()] = std::make_pair(functor.backend(), functor.impl()); + } + /** + * @brief Returns total number of kernels + * in the package (across all backends included) + * + * @return a number of kernels in the package + */ + std::size_t size() const; + + /** + * @brief Returns vector of transformations included in the package + * + * @return vector of transformations included in the package + */ + const std::vector& get_transformations() const; + + /** + * @brief Returns vector of kernel ids included in the package + * + * @return vector of kernel ids included in the package + */ + std::vector get_kernel_ids() const; + + /** + * @brief Test if a particular kernel _implementation_ KImpl is + * included in this kernel package. + * + * @sa includesAPI() + * + * @note cannot be applied to transformations + * + * @return true if there is such kernel, false otherwise. + */ + template + bool includes() const + { + static_assert(std::is_base_of::value, + "includes() can be applied to kernels only"); + + auto kernel_it = m_id_kernels.find(KImpl::API::id()); + return kernel_it != m_id_kernels.end() && + kernel_it->second.first == KImpl::backend(); + } + + /** + * @brief Remove all kernels associated with the given backend + * from the package. + * + * Does nothing if there's no kernels of this backend in the package. + * + * @param backend backend which kernels to remove + */ + void remove(const GBackend& backend); + + /** + * @brief Remove all kernels implementing the given API from + * the package. + * + * Does nothing if there's no kernels implementing the given interface. + */ + template + void remove() + { + removeAPI(KAPI::id()); + } + + // FIXME: Rename to includes() and distinguish API/impl case by + // statically? + /** + * Check if package contains ANY implementation of a kernel API + * by API type. + */ + template + bool includesAPI() const + { + return includesAPI(KAPI::id()); + } + + /// @private + bool includesAPI(const std::string &id) const; + + // FIXME: The below comment is wrong, and who needs this function? + /** + * @brief Find a kernel (by its API) + * + * Returns implementation corresponding id. + * Throws if nothing found. + * + * @return Backend which hosts matching kernel implementation. + * + */ + template + GBackend lookup() const + { + return lookup(KAPI::id()).first; + } + + /// @private + std::pair + lookup(const std::string &id) const; + + // FIXME: No overwrites allowed? + /** + * @brief Put a new kernel implementation or a new transformation + * KImpl into the package. + */ + template + void include() + { + includeHelper(); + } + + /** + * @brief Adds a new kernel based on it's backend and id into the kernel package + * + * @param backend backend associated with the kernel + * @param kernel_id a name/id of the kernel + */ + void include(const cv::gapi::GBackend& backend, const std::string& kernel_id) + { + removeAPI(kernel_id); + m_id_kernels[kernel_id] = std::make_pair(backend, GKernelImpl{{}, {}}); + } + + /** + * @brief Lists all backends which are included into package + * + * @return vector of backends + */ + std::vector backends() const; + + // TODO: Doxygen bug -- it wants me to place this comment + // here, not below. + /** + * @brief Create a new package based on `lhs` and `rhs`. + * + * @param lhs "Left-hand-side" package in the process + * @param rhs "Right-hand-side" package in the process + * @return a new kernel package. + */ + friend GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs, + const GKernelPackage &rhs); + }; + + /** + * @brief Create a kernel package object containing kernels + * and transformations specified in variadic template argument. + * + * In G-API, kernel implementations and transformations are _types_. + * Every backend has its own kernel API (like GAPI_OCV_KERNEL() and + * GAPI_FLUID_KERNEL()) but all of that APIs define a new type for + * each kernel implementation. + * + * Use this function to pass kernel implementations (defined in + * either way) and transformations to the system. Example: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp kernels_snippet + * + * Note that kernels() itself is a function returning object, not + * a type, so having `()` at the end is important -- it must be a + * function call. + */ + template GKernelPackage kernels() + { + // FIXME: currently there is no check that transformations' signatures are unique + // and won't be any intersection in graph compilation stage + static_assert(cv::detail::all_unique::value, "Kernels API must be unique"); + + GKernelPackage pkg; + + // For those who wonder - below is a trick to call a number of + // methods based on parameter pack (zeroes just help hiding these + // calls into a sequence which helps to expand this parameter pack). + // Just note that `f(),a` always equals to `a` (with f() called!) + // and parentheses are used to hide function call in the expanded sequence. + // Leading 0 helps to handle case when KK is an empty list (kernels<>()). + int unused[] = { 0, (pkg.include(), 0)... }; + cv::util::suppress_unused_warning(unused); + return pkg; + }; + + template + GKernelPackage kernels(FF&... functors) + { + GKernelPackage pkg; + int unused[] = { 0, (pkg.include(functors), 0)... }; + cv::util::suppress_unused_warning(unused); + return pkg; + }; + + /** @} */ + + // FYI - this function is already commented above + GAPI_EXPORTS GKernelPackage combine(const GKernelPackage &lhs, + const GKernelPackage &rhs); + + /** + * @brief Combines multiple G-API kernel packages into one + * + * @overload + * + * This function successively combines the passed kernel packages using a right fold. + * Calling `combine(a, b, c)` is equal to `combine(a, combine(b, c))`. + * + * @return The resulting kernel package + */ + template + GKernelPackage combine(const GKernelPackage &a, const GKernelPackage &b, Ps&&... rest) + { + return combine(a, combine(b, rest...)); + } + + /** \addtogroup gapi_compile_args + * @{ + */ + /** + * @brief cv::gapi::use_only() is a special combinator which hints G-API to use only + * kernels specified in cv::GComputation::compile() (and not to extend kernels available by + * default with that package). + */ + struct GAPI_EXPORTS use_only + { + GKernelPackage pkg; + }; + /** @} */ + +} // namespace gapi + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.kernel_package"; } + }; + + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.use_only"; } + }; +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_GKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gmat.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gmat.hpp new file mode 100644 index 0000000..7bea97b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gmat.hpp @@ -0,0 +1,279 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GMAT_HPP +#define OPENCV_GAPI_GMAT_HPP + +#include +#include // std::shared_ptr + +#include +#include // GShape + +#include + +// TODO GAPI_EXPORTS or so +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; + +/** \addtogroup gapi_data_objects + * @{ + * + * @brief G-API data objects used to build G-API expressions. + * + * These objects do not own any particular data (except compile-time + * associated values like with cv::GScalar or `cv::GArray`) and are + * used only to construct graphs. + * + * Every graph in G-API starts and ends with data objects. + * + * Once constructed and compiled, G-API operates with regular host-side + * data instead. Refer to the below table to find the mapping between + * G-API and regular data types when passing input and output data + * structures to G-API: + * + * G-API data type | I/O data type + * ------------------ | ------------- + * cv::GMat | cv::Mat, cv::UMat, cv::RMat + * cv::GScalar | cv::Scalar + * `cv::GArray` | std::vector + * `cv::GOpaque` | T + * cv::GFrame | cv::MediaFrame + */ +/** + * @brief GMat class represents image or tensor data in the + * graph. + * + * GMat doesn't store any data itself, instead it describes a + * functional relationship between operations consuming and producing + * GMat objects. + * + * GMat is a virtual counterpart of Mat and UMat, but it + * doesn't mean G-API use Mat or UMat objects internally to represent + * GMat objects -- the internal data representation may be + * backend-specific or optimized out at all. + * + * @sa Mat, GMatDesc + */ +class GAPI_EXPORTS_W_SIMPLE GMat +{ +public: + /** + * @brief Constructs an empty GMat + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty GMat is assigned to a result of some + * operation, it obtains a functional link to this operation (and + * is not empty anymore). + */ + GAPI_WRAP GMat(); // Empty constructor + + /// @private + GMat(const GNode &n, std::size_t out); // Operation result constructor + /// @private + GOrigin& priv(); // Internal use only + /// @private + const GOrigin& priv() const; // Internal use only + +private: + std::shared_ptr m_priv; +}; + +class GAPI_EXPORTS GMatP : public GMat +{ +public: + using GMat::GMat; +}; + +class RMat; + +/** @} */ + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GMatDesc +{ + // FIXME: Default initializers in C++14 + GAPI_PROP int depth; + GAPI_PROP int chan; + GAPI_PROP cv::Size size; // NB.: no multi-dimensional cases covered yet + GAPI_PROP bool planar; + GAPI_PROP std::vector dims; // FIXME: Maybe it's real questionable to have it here + + GAPI_WRAP GMatDesc(int d, int c, cv::Size s, bool p = false) + : depth(d), chan(c), size(s), planar(p) {} + + GAPI_WRAP GMatDesc(int d, const std::vector &dd) + : depth(d), chan(-1), size{-1,-1}, planar(false), dims(dd) {} + + GAPI_WRAP GMatDesc(int d, std::vector &&dd) + : depth(d), chan(-1), size{-1,-1}, planar(false), dims(std::move(dd)) {} + + GAPI_WRAP GMatDesc() : GMatDesc(-1, -1, {-1,-1}) {} + + inline bool operator== (const GMatDesc &rhs) const + { + return depth == rhs.depth + && chan == rhs.chan + && size == rhs.size + && planar == rhs.planar + && dims == rhs.dims; + } + + inline bool operator!= (const GMatDesc &rhs) const + { + return !(*this == rhs); + } + + bool isND() const { return !dims.empty(); } + + // Checks if the passed mat can be described by this descriptor + // (it handles the case when + // 1-channel mat can be reinterpreted as is (1-channel mat) + // and as a 3-channel planar mat with height divided by 3) + bool canDescribe(const cv::Mat& mat) const; + + bool canDescribe(const cv::RMat& mat) const; + + // Meta combinator: return a new GMatDesc which differs in size by delta + // (all other fields are taken unchanged from this GMatDesc) + // FIXME: a better name? + GAPI_WRAP GMatDesc withSizeDelta(cv::Size delta) const + { + GMatDesc desc(*this); + desc.size += delta; + return desc; + } + // Meta combinator: return a new GMatDesc which differs in size by delta + // (all other fields are taken unchanged from this GMatDesc) + // + // This is an overload. + GAPI_WRAP GMatDesc withSizeDelta(int dx, int dy) const + { + return withSizeDelta(cv::Size{dx,dy}); + } + + GAPI_WRAP GMatDesc withSize(cv::Size sz) const + { + GMatDesc desc(*this); + desc.size = sz; + return desc; + } + + // Meta combinator: return a new GMatDesc with specified data depth. + // (all other fields are taken unchanged from this GMatDesc) + GAPI_WRAP GMatDesc withDepth(int ddepth) const + { + GAPI_Assert(CV_MAT_CN(ddepth) == 1 || ddepth == -1); + GMatDesc desc(*this); + if (ddepth != -1) desc.depth = ddepth; + return desc; + } + + // Meta combinator: return a new GMatDesc with specified data depth + // and number of channels. + // (all other fields are taken unchanged from this GMatDesc) + GAPI_WRAP GMatDesc withType(int ddepth, int dchan) const + { + GAPI_Assert(CV_MAT_CN(ddepth) == 1 || ddepth == -1); + GMatDesc desc = withDepth(ddepth); + desc.chan = dchan; + return desc; + } + + // Meta combinator: return a new GMatDesc with planar flag set + // (no size changes are performed, only channel interpretation is changed + // (interleaved -> planar) + GAPI_WRAP GMatDesc asPlanar() const + { + GAPI_Assert(planar == false); + GMatDesc desc(*this); + desc.planar = true; + return desc; + } + + // Meta combinator: return a new GMatDesc + // reinterpreting 1-channel input as planar image + // (size height is divided by plane number) + GAPI_WRAP GMatDesc asPlanar(int planes) const + { + GAPI_Assert(planar == false); + GAPI_Assert(chan == 1); + GAPI_Assert(planes > 1); + GAPI_Assert(size.height % planes == 0); + GMatDesc desc(*this); + desc.size.height /= planes; + desc.chan = planes; + return desc.asPlanar(); + } + + // Meta combinator: return a new GMatDesc with planar flag set to false + // (no size changes are performed, only channel interpretation is changed + // (planar -> interleaved) + GAPI_WRAP GMatDesc asInterleaved() const + { + GAPI_Assert(planar == true); + GMatDesc desc(*this); + desc.planar = false; + return desc; + } +}; + +static inline GMatDesc empty_gmat_desc() { return GMatDesc{-1,-1,{-1,-1}}; } + +namespace gapi { namespace detail { +/** Checks GMatDesc fields if the passed matrix is a set of n-dimentional points. +@param in GMatDesc to check. +@param n expected dimensionality. +@return the amount of points. In case input matrix can't be described as vector of points +of expected dimensionality, returns -1. + */ +int checkVector(const GMatDesc& in, const size_t n); + +/** @overload + +Checks GMatDesc fields if the passed matrix can be described as a set of points of any +dimensionality. + +@return array of two elements in form of std::vector: the amount of points +and their calculated dimensionality. In case input matrix can't be described as vector of points, +returns {-1, -1}. + */ +std::vector checkVector(const GMatDesc& in); +}} // namespace gapi::detail + +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS GMatDesc descr_of(const cv::UMat &mat); +#endif // !defined(GAPI_STANDALONE) + +//Fwd declarations +namespace gapi { namespace own { + class Mat; + GAPI_EXPORTS GMatDesc descr_of(const Mat &mat); +}}//gapi::own + +GAPI_EXPORTS GMatDesc descr_of(const RMat &mat); + +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS GMatDesc descr_of(const cv::Mat &mat); +#else +using gapi::own::descr_of; +#endif + +/** @} */ + +GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc); + +} // namespace cv + +#endif // OPENCV_GAPI_GMAT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gmetaarg.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gmetaarg.hpp new file mode 100644 index 0000000..f21182c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gmetaarg.hpp @@ -0,0 +1,80 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GMETAARG_HPP +#define OPENCV_GAPI_GMETAARG_HPP + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +namespace cv +{ +// FIXME: Rename to GMeta? +// FIXME: user shouldn't deal with it - put to detail? +// GMetaArg is an union type over descriptions of G-types which can serve as +// GComputation's in/output slots. +// +// GMetaArg objects are passed as arguments to GComputation::compile() +// to specify which data a compiled computation should be specialized on. +// For manual compile(), user must supply this metadata, in case of apply() +// this metadata is taken from arguments computation should operate on. +// +// The first type (monostate) is equal to "uninitialized"/"unresolved" meta. +using GMetaArg = util::variant + < util::monostate + , GMatDesc + , GScalarDesc + , GArrayDesc + , GOpaqueDesc + , GFrameDesc + >; +GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &); + +using GMetaArgs = std::vector; + +namespace detail +{ + // These traits are used by GComputation::compile() + + // FIXME: is_constructible doesn't work as variant doesn't do any SFINAE + // in its current template constructor + + template struct is_meta_descr : std::false_type {}; + template<> struct is_meta_descr : std::true_type {}; + template<> struct is_meta_descr : std::true_type {}; + template<> struct is_meta_descr : std::true_type {}; + template<> struct is_meta_descr : std::true_type {}; + + template + using are_meta_descrs = all_satisfy; + + template + using are_meta_descrs_but_last = all_satisfy::type>; + +} // namespace detail + +// Note: descr_of(std::vector<..>) returns a GArrayDesc, while +// descrs_of(std::vector<..>) returns an array of Meta args! +class UMat; +GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector &vec); +GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector &vec); +namespace gapi { namespace own { + GAPI_EXPORTS cv::GMetaArgs descrs_of(const std::vector &vec); +}} // namespace gapi::own + +} // namespace cv + +#endif // OPENCV_GAPI_GMETAARG_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gopaque.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gopaque.hpp new file mode 100644 index 0000000..f77795c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gopaque.hpp @@ -0,0 +1,369 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GOPAQUE_HPP +#define OPENCV_GAPI_GOPAQUE_HPP + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include // OpaqueKind +#include // TypeHintBase + +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; +template class GOpaque; + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GOpaqueDesc +{ + // FIXME: Body + // FIXME: Also implement proper operator== then + bool operator== (const GOpaqueDesc&) const { return true; } +}; +template GOpaqueDesc descr_of(const U &) { return {};} +GAPI_EXPORTS_W inline GOpaqueDesc empty_gopaque_desc() {return {}; } +/** @} */ + +std::ostream& operator<<(std::ostream& os, const cv::GOpaqueDesc &desc); + +namespace detail +{ + // ConstructOpaque is a callback which stores information about T and is used by + // G-API runtime to construct an object in host memory (T remains opaque for G-API). + // ConstructOpaque is carried into G-API internals by GOpaqueU. + // Currently it is suitable for Host (CPU) plugins only, real offload may require + // more information for manual memory allocation on-device. + class OpaqueRef; + using ConstructOpaque = std::function; + + // FIXME: garray.hpp already contains hint classes (for actual T type verification), + // need to think where it can be moved (currently opaque uses it from garray) + + // This class strips type information from GOpaque and makes it usable + // in the G-API graph compiler (expression unrolling, graph generation, etc). + // Part of GProtoArg. + class GAPI_EXPORTS GOpaqueU + { + public: + GOpaqueU(const GNode &n, std::size_t out); // Operation result constructor + + template + bool holds() const; // Check if was created from GOpaque + + GOrigin& priv(); // Internal use only + const GOrigin& priv() const; // Internal use only + + protected: + GOpaqueU(); // Default constructor + template friend class cv::GOpaque; // (available for GOpaque only) + + void setConstructFcn(ConstructOpaque &&cv); // Store T-aware constructor + + template + void specifyType(); // Store type of initial GOpaque + + template + void storeKind(); + + void setKind(cv::detail::OpaqueKind); + + std::shared_ptr m_priv; + std::shared_ptr m_hint; + }; + + template + bool GOpaqueU::holds() const{ + GAPI_Assert(m_hint != nullptr); + using U = util::decay_t; + return dynamic_cast*>(m_hint.get()) != nullptr; + }; + + template + void GOpaqueU::specifyType(){ + m_hint.reset(new TypeHint>); + }; + + template + void GOpaqueU::storeKind(){ + // FIXME: Add assert here on cv::Mat and cv::Scalar? + setKind(cv::detail::GOpaqueTraits::kind); + }; + + // This class represents a typed object reference. + // Depending on origins, this reference may be either "just a" reference to + // an object created externally, OR actually own the underlying object + // (be value holder). + class BasicOpaqueRef + { + public: + cv::GOpaqueDesc m_desc; + virtual ~BasicOpaqueRef() {} + + virtual void mov(BasicOpaqueRef &ref) = 0; + virtual const void* ptr() const = 0; + virtual void set(const cv::util::any &a) = 0; + }; + + template class OpaqueRefT final: public BasicOpaqueRef + { + using empty_t = util::monostate; + using ro_ext_t = const T *; + using rw_ext_t = T *; + using rw_own_t = T ; + util::variant m_ref; + + inline bool isEmpty() const { return util::holds_alternative(m_ref); } + inline bool isROExt() const { return util::holds_alternative(m_ref); } + inline bool isRWExt() const { return util::holds_alternative(m_ref); } + inline bool isRWOwn() const { return util::holds_alternative(m_ref); } + + void init(const T* obj = nullptr) + { + if (obj) m_desc = cv::descr_of(*obj); + } + + public: + OpaqueRefT() { init(); } + virtual ~OpaqueRefT() {} + + explicit OpaqueRefT(const T& obj) : m_ref(&obj) { init(&obj); } + explicit OpaqueRefT( T& obj) : m_ref(&obj) { init(&obj); } + explicit OpaqueRefT( T&& obj) : m_ref(std::move(obj)) { init(&obj); } + + // Reset a OpaqueRefT. Called only for objects instantiated + // internally in G-API (e.g. temporary GOpaque's within a + // computation). Reset here means both initialization + // (creating an object) and reset (discarding its existing + // content before the next execution). Must never be called + // for external OpaqueRefTs. + void reset() + { + if (isEmpty()) + { + T empty_obj{}; + m_desc = cv::descr_of(empty_obj); + m_ref = std::move(empty_obj); + GAPI_Assert(isRWOwn()); + } + else if (isRWOwn()) + { + util::get(m_ref) = {}; + } + else GAPI_Assert(false); // shouldn't be called in *EXT modes + } + + // Obtain a WRITE reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + T& wref() + { + GAPI_Assert(isRWExt() || isRWOwn()); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + // Obtain a READ reference to underlying object + // Used by CPU kernel API wrappers when a kernel execution frame + // is created + const T& rref() const + { + // ANY object can be accessed for reading, even if it declared for + // output. Example -- a GComputation from [in] to [out1,out2] + // where [out2] is a result of operation applied to [out1]: + // + // GComputation boundary + // . . . . . . . + // . . + // [in] ----> foo() ----> [out1] + // . . : + // . . . .:. . . + // . V . + // . bar() ---> [out2] + // . . . . . . . . . . . . + // + if (isROExt()) return *util::get(m_ref); + if (isRWExt()) return *util::get(m_ref); + if (isRWOwn()) return util::get(m_ref); + util::throw_error(std::logic_error("Impossible happened")); + } + + virtual void mov(BasicOpaqueRef &v) override { + OpaqueRefT *tv = dynamic_cast*>(&v); + GAPI_Assert(tv != nullptr); + wref() = std::move(tv->wref()); + } + + virtual const void* ptr() const override { return &rref(); } + + virtual void set(const cv::util::any &a) override { + wref() = util::any_cast(a); + } + }; + + // This class strips type information from OpaqueRefT<> and makes it usable + // in the G-API executables (carrying run-time data/information to kernels). + // Part of GRunArg. + // Its methods are typed proxies to OpaqueRefT. + // OpaqueRef maintains "reference" semantics so two copies of OpaqueRef refer + // to the same underlying object. + class OpaqueRef + { + std::shared_ptr m_ref; + cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN; + + template inline void check() const + { + GAPI_DbgAssert(dynamic_cast*>(m_ref.get()) != nullptr); + } + + public: + OpaqueRef() = default; + + template< + typename T, + typename = util::are_different_t + > + // FIXME: probably won't work with const object + explicit OpaqueRef(T&& obj) : + m_ref(new OpaqueRefT>(std::forward(obj))), + m_kind(GOpaqueTraits>::kind) {} + + cv::detail::OpaqueKind getKind() const + { + return m_kind; + } + + template void reset() + { + if (!m_ref) m_ref.reset(new OpaqueRefT()); + check(); + storeKind(); + static_cast&>(*m_ref).reset(); + } + + template + void storeKind() + { + m_kind = cv::detail::GOpaqueTraits::kind; + } + + template T& wref() + { + check(); + return static_cast&>(*m_ref).wref(); + } + + template const T& rref() const + { + check(); + return static_cast&>(*m_ref).rref(); + } + + void mov(OpaqueRef &v) + { + m_ref->mov(*v.m_ref); + } + + cv::GOpaqueDesc descr_of() const + { + return m_ref->m_desc; + } + + // May be used to uniquely identify this object internally + const void *ptr() const { return m_ref->ptr(); } + + // Introduced for in-graph meta handling + OpaqueRef& operator= (const cv::util::any &a) + { + m_ref->set(a); + return *this; + } + }; +} // namespace detail + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief `cv::GOpaque` template class represents an object of + * class `T` in the graph. + * + * `cv::GOpaque` describes a functional relationship between operations + * consuming and producing object of class `T`. `cv::GOpaque` is + * designed to extend G-API with user-defined data types, which are + * often required with user-defined operations. G-API can't apply any + * optimizations to user-defined types since these types are opaque to + * the framework. However, there is a number of G-API operations + * declared with `cv::GOpaque` as a return type, + * e.g. cv::gapi::streaming::timestamp() or cv::gapi::streaming::size(). + * + * @sa `cv::GArray` + */ +template class GOpaque +{ +public: + // Host type (or Flat type) - the type this GOpaque is actually + // specified to. + /// @private + using HT = typename detail::flatten_g>::type; + + /** + * @brief Constructs an empty `cv::GOpaque` + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty `cv::GOpaque` is assigned to a result + * of some operation, it obtains a functional link to this + * operation (and is not empty anymore). + */ + GOpaque() { putDetails(); } // Empty constructor + + /// @private + explicit GOpaque(detail::GOpaqueU &&ref) // GOpaqueU-based constructor + : m_ref(ref) { putDetails(); } // (used by GCall, not for users) + + /// @private + detail::GOpaqueU strip() const { + return m_ref; + } + /// @private + static void Ctor(detail::OpaqueRef& ref) { + ref.reset(); + } +private: + void putDetails() { + m_ref.setConstructFcn(&Ctor); + m_ref.specifyType(); + m_ref.storeKind(); + } + + detail::GOpaqueU m_ref; +}; + +/** @} */ + +} // namespace cv + +#endif // OPENCV_GAPI_GOPAQUE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gproto.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gproto.hpp new file mode 100644 index 0000000..a2b5d83 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gproto.hpp @@ -0,0 +1,159 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GPROTO_HPP +#define OPENCV_GAPI_GPROTO_HPP + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace cv { + +// FIXME: user shouldn't deal with it - put to detail? +// GProtoArg is an union type over G-types which can serve as +// GComputation's in/output slots. In other words, GProtoArg +// wraps any type which can serve as G-API exchange type. +// +// In Runtime, GProtoArgs are substituted with appropriate GRunArgs. +// +// GProtoArg objects are constructed in-place when user describes +// (captures) computations, user doesn't interact with these types +// directly. +using GProtoArg = util::variant + < GMat + , GMatP + , GFrame + , GScalar + , detail::GArrayU // instead of GArray + , detail::GOpaqueU // instead of GOpaque + >; + +using GProtoArgs = std::vector; + +namespace detail +{ +template inline GProtoArgs packArgs(Ts... args) +{ + return GProtoArgs{ GProtoArg(wrap_gapi_helper::wrap(args))... }; +} + +} + +template +struct GIOProtoArgs +{ +public: + // NB: Used by python wrapper + GIOProtoArgs() = default; + explicit GIOProtoArgs(const GProtoArgs& args) : m_args(args) {} + explicit GIOProtoArgs(GProtoArgs &&args) : m_args(std::move(args)) {} + + GProtoArgs m_args; + + // TODO: Think about the addition operator + /** + * @brief This operator allows to complement the proto vectors at runtime. + * + * It's an ordinary overload of addition assignment operator. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/dynamic_graph_snippets.cpp GIOProtoArgs usage + * + */ + template + friend GIOProtoArgs& operator += (GIOProtoArgs &lhs, const GIOProtoArgs &rhs); +}; + +template +cv::GIOProtoArgs& operator += (cv::GIOProtoArgs &lhs, const cv::GIOProtoArgs &rhs) +{ + lhs.m_args.reserve(lhs.m_args.size() + rhs.m_args.size()); + lhs.m_args.insert(lhs.m_args.end(), rhs.m_args.begin(), rhs.m_args.end()); + return lhs; +} + +struct In_Tag{}; +struct Out_Tag{}; + +using GProtoInputArgs = GIOProtoArgs; +using GProtoOutputArgs = GIOProtoArgs; + +// Perfect forwarding +template inline GProtoInputArgs GIn(Ts&&... ts) +{ + return GProtoInputArgs(detail::packArgs(std::forward(ts)...)); +} + +template inline GProtoOutputArgs GOut(Ts&&... ts) +{ + return GProtoOutputArgs(detail::packArgs(std::forward(ts)...)); +} + +namespace detail +{ + // Extract elements form tuple + // FIXME: Someday utilize a generic tuple_to_vec<> routine + template + static GProtoOutputArgs getGOut_impl(const std::tuple& ts, detail::Seq) + { + return GProtoOutputArgs{ detail::packArgs(std::get(ts)...)}; + } +} + +template inline GProtoOutputArgs GOut(const std::tuple& ts) +{ + // TODO: think of std::forward(ts) + return detail::getGOut_impl(ts, typename detail::MkSeq::type()); +} + +// Takes rvalue as input arg +template inline GProtoOutputArgs GOut(std::tuple&& ts) +{ + // TODO: think of std::forward(ts) + return detail::getGOut_impl(ts, typename detail::MkSeq::type()); +} + +// Extract run-time arguments from node origin +// Can be used to extract constant values associated with G-objects +// (like GScalar) at graph construction time +GRunArg value_of(const GOrigin &origin); + +// Transform run-time computation arguments into a collection of metadata +// extracted from that arguments +GMetaArg GAPI_EXPORTS descr_of(const GRunArg &arg ); +GMetaArgs GAPI_EXPORTS descr_of(const GRunArgs &args); + +// Transform run-time operation result argument into metadata extracted from that argument +// Used to compare the metadata, which generated at compile time with the metadata result operation in run time +GMetaArg GAPI_EXPORTS descr_of(const GRunArgP& argp); + +// Checks if run-time computation argument can be described by metadata +bool GAPI_EXPORTS can_describe(const GMetaArg& meta, const GRunArg& arg); +bool GAPI_EXPORTS can_describe(const GMetaArgs& metas, const GRunArgs& args); + +// Checks if run-time computation result argument can be described by metadata. +// Used to check if the metadata generated at compile time +// coincides with output arguments passed to computation in cpu and ocl backends +bool GAPI_EXPORTS can_describe(const GMetaArg& meta, const GRunArgP& argp); + +// Validates input arguments +void GAPI_EXPORTS validate_input_arg(const GRunArg& arg); +void GAPI_EXPORTS validate_input_args(const GRunArgs& args); + +} // namespace cv + +#endif // OPENCV_GAPI_GPROTO_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/core.hpp new file mode 100644 index 0000000..a7ee595 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/core.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GPU_CORE_API_HPP +#define OPENCV_GAPI_GPU_CORE_API_HPP +/** @file +* @deprecated Use instead. +*/ + +#include + +namespace cv { +namespace gapi { +namespace core { +namespace gpu { + using namespace ocl; +} // namespace gpu +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_GPU_CORE_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/ggpukernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/ggpukernel.hpp new file mode 100644 index 0000000..b52c21d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/ggpukernel.hpp @@ -0,0 +1,18 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GGPUKERNEL_HPP +#define OPENCV_GAPI_GGPUKERNEL_HPP +/** @file +* @deprecated Use instead. +*/ + +#include +#define GAPI_GPU_KERNEL GAPI_OCL_KERNEL + + +#endif // OPENCV_GAPI_GGPUKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/imgproc.hpp new file mode 100644 index 0000000..b0df7ae --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gpu/imgproc.hpp @@ -0,0 +1,28 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GPU_IMGPROC_API_HPP +#define OPENCV_GAPI_GPU_IMGPROC_API_HPP +/** @file +* @deprecated Use instead. +*/ + +#include + + +namespace cv { +namespace gapi { +namespace imgproc { +namespace gpu { + using namespace ocl; +} // namespace gpu +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_GPU_IMGPROC_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gscalar.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gscalar.hpp new file mode 100644 index 0000000..7ebeded --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gscalar.hpp @@ -0,0 +1,140 @@ +// This file is part of OpenCV project. + +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GSCALAR_HPP +#define OPENCV_GAPI_GSCALAR_HPP + +#include + +#include +#include // GShape +#include + +namespace cv +{ +// Forward declaration; GNode and GOrigin are an internal +// (user-inaccessible) classes. +class GNode; +struct GOrigin; + +/** \addtogroup gapi_data_objects + * @{ + */ +/** + * @brief GScalar class represents cv::Scalar data in the graph. + * + * GScalar may be associated with a cv::Scalar value, which becomes + * its constant value bound in graph compile time. cv::GScalar describes a + * functional relationship between operations consuming and producing + * GScalar objects. + * + * GScalar is a virtual counterpart of cv::Scalar, which is usually used + * to represent the GScalar data in G-API during the execution. + * + * @sa Scalar + */ +class GAPI_EXPORTS_W_SIMPLE GScalar +{ +public: + /** + * @brief Constructs an empty GScalar + * + * Normally, empty G-API data objects denote a starting point of + * the graph. When an empty GScalar is assigned to a result of some + * operation, it obtains a functional link to this operation (and + * is not empty anymore). + */ + GAPI_WRAP GScalar(); + + /** + * @brief Constructs a value-initialized GScalar + * + * In contrast with GMat (which can be either an explicit graph input + * or a result of some operation), GScalars may have their values + * be associated at graph construction time. It is useful when + * some operation has a GScalar input which doesn't change during + * the program execution, and is set only once. In this case, + * there is no need to declare such GScalar as a graph input. + * + * @note The value of GScalar may be overwritten by assigning some + * other GScalar to the object using `operator=` -- on the + * assigment, the old GScalar value is discarded. + * + * @param s a cv::Scalar value to associate with this GScalar object. + */ + explicit GScalar(const cv::Scalar& s); + + /** + * @overload + * @brief Constructs a value-initialized GScalar + * + * @param s a cv::Scalar value to associate with this GScalar object. + */ + explicit GScalar(cv::Scalar&& s); // Constant value move-constructor from cv::Scalar + + /** + * @overload + * @brief Constructs a value-initialized GScalar + * + * @param v0 A `double` value to associate with this GScalar. Note + * that only the first component of a four-component cv::Scalar is + * set to this value, with others remain zeros. + * + * This constructor overload is not marked `explicit` and can be + * used in G-API expression code like this: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp gscalar_implicit + * + * Here operator+(GMat,GScalar) is used to wrap cv::gapi::addC() + * and a value-initialized GScalar is created on the fly. + * + * @overload + */ + GScalar(double v0); // Constant value constructor from double + + /// @private + GScalar(const GNode &n, std::size_t out); // Operation result constructor + /// @private + GOrigin& priv(); // Internal use only + /// @private + const GOrigin& priv() const; // Internal use only + +private: + std::shared_ptr m_priv; +}; + +/** @} */ + +/** + * \addtogroup gapi_meta_args + * @{ + */ +struct GAPI_EXPORTS_W_SIMPLE GScalarDesc +{ + // NB.: right now it is empty + + inline bool operator== (const GScalarDesc &) const + { + return true; // NB: implement this method if GScalar meta appears + } + + inline bool operator!= (const GScalarDesc &rhs) const + { + return !(*this == rhs); + } +}; + +GAPI_EXPORTS_W inline GScalarDesc empty_scalar_desc() { return GScalarDesc(); } + +GAPI_EXPORTS GScalarDesc descr_of(const cv::Scalar &scalar); + +std::ostream& operator<<(std::ostream& os, const cv::GScalarDesc &desc); + +} // namespace cv + +#endif // OPENCV_GAPI_GSCALAR_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gstreaming.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gstreaming.hpp new file mode 100644 index 0000000..890eb58 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gstreaming.hpp @@ -0,0 +1,430 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GSTREAMING_COMPILED_HPP +#define OPENCV_GAPI_GSTREAMING_COMPILED_HPP + +#include +#include + +#include +#include +#include +#include +#include + +namespace cv { + +template using optional = cv::util::optional; + +namespace detail { +template struct wref_spec { + using type = T; +}; +template struct wref_spec > { + using type = T; +}; + +template +struct OptRef { + struct OptHolder { + virtual void mov(RefHolder &h) = 0; + virtual void reset() = 0; + virtual ~OptHolder() = default; + using Ptr = std::shared_ptr; + }; + template struct Holder final: OptHolder { + std::reference_wrapper > m_opt_ref; + + explicit Holder(cv::optional& opt) : m_opt_ref(std::ref(opt)) { + } + virtual void mov(RefHolder &h) override { + using U = typename wref_spec::type; + m_opt_ref.get() = cv::util::make_optional(std::move(h.template wref())); + } + virtual void reset() override { + m_opt_ref.get().reset(); + } + }; + template + explicit OptRef(cv::optional& t) : m_opt{new Holder(t)} {} + void mov(RefHolder &h) { m_opt->mov(h); } + void reset() { m_opt->reset();} +private: + typename OptHolder::Ptr m_opt; +}; +using OptionalVectorRef = OptRef; +using OptionalOpaqueRef = OptRef; +} // namespace detail + +// TODO: Keep it in sync with GRunArgP (derive the type automatically?) +using GOptRunArgP = util::variant< + optional*, + optional*, + optional*, + optional*, + cv::detail::OptionalVectorRef, + cv::detail::OptionalOpaqueRef +>; +using GOptRunArgsP = std::vector; + +using GOptRunArg = util::variant< + optional, + optional, + optional, + optional, + optional, + optional +>; +using GOptRunArgs = std::vector; + +namespace detail { + +template inline GOptRunArgP wrap_opt_arg(optional& arg) { + // By default, T goes to an OpaqueRef. All other types are specialized + return GOptRunArgP{OptionalOpaqueRef(arg)}; +} + +template inline GOptRunArgP wrap_opt_arg(optional >& arg) { + return GOptRunArgP{OptionalVectorRef(arg)}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &m) { + return GOptRunArgP{&m}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &m) { + return GOptRunArgP{&m}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &f) { + return GOptRunArgP{&f}; +} + +template<> inline GOptRunArgP wrap_opt_arg(optional &s) { + return GOptRunArgP{&s}; +} + +} // namespace detail + +// Now cv::gout() may produce an empty vector (see "dynamic graphs"), so +// there may be a conflict between these two. State here that Opt version +// _must_ have at least one input for this overload +template +inline GOptRunArgsP gout(optional&arg, optional&... args) +{ + return GOptRunArgsP{ detail::wrap_opt_arg(arg), detail::wrap_opt_arg(args)... }; +} + +/** + * \addtogroup gapi_main_classes + * @{ + */ +/** + * @brief Represents a computation (graph) compiled for streaming. + * + * This class represents a product of graph compilation (calling + * cv::GComputation::compileStreaming()). Objects of this class + * actually do stream processing, and the whole pipeline execution + * complexity is incapsulated into objects of this class. Execution + * model has two levels: at the very top, the execution of a + * heterogeneous graph is aggressively pipelined; at the very bottom + * the execution of every internal block is determined by its + * associated backend. Backends are selected based on kernel packages + * passed via compilation arguments ( see @ref gapi_compile_args, + * GNetworkPackage, GKernelPackage for details). + * + * GStreamingCompiled objects have a "player" semantics -- there are + * methods like start() and stop(). GStreamingCompiled has a full + * control over a videostream and so is stateful. You need to specify the + * input stream data using setSource() and then call start() to + * actually start processing. After that, use pull() or try_pull() to + * obtain next processed data frame from the graph in a blocking or + * non-blocking way, respectively. + * + * Currently a single GStreamingCompiled can process only one video + * streat at time. Produce multiple GStreamingCompiled objects to run the + * same graph on multiple video streams. + * + * @sa GCompiled + */ +class GAPI_EXPORTS_W_SIMPLE GStreamingCompiled +{ +public: + class GAPI_EXPORTS Priv; + GAPI_WRAP GStreamingCompiled(); + + // FIXME: More overloads? + /** + * @brief Specify the input data to GStreamingCompiled for + * processing, a generic version. + * + * Use gin() to create an input parameter vector. + * + * Input vectors must have the same number of elements as defined + * in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::Mat needs to be passed where cv::GMat has been + * declared as input, and so on). Run-time exception is generated + * on type mismatch. + * + * In contrast with regular GCompiled, user can also pass an + * object of type GVideoCapture for a GMat parameter of the parent + * GComputation. The compiled pipeline will start fetching data + * from that GVideoCapture and feeding it into the + * pipeline. Pipeline stops when a GVideoCapture marks end of the + * stream (or when stop() is called). + * + * Passing a regular Mat for a GMat parameter makes it "infinite" + * source -- pipeline may run forever feeding with this Mat until + * stopped explicitly. + * + * Currently only a single GVideoCapture is supported as input. If + * the parent GComputation is declared with multiple input GMat's, + * one of those can be specified as GVideoCapture but all others + * must be regular Mat objects. + * + * Throws if pipeline is already running. Use stop() and then + * setSource() to run the graph on a new video stream. + * + * @note This method is not thread-safe (with respect to the user + * side) at the moment. Protect the access if + * start()/stop()/setSource() may be called on the same object in + * multiple threads in your application. + * + * @param ins vector of inputs to process. + * @sa gin + */ + void setSource(GRunArgs &&ins); + + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP void setSource(const cv::detail::ExtractArgsCallback& callback); + + /** + * @brief Specify an input video stream for a single-input + * computation pipeline. + * + * Throws if pipeline is already running. Use stop() and then + * setSource() to run the graph on a new video stream. + * + * @overload + * @param s a shared pointer to IStreamSource representing the + * input video stream. + */ + void setSource(const gapi::wip::IStreamSource::Ptr& s); + + /** + * @brief Constructs and specifies an input video stream for a + * single-input computation pipeline with the given parameters. + * + * Throws if pipeline is already running. Use stop() and then + * setSource() to run the graph on a new video stream. + * + * @overload + * @param args arguments used to contruct and initialize a stream + * source. + */ + template + void setSource(Args&&... args) { + setSource(cv::gapi::wip::make_src(std::forward(args)...)); + } + + /** + * @brief Start the pipeline execution. + * + * Use pull()/try_pull() to obtain data. Throws an exception if + * a video source was not specified. + * + * setSource() must be called first, even if the pipeline has been + * working already and then stopped (explicitly via stop() or due + * stream completion) + * + * @note This method is not thread-safe (with respect to the user + * side) at the moment. Protect the access if + * start()/stop()/setSource() may be called on the same object in + * multiple threads in your application. + */ + GAPI_WRAP void start(); + + /** + * @brief Get the next processed frame from the pipeline. + * + * Use gout() to create an output parameter vector. + * + * Output vectors must have the same number of elements as defined + * in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::Mat needs to be passed where cv::GMat has been + * declared as output, and so on). Run-time exception is generated + * on type mismatch. + * + * This method writes new data into objects passed via output + * vector. If there is no data ready yet, this method blocks. Use + * try_pull() if you need a non-blocking version. + * + * @param outs vector of output parameters to obtain. + * @return true if next result has been obtained, + * false marks end of the stream. + */ + bool pull(cv::GRunArgsP &&outs); + + // NB: Used from python + /// @private -- Exclude this function from OpenCV documentation + GAPI_WRAP std::tuple> pull(); + + /** + * @brief Get some next available data from the pipeline. + * + * This method takes a vector of cv::optional object. An object is + * assigned to some value if this value is available (ready) at + * the time of the call, and resets the object to empty() if it is + * not. + * + * This is a blocking method which guarantees that some data has + * been written to the output vector on return. + * + * Using this method only makes sense if the graph has + * desynchronized parts (see cv::gapi::desync). If there is no + * desynchronized parts in the graph, the behavior of this + * method is identical to the regular pull() (all data objects are + * produced synchronously in the output vector). + * + * Use gout() to create an output parameter vector. + * + * Output vectors must have the same number of elements as defined + * in the cv::GComputation protocol (at the moment of its + * construction). Shapes of elements also must conform to protocol + * (e.g. cv::optional needs to be passed where cv::GMat + * has been declared as output, and so on). Run-time exception is + * generated on type mismatch. + * + * This method writes new data into objects passed via output + * vector. If there is no data ready yet, this method blocks. Use + * try_pull() if you need a non-blocking version. + * + * @param outs vector of output parameters to obtain. + * @return true if next result has been obtained, + * false marks end of the stream. + * + * @sa cv::gapi::desync + */ + bool pull(cv::GOptRunArgsP &&outs); + + /** + * @brief Try to get the next processed frame from the pipeline. + * + * Use gout() to create an output parameter vector. + * + * This method writes new data into objects passed via output + * vector. If there is no data ready yet, the output vector + * remains unchanged and false is returned. + * + * @return true if data has been obtained, and false if it was + * not. Note: false here doesn't mark the end of the stream. + */ + bool try_pull(cv::GRunArgsP &&outs); + + /** + * @brief Stop (abort) processing the pipeline. + * + * Note - it is not pause but a complete stop. Calling start() + * will cause G-API to start processing the stream from the early beginning. + * + * Throws if the pipeline is not running. + */ + GAPI_WRAP void stop(); + + /** + * @brief Test if the pipeline is running. + * + * @note This method is not thread-safe (with respect to the user + * side) at the moment. Protect the access if + * start()/stop()/setSource() may be called on the same object in + * multiple threads in your application. + * + * @return true if the current stream is not over yet. + */ + GAPI_WRAP bool running() const; + + /// @private + Priv& priv(); + + /** + * @brief Check if compiled object is valid (non-empty) + * + * @return true if the object is runnable (valid), false otherwise + */ + explicit operator bool () const; + + /** + * @brief Vector of metadata this graph was compiled for. + * + * @return Unless _reshape_ is not supported, return value is the + * same vector which was passed to cv::GComputation::compile() to + * produce this compiled object. Otherwise, it is the latest + * metadata vector passed to reshape() (if that call was + * successful). + */ + const GMetaArgs& metas() const; // Meta passed to compile() + + /** + * @brief Vector of metadata descriptions of graph outputs + * + * @return vector with formats/resolutions of graph's output + * objects, auto-inferred from input metadata vector by + * operations which form this computation. + * + * @note GCompiled objects produced from the same + * cv::GComputiation graph with different input metas may return + * different values in this vector. + */ + const GMetaArgs& outMetas() const; + +protected: + /// @private + std::shared_ptr m_priv; +}; +/** @} */ + +namespace gapi { + +/** + * @brief This namespace contains G-API functions, structures, and + * symbols related to the Streaming execution mode. + * + * Some of the operations defined in this namespace (e.g. size(), + * BGR(), etc.) can be used in the traditional execution mode too. + */ +namespace streaming { +/** + * @brief Specify queue capacity for streaming execution. + * + * In the streaming mode the pipeline steps are connected with queues + * and this compile argument controls every queue's size. + */ +struct GAPI_EXPORTS_W_SIMPLE queue_capacity +{ + GAPI_WRAP + explicit queue_capacity(size_t cap = 1) : capacity(cap) { }; + GAPI_PROP_RW + size_t capacity; +}; +/** @} */ +} // namespace streaming +} // namespace gapi + +namespace detail +{ +template<> struct CompileArgTag +{ + static const char* tag() { return "gapi.queue_capacity"; } +}; +} + +} + +#endif // OPENCV_GAPI_GSTREAMING_COMPILED_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtransform.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtransform.hpp new file mode 100644 index 0000000..109bc87 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtransform.hpp @@ -0,0 +1,103 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_GTRANSFORM_HPP +#define OPENCV_GAPI_GTRANSFORM_HPP + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace cv +{ + +struct GAPI_EXPORTS GTransform +{ + // FIXME: consider another simplified + // class instead of GComputation + using F = std::function; + + std::string description; + F pattern; + F substitute; + + GTransform(const std::string& d, const F &p, const F &s) : description(d), pattern(p), substitute(s) {} +}; + +namespace detail +{ + +template +struct TransHelper; + +template +struct TransHelper, Out> +{ + template + static GComputation invoke(Callable f, Seq, Seq) + { + const std::tuple ins; + const auto r = tuple_wrap_helper::get(f(std::get(ins)...)); + return GComputation(cv::GIn(std::get(ins)...), + cv::GOut(std::get(r)...)); + } + + static GComputation get_pattern() + { + return invoke(K::pattern, typename MkSeq::type(), + typename MkSeq::type>::value>::type()); + } + static GComputation get_substitute() + { + return invoke(K::substitute, typename MkSeq::type(), + typename MkSeq::type>::value>::type()); + } +}; +} // namespace detail + +template +class GTransformImpl; + +template +class GTransformImpl> : public cv::detail::TransHelper, R>, + public cv::detail::TransformTag +{ +public: + // FIXME: currently there is no check that transformations' signatures are unique + // and won't be any intersection in graph compilation stage + using API = K; + + static GTransform transformation() + { + return GTransform(K::descr(), &K::get_pattern, &K::get_substitute); + } +}; +} // namespace cv + +#define G_DESCR_HELPER_CLASS(Class) Class##DescrHelper + +#define G_DESCR_HELPER_BODY(Class, Descr) \ + namespace detail \ + { \ + struct G_DESCR_HELPER_CLASS(Class) \ + { \ + static constexpr const char *descr() { return Descr; }; \ + }; \ + } + +#define GAPI_TRANSFORM(Class, API, Descr) \ + G_DESCR_HELPER_BODY(Class, Descr) \ + struct Class final : public cv::GTransformImpl, \ + public detail::G_DESCR_HELPER_CLASS(Class) + +#endif // OPENCV_GAPI_GTRANSFORM_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtype_traits.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtype_traits.hpp new file mode 100644 index 0000000..2b43421 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtype_traits.hpp @@ -0,0 +1,240 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GTYPE_TRAITS_HPP +#define OPENCV_GAPI_GTYPE_TRAITS_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cv +{ +namespace detail +{ + template + struct contains_shape_field : std::false_type {}; + + template + struct contains_shape_field> : + std::is_same::type, GShape> + {}; + + template + struct has_gshape : contains_shape_field {}; + + // FIXME: These traits and enum and possible numerous switch(kind) + // block may be replaced with a special Handler object or with + // a double dispatch + enum class ArgKind: int + { + OPAQUE_VAL, // Unknown, generic, opaque-to-GAPI data type - STATIC + // Note: OPAQUE is sometimes defined in Win sys headers +#if !defined(OPAQUE) && !defined(CV_DOXYGEN) + OPAQUE = OPAQUE_VAL, // deprecated value used for compatibility, use OPAQUE_VAL instead +#endif + GOBJREF, // reference to object + GMAT, // a cv::GMat + GMATP, // a cv::GMatP + GFRAME, // a cv::GFrame + GSCALAR, // a cv::GScalar + GARRAY, // a cv::GArrayU (note - exactly GArrayU, not GArray!) + GOPAQUE, // a cv::GOpaqueU (note - exactly GOpaqueU, not GOpaque!) + }; + + // Describe G-API types (G-types) with traits. Mostly used by + // cv::GArg to store meta information about types passed into + // operation arguments. Please note that cv::GComputation is + // defined on GProtoArgs, not GArgs! + template struct GTypeTraits; + template struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::OPAQUE_VAL; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GMAT; + static constexpr const GShape shape = GShape::GMAT; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GMATP; + static constexpr const GShape shape = GShape::GMAT; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GFRAME; + static constexpr const GShape shape = GShape::GFRAME; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template<> struct GTypeTraits + { + static constexpr const ArgKind kind = ArgKind::GSCALAR; + static constexpr const GShape shape = GShape::GSCALAR; + static constexpr const OpaqueKind op_kind = OpaqueKind::CV_UNKNOWN; + }; + template struct GTypeTraits > + { + static constexpr const ArgKind kind = ArgKind::GARRAY; + static constexpr const GShape shape = GShape::GARRAY; + static constexpr const OpaqueKind op_kind = GOpaqueTraits::kind; + using host_type = std::vector; + using strip_type = cv::detail::VectorRef; + static cv::detail::GArrayU wrap_value(const cv::GArray &t) { return t.strip();} + static cv::detail::VectorRef wrap_in (const std::vector &t) { return detail::VectorRef(t); } + static cv::detail::VectorRef wrap_out ( std::vector &t) { return detail::VectorRef(t); } + }; + template struct GTypeTraits > + { + static constexpr const ArgKind kind = ArgKind::GOPAQUE; + static constexpr const GShape shape = GShape::GOPAQUE; + static constexpr const OpaqueKind op_kind = GOpaqueTraits::kind; + using host_type = T; + using strip_type = cv::detail::OpaqueRef; + static cv::detail::GOpaqueU wrap_value(const cv::GOpaque &t) { return t.strip();} + static cv::detail::OpaqueRef wrap_in (const T &t) { return detail::OpaqueRef(t); } + static cv::detail::OpaqueRef wrap_out ( T &t) { return detail::OpaqueRef(t); } + }; + + // Tests if Trait for type T requires extra marshalling ("custom wrap") or not. + // If Traits has wrap_value() defined, it does. + template struct has_custom_wrap + { + template class check; + template static std::true_type test(check::wrap_value)> *); + template static std::false_type test(...); + using type = decltype(test(nullptr)); + static const constexpr bool value = std::is_same(nullptr))>::value; + }; + + // Resolve a Host type back to its associated G-Type. + // FIXME: Probably it can be avoided + // FIXME: GMatP is not present here. + // (Actually these traits is used only to check + // if associated G-type has custom wrap functions + // and GMat behavior is correct for GMatP) + template struct GTypeOf; +#if !defined(GAPI_STANDALONE) + template<> struct GTypeOf { using type = cv::GMat; }; +#endif // !defined(GAPI_STANDALONE) + template<> struct GTypeOf { using type = cv::GMat; }; + template<> struct GTypeOf { using type = cv::GMat; }; + template<> struct GTypeOf { using type = cv::GScalar; }; + template struct GTypeOf > { using type = cv::GArray; }; + template struct GTypeOf { using type = cv::GOpaque;}; + template<> struct GTypeOf { using type = cv::GFrame; }; + // FIXME: This is not quite correct since IStreamSource may produce not only Mat but also Scalar + // and vector data. TODO: Extend the type dispatching on these types too. + template<> struct GTypeOf { using type = cv::GMat;}; + template using g_type_of_t = typename GTypeOf::type; + + // Marshalling helper for G-types and its Host types. Helps G-API + // to store G types in internal generic containers for further + // processing. Implements the following callbacks: + // + // * wrap() - converts user-facing G-type into an internal one + // for internal storage. + // Used when G-API operation is instantiated (G::on(), + // etc) during expressing a pipeline. Mostly returns input + // value "as is" except the case when G-type is a template. For + // template G-classes, calls custom wrap() from Traits. + // The value returned by wrap() is then wrapped into GArg() and + // stored in G-API metadata. + // + // Example: + // - cv::GMat arguments are passed as-is. + // - integers, pointers, STL containers, user types are passed as-is. + // - cv::GArray is converted to cv::GArrayU. + // + // * wrap_in() / wrap_out() - convert Host type associated with + // G-type to internal representation type. + // + // - For "simple" (non-template) G-types, returns value as-is. + // Example: cv::GMat has host type cv::Mat, when user passes a + // cv::Mat, system stores it internally as cv::Mat. + // + // - For "complex" (template) G-types, utilizes custom + // wrap_in()/wrap_out() as described in Traits. + // Example: cv::GArray has host type std::vector, when + // user passes a std::vector, system stores it + // internally as VectorRef (with stripped away). + template struct WrapValue + { + static auto wrap(const T& t) -> + typename std::remove_reference::type + { + return static_cast::type>(t); + } + + template static U wrap_in (const U &u) { return u; } + template static U* wrap_out(U &u) { return &u; } + }; + template struct WrapValue::value>::type> + { + static auto wrap(const T& t) -> decltype(GTypeTraits::wrap_value(t)) + { + return GTypeTraits::wrap_value(t); + } + template static auto wrap_in (const U &u) -> typename GTypeTraits::strip_type + { + static_assert(!(cv::detail::has_gshape>::value + || cv::detail::contains::type, GAPI_OWN_TYPES_LIST>::value), + "gin/gout must not be used with G* classes or cv::gapi::own::*"); + return GTypeTraits::wrap_in(u); + } + template static auto wrap_out(U &u) -> typename GTypeTraits::strip_type + { + static_assert(!(cv::detail::has_gshape>::value + || cv::detail::contains::type, GAPI_OWN_TYPES_LIST>::value), + "gin/gout must not be used with G* classses or cv::gapi::own::*"); + return GTypeTraits::wrap_out(u); + } + }; + + template using wrap_gapi_helper = WrapValue::type>; + template using wrap_host_helper = WrapValue >::type>; + +// Union type for various user-defined type constructors (GArray, +// GOpaque, etc) +// +// TODO: Replace construct-only API with a more generic one (probably +// with bits of introspection) +// +// Not required for non-user-defined types (GMat, GScalar, etc) +using HostCtor = util::variant + < util::monostate + , detail::ConstructVec + , detail::ConstructOpaque + >; + +template struct GObtainCtor { + static HostCtor get() { return HostCtor{}; } +}; +template struct GObtainCtor > { + static HostCtor get() { return HostCtor{ConstructVec{&GArray::VCtor}}; }; +}; +template struct GObtainCtor > { + static HostCtor get() { return HostCtor{ConstructOpaque{&GOpaque::Ctor}}; }; +}; +} // namespace detail +} // namespace cv + +#endif // OPENCV_GAPI_GTYPE_TRAITS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtyped.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtyped.hpp new file mode 100644 index 0000000..c1c16d1 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/gtyped.hpp @@ -0,0 +1,246 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GTYPED_HPP +#define OPENCV_GAPI_GTYPED_HPP +#if !defined(GAPI_STANDALONE) + +#include + +#include +#include +#include +#include + +namespace cv { + +namespace detail +{ + // FIXME: How to prevent coolhackers from extending it by their own types? + // FIXME: ...Should we care? + template struct ProtoToParam; + template<> struct ProtoToParam { using type = cv::Mat; }; + template<> struct ProtoToParam { using type = cv::Scalar; }; + template struct ProtoToParam > { using type = std::vector; }; + template<> struct ProtoToParam> { using type = std::vector; }; + template struct ProtoToParam > { using type = U; }; + template using ProtoToParamT = typename ProtoToParam::type; + + template struct ProtoToMeta; + template<> struct ProtoToMeta { using type = cv::GMatDesc; }; + template<> struct ProtoToMeta { using type = cv::GScalarDesc; }; + template struct ProtoToMeta > { using type = cv::GArrayDesc; }; + template struct ProtoToMeta > { using type = cv::GOpaqueDesc; }; + template using ProtoToMetaT = typename ProtoToMeta::type; + + //workaround for MSVC 19.0 bug + template + auto make_default()->decltype(T{}) {return {};} +}; // detail + +/** + * @brief This class is a typed wrapper over a regular GComputation. + * + * `std::function<>`-like template parameter specifies the graph + * signature so methods so the object's constructor, methods like + * `apply()` and the derived `GCompiledT::operator()` also become + * typed. + * + * There is no need to use cv::gin() or cv::gout() modifiers with + * objects of this class. Instead, all input arguments are followed + * by all output arguments in the order from the template argument + * signature. + * + * Refer to the following example. Regular (untyped) code is written this way: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp Untyped_Example + * + * Here: + * + * - cv::GComputation object is created with a lambda constructor + * where it is defined as a two-input, one-output graph. + * + * - Its method `apply()` in fact takes arbitrary number of arguments + * (as vectors) so user can pass wrong number of inputs/outputs + * here. C++ compiler wouldn't notice that since the cv::GComputation + * API is polymorphic, and only a run-time error will be generated. + * + * Now the same code written with typed API: + * + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp Typed_Example + * + * The key difference is: + * + * - Now the constructor lambda *must take* parameters and *must + * return* values as defined in the `GComputationT<>` signature. + * - Its method `apply()` does not require any extra specifiers to + * separate input arguments from the output ones + * - A `GCompiledT` (compilation product) takes input/output + * arguments with no extra specifiers as well. + */ +template class GComputationT; + +// Single return value implementation +template class GComputationT +{ +public: + typedef std::function Gen; + + class GCompiledT + { + private: + friend class GComputationT; + + cv::GCompiled m_comp; + + explicit GCompiledT(const cv::GCompiled &comp) : m_comp(comp) {} + + public: + GCompiledT() {} + + void operator()(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT &outArg) + { + m_comp(cv::gin(inArgs...), cv::gout(outArg)); + } + + explicit operator bool() const + { + return static_cast(m_comp); + } + }; + +private: + typedef std::pair Captured; + + Captured capture(const Gen& g, Args... args) + { + return Captured(g(args...), cv::GIn(args...)); + } + + Captured m_capture; + cv::GComputation m_comp; + +public: + GComputationT(const Gen &generator) + : m_capture(capture(generator, detail::make_default()...)) + , m_comp(cv::GProtoInputArgs(std::move(m_capture.second)), + cv::GOut(m_capture.first)) + { + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT &outArg, + GCompileArgs &&args) + { + m_comp.apply(cv::gin(inArgs...), cv::gout(outArg), std::move(args)); + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT &outArg) + { + apply(inArgs..., outArg, GCompileArgs()); + } + + + GCompiledT compile(detail::ProtoToMetaT... inDescs) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), GCompileArgs())); + } + + GCompiledT compile(detail::ProtoToMetaT... inDescs, GCompileArgs &&args) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), std::move(args))); + } +}; + +// Multiple (fixed) return value implementation. FIXME: How to avoid copy-paste? +template class GComputationT(Args...)> +{ +public: + typedef std::function(Args...)> Gen; + + class GCompiledT + { + private: + friend class GComputationT(Args...)>; + + cv::GCompiled m_comp; + explicit GCompiledT(const cv::GCompiled &comp) : m_comp(comp) {} + + public: + GCompiledT() {} + + void operator()(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT&... outArgs) + { + m_comp(cv::gin(inArgs...), cv::gout(outArgs...)); + } + + explicit operator bool() const + { + return static_cast(m_comp); + } + }; + +private: + typedef std::pair Captured; + + template + Captured capture(GProtoArgs &&args, const std::tuple &rr, detail::Seq) + { + return Captured(cv::GOut(std::get(rr)...).m_args, args); + } + + Captured capture(const Gen& g, Args... args) + { + return capture(cv::GIn(args...).m_args, g(args...), typename detail::MkSeq::type()); + } + + Captured m_capture; + cv::GComputation m_comp; + +public: + GComputationT(const Gen &generator) + : m_capture(capture(generator, detail::make_default()...)) + , m_comp(cv::GProtoInputArgs(std::move(m_capture.second)), + cv::GProtoOutputArgs(std::move(m_capture.first))) + { + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT&... outArgs, + GCompileArgs &&args) + { + m_comp.apply(cv::gin(inArgs...), cv::gout(outArgs...), std::move(args)); + } + + void apply(detail::ProtoToParamT... inArgs, + detail::ProtoToParamT&... outArgs) + { + apply(inArgs..., outArgs..., GCompileArgs()); + } + + + GCompiledT compile(detail::ProtoToMetaT... inDescs) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), GCompileArgs())); + } + + GCompiledT compile(detail::ProtoToMetaT... inDescs, GCompileArgs &&args) + { + GMetaArgs inMetas = { GMetaArg(inDescs)... }; + return GCompiledT(m_comp.compile(std::move(inMetas), std::move(args))); + } +}; + +} // namespace cv +#endif // !defined(GAPI_STANDALONE) +#endif // OPENCV_GAPI_GTYPED_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/imgproc.hpp new file mode 100644 index 0000000..5c4c6f7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/imgproc.hpp @@ -0,0 +1,1682 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_IMGPROC_HPP +#define OPENCV_GAPI_IMGPROC_HPP + +#include + +#include // std::tuple + +#include +#include +#include + + +/** \defgroup gapi_imgproc G-API Image processing functionality +@{ + @defgroup gapi_filters Graph API: Image filters + @defgroup gapi_colorconvert Graph API: Converting image from one color space to another + @defgroup gapi_feature Graph API: Image Feature Detection + @defgroup gapi_shape Graph API: Image Structural Analysis and Shape Descriptors +@} + */ + +namespace { +void validateFindingContoursMeta(const int depth, const int chan, const int mode) +{ + GAPI_Assert(chan == 1); + switch (mode) + { + case cv::RETR_CCOMP: + GAPI_Assert(depth == CV_8U || depth == CV_32S); + break; + case cv::RETR_FLOODFILL: + GAPI_Assert(depth == CV_32S); + break; + default: + GAPI_Assert(depth == CV_8U); + break; + } +} +} // anonymous namespace + +namespace cv { namespace gapi { + +/** + * @brief This namespace contains G-API Operation Types for OpenCV + * ImgProc module functionality. + */ +namespace imgproc { + using GMat2 = std::tuple; + using GMat3 = std::tuple; // FIXME: how to avoid this? + using GFindContoursOutput = std::tuple>,GArray>; + + G_TYPED_KERNEL(GFilter2D, ,"org.opencv.imgproc.filters.filter2D") { + static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Point, Scalar, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GSepFilter, , "org.opencv.imgproc.filters.sepfilter") { + static GMatDesc outMeta(GMatDesc in, int ddepth, Mat, Mat, Point, Scalar, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GBoxFilter, , "org.opencv.imgproc.filters.boxfilter") { + static GMatDesc outMeta(GMatDesc in, int ddepth, Size, Point, bool, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GBlur, , "org.opencv.imgproc.filters.blur"){ + static GMatDesc outMeta(GMatDesc in, Size, Point, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GGaussBlur, , "org.opencv.imgproc.filters.gaussianBlur") { + static GMatDesc outMeta(GMatDesc in, Size, double, double, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GMedianBlur, , "org.opencv.imgproc.filters.medianBlur") { + static GMatDesc outMeta(GMatDesc in, int) { + return in; + } + }; + + G_TYPED_KERNEL(GErode, , "org.opencv.imgproc.filters.erode") { + static GMatDesc outMeta(GMatDesc in, Mat, Point, int, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GDilate, , "org.opencv.imgproc.filters.dilate") { + static GMatDesc outMeta(GMatDesc in, Mat, Point, int, int, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GMorphologyEx, , + "org.opencv.imgproc.filters.morphologyEx") { + static GMatDesc outMeta(const GMatDesc &in, MorphTypes, Mat, Point, int, + BorderTypes, Scalar) { + return in; + } + }; + + G_TYPED_KERNEL(GSobel, , "org.opencv.imgproc.filters.sobel") { + static GMatDesc outMeta(GMatDesc in, int ddepth, int, int, int, double, double, int, Scalar) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL_M(GSobelXY, , "org.opencv.imgproc.filters.sobelxy") { + static std::tuple outMeta(GMatDesc in, int ddepth, int, int, double, double, int, Scalar) { + return std::make_tuple(in.withDepth(ddepth), in.withDepth(ddepth)); + } + }; + + G_TYPED_KERNEL(GLaplacian, , + "org.opencv.imgproc.filters.laplacian") { + static GMatDesc outMeta(GMatDesc in, int ddepth, int, double, double, int) { + return in.withDepth(ddepth); + } + }; + + G_TYPED_KERNEL(GBilateralFilter, , + "org.opencv.imgproc.filters.bilateralfilter") { + static GMatDesc outMeta(GMatDesc in, int, double, double, int) { + return in; + } + }; + + G_TYPED_KERNEL(GEqHist, , "org.opencv.imgproc.equalizeHist"){ + static GMatDesc outMeta(GMatDesc in) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GCanny, , "org.opencv.imgproc.feature.canny"){ + static GMatDesc outMeta(GMatDesc in, double, double, int, bool) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GGoodFeatures, + (GMat,int,double,double,Mat,int,bool,double)>, + "org.opencv.imgproc.feature.goodFeaturesToTrack") { + static GArrayDesc outMeta(GMatDesc, int, double, double, const Mat&, int, bool, double) { + return empty_array_desc(); + } + }; + + using RetrMode = RetrievalModes; + using ContMethod = ContourApproximationModes; + G_TYPED_KERNEL(GFindContours, >(GMat,RetrMode,ContMethod,GOpaque)>, + "org.opencv.imgproc.shape.findContours") + { + static GArrayDesc outMeta(GMatDesc in, RetrMode mode, ContMethod, GOpaqueDesc) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return empty_array_desc(); + } + }; + + // FIXME oc: make default value offset = Point() + G_TYPED_KERNEL(GFindContoursNoOffset, >(GMat,RetrMode,ContMethod)>, + "org.opencv.imgproc.shape.findContoursNoOffset") + { + static GArrayDesc outMeta(GMatDesc in, RetrMode mode, ContMethod) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return empty_array_desc(); + } + }; + + G_TYPED_KERNEL(GFindContoursH,)>, + "org.opencv.imgproc.shape.findContoursH") + { + static std::tuple + outMeta(GMatDesc in, RetrMode mode, ContMethod, GOpaqueDesc) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + }; + + // FIXME oc: make default value offset = Point() + G_TYPED_KERNEL(GFindContoursHNoOffset,, + "org.opencv.imgproc.shape.findContoursHNoOffset") + { + static std::tuple + outMeta(GMatDesc in, RetrMode mode, ContMethod) + { + validateFindingContoursMeta(in.depth, in.chan, mode); + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GBoundingRectMat, (GMat)>, + "org.opencv.imgproc.shape.boundingRectMat") { + static GOpaqueDesc outMeta(GMatDesc in) { + if (in.depth == CV_8U) + { + GAPI_Assert(in.chan == 1); + } + else + { + GAPI_Assert (in.depth == CV_32S || in.depth == CV_32F); + int amount = detail::checkVector(in, 2u); + GAPI_Assert(amount != -1 && + "Input Mat can't be described as vector of 2-dimentional points"); + } + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GBoundingRectVector32S, (GArray)>, + "org.opencv.imgproc.shape.boundingRectVector32S") { + static GOpaqueDesc outMeta(GArrayDesc) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GBoundingRectVector32F, (GArray)>, + "org.opencv.imgproc.shape.boundingRectVector32F") { + static GOpaqueDesc outMeta(GArrayDesc) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DMat, (GMat,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DMat") { + static GOpaqueDesc outMeta(GMatDesc in,DistanceTypes,double,double,double) { + int amount = detail::checkVector(in, 2u); + GAPI_Assert(amount != -1 && + "Input Mat can't be described as vector of 2-dimentional points"); + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DVector32S, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DVector32S") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DVector32F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DVector32F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine2DVector64F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine2DVector64F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DMat, (GMat,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DMat") { + static GOpaqueDesc outMeta(GMatDesc in,int,double,double,double) { + int amount = detail::checkVector(in, 3u); + GAPI_Assert(amount != -1 && + "Input Mat can't be described as vector of 3-dimentional points"); + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DVector32S, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DVector32S") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DVector32F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DVector32F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GFitLine3DVector64F, + (GArray,DistanceTypes,double,double,double)>, + "org.opencv.imgproc.shape.fitLine3DVector64F") { + static GOpaqueDesc outMeta(GArrayDesc,DistanceTypes,double,double,double) { + return empty_gopaque_desc(); + } + }; + + G_TYPED_KERNEL(GBGR2RGB, , "org.opencv.imgproc.colorconvert.bgr2rgb") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GRGB2YUV, , "org.opencv.imgproc.colorconvert.rgb2yuv") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GYUV2RGB, , "org.opencv.imgproc.colorconvert.yuv2rgb") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GBGR2I420, , "org.opencv.imgproc.colorconvert.bgr2i420") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + GAPI_Assert(in.size.height % 2 == 0); + return in.withType(in.depth, 1).withSize(Size(in.size.width, in.size.height * 3 / 2)); + } + }; + + G_TYPED_KERNEL(GRGB2I420, , "org.opencv.imgproc.colorconvert.rgb2i420") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + GAPI_Assert(in.size.height % 2 == 0); + return in.withType(in.depth, 1).withSize(Size(in.size.width, in.size.height * 3 / 2)); + } + }; + + G_TYPED_KERNEL(GI4202BGR, , "org.opencv.imgproc.colorconvert.i4202bgr") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 1); + GAPI_Assert(in.size.height % 3 == 0); + return in.withType(in.depth, 3).withSize(Size(in.size.width, in.size.height * 2 / 3)); + } + }; + + G_TYPED_KERNEL(GI4202RGB, , "org.opencv.imgproc.colorconvert.i4202rgb") { + static GMatDesc outMeta(GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 1); + GAPI_Assert(in.size.height % 3 == 0); + return in.withType(in.depth, 3).withSize(Size(in.size.width, in.size.height * 2 / 3)); + } + }; + + G_TYPED_KERNEL(GNV12toRGB, , "org.opencv.imgproc.colorconvert.nv12torgb") { + static GMatDesc outMeta(GMatDesc in_y, GMatDesc in_uv) { + GAPI_Assert(in_y.chan == 1); + GAPI_Assert(in_uv.chan == 2); + GAPI_Assert(in_y.depth == CV_8U); + GAPI_Assert(in_uv.depth == CV_8U); + // UV size should be aligned with Y + GAPI_Assert(in_y.size.width == 2 * in_uv.size.width); + GAPI_Assert(in_y.size.height == 2 * in_uv.size.height); + return in_y.withType(CV_8U, 3); // type will be CV_8UC3; + } + }; + + G_TYPED_KERNEL(GNV12toBGR, , "org.opencv.imgproc.colorconvert.nv12tobgr") { + static GMatDesc outMeta(GMatDesc in_y, GMatDesc in_uv) { + GAPI_Assert(in_y.chan == 1); + GAPI_Assert(in_uv.chan == 2); + GAPI_Assert(in_y.depth == CV_8U); + GAPI_Assert(in_uv.depth == CV_8U); + // UV size should be aligned with Y + GAPI_Assert(in_y.size.width == 2 * in_uv.size.width); + GAPI_Assert(in_y.size.height == 2 * in_uv.size.height); + return in_y.withType(CV_8U, 3); // type will be CV_8UC3; + } + }; + + G_TYPED_KERNEL(GRGB2Lab, , "org.opencv.imgproc.colorconvert.rgb2lab") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GBGR2LUV, , "org.opencv.imgproc.colorconvert.bgr2luv") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GLUV2BGR, , "org.opencv.imgproc.colorconvert.luv2bgr") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GYUV2BGR, , "org.opencv.imgproc.colorconvert.yuv2bgr") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GBGR2YUV, , "org.opencv.imgproc.colorconvert.bgr2yuv") { + static GMatDesc outMeta(GMatDesc in) { + return in; // type still remains CV_8UC3; + } + }; + + G_TYPED_KERNEL(GRGB2Gray, , "org.opencv.imgproc.colorconvert.rgb2gray") { + static GMatDesc outMeta(GMatDesc in) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GRGB2GrayCustom, , "org.opencv.imgproc.colorconvert.rgb2graycustom") { + static GMatDesc outMeta(GMatDesc in, float, float, float) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GBGR2Gray, , "org.opencv.imgproc.colorconvert.bgr2gray") { + static GMatDesc outMeta(GMatDesc in) { + return in.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GBayerGR2RGB, , "org.opencv.imgproc.colorconvert.bayergr2rgb") { + static cv::GMatDesc outMeta(cv::GMatDesc in) { + return in.withType(CV_8U, 3); + } + }; + + G_TYPED_KERNEL(GRGB2HSV, , "org.opencv.imgproc.colorconvert.rgb2hsv") { + static cv::GMatDesc outMeta(cv::GMatDesc in) { + return in; + } + }; + + G_TYPED_KERNEL(GRGB2YUV422, , "org.opencv.imgproc.colorconvert.rgb2yuv422") { + static cv::GMatDesc outMeta(cv::GMatDesc in) { + GAPI_Assert(in.depth == CV_8U); + GAPI_Assert(in.chan == 3); + return in.withType(in.depth, 2); + } + }; + + G_TYPED_KERNEL(GNV12toRGBp, , "org.opencv.imgproc.colorconvert.nv12torgbp") { + static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) { + GAPI_Assert(inY.depth == CV_8U); + GAPI_Assert(inUV.depth == CV_8U); + GAPI_Assert(inY.chan == 1); + GAPI_Assert(inY.planar == false); + GAPI_Assert(inUV.chan == 2); + GAPI_Assert(inUV.planar == false); + GAPI_Assert(inY.size.width == 2 * inUV.size.width); + GAPI_Assert(inY.size.height == 2 * inUV.size.height); + return inY.withType(CV_8U, 3).asPlanar(); + } + }; + + G_TYPED_KERNEL(GNV12toGray, , "org.opencv.imgproc.colorconvert.nv12togray") { + static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) { + GAPI_Assert(inY.depth == CV_8U); + GAPI_Assert(inUV.depth == CV_8U); + GAPI_Assert(inY.chan == 1); + GAPI_Assert(inY.planar == false); + GAPI_Assert(inUV.chan == 2); + GAPI_Assert(inUV.planar == false); + + GAPI_Assert(inY.size.width == 2 * inUV.size.width); + GAPI_Assert(inY.size.height == 2 * inUV.size.height); + return inY.withType(CV_8U, 1); + } + }; + + G_TYPED_KERNEL(GNV12toBGRp, , "org.opencv.imgproc.colorconvert.nv12tobgrp") { + static GMatDesc outMeta(GMatDesc inY, GMatDesc inUV) { + GAPI_Assert(inY.depth == CV_8U); + GAPI_Assert(inUV.depth == CV_8U); + GAPI_Assert(inY.chan == 1); + GAPI_Assert(inY.planar == false); + GAPI_Assert(inUV.chan == 2); + GAPI_Assert(inUV.planar == false); + GAPI_Assert(inY.size.width == 2 * inUV.size.width); + GAPI_Assert(inY.size.height == 2 * inUV.size.height); + return inY.withType(CV_8U, 3).asPlanar(); + } + }; + +} //namespace imgproc + +//! @addtogroup gapi_filters +//! @{ +/** @brief Applies a separable linear filter to a matrix(image). + +The function applies a separable linear filter to the matrix. That is, first, every row of src is +filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D +kernel kernelY. The final result is returned. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - In case of floating-point computation, rounding to nearest even is procedeed +if hardware supports it (if not - to nearest value). + - Function textual ID is "org.opencv.imgproc.filters.sepfilter" +@param src Source image. +@param ddepth desired depth of the destination image (the following combinations of src.depth() and ddepth are supported: + + src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F + src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F + src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F + src.depth() = CV_64F, ddepth = -1/CV_64F + +when ddepth=-1, the output image will have the same depth as the source) +@param kernelX Coefficients for filtering each row. +@param kernelY Coefficients for filtering each column. +@param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor +is at the kernel center. +@param delta Value added to the filtered results before storing them. +@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa boxFilter, gaussianBlur, medianBlur + */ +GAPI_EXPORTS GMat sepFilter(const GMat& src, int ddepth, const Mat& kernelX, const Mat& kernelY, const Point& anchor /*FIXME: = Point(-1,-1)*/, + const Scalar& delta /*FIXME = GScalar(0)*/, int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Convolves an image with the kernel. + +The function applies an arbitrary linear filter to an image. When +the aperture is partially outside the image, the function interpolates outlier pixel values +according to the specified border mode. + +The function does actually compute correlation, not the convolution: + +\f[\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\f] + +That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip +the kernel using flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - +anchor.y - 1)`. + +Supported matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same size and number of channels an input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.filter2D" + +@param src input image. +@param ddepth desired depth of the destination image +@param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point +matrix; if you want to apply different kernels to different channels, split the image into +separate color planes using split and process them individually. +@param anchor anchor of the kernel that indicates the relative position of a filtered point within +the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor +is at the kernel center. +@param delta optional value added to the filtered pixels before storing them in dst. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa sepFilter + */ +GAPI_EXPORTS GMat filter2D(const GMat& src, int ddepth, const Mat& kernel, const Point& anchor = Point(-1,-1), const Scalar& delta = Scalar(0), + int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0)); + + +/** @brief Blurs an image using the box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\f] + +where + +\f[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise} \end{cases}\f] + +Unnormalized box filter is useful for computing various integral characteristics over each pixel +neighborhood, such as covariance matrices of image derivatives (used in dense optical flow +algorithms, and so on). If you need to compute pixel sums over variable-size windows, use cv::integral. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.boxfilter" + +@param src Source image. +@param dtype the output image depth (-1 to set the input image data type). +@param ksize blurring kernel size. +@param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor +is at the kernel center. +@param normalize flag, specifying whether the kernel is normalized by its area or not. +@param borderType Pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa sepFilter, gaussianBlur, medianBlur, integral + */ +GAPI_EXPORTS GMat boxFilter(const GMat& src, int dtype, const Size& ksize, const Point& anchor = Point(-1,-1), + bool normalize = true, int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Blurs an image using the normalized box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\f] + +The call `blur(src, ksize, anchor, borderType)` is equivalent to `boxFilter(src, src.type(), ksize, anchor, +true, borderType)`. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.blur" + +@param src Source image. +@param ksize blurring kernel size. +@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel +center. +@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa boxFilter, bilateralFilter, GaussianBlur, medianBlur + */ +GAPI_EXPORTS GMat blur(const GMat& src, const Size& ksize, const Point& anchor = Point(-1,-1), + int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0)); + + +//GAPI_EXPORTS_W void blur( InputArray src, OutputArray dst, + // Size ksize, Point anchor = Point(-1,-1), + // int borderType = BORDER_DEFAULT ); + + +/** @brief Blurs an image using a Gaussian filter. + +The function filter2Ds the source image with the specified Gaussian kernel. +Output image must have the same type and number of channels an input image. + +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.gaussianBlur" + +@param src input image; +@param ksize Gaussian kernel size. ksize.width and ksize.height can differ but they both must be +positive and odd. Or, they can be zero's and then they are computed from sigma. +@param sigmaX Gaussian kernel standard deviation in X direction. +@param sigmaY Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be +equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, +respectively (see cv::getGaussianKernel for details); to fully control the result regardless of +possible future modifications of all this semantics, it is recommended to specify all of ksize, +sigmaX, and sigmaY. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa sepFilter, boxFilter, medianBlur + */ +GAPI_EXPORTS GMat gaussianBlur(const GMat& src, const Size& ksize, double sigmaX, double sigmaY = 0, + int borderType = BORDER_DEFAULT, const Scalar& borderValue = Scalar(0)); + +/** @brief Blurs an image using the median filter. + +The function smoothes an image using the median filter with the \f$\texttt{ksize} \times +\texttt{ksize}\f$ aperture. Each channel of a multi-channel image is processed independently. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. +The median filter uses cv::BORDER_REPLICATE internally to cope with border pixels, see cv::BorderTypes + - Function textual ID is "org.opencv.imgproc.filters.medianBlur" + +@param src input matrix (image) +@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ... +@sa boxFilter, gaussianBlur + */ +GAPI_EXPORTS_W GMat medianBlur(const GMat& src, int ksize); + +/** @brief Erodes an image by using a specific structuring element. + +The function erodes the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the minimum is taken: + +\f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.erode" + +@param src input image +@param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular +structuring element is used. Kernel can be created using getStructuringElement. +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times erosion is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa dilate, morphologyEx + */ +GAPI_EXPORTS GMat erode(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Erodes an image by using 3 by 3 rectangular structuring element. + +The function erodes the source image using the rectangular structuring element with rectangle center as an anchor. +Erosion can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.erode" + +@param src input image +@param iterations number of times erosion is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa erode, dilate3x3 + */ +GAPI_EXPORTS GMat erode3x3(const GMat& src, int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Dilates an image by using a specific structuring element. + +The function dilates the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the maximum is taken: +\f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.dilate" + +@param src input image. +@param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular +structuring element is used. Kernel can be created using getStructuringElement +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times dilation is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa erode, morphologyEx, getStructuringElement + */ +GAPI_EXPORTS GMat dilate(const GMat& src, const Mat& kernel, const Point& anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Dilates an image by using 3 by 3 rectangular structuring element. + +The function dilates the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the maximum is taken: +\f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +Dilation can be applied several (iterations) times. In case of multi-channel images, each channel is processed independently. +Supported input matrix data types are @ref CV_8UC1, @ref CV_8UC3, @ref CV_16UC1, @ref CV_16SC1, and @ref CV_32FC1. +Output image must have the same type, size, and number of channels as the input image. +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.dilate" + +@param src input image. +@param iterations number of times dilation is applied. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of a constant border +@sa dilate, erode3x3 + */ + +GAPI_EXPORTS GMat dilate3x3(const GMat& src, int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue()); + +/** @brief Performs advanced morphological transformations. + +The function can perform advanced morphological transformations using an erosion and dilation as +basic operations. + +Any of the operations can be done in-place. In case of multi-channel images, each channel is +processed independently. + +@note + - Function textual ID is "org.opencv.imgproc.filters.morphologyEx" + - The number of iterations is the number of times erosion or dilatation operation will be +applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to +apply successively: erode -> erode -> dilate -> dilate +(and not erode -> dilate -> erode -> dilate). + +@param src Input image. +@param op Type of a morphological operation, see #MorphTypes +@param kernel Structuring element. It can be created using #getStructuringElement. +@param anchor Anchor position within the element. Both negative values mean that the anchor is at +the kernel center. +@param iterations Number of times erosion and dilation are applied. +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@param borderValue Border value in case of a constant border. The default value has a special +meaning. +@sa dilate, erode, getStructuringElement + */ +GAPI_EXPORTS GMat morphologyEx(const GMat &src, const MorphTypes op, const Mat &kernel, + const Point &anchor = Point(-1,-1), + const int iterations = 1, + const BorderTypes borderType = BORDER_CONSTANT, + const Scalar &borderValue = morphologyDefaultBorderValue()); + +/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. + +In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to +calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$ +kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first +or the second x- or y- derivatives. + +There is also the special value `ksize = FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is + +\f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] + +for the x-derivative, or transposed for the y-derivative. + +The function calculates an image derivative by convolving the image with the appropriate kernel: + +\f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f] + +The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less +resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) +or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first +case corresponds to a kernel of: + +\f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f] + +The second case corresponds to a kernel of: + +\f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f] + +@note + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.sobel" + +@param src input image. +@param ddepth output image depth, see @ref filter_depths "combinations"; in the case of + 8-bit input images it will result in truncated derivatives. +@param dx order of the derivative x. +@param dy order of the derivative y. +@param ksize size of the extended Sobel kernel; it must be odd. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see cv::getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa filter2D, gaussianBlur, cartToPolar + */ +GAPI_EXPORTS GMat Sobel(const GMat& src, int ddepth, int dx, int dy, int ksize = 3, + double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. + +In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to +calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$ +kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first +or the second x- or y- derivatives. + +There is also the special value `ksize = FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is + +\f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] + +for the x-derivative, or transposed for the y-derivative. + +The function calculates an image derivative by convolving the image with the appropriate kernel: + +\f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f] + +The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less +resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) +or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first +case corresponds to a kernel of: + +\f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f] + +The second case corresponds to a kernel of: + +\f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f] + +@note + - First returned matrix correspons to dx derivative while the second one to dy. + - Rounding to nearest even is procedeed if hardware supports it, if not - to nearest. + - Function textual ID is "org.opencv.imgproc.filters.sobelxy" + +@param src input image. +@param ddepth output image depth, see @ref filter_depths "combinations"; in the case of + 8-bit input images it will result in truncated derivatives. +@param order order of the derivatives. +@param ksize size of the extended Sobel kernel; it must be odd. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see cv::getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see cv::BorderTypes +@param borderValue border value in case of constant border type +@sa filter2D, gaussianBlur, cartToPolar + */ +GAPI_EXPORTS std::tuple SobelXY(const GMat& src, int ddepth, int order, int ksize = 3, + double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT, + const Scalar& borderValue = Scalar(0)); + +/** @brief Calculates the Laplacian of an image. + +The function calculates the Laplacian of the source image by adding up the second x and y +derivatives calculated using the Sobel operator: + +\f[\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\f] + +This is done when `ksize > 1`. When `ksize == 1`, the Laplacian is computed by filtering the image +with the following \f$3 \times 3\f$ aperture: + +\f[\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\f] + +@note Function textual ID is "org.opencv.imgproc.filters.laplacian" + +@param src Source image. +@param ddepth Desired depth of the destination image. +@param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for +details. The size must be positive and odd. +@param scale Optional scale factor for the computed Laplacian values. By default, no scaling is +applied. See #getDerivKernels for details. +@param delta Optional delta value that is added to the results prior to storing them in dst . +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@return Destination image of the same size and the same number of channels as src. +@sa Sobel, Scharr + */ +GAPI_EXPORTS GMat Laplacian(const GMat& src, int ddepth, int ksize = 1, + double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT); + +/** @brief Applies the bilateral filter to an image. + +The function applies bilateral filtering to the input image, as described in +http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html +bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is +very slow compared to most filters. + +_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\< +10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very +strong effect, making the image look "cartoonish". + +_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time +applications, and perhaps d=9 for offline applications that need heavy noise filtering. + +This filter does not work inplace. + +@note Function textual ID is "org.opencv.imgproc.filters.bilateralfilter" + +@param src Source 8-bit or floating-point, 1-channel or 3-channel image. +@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, +it is computed from sigmaSpace. +@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that +farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting +in larger areas of semi-equal color. +@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that +farther pixels will influence each other as long as their colors are close enough (see sigmaColor +). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is +proportional to sigmaSpace. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes +@return Destination image of the same size and type as src. + */ +GAPI_EXPORTS GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace, + int borderType = BORDER_DEFAULT); + +//! @} gapi_filters + +//! @addtogroup gapi_feature +//! @{ +/** @brief Finds edges in an image using the Canny algorithm. + +The function finds edges in the input image and marks them in the output map edges using the +Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The +largest value is used to find initial segments of strong edges. See + + +@note Function textual ID is "org.opencv.imgproc.feature.canny" + +@param image 8-bit input image. +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param apertureSize aperture size for the Sobel operator. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). + */ +GAPI_EXPORTS GMat Canny(const GMat& image, double threshold1, double threshold2, + int apertureSize = 3, bool L2gradient = false); + +/** @brief Determines strong corners on an image. + +The function finds the most prominent corners in the image or in the specified image region, as +described in @cite Shi94 + +- Function calculates the corner quality measure at every source image pixel using the + #cornerMinEigenVal or #cornerHarris . +- Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are + retained). +- The corners with the minimal eigenvalue less than + \f$\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\f$ are rejected. +- The remaining corners are sorted by the quality measure in the descending order. +- Function throws away each corner for which there is a stronger corner at a distance less than + maxDistance. + +The function can be used to initialize a point-based tracker of an object. + +@note + - If the function is called with different values A and B of the parameter qualityLevel , and +A \> B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector +with qualityLevel=B . + - Function textual ID is "org.opencv.imgproc.feature.goodFeaturesToTrack" + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Optional region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + +@return vector of detected corners. + */ +GAPI_EXPORTS_W GArray goodFeaturesToTrack(const GMat &image, + int maxCorners, + double qualityLevel, + double minDistance, + const Mat &mask = Mat(), + int blockSize = 3, + bool useHarrisDetector = false, + double k = 0.04); + +/** @brief Equalizes the histogram of a grayscale image. + +//! @} gapi_feature + +The function equalizes the histogram of the input image using the following algorithm: + +- Calculate the histogram \f$H\f$ for src . +- Normalize the histogram so that the sum of histogram bins is 255. +- Compute the integral of the histogram: +\f[H'_i = \sum _{0 \le j < i} H(j)\f] +- Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$ + +The algorithm normalizes the brightness and increases the contrast of the image. +@note + - The returned image is of the same size and type as input. + - Function textual ID is "org.opencv.imgproc.equalizeHist" + +@param src Source 8-bit single channel image. + */ +GAPI_EXPORTS GMat equalizeHist(const GMat& src); + +//! @addtogroup gapi_shape +//! @{ +/** @brief Finds contours in a binary image. + +The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . +The contours are a useful tool for shape analysis and object detection and recognition. +See squares.cpp in the OpenCV sample directory. + +@note Function textual ID is "org.opencv.imgproc.shape.findContours" + +@param src Input gray-scale image @ref CV_8UC1. Non-zero pixels are treated as 1's. Zero +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP, the input can also be a 32-bit integer +image of labels ( @ref CV_32SC1 ). If #RETR_FLOODFILL then @ref CV_32SC1 is supported only. +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes +@param offset Optional offset by which every contour point is shifted. This is useful if the +contours are extracted from the image ROI and then they should be analyzed in the whole image +context. + +@return GArray of detected contours. Each contour is stored as a GArray of points. + */ +GAPI_EXPORTS GArray> +findContours(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, + const GOpaque &offset); + +// FIXME oc: make default value offset = Point() +/** @overload +@note Function textual ID is "org.opencv.imgproc.shape.findContoursNoOffset" + */ +GAPI_EXPORTS GArray> +findContours(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method); + +/** @brief Finds contours and their hierarchy in a binary image. + +The function retrieves contours from the binary image using the algorithm @cite Suzuki85 +and calculates their hierarchy. +The contours are a useful tool for shape analysis and object detection and recognition. +See squares.cpp in the OpenCV sample directory. + +@note Function textual ID is "org.opencv.imgproc.shape.findContoursH" + +@param src Input gray-scale image @ref CV_8UC1. Non-zero pixels are treated as 1's. Zero +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP, the input can also be a 32-bit integer +image of labels ( @ref CV_32SC1 ). If #RETR_FLOODFILL -- @ref CV_32SC1 supports only. +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes +@param offset Optional offset by which every contour point is shifted. This is useful if the +contours are extracted from the image ROI and then they should be analyzed in the whole image +context. + +@return + - GArray of detected contours. Each contour is stored as a GArray of points. + - Optional output GArray of cv::Vec4i, containing information about the image topology. +It has as many elements as the number of contours. For each i-th contour contours[i], the elements +hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based +indices in contours of the next and previous contours at the same hierarchical level, the first +child contour and the parent contour, respectively. If for the contour i there are no next, +previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative. + */ +GAPI_EXPORTS std::tuple>,GArray> +findContoursH(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method, + const GOpaque &offset); + +// FIXME oc: make default value offset = Point() +/** @overload +@note Function textual ID is "org.opencv.imgproc.shape.findContoursHNoOffset" + */ +GAPI_EXPORTS std::tuple>,GArray> +findContoursH(const GMat &src, const RetrievalModes mode, const ContourApproximationModes method); + +/** @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels +of gray-scale image. + +The function calculates and returns the minimal up-right bounding rectangle for the specified +point set or non-zero pixels of gray-scale image. + +@note + - Function textual ID is "org.opencv.imgproc.shape.boundingRectMat" + - In case of a 2D points' set given, Mat should be 2-dimensional, have a single row or column +if there are 2 channels, or have 2 columns if there is a single channel. Mat should have either +@ref CV_32S or @ref CV_32F depth + +@param src Input gray-scale image @ref CV_8UC1; or input set of @ref CV_32S or @ref CV_32F +2D points stored in Mat. + */ +GAPI_EXPORTS_W GOpaque boundingRect(const GMat& src); + +/** @overload + +Calculates the up-right bounding rectangle of a point set. + +@note Function textual ID is "org.opencv.imgproc.shape.boundingRectVector32S" + +@param src Input 2D point set, stored in std::vector. + */ +GAPI_EXPORTS_W GOpaque boundingRect(const GArray& src); + +/** @overload + +Calculates the up-right bounding rectangle of a point set. + +@note Function textual ID is "org.opencv.imgproc.shape.boundingRectVector32F" + +@param src Input 2D point set, stored in std::vector. + */ +GAPI_EXPORTS GOpaque boundingRect(const GArray& src); + +/** @brief Fits a line to a 2D point set. + +The function fits a line to a 2D point set by minimizing \f$\sum_i \rho(r_i)\f$ where +\f$r_i\f$ is a distance between the \f$i^{th}\f$ point, the line and \f$\rho(r)\f$ is a distance +function, one of the following: +- DIST_L2 +\f[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\f] +- DIST_L1 +\f[\rho (r) = r\f] +- DIST_L12 +\f[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\f] +- DIST_FAIR +\f[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{where} \quad C=1.3998\f] +- DIST_WELSCH +\f[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{where} \quad C=2.9846\f] +- DIST_HUBER +\f[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\f] + +The algorithm is based on the M-estimator ( ) technique +that iteratively fits the line using the weighted least-squares algorithm. After each iteration the +weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . + +@note + - Function textual ID is "org.opencv.imgproc.shape.fitLine2DMat" + - In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row +or column if there are N channels, or have N columns if there is a single channel. + +@param src Input set of 2D points stored in one of possible containers: Mat, +std::vector, std::vector, std::vector. +@param distType Distance used by the M-estimator, see #DistanceTypes. @ref DIST_USER +and @ref DIST_C are not suppored. +@param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value +is chosen. +@param reps Sufficient accuracy for the radius (distance between the coordinate origin and the +line). 1.0 would be a good default value for reps. If it is 0, a default value is chosen. +@param aeps Sufficient accuracy for the angle. 0.01 would be a good default value for aeps. +If it is 0, a default value is chosen. + +@return Output line parameters: a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), +where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line. + */ +GAPI_EXPORTS GOpaque fitLine2D(const GMat& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector32S" + + */ +GAPI_EXPORTS GOpaque fitLine2D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector32F" + + */ +GAPI_EXPORTS GOpaque fitLine2D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine2DVector64F" + + */ +GAPI_EXPORTS GOpaque fitLine2D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @brief Fits a line to a 3D point set. + +The function fits a line to a 3D point set by minimizing \f$\sum_i \rho(r_i)\f$ where +\f$r_i\f$ is a distance between the \f$i^{th}\f$ point, the line and \f$\rho(r)\f$ is a distance +function, one of the following: +- DIST_L2 +\f[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\f] +- DIST_L1 +\f[\rho (r) = r\f] +- DIST_L12 +\f[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\f] +- DIST_FAIR +\f[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{where} \quad C=1.3998\f] +- DIST_WELSCH +\f[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{where} \quad C=2.9846\f] +- DIST_HUBER +\f[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\f] + +The algorithm is based on the M-estimator ( ) technique +that iteratively fits the line using the weighted least-squares algorithm. After each iteration the +weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . + +@note + - Function textual ID is "org.opencv.imgproc.shape.fitLine3DMat" + - In case of an N-dimentional points' set given, Mat should be 2-dimensional, have a single row +or column if there are N channels, or have N columns if there is a single channel. + +@param src Input set of 3D points stored in one of possible containers: Mat, +std::vector, std::vector, std::vector. +@param distType Distance used by the M-estimator, see #DistanceTypes. @ref DIST_USER +and @ref DIST_C are not suppored. +@param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value +is chosen. +@param reps Sufficient accuracy for the radius (distance between the coordinate origin and the +line). 1.0 would be a good default value for reps. If it is 0, a default value is chosen. +@param aeps Sufficient accuracy for the angle. 0.01 would be a good default value for aeps. +If it is 0, a default value is chosen. + +@return Output line parameters: a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), +where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on +the line. + */ +GAPI_EXPORTS GOpaque fitLine3D(const GMat& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector32S" + + */ +GAPI_EXPORTS GOpaque fitLine3D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector32F" + + */ +GAPI_EXPORTS GOpaque fitLine3D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +/** @overload + +@note Function textual ID is "org.opencv.imgproc.shape.fitLine3DVector64F" + + */ +GAPI_EXPORTS GOpaque fitLine3D(const GArray& src, const DistanceTypes distType, + const double param = 0., const double reps = 0., + const double aeps = 0.); + +//! @} gapi_shape + +//! @addtogroup gapi_colorconvert +//! @{ +/** @brief Converts an image from BGR color space to RGB color space. + +The function converts an input image from BGR color space to RGB. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image is 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2rgb" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa RGB2BGR +*/ +GAPI_EXPORTS_W GMat BGR2RGB(const GMat& src); + +/** @brief Converts an image from RGB color space to gray-scaled. + +The conventional ranges for R, G, and B channel values are 0 to 255. +Resulting gray color value computed as +\f[\texttt{dst} (I)= \texttt{0.299} * \texttt{src}(I).R + \texttt{0.587} * \texttt{src}(I).G + \texttt{0.114} * \texttt{src}(I).B \f] + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2gray" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@sa RGB2YUV + */ +GAPI_EXPORTS_W GMat RGB2Gray(const GMat& src); + +/** @overload +Resulting gray color value computed as +\f[\texttt{dst} (I)= \texttt{rY} * \texttt{src}(I).R + \texttt{gY} * \texttt{src}(I).G + \texttt{bY} * \texttt{src}(I).B \f] + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2graycustom" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@param rY float multiplier for R channel. +@param gY float multiplier for G channel. +@param bY float multiplier for B channel. +@sa RGB2YUV + */ +GAPI_EXPORTS GMat RGB2Gray(const GMat& src, float rY, float gY, float bY); + +/** @brief Converts an image from BGR color space to gray-scaled. + +The conventional ranges for B, G, and R channel values are 0 to 255. +Resulting gray color value computed as +\f[\texttt{dst} (I)= \texttt{0.114} * \texttt{src}(I).B + \texttt{0.587} * \texttt{src}(I).G + \texttt{0.299} * \texttt{src}(I).R \f] + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2gray" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@sa BGR2LUV + */ +GAPI_EXPORTS GMat BGR2Gray(const GMat& src); + +/** @brief Converts an image from RGB color space to YUV color space. + +The function converts an input image from RGB color space to YUV. +The conventional ranges for R, G, and B channel values are 0 to 255. + +In case of linear transformations, the range does not matter. But in case of a non-linear +transformation, an input RGB image should be normalized to the proper value range to get the correct +results, like here, at RGB \f$\rightarrow\f$ Y\*u\*v\* transformation. +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2yuv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa YUV2RGB, RGB2Lab +*/ +GAPI_EXPORTS GMat RGB2YUV(const GMat& src); + +/** @brief Converts an image from BGR color space to I420 color space. + +The function converts an input image from BGR color space to I420. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 1-channel image. @ref CV_8UC1. +Width of I420 output image must be the same as width of input image. +Height of I420 output image must be equal 3/2 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2i420" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa I4202BGR +*/ +GAPI_EXPORTS GMat BGR2I420(const GMat& src); + +/** @brief Converts an image from RGB color space to I420 color space. + +The function converts an input image from RGB color space to I420. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 1-channel image. @ref CV_8UC1. +Width of I420 output image must be the same as width of input image. +Height of I420 output image must be equal 3/2 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2i420" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa I4202RGB +*/ +GAPI_EXPORTS GMat RGB2I420(const GMat& src); + +/** @brief Converts an image from I420 color space to BGR color space. + +The function converts an input image from I420 color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image. @ref CV_8UC3. +Width of BGR output image must be the same as width of input image. +Height of BGR output image must be equal 2/3 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.i4202bgr" + +@param src input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@sa BGR2I420 +*/ +GAPI_EXPORTS GMat I4202BGR(const GMat& src); + +/** @brief Converts an image from I420 color space to BGR color space. + +The function converts an input image from I420 color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image. @ref CV_8UC3. +Width of RGB output image must be the same as width of input image. +Height of RGB output image must be equal 2/3 from height of input image. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.i4202rgb" + +@param src input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@sa RGB2I420 +*/ +GAPI_EXPORTS GMat I4202RGB(const GMat& src); + +/** @brief Converts an image from BGR color space to LUV color space. + +The function converts an input image from BGR color space to LUV. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2luv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa RGB2Lab, RGB2LUV +*/ +GAPI_EXPORTS GMat BGR2LUV(const GMat& src); + +/** @brief Converts an image from LUV color space to BGR color space. + +The function converts an input image from LUV color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.luv2bgr" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa BGR2LUV +*/ +GAPI_EXPORTS GMat LUV2BGR(const GMat& src); + +/** @brief Converts an image from YUV color space to BGR color space. + +The function converts an input image from YUV color space to BGR. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2bgr" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa BGR2YUV +*/ +GAPI_EXPORTS GMat YUV2BGR(const GMat& src); + +/** @brief Converts an image from BGR color space to YUV color space. + +The function converts an input image from BGR color space to YUV. +The conventional ranges for B, G, and R channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bgr2yuv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@sa YUV2BGR +*/ +GAPI_EXPORTS GMat BGR2YUV(const GMat& src); + +/** @brief Converts an image from RGB color space to Lab color space. + +The function converts an input image from BGR color space to Lab. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2lab" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC1. +@sa RGB2YUV, RGB2LUV +*/ +GAPI_EXPORTS GMat RGB2Lab(const GMat& src); + +/** @brief Converts an image from YUV color space to RGB. +The function converts an input image from YUV color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.yuv2rgb" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. + +@sa RGB2Lab, RGB2YUV +*/ +GAPI_EXPORTS GMat YUV2RGB(const GMat& src); + +/** @brief Converts an image from NV12 (YUV420p) color space to RGB. +The function converts an input image from NV12 color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12torgb" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toBGR +*/ +GAPI_EXPORTS GMat NV12toRGB(const GMat& src_y, const GMat& src_uv); + +/** @brief Converts an image from NV12 (YUV420p) color space to gray-scaled. +The function converts an input image from NV12 color space to gray-scaled. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 1-channel image @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12togray" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toBGR +*/ +GAPI_EXPORTS GMat NV12toGray(const GMat& src_y, const GMat& src_uv); + +/** @brief Converts an image from NV12 (YUV420p) color space to BGR. +The function converts an input image from NV12 color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12tobgr" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat NV12toBGR(const GMat& src_y, const GMat& src_uv); + +/** @brief Converts an image from BayerGR color space to RGB. +The function converts an input image from BayerGR color space to RGB. +The conventional ranges for G, R, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.bayergr2rgb" + +@param src_gr input image: 8-bit unsigned 1-channel image @ref CV_8UC1. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat BayerGR2RGB(const GMat& src_gr); + +/** @brief Converts an image from RGB color space to HSV. +The function converts an input image from RGB color space to HSV. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 3-channel image @ref CV_8UC3. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2hsv" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat RGB2HSV(const GMat& src); + +/** @brief Converts an image from RGB color space to YUV422. +The function converts an input image from RGB color space to YUV422. +The conventional ranges for R, G, and B channel values are 0 to 255. + +Output image must be 8-bit unsigned 2-channel image @ref CV_8UC2. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.rgb2yuv422" + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3. + +@sa YUV2BGR, NV12toRGB +*/ +GAPI_EXPORTS GMat RGB2YUV422(const GMat& src); + +/** @brief Converts an image from NV12 (YUV420p) color space to RGB. +The function converts an input image from NV12 color space to RGB. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned planar 3-channel image @ref CV_8UC1. +Planar image memory layout is three planes laying in the memory contiguously, +so the image height should be plane_height*plane_number, +image type is @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12torgbp" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toBGRp, NV12toRGB +*/ +GAPI_EXPORTS GMatP NV12toRGBp(const GMat &src_y, const GMat &src_uv); + +/** @brief Converts an image from NV12 (YUV420p) color space to BGR. +The function converts an input image from NV12 color space to BGR. +The conventional ranges for Y, U, and V channel values are 0 to 255. + +Output image must be 8-bit unsigned planar 3-channel image @ref CV_8UC1. +Planar image memory layout is three planes laying in the memory contiguously, +so the image height should be plane_height*plane_number, +image type is @ref CV_8UC1. + +@note Function textual ID is "org.opencv.imgproc.colorconvert.nv12torgbp" + +@param src_y input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param src_uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2. + +@sa YUV2RGB, NV12toRGBp, NV12toBGR +*/ +GAPI_EXPORTS GMatP NV12toBGRp(const GMat &src_y, const GMat &src_uv); + +//! @} gapi_colorconvert +} //namespace gapi +} //namespace cv + +#endif // OPENCV_GAPI_IMGPROC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer.hpp new file mode 100644 index 0000000..807c82d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer.hpp @@ -0,0 +1,714 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_INFER_HPP +#define OPENCV_GAPI_INFER_HPP + +// FIXME: Inference API is currently only available in full mode +#if !defined(GAPI_STANDALONE) + +#include +#include // string +#include // tuple +#include // is_same, false_type + +#include // all_satisfy +#include // any<> +#include // GKernelType[M], GBackend +#include // GArg +#include // CompileArgTag +#include // GMetaArg + +namespace cv { + +template class GNetworkType; + +namespace detail { + +// Infer /////////////////////////////////////////////////////////////////////// +template +struct accepted_infer_types { + static constexpr const auto value = + std::is_same::type, cv::GMat>::value + || std::is_same::type, cv::GFrame>::value; +}; + +template +using valid_infer_types = all_satisfy; + +// Infer2 ////////////////////////////////////////////////////////////////////// + +template +struct valid_infer2_types; + +// Terminal case 1 (50/50 success) +template +struct valid_infer2_types< std::tuple, std::tuple > { + // By default, Nets are limited to GMat argument types only + // for infer2, every GMat argument may translate to either + // GArray or GArray. GArray<> part is stripped + // already at this point. + static constexpr const auto value = + std::is_same::type, cv::GMat>::value + || std::is_same::type, cv::Rect>::value; +}; + +// Terminal case 2 (100% failure) +template +struct valid_infer2_types< std::tuple<>, std::tuple > + : public std::false_type { +}; + +// Terminal case 3 (100% failure) +template +struct valid_infer2_types< std::tuple, std::tuple<> > + : public std::false_type { +}; + +// Recursion -- generic +template +struct valid_infer2_types< std::tuple, std::tuple > { + static constexpr const auto value = + valid_infer2_types< std::tuple, std::tuple >::value + && valid_infer2_types< std::tuple, std::tuple >::value; +}; + +// Struct stores network input/output names. +// Used by infer +struct InOutInfo +{ + std::vector in_names; + std::vector out_names; +}; + +template +class GInferOutputsTyped +{ +public: + GInferOutputsTyped() = default; + GInferOutputsTyped(std::shared_ptr call) + : m_priv(std::make_shared(std::move(call))) + { + } + + OutT at(const std::string& name) + { + auto it = m_priv->blobs.find(name); + if (it == m_priv->blobs.end()) { + // FIXME: Avoid modifying GKernel + auto shape = cv::detail::GTypeTraits::shape; + m_priv->call->kernel().outShapes.push_back(shape); + m_priv->call->kernel().outCtors.emplace_back(cv::detail::GObtainCtor::get()); + auto out_idx = static_cast(m_priv->blobs.size()); + it = m_priv->blobs.emplace(name, + cv::detail::Yield::yield(*(m_priv->call), out_idx)).first; + m_priv->info->out_names.push_back(name); + } + return it->second; + } +private: + struct Priv + { + Priv(std::shared_ptr c) + : call(std::move(c)), info(cv::util::any_cast(&call->params())) + { + } + + std::shared_ptr call; + InOutInfo* info = nullptr; + std::unordered_map blobs; + }; + + std::shared_ptr m_priv; +}; + +template +class GInferInputsTyped +{ +public: + GInferInputsTyped() + : m_priv(std::make_shared()) + { + } + + template + GInferInputsTyped& setInput(const std::string& name, U in) + { + m_priv->blobs.emplace(std::piecewise_construct, + std::forward_as_tuple(name), + std::forward_as_tuple(in)); + return *this; + } + + using StorageT = cv::util::variant; + StorageT& operator[](const std::string& name) { + return m_priv->blobs[name]; + } + + using Map = std::unordered_map; + const Map& getBlobs() const { + return m_priv->blobs; + } + +private: + struct Priv + { + std::unordered_map blobs; + }; + + std::shared_ptr m_priv; +}; + +template +std::shared_ptr makeCall(const std::string &tag, + std::vector &&args, + std::vector &&names, + cv::GKinds &&kinds) { + auto call = std::make_shared(GKernel{ + InferT::id(), + tag, + InferT::getOutMeta, + {}, // outShape will be filled later + std::move(kinds), + {}, // outCtors will be filled later + }); + + call->setArgs(std::move(args)); + call->params() = cv::detail::InOutInfo{std::move(names), {}}; + + return call; +} + +} // namespace detail + +// TODO: maybe tuple_wrap_helper from util.hpp may help with this. +// Multiple-return-value network definition (specialized base class) +template +class GNetworkType(Args...)> > +{ +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + using Result = OutArgs; + using API = std::function; + + using ResultL = std::tuple< cv::GArray... >; +}; + +// Single-return-value network definition (specialized base class) +template +class GNetworkType > +{ +public: + using InArgs = std::tuple; + using OutArgs = std::tuple; + + using Result = R; + using API = std::function; + + using ResultL = cv::GArray; +}; + +// InferAPI: Accepts either GMat or GFrame for very individual network's input +template +struct InferAPI { + using type = typename std::enable_if + < detail::valid_infer_types::value + && std::tuple_size::value == sizeof...(Ts) + , std::function + >::type; +}; + +// InferAPIRoi: Accepts a rectangle and either GMat or GFrame +template +struct InferAPIRoi { + using type = typename std::enable_if + < detail::valid_infer_types::value + && std::tuple_size::value == 1u + , std::function, T)> + >::type; +}; + +// InferAPIList: Accepts a list of rectangles and list of GMat/GFrames; +// crops every input. +template +struct InferAPIList { + using type = typename std::enable_if + < detail::valid_infer_types::value + && std::tuple_size::value == sizeof...(Ts) + , std::function, Ts...)> + >::type; +}; + +// APIList2 is also template to allow different calling options +// (GArray vs GArray per input) +template +struct InferAPIList2 { + using type = typename std::enable_if + < detail::valid_infer_types::value && + cv::detail::valid_infer2_types< typename Net::InArgs + , std::tuple >::value, + std::function...)> + >::type; +}; + +// Base "Infer" kernel. Note - for whatever network, kernel ID +// is always the same. Different inference calls are distinguished by +// network _tag_ (an extra field in GCall) +// +// getOutMeta is a stub callback collected by G-API kernel subsystem +// automatically. This is a rare case when this callback is defined by +// a particular backend, not by a network itself. +struct GInferBase { + static constexpr const char * id() { + return "org.opencv.dnn.infer"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// Base "InferROI" kernel. +// All notes from "Infer" kernel apply here as well. +struct GInferROIBase { + static constexpr const char * id() { + return "org.opencv.dnn.infer-roi"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// Base "Infer list" kernel. +// All notes from "Infer" kernel apply here as well. +struct GInferListBase { + static constexpr const char * id() { + return "org.opencv.dnn.infer-roi-list-1"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// Base "Infer list 2" kernel. +// All notes from "Infer" kernel apply here as well. +struct GInferList2Base { + static constexpr const char * id() { + return "org.opencv.dnn.infer-roi-list-2"; // Universal stub + } + static GMetaArgs getOutMeta(const GMetaArgs &, const GArgs &) { + return GMetaArgs{}; // One more universal stub + } +}; + +// A generic inference kernel. API (::on()) is fully defined by the Net +// template parameter. +// Acts as a regular kernel in graph (via KernelTypeMedium). +template +struct GInfer final + : public GInferBase + , public detail::KernelTypeMedium< GInfer + , typename InferAPI::type > { + using GInferBase::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + +// A specific roi-inference kernel. API (::on()) is fixed here and +// verified against Net. +template +struct GInferROI final + : public GInferROIBase + , public detail::KernelTypeMedium< GInferROI + , typename InferAPIRoi::type > { + using GInferROIBase::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + + +// A generic roi-list inference kernel. API (::on()) is derived from +// the Net template parameter (see more in infer<> overload). +template +struct GInferList final + : public GInferListBase + , public detail::KernelTypeMedium< GInferList + , typename InferAPIList::type > { + using GInferListBase::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + +// An even more generic roi-list inference kernel. API (::on()) is +// derived from the Net template parameter (see more in infer<> +// overload). +// Takes an extra variadic template list to reflect how this network +// was called (with Rects or GMats as array parameters) +template +struct GInferList2 final + : public GInferList2Base + , public detail::KernelTypeMedium< GInferList2 + , typename InferAPIList2::type > { + using GInferList2Base::getOutMeta; // FIXME: name lookup conflict workaround? + + static constexpr const char* tag() { return Net::tag(); } +}; + +/** + * @brief G-API object used to collect network inputs + */ +using GInferInputs = cv::detail::GInferInputsTyped; + +/** + * @brief G-API object used to collect the list of network inputs + */ +using GInferListInputs = cv::detail::GInferInputsTyped, cv::GArray>; + +/** + * @brief G-API object used to collect network outputs + */ +using GInferOutputs = cv::detail::GInferOutputsTyped; + +/** + * @brief G-API object used to collect the list of network outputs + */ +using GInferListOutputs = cv::detail::GInferOutputsTyped>; + +namespace detail { +void inline unpackBlobs(const cv::GInferInputs::Map& blobs, + std::vector& args, + std::vector& names, + cv::GKinds& kinds) +{ + for (auto&& p : blobs) { + names.emplace_back(p.first); + switch (p.second.index()) { + case cv::GInferInputs::StorageT::index_of(): + args.emplace_back(cv::util::get(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_MAT); + break; + case cv::GInferInputs::StorageT::index_of(): + args.emplace_back(cv::util::get(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_UNKNOWN); + break; + default: + GAPI_Assert(false); + } + } +} + +template +struct InferROITraits; + +template <> +struct InferROITraits +{ + using outType = cv::GInferOutputs; + using inType = cv::GOpaque; +}; + +template <> +struct InferROITraits +{ + using outType = cv::GInferListOutputs; + using inType = cv::GArray; +}; + +template +typename InferROITraits::outType +inferGenericROI(const std::string& tag, + const typename InferROITraits::inType& in, + const cv::GInferInputs& inputs) +{ + std::vector args; + std::vector names; + cv::GKinds kinds; + + args.emplace_back(in); + kinds.emplace_back(cv::detail::OpaqueKind::CV_RECT); + + unpackBlobs(inputs.getBlobs(), args, names, kinds); + + auto call = cv::detail::makeCall(tag, + std::move(args), + std::move(names), + std::move(kinds)); + + return {std::move(call)}; +} + +} // namespace detail +} // namespace cv + +// FIXME: Probably the signature makes a function/tuple/function round-trip +#define G_API_NET(Class, API, Tag) \ + struct Class final: public cv::GNetworkType { \ + static constexpr const char * tag() { return Tag; } \ + } + +namespace cv { +namespace gapi { + +/** @brief Calculates response for the specified network (template + * parameter) for the specified region in the source image. + * Currently expects a single-input network only. + * + * @tparam A network type defined with G_API_NET() macro. + * @param in input image where to take ROI from. + * @param roi an object describing the region of interest + * in the source image. May be calculated in the same graph dynamically. + * @return an object of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * objects of appropriate type is returned. + * @sa G_API_NET() + */ +template +typename Net::Result infer(cv::GOpaque roi, T in) { + return GInferROI::on(roi, in); +} + +/** @brief Calculates responses for the specified network (template + * parameter) for every region in the source image. + * + * @tparam A network type defined with G_API_NET() macro. + * @param roi a list of rectangles describing regions of interest + * in the source image. Usually an output of object detector or tracker. + * @param args network's input parameters as specified in G_API_NET() macro. + * NOTE: verified to work reliably with 1-input topologies only. + * @return a list of objects of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * GArray<> objects is returned with the appropriate types inside. + * @sa G_API_NET() + */ +template +typename Net::ResultL infer(cv::GArray roi, Args&&... args) { + return GInferList::on(roi, std::forward(args)...); +} + +/** @brief Calculates responses for the specified network (template + * parameter) for every region in the source image, extended version. + * + * @tparam A network type defined with G_API_NET() macro. + * @param image A source image containing regions of interest + * @param args GArray<> objects of cv::Rect or cv::GMat, one per every + * network input: + * - If a cv::GArray is passed, the appropriate + * regions are taken from `image` and preprocessed to this particular + * network input; + * - If a cv::GArray is passed, the underlying data traited + * as tensor (no automatic preprocessing happen). + * @return a list of objects of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * GArray<> objects is returned with the appropriate types inside. + * @sa G_API_NET() + */ + +template +typename Net::ResultL infer2(T image, cv::GArray... args) { + // FIXME: Declared as "2" because in the current form it steals + // overloads from the regular infer + return GInferList2::on(image, args...); +} + +/** + * @brief Calculates response for the specified network (template + * parameter) given the input data. + * + * @tparam A network type defined with G_API_NET() macro. + * @param args network's input parameters as specified in G_API_NET() macro. + * @return an object of return type as defined in G_API_NET(). + * If a network has multiple return values (defined with a tuple), a tuple of + * objects of appropriate type is returned. + * @sa G_API_NET() + */ +template +typename Net::Result infer(Args&&... args) { + return GInfer::on(std::forward(args)...); +} + +/** + * @brief Generic network type: input and output layers are configured dynamically at runtime + * + * Unlike the network types defined with G_API_NET macro, this one + * doesn't fix number of network inputs and outputs at the compilation stage + * thus providing user with an opportunity to program them in runtime. + */ +struct Generic { }; + +/** + * @brief Calculates response for generic network + * + * @param tag a network tag + * @param inputs networks's inputs + * @return a GInferOutputs + */ +template cv::GInferOutputs +infer(const std::string& tag, const cv::GInferInputs& inputs) +{ + std::vector args; + std::vector names; + cv::GKinds kinds; + + cv::detail::unpackBlobs(inputs.getBlobs(), args, names, kinds); + + auto call = cv::detail::makeCall(tag, + std::move(args), + std::move(names), + std::move(kinds)); + + return cv::GInferOutputs{std::move(call)}; +} + +/** @brief Calculates response for the generic network + * for the specified region in the source image. + * Currently expects a single-input network only. + * + * @param tag a network tag + * @param roi a an object describing the region of interest + * in the source image. May be calculated in the same graph dynamically. + * @param inputs networks's inputs + * @return a cv::GInferOutputs + */ +template cv::GInferOutputs +infer(const std::string& tag, const cv::GOpaque& roi, const cv::GInferInputs& inputs) +{ + return cv::detail::inferGenericROI(tag, roi, inputs); +} + +/** @brief Calculates responses for the specified network + * for every region in the source image. + * + * @param tag a network tag + * @param rois a list of rectangles describing regions of interest + * in the source image. Usually an output of object detector or tracker. + * @param inputs networks's inputs + * @return a cv::GInferListOutputs + */ +template cv::GInferListOutputs +infer(const std::string& tag, const cv::GArray& rois, const cv::GInferInputs& inputs) +{ + return cv::detail::inferGenericROI(tag, rois, inputs); +} + +/** @brief Calculates responses for the specified network + * for every region in the source image, extended version. + * + * @param tag a network tag + * @param in a source image containing regions of interest. + * @param inputs networks's inputs + * @return a cv::GInferListOutputs + */ +template +typename std::enable_if::value, cv::GInferListOutputs>::type +infer2(const std::string& tag, + const Input& in, + const cv::GInferListInputs& inputs) +{ + std::vector args; + std::vector names; + cv::GKinds kinds; + + args.emplace_back(in); + auto k = cv::detail::GOpaqueTraits::kind; + kinds.emplace_back(k); + + for (auto&& p : inputs.getBlobs()) { + names.emplace_back(p.first); + switch (p.second.index()) { + case cv::GInferListInputs::StorageT::index_of>(): + args.emplace_back(cv::util::get>(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_MAT); + break; + case cv::GInferListInputs::StorageT::index_of>(): + args.emplace_back(cv::util::get>(p.second)); + kinds.emplace_back(cv::detail::OpaqueKind::CV_RECT); + break; + default: + GAPI_Assert(false); + } + } + + auto call = cv::detail::makeCall(tag, + std::move(args), + std::move(names), + std::move(kinds)); + + return cv::GInferListOutputs{std::move(call)}; +} + +} // namespace gapi +} // namespace cv + +#endif // GAPI_STANDALONE + +namespace cv { +namespace gapi { + +// Note: the below code _is_ part of STANDALONE build, +// just to make our compiler code compileable. + +// A type-erased form of network parameters. +// Similar to how a type-erased GKernel is represented and used. +/// @private +struct GAPI_EXPORTS_W_SIMPLE GNetParam { + std::string tag; // FIXME: const? + GBackend backend; // Specifies the execution model + util::any params; // Backend-interpreted parameter structure +}; + +/** \addtogroup gapi_compile_args + * @{ + */ +/** + * @brief A container class for network configurations. Similar to + * GKernelPackage. Use cv::gapi::networks() to construct this object. + * + * @sa cv::gapi::networks + */ +struct GAPI_EXPORTS_W_SIMPLE GNetPackage { + GAPI_WRAP GNetPackage() = default; + GAPI_WRAP explicit GNetPackage(std::vector nets); + explicit GNetPackage(std::initializer_list ii); + std::vector backends() const; + std::vector networks; +}; +/** @} gapi_compile_args */ +} // namespace gapi + +namespace detail { +template +gapi::GNetParam strip(T&& t) { + return gapi::GNetParam { t.tag() + , t.backend() + , t.params() + }; +} + +template<> struct CompileArgTag { + static const char* tag() { return "gapi.net_package"; } +}; + +} // namespace cv::detail + +namespace gapi { +template +cv::gapi::GNetPackage networks(Args&&... args) { + return cv::gapi::GNetPackage({ cv::detail::strip(args)... }); +} + +inline cv::gapi::GNetPackage& operator += ( cv::gapi::GNetPackage& lhs, + const cv::gapi::GNetPackage& rhs) { + lhs.networks.reserve(lhs.networks.size() + rhs.networks.size()); + lhs.networks.insert(lhs.networks.end(), rhs.networks.begin(), rhs.networks.end()); + return lhs; +} + +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/bindings_ie.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/bindings_ie.hpp new file mode 100644 index 0000000..94272de --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/bindings_ie.hpp @@ -0,0 +1,70 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_INFER_BINDINGS_IE_HPP +#define OPENCV_GAPI_INFER_BINDINGS_IE_HPP + +#include +#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS +#include // GKernelPackage +#include // Params + +#include + +namespace cv { +namespace gapi { +namespace ie { + +// NB: Used by python wrapper +// This class can be marked as SIMPLE, because it's implemented as pimpl +class GAPI_EXPORTS_W_SIMPLE PyParams { +public: + GAPI_WRAP + PyParams() = default; + + GAPI_WRAP + PyParams(const std::string &tag, + const std::string &model, + const std::string &weights, + const std::string &device); + + GAPI_WRAP + PyParams(const std::string &tag, + const std::string &model, + const std::string &device); + + GAPI_WRAP + PyParams& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR); + + GAPI_WRAP + PyParams& cfgNumRequests(size_t nireq); + + GAPI_WRAP + PyParams& cfgBatchSize(const size_t size); + + GBackend backend() const; + std::string tag() const; + cv::util::any params() const; + +private: + std::shared_ptr> m_priv; +}; + +GAPI_EXPORTS_W PyParams params(const std::string &tag, + const std::string &model, + const std::string &weights, + const std::string &device); + +GAPI_EXPORTS_W PyParams params(const std::string &tag, + const std::string &model, + const std::string &device); +} // namespace ie +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_BINDINGS_IE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/ie.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/ie.hpp new file mode 100644 index 0000000..e6b7be5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/ie.hpp @@ -0,0 +1,479 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019-2021 Intel Corporation + +#ifndef OPENCV_GAPI_INFER_IE_HPP +#define OPENCV_GAPI_INFER_IE_HPP + +#include +#include +#include +#include +#include // tuple, tuple_size +#include + +#include +#include + +#include // GAPI_EXPORTS +#include // GKernelPackage +#include // Generic + +namespace cv { +namespace gapi { +// FIXME: introduce a new sub-namespace for NN? + +/** + * @brief This namespace contains G-API OpenVINO backend functions, + * structures, and symbols. + */ +namespace ie { + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +/** + * Specifies how G-API and IE should trait input data + * + * In OpenCV, the same cv::Mat is used to represent both + * image and tensor data. Sometimes those are hardly distinguishable, + * so this extra parameter is used to give G-API a hint. + * + * This hint controls how G-API reinterprets the data when converting + * it to IE Blob format (and which layout/etc is assigned to this data). + */ +enum class TraitAs: int +{ + TENSOR, //!< G-API traits an associated cv::Mat as a raw tensor and passes dimensions as-is + IMAGE //!< G-API traits an associated cv::Mat as an image so creates an "image" blob (NCHW/NHWC, etc) +}; + +using IEConfig = std::map; + +namespace detail { +struct ParamDesc { + std::string model_path; + std::string weights_path; + std::string device_id; + + std::vector input_names; + std::vector output_names; + + using ConstInput = std::pair; + std::unordered_map const_inputs; + + std::size_t num_in; + std::size_t num_out; + + enum class Kind {Load, Import}; + Kind kind; + bool is_generic; + IEConfig config; + + std::map> reshape_table; + std::unordered_set layer_names_to_reshape; + + // NB: Number of asyncrhonious infer requests + size_t nireq; + + // NB: An optional config to setup RemoteContext for IE + cv::util::any context_config; + + // NB: batch_size can't be equal to 1 by default, because some of models + // have 2D (Layout::NC) input and if the first dimension not equal to 1 + // net.setBatchSize(1) will overwrite it. + cv::optional batch_size; +}; +} // namespace detail + +// FIXME: this is probably a shared (reusable) thing +template +struct PortCfg { + using In = std::array + < std::string + , std::tuple_size::value >; + using Out = std::array + < std::string + , std::tuple_size::value >; +}; + +/** + * @brief This structure provides functions + * that fill inference parameters for "OpenVINO Toolkit" model. + */ +template class Params { +public: + /** @brief Class constructor. + + Constructs Params based on model information and specifies default values for other + inference description parameters. Model is loaded and compiled using "OpenVINO Toolkit". + + @param model Path to topology IR (.xml file). + @param weights Path to weights (.bin file). + @param device target device to use. + */ + Params(const std::string &model, + const std::string &weights, + const std::string &device) + : desc{ model, weights, device, {}, {}, {} + , std::tuple_size::value // num_in + , std::tuple_size::value // num_out + , detail::ParamDesc::Kind::Load + , false + , {} + , {} + , {} + , 1u + , {} + , {}} { + }; + + /** @overload + Use this constructor to work with pre-compiled network. + Model is imported from a pre-compiled blob. + + @param model Path to model. + @param device target device to use. + */ + Params(const std::string &model, + const std::string &device) + : desc{ model, {}, device, {}, {}, {} + , std::tuple_size::value // num_in + , std::tuple_size::value // num_out + , detail::ParamDesc::Kind::Import + , false + , {} + , {} + , {} + , 1u + , {} + , {}} { + }; + + /** @brief Specifies sequence of network input layers names for inference. + + The function is used to associate cv::gapi::infer<> inputs with the model inputs. + Number of names has to match the number of network inputs as defined in G_API_NET(). + In case a network has only single input layer, there is no need to specify name manually. + + @param layer_names std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains names of input layers. + @return reference to this parameter structure. + */ + Params& cfgInputLayers(const typename PortCfg::In &layer_names) { + desc.input_names.clear(); + desc.input_names.reserve(layer_names.size()); + std::copy(layer_names.begin(), layer_names.end(), + std::back_inserter(desc.input_names)); + return *this; + } + + /** @brief Specifies sequence of network output layers names for inference. + + The function is used to associate cv::gapi::infer<> outputs with the model outputs. + Number of names has to match the number of network outputs as defined in G_API_NET(). + In case a network has only single output layer, there is no need to specify name manually. + + @param layer_names std::array where N is the number of outputs + as defined in the @ref G_API_NET. Contains names of output layers. + @return reference to this parameter structure. + */ + Params& cfgOutputLayers(const typename PortCfg::Out &layer_names) { + desc.output_names.clear(); + desc.output_names.reserve(layer_names.size()); + std::copy(layer_names.begin(), layer_names.end(), + std::back_inserter(desc.output_names)); + return *this; + } + + /** @brief Specifies a constant input. + + The function is used to set a constant input. This input has to be + a preprocessed tensor if its type is TENSOR. Need to provide name of the + network layer which will receive provided data. + + @param layer_name Name of network layer. + @param data cv::Mat that contains data which will be associated with network layer. + @param hint Input type @sa cv::gapi::ie::TraitAs. + @return reference to this parameter structure. + */ + Params& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR) { + desc.const_inputs[layer_name] = {data, hint}; + return *this; + } + + /** @brief Specifies OpenVINO plugin configuration. + + The function is used to set configuration for OpenVINO plugin. Some parameters + can be different for each plugin. Please follow https://docs.openvinotoolkit.org/latest/index.html + to check information about specific plugin. + + @param cfg Map of pairs: (config parameter name, config parameter value). + @return reference to this parameter structure. + */ + Params& pluginConfig(const IEConfig& cfg) { + desc.config = cfg; + return *this; + } + + /** @overload + Function with a rvalue parameter. + + @param cfg rvalue map of pairs: (config parameter name, config parameter value). + @return reference to this parameter structure. + */ + Params& pluginConfig(IEConfig&& cfg) { + desc.config = std::move(cfg); + return *this; + } + + /** @brief Specifies configuration for RemoteContext in InferenceEngine. + + When RemoteContext is configured the backend imports the networks using the context. + It also expects cv::MediaFrames to be actually remote, to operate with blobs via the context. + + @param ctx_cfg cv::util::any value which holds InferenceEngine::ParamMap. + @return reference to this parameter structure. + */ + Params& cfgContextParams(const cv::util::any& ctx_cfg) { + desc.context_config = ctx_cfg; + return *this; + } + + /** @overload + Function with an rvalue parameter. + + @param ctx_cfg cv::util::any value which holds InferenceEngine::ParamMap. + @return reference to this parameter structure. + */ + Params& cfgContextParams(cv::util::any&& ctx_cfg) { + desc.context_config = std::move(ctx_cfg); + return *this; + } + + /** @brief Specifies number of asynchronous inference requests. + + @param nireq Number of inference asynchronous requests. + @return reference to this parameter structure. + */ + Params& cfgNumRequests(size_t nireq) { + GAPI_Assert(nireq > 0 && "Number of infer requests must be greater than zero!"); + desc.nireq = nireq; + return *this; + } + + /** @brief Specifies new input shapes for the network inputs. + + The function is used to specify new input shapes for the network inputs. + Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1networkNetwork.html + for additional information. + + @param reshape_table Map of pairs: name of corresponding data and its dimension. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(const std::map>& reshape_table) { + desc.reshape_table = reshape_table; + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::map>&& reshape_table) { + desc.reshape_table = std::move(reshape_table); + return *this; + } + + /** @overload + + @param layer_name Name of layer. + @param layer_dims New dimensions for this layer. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(const std::string& layer_name, const std::vector& layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::string&& layer_name, std::vector&& layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload + + @param layer_names set of names of network layers that will be used for network reshape. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(const std::unordered_set& layer_names) { + desc.layer_names_to_reshape = layer_names; + return *this; + } + + /** @overload + + @param layer_names rvalue set of the selected layers will be reshaped automatically + its input image size. + @return reference to this parameter structure. + */ + Params& cfgInputReshape(std::unordered_set&& layer_names) { + desc.layer_names_to_reshape = std::move(layer_names); + return *this; + } + + /** @brief Specifies the inference batch size. + + The function is used to specify inference batch size. + Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1CNNNetwork.html#a8e9d19270a48aab50cb5b1c43eecb8e9 for additional information + + @param size batch size which will be used. + @return reference to this parameter structure. + */ + Params& cfgBatchSize(const size_t size) { + desc.batch_size = cv::util::make_optional(size); + return *this; + } + + // BEGIN(G-API's network parametrization API) + GBackend backend() const { return cv::gapi::ie::backend(); } + std::string tag() const { return Net::tag(); } + cv::util::any params() const { return { desc }; } + // END(G-API's network parametrization API) + +protected: + detail::ParamDesc desc; +}; + +/* +* @brief This structure provides functions for generic network type that +* fill inference parameters. +* @see struct Generic +*/ +template<> +class Params { +public: + /** @brief Class constructor. + + Constructs Params based on model information and sets default values for other + inference description parameters. Model is loaded and compiled using OpenVINO Toolkit. + + @param tag string tag of the network for which these parameters are intended. + @param model path to topology IR (.xml file). + @param weights path to weights (.bin file). + @param device target device to use. + */ + Params(const std::string &tag, + const std::string &model, + const std::string &weights, + const std::string &device) + : desc{ model, weights, device, {}, {}, {}, 0u, 0u, + detail::ParamDesc::Kind::Load, true, {}, {}, {}, 1u, + {}, {}}, + m_tag(tag) { + }; + + /** @overload + + This constructor for pre-compiled networks. Model is imported from pre-compiled + blob. + + @param tag string tag of the network for which these parameters are intended. + @param model path to model. + @param device target device to use. + */ + Params(const std::string &tag, + const std::string &model, + const std::string &device) + : desc{ model, {}, device, {}, {}, {}, 0u, 0u, + detail::ParamDesc::Kind::Import, true, {}, {}, {}, 1u, + {}, {}}, + m_tag(tag) { + }; + + /** @see ie::Params::pluginConfig. */ + Params& pluginConfig(const IEConfig& cfg) { + desc.config = cfg; + return *this; + } + + /** @overload */ + Params& pluginConfig(IEConfig&& cfg) { + desc.config = std::move(cfg); + return *this; + } + + /** @see ie::Params::constInput. */ + Params& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR) { + desc.const_inputs[layer_name] = {data, hint}; + return *this; + } + + /** @see ie::Params::cfgNumRequests. */ + Params& cfgNumRequests(size_t nireq) { + GAPI_Assert(nireq > 0 && "Number of infer requests must be greater than zero!"); + desc.nireq = nireq; + return *this; + } + + /** @see ie::Params::cfgInputReshape */ + Params& cfgInputReshape(const std::map>&reshape_table) { + desc.reshape_table = reshape_table; + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::map> && reshape_table) { + desc.reshape_table = std::move(reshape_table); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::string && layer_name, std::vector && layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(const std::string & layer_name, const std::vector&layer_dims) { + desc.reshape_table.emplace(layer_name, layer_dims); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(std::unordered_set && layer_names) { + desc.layer_names_to_reshape = std::move(layer_names); + return *this; + } + + /** @overload */ + Params& cfgInputReshape(const std::unordered_set&layer_names) { + desc.layer_names_to_reshape = layer_names; + return *this; + } + + /** @see ie::Params::cfgBatchSize */ + Params& cfgBatchSize(const size_t size) { + desc.batch_size = cv::util::make_optional(size); + return *this; + } + + // BEGIN(G-API's network parametrization API) + GBackend backend() const { return cv::gapi::ie::backend(); } + std::string tag() const { return m_tag; } + cv::util::any params() const { return { desc }; } + // END(G-API's network parametrization API) + +protected: + detail::ParamDesc desc; + std::string m_tag; +}; + +} // namespace ie +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_IE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/onnx.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/onnx.hpp new file mode 100644 index 0000000..bb5ef6c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/onnx.hpp @@ -0,0 +1,284 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + +#ifndef OPENCV_GAPI_INFER_ONNX_HPP +#define OPENCV_GAPI_INFER_ONNX_HPP + +#include +#include +#include +#include // tuple, tuple_size + +#include +#include + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { + +/** + * @brief This namespace contains G-API ONNX Runtime backend functions, structures, and symbols. + */ +namespace onnx { + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +enum class TraitAs: int { + TENSOR, //!< G-API traits an associated cv::Mat as a raw tensor + // and passes dimensions as-is + IMAGE //!< G-API traits an associated cv::Mat as an image so + // creates an "image" blob (NCHW/NHWC, etc) +}; + +using PostProc = std::function &, + std::unordered_map &)>; + +namespace detail { +/** +* @brief This structure contains description of inference parameters +* which is specific to ONNX models. +*/ +struct ParamDesc { + std::string model_path; //!< Path to model. + + // NB: nun_* may differ from topology's real input/output port numbers + // (e.g. topology's partial execution) + std::size_t num_in; //!< How many inputs are defined in the operation + std::size_t num_out; //!< How many outputs are defined in the operation + + // NB: Here order follows the `Net` API + std::vector input_names; //!< Names of input network layers. + std::vector output_names; //!< Names of output network layers. + + using ConstInput = std::pair; + std::unordered_map const_inputs; //!< Map with pair of name of network layer and ConstInput which will be associated with this. + + std::vector mean; //!< Mean values for preprocessing. + std::vector stdev; //!< Standard deviation values for preprocessing. + + std::vector out_metas; //!< Out meta information about your output (type, dimension). + PostProc custom_post_proc; //!< Post processing function. + + std::vector normalize; //!< Vector of bool values that enabled or disabled normalize of input data. + + std::vector names_to_remap; //!< Names of output layers that will be processed in PostProc function. +}; +} // namespace detail + +template +struct PortCfg { + using In = std::array + < std::string + , std::tuple_size::value >; + using Out = std::array + < std::string + , std::tuple_size::value >; + using NormCoefs = std::array + < cv::Scalar + , std::tuple_size::value >; + using Normalize = std::array + < bool + , std::tuple_size::value >; +}; + +/** + * Contains description of inference parameters and kit of functions that + * fill this parameters. + */ +template class Params { +public: + /** @brief Class constructor. + + Constructs Params based on model information and sets default values for other + inference description parameters. + + @param model Path to model (.onnx file). + */ + Params(const std::string &model) { + desc.model_path = model; + desc.num_in = std::tuple_size::value; + desc.num_out = std::tuple_size::value; + }; + + /** @brief Specifies sequence of network input layers names for inference. + + The function is used to associate data of graph inputs with input layers of + network topology. Number of names has to match the number of network inputs. If a network + has only one input layer, there is no need to call it as the layer is + associated with input automatically but this doesn't prevent you from + doing it yourself. Count of names has to match to number of network inputs. + + @param layer_names std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains names of input layers. + @return the reference on modified object. + */ + Params& cfgInputLayers(const typename PortCfg::In &layer_names) { + desc.input_names.assign(layer_names.begin(), layer_names.end()); + return *this; + } + + /** @brief Specifies sequence of output layers names for inference. + + The function is used to associate data of graph outputs with output layers of + network topology. If a network has only one output layer, there is no need to call it + as the layer is associated with ouput automatically but this doesn't prevent + you from doing it yourself. Count of names has to match to number of network + outputs or you can set your own output but for this case you have to + additionally use @ref cfgPostProc function. + + @param layer_names std::array where N is the number of outputs + as defined in the @ref G_API_NET. Contains names of output layers. + @return the reference on modified object. + */ + Params& cfgOutputLayers(const typename PortCfg::Out &layer_names) { + desc.output_names.assign(layer_names.begin(), layer_names.end()); + return *this; + } + + /** @brief Sets a constant input. + + The function is used to set constant input. This input has to be + a prepared tensor since preprocessing is disabled for this case. You should + provide name of network layer which will receive provided data. + + @param layer_name Name of network layer. + @param data cv::Mat that contains data which will be associated with network layer. + @param hint Type of input (TENSOR). + @return the reference on modified object. + */ + Params& constInput(const std::string &layer_name, + const cv::Mat &data, + TraitAs hint = TraitAs::TENSOR) { + desc.const_inputs[layer_name] = {data, hint}; + return *this; + } + + /** @brief Specifies mean value and standard deviation for preprocessing. + + The function is used to set mean value and standard deviation for preprocessing + of input data. + + @param m std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains mean values. + @param s std::array where N is the number of inputs + as defined in the @ref G_API_NET. Contains standard deviation values. + @return the reference on modified object. + */ + Params& cfgMeanStd(const typename PortCfg::NormCoefs &m, + const typename PortCfg::NormCoefs &s) { + desc.mean.assign(m.begin(), m.end()); + desc.stdev.assign(s.begin(), s.end()); + return *this; + } + + /** @brief Configures graph output and provides the post processing function from user. + + The function is used when you work with networks with dynamic outputs. + Since we can't know dimensions of inference result needs provide them for + construction of graph output. This dimensions can differ from inference result. + So you have to provide @ref PostProc function that gets information from inference + result and fill output which is constructed by dimensions from out_metas. + + @param out_metas Out meta information about your output (type, dimension). + @param remap_function Post processing function, which has two parameters. First is onnx + result, second is graph output. Both parameters is std::map that contain pair of + layer's name and cv::Mat. + @return the reference on modified object. + */ + Params& cfgPostProc(const std::vector &out_metas, + const PostProc &remap_function) { + desc.out_metas = out_metas; + desc.custom_post_proc = remap_function; + return *this; + } + + /** @overload + Function with a rvalue parameters. + + @param out_metas rvalue out meta information about your output (type, dimension). + @param remap_function rvalue post processing function, which has two parameters. First is onnx + result, second is graph output. Both parameters is std::map that contain pair of + layer's name and cv::Mat. + @return the reference on modified object. + */ + Params& cfgPostProc(std::vector &&out_metas, + PostProc &&remap_function) { + desc.out_metas = std::move(out_metas); + desc.custom_post_proc = std::move(remap_function); + return *this; + } + + /** @overload + The function has additional parameter names_to_remap. This parameter provides + information about output layers which will be used for inference and post + processing function. + + @param out_metas Out meta information. + @param remap_function Post processing function. + @param names_to_remap Names of output layers. network's inference will + be done on these layers. Inference's result will be processed in post processing + function using these names. + @return the reference on modified object. + */ + Params& cfgPostProc(const std::vector &out_metas, + const PostProc &remap_function, + const std::vector &names_to_remap) { + desc.out_metas = out_metas; + desc.custom_post_proc = remap_function; + desc.names_to_remap = names_to_remap; + return *this; + } + + /** @overload + Function with a rvalue parameters and additional parameter names_to_remap. + + @param out_metas rvalue out meta information. + @param remap_function rvalue post processing function. + @param names_to_remap rvalue names of output layers. network's inference will + be done on these layers. Inference's result will be processed in post processing + function using these names. + @return the reference on modified object. + */ + Params& cfgPostProc(std::vector &&out_metas, + PostProc &&remap_function, + std::vector &&names_to_remap) { + desc.out_metas = std::move(out_metas); + desc.custom_post_proc = std::move(remap_function); + desc.names_to_remap = std::move(names_to_remap); + return *this; + } + + /** @brief Specifies normalize parameter for preprocessing. + + The function is used to set normalize parameter for preprocessing of input data. + + @param normalizations std::array where N is the number of inputs + as defined in the @ref G_API_NET. Сontains bool values that enabled or disabled + normalize of input data. + @return the reference on modified object. + */ + Params& cfgNormalize(const typename PortCfg::Normalize &normalizations) { + desc.normalize.assign(normalizations.begin(), normalizations.end()); + return *this; + } + + // BEGIN(G-API's network parametrization API) + GBackend backend() const { return cv::gapi::onnx::backend(); } + std::string tag() const { return Net::tag(); } + cv::util::any params() const { return { desc }; } + // END(G-API's network parametrization API) + +protected: + detail::ParamDesc desc; +}; + +} // namespace onnx +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_INFER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/parsers.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/parsers.hpp new file mode 100644 index 0000000..c7308dd --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/infer/parsers.hpp @@ -0,0 +1,138 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_PARSERS_HPP +#define OPENCV_GAPI_PARSERS_HPP + +#include // std::tuple + +#include +#include + +namespace cv { namespace gapi { +namespace nn { +namespace parsers { + using GRects = GArray; + using GDetections = std::tuple, GArray>; + + G_TYPED_KERNEL(GParseSSDBL, , float, int)>, + "org.opencv.nn.parsers.parseSSD_BL") { + static std::tuple outMeta(const GMatDesc&, const GOpaqueDesc&, float, int) { + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + }; + + G_TYPED_KERNEL(GParseSSD, , float, bool, bool)>, + "org.opencv.nn.parsers.parseSSD") { + static GArrayDesc outMeta(const GMatDesc&, const GOpaqueDesc&, float, bool, bool) { + return empty_array_desc(); + } + }; + + G_TYPED_KERNEL(GParseYolo, , float, float, std::vector)>, + "org.opencv.nn.parsers.parseYolo") { + static std::tuple outMeta(const GMatDesc&, const GOpaqueDesc&, + float, float, const std::vector&) { + return std::make_tuple(empty_array_desc(), empty_array_desc()); + } + static const std::vector& defaultAnchors() { + static std::vector anchors { + 0.57273f, 0.677385f, 1.87446f, 2.06253f, 3.33843f, 5.47434f, 7.88282f, 3.52778f, 9.77052f, 9.16828f + }; + return anchors; + } + }; +} // namespace parsers +} // namespace nn + +/** @brief Parses output of SSD network. + +Extracts detection information (box, confidence, label) from SSD output and +filters it by given confidence and label. + +@note Function textual ID is "org.opencv.nn.parsers.parseSSD_BL" + +@param in Input CV_32F tensor with {1,1,N,7} dimensions. +@param inSz Size to project detected boxes to (size of the input image). +@param confidenceThreshold If confidence of the +detection is smaller than confidence threshold, detection is rejected. +@param filterLabel If provided (!= -1), only detections with +given label will get to the output. +@return a tuple with a vector of detected boxes and a vector of appropriate labels. +*/ +GAPI_EXPORTS_W std::tuple, GArray> parseSSD(const GMat& in, + const GOpaque& inSz, + const float confidenceThreshold = 0.5f, + const int filterLabel = -1); + +/** @brief Parses output of SSD network. + +Extracts detection information (box, confidence) from SSD output and +filters it by given confidence and by going out of bounds. + +@note Function textual ID is "org.opencv.nn.parsers.parseSSD" + +@param in Input CV_32F tensor with {1,1,N,7} dimensions. +@param inSz Size to project detected boxes to (size of the input image). +@param confidenceThreshold If confidence of the +detection is smaller than confidence threshold, detection is rejected. +@param alignmentToSquare If provided true, bounding boxes are extended to squares. +The center of the rectangle remains unchanged, the side of the square is +the larger side of the rectangle. +@param filterOutOfBounds If provided true, out-of-frame boxes are filtered. +@return a vector of detected bounding boxes. +*/ +GAPI_EXPORTS_W GArray parseSSD(const GMat& in, + const GOpaque& inSz, + const float confidenceThreshold, + const bool alignmentToSquare, + const bool filterOutOfBounds); + +/** @brief Parses output of Yolo network. + +Extracts detection information (box, confidence, label) from Yolo output, +filters it by given confidence and performs non-maximum supression for overlapping boxes. + +@note Function textual ID is "org.opencv.nn.parsers.parseYolo" + +@param in Input CV_32F tensor with {1,13,13,N} dimensions, N should satisfy: +\f[\texttt{N} = (\texttt{num_classes} + \texttt{5}) * \texttt{5},\f] +where num_classes - a number of classes Yolo network was trained with. +@param inSz Size to project detected boxes to (size of the input image). +@param confidenceThreshold If confidence of the +detection is smaller than confidence threshold, detection is rejected. +@param nmsThreshold Non-maximum supression threshold which controls minimum +relative box intersection area required for rejecting the box with a smaller confidence. +If 1.f, nms is not performed and no boxes are rejected. +@param anchors Anchors Yolo network was trained with. +@note The default anchor values are specified for YOLO v2 Tiny as described in Intel Open Model Zoo +documentation. +@return a tuple with a vector of detected boxes and a vector of appropriate labels. +*/ +GAPI_EXPORTS_W std::tuple, GArray> parseYolo(const GMat& in, + const GOpaque& inSz, + const float confidenceThreshold = 0.5f, + const float nmsThreshold = 0.5f, + const std::vector& anchors + = nn::parsers::GParseYolo::defaultAnchors()); + +} // namespace gapi +} // namespace cv + +// Reimport parseSSD & parseYolo under their initial namespace +namespace cv { +namespace gapi { +namespace streaming { + +using cv::gapi::parseSSD; +using cv::gapi::parseYolo; + +} // namespace streaming +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_PARSERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/media.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/media.hpp new file mode 100644 index 0000000..19aaef3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/media.hpp @@ -0,0 +1,257 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_MEDIA_HPP +#define OPENCV_GAPI_MEDIA_HPP + +#include // unique_ptr<>, shared_ptr<> +#include // array<> +#include // function<> +#include // forward<>() + +#include +#include + +// Forward declaration +namespace cv { +namespace gapi { +namespace s11n { +struct IOStream; +struct IIStream; +} // namespace s11n +} // namespace gapi +} // namespace cv + +namespace cv { + +/** \addtogroup gapi_data_structures + * @{ + * + * @brief Extra G-API data structures used to pass input/output data + * to the graph for processing. + */ +/** + * @brief cv::MediaFrame class represents an image/media frame + * obtained from an external source. + * + * cv::MediaFrame represents image data as specified in + * cv::MediaFormat. cv::MediaFrame is designed to be a thin wrapper over some + * external memory of buffer; the class itself provides an uniform + * interface over such types of memory. cv::MediaFrame wraps data from + * a camera driver or from a media codec and provides an abstraction + * layer over this memory to G-API. MediaFrame defines a compact interface + * to access and manage the underlying data; the implementation is + * fully defined by the associated Adapter (which is usually + * user-defined). + * + * @sa cv::RMat + */ +class GAPI_EXPORTS MediaFrame { +public: + /// This enum defines different types of cv::MediaFrame provided + /// access to the underlying data. Note that different flags can't + /// be combined in this version. + enum class Access { + R, ///< Access data for reading + W, ///< Access data for writing + }; + class IAdapter; + class View; + using AdapterPtr = std::unique_ptr; + + /** + * @brief Constructs an empty MediaFrame + * + * The constructed object has no any data associated with it. + */ + MediaFrame(); + + /** + * @brief Constructs a MediaFrame with the given + * Adapter. MediaFrame takes ownership over the passed adapter. + * + * @param p an unique pointer to instance of IAdapter derived class. + */ + explicit MediaFrame(AdapterPtr &&p); + + /** + * @overload + * @brief Constructs a MediaFrame with the given parameters for + * the Adapter. The adapter of type `T` is costructed on the fly. + * + * @param args list of arguments to construct an adapter of type + * `T`. + */ + template static cv::MediaFrame Create(Args&&... args); + + /** + * @brief Obtain access to the underlying data with the given + * mode. + * + * Depending on the associated Adapter and the data wrapped, this + * method may be cheap (e.g., the underlying memory is local) or + * costly (if the underlying memory is external or device + * memory). + * + * @param mode an access mode flag + * @return a MediaFrame::View object. The views should be handled + * carefully, refer to the MediaFrame::View documentation for details. + */ + View access(Access mode) const; + + /** + * @brief Returns a media frame descriptor -- the information + * about the media format, dimensions, etc. + * @return a cv::GFrameDesc + */ + cv::GFrameDesc desc() const; + + // FIXME: design a better solution + // Should be used only if the actual adapter provides implementation + /// @private -- exclude from the OpenCV documentation for now. + cv::util::any blobParams() const; + + /** + * @brief Casts and returns the associated MediaFrame adapter to + * the particular adapter type `T`, returns nullptr if the type is + * different. + * + * This method may be useful if the adapter type is known by the + * caller, and some lower level access to the memory is required. + * Depending on the memory type, it may be more efficient than + * access(). + * + * @return a pointer to the adapter object, nullptr if the adapter + * type is different. + */ + template T* get() const { + static_assert(std::is_base_of::value, + "T is not derived from cv::MediaFrame::IAdapter!"); + auto* adapter = getAdapter(); + GAPI_Assert(adapter != nullptr); + return dynamic_cast(adapter); + } + + /** + * @brief Serialize MediaFrame's data to a byte array. + * + * @note The actual logic is implemented by frame's adapter class. + * Does nothing by default. + * + * @param os Bytestream to store serialized MediaFrame data in. + */ + void serialize(cv::gapi::s11n::IOStream& os) const; + +private: + struct Priv; + std::shared_ptr m; + IAdapter* getAdapter() const; +}; + +template +inline cv::MediaFrame cv::MediaFrame::Create(Args&&... args) { + std::unique_ptr ptr(new T(std::forward(args)...)); + return cv::MediaFrame(std::move(ptr)); +} + +/** + * @brief Provides access to the MediaFrame's underlying data. + * + * This object contains the necessary information to access the pixel + * data of the associated MediaFrame: arrays of pointers and strides + * (distance between every plane row, in bytes) for every image + * plane, as defined in cv::MediaFormat. + * There may be up to four image planes in MediaFrame. + * + * Depending on the MediaFrame::Access flag passed in + * MediaFrame::access(), a MediaFrame::View may be read- or + * write-only. + * + * Depending on the MediaFrame::IAdapter implementation associated + * with the parent MediaFrame, writing to memory with + * MediaFrame::Access::R flag may have no effect or lead to + * undefined behavior. Same applies to reading the memory with + * MediaFrame::Access::W flag -- again, depending on the IAdapter + * implementation, the host-side buffer the view provides access to + * may have no current data stored in (so in-place editing of the + * buffer contents may not be possible). + * + * MediaFrame::View objects must be handled carefully, as an external + * resource associated with MediaFrame may be locked for the time the + * MediaFrame::View object exists. Obtaining MediaFrame::View should + * be seen as "map" and destroying it as "unmap" in the "map/unmap" + * idiom (applicable to OpenCL, device memory, remote + * memory). + * + * When a MediaFrame buffer is accessed for writing, and the memory + * under MediaFrame::View::Ptrs is altered, the data synchronization + * of a host-side and device/remote buffer is not guaranteed until the + * MediaFrame::View is destroyed. In other words, the real data on the + * device or in a remote target may be updated at the MediaFrame::View + * destruction only -- but it depends on the associated + * MediaFrame::IAdapter implementation. + */ +class GAPI_EXPORTS MediaFrame::View final { +public: + static constexpr const size_t MAX_PLANES = 4; + using Ptrs = std::array; + using Strides = std::array; // in bytes + using Callback = std::function; + + /// @private + View(Ptrs&& ptrs, Strides&& strs, Callback &&cb = [](){}); + + /// @private + View(const View&) = delete; + + /// @private + View(View&&) = default; + + /// @private + View& operator = (const View&) = delete; + + ~View(); + + Ptrs ptr; ///< Array of image plane pointers + Strides stride; ///< Array of image plane strides, in bytes. + +private: + Callback m_cb; +}; + +/** + * @brief An interface class for MediaFrame data adapters. + * + * Implement this interface to wrap media data in the MediaFrame. It + * makes sense to implement this class if there is a custom + * cv::gapi::wip::IStreamSource defined -- in this case, a stream + * source can produce MediaFrame objects with this adapter and the + * media data may be passed to graph without any copy. For example, a + * GStreamer-based stream source can implement an adapter over + * `GstBuffer` and G-API will transparently use it in the graph. + */ +class GAPI_EXPORTS MediaFrame::IAdapter { +public: + virtual ~IAdapter() = 0; + virtual cv::GFrameDesc meta() const = 0; + virtual MediaFrame::View access(MediaFrame::Access) = 0; + // FIXME: design a better solution + // The default implementation does nothing + virtual cv::util::any blobParams() const; + virtual void serialize(cv::gapi::s11n::IOStream&) { + GAPI_Assert(false && "Generic serialize method of MediaFrame::IAdapter does nothing by default. " + "Please, implement it in derived class to properly serialize the object."); + } + virtual void deserialize(cv::gapi::s11n::IIStream&) { + GAPI_Assert(false && "Generic deserialize method of MediaFrame::IAdapter does nothing by default. " + "Please, implement it in derived class to properly deserialize the object."); + } +}; +/** @} */ + +} //namespace cv + +#endif // OPENCV_GAPI_MEDIA_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/core.hpp new file mode 100644 index 0000000..6c75870 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/core.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OCL_CORE_API_HPP +#define OPENCV_GAPI_OCL_CORE_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace core { +namespace ocl { + + GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +} // namespace ocl +} // namespace core +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_OCL_CORE_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/goclkernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/goclkernel.hpp new file mode 100644 index 0000000..6a2f1df --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/goclkernel.hpp @@ -0,0 +1,249 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GOCLKERNEL_HPP +#define OPENCV_GAPI_GOCLKERNEL_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +// FIXME: namespace scheme for backends? +namespace cv { + +namespace gimpl +{ + // Forward-declare an internal class + class GOCLExecutable; +} // namespace gimpl + +namespace gapi +{ +/** + * @brief This namespace contains G-API OpenCL backend functions, structures, and symbols. + */ +namespace ocl +{ + /** + * \addtogroup gapi_std_backends G-API Standard Backends + * @{ + */ + /** + * @brief Get a reference to OCL backend. + * + * At the moment, the OCL backend is built atop of OpenCV + * "Transparent API" (T-API), see cv::UMat for details. + * + * @sa gapi_std_backends + */ + GAPI_EXPORTS cv::gapi::GBackend backend(); + /** @} */ +} // namespace ocl +} // namespace gapi + + +// Represents arguments which are passed to a wrapped OCL function +// FIXME: put into detail? +class GAPI_EXPORTS GOCLContext +{ +public: + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const cv::UMat& inMat(int input); + cv::UMat& outMatR(int output); // FIXME: Avoid cv::Mat m = ctx.outMatR() + + const cv::Scalar& inVal(int input); + cv::Scalar& outValR(int output); // FIXME: Avoid cv::Scalar s = ctx.outValR() + template std::vector& outVecR(int output) // FIXME: the same issue + { + return outVecRef(output).wref(); + } + template T& outOpaqueR(int output) // FIXME: the same issue + { + return outOpaqueRef(output).wref(); + } + +protected: + detail::VectorRef& outVecRef(int output); + detail::OpaqueRef& outOpaqueRef(int output); + + std::vector m_args; + std::unordered_map m_results; + + + friend class gimpl::GOCLExecutable; +}; + +class GAPI_EXPORTS GOCLKernel +{ +public: + // This function is kernel's execution entry point (does the processing work) + using F = std::function; + + GOCLKernel(); + explicit GOCLKernel(const F& f); + + void apply(GOCLContext &ctx); + +protected: + F m_f; +}; + +// FIXME: This is an ugly ad-hoc implementation. TODO: refactor + +namespace detail +{ +template struct ocl_get_in; +template<> struct ocl_get_in +{ + static cv::UMat get(GOCLContext &ctx, int idx) { return ctx.inMat(idx); } +}; +template<> struct ocl_get_in +{ + static cv::Scalar get(GOCLContext &ctx, int idx) { return ctx.inVal(idx); } +}; +template struct ocl_get_in > +{ + static const std::vector& get(GOCLContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct ocl_get_in > +{ + static const U& get(GOCLContext &ctx, int idx) { return ctx.inArg(idx).rref(); } +}; +template struct ocl_get_in +{ + static T get(GOCLContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +struct tracked_cv_umat{ + //TODO Think if T - API could reallocate UMat to a proper size - how do we handle this ? + //tracked_cv_umat(cv::UMat& m) : r{(m)}, original_data{m.getMat(ACCESS_RW).data} {} + tracked_cv_umat(cv::UMat& m) : r(m), original_data{ nullptr } {} + cv::UMat &r; // FIXME: It was a value (not a reference) before. + // Actually OCL backend should allocate its internal data! + uchar* original_data; + + operator cv::UMat& (){ return r;} + void validate() const{ + //if (r.getMat(ACCESS_RW).data != original_data) + //{ + // util::throw_error + // (std::logic_error + // ("OpenCV kernel output parameter was reallocated. \n" + // "Incorrect meta data was provided ?")); + //} + + } +}; + +template +void postprocess_ocl(Outputs&... outs) +{ + struct + { + void operator()(tracked_cv_umat* bm) { bm->validate(); } + void operator()(...) { } + + } validate; + //dummy array to unfold parameter pack + int dummy[] = { 0, (validate(&outs), 0)... }; + cv::util::suppress_unused_warning(dummy); +} + +template struct ocl_get_out; +template<> struct ocl_get_out +{ + static tracked_cv_umat get(GOCLContext &ctx, int idx) + { + auto& r = ctx.outMatR(idx); + return{ r }; + } +}; +template<> struct ocl_get_out +{ + static cv::Scalar& get(GOCLContext &ctx, int idx) + { + return ctx.outValR(idx); + } +}; +template struct ocl_get_out > +{ + static std::vector& get(GOCLContext &ctx, int idx) { return ctx.outVecR(idx); } +}; +template struct ocl_get_out > +{ + static U& get(GOCLContext &ctx, int idx) { return ctx.outOpaqueR(idx); } +}; + +template +struct OCLCallHelper; + +// FIXME: probably can be simplified with std::apply or analogue. +template +struct OCLCallHelper, std::tuple > +{ + template + struct call_and_postprocess + { + template + static void call(Inputs&&... ins, Outputs&&... outs) + { + //not using a std::forward on outs is deliberate in order to + //cause compilation error, by trying to bind rvalue references to lvalue references + Impl::run(std::forward(ins)..., outs...); + + postprocess_ocl(outs...); + } + }; + + template + static void call_impl(GOCLContext &ctx, detail::Seq, detail::Seq) + { + //TODO: Make sure that OpenCV kernels do not reallocate memory for output parameters + //by comparing it's state (data ptr) before and after the call. + //Convert own::Scalar to cv::Scalar before call kernel and run kernel + //convert cv::Scalar to own::Scalar after call kernel and write back results + call_and_postprocess::get(ctx, IIs))...>::call(ocl_get_in::get(ctx, IIs)..., ocl_get_out::get(ctx, OIs)...); + } + + static void call(GOCLContext &ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GOCLKernelImpl: public cv::detail::OCLCallHelper, + public cv::detail::KernelTag +{ + using P = detail::OCLCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::ocl::backend(); } + static cv::GOCLKernel kernel() { return GOCLKernel(&P::call); } +}; + +#define GAPI_OCL_KERNEL(Name, API) struct Name: public cv::GOCLKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GOCLKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/imgproc.hpp new file mode 100644 index 0000000..1bb5911 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/ocl/imgproc.hpp @@ -0,0 +1,27 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OCL_IMGPROC_API_HPP +#define OPENCV_GAPI_OCL_IMGPROC_API_HPP + +#include // GAPI_EXPORTS +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace imgproc { +namespace ocl { + + GAPI_EXPORTS GKernelPackage kernels(); + +} // namespace ocl +} // namespace imgproc +} // namespace gapi +} // namespace cv + + +#endif // OPENCV_GAPI_OCL_IMGPROC_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/opencv_includes.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/opencv_includes.hpp new file mode 100644 index 0000000..25a67d6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/opencv_includes.hpp @@ -0,0 +1,41 @@ +// This file is part of OpenCV project. + +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OPENCV_INCLUDES_HPP +#define OPENCV_GAPI_OPENCV_INCLUDES_HPP + +#if !defined(GAPI_STANDALONE) +# include +# include +# include +# include +#define GAPI_OWN_TYPES_LIST cv::gapi::own::Rect, \ + cv::gapi::own::Size, \ + cv::gapi::own::Point, \ + cv::gapi::own::Point2f, \ + cv::gapi::own::Scalar, \ + cv::gapi::own::Mat +#else // Without OpenCV +# include +# include // cv::gapi::own::Rect/Size/Point +# include // cv::gapi::own::Scalar +# include +// replacement of cv's structures: +namespace cv { + using Rect = gapi::own::Rect; + using Size = gapi::own::Size; + using Point = gapi::own::Point; + using Point2f = gapi::own::Point2f; + using Scalar = gapi::own::Scalar; + using Mat = gapi::own::Mat; +} // namespace cv +#define GAPI_OWN_TYPES_LIST cv::gapi::own::VoidType + +#endif // !defined(GAPI_STANDALONE) + +#endif // OPENCV_GAPI_OPENCV_INCLUDES_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/operators.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/operators.hpp new file mode 100644 index 0000000..6794b44 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/operators.hpp @@ -0,0 +1,70 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OPERATORS_HPP +#define OPENCV_GAPI_OPERATORS_HPP + +#include +#include + +namespace cv +{ +GAPI_EXPORTS cv::GMat operator+(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator+(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator+(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator-(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator-(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator-(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator*(const cv::GMat& lhs, float rhs); +GAPI_EXPORTS cv::GMat operator*(float lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator*(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator*(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator/(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator/(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator/(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator&(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator|(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator^(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator~(const cv::GMat& lhs); + +GAPI_EXPORTS cv::GMat operator&(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator|(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator^(const cv::GScalar& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator&(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator|(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator^(const cv::GMat& lhs, const cv::GScalar& rhs); + +GAPI_EXPORTS cv::GMat operator>(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator>=(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<=(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator==(const cv::GMat& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator!=(const cv::GMat& lhs, const cv::GMat& rhs); + +GAPI_EXPORTS cv::GMat operator>(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator>=(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator<(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator<=(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator==(const cv::GMat& lhs, const cv::GScalar& rhs); +GAPI_EXPORTS cv::GMat operator!=(const cv::GMat& lhs, const cv::GScalar& rhs); + +GAPI_EXPORTS cv::GMat operator>(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator>=(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator<=(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator==(const cv::GScalar& lhs, const cv::GMat& rhs); +GAPI_EXPORTS cv::GMat operator!=(const cv::GScalar& lhs, const cv::GMat& rhs); +} // cv + +#endif // OPENCV_GAPI_OPERATORS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/assert.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/assert.hpp new file mode 100644 index 0000000..d50543f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/assert.hpp @@ -0,0 +1,55 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_ASSERT_HPP +#define OPENCV_GAPI_OWN_ASSERT_HPP + +#include + +#define GAPI_DbgAssertNoOp(expr) { \ + constexpr bool _assert_tmp = false && (expr); \ + cv::util::suppress_unused_warning(_assert_tmp); \ +} + +#if !defined(GAPI_STANDALONE) +#include +#define GAPI_Assert CV_Assert + +#if defined _DEBUG || defined CV_STATIC_ANALYSIS +# define GAPI_DbgAssert CV_DbgAssert +#else +# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr) +#endif + +#else +#include +#include +#include + +namespace detail +{ + [[noreturn]] inline void assert_abort(const char* str, int line, const char* file, const char* func) + { + std::stringstream ss; + ss << file << ":" << line << ": Assertion " << str << " in function " << func << " failed\n"; + cv::util::throw_error(std::logic_error(ss.str())); + } +} + +#define GAPI_Assert(expr) \ +{ if (!(expr)) ::detail::assert_abort(#expr, __LINE__, __FILE__, __func__); } + + +#ifdef NDEBUG +# define GAPI_DbgAssert(expr) GAPI_DbgAssertNoOp(expr) +#else +# define GAPI_DbgAssert(expr) GAPI_Assert(expr) +#endif + +#endif // GAPI_STANDALONE + +#endif // OPENCV_GAPI_OWN_ASSERT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/convert.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/convert.hpp new file mode 100644 index 0000000..1a8ecd8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/convert.hpp @@ -0,0 +1,55 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_CONVERT_HPP +#define OPENCV_GAPI_OWN_CONVERT_HPP + +#if !defined(GAPI_STANDALONE) + +#include +#include + +namespace cv +{ + template + std::vector to_own(const cv::MatSize &sz) { + std::vector result(sz.dims()); + for (int i = 0; i < sz.dims(); i++) { + // Note: cv::MatSize is not iterable + result[i] = static_cast(sz[i]); + } + return result; + } + + cv::gapi::own::Mat to_own(Mat&&) = delete; + + inline cv::gapi::own::Mat to_own(Mat const& m) { + return (m.dims == 2) + ? cv::gapi::own::Mat{m.rows, m.cols, m.type(), m.data, m.step} + : cv::gapi::own::Mat{to_own(m.size), m.type(), m.data}; + }; + +namespace gapi +{ +namespace own +{ + + inline cv::Mat to_ocv(Mat const& m) { + return m.dims.empty() + ? cv::Mat{m.rows, m.cols, m.type(), m.data, m.step} + : cv::Mat{m.dims, m.type(), m.data}; + } + + cv::Mat to_ocv(Mat&&) = delete; + +} // namespace own +} // namespace gapi +} // namespace cv + +#endif // !defined(GAPI_STANDALONE) + +#endif // OPENCV_GAPI_OWN_CONVERT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/cvdefs.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/cvdefs.hpp new file mode 100644 index 0000000..d3bef98 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/cvdefs.hpp @@ -0,0 +1,166 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_CV_DEFS_HPP +#define OPENCV_GAPI_CV_DEFS_HPP + +#if defined(GAPI_STANDALONE) +// Simulate OpenCV definitions taken from various +// OpenCV interface headers if G-API is built in a +// standalone mode. + +// interface.h: + +typedef unsigned char uchar; +typedef char schar; + +typedef unsigned short ushort; + +#define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0" + +#define CV_CN_MAX 512 +#define CV_CN_SHIFT 3 +#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) + +#define CV_8U 0 +#define CV_8S 1 +#define CV_16U 2 +#define CV_16S 3 +#define CV_32S 4 +#define CV_32F 5 +#define CV_64F 6 +#define CV_16F 7 + +#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) +#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) + +#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) +#define CV_MAKE_TYPE CV_MAKETYPE + +#define CV_8UC1 CV_MAKETYPE(CV_8U,1) +#define CV_8UC2 CV_MAKETYPE(CV_8U,2) +#define CV_8UC3 CV_MAKETYPE(CV_8U,3) +#define CV_8UC4 CV_MAKETYPE(CV_8U,4) +#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) + +#define CV_8SC1 CV_MAKETYPE(CV_8S,1) +#define CV_8SC2 CV_MAKETYPE(CV_8S,2) +#define CV_8SC3 CV_MAKETYPE(CV_8S,3) +#define CV_8SC4 CV_MAKETYPE(CV_8S,4) +#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) + +#define CV_16UC1 CV_MAKETYPE(CV_16U,1) +#define CV_16UC2 CV_MAKETYPE(CV_16U,2) +#define CV_16UC3 CV_MAKETYPE(CV_16U,3) +#define CV_16UC4 CV_MAKETYPE(CV_16U,4) +#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) + +#define CV_16SC1 CV_MAKETYPE(CV_16S,1) +#define CV_16SC2 CV_MAKETYPE(CV_16S,2) +#define CV_16SC3 CV_MAKETYPE(CV_16S,3) +#define CV_16SC4 CV_MAKETYPE(CV_16S,4) +#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) + +#define CV_32SC1 CV_MAKETYPE(CV_32S,1) +#define CV_32SC2 CV_MAKETYPE(CV_32S,2) +#define CV_32SC3 CV_MAKETYPE(CV_32S,3) +#define CV_32SC4 CV_MAKETYPE(CV_32S,4) +#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) + +#define CV_16FC1 CV_MAKETYPE(CV_16F,1) +#define CV_16FC2 CV_MAKETYPE(CV_16F,2) +#define CV_16FC3 CV_MAKETYPE(CV_16F,3) +#define CV_16FC4 CV_MAKETYPE(CV_16F,4) +#define CV_16FC(n) CV_MAKETYPE(CV_16F,(n)) + +#define CV_32FC1 CV_MAKETYPE(CV_32F,1) +#define CV_32FC2 CV_MAKETYPE(CV_32F,2) +#define CV_32FC3 CV_MAKETYPE(CV_32F,3) +#define CV_32FC4 CV_MAKETYPE(CV_32F,4) +#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) + +#define CV_64FC1 CV_MAKETYPE(CV_64F,1) +#define CV_64FC2 CV_MAKETYPE(CV_64F,2) +#define CV_64FC3 CV_MAKETYPE(CV_64F,3) +#define CV_64FC4 CV_MAKETYPE(CV_64F,4) +#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) + +// cvdef.h: + +#ifndef CV_ALWAYS_INLINE +# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +# define CV_ALWAYS_INLINE inline __attribute__((always_inline)) +# elif defined(_MSC_VER) +# define CV_ALWAYS_INLINE __forceinline +# else +# define CV_ALWAYS_INLINE inline +# endif +#endif + +#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) +#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) +#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) +#define CV_MAT_CONT_FLAG_SHIFT 14 +#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) +#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) +#define CV_IS_CONT_MAT CV_IS_MAT_CONT +#define CV_SUBMAT_FLAG_SHIFT 15 +#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT) +#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG) + +//** Size of each channel item, +// 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ +#define CV_ELEM_SIZE1(type) \ + ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15) + +#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) + +/** 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */ +#define CV_ELEM_SIZE(type) \ + (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)) + +#ifndef CV_OVERRIDE +# define CV_OVERRIDE override +#endif + +// base.h: +namespace cv +{ +enum BorderTypes { + BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i` + BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh` + BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb` + BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg` + BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba` + BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno` + + BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101 + BORDER_ISOLATED = 16 //!< do not look outside of ROI +}; +// imgproc.hpp: +enum InterpolationFlags{ + INTER_NEAREST = 0, + INTER_LINEAR = 1, + INTER_CUBIC = 2, + INTER_AREA = 3, + INTER_LANCZOS4 = 4, + INTER_LINEAR_EXACT = 5, + INTER_MAX = 7, +}; +} // namespace cv + +static inline int cvFloor( double value ) +{ + int i = (int)value; + return i - (i > value); +} + +#endif // defined(GAPI_STANDALONE) + +#endif // OPENCV_GAPI_CV_DEFS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/exports.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/exports.hpp new file mode 100644 index 0000000..c36f400 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/exports.hpp @@ -0,0 +1,42 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_TYPES_HPP +#define OPENCV_GAPI_OWN_TYPES_HPP + +# if defined(__OPENCV_BUILD) +# include +# define GAPI_EXPORTS CV_EXPORTS + /* special informative macros for wrapper generators */ +# define GAPI_PROP CV_PROP +# define GAPI_PROP_RW CV_PROP_RW +# define GAPI_WRAP CV_WRAP +# define GAPI_EXPORTS_W_SIMPLE CV_EXPORTS_W_SIMPLE +# define GAPI_EXPORTS_W CV_EXPORTS_W +# else +# define GAPI_PROP +# define GAPI_PROP_RW +# define GAPI_WRAP +# define GAPI_EXPORTS +# define GAPI_EXPORTS_W_SIMPLE +# define GAPI_EXPORTS_W + +#if 0 // Note: the following version currently is not needed for non-OpenCV build +# if defined _WIN32 +# define GAPI_EXPORTS __declspec(dllexport) +# elif defined __GNUC__ && __GNUC__ >= 4 +# define GAPI_EXPORTS __attribute__ ((visibility ("default"))) +# endif + +# ifndef GAPI_EXPORTS +# define GAPI_EXPORTS +# endif +#endif + +# endif + +#endif // OPENCV_GAPI_OWN_TYPES_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/mat.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/mat.hpp new file mode 100644 index 0000000..ce9c0bf --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/mat.hpp @@ -0,0 +1,354 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_MAT_HPP +#define OPENCV_GAPI_OWN_MAT_HPP + +#include +#include +#include +#include +#include + +#include //std::shared_ptr +#include //std::memcpy +#include //std::accumulate +#include +#include + +namespace cv { namespace gapi { namespace own { + namespace detail { + template + void assign_row(void* ptr, int cols, Scalar const& s) + { + auto p = static_cast(ptr); + for (int c = 0; c < cols; c++) + { + for (int ch = 0; ch < channels; ch++) + { + p[c * channels + ch] = saturate(s[ch], roundd); + } + } + } + + inline size_t default_step(int type, int cols) + { + return CV_ELEM_SIZE(type) * cols; + } + //Matrix header, i.e. fields that are unique to each Mat object. + //Devoted class is needed to implement custom behavior on move (erasing state of moved from object) + struct MatHeader{ + enum { AUTO_STEP = 0}; + enum { TYPE_MASK = 0x00000FFF }; + + MatHeader() = default; + + MatHeader(int _rows, int _cols, int type, void* _data, size_t _step) + : flags((type & TYPE_MASK)), rows(_rows), cols(_cols), data((uchar*)_data), step(_step == AUTO_STEP ? detail::default_step(type, _cols) : _step) + {} + + MatHeader(const std::vector &_dims, int type, void* _data) + : flags((type & TYPE_MASK)), data((uchar*)_data), step(0), dims(_dims) + {} + + MatHeader(const MatHeader& ) = default; + MatHeader(MatHeader&& src) : MatHeader(src) // reuse copy constructor here + { + MatHeader empty; //give it a name to call copy(not move) assignment below + src = empty; + } + MatHeader& operator=(const MatHeader& ) = default; + MatHeader& operator=(MatHeader&& src) + { + *this = src; //calling a copy assignment here, not move one + MatHeader empty; //give it a name to call copy(not move) assignment below + src = empty; + return *this; + } + /*! includes several bit-fields: + - depth + - number of channels + */ + int flags = 0; + + //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions + int rows = 0, cols = 0; + //! pointer to the data + uchar* data = nullptr; + size_t step = 0; + //! dimensions (ND-case) + std::vector dims; + }; + } // namespace detail + //concise version of cv::Mat suitable for GAPI needs (used when no dependence on OpenCV is required) + class Mat : public detail::MatHeader{ + public: + + Mat() = default; + + /** @overload + @param _rows Number of rows in a 2D array. + @param _cols Number of columns in a 2D array. + @param _type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or + CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices. + @param _data Pointer to the user data. Matrix constructors that take data and step parameters do not + allocate matrix data. Instead, they just initialize the matrix header that points to the specified + data, which means that no data is copied. This operation is very efficient and can be used to + process external data using OpenCV functions. The external data is not automatically deallocated, so + you should take care of it. + @param _step Number of bytes each matrix row occupies. The value should include the padding bytes at + the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed + and the actual step is calculated as cols*elemSize(). See Mat::elemSize. + */ + Mat(int _rows, int _cols, int _type, void* _data, size_t _step = AUTO_STEP) + : MatHeader (_rows, _cols, _type, _data, _step) + {} + + Mat(const std::vector &_dims, int _type, void* _data) + : MatHeader (_dims, _type, _data) + {} + + Mat(std::vector &&_dims, int _type, void* _data) + : MatHeader (std::move(_dims), _type, _data) + {} + + Mat(Mat const& src, const Rect& roi ) + : Mat(src) + { + rows = roi.height; + cols = roi.width; + data = ptr(roi.y, roi.x); + } + + Mat(Mat const& ) = default; + Mat(Mat&& ) = default; + + Mat& operator=(Mat const& ) = default; + Mat& operator=(Mat&& ) = default; + + /** @brief Sets all or some of the array elements to the specified value. + @param s Assigned scalar converted to the actual array type. + */ + Mat& operator = (const Scalar& s) + { + constexpr unsigned max_channels = 4; //Scalar can't fit more than 4 + using func_p_t = void (*)(void*, int, Scalar const&); + using detail::assign_row; + #define TABLE_ENTRY(type) {assign_row, assign_row, assign_row, assign_row} + static constexpr func_p_t func_tbl[][max_channels] = { + TABLE_ENTRY(uchar), + TABLE_ENTRY(schar), + TABLE_ENTRY(ushort), + TABLE_ENTRY(short), + TABLE_ENTRY(int), + TABLE_ENTRY(float), + TABLE_ENTRY(double) + }; + #undef TABLE_ENTRY + + static_assert(CV_8U == 0 && CV_8S == 1 && CV_16U == 2 && CV_16S == 3 + && CV_32S == 4 && CV_32F == 5 && CV_64F == 6, + "OCV type ids used as indexes to array, thus exact numbers are important!" + ); + + const auto depth = static_cast(this->depth()); + GAPI_Assert(depth < sizeof(func_tbl)/sizeof(func_tbl[0])); + + if (dims.empty()) + { + const auto channels = static_cast(this->channels()); + GAPI_Assert(channels <= max_channels); + + auto* f = func_tbl[depth][channels - 1]; + for (int r = 0; r < rows; ++r) + { + (*f)(static_cast(ptr(r)), cols, s ); + } + } + else + { + auto* f = func_tbl[depth][0]; + // FIXME: better to refactor assign_row to use std::size_t by default + (*f)(static_cast(data), static_cast(total()), s); + } + return *this; + } + + /** @brief Returns the matrix element size in bytes. + + The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , + the method returns 3\*sizeof(short) or 6. + */ + size_t elemSize() const + { + return CV_ELEM_SIZE(type()); + } + /** @brief Returns the type of a matrix element. + + The method returns a matrix element type. This is an identifier compatible with the CvMat type + system, like CV_16SC3 or 16-bit signed 3-channel array, and so on. + */ + int type() const {return CV_MAT_TYPE(flags);} + + /** @brief Returns the depth of a matrix element. + + The method returns the identifier of the matrix element depth (the type of each individual channel). + For example, for a 16-bit signed element array, the method returns CV_16S . A complete list of + matrix types contains the following values: + - CV_8U - 8-bit unsigned integers ( 0..255 ) + - CV_8S - 8-bit signed integers ( -128..127 ) + - CV_16U - 16-bit unsigned integers ( 0..65535 ) + - CV_16S - 16-bit signed integers ( -32768..32767 ) + - CV_32S - 32-bit signed integers ( -2147483648..2147483647 ) + - CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN ) + - CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN ) + */ + int depth() const {return CV_MAT_DEPTH(flags);} + + /** @brief Returns the number of matrix channels. + + The method returns the number of matrix channels. + If matrix is N-dimensional, -1 is returned. + */ + int channels() const {return dims.empty() ? CV_MAT_CN(flags) : -1;} + + /** + @param _rows New number of rows. + @param _cols New number of columns. + @param _type New matrix type. + */ + void create(int _rows, int _cols, int _type) + { + create(Size{_cols, _rows}, _type); + } + /** @overload + @param _size Alternative new matrix size specification: Size(cols, rows) + @param _type New matrix type. + */ + void create(Size _size, int _type) + { + GAPI_Assert(_size.height >= 0 && _size.width >= 0); + if (_size != Size{cols, rows} ) + { + Mat tmp{_size.height, _size.width, _type, nullptr}; + tmp.memory.reset(new uchar[ tmp.step * tmp.rows], [](uchar * p){delete[] p;}); + tmp.data = tmp.memory.get(); + + *this = std::move(tmp); + } + } + + void create(const std::vector &_dims, int _type) + { + // FIXME: make a proper reallocation-on-demands + // WARNING: no tensor views, so no strides + Mat tmp{_dims, _type, nullptr}; + // FIXME: this accumulate duplicates a lot + const auto sz = std::accumulate(_dims.begin(), _dims.end(), 1, std::multiplies()); + tmp.memory.reset(new uchar[CV_ELEM_SIZE(_type)*sz], [](uchar * p){delete[] p;}); + tmp.data = tmp.memory.get(); + *this = std::move(tmp); + } + + /** @brief Creates a full copy of the matrix and the underlying data. + + The method creates a full copy of the matrix. The original step[] is not taken into account. + So, the copy has a continuous buffer occupying total() * elemSize() bytes. + */ + Mat clone() const + { + Mat m; + copyTo(m); + return m; + } + + /** @brief Copies the matrix to another one. + + The method copies the matrix data to another matrix. Before copying the data, the method invokes : + @code + m.create(this->size(), this->type()); + @endcode + so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the + function does not handle the case of a partial overlap between the source and the destination + matrices. + */ + void copyTo(Mat& dst) const + { + if (dims.empty()) + { + dst.create(rows, cols, type()); + for (int r = 0; r < rows; ++r) + { + std::copy_n(ptr(r), detail::default_step(type(),cols), dst.ptr(r)); + } + } + else + { + dst.create(dims, depth()); + std::copy_n(data, total()*elemSize(), data); + } + } + + /** @brief Returns true if the array has no elements. + + The method returns true if Mat::total() is 0 or if Mat::data is NULL. Because of pop_back() and + resize() methods `M.total() == 0` does not imply that `M.data == NULL`. + */ + bool empty() const + { + return data == 0 || total() == 0; + } + + /** @brief Returns the total number of array elements. + + The method returns the number of array elements (a number of pixels if the array represents an + image). + */ + size_t total() const + { + return dims.empty() + ? (static_cast(rows) * cols) + : std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies()); + } + + /** @overload + @param roi Extracted submatrix specified as a rectangle. + */ + Mat operator()( const Rect& roi ) const + { + return Mat{*this, roi}; + } + + + /** @brief Returns a pointer to the specified matrix row. + + The methods return `uchar*` or typed pointer to the specified matrix row. See the sample in + Mat::isContinuous to know how to use these methods. + @param row Index along the dimension 0 + @param col Index along the dimension 1 + */ + uchar* ptr(int row, int col = 0) + { + return const_cast(const_cast(this)->ptr(row,col)); + } + /** @overload */ + const uchar* ptr(int row, int col = 0) const + { + return data + step * row + CV_ELEM_SIZE(type()) * col; + } + + + private: + //actual memory allocated for storage, or nullptr if object is non owning view to over memory + std::shared_ptr memory; + }; + +} //namespace own +} //namespace gapi +} //namespace cv + +#endif /* OPENCV_GAPI_OWN_MAT_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/saturate.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/saturate.hpp new file mode 100644 index 0000000..74eaecf --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/saturate.hpp @@ -0,0 +1,83 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_OWN_SATURATE_HPP +#define OPENCV_GAPI_OWN_SATURATE_HPP + +#include + +#include + +#include +#include + +namespace cv { namespace gapi { namespace own { +//----------------------------- +// +// Numeric cast with saturation +// +//----------------------------- + +template::value && + std::is_integral::value && + std::is_integral::value> > +static CV_ALWAYS_INLINE DST saturate(SRC x) +{ + if (sizeof(DST) > sizeof(SRC)) + return static_cast(x); + + // compiler must recognize this saturation, + // so compile saturate(a + b) with adds + // instruction (e.g.: _mm_adds_epi16 if x86) + return x < std::numeric_limits::min()? + std::numeric_limits::min(): + x > std::numeric_limits::max()? + std::numeric_limits::max(): + static_cast(x); +} +template +static CV_ALWAYS_INLINE T saturate(T x) +{ + return x; +} + +template::value, bool> = true > +static CV_ALWAYS_INLINE DST saturate(SRC x, R) +{ + return static_cast(x); +} +template::value && + std::is_integral::value , bool> = true > +static CV_ALWAYS_INLINE DST saturate(SRC x, R) +{ + return saturate(x); +} +// Note, that OpenCV rounds differently: +// - like std::round() for add, subtract +// - like std::rint() for multiply, divide +template::value && + std::is_floating_point::value, bool> = true > +static CV_ALWAYS_INLINE DST saturate(SRC x, R round) +{ + int ix = static_cast(round(x)); + return saturate(ix); +} + +// explicit suffix 'd' for double type +inline double ceild(double x) { return ceil(x); } +inline double floord(double x) { return floor(x); } +inline double roundd(double x) { return round(x); } +inline double rintd(double x) { return rint(x); } + +} //namespace own +} //namespace gapi +} //namespace cv +#endif /* OPENCV_GAPI_OWN_SATURATE_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/scalar.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/scalar.hpp new file mode 100644 index 0000000..bda91c8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/scalar.hpp @@ -0,0 +1,47 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_GAPI_OWN_SCALAR_HPP +#define OPENCV_GAPI_GAPI_OWN_SCALAR_HPP + +#include + +namespace cv +{ +namespace gapi +{ +namespace own +{ + +class GAPI_EXPORTS Scalar +{ +public: + Scalar() = default; + explicit Scalar(double v0) { val[0] = v0; }; + Scalar(double v0, double v1, double v2 = 0, double v3 = 0) + : val{v0, v1, v2, v3} + { + } + + const double& operator[](int i) const { return val[i]; } + double& operator[](int i) { return val[i]; } + + static Scalar all(double v0) { return Scalar(v0, v0, v0, v0); } + + double val[4] = {0}; +}; + +inline bool operator==(const Scalar& lhs, const Scalar& rhs) +{ + return std::equal(std::begin(lhs.val), std::end(lhs.val), std::begin(rhs.val)); +} + +} // namespace own +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GAPI_OWN_SCALAR_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/types.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/types.hpp new file mode 100644 index 0000000..3814366 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/own/types.hpp @@ -0,0 +1,151 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_TYPES_HPP +#define OPENCV_GAPI_TYPES_HPP + +#include // std::max, std::min +#include + +namespace cv +{ +namespace gapi +{ + +/** + * @brief This namespace contains G-API own data structures used in + * its standalone mode build. + */ +namespace own +{ + +class Point +{ +public: + Point() = default; + Point(int _x, int _y) : x(_x), y(_y) {} + + int x = 0; + int y = 0; +}; + +class Point2f +{ +public: + Point2f() = default; + Point2f(float _x, float _y) : x(_x), y(_y) {} + + float x = 0.f; + float y = 0.f; +}; + +class Rect +{ +public: + Rect() = default; + Rect(int _x, int _y, int _width, int _height) : x(_x), y(_y), width(_width), height(_height) {} +#if !defined(GAPI_STANDALONE) + Rect(const cv::Rect& other) : x(other.x), y(other.y), width(other.width), height(other.height) {} + inline Rect& operator=(const cv::Rect& other) + { + x = other.x; + y = other.x; + width = other.width; + height = other.height; + return *this; + } +#endif // !defined(GAPI_STANDALONE) + + int x = 0; //!< x coordinate of the top-left corner + int y = 0; //!< y coordinate of the top-left corner + int width = 0; //!< width of the rectangle + int height = 0; //!< height of the rectangle +}; + +inline bool operator==(const Rect& lhs, const Rect& rhs) +{ + return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height; +} + +inline bool operator!=(const Rect& lhs, const Rect& rhs) +{ + return !(lhs == rhs); +} + +inline Rect& operator&=(Rect& lhs, const Rect& rhs) +{ + int x1 = std::max(lhs.x, rhs.x); + int y1 = std::max(lhs.y, rhs.y); + lhs.width = std::min(lhs.x + lhs.width, rhs.x + rhs.width) - x1; + lhs.height = std::min(lhs.y + lhs.height, rhs.y + rhs.height) - y1; + lhs.x = x1; + lhs.y = y1; + if( lhs.width <= 0 || lhs.height <= 0 ) + lhs = Rect(); + return lhs; +} + +inline const Rect operator&(const Rect& lhs, const Rect& rhs) +{ + Rect result = lhs; + return result &= rhs; +} + +inline std::ostream& operator<<(std::ostream& o, const Rect& rect) +{ + return o << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]"; +} + +class Size +{ +public: + Size() = default; + Size(int _width, int _height) : width(_width), height(_height) {} +#if !defined(GAPI_STANDALONE) + Size(const cv::Size& other) : width(other.width), height(other.height) {} + inline Size& operator=(const cv::Size& rhs) + { + width = rhs.width; + height = rhs.height; + return *this; + } +#endif // !defined(GAPI_STANDALONE) + + int width = 0; + int height = 0; +}; + +inline Size& operator+=(Size& lhs, const Size& rhs) +{ + lhs.width += rhs.width; + lhs.height += rhs.height; + return lhs; +} + +inline bool operator==(const Size& lhs, const Size& rhs) +{ + return lhs.width == rhs.width && lhs.height == rhs.height; +} + +inline bool operator!=(const Size& lhs, const Size& rhs) +{ + return !(lhs == rhs); +} + + +inline std::ostream& operator<<(std::ostream& o, const Size& s) +{ + o << "[" << s.width << " x " << s.height << "]"; + return o; +} + +struct VoidType {}; +} // namespace own +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_TYPES_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/core.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/core.hpp new file mode 100644 index 0000000..3c63fed --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/core.hpp @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + + +#ifndef OPENCV_GAPI_PLAIDML_CORE_HPP +#define OPENCV_GAPI_PLAIDML_CORE_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { namespace gapi { namespace core { namespace plaidml { + +GAPI_EXPORTS cv::gapi::GKernelPackage kernels(); + +}}}} + +#endif // OPENCV_GAPI_PLAIDML_CORE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/gplaidmlkernel.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/gplaidmlkernel.hpp new file mode 100644 index 0000000..e22ecc7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/gplaidmlkernel.hpp @@ -0,0 +1,140 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation +// + + +#ifndef OPENCV_GAPI_GPLAIDMLKERNEL_HPP +#define OPENCV_GAPI_GPLAIDMLKERNEL_HPP + +#include +#include + +namespace plaidml +{ +namespace edsl +{ + class Tensor; +} // namespace edsl +} // namespace plaidml + +namespace cv +{ +namespace gapi +{ +namespace plaidml +{ + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +} // namespace plaidml +} // namespace gapi + +struct GPlaidMLContext +{ + // Generic accessor API + template + const T& inArg(int input) { return m_args.at(input).get(); } + + // Syntax sugar + const plaidml::edsl::Tensor& inTensor(int input) + { + return inArg(input); + } + + plaidml::edsl::Tensor& outTensor(int output) + { + return *(m_results.at(output).get()); + } + + std::vector m_args; + std::unordered_map m_results; +}; + +class GAPI_EXPORTS GPlaidMLKernel +{ +public: + using F = std::function; + + GPlaidMLKernel() = default; + explicit GPlaidMLKernel(const F& f) : m_f(f) {} + + void apply(GPlaidMLContext &ctx) const + { + GAPI_Assert(m_f); + m_f(ctx); + } + +protected: + F m_f; +}; + + +namespace detail +{ + +template struct plaidml_get_in; +template<> struct plaidml_get_in +{ + static const plaidml::edsl::Tensor& get(GPlaidMLContext& ctx, int idx) + { + return ctx.inTensor(idx); + } +}; + +template struct plaidml_get_in +{ + static T get(GPlaidMLContext &ctx, int idx) { return ctx.inArg(idx); } +}; + +template struct plaidml_get_out; +template<> struct plaidml_get_out +{ + static plaidml::edsl::Tensor& get(GPlaidMLContext& ctx, int idx) + { + return ctx.outTensor(idx); + } +}; + +template +struct PlaidMLCallHelper; + +template +struct PlaidMLCallHelper, std::tuple > +{ + template + static void call_impl(GPlaidMLContext &ctx, detail::Seq, detail::Seq) + { + Impl::run(plaidml_get_in::get(ctx, IIs)..., plaidml_get_out::get(ctx, OIs)...); + } + + static void call(GPlaidMLContext& ctx) + { + call_impl(ctx, + typename detail::MkSeq::type(), + typename detail::MkSeq::type()); + } +}; + +} // namespace detail + +template +class GPlaidMLKernelImpl: public cv::detail::PlaidMLCallHelper, + public cv::detail::KernelTag +{ + using P = detail::PlaidMLCallHelper; + +public: + using API = K; + + static cv::gapi::GBackend backend() { return cv::gapi::plaidml::backend(); } + static cv::GPlaidMLKernel kernel() { return GPlaidMLKernel(&P::call); } +}; + +#define GAPI_PLAIDML_KERNEL(Name, API) struct Name: public cv::GPlaidMLKernelImpl + +} // namespace cv + +#endif // OPENCV_GAPI_GPLAIDMLKERNEL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/plaidml.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/plaidml.hpp new file mode 100644 index 0000000..3207a8c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/plaidml/plaidml.hpp @@ -0,0 +1,53 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + + +#ifndef OPENCV_GAPI_PLAIDML_PLAIDML_HPP +#define OPENCV_GAPI_PLAIDML_PLAIDML_HPP + +#include +#include // CompileArgTag + +namespace cv +{ +namespace gapi +{ + +/** + * @brief This namespace contains G-API PlaidML backend functions, + * structures, and symbols. + */ +namespace plaidml +{ + +/** \addtogroup gapi_compile_args + * @{ + */ +/** + * @brief This structure represents the basic parameters for the experimental + * PlaidML backend. + */ +struct config +{ + std::string dev_id; //!< Device ID. Refer to PlaidML documentation for details. + std::string trg_id; //!< Target ID. Refer to PlaidML documentation for details. +}; +/** @} gapi_compile_args */ + +} // namespace plaidml +} // namespace gapi + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.plaidml.config"; } + }; +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_PLAIDML_PLAIDML_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/python/python.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/python/python.hpp new file mode 100644 index 0000000..0e20bbb --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/python/python.hpp @@ -0,0 +1,67 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + + +#ifndef OPENCV_GAPI_PYTHON_API_HPP +#define OPENCV_GAPI_PYTHON_API_HPP + +#include // GKernelPackage +#include // GAPI_EXPORTS + +namespace cv { +namespace gapi { + +/** + * @brief This namespace contains G-API Python backend functions, + * structures, and symbols. + * + * This functionality is required to enable G-API custom operations + * and kernels when using G-API from Python, no need to use it in the + * C++ form. + */ +namespace python { + +GAPI_EXPORTS cv::gapi::GBackend backend(); + +struct GPythonContext +{ + const cv::GArgs &ins; + const cv::GMetaArgs &in_metas; + const cv::GTypesInfo &out_info; +}; + +using Impl = std::function; + +class GAPI_EXPORTS GPythonKernel +{ +public: + GPythonKernel() = default; + GPythonKernel(Impl run); + + cv::GRunArgs operator()(const GPythonContext& ctx); +private: + Impl m_run; +}; + +class GAPI_EXPORTS GPythonFunctor : public cv::gapi::GFunctor +{ +public: + using Meta = cv::GKernel::M; + + GPythonFunctor(const char* id, const Meta &meta, const Impl& impl); + + GKernelImpl impl() const override; + gapi::GBackend backend() const override; + +private: + GKernelImpl impl_; +}; + +} // namespace python +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_PYTHON_API_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render.hpp new file mode 100644 index 0000000..52e55b0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render.hpp @@ -0,0 +1,14 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_RENDER_ROOT_HPP +#define OPENCV_GAPI_RENDER_ROOT_HPP + +// This file is just a shortcut to render/render.hpp + +#include + +#endif // OPENCV_GAPI_RENDER_ROOT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render/render.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render/render.hpp new file mode 100644 index 0000000..5375412 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render/render.hpp @@ -0,0 +1,196 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2020 Intel Corporation + + +#ifndef OPENCV_GAPI_RENDER_HPP +#define OPENCV_GAPI_RENDER_HPP + +#include + +#include + +/** \defgroup gapi_draw G-API Drawing and composition functionality + * @{ + * + * @brief Functions for in-graph drawing. + * + * @note This is a Work in Progress functionality and APIs may + * change in the future releases. + * + * G-API can do some in-graph drawing with a generic operations and a + * set of [rendering primitives](@ref gapi_draw_prims). + * In contrast with traditional OpenCV, in G-API user need to form a + * *rendering list* of primitives to draw. This list can be built + * manually or generated within a graph. This list is passed to + * [special operations or functions](@ref gapi_draw_api) where all + * primitives are interpreted and applied to the image. + * + * For example, in a complex pipeline a list of detected objects + * can be translated in-graph to a list of cv::gapi::wip::draw::Rect + * primitives to highlight those with bounding boxes, or a list of + * detected faces can be translated in-graph to a list of + * cv::gapi::wip::draw::Mosaic primitives to hide sensitive content + * or protect privacy. + * + * Like any other operations, rendering in G-API can be reimplemented + * by different backends. Currently only an OpenCV-based backend is + * available. + * + * In addition to the graph-level operations, there are also regular + * (immediate) OpenCV-like functions are available -- see + * cv::gapi::wip::draw::render(). These functions are just wrappers + * over regular G-API and build the rendering graphs on the fly, so + * take compilation arguments as parameters. + * + * Currently this API is more machine-oriented than human-oriented. + * The main purpose is to translate a set of domain-specific objects + * to a list of primitives to draw. For example, in order to generate + * a picture like this: + * + * ![](modules/gapi/doc/pics/render_example.png) + * + * Rendering list needs to be generated as follows: + * + * @include modules/gapi/samples/draw_example.cpp + * + * @defgroup gapi_draw_prims Drawing primitives + * @defgroup gapi_draw_api Drawing operations and functions + * @} + */ + +namespace cv +{ +namespace gapi +{ +namespace wip +{ +namespace draw +{ + +using GMat2 = std::tuple; +using GMatDesc2 = std::tuple; + +//! @addtogroup gapi_draw_api +//! @{ +/** @brief The function renders on the input image passed drawing primitivies + +@param bgr input image: 8-bit unsigned 3-channel image @ref CV_8UC3. +@param prims vector of drawing primitivies +@param args graph compile time parameters +*/ +void GAPI_EXPORTS_W render(cv::Mat& bgr, + const Prims& prims, + cv::GCompileArgs&& args = {}); + +/** @brief The function renders on two NV12 planes passed drawing primitivies + +@param y_plane input image: 8-bit unsigned 1-channel image @ref CV_8UC1. +@param uv_plane input image: 8-bit unsigned 2-channel image @ref CV_8UC2. +@param prims vector of drawing primitivies +@param args graph compile time parameters +*/ +void GAPI_EXPORTS_W render(cv::Mat& y_plane, + cv::Mat& uv_plane, + const Prims& prims, + cv::GCompileArgs&& args = {}); + +/** @brief The function renders on the input media frame passed drawing primitivies + +@param frame input Media Frame : @ref cv::MediaFrame. +@param prims vector of drawing primitivies +@param args graph compile time parameters +*/ +void GAPI_EXPORTS render(cv::MediaFrame& frame, + const Prims& prims, + cv::GCompileArgs&& args = {}); + + +G_TYPED_KERNEL_M(GRenderNV12, )>, "org.opencv.render.nv12") +{ + static GMatDesc2 outMeta(GMatDesc y_plane, GMatDesc uv_plane, GArrayDesc) + { + return std::make_tuple(y_plane, uv_plane); + } +}; + +G_TYPED_KERNEL(GRenderBGR, )>, "org.opencv.render.bgr") +{ + static GMatDesc outMeta(GMatDesc bgr, GArrayDesc) + { + return bgr; + } +}; + +G_TYPED_KERNEL(GRenderFrame, )>, "org.opencv.render.frame") +{ + static GFrameDesc outMeta(GFrameDesc desc, GArrayDesc) + { + return desc; + } +}; + +/** @brief Renders on 3 channels input + +Output image must be 8-bit unsigned planar 3-channel image + +@param src input image: 8-bit unsigned 3-channel image @ref CV_8UC3 +@param prims draw primitives +*/ +GAPI_EXPORTS_W GMat render3ch(const GMat& src, const GArray& prims); + +/** @brief Renders on two planes + +Output y image must be 8-bit unsigned planar 1-channel image @ref CV_8UC1 +uv image must be 8-bit unsigned planar 2-channel image @ref CV_8UC2 + +@param y input image: 8-bit unsigned 1-channel image @ref CV_8UC1 +@param uv input image: 8-bit unsigned 2-channel image @ref CV_8UC2 +@param prims draw primitives +*/ +GAPI_EXPORTS_W GMat2 renderNV12(const GMat& y, + const GMat& uv, + const GArray& prims); + +/** @brief Renders Media Frame + +Output media frame frame cv::MediaFrame + +@param m_frame input image: cv::MediaFrame @ref cv::MediaFrame +@param prims draw primitives +*/ +GAPI_EXPORTS GFrame renderFrame(const GFrame& m_frame, + const GArray& prims); + +//! @} gapi_draw_api + +} // namespace draw +} // namespace wip + +/** + * @brief This namespace contains G-API CPU rendering backend functions, + * structures, and symbols. See @ref gapi_draw for details. + */ +namespace render +{ +namespace ocv +{ + GAPI_EXPORTS_W cv::gapi::GKernelPackage kernels(); + +} // namespace ocv +} // namespace render +} // namespace gapi + +namespace detail +{ + template<> struct CompileArgTag + { + static const char* tag() { return "gapi.freetype_font"; } + }; +} // namespace detail + +} // namespace cv + +#endif // OPENCV_GAPI_RENDER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render/render_types.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render/render_types.hpp new file mode 100644 index 0000000..6d70e3a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/render/render_types.hpp @@ -0,0 +1,359 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_RENDER_TYPES_HPP +#define OPENCV_GAPI_RENDER_TYPES_HPP + +#include +#include + +#include +#include +#include + +namespace cv +{ +namespace gapi +{ +namespace wip +{ +namespace draw +{ + +/** + * @brief This structure specifies which FreeType font to use by FText primitives. + */ +struct freetype_font +{ + /*@{*/ + std::string path; //!< The path to the font file (.ttf) + /*@{*/ +}; + +//! @addtogroup gapi_draw_prims +//! @{ +/** + * @brief This structure represents a text string to draw. + * + * Parameters match cv::putText(). + */ +struct GAPI_EXPORTS_W_SIMPLE Text +{ + /** + * @brief Text constructor + * + * @param text_ The text string to be drawn + * @param org_ The bottom-left corner of the text string in the image + * @param ff_ The font type, see #HersheyFonts + * @param fs_ The font scale factor that is multiplied by the font-specific base size + * @param color_ The text color + * @param thick_ The thickness of the lines used to draw a text + * @param lt_ The line type. See #LineTypes + * @param bottom_left_origin_ When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner + */ + GAPI_WRAP + Text(const std::string& text_, + const cv::Point& org_, + int ff_, + double fs_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + bool bottom_left_origin_ = false) : + text(text_), org(org_), ff(ff_), fs(fs_), + color(color_), thick(thick_), lt(lt_), bottom_left_origin(bottom_left_origin_) + { + } + + GAPI_WRAP + Text() = default; + + /*@{*/ + GAPI_PROP_RW std::string text; //!< The text string to be drawn + GAPI_PROP_RW cv::Point org; //!< The bottom-left corner of the text string in the image + GAPI_PROP_RW int ff; //!< The font type, see #HersheyFonts + GAPI_PROP_RW double fs; //!< The font scale factor that is multiplied by the font-specific base size + GAPI_PROP_RW cv::Scalar color; //!< The text color + GAPI_PROP_RW int thick; //!< The thickness of the lines used to draw a text + GAPI_PROP_RW int lt; //!< The line type. See #LineTypes + GAPI_PROP_RW bool bottom_left_origin; //!< When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner + /*@{*/ +}; + +/** + * @brief This structure represents a text string to draw using + * FreeType renderer. + * + * If OpenCV is built without FreeType support, this primitive will + * fail at the execution stage. + */ +struct FText +{ + /** + * @brief FText constructor + * + * @param text_ The text string to be drawn + * @param org_ The bottom-left corner of the text string in the image + * @param fh_ The height of text + * @param color_ The text color + */ + FText(const std::wstring& text_, + const cv::Point& org_, + int fh_, + const cv::Scalar& color_) : + text(text_), org(org_), fh(fh_), color(color_) + { + } + + FText() = default; + + /*@{*/ + std::wstring text; //!< The text string to be drawn + cv::Point org; //!< The bottom-left corner of the text string in the image + int fh; //!< The height of text + cv::Scalar color; //!< The text color + /*@{*/ +}; + +/** + * @brief This structure represents a rectangle to draw. + * + * Parameters match cv::rectangle(). + */ +struct GAPI_EXPORTS_W_SIMPLE Rect +{ + /** + * @brief Rect constructor + * + * @param rect_ Coordinates of the rectangle + * @param color_ The bottom-left corner of the text string in the image + * @param thick_ The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle + * @param lt_ The type of the line. See #LineTypes + * @param shift_ The number of fractional bits in the point coordinates + */ + Rect(const cv::Rect& rect_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + rect(rect_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Rect() = default; + + /*@{*/ + GAPI_PROP_RW cv::Rect rect; //!< Coordinates of the rectangle + GAPI_PROP_RW cv::Scalar color; //!< The rectangle color or brightness (grayscale image) + GAPI_PROP_RW int thick; //!< The thickness of lines that make up the rectangle. Negative values, like #FILLED, mean that the function has to draw a filled rectangle + GAPI_PROP_RW int lt; //!< The type of the line. See #LineTypes + GAPI_PROP_RW int shift; //!< The number of fractional bits in the point coordinates + /*@{*/ +}; + +/** + * @brief This structure represents a circle to draw. + * + * Parameters match cv::circle(). + */ +struct GAPI_EXPORTS_W_SIMPLE Circle +{ + /** + * @brief Circle constructor + * + * @param center_ The center of the circle + * @param radius_ The radius of the circle + * @param color_ The color of the circle + * @param thick_ The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn + * @param lt_ The Type of the circle boundary. See #LineTypes + * @param shift_ The Number of fractional bits in the coordinates of the center and in the radius value + */ + GAPI_WRAP + Circle(const cv::Point& center_, + int radius_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + center(center_), radius(radius_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Circle() = default; + + /*@{*/ + GAPI_PROP_RW cv::Point center; //!< The center of the circle + GAPI_PROP_RW int radius; //!< The radius of the circle + GAPI_PROP_RW cv::Scalar color; //!< The color of the circle + GAPI_PROP_RW int thick; //!< The thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn + GAPI_PROP_RW int lt; //!< The Type of the circle boundary. See #LineTypes + GAPI_PROP_RW int shift; //!< The Number of fractional bits in the coordinates of the center and in the radius value + /*@{*/ +}; + +/** + * @brief This structure represents a line to draw. + * + * Parameters match cv::line(). + */ +struct GAPI_EXPORTS_W_SIMPLE Line +{ + /** + * @brief Line constructor + * + * @param pt1_ The first point of the line segment + * @param pt2_ The second point of the line segment + * @param color_ The line color + * @param thick_ The thickness of line + * @param lt_ The Type of the line. See #LineTypes + * @param shift_ The number of fractional bits in the point coordinates + */ + GAPI_WRAP + Line(const cv::Point& pt1_, + const cv::Point& pt2_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + pt1(pt1_), pt2(pt2_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Line() = default; + + /*@{*/ + GAPI_PROP_RW cv::Point pt1; //!< The first point of the line segment + GAPI_PROP_RW cv::Point pt2; //!< The second point of the line segment + GAPI_PROP_RW cv::Scalar color; //!< The line color + GAPI_PROP_RW int thick; //!< The thickness of line + GAPI_PROP_RW int lt; //!< The Type of the line. See #LineTypes + GAPI_PROP_RW int shift; //!< The number of fractional bits in the point coordinates + /*@{*/ +}; + +/** + * @brief This structure represents a mosaicing operation. + * + * Mosaicing is a very basic method to obfuscate regions in the image. + */ +struct GAPI_EXPORTS_W_SIMPLE Mosaic +{ + /** + * @brief Mosaic constructor + * + * @param mos_ Coordinates of the mosaic + * @param cellSz_ Cell size (same for X, Y) + * @param decim_ Decimation (0 stands for no decimation) + */ + Mosaic(const cv::Rect& mos_, + int cellSz_, + int decim_) : + mos(mos_), cellSz(cellSz_), decim(decim_) + { + } + + GAPI_WRAP + Mosaic() : cellSz(0), decim(0) {} + + /*@{*/ + GAPI_PROP_RW cv::Rect mos; //!< Coordinates of the mosaic + GAPI_PROP_RW int cellSz; //!< Cell size (same for X, Y) + GAPI_PROP_RW int decim; //!< Decimation (0 stands for no decimation) + /*@{*/ +}; + +/** + * @brief This structure represents an image to draw. + * + * Image is blended on a frame using the specified mask. + */ +struct GAPI_EXPORTS_W_SIMPLE Image +{ + /** + * @brief Mosaic constructor + * + * @param org_ The bottom-left corner of the image + * @param img_ Image to draw + * @param alpha_ Alpha channel for image to draw (same size and number of channels) + */ + GAPI_WRAP + Image(const cv::Point& org_, + const cv::Mat& img_, + const cv::Mat& alpha_) : + org(org_), img(img_), alpha(alpha_) + { + } + + GAPI_WRAP + Image() = default; + + /*@{*/ + GAPI_PROP_RW cv::Point org; //!< The bottom-left corner of the image + GAPI_PROP_RW cv::Mat img; //!< Image to draw + GAPI_PROP_RW cv::Mat alpha; //!< Alpha channel for image to draw (same size and number of channels) + /*@{*/ +}; + +/** + * @brief This structure represents a polygon to draw. + */ +struct GAPI_EXPORTS_W_SIMPLE Poly +{ + /** + * @brief Mosaic constructor + * + * @param points_ Points to connect + * @param color_ The line color + * @param thick_ The thickness of line + * @param lt_ The Type of the line. See #LineTypes + * @param shift_ The number of fractional bits in the point coordinate + */ + GAPI_WRAP + Poly(const std::vector& points_, + const cv::Scalar& color_, + int thick_ = 1, + int lt_ = 8, + int shift_ = 0) : + points(points_), color(color_), thick(thick_), lt(lt_), shift(shift_) + { + } + + GAPI_WRAP + Poly() = default; + + /*@{*/ + GAPI_PROP_RW std::vector points; //!< Points to connect + GAPI_PROP_RW cv::Scalar color; //!< The line color + GAPI_PROP_RW int thick; //!< The thickness of line + GAPI_PROP_RW int lt; //!< The Type of the line. See #LineTypes + GAPI_PROP_RW int shift; //!< The number of fractional bits in the point coordinate + /*@{*/ +}; + +using Prim = util::variant + < Text + , FText + , Rect + , Circle + , Line + , Mosaic + , Image + , Poly + >; + +using Prims = std::vector; +//! @} gapi_draw_prims + +} // namespace draw +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_RENDER_TYPES_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/rmat.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/rmat.hpp new file mode 100644 index 0000000..38668d6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/rmat.hpp @@ -0,0 +1,160 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_RMAT_HPP +#define OPENCV_GAPI_RMAT_HPP + +#include +#include + +// Forward declaration +namespace cv { +namespace gapi { +namespace s11n { +struct IOStream; +struct IIStream; +} // namespace s11n +} // namespace gapi +} // namespace cv + +namespace cv { + +// "Remote Mat", a general class which provides an abstraction layer over the data +// storage and placement (host, remote device etc) and allows to access this data. +// +// The device specific implementation is hidden in the RMat::IAdapter class +// +// The basic flow is the following: +// * Backend which is aware of the remote device: +// - Implements own AdapterT class which is derived from RMat::IAdapter +// - Wraps device memory into RMat via make_rmat utility function: +// cv::RMat rmat = cv::make_rmat(args); +// +// * End user: +// - Writes the code which works with RMats without any knowledge of the remote device: +// void func(const cv::RMat& in_rmat, cv::RMat& out_rmat) { +// // Fetch input data from the device, get mapped memory for output +// cv::RMat::View in_view = in_rmat.access(Access::R); +// cv::RMat::View out_view = out_rmat.access(Access::W); +// performCalculations(in_view, out_view); +// // data from out_view is transferred to the device when out_view is destroyed +// } +/** \addtogroup gapi_data_structures + * @{ + */ +class GAPI_EXPORTS RMat +{ +public: + // A lightweight wrapper on image data: + // - Doesn't own the memory; + // - Doesn't implement copy semantics (it's assumed that a view is created each time + // wrapped data is being accessed); + // - Has an optional callback which is called when the view is destroyed. + class GAPI_EXPORTS View + { + public: + using DestroyCallback = std::function; + using stepsT = std::vector; + + View() = default; + View(const GMatDesc& desc, uchar* data, const stepsT& steps = {}, DestroyCallback&& cb = nullptr); + View(const GMatDesc& desc, uchar* data, size_t step, DestroyCallback&& cb = nullptr); + + View(const View&) = delete; + View& operator=(const View&) = delete; + View(View&&) = default; + View& operator=(View&& v); + ~View() { if (m_cb) m_cb(); } + + cv::Size size() const { return m_desc.size; } + const std::vector& dims() const { return m_desc.dims; } + int cols() const { return m_desc.size.width; } + int rows() const { return m_desc.size.height; } + int type() const; + int depth() const { return m_desc.depth; } + int chan() const { return m_desc.chan; } + size_t elemSize() const { return CV_ELEM_SIZE(type()); } + + template T* ptr(int y = 0) { + return reinterpret_cast(m_data + step()*y); + } + template const T* ptr(int y = 0) const { + return reinterpret_cast(m_data + step()*y); + } + template T* ptr(int y, int x) { + return reinterpret_cast(m_data + step()*y + step(1)*x); + } + template const T* ptr(int y, int x) const { + return reinterpret_cast(m_data + step()*y + step(1)*x); + } + size_t step(size_t i = 0) const { GAPI_DbgAssert(i; + + RMat() = default; + RMat(AdapterP&& a) : m_adapter(std::move(a)) {} + GMatDesc desc() const { return m_adapter->desc(); } + + // Note: When accessed for write there is no guarantee that returned view + // will contain actual snapshot of the mapped device memory + // (no guarantee that fetch from a device is performed). The only + // guaranty is that when the view is destroyed, its data will be + // transferred to the device + View access(Access a) const { return m_adapter->access(a); } + + // Cast underlying RMat adapter to the particular adapter type, + // return nullptr if underlying type is different + template T* get() const + { + static_assert(std::is_base_of::value, "T is not derived from IAdapter!"); + GAPI_Assert(m_adapter != nullptr); + return dynamic_cast(m_adapter.get()); + } + + void serialize(cv::gapi::s11n::IOStream& os) const { + m_adapter->serialize(os); + } + +private: + AdapterP m_adapter = nullptr; +}; + +template +RMat make_rmat(Ts&&... args) { return { std::make_shared(std::forward(args)...) }; } +/** @} */ + +} //namespace cv + +#endif /* OPENCV_GAPI_RMAT_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/s11n.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/s11n.hpp new file mode 100644 index 0000000..6863a5e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/s11n.hpp @@ -0,0 +1,505 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + +#ifndef OPENCV_GAPI_S11N_HPP +#define OPENCV_GAPI_S11N_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +// FIXME: caused by deserialize_runarg +#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER +#pragma warning(disable: 4702) +#endif + +namespace cv { +namespace gapi { + +/** +* \addtogroup gapi_serialization +* @{ +*/ + +namespace detail { + GAPI_EXPORTS cv::GComputation getGraph(const std::vector &bytes); + + GAPI_EXPORTS cv::GMetaArgs getMetaArgs(const std::vector &bytes); + + GAPI_EXPORTS cv::GRunArgs getRunArgs(const std::vector &bytes); + + GAPI_EXPORTS std::vector getVectorOfStrings(const std::vector &bytes); + + template + cv::GCompileArgs getCompileArgs(const std::vector &bytes); + + template + cv::GRunArgs getRunArgsWithAdapters(const std::vector &bytes); +} // namespace detail + +/** @brief Serialize a graph represented by GComputation into an array of bytes. + * + * Check different overloads for more examples. + * @param c GComputation to serialize. + * @return serialized vector of bytes. + */ +GAPI_EXPORTS std::vector serialize(const cv::GComputation &c); + +/** @overload + * @param ca GCompileArgs to serialize. + */ +GAPI_EXPORTS std::vector serialize(const cv::GCompileArgs& ca); + +/** @overload + * @param ma GMetaArgs to serialize. + */ +GAPI_EXPORTS std::vector serialize(const cv::GMetaArgs& ma); + +/** @overload + * @param ra GRunArgs to serialize. + */ +GAPI_EXPORTS std::vector serialize(const cv::GRunArgs& ra); + +/** @overload + * @param vs std::vector to serialize. + */ +GAPI_EXPORTS std::vector serialize(const std::vector& vs); + +/** + * @private + */ +template static inline +T deserialize(const std::vector &bytes); + +/** @brief Deserialize GComputation from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized GComputation object. + */ +template<> inline +cv::GComputation deserialize(const std::vector &bytes) { + return detail::getGraph(bytes); +} + +/** @brief Deserialize GMetaArgs from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized GMetaArgs object. + */ +template<> inline +cv::GMetaArgs deserialize(const std::vector &bytes) { + return detail::getMetaArgs(bytes); +} + +/** @brief Deserialize GRunArgs from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized GRunArgs object. + */ +template<> inline +cv::GRunArgs deserialize(const std::vector &bytes) { + return detail::getRunArgs(bytes); +} + +/** @brief Deserialize std::vector from a byte array. + * + * Check different overloads for more examples. + * @param bytes serialized vector of bytes. + * @return deserialized std::vector object. + */ +template<> inline +std::vector deserialize(const std::vector &bytes) { + return detail::getVectorOfStrings(bytes); +} + +/** + * @brief Deserialize GCompileArgs which types were specified in the template from a byte array. + * + * @note cv::gapi::s11n::detail::S11N template specialization must be provided to make a custom type + * in GCompileArgs deserializable. + * + * @param bytes vector of bytes to deserialize GCompileArgs object from. + * @return GCompileArgs object. + * @see GCompileArgs cv::gapi::s11n::detail::S11N + */ +template inline +typename std::enable_if::value, GCompileArgs>:: +type deserialize(const std::vector &bytes) { + return detail::getCompileArgs(bytes); +} + +/** + * @brief Deserialize GRunArgs including RMat and MediaFrame objects if any from a byte array. + * + * Adapter types are specified in the template. + * @note To be used properly specified adapter types must overload their deserialize() method. + * @param bytes vector of bytes to deserialize GRunArgs object from. + * @return GRunArgs including RMat and MediaFrame objects if any. + * @see RMat MediaFrame + */ +template inline +typename std::enable_if::value, GRunArgs>:: +type deserialize(const std::vector &bytes) { + return detail::getRunArgsWithAdapters(bytes); +} +} // namespace gapi +} // namespace cv + +namespace cv { +namespace gapi { +namespace s11n { + +/** @brief This structure is an interface for serialization routines. + * + * It's main purpose is to provide multiple overloads for operator<<() + * with basic C++ in addition to OpenCV/G-API types. + * + * This sctructure can be inherited and further extended with additional types. + * + * For example, it is utilized in cv::gapi::s11n::detail::S11N as input parameter + * in serialize() method. + */ +struct GAPI_EXPORTS IOStream { + virtual ~IOStream() = default; + // Define the native support for basic C++ types at the API level: + virtual IOStream& operator<< (bool) = 0; + virtual IOStream& operator<< (char) = 0; + virtual IOStream& operator<< (unsigned char) = 0; + virtual IOStream& operator<< (short) = 0; + virtual IOStream& operator<< (unsigned short) = 0; + virtual IOStream& operator<< (int) = 0; + virtual IOStream& operator<< (uint32_t) = 0; + virtual IOStream& operator<< (uint64_t) = 0; + virtual IOStream& operator<< (float) = 0; + virtual IOStream& operator<< (double) = 0; + virtual IOStream& operator<< (const std::string&) = 0; +}; + +/** @brief This structure is an interface for deserialization routines. + * + * It's main purpose is to provide multiple overloads for operator>>() + * with basic C++ in addition to OpenCV/G-API types. + * + * This structure can be inherited and further extended with additional types. + * + * For example, it is utilized in cv::gapi::s11n::detail::S11N as input parameter + * in deserialize() method. + */ +struct GAPI_EXPORTS IIStream { + virtual ~IIStream() = default; + virtual IIStream& operator>> (bool &) = 0; + virtual IIStream& operator>> (std::vector::reference) = 0; + virtual IIStream& operator>> (char &) = 0; + virtual IIStream& operator>> (unsigned char &) = 0; + virtual IIStream& operator>> (short &) = 0; + virtual IIStream& operator>> (unsigned short &) = 0; + virtual IIStream& operator>> (int &) = 0; + virtual IIStream& operator>> (float &) = 0; + virtual IIStream& operator>> (double &) = 0; + virtual IIStream& operator >> (uint32_t &) = 0; + virtual IIStream& operator >> (uint64_t &) = 0; + virtual IIStream& operator>> (std::string &) = 0; +}; + +namespace detail { +GAPI_EXPORTS std::unique_ptr getInStream(const std::vector &bytes); +} // namespace detail + +//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +// S11N operators +// Note: operators for basic types are defined in IIStream/IOStream + +// OpenCV types //////////////////////////////////////////////////////////////// + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point &pt); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point &pt); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Point2f &pt); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Point2f &pt); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Size &sz); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Size &sz); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Rect &rc); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Rect &rc); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Scalar &s); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Scalar &s); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::Mat &m); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::Mat &m); + +// FIXME: for GRunArgs serailization +#if !defined(GAPI_STANDALONE) +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::UMat & um); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::UMat & um); +#endif // !defined(GAPI_STANDALONE) + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::RMat &r); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::RMat &r); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::gapi::wip::IStreamSource::Ptr &issptr); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::gapi::wip::IStreamSource::Ptr &issptr); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::detail::VectorRef &vr); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::detail::VectorRef &vr); + +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::detail::OpaqueRef &opr); +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::detail::OpaqueRef &opr); + +/// @private -- Exclude this function from OpenCV documentation +GAPI_EXPORTS IOStream& operator<< (IOStream& os, const cv::MediaFrame &mf); +/// @private -- Exclude this function from OpenCV documentation +GAPI_EXPORTS IIStream& operator>> (IIStream& is, cv::MediaFrame &mf); + +// Generic STL types //////////////////////////////////////////////////////////////// +template +IOStream& operator<< (IOStream& os, const std::map &m) { + const uint32_t sz = static_cast(m.size()); + os << sz; + for (const auto& it : m) os << it.first << it.second; + return os; +} +template +IIStream& operator>> (IIStream& is, std::map &m) { + m.clear(); + uint32_t sz = 0u; + is >> sz; + for (std::size_t i = 0; i < sz; ++i) { + K k{}; + V v{}; + is >> k >> v; + m[k] = v; + } + return is; +} + +template +IOStream& operator<< (IOStream& os, const std::unordered_map &m) { + const uint32_t sz = static_cast(m.size()); + os << sz; + for (auto &&it : m) os << it.first << it.second; + return os; +} +template +IIStream& operator>> (IIStream& is, std::unordered_map &m) { + m.clear(); + uint32_t sz = 0u; + is >> sz; + for (std::size_t i = 0; i < sz; ++i) { + K k{}; + V v{}; + is >> k >> v; + m[k] = v; + } + return is; +} + +template +IOStream& operator<< (IOStream& os, const std::vector &ts) { + const uint32_t sz = static_cast(ts.size()); + os << sz; + for (auto &&v : ts) os << v; + return os; +} +template +IIStream& operator>> (IIStream& is, std::vector &ts) { + uint32_t sz = 0u; + is >> sz; + if (sz == 0u) { + ts.clear(); + } + else { + ts.resize(sz); + for (std::size_t i = 0; i < sz; ++i) is >> ts[i]; + } + return is; +} + +// Generic: variant serialization +namespace detail { +template +IOStream& put_v(IOStream&, const V&, std::size_t) { + GAPI_Assert(false && "variant>>: requested index is invalid"); +}; + +template +IOStream& put_v(IOStream& os, const V& v, std::size_t x) { + return (x == 0u) + ? os << cv::util::get(v) + : put_v(os, v, x-1); +} + +template +IIStream& get_v(IIStream&, V&, std::size_t, std::size_t) { + GAPI_Assert(false && "variant<<: requested index is invalid"); +} + +template +IIStream& get_v(IIStream& is, V& v, std::size_t i, std::size_t gi) { + if (i == gi) { + X x{}; + is >> x; + v = V{std::move(x)}; + return is; + } else return get_v(is, v, i+1, gi); +} +} // namespace detail + +//! @overload +template +IOStream& operator<< (IOStream& os, const cv::util::variant &v) { + os << static_cast(v.index()); + return detail::put_v, Ts...>(os, v, v.index()); +} +//! @overload +template +IIStream& operator>> (IIStream& is, cv::util::variant &v) { + int idx = -1; + is >> idx; + GAPI_Assert(idx >= 0 && idx < (int)sizeof...(Ts)); + return detail::get_v, Ts...>(is, v, 0u, idx); +} + +// FIXME: consider a better solution +/// @private -- Exclude this function from OpenCV documentation +template +void getRunArgByIdx (IIStream& is, cv::util::variant &v, uint32_t idx) { + is = detail::get_v, Ts...>(is, v, 0u, idx); +} +} // namespace s11n + +namespace detail +{ +template struct try_deserialize_comparg; + +template<> struct try_deserialize_comparg> { +static cv::util::optional exec(const std::string&, cv::gapi::s11n::IIStream&) { + return { }; + } +}; + +template +struct try_deserialize_comparg> { +static cv::util::optional exec(const std::string& tag, cv::gapi::s11n::IIStream& is) { + if (tag == cv::detail::CompileArgTag::tag()) { + static_assert(cv::gapi::s11n::detail::has_S11N_spec::value, + "cv::gapi::deserialize expects Types to have S11N " + "specializations with deserialization callbacks!"); + return cv::util::optional( + GCompileArg { cv::gapi::s11n::detail::S11N::deserialize(is) }); + } + return try_deserialize_comparg>::exec(tag, is); +} +}; + +template +struct deserialize_arg_with_adapter; + +template +struct deserialize_arg_with_adapter { +static GRunArg exec(cv::gapi::s11n::IIStream& is) { + std::unique_ptr ptr(new TA); + ptr->deserialize(is); + return GRunArg { RA(std::move(ptr)) }; +} +}; + +template +struct deserialize_arg_with_adapter { +static GRunArg exec(cv::gapi::s11n::IIStream&) { + GAPI_Assert(false && "No suitable adapter class found during RMat/MediaFrame deserialization. " + "Please, make sure you've passed them in cv::gapi::deserialize() template"); + return GRunArg{}; +} +}; + +template +struct deserialize_runarg { +static GRunArg exec(cv::gapi::s11n::IIStream& is, uint32_t idx) { + if (idx == GRunArg::index_of()) { + // Type or void (if not found) + using TA = typename cv::util::find_adapter_impl::type; + return deserialize_arg_with_adapter::exec(is); + } else if (idx == GRunArg::index_of()) { + // Type or void (if not found) + using TA = typename cv::util::find_adapter_impl::type; + return deserialize_arg_with_adapter::exec(is); + } else { // not an adapter holding type runarg - use default deserialization + GRunArg arg; + getRunArgByIdx(is, arg, idx); + return arg; + } +} +}; + +template +inline cv::util::optional tryDeserializeCompArg(const std::string& tag, + const std::vector& sArg) { + std::unique_ptr pArgIs = cv::gapi::s11n::detail::getInStream(sArg); + return try_deserialize_comparg>::exec(tag, *pArgIs); +} + +template +cv::GCompileArgs getCompileArgs(const std::vector &sArgs) { + cv::GCompileArgs args; + + std::unique_ptr pIs = cv::gapi::s11n::detail::getInStream(sArgs); + cv::gapi::s11n::IIStream& is = *pIs; + + uint32_t sz = 0; + is >> sz; + for (uint32_t i = 0; i < sz; ++i) { + std::string tag; + is >> tag; + + std::vector sArg; + is >> sArg; + + cv::util::optional dArg = + cv::gapi::detail::tryDeserializeCompArg(tag, sArg); + + if (dArg.has_value()) + { + args.push_back(dArg.value()); + } + } + + return args; +} + +template +cv::GRunArgs getRunArgsWithAdapters(const std::vector &bytes) { + std::unique_ptr pIs = cv::gapi::s11n::detail::getInStream(bytes); + cv::gapi::s11n::IIStream& is = *pIs; + cv::GRunArgs args; + + uint32_t sz = 0; + is >> sz; + for (uint32_t i = 0; i < sz; ++i) { + uint32_t idx = 0; + is >> idx; + args.push_back(cv::gapi::detail::deserialize_runarg::exec(is, idx)); + } + + return args; +} +} // namespace detail +/** @} */ + +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_S11N_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/s11n/base.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/s11n/base.hpp new file mode 100644 index 0000000..6cea941 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/s11n/base.hpp @@ -0,0 +1,80 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + +#ifndef OPENCV_GAPI_S11N_BASE_HPP +#define OPENCV_GAPI_S11N_BASE_HPP + +#include +#include + +namespace cv { +namespace gapi { + +/** + * @brief This namespace contains G-API serialization and + * deserialization functions and data structures. + */ +namespace s11n { +struct IOStream; +struct IIStream; + +namespace detail { + +//! @addtogroup gapi_serialization +//! @{ + +struct NotImplemented { +}; + +/** @brief This structure allows to implement serialization routines for custom types. + * + * The default S11N for custom types is not implemented. + * + * @note When providing an overloaded implementation for S11N with your type + * don't inherit it from NotImplemented structure. + * + * @note There are lots of overloaded >> and << operators for basic and OpenCV/G-API types + * which can be utilized when serializing a custom type. + * + * Example of usage: + * @snippet samples/cpp/tutorial_code/gapi/doc_snippets/api_ref_snippets.cpp S11N usage + * + */ +template +struct S11N: public NotImplemented { + /** + * @brief This function allows user to serialize their custom type. + * + * @note The default overload throws an exception if called. User need to + * properly overload the function to use it. + */ + static void serialize(IOStream &, const T &) { + GAPI_Assert(false && "No serialization routine is provided!"); + } + /** + * @brief This function allows user to deserialize their custom type. + * + * @note The default overload throws an exception if called. User need to + * properly overload the function to use it. + */ + static T deserialize(IIStream &) { + GAPI_Assert(false && "No deserialization routine is provided!"); + } +}; + +/// @private -- Exclude this struct from OpenCV documentation +template struct has_S11N_spec { + static constexpr bool value = !std::is_base_of::type>>::value; +}; +//! @} gapi_serialization + +} // namespace detail +} // namespace s11n +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_S11N_BASE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/stereo.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/stereo.hpp new file mode 100644 index 0000000..dcf8f4d --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/stereo.hpp @@ -0,0 +1,85 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distereoibution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STEREO_HPP +#define OPENCV_GAPI_STEREO_HPP + +#include +#include +#include + +namespace cv { +namespace gapi { + +/** + * The enum specified format of result that you get from @ref cv::gapi::stereo. + */ +enum class StereoOutputFormat { + DEPTH_FLOAT16, ///< Floating point 16 bit value, CV_16FC1. + ///< This identifier is deprecated, use DEPTH_16F instead. + DEPTH_FLOAT32, ///< Floating point 32 bit value, CV_32FC1 + ///< This identifier is deprecated, use DEPTH_16F instead. + DISPARITY_FIXED16_11_5, ///< 16 bit signed: first bit for sign, + ///< 10 bits for integer part, + ///< 5 bits for fractional part. + ///< This identifier is deprecated, + ///< use DISPARITY_16Q_10_5 instead. + DISPARITY_FIXED16_12_4, ///< 16 bit signed: first bit for sign, + ///< 11 bits for integer part, + ///< 4 bits for fractional part. + ///< This identifier is deprecated, + ///< use DISPARITY_16Q_11_4 instead. + DEPTH_16F = DEPTH_FLOAT16, ///< Same as DEPTH_FLOAT16 + DEPTH_32F = DEPTH_FLOAT32, ///< Same as DEPTH_FLOAT32 + DISPARITY_16Q_10_5 = DISPARITY_FIXED16_11_5, ///< Same as DISPARITY_FIXED16_11_5 + DISPARITY_16Q_11_4 = DISPARITY_FIXED16_12_4 ///< Same as DISPARITY_FIXED16_12_4 +}; + + +/** + * @brief This namespace contains G-API Operation Types for Stereo and + * related functionality. + */ +namespace calib3d { + +G_TYPED_KERNEL(GStereo, , "org.opencv.stereo") { + static GMatDesc outMeta(const GMatDesc &left, const GMatDesc &right, const StereoOutputFormat of) { + GAPI_Assert(left.chan == 1); + GAPI_Assert(left.depth == CV_8U); + + GAPI_Assert(right.chan == 1); + GAPI_Assert(right.depth == CV_8U); + + switch(of) { + case StereoOutputFormat::DEPTH_FLOAT16: + return left.withDepth(CV_16FC1); + case StereoOutputFormat::DEPTH_FLOAT32: + return left.withDepth(CV_32FC1); + case StereoOutputFormat::DISPARITY_FIXED16_11_5: + case StereoOutputFormat::DISPARITY_FIXED16_12_4: + return left.withDepth(CV_16SC1); + default: + GAPI_Assert(false && "Unknown output format!"); + } + } +}; + +} // namespace calib3d + +/** @brief Computes disparity/depth map for the specified stereo-pair. +The function computes disparity or depth map depending on passed StereoOutputFormat argument. + +@param left 8-bit single-channel left image of @ref CV_8UC1 type. +@param right 8-bit single-channel right image of @ref CV_8UC1 type. +@param of enum to specified output kind: depth or disparity and corresponding type +*/ +GAPI_EXPORTS GMat stereo(const GMat& left, + const GMat& right, + const StereoOutputFormat of = StereoOutputFormat::DEPTH_FLOAT32); +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STEREO_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/cap.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/cap.hpp new file mode 100644 index 0000000..aad6af6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/cap.hpp @@ -0,0 +1,126 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_CAP_HPP +#define OPENCV_GAPI_STREAMING_CAP_HPP + +/** + * YOUR ATTENTION PLEASE! + * + * This is a header-only implementation of cv::VideoCapture-based + * Stream source. It is not built by default with G-API as G-API + * doesn't depend on videoio module. + * + * If you want to use it in your application, please make sure + * videioio is available in your OpenCV package and is linked to your + * application. + * + * Note for developers: please don't put videoio dependency in G-API + * because of this file. + */ +#include + +#include +#include +#include + +namespace cv { +namespace gapi { +namespace wip { + +/** + * @brief OpenCV's VideoCapture-based streaming source. + * + * This class implements IStreamSource interface. + * Its constructor takes the same parameters as cv::VideoCapture does. + * + * Please make sure that videoio OpenCV module is available before using + * this in your application (G-API doesn't depend on it directly). + * + * @note stream sources are passed to G-API via shared pointers, so + * please gapi::make_src<> to create objects and ptr() to pass a + * GCaptureSource to cv::gin(). + */ +class GCaptureSource: public IStreamSource +{ +public: + explicit GCaptureSource(int id) : cap(id) { prep(); } + explicit GCaptureSource(const std::string &path) : cap(path) { prep(); } + + // TODO: Add more constructor overloads to make it + // fully compatible with VideoCapture's interface. + +protected: + cv::VideoCapture cap; + cv::Mat first; + bool first_pulled = false; + int64_t counter = 0; + + void prep() + { + // Prepare first frame to report its meta to engine + // when needed + GAPI_Assert(first.empty()); + cv::Mat tmp; + if (!cap.read(tmp)) + { + GAPI_Assert(false && "Couldn't grab the very first frame"); + } + // NOTE: Some decode/media VideoCapture backends continue + // owning the video buffer under cv::Mat so in order to + // process it safely in a highly concurrent pipeline, clone() + // is the only right way. + first = tmp.clone(); + } + + virtual bool pull(cv::gapi::wip::Data &data) override + { + if (!first_pulled) + { + GAPI_Assert(!first.empty()); + first_pulled = true; + data = first; // no need to clone here since it was cloned already + } + else + { + if (!cap.isOpened()) return false; + + cv::Mat frame; + if (!cap.read(frame)) + { + // end-of-stream happened + return false; + } + // Same reason to clone as in prep() + data = frame.clone(); + } + // Tag data with seq_id/ts + const auto now = std::chrono::system_clock::now(); + const auto dur = std::chrono::duration_cast + (now.time_since_epoch()); + data.meta[cv::gapi::streaming::meta_tag::timestamp] = int64_t{dur.count()}; + data.meta[cv::gapi::streaming::meta_tag::seq_id] = int64_t{counter++}; + return true; + } + + virtual GMetaArg descr_of() const override + { + GAPI_Assert(!first.empty()); + return cv::GMetaArg{cv::descr_of(first)}; + } +}; + +// NB: Overload for using from python +GAPI_EXPORTS_W cv::Ptr inline make_capture_src(const std::string& path) +{ + return make_src(path); +} + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_CAP_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/desync.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/desync.hpp new file mode 100644 index 0000000..1ed6e24 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/desync.hpp @@ -0,0 +1,85 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020-2021 Intel Corporation + + +#ifndef OPENCV_GAPI_GSTREAMING_DESYNC_HPP +#define OPENCV_GAPI_GSTREAMING_DESYNC_HPP + +#include + +#include +#include +#include +#include +#include + +namespace cv { +namespace gapi { +namespace streaming { + +namespace detail { +struct GDesync { + static const char *id() { + return "org.opencv.streaming.desync"; + } + + // An universal yield for desync. + // Yields output objects according to the input Types... + // Reuses gkernel machinery. + // FIXME: This function can be generic and declared in gkernel.hpp + // (it is there already, but a part of GKernelType[M] + template + static std::tuple yield(cv::GCall &call, cv::detail::Seq) { + return std::make_tuple(cv::detail::Yield::yield(call, IIs)...); + } +}; + +template +G desync(const G &g) { + cv::GKernel k{ + GDesync::id() // kernel id + , "" // kernel tag + , [](const GMetaArgs &a, const GArgs &) {return a;} // outMeta callback + , {cv::detail::GTypeTraits::shape} // output Shape + , {cv::detail::GTypeTraits::op_kind} // input data kinds + , {cv::detail::GObtainCtor::get()} // output template ctors + }; + cv::GCall call(std::move(k)); + call.pass(g); + return std::get<0>(GDesync::yield(call, cv::detail::MkSeq<1>::type())); +} +} // namespace detail + +/** + * @brief Starts a desynchronized branch in the graph. + * + * This operation takes a single G-API data object and returns a + * graph-level "duplicate" of this object. + * + * Operations which use this data object can be desynchronized + * from the rest of the graph. + * + * This operation has no effect when a GComputation is compiled with + * regular cv::GComputation::compile(), since cv::GCompiled objects + * always produce their full output vectors. + * + * This operation only makes sense when a GComputation is compiled in + * straming mode with cv::GComputation::compileStreaming(). If this + * operation is used and there are desynchronized outputs, the user + * should use a special version of cv::GStreamingCompiled::pull() + * which produces an array of cv::util::optional<> objects. + * + * @note This feature is highly experimental now and is currently + * limited to a single GMat/GFrame argument only. + */ +GAPI_EXPORTS GMat desync(const GMat &g); +GAPI_EXPORTS GFrame desync(const GFrame &f); + +} // namespace streaming +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GSTREAMING_DESYNC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/format.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/format.hpp new file mode 100644 index 0000000..f7c3bd4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/format.hpp @@ -0,0 +1,94 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_GSTREAMING_FORMAT_HPP +#define OPENCV_GAPI_GSTREAMING_FORMAT_HPP + +#include // GKernelPackage + +namespace cv { +namespace gapi { +namespace streaming { + +GAPI_EXPORTS cv::gapi::GKernelPackage kernels(); + +G_API_OP(GBGR, , "org.opencv.streaming.BGR") +{ + static GMatDesc outMeta(const GFrameDesc& in) { return GMatDesc{CV_8U, 3, in.size}; } +}; + +G_API_OP(GY, , "org.opencv.streaming.Y") { + static GMatDesc outMeta(const GFrameDesc& frameDesc) { + return GMatDesc { CV_8U, 1, frameDesc.size , false }; + } +}; + +G_API_OP(GUV, , "org.opencv.streaming.UV") { + static GMatDesc outMeta(const GFrameDesc& frameDesc) { + return GMatDesc { CV_8U, 2, cv::Size(frameDesc.size.width / 2, frameDesc.size.height / 2), + false }; + } +}; + +/** @brief Gets bgr plane from input frame + +@note Function textual ID is "org.opencv.streaming.BGR" + +@param in Input frame +@return Image in BGR format +*/ +GAPI_EXPORTS cv::GMat BGR(const cv::GFrame& in); + +/** @brief Extracts Y plane from media frame. + +Output image is 8-bit 1-channel image of @ref CV_8UC1. + +@note Function textual ID is "org.opencv.streaming.Y" + +@param frame input media frame. +*/ +GAPI_EXPORTS GMat Y(const cv::GFrame& frame); + +/** @brief Extracts UV plane from media frame. + +Output image is 8-bit 2-channel image of @ref CV_8UC2. + +@note Function textual ID is "org.opencv.streaming.UV" + +@param frame input media frame. +*/ +GAPI_EXPORTS GMat UV(const cv::GFrame& frame); +} // namespace streaming + +//! @addtogroup gapi_transform +//! @{ +/** @brief Makes a copy of the input image. Note that this copy may be not real +(no actual data copied). Use this function to maintain graph contracts, +e.g when graph's input needs to be passed directly to output, like in Streaming mode. + +@note Function textual ID is "org.opencv.streaming.copy" + +@param in Input image +@return Copy of the input +*/ +GAPI_EXPORTS_W GMat copy(const GMat& in); + +/** @brief Makes a copy of the input frame. Note that this copy may be not real +(no actual data copied). Use this function to maintain graph contracts, +e.g when graph's input needs to be passed directly to output, like in Streaming mode. + +@note Function textual ID is "org.opencv.streaming.copy" + +@param in Input frame +@return Copy of the input +*/ +GAPI_EXPORTS GFrame copy(const GFrame& in); +//! @} gapi_transform + +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GSTREAMING_FORMAT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp new file mode 100644 index 0000000..83afc99 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp @@ -0,0 +1,47 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP +#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP + +#include +#include + +#include +#include +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace gst { + +class GAPI_EXPORTS GStreamerPipeline +{ +public: + class Priv; + + explicit GStreamerPipeline(const std::string& pipeline); + IStreamSource::Ptr getStreamingSource(const std::string& appsinkName, + const GStreamerSource::OutputType outputType = + GStreamerSource::OutputType::MAT); + virtual ~GStreamerPipeline(); + +protected: + explicit GStreamerPipeline(std::unique_ptr priv); + + std::unique_ptr m_priv; +}; + +} // namespace gst + +using GStreamerPipeline = gst::GStreamerPipeline; + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERPIPELINE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamersource.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamersource.hpp new file mode 100644 index 0000000..b81bad3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/gstreamer/gstreamersource.hpp @@ -0,0 +1,89 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP +#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP + +#include +#include + +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace gst { + +/** + * @brief OpenCV's GStreamer streaming source. + * Streams cv::Mat-s/cv::MediaFrame from passed GStreamer pipeline. + * + * This class implements IStreamSource interface. + * + * To create GStreamerSource instance you need to pass 'pipeline' and, optionally, 'outputType' + * arguments into constructor. + * 'pipeline' should represent GStreamer pipeline in form of textual description. + * Almost any custom pipeline is supported which can be successfully ran via gst-launch. + * The only two limitations are: + * - there should be __one__ appsink element in the pipeline to pass data to OpenCV app. + * Pipeline can actually contain many sink elements, but it must have one and only one + * appsink among them. + * + * - data passed to appsink should be video-frame in NV12 format. + * + * 'outputType' is used to select type of output data to produce: 'cv::MediaFrame' or 'cv::Mat'. + * To produce 'cv::MediaFrame'-s you need to pass 'GStreamerSource::OutputType::FRAME' and, + * correspondingly, 'GStreamerSource::OutputType::MAT' to produce 'cv::Mat'-s. + * Please note, that in the last case, output 'cv::Mat' will be of BGR format, internal conversion + * from NV12 GStreamer data will happen. + * Default value for 'outputType' is 'GStreamerSource::OutputType::MAT'. + * + * @note Stream sources are passed to G-API via shared pointers, so please use gapi::make_src<> + * to create objects and ptr() to pass a GStreamerSource to cv::gin(). + * + * @note You need to build OpenCV with GStreamer support to use this class. + */ + +class GStreamerPipelineFacade; + +class GAPI_EXPORTS GStreamerSource : public IStreamSource +{ +public: + class Priv; + + // Indicates what type of data should be produced by GStreamerSource: cv::MediaFrame or cv::Mat + enum class OutputType { + FRAME, + MAT + }; + + GStreamerSource(const std::string& pipeline, + const GStreamerSource::OutputType outputType = + GStreamerSource::OutputType::MAT); + GStreamerSource(std::shared_ptr pipeline, + const std::string& appsinkName, + const GStreamerSource::OutputType outputType = + GStreamerSource::OutputType::MAT); + + bool pull(cv::gapi::wip::Data& data) override; + GMetaArg descr_of() const override; + ~GStreamerSource() override; + +protected: + explicit GStreamerSource(std::unique_ptr priv); + + std::unique_ptr m_priv; +}; + +} // namespace gst + +using GStreamerSource = gst::GStreamerSource; + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/meta.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/meta.hpp new file mode 100644 index 0000000..cbcfc3a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/meta.hpp @@ -0,0 +1,79 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_GSTREAMING_META_HPP +#define OPENCV_GAPI_GSTREAMING_META_HPP + +#include +#include +#include +#include + +namespace cv { +namespace gapi { +namespace streaming { + +// FIXME: the name is debatable +namespace meta_tag { +static constexpr const char * timestamp = "org.opencv.gapi.meta.timestamp"; +static constexpr const char * seq_id = "org.opencv.gapi.meta.seq_id"; +} // namespace meta_tag + +namespace detail { +struct GMeta { + static const char *id() { + return "org.opencv.streaming.meta"; + } + // A universal yield for meta(), same as in GDesync + template + static std::tuple yield(cv::GCall &call, cv::detail::Seq) { + return std::make_tuple(cv::detail::Yield::yield(call, IIs)...); + } + // Also a universal outMeta stub here + static GMetaArgs getOutMeta(const GMetaArgs &args, const GArgs &) { + return args; + } +}; +} // namespace detail + +template +cv::GOpaque meta(G g, const std::string &tag) { + using O = cv::GOpaque; + cv::GKernel k{ + detail::GMeta::id() // kernel id + , tag // kernel tag. Use meta tag here + , &detail::GMeta::getOutMeta // outMeta callback + , {cv::detail::GTypeTraits::shape} // output Shape + , {cv::detail::GTypeTraits::op_kind} // input data kinds + , {cv::detail::GObtainCtor::get()} // output template ctors + }; + cv::GCall call(std::move(k)); + call.pass(g); + return std::get<0>(detail::GMeta::yield(call, cv::detail::MkSeq<1>::type())); +} + +template +cv::GOpaque timestamp(G g) { + return meta(g, meta_tag::timestamp); +} + +template +cv::GOpaque seq_id(G g) { + return meta(g, meta_tag::seq_id); +} + +template +cv::GOpaque seqNo(G g) { + // Old name, compatibility only + return seq_id(g); +} + +} // namespace streaming +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_GSTREAMING_META_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp new file mode 100644 index 0000000..bfd9224 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/cfg_params.hpp @@ -0,0 +1,151 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP +#define OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP + +#include +#include +#include + +#include +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { + +/** + * @brief Public class is using for creation of onevpl::GSource instances. + * + * Class members availaible through methods @ref CfgParam::get_name() and @ref CfgParam::get_value() are used by + * onevpl::GSource inner logic to create or find oneVPL particular implementation + * (software/hardware, specific API version and etc.). + * + * @note Because oneVPL may provide several implementations which are satisfying with multiple (or single one) @ref CfgParam + * criteria therefore it is possible to configure `preferred` parameters. This kind of CfgParams are created + * using `is_major = false` argument in @ref CfgParam::create method and are not used by creating oneVPL particular implementations. + * Instead they fill out a "score table" to select preferrable implementation from available list. Implementation are satisfying + * with most of these optional params would be chosen. + * If no one optional CfgParam params were present then first of available oneVPL implementation would be applied. + * Please get on https://spec.oneapi.io/versions/latest/elements/oneVPL/source/API_ref/VPL_disp_api_func.html?highlight=mfxcreateconfig#mfxsetconfigfilterproperty + * for using OneVPL configuration. In this schema `mfxU8 *name` represents @ref CfgParam::get_name() and + * `mfxVariant value` is @ref CfgParam::get_value() + */ +struct GAPI_EXPORTS CfgParam { + using name_t = std::string; + using value_t = cv::util::variant; + /** + * @brief frames_pool_size_name + * + * Special configuration parameter name for onevp::GSource: + * + * @note frames_pool_size_name allows to allocate surfaces pool appropriate size to keep + * decoded frames in accelerator memory ready before + * they would be consumed by onevp::GSource::pull operation. If you see + * a lot of WARNING about lack of free surface then it's time to increase + * frames_pool_size_name but be aware of accelerator free memory volume. + * If not set then MFX implementation use + * mfxFrameAllocRequest::NumFrameSuggested behavior + * + */ + static constexpr const char *frames_pool_size_name() { return "frames_pool_size"; } + static CfgParam create_frames_pool_size(size_t value); + + /** + * @brief acceleration_mode_name + * + * Special configuration parameter names for onevp::GSource: + * + * @note acceleration_mode_name allows to activate hardware acceleration & + * device memory management. + * Supported values: + * - MFX_ACCEL_MODE_VIA_D3D11 Will activate DX11 acceleration and will produces + * MediaFrames with data allocated in DX11 device memory + * + * If not set then MFX implementation will use default acceleration behavior: + * all decoding operation uses default GPU resources but MediaFrame produces + * data allocated by using host RAM + * + */ + static constexpr const char *acceleration_mode_name() { return "mfxImplDescription.AccelerationMode"; } + static CfgParam create_acceleration_mode(uint32_t value); + static CfgParam create_acceleration_mode(const char* value); + + /** + * @brief decoder_id_name + * + * Special configuration parameter names for onevp::GSource: + * + * @note decoder_id_name allows to specify VPL decoder type which MUST present + * in case of RAW video input data and MUST NOT present as CfgParam if video + * stream incapsulated into container(*.mp4, *.mkv and so on). In latter case + * onevp::GSource will determine it automatically + * Supported values: + * - MFX_CODEC_AVC + * - MFX_CODEC_HEVC + * - MFX_CODEC_MPEG2 + * - MFX_CODEC_VC1 + * - MFX_CODEC_CAPTURE + * - MFX_CODEC_VP9 + * - MFX_CODEC_AV1 + * + */ + static constexpr const char *decoder_id_name() { return "mfxImplDescription.mfxDecoderDescription.decoder.CodecID"; } + static CfgParam create_decoder_id(uint32_t value); + static CfgParam create_decoder_id(const char* value); + + static constexpr const char *implementation_name() { return "mfxImplDescription.Impl"; } + static CfgParam create_implementation(uint32_t value); + static CfgParam create_implementation(const char* value); + + /** + * Create generic onevp::GSource configuration parameter. + * + *@param name name of parameter. + *@param value value of parameter. + *@param is_major TRUE if parameter MUST be provided by OneVPL inner implementation, FALSE for optional (for resolve multiple available implementations). + * + */ + template + static CfgParam create(const std::string& name, ValueType&& value, bool is_major = true) { + CfgParam param(name, CfgParam::value_t(std::forward(value)), is_major); + return param; + } + + struct Priv; + + const name_t& get_name() const; + const value_t& get_value() const; + bool is_major() const; + bool operator==(const CfgParam& rhs) const; + bool operator< (const CfgParam& rhs) const; + bool operator!=(const CfgParam& rhs) const; + + CfgParam& operator=(const CfgParam& src); + CfgParam& operator=(CfgParam&& src); + CfgParam(const CfgParam& src); + CfgParam(CfgParam&& src); + ~CfgParam(); +private: + CfgParam(const std::string& param_name, value_t&& param_value, bool is_major_param); + std::shared_ptr m_priv; +}; + +} //namespace onevpl +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_ONEVPL_CFG_PARAMS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/data_provider_interface.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/data_provider_interface.hpp new file mode 100644 index 0000000..c70e3db --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/data_provider_interface.hpp @@ -0,0 +1,105 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP +#define GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP +#include +#include +#include + +#include // GAPI_EXPORTS +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { + +struct GAPI_EXPORTS DataProviderException : public std::exception { + DataProviderException(const std::string& descr); + DataProviderException(std::string&& descr); + + virtual ~DataProviderException() = default; + virtual const char* what() const noexcept override; +private: + std::string reason; +}; + +struct GAPI_EXPORTS DataProviderSystemErrorException final : public DataProviderException { + DataProviderSystemErrorException(int error_code, const std::string& desription = std::string()); + ~DataProviderSystemErrorException() = default; +}; + +struct GAPI_EXPORTS DataProviderUnsupportedException final : public DataProviderException { + DataProviderUnsupportedException(const std::string& description); + ~DataProviderUnsupportedException() = default; +}; + +struct GAPI_EXPORTS DataProviderImplementationException : public DataProviderException { + DataProviderImplementationException(const std::string& description); + ~DataProviderImplementationException() = default; +}; +/** + * @brief Public interface allows to customize extraction of video stream data + * used by onevpl::GSource instead of reading stream from file (by default). + * + * Interface implementation constructor MUST provide consistency and creates fully operable object. + * If error happened implementation MUST throw `DataProviderException` kind exceptions + * + * @note Interface implementation MUST manage stream and other constructed resources by itself to avoid any kind of leak. + * For simple interface implementation example please see `StreamDataProvider` in `tests/streaming/gapi_streaming_tests.cpp` + */ +struct GAPI_EXPORTS IDataProvider { + using Ptr = std::shared_ptr; + using mfx_codec_id_type = uint32_t; + + /** + * NB: here is supposed to be forward declaration of mfxBitstream + * But according to current oneVPL implementation it is impossible to forward + * declare untagged struct mfxBitstream. + * + * IDataProvider makes sense only for HAVE_VPL is ON and to keep IDataProvider + * interface API/ABI compliant between core library and user application layer + * let's introduce wrapper mfx_bitstream which inherits mfxBitstream in private + * G-API code section and declare forward for wrapper mfx_bitstream here + */ + struct mfx_bitstream; + + virtual ~IDataProvider() = default; + + /** + * The function is used by onevpl::GSource to extract codec id from data + * + */ + virtual mfx_codec_id_type get_mfx_codec_id() const = 0; + + /** + * The function is used by onevpl::GSource to extract binary data stream from @ref IDataProvider + * implementation. + * + * It MUST throw `DataProviderException` kind exceptions in fail cases. + * It MUST return MFX_ERR_MORE_DATA in EOF which considered as not-fail case. + * + * @param in_out_bitsream the input-output reference on MFX bitstream buffer which MUST be empty at the first request + * to allow implementation to allocate it by itself and to return back. Subsequent invocation of `fetch_bitstream_data` + * MUST use the previously used in_out_bitsream to avoid skipping rest of frames which haven't been consumed + * @return true for fetched data, false on EOF and throws exception on error + */ + virtual bool fetch_bitstream_data(std::shared_ptr &in_out_bitsream) = 0; + + /** + * The function is used by onevpl::GSource to check more binary data availability. + * + * It MUST return TRUE in case of EOF and NO_THROW exceptions. + * + * @return boolean value which detects end of stream + */ + virtual bool empty() const = 0; +}; +} // namespace onevpl +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // GAPI_STREAMING_ONEVPL_ONEVPL_DATA_PROVIDER_INTERFACE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/device_selector_interface.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/device_selector_interface.hpp new file mode 100644 index 0000000..04f8cae --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/device_selector_interface.hpp @@ -0,0 +1,102 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP +#define GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP + +#include +#include +#include +#include + +#include "opencv2/gapi/own/exports.hpp" // GAPI_EXPORTS + +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { + +enum class AccelType: uint8_t { + HOST, + DX11, + + LAST_VALUE = std::numeric_limits::max() +}; + +GAPI_EXPORTS const char* to_cstring(AccelType type); + +struct IDeviceSelector; +struct GAPI_EXPORTS Device { + friend struct IDeviceSelector; + using Ptr = void*; + + ~Device(); + const std::string& get_name() const; + Ptr get_ptr() const; + AccelType get_type() const; +private: + Device(Ptr device_ptr, const std::string& device_name, + AccelType device_type); + + std::string name; + Ptr ptr; + AccelType type; +}; + +struct GAPI_EXPORTS Context { + friend struct IDeviceSelector; + using Ptr = void*; + + ~Context(); + Ptr get_ptr() const; + AccelType get_type() const; +private: + Context(Ptr ctx_ptr, AccelType ctx_type); + Ptr ptr; + AccelType type; +}; + +struct GAPI_EXPORTS IDeviceSelector { + using Ptr = std::shared_ptr; + + struct GAPI_EXPORTS Score { + friend struct IDeviceSelector; + using Type = int16_t; + static constexpr Type MaxActivePriority = std::numeric_limits::max(); + static constexpr Type MinActivePriority = 0; + static constexpr Type MaxPassivePriority = MinActivePriority - 1; + static constexpr Type MinPassivePriority = std::numeric_limits::min(); + + Score(Type val); + ~Score(); + + operator Type () const; + Type get() const; + friend bool operator< (Score lhs, Score rhs) { + return lhs.get() < rhs.get(); + } + private: + Type value; + }; + + using DeviceScoreTable = std::map; + using DeviceContexts = std::vector; + + virtual ~IDeviceSelector(); + virtual DeviceScoreTable select_devices() const = 0; + virtual DeviceContexts select_context() = 0; +protected: + template + static Entity create(Args &&...args) { + return Entity(std::forward(args)...); + } +}; +} // namespace onevpl +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // GAPI_STREAMING_ONEVPL_DEVICE_SELECTOR_INTERFACE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/source.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/source.hpp new file mode 100644 index 0000000..6334480 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/onevpl/source.hpp @@ -0,0 +1,90 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP +#define OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP + +#include +#include +#include +#include +#include +#include + +namespace cv { +namespace gapi { +namespace wip { +namespace onevpl { +using CfgParams = std::vector; + +/** + * @brief G-API streaming source based on OneVPL implementation. + * + * This class implements IStreamSource interface. + * Its constructor takes source file path (in usual way) or @ref onevpl::IDataProvider + * interface implementation (for not file-based sources). It also allows to pass-through + * oneVPL configuration parameters by using several @ref onevpl::CfgParam. + * + * @note stream sources are passed to G-API via shared pointers, so + * please gapi::make_onevpl_src<> to create objects and ptr() to pass a + * GSource to cv::gin(). + */ +class GAPI_EXPORTS GSource : public IStreamSource +{ +public: + struct Priv; + + GSource(const std::string& filePath, + const CfgParams& cfg_params = CfgParams{}); + + GSource(const std::string& filePath, + const CfgParams& cfg_params, + const std::string& device_id, + void* accel_device_ptr, + void* accel_ctx_ptr); + + GSource(const std::string& filePath, + const CfgParams& cfg_params, + std::shared_ptr selector); + + + GSource(std::shared_ptr source, + const CfgParams& cfg_params = CfgParams{}); + + GSource(std::shared_ptr source, + const CfgParams& cfg_params, + const std::string& device_id, + void* accel_device_ptr, + void* accel_ctx_ptr); + + GSource(std::shared_ptr source, + const CfgParams& cfg_params, + std::shared_ptr selector); + + ~GSource() override; + + bool pull(cv::gapi::wip::Data& data) override; + GMetaArg descr_of() const override; + +private: + explicit GSource(std::unique_ptr&& impl); + std::unique_ptr m_priv; +}; +} // namespace onevpl + +using GVPLSource = onevpl::GSource; + +template +GAPI_EXPORTS_W cv::Ptr inline make_onevpl_src(Args&&... args) +{ + return make_src(std::forward(args)...); +} + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_ONEVPL_ONEVPL_SOURCE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/source.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/source.hpp new file mode 100644 index 0000000..6597cad --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/source.hpp @@ -0,0 +1,62 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2019 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_SOURCE_HPP +#define OPENCV_GAPI_STREAMING_SOURCE_HPP + +#include // shared_ptr +#include // is_base_of + +#include // GMetaArg + + +namespace cv { +namespace gapi { +namespace wip { + struct Data; // "forward-declaration" of GRunArg + +/** + * @brief Abstract streaming pipeline source. + * + * Implement this interface if you want customize the way how data is + * streaming into GStreamingCompiled. + * + * Objects implementing this interface can be passed to + * GStreamingCompiled using setSource() with cv::gin(). Regular + * compiled graphs (GCompiled) don't support input objects of this + * type. + * + * Default cv::VideoCapture-based implementation is available, see + * cv::gapi::wip::GCaptureSource. + * + * @note stream sources are passed to G-API via shared pointers, so + * please use ptr() when passing a IStreamSource implementation to + * cv::gin(). + */ +class IStreamSource: public std::enable_shared_from_this +{ +public: + using Ptr = std::shared_ptr; + Ptr ptr() { return shared_from_this(); } + virtual bool pull(Data &data) = 0; + virtual GMetaArg descr_of() const = 0; + virtual ~IStreamSource() = default; +}; + +template +IStreamSource::Ptr inline make_src(Args&&... args) +{ + static_assert(std::is_base_of::value, + "T must implement the cv::gapi::IStreamSource interface!"); + auto src_ptr = std::make_shared(std::forward(args)...); + return src_ptr->ptr(); +} + +} // namespace wip +} // namespace gapi +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_SOURCE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/sync.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/sync.hpp new file mode 100644 index 0000000..5801e6f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/streaming/sync.hpp @@ -0,0 +1,30 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2021 Intel Corporation + +#ifndef OPENCV_GAPI_STREAMING_SYNC_HPP +#define OPENCV_GAPI_STREAMING_SYNC_HPP + +namespace cv { +namespace gapi { +namespace streaming { + +enum class sync_policy { + dont_sync, + drop +}; + +} // namespace streaming +} // namespace gapi + +namespace detail { + template<> struct CompileArgTag { + static const char* tag() { return "gapi.streaming.sync_policy"; } + }; + +} // namespace detail +} // namespace cv + +#endif // OPENCV_GAPI_STREAMING_SYNC_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/any.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/any.hpp new file mode 100644 index 0000000..94451c7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/any.hpp @@ -0,0 +1,190 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_ANY_HPP +#define OPENCV_GAPI_UTIL_ANY_HPP + +#include +#include +#include +#include + +#include + +#if defined(_MSC_VER) + // disable MSVC warning on "multiple copy constructors specified" +# pragma warning(disable: 4521) +#endif + +namespace cv +{ + +namespace internal +{ + template + T down_cast(Source operand) + { +#if defined(__GXX_RTTI) || defined(_CPPRTTI) + return dynamic_cast(operand); +#else +#ifdef __GNUC__ +#warning used static cast instead of dynamic because RTTI is disabled +#else +#pragma message("WARNING: used static cast instead of dynamic because RTTI is disabled") +#endif + return static_cast(operand); +#endif + } +} + +namespace util +{ + class bad_any_cast : public std::bad_cast + { + public: + virtual const char* what() const noexcept override + { + return "Bad any cast"; + } + }; + + //modeled against C++17 std::any + + class any + { + private: + struct holder; + using holder_ptr = std::unique_ptr; + struct holder + { + virtual holder_ptr clone() = 0; + virtual ~holder() = default; + }; + + template + struct holder_impl : holder + { + value_t v; + template + holder_impl(arg_t&& a) : v(std::forward(a)) {} + holder_ptr clone() override { return holder_ptr(new holder_impl (v));} + }; + + holder_ptr hldr; + public: + template + any(value_t&& arg) : hldr(new holder_impl::type>( std::forward(arg))) {} + + any(any const& src) : hldr( src.hldr ? src.hldr->clone() : nullptr) {} + //simple hack in order not to write enable_if for the template constructor + any(any & src) : any (const_cast(src)) {} + + any() = default; + any(any&& ) = default; + + any& operator=(any&&) = default; + + any& operator=(any const& src) + { + any copy(src); + swap(*this, copy); + return *this; + } + + template + friend value_t* any_cast(any* operand); + + template + friend const value_t* any_cast(const any* operand); + + template + friend value_t& unsafe_any_cast(any& operand); + + template + friend const value_t& unsafe_any_cast(const any& operand); + + friend void swap(any & lhs, any& rhs) + { + swap(lhs.hldr, rhs.hldr); + } + + }; + + template + value_t* any_cast(any* operand) + { + auto casted = internal::down_cast::type> *>(operand->hldr.get()); + if (casted){ + return & (casted->v); + } + return nullptr; + } + + template + const value_t* any_cast(const any* operand) + { + auto casted = internal::down_cast::type> *>(operand->hldr.get()); + if (casted){ + return & (casted->v); + } + return nullptr; + } + + template + value_t& any_cast(any& operand) + { + auto ptr = any_cast(&operand); + if (ptr) + { + return *ptr; + } + + throw_error(bad_any_cast()); + } + + + template + const value_t& any_cast(const any& operand) + { + auto ptr = any_cast(&operand); + if (ptr) + { + return *ptr; + } + + throw_error(bad_any_cast()); + } + + template + inline value_t& unsafe_any_cast(any& operand) + { +#ifdef DEBUG + return any_cast(operand); +#else + return static_cast::type> *>(operand.hldr.get())->v; +#endif + } + + template + inline const value_t& unsafe_any_cast(const any& operand) + { +#ifdef DEBUG + return any_cast(operand); +#else + return static_cast::type> *>(operand.hldr.get())->v; +#endif + } + +} // namespace util +} // namespace cv + +#if defined(_MSC_VER) + // Enable "multiple copy constructors specified" back +# pragma warning(default: 4521) +#endif + +#endif // OPENCV_GAPI_UTIL_ANY_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/compiler_hints.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/compiler_hints.hpp new file mode 100644 index 0000000..a41a971 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/compiler_hints.hpp @@ -0,0 +1,19 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + +#ifndef OPENCV_GAPI_UTIL_COMPILER_HINTS_HPP +#define OPENCV_GAPI_UTIL_COMPILER_HINTS_HPP + +namespace cv +{ +namespace util +{ + //! Utility template function to prevent "unused" warnings by various compilers. + template void suppress_unused_warning( const T& ) {} +} // namespace util +} // namespace cv + +#endif /* OPENCV_GAPI_UTIL_COMPILER_HINTS_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/copy_through_move.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/copy_through_move.hpp new file mode 100644 index 0000000..1a1121e --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/copy_through_move.hpp @@ -0,0 +1,34 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_UTIL_COPY_THROUGH_MOVE_HPP +#define OPENCV_GAPI_UTIL_COPY_THROUGH_MOVE_HPP + +#include //decay_t + +namespace cv +{ +namespace util +{ + //This is a tool to move initialize captures of a lambda in C++11 + template + struct copy_through_move_t{ + T value; + const T& get() const {return value;} + T& get() {return value;} + copy_through_move_t(T&& g) : value(std::move(g)) {} + copy_through_move_t(copy_through_move_t&&) = default; + copy_through_move_t(copy_through_move_t const& lhs) : copy_through_move_t(std::move(const_cast(lhs))) {} + }; + + template + copy_through_move_t> copy_through_move(T&& t){ + return std::forward(t); + } +} // namespace util +} // namespace cv + +#endif /* OPENCV_GAPI_UTIL_COPY_THROUGH_MOVE_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/optional.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/optional.hpp new file mode 100644 index 0000000..dca03ca --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/optional.hpp @@ -0,0 +1,178 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_OPTIONAL_HPP +#define OPENCV_GAPI_UTIL_OPTIONAL_HPP + +#include + +// A poor man's `optional` implementation, incompletely modeled against C++17 spec. +namespace cv +{ +namespace util +{ + class bad_optional_access: public std::exception + { + public: + virtual const char *what() const noexcept override + { + return "Bad optional access"; + } + }; + + // TODO: nullopt_t + + // Interface /////////////////////////////////////////////////////////////// + template class optional + { + public: + // Constructors + // NB.: there were issues with Clang 3.8 when =default() was used + // instead {} + optional() {} + optional(const optional&) = default; + explicit optional(T&&) noexcept; + explicit optional(const T&) noexcept; + optional(optional&&) noexcept; + // TODO: optional(nullopt_t) noexcept; + // TODO: optional(const optional &) + // TODO: optional(optional &&) + // TODO: optional(Args&&...) + // TODO: optional(initializer_list) + // TODO: optional(U&& value); + + // Assignment + optional& operator=(const optional&) = default; + optional& operator=(optional&&); + + // Observers + T* operator-> (); + const T* operator-> () const; + T& operator* (); + const T& operator* () const; + // TODO: && versions + + operator bool() const noexcept; + bool has_value() const noexcept; + + T& value(); + const T& value() const; + // TODO: && versions + + template + T value_or(U &&default_value) const; + + void swap(optional &other) noexcept; + void reset() noexcept; + // TODO: emplace + + // TODO: operator==, !=, <, <=, >, >= + + private: + struct nothing {}; + util::variant m_holder; + }; + + template + optional::type> make_optional(T&& value); + + // TODO: Args... and initializer_list versions + + // Implementation ////////////////////////////////////////////////////////// + template optional::optional(T &&v) noexcept + : m_holder(std::move(v)) + { + } + + template optional::optional(const T &v) noexcept + : m_holder(v) + { + } + + template optional::optional(optional&& rhs) noexcept + : m_holder(std::move(rhs.m_holder)) + { + rhs.reset(); + } + + template optional& optional::operator=(optional&& rhs) + { + m_holder = std::move(rhs.m_holder); + rhs.reset(); + return *this; + } + + template T* optional::operator-> () + { + return & *(*this); + } + + template const T* optional::operator-> () const + { + return & *(*this); + } + + template T& optional::operator* () + { + return this->value(); + } + + template const T& optional::operator* () const + { + return this->value(); + } + + template optional::operator bool() const noexcept + { + return this->has_value(); + } + + template bool optional::has_value() const noexcept + { + return util::holds_alternative(m_holder); + } + + template T& optional::value() + { + if (!this->has_value()) + throw_error(bad_optional_access()); + return util::get(m_holder); + } + + template const T& optional::value() const + { + if (!this->has_value()) + throw_error(bad_optional_access()); + return util::get(m_holder); + } + + template + template T optional::value_or(U &&default_value) const + { + return (this->has_value() ? this->value() : T(default_value)); + } + + template void optional::swap(optional &other) noexcept + { + m_holder.swap(other.m_holder); + } + + template void optional::reset() noexcept + { + if (this->has_value()) + m_holder = nothing{}; + } + + template + optional::type> make_optional(T&& value) + { + return optional::type>(std::forward(value)); + } +} // namespace util +} // namespace cv + +#endif // OPENCV_GAPI_UTIL_OPTIONAL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/throw.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/throw.hpp new file mode 100644 index 0000000..689bf58 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/throw.hpp @@ -0,0 +1,36 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_THROW_HPP +#define OPENCV_GAPI_UTIL_THROW_HPP + +#include // std::forward + +#if !defined(__EXCEPTIONS) +#include +#include +#endif + +namespace cv +{ +namespace util +{ +template +[[noreturn]] void throw_error(ExceptionType &&e) +{ +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) + throw std::forward(e); +#else + fprintf(stderr, "An exception thrown! %s\n" , e.what()); + fflush(stderr); + abort(); +#endif +} +} // namespace util +} // namespace cv + +#endif // OPENCV_GAPI_UTIL_THROW_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/type_traits.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/type_traits.hpp new file mode 100644 index 0000000..637f184 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/type_traits.hpp @@ -0,0 +1,31 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_TYPE_TRAITS_HPP +#define OPENCV_GAPI_UTIL_TYPE_TRAITS_HPP + +#include + +namespace cv +{ +namespace util +{ + //these are C++14 parts of type_traits : + template< bool B, class T = void > + using enable_if_t = typename std::enable_if::type; + + template + using decay_t = typename std::decay::type; + + //this is not part of C++14 but still, of pretty common usage + template + using are_different_t = enable_if_t< !std::is_same, decay_t>::value, V>; + +} // namespace cv +} // namespace util + +#endif // OPENCV_GAPI_UTIL_TYPE_TRAITS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/util.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/util.hpp new file mode 100644 index 0000000..3be46d7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/util.hpp @@ -0,0 +1,190 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018-2019 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_HPP +#define OPENCV_GAPI_UTIL_HPP + +#include + +// \cond HIDDEN_SYMBOLS +// This header file contains some generic utility functions which are +// used in other G-API Public API headers. +// +// PLEASE don't put any stuff here if it is NOT used in public API headers! + +namespace cv +{ +namespace detail +{ + // Recursive integer sequence type, useful for enumerating elements of + // template parameter packs. + template struct Seq { using next = Seq; }; + template struct MkSeq { using type = typename MkSeq::type::next; }; + template<> struct MkSeq<0>{ using type = Seq<>; }; + + // Checks if elements of variadic template satisfy the given Predicate. + // Implemented via tuple, with an interface to accept plain type lists + template class, typename, typename...> struct all_satisfy; + + template class F, typename T, typename... Ts> + struct all_satisfy > + { + static const constexpr bool value = F::value + && all_satisfy >::value; + }; + template class F, typename T> + struct all_satisfy > + { + static const constexpr bool value = F::value; + }; + + template class F, typename T, typename... Ts> + struct all_satisfy: public all_satisfy > {}; + + // Permute given tuple type C with given integer sequence II + // Sequence may be less than tuple C size. + template struct permute_tuple; + + template + struct permute_tuple > + { + using type = std::tuple< typename std::tuple_element::type... >; + }; + + // Given T..., generates a type sequence of sizeof...(T)-1 elements + // which is T... without its last element + // Implemented via tuple, with an interface to accept plain type lists + template struct all_but_last; + + template + struct all_but_last > + { + using C = std::tuple; + using S = typename MkSeq::value - 1>::type; + using type = typename permute_tuple::type; + }; + + template + struct all_but_last: public all_but_last > {}; + + template + using all_but_last_t = typename all_but_last::type; + + // NB.: This is here because there's no constexpr std::max in C++11 + template struct max_of_t + { + static constexpr const std::size_t rest = max_of_t::value; + static constexpr const std::size_t value = rest > S0 ? rest : S0; + }; + template struct max_of_t + { + static constexpr const std::size_t value = S; + }; + + template + struct contains : std::false_type{}; + + template + struct contains : std::integral_constant::value || + contains::value> {}; + template + struct contains> : std::integral_constant::value> {}; + + template + struct all_unique : std::true_type{}; + + template + struct all_unique : std::integral_constant::value && + all_unique::value> {}; + + template + struct tuple_wrap_helper; + + template struct tuple_wrap_helper + { + using type = std::tuple; + static type get(T&& obj) { return std::make_tuple(std::move(obj)); } + }; + + template + struct tuple_wrap_helper> + { + using type = std::tuple; + static type get(std::tuple&& objs) { return std::forward>(objs); } + }; + + template + struct make_void { typedef void type;}; + + template + using void_t = typename make_void::type; + +} // namespace detail + +namespace util +{ +template +struct overload_lamba_set; + +template +struct overload_lamba_set : public L1 +{ + overload_lamba_set(L1&& lambda) : L1(std::move(lambda)) {} + overload_lamba_set(const L1& lambda) : L1(lambda) {} + + using L1::operator(); +}; + +template +struct overload_lamba_set : public L1, public overload_lamba_set +{ + using base_type = overload_lamba_set; + overload_lamba_set(L1 &&lambda1, L&& ...lambdas): + L1(std::move(lambda1)), + base_type(std::forward(lambdas)...) {} + + overload_lamba_set(const L1 &lambda1, L&& ...lambdas): + L1(lambda1), + base_type(std::forward(lambdas)...) {} + + using L1::operator(); + using base_type::operator(); +}; + +template +overload_lamba_set overload_lambdas(L&& ...lambdas) +{ + return overload_lamba_set(std::forward(lambdas)...); +} + +template +struct find_adapter_impl; + +template +struct find_adapter_impl +{ + using type = typename std::conditional::value, + T, + void>::type; + static constexpr bool found = std::is_base_of::value; +}; + +template +struct find_adapter_impl +{ + using type = typename std::conditional::value, + T, + typename find_adapter_impl::type>::type; + static constexpr bool found = std::is_base_of::value || + find_adapter_impl::found; +}; +} // namespace util +} // namespace cv + +// \endcond + +#endif // OPENCV_GAPI_UTIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/variant.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/variant.hpp new file mode 100644 index 0000000..f412110 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/util/variant.hpp @@ -0,0 +1,658 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2018 Intel Corporation + + +#ifndef OPENCV_GAPI_UTIL_VARIANT_HPP +#define OPENCV_GAPI_UTIL_VARIANT_HPP + +#include +#include + +#include +#include +#include // max_of_t +#include + +// A poor man's `variant` implementation, incompletely modeled against C++17 spec. +namespace cv +{ +namespace util +{ + namespace detail + { + template + struct type_list_index_helper + { + static const constexpr bool is_same = std::is_same::value; + static const constexpr std::size_t value = + std::conditional, type_list_index_helper>::type::value; + }; + + template + struct type_list_index_helper + { + static_assert(std::is_same::value, "Type not found"); + static const constexpr std::size_t value = I; + }; + } + + template + struct type_list_index + { + static const constexpr std::size_t value = detail::type_list_index_helper<0, Target, Types...>::value; + }; + + template + struct type_list_element + { + using type = typename std::tuple_element >::type; + }; + + class bad_variant_access: public std::exception + { + public: + virtual const char *what() const noexcept override + { + return "Bad variant access"; + } + }; + + // Interface /////////////////////////////////////////////////////////////// + struct monostate {}; + inline bool operator==(const util::monostate&, const util::monostate&) + { + return true; + } + + template // FIXME: no references, arrays, and void + class variant + { + // FIXME: Replace with std::aligned_union after gcc4.8 support is dropped + static constexpr const std::size_t S = cv::detail::max_of_t::value; + static constexpr const std::size_t A = cv::detail::max_of_t::value; + using Memory = typename std::aligned_storage::type[1]; + + template struct cctr_h { + static void help(Memory memory, const Memory from) { + new (memory) T(*reinterpret_cast(from)); + } + }; + + template struct mctr_h { + static void help(Memory memory, void *pval) { + new (memory) T(std::move(*reinterpret_cast(pval))); + } + }; + + //FIXME: unify with cctr_h and mctr_h + template struct cnvrt_ctor_h { + static void help(Memory memory, void* from) { + using util::decay_t; + new (memory) decay_t(std::forward(*reinterpret_cast*>(from))); + } + }; + + template struct copy_h { + static void help(Memory to, const Memory from) { + *reinterpret_cast(to) = *reinterpret_cast(from); + } + }; + + template struct move_h { + static void help(Memory to, Memory from) { + *reinterpret_cast(to) = std::move(*reinterpret_cast(from)); + } + }; + + //FIXME: unify with copy_h and move_h + template struct cnvrt_assign_h { + static void help(Memory to, void* from) { + using util::decay_t; + *reinterpret_cast*>(to) = std::forward(*reinterpret_cast*>(from)); + } + }; + + template struct swap_h { + static void help(Memory to, Memory from) { + std::swap(*reinterpret_cast(to), *reinterpret_cast(from)); + } + }; + + template struct dtor_h { + static void help(Memory memory) { + (void) memory; // MSCV warning + reinterpret_cast(memory)->~T(); + } + }; + + template struct equal_h { + static bool help(const Memory lhs, const Memory rhs) { + const T& t_lhs = *reinterpret_cast(lhs); + const T& t_rhs = *reinterpret_cast(rhs); + return t_lhs == t_rhs; + } + }; + + typedef void (*CCtr) (Memory, const Memory); // Copy c-tor (variant) + typedef void (*MCtr) (Memory, void*); // Generic move c-tor + typedef void (*Copy) (Memory, const Memory); // Copy assignment + typedef void (*Move) (Memory, Memory); // Move assignment + + typedef void (*Swap) (Memory, Memory); // Swap + typedef void (*Dtor) (Memory); // Destructor + + using cnvrt_assgn_t = void (*) (Memory, void*); // Converting assignment (via std::forward) + using cnvrt_ctor_t = void (*) (Memory, void*); // Converting constructor (via std::forward) + + typedef bool (*Equal)(const Memory, const Memory); // Equality test (external) + + static constexpr std::array cctrs(){ return {{(&cctr_h::help)...}};} + static constexpr std::array mctrs(){ return {{(&mctr_h::help)...}};} + static constexpr std::array cpyrs(){ return {{(©_h::help)...}};} + static constexpr std::array mvers(){ return {{(&move_h::help)...}};} + static constexpr std::array swprs(){ return {{(&swap_h::help)...}};} + static constexpr std::array dtors(){ return {{(&dtor_h::help)...}};} + + template + struct conditional_ref : std::conditional::type&, typename std::remove_reference::type > {}; + + template + using conditional_ref_t = typename conditional_ref::type; + + + template + static constexpr std::array cnvrt_assgnrs(){ + return {{(&cnvrt_assign_h>::help)...}}; + } + + template + static constexpr std::array cnvrt_ctors(){ + return {{(&cnvrt_ctor_h>::help)...}}; + } + + std::size_t m_index = 0; + + protected: + template friend T& get(variant &v); + template friend const T& get(const variant &v); + template friend T* get_if(variant *v) noexcept; + template friend const T* get_if(const variant *v) noexcept; + + template friend bool operator==(const variant &lhs, + const variant &rhs); + Memory memory; + + public: + // Constructors + variant() noexcept; + variant(const variant& other); + variant(variant&& other) noexcept; + // are_different_t is a SFINAE trick to avoid variant(T &&t) with T=variant + // for some reason, this version is called instead of variant(variant&& o) when + // variant is used in STL containers (examples: vector assignment). + template< + typename T, + typename = util::are_different_t + > + explicit variant(T&& t); + // template explicit variant(Args&&... args); + // FIXME: other constructors + + // Destructor + ~variant(); + + // Assignment + variant& operator=(const variant& rhs); + variant& operator=(variant &&rhs) noexcept; + + // SFINAE trick to avoid operator=(T&&) with T=variant<>, see comment above + template< + typename T, + typename = util::are_different_t + > + variant& operator=(T&& t) noexcept; + + // Observers + std::size_t index() const noexcept; + // FIXME: valueless_by_exception() + + // Modifiers + // FIXME: emplace() + void swap(variant &rhs) noexcept; + + // Non-C++17x! + template static constexpr std::size_t index_of(); + }; + + // FIMXE: visit + template + T* get_if(util::variant* v) noexcept; + + template + const T* get_if(const util::variant* v) noexcept; + + template + T& get(util::variant &v); + + template + const T& get(const util::variant &v); + + template + typename util::type_list_element::type& get(util::variant &v); + + template + const typename util::type_list_element::type& get(const util::variant &v); + + template + bool holds_alternative(const util::variant &v) noexcept; + + + // Visitor + namespace detail + { + struct visitor_interface {}; + + // Class `visitor_return_type_deduction_helper` + // introduces solution for deduction `return_type` in `visit` function in common way + // for both Lambda and class Visitor and keep one interface invocation point: `visit` only + // his helper class is required to unify return_type deduction mechanism because + // for Lambda it is possible to take type of `decltype(visitor(get<0>(var)))` + // but for class Visitor there is no operator() in base case, + // because it provides `operator() (std::size_t index, ...)` + // So `visitor_return_type_deduction_helper` expose `operator()` + // uses only for class Visitor only for deduction `return type` in visit() + template + struct visitor_return_type_deduction_helper + { + using return_type = R; + + // to be used in Lambda return type deduction context only + template + return_type operator() (T&&); + }; + } + + // Special purpose `static_visitor` can receive additional arguments + template + struct static_visitor : public detail::visitor_interface, + public detail::visitor_return_type_deduction_helper { + + // assign responsibility for return type deduction to helper class + using return_type = typename detail::visitor_return_type_deduction_helper::return_type; + using detail::visitor_return_type_deduction_helper::operator(); + friend Impl; + + template + return_type operator() (std::size_t index, VariantValue&& value, Args&& ...args) + { + suppress_unused_warning(index); + return static_cast(this)-> visit( + std::forward(value), + std::forward(args)...); + } + }; + + // Special purpose `static_indexed_visitor` can receive additional arguments + // And make forwarding current variant index as runtime function argument to its `Impl` + template + struct static_indexed_visitor : public detail::visitor_interface, + public detail::visitor_return_type_deduction_helper { + + // assign responsibility for return type deduction to helper class + using return_type = typename detail::visitor_return_type_deduction_helper::return_type; + using detail::visitor_return_type_deduction_helper::operator(); + friend Impl; + + template + return_type operator() (std::size_t Index, VariantValue&& value, Args&& ...args) + { + return static_cast(this)-> visit(Index, + std::forward(value), + std::forward(args)...); + } + }; + + template + struct variant_size; + + template + struct variant_size> + : std::integral_constant { }; + // FIXME: T&&, const TT&& versions. + + // Implementation ////////////////////////////////////////////////////////// + template + variant::variant() noexcept + { + typedef typename std::tuple_element<0, std::tuple >::type TFirst; + new (memory) TFirst(); + } + + template + variant::variant(const variant &other) + : m_index(other.m_index) + { + (cctrs()[m_index])(memory, other.memory); + } + + template + variant::variant(variant &&other) noexcept + : m_index(other.m_index) + { + (mctrs()[m_index])(memory, other.memory); + } + + template + template + variant::variant(T&& t) + : m_index(util::type_list_index, Ts...>::value) + { + const constexpr bool is_lvalue_arg = std::is_lvalue_reference::value; + (cnvrt_ctors()[m_index])(memory, const_cast *>(&t)); + } + + template + variant::~variant() + { + (dtors()[m_index])(memory); + } + + template + variant& variant::operator=(const variant &rhs) + { + if (m_index != rhs.m_index) + { + (dtors()[ m_index])(memory); + (cctrs()[rhs.m_index])(memory, rhs.memory); + m_index = rhs.m_index; + } + else + { + (cpyrs()[rhs.m_index])(memory, rhs.memory); + } + return *this; + } + + template + variant& variant::operator=(variant &&rhs) noexcept + { + if (m_index != rhs.m_index) + { + (dtors()[ m_index])(memory); + (mctrs()[rhs.m_index])(memory, rhs.memory); + m_index = rhs.m_index; + } + else + { + (mvers()[rhs.m_index])(memory, rhs.memory); + } + return *this; + } + + template + template + variant& variant::operator=(T&& t) noexcept + { + using decayed_t = util::decay_t; + // FIXME: No version with implicit type conversion available! + const constexpr std::size_t t_index = + util::type_list_index::value; + + const constexpr bool is_lvalue_arg = std::is_lvalue_reference::value; + + if (t_index != m_index) + { + (dtors()[m_index])(memory); + (cnvrt_ctors()[t_index])(memory, &t); + m_index = t_index; + } + else + { + (cnvrt_assgnrs()[m_index])(memory, &t); + } + return *this; + + } + + template + std::size_t util::variant::index() const noexcept + { + return m_index; + } + + template + void variant::swap(variant &rhs) noexcept + { + if (m_index == rhs.index()) + { + (swprs()[m_index](memory, rhs.memory)); + } + else + { + variant tmp(std::move(*this)); + *this = std::move(rhs); + rhs = std::move(tmp); + } + } + + template + template + constexpr std::size_t variant::index_of() + { + return util::type_list_index::value; // FIXME: tests! + } + + template + T* get_if(util::variant* v) noexcept + { + const constexpr std::size_t t_index = + util::type_list_index::value; + + if (v && v->index() == t_index) + return (T*)(&v->memory); // workaround for ICC 2019 + // original code: return reinterpret_cast(v.memory); + return nullptr; + } + + template + const T* get_if(const util::variant* v) noexcept + { + const constexpr std::size_t t_index = + util::type_list_index::value; + + if (v && v->index() == t_index) + return (const T*)(&v->memory); // workaround for ICC 2019 + // original code: return reinterpret_cast(v.memory); + return nullptr; + } + + template + T& get(util::variant &v) + { + if (auto* p = get_if(&v)) + return *p; + else + throw_error(bad_variant_access()); + } + + template + const T& get(const util::variant &v) + { + if (auto* p = get_if(&v)) + return *p; + else + throw_error(bad_variant_access()); + } + + template + typename util::type_list_element::type& get(util::variant &v) + { + using ReturnType = typename util::type_list_element::type; + return const_cast(get(static_cast &>(v))); + } + + template + const typename util::type_list_element::type& get(const util::variant &v) + { + static_assert(Index < sizeof...(Types), + "`Index` it out of bound of `util::variant` type list"); + using ReturnType = typename util::type_list_element::type; + return get(v); + } + + template + bool holds_alternative(const util::variant &v) noexcept + { + return v.index() == util::variant::template index_of(); + } + + template bool operator==(const variant &lhs, + const variant &rhs) + { + using V = variant; + + // Instantiate table only here since it requires operator== for + // should have operator== only if this one is used, not in general + static const std::array eqs = { + {(&V::template equal_h::help)...} + }; + if (lhs.index() != rhs.index()) + return false; + return (eqs[lhs.index()])(lhs.memory, rhs.memory); + } + + template bool operator!=(const variant &lhs, + const variant &rhs) + { + return !(lhs == rhs); + } + +namespace detail +{ + // terminate recursion implementation for `non-void` ReturnType + template + ReturnType apply_visitor_impl(Visitor&&, Variant&, + std::true_type, std::false_type, + VisitorArgs&& ...) + { + return {}; + } + + // terminate recursion implementation for `void` ReturnType + template + void apply_visitor_impl(Visitor&&, Variant&, + std::true_type, std::true_type, + VisitorArgs&& ...) + { + } + + // Intermediate resursion processor for Lambda Visitors + template + typename std::enable_if::type>::value, ReturnType>::type + apply_visitor_impl(Visitor&& visitor, Variant&& v, std::false_type not_processed, + std::integral_constant should_no_return, + VisitorArgs&& ...args) + { + static_assert(std::is_same(v)))>::value, + "Different `ReturnType`s detected! All `Visitor::visit` or `overload_lamba_set`" + " must return the same type"); + suppress_unused_warning(not_processed); + if (v.index() == CurIndex) + { + return visitor.operator()(get(v), std::forward(args)... ); + } + + using is_variant_processed_t = std::integral_constant= ElemCount>; + return apply_visitor_impl( + std::forward(visitor), + std::forward(v), + is_variant_processed_t{}, + should_no_return, + std::forward(args)...); + } + + //Visual Studio 2014 compilation fix: cast visitor to base class before invoke operator() + template + typename std::enable_if::type>, + typename std::decay::type>::value, ReturnType>::type + invoke_class_visitor(Visitor& visitor, Value&& v, VisitorArgs&&...args) + { + return static_cast::type>&>(visitor).operator() (CurIndex, std::forward(v), std::forward(args)... ); + } + + //Visual Studio 2014 compilation fix: cast visitor to base class before invoke operator() + template + typename std::enable_if::type>, + typename std::decay::type>::value, ReturnType>::type + invoke_class_visitor(Visitor& visitor, Value&& v, VisitorArgs&&...args) + { + return static_cast::type>&>(visitor).operator() (CurIndex, std::forward(v), std::forward(args)... ); + } + + // Intermediate recursion processor for special case `visitor_interface` derived Visitors + template + typename std::enable_if::type>::value, ReturnType>::type + apply_visitor_impl(Visitor&& visitor, Variant&& v, std::false_type not_processed, + std::integral_constant should_no_return, + VisitorArgs&& ...args) + { + static_assert(std::is_same(v)))>::value, + "Different `ReturnType`s detected! All `Visitor::visit` or `overload_lamba_set`" + " must return the same type"); + suppress_unused_warning(not_processed); + if (v.index() == CurIndex) + { + return invoke_class_visitor(visitor, get(v), std::forward(args)... ); + } + + using is_variant_processed_t = std::integral_constant= ElemCount>; + return apply_visitor_impl( + std::forward(visitor), + std::forward(v), + is_variant_processed_t{}, + should_no_return, + std::forward(args)...); + } +} // namespace detail + + template + auto visit(Visitor &visitor, const Variant& var, VisitorArg &&...args) -> decltype(visitor(get<0>(var))) + { + constexpr std::size_t varsize = util::variant_size::value; + static_assert(varsize != 0, "utils::variant must contains one type at least "); + using is_variant_processed_t = std::false_type; + + using ReturnType = decltype(visitor(get<0>(var))); + using return_t = std::is_same; + return detail::apply_visitor_impl( + std::forward(visitor), + var, is_variant_processed_t{}, + return_t{}, + std::forward(args)...); + } + + template + auto visit(Visitor&& visitor, const Variant& var) -> decltype(visitor(get<0>(var))) + { + constexpr std::size_t varsize = util::variant_size::value; + static_assert(varsize != 0, "utils::variant must contains one type at least "); + using is_variant_processed_t = std::false_type; + + using ReturnType = decltype(visitor(get<0>(var))); + using return_t = std::is_same; + return detail::apply_visitor_impl( + std::forward(visitor), + var, is_variant_processed_t{}, + return_t{}); + } +} // namespace util +} // namespace cv + +#endif // OPENCV_GAPI_UTIL_VARIANT_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/video.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/video.hpp new file mode 100644 index 0000000..4dcc1d4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/gapi/video.hpp @@ -0,0 +1,364 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +// +// Copyright (C) 2020 Intel Corporation + +#ifndef OPENCV_GAPI_VIDEO_HPP +#define OPENCV_GAPI_VIDEO_HPP + +#include // std::tuple + +#include + + +/** \defgroup gapi_video G-API Video processing functionality + */ + +namespace cv { namespace gapi { + +/** @brief Structure for the Kalman filter's initialization parameters.*/ + +struct GAPI_EXPORTS KalmanParams +{ + // initial state + + //! corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) + Mat state; + //! posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) + Mat errorCov; + + // dynamic system description + + //! state transition matrix (A) + Mat transitionMatrix; + //! measurement matrix (H) + Mat measurementMatrix; + //! process noise covariance matrix (Q) + Mat processNoiseCov; + //! measurement noise covariance matrix (R) + Mat measurementNoiseCov; + //! control matrix (B) (Optional: not used if there's no control) + Mat controlMatrix; +}; + +/** + * @brief This namespace contains G-API Operations and functions for + * video-oriented algorithms, like optical flow and background subtraction. + */ +namespace video +{ +using GBuildPyrOutput = std::tuple, GScalar>; + +using GOptFlowLKOutput = std::tuple, + cv::GArray, + cv::GArray>; + +G_TYPED_KERNEL(GBuildOptFlowPyramid, , + "org.opencv.video.buildOpticalFlowPyramid") +{ + static std::tuple + outMeta(GMatDesc,const Size&,GScalarDesc,bool,int,int,bool) + { + return std::make_tuple(empty_array_desc(), empty_scalar_desc()); + } +}; + +G_TYPED_KERNEL(GCalcOptFlowLK, + ,cv::GArray,Size, + GScalar,TermCriteria,int,double)>, + "org.opencv.video.calcOpticalFlowPyrLK") +{ + static std::tuple outMeta(GMatDesc,GMatDesc,GArrayDesc, + GArrayDesc,const Size&,GScalarDesc, + const TermCriteria&,int,double) + { + return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc()); + } + +}; + +G_TYPED_KERNEL(GCalcOptFlowLKForPyr, + ,cv::GArray, + cv::GArray,cv::GArray,Size,GScalar, + TermCriteria,int,double)>, + "org.opencv.video.calcOpticalFlowPyrLKForPyr") +{ + static std::tuple outMeta(GArrayDesc,GArrayDesc, + GArrayDesc,GArrayDesc, + const Size&,GScalarDesc, + const TermCriteria&,int,double) + { + return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc()); + } +}; + +enum BackgroundSubtractorType +{ + TYPE_BS_MOG2, + TYPE_BS_KNN +}; + +/** @brief Structure for the Background Subtractor operation's initialization parameters.*/ + +struct BackgroundSubtractorParams +{ + //! Type of the Background Subtractor operation. + BackgroundSubtractorType operation = TYPE_BS_MOG2; + + //! Length of the history. + int history = 500; + + //! For MOG2: Threshold on the squared Mahalanobis distance between the pixel + //! and the model to decide whether a pixel is well described by + //! the background model. + //! For KNN: Threshold on the squared distance between the pixel and the sample + //! to decide whether a pixel is close to that sample. + double threshold = 16; + + //! If true, the algorithm will detect shadows and mark them. + bool detectShadows = true; + + //! The value between 0 and 1 that indicates how fast + //! the background model is learnt. + //! Negative parameter value makes the algorithm use some automatically + //! chosen learning rate. + double learningRate = -1; + + //! default constructor + BackgroundSubtractorParams() {} + + /** Full constructor + @param op MOG2/KNN Background Subtractor type. + @param histLength Length of the history. + @param thrshld For MOG2: Threshold on the squared Mahalanobis distance between + the pixel and the model to decide whether a pixel is well described by the background model. + For KNN: Threshold on the squared distance between the pixel and the sample to decide + whether a pixel is close to that sample. + @param detect If true, the algorithm will detect shadows and mark them. It decreases the + speed a bit, so if you do not need this feature, set the parameter to false. + @param lRate The value between 0 and 1 that indicates how fast the background model is learnt. + Negative parameter value makes the algorithm to use some automatically chosen learning rate. + */ + BackgroundSubtractorParams(BackgroundSubtractorType op, int histLength, + double thrshld, bool detect, double lRate) : operation(op), + history(histLength), + threshold(thrshld), + detectShadows(detect), + learningRate(lRate){} +}; + +G_TYPED_KERNEL(GBackgroundSubtractor, , + "org.opencv.video.BackgroundSubtractor") +{ + static GMatDesc outMeta(const GMatDesc& in, const BackgroundSubtractorParams& bsParams) + { + GAPI_Assert(bsParams.history >= 0); + GAPI_Assert(bsParams.learningRate <= 1); + return in.withType(CV_8U, 1); + } +}; + +void checkParams(const cv::gapi::KalmanParams& kfParams, + const cv::GMatDesc& measurement, const cv::GMatDesc& control = {}); + +G_TYPED_KERNEL(GKalmanFilter, , GMat, KalmanParams)>, + "org.opencv.video.KalmanFilter") +{ + static GMatDesc outMeta(const GMatDesc& measurement, const GOpaqueDesc&, + const GMatDesc& control, const KalmanParams& kfParams) + { + checkParams(kfParams, measurement, control); + return measurement.withSize(Size(1, kfParams.transitionMatrix.rows)); + } +}; + +G_TYPED_KERNEL(GKalmanFilterNoControl, , KalmanParams)>, "org.opencv.video.KalmanFilterNoControl") +{ + static GMatDesc outMeta(const GMatDesc& measurement, const GOpaqueDesc&, const KalmanParams& kfParams) + { + checkParams(kfParams, measurement); + return measurement.withSize(Size(1, kfParams.transitionMatrix.rows)); + } +}; +} //namespace video + +//! @addtogroup gapi_video +//! @{ +/** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK. + +@note Function textual ID is "org.opencv.video.buildOpticalFlowPyramid" + +@param img 8-bit input image. +@param winSize window size of optical flow algorithm. Must be not less than winSize + argument of calcOpticalFlowPyrLK. It is needed to calculate required + padding for pyramid levels. +@param maxLevel 0-based maximal pyramid level number. +@param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is + constructed without the gradients then calcOpticalFlowPyrLK will calculate + them internally. +@param pyrBorder the border mode for pyramid layers. +@param derivBorder the border mode for gradients. +@param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false + to force data copying. + +@return + - output pyramid. + - number of levels in constructed pyramid. Can be less than maxLevel. + */ +GAPI_EXPORTS std::tuple, GScalar> +buildOpticalFlowPyramid(const GMat &img, + const Size &winSize, + const GScalar &maxLevel, + bool withDerivatives = true, + int pyrBorder = BORDER_REFLECT_101, + int derivBorder = BORDER_CONSTANT, + bool tryReuseInputImage = true); + +/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade +method with pyramids. + +See @cite Bouguet00 . + +@note Function textual ID is "org.opencv.video.calcOpticalFlowPyrLK" + +@param prevImg first 8-bit input image (GMat) or pyramid (GArray) constructed by +buildOpticalFlowPyramid. +@param nextImg second input image (GMat) or pyramid (GArray) of the same size and the same +type as prevImg. +@param prevPts GArray of 2D points for which the flow needs to be found; point coordinates must be +single-precision floating-point numbers. +@param predPts GArray of 2D points initial for the flow search; make sense only when +OPTFLOW_USE_INITIAL_FLOW flag is passed; in that case the vector must have the same size as in +the input. +@param winSize size of the search window at each pyramid level. +@param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single +level), if set to 1, two levels are used, and so on; if pyramids are passed to input then +algorithm will use as many levels as pyramids have but no more than maxLevel. +@param criteria parameter, specifying the termination criteria of the iterative search algorithm +(after the specified maximum number of iterations criteria.maxCount or when the search window +moves by less than criteria.epsilon). +@param flags operation flags: + - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is + not set, then prevPts is copied to nextPts and is considered the initial estimate. + - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see + minEigThreshold description); if the flag is not set, then L1 distance between patches + around the original and a moved point, divided by number of pixels in a window, is used as a + error measure. +@param minEigThresh the algorithm calculates the minimum eigen value of a 2x2 normal matrix of +optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided +by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding +feature is filtered out and its flow is not processed, so it allows to remove bad points and get a +performance boost. + +@return + - GArray of 2D points (with single-precision floating-point coordinates) +containing the calculated new positions of input features in the second image. + - status GArray (of unsigned chars); each element of the vector is set to 1 if +the flow for the corresponding features has been found, otherwise, it is set to 0. + - GArray of errors (doubles); each element of the vector is set to an error for the +corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't +found then the error is not defined (use the status parameter to find such cases). + */ +GAPI_EXPORTS std::tuple, GArray, GArray> +calcOpticalFlowPyrLK(const GMat &prevImg, + const GMat &nextImg, + const GArray &prevPts, + const GArray &predPts, + const Size &winSize = Size(21, 21), + const GScalar &maxLevel = 3, + const TermCriteria &criteria = TermCriteria(TermCriteria::COUNT | + TermCriteria::EPS, + 30, 0.01), + int flags = 0, + double minEigThresh = 1e-4); + +/** +@overload +@note Function textual ID is "org.opencv.video.calcOpticalFlowPyrLKForPyr" +*/ +GAPI_EXPORTS std::tuple, GArray, GArray> +calcOpticalFlowPyrLK(const GArray &prevPyr, + const GArray &nextPyr, + const GArray &prevPts, + const GArray &predPts, + const Size &winSize = Size(21, 21), + const GScalar &maxLevel = 3, + const TermCriteria &criteria = TermCriteria(TermCriteria::COUNT | + TermCriteria::EPS, + 30, 0.01), + int flags = 0, + double minEigThresh = 1e-4); + +/** @brief Gaussian Mixture-based or K-nearest neighbours-based Background/Foreground Segmentation Algorithm. +The operation generates a foreground mask. + +@return Output image is foreground mask, i.e. 8-bit unsigned 1-channel (binary) matrix @ref CV_8UC1. + +@note Functional textual ID is "org.opencv.video.BackgroundSubtractor" + +@param src input image: Floating point frame is used without scaling and should be in range [0,255]. +@param bsParams Set of initialization parameters for Background Subtractor kernel. +*/ +GAPI_EXPORTS GMat BackgroundSubtractor(const GMat& src, const cv::gapi::video::BackgroundSubtractorParams& bsParams); + +/** @brief Standard Kalman filter algorithm . + +@note Functional textual ID is "org.opencv.video.KalmanFilter" + +@param measurement input matrix: 32-bit or 64-bit float 1-channel matrix containing measurements. +@param haveMeasurement dynamic input flag that indicates whether we get measurements +at a particular iteration . +@param control input matrix: 32-bit or 64-bit float 1-channel matrix contains control data +for changing dynamic system. +@param kfParams Set of initialization parameters for Kalman filter kernel. + +@return Output matrix is predicted or corrected state. They can be 32-bit or 64-bit float +1-channel matrix @ref CV_32FC1 or @ref CV_64FC1. + +@details If measurement matrix is given (haveMeasurements == true), corrected state will +be returned which corresponds to the pipeline +cv::KalmanFilter::predict(control) -> cv::KalmanFilter::correct(measurement). +Otherwise, predicted state will be returned which corresponds to the call of +cv::KalmanFilter::predict(control). +@sa cv::KalmanFilter +*/ +GAPI_EXPORTS GMat KalmanFilter(const GMat& measurement, const GOpaque& haveMeasurement, + const GMat& control, const cv::gapi::KalmanParams& kfParams); + +/** @overload +The case of Standard Kalman filter algorithm when there is no control in a dynamic system. +In this case the controlMatrix is empty and control vector is absent. + +@note Function textual ID is "org.opencv.video.KalmanFilterNoControl" + +@param measurement input matrix: 32-bit or 64-bit float 1-channel matrix containing measurements. +@param haveMeasurement dynamic input flag that indicates whether we get measurements +at a particular iteration. +@param kfParams Set of initialization parameters for Kalman filter kernel. + +@return Output matrix is predicted or corrected state. They can be 32-bit or 64-bit float +1-channel matrix @ref CV_32FC1 or @ref CV_64FC1. + +@sa cv::KalmanFilter + */ +GAPI_EXPORTS GMat KalmanFilter(const GMat& measurement, const GOpaque& haveMeasurement, + const cv::gapi::KalmanParams& kfParams); + +//! @} gapi_video +} //namespace gapi +} //namespace cv + + +namespace cv { namespace detail { +template<> struct CompileArgTag +{ + static const char* tag() + { + return "org.opencv.video.background_substractor_params"; + } +}; +} // namespace detail +} // namespace cv + +#endif // OPENCV_GAPI_VIDEO_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui.hpp new file mode 100644 index 0000000..7ae2395 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui.hpp @@ -0,0 +1,868 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HIGHGUI_HPP +#define OPENCV_HIGHGUI_HPP + +#include "opencv2/core.hpp" +#ifdef HAVE_OPENCV_IMGCODECS +#include "opencv2/imgcodecs.hpp" +#endif +#ifdef HAVE_OPENCV_VIDEOIO +#include "opencv2/videoio.hpp" +#endif + +/** +@defgroup highgui High-level GUI + +While OpenCV was designed for use in full-scale applications and can be used within functionally +rich UI frameworks (such as Qt\*, WinForms\*, or Cocoa\*) or without any UI at all, sometimes there +it is required to try functionality quickly and visualize the results. This is what the HighGUI +module has been designed for. + +It provides easy interface to: + +- Create and manipulate windows that can display images and "remember" their content (no need to + handle repaint events from OS). +- Add trackbars to the windows, handle simple mouse events as well as keyboard commands. + +@{ + @defgroup highgui_window_flags Flags related creating and manipulating HighGUI windows and mouse events + @defgroup highgui_opengl OpenGL support + @defgroup highgui_qt Qt New Functions + + ![image](pics/qtgui.png) + + This figure explains new functionality implemented with Qt\* GUI. The new GUI provides a statusbar, + a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it. + If you cannot see the control panel, press Ctrl+P or right-click any Qt window and select **Display + properties window**. + + - To attach a trackbar, the window name parameter must be NULL. + + - To attach a buttonbar, a button must be created. If the last bar attached to the control panel + is a buttonbar, the new button is added to the right of the last button. If the last bar + attached to the control panel is a trackbar, or the control panel is empty, a new buttonbar is + created. Then, a new button is attached to it. + + See below the example used to generate the figure: + @code + int main(int argc, char *argv[]) + { + + int value = 50; + int value2 = 0; + + + namedWindow("main1",WINDOW_NORMAL); + namedWindow("main2",WINDOW_AUTOSIZE | WINDOW_GUI_NORMAL); + createTrackbar( "track1", "main1", &value, 255, NULL); + + String nameb1 = "button1"; + String nameb2 = "button2"; + + createButton(nameb1,callbackButton,&nameb1,QT_CHECKBOX,1); + createButton(nameb2,callbackButton,NULL,QT_CHECKBOX,0); + createTrackbar( "track2", NULL, &value2, 255, NULL); + createButton("button5",callbackButton1,NULL,QT_RADIOBOX,0); + createButton("button6",callbackButton2,NULL,QT_RADIOBOX,1); + + setMouseCallback( "main2",on_mouse,NULL ); + + Mat img1 = imread("files/flower.jpg"); + VideoCapture video; + video.open("files/hockey.avi"); + + Mat img2,img3; + + while( waitKey(33) != 27 ) + { + img1.convertTo(img2,-1,1,value); + video >> img3; + + imshow("main1",img2); + imshow("main2",img3); + } + + destroyAllWindows(); + + return 0; + } + @endcode + + + @defgroup highgui_winrt WinRT support + + This figure explains new functionality implemented with WinRT GUI. The new GUI provides an Image control, + and a slider panel. Slider panel holds trackbars attached to it. + + Sliders are attached below the image control. Every new slider is added below the previous one. + + See below the example used to generate the figure: + @code + void sample_app::MainPage::ShowWindow() + { + static cv::String windowName("sample"); + cv::winrt_initContainer(this->cvContainer); + cv::namedWindow(windowName); // not required + + cv::Mat image = cv::imread("Assets/sample.jpg"); + cv::Mat converted = cv::Mat(image.rows, image.cols, CV_8UC4); + cv::cvtColor(image, converted, COLOR_BGR2BGRA); + cv::imshow(windowName, converted); // this will create window if it hasn't been created before + + int state = 42; + cv::TrackbarCallback callback = [](int pos, void* userdata) + { + if (pos == 0) { + cv::destroyWindow(windowName); + } + }; + cv::TrackbarCallback callbackTwin = [](int pos, void* userdata) + { + if (pos >= 70) { + cv::destroyAllWindows(); + } + }; + cv::createTrackbar("Sample trackbar", windowName, &state, 100, callback); + cv::createTrackbar("Twin brother", windowName, &state, 100, callbackTwin); + } + @endcode + + @defgroup highgui_c C API +@} +*/ + +///////////////////////// graphical user interface ////////////////////////// +namespace cv +{ + +//! @addtogroup highgui +//! @{ + +//! @addtogroup highgui_window_flags +//! @{ + +//! Flags for cv::namedWindow +enum WindowFlags { + WINDOW_NORMAL = 0x00000000, //!< the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size. + WINDOW_AUTOSIZE = 0x00000001, //!< the user cannot resize the window, the size is constrainted by the image displayed. + WINDOW_OPENGL = 0x00001000, //!< window with opengl support. + + WINDOW_FULLSCREEN = 1, //!< change the window to fullscreen. + WINDOW_FREERATIO = 0x00000100, //!< the image expends as much as it can (no ratio constraint). + WINDOW_KEEPRATIO = 0x00000000, //!< the ratio of the image is respected. + WINDOW_GUI_EXPANDED=0x00000000, //!< status bar and tool bar + WINDOW_GUI_NORMAL = 0x00000010, //!< old fashious way + }; + +//! Flags for cv::setWindowProperty / cv::getWindowProperty +enum WindowPropertyFlags { + WND_PROP_FULLSCREEN = 0, //!< fullscreen property (can be WINDOW_NORMAL or WINDOW_FULLSCREEN). + WND_PROP_AUTOSIZE = 1, //!< autosize property (can be WINDOW_NORMAL or WINDOW_AUTOSIZE). + WND_PROP_ASPECT_RATIO = 2, //!< window's aspect ration (can be set to WINDOW_FREERATIO or WINDOW_KEEPRATIO). + WND_PROP_OPENGL = 3, //!< opengl support. + WND_PROP_VISIBLE = 4, //!< checks whether the window exists and is visible + WND_PROP_TOPMOST = 5, //!< property to toggle normal window being topmost or not + WND_PROP_VSYNC = 6 //!< enable or disable VSYNC (in OpenGL mode) + }; + +//! Mouse Events see cv::MouseCallback +enum MouseEventTypes { + EVENT_MOUSEMOVE = 0, //!< indicates that the mouse pointer has moved over the window. + EVENT_LBUTTONDOWN = 1, //!< indicates that the left mouse button is pressed. + EVENT_RBUTTONDOWN = 2, //!< indicates that the right mouse button is pressed. + EVENT_MBUTTONDOWN = 3, //!< indicates that the middle mouse button is pressed. + EVENT_LBUTTONUP = 4, //!< indicates that left mouse button is released. + EVENT_RBUTTONUP = 5, //!< indicates that right mouse button is released. + EVENT_MBUTTONUP = 6, //!< indicates that middle mouse button is released. + EVENT_LBUTTONDBLCLK = 7, //!< indicates that left mouse button is double clicked. + EVENT_RBUTTONDBLCLK = 8, //!< indicates that right mouse button is double clicked. + EVENT_MBUTTONDBLCLK = 9, //!< indicates that middle mouse button is double clicked. + EVENT_MOUSEWHEEL = 10,//!< positive and negative values mean forward and backward scrolling, respectively. + EVENT_MOUSEHWHEEL = 11 //!< positive and negative values mean right and left scrolling, respectively. + }; + +//! Mouse Event Flags see cv::MouseCallback +enum MouseEventFlags { + EVENT_FLAG_LBUTTON = 1, //!< indicates that the left mouse button is down. + EVENT_FLAG_RBUTTON = 2, //!< indicates that the right mouse button is down. + EVENT_FLAG_MBUTTON = 4, //!< indicates that the middle mouse button is down. + EVENT_FLAG_CTRLKEY = 8, //!< indicates that CTRL Key is pressed. + EVENT_FLAG_SHIFTKEY = 16,//!< indicates that SHIFT Key is pressed. + EVENT_FLAG_ALTKEY = 32 //!< indicates that ALT Key is pressed. + }; + +//! @} highgui_window_flags + +//! @addtogroup highgui_qt +//! @{ + +//! Qt font weight +enum QtFontWeights { + QT_FONT_LIGHT = 25, //!< Weight of 25 + QT_FONT_NORMAL = 50, //!< Weight of 50 + QT_FONT_DEMIBOLD = 63, //!< Weight of 63 + QT_FONT_BOLD = 75, //!< Weight of 75 + QT_FONT_BLACK = 87 //!< Weight of 87 + }; + +//! Qt font style +enum QtFontStyles { + QT_STYLE_NORMAL = 0, //!< Normal font. + QT_STYLE_ITALIC = 1, //!< Italic font. + QT_STYLE_OBLIQUE = 2 //!< Oblique font. + }; + +//! Qt "button" type +enum QtButtonTypes { + QT_PUSH_BUTTON = 0, //!< Push button. + QT_CHECKBOX = 1, //!< Checkbox button. + QT_RADIOBOX = 2, //!< Radiobox button. + QT_NEW_BUTTONBAR = 1024 //!< Button should create a new buttonbar + }; + +//! @} highgui_qt + +/** @brief Callback function for mouse events. see cv::setMouseCallback +@param event one of the cv::MouseEventTypes constants. +@param x The x-coordinate of the mouse event. +@param y The y-coordinate of the mouse event. +@param flags one of the cv::MouseEventFlags constants. +@param userdata The optional parameter. + */ +typedef void (*MouseCallback)(int event, int x, int y, int flags, void* userdata); + +/** @brief Callback function for Trackbar see cv::createTrackbar +@param pos current position of the specified trackbar. +@param userdata The optional parameter. + */ +typedef void (*TrackbarCallback)(int pos, void* userdata); + +/** @brief Callback function defined to be called every frame. See cv::setOpenGlDrawCallback +@param userdata The optional parameter. + */ +typedef void (*OpenGlDrawCallback)(void* userdata); + +/** @brief Callback function for a button created by cv::createButton +@param state current state of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button. +@param userdata The optional parameter. + */ +typedef void (*ButtonCallback)(int state, void* userdata); + +/** @brief Creates a window. + +The function namedWindow creates a window that can be used as a placeholder for images and +trackbars. Created windows are referred to by their names. + +If a window with the same name already exists, the function does nothing. + +You can call cv::destroyWindow or cv::destroyAllWindows to close the window and de-allocate any associated +memory usage. For a simple program, you do not really have to call these functions because all the +resources and windows of the application are closed automatically by the operating system upon exit. + +@note + +Qt backend supports additional flags: + - **WINDOW_NORMAL or WINDOW_AUTOSIZE:** WINDOW_NORMAL enables you to resize the + window, whereas WINDOW_AUTOSIZE adjusts automatically the window size to fit the + displayed image (see imshow ), and you cannot change the window size manually. + - **WINDOW_FREERATIO or WINDOW_KEEPRATIO:** WINDOW_FREERATIO adjusts the image + with no respect to its ratio, whereas WINDOW_KEEPRATIO keeps the image ratio. + - **WINDOW_GUI_NORMAL or WINDOW_GUI_EXPANDED:** WINDOW_GUI_NORMAL is the old way to draw the window + without statusbar and toolbar, whereas WINDOW_GUI_EXPANDED is a new enhanced GUI. +By default, flags == WINDOW_AUTOSIZE | WINDOW_KEEPRATIO | WINDOW_GUI_EXPANDED + +@param winname Name of the window in the window caption that may be used as a window identifier. +@param flags Flags of the window. The supported flags are: (cv::WindowFlags) + */ +CV_EXPORTS_W void namedWindow(const String& winname, int flags = WINDOW_AUTOSIZE); + +/** @brief Destroys the specified window. + +The function destroyWindow destroys the window with the given name. + +@param winname Name of the window to be destroyed. + */ +CV_EXPORTS_W void destroyWindow(const String& winname); + +/** @brief Destroys all of the HighGUI windows. + +The function destroyAllWindows destroys all of the opened HighGUI windows. + */ +CV_EXPORTS_W void destroyAllWindows(); + +CV_EXPORTS_W int startWindowThread(); + +/** @brief Similar to #waitKey, but returns full key code. + +@note + +Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc + +*/ +CV_EXPORTS_W int waitKeyEx(int delay = 0); + +/** @brief Waits for a pressed key. + +The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay +milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the +function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is +running on your computer at that time. It returns the code of the pressed key or -1 if no key was +pressed before the specified time had elapsed. To check for a key press but not wait for it, use +#pollKey. + +@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle +GUI events, so one of them needs to be called periodically for normal event processing unless +HighGUI is used within an environment that takes care of event processing. + +@note The function only works if there is at least one HighGUI window created and the window is +active. If there are several HighGUI windows, any of them can be active. + +@param delay Delay in milliseconds. 0 is the special value that means "forever". + */ +CV_EXPORTS_W int waitKey(int delay = 0); + +/** @brief Polls for a pressed key. + +The function pollKey polls for a key event without waiting. It returns the code of the pressed key +or -1 if no key was pressed since the last invocation. To wait until a key was pressed, use #waitKey. + +@note The functions #waitKey and #pollKey are the only methods in HighGUI that can fetch and handle +GUI events, so one of them needs to be called periodically for normal event processing unless +HighGUI is used within an environment that takes care of event processing. + +@note The function only works if there is at least one HighGUI window created and the window is +active. If there are several HighGUI windows, any of them can be active. + */ +CV_EXPORTS_W int pollKey(); + +/** @brief Displays an image in the specified window. + +The function imshow displays an image in the specified window. If the window was created with the +cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution. +Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth: + +- If the image is 8-bit unsigned, it is displayed as is. +- If the image is 16-bit unsigned, the pixels are divided by 256. That is, the + value range [0,255\*256] is mapped to [0,255]. +- If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the + value range [0,1] is mapped to [0,255]. +- 32-bit integer images are not processed anymore due to ambiguouty of required transform. + Convert to 8-bit unsigned matrix using a custom preprocessing specific to image's context. + +If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and +cuda::GpuMat as input. + +If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE. + +If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow. + +@note This function should be followed by a call to cv::waitKey or cv::pollKey to perform GUI +housekeeping tasks that are necessary to actually show the given image and make the window respond +to mouse and keyboard events. Otherwise, it won't display the image and the window might lock up. +For example, **waitKey(0)** will display the window infinitely until any keypress (it is suitable +for image display). **waitKey(25)** will display a frame and wait approximately 25 ms for a key +press (suitable for displaying a video frame-by-frame). To remove the window, use cv::destroyWindow. + +@note + +[__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard. + +[__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image. + +@param winname Name of the window. +@param mat Image to be shown. + */ +CV_EXPORTS_W void imshow(const String& winname, InputArray mat); + +/** @brief Resizes the window to the specified size + +@note + +- The specified window size is for the image area. Toolbars are not counted. +- Only windows created without cv::WINDOW_AUTOSIZE flag can be resized. + +@param winname Window name. +@param width The new window width. +@param height The new window height. + */ +CV_EXPORTS_W void resizeWindow(const String& winname, int width, int height); + +/** @overload +@param winname Window name. +@param size The new window size. +*/ +CV_EXPORTS_W void resizeWindow(const String& winname, const cv::Size& size); + +/** @brief Moves the window to the specified position + +@param winname Name of the window. +@param x The new x-coordinate of the window. +@param y The new y-coordinate of the window. + */ +CV_EXPORTS_W void moveWindow(const String& winname, int x, int y); + +/** @brief Changes parameters of a window dynamically. + +The function setWindowProperty enables changing properties of a window. + +@param winname Name of the window. +@param prop_id Window property to edit. The supported operation flags are: (cv::WindowPropertyFlags) +@param prop_value New value of the window property. The supported flags are: (cv::WindowFlags) + */ +CV_EXPORTS_W void setWindowProperty(const String& winname, int prop_id, double prop_value); + +/** @brief Updates window title +@param winname Name of the window. +@param title New title. +*/ +CV_EXPORTS_W void setWindowTitle(const String& winname, const String& title); + +/** @brief Provides parameters of a window. + +The function getWindowProperty returns properties of a window. + +@param winname Name of the window. +@param prop_id Window property to retrieve. The following operation flags are available: (cv::WindowPropertyFlags) + +@sa setWindowProperty + */ +CV_EXPORTS_W double getWindowProperty(const String& winname, int prop_id); + +/** @brief Provides rectangle of image in the window. + +The function getWindowImageRect returns the client screen coordinates, width and height of the image rendering area. + +@param winname Name of the window. + +@sa resizeWindow moveWindow + */ +CV_EXPORTS_W Rect getWindowImageRect(const String& winname); + +/** @example samples/cpp/create_mask.cpp +This program demonstrates using mouse events and how to make and use a mask image (black and white) . +*/ +/** @brief Sets mouse handler for the specified window + +@param winname Name of the window. +@param onMouse Callback function for mouse events. See OpenCV samples on how to specify and use the callback. +@param userdata The optional parameter passed to the callback. + */ +CV_EXPORTS void setMouseCallback(const String& winname, MouseCallback onMouse, void* userdata = 0); + +/** @brief Gets the mouse-wheel motion delta, when handling mouse-wheel events cv::EVENT_MOUSEWHEEL and +cv::EVENT_MOUSEHWHEEL. + +For regular mice with a scroll-wheel, delta will be a multiple of 120. The value 120 corresponds to +a one notch rotation of the wheel or the threshold for action to be taken and one such action should +occur for each delta. Some high-precision mice with higher-resolution freely-rotating wheels may +generate smaller values. + +For cv::EVENT_MOUSEWHEEL positive and negative values mean forward and backward scrolling, +respectively. For cv::EVENT_MOUSEHWHEEL, where available, positive and negative values mean right and +left scrolling, respectively. + +@note + +Mouse-wheel events are currently supported only on Windows. + +@param flags The mouse callback flags parameter. + */ +CV_EXPORTS int getMouseWheelDelta(int flags); + +/** @brief Allows users to select a ROI on the given image. + +The function creates a window and allows users to select a ROI using the mouse. +Controls: use `space` or `enter` to finish selection, use key `c` to cancel selection (function will return the zero cv::Rect). + +@param windowName name of the window where selection process will be shown. +@param img image to select a ROI. +@param showCrosshair if true crosshair of selection rectangle will be shown. +@param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of +selection rectangle will correspont to the initial mouse position. +@return selected ROI or empty rect if selection canceled. + +@note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...). +After finish of work an empty callback will be set for the used window. + */ +CV_EXPORTS_W Rect selectROI(const String& windowName, InputArray img, bool showCrosshair = true, bool fromCenter = false); + +/** @overload + */ +CV_EXPORTS_W Rect selectROI(InputArray img, bool showCrosshair = true, bool fromCenter = false); + +/** @brief Allows users to select multiple ROIs on the given image. + +The function creates a window and allows users to select multiple ROIs using the mouse. +Controls: use `space` or `enter` to finish current selection and start a new one, +use `esc` to terminate multiple ROI selection process. + +@param windowName name of the window where selection process will be shown. +@param img image to select a ROI. +@param boundingBoxes selected ROIs. +@param showCrosshair if true crosshair of selection rectangle will be shown. +@param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of +selection rectangle will correspont to the initial mouse position. + +@note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...). +After finish of work an empty callback will be set for the used window. + */ +CV_EXPORTS_W void selectROIs(const String& windowName, InputArray img, + CV_OUT std::vector& boundingBoxes, bool showCrosshair = true, bool fromCenter = false); + +/** @brief Creates a trackbar and attaches it to the specified window. + +The function createTrackbar creates a trackbar (a slider or range control) with the specified name +and range, assigns a variable value to be a position synchronized with the trackbar and specifies +the callback function onChange to be called on the trackbar position change. The created trackbar is +displayed in the specified window winname. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar should be attached to the +control panel. + +Clicking the label of each trackbar enables editing the trackbar values manually. + +@param trackbarname Name of the created trackbar. +@param winname Name of the window that will be used as a parent of the created trackbar. +@param value Optional pointer to an integer variable whose value reflects the position of the +slider. Upon creation, the slider position is defined by this variable. +@param count Maximal position of the slider. The minimal position is always 0. +@param onChange Pointer to the function to be called every time the slider changes position. This +function should be prototyped as void Foo(int,void\*); , where the first parameter is the trackbar +position and the second parameter is the user data (see the next parameter). If the callback is +the NULL pointer, no callbacks are called, but only value is updated. +@param userdata User data that is passed as is to the callback. It can be used to handle trackbar +events without using global variables. + */ +CV_EXPORTS int createTrackbar(const String& trackbarname, const String& winname, + int* value, int count, + TrackbarCallback onChange = 0, + void* userdata = 0); + +/** @brief Returns the trackbar position. + +The function returns the current position of the specified trackbar. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of the trackbar. + */ +CV_EXPORTS_W int getTrackbarPos(const String& trackbarname, const String& winname); + +/** @brief Sets the trackbar position. + +The function sets the position of the specified trackbar in the specified window. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of trackbar. +@param pos New position. + */ +CV_EXPORTS_W void setTrackbarPos(const String& trackbarname, const String& winname, int pos); + +/** @brief Sets the trackbar maximum position. + +The function sets the maximum position of the specified trackbar in the specified window. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of trackbar. +@param maxval New maximum position. + */ +CV_EXPORTS_W void setTrackbarMax(const String& trackbarname, const String& winname, int maxval); + +/** @brief Sets the trackbar minimum position. + +The function sets the minimum position of the specified trackbar in the specified window. + +@note + +[__Qt Backend Only__] winname can be empty if the trackbar is attached to the control +panel. + +@param trackbarname Name of the trackbar. +@param winname Name of the window that is the parent of trackbar. +@param minval New minimum position. + */ +CV_EXPORTS_W void setTrackbarMin(const String& trackbarname, const String& winname, int minval); + +//! @addtogroup highgui_opengl OpenGL support +//! @{ + +/** @brief Displays OpenGL 2D texture in the specified window. + +@param winname Name of the window. +@param tex OpenGL 2D texture data. + */ +CV_EXPORTS void imshow(const String& winname, const ogl::Texture2D& tex); + +/** @brief Sets a callback function to be called to draw on top of displayed image. + +The function setOpenGlDrawCallback can be used to draw 3D data on the window. See the example of +callback function below: +@code + void on_opengl(void* param) + { + glLoadIdentity(); + + glTranslated(0.0, 0.0, -1.0); + + glRotatef( 55, 1, 0, 0 ); + glRotatef( 45, 0, 1, 0 ); + glRotatef( 0, 0, 0, 1 ); + + static const int coords[6][4][3] = { + { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, + { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } }, + { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } }, + { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } }, + { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } }, + { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } + }; + + for (int i = 0; i < 6; ++i) { + glColor3ub( i*20, 100+i*10, i*42 ); + glBegin(GL_QUADS); + for (int j = 0; j < 4; ++j) { + glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]); + } + glEnd(); + } + } +@endcode + +@param winname Name of the window. +@param onOpenGlDraw Pointer to the function to be called every frame. This function should be +prototyped as void Foo(void\*) . +@param userdata Pointer passed to the callback function.(__Optional__) + */ +CV_EXPORTS void setOpenGlDrawCallback(const String& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0); + +/** @brief Sets the specified window as current OpenGL context. + +@param winname Name of the window. + */ +CV_EXPORTS void setOpenGlContext(const String& winname); + +/** @brief Force window to redraw its context and call draw callback ( See cv::setOpenGlDrawCallback ). + +@param winname Name of the window. + */ +CV_EXPORTS void updateWindow(const String& winname); + +//! @} highgui_opengl + +//! @addtogroup highgui_qt +//! @{ + +/** @brief QtFont available only for Qt. See cv::fontQt + */ +struct QtFont +{ + const char* nameFont; //!< Name of the font + Scalar color; //!< Color of the font. Scalar(blue_component, green_component, red_component[, alpha_component]) + int font_face; //!< See cv::QtFontStyles + const int* ascii; //!< font data and metrics + const int* greek; + const int* cyrillic; + float hscale, vscale; + float shear; //!< slope coefficient: 0 - normal, >0 - italic + int thickness; //!< See cv::QtFontWeights + float dx; //!< horizontal interval between letters + int line_type; //!< PointSize +}; + +/** @brief Creates the font to draw a text on an image. + +The function fontQt creates a cv::QtFont object. This cv::QtFont is not compatible with putText . + +A basic usage of this function is the following: : +@code + QtFont font = fontQt("Times"); + addText( img1, "Hello World !", Point(50,50), font); +@endcode + +@param nameFont Name of the font. The name should match the name of a system font (such as +*Times*). If the font is not found, a default one is used. +@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the +font is set to a system-dependent default value. Generally, this is 12 points. +@param color Color of the font in BGRA where A = 255 is fully transparent. Use the macro CV_RGB +for simplicity. +@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control. +@param style Font style. Available operation flags are : cv::QtFontStyles +@param spacing Spacing between characters. It can be negative or positive. + */ +CV_EXPORTS QtFont fontQt(const String& nameFont, int pointSize = -1, + Scalar color = Scalar::all(0), int weight = QT_FONT_NORMAL, + int style = QT_STYLE_NORMAL, int spacing = 0); + +/** @brief Draws a text on the image. + +The function addText draws *text* on the image *img* using a specific font *font* (see example cv::fontQt +) + +@param img 8-bit 3-channel image where the text should be drawn. +@param text Text to write on an image. +@param org Point(x,y) where the text should start on an image. +@param font Font to use to draw a text. + */ +CV_EXPORTS void addText( const Mat& img, const String& text, Point org, const QtFont& font); + +/** @brief Draws a text on the image. + +@param img 8-bit 3-channel image where the text should be drawn. +@param text Text to write on an image. +@param org Point(x,y) where the text should start on an image. +@param nameFont Name of the font. The name should match the name of a system font (such as +*Times*). If the font is not found, a default one is used. +@param pointSize Size of the font. If not specified, equal zero or negative, the point size of the +font is set to a system-dependent default value. Generally, this is 12 points. +@param color Color of the font in BGRA where A = 255 is fully transparent. +@param weight Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control. +@param style Font style. Available operation flags are : cv::QtFontStyles +@param spacing Spacing between characters. It can be negative or positive. + */ +CV_EXPORTS_W void addText(const Mat& img, const String& text, Point org, const String& nameFont, int pointSize = -1, Scalar color = Scalar::all(0), + int weight = QT_FONT_NORMAL, int style = QT_STYLE_NORMAL, int spacing = 0); + +/** @brief Displays a text on a window image as an overlay for a specified duration. + +The function displayOverlay displays useful information/tips on top of the window for a certain +amount of time *delayms*. The function does not modify the image, displayed in the window, that is, +after the specified delay the original content of the window is restored. + +@param winname Name of the window. +@param text Overlay text to write on a window image. +@param delayms The period (in milliseconds), during which the overlay text is displayed. If this +function is called before the previous overlay text timed out, the timer is restarted and the text +is updated. If this value is zero, the text never disappears. + */ +CV_EXPORTS_W void displayOverlay(const String& winname, const String& text, int delayms = 0); + +/** @brief Displays a text on the window statusbar during the specified period of time. + +The function displayStatusBar displays useful information/tips on top of the window for a certain +amount of time *delayms* . This information is displayed on the window statusbar (the window must be +created with the CV_GUI_EXPANDED flags). + +@param winname Name of the window. +@param text Text to write on the window statusbar. +@param delayms Duration (in milliseconds) to display the text. If this function is called before +the previous text timed out, the timer is restarted and the text is updated. If this value is +zero, the text never disappears. + */ +CV_EXPORTS_W void displayStatusBar(const String& winname, const String& text, int delayms = 0); + +/** @brief Saves parameters of the specified window. + +The function saveWindowParameters saves size, location, flags, trackbars value, zoom and panning +location of the window windowName. + +@param windowName Name of the window. + */ +CV_EXPORTS void saveWindowParameters(const String& windowName); + +/** @brief Loads parameters of the specified window. + +The function loadWindowParameters loads size, location, flags, trackbars value, zoom and panning +location of the window windowName. + +@param windowName Name of the window. + */ +CV_EXPORTS void loadWindowParameters(const String& windowName); + +CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]); + +CV_EXPORTS void stopLoop(); + +/** @brief Attaches a button to the control panel. + +The function createButton attaches a button to the control panel. Each button is added to a +buttonbar to the right of the last button. A new buttonbar is created if nothing was attached to the +control panel before, or if the last element attached to the control panel was a trackbar or if the +QT_NEW_BUTTONBAR flag is added to the type. + +See below various examples of the cv::createButton function call: : +@code + createButton("",callbackButton);//create a push button "button 0", that will call callbackButton. + createButton("button2",callbackButton,NULL,QT_CHECKBOX,0); + createButton("button3",callbackButton,&value); + createButton("button5",callbackButton1,NULL,QT_RADIOBOX); + createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON,1); + createButton("button6",callbackButton2,NULL,QT_PUSH_BUTTON|QT_NEW_BUTTONBAR);// create a push button in a new row +@endcode + +@param bar_name Name of the button. +@param on_change Pointer to the function to be called every time the button changes its state. +This function should be prototyped as void Foo(int state,\*void); . *state* is the current state +of the button. It could be -1 for a push button, 0 or 1 for a check/radio box button. +@param userdata Pointer passed to the callback function. +@param type Optional type of the button. Available types are: (cv::QtButtonTypes) +@param initial_button_state Default state of the button. Use for checkbox and radiobox. Its +value could be 0 or 1. (__Optional__) +*/ +CV_EXPORTS int createButton( const String& bar_name, ButtonCallback on_change, + void* userdata = 0, int type = QT_PUSH_BUTTON, + bool initial_button_state = false); + +//! @} highgui_qt + +//! @} highgui + +} // cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui/highgui.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui/highgui.hpp new file mode 100644 index 0000000..160c9cf --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui/highgui.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/highgui.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui/highgui_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui/highgui_c.h new file mode 100644 index 0000000..e508e14 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/highgui/highgui_c.h @@ -0,0 +1,251 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_HIGHGUI_H +#define OPENCV_HIGHGUI_H + +#include "opencv2/core/core_c.h" +#include "opencv2/imgproc/imgproc_c.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** @addtogroup highgui_c + @{ + */ + +/****************************************************************************************\ +* Basic GUI functions * +\****************************************************************************************/ +//YV +//-----------New for Qt +/* For font */ +enum { CV_FONT_LIGHT = 25,//QFont::Light, + CV_FONT_NORMAL = 50,//QFont::Normal, + CV_FONT_DEMIBOLD = 63,//QFont::DemiBold, + CV_FONT_BOLD = 75,//QFont::Bold, + CV_FONT_BLACK = 87 //QFont::Black +}; + +enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal, + CV_STYLE_ITALIC = 1,//QFont::StyleItalic, + CV_STYLE_OBLIQUE = 2 //QFont::StyleOblique +}; +/* ---------*/ + +//for color cvScalar(blue_component, green_component, red_component[, alpha_component]) +//and alpha= 0 <-> 0xFF (not transparent <-> transparent) +CVAPI(CvFont) cvFontQt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0)); + +CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *arg2); + +CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0)); +CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0)); + +CVAPI(void) cvSaveWindowParameters(const char* name); +CVAPI(void) cvLoadWindowParameters(const char* name); +CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]); +CVAPI(void) cvStopLoop( void ); + +typedef void (CV_CDECL *CvButtonCallback)(int state, void* userdata); +enum {CV_PUSH_BUTTON = 0, CV_CHECKBOX = 1, CV_RADIOBOX = 2}; +CVAPI(int) cvCreateButton( const char* button_name CV_DEFAULT(NULL),CvButtonCallback on_change CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL) , int button_type CV_DEFAULT(CV_PUSH_BUTTON), int initial_button_state CV_DEFAULT(0)); +//---------------------- + + +/* this function is used to set some external parameters in case of X Window */ +CVAPI(int) cvInitSystem( int argc, char** argv ); + +CVAPI(int) cvStartWindowThread( void ); + +// --------- YV --------- +enum +{ + //These 3 flags are used by cvSet/GetWindowProperty + CV_WND_PROP_FULLSCREEN = 0, //to change/get window's fullscreen property + CV_WND_PROP_AUTOSIZE = 1, //to change/get window's autosize property + CV_WND_PROP_ASPECTRATIO= 2, //to change/get window's aspectratio property + CV_WND_PROP_OPENGL = 3, //to change/get window's opengl support + CV_WND_PROP_VISIBLE = 4, + + //These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty + CV_WINDOW_NORMAL = 0x00000000, //the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size + CV_WINDOW_AUTOSIZE = 0x00000001, //the user cannot resize the window, the size is constrainted by the image displayed + CV_WINDOW_OPENGL = 0x00001000, //window with opengl support + + //Those flags are only for Qt + CV_GUI_EXPANDED = 0x00000000, //status bar and tool bar + CV_GUI_NORMAL = 0x00000010, //old fashious way + + //These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty + CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen + CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint) + CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected. +}; + +/* create window */ +CVAPI(int) cvNamedWindow( const char* name, int flags CV_DEFAULT(CV_WINDOW_AUTOSIZE) ); + +/* Set and Get Property of the window */ +CVAPI(void) cvSetWindowProperty(const char* name, int prop_id, double prop_value); +CVAPI(double) cvGetWindowProperty(const char* name, int prop_id); + +/* display image within window (highgui windows remember their content) */ +CVAPI(void) cvShowImage( const char* name, const CvArr* image ); + +/* resize/move window */ +CVAPI(void) cvResizeWindow( const char* name, int width, int height ); +CVAPI(void) cvMoveWindow( const char* name, int x, int y ); + + +/* destroy window and all the trackers associated with it */ +CVAPI(void) cvDestroyWindow( const char* name ); + +CVAPI(void) cvDestroyAllWindows(void); + +/* get native window handle (HWND in case of Win32 and Widget in case of X Window) */ +CVAPI(void*) cvGetWindowHandle( const char* name ); + +/* get name of highgui window given its native handle */ +CVAPI(const char*) cvGetWindowName( void* window_handle ); + + +typedef void (CV_CDECL *CvTrackbarCallback)(int pos); + +/* create trackbar and display it on top of given window, set callback */ +CVAPI(int) cvCreateTrackbar( const char* trackbar_name, const char* window_name, + int* value, int count, CvTrackbarCallback on_change CV_DEFAULT(NULL)); + +typedef void (CV_CDECL *CvTrackbarCallback2)(int pos, void* userdata); + +CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name, + int* value, int count, CvTrackbarCallback2 on_change, + void* userdata CV_DEFAULT(0)); + +/* retrieve or set trackbar position */ +CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name ); +CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos ); +CVAPI(void) cvSetTrackbarMax(const char* trackbar_name, const char* window_name, int maxval); +CVAPI(void) cvSetTrackbarMin(const char* trackbar_name, const char* window_name, int minval); + +enum +{ + CV_EVENT_MOUSEMOVE =0, + CV_EVENT_LBUTTONDOWN =1, + CV_EVENT_RBUTTONDOWN =2, + CV_EVENT_MBUTTONDOWN =3, + CV_EVENT_LBUTTONUP =4, + CV_EVENT_RBUTTONUP =5, + CV_EVENT_MBUTTONUP =6, + CV_EVENT_LBUTTONDBLCLK =7, + CV_EVENT_RBUTTONDBLCLK =8, + CV_EVENT_MBUTTONDBLCLK =9, + CV_EVENT_MOUSEWHEEL =10, + CV_EVENT_MOUSEHWHEEL =11 +}; + +enum +{ + CV_EVENT_FLAG_LBUTTON =1, + CV_EVENT_FLAG_RBUTTON =2, + CV_EVENT_FLAG_MBUTTON =4, + CV_EVENT_FLAG_CTRLKEY =8, + CV_EVENT_FLAG_SHIFTKEY =16, + CV_EVENT_FLAG_ALTKEY =32 +}; + + +#define CV_GET_WHEEL_DELTA(flags) ((short)((flags >> 16) & 0xffff)) // upper 16 bits + +typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param); + +/* assign callback for mouse events */ +CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, + void* param CV_DEFAULT(NULL)); + +/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */ +CVAPI(int) cvWaitKey(int delay CV_DEFAULT(0)); + +// OpenGL support + +typedef void (CV_CDECL *CvOpenGlDrawCallback)(void* userdata); +CVAPI(void) cvSetOpenGlDrawCallback(const char* window_name, CvOpenGlDrawCallback callback, void* userdata CV_DEFAULT(NULL)); + +CVAPI(void) cvSetOpenGlContext(const char* window_name); +CVAPI(void) cvUpdateWindow(const char* window_name); + + +/****************************************************************************************\ + +* Obsolete functions/synonyms * +\****************************************************************************************/ + +#define cvAddSearchPath(path) +#define cvvInitSystem cvInitSystem +#define cvvNamedWindow cvNamedWindow +#define cvvShowImage cvShowImage +#define cvvResizeWindow cvResizeWindow +#define cvvDestroyWindow cvDestroyWindow +#define cvvCreateTrackbar cvCreateTrackbar +#define cvvAddSearchPath cvAddSearchPath +#define cvvWaitKey(name) cvWaitKey(0) +#define cvvWaitKeyEx(name,delay) cvWaitKey(delay) +#define HG_AUTOSIZE CV_WINDOW_AUTOSIZE +#define set_preprocess_func cvSetPreprocessFuncWin32 +#define set_postprocess_func cvSetPostprocessFuncWin32 + +#if defined _WIN32 + +CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback); +CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback); +#define cvSetPreprocessFuncWin32(callback) cvSetPreprocessFuncWin32_((const void*)(callback)) +#define cvSetPostprocessFuncWin32(callback) cvSetPostprocessFuncWin32_((const void*)(callback)) + +#endif + +/** @} highgui_c */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs.hpp new file mode 100644 index 0000000..d7ff9a1 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs.hpp @@ -0,0 +1,330 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGCODECS_HPP +#define OPENCV_IMGCODECS_HPP + +#include "opencv2/core.hpp" + +/** + @defgroup imgcodecs Image file reading and writing + @{ + @defgroup imgcodecs_c C API + @defgroup imgcodecs_flags Flags used for image file reading and writing + @defgroup imgcodecs_ios iOS glue + @defgroup imgcodecs_macosx MacOS(OSX) glue + @} +*/ + +//////////////////////////////// image codec //////////////////////////////// +namespace cv +{ + +//! @addtogroup imgcodecs +//! @{ + +//! @addtogroup imgcodecs_flags +//! @{ + +//! Imread flags +enum ImreadModes { + IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation. + IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion). + IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image. + IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit. + IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format. + IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image. + IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2. + IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2. + IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4. + IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4. + IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8. + IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8. + IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag. + }; + +//! Imwrite flags +enum ImwriteFlags { + IMWRITE_JPEG_QUALITY = 1, //!< For JPEG, it can be a quality from 0 to 100 (the higher is the better). Default value is 95. + IMWRITE_JPEG_PROGRESSIVE = 2, //!< Enable JPEG features, 0 or 1, default is False. + IMWRITE_JPEG_OPTIMIZE = 3, //!< Enable JPEG features, 0 or 1, default is False. + IMWRITE_JPEG_RST_INTERVAL = 4, //!< JPEG restart interval, 0 - 65535, default is 0 - no restart. + IMWRITE_JPEG_LUMA_QUALITY = 5, //!< Separate luma quality level, 0 - 100, default is 0 - don't use. + IMWRITE_JPEG_CHROMA_QUALITY = 6, //!< Separate chroma quality level, 0 - 100, default is 0 - don't use. + IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting). + IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE. + IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0. + IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1. + IMWRITE_EXR_TYPE = (3 << 4) + 0, /* 48 */ //!< override EXR storage type (FLOAT (FP32) is default) + IMWRITE_EXR_COMPRESSION = (3 << 4) + 1, /* 49 */ //!< override EXR compression type (ZIP_COMPRESSION = 3 is default) + IMWRITE_WEBP_QUALITY = 64, //!< For WEBP, it can be a quality from 1 to 100 (the higher is the better). By default (without any parameter) and for quality above 100 the lossless compression is used. + IMWRITE_PAM_TUPLETYPE = 128,//!< For PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format + IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values + IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI + IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI + IMWRITE_TIFF_COMPRESSION = 259, //!< For TIFF, use to specify the image compression scheme. See libtiff for integer constants corresponding to compression formats. Note, for images whose depth is CV_32F, only libtiff's SGILOG compression scheme is used. For other supported depths, the compression scheme can be specified by this flag; LZW compression is the default. + IMWRITE_JPEG2000_COMPRESSION_X1000 = 272 //!< For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000. + }; + +enum ImwriteEXRTypeFlags { + /*IMWRITE_EXR_TYPE_UNIT = 0, //!< not supported */ + IMWRITE_EXR_TYPE_HALF = 1, //!< store as HALF (FP16) + IMWRITE_EXR_TYPE_FLOAT = 2 //!< store as FP32 (default) + }; + +enum ImwriteEXRCompressionFlags { + IMWRITE_EXR_COMPRESSION_NO = 0, //!< no compression + IMWRITE_EXR_COMPRESSION_RLE = 1, //!< run length encoding + IMWRITE_EXR_COMPRESSION_ZIPS = 2, //!< zlib compression, one scan line at a time + IMWRITE_EXR_COMPRESSION_ZIP = 3, //!< zlib compression, in blocks of 16 scan lines + IMWRITE_EXR_COMPRESSION_PIZ = 4, //!< piz-based wavelet compression + IMWRITE_EXR_COMPRESSION_PXR24 = 5, //!< lossy 24-bit float compression + IMWRITE_EXR_COMPRESSION_B44 = 6, //!< lossy 4-by-4 pixel block compression, fixed compression rate + IMWRITE_EXR_COMPRESSION_B44A = 7, //!< lossy 4-by-4 pixel block compression, flat fields are compressed more + IMWRITE_EXR_COMPRESSION_DWAA = 8, //!< lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access. Supported since OpenEXR 2.2.0. + IMWRITE_EXR_COMPRESSION_DWAB = 9, //!< lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION. Supported since OpenEXR 2.2.0. + }; + +//! Imwrite PNG specific flags used to tune the compression algorithm. +/** These flags will be modify the way of PNG image compression and will be passed to the underlying zlib processing stage. + +- The effect of IMWRITE_PNG_STRATEGY_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between IMWRITE_PNG_STRATEGY_DEFAULT and IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY. +- IMWRITE_PNG_STRATEGY_RLE is designed to be almost as fast as IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, but give better compression for PNG image data. +- The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. +- IMWRITE_PNG_STRATEGY_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. +*/ +enum ImwritePNGFlags { + IMWRITE_PNG_STRATEGY_DEFAULT = 0, //!< Use this value for normal data. + IMWRITE_PNG_STRATEGY_FILTERED = 1, //!< Use this value for data produced by a filter (or predictor).Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. + IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY = 2, //!< Use this value to force Huffman encoding only (no string match). + IMWRITE_PNG_STRATEGY_RLE = 3, //!< Use this value to limit match distances to one (run-length encoding). + IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. + }; + +//! Imwrite PAM specific tupletype flags used to define the 'TUPETYPE' field of a PAM file. +enum ImwritePAMFlags { + IMWRITE_PAM_FORMAT_NULL = 0, + IMWRITE_PAM_FORMAT_BLACKANDWHITE = 1, + IMWRITE_PAM_FORMAT_GRAYSCALE = 2, + IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA = 3, + IMWRITE_PAM_FORMAT_RGB = 4, + IMWRITE_PAM_FORMAT_RGB_ALPHA = 5, + }; + +//! @} imgcodecs_flags + +/** @brief Loads an image from a file. + +@anchor imread + +The function imread loads an image from the specified file and returns it. If the image cannot be +read (because of missing file, improper permissions, unsupported or invalid format), the function +returns an empty matrix ( Mat::data==NULL ). + +Currently, the following file formats are supported: + +- Windows bitmaps - \*.bmp, \*.dib (always supported) +- JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section) +- JPEG 2000 files - \*.jp2 (see the *Note* section) +- Portable Network Graphics - \*.png (see the *Note* section) +- WebP - \*.webp (see the *Note* section) +- Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported) +- PFM files - \*.pfm (see the *Note* section) +- Sun rasters - \*.sr, \*.ras (always supported) +- TIFF files - \*.tiff, \*.tif (see the *Note* section) +- OpenEXR Image files - \*.exr (see the *Note* section) +- Radiance HDR - \*.hdr, \*.pic (always supported) +- Raster and Vector geospatial data supported by GDAL (see the *Note* section) + +@note +- The function determines the type of an image by the content, not by the file extension. +- In the case of color images, the decoded images will have the channels stored in **B G R** order. +- When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available. + Results may differ to the output of cvtColor() +- On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg, + libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, + and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware + that currently these native image loaders give images with different pixel values because of + the color management embedded into MacOSX. +- On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for + codecs supplied with an OS image. Install the relevant packages (do not forget the development + files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn + on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake. +- In the case you set *WITH_GDAL* flag to true in CMake and @ref IMREAD_LOAD_GDAL to load the image, + then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting + the following formats: [Raster](http://www.gdal.org/formats_list.html), + [Vector](http://www.gdal.org/ogr_formats.html). +- If EXIF information is embedded in the image file, the EXIF orientation will be taken into account + and thus the image will be rotated accordingly except if the flags @ref IMREAD_IGNORE_ORIENTATION + or @ref IMREAD_UNCHANGED are passed. +- Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image. +- By default number of pixels must be less than 2^30. Limit can be set using system + variable OPENCV_IO_MAX_IMAGE_PIXELS + +@param filename Name of file to be loaded. +@param flags Flag that can take values of cv::ImreadModes +*/ +CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR ); + +/** @brief Loads a multi-page image from a file. + +The function imreadmulti loads a multi-page image from the specified file into a vector of Mat objects. +@param filename Name of file to be loaded. +@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. +@param mats A vector of Mat objects holding each page, if more than one. +@sa cv::imread +*/ +CV_EXPORTS_W bool imreadmulti(const String& filename, CV_OUT std::vector& mats, int flags = IMREAD_ANYCOLOR); + +/** @brief Loads a of images of a multi-page image from a file. + +The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects. +@param filename Name of file to be loaded. +@param start Start index of the image to load +@param count Count number of images to load +@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. +@param mats A vector of Mat objects holding each page, if more than one. +@sa cv::imread +*/ +CV_EXPORTS_W bool imreadmulti(const String& filename, CV_OUT std::vector& mats, int start, int count, int flags = IMREAD_ANYCOLOR); + +/** @brief Returns the number of images inside the give file + +The function imcount will return the number of pages in a multi-page image, or 1 for single-page images +@param filename Name of file to be loaded. +@param flags Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR. +*/ +CV_EXPORTS_W size_t imcount(const String& filename, int flags = IMREAD_ANYCOLOR); + +/** @brief Saves an image to a specified file. + +The function imwrite saves the image to the specified file. The image format is chosen based on the +filename extension (see cv::imread for the list of extensions). In general, only 8-bit +single-channel or 3-channel (with 'BGR' channel order) images +can be saved using this function, with these exceptions: + +- 16-bit unsigned (CV_16U) images can be saved in the case of PNG, JPEG 2000, and TIFF formats +- 32-bit float (CV_32F) images can be saved in PFM, TIFF, OpenEXR, and Radiance HDR formats; + 3-channel (CV_32FC3) TIFF images will be saved using the LogLuv high dynamic range encoding + (4 bytes per pixel) +- PNG images with an alpha channel can be saved using this function. To do this, create +8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels +should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below). +- Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below). + +If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way. + +If the format, depth or channel order is different, use +Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O +functions to save the image to XML or YAML format. + +The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file. +It also demonstrates how to save multiple images in a TIFF file: +@include snippets/imgcodecs_imwrite.cpp +@param filename Name of the file. +@param img (Mat or vector of Mat) Image or Images to be saved. +@param params Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags +*/ +CV_EXPORTS_W bool imwrite( const String& filename, InputArray img, + const std::vector& params = std::vector()); + +/// @overload multi-image overload for bindings +CV_WRAP static inline +bool imwritemulti(const String& filename, InputArrayOfArrays img, + const std::vector& params = std::vector()) +{ + return imwrite(filename, img, params); +} + +/** @brief Reads an image from a buffer in memory. + +The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or +contains invalid data, the function returns an empty matrix ( Mat::data==NULL ). + +See cv::imread for the list of supported formats and flags description. + +@note In the case of color images, the decoded images will have the channels stored in **B G R** order. +@param buf Input array or vector of bytes. +@param flags The same flags as in cv::imread, see cv::ImreadModes. +*/ +CV_EXPORTS_W Mat imdecode( InputArray buf, int flags ); + +/** @overload +@param buf +@param flags +@param dst The optional output placeholder for the decoded matrix. It can save the image +reallocations when the function is called repeatedly for images of the same size. +*/ +CV_EXPORTS Mat imdecode( InputArray buf, int flags, Mat* dst); + +/** @brief Encodes an image into a memory buffer. + +The function imencode compresses the image and stores it in the memory buffer that is resized to fit the +result. See cv::imwrite for the list of supported formats and flags description. + +@param ext File extension that defines the output format. +@param img Image to be written. +@param buf Output buffer resized to fit the compressed image. +@param params Format-specific parameters. See cv::imwrite and cv::ImwriteFlags. +*/ +CV_EXPORTS_W bool imencode( const String& ext, InputArray img, + CV_OUT std::vector& buf, + const std::vector& params = std::vector()); + +/** @brief Returns true if the specified image can be decoded by OpenCV + +@param filename File name of the image +*/ +CV_EXPORTS_W bool haveImageReader( const String& filename ); + +/** @brief Returns true if an image with the specified filename can be encoded by OpenCV + + @param filename File name of the image + */ +CV_EXPORTS_W bool haveImageWriter( const String& filename ); + + +//! @} imgcodecs + +} // cv + +#endif //OPENCV_IMGCODECS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs.hpp new file mode 100644 index 0000000..a3cd232 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/imgcodecs.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs_c.h new file mode 100644 index 0000000..c78b3f7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/imgcodecs_c.h @@ -0,0 +1 @@ +#error "This header with legacy C API declarations has been removed from OpenCV. Legacy constants are available from legacy/constants_c.h file." diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/ios.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/ios.h new file mode 100644 index 0000000..5f17218 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/ios.h @@ -0,0 +1,59 @@ + +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#import +#import +#import +#import +#include "opencv2/core.hpp" + +//! @addtogroup imgcodecs_ios +//! @{ + +CV_EXPORTS CGImageRef MatToCGImage(const cv::Mat& image) CF_RETURNS_RETAINED; +CV_EXPORTS void CGImageToMat(const CGImageRef image, cv::Mat& m, bool alphaExist = false); +CV_EXPORTS UIImage* MatToUIImage(const cv::Mat& image); +CV_EXPORTS void UIImageToMat(const UIImage* image, + cv::Mat& m, bool alphaExist = false); + +//! @} diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/legacy/constants_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/legacy/constants_c.h new file mode 100644 index 0000000..de7be4f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/legacy/constants_c.h @@ -0,0 +1,54 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGCODECS_LEGACY_CONSTANTS_H +#define OPENCV_IMGCODECS_LEGACY_CONSTANTS_H + +/* duplicate of "ImreadModes" enumeration for better compatibility with OpenCV 3.x */ +enum +{ +/* 8bit, color or not */ + CV_LOAD_IMAGE_UNCHANGED =-1, +/* 8bit, gray */ + CV_LOAD_IMAGE_GRAYSCALE =0, +/* ?, color */ + CV_LOAD_IMAGE_COLOR =1, +/* any depth, ? */ + CV_LOAD_IMAGE_ANYDEPTH =2, +/* ?, any color */ + CV_LOAD_IMAGE_ANYCOLOR =4, +/* ?, no rotate */ + CV_LOAD_IMAGE_IGNORE_ORIENTATION =128 +}; + +/* duplicate of "ImwriteFlags" enumeration for better compatibility with OpenCV 3.x */ +enum +{ + CV_IMWRITE_JPEG_QUALITY =1, + CV_IMWRITE_JPEG_PROGRESSIVE =2, + CV_IMWRITE_JPEG_OPTIMIZE =3, + CV_IMWRITE_JPEG_RST_INTERVAL =4, + CV_IMWRITE_JPEG_LUMA_QUALITY =5, + CV_IMWRITE_JPEG_CHROMA_QUALITY =6, + CV_IMWRITE_PNG_COMPRESSION =16, + CV_IMWRITE_PNG_STRATEGY =17, + CV_IMWRITE_PNG_BILEVEL =18, + CV_IMWRITE_PNG_STRATEGY_DEFAULT =0, + CV_IMWRITE_PNG_STRATEGY_FILTERED =1, + CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2, + CV_IMWRITE_PNG_STRATEGY_RLE =3, + CV_IMWRITE_PNG_STRATEGY_FIXED =4, + CV_IMWRITE_PXM_BINARY =32, + CV_IMWRITE_EXR_TYPE = 48, + CV_IMWRITE_WEBP_QUALITY =64, + CV_IMWRITE_PAM_TUPLETYPE = 128, + CV_IMWRITE_PAM_FORMAT_NULL = 0, + CV_IMWRITE_PAM_FORMAT_BLACKANDWHITE = 1, + CV_IMWRITE_PAM_FORMAT_GRAYSCALE = 2, + CV_IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA = 3, + CV_IMWRITE_PAM_FORMAT_RGB = 4, + CV_IMWRITE_PAM_FORMAT_RGB_ALPHA = 5, +}; + +#endif // OPENCV_IMGCODECS_LEGACY_CONSTANTS_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/macosx.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/macosx.h new file mode 100644 index 0000000..cfb0770 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgcodecs/macosx.h @@ -0,0 +1,20 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#if !defined(__APPLE__) || !defined(__MACH__) +#error This header should be used in macOS ObjC/Swift projects. +#endif + +#import +#include "opencv2/core.hpp" + +//! @addtogroup imgcodecs_macosx +//! @{ + +CV_EXPORTS CGImageRef MatToCGImage(const cv::Mat& image) CF_RETURNS_RETAINED; +CV_EXPORTS void CGImageToMat(const CGImageRef image, cv::Mat& m, bool alphaExist = false); +CV_EXPORTS NSImage* MatToNSImage(const cv::Mat& image); +CV_EXPORTS void NSImageToMat(const NSImage* image, cv::Mat& m, bool alphaExist = false); + +//! @} diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc.hpp new file mode 100644 index 0000000..eacec61 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc.hpp @@ -0,0 +1,4994 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_HPP +#define OPENCV_IMGPROC_HPP + +#include "opencv2/core.hpp" + +/** + @defgroup imgproc Image Processing + +This module includes image-processing functions. + + @{ + @defgroup imgproc_filter Image Filtering + +Functions and classes described in this section are used to perform various linear or non-linear +filtering operations on 2D images (represented as Mat's). It means that for each pixel location +\f$(x,y)\f$ in the source image (normally, rectangular), its neighborhood is considered and used to +compute the response. In case of a linear filter, it is a weighted sum of pixel values. In case of +morphological operations, it is the minimum or maximum values, and so on. The computed response is +stored in the destination image at the same location \f$(x,y)\f$. It means that the output image +will be of the same size as the input image. Normally, the functions support multi-channel arrays, +in which case every channel is processed independently. Therefore, the output image will also have +the same number of channels as the input one. + +Another common feature of the functions and classes described in this section is that, unlike +simple arithmetic functions, they need to extrapolate values of some non-existing pixels. For +example, if you want to smooth an image using a Gaussian \f$3 \times 3\f$ filter, then, when +processing the left-most pixels in each row, you need pixels to the left of them, that is, outside +of the image. You can let these pixels be the same as the left-most image pixels ("replicated +border" extrapolation method), or assume that all the non-existing pixels are zeros ("constant +border" extrapolation method), and so on. OpenCV enables you to specify the extrapolation method. +For details, see #BorderTypes + +@anchor filter_depths +### Depth combinations +Input depth (src.depth()) | Output depth (ddepth) +--------------------------|---------------------- +CV_8U | -1/CV_16S/CV_32F/CV_64F +CV_16U/CV_16S | -1/CV_32F/CV_64F +CV_32F | -1/CV_32F/CV_64F +CV_64F | -1/CV_64F + +@note when ddepth=-1, the output image will have the same depth as the source. + + @defgroup imgproc_transform Geometric Image Transformations + +The functions in this section perform various geometrical transformations of 2D images. They do not +change the image content but deform the pixel grid and map this deformed grid to the destination +image. In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from +destination to the source. That is, for each pixel \f$(x, y)\f$ of the destination image, the +functions compute coordinates of the corresponding "donor" pixel in the source image and copy the +pixel value: + +\f[\texttt{dst} (x,y)= \texttt{src} (f_x(x,y), f_y(x,y))\f] + +In case when you specify the forward mapping \f$\left: \texttt{src} \rightarrow +\texttt{dst}\f$, the OpenCV functions first compute the corresponding inverse mapping +\f$\left: \texttt{dst} \rightarrow \texttt{src}\f$ and then use the above formula. + +The actual implementations of the geometrical transformations, from the most generic remap and to +the simplest and the fastest resize, need to solve two main problems with the above formula: + +- Extrapolation of non-existing pixels. Similarly to the filtering functions described in the +previous section, for some \f$(x,y)\f$, either one of \f$f_x(x,y)\f$, or \f$f_y(x,y)\f$, or both +of them may fall outside of the image. In this case, an extrapolation method needs to be used. +OpenCV provides the same selection of extrapolation methods as in the filtering functions. In +addition, it provides the method #BORDER_TRANSPARENT. This means that the corresponding pixels in +the destination image will not be modified at all. + +- Interpolation of pixel values. Usually \f$f_x(x,y)\f$ and \f$f_y(x,y)\f$ are floating-point +numbers. This means that \f$\left\f$ can be either an affine or perspective +transformation, or radial lens distortion correction, and so on. So, a pixel value at fractional +coordinates needs to be retrieved. In the simplest case, the coordinates can be just rounded to the +nearest integer coordinates and the corresponding pixel can be used. This is called a +nearest-neighbor interpolation. However, a better result can be achieved by using more +sophisticated [interpolation methods](http://en.wikipedia.org/wiki/Multivariate_interpolation) , +where a polynomial function is fit into some neighborhood of the computed pixel \f$(f_x(x,y), +f_y(x,y))\f$, and then the value of the polynomial at \f$(f_x(x,y), f_y(x,y))\f$ is taken as the +interpolated pixel value. In OpenCV, you can choose between several interpolation methods. See +resize for details. + +@note The geometrical transformations do not work with `CV_8S` or `CV_32S` images. + + @defgroup imgproc_misc Miscellaneous Image Transformations + @defgroup imgproc_draw Drawing Functions + +Drawing functions work with matrices/images of arbitrary depth. The boundaries of the shapes can be +rendered with antialiasing (implemented only for 8-bit images for now). All the functions include +the parameter color that uses an RGB value (that may be constructed with the Scalar constructor ) +for color images and brightness for grayscale images. For color images, the channel ordering is +normally *Blue, Green, Red*. This is what imshow, imread, and imwrite expect. So, if you form a +color using the Scalar constructor, it should look like: + +\f[\texttt{Scalar} (blue \_ component, green \_ component, red \_ component[, alpha \_ component])\f] + +If you are using your own image rendering and I/O functions, you can use any channel ordering. The +drawing functions process each channel independently and do not depend on the channel order or even +on the used color space. The whole image can be converted from BGR to RGB or to a different color +space using cvtColor . + +If a drawn figure is partially or completely outside the image, the drawing functions clip it. Also, +many drawing functions can handle pixel coordinates specified with sub-pixel accuracy. This means +that the coordinates can be passed as fixed-point numbers encoded as integers. The number of +fractional bits is specified by the shift parameter and the real point coordinates are calculated as +\f$\texttt{Point}(x,y)\rightarrow\texttt{Point2f}(x*2^{-shift},y*2^{-shift})\f$ . This feature is +especially effective when rendering antialiased shapes. + +@note The functions do not support alpha-transparency when the target image is 4-channel. In this +case, the color[3] is simply copied to the repainted pixels. Thus, if you want to paint +semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main +image. + + @defgroup imgproc_color_conversions Color Space Conversions + @defgroup imgproc_colormap ColorMaps in OpenCV + +The human perception isn't built for observing fine changes in grayscale images. Human eyes are more +sensitive to observing changes between colors, so you often need to recolor your grayscale images to +get a clue about them. OpenCV now comes with various colormaps to enhance the visualization in your +computer vision application. + +In OpenCV you only need applyColorMap to apply a colormap on a given image. The following sample +code reads the path to an image from command line, applies a Jet colormap on it and shows the +result: + +@include snippets/imgproc_applyColorMap.cpp + +@see #ColormapTypes + + @defgroup imgproc_subdiv2d Planar Subdivision + +The Subdiv2D class described in this section is used to perform various planar subdivision on +a set of 2D points (represented as vector of Point2f). OpenCV subdivides a plane into triangles +using the Delaunay's algorithm, which corresponds to the dual graph of the Voronoi diagram. +In the figure below, the Delaunay's triangulation is marked with black lines and the Voronoi +diagram with red lines. + +![Delaunay triangulation (black) and Voronoi (red)](pics/delaunay_voronoi.png) + +The subdivisions can be used for the 3D piece-wise transformation of a plane, morphing, fast +location of points on the plane, building special graphs (such as NNG,RNG), and so forth. + + @defgroup imgproc_hist Histograms + @defgroup imgproc_shape Structural Analysis and Shape Descriptors + @defgroup imgproc_motion Motion Analysis and Object Tracking + @defgroup imgproc_feature Feature Detection + @defgroup imgproc_object Object Detection + @defgroup imgproc_segmentation Image Segmentation + @defgroup imgproc_c C API + @defgroup imgproc_hal Hardware Acceleration Layer + @{ + @defgroup imgproc_hal_functions Functions + @defgroup imgproc_hal_interface Interface + @} + @} +*/ + +namespace cv +{ + +/** @addtogroup imgproc +@{ +*/ + +//! @addtogroup imgproc_filter +//! @{ + +enum SpecialFilter { + FILTER_SCHARR = -1 +}; + +//! type of morphological operation +enum MorphTypes{ + MORPH_ERODE = 0, //!< see #erode + MORPH_DILATE = 1, //!< see #dilate + MORPH_OPEN = 2, //!< an opening operation + //!< \f[\texttt{dst} = \mathrm{open} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \mathrm{erode} ( \texttt{src} , \texttt{element} ))\f] + MORPH_CLOSE = 3, //!< a closing operation + //!< \f[\texttt{dst} = \mathrm{close} ( \texttt{src} , \texttt{element} )= \mathrm{erode} ( \mathrm{dilate} ( \texttt{src} , \texttt{element} ))\f] + MORPH_GRADIENT = 4, //!< a morphological gradient + //!< \f[\texttt{dst} = \mathrm{morph\_grad} ( \texttt{src} , \texttt{element} )= \mathrm{dilate} ( \texttt{src} , \texttt{element} )- \mathrm{erode} ( \texttt{src} , \texttt{element} )\f] + MORPH_TOPHAT = 5, //!< "top hat" + //!< \f[\texttt{dst} = \mathrm{tophat} ( \texttt{src} , \texttt{element} )= \texttt{src} - \mathrm{open} ( \texttt{src} , \texttt{element} )\f] + MORPH_BLACKHAT = 6, //!< "black hat" + //!< \f[\texttt{dst} = \mathrm{blackhat} ( \texttt{src} , \texttt{element} )= \mathrm{close} ( \texttt{src} , \texttt{element} )- \texttt{src}\f] + MORPH_HITMISS = 7 //!< "hit or miss" + //!< .- Only supported for CV_8UC1 binary images. A tutorial can be found in the documentation +}; + +//! shape of the structuring element +enum MorphShapes { + MORPH_RECT = 0, //!< a rectangular structuring element: \f[E_{ij}=1\f] + MORPH_CROSS = 1, //!< a cross-shaped structuring element: + //!< \f[E_{ij} = \begin{cases} 1 & \texttt{if } {i=\texttt{anchor.y } {or } {j=\texttt{anchor.x}}} \\0 & \texttt{otherwise} \end{cases}\f] + MORPH_ELLIPSE = 2 //!< an elliptic structuring element, that is, a filled ellipse inscribed + //!< into the rectangle Rect(0, 0, esize.width, 0.esize.height) +}; + +//! @} imgproc_filter + +//! @addtogroup imgproc_transform +//! @{ + +//! interpolation algorithm +enum InterpolationFlags{ + /** nearest neighbor interpolation */ + INTER_NEAREST = 0, + /** bilinear interpolation */ + INTER_LINEAR = 1, + /** bicubic interpolation */ + INTER_CUBIC = 2, + /** resampling using pixel area relation. It may be a preferred method for image decimation, as + it gives moire'-free results. But when the image is zoomed, it is similar to the INTER_NEAREST + method. */ + INTER_AREA = 3, + /** Lanczos interpolation over 8x8 neighborhood */ + INTER_LANCZOS4 = 4, + /** Bit exact bilinear interpolation */ + INTER_LINEAR_EXACT = 5, + /** Bit exact nearest neighbor interpolation. This will produce same results as + the nearest neighbor method in PIL, scikit-image or Matlab. */ + INTER_NEAREST_EXACT = 6, + /** mask for interpolation codes */ + INTER_MAX = 7, + /** flag, fills all of the destination image pixels. If some of them correspond to outliers in the + source image, they are set to zero */ + WARP_FILL_OUTLIERS = 8, + /** flag, inverse transformation + + For example, #linearPolar or #logPolar transforms: + - flag is __not__ set: \f$dst( \rho , \phi ) = src(x,y)\f$ + - flag is set: \f$dst(x,y) = src( \rho , \phi )\f$ + */ + WARP_INVERSE_MAP = 16 +}; + +/** \brief Specify the polar mapping mode +@sa warpPolar +*/ +enum WarpPolarMode +{ + WARP_POLAR_LINEAR = 0, ///< Remaps an image to/from polar space. + WARP_POLAR_LOG = 256 ///< Remaps an image to/from semilog-polar space. +}; + +enum InterpolationMasks { + INTER_BITS = 5, + INTER_BITS2 = INTER_BITS * 2, + INTER_TAB_SIZE = 1 << INTER_BITS, + INTER_TAB_SIZE2 = INTER_TAB_SIZE * INTER_TAB_SIZE + }; + +//! @} imgproc_transform + +//! @addtogroup imgproc_misc +//! @{ + +//! Distance types for Distance Transform and M-estimators +//! @see distanceTransform, fitLine +enum DistanceTypes { + DIST_USER = -1, //!< User defined distance + DIST_L1 = 1, //!< distance = |x1-x2| + |y1-y2| + DIST_L2 = 2, //!< the simple euclidean distance + DIST_C = 3, //!< distance = max(|x1-x2|,|y1-y2|) + DIST_L12 = 4, //!< L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) + DIST_FAIR = 5, //!< distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 + DIST_WELSCH = 6, //!< distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 + DIST_HUBER = 7 //!< distance = |x| \texttt{thresh}\)}{0}{otherwise}\f] + THRESH_BINARY_INV = 1, //!< \f[\texttt{dst} (x,y) = \fork{0}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{maxval}}{otherwise}\f] + THRESH_TRUNC = 2, //!< \f[\texttt{dst} (x,y) = \fork{\texttt{threshold}}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{src}(x,y)}{otherwise}\f] + THRESH_TOZERO = 3, //!< \f[\texttt{dst} (x,y) = \fork{\texttt{src}(x,y)}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{0}{otherwise}\f] + THRESH_TOZERO_INV = 4, //!< \f[\texttt{dst} (x,y) = \fork{0}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{src}(x,y)}{otherwise}\f] + THRESH_MASK = 7, + THRESH_OTSU = 8, //!< flag, use Otsu algorithm to choose the optimal threshold value + THRESH_TRIANGLE = 16 //!< flag, use Triangle algorithm to choose the optimal threshold value +}; + +//! adaptive threshold algorithm +//! @see adaptiveThreshold +enum AdaptiveThresholdTypes { + /** the threshold value \f$T(x,y)\f$ is a mean of the \f$\texttt{blockSize} \times + \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$ minus C */ + ADAPTIVE_THRESH_MEAN_C = 0, + /** the threshold value \f$T(x, y)\f$ is a weighted sum (cross-correlation with a Gaussian + window) of the \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$ + minus C . The default sigma (standard deviation) is used for the specified blockSize . See + #getGaussianKernel*/ + ADAPTIVE_THRESH_GAUSSIAN_C = 1 +}; + +//! class of the pixel in GrabCut algorithm +enum GrabCutClasses { + GC_BGD = 0, //!< an obvious background pixels + GC_FGD = 1, //!< an obvious foreground (object) pixel + GC_PR_BGD = 2, //!< a possible background pixel + GC_PR_FGD = 3 //!< a possible foreground pixel +}; + +//! GrabCut algorithm flags +enum GrabCutModes { + /** The function initializes the state and the mask using the provided rectangle. After that it + runs iterCount iterations of the algorithm. */ + GC_INIT_WITH_RECT = 0, + /** The function initializes the state using the provided mask. Note that GC_INIT_WITH_RECT + and GC_INIT_WITH_MASK can be combined. Then, all the pixels outside of the ROI are + automatically initialized with GC_BGD .*/ + GC_INIT_WITH_MASK = 1, + /** The value means that the algorithm should just resume. */ + GC_EVAL = 2, + /** The value means that the algorithm should just run the grabCut algorithm (a single iteration) with the fixed model */ + GC_EVAL_FREEZE_MODEL = 3 +}; + +//! distanceTransform algorithm flags +enum DistanceTransformLabelTypes { + /** each connected component of zeros in src (as well as all the non-zero pixels closest to the + connected component) will be assigned the same label */ + DIST_LABEL_CCOMP = 0, + /** each zero pixel (and all the non-zero pixels closest to it) gets its own label. */ + DIST_LABEL_PIXEL = 1 +}; + +//! floodfill algorithm flags +enum FloodFillFlags { + /** If set, the difference between the current pixel and seed pixel is considered. Otherwise, + the difference between neighbor pixels is considered (that is, the range is floating). */ + FLOODFILL_FIXED_RANGE = 1 << 16, + /** If set, the function does not change the image ( newVal is ignored), and only fills the + mask with the value specified in bits 8-16 of flags as described above. This option only make + sense in function variants that have the mask parameter. */ + FLOODFILL_MASK_ONLY = 1 << 17 +}; + +//! @} imgproc_misc + +//! @addtogroup imgproc_shape +//! @{ + +//! connected components statistics +enum ConnectedComponentsTypes { + CC_STAT_LEFT = 0, //!< The leftmost (x) coordinate which is the inclusive start of the bounding + //!< box in the horizontal direction. + CC_STAT_TOP = 1, //!< The topmost (y) coordinate which is the inclusive start of the bounding + //!< box in the vertical direction. + CC_STAT_WIDTH = 2, //!< The horizontal size of the bounding box + CC_STAT_HEIGHT = 3, //!< The vertical size of the bounding box + CC_STAT_AREA = 4, //!< The total area (in pixels) of the connected component +#ifndef CV_DOXYGEN + CC_STAT_MAX = 5 //!< Max enumeration value. Used internally only for memory allocation +#endif +}; + +//! connected components algorithm +enum ConnectedComponentsAlgorithmsTypes { + CCL_DEFAULT = -1, //!< Spaghetti @cite Bolelli2019 algorithm for 8-way connectivity, Spaghetti4C @cite Bolelli2021 algorithm for 4-way connectivity. + CCL_WU = 0, //!< SAUF @cite Wu2009 algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity. The parallel implementation described in @cite Bolelli2017 is available for SAUF. + CCL_GRANA = 1, //!< BBDT @cite Grana2010 algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity. The parallel implementation described in @cite Bolelli2017 is available for both BBDT and SAUF. + CCL_BOLELLI = 2, //!< Spaghetti @cite Bolelli2019 algorithm for 8-way connectivity, Spaghetti4C @cite Bolelli2021 algorithm for 4-way connectivity. The parallel implementation described in @cite Bolelli2017 is available for both Spaghetti and Spaghetti4C. + CCL_SAUF = 3, //!< Same as CCL_WU. It is preferable to use the flag with the name of the algorithm (CCL_SAUF) rather than the one with the name of the first author (CCL_WU). + CCL_BBDT = 4, //!< Same as CCL_GRANA. It is preferable to use the flag with the name of the algorithm (CCL_BBDT) rather than the one with the name of the first author (CCL_GRANA). + CCL_SPAGHETTI = 5, //!< Same as CCL_BOLELLI. It is preferable to use the flag with the name of the algorithm (CCL_SPAGHETTI) rather than the one with the name of the first author (CCL_BOLELLI). +}; + +//! mode of the contour retrieval algorithm +enum RetrievalModes { + /** retrieves only the extreme outer contours. It sets `hierarchy[i][2]=hierarchy[i][3]=-1` for + all the contours. */ + RETR_EXTERNAL = 0, + /** retrieves all of the contours without establishing any hierarchical relationships. */ + RETR_LIST = 1, + /** retrieves all of the contours and organizes them into a two-level hierarchy. At the top + level, there are external boundaries of the components. At the second level, there are + boundaries of the holes. If there is another contour inside a hole of a connected component, it + is still put at the top level. */ + RETR_CCOMP = 2, + /** retrieves all of the contours and reconstructs a full hierarchy of nested contours.*/ + RETR_TREE = 3, + RETR_FLOODFILL = 4 //!< +}; + +//! the contour approximation algorithm +enum ContourApproximationModes { + /** stores absolutely all the contour points. That is, any 2 subsequent points (x1,y1) and + (x2,y2) of the contour will be either horizontal, vertical or diagonal neighbors, that is, + max(abs(x1-x2),abs(y2-y1))==1. */ + CHAIN_APPROX_NONE = 1, + /** compresses horizontal, vertical, and diagonal segments and leaves only their end points. + For example, an up-right rectangular contour is encoded with 4 points. */ + CHAIN_APPROX_SIMPLE = 2, + /** applies one of the flavors of the Teh-Chin chain approximation algorithm @cite TehChin89 */ + CHAIN_APPROX_TC89_L1 = 3, + /** applies one of the flavors of the Teh-Chin chain approximation algorithm @cite TehChin89 */ + CHAIN_APPROX_TC89_KCOS = 4 +}; + +/** @brief Shape matching methods + +\f$A\f$ denotes object1,\f$B\f$ denotes object2 + +\f$\begin{array}{l} m^A_i = \mathrm{sign} (h^A_i) \cdot \log{h^A_i} \\ m^B_i = \mathrm{sign} (h^B_i) \cdot \log{h^B_i} \end{array}\f$ + +and \f$h^A_i, h^B_i\f$ are the Hu moments of \f$A\f$ and \f$B\f$ , respectively. +*/ +enum ShapeMatchModes { + CONTOURS_MATCH_I1 =1, //!< \f[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\f] + CONTOURS_MATCH_I2 =2, //!< \f[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\f] + CONTOURS_MATCH_I3 =3 //!< \f[I_3(A,B) = \max _{i=1...7} \frac{ \left| m^A_i - m^B_i \right| }{ \left| m^A_i \right| }\f] +}; + +//! @} imgproc_shape + +//! @addtogroup imgproc_feature +//! @{ + +//! Variants of a Hough transform +enum HoughModes { + + /** classical or standard Hough transform. Every line is represented by two floating-point + numbers \f$(\rho, \theta)\f$ , where \f$\rho\f$ is a distance between (0,0) point and the line, + and \f$\theta\f$ is the angle between x-axis and the normal to the line. Thus, the matrix must + be (the created sequence will be) of CV_32FC2 type */ + HOUGH_STANDARD = 0, + /** probabilistic Hough transform (more efficient in case if the picture contains a few long + linear segments). It returns line segments rather than the whole line. Each segment is + represented by starting and ending points, and the matrix must be (the created sequence will + be) of the CV_32SC4 type. */ + HOUGH_PROBABILISTIC = 1, + /** multi-scale variant of the classical Hough transform. The lines are encoded the same way as + HOUGH_STANDARD. */ + HOUGH_MULTI_SCALE = 2, + HOUGH_GRADIENT = 3, //!< basically *21HT*, described in @cite Yuen90 + HOUGH_GRADIENT_ALT = 4, //!< variation of HOUGH_GRADIENT to get better accuracy +}; + +//! Variants of Line Segment %Detector +enum LineSegmentDetectorModes { + LSD_REFINE_NONE = 0, //!< No refinement applied + LSD_REFINE_STD = 1, //!< Standard refinement is applied. E.g. breaking arches into smaller straighter line approximations. + LSD_REFINE_ADV = 2 //!< Advanced refinement. Number of false alarms is calculated, lines are + //!< refined through increase of precision, decrement in size, etc. +}; + +//! @} imgproc_feature + +/** Histogram comparison methods + @ingroup imgproc_hist +*/ +enum HistCompMethods { + /** Correlation + \f[d(H_1,H_2) = \frac{\sum_I (H_1(I) - \bar{H_1}) (H_2(I) - \bar{H_2})}{\sqrt{\sum_I(H_1(I) - \bar{H_1})^2 \sum_I(H_2(I) - \bar{H_2})^2}}\f] + where + \f[\bar{H_k} = \frac{1}{N} \sum _J H_k(J)\f] + and \f$N\f$ is a total number of histogram bins. */ + HISTCMP_CORREL = 0, + /** Chi-Square + \f[d(H_1,H_2) = \sum _I \frac{\left(H_1(I)-H_2(I)\right)^2}{H_1(I)}\f] */ + HISTCMP_CHISQR = 1, + /** Intersection + \f[d(H_1,H_2) = \sum _I \min (H_1(I), H_2(I))\f] */ + HISTCMP_INTERSECT = 2, + /** Bhattacharyya distance + (In fact, OpenCV computes Hellinger distance, which is related to Bhattacharyya coefficient.) + \f[d(H_1,H_2) = \sqrt{1 - \frac{1}{\sqrt{\bar{H_1} \bar{H_2} N^2}} \sum_I \sqrt{H_1(I) \cdot H_2(I)}}\f] */ + HISTCMP_BHATTACHARYYA = 3, + HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA, //!< Synonym for HISTCMP_BHATTACHARYYA + /** Alternative Chi-Square + \f[d(H_1,H_2) = 2 * \sum _I \frac{\left(H_1(I)-H_2(I)\right)^2}{H_1(I)+H_2(I)}\f] + This alternative formula is regularly used for texture comparison. See e.g. @cite Puzicha1997 */ + HISTCMP_CHISQR_ALT = 4, + /** Kullback-Leibler divergence + \f[d(H_1,H_2) = \sum _I H_1(I) \log \left(\frac{H_1(I)}{H_2(I)}\right)\f] */ + HISTCMP_KL_DIV = 5 +}; + +/** the color conversion codes +@see @ref imgproc_color_conversions +@ingroup imgproc_color_conversions + */ +enum ColorConversionCodes { + COLOR_BGR2BGRA = 0, //!< add alpha channel to RGB or BGR image + COLOR_RGB2RGBA = COLOR_BGR2BGRA, + + COLOR_BGRA2BGR = 1, //!< remove alpha channel from RGB or BGR image + COLOR_RGBA2RGB = COLOR_BGRA2BGR, + + COLOR_BGR2RGBA = 2, //!< convert between RGB and BGR color spaces (with or without alpha channel) + COLOR_RGB2BGRA = COLOR_BGR2RGBA, + + COLOR_RGBA2BGR = 3, + COLOR_BGRA2RGB = COLOR_RGBA2BGR, + + COLOR_BGR2RGB = 4, + COLOR_RGB2BGR = COLOR_BGR2RGB, + + COLOR_BGRA2RGBA = 5, + COLOR_RGBA2BGRA = COLOR_BGRA2RGBA, + + COLOR_BGR2GRAY = 6, //!< convert between RGB/BGR and grayscale, @ref color_convert_rgb_gray "color conversions" + COLOR_RGB2GRAY = 7, + COLOR_GRAY2BGR = 8, + COLOR_GRAY2RGB = COLOR_GRAY2BGR, + COLOR_GRAY2BGRA = 9, + COLOR_GRAY2RGBA = COLOR_GRAY2BGRA, + COLOR_BGRA2GRAY = 10, + COLOR_RGBA2GRAY = 11, + + COLOR_BGR2BGR565 = 12, //!< convert between RGB/BGR and BGR565 (16-bit images) + COLOR_RGB2BGR565 = 13, + COLOR_BGR5652BGR = 14, + COLOR_BGR5652RGB = 15, + COLOR_BGRA2BGR565 = 16, + COLOR_RGBA2BGR565 = 17, + COLOR_BGR5652BGRA = 18, + COLOR_BGR5652RGBA = 19, + + COLOR_GRAY2BGR565 = 20, //!< convert between grayscale to BGR565 (16-bit images) + COLOR_BGR5652GRAY = 21, + + COLOR_BGR2BGR555 = 22, //!< convert between RGB/BGR and BGR555 (16-bit images) + COLOR_RGB2BGR555 = 23, + COLOR_BGR5552BGR = 24, + COLOR_BGR5552RGB = 25, + COLOR_BGRA2BGR555 = 26, + COLOR_RGBA2BGR555 = 27, + COLOR_BGR5552BGRA = 28, + COLOR_BGR5552RGBA = 29, + + COLOR_GRAY2BGR555 = 30, //!< convert between grayscale and BGR555 (16-bit images) + COLOR_BGR5552GRAY = 31, + + COLOR_BGR2XYZ = 32, //!< convert RGB/BGR to CIE XYZ, @ref color_convert_rgb_xyz "color conversions" + COLOR_RGB2XYZ = 33, + COLOR_XYZ2BGR = 34, + COLOR_XYZ2RGB = 35, + + COLOR_BGR2YCrCb = 36, //!< convert RGB/BGR to luma-chroma (aka YCC), @ref color_convert_rgb_ycrcb "color conversions" + COLOR_RGB2YCrCb = 37, + COLOR_YCrCb2BGR = 38, + COLOR_YCrCb2RGB = 39, + + COLOR_BGR2HSV = 40, //!< convert RGB/BGR to HSV (hue saturation value) with H range 0..180 if 8 bit image, @ref color_convert_rgb_hsv "color conversions" + COLOR_RGB2HSV = 41, + + COLOR_BGR2Lab = 44, //!< convert RGB/BGR to CIE Lab, @ref color_convert_rgb_lab "color conversions" + COLOR_RGB2Lab = 45, + + COLOR_BGR2Luv = 50, //!< convert RGB/BGR to CIE Luv, @ref color_convert_rgb_luv "color conversions" + COLOR_RGB2Luv = 51, + COLOR_BGR2HLS = 52, //!< convert RGB/BGR to HLS (hue lightness saturation) with H range 0..180 if 8 bit image, @ref color_convert_rgb_hls "color conversions" + COLOR_RGB2HLS = 53, + + COLOR_HSV2BGR = 54, //!< backward conversions HSV to RGB/BGR with H range 0..180 if 8 bit image + COLOR_HSV2RGB = 55, + + COLOR_Lab2BGR = 56, + COLOR_Lab2RGB = 57, + COLOR_Luv2BGR = 58, + COLOR_Luv2RGB = 59, + COLOR_HLS2BGR = 60, //!< backward conversions HLS to RGB/BGR with H range 0..180 if 8 bit image + COLOR_HLS2RGB = 61, + + COLOR_BGR2HSV_FULL = 66, //!< convert RGB/BGR to HSV (hue saturation value) with H range 0..255 if 8 bit image, @ref color_convert_rgb_hsv "color conversions" + COLOR_RGB2HSV_FULL = 67, + COLOR_BGR2HLS_FULL = 68, //!< convert RGB/BGR to HLS (hue lightness saturation) with H range 0..255 if 8 bit image, @ref color_convert_rgb_hls "color conversions" + COLOR_RGB2HLS_FULL = 69, + + COLOR_HSV2BGR_FULL = 70, //!< backward conversions HSV to RGB/BGR with H range 0..255 if 8 bit image + COLOR_HSV2RGB_FULL = 71, + COLOR_HLS2BGR_FULL = 72, //!< backward conversions HLS to RGB/BGR with H range 0..255 if 8 bit image + COLOR_HLS2RGB_FULL = 73, + + COLOR_LBGR2Lab = 74, + COLOR_LRGB2Lab = 75, + COLOR_LBGR2Luv = 76, + COLOR_LRGB2Luv = 77, + + COLOR_Lab2LBGR = 78, + COLOR_Lab2LRGB = 79, + COLOR_Luv2LBGR = 80, + COLOR_Luv2LRGB = 81, + + COLOR_BGR2YUV = 82, //!< convert between RGB/BGR and YUV + COLOR_RGB2YUV = 83, + COLOR_YUV2BGR = 84, + COLOR_YUV2RGB = 85, + + //! YUV 4:2:0 family to RGB + COLOR_YUV2RGB_NV12 = 90, + COLOR_YUV2BGR_NV12 = 91, + COLOR_YUV2RGB_NV21 = 92, + COLOR_YUV2BGR_NV21 = 93, + COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21, + COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21, + + COLOR_YUV2RGBA_NV12 = 94, + COLOR_YUV2BGRA_NV12 = 95, + COLOR_YUV2RGBA_NV21 = 96, + COLOR_YUV2BGRA_NV21 = 97, + COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21, + COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21, + + COLOR_YUV2RGB_YV12 = 98, + COLOR_YUV2BGR_YV12 = 99, + COLOR_YUV2RGB_IYUV = 100, + COLOR_YUV2BGR_IYUV = 101, + COLOR_YUV2RGB_I420 = COLOR_YUV2RGB_IYUV, + COLOR_YUV2BGR_I420 = COLOR_YUV2BGR_IYUV, + COLOR_YUV420p2RGB = COLOR_YUV2RGB_YV12, + COLOR_YUV420p2BGR = COLOR_YUV2BGR_YV12, + + COLOR_YUV2RGBA_YV12 = 102, + COLOR_YUV2BGRA_YV12 = 103, + COLOR_YUV2RGBA_IYUV = 104, + COLOR_YUV2BGRA_IYUV = 105, + COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV, + COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV, + COLOR_YUV420p2RGBA = COLOR_YUV2RGBA_YV12, + COLOR_YUV420p2BGRA = COLOR_YUV2BGRA_YV12, + + COLOR_YUV2GRAY_420 = 106, + COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420, + COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420, + COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420, + COLOR_YUV420p2GRAY = COLOR_YUV2GRAY_420, + + //! YUV 4:2:2 family to RGB + COLOR_YUV2RGB_UYVY = 107, + COLOR_YUV2BGR_UYVY = 108, + //COLOR_YUV2RGB_VYUY = 109, + //COLOR_YUV2BGR_VYUY = 110, + COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY, + COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY, + COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY, + COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY, + + COLOR_YUV2RGBA_UYVY = 111, + COLOR_YUV2BGRA_UYVY = 112, + //COLOR_YUV2RGBA_VYUY = 113, + //COLOR_YUV2BGRA_VYUY = 114, + COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY, + COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY, + COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY, + COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY, + + COLOR_YUV2RGB_YUY2 = 115, + COLOR_YUV2BGR_YUY2 = 116, + COLOR_YUV2RGB_YVYU = 117, + COLOR_YUV2BGR_YVYU = 118, + COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2, + COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2, + COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2, + COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2, + + COLOR_YUV2RGBA_YUY2 = 119, + COLOR_YUV2BGRA_YUY2 = 120, + COLOR_YUV2RGBA_YVYU = 121, + COLOR_YUV2BGRA_YVYU = 122, + COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2, + COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2, + COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2, + COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2, + + COLOR_YUV2GRAY_UYVY = 123, + COLOR_YUV2GRAY_YUY2 = 124, + //CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY, + COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY, + COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY, + COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2, + COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2, + COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2, + + //! alpha premultiplication + COLOR_RGBA2mRGBA = 125, + COLOR_mRGBA2RGBA = 126, + + //! RGB to YUV 4:2:0 family + COLOR_RGB2YUV_I420 = 127, + COLOR_BGR2YUV_I420 = 128, + COLOR_RGB2YUV_IYUV = COLOR_RGB2YUV_I420, + COLOR_BGR2YUV_IYUV = COLOR_BGR2YUV_I420, + + COLOR_RGBA2YUV_I420 = 129, + COLOR_BGRA2YUV_I420 = 130, + COLOR_RGBA2YUV_IYUV = COLOR_RGBA2YUV_I420, + COLOR_BGRA2YUV_IYUV = COLOR_BGRA2YUV_I420, + COLOR_RGB2YUV_YV12 = 131, + COLOR_BGR2YUV_YV12 = 132, + COLOR_RGBA2YUV_YV12 = 133, + COLOR_BGRA2YUV_YV12 = 134, + + //! Demosaicing, see @ref color_convert_bayer "color conversions" for additional information + COLOR_BayerBG2BGR = 46, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGR = 47, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGR = 48, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGR = 49, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGR = COLOR_BayerBG2BGR, + COLOR_BayerGRBG2BGR = COLOR_BayerGB2BGR, + COLOR_BayerBGGR2BGR = COLOR_BayerRG2BGR, + COLOR_BayerGBRG2BGR = COLOR_BayerGR2BGR, + + COLOR_BayerRGGB2RGB = COLOR_BayerBGGR2BGR, + COLOR_BayerGRBG2RGB = COLOR_BayerGBRG2BGR, + COLOR_BayerBGGR2RGB = COLOR_BayerRGGB2BGR, + COLOR_BayerGBRG2RGB = COLOR_BayerGRBG2BGR, + + COLOR_BayerBG2RGB = COLOR_BayerRG2BGR, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGB = COLOR_BayerGR2BGR, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGB = COLOR_BayerBG2BGR, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGB = COLOR_BayerGB2BGR, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerBG2GRAY = 86, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2GRAY = 87, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2GRAY = 88, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2GRAY = 89, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2GRAY = COLOR_BayerBG2GRAY, + COLOR_BayerGRBG2GRAY = COLOR_BayerGB2GRAY, + COLOR_BayerBGGR2GRAY = COLOR_BayerRG2GRAY, + COLOR_BayerGBRG2GRAY = COLOR_BayerGR2GRAY, + + //! Demosaicing using Variable Number of Gradients + COLOR_BayerBG2BGR_VNG = 62, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGR_VNG = 63, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGR_VNG = 64, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGR_VNG = 65, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGR_VNG = COLOR_BayerBG2BGR_VNG, + COLOR_BayerGRBG2BGR_VNG = COLOR_BayerGB2BGR_VNG, + COLOR_BayerBGGR2BGR_VNG = COLOR_BayerRG2BGR_VNG, + COLOR_BayerGBRG2BGR_VNG = COLOR_BayerGR2BGR_VNG, + + COLOR_BayerRGGB2RGB_VNG = COLOR_BayerBGGR2BGR_VNG, + COLOR_BayerGRBG2RGB_VNG = COLOR_BayerGBRG2BGR_VNG, + COLOR_BayerBGGR2RGB_VNG = COLOR_BayerRGGB2BGR_VNG, + COLOR_BayerGBRG2RGB_VNG = COLOR_BayerGRBG2BGR_VNG, + + COLOR_BayerBG2RGB_VNG = COLOR_BayerRG2BGR_VNG, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGB_VNG = COLOR_BayerGR2BGR_VNG, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGB_VNG = COLOR_BayerBG2BGR_VNG, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGB_VNG = COLOR_BayerGB2BGR_VNG, //!< equivalent to GBRG Bayer pattern + + //! Edge-Aware Demosaicing + COLOR_BayerBG2BGR_EA = 135, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGR_EA = 136, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGR_EA = 137, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGR_EA = 138, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGR_EA = COLOR_BayerBG2BGR_EA, + COLOR_BayerGRBG2BGR_EA = COLOR_BayerGB2BGR_EA, + COLOR_BayerBGGR2BGR_EA = COLOR_BayerRG2BGR_EA, + COLOR_BayerGBRG2BGR_EA = COLOR_BayerGR2BGR_EA, + + COLOR_BayerRGGB2RGB_EA = COLOR_BayerBGGR2BGR_EA, + COLOR_BayerGRBG2RGB_EA = COLOR_BayerGBRG2BGR_EA, + COLOR_BayerBGGR2RGB_EA = COLOR_BayerRGGB2BGR_EA, + COLOR_BayerGBRG2RGB_EA = COLOR_BayerGRBG2BGR_EA, + + COLOR_BayerBG2RGB_EA = COLOR_BayerRG2BGR_EA, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGB_EA = COLOR_BayerGR2BGR_EA, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGB_EA = COLOR_BayerBG2BGR_EA, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGB_EA = COLOR_BayerGB2BGR_EA, //!< equivalent to GBRG Bayer pattern + + //! Demosaicing with alpha channel + COLOR_BayerBG2BGRA = 139, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2BGRA = 140, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2BGRA = 141, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2BGRA = 142, //!< equivalent to GBRG Bayer pattern + + COLOR_BayerRGGB2BGRA = COLOR_BayerBG2BGRA, + COLOR_BayerGRBG2BGRA = COLOR_BayerGB2BGRA, + COLOR_BayerBGGR2BGRA = COLOR_BayerRG2BGRA, + COLOR_BayerGBRG2BGRA = COLOR_BayerGR2BGRA, + + COLOR_BayerRGGB2RGBA = COLOR_BayerBGGR2BGRA, + COLOR_BayerGRBG2RGBA = COLOR_BayerGBRG2BGRA, + COLOR_BayerBGGR2RGBA = COLOR_BayerRGGB2BGRA, + COLOR_BayerGBRG2RGBA = COLOR_BayerGRBG2BGRA, + + COLOR_BayerBG2RGBA = COLOR_BayerRG2BGRA, //!< equivalent to RGGB Bayer pattern + COLOR_BayerGB2RGBA = COLOR_BayerGR2BGRA, //!< equivalent to GRBG Bayer pattern + COLOR_BayerRG2RGBA = COLOR_BayerBG2BGRA, //!< equivalent to BGGR Bayer pattern + COLOR_BayerGR2RGBA = COLOR_BayerGB2BGRA, //!< equivalent to GBRG Bayer pattern + + COLOR_COLORCVT_MAX = 143 +}; + +//! @addtogroup imgproc_shape +//! @{ + +//! types of intersection between rectangles +enum RectanglesIntersectTypes { + INTERSECT_NONE = 0, //!< No intersection + INTERSECT_PARTIAL = 1, //!< There is a partial intersection + INTERSECT_FULL = 2 //!< One of the rectangle is fully enclosed in the other +}; + +/** types of line +@ingroup imgproc_draw +*/ +enum LineTypes { + FILLED = -1, + LINE_4 = 4, //!< 4-connected line + LINE_8 = 8, //!< 8-connected line + LINE_AA = 16 //!< antialiased line +}; + +/** Only a subset of Hershey fonts are supported +@ingroup imgproc_draw +*/ +enum HersheyFonts { + FONT_HERSHEY_SIMPLEX = 0, //!< normal size sans-serif font + FONT_HERSHEY_PLAIN = 1, //!< small size sans-serif font + FONT_HERSHEY_DUPLEX = 2, //!< normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX) + FONT_HERSHEY_COMPLEX = 3, //!< normal size serif font + FONT_HERSHEY_TRIPLEX = 4, //!< normal size serif font (more complex than FONT_HERSHEY_COMPLEX) + FONT_HERSHEY_COMPLEX_SMALL = 5, //!< smaller version of FONT_HERSHEY_COMPLEX + FONT_HERSHEY_SCRIPT_SIMPLEX = 6, //!< hand-writing style font + FONT_HERSHEY_SCRIPT_COMPLEX = 7, //!< more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX + FONT_ITALIC = 16 //!< flag for italic font +}; + +/** Possible set of marker types used for the cv::drawMarker function +@ingroup imgproc_draw +*/ +enum MarkerTypes +{ + MARKER_CROSS = 0, //!< A crosshair marker shape + MARKER_TILTED_CROSS = 1, //!< A 45 degree tilted crosshair marker shape + MARKER_STAR = 2, //!< A star marker shape, combination of cross and tilted cross + MARKER_DIAMOND = 3, //!< A diamond marker shape + MARKER_SQUARE = 4, //!< A square marker shape + MARKER_TRIANGLE_UP = 5, //!< An upwards pointing triangle marker shape + MARKER_TRIANGLE_DOWN = 6 //!< A downwards pointing triangle marker shape +}; + +/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform +*/ +class CV_EXPORTS_W GeneralizedHough : public Algorithm +{ +public: + //! set template to search + CV_WRAP virtual void setTemplate(InputArray templ, Point templCenter = Point(-1, -1)) = 0; + CV_WRAP virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0; + + //! find template on image + CV_WRAP virtual void detect(InputArray image, OutputArray positions, OutputArray votes = noArray()) = 0; + CV_WRAP virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions, OutputArray votes = noArray()) = 0; + + //! Canny low threshold. + CV_WRAP virtual void setCannyLowThresh(int cannyLowThresh) = 0; + CV_WRAP virtual int getCannyLowThresh() const = 0; + + //! Canny high threshold. + CV_WRAP virtual void setCannyHighThresh(int cannyHighThresh) = 0; + CV_WRAP virtual int getCannyHighThresh() const = 0; + + //! Minimum distance between the centers of the detected objects. + CV_WRAP virtual void setMinDist(double minDist) = 0; + CV_WRAP virtual double getMinDist() const = 0; + + //! Inverse ratio of the accumulator resolution to the image resolution. + CV_WRAP virtual void setDp(double dp) = 0; + CV_WRAP virtual double getDp() const = 0; + + //! Maximal size of inner buffers. + CV_WRAP virtual void setMaxBufferSize(int maxBufferSize) = 0; + CV_WRAP virtual int getMaxBufferSize() const = 0; +}; + +/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform + +Detects position only without translation and rotation @cite Ballard1981 . +*/ +class CV_EXPORTS_W GeneralizedHoughBallard : public GeneralizedHough +{ +public: + //! R-Table levels. + CV_WRAP virtual void setLevels(int levels) = 0; + CV_WRAP virtual int getLevels() const = 0; + + //! The accumulator threshold for the template centers at the detection stage. The smaller it is, the more false positions may be detected. + CV_WRAP virtual void setVotesThreshold(int votesThreshold) = 0; + CV_WRAP virtual int getVotesThreshold() const = 0; +}; + +/** @brief finds arbitrary template in the grayscale image using Generalized Hough Transform + +Detects position, translation and rotation @cite Guil1999 . +*/ +class CV_EXPORTS_W GeneralizedHoughGuil : public GeneralizedHough +{ +public: + //! Angle difference in degrees between two points in feature. + CV_WRAP virtual void setXi(double xi) = 0; + CV_WRAP virtual double getXi() const = 0; + + //! Feature table levels. + CV_WRAP virtual void setLevels(int levels) = 0; + CV_WRAP virtual int getLevels() const = 0; + + //! Maximal difference between angles that treated as equal. + CV_WRAP virtual void setAngleEpsilon(double angleEpsilon) = 0; + CV_WRAP virtual double getAngleEpsilon() const = 0; + + //! Minimal rotation angle to detect in degrees. + CV_WRAP virtual void setMinAngle(double minAngle) = 0; + CV_WRAP virtual double getMinAngle() const = 0; + + //! Maximal rotation angle to detect in degrees. + CV_WRAP virtual void setMaxAngle(double maxAngle) = 0; + CV_WRAP virtual double getMaxAngle() const = 0; + + //! Angle step in degrees. + CV_WRAP virtual void setAngleStep(double angleStep) = 0; + CV_WRAP virtual double getAngleStep() const = 0; + + //! Angle votes threshold. + CV_WRAP virtual void setAngleThresh(int angleThresh) = 0; + CV_WRAP virtual int getAngleThresh() const = 0; + + //! Minimal scale to detect. + CV_WRAP virtual void setMinScale(double minScale) = 0; + CV_WRAP virtual double getMinScale() const = 0; + + //! Maximal scale to detect. + CV_WRAP virtual void setMaxScale(double maxScale) = 0; + CV_WRAP virtual double getMaxScale() const = 0; + + //! Scale step. + CV_WRAP virtual void setScaleStep(double scaleStep) = 0; + CV_WRAP virtual double getScaleStep() const = 0; + + //! Scale votes threshold. + CV_WRAP virtual void setScaleThresh(int scaleThresh) = 0; + CV_WRAP virtual int getScaleThresh() const = 0; + + //! Position votes threshold. + CV_WRAP virtual void setPosThresh(int posThresh) = 0; + CV_WRAP virtual int getPosThresh() const = 0; +}; + +//! @} imgproc_shape + +//! @addtogroup imgproc_hist +//! @{ + +/** @brief Base class for Contrast Limited Adaptive Histogram Equalization. +*/ +class CV_EXPORTS_W CLAHE : public Algorithm +{ +public: + /** @brief Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization. + + @param src Source image of type CV_8UC1 or CV_16UC1. + @param dst Destination image. + */ + CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0; + + /** @brief Sets threshold for contrast limiting. + + @param clipLimit threshold value. + */ + CV_WRAP virtual void setClipLimit(double clipLimit) = 0; + + //! Returns threshold value for contrast limiting. + CV_WRAP virtual double getClipLimit() const = 0; + + /** @brief Sets size of grid for histogram equalization. Input image will be divided into + equally sized rectangular tiles. + + @param tileGridSize defines the number of tiles in row and column. + */ + CV_WRAP virtual void setTilesGridSize(Size tileGridSize) = 0; + + //!@brief Returns Size defines the number of tiles in row and column. + CV_WRAP virtual Size getTilesGridSize() const = 0; + + CV_WRAP virtual void collectGarbage() = 0; +}; + +//! @} imgproc_hist + +//! @addtogroup imgproc_subdiv2d +//! @{ + +class CV_EXPORTS_W Subdiv2D +{ +public: + /** Subdiv2D point location cases */ + enum { PTLOC_ERROR = -2, //!< Point location error + PTLOC_OUTSIDE_RECT = -1, //!< Point outside the subdivision bounding rect + PTLOC_INSIDE = 0, //!< Point inside some facet + PTLOC_VERTEX = 1, //!< Point coincides with one of the subdivision vertices + PTLOC_ON_EDGE = 2 //!< Point on some edge + }; + + /** Subdiv2D edge type navigation (see: getEdge()) */ + enum { NEXT_AROUND_ORG = 0x00, + NEXT_AROUND_DST = 0x22, + PREV_AROUND_ORG = 0x11, + PREV_AROUND_DST = 0x33, + NEXT_AROUND_LEFT = 0x13, + NEXT_AROUND_RIGHT = 0x31, + PREV_AROUND_LEFT = 0x20, + PREV_AROUND_RIGHT = 0x02 + }; + + /** creates an empty Subdiv2D object. + To create a new empty Delaunay subdivision you need to use the #initDelaunay function. + */ + CV_WRAP Subdiv2D(); + + /** @overload + + @param rect Rectangle that includes all of the 2D points that are to be added to the subdivision. + + The function creates an empty Delaunay subdivision where 2D points can be added using the function + insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime + error is raised. + */ + CV_WRAP Subdiv2D(Rect rect); + + /** @brief Creates a new empty Delaunay subdivision + + @param rect Rectangle that includes all of the 2D points that are to be added to the subdivision. + + */ + CV_WRAP void initDelaunay(Rect rect); + + /** @brief Insert a single point into a Delaunay triangulation. + + @param pt Point to insert. + + The function inserts a single point into a subdivision and modifies the subdivision topology + appropriately. If a point with the same coordinates exists already, no new point is added. + @returns the ID of the point. + + @note If the point is outside of the triangulation specified rect a runtime error is raised. + */ + CV_WRAP int insert(Point2f pt); + + /** @brief Insert multiple points into a Delaunay triangulation. + + @param ptvec Points to insert. + + The function inserts a vector of points into a subdivision and modifies the subdivision topology + appropriately. + */ + CV_WRAP void insert(const std::vector& ptvec); + + /** @brief Returns the location of a point within a Delaunay triangulation. + + @param pt Point to locate. + @param edge Output edge that the point belongs to or is located to the right of it. + @param vertex Optional output vertex the input point coincides with. + + The function locates the input point within the subdivision and gives one of the triangle edges + or vertices. + + @returns an integer which specify one of the following five cases for point location: + - The point falls into some facet. The function returns #PTLOC_INSIDE and edge will contain one of + edges of the facet. + - The point falls onto the edge. The function returns #PTLOC_ON_EDGE and edge will contain this edge. + - The point coincides with one of the subdivision vertices. The function returns #PTLOC_VERTEX and + vertex will contain a pointer to the vertex. + - The point is outside the subdivision reference rectangle. The function returns #PTLOC_OUTSIDE_RECT + and no pointers are filled. + - One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error + processing mode is selected, #PTLOC_ERROR is returned. + */ + CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex); + + /** @brief Finds the subdivision vertex closest to the given point. + + @param pt Input point. + @param nearestPt Output subdivision vertex point. + + The function is another function that locates the input point within the subdivision. It finds the + subdivision vertex that is the closest to the input point. It is not necessarily one of vertices + of the facet containing the input point, though the facet (located using locate() ) is used as a + starting point. + + @returns vertex ID. + */ + CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt = 0); + + /** @brief Returns a list of all edges. + + @param edgeList Output vector. + + The function gives each edge as a 4 numbers vector, where each two are one of the edge + vertices. i.e. org_x = v[0], org_y = v[1], dst_x = v[2], dst_y = v[3]. + */ + CV_WRAP void getEdgeList(CV_OUT std::vector& edgeList) const; + + /** @brief Returns a list of the leading edge ID connected to each triangle. + + @param leadingEdgeList Output vector. + + The function gives one edge ID for each triangle. + */ + CV_WRAP void getLeadingEdgeList(CV_OUT std::vector& leadingEdgeList) const; + + /** @brief Returns a list of all triangles. + + @param triangleList Output vector. + + The function gives each triangle as a 6 numbers vector, where each two are one of the triangle + vertices. i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5]. + */ + CV_WRAP void getTriangleList(CV_OUT std::vector& triangleList) const; + + /** @brief Returns a list of all Voronoi facets. + + @param idx Vector of vertices IDs to consider. For all vertices you can pass empty vector. + @param facetList Output vector of the Voronoi facets. + @param facetCenters Output vector of the Voronoi facets center points. + + */ + CV_WRAP void getVoronoiFacetList(const std::vector& idx, CV_OUT std::vector >& facetList, + CV_OUT std::vector& facetCenters); + + /** @brief Returns vertex location from vertex ID. + + @param vertex vertex ID. + @param firstEdge Optional. The first edge ID which is connected to the vertex. + @returns vertex (x,y) + + */ + CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge = 0) const; + + /** @brief Returns one of the edges related to the given edge. + + @param edge Subdivision edge ID. + @param nextEdgeType Parameter specifying which of the related edges to return. + The following values are possible: + - NEXT_AROUND_ORG next around the edge origin ( eOnext on the picture below if e is the input edge) + - NEXT_AROUND_DST next around the edge vertex ( eDnext ) + - PREV_AROUND_ORG previous around the edge origin (reversed eRnext ) + - PREV_AROUND_DST previous around the edge destination (reversed eLnext ) + - NEXT_AROUND_LEFT next around the left facet ( eLnext ) + - NEXT_AROUND_RIGHT next around the right facet ( eRnext ) + - PREV_AROUND_LEFT previous around the left facet (reversed eOnext ) + - PREV_AROUND_RIGHT previous around the right facet (reversed eDnext ) + + ![sample output](pics/quadedge.png) + + @returns edge ID related to the input edge. + */ + CV_WRAP int getEdge( int edge, int nextEdgeType ) const; + + /** @brief Returns next edge around the edge origin. + + @param edge Subdivision edge ID. + + @returns an integer which is next edge ID around the edge origin: eOnext on the + picture above if e is the input edge). + */ + CV_WRAP int nextEdge(int edge) const; + + /** @brief Returns another edge of the same quad-edge. + + @param edge Subdivision edge ID. + @param rotate Parameter specifying which of the edges of the same quad-edge as the input + one to return. The following values are possible: + - 0 - the input edge ( e on the picture below if e is the input edge) + - 1 - the rotated edge ( eRot ) + - 2 - the reversed edge (reversed e (in green)) + - 3 - the reversed rotated edge (reversed eRot (in green)) + + @returns one of the edges ID of the same quad-edge as the input edge. + */ + CV_WRAP int rotateEdge(int edge, int rotate) const; + CV_WRAP int symEdge(int edge) const; + + /** @brief Returns the edge origin. + + @param edge Subdivision edge ID. + @param orgpt Output vertex location. + + @returns vertex ID. + */ + CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt = 0) const; + + /** @brief Returns the edge destination. + + @param edge Subdivision edge ID. + @param dstpt Output vertex location. + + @returns vertex ID. + */ + CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt = 0) const; + +protected: + int newEdge(); + void deleteEdge(int edge); + int newPoint(Point2f pt, bool isvirtual, int firstEdge = 0); + void deletePoint(int vtx); + void setEdgePoints( int edge, int orgPt, int dstPt ); + void splice( int edgeA, int edgeB ); + int connectEdges( int edgeA, int edgeB ); + void swapEdges( int edge ); + int isRightOf(Point2f pt, int edge) const; + void calcVoronoi(); + void clearVoronoi(); + void checkSubdiv() const; + + struct CV_EXPORTS Vertex + { + Vertex(); + Vertex(Point2f pt, bool isvirtual, int firstEdge=0); + bool isvirtual() const; + bool isfree() const; + + int firstEdge; + int type; + Point2f pt; + }; + + struct CV_EXPORTS QuadEdge + { + QuadEdge(); + QuadEdge(int edgeidx); + bool isfree() const; + + int next[4]; + int pt[4]; + }; + + //! All of the vertices + std::vector vtx; + //! All of the edges + std::vector qedges; + int freeQEdge; + int freePoint; + bool validGeometry; + + int recentEdge; + //! Top left corner of the bounding rect + Point2f topLeft; + //! Bottom right corner of the bounding rect + Point2f bottomRight; +}; + +//! @} imgproc_subdiv2d + +//! @addtogroup imgproc_feature +//! @{ + +/** @example samples/cpp/lsd_lines.cpp +An example using the LineSegmentDetector +\image html building_lsd.png "Sample output image" width=434 height=300 +*/ + +/** @brief Line segment detector class + +following the algorithm described at @cite Rafael12 . + +@note Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict. +restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license. +*/ +class CV_EXPORTS_W LineSegmentDetector : public Algorithm +{ +public: + + /** @brief Finds lines in the input image. + + This is the output of the default parameters of the algorithm on the above shown image. + + ![image](pics/building_lsd.png) + + @param image A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use: + `lsd_ptr-\>detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);` + @param lines A vector of Vec4f elements specifying the beginning and ending point of a line. Where + Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly + oriented depending on the gradient. + @param width Vector of widths of the regions, where the lines are found. E.g. Width of line. + @param prec Vector of precisions with which the lines are found. + @param nfa Vector containing number of false alarms in the line region, with precision of 10%. The + bigger the value, logarithmically better the detection. + - -1 corresponds to 10 mean false alarms + - 0 corresponds to 1 mean false alarm + - 1 corresponds to 0.1 mean false alarms + This vector will be calculated only when the objects type is #LSD_REFINE_ADV. + */ + CV_WRAP virtual void detect(InputArray image, OutputArray lines, + OutputArray width = noArray(), OutputArray prec = noArray(), + OutputArray nfa = noArray()) = 0; + + /** @brief Draws the line segments on a given image. + @param image The image, where the lines will be drawn. Should be bigger or equal to the image, + where the lines were found. + @param lines A vector of the lines that needed to be drawn. + */ + CV_WRAP virtual void drawSegments(InputOutputArray image, InputArray lines) = 0; + + /** @brief Draws two groups of lines in blue and red, counting the non overlapping (mismatching) pixels. + + @param size The size of the image, where lines1 and lines2 were found. + @param lines1 The first group of lines that needs to be drawn. It is visualized in blue color. + @param lines2 The second group of lines. They visualized in red color. + @param image Optional image, where the lines will be drawn. The image should be color(3-channel) + in order for lines1 and lines2 to be drawn in the above mentioned colors. + */ + CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray image = noArray()) = 0; + + virtual ~LineSegmentDetector() { } +}; + +/** @brief Creates a smart pointer to a LineSegmentDetector object and initializes it. + +The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want +to edit those, as to tailor it for their own application. + +@param refine The way found lines will be refined, see #LineSegmentDetectorModes +@param scale The scale of the image that will be used to find the lines. Range (0..1]. +@param sigma_scale Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale. +@param quant Bound to the quantization error on the gradient norm. +@param ang_th Gradient angle tolerance in degrees. +@param log_eps Detection threshold: -log10(NFA) \> log_eps. Used only when advance refinement is chosen. +@param density_th Minimal density of aligned region points in the enclosing rectangle. +@param n_bins Number of bins in pseudo-ordering of gradient modulus. + */ +CV_EXPORTS_W Ptr createLineSegmentDetector( + int refine = LSD_REFINE_STD, double scale = 0.8, + double sigma_scale = 0.6, double quant = 2.0, double ang_th = 22.5, + double log_eps = 0, double density_th = 0.7, int n_bins = 1024); + +//! @} imgproc_feature + +//! @addtogroup imgproc_filter +//! @{ + +/** @brief Returns Gaussian filter coefficients. + +The function computes and returns the \f$\texttt{ksize} \times 1\f$ matrix of Gaussian filter +coefficients: + +\f[G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)},\f] + +where \f$i=0..\texttt{ksize}-1\f$ and \f$\alpha\f$ is the scale factor chosen so that \f$\sum_i G_i=1\f$. + +Two of such generated kernels can be passed to sepFilter2D. Those functions automatically recognize +smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly. +You may also use the higher-level GaussianBlur. +@param ksize Aperture size. It should be odd ( \f$\texttt{ksize} \mod 2 = 1\f$ ) and positive. +@param sigma Gaussian standard deviation. If it is non-positive, it is computed from ksize as +`sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8`. +@param ktype Type of filter coefficients. It can be CV_32F or CV_64F . +@sa sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur + */ +CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F ); + +/** @brief Returns filter coefficients for computing spatial image derivatives. + +The function computes and returns the filter coefficients for spatial image derivatives. When +`ksize=FILTER_SCHARR`, the Scharr \f$3 \times 3\f$ kernels are generated (see #Scharr). Otherwise, Sobel +kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to + +@param kx Output matrix of row filter coefficients. It has the type ktype . +@param ky Output matrix of column filter coefficients. It has the type ktype . +@param dx Derivative order in respect of x. +@param dy Derivative order in respect of y. +@param ksize Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7. +@param normalize Flag indicating whether to normalize (scale down) the filter coefficients or not. +Theoretically, the coefficients should have the denominator \f$=2^{ksize*2-dx-dy-2}\f$. If you are +going to filter floating-point images, you are likely to use the normalized kernels. But if you +compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve +all the fractional bits, you may want to set normalize=false . +@param ktype Type of filter coefficients. It can be CV_32f or CV_64F . + */ +CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky, + int dx, int dy, int ksize, + bool normalize = false, int ktype = CV_32F ); + +/** @brief Returns Gabor filter coefficients. + +For more details about gabor filter equations and parameters, see: [Gabor +Filter](http://en.wikipedia.org/wiki/Gabor_filter). + +@param ksize Size of the filter returned. +@param sigma Standard deviation of the gaussian envelope. +@param theta Orientation of the normal to the parallel stripes of a Gabor function. +@param lambd Wavelength of the sinusoidal factor. +@param gamma Spatial aspect ratio. +@param psi Phase offset. +@param ktype Type of filter coefficients. It can be CV_32F or CV_64F . + */ +CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd, + double gamma, double psi = CV_PI*0.5, int ktype = CV_64F ); + +//! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation. +static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); } + +/** @brief Returns a structuring element of the specified size and shape for morphological operations. + +The function constructs and returns the structuring element that can be further passed to #erode, +#dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as +the structuring element. + +@param shape Element shape that could be one of #MorphShapes +@param ksize Size of the structuring element. +@param anchor Anchor position within the element. The default value \f$(-1, -1)\f$ means that the +anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor +position. In other cases the anchor just regulates how much the result of the morphological +operation is shifted. + */ +CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1)); + +/** @example samples/cpp/tutorial_code/ImgProc/Smoothing/Smoothing.cpp +Sample code for simple filters +![Sample screenshot](Smoothing_Tutorial_Result_Median_Filter.jpg) +Check @ref tutorial_gausian_median_blur_bilateral_filter "the corresponding tutorial" for more details + */ + +/** @brief Blurs an image using the median filter. + +The function smoothes an image using the median filter with the \f$\texttt{ksize} \times +\texttt{ksize}\f$ aperture. Each channel of a multi-channel image is processed independently. +In-place operation is supported. + +@note The median filter uses #BORDER_REPLICATE internally to cope with border pixels, see #BorderTypes + +@param src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be +CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U. +@param dst destination array of the same size and type as src. +@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ... +@sa bilateralFilter, blur, boxFilter, GaussianBlur + */ +CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize ); + +/** @brief Blurs an image using a Gaussian filter. + +The function convolves the source image with the specified Gaussian kernel. In-place filtering is +supported. + +@param src input image; the image can have any number of channels, which are processed +independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param ksize Gaussian kernel size. ksize.width and ksize.height can differ but they both must be +positive and odd. Or, they can be zero's and then they are computed from sigma. +@param sigmaX Gaussian kernel standard deviation in X direction. +@param sigmaY Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be +equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, +respectively (see #getGaussianKernel for details); to fully control the result regardless of +possible future modifications of all this semantics, it is recommended to specify all of ksize, +sigmaX, and sigmaY. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. + +@sa sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur + */ +CV_EXPORTS_W void GaussianBlur( InputArray src, OutputArray dst, Size ksize, + double sigmaX, double sigmaY = 0, + int borderType = BORDER_DEFAULT ); + +/** @brief Applies the bilateral filter to an image. + +The function applies bilateral filtering to the input image, as described in +http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html +bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is +very slow compared to most filters. + +_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\< +10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very +strong effect, making the image look "cartoonish". + +_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time +applications, and perhaps d=9 for offline applications that need heavy noise filtering. + +This filter does not work inplace. +@param src Source 8-bit or floating-point, 1-channel or 3-channel image. +@param dst Destination image of the same size and type as src . +@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, +it is computed from sigmaSpace. +@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that +farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting +in larger areas of semi-equal color. +@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that +farther pixels will influence each other as long as their colors are close enough (see sigmaColor +). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is +proportional to sigmaSpace. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes + */ +CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d, + double sigmaColor, double sigmaSpace, + int borderType = BORDER_DEFAULT ); + +/** @brief Blurs an image using the box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\f] + +where + +\f[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\f] + +Unnormalized box filter is useful for computing various integral characteristics over each pixel +neighborhood, such as covariance matrices of image derivatives (used in dense optical flow +algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral. + +@param src input image. +@param dst output image of the same size and type as src. +@param ddepth the output image depth (-1 to use src.depth()). +@param ksize blurring kernel size. +@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel +center. +@param normalize flag, specifying whether the kernel is normalized by its area or not. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. +@sa blur, bilateralFilter, GaussianBlur, medianBlur, integral + */ +CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth, + Size ksize, Point anchor = Point(-1,-1), + bool normalize = true, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates the normalized sum of squares of the pixel values overlapping the filter. + +For every pixel \f$ (x, y) \f$ in the source image, the function calculates the sum of squares of those neighboring +pixel values which overlap the filter placed over the pixel \f$ (x, y) \f$. + +The unnormalized square box filter can be useful in computing local image statistics such as the the local +variance and standard deviation around the neighborhood of a pixel. + +@param src input image +@param dst output image of the same size and type as src +@param ddepth the output image depth (-1 to use src.depth()) +@param ksize kernel size +@param anchor kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel +center. +@param normalize flag, specifying whether the kernel is to be normalized by it's area or not. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. +@sa boxFilter +*/ +CV_EXPORTS_W void sqrBoxFilter( InputArray src, OutputArray dst, int ddepth, + Size ksize, Point anchor = Point(-1, -1), + bool normalize = true, + int borderType = BORDER_DEFAULT ); + +/** @brief Blurs an image using the normalized box filter. + +The function smooths an image using the kernel: + +\f[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\f] + +The call `blur(src, dst, ksize, anchor, borderType)` is equivalent to `boxFilter(src, dst, src.type(), ksize, +anchor, true, borderType)`. + +@param src input image; it can have any number of channels, which are processed independently, but +the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param ksize blurring kernel size. +@param anchor anchor point; default value Point(-1,-1) means that the anchor is at the kernel +center. +@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. +@sa boxFilter, bilateralFilter, GaussianBlur, medianBlur + */ +CV_EXPORTS_W void blur( InputArray src, OutputArray dst, + Size ksize, Point anchor = Point(-1,-1), + int borderType = BORDER_DEFAULT ); + +/** @brief Convolves an image with the kernel. + +The function applies an arbitrary linear filter to an image. In-place operation is supported. When +the aperture is partially outside the image, the function interpolates outlier pixel values +according to the specified border mode. + +The function does actually compute correlation, not the convolution: + +\f[\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\f] + +That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip +the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - +anchor.y - 1)`. + +The function uses the DFT-based algorithm in case of sufficiently large kernels (~`11 x 11` or +larger) and the direct algorithm for small kernels. + +@param src input image. +@param dst output image of the same size and the same number of channels as src. +@param ddepth desired depth of the destination image, see @ref filter_depths "combinations" +@param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point +matrix; if you want to apply different kernels to different channels, split the image into +separate color planes using split and process them individually. +@param anchor anchor of the kernel that indicates the relative position of a filtered point within +the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor +is at the kernel center. +@param delta optional value added to the filtered pixels before storing them in dst. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa sepFilter2D, dft, matchTemplate + */ +CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth, + InputArray kernel, Point anchor = Point(-1,-1), + double delta = 0, int borderType = BORDER_DEFAULT ); + +/** @brief Applies a separable linear filter to an image. + +The function applies a separable linear filter to the image. That is, first, every row of src is +filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D +kernel kernelY. The final result shifted by delta is stored in dst . + +@param src Source image. +@param dst Destination image of the same size and the same number of channels as src . +@param ddepth Destination image depth, see @ref filter_depths "combinations" +@param kernelX Coefficients for filtering each row. +@param kernelY Coefficients for filtering each column. +@param anchor Anchor position within the kernel. The default value \f$(-1,-1)\f$ means that the anchor +is at the kernel center. +@param delta Value added to the filtered results before storing them. +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa filter2D, Sobel, GaussianBlur, boxFilter, blur + */ +CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth, + InputArray kernelX, InputArray kernelY, + Point anchor = Point(-1,-1), + double delta = 0, int borderType = BORDER_DEFAULT ); + +/** @example samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp +Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector +![Sample screenshot](Sobel_Derivatives_Tutorial_Result.jpg) +Check @ref tutorial_sobel_derivatives "the corresponding tutorial" for more details +*/ + +/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. + +In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to +calculate the derivative. When \f$\texttt{ksize = 1}\f$, the \f$3 \times 1\f$ or \f$1 \times 3\f$ +kernel is used (that is, no Gaussian smoothing is done). `ksize = 1` can only be used for the first +or the second x- or y- derivatives. + +There is also the special value `ksize = #FILTER_SCHARR (-1)` that corresponds to the \f$3\times3\f$ Scharr +filter that may give more accurate results than the \f$3\times3\f$ Sobel. The Scharr aperture is + +\f[\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\f] + +for the x-derivative, or transposed for the y-derivative. + +The function calculates an image derivative by convolving the image with the appropriate kernel: + +\f[\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\f] + +The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less +resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) +or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first +case corresponds to a kernel of: + +\f[\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\f] + +The second case corresponds to a kernel of: + +\f[\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\f] + +@param src input image. +@param dst output image of the same size and the same number of channels as src . +@param ddepth output image depth, see @ref filter_depths "combinations"; in the case of + 8-bit input images it will result in truncated derivatives. +@param dx order of the derivative x. +@param dy order of the derivative y. +@param ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see #getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar + */ +CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth, + int dx, int dy, int ksize = 3, + double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates the first order image derivative in both x and y using a Sobel operator + +Equivalent to calling: + +@code +Sobel( src, dx, CV_16SC1, 1, 0, 3 ); +Sobel( src, dy, CV_16SC1, 0, 1, 3 ); +@endcode + +@param src input image. +@param dx output image with first-order derivative in x. +@param dy output image with first-order derivative in y. +@param ksize size of Sobel kernel. It must be 3. +@param borderType pixel extrapolation method, see #BorderTypes. + Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported. + +@sa Sobel + */ + +CV_EXPORTS_W void spatialGradient( InputArray src, OutputArray dx, + OutputArray dy, int ksize = 3, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates the first x- or y- image derivative using Scharr operator. + +The function computes the first x- or y- spatial image derivative using the Scharr operator. The +call + +\f[\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\f] + +is equivalent to + +\f[\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\f] + +@param src input image. +@param dst output image of the same size and the same number of channels as src. +@param ddepth output image depth, see @ref filter_depths "combinations" +@param dx order of the derivative x. +@param dy order of the derivative y. +@param scale optional scale factor for the computed derivative values; by default, no scaling is +applied (see #getDerivKernels for details). +@param delta optional delta value that is added to the results prior to storing them in dst. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa cartToPolar + */ +CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth, + int dx, int dy, double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT ); + +/** @example samples/cpp/laplace.cpp +An example using Laplace transformations for edge detection +*/ + +/** @brief Calculates the Laplacian of an image. + +The function calculates the Laplacian of the source image by adding up the second x and y +derivatives calculated using the Sobel operator: + +\f[\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\f] + +This is done when `ksize > 1`. When `ksize == 1`, the Laplacian is computed by filtering the image +with the following \f$3 \times 3\f$ aperture: + +\f[\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\f] + +@param src Source image. +@param dst Destination image of the same size and the same number of channels as src . +@param ddepth Desired depth of the destination image. +@param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for +details. The size must be positive and odd. +@param scale Optional scale factor for the computed Laplacian values. By default, no scaling is +applied. See #getDerivKernels for details. +@param delta Optional delta value that is added to the results prior to storing them in dst . +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@sa Sobel, Scharr + */ +CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth, + int ksize = 1, double scale = 1, double delta = 0, + int borderType = BORDER_DEFAULT ); + +//! @} imgproc_filter + +//! @addtogroup imgproc_feature +//! @{ + +/** @example samples/cpp/edge.cpp +This program demonstrates usage of the Canny edge detector + +Check @ref tutorial_canny_detector "the corresponding tutorial" for more details +*/ + +/** @brief Finds edges in an image using the Canny algorithm @cite Canny86 . + +The function finds edges in the input image and marks them in the output map edges using the +Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The +largest value is used to find initial segments of strong edges. See + + +@param image 8-bit input image. +@param edges output edge map; single channels 8-bit image, which has the same size as image . +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param apertureSize aperture size for the Sobel operator. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). + */ +CV_EXPORTS_W void Canny( InputArray image, OutputArray edges, + double threshold1, double threshold2, + int apertureSize = 3, bool L2gradient = false ); + +/** \overload + +Finds edges in an image using the Canny algorithm with custom image gradient. + +@param dx 16-bit x derivative of input image (CV_16SC1 or CV_16SC3). +@param dy 16-bit y derivative of input image (same type as dx). +@param edges output edge map; single channels 8-bit image, which has the same size as image . +@param threshold1 first threshold for the hysteresis procedure. +@param threshold2 second threshold for the hysteresis procedure. +@param L2gradient a flag, indicating whether a more accurate \f$L_2\f$ norm +\f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( +L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( +L2gradient=false ). + */ +CV_EXPORTS_W void Canny( InputArray dx, InputArray dy, + OutputArray edges, + double threshold1, double threshold2, + bool L2gradient = false ); + +/** @brief Calculates the minimal eigenvalue of gradient matrices for corner detection. + +The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal +eigenvalue of the covariance matrix of derivatives, that is, \f$\min(\lambda_1, \lambda_2)\f$ in terms +of the formulae in the cornerEigenValsAndVecs description. + +@param src Input single-channel 8-bit or floating-point image. +@param dst Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as +src . +@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ). +@param ksize Aperture parameter for the Sobel operator. +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + */ +CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst, + int blockSize, int ksize = 3, + int borderType = BORDER_DEFAULT ); + +/** @brief Harris corner detector. + +The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and +cornerEigenValsAndVecs , for each pixel \f$(x, y)\f$ it calculates a \f$2\times2\f$ gradient covariance +matrix \f$M^{(x,y)}\f$ over a \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood. Then, it +computes the following characteristic: + +\f[\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\f] + +Corners in the image can be found as the local maxima of this response map. + +@param src Input single-channel 8-bit or floating-point image. +@param dst Image to store the Harris detector responses. It has the type CV_32FC1 and the same +size as src . +@param blockSize Neighborhood size (see the details on #cornerEigenValsAndVecs ). +@param ksize Aperture parameter for the Sobel operator. +@param k Harris detector free parameter. See the formula above. +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + */ +CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize, + int ksize, double k, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates eigenvalues and eigenvectors of image blocks for corner detection. + +For every pixel \f$p\f$ , the function cornerEigenValsAndVecs considers a blockSize \f$\times\f$ blockSize +neighborhood \f$S(p)\f$ . It calculates the covariation matrix of derivatives over the neighborhood as: + +\f[M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}\f] + +where the derivatives are computed using the Sobel operator. + +After that, it finds eigenvectors and eigenvalues of \f$M\f$ and stores them in the destination image as +\f$(\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\f$ where + +- \f$\lambda_1, \lambda_2\f$ are the non-sorted eigenvalues of \f$M\f$ +- \f$x_1, y_1\f$ are the eigenvectors corresponding to \f$\lambda_1\f$ +- \f$x_2, y_2\f$ are the eigenvectors corresponding to \f$\lambda_2\f$ + +The output of the function can be used for robust edge or corner detection. + +@param src Input single-channel 8-bit or floating-point image. +@param dst Image to store the results. It has the same size as src and the type CV_32FC(6) . +@param blockSize Neighborhood size (see details below). +@param ksize Aperture parameter for the Sobel operator. +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + +@sa cornerMinEigenVal, cornerHarris, preCornerDetect + */ +CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst, + int blockSize, int ksize, + int borderType = BORDER_DEFAULT ); + +/** @brief Calculates a feature map for corner detection. + +The function calculates the complex spatial derivative-based function of the source image + +\f[\texttt{dst} = (D_x \texttt{src} )^2 \cdot D_{yy} \texttt{src} + (D_y \texttt{src} )^2 \cdot D_{xx} \texttt{src} - 2 D_x \texttt{src} \cdot D_y \texttt{src} \cdot D_{xy} \texttt{src}\f] + +where \f$D_x\f$,\f$D_y\f$ are the first image derivatives, \f$D_{xx}\f$,\f$D_{yy}\f$ are the second image +derivatives, and \f$D_{xy}\f$ is the mixed derivative. + +The corners can be found as local maximums of the functions, as shown below: +@code + Mat corners, dilated_corners; + preCornerDetect(image, corners, 3); + // dilation with 3x3 rectangular structuring element + dilate(corners, dilated_corners, Mat(), 1); + Mat corner_mask = corners == dilated_corners; +@endcode + +@param src Source single-channel 8-bit of floating-point image. +@param dst Output image that has the type CV_32F and the same size as src . +@param ksize %Aperture size of the Sobel . +@param borderType Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. + */ +CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize, + int borderType = BORDER_DEFAULT ); + +/** @brief Refines the corner locations. + +The function iterates to find the sub-pixel accurate location of corners or radial saddle +points as described in @cite forstner1987fast, and as shown on the figure below. + +![image](pics/cornersubpix.png) + +Sub-pixel accurate corner locator is based on the observation that every vector from the center \f$q\f$ +to a point \f$p\f$ located within a neighborhood of \f$q\f$ is orthogonal to the image gradient at \f$p\f$ +subject to image and measurement noise. Consider the expression: + +\f[\epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)\f] + +where \f${DI_{p_i}}\f$ is an image gradient at one of the points \f$p_i\f$ in a neighborhood of \f$q\f$ . The +value of \f$q\f$ is to be found so that \f$\epsilon_i\f$ is minimized. A system of equations may be set up +with \f$\epsilon_i\f$ set to zero: + +\f[\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) \cdot q - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)\f] + +where the gradients are summed within a neighborhood ("search window") of \f$q\f$ . Calling the first +gradient term \f$G\f$ and the second gradient term \f$b\f$ gives: + +\f[q = G^{-1} \cdot b\f] + +The algorithm sets the center of the neighborhood window at this new center \f$q\f$ and then iterates +until the center stays within a set threshold. + +@param image Input single-channel, 8-bit or float image. +@param corners Initial coordinates of the input corners and refined coordinates provided for +output. +@param winSize Half of the side length of the search window. For example, if winSize=Size(5,5) , +then a \f$(5*2+1) \times (5*2+1) = 11 \times 11\f$ search window is used. +@param zeroZone Half of the size of the dead region in the middle of the search zone over which +the summation in the formula below is not done. It is used sometimes to avoid possible +singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such +a size. +@param criteria Criteria for termination of the iterative process of corner refinement. That is, +the process of corner position refinement stops either after criteria.maxCount iterations or when +the corner position moves by less than criteria.epsilon on some iteration. + */ +CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners, + Size winSize, Size zeroZone, + TermCriteria criteria ); + +/** @brief Determines strong corners on an image. + +The function finds the most prominent corners in the image or in the specified image region, as +described in @cite Shi94 + +- Function calculates the corner quality measure at every source image pixel using the + #cornerMinEigenVal or #cornerHarris . +- Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are + retained). +- The corners with the minimal eigenvalue less than + \f$\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\f$ are rejected. +- The remaining corners are sorted by the quality measure in the descending order. +- Function throws away each corner for which there is a stronger corner at a distance less than + maxDistance. + +The function can be used to initialize a point-based tracker of an object. + +@note If the function is called with different values A and B of the parameter qualityLevel , and +A \> B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector +with qualityLevel=B . + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param corners Output vector of detected corners. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Optional region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + +@sa cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform, + */ + +CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask = noArray(), int blockSize = 3, + bool useHarrisDetector = false, double k = 0.04 ); + +CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask, int blockSize, + int gradientSize, bool useHarrisDetector = false, + double k = 0.04 ); + +/** @brief Same as above, but returns also quality measure of the detected corners. + +@param image Input 8-bit or floating-point 32-bit, single-channel image. +@param corners Output vector of detected corners. +@param maxCorners Maximum number of corners to return. If there are more corners than are found, +the strongest of them is returned. `maxCorners <= 0` implies that no limit on the maximum is set +and all detected corners are returned. +@param qualityLevel Parameter characterizing the minimal accepted quality of image corners. The +parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue +(see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the +quality measure less than the product are rejected. For example, if the best corner has the +quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure +less than 15 are rejected. +@param minDistance Minimum possible Euclidean distance between the returned corners. +@param mask Region of interest. If the image is not empty (it needs to have the type +CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. +@param cornersQuality Output vector of quality measure of the detected corners. +@param blockSize Size of an average block for computing a derivative covariation matrix over each +pixel neighborhood. See cornerEigenValsAndVecs . +@param gradientSize Aperture parameter for the Sobel operator used for derivatives computation. +See cornerEigenValsAndVecs . +@param useHarrisDetector Parameter indicating whether to use a Harris detector (see #cornerHarris) +or #cornerMinEigenVal. +@param k Free parameter of the Harris detector. + */ +CV_EXPORTS CV_WRAP_AS(goodFeaturesToTrackWithQuality) void goodFeaturesToTrack( + InputArray image, OutputArray corners, + int maxCorners, double qualityLevel, double minDistance, + InputArray mask, OutputArray cornersQuality, int blockSize = 3, + int gradientSize = 3, bool useHarrisDetector = false, double k = 0.04); + +/** @example samples/cpp/tutorial_code/ImgTrans/houghlines.cpp +An example using the Hough line detector +![Sample input image](Hough_Lines_Tutorial_Original_Image.jpg) ![Output image](Hough_Lines_Tutorial_Result.jpg) +*/ + +/** @brief Finds lines in a binary image using the standard Hough transform. + +The function implements the standard or standard multi-scale Hough transform algorithm for line +detection. See for a good explanation of Hough +transform. + +@param image 8-bit, single-channel binary source image. The image may be modified by the function. +@param lines Output vector of lines. Each line is represented by a 2 or 3 element vector +\f$(\rho, \theta)\f$ or \f$(\rho, \theta, \textrm{votes})\f$ . \f$\rho\f$ is the distance from the coordinate origin \f$(0,0)\f$ (top-left corner of +the image). \f$\theta\f$ is the line rotation angle in radians ( +\f$0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\f$ ). +\f$\textrm{votes}\f$ is the value of accumulator. +@param rho Distance resolution of the accumulator in pixels. +@param theta Angle resolution of the accumulator in radians. +@param threshold Accumulator threshold parameter. Only those lines are returned that get enough +votes ( \f$>\texttt{threshold}\f$ ). +@param srn For the multi-scale Hough transform, it is a divisor for the distance resolution rho . +The coarse accumulator distance resolution is rho and the accurate accumulator resolution is +rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these +parameters should be positive. +@param stn For the multi-scale Hough transform, it is a divisor for the distance resolution theta. +@param min_theta For standard and multi-scale Hough transform, minimum angle to check for lines. +Must fall between 0 and max_theta. +@param max_theta For standard and multi-scale Hough transform, maximum angle to check for lines. +Must fall between min_theta and CV_PI. + */ +CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double srn = 0, double stn = 0, + double min_theta = 0, double max_theta = CV_PI ); + +/** @brief Finds line segments in a binary image using the probabilistic Hough transform. + +The function implements the probabilistic Hough transform algorithm for line detection, described +in @cite Matas00 + +See the line detection example below: +@include snippets/imgproc_HoughLinesP.cpp +This is a sample picture the function parameters have been tuned for: + +![image](pics/building.jpg) + +And this is the output of the above program in case of the probabilistic Hough transform: + +![image](pics/houghp.png) + +@param image 8-bit, single-channel binary source image. The image may be modified by the function. +@param lines Output vector of lines. Each line is represented by a 4-element vector +\f$(x_1, y_1, x_2, y_2)\f$ , where \f$(x_1,y_1)\f$ and \f$(x_2, y_2)\f$ are the ending points of each detected +line segment. +@param rho Distance resolution of the accumulator in pixels. +@param theta Angle resolution of the accumulator in radians. +@param threshold Accumulator threshold parameter. Only those lines are returned that get enough +votes ( \f$>\texttt{threshold}\f$ ). +@param minLineLength Minimum line length. Line segments shorter than that are rejected. +@param maxLineGap Maximum allowed gap between points on the same line to link them. + +@sa LineSegmentDetector + */ +CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double minLineLength = 0, double maxLineGap = 0 ); + +/** @brief Finds lines in a set of points using the standard Hough transform. + +The function finds lines in a set of points using a modification of the Hough transform. +@include snippets/imgproc_HoughLinesPointSet.cpp +@param point Input vector of points. Each vector must be encoded as a Point vector \f$(x,y)\f$. Type must be CV_32FC2 or CV_32SC2. +@param lines Output vector of found lines. Each vector is encoded as a vector \f$(votes, rho, theta)\f$. +The larger the value of 'votes', the higher the reliability of the Hough line. +@param lines_max Max count of Hough lines. +@param threshold Accumulator threshold parameter. Only those lines are returned that get enough +votes ( \f$>\texttt{threshold}\f$ ). +@param min_rho Minimum value for \f$\rho\f$ for the accumulator (Note: \f$\rho\f$ can be negative. The absolute value \f$|\rho|\f$ is the distance of a line to the origin.). +@param max_rho Maximum value for \f$\rho\f$ for the accumulator. +@param rho_step Distance resolution of the accumulator. +@param min_theta Minimum angle value of the accumulator in radians. +@param max_theta Maximum angle value of the accumulator in radians. +@param theta_step Angle resolution of the accumulator in radians. + */ +CV_EXPORTS_W void HoughLinesPointSet( InputArray point, OutputArray lines, int lines_max, int threshold, + double min_rho, double max_rho, double rho_step, + double min_theta, double max_theta, double theta_step ); + +/** @example samples/cpp/tutorial_code/ImgTrans/houghcircles.cpp +An example using the Hough circle detector +*/ + +/** @brief Finds circles in a grayscale image using the Hough transform. + +The function finds circles in a grayscale image using a modification of the Hough transform. + +Example: : +@include snippets/imgproc_HoughLinesCircles.cpp + +@note Usually the function detects the centers of circles well. However, it may fail to find correct +radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if +you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number +to return centers only without radius search, and find the correct radius using an additional procedure. + +It also helps to smooth image a bit unless it's already soft. For example, +GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help. + +@param image 8-bit, single-channel, grayscale input image. +@param circles Output vector of found circles. Each vector is encoded as 3 or 4 element +floating-point vector \f$(x, y, radius)\f$ or \f$(x, y, radius, votes)\f$ . +@param method Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT. +@param dp Inverse ratio of the accumulator resolution to the image resolution. For example, if +dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has +half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, +unless some small very circles need to be detected. +@param minDist Minimum distance between the centers of the detected circles. If the parameter is +too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is +too large, some circles may be missed. +@param param1 First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, +it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). +Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value +shough normally be higher, such as 300 or normally exposed and contrasty images. +@param param2 Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the +accumulator threshold for the circle centers at the detection stage. The smaller it is, the more +false circles may be detected. Circles, corresponding to the larger accumulator values, will be +returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. +The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. +If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. +But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles. +@param minRadius Minimum circle radius. +@param maxRadius Maximum circle radius. If <= 0, uses the maximum image dimension. If < 0, #HOUGH_GRADIENT returns +centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. + +@sa fitEllipse, minEnclosingCircle + */ +CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles, + int method, double dp, double minDist, + double param1 = 100, double param2 = 100, + int minRadius = 0, int maxRadius = 0 ); + +//! @} imgproc_feature + +//! @addtogroup imgproc_filter +//! @{ + +/** @example samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp +Advanced morphology Transformations sample code +![Sample screenshot](Morphology_2_Tutorial_Result.jpg) +Check @ref tutorial_opening_closing_hats "the corresponding tutorial" for more details +*/ + +/** @brief Erodes an image by using a specific structuring element. + +The function erodes the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the minimum is taken: + +\f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In +case of multi-channel images, each channel is processed independently. + +@param src input image; the number of channels can be arbitrary, but the depth should be one of +CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular +structuring element is used. Kernel can be created using #getStructuringElement. +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times erosion is applied. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@param borderValue border value in case of a constant border +@sa dilate, morphologyEx, getStructuringElement + */ +CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel, + Point anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue() ); + +/** @example samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp +Erosion and Dilation sample code +![Sample Screenshot-Erosion](Morphology_1_Tutorial_Erosion_Result.jpg)![Sample Screenshot-Dilation](Morphology_1_Tutorial_Dilation_Result.jpg) +Check @ref tutorial_erosion_dilatation "the corresponding tutorial" for more details +*/ + +/** @brief Dilates an image by using a specific structuring element. + +The function dilates the source image using the specified structuring element that determines the +shape of a pixel neighborhood over which the maximum is taken: +\f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] + +The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In +case of multi-channel images, each channel is processed independently. + +@param src input image; the number of channels can be arbitrary, but the depth should be one of +CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst output image of the same size and type as src. +@param kernel structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular +structuring element is used. Kernel can be created using #getStructuringElement +@param anchor position of the anchor within the element; default value (-1, -1) means that the +anchor is at the element center. +@param iterations number of times dilation is applied. +@param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported. +@param borderValue border value in case of a constant border +@sa erode, morphologyEx, getStructuringElement + */ +CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel, + Point anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue() ); + +/** @brief Performs advanced morphological transformations. + +The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as +basic operations. + +Any of the operations can be done in-place. In case of multi-channel images, each channel is +processed independently. + +@param src Source image. The number of channels can be arbitrary. The depth should be one of +CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. +@param dst Destination image of the same size and type as source image. +@param op Type of a morphological operation, see #MorphTypes +@param kernel Structuring element. It can be created using #getStructuringElement. +@param anchor Anchor position with the kernel. Negative values mean that the anchor is at the +kernel center. +@param iterations Number of times erosion and dilation are applied. +@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. +@param borderValue Border value in case of a constant border. The default value has a special +meaning. +@sa dilate, erode, getStructuringElement +@note The number of iterations is the number of times erosion or dilatation operation will be applied. +For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply +successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate). + */ +CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst, + int op, InputArray kernel, + Point anchor = Point(-1,-1), int iterations = 1, + int borderType = BORDER_CONSTANT, + const Scalar& borderValue = morphologyDefaultBorderValue() ); + +//! @} imgproc_filter + +//! @addtogroup imgproc_transform +//! @{ + +/** @brief Resizes an image. + +The function resize resizes the image src down to or up to the specified size. Note that the +initial dst type or size are not taken into account. Instead, the size and type are derived from +the `src`,`dsize`,`fx`, and `fy`. If you want to resize src so that it fits the pre-created dst, +you may call the function as follows: +@code + // explicitly specify dsize=dst.size(); fx and fy will be computed from that. + resize(src, dst, dst.size(), 0, 0, interpolation); +@endcode +If you want to decimate the image by factor of 2 in each direction, you can call the function this +way: +@code + // specify fx and fy and let the function compute the destination image size. + resize(src, dst, Size(), 0.5, 0.5, interpolation); +@endcode +To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to +enlarge an image, it will generally look best with c#INTER_CUBIC (slow) or #INTER_LINEAR +(faster but still looks OK). + +@param src input image. +@param dst output image; it has the size dsize (when it is non-zero) or the size computed from +src.size(), fx, and fy; the type of dst is the same as of src. +@param dsize output image size; if it equals zero (`None` in Python), it is computed as: + \f[\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\f] + Either dsize or both fx and fy must be non-zero. +@param fx scale factor along the horizontal axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.width/src.cols}\f] +@param fy scale factor along the vertical axis; when it equals 0, it is computed as +\f[\texttt{(double)dsize.height/src.rows}\f] +@param interpolation interpolation method, see #InterpolationFlags + +@sa warpAffine, warpPerspective, remap + */ +CV_EXPORTS_W void resize( InputArray src, OutputArray dst, + Size dsize, double fx = 0, double fy = 0, + int interpolation = INTER_LINEAR ); + +/** @brief Applies an affine transformation to an image. + +The function warpAffine transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted +with #invertAffineTransform and then put in the formula above instead of M. The function cannot +operate in-place. + +@param src input image. +@param dst output image that has the size dsize and the same type as src . +@param M \f$2\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (see #InterpolationFlags) and the optional +flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (see #BorderTypes); when +borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to +the "outliers" in the source image are not modified by the function. +@param borderValue value used in case of a constant border; by default, it is 0. + +@sa warpPerspective, resize, remap, getRectSubPix, transform + */ +CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst, + InputArray M, Size dsize, + int flags = INTER_LINEAR, + int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @example samples/cpp/warpPerspective_demo.cpp +An example program shows using cv::getPerspectiveTransform and cv::warpPerspective for image warping +*/ + +/** @brief Applies a perspective transformation to an image. + +The function warpPerspective transforms the source image using the specified matrix: + +\f[\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , + \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\f] + +when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert +and then put in the formula above instead of M. The function cannot operate in-place. + +@param src input image. +@param dst output image that has the size dsize and the same type as src . +@param M \f$3\times 3\f$ transformation matrix. +@param dsize size of the output image. +@param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the +optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( +\f$\texttt{dst}\rightarrow\texttt{src}\f$ ). +@param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). +@param borderValue value used in case of a constant border; by default, it equals 0. + +@sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform + */ +CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst, + InputArray M, Size dsize, + int flags = INTER_LINEAR, + int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @brief Applies a generic geometrical transformation to an image. + +The function remap transforms the source image using the specified map: + +\f[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\f] + +where values of pixels with non-integer coordinates are computed using one of available +interpolation methods. \f$map_x\f$ and \f$map_y\f$ can be encoded as separate floating-point maps +in \f$map_1\f$ and \f$map_2\f$ respectively, or interleaved floating-point maps of \f$(x,y)\f$ in +\f$map_1\f$, or fixed-point maps created by using convertMaps. The reason you might want to +convert from floating to fixed-point representations of a map is that they can yield much faster +(\~2x) remapping operations. In the converted case, \f$map_1\f$ contains pairs (cvFloor(x), +cvFloor(y)) and \f$map_2\f$ contains indices in a table of interpolation coefficients. + +This function cannot operate in-place. + +@param src Source image. +@param dst Destination image. It has the same size as map1 and the same type as src . +@param map1 The first map of either (x,y) points or just x values having the type CV_16SC2 , +CV_32FC1, or CV_32FC2. See convertMaps for details on converting a floating point +representation to fixed-point for speed. +@param map2 The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map +if map1 is (x,y) points), respectively. +@param interpolation Interpolation method (see #InterpolationFlags). The methods #INTER_AREA +and #INTER_LINEAR_EXACT are not supported by this function. +@param borderMode Pixel extrapolation method (see #BorderTypes). When +borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that +corresponds to the "outliers" in the source image are not modified by the function. +@param borderValue Value used in case of a constant border. By default, it is 0. +@note +Due to current implementation limitations the size of an input and output images should be less than 32767x32767. + */ +CV_EXPORTS_W void remap( InputArray src, OutputArray dst, + InputArray map1, InputArray map2, + int interpolation, int borderMode = BORDER_CONSTANT, + const Scalar& borderValue = Scalar()); + +/** @brief Converts image transformation maps from one representation to another. + +The function converts a pair of maps for remap from one representation to another. The following +options ( (map1.type(), map2.type()) \f$\rightarrow\f$ (dstmap1.type(), dstmap2.type()) ) are +supported: + +- \f$\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. This is the +most frequently used conversion operation, in which the original floating-point maps (see remap ) +are converted to a more compact and much faster fixed-point representation. The first output array +contains the rounded coordinates and the second array (created only when nninterpolation=false ) +contains indices in the interpolation tables. + +- \f$\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. The same as above but +the original maps are stored in one 2-channel matrix. + +- Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same +as the originals. + +@param map1 The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 . +@param map2 The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), +respectively. +@param dstmap1 The first output map that has the type dstmap1type and the same size as src . +@param dstmap2 The second output map. +@param dstmap1type Type of the first output map that should be CV_16SC2, CV_32FC1, or +CV_32FC2 . +@param nninterpolation Flag indicating whether the fixed-point maps are used for the +nearest-neighbor or for a more complex interpolation. + +@sa remap, undistort, initUndistortRectifyMap + */ +CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2, + OutputArray dstmap1, OutputArray dstmap2, + int dstmap1type, bool nninterpolation = false ); + +/** @brief Calculates an affine matrix of 2D rotation. + +The function calculates the following matrix: + +\f[\begin{bmatrix} \alpha & \beta & (1- \alpha ) \cdot \texttt{center.x} - \beta \cdot \texttt{center.y} \\ - \beta & \alpha & \beta \cdot \texttt{center.x} + (1- \alpha ) \cdot \texttt{center.y} \end{bmatrix}\f] + +where + +\f[\begin{array}{l} \alpha = \texttt{scale} \cdot \cos \texttt{angle} , \\ \beta = \texttt{scale} \cdot \sin \texttt{angle} \end{array}\f] + +The transformation maps the rotation center to itself. If this is not the target, adjust the shift. + +@param center Center of the rotation in the source image. +@param angle Rotation angle in degrees. Positive values mean counter-clockwise rotation (the +coordinate origin is assumed to be the top-left corner). +@param scale Isotropic scale factor. + +@sa getAffineTransform, warpAffine, transform + */ +CV_EXPORTS_W Mat getRotationMatrix2D(Point2f center, double angle, double scale); + +/** @sa getRotationMatrix2D */ +CV_EXPORTS Matx23d getRotationMatrix2D_(Point2f center, double angle, double scale); + +inline +Mat getRotationMatrix2D(Point2f center, double angle, double scale) +{ + return Mat(getRotationMatrix2D_(center, angle, scale), true); +} + +/** @brief Calculates an affine transform from three pairs of the corresponding points. + +The function calculates the \f$2 \times 3\f$ matrix of an affine transform so that: + +\f[\begin{bmatrix} x'_i \\ y'_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\f] + +where + +\f[dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2\f] + +@param src Coordinates of triangle vertices in the source image. +@param dst Coordinates of the corresponding triangle vertices in the destination image. + +@sa warpAffine, transform + */ +CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] ); + +/** @brief Inverts an affine transformation. + +The function computes an inverse affine transformation represented by \f$2 \times 3\f$ matrix M: + +\f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ a_{21} & a_{22} & b_2 \end{bmatrix}\f] + +The result is also a \f$2 \times 3\f$ matrix of the same type as M. + +@param M Original affine transformation. +@param iM Output reverse affine transformation. + */ +CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM ); + +/** @brief Calculates a perspective transform from four pairs of the corresponding points. + +The function calculates the \f$3 \times 3\f$ matrix of a perspective transform so that: + +\f[\begin{bmatrix} t_i x'_i \\ t_i y'_i \\ t_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\f] + +where + +\f[dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2,3\f] + +@param src Coordinates of quadrangle vertices in the source image. +@param dst Coordinates of the corresponding quadrangle vertices in the destination image. +@param solveMethod method passed to cv::solve (#DecompTypes) + +@sa findHomography, warpPerspective, perspectiveTransform + */ +CV_EXPORTS_W Mat getPerspectiveTransform(InputArray src, InputArray dst, int solveMethod = DECOMP_LU); + +/** @overload */ +CV_EXPORTS Mat getPerspectiveTransform(const Point2f src[], const Point2f dst[], int solveMethod = DECOMP_LU); + + +CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst ); + +/** @brief Retrieves a pixel rectangle from an image with sub-pixel accuracy. + +The function getRectSubPix extracts pixels from src: + +\f[patch(x, y) = src(x + \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y + \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\f] + +where the values of the pixels at non-integer coordinates are retrieved using bilinear +interpolation. Every channel of multi-channel images is processed independently. Also +the image should be a single channel or three channel image. While the center of the +rectangle must be inside the image, parts of the rectangle may be outside. + +@param image Source image. +@param patchSize Size of the extracted patch. +@param center Floating point coordinates of the center of the extracted rectangle within the +source image. The center must be inside the image. +@param patch Extracted patch that has the size patchSize and the same number of channels as src . +@param patchType Depth of the extracted pixels. By default, they have the same depth as src . + +@sa warpAffine, warpPerspective + */ +CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize, + Point2f center, OutputArray patch, int patchType = -1 ); + +/** @example samples/cpp/polar_transforms.cpp +An example using the cv::linearPolar and cv::logPolar operations +*/ + +/** @brief Remaps an image to semilog-polar coordinates space. + +@deprecated This function produces same result as cv::warpPolar(src, dst, src.size(), center, maxRadius, flags+WARP_POLAR_LOG); + +@internal +Transform the source image using the following transformation (See @ref polar_remaps_reference_image "Polar remaps reference image d)"): +\f[\begin{array}{l} + dst( \rho , \phi ) = src(x,y) \\ + dst.size() \leftarrow src.size() +\end{array}\f] + +where +\f[\begin{array}{l} + I = (dx,dy) = (x - center.x,y - center.y) \\ + \rho = M \cdot log_e(\texttt{magnitude} (I)) ,\\ + \phi = Kangle \cdot \texttt{angle} (I) \\ +\end{array}\f] + +and +\f[\begin{array}{l} + M = src.cols / log_e(maxRadius) \\ + Kangle = src.rows / 2\Pi \\ +\end{array}\f] + +The function emulates the human "foveal" vision and can be used for fast scale and +rotation-invariant template matching, for object tracking and so forth. +@param src Source image +@param dst Destination image. It will have same size and type as src. +@param center The transformation center; where the output precision is maximal +@param M Magnitude scale parameter. It determines the radius of the bounding circle to transform too. +@param flags A combination of interpolation methods, see #InterpolationFlags + +@note +- The function can not operate in-place. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. + +@sa cv::linearPolar +@endinternal +*/ +CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst, + Point2f center, double M, int flags ); + +/** @brief Remaps an image to polar coordinates space. + +@deprecated This function produces same result as cv::warpPolar(src, dst, src.size(), center, maxRadius, flags) + +@internal +Transform the source image using the following transformation (See @ref polar_remaps_reference_image "Polar remaps reference image c)"): +\f[\begin{array}{l} + dst( \rho , \phi ) = src(x,y) \\ + dst.size() \leftarrow src.size() +\end{array}\f] + +where +\f[\begin{array}{l} + I = (dx,dy) = (x - center.x,y - center.y) \\ + \rho = Kmag \cdot \texttt{magnitude} (I) ,\\ + \phi = angle \cdot \texttt{angle} (I) +\end{array}\f] + +and +\f[\begin{array}{l} + Kx = src.cols / maxRadius \\ + Ky = src.rows / 2\Pi +\end{array}\f] + + +@param src Source image +@param dst Destination image. It will have same size and type as src. +@param center The transformation center; +@param maxRadius The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too. +@param flags A combination of interpolation methods, see #InterpolationFlags + +@note +- The function can not operate in-place. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. + +@sa cv::logPolar +@endinternal +*/ +CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst, + Point2f center, double maxRadius, int flags ); + + +/** \brief Remaps an image to polar or semilog-polar coordinates space + +@anchor polar_remaps_reference_image +![Polar remaps reference](pics/polar_remap_doc.png) + +Transform the source image using the following transformation: +\f[ +dst(\rho , \phi ) = src(x,y) +\f] + +where +\f[ +\begin{array}{l} +\vec{I} = (x - center.x, \;y - center.y) \\ +\phi = Kangle \cdot \texttt{angle} (\vec{I}) \\ +\rho = \left\{\begin{matrix} +Klin \cdot \texttt{magnitude} (\vec{I}) & default \\ +Klog \cdot log_e(\texttt{magnitude} (\vec{I})) & if \; semilog \\ +\end{matrix}\right. +\end{array} +\f] + +and +\f[ +\begin{array}{l} +Kangle = dsize.height / 2\Pi \\ +Klin = dsize.width / maxRadius \\ +Klog = dsize.width / log_e(maxRadius) \\ +\end{array} +\f] + + +\par Linear vs semilog mapping + +Polar mapping can be linear or semi-log. Add one of #WarpPolarMode to `flags` to specify the polar mapping mode. + +Linear is the default mode. + +The semilog mapping emulates the human "foveal" vision that permit very high acuity on the line of sight (central vision) +in contrast to peripheral vision where acuity is minor. + +\par Option on `dsize`: + +- if both values in `dsize <=0 ` (default), +the destination image will have (almost) same area of source bounding circle: +\f[\begin{array}{l} +dsize.area \leftarrow (maxRadius^2 \cdot \Pi) \\ +dsize.width = \texttt{cvRound}(maxRadius) \\ +dsize.height = \texttt{cvRound}(maxRadius \cdot \Pi) \\ +\end{array}\f] + + +- if only `dsize.height <= 0`, +the destination image area will be proportional to the bounding circle area but scaled by `Kx * Kx`: +\f[\begin{array}{l} +dsize.height = \texttt{cvRound}(dsize.width \cdot \Pi) \\ +\end{array} +\f] + +- if both values in `dsize > 0 `, +the destination image will have the given size therefore the area of the bounding circle will be scaled to `dsize`. + + +\par Reverse mapping + +You can get reverse mapping adding #WARP_INVERSE_MAP to `flags` +\snippet polar_transforms.cpp InverseMap + +In addiction, to calculate the original coordinate from a polar mapped coordinate \f$(rho, phi)->(x, y)\f$: +\snippet polar_transforms.cpp InverseCoordinate + +@param src Source image. +@param dst Destination image. It will have same type as src. +@param dsize The destination image size (see description for valid options). +@param center The transformation center. +@param maxRadius The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too. +@param flags A combination of interpolation methods, #InterpolationFlags + #WarpPolarMode. + - Add #WARP_POLAR_LINEAR to select linear polar mapping (default) + - Add #WARP_POLAR_LOG to select semilog polar mapping + - Add #WARP_INVERSE_MAP for reverse mapping. +@note +- The function can not operate in-place. +- To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees. +- This function uses #remap. Due to current implementation limitations the size of an input and output images should be less than 32767x32767. + +@sa cv::remap +*/ +CV_EXPORTS_W void warpPolar(InputArray src, OutputArray dst, Size dsize, + Point2f center, double maxRadius, int flags); + + +//! @} imgproc_transform + +//! @addtogroup imgproc_misc +//! @{ + +/** @brief Calculates the integral of an image. + +The function calculates one or more integral images for the source image as follows: + +\f[\texttt{sum} (X,Y) = \sum _{x + +Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed +with getOptimalDFTSize. + +The function performs the following equations: +- First it applies a Hanning window (see ) to each +image to remove possible edge effects. This window is cached until the array size changes to speed +up processing time. +- Next it computes the forward DFTs of each source array: +\f[\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\f] +where \f$\mathcal{F}\f$ is the forward DFT. +- It then computes the cross-power spectrum of each frequency domain array: +\f[R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\f] +- Next the cross-correlation is converted back into the time domain via the inverse DFT: +\f[r = \mathcal{F}^{-1}\{R\}\f] +- Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to +achieve sub-pixel accuracy. +\f[(\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\f] +- If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 +centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single +peak) and will be smaller when there are multiple peaks. + +@param src1 Source floating point array (CV_32FC1 or CV_64FC1) +@param src2 Source floating point array (CV_32FC1 or CV_64FC1) +@param window Floating point array with windowing coefficients to reduce edge effects (optional). +@param response Signal power within the 5x5 centroid around the peak, between 0 and 1 (optional). +@returns detected phase shift (sub-pixel) between the two arrays. + +@sa dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow + */ +CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2, + InputArray window = noArray(), CV_OUT double* response = 0); + +/** @brief This function computes a Hanning window coefficients in two dimensions. + +See (http://en.wikipedia.org/wiki/Hann_function) and (http://en.wikipedia.org/wiki/Window_function) +for more information. + +An example is shown below: +@code + // create hanning window of size 100x100 and type CV_32F + Mat hann; + createHanningWindow(hann, Size(100, 100), CV_32F); +@endcode +@param dst Destination array to place Hann coefficients in +@param winSize The window size specifications (both width and height must be > 1) +@param type Created array type + */ +CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type); + +/** @brief Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum. + +The function cv::divSpectrums performs the per-element division of the first array by the second array. +The arrays are CCS-packed or complex matrices that are results of a real or complex Fourier transform. + +@param a first input array. +@param b second input array of the same size and type as src1 . +@param c output array of the same size and type as src1 . +@param flags operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that +each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a `0` as value. +@param conjB optional flag that conjugates the second input array before the multiplication (true) +or not (false). +*/ +CV_EXPORTS_W void divSpectrums(InputArray a, InputArray b, OutputArray c, + int flags, bool conjB = false); + +//! @} imgproc_motion + +//! @addtogroup imgproc_misc +//! @{ + +/** @brief Applies a fixed-level threshold to each array element. + +The function applies fixed-level thresholding to a multiple-channel array. The function is typically +used to get a bi-level (binary) image out of a grayscale image ( #compare could be also used for +this purpose) or for removing a noise, that is, filtering out pixels with too small or too large +values. There are several types of thresholding supported by the function. They are determined by +type parameter. + +Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with one of the +above values. In these cases, the function determines the optimal threshold value using the Otsu's +or Triangle algorithm and uses it instead of the specified thresh. + +@note Currently, the Otsu's and Triangle methods are implemented only for 8-bit single-channel images. + +@param src input array (multiple-channel, 8-bit or 32-bit floating point). +@param dst output array of the same size and type and the same number of channels as src. +@param thresh threshold value. +@param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding +types. +@param type thresholding type (see #ThresholdTypes). +@return the computed threshold value if Otsu's or Triangle methods used. + +@sa adaptiveThreshold, findContours, compare, min, max + */ +CV_EXPORTS_W double threshold( InputArray src, OutputArray dst, + double thresh, double maxval, int type ); + + +/** @brief Applies an adaptive threshold to an array. + +The function transforms a grayscale image to a binary image according to the formulae: +- **THRESH_BINARY** + \f[dst(x,y) = \fork{\texttt{maxValue}}{if \(src(x,y) > T(x,y)\)}{0}{otherwise}\f] +- **THRESH_BINARY_INV** + \f[dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\f] +where \f$T(x,y)\f$ is a threshold calculated individually for each pixel (see adaptiveMethod parameter). + +The function can process the image in-place. + +@param src Source 8-bit single-channel image. +@param dst Destination image of the same size and the same type as src. +@param maxValue Non-zero value assigned to the pixels for which the condition is satisfied +@param adaptiveMethod Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. +The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries. +@param thresholdType Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, +see #ThresholdTypes. +@param blockSize Size of a pixel neighborhood that is used to calculate a threshold value for the +pixel: 3, 5, 7, and so on. +@param C Constant subtracted from the mean or weighted mean (see the details below). Normally, it +is positive but may be zero or negative as well. + +@sa threshold, blur, GaussianBlur + */ +CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst, + double maxValue, int adaptiveMethod, + int thresholdType, int blockSize, double C ); + +//! @} imgproc_misc + +//! @addtogroup imgproc_filter +//! @{ + +/** @example samples/cpp/tutorial_code/ImgProc/Pyramids/Pyramids.cpp +An example using pyrDown and pyrUp functions +*/ + +/** @brief Blurs an image and downsamples it. + +By default, size of the output image is computed as `Size((src.cols+1)/2, (src.rows+1)/2)`, but in +any case, the following conditions should be satisfied: + +\f[\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\f] + +The function performs the downsampling step of the Gaussian pyramid construction. First, it +convolves the source image with the kernel: + +\f[\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\f] + +Then, it downsamples the image by rejecting even rows and columns. + +@param src input image. +@param dst output image; it has the specified size and the same type as src. +@param dstsize size of the output image. +@param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) + */ +CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst, + const Size& dstsize = Size(), int borderType = BORDER_DEFAULT ); + +/** @brief Upsamples an image and then blurs it. + +By default, size of the output image is computed as `Size(src.cols\*2, (src.rows\*2)`, but in any +case, the following conditions should be satisfied: + +\f[\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\f] + +The function performs the upsampling step of the Gaussian pyramid construction, though it can +actually be used to construct the Laplacian pyramid. First, it upsamples the source image by +injecting even zero rows and columns and then convolves the result with the same kernel as in +pyrDown multiplied by 4. + +@param src input image. +@param dst output image. It has the specified size and the same type as src . +@param dstsize size of the output image. +@param borderType Pixel extrapolation method, see #BorderTypes (only #BORDER_DEFAULT is supported) + */ +CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst, + const Size& dstsize = Size(), int borderType = BORDER_DEFAULT ); + +/** @brief Constructs the Gaussian pyramid for an image. + +The function constructs a vector of images and builds the Gaussian pyramid by recursively applying +pyrDown to the previously built pyramid layers, starting from `dst[0]==src`. + +@param src Source image. Check pyrDown for the list of supported types. +@param dst Destination vector of maxlevel+1 images of the same type as src. dst[0] will be the +same as src. dst[1] is the next pyramid layer, a smoothed and down-sized src, and so on. +@param maxlevel 0-based index of the last (the smallest) pyramid layer. It must be non-negative. +@param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) + */ +CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst, + int maxlevel, int borderType = BORDER_DEFAULT ); + +//! @} imgproc_filter + +//! @addtogroup imgproc_hist +//! @{ + +/** @example samples/cpp/demhist.cpp +An example for creating histograms of an image +*/ + +/** @brief Calculates a histogram of a set of arrays. + +The function cv::calcHist calculates the histogram of one or more arrays. The elements of a tuple used +to increment a histogram bin are taken from the corresponding input arrays at the same location. The +sample below shows how to compute a 2D Hue-Saturation histogram for a color image. : +@include snippets/imgproc_calcHist.cpp + +@param images Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same +size. Each of them can have an arbitrary number of channels. +@param nimages Number of source images. +@param channels List of the dims channels used to compute the histogram. The first array channels +are numerated from 0 to images[0].channels()-1 , the second array channels are counted from +images[0].channels() to images[0].channels() + images[1].channels()-1, and so on. +@param mask Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size +as images[i] . The non-zero mask elements mark the array elements counted in the histogram. +@param hist Output histogram, which is a dense or sparse dims -dimensional array. +@param dims Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS +(equal to 32 in the current OpenCV version). +@param histSize Array of histogram sizes in each dimension. +@param ranges Array of the dims arrays of the histogram bin boundaries in each dimension. When the +histogram is uniform ( uniform =true), then for each dimension i it is enough to specify the lower +(inclusive) boundary \f$L_0\f$ of the 0-th histogram bin and the upper (exclusive) boundary +\f$U_{\texttt{histSize}[i]-1}\f$ for the last histogram bin histSize[i]-1 . That is, in case of a +uniform histogram each of ranges[i] is an array of 2 elements. When the histogram is not uniform ( +uniform=false ), then each of ranges[i] contains histSize[i]+1 elements: +\f$L_0, U_0=L_1, U_1=L_2, ..., U_{\texttt{histSize[i]}-2}=L_{\texttt{histSize[i]}-1}, U_{\texttt{histSize[i]}-1}\f$ +. The array elements, that are not between \f$L_0\f$ and \f$U_{\texttt{histSize[i]}-1}\f$ , are not +counted in the histogram. +@param uniform Flag indicating whether the histogram is uniform or not (see above). +@param accumulate Accumulation flag. If it is set, the histogram is not cleared in the beginning +when it is allocated. This feature enables you to compute a single histogram from several sets of +arrays, or to update the histogram in time. +*/ +CV_EXPORTS void calcHist( const Mat* images, int nimages, + const int* channels, InputArray mask, + OutputArray hist, int dims, const int* histSize, + const float** ranges, bool uniform = true, bool accumulate = false ); + +/** @overload + +this variant uses %SparseMat for output +*/ +CV_EXPORTS void calcHist( const Mat* images, int nimages, + const int* channels, InputArray mask, + SparseMat& hist, int dims, + const int* histSize, const float** ranges, + bool uniform = true, bool accumulate = false ); + +/** @overload */ +CV_EXPORTS_W void calcHist( InputArrayOfArrays images, + const std::vector& channels, + InputArray mask, OutputArray hist, + const std::vector& histSize, + const std::vector& ranges, + bool accumulate = false ); + +/** @brief Calculates the back projection of a histogram. + +The function cv::calcBackProject calculates the back project of the histogram. That is, similarly to +#calcHist , at each location (x, y) the function collects the values from the selected channels +in the input images and finds the corresponding histogram bin. But instead of incrementing it, the +function reads the bin value, scales it by scale , and stores in backProject(x,y) . In terms of +statistics, the function computes probability of each element value in respect with the empirical +probability distribution represented by the histogram. See how, for example, you can find and track +a bright-colored object in a scene: + +- Before tracking, show the object to the camera so that it covers almost the whole frame. +Calculate a hue histogram. The histogram may have strong maximums, corresponding to the dominant +colors in the object. + +- When tracking, calculate a back projection of a hue plane of each input video frame using that +pre-computed histogram. Threshold the back projection to suppress weak colors. It may also make +sense to suppress pixels with non-sufficient color saturation and too dark or too bright pixels. + +- Find connected components in the resulting picture and choose, for example, the largest +component. + +This is an approximate algorithm of the CamShift color object tracker. + +@param images Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same +size. Each of them can have an arbitrary number of channels. +@param nimages Number of source images. +@param channels The list of channels used to compute the back projection. The number of channels +must match the histogram dimensionality. The first array channels are numerated from 0 to +images[0].channels()-1 , the second array channels are counted from images[0].channels() to +images[0].channels() + images[1].channels()-1, and so on. +@param hist Input histogram that can be dense or sparse. +@param backProject Destination back projection array that is a single-channel array of the same +size and depth as images[0] . +@param ranges Array of arrays of the histogram bin boundaries in each dimension. See #calcHist . +@param scale Optional scale factor for the output back projection. +@param uniform Flag indicating whether the histogram is uniform or not (see above). + +@sa calcHist, compareHist + */ +CV_EXPORTS void calcBackProject( const Mat* images, int nimages, + const int* channels, InputArray hist, + OutputArray backProject, const float** ranges, + double scale = 1, bool uniform = true ); + +/** @overload */ +CV_EXPORTS void calcBackProject( const Mat* images, int nimages, + const int* channels, const SparseMat& hist, + OutputArray backProject, const float** ranges, + double scale = 1, bool uniform = true ); + +/** @overload */ +CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const std::vector& channels, + InputArray hist, OutputArray dst, + const std::vector& ranges, + double scale ); + +/** @brief Compares two histograms. + +The function cv::compareHist compares two dense or two sparse histograms using the specified method. + +The function returns \f$d(H_1, H_2)\f$ . + +While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable +for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling +problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms +or more general sparse configurations of weighted points, consider using the #EMD function. + +@param H1 First compared histogram. +@param H2 Second compared histogram of the same size as H1 . +@param method Comparison method, see #HistCompMethods + */ +CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method ); + +/** @overload */ +CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method ); + +/** @brief Equalizes the histogram of a grayscale image. + +The function equalizes the histogram of the input image using the following algorithm: + +- Calculate the histogram \f$H\f$ for src . +- Normalize the histogram so that the sum of histogram bins is 255. +- Compute the integral of the histogram: +\f[H'_i = \sum _{0 \le j < i} H(j)\f] +- Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$ + +The algorithm normalizes the brightness and increases the contrast of the image. + +@param src Source 8-bit single channel image. +@param dst Destination image of the same size and type as src . + */ +CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst ); + +/** @brief Creates a smart pointer to a cv::CLAHE class and initializes it. + +@param clipLimit Threshold for contrast limiting. +@param tileGridSize Size of grid for histogram equalization. Input image will be divided into +equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column. + */ +CV_EXPORTS_W Ptr createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8)); + +/** @brief Computes the "minimal work" distance between two weighted point configurations. + +The function computes the earth mover distance and/or a lower boundary of the distance between the +two weighted point configurations. One of the applications described in @cite RubnerSept98, +@cite Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation +problem that is solved using some modification of a simplex algorithm, thus the complexity is +exponential in the worst case, though, on average it is much faster. In the case of a real metric +the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used +to determine roughly whether the two signatures are far enough so that they cannot relate to the +same object. + +@param signature1 First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ floating-point matrix. +Each row stores the point weight followed by the point coordinates. The matrix is allowed to have +a single column (weights only) if the user-defined cost matrix is used. The weights must be +non-negative and have at least one non-zero value. +@param signature2 Second signature of the same format as signature1 , though the number of rows +may be different. The total weights may be different. In this case an extra "dummy" point is added +to either signature1 or signature2. The weights must be non-negative and have at least one non-zero +value. +@param distType Used metric. See #DistanceTypes. +@param cost User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix +is used, lower boundary lowerBound cannot be calculated because it needs a metric function. +@param lowerBound Optional input/output parameter: lower boundary of a distance between the two +signatures that is a distance between mass centers. The lower boundary may not be calculated if +the user-defined cost matrix is used, the total weights of point configurations are not equal, or +if the signatures consist of weights only (the signature matrices have a single column). You +**must** initialize \*lowerBound . If the calculated distance between mass centers is greater or +equal to \*lowerBound (it means that the signatures are far enough), the function does not +calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on +return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound +should be set to 0. +@param flow Resultant \f$\texttt{size1} \times \texttt{size2}\f$ flow matrix: \f$\texttt{flow}_{i,j}\f$ is +a flow from \f$i\f$ -th point of signature1 to \f$j\f$ -th point of signature2 . + */ +CV_EXPORTS float EMD( InputArray signature1, InputArray signature2, + int distType, InputArray cost=noArray(), + float* lowerBound = 0, OutputArray flow = noArray() ); + +CV_EXPORTS_AS(EMD) float wrapperEMD( InputArray signature1, InputArray signature2, + int distType, InputArray cost=noArray(), + CV_IN_OUT Ptr lowerBound = Ptr(), OutputArray flow = noArray() ); + +//! @} imgproc_hist + +//! @addtogroup imgproc_segmentation +//! @{ + +/** @example samples/cpp/watershed.cpp +An example using the watershed algorithm +*/ + +/** @brief Performs a marker-based image segmentation using the watershed algorithm. + +The function implements one of the variants of watershed, non-parametric marker-based segmentation +algorithm, described in @cite Meyer92 . + +Before passing the image to the function, you have to roughly outline the desired regions in the +image markers with positive (\>0) indices. So, every region is represented as one or more connected +components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary +mask using #findContours and #drawContours (see the watershed.cpp demo). The markers are "seeds" of +the future image regions. All the other pixels in markers , whose relation to the outlined regions +is not known and should be defined by the algorithm, should be set to 0's. In the function output, +each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the +regions. + +@note Any two neighbor connected components are not necessarily separated by a watershed boundary +(-1's pixels); for example, they can touch each other in the initial marker image passed to the +function. + +@param image Input 8-bit 3-channel image. +@param markers Input/output 32-bit single-channel image (map) of markers. It should have the same +size as image . + +@sa findContours + */ +CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers ); + +//! @} imgproc_segmentation + +//! @addtogroup imgproc_filter +//! @{ + +/** @brief Performs initial step of meanshift segmentation of an image. + +The function implements the filtering stage of meanshift segmentation, that is, the output of the +function is the filtered "posterized" image with color gradients and fine-grain texture flattened. +At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes +meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is +considered: + +\f[(x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\f] + +where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively +(though, the algorithm does not depend on the color space used, so any 3-component color space can +be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector +(R',G',B') are found and they act as the neighborhood center on the next iteration: + +\f[(X,Y)~(X',Y'), (R,G,B)~(R',G',B').\f] + +After the iterations over, the color components of the initial pixel (that is, the pixel from where +the iterations started) are set to the final value (average color at the last iteration): + +\f[I(X,Y) <- (R*,G*,B*)\f] + +When maxLevel \> 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is +run on the smallest layer first. After that, the results are propagated to the larger layer and the +iterations are run again only on those pixels where the layer colors differ by more than sr from the +lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the +results will be actually different from the ones obtained by running the meanshift procedure on the +whole original image (i.e. when maxLevel==0). + +@param src The source 8-bit, 3-channel image. +@param dst The destination image of the same format and the same size as the source. +@param sp The spatial window radius. +@param sr The color window radius. +@param maxLevel Maximum level of the pyramid for the segmentation. +@param termcrit Termination criteria: when to stop meanshift iterations. + */ +CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst, + double sp, double sr, int maxLevel = 1, + TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) ); + +//! @} + +//! @addtogroup imgproc_segmentation +//! @{ + +/** @example samples/cpp/grabcut.cpp +An example using the GrabCut algorithm +![Sample Screenshot](grabcut_output1.jpg) +*/ + +/** @brief Runs the GrabCut algorithm. + +The function implements the [GrabCut image segmentation algorithm](http://en.wikipedia.org/wiki/GrabCut). + +@param img Input 8-bit 3-channel image. +@param mask Input/output 8-bit single-channel mask. The mask is initialized by the function when +mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses. +@param rect ROI containing a segmented object. The pixels outside of the ROI are marked as +"obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT . +@param bgdModel Temporary array for the background model. Do not modify it while you are +processing the same image. +@param fgdModel Temporary arrays for the foreground model. Do not modify it while you are +processing the same image. +@param iterCount Number of iterations the algorithm should make before returning the result. Note +that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or +mode==GC_EVAL . +@param mode Operation mode that could be one of the #GrabCutModes + */ +CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect, + InputOutputArray bgdModel, InputOutputArray fgdModel, + int iterCount, int mode = GC_EVAL ); + +//! @} imgproc_segmentation + +//! @addtogroup imgproc_misc +//! @{ + +/** @example samples/cpp/distrans.cpp +An example on using the distance transform +*/ + +/** @brief Calculates the distance to the closest zero pixel for each pixel of the source image. + +The function cv::distanceTransform calculates the approximate or precise distance from every binary +image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero. + +When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the +algorithm described in @cite Felzenszwalb04 . This algorithm is parallelized with the TBB library. + +In other cases, the algorithm @cite Borgefors86 is used. This means that for a pixel the function +finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, +diagonal, or knight's move (the latest is available for a \f$5\times 5\f$ mask). The overall +distance is calculated as a sum of these basic distances. Since the distance function should be +symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all +the diagonal shifts must have the same cost (denoted as `b`), and all knight's moves must have the +same cost (denoted as `c`). For the #DIST_C and #DIST_L1 types, the distance is calculated +precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a +relative error (a \f$5\times 5\f$ mask gives more accurate results). For `a`,`b`, and `c`, OpenCV +uses the values suggested in the original paper: +- DIST_L1: `a = 1, b = 2` +- DIST_L2: + - `3 x 3`: `a=0.955, b=1.3693` + - `5 x 5`: `a=1, b=1.4, c=2.1969` +- DIST_C: `a = 1, b = 1` + +Typically, for a fast, coarse distance estimation #DIST_L2, a \f$3\times 3\f$ mask is used. For a +more accurate distance estimation #DIST_L2, a \f$5\times 5\f$ mask or the precise algorithm is used. +Note that both the precise and the approximate algorithms are linear on the number of pixels. + +This variant of the function does not only compute the minimum distance for each pixel \f$(x, y)\f$ +but also identifies the nearest connected component consisting of zero pixels +(labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the +component/pixel is stored in `labels(x, y)`. When labelType==#DIST_LABEL_CCOMP, the function +automatically finds connected components of zero pixels in the input image and marks them with +distinct labels. When labelType==#DIST_LABEL_PIXEL, the function scans through the input image and +marks all the zero pixels with distinct labels. + +In this mode, the complexity is still linear. That is, the function provides a very fast way to +compute the Voronoi diagram for a binary image. Currently, the second variant can use only the +approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported +yet. + +@param src 8-bit, single-channel (binary) source image. +@param dst Output image with calculated distances. It is a 8-bit or 32-bit floating-point, +single-channel image of the same size as src. +@param labels Output 2D array of labels (the discrete Voronoi diagram). It has the type +CV_32SC1 and the same size as src. +@param distanceType Type of distance, see #DistanceTypes +@param maskSize Size of the distance transform mask, see #DistanceTransformMasks. +#DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type, +the parameter is forced to 3 because a \f$3\times 3\f$ mask gives the same result as \f$5\times +5\f$ or any larger aperture. +@param labelType Type of the label array to build, see #DistanceTransformLabelTypes. + */ +CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst, + OutputArray labels, int distanceType, int maskSize, + int labelType = DIST_LABEL_CCOMP ); + +/** @overload +@param src 8-bit, single-channel (binary) source image. +@param dst Output image with calculated distances. It is a 8-bit or 32-bit floating-point, +single-channel image of the same size as src . +@param distanceType Type of distance, see #DistanceTypes +@param maskSize Size of the distance transform mask, see #DistanceTransformMasks. In case of the +#DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \f$3\times 3\f$ mask gives +the same result as \f$5\times 5\f$ or any larger aperture. +@param dstType Type of output image. It can be CV_8U or CV_32F. Type CV_8U can be used only for +the first variant of the function and distanceType == #DIST_L1. +*/ +CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst, + int distanceType, int maskSize, int dstType=CV_32F); + +/** @brief Fills a connected component with the given color. + +The function cv::floodFill fills a connected component starting from the seed point with the specified +color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The +pixel at \f$(x,y)\f$ is considered to belong to the repainted domain if: + +- in case of a grayscale image and floating range +\f[\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\f] + + +- in case of a grayscale image and fixed range +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\f] + + +- in case of a color image and floating range +\f[\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\f] +\f[\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\f] +and +\f[\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\f] + + +- in case of a color image and fixed range +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\f] +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\f] +and +\f[\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\f] + + +where \f$src(x',y')\f$ is the value of one of pixel neighbors that is already known to belong to the +component. That is, to be added to the connected component, a color/brightness of the pixel should +be close enough to: +- Color/brightness of one of its neighbors that already belong to the connected component in case +of a floating range. +- Color/brightness of the seed point in case of a fixed range. + +Use these functions to either mark a connected component with the specified color in-place, or build +a mask and then extract the contour, or copy the region to another image, and so on. + +@param image Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the +function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See +the details below. +@param mask Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels +taller than image. Since this is both an input and output parameter, you must take responsibility +of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, +an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the +mask corresponding to filled pixels in the image are set to 1 or to the a value specified in flags +as described below. Additionally, the function fills the border of the mask with ones to simplify +internal processing. It is therefore possible to use the same mask in multiple calls to the function +to make sure the filled areas do not overlap. +@param seedPoint Starting point. +@param newVal New value of the repainted domain pixels. +@param loDiff Maximal lower brightness/color difference between the currently observed pixel and +one of its neighbors belonging to the component, or a seed pixel being added to the component. +@param upDiff Maximal upper brightness/color difference between the currently observed pixel and +one of its neighbors belonging to the component, or a seed pixel being added to the component. +@param rect Optional output parameter set by the function to the minimum bounding rectangle of the +repainted domain. +@param flags Operation flags. The first 8 bits contain a connectivity value. The default value of +4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A +connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) +will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill +the mask (the default value is 1). For example, 4 | ( 255 \<\< 8 ) will consider 4 nearest +neighbours and fill the mask with a value of 255. The following additional options occupy higher +bits and therefore may be further combined with the connectivity and mask fill values using +bit-wise or (|), see #FloodFillFlags. + +@note Since the mask is larger than the filled image, a pixel \f$(x, y)\f$ in image corresponds to the +pixel \f$(x+1, y+1)\f$ in the mask . + +@sa findContours + */ +CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask, + Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0, + Scalar loDiff = Scalar(), Scalar upDiff = Scalar(), + int flags = 4 ); + +/** @example samples/cpp/ffilldemo.cpp +An example using the FloodFill technique +*/ + +/** @overload + +variant without `mask` parameter +*/ +CV_EXPORTS int floodFill( InputOutputArray image, + Point seedPoint, Scalar newVal, CV_OUT Rect* rect = 0, + Scalar loDiff = Scalar(), Scalar upDiff = Scalar(), + int flags = 4 ); + +//! Performs linear blending of two images: +//! \f[ \texttt{dst}(i,j) = \texttt{weights1}(i,j)*\texttt{src1}(i,j) + \texttt{weights2}(i,j)*\texttt{src2}(i,j) \f] +//! @param src1 It has a type of CV_8UC(n) or CV_32FC(n), where n is a positive integer. +//! @param src2 It has the same type and size as src1. +//! @param weights1 It has a type of CV_32FC1 and the same size with src1. +//! @param weights2 It has a type of CV_32FC1 and the same size with src1. +//! @param dst It is created if it does not have the same size and type with src1. +CV_EXPORTS_W void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst); + +//! @} imgproc_misc + +//! @addtogroup imgproc_color_conversions +//! @{ + +/** @brief Converts an image from one color space to another. + +The function converts an input image from one color space to another. In case of a transformation +to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note +that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the +bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue +component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and +sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on. + +The conventional ranges for R, G, and B channel values are: +- 0 to 255 for CV_8U images +- 0 to 65535 for CV_16U images +- 0 to 1 for CV_32F images + +In case of linear transformations, the range does not matter. But in case of a non-linear +transformation, an input RGB image should be normalized to the proper value range to get the correct +results, for example, for RGB \f$\rightarrow\f$ L\*u\*v\* transformation. For example, if you have a +32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will +have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor , +you need first to scale the image down: +@code + img *= 1./255; + cvtColor(img, img, COLOR_BGR2Luv); +@endcode +If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many +applications, this will not be noticeable but it is recommended to use 32-bit images in applications +that need the full range of colors or that convert an image before an operation and then convert +back. + +If conversion adds the alpha channel, its value will set to the maximum of corresponding channel +range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F. + +@param src input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision +floating-point. +@param dst output image of the same size and depth as src. +@param code color space conversion code (see #ColorConversionCodes). +@param dstCn number of channels in the destination image; if the parameter is 0, the number of the +channels is derived automatically from src and code. + +@see @ref imgproc_color_conversions + */ +CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 ); + +/** @brief Converts an image from one color space to another where the source image is +stored in two planes. + +This function only supports YUV420 to RGB conversion as of now. + +@param src1: 8-bit image (#CV_8U) of the Y plane. +@param src2: image containing interleaved U/V plane. +@param dst: output image. +@param code: Specifies the type of conversion. It can take any of the following values: +- #COLOR_YUV2BGR_NV12 +- #COLOR_YUV2RGB_NV12 +- #COLOR_YUV2BGRA_NV12 +- #COLOR_YUV2RGBA_NV12 +- #COLOR_YUV2BGR_NV21 +- #COLOR_YUV2RGB_NV21 +- #COLOR_YUV2BGRA_NV21 +- #COLOR_YUV2RGBA_NV21 +*/ +CV_EXPORTS_W void cvtColorTwoPlane( InputArray src1, InputArray src2, OutputArray dst, int code ); + +/** @brief main function for all demosaicing processes + +@param src input image: 8-bit unsigned or 16-bit unsigned. +@param dst output image of the same size and depth as src. +@param code Color space conversion code (see the description below). +@param dstCn number of channels in the destination image; if the parameter is 0, the number of the +channels is derived automatically from src and code. + +The function can do the following transformations: + +- Demosaicing using bilinear interpolation + + #COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR + + #COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY + +- Demosaicing using Variable Number of Gradients. + + #COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG + +- Edge-Aware Demosaicing. + + #COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA + +- Demosaicing with alpha channel + + #COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA + +@sa cvtColor +*/ +CV_EXPORTS_W void demosaicing(InputArray src, OutputArray dst, int code, int dstCn = 0); + +//! @} imgproc_color_conversions + +//! @addtogroup imgproc_shape +//! @{ + +/** @brief Calculates all of the moments up to the third order of a polygon or rasterized shape. + +The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The +results are returned in the structure cv::Moments. + +@param array Raster image (single-channel, 8-bit or floating-point 2D array) or an array ( +\f$1 \times N\f$ or \f$N \times 1\f$ ) of 2D points (Point or Point2f ). +@param binaryImage If it is true, all non-zero image pixels are treated as 1's. The parameter is +used for images only. +@returns moments. + +@note Only applicable to contour moments calculations from Python bindings: Note that the numpy +type for the input array should be either np.int32 or np.float32. + +@sa contourArea, arcLength + */ +CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage = false ); + +/** @brief Calculates seven Hu invariants. + +The function calculates seven Hu invariants (introduced in @cite Hu62; see also +) defined as: + +\f[\begin{array}{l} hu[0]= \eta _{20}+ \eta _{02} \\ hu[1]=( \eta _{20}- \eta _{02})^{2}+4 \eta _{11}^{2} \\ hu[2]=( \eta _{30}-3 \eta _{12})^{2}+ (3 \eta _{21}- \eta _{03})^{2} \\ hu[3]=( \eta _{30}+ \eta _{12})^{2}+ ( \eta _{21}+ \eta _{03})^{2} \\ hu[4]=( \eta _{30}-3 \eta _{12})( \eta _{30}+ \eta _{12})[( \eta _{30}+ \eta _{12})^{2}-3( \eta _{21}+ \eta _{03})^{2}]+(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ hu[5]=( \eta _{20}- \eta _{02})[( \eta _{30}+ \eta _{12})^{2}- ( \eta _{21}+ \eta _{03})^{2}]+4 \eta _{11}( \eta _{30}+ \eta _{12})( \eta _{21}+ \eta _{03}) \\ hu[6]=(3 \eta _{21}- \eta _{03})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}]-( \eta _{30}-3 \eta _{12})( \eta _{21}+ \eta _{03})[3( \eta _{30}+ \eta _{12})^{2}-( \eta _{21}+ \eta _{03})^{2}] \\ \end{array}\f] + +where \f$\eta_{ji}\f$ stands for \f$\texttt{Moments::nu}_{ji}\f$ . + +These values are proved to be invariants to the image scale, rotation, and reflection except the +seventh one, whose sign is changed by reflection. This invariance is proved with the assumption of +infinite image resolution. In case of raster images, the computed Hu invariants for the original and +transformed images are a bit different. + +@param moments Input moments computed with moments . +@param hu Output Hu invariants. + +@sa matchShapes + */ +CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] ); + +/** @overload */ +CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu ); + +//! @} imgproc_shape + +//! @addtogroup imgproc_object +//! @{ + +//! type of the template matching operation +enum TemplateMatchModes { + TM_SQDIFF = 0, /*!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f] + with mask: + \f[R(x,y)= \sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot + M(x',y') \right)^2\f] */ + TM_SQDIFF_NORMED = 1, /*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{ + x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f] + with mask: + \f[R(x,y)= \frac{\sum _{x',y'} \left( (T(x',y')-I(x+x',y+y')) \cdot + M(x',y') \right)^2}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot + M(x',y') \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot + M(x',y') \right)^2}}\f] */ + TM_CCORR = 2, /*!< \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y'))\f] + with mask: + \f[R(x,y)= \sum _{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot M(x',y') + ^2)\f] */ + TM_CCORR_NORMED = 3, /*!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{ + \sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f] + with mask: + \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y') \cdot + M(x',y')^2)}{\sqrt{\sum_{x',y'} \left( T(x',y') \cdot M(x',y') + \right)^2 \cdot \sum_{x',y'} \left( I(x+x',y+y') \cdot M(x',y') + \right)^2}}\f] */ + TM_CCOEFF = 4, /*!< \f[R(x,y)= \sum _{x',y'} (T'(x',y') \cdot I'(x+x',y+y'))\f] + where + \f[\begin{array}{l} T'(x',y')=T(x',y') - 1/(w \cdot h) \cdot \sum _{ + x'',y''} T(x'',y'') \\ I'(x+x',y+y')=I(x+x',y+y') - 1/(w \cdot h) + \cdot \sum _{x'',y''} I(x+x'',y+y'') \end{array}\f] + with mask: + \f[\begin{array}{l} T'(x',y')=M(x',y') \cdot \left( T(x',y') - + \frac{1}{\sum _{x'',y''} M(x'',y'')} \cdot \sum _{x'',y''} + (T(x'',y'') \cdot M(x'',y'')) \right) \\ I'(x+x',y+y')=M(x',y') + \cdot \left( I(x+x',y+y') - \frac{1}{\sum _{x'',y''} M(x'',y'')} + \cdot \sum _{x'',y''} (I(x+x'',y+y'') \cdot M(x'',y'')) \right) + \end{array} \f] */ + TM_CCOEFF_NORMED = 5 /*!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ + \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} + }\f] */ +}; + +/** @example samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp +An example using Template Matching algorithm +*/ + +/** @brief Compares a template against overlapped image regions. + +The function slides through image , compares the overlapped patches of size \f$w \times h\f$ against +templ using the specified method and stores the comparison results in result . #TemplateMatchModes +describes the formulae for the available comparison methods ( \f$I\f$ denotes image, \f$T\f$ +template, \f$R\f$ result, \f$M\f$ the optional mask ). The summation is done over template and/or +the image patch: \f$x' = 0...w-1, y' = 0...h-1\f$ + +After the function finishes the comparison, the best matches can be found as global minimums (when +#TM_SQDIFF was used) or maximums (when #TM_CCORR or #TM_CCOEFF was used) using the +#minMaxLoc function. In case of a color image, template summation in the numerator and each sum in +the denominator is done over all of the channels and separate mean values are used for each channel. +That is, the function can take a color template and a color image. The result will still be a +single-channel image, which is easier to analyze. + +@param image Image where the search is running. It must be 8-bit or 32-bit floating-point. +@param templ Searched template. It must be not greater than the source image and have the same +data type. +@param result Map of comparison results. It must be single-channel 32-bit floating-point. If image +is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ . +@param method Parameter specifying the comparison method, see #TemplateMatchModes +@param mask Optional mask. It must have the same size as templ. It must either have the same number + of channels as template or only one channel, which is then used for all template and + image channels. If the data type is #CV_8U, the mask is interpreted as a binary mask, + meaning only elements where mask is nonzero are used and are kept unchanged independent + of the actual mask value (weight equals 1). For data tpye #CV_32F, the mask values are + used as weights. The exact formulas are documented in #TemplateMatchModes. + */ +CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ, + OutputArray result, int method, InputArray mask = noArray() ); + +//! @} + +//! @addtogroup imgproc_shape +//! @{ + +/** @example samples/cpp/connected_components.cpp +This program demonstrates connected components and use of the trackbar +*/ + +/** @brief computes the connected components labeled image of boolean image + +image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0 +represents the background label. ltype specifies the output label image type, an important +consideration based on the total number of labels or alternatively the total number of pixels in +the source image. ccltype specifies the connected components labeling algorithm to use, currently +Bolelli (Spaghetti) @cite Bolelli2019, Grana (BBDT) @cite Grana2010 and Wu's (SAUF) @cite Wu2009 algorithms +are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces +a row major ordering of labels while Spaghetti and BBDT do not. +This function uses parallel version of the algorithms if at least one allowed +parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs. + +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +@param ccltype connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes). +*/ +CV_EXPORTS_AS(connectedComponentsWithAlgorithm) int connectedComponents(InputArray image, OutputArray labels, + int connectivity, int ltype, int ccltype); + + +/** @overload + +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +*/ +CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels, + int connectivity = 8, int ltype = CV_32S); + + +/** @brief computes the connected components labeled image of boolean image and also produces a statistics output for each label + +image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0 +represents the background label. ltype specifies the output label image type, an important +consideration based on the total number of labels or alternatively the total number of pixels in +the source image. ccltype specifies the connected components labeling algorithm to use, currently +Bolelli (Spaghetti) @cite Bolelli2019, Grana (BBDT) @cite Grana2010 and Wu's (SAUF) @cite Wu2009 algorithms +are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces +a row major ordering of labels while Spaghetti and BBDT do not. +This function uses parallel version of the algorithms (statistics included) if at least one allowed +parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs. + +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param stats statistics output for each label, including the background label. +Statistics are accessed via stats(label, COLUMN) where COLUMN is one of +#ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S. +@param centroids centroid output for each label, including the background label. Centroids are +accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F. +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +@param ccltype connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes). +*/ +CV_EXPORTS_AS(connectedComponentsWithStatsWithAlgorithm) int connectedComponentsWithStats(InputArray image, OutputArray labels, + OutputArray stats, OutputArray centroids, + int connectivity, int ltype, int ccltype); + +/** @overload +@param image the 8-bit single-channel image to be labeled +@param labels destination labeled image +@param stats statistics output for each label, including the background label. +Statistics are accessed via stats(label, COLUMN) where COLUMN is one of +#ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S. +@param centroids centroid output for each label, including the background label. Centroids are +accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F. +@param connectivity 8 or 4 for 8-way or 4-way connectivity respectively +@param ltype output image label type. Currently CV_32S and CV_16U are supported. +*/ +CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labels, + OutputArray stats, OutputArray centroids, + int connectivity = 8, int ltype = CV_32S); + + +/** @brief Finds contours in a binary image. + +The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . The contours +are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the +OpenCV sample directory. +@note Since opencv 3.2 source image is not modified by this function. + +@param image Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero +pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold , +#adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. +If mode equals to #RETR_CCOMP or #RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1). +@param contours Detected contours. Each contour is stored as a vector of points (e.g. +std::vector >). +@param hierarchy Optional output vector (e.g. std::vector), containing information about the image topology. It has +as many elements as the number of contours. For each i-th contour contours[i], the elements +hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices +in contours of the next and previous contours at the same hierarchical level, the first child +contour and the parent contour, respectively. If for the contour i there are no next, previous, +parent, or nested contours, the corresponding elements of hierarchy[i] will be negative. +@note In Python, hierarchy is nested inside a top level array. Use hierarchy[0][i] to access hierarchical elements of i-th contour. +@param mode Contour retrieval mode, see #RetrievalModes +@param method Contour approximation method, see #ContourApproximationModes +@param offset Optional offset by which every contour point is shifted. This is useful if the +contours are extracted from the image ROI and then they should be analyzed in the whole image +context. + */ +CV_EXPORTS_W void findContours( InputArray image, OutputArrayOfArrays contours, + OutputArray hierarchy, int mode, + int method, Point offset = Point()); + +/** @overload */ +CV_EXPORTS void findContours( InputArray image, OutputArrayOfArrays contours, + int mode, int method, Point offset = Point()); + +/** @example samples/cpp/squares.cpp +A program using pyramid scaling, Canny, contours and contour simplification to find +squares in a list of images (pic1-6.png). Returns sequence of squares detected on the image. +*/ + +/** @example samples/tapi/squares.cpp +A program using pyramid scaling, Canny, contours and contour simplification to find +squares in the input image. +*/ + +/** @brief Approximates a polygonal curve(s) with the specified precision. + +The function cv::approxPolyDP approximates a curve or a polygon with another curve/polygon with less +vertices so that the distance between them is less or equal to the specified precision. It uses the +Douglas-Peucker algorithm + +@param curve Input vector of a 2D point stored in std::vector or Mat +@param approxCurve Result of the approximation. The type should match the type of the input curve. +@param epsilon Parameter specifying the approximation accuracy. This is the maximum distance +between the original curve and its approximation. +@param closed If true, the approximated curve is closed (its first and last vertices are +connected). Otherwise, it is not closed. + */ +CV_EXPORTS_W void approxPolyDP( InputArray curve, + OutputArray approxCurve, + double epsilon, bool closed ); + +/** @brief Calculates a contour perimeter or a curve length. + +The function computes a curve length or a closed contour perimeter. + +@param curve Input vector of 2D points, stored in std::vector or Mat. +@param closed Flag indicating whether the curve is closed or not. + */ +CV_EXPORTS_W double arcLength( InputArray curve, bool closed ); + +/** @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image. + +The function calculates and returns the minimal up-right bounding rectangle for the specified point set or +non-zero pixels of gray-scale image. + +@param array Input gray-scale image or 2D point set, stored in std::vector or Mat. + */ +CV_EXPORTS_W Rect boundingRect( InputArray array ); + +/** @brief Calculates a contour area. + +The function computes a contour area. Similarly to moments , the area is computed using the Green +formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using +#drawContours or #fillPoly , can be different. Also, the function will most certainly give a wrong +results for contours with self-intersections. + +Example: +@code + vector contour; + contour.push_back(Point2f(0, 0)); + contour.push_back(Point2f(10, 0)); + contour.push_back(Point2f(10, 10)); + contour.push_back(Point2f(5, 4)); + + double area0 = contourArea(contour); + vector approx; + approxPolyDP(contour, approx, 5, true); + double area1 = contourArea(approx); + + cout << "area0 =" << area0 << endl << + "area1 =" << area1 << endl << + "approx poly vertices" << approx.size() << endl; +@endcode +@param contour Input vector of 2D points (contour vertices), stored in std::vector or Mat. +@param oriented Oriented area flag. If it is true, the function returns a signed area value, +depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can +determine orientation of a contour by taking the sign of an area. By default, the parameter is +false, which means that the absolute value is returned. + */ +CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false ); + +/** @brief Finds a rotated rectangle of the minimum area enclosing the input 2D point set. + +The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a +specified point set. Developer should keep in mind that the returned RotatedRect can contain negative +indices when data is close to the containing Mat element boundary. + +@param points Input vector of 2D points, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect minAreaRect( InputArray points ); + +/** @brief Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle. + +The function finds the four vertices of a rotated rectangle. This function is useful to draw the +rectangle. In C++, instead of using this function, you can directly use RotatedRect::points method. Please +visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information. + +@param box The input rotated rectangle. It may be the output of +@param points The output array of four vertices of rectangles. + */ +CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points); + +/** @brief Finds a circle of the minimum area enclosing a 2D point set. + +The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm. + +@param points Input vector of 2D points, stored in std::vector\<\> or Mat +@param center Output center of the circle. +@param radius Output radius of the circle. + */ +CV_EXPORTS_W void minEnclosingCircle( InputArray points, + CV_OUT Point2f& center, CV_OUT float& radius ); + +/** @example samples/cpp/minarea.cpp +*/ + +/** @brief Finds a triangle of minimum area enclosing a 2D point set and returns its area. + +The function finds a triangle of minimum area enclosing the given set of 2D points and returns its +area. The output for a given 2D point set is shown in the image below. 2D points are depicted in +*red* and the enclosing triangle in *yellow*. + +![Sample output of the minimum enclosing triangle function](pics/minenclosingtriangle.png) + +The implementation of the algorithm is based on O'Rourke's @cite ORourke86 and Klee and Laskowski's +@cite KleeLaskowski85 papers. O'Rourke provides a \f$\theta(n)\f$ algorithm for finding the minimal +enclosing triangle of a 2D convex polygon with n vertices. Since the #minEnclosingTriangle function +takes a 2D point set as input an additional preprocessing step of computing the convex hull of the +2D point set is required. The complexity of the #convexHull function is \f$O(n log(n))\f$ which is higher +than \f$\theta(n)\f$. Thus the overall complexity of the function is \f$O(n log(n))\f$. + +@param points Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector\<\> or Mat +@param triangle Output vector of three 2D points defining the vertices of the triangle. The depth +of the OutputArray must be CV_32F. + */ +CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle ); + +/** @brief Compares two shapes. + +The function compares two shapes. All three implemented methods use the Hu invariants (see #HuMoments) + +@param contour1 First contour or grayscale image. +@param contour2 Second contour or grayscale image. +@param method Comparison method, see #ShapeMatchModes +@param parameter Method-specific parameter (not supported now). + */ +CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2, + int method, double parameter ); + +/** @example samples/cpp/convexhull.cpp +An example using the convexHull functionality +*/ + +/** @brief Finds the convex hull of a point set. + +The function cv::convexHull finds the convex hull of a 2D point set using the Sklansky's algorithm @cite Sklansky82 +that has *O(N logN)* complexity in the current implementation. + +@param points Input 2D point set, stored in std::vector or Mat. +@param hull Output convex hull. It is either an integer vector of indices or vector of points. In +the first case, the hull elements are 0-based indices of the convex hull points in the original +array (since the set of convex hull points is a subset of the original point set). In the second +case, hull elements are the convex hull points themselves. +@param clockwise Orientation flag. If it is true, the output convex hull is oriented clockwise. +Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing +to the right, and its Y axis pointing upwards. +@param returnPoints Operation flag. In case of a matrix, when the flag is true, the function +returns convex hull points. Otherwise, it returns indices of the convex hull points. When the +output array is std::vector, the flag is ignored, and the output depends on the type of the +vector: std::vector\ implies returnPoints=false, std::vector\ implies +returnPoints=true. + +@note `points` and `hull` should be different arrays, inplace processing isn't supported. + +Check @ref tutorial_hull "the corresponding tutorial" for more details. + +useful links: + +https://www.learnopencv.com/convex-hull-using-opencv-in-python-and-c/ + */ +CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull, + bool clockwise = false, bool returnPoints = true ); + +/** @brief Finds the convexity defects of a contour. + +The figure below displays convexity defects of a hand contour: + +![image](pics/defects.png) + +@param contour Input contour. +@param convexhull Convex hull obtained using convexHull that should contain indices of the contour +points that make the hull. +@param convexityDefects The output vector of convexity defects. In C++ and the new Python/Java +interface each convexity defect is represented as 4-element integer vector (a.k.a. #Vec4i): +(start_index, end_index, farthest_pt_index, fixpt_depth), where indices are 0-based indices +in the original contour of the convexity defect beginning, end and the farthest point, and +fixpt_depth is fixed-point approximation (with 8 fractional bits) of the distance between the +farthest contour point and the hull. That is, to get the floating-point value of the depth will be +fixpt_depth/256.0. + */ +CV_EXPORTS_W void convexityDefects( InputArray contour, InputArray convexhull, OutputArray convexityDefects ); + +/** @brief Tests a contour convexity. + +The function tests whether the input contour is convex or not. The contour must be simple, that is, +without self-intersections. Otherwise, the function output is undefined. + +@param contour Input vector of 2D points, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W bool isContourConvex( InputArray contour ); + +/** @example samples/cpp/intersectExample.cpp +Examples of how intersectConvexConvex works +*/ + +/** @brief Finds intersection of two convex polygons + +@param p1 First polygon +@param p2 Second polygon +@param p12 Output polygon describing the intersecting area +@param handleNested When true, an intersection is found if one of the polygons is fully enclosed in the other. +When false, no intersection is found. If the polygons share a side or the vertex of one polygon lies on an edge +of the other, they are not considered nested and an intersection will be found regardless of the value of handleNested. + +@returns Absolute value of area of intersecting polygon + +@note intersectConvexConvex doesn't confirm that both polygons are convex and will return invalid results if they aren't. + */ +CV_EXPORTS_W float intersectConvexConvex( InputArray p1, InputArray p2, + OutputArray p12, bool handleNested = true ); + +/** @example samples/cpp/fitellipse.cpp +An example using the fitEllipse technique +*/ + +/** @brief Fits an ellipse around a set of 2D points. + +The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of +all. It returns the rotated rectangle in which the ellipse is inscribed. The first algorithm described by @cite Fitzgibbon95 +is used. Developer should keep in mind that it is possible that the returned +ellipse/rotatedRect data contains negative indices, due to the data points being close to the +border of the containing Mat element. + +@param points Input 2D point set, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect fitEllipse( InputArray points ); + +/** @brief Fits an ellipse around a set of 2D points. + + The function calculates the ellipse that fits a set of 2D points. + It returns the rotated rectangle in which the ellipse is inscribed. + The Approximate Mean Square (AMS) proposed by @cite Taubin1991 is used. + + For an ellipse, this basis set is \f$ \chi= \left(x^2, x y, y^2, x, y, 1\right) \f$, + which is a set of six free coefficients \f$ A^T=\left\{A_{\text{xx}},A_{\text{xy}},A_{\text{yy}},A_x,A_y,A_0\right\} \f$. + However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \f$ (a,b) \f$, + the position \f$ (x_0,y_0) \f$, and the orientation \f$ \theta \f$. This is because the basis set includes lines, + quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits. + If the fit is found to be a parabolic or hyperbolic function then the standard #fitEllipse method is used. + The AMS method restricts the fit to parabolic, hyperbolic and elliptical curves + by imposing the condition that \f$ A^T ( D_x^T D_x + D_y^T D_y) A = 1 \f$ where + the matrices \f$ Dx \f$ and \f$ Dy \f$ are the partial derivatives of the design matrix \f$ D \f$ with + respect to x and y. The matrices are formed row by row applying the following to + each of the points in the set: + \f{align*}{ + D(i,:)&=\left\{x_i^2, x_i y_i, y_i^2, x_i, y_i, 1\right\} & + D_x(i,:)&=\left\{2 x_i,y_i,0,1,0,0\right\} & + D_y(i,:)&=\left\{0,x_i,2 y_i,0,1,0\right\} + \f} + The AMS method minimizes the cost function + \f{equation*}{ + \epsilon ^2=\frac{ A^T D^T D A }{ A^T (D_x^T D_x + D_y^T D_y) A^T } + \f} + + The minimum cost is found by solving the generalized eigenvalue problem. + + \f{equation*}{ + D^T D A = \lambda \left( D_x^T D_x + D_y^T D_y\right) A + \f} + + @param points Input 2D point set, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect fitEllipseAMS( InputArray points ); + + +/** @brief Fits an ellipse around a set of 2D points. + + The function calculates the ellipse that fits a set of 2D points. + It returns the rotated rectangle in which the ellipse is inscribed. + The Direct least square (Direct) method by @cite Fitzgibbon1999 is used. + + For an ellipse, this basis set is \f$ \chi= \left(x^2, x y, y^2, x, y, 1\right) \f$, + which is a set of six free coefficients \f$ A^T=\left\{A_{\text{xx}},A_{\text{xy}},A_{\text{yy}},A_x,A_y,A_0\right\} \f$. + However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \f$ (a,b) \f$, + the position \f$ (x_0,y_0) \f$, and the orientation \f$ \theta \f$. This is because the basis set includes lines, + quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits. + The Direct method confines the fit to ellipses by ensuring that \f$ 4 A_{xx} A_{yy}- A_{xy}^2 > 0 \f$. + The condition imposed is that \f$ 4 A_{xx} A_{yy}- A_{xy}^2=1 \f$ which satisfies the inequality + and as the coefficients can be arbitrarily scaled is not overly restrictive. + + \f{equation*}{ + \epsilon ^2= A^T D^T D A \quad \text{with} \quad A^T C A =1 \quad \text{and} \quad C=\left(\begin{matrix} + 0 & 0 & 2 & 0 & 0 & 0 \\ + 0 & -1 & 0 & 0 & 0 & 0 \\ + 2 & 0 & 0 & 0 & 0 & 0 \\ + 0 & 0 & 0 & 0 & 0 & 0 \\ + 0 & 0 & 0 & 0 & 0 & 0 \\ + 0 & 0 & 0 & 0 & 0 & 0 + \end{matrix} \right) + \f} + + The minimum cost is found by solving the generalized eigenvalue problem. + + \f{equation*}{ + D^T D A = \lambda \left( C\right) A + \f} + + The system produces only one positive eigenvalue \f$ \lambda\f$ which is chosen as the solution + with its eigenvector \f$\mathbf{u}\f$. These are used to find the coefficients + + \f{equation*}{ + A = \sqrt{\frac{1}{\mathbf{u}^T C \mathbf{u}}} \mathbf{u} + \f} + The scaling factor guarantees that \f$A^T C A =1\f$. + + @param points Input 2D point set, stored in std::vector\<\> or Mat + */ +CV_EXPORTS_W RotatedRect fitEllipseDirect( InputArray points ); + +/** @brief Fits a line to a 2D or 3D point set. + +The function fitLine fits a line to a 2D or 3D point set by minimizing \f$\sum_i \rho(r_i)\f$ where +\f$r_i\f$ is a distance between the \f$i^{th}\f$ point, the line and \f$\rho(r)\f$ is a distance function, one +of the following: +- DIST_L2 +\f[\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\f] +- DIST_L1 +\f[\rho (r) = r\f] +- DIST_L12 +\f[\rho (r) = 2 \cdot ( \sqrt{1 + \frac{r^2}{2}} - 1)\f] +- DIST_FAIR +\f[\rho \left (r \right ) = C^2 \cdot \left ( \frac{r}{C} - \log{\left(1 + \frac{r}{C}\right)} \right ) \quad \text{where} \quad C=1.3998\f] +- DIST_WELSCH +\f[\rho \left (r \right ) = \frac{C^2}{2} \cdot \left ( 1 - \exp{\left(-\left(\frac{r}{C}\right)^2\right)} \right ) \quad \text{where} \quad C=2.9846\f] +- DIST_HUBER +\f[\rho (r) = \fork{r^2/2}{if \(r < C\)}{C \cdot (r-C/2)}{otherwise} \quad \text{where} \quad C=1.345\f] + +The algorithm is based on the M-estimator ( ) technique +that iteratively fits the line using the weighted least-squares algorithm. After each iteration the +weights \f$w_i\f$ are adjusted to be inversely proportional to \f$\rho(r_i)\f$ . + +@param points Input vector of 2D or 3D points, stored in std::vector\<\> or Mat. +@param line Output line parameters. In case of 2D fitting, it should be a vector of 4 elements +(like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and +(x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like +Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line +and (x0, y0, z0) is a point on the line. +@param distType Distance used by the M-estimator, see #DistanceTypes +@param param Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value +is chosen. +@param reps Sufficient accuracy for the radius (distance between the coordinate origin and the line). +@param aeps Sufficient accuracy for the angle. 0.01 would be a good default value for reps and aeps. + */ +CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType, + double param, double reps, double aeps ); + +/** @brief Performs a point-in-contour test. + +The function determines whether the point is inside a contour, outside, or lies on an edge (or +coincides with a vertex). It returns positive (inside), negative (outside), or zero (on an edge) +value, correspondingly. When measureDist=false , the return value is +1, -1, and 0, respectively. +Otherwise, the return value is a signed distance between the point and the nearest contour edge. + +See below a sample output of the function where each image pixel is tested against the contour: + +![sample output](pics/pointpolygon.png) + +@param contour Input contour. +@param pt Point tested against the contour. +@param measureDist If true, the function estimates the signed distance from the point to the +nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not. + */ +CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist ); + +/** @brief Finds out if there is any intersection between two rotated rectangles. + +If there is then the vertices of the intersecting region are returned as well. + +Below are some examples of intersection configurations. The hatched pattern indicates the +intersecting region and the red vertices are returned by the function. + +![intersection examples](pics/intersection.png) + +@param rect1 First rectangle +@param rect2 Second rectangle +@param intersectingRegion The output array of the vertices of the intersecting region. It returns +at most 8 vertices. Stored as std::vector\ or cv::Mat as Mx1 of type CV_32FC2. +@returns One of #RectanglesIntersectTypes + */ +CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion ); + +/** @brief Creates a smart pointer to a cv::GeneralizedHoughBallard class and initializes it. +*/ +CV_EXPORTS_W Ptr createGeneralizedHoughBallard(); + +/** @brief Creates a smart pointer to a cv::GeneralizedHoughGuil class and initializes it. +*/ +CV_EXPORTS_W Ptr createGeneralizedHoughGuil(); + +//! @} imgproc_shape + +//! @addtogroup imgproc_colormap +//! @{ + +//! GNU Octave/MATLAB equivalent colormaps +enum ColormapTypes +{ + COLORMAP_AUTUMN = 0, //!< ![autumn](pics/colormaps/colorscale_autumn.jpg) + COLORMAP_BONE = 1, //!< ![bone](pics/colormaps/colorscale_bone.jpg) + COLORMAP_JET = 2, //!< ![jet](pics/colormaps/colorscale_jet.jpg) + COLORMAP_WINTER = 3, //!< ![winter](pics/colormaps/colorscale_winter.jpg) + COLORMAP_RAINBOW = 4, //!< ![rainbow](pics/colormaps/colorscale_rainbow.jpg) + COLORMAP_OCEAN = 5, //!< ![ocean](pics/colormaps/colorscale_ocean.jpg) + COLORMAP_SUMMER = 6, //!< ![summer](pics/colormaps/colorscale_summer.jpg) + COLORMAP_SPRING = 7, //!< ![spring](pics/colormaps/colorscale_spring.jpg) + COLORMAP_COOL = 8, //!< ![cool](pics/colormaps/colorscale_cool.jpg) + COLORMAP_HSV = 9, //!< ![HSV](pics/colormaps/colorscale_hsv.jpg) + COLORMAP_PINK = 10, //!< ![pink](pics/colormaps/colorscale_pink.jpg) + COLORMAP_HOT = 11, //!< ![hot](pics/colormaps/colorscale_hot.jpg) + COLORMAP_PARULA = 12, //!< ![parula](pics/colormaps/colorscale_parula.jpg) + COLORMAP_MAGMA = 13, //!< ![magma](pics/colormaps/colorscale_magma.jpg) + COLORMAP_INFERNO = 14, //!< ![inferno](pics/colormaps/colorscale_inferno.jpg) + COLORMAP_PLASMA = 15, //!< ![plasma](pics/colormaps/colorscale_plasma.jpg) + COLORMAP_VIRIDIS = 16, //!< ![viridis](pics/colormaps/colorscale_viridis.jpg) + COLORMAP_CIVIDIS = 17, //!< ![cividis](pics/colormaps/colorscale_cividis.jpg) + COLORMAP_TWILIGHT = 18, //!< ![twilight](pics/colormaps/colorscale_twilight.jpg) + COLORMAP_TWILIGHT_SHIFTED = 19, //!< ![twilight shifted](pics/colormaps/colorscale_twilight_shifted.jpg) + COLORMAP_TURBO = 20, //!< ![turbo](pics/colormaps/colorscale_turbo.jpg) + COLORMAP_DEEPGREEN = 21 //!< ![deepgreen](pics/colormaps/colorscale_deepgreen.jpg) +}; + +/** @example samples/cpp/falsecolor.cpp +An example using applyColorMap function +*/ + +/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image. + +@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3. +@param dst The result is the colormapped source image. Note: Mat::create is called on dst. +@param colormap The colormap to apply, see #ColormapTypes +*/ +CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap); + +/** @brief Applies a user colormap on a given image. + +@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3. +@param dst The result is the colormapped source image. Note: Mat::create is called on dst. +@param userColor The colormap to apply of type CV_8UC1 or CV_8UC3 and size 256 +*/ +CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, InputArray userColor); + +//! @} imgproc_colormap + +//! @addtogroup imgproc_draw +//! @{ + + +/** OpenCV color channel order is BGR[A] */ +#define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0) + +/** @brief Draws a line segment connecting two points. + +The function line draws the line segment between pt1 and pt2 points in the image. The line is +clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected +or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings. Antialiased +lines are drawn using Gaussian filtering. + +@param img Image. +@param pt1 First point of the line segment. +@param pt2 Second point of the line segment. +@param color Line color. +@param thickness Line thickness. +@param lineType Type of the line. See #LineTypes. +@param shift Number of fractional bits in the point coordinates. + */ +CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, + int thickness = 1, int lineType = LINE_8, int shift = 0); + +/** @brief Draws an arrow segment pointing from the first point to the second one. + +The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line. + +@param img Image. +@param pt1 The point the arrow starts from. +@param pt2 The point the arrow points to. +@param color Line color. +@param thickness Line thickness. +@param line_type Type of the line. See #LineTypes +@param shift Number of fractional bits in the point coordinates. +@param tipLength The length of the arrow tip in relation to the arrow length + */ +CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color, + int thickness=1, int line_type=8, int shift=0, double tipLength=0.1); + +/** @brief Draws a simple, thick, or filled up-right rectangle. + +The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners +are pt1 and pt2. + +@param img Image. +@param pt1 Vertex of the rectangle. +@param pt2 Vertex of the rectangle opposite to pt1 . +@param color Rectangle color or brightness (grayscale image). +@param thickness Thickness of lines that make up the rectangle. Negative values, like #FILLED, +mean that the function has to draw a filled rectangle. +@param lineType Type of the line. See #LineTypes +@param shift Number of fractional bits in the point coordinates. + */ +CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @overload + +use `rec` parameter as alternative specification of the drawn rectangle: `r.tl() and +r.br()-Point(1,1)` are opposite corners +*/ +CV_EXPORTS_W void rectangle(InputOutputArray img, Rect rec, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @example samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp +An example using drawing functions +*/ + +/** @brief Draws a circle. + +The function cv::circle draws a simple or filled circle with a given center and radius. +@param img Image where the circle is drawn. +@param center Center of the circle. +@param radius Radius of the circle. +@param color Circle color. +@param thickness Thickness of the circle outline, if positive. Negative values, like #FILLED, +mean that a filled circle is to be drawn. +@param lineType Type of the circle boundary. See #LineTypes +@param shift Number of fractional bits in the coordinates of the center and in the radius value. + */ +CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @brief Draws a simple or thick elliptic arc or fills an ellipse sector. + +The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic +arc, or a filled ellipse sector. The drawing code uses general parametric form. +A piecewise-linear curve is used to approximate the elliptic arc +boundary. If you need more control of the ellipse rendering, you can retrieve the curve using +#ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first +variant of the function and want to draw the whole ellipse, not an arc, pass `startAngle=0` and +`endAngle=360`. If `startAngle` is greater than `endAngle`, they are swapped. The figure below explains +the meaning of the parameters to draw the blue arc. + +![Parameters of Elliptic Arc](pics/ellipse.svg) + +@param img Image. +@param center Center of the ellipse. +@param axes Half of the size of the ellipse main axes. +@param angle Ellipse rotation angle in degrees. +@param startAngle Starting angle of the elliptic arc in degrees. +@param endAngle Ending angle of the elliptic arc in degrees. +@param color Ellipse color. +@param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that +a filled ellipse sector is to be drawn. +@param lineType Type of the ellipse boundary. See #LineTypes +@param shift Number of fractional bits in the coordinates of the center and values of axes. + */ +CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes, + double angle, double startAngle, double endAngle, + const Scalar& color, int thickness = 1, + int lineType = LINE_8, int shift = 0); + +/** @overload +@param img Image. +@param box Alternative ellipse representation via RotatedRect. This means that the function draws +an ellipse inscribed in the rotated rectangle. +@param color Ellipse color. +@param thickness Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that +a filled ellipse sector is to be drawn. +@param lineType Type of the ellipse boundary. See #LineTypes +*/ +CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color, + int thickness = 1, int lineType = LINE_8); + +/* ----------------------------------------------------------------------------------------- */ +/* ADDING A SET OF PREDEFINED MARKERS WHICH COULD BE USED TO HIGHLIGHT POSITIONS IN AN IMAGE */ +/* ----------------------------------------------------------------------------------------- */ + +/** @brief Draws a marker on a predefined position in an image. + +The function cv::drawMarker draws a marker on a given position in the image. For the moment several +marker types are supported, see #MarkerTypes for more information. + +@param img Image. +@param position The point where the crosshair is positioned. +@param color Line color. +@param markerType The specific type of marker you want to use, see #MarkerTypes +@param thickness Line thickness. +@param line_type Type of the line, See #LineTypes +@param markerSize The length of the marker axis [default = 20 pixels] + */ +CV_EXPORTS_W void drawMarker(InputOutputArray img, Point position, const Scalar& color, + int markerType = MARKER_CROSS, int markerSize=20, int thickness=1, + int line_type=8); + +/* ----------------------------------------------------------------------------------------- */ +/* END OF MARKER SECTION */ +/* ----------------------------------------------------------------------------------------- */ + +/** @brief Fills a convex polygon. + +The function cv::fillConvexPoly draws a filled convex polygon. This function is much faster than the +function #fillPoly . It can fill not only convex polygons but any monotonic polygon without +self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line) +twice at the most (though, its top-most and/or the bottom edge could be horizontal). + +@param img Image. +@param points Polygon vertices. +@param color Polygon color. +@param lineType Type of the polygon boundaries. See #LineTypes +@param shift Number of fractional bits in the vertex coordinates. + */ +CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points, + const Scalar& color, int lineType = LINE_8, + int shift = 0); + +/** @overload */ +CV_EXPORTS void fillConvexPoly(InputOutputArray img, const Point* pts, int npts, + const Scalar& color, int lineType = LINE_8, + int shift = 0); + +/** @example samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp +An example using drawing functions +Check @ref tutorial_random_generator_and_text "the corresponding tutorial" for more details +*/ + +/** @brief Fills the area bounded by one or more polygons. + +The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill +complex areas, for example, areas with holes, contours with self-intersections (some of their +parts), and so forth. + +@param img Image. +@param pts Array of polygons where each polygon is represented as an array of points. +@param color Polygon color. +@param lineType Type of the polygon boundaries. See #LineTypes +@param shift Number of fractional bits in the vertex coordinates. +@param offset Optional offset of all points of the contours. + */ +CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts, + const Scalar& color, int lineType = LINE_8, int shift = 0, + Point offset = Point() ); + +/** @overload */ +CV_EXPORTS void fillPoly(InputOutputArray img, const Point** pts, + const int* npts, int ncontours, + const Scalar& color, int lineType = LINE_8, int shift = 0, + Point offset = Point() ); + +/** @brief Draws several polygonal curves. + +@param img Image. +@param pts Array of polygonal curves. +@param isClosed Flag indicating whether the drawn polylines are closed or not. If they are closed, +the function draws a line from the last vertex of each curve to its first vertex. +@param color Polyline color. +@param thickness Thickness of the polyline edges. +@param lineType Type of the line segments. See #LineTypes +@param shift Number of fractional bits in the vertex coordinates. + +The function cv::polylines draws one or more polygonal curves. + */ +CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts, + bool isClosed, const Scalar& color, + int thickness = 1, int lineType = LINE_8, int shift = 0 ); + +/** @overload */ +CV_EXPORTS void polylines(InputOutputArray img, const Point* const* pts, const int* npts, + int ncontours, bool isClosed, const Scalar& color, + int thickness = 1, int lineType = LINE_8, int shift = 0 ); + +/** @example samples/cpp/contours2.cpp +An example program illustrates the use of cv::findContours and cv::drawContours +\image html WindowsQtContoursOutput.png "Screenshot of the program" +*/ + +/** @example samples/cpp/segment_objects.cpp +An example using drawContours to clean up a background segmentation result +*/ + +/** @brief Draws contours outlines or filled contours. + +The function draws contour outlines in the image if \f$\texttt{thickness} \ge 0\f$ or fills the area +bounded by the contours if \f$\texttt{thickness}<0\f$ . The example below shows how to retrieve +connected components from the binary image and label them: : +@include snippets/imgproc_drawContours.cpp + +@param image Destination image. +@param contours All the input contours. Each contour is stored as a point vector. +@param contourIdx Parameter indicating a contour to draw. If it is negative, all the contours are drawn. +@param color Color of the contours. +@param thickness Thickness of lines the contours are drawn with. If it is negative (for example, +thickness=#FILLED ), the contour interiors are drawn. +@param lineType Line connectivity. See #LineTypes +@param hierarchy Optional information about hierarchy. It is only needed if you want to draw only +some of the contours (see maxLevel ). +@param maxLevel Maximal level for drawn contours. If it is 0, only the specified contour is drawn. +If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function +draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This +parameter is only taken into account when there is hierarchy available. +@param offset Optional contour shift parameter. Shift all the drawn contours by the specified +\f$\texttt{offset}=(dx,dy)\f$ . +@note When thickness=#FILLED, the function is designed to handle connected components with holes correctly +even when no hierarchy data is provided. This is done by analyzing all the outlines together +using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved +contours. In order to solve this problem, you need to call #drawContours separately for each sub-group +of contours, or iterate over the collection using contourIdx parameter. + */ +CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours, + int contourIdx, const Scalar& color, + int thickness = 1, int lineType = LINE_8, + InputArray hierarchy = noArray(), + int maxLevel = INT_MAX, Point offset = Point() ); + +/** @brief Clips the line against the image rectangle. + +The function cv::clipLine calculates a part of the line segment that is entirely within the specified +rectangle. It returns false if the line segment is completely outside the rectangle. Otherwise, +it returns true . +@param imgSize Image size. The image rectangle is Rect(0, 0, imgSize.width, imgSize.height) . +@param pt1 First line point. +@param pt2 Second line point. + */ +CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2); + +/** @overload +@param imgSize Image size. The image rectangle is Rect(0, 0, imgSize.width, imgSize.height) . +@param pt1 First line point. +@param pt2 Second line point. +*/ +CV_EXPORTS bool clipLine(Size2l imgSize, CV_IN_OUT Point2l& pt1, CV_IN_OUT Point2l& pt2); + +/** @overload +@param imgRect Image rectangle. +@param pt1 First line point. +@param pt2 Second line point. +*/ +CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_IN_OUT Point& pt2); + +/** @brief Approximates an elliptic arc with a polyline. + +The function ellipse2Poly computes the vertices of a polyline that approximates the specified +elliptic arc. It is used by #ellipse. If `arcStart` is greater than `arcEnd`, they are swapped. + +@param center Center of the arc. +@param axes Half of the size of the ellipse main axes. See #ellipse for details. +@param angle Rotation angle of the ellipse in degrees. See #ellipse for details. +@param arcStart Starting angle of the elliptic arc in degrees. +@param arcEnd Ending angle of the elliptic arc in degrees. +@param delta Angle between the subsequent polyline vertices. It defines the approximation +accuracy. +@param pts Output vector of polyline vertices. + */ +CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle, + int arcStart, int arcEnd, int delta, + CV_OUT std::vector& pts ); + +/** @overload +@param center Center of the arc. +@param axes Half of the size of the ellipse main axes. See #ellipse for details. +@param angle Rotation angle of the ellipse in degrees. See #ellipse for details. +@param arcStart Starting angle of the elliptic arc in degrees. +@param arcEnd Ending angle of the elliptic arc in degrees. +@param delta Angle between the subsequent polyline vertices. It defines the approximation accuracy. +@param pts Output vector of polyline vertices. +*/ +CV_EXPORTS void ellipse2Poly(Point2d center, Size2d axes, int angle, + int arcStart, int arcEnd, int delta, + CV_OUT std::vector& pts); + +/** @brief Draws a text string. + +The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered +using the specified font are replaced by question marks. See #getTextSize for a text rendering code +example. + +@param img Image. +@param text Text string to be drawn. +@param org Bottom-left corner of the text string in the image. +@param fontFace Font type, see #HersheyFonts. +@param fontScale Font scale factor that is multiplied by the font-specific base size. +@param color Text color. +@param thickness Thickness of the lines used to draw a text. +@param lineType Line type. See #LineTypes +@param bottomLeftOrigin When true, the image data origin is at the bottom-left corner. Otherwise, +it is at the top-left corner. + */ +CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org, + int fontFace, double fontScale, Scalar color, + int thickness = 1, int lineType = LINE_8, + bool bottomLeftOrigin = false ); + +/** @brief Calculates the width and height of a text string. + +The function cv::getTextSize calculates and returns the size of a box that contains the specified text. +That is, the following code renders some text, the tight box surrounding it, and the baseline: : +@code + String text = "Funny text inside the box"; + int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX; + double fontScale = 2; + int thickness = 3; + + Mat img(600, 800, CV_8UC3, Scalar::all(0)); + + int baseline=0; + Size textSize = getTextSize(text, fontFace, + fontScale, thickness, &baseline); + baseline += thickness; + + // center the text + Point textOrg((img.cols - textSize.width)/2, + (img.rows + textSize.height)/2); + + // draw the box + rectangle(img, textOrg + Point(0, baseline), + textOrg + Point(textSize.width, -textSize.height), + Scalar(0,0,255)); + // ... and the baseline first + line(img, textOrg + Point(0, thickness), + textOrg + Point(textSize.width, thickness), + Scalar(0, 0, 255)); + + // then put the text itself + putText(img, text, textOrg, fontFace, fontScale, + Scalar::all(255), thickness, 8); +@endcode + +@param text Input text string. +@param fontFace Font to use, see #HersheyFonts. +@param fontScale Font scale factor that is multiplied by the font-specific base size. +@param thickness Thickness of lines used to render the text. See #putText for details. +@param[out] baseLine y-coordinate of the baseline relative to the bottom-most text +point. +@return The size of a box that contains the specified text. + +@see putText + */ +CV_EXPORTS_W Size getTextSize(const String& text, int fontFace, + double fontScale, int thickness, + CV_OUT int* baseLine); + + +/** @brief Calculates the font-specific size to use to achieve a given height in pixels. + +@param fontFace Font to use, see cv::HersheyFonts. +@param pixelHeight Pixel height to compute the fontScale for +@param thickness Thickness of lines used to render the text.See putText for details. +@return The fontSize to use for cv::putText + +@see cv::putText +*/ +CV_EXPORTS_W double getFontScaleFromHeight(const int fontFace, + const int pixelHeight, + const int thickness = 1); + +/** @brief Line iterator + +The class is used to iterate over all the pixels on the raster line +segment connecting two specified points. + +The class LineIterator is used to get each pixel of a raster line. It +can be treated as versatile implementation of the Bresenham algorithm +where you can stop at each pixel and do some extra processing, for +example, grab pixel values along the line or draw a line with an effect +(for example, with XOR operation). + +The number of pixels along the line is stored in LineIterator::count. +The method LineIterator::pos returns the current position in the image: + +@code{.cpp} +// grabs pixels along the line (pt1, pt2) +// from 8-bit 3-channel image to the buffer +LineIterator it(img, pt1, pt2, 8); +LineIterator it2 = it; +vector buf(it.count); + +for(int i = 0; i < it.count; i++, ++it) + buf[i] = *(const Vec3b*)*it; + +// alternative way of iterating through the line +for(int i = 0; i < it2.count; i++, ++it2) +{ + Vec3b val = img.at(it2.pos()); + CV_Assert(buf[i] == val); +} +@endcode +*/ +class CV_EXPORTS LineIterator +{ +public: + /** @brief initializes the iterator + + creates iterators for the line connecting pt1 and pt2 + the line will be clipped on the image boundaries + the line is 8-connected or 4-connected + If leftToRight=true, then the iteration is always done + from the left-most point to the right most, + not to depend on the ordering of pt1 and pt2 parameters; + */ + LineIterator( const Mat& img, Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(&img, Rect(0, 0, img.cols, img.rows), pt1, pt2, connectivity, leftToRight); + ptmode = false; + } + LineIterator( Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(0, Rect(std::min(pt1.x, pt2.x), + std::min(pt1.y, pt2.y), + std::max(pt1.x, pt2.x) - std::min(pt1.x, pt2.x) + 1, + std::max(pt1.y, pt2.y) - std::min(pt1.y, pt2.y) + 1), + pt1, pt2, connectivity, leftToRight); + ptmode = true; + } + LineIterator( Size boundingAreaSize, Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(0, Rect(0, 0, boundingAreaSize.width, boundingAreaSize.height), + pt1, pt2, connectivity, leftToRight); + ptmode = true; + } + LineIterator( Rect boundingAreaRect, Point pt1, Point pt2, + int connectivity = 8, bool leftToRight = false ) + { + init(0, boundingAreaRect, pt1, pt2, connectivity, leftToRight); + ptmode = true; + } + void init(const Mat* img, Rect boundingAreaRect, Point pt1, Point pt2, int connectivity, bool leftToRight); + + /** @brief returns pointer to the current pixel + */ + uchar* operator *(); + /** @brief prefix increment operator (++it). shifts iterator to the next pixel + */ + LineIterator& operator ++(); + /** @brief postfix increment operator (it++). shifts iterator to the next pixel + */ + LineIterator operator ++(int); + /** @brief returns coordinates of the current pixel + */ + Point pos() const; + + uchar* ptr; + const uchar* ptr0; + int step, elemSize; + int err, count; + int minusDelta, plusDelta; + int minusStep, plusStep; + int minusShift, plusShift; + Point p; + bool ptmode; +}; + +//! @cond IGNORED + +// === LineIterator implementation === + +inline +uchar* LineIterator::operator *() +{ + return ptmode ? 0 : ptr; +} + +inline +LineIterator& LineIterator::operator ++() +{ + int mask = err < 0 ? -1 : 0; + err += minusDelta + (plusDelta & mask); + if(!ptmode) + { + ptr += minusStep + (plusStep & mask); + } + else + { + p.x += minusShift + (plusShift & mask); + p.y += minusStep + (plusStep & mask); + } + return *this; +} + +inline +LineIterator LineIterator::operator ++(int) +{ + LineIterator it = *this; + ++(*this); + return it; +} + +inline +Point LineIterator::pos() const +{ + if(!ptmode) + { + size_t offset = (size_t)(ptr - ptr0); + int y = (int)(offset/step); + int x = (int)((offset - (size_t)y*step)/elemSize); + return Point(x, y); + } + return p; +} + +//! @endcond + +//! @} imgproc_draw + +//! @} imgproc + +} // cv + + +#include "./imgproc/segmentation.hpp" + + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/bindings.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/bindings.hpp new file mode 100644 index 0000000..c69527a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/bindings.hpp @@ -0,0 +1,34 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGPROC_BINDINGS_HPP +#define OPENCV_IMGPROC_BINDINGS_HPP + +// This file contains special overloads for OpenCV bindings +// No need to use these functions in C++ code. + +namespace cv { + +/** @brief Finds lines in a binary image using the standard Hough transform and get accumulator. + * + * @note This function is for bindings use only. Use original function in C++ code + * + * @sa HoughLines + */ +CV_WRAP static inline +void HoughLinesWithAccumulator( + InputArray image, OutputArray lines, + double rho, double theta, int threshold, + double srn = 0, double stn = 0, + double min_theta = 0, double max_theta = CV_PI +) +{ + std::vector lines_acc; + HoughLines(image, lines_acc, rho, theta, threshold, srn, stn, min_theta, max_theta); + Mat(lines_acc).copyTo(lines); +} + +} // namespace + +#endif // OPENCV_IMGPROC_BINDINGS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/detail/gcgraph.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/detail/gcgraph.hpp new file mode 100644 index 0000000..f17c6e7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/detail/gcgraph.hpp @@ -0,0 +1,395 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_DETAIL_GCGRAPH_HPP +#define OPENCV_IMGPROC_DETAIL_GCGRAPH_HPP + +//! @cond IGNORED + +namespace cv { namespace detail { +template class GCGraph +{ +public: + GCGraph(); + GCGraph( unsigned int vtxCount, unsigned int edgeCount ); + ~GCGraph(); + void create( unsigned int vtxCount, unsigned int edgeCount ); + int addVtx(); + void addEdges( int i, int j, TWeight w, TWeight revw ); + void addTermWeights( int i, TWeight sourceW, TWeight sinkW ); + TWeight maxFlow(); + bool inSourceSegment( int i ); +private: + class Vtx + { + public: + Vtx *next; // initialized and used in maxFlow() only + int parent; + int first; + int ts; + int dist; + TWeight weight; + uchar t; + }; + class Edge + { + public: + int dst; + int next; + TWeight weight; + }; + + std::vector vtcs; + std::vector edges; + TWeight flow; +}; + +template +GCGraph::GCGraph() +{ + flow = 0; +} +template +GCGraph::GCGraph( unsigned int vtxCount, unsigned int edgeCount ) +{ + create( vtxCount, edgeCount ); +} +template +GCGraph::~GCGraph() +{ +} +template +void GCGraph::create( unsigned int vtxCount, unsigned int edgeCount ) +{ + vtcs.reserve( vtxCount ); + edges.reserve( edgeCount + 2 ); + flow = 0; +} + +template +int GCGraph::addVtx() +{ + Vtx v; + memset( &v, 0, sizeof(Vtx)); + vtcs.push_back(v); + return (int)vtcs.size() - 1; +} + +template +void GCGraph::addEdges( int i, int j, TWeight w, TWeight revw ) +{ + CV_Assert( i>=0 && i<(int)vtcs.size() ); + CV_Assert( j>=0 && j<(int)vtcs.size() ); + CV_Assert( w>=0 && revw>=0 ); + CV_Assert( i != j ); + + if( !edges.size() ) + edges.resize( 2 ); + + Edge fromI, toI; + fromI.dst = j; + fromI.next = vtcs[i].first; + fromI.weight = w; + vtcs[i].first = (int)edges.size(); + edges.push_back( fromI ); + + toI.dst = i; + toI.next = vtcs[j].first; + toI.weight = revw; + vtcs[j].first = (int)edges.size(); + edges.push_back( toI ); +} + +template +void GCGraph::addTermWeights( int i, TWeight sourceW, TWeight sinkW ) +{ + CV_Assert( i>=0 && i<(int)vtcs.size() ); + + TWeight dw = vtcs[i].weight; + if( dw > 0 ) + sourceW += dw; + else + sinkW -= dw; + flow += (sourceW < sinkW) ? sourceW : sinkW; + vtcs[i].weight = sourceW - sinkW; +} + +template +TWeight GCGraph::maxFlow() +{ + CV_Assert(!vtcs.empty()); + CV_Assert(!edges.empty()); + const int TERMINAL = -1, ORPHAN = -2; + Vtx stub, *nilNode = &stub, *first = nilNode, *last = nilNode; + int curr_ts = 0; + stub.next = nilNode; + Vtx *vtxPtr = &vtcs[0]; + Edge *edgePtr = &edges[0]; + + std::vector orphans; + + // initialize the active queue and the graph vertices + for( int i = 0; i < (int)vtcs.size(); i++ ) + { + Vtx* v = vtxPtr + i; + v->ts = 0; + if( v->weight != 0 ) + { + last = last->next = v; + v->dist = 1; + v->parent = TERMINAL; + v->t = v->weight < 0; + } + else + v->parent = 0; + } + first = first->next; + last->next = nilNode; + nilNode->next = 0; + + // run the search-path -> augment-graph -> restore-trees loop + for(;;) + { + Vtx* v, *u; + int e0 = -1, ei = 0, ej = 0; + TWeight minWeight, weight; + uchar vt; + + // grow S & T search trees, find an edge connecting them + while( first != nilNode ) + { + v = first; + if( v->parent ) + { + vt = v->t; + for( ei = v->first; ei != 0; ei = edgePtr[ei].next ) + { + if( edgePtr[ei^vt].weight == 0 ) + continue; + u = vtxPtr+edgePtr[ei].dst; + if( !u->parent ) + { + u->t = vt; + u->parent = ei ^ 1; + u->ts = v->ts; + u->dist = v->dist + 1; + if( !u->next ) + { + u->next = nilNode; + last = last->next = u; + } + continue; + } + + if( u->t != vt ) + { + e0 = ei ^ vt; + break; + } + + if( u->dist > v->dist+1 && u->ts <= v->ts ) + { + // reassign the parent + u->parent = ei ^ 1; + u->ts = v->ts; + u->dist = v->dist + 1; + } + } + if( e0 > 0 ) + break; + } + // exclude the vertex from the active list + first = first->next; + v->next = 0; + } + + if( e0 <= 0 ) + break; + + // find the minimum edge weight along the path + minWeight = edgePtr[e0].weight; + CV_Assert( minWeight > 0 ); + // k = 1: source tree, k = 0: destination tree + for( int k = 1; k >= 0; k-- ) + { + for( v = vtxPtr+edgePtr[e0^k].dst;; v = vtxPtr+edgePtr[ei].dst ) + { + if( (ei = v->parent) < 0 ) + break; + weight = edgePtr[ei^k].weight; + minWeight = MIN(minWeight, weight); + CV_Assert( minWeight > 0 ); + } + weight = fabs(v->weight); + minWeight = MIN(minWeight, weight); + CV_Assert( minWeight > 0 ); + } + + // modify weights of the edges along the path and collect orphans + edgePtr[e0].weight -= minWeight; + edgePtr[e0^1].weight += minWeight; + flow += minWeight; + + // k = 1: source tree, k = 0: destination tree + for( int k = 1; k >= 0; k-- ) + { + for( v = vtxPtr+edgePtr[e0^k].dst;; v = vtxPtr+edgePtr[ei].dst ) + { + if( (ei = v->parent) < 0 ) + break; + edgePtr[ei^(k^1)].weight += minWeight; + if( (edgePtr[ei^k].weight -= minWeight) == 0 ) + { + orphans.push_back(v); + v->parent = ORPHAN; + } + } + + v->weight = v->weight + minWeight*(1-k*2); + if( v->weight == 0 ) + { + orphans.push_back(v); + v->parent = ORPHAN; + } + } + + // restore the search trees by finding new parents for the orphans + curr_ts++; + while( !orphans.empty() ) + { + Vtx* v2 = orphans.back(); + orphans.pop_back(); + + int d, minDist = INT_MAX; + e0 = 0; + vt = v2->t; + + for( ei = v2->first; ei != 0; ei = edgePtr[ei].next ) + { + if( edgePtr[ei^(vt^1)].weight == 0 ) + continue; + u = vtxPtr+edgePtr[ei].dst; + if( u->t != vt || u->parent == 0 ) + continue; + // compute the distance to the tree root + for( d = 0;; ) + { + if( u->ts == curr_ts ) + { + d += u->dist; + break; + } + ej = u->parent; + d++; + if( ej < 0 ) + { + if( ej == ORPHAN ) + d = INT_MAX-1; + else + { + u->ts = curr_ts; + u->dist = 1; + } + break; + } + u = vtxPtr+edgePtr[ej].dst; + } + + // update the distance + if( ++d < INT_MAX ) + { + if( d < minDist ) + { + minDist = d; + e0 = ei; + } + for( u = vtxPtr+edgePtr[ei].dst; u->ts != curr_ts; u = vtxPtr+edgePtr[u->parent].dst ) + { + u->ts = curr_ts; + u->dist = --d; + } + } + } + + if( (v2->parent = e0) > 0 ) + { + v2->ts = curr_ts; + v2->dist = minDist; + continue; + } + + /* no parent is found */ + v2->ts = 0; + for( ei = v2->first; ei != 0; ei = edgePtr[ei].next ) + { + u = vtxPtr+edgePtr[ei].dst; + ej = u->parent; + if( u->t != vt || !ej ) + continue; + if( edgePtr[ei^(vt^1)].weight && !u->next ) + { + u->next = nilNode; + last = last->next = u; + } + if( ej > 0 && vtxPtr+edgePtr[ej].dst == v2 ) + { + orphans.push_back(u); + u->parent = ORPHAN; + } + } + } + } + return flow; +} + +template +bool GCGraph::inSourceSegment( int i ) +{ + CV_Assert( i>=0 && i<(int)vtcs.size() ); + return vtcs[i].t == 0; +} + +}} // namespace detail, cv + + +//! @endcond + +#endif // OPENCV_IMGPROC_DETAIL_GCGRAPH_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/hal/hal.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/hal/hal.hpp new file mode 100644 index 0000000..f129012 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/hal/hal.hpp @@ -0,0 +1,246 @@ +#ifndef CV_IMGPROC_HAL_HPP +#define CV_IMGPROC_HAL_HPP + +#include "opencv2/core/cvdef.h" +#include "opencv2/core/cvstd.hpp" +#include "opencv2/core/hal/interface.h" + +namespace cv { namespace hal { + +//! @addtogroup imgproc_hal_functions +//! @{ + +//--------------------------- +//! @cond IGNORED + +struct CV_EXPORTS Filter2D +{ + CV_DEPRECATED static Ptr create(uchar * , size_t , int , + int , int , + int , int , + int , int , + int , double , + int , int , + bool , bool ); + virtual void apply(uchar * , size_t , + uchar * , size_t , + int , int , + int , int , + int , int ) = 0; + virtual ~Filter2D() {} +}; + +struct CV_EXPORTS SepFilter2D +{ + CV_DEPRECATED static Ptr create(int , int , int , + uchar * , int , + uchar * , int , + int , int , + double , int ); + virtual void apply(uchar * , size_t , + uchar * , size_t , + int , int , + int , int , + int , int ) = 0; + virtual ~SepFilter2D() {} +}; + + +struct CV_EXPORTS Morph +{ + CV_DEPRECATED static Ptr create(int , int , int , int , int , + int , uchar * , size_t , + int , int , + int , int , + int , const double *, + int , bool , bool ); + virtual void apply(uchar * , size_t , uchar * , size_t , int , int , + int , int , int , int , + int , int , int , int ) = 0; + virtual ~Morph() {} +}; + +//! @endcond +//--------------------------- + +CV_EXPORTS void filter2D(int stype, int dtype, int kernel_type, + uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int full_width, int full_height, + int offset_x, int offset_y, + uchar * kernel_data, size_t kernel_step, + int kernel_width, int kernel_height, + int anchor_x, int anchor_y, + double delta, int borderType, + bool isSubmatrix); + +CV_EXPORTS void sepFilter2D(int stype, int dtype, int ktype, + uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int full_width, int full_height, + int offset_x, int offset_y, + uchar * kernelx_data, int kernelx_len, + uchar * kernely_data, int kernely_len, + int anchor_x, int anchor_y, + double delta, int borderType); + +CV_EXPORTS void morph(int op, int src_type, int dst_type, + uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int roi_width, int roi_height, int roi_x, int roi_y, + int roi_width2, int roi_height2, int roi_x2, int roi_y2, + int kernel_type, uchar * kernel_data, size_t kernel_step, + int kernel_width, int kernel_height, int anchor_x, int anchor_y, + int borderType, const double borderValue[4], + int iterations, bool isSubmatrix); + + +CV_EXPORTS void resize(int src_type, + const uchar * src_data, size_t src_step, int src_width, int src_height, + uchar * dst_data, size_t dst_step, int dst_width, int dst_height, + double inv_scale_x, double inv_scale_y, int interpolation); + +CV_EXPORTS void warpAffine(int src_type, + const uchar * src_data, size_t src_step, int src_width, int src_height, + uchar * dst_data, size_t dst_step, int dst_width, int dst_height, + const double M[6], int interpolation, int borderType, const double borderValue[4]); + +CV_EXPORTS void warpPerspective(int src_type, + const uchar * src_data, size_t src_step, int src_width, int src_height, + uchar * dst_data, size_t dst_step, int dst_width, int dst_height, + const double M[9], int interpolation, int borderType, const double borderValue[4]); + +CV_EXPORTS void cvtBGRtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, int dcn, bool swapBlue); + +CV_EXPORTS void cvtBGRtoBGR5x5(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int scn, bool swapBlue, int greenBits); + +CV_EXPORTS void cvtBGR5x5toBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int dcn, bool swapBlue, int greenBits); + +CV_EXPORTS void cvtBGRtoGray(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue); + +CV_EXPORTS void cvtGraytoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn); + +CV_EXPORTS void cvtBGR5x5toGray(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int greenBits); + +CV_EXPORTS void cvtGraytoBGR5x5(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int greenBits); +CV_EXPORTS void cvtBGRtoYUV(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue, bool isCbCr); + +CV_EXPORTS void cvtYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue, bool isCbCr); + +CV_EXPORTS void cvtBGRtoXYZ(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue); + +CV_EXPORTS void cvtXYZtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue); + +CV_EXPORTS void cvtBGRtoHSV(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue, bool isFullRange, bool isHSV); + +CV_EXPORTS void cvtHSVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue, bool isFullRange, bool isHSV); + +CV_EXPORTS void cvtBGRtoLab(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int scn, bool swapBlue, bool isLab, bool srgb); + +CV_EXPORTS void cvtLabtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int depth, int dcn, bool swapBlue, bool isLab, bool srgb); + +CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +//! Separate Y and UV planes +CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * y_data, const uchar * uv_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtTwoPlaneYUVtoBGR(const uchar * y_data, size_t y_step, const uchar * uv_data, size_t uv_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtThreePlaneYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int dst_width, int dst_height, + int dcn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtBGRtoThreePlaneYUV(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int scn, bool swapBlue, int uIdx); + +//! Separate Y and UV planes +CV_EXPORTS void cvtBGRtoTwoPlaneYUV(const uchar * src_data, size_t src_step, + uchar * y_data, uchar * uv_data, size_t dst_step, + int width, int height, + int scn, bool swapBlue, int uIdx); + +CV_EXPORTS void cvtOnePlaneYUVtoBGR(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height, + int dcn, bool swapBlue, int uIdx, int ycn); + +CV_EXPORTS void cvtRGBAtoMultipliedRGBA(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height); + +CV_EXPORTS void cvtMultipliedRGBAtoRGBA(const uchar * src_data, size_t src_step, + uchar * dst_data, size_t dst_step, + int width, int height); + +CV_EXPORTS void integral(int depth, int sdepth, int sqdepth, + const uchar* src, size_t srcstep, + uchar* sum, size_t sumstep, + uchar* sqsum, size_t sqsumstep, + uchar* tilted, size_t tstep, + int width, int height, int cn); + +//! @} + +}} + +#endif // CV_IMGPROC_HAL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/hal/interface.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/hal/interface.h new file mode 100644 index 0000000..f8dbcfe --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/hal/interface.h @@ -0,0 +1,46 @@ +#ifndef OPENCV_IMGPROC_HAL_INTERFACE_H +#define OPENCV_IMGPROC_HAL_INTERFACE_H + +//! @addtogroup imgproc_hal_interface +//! @{ + +//! @name Interpolation modes +//! @sa cv::InterpolationFlags +//! @{ +#define CV_HAL_INTER_NEAREST 0 +#define CV_HAL_INTER_LINEAR 1 +#define CV_HAL_INTER_CUBIC 2 +#define CV_HAL_INTER_AREA 3 +#define CV_HAL_INTER_LANCZOS4 4 +//! @} + +//! @name Morphology operations +//! @sa cv::MorphTypes +//! @{ +#define CV_HAL_MORPH_ERODE 0 +#define CV_HAL_MORPH_DILATE 1 +//! @} + +//! @name Threshold types +//! @sa cv::ThresholdTypes +//! @{ +#define CV_HAL_THRESH_BINARY 0 +#define CV_HAL_THRESH_BINARY_INV 1 +#define CV_HAL_THRESH_TRUNC 2 +#define CV_HAL_THRESH_TOZERO 3 +#define CV_HAL_THRESH_TOZERO_INV 4 +#define CV_HAL_THRESH_MASK 7 +#define CV_HAL_THRESH_OTSU 8 +#define CV_HAL_THRESH_TRIANGLE 16 +//! @} + +//! @name Adaptive threshold algorithm +//! @sa cv::AdaptiveThresholdTypes +//! @{ +#define CV_HAL_ADAPTIVE_THRESH_MEAN_C 0 +#define CV_HAL_ADAPTIVE_THRESH_GAUSSIAN_C 1 +//! @} + +//! @} + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/imgproc.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/imgproc.hpp new file mode 100644 index 0000000..4175bd0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/imgproc.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/imgproc.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/imgproc_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/imgproc_c.h new file mode 100644 index 0000000..86dc119 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/imgproc_c.h @@ -0,0 +1,1177 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_IMGPROC_C_H +#define OPENCV_IMGPROC_IMGPROC_C_H + +#include "opencv2/imgproc/types_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup imgproc_c +@{ +*/ + +/*********************** Background statistics accumulation *****************************/ + +/** @brief Adds image to accumulator +@see cv::accumulate +*/ +CVAPI(void) cvAcc( const CvArr* image, CvArr* sum, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Adds squared image to accumulator +@see cv::accumulateSquare +*/ +CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Adds a product of two images to accumulator +@see cv::accumulateProduct +*/ +CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc, + const CvArr* mask CV_DEFAULT(NULL) ); + +/** @brief Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha +@see cv::accumulateWeighted +*/ +CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha, + const CvArr* mask CV_DEFAULT(NULL) ); + +/****************************************************************************************\ +* Image Processing * +\****************************************************************************************/ + +/** Copies source 2D array inside of the larger destination array and + makes a border of the specified type (IPL_BORDER_*) around the copied area. */ +CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset, + int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0))); + +/** @brief Smooths the image in one of several ways. + +@param src The source image +@param dst The destination image +@param smoothtype Type of the smoothing, see SmoothMethod_c +@param size1 The first parameter of the smoothing operation, the aperture width. Must be a +positive odd number (1, 3, 5, ...) +@param size2 The second parameter of the smoothing operation, the aperture height. Ignored by +CV_MEDIAN and CV_BILATERAL methods. In the case of simple scaled/non-scaled and Gaussian blur if +size2 is zero, it is set to size1. Otherwise it must be a positive odd number. +@param sigma1 In the case of a Gaussian parameter this parameter may specify Gaussian \f$\sigma\f$ +(standard deviation). If it is zero, it is calculated from the kernel size: +\f[\sigma = 0.3 (n/2 - 1) + 0.8 \quad \text{where} \quad n= \begin{array}{l l} \mbox{\texttt{size1} for horizontal kernel} \\ \mbox{\texttt{size2} for vertical kernel} \end{array}\f] +Using standard sigma for small kernels ( \f$3\times 3\f$ to \f$7\times 7\f$ ) gives better speed. If +sigma1 is not zero, while size1 and size2 are zeros, the kernel size is calculated from the +sigma (to provide accurate enough operation). +@param sigma2 additional parameter for bilateral filtering + +@see cv::GaussianBlur, cv::blur, cv::medianBlur, cv::bilateralFilter. + */ +CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst, + int smoothtype CV_DEFAULT(CV_GAUSSIAN), + int size1 CV_DEFAULT(3), + int size2 CV_DEFAULT(0), + double sigma1 CV_DEFAULT(0), + double sigma2 CV_DEFAULT(0)); + +/** @brief Convolves an image with the kernel. + +@param src input image. +@param dst output image of the same size and the same number of channels as src. +@param kernel convolution kernel (or rather a correlation kernel), a single-channel floating point +matrix; if you want to apply different kernels to different channels, split the image into +separate color planes using split and process them individually. +@param anchor anchor of the kernel that indicates the relative position of a filtered point within +the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor +is at the kernel center. + +@see cv::filter2D + */ +CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, + CvPoint anchor CV_DEFAULT(cvPoint(-1,-1))); + +/** @brief Finds integral image: SUM(X,Y) = sum(x \texttt{hist1}(I)\)}{\frac{\texttt{hist2}(I) \cdot \texttt{scale}}{\texttt{hist1}(I)}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) \le \texttt{hist1}(I)\)}\f] + +@param hist1 First histogram (the divisor). +@param hist2 Second histogram. +@param dst_hist Destination histogram. +@param scale Scale factor for the destination histogram. + */ +CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2, + CvHistogram* dst_hist, double scale CV_DEFAULT(255) ); + +/** @brief equalizes histogram of 8-bit single-channel image +@see cv::equalizeHist +*/ +CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst ); + + +/** @brief Applies distance transform to binary image +@see cv::distanceTransform +*/ +CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst, + int distance_type CV_DEFAULT(CV_DIST_L2), + int mask_size CV_DEFAULT(3), + const float* mask CV_DEFAULT(NULL), + CvArr* labels CV_DEFAULT(NULL), + int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP)); + + +/** @brief Applies fixed-level threshold to grayscale image. + + This is a basic operation applied before retrieving contours +@see cv::threshold +*/ +CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst, + double threshold, double max_value, + int threshold_type ); + +/** @brief Applies adaptive threshold to grayscale image. + + The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and + CV_ADAPTIVE_THRESH_GAUSSIAN_C are: + neighborhood size (3, 5, 7 etc.), + and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) +@see cv::adaptiveThreshold +*/ +CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value, + int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C), + int threshold_type CV_DEFAULT(CV_THRESH_BINARY), + int block_size CV_DEFAULT(3), + double param1 CV_DEFAULT(5)); + +/** @brief Fills the connected component until the color difference gets large enough +@see cv::floodFill +*/ +CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point, + CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)), + CvScalar up_diff CV_DEFAULT(cvScalarAll(0)), + CvConnectedComp* comp CV_DEFAULT(NULL), + int flags CV_DEFAULT(4), + CvArr* mask CV_DEFAULT(NULL)); + +/****************************************************************************************\ +* Feature detection * +\****************************************************************************************/ + +/** @brief Runs canny edge detector +@see cv::Canny +*/ +CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1, + double threshold2, int aperture_size CV_DEFAULT(3) ); + +/** @brief Calculates constraint image for corner detection + + Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. + Applying threshold to the result gives coordinates of corners +@see cv::preCornerDetect +*/ +CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners, + int aperture_size CV_DEFAULT(3) ); + +/** @brief Calculates eigen values and vectors of 2x2 + gradient covariation matrix at every image pixel +@see cv::cornerEigenValsAndVecs +*/ +CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/** @brief Calculates minimal eigenvalue for 2x2 gradient covariation matrix at + every image pixel +@see cv::cornerMinEigenVal +*/ +CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, + int block_size, int aperture_size CV_DEFAULT(3) ); + +/** @brief Harris corner detector: + + Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel +@see cv::cornerHarris +*/ +CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_response, + int block_size, int aperture_size CV_DEFAULT(3), + double k CV_DEFAULT(0.04) ); + +/** @brief Adjust corner position using some sort of gradient search +@see cv::cornerSubPix +*/ +CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, + int count, CvSize win, CvSize zero_zone, + CvTermCriteria criteria ); + +/** @brief Finds a sparse set of points within the selected region + that seem to be easy to track +@see cv::goodFeaturesToTrack +*/ +CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, + CvArr* temp_image, CvPoint2D32f* corners, + int* corner_count, double quality_level, + double min_distance, + const CvArr* mask CV_DEFAULT(NULL), + int block_size CV_DEFAULT(3), + int use_harris CV_DEFAULT(0), + double k CV_DEFAULT(0.04) ); + +/** @brief Finds lines on binary image using one of several methods. + + line_storage is either memory storage or 1 x _max number of lines_ CvMat, its + number of columns is changed by the function. + method is one of CV_HOUGH_*; + rho, theta and threshold are used for each of those methods; + param1 ~ line length, param2 ~ line gap - for probabilistic, + param1 ~ srn, param2 ~ stn - for multi-scale +@see cv::HoughLines +*/ +CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method, + double rho, double theta, int threshold, + double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0), + double min_theta CV_DEFAULT(0), double max_theta CV_DEFAULT(CV_PI)); + +/** @brief Finds circles in the image +@see cv::HoughCircles +*/ +CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage, + int method, double dp, double min_dist, + double param1 CV_DEFAULT(100), + double param2 CV_DEFAULT(100), + int min_radius CV_DEFAULT(0), + int max_radius CV_DEFAULT(0)); + +/** @brief Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) +@see cv::fitLine +*/ +CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, + double reps, double aeps, float* line ); + +/****************************************************************************************\ +* Drawing * +\****************************************************************************************/ + +/****************************************************************************************\ +* Drawing functions work with images/matrices of arbitrary type. * +* For color images the channel order is BGR[A] * +* Antialiasing is supported only for 8-bit image now. * +* All the functions include parameter color that means rgb value (that may be * +* constructed with CV_RGB macro) for color images and brightness * +* for grayscale images. * +* If a drawn figure is partially or completely outside of the image, it is clipped.* +\****************************************************************************************/ + +#define CV_FILLED -1 + +#define CV_AA 16 + +/** @brief Draws 4-connected, 8-connected or antialiased line segment connecting two points +@see cv::line +*/ +CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/** @brief Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2) + + if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn +@see cv::rectangle +*/ +CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + int shift CV_DEFAULT(0)); + +/** @brief Draws a rectangle specified by a CvRect structure +@see cv::rectangle +*/ +CVAPI(void) cvRectangleR( CvArr* img, CvRect r, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + int shift CV_DEFAULT(0)); + + +/** @brief Draws a circle with specified center and radius. + + Thickness works in the same way as with cvRectangle +@see cv::circle +*/ +CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/** @brief Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector + + depending on _thickness_, _start_angle_ and _end_angle_ parameters. The resultant figure + is rotated by _angle_. All the angles are in degrees +@see cv::ellipse +*/ +CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, + double angle, double start_angle, double end_angle, + CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color, + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ) +{ + CvSize axes = cvSize( + cvRound(box.size.width*0.5), + cvRound(box.size.height*0.5) + ); + + cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle, + 0, 360, color, thickness, line_type, shift ); +} + +/** @brief Fills convex or monotonous polygon. +@see cv::fillConvexPoly +*/ +CVAPI(void) cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); + +/** @brief Fills an area bounded by one or more arbitrary polygons +@see cv::fillPoly +*/ +CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, const int* npts, + int contours, CvScalar color, + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +/** @brief Draws one or more polygonal curves +@see cv::polylines +*/ +CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours, + int is_closed, CvScalar color, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); + +#define cvDrawRect cvRectangle +#define cvDrawLine cvLine +#define cvDrawCircle cvCircle +#define cvDrawEllipse cvEllipse +#define cvDrawPolyLine cvPolyLine + +/** @brief Clips the line segment connecting *pt1 and *pt2 + by the rectangular window + + (0<=xptr will point to pt1 (or pt2, see left_to_right description) location in +the image. Returns the number of pixels on the line between the ending points. +@see cv::LineIterator +*/ +CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2, + CvLineIterator* line_iterator, + int connectivity CV_DEFAULT(8), + int left_to_right CV_DEFAULT(0)); + +#define CV_NEXT_LINE_POINT( line_iterator ) \ +{ \ + int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \ + (line_iterator).err += (line_iterator).minus_delta + \ + ((line_iterator).plus_delta & _line_iterator_mask); \ + (line_iterator).ptr += (line_iterator).minus_step + \ + ((line_iterator).plus_step & _line_iterator_mask); \ +} + + +#define CV_FONT_HERSHEY_SIMPLEX 0 +#define CV_FONT_HERSHEY_PLAIN 1 +#define CV_FONT_HERSHEY_DUPLEX 2 +#define CV_FONT_HERSHEY_COMPLEX 3 +#define CV_FONT_HERSHEY_TRIPLEX 4 +#define CV_FONT_HERSHEY_COMPLEX_SMALL 5 +#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6 +#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7 + +#define CV_FONT_ITALIC 16 + +#define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX + + +/** Font structure */ +typedef struct CvFont +{ + const char* nameFont; //Qt:nameFont + CvScalar color; //Qt:ColorFont -> cvScalar(blue_component, green_component, red_component[, alpha_component]) + int font_face; //Qt: bool italic /** =CV_FONT_* */ + const int* ascii; //!< font data and metrics + const int* greek; + const int* cyrillic; + float hscale, vscale; + float shear; //!< slope coefficient: 0 - normal, >0 - italic + int thickness; //!< Qt: weight /** letters thickness */ + float dx; //!< horizontal interval between letters + int line_type; //!< Qt: PointSize +} +CvFont; + +/** @brief Initializes font structure (OpenCV 1.x API). + +The function initializes the font structure that can be passed to text rendering functions. + +@param font Pointer to the font structure initialized by the function +@param font_face Font name identifier. See cv::HersheyFonts and corresponding old CV_* identifiers. +@param hscale Horizontal scale. If equal to 1.0f , the characters have the original width +depending on the font type. If equal to 0.5f , the characters are of half the original width. +@param vscale Vertical scale. If equal to 1.0f , the characters have the original height depending +on the font type. If equal to 0.5f , the characters are of half the original height. +@param shear Approximate tangent of the character slope relative to the vertical line. A zero +value means a non-italic font, 1.0f means about a 45 degree slope, etc. +@param thickness Thickness of the text strokes +@param line_type Type of the strokes, see line description + +@sa cvPutText + */ +CVAPI(void) cvInitFont( CvFont* font, int font_face, + double hscale, double vscale, + double shear CV_DEFAULT(0), + int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8)); + +CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) ) +{ + CvFont font; + cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA ); + return font; +} + +/** @brief Renders text stroke with specified font and color at specified location. + CvFont should be initialized with cvInitFont +@see cvInitFont, cvGetTextSize, cvFont, cv::putText +*/ +CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org, + const CvFont* font, CvScalar color ); + +/** @brief Calculates bounding box of text stroke (useful for alignment) +@see cv::getTextSize +*/ +CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font, + CvSize* text_size, int* baseline ); + +/** @brief Unpacks color value + +if arrtype is CV_8UC?, _color_ is treated as packed color value, otherwise the first channels +(depending on arrtype) of destination scalar are set to the same value = _color_ +*/ +CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype ); + +/** @brief Returns the polygon points which make up the given ellipse. + +The ellipse is define by the box of size 'axes' rotated 'angle' around the 'center'. A partial +sweep of the ellipse arc can be done by specifying arc_start and arc_end to be something other than +0 and 360, respectively. The input array 'pts' must be large enough to hold the result. The total +number of points stored into 'pts' is returned by this function. +@see cv::ellipse2Poly +*/ +CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes, + int angle, int arc_start, int arc_end, CvPoint * pts, int delta ); + +/** @brief Draws contour outlines or filled interiors on the image +@see cv::drawContours +*/ +CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, + CvScalar external_color, CvScalar hole_color, + int max_level, int thickness CV_DEFAULT(1), + int line_type CV_DEFAULT(8), + CvPoint offset CV_DEFAULT(cvPoint(0,0))); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/segmentation.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/segmentation.hpp new file mode 100644 index 0000000..26882f4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/segmentation.hpp @@ -0,0 +1,141 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_IMGPROC_SEGMENTATION_HPP +#define OPENCV_IMGPROC_SEGMENTATION_HPP + +#include "opencv2/imgproc.hpp" + +namespace cv { + +namespace segmentation { + +//! @addtogroup imgproc_segmentation +//! @{ + + +/** @brief Intelligent Scissors image segmentation + * + * This class is used to find the path (contour) between two points + * which can be used for image segmentation. + * + * Usage example: + * @snippet snippets/imgproc_segmentation.cpp usage_example_intelligent_scissors + * + * Reference: "Intelligent Scissors for Image Composition" + * algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University + * @cite Mortensen95intelligentscissors + */ +class CV_EXPORTS_W_SIMPLE IntelligentScissorsMB +{ +public: + CV_WRAP + IntelligentScissorsMB(); + + /** @brief Specify weights of feature functions + * + * Consider keeping weights normalized (sum of weights equals to 1.0) + * Discrete dynamic programming (DP) goal is minimization of costs between pixels. + * + * @param weight_non_edge Specify cost of non-edge pixels (default: 0.43f) + * @param weight_gradient_direction Specify cost of gradient direction function (default: 0.43f) + * @param weight_gradient_magnitude Specify cost of gradient magnitude function (default: 0.14f) + */ + CV_WRAP + IntelligentScissorsMB& setWeights(float weight_non_edge, float weight_gradient_direction, float weight_gradient_magnitude); + + /** @brief Specify gradient magnitude max value threshold + * + * Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article). + * Otherwize pixels with `gradient magnitude >= threshold` have zero cost. + * + * @note Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos). + * + * @param gradient_magnitude_threshold_max Specify gradient magnitude max value threshold (default: 0, disabled) + */ + CV_WRAP + IntelligentScissorsMB& setGradientMagnitudeMaxLimit(float gradient_magnitude_threshold_max = 0.0f); + + /** @brief Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters + * + * This feature extractor is used by default according to article. + * + * Implementation has additional filtering for regions with low-amplitude noise. + * This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16). + * + * @note Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first). + * + * @note Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters(). + * + * @param gradient_magnitude_min_value Minimal gradient magnitude value for edge pixels (default: 0, check is disabled) + */ + CV_WRAP + IntelligentScissorsMB& setEdgeFeatureZeroCrossingParameters(float gradient_magnitude_min_value = 0.0f); + + /** @brief Switch edge feature extractor to use Canny edge detector + * + * @note "Laplacian Zero-Crossing" feature extractor is used by default (following to original article) + * + * @sa Canny + */ + CV_WRAP + IntelligentScissorsMB& setEdgeFeatureCannyParameters( + double threshold1, double threshold2, + int apertureSize = 3, bool L2gradient = false + ); + + /** @brief Specify input image and extract image features + * + * @param image input image. Type is #CV_8UC1 / #CV_8UC3 + */ + CV_WRAP + IntelligentScissorsMB& applyImage(InputArray image); + + /** @brief Specify custom features of imput image + * + * Customized advanced variant of applyImage() call. + * + * @param non_edge Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are `{0, 1}`. + * @param gradient_direction Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: `x^2 + y^2 == 1` + * @param gradient_magnitude Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range `[0, 1]`. + * @param image **Optional parameter**. Must be specified if subset of features is specified (non-specified features are calculated internally) + */ + CV_WRAP + IntelligentScissorsMB& applyImageFeatures( + InputArray non_edge, InputArray gradient_direction, InputArray gradient_magnitude, + InputArray image = noArray() + ); + + /** @brief Prepares a map of optimal paths for the given source point on the image + * + * @note applyImage() / applyImageFeatures() must be called before this call + * + * @param sourcePt The source point used to find the paths + */ + CV_WRAP void buildMap(const Point& sourcePt); + + /** @brief Extracts optimal contour for the given target point on the image + * + * @note buildMap() must be called before this call + * + * @param targetPt The target point + * @param[out] contour The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with `std::vector`) + * @param backward Flag to indicate reverse order of retrived pixels (use "true" value to fetch points from the target to the source point) + */ + CV_WRAP void getContour(const Point& targetPt, OutputArray contour, bool backward = false) const; + +#ifndef CV_DOXYGEN + struct Impl; + inline Impl* getImpl() const { return impl.get(); } +protected: + std::shared_ptr impl; +#endif +}; + +//! @} + +} // namespace segmentation +} // namespace cv + +#endif // OPENCV_IMGPROC_SEGMENTATION_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/types_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/types_c.h new file mode 100644 index 0000000..d3e55f5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/imgproc/types_c.h @@ -0,0 +1,659 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_IMGPROC_TYPES_C_H +#define OPENCV_IMGPROC_TYPES_C_H + +#include "opencv2/core/core_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup imgproc_c + @{ +*/ + +/** Connected component structure */ +typedef struct CvConnectedComp +{ + double area; /** DBL_EPSILON ? 1./std::sqrt(am00) : 0; + } + operator cv::Moments() const + { + return cv::Moments(m00, m10, m01, m20, m11, m02, m30, m21, m12, m03); + } +#endif +} +CvMoments; + +#ifdef __cplusplus +} // extern "C" + +CV_INLINE CvMoments cvMoments() +{ +#if !defined(CV__ENABLE_C_API_CTORS) + CvMoments self = CV_STRUCT_INITIALIZER; return self; +#else + return CvMoments(); +#endif +} + +CV_INLINE CvMoments cvMoments(const cv::Moments& m) +{ +#if !defined(CV__ENABLE_C_API_CTORS) + double am00 = std::abs(m.m00); + CvMoments self = { + m.m00, m.m10, m.m01, m.m20, m.m11, m.m02, m.m30, m.m21, m.m12, m.m03, + m.mu20, m.mu11, m.mu02, m.mu30, m.mu21, m.mu12, m.mu03, + am00 > DBL_EPSILON ? 1./std::sqrt(am00) : 0 + }; + return self; +#else + return CvMoments(m); +#endif +} + +extern "C" { +#endif // __cplusplus + +/** Hu invariants */ +typedef struct CvHuMoments +{ + double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /**< Hu invariants */ +} +CvHuMoments; + +/** Template matching methods */ +enum +{ + CV_TM_SQDIFF =0, + CV_TM_SQDIFF_NORMED =1, + CV_TM_CCORR =2, + CV_TM_CCORR_NORMED =3, + CV_TM_CCOEFF =4, + CV_TM_CCOEFF_NORMED =5 +}; + +typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param ); + +/** Contour retrieval modes */ +enum +{ + CV_RETR_EXTERNAL=0, + CV_RETR_LIST=1, + CV_RETR_CCOMP=2, + CV_RETR_TREE=3, + CV_RETR_FLOODFILL=4 +}; + +/** Contour approximation methods */ +enum +{ + CV_CHAIN_CODE=0, + CV_CHAIN_APPROX_NONE=1, + CV_CHAIN_APPROX_SIMPLE=2, + CV_CHAIN_APPROX_TC89_L1=3, + CV_CHAIN_APPROX_TC89_KCOS=4, + CV_LINK_RUNS=5 +}; + +/* +Internal structure that is used for sequential retrieving contours from the image. +It supports both hierarchical and plane variants of Suzuki algorithm. +*/ +typedef struct _CvContourScanner* CvContourScanner; + +/** Freeman chain reader state */ +typedef struct CvChainPtReader +{ + CV_SEQ_READER_FIELDS() + char code; + CvPoint pt; + schar deltas[8][2]; +} +CvChainPtReader; + +/** initializes 8-element array for fast access to 3x3 neighborhood of a pixel */ +#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \ + ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ + (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ + (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ + (deltas)[6] = (step), (deltas)[7] = (step) + (nch)) + + +/** Contour approximation algorithms */ +enum +{ + CV_POLY_APPROX_DP = 0 +}; + +/** Shape matching methods */ +enum +{ + CV_CONTOURS_MATCH_I1 =1, //!< \f[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\f] + CV_CONTOURS_MATCH_I2 =2, //!< \f[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\f] + CV_CONTOURS_MATCH_I3 =3 //!< \f[I_3(A,B) = \max _{i=1...7} \frac{ \left| m^A_i - m^B_i \right| }{ \left| m^A_i \right| }\f] +}; + +/** Shape orientation */ +enum +{ + CV_CLOCKWISE =1, + CV_COUNTER_CLOCKWISE =2 +}; + + +/** Convexity defect */ +typedef struct CvConvexityDefect +{ + CvPoint* start; /**< point of the contour where the defect begins */ + CvPoint* end; /**< point of the contour where the defect ends */ + CvPoint* depth_point; /**< the farthest from the convex hull point within the defect */ + float depth; /**< distance between the farthest point and the convex hull */ +} CvConvexityDefect; + + +/** Histogram comparison methods */ +enum +{ + CV_COMP_CORREL =0, + CV_COMP_CHISQR =1, + CV_COMP_INTERSECT =2, + CV_COMP_BHATTACHARYYA =3, + CV_COMP_HELLINGER =CV_COMP_BHATTACHARYYA, + CV_COMP_CHISQR_ALT =4, + CV_COMP_KL_DIV =5 +}; + +/** Mask size for distance transform */ +enum +{ + CV_DIST_MASK_3 =3, + CV_DIST_MASK_5 =5, + CV_DIST_MASK_PRECISE =0 +}; + +/** Content of output label array: connected components or pixels */ +enum +{ + CV_DIST_LABEL_CCOMP = 0, + CV_DIST_LABEL_PIXEL = 1 +}; + +/** Distance types for Distance Transform and M-estimators */ +enum +{ + CV_DIST_USER =-1, /**< User defined distance */ + CV_DIST_L1 =1, /**< distance = |x1-x2| + |y1-y2| */ + CV_DIST_L2 =2, /**< the simple euclidean distance */ + CV_DIST_C =3, /**< distance = max(|x1-x2|,|y1-y2|) */ + CV_DIST_L12 =4, /**< L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */ + CV_DIST_FAIR =5, /**< distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */ + CV_DIST_WELSCH =6, /**< distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */ + CV_DIST_HUBER =7 /**< distance = |x| threshold ? max_value : 0 */ + CV_THRESH_BINARY_INV =1, /**< value = value > threshold ? 0 : max_value */ + CV_THRESH_TRUNC =2, /**< value = value > threshold ? threshold : value */ + CV_THRESH_TOZERO =3, /**< value = value > threshold ? value : 0 */ + CV_THRESH_TOZERO_INV =4, /**< value = value > threshold ? 0 : value */ + CV_THRESH_MASK =7, + CV_THRESH_OTSU =8, /**< use Otsu algorithm to choose the optimal threshold value; + combine the flag with one of the above CV_THRESH_* values */ + CV_THRESH_TRIANGLE =16 /**< use Triangle algorithm to choose the optimal threshold value; + combine the flag with one of the above CV_THRESH_* values, but not + with CV_THRESH_OTSU */ +}; + +/** Adaptive threshold methods */ +enum +{ + CV_ADAPTIVE_THRESH_MEAN_C =0, + CV_ADAPTIVE_THRESH_GAUSSIAN_C =1 +}; + +/** FloodFill flags */ +enum +{ + CV_FLOODFILL_FIXED_RANGE =(1 << 16), + CV_FLOODFILL_MASK_ONLY =(1 << 17) +}; + + +/** Canny edge detector flags */ +enum +{ + CV_CANNY_L2_GRADIENT =(1 << 31) +}; + +/** Variants of a Hough transform */ +enum +{ + CV_HOUGH_STANDARD =0, + CV_HOUGH_PROBABILISTIC =1, + CV_HOUGH_MULTI_SCALE =2, + CV_HOUGH_GRADIENT =3 +}; + + +/* Fast search data structures */ +struct CvFeatureTree; +struct CvLSH; +struct CvLSHOperations; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/ml.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/ml.hpp new file mode 100644 index 0000000..d537ab7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/ml.hpp @@ -0,0 +1,1956 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Copyright (C) 2014, Itseez Inc, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_ML_HPP +#define OPENCV_ML_HPP + +#ifdef __cplusplus +# include "opencv2/core.hpp" +#endif + +#ifdef __cplusplus + +#include +#include +#include + +/** + @defgroup ml Machine Learning + + The Machine Learning Library (MLL) is a set of classes and functions for statistical + classification, regression, and clustering of data. + + Most of the classification and regression algorithms are implemented as C++ classes. As the + algorithms have different sets of features (like an ability to handle missing measurements or + categorical input variables), there is a little common ground between the classes. This common + ground is defined by the class cv::ml::StatModel that all the other ML classes are derived from. + + See detailed overview here: @ref ml_intro. + */ + +namespace cv +{ + +namespace ml +{ + +//! @addtogroup ml +//! @{ + +/** @brief Variable types */ +enum VariableTypes +{ + VAR_NUMERICAL =0, //!< same as VAR_ORDERED + VAR_ORDERED =0, //!< ordered variables + VAR_CATEGORICAL =1 //!< categorical variables +}; + +/** @brief %Error types */ +enum ErrorTypes +{ + TEST_ERROR = 0, + TRAIN_ERROR = 1 +}; + +/** @brief Sample types */ +enum SampleTypes +{ + ROW_SAMPLE = 0, //!< each training sample is a row of samples + COL_SAMPLE = 1 //!< each training sample occupies a column of samples +}; + +/** @brief The structure represents the logarithmic grid range of statmodel parameters. + +It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate +being computed by cross-validation. + */ +class CV_EXPORTS_W ParamGrid +{ +public: + /** @brief Default constructor */ + ParamGrid(); + /** @brief Constructor with parameters */ + ParamGrid(double _minVal, double _maxVal, double _logStep); + + CV_PROP_RW double minVal; //!< Minimum value of the statmodel parameter. Default value is 0. + CV_PROP_RW double maxVal; //!< Maximum value of the statmodel parameter. Default value is 0. + /** @brief Logarithmic step for iterating the statmodel parameter. + + The grid determines the following iteration sequence of the statmodel parameter values: + \f[(minVal, minVal*step, minVal*{step}^2, \dots, minVal*{logStep}^n),\f] + where \f$n\f$ is the maximal index satisfying + \f[\texttt{minVal} * \texttt{logStep} ^n < \texttt{maxVal}\f] + The grid is logarithmic, so logStep must always be greater than 1. Default value is 1. + */ + CV_PROP_RW double logStep; + + /** @brief Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method + + @param minVal minimum value of the parameter grid + @param maxVal maximum value of the parameter grid + @param logstep Logarithmic step for iterating the statmodel parameter + */ + CV_WRAP static Ptr create(double minVal=0., double maxVal=0., double logstep=1.); +}; + +/** @brief Class encapsulating training data. + +Please note that the class only specifies the interface of training data, but not implementation. +All the statistical model classes in _ml_ module accepts Ptr\ as parameter. In other +words, you can create your own class derived from TrainData and pass smart pointer to the instance +of this class into StatModel::train. + +@sa @ref ml_intro_data + */ +class CV_EXPORTS_W TrainData +{ +public: + static inline float missingValue() { return FLT_MAX; } + virtual ~TrainData(); + + CV_WRAP virtual int getLayout() const = 0; + CV_WRAP virtual int getNTrainSamples() const = 0; + CV_WRAP virtual int getNTestSamples() const = 0; + CV_WRAP virtual int getNSamples() const = 0; + CV_WRAP virtual int getNVars() const = 0; + CV_WRAP virtual int getNAllVars() const = 0; + + CV_WRAP virtual void getSample(InputArray varIdx, int sidx, float* buf) const = 0; + CV_WRAP virtual Mat getSamples() const = 0; + CV_WRAP virtual Mat getMissing() const = 0; + + /** @brief Returns matrix of train samples + + @param layout The requested layout. If it's different from the initial one, the matrix is + transposed. See ml::SampleTypes. + @param compressSamples if true, the function returns only the training samples (specified by + sampleIdx) + @param compressVars if true, the function returns the shorter training samples, containing only + the active variables. + + In current implementation the function tries to avoid physical data copying and returns the + matrix stored inside TrainData (unless the transposition or compression is needed). + */ + CV_WRAP virtual Mat getTrainSamples(int layout=ROW_SAMPLE, + bool compressSamples=true, + bool compressVars=true) const = 0; + + /** @brief Returns the vector of responses + + The function returns ordered or the original categorical responses. Usually it's used in + regression algorithms. + */ + CV_WRAP virtual Mat getTrainResponses() const = 0; + + /** @brief Returns the vector of normalized categorical responses + + The function returns vector of responses. Each response is integer from `0` to `-1`. The actual label value can be retrieved then from the class label vector, see + TrainData::getClassLabels. + */ + CV_WRAP virtual Mat getTrainNormCatResponses() const = 0; + CV_WRAP virtual Mat getTestResponses() const = 0; + CV_WRAP virtual Mat getTestNormCatResponses() const = 0; + CV_WRAP virtual Mat getResponses() const = 0; + CV_WRAP virtual Mat getNormCatResponses() const = 0; + CV_WRAP virtual Mat getSampleWeights() const = 0; + CV_WRAP virtual Mat getTrainSampleWeights() const = 0; + CV_WRAP virtual Mat getTestSampleWeights() const = 0; + CV_WRAP virtual Mat getVarIdx() const = 0; + CV_WRAP virtual Mat getVarType() const = 0; + CV_WRAP virtual Mat getVarSymbolFlags() const = 0; + CV_WRAP virtual int getResponseType() const = 0; + CV_WRAP virtual Mat getTrainSampleIdx() const = 0; + CV_WRAP virtual Mat getTestSampleIdx() const = 0; + CV_WRAP virtual void getValues(int vi, InputArray sidx, float* values) const = 0; + virtual void getNormCatValues(int vi, InputArray sidx, int* values) const = 0; + CV_WRAP virtual Mat getDefaultSubstValues() const = 0; + + CV_WRAP virtual int getCatCount(int vi) const = 0; + + /** @brief Returns the vector of class labels + + The function returns vector of unique labels occurred in the responses. + */ + CV_WRAP virtual Mat getClassLabels() const = 0; + + CV_WRAP virtual Mat getCatOfs() const = 0; + CV_WRAP virtual Mat getCatMap() const = 0; + + /** @brief Splits the training data into the training and test parts + @sa TrainData::setTrainTestSplitRatio + */ + CV_WRAP virtual void setTrainTestSplit(int count, bool shuffle=true) = 0; + + /** @brief Splits the training data into the training and test parts + + The function selects a subset of specified relative size and then returns it as the training + set. If the function is not called, all the data is used for training. Please, note that for + each of TrainData::getTrain\* there is corresponding TrainData::getTest\*, so that the test + subset can be retrieved and processed as well. + @sa TrainData::setTrainTestSplit + */ + CV_WRAP virtual void setTrainTestSplitRatio(double ratio, bool shuffle=true) = 0; + CV_WRAP virtual void shuffleTrainTest() = 0; + + /** @brief Returns matrix of test samples */ + CV_WRAP virtual Mat getTestSamples() const = 0; + + /** @brief Returns vector of symbolic names captured in loadFromCSV() */ + CV_WRAP virtual void getNames(std::vector& names) const = 0; + + /** @brief Extract from 1D vector elements specified by passed indexes. + @param vec input vector (supported types: CV_32S, CV_32F, CV_64F) + @param idx 1D index vector + */ + static CV_WRAP Mat getSubVector(const Mat& vec, const Mat& idx); + + /** @brief Extract from matrix rows/cols specified by passed indexes. + @param matrix input matrix (supported types: CV_32S, CV_32F, CV_64F) + @param idx 1D index vector + @param layout specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES) + */ + static CV_WRAP Mat getSubMatrix(const Mat& matrix, const Mat& idx, int layout); + + /** @brief Reads the dataset from a .csv file and returns the ready-to-use training data. + + @param filename The input file name + @param headerLineCount The number of lines in the beginning to skip; besides the header, the + function also skips empty lines and lines staring with `#` + @param responseStartIdx Index of the first output variable. If -1, the function considers the + last variable as the response + @param responseEndIdx Index of the last output variable + 1. If -1, then there is single + response variable at responseStartIdx. + @param varTypeSpec The optional text string that specifies the variables' types. It has the + format `ord[n1-n2,n3,n4-n5,...]cat[n6,n7-n8,...]`. That is, variables from `n1 to n2` + (inclusive range), `n3`, `n4 to n5` ... are considered ordered and `n6`, `n7 to n8` ... are + considered as categorical. The range `[n1..n2] + [n3] + [n4..n5] + ... + [n6] + [n7..n8]` + should cover all the variables. If varTypeSpec is not specified, then algorithm uses the + following rules: + - all input variables are considered ordered by default. If some column contains has non- + numerical values, e.g. 'apple', 'pear', 'apple', 'apple', 'mango', the corresponding + variable is considered categorical. + - if there are several output variables, they are all considered as ordered. Error is + reported when non-numerical values are used. + - if there is a single output variable, then if its values are non-numerical or are all + integers, then it's considered categorical. Otherwise, it's considered ordered. + @param delimiter The character used to separate values in each line. + @param missch The character used to specify missing measurements. It should not be a digit. + Although it's a non-numerical value, it surely does not affect the decision of whether the + variable ordered or categorical. + @note If the dataset only contains input variables and no responses, use responseStartIdx = -2 + and responseEndIdx = 0. The output variables vector will just contain zeros. + */ + static Ptr loadFromCSV(const String& filename, + int headerLineCount, + int responseStartIdx=-1, + int responseEndIdx=-1, + const String& varTypeSpec=String(), + char delimiter=',', + char missch='?'); + + /** @brief Creates training data from in-memory arrays. + + @param samples matrix of samples. It should have CV_32F type. + @param layout see ml::SampleTypes. + @param responses matrix of responses. If the responses are scalar, they should be stored as a + single row or as a single column. The matrix should have type CV_32F or CV_32S (in the + former case the responses are considered as ordered by default; in the latter case - as + categorical) + @param varIdx vector specifying which variables to use for training. It can be an integer vector + (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of + active variables. + @param sampleIdx vector specifying which samples to use for training. It can be an integer + vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask + of training samples. + @param sampleWeights optional vector with weights for each sample. It should have CV_32F type. + @param varType optional vector of type CV_8U and size ` + + `, containing types of each input and output variable. See + ml::VariableTypes. + */ + CV_WRAP static Ptr create(InputArray samples, int layout, InputArray responses, + InputArray varIdx=noArray(), InputArray sampleIdx=noArray(), + InputArray sampleWeights=noArray(), InputArray varType=noArray()); +}; + +/** @brief Base class for statistical models in OpenCV ML. + */ +class CV_EXPORTS_W StatModel : public Algorithm +{ +public: + /** Predict options */ + enum Flags { + UPDATE_MODEL = 1, + RAW_OUTPUT=1, //!< makes the method return the raw results (the sum), not the class label + COMPRESSED_INPUT=2, + PREPROCESSED_INPUT=4 + }; + + /** @brief Returns the number of variables in training samples */ + CV_WRAP virtual int getVarCount() const = 0; + + CV_WRAP virtual bool empty() const CV_OVERRIDE; + + /** @brief Returns true if the model is trained */ + CV_WRAP virtual bool isTrained() const = 0; + /** @brief Returns true if the model is classifier */ + CV_WRAP virtual bool isClassifier() const = 0; + + /** @brief Trains the statistical model + + @param trainData training data that can be loaded from file using TrainData::loadFromCSV or + created with TrainData::create. + @param flags optional flags, depending on the model. Some of the models can be updated with the + new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP). + */ + CV_WRAP virtual bool train( const Ptr& trainData, int flags=0 ); + + /** @brief Trains the statistical model + + @param samples training samples + @param layout See ml::SampleTypes. + @param responses vector of responses associated with the training samples. + */ + CV_WRAP virtual bool train( InputArray samples, int layout, InputArray responses ); + + /** @brief Computes error on the training or test dataset + + @param data the training data + @param test if true, the error is computed over the test subset of the data, otherwise it's + computed over the training subset of the data. Please note that if you loaded a completely + different dataset to evaluate already trained classifier, you will probably want not to set + the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so + that the error is computed for the whole new set. Yes, this sounds a bit confusing. + @param resp the optional output responses. + + The method uses StatModel::predict to compute the error. For regression models the error is + computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%). + */ + CV_WRAP virtual float calcError( const Ptr& data, bool test, OutputArray resp ) const; + + /** @brief Predicts response(s) for the provided sample(s) + + @param samples The input samples, floating-point matrix + @param results The optional output matrix of results. + @param flags The optional flags, model-dependent. See cv::ml::StatModel::Flags. + */ + CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const = 0; + + /** @brief Create and train model with default parameters + + The class must implement static `create()` method with no parameters or with all default parameter values + */ + template static Ptr<_Tp> train(const Ptr& data, int flags=0) + { + Ptr<_Tp> model = _Tp::create(); + return !model.empty() && model->train(data, flags) ? model : Ptr<_Tp>(); + } +}; + +/****************************************************************************************\ +* Normal Bayes Classifier * +\****************************************************************************************/ + +/** @brief Bayes classifier for normally distributed data. + +@sa @ref ml_intro_bayes + */ +class CV_EXPORTS_W NormalBayesClassifier : public StatModel +{ +public: + /** @brief Predicts the response for sample(s). + + The method estimates the most probable classes for input vectors. Input vectors (one or more) + are stored as rows of the matrix inputs. In case of multiple input vectors, there should be one + output vector outputs. The predicted class for a single input vector is returned by the method. + The vector outputProbs contains the output probabilities corresponding to each element of + result. + */ + CV_WRAP virtual float predictProb( InputArray inputs, OutputArray outputs, + OutputArray outputProbs, int flags=0 ) const = 0; + + /** Creates empty model + Use StatModel::train to train the model after creation. */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized NormalBayesClassifier from a file + * + * Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk. + * Load the NormalBayesClassifier from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized NormalBayesClassifier + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* K-Nearest Neighbour Classifier * +\****************************************************************************************/ + +/** @brief The class implements K-Nearest Neighbors model + +@sa @ref ml_intro_knn + */ +class CV_EXPORTS_W KNearest : public StatModel +{ +public: + + /** Default number of neighbors to use in predict method. */ + /** @see setDefaultK */ + CV_WRAP virtual int getDefaultK() const = 0; + /** @copybrief getDefaultK @see getDefaultK */ + CV_WRAP virtual void setDefaultK(int val) = 0; + + /** Whether classification or regression model should be trained. */ + /** @see setIsClassifier */ + CV_WRAP virtual bool getIsClassifier() const = 0; + /** @copybrief getIsClassifier @see getIsClassifier */ + CV_WRAP virtual void setIsClassifier(bool val) = 0; + + /** Parameter for KDTree implementation. */ + /** @see setEmax */ + CV_WRAP virtual int getEmax() const = 0; + /** @copybrief getEmax @see getEmax */ + CV_WRAP virtual void setEmax(int val) = 0; + + /** %Algorithm type, one of KNearest::Types. */ + /** @see setAlgorithmType */ + CV_WRAP virtual int getAlgorithmType() const = 0; + /** @copybrief getAlgorithmType @see getAlgorithmType */ + CV_WRAP virtual void setAlgorithmType(int val) = 0; + + /** @brief Finds the neighbors and predicts responses for input vectors. + + @param samples Input samples stored by rows. It is a single-precision floating-point matrix of + ` * k` size. + @param k Number of used nearest neighbors. Should be greater than 1. + @param results Vector with results of prediction (regression or classification) for each input + sample. It is a single-precision floating-point vector with `` elements. + @param neighborResponses Optional output values for corresponding neighbors. It is a single- + precision floating-point matrix of ` * k` size. + @param dist Optional output distances from the input vectors to the corresponding neighbors. It + is a single-precision floating-point matrix of ` * k` size. + + For each input vector (a row of the matrix samples), the method finds the k nearest neighbors. + In case of regression, the predicted result is a mean value of the particular vector's neighbor + responses. In case of classification, the class is determined by voting. + + For each input vector, the neighbors are sorted by their distances to the vector. + + In case of C++ interface you can use output pointers to empty matrices and the function will + allocate memory itself. + + If only a single input vector is passed, all output matrices are optional and the predicted + value is returned by the method. + + The function is parallelized with the TBB library. + */ + CV_WRAP virtual float findNearest( InputArray samples, int k, + OutputArray results, + OutputArray neighborResponses=noArray(), + OutputArray dist=noArray() ) const = 0; + + /** @brief Implementations of KNearest algorithm + */ + enum Types + { + BRUTE_FORCE=1, + KDTREE=2 + }; + + /** @brief Creates the empty model + + The static method creates empty %KNearest classifier. It should be then trained using StatModel::train method. + */ + CV_WRAP static Ptr create(); + /** @brief Loads and creates a serialized knearest from a file + * + * Use KNearest::save to serialize and store an KNearest to disk. + * Load the KNearest from this file again, by calling this function with the path to the file. + * + * @param filepath path to serialized KNearest + */ + CV_WRAP static Ptr load(const String& filepath); +}; + +/****************************************************************************************\ +* Support Vector Machines * +\****************************************************************************************/ + +/** @brief Support Vector Machines. + +@sa @ref ml_intro_svm + */ +class CV_EXPORTS_W SVM : public StatModel +{ +public: + + class CV_EXPORTS Kernel : public Algorithm + { + public: + virtual int getType() const = 0; + virtual void calc( int vcount, int n, const float* vecs, const float* another, float* results ) = 0; + }; + + /** Type of a %SVM formulation. + See SVM::Types. Default value is SVM::C_SVC. */ + /** @see setType */ + CV_WRAP virtual int getType() const = 0; + /** @copybrief getType @see getType */ + CV_WRAP virtual void setType(int val) = 0; + + /** Parameter \f$\gamma\f$ of a kernel function. + For SVM::POLY, SVM::RBF, SVM::SIGMOID or SVM::CHI2. Default value is 1. */ + /** @see setGamma */ + CV_WRAP virtual double getGamma() const = 0; + /** @copybrief getGamma @see getGamma */ + CV_WRAP virtual void setGamma(double val) = 0; + + /** Parameter _coef0_ of a kernel function. + For SVM::POLY or SVM::SIGMOID. Default value is 0.*/ + /** @see setCoef0 */ + CV_WRAP virtual double getCoef0() const = 0; + /** @copybrief getCoef0 @see getCoef0 */ + CV_WRAP virtual void setCoef0(double val) = 0; + + /** Parameter _degree_ of a kernel function. + For SVM::POLY. Default value is 0. */ + /** @see setDegree */ + CV_WRAP virtual double getDegree() const = 0; + /** @copybrief getDegree @see getDegree */ + CV_WRAP virtual void setDegree(double val) = 0; + + /** Parameter _C_ of a %SVM optimization problem. + For SVM::C_SVC, SVM::EPS_SVR or SVM::NU_SVR. Default value is 0. */ + /** @see setC */ + CV_WRAP virtual double getC() const = 0; + /** @copybrief getC @see getC */ + CV_WRAP virtual void setC(double val) = 0; + + /** Parameter \f$\nu\f$ of a %SVM optimization problem. + For SVM::NU_SVC, SVM::ONE_CLASS or SVM::NU_SVR. Default value is 0. */ + /** @see setNu */ + CV_WRAP virtual double getNu() const = 0; + /** @copybrief getNu @see getNu */ + CV_WRAP virtual void setNu(double val) = 0; + + /** Parameter \f$\epsilon\f$ of a %SVM optimization problem. + For SVM::EPS_SVR. Default value is 0. */ + /** @see setP */ + CV_WRAP virtual double getP() const = 0; + /** @copybrief getP @see getP */ + CV_WRAP virtual void setP(double val) = 0; + + /** Optional weights in the SVM::C_SVC problem, assigned to particular classes. + They are multiplied by _C_ so the parameter _C_ of class _i_ becomes `classWeights(i) * C`. Thus + these weights affect the misclassification penalty for different classes. The larger weight, + the larger penalty on misclassification of data from the corresponding class. Default value is + empty Mat. */ + /** @see setClassWeights */ + CV_WRAP virtual cv::Mat getClassWeights() const = 0; + /** @copybrief getClassWeights @see getClassWeights */ + CV_WRAP virtual void setClassWeights(const cv::Mat &val) = 0; + + /** Termination criteria of the iterative %SVM training procedure which solves a partial + case of constrained quadratic optimization problem. + You can specify tolerance and/or the maximum number of iterations. Default value is + `TermCriteria( TermCriteria::MAX_ITER + TermCriteria::EPS, 1000, FLT_EPSILON )`; */ + /** @see setTermCriteria */ + CV_WRAP virtual cv::TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const cv::TermCriteria &val) = 0; + + /** Type of a %SVM kernel. + See SVM::KernelTypes. Default value is SVM::RBF. */ + CV_WRAP virtual int getKernelType() const = 0; + + /** Initialize with one of predefined kernels. + See SVM::KernelTypes. */ + CV_WRAP virtual void setKernel(int kernelType) = 0; + + /** Initialize with custom kernel. + See SVM::Kernel class for implementation details */ + virtual void setCustomKernel(const Ptr &_kernel) = 0; + + //! %SVM type + enum Types { + /** C-Support Vector Classification. n-class classification (n \f$\geq\f$ 2), allows + imperfect separation of classes with penalty multiplier C for outliers. */ + C_SVC=100, + /** \f$\nu\f$-Support Vector Classification. n-class classification with possible + imperfect separation. Parameter \f$\nu\f$ (in the range 0..1, the larger the value, the smoother + the decision boundary) is used instead of C. */ + NU_SVC=101, + /** Distribution Estimation (One-class %SVM). All the training data are from + the same class, %SVM builds a boundary that separates the class from the rest of the feature + space. */ + ONE_CLASS=102, + /** \f$\epsilon\f$-Support Vector Regression. The distance between feature vectors + from the training set and the fitting hyper-plane must be less than p. For outliers the + penalty multiplier C is used. */ + EPS_SVR=103, + /** \f$\nu\f$-Support Vector Regression. \f$\nu\f$ is used instead of p. + See @cite LibSVM for details. */ + NU_SVR=104 + }; + + /** @brief %SVM kernel type + + A comparison of different kernels on the following 2D test case with four classes. Four + SVM::C_SVC SVMs have been trained (one against rest) with auto_train. Evaluation on three + different kernels (SVM::CHI2, SVM::INTER, SVM::RBF). The color depicts the class with max score. + Bright means max-score \> 0, dark means max-score \< 0. + ![image](pics/SVM_Comparison.png) + */ + enum KernelTypes { + /** Returned by SVM::getKernelType in case when custom kernel has been set */ + CUSTOM=-1, + /** Linear kernel. No mapping is done, linear discrimination (or regression) is + done in the original feature space. It is the fastest option. \f$K(x_i, x_j) = x_i^T x_j\f$. */ + LINEAR=0, + /** Polynomial kernel: + \f$K(x_i, x_j) = (\gamma x_i^T x_j + coef0)^{degree}, \gamma > 0\f$. */ + POLY=1, + /** Radial basis function (RBF), a good choice in most cases. + \f$K(x_i, x_j) = e^{-\gamma ||x_i - x_j||^2}, \gamma > 0\f$. */ + RBF=2, + /** Sigmoid kernel: \f$K(x_i, x_j) = \tanh(\gamma x_i^T x_j + coef0)\f$. */ + SIGMOID=3, + /** Exponential Chi2 kernel, similar to the RBF kernel: + \f$K(x_i, x_j) = e^{-\gamma \chi^2(x_i,x_j)}, \chi^2(x_i,x_j) = (x_i-x_j)^2/(x_i+x_j), \gamma > 0\f$. */ + CHI2=4, + /** Histogram intersection kernel. A fast kernel. \f$K(x_i, x_j) = min(x_i,x_j)\f$. */ + INTER=5 + }; + + //! %SVM params type + enum ParamTypes { + C=0, + GAMMA=1, + P=2, + NU=3, + COEF=4, + DEGREE=5 + }; + + /** @brief Trains an %SVM with optimal parameters. + + @param data the training data that can be constructed using TrainData::create or + TrainData::loadFromCSV. + @param kFold Cross-validation parameter. The training set is divided into kFold subsets. One + subset is used to test the model, the others form the train set. So, the %SVM algorithm is + executed kFold times. + @param Cgrid grid for C + @param gammaGrid grid for gamma + @param pGrid grid for p + @param nuGrid grid for nu + @param coeffGrid grid for coeff + @param degreeGrid grid for degree + @param balanced If true and the problem is 2-class classification then the method creates more + balanced cross-validation subsets that is proportions between classes in subsets are close + to such proportion in the whole train dataset. + + The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p, + nu, coef0, degree. Parameters are considered optimal when the cross-validation + estimate of the test set error is minimal. + + If there is no need to optimize a parameter, the corresponding grid step should be set to any + value less than or equal to 1. For example, to avoid optimization in gamma, set `gammaGrid.step + = 0`, `gammaGrid.minVal`, `gamma_grid.maxVal` as arbitrary numbers. In this case, the value + `Gamma` is taken for gamma. + + And, finally, if the optimization in a parameter is required but the corresponding grid is + unknown, you may call the function SVM::getDefaultGrid. To generate a grid, for example, for + gamma, call `SVM::getDefaultGrid(SVM::GAMMA)`. + + This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the + regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and + the usual %SVM with parameters specified in params is executed. + */ + virtual bool trainAuto( const Ptr& data, int kFold = 10, + ParamGrid Cgrid = getDefaultGrid(C), + ParamGrid gammaGrid = getDefaultGrid(GAMMA), + ParamGrid pGrid = getDefaultGrid(P), + ParamGrid nuGrid = getDefaultGrid(NU), + ParamGrid coeffGrid = getDefaultGrid(COEF), + ParamGrid degreeGrid = getDefaultGrid(DEGREE), + bool balanced=false) = 0; + + /** @brief Trains an %SVM with optimal parameters + + @param samples training samples + @param layout See ml::SampleTypes. + @param responses vector of responses associated with the training samples. + @param kFold Cross-validation parameter. The training set is divided into kFold subsets. One + subset is used to test the model, the others form the train set. So, the %SVM algorithm is + @param Cgrid grid for C + @param gammaGrid grid for gamma + @param pGrid grid for p + @param nuGrid grid for nu + @param coeffGrid grid for coeff + @param degreeGrid grid for degree + @param balanced If true and the problem is 2-class classification then the method creates more + balanced cross-validation subsets that is proportions between classes in subsets are close + to such proportion in the whole train dataset. + + The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p, + nu, coef0, degree. Parameters are considered optimal when the cross-validation + estimate of the test set error is minimal. + + This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only + offers rudimentary parameter options. + + This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the + regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and + the usual %SVM with parameters specified in params is executed. + */ + CV_WRAP virtual bool trainAuto(InputArray samples, + int layout, + InputArray responses, + int kFold = 10, + Ptr Cgrid = SVM::getDefaultGridPtr(SVM::C), + Ptr gammaGrid = SVM::getDefaultGridPtr(SVM::GAMMA), + Ptr pGrid = SVM::getDefaultGridPtr(SVM::P), + Ptr nuGrid = SVM::getDefaultGridPtr(SVM::NU), + Ptr coeffGrid = SVM::getDefaultGridPtr(SVM::COEF), + Ptr degreeGrid = SVM::getDefaultGridPtr(SVM::DEGREE), + bool balanced=false) = 0; + + /** @brief Retrieves all the support vectors + + The method returns all the support vectors as a floating-point matrix, where support vectors are + stored as matrix rows. + */ + CV_WRAP virtual Mat getSupportVectors() const = 0; + + /** @brief Retrieves all the uncompressed support vectors of a linear %SVM + + The method returns all the uncompressed support vectors of a linear %SVM that the compressed + support vector, used for prediction, was derived from. They are returned in a floating-point + matrix, where the support vectors are stored as matrix rows. + */ + CV_WRAP virtual Mat getUncompressedSupportVectors() const = 0; + + /** @brief Retrieves the decision function + + @param i the index of the decision function. If the problem solved is regression, 1-class or + 2-class classification, then there will be just one decision function and the index should + always be 0. Otherwise, in the case of N-class classification, there will be \f$N(N-1)/2\f$ + decision functions. + @param alpha the optional output vector for weights, corresponding to different support vectors. + In the case of linear %SVM all the alpha's will be 1's. + @param svidx the optional output vector of indices of support vectors within the matrix of + support vectors (which can be retrieved by SVM::getSupportVectors). In the case of linear + %SVM each decision function consists of a single "compressed" support vector. + + The method returns rho parameter of the decision function, a scalar subtracted from the weighted + sum of kernel responses. + */ + CV_WRAP virtual double getDecisionFunction(int i, OutputArray alpha, OutputArray svidx) const = 0; + + /** @brief Generates a grid for %SVM parameters. + + @param param_id %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is + generated for the parameter with this ID. + + The function generates a grid for the specified parameter of the %SVM algorithm. The grid may be + passed to the function SVM::trainAuto. + */ + static ParamGrid getDefaultGrid( int param_id ); + + /** @brief Generates a grid for %SVM parameters. + + @param param_id %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is + generated for the parameter with this ID. + + The function generates a grid pointer for the specified parameter of the %SVM algorithm. + The grid may be passed to the function SVM::trainAuto. + */ + CV_WRAP static Ptr getDefaultGridPtr( int param_id ); + + /** Creates empty model. + Use StatModel::train to train the model. Since %SVM has several parameters, you may want to + find the best parameters for your problem, it can be done with SVM::trainAuto. */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized svm from a file + * + * Use SVM::save to serialize and store an SVM to disk. + * Load the SVM from this file again, by calling this function with the path to the file. + * + * @param filepath path to serialized svm + */ + CV_WRAP static Ptr load(const String& filepath); +}; + +/****************************************************************************************\ +* Expectation - Maximization * +\****************************************************************************************/ + +/** @brief The class implements the Expectation Maximization algorithm. + +@sa @ref ml_intro_em + */ +class CV_EXPORTS_W EM : public StatModel +{ +public: + //! Type of covariation matrices + enum Types { + /** A scaled identity matrix \f$\mu_k * I\f$. There is the only + parameter \f$\mu_k\f$ to be estimated for each matrix. The option may be used in special cases, + when the constraint is relevant, or as a first step in the optimization (for example in case + when the data is preprocessed with PCA). The results of such preliminary estimation may be + passed again to the optimization procedure, this time with + covMatType=EM::COV_MAT_DIAGONAL. */ + COV_MAT_SPHERICAL=0, + /** A diagonal matrix with positive diagonal elements. The number of + free parameters is d for each matrix. This is most commonly used option yielding good + estimation results. */ + COV_MAT_DIAGONAL=1, + /** A symmetric positively defined matrix. The number of free + parameters in each matrix is about \f$d^2/2\f$. It is not recommended to use this option, unless + there is pretty accurate initial estimation of the parameters and/or a huge number of + training samples. */ + COV_MAT_GENERIC=2, + COV_MAT_DEFAULT=COV_MAT_DIAGONAL + }; + + //! Default parameters + enum {DEFAULT_NCLUSTERS=5, DEFAULT_MAX_ITERS=100}; + + //! The initial step + enum {START_E_STEP=1, START_M_STEP=2, START_AUTO_STEP=0}; + + /** The number of mixture components in the Gaussian mixture model. + Default value of the parameter is EM::DEFAULT_NCLUSTERS=5. Some of %EM implementation could + determine the optimal number of mixtures within a specified value range, but that is not the + case in ML yet. */ + /** @see setClustersNumber */ + CV_WRAP virtual int getClustersNumber() const = 0; + /** @copybrief getClustersNumber @see getClustersNumber */ + CV_WRAP virtual void setClustersNumber(int val) = 0; + + /** Constraint on covariance matrices which defines type of matrices. + See EM::Types. */ + /** @see setCovarianceMatrixType */ + CV_WRAP virtual int getCovarianceMatrixType() const = 0; + /** @copybrief getCovarianceMatrixType @see getCovarianceMatrixType */ + CV_WRAP virtual void setCovarianceMatrixType(int val) = 0; + + /** The termination criteria of the %EM algorithm. + The %EM algorithm can be terminated by the number of iterations termCrit.maxCount (number of + M-steps) or when relative change of likelihood logarithm is less than termCrit.epsilon. Default + maximum number of iterations is EM::DEFAULT_MAX_ITERS=100. */ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const TermCriteria &val) = 0; + + /** @brief Returns weights of the mixtures + + Returns vector with the number of elements equal to the number of mixtures. + */ + CV_WRAP virtual Mat getWeights() const = 0; + /** @brief Returns the cluster centers (means of the Gaussian mixture) + + Returns matrix with the number of rows equal to the number of mixtures and number of columns + equal to the space dimensionality. + */ + CV_WRAP virtual Mat getMeans() const = 0; + /** @brief Returns covariation matrices + + Returns vector of covariation matrices. Number of matrices is the number of gaussian mixtures, + each matrix is a square floating-point matrix NxN, where N is the space dimensionality. + */ + CV_WRAP virtual void getCovs(CV_OUT std::vector& covs) const = 0; + + /** @brief Returns posterior probabilities for the provided samples + + @param samples The input samples, floating-point matrix + @param results The optional output \f$ nSamples \times nClusters\f$ matrix of results. It contains + posterior probabilities for each sample from the input + @param flags This parameter will be ignored + */ + CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const CV_OVERRIDE = 0; + + /** @brief Returns a likelihood logarithm value and an index of the most probable mixture component + for the given sample. + + @param sample A sample for classification. It should be a one-channel matrix of + \f$1 \times dims\f$ or \f$dims \times 1\f$ size. + @param probs Optional output matrix that contains posterior probabilities of each component + given the sample. It has \f$1 \times nclusters\f$ size and CV_64FC1 type. + + The method returns a two-element double vector. Zero element is a likelihood logarithm value for + the sample. First element is an index of the most probable mixture component for the given + sample. + */ + CV_WRAP virtual Vec2d predict2(InputArray sample, OutputArray probs) const = 0; + + /** @brief Estimate the Gaussian mixture parameters from a samples set. + + This variation starts with Expectation step. Initial values of the model parameters will be + estimated by the k-means algorithm. + + Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take + responses (class labels or function values) as input. Instead, it computes the *Maximum + Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the + parameters inside the structure: \f$p_{i,k}\f$ in probs, \f$a_k\f$ in means , \f$S_k\f$ in + covs[k], \f$\pi_k\f$ in weights , and optionally computes the output "class label" for each + sample: \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most + probable mixture component for each sample). + + The trained model can be used further for prediction, just like any other classifier. The + trained model is similar to the NormalBayesClassifier. + + @param samples Samples from which the Gaussian mixture model will be estimated. It should be a + one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type + it will be converted to the inner matrix of such type for the further computing. + @param logLikelihoods The optional output matrix that contains a likelihood logarithm value for + each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type. + @param labels The optional output "class label" for each sample: + \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable + mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type. + @param probs The optional output matrix that contains posterior probabilities of each Gaussian + mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and + CV_64FC1 type. + */ + CV_WRAP virtual bool trainEM(InputArray samples, + OutputArray logLikelihoods=noArray(), + OutputArray labels=noArray(), + OutputArray probs=noArray()) = 0; + + /** @brief Estimate the Gaussian mixture parameters from a samples set. + + This variation starts with Expectation step. You need to provide initial means \f$a_k\f$ of + mixture components. Optionally you can pass initial weights \f$\pi_k\f$ and covariance matrices + \f$S_k\f$ of mixture components. + + @param samples Samples from which the Gaussian mixture model will be estimated. It should be a + one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type + it will be converted to the inner matrix of such type for the further computing. + @param means0 Initial means \f$a_k\f$ of mixture components. It is a one-channel matrix of + \f$nclusters \times dims\f$ size. If the matrix does not have CV_64F type it will be + converted to the inner matrix of such type for the further computing. + @param covs0 The vector of initial covariance matrices \f$S_k\f$ of mixture components. Each of + covariance matrices is a one-channel matrix of \f$dims \times dims\f$ size. If the matrices + do not have CV_64F type they will be converted to the inner matrices of such type for the + further computing. + @param weights0 Initial weights \f$\pi_k\f$ of mixture components. It should be a one-channel + floating-point matrix with \f$1 \times nclusters\f$ or \f$nclusters \times 1\f$ size. + @param logLikelihoods The optional output matrix that contains a likelihood logarithm value for + each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type. + @param labels The optional output "class label" for each sample: + \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable + mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type. + @param probs The optional output matrix that contains posterior probabilities of each Gaussian + mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and + CV_64FC1 type. + */ + CV_WRAP virtual bool trainE(InputArray samples, InputArray means0, + InputArray covs0=noArray(), + InputArray weights0=noArray(), + OutputArray logLikelihoods=noArray(), + OutputArray labels=noArray(), + OutputArray probs=noArray()) = 0; + + /** @brief Estimate the Gaussian mixture parameters from a samples set. + + This variation starts with Maximization step. You need to provide initial probabilities + \f$p_{i,k}\f$ to use this option. + + @param samples Samples from which the Gaussian mixture model will be estimated. It should be a + one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type + it will be converted to the inner matrix of such type for the further computing. + @param probs0 the probabilities + @param logLikelihoods The optional output matrix that contains a likelihood logarithm value for + each sample. It has \f$nsamples \times 1\f$ size and CV_64FC1 type. + @param labels The optional output "class label" for each sample: + \f$\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\f$ (indices of the most probable + mixture component for each sample). It has \f$nsamples \times 1\f$ size and CV_32SC1 type. + @param probs The optional output matrix that contains posterior probabilities of each Gaussian + mixture component given the each sample. It has \f$nsamples \times nclusters\f$ size and + CV_64FC1 type. + */ + CV_WRAP virtual bool trainM(InputArray samples, InputArray probs0, + OutputArray logLikelihoods=noArray(), + OutputArray labels=noArray(), + OutputArray probs=noArray()) = 0; + + /** Creates empty %EM model. + The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you + can use one of the EM::train\* methods or load it from file using Algorithm::load\(filename). + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized EM from a file + * + * Use EM::save to serialize and store an EM to disk. + * Load the EM from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized EM + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Decision Tree * +\****************************************************************************************/ + +/** @brief The class represents a single decision tree or a collection of decision trees. + +The current public interface of the class allows user to train only a single decision tree, however +the class is capable of storing multiple decision trees and using them for prediction (by summing +responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost) +use this capability to implement decision tree ensembles. + +@sa @ref ml_intro_trees +*/ +class CV_EXPORTS_W DTrees : public StatModel +{ +public: + /** Predict options */ + enum Flags { PREDICT_AUTO=0, PREDICT_SUM=(1<<8), PREDICT_MAX_VOTE=(2<<8), PREDICT_MASK=(3<<8) }; + + /** Cluster possible values of a categorical variable into K\<=maxCategories clusters to + find a suboptimal split. + If a discrete variable, on which the training procedure tries to make a split, takes more than + maxCategories values, the precise best subset estimation may take a very long time because the + algorithm is exponential. Instead, many decision trees engines (including our implementation) + try to find sub-optimal split in this case by clustering all the samples into maxCategories + clusters that is some categories are merged together. The clustering is applied only in n \> + 2-class classification problems for categorical variables with N \> max_categories possible + values. In case of regression and 2-class classification the optimal split can be found + efficiently without employing clustering, thus the parameter is not used in these cases. + Default value is 10.*/ + /** @see setMaxCategories */ + CV_WRAP virtual int getMaxCategories() const = 0; + /** @copybrief getMaxCategories @see getMaxCategories */ + CV_WRAP virtual void setMaxCategories(int val) = 0; + + /** The maximum possible depth of the tree. + That is the training algorithms attempts to split a node while its depth is less than maxDepth. + The root node has zero depth. The actual depth may be smaller if the other termination criteria + are met (see the outline of the training procedure @ref ml_intro_trees "here"), and/or if the + tree is pruned. Default value is INT_MAX.*/ + /** @see setMaxDepth */ + CV_WRAP virtual int getMaxDepth() const = 0; + /** @copybrief getMaxDepth @see getMaxDepth */ + CV_WRAP virtual void setMaxDepth(int val) = 0; + + /** If the number of samples in a node is less than this parameter then the node will not be split. + + Default value is 10.*/ + /** @see setMinSampleCount */ + CV_WRAP virtual int getMinSampleCount() const = 0; + /** @copybrief getMinSampleCount @see getMinSampleCount */ + CV_WRAP virtual void setMinSampleCount(int val) = 0; + + /** If CVFolds \> 1 then algorithms prunes the built decision tree using K-fold + cross-validation procedure where K is equal to CVFolds. + Default value is 10.*/ + /** @see setCVFolds */ + CV_WRAP virtual int getCVFolds() const = 0; + /** @copybrief getCVFolds @see getCVFolds */ + CV_WRAP virtual void setCVFolds(int val) = 0; + + /** If true then surrogate splits will be built. + These splits allow to work with missing data and compute variable importance correctly. + Default value is false. + @note currently it's not implemented.*/ + /** @see setUseSurrogates */ + CV_WRAP virtual bool getUseSurrogates() const = 0; + /** @copybrief getUseSurrogates @see getUseSurrogates */ + CV_WRAP virtual void setUseSurrogates(bool val) = 0; + + /** If true then a pruning will be harsher. + This will make a tree more compact and more resistant to the training data noise but a bit less + accurate. Default value is true.*/ + /** @see setUse1SERule */ + CV_WRAP virtual bool getUse1SERule() const = 0; + /** @copybrief getUse1SERule @see getUse1SERule */ + CV_WRAP virtual void setUse1SERule(bool val) = 0; + + /** If true then pruned branches are physically removed from the tree. + Otherwise they are retained and it is possible to get results from the original unpruned (or + pruned less aggressively) tree. Default value is true.*/ + /** @see setTruncatePrunedTree */ + CV_WRAP virtual bool getTruncatePrunedTree() const = 0; + /** @copybrief getTruncatePrunedTree @see getTruncatePrunedTree */ + CV_WRAP virtual void setTruncatePrunedTree(bool val) = 0; + + /** Termination criteria for regression trees. + If all absolute differences between an estimated value in a node and values of train samples + in this node are less than this parameter then the node will not be split further. Default + value is 0.01f*/ + /** @see setRegressionAccuracy */ + CV_WRAP virtual float getRegressionAccuracy() const = 0; + /** @copybrief getRegressionAccuracy @see getRegressionAccuracy */ + CV_WRAP virtual void setRegressionAccuracy(float val) = 0; + + /** @brief The array of a priori class probabilities, sorted by the class label value. + + The parameter can be used to tune the decision tree preferences toward a certain class. For + example, if you want to detect some rare anomaly occurrence, the training base will likely + contain much more normal cases than anomalies, so a very good classification performance + will be achieved just by considering every case as normal. To avoid this, the priors can be + specified, where the anomaly probability is artificially increased (up to 0.5 or even + greater), so the weight of the misclassified anomalies becomes much bigger, and the tree is + adjusted properly. + + You can also think about this parameter as weights of prediction categories which determine + relative weights that you give to misclassification. That is, if the weight of the first + category is 1 and the weight of the second category is 10, then each mistake in predicting + the second category is equivalent to making 10 mistakes in predicting the first category. + Default value is empty Mat.*/ + /** @see setPriors */ + CV_WRAP virtual cv::Mat getPriors() const = 0; + /** @copybrief getPriors @see getPriors */ + CV_WRAP virtual void setPriors(const cv::Mat &val) = 0; + + /** @brief The class represents a decision tree node. + */ + class CV_EXPORTS Node + { + public: + Node(); + double value; //!< Value at the node: a class label in case of classification or estimated + //!< function value in case of regression. + int classIdx; //!< Class index normalized to 0..class_count-1 range and assigned to the + //!< node. It is used internally in classification trees and tree ensembles. + int parent; //!< Index of the parent node + int left; //!< Index of the left child node + int right; //!< Index of right child node + int defaultDir; //!< Default direction where to go (-1: left or +1: right). It helps in the + //!< case of missing values. + int split; //!< Index of the first split + }; + + /** @brief The class represents split in a decision tree. + */ + class CV_EXPORTS Split + { + public: + Split(); + int varIdx; //!< Index of variable on which the split is created. + bool inversed; //!< If true, then the inverse split rule is used (i.e. left and right + //!< branches are exchanged in the rule expressions below). + float quality; //!< The split quality, a positive number. It is used to choose the best split. + int next; //!< Index of the next split in the list of splits for the node + float c; /**< The threshold value in case of split on an ordered variable. + The rule is: + @code{.none} + if var_value < c + then next_node <- left + else next_node <- right + @endcode */ + int subsetOfs; /**< Offset of the bitset used by the split on a categorical variable. + The rule is: + @code{.none} + if bitset[var_value] == 1 + then next_node <- left + else next_node <- right + @endcode */ + }; + + /** @brief Returns indices of root nodes + */ + virtual const std::vector& getRoots() const = 0; + /** @brief Returns all the nodes + + all the node indices are indices in the returned vector + */ + virtual const std::vector& getNodes() const = 0; + /** @brief Returns all the splits + + all the split indices are indices in the returned vector + */ + virtual const std::vector& getSplits() const = 0; + /** @brief Returns all the bitsets for categorical splits + + Split::subsetOfs is an offset in the returned vector + */ + virtual const std::vector& getSubsets() const = 0; + + /** @brief Creates the empty model + + The static method creates empty decision tree with the specified parameters. It should be then + trained using train method (see StatModel::train). Alternatively, you can load the model from + file using Algorithm::load\(filename). + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized DTrees from a file + * + * Use DTree::save to serialize and store an DTree to disk. + * Load the DTree from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized DTree + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Random Trees Classifier * +\****************************************************************************************/ + +/** @brief The class implements the random forest predictor. + +@sa @ref ml_intro_rtrees + */ +class CV_EXPORTS_W RTrees : public DTrees +{ +public: + + /** If true then variable importance will be calculated and then it can be retrieved by RTrees::getVarImportance. + Default value is false.*/ + /** @see setCalculateVarImportance */ + CV_WRAP virtual bool getCalculateVarImportance() const = 0; + /** @copybrief getCalculateVarImportance @see getCalculateVarImportance */ + CV_WRAP virtual void setCalculateVarImportance(bool val) = 0; + + /** The size of the randomly selected subset of features at each tree node and that are used + to find the best split(s). + If you set it to 0 then the size will be set to the square root of the total number of + features. Default value is 0.*/ + /** @see setActiveVarCount */ + CV_WRAP virtual int getActiveVarCount() const = 0; + /** @copybrief getActiveVarCount @see getActiveVarCount */ + CV_WRAP virtual void setActiveVarCount(int val) = 0; + + /** The termination criteria that specifies when the training algorithm stops. + Either when the specified number of trees is trained and added to the ensemble or when + sufficient accuracy (measured as OOB error) is achieved. Typically the more trees you have the + better the accuracy. However, the improvement in accuracy generally diminishes and asymptotes + pass a certain number of trees. Also to keep in mind, the number of tree increases the + prediction time linearly. Default value is TermCriteria(TermCriteria::MAX_ITERS + + TermCriteria::EPS, 50, 0.1)*/ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const TermCriteria &val) = 0; + + /** Returns the variable importance array. + The method returns the variable importance vector, computed at the training stage when + CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is + returned. + */ + CV_WRAP virtual Mat getVarImportance() const = 0; + + /** Returns the result of each individual tree in the forest. + In case the model is a regression problem, the method will return each of the trees' + results for each of the sample cases. If the model is a classifier, it will return + a Mat with samples + 1 rows, where the first row gives the class number and the + following rows return the votes each class had for each sample. + @param samples Array containing the samples for which votes will be calculated. + @param results Array where the result of the calculation will be written. + @param flags Flags for defining the type of RTrees. + */ + CV_WRAP virtual void getVotes(InputArray samples, OutputArray results, int flags) const = 0; + + /** Returns the OOB error value, computed at the training stage when calcOOBError is set to true. + * If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting. + */ +#if CV_VERSION_MAJOR == 4 + CV_WRAP virtual double getOOBError() const { return 0; } +#else + /*CV_WRAP*/ virtual double getOOBError() const = 0; +#endif + + /** Creates the empty model. + Use StatModel::train to train the model, StatModel::train to create and train the model, + Algorithm::load to load the pre-trained model. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized RTree from a file + * + * Use RTree::save to serialize and store an RTree to disk. + * Load the RTree from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized RTree + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Boosted tree classifier * +\****************************************************************************************/ + +/** @brief Boosted tree classifier derived from DTrees + +@sa @ref ml_intro_boost + */ +class CV_EXPORTS_W Boost : public DTrees +{ +public: + /** Type of the boosting algorithm. + See Boost::Types. Default value is Boost::REAL. */ + /** @see setBoostType */ + CV_WRAP virtual int getBoostType() const = 0; + /** @copybrief getBoostType @see getBoostType */ + CV_WRAP virtual void setBoostType(int val) = 0; + + /** The number of weak classifiers. + Default value is 100. */ + /** @see setWeakCount */ + CV_WRAP virtual int getWeakCount() const = 0; + /** @copybrief getWeakCount @see getWeakCount */ + CV_WRAP virtual void setWeakCount(int val) = 0; + + /** A threshold between 0 and 1 used to save computational time. + Samples with summary weight \f$\leq 1 - weight_trim_rate\f$ do not participate in the *next* + iteration of training. Set this parameter to 0 to turn off this functionality. Default value is 0.95.*/ + /** @see setWeightTrimRate */ + CV_WRAP virtual double getWeightTrimRate() const = 0; + /** @copybrief getWeightTrimRate @see getWeightTrimRate */ + CV_WRAP virtual void setWeightTrimRate(double val) = 0; + + /** Boosting type. + Gentle AdaBoost and Real AdaBoost are often the preferable choices. */ + enum Types { + DISCRETE=0, //!< Discrete AdaBoost. + REAL=1, //!< Real AdaBoost. It is a technique that utilizes confidence-rated predictions + //!< and works well with categorical data. + LOGIT=2, //!< LogitBoost. It can produce good regression fits. + GENTLE=3 //!< Gentle AdaBoost. It puts less weight on outlier data points and for that + //!(filename) to load the pre-trained model. */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized Boost from a file + * + * Use Boost::save to serialize and store an RTree to disk. + * Load the Boost from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized Boost + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + +/****************************************************************************************\ +* Gradient Boosted Trees * +\****************************************************************************************/ + +/*class CV_EXPORTS_W GBTrees : public DTrees +{ +public: + struct CV_EXPORTS_W_MAP Params : public DTrees::Params + { + CV_PROP_RW int weakCount; + CV_PROP_RW int lossFunctionType; + CV_PROP_RW float subsamplePortion; + CV_PROP_RW float shrinkage; + + Params(); + Params( int lossFunctionType, int weakCount, float shrinkage, + float subsamplePortion, int maxDepth, bool useSurrogates ); + }; + + enum {SQUARED_LOSS=0, ABSOLUTE_LOSS, HUBER_LOSS=3, DEVIANCE_LOSS}; + + virtual void setK(int k) = 0; + + virtual float predictSerial( InputArray samples, + OutputArray weakResponses, int flags) const = 0; + + static Ptr create(const Params& p); +};*/ + +/****************************************************************************************\ +* Artificial Neural Networks (ANN) * +\****************************************************************************************/ + +/////////////////////////////////// Multi-Layer Perceptrons ////////////////////////////// + +/** @brief Artificial Neural Networks - Multi-Layer Perceptrons. + +Unlike many other models in ML that are constructed and trained at once, in the MLP model these +steps are separated. First, a network with the specified topology is created using the non-default +constructor or the method ANN_MLP::create. All the weights are set to zeros. Then, the network is +trained using a set of input and output vectors. The training procedure can be repeated more than +once, that is, the weights can be adjusted based on the new training data. + +Additional flags for StatModel::train are available: ANN_MLP::TrainFlags. + +@sa @ref ml_intro_ann + */ +class CV_EXPORTS_W ANN_MLP : public StatModel +{ +public: + /** Available training methods */ + enum TrainingMethods { + BACKPROP=0, //!< The back-propagation algorithm. + RPROP = 1, //!< The RPROP algorithm. See @cite RPROP93 for details. + ANNEAL = 2 //!< The simulated annealing algorithm. See @cite Kirkpatrick83 for details. + }; + + /** Sets training method and common parameters. + @param method Default value is ANN_MLP::RPROP. See ANN_MLP::TrainingMethods. + @param param1 passed to setRpropDW0 for ANN_MLP::RPROP and to setBackpropWeightScale for ANN_MLP::BACKPROP and to initialT for ANN_MLP::ANNEAL. + @param param2 passed to setRpropDWMin for ANN_MLP::RPROP and to setBackpropMomentumScale for ANN_MLP::BACKPROP and to finalT for ANN_MLP::ANNEAL. + */ + CV_WRAP virtual void setTrainMethod(int method, double param1 = 0, double param2 = 0) = 0; + + /** Returns current training method */ + CV_WRAP virtual int getTrainMethod() const = 0; + + /** Initialize the activation function for each neuron. + Currently the default and the only fully supported activation function is ANN_MLP::SIGMOID_SYM. + @param type The type of activation function. See ANN_MLP::ActivationFunctions. + @param param1 The first parameter of the activation function, \f$\alpha\f$. Default value is 0. + @param param2 The second parameter of the activation function, \f$\beta\f$. Default value is 0. + */ + CV_WRAP virtual void setActivationFunction(int type, double param1 = 0, double param2 = 0) = 0; + + /** Integer vector specifying the number of neurons in each layer including the input and output layers. + The very first element specifies the number of elements in the input layer. + The last element - number of elements in the output layer. Default value is empty Mat. + @sa getLayerSizes */ + CV_WRAP virtual void setLayerSizes(InputArray _layer_sizes) = 0; + + /** Integer vector specifying the number of neurons in each layer including the input and output layers. + The very first element specifies the number of elements in the input layer. + The last element - number of elements in the output layer. + @sa setLayerSizes */ + CV_WRAP virtual cv::Mat getLayerSizes() const = 0; + + /** Termination criteria of the training algorithm. + You can specify the maximum number of iterations (maxCount) and/or how much the error could + change between the iterations to make the algorithm continue (epsilon). Default value is + TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 1000, 0.01).*/ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(TermCriteria val) = 0; + + /** BPROP: Strength of the weight gradient term. + The recommended value is about 0.1. Default value is 0.1.*/ + /** @see setBackpropWeightScale */ + CV_WRAP virtual double getBackpropWeightScale() const = 0; + /** @copybrief getBackpropWeightScale @see getBackpropWeightScale */ + CV_WRAP virtual void setBackpropWeightScale(double val) = 0; + + /** BPROP: Strength of the momentum term (the difference between weights on the 2 previous iterations). + This parameter provides some inertia to smooth the random fluctuations of the weights. It can + vary from 0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough. + Default value is 0.1.*/ + /** @see setBackpropMomentumScale */ + CV_WRAP virtual double getBackpropMomentumScale() const = 0; + /** @copybrief getBackpropMomentumScale @see getBackpropMomentumScale */ + CV_WRAP virtual void setBackpropMomentumScale(double val) = 0; + + /** RPROP: Initial value \f$\Delta_0\f$ of update-values \f$\Delta_{ij}\f$. + Default value is 0.1.*/ + /** @see setRpropDW0 */ + CV_WRAP virtual double getRpropDW0() const = 0; + /** @copybrief getRpropDW0 @see getRpropDW0 */ + CV_WRAP virtual void setRpropDW0(double val) = 0; + + /** RPROP: Increase factor \f$\eta^+\f$. + It must be \>1. Default value is 1.2.*/ + /** @see setRpropDWPlus */ + CV_WRAP virtual double getRpropDWPlus() const = 0; + /** @copybrief getRpropDWPlus @see getRpropDWPlus */ + CV_WRAP virtual void setRpropDWPlus(double val) = 0; + + /** RPROP: Decrease factor \f$\eta^-\f$. + It must be \<1. Default value is 0.5.*/ + /** @see setRpropDWMinus */ + CV_WRAP virtual double getRpropDWMinus() const = 0; + /** @copybrief getRpropDWMinus @see getRpropDWMinus */ + CV_WRAP virtual void setRpropDWMinus(double val) = 0; + + /** RPROP: Update-values lower limit \f$\Delta_{min}\f$. + It must be positive. Default value is FLT_EPSILON.*/ + /** @see setRpropDWMin */ + CV_WRAP virtual double getRpropDWMin() const = 0; + /** @copybrief getRpropDWMin @see getRpropDWMin */ + CV_WRAP virtual void setRpropDWMin(double val) = 0; + + /** RPROP: Update-values upper limit \f$\Delta_{max}\f$. + It must be \>1. Default value is 50.*/ + /** @see setRpropDWMax */ + CV_WRAP virtual double getRpropDWMax() const = 0; + /** @copybrief getRpropDWMax @see getRpropDWMax */ + CV_WRAP virtual void setRpropDWMax(double val) = 0; + + /** ANNEAL: Update initial temperature. + It must be \>=0. Default value is 10.*/ + /** @see setAnnealInitialT */ + CV_WRAP virtual double getAnnealInitialT() const = 0; + /** @copybrief getAnnealInitialT @see getAnnealInitialT */ + CV_WRAP virtual void setAnnealInitialT(double val) = 0; + + /** ANNEAL: Update final temperature. + It must be \>=0 and less than initialT. Default value is 0.1.*/ + /** @see setAnnealFinalT */ + CV_WRAP virtual double getAnnealFinalT() const = 0; + /** @copybrief getAnnealFinalT @see getAnnealFinalT */ + CV_WRAP virtual void setAnnealFinalT(double val) = 0; + + /** ANNEAL: Update cooling ratio. + It must be \>0 and less than 1. Default value is 0.95.*/ + /** @see setAnnealCoolingRatio */ + CV_WRAP virtual double getAnnealCoolingRatio() const = 0; + /** @copybrief getAnnealCoolingRatio @see getAnnealCoolingRatio */ + CV_WRAP virtual void setAnnealCoolingRatio(double val) = 0; + + /** ANNEAL: Update iteration per step. + It must be \>0 . Default value is 10.*/ + /** @see setAnnealItePerStep */ + CV_WRAP virtual int getAnnealItePerStep() const = 0; + /** @copybrief getAnnealItePerStep @see getAnnealItePerStep */ + CV_WRAP virtual void setAnnealItePerStep(int val) = 0; + + /** @brief Set/initialize anneal RNG */ + virtual void setAnnealEnergyRNG(const RNG& rng) = 0; + + /** possible activation functions */ + enum ActivationFunctions { + /** Identity function: \f$f(x)=x\f$ */ + IDENTITY = 0, + /** Symmetrical sigmoid: \f$f(x)=\beta*(1-e^{-\alpha x})/(1+e^{-\alpha x})\f$ + @note + If you are using the default sigmoid activation function with the default parameter values + fparam1=0 and fparam2=0 then the function used is y = 1.7159\*tanh(2/3 \* x), so the output + will range from [-1.7159, 1.7159], instead of [0,1].*/ + SIGMOID_SYM = 1, + /** Gaussian function: \f$f(x)=\beta e^{-\alpha x*x}\f$ */ + GAUSSIAN = 2, + /** ReLU function: \f$f(x)=max(0,x)\f$ */ + RELU = 3, + /** Leaky ReLU function: for x>0 \f$f(x)=x \f$ and x<=0 \f$f(x)=\alpha x \f$*/ + LEAKYRELU= 4 + }; + + /** Train options */ + enum TrainFlags { + /** Update the network weights, rather than compute them from scratch. In the latter case + the weights are initialized using the Nguyen-Widrow algorithm. */ + UPDATE_WEIGHTS = 1, + /** Do not normalize the input vectors. If this flag is not set, the training algorithm + normalizes each input feature independently, shifting its mean value to 0 and making the + standard deviation equal to 1. If the network is assumed to be updated frequently, the new + training data could be much different from original one. In this case, you should take care + of proper normalization. */ + NO_INPUT_SCALE = 2, + /** Do not normalize the output vectors. If the flag is not set, the training algorithm + normalizes each output feature independently, by transforming it to the certain range + depending on the used activation function. */ + NO_OUTPUT_SCALE = 4 + }; + + CV_WRAP virtual Mat getWeights(int layerIdx) const = 0; + + /** @brief Creates empty model + + Use StatModel::train to train the model, Algorithm::load\(filename) to load the pre-trained model. + Note that the train method has optional flags: ANN_MLP::TrainFlags. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized ANN from a file + * + * Use ANN::save to serialize and store an ANN to disk. + * Load the ANN from this file again, by calling this function with the path to the file. + * + * @param filepath path to serialized ANN + */ + CV_WRAP static Ptr load(const String& filepath); + +}; + +#ifndef DISABLE_OPENCV_3_COMPATIBILITY +typedef ANN_MLP ANN_MLP_ANNEAL; +#endif + +/****************************************************************************************\ +* Logistic Regression * +\****************************************************************************************/ + +/** @brief Implements Logistic Regression classifier. + +@sa @ref ml_intro_lr + */ +class CV_EXPORTS_W LogisticRegression : public StatModel +{ +public: + + /** Learning rate. */ + /** @see setLearningRate */ + CV_WRAP virtual double getLearningRate() const = 0; + /** @copybrief getLearningRate @see getLearningRate */ + CV_WRAP virtual void setLearningRate(double val) = 0; + + /** Number of iterations. */ + /** @see setIterations */ + CV_WRAP virtual int getIterations() const = 0; + /** @copybrief getIterations @see getIterations */ + CV_WRAP virtual void setIterations(int val) = 0; + + /** Kind of regularization to be applied. See LogisticRegression::RegKinds. */ + /** @see setRegularization */ + CV_WRAP virtual int getRegularization() const = 0; + /** @copybrief getRegularization @see getRegularization */ + CV_WRAP virtual void setRegularization(int val) = 0; + + /** Kind of training method used. See LogisticRegression::Methods. */ + /** @see setTrainMethod */ + CV_WRAP virtual int getTrainMethod() const = 0; + /** @copybrief getTrainMethod @see getTrainMethod */ + CV_WRAP virtual void setTrainMethod(int val) = 0; + + /** Specifies the number of training samples taken in each step of Mini-Batch Gradient + Descent. Will only be used if using LogisticRegression::MINI_BATCH training algorithm. It + has to take values less than the total number of training samples. */ + /** @see setMiniBatchSize */ + CV_WRAP virtual int getMiniBatchSize() const = 0; + /** @copybrief getMiniBatchSize @see getMiniBatchSize */ + CV_WRAP virtual void setMiniBatchSize(int val) = 0; + + /** Termination criteria of the algorithm. */ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(TermCriteria val) = 0; + + //! Regularization kinds + enum RegKinds { + REG_DISABLE = -1, //!< Regularization disabled + REG_L1 = 0, //!< %L1 norm + REG_L2 = 1 //!< %L2 norm + }; + + //! Training methods + enum Methods { + BATCH = 0, + MINI_BATCH = 1 //!< Set MiniBatchSize to a positive integer when using this method. + }; + + /** @brief Predicts responses for input samples and returns a float type. + + @param samples The input data for the prediction algorithm. Matrix [m x n], where each row + contains variables (features) of one object being classified. Should have data type CV_32F. + @param results Predicted labels as a column matrix of type CV_32S. + @param flags Not used. + */ + CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const CV_OVERRIDE = 0; + + /** @brief This function returns the trained parameters arranged across rows. + + For a two class classification problem, it returns a row matrix. It returns learnt parameters of + the Logistic Regression as a matrix of type CV_32F. + */ + CV_WRAP virtual Mat get_learnt_thetas() const = 0; + + /** @brief Creates empty model. + + Creates Logistic Regression model with parameters given. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized LogisticRegression from a file + * + * Use LogisticRegression::save to serialize and store an LogisticRegression to disk. + * Load the LogisticRegression from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized LogisticRegression + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); +}; + + +/****************************************************************************************\ +* Stochastic Gradient Descent SVM Classifier * +\****************************************************************************************/ + +/*! +@brief Stochastic Gradient Descent SVM classifier + +SVMSGD provides a fast and easy-to-use implementation of the SVM classifier using the Stochastic Gradient Descent approach, +as presented in @cite bottou2010large. + +The classifier has following parameters: +- model type, +- margin type, +- margin regularization (\f$\lambda\f$), +- initial step size (\f$\gamma_0\f$), +- step decreasing power (\f$c\f$), +- and termination criteria. + +The model type may have one of the following values: \ref SGD and \ref ASGD. + +- \ref SGD is the classic version of SVMSGD classifier: every next step is calculated by the formula + \f[w_{t+1} = w_t - \gamma(t) \frac{dQ_i}{dw} |_{w = w_t}\f] + where + - \f$w_t\f$ is the weights vector for decision function at step \f$t\f$, + - \f$\gamma(t)\f$ is the step size of model parameters at the iteration \f$t\f$, it is decreased on each step by the formula + \f$\gamma(t) = \gamma_0 (1 + \lambda \gamma_0 t) ^ {-c}\f$ + - \f$Q_i\f$ is the target functional from SVM task for sample with number \f$i\f$, this sample is chosen stochastically on each step of the algorithm. + +- \ref ASGD is Average Stochastic Gradient Descent SVM Classifier. ASGD classifier averages weights vector on each step of algorithm by the formula +\f$\widehat{w}_{t+1} = \frac{t}{1+t}\widehat{w}_{t} + \frac{1}{1+t}w_{t+1}\f$ + +The recommended model type is ASGD (following @cite bottou2010large). + +The margin type may have one of the following values: \ref SOFT_MARGIN or \ref HARD_MARGIN. + +- You should use \ref HARD_MARGIN type, if you have linearly separable sets. +- You should use \ref SOFT_MARGIN type, if you have non-linearly separable sets or sets with outliers. +- In the general case (if you know nothing about linear separability of your sets), use SOFT_MARGIN. + +The other parameters may be described as follows: +- Margin regularization parameter is responsible for weights decreasing at each step and for the strength of restrictions on outliers + (the less the parameter, the less probability that an outlier will be ignored). + Recommended value for SGD model is 0.0001, for ASGD model is 0.00001. + +- Initial step size parameter is the initial value for the step size \f$\gamma(t)\f$. + You will have to find the best initial step for your problem. + +- Step decreasing power is the power parameter for \f$\gamma(t)\f$ decreasing by the formula, mentioned above. + Recommended value for SGD model is 1, for ASGD model is 0.75. + +- Termination criteria can be TermCriteria::COUNT, TermCriteria::EPS or TermCriteria::COUNT + TermCriteria::EPS. + You will have to find the best termination criteria for your problem. + +Note that the parameters margin regularization, initial step size, and step decreasing power should be positive. + +To use SVMSGD algorithm do as follows: + +- first, create the SVMSGD object. The algorithm will set optimal parameters by default, but you can set your own parameters via functions setSvmsgdType(), + setMarginType(), setMarginRegularization(), setInitialStepSize(), and setStepDecreasingPower(). + +- then the SVM model can be trained using the train features and the correspondent labels by the method train(). + +- after that, the label of a new feature vector can be predicted using the method predict(). + +@code +// Create empty object +cv::Ptr svmsgd = SVMSGD::create(); + +// Train the Stochastic Gradient Descent SVM +svmsgd->train(trainData); + +// Predict labels for the new samples +svmsgd->predict(samples, responses); +@endcode + +*/ + +class CV_EXPORTS_W SVMSGD : public cv::ml::StatModel +{ +public: + + /** SVMSGD type. + ASGD is often the preferable choice. */ + enum SvmsgdType + { + SGD, //!< Stochastic Gradient Descent + ASGD //!< Average Stochastic Gradient Descent + }; + + /** Margin type.*/ + enum MarginType + { + SOFT_MARGIN, //!< General case, suits to the case of non-linearly separable sets, allows outliers. + HARD_MARGIN //!< More accurate for the case of linearly separable sets. + }; + + /** + * @return the weights of the trained model (decision function f(x) = weights * x + shift). + */ + CV_WRAP virtual Mat getWeights() = 0; + + /** + * @return the shift of the trained model (decision function f(x) = weights * x + shift). + */ + CV_WRAP virtual float getShift() = 0; + + /** @brief Creates empty model. + * Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to + * find the best parameters for your problem or use setOptimalParameters() to set some default parameters. + */ + CV_WRAP static Ptr create(); + + /** @brief Loads and creates a serialized SVMSGD from a file + * + * Use SVMSGD::save to serialize and store an SVMSGD to disk. + * Load the SVMSGD from this file again, by calling this function with the path to the file. + * Optionally specify the node for the file containing the classifier + * + * @param filepath path to serialized SVMSGD + * @param nodeName name of node containing the classifier + */ + CV_WRAP static Ptr load(const String& filepath , const String& nodeName = String()); + + /** @brief Function sets optimal parameters values for chosen SVM SGD model. + * @param svmsgdType is the type of SVMSGD classifier. + * @param marginType is the type of margin constraint. + */ + CV_WRAP virtual void setOptimalParameters(int svmsgdType = SVMSGD::ASGD, int marginType = SVMSGD::SOFT_MARGIN) = 0; + + /** @brief %Algorithm type, one of SVMSGD::SvmsgdType. */ + /** @see setSvmsgdType */ + CV_WRAP virtual int getSvmsgdType() const = 0; + /** @copybrief getSvmsgdType @see getSvmsgdType */ + CV_WRAP virtual void setSvmsgdType(int svmsgdType) = 0; + + /** @brief %Margin type, one of SVMSGD::MarginType. */ + /** @see setMarginType */ + CV_WRAP virtual int getMarginType() const = 0; + /** @copybrief getMarginType @see getMarginType */ + CV_WRAP virtual void setMarginType(int marginType) = 0; + + /** @brief Parameter marginRegularization of a %SVMSGD optimization problem. */ + /** @see setMarginRegularization */ + CV_WRAP virtual float getMarginRegularization() const = 0; + /** @copybrief getMarginRegularization @see getMarginRegularization */ + CV_WRAP virtual void setMarginRegularization(float marginRegularization) = 0; + + /** @brief Parameter initialStepSize of a %SVMSGD optimization problem. */ + /** @see setInitialStepSize */ + CV_WRAP virtual float getInitialStepSize() const = 0; + /** @copybrief getInitialStepSize @see getInitialStepSize */ + CV_WRAP virtual void setInitialStepSize(float InitialStepSize) = 0; + + /** @brief Parameter stepDecreasingPower of a %SVMSGD optimization problem. */ + /** @see setStepDecreasingPower */ + CV_WRAP virtual float getStepDecreasingPower() const = 0; + /** @copybrief getStepDecreasingPower @see getStepDecreasingPower */ + CV_WRAP virtual void setStepDecreasingPower(float stepDecreasingPower) = 0; + + /** @brief Termination criteria of the training algorithm. + You can specify the maximum number of iterations (maxCount) and/or how much the error could + change between the iterations to make the algorithm continue (epsilon).*/ + /** @see setTermCriteria */ + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + /** @copybrief getTermCriteria @see getTermCriteria */ + CV_WRAP virtual void setTermCriteria(const cv::TermCriteria &val) = 0; +}; + + +/****************************************************************************************\ +* Auxiliary functions declarations * +\****************************************************************************************/ + +/** @brief Generates _sample_ from multivariate normal distribution + +@param mean an average row vector +@param cov symmetric covariation matrix +@param nsamples returned samples count +@param samples returned samples array +*/ +CV_EXPORTS void randMVNormal( InputArray mean, InputArray cov, int nsamples, OutputArray samples); + +/** @brief Creates test set */ +CV_EXPORTS void createConcentricSpheresTestSet( int nsamples, int nfeatures, int nclasses, + OutputArray samples, OutputArray responses); + + +/****************************************************************************************\ +* Simulated annealing solver * +\****************************************************************************************/ + +#ifdef CV_DOXYGEN +/** @brief This class declares example interface for system state used in simulated annealing optimization algorithm. + +@note This class is not defined in C++ code and can't be use directly - you need your own implementation with the same methods. +*/ +struct SimulatedAnnealingSolverSystem +{ + /** Give energy value for a state of system.*/ + double energy() const; + /** Function which change the state of system (random perturbation).*/ + void changeState(); + /** Function to reverse to the previous state. Can be called once only after changeState(). */ + void reverseState(); +}; +#endif // CV_DOXYGEN + +/** @brief The class implements simulated annealing for optimization. + +@cite Kirkpatrick83 for details + +@param solverSystem optimization system (see SimulatedAnnealingSolverSystem) +@param initialTemperature initial temperature +@param finalTemperature final temperature +@param coolingRatio temperature step multiplies +@param iterationsPerStep number of iterations per temperature changing step +@param lastTemperature optional output for last used temperature +@param rngEnergy specify custom random numbers generator (cv::theRNG() by default) +*/ +template +int simulatedAnnealingSolver(SimulatedAnnealingSolverSystem& solverSystem, + double initialTemperature, double finalTemperature, double coolingRatio, + size_t iterationsPerStep, + CV_OUT double* lastTemperature = NULL, + cv::RNG& rngEnergy = cv::theRNG() +); + +//! @} ml + +} +} + +#include + +#endif // __cplusplus +#endif // OPENCV_ML_HPP + +/* End of file. */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/ml/ml.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/ml/ml.hpp new file mode 100644 index 0000000..f6f9cd8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/ml/ml.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/ml.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/ml/ml.inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/ml/ml.inl.hpp new file mode 100644 index 0000000..dc9c783 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/ml/ml.inl.hpp @@ -0,0 +1,60 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_ML_INL_HPP +#define OPENCV_ML_INL_HPP + +namespace cv { namespace ml { + +// declared in ml.hpp +template +int simulatedAnnealingSolver(SimulatedAnnealingSolverSystem& solverSystem, + double initialTemperature, double finalTemperature, double coolingRatio, + size_t iterationsPerStep, + CV_OUT double* lastTemperature, + cv::RNG& rngEnergy +) +{ + CV_Assert(finalTemperature > 0); + CV_Assert(initialTemperature > finalTemperature); + CV_Assert(iterationsPerStep > 0); + CV_Assert(coolingRatio < 1.0f); + double Ti = initialTemperature; + double previousEnergy = solverSystem.energy(); + int exchange = 0; + while (Ti > finalTemperature) + { + for (size_t i = 0; i < iterationsPerStep; i++) + { + solverSystem.changeState(); + double newEnergy = solverSystem.energy(); + if (newEnergy < previousEnergy) + { + previousEnergy = newEnergy; + exchange++; + } + else + { + double r = rngEnergy.uniform(0.0, 1.0); + if (r < std::exp(-(newEnergy - previousEnergy) / Ti)) + { + previousEnergy = newEnergy; + exchange++; + } + else + { + solverSystem.reverseState(); + } + } + } + Ti *= coolingRatio; + } + if (lastTemperature) + *lastTemperature = Ti; + return exchange; +} + +}} //namespace + +#endif // OPENCV_ML_INL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect.hpp new file mode 100644 index 0000000..3592255 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect.hpp @@ -0,0 +1,836 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OBJDETECT_HPP +#define OPENCV_OBJDETECT_HPP + +#include "opencv2/core.hpp" + +/** +@defgroup objdetect Object Detection + +Haar Feature-based Cascade Classifier for Object Detection +---------------------------------------------------------- + +The object detector described below has been initially proposed by Paul Viola @cite Viola01 and +improved by Rainer Lienhart @cite Lienhart02 . + +First, a classifier (namely a *cascade of boosted classifiers working with haar-like features*) is +trained with a few hundred sample views of a particular object (i.e., a face or a car), called +positive examples, that are scaled to the same size (say, 20x20), and negative examples - arbitrary +images of the same size. + +After a classifier is trained, it can be applied to a region of interest (of the same size as used +during the training) in an input image. The classifier outputs a "1" if the region is likely to show +the object (i.e., face/car), and "0" otherwise. To search for the object in the whole image one can +move the search window across the image and check every location using the classifier. The +classifier is designed so that it can be easily "resized" in order to be able to find the objects of +interest at different sizes, which is more efficient than resizing the image itself. So, to find an +object of an unknown size in the image the scan procedure should be done several times at different +scales. + +The word "cascade" in the classifier name means that the resultant classifier consists of several +simpler classifiers (*stages*) that are applied subsequently to a region of interest until at some +stage the candidate is rejected or all the stages are passed. The word "boosted" means that the +classifiers at every stage of the cascade are complex themselves and they are built out of basic +classifiers using one of four different boosting techniques (weighted voting). Currently Discrete +Adaboost, Real Adaboost, Gentle Adaboost and Logitboost are supported. The basic classifiers are +decision-tree classifiers with at least 2 leaves. Haar-like features are the input to the basic +classifiers, and are calculated as described below. The current algorithm uses the following +Haar-like features: + +![image](pics/haarfeatures.png) + +The feature used in a particular classifier is specified by its shape (1a, 2b etc.), position within +the region of interest and the scale (this scale is not the same as the scale used at the detection +stage, though these two scales are multiplied). For example, in the case of the third line feature +(2c) the response is calculated as the difference between the sum of image pixels under the +rectangle covering the whole feature (including the two white stripes and the black stripe in the +middle) and the sum of the image pixels under the black stripe multiplied by 3 in order to +compensate for the differences in the size of areas. The sums of pixel values over a rectangular +regions are calculated rapidly using integral images (see below and the integral description). + +To see the object detector at work, have a look at the facedetect demo: + + +The following reference is for the detection part only. There is a separate application called +opencv_traincascade that can train a cascade of boosted classifiers from a set of samples. + +@note In the new C++ interface it is also possible to use LBP (local binary pattern) features in +addition to Haar-like features. .. [Viola01] Paul Viola and Michael J. Jones. Rapid Object Detection +using a Boosted Cascade of Simple Features. IEEE CVPR, 2001. The paper is available online at + + +@{ + @defgroup objdetect_c C API +@} + */ + +typedef struct CvHaarClassifierCascade CvHaarClassifierCascade; + +namespace cv +{ + +//! @addtogroup objdetect +//! @{ + +///////////////////////////// Object Detection //////////////////////////// + +//! class for grouping object candidates, detected by Cascade Classifier, HOG etc. +//! instance of the class is to be passed to cv::partition (see cxoperations.hpp) +class CV_EXPORTS SimilarRects +{ +public: + SimilarRects(double _eps) : eps(_eps) {} + inline bool operator()(const Rect& r1, const Rect& r2) const + { + double delta = eps * ((std::min)(r1.width, r2.width) + (std::min)(r1.height, r2.height)) * 0.5; + return std::abs(r1.x - r2.x) <= delta && + std::abs(r1.y - r2.y) <= delta && + std::abs(r1.x + r1.width - r2.x - r2.width) <= delta && + std::abs(r1.y + r1.height - r2.y - r2.height) <= delta; + } + double eps; +}; + +/** @brief Groups the object candidate rectangles. + +@param rectList Input/output vector of rectangles. Output vector includes retained and grouped +rectangles. (The Python list is not modified in place.) +@param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a +group of rectangles to retain it. +@param eps Relative difference between sides of the rectangles to merge them into a group. + +The function is a wrapper for the generic function partition . It clusters all the input rectangles +using the rectangle equivalence criteria that combines rectangles with similar sizes and similar +locations. The similarity is defined by eps. When eps=0 , no clustering is done at all. If +\f$\texttt{eps}\rightarrow +\inf\f$ , all the rectangles are put in one cluster. Then, the small +clusters containing less than or equal to groupThreshold rectangles are rejected. In each other +cluster, the average rectangle is computed and put into the output rectangle list. + */ +CV_EXPORTS void groupRectangles(std::vector& rectList, int groupThreshold, double eps = 0.2); +/** @overload */ +CV_EXPORTS_W void groupRectangles(CV_IN_OUT std::vector& rectList, CV_OUT std::vector& weights, + int groupThreshold, double eps = 0.2); +/** @overload */ +CV_EXPORTS void groupRectangles(std::vector& rectList, int groupThreshold, + double eps, std::vector* weights, std::vector* levelWeights ); +/** @overload */ +CV_EXPORTS void groupRectangles(std::vector& rectList, std::vector& rejectLevels, + std::vector& levelWeights, int groupThreshold, double eps = 0.2); +/** @overload */ +CV_EXPORTS void groupRectangles_meanshift(std::vector& rectList, std::vector& foundWeights, + std::vector& foundScales, + double detectThreshold = 0.0, Size winDetSize = Size(64, 128)); + +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvHaarClassifierCascade* obj) const; }; + +enum { CASCADE_DO_CANNY_PRUNING = 1, + CASCADE_SCALE_IMAGE = 2, + CASCADE_FIND_BIGGEST_OBJECT = 4, + CASCADE_DO_ROUGH_SEARCH = 8 + }; + +class CV_EXPORTS_W BaseCascadeClassifier : public Algorithm +{ +public: + virtual ~BaseCascadeClassifier(); + virtual bool empty() const CV_OVERRIDE = 0; + virtual bool load( const String& filename ) = 0; + virtual void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + double scaleFactor, + int minNeighbors, int flags, + Size minSize, Size maxSize ) = 0; + + virtual void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& numDetections, + double scaleFactor, + int minNeighbors, int flags, + Size minSize, Size maxSize ) = 0; + + virtual void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& rejectLevels, + CV_OUT std::vector& levelWeights, + double scaleFactor, + int minNeighbors, int flags, + Size minSize, Size maxSize, + bool outputRejectLevels ) = 0; + + virtual bool isOldFormatCascade() const = 0; + virtual Size getOriginalWindowSize() const = 0; + virtual int getFeatureType() const = 0; + virtual void* getOldCascade() = 0; + + class CV_EXPORTS MaskGenerator + { + public: + virtual ~MaskGenerator() {} + virtual Mat generateMask(const Mat& src)=0; + virtual void initializeMask(const Mat& /*src*/) { } + }; + virtual void setMaskGenerator(const Ptr& maskGenerator) = 0; + virtual Ptr getMaskGenerator() = 0; +}; + +/** @example samples/cpp/facedetect.cpp +This program demonstrates usage of the Cascade classifier class +\image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254 +*/ +/** @brief Cascade classifier class for object detection. + */ +class CV_EXPORTS_W CascadeClassifier +{ +public: + CV_WRAP CascadeClassifier(); + /** @brief Loads a classifier from a file. + + @param filename Name of the file from which the classifier is loaded. + */ + CV_WRAP CascadeClassifier(const String& filename); + ~CascadeClassifier(); + /** @brief Checks whether the classifier has been loaded. + */ + CV_WRAP bool empty() const; + /** @brief Loads a classifier from a file. + + @param filename Name of the file from which the classifier is loaded. The file may contain an old + HAAR classifier trained by the haartraining application or a new cascade classifier trained by the + traincascade application. + */ + CV_WRAP bool load( const String& filename ); + /** @brief Reads a classifier from a FileStorage node. + + @note The file may contain a new cascade classifier (trained traincascade application) only. + */ + CV_WRAP bool read( const FileNode& node ); + + /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list + of rectangles. + + @param image Matrix of the type CV_8U containing an image where objects are detected. + @param objects Vector of rectangles where each rectangle contains the detected object, the + rectangles may be partially outside the original image. + @param scaleFactor Parameter specifying how much the image size is reduced at each image scale. + @param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have + to retain it. + @param flags Parameter with the same meaning for an old cascade as in the function + cvHaarDetectObjects. It is not used for a new cascade. + @param minSize Minimum possible object size. Objects smaller than that are ignored. + @param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale. + + The function is parallelized with the TBB library. + + @note + - (Python) A face detection example using cascade classifiers can be found at + opencv_source_code/samples/python/facedetect.py + */ + CV_WRAP void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + double scaleFactor = 1.1, + int minNeighbors = 3, int flags = 0, + Size minSize = Size(), + Size maxSize = Size() ); + + /** @overload + @param image Matrix of the type CV_8U containing an image where objects are detected. + @param objects Vector of rectangles where each rectangle contains the detected object, the + rectangles may be partially outside the original image. + @param numDetections Vector of detection numbers for the corresponding objects. An object's number + of detections is the number of neighboring positively classified rectangles that were joined + together to form the object. + @param scaleFactor Parameter specifying how much the image size is reduced at each image scale. + @param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have + to retain it. + @param flags Parameter with the same meaning for an old cascade as in the function + cvHaarDetectObjects. It is not used for a new cascade. + @param minSize Minimum possible object size. Objects smaller than that are ignored. + @param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale. + */ + CV_WRAP_AS(detectMultiScale2) void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& numDetections, + double scaleFactor=1.1, + int minNeighbors=3, int flags=0, + Size minSize=Size(), + Size maxSize=Size() ); + + /** @overload + This function allows you to retrieve the final stage decision certainty of classification. + For this, one needs to set `outputRejectLevels` on true and provide the `rejectLevels` and `levelWeights` parameter. + For each resulting detection, `levelWeights` will then contain the certainty of classification at the final stage. + This value can then be used to separate strong from weaker classifications. + + A code sample on how to use it efficiently can be found below: + @code + Mat img; + vector weights; + vector levels; + vector detections; + CascadeClassifier model("/path/to/your/model.xml"); + model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); + cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl; + @endcode + */ + CV_WRAP_AS(detectMultiScale3) void detectMultiScale( InputArray image, + CV_OUT std::vector& objects, + CV_OUT std::vector& rejectLevels, + CV_OUT std::vector& levelWeights, + double scaleFactor = 1.1, + int minNeighbors = 3, int flags = 0, + Size minSize = Size(), + Size maxSize = Size(), + bool outputRejectLevels = false ); + + CV_WRAP bool isOldFormatCascade() const; + CV_WRAP Size getOriginalWindowSize() const; + CV_WRAP int getFeatureType() const; + void* getOldCascade(); + + CV_WRAP static bool convert(const String& oldcascade, const String& newcascade); + + void setMaskGenerator(const Ptr& maskGenerator); + Ptr getMaskGenerator(); + + Ptr cc; +}; + +CV_EXPORTS Ptr createFaceDetectionMaskGenerator(); + +//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector ////////////// + +//! struct for detection region of interest (ROI) +struct DetectionROI +{ + //! scale(size) of the bounding box + double scale; + //! set of requested locations to be evaluated + std::vector locations; + //! vector that will contain confidence values for each location + std::vector confidences; +}; + +/**@brief Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. + +the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs @cite Dalal2005 . + +useful links: + +https://hal.inria.fr/inria-00548512/document/ + +https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients + +https://software.intel.com/en-us/ipp-dev-reference-histogram-of-oriented-gradients-hog-descriptor + +http://www.learnopencv.com/histogram-of-oriented-gradients + +http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial + + */ +struct CV_EXPORTS_W HOGDescriptor +{ +public: + enum HistogramNormType { L2Hys = 0 //!< Default histogramNormType + }; + enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value. + }; + enum DescriptorStorageFormat { DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW }; + + /**@brief Creates the HOG descriptor and detector with default params. + + aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) + */ + CV_WRAP HOGDescriptor() : winSize(64,128), blockSize(16,16), blockStride(8,8), + cellSize(8,8), nbins(9), derivAperture(1), winSigma(-1), + histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2), gammaCorrection(true), + free_coef(-1.f), nlevels(HOGDescriptor::DEFAULT_NLEVELS), signedGradient(false) + {} + + /** @overload + @param _winSize sets winSize with given value. + @param _blockSize sets blockSize with given value. + @param _blockStride sets blockStride with given value. + @param _cellSize sets cellSize with given value. + @param _nbins sets nbins with given value. + @param _derivAperture sets derivAperture with given value. + @param _winSigma sets winSigma with given value. + @param _histogramNormType sets histogramNormType with given value. + @param _L2HysThreshold sets L2HysThreshold with given value. + @param _gammaCorrection sets gammaCorrection with given value. + @param _nlevels sets nlevels with given value. + @param _signedGradient sets signedGradient with given value. + */ + CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, + Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1, + HOGDescriptor::HistogramNormType _histogramNormType=HOGDescriptor::L2Hys, + double _L2HysThreshold=0.2, bool _gammaCorrection=false, + int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false) + : winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize), + nbins(_nbins), derivAperture(_derivAperture), winSigma(_winSigma), + histogramNormType(_histogramNormType), L2HysThreshold(_L2HysThreshold), + gammaCorrection(_gammaCorrection), free_coef(-1.f), nlevels(_nlevels), signedGradient(_signedGradient) + {} + + /** @overload + @param filename The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier. + */ + CV_WRAP HOGDescriptor(const String& filename) + { + load(filename); + } + + /** @overload + @param d the HOGDescriptor which cloned to create a new one. + */ + HOGDescriptor(const HOGDescriptor& d) + { + d.copyTo(*this); + } + + /**@brief Default destructor. + */ + virtual ~HOGDescriptor() {} + + /**@brief Returns the number of coefficients required for the classification. + */ + CV_WRAP size_t getDescriptorSize() const; + + /** @brief Checks if detector size equal to descriptor size. + */ + CV_WRAP bool checkDetectorSize() const; + + /** @brief Returns winSigma value + */ + CV_WRAP double getWinSigma() const; + + /**@example samples/cpp/peopledetect.cpp + */ + /**@brief Sets coefficients for the linear SVM classifier. + @param svmdetector coefficients for the linear SVM classifier. + */ + CV_WRAP virtual void setSVMDetector(InputArray svmdetector); + + /** @brief Reads HOGDescriptor parameters from a cv::FileNode. + @param fn File node + */ + virtual bool read(FileNode& fn); + + /** @brief Stores HOGDescriptor parameters in a cv::FileStorage. + @param fs File storage + @param objname Object name + */ + virtual void write(FileStorage& fs, const String& objname) const; + + /** @brief loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. + @param filename Path of the file to read. + @param objname The optional name of the node to read (if empty, the first top-level node will be used). + */ + CV_WRAP virtual bool load(const String& filename, const String& objname = String()); + + /** @brief saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file + @param filename File name + @param objname Object name + */ + CV_WRAP virtual void save(const String& filename, const String& objname = String()) const; + + /** @brief clones the HOGDescriptor + @param c cloned HOGDescriptor + */ + virtual void copyTo(HOGDescriptor& c) const; + + /**@example samples/cpp/train_HOG.cpp + */ + /** @brief Computes HOG descriptors of given image. + @param img Matrix of the type CV_8U containing an image where HOG features will be calculated. + @param descriptors Matrix of the type CV_32F + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param locations Vector of Point + */ + CV_WRAP virtual void compute(InputArray img, + CV_OUT std::vector& descriptors, + Size winStride = Size(), Size padding = Size(), + const std::vector& locations = std::vector()) const; + + /** @brief Performs object detection without a multi-scale window. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries. + @param weights Vector that will contain confidence values for each detected object. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param searchLocations Vector of Point includes set of requested locations to be evaluated. + */ + CV_WRAP virtual void detect(InputArray img, CV_OUT std::vector& foundLocations, + CV_OUT std::vector& weights, + double hitThreshold = 0, Size winStride = Size(), + Size padding = Size(), + const std::vector& searchLocations = std::vector()) const; + + /** @brief Performs object detection without a multi-scale window. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param searchLocations Vector of Point includes locations to search. + */ + virtual void detect(InputArray img, CV_OUT std::vector& foundLocations, + double hitThreshold = 0, Size winStride = Size(), + Size padding = Size(), + const std::vector& searchLocations=std::vector()) const; + + /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list + of rectangles. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of rectangles where each rectangle contains the detected object. + @param foundWeights Vector that will contain confidence values for each detected object. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param scale Coefficient of the detection window increase. + @param finalThreshold Final threshold + @param useMeanshiftGrouping indicates grouping algorithm + */ + CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector& foundLocations, + CV_OUT std::vector& foundWeights, double hitThreshold = 0, + Size winStride = Size(), Size padding = Size(), double scale = 1.05, + double finalThreshold = 2.0,bool useMeanshiftGrouping = false) const; + + /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list + of rectangles. + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of rectangles where each rectangle contains the detected object. + @param hitThreshold Threshold for the distance between features and SVM classifying plane. + Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). + But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param winStride Window stride. It must be a multiple of block stride. + @param padding Padding + @param scale Coefficient of the detection window increase. + @param finalThreshold Final threshold + @param useMeanshiftGrouping indicates grouping algorithm + */ + virtual void detectMultiScale(InputArray img, CV_OUT std::vector& foundLocations, + double hitThreshold = 0, Size winStride = Size(), + Size padding = Size(), double scale = 1.05, + double finalThreshold = 2.0, bool useMeanshiftGrouping = false) const; + + /** @brief Computes gradients and quantized gradient orientations. + @param img Matrix contains the image to be computed + @param grad Matrix of type CV_32FC2 contains computed gradients + @param angleOfs Matrix of type CV_8UC2 contains quantized gradient orientations + @param paddingTL Padding from top-left + @param paddingBR Padding from bottom-right + */ + CV_WRAP virtual void computeGradient(InputArray img, InputOutputArray grad, InputOutputArray angleOfs, + Size paddingTL = Size(), Size paddingBR = Size()) const; + + /** @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows). + */ + CV_WRAP static std::vector getDefaultPeopleDetector(); + + /**@example samples/tapi/hog.cpp + */ + /** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows). + */ + CV_WRAP static std::vector getDaimlerPeopleDetector(); + + //! Detection window size. Align to block size and block stride. Default value is Size(64,128). + CV_PROP Size winSize; + + //! Block size in pixels. Align to cell size. Default value is Size(16,16). + CV_PROP Size blockSize; + + //! Block stride. It must be a multiple of cell size. Default value is Size(8,8). + CV_PROP Size blockStride; + + //! Cell size. Default value is Size(8,8). + CV_PROP Size cellSize; + + //! Number of bins used in the calculation of histogram of gradients. Default value is 9. + CV_PROP int nbins; + + //! not documented + CV_PROP int derivAperture; + + //! Gaussian smoothing window parameter. + CV_PROP double winSigma; + + //! histogramNormType + CV_PROP HOGDescriptor::HistogramNormType histogramNormType; + + //! L2-Hys normalization method shrinkage. + CV_PROP double L2HysThreshold; + + //! Flag to specify whether the gamma correction preprocessing is required or not. + CV_PROP bool gammaCorrection; + + //! coefficients for the linear SVM classifier. + CV_PROP std::vector svmDetector; + + //! coefficients for the linear SVM classifier used when OpenCL is enabled + UMat oclSvmDetector; + + //! not documented + float free_coef; + + //! Maximum number of detection window increases. Default value is 64 + CV_PROP int nlevels; + + //! Indicates signed gradient will be used or not + CV_PROP bool signedGradient; + + /** @brief evaluate specified ROI and return confidence value for each location + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param locations Vector of Point + @param foundLocations Vector of Point where each Point is detected object's top-left point. + @param confidences confidences + @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually + it is 0 and should be specified in the detector coefficients (as the last free coefficient). But if + the free coefficient is omitted (which is allowed), you can specify it manually here + @param winStride winStride + @param padding padding + */ + virtual void detectROI(InputArray img, const std::vector &locations, + CV_OUT std::vector& foundLocations, CV_OUT std::vector& confidences, + double hitThreshold = 0, cv::Size winStride = Size(), + cv::Size padding = Size()) const; + + /** @brief evaluate specified ROI and return confidence value for each location in multiple scales + @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. + @param foundLocations Vector of rectangles where each rectangle contains the detected object. + @param locations Vector of DetectionROI + @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified + in the detector coefficients (as the last free coefficient). But if the free coefficient is omitted (which is allowed), you can specify it manually here. + @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. + */ + virtual void detectMultiScaleROI(InputArray img, + CV_OUT std::vector& foundLocations, + std::vector& locations, + double hitThreshold = 0, + int groupThreshold = 0) const; + + /** @brief Groups the object candidate rectangles. + @param rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.) + @param weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.) + @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. + @param eps Relative difference between sides of the rectangles to merge them into a group. + */ + void groupRectangles(std::vector& rectList, std::vector& weights, int groupThreshold, double eps) const; +}; + +class CV_EXPORTS_W QRCodeEncoder { +protected: + QRCodeEncoder(); // use ::create() +public: + virtual ~QRCodeEncoder(); + + enum EncodeMode { + MODE_AUTO = -1, + MODE_NUMERIC = 1, // 0b0001 + MODE_ALPHANUMERIC = 2, // 0b0010 + MODE_BYTE = 4, // 0b0100 + MODE_ECI = 7, // 0b0111 + MODE_KANJI = 8, // 0b1000 + MODE_STRUCTURED_APPEND = 3 // 0b0011 + }; + + enum CorrectionLevel { + CORRECT_LEVEL_L = 0, + CORRECT_LEVEL_M = 1, + CORRECT_LEVEL_Q = 2, + CORRECT_LEVEL_H = 3 + }; + + enum ECIEncodings { + ECI_UTF8 = 26 + }; + + /** @brief QR code encoder parameters. + @param version The optional version of QR code (by default - maximum possible depending on + the length of the string). + @param correction_level The optional level of error correction (by default - the lowest). + @param mode The optional encoding mode - Numeric, Alphanumeric, Byte, Kanji, ECI or Structured Append. + @param structure_number The optional number of QR codes to generate in Structured Append mode. + */ + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW int version; + CV_PROP_RW CorrectionLevel correction_level; + CV_PROP_RW EncodeMode mode; + CV_PROP_RW int structure_number; + }; + + /** @brief Constructor + @param parameters QR code encoder parameters QRCodeEncoder::Params + */ + static CV_WRAP + Ptr create(const QRCodeEncoder::Params& parameters = QRCodeEncoder::Params()); + + /** @brief Generates QR code from input string. + @param encoded_info Input string to encode. + @param qrcode Generated QR code. + */ + CV_WRAP virtual void encode(const String& encoded_info, OutputArray qrcode) = 0; + + /** @brief Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes. + @param encoded_info Input string to encode. + @param qrcodes Vector of generated QR codes. + */ + CV_WRAP virtual void encodeStructuredAppend(const String& encoded_info, OutputArrayOfArrays qrcodes) = 0; + +}; + +class CV_EXPORTS_W QRCodeDetector +{ +public: + CV_WRAP QRCodeDetector(); + ~QRCodeDetector(); + + /** @brief sets the epsilon used during the horizontal scan of QR code stop marker detection. + @param epsX Epsilon neighborhood, which allows you to determine the horizontal pattern + of the scheme 1:1:3:1:1 according to QR code standard. + */ + CV_WRAP void setEpsX(double epsX); + /** @brief sets the epsilon used during the vertical scan of QR code stop marker detection. + @param epsY Epsilon neighborhood, which allows you to determine the vertical pattern + of the scheme 1:1:3:1:1 according to QR code standard. + */ + CV_WRAP void setEpsY(double epsY); + + /** @brief Detects QR code in image and returns the quadrangle containing the code. + @param img grayscale or color (BGR) image containing (or not) QR code. + @param points Output vector of vertices of the minimum-area quadrangle containing the code. + */ + CV_WRAP bool detect(InputArray img, OutputArray points) const; + + /** @brief Decodes QR code in image once it's found by the detect() method. + + Returns UTF8-encoded output string or empty string if the code cannot be decoded. + @param img grayscale or color (BGR) image containing QR code. + @param points Quadrangle vertices found by detect() method (or some other algorithm). + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP std::string decode(InputArray img, InputArray points, OutputArray straight_qrcode = noArray()); + + /** @brief Decodes QR code on a curved surface in image once it's found by the detect() method. + + Returns UTF8-encoded output string or empty string if the code cannot be decoded. + @param img grayscale or color (BGR) image containing QR code. + @param points Quadrangle vertices found by detect() method (or some other algorithm). + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP cv::String decodeCurved(InputArray img, InputArray points, OutputArray straight_qrcode = noArray()); + + /** @brief Both detects and decodes QR code + + @param img grayscale or color (BGR) image containing QR code. + @param points optional output array of vertices of the found QR code quadrangle. Will be empty if not found. + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP std::string detectAndDecode(InputArray img, OutputArray points=noArray(), + OutputArray straight_qrcode = noArray()); + + /** @brief Both detects and decodes QR code on a curved surface + + @param img grayscale or color (BGR) image containing QR code. + @param points optional output array of vertices of the found QR code quadrangle. Will be empty if not found. + @param straight_qrcode The optional output image containing rectified and binarized QR code + */ + CV_WRAP std::string detectAndDecodeCurved(InputArray img, OutputArray points=noArray(), + OutputArray straight_qrcode = noArray()); + + /** @brief Detects QR codes in image and returns the vector of the quadrangles containing the codes. + @param img grayscale or color (BGR) image containing (or not) QR codes. + @param points Output vector of vector of vertices of the minimum-area quadrangle containing the codes. + */ + CV_WRAP + bool detectMulti(InputArray img, OutputArray points) const; + + /** @brief Decodes QR codes in image once it's found by the detect() method. + @param img grayscale or color (BGR) image containing QR codes. + @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. + @param points vector of Quadrangle vertices found by detect() method (or some other algorithm). + @param straight_qrcode The optional output vector of images containing rectified and binarized QR codes + */ + CV_WRAP + bool decodeMulti( + InputArray img, InputArray points, + CV_OUT std::vector& decoded_info, + OutputArrayOfArrays straight_qrcode = noArray() + ) const; + + /** @brief Both detects and decodes QR codes + @param img grayscale or color (BGR) image containing QR codes. + @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded. + @param points optional output vector of vertices of the found QR code quadrangles. Will be empty if not found. + @param straight_qrcode The optional output vector of images containing rectified and binarized QR codes + */ + CV_WRAP + bool detectAndDecodeMulti( + InputArray img, CV_OUT std::vector& decoded_info, + OutputArray points = noArray(), + OutputArrayOfArrays straight_qrcode = noArray() + ) const; + +protected: + struct Impl; + Ptr p; +}; + +//! @} objdetect +} + +#include "opencv2/objdetect/detection_based_tracker.hpp" +#include "opencv2/objdetect/face.hpp" + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/detection_based_tracker.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/detection_based_tracker.hpp new file mode 100644 index 0000000..18cde13 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/detection_based_tracker.hpp @@ -0,0 +1,222 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_OBJDETECT_DBT_HPP +#define OPENCV_OBJDETECT_DBT_HPP + +#include + +#include + +namespace cv +{ + +//! @addtogroup objdetect +//! @{ + +class CV_EXPORTS DetectionBasedTracker +{ + public: + struct CV_EXPORTS Parameters + { + int maxTrackLifetime; + int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0 + + Parameters(); + }; + + class IDetector + { + public: + IDetector(): + minObjSize(96, 96), + maxObjSize(INT_MAX, INT_MAX), + minNeighbours(2), + scaleFactor(1.1f) + {} + + virtual void detect(const cv::Mat& image, std::vector& objects) = 0; + + void setMinObjectSize(const cv::Size& min) + { + minObjSize = min; + } + void setMaxObjectSize(const cv::Size& max) + { + maxObjSize = max; + } + cv::Size getMinObjectSize() const + { + return minObjSize; + } + cv::Size getMaxObjectSize() const + { + return maxObjSize; + } + float getScaleFactor() + { + return scaleFactor; + } + void setScaleFactor(float value) + { + scaleFactor = value; + } + int getMinNeighbours() + { + return minNeighbours; + } + void setMinNeighbours(int value) + { + minNeighbours = value; + } + virtual ~IDetector() {} + + protected: + cv::Size minObjSize; + cv::Size maxObjSize; + int minNeighbours; + float scaleFactor; + }; + + DetectionBasedTracker(cv::Ptr mainDetector, cv::Ptr trackingDetector, const Parameters& params); + virtual ~DetectionBasedTracker(); + + virtual bool run(); + virtual void stop(); + virtual void resetTracking(); + + virtual void process(const cv::Mat& imageGray); + + bool setParameters(const Parameters& params); + const Parameters& getParameters() const; + + + typedef std::pair Object; + virtual void getObjects(std::vector& result) const; + virtual void getObjects(std::vector& result) const; + + enum ObjectStatus + { + DETECTED_NOT_SHOWN_YET, + DETECTED, + DETECTED_TEMPORARY_LOST, + WRONG_OBJECT + }; + struct ExtObject + { + int id; + cv::Rect location; + ObjectStatus status; + ExtObject(int _id, cv::Rect _location, ObjectStatus _status) + :id(_id), location(_location), status(_status) + { + } + }; + virtual void getObjects(std::vector& result) const; + + + virtual int addObject(const cv::Rect& location); //returns id of the new object + + protected: + class SeparateDetectionWork; + cv::Ptr separateDetectionWork; + friend void* workcycleObjectDetectorFunction(void* p); + + struct InnerParameters + { + int numLastPositionsToTrack; + int numStepsToWaitBeforeFirstShow; + int numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown; + int numStepsToShowWithoutDetecting; + + float coeffTrackingWindowSize; + float coeffObjectSizeToTrack; + float coeffObjectSpeedUsingInPrediction; + + InnerParameters(); + }; + Parameters parameters; + InnerParameters innerParameters; + + struct TrackedObject + { + typedef std::vector PositionsVector; + + PositionsVector lastPositions; + + int numDetectedFrames; + int numFramesNotDetected; + int id; + + TrackedObject(const cv::Rect& rect):numDetectedFrames(1), numFramesNotDetected(0) + { + lastPositions.push_back(rect); + id=getNextId(); + }; + + static int getNextId() + { + static int _id=0; + return _id++; + } + }; + + int numTrackedSteps; + std::vector trackedObjects; + + std::vector weightsPositionsSmoothing; + std::vector weightsSizesSmoothing; + + cv::Ptr cascadeForTracking; + + void updateTrackedObjects(const std::vector& detectedObjects); + cv::Rect calcTrackedObjectPositionToShow(int i) const; + cv::Rect calcTrackedObjectPositionToShow(int i, ObjectStatus& status) const; + void detectInRegion(const cv::Mat& img, const cv::Rect& r, std::vector& detectedObjectsInRegions); +}; + +//! @} objdetect + +} //end of cv namespace + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/face.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/face.hpp new file mode 100644 index 0000000..f2429c5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/face.hpp @@ -0,0 +1,125 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_OBJDETECT_FACE_HPP +#define OPENCV_OBJDETECT_FACE_HPP + +#include + +/** @defgroup dnn_face DNN-based face detection and recognition + */ + +namespace cv +{ + +/** @brief DNN-based face detector, model download link: https://github.com/ShiqiYu/libfacedetection.train/tree/master/tasks/task1/onnx. + */ +class CV_EXPORTS_W FaceDetectorYN +{ +public: + virtual ~FaceDetectorYN() {}; + + /** @brief Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model + * + * @param input_size the size of the input image + */ + CV_WRAP virtual void setInputSize(const Size& input_size) = 0; + + CV_WRAP virtual Size getInputSize() = 0; + + /** @brief Set the score threshold to filter out bounding boxes of score less than the given value + * + * @param score_threshold threshold for filtering out bounding boxes + */ + CV_WRAP virtual void setScoreThreshold(float score_threshold) = 0; + + CV_WRAP virtual float getScoreThreshold() = 0; + + /** @brief Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value + * + * @param nms_threshold threshold for NMS operation + */ + CV_WRAP virtual void setNMSThreshold(float nms_threshold) = 0; + + CV_WRAP virtual float getNMSThreshold() = 0; + + /** @brief Set the number of bounding boxes preserved before NMS + * + * @param top_k the number of bounding boxes to preserve from top rank based on score + */ + CV_WRAP virtual void setTopK(int top_k) = 0; + + CV_WRAP virtual int getTopK() = 0; + + /** @brief A simple interface to detect face from given image + * + * @param image an image to detect + * @param faces detection results stored in a cv::Mat + */ + CV_WRAP virtual int detect(InputArray image, OutputArray faces) = 0; + + /** @brief Creates an instance of this class with given parameters + * + * @param model the path to the requested model + * @param config the path to the config file for compability, which is not requested for ONNX models + * @param input_size the size of the input image + * @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value + * @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value + * @param top_k keep top K bboxes before NMS + * @param backend_id the id of backend + * @param target_id the id of target device + */ + CV_WRAP static Ptr create(const String& model, + const String& config, + const Size& input_size, + float score_threshold = 0.9f, + float nms_threshold = 0.3f, + int top_k = 5000, + int backend_id = 0, + int target_id = 0); +}; + +/** @brief DNN-based face recognizer, model download link: https://drive.google.com/file/d/1ClK9WiB492c5OZFKveF3XiHCejoOxINW/view. + */ +class CV_EXPORTS_W FaceRecognizerSF +{ +public: + virtual ~FaceRecognizerSF() {}; + + /** @brief Definition of distance used for calculating the distance between two face features + */ + enum DisType { FR_COSINE=0, FR_NORM_L2=1 }; + + /** @brief Aligning image to put face on the standard position + * @param src_img input image + * @param face_box the detection result used for indicate face in input image + * @param aligned_img output aligned image + */ + CV_WRAP virtual void alignCrop(InputArray src_img, InputArray face_box, OutputArray aligned_img) const = 0; + + /** @brief Extracting face feature from aligned image + * @param aligned_img input aligned image + * @param face_feature output face feature + */ + CV_WRAP virtual void feature(InputArray aligned_img, OutputArray face_feature) = 0; + + /** @brief Calculating the distance between two face features + * @param _face_feature1 the first input feature + * @param _face_feature2 the second input feature of the same size and the same type as _face_feature1 + * @param dis_type defining the similarity with optional values "FR_OSINE" or "FR_NORM_L2" + */ + CV_WRAP virtual double match(InputArray _face_feature1, InputArray _face_feature2, int dis_type = FaceRecognizerSF::FR_COSINE) const = 0; + + /** @brief Creates an instance of this class with given parameters + * @param model the path of the onnx model used for face recognition + * @param config the path to the config file for compability, which is not requested for ONNX models + * @param backend_id the id of backend + * @param target_id the id of target device + */ + CV_WRAP static Ptr create(const String& model, const String& config, int backend_id = 0, int target_id = 0); +}; + +} // namespace cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/objdetect.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/objdetect.hpp new file mode 100644 index 0000000..3ee284f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/objdetect/objdetect.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/objdetect.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/opencv.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/opencv.hpp new file mode 100644 index 0000000..d17b94a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/opencv.hpp @@ -0,0 +1,95 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_ALL_HPP +#define OPENCV_ALL_HPP + +// File that defines what modules where included during the build of OpenCV +// These are purely the defines of the correct HAVE_OPENCV_modulename values +#include "opencv2/opencv_modules.hpp" + +// Then the list of defines is checked to include the correct headers +// Core library is always included --> without no OpenCV functionality available +#include "opencv2/core.hpp" + +// Then the optional modules are checked +#ifdef HAVE_OPENCV_CALIB3D +#include "opencv2/calib3d.hpp" +#endif +#ifdef HAVE_OPENCV_FEATURES2D +#include "opencv2/features2d.hpp" +#endif +#ifdef HAVE_OPENCV_DNN +#include "opencv2/dnn.hpp" +#endif +#ifdef HAVE_OPENCV_FLANN +#include "opencv2/flann.hpp" +#endif +#ifdef HAVE_OPENCV_HIGHGUI +#include "opencv2/highgui.hpp" +#endif +#ifdef HAVE_OPENCV_IMGCODECS +#include "opencv2/imgcodecs.hpp" +#endif +#ifdef HAVE_OPENCV_IMGPROC +#include "opencv2/imgproc.hpp" +#endif +#ifdef HAVE_OPENCV_ML +#include "opencv2/ml.hpp" +#endif +#ifdef HAVE_OPENCV_OBJDETECT +#include "opencv2/objdetect.hpp" +#endif +#ifdef HAVE_OPENCV_PHOTO +#include "opencv2/photo.hpp" +#endif +#ifdef HAVE_OPENCV_STITCHING +#include "opencv2/stitching.hpp" +#endif +#ifdef HAVE_OPENCV_VIDEO +#include "opencv2/video.hpp" +#endif +#ifdef HAVE_OPENCV_VIDEOIO +#include "opencv2/videoio.hpp" +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/opencv_modules.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/opencv_modules.hpp new file mode 100644 index 0000000..c9e24d8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/opencv_modules.hpp @@ -0,0 +1,30 @@ +/* + * ** File generated automatically, do not modify ** + * + * This file defines the list of modules available in current build configuration + * + * +*/ + +// This definition means that OpenCV is built with enabled non-free code. +// For example, patented algorithms for non-profit/non-commercial use only. +/* #undef OPENCV_ENABLE_NONFREE */ + +#define HAVE_OPENCV_CALIB3D +#define HAVE_OPENCV_CORE +#define HAVE_OPENCV_DNN +#define HAVE_OPENCV_FEATURES2D +#define HAVE_OPENCV_FLANN +#define HAVE_OPENCV_GAPI +#define HAVE_OPENCV_HIGHGUI +#define HAVE_OPENCV_IMGCODECS +#define HAVE_OPENCV_IMGPROC +#define HAVE_OPENCV_ML +#define HAVE_OPENCV_OBJDETECT +#define HAVE_OPENCV_PHOTO +#define HAVE_OPENCV_STITCHING +#define HAVE_OPENCV_VIDEO +#define HAVE_OPENCV_VIDEOIO +#define HAVE_OPENCV_WORLD + + diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/photo.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo.hpp new file mode 100644 index 0000000..c2e89a3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo.hpp @@ -0,0 +1,858 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_PHOTO_HPP +#define OPENCV_PHOTO_HPP + +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" + +/** +@defgroup photo Computational Photography + +This module includes photo processing algorithms +@{ + @defgroup photo_inpaint Inpainting + @defgroup photo_denoise Denoising + @defgroup photo_hdr HDR imaging + +This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment, +camera calibration with multiple exposures and exposure fusion. + + @defgroup photo_decolor Contrast Preserving Decolorization + +Useful links: + +http://www.cse.cuhk.edu.hk/leojia/projects/color2gray/index.html + + @defgroup photo_clone Seamless Cloning + +Useful links: + +https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp + + @defgroup photo_render Non-Photorealistic Rendering + +Useful links: + +http://www.inf.ufrgs.br/~eslgastal/DomainTransform + +https://www.learnopencv.com/non-photorealistic-rendering-using-opencv-python-c/ + + @defgroup photo_c C API +@} + */ + +namespace cv +{ + +//! @addtogroup photo +//! @{ + +//! @addtogroup photo_inpaint +//! @{ +//! the inpainting algorithm +enum +{ + INPAINT_NS = 0, //!< Use Navier-Stokes based method + INPAINT_TELEA = 1 //!< Use the algorithm proposed by Alexandru Telea @cite Telea04 +}; + +/** @brief Restores the selected region in an image using the region neighborhood. + +@param src Input 8-bit, 16-bit unsigned or 32-bit float 1-channel or 8-bit 3-channel image. +@param inpaintMask Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that +needs to be inpainted. +@param dst Output image with the same size and type as src . +@param inpaintRadius Radius of a circular neighborhood of each point inpainted that is considered +by the algorithm. +@param flags Inpainting method that could be cv::INPAINT_NS or cv::INPAINT_TELEA + +The function reconstructs the selected image area from the pixel near the area boundary. The +function may be used to remove dust and scratches from a scanned photo, or to remove undesirable +objects from still images or video. See for more details. + +@note + - An example using the inpainting technique can be found at + opencv_source_code/samples/cpp/inpaint.cpp + - (Python) An example using the inpainting technique can be found at + opencv_source_code/samples/python/inpaint.py + */ +CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask, + OutputArray dst, double inpaintRadius, int flags ); + +//! @} photo_inpaint + +//! @addtogroup photo_denoise +//! @{ + +/** @brief Perform image denoising using Non-local Means Denoising algorithm + with several computational +optimizations. Noise expected to be a gaussian white noise + +@param src Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image. +@param dst Output image with the same size and type as src . +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength. Big h value perfectly removes noise but also +removes image details, smaller h value preserves details but also preserves some noise + +This function expected to be applied to grayscale images. For colored images look at +fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored +image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting +image to CIELAB colorspace and then separately denoise L and AB components with different h +parameter. + */ +CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, float h = 3, + int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Perform image denoising using Non-local Means Denoising algorithm + with several computational +optimizations. Noise expected to be a gaussian white noise + +@param src Input 8-bit or 16-bit (only with NORM_L1) 1-channel, +2-channel, 3-channel or 4-channel image. +@param dst Output image with the same size and type as src . +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Array of parameters regulating filter strength, either one +parameter applied to all channels or one per channel in dst. Big h value +perfectly removes noise but also removes image details, smaller h +value preserves details but also preserves some noise +@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1 + +This function expected to be applied to grayscale images. For colored images look at +fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored +image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting +image to CIELAB colorspace and then separately denoise L and AB components with different h +parameter. + */ +CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, + const std::vector& h, + int templateWindowSize = 7, int searchWindowSize = 21, + int normType = NORM_L2); + +/** @brief Modification of fastNlMeansDenoising function for colored images + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src . +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly +removes noise but also removes image details, smaller h value preserves details but also preserves +some noise +@param hColor The same as h but for color components. For most images value equals 10 +will be enough to remove colored noise and do not distort colors + +The function converts image to CIELAB colorspace and then separately denoise L and AB components +with given h parameters using fastNlMeansDenoising function. + */ +CV_EXPORTS_W void fastNlMeansDenoisingColored( InputArray src, OutputArray dst, + float h = 3, float hColor = 3, + int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Modification of fastNlMeansDenoising function for images sequence where consecutive images have been +captured in small period of time. For example video. This version of the function is for grayscale +images or for manual manipulation with colorspaces. For more details see + + +@param srcImgs Input 8-bit 1-channel, 2-channel, 3-channel or +4-channel images sequence. All images should have the same type and +size. +@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence +@param temporalWindowSize Number of surrounding images to use for target image denoising. Should +be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to +imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise +srcImgs[imgToDenoiseIndex] image. +@param dst Output image with the same size and type as srcImgs images. +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength. Bigger h value +perfectly removes noise but also removes image details, smaller h +value preserves details but also preserves some noise + */ +CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst, + int imgToDenoiseIndex, int temporalWindowSize, + float h = 3, int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Modification of fastNlMeansDenoising function for images sequence where consecutive images have been +captured in small period of time. For example video. This version of the function is for grayscale +images or for manual manipulation with colorspaces. For more details see + + +@param srcImgs Input 8-bit or 16-bit (only with NORM_L1) 1-channel, +2-channel, 3-channel or 4-channel images sequence. All images should +have the same type and size. +@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence +@param temporalWindowSize Number of surrounding images to use for target image denoising. Should +be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to +imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise +srcImgs[imgToDenoiseIndex] image. +@param dst Output image with the same size and type as srcImgs images. +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Array of parameters regulating filter strength, either one +parameter applied to all channels or one per channel in dst. Big h value +perfectly removes noise but also removes image details, smaller h +value preserves details but also preserves some noise +@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1 + */ +CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst, + int imgToDenoiseIndex, int temporalWindowSize, + const std::vector& h, + int templateWindowSize = 7, int searchWindowSize = 21, + int normType = NORM_L2); + +/** @brief Modification of fastNlMeansDenoisingMulti function for colored images sequences + +@param srcImgs Input 8-bit 3-channel images sequence. All images should have the same type and +size. +@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence +@param temporalWindowSize Number of surrounding images to use for target image denoising. Should +be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to +imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise +srcImgs[imgToDenoiseIndex] image. +@param dst Output image with the same size and type as srcImgs images. +@param templateWindowSize Size in pixels of the template patch that is used to compute weights. +Should be odd. Recommended value 7 pixels +@param searchWindowSize Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater +denoising time. Recommended value 21 pixels +@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly +removes noise but also removes image details, smaller h value preserves details but also preserves +some noise. +@param hColor The same as h but for color components. + +The function converts images to CIELAB colorspace and then separately denoise L and AB components +with given h parameters using fastNlMeansDenoisingMulti function. + */ +CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs, OutputArray dst, + int imgToDenoiseIndex, int temporalWindowSize, + float h = 3, float hColor = 3, + int templateWindowSize = 7, int searchWindowSize = 21); + +/** @brief Primal-dual algorithm is an algorithm for solving special types of variational problems (that is, +finding a function to minimize some functional). As the image denoising, in particular, may be seen +as the variational problem, primal-dual algorithm then can be used to perform denoising and this is +exactly what is implemented. + +It should be noted, that this implementation was taken from the July 2013 blog entry +@cite MA13 , which also contained (slightly more general) ready-to-use source code on Python. +Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end +of July 2013 and finally it was slightly adapted by later authors. + +Although the thorough discussion and justification of the algorithm involved may be found in +@cite ChambolleEtAl, it might make sense to skim over it here, following @cite MA13 . To begin +with, we consider the 1-byte gray-level images as the functions from the rectangular domain of +pixels (it may be seen as set +\f$\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\f$ for some +\f$m,\;n\in\mathbb{N}\f$) into \f$\{0,1,\dots,255\}\f$. We shall denote the noised images as \f$f_i\f$ and with +this view, given some image \f$x\f$ of the same size, we may measure how bad it is by the formula + +\f[\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\f] + +\f$\|\|\cdot\|\|\f$ here denotes \f$L_2\f$-norm and as you see, the first addend states that we want our +image to be smooth (ideally, having zero gradient, thus being constant) and the second states that +we want our result to be close to the observations we've got. If we treat \f$x\f$ as a function, this is +exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play. + +@param observations This array should contain one or more noised versions of the image that is to +be restored. +@param result Here the denoised image will be stored. There is no need to do pre-allocation of +storage space, as it will be automatically allocated, if necessary. +@param lambda Corresponds to \f$\lambda\f$ in the formulas above. As it is enlarged, the smooth +(blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly +speaking, as it becomes smaller, the result will be more blur but more sever outliers will be +removed. +@param niters Number of iterations that the algorithm will run. Of course, as more iterations as +better, but it is hard to quantitatively refine this statement, so just use the default and +increase it if the results are poor. + */ +CV_EXPORTS_W void denoise_TVL1(const std::vector& observations,Mat& result, double lambda=1.0, int niters=30); + +//! @} photo_denoise + +//! @addtogroup photo_hdr +//! @{ + +enum { LDR_SIZE = 256 }; + +/** @brief Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range. + */ +class CV_EXPORTS_W Tonemap : public Algorithm +{ +public: + /** @brief Tonemaps image + + @param src source image - CV_32FC3 Mat (float 32 bits 3 channels) + @param dst destination image - CV_32FC3 Mat with values in [0, 1] range + */ + CV_WRAP virtual void process(InputArray src, OutputArray dst) = 0; + + CV_WRAP virtual float getGamma() const = 0; + CV_WRAP virtual void setGamma(float gamma) = 0; +}; + +/** @brief Creates simple linear mapper with gamma correction + +@param gamma positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma +equal to 2.2f is suitable for most displays. +Generally gamma \> 1 brightens the image and gamma \< 1 darkens it. + */ +CV_EXPORTS_W Ptr createTonemap(float gamma = 1.0f); + +/** @brief Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in +logarithmic domain. + +Since it's a global operator the same function is applied to all the pixels, it is controlled by the +bias parameter. + +Optional saturation enhancement is possible as described in @cite FL02 . + +For more information see @cite DM03 . + */ +class CV_EXPORTS_W TonemapDrago : public Tonemap +{ +public: + + CV_WRAP virtual float getSaturation() const = 0; + CV_WRAP virtual void setSaturation(float saturation) = 0; + + CV_WRAP virtual float getBias() const = 0; + CV_WRAP virtual void setBias(float bias) = 0; +}; + +/** @brief Creates TonemapDrago object + +@param gamma gamma value for gamma correction. See createTonemap +@param saturation positive saturation enhancement value. 1.0 preserves saturation, values greater +than 1 increase saturation and values less than 1 decrease it. +@param bias value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best +results, default value is 0.85. + */ +CV_EXPORTS_W Ptr createTonemapDrago(float gamma = 1.0f, float saturation = 1.0f, float bias = 0.85f); + + +/** @brief This is a global tonemapping operator that models human visual system. + +Mapping function is controlled by adaptation parameter, that is computed using light adaptation and +color adaptation. + +For more information see @cite RD05 . + */ +class CV_EXPORTS_W TonemapReinhard : public Tonemap +{ +public: + CV_WRAP virtual float getIntensity() const = 0; + CV_WRAP virtual void setIntensity(float intensity) = 0; + + CV_WRAP virtual float getLightAdaptation() const = 0; + CV_WRAP virtual void setLightAdaptation(float light_adapt) = 0; + + CV_WRAP virtual float getColorAdaptation() const = 0; + CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0; +}; + +/** @brief Creates TonemapReinhard object + +@param gamma gamma value for gamma correction. See createTonemap +@param intensity result intensity in [-8, 8] range. Greater intensity produces brighter results. +@param light_adapt light adaptation in [0, 1] range. If 1 adaptation is based only on pixel +value, if 0 it's global, otherwise it's a weighted mean of this two cases. +@param color_adapt chromatic adaptation in [0, 1] range. If 1 channels are treated independently, +if 0 adaptation level is the same for each channel. + */ +CV_EXPORTS_W Ptr +createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f); + +/** @brief This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid, +transforms contrast values to HVS response and scales the response. After this the image is +reconstructed from new contrast values. + +For more information see @cite MM06 . + */ +class CV_EXPORTS_W TonemapMantiuk : public Tonemap +{ +public: + CV_WRAP virtual float getScale() const = 0; + CV_WRAP virtual void setScale(float scale) = 0; + + CV_WRAP virtual float getSaturation() const = 0; + CV_WRAP virtual void setSaturation(float saturation) = 0; +}; + +/** @brief Creates TonemapMantiuk object + +@param gamma gamma value for gamma correction. See createTonemap +@param scale contrast scale factor. HVS response is multiplied by this parameter, thus compressing +dynamic range. Values from 0.6 to 0.9 produce best results. +@param saturation saturation enhancement value. See createTonemapDrago + */ +CV_EXPORTS_W Ptr +createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f); + +/** @brief The base class for algorithms that align images of the same scene with different exposures + */ +class CV_EXPORTS_W AlignExposures : public Algorithm +{ +public: + /** @brief Aligns images + + @param src vector of input images + @param dst vector of aligned images + @param times vector of exposure time values for each image + @param response 256x1 matrix with inverse camera response function for each pixel value, it should + have the same number of channels as images. + */ + CV_WRAP virtual void process(InputArrayOfArrays src, std::vector& dst, + InputArray times, InputArray response) = 0; +}; + +/** @brief This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median +luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations. + +It is invariant to exposure, so exposure values and camera response are not necessary. + +In this implementation new image regions are filled with zeros. + +For more information see @cite GW03 . + */ +class CV_EXPORTS_W AlignMTB : public AlignExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, std::vector& dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + + /** @brief Short version of process, that doesn't take extra arguments. + + @param src vector of input images + @param dst vector of aligned images + */ + CV_WRAP virtual void process(InputArrayOfArrays src, std::vector& dst) = 0; + + /** @brief Calculates shift between two images, i. e. how to shift the second image to correspond it with the + first. + + @param img0 first image + @param img1 second image + */ + CV_WRAP virtual Point calculateShift(InputArray img0, InputArray img1) = 0; + /** @brief Helper function, that shift Mat filling new regions with zeros. + + @param src input image + @param dst result image + @param shift shift value + */ + CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0; + /** @brief Computes median threshold and exclude bitmaps of given image. + + @param img input image + @param tb median threshold bitmap + @param eb exclude bitmap + */ + CV_WRAP virtual void computeBitmaps(InputArray img, OutputArray tb, OutputArray eb) = 0; + + CV_WRAP virtual int getMaxBits() const = 0; + CV_WRAP virtual void setMaxBits(int max_bits) = 0; + + CV_WRAP virtual int getExcludeRange() const = 0; + CV_WRAP virtual void setExcludeRange(int exclude_range) = 0; + + CV_WRAP virtual bool getCut() const = 0; + CV_WRAP virtual void setCut(bool value) = 0; +}; + +/** @brief Creates AlignMTB object + +@param max_bits logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are +usually good enough (31 and 63 pixels shift respectively). +@param exclude_range range for exclusion bitmap that is constructed to suppress noise around the +median value. +@param cut if true cuts images, otherwise fills the new regions with zeros. + */ +CV_EXPORTS_W Ptr createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true); + +/** @brief The base class for camera response calibration algorithms. + */ +class CV_EXPORTS_W CalibrateCRF : public Algorithm +{ +public: + /** @brief Recovers inverse camera response. + + @param src vector of input images + @param dst 256x1 matrix with inverse camera response function + @param times vector of exposure time values for each image + */ + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0; +}; + +/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective +function as linear system. Objective function is constructed using pixel values on the same position +in all images, extra term is added to make the result smoother. + +For more information see @cite DM97 . + */ +class CV_EXPORTS_W CalibrateDebevec : public CalibrateCRF +{ +public: + CV_WRAP virtual float getLambda() const = 0; + CV_WRAP virtual void setLambda(float lambda) = 0; + + CV_WRAP virtual int getSamples() const = 0; + CV_WRAP virtual void setSamples(int samples) = 0; + + CV_WRAP virtual bool getRandom() const = 0; + CV_WRAP virtual void setRandom(bool random) = 0; +}; + +/** @brief Creates CalibrateDebevec object + +@param samples number of pixel locations to use +@param lambda smoothness term weight. Greater values produce smoother results, but can alter the +response. +@param random if true sample pixel locations are chosen at random, otherwise they form a +rectangular grid. + */ +CV_EXPORTS_W Ptr createCalibrateDebevec(int samples = 70, float lambda = 10.0f, bool random = false); + +/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective +function as linear system. This algorithm uses all image pixels. + +For more information see @cite RB99 . + */ +class CV_EXPORTS_W CalibrateRobertson : public CalibrateCRF +{ +public: + CV_WRAP virtual int getMaxIter() const = 0; + CV_WRAP virtual void setMaxIter(int max_iter) = 0; + + CV_WRAP virtual float getThreshold() const = 0; + CV_WRAP virtual void setThreshold(float threshold) = 0; + + CV_WRAP virtual Mat getRadiance() const = 0; +}; + +/** @brief Creates CalibrateRobertson object + +@param max_iter maximal number of Gauss-Seidel solver iterations. +@param threshold target difference between results of two successive steps of the minimization. + */ +CV_EXPORTS_W Ptr createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f); + +/** @brief The base class algorithms that can merge exposure sequence to a single image. + */ +class CV_EXPORTS_W MergeExposures : public Algorithm +{ +public: + /** @brief Merges images. + + @param src vector of input images + @param dst result image + @param times vector of exposure time values for each image + @param response 256x1 matrix with inverse camera response function for each pixel value, it should + have the same number of channels as images. + */ + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) = 0; +}; + +/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure +values and camera response. + +For more information see @cite DM97 . + */ +class CV_EXPORTS_W MergeDebevec : public MergeExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0; +}; + +/** @brief Creates MergeDebevec object + */ +CV_EXPORTS_W Ptr createMergeDebevec(); + +/** @brief Pixels are weighted using contrast, saturation and well-exposedness measures, than images are +combined using laplacian pyramids. + +The resulting image weight is constructed as weighted average of contrast, saturation and +well-exposedness measures. + +The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying +by 255, but it's recommended to apply gamma correction and/or linear tonemapping. + +For more information see @cite MK07 . + */ +class CV_EXPORTS_W MergeMertens : public MergeExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + /** @brief Short version of process, that doesn't take extra arguments. + + @param src vector of input images + @param dst result image + */ + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0; + + CV_WRAP virtual float getContrastWeight() const = 0; + CV_WRAP virtual void setContrastWeight(float contrast_weiht) = 0; + + CV_WRAP virtual float getSaturationWeight() const = 0; + CV_WRAP virtual void setSaturationWeight(float saturation_weight) = 0; + + CV_WRAP virtual float getExposureWeight() const = 0; + CV_WRAP virtual void setExposureWeight(float exposure_weight) = 0; +}; + +/** @brief Creates MergeMertens object + +@param contrast_weight contrast measure weight. See MergeMertens. +@param saturation_weight saturation measure weight +@param exposure_weight well-exposedness measure weight + */ +CV_EXPORTS_W Ptr +createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f); + +/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure +values and camera response. + +For more information see @cite RB99 . + */ +class CV_EXPORTS_W MergeRobertson : public MergeExposures +{ +public: + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, + InputArray times, InputArray response) CV_OVERRIDE = 0; + CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0; +}; + +/** @brief Creates MergeRobertson object + */ +CV_EXPORTS_W Ptr createMergeRobertson(); + +//! @} photo_hdr + +//! @addtogroup photo_decolor +//! @{ + +/** @brief Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized +black-and-white photograph rendering, and in many single channel image processing applications +@cite CL12 . + +@param src Input 8-bit 3-channel image. +@param grayscale Output 8-bit 1-channel image. +@param color_boost Output 8-bit 3-channel image. + +This function is to be applied on color images. + */ +CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray color_boost); + +//! @} photo_decolor + +//! @addtogroup photo_clone +//! @{ + + +//! seamlessClone algorithm flags +enum +{ + /** The power of the method is fully expressed when inserting objects with complex outlines into a new background*/ + NORMAL_CLONE = 1, + /** The classic method, color-based selection and alpha masking might be time consuming and often leaves an undesirable + halo. Seamless cloning, even averaged with the original image, is not effective. Mixed seamless cloning based on a loose selection proves effective.*/ + MIXED_CLONE = 2, + /** Monochrome transfer allows the user to easily replace certain features of one object by alternative features.*/ + MONOCHROME_TRANSFER = 3}; + + +/** @example samples/cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp +An example using seamlessClone function +*/ +/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters, +deformations) or local changes concerned to a selection. Here we are interested in achieving local +changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless +manner. The extent of the changes ranges from slight distortions to complete replacement by novel +content @cite PM03 . + +@param src Input 8-bit 3-channel image. +@param dst Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param p Point in dst image where object is placed. +@param blend Output image with the same size and type as dst. +@param flags Cloning method that could be cv::NORMAL_CLONE, cv::MIXED_CLONE or cv::MONOCHROME_TRANSFER + */ +CV_EXPORTS_W void seamlessClone( InputArray src, InputArray dst, InputArray mask, Point p, + OutputArray blend, int flags); + +/** @brief Given an original color image, two differently colored versions of this image can be mixed +seamlessly. + +@param src Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param dst Output image with the same size and type as src . +@param red_mul R-channel multiply factor. +@param green_mul G-channel multiply factor. +@param blue_mul B-channel multiply factor. + +Multiplication factor is between .5 to 2.5. + */ +CV_EXPORTS_W void colorChange(InputArray src, InputArray mask, OutputArray dst, float red_mul = 1.0f, + float green_mul = 1.0f, float blue_mul = 1.0f); + +/** @brief Applying an appropriate non-linear transformation to the gradient field inside the selection and +then integrating back with a Poisson solver, modifies locally the apparent illumination of an image. + +@param src Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param dst Output image with the same size and type as src. +@param alpha Value ranges between 0-2. +@param beta Value ranges between 0-2. + +This is useful to highlight under-exposed foreground objects or to reduce specular reflections. + */ +CV_EXPORTS_W void illuminationChange(InputArray src, InputArray mask, OutputArray dst, + float alpha = 0.2f, float beta = 0.4f); + +/** @brief By retaining only the gradients at edge locations, before integrating with the Poisson solver, one +washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used. + +@param src Input 8-bit 3-channel image. +@param mask Input 8-bit 1 or 3-channel image. +@param dst Output image with the same size and type as src. +@param low_threshold %Range from 0 to 100. +@param high_threshold Value \> 100. +@param kernel_size The size of the Sobel kernel to be used. + +@note +The algorithm assumes that the color of the source image is close to that of the destination. This +assumption means that when the colors don't match, the source image color gets tinted toward the +color of the destination image. + */ +CV_EXPORTS_W void textureFlattening(InputArray src, InputArray mask, OutputArray dst, + float low_threshold = 30, float high_threshold = 45, + int kernel_size = 3); + +//! @} photo_clone + +//! @addtogroup photo_render +//! @{ + +//! Edge preserving filters +enum +{ + RECURS_FILTER = 1, //!< Recursive Filtering + NORMCONV_FILTER = 2 //!< Normalized Convolution Filtering +}; + +/** @brief Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing +filters are used in many different applications @cite EM11 . + +@param src Input 8-bit 3-channel image. +@param dst Output 8-bit 3-channel image. +@param flags Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. + */ +CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flags = 1, + float sigma_s = 60, float sigma_r = 0.4f); + +/** @brief This filter enhances the details of a particular image. + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. + */ +CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10, + float sigma_r = 0.15f); + +/** @example samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp +An example using non-photorealistic line drawing functions +*/ +/** @brief Pencil-like non-photorealistic line drawing + +@param src Input 8-bit 3-channel image. +@param dst1 Output 8-bit 1-channel image. +@param dst2 Output image with the same size and type as src. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. +@param shade_factor %Range between 0 to 0.1. + */ +CV_EXPORTS_W void pencilSketch(InputArray src, OutputArray dst1, OutputArray dst2, + float sigma_s = 60, float sigma_r = 0.07f, float shade_factor = 0.02f); + +/** @brief Stylization aims to produce digital imagery with a wide variety of effects not focused on +photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low +contrast while preserving, or enhancing, high-contrast features. + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src. +@param sigma_s %Range between 0 to 200. +@param sigma_r %Range between 0 to 1. + */ +CV_EXPORTS_W void stylization(InputArray src, OutputArray dst, float sigma_s = 60, + float sigma_r = 0.45f); + +//! @} photo_render + +//! @} photo + +} // cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/cuda.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/cuda.hpp new file mode 100644 index 0000000..a2f3816 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/cuda.hpp @@ -0,0 +1,132 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_PHOTO_CUDA_HPP +#define OPENCV_PHOTO_CUDA_HPP + +#include "opencv2/core/cuda.hpp" + +namespace cv { namespace cuda { + +//! @addtogroup photo_denoise +//! @{ + +/** @brief Performs pure non local means denoising without any simplification, and thus it is not fast. + +@param src Source image. Supports only CV_8UC1, CV_8UC2 and CV_8UC3. +@param dst Destination image. +@param h Filter sigma regulating filter strength for color. +@param search_window Size of search window. +@param block_size Size of block used for computing weights. +@param borderMode Border type. See borderInterpolate for details. BORDER_REFLECT101 , +BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now. +@param stream Stream for the asynchronous version. + +@sa + fastNlMeansDenoising + */ +CV_EXPORTS void nonLocalMeans(InputArray src, OutputArray dst, + float h, + int search_window = 21, + int block_size = 7, + int borderMode = BORDER_DEFAULT, + Stream& stream = Stream::Null()); + +/** @brief Perform image denoising using Non-local Means Denoising algorithm + with several computational +optimizations. Noise expected to be a gaussian white noise + +@param src Input 8-bit 1-channel, 2-channel or 3-channel image. +@param dst Output image with the same size and type as src . +@param h Parameter regulating filter strength. Big h value perfectly removes noise but also +removes image details, smaller h value preserves details but also preserves some noise +@param search_window Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater search_window - greater +denoising time. Recommended value 21 pixels +@param block_size Size in pixels of the template patch that is used to compute weights. Should be +odd. Recommended value 7 pixels +@param stream Stream for the asynchronous invocations. + +This function expected to be applied to grayscale images. For colored images look at +FastNonLocalMeansDenoising::labMethod. + +@sa + fastNlMeansDenoising + */ +CV_EXPORTS void fastNlMeansDenoising(InputArray src, OutputArray dst, + float h, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()); + +/** @brief Modification of fastNlMeansDenoising function for colored images + +@param src Input 8-bit 3-channel image. +@param dst Output image with the same size and type as src . +@param h_luminance Parameter regulating filter strength. Big h value perfectly removes noise but +also removes image details, smaller h value preserves details but also preserves some noise +@param photo_render float The same as h but for color components. For most images value equals 10 will be +enough to remove colored noise and do not distort colors +@param search_window Size in pixels of the window that is used to compute weighted average for +given pixel. Should be odd. Affect performance linearly: greater search_window - greater +denoising time. Recommended value 21 pixels +@param block_size Size in pixels of the template patch that is used to compute weights. Should be +odd. Recommended value 7 pixels +@param stream Stream for the asynchronous invocations. + +The function converts image to CIELAB colorspace and then separately denoise L and AB components +with given h parameters using FastNonLocalMeansDenoising::simpleMethod function. + +@sa + fastNlMeansDenoisingColored + */ +CV_EXPORTS void fastNlMeansDenoisingColored(InputArray src, OutputArray dst, + float h_luminance, float photo_render, + int search_window = 21, + int block_size = 7, + Stream& stream = Stream::Null()); + +//! @} photo + +}} // namespace cv { namespace cuda { + +#endif /* OPENCV_PHOTO_CUDA_HPP */ diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/legacy/constants_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/legacy/constants_c.h new file mode 100644 index 0000000..ec1d440 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/legacy/constants_c.h @@ -0,0 +1,14 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_PHOTO_LEGACY_CONSTANTS_H +#define OPENCV_PHOTO_LEGACY_CONSTANTS_H + +enum InpaintingModes +{ + CV_INPAINT_NS =0, + CV_INPAINT_TELEA =1 +}; + +#endif // OPENCV_PHOTO_LEGACY_CONSTANTS_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/photo.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/photo.hpp new file mode 100644 index 0000000..8af5e9f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/photo/photo.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/photo.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching.hpp new file mode 100644 index 0000000..fb0ebe9 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching.hpp @@ -0,0 +1,357 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_STITCHER_HPP +#define OPENCV_STITCHING_STITCHER_HPP + +#include "opencv2/core.hpp" +#include "opencv2/features2d.hpp" +#include "opencv2/stitching/warpers.hpp" +#include "opencv2/stitching/detail/matchers.hpp" +#include "opencv2/stitching/detail/motion_estimators.hpp" +#include "opencv2/stitching/detail/exposure_compensate.hpp" +#include "opencv2/stitching/detail/seam_finders.hpp" +#include "opencv2/stitching/detail/blenders.hpp" +#include "opencv2/stitching/detail/camera.hpp" + + +#if defined(Status) +# warning Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers. +#endif + + +/** +@defgroup stitching Images stitching + +This figure illustrates the stitching module pipeline implemented in the Stitcher class. Using that +class it's possible to configure/remove some steps, i.e. adjust the stitching pipeline according to +the particular needs. All building blocks from the pipeline are available in the detail namespace, +one can combine and use them separately. + +The implemented stitching pipeline is very similar to the one proposed in @cite BL07 . + +![stitching pipeline](StitchingPipeline.jpg) + +Camera models +------------- + +There are currently 2 camera models implemented in stitching pipeline. + +- _Homography model_ expecting perspective transformations between images + implemented in @ref cv::detail::BestOf2NearestMatcher cv::detail::HomographyBasedEstimator + cv::detail::BundleAdjusterReproj cv::detail::BundleAdjusterRay +- _Affine model_ expecting affine transformation with 6 DOF or 4 DOF implemented in + @ref cv::detail::AffineBestOf2NearestMatcher cv::detail::AffineBasedEstimator + cv::detail::BundleAdjusterAffine cv::detail::BundleAdjusterAffinePartial cv::AffineWarper + +Homography model is useful for creating photo panoramas captured by camera, +while affine-based model can be used to stitch scans and object captured by +specialized devices. Use @ref cv::Stitcher::create to get preconfigured pipeline for one +of those models. + +@note +Certain detailed settings of @ref cv::Stitcher might not make sense. Especially +you should not mix classes implementing affine model and classes implementing +Homography model, as they work with different transformations. + +@{ + @defgroup stitching_match Features Finding and Images Matching + @defgroup stitching_rotation Rotation Estimation + @defgroup stitching_autocalib Autocalibration + @defgroup stitching_warp Images Warping + @defgroup stitching_seam Seam Estimation + @defgroup stitching_exposure Exposure Compensation + @defgroup stitching_blend Image Blenders +@} + */ + +namespace cv { + +//! @addtogroup stitching +//! @{ + +/** @example samples/cpp/stitching.cpp +A basic example on image stitching +*/ + +/** @example samples/python/stitching.py +A basic example on image stitching in Python. +*/ + +/** @example samples/cpp/stitching_detailed.cpp +A detailed example on image stitching +*/ + +/** @brief High level image stitcher. + +It's possible to use this class without being aware of the entire stitching pipeline. However, to +be able to achieve higher stitching stability and quality of the final images at least being +familiar with the theory is recommended. + +@note +- A basic example on image stitching can be found at + opencv_source_code/samples/cpp/stitching.cpp +- A basic example on image stitching in Python can be found at + opencv_source_code/samples/python/stitching.py +- A detailed example on image stitching can be found at + opencv_source_code/samples/cpp/stitching_detailed.cpp + */ +class CV_EXPORTS_W Stitcher +{ +public: + /** + * When setting a resolution for stitching, this values is a placeholder + * for preserving the original resolution. + */ +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/) + static constexpr double ORIG_RESOL = -1.0; +#else + // support MSVS 2013 + static const double ORIG_RESOL; // Initialized in stitcher.cpp +#endif + + enum Status + { + OK = 0, + ERR_NEED_MORE_IMGS = 1, + ERR_HOMOGRAPHY_EST_FAIL = 2, + ERR_CAMERA_PARAMS_ADJUST_FAIL = 3 + }; + + enum Mode + { + /** Mode for creating photo panoramas. Expects images under perspective + transformation and projects resulting pano to sphere. + + @sa detail::BestOf2NearestMatcher SphericalWarper + */ + PANORAMA = 0, + /** Mode for composing scans. Expects images under affine transformation does + not compensate exposure by default. + + @sa detail::AffineBestOf2NearestMatcher AffineWarper + */ + SCANS = 1, + + }; + + /** @brief Creates a Stitcher configured in one of the stitching modes. + + @param mode Scenario for stitcher operation. This is usually determined by source of images + to stitch and their transformation. Default parameters will be chosen for operation in given + scenario. + @return Stitcher class instance. + */ + CV_WRAP static Ptr create(Mode mode = Stitcher::PANORAMA); + + CV_WRAP double registrationResol() const { return registr_resol_; } + CV_WRAP void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; } + + CV_WRAP double seamEstimationResol() const { return seam_est_resol_; } + CV_WRAP void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; } + + CV_WRAP double compositingResol() const { return compose_resol_; } + CV_WRAP void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; } + + CV_WRAP double panoConfidenceThresh() const { return conf_thresh_; } + CV_WRAP void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } + + CV_WRAP bool waveCorrection() const { return do_wave_correct_; } + CV_WRAP void setWaveCorrection(bool flag) { do_wave_correct_ = flag; } + + CV_WRAP InterpolationFlags interpolationFlags() const { return interp_flags_; } + CV_WRAP void setInterpolationFlags(InterpolationFlags interp_flags) { interp_flags_ = interp_flags; } + + detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; } + void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; } + + Ptr featuresFinder() { return features_finder_; } + const Ptr featuresFinder() const { return features_finder_; } + void setFeaturesFinder(Ptr features_finder) + { features_finder_ = features_finder; } + + Ptr featuresMatcher() { return features_matcher_; } + const Ptr featuresMatcher() const { return features_matcher_; } + void setFeaturesMatcher(Ptr features_matcher) + { features_matcher_ = features_matcher; } + + const cv::UMat& matchingMask() const { return matching_mask_; } + void setMatchingMask(const cv::UMat &mask) + { + CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows); + matching_mask_ = mask.clone(); + } + + Ptr bundleAdjuster() { return bundle_adjuster_; } + const Ptr bundleAdjuster() const { return bundle_adjuster_; } + void setBundleAdjuster(Ptr bundle_adjuster) + { bundle_adjuster_ = bundle_adjuster; } + + Ptr estimator() { return estimator_; } + const Ptr estimator() const { return estimator_; } + void setEstimator(Ptr estimator) + { estimator_ = estimator; } + + Ptr warper() { return warper_; } + const Ptr warper() const { return warper_; } + void setWarper(Ptr creator) { warper_ = creator; } + + Ptr exposureCompensator() { return exposure_comp_; } + const Ptr exposureCompensator() const { return exposure_comp_; } + void setExposureCompensator(Ptr exposure_comp) + { exposure_comp_ = exposure_comp; } + + Ptr seamFinder() { return seam_finder_; } + const Ptr seamFinder() const { return seam_finder_; } + void setSeamFinder(Ptr seam_finder) { seam_finder_ = seam_finder; } + + Ptr blender() { return blender_; } + const Ptr blender() const { return blender_; } + void setBlender(Ptr b) { blender_ = b; } + + /** @brief These functions try to match the given images and to estimate rotations of each camera. + + @note Use the functions only if you're aware of the stitching pipeline, otherwise use + Stitcher::stitch. + + @param images Input images. + @param masks Masks for each input image specifying where to look for keypoints (optional). + @return Status code. + */ + CV_WRAP Status estimateTransform(InputArrayOfArrays images, InputArrayOfArrays masks = noArray()); + + /** @brief These function restors camera rotation and camera intrinsics of each camera + * that can be got with @ref Stitcher::cameras call + + @param images Input images. + @param cameras Estimated rotation of cameras for each of the input images. + @param component Indices (0-based) of images constituting the final panorama (optional). + @return Status code. + */ + Status setTransform(InputArrayOfArrays images, + const std::vector &cameras, + const std::vector &component); + /** @overload */ + Status setTransform(InputArrayOfArrays images, const std::vector &cameras); + + /** @overload */ + CV_WRAP Status composePanorama(OutputArray pano); + /** @brief These functions try to compose the given images (or images stored internally from the other function + calls) into the final pano under the assumption that the image transformations were estimated + before. + + @note Use the functions only if you're aware of the stitching pipeline, otherwise use + Stitcher::stitch. + + @param images Input images. + @param pano Final pano. + @return Status code. + */ + CV_WRAP Status composePanorama(InputArrayOfArrays images, OutputArray pano); + + /** @overload */ + CV_WRAP Status stitch(InputArrayOfArrays images, OutputArray pano); + /** @brief These functions try to stitch the given images. + + @param images Input images. + @param masks Masks for each input image specifying where to look for keypoints (optional). + @param pano Final pano. + @return Status code. + */ + CV_WRAP Status stitch(InputArrayOfArrays images, InputArrayOfArrays masks, OutputArray pano); + + std::vector component() const { return indices_; } + std::vector cameras() const { return cameras_; } + CV_WRAP double workScale() const { return work_scale_; } + UMat resultMask() const { return result_mask_; } + +private: + Status matchImages(); + Status estimateCameraParams(); + + double registr_resol_; + double seam_est_resol_; + double compose_resol_; + double conf_thresh_; + InterpolationFlags interp_flags_; + Ptr features_finder_; + Ptr features_matcher_; + cv::UMat matching_mask_; + Ptr bundle_adjuster_; + Ptr estimator_; + bool do_wave_correct_; + detail::WaveCorrectKind wave_correct_kind_; + Ptr warper_; + Ptr exposure_comp_; + Ptr seam_finder_; + Ptr blender_; + + std::vector imgs_; + std::vector masks_; + std::vector full_img_sizes_; + std::vector features_; + std::vector pairwise_matches_; + std::vector seam_est_imgs_; + std::vector indices_; + std::vector cameras_; + UMat result_mask_; + double work_scale_; + double seam_scale_; + double seam_work_aspect_; + double warped_image_scale_; +}; + +/** + * @deprecated use Stitcher::create + */ +CV_DEPRECATED Ptr createStitcher(bool try_use_gpu = false); + +/** + * @deprecated use Stitcher::create + */ +CV_DEPRECATED Ptr createStitcherScans(bool try_use_gpu = false); + +//! @} stitching + +} // namespace cv + +#endif // OPENCV_STITCHING_STITCHER_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/autocalib.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/autocalib.hpp new file mode 100644 index 0000000..8eb6212 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/autocalib.hpp @@ -0,0 +1,86 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_AUTOCALIB_HPP +#define OPENCV_STITCHING_AUTOCALIB_HPP + +#include "opencv2/core.hpp" +#include "matchers.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_autocalib +//! @{ + +/** @brief Tries to estimate focal lengths from the given homography under the assumption that the camera +undergoes rotations around its centre only. + +@param H Homography. +@param f0 Estimated focal length along X axis. +@param f1 Estimated focal length along Y axis. +@param f0_ok True, if f0 was estimated successfully, false otherwise. +@param f1_ok True, if f1 was estimated successfully, false otherwise. + +See "Construction of Panoramic Image Mosaics with Global and Local Alignment" +by Heung-Yeung Shum and Richard Szeliski. + */ +void CV_EXPORTS_W focalsFromHomography(const Mat &H, double &f0, double &f1, bool &f0_ok, bool &f1_ok); + +/** @brief Estimates focal lengths for each given camera. + +@param features Features of images. +@param pairwise_matches Matches between all image pairs. +@param focals Estimated focal lengths for each camera. + */ +void CV_EXPORTS estimateFocal(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &focals); + +bool CV_EXPORTS_W calibrateRotatingCamera(const std::vector &Hs,CV_OUT Mat &K); + +//! @} stitching_autocalib + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_AUTOCALIB_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/blenders.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/blenders.hpp new file mode 100644 index 0000000..ec35aa7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/blenders.hpp @@ -0,0 +1,184 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_BLENDERS_HPP +#define OPENCV_STITCHING_BLENDERS_HPP + +#if defined(NO) +# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers. +#endif + +#include "opencv2/core.hpp" +#include "opencv2/core/cuda.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_blend +//! @{ + +/** @brief Base class for all blenders. + +Simple blender which puts one image over another +*/ +class CV_EXPORTS_W Blender +{ +public: + virtual ~Blender() {} + + enum { NO, FEATHER, MULTI_BAND }; + CV_WRAP static Ptr createDefault(int type, bool try_gpu = false); + + /** @brief Prepares the blender for blending. + + @param corners Source images top-left corners + @param sizes Source image sizes + */ + CV_WRAP virtual void prepare(const std::vector &corners, const std::vector &sizes); + /** @overload */ + CV_WRAP virtual void prepare(Rect dst_roi); + /** @brief Processes the image. + + @param img Source image + @param mask Source image mask + @param tl Source image top-left corners + */ + CV_WRAP virtual void feed(InputArray img, InputArray mask, Point tl); + /** @brief Blends and returns the final pano. + + @param dst Final pano + @param dst_mask Final pano mask + */ + CV_WRAP virtual void blend(CV_IN_OUT InputOutputArray dst,CV_IN_OUT InputOutputArray dst_mask); + +protected: + UMat dst_, dst_mask_; + Rect dst_roi_; +}; + +/** @brief Simple blender which mixes images at its borders. + */ +class CV_EXPORTS_W FeatherBlender : public Blender +{ +public: + CV_WRAP FeatherBlender(float sharpness = 0.02f); + + CV_WRAP float sharpness() const { return sharpness_; } + CV_WRAP void setSharpness(float val) { sharpness_ = val; } + + CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE; + CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE; + CV_WRAP void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE; + + //! Creates weight maps for fixed set of source images by their masks and top-left corners. + //! Final image can be obtained by simple weighting of the source images. + CV_WRAP Rect createWeightMaps(const std::vector &masks, const std::vector &corners, + CV_IN_OUT std::vector &weight_maps); + +private: + float sharpness_; + UMat weight_map_; + UMat dst_weight_map_; +}; + +inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); } + +/** @brief Blender which uses multi-band blending algorithm (see @cite BA83). + */ +class CV_EXPORTS_W MultiBandBlender : public Blender +{ +public: + CV_WRAP MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F); + + CV_WRAP int numBands() const { return actual_num_bands_; } + CV_WRAP void setNumBands(int val) { actual_num_bands_ = val; } + + CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE; + CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE; + CV_WRAP void blend(CV_IN_OUT InputOutputArray dst, CV_IN_OUT InputOutputArray dst_mask) CV_OVERRIDE; + +private: + int actual_num_bands_, num_bands_; + std::vector dst_pyr_laplace_; + std::vector dst_band_weights_; + Rect dst_roi_final_; + bool can_use_gpu_; + int weight_type_; //CV_32F or CV_16S +#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING) + std::vector gpu_dst_pyr_laplace_; + std::vector gpu_dst_band_weights_; + std::vector gpu_tl_points_; + std::vector gpu_imgs_with_border_; + std::vector > gpu_weight_pyr_gauss_vec_; + std::vector > gpu_src_pyr_laplace_vec_; + std::vector > gpu_ups_; + cuda::GpuMat gpu_dst_mask_; + cuda::GpuMat gpu_mask_; + cuda::GpuMat gpu_img_; + cuda::GpuMat gpu_weight_map_; + cuda::GpuMat gpu_add_mask_; + int gpu_feed_idx_; + bool gpu_initialized_; +#endif +}; + + +////////////////////////////////////////////////////////////////////////////// +// Auxiliary functions + +void CV_EXPORTS_W normalizeUsingWeightMap(InputArray weight, CV_IN_OUT InputOutputArray src); + +void CV_EXPORTS_W createWeightMap(InputArray mask, float sharpness, CV_IN_OUT InputOutputArray weight); + +void CV_EXPORTS_W createLaplacePyr(InputArray img, int num_levels, CV_IN_OUT std::vector& pyr); +void CV_EXPORTS_W createLaplacePyrGpu(InputArray img, int num_levels, CV_IN_OUT std::vector& pyr); + +// Restores source image +void CV_EXPORTS_W restoreImageFromLaplacePyr(CV_IN_OUT std::vector& pyr); +void CV_EXPORTS_W restoreImageFromLaplacePyrGpu(CV_IN_OUT std::vector& pyr); + +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_BLENDERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/camera.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/camera.hpp new file mode 100644 index 0000000..14ecf60 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/camera.hpp @@ -0,0 +1,78 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_CAMERA_HPP +#define OPENCV_STITCHING_CAMERA_HPP + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching +//! @{ + +/** @brief Describes camera parameters. + +@note Translation is assumed to be zero during the whole stitching pipeline. : + */ +struct CV_EXPORTS_W_SIMPLE CameraParams +{ + CameraParams(); + CameraParams(const CameraParams& other); + CameraParams& operator =(const CameraParams& other); + CV_WRAP Mat K() const; + + CV_PROP_RW double focal; // Focal length + CV_PROP_RW double aspect; // Aspect ratio + CV_PROP_RW double ppx; // Principal point X + CV_PROP_RW double ppy; // Principal point Y + CV_PROP_RW Mat R; // Rotation + CV_PROP_RW Mat t; // Translation +}; + +//! @} + +} // namespace detail +} // namespace cv + +#endif // #ifndef OPENCV_STITCHING_CAMERA_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/exposure_compensate.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/exposure_compensate.hpp new file mode 100644 index 0000000..074c9b6 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/exposure_compensate.hpp @@ -0,0 +1,245 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP +#define OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP + +#if defined(NO) +# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers. +#endif + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_exposure +//! @{ + +/** @brief Base class for all exposure compensators. + */ +class CV_EXPORTS_W ExposureCompensator +{ +public: + ExposureCompensator(): updateGain(true) {} + virtual ~ExposureCompensator() {} + + enum { NO, GAIN, GAIN_BLOCKS, CHANNELS, CHANNELS_BLOCKS }; + CV_WRAP static Ptr createDefault(int type); + + /** + @param corners Source image top-left corners + @param images Source images + @param masks Image masks to update (second value in pair specifies the value which should be used + to detect where image is) + */ + CV_WRAP void feed(const std::vector &corners, const std::vector &images, + const std::vector &masks); + /** @overload */ + virtual void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) = 0; + /** @brief Compensate exposure in the specified image. + + @param index Image index + @param corner Image top-left corner + @param image Image to process + @param mask Image mask + */ + CV_WRAP virtual void apply(int index, Point corner, InputOutputArray image, InputArray mask) = 0; + CV_WRAP virtual void getMatGains(CV_OUT std::vector& ) {CV_Error(Error::StsInternal, "");}; + CV_WRAP virtual void setMatGains(std::vector& ) { CV_Error(Error::StsInternal, ""); }; + CV_WRAP void setUpdateGain(bool b) { updateGain = b; }; + CV_WRAP bool getUpdateGain() { return updateGain; }; +protected : + bool updateGain; +}; + +/** @brief Stub exposure compensator which does nothing. + */ +class CV_EXPORTS_W NoExposureCompensator : public ExposureCompensator +{ +public: + void feed(const std::vector &/*corners*/, const std::vector &/*images*/, + const std::vector > &/*masks*/) CV_OVERRIDE { } + CV_WRAP void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) CV_OVERRIDE { } + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE { umv.clear(); return; }; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE { umv.clear(); return; }; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image +intensities, see @cite BL07 and @cite WJ10 for details. + */ +class CV_EXPORTS_W GainCompensator : public ExposureCompensator +{ +public: + // This Constructor only exists to make source level compatibility detector happy + CV_WRAP GainCompensator() + : GainCompensator(1) {} + CV_WRAP GainCompensator(int nr_feeds) + : nr_feeds_(nr_feeds), similarity_threshold_(1) {} + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; + void singleFeed(const std::vector &corners, const std::vector &images, + const std::vector > &masks); + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE; + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE ; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE ; + CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; } + CV_WRAP int getNrFeeds() { return nr_feeds_; } + CV_WRAP void setSimilarityThreshold(double similarity_threshold) { similarity_threshold_ = similarity_threshold; } + CV_WRAP double getSimilarityThreshold() const { return similarity_threshold_; } + void prepareSimilarityMask(const std::vector &corners, const std::vector &images); + std::vector gains() const; + +private: + UMat buildSimilarityMask(InputArray src_array1, InputArray src_array2); + + Mat_ gains_; + int nr_feeds_; + double similarity_threshold_; + std::vector similarities_; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image +intensities on each channel independently. + */ +class CV_EXPORTS_W ChannelsCompensator : public ExposureCompensator +{ +public: + CV_WRAP ChannelsCompensator(int nr_feeds=1) + : nr_feeds_(nr_feeds), similarity_threshold_(1) {} + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE; + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE; + CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; } + CV_WRAP int getNrFeeds() { return nr_feeds_; } + CV_WRAP void setSimilarityThreshold(double similarity_threshold) { similarity_threshold_ = similarity_threshold; } + CV_WRAP double getSimilarityThreshold() const { return similarity_threshold_; } + std::vector gains() const { return gains_; } + +private: + std::vector gains_; + int nr_feeds_; + double similarity_threshold_; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image blocks. + */ +class CV_EXPORTS_W BlocksCompensator : public ExposureCompensator +{ +public: + BlocksCompensator(int bl_width=32, int bl_height=32, int nr_feeds=1) + : bl_width_(bl_width), bl_height_(bl_height), nr_feeds_(nr_feeds), nr_gain_filtering_iterations_(2), + similarity_threshold_(1) {} + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE; + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE; + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE; + CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; } + CV_WRAP int getNrFeeds() { return nr_feeds_; } + CV_WRAP void setSimilarityThreshold(double similarity_threshold) { similarity_threshold_ = similarity_threshold; } + CV_WRAP double getSimilarityThreshold() const { return similarity_threshold_; } + CV_WRAP void setBlockSize(int width, int height) { bl_width_ = width; bl_height_ = height; } + CV_WRAP void setBlockSize(Size size) { setBlockSize(size.width, size.height); } + CV_WRAP Size getBlockSize() const { return Size(bl_width_, bl_height_); } + CV_WRAP void setNrGainsFilteringIterations(int nr_iterations) { nr_gain_filtering_iterations_ = nr_iterations; } + CV_WRAP int getNrGainsFilteringIterations() const { return nr_gain_filtering_iterations_; } + +protected: + template + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks); + +private: + UMat getGainMap(const GainCompensator& compensator, int bl_idx, Size bl_per_img); + UMat getGainMap(const ChannelsCompensator& compensator, int bl_idx, Size bl_per_img); + + int bl_width_, bl_height_; + std::vector gain_maps_; + int nr_feeds_; + int nr_gain_filtering_iterations_; + double similarity_threshold_; +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block +intensities, see @cite UES01 for details. + */ +class CV_EXPORTS_W BlocksGainCompensator : public BlocksCompensator +{ +public: + // This Constructor only exists to make source level compatibility detector happy + CV_WRAP BlocksGainCompensator(int bl_width = 32, int bl_height = 32) + : BlocksGainCompensator(bl_width, bl_height, 1) {} + CV_WRAP BlocksGainCompensator(int bl_width, int bl_height, int nr_feeds) + : BlocksCompensator(bl_width, bl_height, nr_feeds) {} + + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; + + // This function only exists to make source level compatibility detector happy + CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE { + BlocksCompensator::apply(index, corner, image, mask); } + // This function only exists to make source level compatibility detector happy + CV_WRAP void getMatGains(CV_OUT std::vector& umv) CV_OVERRIDE { BlocksCompensator::getMatGains(umv); } + // This function only exists to make source level compatibility detector happy + CV_WRAP void setMatGains(std::vector& umv) CV_OVERRIDE { BlocksCompensator::setMatGains(umv); } +}; + +/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block +on each channel. + */ +class CV_EXPORTS_W BlocksChannelsCompensator : public BlocksCompensator +{ +public: + CV_WRAP BlocksChannelsCompensator(int bl_width=32, int bl_height=32, int nr_feeds=1) + : BlocksCompensator(bl_width, bl_height, nr_feeds) {} + + void feed(const std::vector &corners, const std::vector &images, + const std::vector > &masks) CV_OVERRIDE; +}; +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/matchers.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/matchers.hpp new file mode 100644 index 0000000..cd9749c --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/matchers.hpp @@ -0,0 +1,253 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_MATCHERS_HPP +#define OPENCV_STITCHING_MATCHERS_HPP + +#include "opencv2/core.hpp" +#include "opencv2/features2d.hpp" + +#include "opencv2/opencv_modules.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_match +//! @{ + +/** @brief Structure containing image keypoints and descriptors. */ +struct CV_EXPORTS_W_SIMPLE ImageFeatures +{ + CV_PROP_RW int img_idx; + CV_PROP_RW Size img_size; + CV_PROP_RW std::vector keypoints; + CV_PROP_RW UMat descriptors; + CV_WRAP std::vector getKeypoints() { return keypoints; }; +}; +/** @brief + +@param featuresFinder +@param images +@param features +@param masks +*/ +CV_EXPORTS_W void computeImageFeatures( + const Ptr &featuresFinder, + InputArrayOfArrays images, + CV_OUT std::vector &features, + InputArrayOfArrays masks = noArray()); + +/** @brief + +@param featuresFinder +@param image +@param features +@param mask +*/ +CV_EXPORTS_AS(computeImageFeatures2) void computeImageFeatures( + const Ptr &featuresFinder, + InputArray image, + CV_OUT ImageFeatures &features, + InputArray mask = noArray()); + +/** @brief Structure containing information about matches between two images. + +It's assumed that there is a transformation between those images. Transformation may be +homography or affine transformation based on selected matcher. + +@sa detail::FeaturesMatcher +*/ +struct CV_EXPORTS_W_SIMPLE MatchesInfo +{ + MatchesInfo(); + MatchesInfo(const MatchesInfo &other); + MatchesInfo& operator =(const MatchesInfo &other); + + CV_PROP_RW int src_img_idx; + CV_PROP_RW int dst_img_idx; //!< Images indices (optional) + std::vector matches; + std::vector inliers_mask; //!< Geometrically consistent matches mask + CV_PROP_RW int num_inliers; //!< Number of geometrically consistent matches + CV_PROP_RW Mat H; //!< Estimated transformation + CV_PROP_RW double confidence; //!< Confidence two images are from the same panorama + CV_WRAP std::vector getMatches() { return matches; }; + CV_WRAP std::vector getInliers() { return inliers_mask; }; +}; + +/** @brief Feature matchers base class. */ +class CV_EXPORTS_W FeaturesMatcher +{ +public: + CV_WRAP virtual ~FeaturesMatcher() {} + + /** @overload + @param features1 First image features + @param features2 Second image features + @param matches_info Found matches + */ + CV_WRAP_AS(apply) void operator ()(const ImageFeatures &features1, const ImageFeatures &features2, + CV_OUT MatchesInfo& matches_info) { match(features1, features2, matches_info); } + + /** @brief Performs images matching. + + @param features Features of the source images + @param pairwise_matches Found pairwise matches + @param mask Mask indicating which image pairs must be matched + + The function is parallelized with the TBB library. + + @sa detail::MatchesInfo + */ + CV_WRAP_AS(apply2) void operator ()(const std::vector &features, CV_OUT std::vector &pairwise_matches, + const cv::UMat &mask = cv::UMat()); + + /** @return True, if it's possible to use the same matcher instance in parallel, false otherwise + */ + CV_WRAP bool isThreadSafe() const { return is_thread_safe_; } + + /** @brief Frees unused memory allocated before if there is any. + */ + CV_WRAP virtual void collectGarbage() {} + +protected: + FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {} + + /** @brief This method must implement matching logic in order to make the wrappers + detail::FeaturesMatcher::operator()_ work. + + @param features1 first image features + @param features2 second image features + @param matches_info found matches + */ + virtual void match(const ImageFeatures &features1, const ImageFeatures &features2, + MatchesInfo& matches_info) = 0; + + bool is_thread_safe_; +}; + +/** @brief Features matcher which finds two best matches for each feature and leaves the best one only if the +ratio between descriptor distances is greater than the threshold match_conf + +@sa detail::FeaturesMatcher + */ +class CV_EXPORTS_W BestOf2NearestMatcher : public FeaturesMatcher +{ +public: + /** @brief Constructs a "best of 2 nearest" matcher. + + @param try_use_gpu Should try to use GPU or not + @param match_conf Match distances ration threshold + @param num_matches_thresh1 Minimum number of matches required for the 2D projective transform + estimation used in the inliers classification step + @param num_matches_thresh2 Minimum number of matches required for the 2D projective transform + re-estimation on inliers + */ + CV_WRAP BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6, + int num_matches_thresh2 = 6); + + CV_WRAP void collectGarbage() CV_OVERRIDE; + CV_WRAP static Ptr create(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6, + int num_matches_thresh2 = 6); + +protected: + + void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE; + int num_matches_thresh1_; + int num_matches_thresh2_; + Ptr impl_; +}; + +class CV_EXPORTS_W BestOf2NearestRangeMatcher : public BestOf2NearestMatcher +{ +public: + CV_WRAP BestOf2NearestRangeMatcher(int range_width = 5, bool try_use_gpu = false, float match_conf = 0.3f, + int num_matches_thresh1 = 6, int num_matches_thresh2 = 6); + + void operator ()(const std::vector &features, std::vector &pairwise_matches, + const cv::UMat &mask = cv::UMat()); + + +protected: + int range_width_; +}; + +/** @brief Features matcher similar to cv::detail::BestOf2NearestMatcher which +finds two best matches for each feature and leaves the best one only if the +ratio between descriptor distances is greater than the threshold match_conf. + +Unlike cv::detail::BestOf2NearestMatcher this matcher uses affine +transformation (affine transformation estimate will be placed in matches_info). + +@sa cv::detail::FeaturesMatcher cv::detail::BestOf2NearestMatcher + */ +class CV_EXPORTS_W AffineBestOf2NearestMatcher : public BestOf2NearestMatcher +{ +public: + /** @brief Constructs a "best of 2 nearest" matcher that expects affine transformation + between images + + @param full_affine whether to use full affine transformation with 6 degress of freedom or reduced + transformation with 4 degrees of freedom using only rotation, translation and uniform scaling + @param try_use_gpu Should try to use GPU or not + @param match_conf Match distances ration threshold + @param num_matches_thresh1 Minimum number of matches required for the 2D affine transform + estimation used in the inliers classification step + + @sa cv::estimateAffine2D cv::estimateAffinePartial2D + */ + CV_WRAP AffineBestOf2NearestMatcher(bool full_affine = false, bool try_use_gpu = false, + float match_conf = 0.3f, int num_matches_thresh1 = 6) : + BestOf2NearestMatcher(try_use_gpu, match_conf, num_matches_thresh1, num_matches_thresh1), + full_affine_(full_affine) {} + +protected: + void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE; + + bool full_affine_; +}; + +//! @} stitching_match + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_MATCHERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/motion_estimators.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/motion_estimators.hpp new file mode 100644 index 0000000..ad21ee1 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/motion_estimators.hpp @@ -0,0 +1,373 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_MOTION_ESTIMATORS_HPP +#define OPENCV_STITCHING_MOTION_ESTIMATORS_HPP + +#include "opencv2/core.hpp" +#include "matchers.hpp" +#include "util.hpp" +#include "camera.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_rotation +//! @{ + +/** @brief Rotation estimator base class. + +It takes features of all images, pairwise matches between all images and estimates rotations of all +cameras. + +@note The coordinate system origin is implementation-dependent, but you can always normalize the +rotations in respect to the first camera, for instance. : + */ +class CV_EXPORTS_W Estimator +{ +public: + virtual ~Estimator() {} + + /** @brief Estimates camera parameters. + + @param features Features of images + @param pairwise_matches Pairwise matches of images + @param cameras Estimated camera parameters + @return True in case of success, false otherwise + */ + CV_WRAP_AS(apply) bool operator ()(const std::vector &features, + const std::vector &pairwise_matches, + CV_OUT CV_IN_OUT std::vector &cameras) + { + return estimate(features, pairwise_matches, cameras); + } + +protected: + /** @brief This method must implement camera parameters estimation logic in order to make the wrapper + detail::Estimator::operator()_ work. + + @param features Features of images + @param pairwise_matches Pairwise matches of images + @param cameras Estimated camera parameters + @return True in case of success, false otherwise + */ + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + CV_OUT std::vector &cameras) = 0; +}; + +/** @brief Homography based rotation estimator. + */ +class CV_EXPORTS_W HomographyBasedEstimator : public Estimator +{ +public: + CV_WRAP HomographyBasedEstimator(bool is_focals_estimated = false) + : is_focals_estimated_(is_focals_estimated) {} + +private: + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) CV_OVERRIDE; + + bool is_focals_estimated_; +}; + +/** @brief Affine transformation based estimator. + +This estimator uses pairwise transformations estimated by matcher to estimate +final transformation for each camera. + +@sa cv::detail::HomographyBasedEstimator + */ +class CV_EXPORTS_W AffineBasedEstimator : public Estimator +{ +public: + CV_WRAP AffineBasedEstimator(){} +private: + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) CV_OVERRIDE; +}; + +/** @brief Base class for all camera parameters refinement methods. + */ +class CV_EXPORTS_W BundleAdjusterBase : public Estimator +{ +public: + CV_WRAP const Mat refinementMask() const { return refinement_mask_.clone(); } + CV_WRAP void setRefinementMask(const Mat &mask) + { + CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3)); + refinement_mask_ = mask.clone(); + } + + CV_WRAP double confThresh() const { return conf_thresh_; } + CV_WRAP void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } + + CV_WRAP TermCriteria termCriteria() { return term_criteria_; } + CV_WRAP void setTermCriteria(const TermCriteria& term_criteria) { term_criteria_ = term_criteria; } + +protected: + /** @brief Construct a bundle adjuster base instance. + + @param num_params_per_cam Number of parameters per camera + @param num_errs_per_measurement Number of error terms (components) per match + */ + BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement) + : num_images_(0), total_num_matches_(0), + num_params_per_cam_(num_params_per_cam), + num_errs_per_measurement_(num_errs_per_measurement), + features_(0), pairwise_matches_(0), conf_thresh_(0) + { + setRefinementMask(Mat::ones(3, 3, CV_8U)); + setConfThresh(1.); + setTermCriteria(TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 1000, DBL_EPSILON)); + } + + // Runs bundle adjustment + virtual bool estimate(const std::vector &features, + const std::vector &pairwise_matches, + std::vector &cameras) CV_OVERRIDE; + + /** @brief Sets initial camera parameter to refine. + + @param cameras Camera parameters + */ + virtual void setUpInitialCameraParams(const std::vector &cameras) = 0; + /** @brief Gets the refined camera parameters. + + @param cameras Refined camera parameters + */ + virtual void obtainRefinedCameraParams(std::vector &cameras) const = 0; + /** @brief Calculates error vector. + + @param err Error column-vector of length total_num_matches \* num_errs_per_measurement + */ + virtual void calcError(Mat &err) = 0; + /** @brief Calculates the cost function jacobian. + + @param jac Jacobian matrix of dimensions + (total_num_matches \* num_errs_per_measurement) x (num_images \* num_params_per_cam) + */ + virtual void calcJacobian(Mat &jac) = 0; + + // 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine + Mat refinement_mask_; + + int num_images_; + int total_num_matches_; + + int num_params_per_cam_; + int num_errs_per_measurement_; + + const ImageFeatures *features_; + const MatchesInfo *pairwise_matches_; + + // Threshold to filter out poorly matched image pairs + double conf_thresh_; + + //Levenberg-Marquardt algorithm termination criteria + TermCriteria term_criteria_; + + // Camera parameters matrix (CV_64F) + Mat cam_params_; + + // Connected images pairs + std::vector > edges_; +}; + + +/** @brief Stub bundle adjuster that does nothing. + */ +class CV_EXPORTS_W NoBundleAdjuster : public BundleAdjusterBase +{ +public: + CV_WRAP NoBundleAdjuster() : BundleAdjusterBase(0, 0) {} + +private: + bool estimate(const std::vector &, const std::vector &, + std::vector &) CV_OVERRIDE + { + return true; + } + void setUpInitialCameraParams(const std::vector &) CV_OVERRIDE {} + void obtainRefinedCameraParams(std::vector &) const CV_OVERRIDE {} + void calcError(Mat &) CV_OVERRIDE {} + void calcJacobian(Mat &) CV_OVERRIDE {} +}; + + +/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection +error squares + +It can estimate focal length, aspect ratio, principal point. +You can affect only on them via the refinement mask. + */ +class CV_EXPORTS_W BundleAdjusterReproj : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the distances +between the rays passing through the camera center and a feature. : + +It can estimate focal length. It ignores the refinement mask for now. + */ +class CV_EXPORTS_W BundleAdjusterRay : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterRay() : BundleAdjusterBase(4, 3) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +/** @brief Bundle adjuster that expects affine transformation +represented in homogeneous coordinates in R for each camera param. Implements +camera parameters refinement algorithm which minimizes sum of the reprojection +error squares + +It estimates all transformation parameters. Refinement mask is ignored. + +@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial + */ +class CV_EXPORTS_W BundleAdjusterAffine : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterAffine() : BundleAdjusterBase(6, 2) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +/** @brief Bundle adjuster that expects affine transformation with 4 DOF +represented in homogeneous coordinates in R for each camera param. Implements +camera parameters refinement algorithm which minimizes sum of the reprojection +error squares + +It estimates all transformation parameters. Refinement mask is ignored. + +@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine + */ +class CV_EXPORTS_W BundleAdjusterAffinePartial : public BundleAdjusterBase +{ +public: + CV_WRAP BundleAdjusterAffinePartial() : BundleAdjusterBase(4, 2) {} + +private: + void setUpInitialCameraParams(const std::vector &cameras) CV_OVERRIDE; + void obtainRefinedCameraParams(std::vector &cameras) const CV_OVERRIDE; + void calcError(Mat &err) CV_OVERRIDE; + void calcJacobian(Mat &jac) CV_OVERRIDE; + + Mat err1_, err2_; +}; + + +enum WaveCorrectKind +{ + WAVE_CORRECT_HORIZ, + WAVE_CORRECT_VERT, + WAVE_CORRECT_AUTO +}; + +/** @brief Tries to detect the wave correction kind depending +on whether a panorama spans horizontally or vertically + +@param rmats Camera rotation matrices. +@return The correction kind to use for this panorama + */ +CV_EXPORTS +WaveCorrectKind autoDetectWaveCorrectKind(const std::vector &rmats); + +/** @brief Tries to make panorama more horizontal (or vertical). + +@param rmats Camera rotation matrices. +@param kind Correction kind, see detail::WaveCorrectKind. + */ +void CV_EXPORTS_W waveCorrect(CV_IN_OUT std::vector &rmats, WaveCorrectKind kind); + + +////////////////////////////////////////////////////////////////////////////// +// Auxiliary functions + +// Returns matches graph representation in DOT language +String CV_EXPORTS_W matchesGraphAsString(std::vector &pathes, std::vector &pairwise_matches, + float conf_threshold); + +CV_EXPORTS_W std::vector leaveBiggestComponent( + std::vector &features, + std::vector &pairwise_matches, + float conf_threshold); + +void CV_EXPORTS findMaxSpanningTree( + int num_images, const std::vector &pairwise_matches, + Graph &span_tree, std::vector ¢ers); + +//! @} stitching_rotation + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_MOTION_ESTIMATORS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/seam_finders.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/seam_finders.hpp new file mode 100644 index 0000000..71dae7f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/seam_finders.hpp @@ -0,0 +1,291 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_SEAM_FINDERS_HPP +#define OPENCV_STITCHING_SEAM_FINDERS_HPP + +#include +#include "opencv2/core.hpp" +#include "opencv2/opencv_modules.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_seam +//! @{ + +/** @brief Base class for a seam estimator. + */ +class CV_EXPORTS_W SeamFinder +{ +public: + CV_WRAP virtual ~SeamFinder() {} + enum { NO, VORONOI_SEAM, DP_SEAM }; + /** @brief Estimates seams. + + @param src Source images + @param corners Source image top-left corners + @param masks Source image masks to update + */ + CV_WRAP virtual void find(const std::vector &src, const std::vector &corners, + CV_IN_OUT std::vector &masks) = 0; + CV_WRAP static Ptr createDefault(int type); +}; + +/** @brief Stub seam estimator which does nothing. + */ +class CV_EXPORTS_W NoSeamFinder : public SeamFinder +{ +public: + CV_WRAP void find(const std::vector&, const std::vector&, CV_IN_OUT std::vector&) CV_OVERRIDE {} +}; + +/** @brief Base class for all pairwise seam estimators. + */ +class CV_EXPORTS_W PairwiseSeamFinder : public SeamFinder +{ +public: + CV_WRAP virtual void find(const std::vector &src, const std::vector &corners, + CV_IN_OUT std::vector &masks) CV_OVERRIDE; + +protected: + void run(); + /** @brief Resolves masks intersection of two specified images in the given ROI. + + @param first First image index + @param second Second image index + @param roi Region of interest + */ + virtual void findInPair(size_t first, size_t second, Rect roi) = 0; + + std::vector images_; + std::vector sizes_; + std::vector corners_; + std::vector masks_; +}; + +/** @brief Voronoi diagram-based seam estimator. + */ +class CV_EXPORTS_W VoronoiSeamFinder : public PairwiseSeamFinder +{ +public: + CV_WRAP virtual void find(const std::vector &src, const std::vector &corners, + CV_IN_OUT std::vector &masks) CV_OVERRIDE; + virtual void find(const std::vector &size, const std::vector &corners, + std::vector &masks); +private: + void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE; +}; + + +class CV_EXPORTS_W DpSeamFinder : public SeamFinder +{ +public: + enum CostFunction { COLOR, COLOR_GRAD }; + + DpSeamFinder(CostFunction costFunc = COLOR); + CV_WRAP DpSeamFinder(String costFunc ); + + CostFunction costFunction() const { return costFunc_; } + void setCostFunction(CostFunction val) { costFunc_ = val; } + CV_WRAP void setCostFunction(String val); + + virtual void find(const std::vector &src, const std::vector &corners, + std::vector &masks) CV_OVERRIDE; + +private: + enum ComponentState + { + FIRST = 1, SECOND = 2, INTERS = 4, + INTERS_FIRST = INTERS | FIRST, + INTERS_SECOND = INTERS | SECOND + }; + + class ImagePairLess + { + public: + ImagePairLess(const std::vector &images, const std::vector &corners) + : src_(&images[0]), corners_(&corners[0]) {} + + bool operator() (const std::pair &l, const std::pair &r) const + { + Point c1 = corners_[l.first] + Point(src_[l.first].cols / 2, src_[l.first].rows / 2); + Point c2 = corners_[l.second] + Point(src_[l.second].cols / 2, src_[l.second].rows / 2); + int d1 = (c1 - c2).dot(c1 - c2); + + c1 = corners_[r.first] + Point(src_[r.first].cols / 2, src_[r.first].rows / 2); + c2 = corners_[r.second] + Point(src_[r.second].cols / 2, src_[r.second].rows / 2); + int d2 = (c1 - c2).dot(c1 - c2); + + return d1 < d2; + } + + private: + const Mat *src_; + const Point *corners_; + }; + + class ClosePoints + { + public: + ClosePoints(int minDist) : minDist_(minDist) {} + + bool operator() (const Point &p1, const Point &p2) const + { + int dist2 = (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y); + return dist2 < minDist_ * minDist_; + } + + private: + int minDist_; + }; + + void process( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); + + void findComponents(); + + void findEdges(); + + void resolveConflicts( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); + + void computeGradients(const Mat &image1, const Mat &image2); + + bool hasOnlyOneNeighbor(int comp); + + bool closeToContour(int y, int x, const Mat_ &contourMask); + + bool getSeamTips(int comp1, int comp2, Point &p1, Point &p2); + + void computeCosts( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, + int comp, Mat_ &costV, Mat_ &costH); + + bool estimateSeam( + const Mat &image1, const Mat &image2, Point tl1, Point tl2, int comp, + Point p1, Point p2, std::vector &seam, bool &isHorizontal); + + void updateLabelsUsingSeam( + int comp1, int comp2, const std::vector &seam, bool isHorizontalSeam); + + CostFunction costFunc_; + + // processing images pair data + Point unionTl_, unionBr_; + Size unionSize_; + Mat_ mask1_, mask2_; + Mat_ contour1mask_, contour2mask_; + Mat_ gradx1_, grady1_; + Mat_ gradx2_, grady2_; + + // components data + int ncomps_; + Mat_ labels_; + std::vector states_; + std::vector tls_, brs_; + std::vector > contours_; + std::set > edges_; +}; + +/** @brief Base class for all minimum graph-cut-based seam estimators. + */ +class CV_EXPORTS GraphCutSeamFinderBase +{ +public: + enum CostType { COST_COLOR, COST_COLOR_GRAD }; +}; + +/** @brief Minimum graph cut-based seam estimator. See details in @cite V03 . + */ +class CV_EXPORTS_W GraphCutSeamFinder : public GraphCutSeamFinderBase, public SeamFinder +{ +public: + GraphCutSeamFinder(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f, + float bad_region_penalty = 1000.f); + CV_WRAP GraphCutSeamFinder(String cost_type,float terminal_cost = 10000.f, + float bad_region_penalty = 1000.f); + + ~GraphCutSeamFinder(); + + CV_WRAP void find(const std::vector &src, const std::vector &corners, + std::vector &masks) CV_OVERRIDE; + +private: + // To avoid GCGraph dependency + class Impl; + Ptr impl_; +}; + + +#ifdef HAVE_OPENCV_CUDALEGACY +class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder +{ +public: + GraphCutSeamFinderGpu(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f, + float bad_region_penalty = 1000.f) + : cost_type_(cost_type), terminal_cost_(terminal_cost), + bad_region_penalty_(bad_region_penalty) {} + + void find(const std::vector &src, const std::vector &corners, + std::vector &masks) CV_OVERRIDE; + void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE; + +private: + void setGraphWeightsColor(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &mask1, const cv::Mat &mask2, + cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom); + void setGraphWeightsColorGrad(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &dx1, const cv::Mat &dx2, + const cv::Mat &dy1, const cv::Mat &dy2, const cv::Mat &mask1, const cv::Mat &mask2, + cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom); + std::vector dx_, dy_; + int cost_type_; + float terminal_cost_; + float bad_region_penalty_; +}; +#endif + +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_SEAM_FINDERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/timelapsers.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/timelapsers.hpp new file mode 100644 index 0000000..f6f3da8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/timelapsers.hpp @@ -0,0 +1,91 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + + +#ifndef OPENCV_STITCHING_TIMELAPSERS_HPP +#define OPENCV_STITCHING_TIMELAPSERS_HPP + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching +//! @{ + +// Base Timelapser class, takes a sequence of images, applies appropriate shift, stores result in dst_. + +class CV_EXPORTS_W Timelapser +{ +public: + + enum {AS_IS, CROP}; + + virtual ~Timelapser() {} + + CV_WRAP static Ptr createDefault(int type); + + CV_WRAP virtual void initialize(const std::vector &corners, const std::vector &sizes); + CV_WRAP virtual void process(InputArray img, InputArray mask, Point tl); + CV_WRAP virtual const UMat& getDst() {return dst_;} + +protected: + + virtual bool test_point(Point pt); + + UMat dst_; + Rect dst_roi_; +}; + + +class CV_EXPORTS_W TimelapserCrop : public Timelapser +{ +public: + virtual void initialize(const std::vector &corners, const std::vector &sizes) CV_OVERRIDE; +}; + +//! @} + +} // namespace detail +} // namespace cv + +#endif // OPENCV_STITCHING_TIMELAPSERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/util.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/util.hpp new file mode 100644 index 0000000..bf7a390 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/util.hpp @@ -0,0 +1,121 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_UTIL_HPP +#define OPENCV_STITCHING_UTIL_HPP + +#include +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching +//! @{ + +class CV_EXPORTS DisjointSets +{ +public: + DisjointSets(int elem_count = 0) { createOneElemSets(elem_count); } + + void createOneElemSets(int elem_count); + int findSetByElem(int elem); + int mergeSets(int set1, int set2); + + std::vector parent; + std::vector size; + +private: + std::vector rank_; +}; + + +struct CV_EXPORTS GraphEdge +{ + GraphEdge(int from, int to, float weight); + bool operator <(const GraphEdge& other) const { return weight < other.weight; } + bool operator >(const GraphEdge& other) const { return weight > other.weight; } + + int from, to; + float weight; +}; + +inline GraphEdge::GraphEdge(int _from, int _to, float _weight) : from(_from), to(_to), weight(_weight) {} + + +class CV_EXPORTS Graph +{ +public: + Graph(int num_vertices = 0) { create(num_vertices); } + void create(int num_vertices) { edges_.assign(num_vertices, std::list()); } + int numVertices() const { return static_cast(edges_.size()); } + void addEdge(int from, int to, float weight); + template B forEach(B body) const; + template B walkBreadthFirst(int from, B body) const; + +private: + std::vector< std::list > edges_; +}; + + +////////////////////////////////////////////////////////////////////////////// +// Auxiliary functions + +CV_EXPORTS_W bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi); +CV_EXPORTS_W Rect resultRoi(const std::vector &corners, const std::vector &images); +CV_EXPORTS_W Rect resultRoi(const std::vector &corners, const std::vector &sizes); +CV_EXPORTS_W Rect resultRoiIntersection(const std::vector &corners, const std::vector &sizes); +CV_EXPORTS_W Point resultTl(const std::vector &corners); + +// Returns random 'count' element subset of the {0,1,...,size-1} set +CV_EXPORTS_W void selectRandomSubset(int count, int size, std::vector &subset); + +CV_EXPORTS_W int& stitchingLogLevel(); + +//! @} + +} // namespace detail +} // namespace cv + +#include "util_inl.hpp" + +#endif // OPENCV_STITCHING_UTIL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/util_inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/util_inl.hpp new file mode 100644 index 0000000..dafab8b --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/util_inl.hpp @@ -0,0 +1,131 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_UTIL_INL_HPP +#define OPENCV_STITCHING_UTIL_INL_HPP + +#include +#include "opencv2/core.hpp" +#include "util.hpp" // Make your IDE see declarations + +//! @cond IGNORED + +namespace cv { +namespace detail { + +template +B Graph::forEach(B body) const +{ + for (int i = 0; i < numVertices(); ++i) + { + std::list::const_iterator edge = edges_[i].begin(); + for (; edge != edges_[i].end(); ++edge) + body(*edge); + } + return body; +} + + +template +B Graph::walkBreadthFirst(int from, B body) const +{ + std::vector was(numVertices(), false); + std::queue vertices; + + was[from] = true; + vertices.push(from); + + while (!vertices.empty()) + { + int vertex = vertices.front(); + vertices.pop(); + + std::list::const_iterator edge = edges_[vertex].begin(); + for (; edge != edges_[vertex].end(); ++edge) + { + if (!was[edge->to]) + { + body(*edge); + was[edge->to] = true; + vertices.push(edge->to); + } + } + } + + return body; +} + + +////////////////////////////////////////////////////////////////////////////// +// Some auxiliary math functions + +static inline +float normL2(const Point3f& a) +{ + return a.x * a.x + a.y * a.y + a.z * a.z; +} + + +static inline +float normL2(const Point3f& a, const Point3f& b) +{ + return normL2(a - b); +} + + +static inline +double normL2sq(const Mat &r) +{ + return r.dot(r); +} + + +static inline int sqr(int x) { return x * x; } +static inline float sqr(float x) { return x * x; } +static inline double sqr(double x) { return x * x; } + +} // namespace detail +} // namespace cv + +//! @endcond + +#endif // OPENCV_STITCHING_UTIL_INL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/warpers.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/warpers.hpp new file mode 100644 index 0000000..ff005e8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/warpers.hpp @@ -0,0 +1,682 @@ + /*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_WARPERS_HPP +#define OPENCV_STITCHING_WARPERS_HPP + +#include "opencv2/core.hpp" +#include "opencv2/core/cuda.hpp" +#include "opencv2/imgproc.hpp" +#include "opencv2/opencv_modules.hpp" + +namespace cv { +namespace detail { + +//! @addtogroup stitching_warp +//! @{ + +/** @brief Rotation-only model image warper interface. + */ +class CV_EXPORTS RotationWarper +{ +public: + virtual ~RotationWarper() {} + + /** @brief Projects the image point. + + @param pt Source point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected point + */ + virtual Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) = 0; + + /** @brief Projects the image point backward. + + @param pt Projected point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Backward-projected point + */ +#if CV_VERSION_MAJOR == 4 + virtual Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) + { + CV_UNUSED(pt); CV_UNUSED(K); CV_UNUSED(R); + CV_Error(Error::StsNotImplemented, ""); + } +#else + virtual Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) = 0; +#endif + + /** @brief Builds the projection maps according to the given camera data. + + @param src_size Source image size + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param xmap Projection map for the x axis + @param ymap Projection map for the y axis + @return Projected image minimum bounding box + */ + virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) = 0; + + /** @brief Projects the image. + + @param src Source image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst Projected image + @return Project image top-left corner + */ + virtual Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + CV_OUT OutputArray dst) = 0; + + /** @brief Projects the image backward. + + @param src Projected image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst_size Backward-projected image size + @param dst Backward-projected image + */ + virtual void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, CV_OUT OutputArray dst) = 0; + + /** + @param src_size Source image bounding box + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected image minimum bounding box + */ + virtual Rect warpRoi(Size src_size, InputArray K, InputArray R) = 0; + + virtual float getScale() const { return 1.f; } + virtual void setScale(float) {} +}; + +/** @brief Base class for warping logic implementation. + */ +struct CV_EXPORTS_W_SIMPLE ProjectorBase +{ + void setCameraParams(InputArray K = Mat::eye(3, 3, CV_32F), + InputArray R = Mat::eye(3, 3, CV_32F), + InputArray T = Mat::zeros(3, 1, CV_32F)); + + float scale; + float k[9]; + float rinv[9]; + float r_kinv[9]; + float k_rinv[9]; + float t[3]; +}; + +/** @brief Base class for rotation-based warper using a detail::ProjectorBase_ derived class. + */ +template +class CV_EXPORTS_TEMPLATE RotationWarperBase : public RotationWarper +{ +public: + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE; + + Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE; + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE; + + void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, OutputArray dst) CV_OVERRIDE; + + Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE; + + float getScale() const CV_OVERRIDE{ return projector_.scale; } + void setScale(float val) CV_OVERRIDE { projector_.scale = val; } + +protected: + + // Detects ROI of the destination image. It's correct for any projection. + virtual void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br); + + // Detects ROI of the destination image by walking over image border. + // Correctness for any projection isn't guaranteed. + void detectResultRoiByBorder(Size src_size, Point &dst_tl, Point &dst_br); + + P projector_; +}; + + +struct CV_EXPORTS PlaneProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + +/** @brief Warper that maps an image onto the z = 1 plane. + */ +class CV_EXPORTS PlaneWarper : public RotationWarperBase +{ +public: + /** @brief Construct an instance of the plane warper class. + + @param scale Projected image scale multiplier + */ + PlaneWarper(float scale = 1.f) { projector_.scale = scale; } + + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE; + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R, InputArray T); + + Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) CV_OVERRIDE; + Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R, InputArray T); + + virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, CV_OUT OutputArray xmap, CV_OUT OutputArray ymap); + Rect buildMaps(Size src_size, InputArray K, InputArray R, CV_OUT OutputArray xmap, CV_OUT OutputArray ymap) CV_OVERRIDE; + + Point warp(InputArray src, InputArray K, InputArray R, + int interp_mode, int border_mode, CV_OUT OutputArray dst) CV_OVERRIDE; + virtual Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, + CV_OUT OutputArray dst); + + Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE; + Rect warpRoi(Size src_size, InputArray K, InputArray R, InputArray T); + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE; +}; + + +/** @brief Affine warper that uses rotations and translations + + Uses affine transformation in homogeneous coordinates to represent both rotation and + translation in camera rotation matrix. + */ +class CV_EXPORTS AffineWarper : public PlaneWarper +{ +public: + /** @brief Construct an instance of the affine warper class. + + @param scale Projected image scale multiplier + */ + AffineWarper(float scale = 1.f) : PlaneWarper(scale) {} + + /** @brief Projects the image point. + + @param pt Source point + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @return Projected point + */ + Point2f warpPoint(const Point2f &pt, InputArray K, InputArray H) CV_OVERRIDE; + + /** @brief Projects the image point backward. + + @param pt Projected point + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @return Backward-projected point + */ + Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray H) CV_OVERRIDE; + + /** @brief Builds the projection maps according to the given camera data. + + @param src_size Source image size + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @param xmap Projection map for the x axis + @param ymap Projection map for the y axis + @return Projected image minimum bounding box + */ + Rect buildMaps(Size src_size, InputArray K, InputArray H, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + + /** @brief Projects the image. + + @param src Source image + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst Projected image + @return Project image top-left corner + */ + Point warp(InputArray src, InputArray K, InputArray H, + int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE; + + /** + @param src_size Source image bounding box + @param K Camera intrinsic parameters + @param H Camera extrinsic parameters + @return Projected image minimum bounding box + */ + Rect warpRoi(Size src_size, InputArray K, InputArray H) CV_OVERRIDE; + +protected: + /** @brief Extracts rotation and translation matrices from matrix H representing + affine transformation in homogeneous coordinates + */ + void getRTfromHomogeneous(InputArray H, Mat &R, Mat &T); +}; + + +struct CV_EXPORTS_W_SIMPLE SphericalProjector : ProjectorBase +{ + CV_WRAP void mapForward(float x, float y, float &u, float &v); + CV_WRAP void mapBackward(float u, float v, float &x, float &y); +}; + + +/** @brief Warper that maps an image onto the unit sphere located at the origin. + + Projects image onto unit sphere with origin at (0, 0, 0) and radius scale, measured in pixels. + A 360 panorama would therefore have a resulting width of 2 * scale * PI pixels. + Poles are located at (0, -1, 0) and (0, 1, 0) points. +*/ +class CV_EXPORTS SphericalWarper : public RotationWarperBase +{ +public: + /** @brief Construct an instance of the spherical warper class. + + @param scale Radius of the projected sphere, in pixels. An image spanning the + whole sphere will have a width of 2 * scale * PI pixels. + */ + SphericalWarper(float scale) { projector_.scale = scale; } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE; +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE; +}; + + +struct CV_EXPORTS CylindricalProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +/** @brief Warper that maps an image onto the x\*x + z\*z = 1 cylinder. + */ +class CV_EXPORTS CylindricalWarper : public RotationWarperBase +{ +public: + /** @brief Construct an instance of the cylindrical warper class. + + @param scale Projected image scale multiplier + */ + CylindricalWarper(float scale) { projector_.scale = scale; } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE; + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE; +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE + { + RotationWarperBase::detectResultRoiByBorder(src_size, dst_tl, dst_br); + } +}; + + +struct CV_EXPORTS FisheyeProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS FisheyeWarper : public RotationWarperBase +{ +public: + FisheyeWarper(float scale) { projector_.scale = scale; } +}; + + +struct CV_EXPORTS StereographicProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS StereographicWarper : public RotationWarperBase +{ +public: + StereographicWarper(float scale) { projector_.scale = scale; } +}; + + +struct CV_EXPORTS CompressedRectilinearProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS CompressedRectilinearWarper : public RotationWarperBase +{ +public: + CompressedRectilinearWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } +}; + + +struct CV_EXPORTS CompressedRectilinearPortraitProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS CompressedRectilinearPortraitWarper : public RotationWarperBase +{ +public: + CompressedRectilinearPortraitWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } +}; + + +struct CV_EXPORTS PaniniProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS PaniniWarper : public RotationWarperBase +{ +public: + PaniniWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } +}; + + +struct CV_EXPORTS PaniniPortraitProjector : ProjectorBase +{ + float a, b; + + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS PaniniPortraitWarper : public RotationWarperBase +{ +public: + PaniniPortraitWarper(float scale, float A = 1, float B = 1) + { + projector_.a = A; + projector_.b = B; + projector_.scale = scale; + } + +}; + + +struct CV_EXPORTS MercatorProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS MercatorWarper : public RotationWarperBase +{ +public: + MercatorWarper(float scale) { projector_.scale = scale; } +}; + + +struct CV_EXPORTS TransverseMercatorProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS TransverseMercatorWarper : public RotationWarperBase +{ +public: + TransverseMercatorWarper(float scale) { projector_.scale = scale; } +}; + + +class CV_EXPORTS PlaneWarperGpu : public PlaneWarper +{ +public: + PlaneWarperGpu(float scale = 1.f) : PlaneWarper(scale) {} + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, T, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, T, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, int interp_mode, int border_mode, + cuda::GpuMat & dst); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, + cuda::GpuMat & dst); + +private: + cuda::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_; +}; + + +class CV_EXPORTS SphericalWarperGpu : public SphericalWarper +{ +public: + SphericalWarperGpu(float scale) : SphericalWarper(scale) {} + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, int interp_mode, int border_mode, + cuda::GpuMat & dst); + +private: + cuda::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_; +}; + + +class CV_EXPORTS CylindricalWarperGpu : public CylindricalWarper +{ +public: + CylindricalWarperGpu(float scale) : CylindricalWarper(scale) {} + + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE + { + Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_); + d_xmap_.download(xmap); + d_ymap_.download(ymap); + return result; + } + + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) CV_OVERRIDE + { + d_src_.upload(src); + Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_); + d_dst_.download(dst); + return result; + } + + Rect buildMaps(Size src_size, InputArray K, InputArray R, cuda::GpuMat & xmap, cuda::GpuMat & ymap); + + Point warp(const cuda::GpuMat & src, InputArray K, InputArray R, int interp_mode, int border_mode, + cuda::GpuMat & dst); + +private: + cuda::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_; +}; + + +struct CV_EXPORTS SphericalPortraitProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +// Projects image onto unit sphere with origin at (0, 0, 0). +// Poles are located NOT at (0, -1, 0) and (0, 1, 0) points, BUT at (1, 0, 0) and (-1, 0, 0) points. +class CV_EXPORTS SphericalPortraitWarper : public RotationWarperBase +{ +public: + SphericalPortraitWarper(float scale) { projector_.scale = scale; } + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE; +}; + +struct CV_EXPORTS CylindricalPortraitProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS CylindricalPortraitWarper : public RotationWarperBase +{ +public: + CylindricalPortraitWarper(float scale) { projector_.scale = scale; } + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE + { + RotationWarperBase::detectResultRoiByBorder(src_size, dst_tl, dst_br); + } +}; + +struct CV_EXPORTS PlanePortraitProjector : ProjectorBase +{ + void mapForward(float x, float y, float &u, float &v); + void mapBackward(float u, float v, float &x, float &y); +}; + + +class CV_EXPORTS PlanePortraitWarper : public RotationWarperBase +{ +public: + PlanePortraitWarper(float scale) { projector_.scale = scale; } + +protected: + void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE + { + RotationWarperBase::detectResultRoiByBorder(src_size, dst_tl, dst_br); + } +}; + +//! @} stitching_warp + +} // namespace detail +} // namespace cv + +#include "warpers_inl.hpp" + +#endif // OPENCV_STITCHING_WARPERS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/warpers_inl.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/warpers_inl.hpp new file mode 100644 index 0000000..72b5c08 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/detail/warpers_inl.hpp @@ -0,0 +1,782 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_WARPERS_INL_HPP +#define OPENCV_STITCHING_WARPERS_INL_HPP + +#include "opencv2/core.hpp" +#include "warpers.hpp" // Make your IDE see declarations +#include + +//! @cond IGNORED + +namespace cv { +namespace detail { + +template +Point2f RotationWarperBase

::warpPoint(const Point2f &pt, InputArray K, InputArray R) +{ + projector_.setCameraParams(K, R); + Point2f uv; + projector_.mapForward(pt.x, pt.y, uv.x, uv.y); + return uv; +} + +template +Point2f RotationWarperBase

::warpPointBackward(const Point2f& pt, InputArray K, InputArray R) +{ + projector_.setCameraParams(K, R); + Point2f xy; + projector_.mapBackward(pt.x, pt.y, xy.x, xy.y); + return xy; +} + +template +Rect RotationWarperBase

::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray _xmap, OutputArray _ymap) +{ + projector_.setCameraParams(K, R); + + Point dst_tl, dst_br; + detectResultRoi(src_size, dst_tl, dst_br); + + _xmap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); + _ymap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); + + Mat xmap = _xmap.getMat(), ymap = _ymap.getMat(); + + float x, y; + for (int v = dst_tl.y; v <= dst_br.y; ++v) + { + for (int u = dst_tl.x; u <= dst_br.x; ++u) + { + projector_.mapBackward(static_cast(u), static_cast(v), x, y); + xmap.at(v - dst_tl.y, u - dst_tl.x) = x; + ymap.at(v - dst_tl.y, u - dst_tl.x) = y; + } + } + + return Rect(dst_tl, dst_br); +} + + +template +Point RotationWarperBase

::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + OutputArray dst) +{ + UMat xmap, ymap; + Rect dst_roi = buildMaps(src.size(), K, R, xmap, ymap); + + dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); + remap(src, dst, xmap, ymap, interp_mode, border_mode); + + return dst_roi.tl(); +} + + +template +void RotationWarperBase

::warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, OutputArray dst) +{ + projector_.setCameraParams(K, R); + + Point src_tl, src_br; + detectResultRoi(dst_size, src_tl, src_br); + + Size size = src.size(); + CV_Assert(src_br.x - src_tl.x + 1 == size.width && src_br.y - src_tl.y + 1 == size.height); + + Mat xmap(dst_size, CV_32F); + Mat ymap(dst_size, CV_32F); + + float u, v; + for (int y = 0; y < dst_size.height; ++y) + { + for (int x = 0; x < dst_size.width; ++x) + { + projector_.mapForward(static_cast(x), static_cast(y), u, v); + xmap.at(y, x) = u - src_tl.x; + ymap.at(y, x) = v - src_tl.y; + } + } + + dst.create(dst_size, src.type()); + remap(src, dst, xmap, ymap, interp_mode, border_mode); +} + + +template +Rect RotationWarperBase

::warpRoi(Size src_size, InputArray K, InputArray R) +{ + projector_.setCameraParams(K, R); + + Point dst_tl, dst_br; + detectResultRoi(src_size, dst_tl, dst_br); + + return Rect(dst_tl, Point(dst_br.x + 1, dst_br.y + 1)); +} + + +template +void RotationWarperBase

::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) +{ + float tl_uf = (std::numeric_limits::max)(); + float tl_vf = (std::numeric_limits::max)(); + float br_uf = -(std::numeric_limits::max)(); + float br_vf = -(std::numeric_limits::max)(); + + float u, v; + for (int y = 0; y < src_size.height; ++y) + { + for (int x = 0; x < src_size.width; ++x) + { + projector_.mapForward(static_cast(x), static_cast(y), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + } + } + + dst_tl.x = static_cast(tl_uf); + dst_tl.y = static_cast(tl_vf); + dst_br.x = static_cast(br_uf); + dst_br.y = static_cast(br_vf); +} + + +template +void RotationWarperBase

::detectResultRoiByBorder(Size src_size, Point &dst_tl, Point &dst_br) +{ + float tl_uf = (std::numeric_limits::max)(); + float tl_vf = (std::numeric_limits::max)(); + float br_uf = -(std::numeric_limits::max)(); + float br_vf = -(std::numeric_limits::max)(); + + float u, v; + for (float x = 0; x < src_size.width; ++x) + { + projector_.mapForward(static_cast(x), 0, u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + + projector_.mapForward(static_cast(x), static_cast(src_size.height - 1), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + } + for (int y = 0; y < src_size.height; ++y) + { + projector_.mapForward(0, static_cast(y), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + + projector_.mapForward(static_cast(src_size.width - 1), static_cast(y), u, v); + tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v); + br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v); + } + + dst_tl.x = static_cast(tl_uf); + dst_tl.y = static_cast(tl_vf); + dst_br.x = static_cast(br_uf); + dst_br.y = static_cast(br_vf); +} + + +inline +void PlaneProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + x_ = t[0] + x_ / z_ * (1 - t[2]); + y_ = t[1] + y_ / z_ * (1 - t[2]); + + u = scale * x_; + v = scale * y_; +} + + +inline +void PlaneProjector::mapBackward(float u, float v, float &x, float &y) +{ + u = u / scale - t[0]; + v = v / scale - t[1]; + + float z; + x = k_rinv[0] * u + k_rinv[1] * v + k_rinv[2] * (1 - t[2]); + y = k_rinv[3] * u + k_rinv[4] * v + k_rinv[5] * (1 - t[2]); + z = k_rinv[6] * u + k_rinv[7] * v + k_rinv[8] * (1 - t[2]); + + x /= z; + y /= z; +} + + +inline +void SphericalProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + u = scale * atan2f(x_, z_); + float w = y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_); + v = scale * (static_cast(CV_PI) - acosf(w == w ? w : 0)); +} + + +inline +void SphericalProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float sinv = sinf(static_cast(CV_PI) - v); + float x_ = sinv * sinf(u); + float y_ = cosf(static_cast(CV_PI) - v); + float z_ = sinv * cosf(u); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + + +inline +void CylindricalProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + u = scale * atan2f(x_, z_); + v = scale * y_ / sqrtf(x_ * x_ + z_ * z_); +} + + +inline +void CylindricalProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float x_ = sinf(u); + float y_ = v; + float z_ = cosf(u); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void FisheyeProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = scale * v_ * cosf(u_); + v = scale * v_ * sinf(u_); +} + +inline +void FisheyeProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float u_ = atan2f(v, u); + float v_ = sqrtf(u*u + v*v); + + float sinv = sinf((float)CV_PI - v_); + float x_ = sinv * sinf(u_); + float y_ = cosf((float)CV_PI - v_); + float z_ = sinv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void StereographicProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = (float)CV_PI - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float r = sinf(v_) / (1 - cosf(v_)); + + u = scale * r * std::cos(u_); + v = scale * r * std::sin(u_); +} + +inline +void StereographicProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float u_ = atan2f(v, u); + float r = sqrtf(u*u + v*v); + float v_ = 2 * atanf(1.f / r); + + float sinv = sinf((float)CV_PI - v_); + float x_ = sinv * sinf(u_); + float y_ = cosf((float)CV_PI - v_); + float z_ = sinv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void CompressedRectilinearProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = scale * a * tanf(u_ / a); + v = scale * b * tanf(v_) / cosf(u_); +} + +inline +void CompressedRectilinearProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float aatg = a * atanf(u / a); + float u_ = aatg; + float v_ = atanf(v * cosf(aatg) / b); + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void CompressedRectilinearPortraitProjector::mapForward(float x, float y, float &u, float &v) +{ + float y_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float x_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = - scale * a * tanf(u_ / a); + v = scale * b * tanf(v_) / cosf(u_); +} + +inline +void CompressedRectilinearPortraitProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= - scale; + v /= scale; + + float aatg = a * atanf(u / a); + float u_ = aatg; + float v_ = atanf(v * cosf( aatg ) / b); + + float cosv = cosf(v_); + float y_ = cosv * sinf(u_); + float x_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void PaniniProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float tg = a * tanf(u_ / a); + u = scale * tg; + + float sinu = sinf(u_); + if ( fabs(sinu) < 1E-7 ) + v = scale * b * tanf(v_); + else + v = scale * b * tg * tanf(v_) / sinu; +} + +inline +void PaniniProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float lamda = a * atanf(u / a); + float u_ = lamda; + + float v_; + if ( fabs(lamda) > 1E-7) + v_ = atanf(v * sinf(lamda) / (b * a * tanf(lamda / a))); + else + v_ = atanf(v / b); + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void PaniniPortraitProjector::mapForward(float x, float y, float &u, float &v) +{ + float y_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float x_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float tg = a * tanf(u_ / a); + u = - scale * tg; + + float sinu = sinf( u_ ); + if ( fabs(sinu) < 1E-7 ) + v = scale * b * tanf(v_); + else + v = scale * b * tg * tanf(v_) / sinu; +} + +inline +void PaniniPortraitProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= - scale; + v /= scale; + + float lamda = a * atanf(u / a); + float u_ = lamda; + + float v_; + if ( fabs(lamda) > 1E-7) + v_ = atanf(v * sinf(lamda) / (b * a * tanf(lamda/a))); + else + v_ = atanf(v / b); + + float cosv = cosf(v_); + float y_ = cosv * sinf(u_); + float x_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void MercatorProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + u = scale * u_; + v = scale * logf( tanf( (float)(CV_PI/4) + v_/2 ) ); +} + +inline +void MercatorProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float v_ = atanf( sinhf(v) ); + float u_ = u; + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void TransverseMercatorProjector::mapForward(float x, float y, float &u, float &v) +{ + float x_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float u_ = atan2f(x_, z_); + float v_ = asinf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_)); + + float B = cosf(v_) * sinf(u_); + + u = scale / 2 * logf( (1+B) / (1-B) ); + v = scale * atan2f(tanf(v_), cosf(u_)); +} + +inline +void TransverseMercatorProjector::mapBackward(float u, float v, float &x, float &y) +{ + u /= scale; + v /= scale; + + float v_ = asinf( sinf(v) / coshf(u) ); + float u_ = atan2f( sinhf(u), std::cos(v) ); + + float cosv = cosf(v_); + float x_ = cosv * sinf(u_); + float y_ = sinf(v_); + float z_ = cosv * cosf(u_); + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void SphericalPortraitProjector::mapForward(float x, float y, float &u0, float &v0) +{ + float x0_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y0_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float x_ = y0_; + float y_ = x0_; + float u, v; + + u = scale * atan2f(x_, z_); + v = scale * (static_cast(CV_PI) - acosf(y_ / sqrtf(x_ * x_ + y_ * y_ + z_ * z_))); + + u0 = -u;//v; + v0 = v;//u; +} + + +inline +void SphericalPortraitProjector::mapBackward(float u0, float v0, float &x, float &y) +{ + float u, v; + u = -u0;//v0; + v = v0;//u0; + + u /= scale; + v /= scale; + + float sinv = sinf(static_cast(CV_PI) - v); + float x0_ = sinv * sinf(u); + float y0_ = cosf(static_cast(CV_PI) - v); + float z_ = sinv * cosf(u); + + float x_ = y0_; + float y_ = x0_; + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void CylindricalPortraitProjector::mapForward(float x, float y, float &u0, float &v0) +{ + float x0_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y0_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float x_ = y0_; + float y_ = x0_; + float u, v; + + u = scale * atan2f(x_, z_); + v = scale * y_ / sqrtf(x_ * x_ + z_ * z_); + + u0 = -u;//v; + v0 = v;//u; +} + + +inline +void CylindricalPortraitProjector::mapBackward(float u0, float v0, float &x, float &y) +{ + float u, v; + u = -u0;//v0; + v = v0;//u0; + + u /= scale; + v /= scale; + + float x0_ = sinf(u); + float y0_ = v; + float z_ = cosf(u); + + float x_ = y0_; + float y_ = x0_; + + float z; + x = k_rinv[0] * x_ + k_rinv[1] * y_ + k_rinv[2] * z_; + y = k_rinv[3] * x_ + k_rinv[4] * y_ + k_rinv[5] * z_; + z = k_rinv[6] * x_ + k_rinv[7] * y_ + k_rinv[8] * z_; + + if (z > 0) { x /= z; y /= z; } + else x = y = -1; +} + +inline +void PlanePortraitProjector::mapForward(float x, float y, float &u0, float &v0) +{ + float x0_ = r_kinv[0] * x + r_kinv[1] * y + r_kinv[2]; + float y0_ = r_kinv[3] * x + r_kinv[4] * y + r_kinv[5]; + float z_ = r_kinv[6] * x + r_kinv[7] * y + r_kinv[8]; + + float x_ = y0_; + float y_ = x0_; + + x_ = t[0] + x_ / z_ * (1 - t[2]); + y_ = t[1] + y_ / z_ * (1 - t[2]); + + float u,v; + u = scale * x_; + v = scale * y_; + + u0 = -u; + v0 = v; +} + + +inline +void PlanePortraitProjector::mapBackward(float u0, float v0, float &x, float &y) +{ + float u, v; + u = -u0; + v = v0; + + u = u / scale - t[0]; + v = v / scale - t[1]; + + float z; + x = k_rinv[0] * v + k_rinv[1] * u + k_rinv[2] * (1 - t[2]); + y = k_rinv[3] * v + k_rinv[4] * u + k_rinv[5] * (1 - t[2]); + z = k_rinv[6] * v + k_rinv[7] * u + k_rinv[8] * (1 - t[2]); + + x /= z; + y /= z; +} + + +} // namespace detail +} // namespace cv + +//! @endcond + +#endif // OPENCV_STITCHING_WARPERS_INL_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/warpers.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/warpers.hpp new file mode 100644 index 0000000..aa1ce5a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/stitching/warpers.hpp @@ -0,0 +1,277 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_STITCHING_WARPER_CREATORS_HPP +#define OPENCV_STITCHING_WARPER_CREATORS_HPP + +#include "opencv2/stitching/detail/warpers.hpp" +#include + +namespace cv { + class CV_EXPORTS_W PyRotationWarper + { + Ptr rw; + + public: + CV_WRAP PyRotationWarper(String type, float scale); + CV_WRAP PyRotationWarper() {}; + ~PyRotationWarper() {} + + /** @brief Projects the image point. + + @param pt Source point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected point + */ + CV_WRAP Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R); + + /** @brief Projects the image point backward. + + @param pt Projected point + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Backward-projected point + */ +#if CV_VERSION_MAJOR == 4 + CV_WRAP Point2f warpPointBackward(const Point2f& pt, InputArray K, InputArray R) + { + CV_UNUSED(pt); CV_UNUSED(K); CV_UNUSED(R); + CV_Error(Error::StsNotImplemented, ""); + } +#else + CV_WRAP Point2f warpPointBackward(const Point2f &pt, InputArray K, InputArray R); +#endif + /** @brief Builds the projection maps according to the given camera data. + + @param src_size Source image size + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param xmap Projection map for the x axis + @param ymap Projection map for the y axis + @return Projected image minimum bounding box + */ + CV_WRAP Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap); + + /** @brief Projects the image. + + @param src Source image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst Projected image + @return Project image top-left corner + */ + CV_WRAP Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + CV_OUT OutputArray dst); + + /** @brief Projects the image backward. + + @param src Projected image + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @param interp_mode Interpolation mode + @param border_mode Border extrapolation mode + @param dst_size Backward-projected image size + @param dst Backward-projected image + */ + CV_WRAP void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, + Size dst_size, CV_OUT OutputArray dst); + + /** + @param src_size Source image bounding box + @param K Camera intrinsic parameters + @param R Camera rotation matrix + @return Projected image minimum bounding box + */ + CV_WRAP Rect warpRoi(Size src_size, InputArray K, InputArray R); + + CV_WRAP float getScale() const { return 1.f; } + CV_WRAP void setScale(float) {} + }; + +//! @addtogroup stitching_warp +//! @{ + +/** @brief Image warper factories base class. + */ + +class CV_EXPORTS_W WarperCreator +{ +public: + CV_WRAP virtual ~WarperCreator() {} + virtual Ptr create(float scale) const = 0; +}; + + +/** @brief Plane warper factory class. + @sa detail::PlaneWarper + */ +class CV_EXPORTS PlaneWarper : public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +/** @brief Affine warper factory class. + @sa detail::AffineWarper + */ +class CV_EXPORTS AffineWarper : public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +/** @brief Cylindrical warper factory class. +@sa detail::CylindricalWarper +*/ +class CV_EXPORTS CylindricalWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +/** @brief Spherical warper factory class */ +class CV_EXPORTS SphericalWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS FisheyeWarper : public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS StereographicWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS CompressedRectilinearWarper: public WarperCreator +{ + float a, b; +public: + CompressedRectilinearWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS CompressedRectilinearPortraitWarper: public WarperCreator +{ + float a, b; +public: + CompressedRectilinearPortraitWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS PaniniWarper: public WarperCreator +{ + float a, b; +public: + PaniniWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS PaniniPortraitWarper: public WarperCreator +{ + float a, b; +public: + PaniniPortraitWarper(float A = 1, float B = 1) + { + a = A; b = B; + } + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale, a, b); } +}; + +class CV_EXPORTS MercatorWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + +class CV_EXPORTS TransverseMercatorWarper: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + + + +#ifdef HAVE_OPENCV_CUDAWARPING +class PlaneWarperGpu: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + + +class CylindricalWarperGpu: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; + + +class SphericalWarperGpu: public WarperCreator +{ +public: + Ptr create(float scale) const CV_OVERRIDE { return makePtr(scale); } +}; +#endif + +//! @} stitching_warp + +} // namespace cv + +#endif // OPENCV_STITCHING_WARPER_CREATORS_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/video.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/video.hpp new file mode 100644 index 0000000..a3dde60 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/video.hpp @@ -0,0 +1,59 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_VIDEO_HPP +#define OPENCV_VIDEO_HPP + +/** + @defgroup video Video Analysis + @{ + @defgroup video_motion Motion Analysis + @defgroup video_track Object Tracking + @defgroup video_c C API + @} +*/ + +#include "opencv2/video/tracking.hpp" +#include "opencv2/video/background_segm.hpp" + +#endif //OPENCV_VIDEO_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/video/background_segm.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/background_segm.hpp new file mode 100644 index 0000000..e1dfa15 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/background_segm.hpp @@ -0,0 +1,317 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_BACKGROUND_SEGM_HPP +#define OPENCV_BACKGROUND_SEGM_HPP + +#include "opencv2/core.hpp" + +namespace cv +{ + +//! @addtogroup video_motion +//! @{ + +/** @brief Base class for background/foreground segmentation. : + +The class is only used to define the common interface for the whole family of background/foreground +segmentation algorithms. + */ +class CV_EXPORTS_W BackgroundSubtractor : public Algorithm +{ +public: + /** @brief Computes a foreground mask. + + @param image Next video frame. + @param fgmask The output foreground mask as an 8-bit binary image. + @param learningRate The value between 0 and 1 that indicates how fast the background model is + learnt. Negative parameter value makes the algorithm to use some automatically chosen learning + rate. 0 means that the background model is not updated at all, 1 means that the background model + is completely reinitialized from the last frame. + */ + CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0; + + /** @brief Computes a background image. + + @param backgroundImage The output background image. + + @note Sometimes the background image can be very blurry, as it contain the average background + statistics. + */ + CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const = 0; +}; + + +/** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm. + +The class implements the Gaussian mixture model background subtraction described in @cite Zivkovic2004 +and @cite Zivkovic2006 . + */ +class CV_EXPORTS_W BackgroundSubtractorMOG2 : public BackgroundSubtractor +{ +public: + /** @brief Returns the number of last frames that affect the background model + */ + CV_WRAP virtual int getHistory() const = 0; + /** @brief Sets the number of last frames that affect the background model + */ + CV_WRAP virtual void setHistory(int history) = 0; + + /** @brief Returns the number of gaussian components in the background model + */ + CV_WRAP virtual int getNMixtures() const = 0; + /** @brief Sets the number of gaussian components in the background model. + + The model needs to be reinitalized to reserve memory. + */ + CV_WRAP virtual void setNMixtures(int nmixtures) = 0;//needs reinitialization! + + /** @brief Returns the "background ratio" parameter of the algorithm + + If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's + considered background and added to the model as a center of a new component. It corresponds to TB + parameter in the paper. + */ + CV_WRAP virtual double getBackgroundRatio() const = 0; + /** @brief Sets the "background ratio" parameter of the algorithm + */ + CV_WRAP virtual void setBackgroundRatio(double ratio) = 0; + + /** @brief Returns the variance threshold for the pixel-model match + + The main threshold on the squared Mahalanobis distance to decide if the sample is well described by + the background model or not. Related to Cthr from the paper. + */ + CV_WRAP virtual double getVarThreshold() const = 0; + /** @brief Sets the variance threshold for the pixel-model match + */ + CV_WRAP virtual void setVarThreshold(double varThreshold) = 0; + + /** @brief Returns the variance threshold for the pixel-model match used for new mixture component generation + + Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the + existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it + is considered foreground or added as a new component. 3 sigma =\> Tg=3\*3=9 is default. A smaller Tg + value generates more components. A higher Tg value may result in a small number of components but + they can grow too large. + */ + CV_WRAP virtual double getVarThresholdGen() const = 0; + /** @brief Sets the variance threshold for the pixel-model match used for new mixture component generation + */ + CV_WRAP virtual void setVarThresholdGen(double varThresholdGen) = 0; + + /** @brief Returns the initial variance of each gaussian component + */ + CV_WRAP virtual double getVarInit() const = 0; + /** @brief Sets the initial variance of each gaussian component + */ + CV_WRAP virtual void setVarInit(double varInit) = 0; + + CV_WRAP virtual double getVarMin() const = 0; + CV_WRAP virtual void setVarMin(double varMin) = 0; + + CV_WRAP virtual double getVarMax() const = 0; + CV_WRAP virtual void setVarMax(double varMax) = 0; + + /** @brief Returns the complexity reduction threshold + + This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 + is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the + standard Stauffer&Grimson algorithm. + */ + CV_WRAP virtual double getComplexityReductionThreshold() const = 0; + /** @brief Sets the complexity reduction threshold + */ + CV_WRAP virtual void setComplexityReductionThreshold(double ct) = 0; + + /** @brief Returns the shadow detection flag + + If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for + details. + */ + CV_WRAP virtual bool getDetectShadows() const = 0; + /** @brief Enables or disables shadow detection + */ + CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0; + + /** @brief Returns the shadow value + + Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 + in the mask always means background, 255 means foreground. + */ + CV_WRAP virtual int getShadowValue() const = 0; + /** @brief Sets the shadow value + */ + CV_WRAP virtual void setShadowValue(int value) = 0; + + /** @brief Returns the shadow threshold + + A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in + the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel + is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara, + *Detecting Moving Shadows...*, IEEE PAMI,2003. + */ + CV_WRAP virtual double getShadowThreshold() const = 0; + /** @brief Sets the shadow threshold + */ + CV_WRAP virtual void setShadowThreshold(double threshold) = 0; + + /** @brief Computes a foreground mask. + + @param image Next video frame. Floating point frame will be used without scaling and should be in range \f$[0,255]\f$. + @param fgmask The output foreground mask as an 8-bit binary image. + @param learningRate The value between 0 and 1 that indicates how fast the background model is + learnt. Negative parameter value makes the algorithm to use some automatically chosen learning + rate. 0 means that the background model is not updated at all, 1 means that the background model + is completely reinitialized from the last frame. + */ + CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0; +}; + +/** @brief Creates MOG2 Background Subtractor + +@param history Length of the history. +@param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model +to decide whether a pixel is well described by the background model. This parameter does not +affect the background update. +@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the +speed a bit, so if you do not need this feature, set the parameter to false. + */ +CV_EXPORTS_W Ptr + createBackgroundSubtractorMOG2(int history=500, double varThreshold=16, + bool detectShadows=true); + +/** @brief K-nearest neighbours - based Background/Foreground Segmentation Algorithm. + +The class implements the K-nearest neighbours background subtraction described in @cite Zivkovic2006 . +Very efficient if number of foreground pixels is low. + */ +class CV_EXPORTS_W BackgroundSubtractorKNN : public BackgroundSubtractor +{ +public: + /** @brief Returns the number of last frames that affect the background model + */ + CV_WRAP virtual int getHistory() const = 0; + /** @brief Sets the number of last frames that affect the background model + */ + CV_WRAP virtual void setHistory(int history) = 0; + + /** @brief Returns the number of data samples in the background model + */ + CV_WRAP virtual int getNSamples() const = 0; + /** @brief Sets the number of data samples in the background model. + + The model needs to be reinitalized to reserve memory. + */ + CV_WRAP virtual void setNSamples(int _nN) = 0;//needs reinitialization! + + /** @brief Returns the threshold on the squared distance between the pixel and the sample + + The threshold on the squared distance between the pixel and the sample to decide whether a pixel is + close to a data sample. + */ + CV_WRAP virtual double getDist2Threshold() const = 0; + /** @brief Sets the threshold on the squared distance + */ + CV_WRAP virtual void setDist2Threshold(double _dist2Threshold) = 0; + + /** @brief Returns the number of neighbours, the k in the kNN. + + K is the number of samples that need to be within dist2Threshold in order to decide that that + pixel is matching the kNN background model. + */ + CV_WRAP virtual int getkNNSamples() const = 0; + /** @brief Sets the k in the kNN. How many nearest neighbours need to match. + */ + CV_WRAP virtual void setkNNSamples(int _nkNN) = 0; + + /** @brief Returns the shadow detection flag + + If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for + details. + */ + CV_WRAP virtual bool getDetectShadows() const = 0; + /** @brief Enables or disables shadow detection + */ + CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0; + + /** @brief Returns the shadow value + + Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 + in the mask always means background, 255 means foreground. + */ + CV_WRAP virtual int getShadowValue() const = 0; + /** @brief Sets the shadow value + */ + CV_WRAP virtual void setShadowValue(int value) = 0; + + /** @brief Returns the shadow threshold + + A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in + the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel + is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara, + *Detecting Moving Shadows...*, IEEE PAMI,2003. + */ + CV_WRAP virtual double getShadowThreshold() const = 0; + /** @brief Sets the shadow threshold + */ + CV_WRAP virtual void setShadowThreshold(double threshold) = 0; +}; + +/** @brief Creates KNN Background Subtractor + +@param history Length of the history. +@param dist2Threshold Threshold on the squared distance between the pixel and the sample to decide +whether a pixel is close to that sample. This parameter does not affect the background update. +@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the +speed a bit, so if you do not need this feature, set the parameter to false. + */ +CV_EXPORTS_W Ptr + createBackgroundSubtractorKNN(int history=500, double dist2Threshold=400.0, + bool detectShadows=true); + +//! @} video_motion + +} // cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/video/detail/tracking.detail.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/detail/tracking.detail.hpp new file mode 100644 index 0000000..1e61079 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/detail/tracking.detail.hpp @@ -0,0 +1,406 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEO_DETAIL_TRACKING_HPP +#define OPENCV_VIDEO_DETAIL_TRACKING_HPP + +/* + * Partially based on: + * ==================================================================================================================== + * - [AAM] S. Salti, A. Cavallaro, L. Di Stefano, Adaptive Appearance Modeling for Video Tracking: Survey and Evaluation + * - [AMVOT] X. Li, W. Hu, C. Shen, Z. Zhang, A. Dick, A. van den Hengel, A Survey of Appearance Models in Visual Object Tracking + * + * This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/doc/uml + * + */ + +#include "opencv2/core.hpp" + +namespace cv { +namespace detail { +inline namespace tracking { + +/** @addtogroup tracking_detail +@{ +*/ + +/************************************ TrackerFeature Base Classes ************************************/ + +/** @brief Abstract base class for TrackerFeature that represents the feature. +*/ +class CV_EXPORTS TrackerFeature +{ +public: + virtual ~TrackerFeature(); + + /** @brief Compute the features in the images collection + @param images The images + @param response The output response + */ + void compute(const std::vector& images, Mat& response); + +protected: + virtual bool computeImpl(const std::vector& images, Mat& response) = 0; +}; + +/** @brief Class that manages the extraction and selection of features + +@cite AAM Feature Extraction and Feature Set Refinement (Feature Processing and Feature Selection). +See table I and section III C @cite AMVOT Appearance modelling -\> Visual representation (Table II, +section 3.1 - 3.2) + +TrackerFeatureSet is an aggregation of TrackerFeature + +@sa + TrackerFeature + +*/ +class CV_EXPORTS TrackerFeatureSet +{ +public: + TrackerFeatureSet(); + + ~TrackerFeatureSet(); + + /** @brief Extract features from the images collection + @param images The input images + */ + void extraction(const std::vector& images); + + /** @brief Add TrackerFeature in the collection. Return true if TrackerFeature is added, false otherwise + @param feature The TrackerFeature class + */ + bool addTrackerFeature(const Ptr& feature); + + /** @brief Get the TrackerFeature collection (TrackerFeature name, TrackerFeature pointer) + */ + const std::vector>& getTrackerFeatures() const; + + /** @brief Get the responses + @note Be sure to call extraction before getResponses Example TrackerFeatureSet::getResponses + */ + const std::vector& getResponses() const; + +private: + void clearResponses(); + bool blockAddTrackerFeature; + + std::vector> features; // list of features + std::vector responses; // list of response after compute +}; + +/************************************ TrackerSampler Base Classes ************************************/ + +/** @brief Abstract base class for TrackerSamplerAlgorithm that represents the algorithm for the specific +sampler. +*/ +class CV_EXPORTS TrackerSamplerAlgorithm +{ +public: + virtual ~TrackerSamplerAlgorithm(); + + /** @brief Computes the regions starting from a position in an image. + + Return true if samples are computed, false otherwise + + @param image The current frame + @param boundingBox The bounding box from which regions can be calculated + + @param sample The computed samples @cite AAM Fig. 1 variable Sk + */ + virtual bool sampling(const Mat& image, const Rect& boundingBox, std::vector& sample) = 0; +}; + +/** + * \brief Class that manages the sampler in order to select regions for the update the model of the tracker + * [AAM] Sampling e Labeling. See table I and section III B + */ + +/** @brief Class that manages the sampler in order to select regions for the update the model of the tracker + +@cite AAM Sampling e Labeling. See table I and section III B + +TrackerSampler is an aggregation of TrackerSamplerAlgorithm +@sa + TrackerSamplerAlgorithm + */ +class CV_EXPORTS TrackerSampler +{ +public: + TrackerSampler(); + + ~TrackerSampler(); + + /** @brief Computes the regions starting from a position in an image + @param image The current frame + @param boundingBox The bounding box from which regions can be calculated + */ + void sampling(const Mat& image, Rect boundingBox); + + /** @brief Return the collection of the TrackerSamplerAlgorithm + */ + const std::vector>& getSamplers() const; + + /** @brief Return the samples from all TrackerSamplerAlgorithm, @cite AAM Fig. 1 variable Sk + */ + const std::vector& getSamples() const; + + /** @brief Add TrackerSamplerAlgorithm in the collection. Return true if sampler is added, false otherwise + @param sampler The TrackerSamplerAlgorithm + */ + bool addTrackerSamplerAlgorithm(const Ptr& sampler); + +private: + std::vector> samplers; + std::vector samples; + bool blockAddTrackerSampler; + + void clearSamples(); +}; + +/************************************ TrackerModel Base Classes ************************************/ + +/** @brief Abstract base class for TrackerTargetState that represents a possible state of the target. + +See @cite AAM \f$\hat{x}^{i}_{k}\f$ all the states candidates. + +Inherits this class with your Target state, In own implementation you can add scale variation, +width, height, orientation, etc. +*/ +class CV_EXPORTS TrackerTargetState +{ +public: + virtual ~TrackerTargetState() {}; + /** @brief Get the position + * @return The position + */ + Point2f getTargetPosition() const; + + /** @brief Set the position + * @param position The position + */ + void setTargetPosition(const Point2f& position); + /** @brief Get the width of the target + * @return The width of the target + */ + int getTargetWidth() const; + + /** @brief Set the width of the target + * @param width The width of the target + */ + void setTargetWidth(int width); + /** @brief Get the height of the target + * @return The height of the target + */ + int getTargetHeight() const; + + /** @brief Set the height of the target + * @param height The height of the target + */ + void setTargetHeight(int height); + +protected: + Point2f targetPosition; + int targetWidth; + int targetHeight; +}; + +/** @brief Represents the model of the target at frame \f$k\f$ (all states and scores) + +See @cite AAM The set of the pair \f$\langle \hat{x}^{i}_{k}, C^{i}_{k} \rangle\f$ +@sa TrackerTargetState +*/ +typedef std::vector, float>> ConfidenceMap; + +/** @brief Represents the estimate states for all frames + +@cite AAM \f$x_{k}\f$ is the trajectory of the target up to time \f$k\f$ + +@sa TrackerTargetState +*/ +typedef std::vector> Trajectory; + +/** @brief Abstract base class for TrackerStateEstimator that estimates the most likely target state. + +See @cite AAM State estimator + +See @cite AMVOT Statistical modeling (Fig. 3), Table III (generative) - IV (discriminative) - V (hybrid) +*/ +class CV_EXPORTS TrackerStateEstimator +{ +public: + virtual ~TrackerStateEstimator(); + + /** @brief Estimate the most likely target state, return the estimated state + @param confidenceMaps The overall appearance model as a list of :cConfidenceMap + */ + Ptr estimate(const std::vector& confidenceMaps); + + /** @brief Update the ConfidenceMap with the scores + @param confidenceMaps The overall appearance model as a list of :cConfidenceMap + */ + void update(std::vector& confidenceMaps); + + /** @brief Create TrackerStateEstimator by tracker state estimator type + @param trackeStateEstimatorType The TrackerStateEstimator name + + The modes available now: + + - "BOOSTING" -- Boosting-based discriminative appearance models. See @cite AMVOT section 4.4 + + The modes available soon: + + - "SVM" -- SVM-based discriminative appearance models. See @cite AMVOT section 4.5 + */ + static Ptr create(const String& trackeStateEstimatorType); + + /** @brief Get the name of the specific TrackerStateEstimator + */ + String getClassName() const; + +protected: + virtual Ptr estimateImpl(const std::vector& confidenceMaps) = 0; + virtual void updateImpl(std::vector& confidenceMaps) = 0; + String className; +}; + +/** @brief Abstract class that represents the model of the target. + +It must be instantiated by specialized tracker + +See @cite AAM Ak + +Inherits this with your TrackerModel +*/ +class CV_EXPORTS TrackerModel +{ +public: + TrackerModel(); + + virtual ~TrackerModel(); + + /** @brief Set TrackerEstimator, return true if the tracker state estimator is added, false otherwise + @param trackerStateEstimator The TrackerStateEstimator + @note You can add only one TrackerStateEstimator + */ + bool setTrackerStateEstimator(Ptr trackerStateEstimator); + + /** @brief Estimate the most likely target location + + @cite AAM ME, Model Estimation table I + @param responses Features extracted from TrackerFeatureSet + */ + void modelEstimation(const std::vector& responses); + + /** @brief Update the model + + @cite AAM MU, Model Update table I + */ + void modelUpdate(); + + /** @brief Run the TrackerStateEstimator, return true if is possible to estimate a new state, false otherwise + */ + bool runStateEstimator(); + + /** @brief Set the current TrackerTargetState in the Trajectory + @param lastTargetState The current TrackerTargetState + */ + void setLastTargetState(const Ptr& lastTargetState); + + /** @brief Get the last TrackerTargetState from Trajectory + */ + Ptr getLastTargetState() const; + + /** @brief Get the list of the ConfidenceMap + */ + const std::vector& getConfidenceMaps() const; + + /** @brief Get the last ConfidenceMap for the current frame + */ + const ConfidenceMap& getLastConfidenceMap() const; + + /** @brief Get the TrackerStateEstimator + */ + Ptr getTrackerStateEstimator() const; + +private: + void clearCurrentConfidenceMap(); + +protected: + std::vector confidenceMaps; + Ptr stateEstimator; + ConfidenceMap currentConfidenceMap; + Trajectory trajectory; + int maxCMLength; + + virtual void modelEstimationImpl(const std::vector& responses) = 0; + virtual void modelUpdateImpl() = 0; +}; + +/************************************ Specific TrackerStateEstimator Classes ************************************/ + +// None + +/************************************ Specific TrackerSamplerAlgorithm Classes ************************************/ + +/** @brief TrackerSampler based on CSC (current state centered), used by MIL algorithm TrackerMIL + */ +class CV_EXPORTS TrackerSamplerCSC : public TrackerSamplerAlgorithm +{ +public: + ~TrackerSamplerCSC(); + + enum MODE + { + MODE_INIT_POS = 1, //!< mode for init positive samples + MODE_INIT_NEG = 2, //!< mode for init negative samples + MODE_TRACK_POS = 3, //!< mode for update positive samples + MODE_TRACK_NEG = 4, //!< mode for update negative samples + MODE_DETECT = 5 //!< mode for detect samples + }; + + struct CV_EXPORTS Params + { + Params(); + float initInRad; //!< radius for gathering positive instances during init + float trackInPosRad; //!< radius for gathering positive instances during tracking + float searchWinSize; //!< size of search window + int initMaxNegNum; //!< # negative samples to use during init + int trackMaxPosNum; //!< # positive samples to use during training + int trackMaxNegNum; //!< # negative samples to use during training + }; + + /** @brief Constructor + @param parameters TrackerSamplerCSC parameters TrackerSamplerCSC::Params + */ + TrackerSamplerCSC(const TrackerSamplerCSC::Params& parameters = TrackerSamplerCSC::Params()); + + /** @brief Set the sampling mode of TrackerSamplerCSC + @param samplingMode The sampling mode + + The modes are: + + - "MODE_INIT_POS = 1" -- for the positive sampling in initialization step + - "MODE_INIT_NEG = 2" -- for the negative sampling in initialization step + - "MODE_TRACK_POS = 3" -- for the positive sampling in update step + - "MODE_TRACK_NEG = 4" -- for the negative sampling in update step + - "MODE_DETECT = 5" -- for the sampling in detection step + */ + void setMode(int samplingMode); + + bool sampling(const Mat& image, const Rect& boundingBox, std::vector& sample) CV_OVERRIDE; + +private: + Params params; + int mode; + RNG rng; + + std::vector sampleImage(const Mat& img, int x, int y, int w, int h, float inrad, float outrad = 0, int maxnum = 1000000); +}; + +//! @} + +}}} // namespace cv::detail::tracking + +#endif // OPENCV_VIDEO_DETAIL_TRACKING_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/video/legacy/constants_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/legacy/constants_c.h new file mode 100644 index 0000000..1a98f52 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/legacy/constants_c.h @@ -0,0 +1,16 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEO_LEGACY_CONSTANTS_H +#define OPENCV_VIDEO_LEGACY_CONSTANTS_H + +enum +{ + CV_LKFLOW_PYR_A_READY = 1, + CV_LKFLOW_PYR_B_READY = 2, + CV_LKFLOW_INITIAL_GUESSES = 4, + CV_LKFLOW_GET_MIN_EIGENVALS = 8 +}; + +#endif // OPENCV_VIDEO_LEGACY_CONSTANTS_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/video/tracking.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/tracking.hpp new file mode 100644 index 0000000..7ec6bc5 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/tracking.hpp @@ -0,0 +1,857 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_TRACKING_HPP +#define OPENCV_TRACKING_HPP + +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" + +namespace cv +{ + +//! @addtogroup video_track +//! @{ + +enum { OPTFLOW_USE_INITIAL_FLOW = 4, + OPTFLOW_LK_GET_MIN_EIGENVALS = 8, + OPTFLOW_FARNEBACK_GAUSSIAN = 256 + }; + +/** @brief Finds an object center, size, and orientation. + +@param probImage Back projection of the object histogram. See calcBackProject. +@param window Initial search window. +@param criteria Stop criteria for the underlying meanShift. +returns +(in old interfaces) Number of iterations CAMSHIFT took to converge +The function implements the CAMSHIFT object tracking algorithm @cite Bradski98 . First, it finds an +object center using meanShift and then adjusts the window size and finds the optimal rotation. The +function returns the rotated rectangle structure that includes the object position, size, and +orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() + +See the OpenCV sample camshiftdemo.c that tracks colored objects. + +@note +- (Python) A sample explaining the camshift tracking algorithm can be found at + opencv_source_code/samples/python/camshift.py + */ +CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window, + TermCriteria criteria ); +/** @example samples/cpp/camshiftdemo.cpp +An example using the mean-shift tracking algorithm +*/ + +/** @brief Finds an object on a back projection image. + +@param probImage Back projection of the object histogram. See calcBackProject for details. +@param window Initial search window. +@param criteria Stop criteria for the iterative search algorithm. +returns +: Number of iterations CAMSHIFT took to converge. +The function implements the iterative object search algorithm. It takes the input back projection of +an object and the initial position. The mass center in window of the back projection image is +computed and the search window center shifts to the mass center. The procedure is repeated until the +specified number of iterations criteria.maxCount is done or until the window center shifts by less +than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search +window size or orientation do not change during the search. You can simply pass the output of +calcBackProject to this function. But better results can be obtained if you pre-filter the back +projection and remove the noise. For example, you can do this by retrieving connected components +with findContours , throwing away contours with small area ( contourArea ), and rendering the +remaining contours with drawContours. + + */ +CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria ); + +/** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK. + +@param img 8-bit input image. +@param pyramid output pyramid. +@param winSize window size of optical flow algorithm. Must be not less than winSize argument of +calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels. +@param maxLevel 0-based maximal pyramid level number. +@param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is +constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally. +@param pyrBorder the border mode for pyramid layers. +@param derivBorder the border mode for gradients. +@param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false +to force data copying. +@return number of levels in constructed pyramid. Can be less than maxLevel. + */ +CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays pyramid, + Size winSize, int maxLevel, bool withDerivatives = true, + int pyrBorder = BORDER_REFLECT_101, + int derivBorder = BORDER_CONSTANT, + bool tryReuseInputImage = true ); + +/** @example samples/cpp/lkdemo.cpp +An example using the Lucas-Kanade optical flow algorithm +*/ + +/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with +pyramids. + +@param prevImg first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid. +@param nextImg second input image or pyramid of the same size and the same type as prevImg. +@param prevPts vector of 2D points for which the flow needs to be found; point coordinates must be +single-precision floating-point numbers. +@param nextPts output vector of 2D points (with single-precision floating-point coordinates) +containing the calculated new positions of input features in the second image; when +OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input. +@param status output status vector (of unsigned chars); each element of the vector is set to 1 if +the flow for the corresponding features has been found, otherwise, it is set to 0. +@param err output vector of errors; each element of the vector is set to an error for the +corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't +found then the error is not defined (use the status parameter to find such cases). +@param winSize size of the search window at each pyramid level. +@param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single +level), if set to 1, two levels are used, and so on; if pyramids are passed to input then +algorithm will use as many levels as pyramids have but no more than maxLevel. +@param criteria parameter, specifying the termination criteria of the iterative search algorithm +(after the specified maximum number of iterations criteria.maxCount or when the search window +moves by less than criteria.epsilon. +@param flags operation flags: + - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is + not set, then prevPts is copied to nextPts and is considered the initial estimate. + - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see + minEigThreshold description); if the flag is not set, then L1 distance between patches + around the original and a moved point, divided by number of pixels in a window, is used as a + error measure. +@param minEigThreshold the algorithm calculates the minimum eigen value of a 2x2 normal matrix of +optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided +by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding +feature is filtered out and its flow is not processed, so it allows to remove bad points and get a +performance boost. + +The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See +@cite Bouguet00 . The function is parallelized with the TBB library. + +@note + +- An example using the Lucas-Kanade optical flow algorithm can be found at + opencv_source_code/samples/cpp/lkdemo.cpp +- (Python) An example using the Lucas-Kanade optical flow algorithm can be found at + opencv_source_code/samples/python/lk_track.py +- (Python) An example using the Lucas-Kanade tracker for homography matching can be found at + opencv_source_code/samples/python/lk_homography.py + */ +CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, + InputArray prevPts, InputOutputArray nextPts, + OutputArray status, OutputArray err, + Size winSize = Size(21,21), int maxLevel = 3, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), + int flags = 0, double minEigThreshold = 1e-4 ); + +/** @brief Computes a dense optical flow using the Gunnar Farneback's algorithm. + +@param prev first 8-bit single-channel input image. +@param next second input image of the same size and the same type as prev. +@param flow computed flow image that has the same size as prev and type CV_32FC2. +@param pyr_scale parameter, specifying the image scale (\<1) to build pyramids for each image; +pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous +one. +@param levels number of pyramid layers including the initial image; levels=1 means that no extra +layers are created and only the original images are used. +@param winsize averaging window size; larger values increase the algorithm robustness to image +noise and give more chances for fast motion detection, but yield more blurred motion field. +@param iterations number of iterations the algorithm does at each pyramid level. +@param poly_n size of the pixel neighborhood used to find polynomial expansion in each pixel; +larger values mean that the image will be approximated with smoother surfaces, yielding more +robust algorithm and more blurred motion field, typically poly_n =5 or 7. +@param poly_sigma standard deviation of the Gaussian that is used to smooth derivatives used as a +basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a +good value would be poly_sigma=1.5. +@param flags operation flags that can be a combination of the following: + - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation. + - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian \f$\texttt{winsize}\times\texttt{winsize}\f$ + filter instead of a box filter of the same size for optical flow estimation; usually, this + option gives z more accurate flow than with a box filter, at the cost of lower speed; + normally, winsize for a Gaussian window should be set to a larger value to achieve the same + level of robustness. + +The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that + +\f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f] + +@note + +- An example using the optical flow algorithm described by Gunnar Farneback can be found at + opencv_source_code/samples/cpp/fback.cpp +- (Python) An example using the optical flow algorithm described by Gunnar Farneback can be + found at opencv_source_code/samples/python/opt_flow.py + */ +CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow, + double pyr_scale, int levels, int winsize, + int iterations, int poly_n, double poly_sigma, + int flags ); + +/** @brief Computes an optimal affine transformation between two 2D point sets. + +@param src First input 2D point set stored in std::vector or Mat, or an image stored in Mat. +@param dst Second input 2D point set of the same size and the same type as A, or another image. +@param fullAffine If true, the function finds an optimal affine transformation with no additional +restrictions (6 degrees of freedom). Otherwise, the class of transformations to choose from is +limited to combinations of translation, rotation, and uniform scaling (4 degrees of freedom). + +The function finds an optimal affine transform *[A|b]* (a 2 x 3 floating-point matrix) that +approximates best the affine transformation between: + +* Two point sets +* Two raster images. In this case, the function first finds some features in the src image and + finds the corresponding features in dst image. After that, the problem is reduced to the first + case. +In case of point sets, the problem is formulated as follows: you need to find a 2x2 matrix *A* and +2x1 vector *b* so that: + +\f[[A^*|b^*] = arg \min _{[A|b]} \sum _i \| \texttt{dst}[i] - A { \texttt{src}[i]}^T - b \| ^2\f] +where src[i] and dst[i] are the i-th points in src and dst, respectively +\f$[A|b]\f$ can be either arbitrary (when fullAffine=true ) or have a form of +\f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ -a_{12} & a_{11} & b_2 \end{bmatrix}\f] +when fullAffine=false. + +@deprecated Use cv::estimateAffine2D, cv::estimateAffinePartial2D instead. If you are using this function +with images, extract points using cv::calcOpticalFlowPyrLK and then use the estimation functions. + +@sa +estimateAffine2D, estimateAffinePartial2D, getAffineTransform, getPerspectiveTransform, findHomography + */ +CV_DEPRECATED CV_EXPORTS Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine ); + +enum +{ + MOTION_TRANSLATION = 0, + MOTION_EUCLIDEAN = 1, + MOTION_AFFINE = 2, + MOTION_HOMOGRAPHY = 3 +}; + +/** @brief Computes the Enhanced Correlation Coefficient value between two images @cite EP08 . + +@param templateImage single-channel template image; CV_8U or CV_32F array. +@param inputImage single-channel input image to be warped to provide an image similar to + templateImage, same type as templateImage. +@param inputMask An optional mask to indicate valid values of inputImage. + +@sa +findTransformECC + */ + +CV_EXPORTS_W double computeECC(InputArray templateImage, InputArray inputImage, InputArray inputMask = noArray()); + +/** @example samples/cpp/image_alignment.cpp +An example using the image alignment ECC algorithm +*/ + +/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 . + +@param templateImage single-channel template image; CV_8U or CV_32F array. +@param inputImage single-channel input image which should be warped with the final warpMatrix in +order to provide an image similar to templateImage, same type as templateImage. +@param warpMatrix floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp). +@param motionType parameter, specifying the type of motion: + - **MOTION_TRANSLATION** sets a translational motion model; warpMatrix is \f$2\times 3\f$ with + the first \f$2\times 2\f$ part being the unity matrix and the rest two parameters being + estimated. + - **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three + parameters are estimated; warpMatrix is \f$2\times 3\f$. + - **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated; + warpMatrix is \f$2\times 3\f$. + - **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are + estimated;\`warpMatrix\` is \f$3\times 3\f$. +@param criteria parameter, specifying the termination criteria of the ECC algorithm; +criteria.epsilon defines the threshold of the increment in the correlation coefficient between two +iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion). +Default values are shown in the declaration above. +@param inputMask An optional mask to indicate valid values of inputImage. +@param gaussFiltSize An optional value indicating size of gaussian blur filter; (DEFAULT: 5) + +The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion +(@cite EP08), that is + +\f[\texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\f] + +where + +\f[\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\f] + +(the equation holds with homogeneous coordinates for homography). It returns the final enhanced +correlation coefficient, that is the correlation coefficient between the template image and the +final warped input image. When a \f$3\times 3\f$ matrix is given with motionType =0, 1 or 2, the third +row is ignored. + +Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an +area-based alignment that builds on intensity similarities. In essence, the function updates the +initial transformation that roughly aligns the images. If this information is missing, the identity +warp (unity matrix) is used as an initialization. Note that if images undergo strong +displacements/rotations, an initial transformation that roughly aligns the images is necessary +(e.g., a simple euclidean/similarity transform that allows for the images showing the same image +content approximately). Use inverse warping in the second image to take an image close to the first +one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV +sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws +an exception if algorithm does not converges. + +@sa +computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography + */ +CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray inputImage, + InputOutputArray warpMatrix, int motionType, + TermCriteria criteria, + InputArray inputMask, int gaussFiltSize); + +/** @overload */ +CV_EXPORTS_W +double findTransformECC(InputArray templateImage, InputArray inputImage, + InputOutputArray warpMatrix, int motionType = MOTION_AFFINE, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001), + InputArray inputMask = noArray()); + +/** @example samples/cpp/kalman.cpp +An example using the standard Kalman filter +*/ + +/** @brief Kalman filter class. + +The class implements a standard Kalman filter , +@cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get +an extended Kalman filter functionality. +@note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released +with cvReleaseKalman(&kalmanFilter) + */ +class CV_EXPORTS_W KalmanFilter +{ +public: + CV_WRAP KalmanFilter(); + /** @overload + @param dynamParams Dimensionality of the state. + @param measureParams Dimensionality of the measurement. + @param controlParams Dimensionality of the control vector. + @param type Type of the created matrices that should be CV_32F or CV_64F. + */ + CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); + + /** @brief Re-initializes Kalman filter. The previous content is destroyed. + + @param dynamParams Dimensionality of the state. + @param measureParams Dimensionality of the measurement. + @param controlParams Dimensionality of the control vector. + @param type Type of the created matrices that should be CV_32F or CV_64F. + */ + void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); + + /** @brief Computes a predicted state. + + @param control The optional input control + */ + CV_WRAP const Mat& predict( const Mat& control = Mat() ); + + /** @brief Updates the predicted state from the measurement. + + @param measurement The measured system parameters + */ + CV_WRAP const Mat& correct( const Mat& measurement ); + + CV_PROP_RW Mat statePre; //!< predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k) + CV_PROP_RW Mat statePost; //!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) + CV_PROP_RW Mat transitionMatrix; //!< state transition matrix (A) + CV_PROP_RW Mat controlMatrix; //!< control matrix (B) (not used if there is no control) + CV_PROP_RW Mat measurementMatrix; //!< measurement matrix (H) + CV_PROP_RW Mat processNoiseCov; //!< process noise covariance matrix (Q) + CV_PROP_RW Mat measurementNoiseCov;//!< measurement noise covariance matrix (R) + CV_PROP_RW Mat errorCovPre; //!< priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/ + CV_PROP_RW Mat gain; //!< Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R) + CV_PROP_RW Mat errorCovPost; //!< posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) + + // temporary matrices + Mat temp1; + Mat temp2; + Mat temp3; + Mat temp4; + Mat temp5; +}; + + +/** @brief Read a .flo file + + @param path Path to the file to be loaded + + The function readOpticalFlow loads a flow field from a file and returns it as a single matrix. + Resulting Mat has a type CV_32FC2 - floating-point, 2-channel. First channel corresponds to the + flow in the horizontal direction (u), second - vertical (v). + */ +CV_EXPORTS_W Mat readOpticalFlow( const String& path ); +/** @brief Write a .flo to disk + + @param path Path to the file to be written + @param flow Flow field to be stored + + The function stores a flow field in a file, returns true on success, false otherwise. + The flow field must be a 2-channel, floating-point matrix (CV_32FC2). First channel corresponds + to the flow in the horizontal direction (u), second - vertical (v). + */ +CV_EXPORTS_W bool writeOpticalFlow( const String& path, InputArray flow ); + +/** + Base class for dense optical flow algorithms +*/ +class CV_EXPORTS_W DenseOpticalFlow : public Algorithm +{ +public: + /** @brief Calculates an optical flow. + + @param I0 first 8-bit single-channel input image. + @param I1 second input image of the same size and the same type as prev. + @param flow computed flow image that has the same size as prev and type CV_32FC2. + */ + CV_WRAP virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; + /** @brief Releases all inner buffers. + */ + CV_WRAP virtual void collectGarbage() = 0; +}; + +/** @brief Base interface for sparse optical flow algorithms. + */ +class CV_EXPORTS_W SparseOpticalFlow : public Algorithm +{ +public: + /** @brief Calculates a sparse optical flow. + + @param prevImg First input image. + @param nextImg Second input image of the same size and the same type as prevImg. + @param prevPts Vector of 2D points for which the flow needs to be found. + @param nextPts Output vector of 2D points containing the calculated new positions of input features in the second image. + @param status Output status vector. Each element of the vector is set to 1 if the + flow for the corresponding features has been found. Otherwise, it is set to 0. + @param err Optional output vector that contains error response for each point (inverse confidence). + */ + CV_WRAP virtual void calc(InputArray prevImg, InputArray nextImg, + InputArray prevPts, InputOutputArray nextPts, + OutputArray status, + OutputArray err = cv::noArray()) = 0; +}; + + +/** @brief Class computing a dense optical flow using the Gunnar Farneback's algorithm. + */ +class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow +{ +public: + CV_WRAP virtual int getNumLevels() const = 0; + CV_WRAP virtual void setNumLevels(int numLevels) = 0; + + CV_WRAP virtual double getPyrScale() const = 0; + CV_WRAP virtual void setPyrScale(double pyrScale) = 0; + + CV_WRAP virtual bool getFastPyramids() const = 0; + CV_WRAP virtual void setFastPyramids(bool fastPyramids) = 0; + + CV_WRAP virtual int getWinSize() const = 0; + CV_WRAP virtual void setWinSize(int winSize) = 0; + + CV_WRAP virtual int getNumIters() const = 0; + CV_WRAP virtual void setNumIters(int numIters) = 0; + + CV_WRAP virtual int getPolyN() const = 0; + CV_WRAP virtual void setPolyN(int polyN) = 0; + + CV_WRAP virtual double getPolySigma() const = 0; + CV_WRAP virtual void setPolySigma(double polySigma) = 0; + + CV_WRAP virtual int getFlags() const = 0; + CV_WRAP virtual void setFlags(int flags) = 0; + + CV_WRAP static Ptr create( + int numLevels = 5, + double pyrScale = 0.5, + bool fastPyramids = false, + int winSize = 13, + int numIters = 10, + int polyN = 5, + double polySigma = 1.1, + int flags = 0); +}; + +/** @brief Variational optical flow refinement + +This class implements variational refinement of the input flow field, i.e. +it uses input flow to initialize the minimization of the following functional: +\f$E(U) = \int_{\Omega} \delta \Psi(E_I) + \gamma \Psi(E_G) + \alpha \Psi(E_S) \f$, +where \f$E_I,E_G,E_S\f$ are color constancy, gradient constancy and smoothness terms +respectively. \f$\Psi(s^2)=\sqrt{s^2+\epsilon^2}\f$ is a robust penalizer to limit the +influence of outliers. A complete formulation and a description of the minimization +procedure can be found in @cite Brox2004 +*/ +class CV_EXPORTS_W VariationalRefinement : public DenseOpticalFlow +{ +public: + /** @brief @ref calc function overload to handle separate horizontal (u) and vertical (v) flow components + (to avoid extra splits/merges) */ + CV_WRAP virtual void calcUV(InputArray I0, InputArray I1, InputOutputArray flow_u, InputOutputArray flow_v) = 0; + + /** @brief Number of outer (fixed-point) iterations in the minimization procedure. + @see setFixedPointIterations */ + CV_WRAP virtual int getFixedPointIterations() const = 0; + /** @copybrief getFixedPointIterations @see getFixedPointIterations */ + CV_WRAP virtual void setFixedPointIterations(int val) = 0; + + /** @brief Number of inner successive over-relaxation (SOR) iterations + in the minimization procedure to solve the respective linear system. + @see setSorIterations */ + CV_WRAP virtual int getSorIterations() const = 0; + /** @copybrief getSorIterations @see getSorIterations */ + CV_WRAP virtual void setSorIterations(int val) = 0; + + /** @brief Relaxation factor in SOR + @see setOmega */ + CV_WRAP virtual float getOmega() const = 0; + /** @copybrief getOmega @see getOmega */ + CV_WRAP virtual void setOmega(float val) = 0; + + /** @brief Weight of the smoothness term + @see setAlpha */ + CV_WRAP virtual float getAlpha() const = 0; + /** @copybrief getAlpha @see getAlpha */ + CV_WRAP virtual void setAlpha(float val) = 0; + + /** @brief Weight of the color constancy term + @see setDelta */ + CV_WRAP virtual float getDelta() const = 0; + /** @copybrief getDelta @see getDelta */ + CV_WRAP virtual void setDelta(float val) = 0; + + /** @brief Weight of the gradient constancy term + @see setGamma */ + CV_WRAP virtual float getGamma() const = 0; + /** @copybrief getGamma @see getGamma */ + CV_WRAP virtual void setGamma(float val) = 0; + + /** @brief Creates an instance of VariationalRefinement + */ + CV_WRAP static Ptr create(); +}; + +/** @brief DIS optical flow algorithm. + +This class implements the Dense Inverse Search (DIS) optical flow algorithm. More +details about the algorithm can be found at @cite Kroeger2016 . Includes three presets with preselected +parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is +still relatively fast, use DeepFlow if you need better quality and don't care about speed. + +This implementation includes several additional features compared to the algorithm described in the paper, +including spatial propagation of flow vectors (@ref getUseSpatialPropagation), as well as an option to +utilize an initial flow approximation passed to @ref calc (which is, essentially, temporal propagation, +if the previous frame's flow field is passed). +*/ +class CV_EXPORTS_W DISOpticalFlow : public DenseOpticalFlow +{ +public: + enum + { + PRESET_ULTRAFAST = 0, + PRESET_FAST = 1, + PRESET_MEDIUM = 2 + }; + + /** @brief Finest level of the Gaussian pyramid on which the flow is computed (zero level + corresponds to the original image resolution). The final flow is obtained by bilinear upscaling. + @see setFinestScale */ + CV_WRAP virtual int getFinestScale() const = 0; + /** @copybrief getFinestScale @see getFinestScale */ + CV_WRAP virtual void setFinestScale(int val) = 0; + + /** @brief Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well + enough in most cases. + @see setPatchSize */ + CV_WRAP virtual int getPatchSize() const = 0; + /** @copybrief getPatchSize @see getPatchSize */ + CV_WRAP virtual void setPatchSize(int val) = 0; + + /** @brief Stride between neighbor patches. Must be less than patch size. Lower values correspond + to higher flow quality. + @see setPatchStride */ + CV_WRAP virtual int getPatchStride() const = 0; + /** @copybrief getPatchStride @see getPatchStride */ + CV_WRAP virtual void setPatchStride(int val) = 0; + + /** @brief Maximum number of gradient descent iterations in the patch inverse search stage. Higher values + may improve quality in some cases. + @see setGradientDescentIterations */ + CV_WRAP virtual int getGradientDescentIterations() const = 0; + /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ + CV_WRAP virtual void setGradientDescentIterations(int val) = 0; + + /** @brief Number of fixed point iterations of variational refinement per scale. Set to zero to + disable variational refinement completely. Higher values will typically result in more smooth and + high-quality flow. + @see setGradientDescentIterations */ + CV_WRAP virtual int getVariationalRefinementIterations() const = 0; + /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ + CV_WRAP virtual void setVariationalRefinementIterations(int val) = 0; + + /** @brief Weight of the smoothness term + @see setVariationalRefinementAlpha */ + CV_WRAP virtual float getVariationalRefinementAlpha() const = 0; + /** @copybrief getVariationalRefinementAlpha @see getVariationalRefinementAlpha */ + CV_WRAP virtual void setVariationalRefinementAlpha(float val) = 0; + + /** @brief Weight of the color constancy term + @see setVariationalRefinementDelta */ + CV_WRAP virtual float getVariationalRefinementDelta() const = 0; + /** @copybrief getVariationalRefinementDelta @see getVariationalRefinementDelta */ + CV_WRAP virtual void setVariationalRefinementDelta(float val) = 0; + + /** @brief Weight of the gradient constancy term + @see setVariationalRefinementGamma */ + CV_WRAP virtual float getVariationalRefinementGamma() const = 0; + /** @copybrief getVariationalRefinementGamma @see getVariationalRefinementGamma */ + CV_WRAP virtual void setVariationalRefinementGamma(float val) = 0; + + + /** @brief Whether to use mean-normalization of patches when computing patch distance. It is turned on + by default as it typically provides a noticeable quality boost because of increased robustness to + illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes + in illumination. + @see setUseMeanNormalization */ + CV_WRAP virtual bool getUseMeanNormalization() const = 0; + /** @copybrief getUseMeanNormalization @see getUseMeanNormalization */ + CV_WRAP virtual void setUseMeanNormalization(bool val) = 0; + + /** @brief Whether to use spatial propagation of good optical flow vectors. This option is turned on by + default, as it tends to work better on average and can sometimes help recover from major errors + introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this + option off can make the output flow field a bit smoother, however. + @see setUseSpatialPropagation */ + CV_WRAP virtual bool getUseSpatialPropagation() const = 0; + /** @copybrief getUseSpatialPropagation @see getUseSpatialPropagation */ + CV_WRAP virtual void setUseSpatialPropagation(bool val) = 0; + + /** @brief Creates an instance of DISOpticalFlow + + @param preset one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM + */ + CV_WRAP static Ptr create(int preset = DISOpticalFlow::PRESET_FAST); +}; + +/** @brief Class used for calculating a sparse optical flow. + +The class can calculate an optical flow for a sparse feature set using the +iterative Lucas-Kanade method with pyramids. + +@sa calcOpticalFlowPyrLK + +*/ +class CV_EXPORTS_W SparsePyrLKOpticalFlow : public SparseOpticalFlow +{ +public: + CV_WRAP virtual Size getWinSize() const = 0; + CV_WRAP virtual void setWinSize(Size winSize) = 0; + + CV_WRAP virtual int getMaxLevel() const = 0; + CV_WRAP virtual void setMaxLevel(int maxLevel) = 0; + + CV_WRAP virtual TermCriteria getTermCriteria() const = 0; + CV_WRAP virtual void setTermCriteria(TermCriteria& crit) = 0; + + CV_WRAP virtual int getFlags() const = 0; + CV_WRAP virtual void setFlags(int flags) = 0; + + CV_WRAP virtual double getMinEigThreshold() const = 0; + CV_WRAP virtual void setMinEigThreshold(double minEigThreshold) = 0; + + CV_WRAP static Ptr create( + Size winSize = Size(21, 21), + int maxLevel = 3, TermCriteria crit = + TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), + int flags = 0, + double minEigThreshold = 1e-4); +}; + + + + +/** @brief Base abstract class for the long-term tracker + */ +class CV_EXPORTS_W Tracker +{ +protected: + Tracker(); +public: + virtual ~Tracker(); + + /** @brief Initialize the tracker with a known bounding box that surrounded the target + @param image The initial frame + @param boundingBox The initial bounding box + */ + CV_WRAP virtual + void init(InputArray image, const Rect& boundingBox) = 0; + + /** @brief Update the tracker, find the new most likely bounding box for the target + @param image The current frame + @param boundingBox The bounding box that represent the new target location, if true was returned, not + modified otherwise + + @return True means that target was located and false means that tracker cannot locate target in + current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed + missing from the frame (say, out of sight) + */ + CV_WRAP virtual + bool update(InputArray image, CV_OUT Rect& boundingBox) = 0; +}; + + + +/** @brief The MIL algorithm trains a classifier in an online manner to separate the object from the +background. + +Multiple Instance Learning avoids the drift problem for a robust tracking. The implementation is +based on @cite MIL . + +Original code can be found here + */ +class CV_EXPORTS_W TrackerMIL : public Tracker +{ +protected: + TrackerMIL(); // use ::create() +public: + virtual ~TrackerMIL() CV_OVERRIDE; + + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + //parameters for sampler + CV_PROP_RW float samplerInitInRadius; //!< radius for gathering positive instances during init + CV_PROP_RW int samplerInitMaxNegNum; //!< # negative samples to use during init + CV_PROP_RW float samplerSearchWinSize; //!< size of search window + CV_PROP_RW float samplerTrackInRadius; //!< radius for gathering positive instances during tracking + CV_PROP_RW int samplerTrackMaxPosNum; //!< # positive samples to use during tracking + CV_PROP_RW int samplerTrackMaxNegNum; //!< # negative samples to use during tracking + CV_PROP_RW int featureSetNumFeatures; //!< # features + }; + + /** @brief Create MIL tracker instance + * @param parameters MIL parameters TrackerMIL::Params + */ + static CV_WRAP + Ptr create(const TrackerMIL::Params ¶meters = TrackerMIL::Params()); + + //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; + //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; +}; + + + +/** @brief the GOTURN (Generic Object Tracking Using Regression Networks) tracker + * + * GOTURN (@cite GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers, + * GOTURN is much faster due to offline training without online fine-tuning nature. + * GOTURN tracker addresses the problem of single target tracking: given a bounding box label of an object in the first frame of the video, + * we track that object through the rest of the video. NOTE: Current method of GOTURN does not handle occlusions; however, it is fairly + * robust to viewpoint changes, lighting changes, and deformations. + * Inputs of GOTURN are two RGB patches representing Target and Search patches resized to 227x227. + * Outputs of GOTURN are predicted bounding box coordinates, relative to Search patch coordinate system, in format X1,Y1,X2,Y2. + * Original paper is here: + * As long as original authors implementation: + * Implementation of training algorithm is placed in separately here due to 3d-party dependencies: + * + * GOTURN architecture goturn.prototxt and trained model goturn.caffemodel are accessible on opencv_extra GitHub repository. + */ +class CV_EXPORTS_W TrackerGOTURN : public Tracker +{ +protected: + TrackerGOTURN(); // use ::create() +public: + virtual ~TrackerGOTURN() CV_OVERRIDE; + + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW std::string modelTxt; + CV_PROP_RW std::string modelBin; + }; + + /** @brief Constructor + @param parameters GOTURN parameters TrackerGOTURN::Params + */ + static CV_WRAP + Ptr create(const TrackerGOTURN::Params& parameters = TrackerGOTURN::Params()); + + //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; + //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; +}; + +class CV_EXPORTS_W TrackerDaSiamRPN : public Tracker +{ +protected: + TrackerDaSiamRPN(); // use ::create() +public: + virtual ~TrackerDaSiamRPN() CV_OVERRIDE; + + struct CV_EXPORTS_W_SIMPLE Params + { + CV_WRAP Params(); + CV_PROP_RW std::string model; + CV_PROP_RW std::string kernel_cls1; + CV_PROP_RW std::string kernel_r1; + CV_PROP_RW int backend; + CV_PROP_RW int target; + }; + + /** @brief Constructor + @param parameters DaSiamRPN parameters TrackerDaSiamRPN::Params + */ + static CV_WRAP + Ptr create(const TrackerDaSiamRPN::Params& parameters = TrackerDaSiamRPN::Params()); + + /** @brief Return tracking score + */ + CV_WRAP virtual float getTrackingScore() = 0; + + //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; + //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; +}; + + +//! @} video_track + +} // cv + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/video/video.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/video.hpp new file mode 100644 index 0000000..8267b85 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/video/video.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/video.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio.hpp new file mode 100644 index 0000000..93ea8cd --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio.hpp @@ -0,0 +1,1129 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_VIDEOIO_HPP +#define OPENCV_VIDEOIO_HPP + +#include "opencv2/core.hpp" + +/** + @defgroup videoio Video I/O + + @brief Read and write video or images sequence with OpenCV + + ### See also: + - @ref videoio_overview + - Tutorials: @ref tutorial_table_of_content_app + @{ + @defgroup videoio_flags_base Flags for video I/O + @defgroup videoio_flags_others Additional flags for video I/O API backends + @defgroup videoio_hwaccel Hardware-accelerated video decoding and encoding + @defgroup videoio_c C API for video I/O + @defgroup videoio_ios iOS glue for video I/O + @defgroup videoio_winrt WinRT glue for video I/O + @defgroup videoio_registry Query I/O API backends registry + @} +*/ + +////////////////////////////////// video io ///////////////////////////////// + +typedef struct CvCapture CvCapture; +typedef struct CvVideoWriter CvVideoWriter; + +namespace cv +{ + +//! @addtogroup videoio +//! @{ + +//! @addtogroup videoio_flags_base +//! @{ + + +/** @brief cv::VideoCapture API backends identifier. + +Select preferred API for a capture object. +To be used in the VideoCapture::VideoCapture() constructor or VideoCapture::open() + +@note Backends are available only if they have been built with your OpenCV binaries. +See @ref videoio_overview for more information. +*/ +enum VideoCaptureAPIs { + CAP_ANY = 0, //!< Auto detect == 0 + CAP_VFW = 200, //!< Video For Windows (obsolete, removed) + CAP_V4L = 200, //!< V4L/V4L2 capturing support + CAP_V4L2 = CAP_V4L, //!< Same as CAP_V4L + CAP_FIREWIRE = 300, //!< IEEE 1394 drivers + CAP_FIREWARE = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_IEEE1394 = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_DC1394 = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_CMU1394 = CAP_FIREWIRE, //!< Same value as CAP_FIREWIRE + CAP_QT = 500, //!< QuickTime (obsolete, removed) + CAP_UNICAP = 600, //!< Unicap drivers (obsolete, removed) + CAP_DSHOW = 700, //!< DirectShow (via videoInput) + CAP_PVAPI = 800, //!< PvAPI, Prosilica GigE SDK + CAP_OPENNI = 900, //!< OpenNI (for Kinect) + CAP_OPENNI_ASUS = 910, //!< OpenNI (for Asus Xtion) + CAP_ANDROID = 1000, //!< Android - not used + CAP_XIAPI = 1100, //!< XIMEA Camera API + CAP_AVFOUNDATION = 1200, //!< AVFoundation framework for iOS (OS X Lion will have the same API) + CAP_GIGANETIX = 1300, //!< Smartek Giganetix GigEVisionSDK + CAP_MSMF = 1400, //!< Microsoft Media Foundation (via videoInput) + CAP_WINRT = 1410, //!< Microsoft Windows Runtime using Media Foundation + CAP_INTELPERC = 1500, //!< RealSense (former Intel Perceptual Computing SDK) + CAP_REALSENSE = 1500, //!< Synonym for CAP_INTELPERC + CAP_OPENNI2 = 1600, //!< OpenNI2 (for Kinect) + CAP_OPENNI2_ASUS = 1610, //!< OpenNI2 (for Asus Xtion and Occipital Structure sensors) + CAP_OPENNI2_ASTRA= 1620, //!< OpenNI2 (for Orbbec Astra) + CAP_GPHOTO2 = 1700, //!< gPhoto2 connection + CAP_GSTREAMER = 1800, //!< GStreamer + CAP_FFMPEG = 1900, //!< Open and record video file or stream using the FFMPEG library + CAP_IMAGES = 2000, //!< OpenCV Image Sequence (e.g. img_%02d.jpg) + CAP_ARAVIS = 2100, //!< Aravis SDK + CAP_OPENCV_MJPEG = 2200, //!< Built-in OpenCV MotionJPEG codec + CAP_INTEL_MFX = 2300, //!< Intel MediaSDK + CAP_XINE = 2400, //!< XINE engine (Linux) + CAP_UEYE = 2500, //!< uEye Camera API + }; + +/** @brief cv::VideoCapture generic properties identifier. + + Reading / writing properties involves many layers. Some unexpected result might happens along this chain. + Effective behaviour depends from device hardware, driver and API Backend. + @sa videoio_flags_others, VideoCapture::get(), VideoCapture::set() +*/ +enum VideoCaptureProperties { + CAP_PROP_POS_MSEC =0, //!< Current position of the video file in milliseconds. + CAP_PROP_POS_FRAMES =1, //!< 0-based index of the frame to be decoded/captured next. + CAP_PROP_POS_AVI_RATIO =2, //!< Relative position of the video file: 0=start of the film, 1=end of the film. + CAP_PROP_FRAME_WIDTH =3, //!< Width of the frames in the video stream. + CAP_PROP_FRAME_HEIGHT =4, //!< Height of the frames in the video stream. + CAP_PROP_FPS =5, //!< Frame rate. + CAP_PROP_FOURCC =6, //!< 4-character code of codec. see VideoWriter::fourcc . + CAP_PROP_FRAME_COUNT =7, //!< Number of frames in the video file. + CAP_PROP_FORMAT =8, //!< Format of the %Mat objects (see Mat::type()) returned by VideoCapture::retrieve(). + //!< Set value -1 to fetch undecoded RAW video streams (as Mat 8UC1). + CAP_PROP_MODE =9, //!< Backend-specific value indicating the current capture mode. + CAP_PROP_BRIGHTNESS =10, //!< Brightness of the image (only for those cameras that support). + CAP_PROP_CONTRAST =11, //!< Contrast of the image (only for cameras). + CAP_PROP_SATURATION =12, //!< Saturation of the image (only for cameras). + CAP_PROP_HUE =13, //!< Hue of the image (only for cameras). + CAP_PROP_GAIN =14, //!< Gain of the image (only for those cameras that support). + CAP_PROP_EXPOSURE =15, //!< Exposure (only for those cameras that support). + CAP_PROP_CONVERT_RGB =16, //!< Boolean flags indicating whether images should be converted to RGB.
+ //!< *GStreamer note*: The flag is ignored in case if custom pipeline is used. It's user responsibility to interpret pipeline output. + CAP_PROP_WHITE_BALANCE_BLUE_U =17, //!< Currently unsupported. + CAP_PROP_RECTIFICATION =18, //!< Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently). + CAP_PROP_MONOCHROME =19, + CAP_PROP_SHARPNESS =20, + CAP_PROP_AUTO_EXPOSURE =21, //!< DC1394: exposure control done by camera, user can adjust reference level using this feature. + CAP_PROP_GAMMA =22, + CAP_PROP_TEMPERATURE =23, + CAP_PROP_TRIGGER =24, + CAP_PROP_TRIGGER_DELAY =25, + CAP_PROP_WHITE_BALANCE_RED_V =26, + CAP_PROP_ZOOM =27, + CAP_PROP_FOCUS =28, + CAP_PROP_GUID =29, + CAP_PROP_ISO_SPEED =30, + CAP_PROP_BACKLIGHT =32, + CAP_PROP_PAN =33, + CAP_PROP_TILT =34, + CAP_PROP_ROLL =35, + CAP_PROP_IRIS =36, + CAP_PROP_SETTINGS =37, //!< Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. The property value is ignored) + CAP_PROP_BUFFERSIZE =38, + CAP_PROP_AUTOFOCUS =39, + CAP_PROP_SAR_NUM =40, //!< Sample aspect ratio: num/den (num) + CAP_PROP_SAR_DEN =41, //!< Sample aspect ratio: num/den (den) + CAP_PROP_BACKEND =42, //!< Current backend (enum VideoCaptureAPIs). Read-only property + CAP_PROP_CHANNEL =43, //!< Video input or Channel Number (only for those cameras that support) + CAP_PROP_AUTO_WB =44, //!< enable/ disable auto white-balance + CAP_PROP_WB_TEMPERATURE=45, //!< white-balance color temperature + CAP_PROP_CODEC_PIXEL_FORMAT =46, //!< (read-only) codec's pixel format. 4-character code - see VideoWriter::fourcc . Subset of [AV_PIX_FMT_*](https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/raw.c) or -1 if unknown + CAP_PROP_BITRATE =47, //!< (read-only) Video bitrate in kbits/s + CAP_PROP_ORIENTATION_META=48, //!< (read-only) Frame rotation defined by stream meta (applicable for FFmpeg back-end only) + CAP_PROP_ORIENTATION_AUTO=49, //!< if true - rotates output frames of CvCapture considering video file's metadata (applicable for FFmpeg back-end only) (https://github.com/opencv/opencv/issues/15499) + CAP_PROP_HW_ACCELERATION=50, //!< (**open-only**) Hardware acceleration type (see #VideoAccelerationType). Setting supported only via `params` parameter in cv::VideoCapture constructor / .open() method. Default value is backend-specific. + CAP_PROP_HW_DEVICE =51, //!< (**open-only**) Hardware device index (select GPU if multiple available). Device enumeration is acceleration type specific. + CAP_PROP_HW_ACCELERATION_USE_OPENCL=52, //!< (**open-only**) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between HW accelerated decoder and cv::UMat. + CAP_PROP_OPEN_TIMEOUT_MSEC=53, //!< (**open-only**) timeout in milliseconds for opening a video capture (applicable for FFmpeg back-end only) + CAP_PROP_READ_TIMEOUT_MSEC=54, //!< (**open-only**) timeout in milliseconds for reading from a video capture (applicable for FFmpeg back-end only) + CAP_PROP_STREAM_OPEN_TIME_USEC =55, //). E.g. When reading from a h264 encoded RTSP stream, the FFmpeg backend could return the SPS and/or PPS if available (if sent in reply to a DESCRIBE request), from calls to cap.retrieve(data, ). +#ifndef CV_DOXYGEN + CV__CAP_PROP_LATEST +#endif + }; + +/** @brief cv::VideoWriter generic properties identifier. + @sa VideoWriter::get(), VideoWriter::set() +*/ +enum VideoWriterProperties { + VIDEOWRITER_PROP_QUALITY = 1, //!< Current quality (0..100%) of the encoded videostream. Can be adjusted dynamically in some codecs. + VIDEOWRITER_PROP_FRAMEBYTES = 2, //!< (Read-only): Size of just encoded video frame. Note that the encoding order may be different from representation order. + VIDEOWRITER_PROP_NSTRIPES = 3, //!< Number of stripes for parallel encoding. -1 for auto detection. + VIDEOWRITER_PROP_IS_COLOR = 4, //!< If it is not zero, the encoder will expect and encode color frames, otherwise it + //!< will work with grayscale frames. + VIDEOWRITER_PROP_DEPTH = 5, //!< Defaults to CV_8U. + VIDEOWRITER_PROP_HW_ACCELERATION = 6, //!< (**open-only**) Hardware acceleration type (see #VideoAccelerationType). Setting supported only via `params` parameter in VideoWriter constructor / .open() method. Default value is backend-specific. + VIDEOWRITER_PROP_HW_DEVICE = 7, //!< (**open-only**) Hardware device index (select GPU if multiple available). Device enumeration is acceleration type specific. + VIDEOWRITER_PROP_HW_ACCELERATION_USE_OPENCL= 8, //!< (**open-only**) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between cv::UMat and HW accelerated encoder. +#ifndef CV_DOXYGEN + CV__VIDEOWRITER_PROP_LATEST +#endif +}; + +//! @} videoio_flags_base + +//! @addtogroup videoio_flags_others +//! @{ + +/** @name Hardware acceleration support + @{ +*/ + +/** @brief Video Acceleration type + * + * Used as value in #CAP_PROP_HW_ACCELERATION and #VIDEOWRITER_PROP_HW_ACCELERATION + * + * @note In case of FFmpeg backend, it translated to enum AVHWDeviceType (https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/hwcontext.h) + */ +enum VideoAccelerationType +{ + VIDEO_ACCELERATION_NONE = 0, //!< Do not require any specific H/W acceleration, prefer software processing. + //!< Reading of this value means that special H/W accelerated handling is not added or not detected by OpenCV. + + VIDEO_ACCELERATION_ANY = 1, //!< Prefer to use H/W acceleration. If no one supported, then fallback to software processing. + //!< @note H/W acceleration may require special configuration of used environment. + //!< @note Results in encoding scenario may differ between software and hardware accelerated encoders. + + VIDEO_ACCELERATION_D3D11 = 2, //!< DirectX 11 + VIDEO_ACCELERATION_VAAPI = 3, //!< VAAPI + VIDEO_ACCELERATION_MFX = 4, //!< libmfx (Intel MediaSDK/oneVPL) +}; + +//! @} Hardware acceleration support + +/** @name IEEE 1394 drivers + @{ +*/ + +/** @brief Modes of the IEEE 1394 controlling registers +(can be: auto, manual, auto single push, absolute Latter allowed with any other mode) +every feature can have only one mode turned on at a time +*/ +enum { CAP_PROP_DC1394_OFF = -4, //!< turn the feature off (not controlled manually nor automatically). + CAP_PROP_DC1394_MODE_MANUAL = -3, //!< set automatically when a value of the feature is set by the user. + CAP_PROP_DC1394_MODE_AUTO = -2, + CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1, + CAP_PROP_DC1394_MAX = 31 + }; + +//! @} IEEE 1394 drivers + +/** @name OpenNI (for Kinect) + @{ +*/ + +//! OpenNI map generators +enum { CAP_OPENNI_DEPTH_GENERATOR = 1 << 31, + CAP_OPENNI_IMAGE_GENERATOR = 1 << 30, + CAP_OPENNI_IR_GENERATOR = 1 << 29, + CAP_OPENNI_GENERATORS_MASK = CAP_OPENNI_DEPTH_GENERATOR + CAP_OPENNI_IMAGE_GENERATOR + CAP_OPENNI_IR_GENERATOR + }; + +//! Properties of cameras available through OpenNI backend +enum { CAP_PROP_OPENNI_OUTPUT_MODE = 100, + CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, //!< In mm + CAP_PROP_OPENNI_BASELINE = 102, //!< In mm + CAP_PROP_OPENNI_FOCAL_LENGTH = 103, //!< In pixels + CAP_PROP_OPENNI_REGISTRATION = 104, //!< Flag that synchronizes the remapping depth map to image map + //!< by changing depth generator's view point (if the flag is "on") or + //!< sets this view point to its normal one (if the flag is "off"). + CAP_PROP_OPENNI_REGISTRATION_ON = CAP_PROP_OPENNI_REGISTRATION, + CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105, + CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106, + CAP_PROP_OPENNI_CIRCLE_BUFFER = 107, + CAP_PROP_OPENNI_MAX_TIME_DURATION = 108, + CAP_PROP_OPENNI_GENERATOR_PRESENT = 109, + CAP_PROP_OPENNI2_SYNC = 110, + CAP_PROP_OPENNI2_MIRROR = 111 + }; + +//! OpenNI shortcuts +enum { CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, + CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CAP_OPENNI_IMAGE_GENERATOR + CAP_PROP_OPENNI_OUTPUT_MODE, + CAP_OPENNI_DEPTH_GENERATOR_PRESENT = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, + CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_BASELINE, + CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_FOCAL_LENGTH, + CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION, + CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION, + CAP_OPENNI_IR_GENERATOR_PRESENT = CAP_OPENNI_IR_GENERATOR + CAP_PROP_OPENNI_GENERATOR_PRESENT, + }; + +//! OpenNI data given from depth generator +enum { CAP_OPENNI_DEPTH_MAP = 0, //!< Depth values in mm (CV_16UC1) + CAP_OPENNI_POINT_CLOUD_MAP = 1, //!< XYZ in meters (CV_32FC3) + CAP_OPENNI_DISPARITY_MAP = 2, //!< Disparity in pixels (CV_8UC1) + CAP_OPENNI_DISPARITY_MAP_32F = 3, //!< Disparity in pixels (CV_32FC1) + CAP_OPENNI_VALID_DEPTH_MASK = 4, //!< CV_8UC1 + + CAP_OPENNI_BGR_IMAGE = 5, //!< Data given from RGB image generator + CAP_OPENNI_GRAY_IMAGE = 6, //!< Data given from RGB image generator + + CAP_OPENNI_IR_IMAGE = 7 //!< Data given from IR image generator + }; + +//! Supported output modes of OpenNI image generator +enum { CAP_OPENNI_VGA_30HZ = 0, + CAP_OPENNI_SXGA_15HZ = 1, + CAP_OPENNI_SXGA_30HZ = 2, + CAP_OPENNI_QVGA_30HZ = 3, + CAP_OPENNI_QVGA_60HZ = 4 + }; + +//! @} OpenNI + +/** @name GStreamer + @{ +*/ + +enum { CAP_PROP_GSTREAMER_QUEUE_LENGTH = 200 //!< Default is 1 + }; + +//! @} GStreamer + +/** @name PvAPI, Prosilica GigE SDK + @{ +*/ + +//! PVAPI +enum { CAP_PROP_PVAPI_MULTICASTIP = 300, //!< IP for enable multicast master mode. 0 for disable multicast. + CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, //!< FrameStartTriggerMode: Determines how a frame is initiated. + CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, //!< Horizontal sub-sampling of the image. + CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, //!< Vertical sub-sampling of the image. + CAP_PROP_PVAPI_BINNINGX = 304, //!< Horizontal binning factor. + CAP_PROP_PVAPI_BINNINGY = 305, //!< Vertical binning factor. + CAP_PROP_PVAPI_PIXELFORMAT = 306 //!< Pixel format. + }; + +//! PVAPI: FrameStartTriggerMode +enum { CAP_PVAPI_FSTRIGMODE_FREERUN = 0, //!< Freerun + CAP_PVAPI_FSTRIGMODE_SYNCIN1 = 1, //!< SyncIn1 + CAP_PVAPI_FSTRIGMODE_SYNCIN2 = 2, //!< SyncIn2 + CAP_PVAPI_FSTRIGMODE_FIXEDRATE = 3, //!< FixedRate + CAP_PVAPI_FSTRIGMODE_SOFTWARE = 4 //!< Software + }; + +//! PVAPI: DecimationHorizontal, DecimationVertical +enum { CAP_PVAPI_DECIMATION_OFF = 1, //!< Off + CAP_PVAPI_DECIMATION_2OUTOF4 = 2, //!< 2 out of 4 decimation + CAP_PVAPI_DECIMATION_2OUTOF8 = 4, //!< 2 out of 8 decimation + CAP_PVAPI_DECIMATION_2OUTOF16 = 8 //!< 2 out of 16 decimation + }; + +//! PVAPI: PixelFormat +enum { CAP_PVAPI_PIXELFORMAT_MONO8 = 1, //!< Mono8 + CAP_PVAPI_PIXELFORMAT_MONO16 = 2, //!< Mono16 + CAP_PVAPI_PIXELFORMAT_BAYER8 = 3, //!< Bayer8 + CAP_PVAPI_PIXELFORMAT_BAYER16 = 4, //!< Bayer16 + CAP_PVAPI_PIXELFORMAT_RGB24 = 5, //!< Rgb24 + CAP_PVAPI_PIXELFORMAT_BGR24 = 6, //!< Bgr24 + CAP_PVAPI_PIXELFORMAT_RGBA32 = 7, //!< Rgba32 + CAP_PVAPI_PIXELFORMAT_BGRA32 = 8, //!< Bgra32 + }; + +//! @} PvAPI + +/** @name XIMEA Camera API + @{ +*/ + +//! Properties of cameras available through XIMEA SDK backend +enum { CAP_PROP_XI_DOWNSAMPLING = 400, //!< Change image resolution by binning or skipping. + CAP_PROP_XI_DATA_FORMAT = 401, //!< Output data format. + CAP_PROP_XI_OFFSET_X = 402, //!< Horizontal offset from the origin to the area of interest (in pixels). + CAP_PROP_XI_OFFSET_Y = 403, //!< Vertical offset from the origin to the area of interest (in pixels). + CAP_PROP_XI_TRG_SOURCE = 404, //!< Defines source of trigger. + CAP_PROP_XI_TRG_SOFTWARE = 405, //!< Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. + CAP_PROP_XI_GPI_SELECTOR = 406, //!< Selects general purpose input. + CAP_PROP_XI_GPI_MODE = 407, //!< Set general purpose input mode. + CAP_PROP_XI_GPI_LEVEL = 408, //!< Get general purpose level. + CAP_PROP_XI_GPO_SELECTOR = 409, //!< Selects general purpose output. + CAP_PROP_XI_GPO_MODE = 410, //!< Set general purpose output mode. + CAP_PROP_XI_LED_SELECTOR = 411, //!< Selects camera signalling LED. + CAP_PROP_XI_LED_MODE = 412, //!< Define camera signalling LED functionality. + CAP_PROP_XI_MANUAL_WB = 413, //!< Calculates White Balance(must be called during acquisition). + CAP_PROP_XI_AUTO_WB = 414, //!< Automatic white balance. + CAP_PROP_XI_AEAG = 415, //!< Automatic exposure/gain. + CAP_PROP_XI_EXP_PRIORITY = 416, //!< Exposure priority (0.5 - exposure 50%, gain 50%). + CAP_PROP_XI_AE_MAX_LIMIT = 417, //!< Maximum limit of exposure in AEAG procedure. + CAP_PROP_XI_AG_MAX_LIMIT = 418, //!< Maximum limit of gain in AEAG procedure. + CAP_PROP_XI_AEAG_LEVEL = 419, //!< Average intensity of output signal AEAG should achieve(in %). + CAP_PROP_XI_TIMEOUT = 420, //!< Image capture timeout in milliseconds. + CAP_PROP_XI_EXPOSURE = 421, //!< Exposure time in microseconds. + CAP_PROP_XI_EXPOSURE_BURST_COUNT = 422, //!< Sets the number of times of exposure in one frame. + CAP_PROP_XI_GAIN_SELECTOR = 423, //!< Gain selector for parameter Gain allows to select different type of gains. + CAP_PROP_XI_GAIN = 424, //!< Gain in dB. + CAP_PROP_XI_DOWNSAMPLING_TYPE = 426, //!< Change image downsampling type. + CAP_PROP_XI_BINNING_SELECTOR = 427, //!< Binning engine selector. + CAP_PROP_XI_BINNING_VERTICAL = 428, //!< Vertical Binning - number of vertical photo-sensitive cells to combine together. + CAP_PROP_XI_BINNING_HORIZONTAL = 429, //!< Horizontal Binning - number of horizontal photo-sensitive cells to combine together. + CAP_PROP_XI_BINNING_PATTERN = 430, //!< Binning pattern type. + CAP_PROP_XI_DECIMATION_SELECTOR = 431, //!< Decimation engine selector. + CAP_PROP_XI_DECIMATION_VERTICAL = 432, //!< Vertical Decimation - vertical sub-sampling of the image - reduces the vertical resolution of the image by the specified vertical decimation factor. + CAP_PROP_XI_DECIMATION_HORIZONTAL = 433, //!< Horizontal Decimation - horizontal sub-sampling of the image - reduces the horizontal resolution of the image by the specified vertical decimation factor. + CAP_PROP_XI_DECIMATION_PATTERN = 434, //!< Decimation pattern type. + CAP_PROP_XI_TEST_PATTERN_GENERATOR_SELECTOR = 587, //!< Selects which test pattern generator is controlled by the TestPattern feature. + CAP_PROP_XI_TEST_PATTERN = 588, //!< Selects which test pattern type is generated by the selected generator. + CAP_PROP_XI_IMAGE_DATA_FORMAT = 435, //!< Output data format. + CAP_PROP_XI_SHUTTER_TYPE = 436, //!< Change sensor shutter type(CMOS sensor). + CAP_PROP_XI_SENSOR_TAPS = 437, //!< Number of taps. + CAP_PROP_XI_AEAG_ROI_OFFSET_X = 439, //!< Automatic exposure/gain ROI offset X. + CAP_PROP_XI_AEAG_ROI_OFFSET_Y = 440, //!< Automatic exposure/gain ROI offset Y. + CAP_PROP_XI_AEAG_ROI_WIDTH = 441, //!< Automatic exposure/gain ROI Width. + CAP_PROP_XI_AEAG_ROI_HEIGHT = 442, //!< Automatic exposure/gain ROI Height. + CAP_PROP_XI_BPC = 445, //!< Correction of bad pixels. + CAP_PROP_XI_WB_KR = 448, //!< White balance red coefficient. + CAP_PROP_XI_WB_KG = 449, //!< White balance green coefficient. + CAP_PROP_XI_WB_KB = 450, //!< White balance blue coefficient. + CAP_PROP_XI_WIDTH = 451, //!< Width of the Image provided by the device (in pixels). + CAP_PROP_XI_HEIGHT = 452, //!< Height of the Image provided by the device (in pixels). + CAP_PROP_XI_REGION_SELECTOR = 589, //!< Selects Region in Multiple ROI which parameters are set by width, height, ... ,region mode. + CAP_PROP_XI_REGION_MODE = 595, //!< Activates/deactivates Region selected by Region Selector. + CAP_PROP_XI_LIMIT_BANDWIDTH = 459, //!< Set/get bandwidth(datarate)(in Megabits). + CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH = 460, //!< Sensor output data bit depth. + CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH = 461, //!< Device output data bit depth. + CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH = 462, //!< bitdepth of data returned by function xiGetImage. + CAP_PROP_XI_OUTPUT_DATA_PACKING = 463, //!< Device output data packing (or grouping) enabled. Packing could be enabled if output_data_bit_depth > 8 and packing capability is available. + CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE = 464, //!< Data packing type. Some cameras supports only specific packing type. + CAP_PROP_XI_IS_COOLED = 465, //!< Returns 1 for cameras that support cooling. + CAP_PROP_XI_COOLING = 466, //!< Start camera cooling. + CAP_PROP_XI_TARGET_TEMP = 467, //!< Set sensor target temperature for cooling. + CAP_PROP_XI_CHIP_TEMP = 468, //!< Camera sensor temperature. + CAP_PROP_XI_HOUS_TEMP = 469, //!< Camera housing temperature. + CAP_PROP_XI_HOUS_BACK_SIDE_TEMP = 590, //!< Camera housing back side temperature. + CAP_PROP_XI_SENSOR_BOARD_TEMP = 596, //!< Camera sensor board temperature. + CAP_PROP_XI_CMS = 470, //!< Mode of color management system. + CAP_PROP_XI_APPLY_CMS = 471, //!< Enable applying of CMS profiles to xiGetImage (see XI_PRM_INPUT_CMS_PROFILE, XI_PRM_OUTPUT_CMS_PROFILE). + CAP_PROP_XI_IMAGE_IS_COLOR = 474, //!< Returns 1 for color cameras. + CAP_PROP_XI_COLOR_FILTER_ARRAY = 475, //!< Returns color filter array type of RAW data. + CAP_PROP_XI_GAMMAY = 476, //!< Luminosity gamma. + CAP_PROP_XI_GAMMAC = 477, //!< Chromaticity gamma. + CAP_PROP_XI_SHARPNESS = 478, //!< Sharpness Strength. + CAP_PROP_XI_CC_MATRIX_00 = 479, //!< Color Correction Matrix element [0][0]. + CAP_PROP_XI_CC_MATRIX_01 = 480, //!< Color Correction Matrix element [0][1]. + CAP_PROP_XI_CC_MATRIX_02 = 481, //!< Color Correction Matrix element [0][2]. + CAP_PROP_XI_CC_MATRIX_03 = 482, //!< Color Correction Matrix element [0][3]. + CAP_PROP_XI_CC_MATRIX_10 = 483, //!< Color Correction Matrix element [1][0]. + CAP_PROP_XI_CC_MATRIX_11 = 484, //!< Color Correction Matrix element [1][1]. + CAP_PROP_XI_CC_MATRIX_12 = 485, //!< Color Correction Matrix element [1][2]. + CAP_PROP_XI_CC_MATRIX_13 = 486, //!< Color Correction Matrix element [1][3]. + CAP_PROP_XI_CC_MATRIX_20 = 487, //!< Color Correction Matrix element [2][0]. + CAP_PROP_XI_CC_MATRIX_21 = 488, //!< Color Correction Matrix element [2][1]. + CAP_PROP_XI_CC_MATRIX_22 = 489, //!< Color Correction Matrix element [2][2]. + CAP_PROP_XI_CC_MATRIX_23 = 490, //!< Color Correction Matrix element [2][3]. + CAP_PROP_XI_CC_MATRIX_30 = 491, //!< Color Correction Matrix element [3][0]. + CAP_PROP_XI_CC_MATRIX_31 = 492, //!< Color Correction Matrix element [3][1]. + CAP_PROP_XI_CC_MATRIX_32 = 493, //!< Color Correction Matrix element [3][2]. + CAP_PROP_XI_CC_MATRIX_33 = 494, //!< Color Correction Matrix element [3][3]. + CAP_PROP_XI_DEFAULT_CC_MATRIX = 495, //!< Set default Color Correction Matrix. + CAP_PROP_XI_TRG_SELECTOR = 498, //!< Selects the type of trigger. + CAP_PROP_XI_ACQ_FRAME_BURST_COUNT = 499, //!< Sets number of frames acquired by burst. This burst is used only if trigger is set to FrameBurstStart. + CAP_PROP_XI_DEBOUNCE_EN = 507, //!< Enable/Disable debounce to selected GPI. + CAP_PROP_XI_DEBOUNCE_T0 = 508, //!< Debounce time (x * 10us). + CAP_PROP_XI_DEBOUNCE_T1 = 509, //!< Debounce time (x * 10us). + CAP_PROP_XI_DEBOUNCE_POL = 510, //!< Debounce polarity (pol = 1 t0 - falling edge, t1 - rising edge). + CAP_PROP_XI_LENS_MODE = 511, //!< Status of lens control interface. This shall be set to XI_ON before any Lens operations. + CAP_PROP_XI_LENS_APERTURE_VALUE = 512, //!< Current lens aperture value in stops. Examples: 2.8, 4, 5.6, 8, 11. + CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE = 513, //!< Lens current focus movement value to be used by XI_PRM_LENS_FOCUS_MOVE in motor steps. + CAP_PROP_XI_LENS_FOCUS_MOVE = 514, //!< Moves lens focus motor by steps set in XI_PRM_LENS_FOCUS_MOVEMENT_VALUE. + CAP_PROP_XI_LENS_FOCUS_DISTANCE = 515, //!< Lens focus distance in cm. + CAP_PROP_XI_LENS_FOCAL_LENGTH = 516, //!< Lens focal distance in mm. + CAP_PROP_XI_LENS_FEATURE_SELECTOR = 517, //!< Selects the current feature which is accessible by XI_PRM_LENS_FEATURE. + CAP_PROP_XI_LENS_FEATURE = 518, //!< Allows access to lens feature value currently selected by XI_PRM_LENS_FEATURE_SELECTOR. + CAP_PROP_XI_DEVICE_MODEL_ID = 521, //!< Returns device model id. + CAP_PROP_XI_DEVICE_SN = 522, //!< Returns device serial number. + CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA = 529, //!< The alpha channel of RGB32 output image format. + CAP_PROP_XI_IMAGE_PAYLOAD_SIZE = 530, //!< Buffer size in bytes sufficient for output image returned by xiGetImage. + CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT = 531, //!< Current format of pixels on transport layer. + CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ = 532, //!< Sensor clock frequency in Hz. + CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX = 533, //!< Sensor clock frequency index. Sensor with selected frequencies have possibility to set the frequency only by this index. + CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT = 534, //!< Number of output channels from sensor used for data transfer. + CAP_PROP_XI_FRAMERATE = 535, //!< Define framerate in Hz. + CAP_PROP_XI_COUNTER_SELECTOR = 536, //!< Select counter. + CAP_PROP_XI_COUNTER_VALUE = 537, //!< Counter status. + CAP_PROP_XI_ACQ_TIMING_MODE = 538, //!< Type of sensor frames timing. + CAP_PROP_XI_AVAILABLE_BANDWIDTH = 539, //!< Calculate and returns available interface bandwidth(int Megabits). + CAP_PROP_XI_BUFFER_POLICY = 540, //!< Data move policy. + CAP_PROP_XI_LUT_EN = 541, //!< Activates LUT. + CAP_PROP_XI_LUT_INDEX = 542, //!< Control the index (offset) of the coefficient to access in the LUT. + CAP_PROP_XI_LUT_VALUE = 543, //!< Value at entry LUTIndex of the LUT. + CAP_PROP_XI_TRG_DELAY = 544, //!< Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + CAP_PROP_XI_TS_RST_MODE = 545, //!< Defines how time stamp reset engine will be armed. + CAP_PROP_XI_TS_RST_SOURCE = 546, //!< Defines which source will be used for timestamp reset. Writing this parameter will trigger settings of engine (arming). + CAP_PROP_XI_IS_DEVICE_EXIST = 547, //!< Returns 1 if camera connected and works properly. + CAP_PROP_XI_ACQ_BUFFER_SIZE = 548, //!< Acquisition buffer size in buffer_size_unit. Default bytes. + CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT = 549, //!< Acquisition buffer size unit in bytes. Default 1. E.g. Value 1024 means that buffer_size is in KiBytes. + CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE = 550, //!< Acquisition transport buffer size in bytes. + CAP_PROP_XI_BUFFERS_QUEUE_SIZE = 551, //!< Queue of field/frame buffers. + CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT = 552, //!< Number of buffers to commit to low level. + CAP_PROP_XI_RECENT_FRAME = 553, //!< GetImage returns most recent frame. + CAP_PROP_XI_DEVICE_RESET = 554, //!< Resets the camera to default state. + CAP_PROP_XI_COLUMN_FPN_CORRECTION = 555, //!< Correction of column FPN. + CAP_PROP_XI_ROW_FPN_CORRECTION = 591, //!< Correction of row FPN. + CAP_PROP_XI_SENSOR_MODE = 558, //!< Current sensor mode. Allows to select sensor mode by one integer. Setting of this parameter affects: image dimensions and downsampling. + CAP_PROP_XI_HDR = 559, //!< Enable High Dynamic Range feature. + CAP_PROP_XI_HDR_KNEEPOINT_COUNT = 560, //!< The number of kneepoints in the PWLR. + CAP_PROP_XI_HDR_T1 = 561, //!< Position of first kneepoint(in % of XI_PRM_EXPOSURE). + CAP_PROP_XI_HDR_T2 = 562, //!< Position of second kneepoint (in % of XI_PRM_EXPOSURE). + CAP_PROP_XI_KNEEPOINT1 = 563, //!< Value of first kneepoint (% of sensor saturation). + CAP_PROP_XI_KNEEPOINT2 = 564, //!< Value of second kneepoint (% of sensor saturation). + CAP_PROP_XI_IMAGE_BLACK_LEVEL = 565, //!< Last image black level counts. Can be used for Offline processing to recall it. + CAP_PROP_XI_HW_REVISION = 571, //!< Returns hardware revision number. + CAP_PROP_XI_DEBUG_LEVEL = 572, //!< Set debug level. + CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION = 573, //!< Automatic bandwidth calculation. + CAP_PROP_XI_FFS_FILE_ID = 594, //!< File number. + CAP_PROP_XI_FFS_FILE_SIZE = 580, //!< Size of file. + CAP_PROP_XI_FREE_FFS_SIZE = 581, //!< Size of free camera FFS. + CAP_PROP_XI_USED_FFS_SIZE = 582, //!< Size of used camera FFS. + CAP_PROP_XI_FFS_ACCESS_KEY = 583, //!< Setting of key enables file operations on some cameras. + CAP_PROP_XI_SENSOR_FEATURE_SELECTOR = 585, //!< Selects the current feature which is accessible by XI_PRM_SENSOR_FEATURE_VALUE. + CAP_PROP_XI_SENSOR_FEATURE_VALUE = 586, //!< Allows access to sensor feature value currently selected by XI_PRM_SENSOR_FEATURE_SELECTOR. + }; + +//! @} XIMEA + + +/** @name ARAVIS Camera API + @{ +*/ + +//! Properties of cameras available through ARAVIS backend +enum { CAP_PROP_ARAVIS_AUTOTRIGGER = 600 //!< Automatically trigger frame capture if camera is configured with software trigger +}; + +//! @} ARAVIS + +/** @name AVFoundation framework for iOS + @{ +*/ + +//! Properties of cameras available through AVFOUNDATION backend +enum { CAP_PROP_IOS_DEVICE_FOCUS = 9001, + CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, + CAP_PROP_IOS_DEVICE_FLASH = 9003, + CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, + CAP_PROP_IOS_DEVICE_TORCH = 9005 + }; + +//! @} AVFoundation framework for iOS + + +/** @name Smartek Giganetix GigEVisionSDK + @{ +*/ + +//! Properties of cameras available through Smartek Giganetix Ethernet Vision backend +/* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */ +enum { CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, + CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, + CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, + CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, + CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, + CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006 + }; + +//! @} Smartek + +/** @name Intel Perceptual Computing SDK + @{ +*/ +enum { CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, + CAP_PROP_INTELPERC_PROFILE_IDX = 11002, + CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, + CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, + CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, + CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, + CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007 + }; + +//! Intel Perceptual Streams +enum { CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, + CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, + CAP_INTELPERC_IR_GENERATOR = 1 << 27, + CAP_INTELPERC_GENERATORS_MASK = CAP_INTELPERC_DEPTH_GENERATOR + CAP_INTELPERC_IMAGE_GENERATOR + CAP_INTELPERC_IR_GENERATOR + }; + +enum { CAP_INTELPERC_DEPTH_MAP = 0, //!< Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. + CAP_INTELPERC_UVDEPTH_MAP = 1, //!< Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. + CAP_INTELPERC_IR_MAP = 2, //!< Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. + CAP_INTELPERC_IMAGE = 3 + }; + +//! @} Intel Perceptual + +/** @name gPhoto2 connection + @{ +*/ + +/** @brief gPhoto2 properties + +If `propertyId` is less than 0 then work on widget with that __additive inversed__ camera setting ID +Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE. +@see CvCaptureCAM_GPHOTO2 for more info +*/ +enum { CAP_PROP_GPHOTO2_PREVIEW = 17001, //!< Capture only preview from liveview mode. + CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, //!< Readonly, returns (const char *). + CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, //!< Trigger, only by set. Reload camera settings. + CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, //!< Reload all settings on set. + CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, //!< Collect messages with details. + CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, //!< Readonly, returns (const char *). + CAP_PROP_SPEED = 17007, //!< Exposure speed. Can be readonly, depends on camera program. + CAP_PROP_APERTURE = 17008, //!< Aperture. Can be readonly, depends on camera program. + CAP_PROP_EXPOSUREPROGRAM = 17009, //!< Camera exposure program. + CAP_PROP_VIEWFINDER = 17010 //!< Enter liveview mode. + }; + +//! @} gPhoto2 + + +/** @name Images backend + @{ +*/ + +/** @brief Images backend properties + +*/ +enum { CAP_PROP_IMAGES_BASE = 18000, + CAP_PROP_IMAGES_LAST = 19000 // excluding + }; + +//! @} Images + +//! @} videoio_flags_others + + +class IVideoCapture; +//! @cond IGNORED +namespace internal { class VideoCapturePrivateAccessor; } +//! @endcond IGNORED + +/** @brief Class for video capturing from video files, image sequences or cameras. + +The class provides C++ API for capturing video from cameras or for reading video files and image sequences. + +Here is how the class can be used: +@include samples/cpp/videocapture_basic.cpp + +@note In @ref videoio_c "C API" the black-box structure `CvCapture` is used instead of %VideoCapture. +@note +- (C++) A basic sample on using the %VideoCapture interface can be found at + `OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp` +- (Python) A basic sample on using the %VideoCapture interface can be found at + `OPENCV_SOURCE_CODE/samples/python/video.py` +- (Python) A multi threaded video processing sample can be found at + `OPENCV_SOURCE_CODE/samples/python/video_threaded.py` +- (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend + `OPENCV_SOURCE_CODE/samples/python/video_v4l2.py` + */ +class CV_EXPORTS_W VideoCapture +{ +public: + /** @brief Default constructor + @note In @ref videoio_c "C API", when you finished working with video, release CvCapture structure with + cvReleaseCapture(), or use Ptr\ that calls cvReleaseCapture() automatically in the + destructor. + */ + CV_WRAP VideoCapture(); + + /** @overload + @brief Opens a video file or a capturing device or an IP video stream for video capturing with API Preference + + @param filename it can be: + - name of video file (eg. `video.avi`) + - or image sequence (eg. `img_%02d.jpg`, which will read samples like `img_00.jpg, img_01.jpg, img_02.jpg, ...`) + - or URL of video stream (eg. `protocol://host:port/script_name?script_params|auth`) + - or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend + Note that each video stream or IP camera feed has its own URL scheme. Please refer to the + documentation of source stream to know the right URL. + @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader + implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW. + + @sa cv::VideoCaptureAPIs + */ + CV_WRAP explicit VideoCapture(const String& filename, int apiPreference = CAP_ANY); + + /** @overload + @brief Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + */ + CV_WRAP explicit VideoCapture(const String& filename, int apiPreference, const std::vector& params); + + /** @overload + @brief Opens a camera for video capturing + + @param index id of the video capturing device to open. To open default camera using default backend just pass 0. + (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY) + @param apiPreference preferred Capture API backends to use. Can be used to enforce a specific reader + implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L. + + @sa cv::VideoCaptureAPIs + */ + CV_WRAP explicit VideoCapture(int index, int apiPreference = CAP_ANY); + + /** @overload + @brief Opens a camera for video capturing with API Preference and parameters + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + */ + CV_WRAP explicit VideoCapture(int index, int apiPreference, const std::vector& params); + + /** @brief Default destructor + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + virtual ~VideoCapture(); + + /** @brief Opens a video file or a capturing device or an IP video stream for video capturing. + + @overload + + Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY) + @return `true` if the file has been successfully opened + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(const String& filename, int apiPreference = CAP_ANY); + + /** @brief Opens a camera for video capturing + + @overload + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + + @return `true` if the file has been successfully opened + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(const String& filename, int apiPreference, const std::vector& params); + + /** @brief Opens a camera for video capturing + + @overload + + Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY) + @return `true` if the camera has been successfully opened. + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(int index, int apiPreference = CAP_ANY); + + /** @brief Returns true if video capturing has been initialized already. + + @overload + + The `params` parameter allows to specify extra parameters encoded as pairs `(paramId_1, paramValue_1, paramId_2, paramValue_2, ...)`. + See cv::VideoCaptureProperties + + @return `true` if the camera has been successfully opened. + + The method first calls VideoCapture::release to close the already opened file or camera. + */ + CV_WRAP virtual bool open(int index, int apiPreference, const std::vector& params); + + /** @brief Returns true if video capturing has been initialized already. + + If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns + true. + */ + CV_WRAP virtual bool isOpened() const; + + /** @brief Closes video file or capturing device. + + The method is automatically called by subsequent VideoCapture::open and by VideoCapture + destructor. + + The C function also deallocates memory and clears \*capture pointer. + */ + CV_WRAP virtual void release(); + + /** @brief Grabs the next frame from video file or capturing device. + + @return `true` (non-zero) in the case of success. + + The method/function grabs the next frame from video file or camera and returns true (non-zero) in + the case of success. + + The primary use of the function is in multi-camera environments, especially when the cameras do not + have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that + call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way + the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames + from different cameras will be closer in time. + + Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the + correct way of retrieving data from it is to call VideoCapture::grab() first and then call + VideoCapture::retrieve() one or more times with different values of the channel parameter. + + @ref tutorial_kinect_openni + */ + CV_WRAP virtual bool grab(); + + /** @brief Decodes and returns the grabbed video frame. + + @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty. + @param flag it could be a frame index or a driver specific flag + @return `false` if no frames has been grabbed + + The method decodes and returns the just grabbed frame. If no frames has been grabbed + (camera has been disconnected, or there are no more frames in video file), the method returns false + and the function returns an empty image (with %cv::Mat, test it with Mat::empty()). + + @sa read() + + @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video + capturing structure. It is not allowed to modify or release the image! You can copy the frame using + cvCloneImage and then do whatever you want with the copy. + */ + CV_WRAP virtual bool retrieve(OutputArray image, int flag = 0); + + /** @brief Stream operator to read the next video frame. + @sa read() + */ + virtual VideoCapture& operator >> (CV_OUT Mat& image); + + /** @overload + @sa read() + */ + virtual VideoCapture& operator >> (CV_OUT UMat& image); + + /** @brief Grabs, decodes and returns the next video frame. + + @param [out] image the video frame is returned here. If no frames has been grabbed the image will be empty. + @return `false` if no frames has been grabbed + + The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the + most convenient method for reading video files or capturing data from decode and returns the just + grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more + frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()). + + @note In @ref videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video + capturing structure. It is not allowed to modify or release the image! You can copy the frame using + cvCloneImage and then do whatever you want with the copy. + */ + CV_WRAP virtual bool read(OutputArray image); + + /** @brief Sets a property in the VideoCapture. + + @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) + or one from @ref videoio_flags_others + @param value Value of the property. + @return `true` if the property is supported by backend used by the VideoCapture instance. + @note Even if it returns `true` this doesn't ensure that the property + value has been accepted by the capture device. See note in VideoCapture::get() + */ + CV_WRAP virtual bool set(int propId, double value); + + /** @brief Returns the specified VideoCapture property + + @param propId Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...) + or one from @ref videoio_flags_others + @return Value for the specified property. Value 0 is returned when querying a property that is + not supported by the backend used by the VideoCapture instance. + + @note Reading / writing properties involves many layers. Some unexpected result might happens + along this chain. + @code{.txt} + VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware + @endcode + The returned value might be different from what really used by the device or it could be encoded + using device dependent rules (eg. steps or percentage). Effective behaviour depends from device + driver and API Backend + + */ + CV_WRAP virtual double get(int propId) const; + + /** @brief Returns used backend API name + + @note Stream should be opened. + */ + CV_WRAP String getBackendName() const; + + /** Switches exceptions mode + * + * methods raise exceptions if not successful instead of returning an error code + */ + CV_WRAP void setExceptionMode(bool enable) { throwOnFail = enable; } + + /// query if exception mode is active + CV_WRAP bool getExceptionMode() { return throwOnFail; } + + + /** @brief Wait for ready frames from VideoCapture. + + @param streams input video streams + @param readyIndex stream indexes with grabbed frames (ready to use .retrieve() to fetch actual frame) + @param timeoutNs number of nanoseconds (0 - infinite) + @return `true` if streamReady is not empty + + @throws Exception %Exception on stream errors (check .isOpened() to filter out malformed streams) or VideoCapture type is not supported + + The primary use of the function is in multi-camera environments. + The method fills the ready state vector, grabs video frame, if camera is ready. + + After this call use VideoCapture::retrieve() to decode and fetch frame data. + */ + static /*CV_WRAP*/ + bool waitAny( + const std::vector& streams, + CV_OUT std::vector& readyIndex, + int64 timeoutNs = 0); + +protected: + Ptr cap; + Ptr icap; + bool throwOnFail; + + friend class internal::VideoCapturePrivateAccessor; +}; + +class IVideoWriter; + +/** @example samples/cpp/tutorial_code/videoio/video-write/video-write.cpp +Check @ref tutorial_video_write "the corresponding tutorial" for more details +*/ + +/** @example samples/cpp/videowriter_basic.cpp +An example using VideoCapture and VideoWriter class +*/ + +/** @brief Video writer class. + +The class provides C++ API for writing video files or image sequences. +*/ +class CV_EXPORTS_W VideoWriter +{ +public: + /** @brief Default constructors + + The constructors/functions initialize video writers. + - On Linux FFMPEG is used to write videos; + - On Windows FFMPEG or MSWF or DSHOW is used; + - On MacOSX AVFoundation is used. + */ + CV_WRAP VideoWriter(); + + /** @overload + @param filename Name of the output video file. + @param fourcc 4-character code of codec used to compress the frames. For example, + VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G') is a + motion-jpeg codec etc. List of codes can be obtained at [Video Codecs by + FOURCC](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses + other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs), + so you may receive a warning message from OpenCV about fourcc code conversion. + @param fps Framerate of the created video stream. + @param frameSize Size of the video frames. + @param isColor If it is not zero, the encoder will expect and encode color frames, otherwise it + will work with grayscale frames. + + @b Tips: + - With some backends `fourcc=-1` pops up the codec selection dialog from the system. + - To save image sequence use a proper filename (eg. `img_%02d.jpg`) and `fourcc=0` + OR `fps=0`. Use uncompressed image format (eg. `img_%02d.BMP`) to save raw frames. + - Most codecs are lossy. If you want lossless video file you need to use a lossless codecs + (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...) + - If FFMPEG is enabled, using `codec=0; fps=0;` you can create an uncompressed (raw) video file. + */ + CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation + if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER. + */ + CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + * The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) + * see cv::VideoWriterProperties + */ + CV_WRAP VideoWriter(const String& filename, int fourcc, double fps, const Size& frameSize, + const std::vector& params); + + /** @overload + */ + CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps, + const Size& frameSize, const std::vector& params); + + /** @brief Default destructor + + The method first calls VideoWriter::release to close the already opened file. + */ + virtual ~VideoWriter(); + + /** @brief Initializes or reinitializes video writer. + + The method opens video writer. Parameters are the same as in the constructor + VideoWriter::VideoWriter. + @return `true` if video writer has been successfully initialized + + The method first calls VideoWriter::release to close the already opened file. + */ + CV_WRAP virtual bool open(const String& filename, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + */ + CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps, + Size frameSize, bool isColor = true); + + /** @overload + */ + CV_WRAP bool open(const String& filename, int fourcc, double fps, const Size& frameSize, + const std::vector& params); + + /** @overload + */ + CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps, + const Size& frameSize, const std::vector& params); + + /** @brief Returns true if video writer has been successfully initialized. + */ + CV_WRAP virtual bool isOpened() const; + + /** @brief Closes the video writer. + + The method is automatically called by subsequent VideoWriter::open and by the VideoWriter + destructor. + */ + CV_WRAP virtual void release(); + + /** @brief Stream operator to write the next video frame. + @sa write + */ + virtual VideoWriter& operator << (const Mat& image); + + /** @overload + @sa write + */ + virtual VideoWriter& operator << (const UMat& image); + + /** @brief Writes the next video frame + + @param image The written frame. In general, color images are expected in BGR format. + + The function/method writes the specified image to video file. It must have the same size as has + been specified when opening the video writer. + */ + CV_WRAP virtual void write(InputArray image); + + /** @brief Sets a property in the VideoWriter. + + @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) + or one of @ref videoio_flags_others + + @param value Value of the property. + @return `true` if the property is supported by the backend used by the VideoWriter instance. + */ + CV_WRAP virtual bool set(int propId, double value); + + /** @brief Returns the specified VideoWriter property + + @param propId Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) + or one of @ref videoio_flags_others + + @return Value for the specified property. Value 0 is returned when querying a property that is + not supported by the backend used by the VideoWriter instance. + */ + CV_WRAP virtual double get(int propId) const; + + /** @brief Concatenates 4 chars to a fourcc code + + @return a fourcc code + + This static method constructs the fourcc code of the codec to be used in the constructor + VideoWriter::VideoWriter or VideoWriter::open. + */ + CV_WRAP static int fourcc(char c1, char c2, char c3, char c4); + + /** @brief Returns used backend API name + + @note Stream should be opened. + */ + CV_WRAP String getBackendName() const; + +protected: + Ptr writer; + Ptr iwriter; + + static Ptr create(const String& filename, int fourcc, double fps, + Size frameSize, bool isColor = true); +}; + +//! @cond IGNORED +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvCapture* obj) const; }; +template<> struct DefaultDeleter{ CV_EXPORTS void operator ()(CvVideoWriter* obj) const; }; +//! @endcond IGNORED + +//! @} videoio + +} // cv + +#endif //OPENCV_VIDEOIO_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/cap_ios.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/cap_ios.h new file mode 100644 index 0000000..207ad46 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/cap_ios.h @@ -0,0 +1,150 @@ +/* For iOS video I/O + * by Eduard Feicho on 29/07/12 + * Copyright 2012. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * 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. + * + */ + +#import +#import +#import +#import +#include "opencv2/core.hpp" + +//! @addtogroup videoio_ios +//! @{ + +/////////////////////////////////////// CvAbstractCamera ///////////////////////////////////// + +@class CvAbstractCamera; + +CV_EXPORTS @interface CvAbstractCamera : NSObject +{ + UIDeviceOrientation currentDeviceOrientation; + + BOOL cameraAvailable; +} + +@property (nonatomic, strong) AVCaptureSession* captureSession; +@property (nonatomic, strong) AVCaptureConnection* videoCaptureConnection; + +@property (nonatomic, readonly) BOOL running; +@property (nonatomic, readonly) BOOL captureSessionLoaded; + +@property (nonatomic, assign) int defaultFPS; +@property (nonatomic, readonly) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer; +@property (nonatomic, assign) AVCaptureDevicePosition defaultAVCaptureDevicePosition; +@property (nonatomic, assign) AVCaptureVideoOrientation defaultAVCaptureVideoOrientation; +@property (nonatomic, assign) BOOL useAVCaptureVideoPreviewLayer; +@property (nonatomic, strong) NSString *const defaultAVCaptureSessionPreset; + +@property (nonatomic, assign) int imageWidth; +@property (nonatomic, assign) int imageHeight; + +@property (nonatomic, strong) UIView* parentView; + +- CV_UNUSED(start); +- CV_UNUSED(stop); +- CV_UNUSED(switchCameras); + +- (id)initWithParentView:(UIView*)parent; + +- CV_UNUSED(createCaptureOutput); +- CV_UNUSED(createVideoPreviewLayer); +- CV_UNUSED(updateOrientation); + +- CV_UNUSED(lockFocus); +- CV_UNUSED(unlockFocus); +- CV_UNUSED(lockExposure); +- CV_UNUSED(unlockExposure); +- CV_UNUSED(lockBalance); +- CV_UNUSED(unlockBalance); + +@end + +///////////////////////////////// CvVideoCamera /////////////////////////////////////////// + +@class CvVideoCamera; + +CV_EXPORTS @protocol CvVideoCameraDelegate + +#ifdef __cplusplus +// delegate method for processing image frames +- (void)processImage:(cv::Mat&)image; +#endif + +@end + +CV_EXPORTS @interface CvVideoCamera : CvAbstractCamera +{ + AVCaptureVideoDataOutput *videoDataOutput; + + dispatch_queue_t videoDataOutputQueue; + CALayer *customPreviewLayer; + + CMTime lastSampleTime; + +} + +@property (nonatomic, weak) id delegate; +@property (nonatomic, assign) BOOL grayscaleMode; + +@property (nonatomic, assign) BOOL recordVideo; +@property (nonatomic, assign) BOOL rotateVideo; +@property (nonatomic, strong) AVAssetWriterInput* recordAssetWriterInput; +@property (nonatomic, strong) AVAssetWriterInputPixelBufferAdaptor* recordPixelBufferAdaptor; +@property (nonatomic, strong) AVAssetWriter* recordAssetWriter; + +- (void)adjustLayoutToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation; +- CV_UNUSED(layoutPreviewLayer); +- CV_UNUSED(saveVideo); +- (NSURL *)videoFileURL; +- (NSString *)videoFileString; + + +@end + +///////////////////////////////// CvPhotoCamera /////////////////////////////////////////// + +@class CvPhotoCamera; + +CV_EXPORTS @protocol CvPhotoCameraDelegate + +- (void)photoCamera:(CvPhotoCamera*)photoCamera capturedImage:(UIImage *)image; +- (void)photoCameraCancel:(CvPhotoCamera*)photoCamera; + +@end + +CV_EXPORTS @interface CvPhotoCamera : CvAbstractCamera +{ + AVCaptureStillImageOutput *stillImageOutput; +} + +@property (nonatomic, weak) id delegate; + +- CV_UNUSED(takePicture); + +@end + +//! @} videoio_ios diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/legacy/constants_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/legacy/constants_c.h new file mode 100644 index 0000000..91f85f8 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/legacy/constants_c.h @@ -0,0 +1,434 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEOIO_LEGACY_CONSTANTS_H +#define OPENCV_VIDEOIO_LEGACY_CONSTANTS_H + +enum +{ + CV_CAP_ANY =0, // autodetect + + CV_CAP_MIL =100, // MIL proprietary drivers + + CV_CAP_VFW =200, // platform native + CV_CAP_V4L =200, + CV_CAP_V4L2 =200, + + CV_CAP_FIREWARE =300, // IEEE 1394 drivers + CV_CAP_FIREWIRE =300, + CV_CAP_IEEE1394 =300, + CV_CAP_DC1394 =300, + CV_CAP_CMU1394 =300, + + CV_CAP_STEREO =400, // TYZX proprietary drivers + CV_CAP_TYZX =400, + CV_TYZX_LEFT =400, + CV_TYZX_RIGHT =401, + CV_TYZX_COLOR =402, + CV_TYZX_Z =403, + + CV_CAP_QT =500, // QuickTime + + CV_CAP_UNICAP =600, // Unicap drivers + + CV_CAP_DSHOW =700, // DirectShow (via videoInput) + CV_CAP_MSMF =1400, // Microsoft Media Foundation (via videoInput) + + CV_CAP_PVAPI =800, // PvAPI, Prosilica GigE SDK + + CV_CAP_OPENNI =900, // OpenNI (for Kinect) + CV_CAP_OPENNI_ASUS =910, // OpenNI (for Asus Xtion) + + CV_CAP_ANDROID =1000, // Android - not used + CV_CAP_ANDROID_BACK =CV_CAP_ANDROID+99, // Android back camera - not used + CV_CAP_ANDROID_FRONT =CV_CAP_ANDROID+98, // Android front camera - not used + + CV_CAP_XIAPI =1100, // XIMEA Camera API + + CV_CAP_AVFOUNDATION = 1200, // AVFoundation framework for iOS (OS X Lion will have the same API) + + CV_CAP_GIGANETIX = 1300, // Smartek Giganetix GigEVisionSDK + + CV_CAP_INTELPERC = 1500, // Intel Perceptual Computing + + CV_CAP_OPENNI2 = 1600, // OpenNI2 (for Kinect) + CV_CAP_GPHOTO2 = 1700, + CV_CAP_GSTREAMER = 1800, // GStreamer + CV_CAP_FFMPEG = 1900, // FFMPEG + CV_CAP_IMAGES = 2000, // OpenCV Image Sequence (e.g. img_%02d.jpg) + + CV_CAP_ARAVIS = 2100 // Aravis GigE SDK +}; + +enum +{ + // modes of the controlling registers (can be: auto, manual, auto single push, absolute Latter allowed with any other mode) + // every feature can have only one mode turned on at a time + CV_CAP_PROP_DC1394_OFF = -4, //turn the feature off (not controlled manually nor automatically) + CV_CAP_PROP_DC1394_MODE_MANUAL = -3, //set automatically when a value of the feature is set by the user + CV_CAP_PROP_DC1394_MODE_AUTO = -2, + CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO = -1, + CV_CAP_PROP_POS_MSEC =0, + CV_CAP_PROP_POS_FRAMES =1, + CV_CAP_PROP_POS_AVI_RATIO =2, + CV_CAP_PROP_FRAME_WIDTH =3, + CV_CAP_PROP_FRAME_HEIGHT =4, + CV_CAP_PROP_FPS =5, + CV_CAP_PROP_FOURCC =6, + CV_CAP_PROP_FRAME_COUNT =7, + CV_CAP_PROP_FORMAT =8, + CV_CAP_PROP_MODE =9, + CV_CAP_PROP_BRIGHTNESS =10, + CV_CAP_PROP_CONTRAST =11, + CV_CAP_PROP_SATURATION =12, + CV_CAP_PROP_HUE =13, + CV_CAP_PROP_GAIN =14, + CV_CAP_PROP_EXPOSURE =15, + CV_CAP_PROP_CONVERT_RGB =16, + CV_CAP_PROP_WHITE_BALANCE_BLUE_U =17, + CV_CAP_PROP_RECTIFICATION =18, + CV_CAP_PROP_MONOCHROME =19, + CV_CAP_PROP_SHARPNESS =20, + CV_CAP_PROP_AUTO_EXPOSURE =21, // exposure control done by camera, + // user can adjust reference level + // using this feature + CV_CAP_PROP_GAMMA =22, + CV_CAP_PROP_TEMPERATURE =23, + CV_CAP_PROP_TRIGGER =24, + CV_CAP_PROP_TRIGGER_DELAY =25, + CV_CAP_PROP_WHITE_BALANCE_RED_V =26, + CV_CAP_PROP_ZOOM =27, + CV_CAP_PROP_FOCUS =28, + CV_CAP_PROP_GUID =29, + CV_CAP_PROP_ISO_SPEED =30, + CV_CAP_PROP_MAX_DC1394 =31, + CV_CAP_PROP_BACKLIGHT =32, + CV_CAP_PROP_PAN =33, + CV_CAP_PROP_TILT =34, + CV_CAP_PROP_ROLL =35, + CV_CAP_PROP_IRIS =36, + CV_CAP_PROP_SETTINGS =37, + CV_CAP_PROP_BUFFERSIZE =38, + CV_CAP_PROP_AUTOFOCUS =39, + CV_CAP_PROP_SAR_NUM =40, + CV_CAP_PROP_SAR_DEN =41, + + CV_CAP_PROP_AUTOGRAB =1024, // property for videoio class CvCapture_Android only + CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING=1025, // readonly, tricky property, returns cpnst char* indeed + CV_CAP_PROP_PREVIEW_FORMAT=1026, // readonly, tricky property, returns cpnst char* indeed + + // OpenNI map generators + CV_CAP_OPENNI_DEPTH_GENERATOR = 1 << 31, + CV_CAP_OPENNI_IMAGE_GENERATOR = 1 << 30, + CV_CAP_OPENNI_IR_GENERATOR = 1 << 29, + CV_CAP_OPENNI_GENERATORS_MASK = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_OPENNI_IR_GENERATOR, + + // Properties of cameras available through OpenNI interfaces + CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100, + CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm + CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm + CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels + CV_CAP_PROP_OPENNI_REGISTRATION = 104, // flag + CV_CAP_PROP_OPENNI_REGISTRATION_ON = CV_CAP_PROP_OPENNI_REGISTRATION, // flag that synchronizes the remapping depth map to image map + // by changing depth generator's view point (if the flag is "on") or + // sets this view point to its normal one (if the flag is "off"). + CV_CAP_PROP_OPENNI_APPROX_FRAME_SYNC = 105, + CV_CAP_PROP_OPENNI_MAX_BUFFER_SIZE = 106, + CV_CAP_PROP_OPENNI_CIRCLE_BUFFER = 107, + CV_CAP_PROP_OPENNI_MAX_TIME_DURATION = 108, + + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT = 109, + CV_CAP_PROP_OPENNI2_SYNC = 110, + CV_CAP_PROP_OPENNI2_MIRROR = 111, + + CV_CAP_OPENNI_IMAGE_GENERATOR_PRESENT = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, + CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE, + CV_CAP_OPENNI_DEPTH_GENERATOR_PRESENT = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, + CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE, + CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH, + CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION, + CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION, + CV_CAP_OPENNI_IR_GENERATOR_PRESENT = CV_CAP_OPENNI_IR_GENERATOR + CV_CAP_PROP_OPENNI_GENERATOR_PRESENT, + + // Properties of cameras available through GStreamer interface + CV_CAP_GSTREAMER_QUEUE_LENGTH = 200, // default is 1 + + // PVAPI + CV_CAP_PROP_PVAPI_MULTICASTIP = 300, // ip for anable multicast master mode. 0 for disable multicast + CV_CAP_PROP_PVAPI_FRAMESTARTTRIGGERMODE = 301, // FrameStartTriggerMode: Determines how a frame is initiated + CV_CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302, // Horizontal sub-sampling of the image + CV_CAP_PROP_PVAPI_DECIMATIONVERTICAL = 303, // Vertical sub-sampling of the image + CV_CAP_PROP_PVAPI_BINNINGX = 304, // Horizontal binning factor + CV_CAP_PROP_PVAPI_BINNINGY = 305, // Vertical binning factor + CV_CAP_PROP_PVAPI_PIXELFORMAT = 306, // Pixel format + + // Properties of cameras available through XIMEA SDK interface + CV_CAP_PROP_XI_DOWNSAMPLING = 400, // Change image resolution by binning or skipping. + CV_CAP_PROP_XI_DATA_FORMAT = 401, // Output data format. + CV_CAP_PROP_XI_OFFSET_X = 402, // Horizontal offset from the origin to the area of interest (in pixels). + CV_CAP_PROP_XI_OFFSET_Y = 403, // Vertical offset from the origin to the area of interest (in pixels). + CV_CAP_PROP_XI_TRG_SOURCE = 404, // Defines source of trigger. + CV_CAP_PROP_XI_TRG_SOFTWARE = 405, // Generates an internal trigger. PRM_TRG_SOURCE must be set to TRG_SOFTWARE. + CV_CAP_PROP_XI_GPI_SELECTOR = 406, // Selects general purpose input + CV_CAP_PROP_XI_GPI_MODE = 407, // Set general purpose input mode + CV_CAP_PROP_XI_GPI_LEVEL = 408, // Get general purpose level + CV_CAP_PROP_XI_GPO_SELECTOR = 409, // Selects general purpose output + CV_CAP_PROP_XI_GPO_MODE = 410, // Set general purpose output mode + CV_CAP_PROP_XI_LED_SELECTOR = 411, // Selects camera signalling LED + CV_CAP_PROP_XI_LED_MODE = 412, // Define camera signalling LED functionality + CV_CAP_PROP_XI_MANUAL_WB = 413, // Calculates White Balance(must be called during acquisition) + CV_CAP_PROP_XI_AUTO_WB = 414, // Automatic white balance + CV_CAP_PROP_XI_AEAG = 415, // Automatic exposure/gain + CV_CAP_PROP_XI_EXP_PRIORITY = 416, // Exposure priority (0.5 - exposure 50%, gain 50%). + CV_CAP_PROP_XI_AE_MAX_LIMIT = 417, // Maximum limit of exposure in AEAG procedure + CV_CAP_PROP_XI_AG_MAX_LIMIT = 418, // Maximum limit of gain in AEAG procedure + CV_CAP_PROP_XI_AEAG_LEVEL = 419, // Average intensity of output signal AEAG should achieve(in %) + CV_CAP_PROP_XI_TIMEOUT = 420, // Image capture timeout in milliseconds + CV_CAP_PROP_XI_EXPOSURE = 421, // Exposure time in microseconds + CV_CAP_PROP_XI_EXPOSURE_BURST_COUNT = 422, // Sets the number of times of exposure in one frame. + CV_CAP_PROP_XI_GAIN_SELECTOR = 423, // Gain selector for parameter Gain allows to select different type of gains. + CV_CAP_PROP_XI_GAIN = 424, // Gain in dB + CV_CAP_PROP_XI_DOWNSAMPLING_TYPE = 426, // Change image downsampling type. + CV_CAP_PROP_XI_BINNING_SELECTOR = 427, // Binning engine selector. + CV_CAP_PROP_XI_BINNING_VERTICAL = 428, // Vertical Binning - number of vertical photo-sensitive cells to combine together. + CV_CAP_PROP_XI_BINNING_HORIZONTAL = 429, // Horizontal Binning - number of horizontal photo-sensitive cells to combine together. + CV_CAP_PROP_XI_BINNING_PATTERN = 430, // Binning pattern type. + CV_CAP_PROP_XI_DECIMATION_SELECTOR = 431, // Decimation engine selector. + CV_CAP_PROP_XI_DECIMATION_VERTICAL = 432, // Vertical Decimation - vertical sub-sampling of the image - reduces the vertical resolution of the image by the specified vertical decimation factor. + CV_CAP_PROP_XI_DECIMATION_HORIZONTAL = 433, // Horizontal Decimation - horizontal sub-sampling of the image - reduces the horizontal resolution of the image by the specified vertical decimation factor. + CV_CAP_PROP_XI_DECIMATION_PATTERN = 434, // Decimation pattern type. + CV_CAP_PROP_XI_TEST_PATTERN_GENERATOR_SELECTOR = 587, // Selects which test pattern generator is controlled by the TestPattern feature. + CV_CAP_PROP_XI_TEST_PATTERN = 588, // Selects which test pattern type is generated by the selected generator. + CV_CAP_PROP_XI_IMAGE_DATA_FORMAT = 435, // Output data format. + CV_CAP_PROP_XI_SHUTTER_TYPE = 436, // Change sensor shutter type(CMOS sensor). + CV_CAP_PROP_XI_SENSOR_TAPS = 437, // Number of taps + CV_CAP_PROP_XI_AEAG_ROI_OFFSET_X = 439, // Automatic exposure/gain ROI offset X + CV_CAP_PROP_XI_AEAG_ROI_OFFSET_Y = 440, // Automatic exposure/gain ROI offset Y + CV_CAP_PROP_XI_AEAG_ROI_WIDTH = 441, // Automatic exposure/gain ROI Width + CV_CAP_PROP_XI_AEAG_ROI_HEIGHT = 442, // Automatic exposure/gain ROI Height + CV_CAP_PROP_XI_BPC = 445, // Correction of bad pixels + CV_CAP_PROP_XI_WB_KR = 448, // White balance red coefficient + CV_CAP_PROP_XI_WB_KG = 449, // White balance green coefficient + CV_CAP_PROP_XI_WB_KB = 450, // White balance blue coefficient + CV_CAP_PROP_XI_WIDTH = 451, // Width of the Image provided by the device (in pixels). + CV_CAP_PROP_XI_HEIGHT = 452, // Height of the Image provided by the device (in pixels). + CV_CAP_PROP_XI_REGION_SELECTOR = 589, // Selects Region in Multiple ROI which parameters are set by width, height, ... ,region mode + CV_CAP_PROP_XI_REGION_MODE = 595, // Activates/deactivates Region selected by Region Selector + CV_CAP_PROP_XI_LIMIT_BANDWIDTH = 459, // Set/get bandwidth(datarate)(in Megabits) + CV_CAP_PROP_XI_SENSOR_DATA_BIT_DEPTH = 460, // Sensor output data bit depth. + CV_CAP_PROP_XI_OUTPUT_DATA_BIT_DEPTH = 461, // Device output data bit depth. + CV_CAP_PROP_XI_IMAGE_DATA_BIT_DEPTH = 462, // bitdepth of data returned by function xiGetImage + CV_CAP_PROP_XI_OUTPUT_DATA_PACKING = 463, // Device output data packing (or grouping) enabled. Packing could be enabled if output_data_bit_depth > 8 and packing capability is available. + CV_CAP_PROP_XI_OUTPUT_DATA_PACKING_TYPE = 464, // Data packing type. Some cameras supports only specific packing type. + CV_CAP_PROP_XI_IS_COOLED = 465, // Returns 1 for cameras that support cooling. + CV_CAP_PROP_XI_COOLING = 466, // Start camera cooling. + CV_CAP_PROP_XI_TARGET_TEMP = 467, // Set sensor target temperature for cooling. + CV_CAP_PROP_XI_CHIP_TEMP = 468, // Camera sensor temperature + CV_CAP_PROP_XI_HOUS_TEMP = 469, // Camera housing temperature + CV_CAP_PROP_XI_HOUS_BACK_SIDE_TEMP = 590, // Camera housing back side temperature + CV_CAP_PROP_XI_SENSOR_BOARD_TEMP = 596, // Camera sensor board temperature + CV_CAP_PROP_XI_CMS = 470, // Mode of color management system. + CV_CAP_PROP_XI_APPLY_CMS = 471, // Enable applying of CMS profiles to xiGetImage (see XI_PRM_INPUT_CMS_PROFILE, XI_PRM_OUTPUT_CMS_PROFILE). + CV_CAP_PROP_XI_IMAGE_IS_COLOR = 474, // Returns 1 for color cameras. + CV_CAP_PROP_XI_COLOR_FILTER_ARRAY = 475, // Returns color filter array type of RAW data. + CV_CAP_PROP_XI_GAMMAY = 476, // Luminosity gamma + CV_CAP_PROP_XI_GAMMAC = 477, // Chromaticity gamma + CV_CAP_PROP_XI_SHARPNESS = 478, // Sharpness Strength + CV_CAP_PROP_XI_CC_MATRIX_00 = 479, // Color Correction Matrix element [0][0] + CV_CAP_PROP_XI_CC_MATRIX_01 = 480, // Color Correction Matrix element [0][1] + CV_CAP_PROP_XI_CC_MATRIX_02 = 481, // Color Correction Matrix element [0][2] + CV_CAP_PROP_XI_CC_MATRIX_03 = 482, // Color Correction Matrix element [0][3] + CV_CAP_PROP_XI_CC_MATRIX_10 = 483, // Color Correction Matrix element [1][0] + CV_CAP_PROP_XI_CC_MATRIX_11 = 484, // Color Correction Matrix element [1][1] + CV_CAP_PROP_XI_CC_MATRIX_12 = 485, // Color Correction Matrix element [1][2] + CV_CAP_PROP_XI_CC_MATRIX_13 = 486, // Color Correction Matrix element [1][3] + CV_CAP_PROP_XI_CC_MATRIX_20 = 487, // Color Correction Matrix element [2][0] + CV_CAP_PROP_XI_CC_MATRIX_21 = 488, // Color Correction Matrix element [2][1] + CV_CAP_PROP_XI_CC_MATRIX_22 = 489, // Color Correction Matrix element [2][2] + CV_CAP_PROP_XI_CC_MATRIX_23 = 490, // Color Correction Matrix element [2][3] + CV_CAP_PROP_XI_CC_MATRIX_30 = 491, // Color Correction Matrix element [3][0] + CV_CAP_PROP_XI_CC_MATRIX_31 = 492, // Color Correction Matrix element [3][1] + CV_CAP_PROP_XI_CC_MATRIX_32 = 493, // Color Correction Matrix element [3][2] + CV_CAP_PROP_XI_CC_MATRIX_33 = 494, // Color Correction Matrix element [3][3] + CV_CAP_PROP_XI_DEFAULT_CC_MATRIX = 495, // Set default Color Correction Matrix + CV_CAP_PROP_XI_TRG_SELECTOR = 498, // Selects the type of trigger. + CV_CAP_PROP_XI_ACQ_FRAME_BURST_COUNT = 499, // Sets number of frames acquired by burst. This burst is used only if trigger is set to FrameBurstStart + CV_CAP_PROP_XI_DEBOUNCE_EN = 507, // Enable/Disable debounce to selected GPI + CV_CAP_PROP_XI_DEBOUNCE_T0 = 508, // Debounce time (x * 10us) + CV_CAP_PROP_XI_DEBOUNCE_T1 = 509, // Debounce time (x * 10us) + CV_CAP_PROP_XI_DEBOUNCE_POL = 510, // Debounce polarity (pol = 1 t0 - falling edge, t1 - rising edge) + CV_CAP_PROP_XI_LENS_MODE = 511, // Status of lens control interface. This shall be set to XI_ON before any Lens operations. + CV_CAP_PROP_XI_LENS_APERTURE_VALUE = 512, // Current lens aperture value in stops. Examples: 2.8, 4, 5.6, 8, 11 + CV_CAP_PROP_XI_LENS_FOCUS_MOVEMENT_VALUE = 513, // Lens current focus movement value to be used by XI_PRM_LENS_FOCUS_MOVE in motor steps. + CV_CAP_PROP_XI_LENS_FOCUS_MOVE = 514, // Moves lens focus motor by steps set in XI_PRM_LENS_FOCUS_MOVEMENT_VALUE. + CV_CAP_PROP_XI_LENS_FOCUS_DISTANCE = 515, // Lens focus distance in cm. + CV_CAP_PROP_XI_LENS_FOCAL_LENGTH = 516, // Lens focal distance in mm. + CV_CAP_PROP_XI_LENS_FEATURE_SELECTOR = 517, // Selects the current feature which is accessible by XI_PRM_LENS_FEATURE. + CV_CAP_PROP_XI_LENS_FEATURE = 518, // Allows access to lens feature value currently selected by XI_PRM_LENS_FEATURE_SELECTOR. + CV_CAP_PROP_XI_DEVICE_MODEL_ID = 521, // Return device model id + CV_CAP_PROP_XI_DEVICE_SN = 522, // Return device serial number + CV_CAP_PROP_XI_IMAGE_DATA_FORMAT_RGB32_ALPHA = 529, // The alpha channel of RGB32 output image format. + CV_CAP_PROP_XI_IMAGE_PAYLOAD_SIZE = 530, // Buffer size in bytes sufficient for output image returned by xiGetImage + CV_CAP_PROP_XI_TRANSPORT_PIXEL_FORMAT = 531, // Current format of pixels on transport layer. + CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_HZ = 532, // Sensor clock frequency in Hz. + CV_CAP_PROP_XI_SENSOR_CLOCK_FREQ_INDEX = 533, // Sensor clock frequency index. Sensor with selected frequencies have possibility to set the frequency only by this index. + CV_CAP_PROP_XI_SENSOR_OUTPUT_CHANNEL_COUNT = 534, // Number of output channels from sensor used for data transfer. + CV_CAP_PROP_XI_FRAMERATE = 535, // Define framerate in Hz + CV_CAP_PROP_XI_COUNTER_SELECTOR = 536, // Select counter + CV_CAP_PROP_XI_COUNTER_VALUE = 537, // Counter status + CV_CAP_PROP_XI_ACQ_TIMING_MODE = 538, // Type of sensor frames timing. + CV_CAP_PROP_XI_AVAILABLE_BANDWIDTH = 539, // Calculate and return available interface bandwidth(int Megabits) + CV_CAP_PROP_XI_BUFFER_POLICY = 540, // Data move policy + CV_CAP_PROP_XI_LUT_EN = 541, // Activates LUT. + CV_CAP_PROP_XI_LUT_INDEX = 542, // Control the index (offset) of the coefficient to access in the LUT. + CV_CAP_PROP_XI_LUT_VALUE = 543, // Value at entry LUTIndex of the LUT + CV_CAP_PROP_XI_TRG_DELAY = 544, // Specifies the delay in microseconds (us) to apply after the trigger reception before activating it. + CV_CAP_PROP_XI_TS_RST_MODE = 545, // Defines how time stamp reset engine will be armed + CV_CAP_PROP_XI_TS_RST_SOURCE = 546, // Defines which source will be used for timestamp reset. Writing this parameter will trigger settings of engine (arming) + CV_CAP_PROP_XI_IS_DEVICE_EXIST = 547, // Returns 1 if camera connected and works properly. + CV_CAP_PROP_XI_ACQ_BUFFER_SIZE = 548, // Acquisition buffer size in buffer_size_unit. Default bytes. + CV_CAP_PROP_XI_ACQ_BUFFER_SIZE_UNIT = 549, // Acquisition buffer size unit in bytes. Default 1. E.g. Value 1024 means that buffer_size is in KiBytes + CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_SIZE = 550, // Acquisition transport buffer size in bytes + CV_CAP_PROP_XI_BUFFERS_QUEUE_SIZE = 551, // Queue of field/frame buffers + CV_CAP_PROP_XI_ACQ_TRANSPORT_BUFFER_COMMIT = 552, // Number of buffers to commit to low level + CV_CAP_PROP_XI_RECENT_FRAME = 553, // GetImage returns most recent frame + CV_CAP_PROP_XI_DEVICE_RESET = 554, // Resets the camera to default state. + CV_CAP_PROP_XI_COLUMN_FPN_CORRECTION = 555, // Correction of column FPN + CV_CAP_PROP_XI_ROW_FPN_CORRECTION = 591, // Correction of row FPN + CV_CAP_PROP_XI_SENSOR_MODE = 558, // Current sensor mode. Allows to select sensor mode by one integer. Setting of this parameter affects: image dimensions and downsampling. + CV_CAP_PROP_XI_HDR = 559, // Enable High Dynamic Range feature. + CV_CAP_PROP_XI_HDR_KNEEPOINT_COUNT = 560, // The number of kneepoints in the PWLR. + CV_CAP_PROP_XI_HDR_T1 = 561, // position of first kneepoint(in % of XI_PRM_EXPOSURE) + CV_CAP_PROP_XI_HDR_T2 = 562, // position of second kneepoint (in % of XI_PRM_EXPOSURE) + CV_CAP_PROP_XI_KNEEPOINT1 = 563, // value of first kneepoint (% of sensor saturation) + CV_CAP_PROP_XI_KNEEPOINT2 = 564, // value of second kneepoint (% of sensor saturation) + CV_CAP_PROP_XI_IMAGE_BLACK_LEVEL = 565, // Last image black level counts. Can be used for Offline processing to recall it. + CV_CAP_PROP_XI_HW_REVISION = 571, // Returns hardware revision number. + CV_CAP_PROP_XI_DEBUG_LEVEL = 572, // Set debug level + CV_CAP_PROP_XI_AUTO_BANDWIDTH_CALCULATION = 573, // Automatic bandwidth calculation, + CV_CAP_PROP_XI_FFS_FILE_ID = 594, // File number. + CV_CAP_PROP_XI_FFS_FILE_SIZE = 580, // Size of file. + CV_CAP_PROP_XI_FREE_FFS_SIZE = 581, // Size of free camera FFS. + CV_CAP_PROP_XI_USED_FFS_SIZE = 582, // Size of used camera FFS. + CV_CAP_PROP_XI_FFS_ACCESS_KEY = 583, // Setting of key enables file operations on some cameras. + CV_CAP_PROP_XI_SENSOR_FEATURE_SELECTOR = 585, // Selects the current feature which is accessible by XI_PRM_SENSOR_FEATURE_VALUE. + CV_CAP_PROP_XI_SENSOR_FEATURE_VALUE = 586, // Allows access to sensor feature value currently selected by XI_PRM_SENSOR_FEATURE_SELECTOR. + + + // Properties for Android cameras + CV_CAP_PROP_ANDROID_FLASH_MODE = 8001, + CV_CAP_PROP_ANDROID_FOCUS_MODE = 8002, + CV_CAP_PROP_ANDROID_WHITE_BALANCE = 8003, + CV_CAP_PROP_ANDROID_ANTIBANDING = 8004, + CV_CAP_PROP_ANDROID_FOCAL_LENGTH = 8005, + CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_NEAR = 8006, + CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_OPTIMAL = 8007, + CV_CAP_PROP_ANDROID_FOCUS_DISTANCE_FAR = 8008, + CV_CAP_PROP_ANDROID_EXPOSE_LOCK = 8009, + CV_CAP_PROP_ANDROID_WHITEBALANCE_LOCK = 8010, + + // Properties of cameras available through AVFOUNDATION interface + CV_CAP_PROP_IOS_DEVICE_FOCUS = 9001, + CV_CAP_PROP_IOS_DEVICE_EXPOSURE = 9002, + CV_CAP_PROP_IOS_DEVICE_FLASH = 9003, + CV_CAP_PROP_IOS_DEVICE_WHITEBALANCE = 9004, + CV_CAP_PROP_IOS_DEVICE_TORCH = 9005, + + // Properties of cameras available through Smartek Giganetix Ethernet Vision interface + /* --- Vladimir Litvinenko (litvinenko.vladimir@gmail.com) --- */ + CV_CAP_PROP_GIGA_FRAME_OFFSET_X = 10001, + CV_CAP_PROP_GIGA_FRAME_OFFSET_Y = 10002, + CV_CAP_PROP_GIGA_FRAME_WIDTH_MAX = 10003, + CV_CAP_PROP_GIGA_FRAME_HEIGH_MAX = 10004, + CV_CAP_PROP_GIGA_FRAME_SENS_WIDTH = 10005, + CV_CAP_PROP_GIGA_FRAME_SENS_HEIGH = 10006, + + CV_CAP_PROP_INTELPERC_PROFILE_COUNT = 11001, + CV_CAP_PROP_INTELPERC_PROFILE_IDX = 11002, + CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE = 11003, + CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE = 11004, + CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD = 11005, + CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ = 11006, + CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT = 11007, + + // Intel PerC streams + CV_CAP_INTELPERC_DEPTH_GENERATOR = 1 << 29, + CV_CAP_INTELPERC_IMAGE_GENERATOR = 1 << 28, + CV_CAP_INTELPERC_GENERATORS_MASK = CV_CAP_INTELPERC_DEPTH_GENERATOR + CV_CAP_INTELPERC_IMAGE_GENERATOR +}; + +enum +{ + // Data given from depth generator. + CV_CAP_OPENNI_DEPTH_MAP = 0, // Depth values in mm (CV_16UC1) + CV_CAP_OPENNI_POINT_CLOUD_MAP = 1, // XYZ in meters (CV_32FC3) + CV_CAP_OPENNI_DISPARITY_MAP = 2, // Disparity in pixels (CV_8UC1) + CV_CAP_OPENNI_DISPARITY_MAP_32F = 3, // Disparity in pixels (CV_32FC1) + CV_CAP_OPENNI_VALID_DEPTH_MASK = 4, // CV_8UC1 + + // Data given from RGB image generator. + CV_CAP_OPENNI_BGR_IMAGE = 5, + CV_CAP_OPENNI_GRAY_IMAGE = 6, + + // Data given from IR image generator. + CV_CAP_OPENNI_IR_IMAGE = 7 +}; + +// Supported output modes of OpenNI image generator +enum +{ + CV_CAP_OPENNI_VGA_30HZ = 0, + CV_CAP_OPENNI_SXGA_15HZ = 1, + CV_CAP_OPENNI_SXGA_30HZ = 2, + CV_CAP_OPENNI_QVGA_30HZ = 3, + CV_CAP_OPENNI_QVGA_60HZ = 4 +}; + +enum +{ + CV_CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. + CV_CAP_INTELPERC_UVDEPTH_MAP = 1, // Each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. + CV_CAP_INTELPERC_IR_MAP = 2, // Each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. + CV_CAP_INTELPERC_IMAGE = 3 +}; + +// gPhoto2 properties, if propertyId is less than 0 then work on widget with that __additive inversed__ camera setting ID +// Get IDs by using CAP_PROP_GPHOTO2_WIDGET_ENUMERATE. +// @see CvCaptureCAM_GPHOTO2 for more info +enum +{ + CV_CAP_PROP_GPHOTO2_PREVIEW = 17001, // Capture only preview from liveview mode. + CV_CAP_PROP_GPHOTO2_WIDGET_ENUMERATE = 17002, // Readonly, returns (const char *). + CV_CAP_PROP_GPHOTO2_RELOAD_CONFIG = 17003, // Trigger, only by set. Reload camera settings. + CV_CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE = 17004, // Reload all settings on set. + CV_CAP_PROP_GPHOTO2_COLLECT_MSGS = 17005, // Collect messages with details. + CV_CAP_PROP_GPHOTO2_FLUSH_MSGS = 17006, // Readonly, returns (const char *). + CV_CAP_PROP_SPEED = 17007, // Exposure speed. Can be readonly, depends on camera program. + CV_CAP_PROP_APERTURE = 17008, // Aperture. Can be readonly, depends on camera program. + CV_CAP_PROP_EXPOSUREPROGRAM = 17009, // Camera exposure program. + CV_CAP_PROP_VIEWFINDER = 17010 // Enter liveview mode. +}; + +//! Macro to construct the fourcc code of the codec. Same as CV_FOURCC() +#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24)) + +/** @brief Constructs the fourcc code of the codec function + +Simply call it with 4 chars fourcc code like `CV_FOURCC('I', 'Y', 'U', 'V')` + +List of codes can be obtained at [Video Codecs by FOURCC](http://www.fourcc.org/codecs.php) page. +FFMPEG backend with MP4 container natively uses other values as fourcc code: +see [ObjectType](http://mp4ra.org/#/codecs). +*/ +CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4) +{ + return CV_FOURCC_MACRO(c1, c2, c3, c4); +} + +//! (Windows only) Open Codec Selection Dialog +#define CV_FOURCC_PROMPT -1 +//! (Linux only) Use default codec for specified filename +#define CV_FOURCC_DEFAULT CV_FOURCC('I', 'Y', 'U', 'V') + +#endif // OPENCV_VIDEOIO_LEGACY_CONSTANTS_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/registry.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/registry.hpp new file mode 100644 index 0000000..cf72247 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/registry.hpp @@ -0,0 +1,72 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_VIDEOIO_REGISTRY_HPP +#define OPENCV_VIDEOIO_REGISTRY_HPP + +#include + +namespace cv { namespace videoio_registry { +/** @addtogroup videoio_registry +This section contains API description how to query/configure available Video I/O backends. + +Runtime configuration options: +- enable debug mode: `OPENCV_VIDEOIO_DEBUG=1` +- change backend priority: `OPENCV_VIDEOIO_PRIORITY_=9999` +- disable backend: `OPENCV_VIDEOIO_PRIORITY_=0` +- specify list of backends with high priority (>100000): `OPENCV_VIDEOIO_PRIORITY_LIST=FFMPEG,GSTREAMER` + +@{ + */ + + +/** @brief Returns backend API name or "UnknownVideoAPI(xxx)" +@param api backend ID (#VideoCaptureAPIs) +*/ +CV_EXPORTS_W cv::String getBackendName(VideoCaptureAPIs api); + +/** @brief Returns list of all available backends */ +CV_EXPORTS_W std::vector getBackends(); + +/** @brief Returns list of available backends which works via `cv::VideoCapture(int index)` */ +CV_EXPORTS_W std::vector getCameraBackends(); + +/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */ +CV_EXPORTS_W std::vector getStreamBackends(); + +/** @brief Returns list of available backends which works via `cv::VideoWriter()` */ +CV_EXPORTS_W std::vector getWriterBackends(); + +/** @brief Returns true if backend is available */ +CV_EXPORTS_W bool hasBackend(VideoCaptureAPIs api); + +/** @brief Returns true if backend is built in (false if backend is used as plugin) */ +CV_EXPORTS_W bool isBackendBuiltIn(VideoCaptureAPIs api); + +/** @brief Returns description and ABI/API version of videoio plugin's camera interface */ +CV_EXPORTS_W std::string getCameraBackendPluginVersion( + VideoCaptureAPIs api, + CV_OUT int& version_ABI, + CV_OUT int& version_API +); + +/** @brief Returns description and ABI/API version of videoio plugin's stream capture interface */ +CV_EXPORTS_W std::string getStreamBackendPluginVersion( + VideoCaptureAPIs api, + CV_OUT int& version_ABI, + CV_OUT int& version_API +); + +/** @brief Returns description and ABI/API version of videoio plugin's writer interface */ +CV_EXPORTS_W std::string getWriterBackendPluginVersion( + VideoCaptureAPIs api, + CV_OUT int& version_ABI, + CV_OUT int& version_API +); + + +//! @} +}} // namespace + +#endif // OPENCV_VIDEOIO_REGISTRY_HPP diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/videoio.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/videoio.hpp new file mode 100644 index 0000000..ec84cf7 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/videoio.hpp @@ -0,0 +1,48 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifdef __OPENCV_BUILD +#error this is a compatibility header which should not be used inside the OpenCV library +#endif + +#include "opencv2/videoio.hpp" diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/videoio_c.h b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/videoio_c.h new file mode 100644 index 0000000..cf1a6d0 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/videoio/videoio_c.h @@ -0,0 +1,153 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_VIDEOIO_H +#define OPENCV_VIDEOIO_H + +#include "opencv2/core/core_c.h" + +#include "opencv2/videoio/legacy/constants_c.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + @addtogroup videoio_c + @{ +*/ + +/****************************************************************************************\ +* Working with Video Files and Cameras * +\****************************************************************************************/ + +/** @brief "black box" capture structure + +In C++ use cv::VideoCapture +*/ +typedef struct CvCapture CvCapture; + +/** @brief start capturing frames from video file +*/ +CVAPI(CvCapture*) cvCreateFileCapture( const char* filename ); + +/** @brief start capturing frames from video file. allows specifying a preferred API to use +*/ +CVAPI(CvCapture*) cvCreateFileCaptureWithPreference( const char* filename , int apiPreference); + +/** @brief start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*) +*/ +CVAPI(CvCapture*) cvCreateCameraCapture( int index ); + +/** @brief grab a frame, return 1 on success, 0 on fail. + + this function is thought to be fast +*/ +CVAPI(int) cvGrabFrame( CvCapture* capture ); + +/** @brief get the frame grabbed with cvGrabFrame(..) + + This function may apply some frame processing like + frame decompression, flipping etc. + @warning !!!DO NOT RELEASE or MODIFY the retrieved frame!!! +*/ +CVAPI(IplImage*) cvRetrieveFrame( CvCapture* capture, int streamIdx CV_DEFAULT(0) ); + +/** @brief Just a combination of cvGrabFrame and cvRetrieveFrame + + @warning !!!DO NOT RELEASE or MODIFY the retrieved frame!!! +*/ +CVAPI(IplImage*) cvQueryFrame( CvCapture* capture ); + +/** @brief stop capturing/reading and free resources +*/ +CVAPI(void) cvReleaseCapture( CvCapture** capture ); + +/** @brief retrieve capture properties +*/ +CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id ); +/** @brief set capture properties +*/ +CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value ); + +/** @brief Return the type of the capturer (eg, ::CV_CAP_VFW, ::CV_CAP_UNICAP) + +It is unknown if created with ::CV_CAP_ANY +*/ +CVAPI(int) cvGetCaptureDomain( CvCapture* capture); + +/** @brief "black box" video file writer structure + +In C++ use cv::VideoWriter +*/ +typedef struct CvVideoWriter CvVideoWriter; + +/** @brief initialize video file writer +*/ +CVAPI(CvVideoWriter*) cvCreateVideoWriter( const char* filename, int fourcc, + double fps, CvSize frame_size, + int is_color CV_DEFAULT(1)); + +/** @brief write frame to video file +*/ +CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image ); + +/** @brief close video file writer +*/ +CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer ); + +// *************************************************************************************** +//! @name Obsolete functions/synonyms +//! @{ +#define cvCaptureFromCAM cvCreateCameraCapture //!< @deprecated use cvCreateCameraCapture() instead +#define cvCaptureFromFile cvCreateFileCapture //!< @deprecated use cvCreateFileCapture() instead +#define cvCaptureFromAVI cvCaptureFromFile //!< @deprecated use cvCreateFileCapture() instead +#define cvCreateAVIWriter cvCreateVideoWriter //!< @deprecated use cvCreateVideoWriter() instead +#define cvWriteToAVI cvWriteFrame //!< @deprecated use cvWriteFrame() instead +//! @} Obsolete... + +//! @} videoio_c + +#ifdef __cplusplus +} +#endif + +#endif //OPENCV_VIDEOIO_H diff --git a/CigaretteSingle/OpenCV455Simple/include/opencv2/world.hpp b/CigaretteSingle/OpenCV455Simple/include/opencv2/world.hpp new file mode 100644 index 0000000..4902c2f --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/include/opencv2/world.hpp @@ -0,0 +1,58 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors 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. +// +//M*/ + +#ifndef OPENCV_WORLD_HPP +#define OPENCV_WORLD_HPP + +#include "opencv2/core.hpp" + +#ifdef __cplusplus +namespace cv +{ + +CV_EXPORTS_W bool initAll(); + +} + +#endif + +#endif diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVConfig-version.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVConfig-version.cmake new file mode 100644 index 0000000..435b7ec --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVConfig-version.cmake @@ -0,0 +1,15 @@ +set(OpenCV_VERSION 4.5.5) +set(PACKAGE_VERSION ${OpenCV_VERSION}) + +set(PACKAGE_VERSION_EXACT False) +set(PACKAGE_VERSION_COMPATIBLE False) + +if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT True) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() + +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 4 + AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVConfig.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVConfig.cmake new file mode 100644 index 0000000..b6bb809 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVConfig.cmake @@ -0,0 +1,355 @@ +# =================================================================================== +# The OpenCV CMake configuration file +# +# ** File generated automatically, do not modify ** +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(OpenCV REQUIRED) +# include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11 +# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS}) +# +# Or you can search for specific OpenCV modules: +# +# find_package(OpenCV REQUIRED core videoio) +# +# You can also mark OpenCV components as optional: + +# find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz) +# +# If the module is found then OPENCV__FOUND is set to TRUE. +# +# This file will define the following variables: +# - OpenCV_LIBS : The list of all imported targets for OpenCV modules. +# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. +# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability. +# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API. +# - OpenCV_VERSION : The version of this OpenCV build: "4.5.5" +# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "4" +# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_STATUS : Development status of this build: "" +# +# Advanced variables: +# - OpenCV_SHARED : Use OpenCV as shared library +# - OpenCV_INSTALL_PATH : OpenCV location +# - OpenCV_LIB_COMPONENTS : Present OpenCV modules list +# - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag +# +# Deprecated variables: +# - OpenCV_VERSION_TWEAK : Always "0" +# +# =================================================================================== + +# ====================================================== +# Version variables: +# ====================================================== +SET(OpenCV_VERSION 4.5.5) +SET(OpenCV_VERSION_MAJOR 4) +SET(OpenCV_VERSION_MINOR 5) +SET(OpenCV_VERSION_PATCH 5) +SET(OpenCV_VERSION_TWEAK 0) +SET(OpenCV_VERSION_STATUS "") + +include(FindPackageHandleStandardArgs) + +if(NOT CMAKE_VERSION VERSION_LESS 2.8.8 + AND OpenCV_FIND_COMPONENTS # prevent excessive output +) + # HANDLE_COMPONENTS was introduced in CMake 2.8.8 + list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS) + # The missing components will be handled by the FindPackageHandleStandardArgs + # module. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE) +else() + # The missing components will be handled by this config. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE) +endif() + +# Extract directory name from full path of the file currently being processed. +# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it +# for older versions of CMake to support these as well. +if(CMAKE_VERSION VERSION_LESS "2.8.3") + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +endif() + +# Extract the directory where *this* file has been installed (determined at cmake run-time) +# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings +get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}" REALPATH) +get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../../" REALPATH) + +# Search packages for host system instead of packages for target system. +# in case of cross compilation this macro should be defined by toolchain file +if(NOT COMMAND find_host_package) + macro(find_host_package) + find_package(${ARGN}) + endmacro() +endif() +if(NOT COMMAND find_host_program) + macro(find_host_program) + find_program(${ARGN}) + endmacro() +endif() + + + + + + + + +# Some additional settings are required if OpenCV is built as static libs +set(OpenCV_SHARED ON) + +# Enables mangled install paths, that help with side by side installs +set(OpenCV_USE_MANGLED_PATHS FALSE) + +set(OpenCV_LIB_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_world) +set(__OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include") + +set(OpenCV_INCLUDE_DIRS "") +foreach(d ${__OpenCV_INCLUDE_DIRS}) + get_filename_component(__d "${d}" REALPATH) + if(NOT EXISTS "${__d}") + if(NOT OpenCV_FIND_QUIETLY) + message(WARNING "OpenCV: Include directory doesn't exist: '${d}'. OpenCV installation may be broken. Skip...") + endif() + else() + list(APPEND OpenCV_INCLUDE_DIRS "${__d}") + endif() +endforeach() +unset(__d) + + +if(NOT TARGET opencv_core) + include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) +endif() + +if(NOT CMAKE_VERSION VERSION_LESS "2.8.11") + # Target property INTERFACE_INCLUDE_DIRECTORIES available since 2.8.11: + # * http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_tgt:INTERFACE_INCLUDE_DIRECTORIES + foreach(__component ${OpenCV_LIB_COMPONENTS}) + if(TARGET ${__component}) + set_target_properties( + ${__component} + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}" + ) + endif() + endforeach() +endif() + + +if(NOT DEFINED OPENCV_MAP_IMPORTED_CONFIG) + if(CMAKE_GENERATOR MATCHES "Visual Studio" OR MSVC) + # OpenCV supports Debug and Release builds only. + # But MSVS has 'RelWithDebInfo' 'MinSizeRel' configurations for applications. + # By default CMake maps these configuration on the first available (Debug) which is wrong. + # Non-Debug build of Application can't be used with OpenCV Debug build (ABI mismatch problem) + # Add mapping of RelWithDebInfo and MinSizeRel to Release here + set(OPENCV_MAP_IMPORTED_CONFIG "RELWITHDEBINFO=!Release;MINSIZEREL=!Release") + endif() +endif() +set(__remap_warnings "") +macro(ocv_map_imported_config target) + if(DEFINED OPENCV_MAP_IMPORTED_CONFIG) # list, "RELWITHDEBINFO=Release;MINSIZEREL=Release" + get_target_property(__available_configurations ${target} IMPORTED_CONFIGURATIONS) + foreach(remap ${OPENCV_MAP_IMPORTED_CONFIG}) + if(remap MATCHES "^(.+)=(!?)([^!]+)$") + set(__remap_config "${CMAKE_MATCH_1}") + set(__final_config "${CMAKE_MATCH_3}") + set(__force_flag "${CMAKE_MATCH_2}") + string(TOUPPER "${__final_config}" __final_config_upper) + string(TOUPPER "${__remap_config}" __remap_config_upper) + if(";${__available_configurations};" MATCHES ";${__remap_config_upper};" AND NOT "${__force_flag}" STREQUAL "!") + # configuration already exists, skip remap + set(__remap_warnings "${__remap_warnings}... Configuration already exists ${__remap_config} (skip mapping ${__remap_config} => ${__final_config}) (available configurations: ${__available_configurations})\n") + continue() + endif() + if(__available_configurations AND NOT ";${__available_configurations};" MATCHES ";${__final_config_upper};") + # skip, configuration is not available + if(NOT "${__force_flag}" STREQUAL "!") + set(__remap_warnings "${__remap_warnings}... Configuration is not available '${__final_config}' for ${target}, build may fail (available configurations: ${__available_configurations})\n") + endif() + endif() + set_target_properties(${target} PROPERTIES + MAP_IMPORTED_CONFIG_${__remap_config} "${__final_config}" + ) + else() + message(WARNING "Invalid entry of OPENCV_MAP_IMPORTED_CONFIG: '${remap}' (${OPENCV_MAP_IMPORTED_CONFIG})") + endif() + endforeach() + endif() +endmacro() + + +# ============================================================== +# Form list of modules (components) to find +# ============================================================== +if(NOT OpenCV_FIND_COMPONENTS) + set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS}) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java) + if(GTest_FOUND OR GTEST_FOUND) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts) + endif() +endif() + +set(OpenCV_WORLD_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio) + +# expand short module names and see if requested components exist +foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) + # Store the name of the original component so we can set the + # OpenCV__FOUND variable which can be checked by the user. + set (__original_cvcomponent ${__cvcomponent}) + if(NOT __cvcomponent MATCHES "^opencv_") + set(__cvcomponent opencv_${__cvcomponent}) + endif() + list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx) + if(__cvcomponentIdx LESS 0) + if(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + # Either the component is required or the user did not set any components at + # all. In the latter case, the OpenCV_FIND_REQUIRED_ variable + # will not be defined since it is not set by this config. So let's assume + # the implicitly set components are always required. + if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR + OpenCV_FIND_REQUIRED_${__original_cvcomponent}) + message(FATAL_ERROR "${__cvcomponent} is required but was not found") + elseif(NOT OpenCV_FIND_QUIETLY) + # The component was marked as optional using OPTIONAL_COMPONENTS + message(WARNING "Optional component ${__cvcomponent} was not found") + endif() + endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + #indicate that module is NOT found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND") + set(OpenCV_${__original_cvcomponent}_FOUND FALSE) + else() + # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet. + # Also not clearing OpenCV_LIBS anywhere, so that multiple calls + # to find_package(OpenCV) with different component lists add up. + set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}") + #indicate that module is found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND 1) + set(OpenCV_${__original_cvcomponent}_FOUND TRUE) + endif() + if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent}) + get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG) + get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE) + get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG) + get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE) + get_target_property(__include_dir opencv_world INTERFACE_INCLUDE_DIRECTORIES) + add_library(${__cvcomponent} SHARED IMPORTED) + set_target_properties(${__cvcomponent} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${__include_dir}") + if(__location_dbg) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_DEBUG "${__implib_dbg}" + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "" + IMPORTED_LOCATION_DEBUG "${__location_dbg}" + ) + endif() + if(__location_release) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_RELEASE "${__implib_release}" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" + IMPORTED_LOCATION_RELEASE "${__location_release}" + ) + endif() + endif() + if(TARGET ${__cvcomponent}) + ocv_map_imported_config(${__cvcomponent}) + endif() +endforeach() + +if(__remap_warnings AND NOT OpenCV_FIND_QUIETLY) + message("OpenCV: configurations remap warnings:\n${__remap_warnings}OpenCV: Check variable OPENCV_MAP_IMPORTED_CONFIG=${OPENCV_MAP_IMPORTED_CONFIG}") +endif() + +# ============================================================== +# Compatibility stuff +# ============================================================== +set(OpenCV_LIBRARIES ${OpenCV_LIBS}) + +# Require C++11 features for OpenCV modules +if(CMAKE_VERSION VERSION_LESS "3.1") + if(NOT OpenCV_FIND_QUIETLY AND NOT OPENCV_HIDE_WARNING_COMPILE_FEATURES) + message(STATUS "OpenCV: CMake version is low (${CMAKE_VERSION}, required 3.1+). Can't enable C++11 features: https://github.com/opencv/opencv/issues/13000") + endif() +else() + set(__target opencv_core) + if(TARGET opencv_world) + set(__target opencv_world) + endif() + set(__compile_features cxx_std_11) # CMake 3.8+ + if(DEFINED OPENCV_COMPILE_FEATURES) + set(__compile_features ${OPENCV_COMPILE_FEATURES}) # custom override + elseif(CMAKE_VERSION VERSION_LESS "3.8") + set(__compile_features cxx_auto_type cxx_rvalue_references cxx_lambdas) + endif() + if(__compile_features) + # Simulate exported result of target_compile_features(opencv_core PUBLIC ...) + set_target_properties(${__target} PROPERTIES + INTERFACE_COMPILE_FEATURES "${__compile_features}" + ) + endif() + unset(__target) + unset(__compile_features) +endif() + +# +# Some macros for samples +# +macro(ocv_check_dependencies) + set(OCV_DEPENDENCIES_FOUND TRUE) + foreach(d ${ARGN}) + if(NOT TARGET ${d}) + message(WARNING "OpenCV: Can't resolve dependency: ${d}") + set(OCV_DEPENDENCIES_FOUND FALSE) + break() + endif() + endforeach() +endmacro() + +# adds include directories in such way that directories from the OpenCV source tree go first +function(ocv_include_directories) + set(__add_before "") + file(TO_CMAKE_PATH "${OpenCV_INSTALL_PATH}" __baseDir) + foreach(dir ${ARGN}) + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + if("${__abs_dir}" MATCHES "^${__baseDir}") + list(APPEND __add_before "${dir}") + else() + include_directories(AFTER SYSTEM "${dir}") + endif() + endforeach() + include_directories(BEFORE ${__add_before}) +endfunction() + +macro(ocv_include_modules) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_include_modules_recurse) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_target_link_libraries) + target_link_libraries(${ARGN}) +endmacro() + +# remove all matching elements from the list +macro(ocv_list_filterout lst regex) + foreach(item ${${lst}}) + if(item MATCHES "${regex}") + list(REMOVE_ITEM ${lst} "${item}") + endif() + endforeach() +endmacro() + +# We do not actually need REQUIRED_VARS to be checked for. Just use the +# installation directory for the status. +find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH + VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS}) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules-debug.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules-debug.cmake new file mode 100644 index 0000000..9635f97 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules-debug.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Debug". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Debug" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455d.lib" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455d.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455d.lib" "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455d.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules-release.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules-release.cmake new file mode 100644 index 0000000..fa218f4 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Release" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455.lib" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc14/lib/opencv_world455.lib" "${_IMPORT_PREFIX}/x64/vc14/bin/opencv_world455.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules.cmake new file mode 100644 index 0000000..9ab8ae3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/OpenCVModules.cmake @@ -0,0 +1,90 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget opencv_world) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target opencv_world +add_library(opencv_world SHARED IMPORTED) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/OpenCVModules-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/opencv_world455.lib b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/opencv_world455.lib new file mode 100644 index 0000000..c35f130 Binary files /dev/null and b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/opencv_world455.lib differ diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/opencv_world455d.lib b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/opencv_world455d.lib new file mode 100644 index 0000000..f86c437 Binary files /dev/null and b/CigaretteSingle/OpenCV455Simple/win64/vc14/lib/opencv_world455d.lib differ diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVConfig-version.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVConfig-version.cmake new file mode 100644 index 0000000..435b7ec --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVConfig-version.cmake @@ -0,0 +1,15 @@ +set(OpenCV_VERSION 4.5.5) +set(PACKAGE_VERSION ${OpenCV_VERSION}) + +set(PACKAGE_VERSION_EXACT False) +set(PACKAGE_VERSION_COMPATIBLE False) + +if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT True) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() + +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 4 + AND PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVConfig.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVConfig.cmake new file mode 100644 index 0000000..b6bb809 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVConfig.cmake @@ -0,0 +1,355 @@ +# =================================================================================== +# The OpenCV CMake configuration file +# +# ** File generated automatically, do not modify ** +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(OpenCV REQUIRED) +# include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11 +# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS}) +# +# Or you can search for specific OpenCV modules: +# +# find_package(OpenCV REQUIRED core videoio) +# +# You can also mark OpenCV components as optional: + +# find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz) +# +# If the module is found then OPENCV__FOUND is set to TRUE. +# +# This file will define the following variables: +# - OpenCV_LIBS : The list of all imported targets for OpenCV modules. +# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. +# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability. +# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API. +# - OpenCV_VERSION : The version of this OpenCV build: "4.5.5" +# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "4" +# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "5" +# - OpenCV_VERSION_STATUS : Development status of this build: "" +# +# Advanced variables: +# - OpenCV_SHARED : Use OpenCV as shared library +# - OpenCV_INSTALL_PATH : OpenCV location +# - OpenCV_LIB_COMPONENTS : Present OpenCV modules list +# - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag +# +# Deprecated variables: +# - OpenCV_VERSION_TWEAK : Always "0" +# +# =================================================================================== + +# ====================================================== +# Version variables: +# ====================================================== +SET(OpenCV_VERSION 4.5.5) +SET(OpenCV_VERSION_MAJOR 4) +SET(OpenCV_VERSION_MINOR 5) +SET(OpenCV_VERSION_PATCH 5) +SET(OpenCV_VERSION_TWEAK 0) +SET(OpenCV_VERSION_STATUS "") + +include(FindPackageHandleStandardArgs) + +if(NOT CMAKE_VERSION VERSION_LESS 2.8.8 + AND OpenCV_FIND_COMPONENTS # prevent excessive output +) + # HANDLE_COMPONENTS was introduced in CMake 2.8.8 + list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS) + # The missing components will be handled by the FindPackageHandleStandardArgs + # module. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE) +else() + # The missing components will be handled by this config. + set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE) +endif() + +# Extract directory name from full path of the file currently being processed. +# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it +# for older versions of CMake to support these as well. +if(CMAKE_VERSION VERSION_LESS "2.8.3") + get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +endif() + +# Extract the directory where *this* file has been installed (determined at cmake run-time) +# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings +get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}" REALPATH) +get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../../" REALPATH) + +# Search packages for host system instead of packages for target system. +# in case of cross compilation this macro should be defined by toolchain file +if(NOT COMMAND find_host_package) + macro(find_host_package) + find_package(${ARGN}) + endmacro() +endif() +if(NOT COMMAND find_host_program) + macro(find_host_program) + find_program(${ARGN}) + endmacro() +endif() + + + + + + + + +# Some additional settings are required if OpenCV is built as static libs +set(OpenCV_SHARED ON) + +# Enables mangled install paths, that help with side by side installs +set(OpenCV_USE_MANGLED_PATHS FALSE) + +set(OpenCV_LIB_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_world) +set(__OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include") + +set(OpenCV_INCLUDE_DIRS "") +foreach(d ${__OpenCV_INCLUDE_DIRS}) + get_filename_component(__d "${d}" REALPATH) + if(NOT EXISTS "${__d}") + if(NOT OpenCV_FIND_QUIETLY) + message(WARNING "OpenCV: Include directory doesn't exist: '${d}'. OpenCV installation may be broken. Skip...") + endif() + else() + list(APPEND OpenCV_INCLUDE_DIRS "${__d}") + endif() +endforeach() +unset(__d) + + +if(NOT TARGET opencv_core) + include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) +endif() + +if(NOT CMAKE_VERSION VERSION_LESS "2.8.11") + # Target property INTERFACE_INCLUDE_DIRECTORIES available since 2.8.11: + # * http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_tgt:INTERFACE_INCLUDE_DIRECTORIES + foreach(__component ${OpenCV_LIB_COMPONENTS}) + if(TARGET ${__component}) + set_target_properties( + ${__component} + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}" + ) + endif() + endforeach() +endif() + + +if(NOT DEFINED OPENCV_MAP_IMPORTED_CONFIG) + if(CMAKE_GENERATOR MATCHES "Visual Studio" OR MSVC) + # OpenCV supports Debug and Release builds only. + # But MSVS has 'RelWithDebInfo' 'MinSizeRel' configurations for applications. + # By default CMake maps these configuration on the first available (Debug) which is wrong. + # Non-Debug build of Application can't be used with OpenCV Debug build (ABI mismatch problem) + # Add mapping of RelWithDebInfo and MinSizeRel to Release here + set(OPENCV_MAP_IMPORTED_CONFIG "RELWITHDEBINFO=!Release;MINSIZEREL=!Release") + endif() +endif() +set(__remap_warnings "") +macro(ocv_map_imported_config target) + if(DEFINED OPENCV_MAP_IMPORTED_CONFIG) # list, "RELWITHDEBINFO=Release;MINSIZEREL=Release" + get_target_property(__available_configurations ${target} IMPORTED_CONFIGURATIONS) + foreach(remap ${OPENCV_MAP_IMPORTED_CONFIG}) + if(remap MATCHES "^(.+)=(!?)([^!]+)$") + set(__remap_config "${CMAKE_MATCH_1}") + set(__final_config "${CMAKE_MATCH_3}") + set(__force_flag "${CMAKE_MATCH_2}") + string(TOUPPER "${__final_config}" __final_config_upper) + string(TOUPPER "${__remap_config}" __remap_config_upper) + if(";${__available_configurations};" MATCHES ";${__remap_config_upper};" AND NOT "${__force_flag}" STREQUAL "!") + # configuration already exists, skip remap + set(__remap_warnings "${__remap_warnings}... Configuration already exists ${__remap_config} (skip mapping ${__remap_config} => ${__final_config}) (available configurations: ${__available_configurations})\n") + continue() + endif() + if(__available_configurations AND NOT ";${__available_configurations};" MATCHES ";${__final_config_upper};") + # skip, configuration is not available + if(NOT "${__force_flag}" STREQUAL "!") + set(__remap_warnings "${__remap_warnings}... Configuration is not available '${__final_config}' for ${target}, build may fail (available configurations: ${__available_configurations})\n") + endif() + endif() + set_target_properties(${target} PROPERTIES + MAP_IMPORTED_CONFIG_${__remap_config} "${__final_config}" + ) + else() + message(WARNING "Invalid entry of OPENCV_MAP_IMPORTED_CONFIG: '${remap}' (${OPENCV_MAP_IMPORTED_CONFIG})") + endif() + endforeach() + endif() +endmacro() + + +# ============================================================== +# Form list of modules (components) to find +# ============================================================== +if(NOT OpenCV_FIND_COMPONENTS) + set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS}) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java) + if(GTest_FOUND OR GTEST_FOUND) + list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts) + endif() +endif() + +set(OpenCV_WORLD_COMPONENTS opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio) + +# expand short module names and see if requested components exist +foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) + # Store the name of the original component so we can set the + # OpenCV__FOUND variable which can be checked by the user. + set (__original_cvcomponent ${__cvcomponent}) + if(NOT __cvcomponent MATCHES "^opencv_") + set(__cvcomponent opencv_${__cvcomponent}) + endif() + list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx) + if(__cvcomponentIdx LESS 0) + if(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + # Either the component is required or the user did not set any components at + # all. In the latter case, the OpenCV_FIND_REQUIRED_ variable + # will not be defined since it is not set by this config. So let's assume + # the implicitly set components are always required. + if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR + OpenCV_FIND_REQUIRED_${__original_cvcomponent}) + message(FATAL_ERROR "${__cvcomponent} is required but was not found") + elseif(NOT OpenCV_FIND_QUIETLY) + # The component was marked as optional using OPTIONAL_COMPONENTS + message(WARNING "Optional component ${__cvcomponent} was not found") + endif() + endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY) + #indicate that module is NOT found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND") + set(OpenCV_${__original_cvcomponent}_FOUND FALSE) + else() + # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet. + # Also not clearing OpenCV_LIBS anywhere, so that multiple calls + # to find_package(OpenCV) with different component lists add up. + set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}") + #indicate that module is found + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND 1) + set(OpenCV_${__original_cvcomponent}_FOUND TRUE) + endif() + if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent}) + get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG) + get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE) + get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG) + get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE) + get_target_property(__include_dir opencv_world INTERFACE_INCLUDE_DIRECTORIES) + add_library(${__cvcomponent} SHARED IMPORTED) + set_target_properties(${__cvcomponent} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${__include_dir}") + if(__location_dbg) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_DEBUG "${__implib_dbg}" + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "" + IMPORTED_LOCATION_DEBUG "${__location_dbg}" + ) + endif() + if(__location_release) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_RELEASE "${__implib_release}" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" + IMPORTED_LOCATION_RELEASE "${__location_release}" + ) + endif() + endif() + if(TARGET ${__cvcomponent}) + ocv_map_imported_config(${__cvcomponent}) + endif() +endforeach() + +if(__remap_warnings AND NOT OpenCV_FIND_QUIETLY) + message("OpenCV: configurations remap warnings:\n${__remap_warnings}OpenCV: Check variable OPENCV_MAP_IMPORTED_CONFIG=${OPENCV_MAP_IMPORTED_CONFIG}") +endif() + +# ============================================================== +# Compatibility stuff +# ============================================================== +set(OpenCV_LIBRARIES ${OpenCV_LIBS}) + +# Require C++11 features for OpenCV modules +if(CMAKE_VERSION VERSION_LESS "3.1") + if(NOT OpenCV_FIND_QUIETLY AND NOT OPENCV_HIDE_WARNING_COMPILE_FEATURES) + message(STATUS "OpenCV: CMake version is low (${CMAKE_VERSION}, required 3.1+). Can't enable C++11 features: https://github.com/opencv/opencv/issues/13000") + endif() +else() + set(__target opencv_core) + if(TARGET opencv_world) + set(__target opencv_world) + endif() + set(__compile_features cxx_std_11) # CMake 3.8+ + if(DEFINED OPENCV_COMPILE_FEATURES) + set(__compile_features ${OPENCV_COMPILE_FEATURES}) # custom override + elseif(CMAKE_VERSION VERSION_LESS "3.8") + set(__compile_features cxx_auto_type cxx_rvalue_references cxx_lambdas) + endif() + if(__compile_features) + # Simulate exported result of target_compile_features(opencv_core PUBLIC ...) + set_target_properties(${__target} PROPERTIES + INTERFACE_COMPILE_FEATURES "${__compile_features}" + ) + endif() + unset(__target) + unset(__compile_features) +endif() + +# +# Some macros for samples +# +macro(ocv_check_dependencies) + set(OCV_DEPENDENCIES_FOUND TRUE) + foreach(d ${ARGN}) + if(NOT TARGET ${d}) + message(WARNING "OpenCV: Can't resolve dependency: ${d}") + set(OCV_DEPENDENCIES_FOUND FALSE) + break() + endif() + endforeach() +endmacro() + +# adds include directories in such way that directories from the OpenCV source tree go first +function(ocv_include_directories) + set(__add_before "") + file(TO_CMAKE_PATH "${OpenCV_INSTALL_PATH}" __baseDir) + foreach(dir ${ARGN}) + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + if("${__abs_dir}" MATCHES "^${__baseDir}") + list(APPEND __add_before "${dir}") + else() + include_directories(AFTER SYSTEM "${dir}") + endif() + endforeach() + include_directories(BEFORE ${__add_before}) +endfunction() + +macro(ocv_include_modules) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_include_modules_recurse) + include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") +endmacro() + +macro(ocv_target_link_libraries) + target_link_libraries(${ARGN}) +endmacro() + +# remove all matching elements from the list +macro(ocv_list_filterout lst regex) + foreach(item ${${lst}}) + if(item MATCHES "${regex}") + list(REMOVE_ITEM ${lst} "${item}") + endif() + endforeach() +endmacro() + +# We do not actually need REQUIRED_VARS to be checked for. Just use the +# installation directory for the status. +find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH + VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS}) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules-debug.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules-debug.cmake new file mode 100644 index 0000000..eb122cc --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules-debug.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Debug". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Debug" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455d.lib" + IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455d.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455d.lib" "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455d.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules-release.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules-release.cmake new file mode 100644 index 0000000..38d533a --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules-release.cmake @@ -0,0 +1,19 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "opencv_world" for configuration "Release" +set_property(TARGET opencv_world APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(opencv_world PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455.lib" + IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS opencv_world ) +list(APPEND _IMPORT_CHECK_FILES_FOR_opencv_world "${_IMPORT_PREFIX}/x64/vc15/lib/opencv_world455.lib" "${_IMPORT_PREFIX}/x64/vc15/bin/opencv_world455.dll" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules.cmake b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules.cmake new file mode 100644 index 0000000..9ab8ae3 --- /dev/null +++ b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/OpenCVModules.cmake @@ -0,0 +1,90 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget opencv_world) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Compute the installation prefix relative to this file. +get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target opencv_world +add_library(opencv_world SHARED IMPORTED) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/OpenCVModules-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/opencv_world455.lib b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/opencv_world455.lib new file mode 100644 index 0000000..752add0 Binary files /dev/null and b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/opencv_world455.lib differ diff --git a/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/opencv_world455d.lib b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/opencv_world455d.lib new file mode 100644 index 0000000..9fdee19 Binary files /dev/null and b/CigaretteSingle/OpenCV455Simple/win64/vc15/lib/opencv_world455d.lib differ diff --git a/CigaretteSingle/Queue/ASyncQueue.cpp b/CigaretteSingle/Queue/ASyncQueue.cpp new file mode 100644 index 0000000..0c8a81b --- /dev/null +++ b/CigaretteSingle/Queue/ASyncQueue.cpp @@ -0,0 +1,4 @@ +//异步阻塞队列 +#include "ASyncQueue.h" + + diff --git a/CigaretteSingle/Queue/ASyncQueue.h b/CigaretteSingle/Queue/ASyncQueue.h new file mode 100644 index 0000000..b4d004e --- /dev/null +++ b/CigaretteSingle/Queue/ASyncQueue.h @@ -0,0 +1,81 @@ +#pragma once +#include +//#include +#include +#include + +using namespace std; + +template class ASyncQueue +{ +public: + ASyncQueue(int max_size); + ~ASyncQueue(); + void put(const T& val); + void take(T& val); + void clear(); + bool isEmpty(); + bool isFull(); + int count(); +public: + string name; +private: + mutex lock; + //condition_variable_any cv_full, cv_empty; + list q; + int size; + int max_size; +}; + +using namespace std; + +template +ASyncQueue::ASyncQueue(int max_size) :max_size(max_size) +{ +} + +template +ASyncQueue::~ASyncQueue() +{ +} + +template +void ASyncQueue::put(const T& val) +{ + lock_guard locker(lock); + q.emplace_back(val); +} + +template +void ASyncQueue::take(T& val) +{ + lock_guard locker(lock); + val = q.front(); + q.pop_front(); +} + +template +void ASyncQueue::clear() +{ + lock_guard locker(lock); + q.clear(); +} + +template +bool ASyncQueue::isEmpty() +{ + return q.size() == 0; +} + +template +bool ASyncQueue::isFull() +{ + return q.size() == max_size; +} + +template +int ASyncQueue::count() +{ + lock_guard locker(lock); + return q.size(); +} \ No newline at end of file diff --git a/CigaretteSingle/Queue/SyncQueue.cpp b/CigaretteSingle/Queue/SyncQueue.cpp new file mode 100644 index 0000000..048650d --- /dev/null +++ b/CigaretteSingle/Queue/SyncQueue.cpp @@ -0,0 +1,4 @@ +//同步阻塞队列 +#include "SyncQueue.h" + + diff --git a/CigaretteSingle/Queue/SyncQueue.h b/CigaretteSingle/Queue/SyncQueue.h new file mode 100644 index 0000000..3faf4fd --- /dev/null +++ b/CigaretteSingle/Queue/SyncQueue.h @@ -0,0 +1,95 @@ +#pragma once +#include +#include +#include +#include + +using namespace std; + +template class SyncQueue +{ +public: + SyncQueue(int max_size); + ~SyncQueue(); + void put(const T& val); + void take(T& val); + void clear(); + bool isEmpty(); + bool isFull(); + int count(); +public: + string name; +private: + mutex lock; + condition_variable_any cv_full, cv_empty; + list q; + int size; + int max_size; +}; + +using namespace std; + +template +SyncQueue::SyncQueue(int max_size) :max_size(max_size) +{ +} + +template +SyncQueue::~SyncQueue() +{ +} + +template +void SyncQueue::put(const T& val) +{ + lock_guard locker(lock); + while (isFull()) + { + //cout << "\nQueue " << name << " is full now, wait a minute!" << endl; + cv_full.wait(lock); + } + q.emplace_back(val); + cv_empty.notify_one(); + //cout << " Put image success " << endl; +} + +template +void SyncQueue::take(T& val) +{ + lock_guard locker(lock); + while (isEmpty()) + { + //cout << "\nQueue "<< name << " is empty now, wait a minute!" << endl; + cv_empty.wait(lock); + } + val = q.front(); + q.pop_front(); + cv_full.notify_one(); + //cout << " Take image success "<< endl; +} + +template +void SyncQueue::clear() +{ + lock_guard locker(lock); + q.clear(); +} + +template +bool SyncQueue::isEmpty() +{ + return q.size() == 0; +} + +template +bool SyncQueue::isFull() +{ + return q.size() == max_size; +} + +template +int SyncQueue::count() +{ + lock_guard locker(lock); + return q.size(); +} \ No newline at end of file diff --git a/CigaretteSingle/Resources/alarm.png b/CigaretteSingle/Resources/alarm.png new file mode 100644 index 0000000..a90260e Binary files /dev/null and b/CigaretteSingle/Resources/alarm.png differ diff --git a/CigaretteSingle/Resources/cam1.png b/CigaretteSingle/Resources/cam1.png new file mode 100644 index 0000000..b58f399 Binary files /dev/null and b/CigaretteSingle/Resources/cam1.png differ diff --git a/CigaretteSingle/Resources/cam1_no.png b/CigaretteSingle/Resources/cam1_no.png new file mode 100644 index 0000000..df64b79 Binary files /dev/null and b/CigaretteSingle/Resources/cam1_no.png differ diff --git a/CigaretteSingle/Resources/cam1_yes.png b/CigaretteSingle/Resources/cam1_yes.png new file mode 100644 index 0000000..cc5cdf5 Binary files /dev/null and b/CigaretteSingle/Resources/cam1_yes.png differ diff --git a/CigaretteSingle/Resources/cam2.png b/CigaretteSingle/Resources/cam2.png new file mode 100644 index 0000000..5bc7613 Binary files /dev/null and b/CigaretteSingle/Resources/cam2.png differ diff --git a/CigaretteSingle/Resources/cam2_no.png b/CigaretteSingle/Resources/cam2_no.png new file mode 100644 index 0000000..9b1c83b Binary files /dev/null and b/CigaretteSingle/Resources/cam2_no.png differ diff --git a/CigaretteSingle/Resources/cam2_yes.png b/CigaretteSingle/Resources/cam2_yes.png new file mode 100644 index 0000000..51f30c9 Binary files /dev/null and b/CigaretteSingle/Resources/cam2_yes.png differ diff --git a/CigaretteSingle/Resources/cam3.png b/CigaretteSingle/Resources/cam3.png new file mode 100644 index 0000000..a132efe Binary files /dev/null and b/CigaretteSingle/Resources/cam3.png differ diff --git a/CigaretteSingle/Resources/cam3_no.png b/CigaretteSingle/Resources/cam3_no.png new file mode 100644 index 0000000..a4bb3eb Binary files /dev/null and b/CigaretteSingle/Resources/cam3_no.png differ diff --git a/CigaretteSingle/Resources/cam3_yes.png b/CigaretteSingle/Resources/cam3_yes.png new file mode 100644 index 0000000..5d523bf Binary files /dev/null and b/CigaretteSingle/Resources/cam3_yes.png differ diff --git a/CigaretteSingle/Resources/cam4.png b/CigaretteSingle/Resources/cam4.png new file mode 100644 index 0000000..28c08de Binary files /dev/null and b/CigaretteSingle/Resources/cam4.png differ diff --git a/CigaretteSingle/Resources/cam4_no.png b/CigaretteSingle/Resources/cam4_no.png new file mode 100644 index 0000000..a3b3f8a Binary files /dev/null and b/CigaretteSingle/Resources/cam4_no.png differ diff --git a/CigaretteSingle/Resources/cam4_yes.png b/CigaretteSingle/Resources/cam4_yes.png new file mode 100644 index 0000000..7a2aa1d Binary files /dev/null and b/CigaretteSingle/Resources/cam4_yes.png differ diff --git a/CigaretteSingle/Resources/cam5_no.png b/CigaretteSingle/Resources/cam5_no.png new file mode 100644 index 0000000..5e7660c Binary files /dev/null and b/CigaretteSingle/Resources/cam5_no.png differ diff --git a/CigaretteSingle/Resources/cam5_yes.png b/CigaretteSingle/Resources/cam5_yes.png new file mode 100644 index 0000000..47aad92 Binary files /dev/null and b/CigaretteSingle/Resources/cam5_yes.png differ diff --git a/CigaretteSingle/Resources/cam6_no.png b/CigaretteSingle/Resources/cam6_no.png new file mode 100644 index 0000000..b4d1cb6 Binary files /dev/null and b/CigaretteSingle/Resources/cam6_no.png differ diff --git a/CigaretteSingle/Resources/cam6_yes.png b/CigaretteSingle/Resources/cam6_yes.png new file mode 100644 index 0000000..44438c1 Binary files /dev/null and b/CigaretteSingle/Resources/cam6_yes.png differ diff --git a/CigaretteSingle/Resources/cam7_no.png b/CigaretteSingle/Resources/cam7_no.png new file mode 100644 index 0000000..c7c18c8 Binary files /dev/null and b/CigaretteSingle/Resources/cam7_no.png differ diff --git a/CigaretteSingle/Resources/cam7_yes.png b/CigaretteSingle/Resources/cam7_yes.png new file mode 100644 index 0000000..4f2924a Binary files /dev/null and b/CigaretteSingle/Resources/cam7_yes.png differ diff --git a/CigaretteSingle/Resources/cam8_no.png b/CigaretteSingle/Resources/cam8_no.png new file mode 100644 index 0000000..775e21f Binary files /dev/null and b/CigaretteSingle/Resources/cam8_no.png differ diff --git a/CigaretteSingle/Resources/cam8_yes.png b/CigaretteSingle/Resources/cam8_yes.png new file mode 100644 index 0000000..0d7ba2f Binary files /dev/null and b/CigaretteSingle/Resources/cam8_yes.png differ diff --git a/CigaretteSingle/Resources/exit.png b/CigaretteSingle/Resources/exit.png new file mode 100644 index 0000000..ffd4acb Binary files /dev/null and b/CigaretteSingle/Resources/exit.png differ diff --git a/CigaretteSingle/Resources/keyboard.png b/CigaretteSingle/Resources/keyboard.png new file mode 100644 index 0000000..bebfa28 Binary files /dev/null and b/CigaretteSingle/Resources/keyboard.png differ diff --git a/CigaretteSingle/Resources/lock.png b/CigaretteSingle/Resources/lock.png new file mode 100644 index 0000000..7651853 Binary files /dev/null and b/CigaretteSingle/Resources/lock.png differ diff --git a/CigaretteSingle/Resources/logo.png b/CigaretteSingle/Resources/logo.png new file mode 100644 index 0000000..15fe2a2 Binary files /dev/null and b/CigaretteSingle/Resources/logo.png differ diff --git a/CigaretteSingle/Resources/pause.png b/CigaretteSingle/Resources/pause.png new file mode 100644 index 0000000..2d359a6 Binary files /dev/null and b/CigaretteSingle/Resources/pause.png differ diff --git a/CigaretteSingle/Resources/plc.png b/CigaretteSingle/Resources/plc.png new file mode 100644 index 0000000..1504bdc Binary files /dev/null and b/CigaretteSingle/Resources/plc.png differ diff --git a/CigaretteSingle/Resources/rotate.png b/CigaretteSingle/Resources/rotate.png new file mode 100644 index 0000000..41449a8 Binary files /dev/null and b/CigaretteSingle/Resources/rotate.png differ diff --git a/CigaretteSingle/Resources/setup.png b/CigaretteSingle/Resources/setup.png new file mode 100644 index 0000000..59db0d0 Binary files /dev/null and b/CigaretteSingle/Resources/setup.png differ diff --git a/CigaretteSingle/Resources/start.png b/CigaretteSingle/Resources/start.png new file mode 100644 index 0000000..da3be3d Binary files /dev/null and b/CigaretteSingle/Resources/start.png differ diff --git a/CigaretteSingle/Resources/unlock.png b/CigaretteSingle/Resources/unlock.png new file mode 100644 index 0000000..88bf476 Binary files /dev/null and b/CigaretteSingle/Resources/unlock.png differ diff --git a/CigaretteSingle/WorkThread/savethread.h b/CigaretteSingle/WorkThread/savethread.h new file mode 100644 index 0000000..0b24180 --- /dev/null +++ b/CigaretteSingle/WorkThread/savethread.h @@ -0,0 +1,94 @@ +#ifndef SAVE_THREAD_H +#define SAVE_THREAD_H +#include +#include +#include +#include "SyncQueue.h" +#include "common.h" +#include +#include +#include + +#include + +#include +#include + +class SaveThread : public QThread +{ + Q_OBJECT +signals: + + +public: + SaveThread(QObject *parent = 0): QThread(parent) + { + + } + ~SaveThread() + { + stop(); + p_save_queue->put(std::make_pair("", cv::Mat())); + quit(); + wait(); + } + + void init(SyncQueue > *p_save_queue_) + { + p_save_queue = p_save_queue_; + b_quit = false; + } + void start_work() + { + start(HighestPriority); + } + void stop() + { + b_quit = true; + } +protected: + void run() + { + while (!b_quit) { + cv::Mat image; + std::pair element; + p_save_queue->take(element); + std::string file_name = element.first; + //std::cout << file_name << std::endl; + image = element.second; + if (image.data) + { + std::size_t found = file_name.find_last_of("/\\"); + std::string dir_path = file_name.substr(0, found); + check_save_dir(dir_path); + bool b_save = cv::imwrite(file_name, image); + } + } + } + void check_save_dir(std::string dir_path) + { + bool b_find = false; + for (int i = 0; i < vec_save_dirs.size(); i++) + { + if (dir_path == vec_save_dirs[i]) + { + b_find = true; + } + } + if (!b_find) + { + QString dir_str = QString::fromStdString(dir_path); + QDir dir; + if (!dir.exists(dir_str)) + { + dir.mkpath(dir_str); + } + vec_save_dirs.push_back(dir_path); + } + } +public: + bool b_quit; + std::vector vec_save_dirs; + SyncQueue > *p_save_queue; +}; +#endif diff --git a/CigaretteSingle/WorkThread/workthread.cpp b/CigaretteSingle/WorkThread/workthread.cpp new file mode 100644 index 0000000..b63a5c0 --- /dev/null +++ b/CigaretteSingle/WorkThread/workthread.cpp @@ -0,0 +1,58 @@ +#include "workthread.h" +#include "common.h" + +WorkThread::~WorkThread() +{ + stop(); + p_image_queue->put(cv::Mat()); + quit(); + wait(); +} + +void WorkThread::init() +{ + b_quit = false; +} +void WorkThread::start_work() +{ + start(HighestPriority); +} +void WorkThread::stop() +{ + b_quit = true; +} + +void WorkThread::run() +{ + uint32_t result_index = 0; + while (!b_quit) { + + std::pair element; + cv::Mat image; + p_image_queue->take(image); + + if (!image.data) + { + continue; + } + + if (0) + { + if (image.data) + { + QDateTime now_ts = QDateTime::currentDateTime(); + QString file_name = "EmpiricalData/" + + now_ts.toString("yyyy-MM-dd") + + now_ts.toString("HH-mm-ss_zzz_") + ".jpg"; + p_save_queue->put(std::make_pair(file_name.toStdString(), image)); + } + } + + cv::Mat output_image; + m_alg_ptr->process(image,output_image); + + + emit display_image(image); + + } +} \ No newline at end of file diff --git a/CigaretteSingle/WorkThread/workthread.h b/CigaretteSingle/WorkThread/workthread.h new file mode 100644 index 0000000..ff1ee23 --- /dev/null +++ b/CigaretteSingle/WorkThread/workthread.h @@ -0,0 +1,35 @@ +#pragma once +#include +#include +#include +#include +#include "SyncQueue.h" +#include "ASyncQueue.h" +#include "common.h" +#include +#include "alg.h" +class WorkThread : public QThread +{ + Q_OBJECT +signals: + void display_image(cv::Mat); + +public: + WorkThread(QObject *parent = 0): QThread(parent) + { + + } + ~WorkThread(); + + void init(); + void start_work(); + void stop(); +protected: + void run(); +public: + SyncQueue >* p_save_queue; + SyncQueue* p_image_queue; + ASyncQueue* p_result_queue; + Alg* m_alg_ptr; + bool b_quit; +}; diff --git a/CigaretteSingle/alg.cpp b/CigaretteSingle/alg.cpp new file mode 100644 index 0000000..3c6d2e4 --- /dev/null +++ b/CigaretteSingle/alg.cpp @@ -0,0 +1,392 @@ +#include +#include "alg.h" +#include "AlgCommon.h" + +/* +ͼʽ˵ +1.Ϊͼʼ +һһֱ£ֱƶĿɿһνͼ +ƶĿٴһνͼ +ڽͼУҼȡνͼ״̬ +2.ͼб棬ͼԵҼȡһεĽͼ +洢ʽһǽͼɺٴνͼ״̬Զ洢һֽͼ +洢ʽһԭʼͼƬһԭʼͼƬδһֽͼԶ洢 +*/ + + +#define MIN_ROI_AREA 300 //ЧͼС + +//ȫֱ +static cv::Point g_pt; //洢һΰµ꣬ͼϽꣻ +static cv::Mat g_img_src; //洢ǰԭʼͼ +static cv::Mat g_img_dst; //洢ͼʵʱͼ +static cv::Mat g_img_roi; //洢ͼʱľֲͼ +static cv::Rect roi_area; //洢ͼʱľֲͼ +static bool g_flag = false; //ǷѴڽͼ״̬ıʾ +static bool g_issave = false; //ǷѾδ洢Ļroiıʾ +static std::string g_window_name = "image";// + +//ȡroiͼ +void save_roi(cv::Mat image) +{ + //·imwrite()ԣ +} + +// Ļص +static void onMouse(int event, int x, int y, int, void*) +{ + //¼ + if (cv::EVENT_LBUTTONDOWN == event) + { + //ǰǽͼ״̬ͼ״̬ǰΪʼ㲢洢 + if (g_flag == false) + { + //ͼ״̬ + g_flag = true; + //洢ͼʼ + g_pt = cv::Point(x, y); + + //δһroiı棬д洢 + if (g_issave == true) + { + save_roi(g_img_roi); + g_issave = false; + } + } + //ǰڽͼ״̬ͼ״̬ȡroi + if (g_flag == true && abs(x - g_pt.x)*abs(y - g_pt.y) > MIN_ROI_AREA) + { + //ͼ״̬ + g_flag = false; + // ýͼg_img_roi + roi_area = cv::Rect(g_pt, cv::Point(x, y)); + g_img_src(roi_area).copyTo(g_img_roi); + //cv::imshow("roi", g_img_roi); + g_issave = true; + } + }//if(CV_EVENT_LBUTTONDOWN == event) + + //ƶ¼ڽͼ״̬ʱ + else if (cv::EVENT_MOUSEMOVE == event && g_flag) + { + //³ʼg_img_dstȷg_img_dstʼֻһ + g_img_src.copyTo(g_img_dst); + cv::rectangle(g_img_dst, g_pt, cv::Point(x, y), cv::Scalar(255, 0, 0), 3, 8); + cv::imshow(g_window_name, g_img_dst); + } + + //ɿ¼ + else if (cv::EVENT_LBUTTONUP == event && + abs(x - g_pt.x)*abs(y - g_pt.y) > MIN_ROI_AREA) + { + //ͼ״̬ + g_flag = false; + //ȡroi + roi_area = cv::Rect(g_pt, cv::Point(x, y)); + g_img_src(roi_area).copyTo(g_img_roi); + //cv::imshow("roi", g_img_roi); + g_issave = true; + } + + //Ҽ¼ + else if (cv::EVENT_RBUTTONDOWN == event) + { + //ڽͼ״̬ȡͼ״̬ + if (g_flag == true) + { + g_flag = false; + //ͼ + cv::imshow(g_window_name, g_img_src); + } + //ڽͼ״̬ЧһֵĽͼ棻 + if (g_flag == false) + { + g_issave = false; + //ͼ + cv::imshow(g_window_name, g_img_src); + //رվֲ + //cv::destroyWindow("roi"); + } + } +} + +bool inline getMinMax(std::vector &points, cv::Point3i &min, cv::Point3i &max) +{ + int minx = 0, miny = 0, minz = 0; + int maxx = 0, maxy = 0, maxz = 0; + + for (int i = 0; i < points.size(); i++) { + if (points[i].x < minx)minx = points[i].x; + if (points[i].y < miny)miny = points[i].y; + if (points[i].z < minz)minz = points[i].z; + if (points[i].x > maxx)maxx = points[i].x; + if (points[i].y > maxy)maxy = points[i].y; + if (points[i].z > maxz)maxz = points[i].z; + } + + min.x = minx; + min.y = miny; + min.z = minz; + max.x = maxx; + max.y = maxy; + max.z = maxz; + + return true; +} + +bool Alg::ScreenShot(cv::Mat imgfull) +{ + cv::namedWindow(g_window_name, cv::WINDOW_AUTOSIZE); + cv::setMouseCallback(g_window_name, onMouse, 0); + cv::Mat img = imgfull; + + if (img.empty()) + { + std::cout << "empty image" << std::endl; + return false; + } + //洢ԭʼͼ + g_img_src = img.clone(); + cv::imshow(g_window_name, g_img_src); + + while (1) { + cv::waitKey(100); + if(g_issave)break; + } + //ͼѡ񴰿 + cv::destroyWindow(g_window_name); + + img = g_img_roi.clone(); + if (img.empty()) + { + std::cout << "empty roi image" << std::endl; + return false; + } + + RefRect = roi_area; + return true; +} + +//*****************ͼλ******************* +void dftshift(cv::Mat &img_r, cv::Mat &img_i) +{ + int cx = img_r.cols / 2; + int cy = img_r.rows / 2;//µIJƶͼ (ƵƵ) + cv::Mat part1_r(img_r, cv::Rect(0, 0, cx, cy)); //ԪʾΪ(cx,cy) + cv::Mat part2_r(img_r, cv::Rect(cx, 0, cx, cy)); + cv::Mat part3_r(img_r, cv::Rect(0, cy, cx, cy)); + cv::Mat part4_r(img_r, cv::Rect(cx, cy, cx, cy)); + + cv::Mat temp; + part1_r.copyTo(temp); //½λ(ʵ) + part4_r.copyTo(part1_r); + temp.copyTo(part4_r); + + part2_r.copyTo(temp); //½λ(ʵ) + part3_r.copyTo(part2_r); + temp.copyTo(part3_r); + + cv::Mat part1_i(img_i, cv::Rect(0, 0, cx, cy)); //Ԫ(cx,cy) + cv::Mat part2_i(img_i, cv::Rect(cx, 0, cx, cy)); + cv::Mat part3_i(img_i, cv::Rect(0, cy, cx, cy)); + cv::Mat part4_i(img_i, cv::Rect(cx, cy, cx, cy)); + + part1_i.copyTo(temp); //½λ(鲿) + part4_i.copyTo(part1_i); + temp.copyTo(part4_i); + + part2_i.copyTo(temp); //½λ(鲿) + part3_i.copyTo(part2_i); + temp.copyTo(part3_i); +} +//*****************Ƶ˲******************* +cv::Mat freqfilt(cv::Mat &scr, cv::Mat &blur) +{ + cv::Mat img_r = scr.clone(); + cv::Mat img_i = cv::Mat::zeros(scr.size(), CV_32FC1); + //***********************DFT******************* + cv::Mat plane[] = { img_r, img_i}; //ͨ洢dftʵ鲿CV_32FΪͨ + cv::Mat complexIm; + merge(plane, 2, complexIm);//ϲͨ ϲΪһ2ͨMat + dft(complexIm, complexIm);//иҶ任 + + //***************Ļ******************** + split(complexIm, plane);//ͨ룩 + //plane[0] = plane[0](cv::Rect(0, 0, plane[0].cols & -2, plane[0].rows & -2));//Ϊʲô&-2鿴opencvĵ +// //ʵΪ˰кбż -2Ķ11111111.......10 һλ0 + dftshift(plane[0], plane[1]); + + //*****************˲DFTij˻**************** + cv::Mat BLUR; + { + cv::Mat blur_r, blur_i; + multiply(plane[0], blur, blur_r); //˲ʵ˲ģӦԪˣ + multiply(plane[1], blur, blur_i);//˲鲿˲ģӦԪˣ + cv::Mat plane1[] = { blur_r, blur_i }; + merge(plane1, 2, BLUR);//ʵ鲿ϲ + } + //*********************õԭͼƵͼ*********************************** + //magnitude(plane[0], plane[1], plane[0]);//ȡͼ0ͨΪʵͨ1Ϊ鲿ΪάҶ任Ǹ + //plane[0] += cv::Scalar::all(1); //Ҷ任ͼƬ÷жȽϺÿ + //log(plane[0], plane[0]); // float͵ĻҶȿռΪ[01]) + //normalize(plane[0], plane[0], 1, 0, cv::NORM_MINMAX); //һʾ + //cv::Mat iiimg=plane[0]; + //imshow("ԭͼƵͼ",plane[0]); + + idft(BLUR, BLUR); //idftҲΪ + split(BLUR, plane);//ͨҪȡͨ + magnitude(plane[0], plane[1], plane[0]); //ֵ(ģ) + normalize(plane[0], plane[0], 1, 0, cv::NORM_MINMAX); //һʾ + return plane[0];//ز +} + +cv::Mat ideal_lbrf_kernel(cv::Mat &scr, float sigma) +{ + cv::Mat ideal_low_pass(scr.size(), CV_32FC1); //CV_32FC1 + cv::Mat gauss_low_pass(scr.size(), CV_32FC1); //CV_32FC1 + cv::Mat gauss_high_pass(scr.size(), CV_32FC1); //CV_32FC1 + ////*****************ͨ˲*********************** + //float d0 = sigma;//뾶D0ԽСģԽ󣻰뾶D0ԽģԽС + //for (int i = 0; i < scr.rows; i++) { + // for (int j = 0; j < scr.cols; j++) { + // double d = sqrt(pow((i - scr.rows / 2), 2) + pow((j - scr.cols / 2), 2));//,Ƶĵľ,powΪfloat + // if (d <= d0) { + // ideal_low_pass.at(i, j) = 1; + // } + // else { + // ideal_low_pass.at(i, j) = 0; + // } + // } + //} + //std::string name = "ͨ˲d0=" + std::to_string(sigma); + //*****************˹ͨͨ˲*********************** + //float sigma_gauss_low = sigma; + //for (int i = 0; i < scr.rows; i++) { + // for (int j = 0; j < scr.cols; j++) { + // double d = sqrt(pow((i - scr.rows / 2), 2) + pow((j - scr.cols / 2), 2));//,powΪfloat + // double gauss_value = -1 * pow(d, 2) / (2 * pow(sigma_gauss_low, 2)); + // gauss_value = pow(2.718281828459, gauss_value); + // gauss_low_pass.at(i, j) = gauss_value; + // } + //} + //name = "˹ͨ˲d0=" + std::to_string(sigma); + //*****************˹ͨͨ˲*********************** + float sigma_gauss_high = sigma; + for (int i = 0; i < scr.rows; i++) { + for (int j = 0; j < scr.cols; j++) { + double d = sqrt(pow((i - scr.rows / 2), 2) + pow((j - scr.cols / 2), 2));//,powΪfloat + double gauss_value = -1 * pow(d, 2) / (2 * pow(sigma_gauss_high, 2)); + gauss_value = pow(2.718281828459, gauss_value); + gauss_high_pass.at(i, j) = 1-gauss_value; + } + } + //name = "˹ͨ˲d0=" + std::to_string(sigma); + + return gauss_high_pass; +} + +cv::Mat ideal_Low_Pass_Filter(cv::Mat &src, float sigma) +{ + int M = cv::getOptimalDFTSize(src.rows); + int N = cv::getOptimalDFTSize(src.cols); + cv::Mat padded; //ͼٸҶ任 + copyMakeBorder(src, padded, 0, M - src.rows, 0, N - src.cols, cv::BORDER_CONSTANT, cv::Scalar::all(0)); + padded.convertTo(padded, CV_32FC1); //ͼתΪflaot + + cv::Mat ideal_kernel = ideal_lbrf_kernel(padded, sigma);//ͨ˲ + cv::Mat result = freqfilt(padded, ideal_kernel); + return result; +} + +void Alg::process_2dfft(cv::Mat &input,cv::Mat &output) +{ + double t = (double)cv::getTickCount(); + + cv::Mat img_clone = input.clone(); + resize(img_clone, input,cv::Size(512,512)); + cv::Mat img_thr; + threshold(img_clone, img_thr, 200, 255, cv::THRESH_TOZERO_INV); + threshold(img_thr, img_thr, 50, 255, cv::THRESH_BINARY); + + cv::Mat pro_src = img_thr.clone(); + fistEROthenDIL(pro_src,3, 3); + // + double maxarea = 0; + int maxAreaIdx = 0; + std::vector > contours_pre; + std::vector < cv::Vec4i > hierarchy_pre; + cv::findContours(pro_src, contours_pre, hierarchy_pre, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); + for (int i = 0; i < contours_pre.size(); i++) + { + double tmparea = fabs(contourArea(contours_pre[i])); + if (tmparea > maxarea) + { + maxarea = tmparea; + maxAreaIdx = i;//¼ + } + } + + cv::Mat second_input; + if (contours_pre.size()) + { + cv::Rect rect_pre = cv::boundingRect(contours_pre[maxAreaIdx]); + second_input = img_clone(rect_pre).clone(); + } + else + { + second_input = img_clone; + } + + + cv::Mat ideal = ideal_Low_Pass_Filter(second_input, 30); + ideal = ideal(cv::Rect(0, 0, second_input.cols, second_input.rows)); + + cv::Mat third_input; + normalize(ideal, third_input, 0, 255, cv::NORM_MINMAX); + third_input.convertTo(third_input, CV_8UC1); + threshold(third_input, third_input, 10, 255, cv::THRESH_BINARY); + fistEROthenDIL(third_input, 3, 5); + + output = third_input.clone(); + cv::waitKey(1); + + t = ((double)cv::getTickCount() - t) / cv::getTickFrequency(); + std::cout << "cost time\t" << t <<" s" << std::endl; +} + +bool Alg::process_bool(cv::Mat &input, cv::Mat &output) +{ + double t = (double)cv::getTickCount(); + + cv::Mat img_clone = input.clone(); + cv::Mat img_input; + threshold(img_clone, img_clone, 200, 0, cv::THRESH_TOZERO_INV); + threshold(img_clone, img_input, 90, 0, cv::THRESH_TOZERO); + // third_input.convertTo(third_input, CV_8UC1); + + fistEROthenDIL(img_input, 13, 13); + + // output = third_input.clone(); + + // // + // cv::Mat temp = third_input.clone(); + // double maxarea = 0; + // int maxAreaIdx = 0; + // std::vector > contours_pre; + // std::vector < cv::Vec4i > hierarchy_pre; + // cv::findContours(temp, contours_pre, hierarchy_pre, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE); + // for (int i = 0; i < contours_pre.size(); i++) + // { + // drawContours(temp, contours_pre, i, cv::Scalar(255), 2, 8, hierarchy_pre); + // double tmparea = fabs(contourArea(contours_pre[i])); + // if (tmparea > maxarea) + // { + // maxarea = tmparea; + // maxAreaIdx = i;//¼ + // } + // } + + t = ((double)cv::getTickCount() - t) / cv::getTickFrequency(); + std::cout << "cost time\t" << t << " s" << std::endl; + return 1; +} \ No newline at end of file diff --git a/CigaretteSingle/alg.h b/CigaretteSingle/alg.h new file mode 100644 index 0000000..978aa34 --- /dev/null +++ b/CigaretteSingle/alg.h @@ -0,0 +1,17 @@ +#pragma once + +//OpenCV +#include +#include +#include + + +class Alg +{ +public: + cv::Rect RefRect; +public: + bool ScreenShot(cv::Mat imgfull); + void process_2dfft(cv::Mat &input,cv::Mat &output); + bool process_bool(cv::Mat &input, cv::Mat &output); +}; \ No newline at end of file diff --git a/CigaretteSingle/common.cpp b/CigaretteSingle/common.cpp new file mode 100644 index 0000000..08de1b5 --- /dev/null +++ b/CigaretteSingle/common.cpp @@ -0,0 +1,351 @@ +#include "common.h" +#include +#include "stdarg.h" +#include +#include +#include +std::vector string_split(std::string str, std::string pattern) +{ + std::string::size_type pos; + std::vector result; + str += pattern; + int size = str.size(); + + for (int i = 0; i chars(nLength); + _vsnprintf(chars.data(), nLength, pszFmt, args); + str.assign(chars.data()); + } + va_end(args); + return str; +} + +QImage cvMatToQImage(const cv::Mat& mat) +{ + const unsigned char* data = mat.data; + int width = mat.cols; + int height = mat.rows; + int bytesPerLine = static_cast(mat.step); + switch (mat.type()) + { + // 8bit, ARGB + case CV_8UC4: + { + QImage image(data, width, height, bytesPerLine, + QImage::Format_ARGB32); + return image; + } + // 8bit, BGR + case CV_8UC3: + { + QImage image(data, width, height, bytesPerLine, + QImage::Format_RGB888); + //swap blue and red channel + return image.rgbSwapped(); + } + // 8bit, Grayshale + case CV_8UC1: + { + QImage image(data, width, height, bytesPerLine, + QImage::Format_Grayscale8); + return image; + } + default: + { + return QImage(); + } + } +} + +void getMinMax(std::vector points, cv::Point3i &min, cv::Point3i &max) +{ + int minx=0,miny=0,minz=0; + int maxx=0,maxy=0,maxz=0; + for(int i=0;imaxx)maxx = points[i].x; + if(points[i].y>maxy)maxy = points[i].y; + if(points[i].z>maxz)maxz = points[i].z; + } + min.x = minx; + min.y = miny; + min.z = minz; + max.x = maxx; + max.y = maxy; + max.z = maxz; +} + +QString SecondToQStrTime(qint64 time_sec) +{ + int days = (time_sec) / (24 * 3600); + int hours = (time_sec) % (24 * 3600) / 3600; + int minutes = (time_sec) % 3600 / 60; + int second = (time_sec) % 60; + + return QString(QStringLiteral("%1%2ʱ%3%4")).arg(days).arg(hours).arg(minutes).arg(second); +} + +void getFiles(std::string path, std::vector& files) +{ + //ļ + intptr_t hFile = 0; + //ļϢ + struct _finddata_t fileinfo; + std::string p; + if ((hFile = _findfirst(p.assign(path).c_str(), &fileinfo)) != -1) + { + do + { + if (!(fileinfo.attrib & _A_SUBDIR)) + { + files.push_back(fileinfo.name); + } + } while (_findnext(hFile, &fileinfo) == 0); + _findclose(hFile); + } +} + +std::string WstringToString(std::wstring wstr) +{ + int nLen = wcslen(wstr.c_str()); + std::string str; + str.resize(nLen * 2, ' '); + int nResult = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wstr.c_str(), -1, (LPSTR)str.c_str(), nLen * 2, NULL, NULL); + return str; +} + +/* +TCHAR*תchar* +*/ +char* LPWSTR2LPSTR(LPWSTR lpwszStrIn) +{ + LPSTR pszOut = NULL; + if (lpwszStrIn != NULL) { + int nInputStrLen = wcslen(lpwszStrIn); + int nOutputStrLen = WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, NULL, 0, 0, 0) + 2; + pszOut = new char[nOutputStrLen]; + if (pszOut != NULL) { + memset(pszOut, 0x00, nOutputStrLen); + WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, pszOut, nOutputStrLen, 0, 0); + } + } + return pszOut; +} + +//string sλposʼңҵһxλ÷λ +//ҵҵλãҲ-1 +int __find(const std::string s, const int start, const char x) { + if (start >= s.length())return -1; + for (int i = start; i < s.length(); ++i) { + if (s[i] == x) return i; + } + return -1; +} +//˫бתб +void pathConvert_Double2Single(std::string& s) { + int start = 0; + while (start < s.length()) { + int pos = s.find('\\', start); + if (pos == -1)break; + s.replace(pos, 1,"/"); + start = pos + 1; + } +} + +int CALLBACK BrowseCallbackProc( + HWND hwnd, UINT uMsg, LPARAM /*lParam*/, LPARAM lpData) +{ + LPWSTR buf[1000]; + GetCurrentDirectory(1000, (LPWSTR)buf); + if (uMsg == BFFM_INITIALIZED) + { + SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, (LPARAM)buf); + } + + return 0; +} + +std::string SelectDirBRI() +{ + BROWSEINFO bi; + bi.hwndOwner = NULL; + bi.pidlRoot = CSIDL_DESKTOP; + bi.pszDisplayName = NULL; + bi.lpszTitle = NULL;//?λڶԻϲ?Ϣ + bi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;//½?аť + bi.lpfn = BrowseCallbackProc; + bi.iImage = 0; + LPITEMIDLIST pidl = SHBrowseForFolder(&bi);//?ѡԻ + if (pidl == NULL) + { + std::cout << "ûѡĿ¼" << std::endl; + return ""; + } + TCHAR strFolder[MAX_PATH]; + SHGetPathFromIDList(pidl, strFolder); + std::string sFolder = ""; + sFolder = WstringToString(strFolder); + int pos = sFolder.find('\0'); + if (pos) + { + sFolder = sFolder.substr(0, pos); + } + return sFolder; +} + +std::string SelectFileOFN() +{ + OPENFILENAME ofn;//#include + TCHAR szOpenFileNames[80 * MAX_PATH] = { 0 }; + TCHAR szPath[MAX_PATH]; + TCHAR szFileName[80 * MAX_PATH]; + + int nLen = 0; + TCHAR* p = NULL; + ZeroMemory(&ofn, sizeof(ofn)); + + // ṹС + ofn.lStructSize = sizeof(ofn); + // ӵŴھ + ofn.hwndOwner = NULL; + // շصļעһַҪΪNULL + ofn.lpstrFile = szOpenFileNames; + // + ofn.nMaxFile = sizeof(szOpenFileNames); + // _T滻ΪTEXTʹ_TҪtchar.h + ofn.lpstrFile[0] = _T('\0'); + // ù + ofn.lpstrFilter = _T("All\0*.*\0.mp4\0*.mp4\0.avi\0*.avi\0.mkv\0*.mkv\0.rmvb\0*.rmvb\0.f4v\0*.f4v\0.flv\0*.flv\0.m4v\0*.m4v\0.mpg\0*.mpg\0\0"); + // + ofn.nFilterIndex = 1; + // ڱ + ofn.lpstrTitle = _T("ѡͼƬ"); + + // ļڡѡֻѡԻʹԴû + // ٷĵhttps://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea + ofn.Flags = OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY | OFN_EXPLORER; + + // ļʧܣ򲻲 + if (!::GetOpenFileName(&ofn)) { + return ""; + } + + // ѵһļǰĸƵszPath,: + // ֻѡһļ,͸Ƶһ'/' + // ѡ˶ļ,͸ƵһNULLַ + lstrcpyn(szPath, szOpenFileNames, ofn.nFileOffset); + + // ֻѡһļʱ,NULLַDZ. + // ﲻԴѡһͶļ + szPath[ofn.nFileOffset] = '\0'; + nLen = lstrlen(szPath); + + // ѡ˶ļ,'//' + if (szPath[nLen - 1] != '\\') { + lstrcat(szPath, _T("\\")); + } + + // ָƵһļ + p = szOpenFileNames + ofn.nFileOffset; + + // szFileName + ZeroMemory(szFileName, sizeof(szFileName)); + + // ַƴѡļ· + std::string str = ""; + + while (*p) { + // ȡļ + std::string fileName = LPWSTR2LPSTR(p); + // ȡļļ· + std::string filePath = LPWSTR2LPSTR(szPath); + // ƴļ· + std::string completePath = filePath + fileName; + // ƴַ + str += completePath + "***"; + //һļ + p += lstrlen(p) + 1; + } + + return str; + // stringתΪchar* + //char* strc = new char[strlen(str.c_str()) + 1]; + //const char* cc = str.c_str(); + //strcpy_s(strc, str.size() + 1, cc); +} + +//https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog?redirectedfrom=MSDN +std::string SelectDirIFD() +{ + std::string folderpath = ""; + // CoCreate the File Open Dialog object. + IFileDialog* pfd = NULL; + HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&pfd)); + if (SUCCEEDED(hr)) + { + // Set the options on the dialog. + DWORD dwFlags; + + // Before setting, always get the options first in order + // not to override existing options. + hr = pfd->GetOptions(&dwFlags); + if (SUCCEEDED(hr)) + { + // In this case, get shell items only for file system items. + hr = pfd->SetOptions(dwFlags | FOS_PICKFOLDERS); + if (SUCCEEDED(hr)) + { + // Show the dialog + hr = pfd->Show(NULL); + if (SUCCEEDED(hr)) + { + // Obtain the result once the user clicks + // the 'Open' button. + // The result is an IShellItem object. + IShellItem* psiResult; + hr = pfd->GetResult(&psiResult); + if (SUCCEEDED(hr)) + { + // We are just going to print out the + // name of the file for sample sake. + PWSTR pszFilePath = NULL; + hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH,&pszFilePath); + if (SUCCEEDED(hr)) + { + folderpath = LPWSTR2LPSTR(pszFilePath); + CoTaskMemFree(pszFilePath); + } + psiResult->Release(); + } + } + } + } + pfd->Release(); + } + return folderpath; +} \ No newline at end of file diff --git a/CigaretteSingle/common.h b/CigaretteSingle/common.h new file mode 100644 index 0000000..55445d3 --- /dev/null +++ b/CigaretteSingle/common.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "QtCore\qdatetime.h" +#include "QImage.h" +#include +#include +#include +#include +#include +//#define __DEBUG + +#ifdef __DEBUG +#define DEBUG(format, ...) printf (format "\n", ##__VA_ARGS__) +#else +#define DEBUG(format, ...) +#endif + +#define Queue_Size 15 + +std::vector string_split(std::string str, std::string pattern); +std::string format(const char *pszFmt, ...); +QImage cvMatToQImage(const cv::Mat& mat); +void getMinMax(std::vector points,cv::Point3i &min, cv::Point3i &max); +QString SecondToQStrTime(qint64 time_sec); +void getFiles(std::string path, std::vector& files); +std::string SelectDirBRI(); +std::string SelectFileOFN(); +std::string SelectDirIFD(); \ No newline at end of file diff --git a/CigaretteSingle/darkblack.css b/CigaretteSingle/darkblack.css new file mode 100644 index 0000000..fe462b7 --- /dev/null +++ b/CigaretteSingle/darkblack.css @@ -0,0 +1,657 @@ +QPalette{background:#1F2026;}*{outline:0px;color:#D7E2E9;} + +QWidget[form="true"],QLabel[frameShape="1"]{ +border:1px solid #111214; +border-radius:0px; +} + +QWidget[form="bottom"]{ +background:#242629; +} + +QWidget[form="bottom"] .QFrame{ +border:1px solid #D7E2E9; +} + +QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ +border-radius:0px; +color:#D7E2E9; +background:none; +border-style:none; +} + +QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ +border-style:none; +border-radius:0px; +padding:5px; +color:#D7E2E9; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed,QWidget[nav="top"] QAbstractButton:checked{ +border-style:solid; +border-width:0px 0px 2px 0px; +padding:4px 4px 2px 4px; +border-color:#00BB9E; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +QWidget[nav="left"] QAbstractButton{ +border-radius:0px; +color:#D7E2E9; +background:none; +border-style:none; +} + +QWidget[nav="left"] QAbstractButton:hover{ +color:#FFFFFF; +background-color:#00BB9E; +} + +QWidget[nav="left"] QAbstractButton:checked,QWidget[nav="left"] QAbstractButton:pressed{ +color:#D7E2E9; +border-style:solid; +border-width:0px 0px 0px 2px; +padding:4px 4px 4px 2px; +border-color:#00BB9E; +background-color:#1F2026; +} + +QWidget[video="true"] QLabel{ +color:#D7E2E9; +border:1px solid #111214; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +QWidget[video="true"] QLabel:focus{ +border:1px solid #00BB9E; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +border:1px solid #111214; +border-radius:3px; +padding:2px; +background:none; +selection-background-color:#00BB9E; +selection-color:#FFFFFF; +} + +QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ +border:1px solid #111214; +} + +QLineEdit[echoMode="2"]{ +lineedit-password-character:9679; +} + +.QFrame{ +border:1px solid #111214; +border-radius:3px; +} + +.QGroupBox{ +border:1px solid #111214; +border-radius:5px; +margin-top:3ex; +} + +.QGroupBox::title{ +subcontrol-origin:margin; +position:relative; +left:10px; +} + +.QPushButton,.QToolButton{ +border-style:none; +border:1px solid #111214; +color:#D7E2E9; +padding:5px; +min-height:15px; +border-radius:5px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +.QPushButton:hover,.QToolButton:hover{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +.QPushButton:pressed,.QToolButton:pressed{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +.QToolButton::menu-indicator{ +image:None; +} + +QToolButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ +border-radius:3px; +color:#D7E2E9; +padding:3px; +margin:0px; +background:none; +border-style:none; +} + +QToolButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(51,127,209,230); +} + +QPushButton#btnMenu_Close:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(238,0,0,128); +} + +QRadioButton::indicator{ +width:15px; +height:15px; +} + +QRadioButton::indicator::unchecked{ +image:url(:/qss/darkblack/radiobutton_unchecked.png); +} + +QRadioButton::indicator::unchecked:disabled{ +image:url(:/qss/darkblack/radiobutton_unchecked_disable.png); +} + +QRadioButton::indicator::checked{ +image:url(:/qss/darkblack/radiobutton_checked.png); +} + +QRadioButton::indicator::checked:disabled{ +image:url(:/qss/darkblack/radiobutton_checked_disable.png); +} + +QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{ +padding:0px -3px 0px 0px; +} + +QCheckBox::indicator,QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{ +width:13px; +height:13px; +} + +QCheckBox::indicator:unchecked,QGroupBox::indicator:unchecked,QTreeWidget::indicator:unchecked,QListWidget::indicator:unchecked{ +image:url(:/qss/darkblack/checkbox_unchecked.png); +} + +QCheckBox::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled,QTreeWidget::indicator:unchecked:disabled,QListWidget::indicator:disabled{ +image:url(:/qss/darkblack/checkbox_unchecked_disable.png); +} + +QCheckBox::indicator:checked,QGroupBox::indicator:checked,QTreeWidget::indicator:checked,QListWidget::indicator:checked{ +image:url(:/qss/darkblack/checkbox_checked.png); +} + +QCheckBox::indicator:checked:disabled,QGroupBox::indicator:checked:disabled,QTreeWidget::indicator:checked:disabled,QListWidget::indicator:checked:disabled{ +image:url(:/qss/darkblack/checkbox_checked_disable.png); +} + +QCheckBox::indicator:indeterminate,QGroupBox::indicator:indeterminate,QTreeWidget::indicator:indeterminate,QListWidget::indicator:indeterminate{ +image:url(:/qss/darkblack/checkbox_parcial.png); +} + +QCheckBox::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled,QTreeWidget::indicator:indeterminate:disabled,QListWidget::indicator:indeterminate:disabled{ +image:url(:/qss/darkblack/checkbox_parcial_disable.png); +} + +QTimeEdit::up-button,QDateEdit::up-button,QDateTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button{ +image:url(:/qss/darkblack/add_top.png); +width:10px; +height:10px; +padding:2px 5px 0px 0px; +} + +QTimeEdit::down-button,QDateEdit::down-button,QDateTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button{ +image:url(:/qss/darkblack/add_bottom.png); +width:10px; +height:10px; +padding:0px 5px 2px 0px; +} + +QTimeEdit::up-button:pressed,QDateEdit::up-button:pressed,QDateTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ +top:-2px; +} + +QTimeEdit::down-button:pressed,QDateEdit::down-button:pressed,QDateTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ +bottom:-2px; +} + +QComboBox::down-arrow,QDateEdit[calendarPopup="true"]::down-arrow,QTimeEdit[calendarPopup="true"]::down-arrow,QDateTimeEdit[calendarPopup="true"]::down-arrow{ +image:url(:/qss/darkblack/add_bottom.png); +width:10px; +height:10px; +right:2px; +} + +QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{ +subcontrol-origin:padding; +subcontrol-position:top right; +width:15px; +border-left-width:0px; +border-left-style:solid; +border-top-right-radius:3px; +border-bottom-right-radius:3px; +border-left-color:#111214; +} + +QComboBox::drop-down:on{ +top:1px; +} + +QMenuBar::item{ +color:#D7E2E9; +background-color:#242629; +margin:0px; +padding:3px 10px; +} + +QMenu,QMenuBar,QMenu:disabled,QMenuBar:disabled{ +color:#D7E2E9; +background-color:#242629; +border:1px solid #111214; +margin:0px; +} + +QMenu::item{ +padding:3px 20px; +} + +QMenu::indicator{ +width:13px; +height:13px; +} + +QMenu::item:selected,QMenuBar::item:selected{ +color:#D7E2E9; +border:0px solid #111214; +background:#007DC4; +} + +QMenu::separator{ +height:1px; +background:#111214; +} + +QProgressBar{ +min-height:10px; +background:#242629; +border-radius:5px; +text-align:center; +border:1px solid #242629; +} + +QProgressBar:chunk{ +border-radius:5px; +background-color:#111214; +} + +QSlider::groove:horizontal{ +background:#242629; +height:8px; +border-radius:4px; +} + +QSlider::add-page:horizontal{ +background:#242629; +height:8px; +border-radius:4px; +} + +QSlider::sub-page:horizontal{ +background:#111214; +height:8px; +border-radius:4px; +} + +QSlider::handle:horizontal{ +width:13px; +margin-top:-3px; +margin-bottom:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #1F2026,stop:0.8 #111214); +} + +QSlider::groove:vertical{ +width:8px; +border-radius:4px; +background:#242629; +} + +QSlider::add-page:vertical{ +width:8px; +border-radius:4px; +background:#242629; +} + +QSlider::sub-page:vertical{ +width:8px; +border-radius:4px; +background:#111214; +} + +QSlider::handle:vertical{ +height:14px; +margin-left:-3px; +margin-right:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #1F2026,stop:0.8 #111214); +} + +QScrollBar:horizontal{ +background:#242629; +padding:0px; +border-radius:6px; +max-height:12px; +} + +QScrollBar::handle:horizontal{ +background:#111214; +min-width:50px; +border-radius:6px; +} + +QScrollBar::handle:horizontal:hover{ +background:#00BB9E; +} + +QScrollBar::handle:horizontal:pressed{ +background:#00BB9E; +} + +QScrollBar::add-page:horizontal{ +background:none; +} + +QScrollBar::sub-page:horizontal{ +background:none; +} + +QScrollBar::add-line:horizontal{ +background:none; +} + +QScrollBar::sub-line:horizontal{ +background:none; +} + +QScrollBar:vertical{ +background:#242629; +padding:0px; +border-radius:6px; +max-width:12px; +} + +QScrollBar::handle:vertical{ +background:#111214; +min-height:50px; +border-radius:6px; +} + +QScrollBar::handle:vertical:hover{ +background:#00BB9E; +} + +QScrollBar::handle:vertical:pressed{ +background:#00BB9E; +} + +QScrollBar::add-page:vertical{ +background:none; +} + +QScrollBar::sub-page:vertical{ +background:none; +} + +QScrollBar::add-line:vertical{ +background:none; +} + +QScrollBar::sub-line:vertical{ +background:none; +} + +QScrollArea{ +border:0px; +} + +QTreeView,QListView,QTableView,QTabWidget::pane{ +border:1px solid #111214; +selection-background-color:#007DC4; +selection-color:#D7E2E9; +alternate-background-color:#0074BF; +gridline-color:#111214; +} + +QTreeView::branch:closed:has-children{ +margin:4px; +border-image:url(:/qss/darkblack/branch_open.png); +} + +QTreeView::branch:open:has-children{ +margin:4px; +border-image:url(:/qss/darkblack/branch_close.png); +} + +QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ +background:#1F2026; +} + +QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +color:#D7E2E9; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +QTableView::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView{ +color:#D7E2E9; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +QTableView::item,QListView::item,QTreeView::item{ +padding:1px; +margin:0px; +} + +QHeaderView::section,QTableCornerButton:section{ +padding:3px; +margin:0px; +color:#D7E2E9; +border:1px solid #111214; +border-left-width:0px; +border-right-width:1px; +border-top-width:0px; +border-bottom-width:1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +QTabBar::tab{ +border:1px solid #111214; +color:#D7E2E9; +margin:0px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +QTabBar::tab:selected,QTabBar::tab:hover{ +border-style:solid; +border-color:#00BB9E; +background:#1F2026; +} + +QTabBar::tab:top,QTabBar::tab:bottom{ +padding:3px 8px 3px 8px; +} + +QTabBar::tab:left,QTabBar::tab:right{ +padding:8px 3px 8px 3px; +} + +QTabBar::tab:top:selected,QTabBar::tab:top:hover{ +border-width:2px 0px 0px 0px; +} + +QTabBar::tab:right:selected,QTabBar::tab:right:hover{ +border-width:0px 0px 0px 2px; +} + +QTabBar::tab:bottom:selected,QTabBar::tab:bottom:hover{ +border-width:0px 0px 2px 0px; +} + +QTabBar::tab:left:selected,QTabBar::tab:left:hover{ +border-width:0px 2px 0px 0px; +} + +QTabBar::tab:first:top:selected,QTabBar::tab:first:top:hover,QTabBar::tab:first:bottom:selected,QTabBar::tab:first:bottom:hover{ +border-left-width:1px; +border-left-color:#111214; +} + +QTabBar::tab:first:left:selected,QTabBar::tab:first:left:hover,QTabBar::tab:first:right:selected,QTabBar::tab:first:right:hover{ +border-top-width:1px; +border-top-color:#111214; +} + +QTabBar::tab:last:top:selected,QTabBar::tab:last:top:hover,QTabBar::tab:last:bottom:selected,QTabBar::tab:last:bottom:hover{ +border-right-width:1px; +border-right-color:#111214; +} + +QTabBar::tab:last:left:selected,QTabBar::tab:last:left:hover,QTabBar::tab:last:right:selected,QTabBar::tab:last:right:hover{ +border-bottom-width:1px; +border-bottom-color:#111214; +} + +QStatusBar::item{ +border:0px solid #242629; +border-radius:3px; +} + +QToolBox::tab,QGroupBox#gboxDevicePanel,QGroupBox#gboxDeviceTitle,QFrame#gboxDevicePanel,QFrame#gboxDeviceTitle{ +padding:3px; +border-radius:5px; +color:#D7E2E9; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +QToolTip{ +border:0px solid #D7E2E9; +padding:1px; +color:#D7E2E9; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +QToolBox::tab:selected{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #007DC4,stop:1 #0074BF); +} + +QPrintPreviewDialog QToolButton{ +border:0px solid #D7E2E9; +border-radius:0px; +margin:0px; +padding:3px; +background:none; +} + +QColorDialog QPushButton,QFileDialog QPushButton{ +min-width:80px; +} + +QToolButton#qt_calendar_prevmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/darkblack/calendar_prevmonth.png); +} + +QToolButton#qt_calendar_nextmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/darkblack/calendar_nextmonth.png); +} + +QToolButton#qt_calendar_prevmonth,QToolButton#qt_calendar_nextmonth,QToolButton#qt_calendar_monthbutton,QToolButton#qt_calendar_yearbutton{ +border:0px solid #D7E2E9; +border-radius:3px; +margin:3px 3px 3px 3px; +padding:3px; +background:none; +} + +QToolButton#qt_calendar_prevmonth:hover,QToolButton#qt_calendar_nextmonth:hover,QToolButton#qt_calendar_monthbutton:hover,QToolButton#qt_calendar_yearbutton:hover,QToolButton#qt_calendar_prevmonth:pressed,QToolButton#qt_calendar_nextmonth:pressed,QToolButton#qt_calendar_monthbutton:pressed,QToolButton#qt_calendar_yearbutton:pressed{ +border:1px solid #111214; +} + +QCalendarWidget QSpinBox#qt_calendar_yearedit{ +margin:2px; +} + +QCalendarWidget QToolButton::menu-indicator{ +image:None; +} + +QCalendarWidget QTableView{ +border-width:0px; +} + +QCalendarWidget QWidget#qt_calendar_navigationbar{ +border:1px solid #111214; +border-width:1px 1px 0px 1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #242629,stop:1 #141518); +} + +QComboBox QAbstractItemView::item{ +min-height:20px; +min-width:10px; +} + +QTableView[model="true"]::item{ +padding:0px; +margin:0px; +} + +QTableView QLineEdit,QTableView QComboBox,QTableView QSpinBox,QTableView QDoubleSpinBox,QTableView QDateEdit,QTableView QTimeEdit,QTableView QDateTimeEdit{ +border-width:0px; +border-radius:0px; +} + +QTableView QLineEdit:focus,QTableView QComboBox:focus,QTableView QSpinBox:focus,QTableView QDoubleSpinBox:focus,QTableView QDateEdit:focus,QTableView QTimeEdit:focus,QTableView QDateTimeEdit:focus{ +border-width:0px; +border-radius:0px; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +background:#1F2026; +} + +QTabWidget::pane:top{top:-1px;} +QTabWidget::pane:bottom{bottom:-1px;} +QTabWidget::pane:left{right:-1px;} +QTabWidget::pane:right{left:-1px;} + +QDialog { +background-color:#1F2026; +color:#D7E2E9; +} + +QDialogButtonBox > QPushButton { +min-width:50px; +} + +*:disabled,QMenu::item:disabled,QTabBar::tab:disabled{ +background:#1F2026; +border-color:#242629; +color:#111214; +} + +/*TextColor:#D7E2E9*/ +/*PanelColor:#1F2026*/ +/*BorderColor:#111214*/ +/*NormalColorStart:#242629*/ +/*NormalColorEnd:#141518*/ +/*DarkColorStart:#007DC4*/ +/*DarkColorEnd:#0074BF*/ +/*HighColor:#00BB9E*/ \ No newline at end of file diff --git a/CigaretteSingle/halcon.hdev b/CigaretteSingle/halcon.hdev new file mode 100644 index 0000000..3fe62bc --- /dev/null +++ b/CigaretteSingle/halcon.hdev @@ -0,0 +1,55 @@ + + + + + +*关窗口 +dev_close_window() + +*开窗口 +*dev_open_window (0, 0, 512, 512, 'white', WindowHandle) + +read_image (Image, 'G:/ProjectFile/VS_project_file/cigarette/CigaretteSingle/image/1-1/2022-11-03_09-34-03_306_a.jpg') +rgb1_to_gray (Image, Image) +*dev_display(Image) + +gen_rectangle1 (ROI_0, 206.943, 645.433, 351.551, 723.181) + +region_features (ROI_0, 'width', Width) +region_features (ROI_0, 'height', Height) +reduce_domain(Image,ROI_0,ImageReduced) +crop_domain(ImageReduced, ImageReduced) +* Optimize the fft speed for the specific image size +optimize_rft_speed (Width, Height, 'standard') + +* Construct a suitable filter by combining two gaussian +* filters +Sigma1 := 10.0 +Sigma2 := 3.0 +gen_gauss_filter (GaussFilter1, Sigma1, Sigma1, 0.0, 'none', 'rft', Width, Height) +gen_gauss_filter (GaussFilter2, Sigma2, Sigma2, 0.0, 'none', 'rft', Width, Height) +sub_image (GaussFilter1, GaussFilter2, Filter, 1, 0) + + * Perform the convolution in the frequency domain +rft_generic (ImageReduced, ImageFFT, 'to_freq', 'none', 'complex', Width) +convol_fft (ImageFFT, Filter, ImageConvol) +rft_generic (ImageConvol, ImageFiltered, 'from_freq', 'n', 'real', Width) +* +* Process the filtered image +gray_range_rect (ImageFiltered, ImageResult, 10, 10) +min_max_gray (ImageResult, ImageResult, 0, Min, Max, Range) +threshold (ImageResult, RegionDynThresh, max([5.55,Max * 0.8]), 255) +connection (RegionDynThresh, ConnectedRegions) +select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 4, 99999) +union1 (SelectedRegions, RegionUnion) +closing_circle (RegionUnion, RegionClosing, 10) +connection (RegionClosing, ConnectedRegions1) +select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 10, 99999) +area_center (SelectedRegions1, Area, Row, Column) +* + + + + + + diff --git a/CigaretteSingle/lightblack.css b/CigaretteSingle/lightblack.css new file mode 100644 index 0000000..e1367fd --- /dev/null +++ b/CigaretteSingle/lightblack.css @@ -0,0 +1,657 @@ +QPalette{background:#616F76;}*{outline:0px;color:#E7ECF0;} + +QWidget[form="true"],QLabel[frameShape="1"]{ +border:1px solid #738393; +border-radius:0px; +} + +QWidget[form="bottom"]{ +background:#667481; +} + +QWidget[form="bottom"] .QFrame{ +border:1px solid #E7ECF0; +} + +QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ +border-radius:0px; +color:#E7ECF0; +background:none; +border-style:none; +} + +QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ +border-style:none; +border-radius:0px; +padding:5px; +color:#E7ECF0; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed,QWidget[nav="top"] QAbstractButton:checked{ +border-style:solid; +border-width:0px 0px 2px 0px; +padding:4px 4px 2px 4px; +border-color:#00BB9E; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +QWidget[nav="left"] QAbstractButton{ +border-radius:0px; +color:#E7ECF0; +background:none; +border-style:none; +} + +QWidget[nav="left"] QAbstractButton:hover{ +color:#FFFFFF; +background-color:#00BB9E; +} + +QWidget[nav="left"] QAbstractButton:checked,QWidget[nav="left"] QAbstractButton:pressed{ +color:#E7ECF0; +border-style:solid; +border-width:0px 0px 0px 2px; +padding:4px 4px 4px 2px; +border-color:#00BB9E; +background-color:#616F76; +} + +QWidget[video="true"] QLabel{ +color:#E7ECF0; +border:1px solid #738393; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +QWidget[video="true"] QLabel:focus{ +border:1px solid #00BB9E; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +border:1px solid #738393; +border-radius:3px; +padding:2px; +background:none; +selection-background-color:#00BB9E; +selection-color:#FFFFFF; +} + +QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ +border:1px solid #738393; +} + +QLineEdit[echoMode="2"]{ +lineedit-password-character:9679; +} + +.QFrame{ +border:1px solid #738393; +border-radius:3px; +} + +.QGroupBox{ +border:1px solid #738393; +border-radius:5px; +margin-top:3ex; +} + +.QGroupBox::title{ +subcontrol-origin:margin; +position:relative; +left:10px; +} + +.QPushButton,.QToolButton{ +border-style:none; +border:1px solid #738393; +color:#E7ECF0; +padding:5px; +min-height:15px; +border-radius:5px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +.QPushButton:hover,.QToolButton:hover{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +.QPushButton:pressed,.QToolButton:pressed{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +.QToolButton::menu-indicator{ +image:None; +} + +QToolButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ +border-radius:3px; +color:#E7ECF0; +padding:3px; +margin:0px; +background:none; +border-style:none; +} + +QToolButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(51,127,209,230); +} + +QPushButton#btnMenu_Close:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(238,0,0,128); +} + +QRadioButton::indicator{ +width:15px; +height:15px; +} + +QRadioButton::indicator::unchecked{ +image:url(:/qss/lightblack/radiobutton_unchecked.png); +} + +QRadioButton::indicator::unchecked:disabled{ +image:url(:/qss/lightblack/radiobutton_unchecked_disable.png); +} + +QRadioButton::indicator::checked{ +image:url(:/qss/lightblack/radiobutton_checked.png); +} + +QRadioButton::indicator::checked:disabled{ +image:url(:/qss/lightblack/radiobutton_checked_disable.png); +} + +QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{ +padding:0px -3px 0px 0px; +} + +QCheckBox::indicator,QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{ +width:13px; +height:13px; +} + +QCheckBox::indicator:unchecked,QGroupBox::indicator:unchecked,QTreeWidget::indicator:unchecked,QListWidget::indicator:unchecked{ +image:url(:/qss/lightblack/checkbox_unchecked.png); +} + +QCheckBox::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled,QTreeWidget::indicator:unchecked:disabled,QListWidget::indicator:disabled{ +image:url(:/qss/lightblack/checkbox_unchecked_disable.png); +} + +QCheckBox::indicator:checked,QGroupBox::indicator:checked,QTreeWidget::indicator:checked,QListWidget::indicator:checked{ +image:url(:/qss/lightblack/checkbox_checked.png); +} + +QCheckBox::indicator:checked:disabled,QGroupBox::indicator:checked:disabled,QTreeWidget::indicator:checked:disabled,QListWidget::indicator:checked:disabled{ +image:url(:/qss/lightblack/checkbox_checked_disable.png); +} + +QCheckBox::indicator:indeterminate,QGroupBox::indicator:indeterminate,QTreeWidget::indicator:indeterminate,QListWidget::indicator:indeterminate{ +image:url(:/qss/lightblack/checkbox_parcial.png); +} + +QCheckBox::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled,QTreeWidget::indicator:indeterminate:disabled,QListWidget::indicator:indeterminate:disabled{ +image:url(:/qss/lightblack/checkbox_parcial_disable.png); +} + +QTimeEdit::up-button,QDateEdit::up-button,QDateTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button{ +image:url(:/qss/lightblack/add_top.png); +width:10px; +height:10px; +padding:2px 5px 0px 0px; +} + +QTimeEdit::down-button,QDateEdit::down-button,QDateTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button{ +image:url(:/qss/lightblack/add_bottom.png); +width:10px; +height:10px; +padding:0px 5px 2px 0px; +} + +QTimeEdit::up-button:pressed,QDateEdit::up-button:pressed,QDateTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ +top:-2px; +} + +QTimeEdit::down-button:pressed,QDateEdit::down-button:pressed,QDateTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ +bottom:-2px; +} + +QComboBox::down-arrow,QDateEdit[calendarPopup="true"]::down-arrow,QTimeEdit[calendarPopup="true"]::down-arrow,QDateTimeEdit[calendarPopup="true"]::down-arrow{ +image:url(:/qss/lightblack/add_bottom.png); +width:10px; +height:10px; +right:2px; +} + +QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{ +subcontrol-origin:padding; +subcontrol-position:top right; +width:15px; +border-left-width:0px; +border-left-style:solid; +border-top-right-radius:3px; +border-bottom-right-radius:3px; +border-left-color:#738393; +} + +QComboBox::drop-down:on{ +top:1px; +} + +QMenuBar::item{ +color:#E7ECF0; +background-color:#667481; +margin:0px; +padding:3px 10px; +} + +QMenu,QMenuBar,QMenu:disabled,QMenuBar:disabled{ +color:#E7ECF0; +background-color:#667481; +border:1px solid #738393; +margin:0px; +} + +QMenu::item{ +padding:3px 20px; +} + +QMenu::indicator{ +width:13px; +height:13px; +} + +QMenu::item:selected,QMenuBar::item:selected{ +color:#E7ECF0; +border:0px solid #738393; +background:#778899; +} + +QMenu::separator{ +height:1px; +background:#738393; +} + +QProgressBar{ +min-height:10px; +background:#667481; +border-radius:5px; +text-align:center; +border:1px solid #667481; +} + +QProgressBar:chunk{ +border-radius:5px; +background-color:#738393; +} + +QSlider::groove:horizontal{ +background:#667481; +height:8px; +border-radius:4px; +} + +QSlider::add-page:horizontal{ +background:#667481; +height:8px; +border-radius:4px; +} + +QSlider::sub-page:horizontal{ +background:#738393; +height:8px; +border-radius:4px; +} + +QSlider::handle:horizontal{ +width:13px; +margin-top:-3px; +margin-bottom:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #616F76,stop:0.8 #738393); +} + +QSlider::groove:vertical{ +width:8px; +border-radius:4px; +background:#667481; +} + +QSlider::add-page:vertical{ +width:8px; +border-radius:4px; +background:#667481; +} + +QSlider::sub-page:vertical{ +width:8px; +border-radius:4px; +background:#738393; +} + +QSlider::handle:vertical{ +height:14px; +margin-left:-3px; +margin-right:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #616F76,stop:0.8 #738393); +} + +QScrollBar:horizontal{ +background:#667481; +padding:0px; +border-radius:6px; +max-height:12px; +} + +QScrollBar::handle:horizontal{ +background:#738393; +min-width:50px; +border-radius:6px; +} + +QScrollBar::handle:horizontal:hover{ +background:#00BB9E; +} + +QScrollBar::handle:horizontal:pressed{ +background:#00BB9E; +} + +QScrollBar::add-page:horizontal{ +background:none; +} + +QScrollBar::sub-page:horizontal{ +background:none; +} + +QScrollBar::add-line:horizontal{ +background:none; +} + +QScrollBar::sub-line:horizontal{ +background:none; +} + +QScrollBar:vertical{ +background:#667481; +padding:0px; +border-radius:6px; +max-width:12px; +} + +QScrollBar::handle:vertical{ +background:#738393; +min-height:50px; +border-radius:6px; +} + +QScrollBar::handle:vertical:hover{ +background:#00BB9E; +} + +QScrollBar::handle:vertical:pressed{ +background:#00BB9E; +} + +QScrollBar::add-page:vertical{ +background:none; +} + +QScrollBar::sub-page:vertical{ +background:none; +} + +QScrollBar::add-line:vertical{ +background:none; +} + +QScrollBar::sub-line:vertical{ +background:none; +} + +QScrollArea{ +border:0px; +} + +QTreeView,QListView,QTableView,QTabWidget::pane{ +border:1px solid #738393; +selection-background-color:#778899; +selection-color:#E7ECF0; +alternate-background-color:#708090; +gridline-color:#738393; +} + +QTreeView::branch:closed:has-children{ +margin:4px; +border-image:url(:/qss/lightblack/branch_open.png); +} + +QTreeView::branch:open:has-children{ +margin:4px; +border-image:url(:/qss/lightblack/branch_close.png); +} + +QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ +background:#616F76; +} + +QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +color:#E7ECF0; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +QTableView::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView{ +color:#E7ECF0; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +QTableView::item,QListView::item,QTreeView::item{ +padding:1px; +margin:0px; +} + +QHeaderView::section,QTableCornerButton:section{ +padding:3px; +margin:0px; +color:#E7ECF0; +border:1px solid #738393; +border-left-width:0px; +border-right-width:1px; +border-top-width:0px; +border-bottom-width:1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +QTabBar::tab{ +border:1px solid #738393; +color:#E7ECF0; +margin:0px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +QTabBar::tab:selected,QTabBar::tab:hover{ +border-style:solid; +border-color:#00BB9E; +background:#616F76; +} + +QTabBar::tab:top,QTabBar::tab:bottom{ +padding:3px 8px 3px 8px; +} + +QTabBar::tab:left,QTabBar::tab:right{ +padding:8px 3px 8px 3px; +} + +QTabBar::tab:top:selected,QTabBar::tab:top:hover{ +border-width:2px 0px 0px 0px; +} + +QTabBar::tab:right:selected,QTabBar::tab:right:hover{ +border-width:0px 0px 0px 2px; +} + +QTabBar::tab:bottom:selected,QTabBar::tab:bottom:hover{ +border-width:0px 0px 2px 0px; +} + +QTabBar::tab:left:selected,QTabBar::tab:left:hover{ +border-width:0px 2px 0px 0px; +} + +QTabBar::tab:first:top:selected,QTabBar::tab:first:top:hover,QTabBar::tab:first:bottom:selected,QTabBar::tab:first:bottom:hover{ +border-left-width:1px; +border-left-color:#738393; +} + +QTabBar::tab:first:left:selected,QTabBar::tab:first:left:hover,QTabBar::tab:first:right:selected,QTabBar::tab:first:right:hover{ +border-top-width:1px; +border-top-color:#738393; +} + +QTabBar::tab:last:top:selected,QTabBar::tab:last:top:hover,QTabBar::tab:last:bottom:selected,QTabBar::tab:last:bottom:hover{ +border-right-width:1px; +border-right-color:#738393; +} + +QTabBar::tab:last:left:selected,QTabBar::tab:last:left:hover,QTabBar::tab:last:right:selected,QTabBar::tab:last:right:hover{ +border-bottom-width:1px; +border-bottom-color:#738393; +} + +QStatusBar::item{ +border:0px solid #667481; +border-radius:3px; +} + +QToolBox::tab,QGroupBox#gboxDevicePanel,QGroupBox#gboxDeviceTitle,QFrame#gboxDevicePanel,QFrame#gboxDeviceTitle{ +padding:3px; +border-radius:5px; +color:#E7ECF0; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +QToolTip{ +border:0px solid #E7ECF0; +padding:1px; +color:#E7ECF0; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +QToolBox::tab:selected{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #778899,stop:1 #708090); +} + +QPrintPreviewDialog QToolButton{ +border:0px solid #E7ECF0; +border-radius:0px; +margin:0px; +padding:3px; +background:none; +} + +QColorDialog QPushButton,QFileDialog QPushButton{ +min-width:80px; +} + +QToolButton#qt_calendar_prevmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/lightblack/calendar_prevmonth.png); +} + +QToolButton#qt_calendar_nextmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/lightblack/calendar_nextmonth.png); +} + +QToolButton#qt_calendar_prevmonth,QToolButton#qt_calendar_nextmonth,QToolButton#qt_calendar_monthbutton,QToolButton#qt_calendar_yearbutton{ +border:0px solid #E7ECF0; +border-radius:3px; +margin:3px 3px 3px 3px; +padding:3px; +background:none; +} + +QToolButton#qt_calendar_prevmonth:hover,QToolButton#qt_calendar_nextmonth:hover,QToolButton#qt_calendar_monthbutton:hover,QToolButton#qt_calendar_yearbutton:hover,QToolButton#qt_calendar_prevmonth:pressed,QToolButton#qt_calendar_nextmonth:pressed,QToolButton#qt_calendar_monthbutton:pressed,QToolButton#qt_calendar_yearbutton:pressed{ +border:1px solid #738393; +} + +QCalendarWidget QSpinBox#qt_calendar_yearedit{ +margin:2px; +} + +QCalendarWidget QToolButton::menu-indicator{ +image:None; +} + +QCalendarWidget QTableView{ +border-width:0px; +} + +QCalendarWidget QWidget#qt_calendar_navigationbar{ +border:1px solid #738393; +border-width:1px 1px 0px 1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #667481,stop:1 #566373); +} + +QComboBox QAbstractItemView::item{ +min-height:20px; +min-width:10px; +} + +QTableView[model="true"]::item{ +padding:0px; +margin:0px; +} + +QTableView QLineEdit,QTableView QComboBox,QTableView QSpinBox,QTableView QDoubleSpinBox,QTableView QDateEdit,QTableView QTimeEdit,QTableView QDateTimeEdit{ +border-width:0px; +border-radius:0px; +} + +QTableView QLineEdit:focus,QTableView QComboBox:focus,QTableView QSpinBox:focus,QTableView QDoubleSpinBox:focus,QTableView QDateEdit:focus,QTableView QTimeEdit:focus,QTableView QDateTimeEdit:focus{ +border-width:0px; +border-radius:0px; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +background:#616F76; +} + +QTabWidget::pane:top{top:-1px;} +QTabWidget::pane:bottom{bottom:-1px;} +QTabWidget::pane:left{right:-1px;} +QTabWidget::pane:right{left:-1px;} + +QDialog { +background-color:#616F76; +color:#E7ECF0; +} + +QDialogButtonBox > QPushButton { +min-width:50px; +} + +*:disabled,QMenu::item:disabled,QTabBar::tab:disabled{ +background:#616F76; +border-color:#667481; +border:#738393; +} + +/*TextColor:#E7ECF0*/ +/*PanelColor:#616F76*/ +/*BorderColor:#738393*/ +/*NormalColorStart:#667481*/ +/*NormalColorEnd:#566373*/ +/*DarkColorStart:#778899*/ +/*DarkColorEnd:#708090*/ +/*HighColor:#00BB9E*/ \ No newline at end of file diff --git a/CigaretteSingle/main.cpp b/CigaretteSingle/main.cpp new file mode 100644 index 0000000..35b3bf1 --- /dev/null +++ b/CigaretteSingle/main.cpp @@ -0,0 +1,11 @@ +#include "CigaretteSingle.h" +#include + +int main(int argc, char *argv[]) +{ + qRegisterMetaType("cv::Mat"); + QApplication a(argc, argv); + CigaretteSingle w; + w.show(); + return a.exec(); +} diff --git a/CigaretteSingle/modbus/modbus-private.h b/CigaretteSingle/modbus/modbus-private.h new file mode 100644 index 0000000..198baef --- /dev/null +++ b/CigaretteSingle/modbus/modbus-private.h @@ -0,0 +1,116 @@ +/* + * Copyright © 2010-2012 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_PRIVATE_H +#define MODBUS_PRIVATE_H + +#ifndef _MSC_VER +# include +# include +#else +# include "stdint.h" +# include +typedef int ssize_t; +#endif +#include +#include + +#include "modbus.h" + +MODBUS_BEGIN_DECLS + +/* It's not really the minimal length (the real one is report slave ID + * in RTU (4 bytes)) but it's a convenient size to use in RTU or TCP + * communications to read many values or write a single one. + * Maximum between : + * - HEADER_LENGTH_TCP (7) + function (1) + address (2) + number (2) + * - HEADER_LENGTH_RTU (1) + function (1) + address (2) + number (2) + CRC (2) + */ +#define _MIN_REQ_LENGTH 12 + +#define _REPORT_SLAVE_ID 180 + +#define _MODBUS_EXCEPTION_RSP_LENGTH 5 + +/* Timeouts in microsecond (0.5 s) */ +#define _RESPONSE_TIMEOUT 500000 +#define _BYTE_TIMEOUT 500000 + +typedef enum { + _MODBUS_BACKEND_TYPE_RTU=0, + _MODBUS_BACKEND_TYPE_TCP +} modbus_backend_type_t; + +/* + * ---------- Request Indication ---------- + * | Client | ---------------------->| Server | + * ---------- Confirmation Response ---------- + */ +typedef enum { + /* Request message on the server side */ + MSG_INDICATION, + /* Request message on the client side */ + MSG_CONFIRMATION +} msg_type_t; + +/* This structure reduces the number of params in functions and so + * optimizes the speed of execution (~ 37%). */ +typedef struct _sft { + int slave; + int function; + int t_id; +} sft_t; + +typedef struct _modbus_backend { + unsigned int backend_type; + unsigned int header_length; + unsigned int checksum_length; + unsigned int max_adu_length; + int (*set_slave) (modbus_t *ctx, int slave); + int (*build_request_basis) (modbus_t *ctx, int function, int addr, + int nb, uint8_t *req); + int (*build_response_basis) (sft_t *sft, uint8_t *rsp); + int (*prepare_response_tid) (const uint8_t *req, int *req_length); + int (*send_msg_pre) (uint8_t *req, int req_length); + ssize_t (*send) (modbus_t *ctx, const uint8_t *req, int req_length); + int (*receive) (modbus_t *ctx, uint8_t *req); + ssize_t (*recv) (modbus_t *ctx, uint8_t *rsp, int rsp_length); + int (*check_integrity) (modbus_t *ctx, uint8_t *msg, + const int msg_length); + int (*pre_check_confirmation) (modbus_t *ctx, const uint8_t *req, + const uint8_t *rsp, int rsp_length); + int (*connect) (modbus_t *ctx); + void (*close) (modbus_t *ctx); + int (*flush) (modbus_t *ctx); + int (*select) (modbus_t *ctx, fd_set *rset, struct timeval *tv, int msg_length); + void (*free) (modbus_t *ctx); +} modbus_backend_t; + +struct _modbus { + /* Slave address */ + int slave; + /* Socket or file descriptor */ + int s; + int debug; + int error_recovery; + struct timeval response_timeout; + struct timeval byte_timeout; + struct timeval indication_timeout; + const modbus_backend_t *backend; + void *backend_data; +}; + +void _modbus_init_common(modbus_t *ctx); +void _error_print(modbus_t *ctx, const char *context); +int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type); + +#ifndef HAVE_STRLCPY +size_t strlcpy(char *dest, const char *src, size_t dest_size); +#endif + +MODBUS_END_DECLS + +#endif /* MODBUS_PRIVATE_H */ diff --git a/CigaretteSingle/modbus/modbus-rtu-private.h b/CigaretteSingle/modbus/modbus-rtu-private.h new file mode 100644 index 0000000..1c7d478 --- /dev/null +++ b/CigaretteSingle/modbus/modbus-rtu-private.h @@ -0,0 +1,76 @@ +/* + * Copyright © 2001-2011 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_RTU_PRIVATE_H +#define MODBUS_RTU_PRIVATE_H + +#ifndef _MSC_VER +#include +#else +#include "stdint.h" +#endif + +#if defined(_WIN32) +#include +#else +#include +#endif + +#define _MODBUS_RTU_HEADER_LENGTH 1 +#define _MODBUS_RTU_PRESET_REQ_LENGTH 6 +#define _MODBUS_RTU_PRESET_RSP_LENGTH 2 + +#define _MODBUS_RTU_CHECKSUM_LENGTH 2 + +#if defined(_WIN32) +#if !defined(ENOTSUP) +#define ENOTSUP WSAEOPNOTSUPP +#endif + +/* WIN32: struct containing serial handle and a receive buffer */ +#define PY_BUF_SIZE 512 +struct win32_ser { + /* File handle */ + HANDLE fd; + /* Receive buffer */ + uint8_t buf[PY_BUF_SIZE]; + /* Received chars */ + DWORD n_bytes; +}; +#endif /* _WIN32 */ + +typedef struct _modbus_rtu { + /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*" on Mac OS X. */ + char *device; + /* Bauds: 9600, 19200, 57600, 115200, etc */ + int baud; + /* Data bit */ + uint8_t data_bit; + /* Stop bit */ + uint8_t stop_bit; + /* Parity: 'N', 'O', 'E' */ + char parity; +#if defined(_WIN32) + struct win32_ser w_ser; + DCB old_dcb; +#else + /* Save old termios settings */ + struct termios old_tios; +#endif +#if HAVE_DECL_TIOCSRS485 + int serial_mode; +#endif +#if HAVE_DECL_TIOCM_RTS + int rts; + int rts_delay; + int onebyte_time; + void (*set_rts) (modbus_t *ctx, int on); +#endif + /* To handle many slaves on the same link */ + int confirmation_to_ignore; +} modbus_rtu_t; + +#endif /* MODBUS_RTU_PRIVATE_H */ diff --git a/CigaretteSingle/modbus/modbus-rtu.h b/CigaretteSingle/modbus/modbus-rtu.h new file mode 100644 index 0000000..fa37655 --- /dev/null +++ b/CigaretteSingle/modbus/modbus-rtu.h @@ -0,0 +1,42 @@ +/* + * Copyright © 2001-2011 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_RTU_H +#define MODBUS_RTU_H + +#include "modbus.h" + +MODBUS_BEGIN_DECLS + +/* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 + * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes + */ +#define MODBUS_RTU_MAX_ADU_LENGTH 256 + +MODBUS_API modbus_t* modbus_new_rtu(const char *device, int baud, char parity, + int data_bit, int stop_bit); + +#define MODBUS_RTU_RS232 0 +#define MODBUS_RTU_RS485 1 + +MODBUS_API int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode); +MODBUS_API int modbus_rtu_get_serial_mode(modbus_t *ctx); + +#define MODBUS_RTU_RTS_NONE 0 +#define MODBUS_RTU_RTS_UP 1 +#define MODBUS_RTU_RTS_DOWN 2 + +MODBUS_API int modbus_rtu_set_rts(modbus_t *ctx, int mode); +MODBUS_API int modbus_rtu_get_rts(modbus_t *ctx); + +MODBUS_API int modbus_rtu_set_custom_rts(modbus_t *ctx, void (*set_rts) (modbus_t *ctx, int on)); + +MODBUS_API int modbus_rtu_set_rts_delay(modbus_t *ctx, int us); +MODBUS_API int modbus_rtu_get_rts_delay(modbus_t *ctx); + +MODBUS_END_DECLS + +#endif /* MODBUS_RTU_H */ diff --git a/CigaretteSingle/modbus/modbus-tcp-private.h b/CigaretteSingle/modbus/modbus-tcp-private.h new file mode 100644 index 0000000..780587c --- /dev/null +++ b/CigaretteSingle/modbus/modbus-tcp-private.h @@ -0,0 +1,44 @@ +/* + * Copyright © 2001-2011 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_TCP_PRIVATE_H +#define MODBUS_TCP_PRIVATE_H + +#define _MODBUS_TCP_HEADER_LENGTH 7 +#define _MODBUS_TCP_PRESET_REQ_LENGTH 12 +#define _MODBUS_TCP_PRESET_RSP_LENGTH 8 + +#define _MODBUS_TCP_CHECKSUM_LENGTH 0 + +/* In both structures, the transaction ID must be placed on first position + to have a quick access not dependant of the TCP backend */ +typedef struct _modbus_tcp { + /* Extract from MODBUS Messaging on TCP/IP Implementation Guide V1.0b + (page 23/46): + The transaction identifier is used to associate the future response + with the request. This identifier is unique on each TCP connection. */ + uint16_t t_id; + /* TCP port */ + int port; + /* IP address */ + char ip[16]; +} modbus_tcp_t; + +#define _MODBUS_TCP_PI_NODE_LENGTH 1025 +#define _MODBUS_TCP_PI_SERVICE_LENGTH 32 + +typedef struct _modbus_tcp_pi { + /* Transaction ID */ + uint16_t t_id; + /* TCP port */ + int port; + /* Node */ + char node[_MODBUS_TCP_PI_NODE_LENGTH]; + /* Service */ + char service[_MODBUS_TCP_PI_SERVICE_LENGTH]; +} modbus_tcp_pi_t; + +#endif /* MODBUS_TCP_PRIVATE_H */ diff --git a/CigaretteSingle/modbus/modbus-tcp.h b/CigaretteSingle/modbus/modbus-tcp.h new file mode 100644 index 0000000..d67c239 --- /dev/null +++ b/CigaretteSingle/modbus/modbus-tcp.h @@ -0,0 +1,52 @@ +/* + * Copyright © 2001-2010 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_TCP_H +#define MODBUS_TCP_H + +#include "modbus.h" + +MODBUS_BEGIN_DECLS + +#if defined(_WIN32) && !defined(__CYGWIN__) +/* Win32 with MinGW, supplement to */ +#include +#if !defined(ECONNRESET) +#define ECONNRESET WSAECONNRESET +#endif +#if !defined(ECONNREFUSED) +#define ECONNREFUSED WSAECONNREFUSED +#endif +#if !defined(ETIMEDOUT) +#define ETIMEDOUT WSAETIMEDOUT +#endif +#if !defined(ENOPROTOOPT) +#define ENOPROTOOPT WSAENOPROTOOPT +#endif +#if !defined(EINPROGRESS) +#define EINPROGRESS WSAEINPROGRESS +#endif +#endif + +#define MODBUS_TCP_DEFAULT_PORT 502 +#define MODBUS_TCP_SLAVE 0xFF + +/* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5 + * TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes + */ +#define MODBUS_TCP_MAX_ADU_LENGTH 260 + +MODBUS_API modbus_t* modbus_new_tcp(const char *ip_address, int port); +MODBUS_API int modbus_tcp_listen(modbus_t *ctx, int nb_connection); +MODBUS_API int modbus_tcp_accept(modbus_t *ctx, int *s); + +MODBUS_API modbus_t* modbus_new_tcp_pi(const char *node, const char *service); +MODBUS_API int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection); +MODBUS_API int modbus_tcp_pi_accept(modbus_t *ctx, int *s); + +MODBUS_END_DECLS + +#endif /* MODBUS_TCP_H */ diff --git a/CigaretteSingle/modbus/modbus-version.h b/CigaretteSingle/modbus/modbus-version.h new file mode 100644 index 0000000..0218973 --- /dev/null +++ b/CigaretteSingle/modbus/modbus-version.h @@ -0,0 +1,53 @@ +/* + * Copyright © 2010-2014 Stéphane Raimbault + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MODBUS_VERSION_H +#define MODBUS_VERSION_H + +/* The major version, (1, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MAJOR (3) + +/* The minor version (2, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MINOR (1) + +/* The micro version (3, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MICRO (6) + +/* The full version, like 1.2.3 */ +#define LIBMODBUS_VERSION 3.1.6 + +/* The full version, in string form (suited for string concatenation) + */ +#define LIBMODBUS_VERSION_STRING "3.1.6" + +/* Numerically encoded version, eg. v1.2.3 is 0x010203 */ +#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_VERSION_MAJOR << 16) | \ + (LIBMODBUS_VERSION_MINOR << 8) | \ + (LIBMODBUS_VERSION_MICRO << 0)) + +/* Evaluates to True if the version is greater than @major, @minor and @micro + */ +#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \ + (LIBMODBUS_VERSION_MAJOR > (major) || \ + (LIBMODBUS_VERSION_MAJOR == (major) && \ + LIBMODBUS_VERSION_MINOR > (minor)) || \ + (LIBMODBUS_VERSION_MAJOR == (major) && \ + LIBMODBUS_VERSION_MINOR == (minor) && \ + LIBMODBUS_VERSION_MICRO >= (micro))) + +#endif /* MODBUS_VERSION_H */ diff --git a/CigaretteSingle/modbus/modbus.h b/CigaretteSingle/modbus/modbus.h new file mode 100644 index 0000000..24808ea --- /dev/null +++ b/CigaretteSingle/modbus/modbus.h @@ -0,0 +1,297 @@ +/* + * Copyright © 2001-2013 Stéphane Raimbault + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef MODBUS_H +#define MODBUS_H + +/* Add this for macros that defined unix flavor */ +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include +#endif + +#ifndef _MSC_VER +#include +#else +#include "stdint.h" +#endif + +#include "modbus-version.h" + +#if defined(_MSC_VER) +# if defined(DLLBUILD) +/* define DLLBUILD when building the DLL */ +# define MODBUS_API __declspec(dllexport) +# else +# define MODBUS_API __declspec(dllimport) +# endif +#else +# define MODBUS_API +#endif + +#ifdef __cplusplus +# define MODBUS_BEGIN_DECLS extern "C" { +# define MODBUS_END_DECLS } +#else +# define MODBUS_BEGIN_DECLS +# define MODBUS_END_DECLS +#endif + +MODBUS_BEGIN_DECLS + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef OFF +#define OFF 0 +#endif + +#ifndef ON +#define ON 1 +#endif + +/* Modbus function codes */ +#define MODBUS_FC_READ_COILS 0x01 +#define MODBUS_FC_READ_DISCRETE_INPUTS 0x02 +#define MODBUS_FC_READ_HOLDING_REGISTERS 0x03 +#define MODBUS_FC_READ_INPUT_REGISTERS 0x04 +#define MODBUS_FC_WRITE_SINGLE_COIL 0x05 +#define MODBUS_FC_WRITE_SINGLE_REGISTER 0x06 +#define MODBUS_FC_READ_EXCEPTION_STATUS 0x07 +#define MODBUS_FC_WRITE_MULTIPLE_COILS 0x0F +#define MODBUS_FC_WRITE_MULTIPLE_REGISTERS 0x10 +#define MODBUS_FC_REPORT_SLAVE_ID 0x11 +#define MODBUS_FC_MASK_WRITE_REGISTER 0x16 +#define MODBUS_FC_WRITE_AND_READ_REGISTERS 0x17 + +#define MODBUS_BROADCAST_ADDRESS 0 + +/* Modbus_Application_Protocol_V1_1b.pdf (chapter 6 section 1 page 12) + * Quantity of Coils to read (2 bytes): 1 to 2000 (0x7D0) + * (chapter 6 section 11 page 29) + * Quantity of Coils to write (2 bytes): 1 to 1968 (0x7B0) + */ +#define MODBUS_MAX_READ_BITS 2000 +#define MODBUS_MAX_WRITE_BITS 1968 + +/* Modbus_Application_Protocol_V1_1b.pdf (chapter 6 section 3 page 15) + * Quantity of Registers to read (2 bytes): 1 to 125 (0x7D) + * (chapter 6 section 12 page 31) + * Quantity of Registers to write (2 bytes) 1 to 123 (0x7B) + * (chapter 6 section 17 page 38) + * Quantity of Registers to write in R/W registers (2 bytes) 1 to 121 (0x79) + */ +#define MODBUS_MAX_READ_REGISTERS 125 +#define MODBUS_MAX_WRITE_REGISTERS 123 +#define MODBUS_MAX_WR_WRITE_REGISTERS 121 +#define MODBUS_MAX_WR_READ_REGISTERS 125 + +/* The size of the MODBUS PDU is limited by the size constraint inherited from + * the first MODBUS implementation on Serial Line network (max. RS485 ADU = 256 + * bytes). Therefore, MODBUS PDU for serial line communication = 256 - Server + * address (1 byte) - CRC (2 bytes) = 253 bytes. + */ +#define MODBUS_MAX_PDU_LENGTH 253 + +/* Consequently: + * - RTU MODBUS ADU = 253 bytes + Server address (1 byte) + CRC (2 bytes) = 256 + * bytes. + * - TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes. + * so the maximum of both backend in 260 bytes. This size can used to allocate + * an array of bytes to store responses and it will be compatible with the two + * backends. + */ +#define MODBUS_MAX_ADU_LENGTH 260 + +/* Random number to avoid errno conflicts */ +#define MODBUS_ENOBASE 112345678 + +/* Protocol exceptions */ +enum { + MODBUS_EXCEPTION_ILLEGAL_FUNCTION = 0x01, + MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS, + MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, + MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE, + MODBUS_EXCEPTION_ACKNOWLEDGE, + MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY, + MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE, + MODBUS_EXCEPTION_MEMORY_PARITY, + MODBUS_EXCEPTION_NOT_DEFINED, + MODBUS_EXCEPTION_GATEWAY_PATH, + MODBUS_EXCEPTION_GATEWAY_TARGET, + MODBUS_EXCEPTION_MAX +}; + +#define EMBXILFUN (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_FUNCTION) +#define EMBXILADD (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS) +#define EMBXILVAL (MODBUS_ENOBASE + MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE) +#define EMBXSFAIL (MODBUS_ENOBASE + MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE) +#define EMBXACK (MODBUS_ENOBASE + MODBUS_EXCEPTION_ACKNOWLEDGE) +#define EMBXSBUSY (MODBUS_ENOBASE + MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY) +#define EMBXNACK (MODBUS_ENOBASE + MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE) +#define EMBXMEMPAR (MODBUS_ENOBASE + MODBUS_EXCEPTION_MEMORY_PARITY) +#define EMBXGPATH (MODBUS_ENOBASE + MODBUS_EXCEPTION_GATEWAY_PATH) +#define EMBXGTAR (MODBUS_ENOBASE + MODBUS_EXCEPTION_GATEWAY_TARGET) + +/* Native libmodbus error codes */ +#define EMBBADCRC (EMBXGTAR + 1) +#define EMBBADDATA (EMBXGTAR + 2) +#define EMBBADEXC (EMBXGTAR + 3) +#define EMBUNKEXC (EMBXGTAR + 4) +#define EMBMDATA (EMBXGTAR + 5) +#define EMBBADSLAVE (EMBXGTAR + 6) + +extern const unsigned int libmodbus_version_major; +extern const unsigned int libmodbus_version_minor; +extern const unsigned int libmodbus_version_micro; + +typedef struct _modbus modbus_t; + +typedef struct _modbus_mapping_t { + int nb_bits; + int start_bits; + int nb_input_bits; + int start_input_bits; + int nb_input_registers; + int start_input_registers; + int nb_registers; + int start_registers; + uint8_t *tab_bits; + uint8_t *tab_input_bits; + uint16_t *tab_input_registers; + uint16_t *tab_registers; +} modbus_mapping_t; + +typedef enum +{ + MODBUS_ERROR_RECOVERY_NONE = 0, + MODBUS_ERROR_RECOVERY_LINK = (1<<1), + MODBUS_ERROR_RECOVERY_PROTOCOL = (1<<2) +} modbus_error_recovery_mode; + +MODBUS_API int modbus_set_slave(modbus_t* ctx, int slave); +MODBUS_API int modbus_get_slave(modbus_t* ctx); +MODBUS_API int modbus_set_error_recovery(modbus_t *ctx, modbus_error_recovery_mode error_recovery); +MODBUS_API int modbus_set_socket(modbus_t *ctx, int s); +MODBUS_API int modbus_get_socket(modbus_t *ctx); + +MODBUS_API int modbus_get_response_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); +MODBUS_API int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); + +MODBUS_API int modbus_get_byte_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); +MODBUS_API int modbus_set_byte_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); + +MODBUS_API int modbus_get_indication_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); +MODBUS_API int modbus_set_indication_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); + +MODBUS_API int modbus_get_header_length(modbus_t *ctx); + +MODBUS_API int modbus_connect(modbus_t *ctx); +MODBUS_API void modbus_close(modbus_t *ctx); + +MODBUS_API void modbus_free(modbus_t *ctx); + +MODBUS_API int modbus_flush(modbus_t *ctx); +MODBUS_API int modbus_set_debug(modbus_t *ctx, int flag); + +MODBUS_API const char *modbus_strerror(int errnum); + +MODBUS_API int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest); +MODBUS_API int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest); +MODBUS_API int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest); +MODBUS_API int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest); +MODBUS_API int modbus_write_bit(modbus_t *ctx, int coil_addr, int status); +MODBUS_API int modbus_write_register(modbus_t *ctx, int reg_addr, const uint16_t value); +MODBUS_API int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data); +MODBUS_API int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *data); +MODBUS_API int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and_mask, uint16_t or_mask); +MODBUS_API int modbus_write_and_read_registers(modbus_t *ctx, int write_addr, int write_nb, + const uint16_t *src, int read_addr, int read_nb, + uint16_t *dest); +MODBUS_API int modbus_report_slave_id(modbus_t *ctx, int max_dest, uint8_t *dest); + +MODBUS_API modbus_mapping_t* modbus_mapping_new_start_address( + unsigned int start_bits, unsigned int nb_bits, + unsigned int start_input_bits, unsigned int nb_input_bits, + unsigned int start_registers, unsigned int nb_registers, + unsigned int start_input_registers, unsigned int nb_input_registers); + +MODBUS_API modbus_mapping_t* modbus_mapping_new(int nb_bits, int nb_input_bits, + int nb_registers, int nb_input_registers); +MODBUS_API void modbus_mapping_free(modbus_mapping_t *mb_mapping); + +MODBUS_API int modbus_send_raw_request(modbus_t *ctx, const uint8_t *raw_req, int raw_req_length); + +MODBUS_API int modbus_receive(modbus_t *ctx, uint8_t *req); + +MODBUS_API int modbus_receive_confirmation(modbus_t *ctx, uint8_t *rsp); + +MODBUS_API int modbus_reply(modbus_t *ctx, const uint8_t *req, + int req_length, modbus_mapping_t *mb_mapping); +MODBUS_API int modbus_reply_exception(modbus_t *ctx, const uint8_t *req, + unsigned int exception_code); + +/** + * UTILS FUNCTIONS + **/ + +#define MODBUS_GET_HIGH_BYTE(data) (((data) >> 8) & 0xFF) +#define MODBUS_GET_LOW_BYTE(data) ((data) & 0xFF) +#define MODBUS_GET_INT64_FROM_INT16(tab_int16, index) \ + (((int64_t)tab_int16[(index) ] << 48) | \ + ((int64_t)tab_int16[(index) + 1] << 32) | \ + ((int64_t)tab_int16[(index) + 2] << 16) | \ + (int64_t)tab_int16[(index) + 3]) +#define MODBUS_GET_INT32_FROM_INT16(tab_int16, index) \ + (((int32_t)tab_int16[(index) ] << 16) | \ + (int32_t)tab_int16[(index) + 1]) +#define MODBUS_GET_INT16_FROM_INT8(tab_int8, index) \ + (((int16_t)tab_int8[(index) ] << 8) | \ + (int16_t)tab_int8[(index) + 1]) +#define MODBUS_SET_INT16_TO_INT8(tab_int8, index, value) \ + do { \ + ((int8_t*)(tab_int8))[(index) ] = (int8_t)((value) >> 8); \ + ((int8_t*)(tab_int8))[(index) + 1] = (int8_t)(value); \ + } while (0) +#define MODBUS_SET_INT32_TO_INT16(tab_int16, index, value) \ + do { \ + ((int16_t*)(tab_int16))[(index) ] = (int16_t)((value) >> 16); \ + ((int16_t*)(tab_int16))[(index) + 1] = (int16_t)(value); \ + } while (0) +#define MODBUS_SET_INT64_TO_INT16(tab_int16, index, value) \ + do { \ + ((int16_t*)(tab_int16))[(index) ] = (int16_t)((value) >> 48); \ + ((int16_t*)(tab_int16))[(index) + 1] = (int16_t)((value) >> 32); \ + ((int16_t*)(tab_int16))[(index) + 2] = (int16_t)((value) >> 16); \ + ((int16_t*)(tab_int16))[(index) + 3] = (int16_t)(value); \ + } while (0) + +MODBUS_API void modbus_set_bits_from_byte(uint8_t *dest, int idx, const uint8_t value); +MODBUS_API void modbus_set_bits_from_bytes(uint8_t *dest, int idx, unsigned int nb_bits, + const uint8_t *tab_byte); +MODBUS_API uint8_t modbus_get_byte_from_bits(const uint8_t *src, int idx, unsigned int nb_bits); +MODBUS_API float modbus_get_float(const uint16_t *src); +MODBUS_API float modbus_get_float_abcd(const uint16_t *src); +MODBUS_API float modbus_get_float_dcba(const uint16_t *src); +MODBUS_API float modbus_get_float_badc(const uint16_t *src); +MODBUS_API float modbus_get_float_cdab(const uint16_t *src); + +MODBUS_API void modbus_set_float(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_abcd(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_dcba(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_badc(float f, uint16_t *dest); +MODBUS_API void modbus_set_float_cdab(float f, uint16_t *dest); + +#include "modbus-tcp.h" +#include "modbus-rtu.h" + +MODBUS_END_DECLS + +#endif /* MODBUS_H */ diff --git a/CigaretteSingle/modbus/modbus.lib b/CigaretteSingle/modbus/modbus.lib new file mode 100644 index 0000000..1ac2089 Binary files /dev/null and b/CigaretteSingle/modbus/modbus.lib differ diff --git a/CigaretteSingle/test/1.jpg b/CigaretteSingle/test/1.jpg new file mode 100644 index 0000000..4ecb712 Binary files /dev/null and b/CigaretteSingle/test/1.jpg differ diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/Setup/Setup.vdproj b/Setup/Setup.vdproj new file mode 100644 index 0000000..33377c4 --- /dev/null +++ b/Setup/Setup.vdproj @@ -0,0 +1,3644 @@ +"DeployProject" +{ +"VSVersion" = "3:800" +"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" +"IsWebType" = "8:FALSE" +"ProjectName" = "8:Setup" +"LanguageId" = "3:2052" +"CodePage" = "3:936" +"UILanguageId" = "3:2052" +"SccProjectName" = "8:" +"SccLocalPath" = "8:" +"SccAuxPath" = "8:" +"SccProvider" = "8:" + "Hierarchy" + { + "Entry" + { + "MsmKey" = "8:_0444449EE2434FA4989F390BF7FFD09C" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_07C15F9C05BB494DB505F6B6D37B82C8" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_09C781C2FC214223A8411CBD3360361E" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_0BA0D0C89BE245438939E64B7E5AD2F4" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_0C59200A804F4D90B2F02FFC271CA890" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_0D63D6344B6442A183C45E5783EA4742" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_106C2BAEE2AA4D72B63D91AAEC09A99E" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_106EE21A89EC455684D31614132476AA" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_10CC9367DEE14EB98F04240B462B38C4" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_11424364F0BA4F479241C8BC264F6660" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_142546ADDE584DE58E65C5EB62BD0CD5" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_161C5264EC6A4A4FBD9B14ECF379220D" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_1E2A633E668041889E6E7FF7A0FE5230" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_1E7C71E38DE64BD495926096F8E908DC" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_20159A91CC5C4FFE94BCE9A99AB7BF0D" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_207CD01AFBD34C468D9C233794BDAF29" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_2254FD5164674020B66B22B3A0DB4EC4" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_25DABBE7006B450095049CFD62B019B2" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_2893B1F7A4014201B33E0E5328350A8C" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_2A05AC3FAF8645AA8BE91C2716CDFF82" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_2C9C8C65BA7E43ACAB2B9A84000AEECF" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_2FEF3A24BF6949B389E1659BE7DEEA5A" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_32065F6C2A83401FA41125CB0A26BDFE" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_32C38F97E53C4532A8ED67B7ED01CA35" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_37C9F3B917FB476A992930D3B240DBFF" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_430E5A073E56462A91B76F6448ED3B3B" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_44368CB57A8C4FFA86F041D683CBED57" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_444630636A0D4B06B324DD90A692E266" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_47053C51C90F4B03A72DEACBB43F7C85" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_472F6384CCE441F08CC4C2A94F7AD3C6" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_4E163E9F076C4FB4AF3EB6D1F986C4A9" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_5284F6AAA9BF4658B19BC2EEEED437D3" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_536A6DFCCD1E4BAD946EDB96AB1AE95E" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_569C6EA1F6AE4C86BD5D9C2B9E982E5F" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_5819E0F3660541F3B080FEE67FF5BAAA" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_5E428D16A1EF4FC1845C7463206ADA06" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_60F0D9A3DE4B4355A27DF60F14C9952D" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_61289D0704E640FFB006CCDF7C5E4A5C" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_62C13125E8A94BA3B1473A3D610036B8" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_63014E6D55824C8390E2787EAE62A763" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_63300CC0A73D49EC9692274335F5CB8D" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_634B8592603F498DA0E82D23DE2C078F" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_697E7C42C11A44478E52F518A06E1E56" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_699B2568D16047458CBAD89D8D92941F" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_72B496E7E2734A44BDF6020FD64987C8" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_72C40BD172834DD3A7115B4EB453EB72" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_7311DE504677403687B35E3241B02D89" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_76BEC7F9B06C4F85BB8F91A1641AB418" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_79B84157233E4BEB93D4E7F6B30C3285" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_7A20214A40304488A5F51EE401C92247" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_7A8B096DB91F45F0B068FD522CFEAAF3" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_7C5A2E67576048BEB0BA567E6372614A" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_7ED8B914C15C496798E20230883A81D2" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8010FD6C2DA046B7989EBD1905C960D2" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_807E851B198D497A8D9BFB4FFA665EF2" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_80FDDA94CE2142B0993C8AC5CCF1AC85" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8177DF1667034A3FA679F894E463BB12" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_822B7F484BFC460AA67CF89DAF1CB8CA" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8417E7B7DB6F4ABFA5D697CE9B3CB76C" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_86EA1D2E97EE48D69D5C66F60D3FC136" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_87DE188FB10645838AD9D4033795B84A" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8BFF4EFB5D564B048ADFD7CAACC4D095" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8E5058E35FF74860AA04191234D8CACC" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8F6409E72362447E8D6CABD3F3729A00" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_8FE140442B6D4DC2BB517FC441398B08" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_90C40352FA98406C95124E29DE8A2560" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_911E041E6F704C9A899A8C750FE771E6" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_919EE6A1A8A24124AB87C15A8182AD3B" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_93026DCBC7DC44BF8138B9F3EE8BEA45" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_963E413BFF9B4A909D6213112C55F48F" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_984622D22307438ABAA6CAA3BD55529B" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_9CD596EEA01B4250B91091D07F5DCCC9" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A0D1E8FE7AA04923B69C74047751F1D3" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A28324EE44504AC6BD8436D93BC0E849" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A2DC7051B1364085BFE68307D1970D14" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A4A0BC24AE014898972DB07C734B2188" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A696BA7F2B7A4AFEB8C13F0686472EAC" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A6FE61C2FE034F81A07DBFCE38C2D6AC" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A7403B9D9C6249F6BC5CF59D79617305" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_ABB8F4669E694B8FA156F23CFCC32C17" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_AC82CF7AD71A466B89C74B7FB632555C" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_AF372DCC8CC54770A2BE5C02CD027DA1" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_B7112307C85D4245BB19660E463C44FA" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_B8BB66FDF730433AA37BC50FEED689D9" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_B9469DDDFC6742EF9378E678B86A3386" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_BB1F912A8576465384D1034794F0E802" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_C1FA23D25B87424A8CAF5177AC0F77FF" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_C3B444947CA84A45B3021112D957D450" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_CA180B9B89864CABA492ABCF207C3DEC" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_CB6B08CAC09C4476A705682F74F87482" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_CEBB33035C4C4FCEBF1A82809A644849" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_D2CE10A5562F42A9BC5D468C380101E3" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_D6A9835E19F74AEBB831038F4D6876E9" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_DA6E38363D10415AAF0FE60473FD2F54" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_DA95575312564E21BD459AE78E5B2139" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_DDA0D9F1027E47E388AAEAF52506F58B" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_DF5E661BCED1496289173C48D2733AD5" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_E0CED750D1DF4BE5B6A13A63A8E859E2" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_E12AE9EBD9D74822AC482B2C3691CFF5" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_E4DAAFA194424FD8846298633DDDFD82" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_E8A50CBAE87C4B90AF32DD14043C96EF" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_ED79C9CCA49A4273BEB9BE0E803D96E2" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F37EC15BA95646B5803CAB142943EABE" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F4686342729344769B8FB6D749B7568F" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F4EED7FC1D854494ADFEC8DC6BE478EA" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F532F71D12E343CC8B08E9FF0A4724B1" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F57E0941D3FF4ACBBC116630C38B8001" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F8B2E5B1F6994416B9F4B98CE26573A3" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_FB7B48079FD54792A10AB104BD0B6082" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_FFE4F0E27B984E33AFE0BFF44A96FBDF" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_UNDEFINED" + "OwnerKey" = "8:_A2DC7051B1364085BFE68307D1970D14" + "MsmSig" = "8:_UNDEFINED" + } + } + "Configurations" + { + "Debug" + { + "DisplayName" = "8:Debug" + "IsDebugOnly" = "11:TRUE" + "IsReleaseOnly" = "11:FALSE" + "OutputFilename" = "8:Debug\\Setup.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + "Release" + { + "DisplayName" = "8:Release" + "IsDebugOnly" = "11:FALSE" + "IsReleaseOnly" = "11:TRUE" + "OutputFilename" = "8:Release\\Setup.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + } + "Deployable" + { + "CustomAction" + { + } + "DefaultFeature" + { + "Name" = "8:DefaultFeature" + "Title" = "8:" + "Description" = "8:" + } + "ExternalPersistence" + { + "LaunchCondition" + { + "{A06ECF26-33A3-4562-8140-9B0E340D4F24}:_5F00DC28A6274118B7E46B5DDEE18F16" + { + "Name" = "8:.NET Framework" + "Message" = "8:[VSDNETMSG]" + "FrameworkVersion" = "8:.NETFramework,Version=v4.7.2" + "AllowLaterVersions" = "11:FALSE" + "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=863262" + } + } + } + "File" + { + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0444449EE2434FA4989F390BF7FFD09C" + { + "SourcePath" = "8:..\\runtime\\Log_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:Log_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_07C15F9C05BB494DB505F6B6D37B82C8" + { + "SourcePath" = "8:..\\x64\\Release\\splash.jpg" + "TargetName" = "8:splash.jpg" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_09C781C2FC214223A8411CBD3360361E" + { + "SourcePath" = "8:..\\runtime\\PylonGtc_v6_2_TL.dll" + "TargetName" = "8:PylonGtc_v6_2_TL.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0BA0D0C89BE245438939E64B7E5AD2F4" + { + "SourcePath" = "8:..\\runtime\\avutil-55.dll" + "TargetName" = "8:avutil-55.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0C59200A804F4D90B2F02FFC271CA890" + { + "SourcePath" = "8:..\\runtime\\NodeMapData_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:NodeMapData_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0D63D6344B6442A183C45E5783EA4742" + { + "SourcePath" = "8:..\\runtime\\avdevice-57.dll" + "TargetName" = "8:avdevice-57.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_106C2BAEE2AA4D72B63D91AAEC09A99E" + { + "SourcePath" = "8:..\\runtime\\mycomput.dll" + "TargetName" = "8:mycomput.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_106EE21A89EC455684D31614132476AA" + { + "SourcePath" = "8:..\\runtime\\mydocs.dll" + "TargetName" = "8:mydocs.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_10CC9367DEE14EB98F04240B462B38C4" + { + "SourcePath" = "8:..\\x64\\Release\\pswd_op.txt" + "TargetName" = "8:pswd_op.txt" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_11424364F0BA4F479241C8BC264F6660" + { + "SourcePath" = "8:..\\conf\\plc.txt" + "TargetName" = "8:plc.txt" + "Tag" = "8:" + "Folder" = "8:_239A93F3E45C4F6DA4C65C0DB3F8C12F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_142546ADDE584DE58E65C5EB62BD0CD5" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qtiff.dll" + "TargetName" = "8:qtiff.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_161C5264EC6A4A4FBD9B14ECF379220D" + { + "SourcePath" = "8:..\\x64\\Release\\opengl32sw.dll" + "TargetName" = "8:opengl32sw.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1E2A633E668041889E6E7FF7A0FE5230" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_bg.qm" + "TargetName" = "8:qt_bg.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1E7C71E38DE64BD495926096F8E908DC" + { + "SourcePath" = "8:..\\x64\\Release\\Qt5Svg.dll" + "TargetName" = "8:Qt5Svg.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_20159A91CC5C4FFE94BCE9A99AB7BF0D" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_en.qm" + "TargetName" = "8:qt_en.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_207CD01AFBD34C468D9C233794BDAF29" + { + "SourcePath" = "8:..\\x64\\Release\\libGLESv2.dll" + "TargetName" = "8:libGLESv2.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2254FD5164674020B66B22B3A0DB4EC4" + { + "SourcePath" = "8:..\\runtime\\MvCameraControl.dll" + "TargetName" = "8:MvCameraControl.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_25DABBE7006B450095049CFD62B019B2" + { + "SourcePath" = "8:..\\runtime\\XmlParser_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:XmlParser_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2893B1F7A4014201B33E0E5328350A8C" + { + "SourcePath" = "8:..\\runtime\\CLSerCOM.dll" + "TargetName" = "8:CLSerCOM.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2A05AC3FAF8645AA8BE91C2716CDFF82" + { + "SourcePath" = "8:..\\runtime\\avformat-57.dll" + "TargetName" = "8:avformat-57.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2C9C8C65BA7E43ACAB2B9A84000AEECF" + { + "SourcePath" = "8:..\\runtime\\MediaProcess.dll" + "TargetName" = "8:MediaProcess.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2FEF3A24BF6949B389E1659BE7DEEA5A" + { + "SourcePath" = "8:..\\runtime\\CLProtocol_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:CLProtocol_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_32065F6C2A83401FA41125CB0A26BDFE" + { + "SourcePath" = "8:..\\runtime\\MvCamLVision.dll" + "TargetName" = "8:MvCamLVision.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_32C38F97E53C4532A8ED67B7ED01CA35" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qwebp.dll" + "TargetName" = "8:qwebp.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_37C9F3B917FB476A992930D3B240DBFF" + { + "SourcePath" = "8:..\\conf\\modbus.txt" + "TargetName" = "8:modbus.txt" + "Tag" = "8:" + "Folder" = "8:_239A93F3E45C4F6DA4C65C0DB3F8C12F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_430E5A073E56462A91B76F6448ED3B3B" + { + "SourcePath" = "8:..\\runtime\\NodeMapData_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:NodeMapData_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_44368CB57A8C4FFA86F041D683CBED57" + { + "SourcePath" = "8:..\\runtime\\GCBase_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:GCBase_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_444630636A0D4B06B324DD90A692E266" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qico.dll" + "TargetName" = "8:qico.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_47053C51C90F4B03A72DEACBB43F7C85" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_fi.qm" + "TargetName" = "8:qt_fi.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_472F6384CCE441F08CC4C2A94F7AD3C6" + { + "SourcePath" = "8:..\\runtime\\PylonUsb_v6_2_TL.dll" + "TargetName" = "8:PylonUsb_v6_2_TL.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4E163E9F076C4FB4AF3EB6D1F986C4A9" + { + "SourcePath" = "8:..\\runtime\\log4cpp_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:log4cpp_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5284F6AAA9BF4658B19BC2EEEED437D3" + { + "SourcePath" = "8:..\\runtime\\msvcp90.dll" + "TargetName" = "8:msvcp90.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_536A6DFCCD1E4BAD946EDB96AB1AE95E" + { + "SourcePath" = "8:..\\runtime\\mvPropHandling.dll" + "TargetName" = "8:mvPropHandling.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_569C6EA1F6AE4C86BD5D9C2B9E982E5F" + { + "SourcePath" = "8:..\\runtime\\PylonGUI_v6_2.dll" + "TargetName" = "8:PylonGUI_v6_2.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5819E0F3660541F3B080FEE67FF5BAAA" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_de.qm" + "TargetName" = "8:qt_de.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5E428D16A1EF4FC1845C7463206ADA06" + { + "SourcePath" = "8:..\\x64\\Release\\styles\\qwindowsvistastyle.dll" + "TargetName" = "8:qwindowsvistastyle.dll" + "Tag" = "8:" + "Folder" = "8:_373EB007C6B04A998B88DE10784490BA" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_60F0D9A3DE4B4355A27DF60F14C9952D" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_pl.qm" + "TargetName" = "8:qt_pl.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_61289D0704E640FFB006CCDF7C5E4A5C" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_fr.qm" + "TargetName" = "8:qt_fr.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_62C13125E8A94BA3B1473A3D610036B8" + { + "SourcePath" = "8:..\\runtime\\mvGenTLConsumer.dll" + "TargetName" = "8:mvGenTLConsumer.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_63300CC0A73D49EC9692274335F5CB8D" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_cs.qm" + "TargetName" = "8:qt_cs.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_634B8592603F498DA0E82D23DE2C078F" + { + "SourcePath" = "8:..\\runtime\\opencv_world455.dll" + "TargetName" = "8:opencv_world455.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_697E7C42C11A44478E52F518A06E1E56" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_ko.qm" + "TargetName" = "8:qt_ko.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_699B2568D16047458CBAD89D8D92941F" + { + "SourcePath" = "8:..\\runtime\\MVGigEVisionSDK.dll" + "TargetName" = "8:MVGigEVisionSDK.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_72B496E7E2734A44BDF6020FD64987C8" + { + "SourcePath" = "8:..\\runtime\\XmlParser_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:XmlParser_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_72C40BD172834DD3A7115B4EB453EB72" + { + "SourcePath" = "8:..\\runtime\\GCBase_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:GCBase_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7311DE504677403687B35E3241B02D89" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_ja.qm" + "TargetName" = "8:qt_ja.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_76BEC7F9B06C4F85BB8F91A1641AB418" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qjpeg.dll" + "TargetName" = "8:qjpeg.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_79B84157233E4BEB93D4E7F6B30C3285" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qicns.dll" + "TargetName" = "8:qicns.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7A20214A40304488A5F51EE401C92247" + { + "SourcePath" = "8:..\\x64\\Release\\iconengines\\qsvgicon.dll" + "TargetName" = "8:qsvgicon.dll" + "Tag" = "8:" + "Folder" = "8:_0699D201060A48998C77F36611B82669" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7A8B096DB91F45F0B068FD522CFEAAF3" + { + "SourcePath" = "8:..\\runtime\\msvcp120.dll" + "TargetName" = "8:msvcp120.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7C5A2E67576048BEB0BA567E6372614A" + { + "SourcePath" = "8:..\\runtime\\MvDSS.ax" + "TargetName" = "8:MvDSS.ax" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7ED8B914C15C496798E20230883A81D2" + { + "SourcePath" = "8:..\\runtime\\libmmd.dll" + "TargetName" = "8:libmmd.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8010FD6C2DA046B7989EBD1905C960D2" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_it.qm" + "TargetName" = "8:qt_it.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_807E851B198D497A8D9BFB4FFA665EF2" + { + "SourcePath" = "8:..\\runtime\\MvUsb3vTL.dll" + "TargetName" = "8:MvUsb3vTL.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_80FDDA94CE2142B0993C8AC5CCF1AC85" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_he.qm" + "TargetName" = "8:qt_he.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8177DF1667034A3FA679F894E463BB12" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_uk.qm" + "TargetName" = "8:qt_uk.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_822B7F484BFC460AA67CF89DAF1CB8CA" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_da.qm" + "TargetName" = "8:qt_da.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8417E7B7DB6F4ABFA5D697CE9B3CB76C" + { + "SourcePath" = "8:..\\x64\\Release\\platforms\\qwindows.dll" + "TargetName" = "8:qwindows.dll" + "Tag" = "8:" + "Folder" = "8:_B0BAE2CDE699435997CBCA9EE82FFC37" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_86EA1D2E97EE48D69D5C66F60D3FC136" + { + "SourcePath" = "8:..\\runtime\\modbus.dll" + "TargetName" = "8:modbus.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_87DE188FB10645838AD9D4033795B84A" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_ru.qm" + "TargetName" = "8:qt_ru.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8BFF4EFB5D564B048ADFD7CAACC4D095" + { + "SourcePath" = "8:..\\runtime\\swscale-4.dll" + "TargetName" = "8:swscale-4.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8E5058E35FF74860AA04191234D8CACC" + { + "SourcePath" = "8:..\\runtime\\PylonUtility_v6_2.dll" + "TargetName" = "8:PylonUtility_v6_2.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8F6409E72362447E8D6CABD3F3729A00" + { + "SourcePath" = "8:..\\runtime\\GenApi_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:GenApi_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8FE140442B6D4DC2BB517FC441398B08" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qwbmp.dll" + "TargetName" = "8:qwbmp.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_90C40352FA98406C95124E29DE8A2560" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_lv.qm" + "TargetName" = "8:qt_lv.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_911E041E6F704C9A899A8C750FE771E6" + { + "SourcePath" = "8:..\\x64\\Release\\alg_jd.jpg" + "TargetName" = "8:alg_jd.jpg" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_919EE6A1A8A24124AB87C15A8182AD3B" + { + "SourcePath" = "8:..\\runtime\\MvCameraControlWrapper.dll" + "TargetName" = "8:MvCameraControlWrapper.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_93026DCBC7DC44BF8138B9F3EE8BEA45" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_ca.qm" + "TargetName" = "8:qt_ca.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_963E413BFF9B4A909D6213112C55F48F" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_es.qm" + "TargetName" = "8:qt_es.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_984622D22307438ABAA6CAA3BD55529B" + { + "SourcePath" = "8:..\\runtime\\MvDSS2.ax" + "TargetName" = "8:MvDSS2.ax" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9CD596EEA01B4250B91091D07F5DCCC9" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_sk.qm" + "TargetName" = "8:qt_sk.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A0D1E8FE7AA04923B69C74047751F1D3" + { + "SourcePath" = "8:..\\runtime\\uxapi_v12.dll" + "TargetName" = "8:uxapi_v12.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A28324EE44504AC6BD8436D93BC0E849" + { + "SourcePath" = "8:..\\runtime\\MvProducerU3V.cti" + "TargetName" = "8:MvProducerU3V.cti" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_A2DC7051B1364085BFE68307D1970D14" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:msvcm90, Version=9.0.21022.8, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=AMD64" + "ScatterAssemblies" + { + "_A2DC7051B1364085BFE68307D1970D14" + { + "Name" = "8:msvcm90.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:..\\runtime\\msvcm90.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A4A0BC24AE014898972DB07C734B2188" + { + "SourcePath" = "8:..\\runtime\\GenApi_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:GenApi_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A696BA7F2B7A4AFEB8C13F0686472EAC" + { + "SourcePath" = "8:..\\runtime\\msvcr90.dll" + "TargetName" = "8:msvcr90.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A6FE61C2FE034F81A07DBFCE38C2D6AC" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_gd.qm" + "TargetName" = "8:qt_gd.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A7403B9D9C6249F6BC5CF59D79617305" + { + "SourcePath" = "8:..\\x64\\Release\\bearer\\qgenericbearer.dll" + "TargetName" = "8:qgenericbearer.dll" + "Tag" = "8:" + "Folder" = "8:_2D3CD59D2AAE416FA8423933EDAD2E70" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_ABB8F4669E694B8FA156F23CFCC32C17" + { + "SourcePath" = "8:..\\x64\\Release\\pswd.txt" + "TargetName" = "8:pswd.txt" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_AC82CF7AD71A466B89C74B7FB632555C" + { + "SourcePath" = "8:..\\conf\\rotate.txt" + "TargetName" = "8:rotate.txt" + "Tag" = "8:" + "Folder" = "8:_239A93F3E45C4F6DA4C65C0DB3F8C12F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_AF372DCC8CC54770A2BE5C02CD027DA1" + { + "SourcePath" = "8:..\\runtime\\PylonBase_v6_2.dll" + "TargetName" = "8:PylonBase_v6_2.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B7112307C85D4245BB19660E463C44FA" + { + "SourcePath" = "8:..\\runtime\\mvDeviceManager.dll" + "TargetName" = "8:mvDeviceManager.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B8BB66FDF730433AA37BC50FEED689D9" + { + "SourcePath" = "8:..\\runtime\\MvRender.dll" + "TargetName" = "8:MvRender.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_B9469DDDFC6742EF9378E678B86A3386" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qtga.dll" + "TargetName" = "8:qtga.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_BB1F912A8576465384D1034794F0E802" + { + "SourcePath" = "8:..\\x64\\Release\\libEGL.dll" + "TargetName" = "8:libEGL.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C1FA23D25B87424A8CAF5177AC0F77FF" + { + "SourcePath" = "8:..\\runtime\\avfilter-6.dll" + "TargetName" = "8:avfilter-6.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_C3B444947CA84A45B3021112D957D450" + { + "SourcePath" = "8:..\\runtime\\CLAllSerial_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:CLAllSerial_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CA180B9B89864CABA492ABCF207C3DEC" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_hu.qm" + "TargetName" = "8:qt_hu.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CB6B08CAC09C4476A705682F74F87482" + { + "SourcePath" = "8:..\\x64\\Release\\rotate.txt" + "TargetName" = "8:rotate.txt" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_CEBB33035C4C4FCEBF1A82809A644849" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_ar.qm" + "TargetName" = "8:qt_ar.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D2CE10A5562F42A9BC5D468C380101E3" + { + "SourcePath" = "8:..\\runtime\\MathParser_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:MathParser_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_D6A9835E19F74AEBB831038F4D6876E9" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qsvg.dll" + "TargetName" = "8:qsvg.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_DA6E38363D10415AAF0FE60473FD2F54" + { + "SourcePath" = "8:..\\runtime\\FirmwareUpdate_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:FirmwareUpdate_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_DA95575312564E21BD459AE78E5B2139" + { + "SourcePath" = "8:..\\runtime\\ProducerU3V.cti" + "TargetName" = "8:ProducerU3V.cti" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_DDA0D9F1027E47E388AAEAF52506F58B" + { + "SourcePath" = "8:..\\runtime\\mvDisplay.dll" + "TargetName" = "8:mvDisplay.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_DF5E661BCED1496289173C48D2733AD5" + { + "SourcePath" = "8:..\\runtime\\log4cpp_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:log4cpp_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E0CED750D1DF4BE5B6A13A63A8E859E2" + { + "SourcePath" = "8:..\\runtime\\Log_MD_VC141_v3_1_Basler_pylon.dll" + "TargetName" = "8:Log_MD_VC141_v3_1_Basler_pylon.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E12AE9EBD9D74822AC482B2C3691CFF5" + { + "SourcePath" = "8:..\\runtime\\FormatConversion.dll" + "TargetName" = "8:FormatConversion.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E4DAAFA194424FD8846298633DDDFD82" + { + "SourcePath" = "8:..\\runtime\\Microsoft.VC90.CRT.manifest" + "TargetName" = "8:Microsoft.VC90.CRT.manifest" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_E8A50CBAE87C4B90AF32DD14043C96EF" + { + "SourcePath" = "8:..\\runtime\\msvcr120.dll" + "TargetName" = "8:msvcr120.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_ED79C9CCA49A4273BEB9BE0E803D96E2" + { + "SourcePath" = "8:..\\conf\\conf.txt" + "TargetName" = "8:conf.txt" + "Tag" = "8:" + "Folder" = "8:_239A93F3E45C4F6DA4C65C0DB3F8C12F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F37EC15BA95646B5803CAB142943EABE" + { + "SourcePath" = "8:..\\x64\\Release\\imageformats\\qgif.dll" + "TargetName" = "8:qgif.dll" + "Tag" = "8:" + "Folder" = "8:_88D75C144F0D46B3A05E8238E1FA0ADD" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F4686342729344769B8FB6D749B7568F" + { + "SourcePath" = "8:..\\runtime\\PylonCamEmu_v6_2_TL.dll" + "TargetName" = "8:PylonCamEmu_v6_2_TL.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F4EED7FC1D854494ADFEC8DC6BE478EA" + { + "SourcePath" = "8:..\\runtime\\Microsoft.VC90.DebugCRT.manifest" + "TargetName" = "8:Microsoft.VC90.DebugCRT.manifest" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F532F71D12E343CC8B08E9FF0A4724B1" + { + "SourcePath" = "8:..\\runtime\\MathParser_MD_VC120_v3_0_MVS_v3_1_0.dll" + "TargetName" = "8:MathParser_MD_VC120_v3_0_MVS_v3_1_0.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F57E0941D3FF4ACBBC116630C38B8001" + { + "SourcePath" = "8:..\\x64\\Release\\translations\\qt_zh_TW.qm" + "TargetName" = "8:qt_zh_TW.qm" + "Tag" = "8:" + "Folder" = "8:_26254A3A76994EF0BCB9452605DE9A8F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F8B2E5B1F6994416B9F4B98CE26573A3" + { + "SourcePath" = "8:..\\runtime\\uxtopapi_v6_2.dll" + "TargetName" = "8:uxtopapi_v6_2.dll" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FB7B48079FD54792A10AB104BD0B6082" + { + "SourcePath" = "8:..\\runtime\\PylonFirmwareUpdater.exe" + "TargetName" = "8:PylonFirmwareUpdater.exe" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:4" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FFE4F0E27B984E33AFE0BFF44A96FBDF" + { + "SourcePath" = "8:..\\runtime\\MvProducerGEV.cti" + "TargetName" = "8:MvProducerGEV.cti" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } + } + "FileType" + { + } + "Folder" + { + "{1525181F-901A-416C-8A58-119130FE478E}:_63D1C8C483C74C6091754AE8188284F9" + { + "Name" = "8:#1919" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:ProgramMenuFolder" + "Folders" + { + } + } + "{3C67513D-01DD-4637-8A68-80971EB9504F}:_78BA2173DD6245B2AB1F4241258745B9" + { + "DefaultLocation" = "8:[ProgramFilesFolder][Manufacturer]\\[ProductName]" + "Name" = "8:#1925" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:TARGETDIR" + "Folders" + { + "{9EF0B969-E518-4E46-987F-47570745A589}:_0699D201060A48998C77F36611B82669" + { + "Name" = "8:iconengines" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_9590BAFA76A245FEAFFE16F1DF2AA335" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_239A93F3E45C4F6DA4C65C0DB3F8C12F" + { + "Name" = "8:conf" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_F09AB0549FF042CFB48B8698B68A32A8" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_26254A3A76994EF0BCB9452605DE9A8F" + { + "Name" = "8:translations" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_2A5ADE3FF8A34C7486AC142174A3F74B" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_2D3CD59D2AAE416FA8423933EDAD2E70" + { + "Name" = "8:bearer" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_70F2C0FA0F1142A3B81578410D57617A" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_373EB007C6B04A998B88DE10784490BA" + { + "Name" = "8:styles" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_261C6D87E43947B5A7A63E78D730A886" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_88D75C144F0D46B3A05E8238E1FA0ADD" + { + "Name" = "8:imageformats" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_FB600A7CD3BC4C1FA7F07D39A7ECC419" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_8E9A69C221D743E89DA17E100C453FF9" + { + "Name" = "8:model" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_75153758A9794D65A552CAA7B9C156B6" + "Folders" + { + } + } + "{9EF0B969-E518-4E46-987F-47570745A589}:_B0BAE2CDE699435997CBCA9EE82FFC37" + { + "Name" = "8:platforms" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:_1B21032189B241829FF79482CCCB21A7" + "Folders" + { + } + } + } + } + "{1525181F-901A-416C-8A58-119130FE478E}:_AB17A98B06BB4C1786CD2407040619CF" + { + "Name" = "8:#1916" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:DesktopFolder" + "Folders" + { + } + } + } + "LaunchCondition" + { + } + "Locator" + { + } + "MsiBootstrapper" + { + "LangId" = "3:2052" + "RequiresElevation" = "11:FALSE" + } + "Product" + { + "Name" = "8:Microsoft Visual Studio" + "ProductName" = "8:Setup" + "ProductCode" = "8:{548EC9F5-7779-48BC-B7EF-BD6749EE2C07}" + "PackageCode" = "8:{3D87F604-593D-41B2-AD65-9D0DAF8B4152}" + "UpgradeCode" = "8:{F75A39AE-D6C9-4362-B09E-F8147DB31466}" + "AspNetVersion" = "8:2.0.50727.0" + "RestartWWWService" = "11:FALSE" + "RemovePreviousVersions" = "11:FALSE" + "DetectNewerInstalledVersion" = "11:TRUE" + "InstallAllUsers" = "11:FALSE" + "ProductVersion" = "8:1.0.0" + "Manufacturer" = "8:Default Company Name" + "ARPHELPTELEPHONE" = "8:" + "ARPHELPLINK" = "8:" + "Title" = "8:Setup" + "Subject" = "8:" + "ARPCONTACT" = "8:Default Company Name" + "Keywords" = "8:" + "ARPCOMMENTS" = "8:" + "ARPURLINFOABOUT" = "8:" + "ARPPRODUCTICON" = "8:" + "ARPIconIndex" = "3:0" + "SearchPath" = "8:" + "UseSystemSearchPath" = "11:TRUE" + "TargetPlatform" = "3:0" + "PreBuildEvent" = "8:" + "PostBuildEvent" = "8:" + "RunPostBuildEvent" = "3:0" + } + "Registry" + { + "HKLM" + { + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_F20F3D99C0F14FAF8BF6D5791E5F2993" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_EECD71C809DF4363ADD8F076A6870B61" + { + "Name" = "8:[Manufacturer]" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCU" + { + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_1AEC31645B3A4DF09CDB86DA494AFCE4" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_9762D8599DB5462C840C563F3D6193D5" + { + "Name" = "8:[Manufacturer]" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCR" + { + "Keys" + { + } + } + "HKU" + { + "Keys" + { + } + } + "HKPU" + { + "Keys" + { + } + } + } + "Sequences" + { + } + "Shortcut" + { + "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_44979574DC994FFF836220FFA3E70C43" + { + "Name" = "8:Shortcut to 主输出 from Cigarette (Active)" + "Arguments" = "8:" + "Description" = "8:" + "ShowCmd" = "3:1" + "IconIndex" = "3:0" + "Transitive" = "11:FALSE" + "Target" = "8:_63014E6D55824C8390E2787EAE62A763" + "Folder" = "8:_AB17A98B06BB4C1786CD2407040619CF" + "WorkingFolder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Icon" = "8:" + "Feature" = "8:" + } + } + "UserInterface" + { + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_3F3F6ED693E74EE1AB729EE611321B75" + { + "Name" = "8:#1901" + "Sequence" = "3:1" + "Attributes" = "3:2" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_CD3646ACD4BF4977B79D079D77D1C8AE" + { + "Sequence" = "3:100" + "DisplayName" = "8:进度" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_54F6AE90A50242FAA79AA9F38F01784A" + { + "Name" = "8:#1901" + "Sequence" = "3:2" + "Attributes" = "3:2" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_AD9BA130282E4EE3A5D6CEC856972697" + { + "Sequence" = "3:100" + "DisplayName" = "8:进度" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_59B5654101BD4DB7B32197FB1C710C49" + { + "Name" = "8:#1900" + "Sequence" = "3:1" + "Attributes" = "3:1" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_7A309C7045D54B62889AE1C7ED21FD4C" + { + "Sequence" = "3:300" + "DisplayName" = "8:确认安装" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_AC3D7F673905417EBD17C300781F9FC7" + { + "Sequence" = "3:100" + "DisplayName" = "8:欢迎使用" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_AFEC3FEF0AF64552A89EDF4B9A93BC5D" + { + "Sequence" = "3:200" + "DisplayName" = "8:安装文件夹" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "InstallAllUsersVisible" + { + "Name" = "8:InstallAllUsersVisible" + "DisplayName" = "8:#1059" + "Description" = "8:#1159" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_687E202499EF44A1AE6701BED9C37BAE" + { + "Name" = "8:#1900" + "Sequence" = "3:2" + "Attributes" = "3:1" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_46A32DB3C8B34730B7BE02315D19359F" + { + "Sequence" = "3:100" + "DisplayName" = "8:欢迎使用" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_CF60FEC2B78C49BE9DCDA31B9F56430E" + { + "Sequence" = "3:300" + "DisplayName" = "8:确认安装" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_EF48FBD991514D21813EE60433DFA0AB" + { + "Sequence" = "3:200" + "DisplayName" = "8:安装文件夹" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_AD96024541134B3596C451DE667AEB96" + { + "Name" = "8:#1902" + "Sequence" = "3:2" + "Attributes" = "3:3" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_B76E4ECCD5F644A297A1450F31CD1D9D" + { + "Sequence" = "3:100" + "DisplayName" = "8:已完成" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_C376195DBA8D4D3F9E2244B1D2FBEA53" + { + "Name" = "8:#1902" + "Sequence" = "3:1" + "Attributes" = "3:3" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_53AF66605F6B458A9FD314F0B6B35151" + { + "Sequence" = "3:100" + "DisplayName" = "8:已完成" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "UpdateText" + { + "Name" = "8:UpdateText" + "DisplayName" = "8:#1058" + "Description" = "8:#1158" + "Type" = "3:15" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1258" + "DefaultValue" = "8:#1258" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_E3147A92161347CFB13040D15179910E" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdUserInterface.wim" + } + "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_EAAF039C6F1744D88F56DB6B848CB5A4" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdBasicDialogs.wim" + } + } + "MergeModule" + { + } + "ProjectOutput" + { + "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_63014E6D55824C8390E2787EAE62A763" + { + "SourcePath" = "8:..\\Win32\\Release\\Cigarette.exe" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_78BA2173DD6245B2AB1F4241258745B9" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + "ProjectOutputGroupRegister" = "3:1" + "OutputConfiguration" = "8:" + "OutputGroupCanonicalName" = "8:Built" + "OutputProjectGuid" = "8:{B12702AD-ABFB-343A-A199-8E24837244A3}" + "ShowKeyOutput" = "11:TRUE" + "ExcludeFilters" + { + } + } + } + } +} diff --git a/conf/conf.txt b/conf/conf.txt new file mode 100644 index 0000000..892ca0e --- /dev/null +++ b/conf/conf.txt @@ -0,0 +1,72 @@ +SAVE=0 +MISMATCHACT=1 +SAVE_DAYS=1 +FREESIZE=10 +AUTO_OPEN=1 +AUTO_WORK=1 +AUTO_SHIFT=0 +TIMING_SHIFT=1 +SHIFT_A=6|0 +SHIFT_B=12|0 +SHIFT_C=20|0 +LOCATION=CD TH +MODELPATH=D:/cameras8/0413/cigarette-8cameras/model/jd.weights +***************************************** +EXPO1=2500 +GAIN1=0 +FILTER1=500 +USERID1=0 +NO1=1|1|1 +SHOOT1=3 +***************************************** +EXPO2=2000 +GAIN2=0 +FILTER2=500 +USERID2=1 +NO2=1|1|1 +SHOOT2=3 +***************************************** +EXPO3=2000 +GAIN3=0 +FILTER3=500 +USERID3=2 +NO3=1|1|1 +SHOOT3=3 +***************************************** +EXPO4=2000 +GAIN4=0 +FILTER4=500 +USERID4=3 +NO4=1|1|1 +SHOOT4=3 +***************************************** +EXPO5=2000 +GAIN5=0 +FILTER5=500 +USERID5=255 +NO5=0|0|0 +SHOOT5=3 +***************************************** +EXPO6=2000 +GAIN6=0 +FILTER6=500 +USERID6=255 +NO6=0|0|0 +SHOOT6=3 +***************************************** +EXPO7=2000 +GAIN7=0 +FILTER7=500 +USERID7=255 +NO7=0|0|0 +SHOOT7=3 +***************************************** +EXPO8=2000 +GAIN8=0 +FILTER8=500 +USERID8=255 +NO8=0|0|0 +SHOOT8=3 +***************************************** +MonitorIP=192.168.10.139 +MonitorPort=3000 diff --git a/conf/modbus.txt b/conf/modbus.txt new file mode 100644 index 0000000..d8abd67 --- /dev/null +++ b/conf/modbus.txt @@ -0,0 +1,9 @@ +KICK1=46006 +KICK2=46006 +QUANTITY=46008 +SHIFT=30100 +WORK=30101 +NO_KICK=30102 +DEBUG=30103 +RESET=30104 +ALARM=46018 \ No newline at end of file diff --git a/conf/plc.txt b/conf/plc.txt new file mode 100644 index 0000000..a6c6edf --- /dev/null +++ b/conf/plc.txt @@ -0,0 +1,21 @@ +ʼ/ͣ|30101|0|1ʼ0ͣ +|46018|0|0ޱο +|46008|0|Сģʽ +|30100|0|д1 +1#޳|46006|0|1#޳ +1#У|47000|450| +1#У|47002|510|½ +1#1|47004|550| +1#1|47006|620|½ +1#2|47008|700| +1#2|47010|800|½ +1#3|47012|820| +1#3|47014|880|½ +2#У|47100|450| +2#У|47102|510|½ +2#1|47104|550| +2#1|47106|620|½ +2#2|47108|700| +2#2|47110|800|½ +2#3|47112|820| +2#3|47114|880|½ diff --git a/conf/rotate.txt b/conf/rotate.txt new file mode 100644 index 0000000..ee1035c --- /dev/null +++ b/conf/rotate.txt @@ -0,0 +1 @@ +0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3, \ No newline at end of file